From 4f6cc9ab5337879c4a79564b3aed4fa429d1cd12 Mon Sep 17 00:00:00 2001 From: Peng Tao Date: Mon, 15 Jul 2013 22:27:04 +0800 Subject: [PATCH 001/942] staging/lustre: replace num_physpages with totalram_pages The global variable num_physpages is going away. Replace it with totalram_pages. Cc: Jiang Liu Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../lustre/include/linux/libcfs/linux/linux-mem.h | 4 ++-- drivers/staging/lustre/lustre/ldlm/ldlm_lib.c | 10 +++++----- .../lustre/lustre/libcfs/linux/linux-tracefile.c | 2 +- drivers/staging/lustre/lustre/llite/lproc_llite.c | 8 ++++---- drivers/staging/lustre/lustre/obdclass/class_obd.c | 6 +++--- .../lustre/lustre/obdclass/linux/linux-sysctl.c | 6 +++--- drivers/staging/lustre/lustre/obdclass/lu_object.c | 2 +- drivers/staging/lustre/lustre/osc/lproc_osc.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c | 4 ++-- 10 files changed, 23 insertions(+), 23 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-mem.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-mem.h index 042a2bc432be5..63efb7b456c6e 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-mem.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-mem.h @@ -63,9 +63,9 @@ #if BITS_PER_LONG == 32 /* limit to lowmem on 32-bit systems */ #define NUM_CACHEPAGES \ - min(num_physpages, 1UL << (30 - PAGE_CACHE_SHIFT) * 3 / 4) + min(totalram_pages, 1UL << (30 - PAGE_CACHE_SHIFT) * 3 / 4) #else -#define NUM_CACHEPAGES num_physpages +#define NUM_CACHEPAGES totalram_pages #endif /* diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c index 42df53072dc3c..aace5342b76a6 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c @@ -339,8 +339,8 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg) cli->cl_avail_grant = 0; /* FIXME: Should limit this for the sum of all cl_dirty_max. */ cli->cl_dirty_max = OSC_MAX_DIRTY_DEFAULT * 1024 * 1024; - if (cli->cl_dirty_max >> PAGE_CACHE_SHIFT > num_physpages / 8) - cli->cl_dirty_max = num_physpages << (PAGE_CACHE_SHIFT - 3); + if (cli->cl_dirty_max >> PAGE_CACHE_SHIFT > totalram_pages / 8) + cli->cl_dirty_max = totalram_pages << (PAGE_CACHE_SHIFT - 3); INIT_LIST_HEAD(&cli->cl_cache_waiters); INIT_LIST_HEAD(&cli->cl_loi_ready_list); INIT_LIST_HEAD(&cli->cl_loi_hp_ready_list); @@ -388,11 +388,11 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg) if (!strcmp(name, LUSTRE_MDC_NAME)) { cli->cl_max_rpcs_in_flight = MDC_MAX_RIF_DEFAULT; - } else if (num_physpages >> (20 - PAGE_CACHE_SHIFT) <= 128 /* MB */) { + } else if (totalram_pages >> (20 - PAGE_CACHE_SHIFT) <= 128 /* MB */) { cli->cl_max_rpcs_in_flight = 2; - } else if (num_physpages >> (20 - PAGE_CACHE_SHIFT) <= 256 /* MB */) { + } else if (totalram_pages >> (20 - PAGE_CACHE_SHIFT) <= 256 /* MB */) { cli->cl_max_rpcs_in_flight = 3; - } else if (num_physpages >> (20 - PAGE_CACHE_SHIFT) <= 512 /* MB */) { + } else if (totalram_pages >> (20 - PAGE_CACHE_SHIFT) <= 512 /* MB */) { cli->cl_max_rpcs_in_flight = 4; } else { if (osc_on_mdt(obddev->obd_name)) diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c index 6f563436a2553..a500a0b5ba9f4 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c @@ -269,7 +269,7 @@ void cfs_print_to_console(struct ptldebug_header *hdr, int mask, int cfs_trace_max_debug_mb(void) { - int total_mb = (num_physpages >> (20 - PAGE_SHIFT)); + int total_mb = (totalram_pages >> (20 - PAGE_SHIFT)); return MAX(512, (total_mb * 80)/100); } diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 6a82505c7933d..a30c411b583bc 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -243,9 +243,9 @@ static ssize_t ll_max_readahead_mb_seq_write(struct file *file, const char *buff if (rc) return rc; - if (pages_number < 0 || pages_number > num_physpages / 2) { + if (pages_number < 0 || pages_number > totalram_pages / 2) { CERROR("can't set file readahead more than %lu MB\n", - num_physpages >> (20 - PAGE_CACHE_SHIFT + 1)); /*1/2 of RAM*/ + totalram_pages >> (20 - PAGE_CACHE_SHIFT + 1)); /*1/2 of RAM*/ return -ERANGE; } @@ -388,10 +388,10 @@ static ssize_t ll_max_cached_mb_seq_write(struct file *file, const char *buffer, if (rc) RETURN(rc); - if (pages_number < 0 || pages_number > num_physpages) { + if (pages_number < 0 || pages_number > totalram_pages) { CERROR("%s: can't set max cache more than %lu MB\n", ll_get_fsname(sb, NULL, 0), - num_physpages >> (20 - PAGE_CACHE_SHIFT)); + totalram_pages >> (20 - PAGE_CACHE_SHIFT)); RETURN(-ERANGE); } diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c index af1c2d09c47b2..0715cf2af3ce5 100644 --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c @@ -558,10 +558,10 @@ static int __init init_obdclass(void) /* Default the dirty page cache cap to 1/2 of system memory. * For clients with less memory, a larger fraction is needed * for other purposes (mostly for BGL). */ - if (num_physpages <= 512 << (20 - PAGE_CACHE_SHIFT)) - obd_max_dirty_pages = num_physpages / 4; + if (totalram_pages <= 512 << (20 - PAGE_CACHE_SHIFT)) + obd_max_dirty_pages = totalram_pages / 4; else - obd_max_dirty_pages = num_physpages / 2; + obd_max_dirty_pages = totalram_pages / 2; err = obd_init_caches(); if (err) diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c index 46aad6813cab0..7b94cb7b58e04 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c @@ -202,12 +202,12 @@ int LL_PROC_PROTO(proc_max_dirty_pages_in_mb) 1 << (20 - PAGE_CACHE_SHIFT)); /* Don't allow them to let dirty pages exceed 90% of system * memory and set a hard minimum of 4MB. */ - if (obd_max_dirty_pages > ((num_physpages / 10) * 9)) { + if (obd_max_dirty_pages > ((totalram_pages / 10) * 9)) { CERROR("Refusing to set max dirty pages to %u, which " "is more than 90%% of available RAM; setting " "to %lu\n", obd_max_dirty_pages, - ((num_physpages / 10) * 9)); - obd_max_dirty_pages = ((num_physpages / 10) * 9); + ((totalram_pages / 10) * 9)); + obd_max_dirty_pages = ((totalram_pages / 10) * 9); } else if (obd_max_dirty_pages < 4 << (20 - PAGE_CACHE_SHIFT)) { obd_max_dirty_pages = 4 << (20 - PAGE_CACHE_SHIFT); } diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c index fdf0ed3676939..fdaf4f8c33497 100644 --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c @@ -849,7 +849,7 @@ static int lu_htable_order(void) * * Size of lu_object is (arbitrary) taken as 1K (together with inode). */ - cache_size = num_physpages; + cache_size = totalram_pages; #if BITS_PER_LONG == 32 /* limit hashtable size for lowmem systems to low RAM */ diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c index 198cf3ba1374c..d2f219877927d 100644 --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c @@ -146,7 +146,7 @@ static ssize_t osc_max_dirty_mb_seq_write(struct file *file, const char *buffer, if (pages_number <= 0 || pages_number > OSC_MAX_DIRTY_MB_MAX << (20 - PAGE_CACHE_SHIFT) || - pages_number > num_physpages / 4) /* 1/4 of RAM */ + pages_number > totalram_pages / 4) /* 1/4 of RAM */ return -ERANGE; client_obd_list_lock(&cli->cl_loi_list_lock); diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c index 3e7325499d016..2bd0d985bf1d2 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c @@ -302,7 +302,7 @@ ptlrpc_lprocfs_req_history_max_seq_write(struct file *file, const char *buffer, * hose a kernel by allowing the request history to grow too * far. */ bufpages = (svc->srv_buf_size + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; - if (val > num_physpages/(2 * bufpages)) + if (val > totalram_pages / (2 * bufpages)) return -ERANGE; spin_lock(&svc->srv_lock); diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c index bf53f1bc17422..9013745ab1059 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c @@ -156,7 +156,7 @@ int sptlrpc_proc_enc_pool_seq_show(struct seq_file *m, void *v) "max waitqueue depth: %u\n" "max wait time: "CFS_TIME_T"/%u\n" , - num_physpages, + totalram_pages, PAGES_PER_POOL, page_pools.epp_max_pages, page_pools.epp_max_pools, @@ -705,7 +705,7 @@ int sptlrpc_enc_pool_init(void) * maximum capacity is 1/8 of total physical memory. * is the 1/8 a good number? */ - page_pools.epp_max_pages = num_physpages / 8; + page_pools.epp_max_pages = totalram_pages / 8; page_pools.epp_max_pools = npages_to_npools(page_pools.epp_max_pages); init_waitqueue_head(&page_pools.epp_waitq); -- GitLab From eba32e16374beb2f479bbbf37dfa8fcf785bac3f Mon Sep 17 00:00:00 2001 From: Peng Tao Date: Mon, 15 Jul 2013 22:27:05 +0800 Subject: [PATCH 002/942] staging/lustre: fix Lustre code link order Change Makefiles to keep link order in match with Lustre module dependency, so that when Lustre is built in kernel, we'll have the same dependency. Otherwise we'll crash kernel if Lustre is builtin due to missing internal dependency. Reported-by: Fengguang Wu Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/Makefile | 2 +- drivers/staging/lustre/lnet/Makefile | 2 +- drivers/staging/lustre/lustre/Makefile | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/lustre/Makefile b/drivers/staging/lustre/Makefile index 26162893fd206..fb0e0faf07604 100644 --- a/drivers/staging/lustre/Makefile +++ b/drivers/staging/lustre/Makefile @@ -1,4 +1,4 @@ subdir-ccflags-y := -I$(src)/include/ -obj-$(CONFIG_LUSTRE_FS) += lustre/ obj-$(CONFIG_LNET) += lnet/ +obj-$(CONFIG_LUSTRE_FS) += lustre/ diff --git a/drivers/staging/lustre/lnet/Makefile b/drivers/staging/lustre/lnet/Makefile index 374212b1555af..f6f03e304d81f 100644 --- a/drivers/staging/lustre/lnet/Makefile +++ b/drivers/staging/lustre/lnet/Makefile @@ -1 +1 @@ -obj-$(CONFIG_LNET) := klnds/ lnet/ selftest/ +obj-$(CONFIG_LNET) += lnet/ klnds/ selftest/ diff --git a/drivers/staging/lustre/lustre/Makefile b/drivers/staging/lustre/lustre/Makefile index 3fb94fc12068b..d1eb0bdef06b2 100644 --- a/drivers/staging/lustre/lustre/Makefile +++ b/drivers/staging/lustre/lustre/Makefile @@ -1,2 +1,2 @@ -obj-$(CONFIG_LUSTRE_FS) := fid/ lvfs/ obdclass/ ptlrpc/ obdecho/ mgc/ lov/ \ - osc/ mdc/ lmv/ llite/ fld/ libcfs/ +obj-$(CONFIG_LUSTRE_FS) += libcfs/ lvfs/ obdclass/ ptlrpc/ fld/ osc/ mgc/ \ + fid/ lov/ mdc/ lmv/ llite/ obdecho/ -- GitLab From 4d2d6e29a8d56bd05cc7ea30ddfb4d3f75290cfe Mon Sep 17 00:00:00 2001 From: Peng Tao Date: Mon, 15 Jul 2013 22:27:06 +0800 Subject: [PATCH 003/942] staging/lustre: don't assert module owner It can well be NULL if Lustre is builtin. Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/obdclass/lu_object.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c index fdaf4f8c33497..5559732c0437e 100644 --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c @@ -1315,7 +1315,6 @@ int lu_context_key_register(struct lu_context_key *key) LASSERT(key->lct_init != NULL); LASSERT(key->lct_fini != NULL); LASSERT(key->lct_tags != 0); - LASSERT(key->lct_owner != NULL); result = -ENFILE; spin_lock(&lu_keys_guard); @@ -1349,7 +1348,6 @@ static void key_fini(struct lu_context *ctx, int index) lu_ref_del(&key->lct_reference, "ctx", ctx); atomic_dec(&key->lct_used); - LASSERT(key->lct_owner != NULL); if ((ctx->lc_tags & LCT_NOREF) == 0) { #ifdef CONFIG_MODULE_UNLOAD LINVRNT(module_refcount(key->lct_owner) > 0); @@ -1557,7 +1555,6 @@ static int keys_fill(struct lu_context *ctx) if (unlikely(IS_ERR(value))) return PTR_ERR(value); - LASSERT(key->lct_owner != NULL); if (!(ctx->lc_tags & LCT_NOREF)) try_module_get(key->lct_owner); lu_ref_add_atomic(&key->lct_reference, "ctx", ctx); -- GitLab From 4b1e84ed8883d4f24f99417cb84165ff77a99d66 Mon Sep 17 00:00:00 2001 From: Peng Tao Date: Mon, 15 Jul 2013 22:27:07 +0800 Subject: [PATCH 004/942] staging/lustre: don't assert ln_refcount in LNetGetId If LNetNIInit() fails, we'll get zero ln_refcount. So fail LNetGetId() properly instead of asserting. We can get to it when socklnd fails to scan network interfaces, which is possible if Lustre is builtin. Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/lnet/api-ni.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index e88bee3624973..250c618687041 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -1541,7 +1541,10 @@ LNetGetId(unsigned int index, lnet_process_id_t *id) int rc = -ENOENT; LASSERT(the_lnet.ln_init); - LASSERT(the_lnet.ln_refcount > 0); + + /* LNetNI initilization failed? */ + if (the_lnet.ln_refcount == 0) + return rc; cpt = lnet_net_lock_current(); -- GitLab From c1042ed805e5c8829e0b60d4c7722b5099da40c9 Mon Sep 17 00:00:00 2001 From: Peng Tao Date: Mon, 15 Jul 2013 22:27:08 +0800 Subject: [PATCH 005/942] stating/lustre: only build if configured as module Lustre internal dependency needs to be cleaned up. Currently, libcfs is acting as a basis of all other modules, while other modules in lustre/ directory in turn depend on lnet modules. It creates a dependency loop that need to be fixed. Hopefully we will remove libcfs in the end. So just disable buildin for now. Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/Kconfig b/drivers/staging/lustre/lustre/Kconfig index e0eb8303a50c7..c59ea5564c241 100644 --- a/drivers/staging/lustre/lustre/Kconfig +++ b/drivers/staging/lustre/lustre/Kconfig @@ -1,6 +1,6 @@ config LUSTRE_FS tristate "Lustre file system client support" - depends on STAGING && INET && BROKEN + depends on STAGING && INET && m && BROKEN select LNET select CRYPTO select CRYPTO_CRC32 -- GitLab From 5e8f6920eb2af88e101a1b1fc0f5fb829fe2d799 Mon Sep 17 00:00:00 2001 From: Peng Tao Date: Mon, 15 Jul 2013 22:27:09 +0800 Subject: [PATCH 006/942] staging/lustre: remove HIPQUAD Stephen Rothwell reported below error on powerpc: In file included from drivers/staging/lustre/include/linux/libcfs/libcfs.h:203:0, from drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h:67, from drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c:41: drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c: In function 'kiblnd_dev_need_failover': drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h:215:16: error: implicit declaration of function 'NIPQUAD' [-Werror=implicit-function-declaration] static struct libcfs_debug_msg_data msgdata; \ ^ We should just remove HIPQUAD and replace it with %pI4h. Reported-by: Stephen Rothwell Cc: Joe Perches Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../include/linux/libcfs/linux/linux-tcpip.h | 15 --- .../lustre/lnet/klnds/o2iblnd/o2iblnd.c | 8 +- .../lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | 12 +-- .../lustre/lnet/klnds/socklnd/socklnd.c | 50 +++++----- .../lustre/lnet/klnds/socklnd/socklnd_cb.c | 94 +++++++++---------- .../lustre/lnet/klnds/socklnd/socklnd_proto.c | 60 ++++++------ drivers/staging/lustre/lnet/lnet/acceptor.c | 62 ++++++------ .../lustre/lustre/libcfs/linux/linux-tcpip.c | 4 +- 8 files changed, 145 insertions(+), 160 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-tcpip.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-tcpip.h index 687f33f4e8a7a..7a8d006903b90 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-tcpip.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-tcpip.h @@ -48,21 +48,6 @@ #include -#ifndef HIPQUAD -// XXX Should just kill all users -#if defined(__LITTLE_ENDIAN) -#define HIPQUAD(addr) \ - ((unsigned char *)&addr)[3], \ - ((unsigned char *)&addr)[2], \ - ((unsigned char *)&addr)[1], \ - ((unsigned char *)&addr)[0] -#elif defined(__BIG_ENDIAN) -#define HIPQUAD NIPQUAD -#else -#error "Please fix asm/byteorder.h" -#endif /* __LITTLE_ENDIAN */ -#endif - typedef struct socket socket_t; #define SOCK_SNDBUF(so) ((so)->sk->sk_sndbuf) diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c index 29a97943e4c76..eb6b66aa1ab39 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c @@ -2574,8 +2574,8 @@ kiblnd_dev_need_failover(kib_dev_t *dev) rc = rdma_resolve_addr(cmid, (struct sockaddr *)&srcaddr, (struct sockaddr *)&dstaddr, 1); if (rc != 0 || cmid->device == NULL) { - CERROR("Failed to bind %s:%u.%u.%u.%u to device(%p): %d\n", - dev->ibd_ifname, HIPQUAD(dev->ibd_ifip), + CERROR("Failed to bind %s:%pI4h to device(%p): %d\n", + dev->ibd_ifname, &dev->ibd_ifip, cmid->device, rc); rdma_destroy_id(cmid); return rc; @@ -2647,8 +2647,8 @@ kiblnd_dev_failover(kib_dev_t *dev) /* Bind to failover device or port */ rc = rdma_bind_addr(cmid, (struct sockaddr *)&addr); if (rc != 0 || cmid->device == NULL) { - CERROR("Failed to bind %s:%u.%u.%u.%u to device(%p): %d\n", - dev->ibd_ifname, HIPQUAD(dev->ibd_ifip), + CERROR("Failed to bind %s:%pI4h to device(%p): %d\n", + dev->ibd_ifname, &dev->ibd_ifip, cmid->device, rc); rdma_destroy_id(cmid); goto out; diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c index cc6232126dd0e..63a4258ac2615 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c @@ -1319,9 +1319,9 @@ kiblnd_connect_peer (kib_peer_t *peer) } LASSERT (cmid->device != NULL); - CDEBUG(D_NET, "%s: connection bound to %s:%u.%u.%u.%u:%s\n", + CDEBUG(D_NET, "%s: connection bound to %s:%pI4h:%s\n", libcfs_nid2str(peer->ibp_nid), dev->ibd_ifname, - HIPQUAD(dev->ibd_ifip), cmid->device->name); + &dev->ibd_ifip, cmid->device->name); return; @@ -2209,8 +2209,8 @@ kiblnd_passive_connect (struct rdma_cm_id *cmid, void *priv, int priv_nob) if (*kiblnd_tunables.kib_require_priv_port && ntohs(peer_addr->sin_port) >= PROT_SOCK) { __u32 ip = ntohl(peer_addr->sin_addr.s_addr); - CERROR("Peer's port (%u.%u.%u.%u:%hu) is not privileged\n", - HIPQUAD(ip), ntohs(peer_addr->sin_port)); + CERROR("Peer's port (%pI4h:%hu) is not privileged\n", + &ip, ntohs(peer_addr->sin_port)); goto failed; } @@ -2254,11 +2254,11 @@ kiblnd_passive_connect (struct rdma_cm_id *cmid, void *priv, int priv_nob) if (ni == NULL || /* no matching net */ ni->ni_nid != reqmsg->ibm_dstnid || /* right NET, wrong NID! */ net->ibn_dev != ibdev) { /* wrong device */ - CERROR("Can't accept %s on %s (%s:%d:%u.%u.%u.%u): " + CERROR("Can't accept %s on %s (%s:%d:%pI4h): " "bad dst nid %s\n", libcfs_nid2str(nid), ni == NULL ? "NA" : libcfs_nid2str(ni->ni_nid), ibdev->ibd_ifname, ibdev->ibd_nnets, - HIPQUAD(ibdev->ibd_ifip), + &ibdev->ibd_ifip, libcfs_nid2str(reqmsg->ibm_dstnid)); goto failed; diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c index c826bf9d49ac8..d7b01e78ed7af 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c @@ -334,17 +334,17 @@ ksocknal_associate_route_conn_locked(ksock_route_t *route, ksock_conn_t *conn) if (route->ksnr_myipaddr != conn->ksnc_myipaddr) { if (route->ksnr_myipaddr == 0) { /* route wasn't bound locally yet (the initial route) */ - CDEBUG(D_NET, "Binding %s %u.%u.%u.%u to %u.%u.%u.%u\n", + CDEBUG(D_NET, "Binding %s %pI4h to %pI4h\n", libcfs_id2str(peer->ksnp_id), - HIPQUAD(route->ksnr_ipaddr), - HIPQUAD(conn->ksnc_myipaddr)); + &route->ksnr_ipaddr, + &conn->ksnc_myipaddr); } else { - CDEBUG(D_NET, "Rebinding %s %u.%u.%u.%u from " - "%u.%u.%u.%u to %u.%u.%u.%u\n", + CDEBUG(D_NET, "Rebinding %s %pI4h from " + "%pI4h to %pI4h\n", libcfs_id2str(peer->ksnp_id), - HIPQUAD(route->ksnr_ipaddr), - HIPQUAD(route->ksnr_myipaddr), - HIPQUAD(conn->ksnc_myipaddr)); + &route->ksnr_ipaddr, + &route->ksnr_myipaddr, + &conn->ksnc_myipaddr); iface = ksocknal_ip2iface(route->ksnr_peer->ksnp_ni, route->ksnr_myipaddr); @@ -384,9 +384,9 @@ ksocknal_add_route_locked (ksock_peer_t *peer, ksock_route_t *route) route2 = list_entry(tmp, ksock_route_t, ksnr_list); if (route2->ksnr_ipaddr == route->ksnr_ipaddr) { - CERROR ("Duplicate route %s %u.%u.%u.%u\n", + CERROR("Duplicate route %s %pI4h\n", libcfs_id2str(peer->ksnp_id), - HIPQUAD(route->ksnr_ipaddr)); + &route->ksnr_ipaddr); LBUG(); } } @@ -982,8 +982,8 @@ ksocknal_accept (lnet_ni_t *ni, socket_t *sock) LIBCFS_ALLOC(cr, sizeof(*cr)); if (cr == NULL) { LCONSOLE_ERROR_MSG(0x12f, "Dropping connection request from " - "%u.%u.%u.%u: memory exhausted\n", - HIPQUAD(peer_ip)); + "%pI4h: memory exhausted\n", + &peer_ip); return -ENOMEM; } @@ -1236,10 +1236,10 @@ ksocknal_create_conn (lnet_ni_t *ni, ksock_route_t *route, * code below probably isn't going to work. */ if (active && route->ksnr_ipaddr != conn->ksnc_ipaddr) { - CERROR("Route %s %u.%u.%u.%u connected to %u.%u.%u.%u\n", + CERROR("Route %s %pI4h connected to %pI4h\n", libcfs_id2str(peer->ksnp_id), - HIPQUAD(route->ksnr_ipaddr), - HIPQUAD(conn->ksnc_ipaddr)); + &route->ksnr_ipaddr, + &conn->ksnc_ipaddr); } /* Search for a route corresponding to the new connection and @@ -1297,10 +1297,10 @@ ksocknal_create_conn (lnet_ni_t *ni, ksock_route_t *route, * socket callbacks. */ - CDEBUG(D_NET, "New conn %s p %d.x %u.%u.%u.%u -> %u.%u.%u.%u/%d" + CDEBUG(D_NET, "New conn %s p %d.x %pI4h -> %pI4h/%d" " incarnation:"LPD64" sched[%d:%d]\n", libcfs_id2str(peerid), conn->ksnc_proto->pro_version, - HIPQUAD(conn->ksnc_myipaddr), HIPQUAD(conn->ksnc_ipaddr), + &conn->ksnc_myipaddr, &conn->ksnc_ipaddr, conn->ksnc_port, incarnation, cpt, (int)(sched - &sched->kss_info->ksi_scheds[0])); @@ -1648,10 +1648,10 @@ ksocknal_destroy_conn (ksock_conn_t *conn) last_rcv = conn->ksnc_rx_deadline - cfs_time_seconds(*ksocknal_tunables.ksnd_timeout); CERROR("Completing partial receive from %s[%d]" - ", ip %d.%d.%d.%d:%d, with error, wanted: %d, left: %d, " + ", ip %pI4h:%d, with error, wanted: %d, left: %d, " "last alive is %ld secs ago\n", libcfs_id2str(conn->ksnc_peer->ksnp_id), conn->ksnc_type, - HIPQUAD(conn->ksnc_ipaddr), conn->ksnc_port, + &conn->ksnc_ipaddr, conn->ksnc_port, conn->ksnc_rx_nob_wanted, conn->ksnc_rx_nob_left, cfs_duration_sec(cfs_time_sub(cfs_time_current(), last_rcv))); @@ -1661,25 +1661,25 @@ ksocknal_destroy_conn (ksock_conn_t *conn) case SOCKNAL_RX_LNET_HEADER: if (conn->ksnc_rx_started) CERROR("Incomplete receive of lnet header from %s" - ", ip %d.%d.%d.%d:%d, with error, protocol: %d.x.\n", + ", ip %pI4h:%d, with error, protocol: %d.x.\n", libcfs_id2str(conn->ksnc_peer->ksnp_id), - HIPQUAD(conn->ksnc_ipaddr), conn->ksnc_port, + &conn->ksnc_ipaddr, conn->ksnc_port, conn->ksnc_proto->pro_version); break; case SOCKNAL_RX_KSM_HEADER: if (conn->ksnc_rx_started) CERROR("Incomplete receive of ksock message from %s" - ", ip %d.%d.%d.%d:%d, with error, protocol: %d.x.\n", + ", ip %pI4h:%d, with error, protocol: %d.x.\n", libcfs_id2str(conn->ksnc_peer->ksnp_id), - HIPQUAD(conn->ksnc_ipaddr), conn->ksnc_port, + &conn->ksnc_ipaddr, conn->ksnc_port, conn->ksnc_proto->pro_version); break; case SOCKNAL_RX_SLOP: if (conn->ksnc_rx_started) CERROR("Incomplete receive of slops from %s" - ", ip %d.%d.%d.%d:%d, with error\n", + ", ip %pI4h:%d, with error\n", libcfs_id2str(conn->ksnc_peer->ksnp_id), - HIPQUAD(conn->ksnc_ipaddr), conn->ksnc_port); + &conn->ksnc_ipaddr, conn->ksnc_port); break; default: LBUG (); diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c index ad5e24104238a..a3b8f77399bad 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c @@ -553,21 +553,21 @@ ksocknal_process_transmit (ksock_conn_t *conn, ksock_tx_t *tx) if (!conn->ksnc_closing) { switch (rc) { case -ECONNRESET: - LCONSOLE_WARN("Host %u.%u.%u.%u reset our connection " + LCONSOLE_WARN("Host %pI4h reset our connection " "while we were sending data; it may have " "rebooted.\n", - HIPQUAD(conn->ksnc_ipaddr)); + &conn->ksnc_ipaddr); break; default: LCONSOLE_WARN("There was an unexpected network error " - "while writing to %u.%u.%u.%u: %d.\n", - HIPQUAD(conn->ksnc_ipaddr), rc); + "while writing to %pI4h: %d.\n", + &conn->ksnc_ipaddr, rc); break; } CDEBUG(D_NET, "[%p] Error %d on write to %s" - " ip %d.%d.%d.%d:%d\n", conn, rc, + " ip %pI4h:%d\n", conn, rc, libcfs_id2str(conn->ksnc_peer->ksnp_id), - HIPQUAD(conn->ksnc_ipaddr), + &conn->ksnc_ipaddr, conn->ksnc_port); } @@ -700,9 +700,9 @@ ksocknal_queue_tx_locked (ksock_tx_t *tx, ksock_conn_t *conn) * ksnc_sock... */ LASSERT(!conn->ksnc_closing); - CDEBUG (D_NET, "Sending to %s ip %d.%d.%d.%d:%d\n", + CDEBUG(D_NET, "Sending to %s ip %pI4h:%d\n", libcfs_id2str(conn->ksnc_peer->ksnp_id), - HIPQUAD(conn->ksnc_ipaddr), + &conn->ksnc_ipaddr, conn->ksnc_port); ksocknal_tx_prep(conn, tx); @@ -801,9 +801,9 @@ ksocknal_find_connectable_route_locked (ksock_peer_t *peer) if (!(route->ksnr_retry_interval == 0 || /* first attempt */ cfs_time_aftereq(now, route->ksnr_timeout))) { CDEBUG(D_NET, - "Too soon to retry route %u.%u.%u.%u " + "Too soon to retry route %pI4h " "(cnted %d, interval %ld, %ld secs later)\n", - HIPQUAD(route->ksnr_ipaddr), + &route->ksnr_ipaddr, route->ksnr_connected, route->ksnr_retry_interval, cfs_duration_sec(route->ksnr_timeout - now)); @@ -1133,17 +1133,17 @@ ksocknal_process_receive (ksock_conn_t *conn) LASSERT (rc != -EAGAIN); if (rc == 0) - CDEBUG (D_NET, "[%p] EOF from %s" - " ip %d.%d.%d.%d:%d\n", conn, + CDEBUG(D_NET, "[%p] EOF from %s" + " ip %pI4h:%d\n", conn, libcfs_id2str(conn->ksnc_peer->ksnp_id), - HIPQUAD(conn->ksnc_ipaddr), + &conn->ksnc_ipaddr, conn->ksnc_port); else if (!conn->ksnc_closing) - CERROR ("[%p] Error %d on read from %s" - " ip %d.%d.%d.%d:%d\n", + CERROR("[%p] Error %d on read from %s" + " ip %pI4h:%d\n", conn, rc, libcfs_id2str(conn->ksnc_peer->ksnp_id), - HIPQUAD(conn->ksnc_ipaddr), + &conn->ksnc_ipaddr, conn->ksnc_port); /* it's not an error if conn is being closed */ @@ -1722,8 +1722,8 @@ ksocknal_recv_hello (lnet_ni_t *ni, ksock_conn_t *conn, rc = libcfs_sock_read(sock, &hello->kshm_magic, sizeof (hello->kshm_magic), timeout); if (rc != 0) { - CERROR ("Error %d reading HELLO from %u.%u.%u.%u\n", - rc, HIPQUAD(conn->ksnc_ipaddr)); + CERROR("Error %d reading HELLO from %pI4h\n", + rc, &conn->ksnc_ipaddr); LASSERT (rc < 0); return rc; } @@ -1732,18 +1732,18 @@ ksocknal_recv_hello (lnet_ni_t *ni, ksock_conn_t *conn, hello->kshm_magic != __swab32(LNET_PROTO_MAGIC) && hello->kshm_magic != le32_to_cpu (LNET_PROTO_TCP_MAGIC)) { /* Unexpected magic! */ - CERROR ("Bad magic(1) %#08x (%#08x expected) from " - "%u.%u.%u.%u\n", __cpu_to_le32 (hello->kshm_magic), + CERROR("Bad magic(1) %#08x (%#08x expected) from " + "%pI4h\n", __cpu_to_le32 (hello->kshm_magic), LNET_PROTO_TCP_MAGIC, - HIPQUAD(conn->ksnc_ipaddr)); + &conn->ksnc_ipaddr); return -EPROTO; } rc = libcfs_sock_read(sock, &hello->kshm_version, sizeof(hello->kshm_version), timeout); if (rc != 0) { - CERROR ("Error %d reading HELLO from %u.%u.%u.%u\n", - rc, HIPQUAD(conn->ksnc_ipaddr)); + CERROR("Error %d reading HELLO from %pI4h\n", + rc, &conn->ksnc_ipaddr); LASSERT (rc < 0); return rc; } @@ -1763,10 +1763,10 @@ ksocknal_recv_hello (lnet_ni_t *ni, ksock_conn_t *conn, ksocknal_send_hello(ni, conn, ni->ni_nid, hello); } - CERROR ("Unknown protocol version (%d.x expected)" - " from %u.%u.%u.%u\n", + CERROR("Unknown protocol version (%d.x expected)" + " from %pI4h\n", conn->ksnc_proto->pro_version, - HIPQUAD(conn->ksnc_ipaddr)); + &conn->ksnc_ipaddr); return -EPROTO; } @@ -1777,8 +1777,8 @@ ksocknal_recv_hello (lnet_ni_t *ni, ksock_conn_t *conn, /* receive the rest of hello message anyway */ rc = conn->ksnc_proto->pro_recv_hello(conn, hello, timeout); if (rc != 0) { - CERROR("Error %d reading or checking hello from from %u.%u.%u.%u\n", - rc, HIPQUAD(conn->ksnc_ipaddr)); + CERROR("Error %d reading or checking hello from from %pI4h\n", + rc, &conn->ksnc_ipaddr); LASSERT (rc < 0); return rc; } @@ -1787,7 +1787,7 @@ ksocknal_recv_hello (lnet_ni_t *ni, ksock_conn_t *conn, if (hello->kshm_src_nid == LNET_NID_ANY) { CERROR("Expecting a HELLO hdr with a NID, but got LNET_NID_ANY" - "from %u.%u.%u.%u\n", HIPQUAD(conn->ksnc_ipaddr)); + "from %pI4h\n", &conn->ksnc_ipaddr); return -EPROTO; } @@ -1807,9 +1807,9 @@ ksocknal_recv_hello (lnet_ni_t *ni, ksock_conn_t *conn, /* peer determines type */ conn->ksnc_type = ksocknal_invert_type(hello->kshm_ctype); if (conn->ksnc_type == SOCKLND_CONN_NONE) { - CERROR ("Unexpected type %d from %s ip %u.%u.%u.%u\n", + CERROR("Unexpected type %d from %s ip %pI4h\n", hello->kshm_ctype, libcfs_id2str(*peerid), - HIPQUAD(conn->ksnc_ipaddr)); + &conn->ksnc_ipaddr); return -EPROTO; } @@ -1819,11 +1819,11 @@ ksocknal_recv_hello (lnet_ni_t *ni, ksock_conn_t *conn, if (peerid->pid != recv_id.pid || peerid->nid != recv_id.nid) { LCONSOLE_ERROR_MSG(0x130, "Connected successfully to %s on host" - " %u.%u.%u.%u, but they claimed they were " + " %pI4h, but they claimed they were " "%s; please check your Lustre " "configuration.\n", libcfs_id2str(*peerid), - HIPQUAD(conn->ksnc_ipaddr), + &conn->ksnc_ipaddr, libcfs_id2str(recv_id)); return -EPROTO; } @@ -1834,9 +1834,9 @@ ksocknal_recv_hello (lnet_ni_t *ni, ksock_conn_t *conn, } if (ksocknal_invert_type(hello->kshm_ctype) != conn->ksnc_type) { - CERROR ("Mismatched types: me %d, %s ip %u.%u.%u.%u %d\n", + CERROR("Mismatched types: me %d, %s ip %pI4h %d\n", conn->ksnc_type, libcfs_id2str(*peerid), - HIPQUAD(conn->ksnc_ipaddr), + &conn->ksnc_ipaddr, hello->kshm_ctype); return -EPROTO; } @@ -2208,8 +2208,8 @@ ksocknal_connd (void *arg) /* consecutive retry */ if (cons_retry++ > SOCKNAL_INSANITY_RECONN) { CWARN("massive consecutive " - "re-connecting to %u.%u.%u.%u\n", - HIPQUAD(route->ksnr_ipaddr)); + "re-connecting to %pI4h\n", + &route->ksnr_ipaddr); cons_retry = 0; } } else { @@ -2274,26 +2274,26 @@ ksocknal_find_timed_out_conn (ksock_peer_t *peer) switch (error) { case ECONNRESET: CNETERR("A connection with %s " - "(%u.%u.%u.%u:%d) was reset; " + "(%pI4h:%d) was reset; " "it may have rebooted.\n", libcfs_id2str(peer->ksnp_id), - HIPQUAD(conn->ksnc_ipaddr), + &conn->ksnc_ipaddr, conn->ksnc_port); break; case ETIMEDOUT: CNETERR("A connection with %s " - "(%u.%u.%u.%u:%d) timed out; the " + "(%pI4h:%d) timed out; the " "network or node may be down.\n", libcfs_id2str(peer->ksnp_id), - HIPQUAD(conn->ksnc_ipaddr), + &conn->ksnc_ipaddr, conn->ksnc_port); break; default: CNETERR("An unexpected network error %d " "occurred with %s " - "(%u.%u.%u.%u:%d\n", error, + "(%pI4h:%d\n", error, libcfs_id2str(peer->ksnp_id), - HIPQUAD(conn->ksnc_ipaddr), + &conn->ksnc_ipaddr, conn->ksnc_port); break; } @@ -2306,10 +2306,10 @@ ksocknal_find_timed_out_conn (ksock_peer_t *peer) conn->ksnc_rx_deadline)) { /* Timed out incomplete incoming message */ ksocknal_conn_addref(conn); - CNETERR("Timeout receiving from %s (%u.%u.%u.%u:%d), " + CNETERR("Timeout receiving from %s (%pI4h:%d), " "state %d wanted %d left %d\n", libcfs_id2str(peer->ksnp_id), - HIPQUAD(conn->ksnc_ipaddr), + &conn->ksnc_ipaddr, conn->ksnc_port, conn->ksnc_rx_state, conn->ksnc_rx_nob_wanted, @@ -2324,10 +2324,10 @@ ksocknal_find_timed_out_conn (ksock_peer_t *peer) /* Timed out messages queued for sending or * buffered in the socket's send buffer */ ksocknal_conn_addref(conn); - CNETERR("Timeout sending data to %s (%u.%u.%u.%u:%d) " + CNETERR("Timeout sending data to %s (%pI4h:%d) " "the network or that node may be down.\n", libcfs_id2str(peer->ksnp_id), - HIPQUAD(conn->ksnc_ipaddr), + &conn->ksnc_ipaddr, conn->ksnc_port); return (conn); } diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c index ec57179f8d2b2..6f7147dd36e58 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c @@ -496,8 +496,8 @@ ksocknal_send_hello_v1 (ksock_conn_t *conn, ksock_hello_msg_t *hello) rc = libcfs_sock_write(sock, hdr, sizeof(*hdr),lnet_acceptor_timeout()); if (rc != 0) { - CNETERR("Error %d sending HELLO hdr to %u.%u.%u.%u/%d\n", - rc, HIPQUAD(conn->ksnc_ipaddr), conn->ksnc_port); + CNETERR("Error %d sending HELLO hdr to %pI4h/%d\n", + rc, &conn->ksnc_ipaddr, conn->ksnc_port); goto out; } @@ -513,8 +513,8 @@ ksocknal_send_hello_v1 (ksock_conn_t *conn, ksock_hello_msg_t *hello) lnet_acceptor_timeout()); if (rc != 0) { CNETERR("Error %d sending HELLO payload (%d)" - " to %u.%u.%u.%u/%d\n", rc, hello->kshm_nips, - HIPQUAD(conn->ksnc_ipaddr), conn->ksnc_port); + " to %pI4h/%d\n", rc, hello->kshm_nips, + &conn->ksnc_ipaddr, conn->ksnc_port); } out: LIBCFS_FREE(hdr, sizeof(*hdr)); @@ -545,8 +545,8 @@ ksocknal_send_hello_v2 (ksock_conn_t *conn, ksock_hello_msg_t *hello) lnet_acceptor_timeout()); if (rc != 0) { - CNETERR("Error %d sending HELLO hdr to %u.%u.%u.%u/%d\n", - rc, HIPQUAD(conn->ksnc_ipaddr), conn->ksnc_port); + CNETERR("Error %d sending HELLO hdr to %pI4h/%d\n", + rc, &conn->ksnc_ipaddr, conn->ksnc_port); return rc; } @@ -558,8 +558,8 @@ ksocknal_send_hello_v2 (ksock_conn_t *conn, ksock_hello_msg_t *hello) lnet_acceptor_timeout()); if (rc != 0) { CNETERR("Error %d sending HELLO payload (%d)" - " to %u.%u.%u.%u/%d\n", rc, hello->kshm_nips, - HIPQUAD(conn->ksnc_ipaddr), conn->ksnc_port); + " to %pI4h/%d\n", rc, hello->kshm_nips, + &conn->ksnc_ipaddr, conn->ksnc_port); } return rc; @@ -583,18 +583,18 @@ ksocknal_recv_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello,int timeout) sizeof (*hdr) - offsetof (lnet_hdr_t, src_nid), timeout); if (rc != 0) { - CERROR ("Error %d reading rest of HELLO hdr from %u.%u.%u.%u\n", - rc, HIPQUAD(conn->ksnc_ipaddr)); + CERROR("Error %d reading rest of HELLO hdr from %pI4h\n", + rc, &conn->ksnc_ipaddr); LASSERT (rc < 0 && rc != -EALREADY); goto out; } /* ...and check we got what we expected */ if (hdr->type != cpu_to_le32 (LNET_MSG_HELLO)) { - CERROR ("Expecting a HELLO hdr," - " but got type %d from %u.%u.%u.%u\n", + CERROR("Expecting a HELLO hdr," + " but got type %d from %pI4h\n", le32_to_cpu (hdr->type), - HIPQUAD(conn->ksnc_ipaddr)); + &conn->ksnc_ipaddr); rc = -EPROTO; goto out; } @@ -607,8 +607,8 @@ ksocknal_recv_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello,int timeout) sizeof (__u32); if (hello->kshm_nips > LNET_MAX_INTERFACES) { - CERROR("Bad nips %d from ip %u.%u.%u.%u\n", - hello->kshm_nips, HIPQUAD(conn->ksnc_ipaddr)); + CERROR("Bad nips %d from ip %pI4h\n", + hello->kshm_nips, &conn->ksnc_ipaddr); rc = -EPROTO; goto out; } @@ -619,9 +619,9 @@ ksocknal_recv_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello,int timeout) rc = libcfs_sock_read(sock, hello->kshm_ips, hello->kshm_nips * sizeof(__u32), timeout); if (rc != 0) { - CERROR ("Error %d reading IPs from ip %u.%u.%u.%u\n", - rc, HIPQUAD(conn->ksnc_ipaddr)); - LASSERT (rc < 0 && rc != -EALREADY); + CERROR("Error %d reading IPs from ip %pI4h\n", + rc, &conn->ksnc_ipaddr); + LASSERT(rc < 0 && rc != -EALREADY); goto out; } @@ -629,8 +629,8 @@ ksocknal_recv_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello,int timeout) hello->kshm_ips[i] = __le32_to_cpu(hello->kshm_ips[i]); if (hello->kshm_ips[i] == 0) { - CERROR("Zero IP[%d] from ip %u.%u.%u.%u\n", - i, HIPQUAD(conn->ksnc_ipaddr)); + CERROR("Zero IP[%d] from ip %pI4h\n", + i, &conn->ksnc_ipaddr); rc = -EPROTO; break; } @@ -658,9 +658,9 @@ ksocknal_recv_hello_v2 (ksock_conn_t *conn, ksock_hello_msg_t *hello, int timeou offsetof(ksock_hello_msg_t, kshm_src_nid), timeout); if (rc != 0) { - CERROR ("Error %d reading HELLO from %u.%u.%u.%u\n", - rc, HIPQUAD(conn->ksnc_ipaddr)); - LASSERT (rc < 0 && rc != -EALREADY); + CERROR("Error %d reading HELLO from %pI4h\n", + rc, &conn->ksnc_ipaddr); + LASSERT(rc < 0 && rc != -EALREADY); return rc; } @@ -676,8 +676,8 @@ ksocknal_recv_hello_v2 (ksock_conn_t *conn, ksock_hello_msg_t *hello, int timeou } if (hello->kshm_nips > LNET_MAX_INTERFACES) { - CERROR("Bad nips %d from ip %u.%u.%u.%u\n", - hello->kshm_nips, HIPQUAD(conn->ksnc_ipaddr)); + CERROR("Bad nips %d from ip %pI4h\n", + hello->kshm_nips, &conn->ksnc_ipaddr); return -EPROTO; } @@ -687,9 +687,9 @@ ksocknal_recv_hello_v2 (ksock_conn_t *conn, ksock_hello_msg_t *hello, int timeou rc = libcfs_sock_read(sock, hello->kshm_ips, hello->kshm_nips * sizeof(__u32), timeout); if (rc != 0) { - CERROR ("Error %d reading IPs from ip %u.%u.%u.%u\n", - rc, HIPQUAD(conn->ksnc_ipaddr)); - LASSERT (rc < 0 && rc != -EALREADY); + CERROR("Error %d reading IPs from ip %pI4h\n", + rc, &conn->ksnc_ipaddr); + LASSERT(rc < 0 && rc != -EALREADY); return rc; } @@ -698,8 +698,8 @@ ksocknal_recv_hello_v2 (ksock_conn_t *conn, ksock_hello_msg_t *hello, int timeou __swab32s(&hello->kshm_ips[i]); if (hello->kshm_ips[i] == 0) { - CERROR("Zero IP[%d] from ip %u.%u.%u.%u\n", - i, HIPQUAD(conn->ksnc_ipaddr)); + CERROR("Zero IP[%d] from ip %pI4h\n", + i, &conn->ksnc_ipaddr); return -EPROTO; } } diff --git a/drivers/staging/lustre/lnet/lnet/acceptor.c b/drivers/staging/lustre/lnet/lnet/acceptor.c index 81ef28bbcba07..bb15bde0704c0 100644 --- a/drivers/staging/lustre/lnet/lnet/acceptor.c +++ b/drivers/staging/lustre/lnet/lnet/acceptor.c @@ -101,52 +101,52 @@ lnet_connect_console_error (int rc, lnet_nid_t peer_nid, switch (rc) { /* "normal" errors */ case -ECONNREFUSED: - CNETERR("Connection to %s at host %u.%u.%u.%u on port %d was " + CNETERR("Connection to %s at host %pI4h on port %d was " "refused: check that Lustre is running on that node.\n", libcfs_nid2str(peer_nid), - HIPQUAD(peer_ip), peer_port); + &peer_ip, peer_port); break; case -EHOSTUNREACH: case -ENETUNREACH: - CNETERR("Connection to %s at host %u.%u.%u.%u " + CNETERR("Connection to %s at host %pI4h " "was unreachable: the network or that node may " "be down, or Lustre may be misconfigured.\n", - libcfs_nid2str(peer_nid), HIPQUAD(peer_ip)); + libcfs_nid2str(peer_nid), &peer_ip); break; case -ETIMEDOUT: - CNETERR("Connection to %s at host %u.%u.%u.%u on " + CNETERR("Connection to %s at host %pI4h on " "port %d took too long: that node may be hung " "or experiencing high load.\n", libcfs_nid2str(peer_nid), - HIPQUAD(peer_ip), peer_port); + &peer_ip, peer_port); break; case -ECONNRESET: - LCONSOLE_ERROR_MSG(0x11b, "Connection to %s at host %u.%u.%u.%u" + LCONSOLE_ERROR_MSG(0x11b, "Connection to %s at host %pI4h" " on port %d was reset: " "is it running a compatible version of " "Lustre and is %s one of its NIDs?\n", libcfs_nid2str(peer_nid), - HIPQUAD(peer_ip), peer_port, + &peer_ip, peer_port, libcfs_nid2str(peer_nid)); break; case -EPROTO: LCONSOLE_ERROR_MSG(0x11c, "Protocol error connecting to %s at " - "host %u.%u.%u.%u on port %d: is it running " + "host %pI4h on port %d: is it running " "a compatible version of Lustre?\n", libcfs_nid2str(peer_nid), - HIPQUAD(peer_ip), peer_port); + &peer_ip, peer_port); break; case -EADDRINUSE: LCONSOLE_ERROR_MSG(0x11d, "No privileged ports available to " - "connect to %s at host %u.%u.%u.%u on port " + "connect to %s at host %pI4h on port " "%d\n", libcfs_nid2str(peer_nid), - HIPQUAD(peer_ip), peer_port); + &peer_ip, peer_port); break; default: LCONSOLE_ERROR_MSG(0x11e, "Unexpected error %d connecting to %s" - " at host %u.%u.%u.%u on port %d\n", rc, + " at host %pI4h on port %d\n", rc, libcfs_nid2str(peer_nid), - HIPQUAD(peer_ip), peer_port); + &peer_ip, peer_port); break; } } @@ -253,8 +253,8 @@ lnet_accept(socket_t *sock, __u32 magic) if (rc != 0) CERROR("Error sending magic+version in response" - "to LNET magic from %u.%u.%u.%u: %d\n", - HIPQUAD(peer_ip), rc); + "to LNET magic from %pI4h: %d\n", + &peer_ip, rc); return -EPROTO; } @@ -265,9 +265,9 @@ lnet_accept(socket_t *sock, __u32 magic) else str = "unrecognised"; - LCONSOLE_ERROR_MSG(0x11f, "Refusing connection from %u.%u.%u.%u" + LCONSOLE_ERROR_MSG(0x11f, "Refusing connection from %pI4h" " magic %08x: %s acceptor protocol\n", - HIPQUAD(peer_ip), magic, str); + &peer_ip, magic, str); return -EPROTO; } @@ -278,7 +278,7 @@ lnet_accept(socket_t *sock, __u32 magic) accept_timeout); if (rc != 0) { CERROR("Error %d reading connection request version from " - "%u.%u.%u.%u\n", rc, HIPQUAD(peer_ip)); + "%pI4h\n", rc, &peer_ip); return -EIO; } @@ -301,8 +301,8 @@ lnet_accept(socket_t *sock, __u32 magic) if (rc != 0) CERROR("Error sending magic+version in response" - "to version %d from %u.%u.%u.%u: %d\n", - peer_version, HIPQUAD(peer_ip), rc); + "to version %d from %pI4h: %d\n", + peer_version, &peer_ip, rc); return -EPROTO; } @@ -312,7 +312,7 @@ lnet_accept(socket_t *sock, __u32 magic) accept_timeout); if (rc != 0) { CERROR("Error %d reading connection request from " - "%u.%u.%u.%u\n", rc, HIPQUAD(peer_ip)); + "%pI4h\n", rc, &peer_ip); return -EIO; } @@ -324,23 +324,23 @@ lnet_accept(socket_t *sock, __u32 magic) ni->ni_nid != cr.acr_nid) { /* right NET, wrong NID! */ if (ni != NULL) lnet_ni_decref(ni); - LCONSOLE_ERROR_MSG(0x120, "Refusing connection from %u.%u.%u.%u" + LCONSOLE_ERROR_MSG(0x120, "Refusing connection from %pI4h" " for %s: No matching NI\n", - HIPQUAD(peer_ip), libcfs_nid2str(cr.acr_nid)); + &peer_ip, libcfs_nid2str(cr.acr_nid)); return -EPERM; } if (ni->ni_lnd->lnd_accept == NULL) { /* This catches a request for the loopback LND */ lnet_ni_decref(ni); - LCONSOLE_ERROR_MSG(0x121, "Refusing connection from %u.%u.%u.%u" + LCONSOLE_ERROR_MSG(0x121, "Refusing connection from %pI4h" " for %s: NI doesn not accept IP connections\n", - HIPQUAD(peer_ip), libcfs_nid2str(cr.acr_nid)); + &peer_ip, libcfs_nid2str(cr.acr_nid)); return -EPERM; } - CDEBUG(D_NET, "Accept %s from %u.%u.%u.%u\n", - libcfs_nid2str(cr.acr_nid), HIPQUAD(peer_ip)); + CDEBUG(D_NET, "Accept %s from %pI4h\n", + libcfs_nid2str(cr.acr_nid), &peer_ip); rc = ni->ni_lnd->lnd_accept(ni, sock); @@ -410,9 +410,9 @@ lnet_acceptor(void *arg) } if (secure && peer_port > LNET_ACCEPTOR_MAX_RESERVED_PORT) { - CERROR("Refusing connection from %u.%u.%u.%u: " + CERROR("Refusing connection from %pI4h: " "insecure port %d\n", - HIPQUAD(peer_ip), peer_port); + &peer_ip, peer_port); goto failed; } @@ -420,7 +420,7 @@ lnet_acceptor(void *arg) accept_timeout); if (rc != 0) { CERROR("Error %d reading connection request from " - "%u.%u.%u.%u\n", rc, HIPQUAD(peer_ip)); + "%pI4h\n", rc, &peer_ip); goto failed; } diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c index 855c7e87d96f2..f5e78b54b3e74 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c @@ -641,8 +641,8 @@ libcfs_sock_connect (struct socket **sockp, int *fatal, *fatal = !(rc == -EADDRNOTAVAIL); CDEBUG_LIMIT(*fatal ? D_NETERROR : D_NET, - "Error %d connecting %u.%u.%u.%u/%d -> %u.%u.%u.%u/%d\n", rc, - HIPQUAD(local_ip), local_port, HIPQUAD(peer_ip), peer_port); + "Error %d connecting %pI4h/%d -> %pI4h/%d\n", rc, + &local_ip, local_port, &peer_ip, peer_port); sock_release(*sockp); return rc; -- GitLab From 3867ea5a4bc4d428f8d93557fb0fbc2cac2f2cdf Mon Sep 17 00:00:00 2001 From: Peng Tao Date: Mon, 15 Jul 2013 22:27:10 +0800 Subject: [PATCH 007/942] staging/lustre: fix build error when !CONFIG_SMP Three functions cfs_cpu_ht_nsiblings, cfs_cpt_cpumask and cfs_cpt_table_print are missing if !CONFIG_SMP. cpumask_t/nodemask_t/__read_mostly/____cacheline_aligned are redefined. Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../lustre/include/linux/libcfs/libcfs_cpu.h | 46 +++++++++---------- .../include/linux/libcfs/linux/linux-cpu.h | 6 --- .../lustre/lnet/klnds/o2iblnd/o2iblnd.c | 2 + .../lustre/lustre/libcfs/linux/linux-cpu.c | 46 ++----------------- .../staging/lustre/lustre/ptlrpc/service.c | 11 ++++- 5 files changed, 37 insertions(+), 74 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h index 6ae7415a3b995..c87efb49ebc28 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h @@ -75,11 +75,19 @@ #ifndef __LIBCFS_CPU_H__ #define __LIBCFS_CPU_H__ -#ifndef HAVE_LIBCFS_CPT - -typedef unsigned long cpumask_t; -typedef unsigned long nodemask_t; +/* any CPU partition */ +#define CFS_CPT_ANY (-1) +#ifdef CONFIG_SMP +/** + * return cpumask of CPU partition \a cpt + */ +cpumask_t *cfs_cpt_cpumask(struct cfs_cpt_table *cptab, int cpt); +/** + * print string information of cpt-table + */ +int cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len); +#else /* !CONFIG_SMP */ struct cfs_cpt_table { /* # of CPU partitions */ int ctb_nparts; @@ -91,10 +99,18 @@ struct cfs_cpt_table { __u64 ctb_version; }; -#endif /* !HAVE_LIBCFS_CPT */ +static inline cpumask_t * +cfs_cpt_cpumask(struct cfs_cpt_table *cptab, int cpt) +{ + return NULL; +} -/* any CPU partition */ -#define CFS_CPT_ANY (-1) +static inline int +cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len) +{ + return 0; +} +#endif /* CONFIG_SMP */ extern struct cfs_cpt_table *cfs_cpt_table; @@ -106,10 +122,6 @@ void cfs_cpt_table_free(struct cfs_cpt_table *cptab); * create a cfs_cpt_table with \a ncpt number of partitions */ struct cfs_cpt_table *cfs_cpt_table_alloc(unsigned int ncpt); -/** - * print string information of cpt-table - */ -int cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len); /** * return total number of CPU partitions in \a cptab */ @@ -123,10 +135,6 @@ int cfs_cpt_weight(struct cfs_cpt_table *cptab, int cpt); * is there any online CPU in CPU partition \a cpt */ int cfs_cpt_online(struct cfs_cpt_table *cptab, int cpt); -/** - * return cpumask of CPU partition \a cpt - */ -cpumask_t *cfs_cpt_cpumask(struct cfs_cpt_table *cptab, int cpt); /** * return nodemask of CPU partition \a cpt */ @@ -200,14 +208,6 @@ int cfs_cpt_spread_node(struct cfs_cpt_table *cptab, int cpt); #define cfs_cpt_for_each(i, cptab) \ for (i = 0; i < cfs_cpt_number(cptab); i++) -#ifndef __read_mostly -# define __read_mostly -#endif - -#ifndef ____cacheline_aligned -#define ____cacheline_aligned -#endif - int cfs_cpu_init(void); void cfs_cpu_fini(void); diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h index 224371c92f7c9..5f793f2237509 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h @@ -81,12 +81,6 @@ struct cfs_cpt_table { nodemask_t *ctb_nodemask; }; -void cfs_cpu_core_siblings(int cpu, cpumask_t *mask); -void cfs_cpu_ht_siblings(int cpu, cpumask_t *mask); -void cfs_node_to_cpumask(int node, cpumask_t *mask); -int cfs_cpu_core_nsiblings(int cpu); -int cfs_cpu_ht_nsiblings(int cpu); - /** * comment out definitions for compatible layer * #define CFS_CPU_NR NR_CPUS diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c index eb6b66aa1ab39..86397f96b0331 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c @@ -702,6 +702,8 @@ kiblnd_get_completion_vector(kib_conn_t *conn, int cpt) return 0; mask = cfs_cpt_cpumask(lnet_cpt_table(), cpt); + if (mask == NULL) + return 0; /* hash NID to CPU id in this partition... */ off = do_div(nid, cpus_weight(*mask)); diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c index 95142d1909719..00ab8fdc1053c 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c @@ -76,62 +76,22 @@ struct cfs_cpt_data { static struct cfs_cpt_data cpt_data; -void -cfs_cpu_core_siblings(int cpu, cpumask_t *mask) +static void cfs_cpu_core_siblings(int cpu, cpumask_t *mask) { /* return cpumask of cores in the same socket */ cpumask_copy(mask, topology_core_cpumask(cpu)); } -EXPORT_SYMBOL(cfs_cpu_core_siblings); - -/* return number of cores in the same socket of \a cpu */ -int -cfs_cpu_core_nsiblings(int cpu) -{ - int num; - - down(&cpt_data.cpt_mutex); - - cfs_cpu_core_siblings(cpu, cpt_data.cpt_cpumask); - num = cpus_weight(*cpt_data.cpt_cpumask); - - up(&cpt_data.cpt_mutex); - - return num; -} -EXPORT_SYMBOL(cfs_cpu_core_nsiblings); /* return cpumask of HTs in the same core */ -void -cfs_cpu_ht_siblings(int cpu, cpumask_t *mask) +static void cfs_cpu_ht_siblings(int cpu, cpumask_t *mask) { cpumask_copy(mask, topology_thread_cpumask(cpu)); } -EXPORT_SYMBOL(cfs_cpu_ht_siblings); -/* return number of HTs in the same core of \a cpu */ -int -cfs_cpu_ht_nsiblings(int cpu) -{ - int num; - - down(&cpt_data.cpt_mutex); - - cfs_cpu_ht_siblings(cpu, cpt_data.cpt_cpumask); - num = cpus_weight(*cpt_data.cpt_cpumask); - - up(&cpt_data.cpt_mutex); - - return num; -} -EXPORT_SYMBOL(cfs_cpu_ht_nsiblings); - -void -cfs_node_to_cpumask(int node, cpumask_t *mask) +static void cfs_node_to_cpumask(int node, cpumask_t *mask) { cpumask_copy(mask, cpumask_of_node(node)); } -EXPORT_SYMBOL(cfs_node_to_cpumask); void cfs_cpt_table_free(struct cfs_cpt_table *cptab) diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index 1667b8e86012d..cd1bab5a25207 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -551,6 +551,7 @@ ptlrpc_server_nthreads_check(struct ptlrpc_service *svc, if (tc->tc_thr_factor != 0) { int factor = tc->tc_thr_factor; const int fade = 4; + cpumask_t mask; /* * User wants to increase number of threads with for @@ -564,7 +565,8 @@ ptlrpc_server_nthreads_check(struct ptlrpc_service *svc, * have too many threads no matter how many cores/HTs * there are. */ - if (cfs_cpu_ht_nsiblings(0) > 1) { /* weight is # of HTs */ + cpumask_copy(&mask, topology_thread_cpumask(0)); + if (cpus_weight(mask) > 1) { /* weight is # of HTs */ /* depress thread factor for hyper-thread */ factor = factor - (factor >> 1) + (factor >> 3); } @@ -2776,11 +2778,13 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait) int ptlrpc_hr_init(void) { + cpumask_t mask; struct ptlrpc_hr_partition *hrp; struct ptlrpc_hr_thread *hrt; int rc; int i; int j; + int weight; ENTRY; memset(&ptlrpc_hr, 0, sizeof(ptlrpc_hr)); @@ -2793,6 +2797,9 @@ int ptlrpc_hr_init(void) init_waitqueue_head(&ptlrpc_hr.hr_waitq); + cpumask_copy(&mask, topology_thread_cpumask(0)); + weight = cpus_weight(mask); + cfs_percpt_for_each(hrp, i, ptlrpc_hr.hr_partitions) { hrp->hrp_cpt = i; @@ -2800,7 +2807,7 @@ int ptlrpc_hr_init(void) atomic_set(&hrp->hrp_nstopped, 0); hrp->hrp_nthrs = cfs_cpt_weight(ptlrpc_hr.hr_cpt_table, i); - hrp->hrp_nthrs /= cfs_cpu_ht_nsiblings(0); + hrp->hrp_nthrs /= weight; LASSERT(hrp->hrp_nthrs > 0); OBD_CPT_ALLOC(hrp->hrp_thrs, ptlrpc_hr.hr_cpt_table, i, -- GitLab From 0e145b443e7b8c73e29470f069b0aa61835e4a11 Mon Sep 17 00:00:00 2001 From: Peng Tao Date: Mon, 15 Jul 2013 22:27:11 +0800 Subject: [PATCH 008/942] staging/lustre: fix build on s390 As reported by Fengguang: In file included from drivers/staging/lustre/lustre/obdclass/../include/lustre/lustre_idl.h:99:0, from drivers/staging/lustre/lustre/obdclass/../include/lprocfs_status.h:46, from drivers/staging/lustre/lustre/obdclass/../include/obd_support.h:42, from drivers/staging/lustre/lustre/obdclass/../include/obd_class.h:40, from drivers/staging/lustre/lustre/obdclass/lu_object.c:53: drivers/staging/lustre/lustre/obdclass/../include/lustre/lustre_user.h:356:10: error: field 'lmd_st' has incomplete type drivers/staging/lustre/lustre/obdclass/../include/lustre/lustre_user.h:361:10: error: field 'lmd_st' has incomplete type Reported-by: Fengguang Wu Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/include/linux/lustre_user.h | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_user.h b/drivers/staging/lustre/lustre/include/linux/lustre_user.h index ebaf92977f7fc..ea9393c625cc6 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_user.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_user.h @@ -53,15 +53,19 @@ #include -#if defined(__x86_64__) || defined(__ia64__) || defined(__ppc64__) || \ - defined(__craynv) || defined (__mips64__) || defined(__powerpc64__) -typedef struct stat lstat_t; -#define lstat_f lstat -#define HAVE_LOV_USER_MDS_DATA -#else +/* + * We need to always use 64bit version because the structure + * is shared across entire cluster where 32bit and 64bit machines + * are co-existing. + */ +#if __BITS_PER_LONG != 64 || defined(__ARCH_WANT_STAT64) typedef struct stat64 lstat_t; #define lstat_f lstat64 -#define HAVE_LOV_USER_MDS_DATA +#else +typedef struct stat lstat_t; +#define lstat_f lstat #endif +#define HAVE_LOV_USER_MDS_DATA + #endif /* _LUSTRE_USER_H */ -- GitLab From 2870cd102c1acdab10908625ec0772729d7ec6dc Mon Sep 17 00:00:00 2001 From: Peng Tao Date: Mon, 15 Jul 2013 22:27:12 +0800 Subject: [PATCH 009/942] staging/lustre/llite: add missing include file for prefetchw Got below errors on s390 build: CC [M] drivers/staging/lustre/lustre/llite/dir.o drivers/staging/lustre/lustre/llite/dir.c: In function 'll_dir_filler': drivers/staging/lustre/lustre/llite/dir.c:225:3: error: implicit declaration of function 'prefetchw' [-Werror=implicit-function-declaration] Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/dir.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index 23c61fe81965c..13a6426bdd9fc 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -45,6 +45,7 @@ #include #include // for wait_on_buffer #include +#include #define DEBUG_SUBSYSTEM S_LLITE -- GitLab From 9147dc8d54a1c15f407aca3beeae5797d0b47d1b Mon Sep 17 00:00:00 2001 From: Peng Tao Date: Mon, 15 Jul 2013 22:27:13 +0800 Subject: [PATCH 010/942] staging/lustre/llite: fix build erorr if CONFIG_FS_POSIX_ACL is off Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/llite/llite_internal.h | 21 ++++++++++++------- drivers/staging/lustre/lustre/llite/xattr.c | 2 ++ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 5227c5c4ebe21..1069b8dd84dcb 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -438,14 +438,6 @@ struct rmtacl_ctl_table { #define EE_HASHES 32 -struct eacl_entry { - struct list_head ee_list; - pid_t ee_key; /* hash key */ - struct lu_fid ee_fid; - int ee_type; /* ACL type for ACCESS or DEFAULT */ - ext_acl_xattr_header *ee_acl; -}; - struct eacl_table { spinlock_t et_lock; struct list_head et_entries[EE_HASHES]; @@ -1168,6 +1160,14 @@ void ll_ra_stats_inc(struct address_space *mapping, enum ra_stat which); /* llite/llite_rmtacl.c */ #ifdef CONFIG_FS_POSIX_ACL +struct eacl_entry { + struct list_head ee_list; + pid_t ee_key; /* hash key */ + struct lu_fid ee_fid; + int ee_type; /* ACL type for ACCESS or DEFAULT */ + ext_acl_xattr_header *ee_acl; +}; + obd_valid rce_ops2valid(int ops); struct rmtacl_ctl_entry *rct_search(struct rmtacl_ctl_table *rct, pid_t key); int rct_add(struct rmtacl_ctl_table *rct, pid_t key, int ops); @@ -1183,6 +1183,11 @@ struct eacl_entry *et_search_del(struct eacl_table *et, pid_t key, void et_search_free(struct eacl_table *et, pid_t key); void et_init(struct eacl_table *et); void et_fini(struct eacl_table *et); +#else +static inline obd_valid rce_ops2valid(int ops) +{ + return 0; +} #endif /* statahead.c */ diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c index 4176264984bb6..0a11902c4d2b3 100644 --- a/drivers/staging/lustre/lustre/llite/xattr.c +++ b/drivers/staging/lustre/lustre/llite/xattr.c @@ -112,9 +112,11 @@ int ll_setxattr_common(struct inode *inode, const char *name, struct ptlrpc_request *req; int xattr_type, rc; struct obd_capa *oc; +#ifdef CONFIG_FS_POSIX_ACL posix_acl_xattr_header *new_value = NULL; struct rmtacl_ctl_entry *rce = NULL; ext_acl_xattr_header *acl = NULL; +#endif const char *pv = value; ENTRY; -- GitLab From 4b1a25f06b30b203b35c227b163c8191b091dad8 Mon Sep 17 00:00:00 2001 From: Peng Tao Date: Mon, 15 Jul 2013 22:27:14 +0800 Subject: [PATCH 011/942] staging/lustre: fix build when CONFIG_UIDGID_STRICT_TYPE_CHECKS is on kuid_t/kgid_t are wrappered when CONFIG_UIDGID_STRICT_TYPE_CHECKS is on. Lustre build is broken because we always treat them as plain __u32. The patch fixes it. Internally, Lustre always use __u32 uid/gid, and convert to kuid_t/kgid_t when necessary. Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../lustre/include/linux/libcfs/curproc.h | 2 -- .../lustre/lustre/include/linux/lvfs.h | 8 +++--- .../lustre/lustre/include/lustre_cfg.h | 4 --- .../lustre/libcfs/linux/linux-curproc.c | 16 ------------ .../lustre/lustre/libcfs/linux/linux-module.c | 2 +- drivers/staging/lustre/lustre/llite/dir.c | 9 ++++--- .../staging/lustre/lustre/llite/llite_lib.c | 13 +++++----- .../staging/lustre/lustre/llite/lproc_llite.c | 3 ++- drivers/staging/lustre/lustre/llite/namei.c | 7 +++--- .../staging/lustre/lustre/llite/remote_perm.c | 11 ++++---- .../staging/lustre/lustre/llite/vvp_object.c | 8 +++--- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 12 ++++----- drivers/staging/lustre/lustre/mdc/mdc_lib.c | 25 ++++++++++--------- .../staging/lustre/lustre/mdc/mdc_request.c | 8 ++---- .../lustre/lustre/obdclass/class_obd.c | 3 ++- .../staging/lustre/lustre/obdclass/idmap.c | 12 ++++++--- .../lustre/lustre/obdclass/linux/linux-obdo.c | 4 +-- drivers/staging/lustre/lustre/obdclass/obdo.c | 16 ++++++------ .../lustre/lustre/obdecho/echo_client.c | 12 ++++++--- drivers/staging/lustre/lustre/ptlrpc/sec.c | 19 +++++++------- 20 files changed, 93 insertions(+), 101 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/curproc.h b/drivers/staging/lustre/include/linux/libcfs/curproc.h index 90d7ce630e94c..de8e35b796ab4 100644 --- a/drivers/staging/lustre/include/linux/libcfs/curproc.h +++ b/drivers/staging/lustre/include/linux/libcfs/curproc.h @@ -49,8 +49,6 @@ * Implemented in portals/include/libcfs// */ int cfs_curproc_groups_nr(void); -int current_is_in_group(gid_t group); -void cfs_curproc_groups_dump(gid_t *array, int size); /* * Plus, platform-specific constant diff --git a/drivers/staging/lustre/lustre/include/linux/lvfs.h b/drivers/staging/lustre/lustre/include/linux/lvfs.h index eb59ac7d5946b..e61f1b87f822c 100644 --- a/drivers/staging/lustre/lustre/include/linux/lvfs.h +++ b/drivers/staging/lustre/lustre/include/linux/lvfs.h @@ -54,10 +54,10 @@ /* simple.c */ struct lvfs_ucred { - __u32 luc_uid; - __u32 luc_gid; - __u32 luc_fsuid; - __u32 luc_fsgid; + kuid_t luc_uid; + kgid_t luc_gid; + kuid_t luc_fsuid; + kgid_t luc_fsgid; kernel_cap_t luc_cap; __u32 luc_umask; struct group_info *luc_ginfo; diff --git a/drivers/staging/lustre/lustre/include/lustre_cfg.h b/drivers/staging/lustre/lustre/include/lustre_cfg.h index f12429f382159..fbf94a081ffd4 100644 --- a/drivers/staging/lustre/lustre/include/lustre_cfg.h +++ b/drivers/staging/lustre/lustre/include/lustre_cfg.h @@ -290,10 +290,6 @@ static inline int lustre_cfg_sanity_check(void *buf, int len) #include -#ifndef INVALID_UID -#define INVALID_UID (-1) -#endif - /** @} cfg */ #endif // _LUSTRE_CFG_H diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c index f236510a2f3fd..706dfb39fc287 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c @@ -65,20 +65,6 @@ int cfs_curproc_groups_nr(void) return nr; } -void cfs_curproc_groups_dump(gid_t *array, int size) -{ - task_lock(current); - size = min_t(int, size, current_cred()->group_info->ngroups); - memcpy(array, current_cred()->group_info->blocks[0], size * sizeof(__u32)); - task_unlock(current); -} - - -int current_is_in_group(gid_t gid) -{ - return in_group_p(gid); -} - /* Currently all the CFS_CAP_* defines match CAP_* ones. */ #define cfs_cap_pack(cap) (cap) #define cfs_cap_unpack(cap) (cap) @@ -318,8 +304,6 @@ int cfs_get_environ(const char *key, char *value, int *val_len) EXPORT_SYMBOL(cfs_get_environ); EXPORT_SYMBOL(cfs_curproc_groups_nr); -EXPORT_SYMBOL(cfs_curproc_groups_dump); -EXPORT_SYMBOL(current_is_in_group); EXPORT_SYMBOL(cfs_cap_raise); EXPORT_SYMBOL(cfs_cap_lower); EXPORT_SYMBOL(cfs_cap_raised); diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c index 2c7d4a3d660fe..6b0054ff79159 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c @@ -137,7 +137,7 @@ static long libcfs_ioctl(struct file *file, struct cfs_psdev_file pfile; int rc = 0; - if (current_fsuid() != 0) + if (!capable(CAP_SYS_ADMIN)) return -EACCES; if ( _IOC_TYPE(cmd) != IOC_LIBCFS_TYPE || diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index 13a6426bdd9fc..e2afb97303434 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -685,7 +685,8 @@ int ll_dir_setdirstripe(struct inode *dir, struct lmv_user_md *lump, op_data->op_cli_flags |= CLI_SET_MEA; err = md_create(sbi->ll_md_exp, op_data, lump, sizeof(*lump), mode, - current_fsuid(), current_fsgid(), + from_kuid(&init_user_ns, current_fsuid()), + from_kgid(&init_user_ns, current_fsgid()), cfs_curproc_cap_pack(), 0, &request); ll_finish_md_op_data(op_data); if (err) @@ -1105,8 +1106,10 @@ static int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl) RETURN(-EPERM); break; case Q_GETQUOTA: - if (((type == USRQUOTA && current_euid() != id) || - (type == GRPQUOTA && !in_egroup_p(id))) && + if (((type == USRQUOTA && + uid_eq(current_euid(), make_kuid(&init_user_ns, id))) || + (type == GRPQUOTA && + !in_egroup_p(make_kgid(&init_user_ns, id)))) && (!cfs_capable(CFS_CAP_SYS_ADMIN) || sbi->ll_flags & LL_SBI_RMT_CLIENT)) RETURN(-EPERM); diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index afae8010623d5..1eb5779c1bdad 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -1400,7 +1400,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr) /* POSIX: check before ATTR_*TIME_SET set (from inode_change_ok) */ if (attr->ia_valid & TIMES_SET_FLAGS) { - if (current_fsuid() != inode->i_uid && + if ((!uid_eq(current_fsuid(), inode->i_uid)) && !cfs_capable(CFS_CAP_FOWNER)) RETURN(-EPERM); } @@ -1707,9 +1707,9 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md) inode->i_blkbits = inode->i_sb->s_blocksize_bits; } if (body->valid & OBD_MD_FLUID) - inode->i_uid = body->uid; + inode->i_uid = make_kuid(&init_user_ns, body->uid); if (body->valid & OBD_MD_FLGID) - inode->i_gid = body->gid; + inode->i_gid = make_kgid(&init_user_ns, body->gid); if (body->valid & OBD_MD_FLFLAGS) inode->i_flags = ll_ext_to_inode_flags(body->flags); if (body->valid & OBD_MD_FLNLINK) @@ -1959,7 +1959,8 @@ int ll_flush_ctx(struct inode *inode) { struct ll_sb_info *sbi = ll_i2sbi(inode); - CDEBUG(D_SEC, "flush context for user %d\n", current_uid()); + CDEBUG(D_SEC, "flush context for user %d\n", + from_kuid(&init_user_ns, current_uid())); obd_set_info_async(NULL, sbi->ll_md_exp, sizeof(KEY_FLUSH_CTX), KEY_FLUSH_CTX, @@ -2238,8 +2239,8 @@ struct md_op_data * ll_prep_md_op_data(struct md_op_data *op_data, op_data->op_namelen = namelen; op_data->op_mode = mode; op_data->op_mod_time = cfs_time_current_sec(); - op_data->op_fsuid = current_fsuid(); - op_data->op_fsgid = current_fsgid(); + op_data->op_fsuid = from_kuid(&init_user_ns, current_fsuid()); + op_data->op_fsgid = from_kgid(&init_user_ns, current_fsgid()); op_data->op_cap = cfs_curproc_cap_pack(); op_data->op_bias = 0; op_data->op_cli_flags = 0; diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index a30c411b583bc..5c7368c358a0f 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -822,7 +822,8 @@ void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count) sbi->ll_stats_track_id == current->parent->pid) lprocfs_counter_add(sbi->ll_stats, op, count); else if (sbi->ll_stats_track_type == STATS_TRACK_GID && - sbi->ll_stats_track_id == current_gid()) + sbi->ll_stats_track_id == + from_kgid(&init_user_ns, current_gid())) lprocfs_counter_add(sbi->ll_stats, op, count); } EXPORT_SYMBOL(ll_stats_ops_tally); diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c index ff8f63de5612a..8e948a71dd644 100644 --- a/drivers/staging/lustre/lustre/llite/namei.c +++ b/drivers/staging/lustre/lustre/llite/namei.c @@ -302,8 +302,8 @@ int ll_md_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, __u32 ll_i2suppgid(struct inode *i) { - if (current_is_in_group(i->i_gid)) - return (__u32)i->i_gid; + if (in_group_p(i->i_gid)) + return (__u32)from_kgid(&init_user_ns, i->i_gid); else return (__u32)(-1); } @@ -805,7 +805,8 @@ static int ll_new_node(struct inode *dir, struct qstr *name, GOTO(err_exit, err = PTR_ERR(op_data)); err = md_create(sbi->ll_md_exp, op_data, tgt, tgt_len, mode, - current_fsuid(), current_fsgid(), + from_kuid(&init_user_ns, current_fsuid()), + from_kgid(&init_user_ns, current_fsgid()), cfs_curproc_cap_pack(), rdev, &request); ll_finish_md_op_data(op_data); if (err) diff --git a/drivers/staging/lustre/lustre/llite/remote_perm.c b/drivers/staging/lustre/lustre/llite/remote_perm.c index 68b2dc4a7b62a..4f176e16e01c7 100644 --- a/drivers/staging/lustre/lustre/llite/remote_perm.c +++ b/drivers/staging/lustre/lustre/llite/remote_perm.c @@ -129,17 +129,18 @@ static int do_check_remote_perm(struct ll_inode_info *lli, int mask) if (!lli->lli_remote_perms) RETURN(-ENOENT); - head = lli->lli_remote_perms + remote_perm_hashfunc(current_uid()); + head = lli->lli_remote_perms + + remote_perm_hashfunc(from_kuid(&init_user_ns, current_uid())); spin_lock(&lli->lli_lock); hlist_for_each_entry(lrp, head, lrp_list) { - if (lrp->lrp_uid != current_uid()) + if (lrp->lrp_uid != from_kuid(&init_user_ns, current_uid())) continue; - if (lrp->lrp_gid != current_gid()) + if (lrp->lrp_gid != from_kgid(&init_user_ns, current_gid())) continue; - if (lrp->lrp_fsuid != current_fsuid()) + if (lrp->lrp_fsuid != from_kuid(&init_user_ns, current_fsuid())) continue; - if (lrp->lrp_fsgid != current_fsgid()) + if (lrp->lrp_fsgid != from_kgid(&init_user_ns, current_fsgid())) continue; found = 1; break; diff --git a/drivers/staging/lustre/lustre/llite/vvp_object.c b/drivers/staging/lustre/lustre/llite/vvp_object.c index 01edc5b63e13e..33173fce478fd 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_object.c +++ b/drivers/staging/lustre/lustre/llite/vvp_object.c @@ -91,8 +91,8 @@ static int vvp_attr_get(const struct lu_env *env, struct cl_object *obj, attr->cat_atime = LTIME_S(inode->i_atime); attr->cat_ctime = LTIME_S(inode->i_ctime); attr->cat_blocks = inode->i_blocks; - attr->cat_uid = inode->i_uid; - attr->cat_gid = inode->i_gid; + attr->cat_uid = from_kuid(&init_user_ns, inode->i_uid); + attr->cat_gid = from_kgid(&init_user_ns, inode->i_gid); /* KMS is not known by this layer */ return 0; /* layers below have to fill in the rest */ } @@ -103,9 +103,9 @@ static int vvp_attr_set(const struct lu_env *env, struct cl_object *obj, struct inode *inode = ccc_object_inode(obj); if (valid & CAT_UID) - inode->i_uid = attr->cat_uid; + inode->i_uid = make_kuid(&init_user_ns, attr->cat_uid); if (valid & CAT_GID) - inode->i_gid = attr->cat_gid; + inode->i_gid = make_kgid(&init_user_ns, attr->cat_gid); if (valid & CAT_ATIME) LTIME_S(inode->i_atime) = attr->cat_atime; if (valid & CAT_MTIME) diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index 1eebfbf34871f..d10f7fc553d3b 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -1757,8 +1757,8 @@ static int lmv_link(struct obd_export *exp, struct md_op_data *op_data, PFID(&op_data->op_fid2), op_data->op_namelen, op_data->op_name, PFID(&op_data->op_fid1)); - op_data->op_fsuid = current_fsuid(); - op_data->op_fsgid = current_fsgid(); + op_data->op_fsuid = from_kuid(&init_user_ns, current_fsuid()); + op_data->op_fsgid = from_kgid(&init_user_ns, current_fsgid()); op_data->op_cap = cfs_curproc_cap_pack(); tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid2); if (IS_ERR(tgt)) @@ -1799,8 +1799,8 @@ static int lmv_rename(struct obd_export *exp, struct md_op_data *op_data, if (rc) RETURN(rc); - op_data->op_fsuid = current_fsuid(); - op_data->op_fsgid = current_fsgid(); + op_data->op_fsuid = from_kuid(&init_user_ns, current_fsuid()); + op_data->op_fsgid = from_kgid(&init_user_ns, current_fsgid()); op_data->op_cap = cfs_curproc_cap_pack(); src_tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1); if (IS_ERR(src_tgt)) @@ -2061,8 +2061,8 @@ static int lmv_unlink(struct obd_export *exp, struct md_op_data *op_data, if (IS_ERR(tgt)) RETURN(PTR_ERR(tgt)); - op_data->op_fsuid = current_fsuid(); - op_data->op_fsgid = current_fsgid(); + op_data->op_fsuid = from_kuid(&init_user_ns, current_fsuid()); + op_data->op_fsgid = from_kgid(&init_user_ns, current_fsgid()); op_data->op_cap = cfs_curproc_cap_pack(); /* diff --git a/drivers/staging/lustre/lustre/mdc/mdc_lib.c b/drivers/staging/lustre/lustre/mdc/mdc_lib.c index e789aed98de06..2e5c7cef61ce2 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_lib.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_lib.c @@ -45,10 +45,10 @@ static void __mdc_pack_body(struct mdt_body *b, __u32 suppgid) LASSERT (b != NULL); b->suppgid = suppgid; - b->uid = current_uid(); - b->gid = current_gid(); - b->fsuid = current_fsuid(); - b->fsgid = current_fsgid(); + b->uid = from_kuid(&init_user_ns, current_uid()); + b->gid = from_kgid(&init_user_ns, current_gid()); + b->fsuid = from_kuid(&init_user_ns, current_fsuid()); + b->fsgid = from_kgid(&init_user_ns, current_fsgid()); b->capability = cfs_curproc_cap_pack(); } @@ -219,8 +219,8 @@ void mdc_open_pack(struct ptlrpc_request *req, struct md_op_data *op_data, /* XXX do something about time, uid, gid */ rec->cr_opcode = REINT_OPEN; - rec->cr_fsuid = current_fsuid(); - rec->cr_fsgid = current_fsgid(); + rec->cr_fsuid = from_kuid(&init_user_ns, current_fsuid()); + rec->cr_fsgid = from_kgid(&init_user_ns, current_fsgid()); rec->cr_cap = cfs_curproc_cap_pack(); if (op_data != NULL) { rec->cr_fid1 = op_data->op_fid1; @@ -299,16 +299,16 @@ static void mdc_setattr_pack_rec(struct mdt_rec_setattr *rec, struct md_op_data *op_data) { rec->sa_opcode = REINT_SETATTR; - rec->sa_fsuid = current_fsuid(); - rec->sa_fsgid = current_fsgid(); + rec->sa_fsuid = from_kuid(&init_user_ns, current_fsuid()); + rec->sa_fsgid = from_kgid(&init_user_ns, current_fsgid()); rec->sa_cap = cfs_curproc_cap_pack(); rec->sa_suppgid = -1; rec->sa_fid = op_data->op_fid1; rec->sa_valid = attr_pack(op_data->op_attr.ia_valid); rec->sa_mode = op_data->op_attr.ia_mode; - rec->sa_uid = op_data->op_attr.ia_uid; - rec->sa_gid = op_data->op_attr.ia_gid; + rec->sa_uid = from_kuid(&init_user_ns, op_data->op_attr.ia_uid); + rec->sa_gid = from_kgid(&init_user_ns, op_data->op_attr.ia_gid); rec->sa_size = op_data->op_attr.ia_size; rec->sa_blocks = op_data->op_attr_blocks; rec->sa_atime = LTIME_S(op_data->op_attr.ia_atime); @@ -316,8 +316,9 @@ static void mdc_setattr_pack_rec(struct mdt_rec_setattr *rec, rec->sa_ctime = LTIME_S(op_data->op_attr.ia_ctime); rec->sa_attr_flags = ((struct ll_iattr *)&op_data->op_attr)->ia_attr_flags; if ((op_data->op_attr.ia_valid & ATTR_GID) && - current_is_in_group(op_data->op_attr.ia_gid)) - rec->sa_suppgid = op_data->op_attr.ia_gid; + in_group_p(op_data->op_attr.ia_gid)) + rec->sa_suppgid = + from_kgid(&init_user_ns, op_data->op_attr.ia_gid); else rec->sa_suppgid = op_data->op_suppgids[0]; diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index 3cf9d8d3f2ec1..21e8a9d161301 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -377,12 +377,8 @@ static int mdc_xattr_common(struct obd_export *exp,const struct req_format *fmt, sizeof(struct mdt_rec_reint)); rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT); rec->sx_opcode = REINT_SETXATTR; - /* TODO: - * cfs_curproc_fs{u,g}id() should replace - * current->fs{u,g}id for portability. - */ - rec->sx_fsuid = current_fsuid(); - rec->sx_fsgid = current_fsgid(); + rec->sx_fsuid = from_kuid(&init_user_ns, current_fsuid()); + rec->sx_fsgid = from_kgid(&init_user_ns, current_fsgid()); rec->sx_cap = cfs_curproc_cap_pack(); rec->sx_suppgid1 = suppgid; rec->sx_suppgid2 = -1; diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c index 0715cf2af3ce5..799a1ed8701f3 100644 --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c @@ -122,7 +122,8 @@ int lustre_get_jobid(char *jobid) /* Use process name + fsuid as jobid */ if (strcmp(obd_jobid_var, JOBSTATS_PROCNAME_UID) == 0) { snprintf(jobid, JOBSTATS_JOBID_SIZE, "%s.%u", - current_comm(), current_fsuid()); + current_comm(), + from_kuid(&init_user_ns, current_fsuid())); RETURN(0); } diff --git a/drivers/staging/lustre/lustre/obdclass/idmap.c b/drivers/staging/lustre/lustre/obdclass/idmap.c index 622f8d1652759..afb66a49f8285 100644 --- a/drivers/staging/lustre/lustre/obdclass/idmap.c +++ b/drivers/staging/lustre/lustre/obdclass/idmap.c @@ -71,7 +71,8 @@ static int lustre_groups_search(group_info_t *group_info, right = group_info->ngroups; while (left < right) { int mid = (left + right) / 2; - int cmp = grp - CFS_GROUP_AT(group_info, mid); + int cmp = grp - + from_kgid(&init_user_ns, CFS_GROUP_AT(group_info, mid)); if (cmp > 0) left = mid + 1; @@ -116,16 +117,19 @@ void lustre_groups_sort(group_info_t *group_info) for (base = 0; base < max; base++) { int left = base; int right = left + stride; - gid_t tmp = CFS_GROUP_AT(group_info, right); + gid_t tmp = from_kgid(&init_user_ns, + CFS_GROUP_AT(group_info, right)); while (left >= 0 && - CFS_GROUP_AT(group_info, left) > tmp) { + tmp < from_kgid(&init_user_ns, + CFS_GROUP_AT(group_info, left))) { CFS_GROUP_AT(group_info, right) = CFS_GROUP_AT(group_info, left); right = left; left -= stride; } - CFS_GROUP_AT(group_info, right) = tmp; + CFS_GROUP_AT(group_info, right) = + make_kgid(&init_user_ns, tmp); } stride /= 3; } diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-obdo.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-obdo.c index 6ee347153a167..d3bb5ffc564b1 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-obdo.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-obdo.c @@ -213,9 +213,9 @@ void obdo_to_inode(struct inode *dst, struct obdo *src, obd_flag valid) if (valid & OBD_MD_FLMODE) dst->i_mode = (dst->i_mode & S_IFMT) | (src->o_mode & ~S_IFMT); if (valid & OBD_MD_FLUID) - dst->i_uid = src->o_uid; + dst->i_uid = make_kuid(&init_user_ns, src->o_uid); if (valid & OBD_MD_FLGID) - dst->i_gid = src->o_gid; + dst->i_gid = make_kgid(&init_user_ns, src->o_gid); if (valid & OBD_MD_FLFLAGS) dst->i_flags = src->o_flags; } diff --git a/drivers/staging/lustre/lustre/obdclass/obdo.c b/drivers/staging/lustre/lustre/obdclass/obdo.c index 01a0e1f83a684..70997648a4f3c 100644 --- a/drivers/staging/lustre/lustre/obdclass/obdo.c +++ b/drivers/staging/lustre/lustre/obdclass/obdo.c @@ -100,11 +100,11 @@ void obdo_from_inode(struct obdo *dst, struct inode *src, obd_flag valid) newvalid |= OBD_MD_FLMODE; } if (valid & OBD_MD_FLUID) { - dst->o_uid = src->i_uid; + dst->o_uid = from_kuid(&init_user_ns, src->i_uid); newvalid |= OBD_MD_FLUID; } if (valid & OBD_MD_FLGID) { - dst->o_gid = src->i_gid; + dst->o_gid = from_kgid(&init_user_ns, src->i_gid); newvalid |= OBD_MD_FLGID; } if (valid & OBD_MD_FLFLAGS) { @@ -232,16 +232,16 @@ void obdo_from_iattr(struct obdo *oa, struct iattr *attr, unsigned int ia_valid) if (ia_valid & ATTR_MODE) { oa->o_mode = attr->ia_mode; oa->o_valid |= OBD_MD_FLTYPE | OBD_MD_FLMODE; - if (!current_is_in_group(oa->o_gid) && + if (!in_group_p(make_kgid(&init_user_ns, oa->o_gid)) && !cfs_capable(CFS_CAP_FSETID)) oa->o_mode &= ~S_ISGID; } if (ia_valid & ATTR_UID) { - oa->o_uid = attr->ia_uid; + oa->o_uid = from_kuid(&init_user_ns, attr->ia_uid); oa->o_valid |= OBD_MD_FLUID; } if (ia_valid & ATTR_GID) { - oa->o_gid = attr->ia_gid; + oa->o_gid = from_kgid(&init_user_ns, attr->ia_gid); oa->o_valid |= OBD_MD_FLGID; } } @@ -281,16 +281,16 @@ void iattr_from_obdo(struct iattr *attr, struct obdo *oa, obd_flag valid) if (valid & OBD_MD_FLMODE) { attr->ia_mode = (attr->ia_mode & S_IFMT)|(oa->o_mode & ~S_IFMT); attr->ia_valid |= ATTR_MODE; - if (!current_is_in_group(oa->o_gid) && + if (!in_group_p(make_kgid(&init_user_ns, oa->o_gid)) && !cfs_capable(CFS_CAP_FSETID)) attr->ia_mode &= ~S_ISGID; } if (valid & OBD_MD_FLUID) { - attr->ia_uid = oa->o_uid; + attr->ia_uid = make_kuid(&init_user_ns, oa->o_uid); attr->ia_valid |= ATTR_UID; } if (valid & OBD_MD_FLGID) { - attr->ia_gid = oa->o_gid; + attr->ia_gid = make_kgid(&init_user_ns, oa->o_gid); attr->ia_valid |= ATTR_GID; } } diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c index 184195fde6213..ae89ea6f893cf 100644 --- a/drivers/staging/lustre/lustre/obdecho/echo_client.c +++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c @@ -2097,10 +2097,14 @@ static void echo_ucred_init(struct lu_env *env) ucred->uc_suppgids[0] = -1; ucred->uc_suppgids[1] = -1; - ucred->uc_uid = ucred->uc_o_uid = current_uid(); - ucred->uc_gid = ucred->uc_o_gid = current_gid(); - ucred->uc_fsuid = ucred->uc_o_fsuid = current_fsuid(); - ucred->uc_fsgid = ucred->uc_o_fsgid = current_fsgid(); + ucred->uc_uid = ucred->uc_o_uid = + from_kuid(&init_user_ns, current_uid()); + ucred->uc_gid = ucred->uc_o_gid = + from_kgid(&init_user_ns, current_gid()); + ucred->uc_fsuid = ucred->uc_o_fsuid = + from_kuid(&init_user_ns, current_fsuid()); + ucred->uc_fsgid = ucred->uc_o_fsgid = + from_kgid(&init_user_ns, current_fsgid()); ucred->uc_cap = cfs_curproc_cap_pack(); /* remove fs privilege for non-root user. */ diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c b/drivers/staging/lustre/lustre/ptlrpc/sec.c index 36e8bed5458af..349c57b6d78a3 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c @@ -269,8 +269,8 @@ struct ptlrpc_cli_ctx *get_my_ctx(struct ptlrpc_sec *sec) remove_dead = 0; } } else { - vcred.vc_uid = current_uid(); - vcred.vc_gid = current_gid(); + vcred.vc_uid = from_kuid(&init_user_ns, current_uid()); + vcred.vc_gid = from_kgid(&init_user_ns, current_gid()); } return sec->ps_policy->sp_cops->lookup_ctx(sec, &vcred, @@ -1523,7 +1523,8 @@ void sptlrpc_import_flush_root_ctx(struct obd_import *imp) void sptlrpc_import_flush_my_ctx(struct obd_import *imp) { - import_flush_ctx_common(imp, current_uid(), 1, 1); + import_flush_ctx_common(imp, from_kuid(&init_user_ns, current_uid()), + 1, 1); } EXPORT_SYMBOL(sptlrpc_import_flush_my_ctx); @@ -2055,8 +2056,8 @@ int sptlrpc_svc_unwrap_request(struct ptlrpc_request *req) req->rq_flvr.sf_rpc = WIRE_FLVR(msg->lm_secflvr); req->rq_sp_from = LUSTRE_SP_ANY; - req->rq_auth_uid = INVALID_UID; - req->rq_auth_mapped_uid = INVALID_UID; + req->rq_auth_uid = -1; + req->rq_auth_mapped_uid = -1; policy = sptlrpc_wireflavor2policy(req->rq_flvr.sf_rpc); if (!policy) { @@ -2314,10 +2315,10 @@ int sptlrpc_pack_user_desc(struct lustre_msg *msg, int offset) pud = lustre_msg_buf(msg, offset, 0); - pud->pud_uid = current_uid(); - pud->pud_gid = current_gid(); - pud->pud_fsuid = current_fsuid(); - pud->pud_fsgid = current_fsgid(); + pud->pud_uid = from_kuid(&init_user_ns, current_uid()); + pud->pud_gid = from_kgid(&init_user_ns, current_gid()); + pud->pud_fsuid = from_kuid(&init_user_ns, current_fsuid()); + pud->pud_fsgid = from_kgid(&init_user_ns, current_fsgid()); pud->pud_cap = cfs_curproc_cap_pack(); pud->pud_ngroups = (msg->lm_buflens[offset] - sizeof(*pud)) / 4; -- GitLab From 5d4450c41fe308e10a1805cb90d26adbf1267146 Mon Sep 17 00:00:00 2001 From: Peng Tao Date: Mon, 15 Jul 2013 22:27:15 +0800 Subject: [PATCH 012/942] staging/lustre: fix build error on non-x86 platforms dump_trace() is only available on X86. Without it, Lustre's own watchdog is broken. We can only dump current task's stack. The client-side this code is much less likely to hit deadlocks and it's probably OK to drop this altogether, since we hardly have any ptlrpc threads on clients, most notable ones are ldlm cb threads that should not really be blocking on the client anyway. Remove libcfs watchdog for now, until the upstream kernel watchdog can detect distributed deadlocks and dump other kernel threads. Cc: Oleg Drokin Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../lustre/include/linux/libcfs/libcfs.h | 25 - .../include/linux/libcfs/libcfs_private.h | 1 - .../staging/lustre/lustre/include/linux/obd.h | 5 +- .../lustre/lustre/include/lustre_net.h | 7 +- .../staging/lustre/lustre/ldlm/ldlm_lock.c | 2 +- drivers/staging/lustre/lustre/libcfs/Makefile | 2 +- .../lustre/lustre/libcfs/linux/linux-debug.c | 45 +- .../staging/lustre/lustre/libcfs/watchdog.c | 516 ------------------ drivers/staging/lustre/lustre/llite/dcache.c | 2 +- drivers/staging/lustre/lustre/llite/rw.c | 2 +- drivers/staging/lustre/lustre/osc/osc_io.c | 2 +- .../staging/lustre/lustre/ptlrpc/service.c | 8 + 12 files changed, 21 insertions(+), 596 deletions(-) delete mode 100644 drivers/staging/lustre/lustre/libcfs/watchdog.c diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/libcfs.h index 1ab1f2be9aa51..2983ce412b662 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h @@ -117,31 +117,6 @@ int libcfs_sock_write(socket_t *sock, void *buffer, int nob, int timeout); int libcfs_sock_read(socket_t *sock, void *buffer, int nob, int timeout); void libcfs_sock_release(socket_t *sock); -/* libcfs watchdogs */ -struct lc_watchdog; - -/* Add a watchdog which fires after "time" milliseconds of delay. You have to - * touch it once to enable it. */ -struct lc_watchdog *lc_watchdog_add(int time, - void (*cb)(pid_t pid, void *), - void *data); - -/* Enables a watchdog and resets its timer. */ -void lc_watchdog_touch(struct lc_watchdog *lcw, int timeout); -#define CFS_GET_TIMEOUT(svc) (max_t(int, obd_timeout, \ - AT_OFF ? 0 : at_get(&svc->srv_at_estimate)) * \ - svc->srv_watchdog_factor) - -/* Disable a watchdog; touch it to restart it. */ -void lc_watchdog_disable(struct lc_watchdog *lcw); - -/* Clean up the watchdog */ -void lc_watchdog_delete(struct lc_watchdog *lcw); - -/* Dump a debug log */ -void lc_watchdog_dumplog(pid_t pid, void *data); - - /* need both kernel and user-land acceptor */ #define LNET_ACCEPTOR_MIN_RESERVED_PORT 512 #define LNET_ACCEPTOR_MAX_RESERVED_PORT 1023 diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h index 056caa467126b..62ef8a7490023 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h @@ -210,7 +210,6 @@ do { \ #define ntohs(x) ___ntohs(x) #endif -void libcfs_debug_dumpstack(task_t *tsk); void libcfs_run_upcall(char **argv); void libcfs_run_lbug_upcall(struct libcfs_debug_msg_data *); void libcfs_debug_dumplog(void); diff --git a/drivers/staging/lustre/lustre/include/linux/obd.h b/drivers/staging/lustre/lustre/include/linux/obd.h index 2c36c0d19d06b..01a50265239d4 100644 --- a/drivers/staging/lustre/lustre/include/linux/obd.h +++ b/drivers/staging/lustre/lustre/include/linux/obd.h @@ -93,11 +93,8 @@ static inline void __client_obd_list_lock(client_obd_lock_t *lock, lock, task->comm, task->pid, lock->func, lock->line, (jiffies - lock->time) / HZ); - LCONSOLE_WARN("====== for process holding the " - "lock =====\n"); - libcfs_debug_dumpstack(task); LCONSOLE_WARN("====== for current process =====\n"); - libcfs_debug_dumpstack(NULL); + dump_stack(); LCONSOLE_WARN("====== end =======\n"); cfs_pause(1000 * HZ); } diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h index 293dd90e5b6cd..1b99b5d2b4f17 100644 --- a/drivers/staging/lustre/lustre/include/lustre_net.h +++ b/drivers/staging/lustre/lustre/include/lustre_net.h @@ -2322,8 +2322,13 @@ struct ptlrpc_thread { pid_t t_pid; /** * put watchdog in the structure per thread b=14840 + * + * Lustre watchdog is removed for client in the hope + * of a generic watchdog can be merged in kernel. + * When that happens, we should add below back. + * + * struct lc_watchdog *t_watchdog; */ - struct lc_watchdog *t_watchdog; /** * the svc this thread belonged to b=18582 */ diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index 33b76a1e5dec8..93badf5c29571 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -1548,7 +1548,7 @@ int ldlm_fill_lvb(struct ldlm_lock *lock, struct req_capsule *pill, break; default: LDLM_ERROR(lock, "Unknown LVB type: %d\n", lock->l_lvb_type); - libcfs_debug_dumpstack(NULL); + dump_stack(); RETURN(-EINVAL); } diff --git a/drivers/staging/lustre/lustre/libcfs/Makefile b/drivers/staging/lustre/lustre/libcfs/Makefile index bf5c563dcacc1..6e489d7aaa8b3 100644 --- a/drivers/staging/lustre/lustre/libcfs/Makefile +++ b/drivers/staging/lustre/lustre/libcfs/Makefile @@ -11,7 +11,7 @@ libcfs-linux-objs += linux-crypto-adler.o libcfs-linux-objs := $(addprefix linux/,$(libcfs-linux-objs)) libcfs-all-objs := debug.o fail.o nidstrings.o module.o tracefile.o \ - watchdog.o libcfs_string.o hash.o kernel_user_comm.o \ + libcfs_string.o hash.o kernel_user_comm.o \ prng.o workitem.o upcall_cache.o libcfs_cpu.o \ libcfs_mem.o libcfs_lock.o diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c index e2c195b8dd53c..9b5fa919aa4af 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c @@ -168,7 +168,7 @@ void lbug_with_loc(struct libcfs_debug_msg_data *msgdata) /* not reached */ } - libcfs_debug_dumpstack(NULL); + dump_stack(); if (!libcfs_panic_on_lbug) libcfs_debug_dumplog(); libcfs_run_lbug_upcall(msgdata); @@ -179,48 +179,6 @@ void lbug_with_loc(struct libcfs_debug_msg_data *msgdata) schedule(); } - -#include -#include - - -static int print_trace_stack(void *data, char *name) -{ - printk(" <%s> ", name); - return 0; -} - -# define RELIABLE reliable -# define DUMP_TRACE_CONST const -static void print_trace_address(void *data, unsigned long addr, int reliable) -{ - char fmt[32]; - touch_nmi_watchdog(); - sprintf(fmt, " [<%016lx>] %s%%s\n", addr, RELIABLE ? "": "? "); - __print_symbol(fmt, addr); -} - -static DUMP_TRACE_CONST struct stacktrace_ops print_trace_ops = { - .stack = print_trace_stack, - .address = print_trace_address, - .walk_stack = print_context_stack, -}; - -void libcfs_debug_dumpstack(struct task_struct *tsk) -{ - /* dump_stack() */ - /* show_trace() */ - if (tsk == NULL) - tsk = current; - printk("Pid: %d, comm: %.20s\n", tsk->pid, tsk->comm); - /* show_trace_log_lvl() */ - printk("\nCall Trace:\n"); - dump_trace(tsk, NULL, NULL, - 0, - &print_trace_ops, NULL); - printk("\n"); -} - task_t *libcfs_current(void) { CWARN("current task struct is %p\n", current); @@ -255,7 +213,6 @@ void libcfs_unregister_panic_notifier(void) atomic_notifier_chain_unregister(&panic_notifier_list, &libcfs_panic_notifier); } -EXPORT_SYMBOL(libcfs_debug_dumpstack); EXPORT_SYMBOL(libcfs_current); diff --git a/drivers/staging/lustre/lustre/libcfs/watchdog.c b/drivers/staging/lustre/lustre/libcfs/watchdog.c deleted file mode 100644 index 7c385ada3e101..0000000000000 --- a/drivers/staging/lustre/lustre/libcfs/watchdog.c +++ /dev/null @@ -1,516 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * 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 version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2012, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * libcfs/libcfs/watchdog.c - * - * Author: Jacob Berkman - */ - -#define DEBUG_SUBSYSTEM S_LNET - -#include -#include "tracefile.h" - -struct lc_watchdog { - spinlock_t lcw_lock; /* check or change lcw_list */ - int lcw_refcount; /* must hold lcw_pending_timers_lock */ - timer_list_t lcw_timer; /* kernel timer */ - struct list_head lcw_list; /* chain on pending list */ - cfs_time_t lcw_last_touched; /* last touched stamp */ - task_t *lcw_task; /* owner task */ - void (*lcw_callback)(pid_t, void *); - void *lcw_data; - - pid_t lcw_pid; - - enum { - LC_WATCHDOG_DISABLED, - LC_WATCHDOG_ENABLED, - LC_WATCHDOG_EXPIRED - } lcw_state; -}; - -#ifdef WITH_WATCHDOG -/* - * The dispatcher will complete lcw_start_completion when it starts, - * and lcw_stop_completion when it exits. - * Wake lcw_event_waitq to signal timer callback dispatches. - */ -static struct completion lcw_start_completion; -static struct completion lcw_stop_completion; -static wait_queue_head_t lcw_event_waitq; - -/* - * Set this and wake lcw_event_waitq to stop the dispatcher. - */ -enum { - LCW_FLAG_STOP = 0 -}; -static unsigned long lcw_flags = 0; - -/* - * Number of outstanding watchdogs. - * When it hits 1, we start the dispatcher. - * When it hits 0, we stop the dispatcher. - */ -static __u32 lcw_refcount = 0; -static DEFINE_MUTEX(lcw_refcount_mutex); - -/* - * List of timers that have fired that need their callbacks run by the - * dispatcher. - */ -/* BH lock! */ -static DEFINE_SPINLOCK(lcw_pending_timers_lock); -static struct list_head lcw_pending_timers = LIST_HEAD_INIT(lcw_pending_timers); - -/* Last time a watchdog expired */ -static cfs_time_t lcw_last_watchdog_time; -static int lcw_recent_watchdog_count; - -static void -lcw_dump(struct lc_watchdog *lcw) -{ - ENTRY; - rcu_read_lock(); - if (lcw->lcw_task == NULL) { - LCONSOLE_WARN("Process " LPPID " was not found in the task " - "list; watchdog callback may be incomplete\n", - (int)lcw->lcw_pid); - } else { - libcfs_debug_dumpstack(lcw->lcw_task); - } - - rcu_read_unlock(); - EXIT; -} - -static void lcw_cb(ulong_ptr_t data) -{ - struct lc_watchdog *lcw = (struct lc_watchdog *)data; - ENTRY; - - if (lcw->lcw_state != LC_WATCHDOG_ENABLED) { - EXIT; - return; - } - - lcw->lcw_state = LC_WATCHDOG_EXPIRED; - - spin_lock_bh(&lcw->lcw_lock); - LASSERT(list_empty(&lcw->lcw_list)); - - spin_lock_bh(&lcw_pending_timers_lock); - lcw->lcw_refcount++; /* +1 for pending list */ - list_add(&lcw->lcw_list, &lcw_pending_timers); - wake_up(&lcw_event_waitq); - - spin_unlock_bh(&lcw_pending_timers_lock); - spin_unlock_bh(&lcw->lcw_lock); - EXIT; -} - -static int is_watchdog_fired(void) -{ - int rc; - - if (test_bit(LCW_FLAG_STOP, &lcw_flags)) - return 1; - - spin_lock_bh(&lcw_pending_timers_lock); - rc = !list_empty(&lcw_pending_timers); - spin_unlock_bh(&lcw_pending_timers_lock); - return rc; -} - -static void lcw_dump_stack(struct lc_watchdog *lcw) -{ - cfs_time_t current_time; - cfs_duration_t delta_time; - struct timeval timediff; - - current_time = cfs_time_current(); - delta_time = cfs_time_sub(current_time, lcw->lcw_last_touched); - cfs_duration_usec(delta_time, &timediff); - - /* - * Check to see if we should throttle the watchdog timer to avoid - * too many dumps going to the console thus triggering an NMI. - */ - delta_time = cfs_duration_sec(cfs_time_sub(current_time, - lcw_last_watchdog_time)); - - if (delta_time < libcfs_watchdog_ratelimit && - lcw_recent_watchdog_count > 3) { - LCONSOLE_WARN("Service thread pid %u was inactive for " - "%lu.%.02lus. Watchdog stack traces are limited " - "to 3 per %d seconds, skipping this one.\n", - (int)lcw->lcw_pid, - timediff.tv_sec, - timediff.tv_usec / 10000, - libcfs_watchdog_ratelimit); - } else { - if (delta_time < libcfs_watchdog_ratelimit) { - lcw_recent_watchdog_count++; - } else { - memcpy(&lcw_last_watchdog_time, ¤t_time, - sizeof(current_time)); - lcw_recent_watchdog_count = 0; - } - - LCONSOLE_WARN("Service thread pid %u was inactive for " - "%lu.%.02lus. The thread might be hung, or it " - "might only be slow and will resume later. " - "Dumping the stack trace for debugging purposes:" - "\n", - (int)lcw->lcw_pid, - timediff.tv_sec, - timediff.tv_usec / 10000); - lcw_dump(lcw); - } -} - -static int lcw_dispatch_main(void *data) -{ - int rc = 0; - struct lc_watchdog *lcw; - LIST_HEAD (zombies); - - ENTRY; - - complete(&lcw_start_completion); - - while (1) { - int dumplog = 1; - - cfs_wait_event_interruptible(lcw_event_waitq, - is_watchdog_fired(), rc); - CDEBUG(D_INFO, "Watchdog got woken up...\n"); - if (test_bit(LCW_FLAG_STOP, &lcw_flags)) { - CDEBUG(D_INFO, "LCW_FLAG_STOP set, shutting down...\n"); - - spin_lock_bh(&lcw_pending_timers_lock); - rc = !list_empty(&lcw_pending_timers); - spin_unlock_bh(&lcw_pending_timers_lock); - if (rc) { - CERROR("pending timers list was not empty at " - "time of watchdog dispatch shutdown\n"); - } - break; - } - - spin_lock_bh(&lcw_pending_timers_lock); - while (!list_empty(&lcw_pending_timers)) { - int is_dumplog; - - lcw = list_entry(lcw_pending_timers.next, - struct lc_watchdog, lcw_list); - /* +1 ref for callback to make sure lwc wouldn't be - * deleted after releasing lcw_pending_timers_lock */ - lcw->lcw_refcount++; - spin_unlock_bh(&lcw_pending_timers_lock); - - /* lock ordering */ - spin_lock_bh(&lcw->lcw_lock); - spin_lock_bh(&lcw_pending_timers_lock); - - if (list_empty(&lcw->lcw_list)) { - /* already removed from pending list */ - lcw->lcw_refcount--; /* -1 ref for callback */ - if (lcw->lcw_refcount == 0) - list_add(&lcw->lcw_list, &zombies); - spin_unlock_bh(&lcw->lcw_lock); - /* still hold lcw_pending_timers_lock */ - continue; - } - - list_del_init(&lcw->lcw_list); - lcw->lcw_refcount--; /* -1 ref for pending list */ - - spin_unlock_bh(&lcw_pending_timers_lock); - spin_unlock_bh(&lcw->lcw_lock); - - CDEBUG(D_INFO, "found lcw for pid " LPPID "\n", - lcw->lcw_pid); - lcw_dump_stack(lcw); - - is_dumplog = lcw->lcw_callback == lc_watchdog_dumplog; - if (lcw->lcw_state != LC_WATCHDOG_DISABLED && - (dumplog || !is_dumplog)) { - lcw->lcw_callback(lcw->lcw_pid, lcw->lcw_data); - if (dumplog && is_dumplog) - dumplog = 0; - } - - spin_lock_bh(&lcw_pending_timers_lock); - lcw->lcw_refcount--; /* -1 ref for callback */ - if (lcw->lcw_refcount == 0) - list_add(&lcw->lcw_list, &zombies); - } - spin_unlock_bh(&lcw_pending_timers_lock); - - while (!list_empty(&zombies)) { - lcw = list_entry(lcw_pending_timers.next, - struct lc_watchdog, lcw_list); - list_del(&lcw->lcw_list); - LIBCFS_FREE(lcw, sizeof(*lcw)); - } - } - - complete(&lcw_stop_completion); - - RETURN(rc); -} - -static void lcw_dispatch_start(void) -{ - task_t *task; - - ENTRY; - LASSERT(lcw_refcount == 1); - - init_completion(&lcw_stop_completion); - init_completion(&lcw_start_completion); - init_waitqueue_head(&lcw_event_waitq); - - CDEBUG(D_INFO, "starting dispatch thread\n"); - task = kthread_run(lcw_dispatch_main, NULL, "lc_watchdogd"); - if (IS_ERR(task)) { - CERROR("error spawning watchdog dispatch thread: %ld\n", - PTR_ERR(task)); - EXIT; - return; - } - wait_for_completion(&lcw_start_completion); - CDEBUG(D_INFO, "watchdog dispatcher initialization complete.\n"); - - EXIT; -} - -static void lcw_dispatch_stop(void) -{ - ENTRY; - LASSERT(lcw_refcount == 0); - - CDEBUG(D_INFO, "trying to stop watchdog dispatcher.\n"); - - set_bit(LCW_FLAG_STOP, &lcw_flags); - wake_up(&lcw_event_waitq); - - wait_for_completion(&lcw_stop_completion); - - CDEBUG(D_INFO, "watchdog dispatcher has shut down.\n"); - - EXIT; -} - -struct lc_watchdog *lc_watchdog_add(int timeout, - void (*callback)(pid_t, void *), - void *data) -{ - struct lc_watchdog *lcw = NULL; - ENTRY; - - LIBCFS_ALLOC(lcw, sizeof(*lcw)); - if (lcw == NULL) { - CDEBUG(D_INFO, "Could not allocate new lc_watchdog\n"); - RETURN(ERR_PTR(-ENOMEM)); - } - - spin_lock_init(&lcw->lcw_lock); - lcw->lcw_refcount = 1; /* refcount for owner */ - lcw->lcw_task = current; - lcw->lcw_pid = current_pid(); - lcw->lcw_callback = (callback != NULL) ? callback : lc_watchdog_dumplog; - lcw->lcw_data = data; - lcw->lcw_state = LC_WATCHDOG_DISABLED; - - INIT_LIST_HEAD(&lcw->lcw_list); - cfs_timer_init(&lcw->lcw_timer, lcw_cb, lcw); - - mutex_lock(&lcw_refcount_mutex); - if (++lcw_refcount == 1) - lcw_dispatch_start(); - mutex_unlock(&lcw_refcount_mutex); - - /* Keep this working in case we enable them by default */ - if (lcw->lcw_state == LC_WATCHDOG_ENABLED) { - lcw->lcw_last_touched = cfs_time_current(); - cfs_timer_arm(&lcw->lcw_timer, cfs_time_seconds(timeout) + - cfs_time_current()); - } - - RETURN(lcw); -} -EXPORT_SYMBOL(lc_watchdog_add); - -static void lcw_update_time(struct lc_watchdog *lcw, const char *message) -{ - cfs_time_t newtime = cfs_time_current();; - - if (lcw->lcw_state == LC_WATCHDOG_EXPIRED) { - struct timeval timediff; - cfs_time_t delta_time = cfs_time_sub(newtime, - lcw->lcw_last_touched); - cfs_duration_usec(delta_time, &timediff); - - LCONSOLE_WARN("Service thread pid %u %s after %lu.%.02lus. " - "This indicates the system was overloaded (too " - "many service threads, or there were not enough " - "hardware resources).\n", - lcw->lcw_pid, - message, - timediff.tv_sec, - timediff.tv_usec / 10000); - } - lcw->lcw_last_touched = newtime; -} - -static void lc_watchdog_del_pending(struct lc_watchdog *lcw) -{ - spin_lock_bh(&lcw->lcw_lock); - if (unlikely(!list_empty(&lcw->lcw_list))) { - spin_lock_bh(&lcw_pending_timers_lock); - list_del_init(&lcw->lcw_list); - lcw->lcw_refcount--; /* -1 ref for pending list */ - spin_unlock_bh(&lcw_pending_timers_lock); - } - - spin_unlock_bh(&lcw->lcw_lock); -} - -void lc_watchdog_touch(struct lc_watchdog *lcw, int timeout) -{ - ENTRY; - LASSERT(lcw != NULL); - - lc_watchdog_del_pending(lcw); - - lcw_update_time(lcw, "resumed"); - lcw->lcw_state = LC_WATCHDOG_ENABLED; - - cfs_timer_arm(&lcw->lcw_timer, cfs_time_current() + - cfs_time_seconds(timeout)); - - EXIT; -} -EXPORT_SYMBOL(lc_watchdog_touch); - -void lc_watchdog_disable(struct lc_watchdog *lcw) -{ - ENTRY; - LASSERT(lcw != NULL); - - lc_watchdog_del_pending(lcw); - - lcw_update_time(lcw, "completed"); - lcw->lcw_state = LC_WATCHDOG_DISABLED; - - EXIT; -} -EXPORT_SYMBOL(lc_watchdog_disable); - -void lc_watchdog_delete(struct lc_watchdog *lcw) -{ - int dead; - - ENTRY; - LASSERT(lcw != NULL); - - cfs_timer_disarm(&lcw->lcw_timer); - - lcw_update_time(lcw, "stopped"); - - spin_lock_bh(&lcw->lcw_lock); - spin_lock_bh(&lcw_pending_timers_lock); - if (unlikely(!list_empty(&lcw->lcw_list))) { - list_del_init(&lcw->lcw_list); - lcw->lcw_refcount--; /* -1 ref for pending list */ - } - - lcw->lcw_refcount--; /* -1 ref for owner */ - dead = lcw->lcw_refcount == 0; - spin_unlock_bh(&lcw_pending_timers_lock); - spin_unlock_bh(&lcw->lcw_lock); - - if (dead) - LIBCFS_FREE(lcw, sizeof(*lcw)); - - mutex_lock(&lcw_refcount_mutex); - if (--lcw_refcount == 0) - lcw_dispatch_stop(); - mutex_unlock(&lcw_refcount_mutex); - - EXIT; -} -EXPORT_SYMBOL(lc_watchdog_delete); - -/* - * Provided watchdog handlers - */ - -void lc_watchdog_dumplog(pid_t pid, void *data) -{ - libcfs_debug_dumplog_internal((void *)((long_ptr_t)pid)); -} -EXPORT_SYMBOL(lc_watchdog_dumplog); - -#else /* !defined(WITH_WATCHDOG) */ - -struct lc_watchdog *lc_watchdog_add(int timeout, - void (*callback)(pid_t pid, void *), - void *data) -{ - static struct lc_watchdog watchdog; - return &watchdog; -} -EXPORT_SYMBOL(lc_watchdog_add); - -void lc_watchdog_touch(struct lc_watchdog *lcw, int timeout) -{ -} -EXPORT_SYMBOL(lc_watchdog_touch); - -void lc_watchdog_disable(struct lc_watchdog *lcw) -{ -} -EXPORT_SYMBOL(lc_watchdog_disable); - -void lc_watchdog_delete(struct lc_watchdog *lcw) -{ -} -EXPORT_SYMBOL(lc_watchdog_delete); - -#endif diff --git a/drivers/staging/lustre/lustre/llite/dcache.c b/drivers/staging/lustre/lustre/llite/dcache.c index ff0d085077c84..40b0f3b1debc6 100644 --- a/drivers/staging/lustre/lustre/llite/dcache.c +++ b/drivers/staging/lustre/lustre/llite/dcache.c @@ -300,7 +300,7 @@ void ll_invalidate_aliases(struct inode *inode) CERROR("called on root (?) dentry=%p, inode=%p " "ino=%lu\n", dentry, inode, inode->i_ino); lustre_dump_dentry(dentry, 1); - libcfs_debug_dumpstack(NULL); + dump_stack(); } d_lustre_invalidate(dentry, 0); diff --git a/drivers/staging/lustre/lustre/llite/rw.c b/drivers/staging/lustre/lustre/llite/rw.c index fac1178890118..f48766e6a2128 100644 --- a/drivers/staging/lustre/lustre/llite/rw.c +++ b/drivers/staging/lustre/lustre/llite/rw.c @@ -132,7 +132,7 @@ static struct ll_cl_context *ll_cl_init(struct file *file, * add dirty pages into cache during truncate */ CERROR("Proc %s is dirting page w/o inode lock, this" "will break truncate.\n", current->comm); - libcfs_debug_dumpstack(NULL); + dump_stack(); LBUG(); return ERR_PTR(-EIO); } diff --git a/drivers/staging/lustre/lustre/osc/osc_io.c b/drivers/staging/lustre/lustre/osc/osc_io.c index 1b277045b3e43..70aad1aeec633 100644 --- a/drivers/staging/lustre/lustre/osc/osc_io.c +++ b/drivers/staging/lustre/lustre/osc/osc_io.c @@ -785,7 +785,7 @@ static void osc_req_attr_set(const struct lu_env *env, "no cover page!\n"); CL_PAGE_DEBUG(D_ERROR, env, apage, "dump uncover page!\n"); - libcfs_debug_dumpstack(NULL); + dump_stack(); LBUG(); } diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index cd1bab5a25207..6871711023190 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -2254,7 +2254,9 @@ ptlrpc_wait_event(struct ptlrpc_service_part *svcpt, struct l_wait_info lwi = LWI_TIMEOUT(svcpt->scp_rqbd_timeout, ptlrpc_retry_rqbds, svcpt); + /* XXX: Add this back when libcfs watchdog is merged upstream lc_watchdog_disable(thread->t_watchdog); + */ cond_resched(); @@ -2268,8 +2270,10 @@ ptlrpc_wait_event(struct ptlrpc_service_part *svcpt, if (ptlrpc_thread_stopping(thread)) return -EINTR; + /* lc_watchdog_touch(thread->t_watchdog, ptlrpc_server_get_timeout(svcpt)); + */ return 0; } @@ -2372,8 +2376,10 @@ static int ptlrpc_main(void *arg) /* wake up our creator in case he's still waiting. */ wake_up(&thread->t_ctl_waitq); + /* thread->t_watchdog = lc_watchdog_add(ptlrpc_server_get_timeout(svcpt), NULL, NULL); + */ spin_lock(&svcpt->scp_rep_lock); list_add(&rs->rs_list, &svcpt->scp_rep_idle); @@ -2428,8 +2434,10 @@ static int ptlrpc_main(void *arg) } } + /* lc_watchdog_delete(thread->t_watchdog); thread->t_watchdog = NULL; + */ out_srv_fini: /* -- GitLab From b69835a2c41dead0d5d44265e797d9d4a3b67174 Mon Sep 17 00:00:00 2001 From: Peng Tao Date: Mon, 15 Jul 2013 22:27:16 +0800 Subject: [PATCH 013/942] staging/lustre: fix build warnning on 32bit system MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Building on 32bit system, I got warnings like below: drivers/staging/lustre/lustre/llite/../include/lprocfs_status.h:666:7: note: expected ‘long unsigned int *’ but argument is of type ‘size_t *’ char *lprocfs_find_named_value(const char *buffer, const char *name, drivers/staging/lustre/lustre/lov/lov_io.c: In function ‘lov_io_rw_iter_init’: include/asm-generic/div64.h:43:28: warning: comparison of distinct pointer types lacks a cast [enabled by default] (void)(((typeof((n)) *)0) == ((uint64_t *)0)); \ Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/lprocfs_status.h | 4 ++-- drivers/staging/lustre/lustre/lov/lov_io.c | 2 +- drivers/staging/lustre/lustre/obdclass/lprocfs_status.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index 55f182205d785..294fb7807c8c1 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -663,8 +663,8 @@ extern int lprocfs_write_u64_helper(const char *buffer, unsigned long count, extern int lprocfs_write_frac_u64_helper(const char *buffer, unsigned long count, __u64 *val, int mult); -char *lprocfs_find_named_value(const char *buffer, const char *name, - unsigned long *count); +extern char *lprocfs_find_named_value(const char *buffer, const char *name, + size_t *count); void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value); void lprocfs_oh_tally_log2(struct obd_histogram *oh, unsigned int value); void lprocfs_oh_clear(struct obd_histogram *oh); diff --git a/drivers/staging/lustre/lustre/lov/lov_io.c b/drivers/staging/lustre/lustre/lov/lov_io.c index 1a87abdf09532..022e0f4911c64 100644 --- a/drivers/staging/lustre/lustre/lov/lov_io.c +++ b/drivers/staging/lustre/lustre/lov/lov_io.c @@ -430,7 +430,7 @@ static int lov_io_rw_iter_init(const struct lu_env *env, struct lov_io *lio = cl2lov_io(env, ios); struct cl_io *io = ios->cis_io; struct lov_stripe_md *lsm = lio->lis_object->lo_lsm; - loff_t start = io->u.ci_rw.crw_pos; + __u64 start = io->u.ci_rw.crw_pos; loff_t next; unsigned long ssize = lsm->lsm_stripe_size; diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index f7af3d6a4efcb..85163f42892e6 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -1873,7 +1873,7 @@ static char *lprocfs_strnstr(const char *s1, const char *s2, size_t len) * If \a name is not found the original \a buffer is returned. */ char *lprocfs_find_named_value(const char *buffer, const char *name, - unsigned long *count) + size_t *count) { char *val; size_t buflen = *count; -- GitLab From 5237c44194a5605257b09af5b421dd6995645e65 Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Mon, 15 Jul 2013 22:27:17 +0800 Subject: [PATCH 014/942] staging/lustre: fix for invalidatepage() API change somehow this got dropped during merge window... Signed-off-by: Stephen Rothwell Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/include/linux/lustre_patchless_compat.h | 2 +- drivers/staging/lustre/lustre/llite/rw26.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_patchless_compat.h b/drivers/staging/lustre/lustre/include/linux/lustre_patchless_compat.h index a8e9c0c8ffd23..a260e99a4447e 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_patchless_compat.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_patchless_compat.h @@ -53,7 +53,7 @@ truncate_complete_page(struct address_space *mapping, struct page *page) return; if (PagePrivate(page)) - page->mapping->a_ops->invalidatepage(page, 0); + page->mapping->a_ops->invalidatepage(page, 0, PAGE_CACHE_SIZE); cancel_dirty_page(page, PAGE_SIZE); ClearPageMappedToDisk(page); diff --git a/drivers/staging/lustre/lustre/llite/rw26.c b/drivers/staging/lustre/lustre/llite/rw26.c index 27e4e64bc1e7b..f1a1c5f40a1d4 100644 --- a/drivers/staging/lustre/lustre/llite/rw26.c +++ b/drivers/staging/lustre/lustre/llite/rw26.c @@ -72,7 +72,8 @@ * aligned truncate). Lustre leaves partially truncated page in the cache, * relying on struct inode::i_size to limit further accesses. */ -static void ll_invalidatepage(struct page *vmpage, unsigned long offset) +static void ll_invalidatepage(struct page *vmpage, unsigned int offset, + unsigned int length) { struct inode *inode; struct lu_env *env; @@ -89,7 +90,7 @@ static void ll_invalidatepage(struct page *vmpage, unsigned long offset) * below because they are run with page locked and all our io is * happening with locked page too */ - if (offset == 0) { + if (offset == 0 && length == PAGE_CACHE_SIZE) { env = cl_env_get(&refcheck); if (!IS_ERR(env)) { inode = vmpage->mapping->host; -- GitLab From 90181e1d03b2a1bc054a11c061ef61ddd1dd7b87 Mon Sep 17 00:00:00 2001 From: Peng Tao Date: Mon, 15 Jul 2013 22:27:18 +0800 Subject: [PATCH 015/942] staging/lustre/llite: fix for d_compare API change Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/dcache.c | 3 +-- drivers/staging/lustre/lustre/llite/llite_internal.h | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/dcache.c b/drivers/staging/lustre/lustre/llite/dcache.c index 40b0f3b1debc6..a160a840d5829 100644 --- a/drivers/staging/lustre/lustre/llite/dcache.c +++ b/drivers/staging/lustre/lustre/llite/dcache.c @@ -84,8 +84,7 @@ static void ll_release(struct dentry *de) * an AST before calling d_revalidate_it(). The dentry still exists (marked * INVALID) so d_lookup() matches it, but we have no lock on it (so * lock_match() fails) and we spin around real_lookup(). */ -int ll_dcompare(const struct dentry *parent, const struct inode *pinode, - const struct dentry *dentry, const struct inode *inode, +int ll_dcompare(const struct dentry *parent, const struct dentry *dentry, unsigned int len, const char *str, const struct qstr *name) { ENTRY; diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 1069b8dd84dcb..cbcd11847aac4 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -784,8 +784,7 @@ void ll_intent_release(struct lookup_intent *); void ll_invalidate_aliases(struct inode *); void ll_frob_intent(struct lookup_intent **itp, struct lookup_intent *deft); void ll_lookup_finish_locks(struct lookup_intent *it, struct dentry *dentry); -int ll_dcompare(const struct dentry *parent, const struct inode *pinode, - const struct dentry *dentry, const struct inode *inode, +int ll_dcompare(const struct dentry *parent, const struct dentry *dentry, unsigned int len, const char *str, const struct qstr *d_name); int ll_revalidate_it_finish(struct ptlrpc_request *request, struct lookup_intent *it, struct dentry *de); -- GitLab From 0b09d381bb2b4ccab15711cf98858a7146b24749 Mon Sep 17 00:00:00 2001 From: Peng Tao Date: Mon, 15 Jul 2013 22:27:19 +0800 Subject: [PATCH 016/942] staging/lustre/llite: readdir convert to iterate Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/dir.c | 45 +++++++++---------- .../lustre/lustre/llite/llite_internal.h | 4 +- .../staging/lustre/lustre/llite/llite_nfs.c | 13 +++--- 3 files changed, 28 insertions(+), 34 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index e2afb97303434..1084999be959c 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -483,12 +483,11 @@ struct page *ll_get_dir_page(struct inode *dir, __u64 hash, goto out_unlock; } -int ll_dir_read(struct inode *inode, __u64 *_pos, void *cookie, - filldir_t filldir) +int ll_dir_read(struct inode *inode, struct dir_context *ctx) { struct ll_inode_info *info = ll_i2info(inode); struct ll_sb_info *sbi = ll_i2sbi(inode); - __u64 pos = *_pos; + __u64 pos = ctx->pos; int api32 = ll_need_32bit_api(sbi); int hash64 = sbi->ll_flags & LL_SBI_64BIT_HASH; struct page *page; @@ -548,12 +547,14 @@ int ll_dir_read(struct inode *inode, __u64 *_pos, void *cookie, fid_le_to_cpu(&fid, &ent->lde_fid); ino = cl_fid_build_ino(&fid, api32); type = ll_dirent_type_get(ent); + ctx->pos = lhash; /* For 'll_nfs_get_name_filldir()', it will try * to access the 'ent' through its 'lde_name', - * so the parameter 'name' for 'filldir()' must - * be part of the 'ent'. */ - done = filldir(cookie, ent->lde_name, namelen, - lhash, ino, type); + * so the parameter 'name' for 'ctx->actor()' + * must be part of the 'ent'. + */ + done = !dir_emit(ctx, ent->lde_name, + namelen, ino, type); } next = le64_to_cpu(dp->ldp_hash_end); if (!done) { @@ -594,50 +595,44 @@ int ll_dir_read(struct inode *inode, __u64 *_pos, void *cookie, } } - *_pos = pos; + ctx->pos = pos; ll_dir_chain_fini(&chain); RETURN(rc); } -static int ll_readdir(struct file *filp, void *cookie, filldir_t filldir) +static int ll_readdir(struct file *filp, struct dir_context *ctx) { struct inode *inode = filp->f_dentry->d_inode; struct ll_file_data *lfd = LUSTRE_FPRIVATE(filp); struct ll_sb_info *sbi = ll_i2sbi(inode); - __u64 pos = lfd->lfd_pos; int hash64 = sbi->ll_flags & LL_SBI_64BIT_HASH; int api32 = ll_need_32bit_api(sbi); int rc; - struct path path; ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p) pos %lu/%llu " " 32bit_api %d\n", inode->i_ino, inode->i_generation, - inode, (unsigned long)pos, i_size_read(inode), api32); + inode, (unsigned long)lfd->lfd_pos, i_size_read(inode), api32); - if (pos == MDS_DIR_END_OFF) + if (lfd->lfd_pos == MDS_DIR_END_OFF) /* * end-of-file. */ GOTO(out, rc = 0); - rc = ll_dir_read(inode, &pos, cookie, filldir); - lfd->lfd_pos = pos; - if (pos == MDS_DIR_END_OFF) { + ctx->pos = lfd->lfd_pos; + rc = ll_dir_read(inode, ctx); + lfd->lfd_pos = ctx->pos; + if (ctx->pos == MDS_DIR_END_OFF) { if (api32) - filp->f_pos = LL_DIR_END_OFF_32BIT; + ctx->pos = LL_DIR_END_OFF_32BIT; else - filp->f_pos = LL_DIR_END_OFF; + ctx->pos = LL_DIR_END_OFF; } else { if (api32 && hash64) - filp->f_pos = pos >> 32; - else - filp->f_pos = pos; + ctx->pos >>= 32; } filp->f_version = inode->i_version; - path.mnt = filp->f_path.mnt; - path.dentry = filp->f_dentry; - touch_atime(&path); out: if (!rc) @@ -1976,7 +1971,7 @@ struct file_operations ll_dir_operations = { .open = ll_dir_open, .release = ll_dir_release, .read = generic_read_dir, - .readdir = ll_readdir, + .iterate = ll_readdir, .unlocked_ioctl = ll_dir_ioctl, .fsync = ll_fsync, }; diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index cbcd11847aac4..0534665df905a 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -90,6 +90,7 @@ extern struct file_operations ll_pgcache_seq_fops; #define REMOTE_PERM_HASHSIZE 16 struct ll_getname_data { + struct dir_context ctx; char *lgd_name; /* points to a buffer with NAME_MAX+1 size */ struct lu_fid lgd_fid; /* target fid we are looking for */ int lgd_found; /* inode matched? */ @@ -679,8 +680,7 @@ extern struct file_operations ll_dir_operations; extern struct inode_operations ll_dir_inode_operations; struct page *ll_get_dir_page(struct inode *dir, __u64 hash, struct ll_dir_chain *chain); -int ll_dir_read(struct inode *inode, __u64 *_pos, void *cookie, - filldir_t filldir); +int ll_dir_read(struct inode *inode, struct dir_context *ctx); int ll_get_mdt_idx(struct inode *inode); /* llite/namei.c */ diff --git a/drivers/staging/lustre/lustre/llite/llite_nfs.c b/drivers/staging/lustre/lustre/llite/llite_nfs.c index 28cc41e90581a..f142a1ec3f86f 100644 --- a/drivers/staging/lustre/lustre/llite/llite_nfs.c +++ b/drivers/staging/lustre/lustre/llite/llite_nfs.c @@ -214,9 +214,12 @@ static int ll_get_name(struct dentry *dentry, char *name, struct dentry *child) { struct inode *dir = dentry->d_inode; - struct ll_getname_data lgd; - __u64 offset = 0; int rc; + struct ll_getname_data lgd = { + .lgd_name = name, + .lgd_fid = ll_i2info(child->d_inode)->lli_fid, + .ctx.actor = ll_nfs_get_name_filldir, + }; ENTRY; if (!dir || !S_ISDIR(dir->i_mode)) @@ -225,12 +228,8 @@ static int ll_get_name(struct dentry *dentry, char *name, if (!dir->i_fop) GOTO(out, rc = -EINVAL); - lgd.lgd_name = name; - lgd.lgd_fid = ll_i2info(child->d_inode)->lli_fid; - lgd.lgd_found = 0; - mutex_lock(&dir->i_mutex); - rc = ll_dir_read(dir, &offset, &lgd, ll_nfs_get_name_filldir); + rc = ll_dir_read(dir, &lgd.ctx); mutex_unlock(&dir->i_mutex); if (!rc && !lgd.lgd_found) rc = -ENOENT; -- GitLab From 22eb2c3d900b558ea1e300cbf2f74a9edaef6ecc Mon Sep 17 00:00:00 2001 From: Peng Tao Date: Mon, 15 Jul 2013 22:27:20 +0800 Subject: [PATCH 017/942] staging/lustre: drop CONFIG_BROKEN This reverts commit 0ad1ea69545b1965be4c93ee03fdc685c6beb23d I didn't use git revert because it can not be done cleanly. Hopefully it will be the last time we do it... Cc: Stephen Rothwell Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/Kconfig b/drivers/staging/lustre/lustre/Kconfig index c59ea5564c241..893a3c6fe7853 100644 --- a/drivers/staging/lustre/lustre/Kconfig +++ b/drivers/staging/lustre/lustre/Kconfig @@ -1,6 +1,6 @@ config LUSTRE_FS tristate "Lustre file system client support" - depends on STAGING && INET && m && BROKEN + depends on STAGING && INET && m select LNET select CRYPTO select CRYPTO_CRC32 -- GitLab From 5e8ebf13465a732c542b7e59a004e4e901e574c5 Mon Sep 17 00:00:00 2001 From: Zhao Hongjiang Date: Mon, 8 Jul 2013 17:06:14 +0800 Subject: [PATCH 018/942] staging/lustre: remove the second argument of ll_kmap_atomic() kmap_atomic allows only one argument now, just remove the second. Signed-off-by: Zhao Hongjiang Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lustre/include/linux/lustre_compat25.h | 3 --- drivers/staging/lustre/lustre/llite/rw26.c | 8 ++++---- drivers/staging/lustre/lustre/llite/vvp_io.c | 4 ++-- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h index dff04688945b6..426533b5d1352 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h @@ -266,9 +266,6 @@ static inline int ll_quota_off(struct super_block *sb, int off, int remount) #define queue_max_phys_segments(rq) queue_max_segments(rq) #define queue_max_hw_segments(rq) queue_max_segments(rq) -#define ll_kmap_atomic(a, b) kmap_atomic(a) -#define ll_kunmap_atomic(a, b) kunmap_atomic(a) - #define ll_d_hlist_node hlist_node #define ll_d_hlist_empty(list) hlist_empty(list) diff --git a/drivers/staging/lustre/lustre/llite/rw26.c b/drivers/staging/lustre/lustre/llite/rw26.c index f1a1c5f40a1d4..97088e6ddea07 100644 --- a/drivers/staging/lustre/lustre/llite/rw26.c +++ b/drivers/staging/lustre/lustre/llite/rw26.c @@ -287,11 +287,11 @@ ssize_t ll_direct_rw_pages(const struct lu_env *env, struct cl_io *io, src_page = (rw == WRITE) ? pages[i] : vmpage; dst_page = (rw == WRITE) ? vmpage : pages[i]; - src = ll_kmap_atomic(src_page, KM_USER0); - dst = ll_kmap_atomic(dst_page, KM_USER1); + src = kmap_atomic(src_page); + dst = kmap_atomic(dst_page); memcpy(dst, src, min(page_size, size)); - ll_kunmap_atomic(dst, KM_USER1); - ll_kunmap_atomic(src, KM_USER0); + kunmap_atomic(dst); + kunmap_atomic(src); /* make sure page will be added to the transfer by * cl_io_submit()->...->vvp_page_prep_write(). */ diff --git a/drivers/staging/lustre/lustre/llite/vvp_io.c b/drivers/staging/lustre/lustre/llite/vvp_io.c index eb964acad45c3..bbd6351e1f556 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_io.c +++ b/drivers/staging/lustre/lustre/llite/vvp_io.c @@ -887,10 +887,10 @@ static int vvp_io_prepare_partial(const struct lu_env *env, struct cl_io *io, * purposes here we can treat it like i_size. */ if (attr->cat_kms <= offset) { - char *kaddr = ll_kmap_atomic(cp->cpg_page, KM_USER0); + char *kaddr = kmap_atomic(cp->cpg_page); memset(kaddr, 0, cl_page_size(obj)); - ll_kunmap_atomic(kaddr, KM_USER0); + kunmap_atomic(kaddr); } else if (cp->cpg_defer_uptodate) cp->cpg_ra_used = 1; else -- GitLab From 7522fd7cfbc87bafc91a25b7681d8828412c1959 Mon Sep 17 00:00:00 2001 From: Dragos Foianu Date: Wed, 17 Jul 2013 12:05:24 +0100 Subject: [PATCH 019/942] staging/lustre/libcfs: removed dead code from libcfs_string Confirmed by cscope that the functions are not used anymore. A fresh compilation does not yield any errors. Signed-off-by: Dragos Foianu Reviewed-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/libcfs/libcfs_string.c | 48 ------------------- 1 file changed, 48 deletions(-) diff --git a/drivers/staging/lustre/lustre/libcfs/libcfs_string.c b/drivers/staging/lustre/lustre/libcfs/libcfs_string.c index 9edccc99683ea..c7a19711bb6af 100644 --- a/drivers/staging/lustre/lustre/libcfs/libcfs_string.c +++ b/drivers/staging/lustre/lustre/libcfs/libcfs_string.c @@ -132,54 +132,6 @@ int cfs_str2mask(const char *str, const char *(*bit2str)(int bit), } EXPORT_SYMBOL(cfs_str2mask); -/* Duplicate a string in a platform-independent way */ -char *cfs_strdup(const char *str, u_int32_t flags) -{ - size_t lenz; /* length of str + zero byte */ - char *dup_str; - - lenz = strlen(str) + 1; - - dup_str = kmalloc(lenz, flags); - if (dup_str == NULL) - return NULL; - - memcpy(dup_str, str, lenz); - - return dup_str; -} -EXPORT_SYMBOL(cfs_strdup); - -/** - * cfs_{v}snprintf() return the actual size that is printed rather than - * the size that would be printed in standard functions. - */ -/* safe vsnprintf */ -int cfs_vsnprintf(char *buf, size_t size, const char *fmt, va_list args) -{ - int i; - - LASSERT(size > 0); - i = vsnprintf(buf, size, fmt, args); - - return (i >= size ? size - 1 : i); -} -EXPORT_SYMBOL(cfs_vsnprintf); - -/* safe snprintf */ -int cfs_snprintf(char *buf, size_t size, const char *fmt, ...) -{ - va_list args; - int i; - - va_start(args, fmt); - i = cfs_vsnprintf(buf, size, fmt, args); - va_end(args); - - return i; -} -EXPORT_SYMBOL(cfs_snprintf); - /* get the first string out of @str */ char *cfs_firststr(char *str, size_t size) { -- GitLab From 68a8029799ad368ee82a5cf509a2b5b802837ce9 Mon Sep 17 00:00:00 2001 From: Paul Bolle Date: Sat, 13 Jul 2013 20:46:39 +0200 Subject: [PATCH 020/942] staging/lustre/libcfs: drop bogus Kconfig default Commit 4b5b4c7222 ("staging/lustre/libcfs: restore LINVRNT") added "default false" to this Kconfig file. It was obviously meant to use "default n" here. But we might as well drop this line, as a Kconfig bool defaults to 'n' anyway. Signed-off-by: Paul Bolle Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/Kconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/Kconfig b/drivers/staging/lustre/lustre/Kconfig index 893a3c6fe7853..605fca73628d6 100644 --- a/drivers/staging/lustre/lustre/Kconfig +++ b/drivers/staging/lustre/lustre/Kconfig @@ -43,7 +43,6 @@ config LUSTRE_OBD_MAX_IOCTL_BUFFER config LUSTRE_DEBUG_EXPENSIVE_CHECK bool "Enable Lustre DEBUG checks" depends on LUSTRE_FS - default false help This option is mainly for debug purpose. It enables Lustre code to do expensive checks that may have a performance impact. -- GitLab From 2c922ba54fcfbad313a7cfe9be53698b0fcbf075 Mon Sep 17 00:00:00 2001 From: Peng Tao Date: Tue, 23 Jul 2013 00:06:22 +0800 Subject: [PATCH 021/942] staging/lustre: remove bogus ifndef EXPORT_SYMBOL Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h index 9c40ed904da5b..36def3615d019 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h @@ -40,10 +40,6 @@ #ifndef __LIBCFS_PRIM_H__ #define __LIBCFS_PRIM_H__ -#ifndef EXPORT_SYMBOL -# define EXPORT_SYMBOL(s) -#endif - /* * Schedule */ -- GitLab From 4f37bc04805e20f2a8907a49f06b310e4ebf82b8 Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Tue, 23 Jul 2013 00:06:24 +0800 Subject: [PATCH 022/942] staging/lustre/llite: use READ, WRITE around ll_rw_stats_tally() In vvp_io_write_start() the stats function ll_rw_stats_tally() was incorrectly called with a rw argument of 0. Correct this and use the macros READ and WRITE in and around ll_rw_stats_tally() for clarity. Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3384 Lustre-change: http://review.whamcloud.com/6447 Signed-off-by: John L. Hammond Reviewed-by: Andreas Dilger Reviewed-by: Jinshan Xiong Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/lproc_llite.c | 10 ++++++---- drivers/staging/lustre/lustre/llite/vvp_io.c | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 5c7368c358a0f..a7b12fdd76b14 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -1303,8 +1303,9 @@ static int ll_rw_offset_stats_seq_show(struct seq_file *seq, void *v) /* We stored the discontiguous offsets here; print them first */ for(i = 0; i < LL_OFFSET_HIST_MAX; i++) { if (offset[i].rw_pid != 0) - seq_printf(seq,"%3c %10d %14Lu %14Lu %17lu %17lu %14Lu", - offset[i].rw_op ? 'W' : 'R', + seq_printf(seq, + "%3c %10d %14Lu %14Lu %17lu %17lu %14Lu", + offset[i].rw_op == READ ? 'R' : 'W', offset[i].rw_pid, offset[i].rw_range_start, offset[i].rw_range_end, @@ -1315,8 +1316,9 @@ static int ll_rw_offset_stats_seq_show(struct seq_file *seq, void *v) /* Then print the current offsets for each process */ for(i = 0; i < LL_PROCESS_HIST_MAX; i++) { if (process[i].rw_pid != 0) - seq_printf(seq,"%3c %10d %14Lu %14Lu %17lu %17lu %14Lu", - process[i].rw_op ? 'W' : 'R', + seq_printf(seq, + "%3c %10d %14Lu %14Lu %17lu %17lu %14Lu", + process[i].rw_op == READ ? 'R' : 'W', process[i].rw_pid, process[i].rw_range_start, process[i].rw_last_file_pos, diff --git a/drivers/staging/lustre/lustre/llite/vvp_io.c b/drivers/staging/lustre/lustre/llite/vvp_io.c index bbd6351e1f556..20eac2fd63c3e 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_io.c +++ b/drivers/staging/lustre/lustre/llite/vvp_io.c @@ -525,7 +525,7 @@ static int vvp_io_read_start(const struct lu_env *env, io->ci_continue = 0; io->ci_nob += result; ll_rw_stats_tally(ll_i2sbi(inode), current->pid, - cio->cui_fd, pos, result, 0); + cio->cui_fd, pos, result, READ); result = 0; } return result; @@ -580,7 +580,7 @@ static int vvp_io_write_start(const struct lu_env *env, io->ci_continue = 0; io->ci_nob += result; ll_rw_stats_tally(ll_i2sbi(inode), current->pid, - cio->cui_fd, pos, result, 0); + cio->cui_fd, pos, result, WRITE); result = 0; } RETURN(result); -- GitLab From 1253b2e850850a66a71a512d2f830d4e0205ac72 Mon Sep 17 00:00:00 2001 From: wang di Date: Tue, 23 Jul 2013 00:06:25 +0800 Subject: [PATCH 023/942] staging/lustre/llite: missing last bit in ll_have_md_lock Missing the last bit during INODELOCK check in ll_have_md_lock. Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3385 Lustre-change: http://review.whamcloud.com/6438 Signed-off-by: wang di Reviewed-by: Oleg Drokin Reviewed-by: Andreas Dilger Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index ed1e3f7b4e587..efe66d996f5e7 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -2448,7 +2448,7 @@ int ll_have_md_lock(struct inode *inode, __u64 *bits, ldlm_mode_t l_req_mode) ldlm_lockname[mode]); flags = LDLM_FL_BLOCK_GRANTED | LDLM_FL_CBPENDING | LDLM_FL_TEST_LOCK; - for (i = 0; i < MDS_INODELOCK_MAXSHIFT && *bits != 0; i++) { + for (i = 0; i <= MDS_INODELOCK_MAXSHIFT && *bits != 0; i++) { policy.l_inodebits.bits = *bits & (1 << i); if (policy.l_inodebits.bits == 0) continue; -- GitLab From f8c47be4e883bc49171a85985e6fb54d4680c6eb Mon Sep 17 00:00:00 2001 From: Sebastien Buisson Date: Tue, 23 Jul 2013 00:06:26 +0800 Subject: [PATCH 024/942] staging/lustre: fix 'program hangs' errors Fix 'program hangs' defects found by Coverity version 6.5.1: Missing unlock (LOCK) Returning without unlocking. Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3054 Lustre-change: http://review.whamcloud.com/5870 Signed-off-by: Sebastien Buisson Reviewed-by: Dmitry Eremin Reviewed-by: Andreas Dilger Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/selftest/rpc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lnet/selftest/rpc.c b/drivers/staging/lustre/lnet/selftest/rpc.c index bc1f38b804867..0dfc76e02e0bd 100644 --- a/drivers/staging/lustre/lnet/selftest/rpc.c +++ b/drivers/staging/lustre/lnet/selftest/rpc.c @@ -661,8 +661,10 @@ srpc_finish_service(struct srpc_service *sv) cfs_percpt_for_each(scd, i, sv->sv_cpt_data) { spin_lock(&scd->scd_lock); - if (!swi_deschedule_workitem(&scd->scd_buf_wi)) + if (!swi_deschedule_workitem(&scd->scd_buf_wi)) { + spin_unlock(&scd->scd_lock); return 0; + } if (scd->scd_buf_nposted > 0) { CDEBUG(D_NET, "waiting for %d posted buffers to unlink", -- GitLab From 73863d83b8066b3f7973fd5671162c846b7aea8f Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Tue, 23 Jul 2013 00:06:27 +0800 Subject: [PATCH 025/942] staging/lustre/llite: check alloc in ll_file_data_get, ll_dir_ioctl In ll_file_data_get() and ll_dir_ioctl() return error on failed allocations. Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2753 Lustre-change: http://review.whamcloud.com/5845 Signed-off-by: John L. Hammond Reviewed-by: Andreas Dilger Reviewed-by: Dmitry Eremin Reviewed-by: Sebastien Buisson Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/dir.c | 2 ++ drivers/staging/lustre/lustre/llite/file.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index 1084999be959c..bfc914e4be087 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -1561,6 +1561,8 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) RETURN(rc); OBD_ALLOC_LARGE(lmm, lmmsize); + if (lmm == NULL) + RETURN(-ENOMEM); if (copy_from_user(lmm, lum, lmmsize)) GOTO(free_lmm, rc = -EFAULT); diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index efe66d996f5e7..927b3a03e6546 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -55,6 +55,8 @@ struct ll_file_data *ll_file_data_get(void) struct ll_file_data *fd; OBD_SLAB_ALLOC_PTR_GFP(fd, ll_file_data_slab, __GFP_IO); + if (fd == NULL) + return NULL; fd->fd_write_failed = false; return fd; } -- GitLab From e06c9dfec0f3738409b3936dcd0a4ae126acac07 Mon Sep 17 00:00:00 2001 From: Dmitry Eremin Date: Tue, 23 Jul 2013 00:06:28 +0800 Subject: [PATCH 026/942] staging/lustre/llite: A not locked mutex can be unlocked. In case of memory pressure a not locked mutex can be unlocked in function ll_file_open(). This is not allowed and subsequent behavior is not defined. Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3157 Lustre-change: http://review.whamcloud.com/6028 Signed-off-by: Dmitry Eremin Reviewed-by: John Hammond Reviewed-by: Nikitas Angelinas Reviewed-by: Sebastien Buisson Reviewed-by: Andreas Dilger Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 927b3a03e6546..717682c162ece 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -526,7 +526,7 @@ int ll_file_open(struct inode *inode, struct file *file) fd = ll_file_data_get(); if (fd == NULL) - GOTO(out_och_free, rc = -ENOMEM); + GOTO(out_openerr, rc = -ENOMEM); fd->fd_file = file; if (S_ISDIR(inode->i_mode)) { -- GitLab From 79a8726a8453a2350f463fc3182bae43a5417181 Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Tue, 23 Jul 2013 00:06:29 +0800 Subject: [PATCH 027/942] staging/lustre/llite: check ll_prep_md_op_data() using IS_ERR() In ll_file_ioctl() and ll_swap_layouts() check the result of ll_prep_md_op_data() using IS_ERR(). Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3283 Lustre-change: http://review.whamcloud.com/6275 Signed-off-by: John L. Hammond Reviewed-by: Jinshan Xiong Reviewed-by: Fan Yong Reviewed-by: Oleg Drokin Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/file.c | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 717682c162ece..50ef6a587dc3e 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -1832,12 +1832,12 @@ static int ll_swap_layouts(struct file *file1, struct file *file2, rc = -ENOMEM; op_data = ll_prep_md_op_data(NULL, llss->inode1, llss->inode2, NULL, 0, 0, LUSTRE_OPC_ANY, &msl); - if (op_data != NULL) { - rc = obd_iocontrol(LL_IOC_LOV_SWAP_LAYOUTS, - ll_i2mdexp(llss->inode1), - sizeof(*op_data), op_data, NULL); - ll_finish_md_op_data(op_data); - } + if (IS_ERR(op_data)) + GOTO(free, rc = PTR_ERR(op_data)); + + rc = obd_iocontrol(LL_IOC_LOV_SWAP_LAYOUTS, ll_i2mdexp(llss->inode1), + sizeof(*op_data), op_data, NULL); + ll_finish_md_op_data(op_data); putgl: if (gid != 0) { @@ -2031,9 +2031,9 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0, LUSTRE_OPC_ANY, hus); - if (op_data == NULL) { + if (IS_ERR(op_data)) { OBD_FREE_PTR(hus); - RETURN(-ENOMEM); + RETURN(PTR_ERR(op_data)); } rc = obd_iocontrol(cmd, ll_i2mdexp(inode), sizeof(*op_data), @@ -2069,9 +2069,9 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0, LUSTRE_OPC_ANY, hss); - if (op_data == NULL) { + if (IS_ERR(op_data)) { OBD_FREE_PTR(hss); - RETURN(-ENOMEM); + RETURN(PTR_ERR(op_data)); } rc = obd_iocontrol(cmd, ll_i2mdexp(inode), sizeof(*op_data), @@ -2093,9 +2093,9 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0, LUSTRE_OPC_ANY, hca); - if (op_data == NULL) { + if (IS_ERR(op_data)) { OBD_FREE_PTR(hca); - RETURN(-ENOMEM); + RETURN(PTR_ERR(op_data)); } rc = obd_iocontrol(cmd, ll_i2mdexp(inode), sizeof(*op_data), -- GitLab From c5b60ba79d67797ab6fffcab5edd9364b14d1dd7 Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Tue, 23 Jul 2013 00:06:30 +0800 Subject: [PATCH 028/942] staging/lustre/ldlm: print FID in lvbo_init(), lvbo_update Print the namespace and OBD device name, as well as the first two lock resource fields (typically the FID) if there is an error with loading the object from disk. This will be more important with FID-on-OST and also the MDS. Using fid_extract_from_res_name() isn't possible in the LDLM code, since the lock resource may not be a FID. Make fid_extract_quota_resid() argument order and name consistent with other fid_*_res() functions, with FID first and resource second. Fix a bug in ofd_lvbo_init() where NULL lvb is accessed on error. Print FID in ofd_lvbo_update() CDEBUG() and CERROR() messages. Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2193 Lustre-change: http://review.whamcloud.com/4501 Signed-off-by: Andreas Dilger Reviewed-by: Jinshan Xiong Reviewed-by: Bobi Jam Reviewed-by: Oleg Drokin Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/include/lustre/lustre_idl.h | 4 +- .../lustre/lustre/include/lustre_fid.h | 89 ++++++++++--------- .../lustre/lustre/ldlm/ldlm_resource.c | 5 +- 3 files changed, 50 insertions(+), 48 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h index 8825460f12ac8..1cfebfea7b776 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h @@ -911,7 +911,7 @@ static inline int lu_fid_cmp(const struct lu_fid *f0, __diff_normalize(fid_ver(f0), fid_ver(f1)); } -static inline void ostid_cpu_to_le(struct ost_id *src_oi, +static inline void ostid_cpu_to_le(const struct ost_id *src_oi, struct ost_id *dst_oi) { if (fid_seq_is_mdt0(ostid_seq(src_oi))) { @@ -922,7 +922,7 @@ static inline void ostid_cpu_to_le(struct ost_id *src_oi, } } -static inline void ostid_le_to_cpu(struct ost_id *src_oi, +static inline void ostid_le_to_cpu(const struct ost_id *src_oi, struct ost_id *dst_oi) { if (fid_seq_is_mdt0(ostid_seq(src_oi))) { diff --git a/drivers/staging/lustre/lustre/include/lustre_fid.h b/drivers/staging/lustre/lustre/include/lustre_fid.h index 7d20cba072877..7523b407488e1 100644 --- a/drivers/staging/lustre/lustre/include/lustre_fid.h +++ b/drivers/staging/lustre/lustre/include/lustre_fid.h @@ -488,74 +488,75 @@ struct ldlm_namespace; * renaming name[2,3] fields that need to be used for the quota identifier. */ static inline struct ldlm_res_id * -fid_build_reg_res_name(const struct lu_fid *f, - struct ldlm_res_id *name) +fid_build_reg_res_name(const struct lu_fid *fid, struct ldlm_res_id *res) { - memset(name, 0, sizeof *name); - name->name[LUSTRE_RES_ID_SEQ_OFF] = fid_seq(f); - name->name[LUSTRE_RES_ID_VER_OID_OFF] = fid_ver_oid(f); - return name; + memset(res, 0, sizeof(*res)); + res->name[LUSTRE_RES_ID_SEQ_OFF] = fid_seq(fid); + res->name[LUSTRE_RES_ID_VER_OID_OFF] = fid_ver_oid(fid); + + return res; +} + +/* + * Return true if resource is for object identified by FID. + */ +static inline int fid_res_name_eq(const struct lu_fid *fid, + const struct ldlm_res_id *res) +{ + return res->name[LUSTRE_RES_ID_SEQ_OFF] == fid_seq(fid) && + res->name[LUSTRE_RES_ID_VER_OID_OFF] == fid_ver_oid(fid); +} + +/* + * Extract FID from LDLM resource. Reverse of fid_build_reg_res_name(). + */ +static inline struct lu_fid * +fid_extract_from_res_name(struct lu_fid *fid, const struct ldlm_res_id *res) +{ + fid->f_seq = res->name[LUSTRE_RES_ID_SEQ_OFF]; + fid->f_oid = (__u32)(res->name[LUSTRE_RES_ID_VER_OID_OFF]); + fid->f_ver = (__u32)(res->name[LUSTRE_RES_ID_VER_OID_OFF] >> 32); + LASSERT(fid_res_name_eq(fid, res)); + + return fid; } /* * Build (DLM) resource identifier from global quota FID and quota ID. */ static inline struct ldlm_res_id * -fid_build_quota_resid(const struct lu_fid *glb_fid, union lquota_id *qid, +fid_build_quota_res_name(const struct lu_fid *glb_fid, union lquota_id *qid, struct ldlm_res_id *res) { fid_build_reg_res_name(glb_fid, res); res->name[LUSTRE_RES_ID_QUOTA_SEQ_OFF] = fid_seq(&qid->qid_fid); res->name[LUSTRE_RES_ID_QUOTA_VER_OID_OFF] = fid_ver_oid(&qid->qid_fid); + return res; } /* * Extract global FID and quota ID from resource name */ -static inline void fid_extract_quota_resid(struct ldlm_res_id *res, - struct lu_fid *glb_fid, - union lquota_id *qid) +static inline void fid_extract_from_quota_res(struct lu_fid *glb_fid, + union lquota_id *qid, + const struct ldlm_res_id *res) { - glb_fid->f_seq = res->name[LUSTRE_RES_ID_SEQ_OFF]; - glb_fid->f_oid = (__u32)res->name[LUSTRE_RES_ID_VER_OID_OFF]; - glb_fid->f_ver = (__u32)(res->name[LUSTRE_RES_ID_VER_OID_OFF] >> 32); - + fid_extract_from_res_name(glb_fid, res); qid->qid_fid.f_seq = res->name[LUSTRE_RES_ID_QUOTA_SEQ_OFF]; qid->qid_fid.f_oid = (__u32)res->name[LUSTRE_RES_ID_QUOTA_VER_OID_OFF]; qid->qid_fid.f_ver = (__u32)(res->name[LUSTRE_RES_ID_QUOTA_VER_OID_OFF] >> 32); } -/* - * Return true if resource is for object identified by fid. - */ -static inline int fid_res_name_eq(const struct lu_fid *f, - const struct ldlm_res_id *name) -{ - return name->name[LUSTRE_RES_ID_SEQ_OFF] == fid_seq(f) && - name->name[LUSTRE_RES_ID_VER_OID_OFF] == fid_ver_oid(f); -} - -/* reverse function of fid_build_reg_res_name() */ -static inline void fid_build_from_res_name(struct lu_fid *f, - const struct ldlm_res_id *name) -{ - fid_zero(f); - f->f_seq = name->name[LUSTRE_RES_ID_SEQ_OFF]; - f->f_oid = name->name[LUSTRE_RES_ID_VER_OID_OFF] & 0xffffffff; - f->f_ver = name->name[LUSTRE_RES_ID_VER_OID_OFF] >> 32; - LASSERT(fid_res_name_eq(f, name)); -} - static inline struct ldlm_res_id * -fid_build_pdo_res_name(const struct lu_fid *f, - unsigned int hash, - struct ldlm_res_id *name) +fid_build_pdo_res_name(const struct lu_fid *fid, unsigned int hash, + struct ldlm_res_id *res) { - fid_build_reg_res_name(f, name); - name->name[LUSTRE_RES_ID_HSH_OFF] = hash; - return name; + fid_build_reg_res_name(fid, res); + res->name[LUSTRE_RES_ID_HSH_OFF] = hash; + + return res; } /** @@ -584,7 +585,7 @@ static inline void ostid_build_res_name(struct ost_id *oi, name->name[LUSTRE_RES_ID_SEQ_OFF] = ostid_id(oi); name->name[LUSTRE_RES_ID_VER_OID_OFF] = ostid_seq(oi); } else { - fid_build_reg_res_name((struct lu_fid *)oi, name); + fid_build_reg_res_name(&oi->oi_fid, name); } } @@ -597,7 +598,7 @@ static inline void ostid_res_name_to_id(struct ost_id *oi, ostid_set_id(oi, name->name[LUSTRE_RES_ID_SEQ_OFF]); } else { /* new resid */ - fid_build_from_res_name((struct lu_fid *)oi, name); + fid_extract_from_res_name(&oi->oi_fid, name); } } @@ -644,7 +645,7 @@ static inline void ost_fid_from_resid(struct lu_fid *fid, ostid_to_fid(fid, &oi, 0); } else { /* new resid */ - fid_build_from_res_name(fid, name); + fid_extract_from_res_name(fid, name); } } diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index 9052dc5e7ad24..cb8659f71149b 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -1128,8 +1128,9 @@ ldlm_resource_get(struct ldlm_namespace *ns, struct ldlm_resource *parent, OBD_FAIL_TIMEOUT(OBD_FAIL_LDLM_CREATE_RESOURCE, 2); rc = ns->ns_lvbo->lvbo_init(res); if (rc < 0) { - CERROR("lvbo_init failed for resource " - LPU64": rc %d\n", name->name[0], rc); + CERROR("%s: lvbo_init failed for resource "LPX64":" + LPX64": rc = %d\n", ns->ns_obd->obd_name, + name->name[0], name->name[1], rc); if (res->lr_lvb_data) { OBD_FREE(res->lr_lvb_data, res->lr_lvb_len); res->lr_lvb_data = NULL; -- GitLab From 2080205729edf2a59296f17081c9aa25a7ed6368 Mon Sep 17 00:00:00 2001 From: Dmitry Eremin Date: Tue, 23 Jul 2013 00:06:31 +0800 Subject: [PATCH 029/942] staging/lustre/ptlrpc: race in pinger (use-after-free situation) The race is result of use-after-free situation: ~ ptlrpc_stop_pinger() ~ ptlrpc_pinger_main() --------------------------------------------------------------- thread_set_flags(SVC_STOPPING) cfs_waitq_signal(pinger_thread) ... ... thread_set_flags(SVC_STOPPED) l_wait_event(thread_is_stopped) OBD_FREE_PTR(pinger_thread) ... cfs_waitq_signal(pinger_thread) --------------------------------------------------------------- The memory used by pinger_thread might have been freed and reallocated to something else, when ptlrpc_pinger_main() used it in cvs_waitq_signal(). Signed-off-by: Li Wei Signed-off-by: Dmitry Eremin Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3032 Lustre-change: http://review.whamcloud.com/6040 Reviewed-by: Faccini Bruno Reviewed-by: Mike Pershin Reviewed-by: Andreas Dilger Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ptlrpc/pinger.c | 39 ++++++++----------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c index ef5269aee0dea..f521251a1a6e9 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c @@ -369,7 +369,7 @@ static int ptlrpc_pinger_main(void *arg) return 0; } -static struct ptlrpc_thread *pinger_thread = NULL; +static struct ptlrpc_thread pinger_thread; int ptlrpc_start_pinger(void) { @@ -377,29 +377,25 @@ int ptlrpc_start_pinger(void) int rc; ENTRY; - if (pinger_thread != NULL) + if (!thread_is_init(&pinger_thread) && + !thread_is_stopped(&pinger_thread)) RETURN(-EALREADY); - OBD_ALLOC_PTR(pinger_thread); - if (pinger_thread == NULL) - RETURN(-ENOMEM); - init_waitqueue_head(&pinger_thread->t_ctl_waitq); + init_waitqueue_head(&pinger_thread.t_ctl_waitq); init_waitqueue_head(&suspend_timeouts_waitq); - strcpy(pinger_thread->t_name, "ll_ping"); + strcpy(pinger_thread.t_name, "ll_ping"); /* CLONE_VM and CLONE_FILES just avoid a needless copy, because we * just drop the VM and FILES in cfs_daemonize_ctxt() right away. */ rc = PTR_ERR(kthread_run(ptlrpc_pinger_main, - pinger_thread, pinger_thread->t_name)); + &pinger_thread, pinger_thread.t_name)); if (IS_ERR_VALUE(rc)) { CERROR("cannot start thread: %d\n", rc); - OBD_FREE(pinger_thread, sizeof(*pinger_thread)); - pinger_thread = NULL; RETURN(rc); } - l_wait_event(pinger_thread->t_ctl_waitq, - thread_is_running(pinger_thread), &lwi); + l_wait_event(pinger_thread.t_ctl_waitq, + thread_is_running(&pinger_thread), &lwi); if (suppress_pings) CWARN("Pings will be suppressed at the request of the " @@ -419,20 +415,17 @@ int ptlrpc_stop_pinger(void) int rc = 0; ENTRY; - if (pinger_thread == NULL) + if (!thread_is_init(&pinger_thread) && + !thread_is_stopped(&pinger_thread)) RETURN(-EALREADY); ptlrpc_pinger_remove_timeouts(); - mutex_lock(&pinger_mutex); - thread_set_flags(pinger_thread, SVC_STOPPING); - wake_up(&pinger_thread->t_ctl_waitq); - mutex_unlock(&pinger_mutex); + thread_set_flags(&pinger_thread, SVC_STOPPING); + wake_up(&pinger_thread.t_ctl_waitq); - l_wait_event(pinger_thread->t_ctl_waitq, - thread_is_stopped(pinger_thread), &lwi); + l_wait_event(pinger_thread.t_ctl_waitq, + thread_is_stopped(&pinger_thread), &lwi); - OBD_FREE_PTR(pinger_thread); - pinger_thread = NULL; RETURN(rc); } @@ -617,8 +610,8 @@ int ptlrpc_pinger_remove_timeouts(void) void ptlrpc_pinger_wake_up() { - thread_add_flags(pinger_thread, SVC_EVENT); - wake_up(&pinger_thread->t_ctl_waitq); + thread_add_flags(&pinger_thread, SVC_EVENT); + wake_up(&pinger_thread.t_ctl_waitq); } /* Ping evictor thread */ -- GitLab From 2d58de78b2f6c53688a154b02bae3ada19ed15a9 Mon Sep 17 00:00:00 2001 From: Li Wei Date: Tue, 23 Jul 2013 00:06:32 +0800 Subject: [PATCH 030/942] staging/lustre/ptlrpc: Translate between host and network errnos Lustre puts system errors (e.g., ENOTCONN) on wire as numbers essentially specific to senders' architectures. While this is fine for x86-only sites, where receivers share the same error number definition with senders, problems will arise, however, for sites involving multiple architectures with different error number definitions. For instance, an ENOTCONN reply from a sparc server will be put on wire as -57, which, for an x86 client, means EBADSLT instead. To solve the problem, this patch defines a set of network errors for on-wire or on-disk uses. These errors correspond to a subset of the x86 system errors and share the same number definition, maintaining compatibility with existing x86 clients and servers. Then, either error numbers could be translated at run time, or all host errors going on wire could be replaced with network errors in the code. This patch does the former by introducing both generic and field-specific translation routines and calling them at proper places, so that translations for existing fields are transparent. (Personally, I tend to think the latter way might be worthwhile, as it is more straightforward conceptually. Do we really need so many different errors? Should errors returned by kernel routines really be passed up and eventually put on wire? There could even be security implications in that.) Thank Fujitsu for the original idea and their contributions that make this available upstream. Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2743 Lustre-change: http://review.whamcloud.com/5577 Signed-off-by: Li Wei Reviewed-by: Andreas Dilger Reviewed-by: Hiroya Nozaki Reviewed-by: Oleg Drokin Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/Kconfig | 5 + .../lustre/include/lustre/lustre_errno.h | 215 ++++++++++ .../lustre/lustre/include/lustre/lustre_idl.h | 2 + .../lustre/lustre/include/lustre_net.h | 32 ++ .../staging/lustre/lustre/ldlm/ldlm_lock.c | 3 +- .../staging/lustre/lustre/ldlm/ldlm_lockd.c | 2 + .../staging/lustre/lustre/ldlm/ldlm_request.c | 6 +- drivers/staging/lustre/lustre/mdc/mdc_locks.c | 10 + .../staging/lustre/lustre/mdc/mdc_request.c | 1 + .../staging/lustre/lustre/osc/osc_request.c | 2 + drivers/staging/lustre/lustre/ptlrpc/Makefile | 1 + drivers/staging/lustre/lustre/ptlrpc/errno.c | 382 ++++++++++++++++++ drivers/staging/lustre/lustre/ptlrpc/niobuf.c | 3 +- .../lustre/lustre/ptlrpc/pack_generic.c | 3 + 14 files changed, 662 insertions(+), 5 deletions(-) create mode 100644 drivers/staging/lustre/lustre/include/lustre/lustre_errno.h create mode 100644 drivers/staging/lustre/lustre/ptlrpc/errno.c diff --git a/drivers/staging/lustre/lustre/Kconfig b/drivers/staging/lustre/lustre/Kconfig index 605fca73628d6..9ae7fa86b5a8e 100644 --- a/drivers/staging/lustre/lustre/Kconfig +++ b/drivers/staging/lustre/lustre/Kconfig @@ -48,3 +48,8 @@ config LUSTRE_DEBUG_EXPENSIVE_CHECK expensive checks that may have a performance impact. Use with caution. If unsure, say N. + +config LUSTRE_TRANSLATE_ERRNOS + bool + depends on LUSTRE_FS && !X86 + default true diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_errno.h b/drivers/staging/lustre/lustre/include/lustre/lustre_errno.h new file mode 100644 index 0000000000000..2870487dd2865 --- /dev/null +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_errno.h @@ -0,0 +1,215 @@ +/* + * GPL HEADER START + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 only, + * as published by the Free Software Foundation. + * + * 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 version 2 for more details (a copy is included + * in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU General Public License + * version 2 along with this program; If not, see + * http://www.gnu.org/licenses/gpl-2.0.txt + * + * GPL HEADER END + */ +/* + * Copyright (C) 2011 FUJITSU LIMITED. All rights reserved. + * + * Copyright (c) 2013, Intel Corporation. + */ + +#ifndef LUSTRE_ERRNO_H +#define LUSTRE_ERRNO_H + +/* + * Only "network" errnos, which are defined below, are allowed on wire (or on + * disk). Generic routines exist to help translate between these and a subset + * of the "host" errnos. Some host errnos (e.g., EDEADLOCK) are intentionally + * left out. See also the comment on lustre_errno_hton_mapping[]. + * + * To maintain compatibility with existing x86 clients and servers, each of + * these network errnos has the same numerical value as its corresponding host + * errno on x86. + */ +#define LUSTRE_EPERM 1 /* Operation not permitted */ +#define LUSTRE_ENOENT 2 /* No such file or directory */ +#define LUSTRE_ESRCH 3 /* No such process */ +#define LUSTRE_EINTR 4 /* Interrupted system call */ +#define LUSTRE_EIO 5 /* I/O error */ +#define LUSTRE_ENXIO 6 /* No such device or address */ +#define LUSTRE_E2BIG 7 /* Argument list too long */ +#define LUSTRE_ENOEXEC 8 /* Exec format error */ +#define LUSTRE_EBADF 9 /* Bad file number */ +#define LUSTRE_ECHILD 10 /* No child processes */ +#define LUSTRE_EAGAIN 11 /* Try again */ +#define LUSTRE_ENOMEM 12 /* Out of memory */ +#define LUSTRE_EACCES 13 /* Permission denied */ +#define LUSTRE_EFAULT 14 /* Bad address */ +#define LUSTRE_ENOTBLK 15 /* Block device required */ +#define LUSTRE_EBUSY 16 /* Device or resource busy */ +#define LUSTRE_EEXIST 17 /* File exists */ +#define LUSTRE_EXDEV 18 /* Cross-device link */ +#define LUSTRE_ENODEV 19 /* No such device */ +#define LUSTRE_ENOTDIR 20 /* Not a directory */ +#define LUSTRE_EISDIR 21 /* Is a directory */ +#define LUSTRE_EINVAL 22 /* Invalid argument */ +#define LUSTRE_ENFILE 23 /* File table overflow */ +#define LUSTRE_EMFILE 24 /* Too many open files */ +#define LUSTRE_ENOTTY 25 /* Not a typewriter */ +#define LUSTRE_ETXTBSY 26 /* Text file busy */ +#define LUSTRE_EFBIG 27 /* File too large */ +#define LUSTRE_ENOSPC 28 /* No space left on device */ +#define LUSTRE_ESPIPE 29 /* Illegal seek */ +#define LUSTRE_EROFS 30 /* Read-only file system */ +#define LUSTRE_EMLINK 31 /* Too many links */ +#define LUSTRE_EPIPE 32 /* Broken pipe */ +#define LUSTRE_EDOM 33 /* Math argument out of domain of + func */ +#define LUSTRE_ERANGE 34 /* Math result not representable */ +#define LUSTRE_EDEADLK 35 /* Resource deadlock would occur */ +#define LUSTRE_ENAMETOOLONG 36 /* File name too long */ +#define LUSTRE_ENOLCK 37 /* No record locks available */ +#define LUSTRE_ENOSYS 38 /* Function not implemented */ +#define LUSTRE_ENOTEMPTY 39 /* Directory not empty */ +#define LUSTRE_ELOOP 40 /* Too many symbolic links + encountered */ +#define LUSTRE_ENOMSG 42 /* No message of desired type */ +#define LUSTRE_EIDRM 43 /* Identifier removed */ +#define LUSTRE_ECHRNG 44 /* Channel number out of range */ +#define LUSTRE_EL2NSYNC 45 /* Level 2 not synchronized */ +#define LUSTRE_EL3HLT 46 /* Level 3 halted */ +#define LUSTRE_EL3RST 47 /* Level 3 reset */ +#define LUSTRE_ELNRNG 48 /* Link number out of range */ +#define LUSTRE_EUNATCH 49 /* Protocol driver not attached */ +#define LUSTRE_ENOCSI 50 /* No CSI structure available */ +#define LUSTRE_EL2HLT 51 /* Level 2 halted */ +#define LUSTRE_EBADE 52 /* Invalid exchange */ +#define LUSTRE_EBADR 53 /* Invalid request descriptor */ +#define LUSTRE_EXFULL 54 /* Exchange full */ +#define LUSTRE_ENOANO 55 /* No anode */ +#define LUSTRE_EBADRQC 56 /* Invalid request code */ +#define LUSTRE_EBADSLT 57 /* Invalid slot */ +#define LUSTRE_EBFONT 59 /* Bad font file format */ +#define LUSTRE_ENOSTR 60 /* Device not a stream */ +#define LUSTRE_ENODATA 61 /* No data available */ +#define LUSTRE_ETIME 62 /* Timer expired */ +#define LUSTRE_ENOSR 63 /* Out of streams resources */ +#define LUSTRE_ENONET 64 /* Machine is not on the network */ +#define LUSTRE_ENOPKG 65 /* Package not installed */ +#define LUSTRE_EREMOTE 66 /* Object is remote */ +#define LUSTRE_ENOLINK 67 /* Link has been severed */ +#define LUSTRE_EADV 68 /* Advertise error */ +#define LUSTRE_ESRMNT 69 /* Srmount error */ +#define LUSTRE_ECOMM 70 /* Communication error on send */ +#define LUSTRE_EPROTO 71 /* Protocol error */ +#define LUSTRE_EMULTIHOP 72 /* Multihop attempted */ +#define LUSTRE_EDOTDOT 73 /* RFS specific error */ +#define LUSTRE_EBADMSG 74 /* Not a data message */ +#define LUSTRE_EOVERFLOW 75 /* Value too large for defined data + type */ +#define LUSTRE_ENOTUNIQ 76 /* Name not unique on network */ +#define LUSTRE_EBADFD 77 /* File descriptor in bad state */ +#define LUSTRE_EREMCHG 78 /* Remote address changed */ +#define LUSTRE_ELIBACC 79 /* Can not access a needed shared + library */ +#define LUSTRE_ELIBBAD 80 /* Accessing a corrupted shared + library */ +#define LUSTRE_ELIBSCN 81 /* .lib section in a.out corrupted */ +#define LUSTRE_ELIBMAX 82 /* Attempting to link in too many shared + libraries */ +#define LUSTRE_ELIBEXEC 83 /* Cannot exec a shared library + directly */ +#define LUSTRE_EILSEQ 84 /* Illegal byte sequence */ +#define LUSTRE_ERESTART 85 /* Interrupted system call should be + restarted */ +#define LUSTRE_ESTRPIPE 86 /* Streams pipe error */ +#define LUSTRE_EUSERS 87 /* Too many users */ +#define LUSTRE_ENOTSOCK 88 /* Socket operation on non-socket */ +#define LUSTRE_EDESTADDRREQ 89 /* Destination address required */ +#define LUSTRE_EMSGSIZE 90 /* Message too long */ +#define LUSTRE_EPROTOTYPE 91 /* Protocol wrong type for socket */ +#define LUSTRE_ENOPROTOOPT 92 /* Protocol not available */ +#define LUSTRE_EPROTONOSUPPORT 93 /* Protocol not supported */ +#define LUSTRE_ESOCKTNOSUPPORT 94 /* Socket type not supported */ +#define LUSTRE_EOPNOTSUPP 95 /* Operation not supported on transport + endpoint */ +#define LUSTRE_EPFNOSUPPORT 96 /* Protocol family not supported */ +#define LUSTRE_EAFNOSUPPORT 97 /* Address family not supported by + protocol */ +#define LUSTRE_EADDRINUSE 98 /* Address already in use */ +#define LUSTRE_EADDRNOTAVAIL 99 /* Cannot assign requested address */ +#define LUSTRE_ENETDOWN 100 /* Network is down */ +#define LUSTRE_ENETUNREACH 101 /* Network is unreachable */ +#define LUSTRE_ENETRESET 102 /* Network dropped connection because of + reset */ +#define LUSTRE_ECONNABORTED 103 /* Software caused connection abort */ +#define LUSTRE_ECONNRESET 104 /* Connection reset by peer */ +#define LUSTRE_ENOBUFS 105 /* No buffer space available */ +#define LUSTRE_EISCONN 106 /* Transport endpoint is already + connected */ +#define LUSTRE_ENOTCONN 107 /* Transport endpoint is not + connected */ +#define LUSTRE_ESHUTDOWN 108 /* Cannot send after transport endpoint + shutdown */ +#define LUSTRE_ETOOMANYREFS 109 /* Too many references: cannot splice */ +#define LUSTRE_ETIMEDOUT 110 /* Connection timed out */ +#define LUSTRE_ECONNREFUSED 111 /* Connection refused */ +#define LUSTRE_EHOSTDOWN 112 /* Host is down */ +#define LUSTRE_EHOSTUNREACH 113 /* No route to host */ +#define LUSTRE_EALREADY 114 /* Operation already in progress */ +#define LUSTRE_EINPROGRESS 115 /* Operation now in progress */ +#define LUSTRE_ESTALE 116 /* Stale NFS file handle */ +#define LUSTRE_EUCLEAN 117 /* Structure needs cleaning */ +#define LUSTRE_ENOTNAM 118 /* Not a XENIX named type file */ +#define LUSTRE_ENAVAIL 119 /* No XENIX semaphores available */ +#define LUSTRE_EISNAM 120 /* Is a named type file */ +#define LUSTRE_EREMOTEIO 121 /* Remote I/O error */ +#define LUSTRE_EDQUOT 122 /* Quota exceeded */ +#define LUSTRE_ENOMEDIUM 123 /* No medium found */ +#define LUSTRE_EMEDIUMTYPE 124 /* Wrong medium type */ +#define LUSTRE_ECANCELED 125 /* Operation Canceled */ +#define LUSTRE_ENOKEY 126 /* Required key not available */ +#define LUSTRE_EKEYEXPIRED 127 /* Key has expired */ +#define LUSTRE_EKEYREVOKED 128 /* Key has been revoked */ +#define LUSTRE_EKEYREJECTED 129 /* Key was rejected by service */ +#define LUSTRE_EOWNERDEAD 130 /* Owner died */ +#define LUSTRE_ENOTRECOVERABLE 131 /* State not recoverable */ +#define LUSTRE_ERESTARTSYS 512 +#define LUSTRE_ERESTARTNOINTR 513 +#define LUSTRE_ERESTARTNOHAND 514 /* restart if no handler.. */ +#define LUSTRE_ENOIOCTLCMD 515 /* No ioctl command */ +#define LUSTRE_ERESTART_RESTARTBLOCK 516 /* restart by calling + sys_restart_syscall */ +#define LUSTRE_EBADHANDLE 521 /* Illegal NFS file handle */ +#define LUSTRE_ENOTSYNC 522 /* Update synchronization mismatch */ +#define LUSTRE_EBADCOOKIE 523 /* Cookie is stale */ +#define LUSTRE_ENOTSUPP 524 /* Operation is not supported */ +#define LUSTRE_ETOOSMALL 525 /* Buffer or request is too small */ +#define LUSTRE_ESERVERFAULT 526 /* An untranslatable error occurred */ +#define LUSTRE_EBADTYPE 527 /* Type not supported by server */ +#define LUSTRE_EJUKEBOX 528 /* Request initiated, but will not + complete before timeout */ +#define LUSTRE_EIOCBQUEUED 529 /* iocb queued, will get completion + event */ +#define LUSTRE_EIOCBRETRY 530 /* iocb queued, will trigger a retry */ + +/* + * Translations are optimized away on x86. Host errnos that shouldn't be put + * on wire could leak through as a result. Do not count on this side effect. + */ +#ifdef CONFIG_LUSTRE_TRANSLATE_ERRNOS +unsigned int lustre_errno_hton(unsigned int h); +unsigned int lustre_errno_ntoh(unsigned int n); +#else +#define lustre_errno_hton(h) (h) +#define lustre_errno_ntoh(n) (n) +#endif + +#endif /* LUSTRE_ERRNO_H */ diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h index 1cfebfea7b776..4829419a75d30 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h @@ -98,6 +98,8 @@ /* Defn's shared with user-space. */ #include +#include + /* * GENERAL STUFF */ diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h index 1b99b5d2b4f17..8d7cc7ab00398 100644 --- a/drivers/staging/lustre/lustre/include/lustre_net.h +++ b/drivers/staging/lustre/lustre/include/lustre_net.h @@ -3166,6 +3166,38 @@ lustre_shrink_reply(struct ptlrpc_request *req, int segment, req->rq_replen = lustre_shrink_msg(req->rq_repmsg, segment, newlen, move_data); } + +#ifdef CONFIG_LUSTRE_TRANSLATE_ERRNOS + +static inline int ptlrpc_status_hton(int h) +{ + /* + * Positive errnos must be network errnos, such as LUSTRE_EDEADLK, + * ELDLM_LOCK_ABORTED, etc. + */ + if (h < 0) + return -lustre_errno_hton(-h); + else + return h; +} + +static inline int ptlrpc_status_ntoh(int n) +{ + /* + * See the comment in ptlrpc_status_hton(). + */ + if (n < 0) + return -lustre_errno_ntoh(-n); + else + return n; +} + +#else + +#define ptlrpc_status_hton(h) (h) +#define ptlrpc_status_ntoh(n) (n) + +#endif /** @} */ /** Change request phase of \a req to \a new_phase */ diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index 93badf5c29571..0b3ea88ae5b07 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -2208,7 +2208,8 @@ struct ldlm_resource *ldlm_lock_convert(struct ldlm_lock *lock, int new_mode, /* I can't check the type of lock here because the bitlock of lock * is not held here, so do the allocation blindly. -jay */ OBD_SLAB_ALLOC_PTR_GFP(node, ldlm_interval_slab, __GFP_IO); - if (node == NULL) /* Actually, this causes EDEADLOCK to be returned */ + if (node == NULL) + /* Actually, this causes EDEADLOCK to be returned */ RETURN(NULL); LASSERTF((new_mode == LCK_PW && lock->l_granted_mode == LCK_PR), diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c index 324d5e4286dc9..f79b244d1a68f 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c @@ -555,6 +555,8 @@ static int ldlm_handle_qc_callback(struct ptlrpc_request *req) RETURN(-EPROTO); } + oqctl->qc_stat = ptlrpc_status_ntoh(oqctl->qc_stat); + cli->cl_qchk_stat = oqctl->qc_stat; return 0; } diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c index 1a690edaba034..ab41fea4aa07a 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c @@ -1023,7 +1023,7 @@ static int ldlm_cli_convert_local(struct ldlm_lock *lock, int new_mode, ldlm_reprocess_all(res); rc = 0; } else { - rc = EDEADLOCK; + rc = LUSTRE_EDEADLK; } LDLM_DEBUG(lock, "client-side local convert handler END"); LDLM_LOCK_PUT(lock); @@ -1095,7 +1095,7 @@ int ldlm_cli_convert(struct lustre_handle *lockh, int new_mode, __u32 *flags) GOTO(out, rc); } } else { - rc = EDEADLOCK; + rc = LUSTRE_EDEADLK; } EXIT; out: @@ -1248,7 +1248,7 @@ int ldlm_cli_cancel_req(struct obd_export *exp, struct list_head *cancels, } else { rc = ptlrpc_queue_wait(req); } - if (rc == ESTALE) { + if (rc == LUSTRE_ESTALE) { CDEBUG(D_DLMTRACE, "client/server (nid %s) " "out of sync -- not fatal\n", libcfs_nid2str(req->rq_import-> diff --git a/drivers/staging/lustre/lustre/mdc/mdc_locks.c b/drivers/staging/lustre/lustre/mdc/mdc_locks.c index 1cc90b635fb5d..bae2d67e7fa4d 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_locks.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_locks.c @@ -840,6 +840,9 @@ int mdc_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo, lockrep = req_capsule_server_get(&req->rq_pill, &RMF_DLM_REP); LASSERT(lockrep != NULL); + lockrep->lock_policy_res2 = + ptlrpc_status_ntoh(lockrep->lock_policy_res2); + /* Retry the create infinitely when we get -EINPROGRESS from * server. This is required by the new quota design. */ if (it && it->it_op & IT_CREAT && @@ -1139,6 +1142,7 @@ static int mdc_intent_getattr_async_interpret(const struct lu_env *env, struct lookup_intent *it; struct lustre_handle *lockh; struct obd_device *obddev; + struct ldlm_reply *lockrep; __u64 flags = LDLM_FL_HAS_INTENT; ENTRY; @@ -1159,6 +1163,12 @@ static int mdc_intent_getattr_async_interpret(const struct lu_env *env, GOTO(out, rc); } + lockrep = req_capsule_server_get(&req->rq_pill, &RMF_DLM_REP); + LASSERT(lockrep != NULL); + + lockrep->lock_policy_res2 = + ptlrpc_status_ntoh(lockrep->lock_policy_res2); + rc = mdc_finish_enqueue(exp, req, einfo, it, lockh, rc); if (rc) GOTO(out, rc); diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index 21e8a9d161301..b8bf2dcee09fb 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -1189,6 +1189,7 @@ static int mdc_ioc_hsm_progress(struct obd_export *exp, GOTO(out, rc = -EPROTO); *req_hpk = *hpk; + req_hpk->hpk_errval = lustre_errno_hton(hpk->hpk_errval); ptlrpc_request_set_replen(req); diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 53d6a35c80b9b..0c0e07b6f18eb 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -2347,6 +2347,8 @@ static int osc_enqueue_fini(struct ptlrpc_request *req, struct ost_lvb *lvb, &RMF_DLM_REP); LASSERT(rep != NULL); + rep->lock_policy_res1 = + ptlrpc_status_ntoh(rep->lock_policy_res1); if (rep->lock_policy_res1) rc = rep->lock_policy_res1; } diff --git a/drivers/staging/lustre/lustre/ptlrpc/Makefile b/drivers/staging/lustre/lustre/ptlrpc/Makefile index 983eb66a554d2..a379558bc687e 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/Makefile +++ b/drivers/staging/lustre/lustre/ptlrpc/Makefile @@ -16,6 +16,7 @@ ptlrpc_objs += sec.o sec_bulk.o sec_gc.o sec_config.o sec_lproc.o ptlrpc_objs += sec_null.o sec_plain.o nrs.o nrs_fifo.o ptlrpc-y := $(ldlm_objs) $(ptlrpc_objs) +ptlrpc-$(CONFIG_LUSTRE_TRANSLATE_ERRNOS) += errno.c obj-$(CONFIG_PTLRPC_GSS) += gss/ diff --git a/drivers/staging/lustre/lustre/ptlrpc/errno.c b/drivers/staging/lustre/lustre/ptlrpc/errno.c new file mode 100644 index 0000000000000..46e259e4098be --- /dev/null +++ b/drivers/staging/lustre/lustre/ptlrpc/errno.c @@ -0,0 +1,382 @@ +/* + * GPL HEADER START + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 only, + * as published by the Free Software Foundation. + * + * 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 version 2 for more details (a copy is included + * in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU General Public License + * version 2 along with this program; If not, see + * http://www.gnu.org/licenses/gpl-2.0.txt + * + * GPL HEADER END + */ +/* + * Copyright (C) 2011 FUJITSU LIMITED. All rights reserved. + * + * Copyright (c) 2013, Intel Corporation. + */ + +#include +#include + +/* + * The two translation tables below must define a one-to-one mapping between + * host and network errnos. + * + * EWOULDBLOCK is equal to EAGAIN on all architectures except for parisc, which + * appears irrelevant. Thus, existing references to EWOULDBLOCK are fine. + * + * EDEADLOCK is equal to EDEADLK on x86 but not on sparc, at least. A sparc + * host has no context-free way to determine if a LUSTRE_EDEADLK represents an + * EDEADLK or an EDEADLOCK. Therefore, all existing references to EDEADLOCK + * that need to be transferred on wire have been replaced with EDEADLK. + */ +static int lustre_errno_hton_mapping[] = { + [EPERM] = LUSTRE_EPERM, + [ENOENT] = LUSTRE_ENOENT, + [ESRCH] = LUSTRE_ESRCH, + [EINTR] = LUSTRE_EINTR, + [EIO] = LUSTRE_EIO, + [ENXIO] = LUSTRE_ENXIO, + [E2BIG] = LUSTRE_E2BIG, + [ENOEXEC] = LUSTRE_ENOEXEC, + [EBADF] = LUSTRE_EBADF, + [ECHILD] = LUSTRE_ECHILD, + [EAGAIN] = LUSTRE_EAGAIN, + [ENOMEM] = LUSTRE_ENOMEM, + [EACCES] = LUSTRE_EACCES, + [EFAULT] = LUSTRE_EFAULT, + [ENOTBLK] = LUSTRE_ENOTBLK, + [EBUSY] = LUSTRE_EBUSY, + [EEXIST] = LUSTRE_EEXIST, + [EXDEV] = LUSTRE_EXDEV, + [ENODEV] = LUSTRE_ENODEV, + [ENOTDIR] = LUSTRE_ENOTDIR, + [EISDIR] = LUSTRE_EISDIR, + [EINVAL] = LUSTRE_EINVAL, + [ENFILE] = LUSTRE_ENFILE, + [EMFILE] = LUSTRE_EMFILE, + [ENOTTY] = LUSTRE_ENOTTY, + [ETXTBSY] = LUSTRE_ETXTBSY, + [EFBIG] = LUSTRE_EFBIG, + [ENOSPC] = LUSTRE_ENOSPC, + [ESPIPE] = LUSTRE_ESPIPE, + [EROFS] = LUSTRE_EROFS, + [EMLINK] = LUSTRE_EMLINK, + [EPIPE] = LUSTRE_EPIPE, + [EDOM] = LUSTRE_EDOM, + [ERANGE] = LUSTRE_ERANGE, + [EDEADLK] = LUSTRE_EDEADLK, + [ENAMETOOLONG] = LUSTRE_ENAMETOOLONG, + [ENOLCK] = LUSTRE_ENOLCK, + [ENOSYS] = LUSTRE_ENOSYS, + [ENOTEMPTY] = LUSTRE_ENOTEMPTY, + [ELOOP] = LUSTRE_ELOOP, + [ENOMSG] = LUSTRE_ENOMSG, + [EIDRM] = LUSTRE_EIDRM, + [ECHRNG] = LUSTRE_ECHRNG, + [EL2NSYNC] = LUSTRE_EL2NSYNC, + [EL3HLT] = LUSTRE_EL3HLT, + [EL3RST] = LUSTRE_EL3RST, + [ELNRNG] = LUSTRE_ELNRNG, + [EUNATCH] = LUSTRE_EUNATCH, + [ENOCSI] = LUSTRE_ENOCSI, + [EL2HLT] = LUSTRE_EL2HLT, + [EBADE] = LUSTRE_EBADE, + [EBADR] = LUSTRE_EBADR, + [EXFULL] = LUSTRE_EXFULL, + [ENOANO] = LUSTRE_ENOANO, + [EBADRQC] = LUSTRE_EBADRQC, + [EBADSLT] = LUSTRE_EBADSLT, + [EBFONT] = LUSTRE_EBFONT, + [ENOSTR] = LUSTRE_ENOSTR, + [ENODATA] = LUSTRE_ENODATA, + [ETIME] = LUSTRE_ETIME, + [ENOSR] = LUSTRE_ENOSR, + [ENONET] = LUSTRE_ENONET, + [ENOPKG] = LUSTRE_ENOPKG, + [EREMOTE] = LUSTRE_EREMOTE, + [ENOLINK] = LUSTRE_ENOLINK, + [EADV] = LUSTRE_EADV, + [ESRMNT] = LUSTRE_ESRMNT, + [ECOMM] = LUSTRE_ECOMM, + [EPROTO] = LUSTRE_EPROTO, + [EMULTIHOP] = LUSTRE_EMULTIHOP, + [EDOTDOT] = LUSTRE_EDOTDOT, + [EBADMSG] = LUSTRE_EBADMSG, + [EOVERFLOW] = LUSTRE_EOVERFLOW, + [ENOTUNIQ] = LUSTRE_ENOTUNIQ, + [EBADFD] = LUSTRE_EBADFD, + [EREMCHG] = LUSTRE_EREMCHG, + [ELIBACC] = LUSTRE_ELIBACC, + [ELIBBAD] = LUSTRE_ELIBBAD, + [ELIBSCN] = LUSTRE_ELIBSCN, + [ELIBMAX] = LUSTRE_ELIBMAX, + [ELIBEXEC] = LUSTRE_ELIBEXEC, + [EILSEQ] = LUSTRE_EILSEQ, + [ERESTART] = LUSTRE_ERESTART, + [ESTRPIPE] = LUSTRE_ESTRPIPE, + [EUSERS] = LUSTRE_EUSERS, + [ENOTSOCK] = LUSTRE_ENOTSOCK, + [EDESTADDRREQ] = LUSTRE_EDESTADDRREQ, + [EMSGSIZE] = LUSTRE_EMSGSIZE, + [EPROTOTYPE] = LUSTRE_EPROTOTYPE, + [ENOPROTOOPT] = LUSTRE_ENOPROTOOPT, + [EPROTONOSUPPORT] = LUSTRE_EPROTONOSUPPORT, + [ESOCKTNOSUPPORT] = LUSTRE_ESOCKTNOSUPPORT, + [EOPNOTSUPP] = LUSTRE_EOPNOTSUPP, + [EPFNOSUPPORT] = LUSTRE_EPFNOSUPPORT, + [EAFNOSUPPORT] = LUSTRE_EAFNOSUPPORT, + [EADDRINUSE] = LUSTRE_EADDRINUSE, + [EADDRNOTAVAIL] = LUSTRE_EADDRNOTAVAIL, + [ENETDOWN] = LUSTRE_ENETDOWN, + [ENETUNREACH] = LUSTRE_ENETUNREACH, + [ENETRESET] = LUSTRE_ENETRESET, + [ECONNABORTED] = LUSTRE_ECONNABORTED, + [ECONNRESET] = LUSTRE_ECONNRESET, + [ENOBUFS] = LUSTRE_ENOBUFS, + [EISCONN] = LUSTRE_EISCONN, + [ENOTCONN] = LUSTRE_ENOTCONN, + [ESHUTDOWN] = LUSTRE_ESHUTDOWN, + [ETOOMANYREFS] = LUSTRE_ETOOMANYREFS, + [ETIMEDOUT] = LUSTRE_ETIMEDOUT, + [ECONNREFUSED] = LUSTRE_ECONNREFUSED, + [EHOSTDOWN] = LUSTRE_EHOSTDOWN, + [EHOSTUNREACH] = LUSTRE_EHOSTUNREACH, + [EALREADY] = LUSTRE_EALREADY, + [EINPROGRESS] = LUSTRE_EINPROGRESS, + [ESTALE] = LUSTRE_ESTALE, + [EUCLEAN] = LUSTRE_EUCLEAN, + [ENOTNAM] = LUSTRE_ENOTNAM, + [ENAVAIL] = LUSTRE_ENAVAIL, + [EISNAM] = LUSTRE_EISNAM, + [EREMOTEIO] = LUSTRE_EREMOTEIO, + [EDQUOT] = LUSTRE_EDQUOT, + [ENOMEDIUM] = LUSTRE_ENOMEDIUM, + [EMEDIUMTYPE] = LUSTRE_EMEDIUMTYPE, + [ECANCELED] = LUSTRE_ECANCELED, + [ENOKEY] = LUSTRE_ENOKEY, + [EKEYEXPIRED] = LUSTRE_EKEYEXPIRED, + [EKEYREVOKED] = LUSTRE_EKEYREVOKED, + [EKEYREJECTED] = LUSTRE_EKEYREJECTED, + [EOWNERDEAD] = LUSTRE_EOWNERDEAD, + [ENOTRECOVERABLE] = LUSTRE_ENOTRECOVERABLE, + [ERESTARTSYS] = LUSTRE_ERESTARTSYS, + [ERESTARTNOINTR] = LUSTRE_ERESTARTNOINTR, + [ERESTARTNOHAND] = LUSTRE_ERESTARTNOHAND, + [ENOIOCTLCMD] = LUSTRE_ENOIOCTLCMD, + [ERESTART_RESTARTBLOCK] = LUSTRE_ERESTART_RESTARTBLOCK, + [EBADHANDLE] = LUSTRE_EBADHANDLE, + [ENOTSYNC] = LUSTRE_ENOTSYNC, + [EBADCOOKIE] = LUSTRE_EBADCOOKIE, + [ENOTSUPP] = LUSTRE_ENOTSUPP, + [ETOOSMALL] = LUSTRE_ETOOSMALL, + [ESERVERFAULT] = LUSTRE_ESERVERFAULT, + [EBADTYPE] = LUSTRE_EBADTYPE, + [EJUKEBOX] = LUSTRE_EJUKEBOX, + [EIOCBQUEUED] = LUSTRE_EIOCBQUEUED, + [EIOCBRETRY] = LUSTRE_EIOCBRETRY +}; + +static int lustre_errno_ntoh_mapping[] = { + [LUSTRE_EPERM] = EPERM, + [LUSTRE_ENOENT] = ENOENT, + [LUSTRE_ESRCH] = ESRCH, + [LUSTRE_EINTR] = EINTR, + [LUSTRE_EIO] = EIO, + [LUSTRE_ENXIO] = ENXIO, + [LUSTRE_E2BIG] = E2BIG, + [LUSTRE_ENOEXEC] = ENOEXEC, + [LUSTRE_EBADF] = EBADF, + [LUSTRE_ECHILD] = ECHILD, + [LUSTRE_EAGAIN] = EAGAIN, + [LUSTRE_ENOMEM] = ENOMEM, + [LUSTRE_EACCES] = EACCES, + [LUSTRE_EFAULT] = EFAULT, + [LUSTRE_ENOTBLK] = ENOTBLK, + [LUSTRE_EBUSY] = EBUSY, + [LUSTRE_EEXIST] = EEXIST, + [LUSTRE_EXDEV] = EXDEV, + [LUSTRE_ENODEV] = ENODEV, + [LUSTRE_ENOTDIR] = ENOTDIR, + [LUSTRE_EISDIR] = EISDIR, + [LUSTRE_EINVAL] = EINVAL, + [LUSTRE_ENFILE] = ENFILE, + [LUSTRE_EMFILE] = EMFILE, + [LUSTRE_ENOTTY] = ENOTTY, + [LUSTRE_ETXTBSY] = ETXTBSY, + [LUSTRE_EFBIG] = EFBIG, + [LUSTRE_ENOSPC] = ENOSPC, + [LUSTRE_ESPIPE] = ESPIPE, + [LUSTRE_EROFS] = EROFS, + [LUSTRE_EMLINK] = EMLINK, + [LUSTRE_EPIPE] = EPIPE, + [LUSTRE_EDOM] = EDOM, + [LUSTRE_ERANGE] = ERANGE, + [LUSTRE_EDEADLK] = EDEADLK, + [LUSTRE_ENAMETOOLONG] = ENAMETOOLONG, + [LUSTRE_ENOLCK] = ENOLCK, + [LUSTRE_ENOSYS] = ENOSYS, + [LUSTRE_ENOTEMPTY] = ENOTEMPTY, + [LUSTRE_ELOOP] = ELOOP, + [LUSTRE_ENOMSG] = ENOMSG, + [LUSTRE_EIDRM] = EIDRM, + [LUSTRE_ECHRNG] = ECHRNG, + [LUSTRE_EL2NSYNC] = EL2NSYNC, + [LUSTRE_EL3HLT] = EL3HLT, + [LUSTRE_EL3RST] = EL3RST, + [LUSTRE_ELNRNG] = ELNRNG, + [LUSTRE_EUNATCH] = EUNATCH, + [LUSTRE_ENOCSI] = ENOCSI, + [LUSTRE_EL2HLT] = EL2HLT, + [LUSTRE_EBADE] = EBADE, + [LUSTRE_EBADR] = EBADR, + [LUSTRE_EXFULL] = EXFULL, + [LUSTRE_ENOANO] = ENOANO, + [LUSTRE_EBADRQC] = EBADRQC, + [LUSTRE_EBADSLT] = EBADSLT, + [LUSTRE_EBFONT] = EBFONT, + [LUSTRE_ENOSTR] = ENOSTR, + [LUSTRE_ENODATA] = ENODATA, + [LUSTRE_ETIME] = ETIME, + [LUSTRE_ENOSR] = ENOSR, + [LUSTRE_ENONET] = ENONET, + [LUSTRE_ENOPKG] = ENOPKG, + [LUSTRE_EREMOTE] = EREMOTE, + [LUSTRE_ENOLINK] = ENOLINK, + [LUSTRE_EADV] = EADV, + [LUSTRE_ESRMNT] = ESRMNT, + [LUSTRE_ECOMM] = ECOMM, + [LUSTRE_EPROTO] = EPROTO, + [LUSTRE_EMULTIHOP] = EMULTIHOP, + [LUSTRE_EDOTDOT] = EDOTDOT, + [LUSTRE_EBADMSG] = EBADMSG, + [LUSTRE_EOVERFLOW] = EOVERFLOW, + [LUSTRE_ENOTUNIQ] = ENOTUNIQ, + [LUSTRE_EBADFD] = EBADFD, + [LUSTRE_EREMCHG] = EREMCHG, + [LUSTRE_ELIBACC] = ELIBACC, + [LUSTRE_ELIBBAD] = ELIBBAD, + [LUSTRE_ELIBSCN] = ELIBSCN, + [LUSTRE_ELIBMAX] = ELIBMAX, + [LUSTRE_ELIBEXEC] = ELIBEXEC, + [LUSTRE_EILSEQ] = EILSEQ, + [LUSTRE_ERESTART] = ERESTART, + [LUSTRE_ESTRPIPE] = ESTRPIPE, + [LUSTRE_EUSERS] = EUSERS, + [LUSTRE_ENOTSOCK] = ENOTSOCK, + [LUSTRE_EDESTADDRREQ] = EDESTADDRREQ, + [LUSTRE_EMSGSIZE] = EMSGSIZE, + [LUSTRE_EPROTOTYPE] = EPROTOTYPE, + [LUSTRE_ENOPROTOOPT] = ENOPROTOOPT, + [LUSTRE_EPROTONOSUPPORT] = EPROTONOSUPPORT, + [LUSTRE_ESOCKTNOSUPPORT] = ESOCKTNOSUPPORT, + [LUSTRE_EOPNOTSUPP] = EOPNOTSUPP, + [LUSTRE_EPFNOSUPPORT] = EPFNOSUPPORT, + [LUSTRE_EAFNOSUPPORT] = EAFNOSUPPORT, + [LUSTRE_EADDRINUSE] = EADDRINUSE, + [LUSTRE_EADDRNOTAVAIL] = EADDRNOTAVAIL, + [LUSTRE_ENETDOWN] = ENETDOWN, + [LUSTRE_ENETUNREACH] = ENETUNREACH, + [LUSTRE_ENETRESET] = ENETRESET, + [LUSTRE_ECONNABORTED] = ECONNABORTED, + [LUSTRE_ECONNRESET] = ECONNRESET, + [LUSTRE_ENOBUFS] = ENOBUFS, + [LUSTRE_EISCONN] = EISCONN, + [LUSTRE_ENOTCONN] = ENOTCONN, + [LUSTRE_ESHUTDOWN] = ESHUTDOWN, + [LUSTRE_ETOOMANYREFS] = ETOOMANYREFS, + [LUSTRE_ETIMEDOUT] = ETIMEDOUT, + [LUSTRE_ECONNREFUSED] = ECONNREFUSED, + [LUSTRE_EHOSTDOWN] = EHOSTDOWN, + [LUSTRE_EHOSTUNREACH] = EHOSTUNREACH, + [LUSTRE_EALREADY] = EALREADY, + [LUSTRE_EINPROGRESS] = EINPROGRESS, + [LUSTRE_ESTALE] = ESTALE, + [LUSTRE_EUCLEAN] = EUCLEAN, + [LUSTRE_ENOTNAM] = ENOTNAM, + [LUSTRE_ENAVAIL] = ENAVAIL, + [LUSTRE_EISNAM] = EISNAM, + [LUSTRE_EREMOTEIO] = EREMOTEIO, + [LUSTRE_EDQUOT] = EDQUOT, + [LUSTRE_ENOMEDIUM] = ENOMEDIUM, + [LUSTRE_EMEDIUMTYPE] = EMEDIUMTYPE, + [LUSTRE_ECANCELED] = ECANCELED, + [LUSTRE_ENOKEY] = ENOKEY, + [LUSTRE_EKEYEXPIRED] = EKEYEXPIRED, + [LUSTRE_EKEYREVOKED] = EKEYREVOKED, + [LUSTRE_EKEYREJECTED] = EKEYREJECTED, + [LUSTRE_EOWNERDEAD] = EOWNERDEAD, + [LUSTRE_ENOTRECOVERABLE] = ENOTRECOVERABLE, + [LUSTRE_ERESTARTSYS] = ERESTARTSYS, + [LUSTRE_ERESTARTNOINTR] = ERESTARTNOINTR, + [LUSTRE_ERESTARTNOHAND] = ERESTARTNOHAND, + [LUSTRE_ENOIOCTLCMD] = ENOIOCTLCMD, + [LUSTRE_ERESTART_RESTARTBLOCK] = ERESTART_RESTARTBLOCK, + [LUSTRE_EBADHANDLE] = EBADHANDLE, + [LUSTRE_ENOTSYNC] = ENOTSYNC, + [LUSTRE_EBADCOOKIE] = EBADCOOKIE, + [LUSTRE_ENOTSUPP] = ENOTSUPP, + [LUSTRE_ETOOSMALL] = ETOOSMALL, + [LUSTRE_ESERVERFAULT] = ESERVERFAULT, + [LUSTRE_EBADTYPE] = EBADTYPE, + [LUSTRE_EJUKEBOX] = EJUKEBOX, + [LUSTRE_EIOCBQUEUED] = EIOCBQUEUED, + [LUSTRE_EIOCBRETRY] = EIOCBRETRY +}; + +unsigned int lustre_errno_hton(unsigned int h) +{ + unsigned int n; + + if (h == 0) { + n = 0; + } else if (h < ARRAY_SIZE(lustre_errno_hton_mapping)) { + n = lustre_errno_hton_mapping[h]; + if (n == 0) + goto generic; + } else { +generic: + /* + * A generic errno is better than the unknown one that could + * mean anything to a different host. + */ + n = LUSTRE_EIO; + } + + return n; +} +EXPORT_SYMBOL(lustre_errno_hton); + +unsigned int lustre_errno_ntoh(unsigned int n) +{ + unsigned int h; + + if (n == 0) { + h = 0; + } else if (n < ARRAY_SIZE(lustre_errno_ntoh_mapping)) { + h = lustre_errno_ntoh_mapping[n]; + if (h == 0) + goto generic; + } else { +generic: + /* + * Similar to the situation in lustre_errno_hton(), an unknown + * network errno could coincide with anything. Hence, it is + * better to return a generic errno. + */ + h = EIO; + } + + return h; +} +EXPORT_SYMBOL(lustre_errno_ntoh); diff --git a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c index de3f0db0ba47e..5f1b889e52779 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c +++ b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c @@ -400,7 +400,8 @@ int ptlrpc_send_reply(struct ptlrpc_request *req, int flags) req->rq_type = PTL_RPC_MSG_REPLY; lustre_msg_set_type(req->rq_repmsg, req->rq_type); - lustre_msg_set_status(req->rq_repmsg, req->rq_status); + lustre_msg_set_status(req->rq_repmsg, + ptlrpc_status_hton(req->rq_status)); lustre_msg_set_opc(req->rq_repmsg, req->rq_reqmsg ? lustre_msg_get_opc(req->rq_reqmsg) : 0); diff --git a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c index 1437636dfe28b..be246d491886f 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c @@ -642,6 +642,9 @@ static inline int lustre_unpack_ptlrpc_body_v2(struct ptlrpc_request *req, return -EINVAL; } + if (!inout) + pb->pb_status = ptlrpc_status_ntoh(pb->pb_status); + return 0; } -- GitLab From bdf43213f9e7faf980025f44ec82b80caf453e8d Mon Sep 17 00:00:00 2001 From: jcl Date: Tue, 23 Jul 2013 00:06:33 +0800 Subject: [PATCH 031/942] staging/lustre/mdc: layout lock rpc must not take rpc_lock When a client issue an RPC to get a layout lock, it must not hold rpc_lock because in case of a restore the rpc can be blocking for a long time Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3200 Lustre-change: http://review.whamcloud.com/6115 Signed-off-by: JC Lafoucriere Reviewed-by: Jinshan Xiong Reviewed-by: Johann Lombardi Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/lustre_mdc.h | 6 ++++-- drivers/staging/lustre/lustre/mdc/mdc_locks.c | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_mdc.h b/drivers/staging/lustre/lustre/include/lustre_mdc.h index fb1561a809b99..82d1f2f130314 100644 --- a/drivers/staging/lustre/lustre/include/lustre_mdc.h +++ b/drivers/staging/lustre/lustre/include/lustre_mdc.h @@ -86,7 +86,8 @@ static inline void mdc_get_rpc_lock(struct mdc_rpc_lock *lck, { ENTRY; - if (it != NULL && (it->it_op == IT_GETATTR || it->it_op == IT_LOOKUP)) + if (it != NULL && (it->it_op == IT_GETATTR || it->it_op == IT_LOOKUP || + it->it_op == IT_LAYOUT)) return; /* This would normally block until the existing request finishes. @@ -123,7 +124,8 @@ static inline void mdc_get_rpc_lock(struct mdc_rpc_lock *lck, static inline void mdc_put_rpc_lock(struct mdc_rpc_lock *lck, struct lookup_intent *it) { - if (it != NULL && (it->it_op == IT_GETATTR || it->it_op == IT_LOOKUP)) + if (it != NULL && (it->it_op == IT_GETATTR || it->it_op == IT_LOOKUP || + it->it_op == IT_LAYOUT)) goto out; if (lck->rpcl_it == MDC_FAKE_RPCL_IT) { /* OBD_FAIL_MDC_RPCS_SEM */ diff --git a/drivers/staging/lustre/lustre/mdc/mdc_locks.c b/drivers/staging/lustre/lustre/mdc/mdc_locks.c index bae2d67e7fa4d..9532134e16c67 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_locks.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_locks.c @@ -884,7 +884,7 @@ static int mdc_finish_intent_lock(struct obd_export *exp, struct mdt_body *mdt_body; struct ldlm_lock *lock; int rc; - + ENTRY; LASSERT(request != NULL); LASSERT(request != LP_POISON); -- GitLab From 91a50030f05ebf5f96e9091514b5f2858fcead50 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Tue, 23 Jul 2013 00:06:34 +0800 Subject: [PATCH 032/942] staging/lustre/ldlm: split client namespaces into active and inactive The main reason behind this is ldlm_poold walks all namespaces currently no matter if there are any locks or not. On large systems this could take quite a bit of time, esp. since ldlm_poold is currently woken up once per second. Now every time a client namespace loses it's last resource it is placed into an inactive list that is not touched by ldlm_poold as pointless. On creation of a first resource in a namespace it is placed back into the active list. Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2924 Lustre-change: http://review.whamcloud.com/5624 Signed-off-by: Oleg Drokin Reviewed-by: Hiroya Nozaki Reviewed-by: Niu Yawei Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/include/lustre_dlm.h | 2 - .../lustre/lustre/ldlm/ldlm_internal.h | 46 +++++++++++++-- .../staging/lustre/lustre/ldlm/ldlm_pool.c | 59 +++++++++++++++---- .../lustre/lustre/ldlm/ldlm_resource.c | 55 ++++++++++++++--- 4 files changed, 135 insertions(+), 27 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h index 317f928fc1510..48cb6f89cb0ac 100644 --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h @@ -1471,8 +1471,6 @@ void ldlm_namespace_free(struct ldlm_namespace *ns, struct obd_import *imp, int force); void ldlm_namespace_register(struct ldlm_namespace *ns, ldlm_side_t client); void ldlm_namespace_unregister(struct ldlm_namespace *ns, ldlm_side_t client); -void ldlm_namespace_move_locked(struct ldlm_namespace *ns, ldlm_side_t client); -struct ldlm_namespace *ldlm_namespace_first_locked(ldlm_side_t client); void ldlm_namespace_get(struct ldlm_namespace *ns); void ldlm_namespace_put(struct ldlm_namespace *ns); int ldlm_proc_setup(void); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h index 141a957462f1d..785c1a19da57d 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h @@ -36,23 +36,46 @@ #define MAX_STRING_SIZE 128 -extern atomic_t ldlm_srv_namespace_nr; -extern atomic_t ldlm_cli_namespace_nr; +extern int ldlm_srv_namespace_nr; +extern int ldlm_cli_namespace_nr; extern struct mutex ldlm_srv_namespace_lock; extern struct list_head ldlm_srv_namespace_list; extern struct mutex ldlm_cli_namespace_lock; -extern struct list_head ldlm_cli_namespace_list; +extern struct list_head ldlm_cli_active_namespace_list; +extern struct list_head ldlm_cli_inactive_namespace_list; -static inline atomic_t *ldlm_namespace_nr(ldlm_side_t client) +static inline int ldlm_namespace_nr_read(ldlm_side_t client) { return client == LDLM_NAMESPACE_SERVER ? - &ldlm_srv_namespace_nr : &ldlm_cli_namespace_nr; + ldlm_srv_namespace_nr : ldlm_cli_namespace_nr; +} + +static inline void ldlm_namespace_nr_inc(ldlm_side_t client) +{ + if (client == LDLM_NAMESPACE_SERVER) + ldlm_srv_namespace_nr++; + else + ldlm_cli_namespace_nr++; +} + +static inline void ldlm_namespace_nr_dec(ldlm_side_t client) +{ + if (client == LDLM_NAMESPACE_SERVER) + ldlm_srv_namespace_nr--; + else + ldlm_cli_namespace_nr--; } static inline struct list_head *ldlm_namespace_list(ldlm_side_t client) { return client == LDLM_NAMESPACE_SERVER ? - &ldlm_srv_namespace_list : &ldlm_cli_namespace_list; + &ldlm_srv_namespace_list : &ldlm_cli_active_namespace_list; +} + +static inline struct list_head *ldlm_namespace_inactive_list(ldlm_side_t client) +{ + return client == LDLM_NAMESPACE_SERVER ? + &ldlm_srv_namespace_list : &ldlm_cli_inactive_namespace_list; } static inline struct mutex *ldlm_namespace_lock(ldlm_side_t client) @@ -61,6 +84,17 @@ static inline struct mutex *ldlm_namespace_lock(ldlm_side_t client) &ldlm_srv_namespace_lock : &ldlm_cli_namespace_lock; } +/* ns_bref is the number of resources in this namespace with the notable + * exception of quota namespaces which have their empty refcount at 1 */ +static inline int ldlm_ns_empty(struct ldlm_namespace *ns) +{ + return atomic_read(&ns->ns_bref) == 0; +} + +void ldlm_namespace_move_to_active_locked(struct ldlm_namespace *, ldlm_side_t); +void ldlm_namespace_move_to_inactive_locked(struct ldlm_namespace *, ldlm_side_t); +struct ldlm_namespace *ldlm_namespace_first_locked(ldlm_side_t); + /* ldlm_request.c */ /* Cancel lru flag, it indicates we cancel aged locks. */ enum { diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c index b3b60288e5f5c..1e6802fa0a7b4 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c @@ -1039,6 +1039,7 @@ static int ldlm_pools_shrink(ldlm_side_t client, int nr, { int total = 0, cached = 0, nr_ns; struct ldlm_namespace *ns; + struct ldlm_namespace *ns_old = NULL; /* loop detection */ void *cookie; if (client == LDLM_NAMESPACE_CLIENT && nr != 0 && @@ -1053,7 +1054,7 @@ static int ldlm_pools_shrink(ldlm_side_t client, int nr, /* * Find out how many resources we may release. */ - for (nr_ns = atomic_read(ldlm_namespace_nr(client)); + for (nr_ns = ldlm_namespace_nr_read(client); nr_ns > 0; nr_ns--) { mutex_lock(ldlm_namespace_lock(client)); @@ -1063,8 +1064,23 @@ static int ldlm_pools_shrink(ldlm_side_t client, int nr, return 0; } ns = ldlm_namespace_first_locked(client); + + if (ns == ns_old) { + mutex_unlock(ldlm_namespace_lock(client)); + break; + } + + if (ldlm_ns_empty(ns)) { + ldlm_namespace_move_to_inactive_locked(ns, client); + mutex_unlock(ldlm_namespace_lock(client)); + continue; + } + + if (ns_old == NULL) + ns_old = ns; + ldlm_namespace_get(ns); - ldlm_namespace_move_locked(ns, client); + ldlm_namespace_move_to_active_locked(ns, client); mutex_unlock(ldlm_namespace_lock(client)); total += ldlm_pool_shrink(&ns->ns_pool, 0, gfp_mask); ldlm_namespace_put(ns); @@ -1078,7 +1094,7 @@ static int ldlm_pools_shrink(ldlm_side_t client, int nr, /* * Shrink at least ldlm_namespace_nr(client) namespaces. */ - for (nr_ns = atomic_read(ldlm_namespace_nr(client)); + for (nr_ns = ldlm_namespace_nr_read(client) - nr_ns; nr_ns > 0; nr_ns--) { int cancel, nr_locks; @@ -1099,7 +1115,7 @@ static int ldlm_pools_shrink(ldlm_side_t client, int nr, } ns = ldlm_namespace_first_locked(client); ldlm_namespace_get(ns); - ldlm_namespace_move_locked(ns, client); + ldlm_namespace_move_to_active_locked(ns, client); mutex_unlock(ldlm_namespace_lock(client)); nr_locks = ldlm_pool_granted(&ns->ns_pool); @@ -1132,6 +1148,7 @@ void ldlm_pools_recalc(ldlm_side_t client) { __u32 nr_l = 0, nr_p = 0, l; struct ldlm_namespace *ns; + struct ldlm_namespace *ns_old = NULL; int nr, equal = 0; /* @@ -1190,16 +1207,14 @@ void ldlm_pools_recalc(ldlm_side_t client) * for _all_ pools. */ l = LDLM_POOL_HOST_L / - atomic_read( - ldlm_namespace_nr(client)); + ldlm_namespace_nr_read(client); } else { /* * All the rest of greedy pools will have * all locks in equal parts. */ l = (LDLM_POOL_HOST_L - nr_l) / - (atomic_read( - ldlm_namespace_nr(client)) - + (ldlm_namespace_nr_read(client) - nr_p); } ldlm_pool_setup(&ns->ns_pool, l); @@ -1210,7 +1225,7 @@ void ldlm_pools_recalc(ldlm_side_t client) /* * Recalc at least ldlm_namespace_nr(client) namespaces. */ - for (nr = atomic_read(ldlm_namespace_nr(client)); nr > 0; nr--) { + for (nr = ldlm_namespace_nr_read(client); nr > 0; nr--) { int skip; /* * Lock the list, get first @ns in the list, getref, move it @@ -1226,6 +1241,30 @@ void ldlm_pools_recalc(ldlm_side_t client) } ns = ldlm_namespace_first_locked(client); + if (ns_old == ns) { /* Full pass complete */ + mutex_unlock(ldlm_namespace_lock(client)); + break; + } + + /* We got an empty namespace, need to move it back to inactive + * list. + * The race with parallel resource creation is fine: + * - If they do namespace_get before our check, we fail the + * check and they move this item to the end of the list anyway + * - If we do the check and then they do namespace_get, then + * we move the namespace to inactive and they will move + * it back to active (synchronised by the lock, so no clash + * there). + */ + if (ldlm_ns_empty(ns)) { + ldlm_namespace_move_to_inactive_locked(ns, client); + mutex_unlock(ldlm_namespace_lock(client)); + continue; + } + + if (ns_old == NULL) + ns_old = ns; + spin_lock(&ns->ns_lock); /* * skip ns which is being freed, and we don't want to increase @@ -1239,7 +1278,7 @@ void ldlm_pools_recalc(ldlm_side_t client) } spin_unlock(&ns->ns_lock); - ldlm_namespace_move_locked(ns, client); + ldlm_namespace_move_to_active_locked(ns, client); mutex_unlock(ldlm_namespace_lock(client)); /* diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index cb8659f71149b..716283859d72a 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -48,14 +48,19 @@ struct kmem_cache *ldlm_resource_slab, *ldlm_lock_slab; -atomic_t ldlm_srv_namespace_nr = ATOMIC_INIT(0); -atomic_t ldlm_cli_namespace_nr = ATOMIC_INIT(0); +int ldlm_srv_namespace_nr = 0; +int ldlm_cli_namespace_nr = 0; struct mutex ldlm_srv_namespace_lock; LIST_HEAD(ldlm_srv_namespace_list); struct mutex ldlm_cli_namespace_lock; -LIST_HEAD(ldlm_cli_namespace_list); +/* Client Namespaces that have active resources in them. + * Once all resources go away, ldlm_poold moves such namespaces to the + * inactive list */ +LIST_HEAD(ldlm_cli_active_namespace_list); +/* Client namespaces that don't have any locks in them */ +LIST_HEAD(ldlm_cli_inactive_namespace_list); proc_dir_entry_t *ldlm_type_proc_dir = NULL; proc_dir_entry_t *ldlm_ns_proc_dir = NULL; @@ -636,7 +641,7 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name, GOTO(out_hash, rc); } - idx = atomic_read(ldlm_namespace_nr(client)); + idx = ldlm_namespace_nr_read(client); rc = ldlm_pool_init(&ns->ns_pool, ns, idx, client); if (rc) { CERROR("Can't initialize lock pool, rc %d\n", rc); @@ -953,6 +958,12 @@ void ldlm_namespace_get(struct ldlm_namespace *ns) } EXPORT_SYMBOL(ldlm_namespace_get); +/* This is only for callers that care about refcount */ +int ldlm_namespace_get_return(struct ldlm_namespace *ns) +{ + return atomic_inc_return(&ns->ns_bref); +} + void ldlm_namespace_put(struct ldlm_namespace *ns) { if (atomic_dec_and_lock(&ns->ns_bref, &ns->ns_lock)) { @@ -967,8 +978,8 @@ void ldlm_namespace_register(struct ldlm_namespace *ns, ldlm_side_t client) { mutex_lock(ldlm_namespace_lock(client)); LASSERT(list_empty(&ns->ns_list_chain)); - list_add(&ns->ns_list_chain, ldlm_namespace_list(client)); - atomic_inc(ldlm_namespace_nr(client)); + list_add(&ns->ns_list_chain, ldlm_namespace_inactive_list(client)); + ldlm_namespace_nr_inc(client); mutex_unlock(ldlm_namespace_lock(client)); } @@ -981,18 +992,29 @@ void ldlm_namespace_unregister(struct ldlm_namespace *ns, ldlm_side_t client) * using list_empty(&ns->ns_list_chain). This is why it is * important to use list_del_init() here. */ list_del_init(&ns->ns_list_chain); - atomic_dec(ldlm_namespace_nr(client)); + ldlm_namespace_nr_dec(client); mutex_unlock(ldlm_namespace_lock(client)); } /** Should be called with ldlm_namespace_lock(client) taken. */ -void ldlm_namespace_move_locked(struct ldlm_namespace *ns, ldlm_side_t client) +void ldlm_namespace_move_to_active_locked(struct ldlm_namespace *ns, + ldlm_side_t client) { LASSERT(!list_empty(&ns->ns_list_chain)); LASSERT(mutex_is_locked(ldlm_namespace_lock(client))); list_move_tail(&ns->ns_list_chain, ldlm_namespace_list(client)); } +/** Should be called with ldlm_namespace_lock(client) taken. */ +void ldlm_namespace_move_to_inactive_locked(struct ldlm_namespace *ns, + ldlm_side_t client) +{ + LASSERT(!list_empty(&ns->ns_list_chain)); + LASSERT(mutex_is_locked(ldlm_namespace_lock(client))); + list_move_tail(&ns->ns_list_chain, + ldlm_namespace_inactive_list(client)); +} + /** Should be called with ldlm_namespace_lock(client) taken. */ struct ldlm_namespace *ldlm_namespace_first_locked(ldlm_side_t client) { @@ -1049,6 +1071,7 @@ ldlm_resource_get(struct ldlm_namespace *ns, struct ldlm_resource *parent, struct ldlm_resource *res; cfs_hash_bd_t bd; __u64 version; + int ns_refcount = 0; LASSERT(ns != NULL); LASSERT(parent == NULL); @@ -1119,7 +1142,7 @@ ldlm_resource_get(struct ldlm_namespace *ns, struct ldlm_resource *parent, /* We won! Let's add the resource. */ cfs_hash_bd_add_locked(ns->ns_rs_hash, &bd, &res->lr_hash); if (cfs_hash_bd_count_get(&bd) == 1) - ldlm_namespace_get(ns); + ns_refcount = ldlm_namespace_get_return(ns); cfs_hash_bd_unlock(ns->ns_rs_hash, &bd, 1); if (ns->ns_lvbo && ns->ns_lvbo->lvbo_init) { @@ -1145,6 +1168,20 @@ ldlm_resource_get(struct ldlm_namespace *ns, struct ldlm_resource *parent, /* We create resource with locked lr_lvb_mutex. */ mutex_unlock(&res->lr_lvb_mutex); + /* Let's see if we happened to be the very first resource in this + * namespace. If so, and this is a client namespace, we need to move + * the namespace into the active namespaces list to be patrolled by + * the ldlm_poold. + * A notable exception, for quota namespaces qsd_lib.c already took a + * namespace reference, so it won't be participating in all of this, + * but I guess that's ok since we have no business cancelling quota + * locks anyway */ + if (ns_is_client(ns) && ns_refcount == 1) { + mutex_lock(ldlm_namespace_lock(LDLM_NAMESPACE_CLIENT)); + ldlm_namespace_move_to_active_locked(ns, LDLM_NAMESPACE_CLIENT); + mutex_unlock(ldlm_namespace_lock(LDLM_NAMESPACE_CLIENT)); + } + return res; } EXPORT_SYMBOL(ldlm_resource_get); -- GitLab From 3eface5946de342cfdf4f345353a35dcfa2cf972 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Tue, 23 Jul 2013 00:06:35 +0800 Subject: [PATCH 033/942] staging/lustre: Only wake up ldlm_poold as frequently as the check interval We used to wake up ldlm poold every second, but that's overkill, we should just see how much time is left until next closest recalc interval hits and sleep this much. This will make "per-second" client grant statistic not actually per-second, but I don't think we need any precision in that code Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2924 Lustre-change: http://review.whamcloud.com/5793 Signed-off-by: Oleg Drokin Reviewed-by: Vitaly Fertman Reviewed-by: Hiroya Nozaki Reviewed-by: Niu Yawei Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/include/lustre_dlm.h | 2 +- .../staging/lustre/lustre/ldlm/ldlm_pool.c | 24 ++++++++++++------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h index 48cb6f89cb0ac..25437b7c20267 100644 --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h @@ -1643,7 +1643,7 @@ void unlock_res_and_lock(struct ldlm_lock *lock); * There are not used outside of ldlm. * @{ */ -void ldlm_pools_recalc(ldlm_side_t client); +int ldlm_pools_recalc(ldlm_side_t client); int ldlm_pools_init(void); void ldlm_pools_fini(void); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c index 1e6802fa0a7b4..3277a0dca31e8 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c @@ -578,7 +578,6 @@ int ldlm_pool_recalc(struct ldlm_pool *pl) goto recalc; spin_lock(&pl->pl_lock); - recalc_interval_sec = cfs_time_current_sec() - pl->pl_recalc_time; if (recalc_interval_sec > 0) { /* * Update pool statistics every 1s. @@ -598,12 +597,12 @@ int ldlm_pool_recalc(struct ldlm_pool *pl) count = pl->pl_ops->po_recalc(pl); lprocfs_counter_add(pl->pl_stats, LDLM_POOL_RECALC_STAT, count); - return count; } + recalc_interval_sec = pl->pl_recalc_time - cfs_time_current_sec() + + pl->pl_recalc_period; - return 0; + return recalc_interval_sec; } -EXPORT_SYMBOL(ldlm_pool_recalc); /** * Pool shrink wrapper. Will call either client or server pool recalc callback @@ -1144,12 +1143,13 @@ static int ldlm_pools_cli_shrink(SHRINKER_ARGS(sc, nr_to_scan, gfp_mask)) shrink_param(sc, gfp_mask)); } -void ldlm_pools_recalc(ldlm_side_t client) +int ldlm_pools_recalc(ldlm_side_t client) { __u32 nr_l = 0, nr_p = 0, l; struct ldlm_namespace *ns; struct ldlm_namespace *ns_old = NULL; int nr, equal = 0; + int time = 50; /* seconds of sleep if no active namespaces */ /* * No need to setup pool limit for client pools. @@ -1285,16 +1285,22 @@ void ldlm_pools_recalc(ldlm_side_t client) * After setup is done - recalc the pool. */ if (!skip) { - ldlm_pool_recalc(&ns->ns_pool); + int ttime = ldlm_pool_recalc(&ns->ns_pool); + + if (ttime < time) + time = ttime; + ldlm_namespace_put(ns); } } + return time; } EXPORT_SYMBOL(ldlm_pools_recalc); static int ldlm_pools_thread_main(void *arg) { struct ptlrpc_thread *thread = (struct ptlrpc_thread *)arg; + int s_time, c_time; ENTRY; thread_set_flags(thread, SVC_RUNNING); @@ -1309,14 +1315,14 @@ static int ldlm_pools_thread_main(void *arg) /* * Recal all pools on this tick. */ - ldlm_pools_recalc(LDLM_NAMESPACE_SERVER); - ldlm_pools_recalc(LDLM_NAMESPACE_CLIENT); + s_time = ldlm_pools_recalc(LDLM_NAMESPACE_SERVER); + c_time = ldlm_pools_recalc(LDLM_NAMESPACE_CLIENT); /* * Wait until the next check time, or until we're * stopped. */ - lwi = LWI_TIMEOUT(cfs_time_seconds(LDLM_POOLS_THREAD_PERIOD), + lwi = LWI_TIMEOUT(cfs_time_seconds(min(s_time, c_time)), NULL, NULL); l_wait_event(thread->t_ctl_waitq, thread_is_stopping(thread) || -- GitLab From df9fcbeb7730ec77a8f643ff1e00b99167cbeabe Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Tue, 23 Jul 2013 00:06:36 +0800 Subject: [PATCH 034/942] staging/lustre: Make quota namespace refcounting consistent It seems quota namespace is needlessly referenced on connect, but that's not necessary as it could not go away until entire obd goes away. On the other hand this extra reference disturbs other logic depending on empty namespace having zero refcount, so this patch drops such extra referencing. This picks client side change of the original patch. Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2924 Lustre-change: http://review.whamcloud.com/6234 Signed-off-by: Oleg Drokin Reviewed-by: Niu Yawei Reviewed-by: Johann Lombardi Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ldlm/ldlm_internal.h | 3 +-- drivers/staging/lustre/lustre/ldlm/ldlm_resource.c | 6 +----- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h index 785c1a19da57d..bf6f00341a768 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h @@ -84,8 +84,7 @@ static inline struct mutex *ldlm_namespace_lock(ldlm_side_t client) &ldlm_srv_namespace_lock : &ldlm_cli_namespace_lock; } -/* ns_bref is the number of resources in this namespace with the notable - * exception of quota namespaces which have their empty refcount at 1 */ +/* ns_bref is the number of resources in this namespace */ static inline int ldlm_ns_empty(struct ldlm_namespace *ns) { return atomic_read(&ns->ns_bref) == 0; diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index 716283859d72a..17eab79ba8394 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -1171,11 +1171,7 @@ ldlm_resource_get(struct ldlm_namespace *ns, struct ldlm_resource *parent, /* Let's see if we happened to be the very first resource in this * namespace. If so, and this is a client namespace, we need to move * the namespace into the active namespaces list to be patrolled by - * the ldlm_poold. - * A notable exception, for quota namespaces qsd_lib.c already took a - * namespace reference, so it won't be participating in all of this, - * but I guess that's ok since we have no business cancelling quota - * locks anyway */ + * the ldlm_poold. */ if (ns_is_client(ns) && ns_refcount == 1) { mutex_lock(ldlm_namespace_lock(LDLM_NAMESPACE_CLIENT)); ldlm_namespace_move_to_active_locked(ns, LDLM_NAMESPACE_CLIENT); -- GitLab From f2145eae3d4d7c93fcbd7013bbf31db76bdd0ad4 Mon Sep 17 00:00:00 2001 From: Bruce Korb Date: Tue, 23 Jul 2013 00:06:37 +0800 Subject: [PATCH 035/942] staging/lustre/dlmlock: compress out unused space * lustre/include/lustre_dlm.h: Remove all bit fields and the unused weighing callback procedure. respell LDLM_AST_DISCARD_DATA as LDLM_FL_AST_DISCARD_DATA to match other flags. * .gitignore: ignore emacs temporary files * autogen.sh: rebuild the lock bits, if autogen is available. * contrib/bit-masks/lustre_dlm_flags.def: define the ldlm_lock flags * contrib/bit-masks/lustre_dlm_flags.tpl: template for emitting text * contrib/bit-masks/Makefile: construct the .c and .h files The .c file is for constructing a crash extension and is not preserved. * contrib/bit-masks/.gitignore: ignore built products * lustre/contrib/wireshark/packet-lustre.c: use built files instead of local versions of the defines. In the rest of the modified sources, replace flag field references with bit mask references. * lustre/osc/osc_lock.c: removed osc_lock_weigh, too Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2771 Lustre-change: http://review.whamcloud.com/5312 Signed-off-by: Bruce Korb Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Reviewed-by: Keith Mannthey Reviewed-by: Keith Mannthey Reviewed-by: Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/include/lustre_dlm.h | 198 +------- .../lustre/lustre/include/lustre_dlm_flags.h | 460 ++++++++++++++++++ drivers/staging/lustre/lustre/ldlm/l_lock.c | 8 +- .../staging/lustre/lustre/ldlm/ldlm_flock.c | 2 +- .../staging/lustre/lustre/ldlm/ldlm_lock.c | 48 +- .../staging/lustre/lustre/ldlm/ldlm_lockd.c | 4 +- .../staging/lustre/lustre/ldlm/ldlm_request.c | 7 +- .../lustre/lustre/ldlm/ldlm_resource.c | 4 +- drivers/staging/lustre/lustre/llite/dir.c | 15 +- drivers/staging/lustre/lustre/llite/file.c | 19 +- drivers/staging/lustre/lustre/mdc/mdc_locks.c | 9 +- .../staging/lustre/lustre/mgc/mgc_request.c | 8 +- drivers/staging/lustre/lustre/osc/osc_lock.c | 124 ++--- 13 files changed, 573 insertions(+), 333 deletions(-) create mode 100644 drivers/staging/lustre/lustre/include/lustre_dlm_flags.h diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h index 25437b7c20267..66db562c5caad 100644 --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h @@ -57,6 +57,8 @@ #include /* for interval_node{}, ldlm_extent */ #include +#include "lustre_dlm_flags.h" + struct obd_ops; struct obd_device; @@ -95,161 +97,6 @@ typedef enum { LDLM_NAMESPACE_CLIENT = 1 << 1 } ldlm_side_t; -/** - * Declaration of flags sent through the wire. - **/ -#define LDLM_FL_LOCK_CHANGED 0x000001 /* extent, mode, or resource changed */ - -/** - * If the server returns one of these flags, then the lock was put on that list. - * If the client sends one of these flags (during recovery ONLY!), it wants the - * lock added to the specified list, no questions asked. - */ -#define LDLM_FL_BLOCK_GRANTED 0x000002 -#define LDLM_FL_BLOCK_CONV 0x000004 -#define LDLM_FL_BLOCK_WAIT 0x000008 - -/* Used to be LDLM_FL_CBPENDING 0x000010 moved to non-wire flags */ - -#define LDLM_FL_AST_SENT 0x000020 /* blocking or cancel packet was - * queued for sending. */ -/* Used to be LDLM_FL_WAIT_NOREPROC 0x000040 moved to non-wire flags */ -/* Used to be LDLM_FL_CANCEL 0x000080 moved to non-wire flags */ - -/** - * Lock is being replayed. This could probably be implied by the fact that one - * of BLOCK_{GRANTED,CONV,WAIT} is set, but that is pretty dangerous. - */ -#define LDLM_FL_REPLAY 0x000100 - -#define LDLM_FL_INTENT_ONLY 0x000200 /* Don't grant lock, just do intent. */ - -/* Used to be LDLM_FL_LOCAL_ONLY 0x000400 moved to non-wire flags */ -/* Used to be LDLM_FL_FAILED 0x000800 moved to non-wire flags */ - -#define LDLM_FL_HAS_INTENT 0x001000 /* lock request has intent */ - -/* Used to be LDLM_FL_CANCELING 0x002000 moved to non-wire flags */ -/* Used to be LDLM_FL_LOCAL 0x004000 moved to non-wire flags */ - -#define LDLM_FL_DISCARD_DATA 0x010000 /* discard (no writeback) on cancel */ - -#define LDLM_FL_NO_TIMEOUT 0x020000 /* Blocked by group lock - wait - * indefinitely */ - -/** file & record locking */ -#define LDLM_FL_BLOCK_NOWAIT 0x040000 /* Server told not to wait if blocked. - * For AGL, OST will not send glimpse - * callback. */ -#define LDLM_FL_TEST_LOCK 0x080000 // return blocking lock - -/* Used to be LDLM_FL_LVB_READY 0x100000 moved to non-wire flags */ -/* Used to be LDLM_FL_KMS_IGNORE 0x200000 moved to non-wire flags */ -/* Used to be LDLM_FL_NO_LRU 0x400000 moved to non-wire flags */ - -/* Immediatelly cancel such locks when they block some other locks. Send - * cancel notification to original lock holder, but expect no reply. This is - * for clients (like liblustre) that cannot be expected to reliably response - * to blocking AST. */ -#define LDLM_FL_CANCEL_ON_BLOCK 0x800000 - -/* Flags flags inherited from parent lock when doing intents. */ -#define LDLM_INHERIT_FLAGS (LDLM_FL_CANCEL_ON_BLOCK) - -/* Used to be LDLM_FL_CP_REQD 0x1000000 moved to non-wire flags */ -/* Used to be LDLM_FL_CLEANED 0x2000000 moved to non-wire flags */ -/* Used to be LDLM_FL_ATOMIC_CB 0x4000000 moved to non-wire flags */ -/* Used to be LDLM_FL_BL_AST 0x10000000 moved to non-wire flags */ -/* Used to be LDLM_FL_BL_DONE 0x20000000 moved to non-wire flags */ - -/* measure lock contention and return -EUSERS if locking contention is high */ -#define LDLM_FL_DENY_ON_CONTENTION 0x40000000 - -/* These are flags that are mapped into the flags and ASTs of blocking locks */ -#define LDLM_AST_DISCARD_DATA 0x80000000 /* Add FL_DISCARD to blocking ASTs */ - -/* Flags sent in AST lock_flags to be mapped into the receiving lock. */ -#define LDLM_AST_FLAGS (LDLM_FL_DISCARD_DATA) - -/* - * -------------------------------------------------------------------------- - * NOTE! Starting from this point, that is, LDLM_FL_* flags with values above - * 0x80000000 will not be sent over the wire. - * -------------------------------------------------------------------------- - */ - -/** - * Declaration of flags not sent through the wire. - **/ - -/** - * Used for marking lock as a target for -EINTR while cp_ast sleep - * emulation + race with upcoming bl_ast. - */ -#define LDLM_FL_FAIL_LOC 0x100000000ULL - -/** - * Used while processing the unused list to know that we have already - * handled this lock and decided to skip it. - */ -#define LDLM_FL_SKIPPED 0x200000000ULL -/* this lock is being destroyed */ -#define LDLM_FL_CBPENDING 0x400000000ULL -/* not a real flag, not saved in lock */ -#define LDLM_FL_WAIT_NOREPROC 0x800000000ULL -/* cancellation callback already run */ -#define LDLM_FL_CANCEL 0x1000000000ULL -#define LDLM_FL_LOCAL_ONLY 0x2000000000ULL -/* don't run the cancel callback under ldlm_cli_cancel_unused */ -#define LDLM_FL_FAILED 0x4000000000ULL -/* lock cancel has already been sent */ -#define LDLM_FL_CANCELING 0x8000000000ULL -/* local lock (ie, no srv/cli split) */ -#define LDLM_FL_LOCAL 0x10000000000ULL -/* XXX FIXME: This is being added to b_size as a low-risk fix to the fact that - * the LVB filling happens _after_ the lock has been granted, so another thread - * can match it before the LVB has been updated. As a dirty hack, we set - * LDLM_FL_LVB_READY only after we've done the LVB poop. - * this is only needed on LOV/OSC now, where LVB is actually used and callers - * must set it in input flags. - * - * The proper fix is to do the granting inside of the completion AST, which can - * be replaced with a LVB-aware wrapping function for OSC locks. That change is - * pretty high-risk, though, and would need a lot more testing. */ -#define LDLM_FL_LVB_READY 0x20000000000ULL -/* A lock contributes to the known minimum size (KMS) calculation until it has - * finished the part of its cancelation that performs write back on its dirty - * pages. It can remain on the granted list during this whole time. Threads - * racing to update the KMS after performing their writeback need to know to - * exclude each other's locks from the calculation as they walk the granted - * list. */ -#define LDLM_FL_KMS_IGNORE 0x40000000000ULL -/* completion AST to be executed */ -#define LDLM_FL_CP_REQD 0x80000000000ULL -/* cleanup_resource has already handled the lock */ -#define LDLM_FL_CLEANED 0x100000000000ULL -/* optimization hint: LDLM can run blocking callback from current context - * w/o involving separate thread. in order to decrease cs rate */ -#define LDLM_FL_ATOMIC_CB 0x200000000000ULL - -/* It may happen that a client initiates two operations, e.g. unlink and - * mkdir, such that the server sends a blocking AST for conflicting - * locks to this client for the first operation, whereas the second - * operation has canceled this lock and is waiting for rpc_lock which is - * taken by the first operation. LDLM_FL_BL_AST is set by - * ldlm_callback_handler() in the lock to prevent the Early Lock Cancel - * (ELC) code from cancelling it. - * - * LDLM_FL_BL_DONE is to be set by ldlm_cancel_callback() when lock - * cache is dropped to let ldlm_callback_handler() return EINVAL to the - * server. It is used when ELC RPC is already prepared and is waiting - * for rpc_lock, too late to send a separate CANCEL RPC. */ -#define LDLM_FL_BL_AST 0x400000000000ULL -#define LDLM_FL_BL_DONE 0x800000000000ULL -/* Don't put lock into the LRU list, so that it is not canceled due to aging. - * Used by MGC locks, they are cancelled only at unmount or by callback. */ -#define LDLM_FL_NO_LRU 0x1000000000000ULL - /** * The blocking callback is overloaded to perform two functions. These flags * indicate which operation should be performed. @@ -720,8 +567,6 @@ typedef int (*ldlm_completion_callback)(struct ldlm_lock *lock, __u64 flags, void *data); /** Type for glimpse callback function of a lock. */ typedef int (*ldlm_glimpse_callback)(struct ldlm_lock *lock, void *data); -/** Type for weight callback function of a lock. */ -typedef unsigned long (*ldlm_weigh_callback)(struct ldlm_lock *lock); /** Work list for sending GL ASTs to multiple locks. */ struct ldlm_glimpse_work { @@ -890,9 +735,6 @@ struct ldlm_lock { */ ldlm_glimpse_callback l_glimpse_ast; - /** XXX apparently unused "weight" handler. To be removed? */ - ldlm_weigh_callback l_weigh_ast; - /** * Lock export. * This is a pointer to actual client export for locks that were granted @@ -919,11 +761,11 @@ struct ldlm_lock { ldlm_policy_data_t l_policy_data; /** - * Lock state flags. - * Like whenever we receive any blocking requests for this lock, etc. - * Protected by lr_lock. + * Lock state flags. Protected by lr_lock. + * \see lustre_dlm_flags.h where the bits are defined. */ __u64 l_flags; + /** * Lock r/w usage counters. * Protected by lr_lock. @@ -952,34 +794,6 @@ struct ldlm_lock { /** Originally requested extent for the extent lock. */ struct ldlm_extent l_req_extent; - unsigned int l_failed:1, - /** - * Set for locks that were removed from class hash table and will be - * destroyed when last reference to them is released. Set by - * ldlm_lock_destroy_internal(). - * - * Protected by lock and resource locks. - */ - l_destroyed:1, - /* - * it's set in lock_res_and_lock() and unset in unlock_res_and_lock(). - * - * NB: compared with check_res_locked(), checking this bit is cheaper. - * Also, spin_is_locked() is deprecated for kernel code; one reason is - * because it works only for SMP so user needs to add extra macros like - * LASSERT_SPIN_LOCKED for uniprocessor kernels. - */ - l_res_locked:1, - /* - * It's set once we call ldlm_add_waiting_lock_res_locked() - * to start the lock-timeout timer and it will never be reset. - * - * Protected by lock_res_and_lock(). - */ - l_waited:1, - /** Flag whether this is a server namespace lock. */ - l_ns_srv:1; - /* * Client-side-only members. */ @@ -1230,7 +1044,6 @@ struct ldlm_enqueue_info { void *ei_cb_bl; /** blocking lock callback */ void *ei_cb_cp; /** lock completion callback */ void *ei_cb_gl; /** lock glimpse callback */ - void *ei_cb_wg; /** lock weigh callback */ void *ei_cbdata; /** Data to be passed into callbacks. */ }; @@ -1328,7 +1141,6 @@ struct ldlm_callback_suite { ldlm_completion_callback lcs_completion; ldlm_blocking_callback lcs_blocking; ldlm_glimpse_callback lcs_glimpse; - ldlm_weigh_callback lcs_weigh; }; /* ldlm_lockd.c */ diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm_flags.h b/drivers/staging/lustre/lustre/include/lustre_dlm_flags.h new file mode 100644 index 0000000000000..8c34d9d4d2587 --- /dev/null +++ b/drivers/staging/lustre/lustre/include/lustre_dlm_flags.h @@ -0,0 +1,460 @@ +/* -*- buffer-read-only: t -*- vi: set ro: + * + * DO NOT EDIT THIS FILE (lustre_dlm_flags.h) + * + * It has been AutoGen-ed + * From the definitions lustre_dlm_flags.def + * and the template file lustre_dlm_flags.tpl + * + * lustre 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 3 of the License, or + * (at your option) any later version. + * + * lustre 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. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ +/** + * \file lustre_dlm_flags.h + * The flags and collections of flags (masks) for \see struct ldlm_lock. + * This file is derived from flag definitions in lustre_dlm_flags.def. + * The format is defined in the lustre_dlm_flags.tpl template file. + * + * \addtogroup LDLM Lustre Distributed Lock Manager + * @{ + * + * \name flags + * The flags and collections of flags (masks) for \see struct ldlm_lock. + * @{ + */ +#ifndef LDLM_ALL_FLAGS_MASK + +/** l_flags bits marked as "all_flags" bits */ +#define LDLM_FL_ALL_FLAGS_MASK 0x007FFFFFC08F132FULL + +/** l_flags bits marked as "ast" bits */ +#define LDLM_FL_AST_MASK 0x0000000080000000ULL + +/** l_flags bits marked as "blocked" bits */ +#define LDLM_FL_BLOCKED_MASK 0x000000000000000EULL + +/** l_flags bits marked as "gone" bits */ +#define LDLM_FL_GONE_MASK 0x0006004000000000ULL + +/** l_flags bits marked as "hide_lock" bits */ +#define LDLM_FL_HIDE_LOCK_MASK 0x0000206400000000ULL + +/** l_flags bits marked as "inherit" bits */ +#define LDLM_FL_INHERIT_MASK 0x0000000000800000ULL + +/** l_flags bits marked as "local_only" bits */ +#define LDLM_FL_LOCAL_ONLY_MASK 0x007FFFFF00000000ULL + +/** l_flags bits marked as "on_wire" bits */ +#define LDLM_FL_ON_WIRE_MASK 0x00000000C08F132FULL + +/** extent, mode, or resource changed */ +#define LDLM_FL_LOCK_CHANGED 0x0000000000000001ULL // bit 0 +#define ldlm_is_lock_changed(_l) LDLM_TEST_FLAG(( _l), 1ULL << 0) +#define ldlm_set_lock_changed(_l) LDLM_SET_FLAG(( _l), 1ULL << 0) +#define ldlm_clear_lock_changed(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 0) + +/** + * Server placed lock on granted list, or a recovering client wants the + * lock added to the granted list, no questions asked. */ +#define LDLM_FL_BLOCK_GRANTED 0x0000000000000002ULL // bit 1 +#define ldlm_is_block_granted(_l) LDLM_TEST_FLAG(( _l), 1ULL << 1) +#define ldlm_set_block_granted(_l) LDLM_SET_FLAG(( _l), 1ULL << 1) +#define ldlm_clear_block_granted(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 1) + +/** + * Server placed lock on conv list, or a recovering client wants the lock + * added to the conv list, no questions asked. */ +#define LDLM_FL_BLOCK_CONV 0x0000000000000004ULL // bit 2 +#define ldlm_is_block_conv(_l) LDLM_TEST_FLAG(( _l), 1ULL << 2) +#define ldlm_set_block_conv(_l) LDLM_SET_FLAG(( _l), 1ULL << 2) +#define ldlm_clear_block_conv(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 2) + +/** + * Server placed lock on wait list, or a recovering client wants the lock + * added to the wait list, no questions asked. */ +#define LDLM_FL_BLOCK_WAIT 0x0000000000000008ULL // bit 3 +#define ldlm_is_block_wait(_l) LDLM_TEST_FLAG(( _l), 1ULL << 3) +#define ldlm_set_block_wait(_l) LDLM_SET_FLAG(( _l), 1ULL << 3) +#define ldlm_clear_block_wait(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 3) + +/** blocking or cancel packet was queued for sending. */ +#define LDLM_FL_AST_SENT 0x0000000000000020ULL // bit 5 +#define ldlm_is_ast_sent(_l) LDLM_TEST_FLAG(( _l), 1ULL << 5) +#define ldlm_set_ast_sent(_l) LDLM_SET_FLAG(( _l), 1ULL << 5) +#define ldlm_clear_ast_sent(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 5) + +/** + * Lock is being replayed. This could probably be implied by the fact that + * one of BLOCK_{GRANTED,CONV,WAIT} is set, but that is pretty dangerous. */ +#define LDLM_FL_REPLAY 0x0000000000000100ULL // bit 8 +#define ldlm_is_replay(_l) LDLM_TEST_FLAG(( _l), 1ULL << 8) +#define ldlm_set_replay(_l) LDLM_SET_FLAG(( _l), 1ULL << 8) +#define ldlm_clear_replay(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 8) + +/** Don't grant lock, just do intent. */ +#define LDLM_FL_INTENT_ONLY 0x0000000000000200ULL // bit 9 +#define ldlm_is_intent_only(_l) LDLM_TEST_FLAG(( _l), 1ULL << 9) +#define ldlm_set_intent_only(_l) LDLM_SET_FLAG(( _l), 1ULL << 9) +#define ldlm_clear_intent_only(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 9) + +/** lock request has intent */ +#define LDLM_FL_HAS_INTENT 0x0000000000001000ULL // bit 12 +#define ldlm_is_has_intent(_l) LDLM_TEST_FLAG(( _l), 1ULL << 12) +#define ldlm_set_has_intent(_l) LDLM_SET_FLAG(( _l), 1ULL << 12) +#define ldlm_clear_has_intent(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 12) + +/** discard (no writeback) on cancel */ +#define LDLM_FL_DISCARD_DATA 0x0000000000010000ULL // bit 16 +#define ldlm_is_discard_data(_l) LDLM_TEST_FLAG(( _l), 1ULL << 16) +#define ldlm_set_discard_data(_l) LDLM_SET_FLAG(( _l), 1ULL << 16) +#define ldlm_clear_discard_data(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 16) + +/** Blocked by group lock - wait indefinitely */ +#define LDLM_FL_NO_TIMEOUT 0x0000000000020000ULL // bit 17 +#define ldlm_is_no_timeout(_l) LDLM_TEST_FLAG(( _l), 1ULL << 17) +#define ldlm_set_no_timeout(_l) LDLM_SET_FLAG(( _l), 1ULL << 17) +#define ldlm_clear_no_timeout(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 17) + +/** + * Server told not to wait if blocked. For AGL, OST will not send glimpse + * callback. */ +#define LDLM_FL_BLOCK_NOWAIT 0x0000000000040000ULL // bit 18 +#define ldlm_is_block_nowait(_l) LDLM_TEST_FLAG(( _l), 1ULL << 18) +#define ldlm_set_block_nowait(_l) LDLM_SET_FLAG(( _l), 1ULL << 18) +#define ldlm_clear_block_nowait(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 18) + +/** return blocking lock */ +#define LDLM_FL_TEST_LOCK 0x0000000000080000ULL // bit 19 +#define ldlm_is_test_lock(_l) LDLM_TEST_FLAG(( _l), 1ULL << 19) +#define ldlm_set_test_lock(_l) LDLM_SET_FLAG(( _l), 1ULL << 19) +#define ldlm_clear_test_lock(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 19) + +/** + * Immediatelly cancel such locks when they block some other locks. Send + * cancel notification to original lock holder, but expect no reply. This + * is for clients (like liblustre) that cannot be expected to reliably + * response to blocking AST. */ +#define LDLM_FL_CANCEL_ON_BLOCK 0x0000000000800000ULL // bit 23 +#define ldlm_is_cancel_on_block(_l) LDLM_TEST_FLAG(( _l), 1ULL << 23) +#define ldlm_set_cancel_on_block(_l) LDLM_SET_FLAG(( _l), 1ULL << 23) +#define ldlm_clear_cancel_on_block(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 23) + +/** + * measure lock contention and return -EUSERS if locking contention is high */ +#define LDLM_FL_DENY_ON_CONTENTION 0x0000000040000000ULL // bit 30 +#define ldlm_is_deny_on_contention(_l) LDLM_TEST_FLAG(( _l), 1ULL << 30) +#define ldlm_set_deny_on_contention(_l) LDLM_SET_FLAG(( _l), 1ULL << 30) +#define ldlm_clear_deny_on_contention(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 30) + +/** + * These are flags that are mapped into the flags and ASTs of blocking + * locks Add FL_DISCARD to blocking ASTs */ +#define LDLM_FL_AST_DISCARD_DATA 0x0000000080000000ULL // bit 31 +#define ldlm_is_ast_discard_data(_l) LDLM_TEST_FLAG(( _l), 1ULL << 31) +#define ldlm_set_ast_discard_data(_l) LDLM_SET_FLAG(( _l), 1ULL << 31) +#define ldlm_clear_ast_discard_data(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 31) + +/** + * Used for marking lock as a target for -EINTR while cp_ast sleep emulation + * + race with upcoming bl_ast. */ +#define LDLM_FL_FAIL_LOC 0x0000000100000000ULL // bit 32 +#define ldlm_is_fail_loc(_l) LDLM_TEST_FLAG(( _l), 1ULL << 32) +#define ldlm_set_fail_loc(_l) LDLM_SET_FLAG(( _l), 1ULL << 32) +#define ldlm_clear_fail_loc(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 32) + +/** + * Used while processing the unused list to know that we have already + * handled this lock and decided to skip it. */ +#define LDLM_FL_SKIPPED 0x0000000200000000ULL // bit 33 +#define ldlm_is_skipped(_l) LDLM_TEST_FLAG(( _l), 1ULL << 33) +#define ldlm_set_skipped(_l) LDLM_SET_FLAG(( _l), 1ULL << 33) +#define ldlm_clear_skipped(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 33) + +/** this lock is being destroyed */ +#define LDLM_FL_CBPENDING 0x0000000400000000ULL // bit 34 +#define ldlm_is_cbpending(_l) LDLM_TEST_FLAG(( _l), 1ULL << 34) +#define ldlm_set_cbpending(_l) LDLM_SET_FLAG(( _l), 1ULL << 34) +#define ldlm_clear_cbpending(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 34) + +/** not a real flag, not saved in lock */ +#define LDLM_FL_WAIT_NOREPROC 0x0000000800000000ULL // bit 35 +#define ldlm_is_wait_noreproc(_l) LDLM_TEST_FLAG(( _l), 1ULL << 35) +#define ldlm_set_wait_noreproc(_l) LDLM_SET_FLAG(( _l), 1ULL << 35) +#define ldlm_clear_wait_noreproc(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 35) + +/** cancellation callback already run */ +#define LDLM_FL_CANCEL 0x0000001000000000ULL // bit 36 +#define ldlm_is_cancel(_l) LDLM_TEST_FLAG(( _l), 1ULL << 36) +#define ldlm_set_cancel(_l) LDLM_SET_FLAG(( _l), 1ULL << 36) +#define ldlm_clear_cancel(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 36) + +/** whatever it might mean */ +#define LDLM_FL_LOCAL_ONLY 0x0000002000000000ULL // bit 37 +#define ldlm_is_local_only(_l) LDLM_TEST_FLAG(( _l), 1ULL << 37) +#define ldlm_set_local_only(_l) LDLM_SET_FLAG(( _l), 1ULL << 37) +#define ldlm_clear_local_only(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 37) + +/** don't run the cancel callback under ldlm_cli_cancel_unused */ +#define LDLM_FL_FAILED 0x0000004000000000ULL // bit 38 +#define ldlm_is_failed(_l) LDLM_TEST_FLAG(( _l), 1ULL << 38) +#define ldlm_set_failed(_l) LDLM_SET_FLAG(( _l), 1ULL << 38) +#define ldlm_clear_failed(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 38) + +/** lock cancel has already been sent */ +#define LDLM_FL_CANCELING 0x0000008000000000ULL // bit 39 +#define ldlm_is_canceling(_l) LDLM_TEST_FLAG(( _l), 1ULL << 39) +#define ldlm_set_canceling(_l) LDLM_SET_FLAG(( _l), 1ULL << 39) +#define ldlm_clear_canceling(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 39) + +/** local lock (ie, no srv/cli split) */ +#define LDLM_FL_LOCAL 0x0000010000000000ULL // bit 40 +#define ldlm_is_local(_l) LDLM_TEST_FLAG(( _l), 1ULL << 40) +#define ldlm_set_local(_l) LDLM_SET_FLAG(( _l), 1ULL << 40) +#define ldlm_clear_local(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 40) + +/** + * XXX FIXME: This is being added to b_size as a low-risk fix to the + * fact that the LVB filling happens _after_ the lock has been granted, + * so another thread can match it before the LVB has been updated. As a + * dirty hack, we set LDLM_FL_LVB_READY only after we've done the LVB poop. + * this is only needed on LOV/OSC now, where LVB is actually used and + * callers must set it in input flags. + * + * The proper fix is to do the granting inside of the completion AST, + * which can be replaced with a LVB-aware wrapping function for OSC locks. + * That change is pretty high-risk, though, and would need a lot more + * testing. */ +#define LDLM_FL_LVB_READY 0x0000020000000000ULL // bit 41 +#define ldlm_is_lvb_ready(_l) LDLM_TEST_FLAG(( _l), 1ULL << 41) +#define ldlm_set_lvb_ready(_l) LDLM_SET_FLAG(( _l), 1ULL << 41) +#define ldlm_clear_lvb_ready(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 41) + +/** + * A lock contributes to the known minimum size (KMS) calculation until it + * has finished the part of its cancelation that performs write back on its + * dirty pages. It can remain on the granted list during this whole time. + * Threads racing to update the KMS after performing their writeback need + * to know to exclude each other's locks from the calculation as they walk + * the granted list. */ +#define LDLM_FL_KMS_IGNORE 0x0000040000000000ULL // bit 42 +#define ldlm_is_kms_ignore(_l) LDLM_TEST_FLAG(( _l), 1ULL << 42) +#define ldlm_set_kms_ignore(_l) LDLM_SET_FLAG(( _l), 1ULL << 42) +#define ldlm_clear_kms_ignore(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 42) + +/** completion AST to be executed */ +#define LDLM_FL_CP_REQD 0x0000080000000000ULL // bit 43 +#define ldlm_is_cp_reqd(_l) LDLM_TEST_FLAG(( _l), 1ULL << 43) +#define ldlm_set_cp_reqd(_l) LDLM_SET_FLAG(( _l), 1ULL << 43) +#define ldlm_clear_cp_reqd(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 43) + +/** cleanup_resource has already handled the lock */ +#define LDLM_FL_CLEANED 0x0000100000000000ULL // bit 44 +#define ldlm_is_cleaned(_l) LDLM_TEST_FLAG(( _l), 1ULL << 44) +#define ldlm_set_cleaned(_l) LDLM_SET_FLAG(( _l), 1ULL << 44) +#define ldlm_clear_cleaned(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 44) + +/** + * optimization hint: LDLM can run blocking callback from current context + * w/o involving separate thread. in order to decrease cs rate */ +#define LDLM_FL_ATOMIC_CB 0x0000200000000000ULL // bit 45 +#define ldlm_is_atomic_cb(_l) LDLM_TEST_FLAG(( _l), 1ULL << 45) +#define ldlm_set_atomic_cb(_l) LDLM_SET_FLAG(( _l), 1ULL << 45) +#define ldlm_clear_atomic_cb(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 45) + +/** + * It may happen that a client initiates two operations, e.g. unlink and + * mkdir, such that the server sends a blocking AST for conflicting locks + * to this client for the first operation, whereas the second operation + * has canceled this lock and is waiting for rpc_lock which is taken by + * the first operation. LDLM_FL_BL_AST is set by ldlm_callback_handler() in + * the lock to prevent the Early Lock Cancel (ELC) code from cancelling it. + * + * LDLM_FL_BL_DONE is to be set by ldlm_cancel_callback() when lock cache is + * dropped to let ldlm_callback_handler() return EINVAL to the server. It + * is used when ELC RPC is already prepared and is waiting for rpc_lock, + * too late to send a separate CANCEL RPC. */ +#define LDLM_FL_BL_AST 0x0000400000000000ULL // bit 46 +#define ldlm_is_bl_ast(_l) LDLM_TEST_FLAG(( _l), 1ULL << 46) +#define ldlm_set_bl_ast(_l) LDLM_SET_FLAG(( _l), 1ULL << 46) +#define ldlm_clear_bl_ast(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 46) + +/** whatever it might mean */ +#define LDLM_FL_BL_DONE 0x0000800000000000ULL // bit 47 +#define ldlm_is_bl_done(_l) LDLM_TEST_FLAG(( _l), 1ULL << 47) +#define ldlm_set_bl_done(_l) LDLM_SET_FLAG(( _l), 1ULL << 47) +#define ldlm_clear_bl_done(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 47) + +/** + * Don't put lock into the LRU list, so that it is not canceled due + * to aging. Used by MGC locks, they are cancelled only at unmount or + * by callback. */ +#define LDLM_FL_NO_LRU 0x0001000000000000ULL // bit 48 +#define ldlm_is_no_lru(_l) LDLM_TEST_FLAG(( _l), 1ULL << 48) +#define ldlm_set_no_lru(_l) LDLM_SET_FLAG(( _l), 1ULL << 48) +#define ldlm_clear_no_lru(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 48) + +/** + * Set for locks that failed and where the server has been notified. + * + * Protected by lock and resource locks. */ +#define LDLM_FL_FAIL_NOTIFIED 0x0002000000000000ULL // bit 49 +#define ldlm_is_fail_notified(_l) LDLM_TEST_FLAG(( _l), 1ULL << 49) +#define ldlm_set_fail_notified(_l) LDLM_SET_FLAG(( _l), 1ULL << 49) +#define ldlm_clear_fail_notified(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 49) + +/** + * Set for locks that were removed from class hash table and will + * be destroyed when last reference to them is released. Set by + * ldlm_lock_destroy_internal(). + * + * Protected by lock and resource locks. */ +#define LDLM_FL_DESTROYED 0x0004000000000000ULL // bit 50 +#define ldlm_is_destroyed(_l) LDLM_TEST_FLAG(( _l), 1ULL << 50) +#define ldlm_set_destroyed(_l) LDLM_SET_FLAG(( _l), 1ULL << 50) +#define ldlm_clear_destroyed(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 50) + +/** flag whether this is a server namespace lock */ +#define LDLM_FL_SERVER_LOCK 0x0008000000000000ULL // bit 51 +#define ldlm_is_server_lock(_l) LDLM_TEST_FLAG(( _l), 1ULL << 51) +#define ldlm_set_server_lock(_l) LDLM_SET_FLAG(( _l), 1ULL << 51) +#define ldlm_clear_server_lock(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 51) + +/** + * It's set in lock_res_and_lock() and unset in unlock_res_and_lock(). + * + * NB: compared with check_res_locked(), checking this bit is cheaper. + * Also, spin_is_locked() is deprecated for kernel code; one reason is + * because it works only for SMP so user needs to add extra macros like + * LASSERT_SPIN_LOCKED for uniprocessor kernels. */ +#define LDLM_FL_RES_LOCKED 0x0010000000000000ULL // bit 52 +#define ldlm_is_res_locked(_l) LDLM_TEST_FLAG(( _l), 1ULL << 52) +#define ldlm_set_res_locked(_l) LDLM_SET_FLAG(( _l), 1ULL << 52) +#define ldlm_clear_res_locked(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 52) + +/** + * It's set once we call ldlm_add_waiting_lock_res_locked() to start the + * lock-timeout timer and it will never be reset. + * + * Protected by lock and resource locks. */ +#define LDLM_FL_WAITED 0x0020000000000000ULL // bit 53 +#define ldlm_is_waited(_l) LDLM_TEST_FLAG(( _l), 1ULL << 53) +#define ldlm_set_waited(_l) LDLM_SET_FLAG(( _l), 1ULL << 53) +#define ldlm_clear_waited(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 53) + +/** Flag whether this is a server namespace lock. */ +#define LDLM_FL_NS_SRV 0x0040000000000000ULL // bit 54 +#define ldlm_is_ns_srv(_l) LDLM_TEST_FLAG(( _l), 1ULL << 54) +#define ldlm_set_ns_srv(_l) LDLM_SET_FLAG(( _l), 1ULL << 54) +#define ldlm_clear_ns_srv(_l) LDLM_CLEAR_FLAG((_l), 1ULL << 54) + +/** test for ldlm_lock flag bit set */ +#define LDLM_TEST_FLAG(_l, _b) (((_l)->l_flags & (_b)) != 0) + +/** set a ldlm_lock flag bit */ +#define LDLM_SET_FLAG(_l, _b) (((_l)->l_flags |= (_b)) + +/** clear a ldlm_lock flag bit */ +#define LDLM_CLEAR_FLAG(_l, _b) (((_l)->l_flags &= ~(_b)) + +/** Mask of flags inherited from parent lock when doing intents. */ +#define LDLM_INHERIT_FLAGS LDLM_FL_INHERIT_MASK + +/** Mask of Flags sent in AST lock_flags to map into the receiving lock. */ +#define LDLM_AST_FLAGS LDLM_FL_AST_MASK + +/** @} subgroup */ +/** @} group */ +#ifdef WIRESHARK_COMPILE +static int hf_lustre_ldlm_fl_lock_changed = -1; +static int hf_lustre_ldlm_fl_block_granted = -1; +static int hf_lustre_ldlm_fl_block_conv = -1; +static int hf_lustre_ldlm_fl_block_wait = -1; +static int hf_lustre_ldlm_fl_ast_sent = -1; +static int hf_lustre_ldlm_fl_replay = -1; +static int hf_lustre_ldlm_fl_intent_only = -1; +static int hf_lustre_ldlm_fl_has_intent = -1; +static int hf_lustre_ldlm_fl_discard_data = -1; +static int hf_lustre_ldlm_fl_no_timeout = -1; +static int hf_lustre_ldlm_fl_block_nowait = -1; +static int hf_lustre_ldlm_fl_test_lock = -1; +static int hf_lustre_ldlm_fl_cancel_on_block = -1; +static int hf_lustre_ldlm_fl_deny_on_contention = -1; +static int hf_lustre_ldlm_fl_ast_discard_data = -1; +static int hf_lustre_ldlm_fl_fail_loc = -1; +static int hf_lustre_ldlm_fl_skipped = -1; +static int hf_lustre_ldlm_fl_cbpending = -1; +static int hf_lustre_ldlm_fl_wait_noreproc = -1; +static int hf_lustre_ldlm_fl_cancel = -1; +static int hf_lustre_ldlm_fl_local_only = -1; +static int hf_lustre_ldlm_fl_failed = -1; +static int hf_lustre_ldlm_fl_canceling = -1; +static int hf_lustre_ldlm_fl_local = -1; +static int hf_lustre_ldlm_fl_lvb_ready = -1; +static int hf_lustre_ldlm_fl_kms_ignore = -1; +static int hf_lustre_ldlm_fl_cp_reqd = -1; +static int hf_lustre_ldlm_fl_cleaned = -1; +static int hf_lustre_ldlm_fl_atomic_cb = -1; +static int hf_lustre_ldlm_fl_bl_ast = -1; +static int hf_lustre_ldlm_fl_bl_done = -1; +static int hf_lustre_ldlm_fl_no_lru = -1; +static int hf_lustre_ldlm_fl_fail_notified = -1; +static int hf_lustre_ldlm_fl_destroyed = -1; +static int hf_lustre_ldlm_fl_server_lock = -1; +static int hf_lustre_ldlm_fl_res_locked = -1; +static int hf_lustre_ldlm_fl_waited = -1; +static int hf_lustre_ldlm_fl_ns_srv = -1; + +const value_string lustre_ldlm_flags_vals[] = { + {LDLM_FL_LOCK_CHANGED, "LDLM_FL_LOCK_CHANGED"}, + {LDLM_FL_BLOCK_GRANTED, "LDLM_FL_BLOCK_GRANTED"}, + {LDLM_FL_BLOCK_CONV, "LDLM_FL_BLOCK_CONV"}, + {LDLM_FL_BLOCK_WAIT, "LDLM_FL_BLOCK_WAIT"}, + {LDLM_FL_AST_SENT, "LDLM_FL_AST_SENT"}, + {LDLM_FL_REPLAY, "LDLM_FL_REPLAY"}, + {LDLM_FL_INTENT_ONLY, "LDLM_FL_INTENT_ONLY"}, + {LDLM_FL_HAS_INTENT, "LDLM_FL_HAS_INTENT"}, + {LDLM_FL_DISCARD_DATA, "LDLM_FL_DISCARD_DATA"}, + {LDLM_FL_NO_TIMEOUT, "LDLM_FL_NO_TIMEOUT"}, + {LDLM_FL_BLOCK_NOWAIT, "LDLM_FL_BLOCK_NOWAIT"}, + {LDLM_FL_TEST_LOCK, "LDLM_FL_TEST_LOCK"}, + {LDLM_FL_CANCEL_ON_BLOCK, "LDLM_FL_CANCEL_ON_BLOCK"}, + {LDLM_FL_DENY_ON_CONTENTION, "LDLM_FL_DENY_ON_CONTENTION"}, + {LDLM_FL_AST_DISCARD_DATA, "LDLM_FL_AST_DISCARD_DATA"}, + {LDLM_FL_FAIL_LOC, "LDLM_FL_FAIL_LOC"}, + {LDLM_FL_SKIPPED, "LDLM_FL_SKIPPED"}, + {LDLM_FL_CBPENDING, "LDLM_FL_CBPENDING"}, + {LDLM_FL_WAIT_NOREPROC, "LDLM_FL_WAIT_NOREPROC"}, + {LDLM_FL_CANCEL, "LDLM_FL_CANCEL"}, + {LDLM_FL_LOCAL_ONLY, "LDLM_FL_LOCAL_ONLY"}, + {LDLM_FL_FAILED, "LDLM_FL_FAILED"}, + {LDLM_FL_CANCELING, "LDLM_FL_CANCELING"}, + {LDLM_FL_LOCAL, "LDLM_FL_LOCAL"}, + {LDLM_FL_LVB_READY, "LDLM_FL_LVB_READY"}, + {LDLM_FL_KMS_IGNORE, "LDLM_FL_KMS_IGNORE"}, + {LDLM_FL_CP_REQD, "LDLM_FL_CP_REQD"}, + {LDLM_FL_CLEANED, "LDLM_FL_CLEANED"}, + {LDLM_FL_ATOMIC_CB, "LDLM_FL_ATOMIC_CB"}, + {LDLM_FL_BL_AST, "LDLM_FL_BL_AST"}, + {LDLM_FL_BL_DONE, "LDLM_FL_BL_DONE"}, + {LDLM_FL_NO_LRU, "LDLM_FL_NO_LRU"}, + {LDLM_FL_FAIL_NOTIFIED, "LDLM_FL_FAIL_NOTIFIED"}, + {LDLM_FL_DESTROYED, "LDLM_FL_DESTROYED"}, + {LDLM_FL_SERVER_LOCK, "LDLM_FL_SERVER_LOCK"}, + {LDLM_FL_RES_LOCKED, "LDLM_FL_RES_LOCKED"}, + {LDLM_FL_WAITED, "LDLM_FL_WAITED"}, + {LDLM_FL_NS_SRV, "LDLM_FL_NS_SRV"}, + { 0, NULL } +}; +#endif /* WIRESHARK_COMPILE */ +#endif /* LDLM_ALL_FLAGS_MASK */ diff --git a/drivers/staging/lustre/lustre/ldlm/l_lock.c b/drivers/staging/lustre/lustre/ldlm/l_lock.c index 853409aa945d9..32f4d52b5362a 100644 --- a/drivers/staging/lustre/lustre/ldlm/l_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/l_lock.c @@ -51,12 +51,12 @@ struct ldlm_resource *lock_res_and_lock(struct ldlm_lock *lock) { /* on server-side resource of lock doesn't change */ - if (!lock->l_ns_srv) + if ((lock->l_flags & LDLM_FL_NS_SRV) == 0) spin_lock(&lock->l_lock); lock_res(lock->l_resource); - lock->l_res_locked = 1; + lock->l_flags |= LDLM_FL_RES_LOCKED; return lock->l_resource; } EXPORT_SYMBOL(lock_res_and_lock); @@ -67,10 +67,10 @@ EXPORT_SYMBOL(lock_res_and_lock); void unlock_res_and_lock(struct ldlm_lock *lock) { /* on server-side resource of lock doesn't change */ - lock->l_res_locked = 0; + lock->l_flags &= ~LDLM_FL_RES_LOCKED; unlock_res(lock->l_resource); - if (!lock->l_ns_srv) + if ((lock->l_flags & LDLM_FL_NS_SRV) == 0) spin_unlock(&lock->l_lock); } EXPORT_SYMBOL(unlock_res_and_lock); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c index f100a84bde737..aca1073d18b52 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c @@ -639,7 +639,7 @@ ldlm_flock_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data) granted: OBD_FAIL_TIMEOUT(OBD_FAIL_LDLM_CP_CB_WAIT, 10); - if (lock->l_destroyed) { + if (lock->l_flags & LDLM_FL_DESTROYED) { LDLM_DEBUG(lock, "client-side enqueue waking up: destroyed"); RETURN(0); } diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index 0b3ea88ae5b07..c10ba9c33f42a 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -199,7 +199,7 @@ void ldlm_lock_put(struct ldlm_lock *lock) "final lock_put on destroyed lock, freeing it."); res = lock->l_resource; - LASSERT(lock->l_destroyed); + LASSERT(lock->l_flags & LDLM_FL_DESTROYED); LASSERT(list_empty(&lock->l_res_link)); LASSERT(list_empty(&lock->l_pending_chain)); @@ -254,7 +254,7 @@ int ldlm_lock_remove_from_lru(struct ldlm_lock *lock) int rc; ENTRY; - if (lock->l_ns_srv) { + if (lock->l_flags & LDLM_FL_NS_SRV) { LASSERT(list_empty(&lock->l_lru)); RETURN(0); } @@ -305,7 +305,7 @@ void ldlm_lock_touch_in_lru(struct ldlm_lock *lock) struct ldlm_namespace *ns = ldlm_lock_to_ns(lock); ENTRY; - if (lock->l_ns_srv) { + if (lock->l_flags & LDLM_FL_NS_SRV) { LASSERT(list_empty(&lock->l_lru)); EXIT; return; @@ -353,12 +353,12 @@ int ldlm_lock_destroy_internal(struct ldlm_lock *lock) LBUG(); } - if (lock->l_destroyed) { + if (lock->l_flags & LDLM_FL_DESTROYED) { LASSERT(list_empty(&lock->l_lru)); EXIT; return 0; } - lock->l_destroyed = 1; + lock->l_flags |= LDLM_FL_DESTROYED; if (lock->l_export && lock->l_export->exp_lock_hash) { /* NB: it's safe to call cfs_hash_del() even lock isn't @@ -596,7 +596,7 @@ struct ldlm_lock *__ldlm_handle2lock(const struct lustre_handle *handle, /* It's unlikely but possible that someone marked the lock as * destroyed after we did handle2object on it */ - if (flags == 0 && !lock->l_destroyed) { + if (flags == 0 && ((lock->l_flags & LDLM_FL_DESTROYED)== 0)) { lu_ref_add(&lock->l_reference, "handle", current); RETURN(lock); } @@ -606,7 +606,7 @@ struct ldlm_lock *__ldlm_handle2lock(const struct lustre_handle *handle, LASSERT(lock->l_resource != NULL); lu_ref_add_atomic(&lock->l_reference, "handle", current); - if (unlikely(lock->l_destroyed)) { + if (unlikely(lock->l_flags & LDLM_FL_DESTROYED)) { unlock_res_and_lock(lock); CDEBUG(D_INFO, "lock already destroyed: lock %p\n", lock); LDLM_LOCK_PUT(lock); @@ -695,7 +695,7 @@ void ldlm_add_bl_work_item(struct ldlm_lock *lock, struct ldlm_lock *new, lock->l_flags |= LDLM_FL_AST_SENT; /* If the enqueuing client said so, tell the AST recipient to * discard dirty data, rather than writing back. */ - if (new->l_flags & LDLM_AST_DISCARD_DATA) + if (new->l_flags & LDLM_FL_AST_DISCARD_DATA) lock->l_flags |= LDLM_FL_DISCARD_DATA; LASSERT(list_empty(&lock->l_bl_ast)); list_add(&lock->l_bl_ast, work_list); @@ -873,7 +873,7 @@ void ldlm_lock_decref_internal(struct ldlm_lock *lock, __u32 mode) (lock->l_flags & LDLM_FL_CBPENDING)) { /* If we received a blocked AST and this was the last reference, * run the callback. */ - if (lock->l_ns_srv && lock->l_export) + if ((lock->l_flags & LDLM_FL_NS_SRV) && lock->l_export) CERROR("FL_CBPENDING set on non-local lock--just a " "warning\n"); @@ -1069,7 +1069,7 @@ static void ldlm_granted_list_add_lock(struct ldlm_lock *lock, ldlm_resource_dump(D_INFO, res); LDLM_DEBUG(lock, "About to add lock:"); - if (lock->l_destroyed) { + if (lock->l_flags & LDLM_FL_DESTROYED) { CDEBUG(D_OTHER, "Lock destroyed, not adding to resource\n"); return; } @@ -1203,9 +1203,7 @@ static struct ldlm_lock *search_queue(struct list_head *queue, policy->l_inodebits.bits)) continue; - if (!unref && - (lock->l_destroyed || lock->l_flags & LDLM_FL_FAILED || - lock->l_failed)) + if (!unref && (lock->l_flags & LDLM_FL_GONE_MASK)) continue; if ((flags & LDLM_FL_LOCAL_ONLY) && @@ -1227,8 +1225,8 @@ static struct ldlm_lock *search_queue(struct list_head *queue, void ldlm_lock_fail_match_locked(struct ldlm_lock *lock) { - if (!lock->l_failed) { - lock->l_failed = 1; + if ((lock->l_flags & LDLM_FL_FAIL_NOTIFIED) == 0) { + lock->l_flags |= LDLM_FL_FAIL_NOTIFIED; wake_up_all(&lock->l_waitq); } } @@ -1352,6 +1350,8 @@ ldlm_mode_t ldlm_lock_match(struct ldlm_namespace *ns, __u64 flags, ldlm_lock2handle(lock, lockh); if ((flags & LDLM_FL_LVB_READY) && (!(lock->l_flags & LDLM_FL_LVB_READY))) { + __u64 wait_flags = LDLM_FL_LVB_READY | + LDLM_FL_DESTROYED | LDLM_FL_FAIL_NOTIFIED; struct l_wait_info lwi; if (lock->l_completion_ast) { int err = lock->l_completion_ast(lock, @@ -1373,8 +1373,7 @@ ldlm_mode_t ldlm_lock_match(struct ldlm_namespace *ns, __u64 flags, /* XXX FIXME see comment on CAN_MATCH in lustre_dlm.h */ l_wait_event(lock->l_waitq, - lock->l_flags & LDLM_FL_LVB_READY || - lock->l_destroyed || lock->l_failed, + lock->l_flags & wait_flags, &lwi); if (!(lock->l_flags & LDLM_FL_LVB_READY)) { if (flags & LDLM_FL_TEST_LOCK) @@ -1431,8 +1430,7 @@ ldlm_mode_t ldlm_revalidate_lock_handle(struct lustre_handle *lockh, lock = ldlm_handle2lock(lockh); if (lock != NULL) { lock_res_and_lock(lock); - if (lock->l_destroyed || lock->l_flags & LDLM_FL_FAILED || - lock->l_failed) + if (lock->l_flags & LDLM_FL_GONE_MASK) GOTO(out, mode); if (lock->l_flags & LDLM_FL_CBPENDING && @@ -1583,12 +1581,12 @@ struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace *ns, lock->l_req_mode = mode; lock->l_ast_data = data; lock->l_pid = current_pid(); - lock->l_ns_srv = !!ns_is_server(ns); + if (ns_is_server(ns)) + lock->l_flags |= LDLM_FL_NS_SRV; if (cbs) { lock->l_blocking_ast = cbs->lcs_blocking; lock->l_completion_ast = cbs->lcs_completion; lock->l_glimpse_ast = cbs->lcs_glimpse; - lock->l_weigh_ast = cbs->lcs_weigh; } lock->l_tree_node = NULL; @@ -1693,7 +1691,7 @@ ldlm_error_t ldlm_lock_enqueue(struct ldlm_namespace *ns, /* Some flags from the enqueue want to make it into the AST, via the * lock's l_flags. */ - lock->l_flags |= *flags & LDLM_AST_DISCARD_DATA; + lock->l_flags |= *flags & LDLM_FL_AST_DISCARD_DATA; /* This distinction between local lock trees is very important; a client * namespace only has information about locks taken by that client, and @@ -2046,15 +2044,15 @@ void ldlm_lock_cancel(struct ldlm_lock *lock) LBUG(); } - if (lock->l_waited) + if (lock->l_flags & LDLM_FL_WAITED) ldlm_del_waiting_lock(lock); /* Releases cancel callback. */ ldlm_cancel_callback(lock); /* Yes, second time, just in case it was added again while we were - running with no res lock in ldlm_cancel_callback */ - if (lock->l_waited) + * running with no res lock in ldlm_cancel_callback */ + if (lock->l_flags & LDLM_FL_WAITED) ldlm_del_waiting_lock(lock); ldlm_resource_unlink_lock(lock); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c index f79b244d1a68f..d18936a059d87 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c @@ -198,7 +198,7 @@ static void ldlm_handle_cp_callback(struct ptlrpc_request *req, schedule_timeout_and_set_state( TASK_INTERRUPTIBLE, to); if (lock->l_granted_mode == lock->l_req_mode || - lock->l_destroyed) + lock->l_flags & LDLM_FL_DESTROYED) break; } } @@ -238,7 +238,7 @@ static void ldlm_handle_cp_callback(struct ptlrpc_request *req, } lock_res_and_lock(lock); - if (lock->l_destroyed || + if ((lock->l_flags & LDLM_FL_DESTROYED) || lock->l_granted_mode == lock->l_req_mode) { /* bug 11300: the lock has already been granted */ unlock_res_and_lock(lock); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c index ab41fea4aa07a..c900706a9c8d3 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c @@ -160,7 +160,7 @@ static int ldlm_completion_tail(struct ldlm_lock *lock) long delay; int result; - if (lock->l_destroyed || lock->l_flags & LDLM_FL_FAILED) { + if (lock->l_flags & (LDLM_FL_DESTROYED | LDLM_FL_FAILED)) { LDLM_DEBUG(lock, "client-side enqueue: destroyed"); result = -EIO; } else { @@ -888,9 +888,8 @@ int ldlm_cli_enqueue(struct obd_export *exp, struct ptlrpc_request **reqp, } else { const struct ldlm_callback_suite cbs = { .lcs_completion = einfo->ei_cb_cp, - .lcs_blocking = einfo->ei_cb_bl, - .lcs_glimpse = einfo->ei_cb_gl, - .lcs_weigh = einfo->ei_cb_wg + .lcs_blocking = einfo->ei_cb_bl, + .lcs_glimpse = einfo->ei_cb_gl }; lock = ldlm_lock_create(ns, res_id, einfo->ei_type, einfo->ei_mode, &cbs, einfo->ei_cbdata, diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index 17eab79ba8394..616cb17efc303 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -1283,7 +1283,7 @@ void ldlm_resource_add_lock(struct ldlm_resource *res, struct list_head *head, LDLM_DEBUG(lock, "About to add this lock:\n"); - if (lock->l_destroyed) { + if (lock->l_flags & LDLM_FL_DESTROYED) { CDEBUG(D_OTHER, "Lock destroyed, not adding to resource\n"); return; } @@ -1308,7 +1308,7 @@ void ldlm_resource_insert_lock_after(struct ldlm_lock *original, ldlm_resource_dump(D_INFO, res); LDLM_DEBUG(new, "About to insert this lock after %p:\n", original); - if (new->l_destroyed) { + if (new->l_flags & LDLM_FL_DESTROYED) { CDEBUG(D_OTHER, "Lock destroyed, not adding to resource\n"); goto out; } diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index bfc914e4be087..a94e463f04984 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -356,15 +356,12 @@ struct page *ll_get_dir_page(struct inode *dir, __u64 hash, rc = md_lock_match(ll_i2sbi(dir)->ll_md_exp, LDLM_FL_BLOCK_GRANTED, ll_inode2fid(dir), LDLM_IBITS, &policy, mode, &lockh); if (!rc) { - struct ldlm_enqueue_info einfo = {.ei_type = LDLM_IBITS, - .ei_mode = mode, - .ei_cb_bl = - ll_md_blocking_ast, - .ei_cb_cp = - ldlm_completion_ast, - .ei_cb_gl = NULL, - .ei_cb_wg = NULL, - .ei_cbdata = NULL}; + struct ldlm_enqueue_info einfo = { + .ei_type = LDLM_IBITS, + .ei_mode = mode, + .ei_cb_bl = ll_md_blocking_ast, + .ei_cb_cp = ldlm_completion_ast, + }; struct lookup_intent it = { .it_op = IT_READDIR }; struct ptlrpc_request *request; struct md_op_data *op_data; diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 50ef6a587dc3e..d51f1eee36e2f 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -2290,9 +2290,11 @@ int ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock) { struct inode *inode = file->f_dentry->d_inode; struct ll_sb_info *sbi = ll_i2sbi(inode); - struct ldlm_enqueue_info einfo = { .ei_type = LDLM_FLOCK, - .ei_cb_cp =ldlm_flock_completion_ast, - .ei_cbdata = file_lock }; + struct ldlm_enqueue_info einfo = { + .ei_type = LDLM_FLOCK, + .ei_cb_cp = ldlm_flock_completion_ast, + .ei_cbdata = file_lock, + }; struct md_op_data *op_data; struct lustre_handle lockh = {0}; ldlm_policy_data_t flock = {{0}}; @@ -3116,11 +3118,12 @@ int ll_layout_refresh(struct inode *inode, __u32 *gen) struct lookup_intent it; struct lustre_handle lockh; ldlm_mode_t mode; - struct ldlm_enqueue_info einfo = { .ei_type = LDLM_IBITS, - .ei_mode = LCK_CR, - .ei_cb_bl = ll_md_blocking_ast, - .ei_cb_cp = ldlm_completion_ast, - .ei_cbdata = NULL }; + struct ldlm_enqueue_info einfo = { + .ei_type = LDLM_IBITS, + .ei_mode = LCK_CR, + .ei_cb_bl = ll_md_blocking_ast, + .ei_cb_cp = ldlm_completion_ast, + }; int rc; ENTRY; diff --git a/drivers/staging/lustre/lustre/mdc/mdc_locks.c b/drivers/staging/lustre/lustre/mdc/mdc_locks.c index 9532134e16c67..ab88a46c1a275 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_locks.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_locks.c @@ -1102,9 +1102,12 @@ int mdc_intent_lock(struct obd_export *exp, struct md_op_data *op_data, * this and use the request from revalidate. In this case, revalidate * never dropped its reference, so the refcounts are all OK */ if (!it_disposition(it, DISP_ENQ_COMPLETE)) { - struct ldlm_enqueue_info einfo = - { LDLM_IBITS, it_to_lock_mode(it), cb_blocking, - ldlm_completion_ast, NULL, NULL, NULL }; + struct ldlm_enqueue_info einfo = { + .ei_type = LDLM_IBITS, + .ei_mode = it_to_lock_mode(it), + .ei_cb_bl = cb_blocking, + .ei_cb_cp = ldlm_completion_ast, + }; /* For case if upper layer did not alloc fid, do it now. */ if (!fid_is_sane(&op_data->op_fid2) && it->it_op & IT_CREAT) { diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c index c6c84d97ce4e6..51677678fc754 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c @@ -900,8 +900,12 @@ static int mgc_enqueue(struct obd_export *exp, struct lov_stripe_md *lsm, struct lustre_handle *lockh) { struct config_llog_data *cld = (struct config_llog_data *)data; - struct ldlm_enqueue_info einfo = { type, mode, mgc_blocking_ast, - ldlm_completion_ast, NULL, NULL, NULL }; + struct ldlm_enqueue_info einfo = { + .ei_type = type, + .ei_mode = mode, + .ei_cb_bl = mgc_blocking_ast, + .ei_cb_cp = ldlm_completion_ast, + }; struct ptlrpc_request *req; int short_limit = cld_is_sptlrpc(cld); int rc; diff --git a/drivers/staging/lustre/lustre/osc/osc_lock.c b/drivers/staging/lustre/lustre/osc/osc_lock.c index 640bc3d347093..98478d24f9be2 100644 --- a/drivers/staging/lustre/lustre/osc/osc_lock.c +++ b/drivers/staging/lustre/lustre/osc/osc_lock.c @@ -89,35 +89,49 @@ static struct ldlm_lock *osc_handle_ptr(struct lustre_handle *handle) */ static int osc_lock_invariant(struct osc_lock *ols) { - struct ldlm_lock *lock = osc_handle_ptr(&ols->ols_handle); - struct ldlm_lock *olock = ols->ols_lock; - int handle_used = lustre_handle_is_used(&ols->ols_handle); - - return - ergo(osc_lock_is_lockless(ols), - ols->ols_locklessable && ols->ols_lock == NULL) || - (ergo(olock != NULL, handle_used) && - ergo(olock != NULL, - olock->l_handle.h_cookie == ols->ols_handle.cookie) && - /* - * Check that ->ols_handle and ->ols_lock are consistent, but - * take into account that they are set at the different time. - */ - ergo(handle_used, - ergo(lock != NULL && olock != NULL, lock == olock) && - ergo(lock == NULL, olock == NULL)) && - ergo(ols->ols_state == OLS_CANCELLED, - olock == NULL && !handle_used) && - /* - * DLM lock is destroyed only after we have seen cancellation - * ast. - */ - ergo(olock != NULL && ols->ols_state < OLS_CANCELLED, - !olock->l_destroyed) && - ergo(ols->ols_state == OLS_GRANTED, - olock != NULL && - olock->l_req_mode == olock->l_granted_mode && - ols->ols_hold)); + struct ldlm_lock *lock = osc_handle_ptr(&ols->ols_handle); + struct ldlm_lock *olock = ols->ols_lock; + int handle_used = lustre_handle_is_used(&ols->ols_handle); + + if (ergo(osc_lock_is_lockless(ols), + ols->ols_locklessable && ols->ols_lock == NULL)) + return 1; + + /* + * If all the following "ergo"s are true, return 1, otherwise 0 + */ + if (! ergo(olock != NULL, handle_used)) + return 0; + + if (! ergo(olock != NULL, + olock->l_handle.h_cookie == ols->ols_handle.cookie)) + return 0; + + if (! ergo(handle_used, + ergo(lock != NULL && olock != NULL, lock == olock) && + ergo(lock == NULL, olock == NULL))) + return 0; + /* + * Check that ->ols_handle and ->ols_lock are consistent, but + * take into account that they are set at the different time. + */ + if (! ergo(ols->ols_state == OLS_CANCELLED, + olock == NULL && !handle_used)) + return 0; + /* + * DLM lock is destroyed only after we have seen cancellation + * ast. + */ + if (! ergo(olock != NULL && ols->ols_state < OLS_CANCELLED, + ((olock->l_flags & LDLM_FL_DESTROYED) == 0))) + return 0; + + if (! ergo(ols->ols_state == OLS_GRANTED, + olock != NULL && + olock->l_req_mode == olock->l_granted_mode && + ols->ols_hold)) + return 0; + return 1; } /***************************************************************************** @@ -261,7 +275,7 @@ static __u64 osc_enq2ldlm_flags(__u32 enqflags) if (enqflags & CEF_ASYNC) result |= LDLM_FL_HAS_INTENT; if (enqflags & CEF_DISCARD_DATA) - result |= LDLM_AST_DISCARD_DATA; + result |= LDLM_FL_AST_DISCARD_DATA; return result; } @@ -896,55 +910,6 @@ static unsigned long osc_lock_weigh(const struct lu_env *env, return cl_object_header(slice->cls_obj)->coh_pages; } -/** - * Get the weight of dlm lock for early cancellation. - * - * XXX: it should return the pages covered by this \a dlmlock. - */ -static unsigned long osc_ldlm_weigh_ast(struct ldlm_lock *dlmlock) -{ - struct cl_env_nest nest; - struct lu_env *env; - struct osc_lock *lock; - struct cl_lock *cll; - unsigned long weight; - ENTRY; - - might_sleep(); - /* - * osc_ldlm_weigh_ast has a complex context since it might be called - * because of lock canceling, or from user's input. We have to make - * a new environment for it. Probably it is implementation safe to use - * the upper context because cl_lock_put don't modify environment - * variables. But in case of .. - */ - env = cl_env_nested_get(&nest); - if (IS_ERR(env)) - /* Mostly because lack of memory, tend to eliminate this lock*/ - RETURN(0); - - LASSERT(dlmlock->l_resource->lr_type == LDLM_EXTENT); - lock = osc_ast_data_get(dlmlock); - if (lock == NULL) { - /* cl_lock was destroyed because of memory pressure. - * It is much reasonable to assign this type of lock - * a lower cost. - */ - GOTO(out, weight = 0); - } - - cll = lock->ols_cl.cls_lock; - cl_lock_mutex_get(env, cll); - weight = cl_lock_weigh(env, cll); - cl_lock_mutex_put(env, cll); - osc_ast_data_put(env, lock); - EXIT; - -out: - cl_env_nested_put(&nest, env); - return weight; -} - static void osc_lock_build_einfo(const struct lu_env *env, const struct cl_lock *clock, struct osc_lock *lock, @@ -966,7 +931,6 @@ static void osc_lock_build_einfo(const struct lu_env *env, einfo->ei_cb_bl = osc_ldlm_blocking_ast; einfo->ei_cb_cp = osc_ldlm_completion_ast; einfo->ei_cb_gl = osc_ldlm_glimpse_ast; - einfo->ei_cb_wg = osc_ldlm_weigh_ast; einfo->ei_cbdata = lock; /* value to be put into ->l_ast_data */ } -- GitLab From b62b9c0630a859bc5b6073b8449c9f5c178ece05 Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Tue, 23 Jul 2013 00:06:38 +0800 Subject: [PATCH 036/942] staging/lustre/md: fix lu_ucred.c boilerplate In preparing Ie3a3cd99 (LU-1330 obdclass: splits server-side object stack from client) the lu_ucred infrastructure was put in its own file. Fixup the boilerplate of this file to give the proper path, short description, and authors. Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-1330 Lustre-change: http://review.whamcloud.com/5910 Signed-off-by: John L. Hammond Reviewed-by: Fan Yong Reviewed-by: Vitaly Fertman Reviewed-by: Oleg Drokin Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/obdclass/lu_ucred.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/lu_ucred.c b/drivers/staging/lustre/lustre/obdclass/lu_ucred.c index 229db6c39b78d..e23e545b0d667 100644 --- a/drivers/staging/lustre/lustre/obdclass/lu_ucred.c +++ b/drivers/staging/lustre/lustre/obdclass/lu_ucred.c @@ -33,13 +33,13 @@ * This file is part of Lustre, http://www.lustre.org/ * Lustre is a trademark of Sun Microsystems, Inc. * - * lustre/obdclass/lu_object.c + * lustre/obdclass/lu_ucred.c * - * Lustre Object. - * These are the only exported functions, they provide some generic - * infrastructure for managing object devices + * Lustre user credentials context infrastructure. * * Author: Nikita Danilov + * Author: Fan Yong + * Author: Vitaly Fertman */ #define DEBUG_SUBSYSTEM S_CLASS -- GitLab From 5dd16419919787eed5a3ade9f03a58ecfc9e8630 Mon Sep 17 00:00:00 2001 From: Jinshan Xiong Date: Tue, 23 Jul 2013 00:06:39 +0800 Subject: [PATCH 037/942] staging/lustre/layout: introduce new layout for released files Released files now have a standard layout (with generation, pool, ...) and a stripe count 0 and lmm_pattern flag LOV_PATTERN_F_RELEASED. Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2482 Lustre-change: http://review.whamcloud.com/4816 Signed-off-by: Jinshan Xiong Signed-off-by: Johann Lombardi Reviewed-by: Keith Mannthey Reviewed-by: Fan Yong Reviewed-by: Andreas Dilger Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/include/lustre/lustre_idl.h | 14 +++- drivers/staging/lustre/lustre/include/obd.h | 14 ++++ .../lustre/lustre/lclient/lcommon_cl.c | 2 +- drivers/staging/lustre/lustre/llite/file.c | 27 ++++--- .../staging/lustre/lustre/llite/llite_lib.c | 22 +++--- drivers/staging/lustre/lustre/llite/vvp_io.c | 10 ++- .../lustre/lustre/lov/lov_cl_internal.h | 11 ++- drivers/staging/lustre/lustre/lov/lov_ea.c | 23 +++++- drivers/staging/lustre/lustre/lov/lov_io.c | 34 +++++++++ drivers/staging/lustre/lustre/lov/lov_obd.c | 2 +- .../staging/lustre/lustre/lov/lov_object.c | 73 ++++++++++++++++--- drivers/staging/lustre/lustre/lov/lov_pack.c | 19 +++-- 12 files changed, 197 insertions(+), 54 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h index 4829419a75d30..30c03317fb6f9 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h @@ -1546,10 +1546,16 @@ enum obdo_flags { #define LOV_MAGIC_V1_DEF 0x0CD10BD0 #define LOV_MAGIC_V3_DEF 0x0CD30BD0 -#define LOV_PATTERN_RAID0 0x001 /* stripes are used round-robin */ -#define LOV_PATTERN_RAID1 0x002 /* stripes are mirrors of each other */ -#define LOV_PATTERN_FIRST 0x100 /* first stripe is not in round-robin */ -#define LOV_PATTERN_CMOBD 0x200 +#define LOV_PATTERN_RAID0 0x001 /* stripes are used round-robin */ +#define LOV_PATTERN_RAID1 0x002 /* stripes are mirrors of each other */ +#define LOV_PATTERN_FIRST 0x100 /* first stripe is not in round-robin */ +#define LOV_PATTERN_CMOBD 0x200 + +#define LOV_PATTERN_F_MASK 0xffff0000 +#define LOV_PATTERN_F_RELEASED 0x80000000 /* HSM released file */ + +#define lov_pattern(pattern) (pattern & ~LOV_PATTERN_F_MASK) +#define lov_pattern_flags(pattern) (pattern & LOV_PATTERN_F_MASK) #define lov_ost_data lov_ost_data_v1 struct lov_ost_data_v1 { /* per-stripe data structure (little-endian)*/ diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index 0a251fdfe167f..11d10fe682d00 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -119,6 +119,20 @@ struct lov_stripe_md { #define lsm_stripe_count lsm_wire.lw_stripe_count #define lsm_pool_name lsm_wire.lw_pool_name +static inline bool lsm_is_released(struct lov_stripe_md *lsm) +{ + return !!(lsm->lsm_pattern & LOV_PATTERN_F_RELEASED); +} + +static inline bool lsm_has_objects(struct lov_stripe_md *lsm) +{ + if (lsm == NULL) + return false; + if (lsm_is_released(lsm)) + return false; + return true; +} + struct obd_info; typedef int (*obd_enqueue_update_f)(void *cookie, int rc); diff --git a/drivers/staging/lustre/lustre/lclient/lcommon_cl.c b/drivers/staging/lustre/lustre/lclient/lcommon_cl.c index 4a0166687f075..c8690cb7731d2 100644 --- a/drivers/staging/lustre/lustre/lclient/lcommon_cl.c +++ b/drivers/staging/lustre/lustre/lclient/lcommon_cl.c @@ -1166,7 +1166,7 @@ int cl_file_inode_init(struct inode *inode, struct lustre_md *md) * locked by I_NEW bit. */ lli->lli_clob = clob; - lli->lli_has_smd = md->lsm != NULL; + lli->lli_has_smd = lsm_has_objects(md->lsm); lu_object_ref_add(&clob->co_lu, "inode", inode); } else result = PTR_ERR(clob); diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index d51f1eee36e2f..549384582d498 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -1143,7 +1143,7 @@ static int ll_lov_recreate(struct inode *inode, struct ost_id *oi, RETURN(-ENOMEM); lsm = ccc_inode_lsm_get(inode); - if (lsm == NULL) + if (!lsm_has_objects(lsm)) GOTO(out, rc = -ENOENT); lsm_size = sizeof(*lsm) + (sizeof(struct lov_oinfo) * @@ -1299,6 +1299,12 @@ int ll_lov_getstripe_ea_info(struct inode *inode, const char *filename, * passing it to userspace. */ if (LOV_MAGIC != cpu_to_le32(LOV_MAGIC)) { + int stripe_count; + + stripe_count = le16_to_cpu(lmm->lmm_stripe_count); + if (le32_to_cpu(lmm->lmm_pattern) & LOV_PATTERN_F_RELEASED) + stripe_count = 0; + /* if function called for directory - we should * avoid swab not existent lsm objects */ if (lmm->lmm_magic == cpu_to_le32(LOV_MAGIC_V1)) { @@ -1306,13 +1312,13 @@ int ll_lov_getstripe_ea_info(struct inode *inode, const char *filename, if (S_ISREG(body->mode)) lustre_swab_lov_user_md_objects( ((struct lov_user_md_v1 *)lmm)->lmm_objects, - ((struct lov_user_md_v1 *)lmm)->lmm_stripe_count); + stripe_count); } else if (lmm->lmm_magic == cpu_to_le32(LOV_MAGIC_V3)) { lustre_swab_lov_user_md_v3((struct lov_user_md_v3 *)lmm); if (S_ISREG(body->mode)) lustre_swab_lov_user_md_objects( ((struct lov_user_md_v3 *)lmm)->lmm_objects, - ((struct lov_user_md_v3 *)lmm)->lmm_stripe_count); + stripe_count); } } @@ -1698,20 +1704,18 @@ int ll_data_version(struct inode *inode, __u64 *data_version, /* If no stripe, we consider version is 0. */ lsm = ccc_inode_lsm_get(inode); - if (lsm == NULL) { + if (!lsm_has_objects(lsm)) { *data_version = 0; CDEBUG(D_INODE, "No object for inode\n"); - RETURN(0); + GOTO(out, rc = 0); } OBD_ALLOC_PTR(obdo); - if (obdo == NULL) { - ccc_inode_lsm_put(inode, lsm); - RETURN(-ENOMEM); - } + if (obdo == NULL) + GOTO(out, rc = -ENOMEM); rc = ll_lsm_getattr(lsm, sbi->ll_dt_exp, NULL, obdo, 0, extent_lock); - if (!rc) { + if (rc == 0) { if (!(obdo->o_valid & OBD_MD_FLDATAVERSION)) rc = -EOPNOTSUPP; else @@ -1719,8 +1723,9 @@ int ll_data_version(struct inode *inode, __u64 *data_version, } OBD_FREE_PTR(obdo); + EXIT; +out: ccc_inode_lsm_put(inode, lsm); - RETURN(rc); } diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 1eb5779c1bdad..b9cbe9505d4a3 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -1282,13 +1282,6 @@ int ll_md_setattr(struct dentry *dentry, struct md_op_data *op_data, RETURN(rc); } - ia_valid = op_data->op_attr.ia_valid; - /* inode size will be in ll_setattr_ost, can't do it now since dirty - * cache is not cleared yet. */ - op_data->op_attr.ia_valid &= ~(TIMES_SET_FLAGS | ATTR_SIZE); - rc = simple_setattr(dentry, &op_data->op_attr); - op_data->op_attr.ia_valid = ia_valid; - /* Extract epoch data if obtained. */ op_data->op_handle = md.body->handle; op_data->op_ioepoch = md.body->ioepoch; @@ -1371,6 +1364,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr) struct ll_inode_info *lli = ll_i2info(inode); struct md_op_data *op_data = NULL; struct md_open_data *mod = NULL; + unsigned int valid = attr->ia_valid; int rc = 0, rc1 = 0; ENTRY; @@ -1482,6 +1476,13 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr) rc = ll_setattr_ost(inode, attr); EXIT; out: + if (rc == 0) { + /* Update inode attribute after dirty cache is cleaned + * by truncating OST objects. */ + attr->ia_valid |= ATTR_FORCE; + rc = simple_setattr(dentry, attr); + LASSERT(rc == 0); + } if (op_data) { if (op_data->op_ioepoch) { rc1 = ll_setattr_done_writing(inode, op_data, mod); @@ -1500,7 +1501,8 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr) ll_stats_ops_tally(ll_i2sbi(inode), (attr->ia_valid & ATTR_SIZE) ? LPROC_LL_TRUNC : LPROC_LL_SETATTR, 1); - return rc; + attr->ia_valid = valid; + RETURN(rc); } int ll_setattr(struct dentry *de, struct iattr *attr) @@ -1923,8 +1925,10 @@ int ll_iocontrol(struct inode *inode, struct file *file, inode->i_flags = ll_ext_to_inode_flags(flags); lsm = ccc_inode_lsm_get(inode); - if (lsm == NULL) + if (!lsm_has_objects(lsm)) { + ccc_inode_lsm_put(inode, lsm); RETURN(0); + } OBDO_ALLOC(oinfo.oi_oa); if (!oinfo.oi_oa) { diff --git a/drivers/staging/lustre/lustre/llite/vvp_io.c b/drivers/staging/lustre/lustre/llite/vvp_io.c index 20eac2fd63c3e..23149f96f136e 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_io.c +++ b/drivers/staging/lustre/lustre/llite/vvp_io.c @@ -407,13 +407,15 @@ static int vvp_io_setattr_start(const struct lu_env *env, { struct cl_io *io = ios->cis_io; struct inode *inode = ccc_object_inode(io->ci_obj); + int result = 0; mutex_lock(&inode->i_mutex); if (cl_io_is_trunc(io)) - return vvp_io_setattr_trunc(env, ios, inode, - io->u.ci_setattr.sa_attr.lvb_size); - else - return vvp_io_setattr_time(env, ios); + result = vvp_io_setattr_trunc(env, ios, inode, + io->u.ci_setattr.sa_attr.lvb_size); + if (result == 0) + result = vvp_io_setattr_time(env, ios); + return result; } static void vvp_io_setattr_end(const struct lu_env *env, diff --git a/drivers/staging/lustre/lustre/lov/lov_cl_internal.h b/drivers/staging/lustre/lustre/lov/lov_cl_internal.h index 28801b8b5fdfd..a82dfeab59214 100644 --- a/drivers/staging/lustre/lustre/lov/lov_cl_internal.h +++ b/drivers/staging/lustre/lustre/lov/lov_cl_internal.h @@ -162,10 +162,9 @@ struct lov_device { * Layout type. */ enum lov_layout_type { - /** empty file without body */ - LLT_EMPTY, - /** striped file */ - LLT_RAID0, + LLT_EMPTY, /** empty file without body (mknod + truncate) */ + LLT_RAID0, /** striped file */ + LLT_RELEASED, /** file with no objects (data in HSM) */ LLT_NR }; @@ -255,6 +254,8 @@ struct lov_object { } raid0; struct lov_layout_state_empty { } empty; + struct lov_layout_state_released { + } released; } u; /** * Thread that acquired lov_object::lo_type_guard in an exclusive @@ -582,6 +583,8 @@ int lov_io_init_raid0 (const struct lu_env *env, struct cl_object *obj, struct cl_io *io); int lov_io_init_empty (const struct lu_env *env, struct cl_object *obj, struct cl_io *io); +int lov_io_init_released(const struct lu_env *env, struct cl_object *obj, + struct cl_io *io); void lov_lock_unlink (const struct lu_env *env, struct lov_lock_link *link, struct lovsub_lock *sub); diff --git a/drivers/staging/lustre/lustre/lov/lov_ea.c b/drivers/staging/lustre/lustre/lov/lov_ea.c index 340dbcf829e85..e6c60151dc654 100644 --- a/drivers/staging/lustre/lustre/lov/lov_ea.c +++ b/drivers/staging/lustre/lustre/lov/lov_ea.c @@ -57,7 +57,7 @@ struct lovea_unpack_args { static int lsm_lmm_verify_common(struct lov_mds_md *lmm, int lmm_bytes, __u16 stripe_count) { - if (stripe_count == 0 || stripe_count > LOV_V1_INSANE_STRIPE_COUNT) { + if (stripe_count > LOV_V1_INSANE_STRIPE_COUNT) { CERROR("bad stripe count %d\n", stripe_count); lov_dump_lmm_common(D_WARNING, lmm); return -EINVAL; @@ -69,7 +69,7 @@ static int lsm_lmm_verify_common(struct lov_mds_md *lmm, int lmm_bytes, return -EINVAL; } - if (lmm->lmm_pattern != cpu_to_le32(LOV_PATTERN_RAID0)) { + if (lov_pattern(le32_to_cpu(lmm->lmm_pattern)) != LOV_PATTERN_RAID0) { CERROR("bad striping pattern\n"); lov_dump_lmm_common(D_WARNING, lmm); return -EINVAL; @@ -197,6 +197,8 @@ static int lsm_lmm_verify_v1(struct lov_mds_md_v1 *lmm, int lmm_bytes, } *stripe_count = le16_to_cpu(lmm->lmm_stripe_count); + if (le32_to_cpu(lmm->lmm_pattern) & LOV_PATTERN_F_RELEASED) + *stripe_count = 0; if (lmm_bytes < lov_mds_md_size(*stripe_count, LOV_MAGIC_V1)) { CERROR("LOV EA V1 too small: %d, need %d\n", @@ -213,11 +215,14 @@ int lsm_unpackmd_v1(struct lov_obd *lov, struct lov_stripe_md *lsm, { struct lov_oinfo *loi; int i; + int stripe_count; __u64 stripe_maxbytes = OBD_OBJECT_EOF; lsm_unpackmd_common(lsm, lmm); - for (i = 0; i < lsm->lsm_stripe_count; i++) { + stripe_count = lsm_is_released(lsm) ? 0 : lsm->lsm_stripe_count; + + for (i = 0; i < stripe_count; i++) { /* XXX LOV STACKING call down to osc_unpackmd() */ loi = lsm->lsm_oinfo[i]; ostid_le_to_cpu(&lmm->lmm_objects[i].l_ost_oi, &loi->loi_oi); @@ -240,6 +245,8 @@ int lsm_unpackmd_v1(struct lov_obd *lov, struct lov_stripe_md *lsm, } lsm->lsm_maxbytes = stripe_maxbytes * lsm->lsm_stripe_count; + if (lsm->lsm_stripe_count == 0) + lsm->lsm_maxbytes = stripe_maxbytes * lov->desc.ld_tgt_count; return 0; } @@ -267,6 +274,8 @@ static int lsm_lmm_verify_v3(struct lov_mds_md *lmmv1, int lmm_bytes, } *stripe_count = le16_to_cpu(lmm->lmm_stripe_count); + if (le32_to_cpu(lmm->lmm_pattern) & LOV_PATTERN_F_RELEASED) + *stripe_count = 0; if (lmm_bytes < lov_mds_md_size(*stripe_count, LOV_MAGIC_V3)) { CERROR("LOV EA V3 too small: %d, need %d\n", @@ -285,18 +294,22 @@ int lsm_unpackmd_v3(struct lov_obd *lov, struct lov_stripe_md *lsm, struct lov_mds_md_v3 *lmm; struct lov_oinfo *loi; int i; + int stripe_count; __u64 stripe_maxbytes = OBD_OBJECT_EOF; int cplen = 0; lmm = (struct lov_mds_md_v3 *)lmmv1; lsm_unpackmd_common(lsm, (struct lov_mds_md_v1 *)lmm); + + stripe_count = lsm_is_released(lsm) ? 0 : lsm->lsm_stripe_count; + cplen = strlcpy(lsm->lsm_pool_name, lmm->lmm_pool_name, sizeof(lsm->lsm_pool_name)); if (cplen >= sizeof(lsm->lsm_pool_name)) return -E2BIG; - for (i = 0; i < lsm->lsm_stripe_count; i++) { + for (i = 0; i < stripe_count; i++) { /* XXX LOV STACKING call down to osc_unpackmd() */ loi = lsm->lsm_oinfo[i]; ostid_le_to_cpu(&lmm->lmm_objects[i].l_ost_oi, &loi->loi_oi); @@ -319,6 +332,8 @@ int lsm_unpackmd_v3(struct lov_obd *lov, struct lov_stripe_md *lsm, } lsm->lsm_maxbytes = stripe_maxbytes * lsm->lsm_stripe_count; + if (lsm->lsm_stripe_count == 0) + lsm->lsm_maxbytes = stripe_maxbytes * lov->desc.ld_tgt_count; return 0; } diff --git a/drivers/staging/lustre/lustre/lov/lov_io.c b/drivers/staging/lustre/lustre/lov/lov_io.c index 022e0f4911c64..e78cdb7633ca2 100644 --- a/drivers/staging/lustre/lustre/lov/lov_io.c +++ b/drivers/staging/lustre/lustre/lov/lov_io.c @@ -964,4 +964,38 @@ int lov_io_init_empty(const struct lu_env *env, struct cl_object *obj, RETURN(result != 0); } +int lov_io_init_released(const struct lu_env *env, struct cl_object *obj, + struct cl_io *io) +{ + struct lov_object *lov = cl2lov(obj); + struct lov_io *lio = lov_env_io(env); + int result; + ENTRY; + + LASSERT(lov->lo_lsm != NULL); + lio->lis_object = lov; + + switch (io->ci_type) { + default: + LASSERTF(0, "invalid type %d\n", io->ci_type); + case CIT_MISC: + case CIT_FSYNC: + case CIT_SETATTR: + result = +1; + break; + case CIT_READ: + case CIT_WRITE: + case CIT_FAULT: + /* TODO: need to restore the file. */ + result = -EBADF; + break; + } + if (result == 0) { + cl_io_slice_add(io, &lio->lis_cl, obj, &lov_empty_io_ops); + atomic_inc(&lov->lo_active_ios); + } + + io->ci_result = result < 0 ? result : 0; + RETURN(result != 0); +} /** @} lov */ diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index ef7ff091f0484..0a9e40de8fae7 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -2259,7 +2259,7 @@ static int lov_fiemap(struct lov_obd *lov, __u32 keylen, void *key, int cur_stripe = 0, cur_stripe_wrap = 0, stripe_count; unsigned int buffer_size = FIEMAP_BUFFER_SIZE; - if (lsm == NULL) + if (!lsm_has_objects(lsm)) GOTO(out, rc = 0); if (fiemap_count_to_size(fm_key->fiemap.fm_extent_count) < buffer_size) diff --git a/drivers/staging/lustre/lustre/lov/lov_object.c b/drivers/staging/lustre/lustre/lov/lov_object.c index aa8ae80e81215..e7cc6502237f5 100644 --- a/drivers/staging/lustre/lustre/lov/lov_object.c +++ b/drivers/staging/lustre/lustre/lov/lov_object.c @@ -258,10 +258,25 @@ static int lov_init_raid0(const struct lu_env *env, RETURN(result); } +static int lov_init_released(const struct lu_env *env, + struct lov_device *dev, struct lov_object *lov, + const struct cl_object_conf *conf, + union lov_layout_state *state) +{ + struct lov_stripe_md *lsm = conf->u.coc_md->lsm; + + LASSERT(lsm != NULL); + LASSERT(lsm_is_released(lsm)); + LASSERT(lov->lo_lsm == NULL); + + lov->lo_lsm = lsm_addref(lsm); + return 0; +} + static int lov_delete_empty(const struct lu_env *env, struct lov_object *lov, union lov_layout_state *state) { - LASSERT(lov->lo_type == LLT_EMPTY); + LASSERT(lov->lo_type == LLT_EMPTY || lov->lo_type == LLT_RELEASED); lov_layout_wait(env, lov); @@ -349,7 +364,7 @@ static int lov_delete_raid0(const struct lu_env *env, struct lov_object *lov, static void lov_fini_empty(const struct lu_env *env, struct lov_object *lov, union lov_layout_state *state) { - LASSERT(lov->lo_type == LLT_EMPTY); + LASSERT(lov->lo_type == LLT_EMPTY || lov->lo_type == LLT_RELEASED); } static void lov_fini_raid0(const struct lu_env *env, struct lov_object *lov, @@ -369,6 +384,15 @@ static void lov_fini_raid0(const struct lu_env *env, struct lov_object *lov, EXIT; } +static void lov_fini_released(const struct lu_env *env, struct lov_object *lov, + union lov_layout_state *state) +{ + ENTRY; + dump_lsm(D_INODE, lov->lo_lsm); + lov_free_memmd(&lov->lo_lsm); + EXIT; +} + static int lov_print_empty(const struct lu_env *env, void *cookie, lu_printer_t p, const struct lu_object *o) { @@ -400,6 +424,13 @@ static int lov_print_raid0(const struct lu_env *env, void *cookie, return 0; } +static int lov_print_released(const struct lu_env *env, void *cookie, + lu_printer_t p, const struct lu_object *o) +{ + (*p)(env, cookie, "released\n"); + return 0; +} + /** * Implements cl_object_operations::coo_attr_get() method for an object * without stripes (LLT_EMPTY layout type). @@ -503,10 +534,20 @@ const static struct lov_layout_operations lov_dispatch[] = { .llo_lock_init = lov_lock_init_raid0, .llo_io_init = lov_io_init_raid0, .llo_getattr = lov_attr_get_raid0 + }, + [LLT_RELEASED] = { + .llo_init = lov_init_released, + .llo_delete = lov_delete_empty, + .llo_fini = lov_fini_released, + .llo_install = lov_install_empty, + .llo_print = lov_print_released, + .llo_page_init = lov_page_init_empty, + .llo_lock_init = lov_lock_init_empty, + .llo_io_init = lov_io_init_released, + .llo_getattr = lov_attr_get_empty } }; - /** * Performs a double-dispatch based on the layout type of an object. */ @@ -520,6 +561,18 @@ const static struct lov_layout_operations lov_dispatch[] = { lov_dispatch[__llt].op(__VA_ARGS__); \ }) +/** + * Return lov_layout_type associated with a given lsm + */ +enum lov_layout_type lov_type(struct lov_stripe_md *lsm) +{ + if (lsm == NULL) + return LLT_EMPTY; + if (lsm_is_released(lsm)) + return LLT_RELEASED; + return LLT_RAID0; +} + static inline void lov_conf_freeze(struct lov_object *lov) { if (lov->lo_owner != current) @@ -612,8 +665,8 @@ static int lov_layout_change(const struct lu_env *unused, LASSERT(0 <= lov->lo_type && lov->lo_type < ARRAY_SIZE(lov_dispatch)); - if (conf->u.coc_md != NULL && conf->u.coc_md->lsm != NULL) - llt = LLT_RAID0; /* only raid0 is supported. */ + if (conf->u.coc_md != NULL) + llt = lov_type(conf->u.coc_md->lsm); LASSERT(0 <= llt && llt < ARRAY_SIZE(lov_dispatch)); cookie = cl_env_reenter(); @@ -658,7 +711,6 @@ static int lov_layout_change(const struct lu_env *unused, * Lov object operations. * */ - int lov_object_init(const struct lu_env *env, struct lu_object *obj, const struct lu_object_conf *conf) { @@ -677,7 +729,7 @@ int lov_object_init(const struct lu_env *env, struct lu_object *obj, cl_object_page_init(lu2cl(obj), sizeof(struct lov_page)); /* no locking is necessary, as object is being created */ - lov->lo_type = cconf->u.coc_md->lsm != NULL ? LLT_RAID0 : LLT_EMPTY; + lov->lo_type = lov_type(cconf->u.coc_md->lsm); ops = &lov_dispatch[lov->lo_type]; result = ops->llo_init(env, dev, lov, cconf, set); if (result == 0) @@ -688,9 +740,9 @@ int lov_object_init(const struct lu_env *env, struct lu_object *obj, static int lov_conf_set(const struct lu_env *env, struct cl_object *obj, const struct cl_object_conf *conf) { - struct lov_stripe_md *lsm = NULL; - struct lov_object *lov = cl2lov(obj); - int result = 0; + struct lov_stripe_md *lsm = NULL; + struct lov_object *lov = cl2lov(obj); + int result = 0; ENTRY; lov_conf_lock(lov); @@ -928,6 +980,7 @@ int lov_read_and_clear_async_rc(struct cl_object *clob) loi->loi_ar.ar_rc = 0; } } + case LLT_RELEASED: case LLT_EMPTY: break; default: diff --git a/drivers/staging/lustre/lustre/lov/lov_pack.c b/drivers/staging/lustre/lustre/lov/lov_pack.c index 492948aad6855..9c99e4a2c5d8c 100644 --- a/drivers/staging/lustre/lustre/lov/lov_pack.c +++ b/drivers/staging/lustre/lustre/lov/lov_pack.c @@ -168,10 +168,12 @@ int lov_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, * to the actual number of OSTs in this filesystem. */ if (!lmmp) { stripe_count = lov_get_stripecnt(lov, lmm_magic, - lsm->lsm_stripe_count); + lsm->lsm_stripe_count); lsm->lsm_stripe_count = stripe_count; - } else { + } else if (!lsm_is_released(lsm)) { stripe_count = lsm->lsm_stripe_count; + } else { + stripe_count = 0; } } else { /* No need to allocate more than maximum supported stripes. @@ -325,7 +327,8 @@ int lov_alloc_memmd(struct lov_stripe_md **lsmp, __u16 stripe_count, (*lsmp)->lsm_pattern = pattern; (*lsmp)->lsm_pool_name[0] = '\0'; (*lsmp)->lsm_layout_gen = 0; - (*lsmp)->lsm_oinfo[0]->loi_ost_idx = ~0; + if (stripe_count > 0) + (*lsmp)->lsm_oinfo[0]->loi_ost_idx = ~0; for (i = 0; i < stripe_count; i++) loi_init((*lsmp)->lsm_oinfo[i]); @@ -359,6 +362,7 @@ int lov_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, int rc = 0, lsm_size; __u16 stripe_count; __u32 magic; + __u32 pattern; ENTRY; /* If passed an MDS struct use values from there, otherwise defaults */ @@ -384,8 +388,8 @@ int lov_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, RETURN(0); } - lsm_size = lov_alloc_memmd(lsmp, stripe_count, LOV_PATTERN_RAID0, - magic); + pattern = le32_to_cpu(lmm->lmm_pattern); + lsm_size = lov_alloc_memmd(lsmp, stripe_count, pattern, magic); if (lsm_size < 0) RETURN(lsm_size); @@ -430,7 +434,7 @@ static int __lov_setstripe(struct obd_export *exp, int max_lmm_size, lov->desc.ld_pattern : LOV_PATTERN_RAID0; } - if (lumv1->lmm_pattern != LOV_PATTERN_RAID0) { + if (lov_pattern(lumv1->lmm_pattern) != LOV_PATTERN_RAID0) { CDEBUG(D_IOCTL, "bad userland stripe pattern: %#x\n", lumv1->lmm_pattern); RETURN(-EINVAL); @@ -490,6 +494,9 @@ static int __lov_setstripe(struct obd_export *exp, int max_lmm_size, } } + if (lumv1->lmm_pattern & LOV_PATTERN_F_RELEASED) + stripe_count = 0; + rc = lov_alloc_memmd(lsmp, stripe_count, lumv1->lmm_pattern, lmm_magic); if (rc >= 0) { -- GitLab From 001f54878a57a95dd373a7071693173b66ba999c Mon Sep 17 00:00:00 2001 From: jcl Date: Tue, 23 Jul 2013 00:06:40 +0800 Subject: [PATCH 038/942] staging/lustre/mdt: add macros for fid string len add 2 macros for the length of a fid string 0xSEQ:0xOID:0xVER and it's brace version (FID_NOBRACE_LEN, and FID_LEN) Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2782 Lustre-change: http://review.whamcloud.com/5299 Signed-off-by: JC Lafoucriere Reviewed-by: Jinshan Xiong Reviewed-by: Oleg Drokin Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/lustre/lustre_user.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h index 7e9f57507f044..f72b2e4cbca1e 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h @@ -462,6 +462,8 @@ static inline void obd_uuid2fsname(char *buf, char *uuid, int buflen) /* printf display format e.g. printf("file FID is "DFID"\n", PFID(fid)); */ +#define FID_NOBRACE_LEN 40 +#define FID_LEN (FID_NOBRACE_LEN + 2) #define DFID_NOBRACE LPX64":0x%x:0x%x" #define DFID "["DFID_NOBRACE"]" #define PFID(fid) \ -- GitLab From bc06a6785041fd4948bf25c5d3ac3db3c9b13bbf Mon Sep 17 00:00:00 2001 From: jcl Date: Tue, 23 Jul 2013 00:06:41 +0800 Subject: [PATCH 039/942] staging/lustre/llapi: add user space method for lov_user_md move lov_mds_md_size from obd_lov.h to lustre_idl.h to have it close to lov_mds_md definition. add lov_user_md_size() to compute lum size so llapi and user space utils do not use kernel internal definitions/methods Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3345 Lustre-change: http://review.whamcloud.com/6345 Signed-off-by: JC Lafoucriere Reviewed-by: Jinshan Xiong Reviewed-by: Andreas Dilger Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lustre/include/lustre/lustre_idl.h | 11 +++++++++++ .../lustre/lustre/include/lustre/lustre_user.h | 10 ++++++++++ drivers/staging/lustre/lustre/include/obd_lov.h | 10 ---------- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h index 30c03317fb6f9..ace4e18dfae8e 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h @@ -1670,6 +1670,17 @@ struct lov_mds_md_v3 { /* LOV EA mds/wire data (little-endian) */ struct lov_ost_data_v1 lmm_objects[0]; /* per-stripe data */ }; +static inline __u32 lov_mds_md_size(__u16 stripes, __u32 lmm_magic) +{ + if (lmm_magic == LOV_MAGIC_V3) + return sizeof(struct lov_mds_md_v3) + + stripes * sizeof(struct lov_ost_data_v1); + else + return sizeof(struct lov_mds_md_v1) + + stripes * sizeof(struct lov_ost_data_v1); +} + + #define OBD_MD_FLID (0x00000001ULL) /* object ID */ #define OBD_MD_FLATIME (0x00000002ULL) /* access time */ #define OBD_MD_FLMTIME (0x00000004ULL) /* data modification time */ diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h index f72b2e4cbca1e..c7bd4473a1d0f 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_user.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_user.h @@ -347,6 +347,16 @@ struct lov_user_md_v3 { /* LOV EA user data (host-endian) */ struct lov_user_ost_data_v1 lmm_objects[0]; /* per-stripe data */ } __attribute__((packed)); +static inline __u32 lov_user_md_size(__u16 stripes, __u32 lmm_magic) +{ + if (lmm_magic == LOV_USER_MAGIC_V3) + return sizeof(struct lov_user_md_v3) + + stripes * sizeof(struct lov_user_ost_data_v1); + else + return sizeof(struct lov_user_md_v1) + + stripes * sizeof(struct lov_user_ost_data_v1); +} + /* Compile with -D_LARGEFILE64_SOURCE or -D_GNU_SOURCE (or #define) to * use this. It is unsafe to #define those values in this header as it * is possible the application has already #included . */ diff --git a/drivers/staging/lustre/lustre/include/obd_lov.h b/drivers/staging/lustre/lustre/include/obd_lov.h index d82f3341d0a88..235718b366dc2 100644 --- a/drivers/staging/lustre/lustre/include/obd_lov.h +++ b/drivers/staging/lustre/lustre/include/obd_lov.h @@ -44,16 +44,6 @@ static inline int lov_stripe_md_size(__u16 stripes) return sizeof(struct lov_stripe_md) + stripes*sizeof(struct lov_oinfo*); } -static inline __u32 lov_mds_md_size(__u16 stripes, __u32 lmm_magic) -{ - if (lmm_magic == LOV_MAGIC_V3) - return sizeof(struct lov_mds_md_v3) + - stripes * sizeof(struct lov_ost_data_v1); - else - return sizeof(struct lov_mds_md_v1) + - stripes * sizeof(struct lov_ost_data_v1); -} - struct lov_version_size { __u32 lvs_magic; size_t lvs_lmm_size; -- GitLab From 353471a6bd906e3d4674b143be31ad51c2de134e Mon Sep 17 00:00:00 2001 From: Sebastien Buisson Date: Tue, 23 Jul 2013 00:06:43 +0800 Subject: [PATCH 040/942] staging/lustre: fix 'code maintainability' errors Fix 'code maintainability' issues found by Coverity version 6.5.1: Unused pointer value (UNUSED_VALUE) Pointer returned by function is never used. Missing varargs init or cleanup (VARARGS) va_end was not called for variable. Signed-off-by: Sebastien Buisson Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3107 Lustre-change: http://review.whamcloud.com/5944 Reviewed-by: Dmitry Eremin Reviewed-by: John Hammond Reviewed-by: Andreas Dilger Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/obdclass/lprocfs_jobstats.c | 2 -- drivers/staging/lustre/lustre/ptlrpc/pack_generic.c | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_jobstats.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_jobstats.c index e2d57fef0da3b..7f6072c4b7f88 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_jobstats.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_jobstats.c @@ -366,7 +366,6 @@ static int lprocfs_jobstats_seq_show(struct seq_file *p, void *v) struct job_stat *job = v; struct lprocfs_stats *s; struct lprocfs_counter ret; - struct lprocfs_counter *cntr; struct lprocfs_counter_header *cntr_header; int i; @@ -380,7 +379,6 @@ static int lprocfs_jobstats_seq_show(struct seq_file *p, void *v) s = job->js_stats; for (i = 0; i < s->ls_num; i++) { - cntr = lprocfs_stats_counter_get(s, 0, i); cntr_header = &s->ls_cnt_header[i]; lprocfs_stats_collect(s, i, &ret); diff --git a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c index be246d491886f..ffff648335574 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c @@ -2462,6 +2462,7 @@ void _debug_req(struct ptlrpc_request *req, rep_ok ? lustre_msg_get_flags(req->rq_repmsg) : -1, req->rq_status, rep_ok ? lustre_msg_get_status(req->rq_repmsg) : -1); + va_end(args); } EXPORT_SYMBOL(_debug_req); -- GitLab From 56f4c5a8a5f84a360943b17d7cb531c161d4e9bd Mon Sep 17 00:00:00 2001 From: Liu Xuezhao Date: Tue, 23 Jul 2013 00:06:44 +0800 Subject: [PATCH 041/942] staging/lustre/fid: prepare FID module for client server split Split FID server from client, fid_{handler,store,lib}.c are not compliled unless server support is enabled. Generally cleanup includes in lustre/fid/ and reduce the need for client code to directly or indirectly include {dt,md}_object.h. Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-1330 Lustre-change: http://review.whamcloud.com/2673 Signed-off-by: Liu Xuezhao Signed-off-by: John L. Hammond Reviewed-by: Andreas Dilger Reviewed-by: Nathaniel Clark Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/fid/Makefile | 2 +- .../staging/lustre/lustre/fid/fid_handler.c | 661 ------------------ .../staging/lustre/lustre/fid/fid_internal.h | 36 +- drivers/staging/lustre/lustre/fid/fid_lib.c | 14 +- .../staging/lustre/lustre/fid/fid_request.c | 133 +++- drivers/staging/lustre/lustre/fid/fid_store.c | 259 ------- drivers/staging/lustre/lustre/fid/lproc_fid.c | 3 - .../staging/lustre/lustre/include/lu_object.h | 5 + .../lustre/lustre/include/lustre_fid.h | 24 +- .../staging/lustre/lustre/include/md_object.h | 5 - drivers/staging/lustre/lustre/include/obd.h | 7 +- 11 files changed, 131 insertions(+), 1018 deletions(-) delete mode 100644 drivers/staging/lustre/lustre/fid/fid_handler.c delete mode 100644 drivers/staging/lustre/lustre/fid/fid_store.c diff --git a/drivers/staging/lustre/lustre/fid/Makefile b/drivers/staging/lustre/lustre/fid/Makefile index b8d6d21b39ff8..ed21bea162ba9 100644 --- a/drivers/staging/lustre/lustre/fid/Makefile +++ b/drivers/staging/lustre/lustre/fid/Makefile @@ -1,5 +1,5 @@ obj-$(CONFIG_LUSTRE_FS) += fid.o -fid-y := fid_handler.o fid_store.o fid_request.o lproc_fid.o fid_lib.o +fid-y := fid_request.o lproc_fid.o fid_lib.o ccflags-y := -I$(src)/../include diff --git a/drivers/staging/lustre/lustre/fid/fid_handler.c b/drivers/staging/lustre/lustre/fid/fid_handler.c deleted file mode 100644 index bbbb3cfe57b30..0000000000000 --- a/drivers/staging/lustre/lustre/fid/fid_handler.c +++ /dev/null @@ -1,661 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * 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 version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2011, 2012, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * lustre/fid/fid_handler.c - * - * Lustre Sequence Manager - * - * Author: Yury Umanets - */ - -#define DEBUG_SUBSYSTEM S_FID - -# include -# include - -#include -#include -#include -#include -#include -#include -#include -#include "fid_internal.h" - -int client_fid_init(struct obd_device *obd, - struct obd_export *exp, enum lu_cli_type type) -{ - struct client_obd *cli = &obd->u.cli; - char *prefix; - int rc; - ENTRY; - - OBD_ALLOC_PTR(cli->cl_seq); - if (cli->cl_seq == NULL) - RETURN(-ENOMEM); - - OBD_ALLOC(prefix, MAX_OBD_NAME + 5); - if (prefix == NULL) - GOTO(out_free_seq, rc = -ENOMEM); - - snprintf(prefix, MAX_OBD_NAME + 5, "cli-%s", obd->obd_name); - - /* Init client side sequence-manager */ - rc = seq_client_init(cli->cl_seq, exp, type, prefix, NULL); - OBD_FREE(prefix, MAX_OBD_NAME + 5); - if (rc) - GOTO(out_free_seq, rc); - - RETURN(rc); -out_free_seq: - OBD_FREE_PTR(cli->cl_seq); - cli->cl_seq = NULL; - return rc; -} -EXPORT_SYMBOL(client_fid_init); - -int client_fid_fini(struct obd_device *obd) -{ - struct client_obd *cli = &obd->u.cli; - ENTRY; - - if (cli->cl_seq != NULL) { - seq_client_fini(cli->cl_seq); - OBD_FREE_PTR(cli->cl_seq); - cli->cl_seq = NULL; - } - - RETURN(0); -} -EXPORT_SYMBOL(client_fid_fini); - -static void seq_server_proc_fini(struct lu_server_seq *seq); - -/* Assigns client to sequence controller node. */ -int seq_server_set_cli(struct lu_server_seq *seq, - struct lu_client_seq *cli, - const struct lu_env *env) -{ - int rc = 0; - ENTRY; - - /* - * Ask client for new range, assign that range to ->seq_space and write - * seq state to backing store should be atomic. - */ - mutex_lock(&seq->lss_mutex); - - if (cli == NULL) { - CDEBUG(D_INFO, "%s: Detached sequence client %s\n", - seq->lss_name, cli->lcs_name); - seq->lss_cli = cli; - GOTO(out_up, rc = 0); - } - - if (seq->lss_cli != NULL) { - CDEBUG(D_HA, "%s: Sequence controller is already " - "assigned\n", seq->lss_name); - GOTO(out_up, rc = -EEXIST); - } - - CDEBUG(D_INFO, "%s: Attached sequence controller %s\n", - seq->lss_name, cli->lcs_name); - - seq->lss_cli = cli; - cli->lcs_space.lsr_index = seq->lss_site->ss_node_id; - EXIT; -out_up: - mutex_unlock(&seq->lss_mutex); - return rc; -} -EXPORT_SYMBOL(seq_server_set_cli); -/* - * allocate \a w units of sequence from range \a from. - */ -static inline void range_alloc(struct lu_seq_range *to, - struct lu_seq_range *from, - __u64 width) -{ - width = min(range_space(from), width); - to->lsr_start = from->lsr_start; - to->lsr_end = from->lsr_start + width; - from->lsr_start += width; -} - -/** - * On controller node, allocate new super sequence for regular sequence server. - * As this super sequence controller, this node suppose to maintain fld - * and update index. - * \a out range always has currect mds node number of requester. - */ - -static int __seq_server_alloc_super(struct lu_server_seq *seq, - struct lu_seq_range *out, - const struct lu_env *env) -{ - struct lu_seq_range *space = &seq->lss_space; - int rc; - ENTRY; - - LASSERT(range_is_sane(space)); - - if (range_is_exhausted(space)) { - CERROR("%s: Sequences space is exhausted\n", - seq->lss_name); - RETURN(-ENOSPC); - } else { - range_alloc(out, space, seq->lss_width); - } - - rc = seq_store_update(env, seq, out, 1 /* sync */); - - LCONSOLE_INFO("%s: super-sequence allocation rc = %d " DRANGE"\n", - seq->lss_name, rc, PRANGE(out)); - - RETURN(rc); -} - -int seq_server_alloc_super(struct lu_server_seq *seq, - struct lu_seq_range *out, - const struct lu_env *env) -{ - int rc; - ENTRY; - - mutex_lock(&seq->lss_mutex); - rc = __seq_server_alloc_super(seq, out, env); - mutex_unlock(&seq->lss_mutex); - - RETURN(rc); -} - -static int __seq_set_init(const struct lu_env *env, - struct lu_server_seq *seq) -{ - struct lu_seq_range *space = &seq->lss_space; - int rc; - - range_alloc(&seq->lss_lowater_set, space, seq->lss_set_width); - range_alloc(&seq->lss_hiwater_set, space, seq->lss_set_width); - - rc = seq_store_update(env, seq, NULL, 1); - - return rc; -} - -/* - * This function implements new seq allocation algorithm using async - * updates to seq file on disk. ref bug 18857 for details. - * there are four variable to keep track of this process - * - * lss_space; - available lss_space - * lss_lowater_set; - lu_seq_range for all seqs before barrier, i.e. safe to use - * lss_hiwater_set; - lu_seq_range after barrier, i.e. allocated but may be - * not yet committed - * - * when lss_lowater_set reaches the end it is replaced with hiwater one and - * a write operation is initiated to allocate new hiwater range. - * if last seq write opearion is still not commited, current operation is - * flaged as sync write op. - */ -static int range_alloc_set(const struct lu_env *env, - struct lu_seq_range *out, - struct lu_server_seq *seq) -{ - struct lu_seq_range *space = &seq->lss_space; - struct lu_seq_range *loset = &seq->lss_lowater_set; - struct lu_seq_range *hiset = &seq->lss_hiwater_set; - int rc = 0; - - if (range_is_zero(loset)) - __seq_set_init(env, seq); - - if (OBD_FAIL_CHECK(OBD_FAIL_SEQ_ALLOC)) /* exhaust set */ - loset->lsr_start = loset->lsr_end; - - if (range_is_exhausted(loset)) { - /* reached high water mark. */ - struct lu_device *dev = seq->lss_site->ss_lu->ls_top_dev; - int obd_num_clients = dev->ld_obd->obd_num_exports; - __u64 set_sz; - - /* calculate new seq width based on number of clients */ - set_sz = max(seq->lss_set_width, - obd_num_clients * seq->lss_width); - set_sz = min(range_space(space), set_sz); - - /* Switch to hiwater range now */ - *loset = *hiset; - /* allocate new hiwater range */ - range_alloc(hiset, space, set_sz); - - /* update ondisk seq with new *space */ - rc = seq_store_update(env, seq, NULL, seq->lss_need_sync); - } - - LASSERTF(!range_is_exhausted(loset) || range_is_sane(loset), - DRANGE"\n", PRANGE(loset)); - - if (rc == 0) - range_alloc(out, loset, seq->lss_width); - - RETURN(rc); -} - -static int __seq_server_alloc_meta(struct lu_server_seq *seq, - struct lu_seq_range *out, - const struct lu_env *env) -{ - struct lu_seq_range *space = &seq->lss_space; - int rc = 0; - - ENTRY; - - LASSERT(range_is_sane(space)); - - /* Check if available space ends and allocate new super seq */ - if (range_is_exhausted(space)) { - if (!seq->lss_cli) { - CERROR("%s: No sequence controller is attached.\n", - seq->lss_name); - RETURN(-ENODEV); - } - - rc = seq_client_alloc_super(seq->lss_cli, env); - if (rc) { - CERROR("%s: Can't allocate super-sequence, rc %d\n", - seq->lss_name, rc); - RETURN(rc); - } - - /* Saving new range to allocation space. */ - *space = seq->lss_cli->lcs_space; - LASSERT(range_is_sane(space)); - } - - rc = range_alloc_set(env, out, seq); - if (rc != 0) { - CERROR("%s: Allocated meta-sequence failed: rc = %d\n", - seq->lss_name, rc); - RETURN(rc); - } - - CDEBUG(D_INFO, "%s: Allocated meta-sequence " DRANGE"\n", - seq->lss_name, PRANGE(out)); - - RETURN(rc); -} - -int seq_server_alloc_meta(struct lu_server_seq *seq, - struct lu_seq_range *out, - const struct lu_env *env) -{ - int rc; - ENTRY; - - mutex_lock(&seq->lss_mutex); - rc = __seq_server_alloc_meta(seq, out, env); - mutex_unlock(&seq->lss_mutex); - - RETURN(rc); -} -EXPORT_SYMBOL(seq_server_alloc_meta); - -static int seq_server_handle(struct lu_site *site, - const struct lu_env *env, - __u32 opc, struct lu_seq_range *out) -{ - int rc; - struct seq_server_site *ss_site; - ENTRY; - - ss_site = lu_site2seq(site); - - switch (opc) { - case SEQ_ALLOC_META: - if (!ss_site->ss_server_seq) { - CERROR("Sequence server is not " - "initialized\n"); - RETURN(-EINVAL); - } - rc = seq_server_alloc_meta(ss_site->ss_server_seq, out, env); - break; - case SEQ_ALLOC_SUPER: - if (!ss_site->ss_control_seq) { - CERROR("Sequence controller is not " - "initialized\n"); - RETURN(-EINVAL); - } - rc = seq_server_alloc_super(ss_site->ss_control_seq, out, env); - break; - default: - rc = -EINVAL; - break; - } - - RETURN(rc); -} - -static int seq_req_handle(struct ptlrpc_request *req, - const struct lu_env *env, - struct seq_thread_info *info) -{ - struct lu_seq_range *out, *tmp; - struct lu_site *site; - int rc = -EPROTO; - __u32 *opc; - ENTRY; - - LASSERT(!(lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY)); - site = req->rq_export->exp_obd->obd_lu_dev->ld_site; - LASSERT(site != NULL); - - rc = req_capsule_server_pack(info->sti_pill); - if (rc) - RETURN(err_serious(rc)); - - opc = req_capsule_client_get(info->sti_pill, &RMF_SEQ_OPC); - if (opc != NULL) { - out = req_capsule_server_get(info->sti_pill, &RMF_SEQ_RANGE); - if (out == NULL) - RETURN(err_serious(-EPROTO)); - - tmp = req_capsule_client_get(info->sti_pill, &RMF_SEQ_RANGE); - - /* seq client passed mdt id, we need to pass that using out - * range parameter */ - - out->lsr_index = tmp->lsr_index; - out->lsr_flags = tmp->lsr_flags; - rc = seq_server_handle(site, env, *opc, out); - } else - rc = err_serious(-EPROTO); - - RETURN(rc); -} - -/* context key constructor/destructor: seq_key_init, seq_key_fini */ -LU_KEY_INIT_FINI(seq, struct seq_thread_info); - -/* context key: seq_thread_key */ -LU_CONTEXT_KEY_DEFINE(seq, LCT_MD_THREAD | LCT_DT_THREAD); - -static void seq_thread_info_init(struct ptlrpc_request *req, - struct seq_thread_info *info) -{ - info->sti_pill = &req->rq_pill; - /* Init request capsule */ - req_capsule_init(info->sti_pill, req, RCL_SERVER); - req_capsule_set(info->sti_pill, &RQF_SEQ_QUERY); -} - -static void seq_thread_info_fini(struct seq_thread_info *info) -{ - req_capsule_fini(info->sti_pill); -} - -int seq_handle(struct ptlrpc_request *req) -{ - const struct lu_env *env; - struct seq_thread_info *info; - int rc; - - env = req->rq_svc_thread->t_env; - LASSERT(env != NULL); - - info = lu_context_key_get(&env->le_ctx, &seq_thread_key); - LASSERT(info != NULL); - - seq_thread_info_init(req, info); - rc = seq_req_handle(req, env, info); - /* XXX: we don't need replay but MDT assign transno in any case, - * remove it manually before reply*/ - lustre_msg_set_transno(req->rq_repmsg, 0); - seq_thread_info_fini(info); - - return rc; -} -EXPORT_SYMBOL(seq_handle); - -/* - * Entry point for handling FLD RPCs called from MDT. - */ -int seq_query(struct com_thread_info *info) -{ - return seq_handle(info->cti_pill->rc_req); -} -EXPORT_SYMBOL(seq_query); - - -#ifdef LPROCFS -static int seq_server_proc_init(struct lu_server_seq *seq) -{ - int rc; - ENTRY; - - seq->lss_proc_dir = lprocfs_register(seq->lss_name, - seq_type_proc_dir, - NULL, NULL); - if (IS_ERR(seq->lss_proc_dir)) { - rc = PTR_ERR(seq->lss_proc_dir); - RETURN(rc); - } - - rc = lprocfs_add_vars(seq->lss_proc_dir, - seq_server_proc_list, seq); - if (rc) { - CERROR("%s: Can't init sequence manager " - "proc, rc %d\n", seq->lss_name, rc); - GOTO(out_cleanup, rc); - } - - RETURN(0); - -out_cleanup: - seq_server_proc_fini(seq); - return rc; -} - -static void seq_server_proc_fini(struct lu_server_seq *seq) -{ - ENTRY; - if (seq->lss_proc_dir != NULL) { - if (!IS_ERR(seq->lss_proc_dir)) - lprocfs_remove(&seq->lss_proc_dir); - seq->lss_proc_dir = NULL; - } - EXIT; -} -#else -static int seq_server_proc_init(struct lu_server_seq *seq) -{ - return 0; -} - -static void seq_server_proc_fini(struct lu_server_seq *seq) -{ - return; -} -#endif - - -int seq_server_init(struct lu_server_seq *seq, - struct dt_device *dev, - const char *prefix, - enum lu_mgr_type type, - struct seq_server_site *ss, - const struct lu_env *env) -{ - int rc, is_srv = (type == LUSTRE_SEQ_SERVER); - ENTRY; - - LASSERT(dev != NULL); - LASSERT(prefix != NULL); - LASSERT(ss != NULL); - LASSERT(ss->ss_lu != NULL); - - seq->lss_cli = NULL; - seq->lss_type = type; - seq->lss_site = ss; - range_init(&seq->lss_space); - - range_init(&seq->lss_lowater_set); - range_init(&seq->lss_hiwater_set); - seq->lss_set_width = LUSTRE_SEQ_BATCH_WIDTH; - - mutex_init(&seq->lss_mutex); - - seq->lss_width = is_srv ? - LUSTRE_SEQ_META_WIDTH : LUSTRE_SEQ_SUPER_WIDTH; - - snprintf(seq->lss_name, sizeof(seq->lss_name), - "%s-%s", (is_srv ? "srv" : "ctl"), prefix); - - rc = seq_store_init(seq, env, dev); - if (rc) - GOTO(out, rc); - /* Request backing store for saved sequence info. */ - rc = seq_store_read(seq, env); - if (rc == -ENODATA) { - - /* Nothing is read, init by default value. */ - seq->lss_space = is_srv ? - LUSTRE_SEQ_ZERO_RANGE: - LUSTRE_SEQ_SPACE_RANGE; - - LASSERT(ss != NULL); - seq->lss_space.lsr_index = ss->ss_node_id; - LCONSOLE_INFO("%s: No data found " - "on store. Initialize space\n", - seq->lss_name); - - rc = seq_store_update(env, seq, NULL, 0); - if (rc) { - CERROR("%s: Can't write space data, " - "rc %d\n", seq->lss_name, rc); - } - } else if (rc) { - CERROR("%s: Can't read space data, rc %d\n", - seq->lss_name, rc); - GOTO(out, rc); - } - - if (is_srv) { - LASSERT(range_is_sane(&seq->lss_space)); - } else { - LASSERT(!range_is_zero(&seq->lss_space) && - range_is_sane(&seq->lss_space)); - } - - rc = seq_server_proc_init(seq); - if (rc) - GOTO(out, rc); - - EXIT; -out: - if (rc) - seq_server_fini(seq, env); - return rc; -} -EXPORT_SYMBOL(seq_server_init); - -void seq_server_fini(struct lu_server_seq *seq, - const struct lu_env *env) -{ - ENTRY; - - seq_server_proc_fini(seq); - seq_store_fini(seq, env); - - EXIT; -} -EXPORT_SYMBOL(seq_server_fini); - -int seq_site_fini(const struct lu_env *env, struct seq_server_site *ss) -{ - if (ss == NULL) - RETURN(0); - - if (ss->ss_server_seq) { - seq_server_fini(ss->ss_server_seq, env); - OBD_FREE_PTR(ss->ss_server_seq); - ss->ss_server_seq = NULL; - } - - if (ss->ss_control_seq) { - seq_server_fini(ss->ss_control_seq, env); - OBD_FREE_PTR(ss->ss_control_seq); - ss->ss_control_seq = NULL; - } - - if (ss->ss_client_seq) { - seq_client_fini(ss->ss_client_seq); - OBD_FREE_PTR(ss->ss_client_seq); - ss->ss_client_seq = NULL; - } - - RETURN(0); -} -EXPORT_SYMBOL(seq_site_fini); - -proc_dir_entry_t *seq_type_proc_dir = NULL; - -static int __init fid_mod_init(void) -{ - seq_type_proc_dir = lprocfs_register(LUSTRE_SEQ_NAME, - proc_lustre_root, - NULL, NULL); - if (IS_ERR(seq_type_proc_dir)) - return PTR_ERR(seq_type_proc_dir); - - LU_CONTEXT_KEY_INIT(&seq_thread_key); - lu_context_key_register(&seq_thread_key); - return 0; -} - -static void __exit fid_mod_exit(void) -{ - lu_context_key_degister(&seq_thread_key); - if (seq_type_proc_dir != NULL && !IS_ERR(seq_type_proc_dir)) { - lprocfs_remove(&seq_type_proc_dir); - seq_type_proc_dir = NULL; - } -} - -MODULE_AUTHOR("Sun Microsystems, Inc. "); -MODULE_DESCRIPTION("Lustre FID Module"); -MODULE_LICENSE("GPL"); - -cfs_module(fid, "0.1.0", fid_mod_init, fid_mod_exit); diff --git a/drivers/staging/lustre/lustre/fid/fid_internal.h b/drivers/staging/lustre/lustre/fid/fid_internal.h index 407a7435583f1..1dbe46be0f41b 100644 --- a/drivers/staging/lustre/lustre/fid/fid_internal.h +++ b/drivers/staging/lustre/lustre/fid/fid_internal.h @@ -41,44 +41,16 @@ #define __FID_INTERNAL_H #include -#include - #include -struct seq_thread_info { - struct req_capsule *sti_pill; - struct lu_seq_range sti_space; - struct lu_buf sti_buf; -}; - -enum { - SEQ_TXN_STORE_CREDITS = 20 -}; - -extern struct lu_context_key seq_thread_key; - +/* Functions used internally in module. */ int seq_client_alloc_super(struct lu_client_seq *seq, const struct lu_env *env); -/* Store API functions. */ -int seq_store_init(struct lu_server_seq *seq, - const struct lu_env *env, - struct dt_device *dt); -void seq_store_fini(struct lu_server_seq *seq, - const struct lu_env *env); - -int seq_store_read(struct lu_server_seq *seq, - const struct lu_env *env); - -int seq_store_update(const struct lu_env *env, struct lu_server_seq *seq, - struct lu_seq_range *out, int sync); - -#ifdef LPROCFS -extern struct lprocfs_vars seq_server_proc_list[]; +# ifdef LPROCFS extern struct lprocfs_vars seq_client_proc_list[]; -#endif - +# endif -extern proc_dir_entry_t *seq_type_proc_dir; +extern struct proc_dir_entry *seq_type_proc_dir; #endif /* __FID_INTERNAL_H */ diff --git a/drivers/staging/lustre/lustre/fid/fid_lib.c b/drivers/staging/lustre/lustre/fid/fid_lib.c index eaff51a555fb6..f03afdec027a3 100644 --- a/drivers/staging/lustre/lustre/fid/fid_lib.c +++ b/drivers/staging/lustre/lustre/fid/fid_lib.c @@ -43,11 +43,9 @@ #define DEBUG_SUBSYSTEM S_FID -# include -# include - -#include -#include +#include +#include +#include #include /** @@ -56,9 +54,9 @@ * * Fid namespace: *
- * Normal FID:	seq:64 [2^33,2^64-1]      oid:32	  ver:32
- * IGIF      :	0:32, ino:32	      gen:32	  0:32
- * IDIF      :	0:31, 1:1, ost-index:16,  objd:48	 0:32
+ * Normal FID:        seq:64 [2^33,2^64-1]      oid:32          ver:32
+ * IGIF      :        0:32, ino:32              gen:32          0:32
+ * IDIF      :        0:31, 1:1, ost-index:16,  objd:48         0:32
  * 
* * The first 0x400 sequences of normal FID are reserved for special purpose. diff --git a/drivers/staging/lustre/lustre/fid/fid_request.c b/drivers/staging/lustre/lustre/fid/fid_request.c index fcaaca7e2e013..a279b5ae8e763 100644 --- a/drivers/staging/lustre/lustre/fid/fid_request.c +++ b/drivers/staging/lustre/lustre/fid/fid_request.c @@ -27,7 +27,7 @@ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. * - * Copyright (c) 2011, 2012, Intel Corporation. + * Copyright (c) 2011, 2013, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -42,15 +42,12 @@ #define DEBUG_SUBSYSTEM S_FID -# include -# include +#include +#include #include #include -#include -#include #include -#include #include /* mdc RPC locks */ #include @@ -63,9 +60,9 @@ static int seq_client_rpc(struct lu_client_seq *seq, struct obd_export *exp = seq->lcs_exp; struct ptlrpc_request *req; struct lu_seq_range *out, *in; - __u32 *op; - unsigned int debug_mask; - int rc; + __u32 *op; + unsigned int debug_mask; + int rc; ENTRY; req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_SEQ_QUERY, @@ -153,9 +150,7 @@ int seq_client_alloc_super(struct lu_client_seq *seq, mutex_lock(&seq->lcs_mutex); if (seq->lcs_srv) { - LASSERT(env != NULL); - rc = seq_server_alloc_super(seq->lcs_srv, &seq->lcs_space, - env); + rc = 0; } else { /* Check whether the connection to seq controller has been * setup (lcs_exp != NULL) */ @@ -179,8 +174,7 @@ static int seq_client_alloc_meta(const struct lu_env *env, ENTRY; if (seq->lcs_srv) { - LASSERT(env != NULL); - rc = seq_server_alloc_meta(seq->lcs_srv, &seq->lcs_space, env); + rc = 0; } else { do { /* If meta server return -EINPROGRESS or EAGAIN, @@ -191,6 +185,7 @@ static int seq_client_alloc_meta(const struct lu_env *env, SEQ_ALLOC_META, "meta"); } while (rc == -EINPROGRESS || rc == -EAGAIN); } + RETURN(rc); } @@ -409,11 +404,22 @@ void seq_client_flush(struct lu_client_seq *seq) } EXPORT_SYMBOL(seq_client_flush); -static void seq_client_proc_fini(struct lu_client_seq *seq); - +static void seq_client_proc_fini(struct lu_client_seq *seq) +{ #ifdef LPROCFS + ENTRY; + if (seq->lcs_proc_dir) { + if (!IS_ERR(seq->lcs_proc_dir)) + lprocfs_remove(&seq->lcs_proc_dir); + seq->lcs_proc_dir = NULL; + } + EXIT; +#endif /* LPROCFS */ +} + static int seq_client_proc_init(struct lu_client_seq *seq) { +#ifdef LPROCFS int rc; ENTRY; @@ -441,29 +447,11 @@ static int seq_client_proc_init(struct lu_client_seq *seq) out_cleanup: seq_client_proc_fini(seq); return rc; -} -static void seq_client_proc_fini(struct lu_client_seq *seq) -{ - ENTRY; - if (seq->lcs_proc_dir) { - if (!IS_ERR(seq->lcs_proc_dir)) - lprocfs_remove(&seq->lcs_proc_dir); - seq->lcs_proc_dir = NULL; - } - EXIT; -} -#else -static int seq_client_proc_init(struct lu_client_seq *seq) -{ +#else /* LPROCFS */ return 0; -} - -static void seq_client_proc_fini(struct lu_client_seq *seq) -{ - return; -} #endif +} int seq_client_init(struct lu_client_seq *seq, struct obd_export *exp, @@ -520,3 +508,76 @@ void seq_client_fini(struct lu_client_seq *seq) EXIT; } EXPORT_SYMBOL(seq_client_fini); + +int client_fid_init(struct obd_device *obd, + struct obd_export *exp, enum lu_cli_type type) +{ + struct client_obd *cli = &obd->u.cli; + char *prefix; + int rc; + ENTRY; + + OBD_ALLOC_PTR(cli->cl_seq); + if (cli->cl_seq == NULL) + RETURN(-ENOMEM); + + OBD_ALLOC(prefix, MAX_OBD_NAME + 5); + if (prefix == NULL) + GOTO(out_free_seq, rc = -ENOMEM); + + snprintf(prefix, MAX_OBD_NAME + 5, "cli-%s", obd->obd_name); + + /* Init client side sequence-manager */ + rc = seq_client_init(cli->cl_seq, exp, type, prefix, NULL); + OBD_FREE(prefix, MAX_OBD_NAME + 5); + if (rc) + GOTO(out_free_seq, rc); + + RETURN(rc); +out_free_seq: + OBD_FREE_PTR(cli->cl_seq); + cli->cl_seq = NULL; + return rc; +} +EXPORT_SYMBOL(client_fid_init); + +int client_fid_fini(struct obd_device *obd) +{ + struct client_obd *cli = &obd->u.cli; + ENTRY; + + if (cli->cl_seq != NULL) { + seq_client_fini(cli->cl_seq); + OBD_FREE_PTR(cli->cl_seq); + cli->cl_seq = NULL; + } + + RETURN(0); +} +EXPORT_SYMBOL(client_fid_fini); + +struct proc_dir_entry *seq_type_proc_dir; + +static int __init fid_mod_init(void) +{ + seq_type_proc_dir = lprocfs_register(LUSTRE_SEQ_NAME, + proc_lustre_root, + NULL, NULL); + if (IS_ERR(seq_type_proc_dir)) + return PTR_ERR(seq_type_proc_dir); + return 0; +} + +static void __exit fid_mod_exit(void) +{ + if (seq_type_proc_dir != NULL && !IS_ERR(seq_type_proc_dir)) { + lprocfs_remove(&seq_type_proc_dir); + seq_type_proc_dir = NULL; + } +} + +MODULE_AUTHOR("Sun Microsystems, Inc. "); +MODULE_DESCRIPTION("Lustre FID Module"); +MODULE_LICENSE("GPL"); + +cfs_module(fid, "0.1.0", fid_mod_init, fid_mod_exit); diff --git a/drivers/staging/lustre/lustre/fid/fid_store.c b/drivers/staging/lustre/lustre/fid/fid_store.c deleted file mode 100644 index a90e6e37d6899..0000000000000 --- a/drivers/staging/lustre/lustre/fid/fid_store.c +++ /dev/null @@ -1,259 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * 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 version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2011, 2013, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * lustre/fid/fid_store.c - * - * Lustre Sequence Manager - * - * Author: Yury Umanets - */ - -#define DEBUG_SUBSYSTEM S_FID - -# include -# include - -#include -#include -#include -#include -#include -#include -#include -#include "fid_internal.h" - - -static struct lu_buf *seq_store_buf(struct seq_thread_info *info) -{ - struct lu_buf *buf; - - buf = &info->sti_buf; - buf->lb_buf = &info->sti_space; - buf->lb_len = sizeof(info->sti_space); - return buf; -} - -struct seq_update_callback { - struct dt_txn_commit_cb suc_cb; - struct lu_server_seq *suc_seq; -}; - -void seq_update_cb(struct lu_env *env, struct thandle *th, - struct dt_txn_commit_cb *cb, int err) -{ - struct seq_update_callback *ccb; - - ccb = container_of0(cb, struct seq_update_callback, suc_cb); - - LASSERT(ccb->suc_seq != NULL); - - ccb->suc_seq->lss_need_sync = 0; - OBD_FREE_PTR(ccb); -} - -int seq_update_cb_add(struct thandle *th, struct lu_server_seq *seq) -{ - struct seq_update_callback *ccb; - struct dt_txn_commit_cb *dcb; - int rc; - - OBD_ALLOC_PTR(ccb); - if (ccb == NULL) - return -ENOMEM; - - ccb->suc_seq = seq; - seq->lss_need_sync = 1; - - dcb = &ccb->suc_cb; - dcb->dcb_func = seq_update_cb; - INIT_LIST_HEAD(&dcb->dcb_linkage); - strncpy(dcb->dcb_name, "seq_update_cb", MAX_COMMIT_CB_STR_LEN); - dcb->dcb_name[MAX_COMMIT_CB_STR_LEN - 1] = '\0'; - - rc = dt_trans_cb_add(th, dcb); - if (rc) - OBD_FREE_PTR(ccb); - return rc; -} - -/* This function implies that caller takes care about locking. */ -int seq_store_update(const struct lu_env *env, struct lu_server_seq *seq, - struct lu_seq_range *out, int sync) -{ - struct dt_device *dt_dev = lu2dt_dev(seq->lss_obj->do_lu.lo_dev); - struct seq_thread_info *info; - struct thandle *th; - loff_t pos = 0; - int rc; - - info = lu_context_key_get(&env->le_ctx, &seq_thread_key); - LASSERT(info != NULL); - - th = dt_trans_create(env, dt_dev); - if (IS_ERR(th)) - RETURN(PTR_ERR(th)); - - rc = dt_declare_record_write(env, seq->lss_obj, - sizeof(struct lu_seq_range), 0, th); - if (rc) - GOTO(exit, rc); - - if (out != NULL) { - rc = fld_declare_server_create(env, - seq->lss_site->ss_server_fld, - out, th); - if (rc) - GOTO(exit, rc); - } - - rc = dt_trans_start_local(env, dt_dev, th); - if (rc) - GOTO(exit, rc); - - /* Store ranges in le format. */ - range_cpu_to_le(&info->sti_space, &seq->lss_space); - - rc = dt_record_write(env, seq->lss_obj, seq_store_buf(info), &pos, th); - if (rc) { - CERROR("%s: Can't write space data, rc %d\n", - seq->lss_name, rc); - GOTO(exit, rc); - } else if (out != NULL) { - rc = fld_server_create(env, seq->lss_site->ss_server_fld, out, - th); - if (rc) { - CERROR("%s: Can't Update fld database, rc %d\n", - seq->lss_name, rc); - GOTO(exit, rc); - } - } - /* next sequence update will need sync until this update is committed - * in case of sync operation this is not needed obviously */ - if (!sync) - /* if callback can't be added then sync always */ - sync = !!seq_update_cb_add(th, seq); - - th->th_sync |= sync; -exit: - dt_trans_stop(env, dt_dev, th); - return rc; -} - -/* - * This function implies that caller takes care about locking or locking is not - * needed (init time). - */ -int seq_store_read(struct lu_server_seq *seq, - const struct lu_env *env) -{ - struct seq_thread_info *info; - loff_t pos = 0; - int rc; - ENTRY; - - info = lu_context_key_get(&env->le_ctx, &seq_thread_key); - LASSERT(info != NULL); - - rc = seq->lss_obj->do_body_ops->dbo_read(env, seq->lss_obj, - seq_store_buf(info), - &pos, BYPASS_CAPA); - - if (rc == sizeof(info->sti_space)) { - range_le_to_cpu(&seq->lss_space, &info->sti_space); - CDEBUG(D_INFO, "%s: Space - "DRANGE"\n", - seq->lss_name, PRANGE(&seq->lss_space)); - rc = 0; - } else if (rc == 0) { - rc = -ENODATA; - } else if (rc > 0) { - CERROR("%s: Read only %d bytes of %d\n", seq->lss_name, - rc, (int)sizeof(info->sti_space)); - rc = -EIO; - } - - RETURN(rc); -} - -int seq_store_init(struct lu_server_seq *seq, - const struct lu_env *env, - struct dt_device *dt) -{ - struct dt_object *dt_obj; - struct lu_fid fid; - struct lu_attr attr; - struct dt_object_format dof; - const char *name; - int rc; - ENTRY; - - name = seq->lss_type == LUSTRE_SEQ_SERVER ? - LUSTRE_SEQ_SRV_NAME : LUSTRE_SEQ_CTL_NAME; - - if (seq->lss_type == LUSTRE_SEQ_SERVER) - lu_local_obj_fid(&fid, FID_SEQ_SRV_OID); - else - lu_local_obj_fid(&fid, FID_SEQ_CTL_OID); - - memset(&attr, 0, sizeof(attr)); - attr.la_valid = LA_MODE; - attr.la_mode = S_IFREG | 0666; - dof.dof_type = DFT_REGULAR; - - dt_obj = dt_find_or_create(env, dt, &fid, &dof, &attr); - if (!IS_ERR(dt_obj)) { - seq->lss_obj = dt_obj; - rc = 0; - } else { - CERROR("%s: Can't find \"%s\" obj %d\n", - seq->lss_name, name, (int)PTR_ERR(dt_obj)); - rc = PTR_ERR(dt_obj); - } - - RETURN(rc); -} - -void seq_store_fini(struct lu_server_seq *seq, - const struct lu_env *env) -{ - ENTRY; - - if (seq->lss_obj != NULL) { - if (!IS_ERR(seq->lss_obj)) - lu_object_put(env, &seq->lss_obj->do_lu); - seq->lss_obj = NULL; - } - - EXIT; -} diff --git a/drivers/staging/lustre/lustre/fid/lproc_fid.c b/drivers/staging/lustre/lustre/fid/lproc_fid.c index af817a867f8b1..20d04488c04f1 100644 --- a/drivers/staging/lustre/lustre/fid/lproc_fid.c +++ b/drivers/staging/lustre/lustre/fid/lproc_fid.c @@ -204,9 +204,6 @@ lprocfs_fid_server_seq_show(struct seq_file *m, void *unused) RETURN(rc); } -struct lprocfs_vars seq_server_proc_list[] = { -}; - LPROC_SEQ_FOPS(lprocfs_fid_space); LPROC_SEQ_FOPS(lprocfs_fid_width); LPROC_SEQ_FOPS_RO(lprocfs_fid_server); diff --git a/drivers/staging/lustre/lustre/include/lu_object.h b/drivers/staging/lustre/lustre/include/lu_object.h index d40ad81b4eb2c..94760481bd30c 100644 --- a/drivers/staging/lustre/lustre/include/lu_object.h +++ b/drivers/staging/lustre/lustre/include/lu_object.h @@ -665,6 +665,11 @@ lu_site_bkt_from_fid(struct lu_site *site, struct lu_fid *fid) return cfs_hash_bd_extra_get(site->ls_obj_hash, &bd); } +static inline struct seq_server_site *lu_site2seq(const struct lu_site *s) +{ + return s->ld_seq_site; +} + /** \name ctors * Constructors/destructors. * @{ diff --git a/drivers/staging/lustre/lustre/include/lustre_fid.h b/drivers/staging/lustre/lustre/include/lustre_fid.h index 7523b407488e1..f8f35c3fa091a 100644 --- a/drivers/staging/lustre/lustre/include/lustre_fid.h +++ b/drivers/staging/lustre/lustre/include/lustre_fid.h @@ -38,8 +38,8 @@ * Author: Yury Umanets */ -#ifndef __LINUX_FID_H -#define __LINUX_FID_H +#ifndef __LUSTRE_FID_H +#define __LUSTRE_FID_H /** \defgroup fid fid * @@ -154,13 +154,12 @@ #include #include -#include -#include -#include - +struct lu_env; struct lu_site; struct lu_context; +struct obd_device; +struct obd_export; /* Whole sequences space range and zero range definitions */ extern const struct lu_seq_range LUSTRE_SEQ_SPACE_RANGE; @@ -320,6 +319,12 @@ static inline void lu_last_id_fid(struct lu_fid *fid, __u64 seq) fid->f_ver = 0; } +/* seq client type */ +enum lu_cli_type { + LUSTRE_SEQ_METADATA = 1, + LUSTRE_SEQ_DATA +}; + enum lu_mgr_type { LUSTRE_SEQ_SERVER, LUSTRE_SEQ_CONTROLLER @@ -426,10 +431,14 @@ struct lu_server_seq { struct seq_server_site *lss_site; }; +struct com_thread_info; int seq_query(struct com_thread_info *info); + +struct ptlrpc_request; int seq_handle(struct ptlrpc_request *req); /* Server methods */ + int seq_server_init(struct lu_server_seq *seq, struct dt_device *dev, const char *prefix, @@ -472,6 +481,7 @@ int seq_site_fini(const struct lu_env *env, struct seq_server_site *ss); int fid_is_local(const struct lu_env *env, struct lu_site *site, const struct lu_fid *fid); +enum lu_cli_type; int client_fid_init(struct obd_device *obd, struct obd_export *exp, enum lu_cli_type type); int client_fid_fini(struct obd_device *obd); @@ -760,4 +770,4 @@ static inline void range_be_to_cpu(struct lu_seq_range *dst, const struct lu_seq /** @} fid */ -#endif /* __LINUX_FID_H */ +#endif /* __LUSTRE_FID_H */ diff --git a/drivers/staging/lustre/lustre/include/md_object.h b/drivers/staging/lustre/lustre/include/md_object.h index 92d6420b21daa..65b270a6d5909 100644 --- a/drivers/staging/lustre/lustre/include/md_object.h +++ b/drivers/staging/lustre/lustre/include/md_object.h @@ -503,11 +503,6 @@ static inline struct md_device *md_obj2dev(const struct md_object *o) return container_of0(o->mo_lu.lo_dev, struct md_device, md_lu_dev); } -static inline struct seq_server_site *lu_site2seq(const struct lu_site *s) -{ - return s->ld_seq_site; -} - static inline int md_device_init(struct md_device *md, struct lu_device_type *t) { return lu_device_init(&md->md_lu_dev, t); diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index 11d10fe682d00..fbf997ffa9276 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -52,6 +52,7 @@ #include #include #include +#include #include #include @@ -1232,12 +1233,6 @@ typedef int (* md_enqueue_cb_t)(struct ptlrpc_request *req, struct md_enqueue_info *minfo, int rc); -/* seq client type */ -enum lu_cli_type { - LUSTRE_SEQ_METADATA = 1, - LUSTRE_SEQ_DATA -}; - struct md_enqueue_info { struct md_op_data mi_data; struct lookup_intent mi_it; -- GitLab From e2335e5d52b271dcc907db750b66aed6c021b594 Mon Sep 17 00:00:00 2001 From: jcl Date: Tue, 23 Jul 2013 00:06:45 +0800 Subject: [PATCH 042/942] staging/lustre/llite: force lvb_data update after layout change When a file is restored the layout lock is first associated with the released layout and after restore it has to be assocaited with the new layout. This patch forces lvb_data update in ll_layout_fetch() even if one is present (case for released->normal state change) Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3299 Lustre-change: http://review.whamcloud.com/6291 Signed-off-by: JC Lafoucriere Reviewed-by: Jinshan Xiong Reviewed-by: Johann Lombardi Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/file.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 549384582d498..b1df7f52ffec7 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -2941,7 +2941,11 @@ static int ll_layout_fetch(struct inode *inode, struct ldlm_lock *lock) int rc; ENTRY; - if (lock->l_lvb_data != NULL) + CDEBUG(D_INODE, DFID" LVB_READY=%d l_lvb_data=%p l_lvb_len=%d\n", + PFID(ll_inode2fid(inode)), !!(lock->l_flags & LDLM_FL_LVB_READY), + lock->l_lvb_data, lock->l_lvb_len); + + if ((lock->l_lvb_data != NULL) && (lock->l_flags & LDLM_FL_LVB_READY)) RETURN(0); /* if layout lock was granted right away, the layout is returned @@ -2977,15 +2981,13 @@ static int ll_layout_fetch(struct inode *inode, struct ldlm_lock *lock) memcpy(lvbdata, lmm, lmmsize); lock_res_and_lock(lock); - if (lock->l_lvb_data == NULL) { - lock->l_lvb_data = lvbdata; - lock->l_lvb_len = lmmsize; - lvbdata = NULL; - } + if (lock->l_lvb_data != NULL) + OBD_FREE_LARGE(lock->l_lvb_data, lock->l_lvb_len); + + lock->l_lvb_data = lvbdata; + lock->l_lvb_len = lmmsize; unlock_res_and_lock(lock); - if (lvbdata != NULL) - OBD_FREE_LARGE(lvbdata, lmmsize); EXIT; out: @@ -3017,7 +3019,7 @@ static int ll_layout_lock_set(struct lustre_handle *lockh, ldlm_mode_t mode, LASSERT(ldlm_has_layout(lock)); LDLM_DEBUG(lock, "File %p/"DFID" being reconfigured: %d.\n", - inode, PFID(&lli->lli_fid), reconf); + inode, PFID(&lli->lli_fid), reconf); /* in case this is a caching lock and reinstate with new inode */ md_set_lock_data(sbi->ll_md_exp, &lockh->cookie, inode, NULL); -- GitLab From c6c9f60d9d537e9c05c8667f60eac88be269343a Mon Sep 17 00:00:00 2001 From: Fan Yong Date: Tue, 23 Jul 2013 00:06:46 +0800 Subject: [PATCH 043/942] staging/lustre/lfsck: LFSCK 1.5 technical debts (3) Original patch resolves some LFSCK 1.5 technical debts, including: 1) Check and remove repeated linkea entries. 2) Merge some "goto" branches to make the code more readable. 3) Some comments about object's nlink inconsistency processing. This patch picks the obd flags change. Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2915 Lustre-change: http://review.whamcloud.com/6344 Signed-off-by: Fan Yong Reviewed-by: Alex Zhuravlev Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/obd_support.h | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/lustre/lustre/include/obd_support.h b/drivers/staging/lustre/lustre/include/obd_support.h index b5d40afc3599a..03e6133ef50fc 100644 --- a/drivers/staging/lustre/lustre/include/obd_support.h +++ b/drivers/staging/lustre/lustre/include/obd_support.h @@ -470,6 +470,7 @@ int obd_alloc_fail(const void *ptr, const char *name, const char *type, #define OBD_FAIL_LFSCK_DELAY3 0x1602 #define OBD_FAIL_LFSCK_LINKEA_CRASH 0x1603 #define OBD_FAIL_LFSCK_LINKEA_MORE 0x1604 +#define OBD_FAIL_LFSCK_LINKEA_MORE2 0x1605 #define OBD_FAIL_LFSCK_FATAL1 0x1608 #define OBD_FAIL_LFSCK_FATAL2 0x1609 #define OBD_FAIL_LFSCK_CRASH 0x160a -- GitLab From a55e0f44cf360a2f466b4599ec107fae4bafae64 Mon Sep 17 00:00:00 2001 From: Keith Mannthey Date: Tue, 23 Jul 2013 00:06:47 +0800 Subject: [PATCH 044/942] staging/lustre/osc: Check return code for lu_kmem_init lu_kmem_init can fail and returns has a return code. Check for this return code in lu_kmem_init. This issue was found during 2gb VM Racer testing Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3063 Lustre-change: http://review.whamcloud.com/6514 Signed-off-by: Keith Mannthey Reviewed-by: Mike Pershin Reviewed-by: Nathaniel Clark Reviewed-by: Bob Glossman Reviewed-by: Oleg Drokin Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/osc/osc_request.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 0c0e07b6f18eb..fea04ca8ba6a8 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -3681,6 +3681,8 @@ int __init osc_init(void) CDEBUG(D_INFO, "Lustre OSC module (%p).\n", &osc_caches); rc = lu_kmem_init(osc_caches); + if (rc) + RETURN(rc); lprocfs_osc_init_vars(&lvars); -- GitLab From 5be8e0702619eb3e77ec41c3b8825d0bbdfd8cda Mon Sep 17 00:00:00 2001 From: Hiroya Nozaki Date: Tue, 23 Jul 2013 00:06:48 +0800 Subject: [PATCH 045/942] staging/lustre/ptlrpc: Race between start and stop service threads When ptlrpc_start_thread fails to create a new thread, it will finalize and free a struct ptlrpc_thread created and used here. Considering this, it can be a problem when ptlrpc_svcpt_stop_thread is driven and handles the struct ptlrpc_thread right after or right before failure of cfs_create_thread. Because this situation let the both of ptlrpc_start_thread and ptlrpc_svcpt_stop_threads access the freed ptlrpc_thread and cause OS panic. Or, it may happen that ptlrpc_svcpt_stop_threads waits forever holding an already-freed waitq. This patch adds an error handling into ptlrpc_start_thread to fix this problem. Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2889 Lustre-change: http://review.whamcloud.com/5552 Signed-off-by: Hiroya Nozaki Reviewed-by: Liang Zhen Reviewed-by: Nikitas Angelinas Reviewed-by: Keith Mannthey Reviewed-by: Oleg Drokin Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ptlrpc/service.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index 6871711023190..87bd63858b1c4 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -2765,11 +2765,19 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait) CERROR("cannot start thread '%s': rc %d\n", thread->t_name, rc); spin_lock(&svcpt->scp_lock); - list_del(&thread->t_link); --svcpt->scp_nthrs_starting; - spin_unlock(&svcpt->scp_lock); - - OBD_FREE(thread, sizeof(*thread)); + if (thread_is_stopping(thread)) { + /* this ptlrpc_thread is being hanled + * by ptlrpc_svcpt_stop_threads now + */ + thread_add_flags(thread, SVC_STOPPED); + wake_up(&thread->t_ctl_waitq); + spin_unlock(&svcpt->scp_lock); + } else { + list_del(&thread->t_link); + spin_unlock(&svcpt->scp_lock); + OBD_FREE_PTR(thread); + } RETURN(rc); } -- GitLab From 7045b388be0d0d96dc30f7ad10a062feb23bc95e Mon Sep 17 00:00:00 2001 From: "Alexander.Boyko" Date: Tue, 23 Jul 2013 00:06:49 +0800 Subject: [PATCH 046/942] staging/lustre/crypto: add crc32c module loading to libcfs This patch add automatically module loading for crc32c when libcfs is starting. Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2212 Lustre-change: http://review.whamcloud.com/4372 Signed-off-by: Alexander Boyko Reviewed-by: Andreas Dilger Reviewed-by: Shuichi Ihara Reviewed-by: James Simmons Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/libcfs/linux/linux-crypto.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto.c index 8e35777b4da5f..b6c79bc177adc 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-crypto.c @@ -274,6 +274,8 @@ static int adler32; int cfs_crypto_register(void) { + request_module("crc32c"); + adler32 = cfs_crypto_adler32_register(); /* check all algorithms and do performance test */ -- GitLab From ce74f92d97080b1e6cc72d3b1d06cc06d11fbe67 Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Tue, 23 Jul 2013 00:06:50 +0800 Subject: [PATCH 047/942] staging/lustre/mdt: duplicate link names in directory When creating a hard link to a file, the MDT/MDD/OSD code does not verify whether the target link name already exists in the directory. The ZFS ZAP code checks for duplicate entries. The add_dirent_to_buf() function in ldiskfs only checks entries for duplicates while it is traversing the leaf block looking for free space. Even if it scanned the whole leaf block, this would not work for non-htree directories since there is no guarantee that the name is being inserted into the same leaf block. To fix this, link should check target object doesn't exist as other creat operations. Add sanity.sh test_31o with multiple threads racing to link a new name into the directory, while ensuring that there is a free entry in the leaf block that is large enough to hold the duplicate name. This needs to be racy, because otherwise the client VFS will see the existing name and not send the RPC to the MDS, hiding the bug. Add DLDLMRES/PLDLMRES macros for printing the whole lock resource name (including the name hash) in LDLM_DEBUG() messages in a format similar to DFID/PFID so they can be found in debug logs more easily. The patch pickes client side change of the original patch, which only contains the DLM printk part. Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2901 Lustre-change: http://review.whamcloud.com/6591 Signed-off-by: Andreas Dilger Signed-off-by: Lai Siyao Reviewed-by: Alex Zhuravlev Reviewed-by: Mike Pershin Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/include/lustre/lustre_idl.h | 4 + .../staging/lustre/lustre/ldlm/ldlm_lock.c | 145 +++++++++--------- 2 files changed, 76 insertions(+), 73 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h index ace4e18dfae8e..3aaa869b711f3 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h @@ -2690,6 +2690,10 @@ struct ldlm_res_id { __u64 name[RES_NAME_SIZE]; }; +#define DLDLMRES "["LPX64":"LPX64":"LPX64"]."LPX64i +#define PLDLMRES(res) (res)->lr_name.name[0], (res)->lr_name.name[1], \ + (res)->lr_name.name[2], (res)->lr_name.name[3] + extern void lustre_swab_ldlm_res_id (struct ldlm_res_id *id); static inline int ldlm_res_eq(const struct ldlm_res_id *res0, diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index c10ba9c33f42a..ce1add149f525 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -2336,91 +2336,90 @@ void _ldlm_lock_debug(struct ldlm_lock *lock, switch (resource->lr_type) { case LDLM_EXTENT: libcfs_debug_vmsg2(msgdata, fmt, args, - " ns: %s lock: %p/"LPX64" lrc: %d/%d,%d mode: %s/%s " - "res: "LPU64"/"LPU64" rrc: %d type: %s ["LPU64"->"LPU64 - "] (req "LPU64"->"LPU64") flags: "LPX64" nid: %s remote:" - " "LPX64" expref: %d pid: %u timeout: %lu lvb_type: %d\n", - ldlm_lock_to_ns_name(lock), lock, - lock->l_handle.h_cookie, atomic_read(&lock->l_refc), - lock->l_readers, lock->l_writers, - ldlm_lockname[lock->l_granted_mode], - ldlm_lockname[lock->l_req_mode], - resource->lr_name.name[0], - resource->lr_name.name[1], - atomic_read(&resource->lr_refcount), - ldlm_typename[resource->lr_type], - lock->l_policy_data.l_extent.start, - lock->l_policy_data.l_extent.end, - lock->l_req_extent.start, lock->l_req_extent.end, - lock->l_flags, nid, lock->l_remote_handle.cookie, - exp ? atomic_read(&exp->exp_refcount) : -99, - lock->l_pid, lock->l_callback_timeout, lock->l_lvb_type); + " ns: %s lock: %p/"LPX64" lrc: %d/%d,%d mode: %s/%s " + "res: "DLDLMRES" rrc: %d type: %s ["LPU64"->"LPU64"] " + "(req "LPU64"->"LPU64") flags: "LPX64" nid: %s remote: " + LPX64" expref: %d pid: %u timeout: %lu lvb_type: %d\n", + ldlm_lock_to_ns_name(lock), lock, + lock->l_handle.h_cookie, atomic_read(&lock->l_refc), + lock->l_readers, lock->l_writers, + ldlm_lockname[lock->l_granted_mode], + ldlm_lockname[lock->l_req_mode], + PLDLMRES(resource), + atomic_read(&resource->lr_refcount), + ldlm_typename[resource->lr_type], + lock->l_policy_data.l_extent.start, + lock->l_policy_data.l_extent.end, + lock->l_req_extent.start, lock->l_req_extent.end, + lock->l_flags, nid, lock->l_remote_handle.cookie, + exp ? atomic_read(&exp->exp_refcount) : -99, + lock->l_pid, lock->l_callback_timeout, + lock->l_lvb_type); break; case LDLM_FLOCK: libcfs_debug_vmsg2(msgdata, fmt, args, - " ns: %s lock: %p/"LPX64" lrc: %d/%d,%d mode: %s/%s " - "res: "LPU64"/"LPU64" rrc: %d type: %s pid: %d " - "["LPU64"->"LPU64"] flags: "LPX64" nid: %s remote: "LPX64 - " expref: %d pid: %u timeout: %lu\n", - ldlm_lock_to_ns_name(lock), lock, - lock->l_handle.h_cookie, atomic_read(&lock->l_refc), - lock->l_readers, lock->l_writers, - ldlm_lockname[lock->l_granted_mode], - ldlm_lockname[lock->l_req_mode], - resource->lr_name.name[0], - resource->lr_name.name[1], - atomic_read(&resource->lr_refcount), - ldlm_typename[resource->lr_type], - lock->l_policy_data.l_flock.pid, - lock->l_policy_data.l_flock.start, - lock->l_policy_data.l_flock.end, - lock->l_flags, nid, lock->l_remote_handle.cookie, - exp ? atomic_read(&exp->exp_refcount) : -99, - lock->l_pid, lock->l_callback_timeout); + " ns: %s lock: %p/"LPX64" lrc: %d/%d,%d mode: %s/%s " + "res: "DLDLMRES" rrc: %d type: %s pid: %d " + "["LPU64"->"LPU64"] flags: "LPX64" nid: %s " + "remote: "LPX64" expref: %d pid: %u timeout: %lu\n", + ldlm_lock_to_ns_name(lock), lock, + lock->l_handle.h_cookie, atomic_read(&lock->l_refc), + lock->l_readers, lock->l_writers, + ldlm_lockname[lock->l_granted_mode], + ldlm_lockname[lock->l_req_mode], + PLDLMRES(resource), + atomic_read(&resource->lr_refcount), + ldlm_typename[resource->lr_type], + lock->l_policy_data.l_flock.pid, + lock->l_policy_data.l_flock.start, + lock->l_policy_data.l_flock.end, + lock->l_flags, nid, lock->l_remote_handle.cookie, + exp ? atomic_read(&exp->exp_refcount) : -99, + lock->l_pid, lock->l_callback_timeout); break; case LDLM_IBITS: libcfs_debug_vmsg2(msgdata, fmt, args, - " ns: %s lock: %p/"LPX64" lrc: %d/%d,%d mode: %s/%s " - "res: "LPU64"/"LPU64" bits "LPX64" rrc: %d type: %s " - "flags: "LPX64" nid: %s remote: "LPX64" expref: %d " - "pid: %u timeout: %lu lvb_type: %d\n", - ldlm_lock_to_ns_name(lock), - lock, lock->l_handle.h_cookie, - atomic_read (&lock->l_refc), - lock->l_readers, lock->l_writers, - ldlm_lockname[lock->l_granted_mode], - ldlm_lockname[lock->l_req_mode], - resource->lr_name.name[0], - resource->lr_name.name[1], - lock->l_policy_data.l_inodebits.bits, - atomic_read(&resource->lr_refcount), - ldlm_typename[resource->lr_type], - lock->l_flags, nid, lock->l_remote_handle.cookie, - exp ? atomic_read(&exp->exp_refcount) : -99, - lock->l_pid, lock->l_callback_timeout, lock->l_lvb_type); + " ns: %s lock: %p/"LPX64" lrc: %d/%d,%d mode: %s/%s " + "res: "DLDLMRES" bits "LPX64" rrc: %d type: %s " + "flags: "LPX64" nid: %s remote: "LPX64" expref: %d " + "pid: %u timeout: %lu lvb_type: %d\n", + ldlm_lock_to_ns_name(lock), + lock, lock->l_handle.h_cookie, + atomic_read(&lock->l_refc), + lock->l_readers, lock->l_writers, + ldlm_lockname[lock->l_granted_mode], + ldlm_lockname[lock->l_req_mode], + PLDLMRES(resource), + lock->l_policy_data.l_inodebits.bits, + atomic_read(&resource->lr_refcount), + ldlm_typename[resource->lr_type], + lock->l_flags, nid, lock->l_remote_handle.cookie, + exp ? atomic_read(&exp->exp_refcount) : -99, + lock->l_pid, lock->l_callback_timeout, + lock->l_lvb_type); break; default: libcfs_debug_vmsg2(msgdata, fmt, args, - " ns: %s lock: %p/"LPX64" lrc: %d/%d,%d mode: %s/%s " - "res: "LPU64"/"LPU64" rrc: %d type: %s flags: "LPX64" " - "nid: %s remote: "LPX64" expref: %d pid: %u timeout: %lu" - "lvb_type: %d\n", - ldlm_lock_to_ns_name(lock), - lock, lock->l_handle.h_cookie, - atomic_read (&lock->l_refc), - lock->l_readers, lock->l_writers, - ldlm_lockname[lock->l_granted_mode], - ldlm_lockname[lock->l_req_mode], - resource->lr_name.name[0], - resource->lr_name.name[1], - atomic_read(&resource->lr_refcount), - ldlm_typename[resource->lr_type], - lock->l_flags, nid, lock->l_remote_handle.cookie, - exp ? atomic_read(&exp->exp_refcount) : -99, - lock->l_pid, lock->l_callback_timeout, lock->l_lvb_type); + " ns: %s lock: %p/"LPX64" lrc: %d/%d,%d mode: %s/%s " + "res: "DLDLMRES" rrc: %d type: %s flags: "LPX64" " + "nid: %s remote: "LPX64" expref: %d pid: %u " + "timeout: %lu lvb_type: %d\n", + ldlm_lock_to_ns_name(lock), + lock, lock->l_handle.h_cookie, + atomic_read(&lock->l_refc), + lock->l_readers, lock->l_writers, + ldlm_lockname[lock->l_granted_mode], + ldlm_lockname[lock->l_req_mode], + PLDLMRES(resource), + atomic_read(&resource->lr_refcount), + ldlm_typename[resource->lr_type], + lock->l_flags, nid, lock->l_remote_handle.cookie, + exp ? atomic_read(&exp->exp_refcount) : -99, + lock->l_pid, lock->l_callback_timeout, + lock->l_lvb_type); break; } va_end(args); -- GitLab From 251c4317b3219eeacd800d167c105121ed9be188 Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Tue, 23 Jul 2013 00:06:51 +0800 Subject: [PATCH 048/942] staging/lustre/llite: call simple_setattr() from ll_md_setattr() This partially reverts the change from "LU-2482 layout: introduce new layout for released files" by calling simple_setattr() from ll_md_setattr() without ATTR_SIZE set. Doing so avoids failed assertions in osc_page_delete(). Disable truncates on released files and modify sanity 229 accordingly. Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3448 Lustre-change: http://review.whamcloud.com/6643 Signed-off-by: John L. Hammond Reviewed-by: jacques-Charles Lafoucriere Reviewed-by: Jinshan Xiong Reviewed-by: Oleg Drokin Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lustre/llite/llite_lib.c | 18 ++++++++---------- drivers/staging/lustre/lustre/lov/lov_io.c | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index b9cbe9505d4a3..39d519b30cb4d 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -1282,6 +1282,13 @@ int ll_md_setattr(struct dentry *dentry, struct md_op_data *op_data, RETURN(rc); } + ia_valid = op_data->op_attr.ia_valid; + /* inode size will be in ll_setattr_ost, can't do it now since dirty + * cache is not cleared yet. */ + op_data->op_attr.ia_valid &= ~(TIMES_SET_FLAGS | ATTR_SIZE); + rc = simple_setattr(dentry, &op_data->op_attr); + op_data->op_attr.ia_valid = ia_valid; + /* Extract epoch data if obtained. */ op_data->op_handle = md.body->handle; op_data->op_ioepoch = md.body->ioepoch; @@ -1364,7 +1371,6 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr) struct ll_inode_info *lli = ll_i2info(inode); struct md_op_data *op_data = NULL; struct md_open_data *mod = NULL; - unsigned int valid = attr->ia_valid; int rc = 0, rc1 = 0; ENTRY; @@ -1476,13 +1482,6 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr) rc = ll_setattr_ost(inode, attr); EXIT; out: - if (rc == 0) { - /* Update inode attribute after dirty cache is cleaned - * by truncating OST objects. */ - attr->ia_valid |= ATTR_FORCE; - rc = simple_setattr(dentry, attr); - LASSERT(rc == 0); - } if (op_data) { if (op_data->op_ioepoch) { rc1 = ll_setattr_done_writing(inode, op_data, mod); @@ -1501,8 +1500,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr) ll_stats_ops_tally(ll_i2sbi(inode), (attr->ia_valid & ATTR_SIZE) ? LPROC_LL_TRUNC : LPROC_LL_SETATTR, 1); - attr->ia_valid = valid; - RETURN(rc); + return rc; } int ll_setattr(struct dentry *de, struct iattr *attr) diff --git a/drivers/staging/lustre/lustre/lov/lov_io.c b/drivers/staging/lustre/lustre/lov/lov_io.c index e78cdb7633ca2..b316ce8cfeac7 100644 --- a/drivers/staging/lustre/lustre/lov/lov_io.c +++ b/drivers/staging/lustre/lustre/lov/lov_io.c @@ -980,9 +980,9 @@ int lov_io_init_released(const struct lu_env *env, struct cl_object *obj, LASSERTF(0, "invalid type %d\n", io->ci_type); case CIT_MISC: case CIT_FSYNC: - case CIT_SETATTR: result = +1; break; + case CIT_SETATTR: case CIT_READ: case CIT_WRITE: case CIT_FAULT: -- GitLab From 3fa08ae702b15ad17b394361e53abf80b5e267fd Mon Sep 17 00:00:00 2001 From: Andriy Skulysh Date: Tue, 23 Jul 2013 00:06:52 +0800 Subject: [PATCH 049/942] staging/lustre/ldlm: Fix flock deadlock detection race Deadlock isn't detected if 2 threads are trying to grant 2 locks which deadlock on each other. They call ldlm_flock_deadlock() simultaneously and deadlock ins't detected. The soulition is to add lock to blocking list before calling ldlm_flock_deadlock() Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-1602 Lustre-change: http://review.whamcloud.com/3277 Signed-off-by: Andriy Skulysh Reviewed-by: Vitaly Fertman Reviewed-by: Bruce Korb Reviewed-by: Keith Mannthey Reviewed-by: Oleg Drokin Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ldlm/ldlm_flock.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c index aca1073d18b52..39973cb110a3b 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c @@ -198,6 +198,7 @@ ldlm_flock_deadlock(struct ldlm_lock *req, struct ldlm_lock *bl_lock) if (lock == NULL) break; + LASSERT(req != lock); flock = &lock->l_policy_data.l_flock; LASSERT(flock->owner == bl_owner); bl_owner = flock->blocking_owner; @@ -329,18 +330,21 @@ ldlm_process_flock_lock(struct ldlm_lock *req, __u64 *flags, int first_enq, RETURN(LDLM_ITER_STOP); } - if (ldlm_flock_deadlock(req, lock)) { - ldlm_flock_destroy(req, mode, *flags); - *err = -EDEADLK; - RETURN(LDLM_ITER_STOP); - } - + /* add lock to blocking list before deadlock + * check to prevent race */ rc = ldlm_flock_blocking_link(req, lock); if (rc) { ldlm_flock_destroy(req, mode, *flags); *err = rc; RETURN(LDLM_ITER_STOP); } + if (ldlm_flock_deadlock(req, lock)) { + ldlm_flock_blocking_unlink(req); + ldlm_flock_destroy(req, mode, *flags); + *err = -EDEADLK; + RETURN(LDLM_ITER_STOP); + } + ldlm_resource_add_lock(res, &res->lr_waiting, req); *flags |= LDLM_FL_BLOCK_GRANTED; RETURN(LDLM_ITER_STOP); -- GitLab From 02524b200ca8adec61488ce23e96b6d8816778ae Mon Sep 17 00:00:00 2001 From: Peng Tao Date: Tue, 23 Jul 2013 00:06:53 +0800 Subject: [PATCH 050/942] staging/lustre/lnet: remove empty file lnet/lnet/api-errno.c The file is empty. We can just remove it. Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2335 Lustre-change: http://review.whamcloud.com/5880 Reviewed-by: Liang Zhen Reviewed-by: Li Wei Reviewed-by: Isaac Huang Reviewed-by: Oleg Drokin Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/lnet/Makefile | 2 +- drivers/staging/lustre/lnet/lnet/api-errno.c | 39 -------------------- 2 files changed, 1 insertion(+), 40 deletions(-) delete mode 100644 drivers/staging/lustre/lnet/lnet/api-errno.c diff --git a/drivers/staging/lustre/lnet/lnet/Makefile b/drivers/staging/lustre/lnet/lnet/Makefile index 1bd9ef7742086..b815fe12b10a6 100644 --- a/drivers/staging/lustre/lnet/lnet/Makefile +++ b/drivers/staging/lustre/lnet/lnet/Makefile @@ -1,6 +1,6 @@ obj-$(CONFIG_LNET) += lnet.o -lnet-y := api-errno.o api-ni.o config.o lib-me.o lib-msg.o lib-eq.o \ +lnet-y := api-ni.o config.o lib-me.o lib-msg.o lib-eq.o \ lib-md.o lib-ptl.o lib-move.o module.o lo.o router.o \ router_proc.o acceptor.o peer.o diff --git a/drivers/staging/lustre/lnet/lnet/api-errno.c b/drivers/staging/lustre/lnet/lnet/api-errno.c deleted file mode 100644 index 695b27265e235..0000000000000 --- a/drivers/staging/lustre/lnet/lnet/api-errno.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * 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 version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * lnet/lnet/api-errno.c - * - * Instantiate the string table of errors - */ - -/* If you change these, you must update the number table in portals/errno.h */ -- GitLab From e62e5d9251bf8efd08318e78bcaca86fde228383 Mon Sep 17 00:00:00 2001 From: Liu Xuezhao Date: Tue, 23 Jul 2013 00:06:54 +0800 Subject: [PATCH 051/942] staging/lustre/fld: prepare FLD module for client server split Split FLD server from client, fld_{handler,index}.c are not compliled unless server support is enabled. Do not include dt_object.h or lustre_mdt.h in lustre_fld.h and fix the minor breakages caused by this elsewhere. Generally cleanup includes in lustre/fld. Signed-off-by: Liu Xuezhao Signed-off-by: John L. Hammond Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-1330 Lustre-change: http://review.whamcloud.com/2675 Reviewed-by: Nathaniel Clark Reviewed-by: Andreas Dilger Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/fld/Makefile | 2 +- .../staging/lustre/lustre/fld/fld_handler.c | 447 ------------------ drivers/staging/lustre/lustre/fld/fld_index.c | 426 ----------------- .../staging/lustre/lustre/fld/fld_internal.h | 29 -- .../staging/lustre/lustre/fld/fld_request.c | 40 +- drivers/staging/lustre/lustre/fld/lproc_fld.c | 205 +------- .../lustre/lustre/include/lustre_fld.h | 41 -- .../lustre/lustre/include/lustre_mdt.h | 84 ---- .../lustre/lustre/obdecho/echo_client.c | 1 + 9 files changed, 37 insertions(+), 1238 deletions(-) delete mode 100644 drivers/staging/lustre/lustre/fld/fld_handler.c delete mode 100644 drivers/staging/lustre/lustre/fld/fld_index.c delete mode 100644 drivers/staging/lustre/lustre/include/lustre_mdt.h diff --git a/drivers/staging/lustre/lustre/fld/Makefile b/drivers/staging/lustre/lustre/fld/Makefile index e7f2881a1d9ec..90d46d84fbbb4 100644 --- a/drivers/staging/lustre/lustre/fld/Makefile +++ b/drivers/staging/lustre/lustre/fld/Makefile @@ -1,5 +1,5 @@ obj-$(CONFIG_LUSTRE_FS) += fld.o -fld-y := fld_handler.o fld_request.o fld_cache.o fld_index.o lproc_fld.o +fld-y := fld_request.o fld_cache.o lproc_fld.o ccflags-y := -I$(src)/../include diff --git a/drivers/staging/lustre/lustre/fld/fld_handler.c b/drivers/staging/lustre/lustre/fld/fld_handler.c deleted file mode 100644 index d2707ae4ad57e..0000000000000 --- a/drivers/staging/lustre/lustre/fld/fld_handler.c +++ /dev/null @@ -1,447 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * 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 version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2011, 2013, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * lustre/fld/fld_handler.c - * - * FLD (Fids Location Database) - * - * Author: Yury Umanets - * Author: WangDi - * Author: Pravin Shelar - */ - -#define DEBUG_SUBSYSTEM S_FLD - -# include -# include -# include -# include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include "fld_internal.h" -#include - - -/* context key constructor/destructor: fld_key_init, fld_key_fini */ -LU_KEY_INIT_FINI(fld, struct fld_thread_info); - -/* context key: fld_thread_key */ -LU_CONTEXT_KEY_DEFINE(fld, LCT_MD_THREAD | LCT_DT_THREAD | LCT_MG_THREAD); - -proc_dir_entry_t *fld_type_proc_dir = NULL; - -static int __init fld_mod_init(void) -{ - fld_type_proc_dir = lprocfs_register(LUSTRE_FLD_NAME, - proc_lustre_root, - NULL, NULL); - if (IS_ERR(fld_type_proc_dir)) - return PTR_ERR(fld_type_proc_dir); - - LU_CONTEXT_KEY_INIT(&fld_thread_key); - lu_context_key_register(&fld_thread_key); - return 0; -} - -static void __exit fld_mod_exit(void) -{ - lu_context_key_degister(&fld_thread_key); - if (fld_type_proc_dir != NULL && !IS_ERR(fld_type_proc_dir)) { - lprocfs_remove(&fld_type_proc_dir); - fld_type_proc_dir = NULL; - } -} - -int fld_declare_server_create(const struct lu_env *env, - struct lu_server_fld *fld, - struct lu_seq_range *range, - struct thandle *th) -{ - int rc; - - rc = fld_declare_index_create(env, fld, range, th); - RETURN(rc); -} -EXPORT_SYMBOL(fld_declare_server_create); - -/** - * Insert FLD index entry and update FLD cache. - * - * This function is called from the sequence allocator when a super-sequence - * is granted to a server. - */ -int fld_server_create(const struct lu_env *env, struct lu_server_fld *fld, - struct lu_seq_range *range, struct thandle *th) -{ - int rc; - - mutex_lock(&fld->lsf_lock); - rc = fld_index_create(env, fld, range, th); - mutex_unlock(&fld->lsf_lock); - - RETURN(rc); -} -EXPORT_SYMBOL(fld_server_create); - -/** - * Lookup mds by seq, returns a range for given seq. - * - * If that entry is not cached in fld cache, request is sent to super - * sequence controller node (MDT0). All other MDT[1...N] and client - * cache fld entries, but this cache is not persistent. - */ -int fld_server_lookup(const struct lu_env *env, struct lu_server_fld *fld, - seqno_t seq, struct lu_seq_range *range) -{ - struct lu_seq_range *erange; - struct fld_thread_info *info; - int rc; - ENTRY; - - info = lu_context_key_get(&env->le_ctx, &fld_thread_key); - LASSERT(info != NULL); - erange = &info->fti_lrange; - - /* Lookup it in the cache. */ - rc = fld_cache_lookup(fld->lsf_cache, seq, erange); - if (rc == 0) { - if (unlikely(fld_range_type(erange) != fld_range_type(range) && - !fld_range_is_any(range))) { - CERROR("%s: FLD cache range "DRANGE" does not match" - "requested flag %x: rc = %d\n", fld->lsf_name, - PRANGE(erange), range->lsr_flags, -EIO); - RETURN(-EIO); - } - *range = *erange; - RETURN(0); - } - - if (fld->lsf_obj) { - /* On server side, all entries should be in cache. - * If we can not find it in cache, just return error */ - CERROR("%s: Cannot find sequence "LPX64": rc = %d\n", - fld->lsf_name, seq, -EIO); - RETURN(-EIO); - } else { - LASSERT(fld->lsf_control_exp); - /* send request to mdt0 i.e. super seq. controller. - * This is temporary solution, long term solution is fld - * replication on all mdt servers. - */ - range->lsr_start = seq; - rc = fld_client_rpc(fld->lsf_control_exp, - range, FLD_LOOKUP); - if (rc == 0) - fld_cache_insert(fld->lsf_cache, range); - } - RETURN(rc); -} -EXPORT_SYMBOL(fld_server_lookup); - -/** - * All MDT server handle fld lookup operation. But only MDT0 has fld index. - * if entry is not found in cache we need to forward lookup request to MDT0 - */ - -static int fld_server_handle(struct lu_server_fld *fld, - const struct lu_env *env, - __u32 opc, struct lu_seq_range *range, - struct fld_thread_info *info) -{ - int rc; - ENTRY; - - switch (opc) { - case FLD_LOOKUP: - rc = fld_server_lookup(env, fld, range->lsr_start, range); - break; - default: - rc = -EINVAL; - break; - } - - CDEBUG(D_INFO, "%s: FLD req handle: error %d (opc: %d, range: " - DRANGE"\n", fld->lsf_name, rc, opc, PRANGE(range)); - - RETURN(rc); - -} - -static int fld_req_handle(struct ptlrpc_request *req, - struct fld_thread_info *info) -{ - struct obd_export *exp = req->rq_export; - struct lu_site *site = exp->exp_obd->obd_lu_dev->ld_site; - struct lu_seq_range *in; - struct lu_seq_range *out; - int rc; - __u32 *opc; - ENTRY; - - rc = req_capsule_server_pack(info->fti_pill); - if (rc) - RETURN(err_serious(rc)); - - opc = req_capsule_client_get(info->fti_pill, &RMF_FLD_OPC); - if (opc != NULL) { - in = req_capsule_client_get(info->fti_pill, &RMF_FLD_MDFLD); - if (in == NULL) - RETURN(err_serious(-EPROTO)); - out = req_capsule_server_get(info->fti_pill, &RMF_FLD_MDFLD); - if (out == NULL) - RETURN(err_serious(-EPROTO)); - *out = *in; - - /* For old 2.0 client, the 'lsr_flags' is uninitialized. - * Set it as 'LU_SEQ_RANGE_MDT' by default. */ - if (!(exp_connect_flags(exp) & OBD_CONNECT_64BITHASH) && - !(exp_connect_flags(exp) & OBD_CONNECT_MDS_MDS) && - !(exp_connect_flags(exp) & OBD_CONNECT_LIGHTWEIGHT) && - !exp->exp_libclient) - fld_range_set_mdt(out); - - rc = fld_server_handle(lu_site2seq(site)->ss_server_fld, - req->rq_svc_thread->t_env, - *opc, out, info); - } else { - rc = err_serious(-EPROTO); - } - - RETURN(rc); -} - -static void fld_thread_info_init(struct ptlrpc_request *req, - struct fld_thread_info *info) -{ - info->fti_pill = &req->rq_pill; - /* Init request capsule. */ - req_capsule_init(info->fti_pill, req, RCL_SERVER); - req_capsule_set(info->fti_pill, &RQF_FLD_QUERY); -} - -static void fld_thread_info_fini(struct fld_thread_info *info) -{ - req_capsule_fini(info->fti_pill); -} - -static int fld_handle(struct ptlrpc_request *req) -{ - struct fld_thread_info *info; - const struct lu_env *env; - int rc; - - env = req->rq_svc_thread->t_env; - LASSERT(env != NULL); - - info = lu_context_key_get(&env->le_ctx, &fld_thread_key); - LASSERT(info != NULL); - - fld_thread_info_init(req, info); - rc = fld_req_handle(req, info); - fld_thread_info_fini(info); - - return rc; -} - -/* - * Entry point for handling FLD RPCs called from MDT. - */ -int fld_query(struct com_thread_info *info) -{ - return fld_handle(info->cti_pill->rc_req); -} -EXPORT_SYMBOL(fld_query); - -/* - * Returns true, if fid is local to this server node. - * - * WARNING: this function is *not* guaranteed to return false if fid is - * remote: it makes an educated conservative guess only. - * - * fid_is_local() is supposed to be used in assertion checks only. - */ -int fid_is_local(const struct lu_env *env, - struct lu_site *site, const struct lu_fid *fid) -{ - int result; - struct seq_server_site *ss_site; - struct lu_seq_range *range; - struct fld_thread_info *info; - ENTRY; - - info = lu_context_key_get(&env->le_ctx, &fld_thread_key); - range = &info->fti_lrange; - - result = 1; /* conservatively assume fid is local */ - ss_site = lu_site2seq(site); - if (ss_site->ss_client_fld != NULL) { - int rc; - - rc = fld_cache_lookup(ss_site->ss_client_fld->lcf_cache, - fid_seq(fid), range); - if (rc == 0) - result = (range->lsr_index == ss_site->ss_node_id); - } - return result; -} -EXPORT_SYMBOL(fid_is_local); - -static void fld_server_proc_fini(struct lu_server_fld *fld); - -#ifdef LPROCFS -static int fld_server_proc_init(struct lu_server_fld *fld) -{ - int rc = 0; - ENTRY; - - fld->lsf_proc_dir = lprocfs_register(fld->lsf_name, - fld_type_proc_dir, - fld_server_proc_list, fld); - if (IS_ERR(fld->lsf_proc_dir)) { - rc = PTR_ERR(fld->lsf_proc_dir); - RETURN(rc); - } - - rc = lprocfs_seq_create(fld->lsf_proc_dir, "fldb", 0444, - &fld_proc_seq_fops, fld); - if (rc) { - lprocfs_remove(&fld->lsf_proc_dir); - fld->lsf_proc_dir = NULL; - } - - RETURN(rc); -} - -static void fld_server_proc_fini(struct lu_server_fld *fld) -{ - ENTRY; - if (fld->lsf_proc_dir != NULL) { - if (!IS_ERR(fld->lsf_proc_dir)) - lprocfs_remove(&fld->lsf_proc_dir); - fld->lsf_proc_dir = NULL; - } - EXIT; -} -#else -static int fld_server_proc_init(struct lu_server_fld *fld) -{ - return 0; -} - -static void fld_server_proc_fini(struct lu_server_fld *fld) -{ - return; -} -#endif - -int fld_server_init(const struct lu_env *env, struct lu_server_fld *fld, - struct dt_device *dt, const char *prefix, int mds_node_id, - int type) -{ - int cache_size, cache_threshold; - int rc; - ENTRY; - - snprintf(fld->lsf_name, sizeof(fld->lsf_name), - "srv-%s", prefix); - - cache_size = FLD_SERVER_CACHE_SIZE / - sizeof(struct fld_cache_entry); - - cache_threshold = cache_size * - FLD_SERVER_CACHE_THRESHOLD / 100; - - mutex_init(&fld->lsf_lock); - fld->lsf_cache = fld_cache_init(fld->lsf_name, - cache_size, cache_threshold); - if (IS_ERR(fld->lsf_cache)) { - rc = PTR_ERR(fld->lsf_cache); - fld->lsf_cache = NULL; - GOTO(out, rc); - } - - if (!mds_node_id && type == LU_SEQ_RANGE_MDT) { - rc = fld_index_init(env, fld, dt); - if (rc) - GOTO(out, rc); - } else { - fld->lsf_obj = NULL; - } - - rc = fld_server_proc_init(fld); - if (rc) - GOTO(out, rc); - - fld->lsf_control_exp = NULL; - - GOTO(out, rc); - -out: - if (rc) - fld_server_fini(env, fld); - return rc; -} -EXPORT_SYMBOL(fld_server_init); - -void fld_server_fini(const struct lu_env *env, struct lu_server_fld *fld) -{ - ENTRY; - - fld_server_proc_fini(fld); - fld_index_fini(env, fld); - - if (fld->lsf_cache != NULL) { - if (!IS_ERR(fld->lsf_cache)) - fld_cache_fini(fld->lsf_cache); - fld->lsf_cache = NULL; - } - - EXIT; -} -EXPORT_SYMBOL(fld_server_fini); - -MODULE_AUTHOR("Sun Microsystems, Inc. "); -MODULE_DESCRIPTION("Lustre FLD"); -MODULE_LICENSE("GPL"); - -cfs_module(mdd, "0.1.0", fld_mod_init, fld_mod_exit); diff --git a/drivers/staging/lustre/lustre/fld/fld_index.c b/drivers/staging/lustre/lustre/fld/fld_index.c deleted file mode 100644 index ec68a54c23bd6..0000000000000 --- a/drivers/staging/lustre/lustre/fld/fld_index.c +++ /dev/null @@ -1,426 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * 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 version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - * - * Copyright (c) 2011, 2013, Intel Corporation. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * lustre/fld/fld_index.c - * - * Author: WangDi - * Author: Yury Umanets - */ - -#define DEBUG_SUBSYSTEM S_FLD - -# include -# include -# include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include "fld_internal.h" - -const char fld_index_name[] = "fld"; - -static const struct lu_seq_range IGIF_FLD_RANGE = { - .lsr_start = FID_SEQ_IGIF, - .lsr_end = FID_SEQ_IGIF_MAX + 1, - .lsr_index = 0, - .lsr_flags = LU_SEQ_RANGE_MDT -}; - -static const struct lu_seq_range DOT_LUSTRE_FLD_RANGE = { - .lsr_start = FID_SEQ_DOT_LUSTRE, - .lsr_end = FID_SEQ_DOT_LUSTRE + 1, - .lsr_index = 0, - .lsr_flags = LU_SEQ_RANGE_MDT -}; - -static const struct lu_seq_range ROOT_FLD_RANGE = { - .lsr_start = FID_SEQ_ROOT, - .lsr_end = FID_SEQ_ROOT + 1, - .lsr_index = 0, - .lsr_flags = LU_SEQ_RANGE_MDT -}; - -const struct dt_index_features fld_index_features = { - .dif_flags = DT_IND_UPDATE, - .dif_keysize_min = sizeof(seqno_t), - .dif_keysize_max = sizeof(seqno_t), - .dif_recsize_min = sizeof(struct lu_seq_range), - .dif_recsize_max = sizeof(struct lu_seq_range), - .dif_ptrsize = 4 -}; - -extern struct lu_context_key fld_thread_key; - -int fld_declare_index_create(const struct lu_env *env, - struct lu_server_fld *fld, - const struct lu_seq_range *new_range, - struct thandle *th) -{ - struct lu_seq_range *tmp; - struct lu_seq_range *range; - struct fld_thread_info *info; - int rc = 0; - - ENTRY; - - info = lu_context_key_get(&env->le_ctx, &fld_thread_key); - range = &info->fti_lrange; - tmp = &info->fti_irange; - memset(range, 0, sizeof(*range)); - - rc = fld_index_lookup(env, fld, new_range->lsr_start, range); - if (rc == 0) { - /* In case of duplicate entry, the location must be same */ - LASSERT((range_compare_loc(new_range, range) == 0)); - GOTO(out, rc = -EEXIST); - } - - if (rc != -ENOENT) { - CERROR("%s: lookup range "DRANGE" error: rc = %d\n", - fld->lsf_name, PRANGE(range), rc); - GOTO(out, rc); - } - - /* Check for merge case, since the fld entry can only be increamental, - * so we will only check whether it can be merged from the left. */ - if (new_range->lsr_start == range->lsr_end && range->lsr_end != 0 && - range_compare_loc(new_range, range) == 0) { - range_cpu_to_be(tmp, range); - rc = dt_declare_delete(env, fld->lsf_obj, - (struct dt_key *)&tmp->lsr_start, th); - if (rc) { - CERROR("%s: declare record "DRANGE" failed: rc = %d\n", - fld->lsf_name, PRANGE(range), rc); - GOTO(out, rc); - } - memcpy(tmp, new_range, sizeof(*new_range)); - tmp->lsr_start = range->lsr_start; - } else { - memcpy(tmp, new_range, sizeof(*new_range)); - } - - range_cpu_to_be(tmp, tmp); - rc = dt_declare_insert(env, fld->lsf_obj, (struct dt_rec *)tmp, - (struct dt_key *)&tmp->lsr_start, th); -out: - RETURN(rc); -} - -/** - * insert range in fld store. - * - * \param range range to be inserted - * \param th transaction for this operation as it could compound - * transaction. - * - * \retval 0 success - * \retval -ve error - * - * The whole fld index insertion is protected by seq->lss_mutex (see - * seq_server_alloc_super), i.e. only one thread will access fldb each - * time, so we do not need worry the fld file and cache will being - * changed between declare and create. - * Because the fld entry can only be increamental, so we will only check - * whether it can be merged from the left. - **/ -int fld_index_create(const struct lu_env *env, struct lu_server_fld *fld, - const struct lu_seq_range *new_range, struct thandle *th) -{ - struct lu_seq_range *range; - struct lu_seq_range *tmp; - struct fld_thread_info *info; - int rc = 0; - int deleted = 0; - struct fld_cache_entry *flde; - ENTRY; - - info = lu_context_key_get(&env->le_ctx, &fld_thread_key); - - LASSERT(mutex_is_locked(&fld->lsf_lock)); - - range = &info->fti_lrange; - memset(range, 0, sizeof(*range)); - tmp = &info->fti_irange; - rc = fld_index_lookup(env, fld, new_range->lsr_start, range); - if (rc != -ENOENT) { - rc = rc == 0 ? -EEXIST : rc; - GOTO(out, rc); - } - - if (new_range->lsr_start == range->lsr_end && range->lsr_end != 0 && - range_compare_loc(new_range, range) == 0) { - range_cpu_to_be(tmp, range); - rc = dt_delete(env, fld->lsf_obj, - (struct dt_key *)&tmp->lsr_start, th, - BYPASS_CAPA); - if (rc != 0) - GOTO(out, rc); - memcpy(tmp, new_range, sizeof(*new_range)); - tmp->lsr_start = range->lsr_start; - deleted = 1; - } else { - memcpy(tmp, new_range, sizeof(*new_range)); - } - - range_cpu_to_be(tmp, tmp); - rc = dt_insert(env, fld->lsf_obj, (struct dt_rec *)tmp, - (struct dt_key *)&tmp->lsr_start, th, BYPASS_CAPA, 1); - if (rc != 0) { - CERROR("%s: insert range "DRANGE" failed: rc = %d\n", - fld->lsf_name, PRANGE(new_range), rc); - GOTO(out, rc); - } - - flde = fld_cache_entry_create(new_range); - if (IS_ERR(flde)) - GOTO(out, rc = PTR_ERR(flde)); - - write_lock(&fld->lsf_cache->fci_lock); - if (deleted) - fld_cache_delete_nolock(fld->lsf_cache, new_range); - rc = fld_cache_insert_nolock(fld->lsf_cache, flde); - write_unlock(&fld->lsf_cache->fci_lock); - if (rc) - OBD_FREE_PTR(flde); -out: - RETURN(rc); -} - -/** - * lookup range for a seq passed. note here we only care about the start/end, - * caller should handle the attached location data (flags, index). - * - * \param seq seq for lookup. - * \param range result of lookup. - * - * \retval 0 found, \a range is the matched range; - * \retval -ENOENT not found, \a range is the left-side range; - * \retval -ve other error; - */ -int fld_index_lookup(const struct lu_env *env, struct lu_server_fld *fld, - seqno_t seq, struct lu_seq_range *range) -{ - struct lu_seq_range *fld_rec; - struct fld_thread_info *info; - int rc; - - ENTRY; - - info = lu_context_key_get(&env->le_ctx, &fld_thread_key); - fld_rec = &info->fti_rec; - - rc = fld_cache_lookup(fld->lsf_cache, seq, fld_rec); - if (rc == 0) { - *range = *fld_rec; - if (range_within(range, seq)) - rc = 0; - else - rc = -ENOENT; - } - - CDEBUG(D_INFO, "%s: lookup seq = "LPX64" range : "DRANGE" rc = %d\n", - fld->lsf_name, seq, PRANGE(range), rc); - - RETURN(rc); -} - -int fld_insert_entry(const struct lu_env *env, - struct lu_server_fld *fld, - const struct lu_seq_range *range) -{ - struct thandle *th; - int rc; - ENTRY; - - th = dt_trans_create(env, lu2dt_dev(fld->lsf_obj->do_lu.lo_dev)); - if (IS_ERR(th)) - RETURN(PTR_ERR(th)); - - rc = fld_declare_index_create(env, fld, range, th); - if (rc != 0) { - if (rc == -EEXIST) - rc = 0; - GOTO(out, rc); - } - - rc = dt_trans_start_local(env, lu2dt_dev(fld->lsf_obj->do_lu.lo_dev), - th); - if (rc) - GOTO(out, rc); - - rc = fld_index_create(env, fld, range, th); - if (rc == -EEXIST) - rc = 0; -out: - dt_trans_stop(env, lu2dt_dev(fld->lsf_obj->do_lu.lo_dev), th); - RETURN(rc); -} -EXPORT_SYMBOL(fld_insert_entry); - -static int fld_insert_special_entries(const struct lu_env *env, - struct lu_server_fld *fld) -{ - int rc; - - rc = fld_insert_entry(env, fld, &IGIF_FLD_RANGE); - if (rc != 0) - RETURN(rc); - - rc = fld_insert_entry(env, fld, &DOT_LUSTRE_FLD_RANGE); - if (rc != 0) - RETURN(rc); - - rc = fld_insert_entry(env, fld, &ROOT_FLD_RANGE); - - RETURN(rc); -} - -int fld_index_init(const struct lu_env *env, struct lu_server_fld *fld, - struct dt_device *dt) -{ - struct dt_object *dt_obj = NULL; - struct lu_fid fid; - struct lu_attr *attr = NULL; - struct lu_seq_range *range = NULL; - struct fld_thread_info *info; - struct dt_object_format dof; - struct dt_it *it; - const struct dt_it_ops *iops; - int rc; - ENTRY; - - info = lu_context_key_get(&env->le_ctx, &fld_thread_key); - LASSERT(info != NULL); - - lu_local_obj_fid(&fid, FLD_INDEX_OID); - OBD_ALLOC_PTR(attr); - if (attr == NULL) - RETURN(-ENOMEM); - - memset(attr, 0, sizeof(*attr)); - attr->la_valid = LA_MODE; - attr->la_mode = S_IFREG | 0666; - dof.dof_type = DFT_INDEX; - dof.u.dof_idx.di_feat = &fld_index_features; - - dt_obj = dt_find_or_create(env, dt, &fid, &dof, attr); - if (IS_ERR(dt_obj)) { - rc = PTR_ERR(dt_obj); - CERROR("%s: Can't find \"%s\" obj %d\n", fld->lsf_name, - fld_index_name, rc); - dt_obj = NULL; - GOTO(out, rc); - } - - fld->lsf_obj = dt_obj; - rc = dt_obj->do_ops->do_index_try(env, dt_obj, &fld_index_features); - if (rc != 0) { - CERROR("%s: File \"%s\" is not an index: rc = %d!\n", - fld->lsf_name, fld_index_name, rc); - GOTO(out, rc); - } - - range = &info->fti_rec; - /* Load fld entry to cache */ - iops = &dt_obj->do_index_ops->dio_it; - it = iops->init(env, dt_obj, 0, NULL); - if (IS_ERR(it)) - GOTO(out, rc = PTR_ERR(it)); - - rc = iops->load(env, it, 0); - if (rc < 0) - GOTO(out_it_fini, rc); - - if (rc > 0) { - /* Load FLD entry into server cache */ - do { - rc = iops->rec(env, it, (struct dt_rec *)range, 0); - if (rc != 0) - GOTO(out_it_put, rc); - LASSERT(range != NULL); - range_be_to_cpu(range, range); - rc = fld_cache_insert(fld->lsf_cache, range); - if (rc != 0) - GOTO(out_it_put, rc); - rc = iops->next(env, it); - } while (rc == 0); - } - - /* Note: fld_insert_entry will detect whether these - * special entries already exist inside FLDB */ - mutex_lock(&fld->lsf_lock); - rc = fld_insert_special_entries(env, fld); - mutex_unlock(&fld->lsf_lock); - if (rc != 0) { - CERROR("%s: insert special entries failed!: rc = %d\n", - fld->lsf_name, rc); - GOTO(out_it_put, rc); - } - -out_it_put: - iops->put(env, it); -out_it_fini: - iops->fini(env, it); -out: - if (attr != NULL) - OBD_FREE_PTR(attr); - - if (rc != 0) { - if (dt_obj != NULL) - lu_object_put(env, &dt_obj->do_lu); - fld->lsf_obj = NULL; - } - RETURN(rc); -} - -void fld_index_fini(const struct lu_env *env, struct lu_server_fld *fld) -{ - ENTRY; - if (fld->lsf_obj != NULL) { - if (!IS_ERR(fld->lsf_obj)) - lu_object_put(env, &fld->lsf_obj->do_lu); - fld->lsf_obj = NULL; - } - EXIT; -} diff --git a/drivers/staging/lustre/lustre/fld/fld_internal.h b/drivers/staging/lustre/lustre/fld/fld_internal.h index 9fa9e01cdb676..6e7ca9efe3371 100644 --- a/drivers/staging/lustre/lustre/fld/fld_internal.h +++ b/drivers/staging/lustre/lustre/fld/fld_internal.h @@ -139,38 +139,10 @@ enum { extern struct lu_fld_hash fld_hash[]; - -struct fld_thread_info { - struct req_capsule *fti_pill; - __u64 fti_key; - struct lu_seq_range fti_rec; - struct lu_seq_range fti_lrange; - struct lu_seq_range fti_irange; -}; - -extern struct lu_context_key fld_thread_key; - -int fld_index_init(const struct lu_env *env, struct lu_server_fld *fld, - struct dt_device *dt); - -void fld_index_fini(const struct lu_env *env, struct lu_server_fld *fld); - -int fld_declare_index_create(const struct lu_env *env, - struct lu_server_fld *fld, - const struct lu_seq_range *new, - struct thandle *th); - -int fld_index_create(const struct lu_env *env, struct lu_server_fld *fld, - const struct lu_seq_range *new, struct thandle *th); - -int fld_index_lookup(const struct lu_env *env, struct lu_server_fld *fld, - seqno_t seq, struct lu_seq_range *range); - int fld_client_rpc(struct obd_export *exp, struct lu_seq_range *range, __u32 fld_op); #ifdef LPROCFS -extern struct lprocfs_vars fld_server_proc_list[]; extern struct lprocfs_vars fld_client_proc_list[]; #endif @@ -219,5 +191,4 @@ fld_target_name(struct lu_fld_target *tar) } extern proc_dir_entry_t *fld_type_proc_dir; -extern struct file_operations fld_proc_seq_fops; #endif /* __FLD_INTERNAL_H */ diff --git a/drivers/staging/lustre/lustre/fld/fld_request.c b/drivers/staging/lustre/lustre/fld/fld_request.c index e9f07398b68a6..c99b945cc8ef1 100644 --- a/drivers/staging/lustre/lustre/fld/fld_request.c +++ b/drivers/staging/lustre/lustre/fld/fld_request.c @@ -60,6 +60,8 @@ #include #include "fld_internal.h" +struct lu_context_key fld_thread_key; + /* TODO: these 3 functions are copies of flow-control code from mdc_lib.c * It should be common thing. The same about mdc RPC lock */ static int fld_req_avail(struct client_obd *cli, struct mdc_cache_waiter *mcw) @@ -280,6 +282,8 @@ int fld_client_del_target(struct lu_client_fld *fld, __u64 idx) EXPORT_SYMBOL(fld_client_del_target); #ifdef LPROCFS +proc_dir_entry_t *fld_type_proc_dir = NULL; + static int fld_client_proc_init(struct lu_client_fld *fld) { int rc; @@ -496,12 +500,7 @@ int fld_client_lookup(struct lu_client_fld *fld, seqno_t seq, mdsno_t *mds, res.lsr_start = seq; fld_range_set_type(&res, flags); - if (target->ft_srv != NULL) { - LASSERT(env != NULL); - rc = fld_server_lookup(env, target->ft_srv, seq, &res); - } else { - rc = fld_client_rpc(target->ft_exp, &res, FLD_LOOKUP); - } + rc = fld_client_rpc(target->ft_exp, &res, FLD_LOOKUP); if (rc == 0) { *mds = res.lsr_index; @@ -517,3 +516,32 @@ void fld_client_flush(struct lu_client_fld *fld) fld_cache_flush(fld->lcf_cache); } EXPORT_SYMBOL(fld_client_flush); + +static int __init fld_mod_init(void) +{ + fld_type_proc_dir = lprocfs_register(LUSTRE_FLD_NAME, + proc_lustre_root, + NULL, NULL); + if (IS_ERR(fld_type_proc_dir)) + return PTR_ERR(fld_type_proc_dir); + + LU_CONTEXT_KEY_INIT(&fld_thread_key); + lu_context_key_register(&fld_thread_key); + return 0; +} + +static void __exit fld_mod_exit(void) +{ + lu_context_key_degister(&fld_thread_key); + if (fld_type_proc_dir != NULL && !IS_ERR(fld_type_proc_dir)) { + lprocfs_remove(&fld_type_proc_dir); + fld_type_proc_dir = NULL; + } +} + +MODULE_AUTHOR("Sun Microsystems, Inc. "); +MODULE_DESCRIPTION("Lustre FLD"); +MODULE_LICENSE("GPL"); + +module_init(fld_mod_init) +module_exit(fld_mod_exit) diff --git a/drivers/staging/lustre/lustre/fld/lproc_fld.c b/drivers/staging/lustre/lustre/fld/lproc_fld.c index c1bd80339e674..77322ba5bf312 100644 --- a/drivers/staging/lustre/lustre/fld/lproc_fld.c +++ b/drivers/staging/lustre/lustre/fld/lproc_fld.c @@ -158,202 +158,6 @@ struct file_operations fld_proc_cache_flush_fops = { .release = fld_proc_cache_flush_release, }; -struct fld_seq_param { - struct lu_env fsp_env; - struct dt_it *fsp_it; - struct lu_server_fld *fsp_fld; - unsigned int fsp_stop:1; -}; - -static void *fldb_seq_start(struct seq_file *p, loff_t *pos) -{ - struct fld_seq_param *param = p->private; - struct lu_server_fld *fld; - struct dt_object *obj; - const struct dt_it_ops *iops; - - if (param == NULL || param->fsp_stop) - return NULL; - - fld = param->fsp_fld; - obj = fld->lsf_obj; - LASSERT(obj != NULL); - iops = &obj->do_index_ops->dio_it; - - iops->load(¶m->fsp_env, param->fsp_it, *pos); - - *pos = be64_to_cpu(*(__u64 *)iops->key(¶m->fsp_env, param->fsp_it)); - return param; -} - -static void fldb_seq_stop(struct seq_file *p, void *v) -{ - struct fld_seq_param *param = p->private; - const struct dt_it_ops *iops; - struct lu_server_fld *fld; - struct dt_object *obj; - - if (param == NULL) - return; - - fld = param->fsp_fld; - obj = fld->lsf_obj; - LASSERT(obj != NULL); - iops = &obj->do_index_ops->dio_it; - - iops->put(¶m->fsp_env, param->fsp_it); -} - -static void *fldb_seq_next(struct seq_file *p, void *v, loff_t *pos) -{ - struct fld_seq_param *param = p->private; - struct lu_server_fld *fld; - struct dt_object *obj; - const struct dt_it_ops *iops; - int rc; - - if (param == NULL || param->fsp_stop) - return NULL; - - fld = param->fsp_fld; - obj = fld->lsf_obj; - LASSERT(obj != NULL); - iops = &obj->do_index_ops->dio_it; - - rc = iops->next(¶m->fsp_env, param->fsp_it); - if (rc > 0) { - param->fsp_stop = 1; - return NULL; - } - - *pos = be64_to_cpu(*(__u64 *)iops->key(¶m->fsp_env, param->fsp_it)); - return param; -} - -static int fldb_seq_show(struct seq_file *p, void *v) -{ - struct fld_seq_param *param = p->private; - struct lu_server_fld *fld; - struct dt_object *obj; - const struct dt_it_ops *iops; - struct fld_thread_info *info; - struct lu_seq_range *fld_rec; - int rc; - - if (param == NULL || param->fsp_stop) - return 0; - - fld = param->fsp_fld; - obj = fld->lsf_obj; - LASSERT(obj != NULL); - iops = &obj->do_index_ops->dio_it; - - info = lu_context_key_get(¶m->fsp_env.le_ctx, - &fld_thread_key); - fld_rec = &info->fti_rec; - rc = iops->rec(¶m->fsp_env, param->fsp_it, - (struct dt_rec *)fld_rec, 0); - if (rc != 0) { - CERROR("%s:read record error: rc %d\n", - fld->lsf_name, rc); - } else if (fld_rec->lsr_start != 0) { - range_be_to_cpu(fld_rec, fld_rec); - rc = seq_printf(p, DRANGE"\n", PRANGE(fld_rec)); - } - - return rc; -} - -struct seq_operations fldb_sops = { - .start = fldb_seq_start, - .stop = fldb_seq_stop, - .next = fldb_seq_next, - .show = fldb_seq_show, -}; - -static int fldb_seq_open(struct inode *inode, struct file *file) -{ - struct seq_file *seq; - struct lu_server_fld *fld = (struct lu_server_fld *)PDE_DATA(inode); - struct dt_object *obj; - const struct dt_it_ops *iops; - struct fld_seq_param *param = NULL; - int env_init = 0; - int rc; - - rc = seq_open(file, &fldb_sops); - if (rc) - GOTO(out, rc); - - obj = fld->lsf_obj; - if (obj == NULL) { - seq = file->private_data; - seq->private = NULL; - return 0; - } - - OBD_ALLOC_PTR(param); - if (param == NULL) - GOTO(out, rc = -ENOMEM); - - rc = lu_env_init(¶m->fsp_env, LCT_MD_THREAD); - if (rc != 0) - GOTO(out, rc); - - env_init = 1; - iops = &obj->do_index_ops->dio_it; - param->fsp_it = iops->init(¶m->fsp_env, obj, 0, NULL); - if (IS_ERR(param->fsp_it)) - GOTO(out, rc = PTR_ERR(param->fsp_it)); - - param->fsp_fld = fld; - param->fsp_stop = 0; - - seq = file->private_data; - seq->private = param; -out: - if (rc != 0) { - if (env_init == 1) - lu_env_fini(¶m->fsp_env); - if (param != NULL) - OBD_FREE_PTR(param); - } - return rc; -} - -static int fldb_seq_release(struct inode *inode, struct file *file) -{ - struct seq_file *seq = file->private_data; - struct fld_seq_param *param; - struct lu_server_fld *fld; - struct dt_object *obj; - const struct dt_it_ops *iops; - - param = seq->private; - if (param == NULL) { - lprocfs_seq_release(inode, file); - return 0; - } - - fld = param->fsp_fld; - obj = fld->lsf_obj; - LASSERT(obj != NULL); - iops = &obj->do_index_ops->dio_it; - - LASSERT(iops != NULL); - LASSERT(obj != NULL); - LASSERT(param->fsp_it != NULL); - iops->fini(¶m->fsp_env, param->fsp_it); - lu_env_fini(¶m->fsp_env); - OBD_FREE_PTR(param); - lprocfs_seq_release(inode, file); - - return 0; -} - -struct lprocfs_vars fld_server_proc_list[] = { - { NULL }}; - LPROC_SEQ_FOPS_RO(fld_proc_targets); LPROC_SEQ_FOPS(fld_proc_hash); @@ -363,11 +167,4 @@ struct lprocfs_vars fld_client_proc_list[] = { { "cache_flush", &fld_proc_cache_flush_fops }, { NULL }}; -struct file_operations fld_proc_seq_fops = { - .owner = THIS_MODULE, - .open = fldb_seq_open, - .read = seq_read, - .release = fldb_seq_release, -}; - -#endif +#endif /* LPROCFS */ diff --git a/drivers/staging/lustre/lustre/include/lustre_fld.h b/drivers/staging/lustre/lustre/include/lustre_fld.h index 11e034a65b175..94b697dbe713a 100644 --- a/drivers/staging/lustre/lustre/include/lustre_fld.h +++ b/drivers/staging/lustre/lustre/include/lustre_fld.h @@ -43,9 +43,6 @@ */ #include -#include -#include - #include struct lu_client_fld; @@ -129,47 +126,9 @@ struct lu_client_fld { * Client fld proc entry name. */ char lcf_name[80]; - const struct lu_context *lcf_ctx; - int lcf_flags; }; -/** - * number of blocks to reserve for particular operations. Should be function of - * ... something. Stub for now. - */ -enum { - /* one insert operation can involve two delete and one insert */ - FLD_TXN_INDEX_INSERT_CREDITS = 60, - FLD_TXN_INDEX_DELETE_CREDITS = 20, -}; - -int fld_query(struct com_thread_info *info); - -/* Server methods */ -int fld_server_init(const struct lu_env *env, struct lu_server_fld *fld, - struct dt_device *dt, const char *prefix, int mds_node_id, - int type); - -void fld_server_fini(const struct lu_env *env, struct lu_server_fld *fld); - -int fld_declare_server_create(const struct lu_env *env, - struct lu_server_fld *fld, - struct lu_seq_range *new, - struct thandle *th); - -int fld_server_create(const struct lu_env *env, - struct lu_server_fld *fld, - struct lu_seq_range *add_range, - struct thandle *th); - -int fld_insert_entry(const struct lu_env *env, - struct lu_server_fld *fld, - const struct lu_seq_range *range); - -int fld_server_lookup(const struct lu_env *env, struct lu_server_fld *fld, - seqno_t seq, struct lu_seq_range *range); - /* Client methods */ int fld_client_init(struct lu_client_fld *fld, const char *prefix, int hash); diff --git a/drivers/staging/lustre/lustre/include/lustre_mdt.h b/drivers/staging/lustre/lustre/include/lustre_mdt.h deleted file mode 100644 index dba26a6cfa389..0000000000000 --- a/drivers/staging/lustre/lustre/include/lustre_mdt.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * 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 version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - * - * GPL HEADER END - */ -/* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - */ - -#ifndef __LINUX_MDT_H -#define __LINUX_MDT_H - -/** \defgroup mdt mdt - * - * @{ - */ - -#include -#include -#include -#include -#include - -/* - * Common thread info for mdt, seq and fld - */ -struct com_thread_info { - /* - * for req-layout interface. - */ - struct req_capsule *cti_pill; -}; - -enum { - ESERIOUS = 0x0001000 -}; - -static inline int err_serious(int rc) -{ - LASSERT(rc < 0); - LASSERT(-rc < ESERIOUS); - return -(-rc | ESERIOUS); -} - -static inline int clear_serious(int rc) -{ - if (rc < 0) - rc = -(-rc & ~ESERIOUS); - return rc; -} - -static inline int is_serious(int rc) -{ - return (rc < 0 && -rc & ESERIOUS); -} - -/** @} mdt */ - -#endif diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c index ae89ea6f893cf..de8f4ea7f156f 100644 --- a/drivers/staging/lustre/lustre/obdecho/echo_client.c +++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include -- GitLab From 5907838a44d71a446c6e418f1b9d8a66fff4cbfb Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Tue, 23 Jul 2013 00:06:58 +0800 Subject: [PATCH 052/942] staging/lustre/procfs: return -ENOMEM from lprocfs_register() In lprocfs_register(), if proc_mkdir() fails then return ERR_PTR(-ENOMEM) rather than NULL and hold _lprocfs_mutex for the whole function. In lprocfs_remove_nolock() return early if the entry is an error pointer. Improve error handling around lprocfs_register() in a few spots. Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2650 Lustre-change: http://review.whamcloud.com/5161 Signed-off-by: John L. Hammond Reviewed-by: Emoly Liu Reviewed-by: Keith Mannthey Reviewed-by: Andreas Dilger Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lustre/ldlm/ldlm_pool.c | 1 + drivers/staging/lustre/lustre/llite/super25.c | 2 +- drivers/staging/lustre/lustre/lov/lov_obd.c | 6 ++-- .../lustre/obdclass/linux/linux-module.c | 9 +++++- .../lustre/lustre/obdclass/lprocfs_status.c | 28 +++++++++++-------- .../lustre/lustre/ptlrpc/gss/lproc_gss.c | 6 ++-- 6 files changed, 34 insertions(+), 18 deletions(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c index 3277a0dca31e8..101af4be9ffb3 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c @@ -750,6 +750,7 @@ static int ldlm_pool_proc_init(struct ldlm_pool *pl) if (IS_ERR(pl->pl_proc_dir)) { CERROR("LProcFS failed in ldlm-pool-init\n"); rc = PTR_ERR(pl->pl_proc_dir); + pl->pl_proc_dir = NULL; GOTO(out_free_name, rc); } diff --git a/drivers/staging/lustre/lustre/llite/super25.c b/drivers/staging/lustre/lustre/llite/super25.c index 82c14a993cca0..ea06f1a18776d 100644 --- a/drivers/staging/lustre/lustre/llite/super25.c +++ b/drivers/staging/lustre/lustre/llite/super25.c @@ -214,7 +214,7 @@ static void __exit exit_lustre_lite(void) ll_remote_perm_cachep = NULL; kmem_cache_destroy(ll_file_data_slab); - if (proc_lustre_fs_root) + if (proc_lustre_fs_root && !IS_ERR(proc_lustre_fs_root)) lprocfs_remove(&proc_lustre_fs_root); } diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index 0a9e40de8fae7..c7c1a8cc25929 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -836,11 +836,11 @@ int lov_setup(struct obd_device *obd, struct lustre_cfg *lcfg) lprocfs_obd_setup(obd, lvars.obd_vars); #ifdef LPROCFS { - int rc; + int rc1; - rc = lprocfs_seq_create(obd->obd_proc_entry, "target_obd", + rc1 = lprocfs_seq_create(obd->obd_proc_entry, "target_obd", 0444, &lov_proc_target_fops, obd); - if (rc) + if (rc1) CWARN("Error adding the target_obd file\n"); } #endif diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c index d2c3072541d16..2abacf2065316 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c @@ -385,14 +385,21 @@ struct file_operations obd_device_list_fops = { int class_procfs_init(void) { - int rc; + int rc = 0; ENTRY; obd_sysctl_init(); proc_lustre_root = lprocfs_register("fs/lustre", NULL, lprocfs_base, NULL); + if (IS_ERR(proc_lustre_root)) { + rc = PTR_ERR(proc_lustre_root); + proc_lustre_root = NULL; + goto out; + } + rc = lprocfs_seq_create(proc_lustre_root, "devices", 0444, &obd_device_list_fops, NULL); +out: if (rc) CERROR("error adding /proc/fs/lustre/devices file\n"); RETURN(0); diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index 85163f42892e6..e57a922eda591 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -179,17 +179,21 @@ struct proc_dir_entry *lprocfs_register(const char *name, struct proc_dir_entry *parent, struct lprocfs_vars *list, void *data) { - struct proc_dir_entry *newchild; - - newchild = proc_mkdir(name, parent); - if (newchild != NULL && list != NULL) { - int rc = lprocfs_add_vars(newchild, list, data); - if (rc) { - lprocfs_remove(&newchild); - return ERR_PTR(rc); + struct proc_dir_entry *entry; + + entry = proc_mkdir(name, parent); + if (entry == NULL) + GOTO(out, entry = ERR_PTR(-ENOMEM)); + + if (list != NULL) { + int rc = lprocfs_add_vars(entry, list, data); + if (rc != 0) { + lprocfs_remove(&entry); + entry = ERR_PTR(rc); } } - return newchild; +out: + return entry; } EXPORT_SYMBOL(lprocfs_register); @@ -1596,10 +1600,12 @@ int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int *newnid) NULL, NULL); OBD_FREE(buffer, LNET_NIDSTR_SIZE); - if (new_stat->nid_proc == NULL) { + if (IS_ERR(new_stat->nid_proc)) { CERROR("Error making export directory for nid %s\n", libcfs_nid2str(*nid)); - GOTO(destroy_new_ns, rc = -ENOMEM); + rc = PTR_ERR(new_stat->nid_proc); + new_stat->nid_proc = NULL; + GOTO(destroy_new_ns, rc); } entry = lprocfs_add_simple(new_stat->nid_proc, "uuid", diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/lproc_gss.c b/drivers/staging/lustre/lustre/ptlrpc/gss/lproc_gss.c index 340400089a5a2..de100a14ab52e 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/lproc_gss.c +++ b/drivers/staging/lustre/lustre/ptlrpc/gss/lproc_gss.c @@ -199,15 +199,17 @@ int gss_init_lproc(void) gss_proc_root = lprocfs_register("gss", sptlrpc_proc_root, gss_lprocfs_vars, NULL); if (IS_ERR(gss_proc_root)) { + rc = PTR_ERR(gss_proc_root); gss_proc_root = NULL; - GOTO(err_out, rc = PTR_ERR(gss_proc_root)); + GOTO(err_out, rc); } gss_proc_lk = lprocfs_register("lgss_keyring", gss_proc_root, gss_lk_lprocfs_vars, NULL); if (IS_ERR(gss_proc_lk)) { + rc = PTR_ERR(gss_proc_lk); gss_proc_lk = NULL; - GOTO(err_out, rc = PTR_ERR(gss_proc_root)); + GOTO(err_out, rc); } return 0; -- GitLab From cdb5f7107ff8b4727e32f4921b2c5984984d24e0 Mon Sep 17 00:00:00 2001 From: Ned Bass Date: Tue, 23 Jul 2013 00:06:59 +0800 Subject: [PATCH 053/942] staging/lustre/lmv: fix duplicate directory entries Previously, I accidentally introduced a new way for duplicate directory entries to be returned from readdir(). That patch fails to properly decrement the nlupgs counter when breaking out of the inner-for loop. This accounting error causes an extra iteration of the inner-for loop when processing the next cfs page and a bad ldp_hash_end value is then saved in the lu_dirpage. To fix this, always decrement the nlupgs counter on entry into the inner loop. Note: this bug only affects architectures with > 4k-sized pages, e.g. PowerPC. Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3182 Lustre-change: http://review.whamcloud.com/6405 Signed-off-by: Ned Bass Reviewed-by: Fan Yong Reviewed-by: Andreas Dilger Reviewed-by: Bobi Jam Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index d10f7fc553d3b..5bd952a6dd653 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -1959,7 +1959,7 @@ static void lmv_adjust_dirpages(struct page **pages, int ncfspgs, int nlupgs) __u64 hash_end = dp->ldp_hash_end; __u32 flags = dp->ldp_flags; - for (; nlupgs > 1; nlupgs--) { + while (--nlupgs > 0) { ent = lu_dirent_start(dp); for (end_dirent = ent; ent != NULL; end_dirent = ent, ent = lu_dirent_next(ent)); @@ -1993,6 +1993,7 @@ static void lmv_adjust_dirpages(struct page **pages, int ncfspgs, int nlupgs) kunmap(pages[i]); } + LASSERTF(nlupgs == 0, "left = %d", nlupgs); } #else #define lmv_adjust_dirpages(pages, ncfspgs, nlupgs) do {} while (0) -- GitLab From f1b58c5afadb862c6daae76fe380d083cc370bc7 Mon Sep 17 00:00:00 2001 From: Nathaniel Clark Date: Tue, 23 Jul 2013 00:07:00 +0800 Subject: [PATCH 054/942] staging/lustre/obdclass: be more careful processing server name Because whole options line gets passed to exclude processing, don't search from end of passed in argument to determine fsname at beginning. Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2200 Lustre-change: http://review.whamcloud.com/6197 Signed-off-by: Nathaniel Clark Reviewed-by: Andreas Dilger Reviewed-by: Alex Zhuravlev Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/obdclass/obd_config.c | 11 ++-- .../lustre/lustre/obdclass/obd_mount.c | 58 +++++++++++-------- 2 files changed, 40 insertions(+), 29 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c index bbf06d009fd02..8b5eb6c3b078b 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_config.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c @@ -1426,10 +1426,13 @@ int class_config_llog_handler(const struct lu_env *env, } - if ((clli->cfg_flags & CFG_F_EXCLUDE) && - (lcfg->lcfg_command == LCFG_LOV_ADD_OBD)) - /* Add inactive instead */ - lcfg->lcfg_command = LCFG_LOV_ADD_INA; + if (clli->cfg_flags & CFG_F_EXCLUDE) { + CDEBUG(D_CONFIG, "cmd: %x marked EXCLUDED\n", + lcfg->lcfg_command); + if (lcfg->lcfg_command == LCFG_LOV_ADD_OBD) + /* Add inactive instead */ + lcfg->lcfg_command = LCFG_LOV_ADD_INA; + } lustre_cfg_bufs_init(&bufs, lcfg); diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c b/drivers/staging/lustre/lustre/obdclass/obd_mount.c index 99adad9793c59..f5585ccaff19d 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c @@ -650,6 +650,15 @@ int lustre_put_lsi(struct super_block *sb) RETURN(0); } +/*** SERVER NAME *** + * + * FSNAME is between 1 and 8 characters (inclusive). + * Excluded characters are '/' and ':' + * SEPERATOR is either ':' or '-' + * TYPE: "OST", "MDT", etc. + * INDEX: Hex representation of the index + */ + /** Get the fsname ("lustre") from the server name ("lustre-OST003F"). * @param [in] svname server name including type and index * @param [out] fsname Buffer to copy filesystem name prefix into. @@ -659,22 +668,13 @@ int lustre_put_lsi(struct super_block *sb) */ int server_name2fsname(const char *svname, char *fsname, const char **endptr) { - const char *dash = strrchr(svname, '-'); - if (!dash) { - dash = strrchr(svname, ':'); - if (!dash) - return -EINVAL; - } + const char *dash; - /* interpret -MDTXXXXX-mdc as mdt, the better way is to pass - * in the fsname, then determine the server index */ - if (!strcmp(LUSTRE_MDC_NAME, dash + 1)) { - dash--; - for (; dash > svname && *dash != '-' && *dash != ':'; dash--) - ; - if (dash == svname) - return -EINVAL; - } + dash = svname + strnlen(svname, 8); /* max fsname length is 8 */ + for (; dash > svname && *dash != '-' && *dash != ':'; dash--) + ; + if (dash == svname) + return -EINVAL; if (fsname != NULL) { strncpy(fsname, svname, dash - svname); @@ -697,15 +697,15 @@ int server_name2svname(const char *label, char *svname, const char **endptr, size_t svsize) { int rc; - const const char *dash; + const char *dash; /* We use server_name2fsname() just for parsing */ rc = server_name2fsname(label, NULL, &dash); if (rc != 0) return rc; - if (*dash != '-') - return -1; + if (endptr != NULL) + *endptr = dash; if (strlcpy(svname, dash + 1, svsize) >= svsize) return -E2BIG; @@ -730,9 +730,6 @@ int server_name2index(const char *svname, __u32 *idx, const char **endptr) if (rc != 0) return rc; - if (*dash != '-') - return -EINVAL; - dash++; if (strncmp(dash, "MDT", 3) == 0) @@ -744,11 +741,20 @@ int server_name2index(const char *svname, __u32 *idx, const char **endptr) dash += 3; - if (strcmp(dash, "all") == 0) + if (strncmp(dash, "all", 3) == 0) { + if (endptr != NULL) + *endptr = dash + 3; return rc | LDD_F_SV_ALL; + } index = simple_strtoul(dash, (char **)endptr, 16); - *idx = index; + if (idx != NULL) + *idx = index; + + /* Account for -mdc after index that is possible when specifying mdt */ + if (endptr != NULL && strncmp(LUSTRE_MDC_NAME, *endptr + 1, + sizeof(LUSTRE_MDC_NAME)-1) == 0) + *endptr += sizeof(LUSTRE_MDC_NAME); return rc; } @@ -858,13 +864,15 @@ static int lmd_make_exclusion(struct lustre_mount_data *lmd, const char *ptr) s1++; rc = server_name2index(s1, &index, &s2); if (rc < 0) { - CERROR("Can't parse server name '%s'\n", s1); + CERROR("Can't parse server name '%s': rc = %d\n", + s1, rc); break; } if (rc == LDD_F_SV_TYPE_OST) exclude_list[lmd->lmd_exclude_count++] = index; else - CDEBUG(D_MOUNT, "ignoring exclude %.7s\n", s1); + CDEBUG(D_MOUNT, "ignoring exclude %.*s: type = %#x\n", + (uint)(s2-s1), s1, rc); s1 = s2; /* now we are pointing at ':' (next exclude) or ',' (end of excludes) */ -- GitLab From bd994071a9b680fd2a6ba60c640700af111b037b Mon Sep 17 00:00:00 2001 From: Fan Yong Date: Tue, 23 Jul 2013 00:07:01 +0800 Subject: [PATCH 055/942] staging/lustre/llite: return valid fsid for statfs Lustre uses 64-bits inode number to identify object on client side. When re-export Lustre via NFS, NFS will detect whether support fsid via statfs(). For the non-support case, it will only recognizes and packs low 32-bits inode number in nfs handle. Such handle cannot be used to locate the object properly. To avoid patch linux kernel, Lustre client should generate fsid and return it via statfs() to up layer. Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2904 Lustre-change: http://review.whamcloud.com/6493 Signed-off-by: Fan Yong Reviewed-by: Andreas Dilger Reviewed-by: Lai Siyao Reviewed-by: Oleg Drokin Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lustre/llite/llite_internal.h | 2 ++ drivers/staging/lustre/lustre/llite/llite_lib.c | 6 ++++-- drivers/staging/lustre/lustre/llite/llite_nfs.c | 16 ++++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 0534665df905a..28aed684364f9 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -505,6 +505,7 @@ struct ll_sb_info { * clustred nfs */ struct rmtacl_ctl_table ll_rct; struct eacl_table ll_et; + __kernel_fsid_t ll_fsid; }; #define LL_DEFAULT_MAX_RW_CHUNK (32 * 1024 * 1024) @@ -833,6 +834,7 @@ char *ll_get_fsname(struct super_block *sb, char *buf, int buflen); /* llite/llite_nfs.c */ extern struct export_operations lustre_export_operations; __u32 get_uuid2int(const char *name, int len); +void get_uuid2fsid(const char *name, int len, __kernel_fsid_t *fsid); struct inode *search_inode_for_lustre(struct super_block *sb, const struct lu_fid *fid); diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 39d519b30cb4d..d7d87b1539b4f 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -583,8 +583,10 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, /* s_dev is also used in lt_compare() to compare two fs, but that is * only a node-local comparison. */ uuid = obd_get_uuid(sbi->ll_md_exp); - if (uuid != NULL) + if (uuid != NULL) { sb->s_dev = get_uuid2int(uuid->uuid, strlen(uuid->uuid)); + get_uuid2fsid(uuid->uuid, strlen(uuid->uuid), &sbi->ll_fsid); + } if (data != NULL) OBD_FREE_PTR(data); @@ -1615,7 +1617,7 @@ int ll_statfs(struct dentry *de, struct kstatfs *sfs) sfs->f_blocks = osfs.os_blocks; sfs->f_bfree = osfs.os_bfree; sfs->f_bavail = osfs.os_bavail; - + sfs->f_fsid = ll_s2sbi(sb)->ll_fsid; return 0; } diff --git a/drivers/staging/lustre/lustre/llite/llite_nfs.c b/drivers/staging/lustre/lustre/llite/llite_nfs.c index f142a1ec3f86f..b830004803e4a 100644 --- a/drivers/staging/lustre/lustre/llite/llite_nfs.c +++ b/drivers/staging/lustre/lustre/llite/llite_nfs.c @@ -58,6 +58,22 @@ __u32 get_uuid2int(const char *name, int len) return (key0 << 1); } +void get_uuid2fsid(const char *name, int len, __kernel_fsid_t *fsid) +{ + __u64 key = 0, key0 = 0x12a3fe2d, key1 = 0x37abe8f9; + + while (len--) { + key = key1 + (key0 ^ (*name++ * 7152373)); + if (key & 0x8000000000000000ULL) + key -= 0x7fffffffffffffffULL; + key1 = key0; + key0 = key; + } + + fsid->val[0] = key; + fsid->val[1] = key >> 32; +} + static int ll_nfs_test_inode(struct inode *inode, void *opaque) { return lu_fid_eq(&ll_i2info(inode)->lli_fid, -- GitLab From cb6a2db640d94a9dc29dabb9bf58d4ff2531d42c Mon Sep 17 00:00:00 2001 From: Keith Mannthey Date: Tue, 23 Jul 2013 00:07:02 +0800 Subject: [PATCH 056/942] staging/lustre/llite: error of listxattr when buffer is small According to the standard, listxattr(2) should return -1 and errno should be set to ERANGE if the size of the list buffer is too small to hold the result. However ll_listxattr() will return a value bigger than the size of buffer in some cases. Let's assume listxattr(2) returns SIZE when it is called with a large enough list buffer. If it's called again with a list buffer whose size is smaller than SIZE but bigger than (SIZE - 12), then listxattr(2) will return SIZE too. This patch fixes the problem. Original patch by Li Xi Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3403 Lustre-change: http://review.whamcloud.com/6463 Signed-off-by: Keith Mannthey Reviewed-by: Li Xi Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/xattr.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c index 0a11902c4d2b3..2e3ff6d088bc6 100644 --- a/drivers/staging/lustre/lustre/llite/xattr.c +++ b/drivers/staging/lustre/lustre/llite/xattr.c @@ -564,7 +564,12 @@ ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size) const size_t name_len = sizeof("lov") - 1; const size_t total_len = prefix_len + name_len + 1; - if (buffer && (rc + total_len) <= size) { + if (((rc + total_len) > size) && (buffer != NULL)) { + ptlrpc_req_finished(request); + return -ERANGE; + } + + if (buffer != NULL) { buffer += rc; memcpy(buffer, XATTR_LUSTRE_PREFIX, prefix_len); memcpy(buffer + prefix_len, "lov", name_len); -- GitLab From 4c2060a8942223ee91764736439085d586538f24 Mon Sep 17 00:00:00 2001 From: Patrick Farrell Date: Tue, 23 Jul 2013 00:07:03 +0800 Subject: [PATCH 057/942] staging/lustre/llite: Anonymous dentry incorrectly identified as root When exporting Lustre via NFS on SLES11SP2, this check incorrectly identifies anonymous dentries as root dentries. This is due to a change in SLES11SP2 which makes the d_name.name for anonymous dentries the same as that for root dentries. (Details in LU-3484.) This changes the check to directly compare the value of the dentry pointer to the root dentry pointer found in the superblock, rather than using the name. Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3484 Lustre-change: http://review.whamcloud.com/6726 Signed-off-by: Patrick Farrell Reviewed-by: Bob Glossman Reviewed-by: Andreas Dilger Reviewed-by: Peng Tao Reviewed-by: James Simmons Reviewed-by: Alexey Shvetsov Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/dcache.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/dcache.c b/drivers/staging/lustre/lustre/llite/dcache.c index a160a840d5829..0d49e1bfb6bbf 100644 --- a/drivers/staging/lustre/lustre/llite/dcache.c +++ b/drivers/staging/lustre/lustre/llite/dcache.c @@ -295,9 +295,10 @@ void ll_invalidate_aliases(struct inode *inode) dentry->d_name.name, dentry, dentry->d_parent, dentry->d_inode, dentry->d_flags); - if (dentry->d_name.len == 1 && dentry->d_name.name[0] == '/') { - CERROR("called on root (?) dentry=%p, inode=%p " - "ino=%lu\n", dentry, inode, inode->i_ino); + if (unlikely(dentry == dentry->d_sb->s_root)) { + CERROR("%s: called on root dentry=%p, fid="DFID"\n", + ll_get_fsname(dentry->d_sb, NULL, 0), + dentry, PFID(ll_inode2fid(inode))); lustre_dump_dentry(dentry, 1); dump_stack(); } -- GitLab From 73e8636e4231c3078a4a02f63702d78bf24d55af Mon Sep 17 00:00:00 2001 From: Keith Mannthey Date: Tue, 23 Jul 2013 00:07:06 +0800 Subject: [PATCH 058/942] staging/lustre/style: removes obsolete EXPORT_SYMTAB macros v2 EXPORT_SYMTAB is obsolete after 2.4 kernel, this patch removes EXPORT_SYMTAB from the source code again. Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-1347 Lustre-change: http://review.whamcloud.com/6739 Signed-off-by: Keith Mannthey Reviewed-by: Peng Tao Reviewed-by: Liu Xuezhao Reviewed-by: Andreas Dilger Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c | 3 --- drivers/staging/lustre/lustre/libcfs/libcfs_lock.c | 3 --- drivers/staging/lustre/lustre/libcfs/libcfs_mem.c | 3 --- drivers/staging/lustre/lustre/obdclass/llog_osd.c | 4 ---- 4 files changed, 13 deletions(-) diff --git a/drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c b/drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c index 8e88eb59dd51d..1fb37008cda24 100644 --- a/drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c +++ b/drivers/staging/lustre/lustre/libcfs/libcfs_cpu.c @@ -33,9 +33,6 @@ * Author: liang@whamcloud.com */ -#ifndef EXPORT_SYMTAB -# define EXPORT_SYMTAB -#endif #define DEBUG_SUBSYSTEM S_LNET #include diff --git a/drivers/staging/lustre/lustre/libcfs/libcfs_lock.c b/drivers/staging/lustre/lustre/libcfs/libcfs_lock.c index 8d6c4adf2ee6a..a2ce4c0eb3dcf 100644 --- a/drivers/staging/lustre/lustre/libcfs/libcfs_lock.c +++ b/drivers/staging/lustre/lustre/libcfs/libcfs_lock.c @@ -30,9 +30,6 @@ * Author: liang@whamcloud.com */ -#ifndef EXPORT_SYMTAB -# define EXPORT_SYMTAB -#endif #define DEBUG_SUBSYSTEM S_LNET #include diff --git a/drivers/staging/lustre/lustre/libcfs/libcfs_mem.c b/drivers/staging/lustre/lustre/libcfs/libcfs_mem.c index 879137303482a..feab537c728cd 100644 --- a/drivers/staging/lustre/lustre/libcfs/libcfs_mem.c +++ b/drivers/staging/lustre/lustre/libcfs/libcfs_mem.c @@ -31,9 +31,6 @@ * Author: liang@whamcloud.com */ -#ifndef EXPORT_SYMTAB -# define EXPORT_SYMTAB -#endif #define DEBUG_SUBSYSTEM S_LNET #include diff --git a/drivers/staging/lustre/lustre/obdclass/llog_osd.c b/drivers/staging/lustre/lustre/obdclass/llog_osd.c index 6dbd21a863c2d..87d5012cfc563 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_osd.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_osd.c @@ -41,10 +41,6 @@ #define DEBUG_SUBSYSTEM S_LOG -#ifndef EXPORT_SYMTAB -#define EXPORT_SYMTAB -#endif - #include #include #include -- GitLab From 99a92265bd61d7934542c5f398fd241c30287b70 Mon Sep 17 00:00:00 2001 From: jcl Date: Tue, 23 Jul 2013 00:07:07 +0800 Subject: [PATCH 059/942] staging/lustre/mdt: HSM on disk actions record HSM coordinator memorizes all actions in a llog This patch implements the methods needed to create update display these records. Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3339 Lustre-change: http://review.whamcloud.com/6529 Signed-off-by: JC Lafoucriere Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/include/lprocfs_status.h | 3 - .../lustre/lustre/include/lustre/lustre_idl.h | 47 ++++++++++++++++ .../lustre/lustre/include/lustre_disk.h | 56 ++++++++++--------- drivers/staging/lustre/lustre/include/obd.h | 7 ++- .../lustre/lustre/obdclass/llog_swab.c | 17 ++++++ 5 files changed, 97 insertions(+), 33 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index 294fb7807c8c1..7a0536436120e 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -826,9 +826,6 @@ extern int lprocfs_quota_rd_qs_factor(char *page, char **start, loff_t off, extern int lprocfs_quota_wr_qs_factor(struct file *file, const char *buffer, unsigned long count, void *data); - - - #else /* LPROCFS is not defined */ diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h index 3aaa869b711f3..984235ccd3a5f 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h @@ -2986,6 +2986,7 @@ typedef enum { /* LLOG_JOIN_REC = LLOG_OP_MAGIC | 0x50000, obsolete 1.8.0 */ CHANGELOG_REC = LLOG_OP_MAGIC | 0x60000, CHANGELOG_USER_REC = LLOG_OP_MAGIC | 0x70000, + HSM_AGENT_REC = LLOG_OP_MAGIC | 0x80000, LLOG_HDR_MAGIC = LLOG_OP_MAGIC | 0x45539, LLOG_LOGID_MAGIC = LLOG_OP_MAGIC | 0x4553b, } llog_op_type; @@ -3105,6 +3106,52 @@ struct llog_changelog_user_rec { struct llog_rec_tail cur_tail; } __attribute__((packed)); +enum agent_req_status { + ARS_WAITING, + ARS_STARTED, + ARS_FAILED, + ARS_CANCELED, + ARS_SUCCEED, +}; + +static inline char *agent_req_status2name(enum agent_req_status ars) +{ + switch (ars) { + case ARS_WAITING: + return "WAITING"; + case ARS_STARTED: + return "STARTED"; + case ARS_FAILED: + return "FAILED"; + case ARS_CANCELED: + return "CANCELED"; + case ARS_SUCCEED: + return "SUCCEED"; + default: + return "UNKNOWN"; + } +} + +static inline bool agent_req_in_final_state(enum agent_req_status ars) +{ + return ((ars == ARS_SUCCEED) || (ars == ARS_FAILED) || + (ars == ARS_CANCELED)); +} + +struct llog_agent_req_rec { + struct llog_rec_hdr arr_hdr; /**< record header */ + __u32 arr_status; /**< status of the request */ + /* must match enum + * agent_req_status */ + __u32 arr_archive_id; /**< backend archive number */ + __u64 arr_flags; /**< req flags */ + __u64 arr_compound_id; /**< compound cookie */ + __u64 arr_req_create; /**< req. creation time */ + __u64 arr_req_change; /**< req. status change time */ + struct hsm_action_item arr_hai; /**< req. to the agent */ + struct llog_rec_tail arr_tail; /**< record tail for_sizezof_only */ +} __attribute__((packed)); + /* Old llog gen for compatibility */ struct llog_gen { __u64 mnt_cnt; diff --git a/drivers/staging/lustre/lustre/include/lustre_disk.h b/drivers/staging/lustre/lustre/include/lustre_disk.h index 8db6086ea4ea2..9228b165b258d 100644 --- a/drivers/staging/lustre/lustre/include/lustre_disk.h +++ b/drivers/staging/lustre/lustre/include/lustre_disk.h @@ -53,20 +53,21 @@ /****************** on-disk files *********************/ -#define MDT_LOGS_DIR "LOGS" /* COMPAT_146 */ -#define MOUNT_CONFIGS_DIR "CONFIGS" -#define CONFIGS_FILE "mountdata" +#define MDT_LOGS_DIR "LOGS" /* COMPAT_146 */ +#define MOUNT_CONFIGS_DIR "CONFIGS" +#define CONFIGS_FILE "mountdata" /** Persistent mount data are stored on the disk in this file. */ -#define MOUNT_DATA_FILE MOUNT_CONFIGS_DIR"/"CONFIGS_FILE -#define LAST_RCVD "last_rcvd" -#define LOV_OBJID "lov_objid" +#define MOUNT_DATA_FILE MOUNT_CONFIGS_DIR"/"CONFIGS_FILE +#define LAST_RCVD "last_rcvd" +#define LOV_OBJID "lov_objid" #define LOV_OBJSEQ "lov_objseq" -#define HEALTH_CHECK "health_check" -#define CAPA_KEYS "capa_keys" -#define CHANGELOG_USERS "changelog_users" -#define MGS_NIDTBL_DIR "NIDTBL_VERSIONS" -#define QMT_DIR "quota_master" -#define QSD_DIR "quota_slave" +#define HEALTH_CHECK "health_check" +#define CAPA_KEYS "capa_keys" +#define CHANGELOG_USERS "changelog_users" +#define MGS_NIDTBL_DIR "NIDTBL_VERSIONS" +#define QMT_DIR "quota_master" +#define QSD_DIR "quota_slave" +#define HSM_ACTIONS "hsm_actions" /****************** persistent mount data *********************/ @@ -226,21 +227,22 @@ struct lustre_mount_data { char *lmd_osd_type; /* OSD type */ }; -#define LMD_FLG_SERVER 0x0001 /* Mounting a server */ -#define LMD_FLG_CLIENT 0x0002 /* Mounting a client */ -#define LMD_FLG_ABORT_RECOV 0x0008 /* Abort recovery */ -#define LMD_FLG_NOSVC 0x0010 /* Only start MGS/MGC for servers, - no other services */ -#define LMD_FLG_NOMGS 0x0020 /* Only start target for servers, reusing - existing MGS services */ -#define LMD_FLG_WRITECONF 0x0040 /* Rewrite config log */ -#define LMD_FLG_NOIR 0x0080 /* NO imperative recovery */ -#define LMD_FLG_NOSCRUB 0x0100 /* Do not trigger scrub automatically */ -#define LMD_FLG_MGS 0x0200 /* Also start MGS along with server */ -#define LMD_FLG_IAM 0x0400 /* IAM dir */ -#define LMD_FLG_NO_PRIMNODE 0x0800 /* all nodes are service nodes */ -#define LMD_FLG_VIRGIN 0x1000 /* the service registers first time */ -#define LMD_FLG_UPDATE 0x2000 /* update parameters */ +#define LMD_FLG_SERVER 0x0001 /* Mounting a server */ +#define LMD_FLG_CLIENT 0x0002 /* Mounting a client */ +#define LMD_FLG_ABORT_RECOV 0x0008 /* Abort recovery */ +#define LMD_FLG_NOSVC 0x0010 /* Only start MGS/MGC for servers, + no other services */ +#define LMD_FLG_NOMGS 0x0020 /* Only start target for servers, reusing + existing MGS services */ +#define LMD_FLG_WRITECONF 0x0040 /* Rewrite config log */ +#define LMD_FLG_NOIR 0x0080 /* NO imperative recovery */ +#define LMD_FLG_NOSCRUB 0x0100 /* Do not trigger scrub automatically */ +#define LMD_FLG_MGS 0x0200 /* Also start MGS along with server */ +#define LMD_FLG_IAM 0x0400 /* IAM dir */ +#define LMD_FLG_NO_PRIMNODE 0x0800 /* all nodes are service nodes */ +#define LMD_FLG_VIRGIN 0x1000 /* the service registers first time */ +#define LMD_FLG_UPDATE 0x2000 /* update parameters */ +#define LMD_FLG_HSM 0x4000 /* Start coordinator */ #define lmd_is_client(x) ((x)->lmd_flags & LMD_FLG_CLIENT) diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index fbf997ffa9276..797a6afbddaa9 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -292,9 +292,10 @@ enum llog_ctxt_id { LLOG_TEST_REPL_CTXT, LLOG_LOVEA_ORIG_CTXT, LLOG_LOVEA_REPL_CTXT, - LLOG_CHANGELOG_ORIG_CTXT, /**< changelog generation on mdd */ - LLOG_CHANGELOG_REPL_CTXT, /**< changelog access on clients */ - LLOG_CHANGELOG_USER_ORIG_CTXT, /**< for multiple changelog consumers */ + LLOG_CHANGELOG_ORIG_CTXT, /**< changelog generation on mdd */ + LLOG_CHANGELOG_REPL_CTXT, /**< changelog access on clients */ + LLOG_CHANGELOG_USER_ORIG_CTXT, /**< for multiple changelog consumers */ + LLOG_AGENT_ORIG_CTXT, /**< agent requests generation on cdt */ LLOG_MAX_CTXTS }; diff --git a/drivers/staging/lustre/lustre/obdclass/llog_swab.c b/drivers/staging/lustre/lustre/obdclass/llog_swab.c index dedfecff95bcd..a75b04ee52725 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_swab.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_swab.c @@ -203,6 +203,23 @@ void lustre_swab_llog_rec(struct llog_rec_hdr *rec) break; } + case HSM_AGENT_REC: { + struct llog_agent_req_rec *arr = + (struct llog_agent_req_rec *)rec; + + __swab32s(&arr->arr_hai.hai_len); + __swab32s(&arr->arr_hai.hai_action); + lustre_swab_lu_fid(&arr->arr_hai.hai_fid); + lustre_swab_lu_fid(&arr->arr_hai.hai_dfid); + __swab64s(&arr->arr_hai.hai_cookie); + __swab64s(&arr->arr_hai.hai_extent.offset); + __swab64s(&arr->arr_hai.hai_extent.length); + __swab64s(&arr->arr_hai.hai_gid); + /* no swabing for opaque data */ + /* hai_data[0]; */ + break; + } + case MDS_SETATTR64_REC: { struct llog_setattr64_rec *lsr = -- GitLab From 70b749d43d1654a4fda1b281ad08d194d6aada2b Mon Sep 17 00:00:00 2001 From: Fan Yong Date: Tue, 23 Jul 2013 00:07:08 +0800 Subject: [PATCH 060/942] staging/lustre/scrub: purge inconsistenct objects after OI scrub When OI scrub repaired the found inconsistency, it needs to purge the old object out of cache; otherwise, others may still use those cached stale information. Original patch adds functions in obdclass that is only used by server. Drop that part. Only merge in error handling change. Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3335 Lustre-change: http://review.whamcloud.com/6697 Signed-off-by: Fan Yong Reviewed-by: Alex Zhuravlev Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/obdclass/lu_object.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c index 5559732c0437e..ce0444f6911ce 100644 --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c @@ -538,7 +538,7 @@ static struct lu_object *htable_lookup(struct lu_site *s, __u64 ver = cfs_hash_bd_version_get(bd); if (*version == ver) - return NULL; + return ERR_PTR(-ENOENT); *version = ver; bkt = cfs_hash_bd_extra_get(s->ls_obj_hash, bd); @@ -547,7 +547,7 @@ static struct lu_object *htable_lookup(struct lu_site *s, hnode = cfs_hash_bd_peek_locked(s->ls_obj_hash, bd, (void *)f); if (hnode == NULL) { lprocfs_counter_incr(s->ls_stats, LU_SS_CACHE_MISS); - return NULL; + return ERR_PTR(-ENOENT); } h = container_of0(hnode, struct lu_object_header, loh_hash); @@ -651,7 +651,7 @@ static struct lu_object *lu_object_find_try(const struct lu_env *env, cfs_hash_bd_get_and_lock(hs, (void *)f, &bd, 1); o = htable_lookup(s, &bd, f, waiter, &version); cfs_hash_bd_unlock(hs, &bd, 1); - if (o != NULL) + if (!IS_ERR(o) || PTR_ERR(o) != -ENOENT) return o; /* @@ -667,7 +667,7 @@ static struct lu_object *lu_object_find_try(const struct lu_env *env, cfs_hash_bd_lock(hs, &bd, 1); shadow = htable_lookup(s, &bd, f, waiter, &version); - if (likely(shadow == NULL)) { + if (likely(IS_ERR(shadow) && PTR_ERR(shadow) == -ENOENT)) { struct lu_site_bkt_data *bkt; bkt = cfs_hash_bd_extra_get(hs, &bd); @@ -2076,7 +2076,7 @@ void lu_object_assign_fid(const struct lu_env *env, struct lu_object *o, cfs_hash_bd_get_and_lock(hs, (void *)fid, &bd, 1); shadow = htable_lookup(s, &bd, fid, &waiter, &version); /* supposed to be unique */ - LASSERT(shadow == NULL); + LASSERT(IS_ERR(shadow) && PTR_ERR(shadow) == -ENOENT); *old = *fid; bkt = cfs_hash_bd_extra_get(hs, &bd); cfs_hash_bd_add_locked(hs, &bd, &o->lo_header->loh_hash); -- GitLab From cd6b328cd0c79bba866ffb60ff447b84cfaacf3b Mon Sep 17 00:00:00 2001 From: Bruno Faccini Date: Tue, 23 Jul 2013 00:07:09 +0800 Subject: [PATCH 061/942] staging/lustre/mdc: Keep resend FLocks FLocks requests (particulary F_UNLCKs) can't be trashed upon comm problems with Server/MDS nor upon kill/exit, thus we need to keep retry/send. Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2665 Lustre-change: http://review.whamcloud.com/6415 Signed-off-by: Bruno Faccini Reviewed-by: Bobi Jam Reviewed-by: Oleg Drokin Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/mdc/mdc_locks.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/mdc/mdc_locks.c b/drivers/staging/lustre/lustre/mdc/mdc_locks.c index ab88a46c1a275..803c390e1c35d 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_locks.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_locks.c @@ -823,7 +823,13 @@ int mdc_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo, /* For flock requests we immediatelly return without further delay and let caller deal with the rest, since rest of this function metadata processing makes no sense for flock - requests anyway */ + requests anyway. But in case of problem during comms with + Server (ETIMEDOUT) or any signal/kill attempt (EINTR), we + can not rely on caller and this mainly for F_UNLCKs + (explicits or automatically generated by Kernel to clean + current FLocks upon exit) that can't be trashed */ + if ((rc == -EINTR) || (rc == -ETIMEDOUT)) + goto resend; RETURN(rc); } -- GitLab From c4f395539790680e6ab772876ddca4620e019c14 Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Sun, 21 Jul 2013 03:38:08 +0900 Subject: [PATCH 062/942] staging: lustre: Fix typo in printk Correct spelling typo in printk within staging/lustre Signed-off-by: Masanari Iida Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/vvp_io.c | 2 +- drivers/staging/lustre/lustre/obdclass/genops.c | 2 +- drivers/staging/lustre/lustre/obdecho/echo_client.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/gss/gss_krb5_mech.c | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/vvp_io.c b/drivers/staging/lustre/lustre/llite/vvp_io.c index 23149f96f136e..50a4c9104f6d7 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_io.c +++ b/drivers/staging/lustre/lustre/llite/vvp_io.c @@ -970,7 +970,7 @@ static int vvp_io_commit_write(const struct lu_env *env, LINVRNT(cl_page_is_vmlocked(env, pg)); LASSERT(vmpage->mapping->host == inode); - LU_OBJECT_HEADER(D_INODE, env, &obj->co_lu, "commiting page write\n"); + LU_OBJECT_HEADER(D_INODE, env, &obj->co_lu, "committing page write\n"); CL_PAGE_HEADER(D_PAGE, env, pg, "committing: [%d, %d]\n", from, to); /* diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index d96876e0bc68e..ea041a34f5f7e 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -1484,7 +1484,7 @@ int obd_export_evict_by_uuid(struct obd_device *obd, const char *uuid) CERROR("%s: can't disconnect %s: no exports found\n", obd->obd_name, uuid); } else { - CWARN("%s: evicting %s at adminstrative request\n", + CWARN("%s: evicting %s at administrative request\n", obd->obd_name, doomed_exp->exp_client_uuid.uuid); class_fail_export(doomed_exp); class_export_put(doomed_exp); diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c index de8f4ea7f156f..2e52ef2f92a9b 100644 --- a/drivers/staging/lustre/lustre/obdecho/echo_client.c +++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c @@ -649,7 +649,7 @@ static int echo_site_init(const struct lu_env *env, struct echo_device *ed) /* initialize site */ rc = cl_site_init(site, &ed->ed_cl); if (rc) { - CERROR("Cannot initilize site for echo client(%d)\n", rc); + CERROR("Cannot initialize site for echo client(%d)\n", rc); return rc; } diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_krb5_mech.c b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_krb5_mech.c index 4b28931bbc962..91da7637756d6 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_krb5_mech.c +++ b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_krb5_mech.c @@ -341,7 +341,7 @@ __u32 import_context_rfc1964(struct krb5_ctx *kctx, char *p, char *end) if (p != end) goto out_err; - CDEBUG(D_SEC, "succesfully imported rfc1964 context\n"); + CDEBUG(D_SEC, "successfully imported rfc1964 context\n"); return 0; out_err: return GSS_S_FAILURE; @@ -403,7 +403,7 @@ __u32 import_context_rfc4121(struct krb5_ctx *kctx, char *p, char *end) if (get_keyblock(&p, end, &kctx->kc_keyc, keysize)) goto out_err; - CDEBUG(D_SEC, "succesfully imported v2 context\n"); + CDEBUG(D_SEC, "successfully imported v2 context\n"); return 0; out_err: return GSS_S_FAILURE; @@ -494,7 +494,7 @@ __u32 gss_copy_reverse_context_kerberos(struct gss_ctx *gctx, goto out_err; gctx_new->internal_ctx_id = knew; - CDEBUG(D_SEC, "succesfully copied reverse context\n"); + CDEBUG(D_SEC, "successfully copied reverse context\n"); return GSS_S_COMPLETE; out_err: -- GitLab From 1dc8548c307c1cbab90cb9c754effb2d030cafdd Mon Sep 17 00:00:00 2001 From: Laurent Navet Date: Fri, 5 Jul 2013 14:26:33 +0200 Subject: [PATCH 063/942] staging: lustre: use ERR_CAST() function use ERR_CAST() function instead of ERR_PTR() and PTR_ERR() found using coccinelle and err_cast.cocci Signed-off-by: Laurent Navet Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/llite_nfs.c | 2 +- drivers/staging/lustre/lustre/llite/rw.c | 2 +- drivers/staging/lustre/lustre/obdclass/local_storage.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_nfs.c b/drivers/staging/lustre/lustre/llite/llite_nfs.c index b830004803e4a..32362ece2a7b3 100644 --- a/drivers/staging/lustre/lustre/llite/llite_nfs.c +++ b/drivers/staging/lustre/lustre/llite/llite_nfs.c @@ -147,7 +147,7 @@ ll_iget_for_nfs(struct super_block *sb, struct lu_fid *fid, struct lu_fid *paren inode = search_inode_for_lustre(sb, fid); if (IS_ERR(inode)) - RETURN(ERR_PTR(PTR_ERR(inode))); + RETURN(ERR_CAST(inode)); if (is_bad_inode(inode)) { /* we didn't find the right inode.. */ diff --git a/drivers/staging/lustre/lustre/llite/rw.c b/drivers/staging/lustre/lustre/llite/rw.c index f48766e6a2128..43b5f0d2b72aa 100644 --- a/drivers/staging/lustre/lustre/llite/rw.c +++ b/drivers/staging/lustre/lustre/llite/rw.c @@ -110,7 +110,7 @@ static struct ll_cl_context *ll_cl_init(struct file *file, env = cl_env_get(&refcheck); if (IS_ERR(env)) - return ERR_PTR(PTR_ERR(env)); + return ERR_CAST(env); lcc = &vvp_env_info(env)->vti_io_ctx; memset(lcc, 0, sizeof(*lcc)); diff --git a/drivers/staging/lustre/lustre/obdclass/local_storage.c b/drivers/staging/lustre/lustre/obdclass/local_storage.c index 3be35a83a495f..e1db7abd300a3 100644 --- a/drivers/staging/lustre/lustre/obdclass/local_storage.c +++ b/drivers/staging/lustre/lustre/obdclass/local_storage.c @@ -443,7 +443,7 @@ struct dt_object *local_file_find_or_create_with_fid(const struct lu_env *env, ls = ls_device_get(dt); if (IS_ERR(ls)) { - dto = ERR_PTR(PTR_ERR(ls)); + dto = ERR_CAST(ls); } else { /* create the object */ dti->dti_attr.la_valid = LA_MODE; @@ -537,7 +537,7 @@ local_index_find_or_create_with_fid(const struct lu_env *env, ls = ls_device_get(dt); if (IS_ERR(ls)) { - dto = ERR_PTR(PTR_ERR(ls)); + dto = ERR_CAST(ls); } else { /* create the object */ dti->dti_attr.la_valid = LA_MODE; -- GitLab From b0d67ac7771683b08a29fc21101e785a724cb7a6 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 23 Jul 2013 14:02:13 -0700 Subject: [PATCH 064/942] staging: lustre: remove unused "helper" macros This removes a bunch of unused helper macros in the kp30.h file as they were not being used anywhere, and they better not be used in the future. Cc: Peng Tao Cc: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../lustre/include/linux/libcfs/linux/kp30.h | 42 ------------------- 1 file changed, 42 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/kp30.h b/drivers/staging/lustre/include/linux/libcfs/linux/kp30.h index 4b7ae1c5bd3b8..5ba099595a99d 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/kp30.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/kp30.h @@ -74,34 +74,6 @@ #include -#define prepare_work(wq,cb,cbdata) \ -do { \ - INIT_WORK((wq), (void *)(cb)); \ -} while (0) - -#define cfs_get_work_data(type,field,data) container_of(data,type,field) - - -#define our_recalc_sigpending(current) recalc_sigpending() -#define strtok(a,b) strpbrk(a, b) -#define work_struct_t struct work_struct - -#ifdef CONFIG_SMP -#else -#endif - - -#define SEM_COUNT(sem) ((sem)->count) - - -/* ------------------------------------------------------------------- */ - -#define PORTAL_SYMBOL_REGISTER(x) -#define PORTAL_SYMBOL_UNREGISTER(x) - - - - /******************************************************************************/ /* Module parameter support */ #define CFS_MODULE_PARM(name, t, type, perm, desc) \ @@ -112,24 +84,10 @@ do { \ /******************************************************************************/ -#if (__GNUC__) -/* Use the special GNU C __attribute__ hack to have the compiler check the - * printf style argument string against the actual argument count and - * types. - */ -#ifdef printf -# warning printf has been defined as a macro... -# undef printf -#endif - -#endif /* __GNUC__ */ - # define fprintf(a, format, b...) CDEBUG(D_OTHER, format , ## b) # define printf(format, b...) CDEBUG(D_OTHER, format , ## b) # define time(a) CURRENT_TIME -# define cfs_num_present_cpus() num_present_cpus() - /******************************************************************************/ /* Light-weight trace * Support for temporary event tracing with minimal Heisenberg effect. */ -- GitLab From 54db996e6dab51571718e8e97c26fdc695e254ac Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 24 Jun 2013 16:55:14 -0700 Subject: [PATCH 065/942] staging: comedi: drivers: introduce comedi_alloc_devpriv() Introduce a helper function to allocate memory and set the comedi_device private data pointer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedidev.h | 1 + drivers/staging/comedi/drivers.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index b75915f30f484..bfbe4160edf07 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -357,6 +357,7 @@ void comedi_buf_memcpy_from(struct comedi_async *async, unsigned int offset, /* drivers.c - general comedi driver functions */ +void *comedi_alloc_devpriv(struct comedi_device *, size_t); int comedi_alloc_subdevices(struct comedi_device *, int); int comedi_load_firmware(struct comedi_device *, struct device *, diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index e25eba5713c15..87df7960c96fd 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -57,6 +57,18 @@ static void comedi_clear_hw_dev(struct comedi_device *dev) dev->hw_dev = NULL; } +/** + * comedi_alloc_devpriv() - Allocate memory for the device private data. + * @dev: comedi_device struct + * @size: size of the memory to allocate + */ +void *comedi_alloc_devpriv(struct comedi_device *dev, size_t size) +{ + dev->private = kzalloc(size, GFP_KERNEL); + return dev->private; +} +EXPORT_SYMBOL_GPL(comedi_alloc_devpriv); + int comedi_alloc_subdevices(struct comedi_device *dev, int num_subdevices) { struct comedi_subdevice *s; -- GitLab From 0bdab509bf9c6d838dc0a3b1d68bbf841fc20b5a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 24 Jun 2013 16:55:44 -0700 Subject: [PATCH 066/942] staging: comedi: use comedi_alloc_devpriv() Use the helper function to allocate memory and set the comedi_device private data pointer. This removes the dependency on slab.h from most of the drivers so remove the global #include in comedidev.h and the local #include in some of the drivers. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedidev.h | 1 - drivers/staging/comedi/drivers/8255_pci.c | 3 +-- drivers/staging/comedi/drivers/addi-data/addi_common.c | 3 +-- drivers/staging/comedi/drivers/addi_apci_1032.c | 3 +-- drivers/staging/comedi/drivers/addi_apci_1516.c | 3 +-- drivers/staging/comedi/drivers/addi_apci_1710.c | 3 +-- drivers/staging/comedi/drivers/addi_apci_3120.c | 3 +-- drivers/staging/comedi/drivers/addi_apci_3501.c | 3 +-- drivers/staging/comedi/drivers/addi_apci_3xxx.c | 3 +-- drivers/staging/comedi/drivers/adl_pci6208.c | 3 +-- drivers/staging/comedi/drivers/adl_pci9111.c | 3 +-- drivers/staging/comedi/drivers/adl_pci9118.c | 6 ++---- drivers/staging/comedi/drivers/adq12b.c | 3 +-- drivers/staging/comedi/drivers/adv_pci1710.c | 3 +-- drivers/staging/comedi/drivers/adv_pci1723.c | 3 +-- drivers/staging/comedi/drivers/adv_pci1724.c | 3 +-- drivers/staging/comedi/drivers/adv_pci_dio.c | 3 +-- drivers/staging/comedi/drivers/aio_aio12_8.c | 3 +-- drivers/staging/comedi/drivers/amplc_dio200.c | 5 +---- drivers/staging/comedi/drivers/amplc_dio200_common.c | 1 - drivers/staging/comedi/drivers/amplc_dio200_pci.c | 4 +--- drivers/staging/comedi/drivers/amplc_pc236.c | 6 ++---- drivers/staging/comedi/drivers/amplc_pci224.c | 7 ++----- drivers/staging/comedi/drivers/amplc_pci230.c | 3 +-- drivers/staging/comedi/drivers/cb_das16_cs.c | 4 +--- drivers/staging/comedi/drivers/cb_pcidas.c | 3 +-- drivers/staging/comedi/drivers/cb_pcidas64.c | 3 +-- drivers/staging/comedi/drivers/cb_pcidda.c | 3 +-- drivers/staging/comedi/drivers/cb_pcimdas.c | 3 +-- drivers/staging/comedi/drivers/cb_pcimdda.c | 3 +-- drivers/staging/comedi/drivers/comedi_bond.c | 3 +-- drivers/staging/comedi/drivers/comedi_parport.c | 3 +-- drivers/staging/comedi/drivers/comedi_test.c | 3 +-- drivers/staging/comedi/drivers/daqboard2000.c | 3 +-- drivers/staging/comedi/drivers/das08_cs.c | 4 +--- drivers/staging/comedi/drivers/das08_isa.c | 3 +-- drivers/staging/comedi/drivers/das08_pci.c | 3 +-- drivers/staging/comedi/drivers/das16.c | 4 +--- drivers/staging/comedi/drivers/das16m1.c | 3 +-- drivers/staging/comedi/drivers/das1800.c | 3 +-- drivers/staging/comedi/drivers/das6402.c | 3 +-- drivers/staging/comedi/drivers/das800.c | 3 +-- drivers/staging/comedi/drivers/dmm32at.c | 3 +-- drivers/staging/comedi/drivers/dt2801.c | 3 +-- drivers/staging/comedi/drivers/dt2811.c | 3 +-- drivers/staging/comedi/drivers/dt2814.c | 3 +-- drivers/staging/comedi/drivers/dt2815.c | 3 +-- drivers/staging/comedi/drivers/dt282x.c | 3 +-- drivers/staging/comedi/drivers/dt3000.c | 3 +-- drivers/staging/comedi/drivers/dt9812.c | 4 +--- drivers/staging/comedi/drivers/dyna_pci10xx.c | 3 +-- drivers/staging/comedi/drivers/fl512.c | 3 +-- drivers/staging/comedi/drivers/gsc_hpdi.c | 3 +-- drivers/staging/comedi/drivers/icp_multi.c | 3 +-- drivers/staging/comedi/drivers/ii_pci20kc.c | 3 +-- drivers/staging/comedi/drivers/jr3_pci.c | 3 +-- drivers/staging/comedi/drivers/me4000.c | 3 +-- drivers/staging/comedi/drivers/me_daq.c | 3 +-- drivers/staging/comedi/drivers/mpc624.c | 3 +-- drivers/staging/comedi/drivers/multiq3.c | 3 +-- drivers/staging/comedi/drivers/ni_6527.c | 3 +-- drivers/staging/comedi/drivers/ni_65xx.c | 4 +--- drivers/staging/comedi/drivers/ni_660x.c | 3 +-- drivers/staging/comedi/drivers/ni_670x.c | 4 +--- drivers/staging/comedi/drivers/ni_at_a2150.c | 3 +-- drivers/staging/comedi/drivers/ni_at_ao.c | 3 +-- drivers/staging/comedi/drivers/ni_atmio16d.c | 3 +-- drivers/staging/comedi/drivers/ni_daq_700.c | 1 - drivers/staging/comedi/drivers/ni_labpc.c | 3 +-- drivers/staging/comedi/drivers/ni_labpc_cs.c | 4 +--- drivers/staging/comedi/drivers/ni_labpc_pci.c | 4 +--- drivers/staging/comedi/drivers/ni_mio_common.c | 3 +-- drivers/staging/comedi/drivers/ni_pcidio.c | 3 +-- drivers/staging/comedi/drivers/ni_tio.c | 2 ++ drivers/staging/comedi/drivers/pcl711.c | 3 +-- drivers/staging/comedi/drivers/pcl726.c | 3 +-- drivers/staging/comedi/drivers/pcl812.c | 3 +-- drivers/staging/comedi/drivers/pcl816.c | 3 +-- drivers/staging/comedi/drivers/pcl818.c | 3 +-- drivers/staging/comedi/drivers/pcm3724.c | 3 +-- drivers/staging/comedi/drivers/pcmda12.c | 3 +-- drivers/staging/comedi/drivers/pcmmio.c | 3 +-- drivers/staging/comedi/drivers/pcmuio.c | 3 +-- drivers/staging/comedi/drivers/poc.c | 3 +-- drivers/staging/comedi/drivers/quatech_daqp_cs.c | 3 +-- drivers/staging/comedi/drivers/rtd520.c | 3 +-- drivers/staging/comedi/drivers/rti800.c | 3 +-- drivers/staging/comedi/drivers/rti802.c | 3 +-- drivers/staging/comedi/drivers/s526.c | 3 +-- drivers/staging/comedi/drivers/s626.c | 3 +-- drivers/staging/comedi/drivers/s626.h | 2 -- drivers/staging/comedi/drivers/serial2002.c | 3 +-- drivers/staging/comedi/drivers/skel.c | 6 ++---- drivers/staging/comedi/drivers/unioxx5.c | 1 - drivers/staging/comedi/drivers/usbduxfast.c | 3 +-- drivers/staging/comedi/drivers/usbduxsigma.c | 3 +-- drivers/staging/comedi/drivers/vmk80xx.c | 3 +-- 97 files changed, 97 insertions(+), 208 deletions(-) diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index bfbe4160edf07..c6a7c096f625a 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/staging/comedi/drivers/8255_pci.c b/drivers/staging/comedi/drivers/8255_pci.c index 3d3547c194806..b58e28bb206dd 100644 --- a/drivers/staging/comedi/drivers/8255_pci.c +++ b/drivers/staging/comedi/drivers/8255_pci.c @@ -186,10 +186,9 @@ static int pci_8255_auto_attach(struct comedi_device *dev, dev->board_ptr = board; dev->board_name = board->name; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; ret = comedi_pci_enable(dev); if (ret) diff --git a/drivers/staging/comedi/drivers/addi-data/addi_common.c b/drivers/staging/comedi/drivers/addi-data/addi_common.c index f25e0085219d3..63dff7729ea89 100644 --- a/drivers/staging/comedi/drivers/addi-data/addi_common.c +++ b/drivers/staging/comedi/drivers/addi-data/addi_common.c @@ -85,10 +85,9 @@ static int addi_auto_attach(struct comedi_device *dev, dev->board_name = this_board->pc_DriverName; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; ret = comedi_pci_enable(dev); if (ret) diff --git a/drivers/staging/comedi/drivers/addi_apci_1032.c b/drivers/staging/comedi/drivers/addi_apci_1032.c index 8a93542faedca..242903aac829a 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1032.c +++ b/drivers/staging/comedi/drivers/addi_apci_1032.c @@ -289,10 +289,9 @@ static int apci1032_auto_attach(struct comedi_device *dev, struct comedi_subdevice *s; int ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; ret = comedi_pci_enable(dev); if (ret) diff --git a/drivers/staging/comedi/drivers/addi_apci_1516.c b/drivers/staging/comedi/drivers/addi_apci_1516.c index b626738bb73c4..7523c8b0e8f78 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1516.c +++ b/drivers/staging/comedi/drivers/addi_apci_1516.c @@ -136,10 +136,9 @@ static int apci1516_auto_attach(struct comedi_device *dev, dev->board_ptr = this_board; dev->board_name = this_board->name; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; ret = comedi_pci_enable(dev); if (ret) diff --git a/drivers/staging/comedi/drivers/addi_apci_1710.c b/drivers/staging/comedi/drivers/addi_apci_1710.c index c9e6471eb06ba..e533f55a1d2f0 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1710.c +++ b/drivers/staging/comedi/drivers/addi_apci_1710.c @@ -35,10 +35,9 @@ static int apci1710_auto_attach(struct comedi_device *dev, struct comedi_subdevice *s; int ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; ret = comedi_pci_enable(dev); if (ret) diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 61452848510ff..a7828bb64a917 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -65,10 +65,9 @@ static int apci3120_auto_attach(struct comedi_device *dev, dev->board_ptr = this_board; dev->board_name = this_board->pc_DriverName; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; ret = comedi_pci_enable(dev); if (ret) diff --git a/drivers/staging/comedi/drivers/addi_apci_3501.c b/drivers/staging/comedi/drivers/addi_apci_3501.c index f9b63689a12af..9b8544b43b240 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3501.c +++ b/drivers/staging/comedi/drivers/addi_apci_3501.c @@ -332,10 +332,9 @@ static int apci3501_auto_attach(struct comedi_device *dev, int ao_n_chan; int ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; ret = comedi_pci_enable(dev); if (ret) diff --git a/drivers/staging/comedi/drivers/addi_apci_3xxx.c b/drivers/staging/comedi/drivers/addi_apci_3xxx.c index 5b37cbf9228ee..cf60248c726db 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3xxx.c +++ b/drivers/staging/comedi/drivers/addi_apci_3xxx.c @@ -801,10 +801,9 @@ static int apci3xxx_auto_attach(struct comedi_device *dev, dev->board_ptr = board; dev->board_name = board->name; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; ret = comedi_pci_enable(dev); if (ret) diff --git a/drivers/staging/comedi/drivers/adl_pci6208.c b/drivers/staging/comedi/drivers/adl_pci6208.c index b5e4e53f737f7..ffd91e4f90bf0 100644 --- a/drivers/staging/comedi/drivers/adl_pci6208.c +++ b/drivers/staging/comedi/drivers/adl_pci6208.c @@ -172,10 +172,9 @@ static int pci6208_auto_attach(struct comedi_device *dev, dev->board_ptr = boardinfo; dev->board_name = boardinfo->name; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; ret = comedi_pci_enable(dev); if (ret) diff --git a/drivers/staging/comedi/drivers/adl_pci9111.c b/drivers/staging/comedi/drivers/adl_pci9111.c index af51c74600484..cf93e416dd29e 100644 --- a/drivers/staging/comedi/drivers/adl_pci9111.c +++ b/drivers/staging/comedi/drivers/adl_pci9111.c @@ -855,10 +855,9 @@ static int pci9111_auto_attach(struct comedi_device *dev, struct comedi_subdevice *s; int ret; - dev_private = kzalloc(sizeof(*dev_private), GFP_KERNEL); + dev_private = comedi_alloc_devpriv(dev, sizeof(*dev_private)); if (!dev_private) return -ENOMEM; - dev->private = dev_private; ret = comedi_pci_enable(dev); if (ret) diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index cb4ef2dcbf020..2a48f8421ca04 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -2140,10 +2140,9 @@ static int pci9118_attach(struct comedi_device *dev, softsshdelay = it->options[4]; hw_err_mask = it->options[5]; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; pcidev = pci9118_find_pci(dev, it); if (!pcidev) @@ -2160,10 +2159,9 @@ static int pci9118_auto_attach(struct comedi_device *dev, struct pci_dev *pcidev = comedi_to_pci_dev(dev); struct pci9118_private *devpriv; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; dev->board_ptr = pci9118_find_boardinfo(pcidev); if (dev->board_ptr == NULL) { diff --git a/drivers/staging/comedi/drivers/adq12b.c b/drivers/staging/comedi/drivers/adq12b.c index d187a7bf0a55e..72e88d8465eae 100644 --- a/drivers/staging/comedi/drivers/adq12b.c +++ b/drivers/staging/comedi/drivers/adq12b.c @@ -214,10 +214,9 @@ static int adq12b_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (ret) return ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; devpriv->unipolar = it->options[1]; devpriv->differential = it->options[2]; diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index f847bbc175e72..53653d3c49375 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -1233,10 +1233,9 @@ static int pci1710_auto_attach(struct comedi_device *dev, dev->board_ptr = this_board; dev->board_name = this_board->name; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; ret = comedi_pci_enable(dev); if (ret) diff --git a/drivers/staging/comedi/drivers/adv_pci1723.c b/drivers/staging/comedi/drivers/adv_pci1723.c index 8430a27ec1b59..919babae4cbe3 100644 --- a/drivers/staging/comedi/drivers/adv_pci1723.c +++ b/drivers/staging/comedi/drivers/adv_pci1723.c @@ -237,10 +237,9 @@ static int pci1723_auto_attach(struct comedi_device *dev, struct comedi_subdevice *s; int ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; ret = comedi_pci_enable(dev); if (ret) diff --git a/drivers/staging/comedi/drivers/adv_pci1724.c b/drivers/staging/comedi/drivers/adv_pci1724.c index da7462e01faa9..d27730e2d29fa 100644 --- a/drivers/staging/comedi/drivers/adv_pci1724.c +++ b/drivers/staging/comedi/drivers/adv_pci1724.c @@ -340,10 +340,9 @@ static int adv_pci1724_auto_attach(struct comedi_device *dev, int retval; unsigned int board_id; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; /* init software copies of output values to indicate we don't know * what the output value is since it has never been written. */ diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index 8e6ec75bd294f..ff48cb30d4af1 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -1107,10 +1107,9 @@ static int pci_dio_auto_attach(struct comedi_device *dev, dev->board_ptr = this_board; dev->board_name = this_board->name; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; ret = comedi_pci_enable(dev); if (ret) diff --git a/drivers/staging/comedi/drivers/aio_aio12_8.c b/drivers/staging/comedi/drivers/aio_aio12_8.c index 279dfe8951f70..ae88fe1f79d08 100644 --- a/drivers/staging/comedi/drivers/aio_aio12_8.c +++ b/drivers/staging/comedi/drivers/aio_aio12_8.c @@ -202,10 +202,9 @@ static int aio_aio12_8_attach(struct comedi_device *dev, if (ret) return ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; ret = comedi_alloc_subdevices(dev, 4); if (ret) diff --git a/drivers/staging/comedi/drivers/amplc_dio200.c b/drivers/staging/comedi/drivers/amplc_dio200.c index e2478105ac1a0..d1436733e9137 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200.c +++ b/drivers/staging/comedi/drivers/amplc_dio200.c @@ -192,8 +192,6 @@ * order they appear in the channel list. */ -#include - #include "../comedidev.h" #include "amplc_dio200.h" @@ -272,10 +270,9 @@ static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it) irq = it->options[1]; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; ret = comedi_request_region(dev, it->options[0], thisboard->mainsize); if (ret) diff --git a/drivers/staging/comedi/drivers/amplc_dio200_common.c b/drivers/staging/comedi/drivers/amplc_dio200_common.c index 649fc69724fb7..56b7836421552 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200_common.c +++ b/drivers/staging/comedi/drivers/amplc_dio200_common.c @@ -20,7 +20,6 @@ */ #include -#include #include "../comedidev.h" diff --git a/drivers/staging/comedi/drivers/amplc_dio200_pci.c b/drivers/staging/comedi/drivers/amplc_dio200_pci.c index d7d9f5cc3ab40..25d9cc00b888e 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200_pci.c +++ b/drivers/staging/comedi/drivers/amplc_dio200_pci.c @@ -222,7 +222,6 @@ #include #include -#include #include "../comedidev.h" @@ -380,10 +379,9 @@ static int dio200_pci_auto_attach(struct comedi_device *dev, dev_info(dev->class_dev, "%s: attach pci %s (%s)\n", dev->driver->driver_name, pci_name(pci_dev), dev->board_name); - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; ret = comedi_pci_enable(dev); if (ret) diff --git a/drivers/staging/comedi/drivers/amplc_pc236.c b/drivers/staging/comedi/drivers/amplc_pc236.c index 4e889b82cbf2a..81b9b80f8a64b 100644 --- a/drivers/staging/comedi/drivers/amplc_pc236.c +++ b/drivers/staging/comedi/drivers/amplc_pc236.c @@ -467,10 +467,9 @@ static int pc236_attach(struct comedi_device *dev, struct comedi_devconfig *it) struct pc236_private *devpriv; int ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; /* Process options according to bus type. */ if (is_isa_board(thisboard)) { @@ -510,10 +509,9 @@ static int pc236_auto_attach(struct comedi_device *dev, dev_info(dev->class_dev, PC236_DRIVER_NAME ": attach pci %s\n", pci_name(pci_dev)); - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; dev->board_ptr = pc236_find_pci_board(pci_dev); if (dev->board_ptr == NULL) { diff --git a/drivers/staging/comedi/drivers/amplc_pci224.c b/drivers/staging/comedi/drivers/amplc_pci224.c index f1e36f08b1039..043120448cf94 100644 --- a/drivers/staging/comedi/drivers/amplc_pci224.c +++ b/drivers/staging/comedi/drivers/amplc_pci224.c @@ -100,7 +100,6 @@ Passing a zero for an option is the same as leaving it unspecified. #include #include -#include #include "../comedidev.h" @@ -1419,10 +1418,9 @@ static int pci224_attach(struct comedi_device *dev, struct comedi_devconfig *it) dev_info(dev->class_dev, DRIVER_NAME ": attach\n"); - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; pci_dev = pci224_find_pci_dev(dev, it); if (!pci_dev) @@ -1440,10 +1438,9 @@ pci224_auto_attach(struct comedi_device *dev, unsigned long context_unused) dev_info(dev->class_dev, DRIVER_NAME ": attach pci %s\n", pci_name(pci_dev)); - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; dev->board_ptr = pci224_find_pci_board(pci_dev); if (dev->board_ptr == NULL) { diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c index 846d6448fa4dd..147702b51872f 100644 --- a/drivers/staging/comedi/drivers/amplc_pci230.c +++ b/drivers/staging/comedi/drivers/amplc_pci230.c @@ -2615,10 +2615,9 @@ static int pci230_alloc_private(struct comedi_device *dev) { struct pci230_private *devpriv; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; spin_lock_init(&devpriv->isr_spinlock); spin_lock_init(&devpriv->res_spinlock); diff --git a/drivers/staging/comedi/drivers/cb_das16_cs.c b/drivers/staging/comedi/drivers/cb_das16_cs.c index ae9a2082b5a44..ff0f8939ae786 100644 --- a/drivers/staging/comedi/drivers/cb_das16_cs.c +++ b/drivers/staging/comedi/drivers/cb_das16_cs.c @@ -35,7 +35,6 @@ Status: experimental */ #include -#include #include #include "../comedidev.h" @@ -420,10 +419,9 @@ static int das16cs_auto_attach(struct comedi_device *dev, return ret; dev->irq = link->irq; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; ret = comedi_alloc_subdevices(dev, 3); if (ret) diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c index 58bca184bf22d..d70d1dd30502b 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas.c +++ b/drivers/staging/comedi/drivers/cb_pcidas.c @@ -1444,10 +1444,9 @@ static int cb_pcidas_auto_attach(struct comedi_device *dev, dev->board_ptr = thisboard; dev->board_name = thisboard->name; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; ret = comedi_pci_enable(dev); if (ret) diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index 43c0bf58771ad..e8222b0fe8411 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -4034,10 +4034,9 @@ static int auto_attach(struct comedi_device *dev, return -ENODEV; dev->board_ptr = thisboard; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; retval = comedi_pci_enable(dev); if (retval) diff --git a/drivers/staging/comedi/drivers/cb_pcidda.c b/drivers/staging/comedi/drivers/cb_pcidda.c index 2d3e920e59871..c1f0aa59f66f1 100644 --- a/drivers/staging/comedi/drivers/cb_pcidda.c +++ b/drivers/staging/comedi/drivers/cb_pcidda.c @@ -348,10 +348,9 @@ static int cb_pcidda_auto_attach(struct comedi_device *dev, dev->board_ptr = thisboard; dev->board_name = thisboard->name; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; ret = comedi_pci_enable(dev); if (ret) diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c b/drivers/staging/comedi/drivers/cb_pcimdas.c index 8b5c198862a1a..543f213c72919 100644 --- a/drivers/staging/comedi/drivers/cb_pcimdas.c +++ b/drivers/staging/comedi/drivers/cb_pcimdas.c @@ -210,10 +210,9 @@ static int cb_pcimdas_auto_attach(struct comedi_device *dev, unsigned long iobase_8255; int ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; ret = comedi_pci_enable(dev); if (ret) diff --git a/drivers/staging/comedi/drivers/cb_pcimdda.c b/drivers/staging/comedi/drivers/cb_pcimdda.c index 406cba8cba88e..b019566f6c559 100644 --- a/drivers/staging/comedi/drivers/cb_pcimdda.c +++ b/drivers/staging/comedi/drivers/cb_pcimdda.c @@ -156,10 +156,9 @@ static int cb_pcimdda_auto_attach(struct comedi_device *dev, struct comedi_subdevice *s; int ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; ret = comedi_pci_enable(dev); if (ret) diff --git a/drivers/staging/comedi/drivers/comedi_bond.c b/drivers/staging/comedi/drivers/comedi_bond.c index 1a51866be6f7d..1952c62ad1fd1 100644 --- a/drivers/staging/comedi/drivers/comedi_bond.c +++ b/drivers/staging/comedi/drivers/comedi_bond.c @@ -298,10 +298,9 @@ static int bonding_attach(struct comedi_device *dev, struct comedi_subdevice *s; int ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; /* * Setup our bonding from config params.. sets up our private struct.. diff --git a/drivers/staging/comedi/drivers/comedi_parport.c b/drivers/staging/comedi/drivers/comedi_parport.c index 772a8f5f0c1ce..05d79cf4feffb 100644 --- a/drivers/staging/comedi/drivers/comedi_parport.c +++ b/drivers/staging/comedi/drivers/comedi_parport.c @@ -279,10 +279,9 @@ static int parport_attach(struct comedi_device *dev, if (ret) return ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; s = &dev->subdevices[0]; s->type = COMEDI_SUBD_DIO; diff --git a/drivers/staging/comedi/drivers/comedi_test.c b/drivers/staging/comedi/drivers/comedi_test.c index 907e7a3822f5d..eb05f5e57ebc3 100644 --- a/drivers/staging/comedi/drivers/comedi_test.c +++ b/drivers/staging/comedi/drivers/comedi_test.c @@ -379,10 +379,9 @@ static int waveform_attach(struct comedi_device *dev, int i; int ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; /* set default amplitude and period */ if (amplitude <= 0) diff --git a/drivers/staging/comedi/drivers/daqboard2000.c b/drivers/staging/comedi/drivers/daqboard2000.c index 44c912b48b6e2..f821b81cd3bec 100644 --- a/drivers/staging/comedi/drivers/daqboard2000.c +++ b/drivers/staging/comedi/drivers/daqboard2000.c @@ -683,10 +683,9 @@ static int daqboard2000_auto_attach(struct comedi_device *dev, dev->board_ptr = board; dev->board_name = board->name; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; result = comedi_pci_enable(dev); if (result) diff --git a/drivers/staging/comedi/drivers/das08_cs.c b/drivers/staging/comedi/drivers/das08_cs.c index 885fb179c9b41..24a3922ddd9aa 100644 --- a/drivers/staging/comedi/drivers/das08_cs.c +++ b/drivers/staging/comedi/drivers/das08_cs.c @@ -40,7 +40,6 @@ Command support does not exist, but could be added for this board. */ #include -#include #include "../comedidev.h" @@ -78,10 +77,9 @@ static int das08_cs_auto_attach(struct comedi_device *dev, return ret; iobase = link->resource[0]->start; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; return das08_common_attach(dev, iobase); } diff --git a/drivers/staging/comedi/drivers/das08_isa.c b/drivers/staging/comedi/drivers/das08_isa.c index 21a94389b8b20..50d27aa923dd4 100644 --- a/drivers/staging/comedi/drivers/das08_isa.c +++ b/drivers/staging/comedi/drivers/das08_isa.c @@ -177,10 +177,9 @@ static int das08_isa_attach(struct comedi_device *dev, struct das08_private_struct *devpriv; int ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; ret = comedi_request_region(dev, it->options[0], thisboard->iosize); if (ret) diff --git a/drivers/staging/comedi/drivers/das08_pci.c b/drivers/staging/comedi/drivers/das08_pci.c index 9c5d234e063f0..2786887173a4d 100644 --- a/drivers/staging/comedi/drivers/das08_pci.c +++ b/drivers/staging/comedi/drivers/das08_pci.c @@ -59,10 +59,9 @@ static int das08_pci_auto_attach(struct comedi_device *dev, struct das08_private_struct *devpriv; int ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; /* The das08 driver needs the board_ptr */ dev->board_ptr = &das08_pci_boards[0]; diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index dbec3ba995487..66be41db59add 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -74,7 +74,6 @@ www.measurementcomputing.com */ #include -#include #include #include @@ -1102,10 +1101,9 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) } } - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; if (board->size < 0x400) { ret = comedi_request_region(dev, it->options[0], board->size); diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index 0b33808c3a7d9..ee5e1561c835e 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -567,10 +567,9 @@ static int das16m1_attach(struct comedi_device *dev, int ret; unsigned int irq; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; ret = comedi_request_region(dev, it->options[0], DAS16M1_SIZE); if (ret) diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index 23b4a661eb1af..e6c852530acb0 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -1511,10 +1511,9 @@ static int das1800_attach(struct comedi_device *dev, int board; int ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; ret = comedi_request_region(dev, it->options[0], DAS1800_SIZE); if (ret) diff --git a/drivers/staging/comedi/drivers/das6402.c b/drivers/staging/comedi/drivers/das6402.c index f0530778bb3b3..8529c9f402a16 100644 --- a/drivers/staging/comedi/drivers/das6402.c +++ b/drivers/staging/comedi/drivers/das6402.c @@ -294,10 +294,9 @@ static int das6402_attach(struct comedi_device *dev, dev->irq = irq; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; ret = comedi_alloc_subdevices(dev, 1); if (ret) diff --git a/drivers/staging/comedi/drivers/das800.c b/drivers/staging/comedi/drivers/das800.c index 091cd911b38a8..f3f4be5b3a599 100644 --- a/drivers/staging/comedi/drivers/das800.c +++ b/drivers/staging/comedi/drivers/das800.c @@ -700,10 +700,9 @@ static int das800_attach(struct comedi_device *dev, struct comedi_devconfig *it) int board; int ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; ret = comedi_request_region(dev, it->options[0], DAS800_SIZE); if (ret) diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index e29847d73b432..a8b2c64cafd9b 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -753,10 +753,9 @@ static int dmm32at_attach(struct comedi_device *dev, dev->irq = irq; } - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; ret = comedi_alloc_subdevices(dev, 3); if (ret) diff --git a/drivers/staging/comedi/drivers/dt2801.c b/drivers/staging/comedi/drivers/dt2801.c index 8f5006d70dafd..2aa70d2b502d1 100644 --- a/drivers/staging/comedi/drivers/dt2801.c +++ b/drivers/staging/comedi/drivers/dt2801.c @@ -627,10 +627,9 @@ static int dt2801_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (ret) goto out; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; dev->board_name = board->name; diff --git a/drivers/staging/comedi/drivers/dt2811.c b/drivers/staging/comedi/drivers/dt2811.c index 5348cdae408a7..bbae652aa8943 100644 --- a/drivers/staging/comedi/drivers/dt2811.c +++ b/drivers/staging/comedi/drivers/dt2811.c @@ -450,10 +450,9 @@ static int dt2811_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (ret) return ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; switch (it->options[2]) { case 0: diff --git a/drivers/staging/comedi/drivers/dt2814.c b/drivers/staging/comedi/drivers/dt2814.c index 87e9749c4be77..a46a5b32405d0 100644 --- a/drivers/staging/comedi/drivers/dt2814.c +++ b/drivers/staging/comedi/drivers/dt2814.c @@ -298,10 +298,9 @@ static int dt2814_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (ret) return ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; s = &dev->subdevices[0]; dev->read_subdev = s; diff --git a/drivers/staging/comedi/drivers/dt2815.c b/drivers/staging/comedi/drivers/dt2815.c index 0fcd4fe7acdc4..e729271fcfe34 100644 --- a/drivers/staging/comedi/drivers/dt2815.c +++ b/drivers/staging/comedi/drivers/dt2815.c @@ -165,10 +165,9 @@ static int dt2815_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (ret) return ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; s = &dev->subdevices[0]; /* ao subdevice */ diff --git a/drivers/staging/comedi/drivers/dt282x.c b/drivers/staging/comedi/drivers/dt282x.c index c1950e3b19a2b..3d1ae5f3fa5f6 100644 --- a/drivers/staging/comedi/drivers/dt282x.c +++ b/drivers/staging/comedi/drivers/dt282x.c @@ -1188,10 +1188,9 @@ static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it) #endif } - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; ret = dt282x_grab_dma(dev, it->options[opt_dma1], it->options[opt_dma2]); diff --git a/drivers/staging/comedi/drivers/dt3000.c b/drivers/staging/comedi/drivers/dt3000.c index 01a2f889d5b02..c255ed1ec2318 100644 --- a/drivers/staging/comedi/drivers/dt3000.c +++ b/drivers/staging/comedi/drivers/dt3000.c @@ -722,10 +722,9 @@ static int dt3000_auto_attach(struct comedi_device *dev, dev->board_ptr = this_board; dev->board_name = this_board->name; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; ret = comedi_pci_enable(dev); if (ret < 0) diff --git a/drivers/staging/comedi/drivers/dt9812.c b/drivers/staging/comedi/drivers/dt9812.c index 6c60949d91939..07aa828365e59 100644 --- a/drivers/staging/comedi/drivers/dt9812.c +++ b/drivers/staging/comedi/drivers/dt9812.c @@ -41,7 +41,6 @@ for my needs. #include #include #include -#include #include #include #include @@ -781,10 +780,9 @@ static int dt9812_auto_attach(struct comedi_device *dev, bool is_unipolar; int ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; sema_init(&devpriv->sem, 1); usb_set_intfdata(intf, devpriv); diff --git a/drivers/staging/comedi/drivers/dyna_pci10xx.c b/drivers/staging/comedi/drivers/dyna_pci10xx.c index e14dd3ae9ec6c..33398041b6641 100644 --- a/drivers/staging/comedi/drivers/dyna_pci10xx.c +++ b/drivers/staging/comedi/drivers/dyna_pci10xx.c @@ -183,10 +183,9 @@ static int dyna_pci10xx_auto_attach(struct comedi_device *dev, struct comedi_subdevice *s; int ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; ret = comedi_pci_enable(dev); if (ret) diff --git a/drivers/staging/comedi/drivers/fl512.c b/drivers/staging/comedi/drivers/fl512.c index ff6f0bd7c8637..77646371d80cc 100644 --- a/drivers/staging/comedi/drivers/fl512.c +++ b/drivers/staging/comedi/drivers/fl512.c @@ -118,10 +118,9 @@ static int fl512_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (ret) return ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; ret = comedi_alloc_subdevices(dev, 2); if (ret) diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c b/drivers/staging/comedi/drivers/gsc_hpdi.c index 2fceff93867be..f130327f88d3a 100644 --- a/drivers/staging/comedi/drivers/gsc_hpdi.c +++ b/drivers/staging/comedi/drivers/gsc_hpdi.c @@ -483,10 +483,9 @@ static int hpdi_auto_attach(struct comedi_device *dev, dev->board_ptr = thisboard; dev->board_name = thisboard->name; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; retval = comedi_pci_enable(dev); if (retval) diff --git a/drivers/staging/comedi/drivers/icp_multi.c b/drivers/staging/comedi/drivers/icp_multi.c index a11e015dc03d3..ee40233e81b3c 100644 --- a/drivers/staging/comedi/drivers/icp_multi.c +++ b/drivers/staging/comedi/drivers/icp_multi.c @@ -495,10 +495,9 @@ static int icp_multi_auto_attach(struct comedi_device *dev, struct comedi_subdevice *s; int ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; ret = comedi_pci_enable(dev); if (ret) diff --git a/drivers/staging/comedi/drivers/ii_pci20kc.c b/drivers/staging/comedi/drivers/ii_pci20kc.c index ee7537daf4736..0d4de7d1094dd 100644 --- a/drivers/staging/comedi/drivers/ii_pci20kc.c +++ b/drivers/staging/comedi/drivers/ii_pci20kc.c @@ -203,10 +203,9 @@ static int pci20xxx_attach(struct comedi_device *dev, if (ret) return ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; devpriv->ioaddr = (void __iomem *)(unsigned long)it->options[0]; diff --git a/drivers/staging/comedi/drivers/jr3_pci.c b/drivers/staging/comedi/drivers/jr3_pci.c index 94609f4aa4c94..a9817c980fbc0 100644 --- a/drivers/staging/comedi/drivers/jr3_pci.c +++ b/drivers/staging/comedi/drivers/jr3_pci.c @@ -638,10 +638,9 @@ static int jr3_pci_auto_attach(struct comedi_device *dev, return -EINVAL; } - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; init_timer(&devpriv->timer); switch (pcidev->device) { diff --git a/drivers/staging/comedi/drivers/me4000.c b/drivers/staging/comedi/drivers/me4000.c index c2308fd24d6a2..f84f0fbb6eaa2 100644 --- a/drivers/staging/comedi/drivers/me4000.c +++ b/drivers/staging/comedi/drivers/me4000.c @@ -1544,10 +1544,9 @@ static int me4000_auto_attach(struct comedi_device *dev, dev->board_ptr = thisboard; dev->board_name = thisboard->name; - info = kzalloc(sizeof(*info), GFP_KERNEL); + info = comedi_alloc_devpriv(dev, sizeof(*info)); if (!info) return -ENOMEM; - dev->private = info; result = comedi_pci_enable(dev); if (result) diff --git a/drivers/staging/comedi/drivers/me_daq.c b/drivers/staging/comedi/drivers/me_daq.c index 7533ece3670e3..234332044310e 100644 --- a/drivers/staging/comedi/drivers/me_daq.c +++ b/drivers/staging/comedi/drivers/me_daq.c @@ -490,10 +490,9 @@ static int me_auto_attach(struct comedi_device *dev, dev->board_ptr = board; dev->board_name = board->name; - dev_private = kzalloc(sizeof(*dev_private), GFP_KERNEL); + dev_private = comedi_alloc_devpriv(dev, sizeof(*dev_private)); if (!dev_private) return -ENOMEM; - dev->private = dev_private; ret = comedi_pci_enable(dev); if (ret) diff --git a/drivers/staging/comedi/drivers/mpc624.c b/drivers/staging/comedi/drivers/mpc624.c index 713842ad6ff67..f24657f304fde 100644 --- a/drivers/staging/comedi/drivers/mpc624.c +++ b/drivers/staging/comedi/drivers/mpc624.c @@ -286,10 +286,9 @@ static int mpc624_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (ret) return ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; switch (it->options[1]) { case 0: diff --git a/drivers/staging/comedi/drivers/multiq3.c b/drivers/staging/comedi/drivers/multiq3.c index 5ecd1b1666fbe..8db2aad5441e5 100644 --- a/drivers/staging/comedi/drivers/multiq3.c +++ b/drivers/staging/comedi/drivers/multiq3.c @@ -232,10 +232,9 @@ static int multiq3_attach(struct comedi_device *dev, if (ret) return ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; s = &dev->subdevices[0]; /* ai subdevice */ diff --git a/drivers/staging/comedi/drivers/ni_6527.c b/drivers/staging/comedi/drivers/ni_6527.c index 903c2ef5dd9a6..2077d6ba6d3f2 100644 --- a/drivers/staging/comedi/drivers/ni_6527.c +++ b/drivers/staging/comedi/drivers/ni_6527.c @@ -335,10 +335,9 @@ static int ni6527_auto_attach(struct comedi_device *dev, if (ret) return ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; devpriv->mite = mite_alloc(pcidev); if (!devpriv->mite) diff --git a/drivers/staging/comedi/drivers/ni_65xx.c b/drivers/staging/comedi/drivers/ni_65xx.c index 42a78de473164..1bd830023118d 100644 --- a/drivers/staging/comedi/drivers/ni_65xx.c +++ b/drivers/staging/comedi/drivers/ni_65xx.c @@ -48,7 +48,6 @@ except maybe the 6514. #include #include -#include #include "../comedidev.h" @@ -591,10 +590,9 @@ static int ni_65xx_auto_attach(struct comedi_device *dev, if (ret) return ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; devpriv->mite = mite_alloc(pcidev); if (!devpriv->mite) diff --git a/drivers/staging/comedi/drivers/ni_660x.c b/drivers/staging/comedi/drivers/ni_660x.c index a9e000461ec7f..d90d4a09ba4c8 100644 --- a/drivers/staging/comedi/drivers/ni_660x.c +++ b/drivers/staging/comedi/drivers/ni_660x.c @@ -929,10 +929,9 @@ static int ni_660x_allocate_private(struct comedi_device *dev) struct ni_660x_private *devpriv; unsigned i; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; spin_lock_init(&devpriv->mite_channel_lock); spin_lock_init(&devpriv->interrupt_lock); diff --git a/drivers/staging/comedi/drivers/ni_670x.c b/drivers/staging/comedi/drivers/ni_670x.c index 1a185b9c529f1..4876f116ba928 100644 --- a/drivers/staging/comedi/drivers/ni_670x.c +++ b/drivers/staging/comedi/drivers/ni_670x.c @@ -38,7 +38,6 @@ Commands are not supported. #include #include -#include #include "../comedidev.h" @@ -205,10 +204,9 @@ static int ni_670x_auto_attach(struct comedi_device *dev, if (ret) return ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; devpriv->mite = mite_alloc(pcidev); if (!devpriv->mite) diff --git a/drivers/staging/comedi/drivers/ni_at_a2150.c b/drivers/staging/comedi/drivers/ni_at_a2150.c index 7ea5aa32e9d21..82c5ca6863005 100644 --- a/drivers/staging/comedi/drivers/ni_at_a2150.c +++ b/drivers/staging/comedi/drivers/ni_at_a2150.c @@ -719,10 +719,9 @@ static int a2150_attach(struct comedi_device *dev, struct comedi_devconfig *it) int i; int ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; ret = comedi_request_region(dev, it->options[0], A2150_SIZE); if (ret) diff --git a/drivers/staging/comedi/drivers/ni_at_ao.c b/drivers/staging/comedi/drivers/ni_at_ao.c index e080053c697b8..639377a60c129 100644 --- a/drivers/staging/comedi/drivers/ni_at_ao.c +++ b/drivers/staging/comedi/drivers/ni_at_ao.c @@ -341,10 +341,9 @@ static int atao_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (ret) return ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; ret = comedi_alloc_subdevices(dev, 4); if (ret) diff --git a/drivers/staging/comedi/drivers/ni_atmio16d.c b/drivers/staging/comedi/drivers/ni_atmio16d.c index da7396f94297f..d91fbc8240c0e 100644 --- a/drivers/staging/comedi/drivers/ni_atmio16d.c +++ b/drivers/staging/comedi/drivers/ni_atmio16d.c @@ -645,10 +645,9 @@ static int atmio16d_attach(struct comedi_device *dev, if (ret) return ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; /* reset the atmio16d hardware */ reset_atmio16d(dev); diff --git a/drivers/staging/comedi/drivers/ni_daq_700.c b/drivers/staging/comedi/drivers/ni_daq_700.c index 3c50e31ecc607..12aa15b428879 100644 --- a/drivers/staging/comedi/drivers/ni_daq_700.c +++ b/drivers/staging/comedi/drivers/ni_daq_700.c @@ -47,7 +47,6 @@ Manuals: Register level: http://www.ni.com/pdf/manuals/340698.pdf #include #include -#include #include "../comedidev.h" diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c index f161e70b3a0d3..4119dcfd47617 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.c +++ b/drivers/staging/comedi/drivers/ni_labpc.c @@ -1697,10 +1697,9 @@ static int labpc_attach(struct comedi_device *dev, struct comedi_devconfig *it) unsigned int dma_chan = it->options[2]; int ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; ret = comedi_request_region(dev, it->options[0], LABPC_SIZE); if (ret) diff --git a/drivers/staging/comedi/drivers/ni_labpc_cs.c b/drivers/staging/comedi/drivers/ni_labpc_cs.c index ce67f4bbb1f55..df1de784e90b0 100644 --- a/drivers/staging/comedi/drivers/ni_labpc_cs.c +++ b/drivers/staging/comedi/drivers/ni_labpc_cs.c @@ -56,7 +56,6 @@ NI manuals: #include "../comedidev.h" #include -#include #include "8253.h" #include "8255.h" @@ -96,10 +95,9 @@ static int labpc_auto_attach(struct comedi_device *dev, if (!link->irq) return -EINVAL; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; return labpc_common_attach(dev, link->irq, IRQF_SHARED); } diff --git a/drivers/staging/comedi/drivers/ni_labpc_pci.c b/drivers/staging/comedi/drivers/ni_labpc_pci.c index 6c79237b2b5c6..203a7cef77502 100644 --- a/drivers/staging/comedi/drivers/ni_labpc_pci.c +++ b/drivers/staging/comedi/drivers/ni_labpc_pci.c @@ -30,7 +30,6 @@ */ #include -#include #include #include "../comedidev.h" @@ -72,10 +71,9 @@ static int labpc_pci_auto_attach(struct comedi_device *dev, if (ret) return ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; devpriv->mite = mite_alloc(pcidev); if (!devpriv->mite) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 3e9f544e67fc2..458331d3fcb77 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -4363,10 +4363,9 @@ static int ni_alloc_private(struct comedi_device *dev) { struct ni_private *devpriv; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; spin_lock_init(&devpriv->window_lock); spin_lock_init(&devpriv->soft_reg_copy_lock); diff --git a/drivers/staging/comedi/drivers/ni_pcidio.c b/drivers/staging/comedi/drivers/ni_pcidio.c index 5b2f72e102e10..3c5275b669fc2 100644 --- a/drivers/staging/comedi/drivers/ni_pcidio.c +++ b/drivers/staging/comedi/drivers/ni_pcidio.c @@ -1108,10 +1108,9 @@ static int nidio_auto_attach(struct comedi_device *dev, if (ret) return ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; spin_lock_init(&devpriv->mite_channel_lock); diff --git a/drivers/staging/comedi/drivers/ni_tio.c b/drivers/staging/comedi/drivers/ni_tio.c index f2cf76d15d783..5b6fde08e5829 100644 --- a/drivers/staging/comedi/drivers/ni_tio.c +++ b/drivers/staging/comedi/drivers/ni_tio.c @@ -44,6 +44,8 @@ DAQ 6601/6602 User Manual (NI 322137B-01) Support use of both banks X and Y */ +#include + #include "ni_tio_internal.h" static uint64_t ni_tio_clock_period_ps(const struct ni_gpct *counter, diff --git a/drivers/staging/comedi/drivers/pcl711.c b/drivers/staging/comedi/drivers/pcl711.c index 7abf3f74144e7..f5ac58342a7c4 100644 --- a/drivers/staging/comedi/drivers/pcl711.c +++ b/drivers/staging/comedi/drivers/pcl711.c @@ -474,10 +474,9 @@ static int pcl711_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (ret) return ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; s = &dev->subdevices[0]; /* AI subdevice */ diff --git a/drivers/staging/comedi/drivers/pcl726.c b/drivers/staging/comedi/drivers/pcl726.c index 893f012a1b7a5..9bd341fedced2 100644 --- a/drivers/staging/comedi/drivers/pcl726.c +++ b/drivers/staging/comedi/drivers/pcl726.c @@ -229,10 +229,9 @@ static int pcl726_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (ret) return ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; for (i = 0; i < 12; i++) { devpriv->bipolar[i] = 0; diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index cd02786702c87..699d4558c1221 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -1110,10 +1110,9 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (ret) return ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; irq = 0; if (board->IRQbits != 0) { /* board support IRQ */ diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index 91bd2071f5713..02285976177ab 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -922,10 +922,9 @@ static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it) return -EIO; } - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; /* grab our IRQ */ irq = 0; diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index 91cb1bd6717fd..55f10e754c762 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -1227,10 +1227,9 @@ static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it) unsigned long pages; struct comedi_subdevice *s; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; devpriv->io_range = board->io_range; if ((board->fifo) && (it->options[2] == -1)) { diff --git a/drivers/staging/comedi/drivers/pcm3724.c b/drivers/staging/comedi/drivers/pcm3724.c index 5a9cd38e15f26..87cba62c6aed1 100644 --- a/drivers/staging/comedi/drivers/pcm3724.c +++ b/drivers/staging/comedi/drivers/pcm3724.c @@ -228,10 +228,9 @@ static int pcm3724_attach(struct comedi_device *dev, struct comedi_subdevice *s; int ret, i; - priv = kzalloc(sizeof(*priv), GFP_KERNEL); + priv = comedi_alloc_devpriv(dev, sizeof(*priv)); if (!priv) return -ENOMEM; - dev->private = priv; ret = comedi_request_region(dev, it->options[0], PCM3724_SIZE); if (ret) diff --git a/drivers/staging/comedi/drivers/pcmda12.c b/drivers/staging/comedi/drivers/pcmda12.c index 774a63dfe0402..2839241bb35aa 100644 --- a/drivers/staging/comedi/drivers/pcmda12.c +++ b/drivers/staging/comedi/drivers/pcmda12.c @@ -138,10 +138,9 @@ static int pcmda12_attach(struct comedi_device *dev, if (ret) return ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; devpriv->simultaneous_xfer_mode = it->options[1]; diff --git a/drivers/staging/comedi/drivers/pcmmio.c b/drivers/staging/comedi/drivers/pcmmio.c index 9f76b1f599835..feb83caef26f1 100644 --- a/drivers/staging/comedi/drivers/pcmmio.c +++ b/drivers/staging/comedi/drivers/pcmmio.c @@ -1039,10 +1039,9 @@ static int pcmmio_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (ret) return ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; for (asic = 0; asic < MAX_ASICS; ++asic) { devpriv->asics[asic].num = asic; diff --git a/drivers/staging/comedi/drivers/pcmuio.c b/drivers/staging/comedi/drivers/pcmuio.c index c43b6334ceae8..30f53fb5a0acf 100644 --- a/drivers/staging/comedi/drivers/pcmuio.c +++ b/drivers/staging/comedi/drivers/pcmuio.c @@ -609,10 +609,9 @@ static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (ret) return ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; for (asic = 0; asic < PCMUIO_MAX_ASICS; ++asic) spin_lock_init(&devpriv->asics[asic].spinlock); diff --git a/drivers/staging/comedi/drivers/poc.c b/drivers/staging/comedi/drivers/poc.c index 005fbefae295f..e50dd09a20313 100644 --- a/drivers/staging/comedi/drivers/poc.c +++ b/drivers/staging/comedi/drivers/poc.c @@ -109,10 +109,9 @@ static int poc_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (ret) return ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; /* analog output subdevice */ s = &dev->subdevices[0]; diff --git a/drivers/staging/comedi/drivers/quatech_daqp_cs.c b/drivers/staging/comedi/drivers/quatech_daqp_cs.c index e092ce87722e1..478a97271a487 100644 --- a/drivers/staging/comedi/drivers/quatech_daqp_cs.c +++ b/drivers/staging/comedi/drivers/quatech_daqp_cs.c @@ -715,10 +715,9 @@ static int daqp_auto_attach(struct comedi_device *dev, struct comedi_subdevice *s; int ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; link->config_flags |= CONF_AUTO_SET_IO | CONF_ENABLE_IRQ; ret = comedi_pcmcia_enable(dev, NULL); diff --git a/drivers/staging/comedi/drivers/rtd520.c b/drivers/staging/comedi/drivers/rtd520.c index 9b93a1fc4a599..928f534ae4ec9 100644 --- a/drivers/staging/comedi/drivers/rtd520.c +++ b/drivers/staging/comedi/drivers/rtd520.c @@ -1338,10 +1338,9 @@ static int rtd_auto_attach(struct comedi_device *dev, dev->board_ptr = board; dev->board_name = board->name; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; ret = comedi_pci_enable(dev); if (ret) diff --git a/drivers/staging/comedi/drivers/rti800.c b/drivers/staging/comedi/drivers/rti800.c index f698c7fc57261..b95fce5d26fb7 100644 --- a/drivers/staging/comedi/drivers/rti800.c +++ b/drivers/staging/comedi/drivers/rti800.c @@ -298,10 +298,9 @@ static int rti800_attach(struct comedi_device *dev, struct comedi_devconfig *it) inb(dev->iobase + RTI800_ADCHI); outb(0, dev->iobase + RTI800_CLRFLAGS); - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; devpriv->adc_2comp = (it->options[4] == 0); devpriv->dac_2comp[0] = (it->options[6] == 0); diff --git a/drivers/staging/comedi/drivers/rti802.c b/drivers/staging/comedi/drivers/rti802.c index 9e7445055482a..664ad70b05019 100644 --- a/drivers/staging/comedi/drivers/rti802.c +++ b/drivers/staging/comedi/drivers/rti802.c @@ -93,10 +93,9 @@ static int rti802_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (ret) return ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; ret = comedi_alloc_subdevices(dev, 1); if (ret) diff --git a/drivers/staging/comedi/drivers/s526.c b/drivers/staging/comedi/drivers/s526.c index e1587e58a732a..24d21eef74f84 100644 --- a/drivers/staging/comedi/drivers/s526.c +++ b/drivers/staging/comedi/drivers/s526.c @@ -553,10 +553,9 @@ static int s526_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (ret) return ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; ret = comedi_alloc_subdevices(dev, 4); if (ret) diff --git a/drivers/staging/comedi/drivers/s626.c b/drivers/staging/comedi/drivers/s626.c index 48c4b70b736aa..f5ef91f39bbfa 100644 --- a/drivers/staging/comedi/drivers/s626.c +++ b/drivers/staging/comedi/drivers/s626.c @@ -2585,10 +2585,9 @@ static int s626_auto_attach(struct comedi_device *dev, struct comedi_subdevice *s; int ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; ret = comedi_pci_enable(dev); if (ret) diff --git a/drivers/staging/comedi/drivers/s626.h b/drivers/staging/comedi/drivers/s626.h index d2756b83b62d1..a85e6bdcad075 100644 --- a/drivers/staging/comedi/drivers/s626.h +++ b/drivers/staging/comedi/drivers/s626.h @@ -65,8 +65,6 @@ #define FALSE (0) #endif -#include - #define S626_SIZE 0x0200 #define DMABUF_SIZE 4096 /* 4k pages */ diff --git a/drivers/staging/comedi/drivers/serial2002.c b/drivers/staging/comedi/drivers/serial2002.c index b4f5fe35b0fa1..b6efe9b1d4d2d 100644 --- a/drivers/staging/comedi/drivers/serial2002.c +++ b/drivers/staging/comedi/drivers/serial2002.c @@ -719,10 +719,9 @@ static int serial2002_attach(struct comedi_device *dev, struct comedi_subdevice *s; int ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; devpriv->port = it->options[0]; devpriv->speed = it->options[1]; diff --git a/drivers/staging/comedi/drivers/skel.c b/drivers/staging/comedi/drivers/skel.c index 06aee302bbc23..3fc7713af5ceb 100644 --- a/drivers/staging/comedi/drivers/skel.c +++ b/drivers/staging/comedi/drivers/skel.c @@ -484,10 +484,9 @@ static int skel_attach(struct comedi_device *dev, struct comedi_devconfig *it) /* dev->board_name = thisboard->name; */ /* Allocate the private data */ - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; /* * Supported boards are usually either auto-attached via the @@ -558,10 +557,9 @@ static int skel_auto_attach(struct comedi_device *dev, dev->board_name = thisboard->name; /* Allocate the private data */ - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; /* Enable the PCI device. */ ret = comedi_pci_enable(dev); diff --git a/drivers/staging/comedi/drivers/unioxx5.c b/drivers/staging/comedi/drivers/unioxx5.c index c9201d821fbc3..806285bc6ca73 100644 --- a/drivers/staging/comedi/drivers/unioxx5.c +++ b/drivers/staging/comedi/drivers/unioxx5.c @@ -42,7 +42,6 @@ Devices: [Fastwel] UNIOxx-5 (unioxx5), #include "../comedidev.h" #include -#include #define DRIVER_NAME "unioxx5" #define UNIOXX5_SIZE 0x10 diff --git a/drivers/staging/comedi/drivers/usbduxfast.c b/drivers/staging/comedi/drivers/usbduxfast.c index 27898c44e543f..9707dd1239c4c 100644 --- a/drivers/staging/comedi/drivers/usbduxfast.c +++ b/drivers/staging/comedi/drivers/usbduxfast.c @@ -1061,10 +1061,9 @@ static int usbduxfast_auto_attach(struct comedi_device *dev, return -ENODEV; } - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; sema_init(&devpriv->sem, 1); usb_set_intfdata(intf, devpriv); diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c b/drivers/staging/comedi/drivers/usbduxsigma.c index 898c3c4504066..40eeb8c683062 100644 --- a/drivers/staging/comedi/drivers/usbduxsigma.c +++ b/drivers/staging/comedi/drivers/usbduxsigma.c @@ -1677,10 +1677,9 @@ static int usbduxsigma_auto_attach(struct comedi_device *dev, struct usbduxsigma_private *devpriv; int ret; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; sema_init(&devpriv->sem, 1); usb_set_intfdata(intf, devpriv); diff --git a/drivers/staging/comedi/drivers/vmk80xx.c b/drivers/staging/comedi/drivers/vmk80xx.c index 0ab04c0dd4102..06efa16b9af23 100644 --- a/drivers/staging/comedi/drivers/vmk80xx.c +++ b/drivers/staging/comedi/drivers/vmk80xx.c @@ -875,10 +875,9 @@ static int vmk80xx_auto_attach(struct comedi_device *dev, dev->board_ptr = boardinfo; dev->board_name = boardinfo->name; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) return -ENOMEM; - dev->private = devpriv; devpriv->model = boardinfo->model; -- GitLab From ce157f8032bbd46d9427034c335b0afd751da25d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 24 Jun 2013 17:04:43 -0700 Subject: [PATCH 067/942] staging: comedi: don't rely on comedidev.h to include headers comedidev.h is the main kernel header for comedi. Every comedi driver includes this header which then includes a number of headers. All the drivers need and some of them need . The rest are not needed by any of the drivers. Remove all the includes in comedidev.h except for , which is needed to pick up the enum dma_data_direction for the comedi_subdevice definition, and "comedi.h", which is the uapi header for comedi. Add to all the comedi drivers and to the couple that need it. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedidev.h | 14 -------------- drivers/staging/comedi/drivers/8255.c | 1 + drivers/staging/comedi/drivers/8255_pci.c | 1 + .../staging/comedi/drivers/addi-data/addi_eeprom.c | 2 ++ .../comedi/drivers/addi-data/hwdrv_apci3120.c | 2 ++ drivers/staging/comedi/drivers/addi_apci_035.c | 1 + drivers/staging/comedi/drivers/addi_apci_1032.c | 1 + drivers/staging/comedi/drivers/addi_apci_1500.c | 1 + drivers/staging/comedi/drivers/addi_apci_1516.c | 1 + drivers/staging/comedi/drivers/addi_apci_1564.c | 1 + drivers/staging/comedi/drivers/addi_apci_16xx.c | 1 + drivers/staging/comedi/drivers/addi_apci_1710.c | 1 + drivers/staging/comedi/drivers/addi_apci_2032.c | 1 + drivers/staging/comedi/drivers/addi_apci_2200.c | 1 + drivers/staging/comedi/drivers/addi_apci_3120.c | 1 + drivers/staging/comedi/drivers/addi_apci_3200.c | 1 + drivers/staging/comedi/drivers/addi_apci_3501.c | 1 + drivers/staging/comedi/drivers/addi_apci_3xxx.c | 1 + drivers/staging/comedi/drivers/addi_watchdog.c | 1 + drivers/staging/comedi/drivers/adl_pci6208.c | 1 + drivers/staging/comedi/drivers/adl_pci7x3x.c | 1 + drivers/staging/comedi/drivers/adl_pci8164.c | 1 + drivers/staging/comedi/drivers/adl_pci9111.c | 1 + drivers/staging/comedi/drivers/adl_pci9118.c | 1 + drivers/staging/comedi/drivers/adq12b.c | 3 +++ drivers/staging/comedi/drivers/adv_pci1710.c | 1 + drivers/staging/comedi/drivers/adv_pci1723.c | 1 + drivers/staging/comedi/drivers/adv_pci1724.c | 2 ++ drivers/staging/comedi/drivers/adv_pci_dio.c | 1 + drivers/staging/comedi/drivers/aio_aio12_8.c | 1 + drivers/staging/comedi/drivers/aio_iiro_16.c | 1 + drivers/staging/comedi/drivers/amplc_dio200.c | 1 + .../staging/comedi/drivers/amplc_dio200_common.c | 1 + drivers/staging/comedi/drivers/amplc_dio200_pci.c | 1 + drivers/staging/comedi/drivers/amplc_pc236.c | 1 + drivers/staging/comedi/drivers/amplc_pc263.c | 1 + drivers/staging/comedi/drivers/amplc_pci224.c | 1 + drivers/staging/comedi/drivers/amplc_pci230.c | 1 + drivers/staging/comedi/drivers/amplc_pci263.c | 1 + drivers/staging/comedi/drivers/cb_das16_cs.c | 1 + drivers/staging/comedi/drivers/cb_pcidas.c | 1 + drivers/staging/comedi/drivers/cb_pcidas64.c | 1 + drivers/staging/comedi/drivers/cb_pcidda.c | 1 + drivers/staging/comedi/drivers/cb_pcimdas.c | 1 + drivers/staging/comedi/drivers/cb_pcimdda.c | 1 + drivers/staging/comedi/drivers/comedi_bond.c | 1 + drivers/staging/comedi/drivers/comedi_fc.c | 1 + drivers/staging/comedi/drivers/comedi_parport.c | 1 + drivers/staging/comedi/drivers/comedi_test.c | 1 + drivers/staging/comedi/drivers/contec_pci_dio.c | 1 + drivers/staging/comedi/drivers/daqboard2000.c | 1 + drivers/staging/comedi/drivers/das08.c | 1 + drivers/staging/comedi/drivers/das08_cs.c | 1 + drivers/staging/comedi/drivers/das08_isa.c | 1 + drivers/staging/comedi/drivers/das08_pci.c | 1 + drivers/staging/comedi/drivers/das16.c | 2 ++ drivers/staging/comedi/drivers/das16m1.c | 1 + drivers/staging/comedi/drivers/das1800.c | 1 + drivers/staging/comedi/drivers/das6402.c | 1 + drivers/staging/comedi/drivers/das800.c | 1 + drivers/staging/comedi/drivers/dmm32at.c | 2 ++ drivers/staging/comedi/drivers/dt2801.c | 1 + drivers/staging/comedi/drivers/dt2811.c | 1 + drivers/staging/comedi/drivers/dt2814.c | 1 + drivers/staging/comedi/drivers/dt2815.c | 1 + drivers/staging/comedi/drivers/dt2817.c | 1 + drivers/staging/comedi/drivers/dt282x.c | 4 ++++ drivers/staging/comedi/drivers/dt3000.c | 1 + drivers/staging/comedi/drivers/dt9812.c | 1 + drivers/staging/comedi/drivers/dyna_pci10xx.c | 2 ++ drivers/staging/comedi/drivers/fl512.c | 1 + drivers/staging/comedi/drivers/gsc_hpdi.c | 1 + drivers/staging/comedi/drivers/icp_multi.c | 1 + drivers/staging/comedi/drivers/ii_pci20kc.c | 1 + drivers/staging/comedi/drivers/jr3_pci.c | 1 + drivers/staging/comedi/drivers/ke_counter.c | 1 + drivers/staging/comedi/drivers/me4000.c | 1 + drivers/staging/comedi/drivers/me_daq.c | 1 + drivers/staging/comedi/drivers/mite.c | 1 + drivers/staging/comedi/drivers/mpc624.c | 1 + drivers/staging/comedi/drivers/multiq3.c | 1 + drivers/staging/comedi/drivers/ni_6527.c | 1 + drivers/staging/comedi/drivers/ni_65xx.c | 1 + drivers/staging/comedi/drivers/ni_660x.c | 1 + drivers/staging/comedi/drivers/ni_670x.c | 1 + drivers/staging/comedi/drivers/ni_at_a2150.c | 3 +++ drivers/staging/comedi/drivers/ni_at_ao.c | 1 + drivers/staging/comedi/drivers/ni_atmio.c | 1 + drivers/staging/comedi/drivers/ni_atmio16d.c | 1 + drivers/staging/comedi/drivers/ni_daq_700.c | 2 ++ drivers/staging/comedi/drivers/ni_daq_dio24.c | 1 + drivers/staging/comedi/drivers/ni_labpc.c | 1 + drivers/staging/comedi/drivers/ni_labpc_cs.c | 1 + drivers/staging/comedi/drivers/ni_labpc_pci.c | 1 + drivers/staging/comedi/drivers/ni_mio_cs.c | 1 + drivers/staging/comedi/drivers/ni_pcidio.c | 1 + drivers/staging/comedi/drivers/ni_pcimio.c | 1 + drivers/staging/comedi/drivers/ni_tio.c | 1 + drivers/staging/comedi/drivers/ni_tiocmd.c | 1 + drivers/staging/comedi/drivers/pcl711.c | 1 + drivers/staging/comedi/drivers/pcl724.c | 1 + drivers/staging/comedi/drivers/pcl726.c | 1 + drivers/staging/comedi/drivers/pcl730.c | 1 + drivers/staging/comedi/drivers/pcl812.c | 1 + drivers/staging/comedi/drivers/pcl816.c | 1 + drivers/staging/comedi/drivers/pcl818.c | 1 + drivers/staging/comedi/drivers/pcm3724.c | 1 + drivers/staging/comedi/drivers/pcmad.c | 1 + drivers/staging/comedi/drivers/pcmda12.c | 1 + drivers/staging/comedi/drivers/pcmmio.c | 1 + drivers/staging/comedi/drivers/pcmuio.c | 1 + drivers/staging/comedi/drivers/poc.c | 1 + drivers/staging/comedi/drivers/quatech_daqp_cs.c | 1 + drivers/staging/comedi/drivers/rtd520.c | 1 + drivers/staging/comedi/drivers/rti800.c | 2 ++ drivers/staging/comedi/drivers/rti802.c | 1 + drivers/staging/comedi/drivers/s526.c | 1 + drivers/staging/comedi/drivers/s626.c | 2 ++ drivers/staging/comedi/drivers/serial2002.c | 1 + drivers/staging/comedi/drivers/skel.c | 1 + drivers/staging/comedi/drivers/ssv_dnp.c | 1 + drivers/staging/comedi/drivers/unioxx5.c | 2 ++ 122 files changed, 138 insertions(+), 14 deletions(-) diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index c6a7c096f625a..ab278942ebd1f 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -19,21 +19,7 @@ #ifndef _COMEDIDEV_H #define _COMEDIDEV_H -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include -#include -#include -#include #include "comedi.h" diff --git a/drivers/staging/comedi/drivers/8255.c b/drivers/staging/comedi/drivers/8255.c index 94e17500150f5..7966079a8361a 100644 --- a/drivers/staging/comedi/drivers/8255.c +++ b/drivers/staging/comedi/drivers/8255.c @@ -73,6 +73,7 @@ I/O port base address can be found in the output of 'lspci -v'. will copy the latched value to a Comedi buffer. */ +#include #include "../comedidev.h" #include diff --git a/drivers/staging/comedi/drivers/8255_pci.c b/drivers/staging/comedi/drivers/8255_pci.c index b58e28bb206dd..432e3f9c3301e 100644 --- a/drivers/staging/comedi/drivers/8255_pci.c +++ b/drivers/staging/comedi/drivers/8255_pci.c @@ -50,6 +50,7 @@ Interrupt support for these boards is also not currently supported. Configuration Options: not applicable, uses PCI auto config */ +#include #include #include "../comedidev.h" diff --git a/drivers/staging/comedi/drivers/addi-data/addi_eeprom.c b/drivers/staging/comedi/drivers/addi-data/addi_eeprom.c index dc031c494a27c..aafc172f3a98e 100644 --- a/drivers/staging/comedi/drivers/addi-data/addi_eeprom.c +++ b/drivers/staging/comedi/drivers/addi-data/addi_eeprom.c @@ -22,6 +22,8 @@ * for more details. */ +#include + #define NVRAM_USER_DATA_START 0x100 #define NVCMD_BEGIN_READ (0x7 << 5) /* nvRam begin read command */ diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c index a89e505c8a3ad..1449b92403e24 100644 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c +++ b/drivers/staging/comedi/drivers/addi-data/hwdrv_apci3120.c @@ -40,6 +40,8 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY +----------+-----------+------------------------------------------------+ */ +#include + /* * ADDON RELATED ADDITIONS */ diff --git a/drivers/staging/comedi/drivers/addi_apci_035.c b/drivers/staging/comedi/drivers/addi_apci_035.c index 43c2c10a7c326..8d229b2f09738 100644 --- a/drivers/staging/comedi/drivers/addi_apci_035.c +++ b/drivers/staging/comedi/drivers/addi_apci_035.c @@ -1,3 +1,4 @@ +#include #include #include "../comedidev.h" diff --git a/drivers/staging/comedi/drivers/addi_apci_1032.c b/drivers/staging/comedi/drivers/addi_apci_1032.c index 242903aac829a..34ab0679e9928 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1032.c +++ b/drivers/staging/comedi/drivers/addi_apci_1032.c @@ -22,6 +22,7 @@ * more details. */ +#include #include #include diff --git a/drivers/staging/comedi/drivers/addi_apci_1500.c b/drivers/staging/comedi/drivers/addi_apci_1500.c index b52cfe01e6c83..ae9ded63dcecd 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1500.c +++ b/drivers/staging/comedi/drivers/addi_apci_1500.c @@ -1,3 +1,4 @@ +#include #include #include "../comedidev.h" diff --git a/drivers/staging/comedi/drivers/addi_apci_1516.c b/drivers/staging/comedi/drivers/addi_apci_1516.c index 7523c8b0e8f78..08674c18cf429 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1516.c +++ b/drivers/staging/comedi/drivers/addi_apci_1516.c @@ -22,6 +22,7 @@ * more details. */ +#include #include #include "../comedidev.h" diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index 22bace62210c1..c5717d63e16a7 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -1,3 +1,4 @@ +#include #include #include "../comedidev.h" diff --git a/drivers/staging/comedi/drivers/addi_apci_16xx.c b/drivers/staging/comedi/drivers/addi_apci_16xx.c index 1f7bed9a3f7f6..43296a6e7d4e6 100644 --- a/drivers/staging/comedi/drivers/addi_apci_16xx.c +++ b/drivers/staging/comedi/drivers/addi_apci_16xx.c @@ -22,6 +22,7 @@ * more details. */ +#include #include #include "../comedidev.h" diff --git a/drivers/staging/comedi/drivers/addi_apci_1710.c b/drivers/staging/comedi/drivers/addi_apci_1710.c index e533f55a1d2f0..e600c05c2ecca 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1710.c +++ b/drivers/staging/comedi/drivers/addi_apci_1710.c @@ -1,3 +1,4 @@ +#include #include #include diff --git a/drivers/staging/comedi/drivers/addi_apci_2032.c b/drivers/staging/comedi/drivers/addi_apci_2032.c index 89ead8eb3c707..cb5d26a567d39 100644 --- a/drivers/staging/comedi/drivers/addi_apci_2032.c +++ b/drivers/staging/comedi/drivers/addi_apci_2032.c @@ -22,6 +22,7 @@ * more details. */ +#include #include #include diff --git a/drivers/staging/comedi/drivers/addi_apci_2200.c b/drivers/staging/comedi/drivers/addi_apci_2200.c index ca1bd92ecb174..92ac8ece8494b 100644 --- a/drivers/staging/comedi/drivers/addi_apci_2200.c +++ b/drivers/staging/comedi/drivers/addi_apci_2200.c @@ -22,6 +22,7 @@ * more details. */ +#include #include #include "../comedidev.h" diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index a7828bb64a917..d804957018aba 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -1,3 +1,4 @@ +#include #include #include "../comedidev.h" diff --git a/drivers/staging/comedi/drivers/addi_apci_3200.c b/drivers/staging/comedi/drivers/addi_apci_3200.c index 17b540d3c6aef..1213d5aa6bea9 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3200.c +++ b/drivers/staging/comedi/drivers/addi_apci_3200.c @@ -1,3 +1,4 @@ +#include #include #include diff --git a/drivers/staging/comedi/drivers/addi_apci_3501.c b/drivers/staging/comedi/drivers/addi_apci_3501.c index 9b8544b43b240..d9650ffb7d2f3 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3501.c +++ b/drivers/staging/comedi/drivers/addi_apci_3501.c @@ -22,6 +22,7 @@ * more details. */ +#include #include #include #include diff --git a/drivers/staging/comedi/drivers/addi_apci_3xxx.c b/drivers/staging/comedi/drivers/addi_apci_3xxx.c index cf60248c726db..dbc0678027ca7 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3xxx.c +++ b/drivers/staging/comedi/drivers/addi_apci_3xxx.c @@ -22,6 +22,7 @@ * more details. */ +#include #include #include diff --git a/drivers/staging/comedi/drivers/addi_watchdog.c b/drivers/staging/comedi/drivers/addi_watchdog.c index 7b21acc93929d..23031feaa095a 100644 --- a/drivers/staging/comedi/drivers/addi_watchdog.c +++ b/drivers/staging/comedi/drivers/addi_watchdog.c @@ -18,6 +18,7 @@ * GNU General Public License for more details. */ +#include #include "../comedidev.h" #include "addi_watchdog.h" diff --git a/drivers/staging/comedi/drivers/adl_pci6208.c b/drivers/staging/comedi/drivers/adl_pci6208.c index ffd91e4f90bf0..a67ad57cefcb9 100644 --- a/drivers/staging/comedi/drivers/adl_pci6208.c +++ b/drivers/staging/comedi/drivers/adl_pci6208.c @@ -38,6 +38,7 @@ Configuration Options: not applicable, uses PCI auto config - adl_pci9118.c */ +#include #include #include "../comedidev.h" diff --git a/drivers/staging/comedi/drivers/adl_pci7x3x.c b/drivers/staging/comedi/drivers/adl_pci7x3x.c index 0d9243a5f495b..81b7203f824f1 100644 --- a/drivers/staging/comedi/drivers/adl_pci7x3x.c +++ b/drivers/staging/comedi/drivers/adl_pci7x3x.c @@ -44,6 +44,7 @@ driver. Configuration Options: not applicable, uses comedi PCI auto config */ +#include #include #include "../comedidev.h" diff --git a/drivers/staging/comedi/drivers/adl_pci8164.c b/drivers/staging/comedi/drivers/adl_pci8164.c index 0b591b0b55013..b3d009285ed4c 100644 --- a/drivers/staging/comedi/drivers/adl_pci8164.c +++ b/drivers/staging/comedi/drivers/adl_pci8164.c @@ -27,6 +27,7 @@ */ #include +#include #include #include "../comedidev.h" diff --git a/drivers/staging/comedi/drivers/adl_pci9111.c b/drivers/staging/comedi/drivers/adl_pci9111.c index cf93e416dd29e..78cea193504f3 100644 --- a/drivers/staging/comedi/drivers/adl_pci9111.c +++ b/drivers/staging/comedi/drivers/adl_pci9111.c @@ -64,6 +64,7 @@ a multiple of chanlist_len*convert_arg. */ +#include #include #include #include diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index 2a48f8421ca04..22196ada03622 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -77,6 +77,7 @@ Configuration options: * manual attachment. */ +#include #include #include #include diff --git a/drivers/staging/comedi/drivers/adq12b.c b/drivers/staging/comedi/drivers/adq12b.c index 72e88d8465eae..cdf5ba26c5904 100644 --- a/drivers/staging/comedi/drivers/adq12b.c +++ b/drivers/staging/comedi/drivers/adq12b.c @@ -73,6 +73,9 @@ If you do not specify any options, they will default to */ +#include +#include + #include "../comedidev.h" /* address scheme (page 2.17 of the manual) */ diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index 53653d3c49375..f84df46d326ae 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -41,6 +41,7 @@ Configuration options: device will be used. */ +#include #include #include diff --git a/drivers/staging/comedi/drivers/adv_pci1723.c b/drivers/staging/comedi/drivers/adv_pci1723.c index 919babae4cbe3..f914fb1f571be 100644 --- a/drivers/staging/comedi/drivers/adv_pci1723.c +++ b/drivers/staging/comedi/drivers/adv_pci1723.c @@ -43,6 +43,7 @@ configures all channels in the same group. 3. Implement calibration. */ +#include #include #include "../comedidev.h" diff --git a/drivers/staging/comedi/drivers/adv_pci1724.c b/drivers/staging/comedi/drivers/adv_pci1724.c index d27730e2d29fa..84907c79ca2b3 100644 --- a/drivers/staging/comedi/drivers/adv_pci1724.c +++ b/drivers/staging/comedi/drivers/adv_pci1724.c @@ -52,6 +52,8 @@ supported PCI devices are configured as comedi devices automatically. */ +#include +#include #include #include "../comedidev.h" diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index ff48cb30d4af1..f091fa0d304df 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -29,6 +29,7 @@ Configuration options: */ +#include #include #include diff --git a/drivers/staging/comedi/drivers/aio_aio12_8.c b/drivers/staging/comedi/drivers/aio_aio12_8.c index ae88fe1f79d08..8d081076eed66 100644 --- a/drivers/staging/comedi/drivers/aio_aio12_8.c +++ b/drivers/staging/comedi/drivers/aio_aio12_8.c @@ -35,6 +35,7 @@ Configuration Options: */ +#include #include "../comedidev.h" #include #include "8255.h" diff --git a/drivers/staging/comedi/drivers/aio_iiro_16.c b/drivers/staging/comedi/drivers/aio_iiro_16.c index 029834d0ff1f8..f066b5714941b 100644 --- a/drivers/staging/comedi/drivers/aio_iiro_16.c +++ b/drivers/staging/comedi/drivers/aio_iiro_16.c @@ -30,6 +30,7 @@ Configuration Options: */ +#include #include "../comedidev.h" #include diff --git a/drivers/staging/comedi/drivers/amplc_dio200.c b/drivers/staging/comedi/drivers/amplc_dio200.c index d1436733e9137..dc1dee79fc16c 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200.c +++ b/drivers/staging/comedi/drivers/amplc_dio200.c @@ -192,6 +192,7 @@ * order they appear in the channel list. */ +#include #include "../comedidev.h" #include "amplc_dio200.h" diff --git a/drivers/staging/comedi/drivers/amplc_dio200_common.c b/drivers/staging/comedi/drivers/amplc_dio200_common.c index 56b7836421552..32c490b27b555 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200_common.c +++ b/drivers/staging/comedi/drivers/amplc_dio200_common.c @@ -19,6 +19,7 @@ GNU General Public License for more details. */ +#include #include #include "../comedidev.h" diff --git a/drivers/staging/comedi/drivers/amplc_dio200_pci.c b/drivers/staging/comedi/drivers/amplc_dio200_pci.c index 25d9cc00b888e..a810a24164432 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200_pci.c +++ b/drivers/staging/comedi/drivers/amplc_dio200_pci.c @@ -220,6 +220,7 @@ * order they appear in the channel list. */ +#include #include #include diff --git a/drivers/staging/comedi/drivers/amplc_pc236.c b/drivers/staging/comedi/drivers/amplc_pc236.c index 81b9b80f8a64b..98075f999c9fd 100644 --- a/drivers/staging/comedi/drivers/amplc_pc236.c +++ b/drivers/staging/comedi/drivers/amplc_pc236.c @@ -47,6 +47,7 @@ the IRQ jumper. If no interrupt is connected, then subdevice 1 is unused. */ +#include #include #include diff --git a/drivers/staging/comedi/drivers/amplc_pc263.c b/drivers/staging/comedi/drivers/amplc_pc263.c index 6546095e7a45b..e7108045f5535 100644 --- a/drivers/staging/comedi/drivers/amplc_pc263.c +++ b/drivers/staging/comedi/drivers/amplc_pc263.c @@ -33,6 +33,7 @@ connected to a reed-relay. Relay contacts are closed when output is 1. The state of the outputs can be read. */ +#include #include "../comedidev.h" #define PC263_DRIVER_NAME "amplc_pc263" diff --git a/drivers/staging/comedi/drivers/amplc_pci224.c b/drivers/staging/comedi/drivers/amplc_pci224.c index 043120448cf94..2fc56c40f5b1f 100644 --- a/drivers/staging/comedi/drivers/amplc_pci224.c +++ b/drivers/staging/comedi/drivers/amplc_pci224.c @@ -98,6 +98,7 @@ Passing a zero for an option is the same as leaving it unspecified. correctly. */ +#include #include #include diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c index 147702b51872f..43059c25d5ea1 100644 --- a/drivers/staging/comedi/drivers/amplc_pci230.c +++ b/drivers/staging/comedi/drivers/amplc_pci230.c @@ -184,6 +184,7 @@ Support for PCI230+/260+, more triggered scan functionality, and workarounds for (or detection of) various hardware problems added by Ian Abbott. */ +#include #include #include #include diff --git a/drivers/staging/comedi/drivers/amplc_pci263.c b/drivers/staging/comedi/drivers/amplc_pci263.c index 4da900cc5845a..145bb48f618e9 100644 --- a/drivers/staging/comedi/drivers/amplc_pci263.c +++ b/drivers/staging/comedi/drivers/amplc_pci263.c @@ -32,6 +32,7 @@ connected to a reed-relay. Relay contacts are closed when output is 1. The state of the outputs can be read. */ +#include #include #include "../comedidev.h" diff --git a/drivers/staging/comedi/drivers/cb_das16_cs.c b/drivers/staging/comedi/drivers/cb_das16_cs.c index ff0f8939ae786..05e01a3b5af6a 100644 --- a/drivers/staging/comedi/drivers/cb_das16_cs.c +++ b/drivers/staging/comedi/drivers/cb_das16_cs.c @@ -34,6 +34,7 @@ Status: experimental */ +#include #include #include diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c index d70d1dd30502b..41d89ee7fa330 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas.c +++ b/drivers/staging/comedi/drivers/cb_pcidas.c @@ -61,6 +61,7 @@ AI Triggering: analog triggering on 1602 series */ +#include #include #include #include diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index e8222b0fe8411..e6e456163a29c 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -82,6 +82,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include #include #include #include diff --git a/drivers/staging/comedi/drivers/cb_pcidda.c b/drivers/staging/comedi/drivers/cb_pcidda.c index c1f0aa59f66f1..94f1158202790 100644 --- a/drivers/staging/comedi/drivers/cb_pcidda.c +++ b/drivers/staging/comedi/drivers/cb_pcidda.c @@ -37,6 +37,7 @@ * Only simple analog output writing is supported. */ +#include #include #include "../comedidev.h" diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c b/drivers/staging/comedi/drivers/cb_pcimdas.c index 543f213c72919..b8362a71e4bbb 100644 --- a/drivers/staging/comedi/drivers/cb_pcimdas.c +++ b/drivers/staging/comedi/drivers/cb_pcimdas.c @@ -35,6 +35,7 @@ No interrupts, multi channel or FIFO AI, although the card looks like it could s See http://www.mccdaq.com/PDFs/Manuals/pcim-das1602-16.pdf for more details. */ +#include #include #include #include diff --git a/drivers/staging/comedi/drivers/cb_pcimdda.c b/drivers/staging/comedi/drivers/cb_pcimdda.c index b019566f6c559..edf17b63096fa 100644 --- a/drivers/staging/comedi/drivers/cb_pcimdda.c +++ b/drivers/staging/comedi/drivers/cb_pcimdda.c @@ -74,6 +74,7 @@ Configuration Options: not applicable, uses PCI auto config -Calin Culianu */ +#include #include #include "../comedidev.h" diff --git a/drivers/staging/comedi/drivers/comedi_bond.c b/drivers/staging/comedi/drivers/comedi_bond.c index 1952c62ad1fd1..7e20bf00759ce 100644 --- a/drivers/staging/comedi/drivers/comedi_bond.c +++ b/drivers/staging/comedi/drivers/comedi_bond.c @@ -45,6 +45,7 @@ Configuration Options: within each minor will be concatenated together in the order given here. */ +#include #include #include #include "../comedi.h" diff --git a/drivers/staging/comedi/drivers/comedi_fc.c b/drivers/staging/comedi/drivers/comedi_fc.c index b3d89c82d0879..26d9dbcf8bd4e 100644 --- a/drivers/staging/comedi/drivers/comedi_fc.c +++ b/drivers/staging/comedi/drivers/comedi_fc.c @@ -19,6 +19,7 @@ GNU General Public License for more details. */ +#include #include "../comedidev.h" #include "comedi_fc.h" diff --git a/drivers/staging/comedi/drivers/comedi_parport.c b/drivers/staging/comedi/drivers/comedi_parport.c index 05d79cf4feffb..da52e514b90ef 100644 --- a/drivers/staging/comedi/drivers/comedi_parport.c +++ b/drivers/staging/comedi/drivers/comedi_parport.c @@ -76,6 +76,7 @@ pin, which can be used to wake up tasks. or http://www.linux-magazin.de/ausgabe/1999/10/IO/io.html */ +#include #include "../comedidev.h" #include #include diff --git a/drivers/staging/comedi/drivers/comedi_test.c b/drivers/staging/comedi/drivers/comedi_test.c index eb05f5e57ebc3..16c07802107fd 100644 --- a/drivers/staging/comedi/drivers/comedi_test.c +++ b/drivers/staging/comedi/drivers/comedi_test.c @@ -45,6 +45,7 @@ zero volts). */ +#include #include "../comedidev.h" #include diff --git a/drivers/staging/comedi/drivers/contec_pci_dio.c b/drivers/staging/comedi/drivers/contec_pci_dio.c index 0fb9027dde2d7..e781716bf3555 100644 --- a/drivers/staging/comedi/drivers/contec_pci_dio.c +++ b/drivers/staging/comedi/drivers/contec_pci_dio.c @@ -25,6 +25,7 @@ Status: works Configuration Options: not applicable, uses comedi PCI auto config */ +#include #include #include "../comedidev.h" diff --git a/drivers/staging/comedi/drivers/daqboard2000.c b/drivers/staging/comedi/drivers/daqboard2000.c index f821b81cd3bec..de920ccff400f 100644 --- a/drivers/staging/comedi/drivers/daqboard2000.c +++ b/drivers/staging/comedi/drivers/daqboard2000.c @@ -102,6 +102,7 @@ Configuration options: not applicable, uses PCI auto config */ +#include #include #include #include diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 2e7e3e2023907..126b4528d3cf2 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -33,6 +33,7 @@ * cheap das08 hardware doesn't really support them. */ +#include #include #include "../comedidev.h" diff --git a/drivers/staging/comedi/drivers/das08_cs.c b/drivers/staging/comedi/drivers/das08_cs.c index 24a3922ddd9aa..719c978bff871 100644 --- a/drivers/staging/comedi/drivers/das08_cs.c +++ b/drivers/staging/comedi/drivers/das08_cs.c @@ -39,6 +39,7 @@ Options (for pcm-das08): Command support does not exist, but could be added for this board. */ +#include #include #include "../comedidev.h" diff --git a/drivers/staging/comedi/drivers/das08_isa.c b/drivers/staging/comedi/drivers/das08_isa.c index 50d27aa923dd4..4fb03d3852d32 100644 --- a/drivers/staging/comedi/drivers/das08_isa.c +++ b/drivers/staging/comedi/drivers/das08_isa.c @@ -43,6 +43,7 @@ * [0] - base io address */ +#include #include "../comedidev.h" #include "das08.h" diff --git a/drivers/staging/comedi/drivers/das08_pci.c b/drivers/staging/comedi/drivers/das08_pci.c index 2786887173a4d..3a6d3725b25f9 100644 --- a/drivers/staging/comedi/drivers/das08_pci.c +++ b/drivers/staging/comedi/drivers/das08_pci.c @@ -31,6 +31,7 @@ * Configuration Options: not applicable, uses PCI auto config */ +#include #include #include "../comedidev.h" diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index 66be41db59add..593ec38661468 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -73,6 +73,8 @@ www.measurementcomputing.com */ +#include +#include #include #include diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index ee5e1561c835e..ede0d47aefc37 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -52,6 +52,7 @@ list has 2 or more channels in it, then two conditions must be satisfied: irq can be omitted, although the cmd interface will not work without it. */ +#include #include #include #include "../comedidev.h" diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index e6c852530acb0..f5ed55c68fa16 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -94,6 +94,7 @@ Unipolar and bipolar ranges cannot be mixed in the channel/gain list. read insn for analog out */ +#include #include #include #include diff --git a/drivers/staging/comedi/drivers/das6402.c b/drivers/staging/comedi/drivers/das6402.c index 8529c9f402a16..8f6dc0a449091 100644 --- a/drivers/staging/comedi/drivers/das6402.c +++ b/drivers/staging/comedi/drivers/das6402.c @@ -33,6 +33,7 @@ Devices: [Keithley Metrabyte] DAS6402 (das6402) This driver has suffered bitrot. */ +#include #include #include "../comedidev.h" diff --git a/drivers/staging/comedi/drivers/das800.c b/drivers/staging/comedi/drivers/das800.c index f3f4be5b3a599..13e1cd0afd324 100644 --- a/drivers/staging/comedi/drivers/das800.c +++ b/drivers/staging/comedi/drivers/das800.c @@ -56,6 +56,7 @@ cmd triggers supported: */ +#include #include #include "../comedidev.h" diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index a8b2c64cafd9b..1d80d74575295 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -32,6 +32,8 @@ Configuration Options: comedi_config /dev/comedi0 dmm32at baseaddr,irq */ +#include +#include #include #include "../comedidev.h" #include diff --git a/drivers/staging/comedi/drivers/dt2801.c b/drivers/staging/comedi/drivers/dt2801.c index 2aa70d2b502d1..2537696f80fc9 100644 --- a/drivers/staging/comedi/drivers/dt2801.c +++ b/drivers/staging/comedi/drivers/dt2801.c @@ -29,6 +29,7 @@ Configuration options: [5] - D/A 1 range (same choices) */ +#include #include "../comedidev.h" #include #include diff --git a/drivers/staging/comedi/drivers/dt2811.c b/drivers/staging/comedi/drivers/dt2811.c index bbae652aa8943..34afa940db772 100644 --- a/drivers/staging/comedi/drivers/dt2811.c +++ b/drivers/staging/comedi/drivers/dt2811.c @@ -41,6 +41,7 @@ Configuration options: [4] - D/A 1 range (same choices) */ +#include #include #include "../comedidev.h" diff --git a/drivers/staging/comedi/drivers/dt2814.c b/drivers/staging/comedi/drivers/dt2814.c index a46a5b32405d0..a1076a43c294d 100644 --- a/drivers/staging/comedi/drivers/dt2814.c +++ b/drivers/staging/comedi/drivers/dt2814.c @@ -34,6 +34,7 @@ a power of 10, from 1 to 10^7, of which only 3 or 4 are useful. In addition, the clock does not seem to be very accurate. */ +#include #include #include "../comedidev.h" diff --git a/drivers/staging/comedi/drivers/dt2815.c b/drivers/staging/comedi/drivers/dt2815.c index e729271fcfe34..c33708c905858 100644 --- a/drivers/staging/comedi/drivers/dt2815.c +++ b/drivers/staging/comedi/drivers/dt2815.c @@ -51,6 +51,7 @@ Configuration options: [12] - Analog output 7 range configuration (same options) */ +#include #include "../comedidev.h" #include diff --git a/drivers/staging/comedi/drivers/dt2817.c b/drivers/staging/comedi/drivers/dt2817.c index 2f46be715f79f..1ba49e79ee010 100644 --- a/drivers/staging/comedi/drivers/dt2817.c +++ b/drivers/staging/comedi/drivers/dt2817.c @@ -33,6 +33,7 @@ Configuration options: [0] - I/O port base base address */ +#include #include "../comedidev.h" #include diff --git a/drivers/staging/comedi/drivers/dt282x.c b/drivers/staging/comedi/drivers/dt282x.c index 3d1ae5f3fa5f6..6d3553c8a24d0 100644 --- a/drivers/staging/comedi/drivers/dt282x.c +++ b/drivers/staging/comedi/drivers/dt282x.c @@ -51,13 +51,17 @@ Configuration options: be fixed to check for this situation and return an error. */ +#include #include "../comedidev.h" +#include #include #include #include #include + #include + #include "comedi_fc.h" #define DEBUG diff --git a/drivers/staging/comedi/drivers/dt3000.c b/drivers/staging/comedi/drivers/dt3000.c index c255ed1ec2318..e4748da1993b8 100644 --- a/drivers/staging/comedi/drivers/dt3000.c +++ b/drivers/staging/comedi/drivers/dt3000.c @@ -50,6 +50,7 @@ AO commands are not supported. #define DEBUG 1 +#include #include #include #include diff --git a/drivers/staging/comedi/drivers/dt9812.c b/drivers/staging/comedi/drivers/dt9812.c index 07aa828365e59..ffb7572b10f59 100644 --- a/drivers/staging/comedi/drivers/dt9812.c +++ b/drivers/staging/comedi/drivers/dt9812.c @@ -39,6 +39,7 @@ for my needs. */ #include +#include #include #include #include diff --git a/drivers/staging/comedi/drivers/dyna_pci10xx.c b/drivers/staging/comedi/drivers/dyna_pci10xx.c index 33398041b6641..fd525f499f2a2 100644 --- a/drivers/staging/comedi/drivers/dyna_pci10xx.c +++ b/drivers/staging/comedi/drivers/dyna_pci10xx.c @@ -33,6 +33,8 @@ their cards in their manuals. */ +#include +#include #include #include diff --git a/drivers/staging/comedi/drivers/fl512.c b/drivers/staging/comedi/drivers/fl512.c index 77646371d80cc..13f86d5cc9570 100644 --- a/drivers/staging/comedi/drivers/fl512.c +++ b/drivers/staging/comedi/drivers/fl512.c @@ -18,6 +18,7 @@ Configuration options: #define DEBUG 0 +#include #include "../comedidev.h" #include diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c b/drivers/staging/comedi/drivers/gsc_hpdi.c index f130327f88d3a..cdcc8f42e2093 100644 --- a/drivers/staging/comedi/drivers/gsc_hpdi.c +++ b/drivers/staging/comedi/drivers/gsc_hpdi.c @@ -42,6 +42,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include #include #include #include diff --git a/drivers/staging/comedi/drivers/icp_multi.c b/drivers/staging/comedi/drivers/icp_multi.c index ee40233e81b3c..3889d23292d04 100644 --- a/drivers/staging/comedi/drivers/icp_multi.c +++ b/drivers/staging/comedi/drivers/icp_multi.c @@ -42,6 +42,7 @@ There are 4 x 12-bit Analogue Outputs. Ranges : 5V, 10V, +/-5V, +/-10V Configuration options: not applicable, uses PCI auto config */ +#include #include #include #include diff --git a/drivers/staging/comedi/drivers/ii_pci20kc.c b/drivers/staging/comedi/drivers/ii_pci20kc.c index 0d4de7d1094dd..9c199a194d2b5 100644 --- a/drivers/staging/comedi/drivers/ii_pci20kc.c +++ b/drivers/staging/comedi/drivers/ii_pci20kc.c @@ -77,6 +77,7 @@ options for PCI-20341M: 3 200 */ +#include #include "../comedidev.h" #define PCI20000_ID 0x1d diff --git a/drivers/staging/comedi/drivers/jr3_pci.c b/drivers/staging/comedi/drivers/jr3_pci.c index a9817c980fbc0..b52d58e5de276 100644 --- a/drivers/staging/comedi/drivers/jr3_pci.c +++ b/drivers/staging/comedi/drivers/jr3_pci.c @@ -38,6 +38,7 @@ */ #include +#include #include #include #include diff --git a/drivers/staging/comedi/drivers/ke_counter.c b/drivers/staging/comedi/drivers/ke_counter.c index f10cf10e5fe32..15589f62a6199 100644 --- a/drivers/staging/comedi/drivers/ke_counter.c +++ b/drivers/staging/comedi/drivers/ke_counter.c @@ -29,6 +29,7 @@ This driver is a simple driver to read the counter values from Kolter Electronic PCI Counter Card. */ +#include #include #include "../comedidev.h" diff --git a/drivers/staging/comedi/drivers/me4000.c b/drivers/staging/comedi/drivers/me4000.c index f84f0fbb6eaa2..1eda40a9332ee 100644 --- a/drivers/staging/comedi/drivers/me4000.c +++ b/drivers/staging/comedi/drivers/me4000.c @@ -40,6 +40,7 @@ broken. */ +#include #include #include #include diff --git a/drivers/staging/comedi/drivers/me_daq.c b/drivers/staging/comedi/drivers/me_daq.c index 234332044310e..e8a743c2f9a16 100644 --- a/drivers/staging/comedi/drivers/me_daq.c +++ b/drivers/staging/comedi/drivers/me_daq.c @@ -30,6 +30,7 @@ * Analog Input, Analog Output, Digital I/O */ +#include #include #include #include diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index 12c34db61d637..35cb4ace79701 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -46,6 +46,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include #include #include "../comedidev.h" diff --git a/drivers/staging/comedi/drivers/mpc624.c b/drivers/staging/comedi/drivers/mpc624.c index f24657f304fde..bfdc2d36e6510 100644 --- a/drivers/staging/comedi/drivers/mpc624.c +++ b/drivers/staging/comedi/drivers/mpc624.c @@ -51,6 +51,7 @@ Configuration Options: 1 -10.1V .. +10.1V */ +#include #include "../comedidev.h" #include diff --git a/drivers/staging/comedi/drivers/multiq3.c b/drivers/staging/comedi/drivers/multiq3.c index 8db2aad5441e5..088e3524e5863 100644 --- a/drivers/staging/comedi/drivers/multiq3.c +++ b/drivers/staging/comedi/drivers/multiq3.c @@ -24,6 +24,7 @@ Devices: [Quanser Consulting] MultiQ-3 (multiq3) */ +#include #include #include "../comedidev.h" diff --git a/drivers/staging/comedi/drivers/ni_6527.c b/drivers/staging/comedi/drivers/ni_6527.c index 2077d6ba6d3f2..c2745f201f2c1 100644 --- a/drivers/staging/comedi/drivers/ni_6527.c +++ b/drivers/staging/comedi/drivers/ni_6527.c @@ -36,6 +36,7 @@ Updated: Sat, 25 Jan 2003 13:24:40 -0800 #define DEBUG 1 #define DEBUG_FLAGS +#include #include #include diff --git a/drivers/staging/comedi/drivers/ni_65xx.c b/drivers/staging/comedi/drivers/ni_65xx.c index 1bd830023118d..3ba4c5712dffe 100644 --- a/drivers/staging/comedi/drivers/ni_65xx.c +++ b/drivers/staging/comedi/drivers/ni_65xx.c @@ -46,6 +46,7 @@ except maybe the 6514. #define DEBUG 1 #define DEBUG_FLAGS +#include #include #include diff --git a/drivers/staging/comedi/drivers/ni_660x.c b/drivers/staging/comedi/drivers/ni_660x.c index d90d4a09ba4c8..3607336dafe29 100644 --- a/drivers/staging/comedi/drivers/ni_660x.c +++ b/drivers/staging/comedi/drivers/ni_660x.c @@ -34,6 +34,7 @@ * DAQ 6601/6602 User Manual (NI 322137B-01) */ +#include #include #include diff --git a/drivers/staging/comedi/drivers/ni_670x.c b/drivers/staging/comedi/drivers/ni_670x.c index 4876f116ba928..02016258bd4e2 100644 --- a/drivers/staging/comedi/drivers/ni_670x.c +++ b/drivers/staging/comedi/drivers/ni_670x.c @@ -36,6 +36,7 @@ Commands are not supported. */ +#include #include #include diff --git a/drivers/staging/comedi/drivers/ni_at_a2150.c b/drivers/staging/comedi/drivers/ni_at_a2150.c index 82c5ca6863005..e13d5c83fb483 100644 --- a/drivers/staging/comedi/drivers/ni_at_a2150.c +++ b/drivers/staging/comedi/drivers/ni_at_a2150.c @@ -58,12 +58,15 @@ TRIG_WAKE_EOS */ +#include +#include #include #include #include "../comedidev.h" #include #include + #include #include "8253.h" diff --git a/drivers/staging/comedi/drivers/ni_at_ao.c b/drivers/staging/comedi/drivers/ni_at_ao.c index 639377a60c129..e19a7673ac3bb 100644 --- a/drivers/staging/comedi/drivers/ni_at_ao.c +++ b/drivers/staging/comedi/drivers/ni_at_ao.c @@ -36,6 +36,7 @@ Configuration options: * document 320379.pdf. */ +#include #include "../comedidev.h" #include diff --git a/drivers/staging/comedi/drivers/ni_atmio.c b/drivers/staging/comedi/drivers/ni_atmio.c index 713edd55a91b6..64f5dc7c5431e 100644 --- a/drivers/staging/comedi/drivers/ni_atmio.c +++ b/drivers/staging/comedi/drivers/ni_atmio.c @@ -89,6 +89,7 @@ are not supported. */ +#include #include #include "../comedidev.h" diff --git a/drivers/staging/comedi/drivers/ni_atmio16d.c b/drivers/staging/comedi/drivers/ni_atmio16d.c index d91fbc8240c0e..7b28fffa4913b 100644 --- a/drivers/staging/comedi/drivers/ni_atmio16d.c +++ b/drivers/staging/comedi/drivers/ni_atmio16d.c @@ -30,6 +30,7 @@ Devices: [National Instruments] AT-MIO-16 (atmio16), AT-MIO-16D (atmio16d) * */ +#include #include #include "../comedidev.h" diff --git a/drivers/staging/comedi/drivers/ni_daq_700.c b/drivers/staging/comedi/drivers/ni_daq_700.c index 12aa15b428879..c274a14216ea1 100644 --- a/drivers/staging/comedi/drivers/ni_daq_700.c +++ b/drivers/staging/comedi/drivers/ni_daq_700.c @@ -45,6 +45,8 @@ Manuals: Register level: http://www.ni.com/pdf/manuals/340698.pdf User Manual: http://www.ni.com/pdf/manuals/320676d.pdf */ +#include +#include #include #include diff --git a/drivers/staging/comedi/drivers/ni_daq_dio24.c b/drivers/staging/comedi/drivers/ni_daq_dio24.c index d3d4eb9356a75..335ea34fa57ce 100644 --- a/drivers/staging/comedi/drivers/ni_daq_dio24.c +++ b/drivers/staging/comedi/drivers/ni_daq_dio24.c @@ -31,6 +31,7 @@ This is just a wrapper around the 8255.o driver to properly handle the PCMCIA interface. */ +#include #include "../comedidev.h" #include diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c index 4119dcfd47617..3e95ac5402caf 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.c +++ b/drivers/staging/comedi/drivers/ni_labpc.c @@ -57,6 +57,7 @@ * 320502b (lab-pc+) */ +#include #include #include #include diff --git a/drivers/staging/comedi/drivers/ni_labpc_cs.c b/drivers/staging/comedi/drivers/ni_labpc_cs.c index df1de784e90b0..0a8b3223f74e3 100644 --- a/drivers/staging/comedi/drivers/ni_labpc_cs.c +++ b/drivers/staging/comedi/drivers/ni_labpc_cs.c @@ -53,6 +53,7 @@ NI manuals: */ +#include #include "../comedidev.h" #include diff --git a/drivers/staging/comedi/drivers/ni_labpc_pci.c b/drivers/staging/comedi/drivers/ni_labpc_pci.c index 203a7cef77502..8be681fca9078 100644 --- a/drivers/staging/comedi/drivers/ni_labpc_pci.c +++ b/drivers/staging/comedi/drivers/ni_labpc_pci.c @@ -29,6 +29,7 @@ * 340914a (pci-1200) */ +#include #include #include diff --git a/drivers/staging/comedi/drivers/ni_mio_cs.c b/drivers/staging/comedi/drivers/ni_mio_cs.c index f813f57636719..229a273f20168 100644 --- a/drivers/staging/comedi/drivers/ni_mio_cs.c +++ b/drivers/staging/comedi/drivers/ni_mio_cs.c @@ -36,6 +36,7 @@ See the notes in the ni_atmio.o driver. */ +#include #include "../comedidev.h" #include diff --git a/drivers/staging/comedi/drivers/ni_pcidio.c b/drivers/staging/comedi/drivers/ni_pcidio.c index 3c5275b669fc2..8ac7a7cce0e6e 100644 --- a/drivers/staging/comedi/drivers/ni_pcidio.c +++ b/drivers/staging/comedi/drivers/ni_pcidio.c @@ -50,6 +50,7 @@ comedi_nonfree_firmware tarball available from http://www.comedi.org /* #define DEBUG 1 */ /* #define DEBUG_FLAGS */ +#include #include #include #include diff --git a/drivers/staging/comedi/drivers/ni_pcimio.c b/drivers/staging/comedi/drivers/ni_pcimio.c index 35681ba1f3693..536be83af5494 100644 --- a/drivers/staging/comedi/drivers/ni_pcimio.c +++ b/drivers/staging/comedi/drivers/ni_pcimio.c @@ -106,6 +106,7 @@ SCXI is probably broken for m-series boards. */ +#include #include #include "../comedidev.h" diff --git a/drivers/staging/comedi/drivers/ni_tio.c b/drivers/staging/comedi/drivers/ni_tio.c index 5b6fde08e5829..9b120c77d83a8 100644 --- a/drivers/staging/comedi/drivers/ni_tio.c +++ b/drivers/staging/comedi/drivers/ni_tio.c @@ -44,6 +44,7 @@ DAQ 6601/6602 User Manual (NI 322137B-01) Support use of both banks X and Y */ +#include #include #include "ni_tio_internal.h" diff --git a/drivers/staging/comedi/drivers/ni_tiocmd.c b/drivers/staging/comedi/drivers/ni_tiocmd.c index cff50bc45bcd7..45691efefd056 100644 --- a/drivers/staging/comedi/drivers/ni_tiocmd.c +++ b/drivers/staging/comedi/drivers/ni_tiocmd.c @@ -44,6 +44,7 @@ DAQ 6601/6602 User Manual (NI 322137B-01) Support use of both banks X and Y */ +#include #include "comedi_fc.h" #include "ni_tio_internal.h" #include "mite.h" diff --git a/drivers/staging/comedi/drivers/pcl711.c b/drivers/staging/comedi/drivers/pcl711.c index f5ac58342a7c4..6986837edef07 100644 --- a/drivers/staging/comedi/drivers/pcl711.c +++ b/drivers/staging/comedi/drivers/pcl711.c @@ -53,6 +53,7 @@ supported. */ +#include #include #include "../comedidev.h" diff --git a/drivers/staging/comedi/drivers/pcl724.c b/drivers/staging/comedi/drivers/pcl724.c index cea657c7801dd..51fe1a2740e6b 100644 --- a/drivers/staging/comedi/drivers/pcl724.c +++ b/drivers/staging/comedi/drivers/pcl724.c @@ -25,6 +25,7 @@ * 1, 96: 96 DIO configuration */ +#include #include "../comedidev.h" #include diff --git a/drivers/staging/comedi/drivers/pcl726.c b/drivers/staging/comedi/drivers/pcl726.c index 9bd341fedced2..e167ea6f67609 100644 --- a/drivers/staging/comedi/drivers/pcl726.c +++ b/drivers/staging/comedi/drivers/pcl726.c @@ -62,6 +62,7 @@ Interrupts are not supported. their web page. (http://www.cir.com/) */ +#include #include "../comedidev.h" #include diff --git a/drivers/staging/comedi/drivers/pcl730.c b/drivers/staging/comedi/drivers/pcl730.c index 862e75fd68fd8..6d23a9d0ddcbe 100644 --- a/drivers/staging/comedi/drivers/pcl730.c +++ b/drivers/staging/comedi/drivers/pcl730.c @@ -27,6 +27,7 @@ * The ACL-7130 card has an 8254 timer/counter not supported by this driver. */ +#include #include "../comedidev.h" #include diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index 699d4558c1221..c4f2f4e0a40f7 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -108,6 +108,7 @@ * 3= 20V unipolar inputs */ +#include #include #include #include "../comedidev.h" diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index 02285976177ab..dfce2a5599ceb 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -32,6 +32,7 @@ Configuration Options: */ +#include #include "../comedidev.h" #include diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index 55f10e754c762..48042967065d0 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -98,6 +98,7 @@ A word or two about DMA. Driver support DMA operations at two ways: */ +#include #include #include #include diff --git a/drivers/staging/comedi/drivers/pcm3724.c b/drivers/staging/comedi/drivers/pcm3724.c index 87cba62c6aed1..31d398ca9ae1a 100644 --- a/drivers/staging/comedi/drivers/pcm3724.c +++ b/drivers/staging/comedi/drivers/pcm3724.c @@ -28,6 +28,7 @@ Copy/pasted/hacked from pcm724.c * struct comedi_insn */ +#include #include "../comedidev.h" #include diff --git a/drivers/staging/comedi/drivers/pcmad.c b/drivers/staging/comedi/drivers/pcmad.c index d5c728dc6192f..423f23676d26c 100644 --- a/drivers/staging/comedi/drivers/pcmad.c +++ b/drivers/staging/comedi/drivers/pcmad.c @@ -38,6 +38,7 @@ * 1 = two's complement (+-10V input range) */ +#include #include "../comedidev.h" #define PCMAD_STATUS 0 diff --git a/drivers/staging/comedi/drivers/pcmda12.c b/drivers/staging/comedi/drivers/pcmda12.c index 2839241bb35aa..1c7a135c91d68 100644 --- a/drivers/staging/comedi/drivers/pcmda12.c +++ b/drivers/staging/comedi/drivers/pcmda12.c @@ -48,6 +48,7 @@ * [1] - Do Simultaneous Xfer (see description) */ +#include #include "../comedidev.h" /* AI range is not configurable, it's set by jumpers on the board */ diff --git a/drivers/staging/comedi/drivers/pcmmio.c b/drivers/staging/comedi/drivers/pcmmio.c index feb83caef26f1..fab93a73651da 100644 --- a/drivers/staging/comedi/drivers/pcmmio.c +++ b/drivers/staging/comedi/drivers/pcmmio.c @@ -72,6 +72,7 @@ Configuration Options: leave out if you don't need this feature) */ +#include #include #include diff --git a/drivers/staging/comedi/drivers/pcmuio.c b/drivers/staging/comedi/drivers/pcmuio.c index 30f53fb5a0acf..13f1943f5b8bc 100644 --- a/drivers/staging/comedi/drivers/pcmuio.c +++ b/drivers/staging/comedi/drivers/pcmuio.c @@ -73,6 +73,7 @@ * can be the same as first irq!) */ +#include #include #include diff --git a/drivers/staging/comedi/drivers/poc.c b/drivers/staging/comedi/drivers/poc.c index e50dd09a20313..3b51bef52ef65 100644 --- a/drivers/staging/comedi/drivers/poc.c +++ b/drivers/staging/comedi/drivers/poc.c @@ -30,6 +30,7 @@ Configuration options: [0] - I/O port base */ +#include #include "../comedidev.h" #include diff --git a/drivers/staging/comedi/drivers/quatech_daqp_cs.c b/drivers/staging/comedi/drivers/quatech_daqp_cs.c index 478a97271a487..9775d3622a626 100644 --- a/drivers/staging/comedi/drivers/quatech_daqp_cs.c +++ b/drivers/staging/comedi/drivers/quatech_daqp_cs.c @@ -47,6 +47,7 @@ Status: works Devices: [Quatech] DAQP-208 (daqp), DAQP-308 */ +#include #include "../comedidev.h" #include diff --git a/drivers/staging/comedi/drivers/rtd520.c b/drivers/staging/comedi/drivers/rtd520.c index 928f534ae4ec9..635c8f5cd8f68 100644 --- a/drivers/staging/comedi/drivers/rtd520.c +++ b/drivers/staging/comedi/drivers/rtd520.c @@ -95,6 +95,7 @@ * Digital-IO and Analog-Out only support instruction mode. */ +#include #include #include #include diff --git a/drivers/staging/comedi/drivers/rti800.c b/drivers/staging/comedi/drivers/rti800.c index b95fce5d26fb7..47a0abc88dbb8 100644 --- a/drivers/staging/comedi/drivers/rti800.c +++ b/drivers/staging/comedi/drivers/rti800.c @@ -49,6 +49,8 @@ * [8] - DAC 1 encoding (same as DAC 0) */ +#include +#include #include #include "../comedidev.h" diff --git a/drivers/staging/comedi/drivers/rti802.c b/drivers/staging/comedi/drivers/rti802.c index 664ad70b05019..116687ba21ae4 100644 --- a/drivers/staging/comedi/drivers/rti802.c +++ b/drivers/staging/comedi/drivers/rti802.c @@ -32,6 +32,7 @@ Configuration Options: [17] - dac#7 ... */ +#include #include "../comedidev.h" #include diff --git a/drivers/staging/comedi/drivers/s526.c b/drivers/staging/comedi/drivers/s526.c index 24d21eef74f84..0373a45ec4e7f 100644 --- a/drivers/staging/comedi/drivers/s526.c +++ b/drivers/staging/comedi/drivers/s526.c @@ -36,6 +36,7 @@ comedi_config /dev/comedi0 s526 0x2C0,0x3 */ +#include #include "../comedidev.h" #include #include diff --git a/drivers/staging/comedi/drivers/s626.c b/drivers/staging/comedi/drivers/s626.c index f5ef91f39bbfa..b0ba9b9b433b3 100644 --- a/drivers/staging/comedi/drivers/s626.c +++ b/drivers/staging/comedi/drivers/s626.c @@ -59,6 +59,8 @@ INSN_CONFIG instructions: comedi_do_insn(cf,&insn); //executing configuration */ +#include +#include #include #include #include diff --git a/drivers/staging/comedi/drivers/serial2002.c b/drivers/staging/comedi/drivers/serial2002.c index b6efe9b1d4d2d..11a6da8414541 100644 --- a/drivers/staging/comedi/drivers/serial2002.c +++ b/drivers/staging/comedi/drivers/serial2002.c @@ -26,6 +26,7 @@ Status: in development */ +#include #include "../comedidev.h" #include diff --git a/drivers/staging/comedi/drivers/skel.c b/drivers/staging/comedi/drivers/skel.c index 3fc7713af5ceb..f76fd09e7bd31 100644 --- a/drivers/staging/comedi/drivers/skel.c +++ b/drivers/staging/comedi/drivers/skel.c @@ -67,6 +67,7 @@ Configuration Options: * options that are used with comedi_config. */ +#include #include #include "../comedidev.h" diff --git a/drivers/staging/comedi/drivers/ssv_dnp.c b/drivers/staging/comedi/drivers/ssv_dnp.c index 45c661cbdbb9f..4da4d3208fdbb 100644 --- a/drivers/staging/comedi/drivers/ssv_dnp.c +++ b/drivers/staging/comedi/drivers/ssv_dnp.c @@ -26,6 +26,7 @@ Status: unknown /* include files ----------------------------------------------------------- */ +#include #include "../comedidev.h" /* Some global definitions: the registers of the DNP ----------------------- */ diff --git a/drivers/staging/comedi/drivers/unioxx5.c b/drivers/staging/comedi/drivers/unioxx5.c index 806285bc6ca73..a4cb573233e3e 100644 --- a/drivers/staging/comedi/drivers/unioxx5.c +++ b/drivers/staging/comedi/drivers/unioxx5.c @@ -40,6 +40,8 @@ Devices: [Fastwel] UNIOxx-5 (unioxx5), #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include +#include #include "../comedidev.h" #include -- GitLab From 8e6b7915a1da703617dca28c33e150141fcec9b0 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 24 Jun 2013 17:05:07 -0700 Subject: [PATCH 068/942] staging: comedi: drivers do not need All the ioport resources are managed by the comedi core. None of the drivers depend on . Remove the includes. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_fops.c | 1 - drivers/staging/comedi/drivers/8255.c | 2 -- drivers/staging/comedi/drivers/aio_aio12_8.c | 1 - drivers/staging/comedi/drivers/aio_iiro_16.c | 1 - drivers/staging/comedi/drivers/c6xdigio.c | 1 - drivers/staging/comedi/drivers/comedi_parport.c | 1 - drivers/staging/comedi/drivers/das16m1.c | 1 - drivers/staging/comedi/drivers/das1800.c | 1 - drivers/staging/comedi/drivers/das6402.c | 2 -- drivers/staging/comedi/drivers/das800.c | 1 - drivers/staging/comedi/drivers/dmm32at.c | 1 - drivers/staging/comedi/drivers/dt2801.c | 1 - drivers/staging/comedi/drivers/dt2811.c | 2 -- drivers/staging/comedi/drivers/dt2814.c | 1 - drivers/staging/comedi/drivers/dt2815.c | 1 - drivers/staging/comedi/drivers/dt2817.c | 2 -- drivers/staging/comedi/drivers/dt282x.c | 1 - drivers/staging/comedi/drivers/fl512.c | 1 - drivers/staging/comedi/drivers/mpc624.c | 1 - drivers/staging/comedi/drivers/multiq3.c | 2 -- drivers/staging/comedi/drivers/ni_at_a2150.c | 1 - drivers/staging/comedi/drivers/ni_at_ao.c | 2 -- drivers/staging/comedi/drivers/ni_atmio16d.c | 2 -- drivers/staging/comedi/drivers/ni_daq_700.c | 1 - drivers/staging/comedi/drivers/pcl711.c | 1 - drivers/staging/comedi/drivers/pcl724.c | 1 - drivers/staging/comedi/drivers/pcl726.c | 2 -- drivers/staging/comedi/drivers/pcl730.c | 2 -- drivers/staging/comedi/drivers/pcl812.c | 1 - drivers/staging/comedi/drivers/pcl816.c | 1 - drivers/staging/comedi/drivers/pcl818.c | 1 - drivers/staging/comedi/drivers/pcm3724.c | 1 - drivers/staging/comedi/drivers/poc.c | 2 -- drivers/staging/comedi/drivers/rti800.c | 2 -- drivers/staging/comedi/drivers/rti802.c | 2 -- drivers/staging/comedi/drivers/s526.c | 1 - drivers/staging/comedi/drivers/serial2002.c | 1 - drivers/staging/comedi/drivers/unioxx5.c | 1 - drivers/staging/comedi/kcomedilib/kcomedilib_main.c | 1 - 39 files changed, 51 deletions(-) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 8647518259f6d..ad275567c09ad 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/staging/comedi/drivers/8255.c b/drivers/staging/comedi/drivers/8255.c index 7966079a8361a..1fa29ac4eb5df 100644 --- a/drivers/staging/comedi/drivers/8255.c +++ b/drivers/staging/comedi/drivers/8255.c @@ -76,8 +76,6 @@ I/O port base address can be found in the output of 'lspci -v'. #include #include "../comedidev.h" -#include - #include "comedi_fc.h" #include "8255.h" diff --git a/drivers/staging/comedi/drivers/aio_aio12_8.c b/drivers/staging/comedi/drivers/aio_aio12_8.c index 8d081076eed66..abb28498b58c3 100644 --- a/drivers/staging/comedi/drivers/aio_aio12_8.c +++ b/drivers/staging/comedi/drivers/aio_aio12_8.c @@ -37,7 +37,6 @@ Configuration Options: #include #include "../comedidev.h" -#include #include "8255.h" /* diff --git a/drivers/staging/comedi/drivers/aio_iiro_16.c b/drivers/staging/comedi/drivers/aio_iiro_16.c index f066b5714941b..afe87cc897612 100644 --- a/drivers/staging/comedi/drivers/aio_iiro_16.c +++ b/drivers/staging/comedi/drivers/aio_iiro_16.c @@ -32,7 +32,6 @@ Configuration Options: #include #include "../comedidev.h" -#include #define AIO_IIRO_16_SIZE 0x08 #define AIO_IIRO_16_RELAY_0_7 0x00 diff --git a/drivers/staging/comedi/drivers/c6xdigio.c b/drivers/staging/comedi/drivers/c6xdigio.c index 929218a359754..cff23acd76ee3 100644 --- a/drivers/staging/comedi/drivers/c6xdigio.c +++ b/drivers/staging/comedi/drivers/c6xdigio.c @@ -35,7 +35,6 @@ This driver will not work with a 2.4 kernel. #include #include #include -#include #include #include #include diff --git a/drivers/staging/comedi/drivers/comedi_parport.c b/drivers/staging/comedi/drivers/comedi_parport.c index da52e514b90ef..f28a15f0274e4 100644 --- a/drivers/staging/comedi/drivers/comedi_parport.c +++ b/drivers/staging/comedi/drivers/comedi_parport.c @@ -79,7 +79,6 @@ pin, which can be used to wake up tasks. #include #include "../comedidev.h" #include -#include #include "comedi_fc.h" diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index ede0d47aefc37..b943c449b6919 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -53,7 +53,6 @@ irq can be omitted, although the cmd interface will not work without it. */ #include -#include #include #include "../comedidev.h" diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index f5ed55c68fa16..5b300294d3229 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -100,7 +100,6 @@ Unipolar and bipolar ranges cannot be mixed in the channel/gain list. #include #include "../comedidev.h" -#include #include #include "8253.h" diff --git a/drivers/staging/comedi/drivers/das6402.c b/drivers/staging/comedi/drivers/das6402.c index 8f6dc0a449091..fb25cb847032e 100644 --- a/drivers/staging/comedi/drivers/das6402.c +++ b/drivers/staging/comedi/drivers/das6402.c @@ -37,8 +37,6 @@ This driver has suffered bitrot. #include #include "../comedidev.h" -#include - #define DAS6402_SIZE 16 #define N_WORDS (3000*64) diff --git a/drivers/staging/comedi/drivers/das800.c b/drivers/staging/comedi/drivers/das800.c index 13e1cd0afd324..11e16114e4e31 100644 --- a/drivers/staging/comedi/drivers/das800.c +++ b/drivers/staging/comedi/drivers/das800.c @@ -60,7 +60,6 @@ cmd triggers supported: #include #include "../comedidev.h" -#include #include #include "8253.h" diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index 1d80d74575295..5237f47d39ae9 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -36,7 +36,6 @@ Configuration Options: #include #include #include "../comedidev.h" -#include #include "comedi_fc.h" diff --git a/drivers/staging/comedi/drivers/dt2801.c b/drivers/staging/comedi/drivers/dt2801.c index 2537696f80fc9..e0e7beab7274b 100644 --- a/drivers/staging/comedi/drivers/dt2801.c +++ b/drivers/staging/comedi/drivers/dt2801.c @@ -32,7 +32,6 @@ Configuration options: #include #include "../comedidev.h" #include -#include #define DT2801_TIMEOUT 1000 diff --git a/drivers/staging/comedi/drivers/dt2811.c b/drivers/staging/comedi/drivers/dt2811.c index 34afa940db772..a41a5716f3584 100644 --- a/drivers/staging/comedi/drivers/dt2811.c +++ b/drivers/staging/comedi/drivers/dt2811.c @@ -45,8 +45,6 @@ Configuration options: #include #include "../comedidev.h" -#include - static const struct comedi_lrange range_dt2811_pgh_ai_5_unipolar = { 4, { RANGE(0, 5), diff --git a/drivers/staging/comedi/drivers/dt2814.c b/drivers/staging/comedi/drivers/dt2814.c index a1076a43c294d..6514b9e005528 100644 --- a/drivers/staging/comedi/drivers/dt2814.c +++ b/drivers/staging/comedi/drivers/dt2814.c @@ -38,7 +38,6 @@ addition, the clock does not seem to be very accurate. #include #include "../comedidev.h" -#include #include #include "comedi_fc.h" diff --git a/drivers/staging/comedi/drivers/dt2815.c b/drivers/staging/comedi/drivers/dt2815.c index c33708c905858..34040f0175e88 100644 --- a/drivers/staging/comedi/drivers/dt2815.c +++ b/drivers/staging/comedi/drivers/dt2815.c @@ -54,7 +54,6 @@ Configuration options: #include #include "../comedidev.h" -#include #include #define DT2815_SIZE 2 diff --git a/drivers/staging/comedi/drivers/dt2817.c b/drivers/staging/comedi/drivers/dt2817.c index 1ba49e79ee010..51cf1211f1ba6 100644 --- a/drivers/staging/comedi/drivers/dt2817.c +++ b/drivers/staging/comedi/drivers/dt2817.c @@ -36,8 +36,6 @@ Configuration options: #include #include "../comedidev.h" -#include - #define DT2817_SIZE 5 #define DT2817_CR 0 diff --git a/drivers/staging/comedi/drivers/dt282x.c b/drivers/staging/comedi/drivers/dt282x.c index 6d3553c8a24d0..23cb033559b3c 100644 --- a/drivers/staging/comedi/drivers/dt282x.c +++ b/drivers/staging/comedi/drivers/dt282x.c @@ -56,7 +56,6 @@ Configuration options: #include #include -#include #include #include diff --git a/drivers/staging/comedi/drivers/fl512.c b/drivers/staging/comedi/drivers/fl512.c index 13f86d5cc9570..8d70f64b15747 100644 --- a/drivers/staging/comedi/drivers/fl512.c +++ b/drivers/staging/comedi/drivers/fl512.c @@ -22,7 +22,6 @@ Configuration options: #include "../comedidev.h" #include -#include #define FL512_SIZE 16 /* the size of the used memory */ struct fl512_private { diff --git a/drivers/staging/comedi/drivers/mpc624.c b/drivers/staging/comedi/drivers/mpc624.c index bfdc2d36e6510..acbaeee6250c8 100644 --- a/drivers/staging/comedi/drivers/mpc624.c +++ b/drivers/staging/comedi/drivers/mpc624.c @@ -54,7 +54,6 @@ Configuration Options: #include #include "../comedidev.h" -#include #include /* Consecutive I/O port addresses */ diff --git a/drivers/staging/comedi/drivers/multiq3.c b/drivers/staging/comedi/drivers/multiq3.c index 088e3524e5863..9d75ea4e201bc 100644 --- a/drivers/staging/comedi/drivers/multiq3.c +++ b/drivers/staging/comedi/drivers/multiq3.c @@ -28,8 +28,6 @@ Devices: [Quanser Consulting] MultiQ-3 (multiq3) #include #include "../comedidev.h" -#include - #define MULTIQ3_SIZE 16 /* diff --git a/drivers/staging/comedi/drivers/ni_at_a2150.c b/drivers/staging/comedi/drivers/ni_at_a2150.c index e13d5c83fb483..2512ce8dfcaa7 100644 --- a/drivers/staging/comedi/drivers/ni_at_a2150.c +++ b/drivers/staging/comedi/drivers/ni_at_a2150.c @@ -64,7 +64,6 @@ TRIG_WAKE_EOS #include #include "../comedidev.h" -#include #include #include diff --git a/drivers/staging/comedi/drivers/ni_at_ao.c b/drivers/staging/comedi/drivers/ni_at_ao.c index e19a7673ac3bb..0025496bc643c 100644 --- a/drivers/staging/comedi/drivers/ni_at_ao.c +++ b/drivers/staging/comedi/drivers/ni_at_ao.c @@ -39,8 +39,6 @@ Configuration options: #include #include "../comedidev.h" -#include - /* board egisters */ /* registers with _2_ are accessed when GRP2WR is set in CFG1 */ diff --git a/drivers/staging/comedi/drivers/ni_atmio16d.c b/drivers/staging/comedi/drivers/ni_atmio16d.c index 7b28fffa4913b..8520d83d940f7 100644 --- a/drivers/staging/comedi/drivers/ni_atmio16d.c +++ b/drivers/staging/comedi/drivers/ni_atmio16d.c @@ -34,8 +34,6 @@ Devices: [National Instruments] AT-MIO-16 (atmio16), AT-MIO-16D (atmio16d) #include #include "../comedidev.h" -#include - #include "comedi_fc.h" #include "8255.h" diff --git a/drivers/staging/comedi/drivers/ni_daq_700.c b/drivers/staging/comedi/drivers/ni_daq_700.c index c274a14216ea1..41659652a491f 100644 --- a/drivers/staging/comedi/drivers/ni_daq_700.c +++ b/drivers/staging/comedi/drivers/ni_daq_700.c @@ -47,7 +47,6 @@ Manuals: Register level: http://www.ni.com/pdf/manuals/340698.pdf #include #include -#include #include #include "../comedidev.h" diff --git a/drivers/staging/comedi/drivers/pcl711.c b/drivers/staging/comedi/drivers/pcl711.c index 6986837edef07..e859f85a8e17c 100644 --- a/drivers/staging/comedi/drivers/pcl711.c +++ b/drivers/staging/comedi/drivers/pcl711.c @@ -57,7 +57,6 @@ supported. #include #include "../comedidev.h" -#include #include #include "comedi_fc.h" diff --git a/drivers/staging/comedi/drivers/pcl724.c b/drivers/staging/comedi/drivers/pcl724.c index 51fe1a2740e6b..88060222baf36 100644 --- a/drivers/staging/comedi/drivers/pcl724.c +++ b/drivers/staging/comedi/drivers/pcl724.c @@ -28,7 +28,6 @@ #include #include "../comedidev.h" -#include #include #include "8255.h" diff --git a/drivers/staging/comedi/drivers/pcl726.c b/drivers/staging/comedi/drivers/pcl726.c index e167ea6f67609..a4d0bcc31e52d 100644 --- a/drivers/staging/comedi/drivers/pcl726.c +++ b/drivers/staging/comedi/drivers/pcl726.c @@ -65,8 +65,6 @@ Interrupts are not supported. #include #include "../comedidev.h" -#include - #undef ACL6126_IRQ /* no interrupt support (yet) */ #define PCL726_SIZE 16 diff --git a/drivers/staging/comedi/drivers/pcl730.c b/drivers/staging/comedi/drivers/pcl730.c index 6d23a9d0ddcbe..2a659f23ecda7 100644 --- a/drivers/staging/comedi/drivers/pcl730.c +++ b/drivers/staging/comedi/drivers/pcl730.c @@ -30,8 +30,6 @@ #include #include "../comedidev.h" -#include - /* * Register map * diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index c4f2f4e0a40f7..35251e71b7f8a 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -114,7 +114,6 @@ #include "../comedidev.h" #include -#include #include #include diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index dfce2a5599ceb..f03134962596c 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -35,7 +35,6 @@ Configuration Options: #include #include "../comedidev.h" -#include #include #include #include diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index 48042967065d0..a52ba82ff0e4a 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -99,7 +99,6 @@ A word or two about DMA. Driver support DMA operations at two ways: */ #include -#include #include #include #include diff --git a/drivers/staging/comedi/drivers/pcm3724.c b/drivers/staging/comedi/drivers/pcm3724.c index 31d398ca9ae1a..4c710e52e63b0 100644 --- a/drivers/staging/comedi/drivers/pcm3724.c +++ b/drivers/staging/comedi/drivers/pcm3724.c @@ -31,7 +31,6 @@ Copy/pasted/hacked from pcm724.c #include #include "../comedidev.h" -#include #include #include "8255.h" diff --git a/drivers/staging/comedi/drivers/poc.c b/drivers/staging/comedi/drivers/poc.c index 3b51bef52ef65..2ae4ee15704cc 100644 --- a/drivers/staging/comedi/drivers/poc.c +++ b/drivers/staging/comedi/drivers/poc.c @@ -33,8 +33,6 @@ Configuration options: #include #include "../comedidev.h" -#include - struct boarddef_struct { const char *name; unsigned int iosize; diff --git a/drivers/staging/comedi/drivers/rti800.c b/drivers/staging/comedi/drivers/rti800.c index 47a0abc88dbb8..cbb4ba5b852a1 100644 --- a/drivers/staging/comedi/drivers/rti800.c +++ b/drivers/staging/comedi/drivers/rti800.c @@ -54,8 +54,6 @@ #include #include "../comedidev.h" -#include - /* * Register map */ diff --git a/drivers/staging/comedi/drivers/rti802.c b/drivers/staging/comedi/drivers/rti802.c index 116687ba21ae4..a3fa2a4baef43 100644 --- a/drivers/staging/comedi/drivers/rti802.c +++ b/drivers/staging/comedi/drivers/rti802.c @@ -35,8 +35,6 @@ Configuration Options: #include #include "../comedidev.h" -#include - #define RTI802_SIZE 4 #define RTI802_SELECT 0 diff --git a/drivers/staging/comedi/drivers/s526.c b/drivers/staging/comedi/drivers/s526.c index 0373a45ec4e7f..6670b865256b3 100644 --- a/drivers/staging/comedi/drivers/s526.c +++ b/drivers/staging/comedi/drivers/s526.c @@ -38,7 +38,6 @@ comedi_config /dev/comedi0 s526 0x2C0,0x3 #include #include "../comedidev.h" -#include #include #define S526_SIZE 64 diff --git a/drivers/staging/comedi/drivers/serial2002.c b/drivers/staging/comedi/drivers/serial2002.c index 11a6da8414541..441813ffb175a 100644 --- a/drivers/staging/comedi/drivers/serial2002.c +++ b/drivers/staging/comedi/drivers/serial2002.c @@ -30,7 +30,6 @@ Status: in development #include "../comedidev.h" #include -#include #include #include diff --git a/drivers/staging/comedi/drivers/unioxx5.c b/drivers/staging/comedi/drivers/unioxx5.c index a4cb573233e3e..93eec2fc254c1 100644 --- a/drivers/staging/comedi/drivers/unioxx5.c +++ b/drivers/staging/comedi/drivers/unioxx5.c @@ -43,7 +43,6 @@ Devices: [Fastwel] UNIOxx-5 (unioxx5), #include #include #include "../comedidev.h" -#include #define DRIVER_NAME "unioxx5" #define UNIOXX5_SIZE 0x10 diff --git a/drivers/staging/comedi/kcomedilib/kcomedilib_main.c b/drivers/staging/comedi/kcomedilib/kcomedilib_main.c index da8988c6bf503..cb3d3260a65e0 100644 --- a/drivers/staging/comedi/kcomedilib/kcomedilib_main.c +++ b/drivers/staging/comedi/kcomedilib/kcomedilib_main.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include -- GitLab From d92fef8d2552ffde42b6092cb467f3021ebf8b98 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 24 Jun 2013 17:05:31 -0700 Subject: [PATCH 069/942] staging: comedi: do not include if its not needed Some of the comedi files include this header but don't need it. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers.c | 1 - drivers/staging/comedi/drivers/c6xdigio.c | 1 - drivers/staging/comedi/drivers/cb_pcimdas.c | 1 - drivers/staging/comedi/drivers/das08.c | 1 - drivers/staging/comedi/drivers/das08_cs.c | 1 - drivers/staging/comedi/drivers/ni_atmio.c | 1 - drivers/staging/comedi/drivers/pcl724.c | 2 -- drivers/staging/comedi/drivers/pcm3724.c | 2 -- drivers/staging/comedi/kcomedilib/kcomedilib_main.c | 1 - 9 files changed, 11 deletions(-) diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index 87df7960c96fd..a15934f94ab0f 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/staging/comedi/drivers/c6xdigio.c b/drivers/staging/comedi/drivers/c6xdigio.c index cff23acd76ee3..217aa19cdc321 100644 --- a/drivers/staging/comedi/drivers/c6xdigio.c +++ b/drivers/staging/comedi/drivers/c6xdigio.c @@ -35,7 +35,6 @@ This driver will not work with a 2.4 kernel. #include #include #include -#include #include #include #include diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c b/drivers/staging/comedi/drivers/cb_pcimdas.c index b8362a71e4bbb..30520d4c16a61 100644 --- a/drivers/staging/comedi/drivers/cb_pcimdas.c +++ b/drivers/staging/comedi/drivers/cb_pcimdas.c @@ -37,7 +37,6 @@ See http://www.mccdaq.com/PDFs/Manuals/pcim-das1602-16.pdf for more details. #include #include -#include #include #include "../comedidev.h" diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 126b4528d3cf2..5f669709501f9 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -34,7 +34,6 @@ */ #include -#include #include "../comedidev.h" diff --git a/drivers/staging/comedi/drivers/das08_cs.c b/drivers/staging/comedi/drivers/das08_cs.c index 719c978bff871..f3ccc2ce6d49d 100644 --- a/drivers/staging/comedi/drivers/das08_cs.c +++ b/drivers/staging/comedi/drivers/das08_cs.c @@ -40,7 +40,6 @@ Command support does not exist, but could be added for this board. */ #include -#include #include "../comedidev.h" diff --git a/drivers/staging/comedi/drivers/ni_atmio.c b/drivers/staging/comedi/drivers/ni_atmio.c index 64f5dc7c5431e..856c73d8b7cd3 100644 --- a/drivers/staging/comedi/drivers/ni_atmio.c +++ b/drivers/staging/comedi/drivers/ni_atmio.c @@ -93,7 +93,6 @@ are not supported. #include #include "../comedidev.h" -#include #include #include "ni_stc.h" diff --git a/drivers/staging/comedi/drivers/pcl724.c b/drivers/staging/comedi/drivers/pcl724.c index 88060222baf36..249f98b8346c1 100644 --- a/drivers/staging/comedi/drivers/pcl724.c +++ b/drivers/staging/comedi/drivers/pcl724.c @@ -28,8 +28,6 @@ #include #include "../comedidev.h" -#include - #include "8255.h" #define SIZE_8255 4 diff --git a/drivers/staging/comedi/drivers/pcm3724.c b/drivers/staging/comedi/drivers/pcm3724.c index 4c710e52e63b0..cca972ebd010e 100644 --- a/drivers/staging/comedi/drivers/pcm3724.c +++ b/drivers/staging/comedi/drivers/pcm3724.c @@ -31,8 +31,6 @@ Copy/pasted/hacked from pcm724.c #include #include "../comedidev.h" -#include - #include "8255.h" #define PCM3724_SIZE 16 diff --git a/drivers/staging/comedi/kcomedilib/kcomedilib_main.c b/drivers/staging/comedi/kcomedilib/kcomedilib_main.c index cb3d3260a65e0..066083c1bceb1 100644 --- a/drivers/staging/comedi/kcomedilib/kcomedilib_main.c +++ b/drivers/staging/comedi/kcomedilib/kcomedilib_main.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include -- GitLab From 381102be5b3e6b23d32eb54a686569ec194f55d1 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 24 Jun 2013 17:07:28 -0700 Subject: [PATCH 070/942] staging: comedi: ii_pci20kc: this is an ISA board not a PCI board The Intelligent Instrumentation PCI-20001C board is a legacy PC/XT/AT 8-bit ISA board not a PCI board. The "PCI" appears to mean "Personal Computer Instrumentation". Move the Kconfig option into the COMEDI_ISA group. Signed-off-by: H Hartley Sweeten Acked-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/Kconfig | 18 +++++++++--------- drivers/staging/comedi/drivers/Makefile | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index 8c8a551322572..e336ee8a8e32b 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -403,6 +403,15 @@ config COMEDI_AIO_IIRO_16 To compile this driver as a module, choose M here: the module will be called aio_iiro_16. +config COMEDI_II_PCI20KC + tristate "Intelligent Instruments PCI-20001C carrier support" + ---help--- + Enable support for Intelligent Instruments PCI-20001C carrier + PCI-20001, PCI-20006 and PCI-20341 + + To compile this driver as a module, choose M here: the module will be + called ii_pci20kc. + config COMEDI_C6XDIGIO tristate "Mechatronic Systems Inc. C6x_DIGIO DSP daughter card support" ---help--- @@ -866,15 +875,6 @@ config COMEDI_ICP_MULTI To compile this driver as a module, choose M here: the module will be called icp_multi. -config COMEDI_II_PCI20KC - tristate "Intelligent Instruments PCI-20001C carrier support" - ---help--- - Enable support for Intelligent Instruments PCI-20001C carrier - PCI-20001, PCI-20006 and PCI-20341 - - To compile this driver as a module, choose M here: the module will be - called ii_pci20kc. - config COMEDI_DAQBOARD2000 tristate "IOtech DAQboard/2000 support" select COMEDI_8255 diff --git a/drivers/staging/comedi/drivers/Makefile b/drivers/staging/comedi/drivers/Makefile index dbb93e332487e..643e5517cba49 100644 --- a/drivers/staging/comedi/drivers/Makefile +++ b/drivers/staging/comedi/drivers/Makefile @@ -39,6 +39,7 @@ obj-$(CONFIG_COMEDI_DMM32AT) += dmm32at.o obj-$(CONFIG_COMEDI_FL512) += fl512.o obj-$(CONFIG_COMEDI_AIO_AIO12_8) += aio_aio12_8.o obj-$(CONFIG_COMEDI_AIO_IIRO_16) += aio_iiro_16.o +obj-$(CONFIG_COMEDI_II_PCI20KC) += ii_pci20kc.o obj-$(CONFIG_COMEDI_C6XDIGIO) += c6xdigio.o obj-$(CONFIG_COMEDI_MPC624) += mpc624.o obj-$(CONFIG_COMEDI_ADQ12B) += adq12b.o @@ -89,7 +90,6 @@ obj-$(CONFIG_COMEDI_DYNA_PCI10XX) += dyna_pci10xx.o obj-$(CONFIG_COMEDI_UNIOXX5) += unioxx5.o obj-$(CONFIG_COMEDI_GSC_HPDI) += gsc_hpdi.o obj-$(CONFIG_COMEDI_ICP_MULTI) += icp_multi.o -obj-$(CONFIG_COMEDI_II_PCI20KC) += ii_pci20kc.o obj-$(CONFIG_COMEDI_DAQBOARD2000) += daqboard2000.o obj-$(CONFIG_COMEDI_JR3_PCI) += jr3_pci.o obj-$(CONFIG_COMEDI_KE_COUNTER) += ke_counter.o -- GitLab From ee68080d2c4c8fdb0ff4b126cb7701d05d47a719 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 24 Jun 2013 17:09:20 -0700 Subject: [PATCH 071/942] staging: comedi: pcl724: add support for the PCM-IO48 PC/104 board This driver can support the WinSystems PCM-IO48 PC/104 board. That board has two 8255 devices providing 48 digital I/O channels. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/Kconfig | 14 ++++++++++++-- drivers/staging/comedi/drivers/pcl724.c | 9 +++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index e336ee8a8e32b..b9dc94a8ea690 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -122,8 +122,18 @@ config COMEDI_PCL724 tristate "Advantech PCL-722/724/731 and ADlink ACL-7122/7124/PET-48DIO" select COMEDI_8255 ---help--- - Enable support for Advantech PCL-724, PCL-722, PCL-731 and - ADlink ACL-7122, ACL-7124, PET-48DIO ISA cards + Enable support for ISA and PC/104 based 8255 digital i/o boards. This + driver provides a legacy comedi driver wrapper for the generic 8255 + support driver. + + Supported boards include: + Advantech PCL-724 24 channels + Advantech PCL-722 144 (or 96) channels + Advantech PCL-731 48 channels + ADlink ACL-7122 144 (or 96) channels + ADlink ACL-7124 24 channels + ADlink PET-48DIO 48 channels + WinSystems PCM-IO48 48 channels (PC/104) To compile this driver as a module, choose M here: the module will be called pcl724. diff --git a/drivers/staging/comedi/drivers/pcl724.c b/drivers/staging/comedi/drivers/pcl724.c index 249f98b8346c1..8af13e790ad19 100644 --- a/drivers/staging/comedi/drivers/pcl724.c +++ b/drivers/staging/comedi/drivers/pcl724.c @@ -1,6 +1,6 @@ /* * pcl724.c - * Comedi driver for 8255 based ISA DIO boards + * Comedi driver for 8255 based ISA and PC/104 DIO boards * * Michal Dobes */ @@ -14,6 +14,7 @@ * (ADLink) ACL-7122 [acl7122] * (ADLink) ACL-7124 [acl7124] * (ADLink) PET-48DIO [pet48dio] + * (WinSystems) PCM-IO48 [pcmio48] * Author: Michal Dobes * Status: untested * @@ -68,6 +69,10 @@ static const struct pcl724_board boardtypes[] = { .io_range = 0x02, .is_pet48 = 1, .numofports = 2, /* 48 DIO channels */ + }, { + .name = "pcmio48", + .io_range = 0x08, + .numofports = 2, /* 48 DIO channels */ }, }; @@ -146,5 +151,5 @@ static struct comedi_driver pcl724_driver = { module_comedi_driver(pcl724_driver); MODULE_AUTHOR("Comedi http://www.comedi.org"); -MODULE_DESCRIPTION("Comedi driver for 8255 based ISA DIO boards"); +MODULE_DESCRIPTION("Comedi driver for 8255 based ISA and PC/104 DIO boards"); MODULE_LICENSE("GPL"); -- GitLab From 99c0e2691736d56190764bfdc59f11b090cda4ff Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Thu, 27 Jun 2013 14:50:57 +0100 Subject: [PATCH 072/942] staging: comedi: return void from comedi_driver_unregister() 'Unregister' functions generally return `void`. `comedi_driver_unregister()` currently returns an `int` errno value. Nothing looks at the return value. Change the return type to `void`. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedidev.h | 2 +- drivers/staging/comedi/drivers.c | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index ab278942ebd1f..98058b9097e61 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -363,7 +363,7 @@ int comedi_auto_config(struct device *, struct comedi_driver *, void comedi_auto_unconfig(struct device *); int comedi_driver_register(struct comedi_driver *); -int comedi_driver_unregister(struct comedi_driver *); +void comedi_driver_unregister(struct comedi_driver *); /** * module_comedi_driver() - Helper macro for registering a comedi driver diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index a15934f94ab0f..ba5d6d927a498 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -559,7 +559,7 @@ int comedi_driver_register(struct comedi_driver *driver) } EXPORT_SYMBOL_GPL(comedi_driver_register); -int comedi_driver_unregister(struct comedi_driver *driver) +void comedi_driver_unregister(struct comedi_driver *driver) { struct comedi_driver *prev; int i; @@ -584,15 +584,14 @@ int comedi_driver_unregister(struct comedi_driver *driver) if (comedi_drivers == driver) { comedi_drivers = driver->next; - return 0; + return; } for (prev = comedi_drivers; prev->next; prev = prev->next) { if (prev->next == driver) { prev->next = driver->next; - return 0; + return; } } - return -EINVAL; } EXPORT_SYMBOL_GPL(comedi_driver_unregister); -- GitLab From c383e2d6dacf0b6fdd40fbaf044e235cac54a20f Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Thu, 27 Jun 2013 14:50:58 +0100 Subject: [PATCH 073/942] staging: comedi: use a mutex when accessing driver list Low-level comedi drivers registered with the comedi core by `comedi_driver_register()` are linked together into a simple linked list headed by the `comedi_drivers` variable and chained by the `next` member of `struct comedi_driver`. A driver is removed from the list by `comedi_driver_unregister()`. The driver list is iterated through by `comedi_device_attach()` when the `COMEDI_DEVCONFIG` ioctl is used to attach a "legacy" device to a driver, and is also iterated through by `comedi_read()` in "proc.c" when reading "/proc/comedi". There is currently no protection against items being added or removed from the list while it is being iterated. Add a mutex `comedi_drivers_list_lock` to be locked while adding or removing an item on the list, or when iterating through the list. `comedi_driver_unregister()` also checks for and detaches any devices using the driver. This is currently done before unlinking the driver from the list, but it makes more sense to unlink the driver from the list first to prevent `comedi_device_attach()` attempting to use it, so move the unlinking part to the start of the function. Also, in `comedi_device_attach()` hold on to the mutex until we've finished attempting to attach the device to avoid it interfering with the detachment in `comedi_driver_unregister()`. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_internal.h | 1 + drivers/staging/comedi/drivers.c | 38 +++++++++++++++--------- drivers/staging/comedi/proc.c | 2 ++ 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/drivers/staging/comedi/comedi_internal.h b/drivers/staging/comedi/comedi_internal.h index d5e03e558b352..fda1a7ba0e16b 100644 --- a/drivers/staging/comedi/comedi_internal.h +++ b/drivers/staging/comedi/comedi_internal.h @@ -24,6 +24,7 @@ extern unsigned int comedi_default_buf_maxsize_kb; /* drivers.c */ extern struct comedi_driver *comedi_drivers; +extern struct mutex comedi_drivers_list_lock; int insn_inval(struct comedi_device *, struct comedi_subdevice *, struct comedi_insn *, unsigned int *); diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index ba5d6d927a498..791a26bd5f63c 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -38,6 +38,7 @@ #include "comedi_internal.h" struct comedi_driver *comedi_drivers; +DEFINE_MUTEX(comedi_drivers_list_lock); int comedi_set_hw_dev(struct comedi_device *dev, struct device *hw_dev) { @@ -453,6 +454,7 @@ int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (dev->attached) return -EBUSY; + mutex_lock(&comedi_drivers_list_lock); for (driv = comedi_drivers; driv; driv = driv->next) { if (!try_module_get(driv->module)) continue; @@ -473,7 +475,8 @@ int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it) comedi_report_boards(driv); module_put(driv->module); } - return -EIO; + ret = -EIO; + goto out; } if (driv->attach == NULL) { /* driver does not support manual configuration */ @@ -481,7 +484,8 @@ int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it) "driver '%s' does not support attach using comedi_config\n", driv->driver_name); module_put(driv->module); - return -ENOSYS; + ret = -ENOSYS; + goto out; } /* initialize dev->driver here so * comedi_error() can be called from attach */ @@ -496,6 +500,8 @@ int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it) module_put(dev->driver->module); } /* On success, the driver module count has been incremented. */ +out: + mutex_unlock(&comedi_drivers_list_lock); return ret; } @@ -552,8 +558,10 @@ EXPORT_SYMBOL_GPL(comedi_auto_unconfig); int comedi_driver_register(struct comedi_driver *driver) { + mutex_lock(&comedi_drivers_list_lock); driver->next = comedi_drivers; comedi_drivers = driver; + mutex_unlock(&comedi_drivers_list_lock); return 0; } @@ -564,6 +572,20 @@ void comedi_driver_unregister(struct comedi_driver *driver) struct comedi_driver *prev; int i; + /* unlink the driver */ + mutex_lock(&comedi_drivers_list_lock); + if (comedi_drivers == driver) { + comedi_drivers = driver->next; + } else { + for (prev = comedi_drivers; prev->next; prev = prev->next) { + if (prev->next == driver) { + prev->next = driver->next; + break; + } + } + } + mutex_unlock(&comedi_drivers_list_lock); + /* check for devices using this driver */ for (i = 0; i < COMEDI_NUM_BOARD_MINORS; i++) { struct comedi_device *dev = comedi_dev_from_minor(i); @@ -581,17 +603,5 @@ void comedi_driver_unregister(struct comedi_driver *driver) } mutex_unlock(&dev->mutex); } - - if (comedi_drivers == driver) { - comedi_drivers = driver->next; - return; - } - - for (prev = comedi_drivers; prev->next; prev = prev->next) { - if (prev->next == driver) { - prev->next = driver->next; - return; - } - } } EXPORT_SYMBOL_GPL(comedi_driver_unregister); diff --git a/drivers/staging/comedi/proc.c b/drivers/staging/comedi/proc.c index 8ee94424bc8fe..ade00035d3bb5 100644 --- a/drivers/staging/comedi/proc.c +++ b/drivers/staging/comedi/proc.c @@ -55,6 +55,7 @@ static int comedi_read(struct seq_file *m, void *v) if (!devices_q) seq_puts(m, "no devices\n"); + mutex_lock(&comedi_drivers_list_lock); for (driv = comedi_drivers; driv; driv = driv->next) { seq_printf(m, "%s:\n", driv->driver_name); for (i = 0; i < driv->num_names; i++) @@ -65,6 +66,7 @@ static int comedi_read(struct seq_file *m, void *v) if (!driv->num_names) seq_printf(m, " %s\n", driv->driver_name); } + mutex_unlock(&comedi_drivers_list_lock); return 0; } -- GitLab From 725a70d8a68ef5368652c0c49631fefb361d62cf Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 28 Jun 2013 17:09:17 +0100 Subject: [PATCH 074/942] staging: comedi: ni_labpc: fix possible double-free of dma_buffer If `labpc_attach()` allocates memory for `devpriv->dma_buffer` but fails to request a DMA channel, it frees `devpriv->dma_buffer` but leaves the pointer set. Later, `labpc_detach()` frees `devpriv->dma_buffer` again, which means it has been freed twice in this case. Fix it by only setting `devpriv->dma_buffer` in `labpc_attach()` if the DMA channel was requested successfully. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_labpc.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c index 3e95ac5402caf..4ff1ed0c8fa85 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.c +++ b/drivers/staging/comedi/drivers/ni_labpc.c @@ -1712,13 +1712,15 @@ static int labpc_attach(struct comedi_device *dev, struct comedi_devconfig *it) #ifdef CONFIG_ISA_DMA_API if (dev->irq && (dma_chan == 1 || dma_chan == 3)) { - devpriv->dma_buffer = kmalloc(dma_buffer_size, - GFP_KERNEL | GFP_DMA); - if (devpriv->dma_buffer) { + void *dma_buffer = kmalloc(dma_buffer_size, + GFP_KERNEL | GFP_DMA); + + if (dma_buffer) { ret = request_dma(dma_chan, dev->board_name); if (ret == 0) { unsigned long dma_flags; + devpriv->dma_buffer = dma_buffer; devpriv->dma_chan = dma_chan; devpriv->dma_addr = virt_to_bus(devpriv->dma_buffer); @@ -1728,7 +1730,7 @@ static int labpc_attach(struct comedi_device *dev, struct comedi_devconfig *it) set_dma_mode(devpriv->dma_chan, DMA_MODE_READ); release_dma_lock(dma_flags); } else { - kfree(devpriv->dma_buffer); + kfree(dma_buffer); } } } -- GitLab From f12a34ca0b7f02f725965f39f9ccf5d5c339d3e0 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 28 Jun 2013 17:09:18 +0100 Subject: [PATCH 075/942] staging: comedi: ni_labpc: don't clear cmd3 bits explicitly in labpc_ai_cmd() `labpc_ai_cmd()` calls `labpc_cancel()` which already sets `devpriv->cmd3` to 0. Remove the lines from `labpc_ai_cmd()` that clear specific bits in `devpriv->cmd3` explicitly as they have no effect. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_labpc.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c index 4ff1ed0c8fa85..65ab8f6c5b69b 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.c +++ b/drivers/staging/comedi/drivers/ni_labpc.c @@ -976,8 +976,7 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) release_dma_lock(irq_flags); /* enable board's dma */ devpriv->cmd3 |= (CMD3_DMAEN | CMD3_DMATCINTEN); - } else - devpriv->cmd3 &= ~(CMD3_DMAEN | CMD3_DMATCINTEN); + } #endif /* enable error interrupts */ @@ -985,8 +984,6 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) /* enable fifo not empty interrupt? */ if (xfer == fifo_not_empty_transfer) devpriv->cmd3 |= CMD3_FIFOINTEN; - else - devpriv->cmd3 &= ~CMD3_FIFOINTEN; devpriv->write_byte(devpriv->cmd3, dev->iobase + CMD3_REG); /* setup any external triggering/pacing (cmd4 register) */ -- GitLab From 9a6386623fc8a67f792b9df56acbd8758e1aa93d Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 28 Jun 2013 17:09:19 +0100 Subject: [PATCH 076/942] staging: comedi: ni_labpc_isadma: new module for ISA DMA support It's just an empty module at the moment, selected by COMEDI_NI_LABPC_ISA && ISA_DMA_API && VIRT_TO_BUS, but will be populated by later patches to migrate ISA DMA support for NI Lab-PC cards out of the "ni_labpc" module. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/Kconfig | 4 ++ drivers/staging/comedi/drivers/Makefile | 1 + drivers/staging/comedi/drivers/ni_labpc.c | 1 + .../staging/comedi/drivers/ni_labpc_isadma.c | 37 +++++++++++++++++++ .../staging/comedi/drivers/ni_labpc_isadma.h | 16 ++++++++ 5 files changed, 59 insertions(+) create mode 100644 drivers/staging/comedi/drivers/ni_labpc_isadma.c create mode 100644 drivers/staging/comedi/drivers/ni_labpc_isadma.h diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index b9dc94a8ea690..b6e8faa5d7771 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -492,6 +492,7 @@ config COMEDI_NI_ATMIO16D config COMEDI_NI_LABPC_ISA tristate "NI Lab-PC and compatibles ISA support" select COMEDI_NI_LABPC + select COMEDI_NI_LABPC_ISADMA if ISA_DMA_API && VIRT_TO_BUS depends on VIRT_TO_BUS ---help--- Enable support for National Instruments Lab-PC and compatibles @@ -1272,6 +1273,9 @@ config COMEDI_NI_LABPC select COMEDI_8255 select COMEDI_FC +config COMEDI_NI_LABPC_ISADMA + tristate + config COMEDI_NI_TIO tristate diff --git a/drivers/staging/comedi/drivers/Makefile b/drivers/staging/comedi/drivers/Makefile index 643e5517cba49..94cbd2618fc8b 100644 --- a/drivers/staging/comedi/drivers/Makefile +++ b/drivers/staging/comedi/drivers/Makefile @@ -132,6 +132,7 @@ obj-$(CONFIG_COMEDI_MITE) += mite.o obj-$(CONFIG_COMEDI_NI_TIO) += ni_tio.o obj-$(CONFIG_COMEDI_NI_TIOCMD) += ni_tiocmd.o obj-$(CONFIG_COMEDI_NI_LABPC) += ni_labpc.o +obj-$(CONFIG_COMEDI_NI_LABPC_ISADMA) += ni_labpc_isadma.o obj-$(CONFIG_COMEDI_8255) += 8255.o obj-$(CONFIG_COMEDI_AMPLC_DIO200) += amplc_dio200_common.o diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c index 65ab8f6c5b69b..d1d22a19f022a 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.c +++ b/drivers/staging/comedi/drivers/ni_labpc.c @@ -71,6 +71,7 @@ #include "8255.h" #include "comedi_fc.h" #include "ni_labpc.h" +#include "ni_labpc_isadma.h" /* * Register map (all registers are 8-bit) diff --git a/drivers/staging/comedi/drivers/ni_labpc_isadma.c b/drivers/staging/comedi/drivers/ni_labpc_isadma.c new file mode 100644 index 0000000000000..586ea54b8d79b --- /dev/null +++ b/drivers/staging/comedi/drivers/ni_labpc_isadma.c @@ -0,0 +1,37 @@ +/* + * comedi/drivers/ni_labpc_isadma.c + * ISA DMA support for National Instruments Lab-PC series boards and + * compatibles. + * + * Extracted from ni_labpc.c: + * Copyright (C) 2001-2003 Frank Mori Hess + * + * 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 the License, or + * (at your option) any later version. + * + * 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. + */ + +#include + +#include "ni_labpc_isadma.h" + +static int __init ni_labpc_isadma_init_module(void) +{ + return 0; +} +module_init(ni_labpc_isadma_init_module); + +static void __exit ni_labpc_isadma_cleanup_module(void) +{ +} +module_exit(ni_labpc_isadma_cleanup_module); + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi NI Lab-PC ISA DMA support"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/ni_labpc_isadma.h b/drivers/staging/comedi/drivers/ni_labpc_isadma.h new file mode 100644 index 0000000000000..ac644f0d9fc95 --- /dev/null +++ b/drivers/staging/comedi/drivers/ni_labpc_isadma.h @@ -0,0 +1,16 @@ +/* + * ni_labpc ISA DMA support. +*/ + +#ifndef _NI_LABPC_ISADMA_H +#define _NI_LABPC_ISADMA_H + +#define NI_LABPC_HAVE_ISA_DMA IS_ENABLED(CONFIG_COMEDI_NI_LABPC_ISADMA) + +#if NI_LABPC_HAVE_ISA_DMA + +#else + +#endif + +#endif /* _NI_LABPC_ISADMA_H */ -- GitLab From 86aff4bb11eb721b9be40dcd51f7571fb00edcde Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 28 Jun 2013 17:09:20 +0100 Subject: [PATCH 077/942] staging: comedi: ni_labpc: migrate DMA channel init & free Migrate the code for requesting an ISA DMA channel and a DMA buffer, and the code for freeing them into two new functions in the "ni_labpc_isadma" module: `labpc_init_dma_chan()` and `labpc_free_dma_chan()`. Dummy inline functions are provided in "ni_labpc_isadma.h" if the "ni_labpc_isadma" module is not being built. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_labpc.c | 35 ++---------- .../staging/comedi/drivers/ni_labpc_isadma.c | 54 +++++++++++++++++++ .../staging/comedi/drivers/ni_labpc_isadma.h | 13 +++++ 3 files changed, 72 insertions(+), 30 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c index d1d22a19f022a..ab1773e1fbccb 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.c +++ b/drivers/staging/comedi/drivers/ni_labpc.c @@ -1708,31 +1708,8 @@ static int labpc_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (ret) return ret; -#ifdef CONFIG_ISA_DMA_API - if (dev->irq && (dma_chan == 1 || dma_chan == 3)) { - void *dma_buffer = kmalloc(dma_buffer_size, - GFP_KERNEL | GFP_DMA); - - if (dma_buffer) { - ret = request_dma(dma_chan, dev->board_name); - if (ret == 0) { - unsigned long dma_flags; - - devpriv->dma_buffer = dma_buffer; - devpriv->dma_chan = dma_chan; - devpriv->dma_addr = - virt_to_bus(devpriv->dma_buffer); - - dma_flags = claim_dma_lock(); - disable_dma(devpriv->dma_chan); - set_dma_mode(devpriv->dma_chan, DMA_MODE_READ); - release_dma_lock(dma_flags); - } else { - kfree(dma_buffer); - } - } - } -#endif + if (dev->irq) + labpc_init_dma_chan(dev, dma_chan); return 0; } @@ -1741,11 +1718,9 @@ static void labpc_detach(struct comedi_device *dev) { struct labpc_private *devpriv = dev->private; - if (devpriv) { - kfree(devpriv->dma_buffer); - if (devpriv->dma_chan) - free_dma(devpriv->dma_chan); - } + if (devpriv) + labpc_free_dma_chan(dev); + comedi_legacy_detach(dev); } diff --git a/drivers/staging/comedi/drivers/ni_labpc_isadma.c b/drivers/staging/comedi/drivers/ni_labpc_isadma.c index 586ea54b8d79b..e6c8437f573c7 100644 --- a/drivers/staging/comedi/drivers/ni_labpc_isadma.c +++ b/drivers/staging/comedi/drivers/ni_labpc_isadma.c @@ -18,9 +18,63 @@ */ #include +#include +#include "../comedidev.h" +#include + +#include "ni_labpc.h" #include "ni_labpc_isadma.h" +/* size in bytes of dma buffer */ +static const int dma_buffer_size = 0xff00; + +int labpc_init_dma_chan(struct comedi_device *dev, unsigned int dma_chan) +{ + struct labpc_private *devpriv = dev->private; + void *dma_buffer; + unsigned long dma_flags; + int ret; + + if (dma_chan != 1 && dma_chan != 3) + return -EINVAL; + + dma_buffer = kmalloc(dma_buffer_size, GFP_KERNEL | GFP_DMA); + if (!dma_buffer) + return -ENOMEM; + + ret = request_dma(dma_chan, dev->board_name); + if (ret) { + kfree(dma_buffer); + return ret; + } + + devpriv->dma_buffer = dma_buffer; + devpriv->dma_chan = dma_chan; + devpriv->dma_addr = virt_to_bus(devpriv->dma_buffer); + + dma_flags = claim_dma_lock(); + disable_dma(devpriv->dma_chan); + set_dma_mode(devpriv->dma_chan, DMA_MODE_READ); + release_dma_lock(dma_flags); + + return 0; +} +EXPORT_SYMBOL_GPL(labpc_init_dma_chan); + +void labpc_free_dma_chan(struct comedi_device *dev) +{ + struct labpc_private *devpriv = dev->private; + + kfree(devpriv->dma_buffer); + devpriv->dma_buffer = NULL; + if (devpriv->dma_chan) { + free_dma(devpriv->dma_chan); + devpriv->dma_chan = 0; + } +} +EXPORT_SYMBOL_GPL(labpc_free_dma_chan); + static int __init ni_labpc_isadma_init_module(void) { return 0; diff --git a/drivers/staging/comedi/drivers/ni_labpc_isadma.h b/drivers/staging/comedi/drivers/ni_labpc_isadma.h index ac644f0d9fc95..144f4bafdbd1b 100644 --- a/drivers/staging/comedi/drivers/ni_labpc_isadma.h +++ b/drivers/staging/comedi/drivers/ni_labpc_isadma.h @@ -9,8 +9,21 @@ #if NI_LABPC_HAVE_ISA_DMA +int labpc_init_dma_chan(struct comedi_device *dev, unsigned int dma_chan); +void labpc_free_dma_chan(struct comedi_device *dev); + #else +static inline int labpc_init_dma_chan(struct comedi_device *dev, + unsigned int dma_chan) +{ + return -ENOTSUPP; +} + +static inline void labpc_free_dma_chan(struct comedi_device *dev) +{ +} + #endif #endif /* _NI_LABPC_ISADMA_H */ -- GitLab From c6208c2f358056d77544024373e9d73dd899a384 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 28 Jun 2013 17:09:21 +0100 Subject: [PATCH 078/942] staging: comedi: ni_labpc_isadma: add labpc_have_dma_chan() Add a static inline function to "ni_labpc_isadma.h" to test if a DMA channel has been set-up, in which case `devpriv->dma_chan` will be non-zero (where `devpriv` point to the private data for the comedi device). If the "ni_labpc_isadma" module is not being built, don't bother checking `devpriv->dma_chan`; just return `false` as this may help the compiler to optimize out some unreachable code. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_labpc_isadma.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/staging/comedi/drivers/ni_labpc_isadma.h b/drivers/staging/comedi/drivers/ni_labpc_isadma.h index 144f4bafdbd1b..3b022ea6b564c 100644 --- a/drivers/staging/comedi/drivers/ni_labpc_isadma.h +++ b/drivers/staging/comedi/drivers/ni_labpc_isadma.h @@ -9,11 +9,23 @@ #if NI_LABPC_HAVE_ISA_DMA +static inline bool labpc_have_dma_chan(struct comedi_device *dev) +{ + struct labpc_private *devpriv = dev->private; + + return (bool)devpriv->dma_chan; +} + int labpc_init_dma_chan(struct comedi_device *dev, unsigned int dma_chan); void labpc_free_dma_chan(struct comedi_device *dev); #else +static inline bool labpc_have_dma_chan(struct comedi_device *dev) +{ + return false; +} + static inline int labpc_init_dma_chan(struct comedi_device *dev, unsigned int dma_chan) { -- GitLab From 5c8a138e9d33df4960e3cb497c60723c7fbdacf9 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 28 Jun 2013 17:09:22 +0100 Subject: [PATCH 079/942] staging: comedi: ni_labpc: use labpc_have_dma_chan() Call the new static inline function `labpc_have_dma_chan()` from `labpc_ai_cmd()` to check if the ISA DMA channel has been initialized, tidying up the surrounding code and removing an `#ifdef`. If the "ni_labpc_isadma" module is not being built, `labpc_have_dma_chan()` doesn't bother checking the DMA channel and just returns `false`, allowing the compiler to optimize out a small amount of code. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_labpc.c | 29 ++++++++++------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c index ab1773e1fbccb..1f0f7f5382151 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.c +++ b/drivers/staging/comedi/drivers/ni_labpc.c @@ -871,25 +871,20 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) return ret; } -#ifdef CONFIG_ISA_DMA_API - /* figure out what method we will use to transfer data */ - if (devpriv->dma_chan && /* need a dma channel allocated */ - /* - * dma unsafe at RT priority, - * and too much setup time for TRIG_WAKE_EOS for - */ - (cmd->flags & (TRIG_WAKE_EOS | TRIG_RT)) == 0) { + /* figure out what method we will use to transfer data */ + if (labpc_have_dma_chan(dev) && + /* dma unsafe at RT priority, + * and too much setup time for TRIG_WAKE_EOS */ + (cmd->flags & (TRIG_WAKE_EOS | TRIG_RT)) == 0) xfer = isa_dma_transfer; - /* pc-plus has no fifo-half full interrupt */ - } else -#endif - if (board->is_labpc1200 && - /* wake-end-of-scan should interrupt on fifo not empty */ - (cmd->flags & TRIG_WAKE_EOS) == 0 && - /* make sure we are taking more than just a few points */ - (cmd->stop_src != TRIG_COUNT || devpriv->count > 256)) { + else if (/* pc-plus has no fifo-half full interrupt */ + board->is_labpc1200 && + /* wake-end-of-scan should interrupt on fifo not empty */ + (cmd->flags & TRIG_WAKE_EOS) == 0 && + /* make sure we are taking more than just a few points */ + (cmd->stop_src != TRIG_COUNT || devpriv->count > 256)) xfer = fifo_half_full_transfer; - } else + else xfer = fifo_not_empty_transfer; devpriv->current_transfer = xfer; -- GitLab From 50787fa99d80e86c9a22b7af16fd9827f733f3ab Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 28 Jun 2013 17:09:23 +0100 Subject: [PATCH 080/942] staging: comedi: ni_labpc: move register defs to new file The new "ni_labpc_isadma" module will need to access some register definitions from "ni_labpc.c", which is not part of the module's source. Move all the register definitions into a new, common header file "ni_labpc_regs.h". Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_labpc.c | 68 +---------------- .../staging/comedi/drivers/ni_labpc_isadma.c | 1 + .../staging/comedi/drivers/ni_labpc_regs.h | 75 +++++++++++++++++++ 3 files changed, 77 insertions(+), 67 deletions(-) create mode 100644 drivers/staging/comedi/drivers/ni_labpc_regs.h diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c index 1f0f7f5382151..dd858d58a93ee 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.c +++ b/drivers/staging/comedi/drivers/ni_labpc.c @@ -71,75 +71,9 @@ #include "8255.h" #include "comedi_fc.h" #include "ni_labpc.h" +#include "ni_labpc_regs.h" #include "ni_labpc_isadma.h" -/* - * Register map (all registers are 8-bit) - */ -#define STAT1_REG 0x00 /* R: Status 1 reg */ -#define STAT1_DAVAIL (1 << 0) -#define STAT1_OVERRUN (1 << 1) -#define STAT1_OVERFLOW (1 << 2) -#define STAT1_CNTINT (1 << 3) -#define STAT1_GATA0 (1 << 5) -#define STAT1_EXTGATA0 (1 << 6) -#define CMD1_REG 0x00 /* W: Command 1 reg */ -#define CMD1_MA(x) (((x) & 0x7) << 0) -#define CMD1_TWOSCMP (1 << 3) -#define CMD1_GAIN(x) (((x) & 0x7) << 4) -#define CMD1_SCANEN (1 << 7) -#define CMD2_REG 0x01 /* W: Command 2 reg */ -#define CMD2_PRETRIG (1 << 0) -#define CMD2_HWTRIG (1 << 1) -#define CMD2_SWTRIG (1 << 2) -#define CMD2_TBSEL (1 << 3) -#define CMD2_2SDAC0 (1 << 4) -#define CMD2_2SDAC1 (1 << 5) -#define CMD2_LDAC(x) (1 << (6 + (x))) -#define CMD3_REG 0x02 /* W: Command 3 reg */ -#define CMD3_DMAEN (1 << 0) -#define CMD3_DIOINTEN (1 << 1) -#define CMD3_DMATCINTEN (1 << 2) -#define CMD3_CNTINTEN (1 << 3) -#define CMD3_ERRINTEN (1 << 4) -#define CMD3_FIFOINTEN (1 << 5) -#define ADC_START_CONVERT_REG 0x03 /* W: Start Convert reg */ -#define DAC_LSB_REG(x) (0x04 + 2 * (x)) /* W: DAC0/1 LSB reg */ -#define DAC_MSB_REG(x) (0x05 + 2 * (x)) /* W: DAC0/1 MSB reg */ -#define ADC_FIFO_CLEAR_REG 0x08 /* W: A/D FIFO Clear reg */ -#define ADC_FIFO_REG 0x0a /* R: A/D FIFO reg */ -#define DMATC_CLEAR_REG 0x0a /* W: DMA Interrupt Clear reg */ -#define TIMER_CLEAR_REG 0x0c /* W: Timer Interrupt Clear reg */ -#define CMD6_REG 0x0e /* W: Command 6 reg */ -#define CMD6_NRSE (1 << 0) -#define CMD6_ADCUNI (1 << 1) -#define CMD6_DACUNI(x) (1 << (2 + (x))) -#define CMD6_HFINTEN (1 << 5) -#define CMD6_DQINTEN (1 << 6) -#define CMD6_SCANUP (1 << 7) -#define CMD4_REG 0x0f /* W: Command 3 reg */ -#define CMD4_INTSCAN (1 << 0) -#define CMD4_EOIRCV (1 << 1) -#define CMD4_ECLKDRV (1 << 2) -#define CMD4_SEDIFF (1 << 3) -#define CMD4_ECLKRCV (1 << 4) -#define DIO_BASE_REG 0x10 /* R/W: 8255 DIO base reg */ -#define COUNTER_A_BASE_REG 0x14 /* R/W: 8253 Counter A base reg */ -#define COUNTER_B_BASE_REG 0x18 /* R/W: 8253 Counter B base reg */ -#define CMD5_REG 0x1c /* W: Command 5 reg */ -#define CMD5_WRTPRT (1 << 2) -#define CMD5_DITHEREN (1 << 3) -#define CMD5_CALDACLD (1 << 4) -#define CMD5_SCLK (1 << 5) -#define CMD5_SDATA (1 << 6) -#define CMD5_EEPROMCS (1 << 7) -#define STAT2_REG 0x1d /* R: Status 2 reg */ -#define STAT2_PROMOUT (1 << 0) -#define STAT2_OUTA1 (1 << 1) -#define STAT2_FIFONHF (1 << 2) -#define INTERVAL_COUNT_REG 0x1e /* W: Interval Counter Data reg */ -#define INTERVAL_STROBE_REG 0x1f /* W: Interval Counter Strobe reg */ - #define LABPC_SIZE 0x20 /* size of ISA io region */ #define LABPC_TIMER_BASE 500 /* 2 MHz master clock */ #define LABPC_ADC_TIMEOUT 1000 diff --git a/drivers/staging/comedi/drivers/ni_labpc_isadma.c b/drivers/staging/comedi/drivers/ni_labpc_isadma.c index e6c8437f573c7..a05297421bd12 100644 --- a/drivers/staging/comedi/drivers/ni_labpc_isadma.c +++ b/drivers/staging/comedi/drivers/ni_labpc_isadma.c @@ -24,6 +24,7 @@ #include #include "ni_labpc.h" +#include "ni_labpc_regs.h" #include "ni_labpc_isadma.h" /* size in bytes of dma buffer */ diff --git a/drivers/staging/comedi/drivers/ni_labpc_regs.h b/drivers/staging/comedi/drivers/ni_labpc_regs.h new file mode 100644 index 0000000000000..2a274a3e4e734 --- /dev/null +++ b/drivers/staging/comedi/drivers/ni_labpc_regs.h @@ -0,0 +1,75 @@ +/* + * ni_labpc register definitions. +*/ + +#ifndef _NI_LABPC_REGS_H +#define _NI_LABPC_REGS_H + +/* + * Register map (all registers are 8-bit) + */ +#define STAT1_REG 0x00 /* R: Status 1 reg */ +#define STAT1_DAVAIL (1 << 0) +#define STAT1_OVERRUN (1 << 1) +#define STAT1_OVERFLOW (1 << 2) +#define STAT1_CNTINT (1 << 3) +#define STAT1_GATA0 (1 << 5) +#define STAT1_EXTGATA0 (1 << 6) +#define CMD1_REG 0x00 /* W: Command 1 reg */ +#define CMD1_MA(x) (((x) & 0x7) << 0) +#define CMD1_TWOSCMP (1 << 3) +#define CMD1_GAIN(x) (((x) & 0x7) << 4) +#define CMD1_SCANEN (1 << 7) +#define CMD2_REG 0x01 /* W: Command 2 reg */ +#define CMD2_PRETRIG (1 << 0) +#define CMD2_HWTRIG (1 << 1) +#define CMD2_SWTRIG (1 << 2) +#define CMD2_TBSEL (1 << 3) +#define CMD2_2SDAC0 (1 << 4) +#define CMD2_2SDAC1 (1 << 5) +#define CMD2_LDAC(x) (1 << (6 + (x))) +#define CMD3_REG 0x02 /* W: Command 3 reg */ +#define CMD3_DMAEN (1 << 0) +#define CMD3_DIOINTEN (1 << 1) +#define CMD3_DMATCINTEN (1 << 2) +#define CMD3_CNTINTEN (1 << 3) +#define CMD3_ERRINTEN (1 << 4) +#define CMD3_FIFOINTEN (1 << 5) +#define ADC_START_CONVERT_REG 0x03 /* W: Start Convert reg */ +#define DAC_LSB_REG(x) (0x04 + 2 * (x)) /* W: DAC0/1 LSB reg */ +#define DAC_MSB_REG(x) (0x05 + 2 * (x)) /* W: DAC0/1 MSB reg */ +#define ADC_FIFO_CLEAR_REG 0x08 /* W: A/D FIFO Clear reg */ +#define ADC_FIFO_REG 0x0a /* R: A/D FIFO reg */ +#define DMATC_CLEAR_REG 0x0a /* W: DMA Interrupt Clear reg */ +#define TIMER_CLEAR_REG 0x0c /* W: Timer Interrupt Clear reg */ +#define CMD6_REG 0x0e /* W: Command 6 reg */ +#define CMD6_NRSE (1 << 0) +#define CMD6_ADCUNI (1 << 1) +#define CMD6_DACUNI(x) (1 << (2 + (x))) +#define CMD6_HFINTEN (1 << 5) +#define CMD6_DQINTEN (1 << 6) +#define CMD6_SCANUP (1 << 7) +#define CMD4_REG 0x0f /* W: Command 3 reg */ +#define CMD4_INTSCAN (1 << 0) +#define CMD4_EOIRCV (1 << 1) +#define CMD4_ECLKDRV (1 << 2) +#define CMD4_SEDIFF (1 << 3) +#define CMD4_ECLKRCV (1 << 4) +#define DIO_BASE_REG 0x10 /* R/W: 8255 DIO base reg */ +#define COUNTER_A_BASE_REG 0x14 /* R/W: 8253 Counter A base reg */ +#define COUNTER_B_BASE_REG 0x18 /* R/W: 8253 Counter B base reg */ +#define CMD5_REG 0x1c /* W: Command 5 reg */ +#define CMD5_WRTPRT (1 << 2) +#define CMD5_DITHEREN (1 << 3) +#define CMD5_CALDACLD (1 << 4) +#define CMD5_SCLK (1 << 5) +#define CMD5_SDATA (1 << 6) +#define CMD5_EEPROMCS (1 << 7) +#define STAT2_REG 0x1d /* R: Status 2 reg */ +#define STAT2_PROMOUT (1 << 0) +#define STAT2_OUTA1 (1 << 1) +#define STAT2_FIFONHF (1 << 2) +#define INTERVAL_COUNT_REG 0x1e /* W: Interval Counter Data reg */ +#define INTERVAL_STROBE_REG 0x1f /* W: Interval Counter Strobe reg */ + +#endif /* _NI_LABPC_REGS_H */ -- GitLab From 88dd0c0a8016d6d80ed47eb306c5b41e8af0f83a Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 28 Jun 2013 17:09:24 +0100 Subject: [PATCH 081/942] staging: comedi: ni_labpc: migrate DMA transfer set-up Migrate the code for setting up an ISA DMA transfer into a new function `labpc_setup_dma()` in the "ni_labpc_isadma" module. Provide a dummy inline function in "ni_labpc_isadma.h" if the "ni_labpc_isadma" module is not being built. The static function `labpc_suggest_transfer_size()` also needs to move across to the new module. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_labpc.c | 53 +------------------ .../staging/comedi/drivers/ni_labpc_isadma.c | 51 ++++++++++++++++++ .../staging/comedi/drivers/ni_labpc_isadma.h | 6 +++ 3 files changed, 59 insertions(+), 51 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c index dd858d58a93ee..e1b073f746fe0 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.c +++ b/drivers/staging/comedi/drivers/ni_labpc.c @@ -387,32 +387,6 @@ static int labpc_ai_insn_read(struct comedi_device *dev, return insn->n; } -#ifdef CONFIG_ISA_DMA_API -/* utility function that suggests a dma transfer size in bytes */ -static unsigned int labpc_suggest_transfer_size(const struct comedi_cmd *cmd) -{ - unsigned int size; - unsigned int freq; - - if (cmd->convert_src == TRIG_TIMER) - freq = 1000000000 / cmd->convert_arg; - /* return some default value */ - else - freq = 0xffffffff; - - /* make buffer fill in no more than 1/3 second */ - size = (freq / 3) * sample_size; - - /* set a minimum and maximum size allowed */ - if (size > dma_buffer_size) - size = dma_buffer_size - dma_buffer_size % sample_size; - else if (size < sample_size) - size = sample_size; - - return size; -} -#endif - static bool labpc_use_continuous_mode(const struct comedi_cmd *cmd, enum scan_mode mode) { @@ -883,31 +857,8 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) labpc_clear_adc_fifo(dev); -#ifdef CONFIG_ISA_DMA_API - /* set up dma transfer */ - if (xfer == isa_dma_transfer) { - unsigned long irq_flags; - - irq_flags = claim_dma_lock(); - disable_dma(devpriv->dma_chan); - /* clear flip-flop to make sure 2-byte registers for - * count and address get set correctly */ - clear_dma_ff(devpriv->dma_chan); - set_dma_addr(devpriv->dma_chan, devpriv->dma_addr); - /* set appropriate size of transfer */ - devpriv->dma_transfer_size = labpc_suggest_transfer_size(cmd); - if (cmd->stop_src == TRIG_COUNT && - devpriv->count * sample_size < devpriv->dma_transfer_size) { - devpriv->dma_transfer_size = - devpriv->count * sample_size; - } - set_dma_count(devpriv->dma_chan, devpriv->dma_transfer_size); - enable_dma(devpriv->dma_chan); - release_dma_lock(irq_flags); - /* enable board's dma */ - devpriv->cmd3 |= (CMD3_DMAEN | CMD3_DMATCINTEN); - } -#endif + if (xfer == isa_dma_transfer) + labpc_setup_dma(dev, s); /* enable error interrupts */ devpriv->cmd3 |= CMD3_ERRINTEN; diff --git a/drivers/staging/comedi/drivers/ni_labpc_isadma.c b/drivers/staging/comedi/drivers/ni_labpc_isadma.c index a05297421bd12..dba2be36c48d7 100644 --- a/drivers/staging/comedi/drivers/ni_labpc_isadma.c +++ b/drivers/staging/comedi/drivers/ni_labpc_isadma.c @@ -29,6 +29,57 @@ /* size in bytes of dma buffer */ static const int dma_buffer_size = 0xff00; +/* 2 bytes per sample */ +static const int sample_size = 2; + +/* utility function that suggests a dma transfer size in bytes */ +static unsigned int labpc_suggest_transfer_size(const struct comedi_cmd *cmd) +{ + unsigned int size; + unsigned int freq; + + if (cmd->convert_src == TRIG_TIMER) + freq = 1000000000 / cmd->convert_arg; + else + /* return some default value */ + freq = 0xffffffff; + + /* make buffer fill in no more than 1/3 second */ + size = (freq / 3) * sample_size; + + /* set a minimum and maximum size allowed */ + if (size > dma_buffer_size) + size = dma_buffer_size - dma_buffer_size % sample_size; + else if (size < sample_size) + size = sample_size; + + return size; +} + +void labpc_setup_dma(struct comedi_device *dev, struct comedi_subdevice *s) +{ + struct labpc_private *devpriv = dev->private; + struct comedi_cmd *cmd = &s->async->cmd; + unsigned long irq_flags; + + irq_flags = claim_dma_lock(); + disable_dma(devpriv->dma_chan); + /* clear flip-flop to make sure 2-byte registers for + * count and address get set correctly */ + clear_dma_ff(devpriv->dma_chan); + set_dma_addr(devpriv->dma_chan, devpriv->dma_addr); + /* set appropriate size of transfer */ + devpriv->dma_transfer_size = labpc_suggest_transfer_size(cmd); + if (cmd->stop_src == TRIG_COUNT && + devpriv->count * sample_size < devpriv->dma_transfer_size) + devpriv->dma_transfer_size = devpriv->count * sample_size; + set_dma_count(devpriv->dma_chan, devpriv->dma_transfer_size); + enable_dma(devpriv->dma_chan); + release_dma_lock(irq_flags); + /* set CMD3 bits for caller to enable DMA and interrupt */ + devpriv->cmd3 |= (CMD3_DMAEN | CMD3_DMATCINTEN); +} +EXPORT_SYMBOL_GPL(labpc_setup_dma); int labpc_init_dma_chan(struct comedi_device *dev, unsigned int dma_chan) { diff --git a/drivers/staging/comedi/drivers/ni_labpc_isadma.h b/drivers/staging/comedi/drivers/ni_labpc_isadma.h index 3b022ea6b564c..c721f57daf0c2 100644 --- a/drivers/staging/comedi/drivers/ni_labpc_isadma.h +++ b/drivers/staging/comedi/drivers/ni_labpc_isadma.h @@ -18,6 +18,7 @@ static inline bool labpc_have_dma_chan(struct comedi_device *dev) int labpc_init_dma_chan(struct comedi_device *dev, unsigned int dma_chan); void labpc_free_dma_chan(struct comedi_device *dev); +void labpc_setup_dma(struct comedi_device *dev, struct comedi_subdevice *s); #else @@ -36,6 +37,11 @@ static inline void labpc_free_dma_chan(struct comedi_device *dev) { } +static inline void labpc_setup_dma(struct comedi_device *dev, + struct comedi_subdevice *s) +{ +} + #endif #endif /* _NI_LABPC_ISADMA_H */ -- GitLab From f88e8e09880d4abe3cad98ec8889e0f46eb89e4d Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 28 Jun 2013 17:09:25 +0100 Subject: [PATCH 082/942] staging: comedi: ni_labpc: migrate labpc_drain_dma() Move `labpc_drain_dma()` into the "ni_labpc_isadma" module. Provide a dummy inline function in "ni_labpc_isadma.h" if the module is not being built. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_labpc.c | 56 ------------------- .../staging/comedi/drivers/ni_labpc_isadma.c | 56 +++++++++++++++++++ .../staging/comedi/drivers/ni_labpc_isadma.h | 5 ++ 3 files changed, 61 insertions(+), 56 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c index e1b073f746fe0..818a8abe208ca 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.c +++ b/drivers/staging/comedi/drivers/ni_labpc.c @@ -906,60 +906,6 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) } #ifdef CONFIG_ISA_DMA_API -static void labpc_drain_dma(struct comedi_device *dev) -{ - struct labpc_private *devpriv = dev->private; - struct comedi_subdevice *s = dev->read_subdev; - struct comedi_async *async = s->async; - int status; - unsigned long flags; - unsigned int max_points, num_points, residue, leftover; - int i; - - status = devpriv->stat1; - - flags = claim_dma_lock(); - disable_dma(devpriv->dma_chan); - /* clear flip-flop to make sure 2-byte registers for - * count and address get set correctly */ - clear_dma_ff(devpriv->dma_chan); - - /* figure out how many points to read */ - max_points = devpriv->dma_transfer_size / sample_size; - /* residue is the number of points left to be done on the dma - * transfer. It should always be zero at this point unless - * the stop_src is set to external triggering. - */ - residue = get_dma_residue(devpriv->dma_chan) / sample_size; - num_points = max_points - residue; - if (devpriv->count < num_points && async->cmd.stop_src == TRIG_COUNT) - num_points = devpriv->count; - - /* figure out how many points will be stored next time */ - leftover = 0; - if (async->cmd.stop_src != TRIG_COUNT) { - leftover = devpriv->dma_transfer_size / sample_size; - } else if (devpriv->count > num_points) { - leftover = devpriv->count - num_points; - if (leftover > max_points) - leftover = max_points; - } - - /* write data to comedi buffer */ - for (i = 0; i < num_points; i++) - cfc_write_to_buffer(s, devpriv->dma_buffer[i]); - - if (async->cmd.stop_src == TRIG_COUNT) - devpriv->count -= num_points; - - /* set address and count for next transfer */ - set_dma_addr(devpriv->dma_chan, devpriv->dma_addr); - set_dma_count(devpriv->dma_chan, leftover * sample_size); - release_dma_lock(flags); - - async->events |= COMEDI_CB_BLOCK; -} - static void handle_isa_dma(struct comedi_device *dev) { struct labpc_private *devpriv = dev->private; @@ -1009,12 +955,10 @@ static int labpc_drain_fifo(struct comedi_device *dev) * when acquisition is terminated by stop_src == TRIG_EXT). */ static void labpc_drain_dregs(struct comedi_device *dev) { -#ifdef CONFIG_ISA_DMA_API struct labpc_private *devpriv = dev->private; if (devpriv->current_transfer == isa_dma_transfer) labpc_drain_dma(dev); -#endif labpc_drain_fifo(dev); } diff --git a/drivers/staging/comedi/drivers/ni_labpc_isadma.c b/drivers/staging/comedi/drivers/ni_labpc_isadma.c index dba2be36c48d7..c4bfecc07b637 100644 --- a/drivers/staging/comedi/drivers/ni_labpc_isadma.c +++ b/drivers/staging/comedi/drivers/ni_labpc_isadma.c @@ -23,6 +23,7 @@ #include +#include "comedi_fc.h" #include "ni_labpc.h" #include "ni_labpc_regs.h" #include "ni_labpc_isadma.h" @@ -81,6 +82,61 @@ void labpc_setup_dma(struct comedi_device *dev, struct comedi_subdevice *s) } EXPORT_SYMBOL_GPL(labpc_setup_dma); +void labpc_drain_dma(struct comedi_device *dev) +{ + struct labpc_private *devpriv = dev->private; + struct comedi_subdevice *s = dev->read_subdev; + struct comedi_async *async = s->async; + int status; + unsigned long flags; + unsigned int max_points, num_points, residue, leftover; + int i; + + status = devpriv->stat1; + + flags = claim_dma_lock(); + disable_dma(devpriv->dma_chan); + /* clear flip-flop to make sure 2-byte registers for + * count and address get set correctly */ + clear_dma_ff(devpriv->dma_chan); + + /* figure out how many points to read */ + max_points = devpriv->dma_transfer_size / sample_size; + /* residue is the number of points left to be done on the dma + * transfer. It should always be zero at this point unless + * the stop_src is set to external triggering. + */ + residue = get_dma_residue(devpriv->dma_chan) / sample_size; + num_points = max_points - residue; + if (devpriv->count < num_points && async->cmd.stop_src == TRIG_COUNT) + num_points = devpriv->count; + + /* figure out how many points will be stored next time */ + leftover = 0; + if (async->cmd.stop_src != TRIG_COUNT) { + leftover = devpriv->dma_transfer_size / sample_size; + } else if (devpriv->count > num_points) { + leftover = devpriv->count - num_points; + if (leftover > max_points) + leftover = max_points; + } + + /* write data to comedi buffer */ + for (i = 0; i < num_points; i++) + cfc_write_to_buffer(s, devpriv->dma_buffer[i]); + + if (async->cmd.stop_src == TRIG_COUNT) + devpriv->count -= num_points; + + /* set address and count for next transfer */ + set_dma_addr(devpriv->dma_chan, devpriv->dma_addr); + set_dma_count(devpriv->dma_chan, leftover * sample_size); + release_dma_lock(flags); + + async->events |= COMEDI_CB_BLOCK; +} +EXPORT_SYMBOL_GPL(labpc_drain_dma); + int labpc_init_dma_chan(struct comedi_device *dev, unsigned int dma_chan) { struct labpc_private *devpriv = dev->private; diff --git a/drivers/staging/comedi/drivers/ni_labpc_isadma.h b/drivers/staging/comedi/drivers/ni_labpc_isadma.h index c721f57daf0c2..1f322f2bc2d9e 100644 --- a/drivers/staging/comedi/drivers/ni_labpc_isadma.h +++ b/drivers/staging/comedi/drivers/ni_labpc_isadma.h @@ -19,6 +19,7 @@ static inline bool labpc_have_dma_chan(struct comedi_device *dev) int labpc_init_dma_chan(struct comedi_device *dev, unsigned int dma_chan); void labpc_free_dma_chan(struct comedi_device *dev); void labpc_setup_dma(struct comedi_device *dev, struct comedi_subdevice *s); +void labpc_drain_dma(struct comedi_device *dev); #else @@ -42,6 +43,10 @@ static inline void labpc_setup_dma(struct comedi_device *dev, { } +static inline void labpc_drain_dma(struct comedi_device *dev) +{ +} + #endif #endif /* _NI_LABPC_ISADMA_H */ -- GitLab From 9bd53e0398f490707549455c00475af4923df872 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 28 Jun 2013 17:09:26 +0100 Subject: [PATCH 083/942] staging: comedi: ni_labpc: migrate DMA status handling Migrate the code for checking and handling the interrupt status handling for ISA DMA transfers into new a new function `labpc_handle_dma_status()` in the "ni_labpc_isadma" module. Provide a dummy inline function in "ni_labpc_isadma.h" if the "ni_labpc_isadma" module is not being built. The static function `handle_isa_dma()` also needs to move across to the new module. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_labpc.c | 29 ++----------------- .../staging/comedi/drivers/ni_labpc_isadma.c | 27 +++++++++++++++++ .../staging/comedi/drivers/ni_labpc_isadma.h | 5 ++++ 3 files changed, 35 insertions(+), 26 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c index 818a8abe208ca..57985a24dda46 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.c +++ b/drivers/staging/comedi/drivers/ni_labpc.c @@ -905,20 +905,6 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) return 0; } -#ifdef CONFIG_ISA_DMA_API -static void handle_isa_dma(struct comedi_device *dev) -{ - struct labpc_private *devpriv = dev->private; - - labpc_drain_dma(dev); - - enable_dma(devpriv->dma_chan); - - /* clear dma tc interrupt */ - devpriv->write_byte(0x1, dev->iobase + DMATC_CLEAR_REG); -} -#endif - /* read all available samples from ai fifo */ static int labpc_drain_fifo(struct comedi_device *dev) { @@ -1003,18 +989,9 @@ static irqreturn_t labpc_interrupt(int irq, void *d) return IRQ_HANDLED; } -#ifdef CONFIG_ISA_DMA_API - if (devpriv->current_transfer == isa_dma_transfer) { - /* - * if a dma terminal count of external stop trigger - * has occurred - */ - if (devpriv->stat1 & STAT1_GATA0 || - (board->is_labpc1200 && devpriv->stat2 & STAT2_OUTA1)) { - handle_isa_dma(dev); - } - } else -#endif + if (devpriv->current_transfer == isa_dma_transfer) + labpc_handle_dma_status(dev); + else labpc_drain_fifo(dev); if (devpriv->stat1 & STAT1_CNTINT) { diff --git a/drivers/staging/comedi/drivers/ni_labpc_isadma.c b/drivers/staging/comedi/drivers/ni_labpc_isadma.c index c4bfecc07b637..2149596830afd 100644 --- a/drivers/staging/comedi/drivers/ni_labpc_isadma.c +++ b/drivers/staging/comedi/drivers/ni_labpc_isadma.c @@ -137,6 +137,33 @@ void labpc_drain_dma(struct comedi_device *dev) } EXPORT_SYMBOL_GPL(labpc_drain_dma); +static void handle_isa_dma(struct comedi_device *dev) +{ + struct labpc_private *devpriv = dev->private; + + labpc_drain_dma(dev); + + enable_dma(devpriv->dma_chan); + + /* clear dma tc interrupt */ + devpriv->write_byte(0x1, dev->iobase + DMATC_CLEAR_REG); +} + +void labpc_handle_dma_status(struct comedi_device *dev) +{ + const struct labpc_boardinfo *board = comedi_board(dev); + struct labpc_private *devpriv = dev->private; + + /* + * if a dma terminal count of external stop trigger + * has occurred + */ + if (devpriv->stat1 & STAT1_GATA0 || + (board->is_labpc1200 && devpriv->stat2 & STAT2_OUTA1)) + handle_isa_dma(dev); +} +EXPORT_SYMBOL_GPL(labpc_handle_dma_status); + int labpc_init_dma_chan(struct comedi_device *dev, unsigned int dma_chan) { struct labpc_private *devpriv = dev->private; diff --git a/drivers/staging/comedi/drivers/ni_labpc_isadma.h b/drivers/staging/comedi/drivers/ni_labpc_isadma.h index 1f322f2bc2d9e..771af4bd5a762 100644 --- a/drivers/staging/comedi/drivers/ni_labpc_isadma.h +++ b/drivers/staging/comedi/drivers/ni_labpc_isadma.h @@ -20,6 +20,7 @@ int labpc_init_dma_chan(struct comedi_device *dev, unsigned int dma_chan); void labpc_free_dma_chan(struct comedi_device *dev); void labpc_setup_dma(struct comedi_device *dev, struct comedi_subdevice *s); void labpc_drain_dma(struct comedi_device *dev); +void labpc_handle_dma_status(struct comedi_device *dev); #else @@ -47,6 +48,10 @@ static inline void labpc_drain_dma(struct comedi_device *dev) { } +static inline void labpc_handle_dma_status(struct comedi_device *dev) +{ +} + #endif #endif /* _NI_LABPC_ISADMA_H */ -- GitLab From 72f2baeb75ba2e6e3ffbfb64890438f576f1d931 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 28 Jun 2013 17:09:27 +0100 Subject: [PATCH 084/942] staging: comedi: ni_labpc: tidy up after DMA code migration After migrating the ISA DMA handling code to the "ni_labpc_isadma" module, get rid of an unneeded `#include` and a couple of unused static variables. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_labpc.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c index 57985a24dda46..1add114dc0bc9 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.c +++ b/drivers/staging/comedi/drivers/ni_labpc.c @@ -65,8 +65,6 @@ #include "../comedidev.h" -#include - #include "8253.h" #include "8255.h" #include "comedi_fc.h" @@ -175,11 +173,6 @@ static const struct labpc_boardinfo labpc_boards[] = { }; #endif -/* size in bytes of dma buffer */ -static const int dma_buffer_size = 0xff00; -/* 2 bytes per sample */ -static const int sample_size = 2; - static int labpc_counter_load(struct comedi_device *dev, unsigned long base_address, unsigned int counter_number, -- GitLab From 277bef860c1bdb631c4cae385838bddd65459c07 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 28 Jun 2013 17:09:28 +0100 Subject: [PATCH 085/942] staging: comedi: COMEDI_NI_LABPC_ISA no longer depends on VIRT_TO_BUS After migrating ISA DMA support from the "ni_labpc" module to the new "ni_labpc_isadma" module, the `COMEDI_NI_LABPC_ISA` configuration option no longer depends on `VIRT_TO_BUS`, so remove the dependency. (The new `COMEDI_NI_LABPC_ISADMA` option does depend on `VIRT_TO_BUS` but is not configured manually and is only selected automatically if the `VIRT_TO_BUS` and `ISA_DMA_API` options are set.) Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/Kconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index b6e8faa5d7771..01782fccbf2a6 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -493,7 +493,6 @@ config COMEDI_NI_LABPC_ISA tristate "NI Lab-PC and compatibles ISA support" select COMEDI_NI_LABPC select COMEDI_NI_LABPC_ISADMA if ISA_DMA_API && VIRT_TO_BUS - depends on VIRT_TO_BUS ---help--- Enable support for National Instruments Lab-PC and compatibles Lab-PC-1200, Lab-PC-1200AI, Lab-PC+. -- GitLab From 30f1e5a9abd5ea83a19e8efd71089d4204e21bd4 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Tue, 23 Jul 2013 13:44:59 +0100 Subject: [PATCH 086/942] staging: ozwpan: Remove extra debug logs. Remove unnecessary debug logs. Most of these logs print function name at the start of function, which are not really required. Signed-off-by: Joe Perches Signed-off-by: Rupesh Gujare Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozcdev.c | 2 -- drivers/staging/ozwpan/ozhcd.c | 28 ++++++++-------------------- 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/drivers/staging/ozwpan/ozcdev.c b/drivers/staging/ozwpan/ozcdev.c index 374fdc398641a..284c26da27be0 100644 --- a/drivers/staging/ozwpan/ozcdev.c +++ b/drivers/staging/ozwpan/ozcdev.c @@ -73,7 +73,6 @@ static void oz_cdev_release_ctx(struct oz_serial_ctx *ctx) static int oz_cdev_open(struct inode *inode, struct file *filp) { struct oz_cdev *dev; - oz_trace("oz_cdev_open()\n"); oz_trace("major = %d minor = %d\n", imajor(inode), iminor(inode)); dev = container_of(inode->i_cdev, struct oz_cdev, cdev); filp->private_data = dev; @@ -84,7 +83,6 @@ static int oz_cdev_open(struct inode *inode, struct file *filp) */ static int oz_cdev_release(struct inode *inode, struct file *filp) { - oz_trace("oz_cdev_release()\n"); return 0; } /*------------------------------------------------------------------------------ diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c index d68d63a2e683b..9d1bd4450b8e1 100644 --- a/drivers/staging/ozwpan/ozhcd.c +++ b/drivers/staging/ozwpan/ozhcd.c @@ -394,7 +394,6 @@ static void oz_complete_urb(struct usb_hcd *hcd, struct urb *urb, */ static void oz_ep_free(struct oz_port *port, struct oz_endpoint *ep) { - oz_trace("oz_ep_free()\n"); if (port) { struct list_head list; struct oz_hcd *ozhcd = port->ozhcd; @@ -631,7 +630,6 @@ void *oz_hcd_pd_arrived(void *hpd) void *hport = NULL; struct oz_hcd *ozhcd = NULL; struct oz_endpoint *ep; - oz_trace("oz_hcd_pd_arrived()\n"); ozhcd = oz_hcd_claim(); if (ozhcd == NULL) return NULL; @@ -691,7 +689,6 @@ void oz_hcd_pd_departed(void *hport) void *hpd; struct oz_endpoint *ep = NULL; - oz_trace("oz_hcd_pd_departed()\n"); if (port == NULL) { oz_trace("oz_hcd_pd_departed() port = 0\n"); return; @@ -1696,7 +1693,6 @@ static void oz_hcd_clear_orphanage(struct oz_hcd *ozhcd, int status) */ static int oz_hcd_start(struct usb_hcd *hcd) { - oz_trace("oz_hcd_start()\n"); hcd->power_budget = 200; hcd->state = HC_STATE_RUNNING; hcd->uses_new_polling = 1; @@ -1707,14 +1703,12 @@ static int oz_hcd_start(struct usb_hcd *hcd) */ static void oz_hcd_stop(struct usb_hcd *hcd) { - oz_trace("oz_hcd_stop()\n"); } /*------------------------------------------------------------------------------ * Context: unknown */ static void oz_hcd_shutdown(struct usb_hcd *hcd) { - oz_trace("oz_hcd_shutdown()\n"); } /*------------------------------------------------------------------------------ * Called to queue an urb for the device. @@ -1844,7 +1838,6 @@ static int oz_hcd_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) static void oz_hcd_endpoint_disable(struct usb_hcd *hcd, struct usb_host_endpoint *ep) { - oz_trace("oz_hcd_endpoint_disable\n"); } /*------------------------------------------------------------------------------ * Context: unknown @@ -1852,7 +1845,6 @@ static void oz_hcd_endpoint_disable(struct usb_hcd *hcd, static void oz_hcd_endpoint_reset(struct usb_hcd *hcd, struct usb_host_endpoint *ep) { - oz_trace("oz_hcd_endpoint_reset\n"); } /*------------------------------------------------------------------------------ * Context: unknown @@ -1872,7 +1864,6 @@ static int oz_hcd_hub_status_data(struct usb_hcd *hcd, char *buf) struct oz_hcd *ozhcd = oz_hcd_private(hcd); int i; - oz_trace2(OZ_TRACE_HUB, "oz_hcd_hub_status_data()\n"); buf[0] = 0; spin_lock_bh(&ozhcd->hcd_lock); @@ -1892,7 +1883,6 @@ static int oz_hcd_hub_status_data(struct usb_hcd *hcd, char *buf) static void oz_get_hub_descriptor(struct usb_hcd *hcd, struct usb_hub_descriptor *desc) { - oz_trace2(OZ_TRACE_HUB, "GetHubDescriptor\n"); memset(desc, 0, sizeof(*desc)); desc->bDescriptorType = 0x29; desc->bDescLength = 9; @@ -1911,7 +1901,7 @@ static int oz_set_port_feature(struct usb_hcd *hcd, u16 wvalue, u16 windex) struct oz_hcd *ozhcd = oz_hcd_private(hcd); unsigned set_bits = 0; unsigned clear_bits = 0; - oz_trace2(OZ_TRACE_HUB, "SetPortFeature\n"); + if ((port_id < 1) || (port_id > OZ_NB_PORTS)) return -EPIPE; port = &ozhcd->ports[port_id-1]; @@ -1986,7 +1976,7 @@ static int oz_clear_port_feature(struct usb_hcd *hcd, u16 wvalue, u16 windex) u8 port_id = (u8)windex; struct oz_hcd *ozhcd = oz_hcd_private(hcd); unsigned clear_bits = 0; - oz_trace2(OZ_TRACE_HUB, "ClearPortFeature\n"); + if ((port_id < 1) || (port_id > OZ_NB_PORTS)) return -EPIPE; port = &ozhcd->ports[port_id-1]; @@ -2074,7 +2064,7 @@ static int oz_hcd_hub_control(struct usb_hcd *hcd, u16 req_type, u16 wvalue, u16 windex, char *buf, u16 wlength) { int err = 0; - oz_trace2(OZ_TRACE_HUB, "oz_hcd_hub_control()\n"); + switch (req_type) { case ClearHubFeature: oz_trace2(OZ_TRACE_HUB, "ClearHubFeature: %d\n", req_type); @@ -2111,7 +2101,7 @@ static int oz_hcd_hub_control(struct usb_hcd *hcd, u16 req_type, u16 wvalue, static int oz_hcd_bus_suspend(struct usb_hcd *hcd) { struct oz_hcd *ozhcd; - oz_trace2(OZ_TRACE_HUB, "oz_hcd_hub_suspend()\n"); + ozhcd = oz_hcd_private(hcd); spin_lock_bh(&ozhcd->hcd_lock); hcd->state = HC_STATE_SUSPENDED; @@ -2125,7 +2115,7 @@ static int oz_hcd_bus_suspend(struct usb_hcd *hcd) static int oz_hcd_bus_resume(struct usb_hcd *hcd) { struct oz_hcd *ozhcd; - oz_trace2(OZ_TRACE_HUB, "oz_hcd_hub_resume()\n"); + ozhcd = oz_hcd_private(hcd); spin_lock_bh(&ozhcd->hcd_lock); ozhcd->flags &= ~OZ_HDC_F_SUSPENDED; @@ -2137,8 +2127,8 @@ static int oz_hcd_bus_resume(struct usb_hcd *hcd) */ static void oz_plat_shutdown(struct platform_device *dev) { - oz_trace("oz_plat_shutdown()\n"); } + /*------------------------------------------------------------------------------ * Context: process */ @@ -2148,7 +2138,7 @@ static int oz_plat_probe(struct platform_device *dev) int err; struct usb_hcd *hcd; struct oz_hcd *ozhcd; - oz_trace("oz_plat_probe()\n"); + hcd = usb_create_hcd(&g_oz_hc_drv, &dev->dev, dev_name(&dev->dev)); if (hcd == NULL) { oz_trace("Failed to created hcd object OK\n"); @@ -2188,7 +2178,7 @@ static int oz_plat_remove(struct platform_device *dev) { struct usb_hcd *hcd = platform_get_drvdata(dev); struct oz_hcd *ozhcd; - oz_trace("oz_plat_remove()\n"); + if (hcd == NULL) return -1; ozhcd = oz_hcd_private(hcd); @@ -2209,7 +2199,6 @@ static int oz_plat_remove(struct platform_device *dev) */ static int oz_plat_suspend(struct platform_device *dev, pm_message_t msg) { - oz_trace("oz_plat_suspend()\n"); return 0; } /*------------------------------------------------------------------------------ @@ -2217,7 +2206,6 @@ static int oz_plat_suspend(struct platform_device *dev, pm_message_t msg) */ static int oz_plat_resume(struct platform_device *dev) { - oz_trace("oz_plat_resume()\n"); return 0; } /*------------------------------------------------------------------------------ -- GitLab From f724b5843431aba591a01b6988a725689cd9ebb3 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Tue, 23 Jul 2013 13:45:00 +0100 Subject: [PATCH 087/942] staging: ozwpan: Replace oz_trace with oz_dbg Introduce new debug macros: oz_dbg, oz_cdev_dbg, oz_pd_dbg and then replace old oz_trace & oz_trace2 with new macro. Signed-off-by: Joe Perches Signed-off-by: Rupesh Gujare Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozcdev.c | 48 ++--- drivers/staging/ozwpan/ozdbg.h | 54 +++++ drivers/staging/ozwpan/ozeltbuf.c | 30 ++- drivers/staging/ozwpan/ozhcd.c | 261 ++++++++++++------------- drivers/staging/ozwpan/ozpd.c | 61 +++--- drivers/staging/ozwpan/ozproto.c | 56 +++--- drivers/staging/ozwpan/ozproto.h | 2 +- drivers/staging/ozwpan/ozurbparanoia.c | 9 +- drivers/staging/ozwpan/ozusbsvc.c | 21 +- drivers/staging/ozwpan/ozusbsvc1.c | 17 +- 10 files changed, 307 insertions(+), 252 deletions(-) create mode 100644 drivers/staging/ozwpan/ozdbg.h diff --git a/drivers/staging/ozwpan/ozcdev.c b/drivers/staging/ozwpan/ozcdev.c index 284c26da27be0..87c3131f5b9ff 100644 --- a/drivers/staging/ozwpan/ozcdev.c +++ b/drivers/staging/ozwpan/ozcdev.c @@ -12,6 +12,7 @@ #include #include #include "ozconfig.h" +#include "ozdbg.h" #include "ozprotocol.h" #include "oztrace.h" #include "ozappif.h" @@ -63,7 +64,7 @@ static struct oz_serial_ctx *oz_cdev_claim_ctx(struct oz_pd *pd) static void oz_cdev_release_ctx(struct oz_serial_ctx *ctx) { if (atomic_dec_and_test(&ctx->ref_count)) { - oz_trace("Dealloc serial context.\n"); + oz_dbg(ON, "Dealloc serial context\n"); kfree(ctx); } } @@ -72,9 +73,10 @@ static void oz_cdev_release_ctx(struct oz_serial_ctx *ctx) */ static int oz_cdev_open(struct inode *inode, struct file *filp) { - struct oz_cdev *dev; - oz_trace("major = %d minor = %d\n", imajor(inode), iminor(inode)); - dev = container_of(inode->i_cdev, struct oz_cdev, cdev); + struct oz_cdev *dev = container_of(inode->i_cdev, struct oz_cdev, cdev); + + oz_dbg(ON, "major = %d minor = %d\n", imajor(inode), iminor(inode)); + filp->private_data = dev; return 0; } @@ -249,7 +251,7 @@ static long oz_cdev_ioctl(struct file *filp, unsigned int cmd, switch (cmd) { case OZ_IOCTL_GET_PD_LIST: { struct oz_pd_list list; - oz_trace("OZ_IOCTL_GET_PD_LIST\n"); + oz_dbg(ON, "OZ_IOCTL_GET_PD_LIST\n"); memset(&list, 0, sizeof(list)); list.count = oz_get_pd_list(list.addr, OZ_MAX_PDS); if (copy_to_user((void __user *)arg, &list, @@ -259,7 +261,7 @@ static long oz_cdev_ioctl(struct file *filp, unsigned int cmd, break; case OZ_IOCTL_SET_ACTIVE_PD: { u8 addr[ETH_ALEN]; - oz_trace("OZ_IOCTL_SET_ACTIVE_PD\n"); + oz_dbg(ON, "OZ_IOCTL_SET_ACTIVE_PD\n"); if (copy_from_user(addr, (void __user *)arg, ETH_ALEN)) return -EFAULT; rc = oz_set_active_pd(addr); @@ -267,7 +269,7 @@ static long oz_cdev_ioctl(struct file *filp, unsigned int cmd, break; case OZ_IOCTL_GET_ACTIVE_PD: { u8 addr[ETH_ALEN]; - oz_trace("OZ_IOCTL_GET_ACTIVE_PD\n"); + oz_dbg(ON, "OZ_IOCTL_GET_ACTIVE_PD\n"); spin_lock_bh(&g_cdev.lock); memcpy(addr, g_cdev.active_addr, ETH_ALEN); spin_unlock_bh(&g_cdev.lock); @@ -300,7 +302,7 @@ static unsigned int oz_cdev_poll(struct file *filp, poll_table *wait) { unsigned int ret = 0; struct oz_cdev *dev = filp->private_data; - oz_trace("Poll called wait = %p\n", wait); + oz_dbg(ON, "Poll called wait = %p\n", wait); spin_lock_bh(&dev->lock); if (dev->active_pd) { struct oz_serial_ctx *ctx = oz_cdev_claim_ctx(dev->active_pd); @@ -337,8 +339,8 @@ int oz_cdev_register(void) err = alloc_chrdev_region(&g_cdev.devnum, 0, 1, "ozwpan"); if (err < 0) goto out3; - oz_trace("Alloc dev number %d:%d\n", MAJOR(g_cdev.devnum), - MINOR(g_cdev.devnum)); + oz_dbg(ON, "Alloc dev number %d:%d\n", + MAJOR(g_cdev.devnum), MINOR(g_cdev.devnum)); cdev_init(&g_cdev.cdev, &oz_fops); g_cdev.cdev.owner = THIS_MODULE; g_cdev.cdev.ops = &oz_fops; @@ -346,18 +348,18 @@ int oz_cdev_register(void) init_waitqueue_head(&g_cdev.rdq); err = cdev_add(&g_cdev.cdev, g_cdev.devnum, 1); if (err < 0) { - oz_trace("Failed to add cdev\n"); + oz_dbg(ON, "Failed to add cdev\n"); goto out2; } g_oz_class = class_create(THIS_MODULE, "ozmo_wpan"); if (IS_ERR(g_oz_class)) { - oz_trace("Failed to register ozmo_wpan class\n"); + oz_dbg(ON, "Failed to register ozmo_wpan class\n"); err = PTR_ERR(g_oz_class); goto out1; } dev = device_create(g_oz_class, NULL, g_cdev.devnum, NULL, "ozwpan"); if (IS_ERR(dev)) { - oz_trace("Failed to create sysfs entry for cdev\n"); + oz_dbg(ON, "Failed to create sysfs entry for cdev\n"); err = PTR_ERR(dev); goto out1; } @@ -405,7 +407,7 @@ int oz_cdev_start(struct oz_pd *pd, int resume) struct oz_serial_ctx *ctx; struct oz_serial_ctx *old_ctx; if (resume) { - oz_trace("Serial service resumed.\n"); + oz_dbg(ON, "Serial service resumed\n"); return 0; } ctx = kzalloc(sizeof(struct oz_serial_ctx), GFP_ATOMIC); @@ -427,10 +429,10 @@ int oz_cdev_start(struct oz_pd *pd, int resume) (memcmp(pd->mac_addr, g_cdev.active_addr, ETH_ALEN) == 0)) { oz_pd_get(pd); g_cdev.active_pd = pd; - oz_trace("Active PD arrived.\n"); + oz_dbg(ON, "Active PD arrived\n"); } spin_unlock(&g_cdev.lock); - oz_trace("Serial service started.\n"); + oz_dbg(ON, "Serial service started\n"); return 0; } /*------------------------------------------------------------------------------ @@ -440,7 +442,7 @@ void oz_cdev_stop(struct oz_pd *pd, int pause) { struct oz_serial_ctx *ctx; if (pause) { - oz_trace("Serial service paused.\n"); + oz_dbg(ON, "Serial service paused\n"); return; } spin_lock_bh(&pd->app_lock[OZ_APPID_SERIAL-1]); @@ -457,9 +459,9 @@ void oz_cdev_stop(struct oz_pd *pd, int pause) spin_unlock(&g_cdev.lock); if (pd) { oz_pd_put(pd); - oz_trace("Active PD departed.\n"); + oz_dbg(ON, "Active PD departed\n"); } - oz_trace("Serial service stopped.\n"); + oz_dbg(ON, "Serial service stopped\n"); } /*------------------------------------------------------------------------------ * Context: softirq-serialized @@ -476,7 +478,7 @@ void oz_cdev_rx(struct oz_pd *pd, struct oz_elt *elt) ctx = oz_cdev_claim_ctx(pd); if (ctx == NULL) { - oz_trace("Cannot claim serial context.\n"); + oz_dbg(ON, "Cannot claim serial context\n"); return; } @@ -486,8 +488,8 @@ void oz_cdev_rx(struct oz_pd *pd, struct oz_elt *elt) if (app_hdr->elt_seq_num != 0) { if (((ctx->rx_seq_num - app_hdr->elt_seq_num) & 0x80) == 0) { /* Reject duplicate element. */ - oz_trace("Duplicate element:%02x %02x\n", - app_hdr->elt_seq_num, ctx->rx_seq_num); + oz_dbg(ON, "Duplicate element:%02x %02x\n", + app_hdr->elt_seq_num, ctx->rx_seq_num); goto out; } } @@ -500,7 +502,7 @@ void oz_cdev_rx(struct oz_pd *pd, struct oz_elt *elt) if (space < 0) space += OZ_RD_BUF_SZ; if (len > space) { - oz_trace("Not enough space:%d %d\n", len, space); + oz_dbg(ON, "Not enough space:%d %d\n", len, space); len = space; } ix = ctx->rd_in; diff --git a/drivers/staging/ozwpan/ozdbg.h b/drivers/staging/ozwpan/ozdbg.h new file mode 100644 index 0000000000000..b86a2b7e01787 --- /dev/null +++ b/drivers/staging/ozwpan/ozdbg.h @@ -0,0 +1,54 @@ +/* ----------------------------------------------------------------------------- + * Copyright (c) 2011 Ozmo Inc + * Released under the GNU General Public License Version 2 (GPLv2). + * ---------------------------------------------------------------------------*/ + +#ifndef _OZDBG_H +#define _OZDBG_H + +#define OZ_WANT_DBG 0 +#define OZ_WANT_VERBOSE_DBG 1 + +#define OZ_DBG_ON 0x0 +#define OZ_DBG_STREAM 0x1 +#define OZ_DBG_URB 0x2 +#define OZ_DBG_CTRL_DETAIL 0x4 +#define OZ_DBG_HUB 0x8 +#define OZ_DBG_RX_FRAMES 0x10 +#define OZ_DBG_TX_FRAMES 0x20 + +#define OZ_DEFAULT_DBG_MASK \ + ( \ + /* OZ_DBG_STREAM | */ \ + /* OZ_DBG_URB | */ \ + /* OZ_DBG_CTRL_DETAIL | */ \ + OZ_DBG_HUB | \ + /* OZ_DBG_RX_FRAMES | */ \ + /* OZ_DBG_TX_FRAMES | */ \ + 0) + +extern unsigned int oz_dbg_mask; + +#define oz_want_dbg(mask) \ + ((OZ_WANT_DBG && (OZ_DBG_##mask == OZ_DBG_ON)) || \ + (OZ_WANT_VERBOSE_DBG && (OZ_DBG_##mask & oz_dbg_mask))) + +#define oz_dbg(mask, fmt, ...) \ +do { \ + if (oz_want_dbg(mask)) \ + pr_debug(fmt, ##__VA_ARGS__); \ +} while (0) + +#define oz_cdev_dbg(cdev, mask, fmt, ...) \ +do { \ + if (oz_want_dbg(mask)) \ + netdev_dbg((cdev)->dev, fmt, ##__VA_ARGS__); \ +} while (0) + +#define oz_pd_dbg(pd, mask, fmt, ...) \ +do { \ + if (oz_want_dbg(mask)) \ + pr_debug(fmt, ##__VA_ARGS__); \ +} while (0) + +#endif /* _OZDBG_H */ diff --git a/drivers/staging/ozwpan/ozeltbuf.c b/drivers/staging/ozwpan/ozeltbuf.c index ac90fc7f5441e..bf280aabe3837 100644 --- a/drivers/staging/ozwpan/ozeltbuf.c +++ b/drivers/staging/ozwpan/ozeltbuf.c @@ -7,10 +7,12 @@ #include #include #include "ozconfig.h" +#include "ozdbg.h" #include "ozprotocol.h" #include "ozeltbuf.h" #include "ozpd.h" #include "oztrace.h" + /*------------------------------------------------------------------------------ */ #define OZ_ELT_INFO_MAGIC_USED 0x35791057 @@ -72,8 +74,8 @@ struct oz_elt_info *oz_elt_info_alloc(struct oz_elt_buf *buf) buf->free_elts--; spin_unlock_bh(&buf->lock); if (ei->magic != OZ_ELT_INFO_MAGIC_FREE) { - oz_trace("oz_elt_info_alloc: ei with bad magic: 0x%x\n", - ei->magic); + oz_dbg(ON, "%s: ei with bad magic: 0x%x\n", + __func__, ei->magic); } } else { spin_unlock_bh(&buf->lock); @@ -104,9 +106,8 @@ void oz_elt_info_free(struct oz_elt_buf *buf, struct oz_elt_info *ei) buf->elt_pool = &ei->link; ei->magic = OZ_ELT_INFO_MAGIC_FREE; } else { - oz_trace("oz_elt_info_free: bad magic ei: %p" - " magic: 0x%x\n", - ei, ei->magic); + oz_dbg(ON, "%s: bad magic ei: %p magic: 0x%x\n", + __func__, ei, ei->magic); } } } @@ -132,7 +133,7 @@ int oz_elt_stream_create(struct oz_elt_buf *buf, u8 id, int max_buf_count) { struct oz_elt_stream *st; - oz_trace("oz_elt_stream_create(0x%x)\n", id); + oz_dbg(ON, "%s: (0x%x)\n", __func__, id); st = kzalloc(sizeof(struct oz_elt_stream), GFP_ATOMIC | __GFP_ZERO); if (st == NULL) @@ -152,7 +153,7 @@ int oz_elt_stream_delete(struct oz_elt_buf *buf, u8 id) { struct list_head *e; struct oz_elt_stream *st = NULL; - oz_trace("oz_elt_stream_delete(0x%x)\n", id); + oz_dbg(ON, "%s: (0x%x)\n", __func__, id); spin_lock_bh(&buf->lock); e = buf->stream_list.next; while (e != &buf->stream_list) { @@ -175,9 +176,8 @@ int oz_elt_stream_delete(struct oz_elt_buf *buf, u8 id) list_del_init(&ei->link); list_del_init(&ei->link_order); st->buf_count -= ei->length; - oz_trace2(OZ_TRACE_STREAM, "Stream down: %d %d %d\n", - st->buf_count, - ei->length, atomic_read(&st->ref_count)); + oz_dbg(STREAM, "Stream down: %d %d %d\n", + st->buf_count, ei->length, atomic_read(&st->ref_count)); oz_elt_stream_put(st); oz_elt_info_free(buf, ei); } @@ -196,7 +196,7 @@ void oz_elt_stream_get(struct oz_elt_stream *st) void oz_elt_stream_put(struct oz_elt_stream *st) { if (atomic_dec_and_test(&st->ref_count)) { - oz_trace("Stream destroyed\n"); + oz_dbg(ON, "Stream destroyed\n"); kfree(st); } } @@ -242,8 +242,7 @@ int oz_queue_elt_info(struct oz_elt_buf *buf, u8 isoc, u8 id, st->buf_count += ei->length; /* Add to list in stream. */ list_add_tail(&ei->link, &st->elt_list); - oz_trace2(OZ_TRACE_STREAM, "Stream up: %d %d\n", - st->buf_count, ei->length); + oz_dbg(STREAM, "Stream up: %d %d\n", st->buf_count, ei->length); /* Check if we have too much buffered for this stream. If so * start dropping elements until we are back in bounds. */ @@ -293,9 +292,8 @@ int oz_select_elts_for_tx(struct oz_elt_buf *buf, u8 isoc, unsigned *len, list_del(&ei->link_order); if (ei->stream) { ei->stream->buf_count -= ei->length; - oz_trace2(OZ_TRACE_STREAM, - "Stream down: %d %d\n", - ei->stream->buf_count, ei->length); + oz_dbg(STREAM, "Stream down: %d %d\n", + ei->stream->buf_count, ei->length); oz_elt_stream_put(ei->stream); ei->stream = NULL; } diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c index 9d1bd4450b8e1..fece2dab3ae99 100644 --- a/drivers/staging/ozwpan/ozhcd.c +++ b/drivers/staging/ozwpan/ozhcd.c @@ -31,6 +31,7 @@ #include #include "linux/usb/hcd.h" #include +#include "ozdbg.h" #include "ozconfig.h" #include "ozusbif.h" #include "oztrace.h" @@ -371,14 +372,13 @@ static void oz_complete_urb(struct usb_hcd *hcd, struct urb *urb, */ spin_unlock(&g_tasklet_lock); if (oz_forget_urb(urb)) { - oz_trace("OZWPAN: ERROR Unknown URB %p\n", urb); + oz_dbg(ON, "ERROR Unknown URB %p\n", urb); } else { static unsigned long last_time; atomic_dec(&g_pending_urbs); - oz_trace2(OZ_TRACE_URB, - "%lu: giveback_urb(%p,%x) %lu %lu pending:%d\n", - jiffies, urb, status, jiffies-submit_jiffies, - jiffies-last_time, atomic_read(&g_pending_urbs)); + oz_dbg(URB, "%lu: giveback_urb(%p,%x) %lu %lu pending:%d\n", + jiffies, urb, status, jiffies-submit_jiffies, + jiffies-last_time, atomic_read(&g_pending_urbs)); last_time = jiffies; usb_hcd_giveback_urb(hcd, urb, status); } @@ -408,7 +408,7 @@ static void oz_ep_free(struct oz_port *port, struct oz_endpoint *ep) list_splice_tail(&list, &ozhcd->orphanage); spin_unlock_bh(&ozhcd->hcd_lock); } - oz_trace("Freeing endpoint memory\n"); + oz_dbg(ON, "Freeing endpoint memory\n"); kfree(ep); } /*------------------------------------------------------------------------------ @@ -445,8 +445,8 @@ static void oz_complete_buffered_urb(struct oz_port *port, ep->out_ix = 0; ep->buffered_units--; - oz_trace("Trying to give back buffered frame of size=%d\n", - available_space); + oz_dbg(ON, "Trying to give back buffered frame of size=%d\n", + available_space); oz_complete_urb(port->ozhcd->hcd, urb, 0, 0); } @@ -460,7 +460,7 @@ static int oz_enqueue_ep_urb(struct oz_port *port, u8 ep_addr, int in_dir, struct oz_endpoint *ep; int err = 0; if (ep_addr >= OZ_NB_ENDPOINTS) { - oz_trace("Invalid endpoint number in oz_enqueue_ep_urb().\n"); + oz_dbg(ON, "%s: Invalid endpoint number\n", __func__); return -EINVAL; } urbl = oz_alloc_urb_link(); @@ -479,7 +479,7 @@ static int oz_enqueue_ep_urb(struct oz_port *port, u8 ep_addr, int in_dir, */ if (urb->unlinked) { spin_unlock_bh(&port->ozhcd->hcd_lock); - oz_trace("urb %p unlinked so complete immediately\n", urb); + oz_dbg(ON, "urb %p unlinked so complete immediately\n", urb); oz_complete_urb(port->ozhcd->hcd, urb, 0, 0); oz_free_urb_link(urbl); return 0; @@ -640,7 +640,7 @@ void *oz_hcd_pd_arrived(void *hpd) spin_lock_bh(&ozhcd->hcd_lock); if (ozhcd->conn_port >= 0) { spin_unlock_bh(&ozhcd->hcd_lock); - oz_trace("conn_port >= 0\n"); + oz_dbg(ON, "conn_port >= 0\n"); goto out; } for (i = 0; i < OZ_NB_PORTS; i++) { @@ -654,7 +654,7 @@ void *oz_hcd_pd_arrived(void *hpd) spin_unlock(&port->port_lock); } if (i < OZ_NB_PORTS) { - oz_trace("Setting conn_port = %d\n", i); + oz_dbg(ON, "Setting conn_port = %d\n", i); ozhcd->conn_port = i; /* Attach out endpoint 0. */ @@ -663,7 +663,7 @@ void *oz_hcd_pd_arrived(void *hpd) hport = &ozhcd->ports[i]; spin_unlock_bh(&ozhcd->hcd_lock); if (ozhcd->flags & OZ_HDC_F_SUSPENDED) { - oz_trace("Resuming root hub\n"); + oz_dbg(ON, "Resuming root hub\n"); usb_hcd_resume_root_hub(ozhcd->hcd); } usb_hcd_poll_rh_status(ozhcd->hcd); @@ -690,7 +690,7 @@ void oz_hcd_pd_departed(void *hport) struct oz_endpoint *ep = NULL; if (port == NULL) { - oz_trace("oz_hcd_pd_departed() port = 0\n"); + oz_dbg(ON, "%s: port = 0\n", __func__); return; } ozhcd = port->ozhcd; @@ -701,7 +701,7 @@ void oz_hcd_pd_departed(void *hport) spin_lock_bh(&ozhcd->hcd_lock); if ((ozhcd->conn_port >= 0) && (port == &ozhcd->ports[ozhcd->conn_port])) { - oz_trace("Clearing conn_port\n"); + oz_dbg(ON, "Clearing conn_port\n"); ozhcd->conn_port = -1; } spin_lock(&port->port_lock); @@ -740,7 +740,7 @@ void oz_hcd_pd_reset(void *hpd, void *hport) */ struct oz_port *port = (struct oz_port *)hport; struct oz_hcd *ozhcd = port->ozhcd; - oz_trace("PD Reset\n"); + oz_dbg(ON, "PD Reset\n"); spin_lock_bh(&port->port_lock); port->flags |= OZ_PORT_F_CHANGED; port->status |= USB_PORT_STAT_RESET; @@ -759,8 +759,8 @@ void oz_hcd_get_desc_cnf(void *hport, u8 req_id, int status, const u8 *desc, struct urb *urb; int err = 0; - oz_trace("oz_hcd_get_desc_cnf length = %d offs = %d tot_size = %d\n", - length, offset, total_size); + oz_dbg(ON, "oz_hcd_get_desc_cnf length = %d offs = %d tot_size = %d\n", + length, offset, total_size); urb = oz_find_urb_by_id(port, 0, req_id); if (!urb) return; @@ -802,37 +802,37 @@ static void oz_display_conf_type(u8 t) { switch (t) { case USB_REQ_GET_STATUS: - oz_trace("USB_REQ_GET_STATUS - cnf\n"); + oz_dbg(ON, "USB_REQ_GET_STATUS - cnf\n"); break; case USB_REQ_CLEAR_FEATURE: - oz_trace("USB_REQ_CLEAR_FEATURE - cnf\n"); + oz_dbg(ON, "USB_REQ_CLEAR_FEATURE - cnf\n"); break; case USB_REQ_SET_FEATURE: - oz_trace("USB_REQ_SET_FEATURE - cnf\n"); + oz_dbg(ON, "USB_REQ_SET_FEATURE - cnf\n"); break; case USB_REQ_SET_ADDRESS: - oz_trace("USB_REQ_SET_ADDRESS - cnf\n"); + oz_dbg(ON, "USB_REQ_SET_ADDRESS - cnf\n"); break; case USB_REQ_GET_DESCRIPTOR: - oz_trace("USB_REQ_GET_DESCRIPTOR - cnf\n"); + oz_dbg(ON, "USB_REQ_GET_DESCRIPTOR - cnf\n"); break; case USB_REQ_SET_DESCRIPTOR: - oz_trace("USB_REQ_SET_DESCRIPTOR - cnf\n"); + oz_dbg(ON, "USB_REQ_SET_DESCRIPTOR - cnf\n"); break; case USB_REQ_GET_CONFIGURATION: - oz_trace("USB_REQ_GET_CONFIGURATION - cnf\n"); + oz_dbg(ON, "USB_REQ_GET_CONFIGURATION - cnf\n"); break; case USB_REQ_SET_CONFIGURATION: - oz_trace("USB_REQ_SET_CONFIGURATION - cnf\n"); + oz_dbg(ON, "USB_REQ_SET_CONFIGURATION - cnf\n"); break; case USB_REQ_GET_INTERFACE: - oz_trace("USB_REQ_GET_INTERFACE - cnf\n"); + oz_dbg(ON, "USB_REQ_GET_INTERFACE - cnf\n"); break; case USB_REQ_SET_INTERFACE: - oz_trace("USB_REQ_SET_INTERFACE - cnf\n"); + oz_dbg(ON, "USB_REQ_SET_INTERFACE - cnf\n"); break; case USB_REQ_SYNCH_FRAME: - oz_trace("USB_REQ_SYNCH_FRAME - cnf\n"); + oz_dbg(ON, "USB_REQ_SYNCH_FRAME - cnf\n"); break; } } @@ -870,7 +870,7 @@ static void oz_hcd_complete_set_interface(struct oz_port *port, struct urb *urb, if (rcode == 0) { struct usb_host_config *config; struct usb_host_interface *intf; - oz_trace("Set interface %d alt %d\n", if_num, alt); + oz_dbg(ON, "Set interface %d alt %d\n", if_num, alt); oz_clean_endpoints_for_interface(hcd, port, if_num); config = &urb->dev->config[port->config_num-1]; intf = &config->intf_cache[if_num]->altsetting[alt]; @@ -897,10 +897,10 @@ void oz_hcd_control_cnf(void *hport, u8 req_id, u8 rcode, const u8 *data, unsigned windex; unsigned wvalue; - oz_trace("oz_hcd_control_cnf rcode=%u len=%d\n", rcode, data_len); + oz_dbg(ON, "oz_hcd_control_cnf rcode=%u len=%d\n", rcode, data_len); urb = oz_find_urb_by_id(port, 0, req_id); if (!urb) { - oz_trace("URB not found\n"); + oz_dbg(ON, "URB not found\n"); return; } setup = (struct usb_ctrlrequest *)urb->setup_packet; @@ -924,7 +924,7 @@ void oz_hcd_control_cnf(void *hport, u8 req_id, u8 rcode, const u8 *data, } else { int copy_len; - oz_trace("VENDOR-CLASS - cnf\n"); + oz_dbg(ON, "VENDOR-CLASS - cnf\n"); if (data_len) { if (data_len <= urb->transfer_buffer_length) copy_len = data_len; @@ -950,7 +950,7 @@ static int oz_hcd_buffer_data(struct oz_endpoint *ep, const u8 *data, if (space < 0) space += ep->buffer_size; if (space < (data_len+1)) { - oz_trace("Buffer full\n"); + oz_dbg(ON, "Buffer full\n"); return -1; } ep->buffer[ep->in_ix] = (u8)data_len; @@ -1006,7 +1006,7 @@ void oz_hcd_data_ind(void *hport, u8 endpoint, const u8 *data, int data_len) oz_complete_urb(port->ozhcd->hcd, urb, 0, 0); return; } else { - oz_trace("buffering frame as URB is not available\n"); + oz_dbg(ON, "buffering frame as URB is not available\n"); oz_hcd_buffer_data(ep, data, data_len); } break; @@ -1159,8 +1159,8 @@ int oz_hcd_heartbeat(void *hport) list_for_each_safe(e, n, &ep->urb_list) { urbl = container_of(e, struct oz_urb_link, link); if (time_after(now, urbl->submit_jiffies+HZ/2)) { - oz_trace("%ld: Request 0x%p timeout\n", - now, urbl->urb); + oz_dbg(ON, "%ld: Request 0x%p timeout\n", + now, urbl->urb); urbl->submit_jiffies = now; list_move_tail(e, &xfr_list); } @@ -1172,7 +1172,7 @@ int oz_hcd_heartbeat(void *hport) while (e != &xfr_list) { urbl = container_of(e, struct oz_urb_link, link); e = e->next; - oz_trace("Resending request to PD.\n"); + oz_dbg(ON, "Resending request to PD\n"); oz_process_ep0_urb(ozhcd, urbl->urb, GFP_ATOMIC); oz_free_urb_link(urbl); } @@ -1190,7 +1190,7 @@ static int oz_build_endpoints_for_interface(struct usb_hcd *hcd, int i; int if_ix = intf->desc.bInterfaceNumber; int request_heartbeat = 0; - oz_trace("interface[%d] = %p\n", if_ix, intf); + oz_dbg(ON, "interface[%d] = %p\n", if_ix, intf); for (i = 0; i < intf->desc.bNumEndpoints; i++) { struct usb_host_endpoint *hep = &intf->endpoint[i]; u8 ep_addr = hep->desc.bEndpointAddress; @@ -1198,7 +1198,7 @@ static int oz_build_endpoints_for_interface(struct usb_hcd *hcd, struct oz_endpoint *ep; int buffer_size = 0; - oz_trace("%d bEndpointAddress = %x\n", i, ep_addr); + oz_dbg(ON, "%d bEndpointAddress = %x\n", i, ep_addr); if (ep_addr & USB_ENDPOINT_DIR_MASK) { switch (hep->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) { @@ -1220,8 +1220,8 @@ static int oz_build_endpoints_for_interface(struct usb_hcd *hcd, ep->ep_num = ep_num; if ((ep->attrib & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_ISOC) { - oz_trace("wMaxPacketSize = %d\n", - usb_endpoint_maxp(&hep->desc)); + oz_dbg(ON, "wMaxPacketSize = %d\n", + usb_endpoint_maxp(&hep->desc)); ep->credit_ceiling = 200; if (ep_addr & USB_ENDPOINT_DIR_MASK) { ep->flags |= OZ_F_EP_BUFFERING; @@ -1267,7 +1267,7 @@ static void oz_clean_endpoints_for_interface(struct usb_hcd *hcd, int i; struct list_head ep_list; - oz_trace("Deleting endpoints for interface %d\n", if_ix); + oz_dbg(ON, "Deleting endpoints for interface %d\n", if_ix); if (if_ix >= port->num_iface) return; INIT_LIST_HEAD(&ep_list); @@ -1343,12 +1343,12 @@ static void oz_clean_endpoints_for_config(struct usb_hcd *hcd, { struct oz_hcd *ozhcd = port->ozhcd; int i; - oz_trace("Deleting endpoints for configuration.\n"); + oz_dbg(ON, "Deleting endpoints for configuration\n"); for (i = 0; i < port->num_iface; i++) oz_clean_endpoints_for_interface(hcd, port, i); spin_lock_bh(&ozhcd->hcd_lock); if (port->iface) { - oz_trace("Freeing interfaces object.\n"); + oz_dbg(ON, "Freeing interfaces object\n"); kfree(port->iface); port->iface = NULL; } @@ -1387,7 +1387,7 @@ static void oz_process_ep0_urb(struct oz_hcd *ozhcd, struct urb *urb, int port_ix = -1; struct oz_port *port = NULL; - oz_trace2(OZ_TRACE_URB, "%lu: oz_process_ep0_urb(%p)\n", jiffies, urb); + oz_dbg(URB, "%lu: %s: (%p)\n", jiffies, __func__, urb); port_ix = oz_get_port_from_addr(ozhcd, urb->dev->devnum); if (port_ix < 0) { rc = -EPIPE; @@ -1396,8 +1396,8 @@ static void oz_process_ep0_urb(struct oz_hcd *ozhcd, struct urb *urb, port = &ozhcd->ports[port_ix]; if (((port->flags & OZ_PORT_F_PRESENT) == 0) || (port->flags & OZ_PORT_F_DYING)) { - oz_trace("Refusing URB port_ix = %d devnum = %d\n", - port_ix, urb->dev->devnum); + oz_dbg(ON, "Refusing URB port_ix = %d devnum = %d\n", + port_ix, urb->dev->devnum); rc = -EPIPE; goto out; } @@ -1408,17 +1408,16 @@ static void oz_process_ep0_urb(struct oz_hcd *ozhcd, struct urb *urb, windex = le16_to_cpu(setup->wIndex); wvalue = le16_to_cpu(setup->wValue); wlength = le16_to_cpu(setup->wLength); - oz_trace2(OZ_TRACE_CTRL_DETAIL, "bRequestType = %x\n", - setup->bRequestType); - oz_trace2(OZ_TRACE_CTRL_DETAIL, "bRequest = %x\n", setup->bRequest); - oz_trace2(OZ_TRACE_CTRL_DETAIL, "wValue = %x\n", wvalue); - oz_trace2(OZ_TRACE_CTRL_DETAIL, "wIndex = %x\n", windex); - oz_trace2(OZ_TRACE_CTRL_DETAIL, "wLength = %x\n", wlength); + oz_dbg(CTRL_DETAIL, "bRequestType = %x\n", setup->bRequestType); + oz_dbg(CTRL_DETAIL, "bRequest = %x\n", setup->bRequest); + oz_dbg(CTRL_DETAIL, "wValue = %x\n", wvalue); + oz_dbg(CTRL_DETAIL, "wIndex = %x\n", windex); + oz_dbg(CTRL_DETAIL, "wLength = %x\n", wlength); req_id = port->next_req_id++; hpd = oz_claim_hpd(port); if (hpd == NULL) { - oz_trace("Cannot claim port\n"); + oz_dbg(ON, "Cannot claim port\n"); rc = -EPIPE; goto out; } @@ -1428,30 +1427,31 @@ static void oz_process_ep0_urb(struct oz_hcd *ozhcd, struct urb *urb, */ switch (setup->bRequest) { case USB_REQ_GET_DESCRIPTOR: - oz_trace("USB_REQ_GET_DESCRIPTOR - req\n"); + oz_dbg(ON, "USB_REQ_GET_DESCRIPTOR - req\n"); break; case USB_REQ_SET_ADDRESS: - oz_trace("USB_REQ_SET_ADDRESS - req\n"); - oz_trace("Port %d address is 0x%x\n", ozhcd->conn_port, - (u8)le16_to_cpu(setup->wValue)); + oz_dbg(ON, "USB_REQ_SET_ADDRESS - req\n"); + oz_dbg(ON, "Port %d address is 0x%x\n", + ozhcd->conn_port, + (u8)le16_to_cpu(setup->wValue)); spin_lock_bh(&ozhcd->hcd_lock); if (ozhcd->conn_port >= 0) { ozhcd->ports[ozhcd->conn_port].bus_addr = (u8)le16_to_cpu(setup->wValue); - oz_trace("Clearing conn_port\n"); + oz_dbg(ON, "Clearing conn_port\n"); ozhcd->conn_port = -1; } spin_unlock_bh(&ozhcd->hcd_lock); complete = 1; break; case USB_REQ_SET_CONFIGURATION: - oz_trace("USB_REQ_SET_CONFIGURATION - req\n"); + oz_dbg(ON, "USB_REQ_SET_CONFIGURATION - req\n"); break; case USB_REQ_GET_CONFIGURATION: /* We short circuit this case and reply directly since * we have the selected configuration number cached. */ - oz_trace("USB_REQ_GET_CONFIGURATION - reply now\n"); + oz_dbg(ON, "USB_REQ_GET_CONFIGURATION - reply now\n"); if (urb->transfer_buffer_length >= 1) { urb->actual_length = 1; *((u8 *)urb->transfer_buffer) = @@ -1465,20 +1465,20 @@ static void oz_process_ep0_urb(struct oz_hcd *ozhcd, struct urb *urb, /* We short circuit this case and reply directly since * we have the selected interface alternative cached. */ - oz_trace("USB_REQ_GET_INTERFACE - reply now\n"); + oz_dbg(ON, "USB_REQ_GET_INTERFACE - reply now\n"); if (urb->transfer_buffer_length >= 1) { urb->actual_length = 1; *((u8 *)urb->transfer_buffer) = port->iface[(u8)windex].alt; - oz_trace("interface = %d alt = %d\n", - windex, port->iface[(u8)windex].alt); + oz_dbg(ON, "interface = %d alt = %d\n", + windex, port->iface[(u8)windex].alt); complete = 1; } else { rc = -EPIPE; } break; case USB_REQ_SET_INTERFACE: - oz_trace("USB_REQ_SET_INTERFACE - req\n"); + oz_dbg(ON, "USB_REQ_SET_INTERFACE - req\n"); break; } } @@ -1509,7 +1509,7 @@ static void oz_process_ep0_urb(struct oz_hcd *ozhcd, struct urb *urb, oz_usb_put(hpd); out: if (rc || complete) { - oz_trace("Completing request locally\n"); + oz_dbg(ON, "Completing request locally\n"); oz_complete_urb(ozhcd->hcd, urb, rc, 0); } else { oz_usb_request_heartbeat(port->hpd); @@ -1597,12 +1597,12 @@ static void oz_urb_cancel(struct oz_port *port, u8 ep_num, struct urb *urb) unsigned long irq_state; u8 ix; if (port == NULL) { - oz_trace("ERRORERROR: oz_urb_cancel(%p) port is null\n", urb); + oz_dbg(ON, "%s: ERROR: (%p) port is null\n", __func__, urb); return; } ozhcd = port->ozhcd; if (ozhcd == NULL) { - oz_trace("ERRORERROR: oz_urb_cancel(%p) ozhcd is null\n", urb); + oz_dbg(ON, "%s; ERROR: (%p) ozhcd is null\n", __func__, urb); return; } @@ -1627,7 +1627,7 @@ static void oz_urb_cancel(struct oz_port *port, u8 ep_num, struct urb *urb) urbl = container_of(e, struct oz_urb_link, link); if (urbl->urb == urb) { list_del(e); - oz_trace("Found urb in orphanage\n"); + oz_dbg(ON, "Found urb in orphanage\n"); goto out; } } @@ -1725,16 +1725,14 @@ static int oz_hcd_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, struct oz_port *port; unsigned long irq_state; struct oz_urb_link *urbl; - oz_trace2(OZ_TRACE_URB, "%lu: oz_hcd_urb_enqueue(%p)\n", - jiffies, urb); + oz_dbg(URB, "%lu: %s: (%p)\n", jiffies, __func__, urb); if (unlikely(ozhcd == NULL)) { - oz_trace2(OZ_TRACE_URB, "%lu: Refused urb(%p) not ozhcd.\n", - jiffies, urb); + oz_dbg(URB, "%lu: Refused urb(%p) not ozhcd\n", jiffies, urb); return -EPIPE; } if (unlikely(hcd->state != HC_STATE_RUNNING)) { - oz_trace2(OZ_TRACE_URB, "%lu: Refused urb(%p) not running.\n", - jiffies, urb); + oz_dbg(URB, "%lu: Refused urb(%p) not running\n", + jiffies, urb); return -EPIPE; } port_ix = oz_get_port_from_addr(ozhcd, urb->dev->devnum); @@ -1744,8 +1742,8 @@ static int oz_hcd_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, if (port == NULL) return -EPIPE; if ((port->flags & OZ_PORT_F_PRESENT) == 0) { - oz_trace("Refusing URB port_ix = %d devnum = %d\n", - port_ix, urb->dev->devnum); + oz_dbg(ON, "Refusing URB port_ix = %d devnum = %d\n", + port_ix, urb->dev->devnum); return -EPIPE; } urb->hcpriv = port; @@ -1802,7 +1800,7 @@ static int oz_hcd_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) struct oz_urb_link *urbl = NULL; int rc; unsigned long irq_state; - oz_trace2(OZ_TRACE_URB, "%lu: oz_hcd_urb_dequeue(%p)\n", jiffies, urb); + oz_dbg(URB, "%lu: %s: (%p)\n", jiffies, __func__, urb); urbl = oz_alloc_urb_link(); if (unlikely(urbl == NULL)) return -ENOMEM; @@ -1851,7 +1849,7 @@ static void oz_hcd_endpoint_reset(struct usb_hcd *hcd, */ static int oz_hcd_get_frame_number(struct usb_hcd *hcd) { - oz_trace("oz_hcd_get_frame_number\n"); + oz_dbg(ON, "oz_hcd_get_frame_number\n"); return oz_usb_get_frame_number(); } /*------------------------------------------------------------------------------ @@ -1869,7 +1867,7 @@ static int oz_hcd_hub_status_data(struct usb_hcd *hcd, char *buf) spin_lock_bh(&ozhcd->hcd_lock); for (i = 0; i < OZ_NB_PORTS; i++) { if (ozhcd->ports[i].flags & OZ_PORT_F_CHANGED) { - oz_trace2(OZ_TRACE_HUB, "Port %d changed\n", i); + oz_dbg(HUB, "Port %d changed\n", i); ozhcd->ports[i].flags &= ~OZ_PORT_F_CHANGED; buf[0] |= 1<<(i+1); } @@ -1907,53 +1905,53 @@ static int oz_set_port_feature(struct usb_hcd *hcd, u16 wvalue, u16 windex) port = &ozhcd->ports[port_id-1]; switch (wvalue) { case USB_PORT_FEAT_CONNECTION: - oz_trace2(OZ_TRACE_HUB, "USB_PORT_FEAT_CONNECTION\n"); + oz_dbg(HUB, "USB_PORT_FEAT_CONNECTION\n"); break; case USB_PORT_FEAT_ENABLE: - oz_trace2(OZ_TRACE_HUB, "USB_PORT_FEAT_ENABLE\n"); + oz_dbg(HUB, "USB_PORT_FEAT_ENABLE\n"); break; case USB_PORT_FEAT_SUSPEND: - oz_trace2(OZ_TRACE_HUB, "USB_PORT_FEAT_SUSPEND\n"); + oz_dbg(HUB, "USB_PORT_FEAT_SUSPEND\n"); break; case USB_PORT_FEAT_OVER_CURRENT: - oz_trace2(OZ_TRACE_HUB, "USB_PORT_FEAT_OVER_CURRENT\n"); + oz_dbg(HUB, "USB_PORT_FEAT_OVER_CURRENT\n"); break; case USB_PORT_FEAT_RESET: - oz_trace2(OZ_TRACE_HUB, "USB_PORT_FEAT_RESET\n"); + oz_dbg(HUB, "USB_PORT_FEAT_RESET\n"); set_bits = USB_PORT_STAT_ENABLE | (USB_PORT_STAT_C_RESET<<16); clear_bits = USB_PORT_STAT_RESET; ozhcd->ports[port_id-1].bus_addr = 0; break; case USB_PORT_FEAT_POWER: - oz_trace2(OZ_TRACE_HUB, "USB_PORT_FEAT_POWER\n"); + oz_dbg(HUB, "USB_PORT_FEAT_POWER\n"); set_bits |= USB_PORT_STAT_POWER; break; case USB_PORT_FEAT_LOWSPEED: - oz_trace2(OZ_TRACE_HUB, "USB_PORT_FEAT_LOWSPEED\n"); + oz_dbg(HUB, "USB_PORT_FEAT_LOWSPEED\n"); break; case USB_PORT_FEAT_C_CONNECTION: - oz_trace2(OZ_TRACE_HUB, "USB_PORT_FEAT_C_CONNECTION\n"); + oz_dbg(HUB, "USB_PORT_FEAT_C_CONNECTION\n"); break; case USB_PORT_FEAT_C_ENABLE: - oz_trace2(OZ_TRACE_HUB, "USB_PORT_FEAT_C_ENABLE\n"); + oz_dbg(HUB, "USB_PORT_FEAT_C_ENABLE\n"); break; case USB_PORT_FEAT_C_SUSPEND: - oz_trace2(OZ_TRACE_HUB, "USB_PORT_FEAT_C_SUSPEND\n"); + oz_dbg(HUB, "USB_PORT_FEAT_C_SUSPEND\n"); break; case USB_PORT_FEAT_C_OVER_CURRENT: - oz_trace2(OZ_TRACE_HUB, "USB_PORT_FEAT_C_OVER_CURRENT\n"); + oz_dbg(HUB, "USB_PORT_FEAT_C_OVER_CURRENT\n"); break; case USB_PORT_FEAT_C_RESET: - oz_trace2(OZ_TRACE_HUB, "USB_PORT_FEAT_C_RESET\n"); + oz_dbg(HUB, "USB_PORT_FEAT_C_RESET\n"); break; case USB_PORT_FEAT_TEST: - oz_trace2(OZ_TRACE_HUB, "USB_PORT_FEAT_TEST\n"); + oz_dbg(HUB, "USB_PORT_FEAT_TEST\n"); break; case USB_PORT_FEAT_INDICATOR: - oz_trace2(OZ_TRACE_HUB, "USB_PORT_FEAT_INDICATOR\n"); + oz_dbg(HUB, "USB_PORT_FEAT_INDICATOR\n"); break; default: - oz_trace2(OZ_TRACE_HUB, "Other %d\n", wvalue); + oz_dbg(HUB, "Other %d\n", wvalue); break; } if (set_bits || clear_bits) { @@ -1962,8 +1960,7 @@ static int oz_set_port_feature(struct usb_hcd *hcd, u16 wvalue, u16 windex) port->status |= set_bits; spin_unlock_bh(&port->port_lock); } - oz_trace2(OZ_TRACE_HUB, "Port[%d] status = 0x%x\n", port_id, - port->status); + oz_dbg(HUB, "Port[%d] status = 0x%x\n", port_id, port->status); return err; } /*------------------------------------------------------------------------------ @@ -1982,54 +1979,54 @@ static int oz_clear_port_feature(struct usb_hcd *hcd, u16 wvalue, u16 windex) port = &ozhcd->ports[port_id-1]; switch (wvalue) { case USB_PORT_FEAT_CONNECTION: - oz_trace2(OZ_TRACE_HUB, "USB_PORT_FEAT_CONNECTION\n"); + oz_dbg(HUB, "USB_PORT_FEAT_CONNECTION\n"); break; case USB_PORT_FEAT_ENABLE: - oz_trace2(OZ_TRACE_HUB, "USB_PORT_FEAT_ENABLE\n"); + oz_dbg(HUB, "USB_PORT_FEAT_ENABLE\n"); clear_bits = USB_PORT_STAT_ENABLE; break; case USB_PORT_FEAT_SUSPEND: - oz_trace2(OZ_TRACE_HUB, "USB_PORT_FEAT_SUSPEND\n"); + oz_dbg(HUB, "USB_PORT_FEAT_SUSPEND\n"); break; case USB_PORT_FEAT_OVER_CURRENT: - oz_trace2(OZ_TRACE_HUB, "USB_PORT_FEAT_OVER_CURRENT\n"); + oz_dbg(HUB, "USB_PORT_FEAT_OVER_CURRENT\n"); break; case USB_PORT_FEAT_RESET: - oz_trace2(OZ_TRACE_HUB, "USB_PORT_FEAT_RESET\n"); + oz_dbg(HUB, "USB_PORT_FEAT_RESET\n"); break; case USB_PORT_FEAT_POWER: - oz_trace2(OZ_TRACE_HUB, "USB_PORT_FEAT_POWER\n"); + oz_dbg(HUB, "USB_PORT_FEAT_POWER\n"); clear_bits |= USB_PORT_STAT_POWER; break; case USB_PORT_FEAT_LOWSPEED: - oz_trace2(OZ_TRACE_HUB, "USB_PORT_FEAT_LOWSPEED\n"); + oz_dbg(HUB, "USB_PORT_FEAT_LOWSPEED\n"); break; case USB_PORT_FEAT_C_CONNECTION: - oz_trace2(OZ_TRACE_HUB, "USB_PORT_FEAT_C_CONNECTION\n"); + oz_dbg(HUB, "USB_PORT_FEAT_C_CONNECTION\n"); clear_bits = (USB_PORT_STAT_C_CONNECTION << 16); break; case USB_PORT_FEAT_C_ENABLE: - oz_trace2(OZ_TRACE_HUB, "USB_PORT_FEAT_C_ENABLE\n"); + oz_dbg(HUB, "USB_PORT_FEAT_C_ENABLE\n"); clear_bits = (USB_PORT_STAT_C_ENABLE << 16); break; case USB_PORT_FEAT_C_SUSPEND: - oz_trace2(OZ_TRACE_HUB, "USB_PORT_FEAT_C_SUSPEND\n"); + oz_dbg(HUB, "USB_PORT_FEAT_C_SUSPEND\n"); break; case USB_PORT_FEAT_C_OVER_CURRENT: - oz_trace2(OZ_TRACE_HUB, "USB_PORT_FEAT_C_OVER_CURRENT\n"); + oz_dbg(HUB, "USB_PORT_FEAT_C_OVER_CURRENT\n"); break; case USB_PORT_FEAT_C_RESET: - oz_trace2(OZ_TRACE_HUB, "USB_PORT_FEAT_C_RESET\n"); + oz_dbg(HUB, "USB_PORT_FEAT_C_RESET\n"); clear_bits = (USB_PORT_FEAT_C_RESET << 16); break; case USB_PORT_FEAT_TEST: - oz_trace2(OZ_TRACE_HUB, "USB_PORT_FEAT_TEST\n"); + oz_dbg(HUB, "USB_PORT_FEAT_TEST\n"); break; case USB_PORT_FEAT_INDICATOR: - oz_trace2(OZ_TRACE_HUB, "USB_PORT_FEAT_INDICATOR\n"); + oz_dbg(HUB, "USB_PORT_FEAT_INDICATOR\n"); break; default: - oz_trace2(OZ_TRACE_HUB, "Other %d\n", wvalue); + oz_dbg(HUB, "Other %d\n", wvalue); break; } if (clear_bits) { @@ -2037,8 +2034,8 @@ static int oz_clear_port_feature(struct usb_hcd *hcd, u16 wvalue, u16 windex) port->status &= ~clear_bits; spin_unlock_bh(&port->port_lock); } - oz_trace2(OZ_TRACE_HUB, "Port[%d] status = 0x%x\n", port_id, - ozhcd->ports[port_id-1].status); + oz_dbg(HUB, "Port[%d] status = 0x%x\n", + port_id, ozhcd->ports[port_id-1].status); return err; } /*------------------------------------------------------------------------------ @@ -2051,10 +2048,10 @@ static int oz_get_port_status(struct usb_hcd *hcd, u16 windex, char *buf) if ((windex < 1) || (windex > OZ_NB_PORTS)) return -EPIPE; ozhcd = oz_hcd_private(hcd); - oz_trace2(OZ_TRACE_HUB, "GetPortStatus windex = %d\n", windex); + oz_dbg(HUB, "GetPortStatus windex = %d\n", windex); status = ozhcd->ports[windex-1].status; put_unaligned(cpu_to_le32(status), (__le32 *)buf); - oz_trace2(OZ_TRACE_HUB, "Port[%d] status = %x\n", windex, status); + oz_dbg(HUB, "Port[%d] status = %x\n", windex, status); return 0; } /*------------------------------------------------------------------------------ @@ -2067,7 +2064,7 @@ static int oz_hcd_hub_control(struct usb_hcd *hcd, u16 req_type, u16 wvalue, switch (req_type) { case ClearHubFeature: - oz_trace2(OZ_TRACE_HUB, "ClearHubFeature: %d\n", req_type); + oz_dbg(HUB, "ClearHubFeature: %d\n", req_type); break; case ClearPortFeature: err = oz_clear_port_feature(hcd, wvalue, windex); @@ -2076,21 +2073,20 @@ static int oz_hcd_hub_control(struct usb_hcd *hcd, u16 req_type, u16 wvalue, oz_get_hub_descriptor(hcd, (struct usb_hub_descriptor *)buf); break; case GetHubStatus: - oz_trace2(OZ_TRACE_HUB, "GetHubStatus: req_type = 0x%x\n", - req_type); + oz_dbg(HUB, "GetHubStatus: req_type = 0x%x\n", req_type); put_unaligned(__constant_cpu_to_le32(0), (__le32 *)buf); break; case GetPortStatus: err = oz_get_port_status(hcd, windex, buf); break; case SetHubFeature: - oz_trace2(OZ_TRACE_HUB, "SetHubFeature: %d\n", req_type); + oz_dbg(HUB, "SetHubFeature: %d\n", req_type); break; case SetPortFeature: err = oz_set_port_feature(hcd, wvalue, windex); break; default: - oz_trace2(OZ_TRACE_HUB, "Other: %d\n", req_type); + oz_dbg(HUB, "Other: %d\n", req_type); break; } return err; @@ -2141,7 +2137,7 @@ static int oz_plat_probe(struct platform_device *dev) hcd = usb_create_hcd(&g_oz_hc_drv, &dev->dev, dev_name(&dev->dev)); if (hcd == NULL) { - oz_trace("Failed to created hcd object OK\n"); + oz_dbg(ON, "Failed to created hcd object OK\n"); return -ENOMEM; } ozhcd = oz_hcd_private(hcd); @@ -2162,7 +2158,7 @@ static int oz_plat_probe(struct platform_device *dev) } err = usb_add_hcd(hcd, 0, 0); if (err) { - oz_trace("Failed to add hcd object OK\n"); + oz_dbg(ON, "Failed to add hcd object OK\n"); usb_put_hcd(hcd); return -1; } @@ -2186,14 +2182,15 @@ static int oz_plat_remove(struct platform_device *dev) if (ozhcd == g_ozhcd) g_ozhcd = NULL; spin_unlock_bh(&g_hcdlock); - oz_trace("Clearing orphanage\n"); + oz_dbg(ON, "Clearing orphanage\n"); oz_hcd_clear_orphanage(ozhcd, -EPIPE); - oz_trace("Removing hcd\n"); + oz_dbg(ON, "Removing hcd\n"); usb_remove_hcd(hcd); usb_put_hcd(hcd); oz_empty_link_pool(); return 0; } + /*------------------------------------------------------------------------------ * Context: unknown */ @@ -2201,6 +2198,7 @@ static int oz_plat_suspend(struct platform_device *dev, pm_message_t msg) { return 0; } + /*------------------------------------------------------------------------------ * Context: unknown */ @@ -2208,6 +2206,7 @@ static int oz_plat_resume(struct platform_device *dev) { return 0; } + /*------------------------------------------------------------------------------ * Context: process */ @@ -2219,7 +2218,7 @@ int oz_hcd_init(void) tasklet_init(&g_urb_process_tasklet, oz_urb_process_tasklet, 0); tasklet_init(&g_urb_cancel_tasklet, oz_urb_cancel_tasklet, 0); err = platform_driver_register(&g_oz_plat_drv); - oz_trace("platform_driver_register() returned %d\n", err); + oz_dbg(ON, "platform_driver_register() returned %d\n", err); if (err) goto error; g_plat_dev = platform_device_alloc(OZ_PLAT_DEV_NAME, -1); @@ -2227,11 +2226,11 @@ int oz_hcd_init(void) err = -ENOMEM; goto error1; } - oz_trace("platform_device_alloc() succeeded\n"); + oz_dbg(ON, "platform_device_alloc() succeeded\n"); err = platform_device_add(g_plat_dev); if (err) goto error2; - oz_trace("platform_device_add() succeeded\n"); + oz_dbg(ON, "platform_device_add() succeeded\n"); return 0; error2: platform_device_put(g_plat_dev); @@ -2240,7 +2239,7 @@ int oz_hcd_init(void) error: tasklet_disable(&g_urb_process_tasklet); tasklet_disable(&g_urb_cancel_tasklet); - oz_trace("oz_hcd_init() failed %d\n", err); + oz_dbg(ON, "oz_hcd_init() failed %d\n", err); return err; } /*------------------------------------------------------------------------------ @@ -2252,5 +2251,5 @@ void oz_hcd_term(void) tasklet_kill(&g_urb_cancel_tasklet); platform_device_unregister(g_plat_dev); platform_driver_unregister(&g_oz_plat_drv); - oz_trace("Pending urbs:%d\n", atomic_read(&g_pending_urbs)); + oz_dbg(ON, "Pending urbs:%d\n", atomic_read(&g_pending_urbs)); } diff --git a/drivers/staging/ozwpan/ozpd.c b/drivers/staging/ozwpan/ozpd.c index d67dff2430adb..28adbb47764ad 100644 --- a/drivers/staging/ozwpan/ozpd.c +++ b/drivers/staging/ozwpan/ozpd.c @@ -9,6 +9,7 @@ #include #include #include +#include "ozdbg.h" #include "ozconfig.h" #include "ozprotocol.h" #include "ozeltbuf.h" @@ -123,16 +124,16 @@ void oz_pd_set_state(struct oz_pd *pd, unsigned state) #ifdef WANT_TRACE switch (state) { case OZ_PD_S_IDLE: - oz_trace("PD State: OZ_PD_S_IDLE\n"); + oz_pd_dbg(pd, ON, "PD State: OZ_PD_S_IDLE\n"); break; case OZ_PD_S_CONNECTED: - oz_trace("PD State: OZ_PD_S_CONNECTED\n"); + oz_pd_dbg(pd, ON, "PD State: OZ_PD_S_CONNECTED\n"); break; case OZ_PD_S_STOPPED: - oz_trace("PD State: OZ_PD_S_STOPPED\n"); + oz_pd_dbg(pd, ON, "PD State: OZ_PD_S_STOPPED\n"); break; case OZ_PD_S_SLEEP: - oz_trace("PD State: OZ_PD_S_SLEEP\n"); + oz_pd_dbg(pd, ON, "PD State: OZ_PD_S_SLEEP\n"); break; } #endif /* WANT_TRACE */ @@ -189,7 +190,7 @@ void oz_pd_destroy(struct oz_pd *pd) struct oz_tx_frame *f; struct oz_isoc_stream *st; struct oz_farewell *fwell; - oz_trace("Destroying PD\n"); + oz_pd_dbg(pd, ON, "Destroying PD\n"); /* Delete any streams. */ e = pd->stream_list.next; @@ -235,13 +236,14 @@ int oz_services_start(struct oz_pd *pd, u16 apps, int resume) { const struct oz_app_if *ai; int rc = 0; - oz_trace("oz_services_start(0x%x) resume(%d)\n", apps, resume); + oz_pd_dbg(pd, ON, "%s: (0x%x) resume(%d)\n", __func__, apps, resume); for (ai = g_app_if; ai < &g_app_if[OZ_APPID_MAX]; ai++) { if (apps & (1<app_id)) { if (ai->start(pd, resume)) { rc = -1; - oz_trace("Unabled to start service %d\n", - ai->app_id); + oz_pd_dbg(pd, ON, + "Unable to start service %d\n", + ai->app_id); break; } oz_polling_lock_bh(); @@ -259,7 +261,7 @@ int oz_services_start(struct oz_pd *pd, u16 apps, int resume) void oz_services_stop(struct oz_pd *pd, u16 apps, int pause) { const struct oz_app_if *ai; - oz_trace("oz_stop_services(0x%x) pause(%d)\n", apps, pause); + oz_pd_dbg(pd, ON, "%s: (0x%x) pause(%d)\n", __func__, apps, pause); for (ai = g_app_if; ai < &g_app_if[OZ_APPID_MAX]; ai++) { if (apps & (1<app_id)) { oz_polling_lock_bh(); @@ -301,7 +303,7 @@ void oz_pd_heartbeat(struct oz_pd *pd, u16 apps) void oz_pd_stop(struct oz_pd *pd) { u16 stop_apps = 0; - oz_trace("oz_pd_stop() State = 0x%x\n", pd->state); + oz_dbg(ON, "oz_pd_stop() State = 0x%x\n", pd->state); oz_pd_indicate_farewells(pd); oz_polling_lock_bh(); stop_apps = pd->total_apps; @@ -314,7 +316,7 @@ void oz_pd_stop(struct oz_pd *pd) /* Remove from PD list.*/ list_del(&pd->link); oz_polling_unlock_bh(); - oz_trace("pd ref count = %d\n", atomic_read(&pd->ref_count)); + oz_dbg(ON, "pd ref count = %d\n", atomic_read(&pd->ref_count)); oz_timer_delete(pd, 0); oz_pd_put(pd); } @@ -333,8 +335,8 @@ int oz_pd_sleep(struct oz_pd *pd) if (pd->keep_alive_j && pd->session_id) { oz_pd_set_state(pd, OZ_PD_S_SLEEP); pd->pulse_time_j = jiffies + pd->keep_alive_j; - oz_trace("Sleep Now %lu until %lu\n", - jiffies, pd->pulse_time_j); + oz_dbg(ON, "Sleep Now %lu until %lu\n", + jiffies, pd->pulse_time_j); } else { do_stop = 1; } @@ -384,8 +386,8 @@ static void oz_tx_isoc_free(struct oz_pd *pd, struct oz_tx_frame *f) } else { kfree(f); } - oz_trace2(OZ_TRACE_TX_FRAMES, "Releasing ISOC Frame isoc_nb= %d\n", - pd->nb_queued_isoc_frames); + oz_dbg(TX_FRAMES, "Releasing ISOC Frame isoc_nb= %d\n", + pd->nb_queued_isoc_frames); } /*------------------------------------------------------------------------------ * Context: softirq or process @@ -540,18 +542,16 @@ static int oz_send_next_queued_frame(struct oz_pd *pd, int more_data) if ((int)atomic_read(&g_submitted_isoc) < OZ_MAX_SUBMITTED_ISOC) { if (dev_queue_xmit(skb) < 0) { - oz_trace2(OZ_TRACE_TX_FRAMES, - "Dropping ISOC Frame\n"); + oz_dbg(TX_FRAMES, "Dropping ISOC Frame\n"); return -1; } atomic_inc(&g_submitted_isoc); - oz_trace2(OZ_TRACE_TX_FRAMES, - "Sending ISOC Frame, nb_isoc= %d\n", - pd->nb_queued_isoc_frames); + oz_dbg(TX_FRAMES, "Sending ISOC Frame, nb_isoc= %d\n", + pd->nb_queued_isoc_frames); return 0; } else { kfree_skb(skb); - oz_trace2(OZ_TRACE_TX_FRAMES, "Dropping ISOC Frame>\n"); + oz_dbg(TX_FRAMES, "Dropping ISOC Frame>\n"); return -1; } } @@ -561,7 +561,7 @@ static int oz_send_next_queued_frame(struct oz_pd *pd, int more_data) spin_unlock(&pd->tx_frame_lock); if (more_data) oz_set_more_bit(skb); - oz_trace2(OZ_TRACE_TX_FRAMES, "TX frame PN=0x%x\n", f->hdr.pkt_num); + oz_dbg(TX_FRAMES, "TX frame PN=0x%x\n", f->hdr.pkt_num); if (skb) { if (dev_queue_xmit(skb) < 0) return -1; @@ -627,7 +627,7 @@ static int oz_send_isoc_frame(struct oz_pd *pd) return 0; skb = alloc_skb(total_size + OZ_ALLOCATED_SPACE(dev), GFP_ATOMIC); if (skb == NULL) { - oz_trace("Cannot alloc skb\n"); + oz_dbg(ON, "Cannot alloc skb\n"); oz_elt_info_free_chain(&pd->elt_buff, &list); return -1; } @@ -675,8 +675,8 @@ void oz_retire_tx_frames(struct oz_pd *pd, u8 lpn) diff = (lpn - (pkt_num & OZ_LAST_PN_MASK)) & OZ_LAST_PN_MASK; if ((diff > OZ_LAST_PN_HALF_CYCLE) || (pkt_num == 0)) break; - oz_trace2(OZ_TRACE_TX_FRAMES, "Releasing pkt_num= %u, nb= %d\n", - pkt_num, pd->nb_queued_frames); + oz_dbg(TX_FRAMES, "Releasing pkt_num= %u, nb= %d\n", + pkt_num, pd->nb_queued_frames); if (first == NULL) first = e; last = e; @@ -835,9 +835,8 @@ int oz_send_isoc_unit(struct oz_pd *pd, u8 ep_num, const u8 *data, int len) struct oz_tx_frame *isoc_unit = NULL; int nb = pd->nb_queued_isoc_frames; if (nb >= pd->isoc_latency) { - oz_trace2(OZ_TRACE_TX_FRAMES, - "Dropping ISOC Unit nb= %d\n", - nb); + oz_dbg(TX_FRAMES, "Dropping ISOC Unit nb= %d\n", + nb); goto out; } isoc_unit = oz_tx_frame_alloc(pd); @@ -849,9 +848,9 @@ int oz_send_isoc_unit(struct oz_pd *pd, u8 ep_num, const u8 *data, int len) list_add_tail(&isoc_unit->link, &pd->tx_queue); pd->nb_queued_isoc_frames++; spin_unlock_bh(&pd->tx_frame_lock); - oz_trace2(OZ_TRACE_TX_FRAMES, - "Added ISOC Frame to Tx Queue isoc_nb= %d, nb= %d\n", - pd->nb_queued_isoc_frames, pd->nb_queued_frames); + oz_dbg(TX_FRAMES, + "Added ISOC Frame to Tx Queue isoc_nb= %d, nb= %d\n", + pd->nb_queued_isoc_frames, pd->nb_queued_frames); return 0; } diff --git a/drivers/staging/ozwpan/ozproto.c b/drivers/staging/ozwpan/ozproto.c index 79ac7b51d5b25..494236ed4488a 100644 --- a/drivers/staging/ozwpan/ozproto.c +++ b/drivers/staging/ozwpan/ozproto.c @@ -10,6 +10,7 @@ #include #include #include +#include "ozdbg.h" #include "ozconfig.h" #include "ozprotocol.h" #include "ozeltbuf.h" @@ -124,7 +125,7 @@ static void oz_send_conn_rsp(struct oz_pd *pd, u8 status) body->session_id = pd->session_id; put_unaligned(cpu_to_le16(pd->total_apps), &body->apps); } - oz_trace("TX: OZ_ELT_CONNECT_RSP %d", status); + oz_dbg(ON, "TX: OZ_ELT_CONNECT_RSP %d", status); dev_queue_xmit(skb); return; } @@ -152,7 +153,7 @@ static void pd_set_keepalive(struct oz_pd *pd, u8 kalive) default: pd->keep_alive_j = 0; } - oz_trace("Keepalive = %lu jiffies\n", pd->keep_alive_j); + oz_dbg(ON, "Keepalive = %lu jiffies\n", pd->keep_alive_j); } /*------------------------------------------------------------------------------ * Context: softirq-serialized @@ -163,7 +164,7 @@ static void pd_set_presleep(struct oz_pd *pd, u8 presleep) pd->presleep_j = oz_ms_to_jiffies(presleep*100); else pd->presleep_j = OZ_PRESLEEP_TOUT_J; - oz_trace("Presleep time = %lu jiffies\n", pd->presleep_j); + oz_dbg(ON, "Presleep time = %lu jiffies\n", pd->presleep_j); } /*------------------------------------------------------------------------------ * Context: softirq-serialized @@ -210,7 +211,7 @@ static struct oz_pd *oz_connect_req(struct oz_pd *cur_pd, struct oz_elt *elt, dev_hold(net_dev); pd->net_dev = net_dev; } - oz_trace("Host vendor: %d\n", body->host_vendor); + oz_dbg(ON, "Host vendor: %d\n", body->host_vendor); pd->max_tx_size = OZ_MAX_TX_SIZE; pd->mode = body->mode; pd->pd_info = body->pd_info; @@ -234,8 +235,8 @@ static struct oz_pd *oz_connect_req(struct oz_pd *cur_pd, struct oz_elt *elt, } if (body->max_len_div16) pd->max_tx_size = ((u16)body->max_len_div16)<<4; - oz_trace("Max frame:%u Ms per isoc:%u\n", - pd->max_tx_size, pd->ms_per_isoc); + oz_dbg(ON, "Max frame:%u Ms per isoc:%u\n", + pd->max_tx_size, pd->ms_per_isoc); pd->max_stream_buffering = 3*1024; pd->timeout_time_j = jiffies + OZ_CONNECTION_TOUT_J; pd->pulse_period_j = OZ_QUANTUM_J; @@ -272,8 +273,8 @@ static struct oz_pd *oz_connect_req(struct oz_pd *cur_pd, struct oz_elt *elt, spin_unlock_bh(&g_polling_lock); oz_pd_set_state(pd, OZ_PD_S_CONNECTED); oz_timer_delete(pd, OZ_TIMER_STOP); - oz_trace("new_apps=0x%x total_apps=0x%x paused_apps=0x%x\n", - new_apps, pd->total_apps, pd->paused_apps); + oz_dbg(ON, "new_apps=0x%x total_apps=0x%x paused_apps=0x%x\n", + new_apps, pd->total_apps, pd->paused_apps); if (start_apps) { if (oz_services_start(pd, start_apps, 0)) rsp_status = OZ_STATUS_TOO_MANY_PDS; @@ -315,7 +316,7 @@ static void oz_add_farewell(struct oz_pd *pd, u8 ep_num, u8 index, f->ep_num = ep_num; f->index = index; memcpy(f->report, report, len); - oz_trace("RX: Adding farewell report\n"); + oz_dbg(ON, "RX: Adding farewell report\n"); spin_lock(&g_polling_lock); list_for_each_entry(f2, &pd->farewell_list, link) { if ((f2->ep_num == ep_num) && (f2->index == index)) { @@ -343,17 +344,16 @@ static void oz_rx_frame(struct sk_buff *skb) int dup = 0; u32 pkt_num; - oz_trace2(OZ_TRACE_RX_FRAMES, - "RX frame PN=0x%x LPN=0x%x control=0x%x\n", - oz_hdr->pkt_num, oz_hdr->last_pkt_num, oz_hdr->control); + oz_dbg(RX_FRAMES, "RX frame PN=0x%x LPN=0x%x control=0x%x\n", + oz_hdr->pkt_num, oz_hdr->last_pkt_num, oz_hdr->control); mac_hdr = skb_mac_header(skb); src_addr = &mac_hdr[ETH_ALEN] ; length = skb->len; /* Check the version field */ if (oz_get_prot_ver(oz_hdr->control) != OZ_PROTOCOL_VERSION) { - oz_trace("Incorrect protocol version: %d\n", - oz_get_prot_ver(oz_hdr->control)); + oz_dbg(ON, "Incorrect protocol version: %d\n", + oz_get_prot_ver(oz_hdr->control)); goto done; } @@ -368,12 +368,12 @@ static void oz_rx_frame(struct sk_buff *skb) pd->last_rx_pkt_num = pkt_num; } else { dup = 1; - oz_trace("Duplicate frame\n"); + oz_dbg(ON, "Duplicate frame\n"); } } if (pd && !dup && ((pd->mode & OZ_MODE_MASK) == OZ_MODE_TRIGGERED)) { - oz_trace2(OZ_TRACE_RX_FRAMES, "Received TRIGGER Frame\n"); + oz_dbg(RX_FRAMES, "Received TRIGGER Frame\n"); pd->last_sent_frame = &pd->tx_queue; if (oz_hdr->control & OZ_F_ACK) { /* Retire completed frames */ @@ -397,18 +397,18 @@ static void oz_rx_frame(struct sk_buff *skb) break; switch (elt->type) { case OZ_ELT_CONNECT_REQ: - oz_trace("RX: OZ_ELT_CONNECT_REQ\n"); + oz_dbg(ON, "RX: OZ_ELT_CONNECT_REQ\n"); pd = oz_connect_req(pd, elt, src_addr, skb->dev); break; case OZ_ELT_DISCONNECT: - oz_trace("RX: OZ_ELT_DISCONNECT\n"); + oz_dbg(ON, "RX: OZ_ELT_DISCONNECT\n"); if (pd) oz_pd_sleep(pd); break; case OZ_ELT_UPDATE_PARAM_REQ: { struct oz_elt_update_param *body = (struct oz_elt_update_param *)(elt + 1); - oz_trace("RX: OZ_ELT_UPDATE_PARAM_REQ\n"); + oz_dbg(ON, "RX: OZ_ELT_UPDATE_PARAM_REQ\n"); if (pd && (pd->state & OZ_PD_S_CONNECTED)) { spin_lock(&g_polling_lock); pd_set_keepalive(pd, body->keepalive); @@ -420,7 +420,7 @@ static void oz_rx_frame(struct sk_buff *skb) case OZ_ELT_FAREWELL_REQ: { struct oz_elt_farewell *body = (struct oz_elt_farewell *)(elt + 1); - oz_trace("RX: OZ_ELT_FAREWELL_REQ\n"); + oz_dbg(ON, "RX: OZ_ELT_FAREWELL_REQ\n"); oz_add_farewell(pd, body->ep_num, body->index, body->report, elt->length + 1 - sizeof(*body)); @@ -436,7 +436,7 @@ static void oz_rx_frame(struct sk_buff *skb) } break; default: - oz_trace("RX: Unknown elt %02x\n", elt->type); + oz_dbg(ON, "RX: Unknown elt %02x\n", elt->type); } elt = oz_next_elt(elt); } @@ -488,7 +488,7 @@ void oz_protocol_term(void) chain = chain->next; kfree(t); } - oz_trace("Protocol stopped\n"); + oz_dbg(ON, "Protocol stopped\n"); } /*------------------------------------------------------------------------------ * Context: softirq @@ -583,7 +583,7 @@ static void oz_protocol_timer_start(void) } g_timer_state = OZ_TIMER_SET; } else { - oz_trace("No queued timers\n"); + oz_dbg(ON, "No queued timers\n"); } spin_unlock_bh(&g_polling_lock); } @@ -795,16 +795,16 @@ void oz_binding_add(char *net_dev) binding->ptype.func = oz_pkt_recv; memcpy(binding->name, net_dev, OZ_MAX_BINDING_LEN); if (net_dev && *net_dev) { - oz_trace("Adding binding: %s\n", net_dev); + oz_dbg(ON, "Adding binding: %s\n", net_dev); binding->ptype.dev = dev_get_by_name(&init_net, net_dev); if (binding->ptype.dev == NULL) { - oz_trace("Netdev %s not found\n", net_dev); + oz_dbg(ON, "Netdev %s not found\n", net_dev); kfree(binding); binding = NULL; } } else { - oz_trace("Binding to all netcards\n"); + oz_dbg(ON, "Binding to all netcards\n"); binding->ptype.dev = NULL; } if (binding) { @@ -861,13 +861,13 @@ void oz_binding_remove(char *net_dev) { struct oz_binding *binding; struct oz_binding **link; - oz_trace("Removing binding: %s\n", net_dev); + oz_dbg(ON, "Removing binding: %s\n", net_dev); spin_lock_bh(&g_binding_lock); binding = g_binding; link = &g_binding; while (binding) { if (compare_binding_name(binding->name, net_dev)) { - oz_trace("Binding '%s' found\n", net_dev); + oz_dbg(ON, "Binding '%s' found\n", net_dev); *link = binding->next; break; } else { diff --git a/drivers/staging/ozwpan/ozproto.h b/drivers/staging/ozwpan/ozproto.h index 93bb4c0172e0b..9bb0a6abfc881 100644 --- a/drivers/staging/ozwpan/ozproto.h +++ b/drivers/staging/ozwpan/ozproto.h @@ -7,7 +7,7 @@ #define _OZPROTO_H #include -#include "ozconfig.h" +#include "ozdbg.h" #include "ozappif.h" #define OZ_ALLOCATED_SPACE(__x) (LL_RESERVED_SPACE(__x)+(__x)->needed_tailroom) diff --git a/drivers/staging/ozwpan/ozurbparanoia.c b/drivers/staging/ozwpan/ozurbparanoia.c index 55b9afbbe47b4..387d9dac5fe0f 100644 --- a/drivers/staging/ozwpan/ozurbparanoia.c +++ b/drivers/staging/ozwpan/ozurbparanoia.c @@ -4,6 +4,7 @@ * ----------------------------------------------------------------------------- */ #include +#include "ozdbg.h" #include "ozconfig.h" #ifdef WANT_URB_PARANOIA #include "ozurbparanoia.h" @@ -22,9 +23,9 @@ void oz_remember_urb(struct urb *urb) spin_lock_irqsave(&g_urb_mem_lock, irq_state); if (g_nb_urbs < OZ_MAX_URBS) { g_urb_memory[g_nb_urbs++] = urb; - oz_trace("%lu: urb up = %d %p\n", jiffies, g_nb_urbs, urb); + oz_dbg(ON, "%lu: urb up = %d %p\n", jiffies, g_nb_urbs, urb); } else { - oz_trace("ERROR urb buffer full\n"); + oz_dbg(ON, "ERROR urb buffer full\n"); } spin_unlock_irqrestore(&g_urb_mem_lock, irq_state); } @@ -42,8 +43,8 @@ int oz_forget_urb(struct urb *urb) if (--g_nb_urbs > i) memcpy(&g_urb_memory[i], &g_urb_memory[i+1], (g_nb_urbs - i) * sizeof(struct urb *)); - oz_trace("%lu: urb down = %d %p\n", - jiffies, g_nb_urbs, urb); + oz_dbg(ON, "%lu: urb down = %d %p\n", + jiffies, g_nb_urbs, urb); } } spin_unlock_irqrestore(&g_urb_mem_lock, irq_state); diff --git a/drivers/staging/ozwpan/ozusbsvc.c b/drivers/staging/ozwpan/ozusbsvc.c index 1676328782494..b4aebdbd715d3 100644 --- a/drivers/staging/ozwpan/ozusbsvc.c +++ b/drivers/staging/ozwpan/ozusbsvc.c @@ -18,6 +18,7 @@ #include #include #include +#include "ozdbg.h" #include "ozconfig.h" #include "ozprotocol.h" #include "ozeltbuf.h" @@ -53,10 +54,10 @@ int oz_usb_start(struct oz_pd *pd, int resume) struct oz_usb_ctx *usb_ctx; struct oz_usb_ctx *old_ctx; if (resume) { - oz_trace("USB service resumed.\n"); + oz_dbg(ON, "USB service resumed\n"); return 0; } - oz_trace("USB service started.\n"); + oz_dbg(ON, "USB service started\n"); /* Create a USB context in case we need one. If we find the PD already * has a USB context then we will destroy it. */ @@ -77,7 +78,7 @@ int oz_usb_start(struct oz_pd *pd, int resume) oz_usb_get(pd->app_ctx[OZ_APPID_USB-1]); spin_unlock_bh(&pd->app_lock[OZ_APPID_USB-1]); if (old_ctx) { - oz_trace("Already have USB context.\n"); + oz_dbg(ON, "Already have USB context\n"); kfree(usb_ctx); usb_ctx = old_ctx; } else if (usb_ctx) { @@ -95,7 +96,7 @@ int oz_usb_start(struct oz_pd *pd, int resume) } else { usb_ctx->hport = oz_hcd_pd_arrived(usb_ctx); if (usb_ctx->hport == NULL) { - oz_trace("USB hub returned null port.\n"); + oz_dbg(ON, "USB hub returned null port\n"); spin_lock_bh(&pd->app_lock[OZ_APPID_USB-1]); pd->app_ctx[OZ_APPID_USB-1] = NULL; spin_unlock_bh(&pd->app_lock[OZ_APPID_USB-1]); @@ -114,7 +115,7 @@ void oz_usb_stop(struct oz_pd *pd, int pause) { struct oz_usb_ctx *usb_ctx; if (pause) { - oz_trace("USB service paused.\n"); + oz_dbg(ON, "USB service paused\n"); return; } spin_lock_bh(&pd->app_lock[OZ_APPID_USB-1]); @@ -123,7 +124,7 @@ void oz_usb_stop(struct oz_pd *pd, int pause) spin_unlock_bh(&pd->app_lock[OZ_APPID_USB-1]); if (usb_ctx) { unsigned long tout = jiffies + HZ; - oz_trace("USB service stopping...\n"); + oz_dbg(ON, "USB service stopping...\n"); usb_ctx->stopped = 1; /* At this point the reference count on the usb context should * be 2 - one from when we created it and one from the hcd @@ -134,7 +135,7 @@ void oz_usb_stop(struct oz_pd *pd, int pause) while ((atomic_read(&usb_ctx->ref_count) > 2) && time_before(jiffies, tout)) ; - oz_trace("USB service stopped.\n"); + oz_dbg(ON, "USB service stopped\n"); oz_hcd_pd_departed(usb_ctx->hport); /* Release the reference taken in oz_usb_start. */ @@ -160,7 +161,7 @@ void oz_usb_put(void *hpd) { struct oz_usb_ctx *usb_ctx = (struct oz_usb_ctx *)hpd; if (atomic_dec_and_test(&usb_ctx->ref_count)) { - oz_trace("Dealloc USB context.\n"); + oz_dbg(ON, "Dealloc USB context\n"); oz_pd_put(usb_ctx->pd); kfree(usb_ctx); } @@ -195,7 +196,7 @@ int oz_usb_stream_create(void *hpd, u8 ep_num) { struct oz_usb_ctx *usb_ctx = (struct oz_usb_ctx *)hpd; struct oz_pd *pd = usb_ctx->pd; - oz_trace("oz_usb_stream_create(0x%x)\n", ep_num); + oz_dbg(ON, "%s: (0x%x)\n", __func__, ep_num); if (pd->mode & OZ_F_ISOC_NO_ELTS) { oz_isoc_stream_create(pd, ep_num); } else { @@ -217,7 +218,7 @@ int oz_usb_stream_delete(void *hpd, u8 ep_num) if (usb_ctx) { struct oz_pd *pd = usb_ctx->pd; if (pd) { - oz_trace("oz_usb_stream_delete(0x%x)\n", ep_num); + oz_dbg(ON, "%s: (0x%x)\n", __func__, ep_num); if (pd->mode & OZ_F_ISOC_NO_ELTS) { oz_isoc_stream_delete(pd, ep_num); } else { diff --git a/drivers/staging/ozwpan/ozusbsvc1.c b/drivers/staging/ozwpan/ozusbsvc1.c index 16e607875c38c..ab2c641dffe6b 100644 --- a/drivers/staging/ozwpan/ozusbsvc1.c +++ b/drivers/staging/ozwpan/ozusbsvc1.c @@ -13,6 +13,7 @@ #include #include #include +#include "ozdbg.h" #include "ozconfig.h" #include "ozprotocol.h" #include "ozeltbuf.h" @@ -62,12 +63,12 @@ int oz_usb_get_desc_req(void *hpd, u8 req_id, u8 req_type, u8 desc_type, struct oz_get_desc_req *body; struct oz_elt_buf *eb = &pd->elt_buff; struct oz_elt_info *ei = oz_elt_info_alloc(&pd->elt_buff); - oz_trace(" req_type = 0x%x\n", req_type); - oz_trace(" desc_type = 0x%x\n", desc_type); - oz_trace(" index = 0x%x\n", index); - oz_trace(" windex = 0x%x\n", windex); - oz_trace(" offset = 0x%x\n", offset); - oz_trace(" len = 0x%x\n", len); + oz_dbg(ON, " req_type = 0x%x\n", req_type); + oz_dbg(ON, " desc_type = 0x%x\n", desc_type); + oz_dbg(ON, " index = 0x%x\n", index); + oz_dbg(ON, " windex = 0x%x\n", windex); + oz_dbg(ON, " offset = 0x%x\n", offset); + oz_dbg(ON, " len = 0x%x\n", len); if (len > 200) len = 200; if (ei == NULL) @@ -376,7 +377,7 @@ void oz_usb_rx(struct oz_pd *pd, struct oz_elt *elt) u16 offs = le16_to_cpu(get_unaligned(&body->offset)); u16 total_size = le16_to_cpu(get_unaligned(&body->total_size)); - oz_trace("USB_REQ_GET_DESCRIPTOR - cnf\n"); + oz_dbg(ON, "USB_REQ_GET_DESCRIPTOR - cnf\n"); oz_hcd_get_desc_cnf(usb_ctx->hport, body->req_id, body->rcode, body->data, data_len, offs, total_size); @@ -425,7 +426,7 @@ void oz_usb_farewell(struct oz_pd *pd, u8 ep_num, u8 *data, u8 len) if (usb_ctx == NULL) return; /* Context has gone so nothing to do. */ if (!usb_ctx->stopped) { - oz_trace("Farewell indicated ep = 0x%x\n", ep_num); + oz_dbg(ON, "Farewell indicated ep = 0x%x\n", ep_num); oz_hcd_data_ind(usb_ctx->hport, ep_num, data, len); } oz_usb_put(usb_ctx); -- GitLab From 05f608f237dcc3c4e5188d054d9918cbfd2916c2 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Tue, 23 Jul 2013 13:45:01 +0100 Subject: [PATCH 088/942] staging: ozwpan: Remove old debug macro. Remove old oz_trace & oz_trace2 macro & related header files. Signed-off-by: Joe Perches Signed-off-by: Rupesh Gujare Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/Kbuild | 6 ++--- drivers/staging/ozwpan/ozcdev.c | 2 -- drivers/staging/ozwpan/ozconfig.h | 26 ------------------- drivers/staging/ozwpan/ozeltbuf.c | 2 -- drivers/staging/ozwpan/ozhcd.c | 7 +---- drivers/staging/ozwpan/ozmain.c | 7 +++-- drivers/staging/ozwpan/ozpd.c | 6 ++--- drivers/staging/ozwpan/ozproto.c | 4 +-- drivers/staging/ozwpan/oztrace.c | 36 -------------------------- drivers/staging/ozwpan/oztrace.h | 35 ------------------------- drivers/staging/ozwpan/ozurbparanoia.c | 5 ++-- drivers/staging/ozwpan/ozusbsvc.c | 4 +-- drivers/staging/ozwpan/ozusbsvc1.c | 2 -- 13 files changed, 17 insertions(+), 125 deletions(-) delete mode 100644 drivers/staging/ozwpan/ozconfig.h delete mode 100644 drivers/staging/ozwpan/oztrace.c delete mode 100644 drivers/staging/ozwpan/oztrace.h diff --git a/drivers/staging/ozwpan/Kbuild b/drivers/staging/ozwpan/Kbuild index 1766a268d5f60..29529c1a8e3c1 100644 --- a/drivers/staging/ozwpan/Kbuild +++ b/drivers/staging/ozwpan/Kbuild @@ -2,6 +2,7 @@ # Copyright (c) 2011 Ozmo Inc # Released under the GNU General Public License Version 2 (GPLv2). # ----------------------------------------------------------------------------- + obj-$(CONFIG_USB_WPAN_HCD) += ozwpan.o ozwpan-y := \ ozmain.o \ @@ -12,7 +13,4 @@ ozwpan-y := \ ozeltbuf.o \ ozproto.o \ ozcdev.o \ - ozurbparanoia.o \ - oztrace.o - - + ozurbparanoia.o diff --git a/drivers/staging/ozwpan/ozcdev.c b/drivers/staging/ozwpan/ozcdev.c index 87c3131f5b9ff..3e29760ba77e5 100644 --- a/drivers/staging/ozwpan/ozcdev.c +++ b/drivers/staging/ozwpan/ozcdev.c @@ -11,10 +11,8 @@ #include #include #include -#include "ozconfig.h" #include "ozdbg.h" #include "ozprotocol.h" -#include "oztrace.h" #include "ozappif.h" #include "ozeltbuf.h" #include "ozpd.h" diff --git a/drivers/staging/ozwpan/ozconfig.h b/drivers/staging/ozwpan/ozconfig.h deleted file mode 100644 index 087c322d2de00..0000000000000 --- a/drivers/staging/ozwpan/ozconfig.h +++ /dev/null @@ -1,26 +0,0 @@ -/* ----------------------------------------------------------------------------- - * Copyright (c) 2011 Ozmo Inc - * Released under the GNU General Public License Version 2 (GPLv2). - * ---------------------------------------------------------------------------*/ -#ifndef _OZCONFIG_H -#define _OZCONFIG_H - -/* #define WANT_TRACE */ -#ifdef WANT_TRACE -#define WANT_VERBOSE_TRACE -#endif /* #ifdef WANT_TRACE */ -/* #define WANT_URB_PARANOIA */ - -/* #define WANT_PRE_2_6_39 */ - -/* These defines determine what verbose trace is displayed. */ -#ifdef WANT_VERBOSE_TRACE -/* #define WANT_TRACE_STREAM */ -/* #define WANT_TRACE_URB */ -/* #define WANT_TRACE_CTRL_DETAIL */ -#define WANT_TRACE_HUB -/* #define WANT_TRACE_RX_FRAMES */ -/* #define WANT_TRACE_TX_FRAMES */ -#endif /* WANT_VERBOSE_TRACE */ - -#endif /* _OZCONFIG_H */ diff --git a/drivers/staging/ozwpan/ozeltbuf.c b/drivers/staging/ozwpan/ozeltbuf.c index bf280aabe3837..5e98aeb8bc6bf 100644 --- a/drivers/staging/ozwpan/ozeltbuf.c +++ b/drivers/staging/ozwpan/ozeltbuf.c @@ -6,12 +6,10 @@ #include #include #include -#include "ozconfig.h" #include "ozdbg.h" #include "ozprotocol.h" #include "ozeltbuf.h" #include "ozpd.h" -#include "oztrace.h" /*------------------------------------------------------------------------------ */ diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c index fece2dab3ae99..6b16bfc4cdd87 100644 --- a/drivers/staging/ozwpan/ozhcd.c +++ b/drivers/staging/ozwpan/ozhcd.c @@ -32,9 +32,7 @@ #include "linux/usb/hcd.h" #include #include "ozdbg.h" -#include "ozconfig.h" #include "ozusbif.h" -#include "oztrace.h" #include "ozurbparanoia.h" #include "ozhcd.h" /*------------------------------------------------------------------------------ @@ -797,7 +795,6 @@ void oz_hcd_get_desc_cnf(void *hport, u8 req_id, int status, const u8 *desc, /*------------------------------------------------------------------------------ * Context: softirq */ -#ifdef WANT_TRACE static void oz_display_conf_type(u8 t) { switch (t) { @@ -836,9 +833,7 @@ static void oz_display_conf_type(u8 t) break; } } -#else -#define oz_display_conf_type(__x) -#endif /* WANT_TRACE */ + /*------------------------------------------------------------------------------ * Context: softirq */ diff --git a/drivers/staging/ozwpan/ozmain.c b/drivers/staging/ozwpan/ozmain.c index 51fe9e98c3516..e26d6bee44d23 100644 --- a/drivers/staging/ozwpan/ozmain.c +++ b/drivers/staging/ozwpan/ozmain.c @@ -3,6 +3,7 @@ * Released under the GNU General Public License Version 2 (GPLv2). * ----------------------------------------------------------------------------- */ + #include #include #include @@ -10,11 +11,13 @@ #include #include #include -#include "ozconfig.h" +#include "ozdbg.h" #include "ozpd.h" #include "ozproto.h" #include "ozcdev.h" -#include "oztrace.h" + +unsigned int oz_dbg_mask = OZ_DEFAULT_DBG_MASK; + /*------------------------------------------------------------------------------ * The name of the 802.11 mac device. Empty string is the default value but a * value can be supplied as a parameter to the module. An empty string means diff --git a/drivers/staging/ozwpan/ozpd.c b/drivers/staging/ozwpan/ozpd.c index 28adbb47764ad..8a253ac07c266 100644 --- a/drivers/staging/ozwpan/ozpd.c +++ b/drivers/staging/ozwpan/ozpd.c @@ -3,6 +3,7 @@ * Released under the GNU General Public License Version 2 (GPLv2). * ----------------------------------------------------------------------------- */ + #include #include #include @@ -10,17 +11,16 @@ #include #include #include "ozdbg.h" -#include "ozconfig.h" #include "ozprotocol.h" #include "ozeltbuf.h" #include "ozpd.h" #include "ozproto.h" -#include "oztrace.h" #include "ozcdev.h" #include "ozusbsvc.h" #include #include #include + /*------------------------------------------------------------------------------ */ #define OZ_MAX_TX_POOL_SIZE 6 @@ -121,7 +121,6 @@ static void oz_def_app_rx(struct oz_pd *pd, struct oz_elt *elt) void oz_pd_set_state(struct oz_pd *pd, unsigned state) { pd->state = state; -#ifdef WANT_TRACE switch (state) { case OZ_PD_S_IDLE: oz_pd_dbg(pd, ON, "PD State: OZ_PD_S_IDLE\n"); @@ -136,7 +135,6 @@ void oz_pd_set_state(struct oz_pd *pd, unsigned state) oz_pd_dbg(pd, ON, "PD State: OZ_PD_S_SLEEP\n"); break; } -#endif /* WANT_TRACE */ } /*------------------------------------------------------------------------------ * Context: softirq or process diff --git a/drivers/staging/ozwpan/ozproto.c b/drivers/staging/ozwpan/ozproto.c index 494236ed4488a..760761df3845c 100644 --- a/drivers/staging/ozwpan/ozproto.c +++ b/drivers/staging/ozwpan/ozproto.c @@ -3,6 +3,7 @@ * Released under the GNU General Public License Version 2 (GPLv2). * ----------------------------------------------------------------------------- */ + #include #include #include @@ -11,13 +12,12 @@ #include #include #include "ozdbg.h" -#include "ozconfig.h" #include "ozprotocol.h" #include "ozeltbuf.h" #include "ozpd.h" #include "ozproto.h" #include "ozusbsvc.h" -#include "oztrace.h" + #include "ozappif.h" #include #include diff --git a/drivers/staging/ozwpan/oztrace.c b/drivers/staging/ozwpan/oztrace.c deleted file mode 100644 index 353ead24fd7d0..0000000000000 --- a/drivers/staging/ozwpan/oztrace.c +++ /dev/null @@ -1,36 +0,0 @@ -/* ----------------------------------------------------------------------------- - * Copyright (c) 2011 Ozmo Inc - * Released under the GNU General Public License Version 2 (GPLv2). - * ----------------------------------------------------------------------------- - */ -#include "ozconfig.h" -#include "oztrace.h" - -#ifdef WANT_VERBOSE_TRACE -unsigned long trace_flags = - 0 -#ifdef WANT_TRACE_STREAM - | OZ_TRACE_STREAM -#endif /* WANT_TRACE_STREAM */ -#ifdef WANT_TRACE_URB - | OZ_TRACE_URB -#endif /* WANT_TRACE_URB */ - -#ifdef WANT_TRACE_CTRL_DETAIL - | OZ_TRACE_CTRL_DETAIL -#endif /* WANT_TRACE_CTRL_DETAIL */ - -#ifdef WANT_TRACE_HUB - | OZ_TRACE_HUB -#endif /* WANT_TRACE_HUB */ - -#ifdef WANT_TRACE_RX_FRAMES - | OZ_TRACE_RX_FRAMES -#endif /* WANT_TRACE_RX_FRAMES */ - -#ifdef WANT_TRACE_TX_FRAMES - | OZ_TRACE_TX_FRAMES -#endif /* WANT_TRACE_TX_FRAMES */ - ; -#endif /* WANT_VERBOSE_TRACE */ - diff --git a/drivers/staging/ozwpan/oztrace.h b/drivers/staging/ozwpan/oztrace.h deleted file mode 100644 index 8293b24c5a779..0000000000000 --- a/drivers/staging/ozwpan/oztrace.h +++ /dev/null @@ -1,35 +0,0 @@ -/* ----------------------------------------------------------------------------- - * Copyright (c) 2011 Ozmo Inc - * Released under the GNU General Public License Version 2 (GPLv2). - * ----------------------------------------------------------------------------- - */ -#ifndef _OZTRACE_H_ -#define _OZTRACE_H_ -#include "ozconfig.h" - -#define TRACE_PREFIX KERN_ALERT "OZWPAN: " - -#ifdef WANT_TRACE -#define oz_trace(...) printk(TRACE_PREFIX __VA_ARGS__) -#ifdef WANT_VERBOSE_TRACE -extern unsigned long trace_flags; -#define oz_trace2(_flag, ...) \ - do { if (trace_flags & _flag) printk(TRACE_PREFIX __VA_ARGS__); \ - } while (0) -#else -#define oz_trace2(...) -#endif /* #ifdef WANT_VERBOSE_TRACE */ -#else -#define oz_trace(...) -#define oz_trace2(...) -#endif /* #ifdef WANT_TRACE */ - -#define OZ_TRACE_STREAM 0x1 -#define OZ_TRACE_URB 0x2 -#define OZ_TRACE_CTRL_DETAIL 0x4 -#define OZ_TRACE_HUB 0x8 -#define OZ_TRACE_RX_FRAMES 0x10 -#define OZ_TRACE_TX_FRAMES 0x20 - -#endif /* Sentry */ - diff --git a/drivers/staging/ozwpan/ozurbparanoia.c b/drivers/staging/ozwpan/ozurbparanoia.c index 387d9dac5fe0f..366584b75767c 100644 --- a/drivers/staging/ozwpan/ozurbparanoia.c +++ b/drivers/staging/ozwpan/ozurbparanoia.c @@ -5,10 +5,11 @@ */ #include #include "ozdbg.h" -#include "ozconfig.h" + #ifdef WANT_URB_PARANOIA + #include "ozurbparanoia.h" -#include "oztrace.h" + /*----------------------------------------------------------------------------- */ #define OZ_MAX_URBS 1000 diff --git a/drivers/staging/ozwpan/ozusbsvc.c b/drivers/staging/ozwpan/ozusbsvc.c index b4aebdbd715d3..816cac980586e 100644 --- a/drivers/staging/ozwpan/ozusbsvc.c +++ b/drivers/staging/ozwpan/ozusbsvc.c @@ -10,6 +10,7 @@ * The implementation of this service uses ozhcd.c to implement a USB HCD. * ----------------------------------------------------------------------------- */ + #include #include #include @@ -19,15 +20,14 @@ #include #include #include "ozdbg.h" -#include "ozconfig.h" #include "ozprotocol.h" #include "ozeltbuf.h" #include "ozpd.h" #include "ozproto.h" #include "ozusbif.h" #include "ozhcd.h" -#include "oztrace.h" #include "ozusbsvc.h" + /*------------------------------------------------------------------------------ * This is called once when the driver is loaded to initialise the USB service. * Context: process diff --git a/drivers/staging/ozwpan/ozusbsvc1.c b/drivers/staging/ozwpan/ozusbsvc1.c index ab2c641dffe6b..50d21bf4f927b 100644 --- a/drivers/staging/ozwpan/ozusbsvc1.c +++ b/drivers/staging/ozwpan/ozusbsvc1.c @@ -14,14 +14,12 @@ #include #include #include "ozdbg.h" -#include "ozconfig.h" #include "ozprotocol.h" #include "ozeltbuf.h" #include "ozpd.h" #include "ozproto.h" #include "ozusbif.h" #include "ozhcd.h" -#include "oztrace.h" #include "ozusbsvc.h" /*------------------------------------------------------------------------------ */ -- GitLab From 155c71435cba5ac6761999011bc729cbd94cdac7 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Tue, 23 Jul 2013 13:45:02 +0100 Subject: [PATCH 089/942] staging: ozwpan: Convert macro to function. Replace macro with inline function. Signed-off-by: Joe Perches Signed-off-by: Rupesh Gujare Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozurbparanoia.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/ozwpan/ozurbparanoia.h b/drivers/staging/ozwpan/ozurbparanoia.h index 00f5a3a81bc88..5080ea76f5073 100644 --- a/drivers/staging/ozwpan/ozurbparanoia.h +++ b/drivers/staging/ozwpan/ozurbparanoia.h @@ -10,8 +10,8 @@ void oz_remember_urb(struct urb *urb); int oz_forget_urb(struct urb *urb); #else -#define oz_remember_urb(__x) -#define oz_forget_urb(__x) 0 +static inline void oz_remember_urb(struct urb *urb) {} +static inline int oz_forget_urb(struct urb *urb) { return 0; } #endif /* WANT_URB_PARANOIA */ -- GitLab From ba628ad0baec436e9c0774a8b2125a860cc7742a Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Tue, 23 Jul 2013 13:45:03 +0100 Subject: [PATCH 090/942] staging: ozwpan: Rename Kbuild to Makefile Rename Kbuild to usual Makefile, consistent with Kernel build structure. Signed-off-by: Joe Perches Signed-off-by: Rupesh Gujare Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/{Kbuild => Makefile} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename drivers/staging/ozwpan/{Kbuild => Makefile} (100%) diff --git a/drivers/staging/ozwpan/Kbuild b/drivers/staging/ozwpan/Makefile similarity index 100% rename from drivers/staging/ozwpan/Kbuild rename to drivers/staging/ozwpan/Makefile -- GitLab From 397334fc2be6a7e2f77474bd2b24880efea007bf Mon Sep 17 00:00:00 2001 From: Serban Constantinescu Date: Thu, 4 Jul 2013 10:54:43 +0100 Subject: [PATCH 091/942] staging: android: binder: modify struct binder_write_read to use size_t MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change mirrors the userspace operation where struct binder_write_read members that specify the buffer size and consumed size are size_t elements. The patch also fixes the binder_thread_write() and binder_thread_read() functions prototypes to conform with the definition of binder_write_read. The changes do not affect existing 32bit ABI. Signed-off-by: Serban Constantinescu Acked-by: Arve HjønnevÃ¥g Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/binder.c | 10 +++++----- drivers/staging/android/binder.h | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/android/binder.c b/drivers/staging/android/binder.c index 119d486a5cf7f..787fc921b1e7c 100644 --- a/drivers/staging/android/binder.c +++ b/drivers/staging/android/binder.c @@ -1701,7 +1701,7 @@ static void binder_transaction(struct binder_proc *proc, } int binder_thread_write(struct binder_proc *proc, struct binder_thread *thread, - void __user *buffer, int size, signed long *consumed) + void __user *buffer, size_t size, size_t *consumed) { uint32_t cmd; void __user *ptr = buffer + *consumed; @@ -2081,8 +2081,8 @@ static int binder_has_thread_work(struct binder_thread *thread) static int binder_thread_read(struct binder_proc *proc, struct binder_thread *thread, - void __user *buffer, int size, - signed long *consumed, int non_block) + void __user *buffer, size_t size, + size_t *consumed, int non_block) { void __user *ptr = buffer + *consumed; void __user *end = buffer + size; @@ -2579,7 +2579,7 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) goto err; } binder_debug(BINDER_DEBUG_READ_WRITE, - "%d:%d write %ld at %08lx, read %ld at %08lx\n", + "%d:%d write %zd at %08lx, read %zd at %08lx\n", proc->pid, thread->pid, bwr.write_size, bwr.write_buffer, bwr.read_size, bwr.read_buffer); @@ -2605,7 +2605,7 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) } } binder_debug(BINDER_DEBUG_READ_WRITE, - "%d:%d wrote %ld of %ld, read return %ld of %ld\n", + "%d:%d wrote %zd of %zd, read return %zd of %zd\n", proc->pid, thread->pid, bwr.write_consumed, bwr.write_size, bwr.read_consumed, bwr.read_size); if (copy_to_user(ubuf, &bwr, sizeof(bwr))) { diff --git a/drivers/staging/android/binder.h b/drivers/staging/android/binder.h index dbe81ceca1bdd..edab2491a1b75 100644 --- a/drivers/staging/android/binder.h +++ b/drivers/staging/android/binder.h @@ -67,11 +67,11 @@ struct flat_binder_object { */ struct binder_write_read { - signed long write_size; /* bytes to write */ - signed long write_consumed; /* bytes consumed by driver */ + size_t write_size; /* bytes to write */ + size_t write_consumed; /* bytes consumed by driver */ unsigned long write_buffer; - signed long read_size; /* bytes to read */ - signed long read_consumed; /* bytes consumed by driver */ + size_t read_size; /* bytes to read */ + size_t read_consumed; /* bytes consumed by driver */ unsigned long read_buffer; }; -- GitLab From a9350fc859ae3f1db7f2efd55c7a3e0d09a4098d Mon Sep 17 00:00:00 2001 From: Serban Constantinescu Date: Thu, 4 Jul 2013 10:54:44 +0100 Subject: [PATCH 092/942] staging: android: binder: fix BINDER_SET_MAX_THREADS declaration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change will fix the BINDER_SET_MAX_THREADS ioctl to use __u32 instead of size_t for setting the max threads. Thus using the same handler for 32 and 64bit kernels. This value is stored internally in struct binder_proc and set to 15 on open_binder() in the libbinder API(thus no need for a 64bit size_t on 64bit platforms). The change does not affect existing 32bit ABI. Signed-off-by: Serban Constantinescu Acked-by: Arve HjønnevÃ¥g Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/binder.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/android/binder.h b/drivers/staging/android/binder.h index edab2491a1b75..6515dd2f3552e 100644 --- a/drivers/staging/android/binder.h +++ b/drivers/staging/android/binder.h @@ -86,7 +86,7 @@ struct binder_version { #define BINDER_WRITE_READ _IOWR('b', 1, struct binder_write_read) #define BINDER_SET_IDLE_TIMEOUT _IOW('b', 3, __s64) -#define BINDER_SET_MAX_THREADS _IOW('b', 5, size_t) +#define BINDER_SET_MAX_THREADS _IOW('b', 5, __u32) #define BINDER_SET_IDLE_PRIORITY _IOW('b', 6, __s32) #define BINDER_SET_CONTEXT_MGR _IOW('b', 7, __s32) #define BINDER_THREAD_EXIT _IOW('b', 8, __s32) -- GitLab From fc56f2ecf091d774c18ad0d470c62c6818fa32a3 Mon Sep 17 00:00:00 2001 From: Serban Constantinescu Date: Thu, 4 Jul 2013 10:54:45 +0100 Subject: [PATCH 093/942] staging: android: binder: fix BC_FREE_BUFFER ioctl declaration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BinderDriverCommands mirror the ioctl usage. Thus the size of the structure passed through the interface should be used to generate the ioctl No. The change reflects the type being passed from the user space-a pointer to a binder_buffer. This change should not affect the existing 32bit user space since BC_FREE_BUFFER is computed as: #define _IOW(type,nr,size) \ ((type) << _IOC_TYPESHIFT) | \ ((nr) << _IOC_NRSHIFT) | \ ((size) << _IOC_SIZESHIFT)) and for a 32bit compiler BC_FREE_BUFFER will have the same computed value. This change will also ease our work in differentiating BC_FREE_BUFFER from COMPAT_BC_FREE_BUFFER. The change does not affect existing 32bit ABI. Signed-off-by: Serban Constantinescu Acked-by: Arve HjønnevÃ¥g Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/binder.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/android/binder.h b/drivers/staging/android/binder.h index 6515dd2f3552e..b55bba9ad92b1 100644 --- a/drivers/staging/android/binder.h +++ b/drivers/staging/android/binder.h @@ -265,7 +265,7 @@ enum binder_driver_command_protocol { * Else you have acquired a primary reference on the object. */ - BC_FREE_BUFFER = _IOW('c', 3, int), + BC_FREE_BUFFER = _IOW('c', 3, void *), /* * void *: ptr to transaction data received on a read */ -- GitLab From ec35e852dc9de9809f88ff397d7a611208880f9f Mon Sep 17 00:00:00 2001 From: Serban Constantinescu Date: Thu, 4 Jul 2013 10:54:46 +0100 Subject: [PATCH 094/942] staging: android: binder: fix alignment issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Android userspace aligns the data written to the binder buffers to 4bytes. Thus for 32bit platforms or 64bit platforms running an 32bit Android userspace we can have a buffer looking like this: platform buffer(binder_cmd pointer) size 32/32 32b 32b 8B 64/32 32b 64b 12B 64/64 32b 64b 12B Thus the kernel needs to check that the buffer size is aligned to 4bytes not to (void *) that will be 8bytes on 64bit machines. The change does not affect existing 32bit ABI. Signed-off-by: Serban Constantinescu Acked-by: Arve HjønnevÃ¥g Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/binder.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/android/binder.c b/drivers/staging/android/binder.c index 787fc921b1e7c..c6813ea15f403 100644 --- a/drivers/staging/android/binder.c +++ b/drivers/staging/android/binder.c @@ -1248,7 +1248,7 @@ static void binder_transaction_buffer_release(struct binder_proc *proc, struct flat_binder_object *fp; if (*offp > buffer->data_size - sizeof(*fp) || buffer->data_size < sizeof(*fp) || - !IS_ALIGNED(*offp, sizeof(void *))) { + !IS_ALIGNED(*offp, sizeof(u32))) { pr_err("transaction release %d bad offset %zd, size %zd\n", debug_id, *offp, buffer->data_size); continue; @@ -1497,7 +1497,7 @@ static void binder_transaction(struct binder_proc *proc, struct flat_binder_object *fp; if (*offp > t->buffer->data_size - sizeof(*fp) || t->buffer->data_size < sizeof(*fp) || - !IS_ALIGNED(*offp, sizeof(void *))) { + !IS_ALIGNED(*offp, sizeof(u32))) { binder_user_error("%d:%d got transaction with invalid offset, %zd\n", proc->pid, thread->pid, *offp); return_error = BR_FAILED_REPLY; -- GitLab From eecddef594f9eb159040160b929642f16a07387f Mon Sep 17 00:00:00 2001 From: Serban Constantinescu Date: Thu, 4 Jul 2013 10:54:47 +0100 Subject: [PATCH 095/942] staging: android: binder: replace types with portable ones MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since this driver is meant to be used on different types of processors and a portable driver should specify the size a variable expects to be this patch changes the types used throughout the binder interface. We use "userspace" types since this header will be exported and used by the Android filesystem. The patch does not change in any way the functionality of the binder driver. Signed-off-by: Serban Constantinescu Acked-by: Arve HjønnevÃ¥g Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/binder.h | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/staging/android/binder.h b/drivers/staging/android/binder.h index b55bba9ad92b1..dadfce028c533 100644 --- a/drivers/staging/android/binder.h +++ b/drivers/staging/android/binder.h @@ -123,10 +123,10 @@ struct binder_transaction_data { void *ptr; /* target descriptor of return transaction */ } target; void *cookie; /* target object cookie */ - unsigned int code; /* transaction command */ + __u32 code; /* transaction command */ /* General information about the transaction. */ - unsigned int flags; + __u32 flags; pid_t sender_pid; uid_t sender_euid; size_t data_size; /* number of bytes of data */ @@ -143,7 +143,7 @@ struct binder_transaction_data { /* offsets from buffer to flat_binder_object structs */ const void __user *offsets; } ptr; - uint8_t buf[8]; + __u8 buf[8]; } data; }; @@ -153,18 +153,18 @@ struct binder_ptr_cookie { }; struct binder_pri_desc { - int priority; - int desc; + __s32 priority; + __s32 desc; }; struct binder_pri_ptr_cookie { - int priority; + __s32 priority; void *ptr; void *cookie; }; enum binder_driver_return_protocol { - BR_ERROR = _IOR('r', 0, int), + BR_ERROR = _IOR('r', 0, __s32), /* * int: error code */ @@ -178,7 +178,7 @@ enum binder_driver_return_protocol { * binder_transaction_data: the received command. */ - BR_ACQUIRE_RESULT = _IOR('r', 4, int), + BR_ACQUIRE_RESULT = _IOR('r', 4, __s32), /* * not currently supported * int: 0 if the last bcATTEMPT_ACQUIRE was not successful. @@ -258,7 +258,7 @@ enum binder_driver_command_protocol { * binder_transaction_data: the sent command. */ - BC_ACQUIRE_RESULT = _IOW('c', 2, int), + BC_ACQUIRE_RESULT = _IOW('c', 2, __s32), /* * not currently supported * int: 0 if the last BR_ATTEMPT_ACQUIRE was not successful. @@ -270,10 +270,10 @@ enum binder_driver_command_protocol { * void *: ptr to transaction data received on a read */ - BC_INCREFS = _IOW('c', 4, int), - BC_ACQUIRE = _IOW('c', 5, int), - BC_RELEASE = _IOW('c', 6, int), - BC_DECREFS = _IOW('c', 7, int), + BC_INCREFS = _IOW('c', 4, __u32), + BC_ACQUIRE = _IOW('c', 5, __u32), + BC_RELEASE = _IOW('c', 6, __u32), + BC_DECREFS = _IOW('c', 7, __u32), /* * int: descriptor */ -- GitLab From 64dcfe6b84d4104d93e4baf2b5a0b3e7f2e4cc30 Mon Sep 17 00:00:00 2001 From: Serban Constantinescu Date: Thu, 4 Jul 2013 10:54:48 +0100 Subject: [PATCH 096/942] staging: android: binder: fix binder interface for 64bit compat layer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The changes in this patch will fix the binder interface for use on 64bit machines and stand as the base of the 64bit compat support. The changes apply to the structures that are passed between the kernel and userspace. Most of the changes applied mirror the change to struct binder_version where there is no need for a 64bit wide protocol_version(on 64bit machines). The change inlines with the existing 32bit userspace(the structure has the same size) and simplifies the compat layer such that the same handler can service the BINDER_VERSION ioctl. Other changes make use of kernel types as well as user-exportable ones and fix format specifier issues. The changes do not affect existing 32bit ABI. Signed-off-by: Serban Constantinescu Acked-by: Arve HjønnevÃ¥g Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/binder.c | 20 ++++++++++---------- drivers/staging/android/binder.h | 12 ++++++------ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/staging/android/binder.c b/drivers/staging/android/binder.c index c6813ea15f403..98ac020bf912f 100644 --- a/drivers/staging/android/binder.c +++ b/drivers/staging/android/binder.c @@ -1272,7 +1272,7 @@ static void binder_transaction_buffer_release(struct binder_proc *proc, case BINDER_TYPE_WEAK_HANDLE: { struct binder_ref *ref = binder_get_ref(proc, fp->handle); if (ref == NULL) { - pr_err("transaction release %d bad handle %ld\n", + pr_err("transaction release %d bad handle %d\n", debug_id, fp->handle); break; } @@ -1284,13 +1284,13 @@ static void binder_transaction_buffer_release(struct binder_proc *proc, case BINDER_TYPE_FD: binder_debug(BINDER_DEBUG_TRANSACTION, - " fd %ld\n", fp->handle); + " fd %d\n", fp->handle); if (failed_at) task_close_fd(proc, fp->handle); break; default: - pr_err("transaction release %d bad object type %lx\n", + pr_err("transaction release %d bad object type %x\n", debug_id, fp->type); break; } @@ -1548,7 +1548,7 @@ static void binder_transaction(struct binder_proc *proc, case BINDER_TYPE_WEAK_HANDLE: { struct binder_ref *ref = binder_get_ref(proc, fp->handle); if (ref == NULL) { - binder_user_error("%d:%d got transaction with invalid handle, %ld\n", + binder_user_error("%d:%d got transaction with invalid handle, %d\n", proc->pid, thread->pid, fp->handle); return_error = BR_FAILED_REPLY; @@ -1591,13 +1591,13 @@ static void binder_transaction(struct binder_proc *proc, if (reply) { if (!(in_reply_to->flags & TF_ACCEPT_FDS)) { - binder_user_error("%d:%d got reply with fd, %ld, but target does not allow fds\n", + binder_user_error("%d:%d got reply with fd, %d, but target does not allow fds\n", proc->pid, thread->pid, fp->handle); return_error = BR_FAILED_REPLY; goto err_fd_not_allowed; } } else if (!target_node->accept_fds) { - binder_user_error("%d:%d got transaction with fd, %ld, but target does not allow fds\n", + binder_user_error("%d:%d got transaction with fd, %d, but target does not allow fds\n", proc->pid, thread->pid, fp->handle); return_error = BR_FAILED_REPLY; goto err_fd_not_allowed; @@ -1605,7 +1605,7 @@ static void binder_transaction(struct binder_proc *proc, file = fget(fp->handle); if (file == NULL) { - binder_user_error("%d:%d got transaction with invalid fd, %ld\n", + binder_user_error("%d:%d got transaction with invalid fd, %d\n", proc->pid, thread->pid, fp->handle); return_error = BR_FAILED_REPLY; goto err_fget_failed; @@ -1619,13 +1619,13 @@ static void binder_transaction(struct binder_proc *proc, task_fd_install(target_proc, target_fd, file); trace_binder_transaction_fd(t, fp->handle, target_fd); binder_debug(BINDER_DEBUG_TRANSACTION, - " fd %ld -> %d\n", fp->handle, target_fd); + " fd %d -> %d\n", fp->handle, target_fd); /* TODO: fput? */ fp->handle = target_fd; } break; default: - binder_user_error("%d:%d got transaction with invalid object type, %lx\n", + binder_user_error("%d:%d got transaction with invalid object type, %x\n", proc->pid, thread->pid, fp->type); return_error = BR_FAILED_REPLY; goto err_bad_object_type; @@ -2579,7 +2579,7 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) goto err; } binder_debug(BINDER_DEBUG_READ_WRITE, - "%d:%d write %zd at %08lx, read %zd at %08lx\n", + "%d:%d write %zd at %016lx, read %zd at %016lx\n", proc->pid, thread->pid, bwr.write_size, bwr.write_buffer, bwr.read_size, bwr.read_buffer); diff --git a/drivers/staging/android/binder.h b/drivers/staging/android/binder.h index dadfce028c533..cbe3451680671 100644 --- a/drivers/staging/android/binder.h +++ b/drivers/staging/android/binder.h @@ -48,13 +48,13 @@ enum { */ struct flat_binder_object { /* 8 bytes for large_flat_header. */ - unsigned long type; - unsigned long flags; + __u32 type; + __u32 flags; /* 8 bytes of data. */ union { void __user *binder; /* local object */ - signed long handle; /* remote object */ + __u32 handle; /* remote object */ }; /* extra data associated with local object */ @@ -78,7 +78,7 @@ struct binder_write_read { /* Use with BINDER_VERSION, driver fills in fields. */ struct binder_version { /* driver protocol version -- increment with incompatible change */ - signed long protocol_version; + __s32 protocol_version; }; /* This is the current protocol version. */ @@ -119,7 +119,7 @@ struct binder_transaction_data { * identifying the target and contents of the transaction. */ union { - size_t handle; /* target descriptor of command transaction */ + __u32 handle; /* target descriptor of command transaction */ void *ptr; /* target descriptor of return transaction */ } target; void *cookie; /* target object cookie */ @@ -154,7 +154,7 @@ struct binder_ptr_cookie { struct binder_pri_desc { __s32 priority; - __s32 desc; + __u32 desc; }; struct binder_pri_ptr_cookie { -- GitLab From efb39e4eb3f117925d53c88c63e46131f0efc6da Mon Sep 17 00:00:00 2001 From: Chad Williamson Date: Tue, 25 Jun 2013 18:59:22 -0500 Subject: [PATCH 097/942] Staging: silicom: remove the bpctl_dev_t typdef Replace the bpctl_dev_t typdef in bpctl_mod.c with struct bpctl_dev for coding style compliance. Signed-off-by: Chad Williamson Signed-off-by: Greg Kroah-Hartman --- drivers/staging/silicom/bpctl_mod.c | 552 ++++++++++++++-------------- 1 file changed, 276 insertions(+), 276 deletions(-) diff --git a/drivers/staging/silicom/bpctl_mod.c b/drivers/staging/silicom/bpctl_mod.c index 48b9fb110acd2..4689076fb7d18 100644 --- a/drivers/staging/silicom/bpctl_mod.c +++ b/drivers/staging/silicom/bpctl_mod.c @@ -59,7 +59,7 @@ struct bypass_pfs_sd { struct proc_dir_entry *bypass_entry; }; -typedef struct _bpctl_dev { +struct bpctl_dev { char *name; char *desc; struct pci_dev *pdev; /* PCI device */ @@ -102,26 +102,26 @@ typedef struct _bpctl_dev { char *bp_tx_data; struct bypass_pfs_sd bypass_pfs_set; -} bpctl_dev_t; +}; -static bpctl_dev_t *bpctl_dev_arr; +static struct bpctl_dev *bpctl_dev_arr; static struct semaphore bpctl_sema; static int device_num; static int get_dev_idx(int ifindex); -static bpctl_dev_t *get_master_port_fn(bpctl_dev_t *pbpctl_dev); -static int disc_status(bpctl_dev_t *pbpctl_dev); -static int bypass_status(bpctl_dev_t *pbpctl_dev); -static int wdt_timer(bpctl_dev_t *pbpctl_dev, int *time_left); -static bpctl_dev_t *get_status_port_fn(bpctl_dev_t *pbpctl_dev); +static struct bpctl_dev *get_master_port_fn(struct bpctl_dev *pbpctl_dev); +static int disc_status(struct bpctl_dev *pbpctl_dev); +static int bypass_status(struct bpctl_dev *pbpctl_dev); +static int wdt_timer(struct bpctl_dev *pbpctl_dev, int *time_left); +static struct bpctl_dev *get_status_port_fn(struct bpctl_dev *pbpctl_dev); static void if_scan_init(void); -int bypass_proc_create_dev_sd(bpctl_dev_t *pbp_device_block); -int bypass_proc_remove_dev_sd(bpctl_dev_t *pbp_device_block); +int bypass_proc_create_dev_sd(struct bpctl_dev *pbp_device_block); +int bypass_proc_remove_dev_sd(struct bpctl_dev *pbp_device_block); int bp_proc_create(void); -int is_bypass_fn(bpctl_dev_t *pbpctl_dev); +int is_bypass_fn(struct bpctl_dev *pbpctl_dev); int get_dev_idx_bsf(int bus, int slot, int func); static unsigned long str_to_hex(char *p); @@ -129,7 +129,7 @@ static int bp_device_event(struct notifier_block *unused, unsigned long event, void *ptr) { struct net_device *dev = netdev_notifier_info_to_dev(ptr); - static bpctl_dev_t *pbpctl_dev, *pbpctl_dev_m; + static struct bpctl_dev *pbpctl_dev, *pbpctl_dev_m; int dev_num = 0, ret = 0, ret_d = 0, time_left = 0; /* printk("BP_PROC_SUPPORT event =%d %s %d\n", event,dev->name, dev->ifindex ); */ /* return NOTIFY_DONE; */ @@ -284,17 +284,17 @@ static struct notifier_block bp_notifier_block = { .notifier_call = bp_device_event, }; -int is_bypass_fn(bpctl_dev_t *pbpctl_dev); -int wdt_time_left(bpctl_dev_t *pbpctl_dev); +int is_bypass_fn(struct bpctl_dev *pbpctl_dev); +int wdt_time_left(struct bpctl_dev *pbpctl_dev); -static void write_pulse(bpctl_dev_t *pbpctl_dev, +static void write_pulse(struct bpctl_dev *pbpctl_dev, unsigned int ctrl_ext, unsigned char value, unsigned char len) { unsigned char ctrl_val = 0; unsigned int i = len; unsigned int ctrl = 0; - bpctl_dev_t *pbpctl_dev_c = NULL; + struct bpctl_dev *pbpctl_dev_c = NULL; if (pbpctl_dev->bp_i80) ctrl = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); @@ -590,13 +590,13 @@ static void write_pulse(bpctl_dev_t *pbpctl_dev, } } -static int read_pulse(bpctl_dev_t *pbpctl_dev, unsigned int ctrl_ext, +static int read_pulse(struct bpctl_dev *pbpctl_dev, unsigned int ctrl_ext, unsigned char len) { unsigned char ctrl_val = 0; unsigned int i = len; unsigned int ctrl = 0; - bpctl_dev_t *pbpctl_dev_c = NULL; + struct bpctl_dev *pbpctl_dev_c = NULL; if (pbpctl_dev->bp_i80) ctrl = BPCTL_READ_REG(pbpctl_dev, CTRL_EXT); @@ -765,11 +765,11 @@ static int read_pulse(bpctl_dev_t *pbpctl_dev, unsigned int ctrl_ext, return ctrl_val; } -static void write_reg(bpctl_dev_t *pbpctl_dev, unsigned char value, +static void write_reg(struct bpctl_dev *pbpctl_dev, unsigned char value, unsigned char addr) { uint32_t ctrl_ext = 0, ctrl = 0; - bpctl_dev_t *pbpctl_dev_c = NULL; + struct bpctl_dev *pbpctl_dev_c = NULL; unsigned long flags; if (pbpctl_dev->bp_10g9) { pbpctl_dev_c = get_status_port_fn(pbpctl_dev); @@ -934,15 +934,15 @@ static void write_reg(bpctl_dev_t *pbpctl_dev, unsigned char value, } -static void write_data(bpctl_dev_t *pbpctl_dev, unsigned char value) +static void write_data(struct bpctl_dev *pbpctl_dev, unsigned char value) { write_reg(pbpctl_dev, value, CMND_REG_ADDR); } -static int read_reg(bpctl_dev_t *pbpctl_dev, unsigned char addr) +static int read_reg(struct bpctl_dev *pbpctl_dev, unsigned char addr) { uint32_t ctrl_ext = 0, ctrl = 0, ctrl_value = 0; - bpctl_dev_t *pbpctl_dev_c = NULL; + struct bpctl_dev *pbpctl_dev_c = NULL; #ifdef BP_SYNC_FLAG unsigned long flags; @@ -1208,10 +1208,10 @@ static int read_reg(bpctl_dev_t *pbpctl_dev, unsigned char addr) return ctrl_value; } -static int wdt_pulse(bpctl_dev_t *pbpctl_dev) +static int wdt_pulse(struct bpctl_dev *pbpctl_dev) { uint32_t ctrl_ext = 0, ctrl = 0; - bpctl_dev_t *pbpctl_dev_c = NULL; + struct bpctl_dev *pbpctl_dev_c = NULL; #ifdef BP_SYNC_FLAG unsigned long flags; @@ -1424,7 +1424,7 @@ static int wdt_pulse(bpctl_dev_t *pbpctl_dev) return 0; } -static void data_pulse(bpctl_dev_t *pbpctl_dev, unsigned char value) +static void data_pulse(struct bpctl_dev *pbpctl_dev, unsigned char value) { uint32_t ctrl_ext = 0; @@ -1490,7 +1490,7 @@ static void data_pulse(bpctl_dev_t *pbpctl_dev, unsigned char value) } -static int send_wdt_pulse(bpctl_dev_t *pbpctl_dev) +static int send_wdt_pulse(struct bpctl_dev *pbpctl_dev) { uint32_t ctrl_ext = 0; @@ -1524,7 +1524,7 @@ static int send_wdt_pulse(bpctl_dev_t *pbpctl_dev) return 0; } -void send_bypass_clear_pulse(bpctl_dev_t *pbpctl_dev, unsigned int value) +void send_bypass_clear_pulse(struct bpctl_dev *pbpctl_dev, unsigned int value) { uint32_t ctrl_ext = 0; @@ -1550,7 +1550,7 @@ void send_bypass_clear_pulse(bpctl_dev_t *pbpctl_dev, unsigned int value) /* #endif OLD_FW */ #ifdef BYPASS_DEBUG -int pulse_set_fn(bpctl_dev_t *pbpctl_dev, unsigned int counter) +int pulse_set_fn(struct bpctl_dev *pbpctl_dev, unsigned int counter) { uint32_t ctrl_ext = 0; @@ -1578,7 +1578,7 @@ int pulse_set_fn(bpctl_dev_t *pbpctl_dev, unsigned int counter) return 0; } -int zero_set_fn(bpctl_dev_t *pbpctl_dev) +int zero_set_fn(struct bpctl_dev *pbpctl_dev) { uint32_t ctrl_ext = 0, ctrl_value = 0; if (!pbpctl_dev) @@ -1603,7 +1603,7 @@ int zero_set_fn(bpctl_dev_t *pbpctl_dev) return ctrl_value; } -int pulse_get2_fn(bpctl_dev_t *pbpctl_dev) +int pulse_get2_fn(struct bpctl_dev *pbpctl_dev) { uint32_t ctrl_ext = 0, ctrl_value = 0; if (!pbpctl_dev) @@ -1618,7 +1618,7 @@ int pulse_get2_fn(bpctl_dev_t *pbpctl_dev) return ctrl_value; } -int pulse_get1_fn(bpctl_dev_t *pbpctl_dev) +int pulse_get1_fn(struct bpctl_dev *pbpctl_dev) { uint32_t ctrl_ext = 0, ctrl_value = 0; if (!pbpctl_dev) @@ -1635,7 +1635,7 @@ int pulse_get1_fn(bpctl_dev_t *pbpctl_dev) return ctrl_value; } -int gpio6_set_fn(bpctl_dev_t *pbpctl_dev) +int gpio6_set_fn(struct bpctl_dev *pbpctl_dev) { uint32_t ctrl_ext = 0; @@ -1646,7 +1646,7 @@ int gpio6_set_fn(bpctl_dev_t *pbpctl_dev) return 0; } -int gpio7_set_fn(bpctl_dev_t *pbpctl_dev) +int gpio7_set_fn(struct bpctl_dev *pbpctl_dev) { uint32_t ctrl_ext = 0; @@ -1657,7 +1657,7 @@ int gpio7_set_fn(bpctl_dev_t *pbpctl_dev) return 0; } -int gpio7_clear_fn(bpctl_dev_t *pbpctl_dev) +int gpio7_clear_fn(struct bpctl_dev *pbpctl_dev) { uint32_t ctrl_ext = 0; @@ -1668,7 +1668,7 @@ int gpio7_clear_fn(bpctl_dev_t *pbpctl_dev) return 0; } -int gpio6_clear_fn(bpctl_dev_t *pbpctl_dev) +int gpio6_clear_fn(struct bpctl_dev *pbpctl_dev) { uint32_t ctrl_ext = 0; @@ -1680,9 +1680,9 @@ int gpio6_clear_fn(bpctl_dev_t *pbpctl_dev) } #endif /*BYPASS_DEBUG */ -static bpctl_dev_t *lookup_port(bpctl_dev_t *dev) +static struct bpctl_dev *lookup_port(struct bpctl_dev *dev) { - bpctl_dev_t *p; + struct bpctl_dev *p; int n; for (n = 0, p = bpctl_dev_arr; n < device_num && p->pdev; n++) { if (p->bus == dev->bus @@ -1693,7 +1693,7 @@ static bpctl_dev_t *lookup_port(bpctl_dev_t *dev) return NULL; } -static bpctl_dev_t *get_status_port_fn(bpctl_dev_t *pbpctl_dev) +static struct bpctl_dev *get_status_port_fn(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev) { if (pbpctl_dev->func == 0 || pbpctl_dev->func == 2) @@ -1702,7 +1702,7 @@ static bpctl_dev_t *get_status_port_fn(bpctl_dev_t *pbpctl_dev) return NULL; } -static bpctl_dev_t *get_master_port_fn(bpctl_dev_t *pbpctl_dev) +static struct bpctl_dev *get_master_port_fn(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev) { if (pbpctl_dev->func == 1 || pbpctl_dev->func == 3) @@ -1715,7 +1715,7 @@ static bpctl_dev_t *get_master_port_fn(bpctl_dev_t *pbpctl_dev) /**************INTEL API***************/ /**************************************/ -static void write_data_port_int(bpctl_dev_t *pbpctl_dev, +static void write_data_port_int(struct bpctl_dev *pbpctl_dev, unsigned char ctrl_value) { uint32_t value; @@ -1740,9 +1740,9 @@ static void write_data_port_int(bpctl_dev_t *pbpctl_dev, } -static int write_data_int(bpctl_dev_t *pbpctl_dev, unsigned char value) +static int write_data_int(struct bpctl_dev *pbpctl_dev, unsigned char value) { - bpctl_dev_t *pbpctl_dev_b = NULL; + struct bpctl_dev *pbpctl_dev_b = NULL; pbpctl_dev_b = get_status_port_fn(pbpctl_dev); if (!pbpctl_dev_b) @@ -1755,7 +1755,7 @@ static int write_data_int(bpctl_dev_t *pbpctl_dev, unsigned char value) return 0; } -static int wdt_pulse_int(bpctl_dev_t *pbpctl_dev) +static int wdt_pulse_int(struct bpctl_dev *pbpctl_dev) { if ((atomic_read(&pbpctl_dev->wdt_busy)) == 1) @@ -1779,7 +1779,7 @@ static int wdt_pulse_int(bpctl_dev_t *pbpctl_dev) /*************************************/ /* CMND_ON 0x4 (100)*/ -int cmnd_on(bpctl_dev_t *pbpctl_dev) +int cmnd_on(struct bpctl_dev *pbpctl_dev) { int ret = BP_NOT_CAP; @@ -1796,7 +1796,7 @@ int cmnd_on(bpctl_dev_t *pbpctl_dev) } /* CMND_OFF 0x2 (10)*/ -int cmnd_off(bpctl_dev_t *pbpctl_dev) +int cmnd_off(struct bpctl_dev *pbpctl_dev) { int ret = BP_NOT_CAP; @@ -1814,7 +1814,7 @@ int cmnd_off(bpctl_dev_t *pbpctl_dev) } /* BYPASS_ON (0xa)*/ -int bypass_on(bpctl_dev_t *pbpctl_dev) +int bypass_on(struct bpctl_dev *pbpctl_dev) { int ret = BP_NOT_CAP; @@ -1835,7 +1835,7 @@ int bypass_on(bpctl_dev_t *pbpctl_dev) } /* BYPASS_OFF (0x8 111)*/ -int bypass_off(bpctl_dev_t *pbpctl_dev) +int bypass_off(struct bpctl_dev *pbpctl_dev) { int ret = BP_NOT_CAP; @@ -1858,7 +1858,7 @@ int bypass_off(bpctl_dev_t *pbpctl_dev) } /* TAP_OFF (0x9)*/ -int tap_off(bpctl_dev_t *pbpctl_dev) +int tap_off(struct bpctl_dev *pbpctl_dev) { int ret = BP_NOT_CAP; if ((pbpctl_dev->bp_caps & TAP_CAP) @@ -1871,7 +1871,7 @@ int tap_off(bpctl_dev_t *pbpctl_dev) } /* TAP_ON (0xb)*/ -int tap_on(bpctl_dev_t *pbpctl_dev) +int tap_on(struct bpctl_dev *pbpctl_dev) { int ret = BP_NOT_CAP; if ((pbpctl_dev->bp_caps & TAP_CAP) @@ -1884,7 +1884,7 @@ int tap_on(bpctl_dev_t *pbpctl_dev) } /* DISC_OFF (0x9)*/ -int disc_off(bpctl_dev_t *pbpctl_dev) +int disc_off(struct bpctl_dev *pbpctl_dev) { int ret = 0; if ((pbpctl_dev->bp_caps & DISC_CAP) && (pbpctl_dev->bp_ext_ver >= 0x8)) { @@ -1896,7 +1896,7 @@ int disc_off(bpctl_dev_t *pbpctl_dev) } /* DISC_ON (0xb)*/ -int disc_on(bpctl_dev_t *pbpctl_dev) +int disc_on(struct bpctl_dev *pbpctl_dev) { int ret = 0; if ((pbpctl_dev->bp_caps & DISC_CAP) && (pbpctl_dev->bp_ext_ver >= 0x8)) { @@ -1908,10 +1908,10 @@ int disc_on(bpctl_dev_t *pbpctl_dev) } /* DISC_PORT_ON */ -int disc_port_on(bpctl_dev_t *pbpctl_dev) +int disc_port_on(struct bpctl_dev *pbpctl_dev) { int ret = 0; - bpctl_dev_t *pbpctl_dev_m; + struct bpctl_dev *pbpctl_dev_m; if ((is_bypass_fn(pbpctl_dev)) == 1) pbpctl_dev_m = pbpctl_dev; @@ -1933,10 +1933,10 @@ int disc_port_on(bpctl_dev_t *pbpctl_dev) } /* DISC_PORT_OFF */ -int disc_port_off(bpctl_dev_t *pbpctl_dev) +int disc_port_off(struct bpctl_dev *pbpctl_dev) { int ret = 0; - bpctl_dev_t *pbpctl_dev_m; + struct bpctl_dev *pbpctl_dev_m; if ((is_bypass_fn(pbpctl_dev)) == 1) pbpctl_dev_m = pbpctl_dev; @@ -1958,10 +1958,10 @@ int disc_port_off(bpctl_dev_t *pbpctl_dev) } /*TWO_PORT_LINK_HW_EN (0xe)*/ -int tpl_hw_on(bpctl_dev_t *pbpctl_dev) +int tpl_hw_on(struct bpctl_dev *pbpctl_dev) { int ret = 0, ctrl = 0; - bpctl_dev_t *pbpctl_dev_b = NULL; + struct bpctl_dev *pbpctl_dev_b = NULL; pbpctl_dev_b = get_status_port_fn(pbpctl_dev); if (!pbpctl_dev_b) @@ -1986,10 +1986,10 @@ int tpl_hw_on(bpctl_dev_t *pbpctl_dev) } /*TWO_PORT_LINK_HW_DIS (0xc)*/ -int tpl_hw_off(bpctl_dev_t *pbpctl_dev) +int tpl_hw_off(struct bpctl_dev *pbpctl_dev) { int ret = 0, ctrl = 0; - bpctl_dev_t *pbpctl_dev_b = NULL; + struct bpctl_dev *pbpctl_dev_b = NULL; pbpctl_dev_b = get_status_port_fn(pbpctl_dev); if (!pbpctl_dev_b) @@ -2012,7 +2012,7 @@ int tpl_hw_off(bpctl_dev_t *pbpctl_dev) } /* WDT_OFF (0x6 110)*/ -int wdt_off(bpctl_dev_t *pbpctl_dev) +int wdt_off(struct bpctl_dev *pbpctl_dev) { int ret = BP_NOT_CAP; @@ -2035,7 +2035,7 @@ int wdt_off(bpctl_dev_t *pbpctl_dev) static unsigned int wdt_val_array[] = { 1000, 1500, 2000, 3000, 4000, 8000, 16000, 32000, 0 }; -int wdt_on(bpctl_dev_t *pbpctl_dev, unsigned int timeout) +int wdt_on(struct bpctl_dev *pbpctl_dev, unsigned int timeout) { if (pbpctl_dev->bp_caps & WD_CTL_CAP) { @@ -2087,7 +2087,7 @@ int wdt_on(bpctl_dev_t *pbpctl_dev, unsigned int timeout) return BP_NOT_CAP; } -void bp75_put_hw_semaphore_generic(bpctl_dev_t *pbpctl_dev) +void bp75_put_hw_semaphore_generic(struct bpctl_dev *pbpctl_dev) { u32 swsm; @@ -2098,7 +2098,7 @@ void bp75_put_hw_semaphore_generic(bpctl_dev_t *pbpctl_dev) BPCTL_WRITE_REG(pbpctl_dev, SWSM, swsm); } -s32 bp75_get_hw_semaphore_generic(bpctl_dev_t *pbpctl_dev) +s32 bp75_get_hw_semaphore_generic(struct bpctl_dev *pbpctl_dev) { u32 swsm; s32 ret_val = 0; @@ -2146,7 +2146,7 @@ s32 bp75_get_hw_semaphore_generic(bpctl_dev_t *pbpctl_dev) return ret_val; } -static void bp75_release_phy(bpctl_dev_t *pbpctl_dev) +static void bp75_release_phy(struct bpctl_dev *pbpctl_dev) { u16 mask = BPCTLI_SWFW_PHY0_SM; u32 swfw_sync; @@ -2166,7 +2166,7 @@ static void bp75_release_phy(bpctl_dev_t *pbpctl_dev) bp75_put_hw_semaphore_generic(pbpctl_dev); } -static s32 bp75_acquire_phy(bpctl_dev_t *pbpctl_dev) +static s32 bp75_acquire_phy(struct bpctl_dev *pbpctl_dev) { u16 mask = BPCTLI_SWFW_PHY0_SM; u32 swfw_sync; @@ -2212,7 +2212,7 @@ static s32 bp75_acquire_phy(bpctl_dev_t *pbpctl_dev) return ret_val; } -s32 bp75_read_phy_reg_mdic(bpctl_dev_t *pbpctl_dev, u32 offset, u16 *data) +s32 bp75_read_phy_reg_mdic(struct bpctl_dev *pbpctl_dev, u32 offset, u16 *data) { u32 i, mdic = 0; s32 ret_val = 0; @@ -2245,7 +2245,7 @@ s32 bp75_read_phy_reg_mdic(bpctl_dev_t *pbpctl_dev, u32 offset, u16 *data) return ret_val; } -s32 bp75_write_phy_reg_mdic(bpctl_dev_t *pbpctl_dev, u32 offset, u16 data) +s32 bp75_write_phy_reg_mdic(struct bpctl_dev *pbpctl_dev, u32 offset, u16 data) { u32 i, mdic = 0; s32 ret_val = 0; @@ -2278,7 +2278,7 @@ s32 bp75_write_phy_reg_mdic(bpctl_dev_t *pbpctl_dev, u32 offset, u16 data) return ret_val; } -static s32 bp75_read_phy_reg(bpctl_dev_t *pbpctl_dev, u32 offset, u16 *data) +static s32 bp75_read_phy_reg(struct bpctl_dev *pbpctl_dev, u32 offset, u16 *data) { s32 ret_val = 0; @@ -2304,7 +2304,7 @@ static s32 bp75_read_phy_reg(bpctl_dev_t *pbpctl_dev, u32 offset, u16 *data) return ret_val; } -static s32 bp75_write_phy_reg(bpctl_dev_t *pbpctl_dev, u32 offset, u16 data) +static s32 bp75_write_phy_reg(struct bpctl_dev *pbpctl_dev, u32 offset, u16 data) { s32 ret_val = 0; @@ -2332,10 +2332,10 @@ static s32 bp75_write_phy_reg(bpctl_dev_t *pbpctl_dev, u32 offset, u16 data) } /* SET_TX (non-Bypass command :)) */ -static int set_tx(bpctl_dev_t *pbpctl_dev, int tx_state) +static int set_tx(struct bpctl_dev *pbpctl_dev, int tx_state) { int ret = 0, ctrl = 0; - bpctl_dev_t *pbpctl_dev_m; + struct bpctl_dev *pbpctl_dev_m; if ((is_bypass_fn(pbpctl_dev)) == 1) pbpctl_dev_m = pbpctl_dev; else @@ -2532,7 +2532,7 @@ static int set_tx(bpctl_dev_t *pbpctl_dev, int tx_state) } /* SET_FORCE_LINK (non-Bypass command :)) */ -static int set_bp_force_link(bpctl_dev_t *pbpctl_dev, int tx_state) +static int set_bp_force_link(struct bpctl_dev *pbpctl_dev, int tx_state) { int ret = 0, ctrl = 0; @@ -2556,7 +2556,7 @@ static int set_bp_force_link(bpctl_dev_t *pbpctl_dev, int tx_state) } /*RESET_CONT 0x20 */ -int reset_cont(bpctl_dev_t *pbpctl_dev) +int reset_cont(struct bpctl_dev *pbpctl_dev) { int ret = BP_NOT_CAP; @@ -2573,7 +2573,7 @@ int reset_cont(bpctl_dev_t *pbpctl_dev) } /*DIS_BYPASS_CAP 0x22 */ -int dis_bypass_cap(bpctl_dev_t *pbpctl_dev) +int dis_bypass_cap(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & BP_DIS_CAP) { @@ -2592,7 +2592,7 @@ int dis_bypass_cap(bpctl_dev_t *pbpctl_dev) } /*EN_BYPASS_CAP 0x24 */ -int en_bypass_cap(bpctl_dev_t *pbpctl_dev) +int en_bypass_cap(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & BP_DIS_CAP) { if (INTEL_IF_SERIES(pbpctl_dev->subdevice)) { @@ -2608,7 +2608,7 @@ int en_bypass_cap(bpctl_dev_t *pbpctl_dev) } /* BYPASS_STATE_PWRON 0x26*/ -int bypass_state_pwron(bpctl_dev_t *pbpctl_dev) +int bypass_state_pwron(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & BP_PWUP_CTL_CAP) { write_data(pbpctl_dev, BYPASS_STATE_PWRON); @@ -2622,7 +2622,7 @@ int bypass_state_pwron(bpctl_dev_t *pbpctl_dev) } /* NORMAL_STATE_PWRON 0x28*/ -int normal_state_pwron(bpctl_dev_t *pbpctl_dev) +int normal_state_pwron(struct bpctl_dev *pbpctl_dev) { if ((pbpctl_dev->bp_caps & BP_PWUP_CTL_CAP) || (pbpctl_dev->bp_caps & TAP_PWUP_CTL_CAP)) { @@ -2637,7 +2637,7 @@ int normal_state_pwron(bpctl_dev_t *pbpctl_dev) } /* BYPASS_STATE_PWROFF 0x27*/ -int bypass_state_pwroff(bpctl_dev_t *pbpctl_dev) +int bypass_state_pwroff(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & BP_PWOFF_CTL_CAP) { write_data(pbpctl_dev, BYPASS_STATE_PWROFF); @@ -2648,7 +2648,7 @@ int bypass_state_pwroff(bpctl_dev_t *pbpctl_dev) } /* NORMAL_STATE_PWROFF 0x29*/ -int normal_state_pwroff(bpctl_dev_t *pbpctl_dev) +int normal_state_pwroff(struct bpctl_dev *pbpctl_dev) { if ((pbpctl_dev->bp_caps & BP_PWOFF_CTL_CAP)) { write_data(pbpctl_dev, NORMAL_STATE_PWROFF); @@ -2659,7 +2659,7 @@ int normal_state_pwroff(bpctl_dev_t *pbpctl_dev) } /*TAP_STATE_PWRON 0x2a*/ -int tap_state_pwron(bpctl_dev_t *pbpctl_dev) +int tap_state_pwron(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & TAP_PWUP_CTL_CAP) { write_data(pbpctl_dev, TAP_STATE_PWRON); @@ -2670,7 +2670,7 @@ int tap_state_pwron(bpctl_dev_t *pbpctl_dev) } /*DIS_TAP_CAP 0x2c*/ -int dis_tap_cap(bpctl_dev_t *pbpctl_dev) +int dis_tap_cap(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & TAP_DIS_CAP) { write_data(pbpctl_dev, DIS_TAP_CAP); @@ -2681,7 +2681,7 @@ int dis_tap_cap(bpctl_dev_t *pbpctl_dev) } /*EN_TAP_CAP 0x2e*/ -int en_tap_cap(bpctl_dev_t *pbpctl_dev) +int en_tap_cap(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & TAP_DIS_CAP) { write_data(pbpctl_dev, EN_TAP_CAP); @@ -2692,7 +2692,7 @@ int en_tap_cap(bpctl_dev_t *pbpctl_dev) } /*DISC_STATE_PWRON 0x2a*/ -int disc_state_pwron(bpctl_dev_t *pbpctl_dev) +int disc_state_pwron(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & DISC_PWUP_CTL_CAP) { if (pbpctl_dev->bp_ext_ver >= 0x8) { @@ -2705,7 +2705,7 @@ int disc_state_pwron(bpctl_dev_t *pbpctl_dev) } /*DIS_DISC_CAP 0x2c*/ -int dis_disc_cap(bpctl_dev_t *pbpctl_dev) +int dis_disc_cap(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & DISC_DIS_CAP) { if (pbpctl_dev->bp_ext_ver >= 0x8) { @@ -2718,10 +2718,10 @@ int dis_disc_cap(bpctl_dev_t *pbpctl_dev) } /*DISC_STATE_PWRON 0x2a*/ -int disc_port_state_pwron(bpctl_dev_t *pbpctl_dev) +int disc_port_state_pwron(struct bpctl_dev *pbpctl_dev) { int ret = 0; - bpctl_dev_t *pbpctl_dev_m; + struct bpctl_dev *pbpctl_dev_m; return BP_NOT_CAP; @@ -2744,10 +2744,10 @@ int disc_port_state_pwron(bpctl_dev_t *pbpctl_dev) return ret; } -int normal_port_state_pwron(bpctl_dev_t *pbpctl_dev) +int normal_port_state_pwron(struct bpctl_dev *pbpctl_dev) { int ret = 0; - bpctl_dev_t *pbpctl_dev_m; + struct bpctl_dev *pbpctl_dev_m; return BP_NOT_CAP; if ((is_bypass_fn(pbpctl_dev)) == 1) @@ -2770,7 +2770,7 @@ int normal_port_state_pwron(bpctl_dev_t *pbpctl_dev) } /*EN_TAP_CAP 0x2e*/ -int en_disc_cap(bpctl_dev_t *pbpctl_dev) +int en_disc_cap(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & DISC_DIS_CAP) { if (pbpctl_dev->bp_ext_ver >= 0x8) { @@ -2782,7 +2782,7 @@ int en_disc_cap(bpctl_dev_t *pbpctl_dev) return BP_NOT_CAP; } -int std_nic_on(bpctl_dev_t *pbpctl_dev) +int std_nic_on(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & STD_NIC_CAP) { @@ -2836,7 +2836,7 @@ int std_nic_on(bpctl_dev_t *pbpctl_dev) return BP_NOT_CAP; } -int std_nic_off(bpctl_dev_t *pbpctl_dev) +int std_nic_off(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & STD_NIC_CAP) { @@ -2888,7 +2888,7 @@ int std_nic_off(bpctl_dev_t *pbpctl_dev) return BP_NOT_CAP; } -int wdt_time_left(bpctl_dev_t *pbpctl_dev) +int wdt_time_left(struct bpctl_dev *pbpctl_dev) { /* unsigned long curr_time=((long long)(jiffies*1000))/HZ, delta_time=0,wdt_on_time=((long long)(pbpctl_dev->bypass_wdt_on_time*1000))/HZ; */ @@ -2920,7 +2920,7 @@ int wdt_time_left(bpctl_dev_t *pbpctl_dev) return time_left; } -static int wdt_timer(bpctl_dev_t *pbpctl_dev, int *time_left) +static int wdt_timer(struct bpctl_dev *pbpctl_dev, int *time_left) { int ret = 0; if (pbpctl_dev->bp_caps & WD_CTL_CAP) { @@ -2936,7 +2936,7 @@ static int wdt_timer(bpctl_dev_t *pbpctl_dev, int *time_left) return ret; } -static int wdt_timer_reload(bpctl_dev_t *pbpctl_dev) +static int wdt_timer_reload(struct bpctl_dev *pbpctl_dev) { int ret = 0; @@ -2960,7 +2960,7 @@ static int wdt_timer_reload(bpctl_dev_t *pbpctl_dev) static void wd_reset_timer(unsigned long param) { - bpctl_dev_t *pbpctl_dev = (bpctl_dev_t *) param; + struct bpctl_dev *pbpctl_dev = (struct bpctl_dev *) param; #ifdef BP_SELF_TEST struct sk_buff *skb_tmp; #endif @@ -2999,7 +2999,7 @@ static void wd_reset_timer(unsigned long param) } /*WAIT_AT_PWRUP 0x80 */ -int bp_wait_at_pwup_en(bpctl_dev_t *pbpctl_dev) +int bp_wait_at_pwup_en(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & SW_CTL_CAP) { @@ -3014,7 +3014,7 @@ int bp_wait_at_pwup_en(bpctl_dev_t *pbpctl_dev) } /*DIS_WAIT_AT_PWRUP 0x81 */ -int bp_wait_at_pwup_dis(bpctl_dev_t *pbpctl_dev) +int bp_wait_at_pwup_dis(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & SW_CTL_CAP) { @@ -3031,7 +3031,7 @@ int bp_wait_at_pwup_dis(bpctl_dev_t *pbpctl_dev) /*EN_HW_RESET 0x82 */ -int bp_hw_reset_en(bpctl_dev_t *pbpctl_dev) +int bp_hw_reset_en(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & SW_CTL_CAP) { @@ -3047,7 +3047,7 @@ int bp_hw_reset_en(bpctl_dev_t *pbpctl_dev) /*DIS_HW_RESET 0x83 */ -int bp_hw_reset_dis(bpctl_dev_t *pbpctl_dev) +int bp_hw_reset_dis(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & SW_CTL_CAP) { @@ -3062,7 +3062,7 @@ int bp_hw_reset_dis(bpctl_dev_t *pbpctl_dev) } -int wdt_exp_mode(bpctl_dev_t *pbpctl_dev, int mode) +int wdt_exp_mode(struct bpctl_dev *pbpctl_dev, int mode) { uint32_t status_reg = 0, status_reg1 = 0; @@ -3113,7 +3113,7 @@ int wdt_exp_mode(bpctl_dev_t *pbpctl_dev, int mode) return BP_NOT_CAP; } -int bypass_fw_ver(bpctl_dev_t *pbpctl_dev) +int bypass_fw_ver(struct bpctl_dev *pbpctl_dev) { if (is_bypass_fn(pbpctl_dev)) return read_reg(pbpctl_dev, VER_REG_ADDR); @@ -3121,7 +3121,7 @@ int bypass_fw_ver(bpctl_dev_t *pbpctl_dev) return BP_NOT_CAP; } -int bypass_sign_check(bpctl_dev_t *pbpctl_dev) +int bypass_sign_check(struct bpctl_dev *pbpctl_dev) { if (is_bypass_fn(pbpctl_dev)) @@ -3131,10 +3131,10 @@ int bypass_sign_check(bpctl_dev_t *pbpctl_dev) return BP_NOT_CAP; } -static int tx_status(bpctl_dev_t *pbpctl_dev) +static int tx_status(struct bpctl_dev *pbpctl_dev) { uint32_t ctrl = 0; - bpctl_dev_t *pbpctl_dev_m; + struct bpctl_dev *pbpctl_dev_m; if ((is_bypass_fn(pbpctl_dev)) == 1) pbpctl_dev_m = pbpctl_dev; else @@ -3218,7 +3218,7 @@ static int tx_status(bpctl_dev_t *pbpctl_dev) return BP_NOT_CAP; } -static int bp_force_link_status(bpctl_dev_t *pbpctl_dev) +static int bp_force_link_status(struct bpctl_dev *pbpctl_dev) { if (DBI_IF_SERIES(pbpctl_dev->subdevice)) { @@ -3232,10 +3232,10 @@ static int bp_force_link_status(bpctl_dev_t *pbpctl_dev) return BP_NOT_CAP; } -int bypass_from_last_read(bpctl_dev_t *pbpctl_dev) +int bypass_from_last_read(struct bpctl_dev *pbpctl_dev) { uint32_t ctrl_ext = 0; - bpctl_dev_t *pbpctl_dev_b = NULL; + struct bpctl_dev *pbpctl_dev_b = NULL; if (pbpctl_dev->bp_caps & SW_CTL_CAP) { pbpctl_dev_b = get_status_port_fn(pbpctl_dev); @@ -3252,9 +3252,9 @@ int bypass_from_last_read(bpctl_dev_t *pbpctl_dev) return BP_NOT_CAP; } -int bypass_status_clear(bpctl_dev_t *pbpctl_dev) +int bypass_status_clear(struct bpctl_dev *pbpctl_dev) { - bpctl_dev_t *pbpctl_dev_b = NULL; + struct bpctl_dev *pbpctl_dev_b = NULL; if (pbpctl_dev->bp_caps & SW_CTL_CAP) { pbpctl_dev_b = get_status_port_fn(pbpctl_dev); @@ -3266,7 +3266,7 @@ int bypass_status_clear(bpctl_dev_t *pbpctl_dev) return BP_NOT_CAP; } -int bypass_flag_status(bpctl_dev_t *pbpctl_dev) +int bypass_flag_status(struct bpctl_dev *pbpctl_dev) { if ((pbpctl_dev->bp_caps & BP_CAP)) { @@ -3279,7 +3279,7 @@ int bypass_flag_status(bpctl_dev_t *pbpctl_dev) return BP_NOT_CAP; } -int bypass_flag_status_clear(bpctl_dev_t *pbpctl_dev) +int bypass_flag_status_clear(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & BP_CAP) { @@ -3294,7 +3294,7 @@ int bypass_flag_status_clear(bpctl_dev_t *pbpctl_dev) return BP_NOT_CAP; } -int bypass_change_status(bpctl_dev_t *pbpctl_dev) +int bypass_change_status(struct bpctl_dev *pbpctl_dev) { int ret = BP_NOT_CAP; @@ -3313,7 +3313,7 @@ int bypass_change_status(bpctl_dev_t *pbpctl_dev) return ret; } -int bypass_off_status(bpctl_dev_t *pbpctl_dev) +int bypass_off_status(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & BP_CAP) { @@ -3325,12 +3325,12 @@ int bypass_off_status(bpctl_dev_t *pbpctl_dev) return BP_NOT_CAP; } -static int bypass_status(bpctl_dev_t *pbpctl_dev) +static int bypass_status(struct bpctl_dev *pbpctl_dev) { u32 ctrl_ext = 0; if (pbpctl_dev->bp_caps & BP_CAP) { - bpctl_dev_t *pbpctl_dev_b = NULL; + struct bpctl_dev *pbpctl_dev_b = NULL; pbpctl_dev_b = get_status_port_fn(pbpctl_dev); if (!pbpctl_dev_b) @@ -3408,7 +3408,7 @@ static int bypass_status(bpctl_dev_t *pbpctl_dev) return BP_NOT_CAP; } -int default_pwron_status(bpctl_dev_t *pbpctl_dev) +int default_pwron_status(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & SW_CTL_CAP) { @@ -3426,7 +3426,7 @@ int default_pwron_status(bpctl_dev_t *pbpctl_dev) return BP_NOT_CAP; } -static int default_pwroff_status(bpctl_dev_t *pbpctl_dev) +static int default_pwroff_status(struct bpctl_dev *pbpctl_dev) { /*if ((!pbpctl_dev->bp_caps&BP_DIS_CAP)&& @@ -3440,7 +3440,7 @@ static int default_pwroff_status(bpctl_dev_t *pbpctl_dev) return BP_NOT_CAP; } -int dis_bypass_cap_status(bpctl_dev_t *pbpctl_dev) +int dis_bypass_cap_status(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & BP_DIS_CAP) { @@ -3453,7 +3453,7 @@ int dis_bypass_cap_status(bpctl_dev_t *pbpctl_dev) return BP_NOT_CAP; } -int cmd_en_status(bpctl_dev_t *pbpctl_dev) +int cmd_en_status(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & SW_CTL_CAP) { @@ -3465,7 +3465,7 @@ int cmd_en_status(bpctl_dev_t *pbpctl_dev) return BP_NOT_CAP; } -int wdt_en_status(bpctl_dev_t *pbpctl_dev) +int wdt_en_status(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & WD_CTL_CAP) { @@ -3477,7 +3477,7 @@ int wdt_en_status(bpctl_dev_t *pbpctl_dev) return BP_NOT_CAP; } -int wdt_programmed(bpctl_dev_t *pbpctl_dev, int *timeout) +int wdt_programmed(struct bpctl_dev *pbpctl_dev, int *timeout) { int ret = 0; if (pbpctl_dev->bp_caps & WD_CTL_CAP) { @@ -3503,7 +3503,7 @@ int wdt_programmed(bpctl_dev_t *pbpctl_dev, int *timeout) return ret; } -int bypass_support(bpctl_dev_t *pbpctl_dev) +int bypass_support(struct bpctl_dev *pbpctl_dev) { int ret = 0; @@ -3520,7 +3520,7 @@ int bypass_support(bpctl_dev_t *pbpctl_dev) return ret; } -int tap_support(bpctl_dev_t *pbpctl_dev) +int tap_support(struct bpctl_dev *pbpctl_dev) { int ret = 0; @@ -3536,7 +3536,7 @@ int tap_support(bpctl_dev_t *pbpctl_dev) return ret; } -int normal_support(bpctl_dev_t *pbpctl_dev) +int normal_support(struct bpctl_dev *pbpctl_dev) { int ret = BP_NOT_CAP; @@ -3552,7 +3552,7 @@ int normal_support(bpctl_dev_t *pbpctl_dev) return ret; } -int get_bp_prod_caps(bpctl_dev_t *pbpctl_dev) +int get_bp_prod_caps(struct bpctl_dev *pbpctl_dev) { if ((pbpctl_dev->bp_caps & SW_CTL_CAP) && (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER)) @@ -3561,7 +3561,7 @@ int get_bp_prod_caps(bpctl_dev_t *pbpctl_dev) } -int tap_flag_status(bpctl_dev_t *pbpctl_dev) +int tap_flag_status(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & TAP_STATUS_CAP) { @@ -3573,7 +3573,7 @@ int tap_flag_status(bpctl_dev_t *pbpctl_dev) return BP_NOT_CAP; } -int tap_flag_status_clear(bpctl_dev_t *pbpctl_dev) +int tap_flag_status_clear(struct bpctl_dev *pbpctl_dev) { uint32_t status_reg = 0; if (pbpctl_dev->bp_caps & TAP_STATUS_CAP) { @@ -3587,7 +3587,7 @@ int tap_flag_status_clear(bpctl_dev_t *pbpctl_dev) return BP_NOT_CAP; } -int tap_change_status(bpctl_dev_t *pbpctl_dev) +int tap_change_status(struct bpctl_dev *pbpctl_dev) { int ret = BP_NOT_CAP; if (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER) { @@ -3604,7 +3604,7 @@ int tap_change_status(bpctl_dev_t *pbpctl_dev) return ret; } -int tap_off_status(bpctl_dev_t *pbpctl_dev) +int tap_off_status(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & TAP_CAP) { if (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER) @@ -3614,12 +3614,12 @@ int tap_off_status(bpctl_dev_t *pbpctl_dev) return BP_NOT_CAP; } -int tap_status(bpctl_dev_t *pbpctl_dev) +int tap_status(struct bpctl_dev *pbpctl_dev) { u32 ctrl_ext = 0; if (pbpctl_dev->bp_caps & TAP_CAP) { - bpctl_dev_t *pbpctl_dev_b = NULL; + struct bpctl_dev *pbpctl_dev_b = NULL; pbpctl_dev_b = get_status_port_fn(pbpctl_dev); if (!pbpctl_dev_b) @@ -3653,7 +3653,7 @@ int tap_status(bpctl_dev_t *pbpctl_dev) return BP_NOT_CAP; } -int default_pwron_tap_status(bpctl_dev_t *pbpctl_dev) +int default_pwron_tap_status(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & TAP_PWUP_CTL_CAP) { if (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER) @@ -3664,7 +3664,7 @@ int default_pwron_tap_status(bpctl_dev_t *pbpctl_dev) return BP_NOT_CAP; } -int dis_tap_cap_status(bpctl_dev_t *pbpctl_dev) +int dis_tap_cap_status(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & TAP_PWUP_CTL_CAP) { if (pbpctl_dev->bp_ext_ver >= PXG2TBPI_VER) @@ -3675,7 +3675,7 @@ int dis_tap_cap_status(bpctl_dev_t *pbpctl_dev) return BP_NOT_CAP; } -int disc_flag_status(bpctl_dev_t *pbpctl_dev) +int disc_flag_status(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & DISC_CAP) { @@ -3687,7 +3687,7 @@ int disc_flag_status(bpctl_dev_t *pbpctl_dev) return BP_NOT_CAP; } -int disc_flag_status_clear(bpctl_dev_t *pbpctl_dev) +int disc_flag_status_clear(struct bpctl_dev *pbpctl_dev) { uint32_t status_reg = 0; if (pbpctl_dev->bp_caps & DISC_CAP) { @@ -3701,7 +3701,7 @@ int disc_flag_status_clear(bpctl_dev_t *pbpctl_dev) return BP_NOT_CAP; } -int disc_change_status(bpctl_dev_t *pbpctl_dev) +int disc_change_status(struct bpctl_dev *pbpctl_dev) { int ret = BP_NOT_CAP; if (pbpctl_dev->bp_caps & DISC_CAP) { @@ -3712,9 +3712,9 @@ int disc_change_status(bpctl_dev_t *pbpctl_dev) return BP_NOT_CAP; } -int disc_off_status(bpctl_dev_t *pbpctl_dev) +int disc_off_status(struct bpctl_dev *pbpctl_dev) { - bpctl_dev_t *pbpctl_dev_b = NULL; + struct bpctl_dev *pbpctl_dev_b = NULL; u32 ctrl_ext = 0; if (pbpctl_dev->bp_caps & DISC_CAP) { @@ -3796,7 +3796,7 @@ int disc_off_status(bpctl_dev_t *pbpctl_dev) return BP_NOT_CAP; } -static int disc_status(bpctl_dev_t *pbpctl_dev) +static int disc_status(struct bpctl_dev *pbpctl_dev) { int ctrl = 0; if (pbpctl_dev->bp_caps & DISC_CAP) { @@ -3808,7 +3808,7 @@ static int disc_status(bpctl_dev_t *pbpctl_dev) return BP_NOT_CAP; } -int default_pwron_disc_status(bpctl_dev_t *pbpctl_dev) +int default_pwron_disc_status(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & DISC_PWUP_CTL_CAP) { if (pbpctl_dev->bp_ext_ver >= 0x8) @@ -3819,7 +3819,7 @@ int default_pwron_disc_status(bpctl_dev_t *pbpctl_dev) return BP_NOT_CAP; } -int dis_disc_cap_status(bpctl_dev_t *pbpctl_dev) +int dis_disc_cap_status(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & DIS_DISC_CAP) { if (pbpctl_dev->bp_ext_ver >= 0x8) @@ -3830,10 +3830,10 @@ int dis_disc_cap_status(bpctl_dev_t *pbpctl_dev) return BP_NOT_CAP; } -int disc_port_status(bpctl_dev_t *pbpctl_dev) +int disc_port_status(struct bpctl_dev *pbpctl_dev) { int ret = BP_NOT_CAP; - bpctl_dev_t *pbpctl_dev_m; + struct bpctl_dev *pbpctl_dev_m; if ((is_bypass_fn(pbpctl_dev)) == 1) pbpctl_dev_m = pbpctl_dev; @@ -3854,10 +3854,10 @@ int disc_port_status(bpctl_dev_t *pbpctl_dev) return ret; } -int default_pwron_disc_port_status(bpctl_dev_t *pbpctl_dev) +int default_pwron_disc_port_status(struct bpctl_dev *pbpctl_dev) { int ret = BP_NOT_CAP; - bpctl_dev_t *pbpctl_dev_m; + struct bpctl_dev *pbpctl_dev_m; if ((is_bypass_fn(pbpctl_dev)) == 1) pbpctl_dev_m = pbpctl_dev; @@ -3878,7 +3878,7 @@ int default_pwron_disc_port_status(bpctl_dev_t *pbpctl_dev) return ret; } -int wdt_exp_mode_status(bpctl_dev_t *pbpctl_dev) +int wdt_exp_mode_status(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & WD_CTL_CAP) { if (pbpctl_dev->bp_ext_ver <= PXG2BPI_VER) @@ -3901,7 +3901,7 @@ int wdt_exp_mode_status(bpctl_dev_t *pbpctl_dev) return BP_NOT_CAP; } -int tpl2_flag_status(bpctl_dev_t *pbpctl_dev) +int tpl2_flag_status(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps_ex & TPL2_CAP_EX) { @@ -3912,9 +3912,9 @@ int tpl2_flag_status(bpctl_dev_t *pbpctl_dev) return BP_NOT_CAP; } -int tpl_hw_status(bpctl_dev_t *pbpctl_dev) +int tpl_hw_status(struct bpctl_dev *pbpctl_dev) { - bpctl_dev_t *pbpctl_dev_b = NULL; + struct bpctl_dev *pbpctl_dev_b = NULL; pbpctl_dev_b = get_status_port_fn(pbpctl_dev); if (!pbpctl_dev_b) @@ -3927,7 +3927,7 @@ int tpl_hw_status(bpctl_dev_t *pbpctl_dev) } -int bp_wait_at_pwup_status(bpctl_dev_t *pbpctl_dev) +int bp_wait_at_pwup_status(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & SW_CTL_CAP) { if (pbpctl_dev->bp_ext_ver >= 0x8) @@ -3938,7 +3938,7 @@ int bp_wait_at_pwup_status(bpctl_dev_t *pbpctl_dev) return BP_NOT_CAP; } -int bp_hw_reset_status(bpctl_dev_t *pbpctl_dev) +int bp_hw_reset_status(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & SW_CTL_CAP) { @@ -3952,7 +3952,7 @@ int bp_hw_reset_status(bpctl_dev_t *pbpctl_dev) } -int std_nic_status(bpctl_dev_t *pbpctl_dev) +int std_nic_status(struct bpctl_dev *pbpctl_dev) { int status_val = 0; @@ -4000,10 +4000,10 @@ int std_nic_status(bpctl_dev_t *pbpctl_dev) /******************************************************/ /**************SW_INIT*********************************/ /******************************************************/ -void bypass_caps_init(bpctl_dev_t *pbpctl_dev) +void bypass_caps_init(struct bpctl_dev *pbpctl_dev) { u_int32_t ctrl_ext = 0; - bpctl_dev_t *pbpctl_dev_m = NULL; + struct bpctl_dev *pbpctl_dev_m = NULL; #ifdef BYPASS_DEBUG int ret = 0; @@ -4218,7 +4218,7 @@ void bypass_caps_init(bpctl_dev_t *pbpctl_dev) } } -int bypass_off_init(bpctl_dev_t *pbpctl_dev) +int bypass_off_init(struct bpctl_dev *pbpctl_dev) { int ret = cmnd_on(pbpctl_dev); if (ret < 0) @@ -4234,10 +4234,10 @@ int bypass_off_init(bpctl_dev_t *pbpctl_dev) return 0; } -void remove_bypass_wd_auto(bpctl_dev_t *pbpctl_dev) +void remove_bypass_wd_auto(struct bpctl_dev *pbpctl_dev) { #ifdef BP_SELF_TEST - bpctl_dev_t *pbpctl_dev_sl = NULL; + struct bpctl_dev *pbpctl_dev_sl = NULL; #endif if (pbpctl_dev->bp_caps & WD_CTL_CAP) { @@ -4263,7 +4263,7 @@ void remove_bypass_wd_auto(bpctl_dev_t *pbpctl_dev) } -int init_bypass_wd_auto(bpctl_dev_t *pbpctl_dev) +int init_bypass_wd_auto(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & WD_CTL_CAP) { init_timer(&pbpctl_dev->bp_timer); @@ -4277,7 +4277,7 @@ int init_bypass_wd_auto(bpctl_dev_t *pbpctl_dev) #ifdef BP_SELF_TEST int bp_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) { - bpctl_dev_t *pbpctl_dev = NULL, *pbpctl_dev_m = NULL; + struct bpctl_dev *pbpctl_dev = NULL, *pbpctl_dev_m = NULL; int idx_dev = 0; struct ethhdr *eth = (struct ethhdr *)skb->data; @@ -4310,7 +4310,7 @@ int bp_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) } #endif -int set_bypass_wd_auto(bpctl_dev_t *pbpctl_dev, unsigned int param) +int set_bypass_wd_auto(struct bpctl_dev *pbpctl_dev, unsigned int param) { if (pbpctl_dev->bp_caps & WD_CTL_CAP) { if (pbpctl_dev->reset_time != param) { @@ -4329,7 +4329,7 @@ int set_bypass_wd_auto(bpctl_dev_t *pbpctl_dev, unsigned int param) return BP_NOT_CAP; } -int get_bypass_wd_auto(bpctl_dev_t *pbpctl_dev) +int get_bypass_wd_auto(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & WD_CTL_CAP) return pbpctl_dev->reset_time; @@ -4339,9 +4339,9 @@ int get_bypass_wd_auto(bpctl_dev_t *pbpctl_dev) #ifdef BP_SELF_TEST -int set_bp_self_test(bpctl_dev_t *pbpctl_dev, unsigned int param) +int set_bp_self_test(struct bpctl_dev *pbpctl_dev, unsigned int param) { - bpctl_dev_t *pbpctl_dev_sl = NULL; + struct bpctl_dev *pbpctl_dev_sl = NULL; if (pbpctl_dev->bp_caps & WD_CTL_CAP) { pbpctl_dev->bp_self_test_flag = param == 0 ? 0 : 1; @@ -4374,7 +4374,7 @@ int set_bp_self_test(bpctl_dev_t *pbpctl_dev, unsigned int param) return BP_NOT_CAP; } -int get_bp_self_test(bpctl_dev_t *pbpctl_dev) +int get_bp_self_test(struct bpctl_dev *pbpctl_dev) { if (pbpctl_dev->bp_caps & WD_CTL_CAP) { @@ -4392,7 +4392,7 @@ int get_bp_self_test(bpctl_dev_t *pbpctl_dev) /************************* API ********************************/ /**************************************************************/ -int is_bypass_fn(bpctl_dev_t *pbpctl_dev) +int is_bypass_fn(struct bpctl_dev *pbpctl_dev) { if (!pbpctl_dev) return -1; @@ -4400,7 +4400,7 @@ int is_bypass_fn(bpctl_dev_t *pbpctl_dev) return (((pbpctl_dev->func == 0) || (pbpctl_dev->func == 2)) ? 1 : 0); } -int set_bypass_fn(bpctl_dev_t *pbpctl_dev, int bypass_mode) +int set_bypass_fn(struct bpctl_dev *pbpctl_dev, int bypass_mode) { int ret = 0; @@ -4418,12 +4418,12 @@ int set_bypass_fn(bpctl_dev_t *pbpctl_dev, int bypass_mode) return ret; } -int get_bypass_fn(bpctl_dev_t *pbpctl_dev) +int get_bypass_fn(struct bpctl_dev *pbpctl_dev) { return bypass_status(pbpctl_dev); } -int get_bypass_change_fn(bpctl_dev_t *pbpctl_dev) +int get_bypass_change_fn(struct bpctl_dev *pbpctl_dev) { if (!pbpctl_dev) return -1; @@ -4431,7 +4431,7 @@ int get_bypass_change_fn(bpctl_dev_t *pbpctl_dev) return bypass_change_status(pbpctl_dev); } -int set_dis_bypass_fn(bpctl_dev_t *pbpctl_dev, int dis_param) +int set_dis_bypass_fn(struct bpctl_dev *pbpctl_dev, int dis_param) { int ret = 0; if (!pbpctl_dev) @@ -4450,7 +4450,7 @@ int set_dis_bypass_fn(bpctl_dev_t *pbpctl_dev, int dis_param) return ret; } -int get_dis_bypass_fn(bpctl_dev_t *pbpctl_dev) +int get_dis_bypass_fn(struct bpctl_dev *pbpctl_dev) { if (!pbpctl_dev) return -1; @@ -4458,7 +4458,7 @@ int get_dis_bypass_fn(bpctl_dev_t *pbpctl_dev) return dis_bypass_cap_status(pbpctl_dev); } -int set_bypass_pwoff_fn(bpctl_dev_t *pbpctl_dev, int bypass_mode) +int set_bypass_pwoff_fn(struct bpctl_dev *pbpctl_dev, int bypass_mode) { int ret = 0; if (!pbpctl_dev) @@ -4477,7 +4477,7 @@ int set_bypass_pwoff_fn(bpctl_dev_t *pbpctl_dev, int bypass_mode) return ret; } -int get_bypass_pwoff_fn(bpctl_dev_t *pbpctl_dev) +int get_bypass_pwoff_fn(struct bpctl_dev *pbpctl_dev) { if (!pbpctl_dev) return -1; @@ -4485,7 +4485,7 @@ int get_bypass_pwoff_fn(bpctl_dev_t *pbpctl_dev) return default_pwroff_status(pbpctl_dev); } -int set_bypass_pwup_fn(bpctl_dev_t *pbpctl_dev, int bypass_mode) +int set_bypass_pwup_fn(struct bpctl_dev *pbpctl_dev, int bypass_mode) { int ret = 0; if (!pbpctl_dev) @@ -4504,7 +4504,7 @@ int set_bypass_pwup_fn(bpctl_dev_t *pbpctl_dev, int bypass_mode) return ret; } -int get_bypass_pwup_fn(bpctl_dev_t *pbpctl_dev) +int get_bypass_pwup_fn(struct bpctl_dev *pbpctl_dev) { if (!pbpctl_dev) return -1; @@ -4512,7 +4512,7 @@ int get_bypass_pwup_fn(bpctl_dev_t *pbpctl_dev) return default_pwron_status(pbpctl_dev); } -int set_bypass_wd_fn(bpctl_dev_t *pbpctl_dev, int timeout) +int set_bypass_wd_fn(struct bpctl_dev *pbpctl_dev, int timeout) { int ret = 0; if (!pbpctl_dev) @@ -4534,7 +4534,7 @@ int set_bypass_wd_fn(bpctl_dev_t *pbpctl_dev, int timeout) return ret; } -int get_bypass_wd_fn(bpctl_dev_t *pbpctl_dev, int *timeout) +int get_bypass_wd_fn(struct bpctl_dev *pbpctl_dev, int *timeout) { if (!pbpctl_dev) return -1; @@ -4542,7 +4542,7 @@ int get_bypass_wd_fn(bpctl_dev_t *pbpctl_dev, int *timeout) return wdt_programmed(pbpctl_dev, timeout); } -int get_wd_expire_time_fn(bpctl_dev_t *pbpctl_dev, int *time_left) +int get_wd_expire_time_fn(struct bpctl_dev *pbpctl_dev, int *time_left) { if (!pbpctl_dev) return -1; @@ -4550,7 +4550,7 @@ int get_wd_expire_time_fn(bpctl_dev_t *pbpctl_dev, int *time_left) return wdt_timer(pbpctl_dev, time_left); } -int reset_bypass_wd_timer_fn(bpctl_dev_t *pbpctl_dev) +int reset_bypass_wd_timer_fn(struct bpctl_dev *pbpctl_dev) { if (!pbpctl_dev) return -1; @@ -4558,7 +4558,7 @@ int reset_bypass_wd_timer_fn(bpctl_dev_t *pbpctl_dev) return wdt_timer_reload(pbpctl_dev); } -int get_wd_set_caps_fn(bpctl_dev_t *pbpctl_dev) +int get_wd_set_caps_fn(struct bpctl_dev *pbpctl_dev) { int bp_status = 0; @@ -4582,7 +4582,7 @@ int get_wd_set_caps_fn(bpctl_dev_t *pbpctl_dev) return bp_status; } -int set_std_nic_fn(bpctl_dev_t *pbpctl_dev, int nic_mode) +int set_std_nic_fn(struct bpctl_dev *pbpctl_dev, int nic_mode) { int ret = 0; if (!pbpctl_dev) @@ -4602,7 +4602,7 @@ int set_std_nic_fn(bpctl_dev_t *pbpctl_dev, int nic_mode) return ret; } -int get_std_nic_fn(bpctl_dev_t *pbpctl_dev) +int get_std_nic_fn(struct bpctl_dev *pbpctl_dev) { if (!pbpctl_dev) return -1; @@ -4610,7 +4610,7 @@ int get_std_nic_fn(bpctl_dev_t *pbpctl_dev) return std_nic_status(pbpctl_dev); } -int set_tap_fn(bpctl_dev_t *pbpctl_dev, int tap_mode) +int set_tap_fn(struct bpctl_dev *pbpctl_dev, int tap_mode) { if (!pbpctl_dev) return -1; @@ -4626,7 +4626,7 @@ int set_tap_fn(bpctl_dev_t *pbpctl_dev, int tap_mode) return BP_NOT_CAP; } -int get_tap_fn(bpctl_dev_t *pbpctl_dev) +int get_tap_fn(struct bpctl_dev *pbpctl_dev) { if (!pbpctl_dev) return -1; @@ -4634,7 +4634,7 @@ int get_tap_fn(bpctl_dev_t *pbpctl_dev) return tap_status(pbpctl_dev); } -int set_tap_pwup_fn(bpctl_dev_t *pbpctl_dev, int tap_mode) +int set_tap_pwup_fn(struct bpctl_dev *pbpctl_dev, int tap_mode) { int ret = 0; if (!pbpctl_dev) @@ -4652,7 +4652,7 @@ int set_tap_pwup_fn(bpctl_dev_t *pbpctl_dev, int tap_mode) return ret; } -int get_tap_pwup_fn(bpctl_dev_t *pbpctl_dev) +int get_tap_pwup_fn(struct bpctl_dev *pbpctl_dev) { int ret = 0; if (!pbpctl_dev) @@ -4664,7 +4664,7 @@ int get_tap_pwup_fn(bpctl_dev_t *pbpctl_dev) return ((ret == 0) ? 1 : 0); } -int get_tap_change_fn(bpctl_dev_t *pbpctl_dev) +int get_tap_change_fn(struct bpctl_dev *pbpctl_dev) { if (!pbpctl_dev) return -1; @@ -4672,7 +4672,7 @@ int get_tap_change_fn(bpctl_dev_t *pbpctl_dev) return tap_change_status(pbpctl_dev); } -int set_dis_tap_fn(bpctl_dev_t *pbpctl_dev, int dis_param) +int set_dis_tap_fn(struct bpctl_dev *pbpctl_dev, int dis_param) { int ret = 0; if (!pbpctl_dev) @@ -4689,7 +4689,7 @@ int set_dis_tap_fn(bpctl_dev_t *pbpctl_dev, int dis_param) return BP_NOT_CAP; } -int get_dis_tap_fn(bpctl_dev_t *pbpctl_dev) +int get_dis_tap_fn(struct bpctl_dev *pbpctl_dev) { if (!pbpctl_dev) return -1; @@ -4697,7 +4697,7 @@ int get_dis_tap_fn(bpctl_dev_t *pbpctl_dev) return dis_tap_cap_status(pbpctl_dev); } -int set_disc_fn(bpctl_dev_t *pbpctl_dev, int disc_mode) +int set_disc_fn(struct bpctl_dev *pbpctl_dev, int disc_mode) { if (!pbpctl_dev) return -1; @@ -4714,7 +4714,7 @@ int set_disc_fn(bpctl_dev_t *pbpctl_dev, int disc_mode) return BP_NOT_CAP; } -int get_disc_fn(bpctl_dev_t *pbpctl_dev) +int get_disc_fn(struct bpctl_dev *pbpctl_dev) { int ret = 0; if (!pbpctl_dev) @@ -4725,7 +4725,7 @@ int get_disc_fn(bpctl_dev_t *pbpctl_dev) return ret; } -int set_disc_pwup_fn(bpctl_dev_t *pbpctl_dev, int disc_mode) +int set_disc_pwup_fn(struct bpctl_dev *pbpctl_dev, int disc_mode) { int ret = 0; if (!pbpctl_dev) @@ -4743,7 +4743,7 @@ int set_disc_pwup_fn(bpctl_dev_t *pbpctl_dev, int disc_mode) return ret; } -int get_disc_pwup_fn(bpctl_dev_t *pbpctl_dev) +int get_disc_pwup_fn(struct bpctl_dev *pbpctl_dev) { int ret = 0; if (!pbpctl_dev) @@ -4753,7 +4753,7 @@ int get_disc_pwup_fn(bpctl_dev_t *pbpctl_dev) return (ret == 0 ? 1 : (ret < 0 ? BP_NOT_CAP : 0)); } -int get_disc_change_fn(bpctl_dev_t *pbpctl_dev) +int get_disc_change_fn(struct bpctl_dev *pbpctl_dev) { int ret = 0; if (!pbpctl_dev) @@ -4763,7 +4763,7 @@ int get_disc_change_fn(bpctl_dev_t *pbpctl_dev) return ret; } -int set_dis_disc_fn(bpctl_dev_t *pbpctl_dev, int dis_param) +int set_dis_disc_fn(struct bpctl_dev *pbpctl_dev, int dis_param) { int ret = 0; if (!pbpctl_dev) @@ -4781,7 +4781,7 @@ int set_dis_disc_fn(bpctl_dev_t *pbpctl_dev, int dis_param) return BP_NOT_CAP; } -int get_dis_disc_fn(bpctl_dev_t *pbpctl_dev) +int get_dis_disc_fn(struct bpctl_dev *pbpctl_dev) { int ret = 0; if (!pbpctl_dev) @@ -4792,7 +4792,7 @@ int get_dis_disc_fn(bpctl_dev_t *pbpctl_dev) return ret; } -int set_disc_port_fn(bpctl_dev_t *pbpctl_dev, int disc_mode) +int set_disc_port_fn(struct bpctl_dev *pbpctl_dev, int disc_mode) { int ret = BP_NOT_CAP; if (!pbpctl_dev) @@ -4806,7 +4806,7 @@ int set_disc_port_fn(bpctl_dev_t *pbpctl_dev, int disc_mode) return ret; } -int get_disc_port_fn(bpctl_dev_t *pbpctl_dev) +int get_disc_port_fn(struct bpctl_dev *pbpctl_dev) { if (!pbpctl_dev) return -1; @@ -4814,7 +4814,7 @@ int get_disc_port_fn(bpctl_dev_t *pbpctl_dev) return disc_port_status(pbpctl_dev); } -int set_disc_port_pwup_fn(bpctl_dev_t *pbpctl_dev, int disc_mode) +int set_disc_port_pwup_fn(struct bpctl_dev *pbpctl_dev, int disc_mode) { int ret = BP_NOT_CAP; if (!pbpctl_dev) @@ -4828,7 +4828,7 @@ int set_disc_port_pwup_fn(bpctl_dev_t *pbpctl_dev, int disc_mode) return ret; } -int get_disc_port_pwup_fn(bpctl_dev_t *pbpctl_dev) +int get_disc_port_pwup_fn(struct bpctl_dev *pbpctl_dev) { int ret = 0; if (!pbpctl_dev) @@ -4840,7 +4840,7 @@ int get_disc_port_pwup_fn(bpctl_dev_t *pbpctl_dev) return ((ret == 0) ? 1 : 0); } -int get_wd_exp_mode_fn(bpctl_dev_t *pbpctl_dev) +int get_wd_exp_mode_fn(struct bpctl_dev *pbpctl_dev) { if (!pbpctl_dev) return -1; @@ -4848,7 +4848,7 @@ int get_wd_exp_mode_fn(bpctl_dev_t *pbpctl_dev) return wdt_exp_mode_status(pbpctl_dev); } -int set_wd_exp_mode_fn(bpctl_dev_t *pbpctl_dev, int param) +int set_wd_exp_mode_fn(struct bpctl_dev *pbpctl_dev, int param) { if (!pbpctl_dev) return -1; @@ -4856,7 +4856,7 @@ int set_wd_exp_mode_fn(bpctl_dev_t *pbpctl_dev, int param) return wdt_exp_mode(pbpctl_dev, param); } -int reset_cont_fn(bpctl_dev_t *pbpctl_dev) +int reset_cont_fn(struct bpctl_dev *pbpctl_dev) { int ret = 0; if (!pbpctl_dev) @@ -4868,10 +4868,10 @@ int reset_cont_fn(bpctl_dev_t *pbpctl_dev) return reset_cont(pbpctl_dev); } -int set_tx_fn(bpctl_dev_t *pbpctl_dev, int tx_state) +int set_tx_fn(struct bpctl_dev *pbpctl_dev, int tx_state) { - bpctl_dev_t *pbpctl_dev_b = NULL; + struct bpctl_dev *pbpctl_dev_b = NULL; if (!pbpctl_dev) return -1; @@ -4891,7 +4891,7 @@ int set_tx_fn(bpctl_dev_t *pbpctl_dev, int tx_state) int set_bp_force_link_fn(int dev_num, int tx_state) { - static bpctl_dev_t *bpctl_dev_curr; + static struct bpctl_dev *bpctl_dev_curr; if ((dev_num < 0) || (dev_num > device_num) || (bpctl_dev_arr[dev_num].pdev == NULL)) @@ -4901,7 +4901,7 @@ int set_bp_force_link_fn(int dev_num, int tx_state) return set_bp_force_link(bpctl_dev_curr, tx_state); } -int set_wd_autoreset_fn(bpctl_dev_t *pbpctl_dev, int param) +int set_wd_autoreset_fn(struct bpctl_dev *pbpctl_dev, int param) { if (!pbpctl_dev) return -1; @@ -4909,7 +4909,7 @@ int set_wd_autoreset_fn(bpctl_dev_t *pbpctl_dev, int param) return set_bypass_wd_auto(pbpctl_dev, param); } -int get_wd_autoreset_fn(bpctl_dev_t *pbpctl_dev) +int get_wd_autoreset_fn(struct bpctl_dev *pbpctl_dev) { if (!pbpctl_dev) return -1; @@ -4918,7 +4918,7 @@ int get_wd_autoreset_fn(bpctl_dev_t *pbpctl_dev) } #ifdef BP_SELF_TEST -int set_bp_self_test_fn(bpctl_dev_t *pbpctl_dev, int param) +int set_bp_self_test_fn(struct bpctl_dev *pbpctl_dev, int param) { if (!pbpctl_dev) return -1; @@ -4926,7 +4926,7 @@ int set_bp_self_test_fn(bpctl_dev_t *pbpctl_dev, int param) return set_bp_self_test(pbpctl_dev, param); } -int get_bp_self_test_fn(bpctl_dev_t *pbpctl_dev) +int get_bp_self_test_fn(struct bpctl_dev *pbpctl_dev) { if (!pbpctl_dev) return -1; @@ -4936,7 +4936,7 @@ int get_bp_self_test_fn(bpctl_dev_t *pbpctl_dev) #endif -int get_bypass_caps_fn(bpctl_dev_t *pbpctl_dev) +int get_bypass_caps_fn(struct bpctl_dev *pbpctl_dev) { if (!pbpctl_dev) return -1; @@ -4945,7 +4945,7 @@ int get_bypass_caps_fn(bpctl_dev_t *pbpctl_dev) } -int get_bypass_slave_fn(bpctl_dev_t *pbpctl_dev, bpctl_dev_t **pbpctl_dev_out) +int get_bypass_slave_fn(struct bpctl_dev *pbpctl_dev, struct bpctl_dev **pbpctl_dev_out) { int idx_dev = 0; if (!pbpctl_dev) @@ -4977,7 +4977,7 @@ int get_bypass_slave_fn(bpctl_dev_t *pbpctl_dev, bpctl_dev_t **pbpctl_dev_out) return 0; } -int is_bypass(bpctl_dev_t *pbpctl_dev) +int is_bypass(struct bpctl_dev *pbpctl_dev) { if (!pbpctl_dev) return -1; @@ -4988,9 +4988,9 @@ int is_bypass(bpctl_dev_t *pbpctl_dev) return 0; } -int get_tx_fn(bpctl_dev_t *pbpctl_dev) +int get_tx_fn(struct bpctl_dev *pbpctl_dev) { - bpctl_dev_t *pbpctl_dev_b = NULL; + struct bpctl_dev *pbpctl_dev_b = NULL; if (!pbpctl_dev) return -1; @@ -5010,7 +5010,7 @@ int get_tx_fn(bpctl_dev_t *pbpctl_dev) int get_bp_force_link_fn(int dev_num) { - static bpctl_dev_t *bpctl_dev_curr; + static struct bpctl_dev *bpctl_dev_curr; if ((dev_num < 0) || (dev_num > device_num) || (bpctl_dev_arr[dev_num].pdev == NULL)) @@ -5020,7 +5020,7 @@ int get_bp_force_link_fn(int dev_num) return bp_force_link_status(bpctl_dev_curr); } -static int get_bypass_link_status(bpctl_dev_t *pbpctl_dev) +static int get_bypass_link_status(struct bpctl_dev *pbpctl_dev) { if (!pbpctl_dev) return -1; @@ -5036,9 +5036,9 @@ static int get_bypass_link_status(bpctl_dev_t *pbpctl_dev) static void bp_tpl_timer_fn(unsigned long param) { - bpctl_dev_t *pbpctl_dev = (bpctl_dev_t *) param; + struct bpctl_dev *pbpctl_dev = (struct bpctl_dev *) param; uint32_t link1, link2; - bpctl_dev_t *pbpctl_dev_b = NULL; + struct bpctl_dev *pbpctl_dev_b = NULL; pbpctl_dev_b = get_status_port_fn(pbpctl_dev); if (!pbpctl_dev_b) @@ -5071,9 +5071,9 @@ static void bp_tpl_timer_fn(unsigned long param) mod_timer(&pbpctl_dev->bp_tpl_timer, jiffies + BP_LINK_MON_DELAY * HZ); } -void remove_bypass_tpl_auto(bpctl_dev_t *pbpctl_dev) +void remove_bypass_tpl_auto(struct bpctl_dev *pbpctl_dev) { - bpctl_dev_t *pbpctl_dev_b = NULL; + struct bpctl_dev *pbpctl_dev_b = NULL; if (!pbpctl_dev) return; pbpctl_dev_b = get_status_port_fn(pbpctl_dev); @@ -5089,7 +5089,7 @@ void remove_bypass_tpl_auto(bpctl_dev_t *pbpctl_dev) return; } -int init_bypass_tpl_auto(bpctl_dev_t *pbpctl_dev) +int init_bypass_tpl_auto(struct bpctl_dev *pbpctl_dev) { if (!pbpctl_dev) return -1; @@ -5102,7 +5102,7 @@ int init_bypass_tpl_auto(bpctl_dev_t *pbpctl_dev) return BP_NOT_CAP; } -int set_bypass_tpl_auto(bpctl_dev_t *pbpctl_dev, unsigned int param) +int set_bypass_tpl_auto(struct bpctl_dev *pbpctl_dev, unsigned int param) { if (!pbpctl_dev) return -1; @@ -5120,7 +5120,7 @@ int set_bypass_tpl_auto(bpctl_dev_t *pbpctl_dev, unsigned int param) return BP_NOT_CAP; } -int get_bypass_tpl_auto(bpctl_dev_t *pbpctl_dev) +int get_bypass_tpl_auto(struct bpctl_dev *pbpctl_dev) { if (!pbpctl_dev) return -1; @@ -5130,10 +5130,10 @@ int get_bypass_tpl_auto(bpctl_dev_t *pbpctl_dev) return BP_NOT_CAP; } -int set_tpl_fn(bpctl_dev_t *pbpctl_dev, int tpl_mode) +int set_tpl_fn(struct bpctl_dev *pbpctl_dev, int tpl_mode) { - bpctl_dev_t *pbpctl_dev_b = NULL; + struct bpctl_dev *pbpctl_dev_b = NULL; if (!pbpctl_dev) return -1; @@ -5160,7 +5160,7 @@ int set_tpl_fn(bpctl_dev_t *pbpctl_dev, int tpl_mode) return BP_NOT_CAP; } -int get_tpl_fn(bpctl_dev_t *pbpctl_dev) +int get_tpl_fn(struct bpctl_dev *pbpctl_dev) { int ret = BP_NOT_CAP; if (!pbpctl_dev) @@ -5174,7 +5174,7 @@ int get_tpl_fn(bpctl_dev_t *pbpctl_dev) return ret; } -int set_bp_wait_at_pwup_fn(bpctl_dev_t *pbpctl_dev, int tap_mode) +int set_bp_wait_at_pwup_fn(struct bpctl_dev *pbpctl_dev, int tap_mode) { if (!pbpctl_dev) return -1; @@ -5194,7 +5194,7 @@ int set_bp_wait_at_pwup_fn(bpctl_dev_t *pbpctl_dev, int tap_mode) return BP_NOT_CAP; } -int get_bp_wait_at_pwup_fn(bpctl_dev_t *pbpctl_dev) +int get_bp_wait_at_pwup_fn(struct bpctl_dev *pbpctl_dev) { int ret = 0; if (!pbpctl_dev) @@ -5207,7 +5207,7 @@ int get_bp_wait_at_pwup_fn(bpctl_dev_t *pbpctl_dev) return ret; } -int set_bp_hw_reset_fn(bpctl_dev_t *pbpctl_dev, int tap_mode) +int set_bp_hw_reset_fn(struct bpctl_dev *pbpctl_dev, int tap_mode) { if (!pbpctl_dev) return -1; @@ -5227,7 +5227,7 @@ int set_bp_hw_reset_fn(bpctl_dev_t *pbpctl_dev, int tap_mode) return BP_NOT_CAP; } -int get_bp_hw_reset_fn(bpctl_dev_t *pbpctl_dev) +int get_bp_hw_reset_fn(struct bpctl_dev *pbpctl_dev) { int ret = 0; if (!pbpctl_dev) @@ -5242,7 +5242,7 @@ int get_bp_hw_reset_fn(bpctl_dev_t *pbpctl_dev) } -int get_bypass_info_fn(bpctl_dev_t *pbpctl_dev, char *dev_name, +int get_bypass_info_fn(struct bpctl_dev *pbpctl_dev, char *dev_name, char *add_param) { if (!pbpctl_dev) @@ -5313,7 +5313,7 @@ static int get_dev_idx(int ifindex) return -1; } -static bpctl_dev_t *get_dev_idx_p(int ifindex) +static struct bpctl_dev *get_dev_idx_p(int ifindex) { int idx_dev = 0; @@ -5401,12 +5401,12 @@ static long device_ioctl(struct file *file, /* see include/linux/fs.h */ { struct bpctl_cmd bpctl_cmd; int dev_idx = 0; - bpctl_dev_t *pbpctl_dev_out; + struct bpctl_dev *pbpctl_dev_out; void __user *argp = (void __user *)ioctl_param; int ret = 0; unsigned long flags; - static bpctl_dev_t *pbpctl_dev; + static struct bpctl_dev *pbpctl_dev; /* lock_kernel(); */ if (down_interruptible(&bpctl_sema)) @@ -6623,7 +6623,7 @@ static bpmod_info_t tx_ctl_pci_tbl[] = { {0,} }; -static void find_fw(bpctl_dev_t *dev) +static void find_fw(struct bpctl_dev *dev) { unsigned long mmio_start, mmio_len; struct pci_dev *pdev1 = dev->pdev; @@ -6653,7 +6653,7 @@ static void find_fw(bpctl_dev_t *dev) printk("firmware version: 0x%x\n", dev->bp_fw_ver); } -static int init_one(bpctl_dev_t *dev, bpmod_info_t *info, struct pci_dev *pdev1) +static int init_one(struct bpctl_dev *dev, bpmod_info_t *info, struct pci_dev *pdev1) { unsigned long mmio_start, mmio_len; @@ -6744,7 +6744,7 @@ static int __init bypass_init_module(void) { int ret_val, idx, idx_dev = 0; struct pci_dev *pdev1 = NULL; - bpctl_dev_t *dev; + struct bpctl_dev *dev; printk(BP_MOD_DESCR " v" BP_MOD_VER "\n"); ret_val = register_chrdev(major_num, DEVICE_NAME, &Fops); @@ -6769,14 +6769,14 @@ static int __init bypass_init_module(void) return -1; } - bpctl_dev_arr = kmalloc((device_num) * sizeof(bpctl_dev_t), GFP_KERNEL); + bpctl_dev_arr = kmalloc((device_num) * sizeof(struct bpctl_dev), GFP_KERNEL); if (!bpctl_dev_arr) { printk("Allocation error\n"); unregister_chrdev(major_num, DEVICE_NAME); return -1; } - memset(bpctl_dev_arr, 0, ((device_num) * sizeof(bpctl_dev_t))); + memset(bpctl_dev_arr, 0, ((device_num) * sizeof(struct bpctl_dev))); pdev1 = NULL; dev = bpctl_dev_arr; @@ -6797,7 +6797,7 @@ static int __init bypass_init_module(void) spin_lock_init(&bpvm_lock); { - bpctl_dev_t *pbpctl_dev_c = NULL; + struct bpctl_dev *pbpctl_dev_c = NULL; for (idx_dev = 0, dev = bpctl_dev_arr; idx_dev < device_num && dev->pdev; idx_dev++, dev++) { @@ -7169,7 +7169,7 @@ EXPORT_SYMBOL(get_bypass_caps_sd); int get_bypass_slave_sd(int ifindex) { - bpctl_dev_t *pbpctl_dev_out; + struct bpctl_dev *pbpctl_dev_out; int ret = get_bypass_slave_fn(get_dev_idx_p(ifindex), &pbpctl_dev_out); if (ret == 1) return pbpctl_dev_out->ifindex; @@ -7229,7 +7229,7 @@ int bp_proc_create(void) } static int procfs_add(char *proc_name, const struct file_operations *fops, - bpctl_dev_t *dev) + struct bpctl_dev *dev) { struct bypass_pfs_sd *pfs = &dev->bypass_pfs_set; if (!proc_create_data(proc_name, 0644, pfs->bypass_entry, fops, dev)) @@ -7264,7 +7264,7 @@ static const struct file_operations name##_ops = { \ static int show_bypass_info(struct seq_file *m, void *v) { - bpctl_dev_t *dev = m->private; + struct bpctl_dev *dev = m->private; seq_printf(m, "Name\t\t\t%s\n", dev->name); seq_printf(m, "Firmware version\t0x%x\n", dev->bp_fw_ver); @@ -7274,8 +7274,8 @@ RO_FOPS(bypass_info) static int show_bypass_slave(struct seq_file *m, void *v) { - bpctl_dev_t *dev = m->private; - bpctl_dev_t *slave = get_status_port_fn(dev); + struct bpctl_dev *dev = m->private; + struct bpctl_dev *slave = get_status_port_fn(dev); if (!slave) slave = dev; if (!slave) @@ -7288,7 +7288,7 @@ RO_FOPS(bypass_slave) static int show_bypass_caps(struct seq_file *m, void *v) { - bpctl_dev_t *dev = m->private; + struct bpctl_dev *dev = m->private; int ret = get_bypass_caps_fn(dev); if (ret == BP_NOT_CAP) seq_puts(m, "-1\n"); @@ -7300,7 +7300,7 @@ RO_FOPS(bypass_caps) static int show_wd_set_caps(struct seq_file *m, void *v) { - bpctl_dev_t *dev = m->private; + struct bpctl_dev *dev = m->private; int ret = get_wd_set_caps_fn(dev); if (ret == BP_NOT_CAP) seq_puts(m, "-1\n"); @@ -7346,7 +7346,7 @@ static ssize_t bypass_write(struct file *file, const char __user *buffer, } static int show_bypass(struct seq_file *m, void *v) { - bpctl_dev_t *dev = m->private; + struct bpctl_dev *dev = m->private; int ret = get_bypass_fn(dev); if (ret == BP_NOT_CAP) seq_puts(m, "fail\n"); @@ -7370,7 +7370,7 @@ static ssize_t tap_write(struct file *file, const char __user *buffer, } static int show_tap(struct seq_file *m, void *v) { - bpctl_dev_t *dev = m->private; + struct bpctl_dev *dev = m->private; int ret = get_tap_fn(dev); if (ret == BP_NOT_CAP) seq_puts(m, "fail\n"); @@ -7394,7 +7394,7 @@ static ssize_t disc_write(struct file *file, const char __user *buffer, } static int show_disc(struct seq_file *m, void *v) { - bpctl_dev_t *dev = m->private; + struct bpctl_dev *dev = m->private; int ret = get_disc_fn(dev); if (ret == BP_NOT_CAP) seq_puts(m, "fail\n"); @@ -7408,7 +7408,7 @@ RW_FOPS(disc) static int show_bypass_change(struct seq_file *m, void *v) { - bpctl_dev_t *dev = m->private; + struct bpctl_dev *dev = m->private; int ret = get_bypass_change_fn(dev); if (ret == 1) seq_puts(m, "on\n"); @@ -7422,7 +7422,7 @@ RO_FOPS(bypass_change) static int show_tap_change(struct seq_file *m, void *v) { - bpctl_dev_t *dev = m->private; + struct bpctl_dev *dev = m->private; int ret = get_tap_change_fn(dev); if (ret == 1) seq_puts(m, "on\n"); @@ -7436,7 +7436,7 @@ RO_FOPS(tap_change) static int show_disc_change(struct seq_file *m, void *v) { - bpctl_dev_t *dev = m->private; + struct bpctl_dev *dev = m->private; int ret = get_disc_change_fn(dev); if (ret == 1) seq_puts(m, "on\n"); @@ -7451,7 +7451,7 @@ RO_FOPS(disc_change) static ssize_t bypass_wd_write(struct file *file, const char __user *buffer, size_t count, loff_t *pos) { - bpctl_dev_t *dev = PDE_DATA(file_inode(file)); + struct bpctl_dev *dev = PDE_DATA(file_inode(file)); int timeout; int ret = kstrtoint_from_user(buffer, count, 10, &timeout); if (ret) @@ -7461,7 +7461,7 @@ static ssize_t bypass_wd_write(struct file *file, const char __user *buffer, } static int show_bypass_wd(struct seq_file *m, void *v) { - bpctl_dev_t *dev = m->private; + struct bpctl_dev *dev = m->private; int ret = 0, timeout = 0; ret = get_bypass_wd_fn(dev, &timeout); @@ -7479,7 +7479,7 @@ RW_FOPS(bypass_wd) static int show_wd_expire_time(struct seq_file *m, void *v) { - bpctl_dev_t *dev = m->private; + struct bpctl_dev *dev = m->private; int ret = 0, timeout = 0; ret = get_wd_expire_time_fn(dev, &timeout); if (ret == BP_NOT_CAP) @@ -7497,7 +7497,7 @@ RO_FOPS(wd_expire_time) static ssize_t tpl_write(struct file *file, const char __user *buffer, size_t count, loff_t *pos) { - bpctl_dev_t *dev = PDE_DATA(file_inode(file)); + struct bpctl_dev *dev = PDE_DATA(file_inode(file)); int tpl_param = user_on_off(buffer, count); if (tpl_param < 0) return -1; @@ -7507,7 +7507,7 @@ static ssize_t tpl_write(struct file *file, const char __user *buffer, } static int show_tpl(struct seq_file *m, void *v) { - bpctl_dev_t *dev = m->private; + struct bpctl_dev *dev = m->private; int ret = get_tpl_fn(dev); if (ret == BP_NOT_CAP) seq_puts(m, "fail\n"); @@ -7523,7 +7523,7 @@ RW_FOPS(tpl) static ssize_t wait_at_pwup_write(struct file *file, const char __user *buffer, size_t count, loff_t *pos) { - bpctl_dev_t *dev = PDE_DATA(file_inode(file)); + struct bpctl_dev *dev = PDE_DATA(file_inode(file)); int tpl_param = user_on_off(buffer, count); if (tpl_param < 0) return -1; @@ -7533,7 +7533,7 @@ static ssize_t wait_at_pwup_write(struct file *file, const char __user *buffer, } static int show_wait_at_pwup(struct seq_file *m, void *v) { - bpctl_dev_t *dev = m->private; + struct bpctl_dev *dev = m->private; int ret = get_bp_wait_at_pwup_fn(dev); if (ret == BP_NOT_CAP) seq_puts(m, "fail\n"); @@ -7548,7 +7548,7 @@ RW_FOPS(wait_at_pwup) static ssize_t hw_reset_write(struct file *file, const char __user *buffer, size_t count, loff_t *pos) { - bpctl_dev_t *dev = PDE_DATA(file_inode(file)); + struct bpctl_dev *dev = PDE_DATA(file_inode(file)); int tpl_param = user_on_off(buffer, count); if (tpl_param < 0) return -1; @@ -7558,7 +7558,7 @@ static ssize_t hw_reset_write(struct file *file, const char __user *buffer, } static int show_hw_reset(struct seq_file *m, void *v) { - bpctl_dev_t *dev = m->private; + struct bpctl_dev *dev = m->private; int ret = get_bp_hw_reset_fn(dev); if (ret == BP_NOT_CAP) seq_puts(m, "fail\n"); @@ -7574,7 +7574,7 @@ RW_FOPS(hw_reset) static int show_reset_bypass_wd(struct seq_file *m, void *v) { - bpctl_dev_t *dev = m->private; + struct bpctl_dev *dev = m->private; int ret = reset_bypass_wd_timer_fn(dev); if (ret == BP_NOT_CAP) seq_puts(m, "fail\n"); @@ -7598,7 +7598,7 @@ static ssize_t dis_bypass_write(struct file *file, const char __user *buffer, } static int show_dis_bypass(struct seq_file *m, void *v) { - bpctl_dev_t *dev = m->private; + struct bpctl_dev *dev = m->private; int ret = get_dis_bypass_fn(dev); if (ret == BP_NOT_CAP) seq_puts(m, "fail\n"); @@ -7622,7 +7622,7 @@ static ssize_t dis_tap_write(struct file *file, const char __user *buffer, } static int show_dis_tap(struct seq_file *m, void *v) { - bpctl_dev_t *dev = m->private; + struct bpctl_dev *dev = m->private; int ret = get_dis_tap_fn(dev); if (ret == BP_NOT_CAP) seq_puts(m, "fail\n"); @@ -7646,7 +7646,7 @@ static ssize_t dis_disc_write(struct file *file, const char __user *buffer, } static int show_dis_disc(struct seq_file *m, void *v) { - bpctl_dev_t *dev = m->private; + struct bpctl_dev *dev = m->private; int ret = get_dis_disc_fn(dev); if (ret == BP_NOT_CAP) seq_puts(m, "fail\n"); @@ -7670,7 +7670,7 @@ static ssize_t bypass_pwup_write(struct file *file, const char __user *buffer, } static int show_bypass_pwup(struct seq_file *m, void *v) { - bpctl_dev_t *dev = m->private; + struct bpctl_dev *dev = m->private; int ret = get_bypass_pwup_fn(dev); if (ret == BP_NOT_CAP) seq_puts(m, "fail\n"); @@ -7694,7 +7694,7 @@ static ssize_t bypass_pwoff_write(struct file *file, const char __user *buffer, } static int show_bypass_pwoff(struct seq_file *m, void *v) { - bpctl_dev_t *dev = m->private; + struct bpctl_dev *dev = m->private; int ret = get_bypass_pwoff_fn(dev); if (ret == BP_NOT_CAP) seq_puts(m, "fail\n"); @@ -7718,7 +7718,7 @@ static ssize_t tap_pwup_write(struct file *file, const char __user *buffer, } static int show_tap_pwup(struct seq_file *m, void *v) { - bpctl_dev_t *dev = m->private; + struct bpctl_dev *dev = m->private; int ret = get_tap_pwup_fn(dev); if (ret == BP_NOT_CAP) seq_puts(m, "fail\n"); @@ -7742,7 +7742,7 @@ static ssize_t disc_pwup_write(struct file *file, const char __user *buffer, } static int show_disc_pwup(struct seq_file *m, void *v) { - bpctl_dev_t *dev = m->private; + struct bpctl_dev *dev = m->private; int ret = get_disc_pwup_fn(dev); if (ret == BP_NOT_CAP) seq_puts(m, "fail\n"); @@ -7766,7 +7766,7 @@ static ssize_t std_nic_write(struct file *file, const char __user *buffer, } static int show_std_nic(struct seq_file *m, void *v) { - bpctl_dev_t *dev = m->private; + struct bpctl_dev *dev = m->private; int ret = get_std_nic_fn(dev); if (ret == BP_NOT_CAP) seq_puts(m, "fail\n"); @@ -7808,7 +7808,7 @@ static ssize_t wd_exp_mode_write(struct file *file, const char __user *buffer, } static int show_wd_exp_mode(struct seq_file *m, void *v) { - bpctl_dev_t *dev = m->private; + struct bpctl_dev *dev = m->private; int ret = get_wd_exp_mode_fn(dev); if (ret == 1) seq_puts(m, "tap\n"); @@ -7834,7 +7834,7 @@ static ssize_t wd_autoreset_write(struct file *file, const char __user *buffer, } static int show_wd_autoreset(struct seq_file *m, void *v) { - bpctl_dev_t *dev = m->private; + struct bpctl_dev *dev = m->private; int ret = get_wd_autoreset_fn(dev); if (ret >= 0) seq_printf(m, "%d\n", ret); @@ -7844,7 +7844,7 @@ static int show_wd_autoreset(struct seq_file *m, void *v) } RW_FOPS(wd_autoreset) -int bypass_proc_create_dev_sd(bpctl_dev_t *pbp_device_block) +int bypass_proc_create_dev_sd(struct bpctl_dev *pbp_device_block) { struct bypass_pfs_sd *current_pfs = &(pbp_device_block->bypass_pfs_set); static struct proc_dir_entry *procfs_dir; @@ -7914,7 +7914,7 @@ int bypass_proc_create_dev_sd(bpctl_dev_t *pbp_device_block) return ret; } -int bypass_proc_remove_dev_sd(bpctl_dev_t *pbp_device_block) +int bypass_proc_remove_dev_sd(struct bpctl_dev *pbp_device_block) { struct bypass_pfs_sd *current_pfs = &pbp_device_block->bypass_pfs_set; -- GitLab From c014185968903c3424776cd22d0deb1a493a1df5 Mon Sep 17 00:00:00 2001 From: Chad Williamson Date: Tue, 25 Jun 2013 18:59:23 -0500 Subject: [PATCH 098/942] Staging: silicom: remove the typedef for bpmod_info_t Remove the bpmod_info_t typedef from bpctl_mod.c, replacing it with struct bpmod_info. Signed-off-by: Chad Williamson Signed-off-by: Greg Kroah-Hartman --- drivers/staging/silicom/bpctl_mod.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/silicom/bpctl_mod.c b/drivers/staging/silicom/bpctl_mod.c index 4689076fb7d18..91c864cf4d30f 100644 --- a/drivers/staging/silicom/bpctl_mod.c +++ b/drivers/staging/silicom/bpctl_mod.c @@ -5971,7 +5971,7 @@ enum board_type { PE210G2BPi40, }; -typedef struct _bpmod_info_t { +struct bpmod_info { unsigned int vendor; unsigned int device; unsigned int subvendor; @@ -5979,7 +5979,7 @@ typedef struct _bpmod_info_t { unsigned int index; char *bp_name; -} bpmod_info_t; +}; typedef struct _dev_desc { char *name; @@ -6155,7 +6155,7 @@ dev_desc_t dev_desc[] = { {0}, }; -static bpmod_info_t tx_ctl_pci_tbl[] = { +static struct bpmod_info tx_ctl_pci_tbl[] = { {0x8086, 0x107a, SILICOM_SVID, SILICOM_PXG2BPFI_SSID, PXG2BPFI, "PXG2BPFI-SD"}, {0x8086, 0x107a, SILICOM_SVID, SILICOM_PXG2BPFIL_SSID, PXG2BPFIL, @@ -6653,7 +6653,7 @@ static void find_fw(struct bpctl_dev *dev) printk("firmware version: 0x%x\n", dev->bp_fw_ver); } -static int init_one(struct bpctl_dev *dev, bpmod_info_t *info, struct pci_dev *pdev1) +static int init_one(struct bpctl_dev *dev, struct bpmod_info *info, struct pci_dev *pdev1) { unsigned long mmio_start, mmio_len; -- GitLab From 11c920b0e00f9e009687bdf15c71618e91666731 Mon Sep 17 00:00:00 2001 From: Chad Williamson Date: Tue, 25 Jun 2013 18:59:24 -0500 Subject: [PATCH 099/942] Staging: silicom: remove typedef for dev_desc_t Remove the dev_desc_t typedef for the dev_desc struct in bpctl_mod.c, resolving a checkpatch.pl warning. In fact, we can use an anonymous struct, since it's only used in the single dev_desc array of device descriptions, whose definition follows immediately. Signed-off-by: Chad Williamson Signed-off-by: Greg Kroah-Hartman --- drivers/staging/silicom/bpctl_mod.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/silicom/bpctl_mod.c b/drivers/staging/silicom/bpctl_mod.c index 91c864cf4d30f..32bc530b2cfde 100644 --- a/drivers/staging/silicom/bpctl_mod.c +++ b/drivers/staging/silicom/bpctl_mod.c @@ -5981,11 +5981,9 @@ struct bpmod_info { }; -typedef struct _dev_desc { +struct { char *name; -} dev_desc_t; - -dev_desc_t dev_desc[] = { +} dev_desc[] = { {"Silicom Bypass PXG2BPFI-SD series adapter"}, {"Silicom Bypass PXG2BPFIL-SD series adapter"}, {"Silicom Bypass PXG2BPFILX-SD series adapter"}, -- GitLab From c429df9df06af21912741d5a3848306328564262 Mon Sep 17 00:00:00 2001 From: Vladimir Date: Fri, 12 Jul 2013 09:58:26 +0300 Subject: [PATCH 100/942] Staging: silicom: Remove useless unneeded semicolons Found using coccinelle tool. Signed-off-by: Vladimir Cernov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/silicom/bpctl_mod.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/silicom/bpctl_mod.c b/drivers/staging/silicom/bpctl_mod.c index 32bc530b2cfde..495272d013485 100644 --- a/drivers/staging/silicom/bpctl_mod.c +++ b/drivers/staging/silicom/bpctl_mod.c @@ -1809,7 +1809,7 @@ int cmnd_off(struct bpctl_dev *pbpctl_dev) else data_pulse(pbpctl_dev, CMND_OFF); ret = 0; - }; + } return ret; } @@ -1830,7 +1830,7 @@ int bypass_on(struct bpctl_dev *pbpctl_dev) } else data_pulse(pbpctl_dev, BYPASS_ON); ret = 0; - }; + } return ret; } @@ -1866,7 +1866,7 @@ int tap_off(struct bpctl_dev *pbpctl_dev) write_data(pbpctl_dev, TAP_OFF); msec_delay_bp(LATCH_DELAY); ret = 0; - }; + } return ret; } @@ -1879,7 +1879,7 @@ int tap_on(struct bpctl_dev *pbpctl_dev) write_data(pbpctl_dev, TAP_ON); msec_delay_bp(LATCH_DELAY); ret = 0; - }; + } return ret; } @@ -2025,7 +2025,7 @@ int wdt_off(struct bpctl_dev *pbpctl_dev) data_pulse(pbpctl_dev, WDT_OFF); pbpctl_dev->wdt_status = WDT_STATUS_DIS; ret = 0; - }; + } return ret; } @@ -2568,7 +2568,7 @@ int reset_cont(struct bpctl_dev *pbpctl_dev) else data_pulse(pbpctl_dev, RESET_CONT); ret = 0; - }; + } return ret; } @@ -3497,7 +3497,7 @@ int wdt_programmed(struct bpctl_dev *pbpctl_dev, int *timeout) *timeout = curr_wdt_status == 0 ? 0 : pbpctl_dev->bypass_timer_interval; - }; + } } else ret = BP_NOT_CAP; return ret; @@ -3548,7 +3548,7 @@ int normal_support(struct bpctl_dev *pbpctl_dev) NORMAL_UNSUPPORT_MASK) ? 0 : 1); } else ret = 1; - }; + } return ret; } @@ -5111,7 +5111,7 @@ int set_bypass_tpl_auto(struct bpctl_dev *pbpctl_dev, unsigned int param) pbpctl_dev->bp_tpl_flag = param; mod_timer(&pbpctl_dev->bp_tpl_timer, jiffies + 1); return BP_OK; - }; + } if ((!param) && (pbpctl_dev->bp_tpl_flag)) remove_bypass_tpl_auto(pbpctl_dev); -- GitLab From f2a04351edea25eb9b380ea183ed223e4f445791 Mon Sep 17 00:00:00 2001 From: Xenia Ragiadakou Date: Wed, 26 Jun 2013 04:21:40 +0300 Subject: [PATCH 101/942] staging: rtl8192u: remove commented-out code in r819xU_cmdpkt.c This patch removes commented-out code and the comments that refer to it to facilitate code review. Signed-off-by: Xenia Ragiadakou Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_cmdpkt.c | 42 ++---------------------- 1 file changed, 2 insertions(+), 40 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_cmdpkt.c b/drivers/staging/rtl8192u/r819xU_cmdpkt.c index 6810766edfcf1..5b3a3a21d4bf7 100644 --- a/drivers/staging/rtl8192u/r819xU_cmdpkt.c +++ b/drivers/staging/rtl8192u/r819xU_cmdpkt.c @@ -50,9 +50,6 @@ SendTxCommandPacket( struct sk_buff *skb; cb_desc *tcb_desc; unsigned char *ptr_buf; - //bool bLastInitPacket = false; - - //PlatformAcquireSpinLock(Adapter, RT_TX_SPINLOCK); //Get TCB and local buffer from common pool. (It is shared by CmdQ, MgntQ, and USB coalesce DataQ) skb = dev_alloc_skb(USB_HWDESC_HEADER_LEN + DataLen + 4); @@ -75,7 +72,6 @@ SendTxCommandPacket( priv->ieee80211->softmac_hard_start_xmit(skb,dev); } - //PlatformReleaseSpinLock(Adapter, RT_TX_SPINLOCK); return rtStatus; } @@ -113,8 +109,6 @@ SendTxCommandPacket( struct r8192_priv *priv = ieee80211_priv(dev); u16 frag_threshold; u16 frag_length, frag_offset = 0; - //u16 total_size; - //int i; rt_firmware *pfirmware = priv->pFirmware; struct sk_buff *skb; @@ -310,15 +304,11 @@ cmpk_handle_tx_feedback( priv->stats.txfeedback++; - /* 0. Display received message. */ - //cmpk_Display_Message(CMPK_RX_TX_FB_SIZE, pMsg); - /* 1. Extract TX feedback info from RFD to temp structure buffer. */ /* It seems that FW use big endian(MIPS) and DRV use little endian in windows OS. So we have to read the content byte by byte or transfer endian type before copy the message copy. */ /* 2007/07/05 MH Use pointer to transfer structure memory. */ - //memcpy((UINT8 *)&rx_tx_fb, pMsg, sizeof(CMPK_TXFB_T)); memcpy((u8 *)&rx_tx_fb, pmsg, sizeof(cmpk_txfb_t)); /* 2. Use tx feedback info to count TX statistics. */ cmpk_count_txstatistic(dev, &rx_tx_fb); @@ -326,7 +316,6 @@ cmpk_handle_tx_feedback( /* Collect info TX feedback packet to fill TCB. */ /* We can not know the packet length and transmit type: broadcast or uni or multicast. */ - //CountTxStatistics( pAdapter, &tcb ); } /* cmpk_Handle_Tx_Feedback */ @@ -393,15 +382,10 @@ cmpk_handle_interrupt_status( DMESG("---> cmpk_Handle_Interrupt_Status()\n"); - /* 0. Display received message. */ - //cmpk_Display_Message(CMPK_RX_BEACON_STATE_SIZE, pMsg); - /* 1. Extract TX feedback info from RFD to temp structure buffer. */ /* It seems that FW use big endian(MIPS) and DRV use little endian in windows OS. So we have to read the content byte by byte or transfer endian type before copy the message copy. */ - //rx_bcn_state.Element_ID = pMsg[0]; - //rx_bcn_state.Length = pMsg[1]; rx_intr_status.length = pmsg[1]; if (rx_intr_status.length != (sizeof(cmpk_intr_sta_t) - 2)) { @@ -415,7 +399,6 @@ cmpk_handle_interrupt_status( { //2 maybe need endian transform? rx_intr_status.interrupt_status = *((u32 *)(pmsg + 4)); - //rx_intr_status.InterruptStatus = N2H4BYTE(*((UINT32 *)(pMsg + 4))); DMESG("interrupt status = 0x%x\n", rx_intr_status.interrupt_status); @@ -471,15 +454,11 @@ cmpk_handle_query_config_rx( { cmpk_query_cfg_t rx_query_cfg; /* */ - /* 0. Display received message. */ - //cmpk_Display_Message(CMPK_RX_BEACON_STATE_SIZE, pMsg); /* 1. Extract TX feedback info from RFD to temp structure buffer. */ /* It seems that FW use big endian(MIPS) and DRV use little endian in windows OS. So we have to read the content byte by byte or transfer endian type before copy the message copy. */ - //rx_query_cfg.Element_ID = pMsg[0]; - //rx_query_cfg.Length = pMsg[1]; rx_query_cfg.cfg_action = (pmsg[4] & 0x80000000)>>31; rx_query_cfg.cfg_type = (pmsg[4] & 0x60) >> 5; rx_query_cfg.cfg_size = (pmsg[4] & 0x18) >> 3; @@ -539,9 +518,6 @@ static void cmpk_count_tx_status( struct net_device *dev, priv->stats.txretrycount += pstx_status->txretry; priv->stats.txfeedbackretry += pstx_status->txretry; - //pAdapter->TxStats.NumTxOkBytesTotal += psTx_FB->pkt_length; - //pAdapter->TxStats.NumTxErrBytesTotal += psTx_FB->pkt_length; - //pAdapter->MgntInfo.LinkDetectInfo.NumTxOkInPeriod++; priv->stats.txmulticast += pstx_status->txmcok; priv->stats.txbroadcast += pstx_status->txbcok; @@ -613,7 +589,6 @@ cmpk_handle_tx_rate_history( u8 *pmsg) { cmpk_tx_rahis_t *ptxrate; -// RT_RF_POWER_STATE rtState; u8 i, j; u16 length = sizeof(cmpk_tx_rahis_t); u32 *ptemp; @@ -696,7 +671,6 @@ cmpk_message_handle_rx( struct net_device *dev, struct ieee80211_rx_stats *pstats) { -// u32 debug_level = DBG_LOUD; int total_length; u8 cmd_length, exe_cnt = 0; u8 element_id; @@ -704,11 +678,8 @@ cmpk_message_handle_rx( /* 0. Check inpt arguments. If is is a command queue message or pointer is null. */ - if (/*(prfd->queue_id != CMPK_RX_QUEUE_ID) || */(pstats== NULL)) + if (pstats== NULL) { - /* Print error message. */ - /*RT_TRACE(COMP_SEND, DebugLevel, - ("\n\r[CMPK]-->Err queue id or pointer"));*/ return 0; /* This is not a command packet. */ } @@ -720,8 +691,6 @@ cmpk_message_handle_rx( /* 3. Read command packet element id and length. */ element_id = pcmd_buff[0]; - /*RT_TRACE(COMP_SEND, DebugLevel, - ("\n\r[CMPK]-->element ID=%d Len=%d", element_id, total_length));*/ /* 4. Check every received command packet content according to different element type. Because FW may aggregate RX command packet to minimize @@ -757,12 +726,10 @@ cmpk_message_handle_rx( case RX_TX_PER_PKT_FEEDBACK: // You must at lease add a switch case element here, // Otherwise, we will jump to default case. - //DbgPrint("CCX Test\r\n"); cmd_length = CMPK_RX_TX_FB_SIZE; break; case RX_TX_RATE_HISTORY: - //DbgPrint(" rx tx rate history\r\n"); cmpk_handle_tx_rate_history(dev, pcmd_buff); cmd_length = CMPK_TX_RAHIS_SIZE; break; @@ -772,15 +739,10 @@ cmpk_message_handle_rx( RT_TRACE(COMP_ERR, "---->cmpk_message_handle_rx():unknow CMD Element\n"); return 1; /* This is a command packet. */ } - // 2007/01/22 MH Display received rx command packet info. - //cmpk_Display_Message(cmd_length, pcmd_buff); - - // 2007/01/22 MH Add to display tx statistic. - //cmpk_DisplayTxStatistic(pAdapter); total_length -= cmd_length; pcmd_buff += cmd_length; - } /* while (total_length > 0) */ + } return 1; /* This is a command packet. */ } /* CMPK_Message_Handle_Rx */ -- GitLab From 05cdf47ac3374f91a2ac438be58f216562aa9b72 Mon Sep 17 00:00:00 2001 From: Xenia Ragiadakou Date: Wed, 26 Jun 2013 04:21:41 +0300 Subject: [PATCH 102/942] staging: rtl8192u: fix braces in r819xU_cmdpkt.c This patch fixes the brace position according to the linux kernel coding style and removes unnecessary braces. Signed-off-by: Xenia Ragiadakou Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_cmdpkt.c | 70 +++++------------------- 1 file changed, 15 insertions(+), 55 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_cmdpkt.c b/drivers/staging/rtl8192u/r819xU_cmdpkt.c index 5b3a3a21d4bf7..fd69da732d82c 100644 --- a/drivers/staging/rtl8192u/r819xU_cmdpkt.c +++ b/drivers/staging/rtl8192u/r819xU_cmdpkt.c @@ -209,9 +209,7 @@ cmpk_count_txstatistic( // reason, ie. there may be a duration while sw switch is changed and hw // switch is being changed. 2006.12.04, by shien chang. if (rtState == eRfOff) - { return; - } #endif #ifdef TODO @@ -221,49 +219,35 @@ cmpk_count_txstatistic( /* We can not know the packet length and transmit type: broadcast or uni or multicast. So the relative statistics must be collected in tx feedback info. */ - if (pstx_fb->tok) - { + if (pstx_fb->tok) { priv->stats.txfeedbackok++; priv->stats.txoktotal++; priv->stats.txokbytestotal += pstx_fb->pkt_length; priv->stats.txokinperiod++; /* We can not make sure broadcast/multicast or unicast mode. */ - if (pstx_fb->pkt_type == PACKET_MULTICAST) - { + if (pstx_fb->pkt_type == PACKET_MULTICAST) { priv->stats.txmulticast++; priv->stats.txbytesmulticast += pstx_fb->pkt_length; - } - else if (pstx_fb->pkt_type == PACKET_BROADCAST) - { + } else if (pstx_fb->pkt_type == PACKET_BROADCAST) { priv->stats.txbroadcast++; priv->stats.txbytesbroadcast += pstx_fb->pkt_length; - } - else - { + } else { priv->stats.txunicast++; priv->stats.txbytesunicast += pstx_fb->pkt_length; } - } - else - { + } else { priv->stats.txfeedbackfail++; priv->stats.txerrtotal++; priv->stats.txerrbytestotal += pstx_fb->pkt_length; /* We can not make sure broadcast/multicast or unicast mode. */ if (pstx_fb->pkt_type == PACKET_MULTICAST) - { priv->stats.txerrmulticast++; - } else if (pstx_fb->pkt_type == PACKET_BROADCAST) - { priv->stats.txerrbroadcast++; - } else - { priv->stats.txerrunicast++; - } } priv->stats.txretrycount += pstx_fb->retry_cnt; @@ -326,26 +310,21 @@ cmdpkt_beacontimerinterrupt_819xusb( { struct r8192_priv *priv = ieee80211_priv(dev); u16 tx_rate; - { // // 070117, rcnjko: 87B have to S/W beacon for DTM encryption_cmn. // if (priv->ieee80211->current_network.mode == IEEE_A || priv->ieee80211->current_network.mode == IEEE_N_5G || - (priv->ieee80211->current_network.mode == IEEE_N_24G && (!priv->ieee80211->pHTInfo->bCurSuppCCK))) - { + (priv->ieee80211->current_network.mode == IEEE_N_24G && (!priv->ieee80211->pHTInfo->bCurSuppCCK))) { tx_rate = 60; DMESG("send beacon frame tx rate is 6Mbpm\n"); - } - else - { + } else { tx_rate =10; DMESG("send beacon frame tx rate is 1Mbpm\n"); } rtl819xusb_beacon_tx(dev,tx_rate); // HW Beacon - } } @@ -387,36 +366,29 @@ cmpk_handle_interrupt_status( windows OS. So we have to read the content byte by byte or transfer endian type before copy the message copy. */ rx_intr_status.length = pmsg[1]; - if (rx_intr_status.length != (sizeof(cmpk_intr_sta_t) - 2)) - { + if (rx_intr_status.length != (sizeof(cmpk_intr_sta_t) - 2)) { DMESG("cmpk_Handle_Interrupt_Status: wrong length!\n"); return; } // Statistics of beacon for ad-hoc mode. - if ( priv->ieee80211->iw_mode == IW_MODE_ADHOC) - { + if ( priv->ieee80211->iw_mode == IW_MODE_ADHOC) { //2 maybe need endian transform? rx_intr_status.interrupt_status = *((u32 *)(pmsg + 4)); DMESG("interrupt status = 0x%x\n", rx_intr_status.interrupt_status); - if (rx_intr_status.interrupt_status & ISR_TxBcnOk) - { + if (rx_intr_status.interrupt_status & ISR_TxBcnOk) { priv->ieee80211->bibsscoordinator = true; priv->stats.txbeaconokint++; - } - else if (rx_intr_status.interrupt_status & ISR_TxBcnErr) - { + } else if (rx_intr_status.interrupt_status & ISR_TxBcnErr) { priv->ieee80211->bibsscoordinator = false; priv->stats.txbeaconerr++; } if (rx_intr_status.interrupt_status & ISR_BcnTimerIntr) - { cmdpkt_beacontimerinterrupt_819xusb(dev); - } } @@ -504,9 +476,7 @@ static void cmpk_count_tx_status( struct net_device *dev, // reason, ie. there may be a duration while sw switch is changed and hw // switch is being changed. 2006.12.04, by shien chang. if (rtState == eRfOff) - { return; - } #endif priv->stats.txfeedbackok += pstx_status->txok; @@ -602,9 +572,7 @@ cmpk_handle_tx_rate_history( // reason, ie. there may be a duration while sw switch is changed and hw // switch is being changed. 2006.12.04, by shien chang. if (rtState == eRfOff) - { return; - } #endif ptemp = (u32 *)pmsg; @@ -613,8 +581,7 @@ cmpk_handle_tx_rate_history( // Do endian transfer to word alignment(16 bits) for windows system. // You must do different endian transfer for linux and MAC OS // - for (i = 0; i < (length/4); i++) - { + for (i = 0; i < (length/4); i++) { u16 temp1, temp2; temp1 = ptemp[i]&0x0000FFFF; @@ -625,12 +592,9 @@ cmpk_handle_tx_rate_history( ptxrate = (cmpk_tx_rahis_t *)pmsg; if (ptxrate == NULL ) - { return; - } - for (i = 0; i < 16; i++) - { + for (i = 0; i < 16; i++) { // Collect CCK rate packet num if (i < 4) priv->stats.txrate.cck[i] += ptxrate->cck[i]; @@ -679,9 +643,7 @@ cmpk_message_handle_rx( /* 0. Check inpt arguments. If is is a command queue message or pointer is null. */ if (pstats== NULL) - { return 0; /* This is not a command packet. */ - } /* 1. Read received command packet message length from RFD. */ total_length = pstats->Length; @@ -696,13 +658,11 @@ cmpk_message_handle_rx( element type. Because FW may aggregate RX command packet to minimize transmit time between DRV and FW.*/ // Add a counter to prevent the lock in the loop from being held too long - while (total_length > 0 && exe_cnt++ < 100) - { + while (total_length > 0 && exe_cnt++ < 100) { /* 2007/01/17 MH We support aggregation of different cmd in the same packet. */ element_id = pcmd_buff[0]; - switch (element_id) - { + switch (element_id) { case RX_TX_FEEDBACK: cmpk_handle_tx_feedback (dev, pcmd_buff); cmd_length = CMPK_RX_TX_FB_SIZE; -- GitLab From fa6b108bb17558d721c5adfa48fc309388cd0230 Mon Sep 17 00:00:00 2001 From: Xenia Ragiadakou Date: Wed, 26 Jun 2013 04:21:42 +0300 Subject: [PATCH 103/942] staging: rtl8192u: fix whitespace in r819xU_cmdpkt.c This patch fixes whitespaces in r819xU_cmdpkt.c to follow the kernel coding style and to improve code readability. It fixes the spaces around <,=||&&();} and adds or removes tabs to better align variables. Signed-off-by: Xenia Ragiadakou Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_cmdpkt.c | 150 +++++++++-------------- 1 file changed, 60 insertions(+), 90 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_cmdpkt.c b/drivers/staging/rtl8192u/r819xU_cmdpkt.c index fd69da732d82c..777286beffb31 100644 --- a/drivers/staging/rtl8192u/r819xU_cmdpkt.c +++ b/drivers/staging/rtl8192u/r819xU_cmdpkt.c @@ -33,17 +33,12 @@ u32 temp[10];\ \ memcpy(temp, Address, 40);\ - for (i = 0; i <40; i+=4)\ + for (i = 0; i < 40; i += 4)\ printk("\r\n %08x", temp[i]);\ }\ /*---------------------------Define functions---------------------------------*/ -rt_status -SendTxCommandPacket( - struct net_device *dev, - void *pData, - u32 DataLen - ) +rt_status SendTxCommandPacket(struct net_device *dev, void *pData, u32 DataLen) { rt_status rtStatus = RT_STATUS_SUCCESS; struct r8192_priv *priv = ieee80211_priv(dev); @@ -53,23 +48,23 @@ SendTxCommandPacket( //Get TCB and local buffer from common pool. (It is shared by CmdQ, MgntQ, and USB coalesce DataQ) skb = dev_alloc_skb(USB_HWDESC_HEADER_LEN + DataLen + 4); - memcpy((unsigned char *)(skb->cb),&dev,sizeof(dev)); + memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev)); tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); tcb_desc->queue_index = TXCMD_QUEUE; tcb_desc->bCmdOrInit = DESC_PACKET_TYPE_NORMAL; tcb_desc->bLastIniPkt = 0; skb_reserve(skb, USB_HWDESC_HEADER_LEN); ptr_buf = skb_put(skb, DataLen); - memcpy(ptr_buf,pData,DataLen); - tcb_desc->txbuf_size= (u16)DataLen; + memcpy(ptr_buf, pData, DataLen); + tcb_desc->txbuf_size = (u16)DataLen; - if (!priv->ieee80211->check_nic_enough_desc(dev,tcb_desc->queue_index)|| - (!skb_queue_empty(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index]))||\ - (priv->ieee80211->queue_stop) ) { - RT_TRACE(COMP_FIRMWARE,"===================NULL packet==================================> tx full!\n"); + if (!priv->ieee80211->check_nic_enough_desc(dev, tcb_desc->queue_index) || + (!skb_queue_empty(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index])) ||\ + (priv->ieee80211->queue_stop)) { + RT_TRACE(COMP_FIRMWARE, "===================NULL packet==================================> tx full!\n"); skb_queue_tail(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index], skb); } else { - priv->ieee80211->softmac_hard_start_xmit(skb,dev); + priv->ieee80211->softmac_hard_start_xmit(skb, dev); } return rtStatus; @@ -95,11 +90,9 @@ SendTxCommandPacket( * 05/06/2008 amy porting from windows code. * *---------------------------------------------------------------------------*/ - extern rt_status cmpk_message_handle_tx( - struct net_device *dev, - u8 *codevirtualaddress, - u32 packettype, - u32 buffer_len) +extern rt_status cmpk_message_handle_tx(struct net_device *dev, + u8 *codevirtualaddress, + u32 packettype, u32 buffer_len) { bool rt_status = true; @@ -121,7 +114,7 @@ SendTxCommandPacket( frag_threshold = pfirmware->cmdpacket_frag_thresold; do { if ((buffer_len - frag_offset) > frag_threshold) { - frag_length = frag_threshold ; + frag_length = frag_threshold; bLastIniPkt = 0; } else { @@ -138,7 +131,7 @@ SendTxCommandPacket( #else skb = dev_alloc_skb(frag_length + 4); #endif - memcpy((unsigned char *)(skb->cb),&dev,sizeof(dev)); + memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev)); tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); tcb_desc->queue_index = TXCMD_QUEUE; tcb_desc->bCmdOrInit = packettype; @@ -153,23 +146,23 @@ SendTxCommandPacket( * Transform from little endian to big endian * and pending zero */ - memcpy(seg_ptr,codevirtualaddress,buffer_len); - tcb_desc->txbuf_size= (u16)buffer_len; + memcpy(seg_ptr, codevirtualaddress, buffer_len); + tcb_desc->txbuf_size = (u16)buffer_len; - if (!priv->ieee80211->check_nic_enough_desc(dev,tcb_desc->queue_index)|| - (!skb_queue_empty(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index]))||\ - (priv->ieee80211->queue_stop) ) { - RT_TRACE(COMP_FIRMWARE,"=====================================================> tx full!\n"); + if (!priv->ieee80211->check_nic_enough_desc(dev, tcb_desc->queue_index) || + (!skb_queue_empty(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index])) ||\ + (priv->ieee80211->queue_stop)) { + RT_TRACE(COMP_FIRMWARE, "=====================================================> tx full!\n"); skb_queue_tail(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index], skb); } else { - priv->ieee80211->softmac_hard_start_xmit(skb,dev); + priv->ieee80211->softmac_hard_start_xmit(skb, dev); } codevirtualaddress += frag_length; frag_offset += frag_length; - }while(frag_offset < buffer_len); + } while (frag_offset < buffer_len); return rt_status; @@ -194,10 +187,7 @@ SendTxCommandPacket( * 05/12/2008 amy Create Version 0 porting from windows code. * *---------------------------------------------------------------------------*/ -static void -cmpk_count_txstatistic( - struct net_device *dev, - cmpk_txfb_t *pstx_fb) +static void cmpk_count_txstatistic(struct net_device *dev, cmpk_txfb_t *pstx_fb) { struct r8192_priv *priv = ieee80211_priv(dev); #ifdef ENABLE_PS @@ -278,10 +268,7 @@ cmpk_count_txstatistic( * 05/08/2008 amy Create Version 0 porting from windows code. * *---------------------------------------------------------------------------*/ -static void -cmpk_handle_tx_feedback( - struct net_device *dev, - u8 *pmsg) +static void cmpk_handle_tx_feedback(struct net_device *dev, u8 *pmsg) { struct r8192_priv *priv = ieee80211_priv(dev); cmpk_txfb_t rx_tx_fb; /* */ @@ -303,27 +290,24 @@ cmpk_handle_tx_feedback( } /* cmpk_Handle_Tx_Feedback */ -void -cmdpkt_beacontimerinterrupt_819xusb( - struct net_device *dev -) +void cmdpkt_beacontimerinterrupt_819xusb(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv(dev); u16 tx_rate; // // 070117, rcnjko: 87B have to S/W beacon for DTM encryption_cmn. // - if (priv->ieee80211->current_network.mode == IEEE_A || + if (priv->ieee80211->current_network.mode == IEEE_A || priv->ieee80211->current_network.mode == IEEE_N_5G || - (priv->ieee80211->current_network.mode == IEEE_N_24G && (!priv->ieee80211->pHTInfo->bCurSuppCCK))) { + (priv->ieee80211->current_network.mode == IEEE_N_24G && (!priv->ieee80211->pHTInfo->bCurSuppCCK))) { tx_rate = 60; DMESG("send beacon frame tx rate is 6Mbpm\n"); } else { - tx_rate =10; + tx_rate = 10; DMESG("send beacon frame tx rate is 1Mbpm\n"); } - rtl819xusb_beacon_tx(dev,tx_rate); // HW Beacon + rtl819xusb_beacon_tx(dev, tx_rate); // HW Beacon } @@ -351,10 +335,7 @@ cmdpkt_beacontimerinterrupt_819xusb( * 05/12/2008 amy Add this for rtl8192 porting from windows code. * *---------------------------------------------------------------------------*/ -static void -cmpk_handle_interrupt_status( - struct net_device *dev, - u8 *pmsg) +static void cmpk_handle_interrupt_status(struct net_device *dev, u8 *pmsg) { cmpk_intr_sta_t rx_intr_status; /* */ struct r8192_priv *priv = ieee80211_priv(dev); @@ -373,7 +354,7 @@ cmpk_handle_interrupt_status( // Statistics of beacon for ad-hoc mode. - if ( priv->ieee80211->iw_mode == IW_MODE_ADHOC) { + if (priv->ieee80211->iw_mode == IW_MODE_ADHOC) { //2 maybe need endian transform? rx_intr_status.interrupt_status = *((u32 *)(pmsg + 4)); @@ -419,10 +400,7 @@ cmpk_handle_interrupt_status( * 05/12/2008 amy Create Version 0 porting from windows code. * *---------------------------------------------------------------------------*/ -static void -cmpk_handle_query_config_rx( - struct net_device *dev, - u8 *pmsg) +static void cmpk_handle_query_config_rx(struct net_device *dev, u8 *pmsg) { cmpk_query_cfg_t rx_query_cfg; /* */ @@ -431,15 +409,15 @@ cmpk_handle_query_config_rx( /* It seems that FW use big endian(MIPS) and DRV use little endian in windows OS. So we have to read the content byte by byte or transfer endian type before copy the message copy. */ - rx_query_cfg.cfg_action = (pmsg[4] & 0x80000000)>>31; + rx_query_cfg.cfg_action = (pmsg[4] & 0x80000000) >> 31; rx_query_cfg.cfg_type = (pmsg[4] & 0x60) >> 5; rx_query_cfg.cfg_size = (pmsg[4] & 0x18) >> 3; rx_query_cfg.cfg_page = (pmsg[6] & 0x0F) >> 0; - rx_query_cfg.cfg_offset = pmsg[7]; - rx_query_cfg.value = (pmsg[8] << 24) | (pmsg[9] << 16) | - (pmsg[10] << 8) | (pmsg[11] << 0); - rx_query_cfg.mask = (pmsg[12] << 24) | (pmsg[13] << 16) | - (pmsg[14] << 8) | (pmsg[15] << 0); + rx_query_cfg.cfg_offset = pmsg[7]; + rx_query_cfg.value = (pmsg[8] << 24) | (pmsg[9] << 16) | + (pmsg[10] << 8) | (pmsg[11] << 0); + rx_query_cfg.mask = (pmsg[12] << 24) | (pmsg[13] << 16) | + (pmsg[14] << 8) | (pmsg[15] << 0); } /* cmpk_Handle_Query_Config_Rx */ @@ -461,8 +439,8 @@ cmpk_handle_query_config_rx( * 05/12/2008 amy Create Version 0 porting from windows code. * *---------------------------------------------------------------------------*/ -static void cmpk_count_tx_status( struct net_device *dev, - cmpk_tx_status_t *pstx_status) +static void cmpk_count_tx_status(struct net_device *dev, + cmpk_tx_status_t *pstx_status) { struct r8192_priv *priv = ieee80211_priv(dev); @@ -485,12 +463,12 @@ static void cmpk_count_tx_status( struct net_device *dev, priv->stats.txfeedbackfail += pstx_status->txfail; priv->stats.txerrtotal += pstx_status->txfail; - priv->stats.txretrycount += pstx_status->txretry; + priv->stats.txretrycount += pstx_status->txretry; priv->stats.txfeedbackretry += pstx_status->txretry; - priv->stats.txmulticast += pstx_status->txmcok; - priv->stats.txbroadcast += pstx_status->txbcok; + priv->stats.txmulticast += pstx_status->txmcok; + priv->stats.txbroadcast += pstx_status->txbcok; priv->stats.txunicast += pstx_status->txucok; priv->stats.txerrmulticast += pstx_status->txmcfail; @@ -499,9 +477,9 @@ static void cmpk_count_tx_status( struct net_device *dev, priv->stats.txbytesmulticast += pstx_status->txmclength; priv->stats.txbytesbroadcast += pstx_status->txbclength; - priv->stats.txbytesunicast += pstx_status->txuclength; + priv->stats.txbytesunicast += pstx_status->txuclength; - priv->stats.last_packet_rate = pstx_status->rate; + priv->stats.last_packet_rate = pstx_status->rate; } /* cmpk_CountTxStatus */ @@ -523,10 +501,7 @@ static void cmpk_count_tx_status( struct net_device *dev, * 05/12/2008 amy Create Version 0 porting from windows code. * *---------------------------------------------------------------------------*/ -static void -cmpk_handle_tx_status( - struct net_device *dev, - u8 *pmsg) +static void cmpk_handle_tx_status(struct net_device *dev, u8 *pmsg) { cmpk_tx_status_t rx_tx_sts; /* */ @@ -553,15 +528,12 @@ cmpk_handle_tx_status( * 05/12/2008 amy Create Version 0 porting from windows code. * *---------------------------------------------------------------------------*/ -static void -cmpk_handle_tx_rate_history( - struct net_device *dev, - u8 *pmsg) +static void cmpk_handle_tx_rate_history(struct net_device *dev, u8 *pmsg) { cmpk_tx_rahis_t *ptxrate; - u8 i, j; - u16 length = sizeof(cmpk_tx_rahis_t); - u32 *ptemp; + u8 i, j; + u16 length = sizeof(cmpk_tx_rahis_t); + u32 *ptemp; struct r8192_priv *priv = ieee80211_priv(dev); @@ -584,14 +556,14 @@ cmpk_handle_tx_rate_history( for (i = 0; i < (length/4); i++) { u16 temp1, temp2; - temp1 = ptemp[i]&0x0000FFFF; - temp2 = ptemp[i]>>16; - ptemp[i] = (temp1<<16)|temp2; + temp1 = ptemp[i] & 0x0000FFFF; + temp2 = ptemp[i] >> 16; + ptemp[i] = (temp1 << 16) | temp2; } ptxrate = (cmpk_tx_rahis_t *)pmsg; - if (ptxrate == NULL ) + if (ptxrate == NULL) return; for (i = 0; i < 16; i++) { @@ -600,7 +572,7 @@ cmpk_handle_tx_rate_history( priv->stats.txrate.cck[i] += ptxrate->cck[i]; // Collect OFDM rate packet num - if (i< 8) + if (i < 8) priv->stats.txrate.ofdm[i] += ptxrate->ofdm[i]; for (j = 0; j < 4; j++) @@ -630,10 +602,8 @@ cmpk_handle_tx_rate_history( * 05/06/2008 amy Create Version 0 porting from windows code. * *---------------------------------------------------------------------------*/ -extern u32 -cmpk_message_handle_rx( - struct net_device *dev, - struct ieee80211_rx_stats *pstats) +extern u32 cmpk_message_handle_rx(struct net_device *dev, + struct ieee80211_rx_stats *pstats) { int total_length; u8 cmd_length, exe_cnt = 0; @@ -642,7 +612,7 @@ cmpk_message_handle_rx( /* 0. Check inpt arguments. If is is a command queue message or pointer is null. */ - if (pstats== NULL) + if (pstats == NULL) return 0; /* This is not a command packet. */ /* 1. Read received command packet message length from RFD. */ @@ -664,7 +634,7 @@ cmpk_message_handle_rx( switch (element_id) { case RX_TX_FEEDBACK: - cmpk_handle_tx_feedback (dev, pcmd_buff); + cmpk_handle_tx_feedback(dev, pcmd_buff); cmd_length = CMPK_RX_TX_FB_SIZE; break; -- GitLab From 6df9f669de3da57e661e27e6f55799ae587fb2c9 Mon Sep 17 00:00:00 2001 From: Xenia Ragiadakou Date: Wed, 26 Jun 2013 04:21:43 +0300 Subject: [PATCH 104/942] staging: rtl8192u: fix comments in r819xU_cmdpkt.c This patches fixes comments by: - replacing // comments with /**/ comments - removing unnecessary comments (trailing comments with the function name, comments stating date/author when they are placed inside the function definition) - fixing internal alignment Signed-off-by: Xenia Ragiadakou Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_cmdpkt.c | 252 +++++++++++------------ 1 file changed, 125 insertions(+), 127 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_cmdpkt.c b/drivers/staging/rtl8192u/r819xU_cmdpkt.c index 777286beffb31..b6a6e44200a7e 100644 --- a/drivers/staging/rtl8192u/r819xU_cmdpkt.c +++ b/drivers/staging/rtl8192u/r819xU_cmdpkt.c @@ -1,32 +1,34 @@ /****************************************************************************** - - (c) Copyright 2008, RealTEK Technologies Inc. All Rights Reserved. - - Module: r819xusb_cmdpkt.c (RTL8190 TX/RX command packet handler Source C File) - - Note: The module is responsible for handling TX and RX command packet. - 1. TX : Send set and query configuration command packet. - 2. RX : Receive tx feedback, beacon state, query configuration - command packet. - - Function: - - Export: - - Abbrev: - - History: - Data Who Remark - - 05/06/2008 amy Create initial version porting from windows driver. - -******************************************************************************/ + * + * (c) Copyright 2008, RealTEK Technologies Inc. All Rights Reserved. + * + * Module: r819xusb_cmdpkt.c + * (RTL8190 TX/RX command packet handler Source C File) + * + * Note: The module is responsible for handling TX and RX command packet. + * 1. TX : Send set and query configuration command packet. + * 2. RX : Receive tx feedback, beacon state, query configuration + * command packet. + * + * Function: + * + * Export: + * + * Abbrev: + * + * History: + * + * Date Who Remark + * 05/06/2008 amy Create initial version porting from + * windows driver. + * + ******************************************************************************/ #include "r8192U.h" #include "r819xU_cmdpkt.h" -/*---------------------------Define Local Constant---------------------------*/ -/* Debug constant*/ + +/* Debug constant */ #define CMPK_DEBOUNCE_CNT 1 -/* 2007/10/24 MH Add for printing a range of data. */ +/* Add for printing a range of data. */ #define CMPK_PRINT(Address)\ {\ unsigned char i;\ @@ -36,7 +38,6 @@ for (i = 0; i < 40; i += 4)\ printk("\r\n %08x", temp[i]);\ }\ -/*---------------------------Define functions---------------------------------*/ rt_status SendTxCommandPacket(struct net_device *dev, void *pData, u32 DataLen) { @@ -46,7 +47,8 @@ rt_status SendTxCommandPacket(struct net_device *dev, void *pData, u32 DataLen) cb_desc *tcb_desc; unsigned char *ptr_buf; - //Get TCB and local buffer from common pool. (It is shared by CmdQ, MgntQ, and USB coalesce DataQ) + /* Get TCB and local buffer from common pool. + (It is shared by CmdQ, MgntQ, and USB coalesce DataQ) */ skb = dev_alloc_skb(USB_HWDESC_HEADER_LEN + DataLen + 4); memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev)); tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); @@ -74,16 +76,16 @@ rt_status SendTxCommandPacket(struct net_device *dev, void *pData, u32 DataLen) * Function: cmpk_message_handle_tx() * * Overview: Driver internal module can call the API to send message to - * firmware side. For example, you can send a debug command packet. - * Or you can send a request for FW to modify RLX4181 LBUS HW bank. - * Otherwise, you can change MAC/PHT/RF register by firmware at - * run time. We do not support message more than one segment now. + * firmware side. For example, you can send a debug command packet. + * Or you can send a request for FW to modify RLX4181 LBUS HW bank. + * Otherwise, you can change MAC/PHT/RF register by firmware at + * run time. We do not support message more than one segment now. * - * Input: NONE + * Input: NONE * - * Output: NONE + * Output: NONE * - * Return: NONE + * Return: NONE * * Revised History: * When Who Remark @@ -110,7 +112,7 @@ extern rt_status cmpk_message_handle_tx(struct net_device *dev, u8 bLastIniPkt; firmware_init_param(dev); - //Fragmentation might be required + /* Fragmentation might be required */ frag_threshold = pfirmware->cmdpacket_frag_thresold; do { if ((buffer_len - frag_offset) > frag_threshold) { @@ -123,9 +125,8 @@ extern rt_status cmpk_message_handle_tx(struct net_device *dev, } - /* Allocate skb buffer to contain firmware info and tx descriptor info - * add 4 to avoid packet appending overflow. - * */ + /* Allocate skb buffer to contain firmware info and tx + descriptor info add 4 to avoid packet appending overflow. */ #ifdef RTL8192U skb = dev_alloc_skb(USB_HWDESC_HEADER_LEN + frag_length + 4); #else @@ -168,23 +169,23 @@ extern rt_status cmpk_message_handle_tx(struct net_device *dev, #endif -} /* CMPK_Message_Handle_Tx */ +} /*----------------------------------------------------------------------------- * Function: cmpk_counttxstatistic() * * Overview: * - * Input: PADAPTER pAdapter - . - * CMPK_TXFB_T *psTx_FB - . + * Input: PADAPTER pAdapter + * CMPK_TXFB_T *psTx_FB * * Output: NONE * * Return: NONE * * Revised History: - * When Who Remark - * 05/12/2008 amy Create Version 0 porting from windows code. + * When Who Remark + * 05/12/2008 amy Create Version 0 porting from windows code. * *---------------------------------------------------------------------------*/ static void cmpk_count_txstatistic(struct net_device *dev, cmpk_txfb_t *pstx_fb) @@ -195,9 +196,9 @@ static void cmpk_count_txstatistic(struct net_device *dev, cmpk_txfb_t *pstx_fb) pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, (pu1Byte)(&rtState)); - // When RF is off, we should not count the packet for hw/sw synchronize - // reason, ie. there may be a duration while sw switch is changed and hw - // switch is being changed. 2006.12.04, by shien chang. + /* When RF is off, we should not count the packet for hw/sw synchronize + reason, ie. there may be a duration while sw switch is changed and + hw switch is being changed. */ if (rtState == eRfOff) return; #endif @@ -206,9 +207,9 @@ static void cmpk_count_txstatistic(struct net_device *dev, cmpk_txfb_t *pstx_fb) if (pAdapter->bInHctTest) return; #endif - /* We can not know the packet length and transmit type: broadcast or uni - or multicast. So the relative statistics must be collected in tx - feedback info. */ + /* We can not know the packet length and transmit type: + broadcast or uni or multicast. So the relative statistics + must be collected in tx feedback info. */ if (pstx_fb->tok) { priv->stats.txfeedbackok++; priv->stats.txoktotal++; @@ -243,7 +244,7 @@ static void cmpk_count_txstatistic(struct net_device *dev, cmpk_txfb_t *pstx_fb) priv->stats.txretrycount += pstx_fb->retry_cnt; priv->stats.txfeedbackretry += pstx_fb->retry_cnt; -} /* cmpk_CountTxStatistic */ +} @@ -251,27 +252,27 @@ static void cmpk_count_txstatistic(struct net_device *dev, cmpk_txfb_t *pstx_fb) * Function: cmpk_handle_tx_feedback() * * Overview: The function is responsible for extract the message inside TX - * feedbck message from firmware. It will contain dedicated info in - * ws-06-0063-rtl8190-command-packet-specification. Please - * refer to chapter "TX Feedback Element". We have to read 20 bytes - * in the command packet. + * feedbck message from firmware. It will contain dedicated info in + * ws-06-0063-rtl8190-command-packet-specification. + * Please refer to chapter "TX Feedback Element". + * We have to read 20 bytes in the command packet. * - * Input: struct net_device * dev - * u8 * pmsg - Msg Ptr of the command packet. + * Input: struct net_device *dev + * u8 *pmsg - Msg Ptr of the command packet. * * Output: NONE * * Return: NONE * * Revised History: - * When Who Remark - * 05/08/2008 amy Create Version 0 porting from windows code. + * When Who Remark + * 05/08/2008 amy Create Version 0 porting from windows code. * *---------------------------------------------------------------------------*/ static void cmpk_handle_tx_feedback(struct net_device *dev, u8 *pmsg) { struct r8192_priv *priv = ieee80211_priv(dev); - cmpk_txfb_t rx_tx_fb; /* */ + cmpk_txfb_t rx_tx_fb; priv->stats.txfeedback++; @@ -279,24 +280,22 @@ static void cmpk_handle_tx_feedback(struct net_device *dev, u8 *pmsg) /* It seems that FW use big endian(MIPS) and DRV use little endian in windows OS. So we have to read the content byte by byte or transfer endian type before copy the message copy. */ - /* 2007/07/05 MH Use pointer to transfer structure memory. */ + /* Use pointer to transfer structure memory. */ memcpy((u8 *)&rx_tx_fb, pmsg, sizeof(cmpk_txfb_t)); /* 2. Use tx feedback info to count TX statistics. */ cmpk_count_txstatistic(dev, &rx_tx_fb); - /* 2007/01/17 MH Comment previous method for TX statistic function. */ + /* Comment previous method for TX statistic function. */ /* Collect info TX feedback packet to fill TCB. */ /* We can not know the packet length and transmit type: broadcast or uni or multicast. */ -} /* cmpk_Handle_Tx_Feedback */ +} void cmdpkt_beacontimerinterrupt_819xusb(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv(dev); u16 tx_rate; - // - // 070117, rcnjko: 87B have to S/W beacon for DTM encryption_cmn. - // + /* 87B have to S/W beacon for DTM encryption_cmn. */ if (priv->ieee80211->current_network.mode == IEEE_A || priv->ieee80211->current_network.mode == IEEE_N_5G || (priv->ieee80211->current_network.mode == IEEE_N_24G && (!priv->ieee80211->pHTInfo->bCurSuppCCK))) { @@ -307,7 +306,7 @@ void cmdpkt_beacontimerinterrupt_819xusb(struct net_device *dev) DMESG("send beacon frame tx rate is 1Mbpm\n"); } - rtl819xusb_beacon_tx(dev, tx_rate); // HW Beacon + rtl819xusb_beacon_tx(dev, tx_rate); /* HW Beacon */ } @@ -319,20 +318,20 @@ void cmdpkt_beacontimerinterrupt_819xusb(struct net_device *dev) * Function: cmpk_handle_interrupt_status() * * Overview: The function is responsible for extract the message from - * firmware. It will contain dedicated info in - * ws-07-0063-v06-rtl819x-command-packet-specification-070315.doc. - * Please refer to chapter "Interrupt Status Element". + * firmware. It will contain dedicated info in + * ws-07-0063-v06-rtl819x-command-packet-specification-070315.doc. + * Please refer to chapter "Interrupt Status Element". * - * Input: struct net_device *dev, - * u8* pmsg - Message Pointer of the command packet. + * Input: struct net_device *dev + * u8 *pmsg - Message Pointer of the command packet. * * Output: NONE * * Return: NONE * * Revised History: - * When Who Remark - * 05/12/2008 amy Add this for rtl8192 porting from windows code. + * When Who Remark + * 05/12/2008 amy Add this for rtl8192 porting from windows code. * *---------------------------------------------------------------------------*/ static void cmpk_handle_interrupt_status(struct net_device *dev, u8 *pmsg) @@ -353,9 +352,9 @@ static void cmpk_handle_interrupt_status(struct net_device *dev, u8 *pmsg) } - // Statistics of beacon for ad-hoc mode. + /* Statistics of beacon for ad-hoc mode. */ if (priv->ieee80211->iw_mode == IW_MODE_ADHOC) { - //2 maybe need endian transform? + /* 2 maybe need endian transform? */ rx_intr_status.interrupt_status = *((u32 *)(pmsg + 4)); DMESG("interrupt status = 0x%x\n", rx_intr_status.interrupt_status); @@ -373,36 +372,36 @@ static void cmpk_handle_interrupt_status(struct net_device *dev, u8 *pmsg) } - // Other informations in interrupt status we need? + /* Other informations in interrupt status we need? */ DMESG("<---- cmpk_handle_interrupt_status()\n"); -} /* cmpk_handle_interrupt_status */ +} /*----------------------------------------------------------------------------- * Function: cmpk_handle_query_config_rx() * * Overview: The function is responsible for extract the message from - * firmware. It will contain dedicated info in - * ws-06-0063-rtl8190-command-packet-specification. Please - * refer to chapter "Beacon State Element". + * firmware. It will contain dedicated info in + * ws-06-0063-rtl8190-command-packet-specification. Please + * refer to chapter "Beacon State Element". * - * Input: u8 * pmsg - Message Pointer of the command packet. + * Input: u8 *pmsg - Message Pointer of the command packet. * * Output: NONE * * Return: NONE * * Revised History: - * When Who Remark - * 05/12/2008 amy Create Version 0 porting from windows code. + * When Who Remark + * 05/12/2008 amy Create Version 0 porting from windows code. * *---------------------------------------------------------------------------*/ static void cmpk_handle_query_config_rx(struct net_device *dev, u8 *pmsg) { - cmpk_query_cfg_t rx_query_cfg; /* */ + cmpk_query_cfg_t rx_query_cfg; /* 1. Extract TX feedback info from RFD to temp structure buffer. */ @@ -419,24 +418,24 @@ static void cmpk_handle_query_config_rx(struct net_device *dev, u8 *pmsg) rx_query_cfg.mask = (pmsg[12] << 24) | (pmsg[13] << 16) | (pmsg[14] << 8) | (pmsg[15] << 0); -} /* cmpk_Handle_Query_Config_Rx */ +} /*----------------------------------------------------------------------------- * Function: cmpk_count_tx_status() * * Overview: Count aggregated tx status from firmwar of one type rx command - * packet element id = RX_TX_STATUS. + * packet element id = RX_TX_STATUS. * - * Input: NONE + * Input: NONE * - * Output: NONE + * Output: NONE * - * Return: NONE + * Return: NONE * * Revised History: - * When Who Remark - * 05/12/2008 amy Create Version 0 porting from windows code. + * When Who Remark + * 05/12/2008 amy Create Version 0 porting from windows code. * *---------------------------------------------------------------------------*/ static void cmpk_count_tx_status(struct net_device *dev, @@ -450,9 +449,9 @@ static void cmpk_count_tx_status(struct net_device *dev, pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, (pu1Byte)(&rtState)); - // When RF is off, we should not count the packet for hw/sw synchronize - // reason, ie. there may be a duration while sw switch is changed and hw - // switch is being changed. 2006.12.04, by shien chang. + /* When RF is off, we should not count the packet for hw/sw synchronize + reason, ie. there may be a duration while sw switch is changed and + hw switch is being changed. */ if (rtState == eRfOff) return; #endif @@ -480,7 +479,7 @@ static void cmpk_count_tx_status(struct net_device *dev, priv->stats.txbytesunicast += pstx_status->txuclength; priv->stats.last_packet_rate = pstx_status->rate; -} /* cmpk_CountTxStatus */ +} @@ -488,7 +487,7 @@ static void cmpk_count_tx_status(struct net_device *dev, * Function: cmpk_handle_tx_status() * * Overview: Firmware add a new tx feedback status to reduce rx command - * packet buffer operation load. + * packet buffer operation load. * * Input: NONE * @@ -497,19 +496,19 @@ static void cmpk_count_tx_status(struct net_device *dev, * Return: NONE * * Revised History: - * When Who Remark - * 05/12/2008 amy Create Version 0 porting from windows code. + * When Who Remark + * 05/12/2008 amy Create Version 0 porting from windows code. * *---------------------------------------------------------------------------*/ static void cmpk_handle_tx_status(struct net_device *dev, u8 *pmsg) { - cmpk_tx_status_t rx_tx_sts; /* */ + cmpk_tx_status_t rx_tx_sts; memcpy((void *)&rx_tx_sts, (void *)pmsg, sizeof(cmpk_tx_status_t)); /* 2. Use tx feedback info to count TX statistics. */ cmpk_count_tx_status(dev, &rx_tx_sts); -} /* cmpk_Handle_Tx_Status */ +} /*----------------------------------------------------------------------------- @@ -524,8 +523,8 @@ static void cmpk_handle_tx_status(struct net_device *dev, u8 *pmsg) * Return: NONE * * Revised History: - * When Who Remark - * 05/12/2008 amy Create Version 0 porting from windows code. + * When Who Remark + * 05/12/2008 amy Create Version 0 porting from windows code. * *---------------------------------------------------------------------------*/ static void cmpk_handle_tx_rate_history(struct net_device *dev, u8 *pmsg) @@ -540,19 +539,17 @@ static void cmpk_handle_tx_rate_history(struct net_device *dev, u8 *pmsg) #ifdef ENABLE_PS pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, (pu1Byte)(&rtState)); - // When RF is off, we should not count the packet for hw/sw synchronize - // reason, ie. there may be a duration while sw switch is changed and hw - // switch is being changed. 2006.12.04, by shien chang. + /* When RF is off, we should not count the packet for hw/sw synchronize + reason, ie. there may be a duration while sw switch is changed and + hw switch is being changed. */ if (rtState == eRfOff) return; #endif ptemp = (u32 *)pmsg; - // - // Do endian transfer to word alignment(16 bits) for windows system. - // You must do different endian transfer for linux and MAC OS - // + /* Do endian transfer to word alignment(16 bits) for windows system. + You must do different endian transfer for linux and MAC OS */ for (i = 0; i < (length/4); i++) { u16 temp1, temp2; @@ -567,11 +564,11 @@ static void cmpk_handle_tx_rate_history(struct net_device *dev, u8 *pmsg) return; for (i = 0; i < 16; i++) { - // Collect CCK rate packet num + /* Collect CCK rate packet num */ if (i < 4) priv->stats.txrate.cck[i] += ptxrate->cck[i]; - // Collect OFDM rate packet num + /* Collect OFDM rate packet num */ if (i < 8) priv->stats.txrate.ofdm[i] += ptxrate->ofdm[i]; @@ -579,17 +576,17 @@ static void cmpk_handle_tx_rate_history(struct net_device *dev, u8 *pmsg) priv->stats.txrate.ht_mcs[j][i] += ptxrate->ht_mcs[j][i]; } -} /* cmpk_Handle_Tx_Rate_History */ +} /*----------------------------------------------------------------------------- * Function: cmpk_message_handle_rx() * * Overview: In the function, we will capture different RX command packet - * info. Every RX command packet element has different message - * length and meaning in content. We only support three type of RX - * command packet now. Please refer to document - * ws-06-0063-rtl8190-command-packet-specification. + * info. Every RX command packet element has different message + * length and meaning in content. We only support three type of RX + * command packet now. Please refer to document + * ws-06-0063-rtl8190-command-packet-specification. * * Input: NONE * @@ -598,8 +595,8 @@ static void cmpk_handle_tx_rate_history(struct net_device *dev, u8 *pmsg) * Return: NONE * * Revised History: - * When Who Remark - * 05/06/2008 amy Create Version 0 porting from windows code. + * When Who Remark + * 05/06/2008 amy Create Version 0 porting from windows code. * *---------------------------------------------------------------------------*/ extern u32 cmpk_message_handle_rx(struct net_device *dev, @@ -610,8 +607,8 @@ extern u32 cmpk_message_handle_rx(struct net_device *dev, u8 element_id; u8 *pcmd_buff; - /* 0. Check inpt arguments. If is is a command queue message or pointer is - null. */ + /* 0. Check inpt arguments. If is is a command queue message or + pointer is null. */ if (pstats == NULL) return 0; /* This is not a command packet. */ @@ -625,11 +622,12 @@ extern u32 cmpk_message_handle_rx(struct net_device *dev, element_id = pcmd_buff[0]; /* 4. Check every received command packet content according to different - element type. Because FW may aggregate RX command packet to minimize - transmit time between DRV and FW.*/ - // Add a counter to prevent the lock in the loop from being held too long + element type. Because FW may aggregate RX command packet to + minimize transmit time between DRV and FW.*/ + /* Add a counter to prevent the lock in the loop from being held too + long */ while (total_length > 0 && exe_cnt++ < 100) { - /* 2007/01/17 MH We support aggregation of different cmd in the same packet. */ + /* We support aggregation of different cmd in the same packet */ element_id = pcmd_buff[0]; switch (element_id) { @@ -654,8 +652,8 @@ extern u32 cmpk_message_handle_rx(struct net_device *dev, break; case RX_TX_PER_PKT_FEEDBACK: - // You must at lease add a switch case element here, - // Otherwise, we will jump to default case. + /* You must at lease add a switch case element here, + Otherwise, we will jump to default case. */ cmd_length = CMPK_RX_TX_FB_SIZE; break; @@ -675,4 +673,4 @@ extern u32 cmpk_message_handle_rx(struct net_device *dev, } return 1; /* This is a command packet. */ -} /* CMPK_Message_Handle_Rx */ +} -- GitLab From bdcd57fa210646738c7fd6ecc927fc87065b5bbd Mon Sep 17 00:00:00 2001 From: Xenia Ragiadakou Date: Wed, 26 Jun 2013 04:21:44 +0300 Subject: [PATCH 105/942] staging: rtl8192u: remove unnecessary line continuations in r819xU_cmdpkt.c This patch fixes the following checkpatch warning: WARNING: Avoid unnecessary line continuations Signed-off-by: Xenia Ragiadakou Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_cmdpkt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_cmdpkt.c b/drivers/staging/rtl8192u/r819xU_cmdpkt.c index b6a6e44200a7e..469b12bf2d973 100644 --- a/drivers/staging/rtl8192u/r819xU_cmdpkt.c +++ b/drivers/staging/rtl8192u/r819xU_cmdpkt.c @@ -61,7 +61,7 @@ rt_status SendTxCommandPacket(struct net_device *dev, void *pData, u32 DataLen) tcb_desc->txbuf_size = (u16)DataLen; if (!priv->ieee80211->check_nic_enough_desc(dev, tcb_desc->queue_index) || - (!skb_queue_empty(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index])) ||\ + (!skb_queue_empty(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index])) || (priv->ieee80211->queue_stop)) { RT_TRACE(COMP_FIRMWARE, "===================NULL packet==================================> tx full!\n"); skb_queue_tail(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index], skb); @@ -152,7 +152,7 @@ extern rt_status cmpk_message_handle_tx(struct net_device *dev, if (!priv->ieee80211->check_nic_enough_desc(dev, tcb_desc->queue_index) || - (!skb_queue_empty(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index])) ||\ + (!skb_queue_empty(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index])) || (priv->ieee80211->queue_stop)) { RT_TRACE(COMP_FIRMWARE, "=====================================================> tx full!\n"); skb_queue_tail(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index], skb); -- GitLab From f70edb9f1c62e4367068f263bfb596767675477b Mon Sep 17 00:00:00 2001 From: Xenia Ragiadakou Date: Wed, 26 Jun 2013 04:21:45 +0300 Subject: [PATCH 106/942] staging: rtl8192u: fix line size and identation in r819xU_cmdpkt.c This patch limits the line size below 80 characters, when possible, and fixes identation to meet kernel coding style convetions. Signed-off-by: Xenia Ragiadakou Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_cmdpkt.c | 116 ++++++++++++----------- 1 file changed, 61 insertions(+), 55 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_cmdpkt.c b/drivers/staging/rtl8192u/r819xU_cmdpkt.c index 469b12bf2d973..8c56598b5eac1 100644 --- a/drivers/staging/rtl8192u/r819xU_cmdpkt.c +++ b/drivers/staging/rtl8192u/r819xU_cmdpkt.c @@ -61,13 +61,13 @@ rt_status SendTxCommandPacket(struct net_device *dev, void *pData, u32 DataLen) tcb_desc->txbuf_size = (u16)DataLen; if (!priv->ieee80211->check_nic_enough_desc(dev, tcb_desc->queue_index) || - (!skb_queue_empty(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index])) || - (priv->ieee80211->queue_stop)) { - RT_TRACE(COMP_FIRMWARE, "===================NULL packet==================================> tx full!\n"); - skb_queue_tail(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index], skb); - } else { - priv->ieee80211->softmac_hard_start_xmit(skb, dev); - } + (!skb_queue_empty(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index])) || + (priv->ieee80211->queue_stop)) { + RT_TRACE(COMP_FIRMWARE, "=== NULL packet ======> tx full!\n"); + skb_queue_tail(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index], skb); + } else { + priv->ieee80211->softmac_hard_start_xmit(skb, dev); + } return rtStatus; } @@ -127,20 +127,20 @@ extern rt_status cmpk_message_handle_tx(struct net_device *dev, /* Allocate skb buffer to contain firmware info and tx descriptor info add 4 to avoid packet appending overflow. */ - #ifdef RTL8192U +#ifdef RTL8192U skb = dev_alloc_skb(USB_HWDESC_HEADER_LEN + frag_length + 4); - #else +#else skb = dev_alloc_skb(frag_length + 4); - #endif +#endif memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev)); tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); tcb_desc->queue_index = TXCMD_QUEUE; tcb_desc->bCmdOrInit = packettype; tcb_desc->bLastIniPkt = bLastIniPkt; - #ifdef RTL8192U +#ifdef RTL8192U skb_reserve(skb, USB_HWDESC_HEADER_LEN); - #endif +#endif seg_ptr = skb_put(skb, buffer_len); /* @@ -152,9 +152,9 @@ extern rt_status cmpk_message_handle_tx(struct net_device *dev, if (!priv->ieee80211->check_nic_enough_desc(dev, tcb_desc->queue_index) || - (!skb_queue_empty(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index])) || - (priv->ieee80211->queue_stop)) { - RT_TRACE(COMP_FIRMWARE, "=====================================================> tx full!\n"); + (!skb_queue_empty(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index])) || + (priv->ieee80211->queue_stop)) { + RT_TRACE(COMP_FIRMWARE, "======> tx full!\n"); skb_queue_tail(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index], skb); } else { priv->ieee80211->softmac_hard_start_xmit(skb, dev); @@ -194,7 +194,8 @@ static void cmpk_count_txstatistic(struct net_device *dev, cmpk_txfb_t *pstx_fb) #ifdef ENABLE_PS RT_RF_POWER_STATE rtState; - pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, (pu1Byte)(&rtState)); + pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, + (pu1Byte)(&rtState)); /* When RF is off, we should not count the packet for hw/sw synchronize reason, ie. there may be a duration while sw switch is changed and @@ -298,7 +299,8 @@ void cmdpkt_beacontimerinterrupt_819xusb(struct net_device *dev) /* 87B have to S/W beacon for DTM encryption_cmn. */ if (priv->ieee80211->current_network.mode == IEEE_A || priv->ieee80211->current_network.mode == IEEE_N_5G || - (priv->ieee80211->current_network.mode == IEEE_N_24G && (!priv->ieee80211->pHTInfo->bCurSuppCCK))) { + (priv->ieee80211->current_network.mode == IEEE_N_24G && + (!priv->ieee80211->pHTInfo->bCurSuppCCK))) { tx_rate = 60; DMESG("send beacon frame tx rate is 6Mbpm\n"); } else { @@ -357,7 +359,8 @@ static void cmpk_handle_interrupt_status(struct net_device *dev, u8 *pmsg) /* 2 maybe need endian transform? */ rx_intr_status.interrupt_status = *((u32 *)(pmsg + 4)); - DMESG("interrupt status = 0x%x\n", rx_intr_status.interrupt_status); + DMESG("interrupt status = 0x%x\n", + rx_intr_status.interrupt_status); if (rx_intr_status.interrupt_status & ISR_TxBcnOk) { priv->ieee80211->bibsscoordinator = true; @@ -447,7 +450,8 @@ static void cmpk_count_tx_status(struct net_device *dev, RT_RF_POWER_STATE rtstate; - pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, (pu1Byte)(&rtState)); + pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, + (pu1Byte)(&rtState)); /* When RF is off, we should not count the packet for hw/sw synchronize reason, ie. there may be a duration while sw switch is changed and @@ -537,7 +541,8 @@ static void cmpk_handle_tx_rate_history(struct net_device *dev, u8 *pmsg) #ifdef ENABLE_PS - pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, (pu1Byte)(&rtState)); + pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, + (pu1Byte)(&rtState)); /* When RF is off, we should not count the packet for hw/sw synchronize reason, ie. there may be a duration while sw switch is changed and @@ -631,41 +636,42 @@ extern u32 cmpk_message_handle_rx(struct net_device *dev, element_id = pcmd_buff[0]; switch (element_id) { - case RX_TX_FEEDBACK: - cmpk_handle_tx_feedback(dev, pcmd_buff); - cmd_length = CMPK_RX_TX_FB_SIZE; - break; - - case RX_INTERRUPT_STATUS: - cmpk_handle_interrupt_status(dev, pcmd_buff); - cmd_length = sizeof(cmpk_intr_sta_t); - break; - - case BOTH_QUERY_CONFIG: - cmpk_handle_query_config_rx(dev, pcmd_buff); - cmd_length = CMPK_BOTH_QUERY_CONFIG_SIZE; - break; - - case RX_TX_STATUS: - cmpk_handle_tx_status(dev, pcmd_buff); - cmd_length = CMPK_RX_TX_STS_SIZE; - break; - - case RX_TX_PER_PKT_FEEDBACK: - /* You must at lease add a switch case element here, - Otherwise, we will jump to default case. */ - cmd_length = CMPK_RX_TX_FB_SIZE; - break; - - case RX_TX_RATE_HISTORY: - cmpk_handle_tx_rate_history(dev, pcmd_buff); - cmd_length = CMPK_TX_RAHIS_SIZE; - break; - - default: - - RT_TRACE(COMP_ERR, "---->cmpk_message_handle_rx():unknow CMD Element\n"); - return 1; /* This is a command packet. */ + case RX_TX_FEEDBACK: + cmpk_handle_tx_feedback(dev, pcmd_buff); + cmd_length = CMPK_RX_TX_FB_SIZE; + break; + + case RX_INTERRUPT_STATUS: + cmpk_handle_interrupt_status(dev, pcmd_buff); + cmd_length = sizeof(cmpk_intr_sta_t); + break; + + case BOTH_QUERY_CONFIG: + cmpk_handle_query_config_rx(dev, pcmd_buff); + cmd_length = CMPK_BOTH_QUERY_CONFIG_SIZE; + break; + + case RX_TX_STATUS: + cmpk_handle_tx_status(dev, pcmd_buff); + cmd_length = CMPK_RX_TX_STS_SIZE; + break; + + case RX_TX_PER_PKT_FEEDBACK: + /* You must at lease add a switch case element here, + Otherwise, we will jump to default case. */ + cmd_length = CMPK_RX_TX_FB_SIZE; + break; + + case RX_TX_RATE_HISTORY: + cmpk_handle_tx_rate_history(dev, pcmd_buff); + cmd_length = CMPK_TX_RAHIS_SIZE; + break; + + default: + + RT_TRACE(COMP_ERR, "---->%s():unknown CMD Element\n", + __func__); + return 1; /* This is a command packet. */ } total_length -= cmd_length; -- GitLab From bdc7cb1994d5df7f14e42cd61b332e8eb12cac3e Mon Sep 17 00:00:00 2001 From: Xenia Ragiadakou Date: Wed, 26 Jun 2013 04:21:46 +0300 Subject: [PATCH 107/942] staging: rtl8192u: remove unused macros r819xU_cmdpkt.c This patch removes CMPK_DEBOUNCE_CNT and CMPK_PRINT() because they are not used anywhere in the driver. Signed-off-by: Xenia Ragiadakou Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_cmdpkt.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_cmdpkt.c b/drivers/staging/rtl8192u/r819xU_cmdpkt.c index 8c56598b5eac1..5bc361b16d4ca 100644 --- a/drivers/staging/rtl8192u/r819xU_cmdpkt.c +++ b/drivers/staging/rtl8192u/r819xU_cmdpkt.c @@ -26,19 +26,6 @@ #include "r8192U.h" #include "r819xU_cmdpkt.h" -/* Debug constant */ -#define CMPK_DEBOUNCE_CNT 1 -/* Add for printing a range of data. */ -#define CMPK_PRINT(Address)\ -{\ - unsigned char i;\ - u32 temp[10];\ - \ - memcpy(temp, Address, 40);\ - for (i = 0; i < 40; i += 4)\ - printk("\r\n %08x", temp[i]);\ -}\ - rt_status SendTxCommandPacket(struct net_device *dev, void *pData, u32 DataLen) { rt_status rtStatus = RT_STATUS_SUCCESS; -- GitLab From 977da7f0a5012b994f03af7be983f458edcd0644 Mon Sep 17 00:00:00 2001 From: Lilis Iskandar Date: Tue, 23 Jul 2013 19:51:02 +0800 Subject: [PATCH 108/942] Staging: bcm: Qos: Fix some coding style issues Fixed spacing/tabs issues that were found using checkpatch. Signed-off-by: Lilis Iskandar Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Qos.c | 538 +++++++++++++++++++------------------- 1 file changed, 269 insertions(+), 269 deletions(-) diff --git a/drivers/staging/bcm/Qos.c b/drivers/staging/bcm/Qos.c index 8d142a547e7fd..2d4a77cca9150 100644 --- a/drivers/staging/bcm/Qos.c +++ b/drivers/staging/bcm/Qos.c @@ -4,11 +4,11 @@ This file contains the routines related to Quality of Service. */ #include "headers.h" -static void EThCSGetPktInfo(struct bcm_mini_adapter *Adapter,PVOID pvEthPayload, struct bcm_eth_packet_info *pstEthCsPktInfo); -static BOOLEAN EThCSClassifyPkt(struct bcm_mini_adapter *Adapter,struct sk_buff* skb, struct bcm_eth_packet_info *pstEthCsPktInfo,struct bcm_classifier_rule *pstClassifierRule, B_UINT8 EthCSCupport); +static void EThCSGetPktInfo(struct bcm_mini_adapter *Adapter, PVOID pvEthPayload, struct bcm_eth_packet_info *pstEthCsPktInfo); +static BOOLEAN EThCSClassifyPkt(struct bcm_mini_adapter *Adapter, struct sk_buff* skb, struct bcm_eth_packet_info *pstEthCsPktInfo, struct bcm_classifier_rule *pstClassifierRule, B_UINT8 EthCSCupport); static USHORT IpVersion4(struct bcm_mini_adapter *Adapter, struct iphdr *iphd, - struct bcm_classifier_rule *pstClassifierRule ); + struct bcm_classifier_rule *pstClassifierRule); static VOID PruneQueue(struct bcm_mini_adapter *Adapter, INT iIndex); @@ -20,30 +20,30 @@ static VOID PruneQueue(struct bcm_mini_adapter *Adapter, INT iIndex); * matches with that of Queue. * * Parameters - pstClassifierRule: Pointer to the packet info structure. -* - ulSrcIP : Source IP address from the packet. +* - ulSrcIP : Source IP address from the packet. * * Returns - TRUE(If address matches) else FAIL . *********************************************************************/ -BOOLEAN MatchSrcIpAddress(struct bcm_classifier_rule *pstClassifierRule,ULONG ulSrcIP) +BOOLEAN MatchSrcIpAddress(struct bcm_classifier_rule *pstClassifierRule, ULONG ulSrcIP) { - UCHAR ucLoopIndex=0; - - struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - - ulSrcIP=ntohl(ulSrcIP); - if(0 == pstClassifierRule->ucIPSourceAddressLength) - return TRUE; - for(ucLoopIndex=0; ucLoopIndex < (pstClassifierRule->ucIPSourceAddressLength);ucLoopIndex++) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Src Ip Address Mask:0x%x PacketIp:0x%x and Classification:0x%x", (UINT)pstClassifierRule->stSrcIpAddress.ulIpv4Mask[ucLoopIndex], (UINT)ulSrcIP, (UINT)pstClassifierRule->stSrcIpAddress.ulIpv6Addr[ucLoopIndex]); - if((pstClassifierRule->stSrcIpAddress.ulIpv4Mask[ucLoopIndex] & ulSrcIP)== - (pstClassifierRule->stSrcIpAddress.ulIpv4Addr[ucLoopIndex] & pstClassifierRule->stSrcIpAddress.ulIpv4Mask[ucLoopIndex] )) - { - return TRUE; - } - } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Src Ip Address Not Matched"); - return FALSE; + UCHAR ucLoopIndex = 0; + + struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); + + ulSrcIP = ntohl(ulSrcIP); + if (0 == pstClassifierRule->ucIPSourceAddressLength) + return TRUE; + for (ucLoopIndex = 0; ucLoopIndex < (pstClassifierRule->ucIPSourceAddressLength); ucLoopIndex++) + { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Src Ip Address Mask:0x%x PacketIp:0x%x and Classification:0x%x", (UINT)pstClassifierRule->stSrcIpAddress.ulIpv4Mask[ucLoopIndex], (UINT)ulSrcIP, (UINT)pstClassifierRule->stSrcIpAddress.ulIpv6Addr[ucLoopIndex]); + if ((pstClassifierRule->stSrcIpAddress.ulIpv4Mask[ucLoopIndex] & ulSrcIP) == + (pstClassifierRule->stSrcIpAddress.ulIpv4Addr[ucLoopIndex] & pstClassifierRule->stSrcIpAddress.ulIpv4Mask[ucLoopIndex])) + { + return TRUE; + } + } + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Src Ip Address Not Matched"); + return FALSE; } @@ -54,30 +54,30 @@ BOOLEAN MatchSrcIpAddress(struct bcm_classifier_rule *pstClassifierRule,ULONG ul * matches with that of Queue. * * Parameters - pstClassifierRule: Pointer to the packet info structure. -* - ulDestIP : Destination IP address from the packet. +* - ulDestIP : Destination IP address from the packet. * * Returns - TRUE(If address matches) else FAIL . *********************************************************************/ -BOOLEAN MatchDestIpAddress(struct bcm_classifier_rule *pstClassifierRule,ULONG ulDestIP) +BOOLEAN MatchDestIpAddress(struct bcm_classifier_rule *pstClassifierRule, ULONG ulDestIP) { - UCHAR ucLoopIndex=0; + UCHAR ucLoopIndex = 0; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - ulDestIP=ntohl(ulDestIP); - if(0 == pstClassifierRule->ucIPDestinationAddressLength) - return TRUE; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Destination Ip Address 0x%x 0x%x 0x%x ", (UINT)ulDestIP, (UINT)pstClassifierRule->stDestIpAddress.ulIpv4Mask[ucLoopIndex], (UINT)pstClassifierRule->stDestIpAddress.ulIpv4Addr[ucLoopIndex]); - - for(ucLoopIndex=0;ucLoopIndex<(pstClassifierRule->ucIPDestinationAddressLength);ucLoopIndex++) - { - if((pstClassifierRule->stDestIpAddress.ulIpv4Mask[ucLoopIndex] & ulDestIP)== - (pstClassifierRule->stDestIpAddress.ulIpv4Addr[ucLoopIndex] & pstClassifierRule->stDestIpAddress.ulIpv4Mask[ucLoopIndex])) - { - return TRUE; - } - } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Destination Ip Address Not Matched"); - return FALSE; + ulDestIP = ntohl(ulDestIP); + if (0 == pstClassifierRule->ucIPDestinationAddressLength) + return TRUE; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Destination Ip Address 0x%x 0x%x 0x%x ", (UINT)ulDestIP, (UINT)pstClassifierRule->stDestIpAddress.ulIpv4Mask[ucLoopIndex], (UINT)pstClassifierRule->stDestIpAddress.ulIpv4Addr[ucLoopIndex]); + + for (ucLoopIndex = 0; ucLoopIndex < (pstClassifierRule->ucIPDestinationAddressLength); ucLoopIndex++) + { + if ((pstClassifierRule->stDestIpAddress.ulIpv4Mask[ucLoopIndex] & ulDestIP) == + (pstClassifierRule->stDestIpAddress.ulIpv4Addr[ucLoopIndex] & pstClassifierRule->stDestIpAddress.ulIpv4Mask[ucLoopIndex])) + { + return TRUE; + } + } + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Destination Ip Address Not Matched"); + return FALSE; } @@ -87,23 +87,23 @@ BOOLEAN MatchDestIpAddress(struct bcm_classifier_rule *pstClassifierRule,ULONG u * Description - Checks the TOS from the packet matches with that of queue. * * Parameters - pstClassifierRule : Pointer to the packet info structure. -* - ucTypeOfService: TOS from the packet. +* - ucTypeOfService: TOS from the packet. * * Returns - TRUE(If address matches) else FAIL. **************************************************************************/ -BOOLEAN MatchTos(struct bcm_classifier_rule *pstClassifierRule,UCHAR ucTypeOfService) +BOOLEAN MatchTos(struct bcm_classifier_rule *pstClassifierRule, UCHAR ucTypeOfService) { struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - if( 3 != pstClassifierRule->ucIPTypeOfServiceLength ) - return TRUE; - - if(((pstClassifierRule->ucTosMask & ucTypeOfService)<=pstClassifierRule->ucTosHigh) && ((pstClassifierRule->ucTosMask & ucTypeOfService)>=pstClassifierRule->ucTosLow)) - { - return TRUE; - } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Type Of Service Not Matched"); - return FALSE; + if (3 != pstClassifierRule->ucIPTypeOfServiceLength) + return TRUE; + + if (((pstClassifierRule->ucTosMask & ucTypeOfService) <= pstClassifierRule->ucTosHigh) && ((pstClassifierRule->ucTosMask & ucTypeOfService) >= pstClassifierRule->ucTosLow)) + { + return TRUE; + } + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Type Of Service Not Matched"); + return FALSE; } @@ -113,26 +113,26 @@ BOOLEAN MatchTos(struct bcm_classifier_rule *pstClassifierRule,UCHAR ucTypeOfSer * Description - Checks the protocol from the packet matches with that of queue. * * Parameters - pstClassifierRule: Pointer to the packet info structure. -* - ucProtocol : Protocol from the packet. +* - ucProtocol : Protocol from the packet. * * Returns - TRUE(If address matches) else FAIL. ****************************************************************************/ -bool MatchProtocol(struct bcm_classifier_rule *pstClassifierRule,UCHAR ucProtocol) +bool MatchProtocol(struct bcm_classifier_rule *pstClassifierRule, UCHAR ucProtocol) { - UCHAR ucLoopIndex=0; + UCHAR ucLoopIndex = 0; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - if(0 == pstClassifierRule->ucProtocolLength) - return TRUE; - for(ucLoopIndex=0;ucLoopIndexucProtocolLength;ucLoopIndex++) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Protocol:0x%X Classification Protocol:0x%X",ucProtocol,pstClassifierRule->ucProtocol[ucLoopIndex]); - if(pstClassifierRule->ucProtocol[ucLoopIndex]==ucProtocol) - { - return TRUE; - } - } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Protocol Not Matched"); - return FALSE; + if (0 == pstClassifierRule->ucProtocolLength) + return TRUE; + for (ucLoopIndex = 0; ucLoopIndex < pstClassifierRule->ucProtocolLength; ucLoopIndex++) + { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Protocol:0x%X Classification Protocol:0x%X", ucProtocol, pstClassifierRule->ucProtocol[ucLoopIndex]); + if (pstClassifierRule->ucProtocol[ucLoopIndex] == ucProtocol) + { + return TRUE; + } + } + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Protocol Not Matched"); + return FALSE; } @@ -142,29 +142,29 @@ bool MatchProtocol(struct bcm_classifier_rule *pstClassifierRule,UCHAR ucProtoco * Description - Checks, Source port from the packet matches with that of queue. * * Parameters - pstClassifierRule: Pointer to the packet info structure. -* - ushSrcPort : Source port from the packet. +* - ushSrcPort : Source port from the packet. * * Returns - TRUE(If address matches) else FAIL. ***************************************************************************/ -bool MatchSrcPort(struct bcm_classifier_rule *pstClassifierRule,USHORT ushSrcPort) +bool MatchSrcPort(struct bcm_classifier_rule *pstClassifierRule, USHORT ushSrcPort) { - UCHAR ucLoopIndex=0; + UCHAR ucLoopIndex = 0; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - if(0 == pstClassifierRule->ucSrcPortRangeLength) - return TRUE; - for(ucLoopIndex=0;ucLoopIndexucSrcPortRangeLength;ucLoopIndex++) - { - if(ushSrcPort <= pstClassifierRule->usSrcPortRangeHi[ucLoopIndex] && - ushSrcPort >= pstClassifierRule->usSrcPortRangeLo[ucLoopIndex]) - { - return TRUE; - } - } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Src Port: %x Not Matched ",ushSrcPort); - return FALSE; + if (0 == pstClassifierRule->ucSrcPortRangeLength) + return TRUE; + for (ucLoopIndex = 0; ucLoopIndex < pstClassifierRule->ucSrcPortRangeLength; ucLoopIndex++) + { + if (ushSrcPort <= pstClassifierRule->usSrcPortRangeHi[ucLoopIndex] && + ushSrcPort >= pstClassifierRule->usSrcPortRangeLo[ucLoopIndex]) + { + return TRUE; + } + } + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Src Port: %x Not Matched ", ushSrcPort); + return FALSE; } @@ -174,30 +174,30 @@ bool MatchSrcPort(struct bcm_classifier_rule *pstClassifierRule,USHORT ushSrcPor * Description - Checks, Destination port from packet matches with that of queue. * * Parameters - pstClassifierRule: Pointer to the packet info structure. -* - ushDestPort : Destination port from the packet. +* - ushDestPort : Destination port from the packet. * * Returns - TRUE(If address matches) else FAIL. ***************************************************************************/ -bool MatchDestPort(struct bcm_classifier_rule *pstClassifierRule,USHORT ushDestPort) +bool MatchDestPort(struct bcm_classifier_rule *pstClassifierRule, USHORT ushDestPort) { - UCHAR ucLoopIndex=0; + UCHAR ucLoopIndex = 0; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - if(0 == pstClassifierRule->ucDestPortRangeLength) - return TRUE; - - for(ucLoopIndex=0;ucLoopIndexucDestPortRangeLength;ucLoopIndex++) - { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Matching Port:0x%X 0x%X 0x%X",ushDestPort,pstClassifierRule->usDestPortRangeLo[ucLoopIndex],pstClassifierRule->usDestPortRangeHi[ucLoopIndex]); - - if(ushDestPort <= pstClassifierRule->usDestPortRangeHi[ucLoopIndex] && - ushDestPort >= pstClassifierRule->usDestPortRangeLo[ucLoopIndex]) - { - return TRUE; - } - } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Dest Port: %x Not Matched",ushDestPort); - return FALSE; + if (0 == pstClassifierRule->ucDestPortRangeLength) + return TRUE; + + for (ucLoopIndex = 0; ucLoopIndex < pstClassifierRule->ucDestPortRangeLength; ucLoopIndex++) + { + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Matching Port:0x%X 0x%X 0x%X", ushDestPort, pstClassifierRule->usDestPortRangeLo[ucLoopIndex], pstClassifierRule->usDestPortRangeHi[ucLoopIndex]); + + if (ushDestPort <= pstClassifierRule->usDestPortRangeHi[ucLoopIndex] && + ushDestPort >= pstClassifierRule->usDestPortRangeLo[ucLoopIndex]) + { + return TRUE; + } + } + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Dest Port: %x Not Matched", ushDestPort); + return FALSE; } /** @ingroup tx_functions @@ -209,95 +209,95 @@ static USHORT IpVersion4(struct bcm_mini_adapter *Adapter, struct bcm_classifier_rule *pstClassifierRule) { struct bcm_transport_header *xprt_hdr = NULL; - BOOLEAN bClassificationSucceed=FALSE; + BOOLEAN bClassificationSucceed = FALSE; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "========>"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "========>"); - xprt_hdr=(struct bcm_transport_header *)((PUCHAR)iphd + sizeof(struct iphdr)); + xprt_hdr = (struct bcm_transport_header *)((PUCHAR)iphd + sizeof(struct iphdr)); do { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Trying to see Direction = %d %d", + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Trying to see Direction = %d %d", pstClassifierRule->ucDirection, pstClassifierRule->usVCID_Value); //Checking classifier validity - if(!pstClassifierRule->bUsed || pstClassifierRule->ucDirection == DOWNLINK_DIR) + if (!pstClassifierRule->bUsed || pstClassifierRule->ucDirection == DOWNLINK_DIR) { bClassificationSucceed = FALSE; break; } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "is IPv6 check!"); - if(pstClassifierRule->bIpv6Protocol) + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "is IPv6 check!"); + if (pstClassifierRule->bIpv6Protocol) break; //**************Checking IP header parameter**************************// - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Trying to match Source IP Address"); - if(FALSE == (bClassificationSucceed = + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Trying to match Source IP Address"); + if (FALSE == (bClassificationSucceed = MatchSrcIpAddress(pstClassifierRule, iphd->saddr))) break; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Source IP Address Matched"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Source IP Address Matched"); - if(FALSE == (bClassificationSucceed = + if (FALSE == (bClassificationSucceed = MatchDestIpAddress(pstClassifierRule, iphd->daddr))) break; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Destination IP Address Matched"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Destination IP Address Matched"); - if(FALSE == (bClassificationSucceed = + if (FALSE == (bClassificationSucceed = MatchTos(pstClassifierRule, iphd->tos))) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "TOS Match failed\n"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "TOS Match failed\n"); break; } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "TOS Matched"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "TOS Matched"); - if(FALSE == (bClassificationSucceed = - MatchProtocol(pstClassifierRule,iphd->protocol))) + if (FALSE == (bClassificationSucceed = + MatchProtocol(pstClassifierRule, iphd->protocol))) break; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Protocol Matched"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Protocol Matched"); //if protocol is not TCP or UDP then no need of comparing source port and destination port - if(iphd->protocol!=TCP && iphd->protocol!=UDP) + if (iphd->protocol != TCP && iphd->protocol != UDP) break; //******************Checking Transport Layer Header field if present *****************// - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Source Port %04x", - (iphd->protocol==UDP)?xprt_hdr->uhdr.source:xprt_hdr->thdr.source); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Source Port %04x", + (iphd->protocol == UDP) ? xprt_hdr->uhdr.source : xprt_hdr->thdr.source); - if(FALSE == (bClassificationSucceed = + if (FALSE == (bClassificationSucceed = MatchSrcPort(pstClassifierRule, - ntohs((iphd->protocol == UDP)? - xprt_hdr->uhdr.source:xprt_hdr->thdr.source)))) + ntohs((iphd->protocol == UDP) ? + xprt_hdr->uhdr.source : xprt_hdr->thdr.source)))) break; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Src Port Matched"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Src Port Matched"); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Destination Port %04x", - (iphd->protocol==UDP)?xprt_hdr->uhdr.dest: + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Destination Port %04x", + (iphd->protocol == UDP) ? xprt_hdr->uhdr.dest : xprt_hdr->thdr.dest); - if(FALSE == (bClassificationSucceed = + if (FALSE == (bClassificationSucceed = MatchDestPort(pstClassifierRule, - ntohs((iphd->protocol == UDP)? - xprt_hdr->uhdr.dest:xprt_hdr->thdr.dest)))) + ntohs((iphd->protocol == UDP) ? + xprt_hdr->uhdr.dest : xprt_hdr->thdr.dest)))) break; - } while(0); + } while (0); - if(TRUE==bClassificationSucceed) + if (TRUE == bClassificationSucceed) { INT iMatchedSFQueueIndex = 0; - iMatchedSFQueueIndex = SearchSfid(Adapter,pstClassifierRule->ulSFID); - if(iMatchedSFQueueIndex >= NO_OF_QUEUES) + iMatchedSFQueueIndex = SearchSfid(Adapter, pstClassifierRule->ulSFID); + if (iMatchedSFQueueIndex >= NO_OF_QUEUES) { bClassificationSucceed = FALSE; } else { - if(FALSE == Adapter->PackInfo[iMatchedSFQueueIndex].bActive) + if (FALSE == Adapter->PackInfo[iMatchedSFQueueIndex].bActive) { bClassificationSucceed = FALSE; } } } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "IpVersion4 <=========="); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "IpVersion4 <=========="); return bClassificationSucceed; } @@ -306,9 +306,9 @@ VOID PruneQueueAllSF(struct bcm_mini_adapter *Adapter) { UINT iIndex = 0; - for(iIndex = 0; iIndex < HiPriority; iIndex++) + for (iIndex = 0; iIndex < HiPriority; iIndex++) { - if(!Adapter->PackInfo[iIndex].bValid) + if (!Adapter->PackInfo[iIndex].bValid) continue; PruneQueue(Adapter, iIndex); @@ -325,15 +325,15 @@ less than or equal to max queue size for the queue. */ static VOID PruneQueue(struct bcm_mini_adapter *Adapter, INT iIndex) { - struct sk_buff* PacketToDrop=NULL; + struct sk_buff* PacketToDrop = NULL; struct net_device_stats *netstats; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, PRUNE_QUEUE, DBG_LVL_ALL, "=====> Index %d",iIndex); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, PRUNE_QUEUE, DBG_LVL_ALL, "=====> Index %d", iIndex); - if(iIndex == HiPriority) + if (iIndex == HiPriority) return; - if(!Adapter || (iIndex < 0) || (iIndex > HiPriority)) + if (!Adapter || (iIndex < 0) || (iIndex > HiPriority)) return; /* To Store the netdevice statistic */ @@ -341,26 +341,26 @@ static VOID PruneQueue(struct bcm_mini_adapter *Adapter, INT iIndex) spin_lock_bh(&Adapter->PackInfo[iIndex].SFQueueLock); - while(1) + while (1) // while((UINT)Adapter->PackInfo[iIndex].uiCurrentPacketsOnHost > // SF_MAX_ALLOWED_PACKETS_TO_BACKUP) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, PRUNE_QUEUE, DBG_LVL_ALL, "uiCurrentBytesOnHost:%x uiMaxBucketSize :%x", + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, PRUNE_QUEUE, DBG_LVL_ALL, "uiCurrentBytesOnHost:%x uiMaxBucketSize :%x", Adapter->PackInfo[iIndex].uiCurrentBytesOnHost, Adapter->PackInfo[iIndex].uiMaxBucketSize); PacketToDrop = Adapter->PackInfo[iIndex].FirstTxQueue; - if(PacketToDrop == NULL) + if (PacketToDrop == NULL) break; - if((Adapter->PackInfo[iIndex].uiCurrentPacketsOnHost < SF_MAX_ALLOWED_PACKETS_TO_BACKUP) && + if ((Adapter->PackInfo[iIndex].uiCurrentPacketsOnHost < SF_MAX_ALLOWED_PACKETS_TO_BACKUP) && ((1000*(jiffies - *((B_UINT32 *)(PacketToDrop->cb)+SKB_CB_LATENCY_OFFSET))/HZ) <= Adapter->PackInfo[iIndex].uiMaxLatency)) break; - if(PacketToDrop) + if (PacketToDrop) { if (netif_msg_tx_err(Adapter)) - pr_info(PFX "%s: tx queue %d overlimit\n", + pr_info(PFX "%s: tx queue %d overlimit\n", Adapter->dev->name, iIndex); netstats->tx_dropped++; @@ -378,7 +378,7 @@ static VOID PruneQueue(struct bcm_mini_adapter *Adapter, INT iIndex) } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, PRUNE_QUEUE, DBG_LVL_ALL, "Dropped Bytes:%x Dropped Packets:%x", + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, PRUNE_QUEUE, DBG_LVL_ALL, "Dropped Bytes:%x Dropped Packets:%x", Adapter->PackInfo[iIndex].uiDroppedCountBytes, Adapter->PackInfo[iIndex].uiDroppedCountPackets); @@ -387,29 +387,29 @@ static VOID PruneQueue(struct bcm_mini_adapter *Adapter, INT iIndex) spin_unlock_bh(&Adapter->PackInfo[iIndex].SFQueueLock); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, PRUNE_QUEUE, DBG_LVL_ALL, "TotalPacketCount:%x", + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, PRUNE_QUEUE, DBG_LVL_ALL, "TotalPacketCount:%x", atomic_read(&Adapter->TotalPacketCount)); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, PRUNE_QUEUE, DBG_LVL_ALL, "<====="); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, PRUNE_QUEUE, DBG_LVL_ALL, "<====="); } VOID flush_all_queues(struct bcm_mini_adapter *Adapter) { INT iQIndex; UINT uiTotalPacketLength; - struct sk_buff* PacketToDrop=NULL; + struct sk_buff* PacketToDrop = NULL; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "=====>"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "=====>"); // down(&Adapter->data_packet_queue_lock); - for(iQIndex=LowPriority; iQIndexdev->stats; spin_lock_bh(&Adapter->PackInfo[iQIndex].SFQueueLock); - while(Adapter->PackInfo[iQIndex].FirstTxQueue) + while (Adapter->PackInfo[iQIndex].FirstTxQueue) { PacketToDrop = Adapter->PackInfo[iQIndex].FirstTxQueue; - if(PacketToDrop) + if (PacketToDrop) { uiTotalPacketLength = PacketToDrop->len; netstats->tx_dropped++; @@ -431,7 +431,7 @@ VOID flush_all_queues(struct bcm_mini_adapter *Adapter) Adapter->PackInfo[iQIndex].uiDroppedCountBytes += uiTotalPacketLength; Adapter->PackInfo[iQIndex].uiDroppedCountPackets++; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "Dropped Bytes:%x Dropped Packets:%x", + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "Dropped Bytes:%x Dropped Packets:%x", Adapter->PackInfo[iQIndex].uiDroppedCountBytes, Adapter->PackInfo[iQIndex].uiDroppedCountPackets); atomic_dec(&Adapter->TotalPacketCount); @@ -439,30 +439,30 @@ VOID flush_all_queues(struct bcm_mini_adapter *Adapter) spin_unlock_bh(&Adapter->PackInfo[iQIndex].SFQueueLock); } // up(&Adapter->data_packet_queue_lock); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "<====="); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, DUMP_INFO, DBG_LVL_ALL, "<====="); } -USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter,struct sk_buff* skb) +USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter, struct sk_buff* skb) { - INT uiLoopIndex=0; + INT uiLoopIndex = 0; struct bcm_classifier_rule *pstClassifierRule = NULL; struct bcm_eth_packet_info stEthCsPktInfo; PVOID pvEThPayload = NULL; - struct iphdr *pIpHeader = NULL; - INT uiSfIndex=0; - USHORT usIndex=Adapter->usBestEffortQueueIndex; - BOOLEAN bFragmentedPkt=FALSE,bClassificationSucceed=FALSE; - USHORT usCurrFragment =0; + struct iphdr *pIpHeader = NULL; + INT uiSfIndex = 0; + USHORT usIndex = Adapter->usBestEffortQueueIndex; + BOOLEAN bFragmentedPkt = FALSE, bClassificationSucceed = FALSE; + USHORT usCurrFragment = 0; struct bcm_tcp_header *pTcpHeader; UCHAR IpHeaderLength; UCHAR TcpHeaderLength; pvEThPayload = skb->data; - *((UINT32*) (skb->cb) +SKB_CB_TCPACK_OFFSET ) = 0; - EThCSGetPktInfo(Adapter,pvEThPayload,&stEthCsPktInfo); + *((UINT32*) (skb->cb) +SKB_CB_TCPACK_OFFSET) = 0; + EThCSGetPktInfo(Adapter, pvEThPayload, &stEthCsPktInfo); - switch(stEthCsPktInfo.eNwpktEthFrameType) + switch (stEthCsPktInfo.eNwpktEthFrameType) { case eEth802LLCFrame: { @@ -497,75 +497,75 @@ USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter,struct sk_buff* skb) } } - if(stEthCsPktInfo.eNwpktIPFrameType == eIPv4Packet) + if (stEthCsPktInfo.eNwpktIPFrameType == eIPv4Packet) { usCurrFragment = (ntohs(pIpHeader->frag_off) & IP_OFFSET); - if((ntohs(pIpHeader->frag_off) & IP_MF) || usCurrFragment) + if ((ntohs(pIpHeader->frag_off) & IP_MF) || usCurrFragment) bFragmentedPkt = TRUE; - if(bFragmentedPkt) + if (bFragmentedPkt) { //Fragmented Packet. Get Frag Classifier Entry. - pstClassifierRule = GetFragIPClsEntry(Adapter,pIpHeader->id, pIpHeader->saddr); - if(pstClassifierRule) + pstClassifierRule = GetFragIPClsEntry(Adapter, pIpHeader->id, pIpHeader->saddr); + if (pstClassifierRule) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,"It is next Fragmented pkt"); - bClassificationSucceed=TRUE; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "It is next Fragmented pkt"); + bClassificationSucceed = TRUE; } - if(!(ntohs(pIpHeader->frag_off) & IP_MF)) + if (!(ntohs(pIpHeader->frag_off) & IP_MF)) { //Fragmented Last packet . Remove Frag Classifier Entry - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL,"This is the last fragmented Pkt"); - DelFragIPClsEntry(Adapter,pIpHeader->id, pIpHeader->saddr); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "This is the last fragmented Pkt"); + DelFragIPClsEntry(Adapter, pIpHeader->id, pIpHeader->saddr); } } } - for(uiLoopIndex = MAX_CLASSIFIERS - 1; uiLoopIndex >= 0; uiLoopIndex--) + for (uiLoopIndex = MAX_CLASSIFIERS - 1; uiLoopIndex >= 0; uiLoopIndex--) { - if(bClassificationSucceed) + if (bClassificationSucceed) break; //Iterate through all classifiers which are already in order of priority //to classify the packet until match found do { - if(FALSE==Adapter->astClassifierTable[uiLoopIndex].bUsed) + if (FALSE == Adapter->astClassifierTable[uiLoopIndex].bUsed) { - bClassificationSucceed=FALSE; + bClassificationSucceed = FALSE; break; } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Adapter->PackInfo[%d].bvalid=True\n",uiLoopIndex); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Adapter->PackInfo[%d].bvalid=True\n", uiLoopIndex); - if(0 == Adapter->astClassifierTable[uiLoopIndex].ucDirection) + if (0 == Adapter->astClassifierTable[uiLoopIndex].ucDirection) { - bClassificationSucceed=FALSE;//cannot be processed for classification. + bClassificationSucceed = FALSE;//cannot be processed for classification. break; // it is a down link connection } pstClassifierRule = &Adapter->astClassifierTable[uiLoopIndex]; - uiSfIndex = SearchSfid(Adapter,pstClassifierRule->ulSFID); + uiSfIndex = SearchSfid(Adapter, pstClassifierRule->ulSFID); if (uiSfIndex >= NO_OF_QUEUES) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Queue Not Valid. SearchSfid for this classifier Failed\n"); break; } - if(Adapter->PackInfo[uiSfIndex].bEthCSSupport) + if (Adapter->PackInfo[uiSfIndex].bEthCSSupport) { - if(eEthUnsupportedFrame==stEthCsPktInfo.eNwpktEthFrameType) + if (eEthUnsupportedFrame == stEthCsPktInfo.eNwpktEthFrameType) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, " ClassifyPacket : Packet Not a Valid Supported Ethernet Frame \n"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, " ClassifyPacket : Packet Not a Valid Supported Ethernet Frame\n"); bClassificationSucceed = FALSE; break; } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Performing ETH CS Classification on Classifier Rule ID : %x Service Flow ID : %lx\n",pstClassifierRule->uiClassifierRuleIndex,Adapter->PackInfo[uiSfIndex].ulSFID); - bClassificationSucceed = EThCSClassifyPkt(Adapter,skb,&stEthCsPktInfo,pstClassifierRule, Adapter->PackInfo[uiSfIndex].bEthCSSupport); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Performing ETH CS Classification on Classifier Rule ID : %x Service Flow ID : %lx\n", pstClassifierRule->uiClassifierRuleIndex, Adapter->PackInfo[uiSfIndex].ulSFID); + bClassificationSucceed = EThCSClassifyPkt(Adapter, skb, &stEthCsPktInfo, pstClassifierRule, Adapter->PackInfo[uiSfIndex].bEthCSSupport); - if(!bClassificationSucceed) + if (!bClassificationSucceed) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ClassifyPacket : Ethernet CS Classification Failed\n"); break; @@ -574,9 +574,9 @@ USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter,struct sk_buff* skb) else // No ETH Supported on this SF { - if(eEthOtherFrame != stEthCsPktInfo.eNwpktEthFrameType) + if (eEthOtherFrame != stEthCsPktInfo.eNwpktEthFrameType) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, " ClassifyPacket : Packet Not a 802.3 Ethernet Frame... hence not allowed over non-ETH CS SF \n"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, " ClassifyPacket : Packet Not a 802.3 Ethernet Frame... hence not allowed over non-ETH CS SF\n"); bClassificationSucceed = FALSE; break; } @@ -584,51 +584,51 @@ USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter,struct sk_buff* skb) BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Proceeding to IP CS Clasification"); - if(Adapter->PackInfo[uiSfIndex].bIPCSSupport) + if (Adapter->PackInfo[uiSfIndex].bIPCSSupport) { - if(stEthCsPktInfo.eNwpktIPFrameType == eNonIPPacket) + if (stEthCsPktInfo.eNwpktIPFrameType == eNonIPPacket) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, " ClassifyPacket : Packet is Not an IP Packet \n"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, " ClassifyPacket : Packet is Not an IP Packet\n"); bClassificationSucceed = FALSE; break; } - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Dump IP Header : \n"); - DumpFullPacket((PUCHAR)pIpHeader,20); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "Dump IP Header :\n"); + DumpFullPacket((PUCHAR)pIpHeader, 20); - if(stEthCsPktInfo.eNwpktIPFrameType == eIPv4Packet) - bClassificationSucceed = IpVersion4(Adapter,pIpHeader,pstClassifierRule); - else if(stEthCsPktInfo.eNwpktIPFrameType == eIPv6Packet) - bClassificationSucceed = IpVersion6(Adapter,pIpHeader,pstClassifierRule); + if (stEthCsPktInfo.eNwpktIPFrameType == eIPv4Packet) + bClassificationSucceed = IpVersion4(Adapter, pIpHeader, pstClassifierRule); + else if (stEthCsPktInfo.eNwpktIPFrameType == eIPv6Packet) + bClassificationSucceed = IpVersion6(Adapter, pIpHeader, pstClassifierRule); } - }while(0); + } while (0); } - if(bClassificationSucceed == TRUE) + if (bClassificationSucceed == TRUE) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "CF id : %d, SF ID is =%lu",pstClassifierRule->uiClassifierRuleIndex, pstClassifierRule->ulSFID); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "CF id : %d, SF ID is =%lu", pstClassifierRule->uiClassifierRuleIndex, pstClassifierRule->ulSFID); //Store The matched Classifier in SKB *((UINT32*)(skb->cb)+SKB_CB_CLASSIFICATION_OFFSET) = pstClassifierRule->uiClassifierRuleIndex; - if((TCP == pIpHeader->protocol ) && !bFragmentedPkt && (ETH_AND_IP_HEADER_LEN + TCP_HEADER_LEN <= skb->len) ) + if ((TCP == pIpHeader->protocol) && !bFragmentedPkt && (ETH_AND_IP_HEADER_LEN + TCP_HEADER_LEN <= skb->len)) { IpHeaderLength = pIpHeader->ihl; pTcpHeader = (struct bcm_tcp_header *)(((PUCHAR)pIpHeader)+(IpHeaderLength*4)); TcpHeaderLength = GET_TCP_HEADER_LEN(pTcpHeader->HeaderLength); - if((pTcpHeader->ucFlags & TCP_ACK) && + if ((pTcpHeader->ucFlags & TCP_ACK) && (ntohs(pIpHeader->tot_len) == (IpHeaderLength*4)+(TcpHeaderLength*4))) { - *((UINT32*) (skb->cb) +SKB_CB_TCPACK_OFFSET ) = TCP_ACK; + *((UINT32*) (skb->cb) + SKB_CB_TCPACK_OFFSET) = TCP_ACK; } } usIndex = SearchSfid(Adapter, pstClassifierRule->ulSFID); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "index is =%d", usIndex); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "index is =%d", usIndex); //If this is the first fragment of a Fragmented pkt, add this CF. Only This CF should be used for all other fragment of this Pkt. - if(bFragmentedPkt && (usCurrFragment == 0)) + if (bFragmentedPkt && (usCurrFragment == 0)) { //First Fragment of Fragmented Packet. Create Frag CLS Entry struct bcm_fragmented_packet_info stFragPktInfo; @@ -637,77 +637,77 @@ USHORT ClassifyPacket(struct bcm_mini_adapter *Adapter,struct sk_buff* skb) stFragPktInfo.usIpIdentification = pIpHeader->id; stFragPktInfo.pstMatchedClassifierEntry = pstClassifierRule; stFragPktInfo.bOutOfOrderFragment = FALSE; - AddFragIPClsEntry(Adapter,&stFragPktInfo); + AddFragIPClsEntry(Adapter, &stFragPktInfo); } } - if(bClassificationSucceed) + if (bClassificationSucceed) return usIndex; else return INVALID_QUEUE_INDEX; } -static BOOLEAN EthCSMatchSrcMACAddress(struct bcm_classifier_rule *pstClassifierRule,PUCHAR Mac) +static BOOLEAN EthCSMatchSrcMACAddress(struct bcm_classifier_rule *pstClassifierRule, PUCHAR Mac) { - UINT i=0; + UINT i = 0; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - if(pstClassifierRule->ucEthCSSrcMACLen==0) + if (pstClassifierRule->ucEthCSSrcMACLen == 0) return TRUE; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s \n",__FUNCTION__); - for(i=0;iau8EThCSSrcMAC[i],pstClassifierRule->au8EThCSSrcMACMask[i]); - if((pstClassifierRule->au8EThCSSrcMAC[i] & pstClassifierRule->au8EThCSSrcMACMask[i])!= + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "SRC MAC[%x] = %x ClassifierRuleSrcMAC = %x Mask : %x\n", i, Mac[i], pstClassifierRule->au8EThCSSrcMAC[i], pstClassifierRule->au8EThCSSrcMACMask[i]); + if ((pstClassifierRule->au8EThCSSrcMAC[i] & pstClassifierRule->au8EThCSSrcMACMask[i]) != (Mac[i] & pstClassifierRule->au8EThCSSrcMACMask[i])) return FALSE; } return TRUE; } -static BOOLEAN EthCSMatchDestMACAddress(struct bcm_classifier_rule *pstClassifierRule,PUCHAR Mac) +static BOOLEAN EthCSMatchDestMACAddress(struct bcm_classifier_rule *pstClassifierRule, PUCHAR Mac) { - UINT i=0; + UINT i = 0; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - if(pstClassifierRule->ucEthCSDestMACLen==0) + if (pstClassifierRule->ucEthCSDestMACLen == 0) return TRUE; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s \n",__FUNCTION__); - for(i=0;iau8EThCSDestMAC[i],pstClassifierRule->au8EThCSDestMACMask[i]); - if((pstClassifierRule->au8EThCSDestMAC[i] & pstClassifierRule->au8EThCSDestMACMask[i])!= + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "SRC MAC[%x] = %x ClassifierRuleSrcMAC = %x Mask : %x\n", i, Mac[i], pstClassifierRule->au8EThCSDestMAC[i], pstClassifierRule->au8EThCSDestMACMask[i]); + if ((pstClassifierRule->au8EThCSDestMAC[i] & pstClassifierRule->au8EThCSDestMACMask[i]) != (Mac[i] & pstClassifierRule->au8EThCSDestMACMask[i])) return FALSE; } return TRUE; } -static BOOLEAN EthCSMatchEThTypeSAP(struct bcm_classifier_rule *pstClassifierRule,struct sk_buff* skb, struct bcm_eth_packet_info *pstEthCsPktInfo) +static BOOLEAN EthCSMatchEThTypeSAP(struct bcm_classifier_rule *pstClassifierRule, struct sk_buff* skb, struct bcm_eth_packet_info *pstEthCsPktInfo) { struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - if((pstClassifierRule->ucEtherTypeLen==0)|| + if ((pstClassifierRule->ucEtherTypeLen == 0) || (pstClassifierRule->au8EthCSEtherType[0] == 0)) return TRUE; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s SrcEtherType:%x CLS EtherType[0]:%x\n",__FUNCTION__,pstEthCsPktInfo->usEtherType,pstClassifierRule->au8EthCSEtherType[0]); - if(pstClassifierRule->au8EthCSEtherType[0] == 1) + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s SrcEtherType:%x CLS EtherType[0]:%x\n", __FUNCTION__, pstEthCsPktInfo->usEtherType, pstClassifierRule->au8EthCSEtherType[0]); + if (pstClassifierRule->au8EthCSEtherType[0] == 1) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s CLS EtherType[1]:%x EtherType[2]:%x\n",__FUNCTION__,pstClassifierRule->au8EthCSEtherType[1],pstClassifierRule->au8EthCSEtherType[2]); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s CLS EtherType[1]:%x EtherType[2]:%x\n", __FUNCTION__, pstClassifierRule->au8EthCSEtherType[1], pstClassifierRule->au8EthCSEtherType[2]); - if(memcmp(&pstEthCsPktInfo->usEtherType,&pstClassifierRule->au8EthCSEtherType[1],2)==0) + if (memcmp(&pstEthCsPktInfo->usEtherType, &pstClassifierRule->au8EthCSEtherType[1], 2) == 0) return TRUE; else return FALSE; } - if(pstClassifierRule->au8EthCSEtherType[0] == 2) + if (pstClassifierRule->au8EthCSEtherType[0] == 2) { - if(eEth802LLCFrame != pstEthCsPktInfo->eNwpktEthFrameType) + if (eEth802LLCFrame != pstEthCsPktInfo->eNwpktEthFrameType) return FALSE; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s EthCS DSAP:%x EtherType[2]:%x\n",__FUNCTION__,pstEthCsPktInfo->ucDSAP,pstClassifierRule->au8EthCSEtherType[2]); - if(pstEthCsPktInfo->ucDSAP == pstClassifierRule->au8EthCSEtherType[2]) + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s EthCS DSAP:%x EtherType[2]:%x\n", __FUNCTION__, pstEthCsPktInfo->ucDSAP, pstClassifierRule->au8EthCSEtherType[2]); + if (pstEthCsPktInfo->ucDSAP == pstClassifierRule->au8EthCSEtherType[2]) return TRUE; else return FALSE; @@ -718,27 +718,27 @@ static BOOLEAN EthCSMatchEThTypeSAP(struct bcm_classifier_rule *pstClassifierRul } -static BOOLEAN EthCSMatchVLANRules(struct bcm_classifier_rule *pstClassifierRule,struct sk_buff* skb, struct bcm_eth_packet_info *pstEthCsPktInfo) +static BOOLEAN EthCSMatchVLANRules(struct bcm_classifier_rule *pstClassifierRule, struct sk_buff* skb, struct bcm_eth_packet_info *pstEthCsPktInfo) { BOOLEAN bClassificationSucceed = FALSE; USHORT usVLANID; B_UINT8 uPriority = 0; struct bcm_mini_adapter *Adapter = GET_BCM_ADAPTER(gblpnetdev); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s CLS UserPrio:%x CLS VLANID:%x\n",__FUNCTION__,ntohs(*((USHORT *)pstClassifierRule->usUserPriority)),pstClassifierRule->usVLANID); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s CLS UserPrio:%x CLS VLANID:%x\n", __FUNCTION__, ntohs(*((USHORT *)pstClassifierRule->usUserPriority)), pstClassifierRule->usVLANID); /* In case FW didn't receive the TLV, the priority field should be ignored */ - if(pstClassifierRule->usValidityBitMap & (1<usValidityBitMap & (1<eNwpktEthFrameType!=eEth802QVLANFrame) + if (pstEthCsPktInfo->eNwpktEthFrameType != eEth802QVLANFrame) return FALSE; uPriority = (ntohs(*(USHORT *)(skb->data + sizeof(struct bcm_eth_header))) & 0xF000) >> 13; - if((uPriority >= pstClassifierRule->usUserPriority[0]) && (uPriority <= pstClassifierRule->usUserPriority[1])) + if ((uPriority >= pstClassifierRule->usUserPriority[0]) && (uPriority <= pstClassifierRule->usUserPriority[1])) bClassificationSucceed = TRUE; - if(!bClassificationSucceed) + if (!bClassificationSucceed) return FALSE; } @@ -746,19 +746,19 @@ static BOOLEAN EthCSMatchVLANRules(struct bcm_classifier_rule *pstClassifierRule bClassificationSucceed = FALSE; - if(pstClassifierRule->usValidityBitMap & (1<usValidityBitMap & (1<eNwpktEthFrameType!=eEth802QVLANFrame) + if (pstEthCsPktInfo->eNwpktEthFrameType != eEth802QVLANFrame) return FALSE; usVLANID = ntohs(*(USHORT *)(skb->data + sizeof(struct bcm_eth_header))) & 0xFFF; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s Pkt VLANID %x Priority: %d\n",__FUNCTION__,usVLANID, uPriority); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "%s Pkt VLANID %x Priority: %d\n", __FUNCTION__, usVLANID, uPriority); - if(usVLANID == ((pstClassifierRule->usVLANID & 0xFFF0) >> 4)) + if (usVLANID == ((pstClassifierRule->usVLANID & 0xFFF0) >> 4)) bClassificationSucceed = TRUE; - if(!bClassificationSucceed) + if (!bClassificationSucceed) return FALSE; } @@ -768,50 +768,50 @@ static BOOLEAN EthCSMatchVLANRules(struct bcm_classifier_rule *pstClassifierRule } -static BOOLEAN EThCSClassifyPkt(struct bcm_mini_adapter *Adapter,struct sk_buff* skb, +static BOOLEAN EThCSClassifyPkt(struct bcm_mini_adapter *Adapter, struct sk_buff* skb, struct bcm_eth_packet_info *pstEthCsPktInfo, struct bcm_classifier_rule *pstClassifierRule, B_UINT8 EthCSCupport) { BOOLEAN bClassificationSucceed = FALSE; - bClassificationSucceed = EthCSMatchSrcMACAddress(pstClassifierRule,((struct bcm_eth_header *)(skb->data))->au8SourceAddress); - if(!bClassificationSucceed) + bClassificationSucceed = EthCSMatchSrcMACAddress(pstClassifierRule, ((struct bcm_eth_header *)(skb->data))->au8SourceAddress); + if (!bClassificationSucceed) return FALSE; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ETH CS SrcMAC Matched\n"); - bClassificationSucceed = EthCSMatchDestMACAddress(pstClassifierRule,((struct bcm_eth_header *)(skb->data))->au8DestinationAddress); - if(!bClassificationSucceed) + bClassificationSucceed = EthCSMatchDestMACAddress(pstClassifierRule, ((struct bcm_eth_header *)(skb->data))->au8DestinationAddress); + if (!bClassificationSucceed) return FALSE; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ETH CS DestMAC Matched\n"); //classify on ETHType/802.2SAP TLV - bClassificationSucceed = EthCSMatchEThTypeSAP(pstClassifierRule,skb,pstEthCsPktInfo); - if(!bClassificationSucceed) + bClassificationSucceed = EthCSMatchEThTypeSAP(pstClassifierRule, skb, pstEthCsPktInfo); + if (!bClassificationSucceed) return FALSE; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ETH CS EthType/802.2SAP Matched\n"); //classify on 802.1VLAN Header Parameters - bClassificationSucceed = EthCSMatchVLANRules(pstClassifierRule,skb,pstEthCsPktInfo); - if(!bClassificationSucceed) + bClassificationSucceed = EthCSMatchVLANRules(pstClassifierRule, skb, pstEthCsPktInfo); + if (!bClassificationSucceed) return FALSE; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "ETH CS 802.1 VLAN Rules Matched\n"); return bClassificationSucceed; } -static void EThCSGetPktInfo(struct bcm_mini_adapter *Adapter,PVOID pvEthPayload, +static void EThCSGetPktInfo(struct bcm_mini_adapter *Adapter, PVOID pvEthPayload, struct bcm_eth_packet_info *pstEthCsPktInfo) { USHORT u16Etype = ntohs(((struct bcm_eth_header *)pvEthPayload)->u16Etype); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "EthCSGetPktInfo : Eth Hdr Type : %X\n",u16Etype); - if(u16Etype > 0x5dc) + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "EthCSGetPktInfo : Eth Hdr Type : %X\n", u16Etype); + if (u16Etype > 0x5dc) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "EthCSGetPktInfo : ETH2 Frame \n"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "EthCSGetPktInfo : ETH2 Frame\n"); //ETH2 Frame - if(u16Etype == ETHERNET_FRAMETYPE_802QVLAN) + if (u16Etype == ETHERNET_FRAMETYPE_802QVLAN) { //802.1Q VLAN Header pstEthCsPktInfo->eNwpktEthFrameType = eEth802QVLANFrame; @@ -828,27 +828,27 @@ static void EThCSGetPktInfo(struct bcm_mini_adapter *Adapter,PVOID pvEthPayload, else { //802.2 LLC - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "802.2 LLC Frame \n"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "802.2 LLC Frame\n"); pstEthCsPktInfo->eNwpktEthFrameType = eEth802LLCFrame; pstEthCsPktInfo->ucDSAP = ((struct bcm_eth_llc_frame *)pvEthPayload)->DSAP; - if(pstEthCsPktInfo->ucDSAP == 0xAA && ((struct bcm_eth_llc_frame *)pvEthPayload)->SSAP == 0xAA) + if (pstEthCsPktInfo->ucDSAP == 0xAA && ((struct bcm_eth_llc_frame *)pvEthPayload)->SSAP == 0xAA) { //SNAP Frame pstEthCsPktInfo->eNwpktEthFrameType = eEth802LLCSNAPFrame; u16Etype = ((struct bcm_eth_llc_snap_frame *)pvEthPayload)->usEtherType; } } - if(u16Etype == ETHERNET_FRAMETYPE_IPV4) + if (u16Etype == ETHERNET_FRAMETYPE_IPV4) pstEthCsPktInfo->eNwpktIPFrameType = eIPv4Packet; - else if(u16Etype == ETHERNET_FRAMETYPE_IPV6) + else if (u16Etype == ETHERNET_FRAMETYPE_IPV6) pstEthCsPktInfo->eNwpktIPFrameType = eIPv6Packet; else pstEthCsPktInfo->eNwpktIPFrameType = eNonIPPacket; pstEthCsPktInfo->usEtherType = ((struct bcm_eth_header *)pvEthPayload)->u16Etype; - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "EthCsPktInfo->eNwpktIPFrameType : %x\n",pstEthCsPktInfo->eNwpktIPFrameType); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "EthCsPktInfo->eNwpktEthFrameType : %x\n",pstEthCsPktInfo->eNwpktEthFrameType); - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "EthCsPktInfo->usEtherType : %x\n",pstEthCsPktInfo->usEtherType); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "EthCsPktInfo->eNwpktIPFrameType : %x\n", pstEthCsPktInfo->eNwpktIPFrameType); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "EthCsPktInfo->eNwpktEthFrameType : %x\n", pstEthCsPktInfo->eNwpktEthFrameType); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, IPV4_DBG, DBG_LVL_ALL, "EthCsPktInfo->usEtherType : %x\n", pstEthCsPktInfo->usEtherType); } -- GitLab From 4599934de2cd1c028efcfb8dd643f47bc999d4ff Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Wed, 24 Jul 2013 01:05:07 +0900 Subject: [PATCH 109/942] staging: imx-drm: Fix typo in staging/imx-drm Correct spelling typo in staging/imx-drm Singed-off-by: Masanari Iida Acked-by: Sascha Hauer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/imx-drm/Kconfig | 2 +- drivers/staging/imx-drm/imx-ldb.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/imx-drm/Kconfig b/drivers/staging/imx-drm/Kconfig index 22339059837ff..6156e3f2a3e76 100644 --- a/drivers/staging/imx-drm/Kconfig +++ b/drivers/staging/imx-drm/Kconfig @@ -15,7 +15,7 @@ config DRM_IMX_FB_HELPER help The DRM framework can provide a legacy /dev/fb0 framebuffer for your device. This is necessary to get a framebuffer console - and also for appplications using the legacy framebuffer API + and also for applications using the legacy framebuffer API config DRM_IMX_PARALLEL_DISPLAY tristate "Support for parallel displays" diff --git a/drivers/staging/imx-drm/imx-ldb.c b/drivers/staging/imx-drm/imx-ldb.c index 8af7f3b40baec..bb7da0e4dc038 100644 --- a/drivers/staging/imx-drm/imx-ldb.c +++ b/drivers/staging/imx-drm/imx-ldb.c @@ -497,7 +497,7 @@ static int imx_ldb_probe(struct platform_device *pdev) imx_ldb->ldb_ctrl |= LDB_SPLIT_MODE_EN; /* - * There are three diferent possible clock mux configurations: + * There are three different possible clock mux configurations: * i.MX53: ipu1_di0_sel, ipu1_di1_sel * i.MX6q: ipu1_di0_sel, ipu1_di1_sel, ipu2_di0_sel, ipu2_di1_sel * i.MX6dl: ipu1_di0_sel, ipu1_di1_sel, lcdif_sel -- GitLab From 87fa05e8ab38149c1e69324c96ade9d47f6d27b9 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Wed, 10 Jul 2013 17:27:21 +0300 Subject: [PATCH 110/942] staging: rtl8712: return MAC in standard form MAC respresentation should follow standard form. Signed-off-by: Andy Shevchenko Acked-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c index f034567122d97..d58aa7e3b15ce 100644 --- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c +++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c @@ -1000,12 +1000,8 @@ static int r871x_wx_set_priv(struct net_device *dev, sprintf(ext, "LINKSPEED %d", mbps); } else if (0 == strcasecmp(ext, "MACADDR")) { /*Return mac address of the station */ - /*Macaddr = xx.xx.xx.xx.xx.xx */ - sprintf(ext, - "MACADDR = %02x.%02x.%02x.%02x.%02x.%02x", - *(dev->dev_addr), *(dev->dev_addr+1), - *(dev->dev_addr+2), *(dev->dev_addr+3), - *(dev->dev_addr+4), *(dev->dev_addr+5)); + /* Macaddr = xx:xx:xx:xx:xx:xx */ + sprintf(ext, "MACADDR = %pM", dev->dev_addr); } else if (0 == strcasecmp(ext, "SCAN-ACTIVE")) { /*Set scan type to active */ /*OK if successful */ -- GitLab From e842b976a88a39b447fc34bd0fcb3c0be0a1d9d9 Mon Sep 17 00:00:00 2001 From: Sunghan Suh Date: Fri, 12 Jul 2013 16:08:13 +0900 Subject: [PATCH 111/942] staging: zsmalloc: access page->private by using page_private macro Signed-off-by: Sunghan Suh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/zsmalloc/zsmalloc-main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/zsmalloc/zsmalloc-main.c b/drivers/staging/zsmalloc/zsmalloc-main.c index 4bb275b2d98f8..1a67537dbc565 100644 --- a/drivers/staging/zsmalloc/zsmalloc-main.c +++ b/drivers/staging/zsmalloc/zsmalloc-main.c @@ -423,7 +423,7 @@ static struct page *get_next_page(struct page *page) if (is_last_page(page)) next = NULL; else if (is_first_page(page)) - next = (struct page *)page->private; + next = (struct page *)page_private(page); else next = list_entry(page->lru.next, struct page, lru); @@ -581,7 +581,7 @@ static struct page *alloc_zspage(struct size_class *class, gfp_t flags) first_page->inuse = 0; } if (i == 1) - first_page->private = (unsigned long)page; + set_page_private(first_page, (unsigned long)page); if (i >= 1) page->first_page = first_page; if (i >= 2) -- GitLab From 0d012b98662495f1fe5c4aa8acc7e6ed121c1254 Mon Sep 17 00:00:00 2001 From: Paul Zimmerman Date: Sat, 13 Jul 2013 14:53:48 -0700 Subject: [PATCH 112/942] staging: dwc2: refactor dwc2_host_complete() The parameters to dwc2_host_complete() didn't make much sense. The 'context' parameter always came from the ->priv member of the 'dwc2_urb' parameter, and both of those always came from a struct dwc2_qtd. So just pass in the struct dwc2_qtd instead. This also allows us to null out the dwc2_qtd->urb member after it is freed, which the calling code forgot to do in several places, causing random driver crashes from dereferencing the freed pointer. This also requires the calls to dwc2_hc_handle_tt_clear() to be moved before the calls to dwc2_host_complete(), otherwise that routine would do nothing because dwc2_qtd->urb has already been freed. Signed-off-by: Paul Zimmerman Tested-by: Stephen Warren Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dwc2/hcd.c | 42 +++++++++++++---------- drivers/staging/dwc2/hcd.h | 4 +-- drivers/staging/dwc2/hcd_ddma.c | 23 +++++++++---- drivers/staging/dwc2/hcd_intr.c | 59 +++++++++++++++------------------ 4 files changed, 68 insertions(+), 60 deletions(-) diff --git a/drivers/staging/dwc2/hcd.c b/drivers/staging/dwc2/hcd.c index 2ed54b172a3b1..e8fb84f53dd90 100644 --- a/drivers/staging/dwc2/hcd.c +++ b/drivers/staging/dwc2/hcd.c @@ -134,11 +134,8 @@ static void dwc2_kill_urbs_in_qh_list(struct dwc2_hsotg *hsotg, list_for_each_entry_safe(qh, qh_tmp, qh_list, qh_list_entry) { list_for_each_entry_safe(qtd, qtd_tmp, &qh->qtd_list, qtd_list_entry) { - if (qtd->urb != NULL) { - dwc2_host_complete(hsotg, qtd->urb->priv, - qtd->urb, -ETIMEDOUT); - dwc2_hcd_qtd_unlink_and_free(hsotg, qtd, qh); - } + dwc2_host_complete(hsotg, qtd, -ETIMEDOUT); + dwc2_hcd_qtd_unlink_and_free(hsotg, qtd, qh); } } } @@ -421,6 +418,8 @@ static int dwc2_hcd_urb_dequeue(struct dwc2_hsotg *hsotg, return -EINVAL; } + urb->priv = NULL; + if (urb_qtd->in_process && qh->channel) { dwc2_dump_channel_info(hsotg, qh->channel); @@ -2088,23 +2087,29 @@ static void dwc2_free_bus_bandwidth(struct usb_hcd *hcd, u16 bw, * * Must be called with interrupt disabled and spinlock held */ -void dwc2_host_complete(struct dwc2_hsotg *hsotg, void *context, - struct dwc2_hcd_urb *dwc2_urb, int status) +void dwc2_host_complete(struct dwc2_hsotg *hsotg, struct dwc2_qtd *qtd, + int status) { - struct urb *urb = context; + struct urb *urb; int i; - if (!urb) { - dev_dbg(hsotg->dev, "## %s: context is NULL ##\n", __func__); + if (!qtd) { + dev_dbg(hsotg->dev, "## %s: qtd is NULL ##\n", __func__); return; } - if (!dwc2_urb) { - dev_dbg(hsotg->dev, "## %s: dwc2_urb is NULL ##\n", __func__); + if (!qtd->urb) { + dev_dbg(hsotg->dev, "## %s: qtd->urb is NULL ##\n", __func__); return; } - urb->actual_length = dwc2_hcd_urb_get_actual_length(dwc2_urb); + urb = qtd->urb->priv; + if (!urb) { + dev_dbg(hsotg->dev, "## %s: urb->priv is NULL ##\n", __func__); + return; + } + + urb->actual_length = dwc2_hcd_urb_get_actual_length(qtd->urb); if (dbg_urb(urb)) dev_vdbg(hsotg->dev, @@ -2121,18 +2126,17 @@ void dwc2_host_complete(struct dwc2_hsotg *hsotg, void *context, } if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) { - urb->error_count = dwc2_hcd_urb_get_error_count(dwc2_urb); + urb->error_count = dwc2_hcd_urb_get_error_count(qtd->urb); for (i = 0; i < urb->number_of_packets; ++i) { urb->iso_frame_desc[i].actual_length = dwc2_hcd_urb_get_iso_desc_actual_length( - dwc2_urb, i); + qtd->urb, i); urb->iso_frame_desc[i].status = - dwc2_hcd_urb_get_iso_desc_status(dwc2_urb, i); + dwc2_hcd_urb_get_iso_desc_status(qtd->urb, i); } } urb->status = status; - urb->hcpriv = NULL; if (!status) { if ((urb->transfer_flags & URB_SHORT_NOT_OK) && urb->actual_length < urb->transfer_buffer_length) @@ -2149,7 +2153,9 @@ void dwc2_host_complete(struct dwc2_hsotg *hsotg, void *context, urb); } - kfree(dwc2_urb); + urb->hcpriv = NULL; + kfree(qtd->urb); + qtd->urb = NULL; spin_unlock(&hsotg->lock); usb_hcd_giveback_urb(dwc2_hsotg_to_hcd(hsotg), urb, status); diff --git a/drivers/staging/dwc2/hcd.h b/drivers/staging/dwc2/hcd.h index cf6c055aec8d1..933e8d1999bfa 100644 --- a/drivers/staging/dwc2/hcd.h +++ b/drivers/staging/dwc2/hcd.h @@ -716,8 +716,8 @@ extern void dwc2_host_disconnect(struct dwc2_hsotg *hsotg); extern void dwc2_host_hub_info(struct dwc2_hsotg *hsotg, void *context, int *hub_addr, int *hub_port); extern int dwc2_host_get_speed(struct dwc2_hsotg *hsotg, void *context); -extern void dwc2_host_complete(struct dwc2_hsotg *hsotg, void *context, - struct dwc2_hcd_urb *dwc2_urb, int status); +extern void dwc2_host_complete(struct dwc2_hsotg *hsotg, struct dwc2_qtd *qtd, + int status); #ifdef DEBUG /* diff --git a/drivers/staging/dwc2/hcd_ddma.c b/drivers/staging/dwc2/hcd_ddma.c index 5c0fd273a7bfd..de5af1b9b5d9b 100644 --- a/drivers/staging/dwc2/hcd_ddma.c +++ b/drivers/staging/dwc2/hcd_ddma.c @@ -800,6 +800,9 @@ static int dwc2_cmpl_host_isoc_dma_desc(struct dwc2_hsotg *hsotg, u16 remain = 0; int rc = 0; + if (!qtd->urb) + return -EINVAL; + frame_desc = &qtd->urb->iso_descs[qtd->isoc_frame_index_last]; dma_desc->buf = (u32)(qtd->urb->dma + frame_desc->offset); if (chan->ep_is_in) @@ -826,7 +829,7 @@ static int dwc2_cmpl_host_isoc_dma_desc(struct dwc2_hsotg *hsotg, * urb->status is not used for isoc transfers here. The * individual frame_desc status are used instead. */ - dwc2_host_complete(hsotg, qtd->urb->priv, qtd->urb, 0); + dwc2_host_complete(hsotg, qtd, 0); dwc2_hcd_qtd_unlink_and_free(hsotg, qtd, qh); /* @@ -884,13 +887,16 @@ static void dwc2_complete_isoc_xfer_ddma(struct dwc2_hsotg *hsotg, list_for_each_entry_safe(qtd, qtd_tmp, &qh->qtd_list, qtd_list_entry) { - for (idx = 0; idx < qtd->urb->packet_count; idx++) { - frame_desc = &qtd->urb->iso_descs[idx]; - frame_desc->status = err; + if (qtd->urb) { + for (idx = 0; idx < qtd->urb->packet_count; + idx++) { + frame_desc = &qtd->urb->iso_descs[idx]; + frame_desc->status = err; + } + + dwc2_host_complete(hsotg, qtd, err); } - dwc2_host_complete(hsotg, qtd->urb->priv, qtd->urb, - err); dwc2_hcd_qtd_unlink_and_free(hsotg, qtd, qh); } @@ -1015,6 +1021,9 @@ static int dwc2_process_non_isoc_desc(struct dwc2_hsotg *hsotg, dev_vdbg(hsotg->dev, "%s()\n", __func__); + if (!urb) + return -EINVAL; + dma_desc = &qh->desc_list[desc_num]; n_bytes = qh->n_bytes[desc_num]; dev_vdbg(hsotg->dev, @@ -1024,7 +1033,7 @@ static int dwc2_process_non_isoc_desc(struct dwc2_hsotg *hsotg, halt_status, n_bytes, xfer_done); if (failed || (*xfer_done && urb->status != -EINPROGRESS)) { - dwc2_host_complete(hsotg, urb->priv, urb, urb->status); + dwc2_host_complete(hsotg, qtd, urb->status); dwc2_hcd_qtd_unlink_and_free(hsotg, qtd, qh); dev_vdbg(hsotg->dev, "failed=%1x xfer_done=%1x status=%08x\n", failed, *xfer_done, urb->status); diff --git a/drivers/staging/dwc2/hcd_intr.c b/drivers/staging/dwc2/hcd_intr.c index e75dccb3b80b5..22836f5f7ff66 100644 --- a/drivers/staging/dwc2/hcd_intr.c +++ b/drivers/staging/dwc2/hcd_intr.c @@ -623,7 +623,7 @@ static enum dwc2_halt_status dwc2_update_isoc_urb_state( * urb->status is not used for isoc transfers. The individual * frame_desc statuses are used instead. */ - dwc2_host_complete(hsotg, urb->priv, urb, 0); + dwc2_host_complete(hsotg, qtd, 0); halt_status = DWC2_HC_XFER_URB_COMPLETE; } else { halt_status = DWC2_HC_XFER_COMPLETE; @@ -714,11 +714,7 @@ static void dwc2_release_channel(struct dwc2_hsotg *hsotg, dev_vdbg(hsotg->dev, " Complete URB with transaction error\n"); free_qtd = 1; - if (qtd->urb) { - qtd->urb->status = -EPROTO; - dwc2_host_complete(hsotg, qtd->urb->priv, - qtd->urb, -EPROTO); - } + dwc2_host_complete(hsotg, qtd, -EPROTO); } break; case DWC2_HC_XFER_URB_DEQUEUE: @@ -731,11 +727,7 @@ static void dwc2_release_channel(struct dwc2_hsotg *hsotg, case DWC2_HC_XFER_PERIODIC_INCOMPLETE: dev_vdbg(hsotg->dev, " Complete URB with I/O error\n"); free_qtd = 1; - if (qtd && qtd->urb) { - qtd->urb->status = -EIO; - dwc2_host_complete(hsotg, qtd->urb->priv, qtd->urb, - -EIO); - } + dwc2_host_complete(hsotg, qtd, -EIO); break; case DWC2_HC_XFER_NO_HALT_STATUS: default: @@ -957,7 +949,7 @@ static int dwc2_xfercomp_isoc_split_in(struct dwc2_hsotg *hsotg, } if (qtd->isoc_frame_index == qtd->urb->packet_count) { - dwc2_host_complete(hsotg, qtd->urb->priv, qtd->urb, 0); + dwc2_host_complete(hsotg, qtd, 0); dwc2_release_channel(hsotg, chan, qtd, DWC2_HC_XFER_URB_COMPLETE); } else { @@ -1040,7 +1032,7 @@ static void dwc2_hc_xfercomp_intr(struct dwc2_hsotg *hsotg, dev_vdbg(hsotg->dev, " Control transfer complete\n"); if (urb->status == -EINPROGRESS) urb->status = 0; - dwc2_host_complete(hsotg, urb->priv, urb, urb->status); + dwc2_host_complete(hsotg, qtd, urb->status); halt_status = DWC2_HC_XFER_URB_COMPLETE; break; } @@ -1053,7 +1045,7 @@ static void dwc2_hc_xfercomp_intr(struct dwc2_hsotg *hsotg, urb_xfer_done = dwc2_update_urb_state(hsotg, chan, chnum, urb, qtd); if (urb_xfer_done) { - dwc2_host_complete(hsotg, urb->priv, urb, urb->status); + dwc2_host_complete(hsotg, qtd, urb->status); halt_status = DWC2_HC_XFER_URB_COMPLETE; } else { halt_status = DWC2_HC_XFER_COMPLETE; @@ -1073,11 +1065,10 @@ static void dwc2_hc_xfercomp_intr(struct dwc2_hsotg *hsotg, * interrupt */ if (urb_xfer_done) { - dwc2_host_complete(hsotg, urb->priv, urb, - urb->status); - halt_status = DWC2_HC_XFER_URB_COMPLETE; + dwc2_host_complete(hsotg, qtd, urb->status); + halt_status = DWC2_HC_XFER_URB_COMPLETE; } else { - halt_status = DWC2_HC_XFER_COMPLETE; + halt_status = DWC2_HC_XFER_COMPLETE; } dwc2_hcd_save_data_toggle(hsotg, chan, chnum, qtd); @@ -1123,11 +1114,11 @@ static void dwc2_hc_stall_intr(struct dwc2_hsotg *hsotg, goto handle_stall_halt; if (pipe_type == USB_ENDPOINT_XFER_CONTROL) - dwc2_host_complete(hsotg, urb->priv, urb, -EPIPE); + dwc2_host_complete(hsotg, qtd, -EPIPE); if (pipe_type == USB_ENDPOINT_XFER_BULK || pipe_type == USB_ENDPOINT_XFER_INT) { - dwc2_host_complete(hsotg, urb->priv, urb, -EPIPE); + dwc2_host_complete(hsotg, qtd, -EPIPE); /* * USB protocol requires resetting the data toggle for bulk * and interrupt endpoints when a CLEAR_FEATURE(ENDPOINT_HALT) @@ -1372,10 +1363,10 @@ static void dwc2_hc_nyet_intr(struct dwc2_hsotg *hsotg, hsotg->core_params->dma_enable > 0) { qtd->complete_split = 0; qtd->isoc_split_offset = 0; + qtd->isoc_frame_index++; if (qtd->urb && - ++qtd->isoc_frame_index == qtd->urb->packet_count) { - dwc2_host_complete(hsotg, qtd->urb->priv, - qtd->urb, 0); + qtd->isoc_frame_index == qtd->urb->packet_count) { + dwc2_host_complete(hsotg, qtd, 0); dwc2_release_channel(hsotg, chan, qtd, DWC2_HC_XFER_URB_COMPLETE); } else { @@ -1445,16 +1436,16 @@ static void dwc2_hc_babble_intr(struct dwc2_hsotg *hsotg, dev_dbg(hsotg->dev, "--Host Channel %d Interrupt: Babble Error--\n", chnum); + dwc2_hc_handle_tt_clear(hsotg, chan, qtd); + if (hsotg->core_params->dma_desc_enable > 0) { dwc2_hcd_complete_xfer_ddma(hsotg, chan, chnum, DWC2_HC_XFER_BABBLE_ERR); - goto handle_babble_done; + goto disable_int; } if (chan->ep_type != USB_ENDPOINT_XFER_ISOC) { - if (qtd->urb) - dwc2_host_complete(hsotg, qtd->urb->priv, qtd->urb, - -EOVERFLOW); + dwc2_host_complete(hsotg, qtd, -EOVERFLOW); dwc2_halt_channel(hsotg, chan, qtd, DWC2_HC_XFER_BABBLE_ERR); } else { enum dwc2_halt_status halt_status; @@ -1464,8 +1455,7 @@ static void dwc2_hc_babble_intr(struct dwc2_hsotg *hsotg, dwc2_halt_channel(hsotg, chan, qtd, halt_status); } -handle_babble_done: - dwc2_hc_handle_tt_clear(hsotg, chan, qtd); +disable_int: disable_hc_int(hsotg, chnum, HCINTMSK_BBLERR); } @@ -1490,6 +1480,8 @@ static void dwc2_hc_ahberr_intr(struct dwc2_hsotg *hsotg, if (!urb) goto handle_ahberr_halt; + dwc2_hc_handle_tt_clear(hsotg, chan, qtd); + hcchar = readl(hsotg->regs + HCCHAR(chnum)); hcsplt = readl(hsotg->regs + HCSPLT(chnum)); hctsiz = readl(hsotg->regs + HCTSIZ(chnum)); @@ -1557,7 +1549,7 @@ static void dwc2_hc_ahberr_intr(struct dwc2_hsotg *hsotg, goto handle_ahberr_done; } - dwc2_host_complete(hsotg, urb->priv, urb, -EIO); + dwc2_host_complete(hsotg, qtd, -EIO); handle_ahberr_halt: /* @@ -1567,7 +1559,6 @@ static void dwc2_hc_ahberr_intr(struct dwc2_hsotg *hsotg, dwc2_hc_halt(hsotg, chan, DWC2_HC_XFER_AHB_ERR); handle_ahberr_done: - dwc2_hc_handle_tt_clear(hsotg, chan, qtd); disable_hc_int(hsotg, chnum, HCINTMSK_AHBERR); } @@ -1582,6 +1573,8 @@ static void dwc2_hc_xacterr_intr(struct dwc2_hsotg *hsotg, dev_dbg(hsotg->dev, "--Host Channel %d Interrupt: Transaction Error--\n", chnum); + dwc2_hc_handle_tt_clear(hsotg, chan, qtd); + if (hsotg->core_params->dma_desc_enable > 0) { dwc2_hcd_complete_xfer_ddma(hsotg, chan, chnum, DWC2_HC_XFER_XACT_ERR); @@ -1625,7 +1618,6 @@ static void dwc2_hc_xacterr_intr(struct dwc2_hsotg *hsotg, } handle_xacterr_done: - dwc2_hc_handle_tt_clear(hsotg, chan, qtd); disable_hc_int(hsotg, chnum, HCINTMSK_XACTERR); } @@ -1643,6 +1635,8 @@ static void dwc2_hc_frmovrun_intr(struct dwc2_hsotg *hsotg, dev_dbg(hsotg->dev, "--Host Channel %d Interrupt: Frame Overrun--\n", chnum); + dwc2_hc_handle_tt_clear(hsotg, chan, qtd); + switch (dwc2_hcd_get_pipe_type(&qtd->urb->pipe_info)) { case USB_ENDPOINT_XFER_CONTROL: case USB_ENDPOINT_XFER_BULK: @@ -1657,7 +1651,6 @@ static void dwc2_hc_frmovrun_intr(struct dwc2_hsotg *hsotg, break; } - dwc2_hc_handle_tt_clear(hsotg, chan, qtd); disable_hc_int(hsotg, chnum, HCINTMSK_FRMOVRUN); } -- GitLab From c9e1c907ff520bdc01170a8d6461d262094ed6f8 Mon Sep 17 00:00:00 2001 From: Paul Zimmerman Date: Sat, 13 Jul 2013 14:53:49 -0700 Subject: [PATCH 113/942] staging: dwc2: add calls to usb_hcd_link_urb_to_ep() and friends The driver was lacking calls to usb_hcd_link_urb_to_ep(), usb_hcd_unlink_urb_from_ep(), and usb_hcd_check_unlink_urb(). Add those now. Signed-off-by: Paul Zimmerman Tested-by: Stephen Warren Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dwc2/hcd.c | 52 +++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/drivers/staging/dwc2/hcd.c b/drivers/staging/dwc2/hcd.c index e8fb84f53dd90..d72daf1791485 100644 --- a/drivers/staging/dwc2/hcd.c +++ b/drivers/staging/dwc2/hcd.c @@ -2153,6 +2153,7 @@ void dwc2_host_complete(struct dwc2_hsotg *hsotg, struct dwc2_qtd *qtd, urb); } + usb_hcd_unlink_urb_from_ep(dwc2_hsotg_to_hcd(hsotg), urb); urb->hcpriv = NULL; kfree(qtd->urb); qtd->urb = NULL; @@ -2343,8 +2344,8 @@ static int _dwc2_hcd_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, struct usb_host_endpoint *ep = urb->ep; struct dwc2_hcd_urb *dwc2_urb; int i; + int retval; int alloc_bandwidth = 0; - int retval = 0; u8 ep_type = 0; u32 tflags = 0; void *buf; @@ -2426,21 +2427,36 @@ static int _dwc2_hcd_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, urb->iso_frame_desc[i].length); urb->hcpriv = dwc2_urb; - retval = dwc2_hcd_urb_enqueue(hsotg, dwc2_urb, &ep->hcpriv, - mem_flags); - if (retval) { - urb->hcpriv = NULL; - kfree(dwc2_urb); - } else { - if (alloc_bandwidth) { - spin_lock_irqsave(&hsotg->lock, flags); - dwc2_allocate_bus_bandwidth(hcd, - dwc2_hcd_get_ep_bandwidth(hsotg, ep), - urb); - spin_unlock_irqrestore(&hsotg->lock, flags); - } + + spin_lock_irqsave(&hsotg->lock, flags); + retval = usb_hcd_link_urb_to_ep(hcd, urb); + spin_unlock_irqrestore(&hsotg->lock, flags); + if (retval) + goto fail1; + + retval = dwc2_hcd_urb_enqueue(hsotg, dwc2_urb, &ep->hcpriv, mem_flags); + if (retval) + goto fail2; + + if (alloc_bandwidth) { + spin_lock_irqsave(&hsotg->lock, flags); + dwc2_allocate_bus_bandwidth(hcd, + dwc2_hcd_get_ep_bandwidth(hsotg, ep), + urb); + spin_unlock_irqrestore(&hsotg->lock, flags); } + return 0; + +fail2: + spin_lock_irqsave(&hsotg->lock, flags); + dwc2_urb->priv = NULL; + usb_hcd_unlink_urb_from_ep(hcd, urb); + spin_unlock_irqrestore(&hsotg->lock, flags); +fail1: + urb->hcpriv = NULL; + kfree(dwc2_urb); + return retval; } @@ -2451,7 +2467,7 @@ static int _dwc2_hcd_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) { struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd); - int rc = 0; + int rc; unsigned long flags; dev_dbg(hsotg->dev, "DWC OTG HCD URB Dequeue\n"); @@ -2459,6 +2475,10 @@ static int _dwc2_hcd_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, spin_lock_irqsave(&hsotg->lock, flags); + rc = usb_hcd_check_unlink_urb(hcd, urb, status); + if (rc) + goto out; + if (!urb->hcpriv) { dev_dbg(hsotg->dev, "## urb->hcpriv is NULL ##\n"); goto out; @@ -2466,6 +2486,8 @@ static int _dwc2_hcd_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, rc = dwc2_hcd_urb_dequeue(hsotg, urb->hcpriv); + usb_hcd_unlink_urb_from_ep(hcd, urb); + kfree(urb->hcpriv); urb->hcpriv = NULL; -- GitLab From 399fdf9e57457444bbb5ab33eefa1f8723e9ea05 Mon Sep 17 00:00:00 2001 From: Paul Zimmerman Date: Sat, 13 Jul 2013 14:53:50 -0700 Subject: [PATCH 114/942] staging: dwc2: optimize dwc2_hc_handle_tt_clear() a bit Make dwc2_hc_handle_tt_clear() return early if the device is hi-speed. Signed-off-by: Paul Zimmerman Tested-by: Stephen Warren Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dwc2/hcd_intr.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/staging/dwc2/hcd_intr.c b/drivers/staging/dwc2/hcd_intr.c index 22836f5f7ff66..093a75c3d0db6 100644 --- a/drivers/staging/dwc2/hcd_intr.c +++ b/drivers/staging/dwc2/hcd_intr.c @@ -89,15 +89,20 @@ static void dwc2_hc_handle_tt_clear(struct dwc2_hsotg *hsotg, { struct urb *usb_urb; - if (!chan->qh || !qtd->urb) + if (!chan->qh) + return; + + if (chan->qh->dev_speed == USB_SPEED_HIGH) + return; + + if (!qtd->urb) return; usb_urb = qtd->urb->priv; - if (!usb_urb || !usb_urb->dev) + if (!usb_urb || !usb_urb->dev || !usb_urb->dev->tt) return; - if (chan->qh->dev_speed != USB_SPEED_HIGH && - qtd->urb->status != -EPIPE && qtd->urb->status != -EREMOTEIO) { + if (qtd->urb->status != -EPIPE && qtd->urb->status != -EREMOTEIO) { chan->qh->tt_buffer_dirty = 1; if (usb_hub_clear_tt_buffer(usb_urb)) /* Clear failed; let's hope things work anyway */ -- GitLab From b2d6cb55183b93d65dfc4a71c2706c4e13fa19c5 Mon Sep 17 00:00:00 2001 From: Paul Zimmerman Date: Sat, 13 Jul 2013 14:53:51 -0700 Subject: [PATCH 115/942] staging: dwc2: fix dwc2_hcd_qtd_add() The logic in dwc2_hcd_qtd_add() was a bit messy, and one of the error exit paths was broken. Fix it up. Signed-off-by: Paul Zimmerman Tested-by: Stephen Warren Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dwc2/hcd_queue.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/staging/dwc2/hcd_queue.c b/drivers/staging/dwc2/hcd_queue.c index b36f783dd3e9e..5461e3b86ae94 100644 --- a/drivers/staging/dwc2/hcd_queue.c +++ b/drivers/staging/dwc2/hcd_queue.c @@ -197,6 +197,9 @@ static struct dwc2_qh *dwc2_hcd_qh_create(struct dwc2_hsotg *hsotg, { struct dwc2_qh *qh; + if (!urb->priv) + return NULL; + /* Allocate memory */ qh = kzalloc(sizeof(*qh), mem_flags); if (!qh) @@ -638,7 +641,7 @@ int dwc2_hcd_qtd_add(struct dwc2_hsotg *hsotg, struct dwc2_qtd *qtd, struct dwc2_hcd_urb *urb = qtd->urb; unsigned long flags; int allocated = 0; - int retval = 0; + int retval; /* * Get the QH which holds the QTD-list to insert to. Create QH if it @@ -652,8 +655,19 @@ int dwc2_hcd_qtd_add(struct dwc2_hsotg *hsotg, struct dwc2_qtd *qtd, } spin_lock_irqsave(&hsotg->lock, flags); + retval = dwc2_hcd_qh_add(hsotg, *qh); - if (retval && allocated) { + if (retval) + goto fail; + + qtd->qh = *qh; + list_add_tail(&qtd->qtd_list_entry, &(*qh)->qtd_list); + spin_unlock_irqrestore(&hsotg->lock, flags); + + return 0; + +fail: + if (allocated) { struct dwc2_qtd *qtd2, *qtd2_tmp; struct dwc2_qh *qh_tmp = *qh; @@ -668,8 +682,6 @@ int dwc2_hcd_qtd_add(struct dwc2_hsotg *hsotg, struct dwc2_qtd *qtd, spin_unlock_irqrestore(&hsotg->lock, flags); dwc2_hcd_qh_free(hsotg, qh_tmp); } else { - qtd->qh = *qh; - list_add_tail(&qtd->qtd_list_entry, &(*qh)->qtd_list); spin_unlock_irqrestore(&hsotg->lock, flags); } -- GitLab From 0cf31f8629bf50efe0651ef878a8ddd29a722cac Mon Sep 17 00:00:00 2001 From: Paul Zimmerman Date: Sat, 13 Jul 2013 14:53:52 -0700 Subject: [PATCH 116/942] staging: dwc2: reduce noisy debug messages Change the non-aligned buffer debug messages to dev_vdbg(). Also remove some duplicated debug output when the driver is loaded. Signed-off-by: Paul Zimmerman Tested-by: Stephen Warren Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dwc2/hcd.c | 2 -- drivers/staging/dwc2/hcd_intr.c | 14 +++++++------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/staging/dwc2/hcd.c b/drivers/staging/dwc2/hcd.c index d72daf1791485..26392090e2f8d 100644 --- a/drivers/staging/dwc2/hcd.c +++ b/drivers/staging/dwc2/hcd.c @@ -2950,8 +2950,6 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq, if (retval < 0) goto error3; - dwc2_dump_global_registers(hsotg); - dwc2_dump_host_registers(hsotg); dwc2_hcd_dump_state(hsotg); dwc2_enable_global_interrupts(hsotg); diff --git a/drivers/staging/dwc2/hcd_intr.c b/drivers/staging/dwc2/hcd_intr.c index 093a75c3d0db6..9e68ef1d5998b 100644 --- a/drivers/staging/dwc2/hcd_intr.c +++ b/drivers/staging/dwc2/hcd_intr.c @@ -467,7 +467,7 @@ static int dwc2_update_urb_state(struct dwc2_hsotg *hsotg, /* Non DWORD-aligned buffer case handling */ if (chan->align_buf && xfer_length && chan->ep_is_in) { - dev_dbg(hsotg->dev, "%s(): non-aligned buffer\n", __func__); + dev_vdbg(hsotg->dev, "%s(): non-aligned buffer\n", __func__); dma_sync_single_for_cpu(hsotg->dev, urb->dma, urb->length, DMA_FROM_DEVICE); memcpy(urb->buf + urb->actual_length, chan->qh->dw_align_buf, @@ -562,8 +562,8 @@ static enum dwc2_halt_status dwc2_update_isoc_urb_state( /* Non DWORD-aligned buffer case handling */ if (chan->align_buf && frame_desc->actual_length && chan->ep_is_in) { - dev_dbg(hsotg->dev, "%s(): non-aligned buffer\n", - __func__); + dev_vdbg(hsotg->dev, "%s(): non-aligned buffer\n", + __func__); dma_sync_single_for_cpu(hsotg->dev, urb->dma, urb->length, DMA_FROM_DEVICE); memcpy(urb->buf + frame_desc->offset + @@ -596,8 +596,8 @@ static enum dwc2_halt_status dwc2_update_isoc_urb_state( /* Non DWORD-aligned buffer case handling */ if (chan->align_buf && frame_desc->actual_length && chan->ep_is_in) { - dev_dbg(hsotg->dev, "%s(): non-aligned buffer\n", - __func__); + dev_vdbg(hsotg->dev, "%s(): non-aligned buffer\n", + __func__); dma_sync_single_for_cpu(hsotg->dev, urb->dma, urb->length, DMA_FROM_DEVICE); memcpy(urb->buf + frame_desc->offset + @@ -935,7 +935,7 @@ static int dwc2_xfercomp_isoc_split_in(struct dwc2_hsotg *hsotg, frame_desc->actual_length += len; if (chan->align_buf && len) { - dev_dbg(hsotg->dev, "%s(): non-aligned buffer\n", __func__); + dev_vdbg(hsotg->dev, "%s(): non-aligned buffer\n", __func__); dma_sync_single_for_cpu(hsotg->dev, qtd->urb->dma, qtd->urb->length, DMA_FROM_DEVICE); memcpy(qtd->urb->buf + frame_desc->offset + @@ -1164,7 +1164,7 @@ static void dwc2_update_urb_state_abn(struct dwc2_hsotg *hsotg, /* Non DWORD-aligned buffer case handling */ if (chan->align_buf && xfer_length && chan->ep_is_in) { - dev_dbg(hsotg->dev, "%s(): non-aligned buffer\n", __func__); + dev_vdbg(hsotg->dev, "%s(): non-aligned buffer\n", __func__); dma_sync_single_for_cpu(hsotg->dev, urb->dma, urb->length, DMA_FROM_DEVICE); memcpy(urb->buf + urb->actual_length, chan->qh->dw_align_buf, -- GitLab From 25a494457c2bfc9e1d92be9067e235524fad96ee Mon Sep 17 00:00:00 2001 From: Paul Zimmerman Date: Sat, 13 Jul 2013 14:53:53 -0700 Subject: [PATCH 117/942] staging: dwc2: remove use of bus_to_virt() Remove the use of bus_to_virt() and just fail the transfer if an unaligned buffer with no virtual address is found. AFAIK that can't happen anyway. Also change setting of coherent DMA mask to the normal 32 bits. 31 bits was only needed when calling bus_to_virt() AFAICR. Signed-off-by: Paul Zimmerman Tested-by: Stephen Warren Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dwc2/Kconfig | 1 - drivers/staging/dwc2/hcd.c | 20 ++++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/staging/dwc2/Kconfig b/drivers/staging/dwc2/Kconfig index d15d9d58e5ac2..be947d6738445 100644 --- a/drivers/staging/dwc2/Kconfig +++ b/drivers/staging/dwc2/Kconfig @@ -1,7 +1,6 @@ config USB_DWC2 tristate "DesignWare USB2 DRD Core Support" depends on USB - depends on VIRT_TO_BUS help Say Y or M here if your system has a Dual Role HighSpeed USB controller based on the DesignWare HSOTG IP Core. diff --git a/drivers/staging/dwc2/hcd.c b/drivers/staging/dwc2/hcd.c index 26392090e2f8d..962468f067161 100644 --- a/drivers/staging/dwc2/hcd.c +++ b/drivers/staging/dwc2/hcd.c @@ -2396,14 +2396,15 @@ static int _dwc2_hcd_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, !(usb_pipein(urb->pipe)))); buf = urb->transfer_buffer; + if (hcd->self.uses_dma) { - /* - * Calculate virtual address from physical address, because - * some class driver may not fill transfer_buffer. - * In Buffer DMA mode virtual address is used, when handling - * non-DWORD aligned buffers. - */ - buf = bus_to_virt(urb->transfer_dma); + if (!buf && (urb->transfer_dma & 3)) { + dev_err(hsotg->dev, + "%s: unaligned transfer with no transfer_buffer", + __func__); + retval = -EINVAL; + goto fail1; + } } if (!(urb->transfer_flags & URB_NO_INTERRUPT)) @@ -2833,9 +2834,8 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq, if (hsotg->core_params->dma_enable > 0) { if (dma_set_mask(hsotg->dev, DMA_BIT_MASK(32)) < 0) dev_warn(hsotg->dev, "can't set DMA mask\n"); - if (dma_set_coherent_mask(hsotg->dev, DMA_BIT_MASK(31)) < 0) - dev_warn(hsotg->dev, - "can't enable workaround for >2GB RAM\n"); + if (dma_set_coherent_mask(hsotg->dev, DMA_BIT_MASK(32)) < 0) + dev_warn(hsotg->dev, "can't set coherent DMA mask\n"); } else { dma_set_mask(hsotg->dev, 0); dma_set_coherent_mask(hsotg->dev, 0); -- GitLab From b39ed5c7b480f720d549987c9b3acd0833eafc8e Mon Sep 17 00:00:00 2001 From: Julien Delacou Date: Thu, 11 Jul 2013 14:24:10 +0200 Subject: [PATCH 118/942] staging: dwc2: fix value used in dwc2_set_all_params This fix uses 'value' parameter as it should be instead of hardcoded -1. Signed-off-by: Julien Delacou Acked-by: Paul Zimmerman Reviewed-by: Matthijs Kooijman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dwc2/hcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/dwc2/hcd.c b/drivers/staging/dwc2/hcd.c index 962468f067161..d4ef5f34c2a09 100644 --- a/drivers/staging/dwc2/hcd.c +++ b/drivers/staging/dwc2/hcd.c @@ -2719,7 +2719,7 @@ void dwc2_set_all_params(struct dwc2_core_params *params, int value) int i; for (i = 0; i < size; i++) - p[i] = -1; + p[i] = value; } EXPORT_SYMBOL_GPL(dwc2_set_all_params); -- GitLab From 4d3190e1f84f08692f4b87461108f72e9a0b452c Mon Sep 17 00:00:00 2001 From: Paul Zimmerman Date: Tue, 16 Jul 2013 12:22:12 -0700 Subject: [PATCH 119/942] staging: dwc2: add driver parameter to set AHB config register value The dwc2 driver sets the value of the DWC2 GAHBCFG register to 0x6, which is GAHBCFG_HBSTLEN_INCR4. But different platforms may require different values. In particular, the Broadcom 2835 SOC used in the Raspberry Pi needs a value of 0x10, otherwise the DWC2 controller stops working after a short period of heavy USB traffic. So this patch adds another driver parameter named 'ahbcfg'. The default value is 0x6. Any platform needing a different value should add a DT attribute to set it. This patch also removes the 'ahb_single' driver parameter, since that bit can now be set using 'ahbcfg'. This patch does not add DT support to platform.c, I will leave that to whoever owns the first platform that needs a non-default value. (Stephen?) Signed-off-by: Paul Zimmerman Tested-by: Stephen Warren Reviewed-by: Matthijs Kooijman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dwc2/core.c | 51 ++++++++++--------------------------- drivers/staging/dwc2/core.h | 13 +++++----- drivers/staging/dwc2/hw.h | 4 +++ drivers/staging/dwc2/pci.c | 2 +- 4 files changed, 25 insertions(+), 45 deletions(-) diff --git a/drivers/staging/dwc2/core.c b/drivers/staging/dwc2/core.c index e3a0e770301d5..a090f79bb5f53 100644 --- a/drivers/staging/dwc2/core.c +++ b/drivers/staging/dwc2/core.c @@ -277,7 +277,7 @@ static void dwc2_phy_init(struct dwc2_hsotg *hsotg, bool select_phy) static int dwc2_gahbcfg_init(struct dwc2_hsotg *hsotg) { - u32 ahbcfg = 0; + u32 ahbcfg = readl(hsotg->regs + GAHBCFG); switch (hsotg->hwcfg2 & GHWCFG2_ARCHITECTURE_MASK) { case GHWCFG2_EXT_DMA_ARCH: @@ -286,11 +286,11 @@ static int dwc2_gahbcfg_init(struct dwc2_hsotg *hsotg) case GHWCFG2_INT_DMA_ARCH: dev_dbg(hsotg->dev, "Internal DMA Mode\n"); - /* - * Old value was GAHBCFG_HBSTLEN_INCR - done for - * Host mode ISOC in issue fix - vahrama - */ - ahbcfg |= GAHBCFG_HBSTLEN_INCR4; + if (hsotg->core_params->ahbcfg != -1) { + ahbcfg &= GAHBCFG_CTRL_MASK; + ahbcfg |= hsotg->core_params->ahbcfg & + ~GAHBCFG_CTRL_MASK; + } break; case GHWCFG2_SLAVE_ONLY_ARCH: @@ -313,9 +313,6 @@ static int dwc2_gahbcfg_init(struct dwc2_hsotg *hsotg) hsotg->core_params->dma_desc_enable = 0; } - if (hsotg->core_params->ahb_single > 0) - ahbcfg |= GAHBCFG_AHB_SINGLE; - if (hsotg->core_params->dma_enable > 0) ahbcfg |= GAHBCFG_DMA_EN; @@ -2586,35 +2583,13 @@ int dwc2_set_param_reload_ctl(struct dwc2_hsotg *hsotg, int val) return retval; } -int dwc2_set_param_ahb_single(struct dwc2_hsotg *hsotg, int val) +int dwc2_set_param_ahbcfg(struct dwc2_hsotg *hsotg, int val) { - int valid = 1; - int retval = 0; - - if (DWC2_PARAM_TEST(val, 0, 1)) { - if (val >= 0) { - dev_err(hsotg->dev, - "'%d' invalid for parameter ahb_single\n", val); - dev_err(hsotg->dev, "ahb_single must be 0 or 1\n"); - } - valid = 0; - } - - if (val > 0 && hsotg->snpsid < DWC2_CORE_REV_2_94a) - valid = 0; - - if (!valid) { - if (val >= 0) - dev_err(hsotg->dev, - "%d invalid for parameter ahb_single. Check HW configuration.\n", - val); - val = 0; - dev_dbg(hsotg->dev, "Setting ahb_single to %d\n", val); - retval = -EINVAL; - } - - hsotg->core_params->ahb_single = val; - return retval; + if (val != -1) + hsotg->core_params->ahbcfg = val; + else + hsotg->core_params->ahbcfg = GAHBCFG_HBSTLEN_INCR4; + return 0; } int dwc2_set_param_otg_ver(struct dwc2_hsotg *hsotg, int val) @@ -2681,7 +2656,7 @@ int dwc2_set_parameters(struct dwc2_hsotg *hsotg, retval |= dwc2_set_param_en_multiple_tx_fifo(hsotg, params->en_multiple_tx_fifo); retval |= dwc2_set_param_reload_ctl(hsotg, params->reload_ctl); - retval |= dwc2_set_param_ahb_single(hsotg, params->ahb_single); + retval |= dwc2_set_param_ahbcfg(hsotg, params->ahbcfg); retval |= dwc2_set_param_otg_ver(hsotg, params->otg_ver); return retval; diff --git a/drivers/staging/dwc2/core.h b/drivers/staging/dwc2/core.h index fc075a7c1de5f..e771e405453f6 100644 --- a/drivers/staging/dwc2/core.h +++ b/drivers/staging/dwc2/core.h @@ -150,10 +150,11 @@ enum dwc2_lx_state { * are enabled * @reload_ctl: True to allow dynamic reloading of HFIR register during * runtime - * @ahb_single: This bit enables SINGLE transfers for remainder data in - * a transfer for DMA mode of operation. - * 0 - remainder data will be sent using INCR burst size - * 1 - remainder data will be sent using SINGLE burst size + * @ahbcfg: This field allows the default value of the GAHBCFG + * register to be overridden + * -1 - GAHBCFG value will not be overridden + * all others - GAHBCFG value will be overridden with + * this value * @otg_ver: OTG version supported * 0 - 1.3 * 1 - 2.0 @@ -189,7 +190,7 @@ struct dwc2_core_params { int host_ls_low_power_phy_clk; int ts_dline; int reload_ctl; - int ahb_single; + int ahbcfg; }; /** @@ -643,7 +644,7 @@ extern int dwc2_set_param_en_multiple_tx_fifo(struct dwc2_hsotg *hsotg, extern int dwc2_set_param_reload_ctl(struct dwc2_hsotg *hsotg, int val); -extern int dwc2_set_param_ahb_single(struct dwc2_hsotg *hsotg, int val); +extern int dwc2_set_param_ahbcfg(struct dwc2_hsotg *hsotg, int val); extern int dwc2_set_param_otg_ver(struct dwc2_hsotg *hsotg, int val); diff --git a/drivers/staging/dwc2/hw.h b/drivers/staging/dwc2/hw.h index 382a1d74865d2..cf0dc97d5520e 100644 --- a/drivers/staging/dwc2/hw.h +++ b/drivers/staging/dwc2/hw.h @@ -78,6 +78,10 @@ #define GAHBCFG_HBSTLEN_INCR8 (5 << 1) #define GAHBCFG_HBSTLEN_INCR16 (7 << 1) #define GAHBCFG_GLBL_INTR_EN (1 << 0) +#define GAHBCFG_CTRL_MASK (GAHBCFG_P_TXF_EMP_LVL | \ + GAHBCFG_NP_TXF_EMP_LVL | \ + GAHBCFG_DMA_EN | \ + GAHBCFG_GLBL_INTR_EN) #define GUSBCFG HSOTG_REG(0x00C) #define GUSBCFG_FORCEDEVMODE (1 << 30) diff --git a/drivers/staging/dwc2/pci.c b/drivers/staging/dwc2/pci.c index 3ca54d6782fdc..fdfbc719663c5 100644 --- a/drivers/staging/dwc2/pci.c +++ b/drivers/staging/dwc2/pci.c @@ -83,7 +83,7 @@ static const struct dwc2_core_params dwc2_module_params = { .host_ls_low_power_phy_clk = -1, .ts_dline = -1, .reload_ctl = -1, - .ahb_single = -1, + .ahbcfg = -1, }; /** -- GitLab From a0112f487180bd243aec86b5a8c4b5e2d45e8404 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Fri, 19 Jul 2013 11:34:22 +0200 Subject: [PATCH 120/942] staging: dwc2: disable dma when no dma_mask was setup If the platform or bus driver failed to setup a dma_mask, but the hardware advertises support for DMA, before DMA would be enabled in dwc2, but disabled in the usb core, making all connectivity break. With this commit, the dwc2 driver will emit a warning and fall back to slave mode in this case. Note that since commit 642f2ec (staging: dwc2: Fix dma-enabled platform devices using a default dma_mask) the platform bindings make sure a DMA mask is always present, but having this check here anyway is probably a good from a defensive programming standpoint (in case of changes to platform.c or addition of new glue layers). Signed-off-by: Matthijs Kooijman Acked-by: Paul Zimmerman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dwc2/hcd.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/staging/dwc2/hcd.c b/drivers/staging/dwc2/hcd.c index d4ef5f34c2a09..f77e66333ac76 100644 --- a/drivers/staging/dwc2/hcd.c +++ b/drivers/staging/dwc2/hcd.c @@ -2830,6 +2830,15 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq, /* Validate parameter values */ dwc2_set_parameters(hsotg, params); + /* Check if the bus driver or platform code has setup a dma_mask */ + if (hsotg->core_params->dma_enable > 0 && + hsotg->dev->dma_mask == NULL) { + dev_warn(hsotg->dev, + "dma_mask not set, disabling DMA\n"); + hsotg->core_params->dma_enable = 0; + hsotg->core_params->dma_desc_enable = 0; + } + /* Set device flags indicating whether the HCD supports DMA */ if (hsotg->core_params->dma_enable > 0) { if (dma_set_mask(hsotg->dev, DMA_BIT_MASK(32)) < 0) -- GitLab From 7de76ee118ce013bb17c924515cb45464d8a059b Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Fri, 19 Jul 2013 11:34:23 +0200 Subject: [PATCH 121/942] staging: dwc2: when dma is disabled, clear hcd->self.uses_dma When dma is disabled inside dwc2 (because the hardware does not support it, or the code was changed to disable it for testing), let the usb core know about this by clearing hcd->self.uses_dma. By default, the usb core assumes that dma is used when a dma_mask is set, but this might not always match the dma_enable value in dwc2. To prevent problems resulting from a mismatch, better to explicitely disable dma in this case (though everything seemed to work with the wrong value of uses_dma as well, probably only resulted in some unneeded work). Signed-off-by: Matthijs Kooijman Acked-by: Paul Zimmerman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dwc2/hcd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/staging/dwc2/hcd.c b/drivers/staging/dwc2/hcd.c index f77e66333ac76..fbacf6a9f72ea 100644 --- a/drivers/staging/dwc2/hcd.c +++ b/drivers/staging/dwc2/hcd.c @@ -2854,6 +2854,9 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq, if (!hcd) goto error1; + if (hsotg->core_params->dma_enable <= 0) + hcd->self.uses_dma = 0; + hcd->has_tt = 1; spin_lock_init(&hsotg->lock); -- GitLab From f3ac47cf7910f5b8414c1d8fc247399791a968b8 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 16 Jul 2013 23:13:25 +0300 Subject: [PATCH 122/942] staging: xgifb: delete unused "rateindex" parameters Delete unused "rateindex" parameters from internal functions. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main_26.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index 801ac4053a7aa..015d7bbccf866 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -60,7 +60,7 @@ static inline void dumpVGAReg(void) static int XGIfb_mode_rate_to_dclock(struct vb_device_info *XGI_Pr, struct xgi_hw_device_info *HwDeviceExtension, - unsigned char modeno, unsigned char rateindex) + unsigned char modeno) { unsigned short ModeNo = modeno; unsigned short ModeIdIndex = 0, ClockIndex = 0; @@ -82,7 +82,7 @@ static int XGIfb_mode_rate_to_dclock(struct vb_device_info *XGI_Pr, static int XGIfb_mode_rate_to_ddata(struct vb_device_info *XGI_Pr, struct xgi_hw_device_info *HwDeviceExtension, - unsigned char modeno, unsigned char rateindex, + unsigned char modeno, u32 *left_margin, u32 *right_margin, u32 *upper_margin, u32 *lower_margin, u32 *hsync_len, u32 *vsync_len, u32 *sync, u32 *vmode) @@ -1980,12 +1980,10 @@ static int xgifb_probe(struct pci_dev *pdev, fb_info->var.pixclock = (u32) (1000000000 / XGIfb_mode_rate_to_dclock(&xgifb_info->dev_info, hw_info, - XGIbios_mode[xgifb_info->mode_idx].mode_no, - xgifb_info->rate_idx)); + XGIbios_mode[xgifb_info->mode_idx].mode_no)); if (XGIfb_mode_rate_to_ddata(&xgifb_info->dev_info, hw_info, XGIbios_mode[xgifb_info->mode_idx].mode_no, - xgifb_info->rate_idx, &fb_info->var.left_margin, &fb_info->var.right_margin, &fb_info->var.upper_margin, -- GitLab From 3d05f66f76487536513f461e9f005a11851102ec Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 16 Jul 2013 23:13:26 +0300 Subject: [PATCH 123/942] staging: xgifb: delete unused "ModeNo" parameters Delete unused "ModeNo" parameters from internal functions. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_setmode.c | 241 +++++++++++++---------------- 1 file changed, 107 insertions(+), 134 deletions(-) diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c index fcefe5b36cddb..84cc48612e152 100644 --- a/drivers/staging/xgifb/vb_setmode.c +++ b/drivers/staging/xgifb/vb_setmode.c @@ -63,8 +63,7 @@ void InitTo330Pointer(unsigned char ChipType, struct vb_device_info *pVBInfo) } -static void XGI_SetSeqRegs(unsigned short ModeNo, - unsigned short ModeIdIndex, +static void XGI_SetSeqRegs(unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) { unsigned char SRdata, i; @@ -96,8 +95,7 @@ static void XGI_SetCRTCRegs(struct xgi_hw_device_info *HwDeviceExtension, } } -static void XGI_SetATTRegs(unsigned short ModeNo, - unsigned short ModeIdIndex, +static void XGI_SetATTRegs(unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) { unsigned char ARdata; @@ -171,8 +169,7 @@ static unsigned char XGI_SetDefaultVCLK(struct vb_device_info *pVBInfo) return 0; } -static unsigned char XGI_AjustCRT2Rate(unsigned short ModeNo, - unsigned short ModeIdIndex, +static unsigned char XGI_AjustCRT2Rate(unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, unsigned short *i, struct vb_device_info *pVBInfo) { @@ -322,7 +319,6 @@ static void XGI_SetCRT1Timing_H(struct vb_device_info *pVBInfo, } static void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex, - unsigned short ModeNo, struct vb_device_info *pVBInfo) { unsigned char data; @@ -365,7 +361,7 @@ static void XGI_SetCRT1Timing_V(unsigned short ModeIdIndex, xgifb_reg_set(pVBInfo->P3d4, 0x09, data); } -static void XGI_SetCRT1CRTC(unsigned short ModeNo, unsigned short ModeIdIndex, +static void XGI_SetCRT1CRTC(unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo, struct xgi_hw_device_info *HwDeviceExtension) @@ -391,7 +387,7 @@ static void XGI_SetCRT1CRTC(unsigned short ModeNo, unsigned short ModeIdIndex, XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension); - XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo); + XGI_SetCRT1Timing_V(ModeIdIndex, pVBInfo); if (pVBInfo->ModeType > 0x03) xgifb_reg_set(pVBInfo->P3d4, 0x14, 0x4F); @@ -403,7 +399,7 @@ static void XGI_SetCRT1CRTC(unsigned short ModeNo, unsigned short ModeIdIndex, /* Output : Fill CRT Hsync/Vsync to SR2E/SR2F/SR30/SR33/SR34/SR3F */ /* Description : Set LCD timing */ /* --------------------------------------------------------------------- */ -static void XGI_SetXG21CRTC(unsigned short ModeNo, unsigned short ModeIdIndex, +static void XGI_SetXG21CRTC(unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo) { @@ -500,8 +496,7 @@ static void XGI_SetXG21CRTC(unsigned short ModeNo, unsigned short ModeIdIndex, xgifb_reg_set(pVBInfo->P3c4, 0x3F, Tempax); } -static void XGI_SetXG27CRTC(unsigned short ModeNo, - unsigned short ModeIdIndex, +static void XGI_SetXG27CRTC(unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo) { @@ -605,8 +600,7 @@ static void XGI_SetXG27FPBits(struct vb_device_info *pVBInfo) static void xgifb_set_lcd(int chip_id, struct vb_device_info *pVBInfo, - unsigned short RefreshRateTableIndex, - unsigned short ModeNo) + unsigned short RefreshRateTableIndex) { unsigned short temp; @@ -688,7 +682,7 @@ static void XGI_UpdateXG21CRTC(unsigned short ModeNo, } static void XGI_SetCRT1DE(struct xgi_hw_device_info *HwDeviceExtension, - unsigned short ModeNo, unsigned short ModeIdIndex, + unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo) { @@ -834,8 +828,7 @@ static void XGI_SetCRT1Offset(unsigned short ModeNo, xgifb_reg_set(pVBInfo->P3c4, 0x10, ah); } -static unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo, - unsigned short ModeIdIndex, +static unsigned short XGI_GetVCLK2Ptr(unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo) @@ -886,8 +879,7 @@ static unsigned short XGI_GetVCLK2Ptr(unsigned short ModeNo, return VCLKIndex; } -static void XGI_SetCRT1VCLK(unsigned short ModeNo, - unsigned short ModeIdIndex, +static void XGI_SetCRT1VCLK(unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo) @@ -899,9 +891,8 @@ static void XGI_SetCRT1VCLK(unsigned short ModeNo, (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B | VB_SIS301LV | VB_SIS302LV | VB_XGI301C)) && (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) { - vclkindex = XGI_GetVCLK2Ptr(ModeNo, ModeIdIndex, - RefreshRateTableIndex, HwDeviceExtension, - pVBInfo); + vclkindex = XGI_GetVCLK2Ptr(ModeIdIndex, RefreshRateTableIndex, + HwDeviceExtension, pVBInfo); data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF; xgifb_reg_set(pVBInfo->P3c4, 0x31, data); data = XGI_VBVCLKData[vclkindex].Part4_A; @@ -948,9 +939,8 @@ static void XGI_SetXG21FPBits(struct vb_device_info *pVBInfo) } -static void XGI_SetCRT1FIFO(unsigned short ModeNo, - struct xgi_hw_device_info *HwDeviceExtension, - struct vb_device_info *pVBInfo) +static void XGI_SetCRT1FIFO(struct xgi_hw_device_info *HwDeviceExtension, + struct vb_device_info *pVBInfo) { unsigned short data; @@ -971,7 +961,7 @@ static void XGI_SetCRT1FIFO(unsigned short ModeNo, } static void XGI_SetVCLKState(struct xgi_hw_device_info *HwDeviceExtension, - unsigned short ModeNo, unsigned short RefreshRateTableIndex, + unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo) { unsigned short data, data2 = 0; @@ -1010,7 +1000,7 @@ static void XGI_SetVCLKState(struct xgi_hw_device_info *HwDeviceExtension, } static void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info *HwDeviceExtension, - unsigned short ModeNo, unsigned short ModeIdIndex, + unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo) { @@ -1063,8 +1053,7 @@ static void XGI_SetCRT1ModeRegs(struct xgi_hw_device_info *HwDeviceExtension, data = data ^ 0xA0; xgifb_reg_and_or(pVBInfo->P3c4, 0x21, 0x1F, data); - XGI_SetVCLKState(HwDeviceExtension, ModeNo, RefreshRateTableIndex, - pVBInfo); + XGI_SetVCLKState(HwDeviceExtension, RefreshRateTableIndex, pVBInfo); data = xgifb_reg_get(pVBInfo->P3d4, 0x31); @@ -1122,7 +1111,7 @@ static void XGI_WriteDAC(unsigned short dl, outb((unsigned short) bl, pVBInfo->P3c9); } -static void XGI_LoadDAC(unsigned short ModeNo, unsigned short ModeIdIndex, +static void XGI_LoadDAC(unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) { unsigned short data, data2, i, k, m, n, o, si, di, bx, dl, al, ah, dh; @@ -1188,8 +1177,7 @@ static void XGI_LoadDAC(unsigned short ModeNo, unsigned short ModeIdIndex, } } -static void XGI_GetLVDSResInfo(unsigned short ModeNo, - unsigned short ModeIdIndex, +static void XGI_GetLVDSResInfo(unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) { unsigned short resindex, xres, yres, modeflag; @@ -1219,7 +1207,6 @@ static void XGI_GetLVDSResInfo(unsigned short ModeNo, } static void const *XGI_GetLcdPtr(struct XGI330_LCDDataTablStruct const *table, - unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo) @@ -1259,8 +1246,7 @@ static void const *XGI_GetLcdPtr(struct XGI330_LCDDataTablStruct const *table, return table[i].DATAPTR; } -static struct SiS_TVData const *XGI_GetTVPtr(unsigned short ModeNo, - unsigned short ModeIdIndex, +static struct SiS_TVData const *XGI_GetTVPtr(unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo) { @@ -1289,7 +1275,7 @@ static struct SiS_TVData const *XGI_GetTVPtr(unsigned short ModeNo, return &XGI_TVDataTable[i].DATAPTR[tempal]; } -static void XGI_GetLVDSData(unsigned short ModeNo, unsigned short ModeIdIndex, +static void XGI_GetLVDSData(unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo) { @@ -1298,7 +1284,7 @@ static void XGI_GetLVDSData(unsigned short ModeNo, unsigned short ModeIdIndex, if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))) return; - LCDPtr = XGI_GetLcdPtr(XGI_EPLLCDDataPtr, ModeNo, ModeIdIndex, + LCDPtr = XGI_GetLcdPtr(XGI_EPLLCDDataPtr, ModeIdIndex, RefreshRateTableIndex, pVBInfo); pVBInfo->VGAHT = LCDPtr->VGAHT; pVBInfo->VGAVT = LCDPtr->VGAVT; @@ -1325,7 +1311,7 @@ static void XGI_GetLVDSData(unsigned short ModeNo, unsigned short ModeIdIndex, } } -static void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex, +static void XGI_ModCRT1Regs(unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo) @@ -1335,7 +1321,7 @@ static void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex, struct XGI_LVDSCRT1VDataStruct const *LCDPtr1 = NULL; if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { - LCDPtr = XGI_GetLcdPtr(xgifb_epllcd_crt1_h, ModeNo, ModeIdIndex, + LCDPtr = XGI_GetLcdPtr(xgifb_epllcd_crt1_h, ModeIdIndex, RefreshRateTableIndex, pVBInfo); for (i = 0; i < 8; i++) @@ -1345,14 +1331,13 @@ static void XGI_ModCRT1Regs(unsigned short ModeNo, unsigned short ModeIdIndex, XGI_SetCRT1Timing_H(pVBInfo, HwDeviceExtension); if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { - LCDPtr1 = XGI_GetLcdPtr(xgifb_epllcd_crt1_v, ModeNo, - ModeIdIndex, RefreshRateTableIndex, - pVBInfo); + LCDPtr1 = XGI_GetLcdPtr(xgifb_epllcd_crt1_v, ModeIdIndex, + RefreshRateTableIndex, pVBInfo); for (i = 0; i < 7; i++) pVBInfo->TimingV.data[i] = LCDPtr1[0].Reg[i]; } - XGI_SetCRT1Timing_V(ModeIdIndex, ModeNo, pVBInfo); + XGI_SetCRT1Timing_V(ModeIdIndex, pVBInfo); } static unsigned short XGI_GetLCDCapPtr(struct vb_device_info *pVBInfo) @@ -1425,7 +1410,7 @@ static void XGI_GetLCDSync(unsigned short *HSyncWidth, *VSyncWidth = pVBInfo->LCDCapList[Index].LCD_VSyncWidth; } -static void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex, +static void XGI_SetLVDSRegs(unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo) { @@ -1434,8 +1419,8 @@ static void XGI_SetLVDSRegs(unsigned short ModeNo, unsigned short ModeIdIndex, struct XGI330_LCDDataDesStruct2 const *LCDPtr1 = NULL; modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - LCDPtr1 = XGI_GetLcdPtr(XGI_EPLLCDDesDataPtr, ModeNo, ModeIdIndex, - RefreshRateTableIndex, pVBInfo); + LCDPtr1 = XGI_GetLcdPtr(XGI_EPLLCDDesDataPtr, ModeIdIndex, + RefreshRateTableIndex, pVBInfo); XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); push1 = tempbx; @@ -1686,8 +1671,7 @@ static void XGI_GetLCDVCLKPtr(unsigned char *di_0, unsigned char *di_1, } static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex, - unsigned short ModeNo, unsigned short ModeIdIndex, - struct vb_device_info *pVBInfo) + unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) { unsigned short index, modeflag; @@ -1769,15 +1753,14 @@ static void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0, } } -static void XGI_SetCRT2ECLK(unsigned short ModeNo, unsigned short ModeIdIndex, +static void XGI_SetCRT2ECLK(unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo) { unsigned char di_0, di_1, tempal; int i; - tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex, - pVBInfo); + tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeIdIndex, pVBInfo); XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo); XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo); @@ -1922,7 +1905,7 @@ void XGI_GetVBType(struct vb_device_info *pVBInfo) pVBInfo->VBType = tempbx; } -static void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex, +static void XGI_GetVBInfo(unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo) { @@ -2048,7 +2031,7 @@ static void XGI_GetVBInfo(unsigned short ModeNo, unsigned short ModeIdIndex, pVBInfo->VBInfo = tempbx; } -static void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex, +static void XGI_GetTVInfo(unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) { unsigned short tempbx = 0, resinfo = 0, modeflag, index1; @@ -2115,8 +2098,8 @@ static void XGI_GetTVInfo(unsigned short ModeNo, unsigned short ModeIdIndex, pVBInfo->TVInfo = tempbx; } -static unsigned char XGI_GetLCDInfo(unsigned short ModeNo, - unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) +static unsigned char XGI_GetLCDInfo(unsigned short ModeIdIndex, + struct vb_device_info *pVBInfo) { unsigned short temp, tempax, tempbx, resinfo = 0, LCDIdIndex; @@ -2435,8 +2418,7 @@ static void XGI_SaveCRT2Info(unsigned short ModeNo, xgifb_reg_and_or(pVBInfo->P3d4, 0x31, temp2, temp1); } -static void XGI_GetCRT2ResInfo(unsigned short ModeNo, - unsigned short ModeIdIndex, +static void XGI_GetCRT2ResInfo(unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) { unsigned short xres, yres, modeflag, resindex; @@ -2508,8 +2490,7 @@ static unsigned char XGI_IsLCDDualLink(struct vb_device_info *pVBInfo) return 0; } -static void XGI_GetRAMDAC2DATA(unsigned short ModeNo, - unsigned short ModeIdIndex, +static void XGI_GetRAMDAC2DATA(unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo) { @@ -2551,7 +2532,7 @@ static void XGI_GetRAMDAC2DATA(unsigned short ModeNo, pVBInfo->VT = tempbx; } -static void XGI_GetCRT2Data(unsigned short ModeNo, unsigned short ModeIdIndex, +static void XGI_GetCRT2Data(unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo) { @@ -2566,13 +2547,12 @@ static void XGI_GetCRT2Data(unsigned short ModeNo, unsigned short ModeIdIndex, pVBInfo->RVBHRS = 50; if (pVBInfo->VBInfo & SetCRT2ToRAMDAC) { - XGI_GetRAMDAC2DATA(ModeNo, ModeIdIndex, RefreshRateTableIndex, - pVBInfo); + XGI_GetRAMDAC2DATA(ModeIdIndex, RefreshRateTableIndex, pVBInfo); return; } if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { - LCDPtr = XGI_GetLcdPtr(XGI_LCDDataTable, ModeNo, ModeIdIndex, + LCDPtr = XGI_GetLcdPtr(XGI_LCDDataTable, ModeIdIndex, RefreshRateTableIndex, pVBInfo); pVBInfo->RVBHCMAX = LCDPtr->RVBHCMAX; @@ -2654,7 +2634,7 @@ static void XGI_GetCRT2Data(unsigned short ModeNo, unsigned short ModeIdIndex, if (pVBInfo->VBInfo & (SetCRT2ToTV)) { struct SiS_TVData const *TVPtr; - TVPtr = XGI_GetTVPtr(ModeNo, ModeIdIndex, RefreshRateTableIndex, + TVPtr = XGI_GetTVPtr(ModeIdIndex, RefreshRateTableIndex, pVBInfo); pVBInfo->RVBHCMAX = TVPtr->RVBHCMAX; @@ -2722,14 +2702,13 @@ static void XGI_GetCRT2Data(unsigned short ModeNo, unsigned short ModeIdIndex, } } -static void XGI_SetCRT2VCLK(unsigned short ModeNo, unsigned short ModeIdIndex, +static void XGI_SetCRT2VCLK(unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo) { unsigned char di_0, di_1, tempal; - tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeNo, ModeIdIndex, - pVBInfo); + tempal = XGI_GetVCLKPtr(RefreshRateTableIndex, ModeIdIndex, pVBInfo); XGI_GetVCLKLen(tempal, &di_0, &di_1, pVBInfo); XGI_GetLCDVCLKPtr(&di_0, &di_1, pVBInfo); @@ -2751,8 +2730,8 @@ static void XGI_SetCRT2VCLK(unsigned short ModeNo, unsigned short ModeIdIndex, xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x08); } -static unsigned short XGI_GetColorDepth(unsigned short ModeNo, - unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) +static unsigned short XGI_GetColorDepth(unsigned short ModeIdIndex, + struct vb_device_info *pVBInfo) { unsigned short ColorDepth[6] = { 1, 2, 4, 4, 6, 8 }; short index; @@ -2786,7 +2765,7 @@ static unsigned short XGI_GetOffset(unsigned short ModeNo, if (infoflag & InterlaceMode) temp = temp << 1; - colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex, pVBInfo); + colordepth = XGI_GetColorDepth(ModeIdIndex, pVBInfo); if ((ModeNo >= 0x7C) && (ModeNo <= 0x7E)) { temp = ModeNo - 0x7C; @@ -2846,7 +2825,7 @@ static void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex, xgifb_reg_set(pVBInfo->Part1Port, 0x02, 0x44); /* temp 0206 */ } -static void XGI_SetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex, +static void XGI_SetGroup1(unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo) @@ -3724,7 +3703,7 @@ static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex, } } -static void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex, +static void XGI_SetLCDRegs(unsigned short ModeIdIndex, struct xgi_hw_device_info *HwDeviceExtension, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo) @@ -3772,12 +3751,11 @@ static void XGI_SetLCDRegs(unsigned short ModeNo, unsigned short ModeIdIndex, /* Customized LCDB Does not add */ if ((pVBInfo->VBType & VB_SIS301LV) || (pVBInfo->VBType & VB_SIS302LV)) - LCDBDesPtr = XGI_GetLcdPtr(xgifb_lcddldes, ModeNo, ModeIdIndex, + LCDBDesPtr = XGI_GetLcdPtr(xgifb_lcddldes, ModeIdIndex, RefreshRateTableIndex, pVBInfo); else - LCDBDesPtr = XGI_GetLcdPtr(XGI_LCDDesDataTable, ModeNo, - ModeIdIndex, RefreshRateTableIndex, - pVBInfo); + LCDBDesPtr = XGI_GetLcdPtr(XGI_LCDDesDataTable, ModeIdIndex, + RefreshRateTableIndex, pVBInfo); tempah = pVBInfo->LCDResInfo; tempah &= PanelResInfo; @@ -4003,8 +3981,8 @@ static void XGI_SetTap4Regs(struct vb_device_info *pVBInfo) xgifb_reg_and_or(pVBInfo->Part2Port, 0x4E, ~0x14, 0x10); } -static void XGI_SetGroup3(unsigned short ModeNo, unsigned short ModeIdIndex, - struct vb_device_info *pVBInfo) +static void XGI_SetGroup3(unsigned short ModeIdIndex, + struct vb_device_info *pVBInfo) { unsigned short i; unsigned char const *tempdi; @@ -4059,7 +4037,7 @@ static void XGI_SetGroup3(unsigned short ModeNo, unsigned short ModeIdIndex, } } -static void XGI_SetGroup4(unsigned short ModeNo, unsigned short ModeIdIndex, +static void XGI_SetGroup4(unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo) @@ -4224,7 +4202,7 @@ static void XGI_SetGroup4(unsigned short ModeNo, unsigned short ModeIdIndex, } /* end 301b */ - XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); + XGI_SetCRT2VCLK(ModeIdIndex, RefreshRateTableIndex, pVBInfo); } static void XGINew_EnableCRT2(struct vb_device_info *pVBInfo) @@ -4232,8 +4210,8 @@ static void XGINew_EnableCRT2(struct vb_device_info *pVBInfo) xgifb_reg_and_or(pVBInfo->P3c4, 0x1E, 0xFF, 0x20); } -static void XGI_SetGroup5(unsigned short ModeNo, unsigned short ModeIdIndex, - struct vb_device_info *pVBInfo) +static void XGI_SetGroup5(unsigned short ModeIdIndex, + struct vb_device_info *pVBInfo) { if (pVBInfo->ModeType == ModeVGA) { if (!(pVBInfo->VBInfo & (SetInSlaveMode | LoadDACFlag @@ -4281,7 +4259,7 @@ static unsigned char XGI_XG21CheckLVDSMode(struct xgifb_video_info *xgifb_info, if (xres != xgifb_info->lvds_data.LVDSHDE || yres != xgifb_info->lvds_data.LVDSVDE) { - colordepth = XGI_GetColorDepth(ModeNo, ModeIdIndex, pVBInfo); + colordepth = XGI_GetColorDepth(ModeIdIndex, pVBInfo); if (colordepth > 2) return 0; } @@ -4290,7 +4268,6 @@ static unsigned char XGI_XG21CheckLVDSMode(struct xgifb_video_info *xgifb_info, static void xgifb_set_lvds(struct xgifb_video_info *xgifb_info, int chip_id, - unsigned short ModeNo, unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) { @@ -4831,8 +4808,7 @@ static void XGI_SetLCDCap(struct vb_device_info *pVBInfo) /* Output : */ /* Description : Set TV Customized Param. */ /* --------------------------------------------------------------------- */ -static void XGI_SetAntiFlicker(unsigned short ModeNo, - unsigned short ModeIdIndex, +static void XGI_SetAntiFlicker(unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) { unsigned short tempbx; @@ -4850,8 +4826,7 @@ static void XGI_SetAntiFlicker(unsigned short ModeNo, xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0x8F, tempah); } -static void XGI_SetEdgeEnhance(unsigned short ModeNo, - unsigned short ModeIdIndex, +static void XGI_SetEdgeEnhance(unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) { unsigned short tempbx; @@ -4887,8 +4862,8 @@ static void XGI_SetPhaseIncr(struct vb_device_info *pVBInfo) & 0xFF000000) >> 24)); } -static void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex, - struct vb_device_info *pVBInfo) +static void XGI_SetYFilter(unsigned short ModeIdIndex, + struct vb_device_info *pVBInfo) { unsigned short tempbx, index; unsigned char const *filterPtr; @@ -4957,8 +4932,7 @@ static void XGI_SetYFilter(unsigned short ModeNo, unsigned short ModeIdIndex, /* Output : */ /* Description : Customized Param. for 301 */ /* --------------------------------------------------------------------- */ -static void XGI_OEM310Setting(unsigned short ModeNo, - unsigned short ModeIdIndex, +static void XGI_OEM310Setting(unsigned short ModeIdIndex, struct vb_device_info *pVBInfo) { XGI_SetDelayComp(pVBInfo); @@ -4968,11 +4942,11 @@ static void XGI_OEM310Setting(unsigned short ModeNo, if (pVBInfo->VBInfo & SetCRT2ToTV) { XGI_SetPhaseIncr(pVBInfo); - XGI_SetYFilter(ModeNo, ModeIdIndex, pVBInfo); - XGI_SetAntiFlicker(ModeNo, ModeIdIndex, pVBInfo); + XGI_SetYFilter(ModeIdIndex, pVBInfo); + XGI_SetAntiFlicker(ModeIdIndex, pVBInfo); if (pVBInfo->VBType & VB_SIS301) - XGI_SetEdgeEnhance(ModeNo, ModeIdIndex, pVBInfo); + XGI_SetEdgeEnhance(ModeIdIndex, pVBInfo); } } @@ -4982,8 +4956,7 @@ static void XGI_OEM310Setting(unsigned short ModeNo, /* Output : */ /* Description : Origin code for crt2group */ /* --------------------------------------------------------------------- */ -static void XGI_SetCRT2ModeRegs(unsigned short ModeNo, - struct xgi_hw_device_info *HwDeviceExtension, +static void XGI_SetCRT2ModeRegs(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo) { unsigned short tempbl; @@ -5231,8 +5204,8 @@ unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE, } i--; if ((pVBInfo->SetFlag & ProgrammingCRT2)) { - temp = XGI_AjustCRT2Rate(ModeNo, ModeIdIndex, - RefreshRateTableIndex, &i, pVBInfo); + temp = XGI_AjustCRT2Rate(ModeIdIndex, RefreshRateTableIndex, + &i, pVBInfo); } return RefreshRateTableIndex + i; } @@ -5246,12 +5219,12 @@ static void XGI_SetLCDAGroup(unsigned short ModeNo, unsigned short ModeIdIndex, pVBInfo->SetFlag |= ProgrammingCRT2; RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo, ModeIdIndex, pVBInfo); - XGI_GetLVDSResInfo(ModeNo, ModeIdIndex, pVBInfo); - XGI_GetLVDSData(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); - XGI_ModCRT1Regs(ModeNo, ModeIdIndex, RefreshRateTableIndex, - HwDeviceExtension, pVBInfo); - XGI_SetLVDSRegs(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); - XGI_SetCRT2ECLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); + XGI_GetLVDSResInfo(ModeIdIndex, pVBInfo); + XGI_GetLVDSData(ModeIdIndex, RefreshRateTableIndex, pVBInfo); + XGI_ModCRT1Regs(ModeIdIndex, RefreshRateTableIndex, HwDeviceExtension, + pVBInfo); + XGI_SetLVDSRegs(ModeIdIndex, RefreshRateTableIndex, pVBInfo); + XGI_SetCRT2ECLK(ModeIdIndex, RefreshRateTableIndex, pVBInfo); } static unsigned char XGI_SetCRT2Group301(unsigned short ModeNo, @@ -5266,24 +5239,24 @@ static unsigned char XGI_SetCRT2Group301(unsigned short ModeNo, RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo, ModeIdIndex, pVBInfo); XGI_SaveCRT2Info(ModeNo, pVBInfo); - XGI_GetCRT2ResInfo(ModeNo, ModeIdIndex, pVBInfo); - XGI_GetCRT2Data(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); + XGI_GetCRT2ResInfo(ModeIdIndex, pVBInfo); + XGI_GetCRT2Data(ModeIdIndex, RefreshRateTableIndex, pVBInfo); XGI_PreSetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension, RefreshRateTableIndex, pVBInfo); - XGI_SetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension, - RefreshRateTableIndex, pVBInfo); + XGI_SetGroup1(ModeIdIndex, HwDeviceExtension, RefreshRateTableIndex, + pVBInfo); XGI_SetLockRegs(ModeNo, ModeIdIndex, HwDeviceExtension, RefreshRateTableIndex, pVBInfo); XGI_SetGroup2(ModeNo, ModeIdIndex, RefreshRateTableIndex, HwDeviceExtension, pVBInfo); - XGI_SetLCDRegs(ModeNo, ModeIdIndex, HwDeviceExtension, - RefreshRateTableIndex, pVBInfo); + XGI_SetLCDRegs(ModeIdIndex, HwDeviceExtension, RefreshRateTableIndex, + pVBInfo); XGI_SetTap4Regs(pVBInfo); - XGI_SetGroup3(ModeNo, ModeIdIndex, pVBInfo); - XGI_SetGroup4(ModeNo, ModeIdIndex, RefreshRateTableIndex, - HwDeviceExtension, pVBInfo); - XGI_SetCRT2VCLK(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); - XGI_SetGroup5(ModeNo, ModeIdIndex, pVBInfo); + XGI_SetGroup3(ModeIdIndex, pVBInfo); + XGI_SetGroup4(ModeIdIndex, RefreshRateTableIndex, HwDeviceExtension, + pVBInfo); + XGI_SetCRT2VCLK(ModeIdIndex, RefreshRateTableIndex, pVBInfo); + XGI_SetGroup5(ModeIdIndex, pVBInfo); XGI_AutoThreshold(pVBInfo); return 1; } @@ -5467,10 +5440,10 @@ static void XGI_SetCRT1Group(struct xgifb_video_info *xgifb_info, { unsigned short RefreshRateTableIndex, temp; - XGI_SetSeqRegs(ModeNo, ModeIdIndex, pVBInfo); + XGI_SetSeqRegs(ModeIdIndex, pVBInfo); outb(XGI330_StandTable.MISC, pVBInfo->P3c2); XGI_SetCRTCRegs(HwDeviceExtension, pVBInfo); - XGI_SetATTRegs(ModeNo, ModeIdIndex, pVBInfo); + XGI_SetATTRegs(ModeIdIndex, pVBInfo); XGI_SetGRCRegs(pVBInfo); XGI_ClearExt1Regs(pVBInfo); @@ -5495,13 +5468,13 @@ static void XGI_SetCRT1Group(struct xgifb_video_info *xgifb_info, ModeIdIndex, pVBInfo); if (RefreshRateTableIndex != 0xFFFF) { XGI_SetSync(RefreshRateTableIndex, pVBInfo); - XGI_SetCRT1CRTC(ModeNo, ModeIdIndex, RefreshRateTableIndex, + XGI_SetCRT1CRTC(ModeIdIndex, RefreshRateTableIndex, pVBInfo, HwDeviceExtension); - XGI_SetCRT1DE(HwDeviceExtension, ModeNo, ModeIdIndex, + XGI_SetCRT1DE(HwDeviceExtension, ModeIdIndex, RefreshRateTableIndex, pVBInfo); XGI_SetCRT1Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex, HwDeviceExtension, pVBInfo); - XGI_SetCRT1VCLK(ModeNo, ModeIdIndex, HwDeviceExtension, + XGI_SetCRT1VCLK(ModeIdIndex, HwDeviceExtension, RefreshRateTableIndex, pVBInfo); } @@ -5510,30 +5483,30 @@ static void XGI_SetCRT1Group(struct xgifb_video_info *xgifb_info, if (temp & 0xA0) { if (HwDeviceExtension->jChipType == XG27) - XGI_SetXG27CRTC(ModeNo, ModeIdIndex, + XGI_SetXG27CRTC(ModeIdIndex, RefreshRateTableIndex, pVBInfo); else - XGI_SetXG21CRTC(ModeNo, ModeIdIndex, + XGI_SetXG21CRTC(ModeIdIndex, RefreshRateTableIndex, pVBInfo); XGI_UpdateXG21CRTC(ModeNo, pVBInfo, RefreshRateTableIndex); xgifb_set_lcd(HwDeviceExtension->jChipType, - pVBInfo, RefreshRateTableIndex, ModeNo); + pVBInfo, RefreshRateTableIndex); if (pVBInfo->IF_DEF_LVDS == 1) xgifb_set_lvds(xgifb_info, HwDeviceExtension->jChipType, - ModeNo, ModeIdIndex, pVBInfo); + ModeIdIndex, pVBInfo); } } pVBInfo->SetFlag &= (~ProgrammingCRT2); - XGI_SetCRT1FIFO(ModeNo, HwDeviceExtension, pVBInfo); - XGI_SetCRT1ModeRegs(HwDeviceExtension, ModeNo, ModeIdIndex, - RefreshRateTableIndex, pVBInfo); - XGI_LoadDAC(ModeNo, ModeIdIndex, pVBInfo); + XGI_SetCRT1FIFO(HwDeviceExtension, pVBInfo); + XGI_SetCRT1ModeRegs(HwDeviceExtension, ModeIdIndex, + RefreshRateTableIndex, pVBInfo); + XGI_LoadDAC(ModeIdIndex, pVBInfo); } unsigned char XGISetModeNew(struct xgifb_video_info *xgifb_info, @@ -5573,9 +5546,9 @@ unsigned char XGISetModeNew(struct xgifb_video_info *xgifb_info, XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo); if (HwDeviceExtension->jChipType < XG20) { - XGI_GetVBInfo(ModeNo, ModeIdIndex, HwDeviceExtension, pVBInfo); - XGI_GetTVInfo(ModeNo, ModeIdIndex, pVBInfo); - XGI_GetLCDInfo(ModeNo, ModeIdIndex, pVBInfo); + XGI_GetVBInfo(ModeIdIndex, HwDeviceExtension, pVBInfo); + XGI_GetTVInfo(ModeIdIndex, pVBInfo); + XGI_GetLCDInfo(ModeIdIndex, pVBInfo); XGI_DisableBridge(xgifb_info, HwDeviceExtension, pVBInfo); if (pVBInfo->VBInfo & (SetSimuScanMode | XGI_SetCRT2ToLCDA) || @@ -5602,8 +5575,8 @@ unsigned char XGISetModeNew(struct xgifb_video_info *xgifb_info, } } - XGI_SetCRT2ModeRegs(ModeNo, HwDeviceExtension, pVBInfo); - XGI_OEM310Setting(ModeNo, ModeIdIndex, pVBInfo); /*0212*/ + XGI_SetCRT2ModeRegs(HwDeviceExtension, pVBInfo); + XGI_OEM310Setting(ModeIdIndex, pVBInfo); /*0212*/ XGI_EnableBridge(xgifb_info, HwDeviceExtension, pVBInfo); } /* !XG20 */ else { -- GitLab From 6b6e6a3995435d2cf8c8c30dbfc75953ead64c35 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 16 Jul 2013 23:13:27 +0300 Subject: [PATCH 124/942] staging: xgifb: delete unused "ModeIdIndex" parameters Delete unused "ModeIdIndex" parameters from internal functions. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_setmode.c | 37 +++++++++++------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c index 84cc48612e152..36be17bfa5a86 100644 --- a/drivers/staging/xgifb/vb_setmode.c +++ b/drivers/staging/xgifb/vb_setmode.c @@ -63,8 +63,7 @@ void InitTo330Pointer(unsigned char ChipType, struct vb_device_info *pVBInfo) } -static void XGI_SetSeqRegs(unsigned short ModeIdIndex, - struct vb_device_info *pVBInfo) +static void XGI_SetSeqRegs(struct vb_device_info *pVBInfo) { unsigned char SRdata, i; @@ -399,8 +398,7 @@ static void XGI_SetCRT1CRTC(unsigned short ModeIdIndex, /* Output : Fill CRT Hsync/Vsync to SR2E/SR2F/SR30/SR33/SR34/SR3F */ /* Description : Set LCD timing */ /* --------------------------------------------------------------------- */ -static void XGI_SetXG21CRTC(unsigned short ModeIdIndex, - unsigned short RefreshRateTableIndex, +static void XGI_SetXG21CRTC(unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo) { unsigned char index, Tempax, Tempbx, Tempcx, Tempdx; @@ -496,8 +494,7 @@ static void XGI_SetXG21CRTC(unsigned short ModeIdIndex, xgifb_reg_set(pVBInfo->P3c4, 0x3F, Tempax); } -static void XGI_SetXG27CRTC(unsigned short ModeIdIndex, - unsigned short RefreshRateTableIndex, +static void XGI_SetXG27CRTC(unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo) { unsigned short index, Tempax, Tempbx, Tempcx; @@ -1111,8 +1108,7 @@ static void XGI_WriteDAC(unsigned short dl, outb((unsigned short) bl, pVBInfo->P3c9); } -static void XGI_LoadDAC(unsigned short ModeIdIndex, - struct vb_device_info *pVBInfo) +static void XGI_LoadDAC(struct vb_device_info *pVBInfo) { unsigned short data, data2, i, k, m, n, o, si, di, bx, dl, al, ah, dh; const unsigned short *table = XGINew_VGA_DAC; @@ -4210,8 +4206,7 @@ static void XGINew_EnableCRT2(struct vb_device_info *pVBInfo) xgifb_reg_and_or(pVBInfo->P3c4, 0x1E, 0xFF, 0x20); } -static void XGI_SetGroup5(unsigned short ModeIdIndex, - struct vb_device_info *pVBInfo) +static void XGI_SetGroup5(struct vb_device_info *pVBInfo) { if (pVBInfo->ModeType == ModeVGA) { if (!(pVBInfo->VBInfo & (SetInSlaveMode | LoadDACFlag @@ -4808,8 +4803,7 @@ static void XGI_SetLCDCap(struct vb_device_info *pVBInfo) /* Output : */ /* Description : Set TV Customized Param. */ /* --------------------------------------------------------------------- */ -static void XGI_SetAntiFlicker(unsigned short ModeIdIndex, - struct vb_device_info *pVBInfo) +static void XGI_SetAntiFlicker(struct vb_device_info *pVBInfo) { unsigned short tempbx; @@ -4826,8 +4820,7 @@ static void XGI_SetAntiFlicker(unsigned short ModeIdIndex, xgifb_reg_and_or(pVBInfo->Part2Port, 0x0A, 0x8F, tempah); } -static void XGI_SetEdgeEnhance(unsigned short ModeIdIndex, - struct vb_device_info *pVBInfo) +static void XGI_SetEdgeEnhance(struct vb_device_info *pVBInfo) { unsigned short tempbx; @@ -4943,10 +4936,10 @@ static void XGI_OEM310Setting(unsigned short ModeIdIndex, if (pVBInfo->VBInfo & SetCRT2ToTV) { XGI_SetPhaseIncr(pVBInfo); XGI_SetYFilter(ModeIdIndex, pVBInfo); - XGI_SetAntiFlicker(ModeIdIndex, pVBInfo); + XGI_SetAntiFlicker(pVBInfo); if (pVBInfo->VBType & VB_SIS301) - XGI_SetEdgeEnhance(ModeIdIndex, pVBInfo); + XGI_SetEdgeEnhance(pVBInfo); } } @@ -5256,7 +5249,7 @@ static unsigned char XGI_SetCRT2Group301(unsigned short ModeNo, XGI_SetGroup4(ModeIdIndex, RefreshRateTableIndex, HwDeviceExtension, pVBInfo); XGI_SetCRT2VCLK(ModeIdIndex, RefreshRateTableIndex, pVBInfo); - XGI_SetGroup5(ModeIdIndex, pVBInfo); + XGI_SetGroup5(pVBInfo); XGI_AutoThreshold(pVBInfo); return 1; } @@ -5440,7 +5433,7 @@ static void XGI_SetCRT1Group(struct xgifb_video_info *xgifb_info, { unsigned short RefreshRateTableIndex, temp; - XGI_SetSeqRegs(ModeIdIndex, pVBInfo); + XGI_SetSeqRegs(pVBInfo); outb(XGI330_StandTable.MISC, pVBInfo->P3c2); XGI_SetCRTCRegs(HwDeviceExtension, pVBInfo); XGI_SetATTRegs(ModeIdIndex, pVBInfo); @@ -5483,11 +5476,9 @@ static void XGI_SetCRT1Group(struct xgifb_video_info *xgifb_info, if (temp & 0xA0) { if (HwDeviceExtension->jChipType == XG27) - XGI_SetXG27CRTC(ModeIdIndex, - RefreshRateTableIndex, pVBInfo); + XGI_SetXG27CRTC(RefreshRateTableIndex, pVBInfo); else - XGI_SetXG21CRTC(ModeIdIndex, - RefreshRateTableIndex, pVBInfo); + XGI_SetXG21CRTC(RefreshRateTableIndex, pVBInfo); XGI_UpdateXG21CRTC(ModeNo, pVBInfo, RefreshRateTableIndex); @@ -5506,7 +5497,7 @@ static void XGI_SetCRT1Group(struct xgifb_video_info *xgifb_info, XGI_SetCRT1FIFO(HwDeviceExtension, pVBInfo); XGI_SetCRT1ModeRegs(HwDeviceExtension, ModeIdIndex, RefreshRateTableIndex, pVBInfo); - XGI_LoadDAC(ModeIdIndex, pVBInfo); + XGI_LoadDAC(pVBInfo); } unsigned char XGISetModeNew(struct xgifb_video_info *xgifb_info, -- GitLab From b053af16885fb5f4ebd720433271abb63ea4c7fa Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 16 Jul 2013 23:13:28 +0300 Subject: [PATCH 125/942] staging: xgifb: delete unused "HwDeviceExtension" parameters Delete unused "HwDeviceExtension" parameters from internal functions. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_init.c | 31 +++++------- drivers/staging/xgifb/vb_setmode.c | 78 +++++++++--------------------- drivers/staging/xgifb/vb_setmode.h | 6 +-- 3 files changed, 39 insertions(+), 76 deletions(-) diff --git a/drivers/staging/xgifb/vb_init.c b/drivers/staging/xgifb/vb_init.c index 5f1c41ed778b5..506b7fe9c20d3 100644 --- a/drivers/staging/xgifb/vb_init.c +++ b/drivers/staging/xgifb/vb_init.c @@ -102,10 +102,8 @@ static void XGINew_DDR1x_MRS_340(unsigned long P3c4, xgifb_reg_set(P3c4, 0x1B, 0x00); } -static void XGINew_SetMemoryClock(struct xgi_hw_device_info *HwDeviceExtension, - struct vb_device_info *pVBInfo) +static void XGINew_SetMemoryClock(struct vb_device_info *pVBInfo) { - xgifb_reg_set(pVBInfo->P3c4, 0x28, pVBInfo->MCLKData[pVBInfo->ram_type].SR28); @@ -133,7 +131,7 @@ static void XGINew_DDRII_Bootup_XG27( { unsigned long P3d4 = P3c4 + 0x10; pVBInfo->ram_type = XGINew_GetXG20DRAMType(HwDeviceExtension, pVBInfo); - XGINew_SetMemoryClock(HwDeviceExtension, pVBInfo); + XGINew_SetMemoryClock(pVBInfo); /* Set Double Frequency */ xgifb_reg_set(P3d4, 0x97, pVBInfo->XGINew_CR97); /* CR97 */ @@ -206,7 +204,7 @@ static void XGINew_DDR2_MRS_XG20(struct xgi_hw_device_info *HwDeviceExtension, unsigned long P3d4 = P3c4 + 0x10; pVBInfo->ram_type = XGINew_GetXG20DRAMType(HwDeviceExtension, pVBInfo); - XGINew_SetMemoryClock(HwDeviceExtension, pVBInfo); + XGINew_SetMemoryClock(pVBInfo); xgifb_reg_set(P3d4, 0x97, 0x11); /* CR97 */ @@ -280,7 +278,7 @@ static void XGINew_DDR1x_DefaultRegister( unsigned long P3d4 = Port, P3c4 = Port - 0x10; if (HwDeviceExtension->jChipType >= XG20) { - XGINew_SetMemoryClock(HwDeviceExtension, pVBInfo); + XGINew_SetMemoryClock(pVBInfo); xgifb_reg_set(P3d4, 0x82, pVBInfo->CR40[11][pVBInfo->ram_type]); /* CR82 */ @@ -296,7 +294,7 @@ static void XGINew_DDR1x_DefaultRegister( XGINew_DDR1x_MRS_XG20(P3c4, pVBInfo); } else { - XGINew_SetMemoryClock(HwDeviceExtension, pVBInfo); + XGINew_SetMemoryClock(pVBInfo); switch (HwDeviceExtension->jChipType) { case XG42: @@ -948,8 +946,7 @@ static bool xgifb_read_vbios(struct pci_dev *pdev, return false; } -static void XGINew_ChkSenseStatus(struct xgi_hw_device_info *HwDeviceExtension, - struct vb_device_info *pVBInfo) +static void XGINew_ChkSenseStatus(struct vb_device_info *pVBInfo) { unsigned short tempbx = 0, temp, tempcx, CR3CData; @@ -991,8 +988,7 @@ static void XGINew_ChkSenseStatus(struct xgi_hw_device_info *HwDeviceExtension, xgifb_reg_set(pVBInfo->P3d4, 0x3e, ((tempbx & 0xFF00) >> 8)); } -static void XGINew_SetModeScratch(struct xgi_hw_device_info *HwDeviceExtension, - struct vb_device_info *pVBInfo) +static void XGINew_SetModeScratch(struct vb_device_info *pVBInfo) { unsigned short temp, tempcl = 0, tempch = 0, CR31Data, CR38Data; @@ -1126,8 +1122,7 @@ static void XGINew_GetXG21Sense(struct pci_dev *pdev, } } -static void XGINew_GetXG27Sense(struct xgi_hw_device_info *HwDeviceExtension, - struct vb_device_info *pVBInfo) +static void XGINew_GetXG27Sense(struct vb_device_info *pVBInfo) { unsigned char Temp, bCR4A; @@ -1222,7 +1217,7 @@ unsigned char XGIInitNew(struct pci_dev *pdev) XGINew_GetXG21Sense(pdev, pVBInfo); if (HwDeviceExtension->jChipType == XG27) - XGINew_GetXG27Sense(HwDeviceExtension, pVBInfo); + XGINew_GetXG27Sense(pVBInfo); /* Reset Extended register */ @@ -1294,7 +1289,7 @@ unsigned char XGIInitNew(struct pci_dev *pdev) if (HwDeviceExtension->jChipType < XG20) { /* Set VB */ - XGI_UnLockCRT2(HwDeviceExtension, pVBInfo); + XGI_UnLockCRT2(pVBInfo); /* disable VideoCapture */ xgifb_reg_and_or(pVBInfo->Part0Port, 0x3F, 0xEF, 0x00); xgifb_reg_set(pVBInfo->Part1Port, 0x00, 0x00); @@ -1334,7 +1329,7 @@ unsigned char XGIInitNew(struct pci_dev *pdev) xgifb_reg_set(pVBInfo->Part4Port, 0x10, XGI330_CRT2Data_4_10); xgifb_reg_set(pVBInfo->Part4Port, 0x0F, 0x3F); - XGI_LockCRT2(HwDeviceExtension, pVBInfo); + XGI_LockCRT2(pVBInfo); } } /* != XG20 */ @@ -1370,8 +1365,8 @@ unsigned char XGIInitNew(struct pci_dev *pdev) xgifb_reg_set(pVBInfo->P3c4, 0x22, 0xfa); xgifb_reg_set(pVBInfo->P3c4, 0x21, 0xa3); - XGINew_ChkSenseStatus(HwDeviceExtension, pVBInfo); - XGINew_SetModeScratch(HwDeviceExtension, pVBInfo); + XGINew_ChkSenseStatus(pVBInfo); + XGINew_SetModeScratch(pVBInfo); xgifb_reg_set(pVBInfo->P3d4, 0x8c, 0x87); diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c index 36be17bfa5a86..729203803b1b4 100644 --- a/drivers/staging/xgifb/vb_setmode.c +++ b/drivers/staging/xgifb/vb_setmode.c @@ -77,8 +77,7 @@ static void XGI_SetSeqRegs(struct vb_device_info *pVBInfo) } } -static void XGI_SetCRTCRegs(struct xgi_hw_device_info *HwDeviceExtension, - struct vb_device_info *pVBInfo) +static void XGI_SetCRTCRegs(struct vb_device_info *pVBInfo) { unsigned char CRTCdata; unsigned short i; @@ -678,8 +677,7 @@ static void XGI_UpdateXG21CRTC(unsigned short ModeNo, } } -static void XGI_SetCRT1DE(struct xgi_hw_device_info *HwDeviceExtension, - unsigned short ModeIdIndex, +static void XGI_SetCRT1DE(unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo) { @@ -827,7 +825,6 @@ static void XGI_SetCRT1Offset(unsigned short ModeNo, static unsigned short XGI_GetVCLK2Ptr(unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, - struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo) { unsigned short VCLKIndex, modeflag; @@ -889,7 +886,7 @@ static void XGI_SetCRT1VCLK(unsigned short ModeIdIndex, VB_SIS302LV | VB_XGI301C)) && (pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) { vclkindex = XGI_GetVCLK2Ptr(ModeIdIndex, RefreshRateTableIndex, - HwDeviceExtension, pVBInfo); + pVBInfo); data = xgifb_reg_get(pVBInfo->P3c4, 0x31) & 0xCF; xgifb_reg_set(pVBInfo->P3c4, 0x31, data); data = XGI_VBVCLKData[vclkindex].Part4_A; @@ -1774,8 +1771,7 @@ static void XGI_SetCRT2ECLK(unsigned short ModeIdIndex, } } -static void XGI_UpdateModeInfo(struct xgi_hw_device_info *HwDeviceExtension, - struct vb_device_info *pVBInfo) +static void XGI_UpdateModeInfo(struct vb_device_info *pVBInfo) { unsigned short tempcl, tempch, temp, tempbl, tempax; @@ -1902,7 +1898,6 @@ void XGI_GetVBType(struct vb_device_info *pVBInfo) } static void XGI_GetVBInfo(unsigned short ModeIdIndex, - struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo) { unsigned short tempax, push, tempbx, temp, modeflag; @@ -2745,7 +2740,6 @@ static unsigned short XGI_GetColorDepth(unsigned short ModeIdIndex, static unsigned short XGI_GetOffset(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, - struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo) { unsigned short temp, colordepth, modeinfo, index, infoflag, @@ -2776,7 +2770,6 @@ static unsigned short XGI_GetOffset(unsigned short ModeNo, static void XGI_SetCRT2Offset(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, - struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo) { unsigned short offset; @@ -2786,7 +2779,7 @@ static void XGI_SetCRT2Offset(unsigned short ModeNo, return; offset = XGI_GetOffset(ModeNo, ModeIdIndex, RefreshRateTableIndex, - HwDeviceExtension, pVBInfo); + pVBInfo); temp = (unsigned char) (offset & 0xFF); xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp); temp = (unsigned char) ((offset & 0xFF00) >> 8); @@ -2804,14 +2797,12 @@ static void XGI_SetCRT2FIFO(struct vb_device_info *pVBInfo) } static void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex, - struct xgi_hw_device_info *HwDeviceExtension, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo) { u8 tempcx; - XGI_SetCRT2Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex, - HwDeviceExtension, pVBInfo); + XGI_SetCRT2Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); XGI_SetCRT2FIFO(pVBInfo); for (tempcx = 4; tempcx < 7; tempcx++) @@ -2822,7 +2813,6 @@ static void XGI_PreSetGroup1(unsigned short ModeNo, unsigned short ModeIdIndex, } static void XGI_SetGroup1(unsigned short ModeIdIndex, - struct xgi_hw_device_info *HwDeviceExtension, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo) { @@ -2977,7 +2967,6 @@ static unsigned short XGI_GetVGAHT2(struct vb_device_info *pVBInfo) } static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex, - struct xgi_hw_device_info *HwDeviceExtension, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo) { @@ -3270,7 +3259,6 @@ static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex, static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, - struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo) { unsigned short i, j, tempax, tempbx, tempcx, temp, push1, push2, @@ -3700,7 +3688,6 @@ static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex, } static void XGI_SetLCDRegs(unsigned short ModeIdIndex, - struct xgi_hw_device_info *HwDeviceExtension, unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo) { @@ -4035,7 +4022,6 @@ static void XGI_SetGroup3(unsigned short ModeIdIndex, static void XGI_SetGroup4(unsigned short ModeIdIndex, unsigned short RefreshRateTableIndex, - struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo) { unsigned short tempax, tempcx, tempbx, modeflag, temp, temp2; @@ -4216,10 +4202,8 @@ static void XGI_SetGroup5(struct vb_device_info *pVBInfo) } } -static void XGI_DisableGatingCRT(struct xgi_hw_device_info *HwDeviceExtension, - struct vb_device_info *pVBInfo) +static void XGI_DisableGatingCRT(struct vb_device_info *pVBInfo) { - xgifb_reg_and_or(pVBInfo->P3d4, 0x63, 0xBF, 0x00); } @@ -4949,8 +4933,7 @@ static void XGI_OEM310Setting(unsigned short ModeIdIndex, /* Output : */ /* Description : Origin code for crt2group */ /* --------------------------------------------------------------------- */ -static void XGI_SetCRT2ModeRegs(struct xgi_hw_device_info *HwDeviceExtension, - struct vb_device_info *pVBInfo) +static void XGI_SetCRT2ModeRegs(struct vb_device_info *pVBInfo) { unsigned short tempbl; short tempcl; @@ -5112,20 +5095,14 @@ static void XGI_SetCRT2ModeRegs(struct xgi_hw_device_info *HwDeviceExtension, } -void XGI_UnLockCRT2(struct xgi_hw_device_info *HwDeviceExtension, - struct vb_device_info *pVBInfo) +void XGI_UnLockCRT2(struct vb_device_info *pVBInfo) { - xgifb_reg_and_or(pVBInfo->Part1Port, 0x2f, 0xFF, 0x01); - } -void XGI_LockCRT2(struct xgi_hw_device_info *HwDeviceExtension, - struct vb_device_info *pVBInfo) +void XGI_LockCRT2(struct vb_device_info *pVBInfo) { - xgifb_reg_and_or(pVBInfo->Part1Port, 0x2F, 0xFE, 0x00); - } unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE, @@ -5234,20 +5211,14 @@ static unsigned char XGI_SetCRT2Group301(unsigned short ModeNo, XGI_SaveCRT2Info(ModeNo, pVBInfo); XGI_GetCRT2ResInfo(ModeIdIndex, pVBInfo); XGI_GetCRT2Data(ModeIdIndex, RefreshRateTableIndex, pVBInfo); - XGI_PreSetGroup1(ModeNo, ModeIdIndex, HwDeviceExtension, - RefreshRateTableIndex, pVBInfo); - XGI_SetGroup1(ModeIdIndex, HwDeviceExtension, RefreshRateTableIndex, - pVBInfo); - XGI_SetLockRegs(ModeNo, ModeIdIndex, HwDeviceExtension, - RefreshRateTableIndex, pVBInfo); - XGI_SetGroup2(ModeNo, ModeIdIndex, RefreshRateTableIndex, - HwDeviceExtension, pVBInfo); - XGI_SetLCDRegs(ModeIdIndex, HwDeviceExtension, RefreshRateTableIndex, - pVBInfo); + XGI_PreSetGroup1(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); + XGI_SetGroup1(ModeIdIndex, RefreshRateTableIndex, pVBInfo); + XGI_SetLockRegs(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); + XGI_SetGroup2(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); + XGI_SetLCDRegs(ModeIdIndex, RefreshRateTableIndex, pVBInfo); XGI_SetTap4Regs(pVBInfo); XGI_SetGroup3(ModeIdIndex, pVBInfo); - XGI_SetGroup4(ModeIdIndex, RefreshRateTableIndex, HwDeviceExtension, - pVBInfo); + XGI_SetGroup4(ModeIdIndex, RefreshRateTableIndex, pVBInfo); XGI_SetCRT2VCLK(ModeIdIndex, RefreshRateTableIndex, pVBInfo); XGI_SetGroup5(pVBInfo); XGI_AutoThreshold(pVBInfo); @@ -5408,7 +5379,7 @@ static void XGI_EnableBridge(struct xgifb_video_info *xgifb_info, /* EnablePart4_1F */ xgifb_reg_or(pVBInfo->Part4Port, 0x1F, tempah); - XGI_DisableGatingCRT(HwDeviceExtension, pVBInfo); + XGI_DisableGatingCRT(pVBInfo); XGI_DisplayOn(xgifb_info, HwDeviceExtension, pVBInfo); } /* 301 */ else { /* LVDS */ @@ -5435,7 +5406,7 @@ static void XGI_SetCRT1Group(struct xgifb_video_info *xgifb_info, XGI_SetSeqRegs(pVBInfo); outb(XGI330_StandTable.MISC, pVBInfo->P3c2); - XGI_SetCRTCRegs(HwDeviceExtension, pVBInfo); + XGI_SetCRTCRegs(pVBInfo); XGI_SetATTRegs(ModeIdIndex, pVBInfo); XGI_SetGRCRegs(pVBInfo); XGI_ClearExt1Regs(pVBInfo); @@ -5463,8 +5434,7 @@ static void XGI_SetCRT1Group(struct xgifb_video_info *xgifb_info, XGI_SetSync(RefreshRateTableIndex, pVBInfo); XGI_SetCRT1CRTC(ModeIdIndex, RefreshRateTableIndex, pVBInfo, HwDeviceExtension); - XGI_SetCRT1DE(HwDeviceExtension, ModeIdIndex, - RefreshRateTableIndex, pVBInfo); + XGI_SetCRT1DE(ModeIdIndex, RefreshRateTableIndex, pVBInfo); XGI_SetCRT1Offset(ModeNo, ModeIdIndex, RefreshRateTableIndex, HwDeviceExtension, pVBInfo); XGI_SetCRT1VCLK(ModeIdIndex, HwDeviceExtension, @@ -5532,12 +5502,12 @@ unsigned char XGISetModeNew(struct xgifb_video_info *xgifb_info, xgifb_reg_set(pVBInfo->P3c4, 0x05, 0x86); if (HwDeviceExtension->jChipType < XG20) - XGI_UnLockCRT2(HwDeviceExtension, pVBInfo); + XGI_UnLockCRT2(pVBInfo); XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo); if (HwDeviceExtension->jChipType < XG20) { - XGI_GetVBInfo(ModeIdIndex, HwDeviceExtension, pVBInfo); + XGI_GetVBInfo(ModeIdIndex, pVBInfo); XGI_GetTVInfo(ModeIdIndex, pVBInfo); XGI_GetLCDInfo(ModeIdIndex, pVBInfo); XGI_DisableBridge(xgifb_info, HwDeviceExtension, pVBInfo); @@ -5566,7 +5536,7 @@ unsigned char XGISetModeNew(struct xgifb_video_info *xgifb_info, } } - XGI_SetCRT2ModeRegs(HwDeviceExtension, pVBInfo); + XGI_SetCRT2ModeRegs(pVBInfo); XGI_OEM310Setting(ModeIdIndex, pVBInfo); /*0212*/ XGI_EnableBridge(xgifb_info, HwDeviceExtension, pVBInfo); } /* !XG20 */ @@ -5591,10 +5561,10 @@ unsigned char XGISetModeNew(struct xgifb_video_info *xgifb_info, XGI_DisplayOn(xgifb_info, HwDeviceExtension, pVBInfo); } - XGI_UpdateModeInfo(HwDeviceExtension, pVBInfo); + XGI_UpdateModeInfo(pVBInfo); if (HwDeviceExtension->jChipType < XG20) - XGI_LockCRT2(HwDeviceExtension, pVBInfo); + XGI_LockCRT2(pVBInfo); return 1; } diff --git a/drivers/staging/xgifb/vb_setmode.h b/drivers/staging/xgifb/vb_setmode.h index 2c0a31c8dfd50..3170dd3843923 100644 --- a/drivers/staging/xgifb/vb_setmode.h +++ b/drivers/staging/xgifb/vb_setmode.h @@ -2,10 +2,8 @@ #define _VBSETMODE_ extern void InitTo330Pointer(unsigned char, struct vb_device_info *); -extern void XGI_UnLockCRT2(struct xgi_hw_device_info *HwDeviceExtension, - struct vb_device_info *); -extern void XGI_LockCRT2(struct xgi_hw_device_info *HwDeviceExtension, - struct vb_device_info *); +extern void XGI_UnLockCRT2(struct vb_device_info *); +extern void XGI_LockCRT2(struct vb_device_info *); extern void XGI_DisplayOff(struct xgifb_video_info *, struct xgi_hw_device_info *, struct vb_device_info *); -- GitLab From 88a3dfdd93ab1f1ac4a92defd17fadcbc1c0e812 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 16 Jul 2013 23:13:29 +0300 Subject: [PATCH 126/942] staging: xgifb: delete unused "RefreshRateTableIndex" parameters Delete unused "RefreshRateTableIndex" parameters from internal functions. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_setmode.c | 44 ++++++++++++------------------ 1 file changed, 17 insertions(+), 27 deletions(-) diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c index 729203803b1b4..7228d171d31ef 100644 --- a/drivers/staging/xgifb/vb_setmode.c +++ b/drivers/staging/xgifb/vb_setmode.c @@ -1201,7 +1201,6 @@ static void XGI_GetLVDSResInfo(unsigned short ModeIdIndex, static void const *XGI_GetLcdPtr(struct XGI330_LCDDataTablStruct const *table, unsigned short ModeIdIndex, - unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo) { unsigned short i, tempdx, tempbx, modeflag; @@ -1269,16 +1268,14 @@ static struct SiS_TVData const *XGI_GetTVPtr(unsigned short ModeIdIndex, } static void XGI_GetLVDSData(unsigned short ModeIdIndex, - unsigned short RefreshRateTableIndex, - struct vb_device_info *pVBInfo) + struct vb_device_info *pVBInfo) { struct SiS_LVDSData const *LCDPtr; if (!(pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA))) return; - LCDPtr = XGI_GetLcdPtr(XGI_EPLLCDDataPtr, ModeIdIndex, - RefreshRateTableIndex, pVBInfo); + LCDPtr = XGI_GetLcdPtr(XGI_EPLLCDDataPtr, ModeIdIndex, pVBInfo); pVBInfo->VGAHT = LCDPtr->VGAHT; pVBInfo->VGAVT = LCDPtr->VGAVT; pVBInfo->HT = LCDPtr->LCDHT; @@ -1305,9 +1302,8 @@ static void XGI_GetLVDSData(unsigned short ModeIdIndex, } static void XGI_ModCRT1Regs(unsigned short ModeIdIndex, - unsigned short RefreshRateTableIndex, - struct xgi_hw_device_info *HwDeviceExtension, - struct vb_device_info *pVBInfo) + struct xgi_hw_device_info *HwDeviceExtension, + struct vb_device_info *pVBInfo) { unsigned short i; struct XGI_LVDSCRT1HDataStruct const *LCDPtr = NULL; @@ -1315,7 +1311,7 @@ static void XGI_ModCRT1Regs(unsigned short ModeIdIndex, if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { LCDPtr = XGI_GetLcdPtr(xgifb_epllcd_crt1_h, ModeIdIndex, - RefreshRateTableIndex, pVBInfo); + pVBInfo); for (i = 0; i < 8; i++) pVBInfo->TimingH.data[i] = LCDPtr[0].Reg[i]; @@ -1325,7 +1321,7 @@ static void XGI_ModCRT1Regs(unsigned short ModeIdIndex, if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { LCDPtr1 = XGI_GetLcdPtr(xgifb_epllcd_crt1_v, ModeIdIndex, - RefreshRateTableIndex, pVBInfo); + pVBInfo); for (i = 0; i < 7; i++) pVBInfo->TimingV.data[i] = LCDPtr1[0].Reg[i]; } @@ -1404,16 +1400,14 @@ static void XGI_GetLCDSync(unsigned short *HSyncWidth, } static void XGI_SetLVDSRegs(unsigned short ModeIdIndex, - unsigned short RefreshRateTableIndex, - struct vb_device_info *pVBInfo) + struct vb_device_info *pVBInfo) { unsigned short tempbx, tempax, tempcx, tempdx, push1, push2, modeflag; unsigned long temp, temp1, temp2, temp3, push3; struct XGI330_LCDDataDesStruct2 const *LCDPtr1 = NULL; modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag; - LCDPtr1 = XGI_GetLcdPtr(XGI_EPLLCDDesDataPtr, ModeIdIndex, - RefreshRateTableIndex, pVBInfo); + LCDPtr1 = XGI_GetLcdPtr(XGI_EPLLCDDesDataPtr, ModeIdIndex, pVBInfo); XGI_GetLCDSync(&tempax, &tempbx, pVBInfo); push1 = tempbx; @@ -2544,7 +2538,7 @@ static void XGI_GetCRT2Data(unsigned short ModeIdIndex, if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { LCDPtr = XGI_GetLcdPtr(XGI_LCDDataTable, ModeIdIndex, - RefreshRateTableIndex, pVBInfo); + pVBInfo); pVBInfo->RVBHCMAX = LCDPtr->RVBHCMAX; pVBInfo->RVBHCFACT = LCDPtr->RVBHCFACT; @@ -2967,7 +2961,6 @@ static unsigned short XGI_GetVGAHT2(struct vb_device_info *pVBInfo) } static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex, - unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo) { unsigned short push1, push2, tempax, tempbx = 0, tempcx, temp, resinfo, @@ -3258,7 +3251,6 @@ static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex, } static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex, - unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo) { unsigned short i, j, tempax, tempbx, tempcx, temp, push1, push2, @@ -3688,7 +3680,6 @@ static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex, } static void XGI_SetLCDRegs(unsigned short ModeIdIndex, - unsigned short RefreshRateTableIndex, struct vb_device_info *pVBInfo) { unsigned short pushbx, tempax, tempbx, tempcx, temp, tempah, @@ -3735,10 +3726,10 @@ static void XGI_SetLCDRegs(unsigned short ModeIdIndex, /* Customized LCDB Does not add */ if ((pVBInfo->VBType & VB_SIS301LV) || (pVBInfo->VBType & VB_SIS302LV)) LCDBDesPtr = XGI_GetLcdPtr(xgifb_lcddldes, ModeIdIndex, - RefreshRateTableIndex, pVBInfo); + pVBInfo); else LCDBDesPtr = XGI_GetLcdPtr(XGI_LCDDesDataTable, ModeIdIndex, - RefreshRateTableIndex, pVBInfo); + pVBInfo); tempah = pVBInfo->LCDResInfo; tempah &= PanelResInfo; @@ -5190,10 +5181,9 @@ static void XGI_SetLCDAGroup(unsigned short ModeNo, unsigned short ModeIdIndex, RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo, ModeIdIndex, pVBInfo); XGI_GetLVDSResInfo(ModeIdIndex, pVBInfo); - XGI_GetLVDSData(ModeIdIndex, RefreshRateTableIndex, pVBInfo); - XGI_ModCRT1Regs(ModeIdIndex, RefreshRateTableIndex, HwDeviceExtension, - pVBInfo); - XGI_SetLVDSRegs(ModeIdIndex, RefreshRateTableIndex, pVBInfo); + XGI_GetLVDSData(ModeIdIndex, pVBInfo); + XGI_ModCRT1Regs(ModeIdIndex, HwDeviceExtension, pVBInfo); + XGI_SetLVDSRegs(ModeIdIndex, pVBInfo); XGI_SetCRT2ECLK(ModeIdIndex, RefreshRateTableIndex, pVBInfo); } @@ -5213,9 +5203,9 @@ static unsigned char XGI_SetCRT2Group301(unsigned short ModeNo, XGI_GetCRT2Data(ModeIdIndex, RefreshRateTableIndex, pVBInfo); XGI_PreSetGroup1(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); XGI_SetGroup1(ModeIdIndex, RefreshRateTableIndex, pVBInfo); - XGI_SetLockRegs(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); - XGI_SetGroup2(ModeNo, ModeIdIndex, RefreshRateTableIndex, pVBInfo); - XGI_SetLCDRegs(ModeIdIndex, RefreshRateTableIndex, pVBInfo); + XGI_SetLockRegs(ModeNo, ModeIdIndex, pVBInfo); + XGI_SetGroup2(ModeNo, ModeIdIndex, pVBInfo); + XGI_SetLCDRegs(ModeIdIndex, pVBInfo); XGI_SetTap4Regs(pVBInfo); XGI_SetGroup3(ModeIdIndex, pVBInfo); XGI_SetGroup4(ModeIdIndex, RefreshRateTableIndex, pVBInfo); -- GitLab From 334ab0728d7b6e333a07a7c28d6b7bb25ad8b220 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 16 Jul 2013 23:13:30 +0300 Subject: [PATCH 127/942] staging: xgifb: delete unused "pVBInfo" parameters Delete unused "pVBInfo" parameters from internal functions. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main_26.c | 4 ++-- drivers/staging/xgifb/vb_init.c | 5 ++--- drivers/staging/xgifb/vb_setmode.c | 25 ++++++++++--------------- drivers/staging/xgifb/vb_setmode.h | 3 +-- 4 files changed, 15 insertions(+), 22 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index 015d7bbccf866..3b3e17d3f6f58 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -68,7 +68,7 @@ static int XGIfb_mode_rate_to_dclock(struct vb_device_info *XGI_Pr, int Clock; InitTo330Pointer(HwDeviceExtension->jChipType, XGI_Pr); - XGI_SearchModeID(ModeNo, &ModeIdIndex, XGI_Pr); + XGI_SearchModeID(ModeNo, &ModeIdIndex); RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo, ModeIdIndex, XGI_Pr); @@ -96,7 +96,7 @@ static int XGIfb_mode_rate_to_ddata(struct vb_device_info *XGI_Pr, unsigned char sr_data, cr_data, cr_data2; int B, C, D, F, temp, j; InitTo330Pointer(HwDeviceExtension->jChipType, XGI_Pr); - if (!XGI_SearchModeID(ModeNo, &ModeIdIndex, XGI_Pr)) + if (!XGI_SearchModeID(ModeNo, &ModeIdIndex)) return 0; RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo, ModeIdIndex, XGI_Pr); diff --git a/drivers/staging/xgifb/vb_init.c b/drivers/staging/xgifb/vb_init.c index 506b7fe9c20d3..21541720e05ce 100644 --- a/drivers/staging/xgifb/vb_init.c +++ b/drivers/staging/xgifb/vb_init.c @@ -874,8 +874,7 @@ static u8 *xgifb_copy_rom(struct pci_dev *dev, size_t *rom_size) return rom_copy; } -static bool xgifb_read_vbios(struct pci_dev *pdev, - struct vb_device_info *pVBInfo) +static bool xgifb_read_vbios(struct pci_dev *pdev) { struct xgifb_video_info *xgifb_info = pci_get_drvdata(pdev); u8 *vbios; @@ -1098,7 +1097,7 @@ static void XGINew_GetXG21Sense(struct pci_dev *pdev, struct xgifb_video_info *xgifb_info = pci_get_drvdata(pdev); unsigned char Temp; - if (xgifb_read_vbios(pdev, pVBInfo)) { /* For XG21 LVDS */ + if (xgifb_read_vbios(pdev)) { /* For XG21 LVDS */ xgifb_reg_or(pVBInfo->P3d4, 0x32, LCDSense); /* LVDS on chip */ xgifb_reg_and_or(pVBInfo->P3d4, 0x38, ~0xE0, 0xC0); diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c index 7228d171d31ef..46dea3f108880 100644 --- a/drivers/staging/xgifb/vb_setmode.c +++ b/drivers/staging/xgifb/vb_setmode.c @@ -2164,7 +2164,7 @@ static unsigned char XGI_GetLCDInfo(unsigned short ModeIdIndex, } unsigned char XGI_SearchModeID(unsigned short ModeNo, - unsigned short *ModeIdIndex, struct vb_device_info *pVBInfo) + unsigned short *ModeIdIndex) { for (*ModeIdIndex = 0;; (*ModeIdIndex)++) { if (XGI330_EModeIDTable[*ModeIdIndex].Ext_ModeID == ModeNo) @@ -2715,8 +2715,7 @@ static void XGI_SetCRT2VCLK(unsigned short ModeIdIndex, xgifb_reg_or(pVBInfo->Part4Port, 0x12, 0x08); } -static unsigned short XGI_GetColorDepth(unsigned short ModeIdIndex, - struct vb_device_info *pVBInfo) +static unsigned short XGI_GetColorDepth(unsigned short ModeIdIndex) { unsigned short ColorDepth[6] = { 1, 2, 4, 4, 6, 8 }; short index; @@ -2733,8 +2732,7 @@ static unsigned short XGI_GetColorDepth(unsigned short ModeIdIndex, static unsigned short XGI_GetOffset(unsigned short ModeNo, unsigned short ModeIdIndex, - unsigned short RefreshRateTableIndex, - struct vb_device_info *pVBInfo) + unsigned short RefreshRateTableIndex) { unsigned short temp, colordepth, modeinfo, index, infoflag, ColorDepth[] = { 0x01, 0x02, 0x04 }; @@ -2749,7 +2747,7 @@ static unsigned short XGI_GetOffset(unsigned short ModeNo, if (infoflag & InterlaceMode) temp = temp << 1; - colordepth = XGI_GetColorDepth(ModeIdIndex, pVBInfo); + colordepth = XGI_GetColorDepth(ModeIdIndex); if ((ModeNo >= 0x7C) && (ModeNo <= 0x7E)) { temp = ModeNo - 0x7C; @@ -2772,8 +2770,7 @@ static void XGI_SetCRT2Offset(unsigned short ModeNo, if (pVBInfo->VBInfo & SetInSlaveMode) return; - offset = XGI_GetOffset(ModeNo, ModeIdIndex, RefreshRateTableIndex, - pVBInfo); + offset = XGI_GetOffset(ModeNo, ModeIdIndex, RefreshRateTableIndex); temp = (unsigned char) (offset & 0xFF); xgifb_reg_set(pVBInfo->Part1Port, 0x07, temp); temp = (unsigned char) ((offset & 0xFF00) >> 8); @@ -4199,8 +4196,7 @@ static void XGI_DisableGatingCRT(struct vb_device_info *pVBInfo) } static unsigned char XGI_XG21CheckLVDSMode(struct xgifb_video_info *xgifb_info, - unsigned short ModeNo, unsigned short ModeIdIndex, - struct vb_device_info *pVBInfo) + unsigned short ModeNo, unsigned short ModeIdIndex) { unsigned short xres, yres, colordepth, modeflag, resindex; @@ -4229,7 +4225,7 @@ static unsigned char XGI_XG21CheckLVDSMode(struct xgifb_video_info *xgifb_info, if (xres != xgifb_info->lvds_data.LVDSHDE || yres != xgifb_info->lvds_data.LVDSVDE) { - colordepth = XGI_GetColorDepth(ModeIdIndex, pVBInfo); + colordepth = XGI_GetColorDepth(ModeIdIndex); if (colordepth > 2) return 0; } @@ -5194,7 +5190,7 @@ static unsigned char XGI_SetCRT2Group301(unsigned short ModeNo, unsigned short ModeIdIndex, RefreshRateTableIndex; pVBInfo->SetFlag |= ProgrammingCRT2; - XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo); + XGI_SearchModeID(ModeNo, &ModeIdIndex); pVBInfo->SelectCRT2Rate = 4; RefreshRateTableIndex = XGI_GetRatePtrCRT2(HwDeviceExtension, ModeNo, ModeIdIndex, pVBInfo); @@ -5494,7 +5490,7 @@ unsigned char XGISetModeNew(struct xgifb_video_info *xgifb_info, if (HwDeviceExtension->jChipType < XG20) XGI_UnLockCRT2(pVBInfo); - XGI_SearchModeID(ModeNo, &ModeIdIndex, pVBInfo); + XGI_SearchModeID(ModeNo, &ModeIdIndex); if (HwDeviceExtension->jChipType < XG20) { XGI_GetVBInfo(ModeIdIndex, pVBInfo); @@ -5533,8 +5529,7 @@ unsigned char XGISetModeNew(struct xgifb_video_info *xgifb_info, else { if (pVBInfo->IF_DEF_LVDS == 1) if (!XGI_XG21CheckLVDSMode(xgifb_info, ModeNo, - ModeIdIndex, - pVBInfo)) + ModeIdIndex)) return 0; pVBInfo->ModeType = XGI330_EModeIDTable[ModeIdIndex]. diff --git a/drivers/staging/xgifb/vb_setmode.h b/drivers/staging/xgifb/vb_setmode.h index 3170dd3843923..f67d9478f7688 100644 --- a/drivers/staging/xgifb/vb_setmode.h +++ b/drivers/staging/xgifb/vb_setmode.h @@ -14,8 +14,7 @@ extern unsigned char XGISetModeNew(struct xgifb_video_info *xgifb_info, unsigned short ModeNo) ; extern unsigned char XGI_SearchModeID(unsigned short ModeNo, - unsigned short *ModeIdIndex, - struct vb_device_info *); + unsigned short *ModeIdIndex); extern unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE, unsigned short ModeNo, unsigned short ModeIdIndex, -- GitLab From 04948a34698ddfa8823148b3a357cf3438e1433b Mon Sep 17 00:00:00 2001 From: Anthony Foiani Date: Mon, 8 Jul 2013 00:52:40 -0600 Subject: [PATCH 128/942] staging: usbip: clean up checkpatch warnings in usbipd.c A few whitespace changes allows the file to pass checkpatch --strict (other than ignoring the CamelCase derived from the USB standard.) Signed-Off-By: Anthony Foiani Signed-off-by: Greg Kroah-Hartman --- drivers/staging/usbip/userspace/src/usbipd.c | 31 ++++++++++---------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/drivers/staging/usbip/userspace/src/usbipd.c b/drivers/staging/usbip/userspace/src/usbipd.c index 3e913b861dc2f..9d3824133e85e 100644 --- a/drivers/staging/usbip/userspace/src/usbipd.c +++ b/drivers/staging/usbip/userspace/src/usbipd.c @@ -53,18 +53,18 @@ static const char usbip_version_string[] = PACKAGE_STRING; static const char usbipd_help_string[] = - "usage: usbipd [options] \n" - " -D, --daemon \n" - " Run as a daemon process. \n" - " \n" - " -d, --debug \n" - " Print debugging information. \n" - " \n" - " -h, --help \n" - " Print this help. \n" - " \n" - " -v, --version \n" - " Show version. \n"; + "usage: usbipd [options]\n" + " -D, --daemon\n" + " Run as a daemon process.\n" + "\n" + " -d, --debug\n" + " Print debugging information.\n" + "\n" + " -h, --help\n" + " Print this help.\n" + "\n" + " -v, --version\n" + " Show version.\n"; static void usbipd_help(void) { @@ -286,13 +286,13 @@ static int do_accept(int listenfd) memset(&ss, 0, sizeof(ss)); - connfd = accept(listenfd, (struct sockaddr *) &ss, &len); + connfd = accept(listenfd, (struct sockaddr *)&ss, &len); if (connfd < 0) { err("failed to accept connection"); return -1; } - rc = getnameinfo((struct sockaddr *) &ss, len, host, sizeof(host), + rc = getnameinfo((struct sockaddr *)&ss, len, host, sizeof(host), port, sizeof(port), NI_NUMERICHOST | NI_NUMERICSERV); if (rc) err("getnameinfo: %s", gai_strerror(rc)); @@ -496,8 +496,9 @@ static int do_standalone_mode(int daemonize) process_request(sockfdlist[i]); } } - } else + } else { dbg("heartbeat timeout on ppoll()"); + } } info("shutting down " PROGNAME); -- GitLab From 2568dd1b6b800dd0fdff5aa997cf7d0c46c19ffe Mon Sep 17 00:00:00 2001 From: Anthony Foiani Date: Mon, 8 Jul 2013 00:52:41 -0600 Subject: [PATCH 129/942] staging: usbip: use local variable while setting up socket Using a simple integer makes the code easier to read and removes the need to blank out array elements in case of errors. Signed-Off-By: Anthony Foiani Signed-off-by: Greg Kroah-Hartman --- drivers/staging/usbip/userspace/src/usbipd.c | 27 +++++++++----------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/drivers/staging/usbip/userspace/src/usbipd.c b/drivers/staging/usbip/userspace/src/usbipd.c index 9d3824133e85e..d833e7b5fdf94 100644 --- a/drivers/staging/usbip/userspace/src/usbipd.c +++ b/drivers/staging/usbip/userspace/src/usbipd.c @@ -348,36 +348,33 @@ static int listen_all_addrinfo(struct addrinfo *ai_head, int sockfdlist[]) int ret, nsockfd = 0; for (ai = ai_head; ai && nsockfd < MAXSOCKFD; ai = ai->ai_next) { - sockfdlist[nsockfd] = socket(ai->ai_family, ai->ai_socktype, - ai->ai_protocol); - if (sockfdlist[nsockfd] < 0) + int sock = socket(ai->ai_family, ai->ai_socktype, + ai->ai_protocol); + if (sock < 0) continue; - usbip_net_set_reuseaddr(sockfdlist[nsockfd]); - usbip_net_set_nodelay(sockfdlist[nsockfd]); + usbip_net_set_reuseaddr(sock); + usbip_net_set_nodelay(sock); - if (sockfdlist[nsockfd] >= FD_SETSIZE) { - close(sockfdlist[nsockfd]); - sockfdlist[nsockfd] = -1; + if (sock >= FD_SETSIZE) { + close(sock); continue; } - ret = bind(sockfdlist[nsockfd], ai->ai_addr, ai->ai_addrlen); + ret = bind(sock, ai->ai_addr, ai->ai_addrlen); if (ret < 0) { - close(sockfdlist[nsockfd]); - sockfdlist[nsockfd] = -1; + close(sock); continue; } - ret = listen(sockfdlist[nsockfd], SOMAXCONN); + ret = listen(sock, SOMAXCONN); if (ret < 0) { - close(sockfdlist[nsockfd]); - sockfdlist[nsockfd] = -1; + close(sock); continue; } log_addrinfo(ai); - nsockfd++; + sockfdlist[nsockfd++] = sock; } if (nsockfd == 0) -- GitLab From a159d620b0d9a2095616be4e98d10654ad386c11 Mon Sep 17 00:00:00 2001 From: Anthony Foiani Date: Mon, 8 Jul 2013 00:52:42 -0600 Subject: [PATCH 130/942] staging: usbip: improve error reporting Give useful error messages when we can't create server sockets. Signed-Off-By: Anthony Foiani Signed-off-by: Greg Kroah-Hartman --- drivers/staging/usbip/userspace/src/usbipd.c | 28 +++++++++++++++----- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/drivers/staging/usbip/userspace/src/usbipd.c b/drivers/staging/usbip/userspace/src/usbipd.c index d833e7b5fdf94..1ecca9dd99458 100644 --- a/drivers/staging/usbip/userspace/src/usbipd.c +++ b/drivers/staging/usbip/userspace/src/usbipd.c @@ -328,52 +328,68 @@ int process_request(int listenfd) return 0; } -static void log_addrinfo(struct addrinfo *ai) +static void addrinfo_to_text(struct addrinfo *ai, char buf[], + const size_t buf_size) { char hbuf[NI_MAXHOST]; char sbuf[NI_MAXSERV]; int rc; + buf[0] = '\0'; + rc = getnameinfo(ai->ai_addr, ai->ai_addrlen, hbuf, sizeof(hbuf), sbuf, sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV); if (rc) err("getnameinfo: %s", gai_strerror(rc)); - info("listening on %s:%s", hbuf, sbuf); + snprintf(buf, buf_size, "%s:%s", hbuf, sbuf); } static int listen_all_addrinfo(struct addrinfo *ai_head, int sockfdlist[]) { struct addrinfo *ai; int ret, nsockfd = 0; + const size_t ai_buf_size = NI_MAXHOST + NI_MAXSERV + 2; + char ai_buf[ai_buf_size]; for (ai = ai_head; ai && nsockfd < MAXSOCKFD; ai = ai->ai_next) { - int sock = socket(ai->ai_family, ai->ai_socktype, - ai->ai_protocol); - if (sock < 0) + int sock; + addrinfo_to_text(ai, ai_buf, ai_buf_size); + dbg("opening %s", ai_buf); + sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); + if (sock < 0) { + err("socket: %s: %d (%s)", + ai_buf, errno, strerror(errno)); continue; + } usbip_net_set_reuseaddr(sock); usbip_net_set_nodelay(sock); if (sock >= FD_SETSIZE) { + err("FD_SETSIZE: %s: sock=%d, max=%d", + ai_buf, sock, FD_SETSIZE); close(sock); continue; } ret = bind(sock, ai->ai_addr, ai->ai_addrlen); if (ret < 0) { + err("bind: %s: %d (%s)", + ai_buf, errno, strerror(errno)); close(sock); continue; } ret = listen(sock, SOMAXCONN); if (ret < 0) { + err("listen: %s: %d (%s)", + ai_buf, errno, strerror(errno)); close(sock); continue; } - log_addrinfo(ai); + info("listening on %s", ai_buf); sockfdlist[nsockfd++] = sock; } -- GitLab From 12da3d35a9381cda892ffbed3c1f13670832b622 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 24 Jul 2013 12:06:20 +0530 Subject: [PATCH 131/942] staging: lustre: Remove version.h header inclusion in kp30.h version.h header inclusion is not necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/include/linux/libcfs/linux/kp30.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/kp30.h b/drivers/staging/lustre/include/linux/libcfs/linux/kp30.h index 5ba099595a99d..2e5c850716478 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/kp30.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/kp30.h @@ -55,7 +55,6 @@ #include #include #include -#include #include #include #include -- GitLab From ac20a8af710718d5fc2c93e5d063e6cc2dcf38b2 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 24 Jul 2013 12:06:21 +0530 Subject: [PATCH 132/942] staging: lustre: Remove version.h header inclusion in linux-cpu.h version.h header inclusion is not necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h index 5f793f2237509..36928791e75d0 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h @@ -46,8 +46,6 @@ #include #include #include -#include - #ifdef CONFIG_SMP -- GitLab From 71930337f4df062ad1806b4c2f9c2ec461a65775 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 24 Jul 2013 12:06:22 +0530 Subject: [PATCH 133/942] staging: lustre: Remove version.h header inclusion in linux-prim.h version.h header inclusion is not necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h index a4963a8dfdd85..acdf7ee089f21 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h @@ -49,7 +49,6 @@ #include #include #include -#include #include #include #include -- GitLab From 9136e118e04aa9cb22bd67b8b14a1555e20c20a1 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 24 Jul 2013 12:06:23 +0530 Subject: [PATCH 134/942] staging: lustre: Remove version.h header inclusion in linux-time.h version.h header inclusion is not necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h index 4a48b914b42a8..a386d1b1286b3 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h @@ -91,7 +91,6 @@ #include #include -#include #include #include -- GitLab From 95eed10b20a97de95c424425616a4edd8fb4d1b8 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 24 Jul 2013 12:06:24 +0530 Subject: [PATCH 135/942] staging: lustre: Remove version.h header inclusion in socklnd_lib-linux.h version.h header inclusion is not necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.h b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.h index 3c135786dc115..384eb7ca1c82d 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.h +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.h @@ -41,7 +41,6 @@ #include #include -#include #include #include #include -- GitLab From 3c5534cfca74f2239a0e7d1f7554567d79b4a3ca Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 24 Jul 2013 12:06:25 +0530 Subject: [PATCH 136/942] staging: lustre: Remove version.h header inclusion in lprocfs_status.h version.h header inclusion is not necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/linux/lprocfs_status.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/include/linux/lprocfs_status.h b/drivers/staging/lustre/lustre/include/linux/lprocfs_status.h index 586692272d780..4bcc4dcca3da3 100644 --- a/drivers/staging/lustre/lustre/include/linux/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/linux/lprocfs_status.h @@ -48,7 +48,6 @@ #include #include -#include #include #include #include -- GitLab From 082013e97d93fcc38f076a71b21b9233eadbf740 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 24 Jul 2013 12:06:26 +0530 Subject: [PATCH 137/942] staging: lustre: Remove version.h header inclusion in lustre_handles.h version.h header inclusion is not necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/linux/lustre_handles.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_handles.h b/drivers/staging/lustre/lustre/include/linux/lustre_handles.h index ecf1840512524..459b2380600fe 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_handles.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_handles.h @@ -42,7 +42,6 @@ #include #include #include -#include #include #include -- GitLab From 98201dee66e057c0ed40fe40b73e951b17d95abd Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 24 Jul 2013 12:06:27 +0530 Subject: [PATCH 138/942] staging: lustre: Remove version.h header inclusion in lustre_lite.h version.h header inclusion is not necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/linux/lustre_lite.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_lite.h b/drivers/staging/lustre/lustre/include/linux/lustre_lite.h index c95dff900b587..9e5df8dabe803 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_lite.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_lite.h @@ -40,8 +40,6 @@ #endif -#include - #include #include -- GitLab From 73086c2a522cc6756f637863f79fe76ed740a05a Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 24 Jul 2013 12:06:28 +0530 Subject: [PATCH 139/942] staging: lustre: Remove version.h header inclusion in lustre_net.h version.h header inclusion is not necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/linux/lustre_net.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_net.h b/drivers/staging/lustre/lustre/include/linux/lustre_net.h index 2d7c425d70126..05de4d87db9a6 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_net.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_net.h @@ -39,7 +39,6 @@ #error Do not #include this file directly. #include instead #endif -#include #include /* XXX Liang: should be moved to other header instead of here */ -- GitLab From 1194231f4d7b65074dd7420e9c9916df1ab505c4 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 24 Jul 2013 12:06:29 +0530 Subject: [PATCH 140/942] staging: lustre: Remove version.h header inclusion in lustre_quota.h version.h header inclusion is not necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/linux/lustre_quota.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_quota.h b/drivers/staging/lustre/lustre/include/linux/lustre_quota.h index 421866b004cf8..a39505014c82a 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_quota.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_quota.h @@ -39,7 +39,6 @@ #error Do not #include this file directly. #include instead #endif -#include #include #include #include -- GitLab From f1289cba70c3b51e2bb30516ef734cc9c5576602 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 24 Jul 2013 12:06:30 +0530 Subject: [PATCH 141/942] staging: lustre: Remove version.h header inclusion in lustre_user.h version.h header inclusion is not necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/linux/lustre_user.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_user.h b/drivers/staging/lustre/lustre/include/linux/lustre_user.h index ea9393c625cc6..9cc2849f3f855 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_user.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_user.h @@ -41,7 +41,6 @@ #ifndef _LINUX_LUSTRE_USER_H #define _LINUX_LUSTRE_USER_H -# include # include /* -- GitLab From 1e591d1be945264014168cb32661b7402018f585 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 24 Jul 2013 12:06:31 +0530 Subject: [PATCH 142/942] staging: lustre: Remove version.h header inclusion in linux-debug.c version.h header inclusion is not necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c index 9b5fa919aa4af..0069b5ea1c28f 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c @@ -55,7 +55,6 @@ #include #include #include -#include # define DEBUG_SUBSYSTEM S_LNET -- GitLab From f2ca6c65f642af85ab212ef0f06c8ef3fca39db8 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 24 Jul 2013 12:06:32 +0530 Subject: [PATCH 143/942] staging: lustre: Remove version.h header inclusion in dir.c version.h header inclusion is not necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/dir.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index a94e463f04984..002b37448682b 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -41,7 +41,6 @@ #include #include #include -#include #include #include // for wait_on_buffer #include -- GitLab From 686570c83f7f2ea6db94fdd3869255d3f322ed77 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 24 Jul 2013 12:06:33 +0530 Subject: [PATCH 144/942] staging: lustre: Remove version.h header inclusion in llite_capa.c version.h header inclusion is not necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/llite_capa.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_capa.c b/drivers/staging/lustre/lustre/llite/llite_capa.c index b6fd9593325ad..cfc5ad388c1cb 100644 --- a/drivers/staging/lustre/lustre/llite/llite_capa.c +++ b/drivers/staging/lustre/lustre/llite/llite_capa.c @@ -41,7 +41,6 @@ #define DEBUG_SUBSYSTEM S_LLITE #include -#include #include #include #include -- GitLab From abef43cfbfc9aab014175576518305371c0f45f6 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 24 Jul 2013 12:06:34 +0530 Subject: [PATCH 145/942] staging: lustre: Remove version.h header inclusion in llite_lib.c version.h header inclusion is not necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/llite_lib.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index d7d87b1539b4f..e8bf49fa7bbfe 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -42,7 +42,6 @@ #include #include -#include #include #include -- GitLab From accd0b6bb1fbc96726b8b88489c82577874a6132 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 24 Jul 2013 12:06:35 +0530 Subject: [PATCH 146/942] staging: lustre: Remove version.h header inclusion in llite_mmap.c version.h header inclusion is not necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/llite_mmap.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_mmap.c b/drivers/staging/lustre/lustre/llite/llite_mmap.c index d9590d85634a6..32a57e85300b8 100644 --- a/drivers/staging/lustre/lustre/llite/llite_mmap.c +++ b/drivers/staging/lustre/lustre/llite/llite_mmap.c @@ -40,7 +40,6 @@ #include #include #include -#include #include #include -- GitLab From fff5096ff5f979346532693b01031731e504fd7d Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 24 Jul 2013 12:06:36 +0530 Subject: [PATCH 147/942] staging: lustre: Remove version.h header inclusion in lproc_llite.c version.h header inclusion is not necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/lproc_llite.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index a7b12fdd76b14..3ad391ae58945 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -35,7 +35,6 @@ */ #define DEBUG_SUBSYSTEM S_LLITE -#include #include #include #include -- GitLab From 4917e5bc033a844e1eefd3f2bf86965b887ba767 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 24 Jul 2013 12:06:37 +0530 Subject: [PATCH 148/942] staging: lustre: Remove version.h header inclusion in remote_perm.c version.h header inclusion is not necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/remote_perm.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/llite/remote_perm.c b/drivers/staging/lustre/lustre/llite/remote_perm.c index 4f176e16e01c7..0bc334803c900 100644 --- a/drivers/staging/lustre/lustre/llite/remote_perm.c +++ b/drivers/staging/lustre/lustre/llite/remote_perm.c @@ -45,7 +45,6 @@ #include #include -#include #include #include -- GitLab From 7dd39928e17b5c55145efdc013d1d375fb3b573f Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 24 Jul 2013 12:06:38 +0530 Subject: [PATCH 149/942] staging: lustre: Remove version.h header inclusion in super25.c version.h header inclusion is not necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/super25.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/llite/super25.c b/drivers/staging/lustre/lustre/llite/super25.c index ea06f1a18776d..0beaf4e76b4b5 100644 --- a/drivers/staging/lustre/lustre/llite/super25.c +++ b/drivers/staging/lustre/lustre/llite/super25.c @@ -38,7 +38,6 @@ #include #include -#include #include #include #include -- GitLab From 5995d8ac27aaa594431d738a98c43e6eaea1330a Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 24 Jul 2013 12:06:39 +0530 Subject: [PATCH 150/942] staging: lustre: Remove version.h header inclusion in symlink.c version.h header inclusion is not necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/symlink.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/llite/symlink.c b/drivers/staging/lustre/lustre/llite/symlink.c index 5260e989a4e50..9208afb95f12b 100644 --- a/drivers/staging/lustre/lustre/llite/symlink.c +++ b/drivers/staging/lustre/lustre/llite/symlink.c @@ -37,7 +37,6 @@ #include #include #include -#include #define DEBUG_SUBSYSTEM S_LLITE #include -- GitLab From 0c3242044ba3b0cf7794d628b837a9466f819088 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 24 Jul 2013 12:06:40 +0530 Subject: [PATCH 151/942] staging: lustre: Remove version.h header inclusion in lproc_lmv.c version.h header inclusion is not necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/lmv/lproc_lmv.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c index d1c45b583cbbb..edb5a3a99d572 100644 --- a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c +++ b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c @@ -36,7 +36,6 @@ #define DEBUG_SUBSYSTEM S_CLASS -#include #include #include #include -- GitLab From 386ac14033da97aba40f17675f33acdf7a310691 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 24 Jul 2013 12:06:41 +0530 Subject: [PATCH 152/942] staging: lustre: Remove version.h header inclusion in lproc_lov.c version.h header inclusion is not necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/lov/lproc_lov.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/lov/lproc_lov.c b/drivers/staging/lustre/lustre/lov/lproc_lov.c index 5b2c0d88add1b..15744e13a3f2d 100644 --- a/drivers/staging/lustre/lustre/lov/lproc_lov.c +++ b/drivers/staging/lustre/lustre/lov/lproc_lov.c @@ -35,7 +35,6 @@ */ #define DEBUG_SUBSYSTEM S_CLASS -#include #include #include #include -- GitLab From 18b98a3b489ddb7cf0afb155a311da791d5f012c Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 24 Jul 2013 12:06:42 +0530 Subject: [PATCH 153/942] staging: lustre: Remove version.h header inclusion in fsfilt_ext3.c version.h header inclusion is not necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/lvfs/fsfilt_ext3.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/lvfs/fsfilt_ext3.c b/drivers/staging/lustre/lustre/lvfs/fsfilt_ext3.c index c1e99b37572eb..ee75994003e1c 100644 --- a/drivers/staging/lustre/lustre/lvfs/fsfilt_ext3.c +++ b/drivers/staging/lustre/lustre/lvfs/fsfilt_ext3.c @@ -48,7 +48,6 @@ #include #include #include -#include #include #include -- GitLab From 828dd755b76d8a83b6f3aa9fd34a0fd60b8787ba Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 24 Jul 2013 12:06:43 +0530 Subject: [PATCH 154/942] staging: lustre: Remove version.h header inclusion in lvfs_linux.c version.h header inclusion is not necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/lvfs/lvfs_linux.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c b/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c index e70d8fe99888f..80b841a049cdd 100644 --- a/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c +++ b/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c @@ -40,13 +40,11 @@ #define DEBUG_SUBSYSTEM S_FILTER -#include #include #include #include #include #include -#include #include #include #include -- GitLab From 777a9f4aa7dcd2c1c3573a5c0e739286678d509b Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 24 Jul 2013 12:06:44 +0530 Subject: [PATCH 155/942] staging: lustre: Remove version.h header inclusion in lproc_mdc.c version.h header inclusion is not necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/mdc/lproc_mdc.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c index 6592478e9b6df..75300847f9128 100644 --- a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c +++ b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c @@ -35,7 +35,6 @@ */ #define DEBUG_SUBSYSTEM S_CLASS -#include #include #include #include -- GitLab From 0564e2aa47b103ab6b3cae489188a85871b96400 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 24 Jul 2013 12:06:45 +0530 Subject: [PATCH 156/942] staging: lustre: Remove version.h header inclusion in lproc_mgc.c version.h header inclusion is not necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/mgc/lproc_mgc.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/mgc/lproc_mgc.c b/drivers/staging/lustre/lustre/mgc/lproc_mgc.c index 1105eaa243132..ebecec2b0078c 100644 --- a/drivers/staging/lustre/lustre/mgc/lproc_mgc.c +++ b/drivers/staging/lustre/lustre/mgc/lproc_mgc.c @@ -35,7 +35,6 @@ */ #define DEBUG_SUBSYSTEM S_CLASS -#include #include #include #include -- GitLab From c3f8f3d83adadacf3ba0835a8100ddf399ce9940 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 24 Jul 2013 12:06:46 +0530 Subject: [PATCH 157/942] staging: lustre: Remove version.h header inclusion in capa.c version.h header inclusion is not necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/obdclass/capa.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/obdclass/capa.c b/drivers/staging/lustre/lustre/obdclass/capa.c index 3e532f5106e45..5eea9bec054a0 100644 --- a/drivers/staging/lustre/lustre/obdclass/capa.c +++ b/drivers/staging/lustre/lustre/obdclass/capa.c @@ -42,7 +42,6 @@ #define DEBUG_SUBSYSTEM S_SEC -#include #include #include #include -- GitLab From b17984687cea1362f26f4444d9238df876b255ef Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 24 Jul 2013 12:06:47 +0530 Subject: [PATCH 158/942] staging: lustre: Remove version.h header inclusion in linux-sysctl.c version.h header inclusion is not necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c index 7b94cb7b58e04..8fe6a019d1e3a 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c @@ -39,7 +39,6 @@ #include #include #include -#include #include #include #include -- GitLab From 831ed1965233e93b7c9f64b038c2254cad7e3139 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 24 Jul 2013 12:06:48 +0530 Subject: [PATCH 159/942] staging: lustre: Remove version.h header inclusion in obd_mount.c version.h header inclusion is not necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/obdclass/obd_mount.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c b/drivers/staging/lustre/lustre/obdclass/obd_mount.c index f5585ccaff19d..28d174ab750d0 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c @@ -50,7 +50,6 @@ #include #include #include -#include #include #include #include -- GitLab From 8688a49cd95839d881948b5b074077d786e3be6c Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 24 Jul 2013 12:06:49 +0530 Subject: [PATCH 160/942] staging: lustre: Remove version.h header inclusion in lproc_osc.c version.h header inclusion is not necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/osc/lproc_osc.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c index d2f219877927d..90d24d8dea21c 100644 --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c @@ -35,7 +35,6 @@ */ #define DEBUG_SUBSYSTEM S_CLASS -#include #include #include #include -- GitLab From 305591a58d855d0f82a582059596124f9a3503c2 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 09:55:00 -0700 Subject: [PATCH 161/942] staging: comedi: ni_mio_common: needs As reported by the kbuild test robot: Commit: d92fef8d2552ffde42b6092cb467f3021ebf8b98 staging: comedi: do not include if its not needed Removed the include from the ni_atmio driver, which did not need it. Unfortunately, this driver includes ni_mio_common.c, which does need it. Add the include of to the ni_mio_common.c source where it is needed. Signed-off-by: H Hartley Sweeten Reported-by: kbuild test robot Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 458331d3fcb77..04f4b7dce332d 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -58,6 +58,7 @@ #include #include +#include #include "8255.h" #include "mite.h" #include "comedi_fc.h" -- GitLab From 76a1de328462f353950ba1e614da1cef1e95bdc1 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 09:55:39 -0700 Subject: [PATCH 162/942] staging: comedi: comedi_buf: needs As reported by the kbuild test robot: Commit: ce157f8032bbd46d9427034c335b0afd751da25d staging: comedi: con't rely on comedidev.h to include headers Removed most the includes from comedidev.h and pushed only the needed ones to all the comedi drivers. This one was missed. Signed-off-by: H Hartley Sweeten Reported-by: kbuild test robot Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_buf.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c index b4c001b6f88f9..94b2385fb0af2 100644 --- a/drivers/staging/comedi/comedi_buf.c +++ b/drivers/staging/comedi/comedi_buf.c @@ -15,6 +15,8 @@ * GNU General Public License for more details. */ +#include + #include "comedidev.h" #include "comedi_internal.h" -- GitLab From 66f42cc2187ea2cc624adda597fc1506ca1af176 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 24 Jul 2013 10:06:35 -0700 Subject: [PATCH 163/942] staging: lustre: remove [f]printf() macros that aren't being used This isn't userspace, it's the kernel, luckily these weren't being used, so just remove them entirely so no one gets any ideas... Cc: Peng Tao Cc: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/include/linux/libcfs/linux/kp30.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/kp30.h b/drivers/staging/lustre/include/linux/libcfs/linux/kp30.h index 2e5c850716478..5bd09ccf3a3c7 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/kp30.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/kp30.h @@ -83,8 +83,6 @@ /******************************************************************************/ -# define fprintf(a, format, b...) CDEBUG(D_OTHER, format , ## b) -# define printf(format, b...) CDEBUG(D_OTHER, format , ## b) # define time(a) CURRENT_TIME /******************************************************************************/ -- GitLab From 0f1c743b992908ac2a31c7fec0e0fcac003deee5 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 24 Jul 2013 10:11:47 -0700 Subject: [PATCH 164/942] staging: lustre: don't use time() or CFS_CURRENT_TIME It's just "CURRENT_TIME", don't redefine a macro for something so simple as that... Cc: Peng Tao Cc: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/include/linux/libcfs/libcfs_private.h | 4 ---- drivers/staging/lustre/include/linux/libcfs/linux/kp30.h | 4 ---- drivers/staging/lustre/lustre/llite/llite_lib.c | 6 +++--- drivers/staging/lustre/lustre/osc/osc_io.c | 4 ++-- 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h index 62ef8a7490023..b033aa499deff 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h @@ -455,10 +455,6 @@ int cfs_match_nid(lnet_nid_t nid, struct list_head *list); /* logical equivalence */ #define equi(a, b) (!!(a) == !!(b)) -#ifndef CFS_CURRENT_TIME -# define CFS_CURRENT_TIME time(0) -#endif - /* -------------------------------------------------------------------- * Light-weight trace * Support for temporary event tracing with minimal Heisenberg effect. diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/kp30.h b/drivers/staging/lustre/include/linux/libcfs/linux/kp30.h index 5bd09ccf3a3c7..073f4d1f176e3 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/kp30.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/kp30.h @@ -81,10 +81,6 @@ #define CFS_SYSFS_MODULE_PARM 1 /* module parameters accessible via sysfs */ -/******************************************************************************/ - -# define time(a) CURRENT_TIME - /******************************************************************************/ /* Light-weight trace * Support for temporary event tracing with minimal Heisenberg effect. */ diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index e8bf49fa7bbfe..890268834510b 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -1408,17 +1408,17 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr) /* We mark all of the fields "set" so MDS/OST does not re-set them */ if (attr->ia_valid & ATTR_CTIME) { - attr->ia_ctime = CFS_CURRENT_TIME; + attr->ia_ctime = CURRENT_TIME; attr->ia_valid |= ATTR_CTIME_SET; } if (!(attr->ia_valid & ATTR_ATIME_SET) && (attr->ia_valid & ATTR_ATIME)) { - attr->ia_atime = CFS_CURRENT_TIME; + attr->ia_atime = CURRENT_TIME; attr->ia_valid |= ATTR_ATIME_SET; } if (!(attr->ia_valid & ATTR_MTIME_SET) && (attr->ia_valid & ATTR_MTIME)) { - attr->ia_mtime = CFS_CURRENT_TIME; + attr->ia_mtime = CURRENT_TIME; attr->ia_valid |= ATTR_MTIME_SET; } diff --git a/drivers/staging/lustre/lustre/osc/osc_io.c b/drivers/staging/lustre/lustre/osc/osc_io.c index 70aad1aeec633..342c46e2c91d3 100644 --- a/drivers/staging/lustre/lustre/osc/osc_io.c +++ b/drivers/staging/lustre/lustre/osc/osc_io.c @@ -523,7 +523,7 @@ static int osc_io_read_start(const struct lu_env *env, cl_object_attr_lock(obj); result = cl_object_attr_get(env, obj, attr); if (result == 0) { - attr->cat_atime = LTIME_S(CFS_CURRENT_TIME); + attr->cat_atime = LTIME_S(CURRENT_TIME); result = cl_object_attr_set(env, obj, attr, CAT_ATIME); } @@ -547,7 +547,7 @@ static int osc_io_write_start(const struct lu_env *env, result = cl_object_attr_get(env, obj, attr); if (result == 0) { attr->cat_mtime = attr->cat_ctime = - LTIME_S(CFS_CURRENT_TIME); + LTIME_S(CURRENT_TIME); result = cl_object_attr_set(env, obj, attr, CAT_MTIME | CAT_CTIME); } -- GitLab From c0426cf7df119c68a9715713f9dbf07862172f04 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 24 Jul 2013 10:21:26 -0700 Subject: [PATCH 165/942] staging: lustre: a typedef for 'struct miscdevice'??? Come on, that's just silly... Anyway, remove the typedef and fix up the initializer to use named fields, otherwise bad things might happen in the future. Cc: Peng Tao Cc: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/include/linux/libcfs/libcfs.h | 5 ----- .../lustre/include/linux/libcfs/linux/linux-prim.h | 14 -------------- .../lustre/lustre/libcfs/linux/linux-module.c | 8 ++++---- drivers/staging/lustre/lustre/libcfs/module.c | 2 +- drivers/staging/lustre/lustre/obdclass/class_obd.c | 2 +- .../lustre/lustre/obdclass/linux/linux-module.c | 2 +- 6 files changed, 7 insertions(+), 26 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/libcfs.h index 2983ce412b662..0f76da5c6c2df 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h @@ -124,11 +124,6 @@ void libcfs_sock_release(socket_t *sock); /* * libcfs pseudo device operations * - * struct psdev_t and - * misc_register() and - * misc_deregister() are declared in - * libcfs//-prim.h - * * It's just draft now. */ diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h index acdf7ee089f21..03903ab8f0ccb 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h @@ -78,20 +78,6 @@ #define NR_CPUS 1 #endif -/* - * cache - */ - -/* - * IRQs - */ - - -/* - * Pseudo device register - */ -typedef struct miscdevice psdev_t; - /* * Sysctl register */ diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c index 6b0054ff79159..d8f320e6f4b61 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c @@ -176,8 +176,8 @@ static struct file_operations libcfs_fops = { release : libcfs_psdev_release }; -psdev_t libcfs_dev = { - LNET_MINOR, - "lnet", - &libcfs_fops +struct miscdevice libcfs_dev = { + .minor = LNET_MINOR, + .name = "lnet", + .fops = &libcfs_fops, }; diff --git a/drivers/staging/lustre/lustre/libcfs/module.c b/drivers/staging/lustre/lustre/libcfs/module.c index 3372537c6f3b4..52525bc7ddb08 100644 --- a/drivers/staging/lustre/lustre/libcfs/module.c +++ b/drivers/staging/lustre/lustre/libcfs/module.c @@ -365,7 +365,7 @@ MODULE_AUTHOR("Peter J. Braam "); MODULE_DESCRIPTION("Portals v3.1"); MODULE_LICENSE("GPL"); -extern psdev_t libcfs_dev; +extern struct miscdevice libcfs_dev; extern struct rw_semaphore cfs_tracefile_sem; extern struct mutex cfs_trace_thread_mutex; extern struct cfs_wi_sched *cfs_sched_rehash; diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c index 799a1ed8701f3..deebf806cde04 100644 --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c @@ -432,7 +432,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) RETURN(err); } /* class_handle_ioctl */ -extern psdev_t obd_psdev; +extern struct miscdevice obd_psdev; #define OBD_INIT_CHECK int obd_init_checks(void) diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c index 2abacf2065316..9fe53f3a98ce8 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c @@ -211,7 +211,7 @@ static struct file_operations obd_psdev_fops = { }; /* modules setup */ -psdev_t obd_psdev = { +struct miscdevice obd_psdev = { .minor = OBD_DEV_MINOR, .name = OBD_DEV_NAME, .fops = &obd_psdev_fops, -- GitLab From 847e0fb220799debd44cb4b8526a248a287913d9 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 24 Jul 2013 10:25:17 -0700 Subject: [PATCH 166/942] staging: lustre: NR_CPUS is always defined So don't redefine it. Cc: Peng Tao Cc: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/include/linux/libcfs/linux/linux-cpu.h | 1 - .../staging/lustre/include/linux/libcfs/linux/linux-prim.h | 5 ----- .../lustre/include/linux/libcfs/linux/portals_compat25.h | 5 ----- 3 files changed, 11 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h index 36928791e75d0..8dd354d51606c 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-cpu.h @@ -81,7 +81,6 @@ struct cfs_cpt_table { /** * comment out definitions for compatible layer - * #define CFS_CPU_NR NR_CPUS * * typedef cpumask_t cfs_cpumask_t; * diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h index 03903ab8f0ccb..e2a6c10ae4e69 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h @@ -73,11 +73,6 @@ #define cfs_for_each_possible_cpu(cpu) for_each_cpu(cpu) #endif -#ifdef NR_CPUS -#else -#define NR_CPUS 1 -#endif - /* * Sysctl register */ diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/portals_compat25.h b/drivers/staging/lustre/include/linux/libcfs/linux/portals_compat25.h index 132a4bec35757..6cf758dbf9ef4 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/portals_compat25.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/portals_compat25.h @@ -104,11 +104,6 @@ int proc_call_handler(void *data, int write, #define cfs_for_each_possible_cpu(cpu) for_each_cpu(cpu) #endif -#ifdef NR_CPUS -#else -#define NR_CPUS 1 -#endif - #define cfs_register_sysctl_table(t, a) register_sysctl_table(t) #endif /* _PORTALS_COMPAT_H */ -- GitLab From 78eb90927139abc3048056820611722f4b5247f6 Mon Sep 17 00:00:00 2001 From: Thomas Leibovici Date: Thu, 25 Jul 2013 01:17:24 +0800 Subject: [PATCH 167/942] staging/lustre/lmv: support DNE with HSM. Send HSM requests to the appropriate MDT. Split lists of fids of HSM actions into one list per MDT. Move kuc registration/unregistration from MDC to LMV as this is not MDT related. Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3365 Lustre-change: http://review.whamcloud.com/6714 Signed-off-by: Thomas Leibovici Reviewed-by: John L. Hammond Reviewed-by: jacques-Charles Lafoucriere Reviewed-by: Oleg Drokin Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 200 +++++++++++++++++- .../staging/lustre/lustre/mdc/mdc_request.c | 18 +- 2 files changed, 205 insertions(+), 13 deletions(-) diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index 5bd952a6dd653..11c8d644d5ea8 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -44,6 +44,7 @@ #include #include #include +#include #include #include @@ -783,6 +784,125 @@ static int lmv_fid2path(struct obd_export *exp, int len, void *karg, void *uarg) RETURN(rc); } +static int lmv_hsm_req_count(struct lmv_obd *lmv, + const struct hsm_user_request *hur, + const struct lmv_tgt_desc *tgt_mds) +{ + int i, nr = 0; + struct lmv_tgt_desc *curr_tgt; + + /* count how many requests must be sent to the given target */ + for (i = 0; i < hur->hur_request.hr_itemcount; i++) { + curr_tgt = lmv_find_target(lmv, &hur->hur_user_item[i].hui_fid); + if (obd_uuid_equals(&curr_tgt->ltd_uuid, &tgt_mds->ltd_uuid)) + nr++; + } + return nr; +} + +static void lmv_hsm_req_build(struct lmv_obd *lmv, + struct hsm_user_request *hur_in, + const struct lmv_tgt_desc *tgt_mds, + struct hsm_user_request *hur_out) +{ + int i, nr_out; + struct lmv_tgt_desc *curr_tgt; + + /* build the hsm_user_request for the given target */ + hur_out->hur_request = hur_in->hur_request; + nr_out = 0; + for (i = 0; i < hur_in->hur_request.hr_itemcount; i++) { + curr_tgt = lmv_find_target(lmv, + &hur_in->hur_user_item[i].hui_fid); + if (obd_uuid_equals(&curr_tgt->ltd_uuid, &tgt_mds->ltd_uuid)) { + hur_out->hur_user_item[nr_out] = + hur_in->hur_user_item[i]; + nr_out++; + } + } + hur_out->hur_request.hr_itemcount = nr_out; + memcpy(hur_data(hur_out), hur_data(hur_in), + hur_in->hur_request.hr_data_len); +} + +static int lmv_hsm_ct_unregister(struct lmv_obd *lmv, unsigned int cmd, int len, + struct lustre_kernelcomm *lk, void *uarg) +{ + int i, rc = 0; + ENTRY; + + /* unregister request (call from llapi_hsm_copytool_fini) */ + for (i = 0; i < lmv->desc.ld_tgt_count; i++) { + /* best effort: try to clean as much as possible + * (continue on error) */ + obd_iocontrol(cmd, lmv->tgts[i]->ltd_exp, len, lk, uarg); + } + + /* Whatever the result, remove copytool from kuc groups. + * Unreached coordinators will get EPIPE on next requests + * and will unregister automatically. + */ + rc = libcfs_kkuc_group_rem(lk->lk_uid, lk->lk_group); + RETURN(rc); +} + +static int lmv_hsm_ct_register(struct lmv_obd *lmv, unsigned int cmd, int len, + struct lustre_kernelcomm *lk, void *uarg) +{ + struct file *filp; + int i, j, err; + int rc = 0; + bool any_set = false; + ENTRY; + + /* All or nothing: try to register to all MDS. + * In case of failure, unregister from previous MDS, + * except if it because of inactive target. */ + for (i = 0; i < lmv->desc.ld_tgt_count; i++) { + err = obd_iocontrol(cmd, lmv->tgts[i]->ltd_exp, + len, lk, uarg); + if (err) { + if (lmv->tgts[i]->ltd_active) { + /* permanent error */ + CERROR("error: iocontrol MDC %s on MDT" + "idx %d cmd %x: err = %d\n", + lmv->tgts[i]->ltd_uuid.uuid, + i, cmd, err); + rc = err; + lk->lk_flags |= LK_FLG_STOP; + /* unregister from previous MDS */ + for (j = 0; j < i; j++) + obd_iocontrol(cmd, + lmv->tgts[j]->ltd_exp, + len, lk, uarg); + RETURN(rc); + } + /* else: transient error. + * kuc will register to the missing MDT + * when it is back */ + } else { + any_set = true; + } + } + + if (!any_set) + /* no registration done: return error */ + RETURN(-ENOTCONN); + + /* at least one registration done, with no failure */ + filp = fget(lk->lk_wfd); + if (filp == NULL) { + RETURN(-EBADF); + } + rc = libcfs_kkuc_group_add(filp, lk->lk_uid, lk->lk_group, lk->lk_data); + if (rc != 0 && filp != NULL) + fput(filp); + RETURN(rc); +} + + + + static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, int len, void *karg, void *uarg) { @@ -908,7 +1028,77 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, } case LL_IOC_HSM_STATE_GET: case LL_IOC_HSM_STATE_SET: - case LL_IOC_HSM_ACTION: + case LL_IOC_HSM_ACTION: { + struct md_op_data *op_data = karg; + struct lmv_tgt_desc *tgt; + + tgt = lmv_find_target(lmv, &op_data->op_fid1); + if (IS_ERR(tgt)) + RETURN(PTR_ERR(tgt)); + + if (tgt->ltd_exp == NULL) + RETURN(-EINVAL); + + rc = obd_iocontrol(cmd, tgt->ltd_exp, len, karg, uarg); + break; + } + case LL_IOC_HSM_PROGRESS: { + const struct hsm_progress_kernel *hpk = karg; + struct lmv_tgt_desc *tgt; + + tgt = lmv_find_target(lmv, &hpk->hpk_fid); + if (IS_ERR(tgt)) + RETURN(PTR_ERR(tgt)); + rc = obd_iocontrol(cmd, tgt->ltd_exp, len, karg, uarg); + break; + } + case LL_IOC_HSM_REQUEST: { + struct hsm_user_request *hur = karg; + struct lmv_tgt_desc *tgt; + unsigned int reqcount = hur->hur_request.hr_itemcount; + + if (reqcount == 0) + RETURN(0); + + /* if the request is about a single fid + * or if there is a single MDS, no need to split + * the request. */ + if (reqcount == 1 || count == 1) { + tgt = lmv_find_target(lmv, + &hur->hur_user_item[0].hui_fid); + if (IS_ERR(tgt)) + RETURN(PTR_ERR(tgt)); + rc = obd_iocontrol(cmd, tgt->ltd_exp, len, karg, uarg); + } else { + /* split fid list to their respective MDS */ + for (i = 0; i < count; i++) { + unsigned int nr, reqlen; + int rc1; + struct hsm_user_request *req; + + nr = lmv_hsm_req_count(lmv, hur, lmv->tgts[i]); + if (nr == 0) /* nothing for this MDS */ + continue; + + /* build a request with fids for this MDS */ + reqlen = offsetof(typeof(*hur), + hur_user_item[nr]) + + hur->hur_request.hr_data_len; + OBD_ALLOC_LARGE(req, reqlen); + if (req == NULL) + RETURN(-ENOMEM); + + lmv_hsm_req_build(lmv, hur, lmv->tgts[i], req); + + rc1 = obd_iocontrol(cmd, lmv->tgts[i]->ltd_exp, + reqlen, req, uarg); + if (rc1 != 0 && rc == 0) + rc = rc1; + OBD_FREE_LARGE(req, reqlen); + } + } + break; + } case LL_IOC_LOV_SWAP_LAYOUTS: { struct md_op_data *op_data = karg; struct lmv_tgt_desc *tgt1, *tgt2; @@ -931,6 +1121,14 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, rc = obd_iocontrol(cmd, tgt1->ltd_exp, len, karg, uarg); break; } + case LL_IOC_HSM_CT_START: { + struct lustre_kernelcomm *lk = karg; + if (lk->lk_flags & LK_FLG_STOP) + rc = lmv_hsm_ct_unregister(lmv, cmd, len, lk, uarg); + else + rc = lmv_hsm_ct_register(lmv, cmd, len, lk, uarg); + break; + } default: for (i = 0; i < count; i++) { struct obd_device *mdc_obd; diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index b8bf2dcee09fb..191edc6470cd0 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -1771,6 +1771,9 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, GOTO(out, rc); case LL_IOC_HSM_CT_START: rc = mdc_ioc_hsm_ct_start(exp, karg); + /* ignore if it was already registered on this MDS. */ + if (rc == -EEXIST) + rc = 0; GOTO(out, rc); case LL_IOC_HSM_PROGRESS: rc = mdc_ioc_hsm_progress(exp, karg); @@ -1988,19 +1991,10 @@ static int mdc_ioc_hsm_ct_start(struct obd_export *exp, lk->lk_uid, lk->lk_group, lk->lk_flags); if (lk->lk_flags & LK_FLG_STOP) { - rc = libcfs_kkuc_group_rem(lk->lk_uid, lk->lk_group); /* Unregister with the coordinator */ - if (rc == 0) - rc = mdc_ioc_hsm_ct_unregister(imp); + rc = mdc_ioc_hsm_ct_unregister(imp); } else { - struct file *fp = fget(lk->lk_wfd); - - rc = libcfs_kkuc_group_add(fp, lk->lk_uid, lk->lk_group, - lk->lk_data); - if (rc && fp) - fput(fp); - if (rc == 0) - rc = mdc_ioc_hsm_ct_register(imp, archive); + rc = mdc_ioc_hsm_ct_register(imp, archive); } return rc; @@ -2325,7 +2319,7 @@ static int mdc_import_event(struct obd_device *obd, struct obd_import *imp, } case IMP_EVENT_ACTIVE: rc = obd_notify_observer(obd, obd, OBD_NOTIFY_ACTIVE, NULL); - /* restore re-establish kuc registration after reconnecting */ + /* redo the kuc registration after reconnecting */ if (rc == 0) rc = mdc_kuc_reregister(imp); break; -- GitLab From 8a48df7080b2fa0aed2b8df74437a39217c1eb8c Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Thu, 25 Jul 2013 01:17:25 +0800 Subject: [PATCH 168/942] staging/lustre/llite: handle io init failure in ll_fault_io_init() In ll_fault_io_init(), if cl_io_init() has failed then cleanup and return an ERR_PTR(). This fixes an oops in the page fault handling code when a partially initialized io is used. In ll_page_mkwrite0() do not call cl_io_fini() on an ERR_PTR(). Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3487 Lustre-change: http://review.whamcloud.com/6735 Signed-off-by: John L. Hammond Reviewed-by: Lai Siyao Reviewed-by: Jinshan Xiong Reviewed-by: Oleg Drokin Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lustre/llite/llite_mmap.c | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_mmap.c b/drivers/staging/lustre/lustre/llite/llite_mmap.c index 32a57e85300b8..a4061ee15b62b 100644 --- a/drivers/staging/lustre/lustre/llite/llite_mmap.c +++ b/drivers/staging/lustre/lustre/llite/llite_mmap.c @@ -106,11 +106,12 @@ struct cl_io *ll_fault_io_init(struct vm_area_struct *vma, struct cl_env_nest *nest, pgoff_t index, unsigned long *ra_flags) { - struct file *file = vma->vm_file; - struct inode *inode = file->f_dentry->d_inode; - struct cl_io *io; - struct cl_fault_io *fio; - struct lu_env *env; + struct file *file = vma->vm_file; + struct inode *inode = file->f_dentry->d_inode; + struct cl_io *io; + struct cl_fault_io *fio; + struct lu_env *env; + int rc; ENTRY; *env_ret = NULL; @@ -151,17 +152,22 @@ struct cl_io *ll_fault_io_init(struct vm_area_struct *vma, CDEBUG(D_MMAP, "vm_flags: %lx (%lu %d)\n", vma->vm_flags, fio->ft_index, fio->ft_executable); - if (cl_io_init(env, io, CIT_FAULT, io->ci_obj) == 0) { + rc = cl_io_init(env, io, CIT_FAULT, io->ci_obj); + if (rc == 0) { struct ccc_io *cio = ccc_env_io(env); struct ll_file_data *fd = LUSTRE_FPRIVATE(file); LASSERT(cio->cui_cl.cis_io == io); - /* mmap lock must be MANDATORY - * it has to cache pages. */ + /* mmap lock must be MANDATORY it has to cache + * pages. */ io->ci_lockreq = CILR_MANDATORY; - - cio->cui_fd = fd; + cio->cui_fd = fd; + } else { + LASSERT(rc < 0); + cl_io_fini(env, io); + cl_env_nested_put(nest, env); + io = ERR_PTR(rc); } return io; @@ -189,7 +195,7 @@ static int ll_page_mkwrite0(struct vm_area_struct *vma, struct page *vmpage, result = io->ci_result; if (result < 0) - GOTO(out, result); + GOTO(out_io, result); io->u.ci_fault.ft_mkwrite = 1; io->u.ci_fault.ft_writable = 1; @@ -251,14 +257,14 @@ static int ll_page_mkwrite0(struct vm_area_struct *vma, struct page *vmpage, } EXIT; -out: +out_io: cl_io_fini(env, io); cl_env_nested_put(&nest, env); - +out: CDEBUG(D_MMAP, "%s mkwrite with %d\n", current->comm, result); - LASSERT(ergo(result == 0, PageLocked(vmpage))); - return(result); + + return result; } -- GitLab From f84d3d4735a1c96a745c453de8390936a7eb72d3 Mon Sep 17 00:00:00 2001 From: Sebastien Buisson Date: Thu, 25 Jul 2013 01:17:26 +0800 Subject: [PATCH 169/942] staging/lustre: fix 'data race condition' issues in at_reset() Fix 'data race condition' defects found by Coverity version 6.5.0: Data race condition (MISSING_LOCK) Accessing variable without holding lock. Elsewhere, this variable is accessed with lock held. at_reset() needs to take at->at_lock before modifying its members. Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2744 Lustre-change: http://review.whamcloud.com/6569 Signed-off-by: Sebastien Buisson Reviewed-by: Bob Glossman Reviewed-by: Keith Mannthey Reviewed-by: Oleg Drokin Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/lustre_import.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/lustre/lustre/include/lustre_import.h b/drivers/staging/lustre/lustre/include/lustre_import.h index 3a5dd6a94c08e..67259eb43cde1 100644 --- a/drivers/staging/lustre/lustre/include/lustre_import.h +++ b/drivers/staging/lustre/lustre/include/lustre_import.h @@ -336,9 +336,11 @@ static inline unsigned int at_timeout2est(unsigned int val) } static inline void at_reset(struct adaptive_timeout *at, int val) { + spin_lock(&at->at_lock); at->at_current = val; at->at_worst_ever = val; at->at_worst_time = cfs_time_current_sec(); + spin_unlock(&at->at_lock); } static inline void at_init(struct adaptive_timeout *at, int val, int flags) { memset(at, 0, sizeof(*at)); -- GitLab From ae5ef67b9a71dba0dc4b045cca102c4ab3c0bd5f Mon Sep 17 00:00:00 2001 From: Sebastien Buisson Date: Thu, 25 Jul 2013 01:17:27 +0800 Subject: [PATCH 170/942] staging/lustre/llite: fix 'data race condition' issues of lli_flags Fix 'data race condition' defects found by Coverity version 6.5.0: Data race condition (MISSING_LOCK) Accessing variable without holding lock. Elsewhere, this variable is accessed with lock held. lli->lli_flags need to be protected by lli->lli_lock. Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2744 Lustre-change: http://review.whamcloud.com/6571 Signed-off-by: Sebastien Buisson Reviewed-by: Fan Yong Reviewed-by: Keith Mannthey Reviewed-by: Oleg Drokin Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/llite_lib.c | 4 ++++ drivers/staging/lustre/lustre/llite/namei.c | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 890268834510b..b44a3d6d0eddf 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -1189,7 +1189,9 @@ void ll_clear_inode(struct inode *inode) LASSERT(lli->lli_opendir_pid == 0); } + spin_lock(&lli->lli_lock); ll_i2info(inode)->lli_flags &= ~LLIF_MDS_SIZE_LOCK; + spin_unlock(&lli->lli_lock); md_null_inode(sbi->ll_md_exp, ll_inode2fid(inode)); LASSERT(!lli->lli_open_fd_write_count); @@ -1756,7 +1758,9 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md) /* Use old size assignment to avoid * deadlock bz14138 & bz14326 */ i_size_write(inode, body->size); + spin_lock(&lli->lli_lock); lli->lli_flags |= LLIF_MDS_SIZE_LOCK; + spin_unlock(&lli->lli_lock); } ldlm_lock_decref(&lockh, mode); } diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c index 8e948a71dd644..333e55f692f19 100644 --- a/drivers/staging/lustre/lustre/llite/namei.c +++ b/drivers/staging/lustre/lustre/llite/namei.c @@ -275,8 +275,11 @@ int ll_md_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, CDEBUG(D_INODE, "invaliding layout %d.\n", rc); } - if (bits & MDS_INODELOCK_UPDATE) + if (bits & MDS_INODELOCK_UPDATE) { + spin_lock(&lli->lli_lock); lli->lli_flags &= ~LLIF_MDS_SIZE_LOCK; + spin_unlock(&lli->lli_lock); + } if (S_ISDIR(inode->i_mode) && (bits & MDS_INODELOCK_UPDATE)) { -- GitLab From 631abc6e65a7777afcdfa126343db99eaba03c3b Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Thu, 25 Jul 2013 01:17:30 +0800 Subject: [PATCH 171/942] staging/lustre/obdclass: use a dummy structure for lu_ref_link Move the definition of struct lu_ref_link to lu_ref.h. If USE_LU_REF is not defined then define it to be the empty struct. Change the return type of lu_ref_add() and lu_ref_add_atomic() to void. Add lu_ref_add_at() taking same arguments as lu_ref_add() togerther with a pointer to a struct lu_ref_link and returning void. Adjust all structures containing a lu_ref_link pointer to contain a struct lu_ref_link instead. Use lu_ref_add_at() and lu_ref_del_at() to handle embedded lu_ref_links. [Original patch mainly changes lu_ref.[ch] but in upstream client we don't have lu_ref code in the hope of moving to kobject refcounting. So the patch only picks the other pieces of original patch, in order to keep code in sync and make it easier to port future patches.] Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3059 Lustre-change: http://review.whamcloud.com/5920 Signed-off-by: John L. Hammond Reviewed-by: Alex Zhuravlev Reviewed-by: Jinshan Xiong Reviewed-by: Mike Pershin Reviewed-by: Oleg Drokin Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lustre/include/cl_object.h | 10 +++++----- .../staging/lustre/lustre/include/lu_object.h | 18 +++++++++++++----- drivers/staging/lustre/lustre/include/lu_ref.h | 14 +++++++++++++- drivers/staging/lustre/lustre/obdclass/cl_io.c | 17 +++++++++-------- .../staging/lustre/lustre/obdclass/cl_lock.c | 6 +++--- .../staging/lustre/lustre/obdclass/cl_page.c | 5 +++-- .../staging/lustre/lustre/obdclass/lu_object.c | 15 ++++++++------- drivers/staging/lustre/lustre/osc/osc_cache.c | 8 +++++--- 8 files changed, 59 insertions(+), 34 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h index 4bb68801d3a94..4a478504c45ee 100644 --- a/drivers/staging/lustre/lustre/include/cl_object.h +++ b/drivers/staging/lustre/lustre/include/cl_object.h @@ -768,11 +768,11 @@ struct cl_page { /** List of references to this page, for debugging. */ struct lu_ref cp_reference; /** Link to an object, for debugging. */ - struct lu_ref_link *cp_obj_ref; + struct lu_ref_link cp_obj_ref; /** Link to a queue, for debugging. */ - struct lu_ref_link *cp_queue_ref; + struct lu_ref_link cp_queue_ref; /** Per-page flags from enum cl_page_flags. Protected by a VM lock. */ - unsigned cp_flags; + unsigned cp_flags; /** Assigned if doing a sync_io */ struct cl_sync_io *cp_sync_io; }; @@ -1625,7 +1625,7 @@ struct cl_lock { /** * A reference for cl_lock::cll_descr::cld_obj. For debugging. */ - struct lu_ref_link *cll_obj_ref; + struct lu_ref_link cll_obj_ref; #ifdef CONFIG_LOCKDEP /* "dep_map" name is assumed by lockdep.h macros. */ struct lockdep_map dep_map; @@ -2517,7 +2517,7 @@ struct cl_req_obj { /** object itself */ struct cl_object *ro_obj; /** reference to cl_req_obj::ro_obj. For debugging. */ - struct lu_ref_link *ro_obj_ref; + struct lu_ref_link ro_obj_ref; /* something else? Number of pages for a given object? */ }; diff --git a/drivers/staging/lustre/lustre/include/lu_object.h b/drivers/staging/lustre/lustre/include/lu_object.h index 94760481bd30c..8077898e88ec9 100644 --- a/drivers/staging/lustre/lustre/include/lu_object.h +++ b/drivers/staging/lustre/lustre/include/lu_object.h @@ -496,7 +496,7 @@ struct lu_object { /** * Link to the device, for debugging. */ - struct lu_ref_link *lo_dev_ref; + struct lu_ref_link lo_dev_ref; }; enum lu_object_header_flags { @@ -873,11 +873,19 @@ static inline __u32 lu_object_attr(const struct lu_object *o) return o->lo_header->loh_attr; } -static inline struct lu_ref_link *lu_object_ref_add(struct lu_object *o, - const char *scope, - const void *source) +static inline void lu_object_ref_add(struct lu_object *o, + const char *scope, + const void *source) { - return lu_ref_add(&o->lo_header->loh_reference, scope, source); + lu_ref_add(&o->lo_header->loh_reference, scope, source); +} + +static inline void lu_object_ref_add_at(struct lu_object *o, + struct lu_ref_link *link, + const char *scope, + const void *source) +{ + lu_ref_add_at(&o->lo_header->loh_reference, link, scope, source); } static inline void lu_object_ref_del(struct lu_object *o, diff --git a/drivers/staging/lustre/lustre/include/lu_ref.h b/drivers/staging/lustre/lustre/include/lu_ref.h index 624c19be15240..50a2a7f786dc5 100644 --- a/drivers/staging/lustre/lustre/include/lu_ref.h +++ b/drivers/staging/lustre/lustre/include/lu_ref.h @@ -108,7 +108,12 @@ */ -struct lu_ref {}; +/* + * dummy data structures/functions to pass compile for now. + * We need to reimplement them with kref. + */ +struct lu_ref {}; +struct lu_ref_link {}; static inline void lu_ref_init(struct lu_ref *ref) { @@ -132,6 +137,13 @@ static inline struct lu_ref_link *lu_ref_add_atomic(struct lu_ref *ref, return NULL; } +static inline void lu_ref_add_at(struct lu_ref *ref, + struct lu_ref_link *link, + const char *scope, + const void *source) +{ +} + static inline void lu_ref_del(struct lu_ref *ref, const char *scope, const void *source) { diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c index 75c9be8875e08..f3f03154f094e 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_io.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c @@ -1105,7 +1105,7 @@ void cl_page_list_add(struct cl_page_list *plist, struct cl_page *page) LASSERT(list_empty(&page->cp_batch)); list_add_tail(&page->cp_batch, &plist->pl_pages); ++plist->pl_nr; - page->cp_queue_ref = lu_ref_add(&page->cp_reference, "queue", plist); + lu_ref_add_at(&page->cp_reference, &page->cp_queue_ref, "queue", plist); cl_page_get(page); EXIT; } @@ -1126,7 +1126,7 @@ void cl_page_list_del(const struct lu_env *env, mutex_unlock(&page->cp_mutex); lockdep_on(); --plist->pl_nr; - lu_ref_del_at(&page->cp_reference, page->cp_queue_ref, "queue", plist); + lu_ref_del_at(&page->cp_reference, &page->cp_queue_ref, "queue", plist); cl_page_put(env, page); EXIT; } @@ -1146,8 +1146,8 @@ void cl_page_list_move(struct cl_page_list *dst, struct cl_page_list *src, list_move_tail(&page->cp_batch, &dst->pl_pages); --src->pl_nr; ++dst->pl_nr; - lu_ref_set_at(&page->cp_reference, - page->cp_queue_ref, "queue", src, dst); + lu_ref_set_at(&page->cp_reference, &page->cp_queue_ref, "queue", + src, dst); EXIT; } EXPORT_SYMBOL(cl_page_list_move); @@ -1202,7 +1202,8 @@ void cl_page_list_disown(const struct lu_env *env, * XXX cl_page_disown0() will fail if page is not locked. */ cl_page_disown0(env, io, page); - lu_ref_del(&page->cp_reference, "queue", plist); + lu_ref_del_at(&page->cp_reference, &page->cp_queue_ref, "queue", + plist); cl_page_put(env, page); } EXIT; @@ -1449,7 +1450,7 @@ static void cl_req_free(const struct lu_env *env, struct cl_req *req) struct cl_object *obj = req->crq_o[i].ro_obj; if (obj != NULL) { lu_object_ref_del_at(&obj->co_lu, - req->crq_o[i].ro_obj_ref, + &req->crq_o[i].ro_obj_ref, "cl_req", req); cl_object_put(env, obj); } @@ -1570,8 +1571,8 @@ void cl_req_page_add(const struct lu_env *env, if (rqo->ro_obj == NULL) { rqo->ro_obj = obj; cl_object_get(obj); - rqo->ro_obj_ref = lu_object_ref_add(&obj->co_lu, - "cl_req", req); + lu_object_ref_add_at(&obj->co_lu, &rqo->ro_obj_ref, + "cl_req", req); break; } } diff --git a/drivers/staging/lustre/lustre/obdclass/cl_lock.c b/drivers/staging/lustre/lustre/obdclass/cl_lock.c index d34e044fc8542..958c1e531cfba 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_lock.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_lock.c @@ -267,7 +267,7 @@ static void cl_lock_free(const struct lu_env *env, struct cl_lock *lock) } CS_LOCK_DEC(obj, total); CS_LOCKSTATE_DEC(obj, lock->cll_state); - lu_object_ref_del_at(&obj->co_lu, lock->cll_obj_ref, "cl_lock", lock); + lu_object_ref_del_at(&obj->co_lu, &lock->cll_obj_ref, "cl_lock", lock); cl_object_put(env, obj); lu_ref_fini(&lock->cll_reference); lu_ref_fini(&lock->cll_holders); @@ -373,8 +373,8 @@ static struct cl_lock *cl_lock_alloc(const struct lu_env *env, lock->cll_descr = *descr; lock->cll_state = CLS_NEW; cl_object_get(obj); - lock->cll_obj_ref = lu_object_ref_add(&obj->co_lu, - "cl_lock", lock); + lu_object_ref_add_at(&obj->co_lu, &lock->cll_obj_ref, "cl_lock", + lock); INIT_LIST_HEAD(&lock->cll_layers); INIT_LIST_HEAD(&lock->cll_linkage); INIT_LIST_HEAD(&lock->cll_inclosure); diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c index bb9335911c345..d9ca5d5005707 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_page.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c @@ -270,7 +270,7 @@ static void cl_page_free(const struct lu_env *env, struct cl_page *page) } CS_PAGE_DEC(obj, total); CS_PAGESTATE_DEC(obj, page->cp_state); - lu_object_ref_del_at(&obj->co_lu, page->cp_obj_ref, "cl_page", page); + lu_object_ref_del_at(&obj->co_lu, &page->cp_obj_ref, "cl_page", page); cl_object_put(env, obj); lu_ref_fini(&page->cp_reference); OBD_FREE(page, pagesize); @@ -305,7 +305,8 @@ static struct cl_page *cl_page_alloc(const struct lu_env *env, atomic_inc(&page->cp_ref); page->cp_obj = o; cl_object_get(o); - page->cp_obj_ref = lu_object_ref_add(&o->co_lu, "cl_page",page); + lu_object_ref_add_at(&o->co_lu, &page->cp_obj_ref, "cl_page", + page); page->cp_index = ind; cl_page_state_set_trust(page, CPS_CACHED); page->cp_type = type; diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c index ce0444f6911ce..896f24a8b3b62 100644 --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c @@ -1147,15 +1147,16 @@ EXPORT_SYMBOL(lu_device_fini); * Initialize object \a o that is part of compound object \a h and was created * by device \a d. */ -int lu_object_init(struct lu_object *o, - struct lu_object_header *h, struct lu_device *d) +int lu_object_init(struct lu_object *o, struct lu_object_header *h, + struct lu_device *d) { - memset(o, 0, sizeof *o); + memset(o, 0, sizeof(*o)); o->lo_header = h; - o->lo_dev = d; + o->lo_dev = d; lu_device_get(d); - o->lo_dev_ref = lu_ref_add(&d->ld_reference, "lu_object", o); + lu_ref_add_at(&d->ld_reference, &o->lo_dev_ref, "lu_object", o); INIT_LIST_HEAD(&o->lo_linkage); + return 0; } EXPORT_SYMBOL(lu_object_init); @@ -1170,8 +1171,8 @@ void lu_object_fini(struct lu_object *o) LASSERT(list_empty(&o->lo_linkage)); if (dev != NULL) { - lu_ref_del_at(&dev->ld_reference, - o->lo_dev_ref , "lu_object", o); + lu_ref_del_at(&dev->ld_reference, &o->lo_dev_ref, + "lu_object", o); lu_device_put(dev); o->lo_dev = NULL; } diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index 0a0ec6f7d2dd4..6b0a842dfca0b 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -2064,7 +2064,7 @@ static void osc_check_rpcs(const struct lu_env *env, struct client_obd *cli, while ((osc = osc_next_obj(cli)) != NULL) { struct cl_object *obj = osc2cl(osc); - struct lu_ref_link *link; + struct lu_ref_link link; OSC_IO_DEBUG(osc, "%lu in flight\n", rpcs_in_flight(cli)); @@ -2075,7 +2075,8 @@ static void osc_check_rpcs(const struct lu_env *env, struct client_obd *cli, cl_object_get(obj); client_obd_list_unlock(&cli->cl_loi_list_lock); - link = lu_object_ref_add(&obj->co_lu, "check", current); + lu_object_ref_add_at(&obj->co_lu, &link, "check", + current); /* attempt some read/write balancing by alternating between * reads and writes in an object. The makes_rpc checks here @@ -2116,7 +2117,8 @@ static void osc_check_rpcs(const struct lu_env *env, struct client_obd *cli, osc_object_unlock(osc); osc_list_maint(cli, osc); - lu_object_ref_del_at(&obj->co_lu, link, "check", current); + lu_object_ref_del_at(&obj->co_lu, &link, "check", + current); cl_object_put(env, obj); client_obd_list_lock(&cli->cl_loi_list_lock); -- GitLab From 0dd6f4a414ef45a6b562566a31e1bb46fccdaf45 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 12:23:34 -0700 Subject: [PATCH 172/942] staging: comedi: mite.h: needs As reported by the kbuild test robot: Commit: 0bdab509bf9c6d838dc0a3b1d68bbf841fc20b5a staging: comedi: usee comedi_alloc_devpriv Removed the include of from many of the comedi drivers. Unfortunately, this header uses kfree() in an inline function. Instead of adding to each of the drivers that use this header, include slab.h here. Signed-off-by: H Hartley Sweeten Reported-by: kbuild test robot Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.h | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/comedi/drivers/mite.h b/drivers/staging/comedi/drivers/mite.h index d4487e888e64f..8423b8bf33845 100644 --- a/drivers/staging/comedi/drivers/mite.h +++ b/drivers/staging/comedi/drivers/mite.h @@ -21,6 +21,7 @@ #include #include +#include #include "../comedidev.h" /* #define DEBUG_MITE */ -- GitLab From 46fd3c61e21a2906b2444ee854bcfefda60bcc4c Mon Sep 17 00:00:00 2001 From: Liu Xuezhao Date: Thu, 25 Jul 2013 02:08:17 +0800 Subject: [PATCH 173/942] staging/lustre/obdclass: add obd_target.h Move some server-side data structures form obd.h to obd_target.h. To remove some code dependencies use HAVE_SERVER_SUPPORT to protect some llog/fsfilt_* functions. Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-1330 Lustre-change: http://review.whamcloud.com/2678 Signed-off-by: Liu Xuezhao Signed-off-by: John L. Hammond Reviewed-by: Andreas Dilger Reviewed-by: Peng Tao Reviewed-by: Mike Pershin Signed-off-by: Peng Tao Signed-off-by: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../lustre/include/linux/lustre_fsfilt.h | 10 - .../lustre/lustre/include/lprocfs_status.h | 36 -- drivers/staging/lustre/lustre/include/obd.h | 140 +---- .../staging/lustre/lustre/lvfs/lvfs_linux.c | 1 - .../staging/lustre/lustre/obdclass/Makefile | 2 +- .../lustre/lustre/obdclass/lprocfs_jobstats.c | 560 ------------------ .../lustre/lustre/obdclass/obd_mount.c | 1 - 7 files changed, 3 insertions(+), 747 deletions(-) delete mode 100644 drivers/staging/lustre/lustre/obdclass/lprocfs_jobstats.c diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_fsfilt.h b/drivers/staging/lustre/lustre/include/linux/lustre_fsfilt.h index 6c7260957383f..e637006203ab5 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_fsfilt.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_fsfilt.h @@ -145,16 +145,6 @@ static inline int fsfilt_commit(struct obd_device *obd, struct inode *inode, return rc; } -static inline int fsfilt_map_inode_pages(struct obd_device *obd, - struct inode *inode, - struct page **page, int pages, - unsigned long *blocks, - int create, struct mutex *mutex) -{ - return obd->obd_fsops->fs_map_inode_pages(inode, page, pages, blocks, - create, mutex); -} - static inline int fsfilt_read_record(struct obd_device *obd, struct file *file, void *buf, loff_t size, loff_t *offs) { diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index 7a0536436120e..d7f1be96189b3 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -370,18 +370,6 @@ static inline void s2dhms(struct dhms *ts, time_t secs) #define JOBSTATS_DISABLE "disable" #define JOBSTATS_PROCNAME_UID "procname_uid" -typedef void (*cntr_init_callback)(struct lprocfs_stats *stats); - -struct obd_job_stats { - cfs_hash_t *ojs_hash; - struct list_head ojs_list; - rwlock_t ojs_lock; /* protect the obj_list */ - cntr_init_callback ojs_cntr_init_fn; - int ojs_cntr_num; - int ojs_cleanup_interval; - time_t ojs_last_cleanup; -}; - #ifdef LPROCFS extern int lprocfs_stats_alloc_one(struct lprocfs_stats *stats, @@ -748,16 +736,6 @@ struct file_operations name##_fops = { \ .release = lprocfs_single_release, \ }; -/* lprocfs_jobstats.c */ -int lprocfs_job_stats_log(struct obd_device *obd, char *jobid, - int event, long amount); -void lprocfs_job_stats_fini(struct obd_device *obd); -int lprocfs_job_stats_init(struct obd_device *obd, int cntr_num, - cntr_init_callback fn); -int lprocfs_rd_job_interval(struct seq_file *m, void *data); -int lprocfs_wr_job_interval(struct file *file, const char *buffer, - unsigned long count, void *data); - /* lproc_ptlrpc.c */ struct ptlrpc_request; extern void target_print_req(void *seq_file, struct ptlrpc_request *req); @@ -1018,20 +996,6 @@ __u64 lprocfs_stats_collector(struct lprocfs_stats *stats, int idx, #define LPROC_SEQ_FOPS_RW_TYPE(name, type) #define LPROC_SEQ_FOPS_WR_ONLY(name, type) -/* lprocfs_jobstats.c */ -static inline -int lprocfs_job_stats_log(struct obd_device *obd, char *jobid, int event, - long amount) -{ return 0; } -static inline -void lprocfs_job_stats_fini(struct obd_device *obd) -{ return; } -static inline -int lprocfs_job_stats_init(struct obd_device *obd, int cntr_num, - cntr_init_callback fn) -{ return 0; } - - /* lproc_ptlrpc.c */ #define target_print_req NULL diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index 797a6afbddaa9..094eb96515dcc 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -49,6 +49,8 @@ #define IOC_MDC_MAX_NR 50 #include +#include +#include #include #include #include @@ -56,9 +58,6 @@ #include #include -#include - - #define MAX_OBD_DEVICES 8192 struct osc_async_rc { @@ -254,30 +253,6 @@ struct brw_page { obd_flag flag; }; -/* Individual type definitions */ - -struct ost_server_data; - -struct osd_properties { - size_t osd_max_ea_size; -}; - -#define OBT_MAGIC 0xBDDECEAE -/* hold common fields for "target" device */ -struct obd_device_target { - __u32 obt_magic; - __u32 obt_instance; - struct super_block *obt_sb; - /** last_rcvd file */ - struct file *obt_rcvd_filp; - __u64 obt_mount_count; - struct rw_semaphore obt_rwsem; - struct vfsmount *obt_vfsmnt; - struct file *obt_health_check_filp; - struct osd_properties obt_osd_properties; - struct obd_job_stats obt_jobstats; -}; - /* llog contexts */ enum llog_ctxt_id { LLOG_CONFIG_ORIG_CTXT = 0, @@ -299,94 +274,6 @@ enum llog_ctxt_id { LLOG_MAX_CTXTS }; -#define FILTER_SUBDIR_COUNT 32 /* set to zero for no subdirs */ - -struct filter_subdirs { - struct dentry *dentry[FILTER_SUBDIR_COUNT]; -}; - - -struct filter_ext { - __u64 fe_start; - __u64 fe_end; -}; - -struct filter_obd { - /* NB this field MUST be first */ - struct obd_device_target fo_obt; - const char *fo_fstype; - - int fo_group_count; - struct dentry *fo_dentry_O; - struct dentry **fo_dentry_O_groups; - struct filter_subdirs *fo_dentry_O_sub; - struct mutex fo_init_lock; /* group initialization lock*/ - int fo_committed_group; - - spinlock_t fo_objidlock; /* protect fo_lastobjid */ - - unsigned long fo_destroys_in_progress; - struct mutex fo_create_locks[FILTER_SUBDIR_COUNT]; - - struct list_head fo_export_list; - int fo_subdir_count; - - obd_size fo_tot_dirty; /* protected by obd_osfs_lock */ - obd_size fo_tot_granted; /* all values in bytes */ - obd_size fo_tot_pending; - int fo_tot_granted_clients; - - obd_size fo_readcache_max_filesize; - spinlock_t fo_flags_lock; - unsigned int fo_read_cache:1, /**< enable read-only cache */ - fo_writethrough_cache:1,/**< read cache writes */ - fo_mds_ost_sync:1, /**< MDS-OST orphan recovery*/ - fo_raid_degraded:1;/**< RAID device degraded */ - - struct obd_import *fo_mdc_imp; - struct obd_uuid fo_mdc_uuid; - struct lustre_handle fo_mdc_conn; - struct file **fo_last_objid_files; - __u64 *fo_last_objids; /* last created objid for groups, - * protected by fo_objidlock */ - - struct mutex fo_alloc_lock; - - atomic_t fo_r_in_flight; - atomic_t fo_w_in_flight; - - /* - * per-filter pool of kiobuf's allocated by filter_common_setup() and - * torn down by filter_cleanup(). - * - * This pool contains kiobuf used by - * filter_{prep,commit}rw_{read,write}() and is shared by all OST - * threads. - * - * Locking: protected by internal lock of cfs_hash, pool can be - * found from this hash table by t_id of ptlrpc_thread. - */ - struct cfs_hash *fo_iobuf_hash; - - struct brw_stats fo_filter_stats; - - int fo_fmd_max_num; /* per exp filter_mod_data */ - int fo_fmd_max_age; /* jiffies to fmd expiry */ - unsigned long fo_syncjournal:1, /* sync journal on writes */ - fo_sync_lock_cancel:2;/* sync on lock cancel */ - - - /* sptlrpc stuff */ - rwlock_t fo_sptlrpc_lock; - struct sptlrpc_rule_set fo_sptlrpc_rset; - - /* capability related */ - unsigned int fo_fl_oss_capa; - struct list_head fo_capa_keys; - struct hlist_head *fo_capa_hash; - int fo_sec_level; -}; - struct timeout_item { enum timeout_event ti_event; cfs_time_t ti_timeout; @@ -552,25 +439,6 @@ struct obd_id_info { obd_id *data; }; -/* */ - -struct echo_obd { - struct obd_device_target eo_obt; - struct obdo eo_oa; - spinlock_t eo_lock; - __u64 eo_lastino; - struct lustre_handle eo_nl_lock; - atomic_t eo_prep; -}; - -struct ost_obd { - struct ptlrpc_service *ost_service; - struct ptlrpc_service *ost_create_service; - struct ptlrpc_service *ost_io_service; - struct ptlrpc_service *ost_seq_service; - struct mutex ost_health_mutex; -}; - struct echo_client_obd { struct obd_export *ec_exp; /* the local connection to osc/lov */ spinlock_t ec_lock; @@ -1052,12 +920,8 @@ struct obd_device { int obd_recovery_stage; union { - struct obd_device_target obt; - struct filter_obd filter; struct client_obd cli; - struct ost_obd ost; struct echo_client_obd echo_client; - struct echo_obd echo; struct lov_obd lov; struct lmv_obd lmv; } u; diff --git a/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c b/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c index 80b841a049cdd..9d19d0a79be82 100644 --- a/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c +++ b/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c @@ -46,7 +46,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/staging/lustre/lustre/obdclass/Makefile b/drivers/staging/lustre/lustre/obdclass/Makefile index b80c13c6f5dd5..8a0e08ced454f 100644 --- a/drivers/staging/lustre/lustre/obdclass/Makefile +++ b/drivers/staging/lustre/lustre/obdclass/Makefile @@ -3,7 +3,7 @@ obj-$(CONFIG_LUSTRE_FS) += obdclass.o llog_test.o obdclass-y := linux/linux-module.o linux/linux-obdo.o linux/linux-sysctl.o \ llog.o llog_cat.o llog_obd.o llog_swab.o class_obd.o debug.o \ genops.o uuid.o llog_ioctl.o lprocfs_status.o \ - lprocfs_jobstats.o lustre_handles.o lustre_peer.o llog_osd.o \ + lustre_handles.o lustre_peer.o llog_osd.o \ local_storage.o statfs_pack.o obdo.o obd_config.o obd_mount.o\ mea.o lu_object.o dt_object.o capa.o cl_object.o \ cl_page.o cl_lock.o cl_io.o lu_ref.o acl.o idmap.o \ diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_jobstats.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_jobstats.c deleted file mode 100644 index 7f6072c4b7f88..0000000000000 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_jobstats.c +++ /dev/null @@ -1,560 +0,0 @@ -/* GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * 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 version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * GPL HEADER END - */ -/* - * Copyright (c) 2011, 2012, Intel Corporation. - * Use is subject to license terms. - * - * Author: Niu Yawei - */ -/* - * lustre/obdclass/lprocfs_jobstats.c - */ - -#ifndef EXPORT_SYMTAB -# define EXPORT_SYMTAB -#endif -#define DEBUG_SUBSYSTEM S_CLASS - - -#include -#include -#include - -#if defined(LPROCFS) - -/* - * JobID formats & JobID environment variable names for supported - * job schedulers: - * - * SLURM: - * JobID format: 32 bit integer. - * JobID env var: SLURM_JOB_ID. - * SGE: - * JobID format: Decimal integer range to 99999. - * JobID env var: JOB_ID. - * LSF: - * JobID format: 6 digit integer by default (up to 999999), can be - * increased to 10 digit (up to 2147483646). - * JobID env var: LSB_JOBID. - * Loadleveler: - * JobID format: String of machine_name.cluster_id.process_id, for - * example: fr2n02.32.0 - * JobID env var: LOADL_STEP_ID. - * PBS: - * JobID format: String of sequence_number[.server_name][@server]. - * JobID env var: PBS_JOBID. - * Maui/MOAB: - * JobID format: Same as PBS. - * JobID env var: Same as PBS. - */ - -struct job_stat { - struct hlist_node js_hash; - struct list_head js_list; - atomic_t js_refcount; - char js_jobid[JOBSTATS_JOBID_SIZE]; - time_t js_timestamp; /* seconds */ - struct lprocfs_stats *js_stats; - struct obd_job_stats *js_jobstats; -}; - -static unsigned job_stat_hash(cfs_hash_t *hs, const void *key, unsigned mask) -{ - return cfs_hash_djb2_hash(key, strlen(key), mask); -} - -static void *job_stat_key(struct hlist_node *hnode) -{ - struct job_stat *job; - job = hlist_entry(hnode, struct job_stat, js_hash); - return job->js_jobid; -} - -static int job_stat_keycmp(const void *key, struct hlist_node *hnode) -{ - struct job_stat *job; - job = hlist_entry(hnode, struct job_stat, js_hash); - return (strlen(job->js_jobid) == strlen(key)) && - !strncmp(job->js_jobid, key, strlen(key)); -} - -static void *job_stat_object(struct hlist_node *hnode) -{ - return hlist_entry(hnode, struct job_stat, js_hash); -} - -static void job_stat_get(cfs_hash_t *hs, struct hlist_node *hnode) -{ - struct job_stat *job; - job = hlist_entry(hnode, struct job_stat, js_hash); - atomic_inc(&job->js_refcount); -} - -static void job_free(struct job_stat *job) -{ - LASSERT(atomic_read(&job->js_refcount) == 0); - LASSERT(job->js_jobstats); - - write_lock(&job->js_jobstats->ojs_lock); - list_del_init(&job->js_list); - write_unlock(&job->js_jobstats->ojs_lock); - - lprocfs_free_stats(&job->js_stats); - OBD_FREE_PTR(job); -} - -static void job_putref(struct job_stat *job) -{ - LASSERT(atomic_read(&job->js_refcount) > 0); - if (atomic_dec_and_test(&job->js_refcount)) - job_free(job); -} - -static void job_stat_put_locked(cfs_hash_t *hs, struct hlist_node *hnode) -{ - struct job_stat *job; - job = hlist_entry(hnode, struct job_stat, js_hash); - job_putref(job); -} - -static void job_stat_exit(cfs_hash_t *hs, struct hlist_node *hnode) -{ - CERROR("Should not have any items!"); -} - -static cfs_hash_ops_t job_stats_hash_ops = { - .hs_hash = job_stat_hash, - .hs_key = job_stat_key, - .hs_keycmp = job_stat_keycmp, - .hs_object = job_stat_object, - .hs_get = job_stat_get, - .hs_put_locked = job_stat_put_locked, - .hs_exit = job_stat_exit, -}; - -static int job_iter_callback(cfs_hash_t *hs, cfs_hash_bd_t *bd, - struct hlist_node *hnode, void *data) -{ - time_t oldest = *((time_t *)data); - struct job_stat *job; - - job = hlist_entry(hnode, struct job_stat, js_hash); - if (!oldest || job->js_timestamp < oldest) - cfs_hash_bd_del_locked(hs, bd, hnode); - - return 0; -} - -static void lprocfs_job_cleanup(struct obd_job_stats *stats, bool force) -{ - time_t oldest, now; - - if (stats->ojs_cleanup_interval == 0) - return; - - now = cfs_time_current_sec(); - if (!force && now < stats->ojs_last_cleanup + - stats->ojs_cleanup_interval) - return; - - oldest = now - stats->ojs_cleanup_interval; - cfs_hash_for_each_safe(stats->ojs_hash, job_iter_callback, - &oldest); - stats->ojs_last_cleanup = cfs_time_current_sec(); -} - -static struct job_stat *job_alloc(char *jobid, struct obd_job_stats *jobs) -{ - struct job_stat *job; - - LASSERT(jobs->ojs_cntr_num && jobs->ojs_cntr_init_fn); - - OBD_ALLOC_PTR(job); - if (job == NULL) - return NULL; - - job->js_stats = lprocfs_alloc_stats(jobs->ojs_cntr_num, 0); - if (job->js_stats == NULL) { - OBD_FREE_PTR(job); - return NULL; - } - - jobs->ojs_cntr_init_fn(job->js_stats); - - memcpy(job->js_jobid, jobid, JOBSTATS_JOBID_SIZE); - job->js_timestamp = cfs_time_current_sec(); - job->js_jobstats = jobs; - INIT_HLIST_NODE(&job->js_hash); - INIT_LIST_HEAD(&job->js_list); - atomic_set(&job->js_refcount, 1); - - return job; -} - -int lprocfs_job_stats_log(struct obd_device *obd, char *jobid, - int event, long amount) -{ - struct obd_job_stats *stats = &obd->u.obt.obt_jobstats; - struct job_stat *job, *job2; - ENTRY; - - LASSERT(stats && stats->ojs_hash); - - lprocfs_job_cleanup(stats, false); - - if (!jobid || !strlen(jobid)) - RETURN(-EINVAL); - - if (strlen(jobid) >= JOBSTATS_JOBID_SIZE) { - CERROR("Invalid jobid size (%lu), expect(%d)\n", - (unsigned long)strlen(jobid) + 1, JOBSTATS_JOBID_SIZE); - RETURN(-EINVAL); - } - - job = cfs_hash_lookup(stats->ojs_hash, jobid); - if (job) - goto found; - - job = job_alloc(jobid, stats); - if (job == NULL) - RETURN(-ENOMEM); - - job2 = cfs_hash_findadd_unique(stats->ojs_hash, job->js_jobid, - &job->js_hash); - if (job2 != job) { - job_putref(job); - job = job2; - /* We cannot LASSERT(!list_empty(&job->js_list)) here, - * since we just lost the race for inserting "job" into the - * ojs_list, and some other thread is doing it _right_now_. - * Instead, be content the other thread is doing this, since - * "job2" was initialized in job_alloc() already. LU-2163 */ - } else { - LASSERT(list_empty(&job->js_list)); - write_lock(&stats->ojs_lock); - list_add_tail(&job->js_list, &stats->ojs_list); - write_unlock(&stats->ojs_lock); - } - -found: - LASSERT(stats == job->js_jobstats); - LASSERT(stats->ojs_cntr_num > event); - job->js_timestamp = cfs_time_current_sec(); - lprocfs_counter_add(job->js_stats, event, amount); - - job_putref(job); - RETURN(0); -} -EXPORT_SYMBOL(lprocfs_job_stats_log); - -void lprocfs_job_stats_fini(struct obd_device *obd) -{ - struct obd_job_stats *stats = &obd->u.obt.obt_jobstats; - time_t oldest = 0; - - if (stats->ojs_hash == NULL) - return; - cfs_hash_for_each_safe(stats->ojs_hash, job_iter_callback, &oldest); - cfs_hash_putref(stats->ojs_hash); - stats->ojs_hash = NULL; - LASSERT(list_empty(&stats->ojs_list)); -} -EXPORT_SYMBOL(lprocfs_job_stats_fini); - -static void *lprocfs_jobstats_seq_start(struct seq_file *p, loff_t *pos) -{ - struct obd_job_stats *stats = p->private; - loff_t off = *pos; - struct job_stat *job; - - read_lock(&stats->ojs_lock); - if (off == 0) - return SEQ_START_TOKEN; - off--; - list_for_each_entry(job, &stats->ojs_list, js_list) { - if (!off--) - return job; - } - return NULL; -} - -static void lprocfs_jobstats_seq_stop(struct seq_file *p, void *v) -{ - struct obd_job_stats *stats = p->private; - - read_unlock(&stats->ojs_lock); -} - -static void *lprocfs_jobstats_seq_next(struct seq_file *p, void *v, loff_t *pos) -{ - struct obd_job_stats *stats = p->private; - struct job_stat *job; - struct list_head *next; - - ++*pos; - if (v == SEQ_START_TOKEN) { - next = stats->ojs_list.next; - } else { - job = (struct job_stat *)v; - next = job->js_list.next; - } - - return next == &stats->ojs_list ? NULL : - list_entry(next, struct job_stat, js_list); -} - -/* - * Example of output on MDT: - * - * job_stats: - * - job_id: test_id.222.25844 - * snapshot_time: 1322494486 - * open: { samples: 3, unit: reqs } - * close: { samples: 3, unit: reqs } - * mknod: { samples: 0, unit: reqs } - * link: { samples: 0, unit: reqs } - * unlink: { samples: 0, unit: reqs } - * mkdir: { samples: 0, unit: reqs } - * rmdir: { samples: 0, unit: reqs } - * rename: { samples: 1, unit: reqs } - * getattr: { samples: 7, unit: reqs } - * setattr: { samples: 0, unit: reqs } - * getxattr: { samples: 0, unit: reqs } - * setxattr: { samples: 0, unit: reqs } - * statfs: { samples: 0, unit: reqs } - * sync: { samples: 0, unit: reqs } - * - * Example of output on OST: - * - * job_stats: - * - job_id 4854 - * snapshot_time: 1322494602 - * read: { samples: 0, unit: bytes, min: 0, max: 0, sum: 0 } - * write: { samples: 1, unit: bytes, min: 10, max: 10, sum: 10 } - * setattr: { samples: 0, unit: reqs } - * punch: { samples: 0, unit: reqs } - * sync: { samples: 0, unit: reqs } - */ - -static const char spaces[] = " "; - -static int inline width(const char *str, int len) -{ - return len - min((int)strlen(str), 15); -} - -static int lprocfs_jobstats_seq_show(struct seq_file *p, void *v) -{ - struct job_stat *job = v; - struct lprocfs_stats *s; - struct lprocfs_counter ret; - struct lprocfs_counter_header *cntr_header; - int i; - - if (v == SEQ_START_TOKEN) { - seq_printf(p, "job_stats:\n"); - return 0; - } - - seq_printf(p, "- %-16s %s\n", "job_id:", job->js_jobid); - seq_printf(p, " %-16s %ld\n", "snapshot_time:", job->js_timestamp); - - s = job->js_stats; - for (i = 0; i < s->ls_num; i++) { - cntr_header = &s->ls_cnt_header[i]; - lprocfs_stats_collect(s, i, &ret); - - seq_printf(p, " %s:%.*s { samples: %11"LPF64"u", - cntr_header->lc_name, - width(cntr_header->lc_name, 15), spaces, - ret.lc_count); - if (cntr_header->lc_units[0] != '\0') - seq_printf(p, ", unit: %5s", cntr_header->lc_units); - - if (cntr_header->lc_config & LPROCFS_CNTR_AVGMINMAX) { - seq_printf(p, ", min:%8"LPF64"u, max:%8"LPF64"u," - " sum:%16"LPF64"u", - ret.lc_count ? ret.lc_min : 0, - ret.lc_count ? ret.lc_max : 0, - ret.lc_count ? ret.lc_sum : 0); - } - if (cntr_header->lc_config & LPROCFS_CNTR_STDDEV) { - seq_printf(p, ", sumsq: %18"LPF64"u", - ret.lc_count ? ret.lc_sumsquare : 0); - } - - seq_printf(p, " }\n"); - - } - return 0; -} - -struct seq_operations lprocfs_jobstats_seq_sops = { - start: lprocfs_jobstats_seq_start, - stop: lprocfs_jobstats_seq_stop, - next: lprocfs_jobstats_seq_next, - show: lprocfs_jobstats_seq_show, -}; - -static int lprocfs_jobstats_seq_open(struct inode *inode, struct file *file) -{ - struct seq_file *seq; - int rc; - - rc = seq_open(file, &lprocfs_jobstats_seq_sops); - if (rc) - return rc; - seq = file->private_data; - seq->private = PDE_DATA(inode); - return 0; -} - -static ssize_t lprocfs_jobstats_seq_write(struct file *file, const char *buf, - size_t len, loff_t *off) -{ - struct seq_file *seq = file->private_data; - struct obd_job_stats *stats = seq->private; - char jobid[JOBSTATS_JOBID_SIZE]; - int all = 0; - struct job_stat *job; - - if (!memcmp(buf, "clear", strlen("clear"))) { - all = 1; - } else if (len < JOBSTATS_JOBID_SIZE) { - memset(jobid, 0, JOBSTATS_JOBID_SIZE); - /* Trim '\n' if any */ - if (buf[len - 1] == '\n') - memcpy(jobid, buf, len - 1); - else - memcpy(jobid, buf, len); - } else { - return -EINVAL; - } - - LASSERT(stats->ojs_hash); - if (all) { - time_t oldest = 0; - cfs_hash_for_each_safe(stats->ojs_hash, job_iter_callback, - &oldest); - return len; - } - - if (!strlen(jobid)) - return -EINVAL; - - job = cfs_hash_lookup(stats->ojs_hash, jobid); - if (!job) - return -EINVAL; - - cfs_hash_del_key(stats->ojs_hash, jobid); - - job_putref(job); - return len; -} - -struct file_operations lprocfs_jobstats_seq_fops = { - .owner = THIS_MODULE, - .open = lprocfs_jobstats_seq_open, - .read = seq_read, - .write = lprocfs_jobstats_seq_write, - .llseek = seq_lseek, - .release = lprocfs_seq_release, -}; - -int lprocfs_job_stats_init(struct obd_device *obd, int cntr_num, - cntr_init_callback init_fn) -{ - struct proc_dir_entry *entry; - struct obd_job_stats *stats; - ENTRY; - - LASSERT(obd->obd_proc_entry != NULL); - LASSERT(obd->obd_type->typ_name); - - if (strcmp(obd->obd_type->typ_name, LUSTRE_MDT_NAME) && - strcmp(obd->obd_type->typ_name, LUSTRE_OST_NAME)) { - CERROR("Invalid obd device type.\n"); - RETURN(-EINVAL); - } - stats = &obd->u.obt.obt_jobstats; - - LASSERT(stats->ojs_hash == NULL); - stats->ojs_hash = cfs_hash_create("JOB_STATS", - HASH_JOB_STATS_CUR_BITS, - HASH_JOB_STATS_MAX_BITS, - HASH_JOB_STATS_BKT_BITS, 0, - CFS_HASH_MIN_THETA, - CFS_HASH_MAX_THETA, - &job_stats_hash_ops, - CFS_HASH_DEFAULT); - if (stats->ojs_hash == NULL) - RETURN(-ENOMEM); - - INIT_LIST_HEAD(&stats->ojs_list); - rwlock_init(&stats->ojs_lock); - stats->ojs_cntr_num = cntr_num; - stats->ojs_cntr_init_fn = init_fn; - stats->ojs_cleanup_interval = 600; /* 10 mins by default */ - stats->ojs_last_cleanup = cfs_time_current_sec(); - - entry = proc_create_data("job_stats", 0644, obd->obd_proc_entry, - &lprocfs_jobstats_seq_fops, stats); - if (entry) - RETURN(0); - else - RETURN(-ENOMEM); -} -EXPORT_SYMBOL(lprocfs_job_stats_init); - -int lprocfs_rd_job_interval(struct seq_file *m, void *data) -{ - struct obd_device *obd = (struct obd_device *)data; - struct obd_job_stats *stats; - - LASSERT(obd != NULL); - stats = &obd->u.obt.obt_jobstats; - return seq_printf(m, "%d\n", stats->ojs_cleanup_interval); -} -EXPORT_SYMBOL(lprocfs_rd_job_interval); - -int lprocfs_wr_job_interval(struct file *file, const char *buffer, - unsigned long count, void *data) -{ - struct obd_device *obd = (struct obd_device *)data; - struct obd_job_stats *stats; - int val, rc; - - LASSERT(obd != NULL); - stats = &obd->u.obt.obt_jobstats; - - rc = lprocfs_write_helper(buffer, count, &val); - if (rc) - return rc; - - stats->ojs_cleanup_interval = val; - lprocfs_job_cleanup(stats, true); - - return count; - -} -EXPORT_SYMBOL(lprocfs_wr_job_interval); - -#endif /* LPROCFS*/ diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c b/drivers/staging/lustre/lustre/obdclass/obd_mount.c index 28d174ab750d0..533a49395f328 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c @@ -47,7 +47,6 @@ #include #include -#include #include #include #include -- GitLab From 17dc1597c5051757b58c5397f5162a21a746ecb7 Mon Sep 17 00:00:00 2001 From: Peng Tao Date: Thu, 25 Jul 2013 02:08:18 +0800 Subject: [PATCH 174/942] staging/lustre: fix build on non-x86 On non-x86 we will build with Lustre's errno translate code but it has a few issues. Cc: Andreas Dilger Signed-off-by: Peng Tao Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ptlrpc/Makefile | 2 +- drivers/staging/lustre/lustre/ptlrpc/errno.c | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/Makefile b/drivers/staging/lustre/lustre/ptlrpc/Makefile index a379558bc687e..6d78b80487f2b 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/Makefile +++ b/drivers/staging/lustre/lustre/ptlrpc/Makefile @@ -16,7 +16,7 @@ ptlrpc_objs += sec.o sec_bulk.o sec_gc.o sec_config.o sec_lproc.o ptlrpc_objs += sec_null.o sec_plain.o nrs.o nrs_fifo.o ptlrpc-y := $(ldlm_objs) $(ptlrpc_objs) -ptlrpc-$(CONFIG_LUSTRE_TRANSLATE_ERRNOS) += errno.c +ptlrpc-$(CONFIG_LUSTRE_TRANSLATE_ERRNOS) += errno.o obj-$(CONFIG_PTLRPC_GSS) += gss/ diff --git a/drivers/staging/lustre/lustre/ptlrpc/errno.c b/drivers/staging/lustre/lustre/ptlrpc/errno.c index 46e259e4098be..1c10063339608 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/errno.c +++ b/drivers/staging/lustre/lustre/ptlrpc/errno.c @@ -25,7 +25,7 @@ * Copyright (c) 2013, Intel Corporation. */ -#include +#include #include /* @@ -184,7 +184,6 @@ static int lustre_errno_hton_mapping[] = { [EBADTYPE] = LUSTRE_EBADTYPE, [EJUKEBOX] = LUSTRE_EJUKEBOX, [EIOCBQUEUED] = LUSTRE_EIOCBQUEUED, - [EIOCBRETRY] = LUSTRE_EIOCBRETRY }; static int lustre_errno_ntoh_mapping[] = { @@ -331,7 +330,6 @@ static int lustre_errno_ntoh_mapping[] = { [LUSTRE_EBADTYPE] = EBADTYPE, [LUSTRE_EJUKEBOX] = EJUKEBOX, [LUSTRE_EIOCBQUEUED] = EIOCBQUEUED, - [LUSTRE_EIOCBRETRY] = EIOCBRETRY }; unsigned int lustre_errno_hton(unsigned int h) -- GitLab From 61e121047645122c47714fcda684d0ee67f444af Mon Sep 17 00:00:00 2001 From: Won Kang Date: Thu, 25 Jul 2013 03:36:17 +0900 Subject: [PATCH 175/942] staging: gdm7240: adding LTE USB driver GCT Semiconductor GDM7240 is 4G LTE chip. This driver supports GCT reference platform as a USB device. Signed-off-by: Won Kang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/Kconfig | 2 + drivers/staging/Makefile | 1 + drivers/staging/gdm724x/Kconfig | 15 + drivers/staging/gdm724x/Makefile | 7 + drivers/staging/gdm724x/TODO | 15 + drivers/staging/gdm724x/gdm_endian.c | 67 ++ drivers/staging/gdm724x/gdm_endian.h | 49 ++ drivers/staging/gdm724x/gdm_lte.c | 920 ++++++++++++++++++++++ drivers/staging/gdm724x/gdm_lte.h | 80 ++ drivers/staging/gdm724x/gdm_mux.c | 700 +++++++++++++++++ drivers/staging/gdm724x/gdm_mux.h | 85 +++ drivers/staging/gdm724x/gdm_tty.c | 367 +++++++++ drivers/staging/gdm724x/gdm_tty.h | 59 ++ drivers/staging/gdm724x/gdm_usb.c | 1047 ++++++++++++++++++++++++++ drivers/staging/gdm724x/gdm_usb.h | 110 +++ drivers/staging/gdm724x/hci.h | 55 ++ drivers/staging/gdm724x/hci_packet.h | 93 +++ drivers/staging/gdm724x/lte_ioctl.h | 58 ++ drivers/staging/gdm724x/netlink_k.c | 161 ++++ drivers/staging/gdm724x/netlink_k.h | 25 + 20 files changed, 3916 insertions(+) create mode 100644 drivers/staging/gdm724x/Kconfig create mode 100644 drivers/staging/gdm724x/Makefile create mode 100644 drivers/staging/gdm724x/TODO create mode 100644 drivers/staging/gdm724x/gdm_endian.c create mode 100644 drivers/staging/gdm724x/gdm_endian.h create mode 100644 drivers/staging/gdm724x/gdm_lte.c create mode 100644 drivers/staging/gdm724x/gdm_lte.h create mode 100644 drivers/staging/gdm724x/gdm_mux.c create mode 100644 drivers/staging/gdm724x/gdm_mux.h create mode 100644 drivers/staging/gdm724x/gdm_tty.c create mode 100644 drivers/staging/gdm724x/gdm_tty.h create mode 100644 drivers/staging/gdm724x/gdm_usb.c create mode 100644 drivers/staging/gdm724x/gdm_usb.h create mode 100644 drivers/staging/gdm724x/hci.h create mode 100644 drivers/staging/gdm724x/hci_packet.h create mode 100644 drivers/staging/gdm724x/lte_ioctl.h create mode 100644 drivers/staging/gdm724x/netlink_k.c create mode 100644 drivers/staging/gdm724x/netlink_k.h diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index 57d8b3444600c..d55bc344c5eac 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -118,6 +118,8 @@ source "drivers/staging/ozwpan/Kconfig" source "drivers/staging/gdm72xx/Kconfig" +source "drivers/staging/gdm724x/Kconfig" + source "drivers/staging/silicom/Kconfig" source "drivers/staging/ced1401/Kconfig" diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index 429321f15105f..c23cf3b60c34a 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -52,6 +52,7 @@ obj-$(CONFIG_MFD_NVEC) += nvec/ obj-$(CONFIG_ANDROID) += android/ obj-$(CONFIG_USB_WPAN_HCD) += ozwpan/ obj-$(CONFIG_WIMAX_GDM72XX) += gdm72xx/ +obj-$(CONFIG_LTE_GDM724X) += gdm724x/ obj-$(CONFIG_NET_VENDOR_SILICOM) += silicom/ obj-$(CONFIG_CED1401) += ced1401/ obj-$(CONFIG_DRM_IMX) += imx-drm/ diff --git a/drivers/staging/gdm724x/Kconfig b/drivers/staging/gdm724x/Kconfig new file mode 100644 index 0000000000000..10f7be10305d8 --- /dev/null +++ b/drivers/staging/gdm724x/Kconfig @@ -0,0 +1,15 @@ +# +# GCT GDM724x LTE driver configuration +# + +config LTE_GDM724X + tristate "GCT GDM724x LTE support" + depends on NET && USB + help + This driver supports GCT GDM724x LTE chip based USB modem devices. + It exposes 4 network devices to be used per PDN and 2 tty devices to be + used for AT commands and DM monitoring applications. + The modules will be called gdmulte.ko and gdmtty.ko + + GCT-ATCx can be used for AT Commands + GCT-DMx can be used for LTE protocol monitoring diff --git a/drivers/staging/gdm724x/Makefile b/drivers/staging/gdm724x/Makefile new file mode 100644 index 0000000000000..ba7f11a6a097d --- /dev/null +++ b/drivers/staging/gdm724x/Makefile @@ -0,0 +1,7 @@ +obj-$(CONFIG_LTE_GDM724X) := gdmulte.o +gdmulte-y += gdm_lte.o netlink_k.o +gdmulte-y += gdm_usb.o gdm_endian.o + +obj-$(CONFIG_LTE_GDM724X) += gdmtty.o +gdmtty-y := gdm_tty.o gdm_mux.o + diff --git a/drivers/staging/gdm724x/TODO b/drivers/staging/gdm724x/TODO new file mode 100644 index 0000000000000..cd89214aa2655 --- /dev/null +++ b/drivers/staging/gdm724x/TODO @@ -0,0 +1,15 @@ +TODO: +- Clean up coding style to meet kernel standard. (80 line limit, netdev_err) +- Remove test for host endian +- Remove confusing macros (endian, hci_send, sdu_send, rcv_with_cb) +- Fixes for every instances of function returning -1 +- Check for skb->len in gdm_lte_emulate_arp() +- Use ALIGN() macro for dummy_cnt in up_to_host() +- Error handling in init_usb() +- Explain reason for multiples of 512 bytes in alloc_tx_struct() +- Review use of atomic allocation for tx structs +- No error checking for alloc_tx_struct in do_tx() + +Patches to: + Jonathan Kim + Dean ahn diff --git a/drivers/staging/gdm724x/gdm_endian.c b/drivers/staging/gdm724x/gdm_endian.c new file mode 100644 index 0000000000000..02934093ce7f6 --- /dev/null +++ b/drivers/staging/gdm724x/gdm_endian.c @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * 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. + */ + +#include +#include "gdm_endian.h" + +void set_endian(struct gdm_endian *ed, u8 dev_endian) +{ + u8 a[2] = {0x12, 0x34}; + u8 b[2] = {0, }; + u16 c = 0x1234; + + if (dev_endian == ENDIANNESS_BIG) + ed->dev_ed = ENDIANNESS_BIG; + else + ed->dev_ed = ENDIANNESS_LITTLE; + + memcpy(b, &c, 2); + + if (a[0] != b[0]) + ed->host_ed = ENDIANNESS_LITTLE; + else + ed->host_ed = ENDIANNESS_BIG; + +} + +u16 gdm_cpu_to_dev16(struct gdm_endian *ed, u16 x) +{ + if (ed->dev_ed == ed->host_ed) + return x; + + return Endian16_Swap(x); +} + +u16 gdm_dev16_to_cpu(struct gdm_endian *ed, u16 x) +{ + if (ed->dev_ed == ed->host_ed) + return x; + + return Endian16_Swap(x); +} + +u32 gdm_cpu_to_dev32(struct gdm_endian *ed, u32 x) +{ + if (ed->dev_ed == ed->host_ed) + return x; + + return Endian32_Swap(x); +} + +u32 gdm_dev32_to_cpu(struct gdm_endian *ed, u32 x) +{ + if (ed->dev_ed == ed->host_ed) + return x; + + return Endian32_Swap(x); +} diff --git a/drivers/staging/gdm724x/gdm_endian.h b/drivers/staging/gdm724x/gdm_endian.h new file mode 100644 index 0000000000000..775794db6ab69 --- /dev/null +++ b/drivers/staging/gdm724x/gdm_endian.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * 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. + */ + +#ifndef __GDM_ENDIAN_H__ +#define __GDM_ENDIAN_H__ + +#include + +#define Endian16_Swap(value) \ + ((((u16)((value) & 0x00FF)) << 8) | \ + (((u16)((value) & 0xFF00)) >> 8)) + +#define Endian32_Swap(value) \ + ((((u32)((value) & 0x000000FF)) << 24) | \ + (((u32)((value) & 0x0000FF00)) << 8) | \ + (((u32)((value) & 0x00FF0000)) >> 8) | \ + (((u32)((value) & 0xFF000000)) >> 24)) + +enum { + ENDIANNESS_MIN = 0, + ENDIANNESS_UNKNOWN, + ENDIANNESS_LITTLE, + ENDIANNESS_BIG, + ENDIANNESS_MIDDLE, + ENDIANNESS_MAX +}; + +struct gdm_endian { + u8 dev_ed; + u8 host_ed; +}; + +void set_endian(struct gdm_endian *ed, u8 dev_endian); +u16 gdm_cpu_to_dev16(struct gdm_endian *ed, u16 x); +u16 gdm_dev16_to_cpu(struct gdm_endian *ed, u16 x); +u32 gdm_cpu_to_dev32(struct gdm_endian *ed, u32 x); +u32 gdm_dev32_to_cpu(struct gdm_endian *ed, u32 x); + +#endif /*__GDM_ENDIAN_H__*/ diff --git a/drivers/staging/gdm724x/gdm_lte.c b/drivers/staging/gdm724x/gdm_lte.c new file mode 100644 index 0000000000000..357474acb3711 --- /dev/null +++ b/drivers/staging/gdm724x/gdm_lte.c @@ -0,0 +1,920 @@ +/* + * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * 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. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "gdm_lte.h" +#include "netlink_k.h" +#include "hci.h" +#include "hci_packet.h" +#include "gdm_endian.h" +#include "lte_ioctl.h" + +/* + * Netlink protocol number + */ +#define NETLINK_LTE 30 + +/* + * Default MTU Size + */ +#define DEFAULT_MTU_SIZE 1500 + +#define gdm_dev_endian(n) (\ + n->phy_dev->get_endian(n->phy_dev->priv_dev)) + +#define gdm_lte_hci_send(n, d, l) (\ + n->phy_dev->send_hci_func(n->phy_dev->priv_dev, d, l, NULL, NULL)) + +#define gdm_lte_sdu_send(n, d, l, c, b, i, t) (\ + n->phy_dev->send_sdu_func(n->phy_dev->priv_dev, d, l, n->pdn_table.dft_eps_id, 0, c, b, i, t)) + +#define gdm_lte_rcv_with_cb(n, c, b, e) (\ + n->rcv_func(n->priv_dev, c, b, e)) + +#define IP_VERSION_4 4 +#define IP_VERSION_6 6 + +static struct { + int ref_cnt; + struct sock *sock; +} lte_event; + +static struct device_type wwan_type = { + .name = "wwan", +}; + +static int gdm_lte_open(struct net_device *dev) +{ + netif_start_queue(dev); + return 0; +} + +static int gdm_lte_close(struct net_device *dev) +{ + netif_stop_queue(dev); + return 0; +} + +static int gdm_lte_set_config(struct net_device *dev, struct ifmap *map) +{ + if (dev->flags & IFF_UP) + return -EBUSY; + return 0; +} + +static void tx_complete(void *arg) +{ + struct nic *nic = arg; + + if (netif_queue_stopped(nic->netdev)) + netif_wake_queue(nic->netdev); +} + +static int gdm_lte_rx(struct sk_buff *skb, struct nic *nic, int nic_type) +{ + int ret; + + ret = netif_rx_ni(skb); + if (ret == NET_RX_DROP) { + printk(KERN_ERR "glte: rx - dropped\n"); + nic->stats.rx_dropped++; + } else { + nic->stats.rx_packets++; + nic->stats.rx_bytes += skb->len + ETH_HLEN; + } + + return 0; +} + +int gdm_lte_emulate_arp(struct sk_buff *skb_in, u32 nic_type) +{ + struct nic *nic = netdev_priv(skb_in->dev); + struct sk_buff *skb_out; + struct ethhdr eth; + struct vlan_ethhdr vlan_eth; + struct arphdr *arp_in; + struct arphdr *arp_out; + struct arpdata { + u8 ar_sha[ETH_ALEN]; + u8 ar_sip[4]; + u8 ar_tha[ETH_ALEN]; + u8 ar_tip[4]; + }; + struct arpdata *arp_data_in; + struct arpdata *arp_data_out; + u8 arp_temp[60]; + void *mac_header_data; + u32 mac_header_len; + + /* Format the mac header so that it can be put to skb */ + if (ntohs(((struct ethhdr *)skb_in->data)->h_proto) == ETH_P_8021Q) { + memcpy(&vlan_eth, skb_in->data, sizeof(struct vlan_ethhdr)); + mac_header_data = &vlan_eth; + mac_header_len = VLAN_ETH_HLEN; + } else { + memcpy(ð, skb_in->data, sizeof(struct ethhdr)); + mac_header_data = ð + mac_header_len = ETH_HLEN; + } + + /* Get the pointer of the original request */ + arp_in = (struct arphdr *)(skb_in->data + mac_header_len); + arp_data_in = (struct arpdata *)(skb_in->data + mac_header_len + sizeof(struct arphdr)); + + /* Get the pointer of the outgoing response */ + arp_out = (struct arphdr *)arp_temp; + arp_data_out = (struct arpdata *)(arp_temp + sizeof(struct arphdr)); + + /* Copy the arp header */ + memcpy(arp_out, arp_in, sizeof(struct arphdr)); + arp_out->ar_op = htons(ARPOP_REPLY); + + /* Copy the arp payload: based on 2 bytes of mac and fill the IP */ + arp_data_out->ar_sha[0] = arp_data_in->ar_sha[0]; + arp_data_out->ar_sha[1] = arp_data_in->ar_sha[1]; + memcpy(&arp_data_out->ar_sha[2], &arp_data_in->ar_tip[0], 4); + memcpy(&arp_data_out->ar_sip[0], &arp_data_in->ar_tip[0], 4); + memcpy(&arp_data_out->ar_tha[0], &arp_data_in->ar_sha[0], 6); + memcpy(&arp_data_out->ar_tip[0], &arp_data_in->ar_sip[0], 4); + + /* Fill the destination mac with source mac of the received packet */ + memcpy(mac_header_data, mac_header_data + ETH_ALEN, ETH_ALEN); + /* Fill the source mac with nic's source mac */ + memcpy(mac_header_data + ETH_ALEN, nic->src_mac_addr, ETH_ALEN); + + /* Alloc skb and reserve align */ + skb_out = dev_alloc_skb(skb_in->len); + if (!skb_out) + return -ENOMEM; + skb_reserve(skb_out, NET_IP_ALIGN); + + memcpy(skb_put(skb_out, mac_header_len), mac_header_data, mac_header_len); + memcpy(skb_put(skb_out, sizeof(struct arphdr)), arp_out, sizeof(struct arphdr)); + memcpy(skb_put(skb_out, sizeof(struct arpdata)), arp_data_out, sizeof(struct arpdata)); + + skb_out->protocol = ((struct ethhdr *)mac_header_data)->h_proto; + skb_out->dev = skb_in->dev; + skb_reset_mac_header(skb_out); + skb_pull(skb_out, ETH_HLEN); + + gdm_lte_rx(skb_out, nic, nic_type); + + return 0; +} + +int icmp6_checksum(struct ipv6hdr *ipv6, u16 *ptr, int len) +{ + unsigned short *w = ptr; + int sum = 0; + int i; + + union { + struct { + u8 ph_src[16]; + u8 ph_dst[16]; + u32 ph_len; + u8 ph_zero[3]; + u8 ph_nxt; + } ph __packed; + u16 pa[20]; + } pseudo_header; + + memset(&pseudo_header, 0, sizeof(pseudo_header)); + memcpy(&pseudo_header.ph.ph_src, &ipv6->saddr.in6_u.u6_addr8, 16); + memcpy(&pseudo_header.ph.ph_dst, &ipv6->daddr.in6_u.u6_addr8, 16); + pseudo_header.ph.ph_len = ipv6->payload_len; + pseudo_header.ph.ph_nxt = ipv6->nexthdr; + + w = (u16 *)&pseudo_header; + for (i = 0; i < sizeof(pseudo_header.pa) / sizeof(pseudo_header.pa[0]); i++) + sum += pseudo_header.pa[i]; + + w = ptr; + while (len > 1) { + sum += *w++; + len -= 2; + } + + sum = (sum >> 16) + (sum & 0xFFFF); + sum += (sum >> 16); + sum = ~sum & 0xffff; + + return sum; +} + +int gdm_lte_emulate_ndp(struct sk_buff *skb_in, u32 nic_type) +{ + struct nic *nic = netdev_priv(skb_in->dev); + struct sk_buff *skb_out; + struct ethhdr eth; + struct vlan_ethhdr vlan_eth; + struct neighbour_advertisement { + u8 target_address[16]; + u8 type; + u8 length; + u8 link_layer_address[6]; + }; + struct neighbour_advertisement na; + struct neighbour_solicitation { + u8 target_address[16]; + }; + struct neighbour_solicitation *ns; + struct ipv6hdr *ipv6_in; + struct ipv6hdr ipv6_out; + struct icmp6hdr *icmp6_in; + struct icmp6hdr icmp6_out; + + void *mac_header_data; + u32 mac_header_len; + + /* Format the mac header so that it can be put to skb */ + if (ntohs(((struct ethhdr *)skb_in->data)->h_proto) == ETH_P_8021Q) { + memcpy(&vlan_eth, skb_in->data, sizeof(struct vlan_ethhdr)); + if (ntohs(vlan_eth.h_vlan_encapsulated_proto) != ETH_P_IPV6) + return -1; + mac_header_data = &vlan_eth; + mac_header_len = VLAN_ETH_HLEN; + } else { + memcpy(ð, skb_in->data, sizeof(struct ethhdr)); + if (ntohs(eth.h_proto) != ETH_P_IPV6) + return -1; + mac_header_data = ð + mac_header_len = ETH_HLEN; + } + + /* Check if this is IPv6 ICMP packet */ + ipv6_in = (struct ipv6hdr *)(skb_in->data + mac_header_len); + if (ipv6_in->version != 6 || ipv6_in->nexthdr != IPPROTO_ICMPV6) + return -1; + + /* Check if this is NDP packet */ + icmp6_in = (struct icmp6hdr *)(skb_in->data + mac_header_len + sizeof(struct ipv6hdr)); + if (icmp6_in->icmp6_type == NDISC_ROUTER_SOLICITATION) { /* Check RS */ + return -1; + } else if (icmp6_in->icmp6_type == NDISC_NEIGHBOUR_SOLICITATION) { /* Check NS */ + u8 icmp_na[sizeof(struct icmp6hdr) + sizeof(struct neighbour_advertisement)]; + u8 zero_addr8[16] = {0,}; + + if (memcmp(ipv6_in->saddr.in6_u.u6_addr8, zero_addr8, 16) == 0) + /* Duplicate Address Detection: Source IP is all zero */ + return 0; + + icmp6_out.icmp6_type = NDISC_NEIGHBOUR_ADVERTISEMENT; + icmp6_out.icmp6_code = 0; + icmp6_out.icmp6_cksum = 0; + icmp6_out.icmp6_dataun.un_data32[0] = htonl(0x60000000); /* R=0, S=1, O=1 */ + + ns = (struct neighbour_solicitation *)(skb_in->data + mac_header_len + sizeof(struct ipv6hdr) + sizeof(struct icmp6hdr)); + memcpy(&na.target_address, ns->target_address, 16); + na.type = 0x02; + na.length = 1; + na.link_layer_address[0] = 0x00; + na.link_layer_address[1] = 0x0a; + na.link_layer_address[2] = 0x3b; + na.link_layer_address[3] = 0xaf; + na.link_layer_address[4] = 0x63; + na.link_layer_address[5] = 0xc7; + + memcpy(&ipv6_out, ipv6_in, sizeof(struct ipv6hdr)); + memcpy(ipv6_out.saddr.in6_u.u6_addr8, &na.target_address, 16); + memcpy(ipv6_out.daddr.in6_u.u6_addr8, ipv6_in->saddr.in6_u.u6_addr8, 16); + ipv6_out.payload_len = htons(sizeof(struct icmp6hdr) + sizeof(struct neighbour_advertisement)); + + memcpy(icmp_na, &icmp6_out, sizeof(struct icmp6hdr)); + memcpy(icmp_na + sizeof(struct icmp6hdr), &na, sizeof(struct neighbour_advertisement)); + + icmp6_out.icmp6_cksum = icmp6_checksum(&ipv6_out, (u16 *)icmp_na, sizeof(icmp_na)); + } else { + return -1; + } + + /* Fill the destination mac with source mac of the received packet */ + memcpy(mac_header_data, mac_header_data + ETH_ALEN, ETH_ALEN); + /* Fill the source mac with nic's source mac */ + memcpy(mac_header_data + ETH_ALEN, nic->src_mac_addr, ETH_ALEN); + + /* Alloc skb and reserve align */ + skb_out = dev_alloc_skb(skb_in->len); + if (!skb_out) + return -ENOMEM; + skb_reserve(skb_out, NET_IP_ALIGN); + + memcpy(skb_put(skb_out, mac_header_len), mac_header_data, mac_header_len); + memcpy(skb_put(skb_out, sizeof(struct ipv6hdr)), &ipv6_out, sizeof(struct ipv6hdr)); + memcpy(skb_put(skb_out, sizeof(struct icmp6hdr)), &icmp6_out, sizeof(struct icmp6hdr)); + memcpy(skb_put(skb_out, sizeof(struct neighbour_advertisement)), &na, sizeof(struct neighbour_advertisement)); + + skb_out->protocol = ((struct ethhdr *)mac_header_data)->h_proto; + skb_out->dev = skb_in->dev; + skb_reset_mac_header(skb_out); + skb_pull(skb_out, ETH_HLEN); + + gdm_lte_rx(skb_out, nic, nic_type); + + return 0; +} + +static s32 gdm_lte_tx_nic_type(struct net_device *dev, struct sk_buff *skb) +{ + struct nic *nic = netdev_priv(dev); + struct ethhdr *eth; + struct vlan_ethhdr *vlan_eth; + struct iphdr *ip; + struct ipv6hdr *ipv6; + int mac_proto; + void *network_data; + u32 nic_type = 0; + + /* NIC TYPE is based on the nic_id of this net_device */ + nic_type = 0x00000010 | nic->nic_id; + + /* Get ethernet protocol */ + eth = (struct ethhdr *)skb->data; + if (ntohs(eth->h_proto) == ETH_P_8021Q) { + vlan_eth = (struct vlan_ethhdr *)skb->data; + mac_proto = ntohs(vlan_eth->h_vlan_encapsulated_proto); + network_data = skb->data + VLAN_ETH_HLEN; + nic_type |= NIC_TYPE_F_VLAN; + } else { + mac_proto = ntohs(eth->h_proto); + network_data = skb->data + ETH_HLEN; + } + + /* Process packet for nic type */ + switch (mac_proto) { + case ETH_P_ARP: + nic_type |= NIC_TYPE_ARP; + break; + case ETH_P_IP: + nic_type |= NIC_TYPE_F_IPV4; + ip = (struct iphdr *)network_data; + + /* Check DHCPv4 */ + if (ip->protocol == IPPROTO_UDP) { + struct udphdr *udp = (struct udphdr *)(network_data + sizeof(struct iphdr)); + if (ntohs(udp->dest) == 67 || ntohs(udp->dest) == 68) + nic_type |= NIC_TYPE_F_DHCP; + } + break; + case ETH_P_IPV6: + nic_type |= NIC_TYPE_F_IPV6; + ipv6 = (struct ipv6hdr *)network_data; + + if (ipv6->nexthdr == IPPROTO_ICMPV6) /* Check NDP request */ { + struct icmp6hdr *icmp6 = (struct icmp6hdr *)(network_data + sizeof(struct ipv6hdr)); + if (/*icmp6->icmp6_type == NDISC_ROUTER_SOLICITATION || */ + icmp6->icmp6_type == NDISC_NEIGHBOUR_SOLICITATION) + nic_type |= NIC_TYPE_ICMPV6; + } else if (ipv6->nexthdr == IPPROTO_UDP) /* Check DHCPv6 */ { + struct udphdr *udp = (struct udphdr *)(network_data + sizeof(struct ipv6hdr)); + if (ntohs(udp->dest) == 546 || ntohs(udp->dest) == 547) + nic_type |= NIC_TYPE_F_DHCP; + } + break; + default: + break; + } + + return nic_type; +} + +static int gdm_lte_tx(struct sk_buff *skb, struct net_device *dev) +{ + struct nic *nic = netdev_priv(dev); + u32 nic_type; + void *data_buf; + int data_len; + int idx; + int ret = 0; + + nic_type = gdm_lte_tx_nic_type(dev, skb); + if (nic_type == 0) { + printk(KERN_ERR "glte: tx - invalid nic_type\n"); + return -1; + } + + if (nic_type & NIC_TYPE_ARP) { + if (gdm_lte_emulate_arp(skb, nic_type) == 0) { + dev_kfree_skb(skb); + return 0; + } + } + + if (nic_type & NIC_TYPE_ICMPV6) { + if (gdm_lte_emulate_ndp(skb, nic_type) == 0) { + dev_kfree_skb(skb); + return 0; + } + } + + /* + Need byte shift (that is, remove VLAN tag) if there is one + For the case of ARP, this breaks the offset as vlan_ethhdr+4 is treated as ethhdr + However, it shouldn't be a problem as the reponse starts from arp_hdr and ethhdr + is created by this driver based on the NIC mac + */ + if (nic_type & NIC_TYPE_F_VLAN) { + struct vlan_ethhdr *vlan_eth = (struct vlan_ethhdr *)skb->data; + nic->vlan_id = ntohs(vlan_eth->h_vlan_TCI) & VLAN_VID_MASK; + data_buf = skb->data + (VLAN_ETH_HLEN - ETH_HLEN); + data_len = skb->len - (VLAN_ETH_HLEN - ETH_HLEN); + } else { + nic->vlan_id = 0; + data_buf = skb->data; + data_len = skb->len; + } + + /* If it is a ICMPV6 packet, clear all the other bits : for backward compatibilty with the firmware */ + if (nic_type & NIC_TYPE_ICMPV6) + nic_type = NIC_TYPE_ICMPV6; + + /* If it is not a dhcp packet, clear all the flag bits : original NIC, otherwise the special flag (IPVX | DHCP) */ + if (!(nic_type & NIC_TYPE_F_DHCP)) + nic_type &= NIC_TYPE_MASK; + + sscanf(dev->name, "lte%d", &idx); + + ret = gdm_lte_sdu_send(nic, + data_buf, + data_len, + tx_complete, + nic, + idx, + nic_type); + + if (ret == TX_NO_BUFFER || ret == TX_NO_SPC) { + netif_stop_queue(dev); + if (ret == TX_NO_BUFFER) + ret = 0; + else + ret = -ENOSPC; + } else if (ret == TX_NO_DEV) { + ret = -ENODEV; + } + + /* Updates tx stats */ + if (ret) { + nic->stats.tx_dropped++; + } else { + nic->stats.tx_packets++; + nic->stats.tx_bytes += data_len; + } + dev_kfree_skb(skb); + + return 0; +} + +static struct net_device_stats *gdm_lte_stats(struct net_device *dev) +{ + struct nic *nic = netdev_priv(dev); + return &nic->stats; +} + +static void get_dev_endian(struct data_t *data, struct net_device *dev) +{ + struct nic *nic = netdev_priv(dev); + unsigned long ret; + + ret = copy_to_user(data->buf, gdm_dev_endian(nic), sizeof(struct dev_endian_t)); + if (ret) + printk(KERN_INFO "glte: state - failed to copy\n"); +} + +static int gdm_lte_ioctl_get_data(struct wm_req_t *req, struct net_device *dev) +{ + u16 id = req->data_id; + + switch (id) { + case GET_ENDIAN_INFO: + /* required for the user space application to find out device endian */ + get_dev_endian(&req->data, dev); + break; + default: + printk(KERN_ERR "glte: ioctl - unknown type %d\n", id); + break; + } + return 0; +} + +static int gdm_lte_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) +{ + struct wm_req_t *req = (struct wm_req_t *)ifr; + + if (cmd != SIOCLTEIOCTL || req->cmd != SIOCG_DATA || req->data_id >= 100) + return -EOPNOTSUPP; + + return gdm_lte_ioctl_get_data(req, dev); +} + +static int gdm_lte_event_send(struct net_device *dev, char *buf, int len) +{ + struct nic *nic = netdev_priv(dev); + struct hci_packet *hci = (struct hci_packet *)buf; + int idx; + + sscanf(dev->name, "lte%d", &idx); + + return netlink_send(lte_event.sock, idx, 0, buf, + gdm_dev16_to_cpu(gdm_dev_endian(nic), hci->len) + HCI_HEADER_SIZE); +} + +static void gdm_lte_event_rcv(struct net_device *dev, u16 type, void *msg, int len) +{ + struct nic *nic = netdev_priv(dev); + + gdm_lte_hci_send(nic, msg, len); +} + +int gdm_lte_event_init(void) +{ + if (lte_event.ref_cnt == 0) + lte_event.sock = netlink_init(NETLINK_LTE, gdm_lte_event_rcv); + + if (lte_event.sock) { + lte_event.ref_cnt++; + return 0; + } + + printk(KERN_ERR "glte: event init failed\n"); + return -1; +} + +void gdm_lte_event_exit(void) +{ + if (lte_event.sock && --lte_event.ref_cnt == 0) { + netlink_exit(lte_event.sock); + lte_event.sock = NULL; + } +} + +static u8 find_dev_index(u32 nic_type) +{ + u8 index; + + index = (u8)(nic_type & 0x0000000f); + if (index > MAX_NIC_TYPE) + index = 0; + + return index; +} + +static void gdm_lte_netif_rx(struct net_device *dev, char *buf, int len, int flagged_nic_type) +{ + u32 nic_type; + struct nic *nic; + struct sk_buff *skb; + struct ethhdr eth; + struct vlan_ethhdr vlan_eth; + void *mac_header_data; + u32 mac_header_len; + char ip_version = 0; + + nic_type = flagged_nic_type & NIC_TYPE_MASK; + nic = netdev_priv(dev); + + if (flagged_nic_type & NIC_TYPE_F_DHCP) { + /* Change the destination mac address with the one requested the IP */ + if (flagged_nic_type & NIC_TYPE_F_IPV4) { + struct dhcp_packet { + u8 op; /* BOOTREQUEST or BOOTREPLY */ + u8 htype; /* hardware address type. 1 = 10mb ethernet */ + u8 hlen; /* hardware address length */ + u8 hops; /* used by relay agents only */ + u32 xid; /* unique id */ + u16 secs; /* elapsed since client began acquisition/renewal */ + u16 flags; /* only one flag so far: */ + #define BROADCAST_FLAG 0x8000 /* "I need broadcast replies" */ + u32 ciaddr; /* client IP (if client is in BOUND, RENEW or REBINDING state) */ + u32 yiaddr; /* 'your' (client) IP address */ + /* IP address of next server to use in bootstrap, returned in DHCPOFFER, DHCPACK by server */ + u32 siaddr_nip; + u32 gateway_nip; /* relay agent IP address */ + u8 chaddr[16]; /* link-layer client hardware address (MAC) */ + u8 sname[64]; /* server host name (ASCIZ) */ + u8 file[128]; /* boot file name (ASCIZ) */ + u32 cookie; /* fixed first four option bytes (99,130,83,99 dec) */ + } __packed; + void *addr = buf + sizeof(struct iphdr) + sizeof(struct udphdr) + offsetof(struct dhcp_packet, chaddr); + memcpy(nic->dest_mac_addr, addr, ETH_ALEN); + } + } + + if (nic->vlan_id > 0) { + mac_header_data = (void *)&vlan_eth; + mac_header_len = VLAN_ETH_HLEN; + } else { + mac_header_data = (void *)ð + mac_header_len = ETH_HLEN; + } + + /* Format the data so that it can be put to skb */ + memcpy(mac_header_data, nic->dest_mac_addr, ETH_ALEN); + memcpy(mac_header_data + ETH_ALEN, nic->src_mac_addr, ETH_ALEN); + + vlan_eth.h_vlan_TCI = htons(nic->vlan_id); + vlan_eth.h_vlan_proto = htons(ETH_P_8021Q); + + if (nic_type == NIC_TYPE_ARP) { + /* Should be response: Only happens because there was a request from the host */ + eth.h_proto = htons(ETH_P_ARP); + vlan_eth.h_vlan_encapsulated_proto = htons(ETH_P_ARP); + } else { + ip_version = buf[0] >> 4; + if (ip_version == IP_VERSION_4) { + eth.h_proto = htons(ETH_P_IP); + vlan_eth.h_vlan_encapsulated_proto = htons(ETH_P_IP); + } else if (ip_version == IP_VERSION_6) { + eth.h_proto = htons(ETH_P_IPV6); + vlan_eth.h_vlan_encapsulated_proto = htons(ETH_P_IPV6); + } else { + printk(KERN_ERR "glte: Unknown IP version %d\n", ip_version); + return; + } + } + + /* Alloc skb and reserve align */ + skb = dev_alloc_skb(len + mac_header_len + NET_IP_ALIGN); + if (!skb) + return; + skb_reserve(skb, NET_IP_ALIGN); + + memcpy(skb_put(skb, mac_header_len), mac_header_data, mac_header_len); + memcpy(skb_put(skb, len), buf, len); + + skb->protocol = ((struct ethhdr *)mac_header_data)->h_proto; + skb->dev = dev; + skb_reset_mac_header(skb); + skb_pull(skb, ETH_HLEN); + + gdm_lte_rx(skb, nic, nic_type); +} + +static void gdm_lte_multi_sdu_pkt(struct phy_dev *phy_dev, char *buf, int len) +{ + struct net_device *dev; + struct multi_sdu *multi_sdu = (struct multi_sdu *)buf; + struct sdu *sdu = NULL; + u8 *data = (u8 *)multi_sdu->data; + u16 i = 0; + u16 num_packet; + u16 hci_len; + u16 cmd_evt; + u32 nic_type; + u8 index; + + hci_len = gdm_dev16_to_cpu(phy_dev->get_endian(phy_dev->priv_dev), multi_sdu->len); + num_packet = gdm_dev16_to_cpu(phy_dev->get_endian(phy_dev->priv_dev), multi_sdu->num_packet); + + for (i = 0; i < num_packet; i++) { + sdu = (struct sdu *)data; + + cmd_evt = gdm_dev16_to_cpu(phy_dev->get_endian(phy_dev->priv_dev), sdu->cmd_evt); + hci_len = gdm_dev16_to_cpu(phy_dev->get_endian(phy_dev->priv_dev), sdu->len); + nic_type = gdm_dev32_to_cpu(phy_dev->get_endian(phy_dev->priv_dev), sdu->nic_type); + + if (cmd_evt != LTE_RX_SDU) { + printk(KERN_ERR "glte: rx sdu wrong hci %04x\n", cmd_evt); + return; + } + if (hci_len < 12) { + printk(KERN_ERR "glte: rx sdu invalid len %d\n", hci_len); + return; + } + + index = find_dev_index(nic_type); + if (index < MAX_NIC_TYPE) { + dev = phy_dev->dev[index]; + gdm_lte_netif_rx(dev, (char *)sdu->data, (int)(hci_len-12), nic_type); + } else { + printk(KERN_ERR "glte: rx sdu invalid nic_type : %x\n", nic_type); + } + + data += ((hci_len+3) & 0xfffc) + HCI_HEADER_SIZE; + } +} + +static void gdm_lte_pdn_table(struct net_device *dev, char *buf, int len) +{ + struct nic *nic = netdev_priv(dev); + struct hci_pdn_table_ind *pdn_table = (struct hci_pdn_table_ind *)buf; + + if (pdn_table->activate) { + nic->pdn_table.activate = pdn_table->activate; + nic->pdn_table.dft_eps_id = gdm_dev32_to_cpu(gdm_dev_endian(nic), pdn_table->dft_eps_id); + nic->pdn_table.nic_type = gdm_dev32_to_cpu(gdm_dev_endian(nic), pdn_table->nic_type); + + printk(KERN_INFO "glte: pdn %s activated, nic_type=0x%x\n", + dev->name, nic->pdn_table.nic_type); + } else { + memset(&nic->pdn_table, 0x00, sizeof(struct pdn_table)); + printk(KERN_INFO "glte: pdn %s deactivated\n", + dev->name); + } +} + +static int gdm_lte_receive_pkt(struct phy_dev *phy_dev, char *buf, int len) +{ + struct hci_packet *hci = (struct hci_packet *)buf; + struct hci_pdn_table_ind *pdn_table = (struct hci_pdn_table_ind *)buf; + struct sdu *sdu; + struct net_device *dev; + int ret = 0; + u16 cmd_evt; + u32 nic_type; + u8 index; + + if (!len) + return ret; + + cmd_evt = gdm_dev16_to_cpu(phy_dev->get_endian(phy_dev->priv_dev), hci->cmd_evt); + + dev = phy_dev->dev[0]; + if (dev == NULL) + return 0; + + switch (cmd_evt) { + case LTE_RX_SDU: + sdu = (struct sdu *)hci->data; + nic_type = gdm_dev32_to_cpu(phy_dev->get_endian(phy_dev->priv_dev), sdu->nic_type); + index = find_dev_index(nic_type); + dev = phy_dev->dev[index]; + gdm_lte_netif_rx(dev, hci->data, len, nic_type); + break; + case LTE_RX_MULTI_SDU: + gdm_lte_multi_sdu_pkt(phy_dev, buf, len); + break; + case LTE_LINK_ON_OFF_INDICATION: + { + struct hci_connect_ind *connect_ind = (struct hci_connect_ind *)buf; + printk(KERN_INFO "glte: link %s\n", + connect_ind->connect ? "on" : "off"); + } + break; + case LTE_PDN_TABLE_IND: + pdn_table = (struct hci_pdn_table_ind *)buf; + nic_type = gdm_dev32_to_cpu(phy_dev->get_endian(phy_dev->priv_dev), pdn_table->nic_type); + index = find_dev_index(nic_type); + dev = phy_dev->dev[index]; + gdm_lte_pdn_table(dev, buf, len); + /* Fall through */ + default: + ret = gdm_lte_event_send(dev, buf, len); + break; + } + + return ret; +} + +static int rx_complete(void *arg, void *data, int len, int context) +{ + struct phy_dev *phy_dev = (struct phy_dev *)arg; + + return gdm_lte_receive_pkt(phy_dev, (char *)data, len); +} + +void start_rx_proc(struct phy_dev *phy_dev) +{ + int i; + + for (i = 0; i < MAX_RX_SUBMIT_COUNT; i++) + gdm_lte_rcv_with_cb(phy_dev, rx_complete, phy_dev, USB_COMPLETE); +} + +static struct net_device_ops gdm_netdev_ops = { + .ndo_open = gdm_lte_open, + .ndo_stop = gdm_lte_close, + .ndo_set_config = gdm_lte_set_config, + .ndo_start_xmit = gdm_lte_tx, + .ndo_get_stats = gdm_lte_stats, + .ndo_do_ioctl = gdm_lte_ioctl, +}; + +static u8 gdm_lte_macaddr[ETH_ALEN] = {0x00, 0x0a, 0x3b, 0x00, 0x00, 0x00}; + +static void form_mac_address(u8 *dev_addr, u8 *nic_src, u8 *nic_dest, u8 *mac_address, u8 index) +{ + /* Form the dev_addr */ + if (!mac_address) + memcpy(dev_addr, gdm_lte_macaddr, ETH_ALEN); + else + memcpy(dev_addr, mac_address, ETH_ALEN); + + /* The last byte of the mac address should be less than or equal to 0xFC */ + dev_addr[ETH_ALEN-1] += index; + + /* Create random nic src and copy the first 3 bytes to be the same as dev_addr */ + random_ether_addr(nic_src); + memcpy(nic_src, dev_addr, 3); + + /* Copy the nic_dest from dev_addr*/ + memcpy(nic_dest, dev_addr, ETH_ALEN); +} + +static void validate_mac_address(u8 *mac_address) +{ + /* if zero address or multicast bit set, restore the default value */ + if (is_zero_ether_addr(mac_address) || (mac_address[0] & 0x01)) { + printk(KERN_ERR "glte: MAC invalid, restoring default\n"); + memcpy(mac_address, gdm_lte_macaddr, 6); + } +} + +int register_lte_device(struct phy_dev *phy_dev, struct device *dev, u8 *mac_address) +{ + struct nic *nic; + struct net_device *net; + char pdn_dev_name[16]; + int ret = 0; + u8 index; + + validate_mac_address(mac_address); + + for (index = 0; index < MAX_NIC_TYPE; index++) { + /* Create device name lteXpdnX */ + sprintf(pdn_dev_name, "lte%%dpdn%d", index); + + /* Allocate netdev */ + net = alloc_netdev(sizeof(struct nic), pdn_dev_name, ether_setup); + if (net == NULL) { + printk(KERN_ERR "glte: alloc_netdev failed\n"); + ret = -ENOMEM; + goto err; + } + net->netdev_ops = &gdm_netdev_ops; + net->flags &= ~IFF_MULTICAST; + net->mtu = DEFAULT_MTU_SIZE; + + nic = netdev_priv(net); + memset(nic, 0, sizeof(struct nic)); + nic->netdev = net; + nic->phy_dev = phy_dev; + nic->nic_id = index; + + form_mac_address( + net->dev_addr, + nic->src_mac_addr, + nic->dest_mac_addr, + mac_address, + index); + + SET_NETDEV_DEV(net, dev); + SET_NETDEV_DEVTYPE(net, &wwan_type); + + ret = register_netdev(net); + if (ret) + goto err; + + netif_carrier_on(net); + + phy_dev->dev[index] = net; + } + + return 0; + +err: + unregister_lte_device(phy_dev); + + return ret; +} + +void unregister_lte_device(struct phy_dev *phy_dev) +{ + struct net_device *net; + int index; + + for (index = 0; index < MAX_NIC_TYPE; index++) { + net = phy_dev->dev[index]; + if (net == NULL) + continue; + + unregister_netdev(net); + free_netdev(net); + } +} diff --git a/drivers/staging/gdm724x/gdm_lte.h b/drivers/staging/gdm724x/gdm_lte.h new file mode 100644 index 0000000000000..1614e917c0048 --- /dev/null +++ b/drivers/staging/gdm724x/gdm_lte.h @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * 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. + */ + +#ifndef _GDM_LTE_H_ +#define _GDM_LTE_H_ + +#include +#include +#include + +#include "gdm_endian.h" + +#define MAX_NIC_TYPE 4 +#define MAX_RX_SUBMIT_COUNT 3 +#define DRIVER_VERSION "3.7.17.0" + +enum TX_ERROR_CODE { + TX_NO_ERROR = 0, + TX_NO_DEV, + TX_NO_SPC, + TX_NO_BUFFER, +}; + +enum CALLBACK_CONTEXT { + KERNEL_THREAD = 0, + USB_COMPLETE, +}; + +struct pdn_table { + u8 activate; + u32 dft_eps_id; + u32 nic_type; +} __packed; + +struct nic; + +struct phy_dev { + void *priv_dev; + struct net_device *dev[MAX_NIC_TYPE]; + int (*send_hci_func)(void *priv_dev, void *data, int len, + void (*cb)(void *cb_data), void *cb_data); + int (*send_sdu_func)(void *priv_dev, void *data, int len, + unsigned int dftEpsId, unsigned int epsId, + void (*cb)(void *cb_data), void *cb_data, + int dev_idx, int nic_type); + int (*rcv_func)(void *priv_dev, + int (*cb)(void *cb_data, void *data, int len, int context), + void *cb_data, int context); + struct gdm_endian *(*get_endian)(void *priv_dev); +}; + +struct nic { + struct net_device *netdev; + struct phy_dev *phy_dev; + struct net_device_stats stats; + struct pdn_table pdn_table; + u8 dest_mac_addr[ETH_ALEN]; + u8 src_mac_addr[ETH_ALEN]; + u32 nic_id; + u16 vlan_id; +}; + +int gdm_lte_event_init(void); +void gdm_lte_event_exit(void); + +void start_rx_proc(struct phy_dev *phy_dev); +int register_lte_device(struct phy_dev *phy_dev, struct device *dev, u8 *mac_address); +void unregister_lte_device(struct phy_dev *phy_dev); + +#endif /* _GDM_LTE_H_ */ diff --git a/drivers/staging/gdm724x/gdm_mux.c b/drivers/staging/gdm724x/gdm_mux.c new file mode 100644 index 0000000000000..2199f1bcbc842 --- /dev/null +++ b/drivers/staging/gdm724x/gdm_mux.c @@ -0,0 +1,700 @@ +/* + * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * 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. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "gdm_mux.h" +#include "gdm_tty.h" + +struct workqueue_struct *mux_rx_wq; + +static u16 packet_type[TTY_MAX_COUNT] = {0xF011, 0xF010}; + +#define USB_DEVICE_CDC_DATA(vid, pid) \ + .match_flags = \ + USB_DEVICE_ID_MATCH_DEVICE |\ + USB_DEVICE_ID_MATCH_INT_CLASS |\ + USB_DEVICE_ID_MATCH_INT_SUBCLASS,\ + .idVendor = vid,\ + .idProduct = pid,\ + .bInterfaceClass = USB_CLASS_COMM,\ + .bInterfaceSubClass = USB_CDC_SUBCLASS_ACM + +static const struct usb_device_id id_table[] = { + { USB_DEVICE_CDC_DATA(0x1076, 0x8000) }, /* GCT GDM7240 */ + { USB_DEVICE_CDC_DATA(0x1076, 0x8f00) }, /* GCT GDM7243 */ + { USB_DEVICE_CDC_DATA(0x1076, 0x9000) }, /* GCT GDM7243 */ + { USB_DEVICE_CDC_DATA(0x1d74, 0x2300) }, /* LGIT Phoenix */ + {} +}; + + +MODULE_DEVICE_TABLE(usb, id_table); + +int packet_type_to_index(u16 packetType) +{ + int i; + + for (i = 0; i < TTY_MAX_COUNT; i++) { + if (packet_type[i] == packetType) + return i; + } + + return -1; +} + +static struct mux_tx *alloc_mux_tx(int len) +{ + struct mux_tx *t = NULL; + + t = kzalloc(sizeof(struct mux_tx), GFP_ATOMIC); + if (!t) + return NULL; + + t->urb = usb_alloc_urb(0, GFP_ATOMIC); + t->buf = kmalloc(MUX_TX_MAX_SIZE, GFP_ATOMIC); + if (!t->urb || !t->buf) { + usb_free_urb(t->urb); + kfree(t->buf); + kfree(t); + return NULL; + } + + return t; +} + +static void free_mux_tx(struct mux_tx *t) +{ + if (t) { + usb_free_urb(t->urb); + kfree(t->buf); + kfree(t); + } +} + +static struct mux_rx *alloc_mux_rx(void) +{ + struct mux_rx *r = NULL; + + r = kzalloc(sizeof(struct mux_rx), GFP_ATOMIC); + if (!r) + return NULL; + + r->urb = usb_alloc_urb(0, GFP_ATOMIC); + r->buf = kmalloc(MUX_RX_MAX_SIZE, GFP_ATOMIC); + if (!r->urb || !r->buf) { + usb_free_urb(r->urb); + kfree(r->buf); + kfree(r); + return NULL; + } + + return r; +} + +static void free_mux_rx(struct mux_rx *r) +{ + if (r) { + usb_free_urb(r->urb); + kfree(r->buf); + kfree(r); + } +} + +static struct mux_rx *get_rx_struct(struct rx_cxt *rx) +{ + struct mux_rx *r; + unsigned long flags; + + spin_lock_irqsave(&rx->free_list_lock, flags); + + if (list_empty(&rx->rx_free_list)) { + spin_unlock_irqrestore(&rx->free_list_lock, flags); + return NULL; + } + + r = list_entry(rx->rx_free_list.prev, struct mux_rx, free_list); + list_del(&r->free_list); + + spin_unlock_irqrestore(&rx->free_list_lock, flags); + + return r; +} + +static void put_rx_struct(struct rx_cxt *rx, struct mux_rx *r) +{ + unsigned long flags; + + spin_lock_irqsave(&rx->free_list_lock, flags); + list_add_tail(&r->free_list, &rx->rx_free_list); + spin_unlock_irqrestore(&rx->free_list_lock, flags); +} + + +static int up_to_host(struct mux_rx *r) +{ + struct mux_dev *mux_dev = (struct mux_dev *)r->mux_dev; + struct mux_pkt_header *mux_header; + unsigned int start_flag; + unsigned int payload_size; + unsigned short packet_type; + int remain; + int dummy_cnt; + u32 packet_size_sum = r->offset; + int index; + int ret = TO_HOST_INVALID_PACKET; + int len = r->len; + + while (1) { + mux_header = (struct mux_pkt_header *)(r->buf + packet_size_sum); + start_flag = __le32_to_cpu(mux_header->start_flag); + payload_size = __le32_to_cpu(mux_header->payload_size); + packet_type = __le16_to_cpu(mux_header->packet_type); + + if (start_flag != START_FLAG) { + printk(KERN_ERR "glte: invalid START_FLAG %x\n", + start_flag); + break; + } + + remain = (MUX_HEADER_SIZE + payload_size) % 4; + dummy_cnt = remain ? (4-remain) : 0; + + if (len - packet_size_sum < + MUX_HEADER_SIZE + payload_size + dummy_cnt) { + printk(KERN_ERR "glte: invalid payload : %d %d %04x\n", + payload_size, len, + packet_type + ); + break; + } + + index = packet_type_to_index(packet_type); + if (index < 0) { + printk(KERN_ERR "glte: invalid index %d\n", index); + break; + } + + ret = r->callback(mux_header->data, + payload_size, + index, + mux_dev->minor[index], + RECV_PACKET_PROCESS_CONTINUE + ); + if (ret == TO_HOST_BUFFER_REQUEST_FAIL) { + r->offset += packet_size_sum; + break; + } + + packet_size_sum += MUX_HEADER_SIZE + payload_size + dummy_cnt; + if (len - packet_size_sum <= MUX_HEADER_SIZE + 2) { + ret = r->callback(NULL, + 0, + index, + mux_dev->minor[index], + RECV_PACKET_PROCESS_COMPLETE + ); + break; + } + } + + return ret; +} + +static void do_rx(struct work_struct *work) +{ + struct mux_dev *mux_dev = + container_of(work, struct mux_dev , work_rx.work); + struct mux_rx *r; + struct rx_cxt *rx = (struct rx_cxt *)&mux_dev->rx; + unsigned long flags; + int ret = 0; + + while (1) { + spin_lock_irqsave(&rx->to_host_lock, flags); + if (list_empty(&rx->to_host_list)) { + spin_unlock_irqrestore(&rx->to_host_lock, flags); + break; + } + r = list_entry(rx->to_host_list.next, struct mux_rx, to_host_list); + list_del(&r->to_host_list); + spin_unlock_irqrestore(&rx->to_host_lock, flags); + + ret = up_to_host(r); + if (ret == TO_HOST_BUFFER_REQUEST_FAIL) + printk(KERN_ERR "glte: failed to send mux data to host\n"); + else + put_rx_struct(rx, r); + } +} + +static void remove_rx_submit_list(struct mux_rx *r, struct rx_cxt *rx) +{ + unsigned long flags; + struct mux_rx *r_remove, *r_remove_next; + + spin_lock_irqsave(&rx->submit_list_lock, flags); + list_for_each_entry_safe(r_remove, r_remove_next, &rx->rx_submit_list, rx_submit_list) { + if (r == r_remove) + list_del(&r->rx_submit_list); + } + spin_unlock_irqrestore(&rx->submit_list_lock, flags); +} + +static void gdm_mux_rcv_complete(struct urb *urb) +{ + struct mux_rx *r = urb->context; + struct mux_dev *mux_dev = (struct mux_dev *)r->mux_dev; + struct rx_cxt *rx = &mux_dev->rx; + unsigned long flags; + + remove_rx_submit_list(r, rx); + + if (urb->status) { + if (mux_dev->usb_state == PM_NORMAL) + printk(KERN_ERR "glte: gdm_mux_rcv_complete urb status error %d\n", urb->status); + put_rx_struct(rx, r); + } else { + r->len = r->urb->actual_length; + spin_lock_irqsave(&rx->to_host_lock, flags); + list_add_tail(&r->to_host_list, &rx->to_host_list); + queue_work(mux_rx_wq, &mux_dev->work_rx.work); + spin_unlock_irqrestore(&rx->to_host_lock, flags); + } +} + +static int gdm_mux_recv(void *priv_dev, + int (*cb)(void *data, int len, int tty_index, int minor, int complete) + ) +{ + struct mux_dev *mux_dev = priv_dev; + struct usb_device *usbdev = mux_dev->usbdev; + struct mux_rx *r; + struct rx_cxt *rx = &mux_dev->rx; + unsigned long flags; + int ret; + + if (!usbdev) { + printk(KERN_ERR "glte: device is disconnected\n"); + return -ENODEV; + } + + r = get_rx_struct(rx); + if (!r) { + printk(KERN_ERR "glte: get_rx_struct fail\n"); + return -ENOMEM; + } + + r->offset = 0; + r->mux_dev = (void *)mux_dev; + r->callback = cb; + mux_dev->rx_cb = cb; + + usb_fill_bulk_urb(r->urb, + usbdev, + usb_rcvbulkpipe(usbdev, 0x86), + r->buf, + MUX_RX_MAX_SIZE, + gdm_mux_rcv_complete, + r); + + spin_lock_irqsave(&rx->submit_list_lock, flags); + list_add_tail(&r->rx_submit_list, &rx->rx_submit_list); + spin_unlock_irqrestore(&rx->submit_list_lock, flags); + + ret = usb_submit_urb(r->urb, GFP_KERNEL); + + if (ret) { + spin_lock_irqsave(&rx->submit_list_lock, flags); + list_del(&r->rx_submit_list); + spin_unlock_irqrestore(&rx->submit_list_lock, flags); + + put_rx_struct(rx, r); + + printk(KERN_ERR "glte: usb_submit_urb ret=%d\n", ret); + } + + usb_mark_last_busy(usbdev); + + return ret; +} + +static void gdm_mux_send_complete(struct urb *urb) +{ + struct mux_tx *t = urb->context; + + if (urb->status == -ECONNRESET) { + printk(KERN_INFO "glte: CONNRESET\n"); + free_mux_tx(t); + return; + } + + if (t->callback) + t->callback(t->cb_data); + + free_mux_tx(t); +} + +static int gdm_mux_send(void *priv_dev, void *data, int len, int tty_index, + void (*cb)(void *data), void *cb_data) +{ + struct mux_dev *mux_dev = priv_dev; + struct usb_device *usbdev = mux_dev->usbdev; + struct mux_pkt_header *mux_header; + struct mux_tx *t = NULL; + static u32 seq_num = 1; + int remain; + int dummy_cnt; + int total_len; + int ret; + unsigned long flags; + + if (mux_dev->usb_state == PM_SUSPEND) { + ret = usb_autopm_get_interface(mux_dev->intf); + if (!ret) + usb_autopm_put_interface(mux_dev->intf); + } + + spin_lock_irqsave(&mux_dev->write_lock, flags); + + remain = (MUX_HEADER_SIZE + len) % 4; + dummy_cnt = remain ? (4 - remain) : 0; + + total_len = len + MUX_HEADER_SIZE + dummy_cnt; + + t = alloc_mux_tx(total_len); + if (!t) { + printk(KERN_ERR "glte: alloc_mux_tx fail\n"); + spin_unlock_irqrestore(&mux_dev->write_lock, flags); + return -ENOMEM; + } + + mux_header = (struct mux_pkt_header *)t->buf; + mux_header->start_flag = __cpu_to_le32(START_FLAG); + mux_header->seq_num = __cpu_to_le32(seq_num++); + mux_header->payload_size = __cpu_to_le32((u32)len); + mux_header->packet_type = __cpu_to_le16(packet_type[tty_index]); + + memcpy(t->buf+MUX_HEADER_SIZE, data, len); + memset(t->buf+MUX_HEADER_SIZE+len, 0, dummy_cnt); + + t->len = total_len; + t->callback = cb; + t->cb_data = cb_data; + + usb_fill_bulk_urb(t->urb, + usbdev, + usb_sndbulkpipe(usbdev, 5), + t->buf, + total_len, + gdm_mux_send_complete, + t); + + ret = usb_submit_urb(t->urb, GFP_KERNEL); + + spin_unlock_irqrestore(&mux_dev->write_lock, flags); + + if (ret) + printk(KERN_ERR "glte: usb_submit_urb Error : %d\n", ret); + + usb_mark_last_busy(usbdev); + + return ret; +} + +static int gdm_mux_send_control(void *priv_dev, int request, int value, void *buf, int len) +{ + struct mux_dev *mux_dev = priv_dev; + struct usb_device *usbdev = mux_dev->usbdev; + int ret; + + ret = usb_control_msg(usbdev, + usb_sndctrlpipe(usbdev, 0), + request, + USB_RT_ACM, + value, + 2, + buf, + len, + 5000 + ); + + if (ret < 0) + printk(KERN_ERR "glte: usb_control_msg error : %d\n", ret); + + return ret < 0 ? ret : 0; +} + +static void release_usb(struct mux_dev *mux_dev) +{ + struct rx_cxt *rx = &mux_dev->rx; + struct mux_rx *r, *r_next; + unsigned long flags; + + cancel_delayed_work(&mux_dev->work_rx); + + spin_lock_irqsave(&rx->submit_list_lock, flags); + list_for_each_entry_safe(r, r_next, &rx->rx_submit_list, rx_submit_list) { + spin_unlock_irqrestore(&rx->submit_list_lock, flags); + usb_kill_urb(r->urb); + spin_lock_irqsave(&rx->submit_list_lock, flags); + } + spin_unlock_irqrestore(&rx->submit_list_lock, flags); + + spin_lock_irqsave(&rx->free_list_lock, flags); + list_for_each_entry_safe(r, r_next, &rx->rx_free_list, free_list) { + list_del(&r->free_list); + free_mux_rx(r); + } + spin_unlock_irqrestore(&rx->free_list_lock, flags); + + spin_lock_irqsave(&rx->to_host_lock, flags); + list_for_each_entry_safe(r, r_next, &rx->to_host_list, to_host_list) { + if (r->mux_dev == (void *)mux_dev) { + list_del(&r->to_host_list); + free_mux_rx(r); + } + } + spin_unlock_irqrestore(&rx->to_host_lock, flags); +} + + +static int init_usb(struct mux_dev *mux_dev) +{ + struct mux_rx *r; + struct rx_cxt *rx = &mux_dev->rx; + int ret = 0; + int i; + + spin_lock_init(&mux_dev->write_lock); + INIT_LIST_HEAD(&rx->to_host_list); + INIT_LIST_HEAD(&rx->rx_submit_list); + INIT_LIST_HEAD(&rx->rx_free_list); + spin_lock_init(&rx->to_host_lock); + spin_lock_init(&rx->submit_list_lock); + spin_lock_init(&rx->free_list_lock); + + for (i = 0; i < MAX_ISSUE_NUM * 2; i++) { + r = alloc_mux_rx(); + if (r == NULL) { + ret = -ENOMEM; + break; + } + + list_add(&r->free_list, &rx->rx_free_list); + } + + INIT_DELAYED_WORK(&mux_dev->work_rx, do_rx); + + return ret; +} + +static int gdm_mux_probe(struct usb_interface *intf, const struct usb_device_id *id) +{ + struct mux_dev *mux_dev = NULL; + struct tty_dev *tty_dev = NULL; + u16 idVendor, idProduct; + int bInterfaceNumber; + int ret = 0; + int i; + struct usb_device *usbdev = interface_to_usbdev(intf); + bInterfaceNumber = intf->cur_altsetting->desc.bInterfaceNumber; + + idVendor = __le16_to_cpu(usbdev->descriptor.idVendor); + idProduct = __le16_to_cpu(usbdev->descriptor.idProduct); + + printk(KERN_INFO "glte: mux vid = 0x%04x pid = 0x%04x\n", + idVendor, idProduct); + + if (bInterfaceNumber != 2) { + ret = -ENODEV; + goto out; + } + + mux_dev = kzalloc(sizeof(struct mux_dev), GFP_KERNEL); + if (!mux_dev) { + ret = -ENOMEM; + goto out; + } + + tty_dev = kzalloc(sizeof(struct tty_dev), GFP_KERNEL); + if (!tty_dev) { + kfree(mux_dev); + ret = -ENOMEM; + goto out; + } + + mux_dev->usbdev = usbdev; + mux_dev->control_intf = intf; + + ret = init_usb(mux_dev); + if (ret < 0) + goto out; + + tty_dev->priv_dev = (void *)mux_dev; + tty_dev->send_func = gdm_mux_send; + tty_dev->recv_func = gdm_mux_recv; + tty_dev->send_control = gdm_mux_send_control; + + if (register_lte_tty_device(tty_dev, &intf->dev) < 0) { + unregister_lte_tty_device(tty_dev); + mux_dev = tty_dev->priv_dev; + + ret = -1; + goto out; + } + for (i = 0; i < TTY_MAX_COUNT; i++) + mux_dev->minor[i] = tty_dev->minor[i]; + +out: + if (ret < 0) { + kfree(tty_dev); + if (mux_dev) { + release_usb(mux_dev); + kfree(mux_dev); + } + } else { + mux_dev->intf = intf; + mux_dev->usb_state = PM_NORMAL; + } + + usb_get_dev(usbdev); + usb_set_intfdata(intf, tty_dev); + + return ret; +} + +static void gdm_mux_disconnect(struct usb_interface *intf) +{ + struct tty_dev *tty_dev; + struct mux_dev *mux_dev; + struct usb_device *usbdev = interface_to_usbdev(intf); + + tty_dev = usb_get_intfdata(intf); + + mux_dev = tty_dev->priv_dev; + + release_usb(mux_dev); + unregister_lte_tty_device(tty_dev); + + kfree(mux_dev); + kfree(tty_dev); + + usb_put_dev(usbdev); +} + +static int gdm_mux_suspend(struct usb_interface *intf, pm_message_t pm_msg) +{ + struct tty_dev *tty_dev; + struct mux_dev *mux_dev; + struct rx_cxt *rx; + struct mux_rx *r, *r_next; + unsigned long flags; + + tty_dev = usb_get_intfdata(intf); + mux_dev = tty_dev->priv_dev; + rx = &mux_dev->rx; + + if (mux_dev->usb_state != PM_NORMAL) { + printk(KERN_ERR "glte: usb suspend - invalid state\n"); + return -1; + } + + mux_dev->usb_state = PM_SUSPEND; + + + spin_lock_irqsave(&rx->submit_list_lock, flags); + list_for_each_entry_safe(r, r_next, &rx->rx_submit_list, rx_submit_list) { + spin_unlock_irqrestore(&rx->submit_list_lock, flags); + usb_kill_urb(r->urb); + spin_lock_irqsave(&rx->submit_list_lock, flags); + } + spin_unlock_irqrestore(&rx->submit_list_lock, flags); + + return 0; +} + +static int gdm_mux_resume(struct usb_interface *intf) +{ + struct tty_dev *tty_dev; + struct mux_dev *mux_dev; + u8 i; + + tty_dev = usb_get_intfdata(intf); + mux_dev = tty_dev->priv_dev; + + if (mux_dev->usb_state != PM_SUSPEND) { + printk(KERN_ERR "glte: usb resume - invalid state\n"); + return -1; + } + + mux_dev->usb_state = PM_NORMAL; + + for (i = 0; i < MAX_ISSUE_NUM; i++) + gdm_mux_recv(mux_dev, mux_dev->rx_cb); + + return 0; +} + +static struct usb_driver gdm_mux_driver = { + .name = "gdm_mux", + .probe = gdm_mux_probe, + .disconnect = gdm_mux_disconnect, + .id_table = id_table, + .supports_autosuspend = 1, + .suspend = gdm_mux_suspend, + .resume = gdm_mux_resume, + .reset_resume = gdm_mux_resume, +}; + +static int __init gdm_usb_mux_init(void) +{ + + mux_rx_wq = create_workqueue("mux_rx_wq"); + if (mux_rx_wq == NULL) { + printk(KERN_ERR "glte: work queue create fail"); + return -1; + } + + register_lte_tty_driver(); + + return usb_register(&gdm_mux_driver); +} + +static void __exit gdm_usb_mux_exit(void) +{ + unregister_lte_tty_driver(); + + if (mux_rx_wq) { + flush_workqueue(mux_rx_wq); + destroy_workqueue(mux_rx_wq); + } + + usb_deregister(&gdm_mux_driver); +} + +module_init(gdm_usb_mux_init); +module_exit(gdm_usb_mux_exit); + +MODULE_DESCRIPTION("GCT LTE TTY Device Driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/gdm724x/gdm_mux.h b/drivers/staging/gdm724x/gdm_mux.h new file mode 100644 index 0000000000000..e8cfa8d401e37 --- /dev/null +++ b/drivers/staging/gdm724x/gdm_mux.h @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * 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. + */ + +#ifndef _GDM_MUX_H_ +#define _GDM_MUX_H_ + +#include +#include +#include + +#define PM_NORMAL 0 +#define PM_SUSPEND 1 + +#define USB_RT_ACM (USB_TYPE_CLASS | USB_RECIP_INTERFACE) + +#define START_FLAG 0xA512485A +#define MUX_HEADER_SIZE 14 +#define MUX_TX_MAX_SIZE (1024*10) +#define MUX_RX_MAX_SIZE (1024*30) +#define AT_PKT_TYPE 0xF011 +#define DM_PKT_TYPE 0xF010 + +#define RETRY_TIMER 30 /* msec */ + +struct mux_pkt_header { + unsigned int start_flag; + unsigned int seq_num; + unsigned int payload_size; + unsigned short packet_type; + unsigned char data[0]; +}; + +struct mux_tx { + struct urb *urb; + u8 *buf; + int len; + void (*callback)(void *cb_data); + void *cb_data; +}; + +struct mux_rx { + struct list_head free_list; + struct list_head rx_submit_list; + struct list_head to_host_list; + struct urb *urb; + u8 *buf; + void *mux_dev; + u32 offset; + u32 len; + int (*callback)(void *data, int len, int tty_index, int minor, int complete); +}; + +struct rx_cxt { + struct list_head to_host_list; + struct list_head rx_submit_list; + struct list_head rx_free_list; + spinlock_t to_host_lock; + spinlock_t submit_list_lock; + spinlock_t free_list_lock; +}; + +struct mux_dev { + struct usb_device *usbdev; + struct usb_interface *control_intf; + struct usb_interface *data_intf; + struct rx_cxt rx; + struct delayed_work work_rx; + struct usb_interface *intf; + int usb_state; + int (*rx_cb)(void *data, int len, int tty_index, int minor, int complete); + spinlock_t write_lock; + u8 minor[2]; +}; + +#endif /* _GDM_MUX_H_ */ diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c new file mode 100644 index 0000000000000..4d4040e3b1012 --- /dev/null +++ b/drivers/staging/gdm724x/gdm_tty.c @@ -0,0 +1,367 @@ +/* + * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * 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. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "gdm_tty.h" + +#define GDM_TTY_MAJOR 0 +#define GDM_TTY_MINOR 32 + +#define ACM_CTRL_DTR 0x01 +#define ACM_CTRL_RTS 0x02 +#define ACM_CTRL_DSR 0x02 +#define ACM_CTRL_RI 0x08 +#define ACM_CTRL_DCD 0x01 + +#define WRITE_SIZE 2048 + +#define MUX_TX_MAX_SIZE 2048 + +#define gdm_tty_send(n, d, l, i, c, b) (\ + n->tty_dev->send_func(n->tty_dev->priv_dev, d, l, i, c, b)) +#define gdm_tty_recv(n, c) (\ + n->tty_dev->recv_func(n->tty_dev->priv_dev, c)) +#define gdm_tty_send_control(n, r, v, d, l) (\ + n->tty_dev->send_control(n->tty_dev->priv_dev, r, v, d, l)) + +#define acm_set_comm_feature(n, v) \ + gdm_tty_send_control(n, 0x02, v, NULL, 0) + +#define GDM_TTY_READY(tty_str) (tty_str && tty_str->tty_dev && tty_str->port.count) + +struct tty_driver *g_tty_drv[TTY_MAX_COUNT] = {NULL, }; +struct tty_str *g_tty_str[TTY_MAX_COUNT][GDM_TTY_MINOR] = {{NULL, }, }; + +static char *DRIVER_STRING[TTY_MAX_COUNT] = {"GCTATC", "GCTDM"}; +static char *DEVICE_STRING[TTY_MAX_COUNT] = {"GCT-ATC", "GCT-DM"}; + +static DEFINE_MUTEX(open_mutex); + +static struct tty_port_operations gdm_tty_port_ops = { +}; + +static int gdm_tty_open(struct tty_struct *tty, struct file *filp) +{ + struct tty_str *tty_str = NULL; + int i; + int ret = 0; + + mutex_lock(&open_mutex); + + for (i = 0; i < TTY_MAX_COUNT; i++) { + if (!strcmp(tty->driver->driver_name, DRIVER_STRING[i])) { + tty_str = g_tty_str[i][tty->index]; + break; + } + } + + if (!tty_str) { + printk(KERN_INFO "glte: no tty device\n"); + mutex_unlock(&open_mutex); + return -ENODEV; + } + + set_bit(TTY_NO_WRITE_SPLIT, &tty->flags); + + tty->driver_data = tty_str; + tty_port_tty_set(&tty_str->port, tty); + tty_str->port.count++; + set_bit(ASYNCB_INITIALIZED, &tty_str->port.flags); + ret = tty_port_block_til_ready(&tty_str->port, tty, filp); + + mutex_unlock(&open_mutex); + + return ret; +} + +static void gdm_tty_close(struct tty_struct *tty, struct file *filp) +{ + struct tty_str *tty_str = tty->driver_data; + int i; + + if (!tty_str) { + printk(KERN_INFO "glte: tty device already close\n"); + return; + } + + if (tty_str->port.count != 0) { + tty_port_close_start(&tty_str->port, tty, filp); + tty_port_close_end(&tty_str->port, tty); + + if (tty_str->port.count == 0) + tty_port_tty_set(&tty_str->port, NULL); + tty_str->port.tty = NULL; + } + + if (!tty_str->tty_dev) { + for (i = 0; i < TTY_MAX_COUNT; i++) { + if (!strcmp(tty->driver->driver_name, DRIVER_STRING[i])) + break; + } + + if (i < TTY_MAX_COUNT) { + tty_unregister_device(g_tty_drv[i], tty->index); + tty_port_tty_set(&tty_str->port, NULL); + kfree(tty_str); + g_tty_str[i][tty->index] = NULL; + } + } +} + +static int gdm_tty_recv_complete(void *data, int len, int index, int minor, int complete) +{ + struct tty_str *tty_str = g_tty_str[index][minor]; + struct tty_struct *tty; + + if (!GDM_TTY_READY(tty_str)) { + if (complete == RECV_PACKET_PROCESS_COMPLETE) + gdm_tty_recv(tty_str, gdm_tty_recv_complete); + return TO_HOST_PORT_CLOSE; + } + + if (!data || !len) + goto complete_routine; + + tty = tty_port_tty_get(&tty_str->port); + + if (tty_buffer_request_room(tty, len) == len) { + tty_insert_flip_string(tty, data, len); + tty_flip_buffer_push(tty); + } else { + tty_kref_put(tty); + return TO_HOST_BUFFER_REQUEST_FAIL; + } + + tty_kref_put(tty); +complete_routine: + if (complete == RECV_PACKET_PROCESS_COMPLETE) + gdm_tty_recv(tty_str, gdm_tty_recv_complete); + + return TO_HOST_SUCCESS; +} + +static void gdm_tty_send_complete(void *arg) +{ + struct tty_str *tty_str = (struct tty_str *)arg; + struct tty_struct *tty; + + if (!GDM_TTY_READY(tty_str)) + return; + + tty = tty_port_tty_get(&tty_str->port); + tty_wakeup(tty); + tty_kref_put(tty); +} + +static int gdm_tty_write(struct tty_struct *tty, const unsigned char *buf, int len) +{ + struct tty_str *tty_str = tty->driver_data; + int remain = len; + int sent_len = 0; + int sending_len = 0; + + if (!GDM_TTY_READY(tty_str)) + return -ENODEV; + + if (!len) + return 0; + + while (1) { + sending_len = remain > MUX_TX_MAX_SIZE ? MUX_TX_MAX_SIZE : remain; + gdm_tty_send(tty_str, + (void *)(buf+sent_len), + sending_len, + tty_str->tty_drv_index, + gdm_tty_send_complete, + tty_str + ); + sent_len += sending_len; + remain -= sending_len; + if (remain <= 0) + break; + } + + return len; +} + +static int gdm_tty_write_room(struct tty_struct *tty) +{ + struct tty_str *tty_str = tty->driver_data; + + if (!GDM_TTY_READY(tty_str)) + return -ENODEV; + + return WRITE_SIZE; +} + +static int gdm_tty_tiocmget(struct tty_struct *tty) +{ + struct tty_str *tty_str = tty->driver_data; + + if (!GDM_TTY_READY(tty_str)) + return -ENODEV; + + return (0 & ACM_CTRL_DTR ? TIOCM_DTR : 0) | + (0 & ACM_CTRL_RTS ? TIOCM_RTS : 0) | + (0 & ACM_CTRL_DSR ? TIOCM_DSR : 0) | + (0 & ACM_CTRL_RI ? TIOCM_RI : 0) | + (0 & ACM_CTRL_DCD ? TIOCM_CD : 0) | + TIOCM_CTS; +} + +static int gdm_tty_tiocmset(struct tty_struct *tty, unsigned int set, unsigned int clear) +{ + struct tty_str *tty_str = tty->driver_data; + + if (!GDM_TTY_READY(tty_str)) + return -ENODEV; + + return 1; +} + +int register_lte_tty_device(struct tty_dev *tty_dev, struct device *dev) +{ + struct tty_str *tty_str; + int i, j; + + for (i = 0; i < TTY_MAX_COUNT; i++) { + for (j = 0; j < GDM_TTY_MINOR; j++) { + if (!g_tty_str[i][j]) + break; + } + + if (j == GDM_TTY_MINOR) { + tty_dev->minor[i] = j; + return -1; + } + + tty_str = kmalloc(sizeof(struct tty_str), GFP_KERNEL); + if (!tty_str) + return -ENOMEM; + + g_tty_str[i][j] = tty_str; + + tty_str->tty_dev = tty_dev; + tty_str->tty_drv_index = i; + tty_dev->minor[i] = j; + tty_port_init(&tty_str->port); + tty_str->port.ops = &gdm_tty_port_ops; + + if (strcmp(DEVICE_STRING[i], "GCT-ATC") != 0) + dev = NULL; + tty_register_device(g_tty_drv[i], j, dev); + } + + acm_set_comm_feature(tty_str, 1); + + for (i = 0; i < MAX_ISSUE_NUM; i++) + gdm_tty_recv(tty_str, gdm_tty_recv_complete); + + return 0; +} + +void unregister_lte_tty_device(struct tty_dev *tty_dev) +{ + struct tty_str *tty_str; + int i; + + for (i = 0; i < TTY_MAX_COUNT; i++) { + if (tty_dev->minor[i] >= GDM_TTY_MINOR) + continue; + + tty_str = g_tty_str[i][tty_dev->minor[i]]; + if (!tty_str) + continue; + + tty_str->tty_dev = NULL; + + if (!tty_str->port.count) { + tty_unregister_device(g_tty_drv[i], tty_dev->minor[i]); + tty_port_tty_set(&tty_str->port, NULL); + kfree(tty_str); + g_tty_str[i][tty_dev->minor[i]] = NULL; + } + } +} + +static void gdm_tty_set_termios(struct tty_struct *tty, struct ktermios *termios_old) +{ + return; +} + +static const struct tty_operations gdm_tty_ops = { + .open = gdm_tty_open, + .close = gdm_tty_close, + .write = gdm_tty_write, + .write_room = gdm_tty_write_room, + .tiocmget = gdm_tty_tiocmget, + .tiocmset = gdm_tty_tiocmset, + .set_termios = gdm_tty_set_termios, +}; + +int register_lte_tty_driver(void) +{ + struct tty_driver *tty_driver = NULL; + int i; + int ret; + + for (i = 0; i < TTY_MAX_COUNT; i++) { + tty_driver = alloc_tty_driver(GDM_TTY_MINOR); + if (!tty_driver) { + printk(KERN_ERR "glte: alloc_tty_driver fail\n"); + return -ENOMEM; + } + + tty_driver->owner = THIS_MODULE; + tty_driver->driver_name = DRIVER_STRING[i]; + tty_driver->name = DEVICE_STRING[i]; + tty_driver->major = GDM_TTY_MAJOR; + tty_driver->type = TTY_DRIVER_TYPE_SERIAL; + tty_driver->subtype = SERIAL_TYPE_NORMAL; + tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; + tty_driver->init_termios = tty_std_termios; + tty_driver->init_termios.c_cflag = B9600 | CS8 | HUPCL | CLOCAL; + tty_driver->init_termios.c_lflag = ISIG | ICANON | IEXTEN; + tty_set_operations(tty_driver, &gdm_tty_ops); + + ret = tty_register_driver(tty_driver); + + g_tty_drv[i] = tty_driver; + } + + return ret; +} + +void unregister_lte_tty_driver(void) +{ + struct tty_driver *tty_driver; + int i; + + for (i = 0; i < TTY_MAX_COUNT; i++) { + tty_driver = g_tty_drv[i]; + if (tty_driver) { + tty_unregister_driver(tty_driver); + put_tty_driver(tty_driver); + } + } +} diff --git a/drivers/staging/gdm724x/gdm_tty.h b/drivers/staging/gdm724x/gdm_tty.h new file mode 100644 index 0000000000000..bfe654eb378b0 --- /dev/null +++ b/drivers/staging/gdm724x/gdm_tty.h @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * 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. + */ + +#ifndef _GDM_TTY_H_ +#define _GDM_TTY_H_ + +#include +#include +#include + + +#define TTY_MAX_COUNT 2 + +#define MAX_ISSUE_NUM 3 + +enum TO_HOST_RESULT { + TO_HOST_SUCCESS = 0, + TO_HOST_BUFFER_REQUEST_FAIL = 1, + TO_HOST_PORT_CLOSE = 2, + TO_HOST_INVALID_PACKET = 3, +}; + +enum RECV_PACKET_PROCESS { + RECV_PACKET_PROCESS_COMPLETE = 0, + RECV_PACKET_PROCESS_CONTINUE = 1, +}; + +struct tty_dev { + void *priv_dev; + int (*send_func)(void *priv_dev, void *data, int len, int tty_index, + void (*cb)(void *cb_data), void *cb_data); + int (*recv_func)(void *priv_dev, int (*cb)(void *data, int len, int tty_index, int minor, int complete)); + int (*send_control)(void *priv_dev, int request, int value, void *data, int len); + u8 minor[2]; +}; + +struct tty_str { + struct tty_dev *tty_dev; + int tty_drv_index; + struct tty_port port; +}; + +int register_lte_tty_driver(void); +void unregister_lte_tty_driver(void); +int register_lte_tty_device(struct tty_dev *tty_dev, struct device *dev); +void unregister_lte_tty_device(struct tty_dev *tty_dev); + +#endif /* _GDM_USB_H_ */ + diff --git a/drivers/staging/gdm724x/gdm_usb.c b/drivers/staging/gdm724x/gdm_usb.c new file mode 100644 index 0000000000000..40d362e5b9592 --- /dev/null +++ b/drivers/staging/gdm724x/gdm_usb.c @@ -0,0 +1,1047 @@ +/* + * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * 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. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "gdm_usb.h" +#include "gdm_lte.h" +#include "hci.h" +#include "hci_packet.h" +#include "gdm_endian.h" + +#define USB_DEVICE_CDC_DATA(vid, pid) \ + .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_CLASS | USB_DEVICE_ID_MATCH_INT_SUBCLASS,\ + .idVendor = vid,\ + .idProduct = pid,\ + .bInterfaceClass = USB_CLASS_COMM,\ + .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET + +#define USB_DEVICE_MASS_DATA(vid, pid) \ + .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,\ + .idVendor = vid,\ + .idProduct = pid,\ + .bInterfaceSubClass = USB_SC_SCSI, \ + .bInterfaceClass = USB_CLASS_MASS_STORAGE,\ + .bInterfaceProtocol = USB_PR_BULK + +static const struct usb_device_id id_table[] = { + { USB_DEVICE_CDC_DATA(VID_GCT, PID_GDM7240) }, /* GCT GDM7240 */ + { USB_DEVICE_CDC_DATA(VID_GCT, PID_GDM7243) }, /* GCT GDM7243 */ + { } +}; + +MODULE_DEVICE_TABLE(usb, id_table); + +static struct workqueue_struct *usb_tx_wq; +static struct workqueue_struct *usb_rx_wq; + +static void do_tx(struct work_struct *work); +static void do_rx(struct work_struct *work); + +static int gdm_usb_recv(void *priv_dev, + int (*cb)(void *cb_data, void *data, int len, int context), + void *cb_data, + int context); + +static int request_mac_address(struct lte_udev *udev) +{ + u8 buf[16] = {0,}; + struct hci_packet *hci = (struct hci_packet *)buf; + struct usb_device *usbdev = udev->usbdev; + int actual; + int ret = -1; + + hci->cmd_evt = gdm_cpu_to_dev16(&udev->gdm_ed, LTE_GET_INFORMATION); + hci->len = gdm_cpu_to_dev16(&udev->gdm_ed, 1); + hci->data[0] = MAC_ADDRESS; + + ret = usb_bulk_msg(usbdev, usb_sndbulkpipe(usbdev, 2), buf, 5, + &actual, 1000); + + udev->request_mac_addr = 1; + + return ret; +} + +static struct usb_tx *alloc_tx_struct(int len) +{ + struct usb_tx *t = NULL; + int ret = 0; + + t = kmalloc(sizeof(struct usb_tx), GFP_ATOMIC); + if (!t) { + ret = -ENOMEM; + goto out; + } + memset(t, 0, sizeof(struct usb_tx)); + + t->urb = usb_alloc_urb(0, GFP_ATOMIC); + if (!(len % 512)) + len++; + + t->buf = kmalloc(len, GFP_ATOMIC); + if (!t->urb || !t->buf) { + ret = -ENOMEM; + goto out; + } + +out: + if (ret < 0) { + if (t) { + usb_free_urb(t->urb); + kfree(t->buf); + kfree(t); + } + return NULL; + } + + return t; +} + +static struct usb_tx_sdu *alloc_tx_sdu_struct(void) +{ + struct usb_tx_sdu *t_sdu = NULL; + int ret = 0; + + + t_sdu = kmalloc(sizeof(struct usb_tx_sdu), GFP_ATOMIC); + if (!t_sdu) { + ret = -ENOMEM; + goto out; + } + memset(t_sdu, 0, sizeof(struct usb_tx_sdu)); + + t_sdu->buf = kmalloc(SDU_BUF_SIZE, GFP_ATOMIC); + if (!t_sdu->buf) { + ret = -ENOMEM; + goto out; + } +out: + + if (ret < 0) { + if (t_sdu) { + kfree(t_sdu->buf); + kfree(t_sdu); + } + return NULL; + } + + return t_sdu; +} + +static void free_tx_struct(struct usb_tx *t) +{ + if (t) { + usb_free_urb(t->urb); + kfree(t->buf); + kfree(t); + } +} + +static void free_tx_sdu_struct(struct usb_tx_sdu *t_sdu) +{ + if (t_sdu) { + kfree(t_sdu->buf); + kfree(t_sdu); + } +} + +static struct usb_tx_sdu *get_tx_sdu_struct(struct tx_cxt *tx, int *no_spc) +{ + struct usb_tx_sdu *t_sdu; + + if (list_empty(&tx->free_list)) + return NULL; + + t_sdu = list_entry(tx->free_list.next, struct usb_tx_sdu, list); + list_del(&t_sdu->list); + + tx->avail_count--; + + *no_spc = list_empty(&tx->free_list) ? 1 : 0; + + return t_sdu; +} + +static void put_tx_struct(struct tx_cxt *tx, struct usb_tx_sdu *t_sdu) +{ + list_add_tail(&t_sdu->list, &tx->free_list); + tx->avail_count++; +} + +static struct usb_rx *alloc_rx_struct(void) +{ + struct usb_rx *r = NULL; + int ret = 0; + + r = kmalloc(sizeof(struct usb_rx), GFP_ATOMIC); + if (!r) { + ret = -ENOMEM; + goto out; + } + + r->urb = usb_alloc_urb(0, GFP_ATOMIC); + r->buf = kmalloc(RX_BUF_SIZE, GFP_ATOMIC); + if (!r->urb || !r->buf) { + ret = -ENOMEM; + goto out; + } +out: + + if (ret < 0) { + if (r) { + usb_free_urb(r->urb); + kfree(r->buf); + kfree(r); + } + return NULL; + } + + return r; +} + +static void free_rx_struct(struct usb_rx *r) +{ + if (r) { + usb_free_urb(r->urb); + kfree(r->buf); + kfree(r); + } +} + +static struct usb_rx *get_rx_struct(struct rx_cxt *rx, int *no_spc) +{ + struct usb_rx *r; + unsigned long flags; + + spin_lock_irqsave(&rx->rx_lock, flags); + + if (list_empty(&rx->free_list)) { + spin_unlock_irqrestore(&rx->rx_lock, flags); + return NULL; + } + + r = list_entry(rx->free_list.next, struct usb_rx, free_list); + list_del(&r->free_list); + + rx->avail_count--; + + *no_spc = list_empty(&rx->free_list) ? 1 : 0; + + spin_unlock_irqrestore(&rx->rx_lock, flags); + + return r; +} + +static void put_rx_struct(struct rx_cxt *rx, struct usb_rx *r) +{ + unsigned long flags; + + spin_lock_irqsave(&rx->rx_lock, flags); + + list_add_tail(&r->free_list, &rx->free_list); + rx->avail_count++; + + spin_unlock_irqrestore(&rx->rx_lock, flags); +} + +static void release_usb(struct lte_udev *udev) +{ + struct rx_cxt *rx = &udev->rx; + struct tx_cxt *tx = &udev->tx; + struct usb_tx *t, *t_next; + struct usb_rx *r, *r_next; + struct usb_tx_sdu *t_sdu, *t_sdu_next; + unsigned long flags; + + spin_lock_irqsave(&tx->lock, flags); + list_for_each_entry_safe(t_sdu, t_sdu_next, &tx->sdu_list, list) + { + list_del(&t_sdu->list); + free_tx_sdu_struct(t_sdu); + } + + list_for_each_entry_safe(t, t_next, &tx->hci_list, list) + { + list_del(&t->list); + free_tx_struct(t); + } + + list_for_each_entry_safe(t_sdu, t_sdu_next, &tx->free_list, list) + { + list_del(&t_sdu->list); + free_tx_sdu_struct(t_sdu); + } + spin_unlock_irqrestore(&tx->lock, flags); + + spin_lock_irqsave(&rx->submit_lock, flags); + list_for_each_entry_safe(r, r_next, &rx->rx_submit_list, rx_submit_list) + { + spin_unlock_irqrestore(&rx->submit_lock, flags); + usb_kill_urb(r->urb); + spin_lock_irqsave(&rx->submit_lock, flags); + } + spin_unlock_irqrestore(&rx->submit_lock, flags); + + spin_lock_irqsave(&rx->rx_lock, flags); + list_for_each_entry_safe(r, r_next, &rx->free_list, free_list) + { + list_del(&r->free_list); + free_rx_struct(r); + } + spin_unlock_irqrestore(&rx->rx_lock, flags); + + spin_lock_irqsave(&rx->to_host_lock, flags); + list_for_each_entry_safe(r, r_next, &rx->to_host_list, to_host_list) + { + if (r->index == (void *)udev) { + list_del(&r->to_host_list); + free_rx_struct(r); + } + } + spin_unlock_irqrestore(&rx->to_host_lock, flags); +} + +static int init_usb(struct lte_udev *udev) +{ + int ret = 0; + int i; + struct tx_cxt *tx = &udev->tx; + struct rx_cxt *rx = &udev->rx; + struct usb_tx_sdu *t_sdu = NULL; + struct usb_rx *r = NULL; + + udev->send_complete = 1; + udev->tx_stop = 0; + udev->request_mac_addr = 0; + udev->usb_state = PM_NORMAL; + + INIT_LIST_HEAD(&tx->sdu_list); + INIT_LIST_HEAD(&tx->hci_list); + INIT_LIST_HEAD(&tx->free_list); + INIT_LIST_HEAD(&rx->rx_submit_list); + INIT_LIST_HEAD(&rx->free_list); + INIT_LIST_HEAD(&rx->to_host_list); + spin_lock_init(&tx->lock); + spin_lock_init(&rx->rx_lock); + spin_lock_init(&rx->submit_lock); + spin_lock_init(&rx->to_host_lock); + + tx->avail_count = 0; + rx->avail_count = 0; + + udev->rx_cb = NULL; + + for (i = 0; i < MAX_NUM_SDU_BUF; i++) { + t_sdu = alloc_tx_sdu_struct(); + if (t_sdu == NULL) { + ret = -ENOMEM; + goto fail; + } + + list_add(&t_sdu->list, &tx->free_list); + tx->avail_count++; + } + + for (i = 0; i < MAX_RX_SUBMIT_COUNT*2; i++) { + r = alloc_rx_struct(); + if (r == NULL) { + ret = -ENOMEM; + goto fail; + } + + list_add(&r->free_list, &rx->free_list); + rx->avail_count++; + } + INIT_DELAYED_WORK(&udev->work_tx, do_tx); + INIT_DELAYED_WORK(&udev->work_rx, do_rx); + return 0; +fail: + return ret; +} + +static int set_mac_address(u8 *data, void *arg) +{ + struct phy_dev *phy_dev = (struct phy_dev *)arg; + struct lte_udev *udev = phy_dev->priv_dev; + struct tlv *tlv = (struct tlv *)data; + u8 mac_address[ETH_ALEN] = {0, }; + + if (tlv->type == MAC_ADDRESS && udev->request_mac_addr) { + memcpy(mac_address, tlv->data, tlv->len); + + if (register_lte_device(phy_dev, &udev->intf->dev, mac_address) < 0) + printk(KERN_ERR "glte: register lte device failed\n"); + + udev->request_mac_addr = 0; + + return 1; + } + + return 0; +} + +static void do_rx(struct work_struct *work) +{ + struct lte_udev *udev = container_of(work, struct lte_udev, work_rx.work); + struct rx_cxt *rx = &udev->rx; + struct usb_rx *r; + struct hci_packet *hci; + struct phy_dev *phy_dev; + u16 cmd_evt; + int ret; + unsigned long flags; + + while (1) { + spin_lock_irqsave(&rx->to_host_lock, flags); + if (list_empty(&rx->to_host_list)) { + spin_unlock_irqrestore(&rx->to_host_lock, flags); + break; + } + r = list_entry(rx->to_host_list.next, struct usb_rx, to_host_list); + list_del(&r->to_host_list); + spin_unlock_irqrestore(&rx->to_host_lock, flags); + + phy_dev = (struct phy_dev *)r->cb_data; + udev = (struct lte_udev *)phy_dev->priv_dev; + hci = (struct hci_packet *)r->buf; + cmd_evt = gdm_dev16_to_cpu(&udev->gdm_ed, hci->cmd_evt); + + switch (cmd_evt) { + case LTE_GET_INFORMATION_RESULT: + if (set_mac_address(hci->data, r->cb_data) == 0) { + ret = r->callback(r->cb_data, + r->buf, + r->urb->actual_length, + KERNEL_THREAD); + } + break; + + default: + if (r->callback) { + ret = r->callback(r->cb_data, + r->buf, + r->urb->actual_length, + KERNEL_THREAD); + + if (ret == -EAGAIN) + printk(KERN_ERR "glte: failed to send received data\n"); + } + break; + } + + put_rx_struct(rx, r); + + gdm_usb_recv(udev, + r->callback, + r->cb_data, + USB_COMPLETE); + } +} + +static void remove_rx_submit_list(struct usb_rx *r, struct rx_cxt *rx) +{ + unsigned long flags; + struct usb_rx *r_remove, *r_remove_next; + + spin_lock_irqsave(&rx->submit_lock, flags); + list_for_each_entry_safe(r_remove, r_remove_next, &rx->rx_submit_list, rx_submit_list) + { + if (r == r_remove) { + list_del(&r->rx_submit_list); + break; + } + } + spin_unlock_irqrestore(&rx->submit_lock, flags); +} + +static void gdm_usb_rcv_complete(struct urb *urb) +{ + struct usb_rx *r = urb->context; + struct rx_cxt *rx = r->rx; + unsigned long flags; + struct lte_udev *udev = container_of(r->rx, struct lte_udev, rx); + struct usb_device *usbdev = udev->usbdev; + + remove_rx_submit_list(r, rx); + + if (!urb->status && r->callback) { + spin_lock_irqsave(&rx->to_host_lock, flags); + list_add_tail(&r->to_host_list, &rx->to_host_list); + queue_work(usb_rx_wq, &udev->work_rx.work); + spin_unlock_irqrestore(&rx->to_host_lock, flags); + } else { + if (urb->status && udev->usb_state == PM_NORMAL) + printk(KERN_ERR "glte: gdm_usb_rcv_complete urb status error %d\n", urb->status); + + put_rx_struct(rx, r); + } + + usb_mark_last_busy(usbdev); +} + +static int gdm_usb_recv(void *priv_dev, + int (*cb)(void *cb_data, void *data, int len, int context), + void *cb_data, + int context) +{ + struct lte_udev *udev = priv_dev; + struct usb_device *usbdev = udev->usbdev; + struct rx_cxt *rx = &udev->rx; + struct usb_rx *r; + int no_spc; + int ret; + unsigned long flags; + + if (!udev->usbdev) { + printk(KERN_ERR "glte: invalid device\n"); + return -ENODEV; + } + + r = get_rx_struct(rx, &no_spc); + if (!r) { + printk(KERN_ERR "glte: Out of Memory\n"); + return -ENOMEM; + } + + udev->rx_cb = cb; + r->callback = cb; + r->cb_data = cb_data; + r->index = (void *)udev; + r->rx = rx; + + usb_fill_bulk_urb(r->urb, + usbdev, + usb_rcvbulkpipe(usbdev, 0x83), + r->buf, + RX_BUF_SIZE, + gdm_usb_rcv_complete, + r); + + spin_lock_irqsave(&rx->submit_lock, flags); + list_add_tail(&r->rx_submit_list, &rx->rx_submit_list); + spin_unlock_irqrestore(&rx->submit_lock, flags); + + if (context == KERNEL_THREAD) + ret = usb_submit_urb(r->urb, GFP_KERNEL); + else + ret = usb_submit_urb(r->urb, GFP_ATOMIC); + + if (ret) { + spin_lock_irqsave(&rx->submit_lock, flags); + list_del(&r->rx_submit_list); + spin_unlock_irqrestore(&rx->submit_lock, flags); + + printk(KERN_ERR "glte: usb_submit_urb fail (%p)\n", r); + put_rx_struct(rx, r); + } + + return ret; +} + +static void gdm_usb_send_complete(struct urb *urb) +{ + struct usb_tx *t = urb->context; + struct tx_cxt *tx = t->tx; + struct lte_udev *udev = container_of(tx, struct lte_udev, tx); + unsigned long flags; + + if (urb->status == -ECONNRESET) { + printk(KERN_INFO "glte: CONNRESET\n"); + return; + } + + if (t->callback) + t->callback(t->cb_data); + + free_tx_struct(t); + + spin_lock_irqsave(&tx->lock, flags); + udev->send_complete = 1; + queue_work(usb_tx_wq, &udev->work_tx.work); + spin_unlock_irqrestore(&tx->lock, flags); +} + +static int send_tx_packet(struct usb_device *usbdev, struct usb_tx *t, u32 len) +{ + int ret = 0; + + if (!(len%512)) + len++; + + usb_fill_bulk_urb(t->urb, + usbdev, + usb_sndbulkpipe(usbdev, 2), + t->buf, + len, + gdm_usb_send_complete, + t); + + ret = usb_submit_urb(t->urb, GFP_ATOMIC); + + if (ret) + printk(KERN_ERR "glte: usb_submit_urb fail %d\n", ret); + + usb_mark_last_busy(usbdev); + + return ret; +} + +static u32 packet_aggregation(struct lte_udev *udev, u8 *send_buf) +{ + struct tx_cxt *tx = &udev->tx; + struct usb_tx_sdu *t_sdu = NULL; + struct multi_sdu *multi_sdu = (struct multi_sdu *)send_buf; + u16 send_len = 0; + u16 num_packet = 0; + unsigned long flags; + + multi_sdu->cmd_evt = gdm_cpu_to_dev16(&udev->gdm_ed, LTE_TX_MULTI_SDU); + + while (num_packet < MAX_PACKET_IN_MULTI_SDU) { + spin_lock_irqsave(&tx->lock, flags); + if (list_empty(&tx->sdu_list)) { + spin_unlock_irqrestore(&tx->lock, flags); + break; + } + + t_sdu = list_entry(tx->sdu_list.next, struct usb_tx_sdu, list); + if (send_len + t_sdu->len > MAX_SDU_SIZE) { + spin_unlock_irqrestore(&tx->lock, flags); + break; + } + + list_del(&t_sdu->list); + spin_unlock_irqrestore(&tx->lock, flags); + + memcpy(multi_sdu->data + send_len, t_sdu->buf, t_sdu->len); + + send_len += (t_sdu->len + 3) & 0xfffc; + num_packet++; + + if (tx->avail_count > 10) + t_sdu->callback(t_sdu->cb_data); + + spin_lock_irqsave(&tx->lock, flags); + put_tx_struct(tx, t_sdu); + spin_unlock_irqrestore(&tx->lock, flags); + } + + multi_sdu->len = gdm_cpu_to_dev16(&udev->gdm_ed, send_len); + multi_sdu->num_packet = gdm_cpu_to_dev16(&udev->gdm_ed, num_packet); + + return send_len + offsetof(struct multi_sdu, data); +} + +static void do_tx(struct work_struct *work) +{ + struct lte_udev *udev = container_of(work, struct lte_udev, work_tx.work); + struct usb_device *usbdev = udev->usbdev; + struct tx_cxt *tx = &udev->tx; + struct usb_tx *t = NULL; + int is_send = 0; + u32 len = 0; + unsigned long flags; + + if (!usb_autopm_get_interface(udev->intf)) + usb_autopm_put_interface(udev->intf); + + if (udev->usb_state == PM_SUSPEND) + return; + + spin_lock_irqsave(&tx->lock, flags); + if (!udev->send_complete) { + spin_unlock_irqrestore(&tx->lock, flags); + return; + } else { + udev->send_complete = 0; + } + + if (!list_empty(&tx->hci_list)) { + t = list_entry(tx->hci_list.next, struct usb_tx, list); + list_del(&t->list); + len = t->len; + t->is_sdu = 0; + is_send = 1; + } else if (!list_empty(&tx->sdu_list)) { + if (udev->tx_stop) { + udev->send_complete = 1; + spin_unlock_irqrestore(&tx->lock, flags); + return; + } + + t = alloc_tx_struct(TX_BUF_SIZE); + t->callback = NULL; + t->tx = tx; + t->is_sdu = 1; + is_send = 1; + } + + if (!is_send) { + udev->send_complete = 1; + spin_unlock_irqrestore(&tx->lock, flags); + return; + } + spin_unlock_irqrestore(&tx->lock, flags); + + if (t->is_sdu) + len = packet_aggregation(udev, t->buf); + + if (send_tx_packet(usbdev, t, len)) { + printk(KERN_ERR "glte: send_tx_packet fail\n"); + t->callback = NULL; + gdm_usb_send_complete(t->urb); + } +} + +#define SDU_PARAM_LEN 12 +static int gdm_usb_sdu_send(void *priv_dev, void *data, int len, + unsigned int dftEpsId, unsigned int epsId, + void (*cb)(void *data), void *cb_data, + int dev_idx, int nic_type) +{ + struct lte_udev *udev = priv_dev; + struct tx_cxt *tx = &udev->tx; + struct usb_tx_sdu *t_sdu; + struct sdu *sdu = NULL; + unsigned long flags; + int no_spc = 0; + u16 send_len; + + if (!udev->usbdev) { + printk(KERN_ERR "glte: sdu send - invalid device\n"); + return TX_NO_DEV; + } + + spin_lock_irqsave(&tx->lock, flags); + t_sdu = get_tx_sdu_struct(tx, &no_spc); + spin_unlock_irqrestore(&tx->lock, flags); + + if (t_sdu == NULL) { + printk(KERN_ERR "glte: sdu send - free list empty\n"); + return TX_NO_SPC; + } + + sdu = (struct sdu *)t_sdu->buf; + sdu->cmd_evt = gdm_cpu_to_dev16(&udev->gdm_ed, LTE_TX_SDU); + if (nic_type == NIC_TYPE_ARP) { + send_len = len + SDU_PARAM_LEN; + memcpy(sdu->data, data, len); + } else { + send_len = len - ETH_HLEN; + send_len += SDU_PARAM_LEN; + memcpy(sdu->data, data+ETH_HLEN, len-ETH_HLEN); + } + + sdu->len = gdm_cpu_to_dev16(&udev->gdm_ed, send_len); + sdu->dftEpsId = gdm_cpu_to_dev32(&udev->gdm_ed, dftEpsId); + sdu->bearer_ID = gdm_cpu_to_dev32(&udev->gdm_ed, epsId); + sdu->nic_type = gdm_cpu_to_dev32(&udev->gdm_ed, nic_type); + + t_sdu->len = send_len + HCI_HEADER_SIZE; + t_sdu->callback = cb; + t_sdu->cb_data = cb_data; + + spin_lock_irqsave(&tx->lock, flags); + list_add_tail(&t_sdu->list, &tx->sdu_list); + queue_work(usb_tx_wq, &udev->work_tx.work); + spin_unlock_irqrestore(&tx->lock, flags); + + if (no_spc) + return TX_NO_BUFFER; + + return 0; +} + +static int gdm_usb_hci_send(void *priv_dev, void *data, int len, + void (*cb)(void *data), void *cb_data) +{ + struct lte_udev *udev = priv_dev; + struct tx_cxt *tx = &udev->tx; + struct usb_tx *t; + unsigned long flags; + + if (!udev->usbdev) { + printk(KERN_ERR "glte: hci send - invalid device\n"); + return -ENODEV; + } + + t = alloc_tx_struct(len); + if (t == NULL) { + printk(KERN_ERR "glte: hci_send - out of memory\n"); + return -ENOMEM; + } + + memcpy(t->buf, data, len); + t->callback = cb; + t->cb_data = cb_data; + t->len = len; + t->tx = tx; + t->is_sdu = 0; + + spin_lock_irqsave(&tx->lock, flags); + list_add_tail(&t->list, &tx->hci_list); + queue_work(usb_tx_wq, &udev->work_tx.work); + spin_unlock_irqrestore(&tx->lock, flags); + + return 0; +} + +static struct gdm_endian *gdm_usb_get_endian(void *priv_dev) +{ + struct lte_udev *udev = priv_dev; + + return &udev->gdm_ed; +} + +static int gdm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id) +{ + int ret = 0; + struct phy_dev *phy_dev = NULL; + struct lte_udev *udev = NULL; + u16 idVendor, idProduct; + int bInterfaceNumber; + struct usb_device *usbdev = interface_to_usbdev(intf); + + bInterfaceNumber = intf->cur_altsetting->desc.bInterfaceNumber; + idVendor = __le16_to_cpu(usbdev->descriptor.idVendor); + idProduct = __le16_to_cpu(usbdev->descriptor.idProduct); + + printk(KERN_INFO "glte: net vid = 0x%04x pid = 0x%04x\n", idVendor, idProduct); + + if (bInterfaceNumber > NETWORK_INTERFACE) { + printk(KERN_INFO "glte: not a network device"); + return -1; + } + + phy_dev = kmalloc(sizeof(struct phy_dev), GFP_ATOMIC); + if (!phy_dev) { + ret = -ENOMEM; + goto out; + } + + udev = kmalloc(sizeof(struct lte_udev), GFP_ATOMIC); + if (!udev) { + ret = -ENOMEM; + goto out; + } + + memset(phy_dev, 0, sizeof(struct phy_dev)); + memset(udev, 0, sizeof(struct lte_udev)); + + phy_dev->priv_dev = (void *)udev; + phy_dev->send_hci_func = gdm_usb_hci_send; + phy_dev->send_sdu_func = gdm_usb_sdu_send; + phy_dev->rcv_func = gdm_usb_recv; + phy_dev->get_endian = gdm_usb_get_endian; + + udev->usbdev = usbdev; + ret = init_usb(udev); + if (ret < 0) { + printk(KERN_ERR "glte: init_usb func fail\n"); + goto out; + } + udev->intf = intf; + + intf->needs_remote_wakeup = 1; + usb_enable_autosuspend(usbdev); + pm_runtime_set_autosuspend_delay(&usbdev->dev, AUTO_SUSPEND_TIMER); + + /* List up hosts with big endians, otherwise, defaults to little endian */ + if (idProduct == PID_GDM7243) + set_endian(&udev->gdm_ed, ENDIANNESS_BIG); + else + set_endian(&udev->gdm_ed, ENDIANNESS_LITTLE); + + ret = request_mac_address(udev); + if (ret < 0) { + printk(KERN_ERR "glte: request Mac address failed\n"); + goto out; + } + + start_rx_proc(phy_dev); +out: + + if (ret < 0) { + kfree(phy_dev); + if (udev) { + release_usb(udev); + kfree(udev); + } + } + + usb_get_dev(usbdev); + usb_set_intfdata(intf, phy_dev); + + return ret; +} + +static void gdm_usb_disconnect(struct usb_interface *intf) +{ + struct phy_dev *phy_dev; + struct lte_udev *udev; + u16 idVendor, idProduct; + struct usb_device *usbdev; + usbdev = interface_to_usbdev(intf); + + idVendor = __le16_to_cpu(usbdev->descriptor.idVendor); + idProduct = __le16_to_cpu(usbdev->descriptor.idProduct); + + phy_dev = usb_get_intfdata(intf); + + udev = phy_dev->priv_dev; + unregister_lte_device(phy_dev); + + release_usb(udev); + + kfree(udev); + udev = NULL; + + kfree(phy_dev); + phy_dev = NULL; + + usb_put_dev(usbdev); +} + +static int gdm_usb_suspend(struct usb_interface *intf, pm_message_t pm_msg) +{ + struct phy_dev *phy_dev; + struct lte_udev *udev; + struct rx_cxt *rx; + struct usb_rx *r; + struct usb_rx *r_next; + unsigned long flags; + + phy_dev = usb_get_intfdata(intf); + udev = phy_dev->priv_dev; + rx = &udev->rx; + if (udev->usb_state != PM_NORMAL) { + printk(KERN_ERR "glte: usb suspend - invalid state"); + return -1; + } + + udev->usb_state = PM_SUSPEND; + + spin_lock_irqsave(&rx->submit_lock, flags); + list_for_each_entry_safe(r, r_next, &rx->rx_submit_list, rx_submit_list) + { + spin_unlock_irqrestore(&rx->submit_lock, flags); + usb_kill_urb(r->urb); + spin_lock_irqsave(&rx->submit_lock, flags); + } + spin_unlock_irqrestore(&rx->submit_lock, flags); + + return 0; +} + +static int gdm_usb_resume(struct usb_interface *intf) +{ + struct phy_dev *phy_dev; + struct lte_udev *udev; + struct tx_cxt *tx; + struct rx_cxt *rx; + unsigned long flags; + int issue_count; + int i; + + phy_dev = usb_get_intfdata(intf); + udev = phy_dev->priv_dev; + rx = &udev->rx; + + if (udev->usb_state != PM_SUSPEND) { + printk(KERN_ERR "glte: usb resume - invalid state"); + return -1; + } + udev->usb_state = PM_NORMAL; + + spin_lock_irqsave(&rx->rx_lock, flags); + issue_count = rx->avail_count - MAX_RX_SUBMIT_COUNT; + spin_unlock_irqrestore(&rx->rx_lock, flags); + + if (issue_count >= 0) { + for (i = 0; i < issue_count; i++) + gdm_usb_recv(phy_dev->priv_dev, + udev->rx_cb, + phy_dev, + USB_COMPLETE); + } + + tx = &udev->tx; + spin_lock_irqsave(&tx->lock, flags); + queue_work(usb_tx_wq, &udev->work_tx.work); + spin_unlock_irqrestore(&tx->lock, flags); + + return 0; +} + +static struct usb_driver gdm_usb_lte_driver = { + .name = "gdm_lte", + .probe = gdm_usb_probe, + .disconnect = gdm_usb_disconnect, + .id_table = id_table, + .supports_autosuspend = 1, + .suspend = gdm_usb_suspend, + .resume = gdm_usb_resume, + .reset_resume = gdm_usb_resume, +}; + +static int __init gdm_usb_lte_init(void) +{ + if (gdm_lte_event_init() < 0) { + printk(KERN_ERR "glte: error creating event\n"); + return -1; + } + + usb_tx_wq = create_workqueue("usb_tx_wq"); + if (usb_tx_wq == NULL) + return -1; + + usb_rx_wq = create_workqueue("usb_rx_wq"); + if (usb_rx_wq == NULL) + return -1; + + return usb_register(&gdm_usb_lte_driver); +} + +static void __exit gdm_usb_lte_exit(void) +{ + gdm_lte_event_exit(); + + usb_deregister(&gdm_usb_lte_driver); + + if (usb_tx_wq) { + flush_workqueue(usb_tx_wq); + destroy_workqueue(usb_tx_wq); + } + + if (usb_rx_wq) { + flush_workqueue(usb_rx_wq); + destroy_workqueue(usb_rx_wq); + } +} + +module_init(gdm_usb_lte_init); +module_exit(gdm_usb_lte_exit); + +MODULE_VERSION(DRIVER_VERSION); +MODULE_DESCRIPTION("GCT LTE USB Device Driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/gdm724x/gdm_usb.h b/drivers/staging/gdm724x/gdm_usb.h new file mode 100644 index 0000000000000..38f6537dced00 --- /dev/null +++ b/drivers/staging/gdm724x/gdm_usb.h @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * 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. + */ + +#ifndef _GDM_USB_H_ +#define _GDM_USB_H_ + +#include +#include +#include +#include +#include + +#include "gdm_endian.h" +#include "hci_packet.h" + +#define PM_NORMAL 0 +#define PM_SUSPEND 1 +#define AUTO_SUSPEND_TIMER 5000 /* ms */ + +#define RX_BUF_SIZE (1024*32) +#define TX_BUF_SIZE (1024*32) +#define SDU_BUF_SIZE 2048 +#define MAX_SDU_SIZE (1024*30) +#define MAX_PACKET_IN_MULTI_SDU 256 + +#define VID_GCT 0x1076 +#define PID_GDM7240 0x8000 +#define PID_GDM7243 0x9000 + +#define NETWORK_INTERFACE 1 +#define USB_SC_SCSI 0x06 +#define USB_PR_BULK 0x50 + +#define MAX_NUM_SDU_BUF 64 + +struct usb_tx { + struct list_head list; + struct urb *urb; + u8 *buf; + u32 len; + void (*callback)(void *cb_data); + void *cb_data; + struct tx_cxt *tx; + u8 is_sdu; +}; + +struct usb_tx_sdu { + struct list_head list; + u8 *buf; + u32 len; + void (*callback)(void *cb_data); + void *cb_data; +}; + +struct usb_rx { + struct list_head to_host_list; + struct list_head free_list; + struct list_head rx_submit_list; + struct rx_cxt *rx; + struct urb *urb; + u8 *buf; + int (*callback)(void *cb_data, void *data, int len, int context); + void *cb_data; + void *index; +}; + +struct tx_cxt { + struct list_head sdu_list; + struct list_head hci_list; + struct list_head free_list; + u32 avail_count; + spinlock_t lock; +}; + +struct rx_cxt { + struct list_head to_host_list; + struct list_head rx_submit_list; + struct list_head free_list; + u32 avail_count; + spinlock_t to_host_lock; + spinlock_t rx_lock; + spinlock_t submit_lock; +}; + +struct lte_udev { + struct usb_device *usbdev; + struct gdm_endian gdm_ed; + struct tx_cxt tx; + struct rx_cxt rx; + struct delayed_work work_tx; + struct delayed_work work_rx; + u8 send_complete; + u8 tx_stop; + struct usb_interface *intf; + int (*rx_cb)(void *cb_data, void *data, int len, int context); + int usb_state; + u8 request_mac_addr; +}; + +#endif /* _GDM_USB_H_ */ diff --git a/drivers/staging/gdm724x/hci.h b/drivers/staging/gdm724x/hci.h new file mode 100644 index 0000000000000..9a591b0db516e --- /dev/null +++ b/drivers/staging/gdm724x/hci.h @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * 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. + */ + +#ifndef _HCI_H_ +#define _HCI_H_ + +#define LTE_GET_INFORMATION 0x3002 +#define LTE_GET_INFORMATION_RESULT 0xB003 + #define MAC_ADDRESS 0xA2 + +#define LTE_LINK_ON_OFF_INDICATION 0xB133 +#define LTE_PDN_TABLE_IND 0xB143 + +#define LTE_TX_SDU 0x3200 +#define LTE_RX_SDU 0xB201 +#define LTE_TX_MULTI_SDU 0x3202 +#define LTE_RX_MULTI_SDU 0xB203 + +#define LTE_DL_SDU_FLOW_CONTROL 0x3305 +#define LTE_UL_SDU_FLOW_CONTROL 0xB306 + +#define LTE_AT_CMD_TO_DEVICE 0x3307 +#define LTE_AT_CMD_FROM_DEVICE 0xB308 + +#define LTE_SDIO_DM_SEND_PKT 0x3312 +#define LTE_SDIO_DM_RECV_PKT 0xB313 + +#define LTE_NV_RESTORE_REQUEST 0xB30C +#define LTE_NV_RESTORE_RESPONSE 0x330D +#define LTE_NV_SAVE_REQUEST 0xB30E + #define NV_TYPE_LTE_INFO 0x00 + #define NV_TYPE_BOARD_CONFIG 0x01 + #define NV_TYPE_RF_CAL 0x02 + #define NV_TYPE_TEMP 0x03 + #define NV_TYPE_NET_INFO 0x04 + #define NV_TYPE_SAFETY_INFO 0x05 + #define NV_TYPE_CDMA_CAL 0x06 + #define NV_TYPE_VENDOR 0x07 + #define NV_TYPE_ALL 0xff +#define LTE_NV_SAVE_RESPONSE 0x330F + +#define LTE_AT_CMD_TO_DEVICE_EXT 0x3323 +#define LTE_AT_CMD_FROM_DEVICE_EXT 0xB324 + +#endif /* _HCI_H_ */ diff --git a/drivers/staging/gdm724x/hci_packet.h b/drivers/staging/gdm724x/hci_packet.h new file mode 100644 index 0000000000000..7fba8a687fafd --- /dev/null +++ b/drivers/staging/gdm724x/hci_packet.h @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * 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. + */ + +#ifndef _HCI_PACKET_H_ +#define _HCI_PACKET_H_ + +#define HCI_HEADER_SIZE 4 + +/* + * The NIC type definition: + * For backward compatibility, lower 16 bits used as they were. + * Lower 16 bit: NIC_TYPE values + * Uppoer 16 bit: NIC_TYPE Flags + */ +#define NIC_TYPE_NIC0 0x00000010 +#define NIC_TYPE_NIC1 0x00000011 +#define NIC_TYPE_NIC2 0x00000012 +#define NIC_TYPE_NIC3 0x00000013 +#define NIC_TYPE_ARP 0x00000100 +#define NIC_TYPE_ICMPV6 0x00000200 +#define NIC_TYPE_MASK 0x0000FFFF +#define NIC_TYPE_F_IPV4 0x00010000 +#define NIC_TYPE_F_IPV6 0x00020000 +#define NIC_TYPE_F_DHCP 0x00040000 +#define NIC_TYPE_F_NDP 0x00080000 +#define NIC_TYPE_F_VLAN 0x00100000 + +struct hci_packet { + u16 cmd_evt; + u16 len; + u8 data[0]; +} __packed; + +struct tlv { + u8 type; + u8 len; + u8 *data[1]; +} __packed; + +struct sdu_header { + u16 cmd_evt; + u16 len; + u32 dftEpsId; + u32 bearer_ID; + u32 nic_type; +} __packed; + +struct sdu { + u16 cmd_evt; + u16 len; + u32 dftEpsId; + u32 bearer_ID; + u32 nic_type; + u8 data[0]; +} __packed; + +struct multi_sdu { + u16 cmd_evt; + u16 len; + u16 num_packet; + u16 reserved; + u8 data[0]; +} __packed; + +struct hci_pdn_table_ind { + u16 cmd_evt; + u16 len; + u8 activate; + u32 dft_eps_id; + u32 nic_type; + u8 pdn_type; + u8 ipv4_addr[4]; + u8 ipv6_intf_id[8]; +} __packed; + +struct hci_connect_ind { + u16 cmd_evt; + u16 len; + u32 connect; +} __packed; + + +#endif /* _HCI_PACKET_H_ */ diff --git a/drivers/staging/gdm724x/lte_ioctl.h b/drivers/staging/gdm724x/lte_ioctl.h new file mode 100644 index 0000000000000..4f890e50add92 --- /dev/null +++ b/drivers/staging/gdm724x/lte_ioctl.h @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * 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. + */ + +#ifndef _LTE_IOCTL_H_ +#define _LTE_IOCTL_H_ + +#define SIOCLTEIOCTL SIOCDEVPRIVATE +#define SIOCG_DATA 0x8D10 +#define SIOCS_DATA 0x8D11 + +/* + * For historical reason, ioctl number and structure must be maintained + */ +enum { + LINK_ON, + LINK_OFF, + GET_NETWORK_STATICS, + RX_STOP, + RX_RESUME, + GET_DRV_VER, + GET_SDIO_DEVICE_STATUS, + GET_ENDIAN_INFO, +}; + +struct dev_endian_t { + unsigned char dev_endian; + unsigned char host_endian; +} __packed; + +struct data_t { + long len; + void *buf; +} __packed; + +struct wm_req_t { + union { + char ifrn_name[IFNAMSIZ]; + } ifr_ifrn; + unsigned short cmd; + unsigned short data_id; + struct data_t data; +} __packed; + +#ifndef ifr_name +#define ifr_name (ifr_ifrn.ifrm_name) +#endif + +#endif /* _LTE_IOCTL_H_ */ diff --git a/drivers/staging/gdm724x/netlink_k.c b/drivers/staging/gdm724x/netlink_k.c new file mode 100644 index 0000000000000..9819bf0148571 --- /dev/null +++ b/drivers/staging/gdm724x/netlink_k.c @@ -0,0 +1,161 @@ +/* + * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * 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. + */ + +#include +#include +#include +#include +#include +#include + +#include "netlink_k.h" + +#if defined(DEFINE_MUTEX) +static DEFINE_MUTEX(netlink_mutex); +#else +static struct semaphore netlink_mutex; +#define mutex_lock(x) down(x) +#define mutex_unlock(x) up(x) +#endif + +#define ND_MAX_GROUP 30 +#define ND_IFINDEX_LEN sizeof(int) +#define ND_NLMSG_SPACE(len) (NLMSG_SPACE(len) + ND_IFINDEX_LEN) +#define ND_NLMSG_DATA(nlh) ((void *)((char *)NLMSG_DATA(nlh) + ND_IFINDEX_LEN)) +#define ND_NLMSG_S_LEN(len) (len+ND_IFINDEX_LEN) +#define ND_NLMSG_R_LEN(nlh) (nlh->nlmsg_len-ND_IFINDEX_LEN) +#define ND_NLMSG_IFIDX(nlh) NLMSG_DATA(nlh) +#define ND_MAX_MSG_LEN (1024 * 32) + +static void (*rcv_cb)(struct net_device *dev, u16 type, void *msg, int len); + +static void netlink_rcv_cb(struct sk_buff *skb) +{ + struct nlmsghdr *nlh; + struct net_device *dev; + u32 mlen; + void *msg; + int ifindex; + + if (!rcv_cb) { + printk(KERN_ERR "glte: nl cb - unregistered\n"); + return; + } + + if (skb->len < NLMSG_SPACE(0)) { + printk(KERN_ERR "glte: nl cb - invalid skb length\n"); + return; + } + + nlh = (struct nlmsghdr *)skb->data; + + if (skb->len < nlh->nlmsg_len || nlh->nlmsg_len > ND_MAX_MSG_LEN) { + printk(KERN_ERR "glte: nl cb - invalid length (%d,%d)\n", + skb->len, nlh->nlmsg_len); + return; + } + + memcpy(&ifindex, ND_NLMSG_IFIDX(nlh), ND_IFINDEX_LEN); + msg = ND_NLMSG_DATA(nlh); + mlen = ND_NLMSG_R_LEN(nlh); + + dev = dev_get_by_index(&init_net, ifindex); + if (dev) { + rcv_cb(dev, nlh->nlmsg_type, msg, mlen); + dev_put(dev); + } else { + printk(KERN_ERR "glte: nl cb - dev (%d) not found\n", ifindex); + } +} + +static void netlink_rcv(struct sk_buff *skb) +{ + mutex_lock(&netlink_mutex); + netlink_rcv_cb(skb); + mutex_unlock(&netlink_mutex); +} + +struct sock *netlink_init(int unit, + void (*cb)(struct net_device *dev, u16 type, void *msg, int len)) +{ + struct sock *sock; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0) + struct netlink_kernel_cfg cfg = { + .input = netlink_rcv, + }; +#endif + +#if !defined(DEFINE_MUTEX) + init_MUTEX(&netlink_mutex); +#endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0) + sock = netlink_kernel_create(&init_net, unit, 0, netlink_rcv, NULL, + THIS_MODULE); +#elif LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0) + sock = netlink_kernel_create(&init_net, unit, THIS_MODULE, &cfg); +#else + sock = netlink_kernel_create(&init_net, unit, &cfg); +#endif + + if (sock) + rcv_cb = cb; + + return sock; +} + +void netlink_exit(struct sock *sock) +{ + sock_release(sock->sk_socket); +} + +int netlink_send(struct sock *sock, int group, u16 type, void *msg, int len) +{ + static u32 seq; + struct sk_buff *skb = NULL; + struct nlmsghdr *nlh; + int ret = 0; + + if (group > ND_MAX_GROUP) + return -EINVAL; + + if (!netlink_has_listeners(sock, group+1)) + return -ESRCH; + + skb = alloc_skb(NLMSG_SPACE(len), GFP_ATOMIC); + if (!skb) + return -ENOMEM; + + seq++; + + nlh = nlmsg_put(skb, 0, seq, type, len, 0); + memcpy(NLMSG_DATA(nlh), msg, len); +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0) + NETLINK_CB(skb).pid = 0; +#else + NETLINK_CB(skb).portid = 0; +#endif + NETLINK_CB(skb).dst_group = 0; + + ret = netlink_broadcast(sock, skb, 0, group+1, GFP_ATOMIC); + if (!ret) + return len; + + if (ret != -ESRCH) + printk(KERN_ERR "glte: nl broadcast g=%d, t=%d, l=%d, r=%d\n", + group, type, len, ret); + else if (netlink_has_listeners(sock, group+1)) + return -EAGAIN; + + return ret; +} diff --git a/drivers/staging/gdm724x/netlink_k.h b/drivers/staging/gdm724x/netlink_k.h new file mode 100644 index 0000000000000..589486d76714f --- /dev/null +++ b/drivers/staging/gdm724x/netlink_k.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * 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. + */ + +#ifndef _NETLINK_K_H +#define _NETLINK_K_H + +#include +#include + +struct sock *netlink_init(int unit, + void (*cb)(struct net_device *dev, u16 type, void *msg, int len)); +void netlink_exit(struct sock *sock); +int netlink_send(struct sock *sock, int group, u16 type, void *msg, int len); + +#endif /* _NETLINK_K_H_ */ -- GitLab From 57a39f6d727f240f61fd6262195f6dd635939522 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 24 Jul 2013 13:15:23 -0700 Subject: [PATCH 176/942] staging: gdm724x: gdm_tty: fix tty api build warnings This fixes the build warnings due to changes in the tty api. Note, I don't know if the reference counting is correct, but at least there are no more build warnings. Also the tty code needs to be reworked, no static arrays of tty devices and the like... Cc: Won Kang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm724x/gdm_tty.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c index 4d4040e3b1012..64904e012dc87 100644 --- a/drivers/staging/gdm724x/gdm_tty.c +++ b/drivers/staging/gdm724x/gdm_tty.c @@ -131,7 +131,7 @@ static void gdm_tty_close(struct tty_struct *tty, struct file *filp) static int gdm_tty_recv_complete(void *data, int len, int index, int minor, int complete) { struct tty_str *tty_str = g_tty_str[index][minor]; - struct tty_struct *tty; + struct tty_port *tty_port; if (!GDM_TTY_READY(tty_str)) { if (complete == RECV_PACKET_PROCESS_COMPLETE) @@ -142,17 +142,15 @@ static int gdm_tty_recv_complete(void *data, int len, int index, int minor, int if (!data || !len) goto complete_routine; - tty = tty_port_tty_get(&tty_str->port); + tty_port = &tty_str->port; - if (tty_buffer_request_room(tty, len) == len) { - tty_insert_flip_string(tty, data, len); - tty_flip_buffer_push(tty); + if (tty_buffer_request_room(tty_port, len) == len) { + tty_insert_flip_string(tty_port, data, len); + tty_flip_buffer_push(tty_port); } else { - tty_kref_put(tty); return TO_HOST_BUFFER_REQUEST_FAIL; } - tty_kref_put(tty); complete_routine: if (complete == RECV_PACKET_PROCESS_COMPLETE) gdm_tty_recv(tty_str, gdm_tty_recv_complete); -- GitLab From ca7ea39361aafc769cea5d68e021fccf0dbb714b Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 24 Jul 2013 13:16:53 -0700 Subject: [PATCH 177/942] staging: gdm724x: add tty stuff to TODO file. At the least, this should be dynamic, and all of the tty stuff needs to be audited really well. Cc: Won Kang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm724x/TODO | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/gdm724x/TODO b/drivers/staging/gdm724x/TODO index cd89214aa2655..b2b571ecb063f 100644 --- a/drivers/staging/gdm724x/TODO +++ b/drivers/staging/gdm724x/TODO @@ -9,6 +9,7 @@ TODO: - Explain reason for multiples of 512 bytes in alloc_tx_struct() - Review use of atomic allocation for tx structs - No error checking for alloc_tx_struct in do_tx() +- fix up static tty port allocation to be dynamic Patches to: Jonathan Kim -- GitLab From 497a2e02a1d159269464b531aa6a3e8a60138e25 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 24 Jul 2013 13:22:29 -0700 Subject: [PATCH 178/942] staging: gdm724x: remove unneeded TO_HOST_SUCCESS enum 0 is always success in the kernel, just use that. Cc: Won Kang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm724x/gdm_tty.c | 2 +- drivers/staging/gdm724x/gdm_tty.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c index 64904e012dc87..a19c14ffe6a94 100644 --- a/drivers/staging/gdm724x/gdm_tty.c +++ b/drivers/staging/gdm724x/gdm_tty.c @@ -155,7 +155,7 @@ static int gdm_tty_recv_complete(void *data, int len, int index, int minor, int if (complete == RECV_PACKET_PROCESS_COMPLETE) gdm_tty_recv(tty_str, gdm_tty_recv_complete); - return TO_HOST_SUCCESS; + return 0; } static void gdm_tty_send_complete(void *arg) diff --git a/drivers/staging/gdm724x/gdm_tty.h b/drivers/staging/gdm724x/gdm_tty.h index bfe654eb378b0..046744b5adae1 100644 --- a/drivers/staging/gdm724x/gdm_tty.h +++ b/drivers/staging/gdm724x/gdm_tty.h @@ -24,7 +24,6 @@ #define MAX_ISSUE_NUM 3 enum TO_HOST_RESULT { - TO_HOST_SUCCESS = 0, TO_HOST_BUFFER_REQUEST_FAIL = 1, TO_HOST_PORT_CLOSE = 2, TO_HOST_INVALID_PACKET = 3, -- GitLab From aee9440d78bda37ae07f27c862aee4ec8ddf97ea Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 24 Jul 2013 13:26:12 -0700 Subject: [PATCH 179/942] staging: gdm724x: fix up line lengths in the .h files This fixes up the coding style line lengths in the .h files for this driver. Cc: Won Kang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm724x/gdm_lte.h | 6 ++++-- drivers/staging/gdm724x/gdm_mux.h | 6 ++++-- drivers/staging/gdm724x/gdm_tty.h | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/staging/gdm724x/gdm_lte.h b/drivers/staging/gdm724x/gdm_lte.h index 1614e917c0048..90c9d51fcaf0d 100644 --- a/drivers/staging/gdm724x/gdm_lte.h +++ b/drivers/staging/gdm724x/gdm_lte.h @@ -54,7 +54,8 @@ struct phy_dev { void (*cb)(void *cb_data), void *cb_data, int dev_idx, int nic_type); int (*rcv_func)(void *priv_dev, - int (*cb)(void *cb_data, void *data, int len, int context), + int (*cb)(void *cb_data, void *data, int len, + int context), void *cb_data, int context); struct gdm_endian *(*get_endian)(void *priv_dev); }; @@ -74,7 +75,8 @@ int gdm_lte_event_init(void); void gdm_lte_event_exit(void); void start_rx_proc(struct phy_dev *phy_dev); -int register_lte_device(struct phy_dev *phy_dev, struct device *dev, u8 *mac_address); +int register_lte_device(struct phy_dev *phy_dev, struct device *dev, + u8 *mac_address); void unregister_lte_device(struct phy_dev *phy_dev); #endif /* _GDM_LTE_H_ */ diff --git a/drivers/staging/gdm724x/gdm_mux.h b/drivers/staging/gdm724x/gdm_mux.h index e8cfa8d401e37..d5b0b54dd539b 100644 --- a/drivers/staging/gdm724x/gdm_mux.h +++ b/drivers/staging/gdm724x/gdm_mux.h @@ -57,7 +57,8 @@ struct mux_rx { void *mux_dev; u32 offset; u32 len; - int (*callback)(void *data, int len, int tty_index, int minor, int complete); + int (*callback)(void *data, int len, int tty_index, int minor, + int complete); }; struct rx_cxt { @@ -77,7 +78,8 @@ struct mux_dev { struct delayed_work work_rx; struct usb_interface *intf; int usb_state; - int (*rx_cb)(void *data, int len, int tty_index, int minor, int complete); + int (*rx_cb)(void *data, int len, int tty_index, int minor, + int complete); spinlock_t write_lock; u8 minor[2]; }; diff --git a/drivers/staging/gdm724x/gdm_tty.h b/drivers/staging/gdm724x/gdm_tty.h index 046744b5adae1..faeaa412eca0b 100644 --- a/drivers/staging/gdm724x/gdm_tty.h +++ b/drivers/staging/gdm724x/gdm_tty.h @@ -38,8 +38,10 @@ struct tty_dev { void *priv_dev; int (*send_func)(void *priv_dev, void *data, int len, int tty_index, void (*cb)(void *cb_data), void *cb_data); - int (*recv_func)(void *priv_dev, int (*cb)(void *data, int len, int tty_index, int minor, int complete)); - int (*send_control)(void *priv_dev, int request, int value, void *data, int len); + int (*recv_func)(void *priv_dev, int (*cb)(void *data, int len, + int tty_index, int minor, int complete)); + int (*send_control)(void *priv_dev, int request, int value, void *data, + int len); u8 minor[2]; }; -- GitLab From 0ec473b5267d01762b610d57e168b0401a137f3a Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Wed, 24 Jul 2013 14:13:03 -0700 Subject: [PATCH 180/942] staging: gdm724x: Update logging Make the logging prefixes match the module names by adding #define pr_fmt(fmt) KBUILD_MODNAME and converting printks to netdev_ when a struct netdevice * is available and and pr_ when not. Remove embedded prefixes. Add missing terminating newlines. Remove an unnecessary rx-dropped message. Remove an unnecessary temporary variable. Signed-off-by: Joe Perches Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm724x/gdm_lte.c | 38 ++++++++++++------------- drivers/staging/gdm724x/gdm_mux.c | 41 ++++++++++++++------------- drivers/staging/gdm724x/gdm_tty.c | 8 ++++-- drivers/staging/gdm724x/gdm_usb.c | 43 +++++++++++++++-------------- drivers/staging/gdm724x/netlink_k.c | 12 ++++---- 5 files changed, 73 insertions(+), 69 deletions(-) diff --git a/drivers/staging/gdm724x/gdm_lte.c b/drivers/staging/gdm724x/gdm_lte.c index 357474acb3711..0c336345f9468 100644 --- a/drivers/staging/gdm724x/gdm_lte.c +++ b/drivers/staging/gdm724x/gdm_lte.c @@ -11,6 +11,8 @@ * GNU General Public License for more details. */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include #include #include @@ -103,7 +105,6 @@ static int gdm_lte_rx(struct sk_buff *skb, struct nic *nic, int nic_type) ret = netif_rx_ni(skb); if (ret == NET_RX_DROP) { - printk(KERN_ERR "glte: rx - dropped\n"); nic->stats.rx_dropped++; } else { nic->stats.rx_packets++; @@ -416,7 +417,7 @@ static int gdm_lte_tx(struct sk_buff *skb, struct net_device *dev) nic_type = gdm_lte_tx_nic_type(dev, skb); if (nic_type == 0) { - printk(KERN_ERR "glte: tx - invalid nic_type\n"); + netdev_err(dev, "tx - invalid nic_type\n"); return -1; } @@ -504,7 +505,7 @@ static void get_dev_endian(struct data_t *data, struct net_device *dev) ret = copy_to_user(data->buf, gdm_dev_endian(nic), sizeof(struct dev_endian_t)); if (ret) - printk(KERN_INFO "glte: state - failed to copy\n"); + netdev_info(dev, "state - failed to copy\n"); } static int gdm_lte_ioctl_get_data(struct wm_req_t *req, struct net_device *dev) @@ -517,7 +518,7 @@ static int gdm_lte_ioctl_get_data(struct wm_req_t *req, struct net_device *dev) get_dev_endian(&req->data, dev); break; default: - printk(KERN_ERR "glte: ioctl - unknown type %d\n", id); + netdev_err(dev, "ioctl - unknown type %d\n", id); break; } return 0; @@ -562,7 +563,7 @@ int gdm_lte_event_init(void) return 0; } - printk(KERN_ERR "glte: event init failed\n"); + pr_err("event init failed\n"); return -1; } @@ -654,7 +655,7 @@ static void gdm_lte_netif_rx(struct net_device *dev, char *buf, int len, int fla eth.h_proto = htons(ETH_P_IPV6); vlan_eth.h_vlan_encapsulated_proto = htons(ETH_P_IPV6); } else { - printk(KERN_ERR "glte: Unknown IP version %d\n", ip_version); + netdev_err(dev, "Unknown IP version %d\n", ip_version); return; } } @@ -700,11 +701,11 @@ static void gdm_lte_multi_sdu_pkt(struct phy_dev *phy_dev, char *buf, int len) nic_type = gdm_dev32_to_cpu(phy_dev->get_endian(phy_dev->priv_dev), sdu->nic_type); if (cmd_evt != LTE_RX_SDU) { - printk(KERN_ERR "glte: rx sdu wrong hci %04x\n", cmd_evt); + pr_err("rx sdu wrong hci %04x\n", cmd_evt); return; } if (hci_len < 12) { - printk(KERN_ERR "glte: rx sdu invalid len %d\n", hci_len); + pr_err("rx sdu invalid len %d\n", hci_len); return; } @@ -713,7 +714,7 @@ static void gdm_lte_multi_sdu_pkt(struct phy_dev *phy_dev, char *buf, int len) dev = phy_dev->dev[index]; gdm_lte_netif_rx(dev, (char *)sdu->data, (int)(hci_len-12), nic_type); } else { - printk(KERN_ERR "glte: rx sdu invalid nic_type : %x\n", nic_type); + pr_err("rx sdu invalid nic_type :%x\n", nic_type); } data += ((hci_len+3) & 0xfffc) + HCI_HEADER_SIZE; @@ -730,12 +731,11 @@ static void gdm_lte_pdn_table(struct net_device *dev, char *buf, int len) nic->pdn_table.dft_eps_id = gdm_dev32_to_cpu(gdm_dev_endian(nic), pdn_table->dft_eps_id); nic->pdn_table.nic_type = gdm_dev32_to_cpu(gdm_dev_endian(nic), pdn_table->nic_type); - printk(KERN_INFO "glte: pdn %s activated, nic_type=0x%x\n", - dev->name, nic->pdn_table.nic_type); + netdev_info(dev, "pdn activated, nic_type=0x%x\n", + nic->pdn_table.nic_type); } else { memset(&nic->pdn_table, 0x00, sizeof(struct pdn_table)); - printk(KERN_INFO "glte: pdn %s deactivated\n", - dev->name); + netdev_info(dev, "pdn deactivated\n"); } } @@ -771,11 +771,9 @@ static int gdm_lte_receive_pkt(struct phy_dev *phy_dev, char *buf, int len) gdm_lte_multi_sdu_pkt(phy_dev, buf, len); break; case LTE_LINK_ON_OFF_INDICATION: - { - struct hci_connect_ind *connect_ind = (struct hci_connect_ind *)buf; - printk(KERN_INFO "glte: link %s\n", - connect_ind->connect ? "on" : "off"); - } + netdev_info(dev, "link %s\n", + ((struct hci_connect_ind *)buf)->connect + ? "on" : "off"); break; case LTE_PDN_TABLE_IND: pdn_table = (struct hci_pdn_table_ind *)buf; @@ -841,7 +839,7 @@ static void validate_mac_address(u8 *mac_address) { /* if zero address or multicast bit set, restore the default value */ if (is_zero_ether_addr(mac_address) || (mac_address[0] & 0x01)) { - printk(KERN_ERR "glte: MAC invalid, restoring default\n"); + pr_err("MAC invalid, restoring default\n"); memcpy(mac_address, gdm_lte_macaddr, 6); } } @@ -863,7 +861,7 @@ int register_lte_device(struct phy_dev *phy_dev, struct device *dev, u8 *mac_add /* Allocate netdev */ net = alloc_netdev(sizeof(struct nic), pdn_dev_name, ether_setup); if (net == NULL) { - printk(KERN_ERR "glte: alloc_netdev failed\n"); + pr_err("alloc_netdev failed\n"); ret = -ENOMEM; goto err; } diff --git a/drivers/staging/gdm724x/gdm_mux.c b/drivers/staging/gdm724x/gdm_mux.c index 2199f1bcbc842..f570bc00c9904 100644 --- a/drivers/staging/gdm724x/gdm_mux.c +++ b/drivers/staging/gdm724x/gdm_mux.c @@ -11,6 +11,8 @@ * GNU General Public License for more details. */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include #include #include @@ -172,8 +174,7 @@ static int up_to_host(struct mux_rx *r) packet_type = __le16_to_cpu(mux_header->packet_type); if (start_flag != START_FLAG) { - printk(KERN_ERR "glte: invalid START_FLAG %x\n", - start_flag); + pr_err("invalid START_FLAG %x\n", start_flag); break; } @@ -182,16 +183,14 @@ static int up_to_host(struct mux_rx *r) if (len - packet_size_sum < MUX_HEADER_SIZE + payload_size + dummy_cnt) { - printk(KERN_ERR "glte: invalid payload : %d %d %04x\n", - payload_size, len, - packet_type - ); + pr_err("invalid payload : %d %d %04x\n", + payload_size, len, packet_type); break; } index = packet_type_to_index(packet_type); if (index < 0) { - printk(KERN_ERR "glte: invalid index %d\n", index); + pr_err("invalid index %d\n", index); break; } @@ -242,7 +241,7 @@ static void do_rx(struct work_struct *work) ret = up_to_host(r); if (ret == TO_HOST_BUFFER_REQUEST_FAIL) - printk(KERN_ERR "glte: failed to send mux data to host\n"); + pr_err("failed to send mux data to host\n"); else put_rx_struct(rx, r); } @@ -272,7 +271,8 @@ static void gdm_mux_rcv_complete(struct urb *urb) if (urb->status) { if (mux_dev->usb_state == PM_NORMAL) - printk(KERN_ERR "glte: gdm_mux_rcv_complete urb status error %d\n", urb->status); + pr_err("%s: urb status error %d\n", + __func__, urb->status); put_rx_struct(rx, r); } else { r->len = r->urb->actual_length; @@ -295,13 +295,13 @@ static int gdm_mux_recv(void *priv_dev, int ret; if (!usbdev) { - printk(KERN_ERR "glte: device is disconnected\n"); + pr_err("device is disconnected\n"); return -ENODEV; } r = get_rx_struct(rx); if (!r) { - printk(KERN_ERR "glte: get_rx_struct fail\n"); + pr_err("get_rx_struct fail\n"); return -ENOMEM; } @@ -331,7 +331,7 @@ static int gdm_mux_recv(void *priv_dev, put_rx_struct(rx, r); - printk(KERN_ERR "glte: usb_submit_urb ret=%d\n", ret); + pr_err("usb_submit_urb ret=%d\n", ret); } usb_mark_last_busy(usbdev); @@ -344,7 +344,7 @@ static void gdm_mux_send_complete(struct urb *urb) struct mux_tx *t = urb->context; if (urb->status == -ECONNRESET) { - printk(KERN_INFO "glte: CONNRESET\n"); + pr_info("CONNRESET\n"); free_mux_tx(t); return; } @@ -384,7 +384,7 @@ static int gdm_mux_send(void *priv_dev, void *data, int len, int tty_index, t = alloc_mux_tx(total_len); if (!t) { - printk(KERN_ERR "glte: alloc_mux_tx fail\n"); + pr_err("alloc_mux_tx fail\n"); spin_unlock_irqrestore(&mux_dev->write_lock, flags); return -ENOMEM; } @@ -415,7 +415,7 @@ static int gdm_mux_send(void *priv_dev, void *data, int len, int tty_index, spin_unlock_irqrestore(&mux_dev->write_lock, flags); if (ret) - printk(KERN_ERR "glte: usb_submit_urb Error : %d\n", ret); + pr_err("usb_submit_urb Error: %d\n", ret); usb_mark_last_busy(usbdev); @@ -440,7 +440,7 @@ static int gdm_mux_send_control(void *priv_dev, int request, int value, void *bu ); if (ret < 0) - printk(KERN_ERR "glte: usb_control_msg error : %d\n", ret); + pr_err("usb_control_msg error: %d\n", ret); return ret < 0 ? ret : 0; } @@ -523,8 +523,7 @@ static int gdm_mux_probe(struct usb_interface *intf, const struct usb_device_id idVendor = __le16_to_cpu(usbdev->descriptor.idVendor); idProduct = __le16_to_cpu(usbdev->descriptor.idProduct); - printk(KERN_INFO "glte: mux vid = 0x%04x pid = 0x%04x\n", - idVendor, idProduct); + pr_info("mux vid = 0x%04x pid = 0x%04x\n", idVendor, idProduct); if (bInterfaceNumber != 2) { ret = -ENODEV; @@ -616,7 +615,7 @@ static int gdm_mux_suspend(struct usb_interface *intf, pm_message_t pm_msg) rx = &mux_dev->rx; if (mux_dev->usb_state != PM_NORMAL) { - printk(KERN_ERR "glte: usb suspend - invalid state\n"); + pr_err("usb suspend - invalid state\n"); return -1; } @@ -644,7 +643,7 @@ static int gdm_mux_resume(struct usb_interface *intf) mux_dev = tty_dev->priv_dev; if (mux_dev->usb_state != PM_SUSPEND) { - printk(KERN_ERR "glte: usb resume - invalid state\n"); + pr_err("usb resume - invalid state\n"); return -1; } @@ -672,7 +671,7 @@ static int __init gdm_usb_mux_init(void) mux_rx_wq = create_workqueue("mux_rx_wq"); if (mux_rx_wq == NULL) { - printk(KERN_ERR "glte: work queue create fail"); + pr_err("work queue create fail\n"); return -1; } diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c index a19c14ffe6a94..357daa80560f4 100644 --- a/drivers/staging/gdm724x/gdm_tty.c +++ b/drivers/staging/gdm724x/gdm_tty.c @@ -11,6 +11,8 @@ * GNU General Public License for more details. */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include #include #include @@ -76,7 +78,7 @@ static int gdm_tty_open(struct tty_struct *tty, struct file *filp) } if (!tty_str) { - printk(KERN_INFO "glte: no tty device\n"); + pr_info("no tty device\n"); mutex_unlock(&open_mutex); return -ENODEV; } @@ -100,7 +102,7 @@ static void gdm_tty_close(struct tty_struct *tty, struct file *filp) int i; if (!tty_str) { - printk(KERN_INFO "glte: tty device already close\n"); + pr_info("tty device already closed\n"); return; } @@ -326,7 +328,7 @@ int register_lte_tty_driver(void) for (i = 0; i < TTY_MAX_COUNT; i++) { tty_driver = alloc_tty_driver(GDM_TTY_MINOR); if (!tty_driver) { - printk(KERN_ERR "glte: alloc_tty_driver fail\n"); + pr_err("alloc_tty_driver fail\n"); return -ENOMEM; } diff --git a/drivers/staging/gdm724x/gdm_usb.c b/drivers/staging/gdm724x/gdm_usb.c index 40d362e5b9592..2e658f84486c1 100644 --- a/drivers/staging/gdm724x/gdm_usb.c +++ b/drivers/staging/gdm724x/gdm_usb.c @@ -11,6 +11,8 @@ * GNU General Public License for more details. */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include #include #include @@ -390,7 +392,7 @@ static int set_mac_address(u8 *data, void *arg) memcpy(mac_address, tlv->data, tlv->len); if (register_lte_device(phy_dev, &udev->intf->dev, mac_address) < 0) - printk(KERN_ERR "glte: register lte device failed\n"); + pr_err("register lte device failed\n"); udev->request_mac_addr = 0; @@ -444,7 +446,7 @@ static void do_rx(struct work_struct *work) KERNEL_THREAD); if (ret == -EAGAIN) - printk(KERN_ERR "glte: failed to send received data\n"); + pr_err("failed to send received data\n"); } break; } @@ -491,7 +493,8 @@ static void gdm_usb_rcv_complete(struct urb *urb) spin_unlock_irqrestore(&rx->to_host_lock, flags); } else { if (urb->status && udev->usb_state == PM_NORMAL) - printk(KERN_ERR "glte: gdm_usb_rcv_complete urb status error %d\n", urb->status); + pr_err("%s: urb status error %d\n", + __func__, urb->status); put_rx_struct(rx, r); } @@ -513,13 +516,13 @@ static int gdm_usb_recv(void *priv_dev, unsigned long flags; if (!udev->usbdev) { - printk(KERN_ERR "glte: invalid device\n"); + pr_err("invalid device\n"); return -ENODEV; } r = get_rx_struct(rx, &no_spc); if (!r) { - printk(KERN_ERR "glte: Out of Memory\n"); + pr_err("Out of Memory\n"); return -ENOMEM; } @@ -551,7 +554,7 @@ static int gdm_usb_recv(void *priv_dev, list_del(&r->rx_submit_list); spin_unlock_irqrestore(&rx->submit_lock, flags); - printk(KERN_ERR "glte: usb_submit_urb fail (%p)\n", r); + pr_err("usb_submit_urb failed (%p)\n", r); put_rx_struct(rx, r); } @@ -566,7 +569,7 @@ static void gdm_usb_send_complete(struct urb *urb) unsigned long flags; if (urb->status == -ECONNRESET) { - printk(KERN_INFO "glte: CONNRESET\n"); + pr_info("CONNRESET\n"); return; } @@ -599,7 +602,7 @@ static int send_tx_packet(struct usb_device *usbdev, struct usb_tx *t, u32 len) ret = usb_submit_urb(t->urb, GFP_ATOMIC); if (ret) - printk(KERN_ERR "glte: usb_submit_urb fail %d\n", ret); + pr_err("usb_submit_urb failed: %d\n", ret); usb_mark_last_busy(usbdev); @@ -707,7 +710,7 @@ static void do_tx(struct work_struct *work) len = packet_aggregation(udev, t->buf); if (send_tx_packet(usbdev, t, len)) { - printk(KERN_ERR "glte: send_tx_packet fail\n"); + pr_err("send_tx_packet failed\n"); t->callback = NULL; gdm_usb_send_complete(t->urb); } @@ -728,7 +731,7 @@ static int gdm_usb_sdu_send(void *priv_dev, void *data, int len, u16 send_len; if (!udev->usbdev) { - printk(KERN_ERR "glte: sdu send - invalid device\n"); + pr_err("sdu send - invalid device\n"); return TX_NO_DEV; } @@ -737,7 +740,7 @@ static int gdm_usb_sdu_send(void *priv_dev, void *data, int len, spin_unlock_irqrestore(&tx->lock, flags); if (t_sdu == NULL) { - printk(KERN_ERR "glte: sdu send - free list empty\n"); + pr_err("sdu send - free list empty\n"); return TX_NO_SPC; } @@ -781,13 +784,13 @@ static int gdm_usb_hci_send(void *priv_dev, void *data, int len, unsigned long flags; if (!udev->usbdev) { - printk(KERN_ERR "glte: hci send - invalid device\n"); + pr_err("hci send - invalid device\n"); return -ENODEV; } t = alloc_tx_struct(len); if (t == NULL) { - printk(KERN_ERR "glte: hci_send - out of memory\n"); + pr_err("hci_send - out of memory\n"); return -ENOMEM; } @@ -826,10 +829,10 @@ static int gdm_usb_probe(struct usb_interface *intf, const struct usb_device_id idVendor = __le16_to_cpu(usbdev->descriptor.idVendor); idProduct = __le16_to_cpu(usbdev->descriptor.idProduct); - printk(KERN_INFO "glte: net vid = 0x%04x pid = 0x%04x\n", idVendor, idProduct); + pr_info("net vid = 0x%04x pid = 0x%04x\n", idVendor, idProduct); if (bInterfaceNumber > NETWORK_INTERFACE) { - printk(KERN_INFO "glte: not a network device"); + pr_info("not a network device\n"); return -1; } @@ -857,7 +860,7 @@ static int gdm_usb_probe(struct usb_interface *intf, const struct usb_device_id udev->usbdev = usbdev; ret = init_usb(udev); if (ret < 0) { - printk(KERN_ERR "glte: init_usb func fail\n"); + pr_err("init_usb func failed\n"); goto out; } udev->intf = intf; @@ -874,7 +877,7 @@ static int gdm_usb_probe(struct usb_interface *intf, const struct usb_device_id ret = request_mac_address(udev); if (ret < 0) { - printk(KERN_ERR "glte: request Mac address failed\n"); + pr_err("request Mac address failed\n"); goto out; } @@ -935,7 +938,7 @@ static int gdm_usb_suspend(struct usb_interface *intf, pm_message_t pm_msg) udev = phy_dev->priv_dev; rx = &udev->rx; if (udev->usb_state != PM_NORMAL) { - printk(KERN_ERR "glte: usb suspend - invalid state"); + pr_err("usb suspend - invalid state\n"); return -1; } @@ -968,7 +971,7 @@ static int gdm_usb_resume(struct usb_interface *intf) rx = &udev->rx; if (udev->usb_state != PM_SUSPEND) { - printk(KERN_ERR "glte: usb resume - invalid state"); + pr_err("usb resume - invalid state\n"); return -1; } udev->usb_state = PM_NORMAL; @@ -1007,7 +1010,7 @@ static struct usb_driver gdm_usb_lte_driver = { static int __init gdm_usb_lte_init(void) { if (gdm_lte_event_init() < 0) { - printk(KERN_ERR "glte: error creating event\n"); + pr_err("error creating event\n"); return -1; } diff --git a/drivers/staging/gdm724x/netlink_k.c b/drivers/staging/gdm724x/netlink_k.c index 9819bf0148571..90004a7a16c2e 100644 --- a/drivers/staging/gdm724x/netlink_k.c +++ b/drivers/staging/gdm724x/netlink_k.c @@ -11,6 +11,8 @@ * GNU General Public License for more details. */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include #include #include @@ -48,19 +50,19 @@ static void netlink_rcv_cb(struct sk_buff *skb) int ifindex; if (!rcv_cb) { - printk(KERN_ERR "glte: nl cb - unregistered\n"); + pr_err("nl cb - unregistered\n"); return; } if (skb->len < NLMSG_SPACE(0)) { - printk(KERN_ERR "glte: nl cb - invalid skb length\n"); + pr_err("nl cb - invalid skb length\n"); return; } nlh = (struct nlmsghdr *)skb->data; if (skb->len < nlh->nlmsg_len || nlh->nlmsg_len > ND_MAX_MSG_LEN) { - printk(KERN_ERR "glte: nl cb - invalid length (%d,%d)\n", + pr_err("nl cb - invalid length (%d,%d)\n", skb->len, nlh->nlmsg_len); return; } @@ -74,7 +76,7 @@ static void netlink_rcv_cb(struct sk_buff *skb) rcv_cb(dev, nlh->nlmsg_type, msg, mlen); dev_put(dev); } else { - printk(KERN_ERR "glte: nl cb - dev (%d) not found\n", ifindex); + pr_err("nl cb - dev (%d) not found\n", ifindex); } } @@ -152,7 +154,7 @@ int netlink_send(struct sock *sock, int group, u16 type, void *msg, int len) return len; if (ret != -ESRCH) - printk(KERN_ERR "glte: nl broadcast g=%d, t=%d, l=%d, r=%d\n", + pr_err("nl broadcast g=%d, t=%d, l=%d, r=%d\n", group, type, len, ret); else if (netlink_has_listeners(sock, group+1)) return -EAGAIN; -- GitLab From fc2db2c84e33c4f6c3f0a85540728045eb678dfb Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 24 Jul 2013 22:01:43 -0700 Subject: [PATCH 181/942] staging: gdm724x: prevent module from being built in There are global symbols here that conflict with the rest of the kernel, preventing it from being built, so do not allow this module to be built in. Reported-by: Stephen Rothwell Cc: Won Kang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm724x/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/gdm724x/Kconfig b/drivers/staging/gdm724x/Kconfig index 10f7be10305d8..8749e907d9944 100644 --- a/drivers/staging/gdm724x/Kconfig +++ b/drivers/staging/gdm724x/Kconfig @@ -4,7 +4,7 @@ config LTE_GDM724X tristate "GCT GDM724x LTE support" - depends on NET && USB + depends on NET && USB && m help This driver supports GCT GDM724x LTE chip based USB modem devices. It exposes 4 network devices to be used per PDN and 2 tty devices to be -- GitLab From 8e24a32ed15759640516ecd92668197e2f4d686d Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 25 Jul 2013 09:37:21 -0700 Subject: [PATCH 182/942] staging: gdm724x: remove ioctl call This isn't needed, userspace can trigger off of the device id if they need to do something "special" for different devices in special modes depending on the device's endian issues. Reported-by: Dan Carpenter Cc: Won Kang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm724x/gdm_lte.c | 38 ------------------- drivers/staging/gdm724x/lte_ioctl.h | 58 ----------------------------- 2 files changed, 96 deletions(-) delete mode 100644 drivers/staging/gdm724x/lte_ioctl.h diff --git a/drivers/staging/gdm724x/gdm_lte.c b/drivers/staging/gdm724x/gdm_lte.c index 0c336345f9468..557822fdc9669 100644 --- a/drivers/staging/gdm724x/gdm_lte.c +++ b/drivers/staging/gdm724x/gdm_lte.c @@ -36,7 +36,6 @@ #include "hci.h" #include "hci_packet.h" #include "gdm_endian.h" -#include "lte_ioctl.h" /* * Netlink protocol number @@ -498,42 +497,6 @@ static struct net_device_stats *gdm_lte_stats(struct net_device *dev) return &nic->stats; } -static void get_dev_endian(struct data_t *data, struct net_device *dev) -{ - struct nic *nic = netdev_priv(dev); - unsigned long ret; - - ret = copy_to_user(data->buf, gdm_dev_endian(nic), sizeof(struct dev_endian_t)); - if (ret) - netdev_info(dev, "state - failed to copy\n"); -} - -static int gdm_lte_ioctl_get_data(struct wm_req_t *req, struct net_device *dev) -{ - u16 id = req->data_id; - - switch (id) { - case GET_ENDIAN_INFO: - /* required for the user space application to find out device endian */ - get_dev_endian(&req->data, dev); - break; - default: - netdev_err(dev, "ioctl - unknown type %d\n", id); - break; - } - return 0; -} - -static int gdm_lte_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) -{ - struct wm_req_t *req = (struct wm_req_t *)ifr; - - if (cmd != SIOCLTEIOCTL || req->cmd != SIOCG_DATA || req->data_id >= 100) - return -EOPNOTSUPP; - - return gdm_lte_ioctl_get_data(req, dev); -} - static int gdm_lte_event_send(struct net_device *dev, char *buf, int len) { struct nic *nic = netdev_priv(dev); @@ -811,7 +774,6 @@ static struct net_device_ops gdm_netdev_ops = { .ndo_set_config = gdm_lte_set_config, .ndo_start_xmit = gdm_lte_tx, .ndo_get_stats = gdm_lte_stats, - .ndo_do_ioctl = gdm_lte_ioctl, }; static u8 gdm_lte_macaddr[ETH_ALEN] = {0x00, 0x0a, 0x3b, 0x00, 0x00, 0x00}; diff --git a/drivers/staging/gdm724x/lte_ioctl.h b/drivers/staging/gdm724x/lte_ioctl.h deleted file mode 100644 index 4f890e50add92..0000000000000 --- a/drivers/staging/gdm724x/lte_ioctl.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * 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. - */ - -#ifndef _LTE_IOCTL_H_ -#define _LTE_IOCTL_H_ - -#define SIOCLTEIOCTL SIOCDEVPRIVATE -#define SIOCG_DATA 0x8D10 -#define SIOCS_DATA 0x8D11 - -/* - * For historical reason, ioctl number and structure must be maintained - */ -enum { - LINK_ON, - LINK_OFF, - GET_NETWORK_STATICS, - RX_STOP, - RX_RESUME, - GET_DRV_VER, - GET_SDIO_DEVICE_STATUS, - GET_ENDIAN_INFO, -}; - -struct dev_endian_t { - unsigned char dev_endian; - unsigned char host_endian; -} __packed; - -struct data_t { - long len; - void *buf; -} __packed; - -struct wm_req_t { - union { - char ifrn_name[IFNAMSIZ]; - } ifr_ifrn; - unsigned short cmd; - unsigned short data_id; - struct data_t data; -} __packed; - -#ifndef ifr_name -#define ifr_name (ifr_ifrn.ifrm_name) -#endif - -#endif /* _LTE_IOCTL_H_ */ -- GitLab From a772bbeeea8bc8b5218b8c2171c23a331b730ac9 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Thu, 25 Jul 2013 12:27:12 +0530 Subject: [PATCH 183/942] staging: lustre: o2iblnd: Remove duplicate inclusion of header file Removed the header files included twice. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h index e4626bf82fc77..938df0cf8c64c 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h @@ -53,7 +53,6 @@ #include #include #include -#include #include #include #include -- GitLab From 34d739605e13ac129628e3cd0129184303e07262 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Thu, 25 Jul 2013 12:27:13 +0530 Subject: [PATCH 184/942] staging: lustre: socklnd: Remove duplicate inclusion of header files Removed the header files included twice. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.h b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.h index 384eb7ca1c82d..1cfc1b168bedb 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.h +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.h @@ -57,11 +57,9 @@ #include #include #include -#include #include #include #include -#include #include #include -- GitLab From 86664eb13e8fef0a4b2c712a21e854335f22bb3f Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Thu, 25 Jul 2013 12:27:14 +0530 Subject: [PATCH 185/942] staging: lustre: obd: Remove duplicate inclusion of header file Removed the header file included twice. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/obd.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index 094eb96515dcc..003466498afe0 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -52,7 +52,6 @@ #include #include #include -#include #include #include #include -- GitLab From 6a4b8447cfae56bef3e3c4cc1b50d8b3c17e4b26 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Thu, 25 Jul 2013 12:27:15 +0530 Subject: [PATCH 186/942] staging: lustre: linux-debug: Remove duplicate inclusion of header file Removed the header files included twice. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c index 0069b5ea1c28f..6afb350731418 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c @@ -48,11 +48,8 @@ #include #include #include -#include #include - #include -#include #include #include -- GitLab From 03f278994c04e0ed4e7c975565e8057835eb037a Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Thu, 25 Jul 2013 12:27:16 +0530 Subject: [PATCH 187/942] staging: lustre: libcfs: Remove duplicate inclusion of header file Removed the header files included twice. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c index 522b28e99e41e..80a9fab9b9c19 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c @@ -54,9 +54,7 @@ #include #include -#include #include -#include #include #include -- GitLab From 66270ce4e1dc2f129b79db0107eec09c5b37d302 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Thu, 25 Jul 2013 12:27:17 +0530 Subject: [PATCH 188/942] staging: lustre: linux-tcpip: Remove duplicate header file inclusion Removed the header files included twice. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c index f5e78b54b3e74..e6069d78af6ba 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-tcpip.c @@ -35,7 +35,6 @@ */ #define DEBUG_SUBSYSTEM S_LNET -#include #include #include -- GitLab From 2950b2416fd2f38545dde9444878c7982d8fca19 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Thu, 25 Jul 2013 12:27:18 +0530 Subject: [PATCH 189/942] staging: lustre: Remove duplicate header file inclusion in dir.c Removed the header files included twice. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/dir.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index 002b37448682b..2ca8c4534bd5e 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -48,7 +48,6 @@ #define DEBUG_SUBSYSTEM S_LLITE -#include #include #include #include -- GitLab From 0ad531db6c83e277a86bdf6e5392a297cbeedb73 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Thu, 25 Jul 2013 12:27:19 +0530 Subject: [PATCH 190/942] staging: lustre: Remove duplicate header file inclusion in llite_mmap.c Removed the header files included twice. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/llite_mmap.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_mmap.c b/drivers/staging/lustre/lustre/llite/llite_mmap.c index a4061ee15b62b..b59cbd704ab65 100644 --- a/drivers/staging/lustre/lustre/llite/llite_mmap.c +++ b/drivers/staging/lustre/lustre/llite/llite_mmap.c @@ -43,9 +43,6 @@ #include #include -#include -#include -#include #include #define DEBUG_SUBSYSTEM S_LLITE -- GitLab From f75b7d2d6901a8c03bfbbd3422c747ff6c53bdcc Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Thu, 25 Jul 2013 12:27:20 +0530 Subject: [PATCH 191/942] staging: lustre: Remove duplicate header file inclusion in lloop.c Removed the header files included twice. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/lloop.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/llite/lloop.c b/drivers/staging/lustre/lustre/llite/lloop.c index 9d4c17ea88083..e063efc23af91 100644 --- a/drivers/staging/lustre/lustre/llite/lloop.c +++ b/drivers/staging/lustre/lustre/llite/lloop.c @@ -99,7 +99,6 @@ #include #include #include -#include #include #include -- GitLab From ee49576196ac409ac87c36eee4fdc7f5de2ec269 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Thu, 25 Jul 2013 12:27:21 +0530 Subject: [PATCH 192/942] staging: lustre: Remove duplicate header file inclusion in rw.c Removed the header files included twice. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/rw.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/rw.c b/drivers/staging/lustre/lustre/llite/rw.c index 43b5f0d2b72aa..ab4e95c635541 100644 --- a/drivers/staging/lustre/lustre/llite/rw.c +++ b/drivers/staging/lustre/lustre/llite/rw.c @@ -48,9 +48,6 @@ #include #include -#include -#include -#include #include /* current_is_kswapd() */ #include -- GitLab From 1fabbd6f65eada35e6bcb088ff8bba48c22e1e07 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Thu, 25 Jul 2013 12:27:22 +0530 Subject: [PATCH 193/942] staging: lustre: Remove duplicate header file inclusion in rw26.c Removed the header files included twice. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/llite/rw26.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/rw26.c b/drivers/staging/lustre/lustre/llite/rw26.c index 97088e6ddea07..256ee6356b313 100644 --- a/drivers/staging/lustre/lustre/llite/rw26.c +++ b/drivers/staging/lustre/lustre/llite/rw26.c @@ -51,9 +51,6 @@ #include #include #include -#include -#include -#include #include #define DEBUG_SUBSYSTEM S_LLITE -- GitLab From 0c050588a26eac43b4e875f21eb3926fa1c1b5d7 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Thu, 25 Jul 2013 12:27:23 +0530 Subject: [PATCH 194/942] staging: lustre: Remove duplicate header file inclusion in lmv_fld.c Removed the header file included twice. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/lmv/lmv_fld.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/lmv/lmv_fld.c b/drivers/staging/lustre/lustre/lmv/lmv_fld.c index a4805aefa6845..08a5b69dc90db 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_fld.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_fld.c @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include -- GitLab From c92b5ea0af2816e70f7e72b49c2a67868f20c015 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Thu, 25 Jul 2013 12:27:24 +0530 Subject: [PATCH 195/942] staging: lustre: Remove duplicate header file inclusion in lmv_intent.c Removed the header file included twice. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/lmv/lmv_intent.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/lmv/lmv_intent.c b/drivers/staging/lustre/lustre/lmv/lmv_intent.c index 7eefab5ef5d03..4bc8c6a5d6f20 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_intent.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_intent.c @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include -- GitLab From 713542a8cd156b06770ddbabb495bba38ea017fb Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Thu, 25 Jul 2013 12:27:25 +0530 Subject: [PATCH 196/942] staging: lustre: Remove duplicate header file inclusion in lmv_obd.c Removed the header file included twice. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index 11c8d644d5ea8..1987d4bae9b4a 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include -- GitLab From b9cb7fed5eef3cc21ef61aff66a16c4bd52a1c41 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Thu, 25 Jul 2013 12:27:26 +0530 Subject: [PATCH 197/942] staging: lustre: Remove duplicate header file inclusion in lvfs_linux.c Removed the header file included twice. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/lvfs/lvfs_linux.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c b/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c index 9d19d0a79be82..0f387913d6ff5 100644 --- a/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c +++ b/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c @@ -46,7 +46,6 @@ #include #include #include -#include #include #include #include -- GitLab From af7c25588f45aeaeeaf7eaeadbd25524f4adc308 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Thu, 25 Jul 2013 12:27:27 +0530 Subject: [PATCH 198/942] staging: lustre: obdclass: Remove duplicate header file inclusion Removed the header file included twice. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c index 8fe6a019d1e3a..c4a740286ad11 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include -- GitLab From 7b117940f329729fc673f69661576e5699c91594 Mon Sep 17 00:00:00 2001 From: Xiong Zhou Date: Thu, 25 Jul 2013 15:06:13 +0800 Subject: [PATCH 199/942] staging/lustre: add BLOCK depends in Kconfig MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add BLOCK depends in Kconfig for LUSTRE to fix this: drivers/staging/lustre/lustre/fid/../include/linux/lustre_compat25.h:117:2: error: implicit declaration of function ‘unregister_blkdev’ Signed-off-by: Xiong Zhou Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/Kconfig b/drivers/staging/lustre/lustre/Kconfig index 9ae7fa86b5a8e..0b45de0726f65 100644 --- a/drivers/staging/lustre/lustre/Kconfig +++ b/drivers/staging/lustre/lustre/Kconfig @@ -1,6 +1,6 @@ config LUSTRE_FS tristate "Lustre file system client support" - depends on STAGING && INET && m + depends on STAGING && INET && BLOCK && m select LNET select CRYPTO select CRYPTO_CRC32 -- GitLab From 1bf4d4860ed50cb9c0be6ee4fc6de5ffccf1d072 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Thu, 25 Jul 2013 11:36:49 +0530 Subject: [PATCH 200/942] staging: gdm724x: Remove version.h header inclusion in gdm_lte.c version.h header inclusion is not necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm724x/gdm_lte.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/gdm724x/gdm_lte.c b/drivers/staging/gdm724x/gdm_lte.c index 557822fdc9669..68ebc7d1eae62 100644 --- a/drivers/staging/gdm724x/gdm_lte.c +++ b/drivers/staging/gdm724x/gdm_lte.c @@ -13,7 +13,6 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt -#include #include #include #include -- GitLab From c1636ab01b5dc2f331c80ae32ce9416746edac65 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Thu, 25 Jul 2013 11:36:50 +0530 Subject: [PATCH 201/942] staging: gdm724x: Remove version.h header inclusion in gdm_lte.h version.h header inclusion is not necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm724x/gdm_lte.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/gdm724x/gdm_lte.h b/drivers/staging/gdm724x/gdm_lte.h index 90c9d51fcaf0d..9287d310d8e25 100644 --- a/drivers/staging/gdm724x/gdm_lte.h +++ b/drivers/staging/gdm724x/gdm_lte.h @@ -15,7 +15,6 @@ #define _GDM_LTE_H_ #include -#include #include #include "gdm_endian.h" -- GitLab From 3d2bf0fa5f1ecce06bbc6e7f749e4f32e90854a6 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Thu, 25 Jul 2013 11:36:51 +0530 Subject: [PATCH 202/942] staging: gdm724x: Remove version.h header inclusion in gdm_mux.c version.h header inclusion is not necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm724x/gdm_mux.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/gdm724x/gdm_mux.c b/drivers/staging/gdm724x/gdm_mux.c index f570bc00c9904..2e619d2e7ba10 100644 --- a/drivers/staging/gdm724x/gdm_mux.c +++ b/drivers/staging/gdm724x/gdm_mux.c @@ -14,7 +14,6 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include -#include #include #include #include -- GitLab From c47a5863b66887b1667f8988cef1f0e020e29c8b Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Thu, 25 Jul 2013 11:36:52 +0530 Subject: [PATCH 203/942] staging: gdm724x: Remove version.h header inclusion in gdm_tty.c version.h header inclusion is not necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm724x/gdm_tty.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c index 357daa80560f4..912022b84c03d 100644 --- a/drivers/staging/gdm724x/gdm_tty.c +++ b/drivers/staging/gdm724x/gdm_tty.c @@ -13,7 +13,6 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt -#include #include #include #include -- GitLab From 8f0b54478acdece4a398f65ac76c70294158e33c Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Thu, 25 Jul 2013 11:36:53 +0530 Subject: [PATCH 204/942] staging: gdm724x: Remove version.h header inclusion in gdm_tty.h version.h header inclusion is not necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm724x/gdm_tty.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/gdm724x/gdm_tty.h b/drivers/staging/gdm724x/gdm_tty.h index faeaa412eca0b..a75be1df01001 100644 --- a/drivers/staging/gdm724x/gdm_tty.h +++ b/drivers/staging/gdm724x/gdm_tty.h @@ -14,7 +14,6 @@ #ifndef _GDM_TTY_H_ #define _GDM_TTY_H_ -#include #include #include -- GitLab From 649bf7f98b281ffb0c7b1c4fc62334b0e86d527c Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Thu, 25 Jul 2013 11:36:54 +0530 Subject: [PATCH 205/942] staging: gdm724x: Remove version.h header inclusion in gdm_usb.c version.h header inclusion is not necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm724x/gdm_usb.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/gdm724x/gdm_usb.c b/drivers/staging/gdm724x/gdm_usb.c index 2e658f84486c1..4b10f23845ad0 100644 --- a/drivers/staging/gdm724x/gdm_usb.c +++ b/drivers/staging/gdm724x/gdm_usb.c @@ -14,7 +14,6 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include -#include #include #include #include -- GitLab From 7382b5cde6fd5cdaf5d11e698ad9f9015c8e2e13 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Thu, 25 Jul 2013 11:36:55 +0530 Subject: [PATCH 206/942] staging: gdm724x: Remove version.h header inclusion in gdm_usb.h version.h header inclusion is not necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm724x/gdm_usb.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/gdm724x/gdm_usb.h b/drivers/staging/gdm724x/gdm_usb.h index 38f6537dced00..e6486e71a4285 100644 --- a/drivers/staging/gdm724x/gdm_usb.h +++ b/drivers/staging/gdm724x/gdm_usb.h @@ -14,7 +14,6 @@ #ifndef _GDM_USB_H_ #define _GDM_USB_H_ -#include #include #include #include -- GitLab From 40f1a5ab5e82ab7f15bee23db3db6c3ae957dde4 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 14:06:38 -0700 Subject: [PATCH 207/942] staging: comedi: usbdux: rename struct usbduxsub This struct is the comedi_device private data. For aesthetic reasons, rename it to usbdux_private. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 98 ++++++++++++------------- 1 file changed, 45 insertions(+), 53 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 279e5bd493fa8..a64967684b680 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -228,15 +228,7 @@ static const struct comedi_lrange range_usbdux_ao_range = { 2, { } }; -/* - * private structure of one subdevice - */ - -/* - * This is the structure which holds all the data of - * this driver one sub device just now: A/D - */ -struct usbduxsub { +struct usbdux_private { /* attached? */ int attached; /* is it associated with a subdevice? */ @@ -305,7 +297,7 @@ struct usbduxsub { * _before_ any comedi command is issued. The usb subsystem must be initialised * before comedi can access it. */ -static struct usbduxsub usbduxsub[NUMUSBDUX]; +static struct usbdux_private usbduxsub[NUMUSBDUX]; static DEFINE_SEMAPHORE(start_stop_sem); @@ -313,7 +305,7 @@ static DEFINE_SEMAPHORE(start_stop_sem); * Stops the data acquision * It should be safe to call this function from any context */ -static int usbduxsub_unlink_inurbs(struct usbduxsub *usbduxsub_tmp) +static int usbduxsub_unlink_inurbs(struct usbdux_private *usbduxsub_tmp) { int i = 0; int err = 0; @@ -338,7 +330,7 @@ static int usbduxsub_unlink_inurbs(struct usbduxsub *usbduxsub_tmp) * Is called from within this driver from both the * interrupt context and from comedi */ -static int usbdux_ai_stop(struct usbduxsub *this_usbduxsub, int do_unlink) +static int usbdux_ai_stop(struct usbdux_private *this_usbduxsub, int do_unlink) { int ret = 0; @@ -365,7 +357,7 @@ static int usbdux_ai_stop(struct usbduxsub *this_usbduxsub, int do_unlink) static int usbdux_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { - struct usbduxsub *this_usbduxsub; + struct usbdux_private *this_usbduxsub; int res = 0; /* force unlink of all urbs */ @@ -391,13 +383,13 @@ static int usbdux_ai_cancel(struct comedi_device *dev, static void usbduxsub_ai_isoc_irq(struct urb *urb) { int i, err, n; - struct usbduxsub *this_usbduxsub; + struct usbdux_private *this_usbduxsub; struct comedi_device *this_comedidev; struct comedi_subdevice *s; /* the context variable points to the subdevice */ this_comedidev = urb->context; - /* the private structure of the subdevice is struct usbduxsub */ + /* the private structure of the subdevice is struct usbdux_private */ this_usbduxsub = this_comedidev->private; /* subdevice which is the AD converter */ s = &this_comedidev->subdevices[SUBDEV_AD]; @@ -528,7 +520,7 @@ static void usbduxsub_ai_isoc_irq(struct urb *urb) comedi_event(this_usbduxsub->comedidev, s); } -static int usbduxsub_unlink_outurbs(struct usbduxsub *usbduxsub_tmp) +static int usbduxsub_unlink_outurbs(struct usbdux_private *usbduxsub_tmp) { int i = 0; int err = 0; @@ -549,7 +541,7 @@ static int usbduxsub_unlink_outurbs(struct usbduxsub *usbduxsub_tmp) /* This will cancel a running acquisition operation * in any context. */ -static int usbdux_ao_stop(struct usbduxsub *this_usbduxsub, int do_unlink) +static int usbdux_ao_stop(struct usbdux_private *this_usbduxsub, int do_unlink) { int ret = 0; @@ -569,7 +561,7 @@ static int usbdux_ao_stop(struct usbduxsub *this_usbduxsub, int do_unlink) static int usbdux_ao_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { - struct usbduxsub *this_usbduxsub = dev->private; + struct usbdux_private *this_usbduxsub = dev->private; int res = 0; if (!this_usbduxsub) @@ -591,13 +583,13 @@ static void usbduxsub_ao_isoc_irq(struct urb *urb) { int i, ret; int8_t *datap; - struct usbduxsub *this_usbduxsub; + struct usbdux_private *this_usbduxsub; struct comedi_device *this_comedidev; struct comedi_subdevice *s; /* the context variable points to the subdevice */ this_comedidev = urb->context; - /* the private structure of the subdevice is struct usbduxsub */ + /* the private structure of the subdevice is struct usbdux_private */ this_usbduxsub = this_comedidev->private; s = &this_comedidev->subdevices[SUBDEV_DA]; @@ -727,7 +719,7 @@ static int usbdux_firmware_upload(struct comedi_device *dev, const u8 *data, size_t size, unsigned long context) { - struct usbduxsub *usbduxsub = dev->private; + struct usbdux_private *usbduxsub = dev->private; struct usb_device *usb = usbduxsub->usbdev; uint8_t *buf; uint8_t *tmp; @@ -799,7 +791,7 @@ static int usbdux_firmware_upload(struct comedi_device *dev, return ret; } -static int usbduxsub_submit_inurbs(struct usbduxsub *usbduxsub) +static int usbduxsub_submit_inurbs(struct usbdux_private *usbduxsub) { int i, err_flag; @@ -831,7 +823,7 @@ static int usbduxsub_submit_inurbs(struct usbduxsub *usbduxsub) return 0; } -static int usbduxsub_submit_outurbs(struct usbduxsub *usbduxsub) +static int usbduxsub_submit_outurbs(struct usbdux_private *usbduxsub) { int i, err_flag; @@ -860,7 +852,7 @@ static int usbduxsub_submit_outurbs(struct usbduxsub *usbduxsub) static int usbdux_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { - struct usbduxsub *this_usbduxsub = dev->private; + struct usbdux_private *this_usbduxsub = dev->private; int err = 0, i; unsigned int tmp_timer; @@ -968,7 +960,7 @@ static int8_t create_adc_command(unsigned int chan, int range) #define SENDPWMON 7 #define SENDPWMOFF 8 -static int send_dux_commands(struct usbduxsub *this_usbduxsub, int cmd_type) +static int send_dux_commands(struct usbdux_private *this_usbduxsub, int cmd_type) { int result, nsent; @@ -993,7 +985,7 @@ static int send_dux_commands(struct usbduxsub *this_usbduxsub, int cmd_type) return result; } -static int receive_dux_commands(struct usbduxsub *this_usbduxsub, int command) +static int receive_dux_commands(struct usbdux_private *this_usbduxsub, int command) { int result = (-EFAULT); int nrec; @@ -1027,7 +1019,7 @@ static int usbdux_ai_inttrig(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int trignum) { int ret; - struct usbduxsub *this_usbduxsub = dev->private; + struct usbdux_private *this_usbduxsub = dev->private; if (!this_usbduxsub) return -EFAULT; @@ -1072,7 +1064,7 @@ static int usbdux_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) struct comedi_cmd *cmd = &s->async->cmd; unsigned int chan, range; int i, ret; - struct usbduxsub *this_usbduxsub = dev->private; + struct usbdux_private *this_usbduxsub = dev->private; int result; if (!this_usbduxsub) @@ -1192,7 +1184,7 @@ static int usbdux_ai_insn_read(struct comedi_device *dev, unsigned int one = 0; int chan, range; int err; - struct usbduxsub *this_usbduxsub = dev->private; + struct usbdux_private *this_usbduxsub = dev->private; if (!this_usbduxsub) return 0; @@ -1252,7 +1244,7 @@ static int usbdux_ao_insn_read(struct comedi_device *dev, { int i; int chan = CR_CHAN(insn->chanspec); - struct usbduxsub *this_usbduxsub = dev->private; + struct usbdux_private *this_usbduxsub = dev->private; if (!this_usbduxsub) return -EFAULT; @@ -1275,7 +1267,7 @@ static int usbdux_ao_insn_write(struct comedi_device *dev, { int i, err; int chan = CR_CHAN(insn->chanspec); - struct usbduxsub *this_usbduxsub = dev->private; + struct usbdux_private *this_usbduxsub = dev->private; if (!this_usbduxsub) return -EFAULT; @@ -1324,7 +1316,7 @@ static int usbdux_ao_inttrig(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int trignum) { int ret; - struct usbduxsub *this_usbduxsub = dev->private; + struct usbdux_private *this_usbduxsub = dev->private; if (!this_usbduxsub) return -EFAULT; @@ -1365,7 +1357,7 @@ static int usbdux_ao_inttrig(struct comedi_device *dev, static int usbdux_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { - struct usbduxsub *this_usbduxsub = dev->private; + struct usbdux_private *this_usbduxsub = dev->private; int err = 0; unsigned int flags; @@ -1454,7 +1446,7 @@ static int usbdux_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) struct comedi_cmd *cmd = &s->async->cmd; unsigned int chan, gain; int i, ret; - struct usbduxsub *this_usbduxsub = dev->private; + struct usbdux_private *this_usbduxsub = dev->private; if (!this_usbduxsub) return -EFAULT; @@ -1593,7 +1585,7 @@ static int usbdux_dio_insn_bits(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct usbduxsub *this_usbduxsub = dev->private; + struct usbdux_private *this_usbduxsub = dev->private; int err; if (!this_usbduxsub) @@ -1636,7 +1628,7 @@ static int usbdux_counter_read(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - struct usbduxsub *this_usbduxsub = dev->private; + struct usbdux_private *this_usbduxsub = dev->private; int chan = insn->chanspec; int err; @@ -1671,7 +1663,7 @@ static int usbdux_counter_write(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - struct usbduxsub *this_usbduxsub = dev->private; + struct usbdux_private *this_usbduxsub = dev->private; int err; if (!this_usbduxsub) @@ -1709,7 +1701,7 @@ static int usbdux_counter_config(struct comedi_device *dev, /***********************************/ /* PWM */ -static int usbduxsub_unlink_pwm_urbs(struct usbduxsub *usbduxsub_tmp) +static int usbduxsub_unlink_pwm_urbs(struct usbdux_private *usbduxsub_tmp) { int err = 0; @@ -1725,7 +1717,7 @@ static int usbduxsub_unlink_pwm_urbs(struct usbduxsub *usbduxsub_tmp) /* This cancels a running acquisition operation * in any context. */ -static int usbdux_pwm_stop(struct usbduxsub *this_usbduxsub, int do_unlink) +static int usbdux_pwm_stop(struct usbdux_private *this_usbduxsub, int do_unlink) { int ret = 0; @@ -1745,7 +1737,7 @@ static int usbdux_pwm_stop(struct usbduxsub *this_usbduxsub, int do_unlink) static int usbdux_pwm_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { - struct usbduxsub *this_usbduxsub = dev->private; + struct usbdux_private *this_usbduxsub = dev->private; int res = 0; /* unlink only if it is really running */ @@ -1761,7 +1753,7 @@ static int usbdux_pwm_cancel(struct comedi_device *dev, static void usbduxsub_pwm_irq(struct urb *urb) { int ret; - struct usbduxsub *this_usbduxsub; + struct usbdux_private *this_usbduxsub; struct comedi_device *this_comedidev; struct comedi_subdevice *s; @@ -1769,7 +1761,7 @@ static void usbduxsub_pwm_irq(struct urb *urb) /* the context variable points to the subdevice */ this_comedidev = urb->context; - /* the private structure of the subdevice is struct usbduxsub */ + /* the private structure of the subdevice is struct usbdux_private */ this_usbduxsub = this_comedidev->private; s = &this_comedidev->subdevices[SUBDEV_DA]; @@ -1827,7 +1819,7 @@ static void usbduxsub_pwm_irq(struct urb *urb) } } -static int usbduxsub_submit_pwm_urbs(struct usbduxsub *usbduxsub) +static int usbduxsub_submit_pwm_urbs(struct usbdux_private *usbduxsub) { int err_flag; @@ -1857,7 +1849,7 @@ static int usbduxsub_submit_pwm_urbs(struct usbduxsub *usbduxsub) static int usbdux_pwm_period(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int period) { - struct usbduxsub *this_usbduxsub = dev->private; + struct usbdux_private *this_usbduxsub = dev->private; int fx2delay = 255; if (period < MIN_PWM_PERIOD) { @@ -1886,7 +1878,7 @@ static int usbdux_pwm_start(struct comedi_device *dev, struct comedi_subdevice *s) { int ret, i; - struct usbduxsub *this_usbduxsub = dev->private; + struct usbdux_private *this_usbduxsub = dev->private; dev_dbg(&this_usbduxsub->interface->dev, "comedi%d: %s\n", dev->minor, __func__); @@ -1919,7 +1911,7 @@ static int usbdux_pwm_pattern(struct comedi_device *dev, struct comedi_subdevice *s, int channel, unsigned int value, unsigned int sign) { - struct usbduxsub *this_usbduxsub = dev->private; + struct usbdux_private *this_usbduxsub = dev->private; int i, szbuf; char *p_buf; char pwm_mask; @@ -1961,7 +1953,7 @@ static int usbdux_pwm_write(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - struct usbduxsub *this_usbduxsub = dev->private; + struct usbdux_private *this_usbduxsub = dev->private; if (!this_usbduxsub) return -EFAULT; @@ -1995,7 +1987,7 @@ static int usbdux_pwm_config(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - struct usbduxsub *this_usbduxsub = dev->private; + struct usbdux_private *this_usbduxsub = dev->private; switch (data[0]) { case INSN_CONFIG_ARM: /* switch it on */ @@ -2046,7 +2038,7 @@ static int usbdux_pwm_config(struct comedi_device *dev, /* end of PWM */ /*****************************************************************/ -static void tidy_up(struct usbduxsub *usbduxsub_tmp) +static void tidy_up(struct usbdux_private *usbduxsub_tmp) { int i; @@ -2119,7 +2111,7 @@ static void tidy_up(struct usbduxsub *usbduxsub_tmp) } static int usbdux_attach_common(struct comedi_device *dev, - struct usbduxsub *udev) + struct usbdux_private *udev) { int ret; struct comedi_subdevice *s = NULL; @@ -2250,7 +2242,7 @@ static int usbdux_auto_attach(struct comedi_device *dev, unsigned long context_unused) { struct usb_interface *uinterf = comedi_to_usb_interface(dev); - struct usbduxsub *this_usbduxsub = usb_get_intfdata(uinterf); + struct usbdux_private *this_usbduxsub = usb_get_intfdata(uinterf); struct usb_device *usb = usbduxsub->usbdev; int ret; @@ -2281,7 +2273,7 @@ static int usbdux_auto_attach(struct comedi_device *dev, static void usbdux_detach(struct comedi_device *dev) { - struct usbduxsub *usb = dev->private; + struct usbdux_private *usb = dev->private; if (usb) { down(&usb->sem); @@ -2527,7 +2519,7 @@ static int usbdux_usb_probe(struct usb_interface *uinterf, static void usbdux_usb_disconnect(struct usb_interface *intf) { - struct usbduxsub *usbduxsub_tmp = usb_get_intfdata(intf); + struct usbdux_private *usbduxsub_tmp = usb_get_intfdata(intf); struct usb_device *udev = interface_to_usbdev(intf); if (!usbduxsub_tmp) { -- GitLab From b0daed19f21f4199fb7e4ded5fc0cddd230c655f Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 14:06:58 -0700 Subject: [PATCH 208/942] staging: comedi: usbdux: remove the usb_driver (*probe) noise The dev_dbg() during the usb_driver (*probe) is just added noise. The dev_err() when a usb_alloc_urb() fails is not necessary. The allocation failure will have already output a message. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index a64967684b680..63e302847def6 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -2299,9 +2299,6 @@ static int usbdux_usb_probe(struct usb_interface *uinterf, int i; int index; - dev_dbg(dev, "comedi_: usbdux_: " - "finding a free structure for the usb-device\n"); - down(&start_stop_sem); /* look for a free place in the usbdux array */ index = -1; @@ -2318,8 +2315,6 @@ static int usbdux_usb_probe(struct usb_interface *uinterf, up(&start_stop_sem); return -EMFILE; } - dev_dbg(dev, "comedi_: usbdux: " - "usbduxsub[%d] is ready to connect to comedi.\n", index); sema_init(&(usbduxsub[index].sem), 1); /* save a pointer to the usb device */ @@ -2333,8 +2328,6 @@ static int usbdux_usb_probe(struct usb_interface *uinterf, /* will be needed for disconnect */ usb_set_intfdata(uinterf, &(usbduxsub[index])); - dev_dbg(dev, "comedi_: usbdux: ifnum=%d\n", usbduxsub[index].ifnum); - /* test if it is high speed (USB 2.0) */ usbduxsub[index].high_speed = (usbduxsub[index].usbdev->speed == USB_SPEED_HIGH); @@ -2402,8 +2395,6 @@ static int usbdux_usb_probe(struct usb_interface *uinterf, /* one frame: 1ms */ usbduxsub[index].urb_in[i] = usb_alloc_urb(1, GFP_KERNEL); if (usbduxsub[index].urb_in[i] == NULL) { - dev_err(dev, "comedi_: usbdux%d: " - "Could not alloc. urb(%d)\n", index, i); tidy_up(&(usbduxsub[index])); up(&start_stop_sem); return -ENOMEM; @@ -2447,8 +2438,6 @@ static int usbdux_usb_probe(struct usb_interface *uinterf, /* one frame: 1ms */ usbduxsub[index].urb_out[i] = usb_alloc_urb(1, GFP_KERNEL); if (usbduxsub[index].urb_out[i] == NULL) { - dev_err(dev, "comedi_: usbdux%d: " - "Could not alloc. urb(%d)\n", index, i); tidy_up(&(usbduxsub[index])); up(&start_stop_sem); return -ENOMEM; @@ -2488,8 +2477,6 @@ static int usbdux_usb_probe(struct usb_interface *uinterf, usbduxsub[index].size_pwm_buf = 512; usbduxsub[index].urb_pwm = usb_alloc_urb(0, GFP_KERNEL); if (usbduxsub[index].urb_pwm == NULL) { - dev_err(dev, "comedi_: usbdux%d: " - "Could not alloc. pwm urb\n", index); tidy_up(&(usbduxsub[index])); up(&start_stop_sem); return -ENOMEM; -- GitLab From da9035908edc3e936a2912cf836fed3e9d965cf1 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 14:07:18 -0700 Subject: [PATCH 209/942] staging: comedi: usbdux: tidy up usbdux_usb_probe() Use a pointer to the struct usbdux_private data being configured in the probe. Also use a pointer to the struct urb being setup in the buffer allocations. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 221 +++++++++++------------- 1 file changed, 103 insertions(+), 118 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 63e302847def6..d1651e2cdefe4 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -2296,209 +2296,194 @@ static int usbdux_usb_probe(struct usb_interface *uinterf, { struct usb_device *udev = interface_to_usbdev(uinterf); struct device *dev = &uinterf->dev; + struct usbdux_private *devpriv = NULL; + struct urb *urb; int i; - int index; down(&start_stop_sem); - /* look for a free place in the usbdux array */ - index = -1; + for (i = 0; i < NUMUSBDUX; i++) { - if (!(usbduxsub[i].probed)) { - index = i; + if (!usbduxsub[i].probed) { + devpriv = &usbduxsub[i]; break; } } - - /* no more space */ - if (index == -1) { + if (!devpriv) { dev_err(dev, "Too many usbdux-devices connected.\n"); up(&start_stop_sem); return -EMFILE; } - sema_init(&(usbduxsub[index].sem), 1); - /* save a pointer to the usb device */ - usbduxsub[index].usbdev = udev; + sema_init(&devpriv->sem, 1); - /* 2.6: save the interface itself */ - usbduxsub[index].interface = uinterf; - /* get the interface number from the interface */ - usbduxsub[index].ifnum = uinterf->altsetting->desc.bInterfaceNumber; - /* hand the private data over to the usb subsystem */ - /* will be needed for disconnect */ - usb_set_intfdata(uinterf, &(usbduxsub[index])); + devpriv->usbdev = udev; + devpriv->interface = uinterf; + devpriv->ifnum = uinterf->altsetting->desc.bInterfaceNumber; + usb_set_intfdata(uinterf, devpriv); - /* test if it is high speed (USB 2.0) */ - usbduxsub[index].high_speed = - (usbduxsub[index].usbdev->speed == USB_SPEED_HIGH); + devpriv->high_speed = (devpriv->usbdev->speed == USB_SPEED_HIGH); /* create space for the commands of the DA converter */ - usbduxsub[index].dac_commands = kzalloc(NUMOUTCHANNELS, GFP_KERNEL); - if (!usbduxsub[index].dac_commands) { - tidy_up(&(usbduxsub[index])); + devpriv->dac_commands = kzalloc(NUMOUTCHANNELS, GFP_KERNEL); + if (!devpriv->dac_commands) { + tidy_up(devpriv); up(&start_stop_sem); return -ENOMEM; } /* create space for the commands going to the usb device */ - usbduxsub[index].dux_commands = kzalloc(SIZEOFDUXBUFFER, GFP_KERNEL); - if (!usbduxsub[index].dux_commands) { - tidy_up(&(usbduxsub[index])); + devpriv->dux_commands = kzalloc(SIZEOFDUXBUFFER, GFP_KERNEL); + if (!devpriv->dux_commands) { + tidy_up(devpriv); up(&start_stop_sem); return -ENOMEM; } /* create space for the in buffer and set it to zero */ - usbduxsub[index].in_buffer = kzalloc(SIZEINBUF, GFP_KERNEL); - if (!(usbduxsub[index].in_buffer)) { - tidy_up(&(usbduxsub[index])); + devpriv->in_buffer = kzalloc(SIZEINBUF, GFP_KERNEL); + if (!devpriv->in_buffer) { + tidy_up(devpriv); up(&start_stop_sem); return -ENOMEM; } /* create space of the instruction buffer */ - usbduxsub[index].insn_buffer = kzalloc(SIZEINSNBUF, GFP_KERNEL); - if (!(usbduxsub[index].insn_buffer)) { - tidy_up(&(usbduxsub[index])); + devpriv->insn_buffer = kzalloc(SIZEINSNBUF, GFP_KERNEL); + if (!devpriv->insn_buffer) { + tidy_up(devpriv); up(&start_stop_sem); return -ENOMEM; } /* create space for the outbuffer */ - usbduxsub[index].out_buffer = kzalloc(SIZEOUTBUF, GFP_KERNEL); - if (!(usbduxsub[index].out_buffer)) { - tidy_up(&(usbduxsub[index])); + devpriv->out_buffer = kzalloc(SIZEOUTBUF, GFP_KERNEL); + if (!devpriv->out_buffer) { + tidy_up(devpriv); up(&start_stop_sem); return -ENOMEM; } /* setting to alternate setting 3: enabling iso ep and bulk ep. */ - i = usb_set_interface(usbduxsub[index].usbdev, - usbduxsub[index].ifnum, 3); + i = usb_set_interface(devpriv->usbdev, devpriv->ifnum, 3); if (i < 0) { - dev_err(dev, "comedi_: usbdux%d: " - "could not set alternate setting 3 in high speed.\n", - index); - tidy_up(&(usbduxsub[index])); + dev_err(dev, + "could not set alternate setting 3 in high speed\n"); + tidy_up(devpriv); up(&start_stop_sem); return -ENODEV; } - if (usbduxsub[index].high_speed) - usbduxsub[index].num_in_buffers = NUMOFINBUFFERSHIGH; + if (devpriv->high_speed) + devpriv->num_in_buffers = NUMOFINBUFFERSHIGH; else - usbduxsub[index].num_in_buffers = NUMOFINBUFFERSFULL; + devpriv->num_in_buffers = NUMOFINBUFFERSFULL; - usbduxsub[index].urb_in = - kcalloc(usbduxsub[index].num_in_buffers, sizeof(struct urb *), - GFP_KERNEL); - if (!(usbduxsub[index].urb_in)) { - tidy_up(&(usbduxsub[index])); + devpriv->urb_in = kcalloc(devpriv->num_in_buffers, sizeof(*urb), + GFP_KERNEL); + if (!devpriv->urb_in) { + tidy_up(devpriv); up(&start_stop_sem); return -ENOMEM; } - for (i = 0; i < usbduxsub[index].num_in_buffers; i++) { + for (i = 0; i < devpriv->num_in_buffers; i++) { /* one frame: 1ms */ - usbduxsub[index].urb_in[i] = usb_alloc_urb(1, GFP_KERNEL); - if (usbduxsub[index].urb_in[i] == NULL) { - tidy_up(&(usbduxsub[index])); + urb = usb_alloc_urb(1, GFP_KERNEL); + if (!urb) { + tidy_up(devpriv); up(&start_stop_sem); return -ENOMEM; } - usbduxsub[index].urb_in[i]->dev = usbduxsub[index].usbdev; + devpriv->urb_in[i] = urb; + + urb->dev = devpriv->usbdev; /* will be filled later with a pointer to the comedi-device */ /* and ONLY then the urb should be submitted */ - usbduxsub[index].urb_in[i]->context = NULL; - usbduxsub[index].urb_in[i]->pipe = - usb_rcvisocpipe(usbduxsub[index].usbdev, ISOINEP); - usbduxsub[index].urb_in[i]->transfer_flags = URB_ISO_ASAP; - usbduxsub[index].urb_in[i]->transfer_buffer = - kzalloc(SIZEINBUF, GFP_KERNEL); - if (!(usbduxsub[index].urb_in[i]->transfer_buffer)) { - tidy_up(&(usbduxsub[index])); + urb->context = NULL; + urb->pipe = usb_rcvisocpipe(devpriv->usbdev, ISOINEP); + urb->transfer_flags = URB_ISO_ASAP; + urb->transfer_buffer = kzalloc(SIZEINBUF, GFP_KERNEL); + if (!urb->transfer_buffer) { + tidy_up(devpriv); up(&start_stop_sem); return -ENOMEM; } - usbduxsub[index].urb_in[i]->complete = usbduxsub_ai_isoc_irq; - usbduxsub[index].urb_in[i]->number_of_packets = 1; - usbduxsub[index].urb_in[i]->transfer_buffer_length = SIZEINBUF; - usbduxsub[index].urb_in[i]->iso_frame_desc[0].offset = 0; - usbduxsub[index].urb_in[i]->iso_frame_desc[0].length = SIZEINBUF; + urb->complete = usbduxsub_ai_isoc_irq; + urb->number_of_packets = 1; + urb->transfer_buffer_length = SIZEINBUF; + urb->iso_frame_desc[0].offset = 0; + urb->iso_frame_desc[0].length = SIZEINBUF; } /* out */ - if (usbduxsub[index].high_speed) - usbduxsub[index].num_out_buffers = NUMOFOUTBUFFERSHIGH; + if (devpriv->high_speed) + devpriv->num_out_buffers = NUMOFOUTBUFFERSHIGH; else - usbduxsub[index].num_out_buffers = NUMOFOUTBUFFERSFULL; + devpriv->num_out_buffers = NUMOFOUTBUFFERSFULL; - usbduxsub[index].urb_out = - kcalloc(usbduxsub[index].num_out_buffers, sizeof(struct urb *), - GFP_KERNEL); - if (!(usbduxsub[index].urb_out)) { - tidy_up(&(usbduxsub[index])); + devpriv->urb_out = kcalloc(devpriv->num_out_buffers, sizeof(*urb), + GFP_KERNEL); + if (!devpriv->urb_out) { + tidy_up(devpriv); up(&start_stop_sem); return -ENOMEM; } - for (i = 0; i < usbduxsub[index].num_out_buffers; i++) { + for (i = 0; i < devpriv->num_out_buffers; i++) { /* one frame: 1ms */ - usbduxsub[index].urb_out[i] = usb_alloc_urb(1, GFP_KERNEL); - if (usbduxsub[index].urb_out[i] == NULL) { - tidy_up(&(usbduxsub[index])); + urb = usb_alloc_urb(1, GFP_KERNEL); + if (!urb) { + tidy_up(devpriv); up(&start_stop_sem); return -ENOMEM; } - usbduxsub[index].urb_out[i]->dev = usbduxsub[index].usbdev; + devpriv->urb_out[i] = urb; + + urb->dev = devpriv->usbdev; /* will be filled later with a pointer to the comedi-device */ /* and ONLY then the urb should be submitted */ - usbduxsub[index].urb_out[i]->context = NULL; - usbduxsub[index].urb_out[i]->pipe = - usb_sndisocpipe(usbduxsub[index].usbdev, ISOOUTEP); - usbduxsub[index].urb_out[i]->transfer_flags = URB_ISO_ASAP; - usbduxsub[index].urb_out[i]->transfer_buffer = - kzalloc(SIZEOUTBUF, GFP_KERNEL); - if (!(usbduxsub[index].urb_out[i]->transfer_buffer)) { - tidy_up(&(usbduxsub[index])); + urb->context = NULL; + urb->pipe = usb_sndisocpipe(devpriv->usbdev, ISOOUTEP); + urb->transfer_flags = URB_ISO_ASAP; + urb->transfer_buffer = kzalloc(SIZEOUTBUF, GFP_KERNEL); + if (!(urb->transfer_buffer)) { + tidy_up(devpriv); up(&start_stop_sem); return -ENOMEM; } - usbduxsub[index].urb_out[i]->complete = usbduxsub_ao_isoc_irq; - usbduxsub[index].urb_out[i]->number_of_packets = 1; - usbduxsub[index].urb_out[i]->transfer_buffer_length = SIZEOUTBUF; - usbduxsub[index].urb_out[i]->iso_frame_desc[0].offset = 0; - usbduxsub[index].urb_out[i]->iso_frame_desc[0].length = - SIZEOUTBUF; - if (usbduxsub[index].high_speed) { - /* uframes */ - usbduxsub[index].urb_out[i]->interval = 8; - } else { - /* frames */ - usbduxsub[index].urb_out[i]->interval = 1; - } + urb->complete = usbduxsub_ao_isoc_irq; + urb->number_of_packets = 1; + urb->transfer_buffer_length = SIZEOUTBUF; + urb->iso_frame_desc[0].offset = 0; + urb->iso_frame_desc[0].length = SIZEOUTBUF; + if (devpriv->high_speed) + urb->interval = 8; /* uframes */ + else + urb->interval = 1; /* frames */ } /* pwm */ - if (usbduxsub[index].high_speed) { - /* max bulk ep size in high speed */ - usbduxsub[index].size_pwm_buf = 512; - usbduxsub[index].urb_pwm = usb_alloc_urb(0, GFP_KERNEL); - if (usbduxsub[index].urb_pwm == NULL) { - tidy_up(&(usbduxsub[index])); + if (devpriv->high_speed) { + urb = usb_alloc_urb(0, GFP_KERNEL); + if (!urb) { + tidy_up(devpriv); up(&start_stop_sem); return -ENOMEM; } - usbduxsub[index].urb_pwm->transfer_buffer = - kzalloc(usbduxsub[index].size_pwm_buf, GFP_KERNEL); - if (!(usbduxsub[index].urb_pwm->transfer_buffer)) { - tidy_up(&(usbduxsub[index])); + devpriv->urb_pwm = urb; + + /* max bulk ep size in high speed */ + devpriv->size_pwm_buf = 512; + urb->transfer_buffer = kzalloc(devpriv->size_pwm_buf, + GFP_KERNEL); + if (!urb->transfer_buffer) { + tidy_up(devpriv); up(&start_stop_sem); return -ENOMEM; } } else { - usbduxsub[index].urb_pwm = NULL; - usbduxsub[index].size_pwm_buf = 0; + devpriv->urb_pwm = NULL; + devpriv->size_pwm_buf = 0; } - usbduxsub[index].ai_cmd_running = 0; - usbduxsub[index].ao_cmd_running = 0; - usbduxsub[index].pwm_cmd_running = 0; + devpriv->ai_cmd_running = 0; + devpriv->ao_cmd_running = 0; + devpriv->pwm_cmd_running = 0; /* we've reached the bottom of the function */ - usbduxsub[index].probed = 1; + devpriv->probed = 1; up(&start_stop_sem); return comedi_usb_auto_config(uinterf, &usbdux_driver, 0); -- GitLab From 080bcc188782d733500f8315d55bd1f403106e68 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 14:07:39 -0700 Subject: [PATCH 210/942] staging: comedi: usbdux: move usb buffer allocation into new function Move all the usb buffer allocation code in the usb_driver (*probe) into a new function, usbdux_alloc_usb_buffers(). This allows tidying up the error path in the (*probe). Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 274 +++++++++++------------- 1 file changed, 128 insertions(+), 146 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index d1651e2cdefe4..892ecb53dbf55 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -2238,6 +2238,117 @@ static int usbdux_attach_common(struct comedi_device *dev, return 0; } +static int usbdux_alloc_usb_buffers(struct usbdux_private *devpriv) +{ + struct urb *urb; + int i; + + /* create space for the commands of the DA converter */ + devpriv->dac_commands = kzalloc(NUMOUTCHANNELS, GFP_KERNEL); + if (!devpriv->dac_commands) + return -ENOMEM; + + /* create space for the commands going to the usb device */ + devpriv->dux_commands = kzalloc(SIZEOFDUXBUFFER, GFP_KERNEL); + if (!devpriv->dux_commands) + return -ENOMEM; + + /* create space for the in buffer and set it to zero */ + devpriv->in_buffer = kzalloc(SIZEINBUF, GFP_KERNEL); + if (!devpriv->in_buffer) + return -ENOMEM; + + /* create space of the instruction buffer */ + devpriv->insn_buffer = kzalloc(SIZEINSNBUF, GFP_KERNEL); + if (!devpriv->insn_buffer) + return -ENOMEM; + + /* create space for the outbuffer */ + devpriv->out_buffer = kzalloc(SIZEOUTBUF, GFP_KERNEL); + if (!devpriv->out_buffer) + return -ENOMEM; + + /* in urbs */ + devpriv->urb_in = kcalloc(devpriv->num_in_buffers, sizeof(*urb), + GFP_KERNEL); + if (!devpriv->urb_in) + return -ENOMEM; + + for (i = 0; i < devpriv->num_in_buffers; i++) { + /* one frame: 1ms */ + urb = usb_alloc_urb(1, GFP_KERNEL); + if (!urb) + return -ENOMEM; + devpriv->urb_in[i] = urb; + + urb->dev = devpriv->usbdev; + /* will be filled later with a pointer to the comedi-device */ + /* and ONLY then the urb should be submitted */ + urb->context = NULL; + urb->pipe = usb_rcvisocpipe(devpriv->usbdev, ISOINEP); + urb->transfer_flags = URB_ISO_ASAP; + urb->transfer_buffer = kzalloc(SIZEINBUF, GFP_KERNEL); + if (!urb->transfer_buffer) + return -ENOMEM; + + urb->complete = usbduxsub_ai_isoc_irq; + urb->number_of_packets = 1; + urb->transfer_buffer_length = SIZEINBUF; + urb->iso_frame_desc[0].offset = 0; + urb->iso_frame_desc[0].length = SIZEINBUF; + } + + /* out urbs */ + devpriv->urb_out = kcalloc(devpriv->num_out_buffers, sizeof(*urb), + GFP_KERNEL); + if (!devpriv->urb_out) + return -ENOMEM; + + for (i = 0; i < devpriv->num_out_buffers; i++) { + /* one frame: 1ms */ + urb = usb_alloc_urb(1, GFP_KERNEL); + if (!urb) + return -ENOMEM; + devpriv->urb_out[i] = urb; + + urb->dev = devpriv->usbdev; + /* will be filled later with a pointer to the comedi-device */ + /* and ONLY then the urb should be submitted */ + urb->context = NULL; + urb->pipe = usb_sndisocpipe(devpriv->usbdev, ISOOUTEP); + urb->transfer_flags = URB_ISO_ASAP; + urb->transfer_buffer = kzalloc(SIZEOUTBUF, GFP_KERNEL); + if (!urb->transfer_buffer) + return -ENOMEM; + + urb->complete = usbduxsub_ao_isoc_irq; + urb->number_of_packets = 1; + urb->transfer_buffer_length = SIZEOUTBUF; + urb->iso_frame_desc[0].offset = 0; + urb->iso_frame_desc[0].length = SIZEOUTBUF; + if (devpriv->high_speed) + urb->interval = 8; /* uframes */ + else + urb->interval = 1; /* frames */ + } + + /* pwm */ + if (devpriv->size_pwm_buf) { + urb = usb_alloc_urb(0, GFP_KERNEL); + if (!urb) + return -ENOMEM; + devpriv->urb_pwm = urb; + + /* max bulk ep size in high speed */ + urb->transfer_buffer = kzalloc(devpriv->size_pwm_buf, + GFP_KERNEL); + if (!urb->transfer_buffer) + return -ENOMEM; + } + + return 0; +} + static int usbdux_auto_attach(struct comedi_device *dev, unsigned long context_unused) { @@ -2297,7 +2408,7 @@ static int usbdux_usb_probe(struct usb_interface *uinterf, struct usb_device *udev = interface_to_usbdev(uinterf); struct device *dev = &uinterf->dev; struct usbdux_private *devpriv = NULL; - struct urb *urb; + int ret; int i; down(&start_stop_sem); @@ -2322,160 +2433,31 @@ static int usbdux_usb_probe(struct usb_interface *uinterf, usb_set_intfdata(uinterf, devpriv); devpriv->high_speed = (devpriv->usbdev->speed == USB_SPEED_HIGH); - - /* create space for the commands of the DA converter */ - devpriv->dac_commands = kzalloc(NUMOUTCHANNELS, GFP_KERNEL); - if (!devpriv->dac_commands) { - tidy_up(devpriv); - up(&start_stop_sem); - return -ENOMEM; - } - /* create space for the commands going to the usb device */ - devpriv->dux_commands = kzalloc(SIZEOFDUXBUFFER, GFP_KERNEL); - if (!devpriv->dux_commands) { - tidy_up(devpriv); - up(&start_stop_sem); - return -ENOMEM; - } - /* create space for the in buffer and set it to zero */ - devpriv->in_buffer = kzalloc(SIZEINBUF, GFP_KERNEL); - if (!devpriv->in_buffer) { - tidy_up(devpriv); - up(&start_stop_sem); - return -ENOMEM; - } - /* create space of the instruction buffer */ - devpriv->insn_buffer = kzalloc(SIZEINSNBUF, GFP_KERNEL); - if (!devpriv->insn_buffer) { - tidy_up(devpriv); - up(&start_stop_sem); - return -ENOMEM; - } - /* create space for the outbuffer */ - devpriv->out_buffer = kzalloc(SIZEOUTBUF, GFP_KERNEL); - if (!devpriv->out_buffer) { - tidy_up(devpriv); - up(&start_stop_sem); - return -ENOMEM; - } - /* setting to alternate setting 3: enabling iso ep and bulk ep. */ - i = usb_set_interface(devpriv->usbdev, devpriv->ifnum, 3); - if (i < 0) { - dev_err(dev, - "could not set alternate setting 3 in high speed\n"); - tidy_up(devpriv); - up(&start_stop_sem); - return -ENODEV; - } - if (devpriv->high_speed) + if (devpriv->high_speed) { devpriv->num_in_buffers = NUMOFINBUFFERSHIGH; - else + devpriv->num_out_buffers = NUMOFOUTBUFFERSHIGH; + devpriv->size_pwm_buf = 512; + } else { devpriv->num_in_buffers = NUMOFINBUFFERSFULL; + devpriv->num_out_buffers = NUMOFOUTBUFFERSFULL; + devpriv->size_pwm_buf = 0; + } - devpriv->urb_in = kcalloc(devpriv->num_in_buffers, sizeof(*urb), - GFP_KERNEL); - if (!devpriv->urb_in) { + ret = usbdux_alloc_usb_buffers(devpriv); + if (ret) { tidy_up(devpriv); up(&start_stop_sem); - return -ENOMEM; - } - for (i = 0; i < devpriv->num_in_buffers; i++) { - /* one frame: 1ms */ - urb = usb_alloc_urb(1, GFP_KERNEL); - if (!urb) { - tidy_up(devpriv); - up(&start_stop_sem); - return -ENOMEM; - } - devpriv->urb_in[i] = urb; - - urb->dev = devpriv->usbdev; - /* will be filled later with a pointer to the comedi-device */ - /* and ONLY then the urb should be submitted */ - urb->context = NULL; - urb->pipe = usb_rcvisocpipe(devpriv->usbdev, ISOINEP); - urb->transfer_flags = URB_ISO_ASAP; - urb->transfer_buffer = kzalloc(SIZEINBUF, GFP_KERNEL); - if (!urb->transfer_buffer) { - tidy_up(devpriv); - up(&start_stop_sem); - return -ENOMEM; - } - urb->complete = usbduxsub_ai_isoc_irq; - urb->number_of_packets = 1; - urb->transfer_buffer_length = SIZEINBUF; - urb->iso_frame_desc[0].offset = 0; - urb->iso_frame_desc[0].length = SIZEINBUF; + return ret; } - /* out */ - if (devpriv->high_speed) - devpriv->num_out_buffers = NUMOFOUTBUFFERSHIGH; - else - devpriv->num_out_buffers = NUMOFOUTBUFFERSFULL; - - devpriv->urb_out = kcalloc(devpriv->num_out_buffers, sizeof(*urb), - GFP_KERNEL); - if (!devpriv->urb_out) { + /* setting to alternate setting 3: enabling iso ep and bulk ep. */ + ret = usb_set_interface(devpriv->usbdev, devpriv->ifnum, 3); + if (ret < 0) { + dev_err(dev, + "could not set alternate setting 3 in high speed\n"); tidy_up(devpriv); up(&start_stop_sem); - return -ENOMEM; - } - for (i = 0; i < devpriv->num_out_buffers; i++) { - /* one frame: 1ms */ - urb = usb_alloc_urb(1, GFP_KERNEL); - if (!urb) { - tidy_up(devpriv); - up(&start_stop_sem); - return -ENOMEM; - } - devpriv->urb_out[i] = urb; - - urb->dev = devpriv->usbdev; - /* will be filled later with a pointer to the comedi-device */ - /* and ONLY then the urb should be submitted */ - urb->context = NULL; - urb->pipe = usb_sndisocpipe(devpriv->usbdev, ISOOUTEP); - urb->transfer_flags = URB_ISO_ASAP; - urb->transfer_buffer = kzalloc(SIZEOUTBUF, GFP_KERNEL); - if (!(urb->transfer_buffer)) { - tidy_up(devpriv); - up(&start_stop_sem); - return -ENOMEM; - } - urb->complete = usbduxsub_ao_isoc_irq; - urb->number_of_packets = 1; - urb->transfer_buffer_length = SIZEOUTBUF; - urb->iso_frame_desc[0].offset = 0; - urb->iso_frame_desc[0].length = SIZEOUTBUF; - if (devpriv->high_speed) - urb->interval = 8; /* uframes */ - else - urb->interval = 1; /* frames */ - } - - /* pwm */ - if (devpriv->high_speed) { - urb = usb_alloc_urb(0, GFP_KERNEL); - if (!urb) { - tidy_up(devpriv); - up(&start_stop_sem); - return -ENOMEM; - } - devpriv->urb_pwm = urb; - - /* max bulk ep size in high speed */ - devpriv->size_pwm_buf = 512; - urb->transfer_buffer = kzalloc(devpriv->size_pwm_buf, - GFP_KERNEL); - if (!urb->transfer_buffer) { - tidy_up(devpriv); - up(&start_stop_sem); - return -ENOMEM; - } - } else { - devpriv->urb_pwm = NULL; - devpriv->size_pwm_buf = 0; + return ret; } devpriv->ai_cmd_running = 0; -- GitLab From a7dd65f57cc4bf07c3bcfb798577e275186a9c6f Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 14:08:02 -0700 Subject: [PATCH 211/942] staging: comedi: usbdux: push usb (*disconnect) into comedi (*detach) The usb_driver (*disconnect) calls comedi_usb_auto_unconfig() which will call the comedi_driver (*detach). Just move all the disconnect/detach into the comedi_driver and use comedi_usb_auto_unconfig() directly for the (*disconnect). Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 40 +++++++------------------ 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 892ecb53dbf55..204dfbb6de199 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -2384,15 +2384,18 @@ static int usbdux_auto_attach(struct comedi_device *dev, static void usbdux_detach(struct comedi_device *dev) { - struct usbdux_private *usb = dev->private; + struct usbdux_private *devpriv = dev->private; - if (usb) { - down(&usb->sem); + down(&start_stop_sem); + if (devpriv) { + down(&devpriv->sem); + tidy_up(devpriv); dev->private = NULL; - usb->attached = 0; - usb->comedidev = NULL; - up(&usb->sem); + devpriv->attached = 0; + devpriv->comedidev = NULL; + up(&devpriv->sem); } + up(&start_stop_sem); } static struct comedi_driver usbdux_driver = { @@ -2471,29 +2474,6 @@ static int usbdux_usb_probe(struct usb_interface *uinterf, return comedi_usb_auto_config(uinterf, &usbdux_driver, 0); } -static void usbdux_usb_disconnect(struct usb_interface *intf) -{ - struct usbdux_private *usbduxsub_tmp = usb_get_intfdata(intf); - struct usb_device *udev = interface_to_usbdev(intf); - - if (!usbduxsub_tmp) { - dev_err(&intf->dev, - "comedi_: disconnect called with null pointer.\n"); - return; - } - if (usbduxsub_tmp->usbdev != udev) { - dev_err(&intf->dev, "comedi_: BUG! called with wrong ptr!!!\n"); - return; - } - comedi_usb_auto_unconfig(intf); - down(&start_stop_sem); - down(&usbduxsub_tmp->sem); - tidy_up(usbduxsub_tmp); - up(&usbduxsub_tmp->sem); - up(&start_stop_sem); - dev_dbg(&intf->dev, "comedi_: disconnected from the usb\n"); -} - static const struct usb_device_id usbdux_usb_table[] = { { USB_DEVICE(0x13d8, 0x0001) }, { USB_DEVICE(0x13d8, 0x0002) }, @@ -2505,7 +2485,7 @@ MODULE_DEVICE_TABLE(usb, usbdux_usb_table); static struct usb_driver usbdux_usb_driver = { .name = "usbdux", .probe = usbdux_usb_probe, - .disconnect = usbdux_usb_disconnect, + .disconnect = comedi_usb_auto_unconfig, .id_table = usbdux_usb_table, }; module_comedi_usb_driver(usbdux_driver, usbdux_usb_driver); -- GitLab From ef1ee8cf126a84f5049c6dbf5dc3a350fdc84262 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 14:08:24 -0700 Subject: [PATCH 212/942] staging: comedi: usbdux: push usb (*probe) into comedi (*auto_attach) The usb_driver (*probe) calls comedi_usb_auto_config() after finding a free slot for the static private data and doind some initial allocation and setup. The comedi_usb_auto_config() will then call the comedi_driver (*auto_attach). Move all the probe/auto_attach into the comedi_driver and just have the usb_driver call comedi_usb_auto_config(). This allows the comedi_driver to allocate the private data and removes the need for the static array and the semaphore that protects it. Since all the probe/auto_attach is now handled by the comedi_driver, we can also remove the 'attached' and 'probed' information from the private data. The subdevice functions will only be hooked up if the usb device has been probed and the comedi device is attached. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 218 +++++------------------- 1 file changed, 42 insertions(+), 176 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 204dfbb6de199..8102efbced790 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -185,9 +185,6 @@ sampling rate. If you sample two channels you get 4kHz and so on. /* must have more buffers due to buggy USB ctr */ #define NUMOFOUTBUFFERSHIGH 10 -/* Total number of usbdux devices */ -#define NUMUSBDUX 16 - /* Analogue in subdevice */ #define SUBDEV_AD 0 @@ -229,10 +226,6 @@ static const struct comedi_lrange range_usbdux_ao_range = { 2, { }; struct usbdux_private { - /* attached? */ - int attached; - /* is it associated with a subdevice? */ - int probed; /* pointer to the usb-device */ struct usb_device *usbdev; /* actual number of in-buffers */ @@ -290,17 +283,6 @@ struct usbdux_private { struct semaphore sem; }; -/* - * The pointer to the private usb-data of the driver is also the private data - * for the comedi-device. This has to be global as the usb subsystem needs - * global variables. The other reason is that this structure must be there - * _before_ any comedi command is issued. The usb subsystem must be initialised - * before comedi can access it. - */ -static struct usbdux_private usbduxsub[NUMUSBDUX]; - -static DEFINE_SEMAPHORE(start_stop_sem); - /* * Stops the data acquision * It should be safe to call this function from any context @@ -369,10 +351,6 @@ static int usbdux_ai_cancel(struct comedi_device *dev, /* prevent other CPUs from submitting new commands just now */ down(&this_usbduxsub->sem); - if (!(this_usbduxsub->probed)) { - up(&this_usbduxsub->sem); - return -ENODEV; - } /* unlink only if the urb really has been submitted */ res = usbdux_ai_stop(this_usbduxsub, this_usbduxsub->ai_cmd_running); up(&this_usbduxsub->sem); @@ -569,10 +547,6 @@ static int usbdux_ao_cancel(struct comedi_device *dev, /* prevent other CPUs from submitting a command just now */ down(&this_usbduxsub->sem); - if (!(this_usbduxsub->probed)) { - up(&this_usbduxsub->sem); - return -ENODEV; - } /* unlink only if it is really running */ res = usbdux_ao_stop(this_usbduxsub, this_usbduxsub->ao_cmd_running); up(&this_usbduxsub->sem); @@ -856,9 +830,6 @@ static int usbdux_ai_cmdtest(struct comedi_device *dev, int err = 0, i; unsigned int tmp_timer; - if (!(this_usbduxsub->probed)) - return -ENODEV; - /* Step 1 : check if triggers are trivially valid */ err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_INT); @@ -1024,10 +995,6 @@ static int usbdux_ai_inttrig(struct comedi_device *dev, return -EFAULT; down(&this_usbduxsub->sem); - if (!(this_usbduxsub->probed)) { - up(&this_usbduxsub->sem); - return -ENODEV; - } dev_dbg(&this_usbduxsub->interface->dev, "comedi%d: usbdux_ai_inttrig\n", dev->minor); @@ -1075,11 +1042,6 @@ static int usbdux_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) /* block other CPUs from starting an ai_cmd */ down(&this_usbduxsub->sem); - - if (!(this_usbduxsub->probed)) { - up(&this_usbduxsub->sem); - return -ENODEV; - } if (this_usbduxsub->ai_cmd_running) { dev_err(&this_usbduxsub->interface->dev, "comedi%d: " "ai_cmd not possible. Another ai_cmd is running.\n", @@ -1194,10 +1156,6 @@ static int usbdux_ai_insn_read(struct comedi_device *dev, dev->minor, insn->n, insn->subdev); down(&this_usbduxsub->sem); - if (!(this_usbduxsub->probed)) { - up(&this_usbduxsub->sem); - return -ENODEV; - } if (this_usbduxsub->ai_cmd_running) { dev_err(&this_usbduxsub->interface->dev, "comedi%d: ai_insn_read not possible. " @@ -1250,10 +1208,6 @@ static int usbdux_ao_insn_read(struct comedi_device *dev, return -EFAULT; down(&this_usbduxsub->sem); - if (!(this_usbduxsub->probed)) { - up(&this_usbduxsub->sem); - return -ENODEV; - } for (i = 0; i < insn->n; i++) data[i] = this_usbduxsub->out_buffer[chan]; @@ -1276,10 +1230,6 @@ static int usbdux_ao_insn_write(struct comedi_device *dev, "comedi%d: ao_insn_write\n", dev->minor); down(&this_usbduxsub->sem); - if (!(this_usbduxsub->probed)) { - up(&this_usbduxsub->sem); - return -ENODEV; - } if (this_usbduxsub->ao_cmd_running) { dev_err(&this_usbduxsub->interface->dev, "comedi%d: ao_insn_write: " @@ -1322,10 +1272,6 @@ static int usbdux_ao_inttrig(struct comedi_device *dev, return -EFAULT; down(&this_usbduxsub->sem); - if (!(this_usbduxsub->probed)) { - up(&this_usbduxsub->sem); - return -ENODEV; - } if (trignum != 0) { dev_err(&this_usbduxsub->interface->dev, "comedi%d: usbdux_ao_inttrig: invalid trignum\n", @@ -1364,9 +1310,6 @@ static int usbdux_ao_cmdtest(struct comedi_device *dev, if (!this_usbduxsub) return -EFAULT; - if (!(this_usbduxsub->probed)) - return -ENODEV; - /* Step 1 : check if triggers are trivially valid */ err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_INT); @@ -1452,10 +1395,6 @@ static int usbdux_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) return -EFAULT; down(&this_usbduxsub->sem); - if (!(this_usbduxsub->probed)) { - up(&this_usbduxsub->sem); - return -ENODEV; - } dev_dbg(&this_usbduxsub->interface->dev, "comedi%d: %s\n", dev->minor, __func__); @@ -1593,11 +1532,6 @@ static int usbdux_dio_insn_bits(struct comedi_device *dev, down(&this_usbduxsub->sem); - if (!(this_usbduxsub->probed)) { - up(&this_usbduxsub->sem); - return -ENODEV; - } - /* The insn data is a mask in data[0] and the new data * in data[1], each channel cooresponding to a bit. */ s->state &= ~data[0]; @@ -1636,12 +1570,6 @@ static int usbdux_counter_read(struct comedi_device *dev, return -EFAULT; down(&this_usbduxsub->sem); - - if (!(this_usbduxsub->probed)) { - up(&this_usbduxsub->sem); - return -ENODEV; - } - err = send_dux_commands(this_usbduxsub, READCOUNTERCOMMAND); if (err < 0) { up(&this_usbduxsub->sem); @@ -1670,12 +1598,6 @@ static int usbdux_counter_write(struct comedi_device *dev, return -EFAULT; down(&this_usbduxsub->sem); - - if (!(this_usbduxsub->probed)) { - up(&this_usbduxsub->sem); - return -ENODEV; - } - this_usbduxsub->dux_commands[1] = insn->chanspec; *((int16_t *) (this_usbduxsub->dux_commands + 2)) = cpu_to_le16(*data); @@ -2050,8 +1972,6 @@ static void tidy_up(struct usbdux_private *usbduxsub_tmp) if (usbduxsub_tmp->interface) usb_set_intfdata(usbduxsub_tmp->interface, NULL); - usbduxsub_tmp->probed = 0; - if (usbduxsub_tmp->urb_in) { if (usbduxsub_tmp->ai_cmd_running) { usbduxsub_tmp->ai_cmd_running = 0; @@ -2110,9 +2030,9 @@ static void tidy_up(struct usbdux_private *usbduxsub_tmp) usbduxsub_tmp->pwm_cmd_running = 0; } -static int usbdux_attach_common(struct comedi_device *dev, - struct usbdux_private *udev) +static int usbdux_attach_common(struct comedi_device *dev) { + struct usbdux_private *udev = dev->private; int ret; struct comedi_subdevice *s = NULL; int n_subdevs; @@ -2136,9 +2056,6 @@ static int usbdux_attach_common(struct comedi_device *dev, return ret; } - /* private structure is also simply the usb-structure */ - dev->private = udev; - /* the first subdevice is the A/D converter */ s = &dev->subdevices[SUBDEV_AD]; /* the URBs get the comedi subdevice */ @@ -2227,8 +2144,6 @@ static int usbdux_attach_common(struct comedi_device *dev, s->insn_config = usbdux_pwm_config; usbdux_pwm_period(dev, s, PWM_DEFAULT_PERIOD); } - /* finally decide that it's attached */ - udev->attached = 1; up(&udev->sem); @@ -2352,88 +2267,21 @@ static int usbdux_alloc_usb_buffers(struct usbdux_private *devpriv) static int usbdux_auto_attach(struct comedi_device *dev, unsigned long context_unused) { - struct usb_interface *uinterf = comedi_to_usb_interface(dev); - struct usbdux_private *this_usbduxsub = usb_get_intfdata(uinterf); - struct usb_device *usb = usbduxsub->usbdev; - int ret; - - dev->private = this_usbduxsub; /* This is temporary... */ - ret = comedi_load_firmware(dev, &usb->dev, FIRMWARE, - usbdux_firmware_upload, 0); - if (ret < 0) { - dev->private = NULL; - return ret; - } - - dev->private = NULL; - - down(&start_stop_sem); - if (!this_usbduxsub || !this_usbduxsub->probed) { - dev_err(dev->class_dev, - "usbdux: error: auto_attach failed, not connected\n"); - ret = -ENODEV; - } else if (this_usbduxsub->attached) { - dev_err(dev->class_dev, - "error: auto_attach failed, already attached\n"); - ret = -ENODEV; - } else - ret = usbdux_attach_common(dev, this_usbduxsub); - up(&start_stop_sem); - return ret; -} - -static void usbdux_detach(struct comedi_device *dev) -{ - struct usbdux_private *devpriv = dev->private; - - down(&start_stop_sem); - if (devpriv) { - down(&devpriv->sem); - tidy_up(devpriv); - dev->private = NULL; - devpriv->attached = 0; - devpriv->comedidev = NULL; - up(&devpriv->sem); - } - up(&start_stop_sem); -} - -static struct comedi_driver usbdux_driver = { - .driver_name = "usbdux", - .module = THIS_MODULE, - .auto_attach = usbdux_auto_attach, - .detach = usbdux_detach, -}; - -static int usbdux_usb_probe(struct usb_interface *uinterf, - const struct usb_device_id *id) -{ - struct usb_device *udev = interface_to_usbdev(uinterf); - struct device *dev = &uinterf->dev; - struct usbdux_private *devpriv = NULL; + struct usb_interface *intf = comedi_to_usb_interface(dev); + struct usb_device *usb = comedi_to_usb_dev(dev); + struct usbdux_private *devpriv; int ret; - int i; - down(&start_stop_sem); - - for (i = 0; i < NUMUSBDUX; i++) { - if (!usbduxsub[i].probed) { - devpriv = &usbduxsub[i]; - break; - } - } - if (!devpriv) { - dev_err(dev, "Too many usbdux-devices connected.\n"); - up(&start_stop_sem); - return -EMFILE; - } + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); + if (!devpriv) + return -ENOMEM; sema_init(&devpriv->sem, 1); - devpriv->usbdev = udev; - devpriv->interface = uinterf; - devpriv->ifnum = uinterf->altsetting->desc.bInterfaceNumber; - usb_set_intfdata(uinterf, devpriv); + devpriv->usbdev = usb; + devpriv->interface = intf; + devpriv->ifnum = intf->altsetting->desc.bInterfaceNumber; + usb_set_intfdata(intf, devpriv); devpriv->high_speed = (devpriv->usbdev->speed == USB_SPEED_HIGH); if (devpriv->high_speed) { @@ -2443,35 +2291,54 @@ static int usbdux_usb_probe(struct usb_interface *uinterf, } else { devpriv->num_in_buffers = NUMOFINBUFFERSFULL; devpriv->num_out_buffers = NUMOFOUTBUFFERSFULL; - devpriv->size_pwm_buf = 0; } ret = usbdux_alloc_usb_buffers(devpriv); if (ret) { tidy_up(devpriv); - up(&start_stop_sem); return ret; } /* setting to alternate setting 3: enabling iso ep and bulk ep. */ ret = usb_set_interface(devpriv->usbdev, devpriv->ifnum, 3); if (ret < 0) { - dev_err(dev, + dev_err(dev->class_dev, "could not set alternate setting 3 in high speed\n"); tidy_up(devpriv); - up(&start_stop_sem); return ret; } - devpriv->ai_cmd_running = 0; - devpriv->ao_cmd_running = 0; - devpriv->pwm_cmd_running = 0; + ret = comedi_load_firmware(dev, &usb->dev, FIRMWARE, + usbdux_firmware_upload, 0); + if (ret < 0) + return ret; - /* we've reached the bottom of the function */ - devpriv->probed = 1; - up(&start_stop_sem); + return usbdux_attach_common(dev); +} + +static void usbdux_detach(struct comedi_device *dev) +{ + struct usbdux_private *devpriv = dev->private; - return comedi_usb_auto_config(uinterf, &usbdux_driver, 0); + if (devpriv) { + down(&devpriv->sem); + tidy_up(devpriv); + devpriv->comedidev = NULL; + up(&devpriv->sem); + } +} + +static struct comedi_driver usbdux_driver = { + .driver_name = "usbdux", + .module = THIS_MODULE, + .auto_attach = usbdux_auto_attach, + .detach = usbdux_detach, +}; + +static int usbdux_usb_probe(struct usb_interface *intf, + const struct usb_device_id *id) +{ + return comedi_usb_auto_config(intf, &usbdux_driver, 0); } static const struct usb_device_id usbdux_usb_table[] = { @@ -2479,7 +2346,6 @@ static const struct usb_device_id usbdux_usb_table[] = { { USB_DEVICE(0x13d8, 0x0002) }, { } }; - MODULE_DEVICE_TABLE(usb, usbdux_usb_table); static struct usb_driver usbdux_usb_driver = { -- GitLab From 29d0c07428d590ad93fd4721ff0e2f8f5ca8f264 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 14:08:43 -0700 Subject: [PATCH 213/942] staging: comedi: usbdux: remove unnecessary tidy_up() calls If the comedi_driver (*auto_attach) fails, the comedi core will call the (*detach) function to do any cleanup. It's not necessary to do the cleanup in the (*auto_attach). Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 8102efbced790..6a7d7f4aabec8 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -2294,17 +2294,14 @@ static int usbdux_auto_attach(struct comedi_device *dev, } ret = usbdux_alloc_usb_buffers(devpriv); - if (ret) { - tidy_up(devpriv); + if (ret) return ret; - } /* setting to alternate setting 3: enabling iso ep and bulk ep. */ ret = usb_set_interface(devpriv->usbdev, devpriv->ifnum, 3); if (ret < 0) { dev_err(dev->class_dev, "could not set alternate setting 3 in high speed\n"); - tidy_up(devpriv); return ret; } -- GitLab From 8ff14ee8a6e4d9aca3098c47e876bc43f9e4cbe5 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 14:09:04 -0700 Subject: [PATCH 214/942] staging: comedi: usbdux: cleanup the (*detach) The tidy_up() function is only called by the (*detach). That function unlinks any running urbs and frees all the allocated urbs and buffers used by the driver. Rename tidy_up() to usbdux_free_usb_buffers() and move all the parts that don't deal with the freeing of the buffers directly into the (*detach). Also, remove all the unnecessary clearing of the pointers. The comedi core will kfree() the private data after calling the (*detach). Foe aesthetic reasons, do the kfree()'ing of the buffers and urbs in the reverse order that they were allocated. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 124 ++++++++++-------------- 1 file changed, 53 insertions(+), 71 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 6a7d7f4aabec8..f7efc85e294e3 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -1960,76 +1960,6 @@ static int usbdux_pwm_config(struct comedi_device *dev, /* end of PWM */ /*****************************************************************/ -static void tidy_up(struct usbdux_private *usbduxsub_tmp) -{ - int i; - - if (!usbduxsub_tmp) - return; - dev_dbg(&usbduxsub_tmp->interface->dev, "comedi_: tiding up\n"); - - /* shows the usb subsystem that the driver is down */ - if (usbduxsub_tmp->interface) - usb_set_intfdata(usbduxsub_tmp->interface, NULL); - - if (usbduxsub_tmp->urb_in) { - if (usbduxsub_tmp->ai_cmd_running) { - usbduxsub_tmp->ai_cmd_running = 0; - usbduxsub_unlink_inurbs(usbduxsub_tmp); - } - for (i = 0; i < usbduxsub_tmp->num_in_buffers; i++) { - kfree(usbduxsub_tmp->urb_in[i]->transfer_buffer); - usbduxsub_tmp->urb_in[i]->transfer_buffer = NULL; - usb_kill_urb(usbduxsub_tmp->urb_in[i]); - usb_free_urb(usbduxsub_tmp->urb_in[i]); - usbduxsub_tmp->urb_in[i] = NULL; - } - kfree(usbduxsub_tmp->urb_in); - usbduxsub_tmp->urb_in = NULL; - } - if (usbduxsub_tmp->urb_out) { - if (usbduxsub_tmp->ao_cmd_running) { - usbduxsub_tmp->ao_cmd_running = 0; - usbduxsub_unlink_outurbs(usbduxsub_tmp); - } - for (i = 0; i < usbduxsub_tmp->num_out_buffers; i++) { - kfree(usbduxsub_tmp->urb_out[i]->transfer_buffer); - usbduxsub_tmp->urb_out[i]->transfer_buffer = NULL; - if (usbduxsub_tmp->urb_out[i]) { - usb_kill_urb(usbduxsub_tmp->urb_out[i]); - usb_free_urb(usbduxsub_tmp->urb_out[i]); - usbduxsub_tmp->urb_out[i] = NULL; - } - } - kfree(usbduxsub_tmp->urb_out); - usbduxsub_tmp->urb_out = NULL; - } - if (usbduxsub_tmp->urb_pwm) { - if (usbduxsub_tmp->pwm_cmd_running) { - usbduxsub_tmp->pwm_cmd_running = 0; - usbduxsub_unlink_pwm_urbs(usbduxsub_tmp); - } - kfree(usbduxsub_tmp->urb_pwm->transfer_buffer); - usbduxsub_tmp->urb_pwm->transfer_buffer = NULL; - usb_kill_urb(usbduxsub_tmp->urb_pwm); - usb_free_urb(usbduxsub_tmp->urb_pwm); - usbduxsub_tmp->urb_pwm = NULL; - } - kfree(usbduxsub_tmp->in_buffer); - usbduxsub_tmp->in_buffer = NULL; - kfree(usbduxsub_tmp->insn_buffer); - usbduxsub_tmp->insn_buffer = NULL; - kfree(usbduxsub_tmp->out_buffer); - usbduxsub_tmp->out_buffer = NULL; - kfree(usbduxsub_tmp->dac_commands); - usbduxsub_tmp->dac_commands = NULL; - kfree(usbduxsub_tmp->dux_commands); - usbduxsub_tmp->dux_commands = NULL; - usbduxsub_tmp->ai_cmd_running = 0; - usbduxsub_tmp->ao_cmd_running = 0; - usbduxsub_tmp->pwm_cmd_running = 0; -} - static int usbdux_attach_common(struct comedi_device *dev) { struct usbdux_private *udev = dev->private; @@ -2264,6 +2194,46 @@ static int usbdux_alloc_usb_buffers(struct usbdux_private *devpriv) return 0; } +static void usbdux_free_usb_buffers(struct usbdux_private *devpriv) +{ + struct urb *urb; + int i; + + urb = devpriv->urb_pwm; + if (urb) { + kfree(urb->transfer_buffer); + usb_kill_urb(urb); + usb_free_urb(urb); + } + if (devpriv->urb_out) { + for (i = 0; i < devpriv->num_out_buffers; i++) { + urb = devpriv->urb_out[i]; + if (urb) { + kfree(urb->transfer_buffer); + usb_kill_urb(urb); + usb_free_urb(urb); + } + } + kfree(devpriv->urb_out); + } + if (devpriv->urb_in) { + for (i = 0; i < devpriv->num_in_buffers; i++) { + urb = devpriv->urb_in[i]; + if (urb) { + kfree(urb->transfer_buffer); + usb_kill_urb(urb); + usb_free_urb(urb); + } + } + kfree(devpriv->urb_in); + } + kfree(devpriv->out_buffer); + kfree(devpriv->insn_buffer); + kfree(devpriv->in_buffer); + kfree(devpriv->dux_commands); + kfree(devpriv->dac_commands); +} + static int usbdux_auto_attach(struct comedi_device *dev, unsigned long context_unused) { @@ -2319,8 +2289,20 @@ static void usbdux_detach(struct comedi_device *dev) if (devpriv) { down(&devpriv->sem); - tidy_up(devpriv); + + usb_set_intfdata(devpriv->interface, NULL); + + if (devpriv->pwm_cmd_running) + usbduxsub_unlink_pwm_urbs(devpriv); + if (devpriv->ao_cmd_running) + usbduxsub_unlink_outurbs(devpriv); + if (devpriv->ai_cmd_running) + usbduxsub_unlink_inurbs(devpriv); + + usbdux_free_usb_buffers(devpriv); + devpriv->comedidev = NULL; + up(&devpriv->sem); } } -- GitLab From ee9c2dd35c368c588018c3bad591717cf6bd373a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 14:09:24 -0700 Subject: [PATCH 215/942] staging: comedi: usbdux: remove NOISY_DUX_DEBUGBUG This define enables printing of the 'dux_commands' that is sent to the usb device in send_dux_commands(). This type of development debug should not be left in the final driver. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index f7efc85e294e3..f41b8361bee34 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -78,9 +78,6 @@ sampling rate. If you sample two channels you get 4kHz and so on. * */ -/* generates loads of debug info */ -/* #define NOISY_DUX_DEBUGBUG */ - #include #include #include @@ -936,13 +933,6 @@ static int send_dux_commands(struct usbdux_private *this_usbduxsub, int cmd_type int result, nsent; this_usbduxsub->dux_commands[0] = cmd_type; -#ifdef NOISY_DUX_DEBUGBUG - printk(KERN_DEBUG "comedi%d: usbdux: dux_commands: ", - this_usbduxsub->comedidev->minor); - for (result = 0; result < SIZEOFDUXBUFFER; result++) - printk(" %02x", this_usbduxsub->dux_commands[result]); - printk("\n"); -#endif result = usb_bulk_msg(this_usbduxsub->usbdev, usb_sndbulkpipe(this_usbduxsub->usbdev, COMMAND_OUT_EP), -- GitLab From 72db740fd9ddc5cf4fc487d42bbfbbb7dfc2e564 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 14:09:51 -0700 Subject: [PATCH 216/942] staging: comedi: usbdux: tidy up usbdux_attach_common() Rename the local variable used for the device private data. Move the setting of the device private data 'comedidev' to the (*auto_attach) where the other back pointers are set. Tidy up the subdevice init by removing the unnecessary comments and adding some whitespace. Remove the unnecessary dev_info() after a sucessful attach. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 160 +++++++++--------------- 1 file changed, 60 insertions(+), 100 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index f41b8361bee34..460c066834353 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -1952,123 +1952,82 @@ static int usbdux_pwm_config(struct comedi_device *dev, static int usbdux_attach_common(struct comedi_device *dev) { - struct usbdux_private *udev = dev->private; + struct usbdux_private *devpriv = dev->private; + struct comedi_subdevice *s; int ret; - struct comedi_subdevice *s = NULL; - int n_subdevs; - - down(&udev->sem); - /* pointer back to the corresponding comedi device */ - udev->comedidev = dev; - /* set number of subdevices */ - if (udev->high_speed) { - /* with pwm */ - n_subdevs = 5; - } else { - /* without pwm */ - n_subdevs = 4; - } + down(&devpriv->sem); - ret = comedi_alloc_subdevices(dev, n_subdevs); + ret = comedi_alloc_subdevices(dev, (devpriv->high_speed) ? 5 : 4); if (ret) { - up(&udev->sem); + up(&devpriv->sem); return ret; } - /* the first subdevice is the A/D converter */ + /* Analog Input subdevice */ s = &dev->subdevices[SUBDEV_AD]; - /* the URBs get the comedi subdevice */ - /* which is responsible for reading */ - /* this is the subdevice which reads data */ dev->read_subdev = s; - /* the subdevice receives as private structure the */ - /* usb-structure */ - s->private = NULL; - /* analog input */ - s->type = COMEDI_SUBD_AI; - /* readable and ref is to ground */ - s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_CMD_READ; - /* 8 channels */ - s->n_chan = 8; - /* length of the channellist */ - s->len_chanlist = 8; - /* callback functions */ - s->insn_read = usbdux_ai_insn_read; - s->do_cmdtest = usbdux_ai_cmdtest; - s->do_cmd = usbdux_ai_cmd; - s->cancel = usbdux_ai_cancel; - /* max value from the A/D converter (12bit) */ - s->maxdata = 0xfff; - /* range table to convert to physical units */ - s->range_table = (&range_usbdux_ai_range); - - /* analog out */ + s->type = COMEDI_SUBD_AI; + s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_CMD_READ; + s->n_chan = 8; + s->maxdata = 0x0fff; + s->len_chanlist = 8; + s->range_table = &range_usbdux_ai_range; + s->insn_read = usbdux_ai_insn_read; + s->do_cmdtest = usbdux_ai_cmdtest; + s->do_cmd = usbdux_ai_cmd; + s->cancel = usbdux_ai_cancel; + + /* Analog Output subdevice */ s = &dev->subdevices[SUBDEV_DA]; - /* analog out */ - s->type = COMEDI_SUBD_AO; - /* backward pointer */ dev->write_subdev = s; - /* the subdevice receives as private structure the */ - /* usb-structure */ - s->private = NULL; - /* are writable */ - s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_CMD_WRITE; - /* 4 channels */ - s->n_chan = 4; - /* length of the channellist */ - s->len_chanlist = 4; - /* 12 bit resolution */ - s->maxdata = 0x0fff; - /* bipolar range */ - s->range_table = (&range_usbdux_ao_range); - /* callback */ - s->do_cmdtest = usbdux_ao_cmdtest; - s->do_cmd = usbdux_ao_cmd; - s->cancel = usbdux_ao_cancel; - s->insn_read = usbdux_ao_insn_read; - s->insn_write = usbdux_ao_insn_write; - - /* digital I/O */ + s->type = COMEDI_SUBD_AO; + s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_CMD_WRITE; + s->n_chan = 4; + s->maxdata = 0x0fff; + s->len_chanlist = 4; + s->range_table = &range_usbdux_ao_range; + s->do_cmdtest = usbdux_ao_cmdtest; + s->do_cmd = usbdux_ao_cmd; + s->cancel = usbdux_ao_cancel; + s->insn_read = usbdux_ao_insn_read; + s->insn_write = usbdux_ao_insn_write; + + /* Digital I/O subdevice */ s = &dev->subdevices[SUBDEV_DIO]; - s->type = COMEDI_SUBD_DIO; - s->subdev_flags = SDF_READABLE | SDF_WRITABLE; - s->n_chan = 8; - s->maxdata = 1; - s->range_table = (&range_digital); - s->insn_bits = usbdux_dio_insn_bits; - s->insn_config = usbdux_dio_insn_config; - /* we don't use it */ - s->private = NULL; - - /* counter */ + s->type = COMEDI_SUBD_DIO; + s->subdev_flags = SDF_READABLE | SDF_WRITABLE; + s->n_chan = 8; + s->maxdata = 1; + s->range_table = &range_digital; + s->insn_bits = usbdux_dio_insn_bits; + s->insn_config = usbdux_dio_insn_config; + + /* Counter subdevice */ s = &dev->subdevices[SUBDEV_COUNTER]; - s->type = COMEDI_SUBD_COUNTER; - s->subdev_flags = SDF_WRITABLE | SDF_READABLE; - s->n_chan = 4; - s->maxdata = 0xFFFF; - s->insn_read = usbdux_counter_read; - s->insn_write = usbdux_counter_write; - s->insn_config = usbdux_counter_config; - - if (udev->high_speed) { - /* timer / pwm */ + s->type = COMEDI_SUBD_COUNTER; + s->subdev_flags = SDF_WRITABLE | SDF_READABLE; + s->n_chan = 4; + s->maxdata = 0xffff; + s->insn_read = usbdux_counter_read; + s->insn_write = usbdux_counter_write; + s->insn_config = usbdux_counter_config; + + if (devpriv->high_speed) { + /* PWM subdevice */ s = &dev->subdevices[SUBDEV_PWM]; - s->type = COMEDI_SUBD_PWM; - s->subdev_flags = SDF_WRITABLE | SDF_PWM_HBRIDGE; - s->n_chan = 8; - /* this defines the max duty cycle resolution */ - s->maxdata = udev->size_pwm_buf; - s->insn_write = usbdux_pwm_write; - s->insn_read = usbdux_pwm_read; - s->insn_config = usbdux_pwm_config; + s->type = COMEDI_SUBD_PWM; + s->subdev_flags = SDF_WRITABLE | SDF_PWM_HBRIDGE; + s->n_chan = 8; + s->maxdata = devpriv->size_pwm_buf; + s->insn_write = usbdux_pwm_write; + s->insn_read = usbdux_pwm_read; + s->insn_config = usbdux_pwm_config; + usbdux_pwm_period(dev, s, PWM_DEFAULT_PERIOD); } - up(&udev->sem); - - dev_info(&udev->interface->dev, "comedi%d: attached to usbdux.\n", - dev->minor); + up(&devpriv->sem); return 0; } @@ -2238,6 +2197,7 @@ static int usbdux_auto_attach(struct comedi_device *dev, sema_init(&devpriv->sem, 1); + devpriv->comedidev = dev; devpriv->usbdev = usb; devpriv->interface = intf; devpriv->ifnum = intf->altsetting->desc.bInterfaceNumber; -- GitLab From cc84f4f980449d5274ec38e33718f0cc76f66888 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 14:10:11 -0700 Subject: [PATCH 217/942] staging: comedi: usbdux: absorb usbdux_attach_common into caller This function is only called by usbdux_auto_attach(), absorb it. Also, there is no reason to down/up the semaphore during the attach. None of the subdevices are functioning yet so there are no commands being sent to the usb device. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 152 +++++++++++------------- 1 file changed, 69 insertions(+), 83 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 460c066834353..32021f03bda27 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -1950,88 +1950,6 @@ static int usbdux_pwm_config(struct comedi_device *dev, /* end of PWM */ /*****************************************************************/ -static int usbdux_attach_common(struct comedi_device *dev) -{ - struct usbdux_private *devpriv = dev->private; - struct comedi_subdevice *s; - int ret; - - down(&devpriv->sem); - - ret = comedi_alloc_subdevices(dev, (devpriv->high_speed) ? 5 : 4); - if (ret) { - up(&devpriv->sem); - return ret; - } - - /* Analog Input subdevice */ - s = &dev->subdevices[SUBDEV_AD]; - dev->read_subdev = s; - s->type = COMEDI_SUBD_AI; - s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_CMD_READ; - s->n_chan = 8; - s->maxdata = 0x0fff; - s->len_chanlist = 8; - s->range_table = &range_usbdux_ai_range; - s->insn_read = usbdux_ai_insn_read; - s->do_cmdtest = usbdux_ai_cmdtest; - s->do_cmd = usbdux_ai_cmd; - s->cancel = usbdux_ai_cancel; - - /* Analog Output subdevice */ - s = &dev->subdevices[SUBDEV_DA]; - dev->write_subdev = s; - s->type = COMEDI_SUBD_AO; - s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_CMD_WRITE; - s->n_chan = 4; - s->maxdata = 0x0fff; - s->len_chanlist = 4; - s->range_table = &range_usbdux_ao_range; - s->do_cmdtest = usbdux_ao_cmdtest; - s->do_cmd = usbdux_ao_cmd; - s->cancel = usbdux_ao_cancel; - s->insn_read = usbdux_ao_insn_read; - s->insn_write = usbdux_ao_insn_write; - - /* Digital I/O subdevice */ - s = &dev->subdevices[SUBDEV_DIO]; - s->type = COMEDI_SUBD_DIO; - s->subdev_flags = SDF_READABLE | SDF_WRITABLE; - s->n_chan = 8; - s->maxdata = 1; - s->range_table = &range_digital; - s->insn_bits = usbdux_dio_insn_bits; - s->insn_config = usbdux_dio_insn_config; - - /* Counter subdevice */ - s = &dev->subdevices[SUBDEV_COUNTER]; - s->type = COMEDI_SUBD_COUNTER; - s->subdev_flags = SDF_WRITABLE | SDF_READABLE; - s->n_chan = 4; - s->maxdata = 0xffff; - s->insn_read = usbdux_counter_read; - s->insn_write = usbdux_counter_write; - s->insn_config = usbdux_counter_config; - - if (devpriv->high_speed) { - /* PWM subdevice */ - s = &dev->subdevices[SUBDEV_PWM]; - s->type = COMEDI_SUBD_PWM; - s->subdev_flags = SDF_WRITABLE | SDF_PWM_HBRIDGE; - s->n_chan = 8; - s->maxdata = devpriv->size_pwm_buf; - s->insn_write = usbdux_pwm_write; - s->insn_read = usbdux_pwm_read; - s->insn_config = usbdux_pwm_config; - - usbdux_pwm_period(dev, s, PWM_DEFAULT_PERIOD); - } - - up(&devpriv->sem); - - return 0; -} - static int usbdux_alloc_usb_buffers(struct usbdux_private *devpriv) { struct urb *urb; @@ -2189,6 +2107,7 @@ static int usbdux_auto_attach(struct comedi_device *dev, struct usb_interface *intf = comedi_to_usb_interface(dev); struct usb_device *usb = comedi_to_usb_dev(dev); struct usbdux_private *devpriv; + struct comedi_subdevice *s; int ret; devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); @@ -2230,7 +2149,74 @@ static int usbdux_auto_attach(struct comedi_device *dev, if (ret < 0) return ret; - return usbdux_attach_common(dev); + ret = comedi_alloc_subdevices(dev, (devpriv->high_speed) ? 5 : 4); + if (ret) + return ret; + + /* Analog Input subdevice */ + s = &dev->subdevices[SUBDEV_AD]; + dev->read_subdev = s; + s->type = COMEDI_SUBD_AI; + s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_CMD_READ; + s->n_chan = 8; + s->maxdata = 0x0fff; + s->len_chanlist = 8; + s->range_table = &range_usbdux_ai_range; + s->insn_read = usbdux_ai_insn_read; + s->do_cmdtest = usbdux_ai_cmdtest; + s->do_cmd = usbdux_ai_cmd; + s->cancel = usbdux_ai_cancel; + + /* Analog Output subdevice */ + s = &dev->subdevices[SUBDEV_DA]; + dev->write_subdev = s; + s->type = COMEDI_SUBD_AO; + s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_CMD_WRITE; + s->n_chan = 4; + s->maxdata = 0x0fff; + s->len_chanlist = 4; + s->range_table = &range_usbdux_ao_range; + s->do_cmdtest = usbdux_ao_cmdtest; + s->do_cmd = usbdux_ao_cmd; + s->cancel = usbdux_ao_cancel; + s->insn_read = usbdux_ao_insn_read; + s->insn_write = usbdux_ao_insn_write; + + /* Digital I/O subdevice */ + s = &dev->subdevices[SUBDEV_DIO]; + s->type = COMEDI_SUBD_DIO; + s->subdev_flags = SDF_READABLE | SDF_WRITABLE; + s->n_chan = 8; + s->maxdata = 1; + s->range_table = &range_digital; + s->insn_bits = usbdux_dio_insn_bits; + s->insn_config = usbdux_dio_insn_config; + + /* Counter subdevice */ + s = &dev->subdevices[SUBDEV_COUNTER]; + s->type = COMEDI_SUBD_COUNTER; + s->subdev_flags = SDF_WRITABLE | SDF_READABLE; + s->n_chan = 4; + s->maxdata = 0xffff; + s->insn_read = usbdux_counter_read; + s->insn_write = usbdux_counter_write; + s->insn_config = usbdux_counter_config; + + if (devpriv->high_speed) { + /* PWM subdevice */ + s = &dev->subdevices[SUBDEV_PWM]; + s->type = COMEDI_SUBD_PWM; + s->subdev_flags = SDF_WRITABLE | SDF_PWM_HBRIDGE; + s->n_chan = 8; + s->maxdata = devpriv->size_pwm_buf; + s->insn_write = usbdux_pwm_write; + s->insn_read = usbdux_pwm_read; + s->insn_config = usbdux_pwm_config; + + usbdux_pwm_period(dev, s, PWM_DEFAULT_PERIOD); + } + + return 0; } static void usbdux_detach(struct comedi_device *dev) -- GitLab From 0a9502f2c36539b6ad7fc5b9230ee2d9d34b6777 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 14:10:32 -0700 Subject: [PATCH 218/942] staging: comedi: usbdux: tidy up usbduxsub_ai_isoc_irq() Rename the local variables to the comedi "norm". The comedi_subdevice in this function is actually the dev->read_subdev that was initialized in the attach. Use that instead of accessing the dev->subdevices array directly. Use dev->class_dev as the device for all dev_printk() messages. Instead of using the 'comedidev' back pointer in the private data, use the comedi_device 'dev' that we already have. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 89 ++++++++++--------------- 1 file changed, 36 insertions(+), 53 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 32021f03bda27..d93d10950abd8 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -357,33 +357,22 @@ static int usbdux_ai_cancel(struct comedi_device *dev, /* analogue IN - interrupt service routine */ static void usbduxsub_ai_isoc_irq(struct urb *urb) { + struct comedi_device *dev = urb->context; + struct comedi_subdevice *s = dev->read_subdev; + struct usbdux_private *devpriv = dev->private; int i, err, n; - struct usbdux_private *this_usbduxsub; - struct comedi_device *this_comedidev; - struct comedi_subdevice *s; - - /* the context variable points to the subdevice */ - this_comedidev = urb->context; - /* the private structure of the subdevice is struct usbdux_private */ - this_usbduxsub = this_comedidev->private; - /* subdevice which is the AD converter */ - s = &this_comedidev->subdevices[SUBDEV_AD]; /* first we test if something unusual has just happened */ switch (urb->status) { case 0: /* copy the result in the transfer buffer */ - memcpy(this_usbduxsub->in_buffer, - urb->transfer_buffer, SIZEINBUF); + memcpy(devpriv->in_buffer, urb->transfer_buffer, SIZEINBUF); break; case -EILSEQ: /* error in the ISOchronous data */ /* we don't copy the data into the transfer buffer */ /* and recycle the last data byte */ - dev_dbg(&urb->dev->dev, - "comedi%d: usbdux: CRC error in ISO IN stream.\n", - this_usbduxsub->comedidev->minor); - + dev_dbg(dev->class_dev, "CRC error in ISO IN stream\n"); break; case -ECONNRESET: @@ -391,29 +380,27 @@ static void usbduxsub_ai_isoc_irq(struct urb *urb) case -ESHUTDOWN: case -ECONNABORTED: /* happens after an unlink command */ - if (this_usbduxsub->ai_cmd_running) { - /* we are still running a command */ - /* tell this comedi */ + if (devpriv->ai_cmd_running) { s->async->events |= COMEDI_CB_EOA; s->async->events |= COMEDI_CB_ERROR; - comedi_event(this_usbduxsub->comedidev, s); + comedi_event(dev, s); /* stop the transfer w/o unlink */ - usbdux_ai_stop(this_usbduxsub, 0); + usbdux_ai_stop(devpriv, 0); } return; default: /* a real error on the bus */ /* pass error to comedi if we are really running a command */ - if (this_usbduxsub->ai_cmd_running) { - dev_err(&urb->dev->dev, - "Non-zero urb status received in ai intr " - "context: %d\n", urb->status); + if (devpriv->ai_cmd_running) { + dev_err(dev->class_dev, + "Non-zero urb status received in ai intr context: %d\n", + urb->status); s->async->events |= COMEDI_CB_EOA; s->async->events |= COMEDI_CB_ERROR; - comedi_event(this_usbduxsub->comedidev, s); + comedi_event(dev, s); /* don't do an unlink here */ - usbdux_ai_stop(this_usbduxsub, 0); + usbdux_ai_stop(devpriv, 0); } return; } @@ -422,7 +409,7 @@ static void usbduxsub_ai_isoc_irq(struct urb *urb) * at this point we are reasonably sure that nothing dodgy has happened * are we running a command? */ - if (unlikely((!(this_usbduxsub->ai_cmd_running)))) { + if (unlikely(!devpriv->ai_cmd_running)) { /* * not running a command, do not continue execution if no * asynchronous command is running in particular not resubmit @@ -430,44 +417,42 @@ static void usbduxsub_ai_isoc_irq(struct urb *urb) return; } - urb->dev = this_usbduxsub->usbdev; + urb->dev = devpriv->usbdev; /* resubmit the urb */ err = usb_submit_urb(urb, GFP_ATOMIC); if (unlikely(err < 0)) { - dev_err(&urb->dev->dev, - "comedi_: urb resubmit failed in int-context! err=%d\n", - err); + dev_err(dev->class_dev, + "urb resubmit failed in int-context! err=%d\n", err); if (err == -EL2NSYNC) - dev_err(&urb->dev->dev, - "buggy USB host controller or bug in IRQ " - "handler!\n"); + dev_err(dev->class_dev, + "buggy USB host controller or bug in IRQ handler!\n"); s->async->events |= COMEDI_CB_EOA; s->async->events |= COMEDI_CB_ERROR; - comedi_event(this_usbduxsub->comedidev, s); + comedi_event(dev, s); /* don't do an unlink here */ - usbdux_ai_stop(this_usbduxsub, 0); + usbdux_ai_stop(devpriv, 0); return; } - this_usbduxsub->ai_counter--; - if (likely(this_usbduxsub->ai_counter > 0)) + devpriv->ai_counter--; + if (likely(devpriv->ai_counter > 0)) return; /* timer zero, transfer measurements to comedi */ - this_usbduxsub->ai_counter = this_usbduxsub->ai_timer; + devpriv->ai_counter = devpriv->ai_timer; /* test, if we transmit only a fixed number of samples */ - if (!(this_usbduxsub->ai_continous)) { + if (!devpriv->ai_continous) { /* not continuous, fixed number of samples */ - this_usbduxsub->ai_sample_count--; + devpriv->ai_sample_count--; /* all samples received? */ - if (this_usbduxsub->ai_sample_count < 0) { + if (devpriv->ai_sample_count < 0) { /* prevent a resubmit next time */ - usbdux_ai_stop(this_usbduxsub, 0); + usbdux_ai_stop(devpriv, 0); /* say comedi that the acquistion is over */ s->async->events |= COMEDI_CB_EOA; - comedi_event(this_usbduxsub->comedidev, s); + comedi_event(dev, s); return; } } @@ -476,23 +461,21 @@ static void usbduxsub_ai_isoc_irq(struct urb *urb) for (i = 0; i < n; i++) { /* transfer data */ if (CR_RANGE(s->async->cmd.chanlist[i]) <= 1) { - err = comedi_buf_put - (s->async, - le16_to_cpu(this_usbduxsub->in_buffer[i]) ^ 0x800); + err = comedi_buf_put(s->async, + le16_to_cpu(devpriv->in_buffer[i]) ^ 0x800); } else { - err = comedi_buf_put - (s->async, - le16_to_cpu(this_usbduxsub->in_buffer[i])); + err = comedi_buf_put(s->async, + le16_to_cpu(devpriv->in_buffer[i])); } if (unlikely(err == 0)) { /* buffer overflow */ - usbdux_ai_stop(this_usbduxsub, 0); + usbdux_ai_stop(devpriv, 0); return; } } /* tell comedi that data is there */ s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOS; - comedi_event(this_usbduxsub->comedidev, s); + comedi_event(dev, s); } static int usbduxsub_unlink_outurbs(struct usbdux_private *usbduxsub_tmp) -- GitLab From e057288ffd62ae63536d1f37dad4a22d2b84148b Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 14:10:54 -0700 Subject: [PATCH 219/942] staging: comedi: usbdux: tidy up usbduxsub_ao_isoc_irq() Rename the local variables to the comedi "norm". The comedi_subdevice in this function is actually the dev->write_subdev that was initialized in the attach. Use that instead of accessing the dev->subdevices array directly. Use dev->class_dev as the device for all dev_printk() messages. Instead of using the 'comedidev' back pointer in the private data, use the comedi_device 'dev' that we already have. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 85 +++++++++++-------------- 1 file changed, 36 insertions(+), 49 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index d93d10950abd8..292832b2b5e96 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -535,18 +535,11 @@ static int usbdux_ao_cancel(struct comedi_device *dev, static void usbduxsub_ao_isoc_irq(struct urb *urb) { + struct comedi_device *dev = urb->context; + struct comedi_subdevice *s = dev->write_subdev; + struct usbdux_private *devpriv = dev->private; int i, ret; int8_t *datap; - struct usbdux_private *this_usbduxsub; - struct comedi_device *this_comedidev; - struct comedi_subdevice *s; - - /* the context variable points to the subdevice */ - this_comedidev = urb->context; - /* the private structure of the subdevice is struct usbdux_private */ - this_usbduxsub = this_comedidev->private; - - s = &this_comedidev->subdevices[SUBDEV_DA]; switch (urb->status) { case 0: @@ -559,47 +552,47 @@ static void usbduxsub_ao_isoc_irq(struct urb *urb) case -ECONNABORTED: /* after an unlink command, unplug, ... etc */ /* no unlink needed here. Already shutting down. */ - if (this_usbduxsub->ao_cmd_running) { + if (devpriv->ao_cmd_running) { s->async->events |= COMEDI_CB_EOA; - comedi_event(this_usbduxsub->comedidev, s); - usbdux_ao_stop(this_usbduxsub, 0); + comedi_event(dev, s); + usbdux_ao_stop(devpriv, 0); } return; default: /* a real error */ - if (this_usbduxsub->ao_cmd_running) { - dev_err(&urb->dev->dev, - "comedi_: Non-zero urb status received in ao " - "intr context: %d\n", urb->status); + if (devpriv->ao_cmd_running) { + dev_err(dev->class_dev, + "Non-zero urb status received in ao intr context: %d\n", + urb->status); s->async->events |= COMEDI_CB_ERROR; s->async->events |= COMEDI_CB_EOA; - comedi_event(this_usbduxsub->comedidev, s); + comedi_event(dev, s); /* we do an unlink if we are in the high speed mode */ - usbdux_ao_stop(this_usbduxsub, 0); + usbdux_ao_stop(devpriv, 0); } return; } /* are we actually running? */ - if (!(this_usbduxsub->ao_cmd_running)) + if (!devpriv->ao_cmd_running) return; /* normal operation: executing a command in this subdevice */ - this_usbduxsub->ao_counter--; - if ((int)this_usbduxsub->ao_counter <= 0) { + devpriv->ao_counter--; + if ((int)devpriv->ao_counter <= 0) { /* timer zero */ - this_usbduxsub->ao_counter = this_usbduxsub->ao_timer; + devpriv->ao_counter = devpriv->ao_timer; /* handle non continous acquisition */ - if (!(this_usbduxsub->ao_continous)) { + if (!devpriv->ao_continous) { /* fixed number of samples */ - this_usbduxsub->ao_sample_count--; - if (this_usbduxsub->ao_sample_count < 0) { + devpriv->ao_sample_count--; + if (devpriv->ao_sample_count < 0) { /* all samples transmitted */ - usbdux_ao_stop(this_usbduxsub, 0); + usbdux_ao_stop(devpriv, 0); s->async->events |= COMEDI_CB_EOA; - comedi_event(this_usbduxsub->comedidev, s); + comedi_event(dev, s); /* no resubmit of the urb */ return; } @@ -619,9 +612,7 @@ static void usbduxsub_ao_isoc_irq(struct urb *urb) ret = comedi_buf_get(s->async, &temp); datap[0] = temp; datap[1] = temp >> 8; - datap[2] = this_usbduxsub->dac_commands[i]; - /* printk("data[0]=%x, data[1]=%x, data[2]=%x\n", */ - /* datap[0],datap[1],datap[2]); */ + datap[2] = devpriv->dac_commands[i]; if (ret < 0) { dev_err(&urb->dev->dev, "comedi: buffer underflow\n"); @@ -630,39 +621,35 @@ static void usbduxsub_ao_isoc_irq(struct urb *urb) } /* transmit data to comedi */ s->async->events |= COMEDI_CB_BLOCK; - comedi_event(this_usbduxsub->comedidev, s); + comedi_event(dev, s); } } urb->transfer_buffer_length = SIZEOUTBUF; - urb->dev = this_usbduxsub->usbdev; + urb->dev = devpriv->usbdev; urb->status = 0; - if (this_usbduxsub->ao_cmd_running) { - if (this_usbduxsub->high_speed) { - /* uframes */ - urb->interval = 8; - } else { - /* frames */ - urb->interval = 1; - } + if (devpriv->ao_cmd_running) { + if (devpriv->high_speed) + urb->interval = 8; /* uframes */ + else + urb->interval = 1; /* frames */ urb->number_of_packets = 1; urb->iso_frame_desc[0].offset = 0; urb->iso_frame_desc[0].length = SIZEOUTBUF; urb->iso_frame_desc[0].status = 0; ret = usb_submit_urb(urb, GFP_ATOMIC); if (ret < 0) { - dev_err(&urb->dev->dev, - "comedi_: ao urb resubm failed in int-cont. " - "ret=%d", ret); + dev_err(dev->class_dev, + "ao urb resubm failed in int-cont. ret=%d", + ret); if (ret == EL2NSYNC) - dev_err(&urb->dev->dev, - "buggy USB host controller or bug in " - "IRQ handling!\n"); + dev_err(dev->class_dev, + "buggy USB host controller or bug in IRQ handling!\n"); s->async->events |= COMEDI_CB_EOA; s->async->events |= COMEDI_CB_ERROR; - comedi_event(this_usbduxsub->comedidev, s); + comedi_event(dev, s); /* don't do an unlink here */ - usbdux_ao_stop(this_usbduxsub, 0); + usbdux_ao_stop(devpriv, 0); } } } -- GitLab From c9f3363a301844bbb2fa2d35e4baf4d9fd025df8 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 14:11:14 -0700 Subject: [PATCH 220/942] staging: comedi: usbdux: tidy up usbduxsub_pwm_irq() Rename the local variables to the comedi "norm". Use dev->class_dev as the device for all dev_printk() messages. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 49 ++++++++++--------------- 1 file changed, 19 insertions(+), 30 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 292832b2b5e96..9f1da8eb150d8 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -1634,19 +1634,9 @@ static int usbdux_pwm_cancel(struct comedi_device *dev, static void usbduxsub_pwm_irq(struct urb *urb) { + struct comedi_device *dev = urb->context; + struct usbdux_private *devpriv = dev->private; int ret; - struct usbdux_private *this_usbduxsub; - struct comedi_device *this_comedidev; - struct comedi_subdevice *s; - - /* printk(KERN_DEBUG "PWM: IRQ\n"); */ - - /* the context variable points to the subdevice */ - this_comedidev = urb->context; - /* the private structure of the subdevice is struct usbdux_private */ - this_usbduxsub = this_comedidev->private; - - s = &this_comedidev->subdevices[SUBDEV_DA]; switch (urb->status) { case 0: @@ -1661,42 +1651,41 @@ static void usbduxsub_pwm_irq(struct urb *urb) * after an unlink command, unplug, ... etc * no unlink needed here. Already shutting down. */ - if (this_usbduxsub->pwm_cmd_running) - usbdux_pwm_stop(this_usbduxsub, 0); + if (devpriv->pwm_cmd_running) + usbdux_pwm_stop(devpriv, 0); return; default: /* a real error */ - if (this_usbduxsub->pwm_cmd_running) { - dev_err(&this_usbduxsub->interface->dev, - "comedi_: Non-zero urb status received in " - "pwm intr context: %d\n", urb->status); - usbdux_pwm_stop(this_usbduxsub, 0); + if (devpriv->pwm_cmd_running) { + dev_err(dev->class_dev, + "Non-zero urb status received in pwm intr context: %d\n", + urb->status); + usbdux_pwm_stop(devpriv, 0); } return; } /* are we actually running? */ - if (!(this_usbduxsub->pwm_cmd_running)) + if (!devpriv->pwm_cmd_running) return; - urb->transfer_buffer_length = this_usbduxsub->size_pwm_buf; - urb->dev = this_usbduxsub->usbdev; + urb->transfer_buffer_length = devpriv->size_pwm_buf; + urb->dev = devpriv->usbdev; urb->status = 0; - if (this_usbduxsub->pwm_cmd_running) { + if (devpriv->pwm_cmd_running) { ret = usb_submit_urb(urb, GFP_ATOMIC); if (ret < 0) { - dev_err(&this_usbduxsub->interface->dev, - "comedi_: pwm urb resubm failed in int-cont. " - "ret=%d", ret); + dev_err(dev->class_dev, + "pwm urb resubm failed in int-cont. ret=%d", + ret); if (ret == EL2NSYNC) - dev_err(&this_usbduxsub->interface->dev, - "buggy USB host controller or bug in " - "IRQ handling!\n"); + dev_err(dev->class_dev, + "buggy USB host controller or bug in IRQ handling!\n"); /* don't do an unlink here */ - usbdux_pwm_stop(this_usbduxsub, 0); + usbdux_pwm_stop(devpriv, 0); } } } -- GitLab From e5acdc3561b14a73f5de6bca8a703d9faa7d191c Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 14:11:33 -0700 Subject: [PATCH 221/942] staging: comedi: usbdux: remove the SUBDEV_* defines These defines are only used to index the dev->subdevices array during the attach. It's cleaner to just open-code the values. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 9f1da8eb150d8..226b2945cd1fe 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -182,21 +182,6 @@ sampling rate. If you sample two channels you get 4kHz and so on. /* must have more buffers due to buggy USB ctr */ #define NUMOFOUTBUFFERSHIGH 10 -/* Analogue in subdevice */ -#define SUBDEV_AD 0 - -/* Analogue out subdevice */ -#define SUBDEV_DA 1 - -/* Digital I/O */ -#define SUBDEV_DIO 2 - -/* counter */ -#define SUBDEV_COUNTER 3 - -/* timer aka pwm output */ -#define SUBDEV_PWM 4 - /* number of retries to get the right dux command */ #define RETRIES 10 @@ -2113,7 +2098,7 @@ static int usbdux_auto_attach(struct comedi_device *dev, return ret; /* Analog Input subdevice */ - s = &dev->subdevices[SUBDEV_AD]; + s = &dev->subdevices[0]; dev->read_subdev = s; s->type = COMEDI_SUBD_AI; s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_CMD_READ; @@ -2127,7 +2112,7 @@ static int usbdux_auto_attach(struct comedi_device *dev, s->cancel = usbdux_ai_cancel; /* Analog Output subdevice */ - s = &dev->subdevices[SUBDEV_DA]; + s = &dev->subdevices[1]; dev->write_subdev = s; s->type = COMEDI_SUBD_AO; s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_CMD_WRITE; @@ -2142,7 +2127,7 @@ static int usbdux_auto_attach(struct comedi_device *dev, s->insn_write = usbdux_ao_insn_write; /* Digital I/O subdevice */ - s = &dev->subdevices[SUBDEV_DIO]; + s = &dev->subdevices[2]; s->type = COMEDI_SUBD_DIO; s->subdev_flags = SDF_READABLE | SDF_WRITABLE; s->n_chan = 8; @@ -2152,7 +2137,7 @@ static int usbdux_auto_attach(struct comedi_device *dev, s->insn_config = usbdux_dio_insn_config; /* Counter subdevice */ - s = &dev->subdevices[SUBDEV_COUNTER]; + s = &dev->subdevices[3]; s->type = COMEDI_SUBD_COUNTER; s->subdev_flags = SDF_WRITABLE | SDF_READABLE; s->n_chan = 4; @@ -2163,7 +2148,7 @@ static int usbdux_auto_attach(struct comedi_device *dev, if (devpriv->high_speed) { /* PWM subdevice */ - s = &dev->subdevices[SUBDEV_PWM]; + s = &dev->subdevices[4]; s->type = COMEDI_SUBD_PWM; s->subdev_flags = SDF_WRITABLE | SDF_PWM_HBRIDGE; s->n_chan = 8; -- GitLab From 38691ec1106b2c4345f271746c1fcd7174d1130d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 14:11:53 -0700 Subject: [PATCH 222/942] staging: comedi: usbdux: tidy up the comedi_lrange tables Cleanup the whitespace in the tables. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 30 ++++++++++--------------- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 226b2945cd1fe..6707950e8bdf2 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -185,26 +185,20 @@ sampling rate. If you sample two channels you get 4kHz and so on. /* number of retries to get the right dux command */ #define RETRIES 10 -/**************************************************/ -/* comedi constants */ -static const struct comedi_lrange range_usbdux_ai_range = { 4, { - BIP_RANGE - (4.096), - BIP_RANGE(4.096 - / 2), - UNI_RANGE - (4.096), - UNI_RANGE(4.096 - / 2) - } +static const struct comedi_lrange range_usbdux_ai_range = { + 4, { + BIP_RANGE(4.096), + BIP_RANGE(4.096 / 2), + UNI_RANGE(4.096), + UNI_RANGE(4.096 / 2) + } }; -static const struct comedi_lrange range_usbdux_ao_range = { 2, { - BIP_RANGE - (4.096), - UNI_RANGE - (4.096), - } +static const struct comedi_lrange range_usbdux_ao_range = { + 2, { + BIP_RANGE(4.096), + UNI_RANGE(4.096) + } }; struct usbdux_private { -- GitLab From 91aa6b2193a178dd409ac78a5b909881db8f829c Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 14:12:14 -0700 Subject: [PATCH 223/942] staging: comedi: usbdux: remove dev_printk() noise Most of these are just function trace noise. The rest report errors that the user can't do anything about so they amount to added noise. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 184 +++--------------------- 1 file changed, 16 insertions(+), 168 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 6707950e8bdf2..7b2e072aad1b5 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -275,9 +275,6 @@ static int usbduxsub_unlink_inurbs(struct usbdux_private *usbduxsub_tmp) * cancelled. */ usb_kill_urb(usbduxsub_tmp->urb_in[i]); } - dev_dbg(&usbduxsub_tmp->interface->dev, - "comedi: usbdux: unlinked InURB %d, err=%d\n", - i, err); } } return err; @@ -292,11 +289,8 @@ static int usbdux_ai_stop(struct usbdux_private *this_usbduxsub, int do_unlink) { int ret = 0; - if (!this_usbduxsub) { - pr_err("comedi?: usbdux_ai_stop: this_usbduxsub=NULL!\n"); + if (!this_usbduxsub) return -EFAULT; - } - dev_dbg(&this_usbduxsub->interface->dev, "comedi: usbdux_ai_stop\n"); if (do_unlink) { /* stop aquistion */ @@ -323,8 +317,6 @@ static int usbdux_ai_cancel(struct comedi_device *dev, if (!this_usbduxsub) return -EFAULT; - dev_dbg(&this_usbduxsub->interface->dev, "comedi: usbdux_ai_cancel\n"); - /* prevent other CPUs from submitting new commands just now */ down(&this_usbduxsub->sem); /* unlink only if the urb really has been submitted */ @@ -466,10 +458,6 @@ static int usbduxsub_unlink_outurbs(struct usbdux_private *usbduxsub_tmp) for (i = 0; i < usbduxsub_tmp->num_out_buffers; i++) { if (usbduxsub_tmp->urb_out[i]) usb_kill_urb(usbduxsub_tmp->urb_out[i]); - - dev_dbg(&usbduxsub_tmp->interface->dev, - "comedi: usbdux: unlinked OutURB %d: res=%d\n", - i, err); } } return err; @@ -484,7 +472,6 @@ static int usbdux_ao_stop(struct usbdux_private *this_usbduxsub, int do_unlink) if (!this_usbduxsub) return -EFAULT; - dev_dbg(&this_usbduxsub->interface->dev, "comedi: usbdux_ao_cancel\n"); if (do_unlink) ret = usbduxsub_unlink_outurbs(this_usbduxsub); @@ -726,19 +713,9 @@ static int usbduxsub_submit_inurbs(struct usbdux_private *usbduxsub) usbduxsub->urb_in[i]->dev = usbduxsub->usbdev; usbduxsub->urb_in[i]->status = 0; usbduxsub->urb_in[i]->transfer_flags = URB_ISO_ASAP; - dev_dbg(&usbduxsub->interface->dev, - "comedi%d: submitting in-urb[%d]: %p,%p intv=%d\n", - usbduxsub->comedidev->minor, i, - (usbduxsub->urb_in[i]->context), - (usbduxsub->urb_in[i]->dev), - (usbduxsub->urb_in[i]->interval)); err_flag = usb_submit_urb(usbduxsub->urb_in[i], GFP_ATOMIC); - if (err_flag) { - dev_err(&usbduxsub->interface->dev, - "comedi_: ai: usb_submit_urb(%d) error %d\n", - i, err_flag); + if (err_flag) return err_flag; - } } return 0; } @@ -751,20 +728,14 @@ static int usbduxsub_submit_outurbs(struct usbdux_private *usbduxsub) return -EFAULT; for (i = 0; i < usbduxsub->num_out_buffers; i++) { - dev_dbg(&usbduxsub->interface->dev, - "comedi_: submitting out-urb[%d]\n", i); /* in case of a resubmission after an unlink... */ usbduxsub->urb_out[i]->context = usbduxsub->comedidev; usbduxsub->urb_out[i]->dev = usbduxsub->usbdev; usbduxsub->urb_out[i]->status = 0; usbduxsub->urb_out[i]->transfer_flags = URB_ISO_ASAP; err_flag = usb_submit_urb(usbduxsub->urb_out[i], GFP_ATOMIC); - if (err_flag) { - dev_err(&usbduxsub->interface->dev, - "comedi_: ao: usb_submit_urb(%d) error %d\n", - i, err_flag); + if (err_flag) return err_flag; - } } return 0; } @@ -879,20 +850,15 @@ static int8_t create_adc_command(unsigned int chan, int range) static int send_dux_commands(struct usbdux_private *this_usbduxsub, int cmd_type) { - int result, nsent; + int nsent; this_usbduxsub->dux_commands[0] = cmd_type; - result = usb_bulk_msg(this_usbduxsub->usbdev, - usb_sndbulkpipe(this_usbduxsub->usbdev, - COMMAND_OUT_EP), - this_usbduxsub->dux_commands, SIZEOFDUXBUFFER, - &nsent, BULK_TIMEOUT); - if (result < 0) - dev_err(&this_usbduxsub->interface->dev, "comedi%d: " - "could not transmit dux_command to the usb-device, " - "err=%d\n", this_usbduxsub->comedidev->minor, result); - - return result; + + return usb_bulk_msg(this_usbduxsub->usbdev, + usb_sndbulkpipe(this_usbduxsub->usbdev, + COMMAND_OUT_EP), + this_usbduxsub->dux_commands, SIZEOFDUXBUFFER, + &nsent, BULK_TIMEOUT); } static int receive_dux_commands(struct usbdux_private *this_usbduxsub, int command) @@ -907,21 +873,13 @@ static int receive_dux_commands(struct usbdux_private *this_usbduxsub, int comma COMMAND_IN_EP), this_usbduxsub->insn_buffer, SIZEINSNBUF, &nrec, BULK_TIMEOUT); - if (result < 0) { - dev_err(&this_usbduxsub->interface->dev, "comedi%d: " - "insn: USB error %d while receiving DUX command" - "\n", this_usbduxsub->comedidev->minor, result); + if (result < 0) return result; - } if (le16_to_cpu(this_usbduxsub->insn_buffer[0]) == command) return result; } /* this is only reached if the data has been requested a couple of * times */ - dev_err(&this_usbduxsub->interface->dev, "comedi%d: insn: " - "wrong data returned from firmware: want cmd %d, got cmd %d.\n", - this_usbduxsub->comedidev->minor, command, - le16_to_cpu(this_usbduxsub->insn_buffer[0])); return -EFAULT; } @@ -934,13 +892,8 @@ static int usbdux_ai_inttrig(struct comedi_device *dev, return -EFAULT; down(&this_usbduxsub->sem); - dev_dbg(&this_usbduxsub->interface->dev, - "comedi%d: usbdux_ai_inttrig\n", dev->minor); if (trignum != 0) { - dev_err(&this_usbduxsub->interface->dev, - "comedi%d: usbdux_ai_inttrig: invalid trignum\n", - dev->minor); up(&this_usbduxsub->sem); return -EINVAL; } @@ -948,18 +901,11 @@ static int usbdux_ai_inttrig(struct comedi_device *dev, this_usbduxsub->ai_cmd_running = 1; ret = usbduxsub_submit_inurbs(this_usbduxsub); if (ret < 0) { - dev_err(&this_usbduxsub->interface->dev, - "comedi%d: usbdux_ai_inttrig: " - "urbSubmit: err=%d\n", dev->minor, ret); this_usbduxsub->ai_cmd_running = 0; up(&this_usbduxsub->sem); return ret; } s->async->inttrig = NULL; - } else { - dev_err(&this_usbduxsub->interface->dev, - "comedi%d: ai_inttrig but acqu is already running\n", - dev->minor); } up(&this_usbduxsub->sem); return 1; @@ -976,15 +922,9 @@ static int usbdux_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) if (!this_usbduxsub) return -EFAULT; - dev_dbg(&this_usbduxsub->interface->dev, - "comedi%d: usbdux_ai_cmd\n", dev->minor); - /* block other CPUs from starting an ai_cmd */ down(&this_usbduxsub->sem); if (this_usbduxsub->ai_cmd_running) { - dev_err(&this_usbduxsub->interface->dev, "comedi%d: " - "ai_cmd not possible. Another ai_cmd is running.\n", - dev->minor); up(&this_usbduxsub->sem); return -EBUSY; } @@ -995,20 +935,12 @@ static int usbdux_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) for (i = 0; i < cmd->chanlist_len; ++i) { chan = CR_CHAN(cmd->chanlist[i]); range = CR_RANGE(cmd->chanlist[i]); - if (i >= NUMCHANNELS) { - dev_err(&this_usbduxsub->interface->dev, - "comedi%d: channel list too long\n", - dev->minor); + if (i >= NUMCHANNELS) break; - } this_usbduxsub->dux_commands[i + 2] = create_adc_command(chan, range); } - dev_dbg(&this_usbduxsub->interface->dev, - "comedi %d: sending commands to the usb device: size=%u\n", - dev->minor, NUMCHANNELS); - result = send_dux_commands(this_usbduxsub, SENDADCOMMANDS); if (result < 0) { up(&this_usbduxsub->sem); @@ -1036,10 +968,6 @@ static int usbdux_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) this_usbduxsub->ai_timer = cmd->scan_begin_arg / 1000000; } if (this_usbduxsub->ai_timer < 1) { - dev_err(&this_usbduxsub->interface->dev, "comedi%d: ai_cmd: " - "timer=%d, scan_begin_arg=%d. " - "Not properly tested by cmdtest?\n", dev->minor, - this_usbduxsub->ai_timer, cmd->scan_begin_arg); up(&this_usbduxsub->sem); return -EINVAL; } @@ -1090,15 +1018,8 @@ static int usbdux_ai_insn_read(struct comedi_device *dev, if (!this_usbduxsub) return 0; - dev_dbg(&this_usbduxsub->interface->dev, - "comedi%d: ai_insn_read, insn->n=%d, insn->subdev=%d\n", - dev->minor, insn->n, insn->subdev); - down(&this_usbduxsub->sem); if (this_usbduxsub->ai_cmd_running) { - dev_err(&this_usbduxsub->interface->dev, - "comedi%d: ai_insn_read not possible. " - "Async Command is running.\n", dev->minor); up(&this_usbduxsub->sem); return 0; } @@ -1165,23 +1086,13 @@ static int usbdux_ao_insn_write(struct comedi_device *dev, if (!this_usbduxsub) return -EFAULT; - dev_dbg(&this_usbduxsub->interface->dev, - "comedi%d: ao_insn_write\n", dev->minor); - down(&this_usbduxsub->sem); if (this_usbduxsub->ao_cmd_running) { - dev_err(&this_usbduxsub->interface->dev, - "comedi%d: ao_insn_write: " - "ERROR: asynchronous ao_cmd is running\n", dev->minor); up(&this_usbduxsub->sem); return 0; } for (i = 0; i < insn->n; i++) { - dev_dbg(&this_usbduxsub->interface->dev, - "comedi%d: ao_insn_write: data[chan=%d,i=%d]=%d\n", - dev->minor, chan, i, data[i]); - /* number of channels: 1 */ this_usbduxsub->dux_commands[1] = 1; /* one 16 bit value */ @@ -1212,9 +1123,6 @@ static int usbdux_ao_inttrig(struct comedi_device *dev, down(&this_usbduxsub->sem); if (trignum != 0) { - dev_err(&this_usbduxsub->interface->dev, - "comedi%d: usbdux_ao_inttrig: invalid trignum\n", - dev->minor); up(&this_usbduxsub->sem); return -EINVAL; } @@ -1222,18 +1130,11 @@ static int usbdux_ao_inttrig(struct comedi_device *dev, this_usbduxsub->ao_cmd_running = 1; ret = usbduxsub_submit_outurbs(this_usbduxsub); if (ret < 0) { - dev_err(&this_usbduxsub->interface->dev, - "comedi%d: usbdux_ao_inttrig: submitURB: " - "err=%d\n", dev->minor, ret); this_usbduxsub->ao_cmd_running = 0; up(&this_usbduxsub->sem); return ret; } s->async->inttrig = NULL; - } else { - dev_err(&this_usbduxsub->interface->dev, - "comedi%d: ao_inttrig but acqu is already running.\n", - dev->minor); } up(&this_usbduxsub->sem); return 1; @@ -1334,24 +1235,15 @@ static int usbdux_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) return -EFAULT; down(&this_usbduxsub->sem); - dev_dbg(&this_usbduxsub->interface->dev, - "comedi%d: %s\n", dev->minor, __func__); /* set current channel of the running acquisition to zero */ s->async->cur_chan = 0; for (i = 0; i < cmd->chanlist_len; ++i) { chan = CR_CHAN(cmd->chanlist[i]); gain = CR_RANGE(cmd->chanlist[i]); - if (i >= NUMOUTCHANNELS) { - dev_err(&this_usbduxsub->interface->dev, - "comedi%d: %s: channel list too long\n", - dev->minor, __func__); + if (i >= NUMOUTCHANNELS) break; - } this_usbduxsub->dac_commands[i] = (chan << 6); - dev_dbg(&this_usbduxsub->interface->dev, - "comedi%d: dac command for ch %d is %x\n", - dev->minor, i, this_usbduxsub->dac_commands[i]); } /* we count in steps of 1ms (125us) */ @@ -1364,21 +1256,7 @@ static int usbdux_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) /* 1ms */ /* timing of the scan: we get all channels at once */ this_usbduxsub->ao_timer = cmd->scan_begin_arg / 1000000; - dev_dbg(&this_usbduxsub->interface->dev, - "comedi%d: scan_begin_src=%d, scan_begin_arg=%d, " - "convert_src=%d, convert_arg=%d\n", dev->minor, - cmd->scan_begin_src, cmd->scan_begin_arg, - cmd->convert_src, cmd->convert_arg); - dev_dbg(&this_usbduxsub->interface->dev, - "comedi%d: ao_timer=%d (ms)\n", - dev->minor, this_usbduxsub->ao_timer); if (this_usbduxsub->ao_timer < 1) { - dev_err(&this_usbduxsub->interface->dev, - "comedi%d: usbdux: ao_timer=%d, " - "scan_begin_arg=%d. " - "Not properly tested by cmdtest?\n", - dev->minor, this_usbduxsub->ao_timer, - cmd->scan_begin_arg); up(&this_usbduxsub->sem); return -EINVAL; } @@ -1569,8 +1447,6 @@ static int usbduxsub_unlink_pwm_urbs(struct usbdux_private *usbduxsub_tmp) if (usbduxsub_tmp && usbduxsub_tmp->urb_pwm) { if (usbduxsub_tmp->urb_pwm) usb_kill_urb(usbduxsub_tmp->urb_pwm); - dev_dbg(&usbduxsub_tmp->interface->dev, - "comedi: unlinked PwmURB: res=%d\n", err); } return err; } @@ -1585,7 +1461,6 @@ static int usbdux_pwm_stop(struct usbdux_private *this_usbduxsub, int do_unlink) if (!this_usbduxsub) return -EFAULT; - dev_dbg(&this_usbduxsub->interface->dev, "comedi: %s\n", __func__); if (do_unlink) ret = usbduxsub_unlink_pwm_urbs(this_usbduxsub); @@ -1604,10 +1479,6 @@ static int usbdux_pwm_cancel(struct comedi_device *dev, /* unlink only if it is really running */ res = usbdux_pwm_stop(this_usbduxsub, this_usbduxsub->pwm_cmd_running); - dev_dbg(&this_usbduxsub->interface->dev, - "comedi %d: sending pwm off command to the usb device.\n", - dev->minor); - return send_dux_commands(this_usbduxsub, SENDPWMOFF); } @@ -1676,8 +1547,6 @@ static int usbduxsub_submit_pwm_urbs(struct usbdux_private *usbduxsub) if (!usbduxsub) return -EFAULT; - dev_dbg(&usbduxsub->interface->dev, "comedi_: submitting pwm-urb\n"); - /* in case of a resubmission after an unlink... */ usb_fill_bulk_urb(usbduxsub->urb_pwm, usbduxsub->usbdev, @@ -1687,12 +1556,8 @@ static int usbduxsub_submit_pwm_urbs(struct usbdux_private *usbduxsub) usbduxsub->comedidev); err_flag = usb_submit_urb(usbduxsub->urb_pwm, GFP_ATOMIC); - if (err_flag) { - dev_err(&usbduxsub->interface->dev, - "comedi_: usbdux: pwm: usb_submit_urb error %d\n", - err_flag); + if (err_flag) return err_flag; - } return 0; } @@ -1703,23 +1568,15 @@ static int usbdux_pwm_period(struct comedi_device *dev, int fx2delay = 255; if (period < MIN_PWM_PERIOD) { - dev_err(&this_usbduxsub->interface->dev, - "comedi%d: illegal period setting for pwm.\n", - dev->minor); return -EAGAIN; } else { fx2delay = period / ((int)(6 * 512 * (1.0 / 0.033))) - 6; - if (fx2delay > 255) { - dev_err(&this_usbduxsub->interface->dev, - "comedi%d: period %d for pwm is too low.\n", - dev->minor, period); + if (fx2delay > 255) return -EAGAIN; - } } this_usbduxsub->pwn_delay = fx2delay; this_usbduxsub->pwm_period = period; - dev_dbg(&this_usbduxsub->interface->dev, "%s: frequ=%d, period=%d\n", - __func__, period, fx2delay); + return 0; } @@ -1730,9 +1587,6 @@ static int usbdux_pwm_start(struct comedi_device *dev, int ret, i; struct usbdux_private *this_usbduxsub = dev->private; - dev_dbg(&this_usbduxsub->interface->dev, "comedi%d: %s\n", - dev->minor, __func__); - if (this_usbduxsub->pwm_cmd_running) { /* already running */ return 0; @@ -1841,8 +1695,6 @@ static int usbdux_pwm_config(struct comedi_device *dev, switch (data[0]) { case INSN_CONFIG_ARM: /* switch it on */ - dev_dbg(&this_usbduxsub->interface->dev, - "comedi%d: %s: pwm on\n", dev->minor, __func__); /* * if not zero the PWM is limited to a certain time which is * not supported here @@ -1851,8 +1703,6 @@ static int usbdux_pwm_config(struct comedi_device *dev, return -EINVAL; return usbdux_pwm_start(dev, s); case INSN_CONFIG_DISARM: - dev_dbg(&this_usbduxsub->interface->dev, - "comedi%d: %s: pwm off\n", dev->minor, __func__); return usbdux_pwm_cancel(dev, s); case INSN_CONFIG_GET_PWM_STATUS: /* @@ -1862,8 +1712,6 @@ static int usbdux_pwm_config(struct comedi_device *dev, data[1] = this_usbduxsub->pwm_cmd_running; return 0; case INSN_CONFIG_PWM_SET_PERIOD: - dev_dbg(&this_usbduxsub->interface->dev, - "comedi%d: %s: setting period\n", dev->minor, __func__); return usbdux_pwm_period(dev, s, data[1]); case INSN_CONFIG_PWM_GET_PERIOD: data[1] = this_usbduxsub->pwm_period; -- GitLab From 865d9eedd12570f5f296bf876edc09df78095bfc Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 14:12:35 -0700 Subject: [PATCH 224/942] staging: comedi: usbdux: tidy up usbduxsub_submit_inurbs() Pass the comedi_device pointer (the urb context) to this function instead of the private data pointer. Use a local variable for the urb pointers that are setup and submitted. Remove the sanity check of the private data. This function can only get called if the allocation was successful during the attach. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 35 ++++++++++++++----------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 7b2e072aad1b5..4d4ce3f184b7f 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -698,24 +698,27 @@ static int usbdux_firmware_upload(struct comedi_device *dev, return ret; } -static int usbduxsub_submit_inurbs(struct usbdux_private *usbduxsub) +static int usbduxsub_submit_inurbs(struct comedi_device *dev) { - int i, err_flag; - - if (!usbduxsub) - return -EFAULT; + struct usbdux_private *devpriv = dev->private; + struct urb *urb; + int ret; + int i; /* Submit all URBs and start the transfer on the bus */ - for (i = 0; i < usbduxsub->num_in_buffers; i++) { + for (i = 0; i < devpriv->num_in_buffers; i++) { + urb = devpriv->urb_in[i]; + /* in case of a resubmission after an unlink... */ - usbduxsub->urb_in[i]->interval = usbduxsub->ai_interval; - usbduxsub->urb_in[i]->context = usbduxsub->comedidev; - usbduxsub->urb_in[i]->dev = usbduxsub->usbdev; - usbduxsub->urb_in[i]->status = 0; - usbduxsub->urb_in[i]->transfer_flags = URB_ISO_ASAP; - err_flag = usb_submit_urb(usbduxsub->urb_in[i], GFP_ATOMIC); - if (err_flag) - return err_flag; + urb->interval = devpriv->ai_interval; + urb->context = dev; + urb->dev = devpriv->usbdev; + urb->status = 0; + urb->transfer_flags = URB_ISO_ASAP; + + ret = usb_submit_urb(urb, GFP_ATOMIC); + if (ret) + return ret; } return 0; } @@ -899,7 +902,7 @@ static int usbdux_ai_inttrig(struct comedi_device *dev, } if (!(this_usbduxsub->ai_cmd_running)) { this_usbduxsub->ai_cmd_running = 1; - ret = usbduxsub_submit_inurbs(this_usbduxsub); + ret = usbduxsub_submit_inurbs(dev); if (ret < 0) { this_usbduxsub->ai_cmd_running = 0; up(&this_usbduxsub->sem); @@ -986,7 +989,7 @@ static int usbdux_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) if (cmd->start_src == TRIG_NOW) { /* enable this acquisition operation */ this_usbduxsub->ai_cmd_running = 1; - ret = usbduxsub_submit_inurbs(this_usbduxsub); + ret = usbduxsub_submit_inurbs(dev); if (ret < 0) { this_usbduxsub->ai_cmd_running = 0; /* fixme: unlink here?? */ -- GitLab From 6754698b6a19ad1eb9075b2a49dba85850840a3f Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 14:13:15 -0700 Subject: [PATCH 225/942] staging: comedi: usbdux: tidy up usbduxsub_submit_outurbs() Pass the comedi_device pointer (the urb context) to this function instead of the private data pointer. Use a local variable for the urb pointers that are setup and submitted. Remove the sanity check of the private data. This function can only get called if the allocation was successful during the attach. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 31 ++++++++++++++----------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 4d4ce3f184b7f..7304ef0e2dedf 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -723,22 +723,25 @@ static int usbduxsub_submit_inurbs(struct comedi_device *dev) return 0; } -static int usbduxsub_submit_outurbs(struct usbdux_private *usbduxsub) +static int usbduxsub_submit_outurbs(struct comedi_device *dev) { - int i, err_flag; + struct usbdux_private *devpriv = dev->private; + struct urb *urb; + int ret; + int i; - if (!usbduxsub) - return -EFAULT; + for (i = 0; i < devpriv->num_out_buffers; i++) { + urb = devpriv->urb_out[i]; - for (i = 0; i < usbduxsub->num_out_buffers; i++) { /* in case of a resubmission after an unlink... */ - usbduxsub->urb_out[i]->context = usbduxsub->comedidev; - usbduxsub->urb_out[i]->dev = usbduxsub->usbdev; - usbduxsub->urb_out[i]->status = 0; - usbduxsub->urb_out[i]->transfer_flags = URB_ISO_ASAP; - err_flag = usb_submit_urb(usbduxsub->urb_out[i], GFP_ATOMIC); - if (err_flag) - return err_flag; + urb->context = dev; + urb->dev = devpriv->usbdev; + urb->status = 0; + urb->transfer_flags = URB_ISO_ASAP; + + ret = usb_submit_urb(urb, GFP_ATOMIC); + if (ret) + return ret; } return 0; } @@ -1131,7 +1134,7 @@ static int usbdux_ao_inttrig(struct comedi_device *dev, } if (!(this_usbduxsub->ao_cmd_running)) { this_usbduxsub->ao_cmd_running = 1; - ret = usbduxsub_submit_outurbs(this_usbduxsub); + ret = usbduxsub_submit_outurbs(dev); if (ret < 0) { this_usbduxsub->ao_cmd_running = 0; up(&this_usbduxsub->sem); @@ -1289,7 +1292,7 @@ static int usbdux_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) if (cmd->start_src == TRIG_NOW) { /* enable this acquisition operation */ this_usbduxsub->ao_cmd_running = 1; - ret = usbduxsub_submit_outurbs(this_usbduxsub); + ret = usbduxsub_submit_outurbs(dev); if (ret < 0) { this_usbduxsub->ao_cmd_running = 0; /* fixme: unlink here?? */ -- GitLab From 5a80fa0429b7b6e3b32813614178d4be302f5ea0 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 14:13:34 -0700 Subject: [PATCH 226/942] staging: comedi: usbdux: tidy up usbduxsub_submit_pwm_urbs() Pass the comedi_device pointer (the urb context) to this function instead of the private data pointer. Use a local variable for the urb pointer that is setup and submitted. Remove the sanity check of the private data. This function can only get called if the allocation was successful during the attach. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 29 ++++++++++--------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 7304ef0e2dedf..ad537ed5fc401 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -1546,25 +1546,20 @@ static void usbduxsub_pwm_irq(struct urb *urb) } } -static int usbduxsub_submit_pwm_urbs(struct usbdux_private *usbduxsub) +static int usbduxsub_submit_pwm_urbs(struct comedi_device *dev) { - int err_flag; - - if (!usbduxsub) - return -EFAULT; + struct usbdux_private *devpriv = dev->private; + struct urb *urb = devpriv->urb_pwm; /* in case of a resubmission after an unlink... */ - usb_fill_bulk_urb(usbduxsub->urb_pwm, - usbduxsub->usbdev, - usb_sndbulkpipe(usbduxsub->usbdev, PWM_EP), - usbduxsub->urb_pwm->transfer_buffer, - usbduxsub->size_pwm_buf, usbduxsub_pwm_irq, - usbduxsub->comedidev); - - err_flag = usb_submit_urb(usbduxsub->urb_pwm, GFP_ATOMIC); - if (err_flag) - return err_flag; - return 0; + usb_fill_bulk_urb(urb, devpriv->usbdev, + usb_sndbulkpipe(devpriv->usbdev, PWM_EP), + urb->transfer_buffer, + devpriv->size_pwm_buf, + usbduxsub_pwm_irq, + dev); + + return usb_submit_urb(urb, GFP_ATOMIC); } static int usbdux_pwm_period(struct comedi_device *dev, @@ -1608,7 +1603,7 @@ static int usbdux_pwm_start(struct comedi_device *dev, ((char *)(this_usbduxsub->urb_pwm->transfer_buffer))[i] = 0; this_usbduxsub->pwm_cmd_running = 1; - ret = usbduxsub_submit_pwm_urbs(this_usbduxsub); + ret = usbduxsub_submit_pwm_urbs(dev); if (ret < 0) { this_usbduxsub->pwm_cmd_running = 0; return ret; -- GitLab From cc8cb3da9e0fdaca684089c97708210655b2f343 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 14:14:42 -0700 Subject: [PATCH 227/942] staging: comedi: usbdux: remove 'comedidev' from private data This back pointer is no longer needed by the driver. Remove it. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index ad537ed5fc401..8db118019a3ca 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -229,8 +229,6 @@ struct usbdux_private { int ifnum; /* interface structure in 2.6 */ struct usb_interface *interface; - /* comedi device for the interrupt context */ - struct comedi_device *comedidev; /* is it USB_SPEED_HIGH or not? */ short int high_speed; /* asynchronous command is running */ @@ -1903,7 +1901,6 @@ static int usbdux_auto_attach(struct comedi_device *dev, sema_init(&devpriv->sem, 1); - devpriv->comedidev = dev; devpriv->usbdev = usb; devpriv->interface = intf; devpriv->ifnum = intf->altsetting->desc.bInterfaceNumber; @@ -2024,8 +2021,6 @@ static void usbdux_detach(struct comedi_device *dev) usbdux_free_usb_buffers(devpriv); - devpriv->comedidev = NULL; - up(&devpriv->sem); } } -- GitLab From 5d293d904c944894785f6a7be85acfc85ac4cfac Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 14:15:04 -0700 Subject: [PATCH 228/942] staging: comedi: usbdux: remove 'interface' from private data This back pointer is only used for a couple dev_printk() messages and during the detach. For the dev_printk() we can use the dev->class_dev. In the detach we can get the usb_interface from the comedi_device. Do that and remove the back pointer from the private data. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 8db118019a3ca..6a757f754d5f7 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -227,8 +227,6 @@ struct usbdux_private { int16_t *out_buffer; /* interface number */ int ifnum; - /* interface structure in 2.6 */ - struct usb_interface *interface; /* is it USB_SPEED_HIGH or not? */ short int high_speed; /* asynchronous command is running */ @@ -634,7 +632,7 @@ static int usbdux_firmware_upload(struct comedi_device *dev, return 0; if (size > FIRMWARE_MAX_LEN) { - dev_err(&usbduxsub->interface->dev, + dev_err(dev->class_dev, "usbdux firmware binary it too large for FX2.\n"); return -ENOMEM; } @@ -660,8 +658,7 @@ static int usbdux_firmware_upload(struct comedi_device *dev, tmp, 1, BULK_TIMEOUT); if (ret < 0) { - dev_err(&usbduxsub->interface->dev, - "comedi_: can not stop firmware\n"); + dev_err(dev->class_dev, "can not stop firmware\n"); goto done; } @@ -673,8 +670,7 @@ static int usbdux_firmware_upload(struct comedi_device *dev, buf, size, BULK_TIMEOUT); if (ret < 0) { - dev_err(&usbduxsub->interface->dev, - "comedi_: firmware upload failed\n"); + dev_err(dev->class_dev, "firmware upload failed\n"); goto done; } @@ -687,8 +683,7 @@ static int usbdux_firmware_upload(struct comedi_device *dev, tmp, 1, BULK_TIMEOUT); if (ret < 0) - dev_err(&usbduxsub->interface->dev, - "comedi_: can not start firmware\n"); + dev_err(dev->class_dev, "can not start firmware\n"); done: kfree(tmp); @@ -1902,7 +1897,6 @@ static int usbdux_auto_attach(struct comedi_device *dev, sema_init(&devpriv->sem, 1); devpriv->usbdev = usb; - devpriv->interface = intf; devpriv->ifnum = intf->altsetting->desc.bInterfaceNumber; usb_set_intfdata(intf, devpriv); @@ -2005,12 +1999,13 @@ static int usbdux_auto_attach(struct comedi_device *dev, static void usbdux_detach(struct comedi_device *dev) { + struct usb_interface *intf = comedi_to_usb_interface(dev); struct usbdux_private *devpriv = dev->private; if (devpriv) { down(&devpriv->sem); - usb_set_intfdata(devpriv->interface, NULL); + usb_set_intfdata(intf, NULL); if (devpriv->pwm_cmd_running) usbduxsub_unlink_pwm_urbs(devpriv); -- GitLab From 49cc49dd9e36c7154fc9da528b85db0eb7605969 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 14:15:22 -0700 Subject: [PATCH 229/942] staging: comedi: usbdux: tidy up send_dux_commands() For aesthetic reasons, pass the comedi_device pointer to this function instead of the private data pointer. Rename the local variable used for the private data pointer to the comedi "norm". Add a local variable for the usb_device pointer to tidy up the usb_bulk_msg() call. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 28 ++++++++++++------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 6a757f754d5f7..d2a3a1accb855 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -847,16 +847,16 @@ static int8_t create_adc_command(unsigned int chan, int range) #define SENDPWMON 7 #define SENDPWMOFF 8 -static int send_dux_commands(struct usbdux_private *this_usbduxsub, int cmd_type) +static int send_dux_commands(struct comedi_device *dev, int cmd_type) { + struct usbdux_private *devpriv = dev->private; + struct usb_device *usb = devpriv->usbdev; int nsent; - this_usbduxsub->dux_commands[0] = cmd_type; + devpriv->dux_commands[0] = cmd_type; - return usb_bulk_msg(this_usbduxsub->usbdev, - usb_sndbulkpipe(this_usbduxsub->usbdev, - COMMAND_OUT_EP), - this_usbduxsub->dux_commands, SIZEOFDUXBUFFER, + return usb_bulk_msg(usb, usb_sndbulkpipe(usb, COMMAND_OUT_EP), + devpriv->dux_commands, SIZEOFDUXBUFFER, &nsent, BULK_TIMEOUT); } @@ -940,7 +940,7 @@ static int usbdux_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) create_adc_command(chan, range); } - result = send_dux_commands(this_usbduxsub, SENDADCOMMANDS); + result = send_dux_commands(dev, SENDADCOMMANDS); if (result < 0) { up(&this_usbduxsub->sem); return result; @@ -1030,7 +1030,7 @@ static int usbdux_ai_insn_read(struct comedi_device *dev, this_usbduxsub->dux_commands[1] = create_adc_command(chan, range); /* adc commands */ - err = send_dux_commands(this_usbduxsub, SENDSINGLEAD); + err = send_dux_commands(dev, SENDSINGLEAD); if (err < 0) { up(&this_usbduxsub->sem); return err; @@ -1100,7 +1100,7 @@ static int usbdux_ao_insn_write(struct comedi_device *dev, this_usbduxsub->out_buffer[chan] = data[i]; /* channel number */ this_usbduxsub->dux_commands[4] = (chan << 6); - err = send_dux_commands(this_usbduxsub, SENDDACOMMANDS); + err = send_dux_commands(dev, SENDDACOMMANDS); if (err < 0) { up(&this_usbduxsub->sem); return err; @@ -1357,7 +1357,7 @@ static int usbdux_dio_insn_bits(struct comedi_device *dev, /* This command also tells the firmware to return */ /* the digital input lines */ - err = send_dux_commands(this_usbduxsub, SENDDIOBITSCOMMAND); + err = send_dux_commands(dev, SENDDIOBITSCOMMAND); if (err < 0) { up(&this_usbduxsub->sem); return err; @@ -1386,7 +1386,7 @@ static int usbdux_counter_read(struct comedi_device *dev, return -EFAULT; down(&this_usbduxsub->sem); - err = send_dux_commands(this_usbduxsub, READCOUNTERCOMMAND); + err = send_dux_commands(dev, READCOUNTERCOMMAND); if (err < 0) { up(&this_usbduxsub->sem); return err; @@ -1417,7 +1417,7 @@ static int usbdux_counter_write(struct comedi_device *dev, this_usbduxsub->dux_commands[1] = insn->chanspec; *((int16_t *) (this_usbduxsub->dux_commands + 2)) = cpu_to_le16(*data); - err = send_dux_commands(this_usbduxsub, WRITECOUNTERCOMMAND); + err = send_dux_commands(dev, WRITECOUNTERCOMMAND); if (err < 0) { up(&this_usbduxsub->sem); return err; @@ -1478,7 +1478,7 @@ static int usbdux_pwm_cancel(struct comedi_device *dev, /* unlink only if it is really running */ res = usbdux_pwm_stop(this_usbduxsub, this_usbduxsub->pwm_cmd_running); - return send_dux_commands(this_usbduxsub, SENDPWMOFF); + return send_dux_commands(dev, SENDPWMOFF); } static void usbduxsub_pwm_irq(struct urb *urb) @@ -1587,7 +1587,7 @@ static int usbdux_pwm_start(struct comedi_device *dev, } this_usbduxsub->dux_commands[1] = ((int8_t) this_usbduxsub->pwn_delay); - ret = send_dux_commands(this_usbduxsub, SENDPWMON); + ret = send_dux_commands(dev, SENDPWMON); if (ret < 0) return ret; -- GitLab From fb90856828064ee5195a2b5b0f9c1fa430a3fbb9 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 14:15:43 -0700 Subject: [PATCH 230/942] staging: comedi: usbdux: tidy up receive_dux_commands() For aesthetic reasons, pass the comedi_device pointer to this function instead of the private data pointer. Rename the local variable used for the private data pointer to the comedi "norm". Add a local variable for the usb_device pointer to tidy up the usb_bulk_msg() call. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 29 ++++++++++++------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index d2a3a1accb855..5980b8e366949 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -860,25 +860,24 @@ static int send_dux_commands(struct comedi_device *dev, int cmd_type) &nsent, BULK_TIMEOUT); } -static int receive_dux_commands(struct usbdux_private *this_usbduxsub, int command) +static int receive_dux_commands(struct comedi_device *dev, int command) { - int result = (-EFAULT); + struct usbdux_private *devpriv = dev->private; + struct usb_device *usb = devpriv->usbdev; + int ret; int nrec; int i; for (i = 0; i < RETRIES; i++) { - result = usb_bulk_msg(this_usbduxsub->usbdev, - usb_rcvbulkpipe(this_usbduxsub->usbdev, - COMMAND_IN_EP), - this_usbduxsub->insn_buffer, SIZEINSNBUF, + ret = usb_bulk_msg(usb, usb_rcvbulkpipe(usb, COMMAND_IN_EP), + devpriv->insn_buffer, SIZEINSNBUF, &nrec, BULK_TIMEOUT); - if (result < 0) - return result; - if (le16_to_cpu(this_usbduxsub->insn_buffer[0]) == command) - return result; + if (ret < 0) + return ret; + if (le16_to_cpu(devpriv->insn_buffer[0]) == command) + return ret; } - /* this is only reached if the data has been requested a couple of - * times */ + /* command not received */ return -EFAULT; } @@ -1037,7 +1036,7 @@ static int usbdux_ai_insn_read(struct comedi_device *dev, } for (i = 0; i < insn->n; i++) { - err = receive_dux_commands(this_usbduxsub, SENDSINGLEAD); + err = receive_dux_commands(dev, SENDSINGLEAD); if (err < 0) { up(&this_usbduxsub->sem); return 0; @@ -1362,7 +1361,7 @@ static int usbdux_dio_insn_bits(struct comedi_device *dev, up(&this_usbduxsub->sem); return err; } - err = receive_dux_commands(this_usbduxsub, SENDDIOBITSCOMMAND); + err = receive_dux_commands(dev, SENDDIOBITSCOMMAND); if (err < 0) { up(&this_usbduxsub->sem); return err; @@ -1392,7 +1391,7 @@ static int usbdux_counter_read(struct comedi_device *dev, return err; } - err = receive_dux_commands(this_usbduxsub, READCOUNTERCOMMAND); + err = receive_dux_commands(dev, READCOUNTERCOMMAND); if (err < 0) { up(&this_usbduxsub->sem); return err; -- GitLab From 11642c658ff0e8bb13e68ac59593427a482e8c9a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 14:16:04 -0700 Subject: [PATCH 231/942] staging: comedi: usbdux: pass comedi_device pointer to usbdux_alloc_usb_buffers() For aesthetic reasons, pass the comedi_device pointer to this function instead of the private data pointer. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 5980b8e366949..c3fbfdc6fc5c4 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -1729,8 +1729,9 @@ static int usbdux_pwm_config(struct comedi_device *dev, /* end of PWM */ /*****************************************************************/ -static int usbdux_alloc_usb_buffers(struct usbdux_private *devpriv) +static int usbdux_alloc_usb_buffers(struct comedi_device *dev) { + struct usbdux_private *devpriv = dev->private; struct urb *urb; int i; @@ -1909,7 +1910,7 @@ static int usbdux_auto_attach(struct comedi_device *dev, devpriv->num_out_buffers = NUMOFOUTBUFFERSFULL; } - ret = usbdux_alloc_usb_buffers(devpriv); + ret = usbdux_alloc_usb_buffers(dev); if (ret) return ret; -- GitLab From 0b20d613afd0e1ba394c2b209a5f459c5f43e1ff Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 14:16:24 -0700 Subject: [PATCH 232/942] staging: comedi: usbdux: remove usb_device back pointer from private data The usb_device can be found when needed using the comedi_to_usb_dev() helper. Use that instead the remove the back pointer from the private data. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 39 ++++++++++++------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index c3fbfdc6fc5c4..88419444497fd 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -202,8 +202,6 @@ static const struct comedi_lrange range_usbdux_ao_range = { }; struct usbdux_private { - /* pointer to the usb-device */ - struct usb_device *usbdev; /* actual number of in-buffers */ int num_in_buffers; /* actual number of out-buffers */ @@ -384,7 +382,7 @@ static void usbduxsub_ai_isoc_irq(struct urb *urb) return; } - urb->dev = devpriv->usbdev; + urb->dev = comedi_to_usb_dev(dev); /* resubmit the urb */ err = usb_submit_urb(urb, GFP_ATOMIC); @@ -587,7 +585,7 @@ static void usbduxsub_ao_isoc_irq(struct urb *urb) } } urb->transfer_buffer_length = SIZEOUTBUF; - urb->dev = devpriv->usbdev; + urb->dev = comedi_to_usb_dev(dev); urb->status = 0; if (devpriv->ao_cmd_running) { if (devpriv->high_speed) @@ -622,8 +620,7 @@ static int usbdux_firmware_upload(struct comedi_device *dev, const u8 *data, size_t size, unsigned long context) { - struct usbdux_private *usbduxsub = dev->private; - struct usb_device *usb = usbduxsub->usbdev; + struct usb_device *usb = comedi_to_usb_dev(dev); uint8_t *buf; uint8_t *tmp; int ret; @@ -693,6 +690,7 @@ static int usbdux_firmware_upload(struct comedi_device *dev, static int usbduxsub_submit_inurbs(struct comedi_device *dev) { + struct usb_device *usb = comedi_to_usb_dev(dev); struct usbdux_private *devpriv = dev->private; struct urb *urb; int ret; @@ -705,7 +703,7 @@ static int usbduxsub_submit_inurbs(struct comedi_device *dev) /* in case of a resubmission after an unlink... */ urb->interval = devpriv->ai_interval; urb->context = dev; - urb->dev = devpriv->usbdev; + urb->dev = usb; urb->status = 0; urb->transfer_flags = URB_ISO_ASAP; @@ -718,6 +716,7 @@ static int usbduxsub_submit_inurbs(struct comedi_device *dev) static int usbduxsub_submit_outurbs(struct comedi_device *dev) { + struct usb_device *usb = comedi_to_usb_dev(dev); struct usbdux_private *devpriv = dev->private; struct urb *urb; int ret; @@ -728,7 +727,7 @@ static int usbduxsub_submit_outurbs(struct comedi_device *dev) /* in case of a resubmission after an unlink... */ urb->context = dev; - urb->dev = devpriv->usbdev; + urb->dev = usb; urb->status = 0; urb->transfer_flags = URB_ISO_ASAP; @@ -849,8 +848,8 @@ static int8_t create_adc_command(unsigned int chan, int range) static int send_dux_commands(struct comedi_device *dev, int cmd_type) { + struct usb_device *usb = comedi_to_usb_dev(dev); struct usbdux_private *devpriv = dev->private; - struct usb_device *usb = devpriv->usbdev; int nsent; devpriv->dux_commands[0] = cmd_type; @@ -862,8 +861,8 @@ static int send_dux_commands(struct comedi_device *dev, int cmd_type) static int receive_dux_commands(struct comedi_device *dev, int command) { + struct usb_device *usb = comedi_to_usb_dev(dev); struct usbdux_private *devpriv = dev->private; - struct usb_device *usb = devpriv->usbdev; int ret; int nrec; int i; @@ -1520,7 +1519,7 @@ static void usbduxsub_pwm_irq(struct urb *urb) return; urb->transfer_buffer_length = devpriv->size_pwm_buf; - urb->dev = devpriv->usbdev; + urb->dev = comedi_to_usb_dev(dev); urb->status = 0; if (devpriv->pwm_cmd_running) { ret = usb_submit_urb(urb, GFP_ATOMIC); @@ -1540,12 +1539,12 @@ static void usbduxsub_pwm_irq(struct urb *urb) static int usbduxsub_submit_pwm_urbs(struct comedi_device *dev) { + struct usb_device *usb = comedi_to_usb_dev(dev); struct usbdux_private *devpriv = dev->private; struct urb *urb = devpriv->urb_pwm; /* in case of a resubmission after an unlink... */ - usb_fill_bulk_urb(urb, devpriv->usbdev, - usb_sndbulkpipe(devpriv->usbdev, PWM_EP), + usb_fill_bulk_urb(urb, usb, usb_sndbulkpipe(usb, PWM_EP), urb->transfer_buffer, devpriv->size_pwm_buf, usbduxsub_pwm_irq, @@ -1731,6 +1730,7 @@ static int usbdux_pwm_config(struct comedi_device *dev, static int usbdux_alloc_usb_buffers(struct comedi_device *dev) { + struct usb_device *usb = comedi_to_usb_dev(dev); struct usbdux_private *devpriv = dev->private; struct urb *urb; int i; @@ -1773,11 +1773,11 @@ static int usbdux_alloc_usb_buffers(struct comedi_device *dev) return -ENOMEM; devpriv->urb_in[i] = urb; - urb->dev = devpriv->usbdev; + urb->dev = usb; /* will be filled later with a pointer to the comedi-device */ /* and ONLY then the urb should be submitted */ urb->context = NULL; - urb->pipe = usb_rcvisocpipe(devpriv->usbdev, ISOINEP); + urb->pipe = usb_rcvisocpipe(usb, ISOINEP); urb->transfer_flags = URB_ISO_ASAP; urb->transfer_buffer = kzalloc(SIZEINBUF, GFP_KERNEL); if (!urb->transfer_buffer) @@ -1803,11 +1803,11 @@ static int usbdux_alloc_usb_buffers(struct comedi_device *dev) return -ENOMEM; devpriv->urb_out[i] = urb; - urb->dev = devpriv->usbdev; + urb->dev = usb; /* will be filled later with a pointer to the comedi-device */ /* and ONLY then the urb should be submitted */ urb->context = NULL; - urb->pipe = usb_sndisocpipe(devpriv->usbdev, ISOOUTEP); + urb->pipe = usb_sndisocpipe(usb, ISOOUTEP); urb->transfer_flags = URB_ISO_ASAP; urb->transfer_buffer = kzalloc(SIZEOUTBUF, GFP_KERNEL); if (!urb->transfer_buffer) @@ -1896,11 +1896,10 @@ static int usbdux_auto_attach(struct comedi_device *dev, sema_init(&devpriv->sem, 1); - devpriv->usbdev = usb; devpriv->ifnum = intf->altsetting->desc.bInterfaceNumber; usb_set_intfdata(intf, devpriv); - devpriv->high_speed = (devpriv->usbdev->speed == USB_SPEED_HIGH); + devpriv->high_speed = (usb->speed == USB_SPEED_HIGH); if (devpriv->high_speed) { devpriv->num_in_buffers = NUMOFINBUFFERSHIGH; devpriv->num_out_buffers = NUMOFOUTBUFFERSHIGH; @@ -1915,7 +1914,7 @@ static int usbdux_auto_attach(struct comedi_device *dev, return ret; /* setting to alternate setting 3: enabling iso ep and bulk ep. */ - ret = usb_set_interface(devpriv->usbdev, devpriv->ifnum, 3); + ret = usb_set_interface(usb, devpriv->ifnum, 3); if (ret < 0) { dev_err(dev->class_dev, "could not set alternate setting 3 in high speed\n"); -- GitLab From 903f4fde801343eb95e3f30cab24c50c9fe367c6 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 14:16:44 -0700 Subject: [PATCH 233/942] staging: comedi: usbdux: remove 'ifnum' from the private data The 'ifnum' is only used during the attach of the device. Remove it from the private data. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 88419444497fd..c0c4a27116644 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -223,8 +223,6 @@ struct usbdux_private { int16_t *insn_buffer; /* output buffer for single DA outputs */ int16_t *out_buffer; - /* interface number */ - int ifnum; /* is it USB_SPEED_HIGH or not? */ short int high_speed; /* asynchronous command is running */ @@ -1896,7 +1894,6 @@ static int usbdux_auto_attach(struct comedi_device *dev, sema_init(&devpriv->sem, 1); - devpriv->ifnum = intf->altsetting->desc.bInterfaceNumber; usb_set_intfdata(intf, devpriv); devpriv->high_speed = (usb->speed == USB_SPEED_HIGH); @@ -1914,7 +1911,8 @@ static int usbdux_auto_attach(struct comedi_device *dev, return ret; /* setting to alternate setting 3: enabling iso ep and bulk ep. */ - ret = usb_set_interface(usb, devpriv->ifnum, 3); + ret = usb_set_interface(usb, intf->altsetting->desc.bInterfaceNumber, + 3); if (ret < 0) { dev_err(dev->class_dev, "could not set alternate setting 3 in high speed\n"); -- GitLab From b8c162c961c47f0fa991cc8f4b2acd32e55ae589 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 14:17:05 -0700 Subject: [PATCH 234/942] staging: comedi: usbdux: make private data flags bit-fields Change the flags in the private data to bit-fields to save a bit of space. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index c0c4a27116644..0434674121e86 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -223,16 +223,14 @@ struct usbdux_private { int16_t *insn_buffer; /* output buffer for single DA outputs */ int16_t *out_buffer; - /* is it USB_SPEED_HIGH or not? */ - short int high_speed; - /* asynchronous command is running */ - short int ai_cmd_running; - short int ao_cmd_running; - /* pwm is running */ - short int pwm_cmd_running; - /* continous acquisition */ - short int ai_continous; - short int ao_continous; + + unsigned int high_speed:1; + unsigned int ai_cmd_running:1; + unsigned int ai_continous:1; + unsigned int ao_cmd_running:1; + unsigned int ao_continous:1; + unsigned int pwm_cmd_running:1; + /* number of samples to acquire */ int ai_sample_count; int ao_sample_count; -- GitLab From b3476e67c1afa634437a429673b75e735dcfbd6a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 14:17:23 -0700 Subject: [PATCH 235/942] staging: comedi: usbdux: tidy up usbdux_ai_stop() For aesthetic reasons, pass the comedi_device pointer to this function instead of the private data pointer. Rename the local variable used for the private data pointer to the comedi "norm". Remove the unnecessary sanity check of the private data pointer. This function can only be called is the private data was allocated during the attach. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 31 +++++++++---------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 0434674121e86..c195ec6f8fb52 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -270,24 +270,15 @@ static int usbduxsub_unlink_inurbs(struct usbdux_private *usbduxsub_tmp) return err; } -/* - * This will stop a running acquisition operation - * Is called from within this driver from both the - * interrupt context and from comedi - */ -static int usbdux_ai_stop(struct usbdux_private *this_usbduxsub, int do_unlink) +static int usbdux_ai_stop(struct comedi_device *dev, int do_unlink) { + struct usbdux_private *devpriv = dev->private; int ret = 0; - if (!this_usbduxsub) - return -EFAULT; - - if (do_unlink) { - /* stop aquistion */ - ret = usbduxsub_unlink_inurbs(this_usbduxsub); - } + if (do_unlink) + ret = usbduxsub_unlink_inurbs(devpriv); - this_usbduxsub->ai_cmd_running = 0; + devpriv->ai_cmd_running = 0; return ret; } @@ -310,7 +301,7 @@ static int usbdux_ai_cancel(struct comedi_device *dev, /* prevent other CPUs from submitting new commands just now */ down(&this_usbduxsub->sem); /* unlink only if the urb really has been submitted */ - res = usbdux_ai_stop(this_usbduxsub, this_usbduxsub->ai_cmd_running); + res = usbdux_ai_stop(dev, this_usbduxsub->ai_cmd_running); up(&this_usbduxsub->sem); return res; } @@ -346,7 +337,7 @@ static void usbduxsub_ai_isoc_irq(struct urb *urb) s->async->events |= COMEDI_CB_ERROR; comedi_event(dev, s); /* stop the transfer w/o unlink */ - usbdux_ai_stop(devpriv, 0); + usbdux_ai_stop(dev, 0); } return; @@ -361,7 +352,7 @@ static void usbduxsub_ai_isoc_irq(struct urb *urb) s->async->events |= COMEDI_CB_ERROR; comedi_event(dev, s); /* don't do an unlink here */ - usbdux_ai_stop(devpriv, 0); + usbdux_ai_stop(dev, 0); } return; } @@ -392,7 +383,7 @@ static void usbduxsub_ai_isoc_irq(struct urb *urb) s->async->events |= COMEDI_CB_ERROR; comedi_event(dev, s); /* don't do an unlink here */ - usbdux_ai_stop(devpriv, 0); + usbdux_ai_stop(dev, 0); return; } @@ -410,7 +401,7 @@ static void usbduxsub_ai_isoc_irq(struct urb *urb) /* all samples received? */ if (devpriv->ai_sample_count < 0) { /* prevent a resubmit next time */ - usbdux_ai_stop(devpriv, 0); + usbdux_ai_stop(dev, 0); /* say comedi that the acquistion is over */ s->async->events |= COMEDI_CB_EOA; comedi_event(dev, s); @@ -430,7 +421,7 @@ static void usbduxsub_ai_isoc_irq(struct urb *urb) } if (unlikely(err == 0)) { /* buffer overflow */ - usbdux_ai_stop(devpriv, 0); + usbdux_ai_stop(dev, 0); return; } } -- GitLab From aa6081e5e0989f4df9ca35fa412e3ba8c23e38df Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 14:17:50 -0700 Subject: [PATCH 236/942] staging: comedi: usbdux: tidy up usbdux_ai_cancel() Rename the local variable used for the private data pointer to the comedi "norm". Remove the unnecessary sanity check of the private data pointer. This function can only be called is the private data was allocated during the attach. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index c195ec6f8fb52..edee14851d708 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -283,27 +283,19 @@ static int usbdux_ai_stop(struct comedi_device *dev, int do_unlink) return ret; } -/* - * This will cancel a running acquisition operation. - * This is called by comedi but never from inside the driver. - */ static int usbdux_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { - struct usbdux_private *this_usbduxsub; - int res = 0; - - /* force unlink of all urbs */ - this_usbduxsub = dev->private; - if (!this_usbduxsub) - return -EFAULT; + struct usbdux_private *devpriv = dev->private; + int ret = 0; /* prevent other CPUs from submitting new commands just now */ - down(&this_usbduxsub->sem); + down(&devpriv->sem); /* unlink only if the urb really has been submitted */ - res = usbdux_ai_stop(dev, this_usbduxsub->ai_cmd_running); - up(&this_usbduxsub->sem); - return res; + ret = usbdux_ai_stop(dev, devpriv->ai_cmd_running); + up(&devpriv->sem); + + return ret; } /* analogue IN - interrupt service routine */ -- GitLab From 7c8ed94eb8c0bae49f900085d5221529cf20378c Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 14:18:15 -0700 Subject: [PATCH 237/942] staging: comedi: usbdux: tidy up usbdux_ao_stop() For aesthetic reasons, pass the comedi_device pointer to this function instead of the private data pointer. Rename the local variable used for the private data pointer to the comedi "norm". Remove the unnecessary sanity check of the private data pointer. This function can only be called is the private data was allocated during the attach. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index edee14851d708..1f6750950a5d7 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -436,20 +436,15 @@ static int usbduxsub_unlink_outurbs(struct usbdux_private *usbduxsub_tmp) return err; } -/* This will cancel a running acquisition operation - * in any context. - */ -static int usbdux_ao_stop(struct usbdux_private *this_usbduxsub, int do_unlink) +static int usbdux_ao_stop(struct comedi_device *dev, int do_unlink) { + struct usbdux_private *devpriv = dev->private; int ret = 0; - if (!this_usbduxsub) - return -EFAULT; - if (do_unlink) - ret = usbduxsub_unlink_outurbs(this_usbduxsub); + ret = usbduxsub_unlink_outurbs(devpriv); - this_usbduxsub->ao_cmd_running = 0; + devpriv->ao_cmd_running = 0; return ret; } @@ -467,7 +462,7 @@ static int usbdux_ao_cancel(struct comedi_device *dev, /* prevent other CPUs from submitting a command just now */ down(&this_usbduxsub->sem); /* unlink only if it is really running */ - res = usbdux_ao_stop(this_usbduxsub, this_usbduxsub->ao_cmd_running); + res = usbdux_ao_stop(dev, this_usbduxsub->ao_cmd_running); up(&this_usbduxsub->sem); return res; } @@ -494,7 +489,7 @@ static void usbduxsub_ao_isoc_irq(struct urb *urb) if (devpriv->ao_cmd_running) { s->async->events |= COMEDI_CB_EOA; comedi_event(dev, s); - usbdux_ao_stop(devpriv, 0); + usbdux_ao_stop(dev, 0); } return; @@ -508,7 +503,7 @@ static void usbduxsub_ao_isoc_irq(struct urb *urb) s->async->events |= COMEDI_CB_EOA; comedi_event(dev, s); /* we do an unlink if we are in the high speed mode */ - usbdux_ao_stop(devpriv, 0); + usbdux_ao_stop(dev, 0); } return; } @@ -529,7 +524,7 @@ static void usbduxsub_ao_isoc_irq(struct urb *urb) devpriv->ao_sample_count--; if (devpriv->ao_sample_count < 0) { /* all samples transmitted */ - usbdux_ao_stop(devpriv, 0); + usbdux_ao_stop(dev, 0); s->async->events |= COMEDI_CB_EOA; comedi_event(dev, s); /* no resubmit of the urb */ @@ -588,7 +583,7 @@ static void usbduxsub_ao_isoc_irq(struct urb *urb) s->async->events |= COMEDI_CB_ERROR; comedi_event(dev, s); /* don't do an unlink here */ - usbdux_ao_stop(devpriv, 0); + usbdux_ao_stop(dev, 0); } } } -- GitLab From eee7d9e9ef711abda2482af2d6b15d76e34b8db5 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 14:18:36 -0700 Subject: [PATCH 238/942] staging: comedi: usbdux: tidy up usbdux_ao_cancel() Rename the local variable used for the private data pointer to the comedi "norm". Remove the unnecessary sanity check of the private data pointer. This function can only be called is the private data was allocated during the attach. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 1f6750950a5d7..d0d683bc83c24 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -449,22 +449,19 @@ static int usbdux_ao_stop(struct comedi_device *dev, int do_unlink) return ret; } -/* force unlink, is called by comedi */ static int usbdux_ao_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { - struct usbdux_private *this_usbduxsub = dev->private; - int res = 0; - - if (!this_usbduxsub) - return -EFAULT; + struct usbdux_private *devpriv = dev->private; + int ret = 0; /* prevent other CPUs from submitting a command just now */ - down(&this_usbduxsub->sem); + down(&devpriv->sem); /* unlink only if it is really running */ - res = usbdux_ao_stop(dev, this_usbduxsub->ao_cmd_running); - up(&this_usbduxsub->sem); - return res; + ret = usbdux_ao_stop(dev, devpriv->ao_cmd_running); + up(&devpriv->sem); + + return ret; } static void usbduxsub_ao_isoc_irq(struct urb *urb) -- GitLab From 065b09127057fa728c9290d62c2a2e1c4925132b Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 10:00:45 -0700 Subject: [PATCH 239/942] staging: comedi: range: tidy up comedi_check_chanlist() The only difference in the if() and else if() check of the chanlist is the source of the range table length. Consolidate the checks to make the function a bit more concise. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/range.c | 43 ++++++++++++++++------------------ 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/drivers/staging/comedi/range.c b/drivers/staging/comedi/range.c index 1f20332cc4592..8fde55495d34b 100644 --- a/drivers/staging/comedi/range.c +++ b/drivers/staging/comedi/range.c @@ -127,38 +127,35 @@ static int aref_invalid(struct comedi_subdevice *s, unsigned int chanspec) return 1; } -/* - This function checks each element in a channel/gain list to make - make sure it is valid. +/** + * comedi_check_chanlist() - Validate each element in a chanlist. + * @s: comedi_subdevice struct + * @n: number of elements in the chanlist + * @chanlist: the chanlist to validate */ int comedi_check_chanlist(struct comedi_subdevice *s, int n, unsigned int *chanlist) { struct comedi_device *dev = s->device; - int i; - int chan; + unsigned int chanspec; + int chan, range_len, i; - if (s->range_table) { - for (i = 0; i < n; i++) - if (CR_CHAN(chanlist[i]) >= s->n_chan || - CR_RANGE(chanlist[i]) >= s->range_table->length - || aref_invalid(s, chanlist[i])) { - dev_warn(dev->class_dev, - "bad chanlist[%d]=0x%08x in_chan=%d range length=%d\n", - i, chanlist[i], s->n_chan, - s->range_table->length); - return -EINVAL; - } - } else if (s->range_table_list) { + if (s->range_table || s->range_table_list) { for (i = 0; i < n; i++) { - chan = CR_CHAN(chanlist[i]); + chanspec = chanlist[i]; + chan = CR_CHAN(chanspec); + if (s->range_table) + range_len = s->range_table->length; + else if (s->range_table_list && chan < s->n_chan) + range_len = s->range_table_list[chan]->length; + else + range_len = 0; if (chan >= s->n_chan || - CR_RANGE(chanlist[i]) >= - s->range_table_list[chan]->length - || aref_invalid(s, chanlist[i])) { + CR_RANGE(chanspec) >= range_len || + aref_invalid(s, chanspec)) { dev_warn(dev->class_dev, - "bad chanlist[%d]=0x%08x\n", - i, chanlist[i]); + "bad chanlist[%d]=0x%08x chan=%d range length=%d\n", + i, chanspec, chan, range_len); return -EINVAL; } } -- GitLab From a2ec3dd32508857c09aea044510e28d5411533a9 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 10:03:50 -0700 Subject: [PATCH 240/942] staging: comedi: adv_pci1724: remove ao_range_list_1724 All the AO channels have the same ranges. Remove the subdevice s->range_table_list and just use the s->range_table to setup the ranges. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adv_pci1724.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/adv_pci1724.c b/drivers/staging/comedi/drivers/adv_pci1724.c index 84907c79ca2b3..009a3039fc4fe 100644 --- a/drivers/staging/comedi/drivers/adv_pci1724.c +++ b/drivers/staging/comedi/drivers/adv_pci1724.c @@ -125,10 +125,6 @@ static const struct comedi_lrange ao_ranges_1724 = { 4, } }; -static const struct comedi_lrange *const ao_range_list_1724[NUM_AO_CHANNELS] = { - [0 ... NUM_AO_CHANNELS - 1] = &ao_ranges_1724, -}; - /* this structure is for data unique to this hardware driver. */ struct adv_pci1724_private { int ao_value[NUM_AO_CHANNELS]; @@ -308,7 +304,7 @@ static int setup_subdevices(struct comedi_device *dev) s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_GROUND; s->n_chan = NUM_AO_CHANNELS; s->maxdata = 0x3fff; - s->range_table_list = ao_range_list_1724; + s->range_table = &ao_ranges_1724; s->insn_read = ao_readback_insn; s->insn_write = ao_winsn; -- GitLab From 32d6d4e00b32c056fce8adf9d36a61f3c4d8fc87 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 11:11:51 -0700 Subject: [PATCH 241/942] staging: comedi: addi_apci_1710: fix some compile errors/warnings Fix a couple comments within comments errors. Remove the #include of eddi_eeprom.c. This driver does not use it. Remove an unused local variable. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi-data/APCI1710_82x54.c | 2 +- drivers/staging/comedi/drivers/addi-data/APCI1710_Dig_io.c | 2 +- drivers/staging/comedi/drivers/addi-data/APCI1710_Ttl.c | 2 +- drivers/staging/comedi/drivers/addi_apci_1710.c | 2 -- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_82x54.c b/drivers/staging/comedi/drivers/addi-data/APCI1710_82x54.c index d0702084caa28..a979abfc91218 100644 --- a/drivers/staging/comedi/drivers/addi-data/APCI1710_82x54.c +++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_82x54.c @@ -444,7 +444,7 @@ int i_APCI1710_InsnWriteEnableDisableTimer(struct comedi_device *dev,struct come i_ReturnValue=insn->n; b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec); b_TimerNbr = (unsigned char) CR_CHAN(insn->chanspec); - b_ActionType = (unsigned char) data[0]; /* enable disable */ + b_ActionType = (unsigned char) data[0]; enable disable +----------------------------------------------------------------------------+ | Output Parameters : - | +----------------------------------------------------------------------------+ diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Dig_io.c b/drivers/staging/comedi/drivers/addi-data/APCI1710_Dig_io.c index 27de18e798956..7d1883a0da286 100644 --- a/drivers/staging/comedi/drivers/addi-data/APCI1710_Dig_io.c +++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_Dig_io.c @@ -653,7 +653,7 @@ static int i_APCI1710_InsnWriteDigitalIOChlOnOff(struct comedi_device *dev, * s_BoardInfos. ui_Address + (64 * b_ModulNbr), * dw_WriteValue); */ -*/ + outl(dw_WriteValue, devpriv->s_BoardInfos. ui_Address + (64 * b_ModulNbr)); diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Ttl.c b/drivers/staging/comedi/drivers/addi-data/APCI1710_Ttl.c index fb56360444ee7..c01497a8a457c 100644 --- a/drivers/staging/comedi/drivers/addi-data/APCI1710_Ttl.c +++ b/drivers/staging/comedi/drivers/addi-data/APCI1710_Ttl.c @@ -814,7 +814,7 @@ int i_APCI1710_InsnWriteSetTTLIOChlOnOff(struct comedi_device *dev,struct comedi b_ModulNbr = CR_AREF(insn->chanspec); b_OutputChannel= CR_CHAN(insn->chanspec); - ui_State = data[0]; /* ON or OFF */ + ui_State = data[0]; ON or OFF +----------------------------------------------------------------------------+ | Output Parameters : - | +----------------------------------------------------------------------------+ diff --git a/drivers/staging/comedi/drivers/addi_apci_1710.c b/drivers/staging/comedi/drivers/addi_apci_1710.c index e600c05c2ecca..3035b2aa20cb9 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1710.c +++ b/drivers/staging/comedi/drivers/addi_apci_1710.c @@ -19,7 +19,6 @@ static void fpu_end(void) kernel_fpu_end(); } -#include "addi-data/addi_eeprom.c" #include "addi-data/hwdrv_APCI1710.c" static irqreturn_t v_ADDI_Interrupt(int irq, void *d) @@ -33,7 +32,6 @@ static int apci1710_auto_attach(struct comedi_device *dev, { struct pci_dev *pcidev = comedi_to_pci_dev(dev); struct addi_private *devpriv; - struct comedi_subdevice *s; int ret; devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); -- GitLab From c1f00be048c10763c7fad230bc6141b3538ef2d6 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 11:12:35 -0700 Subject: [PATCH 242/942] staging: comedi: addi_apci_1710: separate from addi_common.h Move the necessary bits from addi_common.h to remove it's dependency and make this driver standalone. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/addi_apci_1710.c | 142 +++++++++++++++++- 1 file changed, 141 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_1710.c b/drivers/staging/comedi/drivers/addi_apci_1710.c index 3035b2aa20cb9..9157ac50815ed 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1710.c +++ b/drivers/staging/comedi/drivers/addi_apci_1710.c @@ -1,5 +1,6 @@ #include #include +#include #include @@ -7,7 +8,146 @@ #include "comedi_fc.h" #include "amcc_s5933.h" -#include "addi-data/addi_common.h" +#define APCI1710_SAVE_INTERRUPT 1 + +union str_ModuleInfo { + /* Incremental counter infos */ + struct { + union { + struct { + unsigned char b_ModeRegister1; + unsigned char b_ModeRegister2; + unsigned char b_ModeRegister3; + unsigned char b_ModeRegister4; + } s_ByteModeRegister; + unsigned int dw_ModeRegister1_2_3_4; + } s_ModeRegister; + + struct { + unsigned int b_IndexInit:1; + unsigned int b_CounterInit:1; + unsigned int b_ReferenceInit:1; + unsigned int b_IndexInterruptOccur:1; + unsigned int b_CompareLogicInit:1; + unsigned int b_FrequencyMeasurementInit:1; + unsigned int b_FrequencyMeasurementEnable:1; + } s_InitFlag; + + } s_SiemensCounterInfo; + + /* SSI infos */ + struct { + unsigned char b_SSIProfile; + unsigned char b_PositionTurnLength; + unsigned char b_TurnCptLength; + unsigned char b_SSIInit; + } s_SSICounterInfo; + + /* TTL I/O infos */ + struct { + unsigned char b_TTLInit; + unsigned char b_PortConfiguration[4]; + } s_TTLIOInfo; + + /* Digital I/O infos */ + struct { + unsigned char b_DigitalInit; + unsigned char b_ChannelAMode; + unsigned char b_ChannelBMode; + unsigned char b_OutputMemoryEnabled; + unsigned int dw_OutputMemory; + } s_DigitalIOInfo; + + /* 82X54 timer infos */ + struct { + struct { + unsigned char b_82X54Init; + unsigned char b_InputClockSelection; + unsigned char b_InputClockLevel; + unsigned char b_OutputLevel; + unsigned char b_HardwareGateLevel; + unsigned int dw_ConfigurationWord; + } s_82X54TimerInfo[3]; + unsigned char b_InterruptMask; + } s_82X54ModuleInfo; + + /* Chronometer infos */ + struct { + unsigned char b_ChronoInit; + unsigned char b_InterruptMask; + unsigned char b_PCIInputClock; + unsigned char b_TimingUnit; + unsigned char b_CycleMode; + double d_TimingInterval; + unsigned int dw_ConfigReg; + } s_ChronoModuleInfo; + + /* Pulse encoder infos */ + struct { + struct { + unsigned char b_PulseEncoderInit; + } s_PulseEncoderInfo[4]; + unsigned int dw_SetRegister; + unsigned int dw_ControlRegister; + unsigned int dw_StatusRegister; + } s_PulseEncoderModuleInfo; + + /* Tor conter infos */ + struct { + struct { + unsigned char b_TorCounterInit; + unsigned char b_TimingUnit; + unsigned char b_InterruptEnable; + double d_TimingInterval; + unsigned int ul_RealTimingInterval; + } s_TorCounterInfo[2]; + unsigned char b_PCIInputClock; + } s_TorCounterModuleInfo; + + /* PWM infos */ + struct { + struct { + unsigned char b_PWMInit; + unsigned char b_TimingUnit; + unsigned char b_InterruptEnable; + double d_LowTiming; + double d_HighTiming; + unsigned int ul_RealLowTiming; + unsigned int ul_RealHighTiming; + } s_PWMInfo[2]; + unsigned char b_ClockSelection; + } s_PWMModuleInfo; + + /* CDA infos */ + struct { + unsigned char b_CDAEnable; + unsigned char b_FctSelection; + } s_CDAModuleInfo; +}; + +struct addi_private { + /* Pointer to the current process */ + struct task_struct *tsk_Current; + + struct { + unsigned int ui_Address; + unsigned char b_BoardVersion; + unsigned int dw_MolduleConfiguration[4]; + } s_BoardInfos; + + struct { + unsigned int ul_InterruptOccur; + unsigned int ui_Read; + unsigned int ui_Write; + struct { + unsigned char b_OldModuleMask; + unsigned int ul_OldInterruptMask; + unsigned int ul_OldCounterLatchValue; + } s_FIFOInterruptParameters[APCI1710_SAVE_INTERRUPT]; + } s_InterruptParameters; + + union str_ModuleInfo s_ModuleInfo[4]; +}; static void fpu_begin(void) { -- GitLab From 3b4cb6717d816be3ee838920b1477d0e73101a09 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 11:13:53 -0700 Subject: [PATCH 243/942] staging: comedi: addi_apci_1710: delete driver This driver is seriously broken and most of it does not "work" with the comedi API. Just remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/APCI1710_82x54.c | 1068 ---- .../drivers/addi-data/APCI1710_Chrono.c | 2050 ------- .../drivers/addi-data/APCI1710_Dig_io.c | 1037 ---- .../drivers/addi-data/APCI1710_INCCPT.c | 5461 ----------------- .../drivers/addi-data/APCI1710_Inp_cpt.c | 866 --- .../comedi/drivers/addi-data/APCI1710_Pwm.c | 3582 ----------- .../comedi/drivers/addi-data/APCI1710_Ssi.c | 845 --- .../comedi/drivers/addi-data/APCI1710_Tor.c | 2065 ------- .../comedi/drivers/addi-data/APCI1710_Ttl.c | 1044 ---- .../comedi/drivers/addi-data/hwdrv_APCI1710.c | 1314 ---- .../staging/comedi/drivers/addi_apci_1710.c | 237 - 11 files changed, 19569 deletions(-) delete mode 100644 drivers/staging/comedi/drivers/addi-data/APCI1710_82x54.c delete mode 100644 drivers/staging/comedi/drivers/addi-data/APCI1710_Chrono.c delete mode 100644 drivers/staging/comedi/drivers/addi-data/APCI1710_Dig_io.c delete mode 100644 drivers/staging/comedi/drivers/addi-data/APCI1710_INCCPT.c delete mode 100644 drivers/staging/comedi/drivers/addi-data/APCI1710_Inp_cpt.c delete mode 100644 drivers/staging/comedi/drivers/addi-data/APCI1710_Pwm.c delete mode 100644 drivers/staging/comedi/drivers/addi-data/APCI1710_Ssi.c delete mode 100644 drivers/staging/comedi/drivers/addi-data/APCI1710_Tor.c delete mode 100644 drivers/staging/comedi/drivers/addi-data/APCI1710_Ttl.c delete mode 100644 drivers/staging/comedi/drivers/addi-data/hwdrv_APCI1710.c delete mode 100644 drivers/staging/comedi/drivers/addi_apci_1710.c diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_82x54.c b/drivers/staging/comedi/drivers/addi-data/APCI1710_82x54.c deleted file mode 100644 index a979abfc91218..0000000000000 --- a/drivers/staging/comedi/drivers/addi-data/APCI1710_82x54.c +++ /dev/null @@ -1,1068 +0,0 @@ -/* - * Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. - * - * ADDI-DATA GmbH - * Dieselstrasse 3 - * D-77833 Ottersweier - * Tel: +19(0)7223/9493-0 - * Fax: +49(0)7223/9493-92 - * http://www.addi-data.com - * info@addi-data.com - * - * 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 the License, or (at your option) - * any later version. - */ -/* - | Description : APCI-1710 82X54 timer module | -*/ - -#define APCI1710_PCI_BUS_CLOCK 0 -#define APCI1710_FRONT_CONNECTOR_INPUT 1 -#define APCI1710_TIMER_READVALUE 0 -#define APCI1710_TIMER_GETOUTPUTLEVEL 1 -#define APCI1710_TIMER_GETPROGRESSSTATUS 2 -#define APCI1710_TIMER_WRITEVALUE 3 - -#define APCI1710_TIMER_READINTERRUPT 1 -#define APCI1710_TIMER_READALLTIMER 2 - -#ifndef APCI1710_10MHZ -#define APCI1710_10MHZ 10 -#endif - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_InitTimer | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char_ b_TimerNbr, | -| unsigned char_ b_TimerMode, | -| ULONG_ ul_ReloadValue, | -| unsigned char_ b_InputClockSelection, | -| unsigned char_ b_InputClockLevel, | -| unsigned char_ b_OutputLevel, | -| unsigned char_ b_HardwareGateLevel) -int i_InsnConfig_InitTimer(struct comedi_device *dev,struct comedi_subdevice *s, - struct comedi_insn *insn,unsigned int *data) -| -+----------------------------------------------------------------------------+ -| Task : Configure the Timer (b_TimerNbr) operating mode | -| (b_TimerMode) from selected module (b_ModulNbr). | -| You must calling this function be for you call any | -| other function witch access of the timer. | -| | -| | -| Timer mode description table | -| | -|+--------+-----------------------------+--------------+--------------------+| -||Selected+ Mode description +u_ReloadValue | Hardware gate input|| -|| mode | | description | action || -|+--------+-----------------------------+--------------+--------------------+| -|| |Mode 0 is typically used | | || -|| |for event counting. After | | || -|| |the initialisation, OUT | | || -|| |is initially low, and | | || -|| 0 |will remain low until the |Start counting| Hardware gate || -|| |counter reaches zero. | value | || -|| |OUT then goes high and | | || -|| |remains high until a new | | || -|| |count is written. See | | || -|| |"i_APCI1710_WriteTimerValue" | | || -|| |function. | | || -|+--------+-----------------------------+--------------+--------------------+| -|| |Mode 1 is similar to mode 0 | | || -|| |except for the gate input | | || -|| 1 |action. The gate input is not|Start counting| Hardware trigger || -|| |used for enabled or disabled | value | || -|| |the timer. | | || -|| |The gate input is used for | | || -|| |triggered the timer. | | || -|+--------+-----------------------------+--------------+--------------------+| -|| |This mode functions like a | | || -|| |divide-by-ul_ReloadValue | | || -|| |counter. It is typically used| | || -|| |to generate a real time clock| | || -|| |interrupt. OUT will initially| | || -|| 2 |be high after the | Division | Hardware gate || -|| |initialisation. When the | factor | || -|| |initial count has decremented| | || -|| |to 1, OUT goes low for one | | || -|| |CLK pule. OUT then goes high | | || -|| |again, the counter reloads | | || -|| |the initial count | | || -|| |(ul_ReloadValue) and the | | || -|| |process is repeated. | | || -|| |This action can generated a | | || -|| |interrupt. See function | | || -|| |"i_APCI1710_SetBoardInt- | | || -|| |RoutineX" | | || -|| |and "i_APCI1710_EnableTimer" | | || -|+--------+-----------------------------+--------------+--------------------+| -|| |Mode 3 is typically used for | | || -|| |baud rate generation. This | | || -|| |mode is similar to mode 2 | | || -|| |except for the duty cycle of | | || -|| 3 |OUT. OUT will initially be | Division | Hardware gate || -|| |high after the initialisation| factor | || -|| |When half the initial count | | || -|| |(ul_ReloadValue) has expired,| | || -|| |OUT goes low for the | | || -|| |remainder of the count. The | | || -|| |mode is periodic; the | | || -|| |sequence above is repeated | | || -|| |indefinitely. | | || -|+--------+-----------------------------+--------------+--------------------+| -|| |OUT will be initially high | | || -|| |after the initialisation. | | || -|| |When the initial count | | || -|| 4 |expires OUT will go low for |Start counting| Hardware gate || -|| |one CLK pulse and then go | value | || -|| |high again. | | || -|| |The counting sequences is | | || -|| |triggered by writing a new | | || -|| |value. See | | || -|| |"i_APCI1710_WriteTimerValue" | | || -|| |function. If a new count is | | || -|| |written during counting, | | || -|| |it will be loaded on the | | || -|| |next CLK pulse | | || -|+--------+-----------------------------+--------------+--------------------+| -|| |Mode 5 is similar to mode 4 | | || -|| |except for the gate input | | || -|| |action. The gate input is not| | || -|| 5 |used for enabled or disabled |Start counting| Hardware trigger || -|| |the timer. The gate input is | value | || -|| |used for triggered the timer.| | || -|+--------+-----------------------------+--------------+--------------------+| -| | -| | -| | -| Input clock selection table | -| | -| +--------------------------------+------------------------------------+ | -| | b_InputClockSelection | Description | | -| | parameter | | | -| +--------------------------------+------------------------------------+ | -| | APCI1710_PCI_BUS_CLOCK | For the timer input clock, the PCI | | -| | | bus clock / 4 is used. This PCI bus| | -| | | clock can be 30MHz or 33MHz. For | | -| | | Timer 0 only this selection are | | -| | | available. | | -| +--------------------------------+------------------------------------+ | -| | APCI1710_ FRONT_CONNECTOR_INPUT| Of the front connector you have the| | -| | | possibility to inject a input clock| | -| | | for Timer 1 or Timer 2. The source | | -| | | from this clock can eat the output | | -| | | clock from Timer 0 or any other | | -| | | clock source. | | -| +--------------------------------+------------------------------------+ | -| | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board | -| APCI-1710 | -| unsigned char_ b_ModulNbr : Module number to | -| configure (0 to 3) | -| unsigned char_ b_TimerNbr : Timer number to | -| configure (0 to 2) | -| unsigned char_ b_TimerMode : Timer mode selection | -| (0 to 5) | -| 0: Interrupt on terminal| -| count | -| 1: Hardware | -| retriggerable one- | -| shot | -| 2: Rate generator | -| 3: Square wave mode | -| 4: Software triggered | -| strobe | -| 5: Hardware triggered | -| strobe | -| See timer mode | -| description table. | -| ULONG_ ul_ReloadValue : Start counting value | -| or division factor | -| See timer mode | -| description table. | -| unsigned char_ b_InputClockSelection : Selection from input | -| timer clock. | -| See input clock | -| selection table. | -| unsigned char_ b_InputClockLevel : Selection from input | -| clock level. | -| 0 : Low active | -| (Input inverted) | -| 1 : High active | -| unsigned char_ b_OutputLevel, : Selection from output | -| clock level. | -| 0 : Low active | -| 1 : High active | -| (Output inverted) | -| unsigned char_ b_HardwareGateLevel : Selection from | -| hardware gate level. | -| 0 : Low active | -| (Input inverted) | -| 1 : High active | -| If you will not used | -| the hardware gate set | -| this value to 0. -|b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec); - b_TimerNbr = (unsigned char) CR_CHAN(insn->chanspec); - b_TimerMode = (unsigned char) data[0]; - ul_ReloadValue = (unsigned int) data[1]; - b_InputClockSelection =(unsigned char) data[2]; - b_InputClockLevel =(unsigned char) data[3]; - b_OutputLevel =(unsigned char) data[4]; - b_HardwareGateLevel =(unsigned char) data[5]; -+----------------------------------------------------------------------------+ -| Output Parameters : - | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: Module selection wrong | -| -3: Timer selection wrong | -| -4: The module is not a TIMER module | -| -5: Timer mode selection is wrong | -| -6: Input timer clock selection is wrong | -| -7: Selection from input clock level is wrong | -| -8: Selection from output clock level is wrong | -| -9: Selection from hardware gate level is wrong | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_InsnConfigInitTimer(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - unsigned char b_ModulNbr; - unsigned char b_TimerNbr; - unsigned char b_TimerMode; - unsigned int ul_ReloadValue; - unsigned char b_InputClockSelection; - unsigned char b_InputClockLevel; - unsigned char b_OutputLevel; - unsigned char b_HardwareGateLevel; - - /* BEGIN JK 27.10.2003 : Add the possibility to use a 40 Mhz quartz */ - unsigned int dw_Test = 0; - /* END JK 27.10.2003 : Add the possibility to use a 40 Mhz quartz */ - - i_ReturnValue = insn->n; - b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec); - b_TimerNbr = (unsigned char) CR_CHAN(insn->chanspec); - b_TimerMode = (unsigned char) data[0]; - ul_ReloadValue = (unsigned int) data[1]; - b_InputClockSelection = (unsigned char) data[2]; - b_InputClockLevel = (unsigned char) data[3]; - b_OutputLevel = (unsigned char) data[4]; - b_HardwareGateLevel = (unsigned char) data[5]; - - /* Test the module number */ - if (b_ModulNbr < 4) { - /* Test if 82X54 timer */ - if ((devpriv->s_BoardInfos.dw_MolduleConfiguration[b_ModulNbr] & 0xFFFF0000UL) == APCI1710_82X54_TIMER) { - /* Test the timer number */ - - if (b_TimerNbr <= 2) { - /* Test the timer mode */ - if (b_TimerMode <= 5) { - /* BEGIN JK 27.10.2003 : Add the possibility to use a 40 Mhz quartz */ - /* Test te imput clock selection */ - /* - if (((b_TimerNbr == 0) && (b_InputClockSelection == 0)) || - ((b_TimerNbr != 0) && ((b_InputClockSelection == 0) || (b_InputClockSelection == 1)))) - */ - - if (((b_TimerNbr == 0) && - (b_InputClockSelection == APCI1710_PCI_BUS_CLOCK)) || - ((b_TimerNbr == 0) && - (b_InputClockSelection == APCI1710_10MHZ)) || - ((b_TimerNbr != 0) && - ((b_InputClockSelection == APCI1710_PCI_BUS_CLOCK) || - (b_InputClockSelection == APCI1710_FRONT_CONNECTOR_INPUT) || - (b_InputClockSelection == APCI1710_10MHZ)))) { - /* BEGIN JK 27.10.2003 : Add the possibility to use a 40 Mhz quartz */ - if (((b_InputClockSelection == APCI1710_10MHZ) && - ((devpriv->s_BoardInfos.dw_MolduleConfiguration[b_ModulNbr] & 0x0000FFFFUL) >= 0x3131)) || - (b_InputClockSelection != APCI1710_10MHZ)) { - /* END JK 27.10.2003 : Add the possibility to use a 40 Mhz quartz */ - /* Test the input clock level selection */ - - if ((b_InputClockLevel == 0) || - (b_InputClockLevel == 1)) { - /* Test the output clock level selection */ - if ((b_OutputLevel == 0) || (b_OutputLevel == 1)) { - /* Test the hardware gate level selection */ - if ((b_HardwareGateLevel == 0) || (b_HardwareGateLevel == 1)) { - /* BEGIN JK 27.10.03 : Add the possibility to use a 40 Mhz quartz */ - /* Test if version > 1.1 and clock selection = 10MHz */ - if ((b_InputClockSelection == APCI1710_10MHZ) && ((devpriv->s_BoardInfos.dw_MolduleConfiguration[b_ModulNbr] & 0x0000FFFFUL) > 0x3131)) { - /* Test if 40MHz quartz on board */ - dw_Test = inl(devpriv->s_BoardInfos.ui_Address + (16 + (b_TimerNbr * 4) + (64 * b_ModulNbr))); - - dw_Test = (dw_Test >> 16) & 1; - } else { - dw_Test = 1; - } - - /* Test if detection OK */ - if (dw_Test == 1) { - /* END JK 27.10.03 : Add the possibility to use a 40 Mhz quartz */ - /* Initialisation OK */ - devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[b_TimerNbr].b_82X54Init = 1; - - /* Save the input clock selection */ - devpriv-> s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[b_TimerNbr].b_InputClockSelection = b_InputClockSelection; - - /* Save the input clock level */ - devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[b_TimerNbr].b_InputClockLevel = ~b_InputClockLevel & 1; - - /* Save the output level */ - devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[b_TimerNbr].b_OutputLevel = ~b_OutputLevel & 1; - - /* Save the gate level */ - devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[b_TimerNbr].b_HardwareGateLevel = b_HardwareGateLevel; - - /* Set the configuration word and disable the timer */ - /* BEGIN JK 27.10.03 : Add the possibility to use a 40 Mhz quartz */ - /* - devpriv->s_ModuleInfo [b_ModulNbr]. - s_82X54ModuleInfo. - s_82X54TimerInfo [b_TimerNbr]. - dw_ConfigurationWord = (unsigned int) (((b_HardwareGateLevel << 0) & 0x1) | - ((b_InputClockLevel << 1) & 0x2) | - (((~b_OutputLevel & 1) << 2) & 0x4) | - ((b_InputClockSelection << 4) & 0x10)); - */ - /* Test if 10MHz selected */ - if (b_InputClockSelection == APCI1710_10MHZ) { - b_InputClockSelection = 2; - } - - devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[b_TimerNbr].dw_ConfigurationWord = (unsigned int)(((b_HardwareGateLevel << 0) & 0x1) | ((b_InputClockLevel << 1) & 0x2) | (((~b_OutputLevel & 1) << 2) & 0x4) | ((b_InputClockSelection << 4) & 0x30)); - /* END JK 27.10.03 : Add the possibility to use a 40 Mhz quartz */ - outl(devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[b_TimerNbr].dw_ConfigurationWord, devpriv->s_BoardInfos.ui_Address + 32 + (b_TimerNbr * 4) + (64 * b_ModulNbr)); - - /* Initialise the 82X54 Timer */ - outl((unsigned int) b_TimerMode, devpriv->s_BoardInfos.ui_Address + 16 + (b_TimerNbr * 4) + (64 * b_ModulNbr)); - - /* Write the reload value */ - outl(ul_ReloadValue, devpriv->s_BoardInfos.ui_Address + 0 + (b_TimerNbr * 4) + (64 * b_ModulNbr)); - /* BEGIN JK 27.10.03 : Add the possibility to use a 40 Mhz quartz */ - } /* if (dw_Test == 1) */ - else { - /* Input timer clock selection is wrong */ - i_ReturnValue = -6; - } /* if (dw_Test == 1) */ - /* END JK 27.10.03 : Add the possibility to use a 40 Mhz quartz */ - } /* if ((b_HardwareGateLevel == 0) || (b_HardwareGateLevel == 1)) */ - else { - /* Selection from hardware gate level is wrong */ - DPRINTK("Selection from hardware gate level is wrong\n"); - i_ReturnValue = -9; - } /* if ((b_HardwareGateLevel == 0) || (b_HardwareGateLevel == 1)) */ - } /* if ((b_OutputLevel == 0) || (b_OutputLevel == 1)) */ - else { - /* Selection from output clock level is wrong */ - DPRINTK("Selection from output clock level is wrong\n"); - i_ReturnValue = -8; - } /* if ((b_OutputLevel == 0) || (b_OutputLevel == 1)) */ - } /* if ((b_InputClockLevel == 0) || (b_InputClockLevel == 1)) */ - else { - /* Selection from input clock level is wrong */ - DPRINTK("Selection from input clock level is wrong\n"); - i_ReturnValue = -7; - } /* if ((b_InputClockLevel == 0) || (b_InputClockLevel == 1)) */ - } else { - /* Input timer clock selection is wrong */ - DPRINTK("Input timer clock selection is wrong\n"); - i_ReturnValue = -6; - } - } else { - /* Input timer clock selection is wrong */ - DPRINTK("Input timer clock selection is wrong\n"); - i_ReturnValue = -6; - } - } /* if ((b_TimerMode >= 0) && (b_TimerMode <= 5)) */ - else { - /* Timer mode selection is wrong */ - DPRINTK("Timer mode selection is wrong\n"); - i_ReturnValue = -5; - } /* if ((b_TimerMode >= 0) && (b_TimerMode <= 5)) */ - } /* if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2)) */ - else { - /* Timer selection wrong */ - DPRINTK("Timer selection wrong\n"); - i_ReturnValue = -3; - } /* if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2)) */ - } else { - /* The module is not a TIMER module */ - DPRINTK("The module is not a TIMER module\n"); - i_ReturnValue = -4; - } - } else { - /* Module number error */ - DPRINTK("Module number error\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_EnableTimer | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char_ b_TimerNbr, | -| unsigned char_ b_InterruptEnable) -int i_APCI1710_InsnWriteEnableDisableTimer(struct comedi_device *dev,struct comedi_subdevice *s, - struct comedi_insn *insn,unsigned int *data) | -+----------------------------------------------------------------------------+ -| Task : Enable OR Disable the Timer (b_TimerNbr) from selected module | -| (b_ModulNbr). You must calling the | -| "i_APCI1710_InitTimer" function be for you call this | -| function. If you enable the timer interrupt, the timer | -| generate a interrupt after the timer value reach | -| the zero. See function "i_APCI1710_SetBoardIntRoutineX"| -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board | -| APCI-1710 | -| unsigned char_ b_ModulNbr : Selected module number | -| (0 to 3) | -| unsigned char_ b_TimerNbr : Timer number to enable | -| (0 to 2) | -| unsigned char_ b_InterruptEnable : Enable or disable the | -| timer interrupt. | -| APCI1710_ENABLE : | -| Enable the timer interrupt | -| APCI1710_DISABLE : | -| Disable the timer interrupt| -i_ReturnValue=insn->n; - b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec); - b_TimerNbr = (unsigned char) CR_CHAN(insn->chanspec); - b_ActionType = (unsigned char) data[0]; enable disable -+----------------------------------------------------------------------------+ -| Output Parameters : - | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: Module selection wrong | -| -3: Timer selection wrong | -| -4: The module is not a TIMER module | -| -5: Timer not initialised see function | -| "i_APCI1710_InitTimer" | -| -6: Interrupt parameter is wrong | -| -7: Interrupt function not initialised. | -| See function "i_APCI1710_SetBoardIntRoutineX" | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_InsnWriteEnableDisableTimer(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - unsigned int dw_DummyRead; - unsigned char b_ModulNbr; - unsigned char b_TimerNbr; - unsigned char b_ActionType; - unsigned char b_InterruptEnable; - - i_ReturnValue = insn->n; - b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec); - b_TimerNbr = (unsigned char) CR_CHAN(insn->chanspec); - b_ActionType = (unsigned char) data[0]; /* enable disable */ - - /* Test the module number */ - if (b_ModulNbr < 4) { - /* Test if 82X54 timer */ - if ((devpriv->s_BoardInfos.dw_MolduleConfiguration[b_ModulNbr] & 0xFFFF0000UL) == APCI1710_82X54_TIMER) { - /* Test the timer number */ - if (b_TimerNbr <= 2) { - /* Test if timer initialised */ - if (devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[b_TimerNbr].b_82X54Init == 1) { - - switch (b_ActionType) { - case APCI1710_ENABLE: - b_InterruptEnable = (unsigned char) data[1]; - /* Test the interrupt selection */ - if ((b_InterruptEnable == APCI1710_ENABLE) || - (b_InterruptEnable == APCI1710_DISABLE)) { - if (b_InterruptEnable == APCI1710_ENABLE) { - - dw_DummyRead = inl(devpriv->s_BoardInfos.ui_Address + 12 + (b_TimerNbr * 4) + (64 * b_ModulNbr)); - - /* Enable the interrupt */ - devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[b_TimerNbr].dw_ConfigurationWord = devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[b_TimerNbr].dw_ConfigurationWord | 0x8; - - outl(devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[b_TimerNbr].dw_ConfigurationWord, devpriv->s_BoardInfos.ui_Address + 32 + (b_TimerNbr * 4) + (64 * b_ModulNbr)); - devpriv->tsk_Current = current; /* Save the current process task structure */ - - } /* if (b_InterruptEnable == APCI1710_ENABLE) */ - else { - /* Disable the interrupt */ - devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[b_TimerNbr].dw_ConfigurationWord = devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[b_TimerNbr].dw_ConfigurationWord & 0xF7; - - outl(devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[b_TimerNbr].dw_ConfigurationWord, devpriv->s_BoardInfos.ui_Address + 32 + (b_TimerNbr * 4) + (64 * b_ModulNbr)); - - /* Save the interrupt flag */ - devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.b_InterruptMask = devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.b_InterruptMask & (0xFF - (1 << b_TimerNbr)); - } /* if (b_InterruptEnable == APCI1710_ENABLE) */ - - /* Test if error occur */ - if (i_ReturnValue >= 0) { - /* Save the interrupt flag */ - devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.b_InterruptMask = devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.b_InterruptMask | ((1 & b_InterruptEnable) << b_TimerNbr); - - /* Enable the timer */ - outl(1, devpriv->s_BoardInfos.ui_Address + 44 + (b_TimerNbr * 4) + (64 * b_ModulNbr)); - } - } else { - /* Interrupt parameter is wrong */ - DPRINTK("\n"); - i_ReturnValue = -6; - } - break; - case APCI1710_DISABLE: - /* Test the interrupt flag */ - if (((devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.b_InterruptMask >> b_TimerNbr) & 1) == 1) { - /* Disable the interrupt */ - - devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[b_TimerNbr]. dw_ConfigurationWord = devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[b_TimerNbr].dw_ConfigurationWord & 0xF7; - - outl(devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[b_TimerNbr].dw_ConfigurationWord, devpriv->s_BoardInfos.ui_Address + 32 + (b_TimerNbr * 4) + (64 * b_ModulNbr)); - - /* Save the interrupt flag */ - devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.b_InterruptMask = devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.b_InterruptMask & (0xFF - (1 << b_TimerNbr)); - } - - /* Disable the timer */ - outl(0, devpriv->s_BoardInfos.ui_Address + 44 + (b_TimerNbr * 4) + (64 * b_ModulNbr)); - break; - } /* Switch end */ - } else { - /* Timer not initialised see function */ - DPRINTK ("Timer not initialised see function\n"); - i_ReturnValue = -5; - } - } else { - /* Timer selection wrong */ - DPRINTK("Timer selection wrong\n"); - i_ReturnValue = -3; - } /* if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2)) */ - } else { - /* The module is not a TIMER module */ - DPRINTK("The module is not a TIMER module\n"); - i_ReturnValue = -4; - } - } else { - /* Module number error */ - DPRINTK("Module number error\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_ReadAllTimerValue | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| PULONG_ pul_TimerValueArray) -int i_APCI1710_InsnReadAllTimerValue(struct comedi_device *dev,struct comedi_subdevice *s, - struct comedi_insn *insn,unsigned int *data) | -+----------------------------------------------------------------------------+ -| Task : Return the all timer values from selected timer | -| module (b_ModulNbr). | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board | -| APCI-1710 | -| unsigned char_ b_ModulNbr : Selected module number | -| (0 to 3) | -+----------------------------------------------------------------------------+ -| Output Parameters : PULONG_ pul_TimerValueArray : Timer value array. | -| Element 0 contain the timer 0 value. | -| Element 1 contain the timer 1 value. | -| Element 2 contain the timer 2 value. | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: Module selection wrong | -| -3: The module is not a TIMER module | -| -4: Timer 0 not initialised see function | -| "i_APCI1710_InitTimer" | -| -5: Timer 1 not initialised see function | -| "i_APCI1710_InitTimer" | -| -6: Timer 2 not initialised see function | -| "i_APCI1710_InitTimer" | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_InsnReadAllTimerValue(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - unsigned char b_ModulNbr, b_ReadType; - unsigned int *pul_TimerValueArray; - - b_ModulNbr = CR_AREF(insn->chanspec); - b_ReadType = CR_CHAN(insn->chanspec); - pul_TimerValueArray = (unsigned int *) data; - i_ReturnValue = insn->n; - - switch (b_ReadType) { - case APCI1710_TIMER_READINTERRUPT: - - data[0] = devpriv->s_InterruptParameters.s_FIFOInterruptParameters[devpriv->s_InterruptParameters.ui_Read].b_OldModuleMask; - data[1] = devpriv->s_InterruptParameters.s_FIFOInterruptParameters[devpriv->s_InterruptParameters.ui_Read].ul_OldInterruptMask; - data[2] = devpriv->s_InterruptParameters.s_FIFOInterruptParameters[devpriv->s_InterruptParameters.ui_Read].ul_OldCounterLatchValue; - - /* Increment the read FIFO */ - devpriv->s_InterruptParameters.ui_Read = (devpriv->s_InterruptParameters.ui_Read + 1) % APCI1710_SAVE_INTERRUPT; - - break; - - case APCI1710_TIMER_READALLTIMER: - /* Test the module number */ - if (b_ModulNbr < 4) { - /* Test if 82X54 timer */ - if ((devpriv->s_BoardInfos.dw_MolduleConfiguration[b_ModulNbr] & 0xFFFF0000UL) == APCI1710_82X54_TIMER) { - /* Test if timer 0 iniutialised */ - if (devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[0].b_82X54Init == 1) { - /* Test if timer 1 iniutialised */ - if (devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[1].b_82X54Init == 1) { - /* Test if timer 2 iniutialised */ - if (devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[2].b_82X54Init == 1) { - /* Latch all counter */ - outl(0x17, devpriv->s_BoardInfos.ui_Address + 12 + (64 * b_ModulNbr)); - - /* Read the timer 0 value */ - pul_TimerValueArray[0] = inl(devpriv->s_BoardInfos.ui_Address + 0 + (64 * b_ModulNbr)); - - /* Read the timer 1 value */ - pul_TimerValueArray[1] = inl(devpriv->s_BoardInfos.ui_Address + 4 + (64 * b_ModulNbr)); - - /* Read the timer 2 value */ - pul_TimerValueArray[2] = inl(devpriv->s_BoardInfos.ui_Address + 8 + (64 * b_ModulNbr)); - } else { - /* Timer 2 not initialised see function */ - DPRINTK("Timer 2 not initialised see function\n"); - i_ReturnValue = -6; - } - } else { - /* Timer 1 not initialised see function */ - DPRINTK("Timer 1 not initialised see function\n"); - i_ReturnValue = -5; - } - } else { - /* Timer 0 not initialised see function */ - DPRINTK("Timer 0 not initialised see function\n"); - i_ReturnValue = -4; - } - } else { - /* The module is not a TIMER module */ - DPRINTK("The module is not a TIMER module\n"); - i_ReturnValue = -3; - } - } else { - /* Module number error */ - DPRINTK("Module number error\n"); - i_ReturnValue = -2; - } - - } /* End of Switch */ - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_ReadTimerValue | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char_ b_TimerNbr, | -| PULONG_ pul_TimerValue) | -+----------------------------------------------------------------------------+ -| Task : Return the timer value from selected digital timer | -| (b_TimerNbr) from selected timer module (b_ModulNbr). | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board | -| APCI-1710 | -| unsigned char_ b_ModulNbr : Selected module number | -| (0 to 3) | -| unsigned char_ b_TimerNbr : Timer number to read | -| (0 to 2) | -+----------------------------------------------------------------------------+ -| Output Parameters : PULONG_ pul_TimerValue : Timer value | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: Module selection wrong | -| -3: Timer selection wrong | -| -4: The module is not a TIMER module | -| -5: Timer not initialised see function | -| "i_APCI1710_InitTimer" | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_ReadTimerValue(struct comedi_device *dev, - unsigned char b_ModulNbr, - unsigned char b_TimerNbr, - unsigned int *pul_TimerValue) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - - /* Test the module number */ - if (b_ModulNbr < 4) { - /* Test if 82X54 timer */ - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[b_ModulNbr] & - 0xFFFF0000UL) == APCI1710_82X54_TIMER) { - /* Test the timer number */ - if (b_TimerNbr <= 2) { - /* Test if timer initialised */ - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_82X54ModuleInfo. - s_82X54TimerInfo[b_TimerNbr]. - b_82X54Init == 1) { - /* Latch the timer value */ - outl((2 << b_TimerNbr) | 0xD0, - devpriv->s_BoardInfos. - ui_Address + 12 + - (64 * b_ModulNbr)); - - /* Read the counter value */ - *pul_TimerValue = - inl(devpriv->s_BoardInfos. - ui_Address + (b_TimerNbr * 4) + - (64 * b_ModulNbr)); - } else { - /* Timer not initialised see function */ - DPRINTK("Timer not initialised see function\n"); - i_ReturnValue = -5; - } - } else { - /* Timer selection wrong */ - DPRINTK("Timer selection wrong\n"); - i_ReturnValue = -3; - } /* if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2)) */ - } else { - /* The module is not a TIMER module */ - DPRINTK("The module is not a TIMER module\n"); - i_ReturnValue = -4; - } - } else { - /* Module number error */ - DPRINTK("Module number error\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - - /* - +----------------------------------------------------------------------------+ - | Function Name : _INT_ i_APCI1710_GetTimerOutputLevel | - | (unsigned char_ b_BoardHandle, | - | unsigned char_ b_ModulNbr, | - | unsigned char_ b_TimerNbr, | - | unsigned char *_ pb_OutputLevel) | - +----------------------------------------------------------------------------+ - | Task : Return the output signal level (pb_OutputLevel) from | - | selected digital timer (b_TimerNbr) from selected timer| - | module (b_ModulNbr). | - +----------------------------------------------------------------------------+ - | Input Parameters : unsigned char_ b_BoardHandle : Handle of board | - | APCI-1710 | - | unsigned char_ b_ModulNbr : Selected module number | - | (0 to 3) | - | unsigned char_ b_TimerNbr : Timer number to test | - | (0 to 2) | - +----------------------------------------------------------------------------+ - | Output Parameters : unsigned char *_ pb_OutputLevel : Output signal level | - | 0 : The output is low | - | 1 : The output is high | - +----------------------------------------------------------------------------+ - | Return Value : 0: No error | - | -1: The handle parameter of the board is wrong | - | -2: Module selection wrong | - | -3: Timer selection wrong | - | -4: The module is not a TIMER module | - | -5: Timer not initialised see function | - | "i_APCI1710_InitTimer" | - +----------------------------------------------------------------------------+ - */ -static int i_APCI1710_GetTimerOutputLevel(struct comedi_device *dev, - unsigned char b_ModulNbr, - unsigned char b_TimerNbr, - unsigned char *pb_OutputLevel) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - unsigned int dw_TimerStatus; - - /* Test the module number */ - if (b_ModulNbr < 4) { - /* Test if 82X54 timer */ - if ((devpriv->s_BoardInfos.dw_MolduleConfiguration[b_ModulNbr] & 0xFFFF0000UL) == APCI1710_82X54_TIMER) { - /* Test the timer number */ - if (b_TimerNbr <= 2) { - /* Test if timer initialised */ - if (devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[b_TimerNbr].b_82X54Init == 1) { - /* Latch the timer value */ - outl((2 << b_TimerNbr) | 0xE0, devpriv->s_BoardInfos.ui_Address + 12 + (64 * b_ModulNbr)); - - /* Read the timer status */ - dw_TimerStatus = inl(devpriv->s_BoardInfos.ui_Address + 16 + (b_TimerNbr * 4) + (64 * b_ModulNbr)); - - *pb_OutputLevel = (unsigned char) (((dw_TimerStatus >> 7) & 1) ^ devpriv-> s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[b_TimerNbr].b_OutputLevel); - } else { - /* Timer not initialised see function */ - DPRINTK("Timer not initialised see function\n"); - i_ReturnValue = -5; - } - } else { - /* Timer selection wrong */ - DPRINTK("Timer selection wrong\n"); - i_ReturnValue = -3; - } /* if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2)) */ - } else { - /* The module is not a TIMER module */ - DPRINTK("The module is not a TIMER module\n"); - i_ReturnValue = -4; - } - } else { - /* Module number error */ - DPRINTK("Module number error\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_GetTimerProgressStatus | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char_ b_TimerNbr, | -| unsigned char *_ pb_TimerStatus) | -+----------------------------------------------------------------------------+ -| Task : Return the progress status (pb_TimerStatus) from | -| selected digital timer (b_TimerNbr) from selected timer| -| module (b_ModulNbr). | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board | -| APCI-1710 | -| unsigned char_ b_ModulNbr : Selected module number | -| (0 to 3) | -| unsigned char_ b_TimerNbr : Timer number to test | -| (0 to 2) | -+----------------------------------------------------------------------------+ -| Output Parameters : unsigned char *_ pb_TimerStatus : Output signal level | -| 0 : Timer not in progress | -| 1 : Timer in progress | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: Module selection wrong | -| -3: Timer selection wrong | -| -4: The module is not a TIMER module | -| -5: Timer not initialised see function | -| "i_APCI1710_InitTimer" | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_GetTimerProgressStatus(struct comedi_device *dev, - unsigned char b_ModulNbr, - unsigned char b_TimerNbr, - unsigned char *pb_TimerStatus) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - unsigned int dw_TimerStatus; - - /* Test the module number */ - if (b_ModulNbr < 4) { - /* Test if 82X54 timer */ - - if ((devpriv->s_BoardInfos.dw_MolduleConfiguration[b_ModulNbr] & 0xFFFF0000UL) == APCI1710_82X54_TIMER) { - /* Test the timer number */ - if (b_TimerNbr <= 2) { - /* Test if timer initialised */ - if (devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[b_TimerNbr].b_82X54Init == 1) { - /* Latch the timer value */ - outl((2 << b_TimerNbr) | 0xE0, devpriv->s_BoardInfos.ui_Address + 12 + (64 * b_ModulNbr)); - - /* Read the timer status */ - dw_TimerStatus = inl(devpriv->s_BoardInfos.ui_Address + 16 + (b_TimerNbr * 4) + (64 * b_ModulNbr)); - - *pb_TimerStatus = (unsigned char) ((dw_TimerStatus) >> 8) & 1; - printk("ProgressStatus : %d", *pb_TimerStatus); - } else { - /* Timer not initialised see function */ - i_ReturnValue = -5; - } - } else { - /* Timer selection wrong */ - i_ReturnValue = -3; - } /* if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2)) */ - } else { - /* The module is not a TIMER module */ - - i_ReturnValue = -4; - } - } else { - /* Module number error */ - - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_WriteTimerValue | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char_ b_TimerNbr, | -| ULONG_ ul_WriteValue) | -+----------------------------------------------------------------------------+ -| Task : Write the value (ul_WriteValue) into the selected timer| -| (b_TimerNbr) from selected timer module (b_ModulNbr). | -| The action in depend of the time mode selection. | -| See timer mode description table. | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board | -| APCI-1710 | -| unsigned char_ b_ModulNbr : Selected module number | -| (0 to 3) | -| unsigned char_ b_TimerNbr : Timer number to write | -| (0 to 2) | -| ULONG_ ul_WriteValue : Value to write | -+----------------------------------------------------------------------------+ -| Output Parameters : - | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: Module selection wrong | -| -3: Timer selection wrong | -| -4: The module is not a TIMER module | -| -5: Timer not initialised see function | -| "i_APCI1710_InitTimer" | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_WriteTimerValue(struct comedi_device *dev, - unsigned char b_ModulNbr, - unsigned char b_TimerNbr, - unsigned int ul_WriteValue) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - - /* Test the module number */ - if (b_ModulNbr < 4) { - /* Test if 82X54 timer */ - if ((devpriv->s_BoardInfos.dw_MolduleConfiguration[b_ModulNbr] & 0xFFFF0000UL) == APCI1710_82X54_TIMER) { - /* Test the timer number */ - if (b_TimerNbr <= 2) { - /* Test if timer initialised */ - if (devpriv->s_ModuleInfo[b_ModulNbr].s_82X54ModuleInfo.s_82X54TimerInfo[b_TimerNbr].b_82X54Init == 1) { - /* Write the value */ - outl(ul_WriteValue, devpriv->s_BoardInfos.ui_Address + (b_TimerNbr * 4) + (64 * b_ModulNbr)); - } else { - /* Timer not initialised see function */ - DPRINTK("Timer not initialised see function\n"); - i_ReturnValue = -5; - } - } else { - /* Timer selection wrong */ - DPRINTK("Timer selection wrong\n"); - i_ReturnValue = -3; - } /* if ((b_TimerNbr >= 0) && (b_TimerNbr <= 2)) */ - } else { - /* The module is not a TIMER module */ - DPRINTK("The module is not a TIMER module\n"); - i_ReturnValue = -4; - } - } else { - /* Module number error */ - DPRINTK("Module number error\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name :INT i_APCI1710_InsnBitsTimer(struct comedi_device *dev, -struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data) | -+----------------------------------------------------------------------------+ -| Task : Read write functions for Timer | -+----------------------------------------------------------------------------+ -| Input Parameters : -+----------------------------------------------------------------------------+ -| Output Parameters : - | -+----------------------------------------------------------------------------+ -| Return Value : -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_InsnBitsTimer(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - unsigned char b_BitsType; - int i_ReturnValue = 0; - b_BitsType = data[0]; - - printk("\n82X54"); - - switch (b_BitsType) { - case APCI1710_TIMER_READVALUE: - i_ReturnValue = i_APCI1710_ReadTimerValue(dev, - (unsigned char)CR_AREF(insn->chanspec), - (unsigned char)CR_CHAN(insn->chanspec), - (unsigned int *) &data[0]); - break; - - case APCI1710_TIMER_GETOUTPUTLEVEL: - i_ReturnValue = i_APCI1710_GetTimerOutputLevel(dev, - (unsigned char)CR_AREF(insn->chanspec), - (unsigned char)CR_CHAN(insn->chanspec), - (unsigned char *) &data[0]); - break; - - case APCI1710_TIMER_GETPROGRESSSTATUS: - i_ReturnValue = i_APCI1710_GetTimerProgressStatus(dev, - (unsigned char)CR_AREF(insn->chanspec), - (unsigned char)CR_CHAN(insn->chanspec), - (unsigned char *)&data[0]); - break; - - case APCI1710_TIMER_WRITEVALUE: - i_ReturnValue = i_APCI1710_WriteTimerValue(dev, - (unsigned char)CR_AREF(insn->chanspec), - (unsigned char)CR_CHAN(insn->chanspec), - (unsigned int)data[1]); - - break; - - default: - printk("Bits Config Parameter Wrong\n"); - i_ReturnValue = -1; - } - - if (i_ReturnValue >= 0) - i_ReturnValue = insn->n; - return i_ReturnValue; -} diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Chrono.c b/drivers/staging/comedi/drivers/addi-data/APCI1710_Chrono.c deleted file mode 100644 index d91f586fdd264..0000000000000 --- a/drivers/staging/comedi/drivers/addi-data/APCI1710_Chrono.c +++ /dev/null @@ -1,2050 +0,0 @@ -/** -@verbatim - -Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. - - ADDI-DATA GmbH - Dieselstrasse 3 - D-77833 Ottersweier - Tel: +19(0)7223/9493-0 - Fax: +49(0)7223/9493-92 - http://www.addi-data.com - info@addi-data.com - -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 the License, or (at your option) any later version. - -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. - -@endverbatim -*/ -/* - - +-----------------------------------------------------------------------+ - | (C) ADDI-DATA GmbH Dieselstraße 3 D-77833 Ottersweier | - +-----------------------------------------------------------------------+ - | Tel : +49 (0) 7223/9493-0 | email : info@addi-data.com | - | Fax : +49 (0) 7223/9493-92 | Internet : http://www.addi-data.com | - +-----------------------------------------------------------------------+ - | Project : API APCI1710 | Compiler : gcc | - | Module name : CHRONO.C | Version : 2.96 | - +-------------------------------+---------------------------------------+ - | Project manager: Eric Stolz | Date : 02/12/2002 | - +-----------------------------------------------------------------------+ - | Description : APCI-1710 chronometer module | - | | - | | - +-----------------------------------------------------------------------+ - | UPDATES | - +-----------------------------------------------------------------------+ - | Date | Author | Description of updates | - +----------+-----------+------------------------------------------------+ - | 29/06/98 | S. Weber | Digital input / output implementation | - |----------|-----------|------------------------------------------------| - | 08/05/00 | Guinot C | - 0400/0228 All Function in RING 0 | - | | | available | - +-----------------------------------------------------------------------+ - | | | | - | | | | - +-----------------------------------------------------------------------+ -*/ - -#define APCI1710_30MHZ 30 -#define APCI1710_33MHZ 33 -#define APCI1710_40MHZ 40 - -#define APCI1710_SINGLE 0 -#define APCI1710_CONTINUOUS 1 - -#define APCI1710_CHRONO_PROGRESS_STATUS 0 -#define APCI1710_CHRONO_READVALUE 1 -#define APCI1710_CHRONO_CONVERTVALUE 2 -#define APCI1710_CHRONO_READINTERRUPT 3 - -#define APCI1710_CHRONO_SET_CHANNELON 0 -#define APCI1710_CHRONO_SET_CHANNELOFF 1 -#define APCI1710_CHRONO_READ_CHANNEL 2 -#define APCI1710_CHRONO_READ_PORT 3 - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_InitChrono | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char_ b_ChronoMode, | -| unsigned char_ b_PCIInputClock, | -| unsigned char_ b_TimingUnit, | -| ULONG_ ul_TimingInterval, | -| PULONG_ pul_RealTimingInterval) - -+----------------------------------------------------------------------------+ -| Task : Configure the chronometer operating mode (b_ChronoMode)| -| from selected module (b_ModulNbr). | -| The ul_TimingInterval and ul_TimingUnit determine the | -| timing base for the measurement. | -| The pul_RealTimingInterval return the real timing | -| value. You must calling this function be for you call | -| any other function witch access of the chronometer. | -| | -| Witch this functionality from the APCI-1710 you have | -| the possibility to measure the timing witch two event. | -| | -| The mode 0 and 1 is appropriate for period measurement.| -| The mode 2 and 3 is appropriate for frequent | -| measurement. | -| The mode 4 to 7 is appropriate for measuring the timing| -| between two event. | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr CR_AREF(insn->chanspec) : Module number to configure | -| (0 to 3) | -| unsigned char_ b_ChronoMode data[0] : Chronometer action mode | -| (0 to 7). | -| unsigned char_ b_PCIInputClock data[1] : Selection from PCI bus clock| -| - APCI1710_30MHZ : | -| The PC have a PCI bus | -| clock from 30 MHz | -| - APCI1710_33MHZ : | -| The PC have a PCI bus | -| clock from 33 MHz | -| - APCI1710_40MHZ | -| The APCI-1710 have a | -| integrated 40Mhz | -| quartz. | -| unsigned char_ b_TimingUnit data[2] : Base timing unity (0 to 4) | -| 0 : ns | -| 1 : µs | -| 2 : ms | -| 3 : s | -| 4 : mn | -| ULONG_ ul_TimingInterval : data[3] Base timing value. | -+----------------------------------------------------------------------------+ -| Output Parameters : PULONG_ pul_RealTimingInterval : Real base timing | -| value. -| data[0] -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: Module selection wrong | -| -3: The module is not a Chronometer module | -| -4: Chronometer mode selection is wrong | -| -5: The selected PCI input clock is wrong | -| -6: Timing unity selection is wrong | -| -7: Base timing selection is wrong | -| -8: You can not used the 40MHz clock selection with | -| this board | -| -9: You can not used the 40MHz clock selection with | -| this CHRONOS version | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_InsnConfigInitChrono(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - unsigned int ul_TimerValue = 0; - unsigned int ul_TimingInterval = 0; - unsigned int ul_RealTimingInterval = 0; - double d_RealTimingInterval = 0; - unsigned int dw_ModeArray[8] = - { 0x01, 0x05, 0x00, 0x04, 0x02, 0x0E, 0x0A, 0x06 }; - unsigned char b_ModulNbr, b_ChronoMode, b_PCIInputClock, b_TimingUnit; - - b_ModulNbr = CR_AREF(insn->chanspec); - b_ChronoMode = (unsigned char) data[0]; - b_PCIInputClock = (unsigned char) data[1]; - b_TimingUnit = (unsigned char) data[2]; - ul_TimingInterval = (unsigned int) data[3]; - i_ReturnValue = insn->n; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /***********************/ - /* Test if chronometer */ - /***********************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[b_ModulNbr] & - 0xFFFF0000UL) == APCI1710_CHRONOMETER) { - /*****************************/ - /* Test the chronometer mode */ - /*****************************/ - - if (b_ChronoMode <= 7) { - /**************************/ - /* Test the PCI bus clock */ - /**************************/ - - if ((b_PCIInputClock == APCI1710_30MHZ) || - (b_PCIInputClock == APCI1710_33MHZ) || - (b_PCIInputClock == APCI1710_40MHZ)) { - /*************************/ - /* Test the timing unity */ - /*************************/ - - if (b_TimingUnit <= 4) { - /**********************************/ - /* Test the base timing selection */ - /**********************************/ - - if (((b_PCIInputClock == APCI1710_30MHZ) && (b_TimingUnit == 0) && (ul_TimingInterval >= 66) && (ul_TimingInterval <= 0xFFFFFFFFUL)) || ((b_PCIInputClock == APCI1710_30MHZ) && (b_TimingUnit == 1) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 143165576UL)) || ((b_PCIInputClock == APCI1710_30MHZ) && (b_TimingUnit == 2) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 143165UL)) || ((b_PCIInputClock == APCI1710_30MHZ) && (b_TimingUnit == 3) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 143UL)) || ((b_PCIInputClock == APCI1710_30MHZ) && (b_TimingUnit == 4) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 2UL)) || ((b_PCIInputClock == APCI1710_33MHZ) && (b_TimingUnit == 0) && (ul_TimingInterval >= 60) && (ul_TimingInterval <= 0xFFFFFFFFUL)) || ((b_PCIInputClock == APCI1710_33MHZ) && (b_TimingUnit == 1) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 130150240UL)) || ((b_PCIInputClock == APCI1710_33MHZ) && (b_TimingUnit == 2) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 130150UL)) || ((b_PCIInputClock == APCI1710_33MHZ) && (b_TimingUnit == 3) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 130UL)) || ((b_PCIInputClock == APCI1710_33MHZ) && (b_TimingUnit == 4) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 2UL)) || ((b_PCIInputClock == APCI1710_40MHZ) && (b_TimingUnit == 0) && (ul_TimingInterval >= 50) && (ul_TimingInterval <= 0xFFFFFFFFUL)) || ((b_PCIInputClock == APCI1710_40MHZ) && (b_TimingUnit == 1) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 107374182UL)) || ((b_PCIInputClock == APCI1710_40MHZ) && (b_TimingUnit == 2) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 107374UL)) || ((b_PCIInputClock == APCI1710_40MHZ) && (b_TimingUnit == 3) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 107UL)) || ((b_PCIInputClock == APCI1710_40MHZ) && (b_TimingUnit == 4) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 1UL))) { - /**************************/ - /* Test the board version */ - /**************************/ - - if (((b_PCIInputClock == APCI1710_40MHZ) && (devpriv->s_BoardInfos.b_BoardVersion > 0)) || (b_PCIInputClock != APCI1710_40MHZ)) { - /************************/ - /* Test the TOR version */ - /************************/ - - if (((b_PCIInputClock == APCI1710_40MHZ) && ((devpriv->s_BoardInfos.dw_MolduleConfiguration[b_ModulNbr] & 0xFFFF) >= 0x3131)) || (b_PCIInputClock != APCI1710_40MHZ)) { - fpu_begin - (); - - /****************************************/ - /* Calculate the timer 0 division fator */ - /****************************************/ - - switch (b_TimingUnit) { - /******/ - /* ns */ - /******/ - - case 0: - - /******************/ - /* Timer 0 factor */ - /******************/ - - ul_TimerValue - = - (unsigned int) - (ul_TimingInterval - * - (0.001 * b_PCIInputClock)); - - /*******************/ - /* Round the value */ - /*******************/ - - if ((double)((double)ul_TimingInterval * (0.001 * (double)b_PCIInputClock)) >= ((double)((double)ul_TimerValue + 0.5))) { - ul_TimerValue - = - ul_TimerValue - + - 1; - } - - /*****************************/ - /* Calculate the real timing */ - /*****************************/ - - ul_RealTimingInterval - = - (unsigned int) - (ul_TimerValue - / - (0.001 * (double)b_PCIInputClock)); - d_RealTimingInterval - = - (double) - ul_TimerValue - / - (0.001 - * - (double) - b_PCIInputClock); - - if ((double)((double)ul_TimerValue / (0.001 * (double)b_PCIInputClock)) >= (double)((double)ul_RealTimingInterval + 0.5)) { - ul_RealTimingInterval - = - ul_RealTimingInterval - + - 1; - } - - ul_TimingInterval - = - ul_TimingInterval - - - 1; - ul_TimerValue - = - ul_TimerValue - - - 2; - if (b_PCIInputClock != APCI1710_40MHZ) { - ul_TimerValue - = - (unsigned int) - ( - (double) - (ul_TimerValue) - * - 0.99392); - } - - break; - - /******/ - /* æs */ - /******/ - - case 1: - - /******************/ - /* Timer 0 factor */ - /******************/ - - ul_TimerValue - = - (unsigned int) - (ul_TimingInterval - * - (1.0 * b_PCIInputClock)); - - /*******************/ - /* Round the value */ - /*******************/ - - if ((double)((double)ul_TimingInterval * (1.0 * (double)b_PCIInputClock)) >= ((double)((double)ul_TimerValue + 0.5))) { - ul_TimerValue - = - ul_TimerValue - + - 1; - } - - /*****************************/ - /* Calculate the real timing */ - /*****************************/ - - ul_RealTimingInterval - = - (unsigned int) - (ul_TimerValue - / - (1.0 * (double)b_PCIInputClock)); - d_RealTimingInterval - = - (double) - ul_TimerValue - / - ( - (double) - 1.0 - * - (double) - b_PCIInputClock); - - if ((double)((double)ul_TimerValue / (1.0 * (double)b_PCIInputClock)) >= (double)((double)ul_RealTimingInterval + 0.5)) { - ul_RealTimingInterval - = - ul_RealTimingInterval - + - 1; - } - - ul_TimingInterval - = - ul_TimingInterval - - - 1; - ul_TimerValue - = - ul_TimerValue - - - 2; - if (b_PCIInputClock != APCI1710_40MHZ) { - ul_TimerValue - = - (unsigned int) - ( - (double) - (ul_TimerValue) - * - 0.99392); - } - - break; - - /******/ - /* ms */ - /******/ - - case 2: - - /******************/ - /* Timer 0 factor */ - /******************/ - - ul_TimerValue - = - ul_TimingInterval - * - (1000 - * - b_PCIInputClock); - - /*******************/ - /* Round the value */ - /*******************/ - - if ((double)((double)ul_TimingInterval * (1000.0 * (double)b_PCIInputClock)) >= ((double)((double)ul_TimerValue + 0.5))) { - ul_TimerValue - = - ul_TimerValue - + - 1; - } - - /*****************************/ - /* Calculate the real timing */ - /*****************************/ - - ul_RealTimingInterval - = - (unsigned int) - (ul_TimerValue - / - (1000.0 * (double)b_PCIInputClock)); - d_RealTimingInterval - = - (double) - ul_TimerValue - / - (1000.0 - * - (double) - b_PCIInputClock); - - if ((double)((double)ul_TimerValue / (1000.0 * (double)b_PCIInputClock)) >= (double)((double)ul_RealTimingInterval + 0.5)) { - ul_RealTimingInterval - = - ul_RealTimingInterval - + - 1; - } - - ul_TimingInterval - = - ul_TimingInterval - - - 1; - ul_TimerValue - = - ul_TimerValue - - - 2; - if (b_PCIInputClock != APCI1710_40MHZ) { - ul_TimerValue - = - (unsigned int) - ( - (double) - (ul_TimerValue) - * - 0.99392); - } - - break; - - /*****/ - /* s */ - /*****/ - - case 3: - - /******************/ - /* Timer 0 factor */ - /******************/ - - ul_TimerValue - = - (unsigned int) - (ul_TimingInterval - * - (1000000.0 - * - b_PCIInputClock)); - - /*******************/ - /* Round the value */ - /*******************/ - - if ((double)((double)ul_TimingInterval * (1000000.0 * (double)b_PCIInputClock)) >= ((double)((double)ul_TimerValue + 0.5))) { - ul_TimerValue - = - ul_TimerValue - + - 1; - } - - /*****************************/ - /* Calculate the real timing */ - /*****************************/ - - ul_RealTimingInterval - = - (unsigned int) - (ul_TimerValue - / - (1000000.0 - * - (double) - b_PCIInputClock)); - d_RealTimingInterval - = - (double) - ul_TimerValue - / - (1000000.0 - * - (double) - b_PCIInputClock); - - if ((double)((double)ul_TimerValue / (1000000.0 * (double)b_PCIInputClock)) >= (double)((double)ul_RealTimingInterval + 0.5)) { - ul_RealTimingInterval - = - ul_RealTimingInterval - + - 1; - } - - ul_TimingInterval - = - ul_TimingInterval - - - 1; - ul_TimerValue - = - ul_TimerValue - - - 2; - if (b_PCIInputClock != APCI1710_40MHZ) { - ul_TimerValue - = - (unsigned int) - ( - (double) - (ul_TimerValue) - * - 0.99392); - } - - break; - - /******/ - /* mn */ - /******/ - - case 4: - - /******************/ - /* Timer 0 factor */ - /******************/ - - ul_TimerValue - = - (unsigned int) - ( - (ul_TimingInterval - * - 60) - * - (1000000.0 - * - b_PCIInputClock)); - - /*******************/ - /* Round the value */ - /*******************/ - - if ((double)((double)(ul_TimingInterval * 60.0) * (1000000.0 * (double)b_PCIInputClock)) >= ((double)((double)ul_TimerValue + 0.5))) { - ul_TimerValue - = - ul_TimerValue - + - 1; - } - - /*****************************/ - /* Calculate the real timing */ - /*****************************/ - - ul_RealTimingInterval - = - (unsigned int) - (ul_TimerValue - / - (1000000.0 - * - (double) - b_PCIInputClock)) - / - 60; - d_RealTimingInterval - = - ( - (double) - ul_TimerValue - / - (0.001 * (double)b_PCIInputClock)) / 60.0; - - if ((double)(((double)ul_TimerValue / (1000000.0 * (double)b_PCIInputClock)) / 60.0) >= (double)((double)ul_RealTimingInterval + 0.5)) { - ul_RealTimingInterval - = - ul_RealTimingInterval - + - 1; - } - - ul_TimingInterval - = - ul_TimingInterval - - - 1; - ul_TimerValue - = - ul_TimerValue - - - 2; - if (b_PCIInputClock != APCI1710_40MHZ) { - ul_TimerValue - = - (unsigned int) - ( - (double) - (ul_TimerValue) - * - 0.99392); - } - - break; - } - - fpu_end(); - - /****************************/ - /* Save the PCI input clock */ - /****************************/ - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_ChronoModuleInfo. - b_PCIInputClock - = - b_PCIInputClock; - - /*************************/ - /* Save the timing unity */ - /*************************/ - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_ChronoModuleInfo. - b_TimingUnit - = - b_TimingUnit; - - /************************/ - /* Save the base timing */ - /************************/ - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_ChronoModuleInfo. - d_TimingInterval - = - d_RealTimingInterval; - - /****************************/ - /* Set the chronometer mode */ - /****************************/ - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_ChronoModuleInfo. - dw_ConfigReg - = - dw_ModeArray - [b_ChronoMode]; - - /***********************/ - /* Test if 40 MHz used */ - /***********************/ - - if (b_PCIInputClock == APCI1710_40MHZ) { - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_ChronoModuleInfo. - dw_ConfigReg - = - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_ChronoModuleInfo. - dw_ConfigReg - | - 0x80; - } - - outl(devpriv->s_ModuleInfo[b_ModulNbr].s_ChronoModuleInfo.dw_ConfigReg, devpriv->s_BoardInfos.ui_Address + 16 + (64 * b_ModulNbr)); - - /***********************/ - /* Write timer 0 value */ - /***********************/ - - outl(ul_TimerValue, devpriv->s_BoardInfos.ui_Address + (64 * b_ModulNbr)); - - /*********************/ - /* Chronometer init. */ - /*********************/ - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_ChronoModuleInfo. - b_ChronoInit - = - 1; - } else { - /***********************************************/ - /* TOR version error for 40MHz clock selection */ - /***********************************************/ - - DPRINTK("TOR version error for 40MHz clock selection\n"); - i_ReturnValue - = - -9; - } - } else { - /**************************************************************/ - /* You can not use the 40MHz clock selection with this board */ - /**************************************************************/ - - DPRINTK("You can not used the 40MHz clock selection with this board\n"); - i_ReturnValue = - -8; - } - } else { - /**********************************/ - /* Base timing selection is wrong */ - /**********************************/ - - DPRINTK("Base timing selection is wrong\n"); - i_ReturnValue = -7; - } - } /* if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4)) */ - else { - /***********************************/ - /* Timing unity selection is wrong */ - /***********************************/ - - DPRINTK("Timing unity selection is wrong\n"); - i_ReturnValue = -6; - } /* if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4)) */ - } /* if ((b_PCIInputClock == APCI1710_30MHZ) || (b_PCIInputClock == APCI1710_33MHZ)) */ - else { - /*****************************************/ - /* The selected PCI input clock is wrong */ - /*****************************************/ - - DPRINTK("The selected PCI input clock is wrong\n"); - i_ReturnValue = -5; - } /* if ((b_PCIInputClock == APCI1710_30MHZ) || (b_PCIInputClock == APCI1710_33MHZ)) */ - } /* if (b_ChronoMode >= 0 && b_ChronoMode <= 7) */ - else { - /***************************************/ - /* Chronometer mode selection is wrong */ - /***************************************/ - - DPRINTK("Chronometer mode selection is wrong\n"); - i_ReturnValue = -4; - } /* if (b_ChronoMode >= 0 && b_ChronoMode <= 7) */ - } else { - /******************************************/ - /* The module is not a Chronometer module */ - /******************************************/ - - DPRINTK("The module is not a Chronometer module\n"); - i_ReturnValue = -3; - } - } else { - /***********************/ - /* Module number error */ - /***********************/ - - DPRINTK("Module number error\n"); - i_ReturnValue = -2; - } - data[0] = ul_RealTimingInterval; - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_EnableChrono | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char_ b_CycleMode, | -| unsigned char_ b_InterruptEnable) -int i_APCI1710_InsnWriteEnableDisableChrono(struct comedi_device *dev, -struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data) | -+----------------------------------------------------------------------------+ -| Task : Enable the chronometer from selected module | -| (b_ModulNbr). You must calling the | -| "i_APCI1710_InitChrono" function be for you call this | -| function. | -| If you enable the chronometer interrupt, the | -| chronometer generate a interrupt after the stop signal.| -| See function "i_APCI1710_SetBoardIntRoutineX" and the | -| Interrupt mask description chapter from this manual. | -| The b_CycleMode parameter determine if you will | -| measured a single or more cycle. - -| Disable the chronometer from selected module | -| (b_ModulNbr). If you disable the chronometer after a | -| start signal occur and you restart the chronometer | -| witch the " i_APCI1710_EnableChrono" function, if no | -| stop signal occur this start signal is ignored. -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr CR_AREF(chanspec) : Selected module number (0 to 3) | - data[0] ENABle/Disable chrono -| unsigned char_ b_CycleMode : Selected the chronometer | -| data[1] acquisition mode | -| unsigned char_ b_InterruptEnable : Enable or disable the | -| data[2] chronometer interrupt. | -| APCI1710_ENABLE: | -| Enable the chronometer | -| interrupt | -| APCI1710_DISABLE: | -| Disable the chronometer | -| interrupt | -+----------------------------------------------------------------------------+ -| Output Parameters : - | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: Module selection wrong | -| -3: The module is not a Chronometer module | -| -4: Chronometer not initialised see function | -| "i_APCI1710_InitChrono" | -| -5: Chronometer acquisition mode cycle is wrong | -| -6: Interrupt parameter is wrong | -| -7: Interrupt function not initialised. | -| See function "i_APCI1710_SetBoardIntRoutineX" - -8: data[0] wrong input | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_InsnWriteEnableDisableChrono(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - unsigned char b_ModulNbr, b_CycleMode, b_InterruptEnable, b_Action; - b_ModulNbr = CR_AREF(insn->chanspec); - b_Action = (unsigned char) data[0]; - b_CycleMode = (unsigned char) data[1]; - b_InterruptEnable = (unsigned char) data[2]; - i_ReturnValue = insn->n; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /***********************/ - /* Test if chronometer */ - /***********************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[b_ModulNbr] & - 0xFFFF0000UL) == APCI1710_CHRONOMETER) { - /***********************************/ - /* Test if chronometer initialised */ - /***********************************/ - - if (devpriv->s_ModuleInfo[b_ModulNbr]. - s_ChronoModuleInfo.b_ChronoInit == 1) { - - switch (b_Action) { - - case APCI1710_ENABLE: - - /*********************************/ - /* Test the cycle mode parameter */ - /*********************************/ - - if ((b_CycleMode == APCI1710_SINGLE) - || (b_CycleMode == - APCI1710_CONTINUOUS)) { - /***************************/ - /* Test the interrupt flag */ - /***************************/ - - if ((b_InterruptEnable == - APCI1710_ENABLE) - || (b_InterruptEnable == - APCI1710_DISABLE)) - { - - /***************************/ - /* Save the interrupt flag */ - /***************************/ - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_ChronoModuleInfo. - b_InterruptMask - = - b_InterruptEnable; - - /***********************/ - /* Save the cycle mode */ - /***********************/ - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_ChronoModuleInfo. - b_CycleMode = - b_CycleMode; - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_ChronoModuleInfo. - dw_ConfigReg = - (devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_ChronoModuleInfo. - dw_ConfigReg & - 0x8F) | ((1 & - b_InterruptEnable) - << 5) | ((1 & - b_CycleMode) - << 6) | 0x10; - - /*****************************/ - /* Test if interrupt enabled */ - /*****************************/ - - if (b_InterruptEnable == - APCI1710_ENABLE) - { - /****************************/ - /* Clear the interrupt flag */ - /****************************/ - - outl(devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_ChronoModuleInfo. - dw_ConfigReg, - devpriv-> - s_BoardInfos. - ui_Address - + 32 + - (64 * b_ModulNbr)); - devpriv->tsk_Current = current; /* Save the current process task structure */ - } - - /***********************************/ - /* Enable or disable the interrupt */ - /* Enable the chronometer */ - /***********************************/ - - outl(devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_ChronoModuleInfo. - dw_ConfigReg, - devpriv-> - s_BoardInfos. - ui_Address + - 16 + - (64 * b_ModulNbr)); - - /*************************/ - /* Clear status register */ - /*************************/ - - outl(0, devpriv-> - s_BoardInfos. - ui_Address + - 36 + - (64 * b_ModulNbr)); - - } /* if ((b_InterruptEnable == APCI1710_ENABLE) || (b_InterruptEnable == APCI1710_DISABLE)) */ - else { - /********************************/ - /* Interrupt parameter is wrong */ - /********************************/ - - DPRINTK("Interrupt parameter is wrong\n"); - i_ReturnValue = -6; - } /* if ((b_InterruptEnable == APCI1710_ENABLE) || (b_InterruptEnable == APCI1710_DISABLE)) */ - } /* if ((b_CycleMode == APCI1710_SINGLE) || (b_CycleMode == APCI1710_CONTINUOUS)) */ - else { - /***********************************************/ - /* Chronometer acquisition mode cycle is wrong */ - /***********************************************/ - - DPRINTK("Chronometer acquisition mode cycle is wrong\n"); - i_ReturnValue = -5; - } /* if ((b_CycleMode == APCI1710_SINGLE) || (b_CycleMode == APCI1710_CONTINUOUS)) */ - break; - - case APCI1710_DISABLE: - - devpriv->s_ModuleInfo[b_ModulNbr]. - s_ChronoModuleInfo. - b_InterruptMask = 0; - - devpriv->s_ModuleInfo[b_ModulNbr]. - s_ChronoModuleInfo. - dw_ConfigReg = - devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_ChronoModuleInfo. - dw_ConfigReg & 0x2F; - - /***************************/ - /* Disable the interrupt */ - /* Disable the chronometer */ - /***************************/ - - outl(devpriv->s_ModuleInfo[b_ModulNbr]. - s_ChronoModuleInfo.dw_ConfigReg, - devpriv->s_BoardInfos. - ui_Address + 16 + - (64 * b_ModulNbr)); - - /***************************/ - /* Test if continuous mode */ - /***************************/ - - if (devpriv->s_ModuleInfo[b_ModulNbr]. - s_ChronoModuleInfo. - b_CycleMode == - APCI1710_CONTINUOUS) { - /*************************/ - /* Clear status register */ - /*************************/ - - outl(0, devpriv->s_BoardInfos. - ui_Address + 36 + - (64 * b_ModulNbr)); - } - break; - - default: - DPRINTK("Inputs wrong! Enable or Disable chrono\n"); - i_ReturnValue = -8; - } /* switch ENABLE/DISABLE */ - } else { - /*******************************/ - /* Chronometer not initialised */ - /*******************************/ - - DPRINTK("Chronometer not initialised\n"); - i_ReturnValue = -4; - } - } else { - /******************************************/ - /* The module is not a Chronometer module */ - /******************************************/ - - DPRINTK("The module is not a Chronometer module\n"); - i_ReturnValue = -3; - } - } else { - /***********************/ - /* Module number error */ - /***********************/ - - DPRINTK("Module number error\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_GetChronoProgressStatus | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char *_ pb_ChronoStatus) | -+----------------------------------------------------------------------------+ -| Task : Return the chronometer status (pb_ChronoStatus) from | -| selected chronometer module (b_ModulNbr). | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr : Selected module number (0 to 3) | -+----------------------------------------------------------------------------+ -| Output Parameters : PULONG_ pb_ChronoStatus : Return the chronometer | -| status. | -| 0 : Measurement not started.| -| No start signal occur. | -| 1 : Measurement started. | -| A start signal occur. | -| 2 : Measurement stopped. | -| A stop signal occur. | -| The measurement is | -| terminate. | -| 3: A overflow occur. You | -| must change the base | -| timing witch the | -| function | -| "i_APCI1710_InitChrono" | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: Module selection wrong | -| -3: The module is not a Chronometer module | -| -4: Chronometer not initialised see function | -| "i_APCI1710_InitChrono" | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_GetChronoProgressStatus(struct comedi_device *dev, - unsigned char b_ModulNbr, - unsigned char *pb_ChronoStatus) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - unsigned int dw_Status; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /***********************/ - /* Test if chronometer */ - /***********************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[b_ModulNbr] & - 0xFFFF0000UL) == APCI1710_CHRONOMETER) { - /***********************************/ - /* Test if chronometer initialised */ - /***********************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_ChronoModuleInfo.b_ChronoInit == 1) { - - dw_Status = inl(devpriv->s_BoardInfos. - ui_Address + 8 + (64 * b_ModulNbr)); - - /********************/ - /* Test if overflow */ - /********************/ - - if ((dw_Status & 8) == 8) { - /******************/ - /* Overflow occur */ - /******************/ - - *pb_ChronoStatus = 3; - } /* if ((dw_Status & 8) == 8) */ - else { - /*******************************/ - /* Test if measurement stopped */ - /*******************************/ - - if ((dw_Status & 2) == 2) { - /***********************/ - /* A stop signal occur */ - /***********************/ - - *pb_ChronoStatus = 2; - } /* if ((dw_Status & 2) == 2) */ - else { - /*******************************/ - /* Test if measurement started */ - /*******************************/ - - if ((dw_Status & 1) == 1) { - /************************/ - /* A start signal occur */ - /************************/ - - *pb_ChronoStatus = 1; - } /* if ((dw_Status & 1) == 1) */ - else { - /***************************/ - /* Measurement not started */ - /***************************/ - - *pb_ChronoStatus = 0; - } /* if ((dw_Status & 1) == 1) */ - } /* if ((dw_Status & 2) == 2) */ - } /* if ((dw_Status & 8) == 8) */ - } else { - /*******************************/ - /* Chronometer not initialised */ - /*******************************/ - DPRINTK("Chronometer not initialised\n"); - i_ReturnValue = -4; - } - } else { - /******************************************/ - /* The module is not a Chronometer module */ - /******************************************/ - DPRINTK("The module is not a Chronometer module\n"); - i_ReturnValue = -3; - } - } else { - /***********************/ - /* Module number error */ - /***********************/ - DPRINTK("Module number error\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_ReadChronoValue | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned int_ ui_TimeOut, | -| unsigned char *_ pb_ChronoStatus, | -| PULONG_ pul_ChronoValue) | -+----------------------------------------------------------------------------+ -| Task : Return the chronometer status (pb_ChronoStatus) and the| -| timing value (pul_ChronoValue) after a stop signal | -| occur from selected chronometer module (b_ModulNbr). | -| This function are only avaible if you have disabled | -| the interrupt functionality. See function | -| "i_APCI1710_EnableChrono" and the Interrupt mask | -| description chapter. | -| You can test the chronometer status witch the | -| "i_APCI1710_GetChronoProgressStatus" function. | -| | -| The returned value from pul_ChronoValue parameter is | -| not real measured timing. | -| You must used the "i_APCI1710_ConvertChronoValue" | -| function or make this operation for calculate the | -| timing: | -| | -| Timing = pul_ChronoValue * pul_RealTimingInterval. | -| | -| pul_RealTimingInterval is the returned parameter from | -| "i_APCI1710_InitChrono" function and the time unity is | -| the b_TimingUnit from "i_APCI1710_InitChrono" function| -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr : Selected module number (0 to 3) | -+----------------------------------------------------------------------------+ -| Output Parameters : PULONG_ pb_ChronoStatus : Return the chronometer | -| status. | -| 0 : Measurement not started.| -| No start signal occur. | -| 1 : Measurement started. | -| A start signal occur. | -| 2 : Measurement stopped. | -| A stop signal occur. | -| The measurement is | -| terminate. | -| 3: A overflow occur. You | -| must change the base | -| timing witch the | -| function | -| "i_APCI1710_InitChrono" | -| unsigned int * pul_ChronoValue : Chronometer timing value. | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: Module selection wrong | -| -3: The module is not a Chronometer module | -| -4: Chronometer not initialised see function | -| "i_APCI1710_InitChrono" | -| -5: Timeout parameter is wrong (0 to 65535) | -| -6: Interrupt routine installed. You can not read | -| directly the chronometer measured timing. | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_ReadChronoValue(struct comedi_device *dev, - unsigned char b_ModulNbr, - unsigned int ui_TimeOut, - unsigned char *pb_ChronoStatus, - unsigned int *pul_ChronoValue) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - unsigned int dw_Status; - unsigned int dw_TimeOut = 0; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /***********************/ - /* Test if chronometer */ - /***********************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[b_ModulNbr] & - 0xFFFF0000UL) == APCI1710_CHRONOMETER) { - /***********************************/ - /* Test if chronometer initialised */ - /***********************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_ChronoModuleInfo.b_ChronoInit == 1) { - /*****************************/ - /* Test the timout parameter */ - /*****************************/ - - if (ui_TimeOut <= 65535UL) { - - for (;;) { - /*******************/ - /* Read the status */ - /*******************/ - - dw_Status = - inl(devpriv-> - s_BoardInfos. - ui_Address + 8 + - (64 * b_ModulNbr)); - - /********************/ - /* Test if overflow */ - /********************/ - - if ((dw_Status & 8) == 8) { - /******************/ - /* Overflow occur */ - /******************/ - - *pb_ChronoStatus = 3; - - /***************************/ - /* Test if continuous mode */ - /***************************/ - - if (devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_ChronoModuleInfo. - b_CycleMode == - APCI1710_CONTINUOUS) - { - /*************************/ - /* Clear status register */ - /*************************/ - - outl(0, devpriv->s_BoardInfos.ui_Address + 36 + (64 * b_ModulNbr)); - } - - break; - } /* if ((dw_Status & 8) == 8) */ - else { - /*******************************/ - /* Test if measurement stopped */ - /*******************************/ - - if ((dw_Status & 2) == - 2) { - /***********************/ - /* A stop signal occur */ - /***********************/ - - *pb_ChronoStatus - = 2; - - /***************************/ - /* Test if continnous mode */ - /***************************/ - - if (devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_ChronoModuleInfo. - b_CycleMode - == - APCI1710_CONTINUOUS) - { - /*************************/ - /* Clear status register */ - /*************************/ - - outl(0, devpriv->s_BoardInfos.ui_Address + 36 + (64 * b_ModulNbr)); - } - break; - } /* if ((dw_Status & 2) == 2) */ - else { - /*******************************/ - /* Test if measurement started */ - /*******************************/ - - if ((dw_Status & 1) == 1) { - /************************/ - /* A start signal occur */ - /************************/ - - *pb_ChronoStatus - = - 1; - } /* if ((dw_Status & 1) == 1) */ - else { - /***************************/ - /* Measurement not started */ - /***************************/ - - *pb_ChronoStatus - = - 0; - } /* if ((dw_Status & 1) == 1) */ - } /* if ((dw_Status & 2) == 2) */ - } /* if ((dw_Status & 8) == 8) */ - - if (dw_TimeOut == ui_TimeOut) { - /*****************/ - /* Timeout occur */ - /*****************/ - - break; - } else { - /*************************/ - /* Increment the timeout */ - /*************************/ - - dw_TimeOut = - dw_TimeOut + 1; - mdelay(1000); - - } - } /* for (;;) */ - - /*****************************/ - /* Test if stop signal occur */ - /*****************************/ - - if (*pb_ChronoStatus == 2) { - /**********************************/ - /* Read the measured timing value */ - /**********************************/ - - *pul_ChronoValue = - inl(devpriv-> - s_BoardInfos. - ui_Address + 4 + - (64 * b_ModulNbr)); - - if (*pul_ChronoValue != 0) { - *pul_ChronoValue = - *pul_ChronoValue - - 1; - } - } else { - /*************************/ - /* Test if timeout occur */ - /*************************/ - - if ((*pb_ChronoStatus != 3) - && (dw_TimeOut == - ui_TimeOut) - && (ui_TimeOut != 0)) { - /*****************/ - /* Timeout occur */ - /*****************/ - - *pb_ChronoStatus = 4; - } - } - - } else { - /******************************/ - /* Timeout parameter is wrong */ - /******************************/ - DPRINTK("Timeout parameter is wrong\n"); - i_ReturnValue = -5; - } - } else { - /*******************************/ - /* Chronometer not initialised */ - /*******************************/ - DPRINTK("Chronometer not initialised\n"); - i_ReturnValue = -4; - } - } else { - /******************************************/ - /* The module is not a Chronometer module */ - /******************************************/ - DPRINTK("The module is not a Chronometer module\n"); - i_ReturnValue = -3; - } - } else { - /***********************/ - /* Module number error */ - /***********************/ - DPRINTK("Module number error\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_ConvertChronoValue | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| ULONG_ ul_ChronoValue, | -| PULONG_ pul_Hour, | -| unsigned char *_ pb_Minute, | -| unsigned char *_ pb_Second, | -| unsigned int *_ pui_MilliSecond, | -| unsigned int *_ pui_MicroSecond, | -| unsigned int *_ pui_NanoSecond) | -+----------------------------------------------------------------------------+ -| Task : Convert the chronometer measured timing | -| (ul_ChronoValue) in to h, mn, s, ms, µs, ns. | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr : Selected module number (0 to 3)| -| ULONG_ ul_ChronoValue : Measured chronometer timing | -| value. | -| See"i_APCI1710_ReadChronoValue"| -+----------------------------------------------------------------------------+ -| Output Parameters : PULONG_ pul_Hour : Chronometer timing hour | -| unsigned char *_ pb_Minute : Chronometer timing minute | -| unsigned char *_ pb_Second : Chronometer timing second | -| unsigned int *_ pui_MilliSecond : Chronometer timing mini | -| second | -| unsigned int *_ pui_MicroSecond : Chronometer timing micro | -| second | -| unsigned int *_ pui_NanoSecond : Chronometer timing nano | -| second | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: Module selection wrong | -| -3: The module is not a Chronometer module | -| -4: Chronometer not initialised see function | -| "i_APCI1710_InitChrono" | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_ConvertChronoValue(struct comedi_device *dev, - unsigned char b_ModulNbr, - unsigned int ul_ChronoValue, - unsigned int *pul_Hour, - unsigned char *pb_Minute, - unsigned char *pb_Second, - unsigned int *pui_MilliSecond, - unsigned int *pui_MicroSecond, - unsigned int *pui_NanoSecond) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - double d_Hour; - double d_Minute; - double d_Second; - double d_MilliSecond; - double d_MicroSecond; - double d_NanoSecond; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /***********************/ - /* Test if chronometer */ - /***********************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[b_ModulNbr] & - 0xFFFF0000UL) == APCI1710_CHRONOMETER) { - /***********************************/ - /* Test if chronometer initialised */ - /***********************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_ChronoModuleInfo.b_ChronoInit == 1) { - fpu_begin(); - - d_Hour = (double)ul_ChronoValue *(double) - devpriv->s_ModuleInfo[b_ModulNbr]. - s_ChronoModuleInfo.d_TimingInterval; - - switch (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_ChronoModuleInfo.b_TimingUnit) { - case 0: - d_Hour = d_Hour / (double)1000.0; - - case 1: - d_Hour = d_Hour / (double)1000.0; - - case 2: - d_Hour = d_Hour / (double)1000.0; - - case 3: - d_Hour = d_Hour / (double)60.0; - - case 4: - /**********************/ - /* Calculate the hour */ - /**********************/ - - d_Hour = d_Hour / (double)60.0; - *pul_Hour = (unsigned int) d_Hour; - - /************************/ - /* Calculate the minute */ - /************************/ - - d_Minute = d_Hour - *pul_Hour; - d_Minute = d_Minute * 60; - *pb_Minute = (unsigned char) d_Minute; - - /************************/ - /* Calculate the second */ - /************************/ - - d_Second = d_Minute - *pb_Minute; - d_Second = d_Second * 60; - *pb_Second = (unsigned char) d_Second; - - /*****************************/ - /* Calculate the mini second */ - /*****************************/ - - d_MilliSecond = d_Second - *pb_Second; - d_MilliSecond = d_MilliSecond * 1000; - *pui_MilliSecond = (unsigned int) d_MilliSecond; - - /******************************/ - /* Calculate the micro second */ - /******************************/ - - d_MicroSecond = - d_MilliSecond - - *pui_MilliSecond; - d_MicroSecond = d_MicroSecond * 1000; - *pui_MicroSecond = (unsigned int) d_MicroSecond; - - /******************************/ - /* Calculate the micro second */ - /******************************/ - - d_NanoSecond = - d_MicroSecond - - *pui_MicroSecond; - d_NanoSecond = d_NanoSecond * 1000; - *pui_NanoSecond = (unsigned int) d_NanoSecond; - break; - } - - fpu_end(); - } else { - /*******************************/ - /* Chronometer not initialised */ - /*******************************/ - DPRINTK("Chronometer not initialised\n"); - i_ReturnValue = -4; - } - } else { - /******************************************/ - /* The module is not a Chronometer module */ - /******************************************/ - DPRINTK("The module is not a Chronometer module\n"); - i_ReturnValue = -3; - } - } else { - /***********************/ - /* Module number error */ - /***********************/ - DPRINTK("Module number error\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name :INT i_APCI1710_InsnReadChrono(struct comedi_device *dev,struct comedi_subdevice *s, -struct comedi_insn *insn,unsigned int *data) | -+----------------------------------------------------------------------------+ -| Task : Read functions for Timer | -+----------------------------------------------------------------------------+ -| Input Parameters : -+----------------------------------------------------------------------------+ -| Output Parameters : - | -+----------------------------------------------------------------------------+ -| Return Value : -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_InsnReadChrono(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - unsigned char b_ReadType; - int i_ReturnValue = insn->n; - - b_ReadType = CR_CHAN(insn->chanspec); - - switch (b_ReadType) { - case APCI1710_CHRONO_PROGRESS_STATUS: - i_ReturnValue = i_APCI1710_GetChronoProgressStatus(dev, - (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]); - break; - - case APCI1710_CHRONO_READVALUE: - i_ReturnValue = i_APCI1710_ReadChronoValue(dev, - (unsigned char) CR_AREF(insn->chanspec), - (unsigned int) insn->unused[0], - (unsigned char *) &data[0], (unsigned int *) &data[1]); - break; - - case APCI1710_CHRONO_CONVERTVALUE: - i_ReturnValue = i_APCI1710_ConvertChronoValue(dev, - (unsigned char) CR_AREF(insn->chanspec), - (unsigned int) insn->unused[0], - (unsigned int *) &data[0], - (unsigned char *) &data[1], - (unsigned char *) &data[2], - (unsigned int *) &data[3], - (unsigned int *) &data[4], (unsigned int *) &data[5]); - break; - - case APCI1710_CHRONO_READINTERRUPT: - printk("In Chrono Read Interrupt\n"); - - data[0] = devpriv->s_InterruptParameters. - s_FIFOInterruptParameters[devpriv-> - s_InterruptParameters.ui_Read].b_OldModuleMask; - data[1] = devpriv->s_InterruptParameters. - s_FIFOInterruptParameters[devpriv-> - s_InterruptParameters.ui_Read].ul_OldInterruptMask; - data[2] = devpriv->s_InterruptParameters. - s_FIFOInterruptParameters[devpriv-> - s_InterruptParameters.ui_Read].ul_OldCounterLatchValue; - - /**************************/ - /* Increment the read FIFO */ - /***************************/ - - devpriv-> - s_InterruptParameters. - ui_Read = (devpriv-> - s_InterruptParameters. - ui_Read + 1) % APCI1710_SAVE_INTERRUPT; - break; - - default: - printk("ReadType Parameter wrong\n"); - } - - if (i_ReturnValue >= 0) - i_ReturnValue = insn->n; - return i_ReturnValue; - -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : int i_APCI1710_InsnBitsChronoDigitalIO(struct comedi_device *dev,struct comedi_subdevice *s, - struct comedi_insn *insn,unsigned int *data) | -+----------------------------------------------------------------------------+ -| Task : Sets the output witch has been passed with the | -| parameter b_Channel. Setting an output means setting an| -| output high. | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr : Selected module number (0 to 3)| -| unsigned char_ b_OutputChannel : Selection from digital output | -| CR_CHAN() channel (0 to 2) | -| 0 : Channel H | -| 1 : Channel A | -| 2 : Channel B | -+----------------------------------------------------------------------------+ -| Output Parameters : - | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: Module selection wrong | -| -3: The module is not a Chronometer module | -| -4: The selected digital output is wrong | -| -5: Chronometer not initialised see function | -| "i_APCI1710_InitChrono" | -+----------------------------------------------------------------------------+ -*/ - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_SetChronoChlOff | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char_ b_OutputChannel) | -+----------------------------------------------------------------------------+ -| Task : Resets the output witch has been passed with the | -| parameter b_Channel. Resetting an output means setting | -| an output low. | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 - data[0] : Chl ON, Chl OFF , Chl Read , Port Read - -| unsigned char_ b_ModulNbr CR_AREF : Selected module number (0 to 3)| -| unsigned char_ b_OutputChannel CR_CHAN : Selection from digital output | -| channel (0 to 2) | -| 0 : Channel H | -| 1 : Channel A | -| 2 : Channel B | -+----------------------------------------------------------------------------+ -| Output Parameters : - | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: Module selection wrong | -| -3: The module is not a Chronometer module | -| -4: The selected digital output is wrong | -| -5: Chronometer not initialised see function | -| "i_APCI1710_InitChrono" | -+----------------------------------------------------------------------------+ -*/ - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_ReadChronoChlValue | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char_ b_InputChannel, | -| unsigned char *_ pb_ChannelStatus) | -+----------------------------------------------------------------------------+ -| Task : Return the status from selected digital input | -| (b_InputChannel) from selected chronometer | -| module (b_ModulNbr). | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr : Selected module number (0 to 3)| -| unsigned char_ b_InputChannel : Selection from digital input | -| channel (0 to 2) | -| CR_CHAN() 0 : Channel E | -| 1 : Channel F | -| 2 : Channel G | -+----------------------------------------------------------------------------+ -| Output Parameters : unsigned char *_ pb_ChannelStatus : Digital input channel status.| -| data[0] 0 : Channel is not active | -| 1 : Channel is active | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: Module selection wrong | -| -3: The module is not a Chronometer module | -| -4: The selected digital input is wrong | -| -5: Chronometer not initialised see function | -| "i_APCI1710_InitChrono" | -+----------------------------------------------------------------------------+ -*/ - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_ReadChronoPortValue | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char *_ pb_PortValue) | -+----------------------------------------------------------------------------+ -| Task : Return the status from digital inputs port from | -| selected (b_ModulNbr) chronometer module. | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr : Selected module number (0 to 3)| -+----------------------------------------------------------------------------+ -| Output Parameters : unsigned char *_ pb_PortValue : Digital inputs port status. -| data[0] -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: Module selection wrong | -| -3: The module is not a Chronometer module | -| -4: Chronometer not initialised see function | -| "i_APCI1710_InitChrono" | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_InsnBitsChronoDigitalIO(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - unsigned char b_ModulNbr, b_OutputChannel, b_InputChannel, b_IOType; - unsigned int dw_Status; - unsigned char *pb_ChannelStatus; - unsigned char *pb_PortValue; - - b_ModulNbr = CR_AREF(insn->chanspec); - i_ReturnValue = insn->n; - b_IOType = (unsigned char) data[0]; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /***********************/ - /* Test if chronometer */ - /***********************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[b_ModulNbr] & - 0xFFFF0000UL) == APCI1710_CHRONOMETER) { - /***********************************/ - /* Test if chronometer initialised */ - /***********************************/ - - if (devpriv->s_ModuleInfo[b_ModulNbr]. - s_ChronoModuleInfo.b_ChronoInit == 1) { - /***********************************/ - /* Test the digital output channel */ - /***********************************/ - switch (b_IOType) { - - case APCI1710_CHRONO_SET_CHANNELOFF: - - b_OutputChannel = - (unsigned char) CR_CHAN(insn->chanspec); - if (b_OutputChannel <= 2) { - - outl(0, devpriv->s_BoardInfos. - ui_Address + 20 + - (b_OutputChannel * 4) + - (64 * b_ModulNbr)); - } /* if ((b_OutputChannel >= 0) && (b_OutputChannel <= 2)) */ - else { - /****************************************/ - /* The selected digital output is wrong */ - /****************************************/ - - DPRINTK("The selected digital output is wrong\n"); - i_ReturnValue = -4; - - } /* if ((b_OutputChannel >= 0) && (b_OutputChannel <= 2)) */ - - break; - - case APCI1710_CHRONO_SET_CHANNELON: - - b_OutputChannel = - (unsigned char) CR_CHAN(insn->chanspec); - if (b_OutputChannel <= 2) { - - outl(1, devpriv->s_BoardInfos. - ui_Address + 20 + - (b_OutputChannel * 4) + - (64 * b_ModulNbr)); - } /* if ((b_OutputChannel >= 0) && (b_OutputChannel <= 2)) */ - else { - /****************************************/ - /* The selected digital output is wrong */ - /****************************************/ - - DPRINTK("The selected digital output is wrong\n"); - i_ReturnValue = -4; - - } /* if ((b_OutputChannel >= 0) && (b_OutputChannel <= 2)) */ - - break; - - case APCI1710_CHRONO_READ_CHANNEL: - /**********************************/ - /* Test the digital input channel */ - /**********************************/ - pb_ChannelStatus = (unsigned char *) &data[0]; - b_InputChannel = - (unsigned char) CR_CHAN(insn->chanspec); - - if (b_InputChannel <= 2) { - - dw_Status = - inl(devpriv-> - s_BoardInfos. - ui_Address + 12 + - (64 * b_ModulNbr)); - - *pb_ChannelStatus = - (unsigned char) (((dw_Status >> - b_InputChannel) - & 1) ^ 1); - } /* if ((b_InputChannel >= 0) && (b_InputChannel <= 2)) */ - else { - /***************************************/ - /* The selected digital input is wrong */ - /***************************************/ - - DPRINTK("The selected digital input is wrong\n"); - i_ReturnValue = -4; - } /* if ((b_InputChannel >= 0) && (b_InputChannel <= 2)) */ - - break; - - case APCI1710_CHRONO_READ_PORT: - - pb_PortValue = (unsigned char *) &data[0]; - - dw_Status = - inl(devpriv->s_BoardInfos. - ui_Address + 12 + - (64 * b_ModulNbr)); - - *pb_PortValue = - (unsigned char) ((dw_Status & 0x7) ^ 7); - break; - } - } else { - /*******************************/ - /* Chronometer not initialised */ - /*******************************/ - - DPRINTK("Chronometer not initialised\n"); - i_ReturnValue = -5; - } - } else { - /******************************************/ - /* The module is not a Chronometer module */ - /******************************************/ - - DPRINTK("The module is not a Chronometer module\n"); - i_ReturnValue = -3; - } - } else { - /***********************/ - /* Module number error */ - /***********************/ - - DPRINTK("Module number error\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Dig_io.c b/drivers/staging/comedi/drivers/addi-data/APCI1710_Dig_io.c deleted file mode 100644 index 7d1883a0da286..0000000000000 --- a/drivers/staging/comedi/drivers/addi-data/APCI1710_Dig_io.c +++ /dev/null @@ -1,1037 +0,0 @@ -/** -@verbatim - -Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. - - ADDI-DATA GmbH - Dieselstrasse 3 - D-77833 Ottersweier - Tel: +19(0)7223/9493-0 - Fax: +49(0)7223/9493-92 - http://www.addi-data.com - info@addi-data.com - -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 the License, or (at your option) any later version. - -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. - -@endverbatim -*/ -/* - - +-----------------------------------------------------------------------+ - | (C) ADDI-DATA GmbH Dieselstraße 3 D-77833 Ottersweier | - +-----------------------------------------------------------------------+ - | Tel : +49 (0) 7223/9493-0 | email : info@addi-data.com | - | Fax : +49 (0) 7223/9493-92 | Internet : http://www.addi-data.com | - +-----------------------------------------------------------------------+ - | Project : API APCI1710 | Compiler : gcc | - | Module name : DIG_IO.C | Version : 2.96 | - +-------------------------------+---------------------------------------+ - | Project manager: Eric Stolz | Date : 02/12/2002 | - +-----------------------------------------------------------------------+ - | Description : APCI-1710 digital I/O module | - | | - | | - +-----------------------------------------------------------------------+ - | UPDATES | - +-----------------------------------------------------------------------+ - | Date | Author | Description of updates | - +----------+-----------+------------------------------------------------+ - | 16/06/98 | S. Weber | Digital input / output implementation | - |----------|-----------|------------------------------------------------| - | 08/05/00 | Guinot C | - 0400/0228 All Function in RING 0 | - | | | available | - +-----------------------------------------------------------------------+ - | | | | - | | | | - +-----------------------------------------------------------------------+ -*/ - -/* Digital Output ON or OFF */ -#define APCI1710_ON 1 -#define APCI1710_OFF 0 - -/* Digital I/O */ -#define APCI1710_INPUT 0 -#define APCI1710_OUTPUT 1 - -#define APCI1710_DIGIO_MEMORYONOFF 0x10 -#define APCI1710_DIGIO_INIT 0x11 - -/* -+----------------------------------------------------------------------------+ -| Function Name : int i_APCI1710_InsnConfigDigitalIO(struct comedi_device *dev, | -| struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data)| -+----------------------------------------------------------------------------+ -| Task : Configure the digital I/O operating mode from selected | -| module (b_ModulNbr). You must calling this function be| -| for you call any other function witch access of digital| -| I/O. | -+----------------------------------------------------------------------------+ -| Input Parameters : | -| unsigned char_ b_ModulNbr data[0]: Module number to | -| configure (0 to 3) | -| unsigned char_ b_ChannelAMode data[1] : Channel A mode selection | -| 0 : Channel used for digital | -| input | -| 1 : Channel used for digital | -| output | -| unsigned char_ b_ChannelBMode data[2] : Channel B mode selection | -| 0 : Channel used for digital | -| input | -| 1 : Channel used for digital | -| output | - data[0] memory on/off -Activates and deactivates the digital output memory. - After having | -| called up this function with memory on,the output you have previously| -| activated with the function are not reset -+----------------------------------------------------------------------------+ -| Output Parameters : - | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: The module parameter is wrong | -| -3: The module is not a digital I/O module | -| -4: Bi-directional channel A configuration error | -| -5: Bi-directional channel B configuration error | -+----------------------------------------------------------------------------+ -*/ - -static int i_APCI1710_InsnConfigDigitalIO(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - unsigned char b_ModulNbr, b_ChannelAMode, b_ChannelBMode; - unsigned char b_MemoryOnOff, b_ConfigType; - int i_ReturnValue = 0; - unsigned int dw_WriteConfig = 0; - - b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec); - b_ConfigType = (unsigned char) data[0]; /* Memory or Init */ - b_ChannelAMode = (unsigned char) data[1]; - b_ChannelBMode = (unsigned char) data[2]; - b_MemoryOnOff = (unsigned char) data[1]; /* if memory operation */ - i_ReturnValue = insn->n; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr >= 4) { - DPRINTK("Module Number invalid\n"); - i_ReturnValue = -2; - return i_ReturnValue; - } - switch (b_ConfigType) { - case APCI1710_DIGIO_MEMORYONOFF: - - if (b_MemoryOnOff) /* If Memory ON */ - { - /****************************/ - /* Set the output memory on */ - /****************************/ - - devpriv->s_ModuleInfo[b_ModulNbr]. - s_DigitalIOInfo.b_OutputMemoryEnabled = 1; - - /***************************/ - /* Clear the output memory */ - /***************************/ - devpriv->s_ModuleInfo[b_ModulNbr]. - s_DigitalIOInfo.dw_OutputMemory = 0; - } else /* If memory off */ - { - /*****************************/ - /* Set the output memory off */ - /*****************************/ - - devpriv->s_ModuleInfo[b_ModulNbr]. - s_DigitalIOInfo.b_OutputMemoryEnabled = 0; - } - break; - - case APCI1710_DIGIO_INIT: - - /*******************************/ - /* Test if digital I/O counter */ - /*******************************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[b_ModulNbr] & - 0xFFFF0000UL) == APCI1710_DIGITAL_IO) { - - /***************************************************/ - /* Test the bi-directional channel A configuration */ - /***************************************************/ - - if ((b_ChannelAMode == 0) || (b_ChannelAMode == 1)) { - /***************************************************/ - /* Test the bi-directional channel B configuration */ - /***************************************************/ - - if ((b_ChannelBMode == 0) - || (b_ChannelBMode == 1)) { - devpriv->s_ModuleInfo[b_ModulNbr]. - s_DigitalIOInfo.b_DigitalInit = - 1; - - /********************************/ - /* Save channel A configuration */ - /********************************/ - - devpriv->s_ModuleInfo[b_ModulNbr]. - s_DigitalIOInfo. - b_ChannelAMode = b_ChannelAMode; - - /********************************/ - /* Save channel B configuration */ - /********************************/ - - devpriv->s_ModuleInfo[b_ModulNbr]. - s_DigitalIOInfo. - b_ChannelBMode = b_ChannelBMode; - - /*****************************************/ - /* Set the channel A and B configuration */ - /*****************************************/ - - dw_WriteConfig = - (unsigned int) (b_ChannelAMode | - (b_ChannelBMode * 2)); - - /***************************/ - /* Write the configuration */ - /***************************/ - - outl(dw_WriteConfig, - devpriv->s_BoardInfos. - ui_Address + 4 + - (64 * b_ModulNbr)); - - } else { - /************************************************/ - /* Bi-directional channel B configuration error */ - /************************************************/ - DPRINTK("Bi-directional channel B configuration error\n"); - i_ReturnValue = -5; - } - - } else { - /************************************************/ - /* Bi-directional channel A configuration error */ - /************************************************/ - DPRINTK("Bi-directional channel A configuration error\n"); - i_ReturnValue = -4; - - } - - } else { - /******************************************/ - /* The module is not a digital I/O module */ - /******************************************/ - DPRINTK("The module is not a digital I/O module\n"); - i_ReturnValue = -3; - } - } /* end of Switch */ - printk("Return Value %d\n", i_ReturnValue); - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| INPUT FUNCTIONS | -+----------------------------------------------------------------------------+ -*/ - -/* -+----------------------------------------------------------------------------+ - -|INT i_APCI1710_InsnReadDigitalIOChlValue(struct comedi_device *dev,comedi_subdevice -*s, struct comedi_insn *insn,unsigned int *data) - -+----------------------------------------------------------------------------+ -| Task : Read the status from selected digital I/O digital input| -| (b_InputChannel) | -+----------------------------------------------------------------------------| - - -| -| unsigned char_ b_ModulNbr CR_AREF(chanspec) : Selected module number | -| (0 to 3) | -| unsigned char_ b_InputChannel CR_CHAN(chanspec) : Selection from digital | -| input ( 0 to 6) | -| 0 : Channel C | -| 1 : Channel D | -| 2 : Channel E | -| 3 : Channel F | -| 4 : Channel G | -| 5 : Channel A | -| 6 : Channel B - - - | -+----------------------------------------------------------------------------+ -| Output Parameters : data[0] : Digital input channel | -| status | -| 0 : Channle is not active| -| 1 : Channle is active | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: The module parameter is wrong | -| -3: The module is not a digital I/O module | -| -4: The selected digital I/O digital input is wrong | -| -5: Digital I/O not initialised | -| -6: The digital channel A is used for output | -| -7: The digital channel B is used for output | -+----------------------------------------------------------------------------+ -*/ - -/* _INT_ i_APCI1710_ReadDigitalIOChlValue (unsigned char_ b_BoardHandle, */ -/* -* unsigned char_ b_ModulNbr, unsigned char_ b_InputChannel, -* unsigned char *_ pb_ChannelStatus) -*/ -static int i_APCI1710_InsnReadDigitalIOChlValue(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - unsigned int dw_StatusReg; - unsigned char b_ModulNbr, b_InputChannel; - unsigned char *pb_ChannelStatus; - b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec); - b_InputChannel = (unsigned char) CR_CHAN(insn->chanspec); - data[0] = 0; - pb_ChannelStatus = (unsigned char *) &data[0]; - i_ReturnValue = insn->n; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /*******************************/ - /* Test if digital I/O counter */ - /*******************************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[b_ModulNbr] & - 0xFFFF0000UL) == APCI1710_DIGITAL_IO) { - /******************************************/ - /* Test the digital imnput channel number */ - /******************************************/ - - if (b_InputChannel <= 6) { - /**********************************************/ - /* Test if the digital I/O module initialised */ - /**********************************************/ - - if (devpriv->s_ModuleInfo[b_ModulNbr]. - s_DigitalIOInfo.b_DigitalInit == 1) { - /**********************************/ - /* Test if channel A or channel B */ - /**********************************/ - - if (b_InputChannel > 4) { - /*********************/ - /* Test if channel A */ - /*********************/ - - if (b_InputChannel == 5) { - /***************************/ - /* Test the channel A mode */ - /***************************/ - - if (devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_DigitalIOInfo. - b_ChannelAMode - != 0) { - /********************************************/ - /* The digital channel A is used for output */ - /********************************************/ - - i_ReturnValue = - -6; - } - } /* if (b_InputChannel == 5) */ - else { - /***************************/ - /* Test the channel B mode */ - /***************************/ - - if (devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_DigitalIOInfo. - b_ChannelBMode - != 0) { - /********************************************/ - /* The digital channel B is used for output */ - /********************************************/ - - i_ReturnValue = - -7; - } - } /* if (b_InputChannel == 5) */ - } /* if (b_InputChannel > 4) */ - - /***********************/ - /* Test if error occur */ - /***********************/ - - if (i_ReturnValue >= 0) { - /**************************/ - /* Read all digital input */ - /**************************/ - -/* -* INPDW (ps_APCI1710Variable-> s_Board [b_BoardHandle]. -* s_BoardInfos. ui_Address + (64 * b_ModulNbr), &dw_StatusReg); -*/ - - dw_StatusReg = - inl(devpriv-> - s_BoardInfos. - ui_Address + - (64 * b_ModulNbr)); - - *pb_ChannelStatus = - (unsigned char) ((dw_StatusReg ^ - 0x1C) >> - b_InputChannel) & 1; - - } /* if (i_ReturnValue == 0) */ - } else { - /*******************************/ - /* Digital I/O not initialised */ - /*******************************/ - DPRINTK("Digital I/O not initialised\n"); - i_ReturnValue = -5; - } - } else { - /********************************/ - /* Selected digital input error */ - /********************************/ - DPRINTK("Selected digital input error\n"); - i_ReturnValue = -4; - } - } else { - /******************************************/ - /* The module is not a digital I/O module */ - /******************************************/ - DPRINTK("The module is not a digital I/O module\n"); - i_ReturnValue = -3; - } - } else { - /***********************/ - /* Module number error */ - /***********************/ - DPRINTK("Module number error\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| OUTPUT FUNCTIONS | -+----------------------------------------------------------------------------+ -*/ - -/* -+----------------------------------------------------------------------------+ -| Function Name : int i_APCI1710_InsnWriteDigitalIOChlOnOff(comedi_device -|*dev,struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data) - -+----------------------------------------------------------------------------+ -| Task : Sets or resets the output witch has been passed with the | -| parameter b_Channel. Setting an output means setting | -| an ouput high. | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr (aref ) : Selected module number (0 to 3)| -| unsigned char_ b_OutputChannel (CR_CHAN) : Selection from digital output | -| channel (0 to 2) | -| 0 : Channel H | -| 1 : Channel A | -| 2 : Channel B | -+----------------------------------------------------------------------------+ -| Output Parameters : - | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: The module parameter is wrong | -| -3: The module is not a digital I/O module | -| -4: The selected digital output is wrong | -| -5: digital I/O not initialised see function | -| " i_APCI1710_InitDigitalIO" | -| -6: The digital channel A is used for input | -| -7: The digital channel B is used for input - -8: Digital Output Memory OFF. | -| Use previously the function | -| "i_APCI1710_SetDigitalIOMemoryOn". | -+----------------------------------------------------------------------------+ -*/ - -/* -* _INT_ i_APCI1710_SetDigitalIOChlOn (unsigned char_ b_BoardHandle, -* unsigned char_ b_ModulNbr, unsigned char_ b_OutputChannel) -*/ -static int i_APCI1710_InsnWriteDigitalIOChlOnOff(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - unsigned int dw_WriteValue = 0; - unsigned char b_ModulNbr, b_OutputChannel; - i_ReturnValue = insn->n; - b_ModulNbr = CR_AREF(insn->chanspec); - b_OutputChannel = CR_CHAN(insn->chanspec); - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /*******************************/ - /* Test if digital I/O counter */ - /*******************************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[b_ModulNbr] & - 0xFFFF0000UL) == APCI1710_DIGITAL_IO) { - /**********************************************/ - /* Test if the digital I/O module initialised */ - /**********************************************/ - - if (devpriv->s_ModuleInfo[b_ModulNbr]. - s_DigitalIOInfo.b_DigitalInit == 1) { - /******************************************/ - /* Test the digital output channel number */ - /******************************************/ - - switch (b_OutputChannel) { - /*************/ - /* Channel H */ - /*************/ - - case 0: - break; - - /*************/ - /* Channel A */ - /*************/ - - case 1: - if (devpriv->s_ModuleInfo[b_ModulNbr]. - s_DigitalIOInfo. - b_ChannelAMode != 1) { - /*******************************************/ - /* The digital channel A is used for input */ - /*******************************************/ - - i_ReturnValue = -6; - } - break; - - /*************/ - /* Channel B */ - /*************/ - - case 2: - if (devpriv->s_ModuleInfo[b_ModulNbr]. - s_DigitalIOInfo. - b_ChannelBMode != 1) { - /*******************************************/ - /* The digital channel B is used for input */ - /*******************************************/ - - i_ReturnValue = -7; - } - break; - - default: - /****************************************/ - /* The selected digital output is wrong */ - /****************************************/ - - i_ReturnValue = -4; - break; - } - - /***********************/ - /* Test if error occur */ - /***********************/ - - if (i_ReturnValue >= 0) { - - /*********************************/ - /* Test if set channel ON */ - /*********************************/ - if (data[0]) { - /*********************************/ - /* Test if output memory enabled */ - /*********************************/ - - if (devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_DigitalIOInfo. - b_OutputMemoryEnabled == - 1) { - dw_WriteValue = - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_DigitalIOInfo. - dw_OutputMemory - | (1 << - b_OutputChannel); - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_DigitalIOInfo. - dw_OutputMemory - = dw_WriteValue; - } else { - dw_WriteValue = - 1 << - b_OutputChannel; - } - } /* set channel off */ - else { - if (devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_DigitalIOInfo. - b_OutputMemoryEnabled == - 1) { - dw_WriteValue = - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_DigitalIOInfo. - dw_OutputMemory - & (0xFFFFFFFFUL - - - (1 << b_OutputChannel)); - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_DigitalIOInfo. - dw_OutputMemory - = dw_WriteValue; - } else { - /*****************************/ - /* Digital Output Memory OFF */ - /*****************************/ - /* +Use previously the function "i_APCI1710_SetDigitalIOMemoryOn" */ - i_ReturnValue = -8; - } - - } - /*******************/ - /* Write the value */ - /*******************/ - - /* OUTPDW (ps_APCI1710Variable-> - * s_Board [b_BoardHandle]. - * s_BoardInfos. ui_Address + (64 * b_ModulNbr), - * dw_WriteValue); - */ - - outl(dw_WriteValue, - devpriv->s_BoardInfos. - ui_Address + (64 * b_ModulNbr)); - } - } else { - /*******************************/ - /* Digital I/O not initialised */ - /*******************************/ - - i_ReturnValue = -5; - } - } else { - /******************************************/ - /* The module is not a digital I/O module */ - /******************************************/ - - i_ReturnValue = -3; - } - } else { - /***********************/ - /* Module number error */ - /***********************/ - - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ - -|INT i_APCI1710_InsnBitsDigitalIOPortOnOff(struct comedi_device *dev,comedi_subdevice - *s, struct comedi_insn *insn,unsigned int *data) -+----------------------------------------------------------------------------+ -| Task : write: - Sets or resets one or several outputs from port. | -| Setting an output means setting an output high. | -| If you have switched OFF the digital output memory | -| (OFF), all the other output are set to "0". - -| read: - Read the status from digital input port | -| from selected digital I/O module (b_ModulNbr) -+----------------------------------------------------------------------------+ -| Input Parameters : - unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr CR_AREF(aref) : Selected module number (0 to 3)| -| unsigned char_ b_PortValue CR_CHAN(chanspec) : Output Value ( 0 To 7 ) -| data[0] read or write port -| data[1] if write then indicate ON or OFF - -| if read : data[1] will return port status. -+----------------------------------------------------------------------------+ -| Output Parameters : - | -+----------------------------------------------------------------------------+ -| Return Value : - -| INPUT : - - 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: The module parameter is wrong | -| -3: The module is not a digital I/O module | -| -4: Digital I/O not initialised - - OUTPUT: 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: The module parameter is wrong | -| -3: The module is not a digital I/O module | -| -4: Output value wrong | -| -5: digital I/O not initialised see function | -| " i_APCI1710_InitDigitalIO" | -| -6: The digital channel A is used for input | -| -7: The digital channel B is used for input - -8: Digital Output Memory OFF. | -| Use previously the function | -| "i_APCI1710_SetDigitalIOMemoryOn". | -+----------------------------------------------------------------------------+ -*/ - -/* - * _INT_ i_APCI1710_SetDigitalIOPortOn (unsigned char_ - * b_BoardHandle, unsigned char_ b_ModulNbr, unsigned char_ - * b_PortValue) -*/ -static int i_APCI1710_InsnBitsDigitalIOPortOnOff(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - unsigned int dw_WriteValue = 0; - unsigned int dw_StatusReg; - unsigned char b_ModulNbr, b_PortValue; - unsigned char b_PortOperation, b_PortOnOFF; - - unsigned char *pb_PortValue; - - b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec); - b_PortOperation = (unsigned char) data[0]; /* Input or output */ - b_PortOnOFF = (unsigned char) data[1]; /* if output then On or Off */ - b_PortValue = (unsigned char) data[2]; /* if out put then Value */ - i_ReturnValue = insn->n; - pb_PortValue = (unsigned char *) &data[0]; -/* if input then read value */ - - switch (b_PortOperation) { - case APCI1710_INPUT: - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /*******************************/ - /* Test if digital I/O counter */ - /*******************************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[b_ModulNbr] & - 0xFFFF0000UL) == APCI1710_DIGITAL_IO) { - /**********************************************/ - /* Test if the digital I/O module initialised */ - /**********************************************/ - - if (devpriv->s_ModuleInfo[b_ModulNbr]. - s_DigitalIOInfo.b_DigitalInit == 1) { - /**************************/ - /* Read all digital input */ - /**************************/ - - /* INPDW (ps_APCI1710Variable-> - * s_Board [b_BoardHandle]. - * s_BoardInfos. - * ui_Address + (64 * b_ModulNbr), - * &dw_StatusReg); - */ - - dw_StatusReg = - inl(devpriv->s_BoardInfos. - ui_Address + (64 * b_ModulNbr)); - *pb_PortValue = - (unsigned char) (dw_StatusReg ^ 0x1C); - - } else { - /*******************************/ - /* Digital I/O not initialised */ - /*******************************/ - - i_ReturnValue = -4; - } - } else { - /******************************************/ - /* The module is not a digital I/O module */ - /******************************************/ - - i_ReturnValue = -3; - } - } else { - /***********************/ - /* Module number error */ - /***********************/ - - i_ReturnValue = -2; - } - - break; - - case APCI1710_OUTPUT: - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /*******************************/ - /* Test if digital I/O counter */ - /*******************************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[b_ModulNbr] & - 0xFFFF0000UL) == APCI1710_DIGITAL_IO) { - /**********************************************/ - /* Test if the digital I/O module initialised */ - /**********************************************/ - - if (devpriv->s_ModuleInfo[b_ModulNbr]. - s_DigitalIOInfo.b_DigitalInit == 1) { - /***********************/ - /* Test the port value */ - /***********************/ - - if (b_PortValue <= 7) { - /***********************************/ - /* Test the digital output channel */ - /***********************************/ - - /**************************/ - /* Test if channel A used */ - /**************************/ - - if ((b_PortValue & 2) == 2) { - if (devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_DigitalIOInfo. - b_ChannelAMode - != 1) { - /*******************************************/ - /* The digital channel A is used for input */ - /*******************************************/ - - i_ReturnValue = - -6; - } - } /* if ((b_PortValue & 2) == 2) */ - - /**************************/ - /* Test if channel B used */ - /**************************/ - - if ((b_PortValue & 4) == 4) { - if (devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_DigitalIOInfo. - b_ChannelBMode - != 1) { - /*******************************************/ - /* The digital channel B is used for input */ - /*******************************************/ - - i_ReturnValue = - -7; - } - } /* if ((b_PortValue & 4) == 4) */ - - /***********************/ - /* Test if error occur */ - /***********************/ - - if (i_ReturnValue >= 0) { - - /* if(data[1]) { */ - - switch (b_PortOnOFF) { - /*********************************/ - /* Test if set Port ON */ - /*********************************/ - - case APCI1710_ON: - - /*********************************/ - /* Test if output memory enabled */ - /*********************************/ - - if (devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_DigitalIOInfo. - b_OutputMemoryEnabled - == 1) { - dw_WriteValue - = - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_DigitalIOInfo. - dw_OutputMemory - | - b_PortValue; - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_DigitalIOInfo. - dw_OutputMemory - = - dw_WriteValue; - } else { - dw_WriteValue - = - b_PortValue; - } - break; - - /* If Set PORT OFF */ - case APCI1710_OFF: - - /*********************************/ - /* Test if output memory enabled */ - /*********************************/ - - if (devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_DigitalIOInfo. - b_OutputMemoryEnabled - == 1) { - dw_WriteValue - = - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_DigitalIOInfo. - dw_OutputMemory - & - (0xFFFFFFFFUL - - - b_PortValue); - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_DigitalIOInfo. - dw_OutputMemory - = - dw_WriteValue; - } else { - /*****************************/ - /* Digital Output Memory OFF */ - /*****************************/ - - i_ReturnValue - = - -8; - } - } /* switch */ - - /*******************/ - /* Write the value */ - /*******************/ - - /* OUTPDW (ps_APCI1710Variable-> - * s_Board [b_BoardHandle]. - * s_BoardInfos. - * ui_Address + (64 * b_ModulNbr), - * dw_WriteValue); */ - - outl(dw_WriteValue, - devpriv-> - s_BoardInfos. - ui_Address + - (64 * b_ModulNbr)); - } - } else { - /**********************/ - /* Output value wrong */ - /**********************/ - - i_ReturnValue = -4; - } - } else { - /*******************************/ - /* Digital I/O not initialised */ - /*******************************/ - - i_ReturnValue = -5; - } - } else { - /******************************************/ - /* The module is not a digital I/O module */ - /******************************************/ - - i_ReturnValue = -3; - } - } else { - /***********************/ - /* Module number error */ - /***********************/ - - i_ReturnValue = -2; - } - break; - - default: - i_ReturnValue = -9; - DPRINTK("NO INPUT/OUTPUT specified\n"); - } /* switch INPUT / OUTPUT */ - return i_ReturnValue; -} diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_INCCPT.c b/drivers/staging/comedi/drivers/addi-data/APCI1710_INCCPT.c deleted file mode 100644 index c9db601da2c99..0000000000000 --- a/drivers/staging/comedi/drivers/addi-data/APCI1710_INCCPT.c +++ /dev/null @@ -1,5461 +0,0 @@ -/** -@verbatim - -Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. - - ADDI-DATA GmbH - Dieselstrasse 3 - D-77833 Ottersweier - Tel: +19(0)7223/9493-0 - Fax: +49(0)7223/9493-92 - http://www.addi-data.com - info@addi-data.com - -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 the License, or (at your option) any later version. - -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. - -@endverbatim -*/ -/* - +-----------------------------------------------------------------------+ - | (C) ADDI-DATA GmbH Dieselstraße 3 D-77833 Ottersweier | - +-----------------------------------------------------------------------+ - | Tel : +49 (0) 7223/9493-0 | email : info@addi-data.com | - | Fax : +49 (0) 7223/9493-92 | Internet : http://www.addi-data.com | - +-----------------------------------------------------------------------+ - | Project : API APCI1710 | Compiler : gcc | - | Module name : INC_CPT.C | Version : 2.96 | - +-------------------------------+---------------------------------------+ - | Project manager: Eric Stolz | Date : 02/12/2002 | - +-----------------------------------------------------------------------+ - | Description : APCI-1710 incremental counter module | - | | - | | - +-----------------------------------------------------------------------+ - | UPDATES | - +-----------------------------------------------------------------------+ - | Date | Author | Description of updates | - +----------+-----------+------------------------------------------------+ - | | | | - |----------|-----------|------------------------------------------------| - | 08/05/00 | Guinot C | - 0400/0228 All Function in RING 0 | - | | | available | - +-----------------------------------------------------------------------+ - | 29/06/01 | Guinot C. | - 1100/0231 -> 0701/0232 | - | | | See i_APCI1710_DisableFrequencyMeasurement | - +-----------------------------------------------------------------------+ -*/ - -#define APCI1710_16BIT_COUNTER 0x10 -#define APCI1710_32BIT_COUNTER 0x0 -#define APCI1710_QUADRUPLE_MODE 0x0 -#define APCI1710_DOUBLE_MODE 0x3 -#define APCI1710_SIMPLE_MODE 0xF -#define APCI1710_DIRECT_MODE 0x80 -#define APCI1710_HYSTERESIS_ON 0x60 -#define APCI1710_HYSTERESIS_OFF 0x0 -#define APCI1710_INCREMENT 0x60 -#define APCI1710_DECREMENT 0x0 -#define APCI1710_LATCH_COUNTER 0x1 -#define APCI1710_CLEAR_COUNTER 0x0 -#define APCI1710_LOW 0x0 -#define APCI1710_HIGH 0x1 - -/*********************/ -/* Version 0600-0229 */ -/*********************/ -#define APCI1710_HIGH_EDGE_CLEAR_COUNTER 0x0 -#define APCI1710_HIGH_EDGE_LATCH_COUNTER 0x1 -#define APCI1710_LOW_EDGE_CLEAR_COUNTER 0x2 -#define APCI1710_LOW_EDGE_LATCH_COUNTER 0x3 -#define APCI1710_HIGH_EDGE_LATCH_AND_CLEAR_COUNTER 0x4 -#define APCI1710_LOW_EDGE_LATCH_AND_CLEAR_COUNTER 0x5 -#define APCI1710_SOURCE_0 0x0 -#define APCI1710_SOURCE_1 0x1 - -#define APCI1710_30MHZ 30 -#define APCI1710_33MHZ 33 -#define APCI1710_40MHZ 40 - -#define APCI1710_ENABLE_LATCH_INT 0x80 -#define APCI1710_DISABLE_LATCH_INT (~APCI1710_ENABLE_LATCH_INT) - -#define APCI1710_INDEX_LATCH_COUNTER 0x10 -#define APCI1710_INDEX_AUTO_MODE 0x8 -#define APCI1710_ENABLE_INDEX 0x4 -#define APCI1710_DISABLE_INDEX (~APCI1710_ENABLE_INDEX) -#define APCI1710_ENABLE_LATCH_AND_CLEAR 0x8 -#define APCI1710_DISABLE_LATCH_AND_CLEAR (~APCI1710_ENABLE_LATCH_AND_CLEAR) -#define APCI1710_SET_LOW_INDEX_LEVEL 0x4 -#define APCI1710_SET_HIGH_INDEX_LEVEL (~APCI1710_SET_LOW_INDEX_LEVEL) -#define APCI1710_INVERT_INDEX_RFERENCE 0x2 -#define APCI1710_DEFAULT_INDEX_RFERENCE (~APCI1710_INVERT_INDEX_RFERENCE) - -#define APCI1710_ENABLE_INDEX_INT 0x1 -#define APCI1710_DISABLE_INDEX_INT (~APCI1710_ENABLE_INDEX_INT) - -#define APCI1710_ENABLE_FREQUENCY 0x4 -#define APCI1710_DISABLE_FREQUENCY (~APCI1710_ENABLE_FREQUENCY) - -#define APCI1710_ENABLE_FREQUENCY_INT 0x8 -#define APCI1710_DISABLE_FREQUENCY_INT (~APCI1710_ENABLE_FREQUENCY_INT) - -#define APCI1710_ENABLE_40MHZ_FREQUENCY 0x40 -#define APCI1710_DISABLE_40MHZ_FREQUENCY (~APCI1710_ENABLE_40MHZ_FREQUENCY) - -#define APCI1710_ENABLE_40MHZ_FILTER 0x80 -#define APCI1710_DISABLE_40MHZ_FILTER (~APCI1710_ENABLE_40MHZ_FILTER) - -#define APCI1710_ENABLE_COMPARE_INT 0x2 -#define APCI1710_DISABLE_COMPARE_INT (~APCI1710_ENABLE_COMPARE_INT) - -#define APCI1710_ENABLE_INDEX_ACTION 0x20 -#define APCI1710_DISABLE_INDEX_ACTION (~APCI1710_ENABLE_INDEX_ACTION) -#define APCI1710_REFERENCE_HIGH 0x40 -#define APCI1710_REFERENCE_LOW (~APCI1710_REFERENCE_HIGH) - -#define APCI1710_TOR_GATE_LOW 0x40 -#define APCI1710_TOR_GATE_HIGH (~APCI1710_TOR_GATE_LOW) - -/* INSN CONFIG */ -#define APCI1710_INCCPT_INITCOUNTER 100 -#define APCI1710_INCCPT_COUNTERAUTOTEST 101 -#define APCI1710_INCCPT_INITINDEX 102 -#define APCI1710_INCCPT_INITREFERENCE 103 -#define APCI1710_INCCPT_INITEXTERNALSTROBE 104 -#define APCI1710_INCCPT_INITCOMPARELOGIC 105 -#define APCI1710_INCCPT_INITFREQUENCYMEASUREMENT 106 - -/* INSN READ */ -#define APCI1710_INCCPT_READLATCHREGISTERSTATUS 200 -#define APCI1710_INCCPT_READLATCHREGISTERVALUE 201 -#define APCI1710_INCCPT_READ16BITCOUNTERVALUE 202 -#define APCI1710_INCCPT_READ32BITCOUNTERVALUE 203 -#define APCI1710_INCCPT_GETINDEXSTATUS 204 -#define APCI1710_INCCPT_GETREFERENCESTATUS 205 -#define APCI1710_INCCPT_GETUASSTATUS 206 -#define APCI1710_INCCPT_GETCBSTATUS 207 -#define APCI1710_INCCPT_GET16BITCBSTATUS 208 -#define APCI1710_INCCPT_GETUDSTATUS 209 -#define APCI1710_INCCPT_GETINTERRUPTUDLATCHEDSTATUS 210 -#define APCI1710_INCCPT_READFREQUENCYMEASUREMENT 211 -#define APCI1710_INCCPT_READINTERRUPT 212 - -/* INSN BITS */ -#define APCI1710_INCCPT_CLEARCOUNTERVALUE 300 -#define APCI1710_INCCPT_CLEARALLCOUNTERVALUE 301 -#define APCI1710_INCCPT_SETINPUTFILTER 302 -#define APCI1710_INCCPT_LATCHCOUNTER 303 -#define APCI1710_INCCPT_SETINDEXANDREFERENCESOURCE 304 -#define APCI1710_INCCPT_SETDIGITALCHLON 305 -#define APCI1710_INCCPT_SETDIGITALCHLOFF 306 - -/* INSN WRITE */ -#define APCI1710_INCCPT_ENABLELATCHINTERRUPT 400 -#define APCI1710_INCCPT_DISABLELATCHINTERRUPT 401 -#define APCI1710_INCCPT_WRITE16BITCOUNTERVALUE 402 -#define APCI1710_INCCPT_WRITE32BITCOUNTERVALUE 403 -#define APCI1710_INCCPT_ENABLEINDEX 404 -#define APCI1710_INCCPT_DISABLEINDEX 405 -#define APCI1710_INCCPT_ENABLECOMPARELOGIC 406 -#define APCI1710_INCCPT_DISABLECOMPARELOGIC 407 -#define APCI1710_INCCPT_ENABLEFREQUENCYMEASUREMENT 408 -#define APCI1710_INCCPT_DISABLEFREQUENCYMEASUREMENT 409 - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_InitCounter | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char_ b_CounterRange, | -| unsigned char_ b_FirstCounterModus, | -| unsigned char_ b_FirstCounterOption, | -| unsigned char_ b_SecondCounterModus, | -| unsigned char_ b_SecondCounterOption) | -+----------------------------------------------------------------------------+ -| Task : Configure the counter operating mode from selected | -| module (b_ModulNbr). You must calling this function be | -| for you call any other function witch access of | -| counters. | -| | -| Counter range | -| ------------- | -| +------------------------------------+-----------------------------------+ | -| | Parameter Passed value | Description | | -| |------------------------------------+-----------------------------------| | -| |b_ModulNbr APCI1710_16BIT_COUNTER | The module is configured for | | -| | | two 16-bit counter. | | -| | | - b_FirstCounterModus and | | -| | | b_FirstCounterOption | | -| | | configure the first 16 bit | | -| | | counter. | | -| | | - b_SecondCounterModus and | | -| | | b_SecondCounterOption | | -| | | configure the second 16 bit | | -| | | counter. | | -| |------------------------------------+-----------------------------------| | -| |b_ModulNbr APCI1710_32BIT_COUNTER | The module is configured for one | | -| | | 32-bit counter. | | -| | | - b_FirstCounterModus and | | -| | | b_FirstCounterOption | | -| | | configure the 32 bit counter. | | -| | | - b_SecondCounterModus and | | -| | | b_SecondCounterOption | | -| | | are not used and have no | | -| | | importance. | | -| +------------------------------------+-----------------------------------+ | -| | -| Counter operating mode | -| ---------------------- | -| | -| +--------------------+-------------------------+-------------------------+ | -| | Parameter | Passed value | Description | | -| |--------------------+-------------------------+-------------------------| | -| |b_FirstCounterModus | APCI1710_QUADRUPLE_MODE | In the quadruple mode, | | -| | or | | the edge analysis | | -| |b_SecondCounterModus| | circuit generates a | | -| | | | counting pulse from | | -| | | | each edge of 2 signals | | -| | | | which are phase shifted | | -| | | | in relation to each | | -| | | | other. | | -| |--------------------+-------------------------+-------------------------| | -| |b_FirstCounterModus | APCI1710_DOUBLE_MODE | Functions in the same | | -| | or | | way as the quadruple | | -| |b_SecondCounterModus| | mode, except that only | | -| | | | two of the four edges | | -| | | | are analysed per | | -| | | | period | | -| |--------------------+-------------------------+-------------------------| | -| |b_FirstCounterModus | APCI1710_SIMPLE_MODE | Functions in the same | | -| | or | | way as the quadruple | | -| |b_SecondCounterModus| | mode, except that only | | -| | | | one of the four edges | | -| | | | is analysed per | | -| | | | period. | | -| |--------------------+-------------------------+-------------------------| | -| |b_FirstCounterModus | APCI1710_DIRECT_MODE | In the direct mode the | | -| | or | | both edge analysis | | -| |b_SecondCounterModus| | circuits are inactive. | | -| | | | The inputs A, B in the | | -| | | | 32-bit mode or A, B and | | -| | | | C, D in the 16-bit mode | | -| | | | represent, each, one | | -| | | | clock pulse gate circuit| | -| | | | There by frequency and | | -| | | | pulse duration | | -| | | | measurements can be | | -| | | | performed. | | -| +--------------------+-------------------------+-------------------------+ | -| | -| | -| IMPORTANT! | -| If you have configured the module for two 16-bit counter, a mixed | -| mode with a counter in quadruple/double/single mode | -| and the other counter in direct mode is not possible! | -| | -| | -| Counter operating option for quadruple/double/simple mode | -| --------------------------------------------------------- | -| | -| +----------------------+-------------------------+------------------------+| -| | Parameter | Passed value | Description || -| |----------------------+-------------------------+------------------------|| -| |b_FirstCounterOption | APCI1710_HYSTERESIS_ON | In both edge analysis || -| | or | | circuits is available || -| |b_SecondCounterOption | | one hysteresis circuit.|| -| | | | It suppresses each || -| | | | time the first counting|| -| | | | pulse after a change || -| | | | of rotation. || -| |----------------------+-------------------------+------------------------|| -| |b_FirstCounterOption | APCI1710_HYSTERESIS_OFF | The first counting || -| | or | | pulse is not suppress || -| |b_SecondCounterOption | | after a change of || -| | | | rotation. || -| +----------------------+-------------------------+------------------------+| -| | -| | -| IMPORTANT! | -| This option are only avaible if you have selected the direct mode. | -| | -| | -| Counter operating option for direct mode | -| ---------------------------------------- | -| | -| +----------------------+--------------------+----------------------------+ | -| | Parameter | Passed value | Description | | -| |----------------------+--------------------+----------------------------| | -| |b_FirstCounterOption | APCI1710_INCREMENT | The counter increment for | | -| | or | | each counting pulse | | -| |b_SecondCounterOption | | | | -| |----------------------+--------------------+----------------------------| | -| |b_FirstCounterOption | APCI1710_DECREMENT | The counter decrement for | | -| | or | | each counting pulse | | -| |b_SecondCounterOption | | | | -| +----------------------+--------------------+----------------------------+ | -| | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710| -| unsigned char_ b_ModulNbr : Module number to | -| configure (0 to 3) | -| unsigned char_ b_CounterRange : Selection form counter | -| range. | -| unsigned char_ b_FirstCounterModus : First counter operating | -| mode. | -| unsigned char_ b_FirstCounterOption : First counter option. | -| unsigned char_ b_SecondCounterModus : Second counter operating | -| mode. | -| unsigned char_ b_SecondCounterOption : Second counter option. | -+----------------------------------------------------------------------------+ -| Output Parameters : - | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: The module is not a counter module | -| -3: The selected counter range is wrong. | -| -4: The selected first counter operating mode is wrong. | -| -5: The selected first counter operating option is wrong| -| -6: The selected second counter operating mode is wrong.| -| -7: The selected second counter operating option is | -| wrong. | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_InitCounter(struct comedi_device *dev, - unsigned char b_ModulNbr, - unsigned char b_CounterRange, - unsigned char b_FirstCounterModus, - unsigned char b_FirstCounterOption, - unsigned char b_SecondCounterModus, - unsigned char b_SecondCounterOption) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - - /*******************************/ - /* Test if incremental counter */ - /*******************************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[b_ModulNbr] & 0xFFFF0000UL) == - APCI1710_INCREMENTAL_COUNTER) { - /**************************/ - /* Test the counter range */ - /**************************/ - - if (b_CounterRange == APCI1710_16BIT_COUNTER - || b_CounterRange == APCI1710_32BIT_COUNTER) { - /********************************/ - /* Test the first counter modus */ - /********************************/ - - if (b_FirstCounterModus == APCI1710_QUADRUPLE_MODE || - b_FirstCounterModus == APCI1710_DOUBLE_MODE || - b_FirstCounterModus == APCI1710_SIMPLE_MODE || - b_FirstCounterModus == APCI1710_DIRECT_MODE) { - /*********************************/ - /* Test the first counter option */ - /*********************************/ - - if ((b_FirstCounterModus == APCI1710_DIRECT_MODE - && (b_FirstCounterOption == - APCI1710_INCREMENT - || b_FirstCounterOption - == APCI1710_DECREMENT)) - || (b_FirstCounterModus != - APCI1710_DIRECT_MODE - && (b_FirstCounterOption == - APCI1710_HYSTERESIS_ON - || b_FirstCounterOption - == - APCI1710_HYSTERESIS_OFF))) - { - /**************************/ - /* Test if 16-bit counter */ - /**************************/ - - if (b_CounterRange == - APCI1710_16BIT_COUNTER) { - /*********************************/ - /* Test the second counter modus */ - /*********************************/ - - if ((b_FirstCounterModus != - APCI1710_DIRECT_MODE - && - (b_SecondCounterModus - == - APCI1710_QUADRUPLE_MODE - || - b_SecondCounterModus - == - APCI1710_DOUBLE_MODE - || - b_SecondCounterModus - == - APCI1710_SIMPLE_MODE)) - || (b_FirstCounterModus - == - APCI1710_DIRECT_MODE - && - b_SecondCounterModus - == - APCI1710_DIRECT_MODE)) - { - /**********************************/ - /* Test the second counter option */ - /**********************************/ - - if ((b_SecondCounterModus == APCI1710_DIRECT_MODE && (b_SecondCounterOption == APCI1710_INCREMENT || b_SecondCounterOption == APCI1710_DECREMENT)) || (b_SecondCounterModus != APCI1710_DIRECT_MODE && (b_SecondCounterOption == APCI1710_HYSTERESIS_ON || b_SecondCounterOption == APCI1710_HYSTERESIS_OFF))) { - i_ReturnValue = - 0; - } else { - /*********************************************************/ - /* The selected second counter operating option is wrong */ - /*********************************************************/ - - DPRINTK("The selected second counter operating option is wrong\n"); - i_ReturnValue = - -7; - } - } else { - /*******************************************************/ - /* The selected second counter operating mode is wrong */ - /*******************************************************/ - - DPRINTK("The selected second counter operating mode is wrong\n"); - i_ReturnValue = -6; - } - } - } else { - /********************************************************/ - /* The selected first counter operating option is wrong */ - /********************************************************/ - - DPRINTK("The selected first counter operating option is wrong\n"); - i_ReturnValue = -5; - } - } else { - /******************************************************/ - /* The selected first counter operating mode is wrong */ - /******************************************************/ - DPRINTK("The selected first counter operating mode is wrong\n"); - i_ReturnValue = -4; - } - } else { - /***************************************/ - /* The selected counter range is wrong */ - /***************************************/ - - DPRINTK("The selected counter range is wrong\n"); - i_ReturnValue = -3; - } - - /*************************/ - /* Test if a error occur */ - /*************************/ - - if (i_ReturnValue == 0) { - /**************************/ - /* Test if 16-Bit counter */ - /**************************/ - - if (b_CounterRange == APCI1710_32BIT_COUNTER) { - devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister1 = b_CounterRange | - b_FirstCounterModus | - b_FirstCounterOption; - } else { - devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister1 = b_CounterRange | - (b_FirstCounterModus & 0x5) | - (b_FirstCounterOption & 0x20) | - (b_SecondCounterModus & 0xA) | - (b_SecondCounterOption & 0x40); - - /***********************/ - /* Test if direct mode */ - /***********************/ - - if (b_FirstCounterModus == APCI1710_DIRECT_MODE) { - devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister1 = devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister1 | - APCI1710_DIRECT_MODE; - } - } - - /***************************/ - /* Write the configuration */ - /***************************/ - - outl(devpriv->s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - dw_ModeRegister1_2_3_4, - devpriv->s_BoardInfos. - ui_Address + 20 + (64 * b_ModulNbr)); - - devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_InitFlag.b_CounterInit = 1; - } - } else { - /**************************************/ - /* The module is not a counter module */ - /**************************************/ - - DPRINTK("The module is not a counter module\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_CounterAutoTest | -| (unsigned char_ b_BoardHandle, | -| unsigned char *_ pb_TestStatus) | -+----------------------------------------------------------------------------+ -| Task : A test mode is intended for testing the component and | -| the connected periphery. All the 8-bit counter chains | -| are operated internally as down counters. | -| Independently from the external signals, | -| all the four 8-bit counter chains are decremented in | -| parallel by each negative clock pulse edge of CLKX. | -| | -| Counter auto test conclusion | -| ---------------------------- | -| +-----------------+-----------------------------+ | -| | pb_TestStatus | Error description | | -| | mask | | | -| |-----------------+-----------------------------| | -| | 0000 | No error detected | | -| |-----------------|-----------------------------| | -| | 0001 | Error detected of counter 0 | | -| |-----------------|-----------------------------| | -| | 0010 | Error detected of counter 1 | | -| |-----------------|-----------------------------| | -| | 0100 | Error detected of counter 2 | | -| |-----------------|-----------------------------| | -| | 1000 | Error detected of counter 3 | | -| +-----------------+-----------------------------+ | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | | -+----------------------------------------------------------------------------+ -| Output Parameters : unsigned char *_ pb_TestStatus : Auto test conclusion. See table| -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: No counter module found | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_CounterAutoTest(struct comedi_device *dev, - unsigned char *pb_TestStatus) -{ - struct addi_private *devpriv = dev->private; - unsigned char b_ModulCpt = 0; - int i_ReturnValue = 0; - unsigned int dw_LathchValue; - - *pb_TestStatus = 0; - - /********************************/ - /* Test if counter module found */ - /********************************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[0] & 0xFFFF0000UL) == - APCI1710_INCREMENTAL_COUNTER - || (devpriv->s_BoardInfos. - dw_MolduleConfiguration[1] & 0xFFFF0000UL) == - APCI1710_INCREMENTAL_COUNTER - || (devpriv->s_BoardInfos. - dw_MolduleConfiguration[2] & 0xFFFF0000UL) == - APCI1710_INCREMENTAL_COUNTER - || (devpriv->s_BoardInfos. - dw_MolduleConfiguration[3] & 0xFFFF0000UL) == - APCI1710_INCREMENTAL_COUNTER) { - for (b_ModulCpt = 0; b_ModulCpt < 4; b_ModulCpt++) { - /*******************************/ - /* Test if incremental counter */ - /*******************************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[b_ModulCpt] & - 0xFFFF0000UL) == - APCI1710_INCREMENTAL_COUNTER) { - /******************/ - /* Start the test */ - /******************/ - - outl(3, devpriv->s_BoardInfos. - ui_Address + 16 + (64 * b_ModulCpt)); - - /*********************/ - /* Tatch the counter */ - /*********************/ - - outl(1, devpriv->s_BoardInfos. - ui_Address + (64 * b_ModulCpt)); - - /************************/ - /* Read the latch value */ - /************************/ - - dw_LathchValue = inl(devpriv->s_BoardInfos. - ui_Address + 4 + (64 * b_ModulCpt)); - - if ((dw_LathchValue & 0xFF) != - ((dw_LathchValue >> 8) & 0xFF) - && (dw_LathchValue & 0xFF) != - ((dw_LathchValue >> 16) & 0xFF) - && (dw_LathchValue & 0xFF) != - ((dw_LathchValue >> 24) & 0xFF)) { - *pb_TestStatus = - *pb_TestStatus | (1 << - b_ModulCpt); - } - - /*****************/ - /* Stop the test */ - /*****************/ - - outl(0, devpriv->s_BoardInfos. - ui_Address + 16 + (64 * b_ModulCpt)); - } - } - } else { - /***************************/ - /* No counter module found */ - /***************************/ - - DPRINTK("No counter module found\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_InitIndex (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char_ b_ReferenceAction, | -| unsigned char_ b_IndexOperation, | -| unsigned char_ b_AutoMode, | -| unsigned char_ b_InterruptEnable) | -+----------------------------------------------------------------------------+ -| Task : Initialise the index corresponding to the selected | -| module (b_ModulNbr). If a INDEX flag occur, you have | -| the possibility to clear the 32-Bit counter or to latch| -| the current 32-Bit value in to the first latch | -| register. The b_IndexOperation parameter give the | -| possibility to choice the INDEX action. | -| If you have enabled the automatic mode, each INDEX | -| action is cleared automatically, else you must read | -| the index status ("i_APCI1710_ReadIndexStatus") | -| after each INDEX action. | -| | -| | -| Index action | -| ------------ | -| | -| +------------------------+------------------------------------+ | -| | b_IndexOperation | Operation | | -| |------------------------+------------------------------------| | -| |APCI1710_LATCH_COUNTER | After a index signal, the counter | | -| | | value (32-Bit) is latched in to | | -| | | the first latch register | | -| |------------------------|------------------------------------| | -| |APCI1710_CLEAR_COUNTER | After a index signal, the counter | | -| | | value is cleared (32-Bit) | | -| +------------------------+------------------------------------+ | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr : Module number to configure | -| (0 to 3) | -| unsigned char_ b_ReferenceAction : Determine if the reference | -| must set or no for the | -| acceptance from index | -| APCI1710_ENABLE : | -| Reference must be set for | -| accepted the index | -| APCI1710_DISABLE : | -| Reference have not | -| importance | -| unsigned char_ b_IndexOperation : Index operating mode. | -| See table. | -| unsigned char_ b_AutoMode : Enable or disable the | -| automatic index reset. | -| APCI1710_ENABLE : | -| Enable the automatic mode | -| APCI1710_DISABLE : | -| Disable the automatic mode | -| unsigned char_ b_InterruptEnable : Enable or disable the | -| interrupt. | -| APCI1710_ENABLE : | -| Enable the interrupt | -| APCI1710_DISABLE : | -| Disable the interrupt | -+----------------------------------------------------------------------------+ -| Output Parameters : - | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: No counter module found | -| -3: Counter not initialised see function | -| "i_APCI1710_InitCounter" | -| -4 The reference action parameter is wrong | -| -5: The index operating mode parameter is wrong | -| -6: The auto mode parameter is wrong | -| -7: Interrupt parameter is wrong | -| -8: Interrupt function not initialised. | -| See function "i_APCI1710_SetBoardIntRoutineX" | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_InitIndex(struct comedi_device *dev, - unsigned char b_ModulNbr, - unsigned char b_ReferenceAction, - unsigned char b_IndexOperation, - unsigned char b_AutoMode, - unsigned char b_InterruptEnable) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /*******************************/ - /* Test if counter initialised */ - /*******************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) { - /********************************/ - /* Test the reference parameter */ - /********************************/ - - if (b_ReferenceAction == APCI1710_ENABLE || - b_ReferenceAction == APCI1710_DISABLE) { - /****************************/ - /* Test the index parameter */ - /****************************/ - - if (b_IndexOperation == - APCI1710_HIGH_EDGE_LATCH_COUNTER - || b_IndexOperation == - APCI1710_LOW_EDGE_LATCH_COUNTER - || b_IndexOperation == - APCI1710_HIGH_EDGE_CLEAR_COUNTER - || b_IndexOperation == - APCI1710_LOW_EDGE_CLEAR_COUNTER - || b_IndexOperation == - APCI1710_HIGH_EDGE_LATCH_AND_CLEAR_COUNTER - || b_IndexOperation == - APCI1710_LOW_EDGE_LATCH_AND_CLEAR_COUNTER) - { - /********************************/ - /* Test the auto mode parameter */ - /********************************/ - - if (b_AutoMode == APCI1710_ENABLE || - b_AutoMode == APCI1710_DISABLE) - { - /***************************/ - /* Test the interrupt mode */ - /***************************/ - - if (b_InterruptEnable == - APCI1710_ENABLE - || b_InterruptEnable == - APCI1710_DISABLE) { - - /************************************/ - /* Makte the configuration commando */ - /************************************/ - - if (b_ReferenceAction == - APCI1710_ENABLE) - { - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister2 - = - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister2 - | - APCI1710_ENABLE_INDEX_ACTION; - } else { - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister2 - = - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister2 - & - APCI1710_DISABLE_INDEX_ACTION; - } - - /****************************************/ - /* Test if low level latch or/and clear */ - /****************************************/ - - if (b_IndexOperation == - APCI1710_LOW_EDGE_LATCH_COUNTER - || - b_IndexOperation - == - APCI1710_LOW_EDGE_CLEAR_COUNTER - || - b_IndexOperation - == - APCI1710_LOW_EDGE_LATCH_AND_CLEAR_COUNTER) - { - /*************************************/ - /* Set the index level to low (DQ26) */ - /*************************************/ - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister4 - = - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister4 - | - APCI1710_SET_LOW_INDEX_LEVEL; - } else { - /**************************************/ - /* Set the index level to high (DQ26) */ - /**************************************/ - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister4 - = - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister4 - & - APCI1710_SET_HIGH_INDEX_LEVEL; - } - - /***********************************/ - /* Test if latch and clear counter */ - /***********************************/ - - if (b_IndexOperation == - APCI1710_HIGH_EDGE_LATCH_AND_CLEAR_COUNTER - || - b_IndexOperation - == - APCI1710_LOW_EDGE_LATCH_AND_CLEAR_COUNTER) - { - /***************************************/ - /* Set the latch and clear flag (DQ27) */ - /***************************************/ - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister4 - = - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister4 - | - APCI1710_ENABLE_LATCH_AND_CLEAR; - } /* if (b_IndexOperation == APCI1710_HIGH_EDGE_LATCH_AND_CLEAR_COUNTER || b_IndexOperation == APCI1710_LOW_EDGE_LATCH_AND_CLEAR_COUNTER) */ - else { - /*****************************************/ - /* Clear the latch and clear flag (DQ27) */ - /*****************************************/ - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister4 - = - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister4 - & - APCI1710_DISABLE_LATCH_AND_CLEAR; - - /*************************/ - /* Test if latch counter */ - /*************************/ - - if (b_IndexOperation == APCI1710_HIGH_EDGE_LATCH_COUNTER || b_IndexOperation == APCI1710_LOW_EDGE_LATCH_COUNTER) { - /*********************************/ - /* Enable the latch from counter */ - /*********************************/ - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister2 - = - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister2 - | - APCI1710_INDEX_LATCH_COUNTER; - } else { - /*********************************/ - /* Enable the clear from counter */ - /*********************************/ - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister2 - = - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister2 - & - (~APCI1710_INDEX_LATCH_COUNTER); - } - } /* // if (b_IndexOperation == APCI1710_HIGH_EDGE_LATCH_AND_CLEAR_COUNTER || b_IndexOperation == APCI1710_LOW_EDGE_LATCH_AND_CLEAR_COUNTER) */ - - if (b_AutoMode == - APCI1710_DISABLE) - { - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister2 - = - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister2 - | - APCI1710_INDEX_AUTO_MODE; - } else { - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister2 - = - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister2 - & - (~APCI1710_INDEX_AUTO_MODE); - } - - if (b_InterruptEnable == - APCI1710_ENABLE) - { - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister3 - = - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister3 - | - APCI1710_ENABLE_INDEX_INT; - } else { - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister3 - = - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister3 - & - APCI1710_DISABLE_INDEX_INT; - } - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SiemensCounterInfo. - s_InitFlag. - b_IndexInit = 1; - - } else { - /********************************/ - /* Interrupt parameter is wrong */ - /********************************/ - DPRINTK("Interrupt parameter is wrong\n"); - i_ReturnValue = -7; - } - } else { - /************************************/ - /* The auto mode parameter is wrong */ - /************************************/ - - DPRINTK("The auto mode parameter is wrong\n"); - i_ReturnValue = -6; - } - } else { - /***********************************************/ - /* The index operating mode parameter is wrong */ - /***********************************************/ - - DPRINTK("The index operating mode parameter is wrong\n"); - i_ReturnValue = -5; - } - } else { - /*******************************************/ - /* The reference action parameter is wrong */ - /*******************************************/ - - DPRINTK("The reference action parameter is wrong\n"); - i_ReturnValue = -4; - } - } else { - /****************************************/ - /* Counter not initialised see function */ - /* "i_APCI1710_InitCounter" */ - /****************************************/ - - DPRINTK("Counter not initialised\n"); - i_ReturnValue = -3; - } - } else { - /*************************************************/ - /* The selected module number parameter is wrong */ - /*************************************************/ - - DPRINTK("The selected module number parameter is wrong\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_InitReference | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char_ b_ReferenceLevel) | -+----------------------------------------------------------------------------+ -| Task : Initialise the reference corresponding to the selected | -| module (b_ModulNbr). | -| | -| Reference level | -| --------------- | -| +--------------------+-------------------------+ | -| | b_ReferenceLevel | Operation | | -| +--------------------+-------------------------+ | -| | APCI1710_LOW | Reference occur if "0" | | -| |--------------------|-------------------------| | -| | APCI1710_HIGH | Reference occur if "1" | | -| +--------------------+-------------------------+ | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr : Module number to configure | -| (0 to 3) | -| unsigned char_ b_ReferenceLevel : Reference level. | -+----------------------------------------------------------------------------+ -| Output Parameters : - | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: The selected module number parameter is wrong | -| -3: Counter not initialised see function | -| "i_APCI1710_InitCounter" | -| -4: Reference level parameter is wrong | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_InitReference(struct comedi_device *dev, - unsigned char b_ModulNbr, - unsigned char b_ReferenceLevel) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /*******************************/ - /* Test if counter initialised */ - /*******************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) { - /**************************************/ - /* Test the reference level parameter */ - /**************************************/ - - if (b_ReferenceLevel == 0 || b_ReferenceLevel == 1) { - if (b_ReferenceLevel == 1) { - devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister2 = devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister2 | - APCI1710_REFERENCE_HIGH; - } else { - devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister2 = devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister2 & - APCI1710_REFERENCE_LOW; - } - - outl(devpriv->s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - dw_ModeRegister1_2_3_4, - devpriv->s_BoardInfos.ui_Address + 20 + - (64 * b_ModulNbr)); - - devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_InitFlag.b_ReferenceInit = 1; - } else { - /**************************************/ - /* Reference level parameter is wrong */ - /**************************************/ - - DPRINTK("Reference level parameter is wrong\n"); - i_ReturnValue = -4; - } - } else { - /****************************************/ - /* Counter not initialised see function */ - /* "i_APCI1710_InitCounter" */ - /****************************************/ - - DPRINTK("Counter not initialised\n"); - i_ReturnValue = -3; - } - } else { - /*************************************************/ - /* The selected module number parameter is wrong */ - /*************************************************/ - - DPRINTK("The selected module number parameter is wrong\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_InitExternalStrobe | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char_ b_ExternalStrobe, | -| unsigned char_ b_ExternalStrobeLevel) | -+----------------------------------------------------------------------------+ -| Task : Initialises the external strobe level corresponding to | -| the selected module (b_ModulNbr). | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr : Module number to configure | -| (0 to 3) | -| unsigned char_ b_ExternalStrobe : External strobe selection | -| 0 : External strobe A | -| 1 : External strobe B | -| unsigned char_ b_ExternalStrobeLevel : External strobe level | -| APCI1710_LOW : | -| External latch occurs if "0" | -| APCI1710_HIGH : | -| External latch occurs if "1" | -+----------------------------------------------------------------------------+ -| Output Parameters : - | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: The selected module number is wrong | -| -3: Counter not initialised. | -| See function "i_APCI1710_InitCounter" | -| -4: External strobe selection is wrong | -| -5: External strobe level parameter is wrong | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_InitExternalStrobe(struct comedi_device *dev, - unsigned char b_ModulNbr, - unsigned char b_ExternalStrobe, - unsigned char b_ExternalStrobeLevel) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /*******************************/ - /* Test if counter initialised */ - /*******************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) { - /**************************************/ - /* Test the external strobe selection */ - /**************************************/ - - if (b_ExternalStrobe == 0 || b_ExternalStrobe == 1) { - /******************/ - /* Test the level */ - /******************/ - - if ((b_ExternalStrobeLevel == APCI1710_HIGH) || - ((b_ExternalStrobeLevel == APCI1710_LOW - && (devpriv-> - s_BoardInfos. - dw_MolduleConfiguration - [b_ModulNbr] & - 0xFFFF) >= - 0x3135))) { - /*****************/ - /* Set the level */ - /*****************/ - - devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister4 = (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister4 & (0xFF - - (0x10 << b_ExternalStrobe))) | ((b_ExternalStrobeLevel ^ 1) << (4 + b_ExternalStrobe)); - } else { - /********************************************/ - /* External strobe level parameter is wrong */ - /********************************************/ - - DPRINTK("External strobe level parameter is wrong\n"); - i_ReturnValue = -5; - } - } /* if (b_ExternalStrobe == 0 || b_ExternalStrobe == 1) */ - else { - /**************************************/ - /* External strobe selection is wrong */ - /**************************************/ - - DPRINTK("External strobe selection is wrong\n"); - i_ReturnValue = -4; - } /* if (b_ExternalStrobe == 0 || b_ExternalStrobe == 1) */ - } else { - /****************************************/ - /* Counter not initialised see function */ - /* "i_APCI1710_InitCounter" */ - /****************************************/ - - DPRINTK("Counter not initialised\n"); - i_ReturnValue = -3; - } - } else { - /*************************************************/ - /* The selected module number parameter is wrong */ - /*************************************************/ - - DPRINTK("The selected module number parameter is wrong\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - - /* - +----------------------------------------------------------------------------+ - | Function Name : _INT_ i_APCI1710_InitCompareLogic | - | (unsigned char_ b_BoardHandle, | - | unsigned char_ b_ModulNbr, | - | unsigned int_ ui_CompareValue) | - +----------------------------------------------------------------------------+ - | Task : Set the 32-Bit compare value. At that moment that the | - | incremental counter arrive to the compare value | - | (ui_CompareValue) a interrupt is generated. | - +----------------------------------------------------------------------------+ - | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | - | unsigned char_ b_ModulNbr : Module number to configure | - | (0 to 3) | - | unsigned int_ ui_CompareValue : 32-Bit compare value | - +----------------------------------------------------------------------------+ - | Output Parameters : - - +----------------------------------------------------------------------------+ - | Return Value : 0: No error | - | -1: The handle parameter of the board is wrong | - | -2: No counter module found | - | -3: Counter not initialised see function | - | "i_APCI1710_InitCounter" | - +----------------------------------------------------------------------------+ - */ -static int i_APCI1710_InitCompareLogic(struct comedi_device *dev, - unsigned char b_ModulNbr, - unsigned int ui_CompareValue) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /*******************************/ - /* Test if counter initialised */ - /*******************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) { - - outl(ui_CompareValue, devpriv->s_BoardInfos. - ui_Address + 28 + (64 * b_ModulNbr)); - - devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_InitFlag.b_CompareLogicInit = 1; - } else { - /****************************************/ - /* Counter not initialised see function */ - /* "i_APCI1710_InitCounter" */ - /****************************************/ - - DPRINTK("Counter not initialised\n"); - i_ReturnValue = -3; - } - } else { - /*************************************************/ - /* The selected module number parameter is wrong */ - /*************************************************/ - - DPRINTK("The selected module number parameter is wrong\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_InitFrequencyMeasurement | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char_ b_PCIInputClock, | -| unsigned char_ b_TimingUnity, | -| ULONG_ ul_TimingInterval, | -| PULONG_ pul_RealTimingInterval) | -+----------------------------------------------------------------------------+ -| Task : Sets the time for the frequency measurement. | -| Configures the selected TOR incremental counter of the | -| selected module (b_ModulNbr). The ul_TimingInterval and| -| ul_TimingUnity determine the time base for the | -| measurement. The pul_RealTimingInterval returns the | -| real time value. You must call up this function before | -| you call up any other function which gives access to | -| the frequency measurement. | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr : Number of the module to be | -| configured (0 to 3) | -| unsigned char_ b_PCIInputClock : Selection of the PCI bus | -| clock | -| - APCI1710_30MHZ : | -| The PC has a PCI bus clock | -| of 30 MHz | -| - APCI1710_33MHZ : | -| The PC has a PCI bus clock | -| of 33 MHz | -| unsigned char_ b_TimingUnity : Base time unit (0 to 2) | -| 0 : ns | -| 1 : æs | -| 2 : ms | -| ULONG_ ul_TimingInterval: Base time value. | -+----------------------------------------------------------------------------+ -| Output Parameters : PULONG_ pul_RealTimingInterval : Real base time value. | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: The selected module number is wrong | -| -3: Counter not initialised see function | -| "i_APCI1710_InitCounter" | -| -4: The selected PCI input clock is wrong | -| -5: Timing unity selection is wrong | -| -6: Base timing selection is wrong | -| -7: 40MHz quartz not on board | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_InitFrequencyMeasurement(struct comedi_device *dev, - unsigned char b_ModulNbr, - unsigned char b_PCIInputClock, - unsigned char b_TimingUnity, - unsigned int ul_TimingInterval, - unsigned int *pul_RealTimingInterval) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - unsigned int ul_TimerValue = 0; - double d_RealTimingInterval; - unsigned int dw_Status = 0; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /*******************************/ - /* Test if counter initialised */ - /*******************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) { - /**************************/ - /* Test the PCI bus clock */ - /**************************/ - - if ((b_PCIInputClock == APCI1710_30MHZ) || - (b_PCIInputClock == APCI1710_33MHZ) || - (b_PCIInputClock == APCI1710_40MHZ)) { - /************************/ - /* Test the timing unit */ - /************************/ - - if (b_TimingUnity <= 2) { - /**********************************/ - /* Test the base timing selection */ - /**********************************/ - - if (((b_PCIInputClock == APCI1710_30MHZ) - && (b_TimingUnity == 0) - && (ul_TimingInterval >= - 266) - && (ul_TimingInterval <= - 8738133UL)) - || ((b_PCIInputClock == - APCI1710_30MHZ) - && (b_TimingUnity == 1) - && (ul_TimingInterval >= - 1) - && (ul_TimingInterval <= - 8738UL)) - || ((b_PCIInputClock == - APCI1710_30MHZ) - && (b_TimingUnity == 2) - && (ul_TimingInterval >= - 1) - && (ul_TimingInterval <= - 8UL)) - || ((b_PCIInputClock == - APCI1710_33MHZ) - && (b_TimingUnity == 0) - && (ul_TimingInterval >= - 242) - && (ul_TimingInterval <= - 7943757UL)) - || ((b_PCIInputClock == - APCI1710_33MHZ) - && (b_TimingUnity == 1) - && (ul_TimingInterval >= - 1) - && (ul_TimingInterval <= - 7943UL)) - || ((b_PCIInputClock == - APCI1710_33MHZ) - && (b_TimingUnity == 2) - && (ul_TimingInterval >= - 1) - && (ul_TimingInterval <= - 7UL)) - || ((b_PCIInputClock == - APCI1710_40MHZ) - && (b_TimingUnity == 0) - && (ul_TimingInterval >= - 200) - && (ul_TimingInterval <= - 6553500UL)) - || ((b_PCIInputClock == - APCI1710_40MHZ) - && (b_TimingUnity == 1) - && (ul_TimingInterval >= - 1) - && (ul_TimingInterval <= - 6553UL)) - || ((b_PCIInputClock == - APCI1710_40MHZ) - && (b_TimingUnity == 2) - && (ul_TimingInterval >= - 1) - && (ul_TimingInterval <= - 6UL))) { - /**********************/ - /* Test if 40MHz used */ - /**********************/ - - if (b_PCIInputClock == - APCI1710_40MHZ) { - /******************************/ - /* Test if firmware >= Rev1.5 */ - /******************************/ - - if ((devpriv->s_BoardInfos.dw_MolduleConfiguration[b_ModulNbr] & 0xFFFF) >= 0x3135) { - /*********************************/ - /* Test if 40MHz quartz on board */ - /*********************************/ - - /*INPDW (ps_APCI1710Variable-> - s_Board [b_BoardHandle]. - s_BoardInfos. - ui_Address + 36 + (64 * b_ModulNbr), &dw_Status); */ - dw_Status = - inl - (devpriv-> - s_BoardInfos. - ui_Address - + 36 + - (64 * b_ModulNbr)); - - /******************************/ - /* Test the quartz flag (DQ0) */ - /******************************/ - - if ((dw_Status & 1) != 1) { - /*****************************/ - /* 40MHz quartz not on board */ - /*****************************/ - - DPRINTK("40MHz quartz not on board\n"); - i_ReturnValue - = - -7; - } - } else { - /*****************************/ - /* 40MHz quartz not on board */ - /*****************************/ - DPRINTK("40MHz quartz not on board\n"); - i_ReturnValue = - -7; - } - } /* if (b_PCIInputClock == APCI1710_40MHZ) */ - - /***************************/ - /* Test if not error occur */ - /***************************/ - - if (i_ReturnValue == 0) { - /****************************/ - /* Test the INC_CPT version */ - /****************************/ - - if ((devpriv->s_BoardInfos.dw_MolduleConfiguration[b_ModulNbr] & 0xFFFF) >= 0x3131) { - - /**********************/ - /* Test if 40MHz used */ - /**********************/ - - if (b_PCIInputClock == APCI1710_40MHZ) { - /*********************************/ - /* Enable the 40MHz quarz (DQ30) */ - /*********************************/ - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister4 - = - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister4 - | - APCI1710_ENABLE_40MHZ_FREQUENCY; - } /* if (b_PCIInputClock == APCI1710_40MHZ) */ - else { - /**********************************/ - /* Disable the 40MHz quarz (DQ30) */ - /**********************************/ - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister4 - = - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister4 - & - APCI1710_DISABLE_40MHZ_FREQUENCY; - - } /* if (b_PCIInputClock == APCI1710_40MHZ) */ - - /********************************/ - /* Calculate the division fator */ - /********************************/ - - fpu_begin(); - switch (b_TimingUnity) { - /******/ - /* ns */ - /******/ - - case 0: - - /******************/ - /* Timer 0 factor */ - /******************/ - - ul_TimerValue - = - (unsigned int) - (ul_TimingInterval - * - (0.00025 * b_PCIInputClock)); - - /*******************/ - /* Round the value */ - /*******************/ - - if ((double)((double)ul_TimingInterval * (0.00025 * (double)b_PCIInputClock)) >= ((double)((double)ul_TimerValue + 0.5))) { - ul_TimerValue - = - ul_TimerValue - + - 1; - } - - /*****************************/ - /* Calculate the real timing */ - /*****************************/ - - *pul_RealTimingInterval - = - (unsigned int) - (ul_TimerValue - / - (0.00025 * (double)b_PCIInputClock)); - d_RealTimingInterval - = - (double) - ul_TimerValue - / - (0.00025 - * - (double) - b_PCIInputClock); - - if ((double)((double)ul_TimerValue / (0.00025 * (double)b_PCIInputClock)) >= (double)((double)*pul_RealTimingInterval + 0.5)) { - *pul_RealTimingInterval - = - *pul_RealTimingInterval - + - 1; - } - - ul_TimingInterval - = - ul_TimingInterval - - - 1; - ul_TimerValue - = - ul_TimerValue - - - 2; - - break; - - /******/ - /* æs */ - /******/ - - case 1: - - /******************/ - /* Timer 0 factor */ - /******************/ - - ul_TimerValue - = - (unsigned int) - (ul_TimingInterval - * - (0.25 * b_PCIInputClock)); - - /*******************/ - /* Round the value */ - /*******************/ - - if ((double)((double)ul_TimingInterval * (0.25 * (double)b_PCIInputClock)) >= ((double)((double)ul_TimerValue + 0.5))) { - ul_TimerValue - = - ul_TimerValue - + - 1; - } - - /*****************************/ - /* Calculate the real timing */ - /*****************************/ - - *pul_RealTimingInterval - = - (unsigned int) - (ul_TimerValue - / - (0.25 * (double)b_PCIInputClock)); - d_RealTimingInterval - = - (double) - ul_TimerValue - / - ( - (double) - 0.25 - * - (double) - b_PCIInputClock); - - if ((double)((double)ul_TimerValue / (0.25 * (double)b_PCIInputClock)) >= (double)((double)*pul_RealTimingInterval + 0.5)) { - *pul_RealTimingInterval - = - *pul_RealTimingInterval - + - 1; - } - - ul_TimingInterval - = - ul_TimingInterval - - - 1; - ul_TimerValue - = - ul_TimerValue - - - 2; - - break; - - /******/ - /* ms */ - /******/ - - case 2: - - /******************/ - /* Timer 0 factor */ - /******************/ - - ul_TimerValue - = - ul_TimingInterval - * - (250.0 - * - b_PCIInputClock); - - /*******************/ - /* Round the value */ - /*******************/ - - if ((double)((double)ul_TimingInterval * (250.0 * (double)b_PCIInputClock)) >= ((double)((double)ul_TimerValue + 0.5))) { - ul_TimerValue - = - ul_TimerValue - + - 1; - } - - /*****************************/ - /* Calculate the real timing */ - /*****************************/ - - *pul_RealTimingInterval - = - (unsigned int) - (ul_TimerValue - / - (250.0 * (double)b_PCIInputClock)); - d_RealTimingInterval - = - (double) - ul_TimerValue - / - (250.0 - * - (double) - b_PCIInputClock); - - if ((double)((double)ul_TimerValue / (250.0 * (double)b_PCIInputClock)) >= (double)((double)*pul_RealTimingInterval + 0.5)) { - *pul_RealTimingInterval - = - *pul_RealTimingInterval - + - 1; - } - - ul_TimingInterval - = - ul_TimingInterval - - - 1; - ul_TimerValue - = - ul_TimerValue - - - 2; - - break; - } - - fpu_end(); - /*************************/ - /* Write the timer value */ - /*************************/ - - outl(ul_TimerValue, devpriv->s_BoardInfos.ui_Address + 32 + (64 * b_ModulNbr)); - - /*******************************/ - /* Set the initialisation flag */ - /*******************************/ - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SiemensCounterInfo. - s_InitFlag. - b_FrequencyMeasurementInit - = 1; - } else { - /***************************/ - /* Counter not initialised */ - /***************************/ - - DPRINTK("Counter not initialised\n"); - i_ReturnValue = - -3; - } - } /* if (i_ReturnValue == 0) */ - } else { - /**********************************/ - /* Base timing selection is wrong */ - /**********************************/ - - DPRINTK("Base timing selection is wrong\n"); - i_ReturnValue = -6; - } - } else { - /***********************************/ - /* Timing unity selection is wrong */ - /***********************************/ - - DPRINTK("Timing unity selection is wrong\n"); - i_ReturnValue = -5; - } - } else { - /*****************************************/ - /* The selected PCI input clock is wrong */ - /*****************************************/ - - DPRINTK("The selected PCI input clock is wrong\n"); - i_ReturnValue = -4; - } - } else { - /****************************************/ - /* Counter not initialised see function */ - /* "i_APCI1710_InitCounter" */ - /****************************************/ - - DPRINTK("Counter not initialised\n"); - i_ReturnValue = -3; - } - } else { - /*************************************************/ - /* The selected module number parameter is wrong */ - /*************************************************/ - - DPRINTK("The selected module number parameter is wrong\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* - * Configuration function for INC_CPT - */ -static int i_APCI1710_InsnConfigINCCPT(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - unsigned int ui_ConfigType; - int i_ReturnValue = 0; - - ui_ConfigType = CR_CHAN(insn->chanspec); - - printk("\nINC_CPT"); - - devpriv->tsk_Current = current; /* Save the current process task structure */ - switch (ui_ConfigType) { - case APCI1710_INCCPT_INITCOUNTER: - i_ReturnValue = i_APCI1710_InitCounter(dev, - CR_AREF(insn->chanspec), - (unsigned char) data[0], - (unsigned char) data[1], - (unsigned char) data[2], (unsigned char) data[3], (unsigned char) data[4]); - break; - - case APCI1710_INCCPT_COUNTERAUTOTEST: - i_ReturnValue = i_APCI1710_CounterAutoTest(dev, - (unsigned char *) &data[0]); - break; - - case APCI1710_INCCPT_INITINDEX: - i_ReturnValue = i_APCI1710_InitIndex(dev, - CR_AREF(insn->chanspec), - (unsigned char) data[0], - (unsigned char) data[1], (unsigned char) data[2], (unsigned char) data[3]); - break; - - case APCI1710_INCCPT_INITREFERENCE: - i_ReturnValue = i_APCI1710_InitReference(dev, - CR_AREF(insn->chanspec), (unsigned char) data[0]); - break; - - case APCI1710_INCCPT_INITEXTERNALSTROBE: - i_ReturnValue = i_APCI1710_InitExternalStrobe(dev, - CR_AREF(insn->chanspec), - (unsigned char) data[0], (unsigned char) data[1]); - break; - - case APCI1710_INCCPT_INITCOMPARELOGIC: - i_ReturnValue = i_APCI1710_InitCompareLogic(dev, - CR_AREF(insn->chanspec), (unsigned int) data[0]); - break; - - case APCI1710_INCCPT_INITFREQUENCYMEASUREMENT: - i_ReturnValue = i_APCI1710_InitFrequencyMeasurement(dev, - CR_AREF(insn->chanspec), - (unsigned char) data[0], - (unsigned char) data[1], (unsigned int) data[2], (unsigned int *) &data[0]); - break; - - default: - printk("Insn Config : Config Parameter Wrong\n"); - - } - - if (i_ReturnValue >= 0) - i_ReturnValue = insn->n; - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_ClearCounterValue | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr) | -+----------------------------------------------------------------------------+ -| Task : Clear the counter value from selected module | -| (b_ModulNbr). | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr : Module number to configure | -| (0 to 3) | -+----------------------------------------------------------------------------+ -| Output Parameters : - | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: The selected module number parameter is wrong | -| -3: Counter not initialised see function | -| "i_APCI1710_InitCounter" | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_ClearCounterValue(struct comedi_device *dev, - unsigned char b_ModulNbr) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /*******************************/ - /* Test if counter initialised */ - /*******************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) { - /*********************/ - /* Clear the counter */ - /*********************/ - - outl(1, devpriv->s_BoardInfos. - ui_Address + 16 + (64 * b_ModulNbr)); - } else { - /****************************************/ - /* Counter not initialised see function */ - /* "i_APCI1710_InitCounter" */ - /****************************************/ - - DPRINTK("Counter not initialised\n"); - i_ReturnValue = -3; - } - } else { - /*************************************************/ - /* The selected module number parameter is wrong */ - /*************************************************/ - - DPRINTK("The selected module number parameter is wrong\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_ClearAllCounterValue | -| (unsigned char_ b_BoardHandle) | -+----------------------------------------------------------------------------+ -| Task : Clear all counter value. | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -+----------------------------------------------------------------------------+ -| Output Parameters : - | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: No counter module found | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_ClearAllCounterValue(struct comedi_device *dev) -{ - struct addi_private *devpriv = dev->private; - unsigned char b_ModulCpt = 0; - int i_ReturnValue = 0; - - /********************************/ - /* Test if counter module found */ - /********************************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[0] & 0xFFFF0000UL) == - APCI1710_INCREMENTAL_COUNTER - || (devpriv->s_BoardInfos. - dw_MolduleConfiguration[1] & 0xFFFF0000UL) == - APCI1710_INCREMENTAL_COUNTER - || (devpriv->s_BoardInfos. - dw_MolduleConfiguration[2] & 0xFFFF0000UL) == - APCI1710_INCREMENTAL_COUNTER - || (devpriv->s_BoardInfos. - dw_MolduleConfiguration[3] & 0xFFFF0000UL) == - APCI1710_INCREMENTAL_COUNTER) { - for (b_ModulCpt = 0; b_ModulCpt < 4; b_ModulCpt++) { - /*******************************/ - /* Test if incremental counter */ - /*******************************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[b_ModulCpt] & - 0xFFFF0000UL) == - APCI1710_INCREMENTAL_COUNTER) { - /*********************/ - /* Clear the counter */ - /*********************/ - - outl(1, devpriv->s_BoardInfos. - ui_Address + 16 + (64 * b_ModulCpt)); - } - } - } else { - /***************************/ - /* No counter module found */ - /***************************/ - - DPRINTK("No counter module found\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_SetInputFilter | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_Module, | -| unsigned char_ b_PCIInputClock, | -| unsigned char_ b_Filter) | -+----------------------------------------------------------------------------+ -| Task : Disable or enable the software filter from selected | -| module (b_ModulNbr). b_Filter determine the filter time| -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr : Number of the module to be | -| configured (0 to 3) | -| unsigned char_ b_PCIInputClock : Selection of the PCI bus | -| clock | -| - APCI1710_30MHZ : | -| The PC has a PCI bus clock | -| of 30 MHz | -| - APCI1710_33MHZ : | -| The PC has a PCI bus clock | -| of 33 MHz | -| - APCI1710_40MHZ : | -| The APCI1710 has a 40MHz | -| quartz | -| unsigned char_ b_Filter : Filter selection | -| | -| 30 MHz | -| ------ | -| 0: Software filter not used | -| 1: Filter from 266ns (3.750000MHz) | -| 2: Filter from 400ns (2.500000MHz) | -| 3: Filter from 533ns (1.876170MHz) | -| 4: Filter from 666ns (1.501501MHz) | -| 5: Filter from 800ns (1.250000MHz) | -| 6: Filter from 933ns (1.071800MHz) | -| 7: Filter from 1066ns (0.938080MHz) | -| 8: Filter from 1200ns (0.833333MHz) | -| 9: Filter from 1333ns (0.750000MHz) | -| 10: Filter from 1466ns (0.682100MHz) | -| 11: Filter from 1600ns (0.625000MHz) | -| 12: Filter from 1733ns (0.577777MHz) | -| 13: Filter from 1866ns (0.535900MHz) | -| 14: Filter from 2000ns (0.500000MHz) | -| 15: Filter from 2133ns (0.468800MHz) | -| | -| 33 MHz | -| ------ | -| 0: Software filter not used | -| 1: Filter from 242ns (4.125000MHz) | -| 2: Filter from 363ns (2.754820MHz) | -| 3: Filter from 484ns (2.066115MHz) | -| 4: Filter from 605ns (1.652892MHz) | -| 5: Filter from 726ns (1.357741MHz) | -| 6: Filter from 847ns (1.180637MHz) | -| 7: Filter from 968ns (1.033055MHz) | -| 8: Filter from 1089ns (0.918273MHz) | -| 9: Filter from 1210ns (0.826446MHz) | -| 10: Filter from 1331ns (0.751314MHz) | -| 11: Filter from 1452ns (0.688705MHz) | -| 12: Filter from 1573ns (0.635727MHz) | -| 13: Filter from 1694ns (0.590318MHz) | -| 14: Filter from 1815ns (0.550964MHz) | -| 15: Filter from 1936ns (0.516528MHz) | -| | -| 40 MHz | -| ------ | -| 0: Software filter not used | -| 1: Filter from 200ns (5.000000MHz) | -| 2: Filter from 300ns (3.333333MHz) | -| 3: Filter from 400ns (2.500000MHz) | -| 4: Filter from 500ns (2.000000MHz) | -| 5: Filter from 600ns (1.666666MHz) | -| 6: Filter from 700ns (1.428500MHz) | -| 7: Filter from 800ns (1.250000MHz) | -| 8: Filter from 900ns (1.111111MHz) | -| 9: Filter from 1000ns (1.000000MHz) | -| 10: Filter from 1100ns (0.909090MHz) | -| 11: Filter from 1200ns (0.833333MHz) | -| 12: Filter from 1300ns (0.769200MHz) | -| 13: Filter from 1400ns (0.714200MHz) | -| 14: Filter from 1500ns (0.666666MHz) | -| 15: Filter from 1600ns (0.625000MHz) | -+----------------------------------------------------------------------------+ -| Output Parameters : - | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: The selected module number is wrong | -| -3: The module is not a counter module | -| -4: The selected PCI input clock is wrong | -| -5: The selected filter value is wrong | -| -6: 40MHz quartz not on board | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_SetInputFilter(struct comedi_device *dev, - unsigned char b_ModulNbr, - unsigned char b_PCIInputClock, - unsigned char b_Filter) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - unsigned int dw_Status = 0; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /*******************************/ - /* Test if incremental counter */ - /*******************************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[b_ModulNbr] & - 0xFFFF0000UL) == APCI1710_INCREMENTAL_COUNTER) { - /******************************/ - /* Test if firmware >= Rev1.5 */ - /******************************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[b_ModulNbr] & - 0xFFFF) >= 0x3135) { - /**************************/ - /* Test the PCI bus clock */ - /**************************/ - - if ((b_PCIInputClock == APCI1710_30MHZ) || - (b_PCIInputClock == APCI1710_33MHZ) || - (b_PCIInputClock == APCI1710_40MHZ)) { - /*************************/ - /* Test the filter value */ - /*************************/ - - if (b_Filter < 16) { - /**********************/ - /* Test if 40MHz used */ - /**********************/ - - if (b_PCIInputClock == - APCI1710_40MHZ) { - /*********************************/ - /* Test if 40MHz quartz on board */ - /*********************************/ - - dw_Status = - inl(devpriv-> - s_BoardInfos. - ui_Address + - 36 + - (64 * b_ModulNbr)); - - /******************************/ - /* Test the quartz flag (DQ0) */ - /******************************/ - - if ((dw_Status & 1) != - 1) { - /*****************************/ - /* 40MHz quartz not on board */ - /*****************************/ - - DPRINTK("40MHz quartz not on board\n"); - i_ReturnValue = - -6; - } - } /* if (b_PCIInputClock == APCI1710_40MHZ) */ - - /***************************/ - /* Test if error not occur */ - /***************************/ - - if (i_ReturnValue == 0) { - /**********************/ - /* Test if 40MHz used */ - /**********************/ - - if (b_PCIInputClock == - APCI1710_40MHZ) - { - /*********************************/ - /* Enable the 40MHz quarz (DQ31) */ - /*********************************/ - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister4 - = - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister4 - | - APCI1710_ENABLE_40MHZ_FILTER; - - } /* if (b_PCIInputClock == APCI1710_40MHZ) */ - else { - /**********************************/ - /* Disable the 40MHz quarz (DQ31) */ - /**********************************/ - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister4 - = - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister4 - & - APCI1710_DISABLE_40MHZ_FILTER; - - } /* if (b_PCIInputClock == APCI1710_40MHZ) */ - - /************************/ - /* Set the filter value */ - /************************/ - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister3 - = - (devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister3 - & 0x1F) | - ((b_Filter & - 0x7) << - 5); - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister4 - = - (devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister4 - & 0xFE) | - ((b_Filter & - 0x8) >> - 3); - - /***************************/ - /* Write the configuration */ - /***************************/ - - outl(devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - dw_ModeRegister1_2_3_4, - devpriv-> - s_BoardInfos. - ui_Address + - 20 + - (64 * b_ModulNbr)); - } /* if (i_ReturnValue == 0) */ - } /* if (b_Filter < 16) */ - else { - /**************************************/ - /* The selected filter value is wrong */ - /**************************************/ - - DPRINTK("The selected filter value is wrong\n"); - i_ReturnValue = -5; - } /* if (b_Filter < 16) */ - } /* if ((b_PCIInputClock == APCI1710_30MHZ) || (b_PCIInputClock == APCI1710_33MHZ) || (b_PCIInputClock == APCI1710_40MHZ)) */ - else { - /*****************************************/ - /* The selected PCI input clock is wrong */ - /*****************************************/ - - DPRINTK("The selected PCI input clock is wrong\n"); - i_ReturnValue = 4; - } /* if ((b_PCIInputClock == APCI1710_30MHZ) || (b_PCIInputClock == APCI1710_33MHZ) || (b_PCIInputClock == APCI1710_40MHZ)) */ - } else { - /**************************************/ - /* The module is not a counter module */ - /**************************************/ - - DPRINTK("The module is not a counter module\n"); - i_ReturnValue = -3; - } - } else { - /**************************************/ - /* The module is not a counter module */ - /**************************************/ - - DPRINTK("The module is not a counter module\n"); - i_ReturnValue = -3; - } - } else { - /*************************************************/ - /* The selected module number parameter is wrong */ - /*************************************************/ - - DPRINTK("The selected module number parameter is wrong\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_LatchCounter (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char_ b_LatchReg) | -+----------------------------------------------------------------------------+ -| Task : Latch the courant value from selected module | -| (b_ModulNbr) in to the selected latch register | -| (b_LatchReg). | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr : Module number to configure | -| (0 to 3) | -| unsigned char_ b_LatchReg : Selected latch register | -| 0 : for the first latch register | -| 1 : for the second latch register | -+----------------------------------------------------------------------------+ -| Output Parameters : - | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: No counter module found | -| -3: Counter not initialised see function | -| "i_APCI1710_InitCounter" | -| -4: The selected latch register parameter is wrong | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_LatchCounter(struct comedi_device *dev, - unsigned char b_ModulNbr, - unsigned char b_LatchReg) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /*******************************/ - /* Test if counter initialised */ - /*******************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) { - /*************************************/ - /* Test the latch register parameter */ - /*************************************/ - - if (b_LatchReg < 2) { - /*********************/ - /* Tatch the counter */ - /*********************/ - - outl(1 << (b_LatchReg * 4), - devpriv->s_BoardInfos.ui_Address + - (64 * b_ModulNbr)); - } else { - /**************************************************/ - /* The selected latch register parameter is wrong */ - /**************************************************/ - - DPRINTK("The selected latch register parameter is wrong\n"); - i_ReturnValue = -4; - } - } else { - /****************************************/ - /* Counter not initialised see function */ - /* "i_APCI1710_InitCounter" */ - /****************************************/ - - DPRINTK("Counter not initialised\n"); - i_ReturnValue = -3; - } - } else { - /*************************************************/ - /* The selected module number parameter is wrong */ - /*************************************************/ - - DPRINTK("The selected module number parameter is wrong\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_SetIndexAndReferenceSource | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char_ b_SourceSelection) | -+----------------------------------------------------------------------------+ -| Task : Determine the hardware source for the index and the | -| reference logic. Per default the index logic is | -| connected to the difference input C and the reference | -| logic is connected to the 24V input E | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr : Module number to configure | -| (0 to 3) | -| unsigned char_ b_SourceSelection : APCI1710_SOURCE_0 : | -| The index logic is connected | -| to the difference input C and| -| the reference logic is | -| connected to the 24V input E.| -| This is the default | -| configuration. | -| APCI1710_SOURCE_1 : | -| The reference logic is | -| connected to the difference | -| input C and the index logic | -| is connected to the 24V | -| input E | -+----------------------------------------------------------------------------+ -| Output Parameters : - | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: The selected module number is wrong | -| -3: The module is not a counter module. | -| -4: The source selection is wrong | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_SetIndexAndReferenceSource(struct comedi_device *dev, - unsigned char b_ModulNbr, - unsigned char b_SourceSelection) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /*******************************/ - /* Test if incremental counter */ - /*******************************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[b_ModulNbr] & - 0xFFFF0000UL) == APCI1710_INCREMENTAL_COUNTER) { - /******************************/ - /* Test if firmware >= Rev1.5 */ - /******************************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[b_ModulNbr] & - 0xFFFF) >= 0x3135) { - /*****************************/ - /* Test the source selection */ - /*****************************/ - - if (b_SourceSelection == APCI1710_SOURCE_0 || - b_SourceSelection == APCI1710_SOURCE_1) - { - /******************************************/ - /* Test if invert the index and reference */ - /******************************************/ - - if (b_SourceSelection == - APCI1710_SOURCE_1) { - /********************************************/ - /* Invert index and reference source (DQ25) */ - /********************************************/ - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister4 = - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister4 | - APCI1710_INVERT_INDEX_RFERENCE; - } else { - /****************************************/ - /* Set the default configuration (DQ25) */ - /****************************************/ - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister4 = - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister4 & - APCI1710_DEFAULT_INDEX_RFERENCE; - } - } /* if (b_SourceSelection == APCI1710_SOURCE_0 ||b_SourceSelection == APCI1710_SOURCE_1) */ - else { - /*********************************/ - /* The source selection is wrong */ - /*********************************/ - - DPRINTK("The source selection is wrong\n"); - i_ReturnValue = -4; - } /* if (b_SourceSelection == APCI1710_SOURCE_0 ||b_SourceSelection == APCI1710_SOURCE_1) */ - } else { - /**************************************/ - /* The module is not a counter module */ - /**************************************/ - - DPRINTK("The module is not a counter module\n"); - i_ReturnValue = -3; - } - } else { - /**************************************/ - /* The module is not a counter module */ - /**************************************/ - - DPRINTK("The module is not a counter module\n"); - i_ReturnValue = -3; - } - } else { - /***************************************/ - /* The selected module number is wrong */ - /***************************************/ - - DPRINTK("The selected module number is wrong\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_SetDigitalChlOn | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr) | -+----------------------------------------------------------------------------+ -| Task : Sets the digital output H Setting an output means | -| setting an ouput high. | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr : Number of the module to be | -| configured (0 to 3) | -+----------------------------------------------------------------------------+ -| Output Parameters : - | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: The selected module number is wrong | -| -3: Counter not initialised see function | -| "i_APCI1710_InitCounter" | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_SetDigitalChlOn(struct comedi_device *dev, - unsigned char b_ModulNbr) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /*******************************/ - /* Test if counter initialised */ - /*******************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) { - devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister3 = devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister.b_ModeRegister3 | 0x10; - - /*********************/ - /* Set the output On */ - /*********************/ - - outl(devpriv->s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - dw_ModeRegister1_2_3_4, devpriv->s_BoardInfos. - ui_Address + 20 + (64 * b_ModulNbr)); - } else { - /****************************************/ - /* Counter not initialised see function */ - /* "i_APCI1710_InitCounter" */ - /****************************************/ - - DPRINTK("Counter not initialised\n"); - i_ReturnValue = -3; - } - } else { - /*************************************************/ - /* The selected module number parameter is wrong */ - /*************************************************/ - - DPRINTK("The selected module number parameter is wrong\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_SetDigitalChlOff | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr) | -+----------------------------------------------------------------------------+ -| Task : Resets the digital output H. Resetting an output means | -| setting an ouput low. | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr : Number of the module to be | -| configured (0 to 3) | -+----------------------------------------------------------------------------+ -| Output Parameters : - | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: The selected module number is wrong | -| -3: Counter not initialised see function | -| "i_APCI1710_InitCounter" | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_SetDigitalChlOff(struct comedi_device *dev, - unsigned char b_ModulNbr) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /*******************************/ - /* Test if counter initialised */ - /*******************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) { - devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister3 = devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister.b_ModeRegister3 & 0xEF; - - /**********************/ - /* Set the output Off */ - /**********************/ - - outl(devpriv->s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - dw_ModeRegister1_2_3_4, devpriv->s_BoardInfos. - ui_Address + 20 + (64 * b_ModulNbr)); - } else { - /****************************************/ - /* Counter not initialised see function */ - /* "i_APCI1710_InitCounter" */ - /****************************************/ - - DPRINTK("Counter not initialised\n"); - i_ReturnValue = -3; - } - } else { - /*************************************************/ - /* The selected module number parameter is wrong */ - /*************************************************/ - - DPRINTK("The selected module number parameter is wrong\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* - * Set & Clear Functions for INC_CPT - */ -static int i_APCI1710_InsnBitsINCCPT(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - unsigned int ui_BitsType; - int i_ReturnValue = 0; - - ui_BitsType = CR_CHAN(insn->chanspec); - devpriv->tsk_Current = current; /* Save the current process task structure */ - - switch (ui_BitsType) { - case APCI1710_INCCPT_CLEARCOUNTERVALUE: - i_ReturnValue = i_APCI1710_ClearCounterValue(dev, - (unsigned char) CR_AREF(insn->chanspec)); - break; - - case APCI1710_INCCPT_CLEARALLCOUNTERVALUE: - i_ReturnValue = i_APCI1710_ClearAllCounterValue(dev); - break; - - case APCI1710_INCCPT_SETINPUTFILTER: - i_ReturnValue = i_APCI1710_SetInputFilter(dev, - (unsigned char) CR_AREF(insn->chanspec), - (unsigned char) data[0], (unsigned char) data[1]); - break; - - case APCI1710_INCCPT_LATCHCOUNTER: - i_ReturnValue = i_APCI1710_LatchCounter(dev, - (unsigned char) CR_AREF(insn->chanspec), (unsigned char) data[0]); - break; - - case APCI1710_INCCPT_SETINDEXANDREFERENCESOURCE: - i_ReturnValue = i_APCI1710_SetIndexAndReferenceSource(dev, - (unsigned char) CR_AREF(insn->chanspec), (unsigned char) data[0]); - break; - - case APCI1710_INCCPT_SETDIGITALCHLON: - i_ReturnValue = i_APCI1710_SetDigitalChlOn(dev, - (unsigned char) CR_AREF(insn->chanspec)); - break; - - case APCI1710_INCCPT_SETDIGITALCHLOFF: - i_ReturnValue = i_APCI1710_SetDigitalChlOff(dev, - (unsigned char) CR_AREF(insn->chanspec)); - break; - - default: - printk("Bits Config Parameter Wrong\n"); - } - - if (i_ReturnValue >= 0) - i_ReturnValue = insn->n; - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_EnableLatchInterrupt | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr) | -+----------------------------------------------------------------------------+ -| Task : Enable the latch interrupt from selected module | -| (b_ModulNbr). Each software or hardware latch occur a | -| interrupt. | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr : Module number to configure | -| (0 to 3) | -+----------------------------------------------------------------------------+ -| Output Parameters : - | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: No counter module found | -| -3: Counter not initialised see function | -| "i_APCI1710_InitCounter" | -| -4: Interrupt routine not installed see function | -| "i_APCI1710_SetBoardIntRoutine" | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_EnableLatchInterrupt(struct comedi_device *dev, - unsigned char b_ModulNbr) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /*******************************/ - /* Test if counter initialised */ - /*******************************/ - - if (devpriv->s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) { - - /********************/ - /* Enable interrupt */ - /********************/ - - devpriv->s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister2 = devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister2 | APCI1710_ENABLE_LATCH_INT; - - /***************************/ - /* Write the configuration */ - /***************************/ - - outl(devpriv->s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - dw_ModeRegister1_2_3_4, devpriv->s_BoardInfos. - ui_Address + 20 + (64 * b_ModulNbr)); - } else { - /****************************************/ - /* Counter not initialised see function */ - /* "i_APCI1710_InitCounter" */ - /****************************************/ - - DPRINTK("Counter not initialised\n"); - i_ReturnValue = -3; - } - } else { - /*************************************************/ - /* The selected module number parameter is wrong */ - /*************************************************/ - - DPRINTK("The selected module number parameter is wrong\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_DisableLatchInterrupt | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr) | -+----------------------------------------------------------------------------+ -| Task : Disable the latch interrupt from selected module | -| (b_ModulNbr). | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr : Module number to configure | -| (0 to 3) | -+----------------------------------------------------------------------------+ -| Output Parameters : - | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: No counter module found | -| -3: Counter not initialised see function | -| "i_APCI1710_InitCounter" | -| -4: Interrupt routine not installed see function | -| "i_APCI1710_SetBoardIntRoutine" | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_DisableLatchInterrupt(struct comedi_device *dev, - unsigned char b_ModulNbr) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /*******************************/ - /* Test if counter initialised */ - /*******************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) { - - /***************************/ - /* Write the configuration */ - /***************************/ - - outl(devpriv->s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - dw_ModeRegister1_2_3_4 & - ((APCI1710_DISABLE_LATCH_INT << 8) | 0xFF), - devpriv->s_BoardInfos.ui_Address + 20 + - (64 * b_ModulNbr)); - - mdelay(1000); - - /*********************/ - /* Disable interrupt */ - /*********************/ - - devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister2 = devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister2 & APCI1710_DISABLE_LATCH_INT; - - } else { - /****************************************/ - /* Counter not initialised see function */ - /* "i_APCI1710_InitCounter" */ - /****************************************/ - - DPRINTK("Counter not initialised\n"); - i_ReturnValue = -3; - } - } else { - /*************************************************/ - /* The selected module number parameter is wrong */ - /*************************************************/ - - DPRINTK("The selected module number parameter is wrong\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_Write16BitCounterValue | -| (unsigned char_ b_BoardHandle | -| unsigned char_ b_ModulNbr, | -| unsigned char_ b_SelectedCounter, | -| unsigned int_ ui_WriteValue) | -+----------------------------------------------------------------------------+ -| Task : Write a 16-Bit value (ui_WriteValue) in to the selected| -| 16-Bit counter (b_SelectedCounter) from selected module| -| (b_ModulNbr). | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr : Module number to configure | -| (0 to 3) | -| unsigned char_ b_SelectedCounter : Selected 16-Bit counter | -| (0 or 1) | -| unsigned int_ ui_WriteValue : 16-Bit write value | -+----------------------------------------------------------------------------+ -| Output Parameters : - | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: No counter module found | -| -3: Counter not initialised see function | -| "i_APCI1710_InitCounter" | -| -4: The selected 16-Bit counter parameter is wrong | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_Write16BitCounterValue(struct comedi_device *dev, - unsigned char b_ModulNbr, - unsigned char b_SelectedCounter, - unsigned int ui_WriteValue) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /*******************************/ - /* Test if counter initialised */ - /*******************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) { - /******************************/ - /* Test the counter selection */ - /******************************/ - - if (b_SelectedCounter < 2) { - /*******************/ - /* Write the value */ - /*******************/ - - outl((unsigned int) ((unsigned int) (ui_WriteValue) << (16 * - b_SelectedCounter)), - devpriv->s_BoardInfos.ui_Address + 8 + - (b_SelectedCounter * 4) + - (64 * b_ModulNbr)); - } else { - /**************************************************/ - /* The selected 16-Bit counter parameter is wrong */ - /**************************************************/ - - DPRINTK("The selected 16-Bit counter parameter is wrong\n"); - i_ReturnValue = -4; - } - } else { - /****************************************/ - /* Counter not initialised see function */ - /* "i_APCI1710_InitCounter" */ - /****************************************/ - - DPRINTK("Counter not initialised\n"); - i_ReturnValue = -3; - } - } else { - /*************************************************/ - /* The selected module number parameter is wrong */ - /*************************************************/ - - DPRINTK("The selected module number parameter is wrong\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_Write32BitCounterValue | -| (unsigned char_ b_BoardHandle | -| unsigned char_ b_ModulNbr, | -| ULONG_ ul_WriteValue) | -+----------------------------------------------------------------------------+ -| Task : Write a 32-Bit value (ui_WriteValue) in to the selected| -| module (b_ModulNbr). | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr : Module number to configure | -| (0 to 3) | -| ULONG_ ul_WriteValue : 32-Bit write value | -+----------------------------------------------------------------------------+ -| Output Parameters : - | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: No counter module found | -| -3: Counter not initialised see function | -| "i_APCI1710_InitCounter" | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_Write32BitCounterValue(struct comedi_device *dev, - unsigned char b_ModulNbr, - unsigned int ul_WriteValue) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /*******************************/ - /* Test if counter initialised */ - /*******************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) { - /*******************/ - /* Write the value */ - /*******************/ - - outl(ul_WriteValue, devpriv->s_BoardInfos. - ui_Address + 4 + (64 * b_ModulNbr)); - } else { - /****************************************/ - /* Counter not initialised see function */ - /* "i_APCI1710_InitCounter" */ - /****************************************/ - - DPRINTK("Counter not initialised\n"); - i_ReturnValue = -3; - } - } else { - /*************************************************/ - /* The selected module number parameter is wrong */ - /*************************************************/ - - DPRINTK("The selected module number parameter is wrong\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_EnableIndex (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr) | -+----------------------------------------------------------------------------+ -| Task : Enable the INDEX actions | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr : Module number to configure | -| (0 to 3) | -+----------------------------------------------------------------------------+ -| Output Parameters : - | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: No counter module found | -| -3: Counter not initialised see function | -| "i_APCI1710_InitCounter" | -| -4: Index not initialised see function | -| "i_APCI1710_InitIndex" | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_EnableIndex(struct comedi_device *dev, - unsigned char b_ModulNbr) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - unsigned int ul_InterruptLatchReg; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /*******************************/ - /* Test if counter initialised */ - /*******************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) { - /*****************************/ - /* Test if index initialised */ - /*****************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo.s_InitFlag.b_IndexInit) { - devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister2 = devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister2 | APCI1710_ENABLE_INDEX; - - ul_InterruptLatchReg = - inl(devpriv->s_BoardInfos.ui_Address + - 24 + (64 * b_ModulNbr)); - - outl(devpriv->s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - dw_ModeRegister1_2_3_4, - devpriv->s_BoardInfos.ui_Address + 20 + - (64 * b_ModulNbr)); - } else { - /*************************************************************/ - /* Index not initialised see function "i_APCI1710_InitIndex" */ - /*************************************************************/ - - DPRINTK("Index not initialised \n"); - i_ReturnValue = -4; - } - } else { - /****************************************/ - /* Counter not initialised see function */ - /* "i_APCI1710_InitCounter" */ - /****************************************/ - - DPRINTK("Counter not initialised\n"); - i_ReturnValue = -3; - } - } else { - /*************************************************/ - /* The selected module number parameter is wrong */ - /*************************************************/ - - DPRINTK("The selected module number parameter is wrong\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_DisableIndex (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr) | -+----------------------------------------------------------------------------+ -| Task : Disable the INDEX actions | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr : Module number to configure | -| (0 to 3) | -+----------------------------------------------------------------------------+ -| Output Parameters : - | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: No counter module found | -| -3: Counter not initialised see function | -| "i_APCI1710_InitCounter" | -| -4: Index not initialised see function | -| "i_APCI1710_InitIndex" | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_DisableIndex(struct comedi_device *dev, - unsigned char b_ModulNbr) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /*******************************/ - /* Test if counter initialised */ - /*******************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) { - /*****************************/ - /* Test if index initialised */ - /*****************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo.s_InitFlag.b_IndexInit) { - devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister2 = devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister2 & - APCI1710_DISABLE_INDEX; - - outl(devpriv->s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - dw_ModeRegister1_2_3_4, - devpriv->s_BoardInfos.ui_Address + 20 + - (64 * b_ModulNbr)); - } else { - /*************************************************************/ - /* Index not initialised see function "i_APCI1710_InitIndex" */ - /*************************************************************/ - - DPRINTK("Index not initialised \n"); - i_ReturnValue = -4; - } - } else { - /****************************************/ - /* Counter not initialised see function */ - /* "i_APCI1710_InitCounter" */ - /****************************************/ - - DPRINTK("Counter not initialised\n"); - i_ReturnValue = -3; - } - } else { - /*************************************************/ - /* The selected module number parameter is wrong */ - /*************************************************/ - - DPRINTK("The selected module number parameter is wrong\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_EnableCompareLogic | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr) | -+----------------------------------------------------------------------------+ -| Task : Enable the 32-Bit compare logic. At that moment that | -| the incremental counter arrive to the compare value a | -| interrupt is generated. | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr : Module number to configure | -| (0 to 3) | -+----------------------------------------------------------------------------+ -| Output Parameters : - -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: No counter module found | -| -3: Counter not initialised see function | -| "i_APCI1710_InitCounter" | -| -4: Compare logic not initialised. | -| See function "i_APCI1710_InitCompareLogic" | -| -5: Interrupt function not initialised. | -| See function "i_APCI1710_SetBoardIntRoutineX" | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_EnableCompareLogic(struct comedi_device *dev, - unsigned char b_ModulNbr) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /*******************************/ - /* Test if counter initialised */ - /*******************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) { - /*************************************/ - /* Test if compare logic initialised */ - /*************************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_InitFlag.b_CompareLogicInit == 1) { - devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister3 = devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister3 | - APCI1710_ENABLE_COMPARE_INT; - - /***************************/ - /* Write the configuration */ - /***************************/ - - outl(devpriv->s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - dw_ModeRegister1_2_3_4, - devpriv->s_BoardInfos.ui_Address + 20 + - (64 * b_ModulNbr)); - } else { - /*********************************/ - /* Compare logic not initialised */ - /*********************************/ - - DPRINTK("Compare logic not initialised\n"); - i_ReturnValue = -4; - } - } else { - /****************************************/ - /* Counter not initialised see function */ - /* "i_APCI1710_InitCounter" */ - /****************************************/ - - DPRINTK("Counter not initialised\n"); - i_ReturnValue = -3; - } - } else { - /*************************************************/ - /* The selected module number parameter is wrong */ - /*************************************************/ - - DPRINTK("The selected module number parameter is wrong\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_DisableCompareLogic | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr) | -+----------------------------------------------------------------------------+ -| Task : Disable the 32-Bit compare logic. -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr : Module number to configure | -| (0 to 3) | -+----------------------------------------------------------------------------+ -| Output Parameters : - -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: No counter module found | -| -3: Counter not initialised see function | -| "i_APCI1710_InitCounter" | -| -4: Compare logic not initialised. | -| See function "i_APCI1710_InitCompareLogic" | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_DisableCompareLogic(struct comedi_device *dev, - unsigned char b_ModulNbr) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /*******************************/ - /* Test if counter initialised */ - /*******************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) { - /*************************************/ - /* Test if compare logic initialised */ - /*************************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_InitFlag.b_CompareLogicInit == 1) { - devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister3 = devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister3 & - APCI1710_DISABLE_COMPARE_INT; - - /***************************/ - /* Write the configuration */ - /***************************/ - - outl(devpriv->s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - dw_ModeRegister1_2_3_4, - devpriv->s_BoardInfos.ui_Address + 20 + - (64 * b_ModulNbr)); - } else { - /*********************************/ - /* Compare logic not initialised */ - /*********************************/ - - DPRINTK("Compare logic not initialised\n"); - i_ReturnValue = -4; - } - } else { - /****************************************/ - /* Counter not initialised see function */ - /* "i_APCI1710_InitCounter" */ - /****************************************/ - - DPRINTK("Counter not initialised\n"); - i_ReturnValue = -3; - } - } else { - /*************************************************/ - /* The selected module number parameter is wrong */ - /*************************************************/ - - DPRINTK("The selected module number parameter is wrong\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - - /* - +----------------------------------------------------------------------------+ - | Function Name : _INT_ i_APCI1710_EnableFrequencyMeasurement | - | (unsigned char_ b_BoardHandle, | - | unsigned char_ b_ModulNbr, | - | unsigned char_ b_InterruptEnable) | - +----------------------------------------------------------------------------+ - | Task : Enables the frequency measurement function | - +----------------------------------------------------------------------------+ - | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | - | unsigned char_ b_ModulNbr : Number of the module to be | - | configured (0 to 3) | - | unsigned char_ b_InterruptEnable: Enable or disable the | - | interrupt. | - | APCI1710_ENABLE: | - | Enable the interrupt | - | APCI1710_DISABLE: | - | Disable the interrupt | - +----------------------------------------------------------------------------+ - | Output Parameters : - | - +----------------------------------------------------------------------------+ - | Return Value : 0: No error | - | -1: The handle parameter of the board is wrong | - | -2: The selected module number is wrong | - | -3: Counter not initialised see function | - | "i_APCI1710_InitCounter" | - | -4: Frequency measurement logic not initialised. | - | See function "i_APCI1710_InitFrequencyMeasurement" | - | -5: Interrupt parameter is wrong | - | -6: Interrupt function not initialised. | - +----------------------------------------------------------------------------+ - */ -static int i_APCI1710_EnableFrequencyMeasurement(struct comedi_device *dev, - unsigned char b_ModulNbr, - unsigned char b_InterruptEnable) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /*******************************/ - /* Test if counter initialised */ - /*******************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) { - /********************************************/ - /* Test if frequency measurement initialised */ - /********************************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_InitFlag.b_FrequencyMeasurementInit == 1) { - /***************************/ - /* Test the interrupt mode */ - /***************************/ - - if ((b_InterruptEnable == APCI1710_DISABLE) || - (b_InterruptEnable == APCI1710_ENABLE)) - { - - /************************************/ - /* Enable the frequency measurement */ - /************************************/ - - devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister3 = devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister3 | - APCI1710_ENABLE_FREQUENCY; - - /*********************************************/ - /* Disable or enable the frequency interrupt */ - /*********************************************/ - - devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister3 = (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister3 & - APCI1710_DISABLE_FREQUENCY_INT) - | (b_InterruptEnable << 3); - - /***************************/ - /* Write the configuration */ - /***************************/ - - outl(devpriv->s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - dw_ModeRegister1_2_3_4, - devpriv->s_BoardInfos. - ui_Address + 20 + - (64 * b_ModulNbr)); - - devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_InitFlag. - b_FrequencyMeasurementEnable = - 1; - } else { - /********************************/ - /* Interrupt parameter is wrong */ - /********************************/ - - DPRINTK("Interrupt parameter is wrong\n"); - i_ReturnValue = -5; - } - } else { - /***********************************************/ - /* Frequency measurement logic not initialised */ - /***********************************************/ - - DPRINTK("Frequency measurement logic not initialised\n"); - i_ReturnValue = -4; - } - } else { - /****************************************/ - /* Counter not initialised see function */ - /* "i_APCI1710_InitCounter" */ - /****************************************/ - - DPRINTK("Counter not initialised\n"); - i_ReturnValue = -3; - } - } else { - /*************************************************/ - /* The selected module number parameter is wrong */ - /*************************************************/ - - DPRINTK("The selected module number parameter is wrong\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - - /* - +----------------------------------------------------------------------------+ - | Function Name : _INT_ i_APCI1710_DisableFrequencyMeasurement | - | (unsigned char_ b_BoardHandle, | - | unsigned char_ b_ModulNbr) | - +----------------------------------------------------------------------------+ - | Task : Disables the frequency measurement function | - +----------------------------------------------------------------------------+ - | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | - | unsigned char_ b_ModulNbr : Number of the module to be | - | configured (0 to 3) | - +----------------------------------------------------------------------------+ - | Output Parameters : - | - +----------------------------------------------------------------------------+ - | Return Value : 0: No error | - | -1: The handle parameter of the board is wrong | - | -2: The selected module number is wrong | - | -3: Counter not initialised see function | - | "i_APCI1710_InitCounter" | - | -4: Frequency measurement logic not initialised. | - | See function "i_APCI1710_InitFrequencyMeasurement" | - +----------------------------------------------------------------------------+ - */ -static int i_APCI1710_DisableFrequencyMeasurement(struct comedi_device *dev, - unsigned char b_ModulNbr) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /*******************************/ - /* Test if counter initialised */ - /*******************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) { - /********************************************/ - /* Test if frequency measurement initialised */ - /********************************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_InitFlag.b_FrequencyMeasurementInit == 1) { - /*************************************/ - /* Disable the frequency measurement */ - /*************************************/ - - devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister3 = devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister3 & - APCI1710_DISABLE_FREQUENCY - /* Begin CG 29/06/01 CG 1100/0231 -> 0701/0232 Frequence measure IRQ must be cleared */ - & APCI1710_DISABLE_FREQUENCY_INT; - /* End CG 29/06/01 CG 1100/0231 -> 0701/0232 Frequence measure IRQ must be cleared */ - - /***************************/ - /* Write the configuration */ - /***************************/ - - outl(devpriv->s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - dw_ModeRegister1_2_3_4, - devpriv->s_BoardInfos.ui_Address + 20 + - (64 * b_ModulNbr)); - - /*************************************/ - /* Disable the frequency measurement */ - /*************************************/ - - devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_InitFlag. - b_FrequencyMeasurementEnable = 0; - } else { - /***********************************************/ - /* Frequency measurement logic not initialised */ - /***********************************************/ - - DPRINTK("Frequency measurement logic not initialised\n"); - i_ReturnValue = -4; - } - } else { - /****************************************/ - /* Counter not initialised see function */ - /* "i_APCI1710_InitCounter" */ - /****************************************/ - - DPRINTK("Counter not initialised\n"); - i_ReturnValue = -3; - } - } else { - /*************************************************/ - /* The selected module number parameter is wrong */ - /*************************************************/ - - DPRINTK("The selected module number parameter is wrong\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* - * Enable Disable functions for INC_CPT - */ -static int i_APCI1710_InsnWriteINCCPT(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - unsigned int ui_WriteType; - int i_ReturnValue = 0; - - ui_WriteType = CR_CHAN(insn->chanspec); - devpriv->tsk_Current = current; /* Save the current process task structure */ - - switch (ui_WriteType) { - case APCI1710_INCCPT_ENABLELATCHINTERRUPT: - i_ReturnValue = i_APCI1710_EnableLatchInterrupt(dev, - (unsigned char) CR_AREF(insn->chanspec)); - break; - - case APCI1710_INCCPT_DISABLELATCHINTERRUPT: - i_ReturnValue = i_APCI1710_DisableLatchInterrupt(dev, - (unsigned char) CR_AREF(insn->chanspec)); - break; - - case APCI1710_INCCPT_WRITE16BITCOUNTERVALUE: - i_ReturnValue = i_APCI1710_Write16BitCounterValue(dev, - (unsigned char) CR_AREF(insn->chanspec), - (unsigned char) data[0], (unsigned int) data[1]); - break; - - case APCI1710_INCCPT_WRITE32BITCOUNTERVALUE: - i_ReturnValue = i_APCI1710_Write32BitCounterValue(dev, - (unsigned char) CR_AREF(insn->chanspec), (unsigned int) data[0]); - - break; - - case APCI1710_INCCPT_ENABLEINDEX: - i_APCI1710_EnableIndex(dev, (unsigned char) CR_AREF(insn->chanspec)); - break; - - case APCI1710_INCCPT_DISABLEINDEX: - i_ReturnValue = i_APCI1710_DisableIndex(dev, - (unsigned char) CR_AREF(insn->chanspec)); - break; - - case APCI1710_INCCPT_ENABLECOMPARELOGIC: - i_ReturnValue = i_APCI1710_EnableCompareLogic(dev, - (unsigned char) CR_AREF(insn->chanspec)); - break; - - case APCI1710_INCCPT_DISABLECOMPARELOGIC: - i_ReturnValue = i_APCI1710_DisableCompareLogic(dev, - (unsigned char) CR_AREF(insn->chanspec)); - break; - - case APCI1710_INCCPT_ENABLEFREQUENCYMEASUREMENT: - i_ReturnValue = i_APCI1710_EnableFrequencyMeasurement(dev, - (unsigned char) CR_AREF(insn->chanspec), (unsigned char) data[0]); - break; - - case APCI1710_INCCPT_DISABLEFREQUENCYMEASUREMENT: - i_ReturnValue = i_APCI1710_DisableFrequencyMeasurement(dev, - (unsigned char) CR_AREF(insn->chanspec)); - break; - - default: - printk("Write Config Parameter Wrong\n"); - } - - if (i_ReturnValue >= 0) - i_ReturnValue = insn->n; - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_ReadLatchRegisterStatus | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char_ b_LatchReg, | -| unsigned char *_ pb_LatchStatus) | -+----------------------------------------------------------------------------+ -| Task : Read the latch register status from selected module | -| (b_ModulNbr) and selected latch register (b_LatchReg). | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr : Module number to configure | -| (0 to 3) | -| unsigned char_ b_LatchReg : Selected latch register | -| 0 : for the first latch register | -| 1 : for the second latch register | -+----------------------------------------------------------------------------+ -| Output Parameters : unsigned char *_ pb_LatchStatus : Latch register status. | -| 0 : No latch occur | -| 1 : A software latch occur | -| 2 : A hardware latch occur | -| 3 : A software and hardware | -| latch occur | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: No counter module found | -| -3: Counter not initialised see function | -| "i_APCI1710_InitCounter" | -| -4: The selected latch register parameter is wrong | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_ReadLatchRegisterStatus(struct comedi_device *dev, - unsigned char b_ModulNbr, - unsigned char b_LatchReg, - unsigned char *pb_LatchStatus) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - unsigned int dw_LatchReg; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /*******************************/ - /* Test if counter initialised */ - /*******************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) { - /*************************************/ - /* Test the latch register parameter */ - /*************************************/ - - if (b_LatchReg < 2) { - dw_LatchReg = inl(devpriv->s_BoardInfos. - ui_Address + (64 * b_ModulNbr)); - - *pb_LatchStatus = - (unsigned char) ((dw_LatchReg >> (b_LatchReg * - 4)) & 0x3); - } else { - /**************************************************/ - /* The selected latch register parameter is wrong */ - /**************************************************/ - - DPRINTK("The selected latch register parameter is wrong\n"); - i_ReturnValue = -4; - } - } else { - /****************************************/ - /* Counter not initialised see function */ - /* "i_APCI1710_InitCounter" */ - /****************************************/ - - DPRINTK("Counter not initialised\n"); - i_ReturnValue = -3; - } - } else { - /*************************************************/ - /* The selected module number parameter is wrong */ - /*************************************************/ - - DPRINTK("The selected module number parameter is wrong\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_ReadLatchRegisterValue | -| (unsigned char_ b_BoardHandle,| -| unsigned char_ b_ModulNbr, | -| unsigned char_ b_LatchReg, | -| PULONG_ pul_LatchValue) | -+----------------------------------------------------------------------------+ -| Task : Read the latch register value from selected module | -| (b_ModulNbr) and selected latch register (b_LatchReg). | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr : Module number to configure | -| (0 to 3) | -| unsigned char_ b_LatchReg : Selected latch register | -| 0 : for the first latch register | -| 1 : for the second latch register | -+----------------------------------------------------------------------------+ -| Output Parameters : PULONG_ pul_LatchValue : Latch register value | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: No counter module found | -| -3: Counter not initialised see function | -| "i_APCI1710_InitCounter" | -| -4: The selected latch register parameter is wrong | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_ReadLatchRegisterValue(struct comedi_device *dev, - unsigned char b_ModulNbr, - unsigned char b_LatchReg, - unsigned int *pul_LatchValue) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /*******************************/ - /* Test if counter initialised */ - /*******************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) { - /*************************************/ - /* Test the latch register parameter */ - /*************************************/ - - if (b_LatchReg < 2) { - *pul_LatchValue = inl(devpriv->s_BoardInfos. - ui_Address + ((b_LatchReg + 1) * 4) + - (64 * b_ModulNbr)); - - } else { - /**************************************************/ - /* The selected latch register parameter is wrong */ - /**************************************************/ - - DPRINTK("The selected latch register parameter is wrong\n"); - i_ReturnValue = -4; - } - } else { - /****************************************/ - /* Counter not initialised see function */ - /* "i_APCI1710_InitCounter" */ - /****************************************/ - - DPRINTK("Counter not initialised\n"); - i_ReturnValue = -3; - } - } else { - /*************************************************/ - /* The selected module number parameter is wrong */ - /*************************************************/ - - DPRINTK("The selected module number parameter is wrong\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_Read16BitCounterValue | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char_ b_SelectedCounter, | -| unsigned int *_ pui_CounterValue) | -+----------------------------------------------------------------------------+ -| Task : Latch the selected 16-Bit counter (b_SelectedCounter) | -| from selected module (b_ModulNbr) in to the first | -| latch register and return the latched value. | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr : Module number to configure | -| (0 to 3) | -| unsigned char_ b_SelectedCounter : Selected 16-Bit counter | -| (0 or 1) | -+----------------------------------------------------------------------------+ -| Output Parameters : unsigned int *_ pui_CounterValue : 16-Bit counter value | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: No counter module found | -| -3: Counter not initialised see function | -| "i_APCI1710_InitCounter" | -| -4: The selected 16-Bit counter parameter is wrong | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_Read16BitCounterValue(struct comedi_device *dev, - unsigned char b_ModulNbr, - unsigned char b_SelectedCounter, - unsigned int *pui_CounterValue) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - unsigned int dw_LathchValue = 0; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /*******************************/ - /* Test if counter initialised */ - /*******************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) { - /******************************/ - /* Test the counter selection */ - /******************************/ - - if (b_SelectedCounter < 2) { - /*********************/ - /* Latch the counter */ - /*********************/ - - outl(1, devpriv->s_BoardInfos. - ui_Address + (64 * b_ModulNbr)); - - /************************/ - /* Read the latch value */ - /************************/ - - dw_LathchValue = inl(devpriv->s_BoardInfos. - ui_Address + 4 + (64 * b_ModulNbr)); - - *pui_CounterValue = - (unsigned int) ((dw_LathchValue >> (16 * - b_SelectedCounter)) & - 0xFFFFU); - } else { - /**************************************************/ - /* The selected 16-Bit counter parameter is wrong */ - /**************************************************/ - - DPRINTK("The selected 16-Bit counter parameter is wrong\n"); - i_ReturnValue = -4; - } - } else { - /****************************************/ - /* Counter not initialised see function */ - /* "i_APCI1710_InitCounter" */ - /****************************************/ - - DPRINTK("Counter not initialised\n"); - i_ReturnValue = -3; - } - } else { - /*************************************************/ - /* The selected module number parameter is wrong */ - /*************************************************/ - - DPRINTK("The selected module number parameter is wrong\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_Read32BitCounterValue | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| PULONG_ pul_CounterValue) | -+----------------------------------------------------------------------------+ -| Task : Latch the 32-Bit counter from selected module | -| (b_ModulNbr) in to the first latch register and return | -| the latched value. | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr : Module number to configure | -| (0 to 3) | -+----------------------------------------------------------------------------+ -| Output Parameters : PULONG_ pul_CounterValue : 32-Bit counter value | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: No counter module found | -| -3: Counter not initialised see function | -| "i_APCI1710_InitCounter" | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_Read32BitCounterValue(struct comedi_device *dev, - unsigned char b_ModulNbr, - unsigned int *pul_CounterValue) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /*******************************/ - /* Test if counter initialised */ - /*******************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) { - /*********************/ - /* Tatch the counter */ - /*********************/ - - outl(1, devpriv->s_BoardInfos. - ui_Address + (64 * b_ModulNbr)); - - /************************/ - /* Read the latch value */ - /************************/ - - *pul_CounterValue = inl(devpriv->s_BoardInfos. - ui_Address + 4 + (64 * b_ModulNbr)); - } else { - /****************************************/ - /* Counter not initialised see function */ - /* "i_APCI1710_InitCounter" */ - /****************************************/ - - DPRINTK("Counter not initialised\n"); - i_ReturnValue = -3; - } - } else { - /*************************************************/ - /* The selected module number parameter is wrong */ - /*************************************************/ - - DPRINTK("The selected module number parameter is wrong\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_GetIndexStatus (unsigned char_ b_BoardHandle,| -| unsigned char_ b_ModulNbr, | -| unsigned char *_ pb_IndexStatus)| -+----------------------------------------------------------------------------+ -| Task : Return the index status | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr : Module number to configure | -| (0 to 3) | -+----------------------------------------------------------------------------+ -| Output Parameters : unsigned char *_ pb_IndexStatus : 0 : No INDEX occur | -| 1 : A INDEX occur | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: No counter module found | -| -3: Counter not initialised see function | -| "i_APCI1710_InitCounter" | -| -4: Index not initialised see function | -| "i_APCI1710_InitIndex" | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_GetIndexStatus(struct comedi_device *dev, - unsigned char b_ModulNbr, - unsigned char *pb_IndexStatus) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - unsigned int dw_StatusReg = 0; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /*******************************/ - /* Test if counter initialised */ - /*******************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) { - /*****************************/ - /* Test if index initialised */ - /*****************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo.s_InitFlag.b_IndexInit) { - dw_StatusReg = inl(devpriv->s_BoardInfos. - ui_Address + 12 + (64 * b_ModulNbr)); - - *pb_IndexStatus = (unsigned char) (dw_StatusReg & 1); - } else { - /*************************************************************/ - /* Index not initialised see function "i_APCI1710_InitIndex" */ - /*************************************************************/ - - DPRINTK("Index not initialised\n"); - i_ReturnValue = -4; - } - } else { - /****************************************/ - /* Counter not initialised see function */ - /* "i_APCI1710_InitCounter" */ - /****************************************/ - - DPRINTK("Counter not initialised\n"); - i_ReturnValue = -3; - } - } else { - /*************************************************/ - /* The selected module number parameter is wrong */ - /*************************************************/ - - DPRINTK("The selected module number parameter is wrong\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_GetReferenceStatus | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char *_ pb_ReferenceStatus) | -+----------------------------------------------------------------------------+ -| Task : Return the reference status | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr : Module number to configure | -| (0 to 3) | -+----------------------------------------------------------------------------+ -| Output Parameters : unsigned char *_ pb_ReferenceStatus : 0 : No REFERENCE occur | -| 1 : A REFERENCE occur | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: No counter module found | -| -3: Counter not initialised see function | -| "i_APCI1710_InitCounter" | -| -4: Reference not initialised see function | -| "i_APCI1710_InitReference" | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_GetReferenceStatus(struct comedi_device *dev, - unsigned char b_ModulNbr, - unsigned char *pb_ReferenceStatus) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - unsigned int dw_StatusReg = 0; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /*******************************/ - /* Test if counter initialised */ - /*******************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) { - /*********************************/ - /* Test if reference initialised */ - /*********************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_InitFlag.b_ReferenceInit) { - dw_StatusReg = inl(devpriv->s_BoardInfos. - ui_Address + 24 + (64 * b_ModulNbr)); - - *pb_ReferenceStatus = - (unsigned char) (~dw_StatusReg & 1); - } else { - /*********************************************************************/ - /* Reference not initialised see function "i_APCI1710_InitReference" */ - /*********************************************************************/ - - DPRINTK("Reference not initialised\n"); - i_ReturnValue = -4; - } - } else { - /****************************************/ - /* Counter not initialised see function */ - /* "i_APCI1710_InitCounter" */ - /****************************************/ - - DPRINTK("Counter not initialised\n"); - i_ReturnValue = -3; - } - } else { - /*************************************************/ - /* The selected module number parameter is wrong */ - /*************************************************/ - - DPRINTK("The selected module number parameter is wrong\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_GetUASStatus | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char *_ pb_UASStatus) | -+----------------------------------------------------------------------------+ -| Task : Return the error signal (UAS) status | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr : Module number to configure | -| (0 to 3) | -+----------------------------------------------------------------------------+ -| Output Parameters : unsigned char *_ pb_UASStatus : 0 : UAS is low "0" | -| 1 : UAS is high "1" | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: No counter module found | -| -3: Counter not initialised see function | -| "i_APCI1710_InitCounter" | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_GetUASStatus(struct comedi_device *dev, - unsigned char b_ModulNbr, - unsigned char *pb_UASStatus) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - unsigned int dw_StatusReg = 0; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /*******************************/ - /* Test if counter initialised */ - /*******************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) { - dw_StatusReg = inl(devpriv->s_BoardInfos. - ui_Address + 24 + (64 * b_ModulNbr)); - - *pb_UASStatus = (unsigned char) ((dw_StatusReg >> 1) & 1); - } else { - /****************************************/ - /* Counter not initialised see function */ - /* "i_APCI1710_InitCounter" */ - /****************************************/ - - DPRINTK("Counter not initialised\n"); - i_ReturnValue = -3; - } - } else { - /*************************************************/ - /* The selected module number parameter is wrong */ - /*************************************************/ - - DPRINTK("The selected module number parameter is wrong\n"); - i_ReturnValue = -2; - - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_GetCBStatus | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char *_ pb_CBStatus) | -+----------------------------------------------------------------------------+ -| Task : Return the counter overflow status | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr : Module number to configure | -| (0 to 3) | -+----------------------------------------------------------------------------+ -| Output Parameters : unsigned char *_ pb_CBStatus : 0 : Counter no overflow | -| 1 : Counter overflow | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: No counter module found | -| -3: Counter not initialised see function | -| "i_APCI1710_InitCounter" | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_GetCBStatus(struct comedi_device *dev, - unsigned char b_ModulNbr, - unsigned char *pb_CBStatus) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - unsigned int dw_StatusReg = 0; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /*******************************/ - /* Test if counter initialised */ - /*******************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) { - dw_StatusReg = inl(devpriv->s_BoardInfos. - ui_Address + 16 + (64 * b_ModulNbr)); - - *pb_CBStatus = (unsigned char) (dw_StatusReg & 1); - - } else { - /****************************************/ - /* Counter not initialised see function */ - /* "i_APCI1710_InitCounter" */ - /****************************************/ - - DPRINTK("Counter not initialised\n"); - i_ReturnValue = -3; - } - } else { - /*************************************************/ - /* The selected module number parameter is wrong */ - /*************************************************/ - - DPRINTK("The selected module number parameter is wrong\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_Get16BitCBStatus | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char *_ pb_CBStatusCounter0, | -| unsigned char *_ pb_CBStatusCounter1) | -+----------------------------------------------------------------------------+ -| Task : Returns the counter overflow (counter initialised to | -| 2*16-bit) status from selected incremental counter | -| module | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr : Module number to configure | -| (0 to 3) | -+----------------------------------------------------------------------------+ -| Output Parameters : unsigned char *_ pb_CBStatusCounter0 : 0 : No overflow occur for | -| the first 16-bit | -| counter | -| 1 : Overflow occur for the| -| first 16-bit counter | -| unsigned char *_ pb_CBStatusCounter1 : 0 : No overflow occur for | -| the second 16-bit | -| counter | -| 1 : Overflow occur for the| -| second 16-bit counter | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: No counter module found | -| -3: Counter not initialised see function | -| "i_APCI1710_InitCounter" | -| -4: Counter not initialised to 2*16-bit mode. | -| See function "i_APCI1710_InitCounter" | -| -5: Firmware revision error | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_Get16BitCBStatus(struct comedi_device *dev, - unsigned char b_ModulNbr, - unsigned char *pb_CBStatusCounter0, - unsigned char *pb_CBStatusCounter1) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - unsigned int dw_StatusReg = 0; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /*******************************/ - /* Test if counter initialised */ - /*******************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) { - /*************************/ - /* Test if 2*16-Bit mode */ - /*************************/ - - if ((devpriv->s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister1 & 0x10) == 0x10) { - /*****************************/ - /* Test the Firmware version */ - /*****************************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration - [b_ModulNbr] & 0xFFFF) >= - 0x3136) { - dw_StatusReg = - inl(devpriv->s_BoardInfos. - ui_Address + 16 + - (64 * b_ModulNbr)); - - *pb_CBStatusCounter1 = - (unsigned char) ((dw_StatusReg >> 0) & - 1); - *pb_CBStatusCounter0 = - (unsigned char) ((dw_StatusReg >> 1) & - 1); - } /* if ((ps_APCI1710Variable->s_Board [b_BoardHandle].s_BoardInfos.dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF) >= 0x3136) */ - else { - /****************************/ - /* Firmware revision error */ - /****************************/ - - i_ReturnValue = -5; - } /* if ((ps_APCI1710Variable->s_Board [b_BoardHandle].s_BoardInfos.dw_MolduleConfiguration [b_ModulNbr] & 0xFFFF) >= 0x3136) */ - } /* if ((ps_APCI1710Variable->s_Board [b_BoardHandle].s_ModuleInfo [b_ModulNbr].s_SiemensCounterInfo.s_ModeRegister.s_ByteModeRegister.b_ModeRegister1 & 0x10) == 0x10) */ - else { - /********************************************/ - /* Counter not initialised to 2*16-bit mode */ - /* "i_APCI1710_InitCounter" */ - /********************************************/ - - DPRINTK("Counter not initialised\n"); - i_ReturnValue = -4; - } /* if ((ps_APCI1710Variable->s_Board [b_BoardHandle].s_ModuleInfo [b_ModulNbr].s_SiemensCounterInfo.s_ModeRegister.s_ByteModeRegister.b_ModeRegister1 & 0x10) == 0x10) */ - } /* if (ps_APCI1710Variable->s_Board [b_BoardHandle].s_ModuleInfo [b_ModulNbr].s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) */ - else { - /****************************************/ - /* Counter not initialised see function */ - /* "i_APCI1710_InitCounter" */ - /****************************************/ - - DPRINTK("Counter not initialised\n"); - i_ReturnValue = -3; - } /* if (ps_APCI1710Variable->s_Board [b_BoardHandle].s_ModuleInfo [b_ModulNbr].s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) */ - } /* if (b_ModulNbr < 4) */ - else { - /*************************************************/ - /* The selected module number parameter is wrong */ - /*************************************************/ - - DPRINTK("The selected module number parameter is wrong\n"); - i_ReturnValue = -2; - } /* if (b_ModulNbr < 4) */ - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_GetUDStatus | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char *_ pb_UDStatus) | -+----------------------------------------------------------------------------+ -| Task : Return the counter progress status | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr : Module number to configure | -| (0 to 3) | -+----------------------------------------------------------------------------+ -| Output Parameters : unsigned char *_ pb_UDStatus : 0 : Counter progress in the | -| selected mode down | -| 1 : Counter progress in the | -| selected mode up | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: No counter module found | -| -3: Counter not initialised see function | -| "i_APCI1710_InitCounter" | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_GetUDStatus(struct comedi_device *dev, - unsigned char b_ModulNbr, - unsigned char *pb_UDStatus) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - unsigned int dw_StatusReg = 0; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /*******************************/ - /* Test if counter initialised */ - /*******************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) { - dw_StatusReg = inl(devpriv->s_BoardInfos. - ui_Address + 24 + (64 * b_ModulNbr)); - - *pb_UDStatus = (unsigned char) ((dw_StatusReg >> 2) & 1); - - } else { - /****************************************/ - /* Counter not initialised see function */ - /* "i_APCI1710_InitCounter" */ - /****************************************/ - - DPRINTK("Counter not initialised\n"); - i_ReturnValue = -3; - } - } else { - /*************************************************/ - /* The selected module number parameter is wrong */ - /*************************************************/ - - DPRINTK("The selected module number parameter is wrong\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_GetInterruptUDLatchedStatus | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char *_ pb_UDStatus) | -+----------------------------------------------------------------------------+ -| Task : Return the counter progress latched status after a | -| index interrupt occur. | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr : Module number to configure | -| (0 to 3) | -+----------------------------------------------------------------------------+ -| Output Parameters : unsigned char *_ pb_UDStatus : 0 : Counter progress in the | -| selected mode down | -| 1 : Counter progress in the | -| selected mode up | -| 2 : No index interrupt occur | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: No counter module found | -| -3: Counter not initialised see function | -| "i_APCI1710_InitCounter" | -| -4: Interrupt function not initialised. | -| See function "i_APCI1710_SetBoardIntRoutineX" | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_GetInterruptUDLatchedStatus(struct comedi_device *dev, - unsigned char b_ModulNbr, - unsigned char *pb_UDStatus) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - unsigned int dw_StatusReg = 0; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /*******************************/ - /* Test if counter initialised */ - /*******************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) { - /*********************************/ - /* Test if index interrupt occur */ - /*********************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_InitFlag.b_IndexInterruptOccur == 1) { - devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_InitFlag.b_IndexInterruptOccur = 0; - - dw_StatusReg = inl(devpriv->s_BoardInfos. - ui_Address + 12 + (64 * b_ModulNbr)); - - *pb_UDStatus = (unsigned char) ((dw_StatusReg >> 1) & 1); - } else { - /****************************/ - /* No index interrupt occur */ - /****************************/ - - *pb_UDStatus = 2; - } - } else { - /****************************************/ - /* Counter not initialised see function */ - /* "i_APCI1710_InitCounter" */ - /****************************************/ - - DPRINTK("Counter not initialised\n"); - i_ReturnValue = -3; - } - } else { - /*************************************************/ - /* The selected module number parameter is wrong */ - /*************************************************/ - - DPRINTK("The selected module number parameter is wrong\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - - /* - +----------------------------------------------------------------------------+ - | Function Name : _INT_ i_APCI1710_ReadFrequencyMeasurement | - | (unsigned char_ b_BoardHandle, | - | unsigned char_ b_ModulNbr, | - | unsigned char *_ pb_Status, | - | PULONG_ pul_ReadValue) | - +----------------------------------------------------------------------------+ - | Task : Returns the status (pb_Status) and the number of | - | increments in the set time. | - | See function " i_APCI1710_InitFrequencyMeasurement " | - +----------------------------------------------------------------------------+ - | Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | - | unsigned char_ b_ModulNbr : Number of the module to be | - | configured (0 to 3) | - +----------------------------------------------------------------------------+ - | Output Parameters : unsigned char *_ pb_Status : Returns the frequency | - | measurement status | - | 0 : Counting cycle not | - | started. | - | 1 : Counting cycle started. | - | 2 : Counting cycle stopped. | - | The measurement cycle is | - | completed. | - | unsigned char *_ pb_UDStatus : 0 : Counter progress in the | - | selected mode down | - | 1 : Counter progress in the | - | selected mode up | - | PULONG_ pul_ReadValue : Return the number of | - | increments in the defined | - | time base. | - +----------------------------------------------------------------------------+ - | Return Value : 0: No error | - | -1: The handle parameter of the board is wrong | - | -2: The selected module number is wrong | - | -3: Counter not initialised see function | - | "i_APCI1710_InitCounter" | - | -4: Frequency measurement logic not initialised. | - | See function "i_APCI1710_InitFrequencyMeasurement" | - +----------------------------------------------------------------------------+ - */ -static int i_APCI1710_ReadFrequencyMeasurement(struct comedi_device *dev, - unsigned char b_ModulNbr, - unsigned char *pb_Status, - unsigned char *pb_UDStatus, - unsigned int *pul_ReadValue) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - unsigned int ui_16BitValue; - unsigned int dw_StatusReg; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /*******************************/ - /* Test if counter initialised */ - /*******************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo.s_InitFlag.b_CounterInit == 1) { - /********************************************/ - /* Test if frequency measurement initialised */ - /********************************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_InitFlag.b_FrequencyMeasurementInit == 1) { - /******************/ - /* Test if enable */ - /******************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SiemensCounterInfo. - s_InitFlag. - b_FrequencyMeasurementEnable == 1) { - /*******************/ - /* Read the status */ - /*******************/ - - dw_StatusReg = - inl(devpriv->s_BoardInfos. - ui_Address + 32 + - (64 * b_ModulNbr)); - - /**************************/ - /* Test if frequency stop */ - /**************************/ - - if (dw_StatusReg & 1) { - *pb_Status = 2; - *pb_UDStatus = - (unsigned char) ((dw_StatusReg >> - 1) & 3); - - /******************/ - /* Read the value */ - /******************/ - - *pul_ReadValue = - inl(devpriv-> - s_BoardInfos. - ui_Address + 28 + - (64 * b_ModulNbr)); - - if (*pb_UDStatus == 0) { - /*************************/ - /* Test the counter mode */ - /*************************/ - - if ((devpriv->s_ModuleInfo[b_ModulNbr].s_SiemensCounterInfo.s_ModeRegister.s_ByteModeRegister.b_ModeRegister1 & APCI1710_16BIT_COUNTER) == APCI1710_16BIT_COUNTER) { - /****************************************/ - /* Test if 16-bit counter 1 pulse occur */ - /****************************************/ - - if ((*pul_ReadValue & 0xFFFFU) != 0) { - ui_16BitValue - = - (unsigned int) - * - pul_ReadValue - & - 0xFFFFU; - *pul_ReadValue - = - (*pul_ReadValue - & - 0xFFFF0000UL) - | - (0xFFFFU - - - ui_16BitValue); - } - - /****************************************/ - /* Test if 16-bit counter 2 pulse occur */ - /****************************************/ - - if ((*pul_ReadValue & 0xFFFF0000UL) != 0) { - ui_16BitValue - = - (unsigned int) - ( - (*pul_ReadValue - >> - 16) - & - 0xFFFFU); - *pul_ReadValue - = - (*pul_ReadValue - & - 0xFFFFUL) - | - ( - (0xFFFFU - ui_16BitValue) << 16); - } - } else { - if (*pul_ReadValue != 0) { - *pul_ReadValue - = - 0xFFFFFFFFUL - - - *pul_ReadValue; - } - } - } else { - if (*pb_UDStatus == 1) { - /****************************************/ - /* Test if 16-bit counter 2 pulse occur */ - /****************************************/ - - if ((*pul_ReadValue & 0xFFFF0000UL) != 0) { - ui_16BitValue - = - (unsigned int) - ( - (*pul_ReadValue - >> - 16) - & - 0xFFFFU); - *pul_ReadValue - = - (*pul_ReadValue - & - 0xFFFFUL) - | - ( - (0xFFFFU - ui_16BitValue) << 16); - } - } else { - if (*pb_UDStatus - == 2) { - /****************************************/ - /* Test if 16-bit counter 1 pulse occur */ - /****************************************/ - - if ((*pul_ReadValue & 0xFFFFU) != 0) { - ui_16BitValue - = - (unsigned int) - * - pul_ReadValue - & - 0xFFFFU; - *pul_ReadValue - = - (*pul_ReadValue - & - 0xFFFF0000UL) - | - (0xFFFFU - - - ui_16BitValue); - } - } - } - } - } else { - *pb_Status = 1; - *pb_UDStatus = 0; - } - } else { - *pb_Status = 0; - *pb_UDStatus = 0; - } - } else { - /***********************************************/ - /* Frequency measurement logic not initialised */ - /***********************************************/ - - DPRINTK("Frequency measurement logic not initialised\n"); - i_ReturnValue = -4; - } - } else { - /****************************************/ - /* Counter not initialised see function */ - /* "i_APCI1710_InitCounter" */ - /****************************************/ - - DPRINTK("Counter not initialised\n"); - i_ReturnValue = -3; - } - } else { - /*************************************************/ - /* The selected module number parameter is wrong */ - /*************************************************/ - - DPRINTK("The selected module number parameter is wrong\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} -/* - * Read and Get functions for INC_CPT - */ -static int i_APCI1710_InsnReadINCCPT(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - unsigned int ui_ReadType; - int i_ReturnValue = 0; - - ui_ReadType = CR_CHAN(insn->chanspec); - - devpriv->tsk_Current = current; /* Save the current process task structure */ - switch (ui_ReadType) { - case APCI1710_INCCPT_READLATCHREGISTERSTATUS: - i_ReturnValue = i_APCI1710_ReadLatchRegisterStatus(dev, - (unsigned char) CR_AREF(insn->chanspec), - (unsigned char) CR_RANGE(insn->chanspec), (unsigned char *) &data[0]); - break; - - case APCI1710_INCCPT_READLATCHREGISTERVALUE: - i_ReturnValue = i_APCI1710_ReadLatchRegisterValue(dev, - (unsigned char) CR_AREF(insn->chanspec), - (unsigned char) CR_RANGE(insn->chanspec), (unsigned int *) &data[0]); - printk("Latch Register Value %d\n", data[0]); - break; - - case APCI1710_INCCPT_READ16BITCOUNTERVALUE: - i_ReturnValue = i_APCI1710_Read16BitCounterValue(dev, - (unsigned char) CR_AREF(insn->chanspec), - (unsigned char) CR_RANGE(insn->chanspec), (unsigned int *) &data[0]); - break; - - case APCI1710_INCCPT_READ32BITCOUNTERVALUE: - i_ReturnValue = i_APCI1710_Read32BitCounterValue(dev, - (unsigned char) CR_AREF(insn->chanspec), (unsigned int *) &data[0]); - break; - - case APCI1710_INCCPT_GETINDEXSTATUS: - i_ReturnValue = i_APCI1710_GetIndexStatus(dev, - (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]); - break; - - case APCI1710_INCCPT_GETREFERENCESTATUS: - i_ReturnValue = i_APCI1710_GetReferenceStatus(dev, - (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]); - break; - - case APCI1710_INCCPT_GETUASSTATUS: - i_ReturnValue = i_APCI1710_GetUASStatus(dev, - (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]); - break; - - case APCI1710_INCCPT_GETCBSTATUS: - i_ReturnValue = i_APCI1710_GetCBStatus(dev, - (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]); - break; - - case APCI1710_INCCPT_GET16BITCBSTATUS: - i_ReturnValue = i_APCI1710_Get16BitCBStatus(dev, - (unsigned char) CR_AREF(insn->chanspec), - (unsigned char *) &data[0], (unsigned char *) &data[1]); - break; - - case APCI1710_INCCPT_GETUDSTATUS: - i_ReturnValue = i_APCI1710_GetUDStatus(dev, - (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]); - - break; - - case APCI1710_INCCPT_GETINTERRUPTUDLATCHEDSTATUS: - i_ReturnValue = i_APCI1710_GetInterruptUDLatchedStatus(dev, - (unsigned char) CR_AREF(insn->chanspec), (unsigned char *) &data[0]); - break; - - case APCI1710_INCCPT_READFREQUENCYMEASUREMENT: - i_ReturnValue = i_APCI1710_ReadFrequencyMeasurement(dev, - (unsigned char) CR_AREF(insn->chanspec), - (unsigned char *) &data[0], - (unsigned char *) &data[1], (unsigned int *) &data[2]); - break; - - case APCI1710_INCCPT_READINTERRUPT: - data[0] = devpriv->s_InterruptParameters. - s_FIFOInterruptParameters[devpriv-> - s_InterruptParameters.ui_Read].b_OldModuleMask; - data[1] = devpriv->s_InterruptParameters. - s_FIFOInterruptParameters[devpriv-> - s_InterruptParameters.ui_Read].ul_OldInterruptMask; - data[2] = devpriv->s_InterruptParameters. - s_FIFOInterruptParameters[devpriv-> - s_InterruptParameters.ui_Read].ul_OldCounterLatchValue; - - /**************************/ - /* Increment the read FIFO */ - /***************************/ - - devpriv-> - s_InterruptParameters. - ui_Read = (devpriv->s_InterruptParameters. - ui_Read + 1) % APCI1710_SAVE_INTERRUPT; - - break; - - default: - printk("ReadType Parameter wrong\n"); - } - - if (i_ReturnValue >= 0) - i_ReturnValue = insn->n; - return i_ReturnValue; - -} diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Inp_cpt.c b/drivers/staging/comedi/drivers/addi-data/APCI1710_Inp_cpt.c deleted file mode 100644 index 6bbcb06cc2794..0000000000000 --- a/drivers/staging/comedi/drivers/addi-data/APCI1710_Inp_cpt.c +++ /dev/null @@ -1,866 +0,0 @@ -/** -@verbatim - -Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. - - ADDI-DATA GmbH - Dieselstrasse 3 - D-77833 Ottersweier - Tel: +19(0)7223/9493-0 - Fax: +49(0)7223/9493-92 - http://www.addi-data.com - info@addi-data.com - -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 the License, or (at your option) any later version. - -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. - -@endverbatim -*/ -/* - - +-----------------------------------------------------------------------+ - | (C) ADDI-DATA GmbH Dieselstraße 3 D-77833 Ottersweier | - +-----------------------------------------------------------------------+ - | Tel : +49 (0) 7223/9493-0 | email : info@addi-data.com | - | Fax : +49 (0) 7223/9493-92 | Internet : http://www.addi-data.com | - +-----------------------------------------------------------------------+ - | Project : API APCI1710 | Compiler : gcc | - | Module name : Inp_CPT.C | Version : 2.96 | - +-------------------------------+---------------------------------------+ - | Project manager: Eric Stolz | Date : 02/12/2002 | - +-----------------------------------------------------------------------+ - | Description : APCI-1710 pulse encoder module | - | | - | | - +-----------------------------------------------------------------------+ - | UPDATES | - +-----------------------------------------------------------------------+ - | Date | Author | Description of updates | - +----------+-----------+------------------------------------------------+ - | | | | - |----------|-----------|------------------------------------------------| - | 08/05/00 | Guinot C | - 0400/0228 All Function in RING 0 | - | | | available | - +-----------------------------------------------------------------------+ -*/ - -#define APCI1710_SINGLE 0 -#define APCI1710_CONTINUOUS 1 - -#define APCI1710_PULSEENCODER_READ 0 -#define APCI1710_PULSEENCODER_WRITE 1 - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_InitPulseEncoder | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char_ b_PulseEncoderNbr, | -| unsigned char_ b_InputLevelSelection, | -| unsigned char_ b_TriggerOutputAction, | -| ULONG_ ul_StartValue) | -+----------------------------------------------------------------------------+ -| Task : Configure the pulse encoder operating mode selected via| -| b_ModulNbr and b_PulseEncoderNbr. The pulse encoder | -| after each pulse decrement the counter value from 1. | -| | -| You must calling this function be for you call any | -| other function witch access of pulse encoders. | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710| -| unsigned char_ b_ModulNbr : Module number to | -| configure (0 to 3) | -| unsigned char_ b_PulseEncoderNbr : Pulse encoder selection | -| (0 to 3) | -| unsigned char_ b_InputLevelSelection : Input level selection | -| (0 or 1) | -| 0 : Set pulse encoder| -| count the the low| -| level pulse. | -| 1 : Set pulse encoder| -| count the the | -| high level pulse.| -| unsigned char_ b_TriggerOutputAction : Digital TRIGGER output | -| action | -| 0 : No action | -| 1 : Set the trigger | -| output to "1" | -| (high) after the | -| passage from 1 to| -| 0 from pulse | -| encoder. | -| 2 : Set the trigger | -| output to "0" | -| (low) after the | -| passage from 1 to| -| 0 from pulse | -| encoder | -| ULONG_ ul_StartValue : Pulse encoder start value| -| (1 to 4294967295) - b_ModulNbr =(unsigned char) CR_AREF(insn->chanspec); - b_PulseEncoderNbr =(unsigned char) data[0]; - b_InputLevelSelection =(unsigned char) data[1]; - b_TriggerOutputAction =(unsigned char) data[2]; - ul_StartValue =(unsigned int) data[3]; - | -+----------------------------------------------------------------------------+ -| Output Parameters : - | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: The module is not a pulse encoder module | -| -3: Pulse encoder selection is wrong | -| -4: Input level selection is wrong | -| -5: Digital TRIGGER output action selection is wrong | -| -6: Pulse encoder start value is wrong | -+----------------------------------------------------------------------------+ -*/ - -static int i_APCI1710_InsnConfigInitPulseEncoder(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - unsigned int dw_IntRegister; - unsigned char b_ModulNbr; - unsigned char b_PulseEncoderNbr; - unsigned char b_InputLevelSelection; - unsigned char b_TriggerOutputAction; - unsigned int ul_StartValue; - - b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec); - b_PulseEncoderNbr = (unsigned char) data[0]; - b_InputLevelSelection = (unsigned char) data[1]; - b_TriggerOutputAction = (unsigned char) data[2]; - ul_StartValue = (unsigned int) data[3]; - - i_ReturnValue = insn->n; - - /***********************************/ - /* Test the selected module number */ - /***********************************/ - - if (b_ModulNbr <= 3) { - /*************************/ - /* Test if pulse encoder */ - /*************************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[b_ModulNbr] & - APCI1710_PULSE_ENCODER) == - APCI1710_PULSE_ENCODER) { - /******************************************/ - /* Test the selected pulse encoder number */ - /******************************************/ - - if (b_PulseEncoderNbr <= 3) { - /************************/ - /* Test the input level */ - /************************/ - - if ((b_InputLevelSelection == 0) - || (b_InputLevelSelection == 1)) { - /*******************************************/ - /* Test the ouput TRIGGER action selection */ - /*******************************************/ - - if ((b_TriggerOutputAction <= 2) - || (b_PulseEncoderNbr > 0)) { - if (ul_StartValue > 1) { - - dw_IntRegister = - inl(devpriv-> - s_BoardInfos. - ui_Address + - 20 + - (64 * b_ModulNbr)); - - /***********************/ - /* Set the start value */ - /***********************/ - - outl(ul_StartValue, - devpriv-> - s_BoardInfos. - ui_Address + - (b_PulseEncoderNbr - * 4) + - (64 * b_ModulNbr)); - - /***********************/ - /* Set the input level */ - /***********************/ - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_PulseEncoderModuleInfo. - dw_SetRegister = - (devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_PulseEncoderModuleInfo. - dw_SetRegister & - (0xFFFFFFFFUL - - (1UL << (8 + b_PulseEncoderNbr)))) | ((1UL & (~b_InputLevelSelection)) << (8 + b_PulseEncoderNbr)); - - /*******************************/ - /* Test if output trigger used */ - /*******************************/ - - if ((b_TriggerOutputAction > 0) && (b_PulseEncoderNbr > 1)) { - /****************************/ - /* Enable the output action */ - /****************************/ - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_PulseEncoderModuleInfo. - dw_SetRegister - = - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_PulseEncoderModuleInfo. - dw_SetRegister - | (1UL - << (4 + b_PulseEncoderNbr)); - - /*********************************/ - /* Set the output TRIGGER action */ - /*********************************/ - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_PulseEncoderModuleInfo. - dw_SetRegister - = - (devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_PulseEncoderModuleInfo. - dw_SetRegister - & - (0xFFFFFFFFUL - - - (1UL << (12 + b_PulseEncoderNbr)))) | ((1UL & (b_TriggerOutputAction - 1)) << (12 + b_PulseEncoderNbr)); - } else { - /*****************************/ - /* Disable the output action */ - /*****************************/ - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_PulseEncoderModuleInfo. - dw_SetRegister - = - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_PulseEncoderModuleInfo. - dw_SetRegister - & - (0xFFFFFFFFUL - - - (1UL << (4 + b_PulseEncoderNbr))); - } - - /*************************/ - /* Set the configuration */ - /*************************/ - - outl(devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_PulseEncoderModuleInfo. - dw_SetRegister, - devpriv-> - s_BoardInfos. - ui_Address + - 20 + - (64 * b_ModulNbr)); - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_PulseEncoderModuleInfo. - s_PulseEncoderInfo - [b_PulseEncoderNbr]. - b_PulseEncoderInit - = 1; - } else { - /**************************************/ - /* Pulse encoder start value is wrong */ - /**************************************/ - - DPRINTK("Pulse encoder start value is wrong\n"); - i_ReturnValue = -6; - } - } else { - /****************************************************/ - /* Digital TRIGGER output action selection is wrong */ - /****************************************************/ - - DPRINTK("Digital TRIGGER output action selection is wrong\n"); - i_ReturnValue = -5; - } - } else { - /**********************************/ - /* Input level selection is wrong */ - /**********************************/ - - DPRINTK("Input level selection is wrong\n"); - i_ReturnValue = -4; - } - } else { - /************************************/ - /* Pulse encoder selection is wrong */ - /************************************/ - - DPRINTK("Pulse encoder selection is wrong\n"); - i_ReturnValue = -3; - } - } else { - /********************************************/ - /* The module is not a pulse encoder module */ - /********************************************/ - - DPRINTK("The module is not a pulse encoder module\n"); - i_ReturnValue = -2; - } - } else { - /********************************************/ - /* The module is not a pulse encoder module */ - /********************************************/ - - DPRINTK("The module is not a pulse encoder module\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_EnablePulseEncoder | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char_ b_PulseEncoderNbr, | -| unsigned char_ b_CycleSelection, | -| unsigned char_ b_InterruptHandling) | -+----------------------------------------------------------------------------+ -| Task : Enableor disable the selected pulse encoder (b_PulseEncoderNbr) | -| from selected module (b_ModulNbr). Each input pulse | -| decrement the pulse encoder counter value from 1. | -| If you enabled the interrupt (b_InterruptHandling), a | -| interrupt is generated when the pulse encoder has run | -| down. | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710| -| unsigned char_ b_ModulNbr : Module number to | -| configure (0 to 3) | -| unsigned char_ b_PulseEncoderNbr : Pulse encoder selection | -| (0 to 3) | -| unsigned char_ b_CycleSelection : APCI1710_CONTINUOUS: | -| Each time the | -| counting value is set| -| on "0", the pulse | -| encoder load the | -| start value after | -| the next pulse. | -| APCI1710_SINGLE: | -| If the counter is set| -| on "0", the pulse | -| encoder is stopped. | -| unsigned char_ b_InterruptHandling : Interrupts can be | -| generated, when the pulse| -| encoder has run down. | -| With this parameter the | -| user decides if | -| interrupts are used or | -| not. | -| APCI1710_ENABLE: | -| Interrupts are enabled | -| APCI1710_DISABLE: | -| Interrupts are disabled - - b_ModulNbr =(unsigned char) CR_AREF(insn->chanspec); - b_Action =(unsigned char) data[0]; - b_PulseEncoderNbr =(unsigned char) data[1]; - b_CycleSelection =(unsigned char) data[2]; - b_InterruptHandling =(unsigned char) data[3];| -+----------------------------------------------------------------------------+ -| Output Parameters : - | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: Module selection is wrong | -| -3: Pulse encoder selection is wrong | -| -4: Pulse encoder not initialised. | -| See function "i_APCI1710_InitPulseEncoder" | -| -5: Cycle selection mode is wrong | -| -6: Interrupt handling mode is wrong | -| -7: Interrupt routine not installed. | -| See function "i_APCI1710_SetBoardIntRoutineX" | -+----------------------------------------------------------------------------+ -*/ - -static int i_APCI1710_InsnWriteEnableDisablePulseEncoder(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - unsigned char b_ModulNbr; - unsigned char b_PulseEncoderNbr; - unsigned char b_CycleSelection; - unsigned char b_InterruptHandling; - unsigned char b_Action; - - i_ReturnValue = insn->n; - b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec); - b_Action = (unsigned char) data[0]; - b_PulseEncoderNbr = (unsigned char) data[1]; - b_CycleSelection = (unsigned char) data[2]; - b_InterruptHandling = (unsigned char) data[3]; - - /***********************************/ - /* Test the selected module number */ - /***********************************/ - - if (b_ModulNbr <= 3) { - /******************************************/ - /* Test the selected pulse encoder number */ - /******************************************/ - - if (b_PulseEncoderNbr <= 3) { - /*************************************/ - /* Test if pulse encoder initialised */ - /*************************************/ - - if (devpriv->s_ModuleInfo[b_ModulNbr]. - s_PulseEncoderModuleInfo. - s_PulseEncoderInfo[b_PulseEncoderNbr]. - b_PulseEncoderInit == 1) { - switch (b_Action) { - - case APCI1710_ENABLE: - /****************************/ - /* Test the cycle selection */ - /****************************/ - - if (b_CycleSelection == - APCI1710_CONTINUOUS - || b_CycleSelection == - APCI1710_SINGLE) { - /*******************************/ - /* Test the interrupt handling */ - /*******************************/ - - if (b_InterruptHandling == - APCI1710_ENABLE - || b_InterruptHandling - == APCI1710_DISABLE) { - /******************************/ - /* Test if interrupt not used */ - /******************************/ - - if (b_InterruptHandling - == - APCI1710_DISABLE) - { - /*************************/ - /* Disable the interrupt */ - /*************************/ - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_PulseEncoderModuleInfo. - dw_SetRegister - = - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_PulseEncoderModuleInfo. - dw_SetRegister - & - (0xFFFFFFFFUL - - - (1UL << b_PulseEncoderNbr)); - } else { - - /************************/ - /* Enable the interrupt */ - /************************/ - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_PulseEncoderModuleInfo. - dw_SetRegister - = - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_PulseEncoderModuleInfo. - dw_SetRegister - | (1UL - << - b_PulseEncoderNbr); - devpriv->tsk_Current = current; /* Save the current process task structure */ - - } - - if (i_ReturnValue >= 0) { - /***********************************/ - /* Enable or disable the interrupt */ - /***********************************/ - - outl(devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_PulseEncoderModuleInfo. - dw_SetRegister, - devpriv-> - s_BoardInfos. - ui_Address - + 20 + - (64 * b_ModulNbr)); - - /****************************/ - /* Enable the pulse encoder */ - /****************************/ - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_PulseEncoderModuleInfo. - dw_ControlRegister - = - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_PulseEncoderModuleInfo. - dw_ControlRegister - | (1UL - << - b_PulseEncoderNbr); - - /**********************/ - /* Set the cycle mode */ - /**********************/ - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_PulseEncoderModuleInfo. - dw_ControlRegister - = - (devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_PulseEncoderModuleInfo. - dw_ControlRegister - & - (0xFFFFFFFFUL - - - (1 << (b_PulseEncoderNbr + 4)))) | ((b_CycleSelection & 1UL) << (4 + b_PulseEncoderNbr)); - - /****************************/ - /* Enable the pulse encoder */ - /****************************/ - - outl(devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_PulseEncoderModuleInfo. - dw_ControlRegister, - devpriv-> - s_BoardInfos. - ui_Address - + 16 + - (64 * b_ModulNbr)); - } - } else { - /************************************/ - /* Interrupt handling mode is wrong */ - /************************************/ - - DPRINTK("Interrupt handling mode is wrong\n"); - i_ReturnValue = -6; - } - } else { - /*********************************/ - /* Cycle selection mode is wrong */ - /*********************************/ - - DPRINTK("Cycle selection mode is wrong\n"); - i_ReturnValue = -5; - } - break; - - case APCI1710_DISABLE: - devpriv->s_ModuleInfo[b_ModulNbr]. - s_PulseEncoderModuleInfo. - dw_ControlRegister = - devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_PulseEncoderModuleInfo. - dw_ControlRegister & - (0xFFFFFFFFUL - - (1UL << b_PulseEncoderNbr)); - - /*****************************/ - /* Disable the pulse encoder */ - /*****************************/ - - outl(devpriv->s_ModuleInfo[b_ModulNbr]. - s_PulseEncoderModuleInfo. - dw_ControlRegister, - devpriv->s_BoardInfos. - ui_Address + 16 + - (64 * b_ModulNbr)); - - break; - } /* switch End */ - - } else { - /*********************************/ - /* Pulse encoder not initialised */ - /*********************************/ - - DPRINTK("Pulse encoder not initialised\n"); - i_ReturnValue = -4; - } - } else { - /************************************/ - /* Pulse encoder selection is wrong */ - /************************************/ - - DPRINTK("Pulse encoder selection is wrong\n"); - i_ReturnValue = -3; - } - } else { - /*****************************/ - /* Module selection is wrong */ - /*****************************/ - - DPRINTK("Module selection is wrong\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_ReadPulseEncoderStatus | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char_ b_PulseEncoderNbr, | -| unsigned char *_ pb_Status) | -+----------------------------------------------------------------------------+ -| Task APCI1710_PULSEENCODER_READ : Reads the pulse encoder status - and valuefrom selected pulse | -| encoder (b_PulseEncoderNbr) from selected module | -| (b_ModulNbr). | -+----------------------------------------------------------------------------+ - unsigned char b_Type; data[0] - APCI1710_PULSEENCODER_WRITE - Writes a 32-bit value (ul_WriteValue) into the selected| -| pulse encoder (b_PulseEncoderNbr) from selected module | -| (b_ModulNbr). This operation set the new start pulse | -| encoder value. - APCI1710_PULSEENCODER_READ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710| -| CRAREF() unsigned char_ b_ModulNbr : Module number to | -| configure (0 to 3) | -| data[1] unsigned char_ b_PulseEncoderNbr : Pulse encoder selection | -| (0 to 3) - APCI1710_PULSEENCODER_WRITE - data[2] ULONG_ ul_WriteValue : 32-bit value to be | -| written | -+----------------------------------------------------------------------------+ -| Output Parameters : unsigned char *_ pb_Status : Pulse encoder status. | -| 0 : No overflow occur| -| 1 : Overflow occur - PULONG_ pul_ReadValue : Pulse encoder value | | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: Module selection is wrong | -| -3: Pulse encoder selection is wrong | -| -4: Pulse encoder not initialised. | -| See function "i_APCI1710_InitPulseEncoder" | -+----------------------------------------------------------------------------+ -*/ - -/*_INT_ i_APCI1710_ReadPulseEncoderStatus (unsigned char_ b_BoardHandle, - unsigned char_ b_ModulNbr, - unsigned char_ b_PulseEncoderNbr, - - unsigned char *_ pb_Status) - */ -static int i_APCI1710_InsnBitsReadWritePulseEncoder(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - unsigned int dw_StatusRegister; - unsigned char b_ModulNbr; - unsigned char b_PulseEncoderNbr; - unsigned char *pb_Status; - unsigned char b_Type; - unsigned int *pul_ReadValue; - unsigned int ul_WriteValue; - - i_ReturnValue = insn->n; - b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec); - b_Type = (unsigned char) data[0]; - b_PulseEncoderNbr = (unsigned char) data[1]; - pb_Status = (unsigned char *) &data[0]; - pul_ReadValue = (unsigned int *) &data[1]; - - /***********************************/ - /* Test the selected module number */ - /***********************************/ - - if (b_ModulNbr <= 3) { - /******************************************/ - /* Test the selected pulse encoder number */ - /******************************************/ - - if (b_PulseEncoderNbr <= 3) { - /*************************************/ - /* Test if pulse encoder initialised */ - /*************************************/ - - if (devpriv->s_ModuleInfo[b_ModulNbr]. - s_PulseEncoderModuleInfo. - s_PulseEncoderInfo[b_PulseEncoderNbr]. - b_PulseEncoderInit == 1) { - - switch (b_Type) { - case APCI1710_PULSEENCODER_READ: - /****************************/ - /* Read the status register */ - /****************************/ - - dw_StatusRegister = - inl(devpriv->s_BoardInfos. - ui_Address + 16 + - (64 * b_ModulNbr)); - - devpriv->s_ModuleInfo[b_ModulNbr]. - s_PulseEncoderModuleInfo. - dw_StatusRegister = devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_PulseEncoderModuleInfo. - dw_StatusRegister | - dw_StatusRegister; - - *pb_Status = - (unsigned char) (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_PulseEncoderModuleInfo. - dw_StatusRegister >> (1 + - b_PulseEncoderNbr)) & 1; - - devpriv->s_ModuleInfo[b_ModulNbr]. - s_PulseEncoderModuleInfo. - dw_StatusRegister = - devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_PulseEncoderModuleInfo. - dw_StatusRegister & - (0xFFFFFFFFUL - (1 << (1 + - b_PulseEncoderNbr))); - - /******************/ - /* Read the value */ - /******************/ - - *pul_ReadValue = - inl(devpriv->s_BoardInfos. - ui_Address + - (4 * b_PulseEncoderNbr) + - (64 * b_ModulNbr)); - break; - - case APCI1710_PULSEENCODER_WRITE: - ul_WriteValue = (unsigned int) data[2]; - /*******************/ - /* Write the value */ - /*******************/ - - outl(ul_WriteValue, - devpriv->s_BoardInfos. - ui_Address + - (4 * b_PulseEncoderNbr) + - (64 * b_ModulNbr)); - - } /* end of switch */ - } else { - /*********************************/ - /* Pulse encoder not initialised */ - /*********************************/ - - DPRINTK("Pulse encoder not initialised\n"); - i_ReturnValue = -4; - } - } else { - /************************************/ - /* Pulse encoder selection is wrong */ - /************************************/ - - DPRINTK("Pulse encoder selection is wrong\n"); - i_ReturnValue = -3; - } - } else { - /*****************************/ - /* Module selection is wrong */ - /*****************************/ - - DPRINTK("Module selection is wrong\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -static int i_APCI1710_InsnReadInterruptPulseEncoder(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - - data[0] = devpriv->s_InterruptParameters. - s_FIFOInterruptParameters[devpriv-> - s_InterruptParameters.ui_Read].b_OldModuleMask; - data[1] = devpriv->s_InterruptParameters. - s_FIFOInterruptParameters[devpriv-> - s_InterruptParameters.ui_Read].ul_OldInterruptMask; - data[2] = devpriv->s_InterruptParameters. - s_FIFOInterruptParameters[devpriv-> - s_InterruptParameters.ui_Read].ul_OldCounterLatchValue; - - /***************************/ - /* Increment the read FIFO */ - /***************************/ - - devpriv->s_InterruptParameters. - ui_Read = (devpriv-> - s_InterruptParameters.ui_Read + 1) % APCI1710_SAVE_INTERRUPT; - - return insn->n; - -} diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Pwm.c b/drivers/staging/comedi/drivers/addi-data/APCI1710_Pwm.c deleted file mode 100644 index 5c830337db857..0000000000000 --- a/drivers/staging/comedi/drivers/addi-data/APCI1710_Pwm.c +++ /dev/null @@ -1,3582 +0,0 @@ -/** -@verbatim - -Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. - - ADDI-DATA GmbH - Dieselstrasse 3 - D-77833 Ottersweier - Tel: +19(0)7223/9493-0 - Fax: +49(0)7223/9493-92 - http://www.addi-data.com - info@addi-data.com - -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 the License, or (at your option) any later version. - -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. - -@endverbatim -*/ -/* - - +-----------------------------------------------------------------------+ - | (C) ADDI-DATA GmbH Dieselstraße 3 D-77833 Ottersweier | - +-----------------------------------------------------------------------+ - | Tel : +49 (0) 7223/9493-0 | email : info@addi-data.com | - | Fax : +49 (0) 7223/9493-92 | Internet : http://www.addi-data.com | - +-----------------------------------------------------------------------+ - | Project : API APCI1710 | Compiler : gcc | - | Module name : PWM.C | Version : 2.96 | - +-------------------------------+---------------------------------------+ - | Project manager: Eric Stolz | Date : 02/12/2002 | - +-----------------------------------------------------------------------+ - | Description : APCI-1710 Wulse wide modulation module | - | | - | | - +-----------------------------------------------------------------------+ - | UPDATES | - +-----------------------------------------------------------------------+ - | Date | Author | Description of updates | - +-----------------------------------------------------------------------+ - | 08/05/00 | Guinot C | - 0400/0228 All Function in RING 0 | - | | | available | - +-----------------------------------------------------------------------+ -*/ - -#define APCI1710_30MHZ 30 -#define APCI1710_33MHZ 33 -#define APCI1710_40MHZ 40 - -#define APCI1710_PWM_INIT 0 -#define APCI1710_PWM_GETINITDATA 1 - -#define APCI1710_PWM_DISABLE 0 -#define APCI1710_PWM_ENABLE 1 -#define APCI1710_PWM_NEWTIMING 2 - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_InitPWM | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char_ b_PWM, | -| unsigned char_ b_ClockSelection, | -| unsigned char_ b_TimingUnit, | -| ULONG_ ul_LowTiming, | -| ULONG_ ul_HighTiming, | -| PULONG_ pul_RealLowTiming, | -| PULONG_ pul_RealHighTiming) | -+----------------------------------------------------------------------------+ -| Task : Configure the selected PWM (b_PWM) from selected module| -| (b_ModulNbr). The ul_LowTiming, ul_HighTiming and | -| ul_TimingUnit determine the low/high timing base for | -| the period. pul_RealLowTiming, pul_RealHighTiming | -| return the real timing value. | -| You must calling this function be for you call any | -| other function witch access of the PWM. | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr : Module number to configure| -| (0 to 3) | -| unsigned char_ b_PWM : Selected PWM (0 or 1). | -| unsigned char_ b_ClockSelection : Selection from PCI bus | -| clock | -| - APCI1710_30MHZ : | -| The PC have a 30 MHz | -| PCI bus clock | -| - APCI1710_33MHZ : | -| The PC have a 33 MHz | -| PCI bus clock | -| - APCI1710_40MHZ | -| The APCI-1710 have a | -| integrated 40Mhz | -| quartz. | -| unsigned char_ b_TimingUnit : Base timing Unit (0 to 4) | -| 0 : ns | -| 1 : æs | -| 2 : ms | -| 3 : s | -| 4 : mn | -| ULONG_ ul_LowTiming : Low base timing value. | -| ULONG_ ul_HighTiming : High base timing value. | -+----------------------------------------------------------------------------+ -| Output Parameters : PULONG_ pul_RealLowTiming : Real low base timing | -| value. | -| PULONG_ pul_RealHighTiming : Real high base timing | -| value. | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: Module selection wrong | -| -3: The module is not a PWM module | -| -4: PWM selection is wrong | -| -5: The selected input clock is wrong | -| -6: Timing Unit selection is wrong | -| -7: Low base timing selection is wrong | -| -8: High base timing selection is wrong | -| -9: You can not used the 40MHz clock selection with | -| this board | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_InitPWM(struct comedi_device *dev, - unsigned char b_ModulNbr, - unsigned char b_PWM, - unsigned char b_ClockSelection, - unsigned char b_TimingUnit, - unsigned int ul_LowTiming, - unsigned int ul_HighTiming, - unsigned int *pul_RealLowTiming, - unsigned int *pul_RealHighTiming) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - unsigned int ul_LowTimerValue = 0; - unsigned int ul_HighTimerValue = 0; - unsigned int dw_Command; - double d_RealLowTiming = 0; - double d_RealHighTiming = 0; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /***************/ - /* Test if PWM */ - /***************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[b_ModulNbr] & - 0xFFFF0000UL) == APCI1710_PWM) { - /**************************/ - /* Test the PWM selection */ - /**************************/ - - if (b_PWM <= 1) { - /******************/ - /* Test the clock */ - /******************/ - - if ((b_ClockSelection == APCI1710_30MHZ) || - (b_ClockSelection == APCI1710_33MHZ) || - (b_ClockSelection == APCI1710_40MHZ)) { - /************************/ - /* Test the timing unit */ - /************************/ - - if (b_TimingUnit <= 4) { - /*********************************/ - /* Test the low timing selection */ - /*********************************/ - - if (((b_ClockSelection == - APCI1710_30MHZ) - && (b_TimingUnit - == 0) - && (ul_LowTiming - >= 266) - && (ul_LowTiming - <= - 0xFFFFFFFFUL)) - || ((b_ClockSelection == - APCI1710_30MHZ) - && (b_TimingUnit - == 1) - && (ul_LowTiming - >= 1) - && (ul_LowTiming - <= - 571230650UL)) - || ((b_ClockSelection == - APCI1710_30MHZ) - && (b_TimingUnit - == 2) - && (ul_LowTiming - >= 1) - && (ul_LowTiming - <= - 571230UL)) - || ((b_ClockSelection == - APCI1710_30MHZ) - && (b_TimingUnit - == 3) - && (ul_LowTiming - >= 1) - && (ul_LowTiming - <= - 571UL)) - || ((b_ClockSelection == - APCI1710_30MHZ) - && (b_TimingUnit - == 4) - && (ul_LowTiming - >= 1) - && (ul_LowTiming - <= 9UL)) - || ((b_ClockSelection == - APCI1710_33MHZ) - && (b_TimingUnit - == 0) - && (ul_LowTiming - >= 242) - && (ul_LowTiming - <= - 0xFFFFFFFFUL)) - || ((b_ClockSelection == - APCI1710_33MHZ) - && (b_TimingUnit - == 1) - && (ul_LowTiming - >= 1) - && (ul_LowTiming - <= - 519691043UL)) - || ((b_ClockSelection == - APCI1710_33MHZ) - && (b_TimingUnit - == 2) - && (ul_LowTiming - >= 1) - && (ul_LowTiming - <= - 519691UL)) - || ((b_ClockSelection == - APCI1710_33MHZ) - && (b_TimingUnit - == 3) - && (ul_LowTiming - >= 1) - && (ul_LowTiming - <= - 520UL)) - || ((b_ClockSelection == - APCI1710_33MHZ) - && (b_TimingUnit - == 4) - && (ul_LowTiming - >= 1) - && (ul_LowTiming - <= 8UL)) - || ((b_ClockSelection == - APCI1710_40MHZ) - && (b_TimingUnit - == 0) - && (ul_LowTiming - >= 200) - && (ul_LowTiming - <= - 0xFFFFFFFFUL)) - || ((b_ClockSelection == - APCI1710_40MHZ) - && (b_TimingUnit - == 1) - && (ul_LowTiming - >= 1) - && (ul_LowTiming - <= - 429496729UL)) - || ((b_ClockSelection == - APCI1710_40MHZ) - && (b_TimingUnit - == 2) - && (ul_LowTiming - >= 1) - && (ul_LowTiming - <= - 429496UL)) - || ((b_ClockSelection == - APCI1710_40MHZ) - && (b_TimingUnit - == 3) - && (ul_LowTiming - >= 1) - && (ul_LowTiming - <= - 429UL)) - || ((b_ClockSelection == - APCI1710_40MHZ) - && (b_TimingUnit - == 4) - && (ul_LowTiming - >= 1) - && (ul_LowTiming - <= - 7UL))) { - /**********************************/ - /* Test the High timing selection */ - /**********************************/ - - if (((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 0) && (ul_HighTiming >= 266) && (ul_HighTiming <= 0xFFFFFFFFUL)) || ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 1) && (ul_HighTiming >= 1) && (ul_HighTiming <= 571230650UL)) || ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 2) && (ul_HighTiming >= 1) && (ul_HighTiming <= 571230UL)) || ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 3) && (ul_HighTiming >= 1) && (ul_HighTiming <= 571UL)) || ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 4) && (ul_HighTiming >= 1) && (ul_HighTiming <= 9UL)) || ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 0) && (ul_HighTiming >= 242) && (ul_HighTiming <= 0xFFFFFFFFUL)) || ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 1) && (ul_HighTiming >= 1) && (ul_HighTiming <= 519691043UL)) || ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 2) && (ul_HighTiming >= 1) && (ul_HighTiming <= 519691UL)) || ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 3) && (ul_HighTiming >= 1) && (ul_HighTiming <= 520UL)) || ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 4) && (ul_HighTiming >= 1) && (ul_HighTiming <= 8UL)) || ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 0) && (ul_HighTiming >= 200) && (ul_HighTiming <= 0xFFFFFFFFUL)) || ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 1) && (ul_HighTiming >= 1) && (ul_HighTiming <= 429496729UL)) || ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 2) && (ul_HighTiming >= 1) && (ul_HighTiming <= 429496UL)) || ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 3) && (ul_HighTiming >= 1) && (ul_HighTiming <= 429UL)) || ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 4) && (ul_HighTiming >= 1) && (ul_HighTiming <= 7UL))) { - /**************************/ - /* Test the board version */ - /**************************/ - - if (((b_ClockSelection == APCI1710_40MHZ) && (devpriv->s_BoardInfos.b_BoardVersion > 0)) || (b_ClockSelection != APCI1710_40MHZ)) { - - /************************************/ - /* Calculate the low division fator */ - /************************************/ - - fpu_begin - (); - - switch (b_TimingUnit) { - /******/ - /* ns */ - /******/ - - case 0: - - /******************/ - /* Timer 0 factor */ - /******************/ - - ul_LowTimerValue - = - (unsigned int) - (ul_LowTiming - * - (0.00025 * b_ClockSelection)); - - /*******************/ - /* Round the value */ - /*******************/ - - if ((double)((double)ul_LowTiming * (0.00025 * (double)b_ClockSelection)) >= ((double)((double)ul_LowTimerValue + 0.5))) { - ul_LowTimerValue - = - ul_LowTimerValue - + - 1; - } - - /*****************************/ - /* Calculate the real timing */ - /*****************************/ - - *pul_RealLowTiming - = - (unsigned int) - (ul_LowTimerValue - / - (0.00025 * (double)b_ClockSelection)); - d_RealLowTiming - = - (double) - ul_LowTimerValue - / - (0.00025 - * - (double) - b_ClockSelection); - - if ((double)((double)ul_LowTimerValue / (0.00025 * (double)b_ClockSelection)) >= (double)((double)*pul_RealLowTiming + 0.5)) { - *pul_RealLowTiming - = - *pul_RealLowTiming - + - 1; - } - - ul_LowTiming - = - ul_LowTiming - - - 1; - ul_LowTimerValue - = - ul_LowTimerValue - - - 2; - - if (b_ClockSelection != APCI1710_40MHZ) { - ul_LowTimerValue - = - (unsigned int) - ( - (double) - (ul_LowTimerValue) - * - 1.007752288); - } - - break; - - /******/ - /* æs */ - /******/ - - case 1: - - /******************/ - /* Timer 0 factor */ - /******************/ - - ul_LowTimerValue - = - (unsigned int) - (ul_LowTiming - * - (0.25 * b_ClockSelection)); - - /*******************/ - /* Round the value */ - /*******************/ - - if ((double)((double)ul_LowTiming * (0.25 * (double)b_ClockSelection)) >= ((double)((double)ul_LowTimerValue + 0.5))) { - ul_LowTimerValue - = - ul_LowTimerValue - + - 1; - } - - /*****************************/ - /* Calculate the real timing */ - /*****************************/ - - *pul_RealLowTiming - = - (unsigned int) - (ul_LowTimerValue - / - (0.25 * (double)b_ClockSelection)); - d_RealLowTiming - = - (double) - ul_LowTimerValue - / - ( - (double) - 0.25 - * - (double) - b_ClockSelection); - - if ((double)((double)ul_LowTimerValue / (0.25 * (double)b_ClockSelection)) >= (double)((double)*pul_RealLowTiming + 0.5)) { - *pul_RealLowTiming - = - *pul_RealLowTiming - + - 1; - } - - ul_LowTiming - = - ul_LowTiming - - - 1; - ul_LowTimerValue - = - ul_LowTimerValue - - - 2; - - if (b_ClockSelection != APCI1710_40MHZ) { - ul_LowTimerValue - = - (unsigned int) - ( - (double) - (ul_LowTimerValue) - * - 1.007752288); - } - - break; - - /******/ - /* ms */ - /******/ - - case 2: - - /******************/ - /* Timer 0 factor */ - /******************/ - - ul_LowTimerValue - = - ul_LowTiming - * - (250.0 - * - b_ClockSelection); - - /*******************/ - /* Round the value */ - /*******************/ - - if ((double)((double)ul_LowTiming * (250.0 * (double)b_ClockSelection)) >= ((double)((double)ul_LowTimerValue + 0.5))) { - ul_LowTimerValue - = - ul_LowTimerValue - + - 1; - } - - /*****************************/ - /* Calculate the real timing */ - /*****************************/ - - *pul_RealLowTiming - = - (unsigned int) - (ul_LowTimerValue - / - (250.0 * (double)b_ClockSelection)); - d_RealLowTiming - = - (double) - ul_LowTimerValue - / - (250.0 - * - (double) - b_ClockSelection); - - if ((double)((double)ul_LowTimerValue / (250.0 * (double)b_ClockSelection)) >= (double)((double)*pul_RealLowTiming + 0.5)) { - *pul_RealLowTiming - = - *pul_RealLowTiming - + - 1; - } - - ul_LowTiming - = - ul_LowTiming - - - 1; - ul_LowTimerValue - = - ul_LowTimerValue - - - 2; - - if (b_ClockSelection != APCI1710_40MHZ) { - ul_LowTimerValue - = - (unsigned int) - ( - (double) - (ul_LowTimerValue) - * - 1.007752288); - } - - break; - - /*****/ - /* s */ - /*****/ - - case 3: - /******************/ - /* Timer 0 factor */ - /******************/ - - ul_LowTimerValue - = - (unsigned int) - (ul_LowTiming - * - (250000.0 - * - b_ClockSelection)); - - /*******************/ - /* Round the value */ - /*******************/ - - if ((double)((double)ul_LowTiming * (250000.0 * (double)b_ClockSelection)) >= ((double)((double)ul_LowTimerValue + 0.5))) { - ul_LowTimerValue - = - ul_LowTimerValue - + - 1; - } - - /*****************************/ - /* Calculate the real timing */ - /*****************************/ - - *pul_RealLowTiming - = - (unsigned int) - (ul_LowTimerValue - / - (250000.0 - * - (double) - b_ClockSelection)); - d_RealLowTiming - = - (double) - ul_LowTimerValue - / - (250000.0 - * - (double) - b_ClockSelection); - - if ((double)((double)ul_LowTimerValue / (250000.0 * (double)b_ClockSelection)) >= (double)((double)*pul_RealLowTiming + 0.5)) { - *pul_RealLowTiming - = - *pul_RealLowTiming - + - 1; - } - - ul_LowTiming - = - ul_LowTiming - - - 1; - ul_LowTimerValue - = - ul_LowTimerValue - - - 2; - - if (b_ClockSelection != APCI1710_40MHZ) { - ul_LowTimerValue - = - (unsigned int) - ( - (double) - (ul_LowTimerValue) - * - 1.007752288); - } - - break; - - /******/ - /* mn */ - /******/ - - case 4: - - /******************/ - /* Timer 0 factor */ - /******************/ - - ul_LowTimerValue - = - (unsigned int) - ( - (ul_LowTiming - * - 60) - * - (250000.0 - * - b_ClockSelection)); - - /*******************/ - /* Round the value */ - /*******************/ - - if ((double)((double)(ul_LowTiming * 60.0) * (250000.0 * (double)b_ClockSelection)) >= ((double)((double)ul_LowTimerValue + 0.5))) { - ul_LowTimerValue - = - ul_LowTimerValue - + - 1; - } - - /*****************************/ - /* Calculate the real timing */ - /*****************************/ - - *pul_RealLowTiming - = - (unsigned int) - (ul_LowTimerValue - / - (250000.0 - * - (double) - b_ClockSelection)) - / - 60; - d_RealLowTiming - = - ( - (double) - ul_LowTimerValue - / - (250000.0 - * - (double) - b_ClockSelection)) - / - 60.0; - - if ((double)(((double)ul_LowTimerValue / (250000.0 * (double)b_ClockSelection)) / 60.0) >= (double)((double)*pul_RealLowTiming + 0.5)) { - *pul_RealLowTiming - = - *pul_RealLowTiming - + - 1; - } - - ul_LowTiming - = - ul_LowTiming - - - 1; - ul_LowTimerValue - = - ul_LowTimerValue - - - 2; - - if (b_ClockSelection != APCI1710_40MHZ) { - ul_LowTimerValue - = - (unsigned int) - ( - (double) - (ul_LowTimerValue) - * - 1.007752288); - } - - break; - } - - /*************************************/ - /* Calculate the high division fator */ - /*************************************/ - - switch (b_TimingUnit) { - /******/ - /* ns */ - /******/ - - case 0: - - /******************/ - /* Timer 0 factor */ - /******************/ - - ul_HighTimerValue - = - (unsigned int) - (ul_HighTiming - * - (0.00025 * b_ClockSelection)); - - /*******************/ - /* Round the value */ - /*******************/ - - if ((double)((double)ul_HighTiming * (0.00025 * (double)b_ClockSelection)) >= ((double)((double)ul_HighTimerValue + 0.5))) { - ul_HighTimerValue - = - ul_HighTimerValue - + - 1; - } - - /*****************************/ - /* Calculate the real timing */ - /*****************************/ - - *pul_RealHighTiming - = - (unsigned int) - (ul_HighTimerValue - / - (0.00025 * (double)b_ClockSelection)); - d_RealHighTiming - = - (double) - ul_HighTimerValue - / - (0.00025 - * - (double) - b_ClockSelection); - - if ((double)((double)ul_HighTimerValue / (0.00025 * (double)b_ClockSelection)) >= (double)((double)*pul_RealHighTiming + 0.5)) { - *pul_RealHighTiming - = - *pul_RealHighTiming - + - 1; - } - - ul_HighTiming - = - ul_HighTiming - - - 1; - ul_HighTimerValue - = - ul_HighTimerValue - - - 2; - - if (b_ClockSelection != APCI1710_40MHZ) { - ul_HighTimerValue - = - (unsigned int) - ( - (double) - (ul_HighTimerValue) - * - 1.007752288); - } - - break; - - /******/ - /* æs */ - /******/ - - case 1: - - /******************/ - /* Timer 0 factor */ - /******************/ - - ul_HighTimerValue - = - (unsigned int) - (ul_HighTiming - * - (0.25 * b_ClockSelection)); - - /*******************/ - /* Round the value */ - /*******************/ - - if ((double)((double)ul_HighTiming * (0.25 * (double)b_ClockSelection)) >= ((double)((double)ul_HighTimerValue + 0.5))) { - ul_HighTimerValue - = - ul_HighTimerValue - + - 1; - } - - /*****************************/ - /* Calculate the real timing */ - /*****************************/ - - *pul_RealHighTiming - = - (unsigned int) - (ul_HighTimerValue - / - (0.25 * (double)b_ClockSelection)); - d_RealHighTiming - = - (double) - ul_HighTimerValue - / - ( - (double) - 0.25 - * - (double) - b_ClockSelection); - - if ((double)((double)ul_HighTimerValue / (0.25 * (double)b_ClockSelection)) >= (double)((double)*pul_RealHighTiming + 0.5)) { - *pul_RealHighTiming - = - *pul_RealHighTiming - + - 1; - } - - ul_HighTiming - = - ul_HighTiming - - - 1; - ul_HighTimerValue - = - ul_HighTimerValue - - - 2; - - if (b_ClockSelection != APCI1710_40MHZ) { - ul_HighTimerValue - = - (unsigned int) - ( - (double) - (ul_HighTimerValue) - * - 1.007752288); - } - - break; - - /******/ - /* ms */ - /******/ - - case 2: - - /******************/ - /* Timer 0 factor */ - /******************/ - - ul_HighTimerValue - = - ul_HighTiming - * - (250.0 - * - b_ClockSelection); - - /*******************/ - /* Round the value */ - /*******************/ - - if ((double)((double)ul_HighTiming * (250.0 * (double)b_ClockSelection)) >= ((double)((double)ul_HighTimerValue + 0.5))) { - ul_HighTimerValue - = - ul_HighTimerValue - + - 1; - } - - /*****************************/ - /* Calculate the real timing */ - /*****************************/ - - *pul_RealHighTiming - = - (unsigned int) - (ul_HighTimerValue - / - (250.0 * (double)b_ClockSelection)); - d_RealHighTiming - = - (double) - ul_HighTimerValue - / - (250.0 - * - (double) - b_ClockSelection); - - if ((double)((double)ul_HighTimerValue / (250.0 * (double)b_ClockSelection)) >= (double)((double)*pul_RealHighTiming + 0.5)) { - *pul_RealHighTiming - = - *pul_RealHighTiming - + - 1; - } - - ul_HighTiming - = - ul_HighTiming - - - 1; - ul_HighTimerValue - = - ul_HighTimerValue - - - 2; - - if (b_ClockSelection != APCI1710_40MHZ) { - ul_HighTimerValue - = - (unsigned int) - ( - (double) - (ul_HighTimerValue) - * - 1.007752288); - } - - break; - - /*****/ - /* s */ - /*****/ - - case 3: - - /******************/ - /* Timer 0 factor */ - /******************/ - - ul_HighTimerValue - = - (unsigned int) - (ul_HighTiming - * - (250000.0 - * - b_ClockSelection)); - - /*******************/ - /* Round the value */ - /*******************/ - - if ((double)((double)ul_HighTiming * (250000.0 * (double)b_ClockSelection)) >= ((double)((double)ul_HighTimerValue + 0.5))) { - ul_HighTimerValue - = - ul_HighTimerValue - + - 1; - } - - /*****************************/ - /* Calculate the real timing */ - /*****************************/ - - *pul_RealHighTiming - = - (unsigned int) - (ul_HighTimerValue - / - (250000.0 - * - (double) - b_ClockSelection)); - d_RealHighTiming - = - (double) - ul_HighTimerValue - / - (250000.0 - * - (double) - b_ClockSelection); - - if ((double)((double)ul_HighTimerValue / (250000.0 * (double)b_ClockSelection)) >= (double)((double)*pul_RealHighTiming + 0.5)) { - *pul_RealHighTiming - = - *pul_RealHighTiming - + - 1; - } - - ul_HighTiming - = - ul_HighTiming - - - 1; - ul_HighTimerValue - = - ul_HighTimerValue - - - 2; - - if (b_ClockSelection != APCI1710_40MHZ) { - ul_HighTimerValue - = - (unsigned int) - ( - (double) - (ul_HighTimerValue) - * - 1.007752288); - } - - break; - - /******/ - /* mn */ - /******/ - - case 4: - - /******************/ - /* Timer 0 factor */ - /******************/ - - ul_HighTimerValue - = - (unsigned int) - ( - (ul_HighTiming - * - 60) - * - (250000.0 - * - b_ClockSelection)); - - /*******************/ - /* Round the value */ - /*******************/ - - if ((double)((double)(ul_HighTiming * 60.0) * (250000.0 * (double)b_ClockSelection)) >= ((double)((double)ul_HighTimerValue + 0.5))) { - ul_HighTimerValue - = - ul_HighTimerValue - + - 1; - } - - /*****************************/ - /* Calculate the real timing */ - /*****************************/ - - *pul_RealHighTiming - = - (unsigned int) - (ul_HighTimerValue - / - (250000.0 - * - (double) - b_ClockSelection)) - / - 60; - d_RealHighTiming - = - ( - (double) - ul_HighTimerValue - / - (250000.0 - * - (double) - b_ClockSelection)) - / - 60.0; - - if ((double)(((double)ul_HighTimerValue / (250000.0 * (double)b_ClockSelection)) / 60.0) >= (double)((double)*pul_RealHighTiming + 0.5)) { - *pul_RealHighTiming - = - *pul_RealHighTiming - + - 1; - } - - ul_HighTiming - = - ul_HighTiming - - - 1; - ul_HighTimerValue - = - ul_HighTimerValue - - - 2; - - if (b_ClockSelection != APCI1710_40MHZ) { - ul_HighTimerValue - = - (unsigned int) - ( - (double) - (ul_HighTimerValue) - * - 1.007752288); - } - - break; - } - - fpu_end(); - /****************************/ - /* Save the clock selection */ - /****************************/ - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_PWMModuleInfo. - b_ClockSelection - = - b_ClockSelection; - - /************************/ - /* Save the timing unit */ - /************************/ - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_PWMModuleInfo. - s_PWMInfo - [b_PWM]. - b_TimingUnit - = - b_TimingUnit; - - /****************************/ - /* Save the low base timing */ - /****************************/ - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_PWMModuleInfo. - s_PWMInfo - [b_PWM]. - d_LowTiming - = - d_RealLowTiming; - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_PWMModuleInfo. - s_PWMInfo - [b_PWM]. - ul_RealLowTiming - = - *pul_RealLowTiming; - - /****************************/ - /* Save the high base timing */ - /****************************/ - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_PWMModuleInfo. - s_PWMInfo - [b_PWM]. - d_HighTiming - = - d_RealHighTiming; - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_PWMModuleInfo. - s_PWMInfo - [b_PWM]. - ul_RealHighTiming - = - *pul_RealHighTiming; - - /************************/ - /* Write the low timing */ - /************************/ - - outl(ul_LowTimerValue, devpriv->s_BoardInfos.ui_Address + 0 + (20 * b_PWM) + (64 * b_ModulNbr)); - - /*************************/ - /* Write the high timing */ - /*************************/ - - outl(ul_HighTimerValue, devpriv->s_BoardInfos.ui_Address + 4 + (20 * b_PWM) + (64 * b_ModulNbr)); - - /***************************/ - /* Set the clock selection */ - /***************************/ - - dw_Command - = - inl - (devpriv-> - s_BoardInfos. - ui_Address - + - 8 - + - (20 * b_PWM) + (64 * b_ModulNbr)); - - dw_Command - = - dw_Command - & - 0x7F; - - if (b_ClockSelection == APCI1710_40MHZ) { - dw_Command - = - dw_Command - | - 0x80; - } - - /***************************/ - /* Set the clock selection */ - /***************************/ - - outl(dw_Command, devpriv->s_BoardInfos.ui_Address + 8 + (20 * b_PWM) + (64 * b_ModulNbr)); - - /*************/ - /* PWM init. */ - /*************/ - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_PWMModuleInfo. - s_PWMInfo - [b_PWM]. - b_PWMInit - = - 1; - } else { - /***************************************************/ - /* You can not used the 40MHz clock selection with */ - /* this board */ - /***************************************************/ - DPRINTK("You can not used the 40MHz clock selection with this board\n"); - i_ReturnValue - = - -9; - } - } else { - /***************************************/ - /* High base timing selection is wrong */ - /***************************************/ - DPRINTK("High base timing selection is wrong\n"); - i_ReturnValue = - -8; - } - } else { - /**************************************/ - /* Low base timing selection is wrong */ - /**************************************/ - DPRINTK("Low base timing selection is wrong\n"); - i_ReturnValue = -7; - } - } /* if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4)) */ - else { - /**********************************/ - /* Timing unit selection is wrong */ - /**********************************/ - DPRINTK("Timing unit selection is wrong\n"); - i_ReturnValue = -6; - } /* if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4)) */ - } /* if ((b_ClockSelection == APCI1710_30MHZ) || (b_ClockSelection == APCI1710_33MHZ) || (b_ClockSelection == APCI1710_40MHZ)) */ - else { - /*******************************/ - /* The selected clock is wrong */ - /*******************************/ - DPRINTK("The selected clock is wrong\n"); - i_ReturnValue = -5; - } /* if ((b_ClockSelection == APCI1710_30MHZ) || (b_ClockSelection == APCI1710_33MHZ) || (b_ClockSelection == APCI1710_40MHZ)) */ - } /* if (b_PWM >= 0 && b_PWM <= 1) */ - else { - /******************************/ - /* Tor PWM selection is wrong */ - /******************************/ - DPRINTK("Tor PWM selection is wrong\n"); - i_ReturnValue = -4; - } /* if (b_PWM >= 0 && b_PWM <= 1) */ - } else { - /**********************************/ - /* The module is not a PWM module */ - /**********************************/ - DPRINTK("The module is not a PWM module\n"); - i_ReturnValue = -3; - } - } else { - /***********************/ - /* Module number error */ - /***********************/ - DPRINTK("Module number error\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_GetPWMInitialisation | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char_ b_PWM, | -| unsigned char *_ pb_TimingUnit, | -| PULONG_ pul_LowTiming, | -| PULONG_ pul_HighTiming, | -| unsigned char *_ pb_StartLevel, | -| unsigned char *_ pb_StopMode, | -| unsigned char *_ pb_StopLevel, | -| unsigned char *_ pb_ExternGate, | -| unsigned char *_ pb_InterruptEnable, | -| unsigned char *_ pb_Enable) | -+----------------------------------------------------------------------------+ -| Task : Return the PWM (b_PWM) initialisation from selected | -| module (b_ModulNbr). You must calling the | -| "i_APCI1710_InitPWM" function be for you call this | -| function. | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr : Selected module number (0 to 3) | -| unsigned char_ b_PWM : Selected PWM (0 or 1) | -+----------------------------------------------------------------------------+ -| Output Parameters : unsigned char *_ pb_TimingUnit : Base timing Unit (0 to 4) | -| 0 : ns | -| 1 : æs | -| 2 : ms | -| 3 : s | -| 4 : mn | -| PULONG_ pul_LowTiming : Low base timing value. | -| PULONG_ pul_HighTiming : High base timing value. | -| unsigned char *_ pb_StartLevel : Start period level | -| selection | -| 0 : The period start | -| with a low level | -| 1 : The period start | -| with a high level| -| unsigned char *_ pb_StopMode : Stop mode selection | -| 0 : The PWM is stopped | -| directly after the | -| "i_APCI1710_DisablePWM"| -| function and break the| -| last period | -| 1 : After the | -| "i_APCI1710_DisablePWM"| -| function the PWM is | -| stopped at the end | -| from last period cycle| -| unsigned char *_ pb_StopLevel : Stop PWM level selection | -| 0 : The output signal | -| keep the level after| -| the | -| "i_APCI1710_DisablePWM"| -| function | -| 1 : The output signal is| -| set to low after the| -| "i_APCI1710_DisablePWM"| -| function | -| 2 : The output signal is| -| set to high after | -| the | -| "i_APCI1710_DisablePWM"| -| function | -| unsigned char *_ pb_ExternGate : Extern gate action | -| selection | -| 0 : Extern gate signal | -| not used. | -| 1 : Extern gate signal | -| used. | -| unsigned char *_ pb_InterruptEnable : Enable or disable the PWM | -| interrupt. | -| - APCI1710_ENABLE : | -| Enable the PWM interrupt| -| A interrupt occur after | -| each period | -| - APCI1710_DISABLE : | -| Disable the PWM | -| interrupt | -| unsigned char *_ pb_Enable : Indicate if the PWM is | -| enabled or no | -| 0 : PWM not enabled | -| 1 : PWM enabled | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: Module selection wrong | -| -3: The module is not a PWM module | -| -4: PWM selection is wrong | -| -5: PWM not initialised see function | -| "i_APCI1710_InitPWM" | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_GetPWMInitialisation(struct comedi_device *dev, - unsigned char b_ModulNbr, - unsigned char b_PWM, - unsigned char *pb_TimingUnit, - unsigned int *pul_LowTiming, - unsigned int *pul_HighTiming, - unsigned char *pb_StartLevel, - unsigned char *pb_StopMode, - unsigned char *pb_StopLevel, - unsigned char *pb_ExternGate, - unsigned char *pb_InterruptEnable, - unsigned char *pb_Enable) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - unsigned int dw_Status; - unsigned int dw_Command; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /***************/ - /* Test if PWM */ - /***************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[b_ModulNbr] & - 0xFFFF0000UL) == APCI1710_PWM) { - /**************************/ - /* Test the PWM selection */ - /**************************/ - - if (b_PWM <= 1) { - /***************************/ - /* Test if PWM initialised */ - /***************************/ - - dw_Status = inl(devpriv->s_BoardInfos. - ui_Address + 12 + (20 * b_PWM) + - (64 * b_ModulNbr)); - - if (dw_Status & 0x10) { - /***********************/ - /* Read the low timing */ - /***********************/ - - *pul_LowTiming = - inl(devpriv->s_BoardInfos. - ui_Address + 0 + (20 * b_PWM) + - (64 * b_ModulNbr)); - - /************************/ - /* Read the high timing */ - /************************/ - - *pul_HighTiming = - inl(devpriv->s_BoardInfos. - ui_Address + 4 + (20 * b_PWM) + - (64 * b_ModulNbr)); - - /********************/ - /* Read the command */ - /********************/ - - dw_Command = inl(devpriv->s_BoardInfos. - ui_Address + 8 + (20 * b_PWM) + - (64 * b_ModulNbr)); - - *pb_StartLevel = - (unsigned char) ((dw_Command >> 5) & 1); - *pb_StopMode = - (unsigned char) ((dw_Command >> 0) & 1); - *pb_StopLevel = - (unsigned char) ((dw_Command >> 1) & 1); - *pb_ExternGate = - (unsigned char) ((dw_Command >> 4) & 1); - *pb_InterruptEnable = - (unsigned char) ((dw_Command >> 3) & 1); - - if (*pb_StopLevel) { - *pb_StopLevel = - *pb_StopLevel + - (unsigned char) ((dw_Command >> - 2) & 1); - } - - /********************/ - /* Read the command */ - /********************/ - - dw_Command = inl(devpriv->s_BoardInfos. - ui_Address + 8 + (20 * b_PWM) + - (64 * b_ModulNbr)); - - *pb_Enable = - (unsigned char) ((dw_Command >> 0) & 1); - - *pb_TimingUnit = devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_PWMModuleInfo. - s_PWMInfo[b_PWM].b_TimingUnit; - } /* if (dw_Status & 0x10) */ - else { - /***********************/ - /* PWM not initialised */ - /***********************/ - DPRINTK("PWM not initialised\n"); - i_ReturnValue = -5; - } /* if (dw_Status & 0x10) */ - } /* if (b_PWM >= 0 && b_PWM <= 1) */ - else { - /******************************/ - /* Tor PWM selection is wrong */ - /******************************/ - DPRINTK("Tor PWM selection is wrong\n"); - i_ReturnValue = -4; - } /* if (b_PWM >= 0 && b_PWM <= 1) */ - } else { - /**********************************/ - /* The module is not a PWM module */ - /**********************************/ - DPRINTK("The module is not a PWM module\n"); - i_ReturnValue = -3; - } - } else { - /***********************/ - /* Module number error */ - /***********************/ - DPRINTK("Module number error\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* - * Pwm Init and Get Pwm Initialisation - */ -static int i_APCI1710_InsnConfigPWM(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - unsigned char b_ConfigType; - int i_ReturnValue = 0; - b_ConfigType = CR_CHAN(insn->chanspec); - - switch (b_ConfigType) { - case APCI1710_PWM_INIT: - i_ReturnValue = i_APCI1710_InitPWM(dev, (unsigned char) CR_AREF(insn->chanspec), /* b_ModulNbr */ - (unsigned char) data[0], /* b_PWM */ - (unsigned char) data[1], /* b_ClockSelection */ - (unsigned char) data[2], /* b_TimingUnit */ - (unsigned int) data[3], /* ul_LowTiming */ - (unsigned int) data[4], /* ul_HighTiming */ - (unsigned int *) &data[0], /* pul_RealLowTiming */ - (unsigned int *) &data[1] /* pul_RealHighTiming */ - ); - break; - - case APCI1710_PWM_GETINITDATA: - i_ReturnValue = i_APCI1710_GetPWMInitialisation(dev, (unsigned char) CR_AREF(insn->chanspec), /* b_ModulNbr */ - (unsigned char) data[0], /* b_PWM */ - (unsigned char *) &data[0], /* pb_TimingUnit */ - (unsigned int *) &data[1], /* pul_LowTiming */ - (unsigned int *) &data[2], /* pul_HighTiming */ - (unsigned char *) &data[3], /* pb_StartLevel */ - (unsigned char *) &data[4], /* pb_StopMode */ - (unsigned char *) &data[5], /* pb_StopLevel */ - (unsigned char *) &data[6], /* pb_ExternGate */ - (unsigned char *) &data[7], /* pb_InterruptEnable */ - (unsigned char *) &data[8] /* pb_Enable */ - ); - break; - - default: - printk(" Config Parameter Wrong\n"); - } - - if (i_ReturnValue >= 0) - i_ReturnValue = insn->n; - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_EnablePWM | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char_ b_PWM, | -| unsigned char_ b_StartLevel, | -| unsigned char_ b_StopMode, | -| unsigned char_ b_StopLevel, | -| unsigned char_ b_ExternGate, | -| unsigned char_ b_InterruptEnable) | -+----------------------------------------------------------------------------+ -| Task : Enable the selected PWM (b_PWM) from selected module | -| (b_ModulNbr). You must calling the "i_APCI1710_InitPWM"| -| function be for you call this function. | -| If you enable the PWM interrupt, the PWM generate a | -| interrupt after each period. | -| See function "i_APCI1710_SetBoardIntRoutineX" and the | -| Interrupt mask description chapter. | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr : Selected module number | -| (0 to 3) | -| unsigned char_ b_PWM : Selected PWM (0 or 1) | -| unsigned char_ b_StartLevel : Start period level selection | -| 0 : The period start with a | -| low level | -| 1 : The period start with a | -| high level | -| unsigned char_ b_StopMode : Stop mode selection | -| 0 : The PWM is stopped | -| directly after the | -| "i_APCI1710_DisablePWM" | -| function and break the | -| last period | -| 1 : After the | -| "i_APCI1710_DisablePWM" | -| function the PWM is | -| stopped at the end from| -| last period cycle. | -| unsigned char_ b_StopLevel : Stop PWM level selection | -| 0 : The output signal keep | -| the level after the | -| "i_APCI1710_DisablePWM" | -| function | -| 1 : The output signal is set| -| to low after the | -| "i_APCI1710_DisablePWM" | -| function | -| 2 : The output signal is set| -| to high after the | -| "i_APCI1710_DisablePWM" | -| function | -| unsigned char_ b_ExternGate : Extern gate action selection | -| 0 : Extern gate signal not | -| used. | -| 1 : Extern gate signal used.| -| unsigned char_ b_InterruptEnable : Enable or disable the PWM | -| interrupt. | -| - APCI1710_ENABLE : | -| Enable the PWM interrupt | -| A interrupt occur after | -| each period | -| - APCI1710_DISABLE : | -| Disable the PWM interrupt | -+----------------------------------------------------------------------------+ -| Output Parameters : - | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: Module selection wrong | -| -3: The module is not a PWM module | -| -4: PWM selection is wrong | -| -5: PWM not initialised see function | -| "i_APCI1710_InitPWM" | -| -6: PWM start level selection is wrong | -| -7: PWM stop mode selection is wrong | -| -8: PWM stop level selection is wrong | -| -9: Extern gate signal selection is wrong | -| -10: Interrupt parameter is wrong | -| -11: Interrupt function not initialised. | -| See function "i_APCI1710_SetBoardIntRoutineX" | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_EnablePWM(struct comedi_device *dev, - unsigned char b_ModulNbr, - unsigned char b_PWM, - unsigned char b_StartLevel, - unsigned char b_StopMode, - unsigned char b_StopLevel, - unsigned char b_ExternGate, - unsigned char b_InterruptEnable) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - unsigned int dw_Status; - unsigned int dw_Command; - - devpriv->tsk_Current = current; /* Save the current process task structure */ - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /***************/ - /* Test if PWM */ - /***************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[b_ModulNbr] & - 0xFFFF0000UL) == APCI1710_PWM) { - /**************************/ - /* Test the PWM selection */ - /**************************/ - - if (b_PWM <= 1) { - /***************************/ - /* Test if PWM initialised */ - /***************************/ - - dw_Status = inl(devpriv->s_BoardInfos. - ui_Address + 12 + (20 * b_PWM) + - (64 * b_ModulNbr)); - - if (dw_Status & 0x10) { - /**********************************/ - /* Test the start level selection */ - /**********************************/ - - if (b_StartLevel <= 1) { - /**********************/ - /* Test the stop mode */ - /**********************/ - - if (b_StopMode <= 1) { - /***********************/ - /* Test the stop level */ - /***********************/ - - if (b_StopLevel <= 2) { - /*****************************/ - /* Test the extern gate mode */ - /*****************************/ - - if (b_ExternGate - <= 1) { - /*****************************/ - /* Test the interrupt action */ - /*****************************/ - - if (b_InterruptEnable == APCI1710_ENABLE || b_InterruptEnable == APCI1710_DISABLE) { - /******************************************/ - /* Test if interrupt function initialised */ - /******************************************/ - - /********************/ - /* Read the command */ - /********************/ - - dw_Command - = - inl - (devpriv-> - s_BoardInfos. - ui_Address - + - 8 - + - (20 * b_PWM) + (64 * b_ModulNbr)); - - dw_Command - = - dw_Command - & - 0x80; - - /********************/ - /* Make the command */ - /********************/ - - dw_Command - = - dw_Command - | - b_StopMode - | - (b_InterruptEnable - << - 3) - | - (b_ExternGate - << - 4) - | - (b_StartLevel - << - 5); - - if (b_StopLevel & 3) { - dw_Command - = - dw_Command - | - 2; - - if (b_StopLevel & 2) { - dw_Command - = - dw_Command - | - 4; - } - } - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_PWMModuleInfo. - s_PWMInfo - [b_PWM]. - b_InterruptEnable - = - b_InterruptEnable; - - /*******************/ - /* Set the command */ - /*******************/ - - outl(dw_Command, devpriv->s_BoardInfos.ui_Address + 8 + (20 * b_PWM) + (64 * b_ModulNbr)); - - /******************/ - /* Enable the PWM */ - /******************/ - outl(1, devpriv->s_BoardInfos.ui_Address + 12 + (20 * b_PWM) + (64 * b_ModulNbr)); - } /* if (b_InterruptEnable == APCI1710_ENABLE || b_InterruptEnable == APCI1710_DISABLE) */ - else { - /********************************/ - /* Interrupt parameter is wrong */ - /********************************/ - DPRINTK("Interrupt parameter is wrong\n"); - i_ReturnValue - = - -10; - } /* if (b_InterruptEnable == APCI1710_ENABLE || b_InterruptEnable == APCI1710_DISABLE) */ - } /* if (b_ExternGate >= 0 && b_ExternGate <= 1) */ - else { - /*****************************************/ - /* Extern gate signal selection is wrong */ - /*****************************************/ - DPRINTK("Extern gate signal selection is wrong\n"); - i_ReturnValue - = - -9; - } /* if (b_ExternGate >= 0 && b_ExternGate <= 1) */ - } /* if (b_StopLevel >= 0 && b_StopLevel <= 2) */ - else { - /*************************************/ - /* PWM stop level selection is wrong */ - /*************************************/ - DPRINTK("PWM stop level selection is wrong\n"); - i_ReturnValue = - -8; - } /* if (b_StopLevel >= 0 && b_StopLevel <= 2) */ - } /* if (b_StopMode >= 0 && b_StopMode <= 1) */ - else { - /************************************/ - /* PWM stop mode selection is wrong */ - /************************************/ - DPRINTK("PWM stop mode selection is wrong\n"); - i_ReturnValue = -7; - } /* if (b_StopMode >= 0 && b_StopMode <= 1) */ - } /* if (b_StartLevel >= 0 && b_StartLevel <= 1) */ - else { - /**************************************/ - /* PWM start level selection is wrong */ - /**************************************/ - DPRINTK("PWM start level selection is wrong\n"); - i_ReturnValue = -6; - } /* if (b_StartLevel >= 0 && b_StartLevel <= 1) */ - } /* if (dw_Status & 0x10) */ - else { - /***********************/ - /* PWM not initialised */ - /***********************/ - DPRINTK("PWM not initialised\n"); - i_ReturnValue = -5; - } /* if (dw_Status & 0x10) */ - } /* if (b_PWM >= 0 && b_PWM <= 1) */ - else { - /******************************/ - /* Tor PWM selection is wrong */ - /******************************/ - DPRINTK("Tor PWM selection is wrong\n"); - i_ReturnValue = -4; - } /* if (b_PWM >= 0 && b_PWM <= 1) */ - } else { - /**********************************/ - /* The module is not a PWM module */ - /**********************************/ - DPRINTK("The module is not a PWM module\n"); - i_ReturnValue = -3; - } - } else { - /***********************/ - /* Module number error */ - /***********************/ - DPRINTK("Module number error\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_DisablePWM (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char_ b_PWM) | -+----------------------------------------------------------------------------+ -| Task : Disable the selected PWM (b_PWM) from selected module | -| (b_ModulNbr). The output signal level depend of the | -| initialisation by the "i_APCI1710_EnablePWM". | -| See the b_StartLevel, b_StopMode and b_StopLevel | -| parameters from this function. | -+----------------------------------------------------------------------------+ -| Input Parameters :BYTE_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr : Selected module number (0 to 3) | -| unsigned char_ b_PWM : Selected PWM (0 or 1) | -+----------------------------------------------------------------------------+ -| Output Parameters : - | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: Module selection wrong | -| -3: The module is not a PWM module | -| -4: PWM selection is wrong | -| -5: PWM not initialised see function | -| "i_APCI1710_InitPWM" | -| -6: PWM not enabled see function | -| "i_APCI1710_EnablePWM" | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_DisablePWM(struct comedi_device *dev, - unsigned char b_ModulNbr, - unsigned char b_PWM) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - unsigned int dw_Status; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /***************/ - /* Test if PWM */ - /***************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[b_ModulNbr] & - 0xFFFF0000UL) == APCI1710_PWM) { - /**************************/ - /* Test the PWM selection */ - /**************************/ - - if (b_PWM <= 1) { - /***************************/ - /* Test if PWM initialised */ - /***************************/ - - dw_Status = inl(devpriv->s_BoardInfos. - ui_Address + 12 + (20 * b_PWM) + - (64 * b_ModulNbr)); - - if (dw_Status & 0x10) { - /***********************/ - /* Test if PWM enabled */ - /***********************/ - - if (dw_Status & 0x1) { - /*******************/ - /* Disable the PWM */ - /*******************/ - outl(0, devpriv->s_BoardInfos. - ui_Address + 12 + - (20 * b_PWM) + - (64 * b_ModulNbr)); - } /* if (dw_Status & 0x1) */ - else { - /*******************/ - /* PWM not enabled */ - /*******************/ - DPRINTK("PWM not enabled\n"); - i_ReturnValue = -6; - } /* if (dw_Status & 0x1) */ - } /* if (dw_Status & 0x10) */ - else { - /***********************/ - /* PWM not initialised */ - /***********************/ - DPRINTK(" PWM not initialised\n"); - i_ReturnValue = -5; - } /* if (dw_Status & 0x10) */ - } /* if (b_PWM >= 0 && b_PWM <= 1) */ - else { - /******************************/ - /* Tor PWM selection is wrong */ - /******************************/ - DPRINTK("Tor PWM selection is wrong\n"); - i_ReturnValue = -4; - } /* if (b_PWM >= 0 && b_PWM <= 1) */ - } else { - /**********************************/ - /* The module is not a PWM module */ - /**********************************/ - DPRINTK("The module is not a PWM module\n"); - i_ReturnValue = -3; - } - } else { - /***********************/ - /* Module number error */ - /***********************/ - DPRINTK("Module number error\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_SetNewPWMTiming | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char_ b_PWM, | -| unsigned char_ b_ClockSelection, | -| unsigned char_ b_TimingUnit, | -| ULONG_ ul_LowTiming, | -| ULONG_ ul_HighTiming) | -+----------------------------------------------------------------------------+ -| Task : Set a new timing. The ul_LowTiming, ul_HighTiming and | -| ul_TimingUnit determine the low/high timing base for | -| the period. | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr : Module number to configure| -| (0 to 3) | -| unsigned char_ b_PWM : Selected PWM (0 or 1). | -| unsigned char_ b_TimingUnit : Base timing Unit (0 to 4) | -| 0 : ns | -| 1 : æs | -| 2 : ms | -| 3 : s | -| 4 : mn | -| ULONG_ ul_LowTiming : Low base timing value. | -| ULONG_ ul_HighTiming : High base timing value. | -+----------------------------------------------------------------------------+ -| Output Parameters : - | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: Module selection wrong | -| -3: The module is not a PWM module | -| -4: PWM selection is wrong | -| -5: PWM not initialised | -| -6: Timing Unit selection is wrong | -| -7: Low base timing selection is wrong | -| -8: High base timing selection is wrong | -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_SetNewPWMTiming(struct comedi_device *dev, - unsigned char b_ModulNbr, - unsigned char b_PWM, - unsigned char b_TimingUnit, - unsigned int ul_LowTiming, - unsigned int ul_HighTiming) -{ - struct addi_private *devpriv = dev->private; - unsigned char b_ClockSelection; - int i_ReturnValue = 0; - unsigned int ul_LowTimerValue = 0; - unsigned int ul_HighTimerValue = 0; - unsigned int ul_RealLowTiming = 0; - unsigned int ul_RealHighTiming = 0; - unsigned int dw_Status; - unsigned int dw_Command; - double d_RealLowTiming = 0; - double d_RealHighTiming = 0; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /***************/ - /* Test if PWM */ - /***************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[b_ModulNbr] & - 0xFFFF0000UL) == APCI1710_PWM) { - /**************************/ - /* Test the PWM selection */ - /**************************/ - - if (b_PWM <= 1) { - /***************************/ - /* Test if PWM initialised */ - /***************************/ - - dw_Status = inl(devpriv->s_BoardInfos. - ui_Address + 12 + (20 * b_PWM) + - (64 * b_ModulNbr)); - - if (dw_Status & 0x10) { - b_ClockSelection = devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_PWMModuleInfo. - b_ClockSelection; - - /************************/ - /* Test the timing unit */ - /************************/ - - if (b_TimingUnit <= 4) { - /*********************************/ - /* Test the low timing selection */ - /*********************************/ - - if (((b_ClockSelection == - APCI1710_30MHZ) - && (b_TimingUnit - == 0) - && (ul_LowTiming - >= 266) - && (ul_LowTiming - <= - 0xFFFFFFFFUL)) - || ((b_ClockSelection == - APCI1710_30MHZ) - && (b_TimingUnit - == 1) - && (ul_LowTiming - >= 1) - && (ul_LowTiming - <= - 571230650UL)) - || ((b_ClockSelection == - APCI1710_30MHZ) - && (b_TimingUnit - == 2) - && (ul_LowTiming - >= 1) - && (ul_LowTiming - <= - 571230UL)) - || ((b_ClockSelection == - APCI1710_30MHZ) - && (b_TimingUnit - == 3) - && (ul_LowTiming - >= 1) - && (ul_LowTiming - <= - 571UL)) - || ((b_ClockSelection == - APCI1710_30MHZ) - && (b_TimingUnit - == 4) - && (ul_LowTiming - >= 1) - && (ul_LowTiming - <= 9UL)) - || ((b_ClockSelection == - APCI1710_33MHZ) - && (b_TimingUnit - == 0) - && (ul_LowTiming - >= 242) - && (ul_LowTiming - <= - 0xFFFFFFFFUL)) - || ((b_ClockSelection == - APCI1710_33MHZ) - && (b_TimingUnit - == 1) - && (ul_LowTiming - >= 1) - && (ul_LowTiming - <= - 519691043UL)) - || ((b_ClockSelection == - APCI1710_33MHZ) - && (b_TimingUnit - == 2) - && (ul_LowTiming - >= 1) - && (ul_LowTiming - <= - 519691UL)) - || ((b_ClockSelection == - APCI1710_33MHZ) - && (b_TimingUnit - == 3) - && (ul_LowTiming - >= 1) - && (ul_LowTiming - <= - 520UL)) - || ((b_ClockSelection == - APCI1710_33MHZ) - && (b_TimingUnit - == 4) - && (ul_LowTiming - >= 1) - && (ul_LowTiming - <= 8UL)) - || ((b_ClockSelection == - APCI1710_40MHZ) - && (b_TimingUnit - == 0) - && (ul_LowTiming - >= 200) - && (ul_LowTiming - <= - 0xFFFFFFFFUL)) - || ((b_ClockSelection == - APCI1710_40MHZ) - && (b_TimingUnit - == 1) - && (ul_LowTiming - >= 1) - && (ul_LowTiming - <= - 429496729UL)) - || ((b_ClockSelection == - APCI1710_40MHZ) - && (b_TimingUnit - == 2) - && (ul_LowTiming - >= 1) - && (ul_LowTiming - <= - 429496UL)) - || ((b_ClockSelection == - APCI1710_40MHZ) - && (b_TimingUnit - == 3) - && (ul_LowTiming - >= 1) - && (ul_LowTiming - <= - 429UL)) - || ((b_ClockSelection == - APCI1710_40MHZ) - && (b_TimingUnit - == 4) - && (ul_LowTiming - >= 1) - && (ul_LowTiming - <= - 7UL))) { - /**********************************/ - /* Test the High timing selection */ - /**********************************/ - - if (((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 0) && (ul_HighTiming >= 266) && (ul_HighTiming <= 0xFFFFFFFFUL)) || ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 1) && (ul_HighTiming >= 1) && (ul_HighTiming <= 571230650UL)) || ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 2) && (ul_HighTiming >= 1) && (ul_HighTiming <= 571230UL)) || ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 3) && (ul_HighTiming >= 1) && (ul_HighTiming <= 571UL)) || ((b_ClockSelection == APCI1710_30MHZ) && (b_TimingUnit == 4) && (ul_HighTiming >= 1) && (ul_HighTiming <= 9UL)) || ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 0) && (ul_HighTiming >= 242) && (ul_HighTiming <= 0xFFFFFFFFUL)) || ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 1) && (ul_HighTiming >= 1) && (ul_HighTiming <= 519691043UL)) || ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 2) && (ul_HighTiming >= 1) && (ul_HighTiming <= 519691UL)) || ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 3) && (ul_HighTiming >= 1) && (ul_HighTiming <= 520UL)) || ((b_ClockSelection == APCI1710_33MHZ) && (b_TimingUnit == 4) && (ul_HighTiming >= 1) && (ul_HighTiming <= 8UL)) || ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 0) && (ul_HighTiming >= 200) && (ul_HighTiming <= 0xFFFFFFFFUL)) || ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 1) && (ul_HighTiming >= 1) && (ul_HighTiming <= 429496729UL)) || ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 2) && (ul_HighTiming >= 1) && (ul_HighTiming <= 429496UL)) || ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 3) && (ul_HighTiming >= 1) && (ul_HighTiming <= 429UL)) || ((b_ClockSelection == APCI1710_40MHZ) && (b_TimingUnit == 4) && (ul_HighTiming >= 1) && (ul_HighTiming <= 7UL))) { - /************************************/ - /* Calculate the low division fator */ - /************************************/ - - fpu_begin(); - switch (b_TimingUnit) { - /******/ - /* ns */ - /******/ - - case 0: - - /******************/ - /* Timer 0 factor */ - /******************/ - - ul_LowTimerValue - = - (unsigned int) - (ul_LowTiming - * - (0.00025 * b_ClockSelection)); - - /*******************/ - /* Round the value */ - /*******************/ - - if ((double)((double)ul_LowTiming * (0.00025 * (double)b_ClockSelection)) >= ((double)((double)ul_LowTimerValue + 0.5))) { - ul_LowTimerValue - = - ul_LowTimerValue - + - 1; - } - - /*****************************/ - /* Calculate the real timing */ - /*****************************/ - - ul_RealLowTiming - = - (unsigned int) - (ul_LowTimerValue - / - (0.00025 * (double)b_ClockSelection)); - d_RealLowTiming - = - (double) - ul_LowTimerValue - / - (0.00025 - * - (double) - b_ClockSelection); - - if ((double)((double)ul_LowTimerValue / (0.00025 * (double)b_ClockSelection)) >= (double)((double)ul_RealLowTiming + 0.5)) { - ul_RealLowTiming - = - ul_RealLowTiming - + - 1; - } - - ul_LowTiming - = - ul_LowTiming - - - 1; - ul_LowTimerValue - = - ul_LowTimerValue - - - 2; - - if (b_ClockSelection != APCI1710_40MHZ) { - ul_LowTimerValue - = - (unsigned int) - ( - (double) - (ul_LowTimerValue) - * - 1.007752288); - } - - break; - - /******/ - /* æs */ - /******/ - - case 1: - - /******************/ - /* Timer 0 factor */ - /******************/ - - ul_LowTimerValue - = - (unsigned int) - (ul_LowTiming - * - (0.25 * b_ClockSelection)); - - /*******************/ - /* Round the value */ - /*******************/ - - if ((double)((double)ul_LowTiming * (0.25 * (double)b_ClockSelection)) >= ((double)((double)ul_LowTimerValue + 0.5))) { - ul_LowTimerValue - = - ul_LowTimerValue - + - 1; - } - - /*****************************/ - /* Calculate the real timing */ - /*****************************/ - - ul_RealLowTiming - = - (unsigned int) - (ul_LowTimerValue - / - (0.25 * (double)b_ClockSelection)); - d_RealLowTiming - = - (double) - ul_LowTimerValue - / - ( - (double) - 0.25 - * - (double) - b_ClockSelection); - - if ((double)((double)ul_LowTimerValue / (0.25 * (double)b_ClockSelection)) >= (double)((double)ul_RealLowTiming + 0.5)) { - ul_RealLowTiming - = - ul_RealLowTiming - + - 1; - } - - ul_LowTiming - = - ul_LowTiming - - - 1; - ul_LowTimerValue - = - ul_LowTimerValue - - - 2; - - if (b_ClockSelection != APCI1710_40MHZ) { - ul_LowTimerValue - = - (unsigned int) - ( - (double) - (ul_LowTimerValue) - * - 1.007752288); - } - - break; - - /******/ - /* ms */ - /******/ - - case 2: - - /******************/ - /* Timer 0 factor */ - /******************/ - - ul_LowTimerValue - = - ul_LowTiming - * - (250.0 - * - b_ClockSelection); - - /*******************/ - /* Round the value */ - /*******************/ - - if ((double)((double)ul_LowTiming * (250.0 * (double)b_ClockSelection)) >= ((double)((double)ul_LowTimerValue + 0.5))) { - ul_LowTimerValue - = - ul_LowTimerValue - + - 1; - } - - /*****************************/ - /* Calculate the real timing */ - /*****************************/ - - ul_RealLowTiming - = - (unsigned int) - (ul_LowTimerValue - / - (250.0 * (double)b_ClockSelection)); - d_RealLowTiming - = - (double) - ul_LowTimerValue - / - (250.0 - * - (double) - b_ClockSelection); - - if ((double)((double)ul_LowTimerValue / (250.0 * (double)b_ClockSelection)) >= (double)((double)ul_RealLowTiming + 0.5)) { - ul_RealLowTiming - = - ul_RealLowTiming - + - 1; - } - - ul_LowTiming - = - ul_LowTiming - - - 1; - ul_LowTimerValue - = - ul_LowTimerValue - - - 2; - - if (b_ClockSelection != APCI1710_40MHZ) { - ul_LowTimerValue - = - (unsigned int) - ( - (double) - (ul_LowTimerValue) - * - 1.007752288); - } - - break; - - /*****/ - /* s */ - /*****/ - - case 3: - - /******************/ - /* Timer 0 factor */ - /******************/ - - ul_LowTimerValue - = - (unsigned int) - (ul_LowTiming - * - (250000.0 - * - b_ClockSelection)); - - /*******************/ - /* Round the value */ - /*******************/ - - if ((double)((double)ul_LowTiming * (250000.0 * (double)b_ClockSelection)) >= ((double)((double)ul_LowTimerValue + 0.5))) { - ul_LowTimerValue - = - ul_LowTimerValue - + - 1; - } - - /*****************************/ - /* Calculate the real timing */ - /*****************************/ - - ul_RealLowTiming - = - (unsigned int) - (ul_LowTimerValue - / - (250000.0 - * - (double) - b_ClockSelection)); - d_RealLowTiming - = - (double) - ul_LowTimerValue - / - (250000.0 - * - (double) - b_ClockSelection); - - if ((double)((double)ul_LowTimerValue / (250000.0 * (double)b_ClockSelection)) >= (double)((double)ul_RealLowTiming + 0.5)) { - ul_RealLowTiming - = - ul_RealLowTiming - + - 1; - } - - ul_LowTiming - = - ul_LowTiming - - - 1; - ul_LowTimerValue - = - ul_LowTimerValue - - - 2; - - if (b_ClockSelection != APCI1710_40MHZ) { - ul_LowTimerValue - = - (unsigned int) - ( - (double) - (ul_LowTimerValue) - * - 1.007752288); - } - - break; - - /******/ - /* mn */ - /******/ - - case 4: - - /******************/ - /* Timer 0 factor */ - /******************/ - - ul_LowTimerValue - = - (unsigned int) - ( - (ul_LowTiming - * - 60) - * - (250000.0 - * - b_ClockSelection)); - - /*******************/ - /* Round the value */ - /*******************/ - - if ((double)((double)(ul_LowTiming * 60.0) * (250000.0 * (double)b_ClockSelection)) >= ((double)((double)ul_LowTimerValue + 0.5))) { - ul_LowTimerValue - = - ul_LowTimerValue - + - 1; - } - - /*****************************/ - /* Calculate the real timing */ - /*****************************/ - - ul_RealLowTiming - = - (unsigned int) - (ul_LowTimerValue - / - (250000.0 - * - (double) - b_ClockSelection)) - / - 60; - d_RealLowTiming - = - ( - (double) - ul_LowTimerValue - / - (250000.0 - * - (double) - b_ClockSelection)) - / - 60.0; - - if ((double)(((double)ul_LowTimerValue / (250000.0 * (double)b_ClockSelection)) / 60.0) >= (double)((double)ul_RealLowTiming + 0.5)) { - ul_RealLowTiming - = - ul_RealLowTiming - + - 1; - } - - ul_LowTiming - = - ul_LowTiming - - - 1; - ul_LowTimerValue - = - ul_LowTimerValue - - - 2; - - if (b_ClockSelection != APCI1710_40MHZ) { - ul_LowTimerValue - = - (unsigned int) - ( - (double) - (ul_LowTimerValue) - * - 1.007752288); - } - - break; - } - - /*************************************/ - /* Calculate the high division fator */ - /*************************************/ - - switch (b_TimingUnit) { - /******/ - /* ns */ - /******/ - - case 0: - - /******************/ - /* Timer 0 factor */ - /******************/ - - ul_HighTimerValue - = - (unsigned int) - (ul_HighTiming - * - (0.00025 * b_ClockSelection)); - - /*******************/ - /* Round the value */ - /*******************/ - - if ((double)((double)ul_HighTiming * (0.00025 * (double)b_ClockSelection)) >= ((double)((double)ul_HighTimerValue + 0.5))) { - ul_HighTimerValue - = - ul_HighTimerValue - + - 1; - } - - /*****************************/ - /* Calculate the real timing */ - /*****************************/ - - ul_RealHighTiming - = - (unsigned int) - (ul_HighTimerValue - / - (0.00025 * (double)b_ClockSelection)); - d_RealHighTiming - = - (double) - ul_HighTimerValue - / - (0.00025 - * - (double) - b_ClockSelection); - - if ((double)((double)ul_HighTimerValue / (0.00025 * (double)b_ClockSelection)) >= (double)((double)ul_RealHighTiming + 0.5)) { - ul_RealHighTiming - = - ul_RealHighTiming - + - 1; - } - - ul_HighTiming - = - ul_HighTiming - - - 1; - ul_HighTimerValue - = - ul_HighTimerValue - - - 2; - - if (b_ClockSelection != APCI1710_40MHZ) { - ul_HighTimerValue - = - (unsigned int) - ( - (double) - (ul_HighTimerValue) - * - 1.007752288); - } - - break; - - /******/ - /* æs */ - /******/ - - case 1: - - /******************/ - /* Timer 0 factor */ - /******************/ - - ul_HighTimerValue - = - (unsigned int) - (ul_HighTiming - * - (0.25 * b_ClockSelection)); - - /*******************/ - /* Round the value */ - /*******************/ - - if ((double)((double)ul_HighTiming * (0.25 * (double)b_ClockSelection)) >= ((double)((double)ul_HighTimerValue + 0.5))) { - ul_HighTimerValue - = - ul_HighTimerValue - + - 1; - } - - /*****************************/ - /* Calculate the real timing */ - /*****************************/ - - ul_RealHighTiming - = - (unsigned int) - (ul_HighTimerValue - / - (0.25 * (double)b_ClockSelection)); - d_RealHighTiming - = - (double) - ul_HighTimerValue - / - ( - (double) - 0.25 - * - (double) - b_ClockSelection); - - if ((double)((double)ul_HighTimerValue / (0.25 * (double)b_ClockSelection)) >= (double)((double)ul_RealHighTiming + 0.5)) { - ul_RealHighTiming - = - ul_RealHighTiming - + - 1; - } - - ul_HighTiming - = - ul_HighTiming - - - 1; - ul_HighTimerValue - = - ul_HighTimerValue - - - 2; - - if (b_ClockSelection != APCI1710_40MHZ) { - ul_HighTimerValue - = - (unsigned int) - ( - (double) - (ul_HighTimerValue) - * - 1.007752288); - } - - break; - - /******/ - /* ms */ - /******/ - - case 2: - - /******************/ - /* Timer 0 factor */ - /******************/ - - ul_HighTimerValue - = - ul_HighTiming - * - (250.0 - * - b_ClockSelection); - - /*******************/ - /* Round the value */ - /*******************/ - - if ((double)((double)ul_HighTiming * (250.0 * (double)b_ClockSelection)) >= ((double)((double)ul_HighTimerValue + 0.5))) { - ul_HighTimerValue - = - ul_HighTimerValue - + - 1; - } - - /*****************************/ - /* Calculate the real timing */ - /*****************************/ - - ul_RealHighTiming - = - (unsigned int) - (ul_HighTimerValue - / - (250.0 * (double)b_ClockSelection)); - d_RealHighTiming - = - (double) - ul_HighTimerValue - / - (250.0 - * - (double) - b_ClockSelection); - - if ((double)((double)ul_HighTimerValue / (250.0 * (double)b_ClockSelection)) >= (double)((double)ul_RealHighTiming + 0.5)) { - ul_RealHighTiming - = - ul_RealHighTiming - + - 1; - } - - ul_HighTiming - = - ul_HighTiming - - - 1; - ul_HighTimerValue - = - ul_HighTimerValue - - - 2; - - if (b_ClockSelection != APCI1710_40MHZ) { - ul_HighTimerValue - = - (unsigned int) - ( - (double) - (ul_HighTimerValue) - * - 1.007752288); - } - - break; - - /*****/ - /* s */ - /*****/ - - case 3: - - /******************/ - /* Timer 0 factor */ - /******************/ - - ul_HighTimerValue - = - (unsigned int) - (ul_HighTiming - * - (250000.0 - * - b_ClockSelection)); - - /*******************/ - /* Round the value */ - /*******************/ - - if ((double)((double)ul_HighTiming * (250000.0 * (double)b_ClockSelection)) >= ((double)((double)ul_HighTimerValue + 0.5))) { - ul_HighTimerValue - = - ul_HighTimerValue - + - 1; - } - - /*****************************/ - /* Calculate the real timing */ - /*****************************/ - - ul_RealHighTiming - = - (unsigned int) - (ul_HighTimerValue - / - (250000.0 - * - (double) - b_ClockSelection)); - d_RealHighTiming - = - (double) - ul_HighTimerValue - / - (250000.0 - * - (double) - b_ClockSelection); - - if ((double)((double)ul_HighTimerValue / (250000.0 * (double)b_ClockSelection)) >= (double)((double)ul_RealHighTiming + 0.5)) { - ul_RealHighTiming - = - ul_RealHighTiming - + - 1; - } - - ul_HighTiming - = - ul_HighTiming - - - 1; - ul_HighTimerValue - = - ul_HighTimerValue - - - 2; - - if (b_ClockSelection != APCI1710_40MHZ) { - ul_HighTimerValue - = - (unsigned int) - ( - (double) - (ul_HighTimerValue) - * - 1.007752288); - } - - break; - - /******/ - /* mn */ - /******/ - - case 4: - - /******************/ - /* Timer 0 factor */ - /******************/ - - ul_HighTimerValue - = - (unsigned int) - ( - (ul_HighTiming - * - 60) - * - (250000.0 - * - b_ClockSelection)); - - /*******************/ - /* Round the value */ - /*******************/ - - if ((double)((double)(ul_HighTiming * 60.0) * (250000.0 * (double)b_ClockSelection)) >= ((double)((double)ul_HighTimerValue + 0.5))) { - ul_HighTimerValue - = - ul_HighTimerValue - + - 1; - } - - /*****************************/ - /* Calculate the real timing */ - /*****************************/ - - ul_RealHighTiming - = - (unsigned int) - (ul_HighTimerValue - / - (250000.0 - * - (double) - b_ClockSelection)) - / - 60; - d_RealHighTiming - = - ( - (double) - ul_HighTimerValue - / - (250000.0 - * - (double) - b_ClockSelection)) - / - 60.0; - - if ((double)(((double)ul_HighTimerValue / (250000.0 * (double)b_ClockSelection)) / 60.0) >= (double)((double)ul_RealHighTiming + 0.5)) { - ul_RealHighTiming - = - ul_RealHighTiming - + - 1; - } - - ul_HighTiming - = - ul_HighTiming - - - 1; - ul_HighTimerValue - = - ul_HighTimerValue - - - 2; - - if (b_ClockSelection != APCI1710_40MHZ) { - ul_HighTimerValue - = - (unsigned int) - ( - (double) - (ul_HighTimerValue) - * - 1.007752288); - } - - break; - } - - fpu_end(); - - /************************/ - /* Save the timing unit */ - /************************/ - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_PWMModuleInfo. - s_PWMInfo - [b_PWM]. - b_TimingUnit - = - b_TimingUnit; - - /****************************/ - /* Save the low base timing */ - /****************************/ - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_PWMModuleInfo. - s_PWMInfo - [b_PWM]. - d_LowTiming - = - d_RealLowTiming; - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_PWMModuleInfo. - s_PWMInfo - [b_PWM]. - ul_RealLowTiming - = - ul_RealLowTiming; - - /****************************/ - /* Save the high base timing */ - /****************************/ - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_PWMModuleInfo. - s_PWMInfo - [b_PWM]. - d_HighTiming - = - d_RealHighTiming; - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_PWMModuleInfo. - s_PWMInfo - [b_PWM]. - ul_RealHighTiming - = - ul_RealHighTiming; - - /************************/ - /* Write the low timing */ - /************************/ - - outl(ul_LowTimerValue, devpriv->s_BoardInfos.ui_Address + 0 + (20 * b_PWM) + (64 * b_ModulNbr)); - - /*************************/ - /* Write the high timing */ - /*************************/ - - outl(ul_HighTimerValue, devpriv->s_BoardInfos.ui_Address + 4 + (20 * b_PWM) + (64 * b_ModulNbr)); - - /***************************/ - /* Set the clock selection */ - /***************************/ - - dw_Command = - inl - (devpriv-> - s_BoardInfos. - ui_Address - + 8 + - (20 * b_PWM) + (64 * b_ModulNbr)); - - dw_Command = - dw_Command - & 0x7F; - - if (b_ClockSelection == APCI1710_40MHZ) { - dw_Command - = - dw_Command - | - 0x80; - } - - /***************************/ - /* Set the clock selection */ - /***************************/ - - outl(dw_Command, - devpriv-> - s_BoardInfos. - ui_Address - + 8 + - (20 * b_PWM) + (64 * b_ModulNbr)); - } else { - /***************************************/ - /* High base timing selection is wrong */ - /***************************************/ - DPRINTK("High base timing selection is wrong\n"); - i_ReturnValue = - -8; - } - } else { - /**************************************/ - /* Low base timing selection is wrong */ - /**************************************/ - DPRINTK("Low base timing selection is wrong\n"); - i_ReturnValue = -7; - } - } /* if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4)) */ - else { - /**********************************/ - /* Timing unit selection is wrong */ - /**********************************/ - DPRINTK("Timing unit selection is wrong\n"); - i_ReturnValue = -6; - } /* if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4)) */ - } /* if (dw_Status & 0x10) */ - else { - /***********************/ - /* PWM not initialised */ - /***********************/ - DPRINTK("PWM not initialised\n"); - i_ReturnValue = -5; - } /* if (dw_Status & 0x10) */ - } /* if (b_PWM >= 0 && b_PWM <= 1) */ - else { - /******************************/ - /* Tor PWM selection is wrong */ - /******************************/ - DPRINTK("Tor PWM selection is wrong\n"); - i_ReturnValue = -4; - } /* if (b_PWM >= 0 && b_PWM <= 1) */ - } else { - /**********************************/ - /* The module is not a PWM module */ - /**********************************/ - DPRINTK("The module is not a PWM module\n"); - i_ReturnValue = -3; - } - } else { - /***********************/ - /* Module number error */ - /***********************/ - DPRINTK("Module number error\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* - * Pwm Enable Disable and Set New Timing - */ -static int i_APCI1710_InsnWritePWM(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - unsigned char b_WriteType; - int i_ReturnValue = 0; - b_WriteType = CR_CHAN(insn->chanspec); - - switch (b_WriteType) { - case APCI1710_PWM_ENABLE: - i_ReturnValue = i_APCI1710_EnablePWM(dev, - (unsigned char) CR_AREF(insn->chanspec), - (unsigned char) data[0], - (unsigned char) data[1], - (unsigned char) data[2], - (unsigned char) data[3], (unsigned char) data[4], (unsigned char) data[5]); - break; - - case APCI1710_PWM_DISABLE: - i_ReturnValue = i_APCI1710_DisablePWM(dev, - (unsigned char) CR_AREF(insn->chanspec), (unsigned char) data[0]); - break; - - case APCI1710_PWM_NEWTIMING: - i_ReturnValue = i_APCI1710_SetNewPWMTiming(dev, - (unsigned char) CR_AREF(insn->chanspec), - (unsigned char) data[0], - (unsigned char) data[1], (unsigned int) data[2], (unsigned int) data[3]); - break; - - default: - printk("Write Config Parameter Wrong\n"); - } - - if (i_ReturnValue >= 0) - i_ReturnValue = insn->n; - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_GetPWMStatus | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char_ b_PWM, | -| unsigned char *_ pb_PWMOutputStatus, | -| unsigned char *_ pb_ExternGateStatus) | -+----------------------------------------------------------------------------+ -| Task : Return the status from selected PWM (b_PWM) from | -| selected module (b_ModulNbr). | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_PWM : Selected PWM (0 or 1) | -| unsigned char_ b_ModulNbr : Selected module number (0 to 3) - b_ModulNbr =(unsigned char) CR_AREF(insn->chanspec); - b_PWM =(unsigned char) data[0]; - - | -+----------------------------------------------------------------------------+ -| Output Parameters : unsigned char *_ pb_PWMOutputStatus : Return the PWM output | -| level status. | -| 0 : The PWM output level| -| is low. | -| 1 : The PWM output level| -| is high. | -| unsigned char *_ pb_ExternGateStatus : Return the extern gate | -| level status. | -| 0 : The extern gate is | -| low. | -| 1 : The extern gate is | -| high. - pb_PWMOutputStatus =(unsigned char *) data[0]; - pb_ExternGateStatus =(unsigned char *) data[1]; | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: Module selection wrong | -| -3: The module is not a PWM module | -| -4: PWM selection is wrong | -| -5: PWM not initialised see function | -| "i_APCI1710_InitPWM" | -| -6: PWM not enabled see function "i_APCI1710_EnablePWM"| -+----------------------------------------------------------------------------+ -*/ -static int i_APCI1710_InsnReadGetPWMStatus(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - unsigned int dw_Status; - unsigned char b_ModulNbr; - unsigned char b_PWM; - unsigned char *pb_PWMOutputStatus; - unsigned char *pb_ExternGateStatus; - - i_ReturnValue = insn->n; - b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec); - b_PWM = (unsigned char) CR_CHAN(insn->chanspec); - pb_PWMOutputStatus = (unsigned char *) &data[0]; - pb_ExternGateStatus = (unsigned char *) &data[1]; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /***************/ - /* Test if PWM */ - /***************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[b_ModulNbr] & - 0xFFFF0000UL) == APCI1710_PWM) { - /**************************/ - /* Test the PWM selection */ - /**************************/ - - if (b_PWM <= 1) { - /***************************/ - /* Test if PWM initialised */ - /***************************/ - - dw_Status = inl(devpriv->s_BoardInfos. - ui_Address + 12 + (20 * b_PWM) + - (64 * b_ModulNbr)); - - if (dw_Status & 0x10) { - /***********************/ - /* Test if PWM enabled */ - /***********************/ - - if (dw_Status & 0x1) { - *pb_PWMOutputStatus = - (unsigned char) ((dw_Status >> 7) - & 1); - *pb_ExternGateStatus = - (unsigned char) ((dw_Status >> 6) - & 1); - } /* if (dw_Status & 0x1) */ - else { - /*******************/ - /* PWM not enabled */ - /*******************/ - - DPRINTK("PWM not enabled \n"); - i_ReturnValue = -6; - } /* if (dw_Status & 0x1) */ - } /* if (dw_Status & 0x10) */ - else { - /***********************/ - /* PWM not initialised */ - /***********************/ - - DPRINTK("PWM not initialised\n"); - i_ReturnValue = -5; - } /* if (dw_Status & 0x10) */ - } /* if (b_PWM >= 0 && b_PWM <= 1) */ - else { - /******************************/ - /* Tor PWM selection is wrong */ - /******************************/ - - DPRINTK("Tor PWM selection is wrong\n"); - i_ReturnValue = -4; - } /* if (b_PWM >= 0 && b_PWM <= 1) */ - } else { - /**********************************/ - /* The module is not a PWM module */ - /**********************************/ - - DPRINTK("The module is not a PWM module\n"); - i_ReturnValue = -3; - } - } else { - /***********************/ - /* Module number error */ - /***********************/ - - DPRINTK("Module number error\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -static int i_APCI1710_InsnBitsReadPWMInterrupt(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - - data[0] = devpriv->s_InterruptParameters. - s_FIFOInterruptParameters[devpriv-> - s_InterruptParameters.ui_Read].b_OldModuleMask; - data[1] = devpriv->s_InterruptParameters. - s_FIFOInterruptParameters[devpriv-> - s_InterruptParameters.ui_Read].ul_OldInterruptMask; - data[2] = devpriv->s_InterruptParameters. - s_FIFOInterruptParameters[devpriv-> - s_InterruptParameters.ui_Read].ul_OldCounterLatchValue; - - /**************************/ - /* Increment the read FIFO */ - /***************************/ - - devpriv-> - s_InterruptParameters. - ui_Read = (devpriv-> - s_InterruptParameters.ui_Read + 1) % APCI1710_SAVE_INTERRUPT; - - return insn->n; - -} diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Ssi.c b/drivers/staging/comedi/drivers/addi-data/APCI1710_Ssi.c deleted file mode 100644 index 6ef1d6a434d90..0000000000000 --- a/drivers/staging/comedi/drivers/addi-data/APCI1710_Ssi.c +++ /dev/null @@ -1,845 +0,0 @@ -/** -@verbatim - -Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. - - ADDI-DATA GmbH - Dieselstrasse 3 - D-77833 Ottersweier - Tel: +19(0)7223/9493-0 - Fax: +49(0)7223/9493-92 - http://www.addi-data.com - info@addi-data.com - -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 the License, or (at your option) any later version. - -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. - -@endverbatim -*/ -/* - - +-----------------------------------------------------------------------+ - | (C) ADDI-DATA GmbH Dieselstraße 3 D-77833 Ottersweier | - +-----------------------------------------------------------------------+ - | Tel : +49 (0) 7223/9493-0 | email : info@addi-data.com | - | Fax : +49 (0) 7223/9493-92 | Internet : http://www.addi-data.com | - +-----------------------------------------------------------------------+ - | Project : API APCI1710 | Compiler : gcc | - | Module name : SSI.C | Version : 2.96 | - +-------------------------------+---------------------------------------+ - | Project manager: Eric Stolz | Date : 02/12/2002 | - +-----------------------------------------------------------------------+ - | Description : APCI-1710 SSI counter module | - +-----------------------------------------------------------------------+ - | several changes done by S. Weber in 1998 and C. Guinot in 2000 | - +-----------------------------------------------------------------------+ -*/ - -#define APCI1710_30MHZ 30 -#define APCI1710_33MHZ 33 -#define APCI1710_40MHZ 40 - -#define APCI1710_BINARY_MODE 0x1 -#define APCI1710_GRAY_MODE 0x0 - -#define APCI1710_SSI_READ1VALUE 1 -#define APCI1710_SSI_READALLVALUE 2 - -#define APCI1710_SSI_SET_CHANNELON 0 -#define APCI1710_SSI_SET_CHANNELOFF 1 -#define APCI1710_SSI_READ_1CHANNEL 2 -#define APCI1710_SSI_READ_ALLCHANNEL 3 - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_InitSSI | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char_ b_SSIProfile, | -| unsigned char_ b_PositionTurnLength, | -| unsigned char_ b_TurnCptLength, | -| unsigned char_ b_PCIInputClock, | -| ULONG_ ul_SSIOutputClock, | -| unsigned char_ b_SSICountingMode) | -+----------------------------------------------------------------------------+ -| Task : Configure the SSI operating mode from selected module | -| (b_ModulNbr). You must calling this function be for you| -| call any other function witch access of SSI. | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710| -| unsigned char_ b_ModulNbr : Module number to | -| configure (0 to 3) | -| unsigned char_ b_SSIProfile : Selection from SSI | -| profile length (2 to 32).| -| unsigned char_ b_PositionTurnLength : Selection from SSI | -| position data length | -| (1 to 31). | -| unsigned char_ b_TurnCptLength : Selection from SSI turn | -| counter data length | -| (1 to 31). | -| unsigned char b_PCIInputClock : Selection from PCI bus | -| clock | -| - APCI1710_30MHZ : | -| The PC have a PCI bus | -| clock from 30 MHz | -| - APCI1710_33MHZ : | -| The PC have a PCI bus | -| clock from 33 MHz | -| ULONG_ ul_SSIOutputClock : Selection from SSI output| -| clock. | -| From 229 to 5 000 000 Hz| -| for 30 MHz selection. | -| From 252 to 5 000 000 Hz| -| for 33 MHz selection. | -| unsigned char b_SSICountingMode : SSI counting mode | -| selection | -| - APCI1710_BINARY_MODE : | -| Binary counting mode. | -| - APCI1710_GRAY_MODE : | -| Gray counting mode. - - b_ModulNbr = CR_AREF(insn->chanspec); - b_SSIProfile = (unsigned char) data[0]; - b_PositionTurnLength= (unsigned char) data[1]; - b_TurnCptLength = (unsigned char) data[2]; - b_PCIInputClock = (unsigned char) data[3]; - ul_SSIOutputClock = (unsigned int) data[4]; - b_SSICountingMode = (unsigned char) data[5]; | -+----------------------------------------------------------------------------+ -| Output Parameters : - | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: The module parameter is wrong | -| -3: The module is not a SSI module | -| -4: The selected SSI profile length is wrong | -| -5: The selected SSI position data length is wrong | -| -6: The selected SSI turn counter data length is wrong | -| -7: The selected PCI input clock is wrong | -| -8: The selected SSI output clock is wrong | -| -9: The selected SSI counting mode parameter is wrong | -+----------------------------------------------------------------------------+ -*/ - -static int i_APCI1710_InsnConfigInitSSI(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - unsigned int ui_TimerValue; - unsigned char b_ModulNbr, b_SSIProfile, b_PositionTurnLength, b_TurnCptLength, - b_PCIInputClock, b_SSICountingMode; - unsigned int ul_SSIOutputClock; - - b_ModulNbr = CR_AREF(insn->chanspec); - b_SSIProfile = (unsigned char) data[0]; - b_PositionTurnLength = (unsigned char) data[1]; - b_TurnCptLength = (unsigned char) data[2]; - b_PCIInputClock = (unsigned char) data[3]; - ul_SSIOutputClock = (unsigned int) data[4]; - b_SSICountingMode = (unsigned char) data[5]; - - i_ReturnValue = insn->n; - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /***********************/ - /* Test if SSI counter */ - /***********************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[b_ModulNbr] & - 0xFFFF0000UL) == APCI1710_SSI_COUNTER) { - /*******************************/ - /* Test the SSI profile length */ - /*******************************/ - - /* CG 22/03/00 b_SSIProfile >= 2 anstatt b_SSIProfile > 2 */ - if (b_SSIProfile >= 2 && b_SSIProfile < 33) { - /*************************************/ - /* Test the SSI position data length */ - /*************************************/ - - if (b_PositionTurnLength > 0 - && b_PositionTurnLength < 32) { - /*****************************************/ - /* Test the SSI turn counter data length */ - /*****************************************/ - - if (b_TurnCptLength > 0 - && b_TurnCptLength < 32) { - /***************************/ - /* Test the profile length */ - /***************************/ - - if ((b_TurnCptLength + - b_PositionTurnLength) - <= b_SSIProfile) { - /****************************/ - /* Test the PCI input clock */ - /****************************/ - - if (b_PCIInputClock == - APCI1710_30MHZ - || - b_PCIInputClock - == - APCI1710_33MHZ) - { - /*************************/ - /* Test the output clock */ - /*************************/ - - if ((b_PCIInputClock == APCI1710_30MHZ && (ul_SSIOutputClock > 228 && ul_SSIOutputClock <= 5000000UL)) || (b_PCIInputClock == APCI1710_33MHZ && (ul_SSIOutputClock > 251 && ul_SSIOutputClock <= 5000000UL))) { - if (b_SSICountingMode == APCI1710_BINARY_MODE || b_SSICountingMode == APCI1710_GRAY_MODE) { - /**********************/ - /* Save configuration */ - /**********************/ - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SSICounterInfo. - b_SSIProfile - = - b_SSIProfile; - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SSICounterInfo. - b_PositionTurnLength - = - b_PositionTurnLength; - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SSICounterInfo. - b_TurnCptLength - = - b_TurnCptLength; - - /*********************************/ - /* Initialise the profile length */ - /*********************************/ - - if (b_SSICountingMode == APCI1710_BINARY_MODE) { - - outl(b_SSIProfile + 1, devpriv->s_BoardInfos.ui_Address + 4 + (64 * b_ModulNbr)); - } else { - - outl(b_SSIProfile, devpriv->s_BoardInfos.ui_Address + 4 + (64 * b_ModulNbr)); - } - - /******************************/ - /* Calculate the output clock */ - /******************************/ - - ui_TimerValue - = - (unsigned int) - ( - ((unsigned int) (b_PCIInputClock) * 500000UL) / ul_SSIOutputClock); - - /************************/ - /* Initialise the timer */ - /************************/ - - outl(ui_TimerValue, devpriv->s_BoardInfos.ui_Address + (64 * b_ModulNbr)); - - /********************************/ - /* Initialise the counting mode */ - /********************************/ - - outl(7 * b_SSICountingMode, devpriv->s_BoardInfos.ui_Address + 12 + (64 * b_ModulNbr)); - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SSICounterInfo. - b_SSIInit - = - 1; - } else { - /*****************************************************/ - /* The selected SSI counting mode parameter is wrong */ - /*****************************************************/ - - DPRINTK("The selected SSI counting mode parameter is wrong\n"); - i_ReturnValue - = - -9; - } - } else { - /******************************************/ - /* The selected SSI output clock is wrong */ - /******************************************/ - - DPRINTK("The selected SSI output clock is wrong\n"); - i_ReturnValue - = - -8; - } - } else { - /*****************************************/ - /* The selected PCI input clock is wrong */ - /*****************************************/ - - DPRINTK("The selected PCI input clock is wrong\n"); - i_ReturnValue = - -7; - } - } else { - /********************************************/ - /* The selected SSI profile length is wrong */ - /********************************************/ - - DPRINTK("The selected SSI profile length is wrong\n"); - i_ReturnValue = -4; - } - } else { - /******************************************************/ - /* The selected SSI turn counter data length is wrong */ - /******************************************************/ - - DPRINTK("The selected SSI turn counter data length is wrong\n"); - i_ReturnValue = -6; - } - } else { - /**************************************************/ - /* The selected SSI position data length is wrong */ - /**************************************************/ - - DPRINTK("The selected SSI position data length is wrong\n"); - i_ReturnValue = -5; - } - } else { - /********************************************/ - /* The selected SSI profile length is wrong */ - /********************************************/ - - DPRINTK("The selected SSI profile length is wrong\n"); - i_ReturnValue = -4; - } - } else { - /**********************************/ - /* The module is not a SSI module */ - /**********************************/ - - DPRINTK("The module is not a SSI module\n"); - i_ReturnValue = -3; - } - } else { - /***********************/ - /* Module number error */ - /***********************/ - - DPRINTK("Module number error\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_Read1SSIValue | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char_ b_SelectedSSI, | -| PULONG_ pul_Position, | -| PULONG_ pul_TurnCpt) - int i_APCI1710_ReadSSIValue(struct comedi_device *dev,struct comedi_subdevice *s, - struct comedi_insn *insn,unsigned int *data) | -+----------------------------------------------------------------------------+ -| Task : - - - Read the selected SSI counter (b_SelectedSSI) from | -| selected module (b_ModulNbr). - or Read all SSI counter (b_SelectedSSI) from | -| selected module (b_ModulNbr). | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710| -| unsigned char_ b_ModulNbr : Module number to | -| configure (0 to 3) | -| unsigned char_ b_SelectedSSI : Selection from SSI | -| counter (0 to 2) - - b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec); - b_SelectedSSI = (unsigned char) CR_CHAN(insn->chanspec); (in case of single ssi) - b_ReadType = (unsigned char) CR_RANGE(insn->chanspec); -| -+----------------------------------------------------------------------------+ -| Output Parameters : PULONG_ pul_Position : SSI position in the turn | -| PULONG_ pul_TurnCpt : Number of turns - -pul_Position = (unsigned int *) &data[0]; - pul_TurnCpt = (unsigned int *) &data[1]; | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: The module parameter is wrong | -| -3: The module is not a SSI module | -| -4: SSI not initialised see function | -| "i_APCI1710_InitSSI" | -| -5: The selected SSI is wrong | -+----------------------------------------------------------------------------+ -*/ - -static int i_APCI1710_InsnReadSSIValue(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - unsigned char b_Cpt; - unsigned char b_Length; - unsigned char b_Schift; - unsigned char b_SSICpt; - unsigned int dw_And; - unsigned int dw_And1; - unsigned int dw_And2; - unsigned int dw_StatusReg; - unsigned int dw_CounterValue; - unsigned char b_ModulNbr; - unsigned char b_SelectedSSI; - unsigned char b_ReadType; - unsigned int *pul_Position; - unsigned int *pul_TurnCpt; - unsigned int *pul_Position1; - unsigned int *pul_TurnCpt1; - - i_ReturnValue = insn->n; - pul_Position1 = (unsigned int *) &data[0]; -/* For Read1 */ - pul_TurnCpt1 = (unsigned int *) &data[1]; -/* For Read all */ - pul_Position = (unsigned int *) &data[0]; /* 0-2 */ - pul_TurnCpt = (unsigned int *) &data[3]; /* 3-5 */ - b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec); - b_SelectedSSI = (unsigned char) CR_CHAN(insn->chanspec); - b_ReadType = (unsigned char) CR_RANGE(insn->chanspec); - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /***********************/ - /* Test if SSI counter */ - /***********************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[b_ModulNbr] & - 0xFFFF0000UL) == APCI1710_SSI_COUNTER) { - /***************************/ - /* Test if SSI initialised */ - /***************************/ - - if (devpriv->s_ModuleInfo[b_ModulNbr]. - s_SSICounterInfo.b_SSIInit == 1) { - - switch (b_ReadType) { - - case APCI1710_SSI_READ1VALUE: - /****************************************/ - /* Test the selected SSI counter number */ - /****************************************/ - - if (b_SelectedSSI < 3) { - /************************/ - /* Start the conversion */ - /************************/ - - outl(0, devpriv->s_BoardInfos. - ui_Address + 8 + - (64 * b_ModulNbr)); - - do { - /*******************/ - /* Read the status */ - /*******************/ - - dw_StatusReg = - inl(devpriv-> - s_BoardInfos. - ui_Address + - (64 * b_ModulNbr)); - } while ((dw_StatusReg & 0x1) - != 0); - - /******************************/ - /* Read the SSI counter value */ - /******************************/ - - dw_CounterValue = - inl(devpriv-> - s_BoardInfos. - ui_Address + 4 + - (b_SelectedSSI * 4) + - (64 * b_ModulNbr)); - - b_Length = - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SSICounterInfo. - b_SSIProfile / 2; - - if ((b_Length * 2) != - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SSICounterInfo. - b_SSIProfile) { - b_Length++; - } - - b_Schift = - b_Length - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SSICounterInfo. - b_PositionTurnLength; - - *pul_Position1 = - dw_CounterValue >> - b_Schift; - - dw_And = 1; - - for (b_Cpt = 0; - b_Cpt < - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SSICounterInfo. - b_PositionTurnLength; - b_Cpt++) { - dw_And = dw_And * 2; - } - - *pul_Position1 = - *pul_Position1 & - ((dw_And) - 1); - - *pul_TurnCpt1 = - dw_CounterValue >> - b_Length; - - dw_And = 1; - - for (b_Cpt = 0; - b_Cpt < - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SSICounterInfo. - b_TurnCptLength; - b_Cpt++) { - dw_And = dw_And * 2; - } - - *pul_TurnCpt1 = - *pul_TurnCpt1 & - ((dw_And) - 1); - } else { - /*****************************/ - /* The selected SSI is wrong */ - /*****************************/ - - DPRINTK("The selected SSI is wrong\n"); - i_ReturnValue = -5; - } - break; - - case APCI1710_SSI_READALLVALUE: - dw_And1 = 1; - - for (b_Cpt = 0; - b_Cpt < - devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SSICounterInfo. - b_PositionTurnLength; b_Cpt++) { - dw_And1 = dw_And1 * 2; - } - - dw_And2 = 1; - - for (b_Cpt = 0; - b_Cpt < - devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_SSICounterInfo. - b_TurnCptLength; b_Cpt++) { - dw_And2 = dw_And2 * 2; - } - - /************************/ - /* Start the conversion */ - /************************/ - - outl(0, devpriv->s_BoardInfos. - ui_Address + 8 + - (64 * b_ModulNbr)); - - do { - /*******************/ - /* Read the status */ - /*******************/ - - dw_StatusReg = - inl(devpriv-> - s_BoardInfos. - ui_Address + - (64 * b_ModulNbr)); - } while ((dw_StatusReg & 0x1) != 0); - - for (b_SSICpt = 0; b_SSICpt < 3; - b_SSICpt++) { - /******************************/ - /* Read the SSI counter value */ - /******************************/ - - dw_CounterValue = - inl(devpriv-> - s_BoardInfos. - ui_Address + 4 + - (b_SSICpt * 4) + - (64 * b_ModulNbr)); - - b_Length = - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SSICounterInfo. - b_SSIProfile / 2; - - if ((b_Length * 2) != - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SSICounterInfo. - b_SSIProfile) { - b_Length++; - } - - b_Schift = - b_Length - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_SSICounterInfo. - b_PositionTurnLength; - - pul_Position[b_SSICpt] = - dw_CounterValue >> - b_Schift; - pul_Position[b_SSICpt] = - pul_Position[b_SSICpt] & - ((dw_And1) - 1); - - pul_TurnCpt[b_SSICpt] = - dw_CounterValue >> - b_Length; - pul_TurnCpt[b_SSICpt] = - pul_TurnCpt[b_SSICpt] & - ((dw_And2) - 1); - } - break; - - default: - printk("Read Type Inputs Wrong\n"); - - } /* switch ending */ - - } else { - /***********************/ - /* SSI not initialised */ - /***********************/ - - DPRINTK("SSI not initialised\n"); - i_ReturnValue = -4; - } - } else { - /**********************************/ - /* The module is not a SSI module */ - /**********************************/ - - DPRINTK("The module is not a SSI module\n"); - i_ReturnValue = -3; - - } - } else { - /***********************/ - /* Module number error */ - /***********************/ - - DPRINTK("Module number error\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_ReadSSI1DigitalInput | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char_ b_InputChannel, | -| unsigned char *_ pb_ChannelStatus) | -+----------------------------------------------------------------------------+ -| Task : - (0) Set the digital output from selected SSI module | -| (b_ModuleNbr) ON - (1) Set the digital output from selected SSI module | -| (b_ModuleNbr) OFF - (2)Read the status from selected SSI digital input | -| (b_InputChannel) - (3)Read the status from all SSI digital inputs from | -| selected SSI module (b_ModulNbr) | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710| -| unsigned char_ b_ModulNbr CR_AREF : Module number to | -| configure (0 to 3) | -| unsigned char_ b_InputChannel CR_CHAN : Selection from digital | -| data[0] which IOTYPE input ( 0 to 2) | -+----------------------------------------------------------------------------+ -| Output Parameters : unsigned char *_ pb_ChannelStatus : Digital input channel | -| data[0] status | -| 0 : Channle is not active| -| 1 : Channle is active | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: The module parameter is wrong | -| -3: The module is not a SSI module | -| -4: The selected SSI digital input is wrong | -+----------------------------------------------------------------------------+ -*/ - -static int i_APCI1710_InsnBitsSSIDigitalIO(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - unsigned int dw_StatusReg; - unsigned char b_ModulNbr; - unsigned char b_InputChannel; - unsigned char *pb_ChannelStatus; - unsigned char *pb_InputStatus; - unsigned char b_IOType; - - i_ReturnValue = insn->n; - b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec); - b_IOType = (unsigned char) data[0]; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /***********************/ - /* Test if SSI counter */ - /***********************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[b_ModulNbr] & - 0xFFFF0000UL) == APCI1710_SSI_COUNTER) { - switch (b_IOType) { - case APCI1710_SSI_SET_CHANNELON: - /*****************************/ - /* Set the digital output ON */ - /*****************************/ - - outl(1, devpriv->s_BoardInfos.ui_Address + 16 + - (64 * b_ModulNbr)); - break; - - case APCI1710_SSI_SET_CHANNELOFF: - /******************************/ - /* Set the digital output OFF */ - /******************************/ - - outl(0, devpriv->s_BoardInfos.ui_Address + 16 + - (64 * b_ModulNbr)); - break; - - case APCI1710_SSI_READ_1CHANNEL: - /******************************************/ - /* Test the digital imnput channel number */ - /******************************************/ - - b_InputChannel = (unsigned char) CR_CHAN(insn->chanspec); - pb_ChannelStatus = (unsigned char *) &data[0]; - - if (b_InputChannel <= 2) { - /**************************/ - /* Read all digital input */ - /**************************/ - - dw_StatusReg = - inl(devpriv->s_BoardInfos. - ui_Address + (64 * b_ModulNbr)); - *pb_ChannelStatus = - (unsigned char) (((~dw_StatusReg) >> (4 + - b_InputChannel)) - & 1); - } else { - /********************************/ - /* Selected digital input error */ - /********************************/ - - DPRINTK("Selected digital input error\n"); - i_ReturnValue = -4; - } - break; - - case APCI1710_SSI_READ_ALLCHANNEL: - /**************************/ - /* Read all digital input */ - /**************************/ - pb_InputStatus = (unsigned char *) &data[0]; - - dw_StatusReg = - inl(devpriv->s_BoardInfos.ui_Address + - (64 * b_ModulNbr)); - *pb_InputStatus = - (unsigned char) (((~dw_StatusReg) >> 4) & 7); - break; - - default: - printk("IO type wrong\n"); - - } /* switch end */ - } else { - /**********************************/ - /* The module is not a SSI module */ - /**********************************/ - - DPRINTK("The module is not a SSI module\n"); - i_ReturnValue = -3; - } - } else { - /***********************/ - /* Module number error */ - /***********************/ - - DPRINTK("Module number error\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Tor.c b/drivers/staging/comedi/drivers/addi-data/APCI1710_Tor.c deleted file mode 100644 index 0b79531ac24b3..0000000000000 --- a/drivers/staging/comedi/drivers/addi-data/APCI1710_Tor.c +++ /dev/null @@ -1,2065 +0,0 @@ -/** -@verbatim - -Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. - - ADDI-DATA GmbH - Dieselstrasse 3 - D-77833 Ottersweier - Tel: +19(0)7223/9493-0 - Fax: +49(0)7223/9493-92 - http://www.addi-data.com - info@addi-data.com - -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 the License, or (at your option) any later version. - -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. - -@endverbatim -*/ -/* - - +-----------------------------------------------------------------------+ - | (C) ADDI-DATA GmbH Dieselstraße 3 D-77833 Ottersweier | - +-----------------------------------------------------------------------+ - | Tel : +49 (0) 7223/9493-0 | email : info@addi-data.com | - | Fax : +49 (0) 7223/9493-92 | Internet : http://www.addi-data.com | - +-----------------------------------------------------------------------+ - | Project : API APCI1710 | Compiler : gcc | - | Module name : TOR.C | Version : 2.96 | - +-------------------------------+---------------------------------------+ - | Project manager: Eric Stolz | Date : 02/12/2002 | - +-----------------------------------------------------------------------+ - | Description : APCI-1710 tor counter module | - | | - | | - +-----------------------------------------------------------------------+ - | UPDATES | - +-----------------------------------------------------------------------+ - | Date | Author | Description of updates | - +----------+-----------+------------------------------------------------+ - | 27/01/99 | S. Weber | 40 MHz implementation | - +-----------------------------------------------------------------------+ - | 28/04/00 | S. Weber | Simple,double and quadruple mode implementation| - | | | Extern clock implementation | - +-----------------------------------------------------------------------+ - | 08/05/00 | Guinot C | - 0400/0228 All Function in RING 0 | - | | | available | - +-----------------------------------------------------------------------+ -*/ - -#define APCI1710_30MHZ 30 -#define APCI1710_33MHZ 33 -#define APCI1710_40MHZ 40 - -#define APCI1710_GATE_INPUT 10 - -#define APCI1710_TOR_SIMPLE_MODE 2 -#define APCI1710_TOR_DOUBLE_MODE 3 -#define APCI1710_TOR_QUADRUPLE_MODE 4 - -#define APCI1710_SINGLE 0 -#define APCI1710_CONTINUOUS 1 - -#define APCI1710_TOR_GETPROGRESSSTATUS 0 -#define APCI1710_TOR_GETCOUNTERVALUE 1 -#define APCI1710_TOR_READINTERRUPT 2 - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_InitTorCounter | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char_ b_TorCounter, | -| unsigned char_ b_PCIInputClock, | -| unsigned char_ b_TimingUnit, | -| ULONG_ ul_TimingInterval, | -| PULONG_ pul_RealTimingInterval) | -+----------------------------------------------------------------------------+ -| Task : Configure the selected tor counter (b_TorCounter) | -| from selected module (b_ModulNbr). | -| The ul_TimingInterval and ul_TimingUnit determine the | -| timing base for the measurement. | -| The pul_RealTimingInterval return the real timing | -| value. You must calling this function be for you call | -| any other function witch access of the tor counter. | -| | -+----------------------------------------------------------------------------+ -| Input Parameters : | -| - CR_AREF unsigned char_ b_ModulNbr : Module number to configure | -| (0 to 3) | -| data[0] unsigned char_ b_TorCounter : Tor counter selection | -| (0 or 1). | -| data[1] unsigned char_ b_PCIInputClock : Selection from PCI bus clock| -| - APCI1710_30MHZ : | -| The PC have a PCI bus | -| clock from 30 MHz | -| - APCI1710_33MHZ : | -| The PC have a PCI bus | -| clock from 33 MHz | -| - APCI1710_40MHZ | -| The APCI-1710 have a | -| integrated 40Mhz | -| quartz. | -| - APCI1710_GATE_INPUT | -| Used the gate input for | -| the base clock. If you | -| have selected this option,| -| than it is not possibl to | -| used the gate input for | -| enabled the acquisition | -| data[2] unsigned char_ b_TimingUnit : Base timing unit (0 to 4) | -| 0 : ns | -| 1 : µs | -| 2 : ms | -| 3 : s | -| 4 : mn | -| data[3] ULONG_ ul_TimingInterval : Base timing value. | -+----------------------------------------------------------------------------+ -| Output Parameters : PULONG_ pul_RealTimingInterval : Real base timing | -| data[0] value. | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: Module selection wrong | -| -3: The module is not a tor counter module | -| -4: Tor counter selection is wrong | -| -5: The selected PCI input clock is wrong | -| -6: Timing unit selection is wrong | -| -7: Base timing selection is wrong | -| -8: You can not used the 40MHz clock selection wich | -| this board | -| -9: You can not used the 40MHz clock selection wich | -| this TOR version | -+----------------------------------------------------------------------------+ -*/ - -static int i_APCI1710_InsnConfigInitTorCounter(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - unsigned int ul_TimerValue = 0; - unsigned int dw_Command; - double d_RealTimingInterval = 0; - unsigned char b_ModulNbr; - unsigned char b_TorCounter; - unsigned char b_PCIInputClock; - unsigned char b_TimingUnit; - unsigned int ul_TimingInterval; - unsigned int ul_RealTimingInterval = 0; - - i_ReturnValue = insn->n; - b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec); - - b_TorCounter = (unsigned char) data[0]; - b_PCIInputClock = (unsigned char) data[1]; - b_TimingUnit = (unsigned char) data[2]; - ul_TimingInterval = (unsigned int) data[3]; - printk("INPUT clock %d\n", b_PCIInputClock); - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /***********************/ - /* Test if tor counter */ - /***********************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[b_ModulNbr] & - 0xFFFF0000UL) == APCI1710_TOR_COUNTER) { - /**********************************/ - /* Test the tor counter selection */ - /**********************************/ - - if (b_TorCounter <= 1) { - /**************************/ - /* Test the PCI bus clock */ - /**************************/ - - if ((b_PCIInputClock == APCI1710_30MHZ) || - (b_PCIInputClock == APCI1710_33MHZ) || - (b_PCIInputClock == APCI1710_40MHZ) || - (b_PCIInputClock == - APCI1710_GATE_INPUT)) { - /************************/ - /* Test the timing unit */ - /************************/ - - if ((b_TimingUnit <= 4) - || (b_PCIInputClock == - APCI1710_GATE_INPUT)) { - /**********************************/ - /* Test the base timing selection */ - /**********************************/ - - if (((b_PCIInputClock == APCI1710_30MHZ) && (b_TimingUnit == 0) && (ul_TimingInterval >= 133) && (ul_TimingInterval <= 0xFFFFFFFFUL)) || ((b_PCIInputClock == APCI1710_30MHZ) && (b_TimingUnit == 1) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 571230650UL)) || ((b_PCIInputClock == APCI1710_30MHZ) && (b_TimingUnit == 2) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 571230UL)) || ((b_PCIInputClock == APCI1710_30MHZ) && (b_TimingUnit == 3) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 571UL)) || ((b_PCIInputClock == APCI1710_30MHZ) && (b_TimingUnit == 4) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 9UL)) || ((b_PCIInputClock == APCI1710_33MHZ) && (b_TimingUnit == 0) && (ul_TimingInterval >= 121) && (ul_TimingInterval <= 0xFFFFFFFFUL)) || ((b_PCIInputClock == APCI1710_33MHZ) && (b_TimingUnit == 1) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 519691043UL)) || ((b_PCIInputClock == APCI1710_33MHZ) && (b_TimingUnit == 2) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 519691UL)) || ((b_PCIInputClock == APCI1710_33MHZ) && (b_TimingUnit == 3) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 520UL)) || ((b_PCIInputClock == APCI1710_33MHZ) && (b_TimingUnit == 4) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 8UL)) || ((b_PCIInputClock == APCI1710_40MHZ) && (b_TimingUnit == 0) && (ul_TimingInterval >= 100) && (ul_TimingInterval <= 0xFFFFFFFFUL)) || ((b_PCIInputClock == APCI1710_40MHZ) && (b_TimingUnit == 1) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 429496729UL)) || ((b_PCIInputClock == APCI1710_40MHZ) && (b_TimingUnit == 2) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 429496UL)) || ((b_PCIInputClock == APCI1710_40MHZ) && (b_TimingUnit == 3) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 429UL)) || ((b_PCIInputClock == APCI1710_40MHZ) && (b_TimingUnit == 4) && (ul_TimingInterval >= 1) && (ul_TimingInterval <= 7UL)) || ((b_PCIInputClock == APCI1710_GATE_INPUT) && (ul_TimingInterval >= 2))) { - /**************************/ - /* Test the board version */ - /**************************/ - - if (((b_PCIInputClock == APCI1710_40MHZ) && (devpriv->s_BoardInfos.b_BoardVersion > 0)) || (b_PCIInputClock != APCI1710_40MHZ)) { - /************************/ - /* Test the TOR version */ - /************************/ - - if (((b_PCIInputClock == APCI1710_40MHZ) && ((devpriv->s_BoardInfos.dw_MolduleConfiguration[b_ModulNbr] & 0xFFFF) >= 0x3131)) || ((b_PCIInputClock == APCI1710_GATE_INPUT) && ((devpriv->s_BoardInfos.dw_MolduleConfiguration[b_ModulNbr] & 0xFFFF) >= 0x3132)) || (b_PCIInputClock == APCI1710_30MHZ) || (b_PCIInputClock == APCI1710_33MHZ)) { - /*********************************/ - /* Test if not extern clock used */ - /*********************************/ - - if (b_PCIInputClock != APCI1710_GATE_INPUT) { - fpu_begin - (); - /****************************************/ - /* Calculate the timer 0 division fator */ - /****************************************/ - - switch (b_TimingUnit) { - /******/ - /* ns */ - /******/ - - case 0: - - /******************/ - /* Timer 0 factor */ - /******************/ - - ul_TimerValue - = - (unsigned int) - (ul_TimingInterval - * - (0.00025 * b_PCIInputClock)); - - /*******************/ - /* Round the value */ - /*******************/ - - if ((double)((double)ul_TimingInterval * (0.00025 * (double)b_PCIInputClock)) >= ((double)((double)ul_TimerValue + 0.5))) { - ul_TimerValue - = - ul_TimerValue - + - 1; - } - - /*****************************/ - /* Calculate the real timing */ - /*****************************/ - - ul_RealTimingInterval - = - (unsigned int) - (ul_TimerValue - / - (0.00025 * (double)b_PCIInputClock)); - d_RealTimingInterval - = - (double) - ul_TimerValue - / - (0.00025 - * - (double) - b_PCIInputClock); - - if ((double)((double)ul_TimerValue / (0.00025 * (double)b_PCIInputClock)) >= (double)((double)ul_RealTimingInterval + 0.5)) { - ul_RealTimingInterval - = - ul_RealTimingInterval - + - 1; - } - - ul_TimingInterval - = - ul_TimingInterval - - - 1; - ul_TimerValue - = - ul_TimerValue - - - 2; - - if (b_PCIInputClock != APCI1710_40MHZ) { - ul_TimerValue - = - (unsigned int) - ( - (double) - (ul_TimerValue) - * - 1.007752288); - } - - break; - - /******/ - /* æs */ - /******/ - - case 1: - - /******************/ - /* Timer 0 factor */ - /******************/ - - ul_TimerValue - = - (unsigned int) - (ul_TimingInterval - * - (0.25 * b_PCIInputClock)); - - /*******************/ - /* Round the value */ - /*******************/ - - if ((double)((double)ul_TimingInterval * (0.25 * (double)b_PCIInputClock)) >= ((double)((double)ul_TimerValue + 0.5))) { - ul_TimerValue - = - ul_TimerValue - + - 1; - } - - /*****************************/ - /* Calculate the real timing */ - /*****************************/ - - ul_RealTimingInterval - = - (unsigned int) - (ul_TimerValue - / - (0.25 * (double)b_PCIInputClock)); - d_RealTimingInterval - = - (double) - ul_TimerValue - / - ( - (double) - 0.25 - * - (double) - b_PCIInputClock); - - if ((double)((double)ul_TimerValue / (0.25 * (double)b_PCIInputClock)) >= (double)((double)ul_RealTimingInterval + 0.5)) { - ul_RealTimingInterval - = - ul_RealTimingInterval - + - 1; - } - - ul_TimingInterval - = - ul_TimingInterval - - - 1; - ul_TimerValue - = - ul_TimerValue - - - 2; - - if (b_PCIInputClock != APCI1710_40MHZ) { - ul_TimerValue - = - (unsigned int) - ( - (double) - (ul_TimerValue) - * - 1.007752288); - } - - break; - - /******/ - /* ms */ - /******/ - - case 2: - - /******************/ - /* Timer 0 factor */ - /******************/ - - ul_TimerValue - = - ul_TimingInterval - * - (250.0 - * - b_PCIInputClock); - - /*******************/ - /* Round the value */ - /*******************/ - - if ((double)((double)ul_TimingInterval * (250.0 * (double)b_PCIInputClock)) >= ((double)((double)ul_TimerValue + 0.5))) { - ul_TimerValue - = - ul_TimerValue - + - 1; - } - - /*****************************/ - /* Calculate the real timing */ - /*****************************/ - - ul_RealTimingInterval - = - (unsigned int) - (ul_TimerValue - / - (250.0 * (double)b_PCIInputClock)); - d_RealTimingInterval - = - (double) - ul_TimerValue - / - (250.0 - * - (double) - b_PCIInputClock); - - if ((double)((double)ul_TimerValue / (250.0 * (double)b_PCIInputClock)) >= (double)((double)ul_RealTimingInterval + 0.5)) { - ul_RealTimingInterval - = - ul_RealTimingInterval - + - 1; - } - - ul_TimingInterval - = - ul_TimingInterval - - - 1; - ul_TimerValue - = - ul_TimerValue - - - 2; - - if (b_PCIInputClock != APCI1710_40MHZ) { - ul_TimerValue - = - (unsigned int) - ( - (double) - (ul_TimerValue) - * - 1.007752288); - } - - break; - - /*****/ - /* s */ - /*****/ - - case 3: - - /******************/ - /* Timer 0 factor */ - /******************/ - - ul_TimerValue - = - (unsigned int) - (ul_TimingInterval - * - (250000.0 - * - b_PCIInputClock)); - - /*******************/ - /* Round the value */ - /*******************/ - - if ((double)((double)ul_TimingInterval * (250000.0 * (double)b_PCIInputClock)) >= ((double)((double)ul_TimerValue + 0.5))) { - ul_TimerValue - = - ul_TimerValue - + - 1; - } - - /*****************************/ - /* Calculate the real timing */ - /*****************************/ - - ul_RealTimingInterval - = - (unsigned int) - (ul_TimerValue - / - (250000.0 - * - (double) - b_PCIInputClock)); - d_RealTimingInterval - = - (double) - ul_TimerValue - / - (250000.0 - * - (double) - b_PCIInputClock); - - if ((double)((double)ul_TimerValue / (250000.0 * (double)b_PCIInputClock)) >= (double)((double)ul_RealTimingInterval + 0.5)) { - ul_RealTimingInterval - = - ul_RealTimingInterval - + - 1; - } - - ul_TimingInterval - = - ul_TimingInterval - - - 1; - ul_TimerValue - = - ul_TimerValue - - - 2; - - if (b_PCIInputClock != APCI1710_40MHZ) { - ul_TimerValue - = - (unsigned int) - ( - (double) - (ul_TimerValue) - * - 1.007752288); - } - - break; - - /******/ - /* mn */ - /******/ - - case 4: - - /******************/ - /* Timer 0 factor */ - /******************/ - - ul_TimerValue - = - (unsigned int) - ( - (ul_TimingInterval - * - 60) - * - (250000.0 - * - b_PCIInputClock)); - - /*******************/ - /* Round the value */ - /*******************/ - - if ((double)((double)(ul_TimingInterval * 60.0) * (250000.0 * (double)b_PCIInputClock)) >= ((double)((double)ul_TimerValue + 0.5))) { - ul_TimerValue - = - ul_TimerValue - + - 1; - } - - /*****************************/ - /* Calculate the real timing */ - /*****************************/ - - ul_RealTimingInterval - = - (unsigned int) - (ul_TimerValue - / - (250000.0 - * - (double) - b_PCIInputClock)) - / - 60; - d_RealTimingInterval - = - ( - (double) - ul_TimerValue - / - (250000.0 - * - (double) - b_PCIInputClock)) - / - 60.0; - - if ((double)(((double)ul_TimerValue / (250000.0 * (double)b_PCIInputClock)) / 60.0) >= (double)((double)ul_RealTimingInterval + 0.5)) { - ul_RealTimingInterval - = - ul_RealTimingInterval - + - 1; - } - - ul_TimingInterval - = - ul_TimingInterval - - - 1; - ul_TimerValue - = - ul_TimerValue - - - 2; - - if (b_PCIInputClock != APCI1710_40MHZ) { - ul_TimerValue - = - (unsigned int) - ( - (double) - (ul_TimerValue) - * - 1.007752288); - } - - break; - } - - fpu_end(); - } /* if (b_PCIInputClock != APCI1710_GATE_INPUT) */ - else { - /*************************************************************/ - /* 2 Clock used for the overflow and the reload from counter */ - /*************************************************************/ - - ul_TimerValue - = - ul_TimingInterval - - - 2; - } /* if (b_PCIInputClock != APCI1710_GATE_INPUT) */ - - /****************************/ - /* Save the PCI input clock */ - /****************************/ - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_TorCounterModuleInfo. - b_PCIInputClock - = - b_PCIInputClock; - - /************************/ - /* Save the timing unit */ - /************************/ - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_TorCounterModuleInfo. - s_TorCounterInfo - [b_TorCounter]. - b_TimingUnit - = - b_TimingUnit; - - /************************/ - /* Save the base timing */ - /************************/ - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_TorCounterModuleInfo. - s_TorCounterInfo - [b_TorCounter]. - d_TimingInterval - = - d_RealTimingInterval; - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_TorCounterModuleInfo. - s_TorCounterInfo - [b_TorCounter]. - ul_RealTimingInterval - = - ul_RealTimingInterval; - - /*******************/ - /* Get the command */ - /*******************/ - - dw_Command - = - inl - (devpriv-> - s_BoardInfos. - ui_Address - + - 4 - + - (16 * b_TorCounter) + (64 * b_ModulNbr)); - - dw_Command - = - (dw_Command - >> - 4) - & - 0xF; - - /******************/ - /* Test if 40 MHz */ - /******************/ - - if (b_PCIInputClock == APCI1710_40MHZ) { - /****************************/ - /* Set the 40 MHz selection */ - /****************************/ - - dw_Command - = - dw_Command - | - 0x10; - } - - /*****************************/ - /* Test if extern clock used */ - /*****************************/ - - if (b_PCIInputClock == APCI1710_GATE_INPUT) { - /****************************/ - /* Set the 40 MHz selection */ - /****************************/ - - dw_Command - = - dw_Command - | - 0x20; - } - - /*************************/ - /* Write the new command */ - /*************************/ - - outl(dw_Command, devpriv->s_BoardInfos.ui_Address + 4 + (16 * b_TorCounter) + (64 * b_ModulNbr)); - - /*******************/ - /* Disable the tor */ - /*******************/ - - outl(0, devpriv->s_BoardInfos.ui_Address + 8 + (16 * b_TorCounter) + (64 * b_ModulNbr)); - /*************************/ - /* Set the timer 1 value */ - /*************************/ - - outl(ul_TimerValue, devpriv->s_BoardInfos.ui_Address + 0 + (16 * b_TorCounter) + (64 * b_ModulNbr)); - - /*********************/ - /* Tor counter init. */ - /*********************/ - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_TorCounterModuleInfo. - s_TorCounterInfo - [b_TorCounter]. - b_TorCounterInit - = - 1; - } else { - /***********************************************/ - /* TOR version error for 40MHz clock selection */ - /***********************************************/ - - DPRINTK("TOR version error for 40MHz clock selection\n"); - i_ReturnValue - = - -9; - } - } else { - /**************************************************************/ - /* You can not used the 40MHz clock selection wich this board */ - /**************************************************************/ - - DPRINTK("You can not used the 40MHz clock selection wich this board\n"); - i_ReturnValue = - -8; - } - } else { - /**********************************/ - /* Base timing selection is wrong */ - /**********************************/ - - DPRINTK("Base timing selection is wrong\n"); - i_ReturnValue = -7; - } - } /* if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4)) */ - else { - /**********************************/ - /* Timing unit selection is wrong */ - /**********************************/ - - DPRINTK("Timing unit selection is wrong\n"); - i_ReturnValue = -6; - } /* if ((b_TimingUnit >= 0) && (b_TimingUnit <= 4)) */ - } /* if ((b_PCIInputClock == APCI1710_30MHZ) || (b_PCIInputClock == APCI1710_33MHZ)) */ - else { - /*****************************************/ - /* The selected PCI input clock is wrong */ - /*****************************************/ - - DPRINTK("The selected PCI input clock is wrong\n"); - i_ReturnValue = -5; - } /* if ((b_PCIInputClock == APCI1710_30MHZ) || (b_PCIInputClock == APCI1710_33MHZ)) */ - } /* if (b_TorCounterMode >= 0 && b_TorCounterMode <= 7) */ - else { - /**********************************/ - /* Tor Counter selection is wrong */ - /**********************************/ - - DPRINTK("Tor Counter selection is wrong\n"); - i_ReturnValue = -4; - } /* if (b_TorCounterMode >= 0 && b_TorCounterMode <= 7) */ - } else { - /******************************************/ - /* The module is not a tor counter module */ - /******************************************/ - - DPRINTK("The module is not a tor counter module\n"); - i_ReturnValue = -3; - } - } else { - /***********************/ - /* Module number error */ - /***********************/ - - DPRINTK("Module number error\n"); - i_ReturnValue = -2; - } - data[0] = (unsigned int) ul_RealTimingInterval; - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_EnableTorCounter | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char_ b_TorCounter, | -| unsigned char_ b_InputMode, | -| unsigned char_ b_ExternGate, | -| unsigned char_ b_CycleMode, | -| unsigned char_ b_InterruptEnable) | -+----------------------------------------------------------------------------+ -| Task : Enable the tor counter (b_TorCounter) from selected | -| module (b_ModulNbr). You must calling the | -| "i_APCI1710_InitTorCounter" function be for you call | -| this function. | -| If you enable the tor counter interrupt, the | -| tor counter generate a interrupt after the timing cycle| -| See function "i_APCI1710_SetBoardIntRoutineX" and the | -| Interrupt mask description chapter from this manual. | -| The b_CycleMode parameter determine if you will | -| measured a single or more cycle. | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr : Selected module number (0 to 3) | -| unsigned char_ b_TorCounter : Tor counter selection (0 or 1). | -| unsigned char_ b_InputMode : Input signal level selection | -| 0 : Tor count each low level | -| 1 : Tor count each high level| -| unsigned char_ b_ExternGate : Extern gate action selection | -| 0 : Extern gate signal not | -| used | -| 1 : Extern gate signal used. | -| If you selected the | -| single mode, each high | -| level signal start the | -| counter. | -| If you selected the | -| continuous mode, the | -| first high level signal | -| start the tor counter | -| | -| APCI1710_TOR_QUADRUPLE _MODE : | -| In the quadruple mode, the edge| -| analysis circuit generates a | -| counting pulse from each edge | -| of 2 signals which are phase | -| shifted in relation to each | -| other. | -| The gate input is used for the | -| signal B | -| | -| APCI1710_TOR_DOUBLE_MODE: | -| Functions in the same way as | -| the quadruple mode, except that| -| only two of the four edges are | -| analysed per period. | -| The gate input is used for the | -| signal B | -| | -| APCI1710_TOR_SIMPLE_MODE: | -| Functions in the same way as | -| the quadruple mode, except that| -| only one of the four edges is | -| analysed per period. | -| The gate input is used for the | -| signal B | -| | -| unsigned char_ b_CycleMode : Selected the tor counter | -| acquisition mode | -| unsigned char_ b_InterruptEnable : Enable or disable the | -| tor counter interrupt. | -| APCI1710_ENABLE: | -| Enable the tor counter | -| interrupt | -| APCI1710_DISABLE: | -| Disable the tor counter | -| interrupt | -+----------------------------------------------------------------------------+ -| Output Parameters : - | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: Module selection wrong | -| -3: The module is not a tor counter module | -| -4: Tor counter selection is wrong | -| -5: Tor counter not initialised see function | -| "i_APCI1710_InitTorCounter" | -| -6: Tor input signal selection is wrong | -| -7: Extern gate signal mode is wrong | -| -8: Tor counter acquisition mode cycle is wrong | -| -9: Interrupt parameter is wrong | -| -10:Interrupt function not initialised. | -| See function "i_APCI1710_SetBoardIntRoutineX" | -+----------------------------------------------------------------------------+ -*/ -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_DisableTorCounter | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char_ b_TorCounter) | -+----------------------------------------------------------------------------+ -| Task : Disable the tor counter (b_TorCounter) from selected | -| module (b_ModulNbr). If you disable the tor counter | -| after a start cycle occur and you restart the tor | -| counter witch the " i_APCI1710_EnableTorCounter" | -| function, the status register is cleared | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr : Selected module number (0 to 3) | -| unsigned char_ b_TorCounter : Tor counter selection (0 or 1). | -+----------------------------------------------------------------------------+ -| Output Parameters : - | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: Module selection wrong | -| -3: The module is not a tor counter module | -| -4: Tor counter selection is wrong | -| -5: Tor counter not initialised see function | -| "i_APCI1710_InitTorCounter" | -| -6: Tor counter not enabled see function | -| "i_APCI1710_EnableTorCounter" | -+----------------------------------------------------------------------------+ -*/ - -static int i_APCI1710_InsnWriteEnableDisableTorCounter(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - unsigned int dw_Status; - unsigned int dw_DummyRead; - unsigned int dw_ConfigReg; - unsigned char b_ModulNbr, b_Action; - unsigned char b_TorCounter; - unsigned char b_InputMode; - unsigned char b_ExternGate; - unsigned char b_CycleMode; - unsigned char b_InterruptEnable; - - b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec); - b_Action = (unsigned char) data[0]; /* enable or disable */ - b_TorCounter = (unsigned char) data[1]; - b_InputMode = (unsigned char) data[2]; - b_ExternGate = (unsigned char) data[3]; - b_CycleMode = (unsigned char) data[4]; - b_InterruptEnable = (unsigned char) data[5]; - i_ReturnValue = insn->n; - devpriv->tsk_Current = current; /* Save the current process task structure */ - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /***********************/ - /* Test if tor counter */ - /***********************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[b_ModulNbr] & - 0xFFFF0000UL) == APCI1710_TOR_COUNTER) { - /**********************************/ - /* Test the tor counter selection */ - /**********************************/ - - if (b_TorCounter <= 1) { - switch (b_Action) /* Enable or Disable */ - { - case APCI1710_ENABLE: - /***********************************/ - /* Test if tor counter initialised */ - /***********************************/ - - dw_Status = - inl(devpriv->s_BoardInfos. - ui_Address + 8 + - (16 * b_TorCounter) + - (64 * b_ModulNbr)); - - if (dw_Status & 0x10) { - /******************************/ - /* Test the input signal mode */ - /******************************/ - - if (b_InputMode == 0 || - b_InputMode == 1 || - b_InputMode == - APCI1710_TOR_SIMPLE_MODE - || b_InputMode == - APCI1710_TOR_DOUBLE_MODE - || b_InputMode == - APCI1710_TOR_QUADRUPLE_MODE) - { - /************************************/ - /* Test the extern gate signal mode */ - /************************************/ - - if (b_ExternGate == 0 - || b_ExternGate - == 1 - || b_InputMode > - 1) { - /*********************************/ - /* Test the cycle mode parameter */ - /*********************************/ - - if ((b_CycleMode == APCI1710_SINGLE) || (b_CycleMode == APCI1710_CONTINUOUS)) { - /***************************/ - /* Test the interrupt flag */ - /***************************/ - - if ((b_InterruptEnable == APCI1710_ENABLE) || (b_InterruptEnable == APCI1710_DISABLE)) { - - /***************************/ - /* Save the interrupt mode */ - /***************************/ - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_TorCounterModuleInfo. - s_TorCounterInfo - [b_TorCounter]. - b_InterruptEnable - = - b_InterruptEnable; - - /*******************/ - /* Get the command */ - /*******************/ - - dw_ConfigReg - = - inl - (devpriv-> - s_BoardInfos. - ui_Address - + - 4 - + - (16 * b_TorCounter) + (64 * b_ModulNbr)); - - dw_ConfigReg - = - (dw_ConfigReg - >> - 4) - & - 0x30; - - /********************************/ - /* Test if not direct mode used */ - /********************************/ - - if (b_InputMode > 1) { - /*******************************/ - /* Extern gate can not be used */ - /*******************************/ - - b_ExternGate - = - 0; - - /*******************************************/ - /* Enable the extern gate for the Signal B */ - /*******************************************/ - - dw_ConfigReg - = - dw_ConfigReg - | - 0x40; - - /***********************/ - /* Test if simple mode */ - /***********************/ - - if (b_InputMode == APCI1710_TOR_SIMPLE_MODE) { - /**************************/ - /* Enable the sinple mode */ - /**************************/ - - dw_ConfigReg - = - dw_ConfigReg - | - 0x780; - - } /* if (b_InputMode == APCI1710_TOR_SIMPLE_MODE) */ - - /***********************/ - /* Test if double mode */ - /***********************/ - - if (b_InputMode == APCI1710_TOR_DOUBLE_MODE) { - /**************************/ - /* Enable the double mode */ - /**************************/ - - dw_ConfigReg - = - dw_ConfigReg - | - 0x180; - - } /* if (b_InputMode == APCI1710_TOR_DOUBLE_MODE) */ - - b_InputMode - = - 0; - } /* if (b_InputMode > 1) */ - - /*******************/ - /* Set the command */ - /*******************/ - - dw_ConfigReg - = - dw_ConfigReg - | - b_CycleMode - | - (b_InterruptEnable - * - 2) - | - (b_InputMode - * - 4) - | - (b_ExternGate - * - 8); - - /*****************************/ - /* Clear the status register */ - /*****************************/ - - dw_DummyRead - = - inl - (devpriv-> - s_BoardInfos. - ui_Address - + - 0 - + - (16 * b_TorCounter) + (64 * b_ModulNbr)); - - /***************************************/ - /* Clear the interrupt status register */ - /***************************************/ - - dw_DummyRead - = - inl - (devpriv-> - s_BoardInfos. - ui_Address - + - 12 - + - (16 * b_TorCounter) + (64 * b_ModulNbr)); - - /********************/ - /* Set the commando */ - /********************/ - - outl(dw_ConfigReg, devpriv->s_BoardInfos.ui_Address + 4 + (16 * b_TorCounter) + (64 * b_ModulNbr)); - - /****************/ - /* Set the gate */ - /****************/ - - outl(1, devpriv->s_BoardInfos.ui_Address + 8 + (16 * b_TorCounter) + (64 * b_ModulNbr)); - - } /* if ((b_InterruptEnable == APCI1710_ENABLE) || (b_InterruptEnable == APCI1710_DISABLE)) */ - else { - /********************************/ - /* Interrupt parameter is wrong */ - /********************************/ - - DPRINTK("Interrupt parameter is wrong\n"); - i_ReturnValue - = - -9; - } /* if ((b_InterruptEnable == APCI1710_ENABLE) || (b_InterruptEnable == APCI1710_DISABLE)) */ - } /* if ((b_CycleMode == APCI1710_SINGLE) || (b_CycleMode == APCI1710_CONTINUOUS)) */ - else { - /***********************************************/ - /* Tor counter acquisition mode cycle is wrong */ - /***********************************************/ - - DPRINTK("Tor counter acquisition mode cycle is wrong\n"); - i_ReturnValue - = - -8; - } /* if ((b_CycleMode == APCI1710_SINGLE) || (b_CycleMode == APCI1710_CONTINUOUS)) */ - } /* if (b_ExternGate >= 0 && b_ExternGate <= 1) */ - else { - /***********************************/ - /* Extern gate input mode is wrong */ - /***********************************/ - - DPRINTK("Extern gate input mode is wrong\n"); - i_ReturnValue = - -7; - } /* if (b_ExternGate >= 0 && b_ExternGate <= 1) */ - } /* if (b_InputMode >= 0 && b_InputMode <= 1) */ - else { - /***************************************/ - /* Tor input signal selection is wrong */ - /***************************************/ - - DPRINTK("Tor input signal selection is wrong\n"); - i_ReturnValue = -6; - } - } else { - /*******************************/ - /* Tor counter not initialised */ - /*******************************/ - - DPRINTK("Tor counter not initialised\n"); - i_ReturnValue = -5; - } - break; - - case APCI1710_DISABLE: - /***********************************/ - /* Test if tor counter initialised */ - /***********************************/ - - dw_Status = inl(devpriv->s_BoardInfos. - ui_Address + 8 + - (16 * b_TorCounter) + - (64 * b_ModulNbr)); - - /*******************************/ - /* Test if counter initialised */ - /*******************************/ - - if (dw_Status & 0x10) { - /***************************/ - /* Test if counter enabled */ - /***************************/ - - if (dw_Status & 0x1) { - /****************************/ - /* Clear the interrupt mode */ - /****************************/ - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_TorCounterModuleInfo. - s_TorCounterInfo - [b_TorCounter]. - b_InterruptEnable - = - APCI1710_DISABLE; - - /******************/ - /* Clear the gate */ - /******************/ - - outl(0, devpriv-> - s_BoardInfos. - ui_Address + 8 + - (16 * b_TorCounter) + (64 * b_ModulNbr)); - } /* if (dw_Status & 0x1) */ - else { - /***************************/ - /* Tor counter not enabled */ - /***************************/ - - DPRINTK("Tor counter not enabled \n"); - i_ReturnValue = -6; - } /* if (dw_Status & 0x1) */ - } /* if (dw_Status & 0x10) */ - else { - /*******************************/ - /* Tor counter not initialised */ - /*******************************/ - - DPRINTK("Tor counter not initialised\n"); - i_ReturnValue = -5; - } /* // if (dw_Status & 0x10) */ - - } /* switch */ - } /* if (b_TorCounter <= 1) */ - else { - /**********************************/ - /* Tor counter selection is wrong */ - /**********************************/ - - DPRINTK("Tor counter selection is wrong\n"); - i_ReturnValue = -4; - } /* if (b_TorCounter <= 1) */ - } else { - /******************************************/ - /* The module is not a tor counter module */ - /******************************************/ - - DPRINTK("The module is not a tor counter module \n"); - i_ReturnValue = -3; - } - } else { - /***********************/ - /* Module number error */ - /***********************/ - - DPRINTK("Module number error \n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_GetTorCounterInitialisation | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char_ b_TorCounter, | -| unsigned char *_ pb_TimingUnit, | -| PULONG_ pul_TimingInterval, | -| unsigned char *_ pb_InputMode, | -| unsigned char *_ pb_ExternGate, | -| unsigned char *_ pb_CycleMode, | -| unsigned char *_ pb_Enable, | -| unsigned char *_ pb_InterruptEnable)| -+----------------------------------------------------------------------------+ -| Task : Enable the tor counter (b_TorCounter) from selected | -| module (b_ModulNbr). You must calling the | -| "i_APCI1710_InitTorCounter" function be for you call | -| this function. | -| If you enable the tor counter interrupt, the | -| tor counter generate a interrupt after the timing cycle| -| See function "i_APCI1710_SetBoardIntRoutineX" and the | -| Interrupt mask description chapter from this manual. | -| The b_CycleMode parameter determine if you will | -| measured a single or more cycle. | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr : Selected module number (0 to 3) | -| unsigned char_ b_TorCounter : Tor counter selection (0 or 1) - - b_ModulNbr = CR_AREF(insn->chanspec); - b_TorCounter = CR_CHAN(insn->chanspec); -. | -+----------------------------------------------------------------------------+ -| Output Parameters : unsigned char *_ pb_TimingUnit : Base timing unit (0 to 4) | -| 0 : ns | -| 1 : µs | -| 2 : ms | -| 3 : s | -| 4 : mn | -| PULONG_ pul_TimingInterval : Base timing value. | -| unsigned char *_ pb_InputMode : Input signal level | -| selection | -| 0 : Tor count each low level | -| 1 : Tor count each high level| -| unsigned char *_ pb_ExternGate : Extern gate action | -| selection | -| 0 : Extern gate signal not | -| used | -| 1 : Extern gate signal used| -| unsigned char *_ pb_CycleMode : Tor counter acquisition | -| mode | -| unsigned char *_ pb_Enable : Indicate if the tor counter| -| is enabled or no | -| 0 : Tor counter disabled | -| 1 : Tor counter enabled | -| unsigned char *_ pb_InterruptEnable : Enable or disable the | -| tor counter interrupt. | -| APCI1710_ENABLE: | -| Enable the tor counter | -| interrupt | -| APCI1710_DISABLE: | -| Disable the tor counter | -| interrupt - pb_TimingUnit = (unsigned char *) &data[0]; - pul_TimingInterval = (unsigned int *) &data[1]; - pb_InputMode = (unsigned char *) &data[2]; - pb_ExternGate = (unsigned char *) &data[3]; - pb_CycleMode = (unsigned char *) &data[4]; - pb_Enable = (unsigned char *) &data[5]; - pb_InterruptEnable = (unsigned char *) &data[6]; - | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: Module selection wrong | -| -3: The module is not a tor counter module | -| -4: Tor counter selection is wrong | -| -5: Tor counter not initialised see function | -| "i_APCI1710_InitTorCounter" | -+----------------------------------------------------------------------------+ -*/ - -static int i_APCI1710_InsnReadGetTorCounterInitialisation(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - unsigned int dw_Status; - unsigned char b_ModulNbr; - unsigned char b_TorCounter; - unsigned char *pb_TimingUnit; - unsigned int *pul_TimingInterval; - unsigned char *pb_InputMode; - unsigned char *pb_ExternGate; - unsigned char *pb_CycleMode; - unsigned char *pb_Enable; - unsigned char *pb_InterruptEnable; - - i_ReturnValue = insn->n; - b_ModulNbr = CR_AREF(insn->chanspec); - b_TorCounter = CR_CHAN(insn->chanspec); - - pb_TimingUnit = (unsigned char *) &data[0]; - pul_TimingInterval = (unsigned int *) &data[1]; - pb_InputMode = (unsigned char *) &data[2]; - pb_ExternGate = (unsigned char *) &data[3]; - pb_CycleMode = (unsigned char *) &data[4]; - pb_Enable = (unsigned char *) &data[5]; - pb_InterruptEnable = (unsigned char *) &data[6]; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /***********************/ - /* Test if tor counter */ - /***********************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[b_ModulNbr] & - 0xFFFF0000UL) == APCI1710_TOR_COUNTER) { - /**********************************/ - /* Test the tor counter selection */ - /**********************************/ - - if (b_TorCounter <= 1) { - - /***********************************/ - /* Test if tor counter initialised */ - /***********************************/ - - dw_Status = inl(devpriv->s_BoardInfos. - ui_Address + 8 + (16 * b_TorCounter) + - (64 * b_ModulNbr)); - - if (dw_Status & 0x10) { - *pb_Enable = dw_Status & 1; - - /********************/ - /* Get the commando */ - /********************/ - - dw_Status = inl(devpriv->s_BoardInfos. - ui_Address + 4 + - (16 * b_TorCounter) + - (64 * b_ModulNbr)); - - *pb_CycleMode = - (unsigned char) ((dw_Status >> 4) & 1); - *pb_InterruptEnable = - (unsigned char) ((dw_Status >> 5) & 1); - - /******************************************************/ - /* Test if extern gate used for clock or for signal B */ - /******************************************************/ - - if (dw_Status & 0x600) { - /*****************************************/ - /* Test if extern gate used for signal B */ - /*****************************************/ - - if (dw_Status & 0x400) { - /***********************/ - /* Test if simple mode */ - /***********************/ - - if ((dw_Status & 0x7800) - == 0x7800) { - *pb_InputMode = - APCI1710_TOR_SIMPLE_MODE; - } - - /***********************/ - /* Test if double mode */ - /***********************/ - - if ((dw_Status & 0x7800) - == 0x1800) { - *pb_InputMode = - APCI1710_TOR_DOUBLE_MODE; - } - - /**************************/ - /* Test if quadruple mode */ - /**************************/ - - if ((dw_Status & 0x7800) - == 0x0000) { - *pb_InputMode = - APCI1710_TOR_QUADRUPLE_MODE; - } - } /* if (dw_Status & 0x400) */ - else { - *pb_InputMode = 1; - } /* // if (dw_Status & 0x400) */ - - /************************/ - /* Extern gate not used */ - /************************/ - - *pb_ExternGate = 0; - } /* if (dw_Status & 0x600) */ - else { - *pb_InputMode = - (unsigned char) ((dw_Status >> 6) - & 1); - *pb_ExternGate = - (unsigned char) ((dw_Status >> 7) - & 1); - } /* if (dw_Status & 0x600) */ - - *pb_TimingUnit = - devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_TorCounterModuleInfo. - s_TorCounterInfo[b_TorCounter]. - b_TimingUnit; - - *pul_TimingInterval = - devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_TorCounterModuleInfo. - s_TorCounterInfo[b_TorCounter]. - ul_RealTimingInterval; - } else { - /*******************************/ - /* Tor counter not initialised */ - /*******************************/ - - DPRINTK("Tor counter not initialised\n"); - i_ReturnValue = -5; - } - - } /* if (b_TorCounter <= 1) */ - else { - /**********************************/ - /* Tor counter selection is wrong */ - /**********************************/ - - DPRINTK("Tor counter selection is wrong \n"); - i_ReturnValue = -4; - } /* if (b_TorCounter <= 1) */ - } else { - /******************************************/ - /* The module is not a tor counter module */ - /******************************************/ - - DPRINTK("The module is not a tor counter module\n"); - i_ReturnValue = -3; - } - } else { - /***********************/ - /* Module number error */ - /***********************/ - - DPRINTK("Module number error\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_ReadTorCounterValue | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char_ b_TorCounter, | -| unsigned int_ ui_TimeOut, | -| unsigned char *_ pb_TorCounterStatus, | -| PULONG_ pul_TorCounterValue) | -+----------------------------------------------------------------------------+ -| Task case APCI1710_TOR_GETPROGRESSSTATUS: Return the tor counter -(b_TorCounter) status (pb_TorCounterStatus) from selected tor counter | -| module (b_ModulNbr). - - case APCI1710_TOR_GETCOUNTERVALUE : - Return the tor counter (b_TorCounter) status | -| (pb_TorCounterStatus) and the timing value | -| (pul_TorCounterValue) after a conting cycle stop | -| from selected tor counter module (b_ModulNbr). | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr : Selected module number (0 to 3) | -| unsigned char_ b_TorCounter : Tor counter selection (0 or 1). - b_ModulNbr = CR_AREF(insn->chanspec); - b_ReadType = (unsigned char) data[0]; - b_TorCounter = (unsigned char) data[1]; - ui_TimeOut = (unsigned int) data[2]; | -+----------------------------------------------------------------------------+ -| Output Parameters : unsigned char *_ pb_TorCounterStatus : Return the tor counter | -| status. | -| 0 : Conting cycle not started| -| Software gate not set. | -| 1 : Conting cycle started. | -| Software gate set. | -| 2 : Conting cycle stopped. | -| The conting cycle is | -| terminate. | -| 3 : A overflow occur. You | -| must change the base | -| timing witch the | -| function | -| "i_APCI1710_InitTorCounter"| -| 4 : Timeeout occur | -| unsigned int * pul_TorCounterValue : Tor counter value. - pb_TorCounterStatus=(unsigned char *) &data[0]; - pul_TorCounterValue=(unsigned int *) &data[1]; | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: Module selection wrong | -| -3: The module is not a tor counter module | -| -4: Tor counter selection is wrong | -| -5: Tor counter not initialised see function | -| "i_APCI1710_InitTorCounter" | -| -6: Tor counter not enabled see function | -| "i_APCI1710_EnableTorCounter" | -| -7: Timeout parameter is wrong (0 to 65535) | -+----------------------------------------------------------------------------+ -*/ - -static int i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - unsigned int dw_Status; - unsigned int dw_TimeOut = 0; - unsigned char b_ModulNbr; - unsigned char b_TorCounter; - unsigned char b_ReadType; - unsigned int ui_TimeOut; - unsigned char *pb_TorCounterStatus; - unsigned int *pul_TorCounterValue; - - i_ReturnValue = insn->n; - b_ModulNbr = CR_AREF(insn->chanspec); - b_ReadType = (unsigned char) data[0]; - b_TorCounter = (unsigned char) data[1]; - ui_TimeOut = (unsigned int) data[2]; - pb_TorCounterStatus = (unsigned char *) &data[0]; - pul_TorCounterValue = (unsigned int *) &data[1]; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ReadType == APCI1710_TOR_READINTERRUPT) { - - data[0] = devpriv->s_InterruptParameters. - s_FIFOInterruptParameters[devpriv-> - s_InterruptParameters.ui_Read].b_OldModuleMask; - data[1] = devpriv->s_InterruptParameters. - s_FIFOInterruptParameters[devpriv-> - s_InterruptParameters.ui_Read].ul_OldInterruptMask; - data[2] = devpriv->s_InterruptParameters. - s_FIFOInterruptParameters[devpriv-> - s_InterruptParameters.ui_Read].ul_OldCounterLatchValue; - - /**************************/ - /* Increment the read FIFO */ - /***************************/ - - devpriv-> - s_InterruptParameters. - ui_Read = (devpriv-> - s_InterruptParameters. - ui_Read + 1) % APCI1710_SAVE_INTERRUPT; - - return insn->n; - } - - if (b_ModulNbr < 4) { - /***********************/ - /* Test if tor counter */ - /***********************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[b_ModulNbr] & - 0xFFFF0000UL) == APCI1710_TOR_COUNTER) { - /**********************************/ - /* Test the tor counter selection */ - /**********************************/ - - if (b_TorCounter <= 1) { - /***********************************/ - /* Test if tor counter initialised */ - /***********************************/ - - dw_Status = inl(devpriv->s_BoardInfos. - ui_Address + 8 + (16 * b_TorCounter) + - (64 * b_ModulNbr)); - - /*******************************/ - /* Test if counter initialised */ - /*******************************/ - - if (dw_Status & 0x10) { - /***************************/ - /* Test if counter enabled */ - /***************************/ - - if (dw_Status & 0x1) { - - switch (b_ReadType) { - - case APCI1710_TOR_GETPROGRESSSTATUS: - /*******************/ - /* Read the status */ - /*******************/ - - dw_Status = - inl(devpriv-> - s_BoardInfos. - ui_Address + 4 + - (16 * b_TorCounter) + (64 * b_ModulNbr)); - - dw_Status = - dw_Status & 0xF; - - /*****************/ - /* Test if start */ - /*****************/ - - if (dw_Status & 1) { - if (dw_Status & - 2) { - if (dw_Status & 4) { - /************************/ - /* Tor counter overflow */ - /************************/ - - *pb_TorCounterStatus - = - 3; - } else { - /***********************/ - /* Tor counter started */ - /***********************/ - - *pb_TorCounterStatus - = - 2; - } - } else { - /***********************/ - /* Tor counter started */ - /***********************/ - - *pb_TorCounterStatus - = - 1; - } - } else { - /***************************/ - /* Tor counter not started */ - /***************************/ - - *pb_TorCounterStatus - = 0; - } - break; - - case APCI1710_TOR_GETCOUNTERVALUE: - - /*****************************/ - /* Test the timout parameter */ - /*****************************/ - - if ((ui_TimeOut >= 0) - && (ui_TimeOut - <= - 65535UL)) - { - for (;;) { - /*******************/ - /* Read the status */ - /*******************/ - - dw_Status - = - inl - (devpriv-> - s_BoardInfos. - ui_Address - + - 4 - + - (16 * b_TorCounter) + (64 * b_ModulNbr)); - /********************/ - /* Test if overflow */ - /********************/ - - if ((dw_Status & 4) == 4) { - /******************/ - /* Overflow occur */ - /******************/ - - *pb_TorCounterStatus - = - 3; - - /******************/ - /* Read the value */ - /******************/ - - *pul_TorCounterValue - = - inl - (devpriv-> - s_BoardInfos. - ui_Address - + - 0 - + - (16 * b_TorCounter) + (64 * b_ModulNbr)); - break; - } /* if ((dw_Status & 4) == 4) */ - else { - /*******************************/ - /* Test if measurement stopped */ - /*******************************/ - - if ((dw_Status & 2) == 2) { - /***********************/ - /* A stop signal occur */ - /***********************/ - - *pb_TorCounterStatus - = - 2; - - /******************/ - /* Read the value */ - /******************/ - - *pul_TorCounterValue - = - inl - (devpriv-> - s_BoardInfos. - ui_Address - + - 0 - + - (16 * b_TorCounter) + (64 * b_ModulNbr)); - - break; - } /* if ((dw_Status & 2) == 2) */ - else { - /*******************************/ - /* Test if measurement started */ - /*******************************/ - - if ((dw_Status & 1) == 1) { - /************************/ - /* A start signal occur */ - /************************/ - - *pb_TorCounterStatus - = - 1; - } /* if ((dw_Status & 1) == 1) */ - else { - /***************************/ - /* Measurement not started */ - /***************************/ - - *pb_TorCounterStatus - = - 0; - } /* if ((dw_Status & 1) == 1) */ - } /* if ((dw_Status & 2) == 2) */ - } /* if ((dw_Status & 8) == 8) */ - - if (dw_TimeOut == ui_TimeOut) { - /*****************/ - /* Timeout occur */ - /*****************/ - - break; - } else { - /*************************/ - /* Increment the timeout */ - /*************************/ - - dw_TimeOut - = - dw_TimeOut - + - 1; - - mdelay(1000); - } - } /* for (;;) */ - - /*************************/ - /* Test if timeout occur */ - /*************************/ - - if ((*pb_TorCounterStatus != 3) && (dw_TimeOut == ui_TimeOut) && (ui_TimeOut != 0)) { - /*****************/ - /* Timeout occur */ - /*****************/ - - *pb_TorCounterStatus - = - 4; - } - } else { - /******************************/ - /* Timeout parameter is wrong */ - /******************************/ - - DPRINTK("Timeout parameter is wrong\n"); - i_ReturnValue = - -7; - } - break; - - default: - printk("Inputs wrong\n"); - } /* switch end */ - } /* if (dw_Status & 0x1) */ - else { - /***************************/ - /* Tor counter not enabled */ - /***************************/ - - DPRINTK("Tor counter not enabled\n"); - i_ReturnValue = -6; - } /* if (dw_Status & 0x1) */ - } else { - /*******************************/ - /* Tor counter not initialised */ - /*******************************/ - - DPRINTK("Tor counter not initialised\n"); - i_ReturnValue = -5; - } - } /* if (b_TorCounter <= 1) */ - else { - /**********************************/ - /* Tor counter selection is wrong */ - /**********************************/ - - DPRINTK("Tor counter selection is wrong\n"); - i_ReturnValue = -4; - } /* if (b_TorCounter <= 1) */ - } else { - /******************************************/ - /* The module is not a tor counter module */ - /******************************************/ - - DPRINTK("The module is not a tor counter module\n"); - i_ReturnValue = -3; - } - } else { - /***********************/ - /* Module number error */ - /***********************/ - - DPRINTK("Module number error\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} diff --git a/drivers/staging/comedi/drivers/addi-data/APCI1710_Ttl.c b/drivers/staging/comedi/drivers/addi-data/APCI1710_Ttl.c deleted file mode 100644 index c01497a8a457c..0000000000000 --- a/drivers/staging/comedi/drivers/addi-data/APCI1710_Ttl.c +++ /dev/null @@ -1,1044 +0,0 @@ -/** -@verbatim - -Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. - - ADDI-DATA GmbH - Dieselstrasse 3 - D-77833 Ottersweier - Tel: +19(0)7223/9493-0 - Fax: +49(0)7223/9493-92 - http://www.addi-data.com - info@addi-data.com - -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 the License, or (at your option) any later version. - -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. - -@endverbatim -*/ -/* - - +-----------------------------------------------------------------------+ - | (C) ADDI-DATA GmbH Dieselstraße 3 D-77833 Ottersweier | - +-----------------------------------------------------------------------+ - | Tel : +49 (0) 7223/9493-0 | email : info@addi-data.com | - | Fax : +49 (0) 7223/9493-92 | Internet : http://www.addi-data.com | - +-----------------------------------------------------------------------+ - | Project : API APCI1710 | Compiler : gcc | - | Module name : TTL.C | Version : 2.96 | - +-------------------------------+---------------------------------------+ - | Project manager: Eric Stolz | Date : 02/12/2002 | - +-----------------------------------------------------------------------+ - | Description : APCI-1710 TTL I/O module | - | | - | | - +-----------------------------------------------------------------------+ - | UPDATES | - +-----------------------------------------------------------------------+ - | Date | Author | Description of updates | - +----------+-----------+------------------------------------------------+ - | 13/05/98 | S. Weber | TTL digital input / output implementation | - |----------|-----------|------------------------------------------------| - | 08/05/00 | Guinot C | - 0400/0228 All Function in RING 0 | - | | | available | - +-----------------------------------------------------------------------+ - | | | | - | | | | - +-----------------------------------------------------------------------+ -*/ - -#define APCI1710_TTL_INIT 0 -#define APCI1710_TTL_INITDIRECTION 1 - -#define APCI1710_TTL_READCHANNEL 0 -#define APCI1710_TTL_READPORT 1 - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_InitTTLIODirection | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char_ b_PortAMode, | -| unsigned char_ b_PortBMode, | -| unsigned char_ b_PortCMode, | -| unsigned char_ b_PortDMode) | -+----------------------------------------------------------------------------+ -| Task APCI1710_TTL_INIT (using defaults) : Configure the TTL I/O operating mode from selected | -| module (b_ModulNbr). You must calling this function be| -| for you call any other function witch access of TTL. | - APCI1710_TTL_INITDIRECTION(user inputs for direction) - -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710| -| unsigned char_ b_ModulNbr : Module number to | -| configure (0 to 3) - b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec); - b_InitType = (unsigned char) data[0]; - b_PortAMode = (unsigned char) data[1]; - b_PortBMode = (unsigned char) data[2]; - b_PortCMode = (unsigned char) data[3]; - b_PortDMode = (unsigned char) data[4];| -+----------------------------------------------------------------------------+ -| Output Parameters : - | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: The module parameter is wrong | -| -3: The module is not a TTL module | -| -4: Function not available for this version | -| -5: Port A mode selection is wrong | -| -6: Port B mode selection is wrong | -| -7: Port C mode selection is wrong | -| -8: Port D mode selection is wrong | -+----------------------------------------------------------------------------+ -*/ - -static int i_APCI1710_InsnConfigInitTTLIO(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - unsigned char b_ModulNbr; - unsigned char b_InitType; - unsigned char b_PortAMode; - unsigned char b_PortBMode; - unsigned char b_PortCMode; - unsigned char b_PortDMode; - - b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec); - b_InitType = (unsigned char) data[0]; - i_ReturnValue = insn->n; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /**************************/ - /* Test if TTL I/O module */ - /**************************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[b_ModulNbr] & - 0xFFFF0000UL) == APCI1710_TTL_IO) { - switch (b_InitType) { - case APCI1710_TTL_INIT: - - devpriv->s_ModuleInfo[b_ModulNbr]. - s_TTLIOInfo.b_TTLInit = 1; - - /***************************/ - /* Set TTL port A to input */ - /***************************/ - - devpriv->s_ModuleInfo[b_ModulNbr]. - s_TTLIOInfo.b_PortConfiguration[0] = 0; - - /***************************/ - /* Set TTL port B to input */ - /***************************/ - - devpriv->s_ModuleInfo[b_ModulNbr]. - s_TTLIOInfo.b_PortConfiguration[1] = 0; - - /***************************/ - /* Set TTL port C to input */ - /***************************/ - - devpriv->s_ModuleInfo[b_ModulNbr]. - s_TTLIOInfo.b_PortConfiguration[2] = 0; - - /****************************/ - /* Set TTL port D to output */ - /****************************/ - - devpriv->s_ModuleInfo[b_ModulNbr]. - s_TTLIOInfo.b_PortConfiguration[3] = 1; - - /*************************/ - /* Set the configuration */ - /*************************/ - - outl(0x8, - devpriv->s_BoardInfos.ui_Address + 20 + - (64 * b_ModulNbr)); - break; - - case APCI1710_TTL_INITDIRECTION: - - b_PortAMode = (unsigned char) data[1]; - b_PortBMode = (unsigned char) data[2]; - b_PortCMode = (unsigned char) data[3]; - b_PortDMode = (unsigned char) data[4]; - - /********************/ - /* Test the version */ - /********************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration - [b_ModulNbr] & 0xFFFF) >= - 0x3230) { - /************************/ - /* Test the port A mode */ - /************************/ - - if ((b_PortAMode == 0) - || (b_PortAMode == 1)) { - /************************/ - /* Test the port B mode */ - /************************/ - - if ((b_PortBMode == 0) - || (b_PortBMode == 1)) { - /************************/ - /* Test the port C mode */ - /************************/ - - if ((b_PortCMode == 0) - || (b_PortCMode - == 1)) { - /************************/ - /* Test the port D mode */ - /************************/ - - if ((b_PortDMode == 0) || (b_PortDMode == 1)) { - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_TTLIOInfo. - b_TTLInit - = - 1; - - /***********************/ - /* Set TTL port A mode */ - /***********************/ - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_TTLIOInfo. - b_PortConfiguration - [0] - = - b_PortAMode; - - /***********************/ - /* Set TTL port B mode */ - /***********************/ - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_TTLIOInfo. - b_PortConfiguration - [1] - = - b_PortBMode; - - /***********************/ - /* Set TTL port C mode */ - /***********************/ - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_TTLIOInfo. - b_PortConfiguration - [2] - = - b_PortCMode; - - /***********************/ - /* Set TTL port D mode */ - /***********************/ - - devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_TTLIOInfo. - b_PortConfiguration - [3] - = - b_PortDMode; - - /*************************/ - /* Set the configuration */ - /*************************/ - - outl((b_PortAMode << 0) | (b_PortBMode << 1) | (b_PortCMode << 2) | (b_PortDMode << 3), devpriv->s_BoardInfos.ui_Address + 20 + (64 * b_ModulNbr)); - } else { - /**********************************/ - /* Port D mode selection is wrong */ - /**********************************/ - - DPRINTK("Port D mode selection is wrong\n"); - i_ReturnValue - = - -8; - } - } else { - /**********************************/ - /* Port C mode selection is wrong */ - /**********************************/ - - DPRINTK("Port C mode selection is wrong\n"); - i_ReturnValue = - -7; - } - } else { - /**********************************/ - /* Port B mode selection is wrong */ - /**********************************/ - - DPRINTK("Port B mode selection is wrong\n"); - i_ReturnValue = -6; - } - } else { - /**********************************/ - /* Port A mode selection is wrong */ - /**********************************/ - - DPRINTK("Port A mode selection is wrong\n"); - i_ReturnValue = -5; - } - } else { - /*******************************************/ - /* Function not available for this version */ - /*******************************************/ - - DPRINTK("Function not available for this version\n"); - i_ReturnValue = -4; - } - break; - - DPRINTK("\n"); - default: - printk("Bad Config Type\n"); - } /* switch end */ - } else { - /**********************************/ - /* The module is not a TTL module */ - /**********************************/ - - DPRINTK("The module is not a TTL module\n"); - i_ReturnValue = -3; - } - } else { - /***********************/ - /* Module number error */ - /***********************/ - - DPRINTK("Module number error\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| INPUT FUNCTIONS | -+----------------------------------------------------------------------------+ -*/ - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_ReadTTLIOChannelValue | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char_ b_SelectedPort, | -| unsigned char_ b_InputChannel, | -| unsigned char *_ pb_ChannelStatus) | -+----------------------------------------------------------------------------+ -| Task : Read the status from selected TTL digital input | -| (b_InputChannel) -+----------------------------------------------------------------------------+ -| Task : Read the status from digital input port | -| (b_SelectedPort) from selected TTL module (b_ModulNbr) | -+----------------------------------------------------------------------------+ - -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710| -| unsigned char_ b_ModulNbr : Module number to | -| configure (0 to 7) | -| unsigned char_ b_SelectedPort, : Selection from TTL I/O | -| port (0 to 2) | -| 0 : Port A selection | -| 1 : Port B selection | -| 2 : Port C selection | -| 3 : Port D selection | -| unsigned char_ b_InputChannel : Selection from digital | -| input ( 0 to 2) -APCI1710_TTL_READCHANNEL - b_ModulNbr = CR_AREF(insn->chanspec); - b_SelectedPort= CR_RANGE(insn->chanspec); - b_InputChannel= CR_CHAN(insn->chanspec); - b_ReadType = (unsigned char) data[0]; - - APCI1710_TTL_READPORT| - b_ModulNbr = CR_AREF(insn->chanspec); - b_SelectedPort= CR_RANGE(insn->chanspec); - b_ReadType = (unsigned char) data[0]; - -+----------------------------------------------------------------------------+ -| Output Parameters : data[0] - - unsigned char *_ pb_ChannelStatus : Digital input channel | -| status | -| 0 : Channle is not active| -| 1 : Channle is active | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: The module parameter is wrong | -| -3: The module is not a TTL module | -| -4: The selected TTL input port is wrong | -| -5: The selected TTL digital input is wrong | -| -6: TTL I/O not initialised | -+----------------------------------------------------------------------------+ -*/ - -static int i_APCI1710_InsnBitsReadTTLIO(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - unsigned int dw_StatusReg; - unsigned char b_ModulNbr; - unsigned char b_SelectedPort; - unsigned char b_InputChannel; - unsigned char b_ReadType; - unsigned char *pb_ChannelStatus; - unsigned char *pb_PortValue; - - i_ReturnValue = insn->n; - b_ReadType = (unsigned char) data[0]; - b_ModulNbr = CR_AREF(insn->chanspec); - b_SelectedPort = CR_RANGE(insn->chanspec); - b_InputChannel = CR_CHAN(insn->chanspec); - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /**************************/ - /* Test if TTL I/O module */ - /**************************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[b_ModulNbr] & - 0xFFFF0000UL) == APCI1710_TTL_IO) { - switch (b_ReadType) { - - case APCI1710_TTL_READCHANNEL: - pb_ChannelStatus = (unsigned char *) &data[0]; - /********************************/ - /* Test the TTL I/O port number */ - /********************************/ - - if (((b_SelectedPort <= 2) - && ((devpriv->s_BoardInfos. - dw_MolduleConfiguration - [b_ModulNbr] & - 0xFFFF) == - 0x3130)) - || ((b_SelectedPort <= 3) - && ((devpriv->s_BoardInfos. - dw_MolduleConfiguration - [b_ModulNbr] & - 0xFFFF) >= - 0x3230))) { - /******************************************/ - /* Test the digital imnput channel number */ - /******************************************/ - - if (((b_InputChannel <= 7) - && (b_SelectedPort < 3)) - || ((b_InputChannel <= 1) - && (b_SelectedPort == - 3))) { - /******************************************/ - /* Test if the TTL I/O module initialised */ - /******************************************/ - - if (devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_TTLIOInfo.b_TTLInit == - 1) { - /***********************************/ - /* Test if TTL port used for input */ - /***********************************/ - - if (((devpriv->s_BoardInfos.dw_MolduleConfiguration[b_ModulNbr] & 0xFFFF) == 0x3130) || (((devpriv->s_BoardInfos.dw_MolduleConfiguration[b_ModulNbr] & 0xFFFF) >= 0x3230) && (devpriv->s_ModuleInfo[b_ModulNbr].s_TTLIOInfo.b_PortConfiguration[b_SelectedPort] == 0))) { - /**************************/ - /* Read all digital input */ - /**************************/ - - dw_StatusReg = - inl - (devpriv-> - s_BoardInfos. - ui_Address - + - (64 * b_ModulNbr)); - - *pb_ChannelStatus - = - (unsigned char) ( - (dw_StatusReg - >> - (8 * b_SelectedPort)) >> b_InputChannel) & 1; - } else { - /*******************************/ - /* Selected TTL I/O port error */ - /*******************************/ - - DPRINTK("Selected TTL I/O port error\n"); - i_ReturnValue = - -4; - } - } else { - /***************************/ - /* TTL I/O not initialised */ - /***************************/ - - DPRINTK("TTL I/O not initialised\n"); - i_ReturnValue = -6; - } - } else { - /********************************/ - /* Selected digital input error */ - /********************************/ - - DPRINTK("Selected digital input error\n"); - i_ReturnValue = -5; - } - } else { - /*******************************/ - /* Selected TTL I/O port error */ - /*******************************/ - - DPRINTK("Selected TTL I/O port error\n"); - i_ReturnValue = -4; - } - break; - - case APCI1710_TTL_READPORT: - pb_PortValue = (unsigned char *) &data[0]; - /********************************/ - /* Test the TTL I/O port number */ - /********************************/ - - if (((b_SelectedPort <= 2) - && ((devpriv->s_BoardInfos. - dw_MolduleConfiguration - [b_ModulNbr] & - 0xFFFF) == - 0x3130)) - || ((b_SelectedPort <= 3) - && ((devpriv->s_BoardInfos. - dw_MolduleConfiguration - [b_ModulNbr] & - 0xFFFF) >= - 0x3230))) { - /******************************************/ - /* Test if the TTL I/O module initialised */ - /******************************************/ - - if (devpriv->s_ModuleInfo[b_ModulNbr]. - s_TTLIOInfo.b_TTLInit == 1) { - /***********************************/ - /* Test if TTL port used for input */ - /***********************************/ - - if (((devpriv->s_BoardInfos. - dw_MolduleConfiguration - [b_ModulNbr] - & - 0xFFFF) - == 0x3130) - || (((devpriv->s_BoardInfos.dw_MolduleConfiguration[b_ModulNbr] & 0xFFFF) >= 0x3230) && (devpriv->s_ModuleInfo[b_ModulNbr].s_TTLIOInfo.b_PortConfiguration[b_SelectedPort] == 0))) { - /**************************/ - /* Read all digital input */ - /**************************/ - - dw_StatusReg = - inl(devpriv-> - s_BoardInfos. - ui_Address + - (64 * b_ModulNbr)); - - *pb_PortValue = - (unsigned char) ( - (dw_StatusReg >> - (8 * b_SelectedPort)) & 0xFF); - } else { - /*******************************/ - /* Selected TTL I/O port error */ - /*******************************/ - - DPRINTK("Selected TTL I/O port error\n"); - i_ReturnValue = -4; - } - } else { - /***************************/ - /* TTL I/O not initialised */ - /***************************/ - - DPRINTK("TTL I/O not initialised\n"); - i_ReturnValue = -5; - } - } else { - /*******************************/ - /* Selected TTL I/O port error */ - /*******************************/ - - DPRINTK("Selected TTL I/O port error\n"); - i_ReturnValue = -4; - } - break; - - default: - printk("Bad ReadType\n"); - - } /* End Switch */ - } else { - /**********************************/ - /* The module is not a TTL module */ - /**********************************/ - - DPRINTK("The module is not a TTL module\n"); - i_ReturnValue = -3; - } - } else { - /***********************/ - /* Module number error */ - /***********************/ - - DPRINTK("Module number error\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| Function Name : int i_APCI1710_InsnReadTTLIOAllPortValue(comedi_device -*dev,struct comedi_subdevice *s,struct comedi_insn *insn,unsigned int *data) | -+----------------------------------------------------------------------------+ -| Task : Read the status from all digital input ports | -| (port A, port B and port C) from selected TTL | -| module (b_ModulNbr) | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710| -| unsigned char_ b_ModulNbr : Module number to | -| configure (0 to 3) | -+----------------------------------------------------------------------------+ -| Output Parameters : PULONG_ pul_PortValue : Digital TTL inputs port | -| status | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: The module parameter is wrong | -| -3: The module is not a TTL module | -| -4: TTL I/O not initialised | -+----------------------------------------------------------------------------+ -*/ - -static int i_APCI1710_InsnReadTTLIOAllPortValue(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - unsigned int dw_StatusReg; - unsigned char b_ModulNbr; - unsigned int *pul_PortValue; - - b_ModulNbr = (unsigned char) CR_AREF(insn->chanspec); - i_ReturnValue = insn->n; - pul_PortValue = (unsigned int *) &data[0]; - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /**************************/ - /* Test if TTL I/O module */ - /**************************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[b_ModulNbr] & - 0xFFFF0000UL) == APCI1710_TTL_IO) { - /******************************************/ - /* Test if the TTL I/O module initialised */ - /******************************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_TTLIOInfo.b_TTLInit == 1) { - /**************************/ - /* Read all digital input */ - /**************************/ - - dw_StatusReg = inl(devpriv->s_BoardInfos. - ui_Address + (64 * b_ModulNbr)); - - /**********************/ - /* Test if TTL Rev1.0 */ - /**********************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration - [b_ModulNbr] & 0xFFFF) == - 0x3130) { - *pul_PortValue = - dw_StatusReg & 0xFFFFFFUL; - } else { - /**************************************/ - /* Test if port A not used for output */ - /**************************************/ - - if (devpriv->s_ModuleInfo[b_ModulNbr]. - s_TTLIOInfo. - b_PortConfiguration[0] == 1) { - *pul_PortValue = - dw_StatusReg & - 0x3FFFF00UL; - } - - /**************************************/ - /* Test if port B not used for output */ - /**************************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_TTLIOInfo. - b_PortConfiguration[1] == 1) { - *pul_PortValue = - dw_StatusReg & - 0x3FF00FFUL; - } - - /**************************************/ - /* Test if port C not used for output */ - /**************************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_TTLIOInfo. - b_PortConfiguration[2] == 1) { - *pul_PortValue = - dw_StatusReg & - 0x300FFFFUL; - } - - /**************************************/ - /* Test if port D not used for output */ - /**************************************/ - - if (devpriv-> - s_ModuleInfo[b_ModulNbr]. - s_TTLIOInfo. - b_PortConfiguration[3] == 1) { - *pul_PortValue = - dw_StatusReg & - 0xFFFFFFUL; - } - } - } else { - /***************************/ - /* TTL I/O not initialised */ - /***************************/ - DPRINTK("TTL I/O not initialised\n"); - i_ReturnValue = -5; - } - } else { - /**********************************/ - /* The module is not a TTL module */ - /**********************************/ - DPRINTK("The module is not a TTL module\n"); - i_ReturnValue = -3; - } - } else { - /***********************/ - /* Module number error */ - /***********************/ - DPRINTK("Module number error\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} - -/* -+----------------------------------------------------------------------------+ -| OUTPUT FUNCTIONS | -+----------------------------------------------------------------------------+ -*/ - -/* -+----------------------------------------------------------------------------+ -| Function Name : _INT_ i_APCI1710_SetTTLIOChlOn | -| (unsigned char_ b_BoardHandle, | -| unsigned char_ b_ModulNbr, | -| unsigned char_ b_OutputChannel) -int i_APCI1710_InsnWriteSetTTLIOChlOnOff(struct comedi_device *dev,struct comedi_subdevice *s, - struct comedi_insn *insn,unsigned int *data) | -+----------------------------------------------------------------------------+ -| Task : Sets or resets the output witch has been passed with the | -| parameter b_Channel. Setting an output means setting | -| an ouput high. | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char_ b_BoardHandle : Handle of board APCI-1710 | -| unsigned char_ b_ModulNbr : Selected module number (0 to 3)| -| unsigned char_ b_OutputChannel : Selection from digital output | -| channel (0 or 1) | -| 0 : PD0 | -| 1 : PD1 | -| 2 to 9 : PA | -| 10 to 17: PB | -| 18 to 25: PC | - - b_ModulNbr = CR_AREF(insn->chanspec); - b_OutputChannel= CR_CHAN(insn->chanspec); - ui_State = data[0]; ON or OFF -+----------------------------------------------------------------------------+ -| Output Parameters : - | -+----------------------------------------------------------------------------+ -| Return Value : 0: No error | -| -1: The handle parameter of the board is wrong | -| -2: The module parameter is wrong | -| -3: The module is not a TTL I/O module | -| -4: The selected digital output is wrong | -| -5: TTL I/O not initialised see function | -| " i_APCI1710_InitTTLIO" -+----------------------------------------------------------------------------+ -*/ - -static int i_APCI1710_InsnWriteSetTTLIOChlOnOff(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct addi_private *devpriv = dev->private; - int i_ReturnValue = 0; - unsigned int dw_StatusReg = 0; - unsigned char b_ModulNbr; - unsigned char b_OutputChannel; - unsigned int ui_State; - - i_ReturnValue = insn->n; - b_ModulNbr = CR_AREF(insn->chanspec); - b_OutputChannel = CR_CHAN(insn->chanspec); - ui_State = data[0]; /* ON or OFF */ - - /**************************/ - /* Test the module number */ - /**************************/ - - if (b_ModulNbr < 4) { - /**************************/ - /* Test if TTL I/O module */ - /**************************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[b_ModulNbr] & - 0xFFFF0000UL) == APCI1710_TTL_IO) { - /******************************************/ - /* Test if the TTL I/O module initialised */ - /******************************************/ - - if (devpriv->s_ModuleInfo[b_ModulNbr]. - s_TTLIOInfo.b_TTLInit == 1) { - /***********************************/ - /* Test the TTL I/O channel number */ - /***********************************/ - - if (((b_OutputChannel <= 1) - && ((devpriv->s_BoardInfos. - dw_MolduleConfiguration - [b_ModulNbr] & - 0xFFFF) == - 0x3130)) - || ((b_OutputChannel <= 25) - && ((devpriv->s_BoardInfos. - dw_MolduleConfiguration - [b_ModulNbr] & - 0xFFFF) >= - 0x3230))) { - /****************************************************/ - /* Test if the selected channel is a output channel */ - /****************************************************/ - - if (((b_OutputChannel <= 1) - && (devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_TTLIOInfo. - b_PortConfiguration - [3] == 1)) - || ((b_OutputChannel >= 2) - && (b_OutputChannel <= - 9) - && (devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_TTLIOInfo. - b_PortConfiguration - [0] == 1)) - || ((b_OutputChannel >= 10) - && (b_OutputChannel <= - 17) - && (devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_TTLIOInfo. - b_PortConfiguration - [1] == 1)) - || ((b_OutputChannel >= 18) - && (b_OutputChannel <= - 25) - && (devpriv-> - s_ModuleInfo - [b_ModulNbr]. - s_TTLIOInfo. - b_PortConfiguration - [2] == 1))) { - /************************/ - /* Test if PD0 selected */ - /************************/ - - if (b_OutputChannel == 0) { - - outl(ui_State, - devpriv-> - s_BoardInfos. - ui_Address + - (64 * b_ModulNbr)); - } else { - /************************/ - /* Test if PD1 selected */ - /************************/ - - if (b_OutputChannel == - 1) { - - outl(ui_State, - devpriv-> - s_BoardInfos. - ui_Address - + 4 + - (64 * b_ModulNbr)); - } else { - b_OutputChannel - = - b_OutputChannel - - 2; - - /********************/ - /* Read all channel */ - /********************/ - - dw_StatusReg = - inl - (devpriv-> - s_BoardInfos. - ui_Address - + - (64 * b_ModulNbr)); - if (ui_State) /* ON */ - { - dw_StatusReg - = - (dw_StatusReg - >> - ((b_OutputChannel / 8) * 8)) & 0xFF; - dw_StatusReg - = - dw_StatusReg - | - (1 - << - (b_OutputChannel - % - 8)); - } else /* Off */ - { - dw_StatusReg - = - (dw_StatusReg - >> - ((b_OutputChannel / 8) * 8)) & 0xFF; - dw_StatusReg - = - dw_StatusReg - & - (0xFF - - - (1 << (b_OutputChannel % 8))); - - } - - /****************************/ - /* Set the new output value */ - /****************************/ - - outl(dw_StatusReg, devpriv->s_BoardInfos.ui_Address + 8 + ((b_OutputChannel / 8) * 4) + (64 * b_ModulNbr)); - } - } - } else { - /************************************/ - /* The selected TTL output is wrong */ - /************************************/ - - DPRINTK(" The selected TTL output is wrong\n"); - i_ReturnValue = -4; - } - } else { - /************************************/ - /* The selected TTL output is wrong */ - /************************************/ - - DPRINTK("The selected TTL output is wrong\n"); - i_ReturnValue = -4; - } - } else { - /***************************/ - /* TTL I/O not initialised */ - /***************************/ - - DPRINTK("TTL I/O not initialised\n"); - i_ReturnValue = -5; - } - } else { - /**************************************/ - /* The module is not a TTL I/O module */ - /**************************************/ - - DPRINTK("The module is not a TTL I/O module\n"); - i_ReturnValue = -3; - } - } else { - /***********************/ - /* Module number error */ - /***********************/ - - DPRINTK("Module number error\n"); - i_ReturnValue = -2; - } - - return i_ReturnValue; -} diff --git a/drivers/staging/comedi/drivers/addi-data/hwdrv_APCI1710.c b/drivers/staging/comedi/drivers/addi-data/hwdrv_APCI1710.c deleted file mode 100644 index b1a7ec1035e11..0000000000000 --- a/drivers/staging/comedi/drivers/addi-data/hwdrv_APCI1710.c +++ /dev/null @@ -1,1314 +0,0 @@ -/** -@verbatim - -Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module. - - ADDI-DATA GmbH - Dieselstrasse 3 - D-77833 Ottersweier - Tel: +19(0)7223/9493-0 - Fax: +49(0)7223/9493-92 - http://www.addi-data.com - info@addi-data.com - -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 the License, or (at your option) any later version. - -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. - -@endverbatim -*/ -/* - +-----------------------------------------------------------------------+ - | (C) ADDI-DATA GmbH Dieselstraße 3 D-77833 Ottersweier | - +-----------------------------------------------------------------------+ - | Tel : +49 (0) 7223/9493-0 | email : info@addi-data.com | - | Fax : +49 (0) 7223/9493-92 | Internet : http://www.addi-data.com | - +-------------------------------+---------------------------------------+ - | Project : APCI-1710 | Compiler : GCC | - | Module name : hwdrv_apci1710.c| Version : 2.96 | - +-------------------------------+---------------------------------------+ - | Project manager: Eric Stolz | Date : 02/12/2002 | - +-------------------------------+---------------------------------------+ - | Description : Hardware Layer Access For APCI-1710 | - +-----------------------------------------------------------------------+ - | UPDATES | - +----------+-----------+------------------------------------------------+ - | Date | Author | Description of updates | - +----------+-----------+------------------------------------------------+ - | | | | - | | | | - | | | | - +----------+-----------+------------------------------------------------+ -*/ - -#define COMEDI_SUBD_TTLIO 11 /* Digital Input Output But TTL */ -#define COMEDI_SUBD_PWM 12 /* Pulse width Measurement */ -#define COMEDI_SUBD_SSI 13 /* Synchronous serial interface */ -#define COMEDI_SUBD_TOR 14 /* Tor counter */ -#define COMEDI_SUBD_CHRONO 15 /* Chrono meter */ -#define COMEDI_SUBD_PULSEENCODER 16 /* Pulse Encoder INP CPT */ -#define COMEDI_SUBD_INCREMENTALCOUNTER 17 /* Incremental Counter */ - -#define APCI1710_BOARD_NAME "apci1710" -#define APCI1710_BOARD_DEVICE_ID 0x818F -#define APCI1710_ADDRESS_RANGE 256 -#define APCI1710_CONFIG_ADDRESS_RANGE 8 -#define APCI1710_INCREMENTAL_COUNTER 0x53430000UL -#define APCI1710_SSI_COUNTER 0x53490000UL -#define APCI1710_TTL_IO 0x544C0000UL -#define APCI1710_DIGITAL_IO 0x44490000UL -#define APCI1710_82X54_TIMER 0x49430000UL -#define APCI1710_CHRONOMETER 0x43480000UL -#define APCI1710_PULSE_ENCODER 0x495A0000UL -#define APCI1710_TOR_COUNTER 0x544F0000UL -#define APCI1710_PWM 0x50570000UL -#define APCI1710_ETM 0x45540000UL -#define APCI1710_CDA 0x43440000UL -#define APCI1710_DISABLE 0 -#define APCI1710_ENABLE 1 -#define APCI1710_SYNCHRONOUS_MODE 1 -#define APCI1710_ASYNCHRONOUS_MODE 0 - -#include "APCI1710_Inp_cpt.c" - -#include "APCI1710_Ssi.c" -#include "APCI1710_Tor.c" -#include "APCI1710_Ttl.c" -#include "APCI1710_Dig_io.c" -#include "APCI1710_82x54.c" -#include "APCI1710_Chrono.c" -#include "APCI1710_Pwm.c" -#include "APCI1710_INCCPT.c" - -static const struct comedi_lrange range_apci1710_ttl = { - 4, { - BIP_RANGE(10), - BIP_RANGE(5), - BIP_RANGE(2), - BIP_RANGE(1) - } -}; - -static const struct comedi_lrange range_apci1710_ssi = { - 4, { - BIP_RANGE(10), - BIP_RANGE(5), - BIP_RANGE(2), - BIP_RANGE(1) - } -}; - -static const struct comedi_lrange range_apci1710_inccpt = { - 4, { - BIP_RANGE(10), - BIP_RANGE(5), - BIP_RANGE(2), - BIP_RANGE(1) - } -}; - -static void i_ADDI_AttachPCI1710(struct comedi_device *dev) -{ - struct comedi_subdevice *s; - int ret = 0; - int n_subdevices = 9; - - ret = comedi_alloc_subdevices(dev, n_subdevices); - if (ret) - return; - - /* Allocate and Initialise Timer Subdevice Structures */ - s = &dev->subdevices[0]; - - s->type = COMEDI_SUBD_TIMER; - s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; - s->n_chan = 3; - s->maxdata = 0; - s->len_chanlist = 3; - s->range_table = &range_digital; - s->insn_write = i_APCI1710_InsnWriteEnableDisableTimer; - s->insn_read = i_APCI1710_InsnReadAllTimerValue; - s->insn_config = i_APCI1710_InsnConfigInitTimer; - s->insn_bits = i_APCI1710_InsnBitsTimer; - - /* Allocate and Initialise DIO Subdevice Structures */ - s = &dev->subdevices[1]; - - s->type = COMEDI_SUBD_DIO; - s->subdev_flags = - SDF_WRITEABLE | SDF_READABLE | SDF_GROUND | SDF_COMMON; - s->n_chan = 7; - s->maxdata = 1; - s->len_chanlist = 7; - s->range_table = &range_digital; - s->insn_config = i_APCI1710_InsnConfigDigitalIO; - s->insn_read = i_APCI1710_InsnReadDigitalIOChlValue; - s->insn_bits = i_APCI1710_InsnBitsDigitalIOPortOnOff; - s->insn_write = i_APCI1710_InsnWriteDigitalIOChlOnOff; - - /* Allocate and Initialise Chrono Subdevice Structures */ - s = &dev->subdevices[2]; - - s->type = COMEDI_SUBD_CHRONO; - s->subdev_flags = SDF_WRITEABLE | SDF_GROUND | SDF_COMMON; - s->n_chan = 4; - s->maxdata = 0; - s->len_chanlist = 4; - s->range_table = &range_digital; - s->insn_write = i_APCI1710_InsnWriteEnableDisableChrono; - s->insn_read = i_APCI1710_InsnReadChrono; - s->insn_config = i_APCI1710_InsnConfigInitChrono; - s->insn_bits = i_APCI1710_InsnBitsChronoDigitalIO; - - /* Allocate and Initialise PWM Subdevice Structures */ - s = &dev->subdevices[3]; - s->type = COMEDI_SUBD_PWM; - s->subdev_flags = - SDF_WRITEABLE | SDF_READABLE | SDF_GROUND | SDF_COMMON; - s->n_chan = 3; - s->maxdata = 1; - s->len_chanlist = 3; - s->range_table = &range_digital; - s->io_bits = 0; /* all bits input */ - s->insn_config = i_APCI1710_InsnConfigPWM; - s->insn_read = i_APCI1710_InsnReadGetPWMStatus; - s->insn_write = i_APCI1710_InsnWritePWM; - s->insn_bits = i_APCI1710_InsnBitsReadPWMInterrupt; - - /* Allocate and Initialise TTLIO Subdevice Structures */ - s = &dev->subdevices[4]; - s->type = COMEDI_SUBD_TTLIO; - s->subdev_flags = - SDF_WRITEABLE | SDF_READABLE | SDF_GROUND | SDF_COMMON; - s->n_chan = 8; - s->maxdata = 1; - s->len_chanlist = 8; - s->range_table = &range_apci1710_ttl; /* to pass arguments in range */ - s->insn_config = i_APCI1710_InsnConfigInitTTLIO; - s->insn_bits = i_APCI1710_InsnBitsReadTTLIO; - s->insn_write = i_APCI1710_InsnWriteSetTTLIOChlOnOff; - s->insn_read = i_APCI1710_InsnReadTTLIOAllPortValue; - - /* Allocate and Initialise TOR Subdevice Structures */ - s = &dev->subdevices[5]; - s->type = COMEDI_SUBD_TOR; - s->subdev_flags = - SDF_WRITEABLE | SDF_READABLE | SDF_GROUND | SDF_COMMON; - s->n_chan = 8; - s->maxdata = 1; - s->len_chanlist = 8; - s->range_table = &range_digital; - s->io_bits = 0; /* all bits input */ - s->insn_config = i_APCI1710_InsnConfigInitTorCounter; - s->insn_read = i_APCI1710_InsnReadGetTorCounterInitialisation; - s->insn_write = i_APCI1710_InsnWriteEnableDisableTorCounter; - s->insn_bits = i_APCI1710_InsnBitsGetTorCounterProgressStatusAndValue; - - /* Allocate and Initialise SSI Subdevice Structures */ - s = &dev->subdevices[6]; - s->type = COMEDI_SUBD_SSI; - s->subdev_flags = - SDF_WRITEABLE | SDF_READABLE | SDF_GROUND | SDF_COMMON; - s->n_chan = 4; - s->maxdata = 1; - s->len_chanlist = 4; - s->range_table = &range_apci1710_ssi; - s->insn_config = i_APCI1710_InsnConfigInitSSI; - s->insn_read = i_APCI1710_InsnReadSSIValue; - s->insn_bits = i_APCI1710_InsnBitsSSIDigitalIO; - - /* Allocate and Initialise PULSEENCODER Subdevice Structures */ - s = &dev->subdevices[7]; - s->type = COMEDI_SUBD_PULSEENCODER; - s->subdev_flags = - SDF_WRITEABLE | SDF_READABLE | SDF_GROUND | SDF_COMMON; - s->n_chan = 4; - s->maxdata = 1; - s->len_chanlist = 4; - s->range_table = &range_digital; - s->insn_config = i_APCI1710_InsnConfigInitPulseEncoder; - s->insn_write = i_APCI1710_InsnWriteEnableDisablePulseEncoder; - s->insn_bits = i_APCI1710_InsnBitsReadWritePulseEncoder; - s->insn_read = i_APCI1710_InsnReadInterruptPulseEncoder; - - /* Allocate and Initialise INCREMENTALCOUNTER Subdevice Structures */ - s = &dev->subdevices[8]; - s->type = COMEDI_SUBD_INCREMENTALCOUNTER; - s->subdev_flags = - SDF_WRITEABLE | SDF_READABLE | SDF_GROUND | SDF_COMMON; - s->n_chan = 500; - s->maxdata = 1; - s->len_chanlist = 500; - s->range_table = &range_apci1710_inccpt; - s->insn_config = i_APCI1710_InsnConfigINCCPT; - s->insn_write = i_APCI1710_InsnWriteINCCPT; - s->insn_read = i_APCI1710_InsnReadINCCPT; - s->insn_bits = i_APCI1710_InsnBitsINCCPT; -} - -static int i_APCI1710_Reset(struct comedi_device *dev) -{ - struct addi_private *devpriv = dev->private; - int ret; - unsigned int dw_Dummy; - - /*********************************/ - /* Read all module configuration */ - /*********************************/ - ret = inl(devpriv->s_BoardInfos.ui_Address + 60); - devpriv->s_BoardInfos.dw_MolduleConfiguration[0] = ret; - - ret = inl(devpriv->s_BoardInfos.ui_Address + 124); - devpriv->s_BoardInfos.dw_MolduleConfiguration[1] = ret; - - ret = inl(devpriv->s_BoardInfos.ui_Address + 188); - devpriv->s_BoardInfos.dw_MolduleConfiguration[2] = ret; - - ret = inl(devpriv->s_BoardInfos.ui_Address + 252); - devpriv->s_BoardInfos.dw_MolduleConfiguration[3] = ret; - - /* outl(0x80808082,devpriv->s_BoardInfos.ui_Address+0x60); */ - outl(0x83838383, devpriv->s_BoardInfos.ui_Address + 0x60); - - devpriv->s_BoardInfos.b_BoardVersion = 1; - - /* Enable the interrupt for the controller */ - dw_Dummy = inl(devpriv->s_BoardInfos.ui_Address + 0x38); - outl(dw_Dummy | 0x2000, devpriv->s_BoardInfos.ui_Address + 0x38); - - return 0; -} - -/* -+----------------------------------------------------------------------------+ -| Function's Name : __void__ v_APCI1710_InterruptFunction | -| (unsigned char b_Interrupt, __CPPARGS) | -+----------------------------------------------------------------------------+ -| Task : APCI-1710 interrupt function | -+----------------------------------------------------------------------------+ -| Input Parameters : unsigned char b_Interrupt : Interrupt number | -+----------------------------------------------------------------------------+ -| Output Parameters : - | -+----------------------------------------------------------------------------+ -| Return Value : 0 : OK | -| -1 : Error | -+----------------------------------------------------------------------------+ -*/ - -static void v_APCI1710_Interrupt(int irq, void *d) -{ - struct comedi_device *dev = d; - struct addi_private *devpriv = dev->private; - unsigned char b_ModuleCpt = 0; - unsigned char b_InterruptFlag = 0; - unsigned char b_PWMCpt = 0; - unsigned char b_TorCounterCpt = 0; - unsigned char b_PulseIncoderCpt = 0; - unsigned int ui_16BitValue; - unsigned int ul_InterruptLatchReg = 0; - unsigned int ul_LatchRegisterValue = 0; - unsigned int ul_82X54InterruptStatus; - unsigned int ul_StatusRegister; - - union str_ModuleInfo *ps_ModuleInfo; - - printk("APCI1710 Interrupt\n"); - for (b_ModuleCpt = 0; b_ModuleCpt < 4; b_ModuleCpt++, ps_ModuleInfo++) { - - /**************************/ - /* 1199/0225 to 0100/0226 */ - /**************************/ - ps_ModuleInfo = &devpriv->s_ModuleInfo[b_ModuleCpt]; - - /***********************/ - /* Test if 82X54 timer */ - /***********************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[b_ModuleCpt] & - 0xFFFF0000UL) == APCI1710_82X54_TIMER) { - - /* printk("TIMER Interrupt Occurred\n"); */ - ul_82X54InterruptStatus = inl(devpriv->s_BoardInfos. - ui_Address + 12 + (64 * b_ModuleCpt)); - - /***************************/ - /* Test if interrupt occur */ - /***************************/ - - if ((ul_82X54InterruptStatus & ps_ModuleInfo-> - s_82X54ModuleInfo. - b_InterruptMask) != 0) { - devpriv-> - s_InterruptParameters. - s_FIFOInterruptParameters[devpriv-> - s_InterruptParameters. - ui_Write]. - ul_OldInterruptMask = - (ul_82X54InterruptStatus & - ps_ModuleInfo->s_82X54ModuleInfo. - b_InterruptMask) << 4; - - devpriv-> - s_InterruptParameters. - s_FIFOInterruptParameters[devpriv-> - s_InterruptParameters. - ui_Write]. - b_OldModuleMask = 1 << b_ModuleCpt; - - devpriv-> - s_InterruptParameters. - s_FIFOInterruptParameters[devpriv-> - s_InterruptParameters. - ui_Write].ul_OldCounterLatchValue = 0; - - devpriv-> - s_InterruptParameters. - ul_InterruptOccur++; - - /****************************/ - /* Increment the write FIFO */ - /****************************/ - - devpriv-> - s_InterruptParameters. - ui_Write = (devpriv-> - s_InterruptParameters. - ui_Write + 1) % APCI1710_SAVE_INTERRUPT; - - b_InterruptFlag = 1; - - /**********************/ - /* Call user function */ - /**********************/ - /* Send a signal to from kernel to user space */ - send_sig(SIGIO, devpriv->tsk_Current, 0); - - } /* if ((ul_82X54InterruptStatus & 0x7) != 0) */ - } /* 82X54 timer */ - - /***************************/ - /* Test if increm. counter */ - /***************************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[b_ModuleCpt] & - 0xFFFF0000UL) == APCI1710_INCREMENTAL_COUNTER) { - - ul_InterruptLatchReg = inl(devpriv->s_BoardInfos. - ui_Address + (64 * b_ModuleCpt)); - - /*********************/ - /* Test if interrupt */ - /*********************/ - - if ((ul_InterruptLatchReg & 0x22) && (ps_ModuleInfo-> - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister2 & 0x80)) { - /************************************/ - /* Test if strobe latch I interrupt */ - /************************************/ - - if (ul_InterruptLatchReg & 2) { - ul_LatchRegisterValue = - inl(devpriv->s_BoardInfos. - ui_Address + 4 + - (64 * b_ModuleCpt)); - - devpriv-> - s_InterruptParameters. - s_FIFOInterruptParameters - [devpriv->s_InterruptParameters. - ui_Write].ul_OldInterruptMask = - 1UL; - - devpriv-> - s_InterruptParameters. - s_FIFOInterruptParameters - [devpriv->s_InterruptParameters. - ui_Write].b_OldModuleMask = - 1 << b_ModuleCpt; - - devpriv-> - s_InterruptParameters. - s_FIFOInterruptParameters - [devpriv->s_InterruptParameters. - ui_Write]. - ul_OldCounterLatchValue = - ul_LatchRegisterValue; - - devpriv-> - s_InterruptParameters. - ul_InterruptOccur++; - - /****************************/ - /* 0899/0224 to 1199/0225 */ - /****************************/ - /* Increment the write FIFO */ - /****************************/ - - devpriv-> - s_InterruptParameters. - ui_Write = (devpriv-> - s_InterruptParameters. - ui_Write + - 1) % APCI1710_SAVE_INTERRUPT; - - b_InterruptFlag = 1; - - /**********************/ - /* Call user function */ - /**********************/ - /* Send a signal to from kernel to user space */ - send_sig(SIGIO, devpriv->tsk_Current, - 0); - - } - - /*************************************/ - /* Test if strobe latch II interrupt */ - /*************************************/ - - if (ul_InterruptLatchReg & 0x20) { - - ul_LatchRegisterValue = - inl(devpriv->s_BoardInfos. - ui_Address + 8 + - (64 * b_ModuleCpt)); - - devpriv-> - s_InterruptParameters. - s_FIFOInterruptParameters - [devpriv->s_InterruptParameters. - ui_Write].ul_OldInterruptMask = - 2UL; - - devpriv-> - s_InterruptParameters. - s_FIFOInterruptParameters - [devpriv->s_InterruptParameters. - ui_Write].b_OldModuleMask = - 1 << b_ModuleCpt; - - devpriv-> - s_InterruptParameters. - s_FIFOInterruptParameters - [devpriv->s_InterruptParameters. - ui_Write]. - ul_OldCounterLatchValue = - ul_LatchRegisterValue; - - devpriv-> - s_InterruptParameters. - ul_InterruptOccur++; - - /****************************/ - /* 0899/0224 to 1199/0225 */ - /****************************/ - /* Increment the write FIFO */ - /****************************/ - - devpriv-> - s_InterruptParameters. - ui_Write = (devpriv-> - s_InterruptParameters. - ui_Write + - 1) % APCI1710_SAVE_INTERRUPT; - - b_InterruptFlag = 1; - - /**********************/ - /* Call user function */ - /**********************/ - /* Send a signal to from kernel to user space */ - send_sig(SIGIO, devpriv->tsk_Current, - 0); - - } - } - - ul_InterruptLatchReg = inl(devpriv->s_BoardInfos. - ui_Address + 24 + (64 * b_ModuleCpt)); - - /***************************/ - /* Test if index interrupt */ - /***************************/ - - if (ul_InterruptLatchReg & 0x8) { - ps_ModuleInfo-> - s_SiemensCounterInfo. - s_InitFlag.b_IndexInterruptOccur = 1; - - if (ps_ModuleInfo-> - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister2 & - APCI1710_INDEX_AUTO_MODE) { - - outl(ps_ModuleInfo-> - s_SiemensCounterInfo. - s_ModeRegister. - dw_ModeRegister1_2_3_4, - devpriv->s_BoardInfos. - ui_Address + 20 + - (64 * b_ModuleCpt)); - } - - /*****************************/ - /* Test if interrupt enabled */ - /*****************************/ - - if ((ps_ModuleInfo-> - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister3 & - APCI1710_ENABLE_INDEX_INT) == - APCI1710_ENABLE_INDEX_INT) { - devpriv->s_InterruptParameters. - s_FIFOInterruptParameters - [devpriv->s_InterruptParameters. - ui_Write].ul_OldInterruptMask = - 4UL; - - devpriv-> - s_InterruptParameters. - s_FIFOInterruptParameters - [devpriv->s_InterruptParameters. - ui_Write].b_OldModuleMask = - 1 << b_ModuleCpt; - - devpriv-> - s_InterruptParameters. - s_FIFOInterruptParameters - [devpriv->s_InterruptParameters. - ui_Write]. - ul_OldCounterLatchValue = - ul_LatchRegisterValue; - - devpriv-> - s_InterruptParameters. - ul_InterruptOccur++; - - /****************************/ - /* 0899/0224 to 1199/0225 */ - /****************************/ - /* Increment the write FIFO */ - /****************************/ - - devpriv-> - s_InterruptParameters. - ui_Write = (devpriv-> - s_InterruptParameters. - ui_Write + - 1) % APCI1710_SAVE_INTERRUPT; - - b_InterruptFlag = 1; - - /**********************/ - /* Call user function */ - /**********************/ - /* Send a signal to from kernel to user space */ - send_sig(SIGIO, devpriv->tsk_Current, - 0); - - } - } - - /*****************************/ - /* Test if compare interrupt */ - /*****************************/ - - if (ul_InterruptLatchReg & 0x10) { - /*****************************/ - /* Test if interrupt enabled */ - /*****************************/ - - if ((ps_ModuleInfo-> - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister3 & - APCI1710_ENABLE_COMPARE_INT) == - APCI1710_ENABLE_COMPARE_INT) { - devpriv->s_InterruptParameters. - s_FIFOInterruptParameters - [devpriv->s_InterruptParameters. - ui_Write].ul_OldInterruptMask = - 8UL; - - devpriv-> - s_InterruptParameters. - s_FIFOInterruptParameters - [devpriv->s_InterruptParameters. - ui_Write].b_OldModuleMask = - 1 << b_ModuleCpt; - - devpriv-> - s_InterruptParameters. - s_FIFOInterruptParameters - [devpriv->s_InterruptParameters. - ui_Write]. - ul_OldCounterLatchValue = - ul_LatchRegisterValue; - - devpriv-> - s_InterruptParameters. - ul_InterruptOccur++; - - /****************************/ - /* 0899/0224 to 1199/0225 */ - /****************************/ - /* Increment the write FIFO */ - /****************************/ - - devpriv-> - s_InterruptParameters. - ui_Write = (devpriv-> - s_InterruptParameters. - ui_Write + - 1) % APCI1710_SAVE_INTERRUPT; - - b_InterruptFlag = 1; - - /**********************/ - /* Call user function */ - /**********************/ - /* Send a signal to from kernel to user space */ - send_sig(SIGIO, devpriv->tsk_Current, - 0); - - } - } - - /*******************************************/ - /* Test if frequency measurement interrupt */ - /*******************************************/ - - if (ul_InterruptLatchReg & 0x20) { - /*******************/ - /* Read the status */ - /*******************/ - - ul_StatusRegister = inl(devpriv->s_BoardInfos. - ui_Address + 32 + (64 * b_ModuleCpt)); - - /******************/ - /* Read the value */ - /******************/ - - ul_LatchRegisterValue = - inl(devpriv->s_BoardInfos.ui_Address + - 28 + (64 * b_ModuleCpt)); - - switch ((ul_StatusRegister >> 1) & 3) { - case 0: - /*************************/ - /* Test the counter mode */ - /*************************/ - - if ((devpriv->s_ModuleInfo[b_ModuleCpt]. - s_SiemensCounterInfo. - s_ModeRegister. - s_ByteModeRegister. - b_ModeRegister1 & - APCI1710_16BIT_COUNTER) - == APCI1710_16BIT_COUNTER) { - /****************************************/ - /* Test if 16-bit counter 1 pulse occur */ - /****************************************/ - - if ((ul_LatchRegisterValue & - 0xFFFFU) != 0) { - ui_16BitValue = - (unsigned int) - ul_LatchRegisterValue - & 0xFFFFU; - ul_LatchRegisterValue = - (ul_LatchRegisterValue - & 0xFFFF0000UL) - | (0xFFFFU - - ui_16BitValue); - } - - /****************************************/ - /* Test if 16-bit counter 2 pulse occur */ - /****************************************/ - - if ((ul_LatchRegisterValue & - 0xFFFF0000UL) != - 0) { - ui_16BitValue = - (unsigned int) ( - (ul_LatchRegisterValue - >> 16) & - 0xFFFFU); - ul_LatchRegisterValue = - (ul_LatchRegisterValue - & 0xFFFFUL) | - ((0xFFFFU - - ui_16BitValue) - << 16); - } - } else { - if (ul_LatchRegisterValue != 0) { - ul_LatchRegisterValue = - 0xFFFFFFFFUL - - ul_LatchRegisterValue; - } - } - break; - - case 1: - /****************************************/ - /* Test if 16-bit counter 2 pulse occur */ - /****************************************/ - - if ((ul_LatchRegisterValue & - 0xFFFF0000UL) != 0) { - ui_16BitValue = - (unsigned int) ( - (ul_LatchRegisterValue - >> 16) & - 0xFFFFU); - ul_LatchRegisterValue = - (ul_LatchRegisterValue & - 0xFFFFUL) | ((0xFFFFU - - ui_16BitValue) - << 16); - } - break; - - case 2: - /****************************************/ - /* Test if 16-bit counter 1 pulse occur */ - /****************************************/ - - if ((ul_LatchRegisterValue & 0xFFFFU) != - 0) { - ui_16BitValue = - (unsigned int) - ul_LatchRegisterValue & - 0xFFFFU; - ul_LatchRegisterValue = - (ul_LatchRegisterValue & - 0xFFFF0000UL) | (0xFFFFU - - ui_16BitValue); - } - break; - } - - devpriv-> - s_InterruptParameters. - s_FIFOInterruptParameters[devpriv-> - s_InterruptParameters. - ui_Write]. - ul_OldInterruptMask = 0x10000UL; - - devpriv-> - s_InterruptParameters. - s_FIFOInterruptParameters[devpriv-> - s_InterruptParameters. - ui_Write]. - b_OldModuleMask = 1 << b_ModuleCpt; - - devpriv-> - s_InterruptParameters. - s_FIFOInterruptParameters[devpriv-> - s_InterruptParameters. - ui_Write]. - ul_OldCounterLatchValue = - ul_LatchRegisterValue; - - devpriv-> - s_InterruptParameters. - ul_InterruptOccur++; - - /****************************/ - /* 0899/0224 to 1199/0225 */ - /****************************/ - /* Increment the write FIFO */ - /****************************/ - - devpriv-> - s_InterruptParameters. - ui_Write = (devpriv-> - s_InterruptParameters. - ui_Write + 1) % APCI1710_SAVE_INTERRUPT; - - b_InterruptFlag = 1; - - /**********************/ - /* Call user function */ - /**********************/ - /* Send a signal to from kernel to user space */ - send_sig(SIGIO, devpriv->tsk_Current, 0); - - } - } /* Incremental counter */ - - /***************/ - /* Test if CDA */ - /***************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[b_ModuleCpt] & - 0xFFFF0000UL) == APCI1710_CDA) { - /******************************************/ - /* Test if CDA enable and functionality 0 */ - /******************************************/ - - if ((devpriv->s_ModuleInfo[b_ModuleCpt]. - s_CDAModuleInfo. - b_CDAEnable == APCI1710_ENABLE) - && (devpriv->s_ModuleInfo[b_ModuleCpt]. - s_CDAModuleInfo.b_FctSelection == 0)) { - /****************************/ - /* Get the interrupt status */ - /****************************/ - - ul_StatusRegister = inl(devpriv->s_BoardInfos. - ui_Address + 16 + (64 * b_ModuleCpt)); - /***************************/ - /* Test if interrupt occur */ - /***************************/ - - if (ul_StatusRegister & 1) { - devpriv-> - s_InterruptParameters. - s_FIFOInterruptParameters - [devpriv->s_InterruptParameters. - ui_Write].ul_OldInterruptMask = - 0x80000UL; - - devpriv-> - s_InterruptParameters. - s_FIFOInterruptParameters - [devpriv->s_InterruptParameters. - ui_Write].b_OldModuleMask = - 1 << b_ModuleCpt; - - devpriv-> - s_InterruptParameters. - s_FIFOInterruptParameters - [devpriv->s_InterruptParameters. - ui_Write]. - ul_OldCounterLatchValue = 0; - - devpriv-> - s_InterruptParameters. - ul_InterruptOccur++; - - /****************************/ - /* Increment the write FIFO */ - /****************************/ - - devpriv-> - s_InterruptParameters. - ui_Write = (devpriv-> - s_InterruptParameters. - ui_Write + - 1) % APCI1710_SAVE_INTERRUPT; - - b_InterruptFlag = 1; - - /**********************/ - /* Call user function */ - /**********************/ - - /* Send a signal to from kernel to user space */ - send_sig(SIGIO, devpriv->tsk_Current, - 0); - - } /* if (ul_StatusRegister & 1) */ - - } - } /* CDA */ - - /***********************/ - /* Test if PWM counter */ - /***********************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[b_ModuleCpt] & - 0xFFFF0000UL) == APCI1710_PWM) { - for (b_PWMCpt = 0; b_PWMCpt < 2; b_PWMCpt++) { - /*************************************/ - /* Test if PWM interrupt initialised */ - /*************************************/ - - if (devpriv-> - s_ModuleInfo[b_ModuleCpt]. - s_PWMModuleInfo. - s_PWMInfo[b_PWMCpt]. - b_InterruptEnable == APCI1710_ENABLE) { - /*****************************/ - /* Read the interrupt status */ - /*****************************/ - - ul_StatusRegister = - inl(devpriv->s_BoardInfos. - ui_Address + 16 + - (20 * b_PWMCpt) + - (64 * b_ModuleCpt)); - - /***************************/ - /* Test if interrupt occur */ - /***************************/ - - if (ul_StatusRegister & 0x1) { - devpriv-> - s_InterruptParameters. - s_FIFOInterruptParameters - [devpriv-> - s_InterruptParameters. - ui_Write]. - ul_OldInterruptMask = - 0x4000UL << b_PWMCpt; - - devpriv-> - s_InterruptParameters. - s_FIFOInterruptParameters - [devpriv-> - s_InterruptParameters. - ui_Write]. - b_OldModuleMask = - 1 << b_ModuleCpt; - - devpriv-> - s_InterruptParameters. - ul_InterruptOccur++; - - /****************************/ - /* Increment the write FIFO */ - /****************************/ - - devpriv-> - s_InterruptParameters. - ui_Write = (devpriv-> - s_InterruptParameters. - ui_Write + - 1) % - APCI1710_SAVE_INTERRUPT; - - b_InterruptFlag = 1; - - /**********************/ - /* Call user function */ - /**********************/ - /* Send a signal to from kernel to user space */ - send_sig(SIGIO, - devpriv->tsk_Current, - 0); - - } /* if (ul_StatusRegister & 0x1) */ - } /* if (APCI1710_ENABLE) */ - } /* for (b_PWMCpt == 0; b_PWMCpt < 0; b_PWMCpt ++) */ - } /* PWM counter */ - - /***********************/ - /* Test if tor counter */ - /***********************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[b_ModuleCpt] & - 0xFFFF0000UL) == APCI1710_TOR_COUNTER) { - for (b_TorCounterCpt = 0; b_TorCounterCpt < 2; - b_TorCounterCpt++) { - /*************************************/ - /* Test if tor interrupt initialised */ - /*************************************/ - - if (devpriv-> - s_ModuleInfo[b_ModuleCpt]. - s_TorCounterModuleInfo. - s_TorCounterInfo[b_TorCounterCpt]. - b_InterruptEnable == APCI1710_ENABLE) { - /*****************************/ - /* Read the interrupt status */ - /*****************************/ - - ul_StatusRegister = - inl(devpriv->s_BoardInfos. - ui_Address + 12 + - (16 * b_TorCounterCpt) + - (64 * b_ModuleCpt)); - - /***************************/ - /* Test if interrupt occur */ - /***************************/ - - if (ul_StatusRegister & 0x1) { - /******************************/ - /* Read the tor counter value */ - /******************************/ - - ul_LatchRegisterValue = - inl(devpriv-> - s_BoardInfos. - ui_Address + 0 + - (16 * b_TorCounterCpt) + - (64 * b_ModuleCpt)); - - devpriv-> - s_InterruptParameters. - s_FIFOInterruptParameters - [devpriv-> - s_InterruptParameters. - ui_Write]. - ul_OldInterruptMask = - 0x1000UL << - b_TorCounterCpt; - - devpriv-> - s_InterruptParameters. - s_FIFOInterruptParameters - [devpriv-> - s_InterruptParameters. - ui_Write]. - b_OldModuleMask = - 1 << b_ModuleCpt; - - devpriv-> - s_InterruptParameters. - s_FIFOInterruptParameters - [devpriv-> - s_InterruptParameters. - ui_Write]. - ul_OldCounterLatchValue - = ul_LatchRegisterValue; - - devpriv-> - s_InterruptParameters. - ul_InterruptOccur++; - - /****************************/ - /* Increment the write FIFO */ - /****************************/ - - devpriv-> - s_InterruptParameters. - ui_Write = (devpriv-> - s_InterruptParameters. - ui_Write + - 1) % - APCI1710_SAVE_INTERRUPT; - - b_InterruptFlag = 1; - - /**********************/ - /* Call user function */ - /**********************/ - - /* Send a signal to from kernel to user space */ - send_sig(SIGIO, - devpriv->tsk_Current, - 0); - } /* if (ul_StatusRegister & 0x1) */ - } /* if (APCI1710_ENABLE) */ - } /* for (b_TorCounterCpt == 0; b_TorCounterCpt < 0; b_TorCounterCpt ++) */ - } /* Tor counter */ - - /***********************/ - /* Test if chronometer */ - /***********************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[b_ModuleCpt] & - 0xFFFF0000UL) == APCI1710_CHRONOMETER) { - - /* printk("APCI1710 Chrono Interrupt\n"); */ - /*****************************/ - /* Read the interrupt status */ - /*****************************/ - - ul_InterruptLatchReg = inl(devpriv->s_BoardInfos. - ui_Address + 12 + (64 * b_ModuleCpt)); - - /***************************/ - /* Test if interrupt occur */ - /***************************/ - - if ((ul_InterruptLatchReg & 0x8) == 0x8) { - /****************************/ - /* Clear the interrupt flag */ - /****************************/ - - outl(0, devpriv->s_BoardInfos. - ui_Address + 32 + (64 * b_ModuleCpt)); - - /***************************/ - /* Test if continuous mode */ - /***************************/ - - if (ps_ModuleInfo-> - s_ChronoModuleInfo. - b_CycleMode == APCI1710_ENABLE) { - /********************/ - /* Clear the status */ - /********************/ - - outl(0, devpriv->s_BoardInfos. - ui_Address + 36 + - (64 * b_ModuleCpt)); - } - - /*************************/ - /* Read the timing value */ - /*************************/ - - ul_LatchRegisterValue = - inl(devpriv->s_BoardInfos.ui_Address + - 4 + (64 * b_ModuleCpt)); - - /*****************************/ - /* Test if interrupt enabled */ - /*****************************/ - - if (ps_ModuleInfo-> - s_ChronoModuleInfo.b_InterruptMask) { - devpriv-> - s_InterruptParameters. - s_FIFOInterruptParameters - [devpriv->s_InterruptParameters. - ui_Write].ul_OldInterruptMask = - 0x80; - - devpriv-> - s_InterruptParameters. - s_FIFOInterruptParameters - [devpriv->s_InterruptParameters. - ui_Write].b_OldModuleMask = - 1 << b_ModuleCpt; - - devpriv-> - s_InterruptParameters. - s_FIFOInterruptParameters - [devpriv->s_InterruptParameters. - ui_Write]. - ul_OldCounterLatchValue = - ul_LatchRegisterValue; - - devpriv-> - s_InterruptParameters. - ul_InterruptOccur++; - - /****************************/ - /* Increment the write FIFO */ - /****************************/ - - devpriv-> - s_InterruptParameters. - ui_Write = (devpriv-> - s_InterruptParameters. - ui_Write + - 1) % APCI1710_SAVE_INTERRUPT; - - b_InterruptFlag = 1; - - /**********************/ - /* Call user function */ - /**********************/ - /* Send a signal to from kernel to user space */ - send_sig(SIGIO, devpriv->tsk_Current, - 0); - - } - } - } /* Chronometer */ - - /*************************/ - /* Test if pulse encoder */ - /*************************/ - - if ((devpriv->s_BoardInfos. - dw_MolduleConfiguration[b_ModuleCpt] & - 0xFFFF0000UL) == APCI1710_PULSE_ENCODER) { - /****************************/ - /* Read the status register */ - /****************************/ - - ul_StatusRegister = inl(devpriv->s_BoardInfos. - ui_Address + 20 + (64 * b_ModuleCpt)); - - if (ul_StatusRegister & 0xF) { - for (b_PulseIncoderCpt = 0; - b_PulseIncoderCpt < 4; - b_PulseIncoderCpt++) { - /*************************************/ - /* Test if pulse encoder initialised */ - /*************************************/ - - if ((ps_ModuleInfo-> - s_PulseEncoderModuleInfo. - s_PulseEncoderInfo - [b_PulseIncoderCpt]. - b_PulseEncoderInit == 1) - && (((ps_ModuleInfo->s_PulseEncoderModuleInfo.dw_SetRegister >> b_PulseIncoderCpt) & 1) == 1) && (((ul_StatusRegister >> (b_PulseIncoderCpt)) & 1) == 1)) { - devpriv->s_InterruptParameters. - s_FIFOInterruptParameters - [devpriv-> - s_InterruptParameters. - ui_Write]. - ul_OldInterruptMask = - 0x100UL << - b_PulseIncoderCpt; - - devpriv-> - s_InterruptParameters. - s_FIFOInterruptParameters - [devpriv-> - s_InterruptParameters. - ui_Write]. - b_OldModuleMask = - 1 << b_ModuleCpt; - - devpriv-> - s_InterruptParameters. - s_FIFOInterruptParameters - [devpriv-> - s_InterruptParameters. - ui_Write]. - ul_OldCounterLatchValue - = ul_LatchRegisterValue; - - devpriv-> - s_InterruptParameters. - ul_InterruptOccur++; - - /****************************/ - /* 0899/0224 to 1199/0225 */ - /****************************/ - /* Increment the write FIFO */ - /****************************/ - - devpriv-> - s_InterruptParameters. - ui_Write = (devpriv-> - s_InterruptParameters. - ui_Write + - 1) % - APCI1710_SAVE_INTERRUPT; - - b_InterruptFlag = 1; - - /**********************/ - /* Call user function */ - /**********************/ - /* Send a signal to from kernel to user space */ - send_sig(SIGIO, - devpriv->tsk_Current, - 0); - - } - } - } - } /* pulse encoder */ - - } - return; - -} diff --git a/drivers/staging/comedi/drivers/addi_apci_1710.c b/drivers/staging/comedi/drivers/addi_apci_1710.c deleted file mode 100644 index 9157ac50815ed..0000000000000 --- a/drivers/staging/comedi/drivers/addi_apci_1710.c +++ /dev/null @@ -1,237 +0,0 @@ -#include -#include -#include - -#include - -#include "../comedidev.h" -#include "comedi_fc.h" -#include "amcc_s5933.h" - -#define APCI1710_SAVE_INTERRUPT 1 - -union str_ModuleInfo { - /* Incremental counter infos */ - struct { - union { - struct { - unsigned char b_ModeRegister1; - unsigned char b_ModeRegister2; - unsigned char b_ModeRegister3; - unsigned char b_ModeRegister4; - } s_ByteModeRegister; - unsigned int dw_ModeRegister1_2_3_4; - } s_ModeRegister; - - struct { - unsigned int b_IndexInit:1; - unsigned int b_CounterInit:1; - unsigned int b_ReferenceInit:1; - unsigned int b_IndexInterruptOccur:1; - unsigned int b_CompareLogicInit:1; - unsigned int b_FrequencyMeasurementInit:1; - unsigned int b_FrequencyMeasurementEnable:1; - } s_InitFlag; - - } s_SiemensCounterInfo; - - /* SSI infos */ - struct { - unsigned char b_SSIProfile; - unsigned char b_PositionTurnLength; - unsigned char b_TurnCptLength; - unsigned char b_SSIInit; - } s_SSICounterInfo; - - /* TTL I/O infos */ - struct { - unsigned char b_TTLInit; - unsigned char b_PortConfiguration[4]; - } s_TTLIOInfo; - - /* Digital I/O infos */ - struct { - unsigned char b_DigitalInit; - unsigned char b_ChannelAMode; - unsigned char b_ChannelBMode; - unsigned char b_OutputMemoryEnabled; - unsigned int dw_OutputMemory; - } s_DigitalIOInfo; - - /* 82X54 timer infos */ - struct { - struct { - unsigned char b_82X54Init; - unsigned char b_InputClockSelection; - unsigned char b_InputClockLevel; - unsigned char b_OutputLevel; - unsigned char b_HardwareGateLevel; - unsigned int dw_ConfigurationWord; - } s_82X54TimerInfo[3]; - unsigned char b_InterruptMask; - } s_82X54ModuleInfo; - - /* Chronometer infos */ - struct { - unsigned char b_ChronoInit; - unsigned char b_InterruptMask; - unsigned char b_PCIInputClock; - unsigned char b_TimingUnit; - unsigned char b_CycleMode; - double d_TimingInterval; - unsigned int dw_ConfigReg; - } s_ChronoModuleInfo; - - /* Pulse encoder infos */ - struct { - struct { - unsigned char b_PulseEncoderInit; - } s_PulseEncoderInfo[4]; - unsigned int dw_SetRegister; - unsigned int dw_ControlRegister; - unsigned int dw_StatusRegister; - } s_PulseEncoderModuleInfo; - - /* Tor conter infos */ - struct { - struct { - unsigned char b_TorCounterInit; - unsigned char b_TimingUnit; - unsigned char b_InterruptEnable; - double d_TimingInterval; - unsigned int ul_RealTimingInterval; - } s_TorCounterInfo[2]; - unsigned char b_PCIInputClock; - } s_TorCounterModuleInfo; - - /* PWM infos */ - struct { - struct { - unsigned char b_PWMInit; - unsigned char b_TimingUnit; - unsigned char b_InterruptEnable; - double d_LowTiming; - double d_HighTiming; - unsigned int ul_RealLowTiming; - unsigned int ul_RealHighTiming; - } s_PWMInfo[2]; - unsigned char b_ClockSelection; - } s_PWMModuleInfo; - - /* CDA infos */ - struct { - unsigned char b_CDAEnable; - unsigned char b_FctSelection; - } s_CDAModuleInfo; -}; - -struct addi_private { - /* Pointer to the current process */ - struct task_struct *tsk_Current; - - struct { - unsigned int ui_Address; - unsigned char b_BoardVersion; - unsigned int dw_MolduleConfiguration[4]; - } s_BoardInfos; - - struct { - unsigned int ul_InterruptOccur; - unsigned int ui_Read; - unsigned int ui_Write; - struct { - unsigned char b_OldModuleMask; - unsigned int ul_OldInterruptMask; - unsigned int ul_OldCounterLatchValue; - } s_FIFOInterruptParameters[APCI1710_SAVE_INTERRUPT]; - } s_InterruptParameters; - - union str_ModuleInfo s_ModuleInfo[4]; -}; - -static void fpu_begin(void) -{ - kernel_fpu_begin(); -} - -static void fpu_end(void) -{ - kernel_fpu_end(); -} - -#include "addi-data/hwdrv_APCI1710.c" - -static irqreturn_t v_ADDI_Interrupt(int irq, void *d) -{ - v_APCI1710_Interrupt(irq, d); - return IRQ_RETVAL(1); -} - -static int apci1710_auto_attach(struct comedi_device *dev, - unsigned long context_unused) -{ - struct pci_dev *pcidev = comedi_to_pci_dev(dev); - struct addi_private *devpriv; - int ret; - - devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); - if (!devpriv) - return -ENOMEM; - - ret = comedi_pci_enable(dev); - if (ret) - return ret; - devpriv->s_BoardInfos.ui_Address = pci_resource_start(pcidev, 2); - - if (pcidev->irq > 0) { - ret = request_irq(pcidev->irq, v_ADDI_Interrupt, IRQF_SHARED, - dev->board_name, dev); - if (ret == 0) - dev->irq = pcidev->irq; - } - - i_ADDI_AttachPCI1710(dev); - - i_APCI1710_Reset(dev); - return 0; -} - -static void apci1710_detach(struct comedi_device *dev) -{ - if (dev->iobase) - i_APCI1710_Reset(dev); - if (dev->irq) - free_irq(dev->irq, dev); - comedi_pci_disable(dev); -} - -static struct comedi_driver apci1710_driver = { - .driver_name = "addi_apci_1710", - .module = THIS_MODULE, - .auto_attach = apci1710_auto_attach, - .detach = apci1710_detach, -}; - -static int apci1710_pci_probe(struct pci_dev *dev, - const struct pci_device_id *id) -{ - return comedi_pci_auto_config(dev, &apci1710_driver, id->driver_data); -} - -static DEFINE_PCI_DEVICE_TABLE(apci1710_pci_table) = { - { PCI_DEVICE(PCI_VENDOR_ID_AMCC, APCI1710_BOARD_DEVICE_ID) }, - { 0 } -}; -MODULE_DEVICE_TABLE(pci, apci1710_pci_table); - -static struct pci_driver apci1710_pci_driver = { - .name = "addi_apci_1710", - .id_table = apci1710_pci_table, - .probe = apci1710_pci_probe, - .remove = comedi_pci_auto_unconfig, -}; -module_comedi_pci_driver(apci1710_driver, apci1710_pci_driver); - -MODULE_AUTHOR("Comedi http://www.comedi.org"); -MODULE_DESCRIPTION("Comedi low-level driver"); -MODULE_LICENSE("GPL"); -- GitLab From 4f2cfd6778969c02dbeb6f6856ff2065d305baf7 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 11:14:43 -0700 Subject: [PATCH 244/942] staging: comedi: addi_common.h: cleanup after removal of addi_apci_1710 Now that the addi_apci_1710 driver has been removed, get rid of all the unnecessary stuff in addi_common.h. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- .../comedi/drivers/addi-data/addi_common.h | 169 ------------------ 1 file changed, 169 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi-data/addi_common.h b/drivers/staging/comedi/drivers/addi-data/addi_common.h index f1be5ade9962e..dfd1e666cc188 100644 --- a/drivers/staging/comedi/drivers/addi-data/addi_common.h +++ b/drivers/staging/comedi/drivers/addi-data/addi_common.h @@ -113,150 +113,6 @@ struct addi_board { struct comedi_insn *, unsigned int *); }; -/* MODULE INFO STRUCTURE */ - -union str_ModuleInfo { - /* Incremental counter infos */ - struct { - union { - struct { - unsigned char b_ModeRegister1; - unsigned char b_ModeRegister2; - unsigned char b_ModeRegister3; - unsigned char b_ModeRegister4; - } s_ByteModeRegister; - unsigned int dw_ModeRegister1_2_3_4; - } s_ModeRegister; - - struct { - unsigned int b_IndexInit:1; - unsigned int b_CounterInit:1; - unsigned int b_ReferenceInit:1; - unsigned int b_IndexInterruptOccur:1; - unsigned int b_CompareLogicInit:1; - unsigned int b_FrequencyMeasurementInit:1; - unsigned int b_FrequencyMeasurementEnable:1; - } s_InitFlag; - - } s_SiemensCounterInfo; - - /* SSI infos */ - struct { - unsigned char b_SSIProfile; - unsigned char b_PositionTurnLength; - unsigned char b_TurnCptLength; - unsigned char b_SSIInit; - } s_SSICounterInfo; - - /* TTL I/O infos */ - struct { - unsigned char b_TTLInit; - unsigned char b_PortConfiguration[4]; - } s_TTLIOInfo; - - /* Digital I/O infos */ - struct { - unsigned char b_DigitalInit; - unsigned char b_ChannelAMode; - unsigned char b_ChannelBMode; - unsigned char b_OutputMemoryEnabled; - unsigned int dw_OutputMemory; - } s_DigitalIOInfo; - - /*********************/ - /* 82X54 timer infos */ - /*********************/ - - struct { - struct { - unsigned char b_82X54Init; - unsigned char b_InputClockSelection; - unsigned char b_InputClockLevel; - unsigned char b_OutputLevel; - unsigned char b_HardwareGateLevel; - unsigned int dw_ConfigurationWord; - } s_82X54TimerInfo[3]; - unsigned char b_InterruptMask; - } s_82X54ModuleInfo; - - /*********************/ - /* Chronometer infos */ - /*********************/ - - struct { - unsigned char b_ChronoInit; - unsigned char b_InterruptMask; - unsigned char b_PCIInputClock; - unsigned char b_TimingUnit; - unsigned char b_CycleMode; - double d_TimingInterval; - unsigned int dw_ConfigReg; - } s_ChronoModuleInfo; - - /***********************/ - /* Pulse encoder infos */ - /***********************/ - - struct { - struct { - unsigned char b_PulseEncoderInit; - } s_PulseEncoderInfo[4]; - unsigned int dw_SetRegister; - unsigned int dw_ControlRegister; - unsigned int dw_StatusRegister; - } s_PulseEncoderModuleInfo; - - /* Tor conter infos */ - struct { - struct { - unsigned char b_TorCounterInit; - unsigned char b_TimingUnit; - unsigned char b_InterruptEnable; - double d_TimingInterval; - unsigned int ul_RealTimingInterval; - } s_TorCounterInfo[2]; - unsigned char b_PCIInputClock; - } s_TorCounterModuleInfo; - - /* PWM infos */ - struct { - struct { - unsigned char b_PWMInit; - unsigned char b_TimingUnit; - unsigned char b_InterruptEnable; - double d_LowTiming; - double d_HighTiming; - unsigned int ul_RealLowTiming; - unsigned int ul_RealHighTiming; - } s_PWMInfo[2]; - unsigned char b_ClockSelection; - } s_PWMModuleInfo; - - /* ETM infos */ - struct { - struct { - unsigned char b_ETMEnable; - unsigned char b_ETMInterrupt; - } s_ETMInfo[2]; - unsigned char b_ETMInit; - unsigned char b_TimingUnit; - unsigned char b_ClockSelection; - double d_TimingInterval; - unsigned int ul_Timing; - } s_ETMModuleInfo; - - /* CDA infos */ - struct { - unsigned char b_CDAEnable; - unsigned char b_CDAInterrupt; - unsigned char b_CDAInit; - unsigned char b_FctSelection; - unsigned char b_CDAReadFIFOOverflow; - } s_CDAModuleInfo; - -}; - -/* Private structure for the addi_apci3120 driver */ struct addi_private { int iobase; int i_IobaseAmcc; /* base+size for AMCC chip */ @@ -299,31 +155,6 @@ struct addi_private { /* Pointer to the current process */ struct task_struct *tsk_Current; - /* Hardware board infos for 1710 */ - struct { - unsigned int ui_Address; /* Board address */ - unsigned int ui_FlashAddress; - unsigned char b_InterruptNbr; /* Board interrupt number */ - unsigned char b_SlotNumber; /* PCI slot number */ - unsigned char b_BoardVersion; - unsigned int dw_MolduleConfiguration[4]; /* Module config */ - } s_BoardInfos; - - /* Interrupt infos */ - struct { - unsigned int ul_InterruptOccur; /* 0 : No interrupt occur */ - /* > 0 : Interrupt occur */ - unsigned int ui_Read; /* Read FIFO */ - unsigned int ui_Write; /* Write FIFO */ - struct { - unsigned char b_OldModuleMask; - unsigned int ul_OldInterruptMask; /* Interrupt mask */ - unsigned int ul_OldCounterLatchValue; /* Interrupt counter value */ - } s_FIFOInterruptParameters[APCI1710_SAVE_INTERRUPT]; - } s_InterruptParameters; - - union str_ModuleInfo s_ModuleInfo[4]; - /* Parameters read from EEPROM overriding static board info */ struct { int i_NbrAiChannel; /* num of A/D chans */ -- GitLab From 2b00f54b248144acc393740e4c4679b6aa531193 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 12:08:58 -0700 Subject: [PATCH 245/942] staging: comedi: ii_pci20kc: use comedi_alloc_spriv() For aesthetic reasons, use the helper function to allocate the subdevice private data instead of hanging it on the device private data. The core will free the memory during the detach. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ii_pci20kc.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/ii_pci20kc.c b/drivers/staging/comedi/drivers/ii_pci20kc.c index 9c199a194d2b5..45d76ed664988 100644 --- a/drivers/staging/comedi/drivers/ii_pci20kc.c +++ b/drivers/staging/comedi/drivers/ii_pci20kc.c @@ -149,9 +149,7 @@ union pci20xxx_subdev_private { }; struct pci20xxx_private { - void __iomem *ioaddr; - union pci20xxx_subdev_private subdev_private[PCI20000_MODULES]; }; #define CHAN (CR_CHAN(it->chanlist[0])) @@ -222,9 +220,10 @@ static int pci20xxx_attach(struct comedi_device *dev, for (i = 0; i < PCI20000_MODULES; i++) { s = &dev->subdevices[i]; + sdp = comedi_alloc_spriv(s, sizeof(*sdp)); + if (!sdp) + return -ENOMEM; id = readb(devpriv->ioaddr + (i + 1) * PCI20000_OFFSET); - s->private = devpriv->subdev_private + i; - sdp = s->private; switch (id) { case PCI20006_ID: sdp->pci20006.iobase = -- GitLab From 0f8409dc057935900a53d4781bcbb77149348267 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 12:09:25 -0700 Subject: [PATCH 246/942] staging: comedi: ii_pci20kc: remove forward declarations 1 Move the pci20xxx_attach() and pci20xxx_detach() functions to remove the need for some of the forward declarations. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ii_pci20kc.c | 184 ++++++++------------ 1 file changed, 75 insertions(+), 109 deletions(-) diff --git a/drivers/staging/comedi/drivers/ii_pci20kc.c b/drivers/staging/comedi/drivers/ii_pci20kc.c index 45d76ed664988..bc95cd66dc5fe 100644 --- a/drivers/staging/comedi/drivers/ii_pci20kc.c +++ b/drivers/staging/comedi/drivers/ii_pci20kc.c @@ -154,115 +154,6 @@ struct pci20xxx_private { #define CHAN (CR_CHAN(it->chanlist[0])) -static int pci20006_init(struct comedi_device *dev, struct comedi_subdevice *s, - int opt0, int opt1); -static int pci20341_init(struct comedi_device *dev, struct comedi_subdevice *s, - int opt0, int opt1); -static int pci20xxx_dio_init(struct comedi_device *dev, - struct comedi_subdevice *s); - -/* - options[0] Board base address - options[1] IRQ - options[2] first option for module 1 - options[3] second option for module 1 - options[4] first option for module 2 - options[5] second option for module 2 - options[6] first option for module 3 - options[7] second option for module 3 - - options for PCI-20341M: - first Analog input gain configuration - 0 == 1 - 1 == 10 - 2 == 100 - 3 == 200 - - options for PCI-20006M: - first Analog output channel 0 range configuration - 0 == bipolar 10 (-10V -- +10V) - 1 == unipolar 10V (0V -- +10V) - 2 == bipolar 5V (-5V -- +5V) - second Analog output channel 1 range configuration - 0 == bipolar 10 (-10V -- +10V) - 1 == unipolar 10V (0V -- +10V) - 2 == bipolar 5V (-5V -- +5V) -*/ -static int pci20xxx_attach(struct comedi_device *dev, - struct comedi_devconfig *it) -{ - struct pci20xxx_private *devpriv; - unsigned char i; - int ret; - int id; - struct comedi_subdevice *s; - union pci20xxx_subdev_private *sdp; - - ret = comedi_alloc_subdevices(dev, 1 + PCI20000_MODULES); - if (ret) - return ret; - - devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); - if (!devpriv) - return -ENOMEM; - - devpriv->ioaddr = (void __iomem *)(unsigned long)it->options[0]; - - /* Check PCI-20001 C-2A Carrier Board ID */ - if ((readb(devpriv->ioaddr) & PCI20000_ID) != PCI20000_ID) { - dev_warn(dev->class_dev, - "PCI-20001 C-2A Carrier Board at base=0x%p not found !\n", - devpriv->ioaddr); - return -EINVAL; - } - dev_info(dev->class_dev, "PCI-20001 C-2A at base=0x%p\n", - devpriv->ioaddr); - - for (i = 0; i < PCI20000_MODULES; i++) { - s = &dev->subdevices[i]; - sdp = comedi_alloc_spriv(s, sizeof(*sdp)); - if (!sdp) - return -ENOMEM; - id = readb(devpriv->ioaddr + (i + 1) * PCI20000_OFFSET); - switch (id) { - case PCI20006_ID: - sdp->pci20006.iobase = - devpriv->ioaddr + (i + 1) * PCI20000_OFFSET; - pci20006_init(dev, s, it->options[2 * i + 2], - it->options[2 * i + 3]); - dev_info(dev->class_dev, - "PCI-20006 module in slot %d\n", i + 1); - break; - case PCI20341_ID: - sdp->pci20341.iobase = - devpriv->ioaddr + (i + 1) * PCI20000_OFFSET; - pci20341_init(dev, s, it->options[2 * i + 2], - it->options[2 * i + 3]); - dev_info(dev->class_dev, - "PCI-20341 module in slot %d\n", i + 1); - break; - default: - dev_warn(dev->class_dev, - "unknown module code 0x%02x in slot %d: module disabled\n", - id, i); /* XXX this looks like a bug! i + 1 ?? */ - /* fall through */ - case PCI20xxx_EMPTY_ID: - s->type = COMEDI_SUBD_UNUSED; - break; - } - } - - /* initialize struct pci20xxx_private */ - pci20xxx_dio_init(dev, &dev->subdevices[PCI20000_MODULES]); - - return 1; -} - -static void pci20xxx_detach(struct comedi_device *dev) -{ - /* Nothing to cleanup */ -} - /* pci20006m */ static int pci20006_insn_read(struct comedi_device *dev, @@ -649,6 +540,81 @@ static unsigned int pci20xxx_di(struct comedi_device *dev, } #endif +static int pci20xxx_attach(struct comedi_device *dev, + struct comedi_devconfig *it) +{ + struct pci20xxx_private *devpriv; + unsigned char i; + int ret; + int id; + struct comedi_subdevice *s; + union pci20xxx_subdev_private *sdp; + + ret = comedi_alloc_subdevices(dev, 1 + PCI20000_MODULES); + if (ret) + return ret; + + devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); + if (!devpriv) + return -ENOMEM; + + devpriv->ioaddr = (void __iomem *)(unsigned long)it->options[0]; + + /* Check PCI-20001 C-2A Carrier Board ID */ + if ((readb(devpriv->ioaddr) & PCI20000_ID) != PCI20000_ID) { + dev_warn(dev->class_dev, + "PCI-20001 C-2A Carrier Board at base=0x%p not found !\n", + devpriv->ioaddr); + return -EINVAL; + } + dev_info(dev->class_dev, "PCI-20001 C-2A at base=0x%p\n", + devpriv->ioaddr); + + for (i = 0; i < PCI20000_MODULES; i++) { + s = &dev->subdevices[i]; + sdp = comedi_alloc_spriv(s, sizeof(*sdp)); + if (!sdp) + return -ENOMEM; + id = readb(devpriv->ioaddr + (i + 1) * PCI20000_OFFSET); + switch (id) { + case PCI20006_ID: + sdp->pci20006.iobase = + devpriv->ioaddr + (i + 1) * PCI20000_OFFSET; + pci20006_init(dev, s, it->options[2 * i + 2], + it->options[2 * i + 3]); + dev_info(dev->class_dev, + "PCI-20006 module in slot %d\n", i + 1); + break; + case PCI20341_ID: + sdp->pci20341.iobase = + devpriv->ioaddr + (i + 1) * PCI20000_OFFSET; + pci20341_init(dev, s, it->options[2 * i + 2], + it->options[2 * i + 3]); + dev_info(dev->class_dev, + "PCI-20341 module in slot %d\n", i + 1); + break; + default: + dev_warn(dev->class_dev, + "unknown module code 0x%02x in slot %d: module disabled\n", + id, i); /* XXX this looks like a bug! i + 1 ?? */ + /* fall through */ + case PCI20xxx_EMPTY_ID: + s->type = COMEDI_SUBD_UNUSED; + break; + } + } + + /* initialize struct pci20xxx_private */ + pci20xxx_dio_init(dev, &dev->subdevices[PCI20000_MODULES]); + + return 1; +} + +static void pci20xxx_detach(struct comedi_device *dev) +{ + /* Nothing to cleanup */ +} + static struct comedi_driver pci20xxx_driver = { .driver_name = "ii_pci20kc", .module = THIS_MODULE, -- GitLab From 63d6e8ff0d25256d57453959c4d192b950a417ce Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 12:09:53 -0700 Subject: [PATCH 247/942] staging: comedi: ii_pci20kc: remove forward declarations 2 Move the pci20xxx_dio_*() functions to remove the need for some of the forward declarations. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ii_pci20kc.c | 190 +++++++++----------- 1 file changed, 88 insertions(+), 102 deletions(-) diff --git a/drivers/staging/comedi/drivers/ii_pci20kc.c b/drivers/staging/comedi/drivers/ii_pci20kc.c index bc95cd66dc5fe..eab48e31fb828 100644 --- a/drivers/staging/comedi/drivers/ii_pci20kc.c +++ b/drivers/staging/comedi/drivers/ii_pci20kc.c @@ -361,95 +361,37 @@ static int pci20341_insn_read(struct comedi_device *dev, return i; } -/* native DIO */ - -static void pci20xxx_dio_config(struct comedi_device *dev, - struct comedi_subdevice *s); -static int pci20xxx_dio_insn_bits(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data); -static int pci20xxx_dio_insn_config(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data); - -/* initialize struct pci20xxx_private */ -static int pci20xxx_dio_init(struct comedi_device *dev, - struct comedi_subdevice *s) -{ - - s->type = COMEDI_SUBD_DIO; - s->subdev_flags = SDF_READABLE | SDF_WRITABLE; - s->n_chan = 32; - s->insn_bits = pci20xxx_dio_insn_bits; - s->insn_config = pci20xxx_dio_insn_config; - s->maxdata = 1; - s->len_chanlist = 32; - s->range_table = &range_digital; - s->io_bits = 0; - - /* digital I/O lines default to input on board reset. */ - pci20xxx_dio_config(dev, s); - - return 0; -} - -static int pci20xxx_dio_insn_config(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) +#if 0 +static void pci20xxx_do(struct comedi_device *dev, struct comedi_subdevice *s) { - int mask, bits; - - mask = 1 << CR_CHAN(insn->chanspec); - if (mask & 0x000000ff) - bits = 0x000000ff; - else if (mask & 0x0000ff00) - bits = 0x0000ff00; - else if (mask & 0x00ff0000) - bits = 0x00ff0000; - else - bits = 0xff000000; - if (data[0]) - s->io_bits |= bits; - else - s->io_bits &= ~bits; - pci20xxx_dio_config(dev, s); + struct pci20xxx_private *devpriv = dev->private; - return 1; + /* XXX if the channel is configured for input, does this + do bad things? */ + /* XXX it would be a good idea to only update the registers + that _need_ to be updated. This requires changes to + comedi, however. */ + writeb((s->state >> 0) & 0xff, devpriv->ioaddr + PCI20000_DIO_0); + writeb((s->state >> 8) & 0xff, devpriv->ioaddr + PCI20000_DIO_1); + writeb((s->state >> 16) & 0xff, devpriv->ioaddr + PCI20000_DIO_2); + writeb((s->state >> 24) & 0xff, devpriv->ioaddr + PCI20000_DIO_3); } -static int pci20xxx_dio_insn_bits(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static unsigned int pci20xxx_di(struct comedi_device *dev, + struct comedi_subdevice *s) { struct pci20xxx_private *devpriv = dev->private; - unsigned int mask = data[0]; - - s->state &= ~mask; - s->state |= (mask & data[1]); - - mask &= s->io_bits; - if (mask & 0x000000ff) - writeb((s->state >> 0) & 0xff, - devpriv->ioaddr + PCI20000_DIO_0); - if (mask & 0x0000ff00) - writeb((s->state >> 8) & 0xff, - devpriv->ioaddr + PCI20000_DIO_1); - if (mask & 0x00ff0000) - writeb((s->state >> 16) & 0xff, - devpriv->ioaddr + PCI20000_DIO_2); - if (mask & 0xff000000) - writeb((s->state >> 24) & 0xff, - devpriv->ioaddr + PCI20000_DIO_3); + unsigned int bits; - data[1] = readb(devpriv->ioaddr + PCI20000_DIO_0); - data[1] |= readb(devpriv->ioaddr + PCI20000_DIO_1) << 8; - data[1] |= readb(devpriv->ioaddr + PCI20000_DIO_2) << 16; - data[1] |= readb(devpriv->ioaddr + PCI20000_DIO_3) << 24; + /* XXX same note as above */ + bits = readb(devpriv->ioaddr + PCI20000_DIO_0); + bits |= readb(devpriv->ioaddr + PCI20000_DIO_1) << 8; + bits |= readb(devpriv->ioaddr + PCI20000_DIO_2) << 16; + bits |= readb(devpriv->ioaddr + PCI20000_DIO_3) << 24; - return insn->n; + return bits; } +#endif static void pci20xxx_dio_config(struct comedi_device *dev, struct comedi_subdevice *s) @@ -508,37 +450,81 @@ static void pci20xxx_dio_config(struct comedi_device *dev, writeb(buffer, devpriv->ioaddr + PCI20000_DIO_BUFFER); } -#if 0 -static void pci20xxx_do(struct comedi_device *dev, struct comedi_subdevice *s) +static int pci20xxx_dio_insn_config(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { - struct pci20xxx_private *devpriv = dev->private; + int mask, bits; - /* XXX if the channel is configured for input, does this - do bad things? */ - /* XXX it would be a good idea to only update the registers - that _need_ to be updated. This requires changes to - comedi, however. */ - writeb((s->state >> 0) & 0xff, devpriv->ioaddr + PCI20000_DIO_0); - writeb((s->state >> 8) & 0xff, devpriv->ioaddr + PCI20000_DIO_1); - writeb((s->state >> 16) & 0xff, devpriv->ioaddr + PCI20000_DIO_2); - writeb((s->state >> 24) & 0xff, devpriv->ioaddr + PCI20000_DIO_3); + mask = 1 << CR_CHAN(insn->chanspec); + if (mask & 0x000000ff) + bits = 0x000000ff; + else if (mask & 0x0000ff00) + bits = 0x0000ff00; + else if (mask & 0x00ff0000) + bits = 0x00ff0000; + else + bits = 0xff000000; + if (data[0]) + s->io_bits |= bits; + else + s->io_bits &= ~bits; + pci20xxx_dio_config(dev, s); + + return 1; } -static unsigned int pci20xxx_di(struct comedi_device *dev, - struct comedi_subdevice *s) +static int pci20xxx_dio_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { struct pci20xxx_private *devpriv = dev->private; - unsigned int bits; + unsigned int mask = data[0]; - /* XXX same note as above */ - bits = readb(devpriv->ioaddr + PCI20000_DIO_0); - bits |= readb(devpriv->ioaddr + PCI20000_DIO_1) << 8; - bits |= readb(devpriv->ioaddr + PCI20000_DIO_2) << 16; - bits |= readb(devpriv->ioaddr + PCI20000_DIO_3) << 24; + s->state &= ~mask; + s->state |= (mask & data[1]); - return bits; + mask &= s->io_bits; + if (mask & 0x000000ff) + writeb((s->state >> 0) & 0xff, + devpriv->ioaddr + PCI20000_DIO_0); + if (mask & 0x0000ff00) + writeb((s->state >> 8) & 0xff, + devpriv->ioaddr + PCI20000_DIO_1); + if (mask & 0x00ff0000) + writeb((s->state >> 16) & 0xff, + devpriv->ioaddr + PCI20000_DIO_2); + if (mask & 0xff000000) + writeb((s->state >> 24) & 0xff, + devpriv->ioaddr + PCI20000_DIO_3); + + data[1] = readb(devpriv->ioaddr + PCI20000_DIO_0); + data[1] |= readb(devpriv->ioaddr + PCI20000_DIO_1) << 8; + data[1] |= readb(devpriv->ioaddr + PCI20000_DIO_2) << 16; + data[1] |= readb(devpriv->ioaddr + PCI20000_DIO_3) << 24; + + return insn->n; +} + +static int pci20xxx_dio_init(struct comedi_device *dev, + struct comedi_subdevice *s) +{ + s->type = COMEDI_SUBD_DIO; + s->subdev_flags = SDF_READABLE | SDF_WRITABLE; + s->n_chan = 32; + s->insn_bits = pci20xxx_dio_insn_bits; + s->insn_config = pci20xxx_dio_insn_config; + s->maxdata = 1; + s->len_chanlist = 32; + s->range_table = &range_digital; + s->io_bits = 0; + + /* digital I/O lines default to input on board reset. */ + pci20xxx_dio_config(dev, s); + + return 0; } -#endif static int pci20xxx_attach(struct comedi_device *dev, struct comedi_devconfig *it) -- GitLab From 842525c6c1efa0bfefb7fb96838ef6ec588ce95e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 12:10:18 -0700 Subject: [PATCH 248/942] staging: comedi: ii_pci20kc: remove forward declarations 3 Move a couple functions to remove the need for the last forward declarations. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ii_pci20kc.c | 135 +++++++++----------- 1 file changed, 62 insertions(+), 73 deletions(-) diff --git a/drivers/staging/comedi/drivers/ii_pci20kc.c b/drivers/staging/comedi/drivers/ii_pci20kc.c index eab48e31fb828..ad4dc5741b27c 100644 --- a/drivers/staging/comedi/drivers/ii_pci20kc.c +++ b/drivers/staging/comedi/drivers/ii_pci20kc.c @@ -156,44 +156,12 @@ struct pci20xxx_private { /* pci20006m */ -static int pci20006_insn_read(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data); -static int pci20006_insn_write(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data); - static const struct comedi_lrange *pci20006_range_list[] = { &range_bipolar10, &range_unipolar10, &range_bipolar5, }; -static int pci20006_init(struct comedi_device *dev, struct comedi_subdevice *s, - int opt0, int opt1) -{ - union pci20xxx_subdev_private *sdp = s->private; - - if (opt0 < 0 || opt0 > 2) - opt0 = 0; - if (opt1 < 0 || opt1 > 2) - opt1 = 0; - - sdp->pci20006.ao_range_list[0] = pci20006_range_list[opt0]; - sdp->pci20006.ao_range_list[1] = pci20006_range_list[opt1]; - - /* ao subdevice */ - s->type = COMEDI_SUBD_AO; - s->subdev_flags = SDF_WRITABLE; - s->n_chan = 2; - s->len_chanlist = 2; - s->insn_read = pci20006_insn_read; - s->insn_write = pci20006_insn_write; - s->maxdata = 0xffff; - s->range_table_list = sdp->pci20006.ao_range_list; - return 0; -} - static int pci20006_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) @@ -238,11 +206,32 @@ static int pci20006_insn_write(struct comedi_device *dev, return 1; } -/* PCI20341M */ +static int pci20006_init(struct comedi_device *dev, struct comedi_subdevice *s, + int opt0, int opt1) +{ + union pci20xxx_subdev_private *sdp = s->private; -static int pci20341_insn_read(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data); + if (opt0 < 0 || opt0 > 2) + opt0 = 0; + if (opt1 < 0 || opt1 > 2) + opt1 = 0; + + sdp->pci20006.ao_range_list[0] = pci20006_range_list[opt0]; + sdp->pci20006.ao_range_list[1] = pci20006_range_list[opt1]; + + /* ao subdevice */ + s->type = COMEDI_SUBD_AO; + s->subdev_flags = SDF_WRITABLE; + s->n_chan = 2; + s->len_chanlist = 2; + s->insn_read = pci20006_insn_read; + s->insn_write = pci20006_insn_write; + s->maxdata = 0xffff; + s->range_table_list = sdp->pci20006.ao_range_list; + return 0; +} + +/* PCI20341M */ static const int pci20341_timebase[] = { 0x00, 0x00, 0x00, 0x04 }; static const int pci20341_settling_time[] = { 0x58, 0x58, 0x93, 0x99 }; @@ -269,43 +258,6 @@ static const struct comedi_lrange *const pci20341_ranges[] = { &range_bipolar0_025, }; -static int pci20341_init(struct comedi_device *dev, struct comedi_subdevice *s, - int opt0, int opt1) -{ - union pci20xxx_subdev_private *sdp = s->private; - int option; - - /* options handling */ - if (opt0 < 0 || opt0 > 3) - opt0 = 0; - sdp->pci20341.timebase = pci20341_timebase[opt0]; - sdp->pci20341.settling_time = pci20341_settling_time[opt0]; - - /* ai subdevice */ - s->type = COMEDI_SUBD_AI; - s->subdev_flags = SDF_READABLE; - s->n_chan = PCI20341_CHAN_NR; - s->len_chanlist = PCI20341_SCANLIST; - s->insn_read = pci20341_insn_read; - s->maxdata = 0xffff; - s->range_table = pci20341_ranges[opt0]; - - /* depends on gain, trigger, repetition mode */ - option = sdp->pci20341.timebase | PCI20341_REPMODE; - - /* initialize Module */ - writeb(PCI20341_INIT, sdp->iobase + PCI20341_CONFIG_REG); - /* set Pacer */ - writeb(PCI20341_PACER, sdp->iobase + PCI20341_MOD_STATUS); - /* option register */ - writeb(option, sdp->iobase + PCI20341_OPT_REG); - /* settling time counter */ - writeb(sdp->pci20341.settling_time, - sdp->iobase + PCI20341_SET_TIME_REG); - /* trigger not implemented */ - return 0; -} - static int pci20341_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) @@ -361,6 +313,43 @@ static int pci20341_insn_read(struct comedi_device *dev, return i; } +static int pci20341_init(struct comedi_device *dev, struct comedi_subdevice *s, + int opt0, int opt1) +{ + union pci20xxx_subdev_private *sdp = s->private; + int option; + + /* options handling */ + if (opt0 < 0 || opt0 > 3) + opt0 = 0; + sdp->pci20341.timebase = pci20341_timebase[opt0]; + sdp->pci20341.settling_time = pci20341_settling_time[opt0]; + + /* ai subdevice */ + s->type = COMEDI_SUBD_AI; + s->subdev_flags = SDF_READABLE; + s->n_chan = PCI20341_CHAN_NR; + s->len_chanlist = PCI20341_SCANLIST; + s->insn_read = pci20341_insn_read; + s->maxdata = 0xffff; + s->range_table = pci20341_ranges[opt0]; + + /* depends on gain, trigger, repetition mode */ + option = sdp->pci20341.timebase | PCI20341_REPMODE; + + /* initialize Module */ + writeb(PCI20341_INIT, sdp->iobase + PCI20341_CONFIG_REG); + /* set Pacer */ + writeb(PCI20341_PACER, sdp->iobase + PCI20341_MOD_STATUS); + /* option register */ + writeb(option, sdp->iobase + PCI20341_OPT_REG); + /* settling time counter */ + writeb(sdp->pci20341.settling_time, + sdp->iobase + PCI20341_SET_TIME_REG); + /* trigger not implemented */ + return 0; +} + #if 0 static void pci20xxx_do(struct comedi_device *dev, struct comedi_subdevice *s) { -- GitLab From 3366244718f5c95b25cc96318cf448dafa1dcd00 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 12:10:41 -0700 Subject: [PATCH 249/942] staging: comedi: ii_pci20kc: move comedi_lrange tables For aesthetic reasons, move the static const data to the head of the file. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ii_pci20kc.c | 65 +++++++++++---------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/drivers/staging/comedi/drivers/ii_pci20kc.c b/drivers/staging/comedi/drivers/ii_pci20kc.c index ad4dc5741b27c..273034a71464b 100644 --- a/drivers/staging/comedi/drivers/ii_pci20kc.c +++ b/drivers/staging/comedi/drivers/ii_pci20kc.c @@ -132,6 +132,40 @@ options for PCI-20341M: #define PCI20341_MUX 0x04 /* Enable on-board MUX */ #define PCI20341_SCANLIST 0x80 /* Channel/Gain Scan List */ +static const struct comedi_lrange range_bipolar0_5 = { + 1, { + BIP_RANGE(0.5) + } +}; + +static const struct comedi_lrange range_bipolar0_05 = { + 1, { + BIP_RANGE(0.05) + } +}; + +static const struct comedi_lrange range_bipolar0_025 = { + 1, { + BIP_RANGE(0.025) + } +}; + +static const struct comedi_lrange *pci20006_range_list[] = { + &range_bipolar10, + &range_unipolar10, + &range_bipolar5, +}; + +static const struct comedi_lrange *const pci20341_ranges[] = { + &range_bipolar5, + &range_bipolar0_5, + &range_bipolar0_05, + &range_bipolar0_025, +}; + +static const int pci20341_timebase[] = { 0x00, 0x00, 0x00, 0x04 }; +static const int pci20341_settling_time[] = { 0x58, 0x58, 0x93, 0x99 }; + union pci20xxx_subdev_private { void __iomem *iobase; struct { @@ -156,12 +190,6 @@ struct pci20xxx_private { /* pci20006m */ -static const struct comedi_lrange *pci20006_range_list[] = { - &range_bipolar10, - &range_unipolar10, - &range_bipolar5, -}; - static int pci20006_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) @@ -233,31 +261,6 @@ static int pci20006_init(struct comedi_device *dev, struct comedi_subdevice *s, /* PCI20341M */ -static const int pci20341_timebase[] = { 0x00, 0x00, 0x00, 0x04 }; -static const int pci20341_settling_time[] = { 0x58, 0x58, 0x93, 0x99 }; - -static const struct comedi_lrange range_bipolar0_5 = { - 1, - {BIP_RANGE(0.5)} -}; - -static const struct comedi_lrange range_bipolar0_05 = { - 1, - {BIP_RANGE(0.05)} -}; - -static const struct comedi_lrange range_bipolar0_025 = { - 1, - {BIP_RANGE(0.025)} -}; - -static const struct comedi_lrange *const pci20341_ranges[] = { - &range_bipolar5, - &range_bipolar0_5, - &range_bipolar0_05, - &range_bipolar0_025, -}; - static int pci20341_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) -- GitLab From 6d305f89529f1c4400e3d04fedfb8411041f1387 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 12:11:00 -0700 Subject: [PATCH 250/942] staging: comedi: ii_pci20kc: remove CHAN macro This macro is not used, and it looks to much like the comedi CR_CHAN macro. Just remove it. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ii_pci20kc.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/ii_pci20kc.c b/drivers/staging/comedi/drivers/ii_pci20kc.c index 273034a71464b..056afdf1165a5 100644 --- a/drivers/staging/comedi/drivers/ii_pci20kc.c +++ b/drivers/staging/comedi/drivers/ii_pci20kc.c @@ -186,8 +186,6 @@ struct pci20xxx_private { void __iomem *ioaddr; }; -#define CHAN (CR_CHAN(it->chanlist[0])) - /* pci20006m */ static int pci20006_insn_read(struct comedi_device *dev, -- GitLab From 9abeb196a740bd52401a24108df27e20576da036 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 12:11:25 -0700 Subject: [PATCH 251/942] staging: comedi: ii_pci20kc.c: cleanup the dio subdevice For asethetics, redefine the register map for the carrier board. The 'PCI*' names lead one to think this is a PCI board not a legacy ISA board. Remove the #if 0'd out pci20xxx_{do,di}() functions. They are not needed. Rename, and fix, the pci20xxx_dio_config() function. The control and direction registers are not readable. Use the new register map defines instead of the crazy bit shifts. Rename, and fix, the pci20xxx_dio_insn_config() function. This function should treat data[0] as the 'instruction' to handle not just use it to determine if the port is an input or output. Rename, and tix, the pci20xxx_dio_insn_bits() function. The 'state' only needs to be updated if the 'mask' indicates. For aesthetics, abosrb the pci20xxx_dio_init() into the (*attach) function. Fix the carrier board id detect in the (*attach). There are two carrier board types, one with 32 dio channels and one without. Use this info when setting up the dio subdevice. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ii_pci20kc.c | 337 ++++++++++---------- 1 file changed, 169 insertions(+), 168 deletions(-) diff --git a/drivers/staging/comedi/drivers/ii_pci20kc.c b/drivers/staging/comedi/drivers/ii_pci20kc.c index 056afdf1165a5..60a3bb2c36579 100644 --- a/drivers/staging/comedi/drivers/ii_pci20kc.c +++ b/drivers/staging/comedi/drivers/ii_pci20kc.c @@ -80,33 +80,47 @@ options for PCI-20341M: #include #include "../comedidev.h" -#define PCI20000_ID 0x1d +/* + * Register I/O map + */ +#define II20K_ID_REG 0x00 +#define II20K_ID_MOD1_EMPTY (1 << 7) +#define II20K_ID_MOD2_EMPTY (1 << 6) +#define II20K_ID_MOD3_EMPTY (1 << 5) +#define II20K_ID_MASK 0x1f +#define II20K_ID_PCI20001C_1A 0x1b /* no on-board DIO */ +#define II20K_ID_PCI20001C_2A 0x1d /* on-board DIO */ +#define II20K_MOD_STATUS_REG 0x40 +#define II20K_MOD_STATUS_IRQ_MOD1 (1 << 7) +#define II20K_MOD_STATUS_IRQ_MOD2 (1 << 6) +#define II20K_MOD_STATUS_IRQ_MOD3 (1 << 5) +#define II20K_DIO0_REG 0x80 +#define II20K_DIO1_REG 0x81 +#define II20K_DIR_ENA_REG 0x82 +#define II20K_DIR_DIO3_OUT (1 << 7) +#define II20K_DIR_DIO2_OUT (1 << 6) +#define II20K_BUF_DISAB_DIO3 (1 << 5) +#define II20K_BUF_DISAB_DIO2 (1 << 4) +#define II20K_DIR_DIO1_OUT (1 << 3) +#define II20K_DIR_DIO0_OUT (1 << 2) +#define II20K_BUF_DISAB_DIO1 (1 << 1) +#define II20K_BUF_DISAB_DIO0 (1 << 0) +#define II20K_CTRL01_REG 0x83 +#define II20K_CTRL01_SET (1 << 7) +#define II20K_CTRL01_DIO0_IN (1 << 4) +#define II20K_CTRL01_DIO1_IN (1 << 1) +#define II20K_DIO2_REG 0xc0 +#define II20K_DIO3_REG 0xc1 +#define II20K_CTRL23_REG 0xc3 +#define II20K_CTRL23_SET (1 << 7) +#define II20K_CTRL23_DIO2_IN (1 << 4) +#define II20K_CTRL23_DIO3_IN (1 << 1) + #define PCI20341_ID 0x77 #define PCI20006_ID 0xe3 #define PCI20xxx_EMPTY_ID 0xff #define PCI20000_OFFSET 0x100 -#define PCI20000_MODULES 3 - -#define PCI20000_DIO_0 0x80 -#define PCI20000_DIO_1 0x81 -#define PCI20000_DIO_2 0xc0 -#define PCI20000_DIO_3 0xc1 -#define PCI20000_DIO_CONTROL_01 0x83 /* port 0, 1 control */ -#define PCI20000_DIO_CONTROL_23 0xc3 /* port 2, 3 control */ -#define PCI20000_DIO_BUFFER 0x82 /* buffer direction & enable */ -#define PCI20000_DIO_EOC 0xef /* even port, control output */ -#define PCI20000_DIO_OOC 0xfd /* odd port, control output */ -#define PCI20000_DIO_EIC 0x90 /* even port, control input */ -#define PCI20000_DIO_OIC 0x82 /* odd port, control input */ -#define DIO_CAND 0x12 /* and bit 1 & 4 of control */ -#define DIO_BE 0x01 /* buffer: port enable */ -#define DIO_BO 0x04 /* buffer: output */ -#define DIO_BI 0x05 /* buffer: input */ -#define DIO_PS_0 0x00 /* buffer: port shift 0 */ -#define DIO_PS_1 0x01 /* buffer: port shift 1 */ -#define DIO_PS_2 0x04 /* buffer: port shift 2 */ -#define DIO_PS_3 0x05 /* buffer: port shift 3 */ #define PCI20006_LCHAN0 0x0d #define PCI20006_STROBE0 0x0b @@ -351,103 +365,79 @@ static int pci20341_init(struct comedi_device *dev, struct comedi_subdevice *s, return 0; } -#if 0 -static void pci20xxx_do(struct comedi_device *dev, struct comedi_subdevice *s) -{ - struct pci20xxx_private *devpriv = dev->private; - - /* XXX if the channel is configured for input, does this - do bad things? */ - /* XXX it would be a good idea to only update the registers - that _need_ to be updated. This requires changes to - comedi, however. */ - writeb((s->state >> 0) & 0xff, devpriv->ioaddr + PCI20000_DIO_0); - writeb((s->state >> 8) & 0xff, devpriv->ioaddr + PCI20000_DIO_1); - writeb((s->state >> 16) & 0xff, devpriv->ioaddr + PCI20000_DIO_2); - writeb((s->state >> 24) & 0xff, devpriv->ioaddr + PCI20000_DIO_3); -} - -static unsigned int pci20xxx_di(struct comedi_device *dev, - struct comedi_subdevice *s) -{ - struct pci20xxx_private *devpriv = dev->private; - unsigned int bits; - - /* XXX same note as above */ - bits = readb(devpriv->ioaddr + PCI20000_DIO_0); - bits |= readb(devpriv->ioaddr + PCI20000_DIO_1) << 8; - bits |= readb(devpriv->ioaddr + PCI20000_DIO_2) << 16; - bits |= readb(devpriv->ioaddr + PCI20000_DIO_3) << 24; - - return bits; -} -#endif - -static void pci20xxx_dio_config(struct comedi_device *dev, - struct comedi_subdevice *s) +static void ii20k_dio_config(struct comedi_device *dev, + struct comedi_subdevice *s) { struct pci20xxx_private *devpriv = dev->private; - unsigned char control_01; - unsigned char control_23; - unsigned char buffer; - - control_01 = readb(devpriv->ioaddr + PCI20000_DIO_CONTROL_01); - control_23 = readb(devpriv->ioaddr + PCI20000_DIO_CONTROL_23); - buffer = readb(devpriv->ioaddr + PCI20000_DIO_BUFFER); + unsigned char ctrl01 = 0; + unsigned char ctrl23 = 0; + unsigned char dir_ena = 0; + /* port 0 - channels 0-7 */ if (s->io_bits & 0x000000ff) { - /* output port 0 */ - control_01 &= PCI20000_DIO_EOC; - buffer = (buffer & (~(DIO_BE << DIO_PS_0))) | (DIO_BO << - DIO_PS_0); + /* output port */ + ctrl01 &= ~II20K_CTRL01_DIO0_IN; + dir_ena &= ~II20K_BUF_DISAB_DIO0; + dir_ena |= II20K_DIR_DIO0_OUT; } else { - /* input port 0 */ - control_01 = (control_01 & DIO_CAND) | PCI20000_DIO_EIC; - buffer = (buffer & (~(DIO_BI << DIO_PS_0))); + /* input port */ + ctrl01 |= II20K_CTRL01_DIO0_IN; + dir_ena &= ~II20K_DIR_DIO0_OUT; } + + /* port 1 - channels 8-15 */ if (s->io_bits & 0x0000ff00) { - /* output port 1 */ - control_01 &= PCI20000_DIO_OOC; - buffer = (buffer & (~(DIO_BE << DIO_PS_1))) | (DIO_BO << - DIO_PS_1); + /* output port */ + ctrl01 &= ~II20K_CTRL01_DIO1_IN; + dir_ena &= ~II20K_BUF_DISAB_DIO1; + dir_ena |= II20K_DIR_DIO1_OUT; } else { - /* input port 1 */ - control_01 = (control_01 & DIO_CAND) | PCI20000_DIO_OIC; - buffer = (buffer & (~(DIO_BI << DIO_PS_1))); + /* input port */ + ctrl01 |= II20K_CTRL01_DIO1_IN; + dir_ena &= ~II20K_DIR_DIO1_OUT; } + + /* port 2 - channels 16-23 */ if (s->io_bits & 0x00ff0000) { - /* output port 2 */ - control_23 &= PCI20000_DIO_EOC; - buffer = (buffer & (~(DIO_BE << DIO_PS_2))) | (DIO_BO << - DIO_PS_2); + /* output port */ + ctrl23 &= ~II20K_CTRL23_DIO2_IN; + dir_ena &= ~II20K_BUF_DISAB_DIO2; + dir_ena |= II20K_DIR_DIO2_OUT; } else { - /* input port 2 */ - control_23 = (control_23 & DIO_CAND) | PCI20000_DIO_EIC; - buffer = (buffer & (~(DIO_BI << DIO_PS_2))); + /* input port */ + ctrl23 |= II20K_CTRL23_DIO2_IN; + dir_ena &= ~II20K_DIR_DIO2_OUT; } + + /* port 3 - channels 24-31 */ if (s->io_bits & 0xff000000) { - /* output port 3 */ - control_23 &= PCI20000_DIO_OOC; - buffer = (buffer & (~(DIO_BE << DIO_PS_3))) | (DIO_BO << - DIO_PS_3); + /* output port */ + ctrl23 &= ~II20K_CTRL23_DIO3_IN; + dir_ena &= ~II20K_BUF_DISAB_DIO3; + dir_ena |= II20K_DIR_DIO3_OUT; } else { - /* input port 3 */ - control_23 = (control_23 & DIO_CAND) | PCI20000_DIO_OIC; - buffer = (buffer & (~(DIO_BI << DIO_PS_3))); + /* input port */ + ctrl23 |= II20K_CTRL23_DIO3_IN; + dir_ena &= ~II20K_DIR_DIO3_OUT; } - writeb(control_01, devpriv->ioaddr + PCI20000_DIO_CONTROL_01); - writeb(control_23, devpriv->ioaddr + PCI20000_DIO_CONTROL_23); - writeb(buffer, devpriv->ioaddr + PCI20000_DIO_BUFFER); + + ctrl23 |= II20K_CTRL01_SET; + ctrl23 |= II20K_CTRL23_SET; + + /* order is important */ + writeb(ctrl01, devpriv->ioaddr + II20K_CTRL01_REG); + writeb(ctrl23, devpriv->ioaddr + II20K_CTRL23_REG); + writeb(dir_ena, devpriv->ioaddr + II20K_DIR_ENA_REG); } -static int pci20xxx_dio_insn_config(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) +static int ii20k_dio_insn_config(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { - int mask, bits; + unsigned int mask = 1 << CR_CHAN(insn->chanspec); + unsigned int bits; - mask = 1 << CR_CHAN(insn->chanspec); if (mask & 0x000000ff) bits = 0x000000ff; else if (mask & 0x0000ff00) @@ -456,79 +446,71 @@ static int pci20xxx_dio_insn_config(struct comedi_device *dev, bits = 0x00ff0000; else bits = 0xff000000; - if (data[0]) - s->io_bits |= bits; - else + + switch (data[0]) { + case INSN_CONFIG_DIO_INPUT: s->io_bits &= ~bits; - pci20xxx_dio_config(dev, s); + break; + case INSN_CONFIG_DIO_OUTPUT: + s->io_bits |= bits; + break; + case INSN_CONFIG_DIO_QUERY: + data[1] = (s->io_bits & bits) ? COMEDI_OUTPUT : COMEDI_INPUT; + return insn->n; + default: + return -EINVAL; + } - return 1; + ii20k_dio_config(dev, s); + + return insn->n; } -static int pci20xxx_dio_insn_bits(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int ii20k_dio_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { struct pci20xxx_private *devpriv = dev->private; - unsigned int mask = data[0]; - - s->state &= ~mask; - s->state |= (mask & data[1]); + unsigned int mask = data[0] & s->io_bits; /* outputs only */ + unsigned int bits = data[1]; + + if (mask) { + s->state &= ~mask; + s->state |= (bits & mask); + + if (mask & 0x000000ff) + writeb((s->state >> 0) & 0xff, + devpriv->ioaddr + II20K_DIO0_REG); + if (mask & 0x0000ff00) + writeb((s->state >> 8) & 0xff, + devpriv->ioaddr + II20K_DIO1_REG); + if (mask & 0x00ff0000) + writeb((s->state >> 16) & 0xff, + devpriv->ioaddr + II20K_DIO2_REG); + if (mask & 0xff000000) + writeb((s->state >> 24) & 0xff, + devpriv->ioaddr + II20K_DIO3_REG); + } - mask &= s->io_bits; - if (mask & 0x000000ff) - writeb((s->state >> 0) & 0xff, - devpriv->ioaddr + PCI20000_DIO_0); - if (mask & 0x0000ff00) - writeb((s->state >> 8) & 0xff, - devpriv->ioaddr + PCI20000_DIO_1); - if (mask & 0x00ff0000) - writeb((s->state >> 16) & 0xff, - devpriv->ioaddr + PCI20000_DIO_2); - if (mask & 0xff000000) - writeb((s->state >> 24) & 0xff, - devpriv->ioaddr + PCI20000_DIO_3); - - data[1] = readb(devpriv->ioaddr + PCI20000_DIO_0); - data[1] |= readb(devpriv->ioaddr + PCI20000_DIO_1) << 8; - data[1] |= readb(devpriv->ioaddr + PCI20000_DIO_2) << 16; - data[1] |= readb(devpriv->ioaddr + PCI20000_DIO_3) << 24; + data[1] = readb(devpriv->ioaddr + II20K_DIO0_REG); + data[1] |= readb(devpriv->ioaddr + II20K_DIO1_REG) << 8; + data[1] |= readb(devpriv->ioaddr + II20K_DIO2_REG) << 16; + data[1] |= readb(devpriv->ioaddr + II20K_DIO3_REG) << 24; return insn->n; } -static int pci20xxx_dio_init(struct comedi_device *dev, - struct comedi_subdevice *s) -{ - s->type = COMEDI_SUBD_DIO; - s->subdev_flags = SDF_READABLE | SDF_WRITABLE; - s->n_chan = 32; - s->insn_bits = pci20xxx_dio_insn_bits; - s->insn_config = pci20xxx_dio_insn_config; - s->maxdata = 1; - s->len_chanlist = 32; - s->range_table = &range_digital; - s->io_bits = 0; - - /* digital I/O lines default to input on board reset. */ - pci20xxx_dio_config(dev, s); - - return 0; -} - static int pci20xxx_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct pci20xxx_private *devpriv; - unsigned char i; - int ret; - int id; - struct comedi_subdevice *s; union pci20xxx_subdev_private *sdp; - - ret = comedi_alloc_subdevices(dev, 1 + PCI20000_MODULES); - if (ret) - return ret; + struct comedi_subdevice *s; + unsigned char id; + bool has_dio; + int ret; + int i; devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) @@ -536,17 +518,22 @@ static int pci20xxx_attach(struct comedi_device *dev, devpriv->ioaddr = (void __iomem *)(unsigned long)it->options[0]; - /* Check PCI-20001 C-2A Carrier Board ID */ - if ((readb(devpriv->ioaddr) & PCI20000_ID) != PCI20000_ID) { - dev_warn(dev->class_dev, - "PCI-20001 C-2A Carrier Board at base=0x%p not found !\n", - devpriv->ioaddr); - return -EINVAL; + id = readb(devpriv->ioaddr + II20K_ID_REG); + switch (id & II20K_ID_MASK) { + case II20K_ID_PCI20001C_1A: + break; + case II20K_ID_PCI20001C_2A: + has_dio = true; + break; + default: + return -ENODEV; } - dev_info(dev->class_dev, "PCI-20001 C-2A at base=0x%p\n", - devpriv->ioaddr); - for (i = 0; i < PCI20000_MODULES; i++) { + ret = comedi_alloc_subdevices(dev, 4); + if (ret) + return ret; + + for (i = 0; i < 3; i++) { s = &dev->subdevices[i]; sdp = comedi_alloc_spriv(s, sizeof(*sdp)); if (!sdp) @@ -580,8 +567,22 @@ static int pci20xxx_attach(struct comedi_device *dev, } } - /* initialize struct pci20xxx_private */ - pci20xxx_dio_init(dev, &dev->subdevices[PCI20000_MODULES]); + /* Digital I/O subdevice */ + s = &dev->subdevices[3]; + if (has_dio) { + s->type = COMEDI_SUBD_DIO; + s->subdev_flags = SDF_READABLE | SDF_WRITABLE; + s->n_chan = 32; + s->maxdata = 1; + s->range_table = &range_digital; + s->insn_bits = ii20k_dio_insn_bits; + s->insn_config = ii20k_dio_insn_config; + + /* default all channels to input */ + ii20k_dio_config(dev, s); + } else { + s->type = COMEDI_SUBD_UNUSED; + } return 1; } -- GitLab From f0e32df3d21f048ee35c07e523e918015845d95f Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 12:11:47 -0700 Subject: [PATCH 252/942] staging: comedi: ii_pci20kc.c: tidy up the subdevice module init Use the carrier board id to determine if a module is installed for a given subdevice. Consolidate the module init code into ii20k_init_module(). For aesthetic reasons, rename the subdevice functions to remove 'pci' from them. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ii_pci20kc.c | 197 +++++++++++--------- 1 file changed, 104 insertions(+), 93 deletions(-) diff --git a/drivers/staging/comedi/drivers/ii_pci20kc.c b/drivers/staging/comedi/drivers/ii_pci20kc.c index 60a3bb2c36579..14721b2832ac4 100644 --- a/drivers/staging/comedi/drivers/ii_pci20kc.c +++ b/drivers/staging/comedi/drivers/ii_pci20kc.c @@ -83,6 +83,7 @@ options for PCI-20341M: /* * Register I/O map */ +#define II20K_MOD_OFFSET 0x100 #define II20K_ID_REG 0x00 #define II20K_ID_MOD1_EMPTY (1 << 7) #define II20K_ID_MOD2_EMPTY (1 << 6) @@ -120,8 +121,6 @@ options for PCI-20341M: #define PCI20006_ID 0xe3 #define PCI20xxx_EMPTY_ID 0xff -#define PCI20000_OFFSET 0x100 - #define PCI20006_LCHAN0 0x0d #define PCI20006_STROBE0 0x0b #define PCI20006_LCHAN1 0x15 @@ -130,7 +129,6 @@ options for PCI-20341M: #define PCI20341_INIT 0x04 #define PCI20341_REPMODE 0x00 /* single shot mode */ #define PCI20341_PACER 0x00 /* Hardware Pacer disabled */ -#define PCI20341_CHAN_NR 0x04 /* number of input channels */ #define PCI20341_CONFIG_REG 0x10 #define PCI20341_MOD_STATUS 0x01 #define PCI20341_OPT_REG 0x11 @@ -164,13 +162,13 @@ static const struct comedi_lrange range_bipolar0_025 = { } }; -static const struct comedi_lrange *pci20006_range_list[] = { +static const struct comedi_lrange *ii20k_ao_ranges[] = { &range_bipolar10, &range_unipolar10, &range_bipolar5, }; -static const struct comedi_lrange *const pci20341_ranges[] = { +static const struct comedi_lrange *const ii20k_ai_ranges[] = { &range_bipolar5, &range_bipolar0_5, &range_bipolar0_05, @@ -200,11 +198,10 @@ struct pci20xxx_private { void __iomem *ioaddr; }; -/* pci20006m */ - -static int pci20006_insn_read(struct comedi_device *dev, +static int ii20k_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { union pci20xxx_subdev_private *sdp = s->private; @@ -213,9 +210,10 @@ static int pci20006_insn_read(struct comedi_device *dev, return 1; } -static int pci20006_insn_write(struct comedi_device *dev, +static int ii20k_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { union pci20xxx_subdev_private *sdp = s->private; int hi, lo; @@ -246,36 +244,10 @@ static int pci20006_insn_write(struct comedi_device *dev, return 1; } -static int pci20006_init(struct comedi_device *dev, struct comedi_subdevice *s, - int opt0, int opt1) -{ - union pci20xxx_subdev_private *sdp = s->private; - - if (opt0 < 0 || opt0 > 2) - opt0 = 0; - if (opt1 < 0 || opt1 > 2) - opt1 = 0; - - sdp->pci20006.ao_range_list[0] = pci20006_range_list[opt0]; - sdp->pci20006.ao_range_list[1] = pci20006_range_list[opt1]; - - /* ao subdevice */ - s->type = COMEDI_SUBD_AO; - s->subdev_flags = SDF_WRITABLE; - s->n_chan = 2; - s->len_chanlist = 2; - s->insn_read = pci20006_insn_read; - s->insn_write = pci20006_insn_write; - s->maxdata = 0xffff; - s->range_table_list = sdp->pci20006.ao_range_list; - return 0; -} - -/* PCI20341M */ - -static int pci20341_insn_read(struct comedi_device *dev, +static int ii20k_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { union pci20xxx_subdev_private *sdp = s->private; unsigned int i = 0, j = 0; @@ -328,26 +300,11 @@ static int pci20341_insn_read(struct comedi_device *dev, return i; } -static int pci20341_init(struct comedi_device *dev, struct comedi_subdevice *s, - int opt0, int opt1) +static void ii20k_ai_init(struct comedi_device *dev, + struct comedi_subdevice *s) { union pci20xxx_subdev_private *sdp = s->private; - int option; - - /* options handling */ - if (opt0 < 0 || opt0 > 3) - opt0 = 0; - sdp->pci20341.timebase = pci20341_timebase[opt0]; - sdp->pci20341.settling_time = pci20341_settling_time[opt0]; - - /* ai subdevice */ - s->type = COMEDI_SUBD_AI; - s->subdev_flags = SDF_READABLE; - s->n_chan = PCI20341_CHAN_NR; - s->len_chanlist = PCI20341_SCANLIST; - s->insn_read = pci20341_insn_read; - s->maxdata = 0xffff; - s->range_table = pci20341_ranges[opt0]; + unsigned char option; /* depends on gain, trigger, repetition mode */ option = sdp->pci20341.timebase | PCI20341_REPMODE; @@ -362,7 +319,6 @@ static int pci20341_init(struct comedi_device *dev, struct comedi_subdevice *s, writeb(sdp->pci20341.settling_time, sdp->iobase + PCI20341_SET_TIME_REG); /* trigger not implemented */ - return 0; } static void ii20k_dio_config(struct comedi_device *dev, @@ -501,16 +457,78 @@ static int ii20k_dio_insn_bits(struct comedi_device *dev, return insn->n; } +static int ii20k_init_module(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_devconfig *it) +{ + struct pci20xxx_private *devpriv = dev->private; + union pci20xxx_subdev_private *sdp; + unsigned int opt0 = it->options[(2 * s->index) + 2]; + unsigned int opt1 = it->options[(2 * s->index) + 3]; + void __iomem *iobase; + unsigned char id; + + sdp = comedi_alloc_spriv(s, sizeof(*sdp)); + if (!sdp) + return -ENOMEM; + + iobase = devpriv->ioaddr + (s->index + 1) * II20K_MOD_OFFSET; + id = readb(iobase + II20K_ID_REG); + switch (id) { + case PCI20006_ID: + if (opt0 < 0 || opt0 > 2) + opt0 = 0; + if (opt1 < 0 || opt1 > 2) + opt1 = 0; + + sdp->pci20006.iobase = iobase; + sdp->pci20006.ao_range_list[0] = ii20k_ao_ranges[opt0]; + sdp->pci20006.ao_range_list[1] = ii20k_ao_ranges[opt1]; + + /* Analog Output subdevice */ + s->type = COMEDI_SUBD_AO; + s->subdev_flags = SDF_WRITABLE; + s->n_chan = 2; + s->maxdata = 0xffff; + s->range_table_list = sdp->pci20006.ao_range_list; + s->insn_read = ii20k_ao_insn_read; + s->insn_write = ii20k_ao_insn_write; + break; + case PCI20341_ID: + if (opt0 < 0 || opt0 > 3) + opt0 = 0; + + sdp->pci20341.iobase = iobase; + sdp->pci20341.timebase = pci20341_timebase[opt0]; + sdp->pci20341.settling_time = pci20341_settling_time[opt0]; + + /* Analog Input subdevice */ + s->type = COMEDI_SUBD_AI; + s->subdev_flags = SDF_READABLE; + s->n_chan = 4; + s->maxdata = 0xffff; + s->range_table = ii20k_ai_ranges[opt0]; + s->insn_read = ii20k_ai_insn_read; + + ii20k_ai_init(dev, s); + break; + case PCI20xxx_EMPTY_ID: + default: + s->type = COMEDI_SUBD_UNUSED; + break; + } + + return 0; +} + static int pci20xxx_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct pci20xxx_private *devpriv; - union pci20xxx_subdev_private *sdp; struct comedi_subdevice *s; unsigned char id; bool has_dio; int ret; - int i; devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); if (!devpriv) @@ -533,38 +551,31 @@ static int pci20xxx_attach(struct comedi_device *dev, if (ret) return ret; - for (i = 0; i < 3; i++) { - s = &dev->subdevices[i]; - sdp = comedi_alloc_spriv(s, sizeof(*sdp)); - if (!sdp) - return -ENOMEM; - id = readb(devpriv->ioaddr + (i + 1) * PCI20000_OFFSET); - switch (id) { - case PCI20006_ID: - sdp->pci20006.iobase = - devpriv->ioaddr + (i + 1) * PCI20000_OFFSET; - pci20006_init(dev, s, it->options[2 * i + 2], - it->options[2 * i + 3]); - dev_info(dev->class_dev, - "PCI-20006 module in slot %d\n", i + 1); - break; - case PCI20341_ID: - sdp->pci20341.iobase = - devpriv->ioaddr + (i + 1) * PCI20000_OFFSET; - pci20341_init(dev, s, it->options[2 * i + 2], - it->options[2 * i + 3]); - dev_info(dev->class_dev, - "PCI-20341 module in slot %d\n", i + 1); - break; - default: - dev_warn(dev->class_dev, - "unknown module code 0x%02x in slot %d: module disabled\n", - id, i); /* XXX this looks like a bug! i + 1 ?? */ - /* fall through */ - case PCI20xxx_EMPTY_ID: - s->type = COMEDI_SUBD_UNUSED; - break; - } + s = &dev->subdevices[0]; + if (id & II20K_ID_MOD1_EMPTY) { + s->type = COMEDI_SUBD_UNUSED; + } else { + ret = ii20k_init_module(dev, s, it); + if (ret) + return ret; + } + + s = &dev->subdevices[1]; + if (id & II20K_ID_MOD2_EMPTY) { + s->type = COMEDI_SUBD_UNUSED; + } else { + ret = ii20k_init_module(dev, s, it); + if (ret) + return ret; + } + + s = &dev->subdevices[2]; + if (id & II20K_ID_MOD3_EMPTY) { + s->type = COMEDI_SUBD_UNUSED; + } else { + ret = ii20k_init_module(dev, s, it); + if (ret) + return ret; } /* Digital I/O subdevice */ -- GitLab From 57b2161f021c26f56574edfaaaa9503f877fc1a2 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 12:12:09 -0700 Subject: [PATCH 253/942] staging: comedi: ii_pci20kc.c: remove 'iobase' from the subdevice private data The 'iobase' can be calculated when needed. Remove it from the subdevice private data. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ii_pci20kc.c | 58 +++++++++++---------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/drivers/staging/comedi/drivers/ii_pci20kc.c b/drivers/staging/comedi/drivers/ii_pci20kc.c index 14721b2832ac4..888c6c32257a0 100644 --- a/drivers/staging/comedi/drivers/ii_pci20kc.c +++ b/drivers/staging/comedi/drivers/ii_pci20kc.c @@ -179,15 +179,12 @@ static const int pci20341_timebase[] = { 0x00, 0x00, 0x00, 0x04 }; static const int pci20341_settling_time[] = { 0x58, 0x58, 0x93, 0x99 }; union pci20xxx_subdev_private { - void __iomem *iobase; struct { - void __iomem *iobase; const struct comedi_lrange *ao_range_list[2]; /* range of channels of ao module */ unsigned int last_data[2]; } pci20006; struct { - void __iomem *iobase; int timebase; int settling_time; int ai_gain; @@ -198,6 +195,14 @@ struct pci20xxx_private { void __iomem *ioaddr; }; +static void __iomem *ii20k_module_iobase(struct comedi_device *dev, + struct comedi_subdevice *s) +{ + struct pci20xxx_private *devpriv = dev->private; + + return devpriv->ioaddr + (s->index + 1) * II20K_MOD_OFFSET; +} + static int ii20k_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, @@ -216,6 +221,7 @@ static int ii20k_ao_insn_write(struct comedi_device *dev, unsigned int *data) { union pci20xxx_subdev_private *sdp = s->private; + void __iomem *iobase = ii20k_module_iobase(dev, s); int hi, lo; unsigned int boarddata; @@ -227,14 +233,14 @@ static int ii20k_ao_insn_write(struct comedi_device *dev, switch (CR_CHAN(insn->chanspec)) { case 0: - writeb(lo, sdp->iobase + PCI20006_LCHAN0); - writeb(hi, sdp->iobase + PCI20006_LCHAN0 + 1); - writeb(0x00, sdp->iobase + PCI20006_STROBE0); + writeb(lo, iobase + PCI20006_LCHAN0); + writeb(hi, iobase + PCI20006_LCHAN0 + 1); + writeb(0x00, iobase + PCI20006_STROBE0); break; case 1: - writeb(lo, sdp->iobase + PCI20006_LCHAN1); - writeb(hi, sdp->iobase + PCI20006_LCHAN1 + 1); - writeb(0x00, sdp->iobase + PCI20006_STROBE1); + writeb(lo, iobase + PCI20006_LCHAN1); + writeb(hi, iobase + PCI20006_LCHAN1 + 1); + writeb(0x00, iobase + PCI20006_STROBE1); break; default: dev_warn(dev->class_dev, "ao channel Error!\n"); @@ -250,6 +256,7 @@ static int ii20k_ai_insn_read(struct comedi_device *dev, unsigned int *data) { union pci20xxx_subdev_private *sdp = s->private; + void __iomem *iobase = ii20k_module_iobase(dev, s); unsigned int i = 0, j = 0; int lo, hi; unsigned char eoc; /* end of conversion */ @@ -257,15 +264,15 @@ static int ii20k_ai_insn_read(struct comedi_device *dev, unsigned int boarddata; /* write number of input channels */ - writeb(1, sdp->iobase + PCI20341_LCHAN_ADDR_REG); + writeb(1, iobase + PCI20341_LCHAN_ADDR_REG); clb = PCI20341_DAISY_CHAIN | PCI20341_MUX | (sdp->pci20341.ai_gain << 3) | CR_CHAN(insn->chanspec); - writeb(clb, sdp->iobase + PCI20341_CHAN_LIST); + writeb(clb, iobase + PCI20341_CHAN_LIST); /* reset settling time counter and trigger delay counter */ - writeb(0x00, sdp->iobase + PCI20341_CC_RESET); + writeb(0x00, iobase + PCI20341_CC_RESET); - writeb(0x00, sdp->iobase + PCI20341_CHAN_RESET); + writeb(0x00, iobase + PCI20341_CHAN_RESET); /* generate Pacer */ @@ -276,21 +283,21 @@ static int ii20k_ai_insn_read(struct comedi_device *dev, */ j = 0; /* generate Pacer */ - readb(sdp->iobase + PCI20341_SOFT_PACER); + readb(iobase + PCI20341_SOFT_PACER); - eoc = readb(sdp->iobase + PCI20341_STATUS_REG); + eoc = readb(iobase + PCI20341_STATUS_REG); /* poll Interrupt Flag */ while ((eoc < 0x80) && j < 100) { j++; - eoc = readb(sdp->iobase + PCI20341_STATUS_REG); + eoc = readb(iobase + PCI20341_STATUS_REG); } if (j >= 100) { dev_warn(dev->class_dev, "AI interrupt channel %i polling exit !\n", i); return -EINVAL; } - lo = readb(sdp->iobase + PCI20341_LDATA); - hi = readb(sdp->iobase + PCI20341_LDATA + 1); + lo = readb(iobase + PCI20341_LDATA); + hi = readb(iobase + PCI20341_LDATA + 1); boarddata = lo + 0x100 * hi; /* board-data -> comedi-data */ @@ -304,20 +311,21 @@ static void ii20k_ai_init(struct comedi_device *dev, struct comedi_subdevice *s) { union pci20xxx_subdev_private *sdp = s->private; + void __iomem *iobase = ii20k_module_iobase(dev, s); unsigned char option; /* depends on gain, trigger, repetition mode */ option = sdp->pci20341.timebase | PCI20341_REPMODE; /* initialize Module */ - writeb(PCI20341_INIT, sdp->iobase + PCI20341_CONFIG_REG); + writeb(PCI20341_INIT, iobase + PCI20341_CONFIG_REG); /* set Pacer */ - writeb(PCI20341_PACER, sdp->iobase + PCI20341_MOD_STATUS); + writeb(PCI20341_PACER, iobase + PCI20341_MOD_STATUS); /* option register */ - writeb(option, sdp->iobase + PCI20341_OPT_REG); + writeb(option, iobase + PCI20341_OPT_REG); /* settling time counter */ writeb(sdp->pci20341.settling_time, - sdp->iobase + PCI20341_SET_TIME_REG); + iobase + PCI20341_SET_TIME_REG); /* trigger not implemented */ } @@ -461,18 +469,16 @@ static int ii20k_init_module(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_devconfig *it) { - struct pci20xxx_private *devpriv = dev->private; union pci20xxx_subdev_private *sdp; + void __iomem *iobase = ii20k_module_iobase(dev, s); unsigned int opt0 = it->options[(2 * s->index) + 2]; unsigned int opt1 = it->options[(2 * s->index) + 3]; - void __iomem *iobase; unsigned char id; sdp = comedi_alloc_spriv(s, sizeof(*sdp)); if (!sdp) return -ENOMEM; - iobase = devpriv->ioaddr + (s->index + 1) * II20K_MOD_OFFSET; id = readb(iobase + II20K_ID_REG); switch (id) { case PCI20006_ID: @@ -481,7 +487,6 @@ static int ii20k_init_module(struct comedi_device *dev, if (opt1 < 0 || opt1 > 2) opt1 = 0; - sdp->pci20006.iobase = iobase; sdp->pci20006.ao_range_list[0] = ii20k_ao_ranges[opt0]; sdp->pci20006.ao_range_list[1] = ii20k_ao_ranges[opt1]; @@ -498,7 +503,6 @@ static int ii20k_init_module(struct comedi_device *dev, if (opt0 < 0 || opt0 > 3) opt0 = 0; - sdp->pci20341.iobase = iobase; sdp->pci20341.timebase = pci20341_timebase[opt0]; sdp->pci20341.settling_time = pci20341_settling_time[opt0]; -- GitLab From 04815a4b5e2d1b3a741326f75c500382a55f7968 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 12:12:30 -0700 Subject: [PATCH 254/942] staging: comedi: ii_pci20kc.c: break up the subdevice private data union The union used for the subdevice private data just adds confusion. Split the union into two separate private data structs. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ii_pci20kc.c | 64 +++++++++++---------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/drivers/staging/comedi/drivers/ii_pci20kc.c b/drivers/staging/comedi/drivers/ii_pci20kc.c index 888c6c32257a0..e86a2b5399ce0 100644 --- a/drivers/staging/comedi/drivers/ii_pci20kc.c +++ b/drivers/staging/comedi/drivers/ii_pci20kc.c @@ -178,17 +178,15 @@ static const struct comedi_lrange *const ii20k_ai_ranges[] = { static const int pci20341_timebase[] = { 0x00, 0x00, 0x00, 0x04 }; static const int pci20341_settling_time[] = { 0x58, 0x58, 0x93, 0x99 }; -union pci20xxx_subdev_private { - struct { - const struct comedi_lrange *ao_range_list[2]; - /* range of channels of ao module */ - unsigned int last_data[2]; - } pci20006; - struct { - int timebase; - int settling_time; - int ai_gain; - } pci20341; +struct ii20k_ao_private { + const struct comedi_lrange *ao_range_list[2]; + unsigned int last_data[2]; +}; + +struct ii20k_ai_private { + int timebase; + int settling_time; + int ai_gain; }; struct pci20xxx_private { @@ -208,9 +206,9 @@ static int ii20k_ao_insn_read(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - union pci20xxx_subdev_private *sdp = s->private; + struct ii20k_ao_private *ao_spriv = s->private; - data[0] = sdp->pci20006.last_data[CR_CHAN(insn->chanspec)]; + data[0] = ao_spriv->last_data[CR_CHAN(insn->chanspec)]; return 1; } @@ -220,12 +218,12 @@ static int ii20k_ao_insn_write(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - union pci20xxx_subdev_private *sdp = s->private; + struct ii20k_ao_private *ao_spriv = s->private; void __iomem *iobase = ii20k_module_iobase(dev, s); int hi, lo; unsigned int boarddata; - sdp->pci20006.last_data[CR_CHAN(insn->chanspec)] = data[0]; + ao_spriv->last_data[CR_CHAN(insn->chanspec)] = data[0]; boarddata = (((unsigned int)data[0] + 0x8000) & 0xffff); /* comedi-data -> board-data */ lo = (boarddata & 0xff); @@ -255,7 +253,7 @@ static int ii20k_ai_insn_read(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - union pci20xxx_subdev_private *sdp = s->private; + struct ii20k_ai_private *ai_spriv = s->private; void __iomem *iobase = ii20k_module_iobase(dev, s); unsigned int i = 0, j = 0; int lo, hi; @@ -265,7 +263,7 @@ static int ii20k_ai_insn_read(struct comedi_device *dev, /* write number of input channels */ writeb(1, iobase + PCI20341_LCHAN_ADDR_REG); - clb = PCI20341_DAISY_CHAIN | PCI20341_MUX | (sdp->pci20341.ai_gain << 3) + clb = PCI20341_DAISY_CHAIN | PCI20341_MUX | (ai_spriv->ai_gain << 3) | CR_CHAN(insn->chanspec); writeb(clb, iobase + PCI20341_CHAN_LIST); @@ -310,12 +308,12 @@ static int ii20k_ai_insn_read(struct comedi_device *dev, static void ii20k_ai_init(struct comedi_device *dev, struct comedi_subdevice *s) { - union pci20xxx_subdev_private *sdp = s->private; + struct ii20k_ai_private *ai_spriv = s->private; void __iomem *iobase = ii20k_module_iobase(dev, s); unsigned char option; /* depends on gain, trigger, repetition mode */ - option = sdp->pci20341.timebase | PCI20341_REPMODE; + option = ai_spriv->timebase | PCI20341_REPMODE; /* initialize Module */ writeb(PCI20341_INIT, iobase + PCI20341_CONFIG_REG); @@ -324,8 +322,7 @@ static void ii20k_ai_init(struct comedi_device *dev, /* option register */ writeb(option, iobase + PCI20341_OPT_REG); /* settling time counter */ - writeb(sdp->pci20341.settling_time, - iobase + PCI20341_SET_TIME_REG); + writeb(ai_spriv->settling_time, iobase + PCI20341_SET_TIME_REG); /* trigger not implemented */ } @@ -469,16 +466,13 @@ static int ii20k_init_module(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_devconfig *it) { - union pci20xxx_subdev_private *sdp; + struct ii20k_ao_private *ao_spriv; + struct ii20k_ai_private *ai_spriv; void __iomem *iobase = ii20k_module_iobase(dev, s); unsigned int opt0 = it->options[(2 * s->index) + 2]; unsigned int opt1 = it->options[(2 * s->index) + 3]; unsigned char id; - sdp = comedi_alloc_spriv(s, sizeof(*sdp)); - if (!sdp) - return -ENOMEM; - id = readb(iobase + II20K_ID_REG); switch (id) { case PCI20006_ID: @@ -487,15 +481,19 @@ static int ii20k_init_module(struct comedi_device *dev, if (opt1 < 0 || opt1 > 2) opt1 = 0; - sdp->pci20006.ao_range_list[0] = ii20k_ao_ranges[opt0]; - sdp->pci20006.ao_range_list[1] = ii20k_ao_ranges[opt1]; + ao_spriv = comedi_alloc_spriv(s, sizeof(*ao_spriv)); + if (!ao_spriv) + return -ENOMEM; + + ao_spriv->ao_range_list[0] = ii20k_ao_ranges[opt0]; + ao_spriv->ao_range_list[1] = ii20k_ao_ranges[opt1]; /* Analog Output subdevice */ s->type = COMEDI_SUBD_AO; s->subdev_flags = SDF_WRITABLE; s->n_chan = 2; s->maxdata = 0xffff; - s->range_table_list = sdp->pci20006.ao_range_list; + s->range_table_list = ao_spriv->ao_range_list; s->insn_read = ii20k_ao_insn_read; s->insn_write = ii20k_ao_insn_write; break; @@ -503,8 +501,12 @@ static int ii20k_init_module(struct comedi_device *dev, if (opt0 < 0 || opt0 > 3) opt0 = 0; - sdp->pci20341.timebase = pci20341_timebase[opt0]; - sdp->pci20341.settling_time = pci20341_settling_time[opt0]; + ai_spriv = comedi_alloc_spriv(s, sizeof(*ai_spriv)); + if (!ai_spriv) + return -ENOMEM; + + ai_spriv->timebase = pci20341_timebase[opt0]; + ai_spriv->settling_time = pci20341_settling_time[opt0]; /* Analog Input subdevice */ s->type = COMEDI_SUBD_AI; -- GitLab From 87a61614e3cd841cb6d73878b46d8e858418e536 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 12:13:04 -0700 Subject: [PATCH 255/942] staging: comedi: ii_pci20kc: cleanup the ao subdevice The PCI-20006M-1 and PCI-20006M-2 modules can both provide an analog output subdevice in this driver. Fix the module init code to detect both of them. The analog output can support +/-5, 0-10, or +/-10 volt ranges depending on jumpers on the board. Report all the ranges to the user instead of relying on the configuration options to set the range. The user can then select the appropriate range depending on how they have configured the hardware. Tidy up the (*insn_{read,write})() functions to work like the comedi core expects. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ii_pci20kc.c | 95 +++++++++------------ 1 file changed, 40 insertions(+), 55 deletions(-) diff --git a/drivers/staging/comedi/drivers/ii_pci20kc.c b/drivers/staging/comedi/drivers/ii_pci20kc.c index e86a2b5399ce0..1119a1a33135c 100644 --- a/drivers/staging/comedi/drivers/ii_pci20kc.c +++ b/drivers/staging/comedi/drivers/ii_pci20kc.c @@ -63,11 +63,6 @@ the other carrier boards with small modifications. Modules supported 7 second option for module 3 options for PCI-20006M: - first: Analog output channel 0 range configuration - 0 bipolar 10 (-10V -- +10V) - 1 unipolar 10 (0V -- +10V) - 2 bipolar 5 (-5V -- 5V) - second: Analog output channel 1 range configuration options for PCI-20341M: first: Analog input gain configuration @@ -117,15 +112,16 @@ options for PCI-20341M: #define II20K_CTRL23_DIO2_IN (1 << 4) #define II20K_CTRL23_DIO3_IN (1 << 1) +#define II20K_ID_PCI20006M_1 0xe2 /* 1 AO channels */ +#define II20K_ID_PCI20006M_2 0xe3 /* 2 AO channels */ +#define II20K_AO_STRB_REG(x) (0x0b + ((x) * 0x08)) +#define II20K_AO_LSB_REG(x) (0x0d + ((x) * 0x08)) +#define II20K_AO_MSB_REG(x) (0x0e + ((x) * 0x08)) +#define II20K_AO_STRB_BOTH_REG 0x1b + #define PCI20341_ID 0x77 -#define PCI20006_ID 0xe3 #define PCI20xxx_EMPTY_ID 0xff -#define PCI20006_LCHAN0 0x0d -#define PCI20006_STROBE0 0x0b -#define PCI20006_LCHAN1 0x15 -#define PCI20006_STROBE1 0x13 - #define PCI20341_INIT 0x04 #define PCI20341_REPMODE 0x00 /* single shot mode */ #define PCI20341_PACER 0x00 /* Hardware Pacer disabled */ @@ -144,6 +140,14 @@ options for PCI-20341M: #define PCI20341_MUX 0x04 /* Enable on-board MUX */ #define PCI20341_SCANLIST 0x80 /* Channel/Gain Scan List */ +/* the AO range is set by jumpers on the 20006M module */ +static const struct comedi_lrange ii20k_ao_ranges = { + 3, { + BIP_RANGE(5), /* Chan 0 - W1/W3 in Chan 1 - W2/W4 in */ + UNI_RANGE(10), /* Chan 0 - W1/W3 out Chan 1 - W2/W4 in */ + BIP_RANGE(10) /* Chan 0 - W1/W3 in Chan 1 - W2/W4 out */ + } +}; static const struct comedi_lrange range_bipolar0_5 = { 1, { BIP_RANGE(0.5) @@ -162,12 +166,6 @@ static const struct comedi_lrange range_bipolar0_025 = { } }; -static const struct comedi_lrange *ii20k_ao_ranges[] = { - &range_bipolar10, - &range_unipolar10, - &range_bipolar5, -}; - static const struct comedi_lrange *const ii20k_ai_ranges[] = { &range_bipolar5, &range_bipolar0_5, @@ -179,7 +177,6 @@ static const int pci20341_timebase[] = { 0x00, 0x00, 0x00, 0x04 }; static const int pci20341_settling_time[] = { 0x58, 0x58, 0x93, 0x99 }; struct ii20k_ao_private { - const struct comedi_lrange *ao_range_list[2]; unsigned int last_data[2]; }; @@ -207,10 +204,13 @@ static int ii20k_ao_insn_read(struct comedi_device *dev, unsigned int *data) { struct ii20k_ao_private *ao_spriv = s->private; + unsigned int chan = CR_CHAN(insn->chanspec); + int i; - data[0] = ao_spriv->last_data[CR_CHAN(insn->chanspec)]; + for (i = 0; i < insn->n; i++) + data[i] = ao_spriv->last_data[chan]; - return 1; + return insn->n; } static int ii20k_ao_insn_write(struct comedi_device *dev, @@ -220,32 +220,25 @@ static int ii20k_ao_insn_write(struct comedi_device *dev, { struct ii20k_ao_private *ao_spriv = s->private; void __iomem *iobase = ii20k_module_iobase(dev, s); - int hi, lo; - unsigned int boarddata; + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned int val = ao_spriv->last_data[chan]; + int i; - ao_spriv->last_data[CR_CHAN(insn->chanspec)] = data[0]; - boarddata = (((unsigned int)data[0] + 0x8000) & 0xffff); - /* comedi-data -> board-data */ - lo = (boarddata & 0xff); - hi = ((boarddata >> 8) & 0xff); - - switch (CR_CHAN(insn->chanspec)) { - case 0: - writeb(lo, iobase + PCI20006_LCHAN0); - writeb(hi, iobase + PCI20006_LCHAN0 + 1); - writeb(0x00, iobase + PCI20006_STROBE0); - break; - case 1: - writeb(lo, iobase + PCI20006_LCHAN1); - writeb(hi, iobase + PCI20006_LCHAN1 + 1); - writeb(0x00, iobase + PCI20006_STROBE1); - break; - default: - dev_warn(dev->class_dev, "ao channel Error!\n"); - return -EINVAL; + for (i = 0; i < insn->n; i++) { + val = data[i]; + + /* munge data */ + val += ((s->maxdata + 1) >> 1); + val &= s->maxdata; + + writeb(val & 0xff, iobase + II20K_AO_LSB_REG(chan)); + writeb((val >> 8) & 0xff, iobase + II20K_AO_MSB_REG(chan)); + writeb(0x00, iobase + II20K_AO_STRB_REG(chan)); } - return 1; + ao_spriv->last_data[chan] = val; + + return insn->n; } static int ii20k_ai_insn_read(struct comedi_device *dev, @@ -470,30 +463,22 @@ static int ii20k_init_module(struct comedi_device *dev, struct ii20k_ai_private *ai_spriv; void __iomem *iobase = ii20k_module_iobase(dev, s); unsigned int opt0 = it->options[(2 * s->index) + 2]; - unsigned int opt1 = it->options[(2 * s->index) + 3]; unsigned char id; id = readb(iobase + II20K_ID_REG); switch (id) { - case PCI20006_ID: - if (opt0 < 0 || opt0 > 2) - opt0 = 0; - if (opt1 < 0 || opt1 > 2) - opt1 = 0; - + case II20K_ID_PCI20006M_1: + case II20K_ID_PCI20006M_2: ao_spriv = comedi_alloc_spriv(s, sizeof(*ao_spriv)); if (!ao_spriv) return -ENOMEM; - ao_spriv->ao_range_list[0] = ii20k_ao_ranges[opt0]; - ao_spriv->ao_range_list[1] = ii20k_ao_ranges[opt1]; - /* Analog Output subdevice */ s->type = COMEDI_SUBD_AO; s->subdev_flags = SDF_WRITABLE; - s->n_chan = 2; + s->n_chan = (id == II20K_ID_PCI20006M_2) ? 2 : 1; s->maxdata = 0xffff; - s->range_table_list = ao_spriv->ao_range_list; + s->range_table = &ii20k_ao_ranges; s->insn_read = ii20k_ao_insn_read; s->insn_write = ii20k_ao_insn_write; break; -- GitLab From 3aa5e81177bd8bf235d2b506659a3ecd05d67634 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 12:13:51 -0700 Subject: [PATCH 256/942] staging: comedi: ii_pci20kc: cleanup the ai subdevice The PCI-200341M-1 module can both provide an analog input subdevice in this driver. The module provides four differential input channels with four programmable gains. Currently the gain is configured as an option passed when the board is attached. Rewrite the ai subdevice support functions to properly handle the programmable gain. For aesthetics, redefine the memory map for the module. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ii_pci20kc.c | 281 +++++++++----------- 1 file changed, 128 insertions(+), 153 deletions(-) diff --git a/drivers/staging/comedi/drivers/ii_pci20kc.c b/drivers/staging/comedi/drivers/ii_pci20kc.c index 1119a1a33135c..069cd959ba4b1 100644 --- a/drivers/staging/comedi/drivers/ii_pci20kc.c +++ b/drivers/staging/comedi/drivers/ii_pci20kc.c @@ -55,21 +55,6 @@ the other carrier boards with small modifications. Modules supported Options: 0 Board base address 1 IRQ - 2 first option for module 1 - 3 second option for module 1 - 4 first option for module 2 - 5 second option for module 2 - 6 first option for module 3 - 7 second option for module 3 - -options for PCI-20006M: - -options for PCI-20341M: - first: Analog input gain configuration - 0 1 - 1 10 - 2 100 - 3 200 */ #include @@ -119,26 +104,44 @@ options for PCI-20341M: #define II20K_AO_MSB_REG(x) (0x0e + ((x) * 0x08)) #define II20K_AO_STRB_BOTH_REG 0x1b -#define PCI20341_ID 0x77 -#define PCI20xxx_EMPTY_ID 0xff - -#define PCI20341_INIT 0x04 -#define PCI20341_REPMODE 0x00 /* single shot mode */ -#define PCI20341_PACER 0x00 /* Hardware Pacer disabled */ -#define PCI20341_CONFIG_REG 0x10 -#define PCI20341_MOD_STATUS 0x01 -#define PCI20341_OPT_REG 0x11 -#define PCI20341_SET_TIME_REG 0x15 -#define PCI20341_LCHAN_ADDR_REG 0x13 -#define PCI20341_CHAN_LIST 0x80 -#define PCI20341_CC_RESET 0x1b -#define PCI20341_CHAN_RESET 0x19 -#define PCI20341_SOFT_PACER 0x04 -#define PCI20341_STATUS_REG 0x12 -#define PCI20341_LDATA 0x02 -#define PCI20341_DAISY_CHAIN 0x20 /* On-board inputs only */ -#define PCI20341_MUX 0x04 /* Enable on-board MUX */ -#define PCI20341_SCANLIST 0x80 /* Channel/Gain Scan List */ +#define II20K_ID_PCI200341M_1 0x77 /* 4 AI channels */ +#define II20K_AI_STATUS_CMD_REG 0x01 +#define II20K_AI_STATUS_CMD_BUSY (1 << 7) +#define II20K_AI_STATUS_CMD_HW_ENA (1 << 1) +#define II20K_AI_STATUS_CMD_EXT_START (1 << 0) +#define II20K_AI_LSB_REG 0x02 +#define II20K_AI_MSB_REG 0x03 +#define II20K_AI_PACER_RESET_REG 0x04 +#define II20K_AI_16BIT_DATA_REG 0x06 +#define II20K_AI_CONF_REG 0x10 +#define II20K_AI_CONF_ENA (1 << 2) +#define II20K_AI_OPT_REG 0x11 +#define II20K_AI_OPT_TRIG_ENA (1 << 5) +#define II20K_AI_OPT_TRIG_INV (1 << 4) +#define II20K_AI_OPT_TIMEBASE(x) (((x) & 0x3) << 1) +#define II20K_AI_OPT_BURST_MODE (1 << 0) +#define II20K_AI_STATUS_REG 0x12 +#define II20K_AI_STATUS_INT (1 << 7) +#define II20K_AI_STATUS_TRIG (1 << 6) +#define II20K_AI_STATUS_TRIG_ENA (1 << 5) +#define II20K_AI_STATUS_PACER_ERR (1 << 2) +#define II20K_AI_STATUS_DATA_ERR (1 << 1) +#define II20K_AI_STATUS_SET_TIME_ERR (1 << 0) +#define II20K_AI_LAST_CHAN_ADDR_REG 0x13 +#define II20K_AI_CUR_ADDR_REG 0x14 +#define II20K_AI_SET_TIME_REG 0x15 +#define II20K_AI_DELAY_LSB_REG 0x16 +#define II20K_AI_DELAY_MSB_REG 0x17 +#define II20K_AI_CHAN_ADV_REG 0x18 +#define II20K_AI_CHAN_RESET_REG 0x19 +#define II20K_AI_START_TRIG_REG 0x1a +#define II20K_AI_COUNT_RESET_REG 0x1b +#define II20K_AI_CHANLIST_REG 0x80 +#define II20K_AI_CHANLIST_ONBOARD_ONLY (1 << 5) +#define II20K_AI_CHANLIST_GAIN(x) (((x) & 0x3) << 3) +#define II20K_AI_CHANLIST_MUX_ENA (1 << 2) +#define II20K_AI_CHANLIST_CHAN(x) (((x) & 0x3) << 0) +#define II20K_AI_CHANLIST_LEN 0x80 /* the AO range is set by jumpers on the 20006M module */ static const struct comedi_lrange ii20k_ao_ranges = { @@ -148,44 +151,20 @@ static const struct comedi_lrange ii20k_ao_ranges = { BIP_RANGE(10) /* Chan 0 - W1/W3 in Chan 1 - W2/W4 out */ } }; -static const struct comedi_lrange range_bipolar0_5 = { - 1, { - BIP_RANGE(0.5) - } -}; - -static const struct comedi_lrange range_bipolar0_05 = { - 1, { - BIP_RANGE(0.05) - } -}; - -static const struct comedi_lrange range_bipolar0_025 = { - 1, { - BIP_RANGE(0.025) - } -}; -static const struct comedi_lrange *const ii20k_ai_ranges[] = { - &range_bipolar5, - &range_bipolar0_5, - &range_bipolar0_05, - &range_bipolar0_025, +static const struct comedi_lrange ii20k_ai_ranges = { + 4, { + BIP_RANGE(5), /* gain 1 */ + BIP_RANGE(0.5), /* gain 10 */ + BIP_RANGE(0.05), /* gain 100 */ + BIP_RANGE(0.025) /* gain 200 */ + }, }; -static const int pci20341_timebase[] = { 0x00, 0x00, 0x00, 0x04 }; -static const int pci20341_settling_time[] = { 0x58, 0x58, 0x93, 0x99 }; - struct ii20k_ao_private { unsigned int last_data[2]; }; -struct ii20k_ai_private { - int timebase; - int settling_time; - int ai_gain; -}; - struct pci20xxx_private { void __iomem *ioaddr; }; @@ -241,82 +220,94 @@ static int ii20k_ao_insn_write(struct comedi_device *dev, return insn->n; } +static int ii20k_ai_wait_eoc(struct comedi_device *dev, + struct comedi_subdevice *s, + int timeout) +{ + void __iomem *iobase = ii20k_module_iobase(dev, s); + unsigned char status; + + do { + status = readb(iobase + II20K_AI_STATUS_REG); + if ((status & II20K_AI_STATUS_INT) == 0) + return 0; + } while (timeout--); + + return -ETIME; +} + +static void ii20k_ai_setup(struct comedi_device *dev, + struct comedi_subdevice *s, + unsigned int chanspec) +{ + void __iomem *iobase = ii20k_module_iobase(dev, s); + unsigned int chan = CR_CHAN(chanspec); + unsigned int range = CR_RANGE(chanspec); + unsigned char val; + + /* initialize module */ + writeb(II20K_AI_CONF_ENA, iobase + II20K_AI_CONF_REG); + + /* software conversion */ + writeb(0, iobase + II20K_AI_STATUS_CMD_REG); + + /* set the time base for the settling time counter based on the gain */ + val = (range < 3) ? II20K_AI_OPT_TIMEBASE(0) : II20K_AI_OPT_TIMEBASE(2); + writeb(val, iobase + II20K_AI_OPT_REG); + + /* set the settling time counter based on the gain */ + val = (range < 2) ? 0x58 : (range < 3) ? 0x93 : 0x99; + writeb(val, iobase + II20K_AI_SET_TIME_REG); + + /* set number of input channels */ + writeb(1, iobase + II20K_AI_LAST_CHAN_ADDR_REG); + + /* set the channel list byte */ + val = II20K_AI_CHANLIST_ONBOARD_ONLY | + II20K_AI_CHANLIST_MUX_ENA | + II20K_AI_CHANLIST_GAIN(range) | + II20K_AI_CHANLIST_CHAN(chan); + writeb(val, iobase + II20K_AI_CHANLIST_REG); + + /* reset settling time counter and trigger delay counter */ + writeb(0, iobase + II20K_AI_COUNT_RESET_REG); + + /* reset channel scanner */ + writeb(0, iobase + II20K_AI_CHAN_RESET_REG); +} + static int ii20k_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - struct ii20k_ai_private *ai_spriv = s->private; void __iomem *iobase = ii20k_module_iobase(dev, s); - unsigned int i = 0, j = 0; - int lo, hi; - unsigned char eoc; /* end of conversion */ - unsigned int clb; /* channel list byte */ - unsigned int boarddata; - - /* write number of input channels */ - writeb(1, iobase + PCI20341_LCHAN_ADDR_REG); - clb = PCI20341_DAISY_CHAIN | PCI20341_MUX | (ai_spriv->ai_gain << 3) - | CR_CHAN(insn->chanspec); - writeb(clb, iobase + PCI20341_CHAN_LIST); + int ret; + int i; - /* reset settling time counter and trigger delay counter */ - writeb(0x00, iobase + PCI20341_CC_RESET); + ii20k_ai_setup(dev, s, insn->chanspec); - writeb(0x00, iobase + PCI20341_CHAN_RESET); + for (i = 0; i < insn->n; i++) { + unsigned int val; - /* generate Pacer */ + /* generate a software start convert signal */ + readb(iobase + II20K_AI_PACER_RESET_REG); - for (i = 0; i < insn->n; i++) { - /* data polling isn't the niciest way to get the data, I know, - * but there are only 6 cycles (mean) and it is easier than - * the whole interrupt stuff - */ - j = 0; - /* generate Pacer */ - readb(iobase + PCI20341_SOFT_PACER); - - eoc = readb(iobase + PCI20341_STATUS_REG); - /* poll Interrupt Flag */ - while ((eoc < 0x80) && j < 100) { - j++; - eoc = readb(iobase + PCI20341_STATUS_REG); - } - if (j >= 100) { - dev_warn(dev->class_dev, - "AI interrupt channel %i polling exit !\n", i); - return -EINVAL; - } - lo = readb(iobase + PCI20341_LDATA); - hi = readb(iobase + PCI20341_LDATA + 1); - boarddata = lo + 0x100 * hi; - - /* board-data -> comedi-data */ - data[i] = (short)((boarddata + 0x8000) & 0xffff); - } + ret = ii20k_ai_wait_eoc(dev, s, 100); + if (ret) + return ret; - return i; -} + val = readb(iobase + II20K_AI_LSB_REG); + val |= (readb(iobase + II20K_AI_MSB_REG) << 8); -static void ii20k_ai_init(struct comedi_device *dev, - struct comedi_subdevice *s) -{ - struct ii20k_ai_private *ai_spriv = s->private; - void __iomem *iobase = ii20k_module_iobase(dev, s); - unsigned char option; - - /* depends on gain, trigger, repetition mode */ - option = ai_spriv->timebase | PCI20341_REPMODE; - - /* initialize Module */ - writeb(PCI20341_INIT, iobase + PCI20341_CONFIG_REG); - /* set Pacer */ - writeb(PCI20341_PACER, iobase + PCI20341_MOD_STATUS); - /* option register */ - writeb(option, iobase + PCI20341_OPT_REG); - /* settling time counter */ - writeb(ai_spriv->settling_time, iobase + PCI20341_SET_TIME_REG); - /* trigger not implemented */ + /* munge two's complement data */ + val += ((s->maxdata + 1) >> 1); + val &= s->maxdata; + + data[i] = val; + } + + return insn->n; } static void ii20k_dio_config(struct comedi_device *dev, @@ -456,13 +447,10 @@ static int ii20k_dio_insn_bits(struct comedi_device *dev, } static int ii20k_init_module(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_devconfig *it) + struct comedi_subdevice *s) { struct ii20k_ao_private *ao_spriv; - struct ii20k_ai_private *ai_spriv; void __iomem *iobase = ii20k_module_iobase(dev, s); - unsigned int opt0 = it->options[(2 * s->index) + 2]; unsigned char id; id = readb(iobase + II20K_ID_REG); @@ -482,28 +470,15 @@ static int ii20k_init_module(struct comedi_device *dev, s->insn_read = ii20k_ao_insn_read; s->insn_write = ii20k_ao_insn_write; break; - case PCI20341_ID: - if (opt0 < 0 || opt0 > 3) - opt0 = 0; - - ai_spriv = comedi_alloc_spriv(s, sizeof(*ai_spriv)); - if (!ai_spriv) - return -ENOMEM; - - ai_spriv->timebase = pci20341_timebase[opt0]; - ai_spriv->settling_time = pci20341_settling_time[opt0]; - + case II20K_ID_PCI200341M_1: /* Analog Input subdevice */ s->type = COMEDI_SUBD_AI; - s->subdev_flags = SDF_READABLE; + s->subdev_flags = SDF_READABLE | SDF_DIFF; s->n_chan = 4; s->maxdata = 0xffff; - s->range_table = ii20k_ai_ranges[opt0]; + s->range_table = &ii20k_ai_ranges; s->insn_read = ii20k_ai_insn_read; - - ii20k_ai_init(dev, s); break; - case PCI20xxx_EMPTY_ID: default: s->type = COMEDI_SUBD_UNUSED; break; @@ -546,7 +521,7 @@ static int pci20xxx_attach(struct comedi_device *dev, if (id & II20K_ID_MOD1_EMPTY) { s->type = COMEDI_SUBD_UNUSED; } else { - ret = ii20k_init_module(dev, s, it); + ret = ii20k_init_module(dev, s); if (ret) return ret; } @@ -555,7 +530,7 @@ static int pci20xxx_attach(struct comedi_device *dev, if (id & II20K_ID_MOD2_EMPTY) { s->type = COMEDI_SUBD_UNUSED; } else { - ret = ii20k_init_module(dev, s, it); + ret = ii20k_init_module(dev, s); if (ret) return ret; } @@ -564,7 +539,7 @@ static int pci20xxx_attach(struct comedi_device *dev, if (id & II20K_ID_MOD3_EMPTY) { s->type = COMEDI_SUBD_UNUSED; } else { - ret = ii20k_init_module(dev, s, it); + ret = ii20k_init_module(dev, s); if (ret) return ret; } -- GitLab From c325f9a9edf24dfc13145b5fce792aec577fe381 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 24 Jul 2013 12:14:11 -0700 Subject: [PATCH 257/942] staging: comedi: ii_pci20kc: cleanup final pieces Tidy up the multi-line comments at the beginning of the file and remove any irrelevant information. Fix the II20K_ID_PCI200341M_1 define, there are one to many 0's. Rename all the remaining pci20xxx_* to ii20k_*. The "pci" just adds confusion, this is not a PCI board. Remove the private (*detach) function. It's safe to call the comedi core provided comedi_legacy_detach() even if there is nothing to cleanup. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ii_pci20kc.c | 107 +++++++------------- 1 file changed, 36 insertions(+), 71 deletions(-) diff --git a/drivers/staging/comedi/drivers/ii_pci20kc.c b/drivers/staging/comedi/drivers/ii_pci20kc.c index 069cd959ba4b1..954c5397f33c8 100644 --- a/drivers/staging/comedi/drivers/ii_pci20kc.c +++ b/drivers/staging/comedi/drivers/ii_pci20kc.c @@ -1,61 +1,31 @@ /* - * comedi/drivers/ii_pci20kc.c - * Driver for Intelligent Instruments PCI-20001C carrier board - * and modules. + * ii_pci20kc.c + * Driver for Intelligent Instruments PCI-20001C carrier board and modules. * - * Copyright (C) 2000 Markus Kempf - * with suggestions from David Schleef - * 16.06.2000 - * - * Linux device driver for COMEDI - * Intelligent Instrumentation - * PCI-20001 C-2A Carrier Board - * PCI-20341 M-1A 16-Bit analog input module - * - differential - * - range (-5V - +5V) - * - 16 bit - * PCI-20006 M-2 16-Bit analog output module - * - ranges (-10V - +10V) (0V - +10V) (-5V - +5V) - * - 16 bit - * - * only ONE PCI-20341 module possible - * only ONE PCI-20006 module possible - * no extern trigger implemented - * - * NOT WORKING (but soon) only 4 on-board differential channels supported - * NOT WORKING (but soon) only ONE di-port and ONE do-port supported - * instead of 4 digital ports - * di-port == Port 0 - * do-port == Port 1 - * - * The state of this driver is only a starting point for a complete - * COMEDI-driver. The final driver should support all features of the - * carrier board and modules. + * Copyright (C) 2000 Markus Kempf + * with suggestions from David Schleef 16.06.2000 + */ + +/* + * Driver: ii_pci20kc + * Description: Intelligent Instruments PCI-20001C carrier board + * Devices: (Intelligent Instrumentation) PCI-20001C [ii_pci20kc] + * Author: Markus Kempf + * Status: works * - * The test configuration: + * Supports the PCI-20001C-1a and PCI-20001C-2a carrier boards. The + * -2a version has 32 on-board DIO channels. Three add-on modules + * can be added to the carrier board for additional functionality. * - * kernel 2.2.14 with RTAI v1.2 and patch-2.2.14rthal2 - * COMEDI 0.7.45 - * COMEDILIB 0.7.9 + * Supported add-on modules: + * PCI-20006M-1 1 channel, 16-bit analog output module + * PCI-20006M-2 2 channel, 16-bit analog output module + * PCI-20341M-1A 4 channel, 16-bit analog input module * + * Options: + * 0 Board base address + * 1 IRQ (not-used) */ -/* -Driver: ii_pci20kc -Description: Intelligent Instruments PCI-20001C carrier board -Author: Markus Kempf -Devices: [Intelligent Instrumentation] PCI-20001C (ii_pci20kc) -Status: works - -Supports the PCI-20001 C-2a Carrier board, and could probably support -the other carrier boards with small modifications. Modules supported -are: - PCI-20006 M-2 16-bit analog output module - PCI-20341 M-1A 16-bit analog input module - -Options: - 0 Board base address - 1 IRQ -*/ #include #include "../comedidev.h" @@ -104,7 +74,7 @@ the other carrier boards with small modifications. Modules supported #define II20K_AO_MSB_REG(x) (0x0e + ((x) * 0x08)) #define II20K_AO_STRB_BOTH_REG 0x1b -#define II20K_ID_PCI200341M_1 0x77 /* 4 AI channels */ +#define II20K_ID_PCI20341M_1 0x77 /* 4 AI channels */ #define II20K_AI_STATUS_CMD_REG 0x01 #define II20K_AI_STATUS_CMD_BUSY (1 << 7) #define II20K_AI_STATUS_CMD_HW_ENA (1 << 1) @@ -165,14 +135,14 @@ struct ii20k_ao_private { unsigned int last_data[2]; }; -struct pci20xxx_private { +struct ii20k_private { void __iomem *ioaddr; }; static void __iomem *ii20k_module_iobase(struct comedi_device *dev, struct comedi_subdevice *s) { - struct pci20xxx_private *devpriv = dev->private; + struct ii20k_private *devpriv = dev->private; return devpriv->ioaddr + (s->index + 1) * II20K_MOD_OFFSET; } @@ -313,7 +283,7 @@ static int ii20k_ai_insn_read(struct comedi_device *dev, static void ii20k_dio_config(struct comedi_device *dev, struct comedi_subdevice *s) { - struct pci20xxx_private *devpriv = dev->private; + struct ii20k_private *devpriv = dev->private; unsigned char ctrl01 = 0; unsigned char ctrl23 = 0; unsigned char dir_ena = 0; @@ -416,7 +386,7 @@ static int ii20k_dio_insn_bits(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct pci20xxx_private *devpriv = dev->private; + struct ii20k_private *devpriv = dev->private; unsigned int mask = data[0] & s->io_bits; /* outputs only */ unsigned int bits = data[1]; @@ -470,7 +440,7 @@ static int ii20k_init_module(struct comedi_device *dev, s->insn_read = ii20k_ao_insn_read; s->insn_write = ii20k_ao_insn_write; break; - case II20K_ID_PCI200341M_1: + case II20K_ID_PCI20341M_1: /* Analog Input subdevice */ s->type = COMEDI_SUBD_AI; s->subdev_flags = SDF_READABLE | SDF_DIFF; @@ -487,10 +457,10 @@ static int ii20k_init_module(struct comedi_device *dev, return 0; } -static int pci20xxx_attach(struct comedi_device *dev, - struct comedi_devconfig *it) +static int ii20k_attach(struct comedi_device *dev, + struct comedi_devconfig *it) { - struct pci20xxx_private *devpriv; + struct ii20k_private *devpriv; struct comedi_subdevice *s; unsigned char id; bool has_dio; @@ -561,21 +531,16 @@ static int pci20xxx_attach(struct comedi_device *dev, s->type = COMEDI_SUBD_UNUSED; } - return 1; -} - -static void pci20xxx_detach(struct comedi_device *dev) -{ - /* Nothing to cleanup */ + return 0; } -static struct comedi_driver pci20xxx_driver = { +static struct comedi_driver ii20k_driver = { .driver_name = "ii_pci20kc", .module = THIS_MODULE, - .attach = pci20xxx_attach, - .detach = pci20xxx_detach, + .attach = ii20k_attach, + .detach = comedi_legacy_detach, }; -module_comedi_driver(pci20xxx_driver); +module_comedi_driver(ii20k_driver); MODULE_AUTHOR("Comedi http://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); -- GitLab From bcc27c82bac2622e352c732a0bda49651e1799b3 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Thu, 25 Jul 2013 22:02:48 +0200 Subject: [PATCH 258/942] staging: comedi: Add missing #include sparc64 allmodconfig: drivers/staging/comedi/drivers/addi_apci_2032.c: In function 'apci2032_auto_attach': drivers/staging/comedi/drivers/addi_apci_2032.c:328:3: error: implicit declaration of function 'kzalloc' [-Werror=implicit-function-declaration] drivers/staging/comedi/drivers/addi_apci_2032.c:328:11: warning: assignment makes pointer from integer without a cast [enabled by default] drivers/staging/comedi/drivers/addi_apci_2032.c: In function 'apci2032_detach': drivers/staging/comedi/drivers/addi_apci_2032.c:350:3: error: implicit declaration of function 'kfree' [-Werror=implicit-function-declaration] drivers/staging/comedi/drivers/amplc_pci224.c: In function 'pci224_attach_common': drivers/staging/comedi/drivers/amplc_pci224.c:1289:2: error: implicit declaration of function 'kmalloc' [-Werror=implicit-function-declaration] drivers/staging/comedi/drivers/amplc_pci224.c:1289:23: warning: assignment makes pointer from integer without a cast [enabled by default] drivers/staging/comedi/drivers/amplc_pci224.c:1296:24: warning: assignment makes pointer from integer without a cast [enabled by default] drivers/staging/comedi/drivers/amplc_pci224.c:1303:25: warning: assignment makes pointer from integer without a cast [enabled by default] drivers/staging/comedi/drivers/amplc_pci224.c:1348:42: warning: assignment makes pointer from integer without a cast [enabled by default] drivers/staging/comedi/drivers/amplc_pci224.c: In function 'pci224_detach': drivers/staging/comedi/drivers/amplc_pci224.c:1474:3: error: implicit declaration of function 'kfree' [-Werror=implicit-function-declaration] Introduced by commit 0bdab509bf9c6d838dc0a3b1d68bbf841fc20b5a ("staging: comedi: use comedi_alloc_devpriv()"), which removed some inclusions of . Signed-off-by: Geert Uytterhoeven Cc: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_2032.c | 1 + drivers/staging/comedi/drivers/amplc_pci224.c | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/staging/comedi/drivers/addi_apci_2032.c b/drivers/staging/comedi/drivers/addi_apci_2032.c index cb5d26a567d39..6b0ea16ff5467 100644 --- a/drivers/staging/comedi/drivers/addi_apci_2032.c +++ b/drivers/staging/comedi/drivers/addi_apci_2032.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "../comedidev.h" #include "addi_watchdog.h" diff --git a/drivers/staging/comedi/drivers/amplc_pci224.c b/drivers/staging/comedi/drivers/amplc_pci224.c index 2fc56c40f5b1f..179de53a86f00 100644 --- a/drivers/staging/comedi/drivers/amplc_pci224.c +++ b/drivers/staging/comedi/drivers/amplc_pci224.c @@ -101,6 +101,7 @@ Passing a zero for an option is the same as leaving it unspecified. #include #include #include +#include #include "../comedidev.h" -- GitLab From ea8d15832016b0d07a8121159904e6b1d21b5b8b Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Fri, 28 Jun 2013 13:55:27 -0300 Subject: [PATCH 259/942] imx-drm: imx-drm-core: Export imx_drm_encoder_get_mux_id When building imx_v6_v7_defconfig with imx-drm drivers selected as modules, we get the following build error: ERROR: "imx_drm_encoder_get_mux_id" [drivers/staging/imx-drm/imx-ldb.ko] undefined! Export the required function to avoid this problem. Signed-off-by: Fabio Estevam Acked-by: Sascha Hauer Acked-by: Philipp Zabel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/imx-drm/imx-drm-core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c index 9854a1daf606b..6bc205baa4a5f 100644 --- a/drivers/staging/imx-drm/imx-drm-core.c +++ b/drivers/staging/imx-drm/imx-drm-core.c @@ -678,6 +678,7 @@ int imx_drm_encoder_get_mux_id(struct imx_drm_encoder *imx_drm_encoder, return i; } +EXPORT_SYMBOL_GPL(imx_drm_encoder_get_mux_id); /* * imx_drm_remove_encoder - remove an encoder -- GitLab From 55b31cf40654b32a75e7c010f9345f361ccae927 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Fri, 28 Jun 2013 13:55:28 -0300 Subject: [PATCH 260/942] imx-drm: ipu-dp: Check the return value of devm_kzalloc() devm_kzalloc() may fail, so let's check its return value. Signed-off-by: Fabio Estevam Acked-by: Sascha Hauer Acked-by: Philipp Zabel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/imx-drm/ipu-v3/ipu-dp.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-dp.c b/drivers/staging/imx-drm/ipu-v3/ipu-dp.c index 113b046c02259..04495158398ef 100644 --- a/drivers/staging/imx-drm/ipu-v3/ipu-dp.c +++ b/drivers/staging/imx-drm/ipu-v3/ipu-dp.c @@ -309,6 +309,8 @@ int ipu_dp_init(struct ipu_soc *ipu, struct device *dev, unsigned long base) int i; priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; priv->dev = dev; priv->ipu = ipu; -- GitLab From ded15b5af1f05a57badd7ea5a1428d2fec83a215 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Fri, 28 Jun 2013 13:55:29 -0300 Subject: [PATCH 261/942] imx-drm: ipu-dp: Remove unneeded braces No need to have braces for a single line 'if' block Signed-off-by: Fabio Estevam Acked-by: Sascha Hauer Acked-by: Philipp Zabel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/imx-drm/ipu-v3/ipu-dp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-dp.c b/drivers/staging/imx-drm/ipu-v3/ipu-dp.c index 04495158398ef..6e0e9f1c6517b 100644 --- a/drivers/staging/imx-drm/ipu-v3/ipu-dp.c +++ b/drivers/staging/imx-drm/ipu-v3/ipu-dp.c @@ -317,9 +317,8 @@ int ipu_dp_init(struct ipu_soc *ipu, struct device *dev, unsigned long base) ipu->dp_priv = priv; priv->base = devm_ioremap(dev, base, PAGE_SIZE); - if (!priv->base) { + if (!priv->base) return -ENOMEM; - } mutex_init(&priv->mutex); -- GitLab From 6fe9a899edc8c145e6ba6d8217f95cf23932f999 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Fri, 28 Jun 2013 13:55:30 -0300 Subject: [PATCH 262/942] imx-drm: ipu-dp: Introduce IPUV3_NUM_FLOWS IPUv3 has a total of 3 flows (one synchronous flow and 2 asynchronous flows). Let's add a definition for such number in order to let the code easier to understand. Signed-off-by: Fabio Estevam Acked-by: Sascha Hauer Acked-by: Philipp Zabel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/imx-drm/ipu-v3/ipu-dp.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-dp.c b/drivers/staging/imx-drm/ipu-v3/ipu-dp.c index 6e0e9f1c6517b..231afd6c60f84 100644 --- a/drivers/staging/imx-drm/ipu-v3/ipu-dp.c +++ b/drivers/staging/imx-drm/ipu-v3/ipu-dp.c @@ -46,6 +46,8 @@ #define DP_COM_CONF_CSC_DEF_BG (2 << 8) #define DP_COM_CONF_CSC_DEF_BOTH (1 << 8) +#define IPUV3_NUM_FLOWS 3 + struct ipu_dp_priv; struct ipu_dp { @@ -67,7 +69,7 @@ struct ipu_dp_priv { struct ipu_soc *ipu; struct device *dev; void __iomem *base; - struct ipu_flow flow[3]; + struct ipu_flow flow[IPUV3_NUM_FLOWS]; struct mutex mutex; int use_count; }; @@ -280,7 +282,7 @@ struct ipu_dp *ipu_dp_get(struct ipu_soc *ipu, unsigned int flow) struct ipu_dp_priv *priv = ipu->dp_priv; struct ipu_dp *dp; - if (flow > 5) + if ((flow >> 1) >= IPUV3_NUM_FLOWS) return ERR_PTR(-EINVAL); if (flow & 1) @@ -322,7 +324,7 @@ int ipu_dp_init(struct ipu_soc *ipu, struct device *dev, unsigned long base) mutex_init(&priv->mutex); - for (i = 0; i < 3; i++) { + for (i = 0; i < IPUV3_NUM_FLOWS; i++) { priv->flow[i].foreground.foreground = 1; priv->flow[i].base = priv->base + ipu_dp_flow_base[i]; priv->flow[i].priv = priv; -- GitLab From 5d78bf80f63cc85548b0643d147b76b1949c64de Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Tue, 16 Jul 2013 02:16:14 -0300 Subject: [PATCH 263/942] imx-drm: imx-tve: Provide __acquires/__releases annotation Fix the following sparse warnings: drivers/staging/imx-drm/imx-tve.c:133:13: warning: context imbalance in 'tve_lock' - wrong count at exit drivers/staging/imx-drm/imx-tve.c:139:13: warning: context imbalance in 'tve_unlock' - unexpected unlock Signed-off-by: Fabio Estevam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/imx-drm/imx-tve.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/imx-drm/imx-tve.c b/drivers/staging/imx-drm/imx-tve.c index a56797d88edcd..0a1c6ab763441 100644 --- a/drivers/staging/imx-drm/imx-tve.c +++ b/drivers/staging/imx-drm/imx-tve.c @@ -131,12 +131,14 @@ struct imx_tve { }; static void tve_lock(void *__tve) +__acquires(&tve->lock) { struct imx_tve *tve = __tve; spin_lock(&tve->lock); } static void tve_unlock(void *__tve) +__releases(&tve->lock) { struct imx_tve *tve = __tve; spin_unlock(&tve->lock); -- GitLab From 1c0541873c281d39e167a47634d5402adb4e3ae4 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Tue, 23 Jul 2013 14:15:32 -0300 Subject: [PATCH 264/942] imx-drm: TODO: Remove LVDS support from missing features list. LVDS Display Bridge is currently supported, so remove it from the missing features list. Signed-off-by: Fabio Estevam Acked-by: Sascha Hauer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/imx-drm/TODO | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/imx-drm/TODO b/drivers/staging/imx-drm/TODO index f80641528f753..9cfa2a7efdc06 100644 --- a/drivers/staging/imx-drm/TODO +++ b/drivers/staging/imx-drm/TODO @@ -10,7 +10,6 @@ TODO: Missing features (not necessarily for moving out of staging): - Add KMS plane support for CRTC driver -- Add LDB (LVDS Display Bridge) support - Add i.MX6 HDMI support - Add support for IC (Image converter) - Add support for CSI (CMOS Sensor interface) -- GitLab From 7c3836a48e318ef8676f43af6632db3f89bf8cc1 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Sun, 21 Jul 2013 22:19:42 -0300 Subject: [PATCH 265/942] imx-drm: imx-tve: Remove unneeded check for platform_get_resource() As devm_ioremap_resource() is used on probe, there is no need to explicitly check the return value from platform_get_resource(), as this is something that devm_ioremap_resource() takes care by itself. Signed-off-by: Fabio Estevam Acked-by: Philipp Zabel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/imx-drm/imx-tve.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/imx-drm/imx-tve.c b/drivers/staging/imx-drm/imx-tve.c index 0a1c6ab763441..12a3940de6954 100644 --- a/drivers/staging/imx-drm/imx-tve.c +++ b/drivers/staging/imx-drm/imx-tve.c @@ -625,11 +625,6 @@ static int imx_tve_probe(struct platform_device *pdev) } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) { - dev_err(&pdev->dev, "failed to get memory region\n"); - return -ENOENT; - } - base = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(base)) return PTR_ERR(base); -- GitLab From be798b2b13bca5a1b25b56acec60ec42bcc57c50 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Sat, 20 Jul 2013 18:22:09 -0300 Subject: [PATCH 266/942] imx-drm: ipu-common: Simplify the error path Instead of jumping to goto labels, just return the error code directly. Signed-off-by: Fabio Estevam Acked-by: Sascha Hauer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/imx-drm/ipu-v3/ipu-common.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-common.c b/drivers/staging/imx-drm/ipu-v3/ipu-common.c index e35d0bf03c7b9..d06b0c81f3972 100644 --- a/drivers/staging/imx-drm/ipu-v3/ipu-common.c +++ b/drivers/staging/imx-drm/ipu-v3/ipu-common.c @@ -1075,16 +1075,14 @@ static int ipu_probe(struct platform_device *pdev) ipu->cpmem_base = devm_ioremap(&pdev->dev, ipu_base + devtype->cpmem_ofs, PAGE_SIZE); - if (!ipu->cm_reg || !ipu->idmac_reg || !ipu->cpmem_base) { - ret = -ENOMEM; - goto failed_ioremap; - } + if (!ipu->cm_reg || !ipu->idmac_reg || !ipu->cpmem_base) + return -ENOMEM; ipu->clk = devm_clk_get(&pdev->dev, "bus"); if (IS_ERR(ipu->clk)) { ret = PTR_ERR(ipu->clk); dev_err(&pdev->dev, "clk_get failed with %d", ret); - goto failed_clk_get; + return ret; } platform_set_drvdata(pdev, ipu); @@ -1134,8 +1132,6 @@ static int ipu_probe(struct platform_device *pdev) ipu_irq_exit(ipu); out_failed_irq: clk_disable_unprepare(ipu->clk); -failed_clk_get: -failed_ioremap: return ret; } -- GitLab From 62645a27ba9b93cf13d505d9ced64171010fb57d Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Sat, 20 Jul 2013 18:22:10 -0300 Subject: [PATCH 267/942] imx-drm: ipu-common: Check the return value from clk_prepare_enable() clk_prepare_enable() may fail, so let's check its return value and propagate it in the case of error. Signed-off-by: Fabio Estevam Acked-by: Sascha Hauer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/imx-drm/ipu-v3/ipu-common.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-common.c b/drivers/staging/imx-drm/ipu-v3/ipu-common.c index d06b0c81f3972..f1299da5ec201 100644 --- a/drivers/staging/imx-drm/ipu-v3/ipu-common.c +++ b/drivers/staging/imx-drm/ipu-v3/ipu-common.c @@ -1087,7 +1087,11 @@ static int ipu_probe(struct platform_device *pdev) platform_set_drvdata(pdev, ipu); - clk_prepare_enable(ipu->clk); + ret = clk_prepare_enable(ipu->clk); + if (ret) { + dev_err(&pdev->dev, "clk_prepare_enable failed: %d\n", ret); + return ret; + } ipu->dev = &pdev->dev; ipu->irq_sync = irq_sync; -- GitLab From 10f2268df80d127d0777dbf5986b58e3956ddb0f Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Sat, 20 Jul 2013 18:22:11 -0300 Subject: [PATCH 268/942] imx-drm: ipu-common: Add MODULE_ALIAS Add MODULE_ALIAS, so that auto module loading can work. Signed-off-by: Fabio Estevam Acked-by: Sascha Hauer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/imx-drm/ipu-v3/ipu-common.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-common.c b/drivers/staging/imx-drm/ipu-v3/ipu-common.c index f1299da5ec201..ba464e5d9f125 100644 --- a/drivers/staging/imx-drm/ipu-v3/ipu-common.c +++ b/drivers/staging/imx-drm/ipu-v3/ipu-common.c @@ -1163,6 +1163,7 @@ static struct platform_driver imx_ipu_driver = { module_platform_driver(imx_ipu_driver); +MODULE_ALIAS("platform:imx-ipuv3"); MODULE_DESCRIPTION("i.MX IPU v3 driver"); MODULE_AUTHOR("Sascha Hauer "); MODULE_LICENSE("GPL"); -- GitLab From aaba4b58820aebebdee3e3191ef71c11b569c629 Mon Sep 17 00:00:00 2001 From: Daniel Vetter Date: Wed, 10 Jul 2013 14:11:45 +0200 Subject: [PATCH 269/942] drm/imx: kill firstopen callback This thing seems to do some kind of delayed setup. Really, real kms drivers shouldn't do that at all. Either stuff needs to be dynamically hotplugged or the driver setup sequence needs to be fixed. This patch here just moves the setup at the very end of the driver load callback, with the locking adjusted accordingly. v2: Also move the corresponding put from ->lastclose to ->unload. Cc: Sascha Hauer Signed-off-by: Daniel Vetter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/imx-drm/imx-drm-core.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c index 6bc205baa4a5f..878f168821071 100644 --- a/drivers/staging/imx-drm/imx-drm-core.c +++ b/drivers/staging/imx-drm/imx-drm-core.c @@ -69,28 +69,20 @@ struct imx_drm_connector { struct module *owner; }; -static int imx_drm_driver_firstopen(struct drm_device *drm) -{ - if (!imx_drm_device_get()) - return -EINVAL; - - return 0; -} - static void imx_drm_driver_lastclose(struct drm_device *drm) { struct imx_drm_device *imxdrm = drm->dev_private; if (imxdrm->fbhelper) drm_fbdev_cma_restore_mode(imxdrm->fbhelper); - - imx_drm_device_put(); } static int imx_drm_driver_unload(struct drm_device *drm) { struct imx_drm_device *imxdrm = drm->dev_private; + imx_drm_device_put(); + drm_mode_config_cleanup(imxdrm->drm); drm_kms_helper_poll_fini(imxdrm->drm); @@ -226,8 +218,6 @@ struct drm_device *imx_drm_device_get(void) struct imx_drm_connector *con; struct imx_drm_crtc *crtc; - mutex_lock(&imxdrm->mutex); - list_for_each_entry(enc, &imxdrm->encoder_list, list) { if (!try_module_get(enc->owner)) { dev_err(imxdrm->dev, "could not get module %s\n", @@ -254,8 +244,6 @@ struct drm_device *imx_drm_device_get(void) imxdrm->references++; - mutex_unlock(&imxdrm->mutex); - return imxdrm->drm; unwind_crtc: @@ -447,6 +435,9 @@ static int imx_drm_driver_load(struct drm_device *drm, unsigned long flags) */ imxdrm->drm->vblank_disable_allowed = 1; + if (!imx_drm_device_get()) + ret = -EINVAL; + ret = 0; err_init: @@ -792,7 +783,6 @@ static struct drm_driver imx_drm_driver = { .driver_features = DRIVER_MODESET | DRIVER_GEM, .load = imx_drm_driver_load, .unload = imx_drm_driver_unload, - .firstopen = imx_drm_driver_firstopen, .lastclose = imx_drm_driver_lastclose, .gem_free_object = drm_gem_cma_free_object, .gem_vm_ops = &drm_gem_cma_vm_ops, -- GitLab From f4616af01813cbf6a2c2aabcedb11c721d5e7680 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Wed, 24 Jul 2013 13:29:22 +0200 Subject: [PATCH 270/942] staging: dwc2: Don't touch the dma_mask when dma is disabled There was some code that cleared the dma_mask when dma was disabled in the driver. Given that clearing the mask doesn't actually tell the usb core we're not using dma, and a previous commit explicitely sets the hcd->self.uses_dma value, it seems these values are unneeded and can only potentially cause problems (when reloading a module, for example). Signed-off-by: Matthijs Kooijman Acked-by: Paul Zimmerman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dwc2/hcd.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/dwc2/hcd.c b/drivers/staging/dwc2/hcd.c index fbacf6a9f72ea..32b52ad5f74fa 100644 --- a/drivers/staging/dwc2/hcd.c +++ b/drivers/staging/dwc2/hcd.c @@ -2845,9 +2845,6 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq, dev_warn(hsotg->dev, "can't set DMA mask\n"); if (dma_set_coherent_mask(hsotg->dev, DMA_BIT_MASK(32)) < 0) dev_warn(hsotg->dev, "can't set coherent DMA mask\n"); - } else { - dma_set_mask(hsotg->dev, 0); - dma_set_coherent_mask(hsotg->dev, 0); } hcd = usb_create_hcd(&dwc2_hc_driver, hsotg->dev, dev_name(hsotg->dev)); -- GitLab From 5607ce90d727d2aaad93bd72551b97067141d68a Mon Sep 17 00:00:00 2001 From: Jens Frederich Date: Thu, 25 Jul 2013 22:06:32 +0200 Subject: [PATCH 271/942] Staging: olpc_dcon: change to msleep to usleep_range The resolution of msleep is related to HZ, so with HZ set to 100 any msleep of less then 10ms will become ~10ms. This is not what we want. Use usleep_range to get more control of what is happening here. Signed-off-by: Jens Frederich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/olpc_dcon/olpc_dcon.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/olpc_dcon/olpc_dcon.c b/drivers/staging/olpc_dcon/olpc_dcon.c index 193e1c68bb454..7c460f2c0d230 100644 --- a/drivers/staging/olpc_dcon/olpc_dcon.c +++ b/drivers/staging/olpc_dcon/olpc_dcon.c @@ -131,13 +131,13 @@ static int dcon_bus_stabilize(struct dcon_priv *dcon, int is_powered_down) pr_warn("unable to force dcon to power up: %d!\n", x); return x; } - msleep(10); /* we'll be conservative */ + usleep_range(10000, 11000); /* we'll be conservative */ } pdata->bus_stabilize_wiggle(); for (x = -1, timeout = 50; timeout && x < 0; timeout--) { - msleep(1); + usleep_range(1000, 1100); x = dcon_read(dcon, DCON_REG_ID); } if (x < 0) { -- GitLab From c70bda992c12e593e411c02a52e4bd6985407539 Mon Sep 17 00:00:00 2001 From: Konrad Rzeszutek Wilk Date: Fri, 12 Jul 2013 14:20:52 -0400 Subject: [PATCH 272/942] staging: zram: Add auto loading of module if user opens /dev/zram. Greg spotted that said driver is not subscribing to the automagic mechanism of auto-loading if a user tries to open /dev/zram. This fixes it. CC: Minchan Kim Signed-off-by: Konrad Rzeszutek Wilk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/zram/zram_drv.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/zram/zram_drv.c b/drivers/staging/zram/zram_drv.c index 82c7202fd5cc9..1b30a5e87c78f 100644 --- a/drivers/staging/zram/zram_drv.c +++ b/drivers/staging/zram/zram_drv.c @@ -919,3 +919,4 @@ MODULE_PARM_DESC(num_devices, "Number of zram devices"); MODULE_LICENSE("Dual BSD/GPL"); MODULE_AUTHOR("Nitin Gupta "); MODULE_DESCRIPTION("Compressed RAM Block Device"); +MODULE_ALIAS("devname:zram"); -- GitLab From 8dbc6aa0e84455afcd5f90290e438b36569b4eec Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Tue, 23 Jul 2013 23:07:02 +0100 Subject: [PATCH 273/942] staging: vt6656: Remove dead code macro ASSERT ASSERT is always defined as empty macro because VIAWET_DEBUG is never defined. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/baseband.c | 1 - drivers/staging/vt6656/device_cfg.h | 8 -------- drivers/staging/vt6656/dpc.c | 6 ------ drivers/staging/vt6656/main_usb.c | 1 - drivers/staging/vt6656/rxtx.c | 3 --- drivers/staging/vt6656/usbpipe.c | 1 - 6 files changed, 20 deletions(-) diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c index 33fa76759bf17..a14a6a0c1cd28 100644 --- a/drivers/staging/vt6656/baseband.c +++ b/drivers/staging/vt6656/baseband.c @@ -680,7 +680,6 @@ BBuGetFrameTime( unsigned int uRate = 0; if (uRateIdx > RATE_54M) { - ASSERT(0); return 0; } diff --git a/drivers/staging/vt6656/device_cfg.h b/drivers/staging/vt6656/device_cfg.h index ea66b975fa5b0..ad1fbf6fab3d6 100644 --- a/drivers/staging/vt6656/device_cfg.h +++ b/drivers/staging/vt6656/device_cfg.h @@ -83,16 +83,8 @@ typedef enum _chip_type { } CHIP_TYPE, *PCHIP_TYPE; #ifdef VIAWET_DEBUG -#define ASSERT(x) { \ - if (!(x)) { \ - printk(KERN_ERR "assertion %s failed: file %s line %d\n", #x, \ - __FUNCTION__, __LINE__);\ - *(int *) 0 = 0; \ - } \ -} #define DBG_PORT80(value) outb(value, 0x80) #else -#define ASSERT(x) #define DBG_PORT80(value) #endif diff --git a/drivers/staging/vt6656/dpc.c b/drivers/staging/vt6656/dpc.c index 7ec166a2ac811..4bc362f530a77 100644 --- a/drivers/staging/vt6656/dpc.c +++ b/drivers/staging/vt6656/dpc.c @@ -314,7 +314,6 @@ int RXbBulkInProcessData(struct vnt_private *pDevice, PRCB pRCB, (BytesToIndicate < (*pwPLCP_Length)) ) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Wrong PLCP Length %x\n", (int) *pwPLCP_Length); - ASSERT(0); return false; } for ( ii=RATE_1M;iiNumRecvFreeList != 0) ) { pRCB = pDevice->FirstRecvFreeList; pDevice->NumRecvFreeList--; - ASSERT(pRCB);// cannot be NULL DequeueRCB(pDevice->FirstRecvFreeList, pDevice->LastRecvFreeList); ntStatus = PIPEnsBulkInUsbRead(pDevice, pRCB); } @@ -1362,9 +1360,6 @@ void RXvFreeRCB(PRCB pRCB, int bReAllocSkb) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->RXvFreeRCB\n"); - ASSERT(!pRCB->Ref); // should be 0 - ASSERT(pRCB->pDevice); // shouldn't be NULL - if (bReAllocSkb == false) { kfree_skb(pRCB->skb); bReAllocSkb = true; @@ -1411,7 +1406,6 @@ void RXvMngWorkItem(struct vnt_private *pDevice) if(!pRCB){ break; } - ASSERT(pRCB);// cannot be NULL pRxPacket = &(pRCB->sMngPacket); vMgrRxManagePacket(pDevice, &pDevice->vnt_mgmt, pRxPacket); pRCB->Ref--; diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index 3a3fdc58b6da1..0c9e60fd57f7f 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -925,7 +925,6 @@ int device_alloc_frag_buf(struct vnt_private *pDevice, pDeF->skb = dev_alloc_skb((int)pDevice->rx_buf_sz); if (pDeF->skb == NULL) return false; - ASSERT(pDeF->skb); pDeF->skb->dev = pDevice->dev; return true; diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 9bf2f8d562c3f..00e0c71187764 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -538,7 +538,6 @@ static u32 s_uGetDataDuration(struct vnt_private *pDevice, u8 byDurType, break; } - ASSERT(false); return 0; } @@ -1475,8 +1474,6 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, memcpy((pbyPayloadHead + cb802_1_H_len), ((u8 *)psEthHeader) + ETH_HLEN, uSkbPacketLen - ETH_HLEN); } - ASSERT(uLength == cbNdisBodySize); - if ((bNeedEncryption == true) && (pTransmitKey != NULL) && (pTransmitKey->byCipherSuite == KEY_CTL_TKIP)) { /////////////////////////////////////////////////////////////////// diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c index 098be609107c8..9b9122dc68cde 100644 --- a/drivers/staging/vt6656/usbpipe.c +++ b/drivers/staging/vt6656/usbpipe.c @@ -635,7 +635,6 @@ static void s_nsBulkOutIoCompleteWrite(struct urb *urb) // The context given to IoSetCompletionRoutine is an USB_CONTEXT struct // pContext = (PUSB_SEND_CONTEXT) urb->context; - ASSERT( NULL != pContext ); pDevice = pContext->pDevice; ContextType = pContext->Type; -- GitLab From f830a01339afe35b46c270faef22c86ad5622912 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Tue, 23 Jul 2013 23:10:59 +0100 Subject: [PATCH 274/942] staging: vt6656: remove dead code DBG_PORT80/VIAWET_DEBUG DBG_PORT80 is always defined as empty macro because VIAWET_DEBUG is never defined. Remove it and VIAWET_DEBUG. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/device_cfg.h | 6 ------ drivers/staging/vt6656/wmgr.c | 2 -- 2 files changed, 8 deletions(-) diff --git a/drivers/staging/vt6656/device_cfg.h b/drivers/staging/vt6656/device_cfg.h index ad1fbf6fab3d6..a97f7bb13db8d 100644 --- a/drivers/staging/vt6656/device_cfg.h +++ b/drivers/staging/vt6656/device_cfg.h @@ -82,10 +82,4 @@ typedef enum _chip_type { VT3184 = 1 } CHIP_TYPE, *PCHIP_TYPE; -#ifdef VIAWET_DEBUG -#define DBG_PORT80(value) outb(value, 0x80) -#else -#define DBG_PORT80(value) -#endif - #endif diff --git a/drivers/staging/vt6656/wmgr.c b/drivers/staging/vt6656/wmgr.c index 6d1ff5eeafa95..b6cbd138a2b46 100644 --- a/drivers/staging/vt6656/wmgr.c +++ b/drivers/staging/vt6656/wmgr.c @@ -751,7 +751,6 @@ static void s_vMgrRxAssocResponse(struct vnt_private *pDevice, || (sFrame.pwStatus == NULL) || (sFrame.pwAid == NULL) || (sFrame.pSuppRates == NULL)) { - DBG_PORT80(0xCC); return; } @@ -3750,7 +3749,6 @@ static void s_vMgrRxProbeResponse(struct vnt_private *pDevice, DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Probe resp:Fail addr:[%p]\n", pRxPacket->p80211Header); - DBG_PORT80(0xCC); return; } -- GitLab From 8079154a1d7c724569d5e3cd2af147a8eb3867c3 Mon Sep 17 00:00:00 2001 From: Rupesh Gujare Date: Wed, 24 Jul 2013 15:06:46 +0100 Subject: [PATCH 275/942] staging: ozwpan: Fix coding style. This patch fixes coding style issues reported by Dan here:- http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2012-June/027767.html Reported-by: Dan Carpenter Signed-off-by: Rupesh Gujare Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozcdev.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/staging/ozwpan/ozcdev.c b/drivers/staging/ozwpan/ozcdev.c index 3e29760ba77e5..73b582cdf424a 100644 --- a/drivers/staging/ozwpan/ozcdev.c +++ b/drivers/staging/ozwpan/ozcdev.c @@ -333,10 +333,11 @@ int oz_cdev_register(void) { int err; struct device *dev; + memset(&g_cdev, 0, sizeof(g_cdev)); err = alloc_chrdev_region(&g_cdev.devnum, 0, 1, "ozwpan"); if (err < 0) - goto out3; + return err; oz_dbg(ON, "Alloc dev number %d:%d\n", MAJOR(g_cdev.devnum), MINOR(g_cdev.devnum)); cdev_init(&g_cdev.cdev, &oz_fops); @@ -347,26 +348,26 @@ int oz_cdev_register(void) err = cdev_add(&g_cdev.cdev, g_cdev.devnum, 1); if (err < 0) { oz_dbg(ON, "Failed to add cdev\n"); - goto out2; + goto unregister; } g_oz_class = class_create(THIS_MODULE, "ozmo_wpan"); if (IS_ERR(g_oz_class)) { oz_dbg(ON, "Failed to register ozmo_wpan class\n"); err = PTR_ERR(g_oz_class); - goto out1; + goto delete; } dev = device_create(g_oz_class, NULL, g_cdev.devnum, NULL, "ozwpan"); if (IS_ERR(dev)) { oz_dbg(ON, "Failed to create sysfs entry for cdev\n"); err = PTR_ERR(dev); - goto out1; + goto delete; } return 0; -out1: + +delete: cdev_del(&g_cdev.cdev); -out2: +unregister: unregister_chrdev_region(g_cdev.devnum, 1); -out3: return err; } /*------------------------------------------------------------------------------ -- GitLab From 48bae0507410a7b8bbedec6d790c9b85c5a6391f Mon Sep 17 00:00:00 2001 From: Eli Billauer Date: Mon, 24 Jun 2013 18:55:47 +0300 Subject: [PATCH 276/942] staging: New driver: Xillybus generic interface for FPGA This is the driver for Xillybus, which is a general-purpose interface for data communication with FPGAs (programmable logic). Please refer to the README included in this patch for a detailed explanation. It was previously submitted for misc-devices, but it appears like noone's willing to review the code (which I can understand, given its magnitude). Hence submitted as a staging driver. Signed-off-by: Eli Billauer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/Kconfig | 2 + drivers/staging/Makefile | 1 + drivers/staging/xillybus/Kconfig | 35 + drivers/staging/xillybus/Makefile | 7 + drivers/staging/xillybus/README | 403 ++++ drivers/staging/xillybus/TODO | 5 + drivers/staging/xillybus/xillybus.h | 185 ++ drivers/staging/xillybus/xillybus_core.c | 2345 ++++++++++++++++++++++ drivers/staging/xillybus/xillybus_of.c | 210 ++ drivers/staging/xillybus/xillybus_pcie.c | 260 +++ 10 files changed, 3453 insertions(+) create mode 100644 drivers/staging/xillybus/Kconfig create mode 100644 drivers/staging/xillybus/Makefile create mode 100644 drivers/staging/xillybus/README create mode 100644 drivers/staging/xillybus/TODO create mode 100644 drivers/staging/xillybus/xillybus.h create mode 100644 drivers/staging/xillybus/xillybus_core.c create mode 100644 drivers/staging/xillybus/xillybus_of.c create mode 100644 drivers/staging/xillybus/xillybus_pcie.c diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index d55bc344c5eac..d036cd29bcd69 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -144,4 +144,6 @@ source "drivers/staging/lustre/Kconfig" source "drivers/staging/btmtk_usb/Kconfig" +source "drivers/staging/xillybus/Kconfig" + endif # STAGING diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index c23cf3b60c34a..7fe578ea1708c 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -64,3 +64,4 @@ obj-$(CONFIG_GOLDFISH) += goldfish/ obj-$(CONFIG_USB_DWC2) += dwc2/ obj-$(CONFIG_LUSTRE_FS) += lustre/ obj-$(CONFIG_USB_BTMTK) += btmtk_usb/ +obj-$(CONFIG_XILLYBUS) += xillybus/ diff --git a/drivers/staging/xillybus/Kconfig b/drivers/staging/xillybus/Kconfig new file mode 100644 index 0000000000000..58fd5488fefbf --- /dev/null +++ b/drivers/staging/xillybus/Kconfig @@ -0,0 +1,35 @@ +# +# Xillybus devices +# + +config XILLYBUS + tristate "Xillybus generic FPGA interface" + depends on PCI || (OF_ADDRESS && OF_DEVICE && OF_IRQ) + default n + help + Xillybus is a generic interface for peripherals designed on + programmable logic (FPGA). The driver probes the hardware for + its capabilities, and creates device files accordingly. + + If unsure, say N. + +if XILLYBUS + +config XILLYBUS_PCIE + tristate "Xillybus over PCIe" + depends on XILLYBUS && PCI + default n + help + Set to M if you want Xillybus to use PCI Express for communicating + with the FPGA. + +config XILLYBUS_OF + tristate "Xillybus over Device Tree" + depends on XILLYBUS && OF_ADDRESS && OF_DEVICE && OF_IRQ + default n + help + Set to M if you want Xillybus to find its resources from the + Open Firmware Flattened Device Tree. If the target is an embedded + system, say M. + +endif # if XILLYBUS diff --git a/drivers/staging/xillybus/Makefile b/drivers/staging/xillybus/Makefile new file mode 100644 index 0000000000000..b68b7ebfd3819 --- /dev/null +++ b/drivers/staging/xillybus/Makefile @@ -0,0 +1,7 @@ +# +# Makefile for Xillybus driver +# + +obj-$(CONFIG_XILLYBUS) += xillybus_core.o +obj-$(CONFIG_XILLYBUS_PCIE) += xillybus_pcie.o +obj-$(CONFIG_XILLYBUS_OF) += xillybus_of.o diff --git a/drivers/staging/xillybus/README b/drivers/staging/xillybus/README new file mode 100644 index 0000000000000..d2d848ae3169e --- /dev/null +++ b/drivers/staging/xillybus/README @@ -0,0 +1,403 @@ + + ========================================== + Xillybus driver for generic FPGA interface + ========================================== + +Author: Eli Billauer, Xillybus Ltd. (http://xillybus.com) +Email: eli.billauer@gmail.com or as advertised on Xillybus' site. + +Contents: + + - Introduction + -- Background + -- Xillybus Overview + + - Usage + -- User interface + -- Synchronization + -- Seekable pipes + +- Internals + -- Source code organization + -- Pipe attributes + -- Host never reads from the FPGA + -- Channels, pipes, and the message channel + -- Data streaming + -- Data granularity + -- Probing + -- Buffer allocation + -- Memory management + -- The "nonempty" message (supporting poll) + + +INTRODUCTION +============ + +Background +---------- + +An FPGA (Field Programmable Gate Array) is a piece of logic hardware, which +can be programmed to become virtually anything that is usually found as a +dedicated chipset: For instance, a display adapter, network interface card, +or even a processor with its peripherals. FPGAs are the LEGO of hardware: +Based upon certain building blocks, you make your own toys the way you like +them. It's usually pointless to reimplement something that is already +available on the market as a chipset, so FPGAs are mostly used when some +special functionality is needed, and the production volume is relatively low +(hence not justifying the development of an ASIC). + +The challenge with FPGAs is that everything is implemented at a very low +level, even lower than assembly language. In order to allow FPGA designers to +focus on their specific project, and not reinvent the wheel over and over +again, pre-designed building blocks, IP cores, are often used. These are the +FPGA parallels of library functions. IP cores may implement certain +mathematical functions, a functional unit (e.g. a USB interface), an entire +processor (e.g. ARM) or anything that might come handy. Think of them as a +building block, with electrical wires dangling on the sides for connection to +other blocks. + +One of the daunting tasks in FPGA design is communicating with a fullblown +operating system (actually, with the processor running it): Implementing the +low-level bus protocol and the somewhat higher-level interface with the host +(registers, interrupts, DMA etc.) is a project in itself. When the FPGA's +function is a well-known one (e.g. a video adapter card, or a NIC), it can +make sense to design the FPGA's interface logic specifically for the project. +A special driver is then written to present the FPGA as a well-known interface +to the kernel and/or user space. In that case, there is no reason to treat the +FPGA differently than any device on the bus. + +It's however common that the desired data communication doesn't fit any well- +known peripheral function. Also, the effort of designing an elegant +abstraction for the data exchange is often considered too big. In those cases, +a quicker and possibly less elegant solution is sought: The driver is +effectively written as a user space program, leaving the kernel space part +with just elementary data transport. This still requires designing some +interface logic for the FPGA, and write a simple ad-hoc driver for the kernel. + +Xillybus Overview +----------------- + +Xillybus is an IP core and a Linux driver. Together, they form a kit for +elementary data transport between an FPGA and the host, providing pipe-like +data streams with a straightforward user interface. It's intended as a low- +effort solution for mixed FPGA-host projects, for which it makes sense to +have the project-specific part of the driver running in a user-space program. + +Since the communication requirements may vary significantly from one FPGA +project to another (the number of data pipes needed in each direction and +their attributes), there isn't one specific chunk of logic being the Xillybus +IP core. Rather, the IP core is configured and built based upon a +specification given by its end user. + +Xillybus presents independent data streams, which resemble pipes or TCP/IP +communication to the user. At the host side, a character device file is used +just like any pipe file. On the FPGA side, hardware FIFOs are used to stream +the data. This is contrary to a common method of communicating through fixed- +sized buffers (even though such buffers are used by Xillybus under the hood). +There may be more than a hundred of these streams on a single IP core, but +also no more than one, depending on the configuration. + +In order to ease the deployment of the Xillybus IP core, it contains a simple +data structure which completely defines the core's configuration. The Linux +driver fetches this data structure during its initialization process, and sets +up the DMA buffers and character devices accordingly. As a result, a single +driver is used to work out of the box with any Xillybus IP core. + +The data structure just mentioned should not be confused with PCI's +configuration space or the Flattened Device Tree. + +USAGE +===== + +User interface +-------------- + +On the host, all interface with Xillybus is done through /dev/xillybus_* +device files, which are generated automatically as the drivers loads. The +names of these files depend on the IP core that is loaded in the FPGA (see +Probing below). To communicate with the FPGA, open the device file that +corresponds to the hardware FIFO you want to send data or receive data from, +and use plain write() or read() calls, just like with a regular pipe. In +particular, it makes perfect sense to go: + +$ cat mydata > /dev/xillybus_thisfifo + +$ cat /dev/xillybus_thatfifo > hisdata + +possibly pressing CTRL-C as some stage, even though the xillybus_* pipes have +the capability to send an EOF (but may not use it). + +The driver and hardware are designed to behave sensibly as pipes, including: + +* Supporting non-blocking I/O (by setting O_NONBLOCK on open() ). + +* Supporting poll() and select(). + +* Being bandwidth efficient under load (using DMA) but also handle small + pieces of data sent across (like TCP/IP) by autoflushing. + +A device file can be read only, write only or bidirectional. Bidirectional +device files are treated like two independent pipes (except for sharing a +"channel" structure in the implementation code). + +Synchronization +--------------- + +Xillybus pipes are configured (on the IP core) to be either synchronous or +asynchronous. For a synchronous pipe, write() returns successfully only after +some data has been submitted and acknowledged by the FPGA. This slows down +bulk data transfers, and is nearly impossible for use with streams that +require data at a constant rate: There is no data transmitted to the FPGA +between write() calls, in particular when the process loses the CPU. + +When a pipe is configured asynchronous, write() returns if there was enough +room in the buffers to store any of the data in the buffers. + +For FPGA to host pipes, asynchronous pipes allow data transfer from the FPGA +as soon as the respective device file is opened, regardless of if the data +has been requested by a read() call. On synchronous pipes, only the amount +of data requested by a read() call is transmitted. + +In summary, for synchronous pipes, data between the host and FPGA is +transmitted only to satisfy the read() or write() call currently handled +by the driver, and those calls wait for the transmission to complete before +returning. + +Note that the synchronization attribute has nothing to do with the possibility +that read() or write() completes less bytes than requested. There is a +separate configuration flag ("allowpartial") that determines whether such a +partial completion is allowed. + +Seekable pipes +-------------- + +A synchronous pipe can be configured to have the stream's position exposed +to the user logic at the FPGA. Such a pipe is also seekable on the host API. +With this feature, a memory or register interface can be attached on the +FPGA side to the seekable stream. Reading or writing to a certain address in +the attached memory is done by seeking to the desired address, and calling +read() or write() as required. + + +INTERNALS +========= + +Source code organization +------------------------ + +The Xillybus driver consists of a core module, xillybus_core.c, and modules +that depend on the specific bus interface (xillybus_of.c and xillybus_pcie.c). + +The bus specific modules are those probed when a suitable device is found by +the kernel. Since the DMA mapping and synchronization functions, which are bus +dependent by their nature, are used by the core module, a +xilly_endpoint_hardware structure is passed to the core module on +initialization. This structure is populated with pointers to wrapper functions +which execute the DMA-related operations on the bus. + +Pipe attributes +--------------- + +Each pipe has a number of attributes which are set when the FPGA component +(IP core) is built. They are fetched from the IDT (the data structure which +defines the core's configuration, see Probing below) by xilly_setupchannels() +in xillybus_core.c as follows: + +* is_writebuf: The pipe's direction. A non-zero value means it's an FPGA to + host pipe (the FPGA "writes"). + +* channelnum: The pipe's identification number in communication between the + host and FPGA. + +* format: The underlying data width. See Data Granularity below. + +* allowpartial: A non-zero value means that a read() or write() (whichever + applies) may return with less than the requested number of bytes. The common + choice is a non-zero value, to match standard UNIX behavior. + +* synchronous: A non-zero value means that the pipe is synchronous. See + Syncronization above. + +* bufsize: Each DMA buffer's size. Always a power of two. + +* bufnum: The number of buffers allocated for this pipe. Always a power of two. + +* exclusive_open: A non-zero value forces exclusive opening of the associated + device file. If the device file is bidirectional, and already opened only in + one direction, the opposite direction may be opened once. + +* seekable: A non-zero value indicates that the pipe is seekable. See + Seekable pipes above. + +* supports_nonempty: A non-zero value (which is typical) indicates that the + hardware will send the messages that are necessary to support select() and + poll() for this pipe. + +Host never reads from the FPGA +------------------------------ + +Even though PCI Express is hotpluggable in general, a typical motherboard +doesn't expect a card to go away all of the sudden. But since the PCIe card +is based upon reprogrammable logic, a sudden disappearance from the bus is +quite likely as a result of an accidental reprogramming of the FPGA while the +host is up. In practice, nothing happens immediately in such a situation. But +if the host attempts to read from an address that is mapped to the PCI Express +device, that leads to an immediate freeze of the system on some motherboards, +even though the PCIe standard requires a graceful recovery. + +In order to avoid these freezes, the Xillybus driver refrains completely from +reading from the device's register space. All communication from the FPGA to +the host is done through DMA. In particular, the Interrupt Service Routine +doesn't follow the common practice of checking a status register when it's +invoked. Rather, the FPGA prepares a small buffer which contains short +messages, which inform the host what the interrupt was about. + +This mechanism is used on non-PCIe buses as well for the sake of uniformity. + + +Channels, pipes, and the message channel +---------------------------------------- + +Each of the (possibly bidirectional) pipes presented to the user is allocated +a data channel between the FPGA and the host. The distinction between channels +and pipes is necessary only because of channel 0, which is used for interrupt- +related messages from the FPGA, and has no pipe attached to it. + +Data streaming +-------------- + +Even though a non-segmented data stream is presented to the user at both +sides, the implementation relies on a set of DMA buffers which is allocated +for each channel. For the sake of illustration, let's take the FPGA to host +direction: As data streams into the respective channel's interface in the +FPGA, the Xillybus IP core writes it to one of the DMA buffers. When the +buffer is full, the FPGA informs the host about that (appending a +XILLYMSG_OPCODE_RELEASEBUF message channel 0 and sending an interrupt if +necessary). The host responds by making the data available for reading through +the character device. When all data has been read, the host writes on the +the FPGA's buffer control register, allowing the buffer's overwriting. Flow +control mechanisms exist on both sides to prevent underflows and overflows. + +This is not good enough for creating a TCP/IP-like stream: If the data flow +stops momentarily before a DMA buffer is filled, the intuitive expectation is +that the partial data in buffer will arrive anyhow, despite the buffer not +being completed. This is implemented by adding a field in the +XILLYMSG_OPCODE_RELEASEBUF message, through which the FPGA informs not just +which buffer is submitted, but how much data it contains. + +But the FPGA will submit a partially filled buffer only if directed to do so +by the host. This situation occurs when the read() method has been blocking +for XILLY_RX_TIMEOUT jiffies (currently 10 ms), after which the host commands +the FPGA to submit a DMA buffer as soon as it can. This timeout mechanism +balances between bus bandwidth efficiency (preventing a lot of partially +filled buffers being sent) and a latency held fairly low for tails of data. + +A similar setting is used in the host to FPGA direction. The handling of +partial DMA buffers is somewhat different, though. The user can tell the +driver to submit all data it has in the buffers to the FPGA, by issuing a +write() with the byte count set to zero. This is similar to a flush request, +but it doesn't block. There is also an autoflushing mechanism, which triggers +an equivalent flush roughly XILLY_RX_TIMEOUT jiffies after the last write(). +This allows the user to be oblivious about the underlying buffering mechanism +and yet enjoy a stream-like interface. + +Note that the issue of partial buffer flushing is irrelevant for pipes having +the "synchronous" attribute nonzero, since synchronous pipes don't allow data +to lay around in the DMA buffers between read() and write() anyhow. + +Data granularity +---------------- + +The data arrives or is sent at the FPGA as 8, 16 or 32 bit wide words, as +configured by the "format" attribute. Whenever possible, the driver attempts +to hide this when the pipe is accessed differently from its natural alignment. +For example, reading single bytes from a pipe with 32 bit granularity works +with no issues. Writing single bytes to pipes with 16 or 32 bit granularity +will also work, but the driver can't send partially completed words to the +FPGA, so the transmission of up to one word may be held until it's fully +occupied with user data. + +This somewhat complicates the handling of host to FPGA streams, because +when a buffer is flushed, it may contain up to 3 bytes don't form a word in +the FPGA, and hence can't be sent. To prevent loss of data, these leftover +bytes need to be moved to the next buffer. The parts in xillybus_core.c +that mention "leftovers" in some way are related to this complication. + +Probing +------- + +As mentioned earlier, the number of pipes that are created when the driver +loads and their attributes depend on the Xillybus IP core in the FPGA. During +the driver's initialization, a blob containing configuration info, the +Interface Description Table (IDT), is sent from the FPGA to the host. The +bootstrap process is done in three phases: + +1. Acquire the length of the IDT, so a buffer can be allocated for it. This + is done by sending a quiesce command to the device, since the acknowledge + for this command contains the IDT's buffer length. + +2. Acquire the IDT itself. + +3. Create the interfaces according to the IDT. + +Buffer allocation +----------------- + +In order to simplify the logic that prevents illegal boundary crossings of +PCIe packets, the following rule applies: If a buffer is smaller than 4kB, +it must not cross a 4kB boundary. Otherwise, it must be 4kB aligned. The +xilly_setupchannels() functions allocates these buffers by requesting whole +pages from the kernel, and diving them into DMA buffers as necessary. Since +all buffers' sizes are powers of two, it's possible to pack any set of such +buffers, with a maximal waste of one page of memory. + +All buffers are allocated when the driver is loaded. This is necessary, +since large continuous physical memory segments are sometimes requested, +which are more likely to be available when the system is freshly booted. + +The allocation of buffer memory takes place in the same order they appear in +the IDT. The driver relies on a rule that the pipes are sorted with decreasing +buffer size in the IDT. If a requested buffer is larger or equal to a page, +the necessary number of pages is requested from the kernel, and these are +used for this buffer. If the requested buffer is smaller than a page, one +single page is requested from the kernel, and that page is partially used. +Or, if there already is a partially used page at hand, the buffer is packed +into that page. It can be shown that all pages requested from the kernel +(except possibly for the last) are 100% utilized this way. + +Memory management +----------------- + +The tricky part about the buffer allocation procedure described above is +freeing and unmapping the buffers, in particular if something goes wrong in +the middle, and the allocations need to be rolled back. The three-stage +probing procedure makes this even more crucial, since temporary buffers are +set up and mapped in the first of its two stages. + +To keep the code clean from complicated and bug-prone memory release routines, +there are special routines for allocating memory. For example, instead of +calling kzalloc, there's + +void *xilly_malloc(struct xilly_cleanup *mem, size_t size) + +which effectively allocates a zeroed buffer of size "size". Its first +argument, "mem", is where this allocation is enlisted, so that it's released +when xillybus_do_cleanup() is called with the same "mem" structure. + +Two other functions enlist allocations in this structure: xilly_pagealloc() +for page allocations and xilly_map_single_*() for DMA mapping. + +The "nonempty" message (supporting poll) +--------------------------------------- + +In order to support the "poll" method (and hence select() ), there is a small +catch regarding the FPGA to host direction: The FPGA may have filled a DMA +buffer with some data, but not submitted that buffer. If the host waited for +the buffer's submission by the FPGA, there would be a possibility that the +FPGA side has sent data, but a select() call would still block, because the +host has not received any notification about this. This is solved with +XILLYMSG_OPCODE_NONEMPTY messages sent by the FPGA when a channel goes from +completely empty to containing some data. + +These messages are used only to support poll() and select(). The IP core can +be configured not to send them for a slight reduction of bandwidth. diff --git a/drivers/staging/xillybus/TODO b/drivers/staging/xillybus/TODO new file mode 100644 index 0000000000000..95cfe2f62fcdd --- /dev/null +++ b/drivers/staging/xillybus/TODO @@ -0,0 +1,5 @@ +TODO: +- have the driver reviewed + +Please send any patches and/or comments to Eli Billauer, +. diff --git a/drivers/staging/xillybus/xillybus.h b/drivers/staging/xillybus/xillybus.h new file mode 100644 index 0000000000000..c260ebcc6c4d0 --- /dev/null +++ b/drivers/staging/xillybus/xillybus.h @@ -0,0 +1,185 @@ +/* + * linux/drivers/misc/xillybus.h + * + * Copyright 2011 Xillybus Ltd, http://xillybus.com + * + * Header file for the Xillybus FPGA/host framework. + * + * This program is free software; you can redistribute it and/or modify + * it under the smems of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + */ + +#ifndef __XILLYBUS_H +#define __XILLYBUS_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +char xillyname[] = "xillybus"; + +struct xilly_endpoint_hardware; + +struct xilly_page { + struct list_head node; + unsigned long addr; + unsigned int order; +}; + +struct xilly_dma { + struct list_head node; + struct pci_dev *pdev; + struct device *dev; + dma_addr_t dma_addr; + size_t size; + int direction; +}; + +struct xilly_buffer { + void *addr; + dma_addr_t dma_addr; + int end_offset; /* Counting elements, not bytes */ +}; + +struct xilly_cleanup { + struct list_head to_kfree; + struct list_head to_pagefree; + struct list_head to_unmap; +}; + +struct xilly_idt_handle { + unsigned char *chandesc; + unsigned char *idt; + int entries; +}; + +/* + * Read-write confusion: wr_* and rd_* notation sticks to FPGA view, so + * wr_* buffers are those consumed by read(), since the FPGA writes to them + * and vice versa. + */ + +struct xilly_channel { + struct xilly_endpoint *endpoint; + int chan_num; + int log2_element_size; + int seekable; + + struct xilly_buffer **wr_buffers; /* FPGA writes, driver reads! */ + int num_wr_buffers; + unsigned int wr_buf_size; /* In bytes */ + int wr_fpga_buf_idx; + int wr_host_buf_idx; + int wr_host_buf_pos; + int wr_empty; + int wr_ready; /* Significant only when wr_empty == 1 */ + int wr_sleepy; + int wr_eof; + int wr_hangup; + spinlock_t wr_spinlock; + struct mutex wr_mutex; + wait_queue_head_t wr_wait; + wait_queue_head_t wr_ready_wait; + int wr_ref_count; + int wr_synchronous; + int wr_allow_partial; + int wr_exclusive_open; + int wr_supports_nonempty; + + struct xilly_buffer **rd_buffers; /* FPGA reads, driver writes! */ + int num_rd_buffers; + unsigned int rd_buf_size; /* In bytes */ + int rd_fpga_buf_idx; + int rd_host_buf_pos; + int rd_host_buf_idx; + int rd_full; + spinlock_t rd_spinlock; + struct mutex rd_mutex; + wait_queue_head_t rd_wait; + int rd_ref_count; + int rd_allow_partial; + int rd_synchronous; + int rd_exclusive_open; + struct delayed_work rd_workitem; + unsigned char rd_leftovers[4]; +}; + +struct xilly_endpoint { + /* + * One of pdev and dev is always NULL, and the other is a valid + * pointer, depending on the type of device + */ + struct pci_dev *pdev; + struct device *dev; + struct resource res; /* OF devices only */ + struct xilly_endpoint_hardware *ephw; + + struct list_head ep_list; + int dma_using_dac; /* =1 if 64-bit DMA is used, =0 otherwise. */ + u32 *registers; + int fatal_error; + + struct mutex register_mutex; + wait_queue_head_t ep_wait; + + /* List of memory allocations, to make release easy */ + struct xilly_cleanup cleanup; + + /* Channels and message handling */ + struct cdev cdev; + + int major; + int lowest_minor; /* Highest minor = lowest_minor + num_channels - 1 */ + + int num_channels; /* EXCLUDING message buffer */ + struct xilly_channel **channels; + int msg_counter; + int failed_messages; + int idtlen; + + u32 *msgbuf_addr; + dma_addr_t msgbuf_dma_addr; + unsigned int msg_buf_size; +}; + +struct xilly_endpoint_hardware { + struct module *owner; + void (*sync_single_for_cpu)(struct xilly_endpoint *, + dma_addr_t, + size_t, + int); + void (*sync_single_for_device)(struct xilly_endpoint *, + dma_addr_t, + size_t, + int); + dma_addr_t (*map_single)(struct xilly_cleanup *, + struct xilly_endpoint *, + void *, + size_t, + int); + void (*unmap_single)(struct xilly_dma *entry); +}; + +irqreturn_t xillybus_isr(int irq, void *data); + +void xillybus_do_cleanup(struct xilly_cleanup *mem, + struct xilly_endpoint *endpoint); + +struct xilly_endpoint *xillybus_init_endpoint(struct pci_dev *pdev, + struct device *dev, + struct xilly_endpoint_hardware + *ephw); + +int xillybus_endpoint_discovery(struct xilly_endpoint *endpoint); + +void xillybus_endpoint_remove(struct xilly_endpoint *endpoint); + +#endif /* __XILLYBUS_H */ diff --git a/drivers/staging/xillybus/xillybus_core.c b/drivers/staging/xillybus/xillybus_core.c new file mode 100644 index 0000000000000..dd0a71c6b518e --- /dev/null +++ b/drivers/staging/xillybus/xillybus_core.c @@ -0,0 +1,2345 @@ +/* + * linux/drivers/misc/xillybus_core.c + * + * Copyright 2011 Xillybus Ltd, http://xillybus.com + * + * Driver for the Xillybus FPGA/host framework. + * + * This driver interfaces with a special IP core in an FPGA, setting up + * a pipe between a hardware FIFO in the programmable logic and a device + * file in the host. The number of such pipes and their attributes are + * set up on the logic. This driver detects these automatically and + * creates the device files accordingly. + * + * This program is free software; you can redistribute it and/or modify + * it under the smems of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "xillybus.h" + +MODULE_DESCRIPTION("Xillybus core functions"); +MODULE_AUTHOR("Eli Billauer, Xillybus Ltd."); +MODULE_VERSION("1.07"); +MODULE_ALIAS("xillybus_core"); +MODULE_LICENSE("GPL v2"); + +/* General timeout is 100 ms, rx timeout is 10 ms */ +#define XILLY_RX_TIMEOUT (10*HZ/1000) +#define XILLY_TIMEOUT (100*HZ/1000) + +#define fpga_msg_ctrl_reg 0x0002 +#define fpga_dma_control_reg 0x0008 +#define fpga_dma_bufno_reg 0x0009 +#define fpga_dma_bufaddr_lowaddr_reg 0x000a +#define fpga_dma_bufaddr_highaddr_reg 0x000b +#define fpga_buf_ctrl_reg 0x000c +#define fpga_buf_offset_reg 0x000d +#define fpga_endian_reg 0x0010 + +#define XILLYMSG_OPCODE_RELEASEBUF 1 +#define XILLYMSG_OPCODE_QUIESCEACK 2 +#define XILLYMSG_OPCODE_FIFOEOF 3 +#define XILLYMSG_OPCODE_FATAL_ERROR 4 +#define XILLYMSG_OPCODE_NONEMPTY 5 + +static struct class *xillybus_class; + +/* + * ep_list_lock is the last lock to be taken; No other lock requests are + * allowed while holding it. It merely protects list_of_endpoints, and not + * the endpoints listed in it. + */ + +static LIST_HEAD(list_of_endpoints); +static struct mutex ep_list_lock; +struct workqueue_struct *xillybus_wq; + +/* + * Locking scheme: Mutexes protect invocations of character device methods. + * If both locks are taken, wr_mutex is taken first, rd_mutex second. + * + * wr_spinlock protects wr_*_buf_idx, wr_empty, wr_sleepy, wr_ready and the + * buffers' end_offset fields against changes made by IRQ handler (and in + * theory, other file request handlers, but the mutex handles that). Nothing + * else. + * They are held for short direct memory manipulations. Needless to say, + * no mutex locking is allowed when a spinlock is held. + * + * rd_spinlock does the same with rd_*_buf_idx, rd_empty and end_offset. + * + * register_mutex is endpoint-specific, and is held when non-atomic + * register operations are performed. wr_mutex and rd_mutex may be + * held when register_mutex is taken, but none of the spinlocks. Note that + * register_mutex doesn't protect against sporadic buf_ctrl_reg writes + * which are unrelated to buf_offset_reg, since they are harmless. + * + * Blocking on the wait queues is allowed with mutexes held, but not with + * spinlocks. + * + * Only interruptible blocking is allowed on mutexes and wait queues. + * + * All in all, the locking order goes (with skips allowed, of course): + * wr_mutex -> rd_mutex -> register_mutex -> wr_spinlock -> rd_spinlock + */ + +static void malformed_message(u32 *buf) +{ + int opcode; + int msg_channel, msg_bufno, msg_data, msg_dir; + + opcode = (buf[0] >> 24) & 0xff; + msg_dir = buf[0] & 1; + msg_channel = (buf[0] >> 1) & 0x7ff; + msg_bufno = (buf[0] >> 12) & 0x3ff; + msg_data = buf[1] & 0xfffffff; + + pr_warn("xillybus: Malformed message (skipping): " + "opcode=%d, channel=%03x, dir=%d, bufno=%03x, data=%07x\n", + opcode, msg_channel, msg_dir, msg_bufno, msg_data); +} + +/* + * xillybus_isr assumes the interrupt is allocated exclusively to it, + * which is the natural case MSI and several other hardware-oriented + * interrupts. Sharing is not allowed. + */ + +irqreturn_t xillybus_isr(int irq, void *data) +{ + struct xilly_endpoint *ep = data; + u32 *buf; + unsigned int buf_size; + int i; + int opcode; + unsigned int msg_channel, msg_bufno, msg_data, msg_dir; + struct xilly_channel *channel; + + /* + * The endpoint structure is altered during periods when it's + * guaranteed no interrupt will occur, but in theory, the cache + * lines may not be updated. So a memory barrier is issued. + */ + + smp_rmb(); + + buf = ep->msgbuf_addr; + buf_size = ep->msg_buf_size/sizeof(u32); + + + ep->ephw->sync_single_for_cpu(ep, + ep->msgbuf_dma_addr, + ep->msg_buf_size, + DMA_FROM_DEVICE); + + for (i = 0; i < buf_size; i += 2) + if (((buf[i+1] >> 28) & 0xf) != ep->msg_counter) { + malformed_message(&buf[i]); + pr_warn("xillybus: Sending a NACK on " + "counter %x (instead of %x) on entry %d\n", + ((buf[i+1] >> 28) & 0xf), + ep->msg_counter, + i/2); + + if (++ep->failed_messages > 10) + pr_err("xillybus: Lost sync with " + "interrupt messages. Stopping.\n"); + else { + ep->ephw->sync_single_for_device( + ep, + ep->msgbuf_dma_addr, + ep->msg_buf_size, + DMA_FROM_DEVICE); + + iowrite32(0x01, /* Message NACK */ + &ep->registers[fpga_msg_ctrl_reg]); + } + return IRQ_HANDLED; + } else if (buf[i] & (1 << 22)) /* Last message */ + break; + + if (i >= buf_size) { + pr_err("xillybus: Bad interrupt message. Stopping.\n"); + return IRQ_HANDLED; + } + + buf_size = i; + + for (i = 0; i <= buf_size; i += 2) { /* Scan through messages */ + opcode = (buf[i] >> 24) & 0xff; + + msg_dir = buf[i] & 1; + msg_channel = (buf[i] >> 1) & 0x7ff; + msg_bufno = (buf[i] >> 12) & 0x3ff; + msg_data = buf[i+1] & 0xfffffff; + + switch (opcode) { + case XILLYMSG_OPCODE_RELEASEBUF: + + if ((msg_channel > ep->num_channels) || + (msg_channel == 0)) { + malformed_message(&buf[i]); + break; + } + + channel = ep->channels[msg_channel]; + + if (msg_dir) { /* Write channel */ + if (msg_bufno >= channel->num_wr_buffers) { + malformed_message(&buf[i]); + break; + } + spin_lock(&channel->wr_spinlock); + channel->wr_buffers[msg_bufno]->end_offset = + msg_data; + channel->wr_fpga_buf_idx = msg_bufno; + channel->wr_empty = 0; + channel->wr_sleepy = 0; + spin_unlock(&channel->wr_spinlock); + + wake_up_interruptible(&channel->wr_wait); + + } else { + /* Read channel */ + + if (msg_bufno >= channel->num_rd_buffers) { + malformed_message(&buf[i]); + break; + } + + spin_lock(&channel->rd_spinlock); + channel->rd_fpga_buf_idx = msg_bufno; + channel->rd_full = 0; + spin_unlock(&channel->rd_spinlock); + + wake_up_interruptible(&channel->rd_wait); + if (!channel->rd_synchronous) + queue_delayed_work( + xillybus_wq, + &channel->rd_workitem, + XILLY_RX_TIMEOUT); + } + + break; + case XILLYMSG_OPCODE_NONEMPTY: + if ((msg_channel > ep->num_channels) || + (msg_channel == 0) || (!msg_dir) || + !ep->channels[msg_channel]->wr_supports_nonempty) { + malformed_message(&buf[i]); + break; + } + + channel = ep->channels[msg_channel]; + + if (msg_bufno >= channel->num_wr_buffers) { + malformed_message(&buf[i]); + break; + } + spin_lock(&channel->wr_spinlock); + if (msg_bufno == channel->wr_host_buf_idx) + channel->wr_ready = 1; + spin_unlock(&channel->wr_spinlock); + + wake_up_interruptible(&channel->wr_ready_wait); + + break; + case XILLYMSG_OPCODE_QUIESCEACK: + ep->idtlen = msg_data; + wake_up_interruptible(&ep->ep_wait); + + break; + case XILLYMSG_OPCODE_FIFOEOF: + channel = ep->channels[msg_channel]; + spin_lock(&channel->wr_spinlock); + channel->wr_eof = msg_bufno; + channel->wr_sleepy = 0; + + channel->wr_hangup = channel->wr_empty && + (channel->wr_host_buf_idx == msg_bufno); + + spin_unlock(&channel->wr_spinlock); + + wake_up_interruptible(&channel->wr_wait); + + break; + case XILLYMSG_OPCODE_FATAL_ERROR: + ep->fatal_error = 1; + wake_up_interruptible(&ep->ep_wait); /* For select() */ + pr_err("xillybus: FPGA reported a fatal " + "error. This means that the low-level " + "communication with the device has failed. " + "This hardware problem is most likely " + "unrelated to xillybus (neither kernel " + "module nor FPGA core), but reports are " + "still welcome. All I/O is aborted.\n"); + break; + default: + malformed_message(&buf[i]); + break; + } + } + + ep->ephw->sync_single_for_device(ep, + ep->msgbuf_dma_addr, + ep->msg_buf_size, + DMA_FROM_DEVICE); + + ep->msg_counter = (ep->msg_counter + 1) & 0xf; + ep->failed_messages = 0; + iowrite32(0x03, &ep->registers[fpga_msg_ctrl_reg]); /* Message ACK */ + + return IRQ_HANDLED; +} +EXPORT_SYMBOL(xillybus_isr); + +/* + * A few trivial memory management functions. + * NOTE: These functions are used only on probe and remove, and therefore + * no locks are applied! + */ + +void xillybus_do_cleanup(struct xilly_cleanup *mem, + struct xilly_endpoint *endpoint) +{ + struct list_head *this, *next; + + list_for_each_safe(this, next, &mem->to_unmap) { + struct xilly_dma *entry = + list_entry(this, struct xilly_dma, node); + + endpoint->ephw->unmap_single(entry); + kfree(entry); + } + + INIT_LIST_HEAD(&mem->to_unmap); + + list_for_each_safe(this, next, &mem->to_kfree) + kfree(this); + + INIT_LIST_HEAD(&mem->to_kfree); + + list_for_each_safe(this, next, &mem->to_pagefree) { + struct xilly_page *entry = + list_entry(this, struct xilly_page, node); + + free_pages(entry->addr, entry->order); + kfree(entry); + } + INIT_LIST_HEAD(&mem->to_pagefree); +} +EXPORT_SYMBOL(xillybus_do_cleanup); + +static void *xilly_malloc(struct xilly_cleanup *mem, size_t size) +{ + void *ptr; + + ptr = kzalloc(sizeof(struct list_head) + size, GFP_KERNEL); + + if (!ptr) + return ptr; + + list_add_tail((struct list_head *) ptr, &mem->to_kfree); + + return ptr + sizeof(struct list_head); +} + +static unsigned long xilly_pagealloc(struct xilly_cleanup *mem, + unsigned long order) +{ + unsigned long addr; + struct xilly_page *this; + + this = kmalloc(sizeof(struct xilly_page), GFP_KERNEL); + if (!this) + return 0; + + addr = __get_free_pages(GFP_KERNEL | __GFP_DMA32 | __GFP_ZERO, order); + + if (!addr) { + kfree(this); + return 0; + } + + this->addr = addr; + this->order = order; + + list_add_tail(&this->node, &mem->to_pagefree); + + return addr; +} + + +static void xillybus_autoflush(struct work_struct *work); + +static int xilly_setupchannels(struct xilly_endpoint *ep, + struct xilly_cleanup *mem, + unsigned char *chandesc, + int entries + ) +{ + int i, entry, wr_nbuffer, rd_nbuffer; + struct xilly_channel *channel; + int channelnum, bufnum, bufsize, format, is_writebuf; + int bytebufsize; + int synchronous, allowpartial, exclusive_open, seekable; + int supports_nonempty; + void *wr_salami = NULL; + void *rd_salami = NULL; + int left_of_wr_salami = 0; + int left_of_rd_salami = 0; + dma_addr_t dma_addr; + int msg_buf_done = 0; + + struct xilly_buffer *this_buffer = NULL; /* Init to silence warning */ + + channel = xilly_malloc(mem, ep->num_channels * + sizeof(struct xilly_channel)); + + if (!channel) + goto memfail; + + ep->channels = xilly_malloc(mem, (ep->num_channels + 1) * + sizeof(struct xilly_channel *)); + + if (!ep->channels) + goto memfail; + + ep->channels[0] = NULL; /* Channel 0 is message buf. */ + + /* Initialize all channels with defaults */ + + for (i = 1; i <= ep->num_channels; i++) { + channel->wr_buffers = NULL; + channel->rd_buffers = NULL; + channel->num_wr_buffers = 0; + channel->num_rd_buffers = 0; + channel->wr_fpga_buf_idx = -1; + channel->wr_host_buf_idx = 0; + channel->wr_host_buf_pos = 0; + channel->wr_empty = 1; + channel->wr_ready = 0; + channel->wr_sleepy = 1; + channel->rd_fpga_buf_idx = 0; + channel->rd_host_buf_idx = 0; + channel->rd_host_buf_pos = 0; + channel->rd_full = 0; + channel->wr_ref_count = 0; + channel->rd_ref_count = 0; + + spin_lock_init(&channel->wr_spinlock); + spin_lock_init(&channel->rd_spinlock); + mutex_init(&channel->wr_mutex); + mutex_init(&channel->rd_mutex); + init_waitqueue_head(&channel->rd_wait); + init_waitqueue_head(&channel->wr_wait); + init_waitqueue_head(&channel->wr_ready_wait); + + INIT_DELAYED_WORK(&channel->rd_workitem, xillybus_autoflush); + + channel->endpoint = ep; + channel->chan_num = i; + + channel->log2_element_size = 0; + + ep->channels[i] = channel++; + } + + /* + * The DMA buffer address update is atomic on the FPGA, so even if + * it was in the middle of sending messages to some buffer, changing + * the address is safe, since the data will go to either of the + * buffers. Not that this situation should occur at all anyhow. + */ + + wr_nbuffer = 1; + rd_nbuffer = 1; /* Buffer zero isn't used at all */ + + for (entry = 0; entry < entries; entry++, chandesc += 4) { + is_writebuf = chandesc[0] & 0x01; + channelnum = (chandesc[0] >> 1) | ((chandesc[1] & 0x0f) << 7); + format = (chandesc[1] >> 4) & 0x03; + allowpartial = (chandesc[1] >> 6) & 0x01; + synchronous = (chandesc[1] >> 7) & 0x01; + bufsize = 1 << (chandesc[2] & 0x1f); + bufnum = 1 << (chandesc[3] & 0x0f); + exclusive_open = (chandesc[2] >> 7) & 0x01; + seekable = (chandesc[2] >> 6) & 0x01; + supports_nonempty = (chandesc[2] >> 5) & 0x01; + + if ((channelnum > ep->num_channels) || + ((channelnum == 0) && !is_writebuf)) { + pr_err("xillybus: IDT requests channel out " + "of range. Aborting.\n"); + return -ENODEV; + } + + channel = ep->channels[channelnum]; /* NULL for msg channel */ + + bytebufsize = bufsize << 2; /* Overwritten just below */ + + if (!is_writebuf) { + channel->num_rd_buffers = bufnum; + channel->log2_element_size = ((format > 2) ? + 2 : format); + bytebufsize = channel->rd_buf_size = bufsize * + (1 << channel->log2_element_size); + channel->rd_allow_partial = allowpartial; + channel->rd_synchronous = synchronous; + channel->rd_exclusive_open = exclusive_open; + channel->seekable = seekable; + + channel->rd_buffers = xilly_malloc( + mem, + bufnum * sizeof(struct xilly_buffer *)); + + if (!channel->rd_buffers) + goto memfail; + + this_buffer = xilly_malloc( + mem, + bufnum * sizeof(struct xilly_buffer)); + + if (!this_buffer) + goto memfail; + } + + else if (channelnum > 0) { + channel->num_wr_buffers = bufnum; + channel->log2_element_size = ((format > 2) ? + 2 : format); + bytebufsize = channel->wr_buf_size = bufsize * + (1 << channel->log2_element_size); + + channel->seekable = seekable; + channel->wr_supports_nonempty = supports_nonempty; + + channel->wr_allow_partial = allowpartial; + channel->wr_synchronous = synchronous; + channel->wr_exclusive_open = exclusive_open; + + channel->wr_buffers = xilly_malloc( + mem, + bufnum * sizeof(struct xilly_buffer *)); + + if (!channel->wr_buffers) + goto memfail; + + this_buffer = xilly_malloc( + mem, + bufnum * sizeof(struct xilly_buffer)); + + if (!this_buffer) + goto memfail; + } + + /* + * Although daunting, we cut the chunks for read buffers + * from a different salami than the write buffers', + * possibly improving performance. + */ + + if (is_writebuf) + for (i = 0; i < bufnum; i++) { + /* + * Buffers are expected in descending + * byte-size order, so there is either + * enough for this buffer or none at all. + */ + if ((left_of_wr_salami < bytebufsize) && + (left_of_wr_salami > 0)) { + pr_err("xillybus: " + "Corrupt buffer allocation " + "in IDT. Aborting.\n"); + return -ENODEV; + } + + if (left_of_wr_salami == 0) { + int allocorder, allocsize; + + allocsize = PAGE_SIZE; + allocorder = 0; + while (bytebufsize > allocsize) { + allocsize *= 2; + allocorder++; + } + + wr_salami = (void *) + xilly_pagealloc(mem, + allocorder); + if (!wr_salami) + goto memfail; + left_of_wr_salami = allocsize; + } + + dma_addr = ep->ephw->map_single( + mem, + ep, + wr_salami, + bytebufsize, + DMA_FROM_DEVICE); + + if (!dma_addr) + goto dmafail; + + iowrite32( + (u32) (dma_addr & 0xffffffff), + &ep->registers[ + fpga_dma_bufaddr_lowaddr_reg] + ); + iowrite32( + ((u32) ((((u64) dma_addr) >> 32) + & 0xffffffff)), + &ep->registers[ + fpga_dma_bufaddr_highaddr_reg] + ); + mmiowb(); + + if (channelnum > 0) { + this_buffer->addr = wr_salami; + this_buffer->dma_addr = dma_addr; + channel->wr_buffers[i] = this_buffer++; + + iowrite32( + 0x80000000 | wr_nbuffer++, + &ep->registers[ + fpga_dma_bufno_reg]); + } else { + ep->msgbuf_addr = wr_salami; + ep->msgbuf_dma_addr = dma_addr; + ep->msg_buf_size = bytebufsize; + msg_buf_done++; + + iowrite32( + 0x80000000, &ep->registers[ + fpga_dma_bufno_reg]); + } + + left_of_wr_salami -= bytebufsize; + wr_salami += bytebufsize; + } + else /* Read buffers */ + for (i = 0; i < bufnum; i++) { + /* + * Buffers are expected in descending + * byte-size order, so there is either + * enough for this buffer or none at all. + */ + if ((left_of_rd_salami < bytebufsize) && + (left_of_rd_salami > 0)) { + pr_err("xillybus: " + "Corrupt buffer allocation " + "in IDT. Aborting.\n"); + return -ENODEV; + } + + if (left_of_rd_salami == 0) { + int allocorder, allocsize; + + allocsize = PAGE_SIZE; + allocorder = 0; + while (bytebufsize > allocsize) { + allocsize *= 2; + allocorder++; + } + + rd_salami = (void *) + xilly_pagealloc( + mem, + allocorder); + + if (!rd_salami) + goto memfail; + left_of_rd_salami = allocsize; + } + + dma_addr = ep->ephw->map_single( + mem, + ep, + rd_salami, + bytebufsize, + DMA_TO_DEVICE); + + if (!dma_addr) + goto dmafail; + + iowrite32( + (u32) (dma_addr & 0xffffffff), + &ep->registers[ + fpga_dma_bufaddr_lowaddr_reg] + ); + iowrite32( + ((u32) ((((u64) dma_addr) >> 32) + & 0xffffffff)), + &ep->registers[ + fpga_dma_bufaddr_highaddr_reg] + ); + mmiowb(); + + this_buffer->addr = rd_salami; + this_buffer->dma_addr = dma_addr; + channel->rd_buffers[i] = this_buffer++; + + iowrite32(rd_nbuffer++, + &ep->registers[fpga_dma_bufno_reg]); + + left_of_rd_salami -= bytebufsize; + rd_salami += bytebufsize; + } + } + + if (!msg_buf_done) { + pr_err("xillybus: Corrupt IDT: No message buffer. " + "Aborting.\n"); + return -ENODEV; + } + + return 0; + +memfail: + pr_err("xillybus: Failed to allocate write buffer memory. " + "Aborting.\n"); + return -ENOMEM; +dmafail: + pr_err("xillybus: Failed to map DMA memory!. Aborting.\n"); + return -ENOMEM; +} + +static void xilly_scan_idt(struct xilly_endpoint *endpoint, + struct xilly_idt_handle *idt_handle) +{ + int count = 0; + unsigned char *idt = endpoint->channels[1]->wr_buffers[0]->addr; + unsigned char *end_of_idt = idt + endpoint->idtlen - 4; + unsigned char *scan; + int len; + + scan = idt; + idt_handle->idt = idt; + + scan++; /* Skip version number */ + + while ((scan <= end_of_idt) && *scan) { + while ((scan <= end_of_idt) && *scan++) + /* Do nothing, just scan thru string */; + count++; + } + + scan++; + + if (scan > end_of_idt) { + pr_err("xillybus: IDT device name list overflow. " + "Aborting.\n"); + idt_handle->chandesc = NULL; + return; + } else + idt_handle->chandesc = scan; + + len = endpoint->idtlen - (3 + ((int) (scan - idt))); + + if (len & 0x03) { + idt_handle->chandesc = NULL; + + pr_err("xillybus: Corrupt IDT device name list. " + "Aborting.\n"); + } + + idt_handle->entries = len >> 2; + + endpoint->num_channels = count; +} + +static int xilly_obtain_idt(struct xilly_endpoint *endpoint) +{ + int rc = 0; + struct xilly_channel *channel; + unsigned char *version; + + channel = endpoint->channels[1]; /* This should be generated ad-hoc */ + + channel->wr_sleepy = 1; + wmb(); /* Setting wr_sleepy must come before the command */ + + iowrite32(1 | + (3 << 24), /* Opcode 3 for channel 0 = Send IDT */ + &endpoint->registers[fpga_buf_ctrl_reg]); + mmiowb(); /* Just to appear safe */ + + wait_event_interruptible_timeout(channel->wr_wait, + (!channel->wr_sleepy), + XILLY_TIMEOUT); + + if (channel->wr_sleepy) { + pr_err("xillybus: Failed to obtain IDT. Aborting.\n"); + + if (endpoint->fatal_error) + return -EIO; + + rc = -ENODEV; + return rc; + } + + endpoint->ephw->sync_single_for_cpu( + channel->endpoint, + channel->wr_buffers[0]->dma_addr, + channel->wr_buf_size, + DMA_FROM_DEVICE); + + if (channel->wr_buffers[0]->end_offset != endpoint->idtlen) { + pr_err("xillybus: IDT length mismatch (%d != %d). " + "Aborting.\n", + channel->wr_buffers[0]->end_offset, endpoint->idtlen); + rc = -ENODEV; + return rc; + } + + if (crc32_le(~0, channel->wr_buffers[0]->addr, + endpoint->idtlen+1) != 0) { + pr_err("xillybus: IDT failed CRC check. Aborting.\n"); + rc = -ENODEV; + return rc; + } + + version = channel->wr_buffers[0]->addr; + + /* Check version number. Accept anything below 0x82 for now. */ + if (*version > 0x82) { + pr_err("xillybus: No support for IDT version 0x%02x. " + "Maybe the xillybus driver needs an upgarde. " + "Aborting.\n", + (int) *version); + rc = -ENODEV; + return rc; + } + + return 0; /* Success */ +} + +static ssize_t xillybus_read(struct file *filp, char *userbuf, size_t count, + loff_t *f_pos) +{ + ssize_t rc; + unsigned long flags; + int bytes_done = 0; + int no_time_left = 0; + long deadline, left_to_sleep; + struct xilly_channel *channel = filp->private_data; + + int empty, reached_eof, exhausted, ready; + /* Initializations are there only to silence warnings */ + + int howmany = 0, bufpos = 0, bufidx = 0, bufferdone = 0; + int waiting_bufidx; + + if (channel->endpoint->fatal_error) + return -EIO; + + deadline = jiffies + 1 + XILLY_RX_TIMEOUT; + + rc = mutex_lock_interruptible(&channel->wr_mutex); + + if (rc) + return rc; + + rc = 0; /* Just to be clear about it. Compiler optimizes this out */ + + while (1) { /* Note that we may drop mutex within this loop */ + int bytes_to_do = count - bytes_done; + spin_lock_irqsave(&channel->wr_spinlock, flags); + + empty = channel->wr_empty; + ready = !empty || channel->wr_ready; + + if (!empty) { + bufidx = channel->wr_host_buf_idx; + bufpos = channel->wr_host_buf_pos; + howmany = ((channel->wr_buffers[bufidx]->end_offset + + 1) << channel->log2_element_size) + - bufpos; + + /* Update wr_host_* to its post-operation state */ + if (howmany > bytes_to_do) { + bufferdone = 0; + + howmany = bytes_to_do; + channel->wr_host_buf_pos += howmany; + } else { + bufferdone = 1; + + channel->wr_host_buf_pos = 0; + + if (bufidx == channel->wr_fpga_buf_idx) { + channel->wr_empty = 1; + channel->wr_sleepy = 1; + channel->wr_ready = 0; + } + + if (bufidx >= (channel->num_wr_buffers - 1)) + channel->wr_host_buf_idx = 0; + else + channel->wr_host_buf_idx++; + } + } + + /* + * Marking our situation after the possible changes above, + * for use after releasing the spinlock. + * + * empty = empty before change + * exhasted = empty after possible change + */ + + reached_eof = channel->wr_empty && + (channel->wr_host_buf_idx == channel->wr_eof); + channel->wr_hangup = reached_eof; + exhausted = channel->wr_empty; + waiting_bufidx = channel->wr_host_buf_idx; + + spin_unlock_irqrestore(&channel->wr_spinlock, flags); + + if (!empty) { /* Go on, now without the spinlock */ + + if (bufpos == 0) /* Position zero means it's virgin */ + channel->endpoint->ephw->sync_single_for_cpu( + channel->endpoint, + channel->wr_buffers[bufidx]->dma_addr, + channel->wr_buf_size, + DMA_FROM_DEVICE); + + if (copy_to_user( + userbuf, + channel->wr_buffers[bufidx]->addr + + bufpos, howmany)) + rc = -EFAULT; + + userbuf += howmany; + bytes_done += howmany; + + if (bufferdone) { + channel->endpoint->ephw-> + sync_single_for_device + ( + channel->endpoint, + channel->wr_buffers[bufidx]-> + dma_addr, + channel->wr_buf_size, + DMA_FROM_DEVICE); + + /* + * Tell FPGA the buffer is done with. It's an + * atomic operation to the FPGA, so what + * happens with other channels doesn't matter, + * and the certain channel is protected with + * the channel-specific mutex. + */ + + iowrite32(1 | (channel->chan_num << 1) + | (bufidx << 12), + &channel->endpoint->registers[ + fpga_buf_ctrl_reg]); + mmiowb(); /* Just to appear safe */ + } + + if (rc) { + mutex_unlock(&channel->wr_mutex); + return rc; + } + } + + /* This includes a zero-count return = EOF */ + if ((bytes_done >= count) || reached_eof) + break; + + if (!exhausted) + continue; /* More in RAM buffer(s)? Just go on. */ + + if ((bytes_done > 0) && + (no_time_left || + (channel->wr_synchronous && channel->wr_allow_partial))) + break; + + /* + * Nonblocking read: The "ready" flag tells us that the FPGA + * has data to send. In non-blocking mode, if it isn't on, + * just return. But if there is, we jump directly to the point + * where we ask for the FPGA to send all it has, and wait + * until that data arrives. So in a sense, we *do* block in + * nonblocking mode, but only for a very short time. + */ + + if (!no_time_left && (filp->f_flags & O_NONBLOCK)) { + if (bytes_done > 0) + break; + + if (ready) + goto desperate; + + bytes_done = -EAGAIN; + break; + } + + if (!no_time_left || (bytes_done > 0)) { + /* + * Note that in case of an element-misaligned read + * request, offsetlimit will include the last element, + * which will be partially read from. + */ + int offsetlimit = ((count - bytes_done) - 1) >> + channel->log2_element_size; + int buf_elements = channel->wr_buf_size >> + channel->log2_element_size; + + /* + * In synchronous mode, always send an offset limit. + * Just don't send a value too big. + */ + + if (channel->wr_synchronous) { + /* Don't request more than one buffer */ + if (channel->wr_allow_partial && + (offsetlimit >= buf_elements)) + offsetlimit = buf_elements - 1; + + /* Don't request more than all buffers */ + if (!channel->wr_allow_partial && + (offsetlimit >= + (buf_elements * channel->num_wr_buffers))) + offsetlimit = buf_elements * + channel->num_wr_buffers - 1; + } + + /* + * In asynchronous mode, force early flush of a buffer + * only if that will allow returning a full count. The + * "offsetlimit < ( ... )" rather than "<=" excludes + * requesting a full buffer, which would obviously + * cause a buffer transmission anyhow + */ + + if (channel->wr_synchronous || + (offsetlimit < (buf_elements - 1))) { + + mutex_lock(&channel->endpoint->register_mutex); + + iowrite32(offsetlimit, + &channel->endpoint->registers[ + fpga_buf_offset_reg]); + mmiowb(); + + iowrite32(1 | (channel->chan_num << 1) | + (2 << 24) | /* 2 = offset limit */ + (waiting_bufidx << 12), + &channel->endpoint->registers[ + fpga_buf_ctrl_reg]); + + mmiowb(); /* Just to appear safe */ + + mutex_unlock(&channel->endpoint-> + register_mutex); + } + + } + + /* + * If partial completion is disallowed, there is no point in + * timeout sleeping. Neither if no_time_left is set and + * there's no data. + */ + + if (!channel->wr_allow_partial || + (no_time_left && (bytes_done == 0))) { + + /* + * This do-loop will run more than once if another + * thread reasserted wr_sleepy before we got the mutex + * back, so we try again. + */ + + do { + mutex_unlock(&channel->wr_mutex); + + if (wait_event_interruptible( + channel->wr_wait, + (!channel->wr_sleepy))) + goto interrupted; + + if (mutex_lock_interruptible( + &channel->wr_mutex)) + goto interrupted; + } while (channel->wr_sleepy); + + continue; + +interrupted: /* Mutex is not held if got here */ + if (channel->endpoint->fatal_error) + return -EIO; + if (bytes_done) + return bytes_done; + if (filp->f_flags & O_NONBLOCK) + return -EAGAIN; /* Don't admit snoozing */ + return -EINTR; + } + + left_to_sleep = deadline - ((long) jiffies); + + /* + * If our time is out, skip the waiting. We may miss wr_sleepy + * being deasserted but hey, almost missing the train is like + * missing it. + */ + + if (left_to_sleep > 0) { + left_to_sleep = + wait_event_interruptible_timeout( + channel->wr_wait, + (!channel->wr_sleepy), + left_to_sleep); + + if (!channel->wr_sleepy) + continue; + + if (left_to_sleep < 0) { /* Interrupt */ + mutex_unlock(&channel->wr_mutex); + if (channel->endpoint->fatal_error) + return -EIO; + if (bytes_done) + return bytes_done; + return -EINTR; + } + } + +desperate: + no_time_left = 1; /* We're out of sleeping time. Desperate! */ + + if (bytes_done == 0) { + /* + * Reaching here means that we allow partial return, + * that we've run out of time, and that we have + * nothing to return. + * So tell the FPGA to send anything it has or gets. + */ + + iowrite32(1 | (channel->chan_num << 1) | + (3 << 24) | /* Opcode 3, flush it all! */ + (waiting_bufidx << 12), + &channel->endpoint->registers[ + fpga_buf_ctrl_reg]); + mmiowb(); /* Just to appear safe */ + } + + /* + * Formally speaking, we should block for data at this point. + * But to keep the code cleaner, we'll just finish the loop, + * make the unlikely check for data, and then block at the + * usual place. + */ + } + + mutex_unlock(&channel->wr_mutex); + + if (channel->endpoint->fatal_error) + return -EIO; + + return bytes_done; +} + +/* + * The timeout argument takes values as follows: + * >0 : Flush with timeout + * ==0 : Flush, and wait idefinitely for the flush to complete + * <0 : Autoflush: Flush only if there's a single buffer occupied + */ + +static int xillybus_myflush(struct xilly_channel *channel, long timeout) +{ + int rc = 0; + unsigned long flags; + + int end_offset_plus1; + int bufidx, bufidx_minus1; + int i; + int empty; + int new_rd_host_buf_pos; + + if (channel->endpoint->fatal_error) + return -EIO; + rc = mutex_lock_interruptible(&channel->rd_mutex); + + if (rc) + return rc; + + /* + * Don't flush a closed channel. This can happen when the work queued + * autoflush thread fires off after the file has closed. This is not + * an error, just something to dismiss. + */ + + if (!channel->rd_ref_count) + goto done; + + bufidx = channel->rd_host_buf_idx; + + bufidx_minus1 = (bufidx == 0) ? channel->num_rd_buffers - 1 : bufidx-1; + + end_offset_plus1 = channel->rd_host_buf_pos >> + channel->log2_element_size; + + new_rd_host_buf_pos = channel->rd_host_buf_pos - + (end_offset_plus1 << channel->log2_element_size); + + /* Submit the current buffer if it's nonempty */ + if (end_offset_plus1) { + unsigned char *tail = channel->rd_buffers[bufidx]->addr + + (end_offset_plus1 << channel->log2_element_size); + + /* Copy unflushed data, so we can put it in next buffer */ + for (i = 0; i < new_rd_host_buf_pos; i++) + channel->rd_leftovers[i] = *tail++; + + spin_lock_irqsave(&channel->rd_spinlock, flags); + + /* Autoflush only if a single buffer is occupied */ + + if ((timeout < 0) && + (channel->rd_full || + (bufidx_minus1 != channel->rd_fpga_buf_idx))) { + spin_unlock_irqrestore(&channel->rd_spinlock, flags); + /* + * A new work item may be queued by the ISR exactly + * now, since the execution of a work item allows the + * queuing of a new one while it's running. + */ + goto done; + } + + /* The 4th element is never needed for data, so it's a flag */ + channel->rd_leftovers[3] = (new_rd_host_buf_pos != 0); + + /* Set up rd_full to reflect a certain moment's state */ + + if (bufidx == channel->rd_fpga_buf_idx) + channel->rd_full = 1; + spin_unlock_irqrestore(&channel->rd_spinlock, flags); + + if (bufidx >= (channel->num_rd_buffers - 1)) + channel->rd_host_buf_idx = 0; + else + channel->rd_host_buf_idx++; + + channel->endpoint->ephw->sync_single_for_device( + channel->endpoint, + channel->rd_buffers[bufidx]->dma_addr, + channel->rd_buf_size, + DMA_TO_DEVICE); + + mutex_lock(&channel->endpoint->register_mutex); + + iowrite32(end_offset_plus1 - 1, + &channel->endpoint->registers[fpga_buf_offset_reg]); + mmiowb(); + + iowrite32((channel->chan_num << 1) | /* Channel ID */ + (2 << 24) | /* Opcode 2, submit buffer */ + (bufidx << 12), + &channel->endpoint->registers[fpga_buf_ctrl_reg]); + mmiowb(); /* Just to appear safe */ + + mutex_unlock(&channel->endpoint->register_mutex); + } else if (bufidx == 0) + bufidx = channel->num_rd_buffers - 1; + else + bufidx--; + + channel->rd_host_buf_pos = new_rd_host_buf_pos; + + if (timeout < 0) + goto done; /* Autoflush */ + + + /* + * bufidx is now the last buffer written to (or equal to + * rd_fpga_buf_idx if buffer was never written to), and + * channel->rd_host_buf_idx the one after it. + * + * If bufidx == channel->rd_fpga_buf_idx we're either empty or full. + */ + + rc = 0; + + while (1) { /* Loop waiting for draining of buffers */ + spin_lock_irqsave(&channel->rd_spinlock, flags); + + if (bufidx != channel->rd_fpga_buf_idx) + channel->rd_full = 1; /* + * Not really full, + * but needs waiting. + */ + + empty = !channel->rd_full; + + spin_unlock_irqrestore(&channel->rd_spinlock, flags); + + if (empty) + break; + + /* + * Indefinite sleep with mutex taken. With data waiting for + * flushing user should not be surprised if open() for write + * sleeps. + */ + if (timeout == 0) + wait_event_interruptible(channel->rd_wait, + (!channel->rd_full)); + + else if (wait_event_interruptible_timeout( + channel->rd_wait, + (!channel->rd_full), + timeout) == 0) { + pr_warn("xillybus: " + "Timed out while flushing. " + "Output data may be lost.\n"); + + rc = -ETIMEDOUT; + break; + } + + if (channel->rd_full) { + rc = -EINTR; + break; + } + } + +done: + mutex_unlock(&channel->rd_mutex); + + if (channel->endpoint->fatal_error) + return -EIO; + + return rc; +} + +static int xillybus_flush(struct file *filp, fl_owner_t id) +{ + if (!(filp->f_mode & FMODE_WRITE)) + return 0; + + return xillybus_myflush(filp->private_data, HZ); /* 1 second timeout */ +} + +static void xillybus_autoflush(struct work_struct *work) +{ + struct delayed_work *workitem = container_of( + work, struct delayed_work, work); + struct xilly_channel *channel = container_of( + workitem, struct xilly_channel, rd_workitem); + int rc; + + rc = xillybus_myflush(channel, -1); + + if (rc == -EINTR) + pr_warn("xillybus: Autoflush failed because " + "work queue thread got a signal.\n"); + else if (rc) + pr_err("xillybus: Autoflush failed under " + "weird circumstances.\n"); + +} + +static ssize_t xillybus_write(struct file *filp, const char *userbuf, + size_t count, loff_t *f_pos) +{ + ssize_t rc; + unsigned long flags; + int bytes_done = 0; + struct xilly_channel *channel = filp->private_data; + + int full, exhausted; + /* Initializations are there only to silence warnings */ + + int howmany = 0, bufpos = 0, bufidx = 0, bufferdone = 0; + int end_offset_plus1 = 0; + + if (channel->endpoint->fatal_error) + return -EIO; + + rc = mutex_lock_interruptible(&channel->rd_mutex); + + if (rc) + return rc; + + rc = 0; /* Just to be clear about it. Compiler optimizes this out */ + + while (1) { + int bytes_to_do = count - bytes_done; + + spin_lock_irqsave(&channel->rd_spinlock, flags); + + full = channel->rd_full; + + if (!full) { + bufidx = channel->rd_host_buf_idx; + bufpos = channel->rd_host_buf_pos; + howmany = channel->rd_buf_size - bufpos; + + /* + * Update rd_host_* to its state after this operation. + * count=0 means committing the buffer immediately, + * which is like flushing, but not necessarily block. + */ + + if ((howmany > bytes_to_do) && + (count || + ((bufpos >> channel->log2_element_size) == 0))) { + bufferdone = 0; + + howmany = bytes_to_do; + channel->rd_host_buf_pos += howmany; + } else { + bufferdone = 1; + + if (count) { + end_offset_plus1 = + channel->rd_buf_size >> + channel->log2_element_size; + channel->rd_host_buf_pos = 0; + } else { + unsigned char *tail; + int i; + + end_offset_plus1 = bufpos >> + channel->log2_element_size; + + channel->rd_host_buf_pos -= + end_offset_plus1 << + channel->log2_element_size; + + tail = channel-> + rd_buffers[bufidx]->addr + + (end_offset_plus1 << + channel->log2_element_size); + + for (i = 0; + i < channel->rd_host_buf_pos; + i++) + channel->rd_leftovers[i] = + *tail++; + } + + if (bufidx == channel->rd_fpga_buf_idx) + channel->rd_full = 1; + + if (bufidx >= (channel->num_rd_buffers - 1)) + channel->rd_host_buf_idx = 0; + else + channel->rd_host_buf_idx++; + } + } + + /* + * Marking our situation after the possible changes above, + * for use after releasing the spinlock. + * + * full = full before change + * exhasted = full after possible change + */ + + exhausted = channel->rd_full; + + spin_unlock_irqrestore(&channel->rd_spinlock, flags); + + if (!full) { /* Go on, now without the spinlock */ + unsigned char *head = + channel->rd_buffers[bufidx]->addr; + int i; + + if ((bufpos == 0) || /* Zero means it's virgin */ + (channel->rd_leftovers[3] != 0)) { + channel->endpoint->ephw->sync_single_for_cpu( + channel->endpoint, + channel->rd_buffers[bufidx]->dma_addr, + channel->rd_buf_size, + DMA_TO_DEVICE); + + /* Virgin, but leftovers are due */ + for (i = 0; i < bufpos; i++) + *head++ = channel->rd_leftovers[i]; + + channel->rd_leftovers[3] = 0; /* Clear flag */ + } + + if (copy_from_user( + channel->rd_buffers[bufidx]->addr + bufpos, + userbuf, howmany)) + rc = -EFAULT; + + userbuf += howmany; + bytes_done += howmany; + + if (bufferdone) { + channel->endpoint->ephw-> + sync_single_for_device( + channel->endpoint, + channel->rd_buffers[bufidx]-> + dma_addr, + channel->rd_buf_size, + DMA_TO_DEVICE); + + mutex_lock(&channel->endpoint->register_mutex); + + iowrite32(end_offset_plus1 - 1, + &channel->endpoint->registers[ + fpga_buf_offset_reg]); + mmiowb(); + iowrite32((channel->chan_num << 1) | + (2 << 24) | /* 2 = submit buffer */ + (bufidx << 12), + &channel->endpoint->registers[ + fpga_buf_ctrl_reg]); + mmiowb(); /* Just to appear safe */ + + mutex_unlock(&channel->endpoint-> + register_mutex); + + channel->rd_leftovers[3] = + (channel->rd_host_buf_pos != 0); + } + + if (rc) { + mutex_unlock(&channel->rd_mutex); + + if (channel->endpoint->fatal_error) + return -EIO; + + if (!channel->rd_synchronous) + queue_delayed_work( + xillybus_wq, + &channel->rd_workitem, + XILLY_RX_TIMEOUT); + + return rc; + } + } + + if (bytes_done >= count) + break; + + if (!exhausted) + continue; /* If there's more space, just go on */ + + if ((bytes_done > 0) && channel->rd_allow_partial) + break; + + /* + * Indefinite sleep with mutex taken. With data waiting for + * flushing, user should not be surprised if open() for write + * sleeps. + */ + + if (filp->f_flags & O_NONBLOCK) { + bytes_done = -EAGAIN; + break; + } + + wait_event_interruptible(channel->rd_wait, + (!channel->rd_full)); + + if (channel->rd_full) { + mutex_unlock(&channel->rd_mutex); + + if (channel->endpoint->fatal_error) + return -EIO; + + if (bytes_done) + return bytes_done; + return -EINTR; + } + } + + mutex_unlock(&channel->rd_mutex); + + if (!channel->rd_synchronous) + queue_delayed_work(xillybus_wq, + &channel->rd_workitem, + XILLY_RX_TIMEOUT); + + if ((channel->rd_synchronous) && (bytes_done > 0)) { + rc = xillybus_myflush(filp->private_data, 0); /* No timeout */ + + if (rc && (rc != -EINTR)) + return rc; + } + + if (channel->endpoint->fatal_error) + return -EIO; + + return bytes_done; +} + +static int xillybus_open(struct inode *inode, struct file *filp) +{ + int rc = 0; + unsigned long flags; + int minor = iminor(inode); + int major = imajor(inode); + struct xilly_endpoint *ep_iter, *endpoint = NULL; + struct xilly_channel *channel; + + mutex_lock(&ep_list_lock); + + list_for_each_entry(ep_iter, &list_of_endpoints, ep_list) { + if ((ep_iter->major == major) && + (minor >= ep_iter->lowest_minor) && + (minor < (ep_iter->lowest_minor + + ep_iter->num_channels))) { + endpoint = ep_iter; + break; + } + } + mutex_unlock(&ep_list_lock); + + if (!endpoint) { + pr_err("xillybus: open() failed to find a device " + "for major=%d and minor=%d\n", major, minor); + return -ENODEV; + } + + if (endpoint->fatal_error) + return -EIO; + + channel = endpoint->channels[1 + minor - endpoint->lowest_minor]; + filp->private_data = channel; + + + /* + * It gets complicated because: + * 1. We don't want to take a mutex we don't have to + * 2. We don't want to open one direction if the other will fail. + */ + + if ((filp->f_mode & FMODE_READ) && (!channel->num_wr_buffers)) + return -ENODEV; + + if ((filp->f_mode & FMODE_WRITE) && (!channel->num_rd_buffers)) + return -ENODEV; + + if ((filp->f_mode & FMODE_READ) && (filp->f_flags & O_NONBLOCK) && + (channel->wr_synchronous || !channel->wr_allow_partial || + !channel->wr_supports_nonempty)) { + pr_err("xillybus: open() failed: " + "O_NONBLOCK not allowed for read on this device\n"); + return -ENODEV; + } + + if ((filp->f_mode & FMODE_WRITE) && (filp->f_flags & O_NONBLOCK) && + (channel->rd_synchronous || !channel->rd_allow_partial)) { + pr_err("xillybus: open() failed: " + "O_NONBLOCK not allowed for write on this device\n"); + return -ENODEV; + } + + /* + * Note: open() may block on getting mutexes despite O_NONBLOCK. + * This shouldn't occur normally, since multiple open of the same + * file descriptor is almost always prohibited anyhow + * (*_exclusive_open is normally set in real-life systems). + */ + + if (filp->f_mode & FMODE_READ) { + rc = mutex_lock_interruptible(&channel->wr_mutex); + if (rc) + return rc; + } + + if (filp->f_mode & FMODE_WRITE) { + rc = mutex_lock_interruptible(&channel->rd_mutex); + if (rc) + goto unlock_wr; + } + + if ((filp->f_mode & FMODE_READ) && + (channel->wr_ref_count != 0) && + (channel->wr_exclusive_open)) { + rc = -EBUSY; + goto unlock; + } + + if ((filp->f_mode & FMODE_WRITE) && + (channel->rd_ref_count != 0) && + (channel->rd_exclusive_open)) { + rc = -EBUSY; + goto unlock; + } + + + if (filp->f_mode & FMODE_READ) { + if (channel->wr_ref_count == 0) { /* First open of file */ + /* Move the host to first buffer */ + spin_lock_irqsave(&channel->wr_spinlock, flags); + channel->wr_host_buf_idx = 0; + channel->wr_host_buf_pos = 0; + channel->wr_fpga_buf_idx = -1; + channel->wr_empty = 1; + channel->wr_ready = 0; + channel->wr_sleepy = 1; + channel->wr_eof = -1; + channel->wr_hangup = 0; + + spin_unlock_irqrestore(&channel->wr_spinlock, flags); + + iowrite32(1 | (channel->chan_num << 1) | + (4 << 24) | /* Opcode 4, open channel */ + ((channel->wr_synchronous & 1) << 23), + &channel->endpoint->registers[ + fpga_buf_ctrl_reg]); + mmiowb(); /* Just to appear safe */ + } + + channel->wr_ref_count++; + } + + if (filp->f_mode & FMODE_WRITE) { + if (channel->rd_ref_count == 0) { /* First open of file */ + /* Move the host to first buffer */ + spin_lock_irqsave(&channel->rd_spinlock, flags); + channel->rd_host_buf_idx = 0; + channel->rd_host_buf_pos = 0; + channel->rd_leftovers[3] = 0; /* No leftovers. */ + channel->rd_fpga_buf_idx = channel->num_rd_buffers - 1; + channel->rd_full = 0; + + spin_unlock_irqrestore(&channel->rd_spinlock, flags); + + iowrite32((channel->chan_num << 1) | + (4 << 24), /* Opcode 4, open channel */ + &channel->endpoint->registers[ + fpga_buf_ctrl_reg]); + mmiowb(); /* Just to appear safe */ + } + + channel->rd_ref_count++; + } + +unlock: + if (filp->f_mode & FMODE_WRITE) + mutex_unlock(&channel->rd_mutex); +unlock_wr: + if (filp->f_mode & FMODE_READ) + mutex_unlock(&channel->wr_mutex); + + if (!rc && (!channel->seekable)) + return nonseekable_open(inode, filp); + + return rc; +} + +static int xillybus_release(struct inode *inode, struct file *filp) +{ + int rc; + unsigned long flags; + struct xilly_channel *channel = filp->private_data; + + int buf_idx; + int eof; + + if (channel->endpoint->fatal_error) + return -EIO; + + if (filp->f_mode & FMODE_WRITE) { + rc = mutex_lock_interruptible(&channel->rd_mutex); + + if (rc) { + pr_warn("xillybus: Failed to close file. " + "Hardware left in messy state.\n"); + return rc; + } + + channel->rd_ref_count--; + + if (channel->rd_ref_count == 0) { + + /* + * We rely on the kernel calling flush() + * before we get here. + */ + + iowrite32((channel->chan_num << 1) | /* Channel ID */ + (5 << 24), /* Opcode 5, close channel */ + &channel->endpoint->registers[ + fpga_buf_ctrl_reg]); + mmiowb(); /* Just to appear safe */ + } + mutex_unlock(&channel->rd_mutex); + } + + if (filp->f_mode & FMODE_READ) { + rc = mutex_lock_interruptible(&channel->wr_mutex); + if (rc) { + pr_warn("xillybus: Failed to close file. " + "Hardware left in messy state.\n"); + return rc; + } + + channel->wr_ref_count--; + + if (channel->wr_ref_count == 0) { + + iowrite32(1 | (channel->chan_num << 1) | + (5 << 24), /* Opcode 5, close channel */ + &channel->endpoint->registers[ + fpga_buf_ctrl_reg]); + mmiowb(); /* Just to appear safe */ + + /* + * This is crazily cautious: We make sure that not + * only that we got an EOF (be it because we closed + * the channel or because of a user's EOF), but verify + * that it's one beyond the last buffer arrived, so + * we have no leftover buffers pending before wrapping + * up (which can only happen in asynchronous channels, + * BTW) + */ + + while (1) { + spin_lock_irqsave(&channel->wr_spinlock, + flags); + buf_idx = channel->wr_fpga_buf_idx; + eof = channel->wr_eof; + channel->wr_sleepy = 1; + spin_unlock_irqrestore(&channel->wr_spinlock, + flags); + + /* + * Check if eof points at the buffer after + * the last one the FPGA submitted. Note that + * no EOF is marked by negative eof. + */ + + buf_idx++; + if (buf_idx == channel->num_wr_buffers) + buf_idx = 0; + + if (buf_idx == eof) + break; + + /* + * Steal extra 100 ms if awaken by interrupt. + * This is a simple workaround for an + * interrupt pending when entering, which would + * otherwise result in declaring the hardware + * non-responsive. + */ + + if (wait_event_interruptible( + channel->wr_wait, + (!channel->wr_sleepy))) + msleep(100); + + if (channel->wr_sleepy) { + mutex_unlock(&channel->wr_mutex); + pr_warn("xillybus: Hardware failed to " + "respond to close command, " + "therefore left in " + "messy state.\n"); + return -EINTR; + } + } + } + + mutex_unlock(&channel->wr_mutex); + } + + return 0; +} +loff_t xillybus_llseek(struct file *filp, loff_t offset, int whence) +{ + struct xilly_channel *channel = filp->private_data; + loff_t pos = filp->f_pos; + int rc = 0; + + /* + * Take both mutexes not allowing interrupts, since it seems like + * common applications don't expect an -EINTR here. Besides, multiple + * access to a single file desriptor on seekable devices is a mess + * anyhow. + */ + + if (channel->endpoint->fatal_error) + return -EIO; + + mutex_lock(&channel->wr_mutex); + mutex_lock(&channel->rd_mutex); + + switch (whence) { + case 0: + pos = offset; + break; + case 1: + pos += offset; + break; + case 2: + pos = offset; /* Going to the end => to the beginning */ + break; + default: + rc = -EINVAL; + goto end; + } + + /* In any case, we must finish on an element boundary */ + if (pos & ((1 << channel->log2_element_size) - 1)) { + rc = -EINVAL; + goto end; + } + + mutex_lock(&channel->endpoint->register_mutex); + + iowrite32(pos >> channel->log2_element_size, + &channel->endpoint->registers[fpga_buf_offset_reg]); + mmiowb(); + iowrite32((channel->chan_num << 1) | + (6 << 24), /* Opcode 6, set address */ + &channel->endpoint->registers[fpga_buf_ctrl_reg]); + mmiowb(); /* Just to appear safe */ + + mutex_unlock(&channel->endpoint->register_mutex); + +end: + mutex_unlock(&channel->rd_mutex); + mutex_unlock(&channel->wr_mutex); + + if (rc) /* Return error after releasing mutexes */ + return rc; + + filp->f_pos = pos; + + /* + * Since seekable devices are allowed only when the channel is + * synchronous, we assume that there is no data pending in either + * direction (which holds true as long as no concurrent access on the + * file descriptor takes place). + * The only thing we may need to throw away is leftovers from partial + * write() flush. + */ + + channel->rd_leftovers[3] = 0; + + return pos; +} + +static unsigned int xillybus_poll(struct file *filp, poll_table *wait) +{ + struct xilly_channel *channel = filp->private_data; + unsigned int mask = 0; + unsigned long flags; + + poll_wait(filp, &channel->endpoint->ep_wait, wait); + + /* + * poll() won't play ball regarding read() channels which + * aren't asynchronous and support the nonempty message. Allowing + * that will create situations where data has been delivered at + * the FPGA, and users expecting select() to wake up, which it may + * not. + */ + + if (!channel->wr_synchronous && channel->wr_supports_nonempty) { + poll_wait(filp, &channel->wr_wait, wait); + poll_wait(filp, &channel->wr_ready_wait, wait); + + spin_lock_irqsave(&channel->wr_spinlock, flags); + if (!channel->wr_empty || channel->wr_ready) + mask |= POLLIN | POLLRDNORM; + + if (channel->wr_hangup) + /* + * Not POLLHUP, because its behavior is in the + * mist, and POLLIN does what we want: Wake up + * the read file descriptor so it sees EOF. + */ + mask |= POLLIN | POLLRDNORM; + spin_unlock_irqrestore(&channel->wr_spinlock, flags); + } + + /* + * If partial data write is disallowed on a write() channel, + * it's pointless to ever signal OK to write, because is could + * block despite some space being available. + */ + + if (channel->rd_allow_partial) { + poll_wait(filp, &channel->rd_wait, wait); + + spin_lock_irqsave(&channel->rd_spinlock, flags); + if (!channel->rd_full) + mask |= POLLOUT | POLLWRNORM; + spin_unlock_irqrestore(&channel->rd_spinlock, flags); + } + + if (channel->endpoint->fatal_error) + mask |= POLLERR; + + return mask; +} + +static const struct file_operations xillybus_fops = { + .owner = THIS_MODULE, + .read = xillybus_read, + .write = xillybus_write, + .open = xillybus_open, + .flush = xillybus_flush, + .release = xillybus_release, + .llseek = xillybus_llseek, + .poll = xillybus_poll, +}; + +static int xillybus_init_chrdev(struct xilly_endpoint *endpoint, + const unsigned char *idt) +{ + int rc; + dev_t dev; + int devnum, i, minor, major; + char devname[48]; + struct device *device; + + rc = alloc_chrdev_region(&dev, 0, /* minor start */ + endpoint->num_channels, + xillyname); + + if (rc) { + pr_warn("xillybus: Failed to obtain major/minors"); + goto error1; + } + + endpoint->major = major = MAJOR(dev); + endpoint->lowest_minor = minor = MINOR(dev); + + cdev_init(&endpoint->cdev, &xillybus_fops); + endpoint->cdev.owner = endpoint->ephw->owner; + rc = cdev_add(&endpoint->cdev, MKDEV(major, minor), + endpoint->num_channels); + if (rc) { + pr_warn("xillybus: Failed to add cdev. Aborting.\n"); + goto error2; + } + + idt++; + + for (i = minor, devnum = 0; + devnum < endpoint->num_channels; + devnum++, i++) { + snprintf(devname, sizeof(devname)-1, "xillybus_%s", idt); + + devname[sizeof(devname)-1] = 0; /* Should never matter */ + + while (*idt++) + /* Skip to next */; + + device = device_create(xillybus_class, + NULL, + MKDEV(major, i), + NULL, + devname); + + if (IS_ERR(device)) { + pr_warn("xillybus: Failed to create %s " + "device. Aborting.\n", devname); + goto error3; + } + } + + pr_info("xillybus: Created %d device files.\n", + endpoint->num_channels); + return 0; /* succeed */ + +error3: + devnum--; i--; + for (; devnum >= 0; devnum--, i--) + device_destroy(xillybus_class, MKDEV(major, i)); + + cdev_del(&endpoint->cdev); +error2: + unregister_chrdev_region(MKDEV(major, minor), endpoint->num_channels); +error1: + + return rc; +} + +static void xillybus_cleanup_chrdev(struct xilly_endpoint *endpoint) +{ + int minor; + + for (minor = endpoint->lowest_minor; + minor < (endpoint->lowest_minor + endpoint->num_channels); + minor++) + device_destroy(xillybus_class, MKDEV(endpoint->major, minor)); + cdev_del(&endpoint->cdev); + unregister_chrdev_region(MKDEV(endpoint->major, + endpoint->lowest_minor), + endpoint->num_channels); + + pr_info("xillybus: Removed %d device files.\n", + endpoint->num_channels); +} + + +struct xilly_endpoint *xillybus_init_endpoint(struct pci_dev *pdev, + struct device *dev, + struct xilly_endpoint_hardware + *ephw) +{ + struct xilly_endpoint *endpoint; + + endpoint = kzalloc(sizeof(*endpoint), GFP_KERNEL); + if (!endpoint) { + pr_err("xillybus: Failed to allocate memory. Aborting.\n"); + return NULL; + } + + endpoint->pdev = pdev; + endpoint->dev = dev; + endpoint->ephw = ephw; + INIT_LIST_HEAD(&endpoint->cleanup.to_kfree); + INIT_LIST_HEAD(&endpoint->cleanup.to_pagefree); + INIT_LIST_HEAD(&endpoint->cleanup.to_unmap); + endpoint->msg_counter = 0x0b; + endpoint->failed_messages = 0; + endpoint->fatal_error = 0; + + init_waitqueue_head(&endpoint->ep_wait); + mutex_init(&endpoint->register_mutex); + + return endpoint; +} +EXPORT_SYMBOL(xillybus_init_endpoint); + +static int xilly_quiesce(struct xilly_endpoint *endpoint) +{ + endpoint->idtlen = -1; + wmb(); /* Make sure idtlen is set before sending command */ + iowrite32((u32) (endpoint->dma_using_dac & 0x0001), + &endpoint->registers[fpga_dma_control_reg]); + mmiowb(); + + wait_event_interruptible_timeout(endpoint->ep_wait, + (endpoint->idtlen >= 0), + XILLY_TIMEOUT); + + if (endpoint->idtlen < 0) { + pr_err("xillybus: Failed to quiesce the device on " + "exit. Quitting while leaving a mess.\n"); + return -ENODEV; + } + return 0; /* Success */ +} + +int xillybus_endpoint_discovery(struct xilly_endpoint *endpoint) +{ + int rc = 0; + + struct xilly_cleanup tmpmem; + int idtbuffersize = (1 << PAGE_SHIFT); + + /* + * The bogus IDT is used during bootstrap for allocating the initial + * message buffer, and then the message buffer and space for the IDT + * itself. The initial message buffer is of a single page's size, but + * it's soon replaced with a more modest one (and memory is freed). + */ + + unsigned char bogus_idt[8] = { 1, 224, (PAGE_SHIFT)-2, 0, + 3, 192, PAGE_SHIFT, 0 }; + struct xilly_idt_handle idt_handle; + + INIT_LIST_HEAD(&tmpmem.to_kfree); + INIT_LIST_HEAD(&tmpmem.to_pagefree); + INIT_LIST_HEAD(&tmpmem.to_unmap); + + /* + * Writing the value 0x00000001 to Endianess register signals which + * endianess this processor is using, so the FPGA can swap words as + * necessary. + */ + + iowrite32(1, &endpoint->registers[fpga_endian_reg]); + mmiowb(); /* Writes below are affected by the one above. */ + + /* Bootstrap phase I: Allocate temporary message buffer */ + + endpoint->num_channels = 0; + + rc = xilly_setupchannels(endpoint, &tmpmem, bogus_idt, 1); + + if (rc) + goto failed_buffers; + + /* Clear the message subsystem (and counter in particular) */ + iowrite32(0x04, &endpoint->registers[fpga_msg_ctrl_reg]); + mmiowb(); + + endpoint->idtlen = -1; + + smp_wmb(); + + /* + * Set DMA 32/64 bit mode, quiesce the device (?!) and get IDT + * buffer size. + */ + iowrite32((u32) (endpoint->dma_using_dac & 0x0001), + &endpoint->registers[fpga_dma_control_reg]); + mmiowb(); + + wait_event_interruptible_timeout(endpoint->ep_wait, + (endpoint->idtlen >= 0), + XILLY_TIMEOUT); + + if (endpoint->idtlen < 0) { + pr_err("xillybus: No response from FPGA. Aborting.\n"); + rc = -ENODEV; + goto failed_quiesce; + } + + /* Enable DMA */ + iowrite32((u32) (0x0002 | (endpoint->dma_using_dac & 0x0001)), + &endpoint->registers[fpga_dma_control_reg]); + mmiowb(); + + /* Bootstrap phase II: Allocate buffer for IDT and obtain it */ + while (endpoint->idtlen >= idtbuffersize) { + idtbuffersize *= 2; + bogus_idt[6]++; + } + + endpoint->num_channels = 1; + + rc = xilly_setupchannels(endpoint, &tmpmem, bogus_idt, 2); + + if (rc) + goto failed_idt; + + smp_wmb(); + + rc = xilly_obtain_idt(endpoint); + + if (rc) + goto failed_idt; + + xilly_scan_idt(endpoint, &idt_handle); + + if (!idt_handle.chandesc) { + rc = -ENODEV; + goto failed_idt; + } + /* Bootstrap phase III: Allocate buffers according to IDT */ + + rc = xilly_setupchannels(endpoint, + &endpoint->cleanup, + idt_handle.chandesc, + idt_handle.entries); + + if (rc) + goto failed_idt; + + smp_wmb(); /* mutex_lock below should suffice, but won't hurt.*/ + + /* + * endpoint is now completely configured. We put it on the list + * available to open() before registering the char device(s) + */ + + mutex_lock(&ep_list_lock); + list_add_tail(&endpoint->ep_list, &list_of_endpoints); + mutex_unlock(&ep_list_lock); + + rc = xillybus_init_chrdev(endpoint, idt_handle.idt); + + if (rc) + goto failed_chrdevs; + + xillybus_do_cleanup(&tmpmem, endpoint); + + return 0; + +failed_chrdevs: + mutex_lock(&ep_list_lock); + list_del(&endpoint->ep_list); + mutex_unlock(&ep_list_lock); + +failed_idt: + /* Quiesce the device. Now it's serious to do it */ + rc = xilly_quiesce(endpoint); + + if (rc) + return rc; /* FPGA may still DMA, so no release */ + + flush_workqueue(xillybus_wq); +failed_quiesce: +failed_buffers: + xillybus_do_cleanup(&tmpmem, endpoint); + + return rc; +} +EXPORT_SYMBOL(xillybus_endpoint_discovery); + +void xillybus_endpoint_remove(struct xilly_endpoint *endpoint) +{ + xillybus_cleanup_chrdev(endpoint); + + mutex_lock(&ep_list_lock); + list_del(&endpoint->ep_list); + mutex_unlock(&ep_list_lock); + + xilly_quiesce(endpoint); + + /* + * Flushing is done upon endpoint release to prevent access to memory + * just about to be released. This makes the quiesce complete. + */ + flush_workqueue(xillybus_wq); +} +EXPORT_SYMBOL(xillybus_endpoint_remove); + +static int __init xillybus_init(void) +{ + int rc = 0; + + mutex_init(&ep_list_lock); + + xillybus_class = class_create(THIS_MODULE, xillyname); + if (IS_ERR(xillybus_class)) { + rc = PTR_ERR(xillybus_class); + pr_warn("xillybus: Failed to register class xillybus\n"); + + return rc; + } + + xillybus_wq = alloc_workqueue(xillyname, 0, 0); + + return 0; /* Success */ +} + +static void __exit xillybus_exit(void) +{ + /* flush_workqueue() was called for each endpoint released */ + destroy_workqueue(xillybus_wq); + + class_destroy(xillybus_class); +} + +module_init(xillybus_init); +module_exit(xillybus_exit); diff --git a/drivers/staging/xillybus/xillybus_of.c b/drivers/staging/xillybus/xillybus_of.c new file mode 100644 index 0000000000000..b875376766a24 --- /dev/null +++ b/drivers/staging/xillybus/xillybus_of.c @@ -0,0 +1,210 @@ +/* + * linux/drivers/misc/xillybus_of.c + * + * Copyright 2011 Xillybus Ltd, http://xillybus.com + * + * Driver for the Xillybus FPGA/host framework using Open Firmware. + * + * This program is free software; you can redistribute it and/or modify + * it under the smems of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "xillybus.h" + +MODULE_DESCRIPTION("Xillybus driver for Open Firmware"); +MODULE_AUTHOR("Eli Billauer, Xillybus Ltd."); +MODULE_VERSION("1.06"); +MODULE_ALIAS("xillybus_of"); +MODULE_LICENSE("GPL v2"); + +/* Match table for of_platform binding */ +static struct of_device_id xillybus_of_match[] = { + { .compatible = "xlnx,xillybus-1.00.a", }, + {} +}; + +MODULE_DEVICE_TABLE(of, xillybus_of_match); + +static void xilly_dma_sync_single_for_cpu_of(struct xilly_endpoint *ep, + dma_addr_t dma_handle, + size_t size, + int direction) +{ + dma_sync_single_for_cpu(ep->dev, dma_handle, size, direction); +} + +static void xilly_dma_sync_single_for_device_of(struct xilly_endpoint *ep, + dma_addr_t dma_handle, + size_t size, + int direction) +{ + dma_sync_single_for_device(ep->dev, dma_handle, size, direction); +} + +static dma_addr_t xilly_map_single_of(struct xilly_cleanup *mem, + struct xilly_endpoint *ep, + void *ptr, + size_t size, + int direction + ) +{ + + dma_addr_t addr = 0; + struct xilly_dma *this; + + this = kmalloc(sizeof(struct xilly_dma), GFP_KERNEL); + if (!this) + return 0; + + addr = dma_map_single(ep->dev, ptr, size, direction); + this->direction = direction; + + if (dma_mapping_error(ep->dev, addr)) { + kfree(this); + return 0; + } + + this->dma_addr = addr; + this->dev = ep->dev; + this->size = size; + + list_add_tail(&this->node, &mem->to_unmap); + + return addr; +} + +void xilly_unmap_single_of(struct xilly_dma *entry) +{ + dma_unmap_single(entry->dev, + entry->dma_addr, + entry->size, + entry->direction); +} + +static struct xilly_endpoint_hardware of_hw = { + .owner = THIS_MODULE, + .sync_single_for_cpu = xilly_dma_sync_single_for_cpu_of, + .sync_single_for_device = xilly_dma_sync_single_for_device_of, + .map_single = xilly_map_single_of, + .unmap_single = xilly_unmap_single_of +}; + +static int xilly_drv_probe(struct platform_device *op) +{ + struct device *dev = &op->dev; + struct xilly_endpoint *endpoint; + int rc = 0; + int irq; + + endpoint = xillybus_init_endpoint(NULL, dev, &of_hw); + + if (!endpoint) + return -ENOMEM; + + dev_set_drvdata(dev, endpoint); + + rc = of_address_to_resource(dev->of_node, 0, &endpoint->res); + if (rc) { + pr_warn("xillybus: Failed to obtain device tree " + "resource\n"); + goto failed_request_regions; + } + + if (!request_mem_region(endpoint->res.start, + resource_size(&endpoint->res), xillyname)) { + pr_err("xillybus: request_mem_region failed. Aborting.\n"); + rc = -EBUSY; + goto failed_request_regions; + } + + endpoint->registers = of_iomap(dev->of_node, 0); + + if (!endpoint->registers) { + pr_err("xillybus: Failed to map I/O memory. Aborting.\n"); + goto failed_iomap0; + } + + irq = irq_of_parse_and_map(dev->of_node, 0); + + rc = request_irq(irq, xillybus_isr, 0, xillyname, endpoint); + + if (rc) { + pr_err("xillybus: Failed to register IRQ handler. " + "Aborting.\n"); + rc = -ENODEV; + goto failed_register_irq; + } + + rc = xillybus_endpoint_discovery(endpoint); + + if (!rc) + return 0; + + free_irq(irq, endpoint); + +failed_register_irq: + iounmap(endpoint->registers); +failed_iomap0: + release_mem_region(endpoint->res.start, + resource_size(&endpoint->res)); + +failed_request_regions: + xillybus_do_cleanup(&endpoint->cleanup, endpoint); + + kfree(endpoint); + return rc; +} + +static int xilly_drv_remove(struct platform_device *op) +{ + struct device *dev = &op->dev; + struct xilly_endpoint *endpoint = dev_get_drvdata(dev); + int irq = irq_of_parse_and_map(dev->of_node, 0); + + xillybus_endpoint_remove(endpoint); + + free_irq(irq, endpoint); + + iounmap(endpoint->registers); + release_mem_region(endpoint->res.start, + resource_size(&endpoint->res)); + + xillybus_do_cleanup(&endpoint->cleanup, endpoint); + + kfree(endpoint); + + return 0; +} + +static struct platform_driver xillybus_platform_driver = { + .probe = xilly_drv_probe, + .remove = xilly_drv_remove, + .driver = { + .name = xillyname, + .owner = THIS_MODULE, + .of_match_table = xillybus_of_match, + }, +}; + +static int __init xillybus_of_init(void) +{ + return platform_driver_register(&xillybus_platform_driver); +} + +static void __exit xillybus_of_exit(void) +{ + platform_driver_unregister(&xillybus_platform_driver); +} + +module_init(xillybus_of_init); +module_exit(xillybus_of_exit); diff --git a/drivers/staging/xillybus/xillybus_pcie.c b/drivers/staging/xillybus/xillybus_pcie.c new file mode 100644 index 0000000000000..592f8f7a0b2c7 --- /dev/null +++ b/drivers/staging/xillybus/xillybus_pcie.c @@ -0,0 +1,260 @@ +/* + * linux/drivers/misc/xillybus_pcie.c + * + * Copyright 2011 Xillybus Ltd, http://xillybus.com + * + * Driver for the Xillybus FPGA/host framework using PCI Express. + * + * This program is free software; you can redistribute it and/or modify + * it under the smems of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + */ + +#include +#include +#include +#include +#include "xillybus.h" + +MODULE_DESCRIPTION("Xillybus driver for PCIe"); +MODULE_AUTHOR("Eli Billauer, Xillybus Ltd."); +MODULE_VERSION("1.06"); +MODULE_ALIAS("xillybus_pcie"); +MODULE_LICENSE("GPL v2"); + +#define PCI_DEVICE_ID_XILLYBUS 0xebeb + +#define PCI_VENDOR_ID_ALTERA 0x1172 +#define PCI_VENDOR_ID_ACTEL 0x11aa +#define PCI_VENDOR_ID_LATTICE 0x1204 + +static DEFINE_PCI_DEVICE_TABLE(xillyids) = { + {PCI_DEVICE(PCI_VENDOR_ID_XILINX, PCI_DEVICE_ID_XILLYBUS)}, + {PCI_DEVICE(PCI_VENDOR_ID_ALTERA, PCI_DEVICE_ID_XILLYBUS)}, + {PCI_DEVICE(PCI_VENDOR_ID_ACTEL, PCI_DEVICE_ID_XILLYBUS)}, + {PCI_DEVICE(PCI_VENDOR_ID_LATTICE, PCI_DEVICE_ID_XILLYBUS)}, + { /* End: all zeroes */ } +}; + +static int xilly_pci_direction(int direction) +{ + switch (direction) { + case DMA_TO_DEVICE: + return PCI_DMA_TODEVICE; + case DMA_FROM_DEVICE: + return PCI_DMA_FROMDEVICE; + default: + return PCI_DMA_BIDIRECTIONAL; + } +} + +static void xilly_dma_sync_single_for_cpu_pci(struct xilly_endpoint *ep, + dma_addr_t dma_handle, + size_t size, + int direction) +{ + pci_dma_sync_single_for_cpu(ep->pdev, + dma_handle, + size, + xilly_pci_direction(direction)); +} + +static void xilly_dma_sync_single_for_device_pci(struct xilly_endpoint *ep, + dma_addr_t dma_handle, + size_t size, + int direction) +{ + pci_dma_sync_single_for_device(ep->pdev, + dma_handle, + size, + xilly_pci_direction(direction)); +} + +/* + * Map either through the PCI DMA mapper or the non_PCI one. Behind the + * scenes exactly the same functions are called with the same parameters, + * but that can change. + */ + +static dma_addr_t xilly_map_single_pci(struct xilly_cleanup *mem, + struct xilly_endpoint *ep, + void *ptr, + size_t size, + int direction + ) +{ + + dma_addr_t addr = 0; + struct xilly_dma *this; + int pci_direction; + + this = kmalloc(sizeof(struct xilly_dma), GFP_KERNEL); + if (!this) + return 0; + + pci_direction = xilly_pci_direction(direction); + addr = pci_map_single(ep->pdev, ptr, size, pci_direction); + this->direction = pci_direction; + + if (pci_dma_mapping_error(ep->pdev, addr)) { + kfree(this); + return 0; + } + + this->dma_addr = addr; + this->pdev = ep->pdev; + this->size = size; + + list_add_tail(&this->node, &mem->to_unmap); + + return addr; +} + +void xilly_unmap_single_pci(struct xilly_dma *entry) +{ + pci_unmap_single(entry->pdev, + entry->dma_addr, + entry->size, + entry->direction); +} + +static struct xilly_endpoint_hardware pci_hw = { + .owner = THIS_MODULE, + .sync_single_for_cpu = xilly_dma_sync_single_for_cpu_pci, + .sync_single_for_device = xilly_dma_sync_single_for_device_pci, + .map_single = xilly_map_single_pci, + .unmap_single = xilly_unmap_single_pci +}; + +static int xilly_probe(struct pci_dev *pdev, + const struct pci_device_id *ent) +{ + struct xilly_endpoint *endpoint; + int rc = 0; + + endpoint = xillybus_init_endpoint(pdev, NULL, &pci_hw); + + if (!endpoint) + return -ENOMEM; + + pci_set_drvdata(pdev, endpoint); + + rc = pci_enable_device(pdev); + + /* L0s has caused packet drops. No power saving, thank you. */ + + pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S); + + if (rc) { + pr_err("xillybus: pci_enable_device() failed. " + "Aborting.\n"); + goto no_enable; + } + + if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) { + pr_err("xillybus: Incorrect BAR configuration. " + "Aborting.\n"); + rc = -ENODEV; + goto bad_bar; + } + + rc = pci_request_regions(pdev, xillyname); + if (rc) { + pr_err("xillybus: pci_request_regions() failed. " + "Aborting.\n"); + goto failed_request_regions; + } + + endpoint->registers = pci_iomap(pdev, 0, 128); + + if (!endpoint->registers) { + pr_err("xillybus: Failed to map BAR 0. Aborting.\n"); + goto failed_iomap0; + } + + pci_set_master(pdev); + + /* Set up a single MSI interrupt */ + if (pci_enable_msi(pdev)) { + pr_err("xillybus: Failed to enable MSI interrupts. " + "Aborting.\n"); + rc = -ENODEV; + goto failed_enable_msi; + } + rc = request_irq(pdev->irq, xillybus_isr, 0, xillyname, endpoint); + + if (rc) { + pr_err("xillybus: Failed to register MSI handler. " + "Aborting.\n"); + rc = -ENODEV; + goto failed_register_msi; + } + + /* + * In theory, an attempt to set the DMA mask to 64 and dma_using_dac=1 + * is the right thing. But some unclever PCIe drivers report it's OK + * when the hardware drops those 64-bit PCIe packets. So trust + * nobody and use 32 bits DMA addressing in any case. + */ + + if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) + endpoint->dma_using_dac = 0; + else { + pr_err("xillybus: Failed to set DMA mask. " + "Aborting.\n"); + rc = -ENODEV; + goto failed_dmamask; + } + + rc = xillybus_endpoint_discovery(endpoint); + + if (!rc) + return 0; + +failed_dmamask: + free_irq(pdev->irq, endpoint); +failed_register_msi: + pci_disable_msi(pdev); +failed_enable_msi: + /* pci_clear_master(pdev); Nobody else seems to do this */ + pci_iounmap(pdev, endpoint->registers); +failed_iomap0: + pci_release_regions(pdev); +failed_request_regions: +bad_bar: + pci_disable_device(pdev); +no_enable: + xillybus_do_cleanup(&endpoint->cleanup, endpoint); + + kfree(endpoint); + return rc; +} + +static void xilly_remove(struct pci_dev *pdev) +{ + struct xilly_endpoint *endpoint = pci_get_drvdata(pdev); + + xillybus_endpoint_remove(endpoint); + + free_irq(pdev->irq, endpoint); + + pci_disable_msi(pdev); + pci_iounmap(pdev, endpoint->registers); + pci_release_regions(pdev); + pci_disable_device(pdev); + + xillybus_do_cleanup(&endpoint->cleanup, endpoint); + + kfree(endpoint); +} + +MODULE_DEVICE_TABLE(pci, xillyids); + +static struct pci_driver xillybus_driver = { + .name = xillyname, + .id_table = xillyids, + .probe = xilly_probe, + .remove = xilly_remove, +}; + +module_pci_driver(xillybus_driver); -- GitLab From f6a6621e543b049323b5a384532da5d1b37b8508 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 26 Jul 2013 14:20:39 -0700 Subject: [PATCH 277/942] staging: xillybus: force to be a module As reported, this driver causes problems when built into the kernel, so force it to be a module until those issues are fixed. Also delete the "default n" lines in the Kconfig, as they are not needed. Reported-by: Stephen Rothwell Cc: Eli Billauer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xillybus/Kconfig | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/xillybus/Kconfig b/drivers/staging/xillybus/Kconfig index 58fd5488fefbf..459d050065f79 100644 --- a/drivers/staging/xillybus/Kconfig +++ b/drivers/staging/xillybus/Kconfig @@ -4,8 +4,7 @@ config XILLYBUS tristate "Xillybus generic FPGA interface" - depends on PCI || (OF_ADDRESS && OF_DEVICE && OF_IRQ) - default n + depends on PCI || (OF_ADDRESS && OF_DEVICE && OF_IRQ) && m help Xillybus is a generic interface for peripherals designed on programmable logic (FPGA). The driver probes the hardware for @@ -18,7 +17,6 @@ if XILLYBUS config XILLYBUS_PCIE tristate "Xillybus over PCIe" depends on XILLYBUS && PCI - default n help Set to M if you want Xillybus to use PCI Express for communicating with the FPGA. @@ -26,7 +24,6 @@ config XILLYBUS_PCIE config XILLYBUS_OF tristate "Xillybus over Device Tree" depends on XILLYBUS && OF_ADDRESS && OF_DEVICE && OF_IRQ - default n help Set to M if you want Xillybus to find its resources from the Open Firmware Flattened Device Tree. If the target is an embedded -- GitLab From e71042f24129fbe8f1d126721eceaf5ad690c97a Mon Sep 17 00:00:00 2001 From: Eli Billauer Date: Sat, 27 Jul 2013 00:24:00 +0300 Subject: [PATCH 278/942] staging: xillybus: Multiple definition of xillyname resolved (bug fix) Reported-by: Stephen Rothwell Signed-off-by: Eli Billauer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xillybus/xillybus.h | 2 -- drivers/staging/xillybus/xillybus_core.c | 2 ++ drivers/staging/xillybus/xillybus_of.c | 2 ++ drivers/staging/xillybus/xillybus_pcie.c | 2 ++ 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/staging/xillybus/xillybus.h b/drivers/staging/xillybus/xillybus.h index c260ebcc6c4d0..b62faeb31c532 100644 --- a/drivers/staging/xillybus/xillybus.h +++ b/drivers/staging/xillybus/xillybus.h @@ -24,8 +24,6 @@ #include #include -char xillyname[] = "xillybus"; - struct xilly_endpoint_hardware; struct xilly_page { diff --git a/drivers/staging/xillybus/xillybus_core.c b/drivers/staging/xillybus/xillybus_core.c index dd0a71c6b518e..7991e572ef04b 100644 --- a/drivers/staging/xillybus/xillybus_core.c +++ b/drivers/staging/xillybus/xillybus_core.c @@ -61,6 +61,8 @@ MODULE_LICENSE("GPL v2"); #define XILLYMSG_OPCODE_FATAL_ERROR 4 #define XILLYMSG_OPCODE_NONEMPTY 5 +static const char xillyname[] = "xillybus"; + static struct class *xillybus_class; /* diff --git a/drivers/staging/xillybus/xillybus_of.c b/drivers/staging/xillybus/xillybus_of.c index b875376766a24..122d9ba1b28b0 100644 --- a/drivers/staging/xillybus/xillybus_of.c +++ b/drivers/staging/xillybus/xillybus_of.c @@ -27,6 +27,8 @@ MODULE_VERSION("1.06"); MODULE_ALIAS("xillybus_of"); MODULE_LICENSE("GPL v2"); +static const char xillyname[] = "xillybus_of"; + /* Match table for of_platform binding */ static struct of_device_id xillybus_of_match[] = { { .compatible = "xlnx,xillybus-1.00.a", }, diff --git a/drivers/staging/xillybus/xillybus_pcie.c b/drivers/staging/xillybus/xillybus_pcie.c index 592f8f7a0b2c7..ad45bdb2a715a 100644 --- a/drivers/staging/xillybus/xillybus_pcie.c +++ b/drivers/staging/xillybus/xillybus_pcie.c @@ -28,6 +28,8 @@ MODULE_LICENSE("GPL v2"); #define PCI_VENDOR_ID_ACTEL 0x11aa #define PCI_VENDOR_ID_LATTICE 0x1204 +static const char xillyname[] = "xillybus_pcie"; + static DEFINE_PCI_DEVICE_TABLE(xillyids) = { {PCI_DEVICE(PCI_VENDOR_ID_XILINX, PCI_DEVICE_ID_XILLYBUS)}, {PCI_DEVICE(PCI_VENDOR_ID_ALTERA, PCI_DEVICE_ID_XILLYBUS)}, -- GitLab From e4ea910a487af187950f88d345e6dc9744c8d257 Mon Sep 17 00:00:00 2001 From: Shaun Laing Date: Fri, 26 Jul 2013 08:25:34 -0600 Subject: [PATCH 279/942] staging: comedi: dt9812: Resolves sparse endian warnings. Resolves warnings from the "sparse" checker of the form "warning: cast to restricted __le??". Signed-off-by: Shaun Laing Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt9812.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt9812.c b/drivers/staging/comedi/drivers/dt9812.c index ffb7572b10f59..bd14017b798c8 100644 --- a/drivers/staging/comedi/drivers/dt9812.c +++ b/drivers/staging/comedi/drivers/dt9812.c @@ -707,8 +707,9 @@ static int dt9812_reset_device(struct comedi_device *dev) u32 serial; u16 vendor; u16 product; - u16 tmp16; u8 tmp8; + __le16 tmp16; + __le32 tmp32; int ret; int i; @@ -731,19 +732,19 @@ static int dt9812_reset_device(struct comedi_device *dev) } } - ret = dt9812_read_info(dev, 1, &vendor, sizeof(vendor)); + ret = dt9812_read_info(dev, 1, &tmp16, sizeof(tmp16)); if (ret) { dev_err(dev->class_dev, "failed to read vendor id\n"); return ret; } - vendor = le16_to_cpu(vendor); + vendor = le16_to_cpu(tmp16); - ret = dt9812_read_info(dev, 3, &product, sizeof(product)); + ret = dt9812_read_info(dev, 3, &tmp16, sizeof(tmp16)); if (ret) { dev_err(dev->class_dev, "failed to read product id\n"); return ret; } - product = le16_to_cpu(product); + product = le16_to_cpu(tmp16); ret = dt9812_read_info(dev, 5, &tmp16, sizeof(tmp16)); if (ret) { @@ -752,12 +753,12 @@ static int dt9812_reset_device(struct comedi_device *dev) } devpriv->device = le16_to_cpu(tmp16); - ret = dt9812_read_info(dev, 7, &serial, sizeof(serial)); + ret = dt9812_read_info(dev, 7, &tmp32, sizeof(tmp32)); if (ret) { dev_err(dev->class_dev, "failed to read serial number\n"); return ret; } - serial = le32_to_cpu(serial); + serial = le32_to_cpu(tmp32); /* let the user know what node this device is now attached to */ dev_info(dev->class_dev, "USB DT9812 (%4.4x.%4.4x.%4.4x) #0x%8.8x\n", -- GitLab From 91f44915115f8c9f79457d24a57472cac78dc2ee Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 26 Jul 2013 12:03:19 +0100 Subject: [PATCH 280/942] staging: comedi: Kconfig: COMEDI_NI_ATMIO16D should not depend on ISAPNP The COMEDI_NI_ATMIO16D configuration option causes the "ni_atmio16d" module to be built, which handles the National Instruments AT-MIO-16 and AT-MIO-16D cards. The configuration option currently depends on ISAPNP, but the module doesn't use any ISAPNP functions and the cards are legacy ISA cards with base I/O port, IRQ and DMA channel configured by jumpers. (The driver doesn't use DMA though.) Remove the ISADNP dependancy from COMEDI_NI_ATMIO16D and fix up the help text - the card names are missing a dash and they're not ISA-PNP. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/Kconfig | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index 01782fccbf2a6..8c6527f7b93ec 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -480,11 +480,10 @@ config COMEDI_NI_ATMIO called ni_atmio. config COMEDI_NI_ATMIO16D - tristate "NI AT-MIO16/AT-MIO16D series ISA-PNP card support" - depends on ISAPNP + tristate "NI AT-MIO-16/AT-MIO-16D series ISA card support" select COMEDI_8255 ---help--- - Enable support for National Instruments AT-MIO16/AT-MIO16D cards. + Enable support for National Instruments AT-MIO-16/AT-MIO-16D cards. To compile this driver as a module, choose M here: the module will be called ni_atmio16d. -- GitLab From 4bed4f03883af9af08f3d0ae276ace2b5898d846 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 26 Jul 2013 12:03:20 +0100 Subject: [PATCH 281/942] staging: comedi: Kconfig: COMEDI_NI_ATMIO doesn't need to depend on ISAPNP The COMEDI_NI_ATMIO configuration option causes the "ni_atmio" module to be built, which handles various National Instruments ISA-PNP data acquisition cards. The configuration option currently depends on ISAPNP. The "ni_atmio" module is a "legacy" comedi driver with no auto-configuration support and it doesn't register as a PNP card driver. The only difference in initialization from the other comedi ISA card drivers is that it will use the ISA-PNP functions to find, attach and activate the card if no I/O base address has been specified by the user in the COMEDI_DEVCONFIG ioctl. The module compiles fine without the ISAPNP configuration option as the and headers provide dummy inline functions if the ISAPNP and PNP options, respectively, are not enabled. Remove the dependancy on the ISAPNP option since the module builds without it and can be used without it. (There is a very slim chance that comedi will support proper ISA PNP drivers one day, in which case the ni_atmio driver could be converted to use this support and not support manual configuration. However, not all the PnP IDs of boards supported by this driver are currently known to us.) Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/Kconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index 8c6527f7b93ec..57362fee75930 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -467,7 +467,6 @@ config COMEDI_NI_AT_AO config COMEDI_NI_ATMIO tristate "NI AT-MIO E series ISA-PNP card support" - depends on ISAPNP select COMEDI_8255 select COMEDI_NI_TIO ---help--- -- GitLab From b07dee7c9aa78e9b55e0b4ecdba622db55a99ffe Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Fri, 26 Jul 2013 10:15:55 +0800 Subject: [PATCH 282/942] staging: gdm724x: use GFP_ATOMIC under spin lock A spin lock is taken here so we should use GFP_ATOMIC. Signed-off-by: Wei Yongjun Acked-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm724x/gdm_mux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/gdm724x/gdm_mux.c b/drivers/staging/gdm724x/gdm_mux.c index 2e619d2e7ba10..b630babb57af6 100644 --- a/drivers/staging/gdm724x/gdm_mux.c +++ b/drivers/staging/gdm724x/gdm_mux.c @@ -409,7 +409,7 @@ static int gdm_mux_send(void *priv_dev, void *data, int len, int tty_index, gdm_mux_send_complete, t); - ret = usb_submit_urb(t->urb, GFP_KERNEL); + ret = usb_submit_urb(t->urb, GFP_ATOMIC); spin_unlock_irqrestore(&mux_dev->write_lock, flags); -- GitLab From 9c922a9076afd9e483bc17d768ed813d2f76f7cb Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 25 Jul 2013 16:21:13 -0700 Subject: [PATCH 283/942] staging: comedi: usbduxsigma: set *_cmd_running flags before submitting urbs As pointed out by Ian Abbott, the *_cmd_running flags should be set before submitting the urbs. There is a possible race condition where an urb could complete and the flag is checked in the completion routine before it's set. Reported-by: Ian Abbott Acked-by: Ian Abbott Reviewed-by: Ian Abbott Signed-off-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbduxsigma.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c b/drivers/staging/comedi/drivers/usbduxsigma.c index 40eeb8c683062..1af235407eb42 100644 --- a/drivers/staging/comedi/drivers/usbduxsigma.c +++ b/drivers/staging/comedi/drivers/usbduxsigma.c @@ -686,13 +686,14 @@ static int usbduxsigma_ai_inttrig(struct comedi_device *dev, down(&devpriv->sem); if (!devpriv->ai_cmd_running) { + devpriv->ai_cmd_running = 1; ret = usbduxsigma_submit_urbs(dev, devpriv->ai_urbs, devpriv->n_ai_urbs, 1); if (ret < 0) { + devpriv->ai_cmd_running = 0; up(&devpriv->sem); return ret; } - devpriv->ai_cmd_running = 1; s->async->inttrig = NULL; } up(&devpriv->sem); @@ -740,14 +741,15 @@ static int usbduxsigma_ai_cmd(struct comedi_device *dev, if (cmd->start_src == TRIG_NOW) { /* enable this acquisition operation */ + devpriv->ai_cmd_running = 1; ret = usbduxsigma_submit_urbs(dev, devpriv->ai_urbs, devpriv->n_ai_urbs, 1); if (ret < 0) { + devpriv->ai_cmd_running = 0; up(&devpriv->sem); return ret; } s->async->inttrig = NULL; - devpriv->ai_cmd_running = 1; } else { /* TRIG_INT */ /* wait for an internal signal and submit the urbs later */ s->async->inttrig = usbduxsigma_ai_inttrig; @@ -876,13 +878,14 @@ static int usbduxsigma_ao_inttrig(struct comedi_device *dev, down(&devpriv->sem); if (!devpriv->ao_cmd_running) { + devpriv->ao_cmd_running = 1; ret = usbduxsigma_submit_urbs(dev, devpriv->ao_urbs, devpriv->n_ao_urbs, 0); if (ret < 0) { + devpriv->ao_cmd_running = 0; up(&devpriv->sem); return ret; } - devpriv->ao_cmd_running = 1; s->async->inttrig = NULL; } up(&devpriv->sem); @@ -1026,14 +1029,15 @@ static int usbduxsigma_ao_cmd(struct comedi_device *dev, if (cmd->start_src == TRIG_NOW) { /* enable this acquisition operation */ + devpriv->ao_cmd_running = 1; ret = usbduxsigma_submit_urbs(dev, devpriv->ao_urbs, devpriv->n_ao_urbs, 0); if (ret < 0) { + devpriv->ao_cmd_running = 0; up(&devpriv->sem); return ret; } s->async->inttrig = NULL; - devpriv->ao_cmd_running = 1; } else { /* TRIG_INT */ /* wait for an internal signal and submit the urbs later */ s->async->inttrig = usbduxsigma_ao_inttrig; @@ -1237,10 +1241,12 @@ static int usbduxsigma_pwm_start(struct comedi_device *dev, memset(devpriv->pwm_urb->transfer_buffer, 0, devpriv->pwm_buf_sz); + devpriv->pwm_cmd_running = 1; ret = usbduxsigma_submit_pwm_urb(dev); - if (ret < 0) + if (ret < 0) { + devpriv->pwm_cmd_running = 0; return ret; - devpriv->pwm_cmd_running = 1; + } return 0; } -- GitLab From e5cb2f9498e0a5b4c7f882a21dbba8f8ba351819 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 25 Jul 2013 16:03:15 -0700 Subject: [PATCH 284/942] staging: comedi: usbdux: tidy up usbdux_ai_inttrig() Rename the local variable used for the private data pointer to the comedi "norm". Remove the unnecessary sanity check of the private data pointer. This function can only be called is the private data was allocated during the attach. Tidy up the exit path using goto to ensure that the semaphore is released. Return -EBUSY if an ai command is already running. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 35 +++++++++++++------------ 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index d0d683bc83c24..95c11e820fd22 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -852,31 +852,32 @@ static int receive_dux_commands(struct comedi_device *dev, int command) } static int usbdux_ai_inttrig(struct comedi_device *dev, - struct comedi_subdevice *s, unsigned int trignum) + struct comedi_subdevice *s, + unsigned int trignum) { - int ret; - struct usbdux_private *this_usbduxsub = dev->private; - if (!this_usbduxsub) - return -EFAULT; + struct usbdux_private *devpriv = dev->private; + int ret = -EINVAL; - down(&this_usbduxsub->sem); + down(&devpriv->sem); - if (trignum != 0) { - up(&this_usbduxsub->sem); - return -EINVAL; - } - if (!(this_usbduxsub->ai_cmd_running)) { - this_usbduxsub->ai_cmd_running = 1; + if (trignum != 0) + goto ai_trig_exit; + + if (!devpriv->ai_cmd_running) { + devpriv->ai_cmd_running = 1; ret = usbduxsub_submit_inurbs(dev); if (ret < 0) { - this_usbduxsub->ai_cmd_running = 0; - up(&this_usbduxsub->sem); - return ret; + devpriv->ai_cmd_running = 0; + goto ai_trig_exit; } s->async->inttrig = NULL; + } else { + ret = -EBUSY; } - up(&this_usbduxsub->sem); - return 1; + +ai_trig_exit: + up(&devpriv->sem); + return ret; } static int usbdux_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) -- GitLab From 9a79dfce37416c5677512fe5cf7c5a59f8f9b73d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 25 Jul 2013 16:03:34 -0700 Subject: [PATCH 285/942] staging: comedi: usbdux: tidy up usbdux_ai_cmd() Rename the local variable used for the private data pointer to the comedi "norm". Remove the unnecessary sanity check of the private data pointer. This function can only be called is the private data was allocated during the attach. Tidy up the exit path using goto to ensure that the semaphore is released. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 93 ++++++++++++------------- 1 file changed, 45 insertions(+), 48 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 95c11e820fd22..aebc728c9be93 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -882,85 +882,79 @@ static int usbdux_ai_inttrig(struct comedi_device *dev, static int usbdux_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { + struct usbdux_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; - unsigned int chan, range; - int i, ret; - struct usbdux_private *this_usbduxsub = dev->private; - int result; - - if (!this_usbduxsub) - return -EFAULT; + int len = cmd->chanlist_len; + int ret = -EBUSY; + int i; /* block other CPUs from starting an ai_cmd */ - down(&this_usbduxsub->sem); - if (this_usbduxsub->ai_cmd_running) { - up(&this_usbduxsub->sem); - return -EBUSY; - } + down(&devpriv->sem); + + if (devpriv->ai_cmd_running) + goto ai_cmd_exit; + /* set current channel of the running acquisition to zero */ s->async->cur_chan = 0; - this_usbduxsub->dux_commands[1] = cmd->chanlist_len; - for (i = 0; i < cmd->chanlist_len; ++i) { - chan = CR_CHAN(cmd->chanlist[i]); - range = CR_RANGE(cmd->chanlist[i]); + devpriv->dux_commands[1] = len; + for (i = 0; i < len; ++i) { + unsigned int chan = CR_CHAN(cmd->chanlist[i]); + unsigned int range = CR_RANGE(cmd->chanlist[i]); + if (i >= NUMCHANNELS) break; - this_usbduxsub->dux_commands[i + 2] = - create_adc_command(chan, range); - } - result = send_dux_commands(dev, SENDADCOMMANDS); - if (result < 0) { - up(&this_usbduxsub->sem); - return result; + devpriv->dux_commands[i + 2] = create_adc_command(chan, range); } - if (this_usbduxsub->high_speed) { + ret = send_dux_commands(dev, SENDADCOMMANDS); + if (ret < 0) + goto ai_cmd_exit; + + if (devpriv->high_speed) { /* * every channel gets a time window of 125us. Thus, if we * sample all 8 channels we need 1ms. If we sample only one * channel we need only 125us */ - this_usbduxsub->ai_interval = 1; + devpriv->ai_interval = 1; /* find a power of 2 for the interval */ - while ((this_usbduxsub->ai_interval) < (cmd->chanlist_len)) { - this_usbduxsub->ai_interval = - (this_usbduxsub->ai_interval) * 2; - } - this_usbduxsub->ai_timer = cmd->scan_begin_arg / (125000 * - (this_usbduxsub-> - ai_interval)); + while (devpriv->ai_interval < len) + devpriv->ai_interval *= 2; + + devpriv->ai_timer = cmd->scan_begin_arg / + (125000 * devpriv->ai_interval); } else { /* interval always 1ms */ - this_usbduxsub->ai_interval = 1; - this_usbduxsub->ai_timer = cmd->scan_begin_arg / 1000000; + devpriv->ai_interval = 1; + devpriv->ai_timer = cmd->scan_begin_arg / 1000000; } - if (this_usbduxsub->ai_timer < 1) { - up(&this_usbduxsub->sem); - return -EINVAL; + if (devpriv->ai_timer < 1) { + ret = -EINVAL; + goto ai_cmd_exit; } - this_usbduxsub->ai_counter = this_usbduxsub->ai_timer; + + devpriv->ai_counter = devpriv->ai_timer; if (cmd->stop_src == TRIG_COUNT) { /* data arrives as one packet */ - this_usbduxsub->ai_sample_count = cmd->stop_arg; - this_usbduxsub->ai_continous = 0; + devpriv->ai_sample_count = cmd->stop_arg; + devpriv->ai_continous = 0; } else { /* continous acquisition */ - this_usbduxsub->ai_continous = 1; - this_usbduxsub->ai_sample_count = 0; + devpriv->ai_continous = 1; + devpriv->ai_sample_count = 0; } if (cmd->start_src == TRIG_NOW) { /* enable this acquisition operation */ - this_usbduxsub->ai_cmd_running = 1; + devpriv->ai_cmd_running = 1; ret = usbduxsub_submit_inurbs(dev); if (ret < 0) { - this_usbduxsub->ai_cmd_running = 0; + devpriv->ai_cmd_running = 0; /* fixme: unlink here?? */ - up(&this_usbduxsub->sem); - return ret; + goto ai_cmd_exit; } s->async->inttrig = NULL; } else { @@ -969,8 +963,11 @@ static int usbdux_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) /* wait for an internal signal */ s->async->inttrig = usbdux_ai_inttrig; } - up(&this_usbduxsub->sem); - return 0; + +ai_cmd_exit: + up(&devpriv->sem); + + return ret; } /* Mode 0 is used to get a single conversion on demand */ -- GitLab From a79b4cdb52151dab5c5b2a86ab7619bc457470a8 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 25 Jul 2013 16:03:53 -0700 Subject: [PATCH 286/942] staging: comedi: usbdux: tidy up usbdux_ai_insn_read() Rename the local variable used for the private data pointer to the comedi "norm". Remove the unnecessary sanity check of the private data pointer. This function can only be called is the private data was allocated during the attach. Tidy up the exit path using goto to ensure that the semaphore is released. Return -EBUSY instead of 0 if the (*insn_read) cannot be done because a command is running. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 59 +++++++++++-------------- 1 file changed, 27 insertions(+), 32 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index aebc728c9be93..a536fa3b6858c 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -973,50 +973,45 @@ static int usbdux_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) /* Mode 0 is used to get a single conversion on demand */ static int usbdux_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { + struct usbdux_private *devpriv = dev->private; + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned int range = CR_RANGE(insn->chanspec); + unsigned int val; + int ret = -EBUSY; int i; - unsigned int one = 0; - int chan, range; - int err; - struct usbdux_private *this_usbduxsub = dev->private; - if (!this_usbduxsub) - return 0; + down(&devpriv->sem); - down(&this_usbduxsub->sem); - if (this_usbduxsub->ai_cmd_running) { - up(&this_usbduxsub->sem); - return 0; - } + if (devpriv->ai_cmd_running) + goto ai_read_exit; - /* sample one channel */ - chan = CR_CHAN(insn->chanspec); - range = CR_RANGE(insn->chanspec); /* set command for the first channel */ - this_usbduxsub->dux_commands[1] = create_adc_command(chan, range); + devpriv->dux_commands[1] = create_adc_command(chan, range); /* adc commands */ - err = send_dux_commands(dev, SENDSINGLEAD); - if (err < 0) { - up(&this_usbduxsub->sem); - return err; - } + ret = send_dux_commands(dev, SENDSINGLEAD); + if (ret < 0) + goto ai_read_exit; for (i = 0; i < insn->n; i++) { - err = receive_dux_commands(dev, SENDSINGLEAD); - if (err < 0) { - up(&this_usbduxsub->sem); - return 0; - } - one = le16_to_cpu(this_usbduxsub->insn_buffer[1]); - if (CR_RANGE(insn->chanspec) <= 1) - one = one ^ 0x800; + ret = receive_dux_commands(dev, SENDSINGLEAD); + if (ret < 0) + goto ai_read_exit; + + val = le16_to_cpu(devpriv->insn_buffer[1]); + if (range <= 1) + val ^= 0x800; - data[i] = one; + data[i] = val; } - up(&this_usbduxsub->sem); - return i; + +ai_read_exit: + up(&devpriv->sem); + + return ret ? ret : insn->n; } /************************************/ -- GitLab From 91891f7cc6453bec358a3bc2a0cf9a0b2f8223d5 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 25 Jul 2013 16:04:17 -0700 Subject: [PATCH 287/942] staging: comedi: usbdux: clarify bipolar ai data Use the comedi_range_is_bipolar() helper instead of checking the 'range' index against a magic number. Also, use the s->maxdata to calculate the value needed to munge the value for bipolar data instead of the magic number. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index a536fa3b6858c..a81b4b17b297a 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -1002,8 +1002,10 @@ static int usbdux_ai_insn_read(struct comedi_device *dev, goto ai_read_exit; val = le16_to_cpu(devpriv->insn_buffer[1]); - if (range <= 1) - val ^= 0x800; + + /* bipolar data is two's-complement */ + if (comedi_range_is_bipolar(s, range)) + val ^= ((s->maxdata + 1) >> 1); data[i] = val; } -- GitLab From 818782c8a7744f5183e5e1a411622ce0ae25a558 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 25 Jul 2013 16:04:34 -0700 Subject: [PATCH 288/942] staging: comedi: usbdux: tidy up usbdux_ao_insn_read() Rename the local variable used for the private data pointer to the comedi "norm". Remove the unnecessary sanity check of the private data pointer. This function can only be called is the private data was allocated during the attach. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index a81b4b17b297a..4159936a6312f 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -1016,26 +1016,21 @@ static int usbdux_ai_insn_read(struct comedi_device *dev, return ret ? ret : insn->n; } -/************************************/ -/* analog out */ - static int usbdux_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { + struct usbdux_private *devpriv = dev->private; + unsigned int chan = CR_CHAN(insn->chanspec); int i; - int chan = CR_CHAN(insn->chanspec); - struct usbdux_private *this_usbduxsub = dev->private; - if (!this_usbduxsub) - return -EFAULT; - - down(&this_usbduxsub->sem); + down(&devpriv->sem); for (i = 0; i < insn->n; i++) - data[i] = this_usbduxsub->out_buffer[chan]; + data[i] = devpriv->out_buffer[chan]; + up(&devpriv->sem); - up(&this_usbduxsub->sem); - return i; + return insn->n; } static int usbdux_ao_insn_write(struct comedi_device *dev, -- GitLab From 37c1d1ec37144e9fe14bcc0c3ab0bba92c332312 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 25 Jul 2013 16:05:00 -0700 Subject: [PATCH 289/942] staging: comedi: usbdux: tidy up usbdux_ao_insn_write() Rename the local variable used for the private data pointer to the comedi "norm". Remove the unnecessary sanity check of the private data pointer. This function can only be called is the private data was allocated during the attach. Tidy up the exit path using goto to ensure that the semaphore is released. Return -EBUSY instead of 0 if the (*insn_write) cannot be done because a command is running. Tidy up the for() loop that writes the data. The dux_commands[1] and [4] can be set outside the loop since they are constant. Use a local pointer for dux_commands[2] to load the value to write. Only the last value needs to be cached in the private data for read back. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 53 +++++++++++++------------ 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 4159936a6312f..1e6cb0a60a079 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -1035,39 +1035,42 @@ static int usbdux_ao_insn_read(struct comedi_device *dev, static int usbdux_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { - int i, err; - int chan = CR_CHAN(insn->chanspec); - struct usbdux_private *this_usbduxsub = dev->private; + struct usbdux_private *devpriv = dev->private; + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned int val = devpriv->out_buffer[chan]; + int16_t *p = (int16_t *)&devpriv->dux_commands[2]; + int ret = -EBUSY; + int i; - if (!this_usbduxsub) - return -EFAULT; + down(&devpriv->sem); - down(&this_usbduxsub->sem); - if (this_usbduxsub->ao_cmd_running) { - up(&this_usbduxsub->sem); - return 0; - } + if (devpriv->ao_cmd_running) + goto ao_write_exit; + + /* number of channels: 1 */ + devpriv->dux_commands[1] = 1; + /* channel number */ + devpriv->dux_commands[4] = chan << 6; for (i = 0; i < insn->n; i++) { - /* number of channels: 1 */ - this_usbduxsub->dux_commands[1] = 1; + val = data[i]; + /* one 16 bit value */ - *((int16_t *) (this_usbduxsub->dux_commands + 2)) = - cpu_to_le16(data[i]); - this_usbduxsub->out_buffer[chan] = data[i]; - /* channel number */ - this_usbduxsub->dux_commands[4] = (chan << 6); - err = send_dux_commands(dev, SENDDACOMMANDS); - if (err < 0) { - up(&this_usbduxsub->sem); - return err; - } + *p = cpu_to_le16(val); + + ret = send_dux_commands(dev, SENDDACOMMANDS); + if (ret < 0) + goto ao_write_exit; } - up(&this_usbduxsub->sem); + devpriv->out_buffer[chan] = val; - return i; +ao_write_exit: + up(&devpriv->sem); + + return ret ? ret : insn->n; } static int usbdux_ao_inttrig(struct comedi_device *dev, -- GitLab From f994282df674e31574291e2f8cbd986f234d9d91 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 25 Jul 2013 16:05:17 -0700 Subject: [PATCH 290/942] staging: comedi: usbdux: tidy up usbdux_ao_inttrig() Rename the local variable used for the private data pointer to the comedi "norm". Remove the unnecessary sanity check of the private data pointer. This function can only be called is the private data was allocated during the attach. Tidy up the exit path using goto to ensure that the semaphore is released. Return -EBUSY instead if an ao command is already running. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 35 +++++++++++++------------ 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 1e6cb0a60a079..9aa2e9ea53d13 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -1074,31 +1074,32 @@ static int usbdux_ao_insn_write(struct comedi_device *dev, } static int usbdux_ao_inttrig(struct comedi_device *dev, - struct comedi_subdevice *s, unsigned int trignum) + struct comedi_subdevice *s, + unsigned int trignum) { - int ret; - struct usbdux_private *this_usbduxsub = dev->private; + struct usbdux_private *devpriv = dev->private; + int ret = -EINVAL; - if (!this_usbduxsub) - return -EFAULT; + down(&devpriv->sem); - down(&this_usbduxsub->sem); - if (trignum != 0) { - up(&this_usbduxsub->sem); - return -EINVAL; - } - if (!(this_usbduxsub->ao_cmd_running)) { - this_usbduxsub->ao_cmd_running = 1; + if (trignum != 0) + goto ao_trig_exit; + + if (!devpriv->ao_cmd_running) { + devpriv->ao_cmd_running = 1; ret = usbduxsub_submit_outurbs(dev); if (ret < 0) { - this_usbduxsub->ao_cmd_running = 0; - up(&this_usbduxsub->sem); - return ret; + devpriv->ao_cmd_running = 0; + goto ao_trig_exit; } s->async->inttrig = NULL; + } else { + ret = -EBUSY; } - up(&this_usbduxsub->sem); - return 1; + +ao_trig_exit: + up(&devpriv->sem); + return ret; } static int usbdux_ao_cmdtest(struct comedi_device *dev, -- GitLab From 2a226948081f6285ddc7e8fd4c592d7378c7c55d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 25 Jul 2013 16:05:35 -0700 Subject: [PATCH 291/942] staging: comedi: usbdux: tidy up usbdux_ao_cmd() Rename the local variable used for the private data pointer to the comedi "norm". Remove the unnecessary sanity check of the private data pointer. This function can only be called is the private data was allocated during the attach. Make sure an ao command is not already running and return -EBUSY. Tidy up the exit path using goto to ensure that the semaphore is released. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 62 +++++++++++++------------ 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 9aa2e9ea53d13..40e1424ce5a0e 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -1188,72 +1188,74 @@ static int usbdux_ao_cmdtest(struct comedi_device *dev, static int usbdux_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { + struct usbdux_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; - unsigned int chan, gain; - int i, ret; - struct usbdux_private *this_usbduxsub = dev->private; + int ret = -EBUSY; + int i; - if (!this_usbduxsub) - return -EFAULT; + down(&devpriv->sem); - down(&this_usbduxsub->sem); + if (devpriv->ao_cmd_running) + goto ao_cmd_exit; /* set current channel of the running acquisition to zero */ s->async->cur_chan = 0; + for (i = 0; i < cmd->chanlist_len; ++i) { - chan = CR_CHAN(cmd->chanlist[i]); - gain = CR_RANGE(cmd->chanlist[i]); + unsigned int chan = CR_CHAN(cmd->chanlist[i]); + if (i >= NUMOUTCHANNELS) break; - this_usbduxsub->dac_commands[i] = (chan << 6); + + devpriv->dac_commands[i] = chan << 6; } /* we count in steps of 1ms (125us) */ /* 125us mode not used yet */ - if (0) { /* (this_usbduxsub->high_speed) */ + if (0) { /* (devpriv->high_speed) */ /* 125us */ /* timing of the conversion itself: every 125 us */ - this_usbduxsub->ao_timer = cmd->convert_arg / 125000; + devpriv->ao_timer = cmd->convert_arg / 125000; } else { /* 1ms */ /* timing of the scan: we get all channels at once */ - this_usbduxsub->ao_timer = cmd->scan_begin_arg / 1000000; - if (this_usbduxsub->ao_timer < 1) { - up(&this_usbduxsub->sem); - return -EINVAL; + devpriv->ao_timer = cmd->scan_begin_arg / 1000000; + if (devpriv->ao_timer < 1) { + ret = -EINVAL; + goto ao_cmd_exit; } } - this_usbduxsub->ao_counter = this_usbduxsub->ao_timer; + + devpriv->ao_counter = devpriv->ao_timer; if (cmd->stop_src == TRIG_COUNT) { /* not continuous */ /* counter */ /* high speed also scans everything at once */ - if (0) { /* (this_usbduxsub->high_speed) */ - this_usbduxsub->ao_sample_count = - (cmd->stop_arg) * (cmd->scan_end_arg); + if (0) { /* (devpriv->high_speed) */ + devpriv->ao_sample_count = cmd->stop_arg * + cmd->scan_end_arg; } else { /* there's no scan as the scan has been */ /* perf inside the FX2 */ /* data arrives as one packet */ - this_usbduxsub->ao_sample_count = cmd->stop_arg; + devpriv->ao_sample_count = cmd->stop_arg; } - this_usbduxsub->ao_continous = 0; + devpriv->ao_continous = 0; } else { /* continous acquisition */ - this_usbduxsub->ao_continous = 1; - this_usbduxsub->ao_sample_count = 0; + devpriv->ao_continous = 1; + devpriv->ao_sample_count = 0; } if (cmd->start_src == TRIG_NOW) { /* enable this acquisition operation */ - this_usbduxsub->ao_cmd_running = 1; + devpriv->ao_cmd_running = 1; ret = usbduxsub_submit_outurbs(dev); if (ret < 0) { - this_usbduxsub->ao_cmd_running = 0; + devpriv->ao_cmd_running = 0; /* fixme: unlink here?? */ - up(&this_usbduxsub->sem); - return ret; + goto ao_cmd_exit; } s->async->inttrig = NULL; } else { @@ -1263,8 +1265,10 @@ static int usbdux_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) s->async->inttrig = usbdux_ao_inttrig; } - up(&this_usbduxsub->sem); - return 0; +ao_cmd_exit: + up(&devpriv->sem); + + return ret; } static int usbdux_dio_insn_config(struct comedi_device *dev, -- GitLab From fc110df61f0adf060d6b2011ecaba45332a479a6 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 25 Jul 2013 16:05:53 -0700 Subject: [PATCH 292/942] staging: comedi: usbdux: tidy up usbdux_dio_insn_config() Tidy up this function a bit. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 40e1424ce5a0e..cdb02876a7190 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -1273,32 +1273,30 @@ static int usbdux_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) static int usbdux_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { - int chan = CR_CHAN(insn->chanspec); - - /* The input or output configuration of each digital line is - * configured by a special insn_config instruction. chanspec - * contains the channel to be changed, and data[0] contains the - * value COMEDI_INPUT or COMEDI_OUTPUT. */ + unsigned int mask = 1 << CR_CHAN(insn->chanspec); switch (data[0]) { case INSN_CONFIG_DIO_OUTPUT: - s->io_bits |= 1 << chan; /* 1 means Out */ + s->io_bits |= mask; break; case INSN_CONFIG_DIO_INPUT: - s->io_bits &= ~(1 << chan); + s->io_bits &= ~mask; break; case INSN_CONFIG_DIO_QUERY: - data[1] = - (s->io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT; + data[1] = (s->io_bits & mask) ? COMEDI_OUTPUT : COMEDI_INPUT; break; default: return -EINVAL; break; } - /* we don't tell the firmware here as it would take 8 frames */ - /* to submit the information. We do it in the insn_bits. */ + + /* + * We don't tell the firmware here as it would take 8 frames + * to submit the information. We do it in the insn_bits. + */ return insn->n; } -- GitLab From 81a9bdaac428174d04df8b361c9363a5e33f533f Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 25 Jul 2013 16:06:11 -0700 Subject: [PATCH 293/942] staging: comedi: usbdux: tidy up usbdux_dio_insn_bits() Rename the local variable used for the private data pointer to the comedi "norm". Remove the unnecessary sanity check of the private data pointer. This function can only be called is the private data was allocated during the attach. Tidy up the exit path using goto to ensure that the semaphore is released. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 54 ++++++++++++------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index cdb02876a7190..a1e5cf1388f1d 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -1302,40 +1302,40 @@ static int usbdux_dio_insn_config(struct comedi_device *dev, static int usbdux_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { - struct usbdux_private *this_usbduxsub = dev->private; - int err; + struct usbdux_private *devpriv = dev->private; + unsigned int mask = data[0]; + unsigned int bits = data[1]; + int ret; - if (!this_usbduxsub) - return -EFAULT; + down(&devpriv->sem); - down(&this_usbduxsub->sem); + s->state &= ~mask; + s->state |= (bits & mask); - /* The insn data is a mask in data[0] and the new data - * in data[1], each channel cooresponding to a bit. */ - s->state &= ~data[0]; - s->state |= data[0] & data[1]; - this_usbduxsub->dux_commands[1] = s->io_bits; - this_usbduxsub->dux_commands[2] = s->state; + devpriv->dux_commands[1] = s->io_bits; + devpriv->dux_commands[2] = s->state; - /* This command also tells the firmware to return */ - /* the digital input lines */ - err = send_dux_commands(dev, SENDDIOBITSCOMMAND); - if (err < 0) { - up(&this_usbduxsub->sem); - return err; - } - err = receive_dux_commands(dev, SENDDIOBITSCOMMAND); - if (err < 0) { - up(&this_usbduxsub->sem); - return err; - } + /* + * This command also tells the firmware to return + * the digital input lines. + */ + ret = send_dux_commands(dev, SENDDIOBITSCOMMAND); + if (ret < 0) + goto dio_exit; + ret = receive_dux_commands(dev, SENDDIOBITSCOMMAND); + if (ret < 0) + goto dio_exit; - data[1] = le16_to_cpu(this_usbduxsub->insn_buffer[1]); - up(&this_usbduxsub->sem); - return insn->n; + data[1] = le16_to_cpu(devpriv->insn_buffer[1]); + +dio_exit: + up(&devpriv->sem); + + return ret ? ret : insn->n; } /* reads the 4 counters, only two are used just now */ -- GitLab From 48967d4f5d91acbe0e70fa821c5951059566ac84 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 25 Jul 2013 16:06:30 -0700 Subject: [PATCH 294/942] staging: comedi: usbdux: fix usbdux_counter_read() Comedi (*insn_read) operations are supposed to read and return insn->n values. Fix this function to work like the core expects. Rename the local variable used for the private data pointer to the comedi "norm". Remove the unnecessary sanity check of the private data pointer. This function can only be called is the private data was allocated during the attach. Tidy up the exit path using goto to ensure that the semaphore is released. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 39 ++++++++++++------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index a1e5cf1388f1d..05bea98444db5 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -1338,34 +1338,33 @@ static int usbdux_dio_insn_bits(struct comedi_device *dev, return ret ? ret : insn->n; } -/* reads the 4 counters, only two are used just now */ static int usbdux_counter_read(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { - struct usbdux_private *this_usbduxsub = dev->private; - int chan = insn->chanspec; - int err; + struct usbdux_private *devpriv = dev->private; + unsigned int chan = CR_CHAN(insn->chanspec); + int ret = 0; + int i; - if (!this_usbduxsub) - return -EFAULT; + down(&devpriv->sem); - down(&this_usbduxsub->sem); - err = send_dux_commands(dev, READCOUNTERCOMMAND); - if (err < 0) { - up(&this_usbduxsub->sem); - return err; - } + for (i = 0; i < insn->n; i++) { + ret = send_dux_commands(dev, READCOUNTERCOMMAND); + if (ret < 0) + goto counter_read_exit; + ret = receive_dux_commands(dev, READCOUNTERCOMMAND); + if (ret < 0) + goto counter_read_exit; - err = receive_dux_commands(dev, READCOUNTERCOMMAND); - if (err < 0) { - up(&this_usbduxsub->sem); - return err; + data[i] = le16_to_cpu(devpriv->insn_buffer[chan + 1]); } - data[0] = le16_to_cpu(this_usbduxsub->insn_buffer[chan + 1]); - up(&this_usbduxsub->sem); - return 1; +counter_read_exit: + up(&devpriv->sem); + + return ret ? ret : insn->n; } static int usbdux_counter_write(struct comedi_device *dev, -- GitLab From f2929618d376075e01136326148e7028350c7c38 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 25 Jul 2013 16:06:47 -0700 Subject: [PATCH 295/942] staging: comedi: usbdux: fix usbdux_counter_write() Comedi (*insn_write) operations are supposed to write insn->n values. Fix this function to work like the core expects. Rename the local variable used for the private data pointer to the comedi "norm". Remove the unnecessary sanity check of the private data pointer. This function can only be called is the private data was allocated during the attach. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 31 ++++++++++++++----------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 05bea98444db5..82624a24eb3eb 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -1369,27 +1369,30 @@ static int usbdux_counter_read(struct comedi_device *dev, static int usbdux_counter_write(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { - struct usbdux_private *this_usbduxsub = dev->private; - int err; + struct usbdux_private *devpriv = dev->private; + unsigned int chan = CR_CHAN(insn->chanspec); + int16_t *p = (int16_t *)&devpriv->dux_commands[2]; + int ret = 0; + int i; - if (!this_usbduxsub) - return -EFAULT; + down(&devpriv->sem); - down(&this_usbduxsub->sem); - this_usbduxsub->dux_commands[1] = insn->chanspec; - *((int16_t *) (this_usbduxsub->dux_commands + 2)) = cpu_to_le16(*data); + devpriv->dux_commands[1] = chan; - err = send_dux_commands(dev, WRITECOUNTERCOMMAND); - if (err < 0) { - up(&this_usbduxsub->sem); - return err; + for (i = 0; i < insn->n; i++) { + *p = cpu_to_le16(data[i]); + + ret = send_dux_commands(dev, WRITECOUNTERCOMMAND); + if (ret < 0) + break; } - up(&this_usbduxsub->sem); + up(&devpriv->sem); - return 1; + return ret ? ret : insn->n; } static int usbdux_counter_config(struct comedi_device *dev, -- GitLab From 38f0683502a5c57dd39e4c65ec86cbe8e3975d5b Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 25 Jul 2013 16:07:04 -0700 Subject: [PATCH 296/942] staging: comedi: usbdux: tidy up usbdux_pwm_stop() For aesthetic reasons, pass the comedi_device pointer to this function instead of the private data pointer. Rename the local variable used for the private data pointer to the comedi "norm". Remove the unnecessary sanity check of the private data pointer. This function can only be called is the private data was allocated during the attach. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 82624a24eb3eb..61e9df90e403c 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -1417,20 +1417,15 @@ static int usbduxsub_unlink_pwm_urbs(struct usbdux_private *usbduxsub_tmp) return err; } -/* This cancels a running acquisition operation - * in any context. - */ -static int usbdux_pwm_stop(struct usbdux_private *this_usbduxsub, int do_unlink) +static int usbdux_pwm_stop(struct comedi_device *dev, int do_unlink) { + struct usbdux_private *devpriv = dev->private; int ret = 0; - if (!this_usbduxsub) - return -EFAULT; - if (do_unlink) - ret = usbduxsub_unlink_pwm_urbs(this_usbduxsub); + ret = usbduxsub_unlink_pwm_urbs(devpriv); - this_usbduxsub->pwm_cmd_running = 0; + devpriv->pwm_cmd_running = 0; return ret; } @@ -1443,7 +1438,7 @@ static int usbdux_pwm_cancel(struct comedi_device *dev, int res = 0; /* unlink only if it is really running */ - res = usbdux_pwm_stop(this_usbduxsub, this_usbduxsub->pwm_cmd_running); + res = usbdux_pwm_stop(dev, this_usbduxsub->pwm_cmd_running); return send_dux_commands(dev, SENDPWMOFF); } @@ -1468,7 +1463,7 @@ static void usbduxsub_pwm_irq(struct urb *urb) * no unlink needed here. Already shutting down. */ if (devpriv->pwm_cmd_running) - usbdux_pwm_stop(devpriv, 0); + usbdux_pwm_stop(dev, 0); return; @@ -1478,7 +1473,7 @@ static void usbduxsub_pwm_irq(struct urb *urb) dev_err(dev->class_dev, "Non-zero urb status received in pwm intr context: %d\n", urb->status); - usbdux_pwm_stop(devpriv, 0); + usbdux_pwm_stop(dev, 0); } return; } @@ -1501,7 +1496,7 @@ static void usbduxsub_pwm_irq(struct urb *urb) "buggy USB host controller or bug in IRQ handling!\n"); /* don't do an unlink here */ - usbdux_pwm_stop(devpriv, 0); + usbdux_pwm_stop(dev, 0); } } } -- GitLab From 96ca37047e774c48cbf5ccf4e6d18e8cf5898dcd Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 25 Jul 2013 16:07:20 -0700 Subject: [PATCH 297/942] staging: comedi: usbdux: fix usbdux_pwm_cancel() Add the missing down/up of the semaphore to prevent other commands from being issued to the usb device while the pwn is being stopped. Rename the local variable used for the private data pointer to the comedi "norm". Make sure to check that usbdux_pwm_stop() was successful before sending command to the usb device to stop the pwm. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 61e9df90e403c..14c26e559cb76 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -1430,17 +1430,25 @@ static int usbdux_pwm_stop(struct comedi_device *dev, int do_unlink) return ret; } -/* force unlink - is called by comedi */ static int usbdux_pwm_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { - struct usbdux_private *this_usbduxsub = dev->private; - int res = 0; + struct usbdux_private *devpriv = dev->private; + int ret; + + down(&devpriv->sem); /* unlink only if it is really running */ - res = usbdux_pwm_stop(dev, this_usbduxsub->pwm_cmd_running); + ret = usbdux_pwm_stop(dev, devpriv->pwm_cmd_running); + if (ret) + goto pwm_cancel_exit; + + ret = send_dux_commands(dev, SENDPWMOFF); - return send_dux_commands(dev, SENDPWMOFF); +pwm_cancel_exit: + up(&devpriv->sem); + + return ret; } static void usbduxsub_pwm_irq(struct urb *urb) -- GitLab From 81e8013484ae0790c7819aa9e08b265807eb6905 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 25 Jul 2013 16:07:39 -0700 Subject: [PATCH 298/942] staging: comedi: usbdux: fix usbdux_pwm_start() Add the missing down/up of the semaphore to prevent other commands from being issued to the usb device while the pwn is being stopped. Rename the local variable used for the private data pointer to the comedi "norm". Use memset() to initialize the urb transfer buffer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 34 ++++++++++++------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 14c26e559cb76..0337da1f36fa2 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -1544,34 +1544,34 @@ static int usbdux_pwm_period(struct comedi_device *dev, return 0; } -/* is called from insn so there's no need to do all the sanity checks */ static int usbdux_pwm_start(struct comedi_device *dev, struct comedi_subdevice *s) { - int ret, i; - struct usbdux_private *this_usbduxsub = dev->private; + struct usbdux_private *devpriv = dev->private; + int ret = 0; - if (this_usbduxsub->pwm_cmd_running) { - /* already running */ - return 0; - } + down(&devpriv->sem); + + if (devpriv->pwm_cmd_running) + goto pwm_start_exit; - this_usbduxsub->dux_commands[1] = ((int8_t) this_usbduxsub->pwn_delay); + devpriv->dux_commands[1] = devpriv->pwn_delay; ret = send_dux_commands(dev, SENDPWMON); if (ret < 0) - return ret; + goto pwm_start_exit; /* initialise the buffer */ - for (i = 0; i < this_usbduxsub->size_pwm_buf; i++) - ((char *)(this_usbduxsub->urb_pwm->transfer_buffer))[i] = 0; + memset(devpriv->urb_pwm->transfer_buffer, 0, devpriv->size_pwm_buf); - this_usbduxsub->pwm_cmd_running = 1; + devpriv->pwm_cmd_running = 1; ret = usbduxsub_submit_pwm_urbs(dev); - if (ret < 0) { - this_usbduxsub->pwm_cmd_running = 0; - return ret; - } - return 0; + if (ret < 0) + devpriv->pwm_cmd_running = 0; + +pwm_start_exit: + up(&devpriv->sem); + + return ret; } /* generates the bit pattern for PWM with the optional sign bit */ -- GitLab From 3c50bbb7cb0ba0d66aab4446b0554bd22e76f524 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 25 Jul 2013 16:07:57 -0700 Subject: [PATCH 299/942] staging: comedi: usbdux: tidy up unlink and stop helpers For aesthetic reasons, pass the comedi_device pointer to the unlink helpers instead of the private data pointer. All the unlink helpers simply call usb_kill_urb() to cancel any pending transfer requests. The usb passed to usb_kill_urb() can be NULL so the extra sanity check is not required. The unlink helpers will always return success so just make them void functions. Since the stop helpers will also always return success, make them void functions as well. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 95 ++++++++----------------- 1 file changed, 29 insertions(+), 66 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 0337da1f36fa2..7077d268f8835 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -249,53 +249,39 @@ struct usbdux_private { struct semaphore sem; }; -/* - * Stops the data acquision - * It should be safe to call this function from any context - */ -static int usbduxsub_unlink_inurbs(struct usbdux_private *usbduxsub_tmp) +static void usbduxsub_unlink_inurbs(struct comedi_device *dev) { - int i = 0; - int err = 0; + struct usbdux_private *devpriv = dev->private; + int i; - if (usbduxsub_tmp && usbduxsub_tmp->urb_in) { - for (i = 0; i < usbduxsub_tmp->num_in_buffers; i++) { - if (usbduxsub_tmp->urb_in[i]) { - /* We wait here until all transfers have been - * cancelled. */ - usb_kill_urb(usbduxsub_tmp->urb_in[i]); - } - } + if (devpriv->urb_in) { + for (i = 0; i < devpriv->num_in_buffers; i++) + usb_kill_urb(devpriv->urb_in[i]); } - return err; } -static int usbdux_ai_stop(struct comedi_device *dev, int do_unlink) +static void usbdux_ai_stop(struct comedi_device *dev, int do_unlink) { struct usbdux_private *devpriv = dev->private; - int ret = 0; if (do_unlink) - ret = usbduxsub_unlink_inurbs(devpriv); + usbduxsub_unlink_inurbs(dev); devpriv->ai_cmd_running = 0; - - return ret; } static int usbdux_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { struct usbdux_private *devpriv = dev->private; - int ret = 0; /* prevent other CPUs from submitting new commands just now */ down(&devpriv->sem); /* unlink only if the urb really has been submitted */ - ret = usbdux_ai_stop(dev, devpriv->ai_cmd_running); + usbdux_ai_stop(dev, devpriv->ai_cmd_running); up(&devpriv->sem); - return ret; + return 0; } /* analogue IN - interrupt service routine */ @@ -422,46 +408,39 @@ static void usbduxsub_ai_isoc_irq(struct urb *urb) comedi_event(dev, s); } -static int usbduxsub_unlink_outurbs(struct usbdux_private *usbduxsub_tmp) +static void usbduxsub_unlink_outurbs(struct comedi_device *dev) { - int i = 0; - int err = 0; + struct usbdux_private *devpriv = dev->private; + int i; - if (usbduxsub_tmp && usbduxsub_tmp->urb_out) { - for (i = 0; i < usbduxsub_tmp->num_out_buffers; i++) { - if (usbduxsub_tmp->urb_out[i]) - usb_kill_urb(usbduxsub_tmp->urb_out[i]); - } + if (devpriv->urb_out) { + for (i = 0; i < devpriv->num_out_buffers; i++) + usb_kill_urb(devpriv->urb_out[i]); } - return err; } -static int usbdux_ao_stop(struct comedi_device *dev, int do_unlink) +static void usbdux_ao_stop(struct comedi_device *dev, int do_unlink) { struct usbdux_private *devpriv = dev->private; - int ret = 0; if (do_unlink) - ret = usbduxsub_unlink_outurbs(devpriv); + usbduxsub_unlink_outurbs(dev); devpriv->ao_cmd_running = 0; - - return ret; } static int usbdux_ao_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { struct usbdux_private *devpriv = dev->private; - int ret = 0; /* prevent other CPUs from submitting a command just now */ down(&devpriv->sem); /* unlink only if it is really running */ - ret = usbdux_ao_stop(dev, devpriv->ao_cmd_running); + usbdux_ao_stop(dev, devpriv->ao_cmd_running); up(&devpriv->sem); - return ret; + return 0; } static void usbduxsub_ao_isoc_irq(struct urb *urb) @@ -1403,31 +1382,21 @@ static int usbdux_counter_config(struct comedi_device *dev, return 2; } -/***********************************/ -/* PWM */ - -static int usbduxsub_unlink_pwm_urbs(struct usbdux_private *usbduxsub_tmp) +static void usbduxsub_unlink_pwm_urbs(struct comedi_device *dev) { - int err = 0; + struct usbdux_private *devpriv = dev->private; - if (usbduxsub_tmp && usbduxsub_tmp->urb_pwm) { - if (usbduxsub_tmp->urb_pwm) - usb_kill_urb(usbduxsub_tmp->urb_pwm); - } - return err; + usb_kill_urb(devpriv->urb_pwm); } -static int usbdux_pwm_stop(struct comedi_device *dev, int do_unlink) +static void usbdux_pwm_stop(struct comedi_device *dev, int do_unlink) { struct usbdux_private *devpriv = dev->private; - int ret = 0; if (do_unlink) - ret = usbduxsub_unlink_pwm_urbs(devpriv); + usbduxsub_unlink_pwm_urbs(dev); devpriv->pwm_cmd_running = 0; - - return ret; } static int usbdux_pwm_cancel(struct comedi_device *dev, @@ -1437,15 +1406,9 @@ static int usbdux_pwm_cancel(struct comedi_device *dev, int ret; down(&devpriv->sem); - /* unlink only if it is really running */ - ret = usbdux_pwm_stop(dev, devpriv->pwm_cmd_running); - if (ret) - goto pwm_cancel_exit; - + usbdux_pwm_stop(dev, devpriv->pwm_cmd_running); ret = send_dux_commands(dev, SENDPWMOFF); - -pwm_cancel_exit: up(&devpriv->sem); return ret; @@ -1979,11 +1942,11 @@ static void usbdux_detach(struct comedi_device *dev) usb_set_intfdata(intf, NULL); if (devpriv->pwm_cmd_running) - usbduxsub_unlink_pwm_urbs(devpriv); + usbduxsub_unlink_pwm_urbs(dev); if (devpriv->ao_cmd_running) - usbduxsub_unlink_outurbs(devpriv); + usbduxsub_unlink_outurbs(dev); if (devpriv->ai_cmd_running) - usbduxsub_unlink_inurbs(devpriv); + usbduxsub_unlink_inurbs(dev); usbdux_free_usb_buffers(devpriv); -- GitLab From ecc2b22990bd59b2e8ea34afa0334598cbdfad71 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 25 Jul 2013 16:08:16 -0700 Subject: [PATCH 300/942] staging: comedi: usbdux: use the stop helpers in the detach Use the stop helpers instead of duplicating the code in the detach. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 7077d268f8835..f60674344ea84 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -1941,12 +1941,10 @@ static void usbdux_detach(struct comedi_device *dev) usb_set_intfdata(intf, NULL); - if (devpriv->pwm_cmd_running) - usbduxsub_unlink_pwm_urbs(dev); - if (devpriv->ao_cmd_running) - usbduxsub_unlink_outurbs(dev); - if (devpriv->ai_cmd_running) - usbduxsub_unlink_inurbs(dev); + /* stop and unlink any submitted urbs */ + usbdux_pwm_stop(dev, devpriv->pwm_cmd_running); + usbdux_ao_stop(dev, devpriv->ao_cmd_running); + usbdux_ai_stop(dev, devpriv->ai_cmd_running); usbdux_free_usb_buffers(devpriv); -- GitLab From a3ef101f119b8510cb14a1f5a6bdb8639c8eb742 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 25 Jul 2013 16:08:35 -0700 Subject: [PATCH 301/942] staging: comedi: usbdux: remove the usb endpoint defines The endpoint defines are each only used in one place and don't help clarify the code. Remove the defines and just open code the values. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index f60674344ea84..644f6aba19412 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -113,21 +113,6 @@ sampling rate. If you sample two channels you get 4kHz and so on. /* max lenghth of the transfer-buffer for software upload */ #define TB_LEN 0x2000 -/* Input endpoint number: ISO/IRQ */ -#define ISOINEP 6 - -/* Output endpoint number: ISO/IRQ */ -#define ISOOUTEP 2 - -/* This EP sends DUX commands to USBDUX */ -#define COMMAND_OUT_EP 1 - -/* This EP receives the DUX commands from USBDUX */ -#define COMMAND_IN_EP 8 - -/* Output endpoint for PWM */ -#define PWM_EP 4 - /* 300Hz max frequ under PWM */ #define MIN_PWM_PERIOD ((long)(1E9/300)) @@ -804,7 +789,7 @@ static int send_dux_commands(struct comedi_device *dev, int cmd_type) devpriv->dux_commands[0] = cmd_type; - return usb_bulk_msg(usb, usb_sndbulkpipe(usb, COMMAND_OUT_EP), + return usb_bulk_msg(usb, usb_sndbulkpipe(usb, 1), devpriv->dux_commands, SIZEOFDUXBUFFER, &nsent, BULK_TIMEOUT); } @@ -818,7 +803,7 @@ static int receive_dux_commands(struct comedi_device *dev, int command) int i; for (i = 0; i < RETRIES; i++) { - ret = usb_bulk_msg(usb, usb_rcvbulkpipe(usb, COMMAND_IN_EP), + ret = usb_bulk_msg(usb, usb_rcvbulkpipe(usb, 8), devpriv->insn_buffer, SIZEINSNBUF, &nrec, BULK_TIMEOUT); if (ret < 0) @@ -1479,7 +1464,7 @@ static int usbduxsub_submit_pwm_urbs(struct comedi_device *dev) struct urb *urb = devpriv->urb_pwm; /* in case of a resubmission after an unlink... */ - usb_fill_bulk_urb(urb, usb, usb_sndbulkpipe(usb, PWM_EP), + usb_fill_bulk_urb(urb, usb, usb_sndbulkpipe(usb, 4), urb->transfer_buffer, devpriv->size_pwm_buf, usbduxsub_pwm_irq, @@ -1712,7 +1697,7 @@ static int usbdux_alloc_usb_buffers(struct comedi_device *dev) /* will be filled later with a pointer to the comedi-device */ /* and ONLY then the urb should be submitted */ urb->context = NULL; - urb->pipe = usb_rcvisocpipe(usb, ISOINEP); + urb->pipe = usb_rcvisocpipe(usb, 6); urb->transfer_flags = URB_ISO_ASAP; urb->transfer_buffer = kzalloc(SIZEINBUF, GFP_KERNEL); if (!urb->transfer_buffer) @@ -1742,7 +1727,7 @@ static int usbdux_alloc_usb_buffers(struct comedi_device *dev) /* will be filled later with a pointer to the comedi-device */ /* and ONLY then the urb should be submitted */ urb->context = NULL; - urb->pipe = usb_sndisocpipe(usb, ISOOUTEP); + urb->pipe = usb_sndisocpipe(usb, 2); urb->transfer_flags = URB_ISO_ASAP; urb->transfer_buffer = kzalloc(SIZEOUTBUF, GFP_KERNEL); if (!urb->transfer_buffer) -- GitLab From 887463bb7968455396a9c61cd3673160b3ebc58c Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 25 Jul 2013 16:08:52 -0700 Subject: [PATCH 302/942] staging: comedi: usbdux: remove some unused defines These defines are not used by the driver. Remove them. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 644f6aba19412..6991e85a6d80f 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -103,16 +103,6 @@ sampling rate. If you sample two channels you get 4kHz and so on. /* internal addresses of the 8051 processor */ #define USBDUXSUB_CPUCS 0xE600 -/* - * the minor device number, major is 180 only for debugging purposes and to - * upload special firmware (programming the eeprom etc) which is not compatible - * with the comedi framwork - */ -#define USBDUXSUB_MINOR 32 - -/* max lenghth of the transfer-buffer for software upload */ -#define TB_LEN 0x2000 - /* 300Hz max frequ under PWM */ #define MIN_PWM_PERIOD ((long)(1E9/300)) -- GitLab From 1731a826cad3a71062b00c80abca4f887d57e501 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 25 Jul 2013 16:09:13 -0700 Subject: [PATCH 303/942] staging: comedi: usbdux: move usbdux_firmware_upload() For aesthetics, move this function closer to the (*auto_attach). Also, rename some of the defined constants that are used by the firmware upload. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 170 ++++++++++++------------ 1 file changed, 82 insertions(+), 88 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 6991e85a6d80f..92d740a4c2951 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -91,17 +91,16 @@ sampling rate. If you sample two channels you get 4kHz and so on. #include "comedi_fc.h" -/* timeout for the USB-transfer in ms*/ -#define BULK_TIMEOUT 1000 +/* constants for firmware upload and download */ +#define USBDUX_FIRMWARE "usbdux_firmware.bin" +#define USBDUX_FIRMWARE_MAX_LEN 0x2000 +#define USBDUX_FIRMWARE_CMD 0xa0 +#define VENDOR_DIR_IN 0xc0 +#define VENDOR_DIR_OUT 0x40 +#define USBDUX_CPU_CS 0xe600 -/* constants for "firmware" upload and download */ -#define FIRMWARE "usbdux_firmware.bin" -#define USBDUXSUB_FIRMWARE 0xA0 -#define VENDOR_DIR_IN 0xC0 -#define VENDOR_DIR_OUT 0x40 - -/* internal addresses of the 8051 processor */ -#define USBDUXSUB_CPUCS 0xE600 +/* timeout for the USB-transfer in ms */ +#define BULK_TIMEOUT 1000 /* 300Hz max frequ under PWM */ #define MIN_PWM_PERIOD ((long)(1E9/300)) @@ -539,80 +538,6 @@ static void usbduxsub_ao_isoc_irq(struct urb *urb) } } -#define FIRMWARE_MAX_LEN 0x2000 - -static int usbdux_firmware_upload(struct comedi_device *dev, - const u8 *data, size_t size, - unsigned long context) -{ - struct usb_device *usb = comedi_to_usb_dev(dev); - uint8_t *buf; - uint8_t *tmp; - int ret; - - if (!data) - return 0; - - if (size > FIRMWARE_MAX_LEN) { - dev_err(dev->class_dev, - "usbdux firmware binary it too large for FX2.\n"); - return -ENOMEM; - } - - /* we generate a local buffer for the firmware */ - buf = kmemdup(data, size, GFP_KERNEL); - if (!buf) - return -ENOMEM; - - /* we need a malloc'ed buffer for usb_control_msg() */ - tmp = kmalloc(1, GFP_KERNEL); - if (!tmp) { - kfree(buf); - return -ENOMEM; - } - - /* stop the current firmware on the device */ - *tmp = 1; /* 7f92 to one */ - ret = usb_control_msg(usb, usb_sndctrlpipe(usb, 0), - USBDUXSUB_FIRMWARE, - VENDOR_DIR_OUT, - USBDUXSUB_CPUCS, 0x0000, - tmp, 1, - BULK_TIMEOUT); - if (ret < 0) { - dev_err(dev->class_dev, "can not stop firmware\n"); - goto done; - } - - /* upload the new firmware to the device */ - ret = usb_control_msg(usb, usb_sndctrlpipe(usb, 0), - USBDUXSUB_FIRMWARE, - VENDOR_DIR_OUT, - 0, 0x0000, - buf, size, - BULK_TIMEOUT); - if (ret < 0) { - dev_err(dev->class_dev, "firmware upload failed\n"); - goto done; - } - - /* start the new firmware on the device */ - *tmp = 0; /* 7f92 to zero */ - ret = usb_control_msg(usb, usb_sndctrlpipe(usb, 0), - USBDUXSUB_FIRMWARE, - VENDOR_DIR_OUT, - USBDUXSUB_CPUCS, 0x0000, - tmp, 1, - BULK_TIMEOUT); - if (ret < 0) - dev_err(dev->class_dev, "can not start firmware\n"); - -done: - kfree(tmp); - kfree(buf); - return ret; -} - static int usbduxsub_submit_inurbs(struct comedi_device *dev) { struct usb_device *usb = comedi_to_usb_dev(dev); @@ -1635,8 +1560,77 @@ static int usbdux_pwm_config(struct comedi_device *dev, return -EINVAL; } -/* end of PWM */ -/*****************************************************************/ +static int usbdux_firmware_upload(struct comedi_device *dev, + const u8 *data, size_t size, + unsigned long context) +{ + struct usb_device *usb = comedi_to_usb_dev(dev); + uint8_t *buf; + uint8_t *tmp; + int ret; + + if (!data) + return 0; + + if (size > USBDUX_FIRMWARE_MAX_LEN) { + dev_err(dev->class_dev, + "usbdux firmware binary it too large for FX2.\n"); + return -ENOMEM; + } + + /* we generate a local buffer for the firmware */ + buf = kmemdup(data, size, GFP_KERNEL); + if (!buf) + return -ENOMEM; + + /* we need a malloc'ed buffer for usb_control_msg() */ + tmp = kmalloc(1, GFP_KERNEL); + if (!tmp) { + kfree(buf); + return -ENOMEM; + } + + /* stop the current firmware on the device */ + *tmp = 1; /* 7f92 to one */ + ret = usb_control_msg(usb, usb_sndctrlpipe(usb, 0), + USBDUX_FIRMWARE_CMD, + VENDOR_DIR_OUT, + USBDUX_CPU_CS, 0x0000, + tmp, 1, + BULK_TIMEOUT); + if (ret < 0) { + dev_err(dev->class_dev, "can not stop firmware\n"); + goto done; + } + + /* upload the new firmware to the device */ + ret = usb_control_msg(usb, usb_sndctrlpipe(usb, 0), + USBDUX_FIRMWARE_CMD, + VENDOR_DIR_OUT, + 0, 0x0000, + buf, size, + BULK_TIMEOUT); + if (ret < 0) { + dev_err(dev->class_dev, "firmware upload failed\n"); + goto done; + } + + /* start the new firmware on the device */ + *tmp = 0; /* 7f92 to zero */ + ret = usb_control_msg(usb, usb_sndctrlpipe(usb, 0), + USBDUX_FIRMWARE_CMD, + VENDOR_DIR_OUT, + USBDUX_CPU_CS, 0x0000, + tmp, 1, + BULK_TIMEOUT); + if (ret < 0) + dev_err(dev->class_dev, "can not start firmware\n"); + +done: + kfree(tmp); + kfree(buf); + return ret; +} static int usbdux_alloc_usb_buffers(struct comedi_device *dev) { @@ -1831,7 +1825,7 @@ static int usbdux_auto_attach(struct comedi_device *dev, return ret; } - ret = comedi_load_firmware(dev, &usb->dev, FIRMWARE, + ret = comedi_load_firmware(dev, &usb->dev, USBDUX_FIRMWARE, usbdux_firmware_upload, 0); if (ret < 0) return ret; @@ -1958,4 +1952,4 @@ module_comedi_usb_driver(usbdux_driver, usbdux_usb_driver); MODULE_AUTHOR("Bernd Porr, BerndPorr@f2s.com"); MODULE_DESCRIPTION("Stirling/ITL USB-DUX -- Bernd.Porr@f2s.com"); MODULE_LICENSE("GPL"); -MODULE_FIRMWARE(FIRMWARE); +MODULE_FIRMWARE(USBDUX_FIRMWARE); -- GitLab From 7acf26edbcba808cb6447af893f30c63751938f8 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 25 Jul 2013 16:09:30 -0700 Subject: [PATCH 304/942] staging: comedi: usbdux: clarify bipolar ai data in usbduxsub_ai_isoc_irq() Use the comedi_range_is_bipolar() helper instead of checking the 'range' index against a magic number. Also, use the s->maxdata to calculate the value needed to munge the value for bipolar data instead of the magic number. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 92d740a4c2951..20b705e87d489 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -363,14 +363,15 @@ static void usbduxsub_ai_isoc_irq(struct urb *urb) /* get the data from the USB bus and hand it over to comedi */ n = s->async->cmd.chanlist_len; for (i = 0; i < n; i++) { + unsigned int range = CR_RANGE(s->async->cmd.chanlist[i]); + int16_t val = le16_to_cpu(devpriv->in_buffer[i]); + + /* bipolar data is two's-complement */ + if (comedi_range_is_bipolar(s, range)) + val ^= ((s->maxdata + 1) >> 1); + /* transfer data */ - if (CR_RANGE(s->async->cmd.chanlist[i]) <= 1) { - err = comedi_buf_put(s->async, - le16_to_cpu(devpriv->in_buffer[i]) ^ 0x800); - } else { - err = comedi_buf_put(s->async, - le16_to_cpu(devpriv->in_buffer[i])); - } + err = comedi_buf_put(s->async, val); if (unlikely(err == 0)) { /* buffer overflow */ usbdux_ai_stop(dev, 0); -- GitLab From c79bc875537d5d9ef396b3a4b7e2bf2b28bd9945 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 25 Jul 2013 16:09:48 -0700 Subject: [PATCH 305/942] staging: comedi: usbdux: rename private data variables The usbdux and usbduxsigma drivers are _very_ similar. For aesthetic reasons, rename the private data variables in this driver to match the names in the usbduxsigma driver so we can start sharing the common code. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 136 ++++++++++++------------ 1 file changed, 68 insertions(+), 68 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 20b705e87d489..bd46bec73d7bb 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -177,24 +177,24 @@ static const struct comedi_lrange range_usbdux_ao_range = { struct usbdux_private { /* actual number of in-buffers */ - int num_in_buffers; + int n_ai_urbs; /* actual number of out-buffers */ - int num_out_buffers; + int n_ao_urbs; /* ISO-transfer handling: buffers */ - struct urb **urb_in; - struct urb **urb_out; + struct urb **ai_urbs; + struct urb **ao_urbs; /* pwm-transfer handling */ - struct urb *urb_pwm; + struct urb *pwm_urb; /* PWM period */ unsigned int pwm_period; /* PWM internal delay for the GPIF in the FX2 */ - int8_t pwn_delay; + int8_t pwm_delay; /* size of the PWM buffer which holds the bit pattern */ - int size_pwm_buf; + int pwm_buf_sz; /* input buffer for the ISO-transfer */ - int16_t *in_buffer; + int16_t *in_buf; /* input buffer for single insn */ - int16_t *insn_buffer; + int16_t *insn_buf; /* output buffer for single DA outputs */ int16_t *out_buffer; @@ -228,9 +228,9 @@ static void usbduxsub_unlink_inurbs(struct comedi_device *dev) struct usbdux_private *devpriv = dev->private; int i; - if (devpriv->urb_in) { - for (i = 0; i < devpriv->num_in_buffers; i++) - usb_kill_urb(devpriv->urb_in[i]); + if (devpriv->ai_urbs) { + for (i = 0; i < devpriv->n_ai_urbs; i++) + usb_kill_urb(devpriv->ai_urbs[i]); } } @@ -270,7 +270,7 @@ static void usbduxsub_ai_isoc_irq(struct urb *urb) switch (urb->status) { case 0: /* copy the result in the transfer buffer */ - memcpy(devpriv->in_buffer, urb->transfer_buffer, SIZEINBUF); + memcpy(devpriv->in_buf, urb->transfer_buffer, SIZEINBUF); break; case -EILSEQ: /* error in the ISOchronous data */ @@ -364,7 +364,7 @@ static void usbduxsub_ai_isoc_irq(struct urb *urb) n = s->async->cmd.chanlist_len; for (i = 0; i < n; i++) { unsigned int range = CR_RANGE(s->async->cmd.chanlist[i]); - int16_t val = le16_to_cpu(devpriv->in_buffer[i]); + int16_t val = le16_to_cpu(devpriv->in_buf[i]); /* bipolar data is two's-complement */ if (comedi_range_is_bipolar(s, range)) @@ -388,9 +388,9 @@ static void usbduxsub_unlink_outurbs(struct comedi_device *dev) struct usbdux_private *devpriv = dev->private; int i; - if (devpriv->urb_out) { - for (i = 0; i < devpriv->num_out_buffers; i++) - usb_kill_urb(devpriv->urb_out[i]); + if (devpriv->ao_urbs) { + for (i = 0; i < devpriv->n_ao_urbs; i++) + usb_kill_urb(devpriv->ao_urbs[i]); } } @@ -548,8 +548,8 @@ static int usbduxsub_submit_inurbs(struct comedi_device *dev) int i; /* Submit all URBs and start the transfer on the bus */ - for (i = 0; i < devpriv->num_in_buffers; i++) { - urb = devpriv->urb_in[i]; + for (i = 0; i < devpriv->n_ai_urbs; i++) { + urb = devpriv->ai_urbs[i]; /* in case of a resubmission after an unlink... */ urb->interval = devpriv->ai_interval; @@ -573,8 +573,8 @@ static int usbduxsub_submit_outurbs(struct comedi_device *dev) int ret; int i; - for (i = 0; i < devpriv->num_out_buffers; i++) { - urb = devpriv->urb_out[i]; + for (i = 0; i < devpriv->n_ao_urbs; i++) { + urb = devpriv->ao_urbs[i]; /* in case of a resubmission after an unlink... */ urb->context = dev; @@ -720,11 +720,11 @@ static int receive_dux_commands(struct comedi_device *dev, int command) for (i = 0; i < RETRIES; i++) { ret = usb_bulk_msg(usb, usb_rcvbulkpipe(usb, 8), - devpriv->insn_buffer, SIZEINSNBUF, + devpriv->insn_buf, SIZEINSNBUF, &nrec, BULK_TIMEOUT); if (ret < 0) return ret; - if (le16_to_cpu(devpriv->insn_buffer[0]) == command) + if (le16_to_cpu(devpriv->insn_buf[0]) == command) return ret; } /* command not received */ @@ -881,7 +881,7 @@ static int usbdux_ai_insn_read(struct comedi_device *dev, if (ret < 0) goto ai_read_exit; - val = le16_to_cpu(devpriv->insn_buffer[1]); + val = le16_to_cpu(devpriv->insn_buf[1]); /* bipolar data is two's-complement */ if (comedi_range_is_bipolar(s, range)) @@ -1210,7 +1210,7 @@ static int usbdux_dio_insn_bits(struct comedi_device *dev, if (ret < 0) goto dio_exit; - data[1] = le16_to_cpu(devpriv->insn_buffer[1]); + data[1] = le16_to_cpu(devpriv->insn_buf[1]); dio_exit: up(&devpriv->sem); @@ -1238,7 +1238,7 @@ static int usbdux_counter_read(struct comedi_device *dev, if (ret < 0) goto counter_read_exit; - data[i] = le16_to_cpu(devpriv->insn_buffer[chan + 1]); + data[i] = le16_to_cpu(devpriv->insn_buf[chan + 1]); } counter_read_exit: @@ -1287,7 +1287,7 @@ static void usbduxsub_unlink_pwm_urbs(struct comedi_device *dev) { struct usbdux_private *devpriv = dev->private; - usb_kill_urb(devpriv->urb_pwm); + usb_kill_urb(devpriv->pwm_urb); } static void usbdux_pwm_stop(struct comedi_device *dev, int do_unlink) @@ -1354,7 +1354,7 @@ static void usbduxsub_pwm_irq(struct urb *urb) if (!devpriv->pwm_cmd_running) return; - urb->transfer_buffer_length = devpriv->size_pwm_buf; + urb->transfer_buffer_length = devpriv->pwm_buf_sz; urb->dev = comedi_to_usb_dev(dev); urb->status = 0; if (devpriv->pwm_cmd_running) { @@ -1377,12 +1377,12 @@ static int usbduxsub_submit_pwm_urbs(struct comedi_device *dev) { struct usb_device *usb = comedi_to_usb_dev(dev); struct usbdux_private *devpriv = dev->private; - struct urb *urb = devpriv->urb_pwm; + struct urb *urb = devpriv->pwm_urb; /* in case of a resubmission after an unlink... */ usb_fill_bulk_urb(urb, usb, usb_sndbulkpipe(usb, 4), urb->transfer_buffer, - devpriv->size_pwm_buf, + devpriv->pwm_buf_sz, usbduxsub_pwm_irq, dev); @@ -1402,7 +1402,7 @@ static int usbdux_pwm_period(struct comedi_device *dev, if (fx2delay > 255) return -EAGAIN; } - this_usbduxsub->pwn_delay = fx2delay; + this_usbduxsub->pwm_delay = fx2delay; this_usbduxsub->pwm_period = period; return 0; @@ -1419,13 +1419,13 @@ static int usbdux_pwm_start(struct comedi_device *dev, if (devpriv->pwm_cmd_running) goto pwm_start_exit; - devpriv->dux_commands[1] = devpriv->pwn_delay; + devpriv->dux_commands[1] = devpriv->pwm_delay; ret = send_dux_commands(dev, SENDPWMON); if (ret < 0) goto pwm_start_exit; /* initialise the buffer */ - memset(devpriv->urb_pwm->transfer_buffer, 0, devpriv->size_pwm_buf); + memset(devpriv->pwm_urb->transfer_buffer, 0, devpriv->pwm_buf_sz); devpriv->pwm_cmd_running = 1; ret = usbduxsub_submit_pwm_urbs(dev); @@ -1459,8 +1459,8 @@ static int usbdux_pwm_pattern(struct comedi_device *dev, sgn_mask = (16 << channel); /* this is the buffer which will be filled with the with bit */ /* pattern for one period */ - szbuf = this_usbduxsub->size_pwm_buf; - p_buf = (char *)(this_usbduxsub->urb_pwm->transfer_buffer); + szbuf = this_usbduxsub->pwm_buf_sz; + p_buf = (char *)(this_usbduxsub->pwm_urb->transfer_buffer); for (i = 0; i < szbuf; i++) { c = *p_buf; /* reset bits */ @@ -1651,13 +1651,13 @@ static int usbdux_alloc_usb_buffers(struct comedi_device *dev) return -ENOMEM; /* create space for the in buffer and set it to zero */ - devpriv->in_buffer = kzalloc(SIZEINBUF, GFP_KERNEL); - if (!devpriv->in_buffer) + devpriv->in_buf = kzalloc(SIZEINBUF, GFP_KERNEL); + if (!devpriv->in_buf) return -ENOMEM; /* create space of the instruction buffer */ - devpriv->insn_buffer = kzalloc(SIZEINSNBUF, GFP_KERNEL); - if (!devpriv->insn_buffer) + devpriv->insn_buf = kzalloc(SIZEINSNBUF, GFP_KERNEL); + if (!devpriv->insn_buf) return -ENOMEM; /* create space for the outbuffer */ @@ -1666,17 +1666,17 @@ static int usbdux_alloc_usb_buffers(struct comedi_device *dev) return -ENOMEM; /* in urbs */ - devpriv->urb_in = kcalloc(devpriv->num_in_buffers, sizeof(*urb), - GFP_KERNEL); - if (!devpriv->urb_in) + devpriv->ai_urbs = kcalloc(devpriv->n_ai_urbs, sizeof(*urb), + GFP_KERNEL); + if (!devpriv->ai_urbs) return -ENOMEM; - for (i = 0; i < devpriv->num_in_buffers; i++) { + for (i = 0; i < devpriv->n_ai_urbs; i++) { /* one frame: 1ms */ urb = usb_alloc_urb(1, GFP_KERNEL); if (!urb) return -ENOMEM; - devpriv->urb_in[i] = urb; + devpriv->ai_urbs[i] = urb; urb->dev = usb; /* will be filled later with a pointer to the comedi-device */ @@ -1696,17 +1696,17 @@ static int usbdux_alloc_usb_buffers(struct comedi_device *dev) } /* out urbs */ - devpriv->urb_out = kcalloc(devpriv->num_out_buffers, sizeof(*urb), + devpriv->ao_urbs = kcalloc(devpriv->n_ao_urbs, sizeof(*urb), GFP_KERNEL); - if (!devpriv->urb_out) + if (!devpriv->ao_urbs) return -ENOMEM; - for (i = 0; i < devpriv->num_out_buffers; i++) { + for (i = 0; i < devpriv->n_ao_urbs; i++) { /* one frame: 1ms */ urb = usb_alloc_urb(1, GFP_KERNEL); if (!urb) return -ENOMEM; - devpriv->urb_out[i] = urb; + devpriv->ao_urbs[i] = urb; urb->dev = usb; /* will be filled later with a pointer to the comedi-device */ @@ -1730,14 +1730,14 @@ static int usbdux_alloc_usb_buffers(struct comedi_device *dev) } /* pwm */ - if (devpriv->size_pwm_buf) { + if (devpriv->pwm_buf_sz) { urb = usb_alloc_urb(0, GFP_KERNEL); if (!urb) return -ENOMEM; - devpriv->urb_pwm = urb; + devpriv->pwm_urb = urb; /* max bulk ep size in high speed */ - urb->transfer_buffer = kzalloc(devpriv->size_pwm_buf, + urb->transfer_buffer = kzalloc(devpriv->pwm_buf_sz, GFP_KERNEL); if (!urb->transfer_buffer) return -ENOMEM; @@ -1751,37 +1751,37 @@ static void usbdux_free_usb_buffers(struct usbdux_private *devpriv) struct urb *urb; int i; - urb = devpriv->urb_pwm; + urb = devpriv->pwm_urb; if (urb) { kfree(urb->transfer_buffer); usb_kill_urb(urb); usb_free_urb(urb); } - if (devpriv->urb_out) { - for (i = 0; i < devpriv->num_out_buffers; i++) { - urb = devpriv->urb_out[i]; + if (devpriv->ao_urbs) { + for (i = 0; i < devpriv->n_ao_urbs; i++) { + urb = devpriv->ao_urbs[i]; if (urb) { kfree(urb->transfer_buffer); usb_kill_urb(urb); usb_free_urb(urb); } } - kfree(devpriv->urb_out); + kfree(devpriv->ao_urbs); } - if (devpriv->urb_in) { - for (i = 0; i < devpriv->num_in_buffers; i++) { - urb = devpriv->urb_in[i]; + if (devpriv->ai_urbs) { + for (i = 0; i < devpriv->n_ai_urbs; i++) { + urb = devpriv->ai_urbs[i]; if (urb) { kfree(urb->transfer_buffer); usb_kill_urb(urb); usb_free_urb(urb); } } - kfree(devpriv->urb_in); + kfree(devpriv->ai_urbs); } kfree(devpriv->out_buffer); - kfree(devpriv->insn_buffer); - kfree(devpriv->in_buffer); + kfree(devpriv->insn_buf); + kfree(devpriv->in_buf); kfree(devpriv->dux_commands); kfree(devpriv->dac_commands); } @@ -1805,12 +1805,12 @@ static int usbdux_auto_attach(struct comedi_device *dev, devpriv->high_speed = (usb->speed == USB_SPEED_HIGH); if (devpriv->high_speed) { - devpriv->num_in_buffers = NUMOFINBUFFERSHIGH; - devpriv->num_out_buffers = NUMOFOUTBUFFERSHIGH; - devpriv->size_pwm_buf = 512; + devpriv->n_ai_urbs = NUMOFINBUFFERSHIGH; + devpriv->n_ao_urbs = NUMOFOUTBUFFERSHIGH; + devpriv->pwm_buf_sz = 512; } else { - devpriv->num_in_buffers = NUMOFINBUFFERSFULL; - devpriv->num_out_buffers = NUMOFOUTBUFFERSFULL; + devpriv->n_ai_urbs = NUMOFINBUFFERSFULL; + devpriv->n_ao_urbs = NUMOFOUTBUFFERSFULL; } ret = usbdux_alloc_usb_buffers(dev); @@ -1890,7 +1890,7 @@ static int usbdux_auto_attach(struct comedi_device *dev, s->type = COMEDI_SUBD_PWM; s->subdev_flags = SDF_WRITABLE | SDF_PWM_HBRIDGE; s->n_chan = 8; - s->maxdata = devpriv->size_pwm_buf; + s->maxdata = devpriv->pwm_buf_sz; s->insn_write = usbdux_pwm_write; s->insn_read = usbdux_pwm_read; s->insn_config = usbdux_pwm_config; -- GitLab From a998a3db530bff8094476e82e28c801b09f7aa9e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 25 Jul 2013 16:10:07 -0700 Subject: [PATCH 306/942] staging: comedi: usbdux: cleanup the private data 'outBuffer' This buffer is used to cache the values that are written to the analog output channels. Currently it only caches the single writes to the channels using the (*insn_write) callback. The async command writes are not cached. The buffer is also being kzalloc'ed during the attach of the driver to a size much larger that required. Rename the CamelCase buffer and change it to an array in the private data of the correct size to cache the analog output channel values. Modify the analog output urb callback so it updates the cached values with those used for the asynchronous command to allow readback after the command completes. The sanity check of the index to dac_commands[] (i.e. the 'chan' being written) is not needed. The chanlist_len will always be less than the number of channels. Also, fix the dev_err() message so it uses the proper device pointer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 49 +++++++++++-------------- 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index bd46bec73d7bb..1399305d739f7 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -99,6 +99,8 @@ sampling rate. If you sample two channels you get 4kHz and so on. #define VENDOR_DIR_OUT 0x40 #define USBDUX_CPU_CS 0xe600 +#define USBDUX_NUM_AO_CHAN 4 + /* timeout for the USB-transfer in ms */ #define BULK_TIMEOUT 1000 @@ -195,8 +197,8 @@ struct usbdux_private { int16_t *in_buf; /* input buffer for single insn */ int16_t *insn_buf; - /* output buffer for single DA outputs */ - int16_t *out_buffer; + + unsigned int ao_readback[USBDUX_NUM_AO_CHAN]; unsigned int high_speed:1; unsigned int ai_cmd_running:1; @@ -486,25 +488,24 @@ static void usbduxsub_ao_isoc_irq(struct urb *urb) ((uint8_t *) (urb->transfer_buffer))[0] = s->async->cmd.chanlist_len; for (i = 0; i < s->async->cmd.chanlist_len; i++) { - short temp; - if (i >= NUMOUTCHANNELS) - break; + unsigned int chan = devpriv->dac_commands[i]; + short val; + ret = comedi_buf_get(s->async, &val); + if (ret < 0) { + dev_err(dev->class_dev, "buffer underflow\n"); + s->async->events |= (COMEDI_CB_EOA | + COMEDI_CB_OVERFLOW); + } /* pointer to the DA */ datap = (&(((int8_t *) urb->transfer_buffer)[i * 3 + 1])); /* get the data from comedi */ - ret = comedi_buf_get(s->async, &temp); - datap[0] = temp; - datap[1] = temp >> 8; - datap[2] = devpriv->dac_commands[i]; - if (ret < 0) { - dev_err(&urb->dev->dev, - "comedi: buffer underflow\n"); - s->async->events |= COMEDI_CB_EOA; - s->async->events |= COMEDI_CB_OVERFLOW; - } - /* transmit data to comedi */ + datap[0] = val; + datap[1] = val >> 8; + datap[2] = chan; + devpriv->ao_readback[chan] = val; + s->async->events |= COMEDI_CB_BLOCK; comedi_event(dev, s); } @@ -907,7 +908,7 @@ static int usbdux_ao_insn_read(struct comedi_device *dev, down(&devpriv->sem); for (i = 0; i < insn->n; i++) - data[i] = devpriv->out_buffer[chan]; + data[i] = devpriv->ao_readback[chan]; up(&devpriv->sem); return insn->n; @@ -920,7 +921,7 @@ static int usbdux_ao_insn_write(struct comedi_device *dev, { struct usbdux_private *devpriv = dev->private; unsigned int chan = CR_CHAN(insn->chanspec); - unsigned int val = devpriv->out_buffer[chan]; + unsigned int val = devpriv->ao_readback[chan]; int16_t *p = (int16_t *)&devpriv->dux_commands[2]; int ret = -EBUSY; int i; @@ -945,7 +946,7 @@ static int usbdux_ao_insn_write(struct comedi_device *dev, if (ret < 0) goto ao_write_exit; } - devpriv->out_buffer[chan] = val; + devpriv->ao_readback[chan] = val; ao_write_exit: up(&devpriv->sem); @@ -1660,11 +1661,6 @@ static int usbdux_alloc_usb_buffers(struct comedi_device *dev) if (!devpriv->insn_buf) return -ENOMEM; - /* create space for the outbuffer */ - devpriv->out_buffer = kzalloc(SIZEOUTBUF, GFP_KERNEL); - if (!devpriv->out_buffer) - return -ENOMEM; - /* in urbs */ devpriv->ai_urbs = kcalloc(devpriv->n_ai_urbs, sizeof(*urb), GFP_KERNEL); @@ -1779,7 +1775,6 @@ static void usbdux_free_usb_buffers(struct usbdux_private *devpriv) } kfree(devpriv->ai_urbs); } - kfree(devpriv->out_buffer); kfree(devpriv->insn_buf); kfree(devpriv->in_buf); kfree(devpriv->dux_commands); @@ -1854,9 +1849,9 @@ static int usbdux_auto_attach(struct comedi_device *dev, dev->write_subdev = s; s->type = COMEDI_SUBD_AO; s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_CMD_WRITE; - s->n_chan = 4; + s->n_chan = USBDUX_NUM_AO_CHAN; s->maxdata = 0x0fff; - s->len_chanlist = 4; + s->len_chanlist = s->n_chan; s->range_table = &range_usbdux_ao_range; s->do_cmdtest = usbdux_ao_cmdtest; s->do_cmd = usbdux_ao_cmd; -- GitLab From c769f85e2740ebe7e4c726632fed52818640faba Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 25 Jul 2013 16:10:25 -0700 Subject: [PATCH 307/942] staging: comedi: usbdux: simplify initializing the ao urb transfer_buffer Remove the ugly casting of datap to the ao urb->transfer_buffer. The format of the data in the buffer is simply. [0] = # of channels to update (s->async->cmd.chanlist.len) [1] = lsb of value for 1st channel to update [2] = msb of value for 1st channel to update [3] = 1st channel to update (depvriv->dac_commands[0]) If more than 1 channel is to be updated they are simply added to the buffer: [4] = lsb of value for 2st channel to update [5] = msb of value for 2st channel to update [6] = 1st channel to update (depvriv->dac_commands[1]) etc. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 1399305d739f7..cb94964cc9bae 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -425,8 +425,10 @@ static void usbduxsub_ao_isoc_irq(struct urb *urb) struct comedi_device *dev = urb->context; struct comedi_subdevice *s = dev->write_subdev; struct usbdux_private *devpriv = dev->private; - int i, ret; int8_t *datap; + int len; + int ret; + int i; switch (urb->status) { case 0: @@ -484,9 +486,11 @@ static void usbduxsub_ao_isoc_irq(struct urb *urb) return; } } + /* transmit data to the USB bus */ - ((uint8_t *) (urb->transfer_buffer))[0] = - s->async->cmd.chanlist_len; + datap = urb->transfer_buffer; + len = s->async->cmd.chanlist_len; + *datap++ = len; for (i = 0; i < s->async->cmd.chanlist_len; i++) { unsigned int chan = devpriv->dac_commands[i]; short val; @@ -498,12 +502,9 @@ static void usbduxsub_ao_isoc_irq(struct urb *urb) COMEDI_CB_OVERFLOW); } /* pointer to the DA */ - datap = - (&(((int8_t *) urb->transfer_buffer)[i * 3 + 1])); - /* get the data from comedi */ - datap[0] = val; - datap[1] = val >> 8; - datap[2] = chan; + *datap++ = val & 0xff; + *datap++ = (val >> 8) & 0xff; + *datap++ = chan; devpriv->ao_readback[chan] = val; s->async->events |= COMEDI_CB_BLOCK; -- GitLab From b979e485b4b9ed7aff8a987f3638b3be5983268c Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 25 Jul 2013 16:10:43 -0700 Subject: [PATCH 308/942] staging: comedi: usbdux: remove unnecessary check in usbdux_ai_cmd() This check is not necessary. The cmd->chanlist_len will always be less than or equal to the subdevice len_chanlist that was setup during the attach of the device. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index cb94964cc9bae..3fc61d134acb5 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -110,9 +110,6 @@ sampling rate. If you sample two channels you get 4kHz and so on. /* Default PWM frequency */ #define PWM_DEFAULT_PERIOD ((long)(1E9/100)) -/* Number of channels */ -#define NUMCHANNELS 8 - /* Size of one A/D value */ #define SIZEADIN ((sizeof(int16_t))) @@ -784,9 +781,6 @@ static int usbdux_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) unsigned int chan = CR_CHAN(cmd->chanlist[i]); unsigned int range = CR_RANGE(cmd->chanlist[i]); - if (i >= NUMCHANNELS) - break; - devpriv->dux_commands[i + 2] = create_adc_command(chan, range); } -- GitLab From 66ce147c7d40b77704b44b6b2071d91f7c510b33 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 25 Jul 2013 16:11:10 -0700 Subject: [PATCH 309/942] staging: comedi: usbdux: remove unnecessary check in usbdux_ao_cmd() This check is not necessary. The cmd->chanlist_len will always be less than or equal to the subdevice len_chanlist that was setup during the attach of the device. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 3fc61d134acb5..80cfa80ba650b 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -1080,9 +1080,6 @@ static int usbdux_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) for (i = 0; i < cmd->chanlist_len; ++i) { unsigned int chan = CR_CHAN(cmd->chanlist[i]); - if (i >= NUMOUTCHANNELS) - break; - devpriv->dac_commands[i] = chan << 6; } -- GitLab From c5bbfe500be3c8f9f45d45b1ac644271761610a1 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 25 Jul 2013 16:11:28 -0700 Subject: [PATCH 310/942] staging: comedi: usbdux: 'dac_commands' does not need to be kzalloc()'d The 'dac_commands' buffer is used to pass the ao channel list from usbdux_ao_cmd() to the urb callback, usbduxsub_ao_isoc_irq(). This buffer does not need to be allocated. Change it into a simple array of the correct size. Rename the variable to 'ao_chanlist' to clarify what it actually is. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 80cfa80ba650b..9529324fbace8 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -195,6 +195,7 @@ struct usbdux_private { /* input buffer for single insn */ int16_t *insn_buf; + int8_t ao_chanlist[USBDUX_NUM_AO_CHAN]; unsigned int ao_readback[USBDUX_NUM_AO_CHAN]; unsigned int high_speed:1; @@ -215,8 +216,6 @@ struct usbdux_private { unsigned int ao_counter; /* interval in frames/uframes */ unsigned int ai_interval; - /* D/A commands */ - int8_t *dac_commands; /* commands */ int8_t *dux_commands; struct semaphore sem; @@ -489,7 +488,7 @@ static void usbduxsub_ao_isoc_irq(struct urb *urb) len = s->async->cmd.chanlist_len; *datap++ = len; for (i = 0; i < s->async->cmd.chanlist_len; i++) { - unsigned int chan = devpriv->dac_commands[i]; + unsigned int chan = devpriv->ao_chanlist[i]; short val; ret = comedi_buf_get(s->async, &val); @@ -1080,7 +1079,7 @@ static int usbdux_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) for (i = 0; i < cmd->chanlist_len; ++i) { unsigned int chan = CR_CHAN(cmd->chanlist[i]); - devpriv->dac_commands[i] = chan << 6; + devpriv->ao_chanlist[i] = chan << 6; } /* we count in steps of 1ms (125us) */ @@ -1633,11 +1632,6 @@ static int usbdux_alloc_usb_buffers(struct comedi_device *dev) struct urb *urb; int i; - /* create space for the commands of the DA converter */ - devpriv->dac_commands = kzalloc(NUMOUTCHANNELS, GFP_KERNEL); - if (!devpriv->dac_commands) - return -ENOMEM; - /* create space for the commands going to the usb device */ devpriv->dux_commands = kzalloc(SIZEOFDUXBUFFER, GFP_KERNEL); if (!devpriv->dux_commands) @@ -1770,7 +1764,6 @@ static void usbdux_free_usb_buffers(struct usbdux_private *devpriv) kfree(devpriv->insn_buf); kfree(devpriv->in_buf); kfree(devpriv->dux_commands); - kfree(devpriv->dac_commands); } static int usbdux_auto_attach(struct comedi_device *dev, -- GitLab From c2141c5b084781063d6f94680c46abcf2b5673c8 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 25 Jul 2013 16:11:46 -0700 Subject: [PATCH 311/942] staging: comedi: usbdux: remove unused define This define is not used, and it's actually incorrect. The usbdux device only has 4 analog output channels. Remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 9529324fbace8..0558613aa2c71 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -122,9 +122,6 @@ sampling rate. If you sample two channels you get 4kHz and so on. /* 16 bytes. */ #define SIZEINSNBUF 16 -/* Number of DA channels */ -#define NUMOUTCHANNELS 8 - /* size of one value for the D/A converter: channel and value */ #define SIZEDAOUT ((sizeof(int8_t)+sizeof(int16_t))) -- GitLab From 757fbc2a782276086088e4e6237fb66dac1f41a3 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 25 Jul 2013 16:12:05 -0700 Subject: [PATCH 312/942] staging: comedi: usbdux: move and rename the bulk transfer commands For aesthetic reasons, move the defines used for the bulk transfer commands out of the middle of the code and rename them so they are a bit more readable. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 45 ++++++++++++------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 0558613aa2c71..b94c655e374a2 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -99,6 +99,17 @@ sampling rate. If you sample two channels you get 4kHz and so on. #define VENDOR_DIR_OUT 0x40 #define USBDUX_CPU_CS 0xe600 +/* usbdux bulk transfer commands */ +#define USBDUX_CMD_MULT_AI 0 +#define USBDUX_CMD_AO 1 +#define USBDUX_CMD_DIO_CFG 2 +#define USBDUX_CMD_DIO_BITS 3 +#define USBDUX_CMD_SINGLE_AI 4 +#define USBDUX_CMD_TIMER_RD 5 +#define USBDUX_CMD_TIMER_WR 6 +#define USBDUX_CMD_PWM_ON 7 +#define USBDUX_CMD_PWM_OFF 8 + #define USBDUX_NUM_AO_CHAN 4 /* timeout for the USB-transfer in ms */ @@ -680,18 +691,6 @@ static int8_t create_adc_command(unsigned int chan, int range) return (chan << 4) | ((p == 1) << 2) | ((r == 1) << 3); } -/* bulk transfers to usbdux */ - -#define SENDADCOMMANDS 0 -#define SENDDACOMMANDS 1 -#define SENDDIOCONFIGCOMMAND 2 -#define SENDDIOBITSCOMMAND 3 -#define SENDSINGLEAD 4 -#define READCOUNTERCOMMAND 5 -#define WRITECOUNTERCOMMAND 6 -#define SENDPWMON 7 -#define SENDPWMOFF 8 - static int send_dux_commands(struct comedi_device *dev, int cmd_type) { struct usb_device *usb = comedi_to_usb_dev(dev); @@ -780,7 +779,7 @@ static int usbdux_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->dux_commands[i + 2] = create_adc_command(chan, range); } - ret = send_dux_commands(dev, SENDADCOMMANDS); + ret = send_dux_commands(dev, USBDUX_CMD_MULT_AI); if (ret < 0) goto ai_cmd_exit; @@ -864,12 +863,12 @@ static int usbdux_ai_insn_read(struct comedi_device *dev, devpriv->dux_commands[1] = create_adc_command(chan, range); /* adc commands */ - ret = send_dux_commands(dev, SENDSINGLEAD); + ret = send_dux_commands(dev, USBDUX_CMD_SINGLE_AI); if (ret < 0) goto ai_read_exit; for (i = 0; i < insn->n; i++) { - ret = receive_dux_commands(dev, SENDSINGLEAD); + ret = receive_dux_commands(dev, USBDUX_CMD_SINGLE_AI); if (ret < 0) goto ai_read_exit; @@ -933,7 +932,7 @@ static int usbdux_ao_insn_write(struct comedi_device *dev, /* one 16 bit value */ *p = cpu_to_le16(val); - ret = send_dux_commands(dev, SENDDACOMMANDS); + ret = send_dux_commands(dev, USBDUX_CMD_AO); if (ret < 0) goto ao_write_exit; } @@ -1192,10 +1191,10 @@ static int usbdux_dio_insn_bits(struct comedi_device *dev, * This command also tells the firmware to return * the digital input lines. */ - ret = send_dux_commands(dev, SENDDIOBITSCOMMAND); + ret = send_dux_commands(dev, USBDUX_CMD_DIO_BITS); if (ret < 0) goto dio_exit; - ret = receive_dux_commands(dev, SENDDIOBITSCOMMAND); + ret = receive_dux_commands(dev, USBDUX_CMD_DIO_BITS); if (ret < 0) goto dio_exit; @@ -1220,10 +1219,10 @@ static int usbdux_counter_read(struct comedi_device *dev, down(&devpriv->sem); for (i = 0; i < insn->n; i++) { - ret = send_dux_commands(dev, READCOUNTERCOMMAND); + ret = send_dux_commands(dev, USBDUX_CMD_TIMER_RD); if (ret < 0) goto counter_read_exit; - ret = receive_dux_commands(dev, READCOUNTERCOMMAND); + ret = receive_dux_commands(dev, USBDUX_CMD_TIMER_RD); if (ret < 0) goto counter_read_exit; @@ -1254,7 +1253,7 @@ static int usbdux_counter_write(struct comedi_device *dev, for (i = 0; i < insn->n; i++) { *p = cpu_to_le16(data[i]); - ret = send_dux_commands(dev, WRITECOUNTERCOMMAND); + ret = send_dux_commands(dev, USBDUX_CMD_TIMER_WR); if (ret < 0) break; } @@ -1298,7 +1297,7 @@ static int usbdux_pwm_cancel(struct comedi_device *dev, down(&devpriv->sem); /* unlink only if it is really running */ usbdux_pwm_stop(dev, devpriv->pwm_cmd_running); - ret = send_dux_commands(dev, SENDPWMOFF); + ret = send_dux_commands(dev, USBDUX_CMD_PWM_OFF); up(&devpriv->sem); return ret; @@ -1409,7 +1408,7 @@ static int usbdux_pwm_start(struct comedi_device *dev, goto pwm_start_exit; devpriv->dux_commands[1] = devpriv->pwm_delay; - ret = send_dux_commands(dev, SENDPWMON); + ret = send_dux_commands(dev, USBDUX_CMD_PWM_ON); if (ret < 0) goto pwm_start_exit; -- GitLab From 0c4349c91625188930f12382b061399827bf4da6 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Thu, 25 Jul 2013 16:12:30 -0700 Subject: [PATCH 313/942] staging: comedi: usbdux: consolidate usbduxsub_unlink_{in, out}urbs() These functions are identical other than the which and how many urbs are unlinked. Consolidate the functions into one usbdux_unlink_urbs() function. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 28 +++++++------------------ 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index b94c655e374a2..7ff731fd804a2 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -229,23 +229,20 @@ struct usbdux_private { struct semaphore sem; }; -static void usbduxsub_unlink_inurbs(struct comedi_device *dev) +static void usbdux_unlink_urbs(struct urb **urbs, int num_urbs) { - struct usbdux_private *devpriv = dev->private; int i; - if (devpriv->ai_urbs) { - for (i = 0; i < devpriv->n_ai_urbs; i++) - usb_kill_urb(devpriv->ai_urbs[i]); - } + for (i = 0; i < num_urbs; i++) + usb_kill_urb(urbs[i]); } static void usbdux_ai_stop(struct comedi_device *dev, int do_unlink) { struct usbdux_private *devpriv = dev->private; - if (do_unlink) - usbduxsub_unlink_inurbs(dev); + if (do_unlink && devpriv->ai_urbs) + usbdux_unlink_urbs(devpriv->ai_urbs, devpriv->n_ai_urbs); devpriv->ai_cmd_running = 0; } @@ -389,23 +386,12 @@ static void usbduxsub_ai_isoc_irq(struct urb *urb) comedi_event(dev, s); } -static void usbduxsub_unlink_outurbs(struct comedi_device *dev) -{ - struct usbdux_private *devpriv = dev->private; - int i; - - if (devpriv->ao_urbs) { - for (i = 0; i < devpriv->n_ao_urbs; i++) - usb_kill_urb(devpriv->ao_urbs[i]); - } -} - static void usbdux_ao_stop(struct comedi_device *dev, int do_unlink) { struct usbdux_private *devpriv = dev->private; - if (do_unlink) - usbduxsub_unlink_outurbs(dev); + if (do_unlink && devpriv->ao_urbs) + usbdux_unlink_urbs(devpriv->ao_urbs, devpriv->n_ao_urbs); devpriv->ao_cmd_running = 0; } -- GitLab From ca01583539b62729609e0ec8c21c813b75617a21 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 26 Jul 2013 15:37:54 -0700 Subject: [PATCH 314/942] staging: asus_oled: delete driver No one has the hardware for it anymore, and there has not been any development on it in a long time. If someone shows up with the hardware, and wants to clean it up, this can be easily reverted. Reported-by: Lidza Louina Cc: Jakub Schmidtke Signed-off-by: Greg Kroah-Hartman --- drivers/staging/Kconfig | 2 - drivers/staging/Makefile | 1 - drivers/staging/asus_oled/Kconfig | 6 - drivers/staging/asus_oled/Makefile | 1 - drivers/staging/asus_oled/README | 156 ----- drivers/staging/asus_oled/TODO | 10 - drivers/staging/asus_oled/asus_oled.c | 847 ------------------------- drivers/staging/asus_oled/linux.txt | 33 - drivers/staging/asus_oled/linux_f.txt | 18 - drivers/staging/asus_oled/linux_fr.txt | 33 - drivers/staging/asus_oled/tux.txt | 33 - drivers/staging/asus_oled/tux_r.txt | 33 - drivers/staging/asus_oled/tux_r2.txt | 33 - drivers/staging/asus_oled/zig.txt | 33 - 14 files changed, 1239 deletions(-) delete mode 100644 drivers/staging/asus_oled/Kconfig delete mode 100644 drivers/staging/asus_oled/Makefile delete mode 100644 drivers/staging/asus_oled/README delete mode 100644 drivers/staging/asus_oled/TODO delete mode 100644 drivers/staging/asus_oled/asus_oled.c delete mode 100644 drivers/staging/asus_oled/linux.txt delete mode 100644 drivers/staging/asus_oled/linux_f.txt delete mode 100644 drivers/staging/asus_oled/linux_fr.txt delete mode 100644 drivers/staging/asus_oled/tux.txt delete mode 100644 drivers/staging/asus_oled/tux_r.txt delete mode 100644 drivers/staging/asus_oled/tux_r2.txt delete mode 100644 drivers/staging/asus_oled/zig.txt diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index d036cd29bcd69..869c488cfb72d 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -40,8 +40,6 @@ source "drivers/staging/comedi/Kconfig" source "drivers/staging/olpc_dcon/Kconfig" -source "drivers/staging/asus_oled/Kconfig" - source "drivers/staging/panel/Kconfig" source "drivers/staging/rtl8187se/Kconfig" diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index 7fe578ea1708c..ca14ab70b7550 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -12,7 +12,6 @@ obj-$(CONFIG_PRISM2_USB) += wlan-ng/ obj-$(CONFIG_ECHO) += echo/ obj-$(CONFIG_COMEDI) += comedi/ obj-$(CONFIG_FB_OLPC_DCON) += olpc_dcon/ -obj-$(CONFIG_ASUS_OLED) += asus_oled/ obj-$(CONFIG_PANEL) += panel/ obj-$(CONFIG_R8187SE) += rtl8187se/ obj-$(CONFIG_RTL8192U) += rtl8192u/ diff --git a/drivers/staging/asus_oled/Kconfig b/drivers/staging/asus_oled/Kconfig deleted file mode 100644 index e56dbb25ac5d8..0000000000000 --- a/drivers/staging/asus_oled/Kconfig +++ /dev/null @@ -1,6 +0,0 @@ -config ASUS_OLED - tristate "Asus OLED driver" - depends on USB - default N - ---help--- - Enable support for the OLED display present in some Asus laptops. diff --git a/drivers/staging/asus_oled/Makefile b/drivers/staging/asus_oled/Makefile deleted file mode 100644 index e71f9aa9e0373..0000000000000 --- a/drivers/staging/asus_oled/Makefile +++ /dev/null @@ -1 +0,0 @@ -obj-$(CONFIG_ASUS_OLED) += asus_oled.o diff --git a/drivers/staging/asus_oled/README b/drivers/staging/asus_oled/README deleted file mode 100644 index 2d721232467a1..0000000000000 --- a/drivers/staging/asus_oled/README +++ /dev/null @@ -1,156 +0,0 @@ - - Driver for Asus OLED display present in some Asus laptops. - - The code of this driver is based on 'asusoled' program taken from - . I just wanted to have a simple - kernel driver for controlling this device, but I didn't know how - to do that. Now I know ;) Also, that program can not be used - with usbhid loaded, which means no USB mouse/keyboard while - controlling OLED display :( - - It has been tested on Asus G1 and didn't cause any problems, - but I don't guarantee that it won't do anything wrong :) - - It can (and probably does) have errors. It is usable - in my case, and I hope others will find it useful too! - -******* - -Building the module - - To build the module you need kernel 2.6 include files and some C compiler. - - Just run: - make - make install (as a root) - - It will build (hopefully) the module and install it in - /lib/modules/'uname -r'/extra/asus_oled.ko. - - To load it just use: - modprobe asus_oled - - You can check if it has detected your OLED display by looking into dmesg output. - There should be something like this: - asus-oled 2-7:1.0: Attached Asus OLED device - - If it doesn't find your display, you can try removing usbhid module. - If you add asus_oled into the list of modules loaded during system boot - before usbhid, it will work even when usbhid is present. - - If it still doesn't detect your hardware, check lsusb output. - There should be similar line: - Bus 002 Device 005: ID 0b05:1726 ASUSTek Computer, Inc. - - If you don't see any lines with '0b05:1726' it means that you have different - type of hardware that is not detected (it may or may not work, but the driver - knows only '0b05:1726' device). - -******* - -Configuration - - There is only one option: start_off. - You can use it by: 'modprobe asus_oled start_off=1', or by adding this - line to /etc/modprobe.d/asus_oled.conf: - options asus_oled start_off=1 - - With this option provided, asus_oled driver will switch off the display - when it is detected and attached. It is nice feature to just switch off the 'ASUS' - logo. If you don't use the display, it is probably the good idea to switch it off, - to protect OLEDs from "wearing off". - -******* - -Usage - - This module can be controlled with two special files: - /sys/class/asus_oled/oled_N/enabled - /sys/class/asus_oled/oled_N/picture - - (N is the device number, the first, and probably the only, has number 1, - so it is /sys/class/asus_oled/oled_1/enabled - and /sys/class/asus_oled/oled_1/picture) - - 'enabled' files is for reading and writing, 'picture' is writeable only. - - You can write 0 or 1 to 'enabled' file, which will switch - on and off the display. Reading from this file will tell you the last - status set, either 0 or 1. By default it is 1, so if the device was set to 'off', - and the computer was rebooted without power-off, this file will contain wrong - value - because the device is off, but hasn't been disabled this time and is - assumed to be on... - - To 'picture' file you write pictures to be displayed by the OLED device. - The format of the file: - - 00001110010111000 - 00010101010101010 - .... - - First line is a configuration parameter. Meaning of fields in : - M - picture mode. It can be either 's' for static pictures, - 'r' for rolling pictures, and 'f' for flashing pictures. - W - width of the picture. May be between 1 and 1792 - H - height of the picture. May be between 1 and 32 - - For example means static picture, 128 pixels long and 32 pixels high. - - The physical size of the display is 128x32 pixels. Static and flashing pictures - can't be larger than that (actually they can, but only part of them will be displayed ;) ) - - If the picture is smaller than 128x32 it will be centered. Rolling pictures wider than - 128 pixels will be centered too, unless their width = n*128. Vertically they will be - centered just like static pictures, if their height is smaller than 32. - - Flashing pictures will be centered horizontally if their width < 128, but they were - centered vertically in a different way. If their height < 16, they will be centered - in the upper half of the display (rows 0-15). This is because only the first half - of flashing pictures is used for flashing. When the picture with heigh = 32 is - displayed in flashing mode, its upper 16 rows will be flashing in the upper half - of the display, and the lower half will be empty. After few seconds upper part will - stop flashing (but that part of the picture will remain there), and the lower - half of the display will start displayin the lower half of the picture - in rolling mode, unless it is empty, or the picture was small enough to fit in - upper part. It is not mine idea, this is just the way Asus' display work ;) - So if you need just flashing, use at most 128x16 picture. If you need flashing and - rolling, use whole size of the display. - - Lines following the first, configuration, line are picture data. Each '1' means - that the pixel is lit, and '0' means that it is not. You can also use '#' as ON, - and ' ' (space) as OFF. Empty lines and all other characters are ignored. - - It is possible to write everything in one line 01010101010101010..., - and W*H characters will be used. If there is not enough characters, nothing will be - displayed. However, the 'line mode' is easier to read (and write), and it also - lets to omit parts of data. Whenever End-Of-Line character is found, but - the line is not W characters long, it is assumed that all missing characters - are equal to the last character in the line. - - Following line represents '0', '1' and a lots of '0's, dependng on the width of the picture - provided in configuration data: - 010 - - So if you need empty line, it is sufficient to write line with only one '0' in it. - The same works with '1' (or ' ' and '#'). - - If there are too many data in the file, they will be ignored. If you are not sure - how many characters you are missing, you can add few lines with one zero in each of them. - - There are some example pictures in .txt format, that can be used as follows: - cat foo.txt > /sys/class/asus_oled/oled_1/picture - - If the display is switched off you also need to run: - echo 1 > /sys/class/asus_oled/oled_1/enabled - To switch it off, just use: - echo 0 > /sys/class/asus_oled/oled_1/enabled - - -******* - - For any additional info please have a look at http://lapsus.berlios.de/asus_oled.html - - - - Jakub Schmidtke (sjakub@gmail.com) - diff --git a/drivers/staging/asus_oled/TODO b/drivers/staging/asus_oled/TODO deleted file mode 100644 index 2514131670a3e..0000000000000 --- a/drivers/staging/asus_oled/TODO +++ /dev/null @@ -1,10 +0,0 @@ -TODO: - - checkpatch.pl cleanups - - sparse fixes - - audit the userspace interface - - sysfs vs. char? - - Documentation/ABI/ needs to be added - - put the sample .txt files and README file somewhere. - -Please send patches to Greg Kroah-Hartman and -Cc: Jakub Schmidtke diff --git a/drivers/staging/asus_oled/asus_oled.c b/drivers/staging/asus_oled/asus_oled.c deleted file mode 100644 index 3654dc32a0c6c..0000000000000 --- a/drivers/staging/asus_oled/asus_oled.c +++ /dev/null @@ -1,847 +0,0 @@ -/* - * Asus OLED USB driver - * - * Copyright (C) 2007,2008 Jakub Schmidtke (sjakub@gmail.com) - * - * 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 the License, or - * (at your option) any later version. - * - * 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. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * - * - * This module is based on usbled and asus-laptop modules. - * - * - * Asus OLED support is based on asusoled program taken from - * . - * - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#define ASUS_OLED_VERSION "0.04-dev" -#define ASUS_OLED_NAME "asus-oled" -#define ASUS_OLED_UNDERSCORE_NAME "asus_oled" - -#define ASUS_OLED_STATIC 's' -#define ASUS_OLED_ROLL 'r' -#define ASUS_OLED_FLASH 'f' - -#define ASUS_OLED_MAX_WIDTH 1792 -#define ASUS_OLED_DISP_HEIGHT 32 -#define ASUS_OLED_PACKET_BUF_SIZE 256 - -#define USB_VENDOR_ID_ASUS 0x0b05 -#define USB_DEVICE_ID_ASUS_LCM 0x1726 -#define USB_DEVICE_ID_ASUS_LCM2 0x175b - -MODULE_AUTHOR("Jakub Schmidtke, sjakub@gmail.com"); -MODULE_DESCRIPTION("Asus OLED Driver"); -MODULE_LICENSE("GPL"); -MODULE_VERSION(ASUS_OLED_VERSION); - -static struct class *oled_class; -static int oled_num; - -static uint start_off; - -module_param(start_off, uint, 0644); - -MODULE_PARM_DESC(start_off, - "Set to 1 to switch off OLED display after it is attached"); - -enum oled_pack_mode { - PACK_MODE_G1, - PACK_MODE_G50, - PACK_MODE_LAST -}; - -struct oled_dev_desc_str { - uint16_t idVendor; - uint16_t idProduct; - /* width of display */ - uint16_t devWidth; - /* formula to be used while packing the picture */ - enum oled_pack_mode packMode; - const char *devDesc; -}; - -/* table of devices that work with this driver */ -static const struct usb_device_id id_table[] = { - /* Asus G1/G2 (and variants)*/ - { USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_LCM) }, - /* Asus G50V (and possibly others - G70? G71?)*/ - { USB_DEVICE(USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_LCM2) }, - { }, -}; - -/* parameters of specific devices */ -static struct oled_dev_desc_str oled_dev_desc_table[] = { - { USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_LCM, 128, PACK_MODE_G1, - "G1/G2" }, - { USB_VENDOR_ID_ASUS, USB_DEVICE_ID_ASUS_LCM2, 256, PACK_MODE_G50, - "G50" }, - { }, -}; - -MODULE_DEVICE_TABLE(usb, id_table); - -struct asus_oled_header { - uint8_t magic1; - uint8_t magic2; - uint8_t flags; - uint8_t value3; - uint8_t buffer1; - uint8_t buffer2; - uint8_t value6; - uint8_t value7; - uint8_t value8; - uint8_t padding2[7]; -} __attribute((packed)); - -struct asus_oled_packet { - struct asus_oled_header header; - uint8_t bitmap[ASUS_OLED_PACKET_BUF_SIZE]; -} __attribute((packed)); - -struct asus_oled_dev { - struct usb_device *udev; - uint8_t pic_mode; - uint16_t dev_width; - enum oled_pack_mode pack_mode; - size_t height; - size_t width; - size_t x_shift; - size_t y_shift; - size_t buf_offs; - uint8_t last_val; - size_t buf_size; - char *buf; - uint8_t enabled; - uint8_t enabled_post_resume; - struct device *dev; -}; - -static void setup_packet_header(struct asus_oled_packet *packet, char flags, - char value3, char buffer1, char buffer2, char value6, - char value7, char value8) -{ - memset(packet, 0, sizeof(struct asus_oled_header)); - packet->header.magic1 = 0x55; - packet->header.magic2 = 0xaa; - packet->header.flags = flags; - packet->header.value3 = value3; - packet->header.buffer1 = buffer1; - packet->header.buffer2 = buffer2; - packet->header.value6 = value6; - packet->header.value7 = value7; - packet->header.value8 = value8; -} - -static void enable_oled(struct asus_oled_dev *odev, uint8_t enabl) -{ - int retval; - int act_len; - struct asus_oled_packet *packet; - - packet = kzalloc(sizeof(struct asus_oled_packet), GFP_KERNEL); - if (!packet) - return; - - setup_packet_header(packet, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00); - - if (enabl) - packet->bitmap[0] = 0xaf; - else - packet->bitmap[0] = 0xae; - - retval = usb_bulk_msg(odev->udev, - usb_sndbulkpipe(odev->udev, 2), - packet, - sizeof(struct asus_oled_header) + 1, - &act_len, - -1); - - if (retval) - dev_dbg(&odev->udev->dev, "retval = %d\n", retval); - - odev->enabled = enabl; - - kfree(packet); -} - -static ssize_t set_enabled(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) -{ - struct usb_interface *intf = to_usb_interface(dev); - struct asus_oled_dev *odev = usb_get_intfdata(intf); - unsigned long value; - if (kstrtoul(buf, 10, &value)) - return -EINVAL; - - enable_oled(odev, value); - - return count; -} - -static ssize_t class_set_enabled(struct device *device, - struct device_attribute *attr, - const char *buf, size_t count) -{ - struct asus_oled_dev *odev = - (struct asus_oled_dev *) dev_get_drvdata(device); - unsigned long value; - - if (kstrtoul(buf, 10, &value)) - return -EINVAL; - - enable_oled(odev, value); - - return count; -} - -static ssize_t get_enabled(struct device *dev, struct device_attribute *attr, - char *buf) -{ - struct usb_interface *intf = to_usb_interface(dev); - struct asus_oled_dev *odev = usb_get_intfdata(intf); - - return sprintf(buf, "%d\n", odev->enabled); -} - -static ssize_t class_get_enabled(struct device *device, - struct device_attribute *attr, char *buf) -{ - struct asus_oled_dev *odev = - (struct asus_oled_dev *) dev_get_drvdata(device); - - return sprintf(buf, "%d\n", odev->enabled); -} - -static void send_packets(struct usb_device *udev, - struct asus_oled_packet *packet, - char *buf, uint8_t p_type, size_t p_num) -{ - size_t i; - int act_len; - - for (i = 0; i < p_num; i++) { - int retval; - - switch (p_type) { - case ASUS_OLED_ROLL: - setup_packet_header(packet, 0x40, 0x80, p_num, - i + 1, 0x00, 0x01, 0xff); - break; - case ASUS_OLED_STATIC: - setup_packet_header(packet, 0x10 + i, 0x80, 0x01, - 0x01, 0x00, 0x01, 0x00); - break; - case ASUS_OLED_FLASH: - setup_packet_header(packet, 0x10 + i, 0x80, 0x01, - 0x01, 0x00, 0x00, 0xff); - break; - } - - memcpy(packet->bitmap, buf + (ASUS_OLED_PACKET_BUF_SIZE*i), - ASUS_OLED_PACKET_BUF_SIZE); - - retval = usb_bulk_msg(udev, usb_sndctrlpipe(udev, 2), - packet, sizeof(struct asus_oled_packet), - &act_len, -1); - - if (retval) - dev_dbg(&udev->dev, "retval = %d\n", retval); - } -} - -static void send_packet(struct usb_device *udev, - struct asus_oled_packet *packet, - size_t offset, size_t len, char *buf, uint8_t b1, - uint8_t b2, uint8_t b3, uint8_t b4, uint8_t b5, - uint8_t b6) { - int retval; - int act_len; - - setup_packet_header(packet, b1, b2, b3, b4, b5, b6, 0x00); - memcpy(packet->bitmap, buf + offset, len); - - retval = usb_bulk_msg(udev, - usb_sndctrlpipe(udev, 2), - packet, - sizeof(struct asus_oled_packet), - &act_len, - -1); - - if (retval) - dev_dbg(&udev->dev, "retval = %d\n", retval); -} - - -static void send_packets_g50(struct usb_device *udev, - struct asus_oled_packet *packet, char *buf) -{ - send_packet(udev, packet, 0, 0x100, buf, - 0x10, 0x00, 0x02, 0x01, 0x00, 0x01); - send_packet(udev, packet, 0x100, 0x080, buf, - 0x10, 0x00, 0x02, 0x02, 0x80, 0x00); - - send_packet(udev, packet, 0x180, 0x100, buf, - 0x11, 0x00, 0x03, 0x01, 0x00, 0x01); - send_packet(udev, packet, 0x280, 0x100, buf, - 0x11, 0x00, 0x03, 0x02, 0x00, 0x01); - send_packet(udev, packet, 0x380, 0x080, buf, - 0x11, 0x00, 0x03, 0x03, 0x80, 0x00); -} - - -static void send_data(struct asus_oled_dev *odev) -{ - size_t packet_num = odev->buf_size / ASUS_OLED_PACKET_BUF_SIZE; - struct asus_oled_packet *packet; - - packet = kzalloc(sizeof(struct asus_oled_packet), GFP_KERNEL); - if (!packet) - return; - - if (odev->pack_mode == PACK_MODE_G1) { - /* - * When sending roll-mode data the display updated only - * first packet. I have no idea why, but when static picture - * is sent just before rolling picture everything works fine. - */ - if (odev->pic_mode == ASUS_OLED_ROLL) - send_packets(odev->udev, packet, odev->buf, - ASUS_OLED_STATIC, 2); - - /* Only ROLL mode can use more than 2 packets.*/ - if (odev->pic_mode != ASUS_OLED_ROLL && packet_num > 2) - packet_num = 2; - - send_packets(odev->udev, packet, odev->buf, - odev->pic_mode, packet_num); - } else if (odev->pack_mode == PACK_MODE_G50) { - send_packets_g50(odev->udev, packet, odev->buf); - } - - kfree(packet); -} - -static int append_values(struct asus_oled_dev *odev, uint8_t val, size_t count) -{ - odev->last_val = val; - - if (val == 0) { - odev->buf_offs += count; - return 0; - } - - while (count-- > 0) { - size_t x = odev->buf_offs % odev->width; - size_t y = odev->buf_offs / odev->width; - size_t i; - - x += odev->x_shift; - y += odev->y_shift; - - switch (odev->pack_mode) { - case PACK_MODE_G1: - /* - * i = (x/128)*640 + 127 - x + (y/8)*128; - * This one for 128 is the same, but might be better - * for different widths? - */ - i = (x/odev->dev_width)*640 + - odev->dev_width - 1 - x + - (y/8)*odev->dev_width; - break; - - case PACK_MODE_G50: - i = (odev->dev_width - 1 - x)/8 + y*odev->dev_width/8; - break; - - default: - i = 0; - dev_err(odev->dev, "Unknown OLED Pack Mode: %d!\n", - odev->pack_mode); - break; - } - - if (i >= odev->buf_size) { - dev_err(odev->dev, "Buffer overflow! Report a bug: offs: %zu >= %zu i: %zu (x: %zu y: %zu)\n", - odev->buf_offs, odev->buf_size, i, x, y); - return -EIO; - } - - switch (odev->pack_mode) { - case PACK_MODE_G1: - odev->buf[i] &= ~(1<<(y%8)); - break; - - case PACK_MODE_G50: - odev->buf[i] &= ~(1<<(x%8)); - break; - - default: - /* cannot get here; stops gcc complaining*/ - break; - } - - odev->buf_offs++; - } - - return 0; -} - -static ssize_t odev_set_picture(struct asus_oled_dev *odev, - const char *buf, size_t count) -{ - size_t offs = 0, max_offs; - - if (count < 1) - return 0; - - if (tolower(buf[0]) == 'b') { - /* binary mode, set the entire memory*/ - - size_t i; - - odev->buf_size = (odev->dev_width * ASUS_OLED_DISP_HEIGHT) / 8; - - kfree(odev->buf); - odev->buf = kmalloc(odev->buf_size, GFP_KERNEL); - if (odev->buf == NULL) { - odev->buf_size = 0; - dev_err(odev->dev, "Out of memory!\n"); - return -ENOMEM; - } - - memset(odev->buf, 0xff, odev->buf_size); - - for (i = 1; i < count && i <= 32 * 32; i++) { - odev->buf[i-1] = buf[i]; - odev->buf_offs = i-1; - } - - odev->width = odev->dev_width / 8; - odev->height = ASUS_OLED_DISP_HEIGHT; - odev->x_shift = 0; - odev->y_shift = 0; - odev->last_val = 0; - - send_data(odev); - - return count; - } - - if (buf[0] == '<') { - size_t i; - size_t w = 0, h = 0; - size_t w_mem, h_mem; - - if (count < 10 || buf[2] != ':') - goto error_header; - - - switch (tolower(buf[1])) { - case ASUS_OLED_STATIC: - case ASUS_OLED_ROLL: - case ASUS_OLED_FLASH: - odev->pic_mode = buf[1]; - break; - default: - dev_err(odev->dev, "Wrong picture mode: '%c'.\n", - buf[1]); - return -EIO; - break; - } - - for (i = 3; i < count; ++i) { - if (buf[i] >= '0' && buf[i] <= '9') { - w = 10*w + (buf[i] - '0'); - - if (w > ASUS_OLED_MAX_WIDTH) - goto error_width; - } else if (tolower(buf[i]) == 'x') { - break; - } else { - goto error_width; - } - } - - for (++i; i < count; ++i) { - if (buf[i] >= '0' && buf[i] <= '9') { - h = 10*h + (buf[i] - '0'); - - if (h > ASUS_OLED_DISP_HEIGHT) - goto error_height; - } else if (tolower(buf[i]) == '>') { - break; - } else { - goto error_height; - } - } - - if (w < 1 || w > ASUS_OLED_MAX_WIDTH) - goto error_width; - - if (h < 1 || h > ASUS_OLED_DISP_HEIGHT) - goto error_height; - - if (i >= count || buf[i] != '>') - goto error_header; - - offs = i+1; - - if (w % (odev->dev_width) != 0) - w_mem = (w/(odev->dev_width) + 1)*(odev->dev_width); - else - w_mem = w; - - if (h < ASUS_OLED_DISP_HEIGHT) - h_mem = ASUS_OLED_DISP_HEIGHT; - else - h_mem = h; - - odev->buf_size = w_mem * h_mem / 8; - - kfree(odev->buf); - odev->buf = kmalloc(odev->buf_size, GFP_KERNEL); - - if (odev->buf == NULL) { - odev->buf_size = 0; - dev_err(odev->dev, "Out of memory!\n"); - return -ENOMEM; - } - - memset(odev->buf, 0xff, odev->buf_size); - - odev->buf_offs = 0; - odev->width = w; - odev->height = h; - odev->x_shift = 0; - odev->y_shift = 0; - odev->last_val = 0; - - if (odev->pic_mode == ASUS_OLED_FLASH) { - if (h < ASUS_OLED_DISP_HEIGHT/2) - odev->y_shift = (ASUS_OLED_DISP_HEIGHT/2 - h)/2; - } else { - if (h < ASUS_OLED_DISP_HEIGHT) - odev->y_shift = (ASUS_OLED_DISP_HEIGHT - h)/2; - } - - if (w < (odev->dev_width)) - odev->x_shift = ((odev->dev_width) - w)/2; - } - - max_offs = odev->width * odev->height; - - while (offs < count && odev->buf_offs < max_offs) { - int ret = 0; - - if (buf[offs] == '1' || buf[offs] == '#') { - ret = append_values(odev, 1, 1); - if (ret < 0) - return ret; - } else if (buf[offs] == '0' || buf[offs] == ' ') { - ret = append_values(odev, 0, 1); - if (ret < 0) - return ret; - } else if (buf[offs] == '\n') { - /* - * New line detected. Lets assume, that all characters - * till the end of the line were equal to the last - * character in this line. - */ - if (odev->buf_offs % odev->width != 0) - ret = append_values(odev, odev->last_val, - odev->width - - (odev->buf_offs % - odev->width)); - if (ret < 0) - return ret; - } - - offs++; - } - - if (odev->buf_offs >= max_offs) - send_data(odev); - - return count; - -error_width: - dev_err(odev->dev, "Wrong picture width specified.\n"); - return -EIO; - -error_height: - dev_err(odev->dev, "Wrong picture height specified.\n"); - return -EIO; - -error_header: - dev_err(odev->dev, "Wrong picture header.\n"); - return -EIO; -} - -static ssize_t set_picture(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) -{ - struct usb_interface *intf = to_usb_interface(dev); - - return odev_set_picture(usb_get_intfdata(intf), buf, count); -} - -static ssize_t class_set_picture(struct device *device, - struct device_attribute *attr, - const char *buf, size_t count) -{ - return odev_set_picture((struct asus_oled_dev *) - dev_get_drvdata(device), buf, count); -} - -#define ASUS_OLED_DEVICE_ATTR(_file) dev_attr_asus_oled_##_file - -static DEVICE_ATTR(asus_oled_enabled, S_IWUSR | S_IRUGO, - get_enabled, set_enabled); -static DEVICE_ATTR(asus_oled_picture, S_IWUSR , NULL, set_picture); - -static DEVICE_ATTR(enabled, S_IWUSR | S_IRUGO, - class_get_enabled, class_set_enabled); -static DEVICE_ATTR(picture, S_IWUSR, NULL, class_set_picture); - -static int asus_oled_probe(struct usb_interface *interface, - const struct usb_device_id *id) -{ - struct usb_device *udev = interface_to_usbdev(interface); - struct asus_oled_dev *odev = NULL; - int retval = -ENOMEM; - uint16_t dev_width = 0; - enum oled_pack_mode pack_mode = PACK_MODE_LAST; - const struct oled_dev_desc_str *dev_desc = oled_dev_desc_table; - const char *desc = NULL; - - if (!id) { - /* Even possible? Just to make sure...*/ - dev_err(&interface->dev, "No usb_device_id provided!\n"); - return -ENODEV; - } - - for (; dev_desc->idVendor; dev_desc++) { - if (dev_desc->idVendor == id->idVendor - && dev_desc->idProduct == id->idProduct) { - dev_width = dev_desc->devWidth; - desc = dev_desc->devDesc; - pack_mode = dev_desc->packMode; - break; - } - } - - if (!desc || dev_width < 1 || pack_mode == PACK_MODE_LAST) { - dev_err(&interface->dev, - "Missing or incomplete device description!\n"); - return -ENODEV; - } - - odev = kzalloc(sizeof(struct asus_oled_dev), GFP_KERNEL); - if (odev == NULL) - return -ENOMEM; - - odev->udev = usb_get_dev(udev); - odev->pic_mode = ASUS_OLED_STATIC; - odev->dev_width = dev_width; - odev->pack_mode = pack_mode; - odev->height = 0; - odev->width = 0; - odev->x_shift = 0; - odev->y_shift = 0; - odev->buf_offs = 0; - odev->buf_size = 0; - odev->last_val = 0; - odev->buf = NULL; - odev->enabled = 1; - odev->dev = NULL; - - usb_set_intfdata(interface, odev); - - retval = device_create_file(&interface->dev, - &ASUS_OLED_DEVICE_ATTR(enabled)); - if (retval) - goto err_files; - - retval = device_create_file(&interface->dev, - &ASUS_OLED_DEVICE_ATTR(picture)); - if (retval) - goto err_files; - - odev->dev = device_create(oled_class, &interface->dev, MKDEV(0, 0), - NULL, "oled_%d", ++oled_num); - - if (IS_ERR(odev->dev)) { - retval = PTR_ERR(odev->dev); - goto err_files; - } - - dev_set_drvdata(odev->dev, odev); - - retval = device_create_file(odev->dev, &dev_attr_enabled); - if (retval) - goto err_class_enabled; - - retval = device_create_file(odev->dev, &dev_attr_picture); - if (retval) - goto err_class_picture; - - dev_info(&interface->dev, - "Attached Asus OLED device: %s [width %u, pack_mode %d]\n", - desc, odev->dev_width, odev->pack_mode); - - if (start_off) - enable_oled(odev, 0); - - return 0; - -err_class_picture: - device_remove_file(odev->dev, &dev_attr_picture); - -err_class_enabled: - device_remove_file(odev->dev, &dev_attr_enabled); - device_unregister(odev->dev); - -err_files: - device_remove_file(&interface->dev, &ASUS_OLED_DEVICE_ATTR(enabled)); - device_remove_file(&interface->dev, &ASUS_OLED_DEVICE_ATTR(picture)); - - usb_set_intfdata(interface, NULL); - usb_put_dev(odev->udev); - kfree(odev); - - return retval; -} - -static void asus_oled_disconnect(struct usb_interface *interface) -{ - struct asus_oled_dev *odev; - - odev = usb_get_intfdata(interface); - usb_set_intfdata(interface, NULL); - - device_remove_file(odev->dev, &dev_attr_picture); - device_remove_file(odev->dev, &dev_attr_enabled); - device_unregister(odev->dev); - - device_remove_file(&interface->dev, &ASUS_OLED_DEVICE_ATTR(picture)); - device_remove_file(&interface->dev, &ASUS_OLED_DEVICE_ATTR(enabled)); - - usb_put_dev(odev->udev); - - kfree(odev->buf); - - kfree(odev); - - dev_info(&interface->dev, "Disconnected Asus OLED device\n"); -} - -#ifdef CONFIG_PM -static int asus_oled_suspend(struct usb_interface *intf, pm_message_t message) -{ - struct asus_oled_dev *odev; - - odev = usb_get_intfdata(intf); - if (!odev) - return -ENODEV; - - odev->enabled_post_resume = odev->enabled; - enable_oled(odev, 0); - - return 0; -} - -static int asus_oled_resume(struct usb_interface *intf) -{ - struct asus_oled_dev *odev; - - odev = usb_get_intfdata(intf); - if (!odev) - return -ENODEV; - - enable_oled(odev, odev->enabled_post_resume); - - return 0; -} -#else -#define asus_oled_suspend NULL -#define asus_oled_resume NULL -#endif - -static struct usb_driver oled_driver = { - .name = ASUS_OLED_NAME, - .probe = asus_oled_probe, - .disconnect = asus_oled_disconnect, - .id_table = id_table, - .suspend = asus_oled_suspend, - .resume = asus_oled_resume, -}; - -static CLASS_ATTR_STRING(version, S_IRUGO, - ASUS_OLED_UNDERSCORE_NAME " " ASUS_OLED_VERSION); - -static int __init asus_oled_init(void) -{ - int retval = 0; - oled_class = class_create(THIS_MODULE, ASUS_OLED_UNDERSCORE_NAME); - - if (IS_ERR(oled_class)) { - pr_err("Error creating " ASUS_OLED_UNDERSCORE_NAME " class\n"); - return PTR_ERR(oled_class); - } - - retval = class_create_file(oled_class, &class_attr_version.attr); - if (retval) { - pr_err("Error creating class version file\n"); - goto error; - } - - retval = usb_register(&oled_driver); - - if (retval) { - pr_err("usb_register failed. Error number %d\n", retval); - goto error; - } - - return retval; - -error: - class_destroy(oled_class); - return retval; -} - -static void __exit asus_oled_exit(void) -{ - usb_deregister(&oled_driver); - class_remove_file(oled_class, &class_attr_version.attr); - class_destroy(oled_class); -} - -module_init(asus_oled_init); -module_exit(asus_oled_exit); - diff --git a/drivers/staging/asus_oled/linux.txt b/drivers/staging/asus_oled/linux.txt deleted file mode 100644 index dc758b0eb3799..0000000000000 --- a/drivers/staging/asus_oled/linux.txt +++ /dev/null @@ -1,33 +0,0 @@ - -0 -0 -00000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000 -01111111111000000000000000000000000000000000000000000000000000000000000000 -00011111100000000000000111000000000000000000000000000000000000000000000000 -00001111000000000000000111000000000000000000000000000000000000000000000000 -00001111000000000000000111000000000000000000000000000000000000000000000000 -00001111000000000000000000000000000000000000000000000000000000000000000000 -00001111000000000000000000000000000000000000000000000000000000000000000000 -00001111000000000000011100001111111111100000111110011111100011111101111000 -00001111000000000000111110000011111000111000111110000111100001111000110000 -00001111000000000001101110000011111000111000001111000111100000111100100000 -00001111000000000001001110000011110000111100001111000111100000111101100000 -00001111000000000100001110000011110000111100001111000111100000011111000000 -00001111000000000100011110000011110000111100001111000111100000001111000000 -00001111000000000100011110000011110000111100001111000111100000001111000000 -00001111000000000100011100100011110000111100001111000111100000001111100000 -00001111000000001100111100100011110000111100001111000111100000001111110000 -00001111000000001100111101100011110000111100001111000111100000011011110000 -00001111000000011100111101000011110000111100001111000111100000010001111000 -00011111000001111100111011000011110000111100001111001111100000110000111100 -11111111111111111100011110001111111011111110000111110111111011111011111110 -00000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000 -0 -0 -0 -0 diff --git a/drivers/staging/asus_oled/linux_f.txt b/drivers/staging/asus_oled/linux_f.txt deleted file mode 100644 index b4bb85cc6ebb9..0000000000000 --- a/drivers/staging/asus_oled/linux_f.txt +++ /dev/null @@ -1,18 +0,0 @@ - -00000000000000000000000000000000001111111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000011110000000000001110000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000011110000000000001110000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000011110000000000011000111111111100001111001111100111110111000000000000000000000000000000000000 -00000000000000000000000000000000000011110000000000111100001111000110001111000111100011100010000000000000000000000000000000000000 -00000000000000000000000000000000000011110000000001011100001111000111000111100111100001110110000000000000000000000000000000000000 -00000000000000000000000000000000000011110000000000011100001110000111000111100111100001111100000000000000000000000000000000000000 -00000000000000000000000000000000000011110000000100011100001110000111000111100111100000111100000000000000000000000000000000000000 -00000000000000000000000000000000000011110000000100011100001110000111000111100111100000111100000000000000000000000000000000000000 -00000000000000000000000000000000000011110000000100111001001110000111000111100111100000111110000000000000000000000000000000000000 -00000000000000000000000000000000000011110000001100111011001110000111000111100111100000111110000000000000000000000000000000000000 -00000000000000000000000000000000000011110000001100111010001110000111000111100111100000100111000000000000000000000000000000000000 -00000000000000000000000000000000000011110000111100110110001110000111000111100111100001000011100000000000000000000000000000000000 -00000000000000000000000000000000001111111111111100111100111111011111100011110111110111101111110000000000000000000000000000000000 - diff --git a/drivers/staging/asus_oled/linux_fr.txt b/drivers/staging/asus_oled/linux_fr.txt deleted file mode 100644 index f88e2b3bdd1b1..0000000000000 --- a/drivers/staging/asus_oled/linux_fr.txt +++ /dev/null @@ -1,33 +0,0 @@ - -00000000000000000000000000000000001111111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000011110000000000001110000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000011110000000000001110000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000011110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000011110000000000011000111111111100001111001111100111110111000000000000000000000000000000000000 -00000000000000000000000000000000000011110000000000111100001111000110001111000111100011100010000000000000000000000000000000000000 -00000000000000000000000000000000000011110000000001011100001111000111000111100111100001110110000000000000000000000000000000000000 -00000000000000000000000000000000000011110000000000011100001110000111000111100111100001111100000000000000000000000000000000000000 -00000000000000000000000000000000000011110000000100011100001110000111000111100111100000111100000000000000000000000000000000000000 -00000000000000000000000000000000000011110000000100011100001110000111000111100111100000111100000000000000000000000000000000000000 -00000000000000000000000000000000000011110000000100111001001110000111000111100111100000111110000000000000000000000000000000000000 -00000000000000000000000000000000000011110000001100111011001110000111000111100111100000111110000000000000000000000000000000000000 -00000000000000000000000000000000000011110000001100111010001110000111000111100111100000100111000000000000000000000000000000000000 -00000000000000000000000000000000000011110000111100110110001110000111000111100111100001000011100000000000000000000000000000000000 -00000000000000000000000000000000001111111111111100111100111111011111100011110111110111101111110000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000110000000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000000 -00000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000 -00000000000000000000000000011111100000000000000000000000000000000000000000000000000000000000011111100000000000000000000000000000 -00000000000000000000000000011111100000000000000000000000000000000000000000000000000000000000011111100000000000000000000000000000 -00000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000 -00000000000000000000000000000110000000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 diff --git a/drivers/staging/asus_oled/tux.txt b/drivers/staging/asus_oled/tux.txt deleted file mode 100644 index 9d2052854b642..0000000000000 --- a/drivers/staging/asus_oled/tux.txt +++ /dev/null @@ -1,33 +0,0 @@ - -00000000000001111111000000000000 -0000000000001 100000000000 -000000000001 10000000000 -000000000001 10000000000 -000000000001 10000000000 -000000000001 1 111 10000000000 -000000000001 1 1 1000000000 -000000000001 111 1000000000 -000000000001 111111 1000000000 -000000000001 111111 1000000000 -000000000001 1 1 100000000 -00000000001 11 100000000 -00000000001 11111111 10000000 -0000000001 11111111 1000000 -000000001 111111111 1000000 -000000001 1111111111 100000 -00000001 11111111111 100000 -00000001 111111111111 10000 -0000001 111111111111 10000 -0000001 111111111111 10000 -0000001 111111111111 10000 -0000001 111111111111 10000 -000000011 11111111111 10000 -000011 11 11111111111 100000 -0001 1111 111111111111111 1000 -001 1111111 11111111111111 1000 -001 1111111 1111111 111111 100 -001 11111111 111111 1111111 10 -001 11111111 11111 100 -001 1111111 111 11100 -000111 111 11111 11 100000 -000000111 111111111 1000000 diff --git a/drivers/staging/asus_oled/tux_r.txt b/drivers/staging/asus_oled/tux_r.txt deleted file mode 100644 index fd81a3e849492..0000000000000 --- a/drivers/staging/asus_oled/tux_r.txt +++ /dev/null @@ -1,33 +0,0 @@ - -00000000000001111111000000000000 -0000000000001 100000000000 -000000000001 10000000000 -000000000001 10000000000 -000000000001 10000000000 -000000000001 1 111 10000000000 -000000000001 1 1 1000000000 -000000000001 111 1000000000 -000000000001 111111 1000000000 -000000000001 111111 1000000000 -000000000001 1 1 100000000 -00000000001 11 100000000 -00000000001 11111111 10000000 -0000000001 11111111 1000000 -000000001 111111111 1000000 -000000001 1111111111 100000 -00000001 11111111111 100000 -00000001 111111111111 10000 -0000001 111111111111 10000 -0000001 111111111111 10000 -0000001 111111111111 10000 -0000001 111111111111 10000 -000000011 11111111111 10000 -000011 11 11111111111 100000 -0001 1111 111111111111111 1000 -001 1111111 11111111111111 1000 -001 1111111 1111111 111111 100 -001 11111111 111111 1111111 10 -001 11111111 11111 100 -001 1111111 111 11100 -000111 111 11111 11 100000 -000000111 111111111 1000000 diff --git a/drivers/staging/asus_oled/tux_r2.txt b/drivers/staging/asus_oled/tux_r2.txt deleted file mode 100644 index e94d84eaab0bf..0000000000000 --- a/drivers/staging/asus_oled/tux_r2.txt +++ /dev/null @@ -1,33 +0,0 @@ - -000000000000000000000000000000000000000000000000000000000000011111110000000000000000000000000000000000000000000000000000000000000 -0000000000000000000000000000000000000000000000000000000000001 1000000000000000000000000000000000000000000000000000000000000 -000000000000000000000000000000000000000000000000000000000001 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -000000000000000000000000000000000000000000000000000000000001 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -000000000000000000000000000000000000000000000000000000000001 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -000000000000000000000000000000000000000000000000000000000001 1 111 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -000000000000000000000000000000000000000000000000000000000001 1 1 100000000000000000000000000000000000000000000000000000000000000000000000000000000000001111111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -000000000000000000000000000000000000000000000000000000000001 111 100000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111100000000000000111000000000000000000000000000000000000000000000000000000000000000000000000000 -000000000000000000000000000000000000000000000000000000000001 111111 100000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000000111000000000000000000000000000000000000000000000000000000000000000000000000000 -000000000000000000000000000000000000000000000000000000000001 111111 100000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000000111000000000000000000000000000000000000000000000000000000000000000000000000000 -000000000000000000000000000000000000000000000000000000000001 1 1 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000001 11 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000001 11111111 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000011100001111111111100000111110011111100011111101111000000000000000000000000000000 -0000000000000000000000000000000000000000000000000000000001 11111111 100000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000000111110000011111000111000111110000111100001111000110000000000000000000000000000000 -000000000000000000000000000000000000000000000000000000001 111111111 100000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000001101110000011111000111000001111000111100000111100100000000000000000000000000000000 -000000000000000000000000000000000000000000000000000000001 1111111111 10000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000001001110000011110000111100001111000111100000111101100000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000001 11111111111 10000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000100001110000011110000111100001111000111100000011111000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000001 111111111111 10000000000000000000000000000000000000000000000000000000000000000000000000000000000011110000000001000111100000111100001111000011110001111000000011110000000 -0000000000000000000000000000000000000000000000000000001 111111111111 1000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000100011110000011110000111100001111000111100000001111000000 -0000000000000000000000000000000000000000000000000000001 111111111111 1000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000000100011100100011110000111100001111000111100000001111100000000000000000000000000000000 -0000000000000000000000000000000000000000000000000000001 111111111111 1000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000001100111100100011110000111100001111000111100000001111110000000000000000000000000000000 -0000000000000000000000000000000000000000000000000000001 111111111111 1000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000001100111101100011110000111100001111000111100000011011110000000000000000000000000000000 -000000000000000000000000000000000000000000000000000000011 11111111111 1000000000000000000000000000000000000000000000000000000000000000000000000000000000001111000000011100111101000011110000111100001111000111100000010001111000000000000000000000000000000 -000000000000000000000000000000000000000000000000000011 11 11111111111 10000000000000000000000000000000000000000000000000000000000000000000000000000000000011111000001111100111011000011110000111100001111001111100000110000111100000000000000000000000000000 -0000000000000000000000000000000000000000000000000001 1111 111111111111111 100000000000000000000000000000000000000000000000000000000000000000000000000000011111111111111111100011110001111111011111110000111110111111011111011111110000000000000000000000000000 -000000000000000000000000000000000000000000000000001 1111111 11111111111111 100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -000000000000000000000000000000000000000000000000001 1111111 1111111 111111 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -000000000000000000000000000000000000000000000000001 11111111 111111 1111111 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -000000000000000000000000000000000000000000000000001 11111111 11111 1000000000000000000000000000000000000000000000000000 -000000000000000000000000000000000000000000000000001 1111111 111 111000000000000000000000000000000000000000000000000000 -000000000000000000000000000000000000000000000000000111 111 11111 11 10 -000000000000000000000000000000000000000000000000000000111 111111111 10 diff --git a/drivers/staging/asus_oled/zig.txt b/drivers/staging/asus_oled/zig.txt deleted file mode 100644 index 31573d8f799aa..0000000000000 --- a/drivers/staging/asus_oled/zig.txt +++ /dev/null @@ -1,33 +0,0 @@ - -10000000000000000000000000000000000000000000000000000000000000011000000000000000000000000000000000000000000000000000000000000001 -01000000000000000000000000000000000000000000000000000000000000100100000000000000000000000000000000000000000000000000000000000010 -00100000000000000000000000000000000000000000000000000000000001000010000000000000000000000000000000000000000000000000000000000100 -00010000000000000000000000000000000000000000000000000000000010000001000000000000000000000000000000000000000000000000000000001000 -00001000000000000000000000000000000000000000000000000000000100000000100000000000000000000000000000000000000000000000000000010000 -00000100000000000000000000000000000000000000000000000000001000000000010000000000000000000000000000000000000000000000000000100000 -00000010000000000000000000000000000000000000000000000000010000000000001000000000000000000000000000000000000000000000000001000000 -00000001000000000000000000000000000000000000000000000000100000000000000100000000000000000000000000000000000000000000000010000000 -00000000100000000000000000000000000000000000000000000001000000000000000010000000000000000000000000000000000000000000000100000000 -00000000010000000000000000000000000000000000000000000010000000000000000001000000000000000000000000000000000000000000001000000000 -00000000001000000000000000000000000000000000000000000100000000000000000000100000000000000000000000000000000000000000010000000000 -00000000000100000000000000000000000000000000000000001000000000000000000000010000000000000000000000000000000000000000100000000000 -00000000000010000000000000000000000000000000000000010000000000000000000000001000000000000000000000000000000000000001000000000000 -00000000000001000000000000000000000000000000000000100000000000000000000000000100000000000000000000000000000000000010000000000000 -00000000000000100000000000000000000000000000000001000000000000000000000000000010000000000000000000000000000000000100000000000000 -00000000000000010000000000000000000000000000000010000000000000000000000000000001000000000000000000000000000000001000000000000000 -00000000000000001000000000000000000000000000000100000000000000000000000000000000100000000000000000000000000000010000000000000000 -00000000000000000100000000000000000000000000001000000000000000000000000000000000010000000000000000000000000000100000000000000000 -00000000000000000010000000000000000000000000010000000000000000000000000000000000001000000000000000000000000001000000000000000000 -00000000000000000001000000000000000000000000100000000000000000000000000000000000000100000000000000000000000010000000000000000000 -00000000000000000000100000000000000000000001000000000000000000000000000000000000000010000000000000000000000100000000000000000000 -00000000000000000000010000000000000000000010000000000000000000000000000000000000000001000000000000000000001000000000000000000000 -00000000000000000000001000000000000000000100000000000000000000000000000000000000000000100000000000000000010000000000000000000000 -00000000000000000000000100000000000000001000000000000000000000000000000000000000000000010000000000000000100000000000000000000000 -00000000000000000000000010000000000000010000000000000000000000000000000000000000000000001000000000000001000000000000000000000000 -00000000000000000000000001000000000000100000000000000000000000000000000000000000000000000100000000000010000000000000000000000000 -00000000000000000000000000100000000001000000000000000000000000000000000000000000000000000010000000000100000000000000000000000000 -00000000000000000000000000010000000010000000000000000000000000000000000000000000000000000001000000001000000000000000000000000000 -00000000000000000000000000001000000100000000000000000000000000000000000000000000000000000000100000010000000000000000000000000000 -00000000000000000000000000000100001000000000000000000000000000000000000000000000000000000000010000100000000000000000000000000000 -00000000000000000000000000000010010000000000000000000000000000000000000000000000000000000000001001000000000000000000000000000000 -00000000000000000000000000000001100000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000000 -- GitLab From f40ac2ae1b506484dd9261a24bbf3e86b2206ff8 Mon Sep 17 00:00:00 2001 From: Sunghan Suh Date: Wed, 3 Jul 2013 20:10:05 +0900 Subject: [PATCH 315/942] zram: prevent data loss in error cases of function zram_bvec_write() In function zram_bvec_write(), previous data at the index is already freed by function zram_free_page(). When failed to compress or zs_malloc, there is no way to restore old data. Therefore, free previous data when it's about to update. Also, no need to check whether table is not empty outside of function zram_free_page(), because the function properly checks inside. Signed-off-by: Sunghan Suh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/zram/zram_drv.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/staging/zram/zram_drv.c b/drivers/staging/zram/zram_drv.c index 1b30a5e87c78f..5ef6508a587c2 100644 --- a/drivers/staging/zram/zram_drv.c +++ b/drivers/staging/zram/zram_drv.c @@ -418,14 +418,6 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index, goto out; } - /* - * System overwrites unused sectors. Free memory associated - * with this sector now. - */ - if (meta->table[index].handle || - zram_test_flag(meta, index, ZRAM_ZERO)) - zram_free_page(zram, index); - user_mem = kmap_atomic(page); if (is_partial_io(bvec)) { @@ -439,6 +431,9 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index, if (page_zero_filled(uncmem)) { kunmap_atomic(user_mem); + /* Free memory associated with this sector now. */ + zram_free_page(zram, index); + zram->stats.pages_zero++; zram_set_flag(meta, index, ZRAM_ZERO); ret = 0; @@ -486,6 +481,12 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index, zs_unmap_object(meta->mem_pool, handle); + /* + * Free memory associated with this sector + * before overwriting unused sectors. + */ + zram_free_page(zram, index); + meta->table[index].handle = handle; meta->table[index].size = clen; -- GitLab From 6496c045292b7afe74b5306c123186976f032125 Mon Sep 17 00:00:00 2001 From: Yijing Wang Date: Thu, 27 Jun 2013 20:57:23 +0800 Subject: [PATCH 316/942] vt6655/trivial: replace numeric with standard PM state macros Use standard PM state macros PCI_Dx instead of numeric 0/1/2.. Signed-off-by: Yijing Wang Cc: Forest Bond Cc: Jiri Kosina Cc: Devendra Naga Cc: Joe Perches Cc: Marcos Paulo de Souza Cc: Bill Pemberton Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 08b250f01dae6..7f36a7103c3ef 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -3370,8 +3370,8 @@ viawget_resume(struct pci_dev *pcid) PSMgmtObject pMgmt = pDevice->pMgmt; int power_status; // to silence the compiler - power_status = pci_set_power_state(pcid, 0); - power_status = pci_enable_wake(pcid, 0, 0); + power_status = pci_set_power_state(pcid, PCI_D0); + power_status = pci_enable_wake(pcid, PCI_D0, 0); pci_restore_state(pcid); if (netif_running(pDevice->dev)) { spin_lock_irq(&pDevice->lock); -- GitLab From 7d46a21a1e27e1b4138feab42130861def57f4fc Mon Sep 17 00:00:00 2001 From: Emil Goode Date: Sun, 28 Jul 2013 00:38:55 +0200 Subject: [PATCH 317/942] staging: lustre: Fix non-ANSI sparse warnings This patch fixes a lot of non-ANSI sparse warnings by adding void to parameterless functions. Signed-off-by: Emil Goode Signed-off-by: Greg Kroah-Hartman --- .../lustre/lnet/klnds/socklnd/socklnd_lib-linux.c | 6 +++--- drivers/staging/lustre/lnet/lnet/api-ni.c | 2 +- drivers/staging/lustre/lnet/selftest/console.c | 2 +- .../lustre/lustre/libcfs/linux/linux-tracefile.c | 14 +++++++------- .../staging/lustre/lustre/ptlrpc/pack_generic.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/pinger.c | 4 ++-- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c index 3e08fe2d1489b..76e442be55823 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c @@ -325,20 +325,20 @@ ksocknal_lib_tunables_init () } void -ksocknal_lib_tunables_fini () +ksocknal_lib_tunables_fini(void) { if (ksocknal_tunables.ksnd_sysctl != NULL) unregister_sysctl_table(ksocknal_tunables.ksnd_sysctl); } #else int -ksocknal_lib_tunables_init () +ksocknal_lib_tunables_init(void) { return 0; } void -ksocknal_lib_tunables_fini () +ksocknal_lib_tunables_fini(void) { } #endif /* # if CONFIG_SYSCTL && !CFS_SYSFS_MODULE_PARM */ diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index 250c618687041..160a4292c6ce6 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -1371,7 +1371,7 @@ EXPORT_SYMBOL(LNetNIInit); * \return always 0 for current implementation. */ int -LNetNIFini() +LNetNIFini(void) { LNET_MUTEX_LOCK(&the_lnet.ln_api_mutex); diff --git a/drivers/staging/lustre/lnet/selftest/console.c b/drivers/staging/lustre/lnet/selftest/console.c index 78e8d04672678..09e4700af6405 100644 --- a/drivers/staging/lustre/lnet/selftest/console.c +++ b/drivers/staging/lustre/lnet/selftest/console.c @@ -1773,7 +1773,7 @@ lstcon_session_info(lst_sid_t *sid_up, int *key_up, unsigned *featp, } int -lstcon_session_end() +lstcon_session_end(void) { lstcon_rpc_trans_t *trans; lstcon_group_t *grp; diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c index a500a0b5ba9f4..162beee24a737 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c @@ -51,7 +51,7 @@ char *cfs_trace_console_buffers[NR_CPUS][CFS_TCD_TYPE_MAX]; struct rw_semaphore cfs_tracefile_sem; -int cfs_tracefile_init_arch() +int cfs_tracefile_init_arch(void) { int i; int j; @@ -96,7 +96,7 @@ int cfs_tracefile_init_arch() return -ENOMEM; } -void cfs_tracefile_fini_arch() +void cfs_tracefile_fini_arch(void) { int i; int j; @@ -116,27 +116,27 @@ void cfs_tracefile_fini_arch() fini_rwsem(&cfs_tracefile_sem); } -void cfs_tracefile_read_lock() +void cfs_tracefile_read_lock(void) { down_read(&cfs_tracefile_sem); } -void cfs_tracefile_read_unlock() +void cfs_tracefile_read_unlock(void) { up_read(&cfs_tracefile_sem); } -void cfs_tracefile_write_lock() +void cfs_tracefile_write_lock(void) { down_write(&cfs_tracefile_sem); } -void cfs_tracefile_write_unlock() +void cfs_tracefile_write_unlock(void) { up_write(&cfs_tracefile_sem); } -cfs_trace_buf_type_t cfs_trace_buf_idx_get() +cfs_trace_buf_type_t cfs_trace_buf_idx_get(void) { if (in_irq()) return CFS_TCD_TYPE_IRQ; diff --git a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c index ffff648335574..9c20d0c606789 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c @@ -115,7 +115,7 @@ int lustre_msg_check_version(struct lustre_msg *msg, __u32 version) EXPORT_SYMBOL(lustre_msg_check_version); /* early reply size */ -int lustre_msg_early_size() +int lustre_msg_early_size(void) { static int size = 0; if (!size) { diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c index f521251a1a6e9..79e7d0852e957 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c @@ -51,7 +51,7 @@ struct mutex pinger_mutex; static LIST_HEAD(pinger_imports); static struct list_head timeout_list = LIST_HEAD_INIT(timeout_list); -int ptlrpc_pinger_suppress_pings() +int ptlrpc_pinger_suppress_pings(void) { return suppress_pings; } @@ -608,7 +608,7 @@ int ptlrpc_pinger_remove_timeouts(void) return 0; } -void ptlrpc_pinger_wake_up() +void ptlrpc_pinger_wake_up(void) { thread_add_flags(&pinger_thread, SVC_EVENT); wake_up(&pinger_thread.t_ctl_waitq); -- GitLab From 805e517aae4a8d47f5a5069eabfded1f26e95343 Mon Sep 17 00:00:00 2001 From: Emil Goode Date: Sun, 28 Jul 2013 00:38:56 +0200 Subject: [PATCH 318/942] staging: lustre: Fix sparse warnings about use of obsolete initializer This patch fixes a lot of sparse warnings about use of obsolete struct and array initializer. Signed-off-by: Emil Goode Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/ldlm/ldlm_lib.c | 16 +++--- .../staging/lustre/lustre/ldlm/ldlm_lock.c | 50 +++++++++---------- .../staging/lustre/lustre/ldlm/ldlm_request.c | 5 +- .../lustre/lustre/libcfs/linux/linux-debug.c | 6 +-- .../lustre/lustre/libcfs/linux/linux-module.c | 6 +-- .../staging/lustre/lustre/mdc/mdc_request.c | 2 +- 6 files changed, 44 insertions(+), 41 deletions(-) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c index aace5342b76a6..950f90acec043 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c @@ -762,14 +762,14 @@ void target_send_reply(struct ptlrpc_request *req, int rc, int fail_id) EXPORT_SYMBOL(target_send_reply); ldlm_mode_t lck_compat_array[] = { - [LCK_EX] LCK_COMPAT_EX, - [LCK_PW] LCK_COMPAT_PW, - [LCK_PR] LCK_COMPAT_PR, - [LCK_CW] LCK_COMPAT_CW, - [LCK_CR] LCK_COMPAT_CR, - [LCK_NL] LCK_COMPAT_NL, - [LCK_GROUP] LCK_COMPAT_GROUP, - [LCK_COS] LCK_COMPAT_COS, + [LCK_EX] = LCK_COMPAT_EX, + [LCK_PW] = LCK_COMPAT_PW, + [LCK_PR] = LCK_COMPAT_PR, + [LCK_CW] = LCK_COMPAT_CW, + [LCK_CR] = LCK_COMPAT_CR, + [LCK_NL] = LCK_COMPAT_NL, + [LCK_GROUP] = LCK_COMPAT_GROUP, + [LCK_COS] = LCK_COMPAT_COS, }; /** diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index ce1add149f525..a9174209aa8f2 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -49,45 +49,45 @@ /* lock types */ char *ldlm_lockname[] = { - [0] "--", - [LCK_EX] "EX", - [LCK_PW] "PW", - [LCK_PR] "PR", - [LCK_CW] "CW", - [LCK_CR] "CR", - [LCK_NL] "NL", - [LCK_GROUP] "GROUP", - [LCK_COS] "COS" + [0] = "--", + [LCK_EX] = "EX", + [LCK_PW] = "PW", + [LCK_PR] = "PR", + [LCK_CW] = "CW", + [LCK_CR] = "CR", + [LCK_NL] = "NL", + [LCK_GROUP] = "GROUP", + [LCK_COS] = "COS", }; EXPORT_SYMBOL(ldlm_lockname); char *ldlm_typename[] = { - [LDLM_PLAIN] "PLN", - [LDLM_EXTENT] "EXT", - [LDLM_FLOCK] "FLK", - [LDLM_IBITS] "IBT", + [LDLM_PLAIN] = "PLN", + [LDLM_EXTENT] = "EXT", + [LDLM_FLOCK] = "FLK", + [LDLM_IBITS] = "IBT", }; EXPORT_SYMBOL(ldlm_typename); static ldlm_policy_wire_to_local_t ldlm_policy_wire18_to_local[] = { - [LDLM_PLAIN - LDLM_MIN_TYPE] ldlm_plain_policy_wire_to_local, - [LDLM_EXTENT - LDLM_MIN_TYPE] ldlm_extent_policy_wire_to_local, - [LDLM_FLOCK - LDLM_MIN_TYPE] ldlm_flock_policy_wire18_to_local, - [LDLM_IBITS - LDLM_MIN_TYPE] ldlm_ibits_policy_wire_to_local, + [LDLM_PLAIN - LDLM_MIN_TYPE] = ldlm_plain_policy_wire_to_local, + [LDLM_EXTENT - LDLM_MIN_TYPE] = ldlm_extent_policy_wire_to_local, + [LDLM_FLOCK - LDLM_MIN_TYPE] = ldlm_flock_policy_wire18_to_local, + [LDLM_IBITS - LDLM_MIN_TYPE] = ldlm_ibits_policy_wire_to_local, }; static ldlm_policy_wire_to_local_t ldlm_policy_wire21_to_local[] = { - [LDLM_PLAIN - LDLM_MIN_TYPE] ldlm_plain_policy_wire_to_local, - [LDLM_EXTENT - LDLM_MIN_TYPE] ldlm_extent_policy_wire_to_local, - [LDLM_FLOCK - LDLM_MIN_TYPE] ldlm_flock_policy_wire21_to_local, - [LDLM_IBITS - LDLM_MIN_TYPE] ldlm_ibits_policy_wire_to_local, + [LDLM_PLAIN - LDLM_MIN_TYPE] = ldlm_plain_policy_wire_to_local, + [LDLM_EXTENT - LDLM_MIN_TYPE] = ldlm_extent_policy_wire_to_local, + [LDLM_FLOCK - LDLM_MIN_TYPE] = ldlm_flock_policy_wire21_to_local, + [LDLM_IBITS - LDLM_MIN_TYPE] = ldlm_ibits_policy_wire_to_local, }; static ldlm_policy_local_to_wire_t ldlm_policy_local_to_wire[] = { - [LDLM_PLAIN - LDLM_MIN_TYPE] ldlm_plain_policy_local_to_wire, - [LDLM_EXTENT - LDLM_MIN_TYPE] ldlm_extent_policy_local_to_wire, - [LDLM_FLOCK - LDLM_MIN_TYPE] ldlm_flock_policy_local_to_wire, - [LDLM_IBITS - LDLM_MIN_TYPE] ldlm_ibits_policy_local_to_wire, + [LDLM_PLAIN - LDLM_MIN_TYPE] = ldlm_plain_policy_local_to_wire, + [LDLM_EXTENT - LDLM_MIN_TYPE] = ldlm_extent_policy_local_to_wire, + [LDLM_FLOCK - LDLM_MIN_TYPE] = ldlm_flock_policy_local_to_wire, + [LDLM_IBITS - LDLM_MIN_TYPE] = ldlm_ibits_policy_local_to_wire, }; /** diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c index c900706a9c8d3..6f21a1204a645 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c @@ -2068,7 +2068,10 @@ void ldlm_namespace_foreach(struct ldlm_namespace *ns, ldlm_iterator_t iter, void *closure) { - struct iter_helper_data helper = { iter: iter, closure: closure }; + struct iter_helper_data helper = { + .iter = iter, + .closure = closure, + }; cfs_hash_for_each_nolock(ns->ns_rs_hash, ldlm_res_iter_helper, &helper); diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c index 6afb350731418..9b57304e6caa2 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c @@ -194,9 +194,9 @@ static int panic_notifier(struct notifier_block *self, unsigned long unused1, } static struct notifier_block libcfs_panic_notifier = { - notifier_call : panic_notifier, - next : NULL, - priority : 10000 + .notifier_call = panic_notifier, + .next = NULL, + .priority = 10000, }; void libcfs_register_panic_notifier(void) diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c index d8f320e6f4b61..7449f4f186402 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c @@ -171,9 +171,9 @@ static long libcfs_ioctl(struct file *file, } static struct file_operations libcfs_fops = { - unlocked_ioctl: libcfs_ioctl, - open : libcfs_psdev_open, - release : libcfs_psdev_release + .unlocked_ioctl = libcfs_ioctl, + .open = libcfs_psdev_open, + .release = libcfs_psdev_release, }; struct miscdevice libcfs_dev = { diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index 191edc6470cd0..2dabfc01d224d 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -2378,7 +2378,7 @@ static int mdc_resource_inode_free(struct ldlm_resource *res) } struct ldlm_valblock_ops inode_lvbo = { - lvbo_free: mdc_resource_inode_free + .lvbo_free = mdc_resource_inode_free, }; static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg) -- GitLab From fc4360d66472f33970c51464eb3b3a77f956d13e Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Mon, 29 Jul 2013 12:59:30 +0800 Subject: [PATCH 319/942] staging: xillybus: remove duplicated include from xillybus_core.c Remove duplicated include. Signed-off-by: Wei Yongjun Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xillybus/xillybus_core.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/xillybus/xillybus_core.c b/drivers/staging/xillybus/xillybus_core.c index 7991e572ef04b..9ccd6aa7e8c5f 100644 --- a/drivers/staging/xillybus/xillybus_core.c +++ b/drivers/staging/xillybus/xillybus_core.c @@ -27,11 +27,9 @@ #include #include #include -#include #include #include #include -#include #include #include #include "xillybus.h" -- GitLab From 485754f5cc79e438e81909e72a14d0a402d70f83 Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Mon, 29 Jul 2013 12:33:24 +0800 Subject: [PATCH 320/942] staging: gdm724x: remove duplicated include from gdm_lte.c Remove duplicated include. Signed-off-by: Wei Yongjun Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm724x/gdm_lte.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/gdm724x/gdm_lte.c b/drivers/staging/gdm724x/gdm_lte.c index 68ebc7d1eae62..7165d3a1490e4 100644 --- a/drivers/staging/gdm724x/gdm_lte.c +++ b/drivers/staging/gdm724x/gdm_lte.c @@ -21,9 +21,7 @@ #include #include #include -#include #include -#include #include #include #include -- GitLab From a66b0f039cddfd01152eb773c4f60b246f612516 Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Mon, 29 Jul 2013 12:28:51 +0800 Subject: [PATCH 321/942] staging: comedi: dt9812: remove duplicated include from dt9812.c Remove duplicated include. Signed-off-by: Wei Yongjun Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt9812.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/dt9812.c b/drivers/staging/comedi/drivers/dt9812.c index bd14017b798c8..7d78c78a4a270 100644 --- a/drivers/staging/comedi/drivers/dt9812.c +++ b/drivers/staging/comedi/drivers/dt9812.c @@ -42,7 +42,6 @@ for my needs. #include #include #include -#include #include #include -- GitLab From 9c02d0dbdefdb8953f6bce698bcce651a13f3a19 Mon Sep 17 00:00:00 2001 From: Won Kang Date: Sat, 27 Jul 2013 15:42:18 +0900 Subject: [PATCH 322/942] staging: gdm724x: Modified function name conflict set_endian Conflict resolution for function name set_endian when building for powerpc The name changed to gdm_set_endian Reported-by: kbuild test robot Signed-off-by: Won Kang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm724x/gdm_endian.c | 2 +- drivers/staging/gdm724x/gdm_endian.h | 2 +- drivers/staging/gdm724x/gdm_usb.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/gdm724x/gdm_endian.c b/drivers/staging/gdm724x/gdm_endian.c index 02934093ce7f6..f6cc90ae9ba69 100644 --- a/drivers/staging/gdm724x/gdm_endian.c +++ b/drivers/staging/gdm724x/gdm_endian.c @@ -14,7 +14,7 @@ #include #include "gdm_endian.h" -void set_endian(struct gdm_endian *ed, u8 dev_endian) +void gdm_set_endian(struct gdm_endian *ed, u8 dev_endian) { u8 a[2] = {0x12, 0x34}; u8 b[2] = {0, }; diff --git a/drivers/staging/gdm724x/gdm_endian.h b/drivers/staging/gdm724x/gdm_endian.h index 775794db6ab69..9b2531ff908e2 100644 --- a/drivers/staging/gdm724x/gdm_endian.h +++ b/drivers/staging/gdm724x/gdm_endian.h @@ -40,7 +40,7 @@ struct gdm_endian { u8 host_ed; }; -void set_endian(struct gdm_endian *ed, u8 dev_endian); +void gdm_set_endian(struct gdm_endian *ed, u8 dev_endian); u16 gdm_cpu_to_dev16(struct gdm_endian *ed, u16 x); u16 gdm_dev16_to_cpu(struct gdm_endian *ed, u16 x); u32 gdm_cpu_to_dev32(struct gdm_endian *ed, u32 x); diff --git a/drivers/staging/gdm724x/gdm_usb.c b/drivers/staging/gdm724x/gdm_usb.c index 4b10f23845ad0..bdc96370e4306 100644 --- a/drivers/staging/gdm724x/gdm_usb.c +++ b/drivers/staging/gdm724x/gdm_usb.c @@ -870,9 +870,9 @@ static int gdm_usb_probe(struct usb_interface *intf, const struct usb_device_id /* List up hosts with big endians, otherwise, defaults to little endian */ if (idProduct == PID_GDM7243) - set_endian(&udev->gdm_ed, ENDIANNESS_BIG); + gdm_set_endian(&udev->gdm_ed, ENDIANNESS_BIG); else - set_endian(&udev->gdm_ed, ENDIANNESS_LITTLE); + gdm_set_endian(&udev->gdm_ed, ENDIANNESS_LITTLE); ret = request_mac_address(udev); if (ret < 0) { -- GitLab From ca250b6017910ca6edca4cbd6eaa7452a13b5c03 Mon Sep 17 00:00:00 2001 From: Marc Dietrich Date: Sat, 27 Jul 2013 18:20:58 +0200 Subject: [PATCH 323/942] staging: nvec: re-enable the clock on resume On resume the slave controller is reinitialized. The tegra i2c master controller disables the clock at the end of the initialiation, propably to save some power, and enables it again on each transfer. We don't do this yet and also forgot to enable the clock on resume. Fix this copy-paste error by not disabling the clock after initialization. This didn't striked us yet because suspend/resume hasn't landed in mainline yet, but will soon. Signed-off-by: Marc Dietrich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/nvec/nvec.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c index 10393da315d7b..5a5c6397e7406 100644 --- a/drivers/staging/nvec/nvec.c +++ b/drivers/staging/nvec/nvec.c @@ -750,8 +750,6 @@ static void tegra_init_i2c_slave(struct nvec_chip *nvec) writel(0, nvec->base + I2C_SL_ADDR2); enable_irq(nvec->irq); - - clk_disable_unprepare(nvec->i2c_clk); } #ifdef CONFIG_PM_SLEEP @@ -872,9 +870,6 @@ static int tegra_nvec_probe(struct platform_device *pdev) tegra_init_i2c_slave(nvec); - clk_prepare_enable(i2c_clk); - - /* enable event reporting */ nvec_toggle_global_events(nvec, true); -- GitLab From 37c79c711dc382e3408964a839f5fbb9a5b6d14f Mon Sep 17 00:00:00 2001 From: Lilis Iskandar Date: Sun, 28 Jul 2013 03:34:43 +0800 Subject: [PATCH 324/942] Staging: bcm: LeakyBucket: Fixed spacing/tabing issues This one fixes spacing/tabbing issues. Signed-off-by: Lilis Iskandar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/LeakyBucket.c | 170 +++++++++++++++--------------- 1 file changed, 85 insertions(+), 85 deletions(-) diff --git a/drivers/staging/bcm/LeakyBucket.c b/drivers/staging/bcm/LeakyBucket.c index 877cf0b2bee1b..ee1d9f6ca0d21 100644 --- a/drivers/staging/bcm/LeakyBucket.c +++ b/drivers/staging/bcm/LeakyBucket.c @@ -17,30 +17,30 @@ static VOID UpdateTokenCount(register struct bcm_mini_adapter *Adapter) { - ULONG liCurrentTime; - INT i = 0; + ULONG liCurrentTime; + INT i = 0; struct timeval tv; BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "=====>\n"); - if(NULL == Adapter) + if (NULL == Adapter) { - BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TOKEN_COUNTS, + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "Adapter found NULL!\n"); return; } do_gettimeofday(&tv); - for(i = 0; i < NO_OF_QUEUES; i++) + for (i = 0; i < NO_OF_QUEUES; i++) { - if(TRUE == Adapter->PackInfo[i].bValid && + if (TRUE == Adapter->PackInfo[i].bValid && (1 == Adapter->PackInfo[i].ucDirection)) { liCurrentTime = ((tv.tv_sec- Adapter->PackInfo[i].stLastUpdateTokenAt.tv_sec)*1000 + (tv.tv_usec-Adapter->PackInfo[i].stLastUpdateTokenAt.tv_usec)/ 1000); - if(0!=liCurrentTime) + if (0 != liCurrentTime) { Adapter->PackInfo[i].uiCurrentTokenCount += (ULONG) ((Adapter->PackInfo[i].uiMaxAllowedRate) * @@ -48,7 +48,7 @@ static VOID UpdateTokenCount(register struct bcm_mini_adapter *Adapter) memcpy(&Adapter->PackInfo[i].stLastUpdateTokenAt, &tv, sizeof(struct timeval)); Adapter->PackInfo[i].liLastUpdateTokenAt = liCurrentTime; - if((Adapter->PackInfo[i].uiCurrentTokenCount) >= + if ((Adapter->PackInfo[i].uiCurrentTokenCount) >= Adapter->PackInfo[i].uiMaxBucketSize) { Adapter->PackInfo[i].uiCurrentTokenCount = @@ -57,7 +57,7 @@ static VOID UpdateTokenCount(register struct bcm_mini_adapter *Adapter) } } } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "<=====\n"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "<=====\n"); return; } @@ -79,33 +79,33 @@ static VOID UpdateTokenCount(register struct bcm_mini_adapter *Adapter) ***********************************************************************/ static ULONG GetSFTokenCount(struct bcm_mini_adapter *Adapter, struct bcm_packet_info *psSF) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "IsPacketAllowedForFlow ===>"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "IsPacketAllowedForFlow ===>"); /* Validate the parameters */ - if(NULL == Adapter || (psSF < Adapter->PackInfo && + if (NULL == Adapter || (psSF < Adapter->PackInfo && (uintptr_t)psSF > (uintptr_t) &Adapter->PackInfo[HiPriority])) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "IPAFF: Got wrong Parameters:Adapter: %p, QIndex: %zd\n", Adapter, (psSF-Adapter->PackInfo)); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "IPAFF: Got wrong Parameters:Adapter: %p, QIndex: %zd\n", Adapter, (psSF-Adapter->PackInfo)); return 0; } - if(FALSE != psSF->bValid && psSF->ucDirection) + if (FALSE != psSF->bValid && psSF->ucDirection) { - if(0 != psSF->uiCurrentTokenCount) + if (0 != psSF->uiCurrentTokenCount) { return psSF->uiCurrentTokenCount; } else { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "Not enough tokens in queue %zd Available %u\n", + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "Not enough tokens in queue %zd Available %u\n", psSF-Adapter->PackInfo, psSF->uiCurrentTokenCount); psSF->uiPendedLast = 1; } } else { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "IPAFF: Queue %zd not valid\n", psSF-Adapter->PackInfo); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "IPAFF: Queue %zd not valid\n", psSF-Adapter->PackInfo); } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "IsPacketAllowedForFlow <==="); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "IsPacketAllowedForFlow <==="); return 0; } @@ -118,31 +118,31 @@ static INT SendPacketFromQueue(struct bcm_mini_adapter *Adapter,/**"); - if(!Adapter || !Packet || !psSF) + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, SEND_QUEUE, DBG_LVL_ALL, "=====>"); + if (!Adapter || !Packet || !psSF) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, SEND_QUEUE, DBG_LVL_ALL, "Got NULL Adapter or Packet"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, SEND_QUEUE, DBG_LVL_ALL, "Got NULL Adapter or Packet"); return -EINVAL; } - if(psSF->liDrainCalculated==0) + if (psSF->liDrainCalculated == 0) { psSF->liDrainCalculated = jiffies; } ///send the packet to the fifo.. PktLen = Packet->len; Status = SetupNextSend(Adapter, Packet, psSF->usVCID_Value); - if(Status == 0) + if (Status == 0) { - for(uiIndex = 0 ; uiIndex < MIBS_MAX_HIST_ENTRIES ; uiIndex++) - { if((PktLen <= MIBS_PKTSIZEHIST_RANGE*(uiIndex+1)) && (PktLen > MIBS_PKTSIZEHIST_RANGE*(uiIndex))) + for (uiIndex = 0; uiIndex < MIBS_MAX_HIST_ENTRIES; uiIndex++) + { if ((PktLen <= MIBS_PKTSIZEHIST_RANGE*(uiIndex+1)) && (PktLen > MIBS_PKTSIZEHIST_RANGE*(uiIndex))) Adapter->aTxPktSizeHist[uiIndex]++; } } - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, SEND_QUEUE, DBG_LVL_ALL, "<====="); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, SEND_QUEUE, DBG_LVL_ALL, "<====="); return Status; } @@ -160,48 +160,48 @@ static INT SendPacketFromQueue(struct bcm_mini_adapter *Adapter,/**", (psSF-Adapter->PackInfo)); - if((psSF != &Adapter->PackInfo[HiPriority]) && Adapter->LinkUpStatus && atomic_read(&psSF->uiPerSFTxResourceCount))//Get data packet - { - if(!psSF->ucDirection ) + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "%zd ====>", (psSF-Adapter->PackInfo)); + if ((psSF != &Adapter->PackInfo[HiPriority]) && Adapter->LinkUpStatus && atomic_read(&psSF->uiPerSFTxResourceCount))//Get data packet + { + if (!psSF->ucDirection) return; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "UpdateTokenCount "); - if(Adapter->IdleMode || Adapter->bPreparingForLowPowerMode) + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "UpdateTokenCount "); + if (Adapter->IdleMode || Adapter->bPreparingForLowPowerMode) return; /* in idle mode */ // Check for Free Descriptors - if(atomic_read(&Adapter->CurrNumFreeTxDesc) <= MINIMUM_PENDING_DESCRIPTORS) + if (atomic_read(&Adapter->CurrNumFreeTxDesc) <= MINIMUM_PENDING_DESCRIPTORS) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, " No Free Tx Descriptor(%d) is available for Data pkt..",atomic_read(&Adapter->CurrNumFreeTxDesc)); - return ; + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, " No Free Tx Descriptor(%d) is available for Data pkt..", atomic_read(&Adapter->CurrNumFreeTxDesc)); + return; } spin_lock_bh(&psSF->SFQueueLock); - QueuePacket=psSF->FirstTxQueue; + QueuePacket = psSF->FirstTxQueue; - if(QueuePacket) + if (QueuePacket) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Dequeuing Data Packet"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Dequeuing Data Packet"); - if(psSF->bEthCSSupport) + if (psSF->bEthCSSupport) iPacketLen = QueuePacket->len; else iPacketLen = QueuePacket->len-ETH_HLEN; - iPacketLen<<=3; - if(iPacketLen <= GetSFTokenCount(Adapter, psSF)) + iPacketLen <<= 3; + if (iPacketLen <= GetSFTokenCount(Adapter, psSF)) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Allowed bytes %d", + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Allowed bytes %d", (iPacketLen >> 3)); - DEQUEUEPACKET(psSF->FirstTxQueue,psSF->LastTxQueue); + DEQUEUEPACKET(psSF->FirstTxQueue, psSF->LastTxQueue); psSF->uiCurrentBytesOnHost -= (QueuePacket->len); psSF->uiCurrentPacketsOnHost--; atomic_dec(&Adapter->TotalPacketCount); @@ -212,8 +212,8 @@ static VOID CheckAndSendPacketFromIndex(struct bcm_mini_adapter *Adapter, struct } else { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "For Queue: %zd\n", psSF-Adapter->PackInfo); - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "\nAvailable Tokens = %d required = %d\n", + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "For Queue: %zd\n", psSF-Adapter->PackInfo); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "\nAvailable Tokens = %d required = %d\n", psSF->uiCurrentTokenCount, iPacketLen); //this part indicates that because of non-availability of the tokens //pkt has not been send out hence setting the pending flag indicating the host to send it out @@ -230,22 +230,22 @@ static VOID CheckAndSendPacketFromIndex(struct bcm_mini_adapter *Adapter, struct else { - if((atomic_read(&Adapter->CurrNumFreeTxDesc) > 0 ) && + if ((atomic_read(&Adapter->CurrNumFreeTxDesc) > 0) && (atomic_read(&Adapter->index_rd_txcntrlpkt) != atomic_read(&Adapter->index_wr_txcntrlpkt)) ) { pControlPacket = Adapter->txctlpacket [(atomic_read(&Adapter->index_rd_txcntrlpkt)%MAX_CNTRL_PKTS)]; - if(pControlPacket) + if (pControlPacket) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Sending Control packet"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Sending Control packet"); Status = SendControlPacket(Adapter, pControlPacket); - if(STATUS_SUCCESS==Status) + if (STATUS_SUCCESS == Status) { spin_lock_bh(&psSF->SFQueueLock); psSF->NumOfPacketsSent++; - psSF->uiSentBytes+=((struct bcm_leader *)pControlPacket)->PLength; + psSF->uiSentBytes += ((struct bcm_leader *)pControlPacket)->PLength; psSF->uiSentPackets++; atomic_dec(&Adapter->TotalPacketCount); psSF->uiCurrentBytesOnHost -= ((struct bcm_leader *)pControlPacket)->PLength; @@ -254,11 +254,11 @@ static VOID CheckAndSendPacketFromIndex(struct bcm_mini_adapter *Adapter, struct spin_unlock_bh(&psSF->SFQueueLock); } else - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "SendControlPacket Failed\n"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "SendControlPacket Failed\n"); } else { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, " Control Pkt is not available, Indexing is wrong...."); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, " Control Pkt is not available, Indexing is wrong...."); } } } @@ -277,79 +277,79 @@ static VOID CheckAndSendPacketFromIndex(struct bcm_mini_adapter *Adapter, struct ********************************************************************/ VOID transmit_packets(struct bcm_mini_adapter *Adapter) { - UINT uiPrevTotalCount = 0; + UINT uiPrevTotalCount = 0; int iIndex = 0; - BOOLEAN exit_flag = TRUE ; + BOOLEAN exit_flag = TRUE; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "=====>"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "=====>"); - if(NULL == Adapter) + if (NULL == Adapter) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX,TX_PACKETS, DBG_LVL_ALL, "Got NULL Adapter"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Got NULL Adapter"); return; } - if(Adapter->device_removed == TRUE) + if (Adapter->device_removed == TRUE) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Device removed"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Device removed"); return; } - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "\nUpdateTokenCount ====>\n"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "\nUpdateTokenCount ====>\n"); UpdateTokenCount(Adapter); - BCM_DEBUG_PRINT (Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "\nPruneQueueAllSF ====>\n"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "\nPruneQueueAllSF ====>\n"); PruneQueueAllSF(Adapter); uiPrevTotalCount = atomic_read(&Adapter->TotalPacketCount); - for(iIndex=HiPriority;iIndex>=0;iIndex--) + for (iIndex = HiPriority; iIndex >= 0; iIndex--) { - if( !uiPrevTotalCount || (TRUE == Adapter->device_removed)) + if (!uiPrevTotalCount || (TRUE == Adapter->device_removed)) break; - if(Adapter->PackInfo[iIndex].bValid && + if (Adapter->PackInfo[iIndex].bValid && Adapter->PackInfo[iIndex].uiPendedLast && Adapter->PackInfo[iIndex].uiCurrentBytesOnHost) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Calling CheckAndSendPacketFromIndex.."); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Calling CheckAndSendPacketFromIndex.."); CheckAndSendPacketFromIndex(Adapter, &Adapter->PackInfo[iIndex]); uiPrevTotalCount--; } } - while(uiPrevTotalCount > 0 && !Adapter->device_removed) + while (uiPrevTotalCount > 0 && !Adapter->device_removed) { - exit_flag = TRUE ; + exit_flag = TRUE; //second iteration to parse non-pending queues - for(iIndex=HiPriority;iIndex>=0;iIndex--) + for (iIndex = HiPriority; iIndex >= 0; iIndex--) { - if( !uiPrevTotalCount || (TRUE == Adapter->device_removed)) - break; + if (!uiPrevTotalCount || (TRUE == Adapter->device_removed)) + break; - if(Adapter->PackInfo[iIndex].bValid && + if (Adapter->PackInfo[iIndex].bValid && Adapter->PackInfo[iIndex].uiCurrentBytesOnHost && - !Adapter->PackInfo[iIndex].uiPendedLast ) + !Adapter->PackInfo[iIndex].uiPendedLast) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Calling CheckAndSendPacketFromIndex.."); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Calling CheckAndSendPacketFromIndex.."); CheckAndSendPacketFromIndex(Adapter, &Adapter->PackInfo[iIndex]); uiPrevTotalCount--; exit_flag = FALSE; } } - if(Adapter->IdleMode || Adapter->bPreparingForLowPowerMode) + if (Adapter->IdleMode || Adapter->bPreparingForLowPowerMode) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "In Idle Mode\n"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "In Idle Mode\n"); break; } - if(exit_flag == TRUE ) - break ; - }/* end of inner while loop */ + if (exit_flag == TRUE) + break; + } /* end of inner while loop */ - update_per_cid_rx (Adapter); + update_per_cid_rx(Adapter); Adapter->txtransmit_running = 0; - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "<======"); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "<======"); } -- GitLab From 68f4f09b9a58345452211a5ad1d7f2b50a23a00e Mon Sep 17 00:00:00 2001 From: Lilis Iskandar Date: Sun, 28 Jul 2013 03:34:44 +0800 Subject: [PATCH 325/942] Staging: bcm: LeakyBucket: Fixed brace issues Fixed brace issues Signed-off-by: Lilis Iskandar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/LeakyBucket.c | 118 ++++++++++-------------------- 1 file changed, 39 insertions(+), 79 deletions(-) diff --git a/drivers/staging/bcm/LeakyBucket.c b/drivers/staging/bcm/LeakyBucket.c index ee1d9f6ca0d21..52e6e05831576 100644 --- a/drivers/staging/bcm/LeakyBucket.c +++ b/drivers/staging/bcm/LeakyBucket.c @@ -23,34 +23,29 @@ static VOID UpdateTokenCount(register struct bcm_mini_adapter *Adapter) BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "=====>\n"); - if (NULL == Adapter) - { + if (NULL == Adapter) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "Adapter found NULL!\n"); return; } do_gettimeofday(&tv); - for (i = 0; i < NO_OF_QUEUES; i++) - { + for (i = 0; i < NO_OF_QUEUES; i++) { if (TRUE == Adapter->PackInfo[i].bValid && - (1 == Adapter->PackInfo[i].ucDirection)) - { + (1 == Adapter->PackInfo[i].ucDirection)) { liCurrentTime = ((tv.tv_sec- Adapter->PackInfo[i].stLastUpdateTokenAt.tv_sec)*1000 + (tv.tv_usec-Adapter->PackInfo[i].stLastUpdateTokenAt.tv_usec)/ 1000); - if (0 != liCurrentTime) - { + if (0 != liCurrentTime) { Adapter->PackInfo[i].uiCurrentTokenCount += (ULONG) ((Adapter->PackInfo[i].uiMaxAllowedRate) * ((ULONG)((liCurrentTime)))/1000); memcpy(&Adapter->PackInfo[i].stLastUpdateTokenAt, &tv, sizeof(struct timeval)); Adapter->PackInfo[i].liLastUpdateTokenAt = liCurrentTime; - if ((Adapter->PackInfo[i].uiCurrentTokenCount) >= - Adapter->PackInfo[i].uiMaxBucketSize) - { + if (Adapter->PackInfo[i].uiCurrentTokenCount >= + Adapter->PackInfo[i].uiMaxBucketSize) { Adapter->PackInfo[i].uiCurrentTokenCount = Adapter->PackInfo[i].uiMaxBucketSize; } @@ -82,27 +77,20 @@ static ULONG GetSFTokenCount(struct bcm_mini_adapter *Adapter, struct bcm_packet BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "IsPacketAllowedForFlow ===>"); /* Validate the parameters */ if (NULL == Adapter || (psSF < Adapter->PackInfo && - (uintptr_t)psSF > (uintptr_t) &Adapter->PackInfo[HiPriority])) - { + (uintptr_t)psSF > (uintptr_t) &Adapter->PackInfo[HiPriority])) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "IPAFF: Got wrong Parameters:Adapter: %p, QIndex: %zd\n", Adapter, (psSF-Adapter->PackInfo)); return 0; } - if (FALSE != psSF->bValid && psSF->ucDirection) - { - if (0 != psSF->uiCurrentTokenCount) - { + if (FALSE != psSF->bValid && psSF->ucDirection) { + if (0 != psSF->uiCurrentTokenCount) { return psSF->uiCurrentTokenCount; - } - else - { + } else { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "Not enough tokens in queue %zd Available %u\n", psSF-Adapter->PackInfo, psSF->uiCurrentTokenCount); psSF->uiPendedLast = 1; } - } - else - { + } else { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "IPAFF: Queue %zd not valid\n", psSF-Adapter->PackInfo); } BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TOKEN_COUNTS, DBG_LVL_ALL, "IsPacketAllowedForFlow <==="); @@ -122,23 +110,19 @@ static INT SendPacketFromQueue(struct bcm_mini_adapter *Adapter,/**"); - if (!Adapter || !Packet || !psSF) - { + if (!Adapter || !Packet || !psSF) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, SEND_QUEUE, DBG_LVL_ALL, "Got NULL Adapter or Packet"); return -EINVAL; } if (psSF->liDrainCalculated == 0) - { psSF->liDrainCalculated = jiffies; - } ///send the packet to the fifo.. PktLen = Packet->len; Status = SetupNextSend(Adapter, Packet, psSF->usVCID_Value); - if (Status == 0) - { - for (uiIndex = 0; uiIndex < MIBS_MAX_HIST_ENTRIES; uiIndex++) - { if ((PktLen <= MIBS_PKTSIZEHIST_RANGE*(uiIndex+1)) && (PktLen > MIBS_PKTSIZEHIST_RANGE*(uiIndex))) + if (Status == 0) { + for (uiIndex = 0; uiIndex < MIBS_MAX_HIST_ENTRIES; uiIndex++) { + if ((PktLen <= MIBS_PKTSIZEHIST_RANGE*(uiIndex+1)) && (PktLen > MIBS_PKTSIZEHIST_RANGE*(uiIndex))) Adapter->aTxPktSizeHist[uiIndex]++; } } @@ -167,8 +151,7 @@ static VOID CheckAndSendPacketFromIndex(struct bcm_mini_adapter *Adapter, struct BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "%zd ====>", (psSF-Adapter->PackInfo)); - if ((psSF != &Adapter->PackInfo[HiPriority]) && Adapter->LinkUpStatus && atomic_read(&psSF->uiPerSFTxResourceCount))//Get data packet - { + if ((psSF != &Adapter->PackInfo[HiPriority]) && Adapter->LinkUpStatus && atomic_read(&psSF->uiPerSFTxResourceCount)) { //Get data packet if (!psSF->ucDirection) return; @@ -177,8 +160,7 @@ static VOID CheckAndSendPacketFromIndex(struct bcm_mini_adapter *Adapter, struct return; /* in idle mode */ // Check for Free Descriptors - if (atomic_read(&Adapter->CurrNumFreeTxDesc) <= MINIMUM_PENDING_DESCRIPTORS) - { + if (atomic_read(&Adapter->CurrNumFreeTxDesc) <= MINIMUM_PENDING_DESCRIPTORS) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, " No Free Tx Descriptor(%d) is available for Data pkt..", atomic_read(&Adapter->CurrNumFreeTxDesc)); return; } @@ -186,8 +168,7 @@ static VOID CheckAndSendPacketFromIndex(struct bcm_mini_adapter *Adapter, struct spin_lock_bh(&psSF->SFQueueLock); QueuePacket = psSF->FirstTxQueue; - if (QueuePacket) - { + if (QueuePacket) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Dequeuing Data Packet"); if (psSF->bEthCSSupport) @@ -196,8 +177,7 @@ static VOID CheckAndSendPacketFromIndex(struct bcm_mini_adapter *Adapter, struct iPacketLen = QueuePacket->len-ETH_HLEN; iPacketLen <<= 3; - if (iPacketLen <= GetSFTokenCount(Adapter, psSF)) - { + if (iPacketLen <= GetSFTokenCount(Adapter, psSF)) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Allowed bytes %d", (iPacketLen >> 3)); @@ -209,9 +189,7 @@ static VOID CheckAndSendPacketFromIndex(struct bcm_mini_adapter *Adapter, struct Status = SendPacketFromQueue(Adapter, psSF, QueuePacket); psSF->uiPendedLast = FALSE; - } - else - { + } else { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "For Queue: %zd\n", psSF-Adapter->PackInfo); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "\nAvailable Tokens = %d required = %d\n", psSF->uiCurrentTokenCount, iPacketLen); @@ -221,28 +199,20 @@ static VOID CheckAndSendPacketFromIndex(struct bcm_mini_adapter *Adapter, struct psSF->uiPendedLast = TRUE; spin_unlock_bh(&psSF->SFQueueLock); } - } - else - { + } else { spin_unlock_bh(&psSF->SFQueueLock); } - } - else - { + } else { if ((atomic_read(&Adapter->CurrNumFreeTxDesc) > 0) && - (atomic_read(&Adapter->index_rd_txcntrlpkt) != - atomic_read(&Adapter->index_wr_txcntrlpkt)) - ) - { + (atomic_read(&Adapter->index_rd_txcntrlpkt) != + atomic_read(&Adapter->index_wr_txcntrlpkt))) { pControlPacket = Adapter->txctlpacket [(atomic_read(&Adapter->index_rd_txcntrlpkt)%MAX_CNTRL_PKTS)]; - if (pControlPacket) - { + if (pControlPacket) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Sending Control packet"); Status = SendControlPacket(Adapter, pControlPacket); - if (STATUS_SUCCESS == Status) - { + if (STATUS_SUCCESS == Status) { spin_lock_bh(&psSF->SFQueueLock); psSF->NumOfPacketsSent++; psSF->uiSentBytes += ((struct bcm_leader *)pControlPacket)->PLength; @@ -252,12 +222,10 @@ static VOID CheckAndSendPacketFromIndex(struct bcm_mini_adapter *Adapter, struct psSF->uiCurrentPacketsOnHost--; atomic_inc(&Adapter->index_rd_txcntrlpkt); spin_unlock_bh(&psSF->SFQueueLock); - } - else + } else { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "SendControlPacket Failed\n"); - } - else - { + } + } else { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, " Control Pkt is not available, Indexing is wrong...."); } } @@ -284,13 +252,11 @@ VOID transmit_packets(struct bcm_mini_adapter *Adapter) BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "=====>"); - if (NULL == Adapter) - { + if (NULL == Adapter) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Got NULL Adapter"); return; } - if (Adapter->device_removed == TRUE) - { + if (Adapter->device_removed == TRUE) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Device removed"); return; } @@ -305,34 +271,29 @@ VOID transmit_packets(struct bcm_mini_adapter *Adapter) uiPrevTotalCount = atomic_read(&Adapter->TotalPacketCount); - for (iIndex = HiPriority; iIndex >= 0; iIndex--) - { + for (iIndex = HiPriority; iIndex >= 0; iIndex--) { if (!uiPrevTotalCount || (TRUE == Adapter->device_removed)) break; if (Adapter->PackInfo[iIndex].bValid && - Adapter->PackInfo[iIndex].uiPendedLast && - Adapter->PackInfo[iIndex].uiCurrentBytesOnHost) - { + Adapter->PackInfo[iIndex].uiPendedLast && + Adapter->PackInfo[iIndex].uiCurrentBytesOnHost) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Calling CheckAndSendPacketFromIndex.."); CheckAndSendPacketFromIndex(Adapter, &Adapter->PackInfo[iIndex]); uiPrevTotalCount--; } } - while (uiPrevTotalCount > 0 && !Adapter->device_removed) - { + while (uiPrevTotalCount > 0 && !Adapter->device_removed) { exit_flag = TRUE; //second iteration to parse non-pending queues - for (iIndex = HiPriority; iIndex >= 0; iIndex--) - { + for (iIndex = HiPriority; iIndex >= 0; iIndex--) { if (!uiPrevTotalCount || (TRUE == Adapter->device_removed)) break; if (Adapter->PackInfo[iIndex].bValid && - Adapter->PackInfo[iIndex].uiCurrentBytesOnHost && - !Adapter->PackInfo[iIndex].uiPendedLast) - { + Adapter->PackInfo[iIndex].uiCurrentBytesOnHost && + !Adapter->PackInfo[iIndex].uiPendedLast) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "Calling CheckAndSendPacketFromIndex.."); CheckAndSendPacketFromIndex(Adapter, &Adapter->PackInfo[iIndex]); uiPrevTotalCount--; @@ -340,8 +301,7 @@ VOID transmit_packets(struct bcm_mini_adapter *Adapter) } } - if (Adapter->IdleMode || Adapter->bPreparingForLowPowerMode) - { + if (Adapter->IdleMode || Adapter->bPreparingForLowPowerMode) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "In Idle Mode\n"); break; } -- GitLab From ea20a1ec00c3c7a7e03cf7c4a7426262d6d7a102 Mon Sep 17 00:00:00 2001 From: Lilis Iskandar Date: Sun, 28 Jul 2013 03:34:45 +0800 Subject: [PATCH 326/942] Staging: bcm: LeakyBucket: Fixed C99 comments Fixed C99 comments Signed-off-by: Lilis Iskandar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/LeakyBucket.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/staging/bcm/LeakyBucket.c b/drivers/staging/bcm/LeakyBucket.c index 52e6e05831576..75d77c2e83d4b 100644 --- a/drivers/staging/bcm/LeakyBucket.c +++ b/drivers/staging/bcm/LeakyBucket.c @@ -117,7 +117,7 @@ static INT SendPacketFromQueue(struct bcm_mini_adapter *Adapter,/**liDrainCalculated == 0) psSF->liDrainCalculated = jiffies; - ///send the packet to the fifo.. + /* send the packet to the fifo.. */ PktLen = Packet->len; Status = SetupNextSend(Adapter, Packet, psSF->usVCID_Value); if (Status == 0) { @@ -151,7 +151,7 @@ static VOID CheckAndSendPacketFromIndex(struct bcm_mini_adapter *Adapter, struct BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "%zd ====>", (psSF-Adapter->PackInfo)); - if ((psSF != &Adapter->PackInfo[HiPriority]) && Adapter->LinkUpStatus && atomic_read(&psSF->uiPerSFTxResourceCount)) { //Get data packet + if ((psSF != &Adapter->PackInfo[HiPriority]) && Adapter->LinkUpStatus && atomic_read(&psSF->uiPerSFTxResourceCount)) { /* Get data packet */ if (!psSF->ucDirection) return; @@ -159,7 +159,7 @@ static VOID CheckAndSendPacketFromIndex(struct bcm_mini_adapter *Adapter, struct if (Adapter->IdleMode || Adapter->bPreparingForLowPowerMode) return; /* in idle mode */ - // Check for Free Descriptors + /* Check for Free Descriptors */ if (atomic_read(&Adapter->CurrNumFreeTxDesc) <= MINIMUM_PENDING_DESCRIPTORS) { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, " No Free Tx Descriptor(%d) is available for Data pkt..", atomic_read(&Adapter->CurrNumFreeTxDesc)); return; @@ -193,9 +193,11 @@ static VOID CheckAndSendPacketFromIndex(struct bcm_mini_adapter *Adapter, struct BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "For Queue: %zd\n", psSF-Adapter->PackInfo); BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "\nAvailable Tokens = %d required = %d\n", psSF->uiCurrentTokenCount, iPacketLen); - //this part indicates that because of non-availability of the tokens - //pkt has not been send out hence setting the pending flag indicating the host to send it out - //first next iteration . + /* + this part indicates that because of non-availability of the tokens + pkt has not been send out hence setting the pending flag indicating the host to send it out + first next iteration. + */ psSF->uiPendedLast = TRUE; spin_unlock_bh(&psSF->SFQueueLock); } @@ -286,7 +288,7 @@ VOID transmit_packets(struct bcm_mini_adapter *Adapter) while (uiPrevTotalCount > 0 && !Adapter->device_removed) { exit_flag = TRUE; - //second iteration to parse non-pending queues + /* second iteration to parse non-pending queues */ for (iIndex = HiPriority; iIndex >= 0; iIndex--) { if (!uiPrevTotalCount || (TRUE == Adapter->device_removed)) break; -- GitLab From 0a6765361c59a3d05818a1e658e917703538fa06 Mon Sep 17 00:00:00 2001 From: Lilis Iskandar Date: Sun, 28 Jul 2013 03:34:46 +0800 Subject: [PATCH 327/942] Staging: bcm: LeakyBucket: Fixed code indent issues Fixed code indent issues Signed-off-by: Lilis Iskandar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/LeakyBucket.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/bcm/LeakyBucket.c b/drivers/staging/bcm/LeakyBucket.c index 75d77c2e83d4b..fb18ae054ed10 100644 --- a/drivers/staging/bcm/LeakyBucket.c +++ b/drivers/staging/bcm/LeakyBucket.c @@ -187,7 +187,7 @@ static VOID CheckAndSendPacketFromIndex(struct bcm_mini_adapter *Adapter, struct atomic_dec(&Adapter->TotalPacketCount); spin_unlock_bh(&psSF->SFQueueLock); - Status = SendPacketFromQueue(Adapter, psSF, QueuePacket); + Status = SendPacketFromQueue(Adapter, psSF, QueuePacket); psSF->uiPendedLast = FALSE; } else { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, "For Queue: %zd\n", psSF-Adapter->PackInfo); @@ -230,7 +230,7 @@ static VOID CheckAndSendPacketFromIndex(struct bcm_mini_adapter *Adapter, struct } else { BCM_DEBUG_PRINT(Adapter, DBG_TYPE_TX, TX_PACKETS, DBG_LVL_ALL, " Control Pkt is not available, Indexing is wrong...."); } - } + } } } @@ -308,7 +308,7 @@ VOID transmit_packets(struct bcm_mini_adapter *Adapter) break; } if (exit_flag == TRUE) - break; + break; } /* end of inner while loop */ update_per_cid_rx(Adapter); -- GitLab From fd18e9febe24d14164f27fca1a6beb9527c77364 Mon Sep 17 00:00:00 2001 From: Lilis Iskandar Date: Sun, 28 Jul 2013 03:34:47 +0800 Subject: [PATCH 328/942] Staging: bcm: LeakyBucket: Fixed a pointer asterisk placement issue Fixed a pointer asterisk placement issue Signed-off-by: Lilis Iskandar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/LeakyBucket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/bcm/LeakyBucket.c b/drivers/staging/bcm/LeakyBucket.c index fb18ae054ed10..bc486163332d9 100644 --- a/drivers/staging/bcm/LeakyBucket.c +++ b/drivers/staging/bcm/LeakyBucket.c @@ -104,7 +104,7 @@ This function despatches packet from the specified queue. */ static INT SendPacketFromQueue(struct bcm_mini_adapter *Adapter,/** Date: Mon, 29 Jul 2013 20:07:41 +0300 Subject: [PATCH 329/942] staging: octeon-usb: depend on CAVIUM_OCTEON_SOC The USB driver should depend on SOC instead of CPU. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/octeon-usb/Kconfig b/drivers/staging/octeon-usb/Kconfig index 018af6db08c8e..16ea17ff3fd25 100644 --- a/drivers/staging/octeon-usb/Kconfig +++ b/drivers/staging/octeon-usb/Kconfig @@ -1,6 +1,6 @@ config OCTEON_USB tristate "Cavium Networks Octeon USB support" - depends on CPU_CAVIUM_OCTEON && USB + depends on CAVIUM_OCTEON_SOC && USB help This driver supports USB host controller on some Cavium Networks' products in the Octeon family. -- GitLab From f6ba63fce2ccf3f48d0d643bd93d32509c90cade Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Mon, 29 Jul 2013 20:07:42 +0300 Subject: [PATCH 330/942] staging: octeon-usb: use correct board type for EdgeRouter Lite Use CVMX_BOARD_TYPE_UBNT_E100 for EdgeRouter Lite. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/cvmx-usb.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/staging/octeon-usb/cvmx-usb.c b/drivers/staging/octeon-usb/cvmx-usb.c index bf366495fdd17..6c7bcf33ee342 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.c +++ b/drivers/staging/octeon-usb/cvmx-usb.c @@ -280,14 +280,9 @@ static int octeon_usb_get_clock_type(void) case CVMX_BOARD_TYPE_LANAI2_A: case CVMX_BOARD_TYPE_LANAI2_U: case CVMX_BOARD_TYPE_LANAI2_G: + case CVMX_BOARD_TYPE_UBNT_E100: return USB_CLOCK_TYPE_CRYSTAL_12; } - - /* FIXME: This should use CVMX_BOARD_TYPE_UBNT_E100 */ - if (OCTEON_IS_MODEL(OCTEON_CN50XX) && - cvmx_sysinfo_get()->board_type == 20002) - return USB_CLOCK_TYPE_CRYSTAL_12; - return USB_CLOCK_TYPE_REF_48; } -- GitLab From 1b50850d01f8996d0247ddc461eab372499d47c6 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Mon, 29 Jul 2013 20:07:43 +0300 Subject: [PATCH 331/942] staging: octeon-usb: cvmx-usb: delete driver-specific tracing code Delete call, parameter, and return value tracing. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/cvmx-usb.c | 325 +++++++------------------- 1 file changed, 87 insertions(+), 238 deletions(-) diff --git a/drivers/staging/octeon-usb/cvmx-usb.c b/drivers/staging/octeon-usb/cvmx-usb.c index 6c7bcf33ee342..6a1e14a37e3ea 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.c +++ b/drivers/staging/octeon-usb/cvmx-usb.c @@ -211,33 +211,6 @@ typedef struct { cvmx_usb_tx_fifo_t nonperiodic; } cvmx_usb_internal_state_t; -/* This macro logs out whenever a function is called if debugging is on */ -#define CVMX_USB_LOG_CALLED() \ - if (cvmx_unlikely(usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_DEBUG_CALLS)) \ - cvmx_dprintf("%*s%s: called\n", 2*usb->indent++, "", __FUNCTION__); - -/* This macro logs out each function parameter if debugging is on */ -#define CVMX_USB_LOG_PARAM(format, param) \ - if (cvmx_unlikely(usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_DEBUG_CALLS)) \ - cvmx_dprintf("%*s%s: param %s = " format "\n", 2*usb->indent, "", __FUNCTION__, #param, param); - -/* This macro logs out when a function returns a value */ -#define CVMX_USB_RETURN(v) \ - do { \ - typeof(v) r = v; \ - if (cvmx_unlikely(usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_DEBUG_CALLS)) \ - cvmx_dprintf("%*s%s: returned %s(%d)\n", 2*--usb->indent, "", __FUNCTION__, #v, r); \ - return r; \ - } while (0); - -/* This macro logs out when a function doesn't return a value */ -#define CVMX_USB_RETURN_NOTHING() \ - do { \ - if (cvmx_unlikely(usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_DEBUG_CALLS)) \ - cvmx_dprintf("%*s%s: returned\n", 2*--usb->indent, "", __FUNCTION__); \ - return; \ - } while (0); - /* This macro spins on a field waiting for it to reach a value */ #define CVMX_WAIT_FOR_FIELD32(address, type, field, op, value, timeout_usec)\ ({int result; \ @@ -574,20 +547,16 @@ cvmx_usb_status_t cvmx_usb_initialize(cvmx_usb_state_t *state, cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; usb->init_flags = flags; - CVMX_USB_LOG_CALLED(); - CVMX_USB_LOG_PARAM("%p", state); - CVMX_USB_LOG_PARAM("%d", usb_port_number); - CVMX_USB_LOG_PARAM("0x%x", flags); /* Make sure that state is large enough to store the internal state */ if (sizeof(*state) < sizeof(*usb)) - CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM); + return CVMX_USB_INVALID_PARAM; /* At first allow 0-1 for the usb port number */ if ((usb_port_number < 0) || (usb_port_number > 1)) - CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM); + return CVMX_USB_INVALID_PARAM; /* For all chips except 52XX there is only one port */ if (!OCTEON_IS_MODEL(OCTEON_CN52XX) && (usb_port_number > 0)) - CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM); + return CVMX_USB_INVALID_PARAM; /* Try to determine clock type automatically */ if ((flags & (CVMX_USB_INITIALIZE_FLAGS_CLOCK_XO_XI | CVMX_USB_INITIALIZE_FLAGS_CLOCK_XO_GND)) == 0) { @@ -611,7 +580,7 @@ cvmx_usb_status_t cvmx_usb_initialize(cvmx_usb_state_t *state, flags |= CVMX_USB_INITIALIZE_FLAGS_CLOCK_48MHZ; break; default: - CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM); + return CVMX_USB_INVALID_PARAM; break; } } @@ -847,7 +816,7 @@ cvmx_usb_status_t cvmx_usb_initialize(cvmx_usb_state_t *state, /* Steps 4-15 from the manual are done later in the port enable */ } - CVMX_USB_RETURN(CVMX_USB_SUCCESS); + return CVMX_USB_SUCCESS; } @@ -867,16 +836,13 @@ cvmx_usb_status_t cvmx_usb_shutdown(cvmx_usb_state_t *state) cvmx_usbnx_clk_ctl_t usbn_clk_ctl; cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; - CVMX_USB_LOG_CALLED(); - CVMX_USB_LOG_PARAM("%p", state); - /* Make sure all pipes are closed */ if (usb->idle_pipes.head || usb->active_pipes[CVMX_USB_TRANSFER_ISOCHRONOUS].head || usb->active_pipes[CVMX_USB_TRANSFER_INTERRUPT].head || usb->active_pipes[CVMX_USB_TRANSFER_CONTROL].head || usb->active_pipes[CVMX_USB_TRANSFER_BULK].head) - CVMX_USB_RETURN(CVMX_USB_BUSY); + return CVMX_USB_BUSY; /* Disable the clocks and put them in power on reset */ usbn_clk_ctl.u64 = __cvmx_usb_read_csr64(usb, CVMX_USBNX_CLK_CTL(usb->index)); @@ -887,7 +853,7 @@ cvmx_usb_status_t cvmx_usb_shutdown(cvmx_usb_state_t *state) usbn_clk_ctl.s.hrst = 0; __cvmx_usb_write_csr64(usb, CVMX_USBNX_CLK_CTL(usb->index), usbn_clk_ctl.u64); - CVMX_USB_RETURN(CVMX_USB_SUCCESS); + return CVMX_USB_SUCCESS; } @@ -906,21 +872,18 @@ cvmx_usb_status_t cvmx_usb_enable(cvmx_usb_state_t *state) cvmx_usbcx_ghwcfg3_t usbcx_ghwcfg3; cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; - CVMX_USB_LOG_CALLED(); - CVMX_USB_LOG_PARAM("%p", state); - usb->usbcx_hprt.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HPRT(usb->index)); /* If the port is already enabled the just return. We don't need to do anything */ if (usb->usbcx_hprt.s.prtena) - CVMX_USB_RETURN(CVMX_USB_SUCCESS); + return CVMX_USB_SUCCESS; /* If there is nothing plugged into the port then fail immediately */ if (!usb->usbcx_hprt.s.prtconnsts) { if (cvmx_unlikely(usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_DEBUG_INFO)) cvmx_dprintf("%s: USB%d Nothing plugged into the port\n", __FUNCTION__, usb->index); - CVMX_USB_RETURN(CVMX_USB_TIMEOUT); + return CVMX_USB_TIMEOUT; } /* Program the port reset bit to start the reset process */ @@ -939,7 +902,7 @@ cvmx_usb_status_t cvmx_usb_enable(cvmx_usb_state_t *state) if (cvmx_unlikely(usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_DEBUG_INFO)) cvmx_dprintf("%s: Timeout waiting for the port to finish reset\n", __FUNCTION__); - CVMX_USB_RETURN(CVMX_USB_TIMEOUT); + return CVMX_USB_TIMEOUT; } /* Read the port speed field to get the enumerated speed, USBC_HPRT[PRTSPD]. */ @@ -984,7 +947,7 @@ cvmx_usb_status_t cvmx_usb_enable(cvmx_usb_state_t *state) CVMX_WAIT_FOR_FIELD32(CVMX_USBCX_GRSTCTL(usb->index), cvmx_usbcx_grstctl_t, rxfflsh, ==, 0, 100); - CVMX_USB_RETURN(CVMX_USB_SUCCESS); + return CVMX_USB_SUCCESS; } @@ -1004,12 +967,9 @@ cvmx_usb_status_t cvmx_usb_disable(cvmx_usb_state_t *state) { cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; - CVMX_USB_LOG_CALLED(); - CVMX_USB_LOG_PARAM("%p", state); - /* Disable the port */ USB_SET_FIELD32(CVMX_USBCX_HPRT(usb->index), cvmx_usbcx_hprt_t, prtena, 1); - CVMX_USB_RETURN(CVMX_USB_SUCCESS); + return CVMX_USB_SUCCESS; } @@ -1035,9 +995,6 @@ cvmx_usb_port_status_t cvmx_usb_get_status(cvmx_usb_state_t *state) memset(&result, 0, sizeof(result)); - CVMX_USB_LOG_CALLED(); - CVMX_USB_LOG_PARAM("%p", state); - usbc_hprt.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HPRT(usb->index)); result.port_enabled = usbc_hprt.s.prtena; result.port_over_current = usbc_hprt.s.prtovrcurract; @@ -1074,10 +1031,8 @@ cvmx_usb_port_status_t cvmx_usb_get_status(cvmx_usb_state_t *state) void cvmx_usb_set_status(cvmx_usb_state_t *state, cvmx_usb_port_status_t port_status) { cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; - CVMX_USB_LOG_CALLED(); - CVMX_USB_LOG_PARAM("%p", state); usb->port_status = port_status; - CVMX_USB_RETURN_NOTHING(); + return; } @@ -1183,51 +1138,37 @@ int cvmx_usb_open_pipe(cvmx_usb_state_t *state, cvmx_usb_pipe_flags_t flags, cvmx_usb_pipe_t *pipe; cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; - CVMX_USB_LOG_CALLED(); - CVMX_USB_LOG_PARAM("%p", state); - CVMX_USB_LOG_PARAM("0x%x", flags); - CVMX_USB_LOG_PARAM("%d", device_addr); - CVMX_USB_LOG_PARAM("%d", endpoint_num); - CVMX_USB_LOG_PARAM("%d", device_speed); - CVMX_USB_LOG_PARAM("%d", max_packet); - CVMX_USB_LOG_PARAM("%d", transfer_type); - CVMX_USB_LOG_PARAM("%d", transfer_dir); - CVMX_USB_LOG_PARAM("%d", interval); - CVMX_USB_LOG_PARAM("%d", multi_count); - CVMX_USB_LOG_PARAM("%d", hub_device_addr); - CVMX_USB_LOG_PARAM("%d", hub_port); - if (cvmx_unlikely((device_addr < 0) || (device_addr > MAX_USB_ADDRESS))) - CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM); + return CVMX_USB_INVALID_PARAM; if (cvmx_unlikely((endpoint_num < 0) || (endpoint_num > MAX_USB_ENDPOINT))) - CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM); + return CVMX_USB_INVALID_PARAM; if (cvmx_unlikely(device_speed > CVMX_USB_SPEED_LOW)) - CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM); + return CVMX_USB_INVALID_PARAM; if (cvmx_unlikely((max_packet <= 0) || (max_packet > 1024))) - CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM); + return CVMX_USB_INVALID_PARAM; if (cvmx_unlikely(transfer_type > CVMX_USB_TRANSFER_INTERRUPT)) - CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM); + return CVMX_USB_INVALID_PARAM; if (cvmx_unlikely((transfer_dir != CVMX_USB_DIRECTION_OUT) && (transfer_dir != CVMX_USB_DIRECTION_IN))) - CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM); + return CVMX_USB_INVALID_PARAM; if (cvmx_unlikely(interval < 0)) - CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM); + return CVMX_USB_INVALID_PARAM; if (cvmx_unlikely((transfer_type == CVMX_USB_TRANSFER_CONTROL) && interval)) - CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM); + return CVMX_USB_INVALID_PARAM; if (cvmx_unlikely(multi_count < 0)) - CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM); + return CVMX_USB_INVALID_PARAM; if (cvmx_unlikely((device_speed != CVMX_USB_SPEED_HIGH) && (multi_count != 0))) - CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM); + return CVMX_USB_INVALID_PARAM; if (cvmx_unlikely((hub_device_addr < 0) || (hub_device_addr > MAX_USB_ADDRESS))) - CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM); + return CVMX_USB_INVALID_PARAM; if (cvmx_unlikely((hub_port < 0) || (hub_port > MAX_USB_HUB_PORT))) - CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM); + return CVMX_USB_INVALID_PARAM; /* Find a free pipe */ pipe = usb->free_pipes.head; if (!pipe) - CVMX_USB_RETURN(CVMX_USB_NO_MEMORY); + return CVMX_USB_NO_MEMORY; __cvmx_usb_remove_pipe(&usb->free_pipes, pipe); pipe->flags = flags | __CVMX_USB_PIPE_FLAGS_OPEN; if ((device_speed == CVMX_USB_SPEED_HIGH) && @@ -1263,7 +1204,7 @@ int cvmx_usb_open_pipe(cvmx_usb_state_t *state, cvmx_usb_pipe_flags_t flags, /* We don't need to tell the hardware about this pipe yet since it doesn't have any submitted requests */ - CVMX_USB_RETURN(__cvmx_usb_get_pipe_handle(usb, pipe)); + return __cvmx_usb_get_pipe_handle(usb, pipe); } @@ -1284,21 +1225,18 @@ static void __cvmx_usb_poll_rx_fifo(cvmx_usb_internal_state_t *usb) uint64_t address; uint32_t *ptr; - CVMX_USB_LOG_CALLED(); - CVMX_USB_LOG_PARAM("%p", usb); - rx_status.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_GRXSTSPH(usb->index)); /* Only read data if IN data is there */ if (rx_status.s.pktsts != 2) - CVMX_USB_RETURN_NOTHING(); + return; /* Check if no data is available */ if (!rx_status.s.bcnt) - CVMX_USB_RETURN_NOTHING(); + return; channel = rx_status.s.chnum; bytes = rx_status.s.bcnt; if (!bytes) - CVMX_USB_RETURN_NOTHING(); + return; /* Get where the DMA engine would have written this data */ address = __cvmx_usb_read_csr64(usb, CVMX_USBNX_DMA0_INB_CHN0(usb->index) + channel*8); @@ -1312,7 +1250,7 @@ static void __cvmx_usb_poll_rx_fifo(cvmx_usb_internal_state_t *usb) } CVMX_SYNCW; - CVMX_USB_RETURN_NOTHING(); + return; } @@ -1330,11 +1268,6 @@ static void __cvmx_usb_poll_rx_fifo(cvmx_usb_internal_state_t *usb) */ static int __cvmx_usb_fill_tx_hw(cvmx_usb_internal_state_t *usb, cvmx_usb_tx_fifo_t *fifo, int available) { - CVMX_USB_LOG_CALLED(); - CVMX_USB_LOG_PARAM("%p", usb); - CVMX_USB_LOG_PARAM("%p", fifo); - CVMX_USB_LOG_PARAM("%d", available); - /* We're done either when there isn't anymore space or the software FIFO is empty */ while (available && (fifo->head != fifo->tail)) { @@ -1373,7 +1306,7 @@ static int __cvmx_usb_fill_tx_hw(cvmx_usb_internal_state_t *usb, cvmx_usb_tx_fif } cvmx_read64_uint64(CVMX_USBNX_DMA0_INB_CHN0(usb->index)); } - CVMX_USB_RETURN(fifo->head != fifo->tail); + return fifo->head != fifo->tail; } @@ -1385,9 +1318,6 @@ static int __cvmx_usb_fill_tx_hw(cvmx_usb_internal_state_t *usb, cvmx_usb_tx_fif */ static void __cvmx_usb_poll_tx_fifo(cvmx_usb_internal_state_t *usb) { - CVMX_USB_LOG_CALLED(); - CVMX_USB_LOG_PARAM("%p", usb); - if (usb->periodic.head != usb->periodic.tail) { cvmx_usbcx_hptxsts_t tx_status; tx_status.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HPTXSTS(usb->index)); @@ -1406,7 +1336,7 @@ static void __cvmx_usb_poll_tx_fifo(cvmx_usb_internal_state_t *usb) USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), cvmx_usbcx_gintmsk_t, nptxfempmsk, 0); } - CVMX_USB_RETURN_NOTHING(); + return; } @@ -1425,24 +1355,20 @@ static void __cvmx_usb_fill_tx_fifo(cvmx_usb_internal_state_t *usb, int channel) cvmx_usbcx_hctsizx_t usbc_hctsiz; cvmx_usb_tx_fifo_t *fifo; - CVMX_USB_LOG_CALLED(); - CVMX_USB_LOG_PARAM("%p", usb); - CVMX_USB_LOG_PARAM("%d", channel); - /* We only need to fill data on outbound channels */ hcchar.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCCHARX(channel, usb->index)); if (hcchar.s.epdir != CVMX_USB_DIRECTION_OUT) - CVMX_USB_RETURN_NOTHING(); + return; /* OUT Splits only have data on the start and not the complete */ usbc_hcsplt.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCSPLTX(channel, usb->index)); if (usbc_hcsplt.s.spltena && usbc_hcsplt.s.compsplt) - CVMX_USB_RETURN_NOTHING(); + return; /* Find out how many bytes we need to fill and convert it into 32bit words */ usbc_hctsiz.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCTSIZX(channel, usb->index)); if (!usbc_hctsiz.s.xfersize) - CVMX_USB_RETURN_NOTHING(); + return; if ((hcchar.s.eptype == CVMX_USB_TRANSFER_INTERRUPT) || (hcchar.s.eptype == CVMX_USB_TRANSFER_ISOCHRONOUS)) @@ -1459,7 +1385,7 @@ static void __cvmx_usb_fill_tx_fifo(cvmx_usb_internal_state_t *usb, int channel) __cvmx_usb_poll_tx_fifo(usb); - CVMX_USB_RETURN_NOTHING(); + return; } /** @@ -1483,11 +1409,6 @@ static void __cvmx_usb_start_channel_control(cvmx_usb_internal_state_t *usb, int packets_to_transfer; cvmx_usbcx_hctsizx_t usbc_hctsiz; - CVMX_USB_LOG_CALLED(); - CVMX_USB_LOG_PARAM("%p", usb); - CVMX_USB_LOG_PARAM("%d", channel); - CVMX_USB_LOG_PARAM("%p", pipe); - usbc_hctsiz.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCTSIZX(channel, usb->index)); switch (transaction->stage) { @@ -1586,7 +1507,7 @@ static void __cvmx_usb_start_channel_control(cvmx_usb_internal_state_t *usb, usbc_hctsiz.s.pktcnt = packets_to_transfer; __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCTSIZX(channel, usb->index), usbc_hctsiz.u32); - CVMX_USB_RETURN_NOTHING(); + return; } @@ -1605,11 +1526,6 @@ static void __cvmx_usb_start_channel(cvmx_usb_internal_state_t *usb, { cvmx_usb_transaction_t *transaction = pipe->head; - CVMX_USB_LOG_CALLED(); - CVMX_USB_LOG_PARAM("%p", usb); - CVMX_USB_LOG_PARAM("%d", channel); - CVMX_USB_LOG_PARAM("%p", pipe); - if (cvmx_unlikely((usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_DEBUG_TRANSFERS) || (pipe->flags & CVMX_USB_PIPE_FLAGS_DEBUG_TRANSFERS))) cvmx_dprintf("%s: Channel %d started. Pipe %d transaction %d stage %d\n", @@ -1843,7 +1759,7 @@ static void __cvmx_usb_start_channel(cvmx_usb_internal_state_t *usb, USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index), cvmx_usbcx_hccharx_t, chena, 1); if (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA) __cvmx_usb_fill_tx_fifo(usb, channel); - CVMX_USB_RETURN_NOTHING(); + return; } @@ -1892,9 +1808,6 @@ static void __cvmx_usb_schedule(cvmx_usb_internal_state_t *usb, int is_sof) int need_sof; cvmx_usb_transfer_t ttype; - CVMX_USB_LOG_CALLED(); - CVMX_USB_LOG_PARAM("%p", usb); - if (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA) { /* Without DMA we need to be careful to not schedule something at the end of a frame and cause an overrun */ cvmx_usbcx_hfnum_t hfnum = {.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HFNUM(usb->index))}; @@ -1931,9 +1844,6 @@ static void __cvmx_usb_schedule(cvmx_usb_internal_state_t *usb, int is_sof) if (!pipe) break; - CVMX_USB_LOG_PARAM("%d", channel); - CVMX_USB_LOG_PARAM("%p", pipe); - if (cvmx_unlikely((usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_DEBUG_TRANSFERS) || (pipe->flags & CVMX_USB_PIPE_FLAGS_DEBUG_TRANSFERS))) { cvmx_usb_transaction_t *transaction = pipe->head; @@ -1980,7 +1890,7 @@ static void __cvmx_usb_schedule(cvmx_usb_internal_state_t *usb, int is_sof) } } USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), cvmx_usbcx_gintmsk_t, sofmsk, need_sof); - CVMX_USB_RETURN_NOTHING(); + return; } @@ -2059,12 +1969,6 @@ static void __cvmx_usb_perform_complete(cvmx_usb_internal_state_t * usb, cvmx_usb_transaction_t *transaction, cvmx_usb_complete_t complete_code) { - CVMX_USB_LOG_CALLED(); - CVMX_USB_LOG_PARAM("%p", usb); - CVMX_USB_LOG_PARAM("%p", pipe); - CVMX_USB_LOG_PARAM("%p", transaction); - CVMX_USB_LOG_PARAM("%d", complete_code); - /* If this was a split then clear our split in progress marker */ if (usb->active_split == transaction) usb->active_split = NULL; @@ -2106,7 +2010,7 @@ static void __cvmx_usb_perform_complete(cvmx_usb_internal_state_t * usb, complete_code); __cvmx_usb_free_transaction(usb, transaction); done: - CVMX_USB_RETURN_NOTHING(); + return; } @@ -2154,18 +2058,17 @@ static int __cvmx_usb_submit_transaction(cvmx_usb_internal_state_t *usb, cvmx_usb_transaction_t *transaction; cvmx_usb_pipe_t *pipe = usb->pipe + pipe_handle; - CVMX_USB_LOG_CALLED(); if (cvmx_unlikely((pipe_handle < 0) || (pipe_handle >= MAX_PIPES))) - CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM); + return CVMX_USB_INVALID_PARAM; /* Fail if the pipe isn't open */ if (cvmx_unlikely((pipe->flags & __CVMX_USB_PIPE_FLAGS_OPEN) == 0)) - CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM); + return CVMX_USB_INVALID_PARAM; if (cvmx_unlikely(pipe->transfer_type != type)) - CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM); + return CVMX_USB_INVALID_PARAM; transaction = __cvmx_usb_alloc_transaction(usb); if (cvmx_unlikely(!transaction)) - CVMX_USB_RETURN(CVMX_USB_NO_MEMORY); + return CVMX_USB_NO_MEMORY; transaction->type = type; transaction->flags |= flags; @@ -2204,7 +2107,7 @@ static int __cvmx_usb_submit_transaction(cvmx_usb_internal_state_t *usb, if (!transaction->prev) __cvmx_usb_schedule(usb, 0); - CVMX_USB_RETURN(submit_handle); + return submit_handle; } @@ -2247,17 +2150,11 @@ int cvmx_usb_submit_bulk(cvmx_usb_state_t *state, int pipe_handle, int submit_handle; cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; - CVMX_USB_LOG_CALLED(); - CVMX_USB_LOG_PARAM("%p", state); - CVMX_USB_LOG_PARAM("%d", pipe_handle); - CVMX_USB_LOG_PARAM("0x%llx", (unsigned long long)buffer); - CVMX_USB_LOG_PARAM("%d", buffer_length); - /* Pipe handle checking is done later in a common place */ if (cvmx_unlikely(!buffer)) - CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM); + return CVMX_USB_INVALID_PARAM; if (cvmx_unlikely(buffer_length < 0)) - CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM); + return CVMX_USB_INVALID_PARAM; submit_handle = __cvmx_usb_submit_transaction(usb, pipe_handle, CVMX_USB_TRANSFER_BULK, @@ -2270,7 +2167,7 @@ int cvmx_usb_submit_bulk(cvmx_usb_state_t *state, int pipe_handle, NULL, /* iso_packets */ callback, user_data); - CVMX_USB_RETURN(submit_handle); + return submit_handle; } @@ -2313,17 +2210,11 @@ int cvmx_usb_submit_interrupt(cvmx_usb_state_t *state, int pipe_handle, int submit_handle; cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; - CVMX_USB_LOG_CALLED(); - CVMX_USB_LOG_PARAM("%p", state); - CVMX_USB_LOG_PARAM("%d", pipe_handle); - CVMX_USB_LOG_PARAM("0x%llx", (unsigned long long)buffer); - CVMX_USB_LOG_PARAM("%d", buffer_length); - /* Pipe handle checking is done later in a common place */ if (cvmx_unlikely(!buffer)) - CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM); + return CVMX_USB_INVALID_PARAM; if (cvmx_unlikely(buffer_length < 0)) - CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM); + return CVMX_USB_INVALID_PARAM; submit_handle = __cvmx_usb_submit_transaction(usb, pipe_handle, CVMX_USB_TRANSFER_INTERRUPT, @@ -2336,7 +2227,7 @@ int cvmx_usb_submit_interrupt(cvmx_usb_state_t *state, int pipe_handle, NULL, /* iso_packets */ callback, user_data); - CVMX_USB_RETURN(submit_handle); + return submit_handle; } @@ -2385,21 +2276,14 @@ int cvmx_usb_submit_control(cvmx_usb_state_t *state, int pipe_handle, cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; cvmx_usb_control_header_t *header = cvmx_phys_to_ptr(control_header); - CVMX_USB_LOG_CALLED(); - CVMX_USB_LOG_PARAM("%p", state); - CVMX_USB_LOG_PARAM("%d", pipe_handle); - CVMX_USB_LOG_PARAM("0x%llx", (unsigned long long)control_header); - CVMX_USB_LOG_PARAM("0x%llx", (unsigned long long)buffer); - CVMX_USB_LOG_PARAM("%d", buffer_length); - /* Pipe handle checking is done later in a common place */ if (cvmx_unlikely(!control_header)) - CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM); + return CVMX_USB_INVALID_PARAM; /* Some drivers send a buffer with a zero length. God only knows why */ if (cvmx_unlikely(buffer && (buffer_length < 0))) - CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM); + return CVMX_USB_INVALID_PARAM; if (cvmx_unlikely(!buffer && (buffer_length != 0))) - CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM); + return CVMX_USB_INVALID_PARAM; if ((header->s.request_type & 0x80) == 0) buffer_length = cvmx_le16_to_cpu(header->s.length); @@ -2414,7 +2298,7 @@ int cvmx_usb_submit_control(cvmx_usb_state_t *state, int pipe_handle, NULL, /* iso_packets */ callback, user_data); - CVMX_USB_RETURN(submit_handle); + return submit_handle; } @@ -2474,29 +2358,19 @@ int cvmx_usb_submit_isochronous(cvmx_usb_state_t *state, int pipe_handle, int submit_handle; cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; - CVMX_USB_LOG_CALLED(); - CVMX_USB_LOG_PARAM("%p", state); - CVMX_USB_LOG_PARAM("%d", pipe_handle); - CVMX_USB_LOG_PARAM("%d", start_frame); - CVMX_USB_LOG_PARAM("0x%x", flags); - CVMX_USB_LOG_PARAM("%d", number_packets); - CVMX_USB_LOG_PARAM("%p", packets); - CVMX_USB_LOG_PARAM("0x%llx", (unsigned long long)buffer); - CVMX_USB_LOG_PARAM("%d", buffer_length); - /* Pipe handle checking is done later in a common place */ if (cvmx_unlikely(start_frame < 0)) - CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM); + return CVMX_USB_INVALID_PARAM; if (cvmx_unlikely(flags & ~(CVMX_USB_ISOCHRONOUS_FLAGS_ALLOW_SHORT | CVMX_USB_ISOCHRONOUS_FLAGS_ASAP))) - CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM); + return CVMX_USB_INVALID_PARAM; if (cvmx_unlikely(number_packets < 1)) - CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM); + return CVMX_USB_INVALID_PARAM; if (cvmx_unlikely(!packets)) - CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM); + return CVMX_USB_INVALID_PARAM; if (cvmx_unlikely(!buffer)) - CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM); + return CVMX_USB_INVALID_PARAM; if (cvmx_unlikely(buffer_length < 0)) - CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM); + return CVMX_USB_INVALID_PARAM; submit_handle = __cvmx_usb_submit_transaction(usb, pipe_handle, CVMX_USB_TRANSFER_ISOCHRONOUS, @@ -2509,7 +2383,7 @@ int cvmx_usb_submit_isochronous(cvmx_usb_state_t *state, int pipe_handle, packets, callback, user_data); - CVMX_USB_RETURN(submit_handle); + return submit_handle; } @@ -2537,25 +2411,20 @@ cvmx_usb_status_t cvmx_usb_cancel(cvmx_usb_state_t *state, int pipe_handle, cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; cvmx_usb_pipe_t *pipe = usb->pipe + pipe_handle; - CVMX_USB_LOG_CALLED(); - CVMX_USB_LOG_PARAM("%p", state); - CVMX_USB_LOG_PARAM("%d", pipe_handle); - CVMX_USB_LOG_PARAM("%d", submit_handle); - if (cvmx_unlikely((pipe_handle < 0) || (pipe_handle >= MAX_PIPES))) - CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM); + return CVMX_USB_INVALID_PARAM; if (cvmx_unlikely((submit_handle < 0) || (submit_handle >= MAX_TRANSACTIONS))) - CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM); + return CVMX_USB_INVALID_PARAM; /* Fail if the pipe isn't open */ if (cvmx_unlikely((pipe->flags & __CVMX_USB_PIPE_FLAGS_OPEN) == 0)) - CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM); + return CVMX_USB_INVALID_PARAM; transaction = usb->transaction + submit_handle; /* Fail if this transaction already completed */ if (cvmx_unlikely((transaction->flags & __CVMX_USB_TRANSACTION_FLAGS_IN_USE) == 0)) - CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM); + return CVMX_USB_INVALID_PARAM; /* If the transaction is the HEAD of the queue and scheduled. We need to treat it special */ @@ -2576,7 +2445,7 @@ cvmx_usb_status_t cvmx_usb_cancel(cvmx_usb_state_t *state, int pipe_handle, } } __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_CANCEL); - CVMX_USB_RETURN(CVMX_USB_SUCCESS); + return CVMX_USB_SUCCESS; } @@ -2597,24 +2466,21 @@ cvmx_usb_status_t cvmx_usb_cancel_all(cvmx_usb_state_t *state, int pipe_handle) cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; cvmx_usb_pipe_t *pipe = usb->pipe + pipe_handle; - CVMX_USB_LOG_CALLED(); - CVMX_USB_LOG_PARAM("%p", state); - CVMX_USB_LOG_PARAM("%d", pipe_handle); if (cvmx_unlikely((pipe_handle < 0) || (pipe_handle >= MAX_PIPES))) - CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM); + return CVMX_USB_INVALID_PARAM; /* Fail if the pipe isn't open */ if (cvmx_unlikely((pipe->flags & __CVMX_USB_PIPE_FLAGS_OPEN) == 0)) - CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM); + return CVMX_USB_INVALID_PARAM; /* Simply loop through and attempt to cancel each transaction */ while (pipe->head) { cvmx_usb_status_t result = cvmx_usb_cancel(state, pipe_handle, __cvmx_usb_get_submit_handle(usb, pipe->head)); if (cvmx_unlikely(result != CVMX_USB_SUCCESS)) - CVMX_USB_RETURN(result); + return result; } - CVMX_USB_RETURN(CVMX_USB_SUCCESS); + return CVMX_USB_SUCCESS; } @@ -2635,25 +2501,22 @@ cvmx_usb_status_t cvmx_usb_close_pipe(cvmx_usb_state_t *state, int pipe_handle) cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; cvmx_usb_pipe_t *pipe = usb->pipe + pipe_handle; - CVMX_USB_LOG_CALLED(); - CVMX_USB_LOG_PARAM("%p", state); - CVMX_USB_LOG_PARAM("%d", pipe_handle); if (cvmx_unlikely((pipe_handle < 0) || (pipe_handle >= MAX_PIPES))) - CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM); + return CVMX_USB_INVALID_PARAM; /* Fail if the pipe isn't open */ if (cvmx_unlikely((pipe->flags & __CVMX_USB_PIPE_FLAGS_OPEN) == 0)) - CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM); + return CVMX_USB_INVALID_PARAM; /* Fail if the pipe has pending transactions */ if (cvmx_unlikely(pipe->head)) - CVMX_USB_RETURN(CVMX_USB_BUSY); + return CVMX_USB_BUSY; pipe->flags = 0; __cvmx_usb_remove_pipe(&usb->idle_pipes, pipe); __cvmx_usb_append_pipe(&usb->free_pipes, pipe); - CVMX_USB_RETURN(CVMX_USB_SUCCESS); + return CVMX_USB_SUCCESS; } @@ -2676,20 +2539,15 @@ cvmx_usb_status_t cvmx_usb_register_callback(cvmx_usb_state_t *state, { cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; - CVMX_USB_LOG_CALLED(); - CVMX_USB_LOG_PARAM("%p", state); - CVMX_USB_LOG_PARAM("%d", reason); - CVMX_USB_LOG_PARAM("%p", callback); - CVMX_USB_LOG_PARAM("%p", user_data); if (cvmx_unlikely(reason >= __CVMX_USB_CALLBACK_END)) - CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM); + return CVMX_USB_INVALID_PARAM; if (cvmx_unlikely(!callback)) - CVMX_USB_RETURN(CVMX_USB_INVALID_PARAM); + return CVMX_USB_INVALID_PARAM; usb->callback[reason] = callback; usb->callback_data[reason] = user_data; - CVMX_USB_RETURN(CVMX_USB_SUCCESS); + return CVMX_USB_SUCCESS; } @@ -2708,13 +2566,10 @@ int cvmx_usb_get_frame_number(cvmx_usb_state_t *state) cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; cvmx_usbcx_hfnum_t usbc_hfnum; - CVMX_USB_LOG_CALLED(); - CVMX_USB_LOG_PARAM("%p", state); - usbc_hfnum.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HFNUM(usb->index)); frame_number = usbc_hfnum.s.frnum; - CVMX_USB_RETURN(frame_number); + return frame_number; } @@ -2738,9 +2593,6 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel) int bytes_in_last_packet; int packets_processed; int buffer_space_left; - CVMX_USB_LOG_CALLED(); - CVMX_USB_LOG_PARAM("%p", usb); - CVMX_USB_LOG_PARAM("%d", channel); /* Read the interrupt status bits for the channel */ usbc_hcint.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCINTX(channel, usb->index)); @@ -2753,7 +2605,7 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel) IN transfers to get stuck until we do a write of HCCHARX without changing things */ __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCCHARX(channel, usb->index), usbc_hcchar.u32); - CVMX_USB_RETURN(0); + return 0; } /* In non DMA mode the channels don't halt themselves. We need to @@ -2767,14 +2619,14 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel) __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCINTMSKX(channel, usb->index), hcintmsk.u32); usbc_hcchar.s.chdis = 1; __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCCHARX(channel, usb->index), usbc_hcchar.u32); - CVMX_USB_RETURN(0); + return 0; } else if (usbc_hcint.s.xfercompl) { /* Successful IN/OUT with transfer complete. Channel halt isn't needed */ } else { cvmx_dprintf("USB%d: Channel %d interrupt without halt\n", usb->index, channel); - CVMX_USB_RETURN(0); + return 0; } } } @@ -2782,7 +2634,7 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel) /* There is are no interrupts that we need to process when the channel is still running */ if (!usbc_hcint.s.chhltd) - CVMX_USB_RETURN(0); + return 0; } /* Disable the channel interrupts now that it is done */ @@ -2794,7 +2646,7 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel) CVMX_PREFETCH(pipe, 0); CVMX_PREFETCH(pipe, 128); if (!pipe) - CVMX_USB_RETURN(0); + return 0; transaction = pipe->head; CVMX_PREFETCH0(transaction); @@ -3118,7 +2970,7 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel) __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_ERROR); } } - CVMX_USB_RETURN(0); + return 0; } @@ -3146,9 +2998,6 @@ cvmx_usb_status_t cvmx_usb_poll(cvmx_usb_state_t *state) CVMX_PREFETCH(usb, 3*128); CVMX_PREFETCH(usb, 4*128); - CVMX_USB_LOG_CALLED(); - CVMX_USB_LOG_PARAM("%p", state); - /* Update the frame counter */ usbc_hfnum.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HFNUM(usb->index)); if ((usb->frame_number&0x3fff) > usbc_hfnum.s.frnum) @@ -3220,5 +3069,5 @@ cvmx_usb_status_t cvmx_usb_poll(cvmx_usb_state_t *state) __cvmx_usb_schedule(usb, usbc_gintsts.s.sof); - CVMX_USB_RETURN(CVMX_USB_SUCCESS); + return CVMX_USB_SUCCESS; } -- GitLab From a7c679482d9f548e6ec3cfba35472ed6afb13274 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Mon, 29 Jul 2013 20:07:44 +0300 Subject: [PATCH 332/942] staging: octeon-usb: cvmx-usb: delete redundant debug flags Delete redudant debug flags and dead code behind them. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/cvmx-usb.c | 87 +-------------------------- drivers/staging/octeon-usb/cvmx-usb.h | 7 --- 2 files changed, 2 insertions(+), 92 deletions(-) diff --git a/drivers/staging/octeon-usb/cvmx-usb.c b/drivers/staging/octeon-usb/cvmx-usb.c index 6a1e14a37e3ea..dd8653c9e5e3a 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.c +++ b/drivers/staging/octeon-usb/cvmx-usb.c @@ -439,8 +439,6 @@ static inline cvmx_usb_transaction_t *__cvmx_usb_alloc_transaction(cvmx_usb_inte if (!usb->free_transaction_head) usb->free_transaction_tail = NULL; } - else if (cvmx_unlikely(usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_DEBUG_INFO)) - cvmx_dprintf("%s: Failed to allocate a transaction\n", __FUNCTION__); if (t) { memset(t, 0, sizeof(*t)); t->flags = __CVMX_USB_TRANSACTION_FLAGS_IN_USE; @@ -791,8 +789,6 @@ cvmx_usb_status_t cvmx_usb_initialize(cvmx_usb_state_t *state, { /* Host Port Initialization */ - if (cvmx_unlikely(usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_DEBUG_INFO)) - cvmx_dprintf("%s: USB%d is in host mode\n", __FUNCTION__, usb->index); /* 1. Program the host-port interrupt-mask field to unmask, USBC_GINTMSK[PRTINT] = 1 */ @@ -881,8 +877,6 @@ cvmx_usb_status_t cvmx_usb_enable(cvmx_usb_state_t *state) /* If there is nothing plugged into the port then fail immediately */ if (!usb->usbcx_hprt.s.prtconnsts) { - if (cvmx_unlikely(usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_DEBUG_INFO)) - cvmx_dprintf("%s: USB%d Nothing plugged into the port\n", __FUNCTION__, usb->index); return CVMX_USB_TIMEOUT; } @@ -898,21 +892,11 @@ cvmx_usb_status_t cvmx_usb_enable(cvmx_usb_state_t *state) /* Wait for the USBC_HPRT[PRTENA]. */ if (CVMX_WAIT_FOR_FIELD32(CVMX_USBCX_HPRT(usb->index), cvmx_usbcx_hprt_t, - prtena, ==, 1, 100000)) { - if (cvmx_unlikely(usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_DEBUG_INFO)) - cvmx_dprintf("%s: Timeout waiting for the port to finish reset\n", - __FUNCTION__); + prtena, ==, 1, 100000)) return CVMX_USB_TIMEOUT; - } /* Read the port speed field to get the enumerated speed, USBC_HPRT[PRTSPD]. */ usb->usbcx_hprt.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HPRT(usb->index)); - if (cvmx_unlikely(usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_DEBUG_INFO)) - cvmx_dprintf("%s: USB%d is in %s speed mode\n", __FUNCTION__, usb->index, - (usb->usbcx_hprt.s.prtspd == CVMX_USB_SPEED_HIGH) ? "high" : - (usb->usbcx_hprt.s.prtspd == CVMX_USB_SPEED_FULL) ? "full" : - "low"); - usbcx_ghwcfg3.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_GHWCFG3(usb->index)); /* 13. Program the USBC_GRXFSIZ register to select the size of the receive @@ -1003,15 +987,6 @@ cvmx_usb_port_status_t cvmx_usb_get_status(cvmx_usb_state_t *state) result.connected = usbc_hprt.s.prtconnsts; result.connect_change = (result.connected != usb->port_status.connected); - if (cvmx_unlikely(usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_DEBUG_CALLS)) - cvmx_dprintf("%*s%s: returned port enabled=%d, over_current=%d, powered=%d, speed=%d, connected=%d, connect_change=%d\n", - 2*(--usb->indent), "", __FUNCTION__, - result.port_enabled, - result.port_over_current, - result.port_powered, - result.port_speed, - result.connected, - result.connect_change); return result; } @@ -1526,13 +1501,6 @@ static void __cvmx_usb_start_channel(cvmx_usb_internal_state_t *usb, { cvmx_usb_transaction_t *transaction = pipe->head; - if (cvmx_unlikely((usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_DEBUG_TRANSFERS) || - (pipe->flags & CVMX_USB_PIPE_FLAGS_DEBUG_TRANSFERS))) - cvmx_dprintf("%s: Channel %d started. Pipe %d transaction %d stage %d\n", - __FUNCTION__, channel, __cvmx_usb_get_pipe_handle(usb, pipe), - __cvmx_usb_get_submit_handle(usb, transaction), - transaction->stage); - /* Make sure all writes to the DMA region get flushed */ CVMX_SYNCW; @@ -1820,11 +1788,8 @@ static void __cvmx_usb_schedule(cvmx_usb_internal_state_t *usb, int is_sof) /* Find an idle channel */ CVMX_CLZ(channel, usb->idle_hardware_channels); channel = 31 - channel; - if (cvmx_unlikely(channel > 7)) { - if (cvmx_unlikely(usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_DEBUG_INFO)) - cvmx_dprintf("%s: Idle hardware channels has a channel higher than 7. This is wrong\n", __FUNCTION__); + if (cvmx_unlikely(channel > 7)) break; - } /* Find a pipe needing service */ pipe = NULL; @@ -1844,34 +1809,6 @@ static void __cvmx_usb_schedule(cvmx_usb_internal_state_t *usb, int is_sof) if (!pipe) break; - if (cvmx_unlikely((usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_DEBUG_TRANSFERS) || - (pipe->flags & CVMX_USB_PIPE_FLAGS_DEBUG_TRANSFERS))) { - cvmx_usb_transaction_t *transaction = pipe->head; - const cvmx_usb_control_header_t *header = (transaction->control_header) ? cvmx_phys_to_ptr(transaction->control_header) : NULL; - const char *dir = (pipe->transfer_dir == CVMX_USB_DIRECTION_IN) ? "IN" : "OUT"; - const char *type; - switch (pipe->transfer_type) { - case CVMX_USB_TRANSFER_CONTROL: - type = "SETUP"; - dir = (header->s.request_type & 0x80) ? "IN" : "OUT"; - break; - case CVMX_USB_TRANSFER_ISOCHRONOUS: - type = "ISOCHRONOUS"; - break; - case CVMX_USB_TRANSFER_BULK: - type = "BULK"; - break; - default: /* CVMX_USB_TRANSFER_INTERRUPT */ - type = "INTERRUPT"; - break; - } - cvmx_dprintf("%s: Starting pipe %d, transaction %d on channel %d. %s %s len=%d header=0x%llx\n", - __FUNCTION__, __cvmx_usb_get_pipe_handle(usb, pipe), - __cvmx_usb_get_submit_handle(usb, transaction), - channel, type, dir, - transaction->buffer_length, - (header) ? (unsigned long long)header->u64 : 0ull); - } __cvmx_usb_start_channel(usb, channel, pipe); } @@ -1935,19 +1872,8 @@ static void __cvmx_usb_perform_callback(cvmx_usb_internal_state_t *usb, if (!callback) return; - if (cvmx_unlikely(usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_DEBUG_CALLBACKS)) - cvmx_dprintf("%*s%s: calling callback %p(usb=%p, complete_code=%s, " - "pipe_handle=%d, submit_handle=%d, bytes_transferred=%d, user_data=%p);\n", - 2*usb->indent, "", __FUNCTION__, callback, usb, - __cvmx_usb_complete_to_string(complete_code), - pipe_handle, submit_handle, bytes_transferred, user_data); - callback((cvmx_usb_state_t *)usb, reason, complete_code, pipe_handle, submit_handle, bytes_transferred, user_data); - - if (cvmx_unlikely(usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_DEBUG_CALLBACKS)) - cvmx_dprintf("%*s%s: callback %p complete\n", 2*usb->indent, "", - __FUNCTION__, callback); } @@ -2694,15 +2620,6 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel) (transaction->stage == CVMX_USB_STAGE_SETUP_SPLIT_COMPLETE)) bytes_this_transfer = 0; - /* Optional debug output */ - if (cvmx_unlikely((usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_DEBUG_TRANSFERS) || - (pipe->flags & CVMX_USB_PIPE_FLAGS_DEBUG_TRANSFERS))) - cvmx_dprintf("%s: Channel %d halted. Pipe %d transaction %d stage %d bytes=%d\n", - __FUNCTION__, channel, - __cvmx_usb_get_pipe_handle(usb, pipe), - __cvmx_usb_get_submit_handle(usb, transaction), - transaction->stage, bytes_this_transfer); - /* Add the bytes transferred to the running total. It is important that bytes_this_transfer doesn't count any data that needs to be retransmitted */ diff --git a/drivers/staging/octeon-usb/cvmx-usb.h b/drivers/staging/octeon-usb/cvmx-usb.h index db9cc05e5d3c0..eed6ba43cf598 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.h +++ b/drivers/staging/octeon-usb/cvmx-usb.h @@ -622,12 +622,6 @@ typedef enum CVMX_USB_INITIALIZE_FLAGS_CLOCK_48MHZ = 3<<3, /**< Speed of reference clock */ /* Bits 3-4 used to encode the clock frequency */ CVMX_USB_INITIALIZE_FLAGS_NO_DMA = 1<<5, /**< Disable DMA and used polled IO for data transfer use for the USB */ - CVMX_USB_INITIALIZE_FLAGS_DEBUG_TRANSFERS = 1<<16, /**< Enable extra console output for debugging USB transfers */ - CVMX_USB_INITIALIZE_FLAGS_DEBUG_CALLBACKS = 1<<17, /**< Enable extra console output for debugging USB callbacks */ - CVMX_USB_INITIALIZE_FLAGS_DEBUG_INFO = 1<<18, /**< Enable extra console output for USB informational data */ - CVMX_USB_INITIALIZE_FLAGS_DEBUG_CALLS = 1<<19, /**< Enable extra console output for every function call */ - CVMX_USB_INITIALIZE_FLAGS_DEBUG_CSRS = 1<<20, /**< Enable extra console output for every CSR access */ - CVMX_USB_INITIALIZE_FLAGS_DEBUG_ALL = ((CVMX_USB_INITIALIZE_FLAGS_DEBUG_CSRS<<1)-1) - (CVMX_USB_INITIALIZE_FLAGS_DEBUG_TRANSFERS-1), } cvmx_usb_initialize_flags_t; /** @@ -636,7 +630,6 @@ typedef enum */ typedef enum { - CVMX_USB_PIPE_FLAGS_DEBUG_TRANSFERS = 1<<15,/**< Used to display CVMX_USB_INITIALIZE_FLAGS_DEBUG_TRANSFERS for a specific pipe only */ __CVMX_USB_PIPE_FLAGS_OPEN = 1<<16, /**< Used internally to determine if a pipe is open. Do not use */ __CVMX_USB_PIPE_FLAGS_SCHEDULED = 1<<17, /**< Used internally to determine if a pipe is actively using hardware. Do not use */ __CVMX_USB_PIPE_FLAGS_NEED_PING = 1<<18, /**< Used internally to determine if a high speed pipe is in the ping state. Do not use */ -- GitLab From 67f70fc624e2aa06291c70d1671f43950a03f3c5 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Mon, 29 Jul 2013 20:07:45 +0300 Subject: [PATCH 333/942] staging: octeon-usb: cvmx-usb: delete redundant example code Delete redundant example code found in comments. It's already there in the driver proper. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/cvmx-usb.h | 209 +------------------------- 1 file changed, 1 insertion(+), 208 deletions(-) diff --git a/drivers/staging/octeon-usb/cvmx-usb.h b/drivers/staging/octeon-usb/cvmx-usb.h index eed6ba43cf598..ffabfbe321f57 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.h +++ b/drivers/staging/octeon-usb/cvmx-usb.h @@ -217,214 +217,7 @@ * messages similar to the usb 2.0 spec for hub control and * status. For these systems it may be necessary to write * function to decode standard usb control messages into - * equivalent cvmx-usb API calls. As an example, the following - * code is used under Linux for some of the basic hub control - * messages. - * - * @code - * static int octeon_usb_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, u16 wIndex, char *buf, u16 wLength) - * { - * cvmx_usb_state_t *usb = (cvmx_usb_state_t *)hcd->hcd_priv; - * cvmx_usb_port_status_t usb_port_status; - * int port_status; - * struct usb_hub_descriptor *desc; - * unsigned long flags; - * - * switch (typeReq) - * { - * case ClearHubFeature: - * DEBUG_ROOT_HUB("OcteonUSB: ClearHubFeature\n"); - * switch (wValue) - * { - * case C_HUB_LOCAL_POWER: - * case C_HUB_OVER_CURRENT: - * // Nothing required here - * break; - * default: - * return -EINVAL; - * } - * break; - * case ClearPortFeature: - * DEBUG_ROOT_HUB("OcteonUSB: ClearPortFeature"); - * if (wIndex != 1) - * { - * DEBUG_ROOT_HUB(" INVALID\n"); - * return -EINVAL; - * } - * - * switch (wValue) - * { - * case USB_PORT_FEAT_ENABLE: - * DEBUG_ROOT_HUB(" ENABLE"); - * local_irq_save(flags); - * cvmx_usb_disable(usb); - * local_irq_restore(flags); - * break; - * case USB_PORT_FEAT_SUSPEND: - * DEBUG_ROOT_HUB(" SUSPEND"); - * // Not supported on Octeon - * break; - * case USB_PORT_FEAT_POWER: - * DEBUG_ROOT_HUB(" POWER"); - * // Not supported on Octeon - * break; - * case USB_PORT_FEAT_INDICATOR: - * DEBUG_ROOT_HUB(" INDICATOR"); - * // Port inidicator not supported - * break; - * case USB_PORT_FEAT_C_CONNECTION: - * DEBUG_ROOT_HUB(" C_CONNECTION"); - * // Clears drivers internal connect status change flag - * cvmx_usb_set_status(usb, cvmx_usb_get_status(usb)); - * break; - * case USB_PORT_FEAT_C_RESET: - * DEBUG_ROOT_HUB(" C_RESET"); - * // Clears the driver's internal Port Reset Change flag - * cvmx_usb_set_status(usb, cvmx_usb_get_status(usb)); - * break; - * case USB_PORT_FEAT_C_ENABLE: - * DEBUG_ROOT_HUB(" C_ENABLE"); - * // Clears the driver's internal Port Enable/Disable Change flag - * cvmx_usb_set_status(usb, cvmx_usb_get_status(usb)); - * break; - * case USB_PORT_FEAT_C_SUSPEND: - * DEBUG_ROOT_HUB(" C_SUSPEND"); - * // Clears the driver's internal Port Suspend Change flag, - * which is set when resume signaling on the host port is - * complete - * break; - * case USB_PORT_FEAT_C_OVER_CURRENT: - * DEBUG_ROOT_HUB(" C_OVER_CURRENT"); - * // Clears the driver's overcurrent Change flag - * cvmx_usb_set_status(usb, cvmx_usb_get_status(usb)); - * break; - * default: - * DEBUG_ROOT_HUB(" UNKNOWN\n"); - * return -EINVAL; - * } - * DEBUG_ROOT_HUB("\n"); - * break; - * case GetHubDescriptor: - * DEBUG_ROOT_HUB("OcteonUSB: GetHubDescriptor\n"); - * desc = (struct usb_hub_descriptor *)buf; - * desc->bDescLength = 9; - * desc->bDescriptorType = 0x29; - * desc->bNbrPorts = 1; - * desc->wHubCharacteristics = 0x08; - * desc->bPwrOn2PwrGood = 1; - * desc->bHubContrCurrent = 0; - * desc->bitmap[0] = 0; - * desc->bitmap[1] = 0xff; - * break; - * case GetHubStatus: - * DEBUG_ROOT_HUB("OcteonUSB: GetHubStatus\n"); - * *(__le32 *)buf = 0; - * break; - * case GetPortStatus: - * DEBUG_ROOT_HUB("OcteonUSB: GetPortStatus"); - * if (wIndex != 1) - * { - * DEBUG_ROOT_HUB(" INVALID\n"); - * return -EINVAL; - * } - * - * usb_port_status = cvmx_usb_get_status(usb); - * port_status = 0; - * - * if (usb_port_status.connect_change) - * { - * port_status |= (1 << USB_PORT_FEAT_C_CONNECTION); - * DEBUG_ROOT_HUB(" C_CONNECTION"); - * } - * - * if (usb_port_status.port_enabled) - * { - * port_status |= (1 << USB_PORT_FEAT_C_ENABLE); - * DEBUG_ROOT_HUB(" C_ENABLE"); - * } - * - * if (usb_port_status.connected) - * { - * port_status |= (1 << USB_PORT_FEAT_CONNECTION); - * DEBUG_ROOT_HUB(" CONNECTION"); - * } - * - * if (usb_port_status.port_enabled) - * { - * port_status |= (1 << USB_PORT_FEAT_ENABLE); - * DEBUG_ROOT_HUB(" ENABLE"); - * } - * - * if (usb_port_status.port_over_current) - * { - * port_status |= (1 << USB_PORT_FEAT_OVER_CURRENT); - * DEBUG_ROOT_HUB(" OVER_CURRENT"); - * } - * - * if (usb_port_status.port_powered) - * { - * port_status |= (1 << USB_PORT_FEAT_POWER); - * DEBUG_ROOT_HUB(" POWER"); - * } - * - * if (usb_port_status.port_speed == CVMX_USB_SPEED_HIGH) - * { - * port_status |= (1 << USB_PORT_FEAT_HIGHSPEED); - * DEBUG_ROOT_HUB(" HIGHSPEED"); - * } - * else if (usb_port_status.port_speed == CVMX_USB_SPEED_LOW) - * { - * port_status |= (1 << USB_PORT_FEAT_LOWSPEED); - * DEBUG_ROOT_HUB(" LOWSPEED"); - * } - * - * *((__le32 *)buf) = cpu_to_le32(port_status); - * DEBUG_ROOT_HUB("\n"); - * break; - * case SetHubFeature: - * DEBUG_ROOT_HUB("OcteonUSB: SetHubFeature\n"); - * // No HUB features supported - * break; - * case SetPortFeature: - * DEBUG_ROOT_HUB("OcteonUSB: SetPortFeature"); - * if (wIndex != 1) - * { - * DEBUG_ROOT_HUB(" INVALID\n"); - * return -EINVAL; - * } - * - * switch (wValue) - * { - * case USB_PORT_FEAT_SUSPEND: - * DEBUG_ROOT_HUB(" SUSPEND\n"); - * return -EINVAL; - * case USB_PORT_FEAT_POWER: - * DEBUG_ROOT_HUB(" POWER\n"); - * return -EINVAL; - * case USB_PORT_FEAT_RESET: - * DEBUG_ROOT_HUB(" RESET\n"); - * local_irq_save(flags); - * cvmx_usb_disable(usb); - * if (cvmx_usb_enable(usb)) - * DEBUG_ERROR("Failed to enable the port\n"); - * local_irq_restore(flags); - * return 0; - * case USB_PORT_FEAT_INDICATOR: - * DEBUG_ROOT_HUB(" INDICATOR\n"); - * // Not supported - * break; - * default: - * DEBUG_ROOT_HUB(" UNKNOWN\n"); - * return -EINVAL; - * } - * break; - * default: - * DEBUG_ROOT_HUB("OcteonUSB: Unknown root hub request\n"); - * return -EINVAL; - * } - * return 0; - * } - * @endcode + * equivalent cvmx-usb API calls. * *

Interrupts

* -- GitLab From 684f94ccbda9757b3a0efbdb5072b53b75a82b49 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Mon, 29 Jul 2013 20:07:46 +0300 Subject: [PATCH 334/942] staging: octeon-usb: cvmx-usb: delete __cplusplus Delete __cplusplus. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/cvmx-usb.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/staging/octeon-usb/cvmx-usb.h b/drivers/staging/octeon-usb/cvmx-usb.h index ffabfbe321f57..e7b524b7de16f 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.h +++ b/drivers/staging/octeon-usb/cvmx-usb.h @@ -241,10 +241,6 @@ #ifndef __CVMX_USB_H__ #define __CVMX_USB_H__ -#ifdef __cplusplus -extern "C" { -#endif - /** * Enumerations representing the status of function calls. */ @@ -864,8 +860,4 @@ extern int cvmx_usb_get_frame_number(cvmx_usb_state_t *state); */ extern cvmx_usb_status_t cvmx_usb_poll(cvmx_usb_state_t *state); -#ifdef __cplusplus -} -#endif - #endif /* __CVMX_USB_H__ */ -- GitLab From 6d658cb2abe8560e047c57f0f68ac5162b917ddb Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Mon, 29 Jul 2013 20:07:47 +0300 Subject: [PATCH 335/942] staging: octeon-usb: cvmx-usb: utilize Linux error codes Use generic Linux error codes to replace cvmx_usb_status_t. The conversion table: Before After cvmx_usb_status_t int CVMX_USB_SUCCESS 0 CVMX_USB_INVALID_PARAM -EINVAL CVMX_USB_NO_MEMORY -ENOMEM CVMX_USB_BUSY -EBUSY CVMX_USB_TIMEOUT -ETIMEDOUT CVMX_USB_INCORRECT_MODE Deleted (was never used) Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/cvmx-usb.c | 191 ++++++++++++-------------- drivers/staging/octeon-usb/cvmx-usb.h | 89 ++++-------- 2 files changed, 117 insertions(+), 163 deletions(-) diff --git a/drivers/staging/octeon-usb/cvmx-usb.c b/drivers/staging/octeon-usb/cvmx-usb.c index dd8653c9e5e3a..9604353935837 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.c +++ b/drivers/staging/octeon-usb/cvmx-usb.c @@ -533,12 +533,10 @@ static inline void __cvmx_usb_remove_pipe(cvmx_usb_pipe_list_t *list, cvmx_usb_p * cvmx_usb_initialize_flags_t for the flag * definitions. Some flags are mandatory. * - * @return CVMX_USB_SUCCESS or a negative error code defined in - * cvmx_usb_status_t. + * @return 0 or a negative error code. */ -cvmx_usb_status_t cvmx_usb_initialize(cvmx_usb_state_t *state, - int usb_port_number, - cvmx_usb_initialize_flags_t flags) +int cvmx_usb_initialize(cvmx_usb_state_t *state, int usb_port_number, + cvmx_usb_initialize_flags_t flags) { cvmx_usbnx_clk_ctl_t usbn_clk_ctl; cvmx_usbnx_usbp_ctl_status_t usbn_usbp_ctl_status; @@ -548,13 +546,13 @@ cvmx_usb_status_t cvmx_usb_initialize(cvmx_usb_state_t *state, /* Make sure that state is large enough to store the internal state */ if (sizeof(*state) < sizeof(*usb)) - return CVMX_USB_INVALID_PARAM; + return -EINVAL; /* At first allow 0-1 for the usb port number */ if ((usb_port_number < 0) || (usb_port_number > 1)) - return CVMX_USB_INVALID_PARAM; + return -EINVAL; /* For all chips except 52XX there is only one port */ if (!OCTEON_IS_MODEL(OCTEON_CN52XX) && (usb_port_number > 0)) - return CVMX_USB_INVALID_PARAM; + return -EINVAL; /* Try to determine clock type automatically */ if ((flags & (CVMX_USB_INITIALIZE_FLAGS_CLOCK_XO_XI | CVMX_USB_INITIALIZE_FLAGS_CLOCK_XO_GND)) == 0) { @@ -578,7 +576,7 @@ cvmx_usb_status_t cvmx_usb_initialize(cvmx_usb_state_t *state, flags |= CVMX_USB_INITIALIZE_FLAGS_CLOCK_48MHZ; break; default: - return CVMX_USB_INVALID_PARAM; + return -EINVAL; break; } } @@ -812,7 +810,7 @@ cvmx_usb_status_t cvmx_usb_initialize(cvmx_usb_state_t *state, /* Steps 4-15 from the manual are done later in the port enable */ } - return CVMX_USB_SUCCESS; + return 0; } @@ -824,10 +822,9 @@ cvmx_usb_status_t cvmx_usb_initialize(cvmx_usb_state_t *state, * @param state USB device state populated by * cvmx_usb_initialize(). * - * @return CVMX_USB_SUCCESS or a negative error code defined in - * cvmx_usb_status_t. + * @return 0 or a negative error code. */ -cvmx_usb_status_t cvmx_usb_shutdown(cvmx_usb_state_t *state) +int cvmx_usb_shutdown(cvmx_usb_state_t *state) { cvmx_usbnx_clk_ctl_t usbn_clk_ctl; cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; @@ -838,7 +835,7 @@ cvmx_usb_status_t cvmx_usb_shutdown(cvmx_usb_state_t *state) usb->active_pipes[CVMX_USB_TRANSFER_INTERRUPT].head || usb->active_pipes[CVMX_USB_TRANSFER_CONTROL].head || usb->active_pipes[CVMX_USB_TRANSFER_BULK].head) - return CVMX_USB_BUSY; + return -EBUSY; /* Disable the clocks and put them in power on reset */ usbn_clk_ctl.u64 = __cvmx_usb_read_csr64(usb, CVMX_USBNX_CLK_CTL(usb->index)); @@ -849,7 +846,7 @@ cvmx_usb_status_t cvmx_usb_shutdown(cvmx_usb_state_t *state) usbn_clk_ctl.s.hrst = 0; __cvmx_usb_write_csr64(usb, CVMX_USBNX_CLK_CTL(usb->index), usbn_clk_ctl.u64); - return CVMX_USB_SUCCESS; + return 0; } @@ -860,10 +857,9 @@ cvmx_usb_status_t cvmx_usb_shutdown(cvmx_usb_state_t *state) * @param state USB device state populated by * cvmx_usb_initialize(). * - * @return CVMX_USB_SUCCESS or a negative error code defined in - * cvmx_usb_status_t. + * @return 0 or a negative error code. */ -cvmx_usb_status_t cvmx_usb_enable(cvmx_usb_state_t *state) +int cvmx_usb_enable(cvmx_usb_state_t *state) { cvmx_usbcx_ghwcfg3_t usbcx_ghwcfg3; cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; @@ -873,11 +869,11 @@ cvmx_usb_status_t cvmx_usb_enable(cvmx_usb_state_t *state) /* If the port is already enabled the just return. We don't need to do anything */ if (usb->usbcx_hprt.s.prtena) - return CVMX_USB_SUCCESS; + return 0; /* If there is nothing plugged into the port then fail immediately */ if (!usb->usbcx_hprt.s.prtconnsts) { - return CVMX_USB_TIMEOUT; + return -ETIMEDOUT; } /* Program the port reset bit to start the reset process */ @@ -893,7 +889,7 @@ cvmx_usb_status_t cvmx_usb_enable(cvmx_usb_state_t *state) /* Wait for the USBC_HPRT[PRTENA]. */ if (CVMX_WAIT_FOR_FIELD32(CVMX_USBCX_HPRT(usb->index), cvmx_usbcx_hprt_t, prtena, ==, 1, 100000)) - return CVMX_USB_TIMEOUT; + return -ETIMEDOUT; /* Read the port speed field to get the enumerated speed, USBC_HPRT[PRTSPD]. */ usb->usbcx_hprt.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HPRT(usb->index)); @@ -931,7 +927,7 @@ cvmx_usb_status_t cvmx_usb_enable(cvmx_usb_state_t *state) CVMX_WAIT_FOR_FIELD32(CVMX_USBCX_GRSTCTL(usb->index), cvmx_usbcx_grstctl_t, rxfflsh, ==, 0, 100); - return CVMX_USB_SUCCESS; + return 0; } @@ -944,16 +940,15 @@ cvmx_usb_status_t cvmx_usb_enable(cvmx_usb_state_t *state) * @param state USB device state populated by * cvmx_usb_initialize(). * - * @return CVMX_USB_SUCCESS or a negative error code defined in - * cvmx_usb_status_t. + * @return 0 or a negative error code. */ -cvmx_usb_status_t cvmx_usb_disable(cvmx_usb_state_t *state) +int cvmx_usb_disable(cvmx_usb_state_t *state) { cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; /* Disable the port */ USB_SET_FIELD32(CVMX_USBCX_HPRT(usb->index), cvmx_usbcx_hprt_t, prtena, 1); - return CVMX_USB_SUCCESS; + return 0; } @@ -1101,7 +1096,7 @@ static inline int __cvmx_usb_get_pipe_handle(cvmx_usb_internal_state_t *usb, * devices behind a high speed hub. * * @return A non negative value is a pipe handle. Negative - * values are failure codes from cvmx_usb_status_t. + * values are error codes. */ int cvmx_usb_open_pipe(cvmx_usb_state_t *state, cvmx_usb_pipe_flags_t flags, int device_addr, int endpoint_num, @@ -1114,36 +1109,36 @@ int cvmx_usb_open_pipe(cvmx_usb_state_t *state, cvmx_usb_pipe_flags_t flags, cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; if (cvmx_unlikely((device_addr < 0) || (device_addr > MAX_USB_ADDRESS))) - return CVMX_USB_INVALID_PARAM; + return -EINVAL; if (cvmx_unlikely((endpoint_num < 0) || (endpoint_num > MAX_USB_ENDPOINT))) - return CVMX_USB_INVALID_PARAM; + return -EINVAL; if (cvmx_unlikely(device_speed > CVMX_USB_SPEED_LOW)) - return CVMX_USB_INVALID_PARAM; + return -EINVAL; if (cvmx_unlikely((max_packet <= 0) || (max_packet > 1024))) - return CVMX_USB_INVALID_PARAM; + return -EINVAL; if (cvmx_unlikely(transfer_type > CVMX_USB_TRANSFER_INTERRUPT)) - return CVMX_USB_INVALID_PARAM; + return -EINVAL; if (cvmx_unlikely((transfer_dir != CVMX_USB_DIRECTION_OUT) && (transfer_dir != CVMX_USB_DIRECTION_IN))) - return CVMX_USB_INVALID_PARAM; + return -EINVAL; if (cvmx_unlikely(interval < 0)) - return CVMX_USB_INVALID_PARAM; + return -EINVAL; if (cvmx_unlikely((transfer_type == CVMX_USB_TRANSFER_CONTROL) && interval)) - return CVMX_USB_INVALID_PARAM; + return -EINVAL; if (cvmx_unlikely(multi_count < 0)) - return CVMX_USB_INVALID_PARAM; + return -EINVAL; if (cvmx_unlikely((device_speed != CVMX_USB_SPEED_HIGH) && (multi_count != 0))) - return CVMX_USB_INVALID_PARAM; + return -EINVAL; if (cvmx_unlikely((hub_device_addr < 0) || (hub_device_addr > MAX_USB_ADDRESS))) - return CVMX_USB_INVALID_PARAM; + return -EINVAL; if (cvmx_unlikely((hub_port < 0) || (hub_port > MAX_USB_HUB_PORT))) - return CVMX_USB_INVALID_PARAM; + return -EINVAL; /* Find a free pipe */ pipe = usb->free_pipes.head; if (!pipe) - return CVMX_USB_NO_MEMORY; + return -ENOMEM; __cvmx_usb_remove_pipe(&usb->free_pipes, pipe); pipe->flags = flags | __CVMX_USB_PIPE_FLAGS_OPEN; if ((device_speed == CVMX_USB_SPEED_HIGH) && @@ -1985,16 +1980,16 @@ static int __cvmx_usb_submit_transaction(cvmx_usb_internal_state_t *usb, cvmx_usb_pipe_t *pipe = usb->pipe + pipe_handle; if (cvmx_unlikely((pipe_handle < 0) || (pipe_handle >= MAX_PIPES))) - return CVMX_USB_INVALID_PARAM; + return -EINVAL; /* Fail if the pipe isn't open */ if (cvmx_unlikely((pipe->flags & __CVMX_USB_PIPE_FLAGS_OPEN) == 0)) - return CVMX_USB_INVALID_PARAM; + return -EINVAL; if (cvmx_unlikely(pipe->transfer_type != type)) - return CVMX_USB_INVALID_PARAM; + return -EINVAL; transaction = __cvmx_usb_alloc_transaction(usb); if (cvmx_unlikely(!transaction)) - return CVMX_USB_NO_MEMORY; + return -ENOMEM; transaction->type = type; transaction->flags |= flags; @@ -2065,8 +2060,7 @@ static int __cvmx_usb_submit_transaction(cvmx_usb_internal_state_t *usb, * callback in not NULL. * * @return A submitted transaction handle or negative on - * failure. Negative values are failure codes from - * cvmx_usb_status_t. + * failure. Negative values are error codes. */ int cvmx_usb_submit_bulk(cvmx_usb_state_t *state, int pipe_handle, uint64_t buffer, int buffer_length, @@ -2078,9 +2072,9 @@ int cvmx_usb_submit_bulk(cvmx_usb_state_t *state, int pipe_handle, /* Pipe handle checking is done later in a common place */ if (cvmx_unlikely(!buffer)) - return CVMX_USB_INVALID_PARAM; + return -EINVAL; if (cvmx_unlikely(buffer_length < 0)) - return CVMX_USB_INVALID_PARAM; + return -EINVAL; submit_handle = __cvmx_usb_submit_transaction(usb, pipe_handle, CVMX_USB_TRANSFER_BULK, @@ -2125,8 +2119,7 @@ int cvmx_usb_submit_bulk(cvmx_usb_state_t *state, int pipe_handle, * callback in not NULL. * * @return A submitted transaction handle or negative on - * failure. Negative values are failure codes from - * cvmx_usb_status_t. + * failure. Negative values are error codes. */ int cvmx_usb_submit_interrupt(cvmx_usb_state_t *state, int pipe_handle, uint64_t buffer, int buffer_length, @@ -2138,9 +2131,9 @@ int cvmx_usb_submit_interrupt(cvmx_usb_state_t *state, int pipe_handle, /* Pipe handle checking is done later in a common place */ if (cvmx_unlikely(!buffer)) - return CVMX_USB_INVALID_PARAM; + return -EINVAL; if (cvmx_unlikely(buffer_length < 0)) - return CVMX_USB_INVALID_PARAM; + return -EINVAL; submit_handle = __cvmx_usb_submit_transaction(usb, pipe_handle, CVMX_USB_TRANSFER_INTERRUPT, @@ -2189,8 +2182,7 @@ int cvmx_usb_submit_interrupt(cvmx_usb_state_t *state, int pipe_handle, * callback in not NULL. * * @return A submitted transaction handle or negative on - * failure. Negative values are failure codes from - * cvmx_usb_status_t. + * failure. Negative values are error codes. */ int cvmx_usb_submit_control(cvmx_usb_state_t *state, int pipe_handle, uint64_t control_header, @@ -2204,12 +2196,12 @@ int cvmx_usb_submit_control(cvmx_usb_state_t *state, int pipe_handle, /* Pipe handle checking is done later in a common place */ if (cvmx_unlikely(!control_header)) - return CVMX_USB_INVALID_PARAM; + return -EINVAL; /* Some drivers send a buffer with a zero length. God only knows why */ if (cvmx_unlikely(buffer && (buffer_length < 0))) - return CVMX_USB_INVALID_PARAM; + return -EINVAL; if (cvmx_unlikely(!buffer && (buffer_length != 0))) - return CVMX_USB_INVALID_PARAM; + return -EINVAL; if ((header->s.request_type & 0x80) == 0) buffer_length = cvmx_le16_to_cpu(header->s.length); @@ -2270,8 +2262,7 @@ int cvmx_usb_submit_control(cvmx_usb_state_t *state, int pipe_handle, * callback in not NULL. * * @return A submitted transaction handle or negative on - * failure. Negative values are failure codes from - * cvmx_usb_status_t. + * failure. Negative values are error codes. */ int cvmx_usb_submit_isochronous(cvmx_usb_state_t *state, int pipe_handle, int start_frame, int flags, @@ -2286,17 +2277,17 @@ int cvmx_usb_submit_isochronous(cvmx_usb_state_t *state, int pipe_handle, /* Pipe handle checking is done later in a common place */ if (cvmx_unlikely(start_frame < 0)) - return CVMX_USB_INVALID_PARAM; + return -EINVAL; if (cvmx_unlikely(flags & ~(CVMX_USB_ISOCHRONOUS_FLAGS_ALLOW_SHORT | CVMX_USB_ISOCHRONOUS_FLAGS_ASAP))) - return CVMX_USB_INVALID_PARAM; + return -EINVAL; if (cvmx_unlikely(number_packets < 1)) - return CVMX_USB_INVALID_PARAM; + return -EINVAL; if (cvmx_unlikely(!packets)) - return CVMX_USB_INVALID_PARAM; + return -EINVAL; if (cvmx_unlikely(!buffer)) - return CVMX_USB_INVALID_PARAM; + return -EINVAL; if (cvmx_unlikely(buffer_length < 0)) - return CVMX_USB_INVALID_PARAM; + return -EINVAL; submit_handle = __cvmx_usb_submit_transaction(usb, pipe_handle, CVMX_USB_TRANSFER_ISOCHRONOUS, @@ -2327,30 +2318,28 @@ int cvmx_usb_submit_isochronous(cvmx_usb_state_t *state, int pipe_handle, * @param submit_handle * Handle to transaction to cancel, returned by the submit function. * - * @return CVMX_USB_SUCCESS or a negative error code defined in - * cvmx_usb_status_t. + * @return 0 or a negative error code. */ -cvmx_usb_status_t cvmx_usb_cancel(cvmx_usb_state_t *state, int pipe_handle, - int submit_handle) +int cvmx_usb_cancel(cvmx_usb_state_t *state, int pipe_handle, int submit_handle) { cvmx_usb_transaction_t *transaction; cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; cvmx_usb_pipe_t *pipe = usb->pipe + pipe_handle; if (cvmx_unlikely((pipe_handle < 0) || (pipe_handle >= MAX_PIPES))) - return CVMX_USB_INVALID_PARAM; + return -EINVAL; if (cvmx_unlikely((submit_handle < 0) || (submit_handle >= MAX_TRANSACTIONS))) - return CVMX_USB_INVALID_PARAM; + return -EINVAL; /* Fail if the pipe isn't open */ if (cvmx_unlikely((pipe->flags & __CVMX_USB_PIPE_FLAGS_OPEN) == 0)) - return CVMX_USB_INVALID_PARAM; + return -EINVAL; transaction = usb->transaction + submit_handle; /* Fail if this transaction already completed */ if (cvmx_unlikely((transaction->flags & __CVMX_USB_TRANSACTION_FLAGS_IN_USE) == 0)) - return CVMX_USB_INVALID_PARAM; + return -EINVAL; /* If the transaction is the HEAD of the queue and scheduled. We need to treat it special */ @@ -2371,7 +2360,7 @@ cvmx_usb_status_t cvmx_usb_cancel(cvmx_usb_state_t *state, int pipe_handle, } } __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_CANCEL); - return CVMX_USB_SUCCESS; + return 0; } @@ -2384,29 +2373,28 @@ cvmx_usb_status_t cvmx_usb_cancel(cvmx_usb_state_t *state, int pipe_handle, * @param pipe_handle * Pipe handle to cancel requests in. * - * @return CVMX_USB_SUCCESS or a negative error code defined in - * cvmx_usb_status_t. + * @return 0 or a negative error code. */ -cvmx_usb_status_t cvmx_usb_cancel_all(cvmx_usb_state_t *state, int pipe_handle) +int cvmx_usb_cancel_all(cvmx_usb_state_t *state, int pipe_handle) { cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; cvmx_usb_pipe_t *pipe = usb->pipe + pipe_handle; if (cvmx_unlikely((pipe_handle < 0) || (pipe_handle >= MAX_PIPES))) - return CVMX_USB_INVALID_PARAM; + return -EINVAL; /* Fail if the pipe isn't open */ if (cvmx_unlikely((pipe->flags & __CVMX_USB_PIPE_FLAGS_OPEN) == 0)) - return CVMX_USB_INVALID_PARAM; + return -EINVAL; /* Simply loop through and attempt to cancel each transaction */ while (pipe->head) { - cvmx_usb_status_t result = cvmx_usb_cancel(state, pipe_handle, + int result = cvmx_usb_cancel(state, pipe_handle, __cvmx_usb_get_submit_handle(usb, pipe->head)); - if (cvmx_unlikely(result != CVMX_USB_SUCCESS)) + if (cvmx_unlikely(result != 0)) return result; } - return CVMX_USB_SUCCESS; + return 0; } @@ -2418,31 +2406,30 @@ cvmx_usb_status_t cvmx_usb_cancel_all(cvmx_usb_state_t *state, int pipe_handle) * @param pipe_handle * Pipe handle to close. * - * @return CVMX_USB_SUCCESS or a negative error code defined in - * cvmx_usb_status_t. CVMX_USB_BUSY is returned if the - * pipe has outstanding transfers. + * @return 0 or a negative error code. EBUSY is returned if the pipe has + * outstanding transfers. */ -cvmx_usb_status_t cvmx_usb_close_pipe(cvmx_usb_state_t *state, int pipe_handle) +int cvmx_usb_close_pipe(cvmx_usb_state_t *state, int pipe_handle) { cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; cvmx_usb_pipe_t *pipe = usb->pipe + pipe_handle; if (cvmx_unlikely((pipe_handle < 0) || (pipe_handle >= MAX_PIPES))) - return CVMX_USB_INVALID_PARAM; + return -EINVAL; /* Fail if the pipe isn't open */ if (cvmx_unlikely((pipe->flags & __CVMX_USB_PIPE_FLAGS_OPEN) == 0)) - return CVMX_USB_INVALID_PARAM; + return -EINVAL; /* Fail if the pipe has pending transactions */ if (cvmx_unlikely(pipe->head)) - return CVMX_USB_BUSY; + return -EBUSY; pipe->flags = 0; __cvmx_usb_remove_pipe(&usb->idle_pipes, pipe); __cvmx_usb_append_pipe(&usb->free_pipes, pipe); - return CVMX_USB_SUCCESS; + return 0; } @@ -2455,25 +2442,24 @@ cvmx_usb_status_t cvmx_usb_close_pipe(cvmx_usb_state_t *state, int pipe_handle) * @param callback Function to call when the event occurs. * @param user_data User data parameter to the function. * - * @return CVMX_USB_SUCCESS or a negative error code defined in - * cvmx_usb_status_t. + * @return 0 or a negative error code. */ -cvmx_usb_status_t cvmx_usb_register_callback(cvmx_usb_state_t *state, - cvmx_usb_callback_t reason, - cvmx_usb_callback_func_t callback, - void *user_data) +int cvmx_usb_register_callback(cvmx_usb_state_t *state, + cvmx_usb_callback_t reason, + cvmx_usb_callback_func_t callback, + void *user_data) { cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; if (cvmx_unlikely(reason >= __CVMX_USB_CALLBACK_END)) - return CVMX_USB_INVALID_PARAM; + return -EINVAL; if (cvmx_unlikely(!callback)) - return CVMX_USB_INVALID_PARAM; + return -EINVAL; usb->callback[reason] = callback; usb->callback_data[reason] = user_data; - return CVMX_USB_SUCCESS; + return 0; } @@ -2900,10 +2886,9 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel) * @param state USB device state populated by * cvmx_usb_initialize(). * - * @return CVMX_USB_SUCCESS or a negative error code defined in - * cvmx_usb_status_t. + * @return 0 or a negative error code. */ -cvmx_usb_status_t cvmx_usb_poll(cvmx_usb_state_t *state) +int cvmx_usb_poll(cvmx_usb_state_t *state) { cvmx_usbcx_hfnum_t usbc_hfnum; cvmx_usbcx_gintsts_t usbc_gintsts; @@ -2986,5 +2971,5 @@ cvmx_usb_status_t cvmx_usb_poll(cvmx_usb_state_t *state) __cvmx_usb_schedule(usb, usbc_gintsts.s.sof); - return CVMX_USB_SUCCESS; + return 0; } diff --git a/drivers/staging/octeon-usb/cvmx-usb.h b/drivers/staging/octeon-usb/cvmx-usb.h index e7b524b7de16f..dc366c8e71710 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.h +++ b/drivers/staging/octeon-usb/cvmx-usb.h @@ -241,21 +241,6 @@ #ifndef __CVMX_USB_H__ #define __CVMX_USB_H__ -/** - * Enumerations representing the status of function calls. - */ -typedef enum -{ - CVMX_USB_SUCCESS = 0, /**< There were no errors */ - CVMX_USB_INVALID_PARAM = -1, /**< A parameter to the function was invalid */ - CVMX_USB_NO_MEMORY = -2, /**< Insufficient resources were available for the request */ - CVMX_USB_BUSY = -3, /**< The resource is busy and cannot service the request */ - CVMX_USB_TIMEOUT = -4, /**< Waiting for an action timed out */ - CVMX_USB_INCORRECT_MODE = -5, /**< The function call doesn't work in the current USB - mode. This happens when host only functions are - called in device mode or vice versa */ -} cvmx_usb_status_t; - /** * Enumerations representing the possible USB device speeds */ @@ -451,12 +436,10 @@ extern int cvmx_usb_get_num_ports(void); * cvmx_usb_initialize_flags_t for the flag * definitions. Some flags are mandatory. * - * @return CVMX_USB_SUCCESS or a negative error code defined in - * cvmx_usb_status_t. + * @return 0 or a negative error code. */ -extern cvmx_usb_status_t cvmx_usb_initialize(cvmx_usb_state_t *state, - int usb_port_number, - cvmx_usb_initialize_flags_t flags); +extern int cvmx_usb_initialize(cvmx_usb_state_t *state, int usb_port_number, + cvmx_usb_initialize_flags_t flags); /** * Shutdown a USB port after a call to cvmx_usb_initialize(). @@ -466,10 +449,9 @@ extern cvmx_usb_status_t cvmx_usb_initialize(cvmx_usb_state_t *state, * @param state USB device state populated by * cvmx_usb_initialize(). * - * @return CVMX_USB_SUCCESS or a negative error code defined in - * cvmx_usb_status_t. + * @return 0 or a negative error code. */ -extern cvmx_usb_status_t cvmx_usb_shutdown(cvmx_usb_state_t *state); +extern int cvmx_usb_shutdown(cvmx_usb_state_t *state); /** * Enable a USB port. After this call succeeds, the USB port is @@ -478,10 +460,9 @@ extern cvmx_usb_status_t cvmx_usb_shutdown(cvmx_usb_state_t *state); * @param state USB device state populated by * cvmx_usb_initialize(). * - * @return CVMX_USB_SUCCESS or a negative error code defined in - * cvmx_usb_status_t. + * @return 0 or a negative error code. */ -extern cvmx_usb_status_t cvmx_usb_enable(cvmx_usb_state_t *state); +extern int cvmx_usb_enable(cvmx_usb_state_t *state); /** * Disable a USB port. After this call the USB port will not @@ -492,10 +473,9 @@ extern cvmx_usb_status_t cvmx_usb_enable(cvmx_usb_state_t *state); * @param state USB device state populated by * cvmx_usb_initialize(). * - * @return CVMX_USB_SUCCESS or a negative error code defined in - * cvmx_usb_status_t. + * @return 0 or a negative error code. */ -extern cvmx_usb_status_t cvmx_usb_disable(cvmx_usb_state_t *state); +extern int cvmx_usb_disable(cvmx_usb_state_t *state); /** * Get the current state of the USB port. Use this call to @@ -581,7 +561,7 @@ extern void cvmx_usb_set_status(cvmx_usb_state_t *state, cvmx_usb_port_status_t * devices behind a high speed hub. * * @return A non negative value is a pipe handle. Negative - * values are failure codes from cvmx_usb_status_t. + * values are error codes. */ extern int cvmx_usb_open_pipe(cvmx_usb_state_t *state, cvmx_usb_pipe_flags_t flags, @@ -620,8 +600,7 @@ extern int cvmx_usb_open_pipe(cvmx_usb_state_t *state, * callback in not NULL. * * @return A submitted transaction handle or negative on - * failure. Negative values are failure codes from - * cvmx_usb_status_t. + * failure. Negative values are error codes. */ extern int cvmx_usb_submit_bulk(cvmx_usb_state_t *state, int pipe_handle, uint64_t buffer, int buffer_length, @@ -656,8 +635,7 @@ extern int cvmx_usb_submit_bulk(cvmx_usb_state_t *state, int pipe_handle, * callback in not NULL. * * @return A submitted transaction handle or negative on - * failure. Negative values are failure codes from - * cvmx_usb_status_t. + * failure. Negative values are error codes. */ extern int cvmx_usb_submit_interrupt(cvmx_usb_state_t *state, int pipe_handle, uint64_t buffer, int buffer_length, @@ -696,8 +674,7 @@ extern int cvmx_usb_submit_interrupt(cvmx_usb_state_t *state, int pipe_handle, * callback in not NULL. * * @return A submitted transaction handle or negative on - * failure. Negative values are failure codes from - * cvmx_usb_status_t. + * failure. Negative values are error codes. */ extern int cvmx_usb_submit_control(cvmx_usb_state_t *state, int pipe_handle, uint64_t control_header, @@ -756,8 +733,7 @@ typedef enum * callback in not NULL. * * @return A submitted transaction handle or negative on - * failure. Negative values are failure codes from - * cvmx_usb_status_t. + * failure. Negative values are error codes. */ extern int cvmx_usb_submit_isochronous(cvmx_usb_state_t *state, int pipe_handle, int start_frame, int flags, @@ -781,11 +757,10 @@ extern int cvmx_usb_submit_isochronous(cvmx_usb_state_t *state, int pipe_handle, * @param submit_handle * Handle to transaction to cancel, returned by the submit function. * - * @return CVMX_USB_SUCCESS or a negative error code defined in - * cvmx_usb_status_t. + * @return 0 or a negative error code. */ -extern cvmx_usb_status_t cvmx_usb_cancel(cvmx_usb_state_t *state, - int pipe_handle, int submit_handle); +extern int cvmx_usb_cancel(cvmx_usb_state_t *state, int pipe_handle, + int submit_handle); /** @@ -797,11 +772,9 @@ extern cvmx_usb_status_t cvmx_usb_cancel(cvmx_usb_state_t *state, * @param pipe_handle * Pipe handle to cancel requests in. * - * @return CVMX_USB_SUCCESS or a negative error code defined in - * cvmx_usb_status_t. + * @return 0 or a negative error code. */ -extern cvmx_usb_status_t cvmx_usb_cancel_all(cvmx_usb_state_t *state, - int pipe_handle); +extern int cvmx_usb_cancel_all(cvmx_usb_state_t *state, int pipe_handle); /** * Close a pipe created with cvmx_usb_open_pipe(). @@ -811,12 +784,10 @@ extern cvmx_usb_status_t cvmx_usb_cancel_all(cvmx_usb_state_t *state, * @param pipe_handle * Pipe handle to close. * - * @return CVMX_USB_SUCCESS or a negative error code defined in - * cvmx_usb_status_t. CVMX_USB_BUSY is returned if the - * pipe has outstanding transfers. + * @return 0 or a negative error code. EBUSY is returned if the pipe has + * outstanding transfers. */ -extern cvmx_usb_status_t cvmx_usb_close_pipe(cvmx_usb_state_t *state, - int pipe_handle); +extern int cvmx_usb_close_pipe(cvmx_usb_state_t *state, int pipe_handle); /** * Register a function to be called when various USB events occur. @@ -827,13 +798,12 @@ extern cvmx_usb_status_t cvmx_usb_close_pipe(cvmx_usb_state_t *state, * @param callback Function to call when the event occurs. * @param user_data User data parameter to the function. * - * @return CVMX_USB_SUCCESS or a negative error code defined in - * cvmx_usb_status_t. + * @return 0 or a negative error code. */ -extern cvmx_usb_status_t cvmx_usb_register_callback(cvmx_usb_state_t *state, - cvmx_usb_callback_t reason, - cvmx_usb_callback_func_t callback, - void *user_data); +extern int cvmx_usb_register_callback(cvmx_usb_state_t *state, + cvmx_usb_callback_t reason, + cvmx_usb_callback_func_t callback, + void *user_data); /** * Get the current USB protocol level frame number. The frame @@ -855,9 +825,8 @@ extern int cvmx_usb_get_frame_number(cvmx_usb_state_t *state); * @param state USB device state populated by * cvmx_usb_initialize(). * - * @return CVMX_USB_SUCCESS or a negative error code defined in - * cvmx_usb_status_t. + * @return 0 or a negative error code. */ -extern cvmx_usb_status_t cvmx_usb_poll(cvmx_usb_state_t *state); +extern int cvmx_usb_poll(cvmx_usb_state_t *state); #endif /* __CVMX_USB_H__ */ -- GitLab From 27bf55251ce33be83e668718e3ad04fa0c245218 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Mon, 29 Jul 2013 20:07:48 +0300 Subject: [PATCH 336/942] staging: octeon-usb: cvmx-usb: eliminate cvmx_likely/unlikely Just use likely/unlikely. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/cvmx-usb.c | 94 +++++++++++++-------------- 1 file changed, 46 insertions(+), 48 deletions(-) diff --git a/drivers/staging/octeon-usb/cvmx-usb.c b/drivers/staging/octeon-usb/cvmx-usb.c index 9604353935837..efea87b988334 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.c +++ b/drivers/staging/octeon-usb/cvmx-usb.c @@ -68,9 +68,7 @@ #define CVMX_PREFETCH_PREF0(address, offset) CVMX_PREFETCH_PREFX(0, address, offset) #define CVMX_CLZ(result, input) asm ("clz %[rd],%[rs]" : [rd] "=d" (result) : [rs] "d" (input)) -#define cvmx_likely likely #define cvmx_wait_usec udelay -#define cvmx_unlikely unlikely #define cvmx_le16_to_cpu le16_to_cpu #define MAX_RETRIES 3 /* Maximum number of times to retry failed transactions */ @@ -1108,31 +1106,31 @@ int cvmx_usb_open_pipe(cvmx_usb_state_t *state, cvmx_usb_pipe_flags_t flags, cvmx_usb_pipe_t *pipe; cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; - if (cvmx_unlikely((device_addr < 0) || (device_addr > MAX_USB_ADDRESS))) + if (unlikely((device_addr < 0) || (device_addr > MAX_USB_ADDRESS))) return -EINVAL; - if (cvmx_unlikely((endpoint_num < 0) || (endpoint_num > MAX_USB_ENDPOINT))) + if (unlikely((endpoint_num < 0) || (endpoint_num > MAX_USB_ENDPOINT))) return -EINVAL; - if (cvmx_unlikely(device_speed > CVMX_USB_SPEED_LOW)) + if (unlikely(device_speed > CVMX_USB_SPEED_LOW)) return -EINVAL; - if (cvmx_unlikely((max_packet <= 0) || (max_packet > 1024))) + if (unlikely((max_packet <= 0) || (max_packet > 1024))) return -EINVAL; - if (cvmx_unlikely(transfer_type > CVMX_USB_TRANSFER_INTERRUPT)) + if (unlikely(transfer_type > CVMX_USB_TRANSFER_INTERRUPT)) return -EINVAL; - if (cvmx_unlikely((transfer_dir != CVMX_USB_DIRECTION_OUT) && + if (unlikely((transfer_dir != CVMX_USB_DIRECTION_OUT) && (transfer_dir != CVMX_USB_DIRECTION_IN))) return -EINVAL; - if (cvmx_unlikely(interval < 0)) + if (unlikely(interval < 0)) return -EINVAL; - if (cvmx_unlikely((transfer_type == CVMX_USB_TRANSFER_CONTROL) && interval)) + if (unlikely((transfer_type == CVMX_USB_TRANSFER_CONTROL) && interval)) return -EINVAL; - if (cvmx_unlikely(multi_count < 0)) + if (unlikely(multi_count < 0)) return -EINVAL; - if (cvmx_unlikely((device_speed != CVMX_USB_SPEED_HIGH) && + if (unlikely((device_speed != CVMX_USB_SPEED_HIGH) && (multi_count != 0))) return -EINVAL; - if (cvmx_unlikely((hub_device_addr < 0) || (hub_device_addr > MAX_USB_ADDRESS))) + if (unlikely((hub_device_addr < 0) || (hub_device_addr > MAX_USB_ADDRESS))) return -EINVAL; - if (cvmx_unlikely((hub_port < 0) || (hub_port > MAX_USB_HUB_PORT))) + if (unlikely((hub_port < 0) || (hub_port > MAX_USB_HUB_PORT))) return -EINVAL; /* Find a free pipe */ @@ -1783,7 +1781,7 @@ static void __cvmx_usb_schedule(cvmx_usb_internal_state_t *usb, int is_sof) /* Find an idle channel */ CVMX_CLZ(channel, usb->idle_hardware_channels); channel = 31 - channel; - if (cvmx_unlikely(channel > 7)) + if (unlikely(channel > 7)) break; /* Find a pipe needing service */ @@ -1793,12 +1791,12 @@ static void __cvmx_usb_schedule(cvmx_usb_internal_state_t *usb, int is_sof) sure that the periodic data is sent in the beginning of the frame */ pipe = __cvmx_usb_find_ready_pipe(usb, usb->active_pipes + CVMX_USB_TRANSFER_ISOCHRONOUS, usb->frame_number); - if (cvmx_likely(!pipe)) + if (likely(!pipe)) pipe = __cvmx_usb_find_ready_pipe(usb, usb->active_pipes + CVMX_USB_TRANSFER_INTERRUPT, usb->frame_number); } - if (cvmx_likely(!pipe)) { + if (likely(!pipe)) { pipe = __cvmx_usb_find_ready_pipe(usb, usb->active_pipes + CVMX_USB_TRANSFER_CONTROL, usb->frame_number); - if (cvmx_likely(!pipe)) + if (likely(!pipe)) pipe = __cvmx_usb_find_ready_pipe(usb, usb->active_pipes + CVMX_USB_TRANSFER_BULK, usb->frame_number); } if (!pipe) @@ -1896,7 +1894,7 @@ static void __cvmx_usb_perform_complete(cvmx_usb_internal_state_t * usb, /* Isochronous transactions need extra processing as they might not be done after a single data transfer */ - if (cvmx_unlikely(transaction->type == CVMX_USB_TRANSFER_ISOCHRONOUS)) { + if (unlikely(transaction->type == CVMX_USB_TRANSFER_ISOCHRONOUS)) { /* Update the number of bytes transferred in this ISO packet */ transaction->iso_packets[0].length = transaction->actual_bytes; transaction->iso_packets[0].status = complete_code; @@ -1979,16 +1977,16 @@ static int __cvmx_usb_submit_transaction(cvmx_usb_internal_state_t *usb, cvmx_usb_transaction_t *transaction; cvmx_usb_pipe_t *pipe = usb->pipe + pipe_handle; - if (cvmx_unlikely((pipe_handle < 0) || (pipe_handle >= MAX_PIPES))) + if (unlikely((pipe_handle < 0) || (pipe_handle >= MAX_PIPES))) return -EINVAL; /* Fail if the pipe isn't open */ - if (cvmx_unlikely((pipe->flags & __CVMX_USB_PIPE_FLAGS_OPEN) == 0)) + if (unlikely((pipe->flags & __CVMX_USB_PIPE_FLAGS_OPEN) == 0)) return -EINVAL; - if (cvmx_unlikely(pipe->transfer_type != type)) + if (unlikely(pipe->transfer_type != type)) return -EINVAL; transaction = __cvmx_usb_alloc_transaction(usb); - if (cvmx_unlikely(!transaction)) + if (unlikely(!transaction)) return -ENOMEM; transaction->type = type; @@ -2071,9 +2069,9 @@ int cvmx_usb_submit_bulk(cvmx_usb_state_t *state, int pipe_handle, cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; /* Pipe handle checking is done later in a common place */ - if (cvmx_unlikely(!buffer)) + if (unlikely(!buffer)) return -EINVAL; - if (cvmx_unlikely(buffer_length < 0)) + if (unlikely(buffer_length < 0)) return -EINVAL; submit_handle = __cvmx_usb_submit_transaction(usb, pipe_handle, @@ -2130,9 +2128,9 @@ int cvmx_usb_submit_interrupt(cvmx_usb_state_t *state, int pipe_handle, cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; /* Pipe handle checking is done later in a common place */ - if (cvmx_unlikely(!buffer)) + if (unlikely(!buffer)) return -EINVAL; - if (cvmx_unlikely(buffer_length < 0)) + if (unlikely(buffer_length < 0)) return -EINVAL; submit_handle = __cvmx_usb_submit_transaction(usb, pipe_handle, @@ -2195,12 +2193,12 @@ int cvmx_usb_submit_control(cvmx_usb_state_t *state, int pipe_handle, cvmx_usb_control_header_t *header = cvmx_phys_to_ptr(control_header); /* Pipe handle checking is done later in a common place */ - if (cvmx_unlikely(!control_header)) + if (unlikely(!control_header)) return -EINVAL; /* Some drivers send a buffer with a zero length. God only knows why */ - if (cvmx_unlikely(buffer && (buffer_length < 0))) + if (unlikely(buffer && (buffer_length < 0))) return -EINVAL; - if (cvmx_unlikely(!buffer && (buffer_length != 0))) + if (unlikely(!buffer && (buffer_length != 0))) return -EINVAL; if ((header->s.request_type & 0x80) == 0) buffer_length = cvmx_le16_to_cpu(header->s.length); @@ -2276,17 +2274,17 @@ int cvmx_usb_submit_isochronous(cvmx_usb_state_t *state, int pipe_handle, cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; /* Pipe handle checking is done later in a common place */ - if (cvmx_unlikely(start_frame < 0)) + if (unlikely(start_frame < 0)) return -EINVAL; - if (cvmx_unlikely(flags & ~(CVMX_USB_ISOCHRONOUS_FLAGS_ALLOW_SHORT | CVMX_USB_ISOCHRONOUS_FLAGS_ASAP))) + if (unlikely(flags & ~(CVMX_USB_ISOCHRONOUS_FLAGS_ALLOW_SHORT | CVMX_USB_ISOCHRONOUS_FLAGS_ASAP))) return -EINVAL; - if (cvmx_unlikely(number_packets < 1)) + if (unlikely(number_packets < 1)) return -EINVAL; - if (cvmx_unlikely(!packets)) + if (unlikely(!packets)) return -EINVAL; - if (cvmx_unlikely(!buffer)) + if (unlikely(!buffer)) return -EINVAL; - if (cvmx_unlikely(buffer_length < 0)) + if (unlikely(buffer_length < 0)) return -EINVAL; submit_handle = __cvmx_usb_submit_transaction(usb, pipe_handle, @@ -2326,19 +2324,19 @@ int cvmx_usb_cancel(cvmx_usb_state_t *state, int pipe_handle, int submit_handle) cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; cvmx_usb_pipe_t *pipe = usb->pipe + pipe_handle; - if (cvmx_unlikely((pipe_handle < 0) || (pipe_handle >= MAX_PIPES))) + if (unlikely((pipe_handle < 0) || (pipe_handle >= MAX_PIPES))) return -EINVAL; - if (cvmx_unlikely((submit_handle < 0) || (submit_handle >= MAX_TRANSACTIONS))) + if (unlikely((submit_handle < 0) || (submit_handle >= MAX_TRANSACTIONS))) return -EINVAL; /* Fail if the pipe isn't open */ - if (cvmx_unlikely((pipe->flags & __CVMX_USB_PIPE_FLAGS_OPEN) == 0)) + if (unlikely((pipe->flags & __CVMX_USB_PIPE_FLAGS_OPEN) == 0)) return -EINVAL; transaction = usb->transaction + submit_handle; /* Fail if this transaction already completed */ - if (cvmx_unlikely((transaction->flags & __CVMX_USB_TRANSACTION_FLAGS_IN_USE) == 0)) + if (unlikely((transaction->flags & __CVMX_USB_TRANSACTION_FLAGS_IN_USE) == 0)) return -EINVAL; /* If the transaction is the HEAD of the queue and scheduled. We need to @@ -2380,18 +2378,18 @@ int cvmx_usb_cancel_all(cvmx_usb_state_t *state, int pipe_handle) cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; cvmx_usb_pipe_t *pipe = usb->pipe + pipe_handle; - if (cvmx_unlikely((pipe_handle < 0) || (pipe_handle >= MAX_PIPES))) + if (unlikely((pipe_handle < 0) || (pipe_handle >= MAX_PIPES))) return -EINVAL; /* Fail if the pipe isn't open */ - if (cvmx_unlikely((pipe->flags & __CVMX_USB_PIPE_FLAGS_OPEN) == 0)) + if (unlikely((pipe->flags & __CVMX_USB_PIPE_FLAGS_OPEN) == 0)) return -EINVAL; /* Simply loop through and attempt to cancel each transaction */ while (pipe->head) { int result = cvmx_usb_cancel(state, pipe_handle, __cvmx_usb_get_submit_handle(usb, pipe->head)); - if (cvmx_unlikely(result != 0)) + if (unlikely(result != 0)) return result; } return 0; @@ -2414,15 +2412,15 @@ int cvmx_usb_close_pipe(cvmx_usb_state_t *state, int pipe_handle) cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; cvmx_usb_pipe_t *pipe = usb->pipe + pipe_handle; - if (cvmx_unlikely((pipe_handle < 0) || (pipe_handle >= MAX_PIPES))) + if (unlikely((pipe_handle < 0) || (pipe_handle >= MAX_PIPES))) return -EINVAL; /* Fail if the pipe isn't open */ - if (cvmx_unlikely((pipe->flags & __CVMX_USB_PIPE_FLAGS_OPEN) == 0)) + if (unlikely((pipe->flags & __CVMX_USB_PIPE_FLAGS_OPEN) == 0)) return -EINVAL; /* Fail if the pipe has pending transactions */ - if (cvmx_unlikely(pipe->head)) + if (unlikely(pipe->head)) return -EBUSY; pipe->flags = 0; @@ -2451,9 +2449,9 @@ int cvmx_usb_register_callback(cvmx_usb_state_t *state, { cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; - if (cvmx_unlikely(reason >= __CVMX_USB_CALLBACK_END)) + if (unlikely(reason >= __CVMX_USB_CALLBACK_END)) return -EINVAL; - if (cvmx_unlikely(!callback)) + if (unlikely(!callback)) return -EINVAL; usb->callback[reason] = callback; -- GitLab From 2e5ae89870a6a9898e88e56be2740c4656322288 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Mon, 29 Jul 2013 20:07:49 +0300 Subject: [PATCH 337/942] staging: octeon-usb: cvmx-usb: replace long udelays with mdelays Replace long udelays with mdelays. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/cvmx-usb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/octeon-usb/cvmx-usb.c b/drivers/staging/octeon-usb/cvmx-usb.c index efea87b988334..fadc695c7d56f 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.c +++ b/drivers/staging/octeon-usb/cvmx-usb.c @@ -672,7 +672,7 @@ int cvmx_usb_initialize(cvmx_usb_state_t *state, int usb_port_number, __cvmx_usb_write_csr64(usb, CVMX_USBNX_CLK_CTL(usb->index), usbn_clk_ctl.u64); /* 4. Wait 1 ms for PHY clock to start */ - cvmx_wait_usec(1000); + mdelay(1); /* 5. Program the Reset input from automatic test equipment field in the USBP control and status register: USBN_USBP_CTL_STATUS[ATE_RESET] = 1 */ usbn_usbp_ctl_status.u64 = __cvmx_usb_read_csr64(usb, CVMX_USBNX_USBP_CTL_STATUS(usb->index)); @@ -879,7 +879,7 @@ int cvmx_usb_enable(cvmx_usb_state_t *state) /* Wait at least 50ms (high speed), or 10ms (full speed) for the reset process to complete. */ - cvmx_wait_usec(50000); + mdelay(50); /* Program the port reset bit to 0, USBC_HPRT[PRTRST] = 0 */ USB_SET_FIELD32(CVMX_USBCX_HPRT(usb->index), cvmx_usbcx_hprt_t, prtrst, 0); -- GitLab From ee7d14ce5ebd4f6588da19ae8c76261a4f77d652 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Mon, 29 Jul 2013 20:07:50 +0300 Subject: [PATCH 338/942] staging: octeon-usb: cvmx-usb: replace cvmx_wait_usec with udelay Just use udelay(). Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/cvmx-usb.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/octeon-usb/cvmx-usb.c b/drivers/staging/octeon-usb/cvmx-usb.c index fadc695c7d56f..906c7d8b2f1ef 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.c +++ b/drivers/staging/octeon-usb/cvmx-usb.c @@ -68,7 +68,6 @@ #define CVMX_PREFETCH_PREF0(address, offset) CVMX_PREFETCH_PREFX(0, address, offset) #define CVMX_CLZ(result, input) asm ("clz %[rd],%[rs]" : [rd] "=d" (result) : [rs] "d" (input)) -#define cvmx_wait_usec udelay #define cvmx_le16_to_cpu le16_to_cpu #define MAX_RETRIES 3 /* Maximum number of times to retry failed transactions */ @@ -698,7 +697,7 @@ int cvmx_usb_initialize(cvmx_usb_state_t *state, int usb_port_number, __cvmx_usb_write_csr64(usb, CVMX_USBNX_USBP_CTL_STATUS(usb->index), usbn_usbp_ctl_status.u64); /* 10. Wait 1 us */ - cvmx_wait_usec(1); + udelay(1); /* 11. Program the hreset_n field in the USBN clock-control register: USBN_CLK_CTL[HRST] = 1 */ usbn_clk_ctl.s.hrst = 1; @@ -708,7 +707,7 @@ int cvmx_usb_initialize(cvmx_usb_state_t *state, int usb_port_number, usbn_clk_ctl.s.enable = 1; __cvmx_usb_write_csr64(usb, CVMX_USBNX_CLK_CTL(usb->index), usbn_clk_ctl.u64); - cvmx_wait_usec(1); + udelay(1); /* USB Core Initialization */ -- GitLab From 5645bcf98b80280d4b73f314af9caa311add2fa7 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Mon, 29 Jul 2013 20:07:51 +0300 Subject: [PATCH 339/942] staging: octeon-usb: cvmx-usb: replace cvmx_le16_to_cpu with le16_to_cpu Replace cvmx_le16_to_cpu() with le16_to_cpu(). Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/cvmx-usb.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/octeon-usb/cvmx-usb.c b/drivers/staging/octeon-usb/cvmx-usb.c index 906c7d8b2f1ef..49a1794998e88 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.c +++ b/drivers/staging/octeon-usb/cvmx-usb.c @@ -68,8 +68,6 @@ #define CVMX_PREFETCH_PREF0(address, offset) CVMX_PREFETCH_PREFX(0, address, offset) #define CVMX_CLZ(result, input) asm ("clz %[rd],%[rs]" : [rd] "=d" (result) : [rs] "d" (input)) -#define cvmx_le16_to_cpu le16_to_cpu - #define MAX_RETRIES 3 /* Maximum number of times to retry failed transactions */ #define MAX_PIPES 32 /* Maximum number of pipes that can be open at once */ #define MAX_TRANSACTIONS 256 /* Maximum number of outstanding transactions across all pipes */ @@ -2200,7 +2198,7 @@ int cvmx_usb_submit_control(cvmx_usb_state_t *state, int pipe_handle, if (unlikely(!buffer && (buffer_length != 0))) return -EINVAL; if ((header->s.request_type & 0x80) == 0) - buffer_length = cvmx_le16_to_cpu(header->s.length); + buffer_length = le16_to_cpu(header->s.length); submit_handle = __cvmx_usb_submit_transaction(usb, pipe_handle, CVMX_USB_TRANSFER_CONTROL, -- GitLab From 95e67a7a29b56b5012f3dd4e01b8f5ebfa7b2b75 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Mon, 29 Jul 2013 20:07:52 +0300 Subject: [PATCH 340/942] staging: octeon-usb: cvmx-usb: delete __cvmx_usb_complete_to_string() Delete a redundant function. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/cvmx-usb.c | 28 --------------------------- 1 file changed, 28 deletions(-) diff --git a/drivers/staging/octeon-usb/cvmx-usb.c b/drivers/staging/octeon-usb/cvmx-usb.c index 49a1794998e88..976ba1970b90c 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.c +++ b/drivers/staging/octeon-usb/cvmx-usb.c @@ -324,34 +324,6 @@ static inline void __cvmx_usb_write_csr64(cvmx_usb_internal_state_t *usb, cvmx_write64_uint64(address, value); } - -/** - * @INTERNAL - * Utility function to convert complete codes into strings - * - * @param complete_code - * Code to convert - * - * @return Human readable string - */ -static const char *__cvmx_usb_complete_to_string(cvmx_usb_complete_t complete_code) -{ - switch (complete_code) - { - case CVMX_USB_COMPLETE_SUCCESS: return "SUCCESS"; - case CVMX_USB_COMPLETE_SHORT: return "SHORT"; - case CVMX_USB_COMPLETE_CANCEL: return "CANCEL"; - case CVMX_USB_COMPLETE_ERROR: return "ERROR"; - case CVMX_USB_COMPLETE_STALL: return "STALL"; - case CVMX_USB_COMPLETE_XACTERR: return "XACTERR"; - case CVMX_USB_COMPLETE_DATATGLERR: return "DATATGLERR"; - case CVMX_USB_COMPLETE_BABBLEERR: return "BABBLEERR"; - case CVMX_USB_COMPLETE_FRAMEERR: return "FRAMEERR"; - } - return "Update __cvmx_usb_complete_to_string"; -} - - /** * @INTERNAL * Return non zero if this pipe connects to a non HIGH speed -- GitLab From eeb90cb28718d80fb55993f690f8e1aa21b90f06 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Mon, 29 Jul 2013 20:07:53 +0300 Subject: [PATCH 341/942] staging: octeon-usb: cvmx-usb: fix whitespace issues Fix most of the whitespace issues reported by checkpatch: - use tabs for indentation - brace placement vs. newlines - (foo_t*) -> (foo_t *) - i=0 -> i = 0 Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/cvmx-usb.c | 4326 ++++++++++++------------- 1 file changed, 2144 insertions(+), 2182 deletions(-) diff --git a/drivers/staging/octeon-usb/cvmx-usb.c b/drivers/staging/octeon-usb/cvmx-usb.c index 976ba1970b90c..e8fad48b1bb50 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.c +++ b/drivers/staging/octeon-usb/cvmx-usb.c @@ -68,24 +68,24 @@ #define CVMX_PREFETCH_PREF0(address, offset) CVMX_PREFETCH_PREFX(0, address, offset) #define CVMX_CLZ(result, input) asm ("clz %[rd],%[rs]" : [rd] "=d" (result) : [rs] "d" (input)) -#define MAX_RETRIES 3 /* Maximum number of times to retry failed transactions */ -#define MAX_PIPES 32 /* Maximum number of pipes that can be open at once */ -#define MAX_TRANSACTIONS 256 /* Maximum number of outstanding transactions across all pipes */ -#define MAX_CHANNELS 8 /* Maximum number of hardware channels supported by the USB block */ -#define MAX_USB_ADDRESS 127 /* The highest valid USB device address */ -#define MAX_USB_ENDPOINT 15 /* The highest valid USB endpoint number */ -#define MAX_USB_HUB_PORT 15 /* The highest valid port number on a hub */ -#define MAX_TRANSFER_BYTES ((1<<19)-1) /* The low level hardware can transfer a maximum of this number of bytes in each transfer. The field is 19 bits wide */ -#define MAX_TRANSFER_PACKETS ((1<<10)-1) /* The low level hardware can transfer a maximum of this number of packets in each transfer. The field is 10 bits wide */ +#define MAX_RETRIES 3 /* Maximum number of times to retry failed transactions */ +#define MAX_PIPES 32 /* Maximum number of pipes that can be open at once */ +#define MAX_TRANSACTIONS 256 /* Maximum number of outstanding transactions across all pipes */ +#define MAX_CHANNELS 8 /* Maximum number of hardware channels supported by the USB block */ +#define MAX_USB_ADDRESS 127 /* The highest valid USB device address */ +#define MAX_USB_ENDPOINT 15 /* The highest valid USB endpoint number */ +#define MAX_USB_HUB_PORT 15 /* The highest valid port number on a hub */ +#define MAX_TRANSFER_BYTES ((1<<19)-1) /* The low level hardware can transfer a maximum of this number of bytes in each transfer. The field is 19 bits wide */ +#define MAX_TRANSFER_PACKETS ((1<<10)-1) /* The low level hardware can transfer a maximum of this number of packets in each transfer. The field is 10 bits wide */ /* These defines disable the normal read and write csr. This is so I can add - extra debug stuff to the usb specific version and I won't use the normal - version by mistake */ + extra debug stuff to the usb specific version and I won't use the normal + version by mistake */ #define cvmx_read_csr use_cvmx_usb_read_csr64_instead_of_cvmx_read_csr #define cvmx_write_csr use_cvmx_usb_write_csr64_instead_of_cvmx_write_csr typedef enum { - __CVMX_USB_TRANSACTION_FLAGS_IN_USE = 1<<16, + __CVMX_USB_TRANSACTION_FLAGS_IN_USE = 1<<16, } cvmx_usb_transaction_flags_t; enum { @@ -104,14 +104,14 @@ enum { * transaction with a simple clearing of bit 0. */ typedef enum { - CVMX_USB_STAGE_NON_CONTROL, - CVMX_USB_STAGE_NON_CONTROL_SPLIT_COMPLETE, - CVMX_USB_STAGE_SETUP, - CVMX_USB_STAGE_SETUP_SPLIT_COMPLETE, - CVMX_USB_STAGE_DATA, - CVMX_USB_STAGE_DATA_SPLIT_COMPLETE, - CVMX_USB_STAGE_STATUS, - CVMX_USB_STAGE_STATUS_SPLIT_COMPLETE, + CVMX_USB_STAGE_NON_CONTROL, + CVMX_USB_STAGE_NON_CONTROL_SPLIT_COMPLETE, + CVMX_USB_STAGE_SETUP, + CVMX_USB_STAGE_SETUP_SPLIT_COMPLETE, + CVMX_USB_STAGE_DATA, + CVMX_USB_STAGE_DATA_SPLIT_COMPLETE, + CVMX_USB_STAGE_STATUS, + CVMX_USB_STAGE_STATUS_SPLIT_COMPLETE, } cvmx_usb_stage_t; /** @@ -120,23 +120,23 @@ typedef enum { * of pending requests for a pipe. */ typedef struct cvmx_usb_transaction { - struct cvmx_usb_transaction *prev; /**< Transaction before this one in the pipe */ - struct cvmx_usb_transaction *next; /**< Transaction after this one in the pipe */ - cvmx_usb_transfer_t type; /**< Type of transaction, duplicated of the pipe */ - cvmx_usb_transaction_flags_t flags; /**< State flags for this transaction */ - uint64_t buffer; /**< User's physical buffer address to read/write */ - int buffer_length; /**< Size of the user's buffer in bytes */ - uint64_t control_header; /**< For control transactions, physical address of the 8 byte standard header */ - int iso_start_frame; /**< For ISO transactions, the starting frame number */ - int iso_number_packets; /**< For ISO transactions, the number of packets in the request */ - cvmx_usb_iso_packet_t *iso_packets; /**< For ISO transactions, the sub packets in the request */ - int xfersize; - int pktcnt; - int retries; - int actual_bytes; /**< Actual bytes transfer for this transaction */ - cvmx_usb_stage_t stage; /**< For control transactions, the current stage */ - cvmx_usb_callback_func_t callback; /**< User's callback function when complete */ - void *callback_data; /**< User's data */ + struct cvmx_usb_transaction *prev; /**< Transaction before this one in the pipe */ + struct cvmx_usb_transaction *next; /**< Transaction after this one in the pipe */ + cvmx_usb_transfer_t type; /**< Type of transaction, duplicated of the pipe */ + cvmx_usb_transaction_flags_t flags; /**< State flags for this transaction */ + uint64_t buffer; /**< User's physical buffer address to read/write */ + int buffer_length; /**< Size of the user's buffer in bytes */ + uint64_t control_header; /**< For control transactions, physical address of the 8 byte standard header */ + int iso_start_frame; /**< For ISO transactions, the starting frame number */ + int iso_number_packets; /**< For ISO transactions, the number of packets in the request */ + cvmx_usb_iso_packet_t *iso_packets; /**< For ISO transactions, the sub packets in the request */ + int xfersize; + int pktcnt; + int retries; + int actual_bytes; /**< Actual bytes transfer for this transaction */ + cvmx_usb_stage_t stage; /**< For control transactions, the current stage */ + cvmx_usb_callback_func_t callback; /**< User's callback function when complete */ + void *callback_data; /**< User's data */ } cvmx_usb_transaction_t; /** @@ -144,99 +144,98 @@ typedef struct cvmx_usb_transaction { * USB device. It contains a list of pending request to the device. */ typedef struct cvmx_usb_pipe { - struct cvmx_usb_pipe *prev; /**< Pipe before this one in the list */ - struct cvmx_usb_pipe *next; /**< Pipe after this one in the list */ - cvmx_usb_transaction_t *head; /**< The first pending transaction */ - cvmx_usb_transaction_t *tail; /**< The last pending transaction */ - uint64_t interval; /**< For periodic pipes, the interval between packets in frames */ - uint64_t next_tx_frame; /**< The next frame this pipe is allowed to transmit on */ - cvmx_usb_pipe_flags_t flags; /**< State flags for this pipe */ - cvmx_usb_speed_t device_speed; /**< Speed of device connected to this pipe */ - cvmx_usb_transfer_t transfer_type; /**< Type of transaction supported by this pipe */ - cvmx_usb_direction_t transfer_dir; /**< IN or OUT. Ignored for Control */ - int multi_count; /**< Max packet in a row for the device */ - uint16_t max_packet; /**< The device's maximum packet size in bytes */ - uint8_t device_addr; /**< USB device address at other end of pipe */ - uint8_t endpoint_num; /**< USB endpoint number at other end of pipe */ - uint8_t hub_device_addr; /**< Hub address this device is connected to */ - uint8_t hub_port; /**< Hub port this device is connected to */ - uint8_t pid_toggle; /**< This toggles between 0/1 on every packet send to track the data pid needed */ - uint8_t channel; /**< Hardware DMA channel for this pipe */ - int8_t split_sc_frame; /**< The low order bits of the frame number the split complete should be sent on */ + struct cvmx_usb_pipe *prev; /**< Pipe before this one in the list */ + struct cvmx_usb_pipe *next; /**< Pipe after this one in the list */ + cvmx_usb_transaction_t *head; /**< The first pending transaction */ + cvmx_usb_transaction_t *tail; /**< The last pending transaction */ + uint64_t interval; /**< For periodic pipes, the interval between packets in frames */ + uint64_t next_tx_frame; /**< The next frame this pipe is allowed to transmit on */ + cvmx_usb_pipe_flags_t flags; /**< State flags for this pipe */ + cvmx_usb_speed_t device_speed; /**< Speed of device connected to this pipe */ + cvmx_usb_transfer_t transfer_type; /**< Type of transaction supported by this pipe */ + cvmx_usb_direction_t transfer_dir; /**< IN or OUT. Ignored for Control */ + int multi_count; /**< Max packet in a row for the device */ + uint16_t max_packet; /**< The device's maximum packet size in bytes */ + uint8_t device_addr; /**< USB device address at other end of pipe */ + uint8_t endpoint_num; /**< USB endpoint number at other end of pipe */ + uint8_t hub_device_addr; /**< Hub address this device is connected to */ + uint8_t hub_port; /**< Hub port this device is connected to */ + uint8_t pid_toggle; /**< This toggles between 0/1 on every packet send to track the data pid needed */ + uint8_t channel; /**< Hardware DMA channel for this pipe */ + int8_t split_sc_frame; /**< The low order bits of the frame number the split complete should be sent on */ } cvmx_usb_pipe_t; typedef struct { - cvmx_usb_pipe_t *head; /**< Head of the list, or NULL if empty */ - cvmx_usb_pipe_t *tail; /**< Tail if the list, or NULL if empty */ + cvmx_usb_pipe_t *head; /**< Head of the list, or NULL if empty */ + cvmx_usb_pipe_t *tail; /**< Tail if the list, or NULL if empty */ } cvmx_usb_pipe_list_t; typedef struct { - struct { - int channel; - int size; - uint64_t address; - } entry[MAX_CHANNELS+1]; - int head; - int tail; + struct { + int channel; + int size; + uint64_t address; + } entry[MAX_CHANNELS+1]; + int head; + int tail; } cvmx_usb_tx_fifo_t; /** * The state of the USB block is stored in this structure */ typedef struct { - int init_flags; /**< Flags passed to initialize */ - int index; /**< Which USB block this is for */ - int idle_hardware_channels; /**< Bit set for every idle hardware channel */ - cvmx_usbcx_hprt_t usbcx_hprt; /**< Stored port status so we don't need to read a CSR to determine splits */ - cvmx_usb_pipe_t *pipe_for_channel[MAX_CHANNELS]; /**< Map channels to pipes */ - cvmx_usb_transaction_t *free_transaction_head; /**< List of free transactions head */ - cvmx_usb_transaction_t *free_transaction_tail; /**< List of free transactions tail */ - cvmx_usb_pipe_t pipe[MAX_PIPES]; /**< Storage for pipes */ - cvmx_usb_transaction_t transaction[MAX_TRANSACTIONS]; /**< Storage for transactions */ - cvmx_usb_callback_func_t callback[__CVMX_USB_CALLBACK_END]; /**< User global callbacks */ - void *callback_data[__CVMX_USB_CALLBACK_END]; /**< User data for each callback */ - int indent; /**< Used by debug output to indent functions */ - cvmx_usb_port_status_t port_status; /**< Last port status used for change notification */ - cvmx_usb_pipe_list_t free_pipes; /**< List of all pipes that are currently closed */ - cvmx_usb_pipe_list_t idle_pipes; /**< List of open pipes that have no transactions */ - cvmx_usb_pipe_list_t active_pipes[4]; /**< Active pipes indexed by transfer type */ - uint64_t frame_number; /**< Increments every SOF interrupt for time keeping */ - cvmx_usb_transaction_t *active_split; /**< Points to the current active split, or NULL */ - cvmx_usb_tx_fifo_t periodic; - cvmx_usb_tx_fifo_t nonperiodic; + int init_flags; /**< Flags passed to initialize */ + int index; /**< Which USB block this is for */ + int idle_hardware_channels; /**< Bit set for every idle hardware channel */ + cvmx_usbcx_hprt_t usbcx_hprt; /**< Stored port status so we don't need to read a CSR to determine splits */ + cvmx_usb_pipe_t *pipe_for_channel[MAX_CHANNELS]; /**< Map channels to pipes */ + cvmx_usb_transaction_t *free_transaction_head; /**< List of free transactions head */ + cvmx_usb_transaction_t *free_transaction_tail; /**< List of free transactions tail */ + cvmx_usb_pipe_t pipe[MAX_PIPES]; /**< Storage for pipes */ + cvmx_usb_transaction_t transaction[MAX_TRANSACTIONS]; /**< Storage for transactions */ + cvmx_usb_callback_func_t callback[__CVMX_USB_CALLBACK_END]; /**< User global callbacks */ + void *callback_data[__CVMX_USB_CALLBACK_END]; /**< User data for each callback */ + int indent; /**< Used by debug output to indent functions */ + cvmx_usb_port_status_t port_status; /**< Last port status used for change notification */ + cvmx_usb_pipe_list_t free_pipes; /**< List of all pipes that are currently closed */ + cvmx_usb_pipe_list_t idle_pipes; /**< List of open pipes that have no transactions */ + cvmx_usb_pipe_list_t active_pipes[4]; /**< Active pipes indexed by transfer type */ + uint64_t frame_number; /**< Increments every SOF interrupt for time keeping */ + cvmx_usb_transaction_t *active_split; /**< Points to the current active split, or NULL */ + cvmx_usb_tx_fifo_t periodic; + cvmx_usb_tx_fifo_t nonperiodic; } cvmx_usb_internal_state_t; /* This macro spins on a field waiting for it to reach a value */ #define CVMX_WAIT_FOR_FIELD32(address, type, field, op, value, timeout_usec)\ - ({int result; \ - do { \ - uint64_t done = cvmx_get_cycle() + (uint64_t)timeout_usec * \ - octeon_get_clock_rate() / 1000000; \ - type c; \ - while (1) \ - { \ - c.u32 = __cvmx_usb_read_csr32(usb, address); \ - if (c.s.field op (value)) { \ - result = 0; \ - break; \ - } else if (cvmx_get_cycle() > done) { \ - result = -1; \ - break; \ - } else \ - cvmx_wait(100); \ - } \ - } while (0); \ - result;}) + ({int result; \ + do { \ + uint64_t done = cvmx_get_cycle() + (uint64_t)timeout_usec * \ + octeon_get_clock_rate() / 1000000; \ + type c; \ + while (1) { \ + c.u32 = __cvmx_usb_read_csr32(usb, address); \ + if (c.s.field op (value)) { \ + result = 0; \ + break; \ + } else if (cvmx_get_cycle() > done) { \ + result = -1; \ + break; \ + } else \ + cvmx_wait(100); \ + } \ + } while (0); \ + result; }) /* This macro logically sets a single field in a CSR. It does the sequence - read, modify, and write */ -#define USB_SET_FIELD32(address, type, field, value)\ - do { \ - type c; \ - c.u32 = __cvmx_usb_read_csr32(usb, address);\ - c.s.field = value; \ - __cvmx_usb_write_csr32(usb, address, c.u32);\ - } while (0) + read, modify, and write */ +#define USB_SET_FIELD32(address, type, field, value) \ + do { \ + type c; \ + c.u32 = __cvmx_usb_read_csr32(usb, address); \ + c.s.field = value; \ + __cvmx_usb_write_csr32(usb, address, c.u32); \ + } while (0) /* Returns the IO address to push/pop stuff data from the FIFOs */ #define USB_FIFO_ADDRESS(channel, usb_index) (CVMX_USBCX_GOTGCTL(usb_index) + ((channel)+1)*0x1000) @@ -266,10 +265,10 @@ static int octeon_usb_get_clock_type(void) * @return Result of the read */ static inline uint32_t __cvmx_usb_read_csr32(cvmx_usb_internal_state_t *usb, - uint64_t address) + uint64_t address) { - uint32_t result = cvmx_read64_uint32(address ^ 4); - return result; + uint32_t result = cvmx_read64_uint32(address ^ 4); + return result; } @@ -284,10 +283,10 @@ static inline uint32_t __cvmx_usb_read_csr32(cvmx_usb_internal_state_t *usb, * @param value Value to write */ static inline void __cvmx_usb_write_csr32(cvmx_usb_internal_state_t *usb, - uint64_t address, uint32_t value) + uint64_t address, uint32_t value) { - cvmx_write64_uint32(address ^ 4, value); - cvmx_read64_uint64(CVMX_USBNX_DMA0_INB_CHN0(usb->index)); + cvmx_write64_uint32(address ^ 4, value); + cvmx_read64_uint64(CVMX_USBNX_DMA0_INB_CHN0(usb->index)); } @@ -302,10 +301,10 @@ static inline void __cvmx_usb_write_csr32(cvmx_usb_internal_state_t *usb, * @return Result of the read */ static inline uint64_t __cvmx_usb_read_csr64(cvmx_usb_internal_state_t *usb, - uint64_t address) + uint64_t address) { - uint64_t result = cvmx_read64_uint64(address); - return result; + uint64_t result = cvmx_read64_uint64(address); + return result; } @@ -319,9 +318,9 @@ static inline uint64_t __cvmx_usb_read_csr64(cvmx_usb_internal_state_t *usb, * @param value Value to write */ static inline void __cvmx_usb_write_csr64(cvmx_usb_internal_state_t *usb, - uint64_t address, uint64_t value) + uint64_t address, uint64_t value) { - cvmx_write64_uint64(address, value); + cvmx_write64_uint64(address, value); } /** @@ -336,7 +335,7 @@ static inline void __cvmx_usb_write_csr64(cvmx_usb_internal_state_t *usb, */ static inline int __cvmx_usb_pipe_needs_split(cvmx_usb_internal_state_t *usb, cvmx_usb_pipe_t *pipe) { - return ((pipe->device_speed != CVMX_USB_SPEED_HIGH) && (usb->usbcx_hprt.s.prtspd == CVMX_USB_SPEED_HIGH)); + return ((pipe->device_speed != CVMX_USB_SPEED_HIGH) && (usb->usbcx_hprt.s.prtspd == CVMX_USB_SPEED_HIGH)); } @@ -350,10 +349,10 @@ static inline int __cvmx_usb_pipe_needs_split(cvmx_usb_internal_state_t *usb, cv */ static inline int __cvmx_usb_get_data_pid(cvmx_usb_pipe_t *pipe) { - if (pipe->pid_toggle) - return 2; /* Data1 */ - else - return 0; /* Data0 */ + if (pipe->pid_toggle) + return 2; /* Data1 */ + else + return 0; /* Data0 */ } @@ -369,22 +368,22 @@ static inline int __cvmx_usb_get_data_pid(cvmx_usb_pipe_t *pipe) */ int cvmx_usb_get_num_ports(void) { - int arch_ports = 0; - - if (OCTEON_IS_MODEL(OCTEON_CN56XX)) - arch_ports = 1; - else if (OCTEON_IS_MODEL(OCTEON_CN52XX)) - arch_ports = 2; - else if (OCTEON_IS_MODEL(OCTEON_CN50XX)) - arch_ports = 1; - else if (OCTEON_IS_MODEL(OCTEON_CN31XX)) - arch_ports = 1; - else if (OCTEON_IS_MODEL(OCTEON_CN30XX)) - arch_ports = 1; - else - arch_ports = 0; - - return arch_ports; + int arch_ports = 0; + + if (OCTEON_IS_MODEL(OCTEON_CN56XX)) + arch_ports = 1; + else if (OCTEON_IS_MODEL(OCTEON_CN52XX)) + arch_ports = 2; + else if (OCTEON_IS_MODEL(OCTEON_CN50XX)) + arch_ports = 1; + else if (OCTEON_IS_MODEL(OCTEON_CN31XX)) + arch_ports = 1; + else if (OCTEON_IS_MODEL(OCTEON_CN30XX)) + arch_ports = 1; + else + arch_ports = 0; + + return arch_ports; } @@ -392,25 +391,25 @@ int cvmx_usb_get_num_ports(void) * @INTERNAL * Allocate a usb transaction for use * - * @param usb USB device state populated by - * cvmx_usb_initialize(). + * @param usb USB device state populated by + * cvmx_usb_initialize(). * * @return Transaction or NULL */ static inline cvmx_usb_transaction_t *__cvmx_usb_alloc_transaction(cvmx_usb_internal_state_t *usb) { - cvmx_usb_transaction_t *t; - t = usb->free_transaction_head; - if (t) { - usb->free_transaction_head = t->next; - if (!usb->free_transaction_head) - usb->free_transaction_tail = NULL; - } - if (t) { - memset(t, 0, sizeof(*t)); - t->flags = __CVMX_USB_TRANSACTION_FLAGS_IN_USE; - } - return t; + cvmx_usb_transaction_t *t; + t = usb->free_transaction_head; + if (t) { + usb->free_transaction_head = t->next; + if (!usb->free_transaction_head) + usb->free_transaction_tail = NULL; + } + if (t) { + memset(t, 0, sizeof(*t)); + t->flags = __CVMX_USB_TRANSACTION_FLAGS_IN_USE; + } + return t; } @@ -418,22 +417,22 @@ static inline cvmx_usb_transaction_t *__cvmx_usb_alloc_transaction(cvmx_usb_inte * @INTERNAL * Free a usb transaction * - * @param usb USB device state populated by - * cvmx_usb_initialize(). + * @param usb USB device state populated by + * cvmx_usb_initialize(). * @param transaction - * Transaction to free + * Transaction to free */ static inline void __cvmx_usb_free_transaction(cvmx_usb_internal_state_t *usb, - cvmx_usb_transaction_t *transaction) + cvmx_usb_transaction_t *transaction) { - transaction->flags = 0; - transaction->prev = NULL; - transaction->next = NULL; - if (usb->free_transaction_tail) - usb->free_transaction_tail->next = transaction; - else - usb->free_transaction_head = transaction; - usb->free_transaction_tail = transaction; + transaction->flags = 0; + transaction->prev = NULL; + transaction->next = NULL; + if (usb->free_transaction_tail) + usb->free_transaction_tail->next = transaction; + else + usb->free_transaction_head = transaction; + usb->free_transaction_tail = transaction; } @@ -445,13 +444,13 @@ static inline void __cvmx_usb_free_transaction(cvmx_usb_internal_state_t *usb, */ static inline void __cvmx_usb_append_pipe(cvmx_usb_pipe_list_t *list, cvmx_usb_pipe_t *pipe) { - pipe->next = NULL; - pipe->prev = list->tail; - if (list->tail) - list->tail->next = pipe; - else - list->head = pipe; - list->tail = pipe; + pipe->next = NULL; + pipe->prev = list->tail; + if (list->tail) + list->tail->next = pipe; + else + list->head = pipe; + list->tail = pipe; } @@ -463,25 +462,23 @@ static inline void __cvmx_usb_append_pipe(cvmx_usb_pipe_list_t *list, cvmx_usb_p */ static inline void __cvmx_usb_remove_pipe(cvmx_usb_pipe_list_t *list, cvmx_usb_pipe_t *pipe) { - if (list->head == pipe) { - list->head = pipe->next; - pipe->next = NULL; - if (list->head) - list->head->prev = NULL; - else - list->tail = NULL; - } - else if (list->tail == pipe) { - list->tail = pipe->prev; - list->tail->next = NULL; - pipe->prev = NULL; - } - else { - pipe->prev->next = pipe->next; - pipe->next->prev = pipe->prev; - pipe->prev = NULL; - pipe->next = NULL; - } + if (list->head == pipe) { + list->head = pipe->next; + pipe->next = NULL; + if (list->head) + list->head->prev = NULL; + else + list->tail = NULL; + } else if (list->tail == pipe) { + list->tail = pipe->prev; + list->tail->next = NULL; + pipe->prev = NULL; + } else { + pipe->prev->next = pipe->next; + pipe->next->prev = pipe->prev; + pipe->prev = NULL; + pipe->next = NULL; + } } @@ -491,293 +488,290 @@ static inline void __cvmx_usb_remove_pipe(cvmx_usb_pipe_list_t *list, cvmx_usb_p * off in the disabled state. * * @param state Pointer to an empty cvmx_usb_state_t structure - * that will be populated by the initialize call. - * This structure is then passed to all other USB - * functions. + * that will be populated by the initialize call. + * This structure is then passed to all other USB + * functions. * @param usb_port_number - * Which Octeon USB port to initialize. + * Which Octeon USB port to initialize. * @param flags Flags to control hardware initialization. See - * cvmx_usb_initialize_flags_t for the flag - * definitions. Some flags are mandatory. + * cvmx_usb_initialize_flags_t for the flag + * definitions. Some flags are mandatory. * * @return 0 or a negative error code. */ int cvmx_usb_initialize(cvmx_usb_state_t *state, int usb_port_number, cvmx_usb_initialize_flags_t flags) { - cvmx_usbnx_clk_ctl_t usbn_clk_ctl; - cvmx_usbnx_usbp_ctl_status_t usbn_usbp_ctl_status; - cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; - - usb->init_flags = flags; - - /* Make sure that state is large enough to store the internal state */ - if (sizeof(*state) < sizeof(*usb)) - return -EINVAL; - /* At first allow 0-1 for the usb port number */ - if ((usb_port_number < 0) || (usb_port_number > 1)) - return -EINVAL; - /* For all chips except 52XX there is only one port */ - if (!OCTEON_IS_MODEL(OCTEON_CN52XX) && (usb_port_number > 0)) - return -EINVAL; - /* Try to determine clock type automatically */ - if ((flags & (CVMX_USB_INITIALIZE_FLAGS_CLOCK_XO_XI | - CVMX_USB_INITIALIZE_FLAGS_CLOCK_XO_GND)) == 0) { - if (octeon_usb_get_clock_type() == USB_CLOCK_TYPE_CRYSTAL_12) - flags |= CVMX_USB_INITIALIZE_FLAGS_CLOCK_XO_XI; /* Only 12 MHZ crystals are supported */ - else - flags |= CVMX_USB_INITIALIZE_FLAGS_CLOCK_XO_GND; - } - - if (flags & CVMX_USB_INITIALIZE_FLAGS_CLOCK_XO_GND) { - /* Check for auto ref clock frequency */ - if (!(flags & CVMX_USB_INITIALIZE_FLAGS_CLOCK_MHZ_MASK)) - switch (octeon_usb_get_clock_type()) { - case USB_CLOCK_TYPE_REF_12: - flags |= CVMX_USB_INITIALIZE_FLAGS_CLOCK_12MHZ; - break; - case USB_CLOCK_TYPE_REF_24: - flags |= CVMX_USB_INITIALIZE_FLAGS_CLOCK_24MHZ; - break; - case USB_CLOCK_TYPE_REF_48: - flags |= CVMX_USB_INITIALIZE_FLAGS_CLOCK_48MHZ; - break; - default: - return -EINVAL; - break; - } - } - - memset(usb, 0, sizeof(usb)); - usb->init_flags = flags; - - /* Initialize the USB state structure */ - { - int i; - usb->index = usb_port_number; - - /* Initialize the transaction double linked list */ - usb->free_transaction_head = NULL; - usb->free_transaction_tail = NULL; - for (i=0; itransaction + i); - for (i=0; ifree_pipes, usb->pipe + i); - } - - /* Power On Reset and PHY Initialization */ - - /* 1. Wait for DCOK to assert (nothing to do) */ - /* 2a. Write USBN0/1_CLK_CTL[POR] = 1 and - USBN0/1_CLK_CTL[HRST,PRST,HCLK_RST] = 0 */ - usbn_clk_ctl.u64 = __cvmx_usb_read_csr64(usb, CVMX_USBNX_CLK_CTL(usb->index)); - usbn_clk_ctl.s.por = 1; - usbn_clk_ctl.s.hrst = 0; - usbn_clk_ctl.s.prst = 0; - usbn_clk_ctl.s.hclk_rst = 0; - usbn_clk_ctl.s.enable = 0; - /* 2b. Select the USB reference clock/crystal parameters by writing - appropriate values to USBN0/1_CLK_CTL[P_C_SEL, P_RTYPE, P_COM_ON] */ - if (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_CLOCK_XO_GND) { - /* The USB port uses 12/24/48MHz 2.5V board clock - source at USB_XO. USB_XI should be tied to GND. - Most Octeon evaluation boards require this setting */ - if (OCTEON_IS_MODEL(OCTEON_CN3XXX)) { - usbn_clk_ctl.cn31xx.p_rclk = 1; /* From CN31XX,CN30XX manual */ - usbn_clk_ctl.cn31xx.p_xenbn = 0; - } - else if (OCTEON_IS_MODEL(OCTEON_CN56XX) || OCTEON_IS_MODEL(OCTEON_CN50XX)) - usbn_clk_ctl.cn56xx.p_rtype = 2; /* From CN56XX,CN50XX manual */ - else - usbn_clk_ctl.cn52xx.p_rtype = 1; /* From CN52XX manual */ - - switch (flags & CVMX_USB_INITIALIZE_FLAGS_CLOCK_MHZ_MASK) { - case CVMX_USB_INITIALIZE_FLAGS_CLOCK_12MHZ: - usbn_clk_ctl.s.p_c_sel = 0; - break; - case CVMX_USB_INITIALIZE_FLAGS_CLOCK_24MHZ: - usbn_clk_ctl.s.p_c_sel = 1; - break; - case CVMX_USB_INITIALIZE_FLAGS_CLOCK_48MHZ: - usbn_clk_ctl.s.p_c_sel = 2; - break; - } - } - else { - /* The USB port uses a 12MHz crystal as clock source - at USB_XO and USB_XI */ - if (OCTEON_IS_MODEL(OCTEON_CN3XXX)) { - usbn_clk_ctl.cn31xx.p_rclk = 1; /* From CN31XX,CN30XX manual */ - usbn_clk_ctl.cn31xx.p_xenbn = 1; - } - else if (OCTEON_IS_MODEL(OCTEON_CN56XX) || OCTEON_IS_MODEL(OCTEON_CN50XX)) - usbn_clk_ctl.cn56xx.p_rtype = 0; /* From CN56XX,CN50XX manual */ - else - usbn_clk_ctl.cn52xx.p_rtype = 0; /* From CN52XX manual */ - - usbn_clk_ctl.s.p_c_sel = 0; - } - /* 2c. Select the HCLK via writing USBN0/1_CLK_CTL[DIVIDE, DIVIDE2] and - setting USBN0/1_CLK_CTL[ENABLE] = 1. Divide the core clock down such - that USB is as close as possible to 125Mhz */ - { - int divisor = (octeon_get_clock_rate()+125000000-1)/125000000; - if (divisor < 4) /* Lower than 4 doesn't seem to work properly */ - divisor = 4; - usbn_clk_ctl.s.divide = divisor; - usbn_clk_ctl.s.divide2 = 0; - } - __cvmx_usb_write_csr64(usb, CVMX_USBNX_CLK_CTL(usb->index), - usbn_clk_ctl.u64); - /* 2d. Write USBN0/1_CLK_CTL[HCLK_RST] = 1 */ - usbn_clk_ctl.s.hclk_rst = 1; - __cvmx_usb_write_csr64(usb, CVMX_USBNX_CLK_CTL(usb->index), - usbn_clk_ctl.u64); - /* 2e. Wait 64 core-clock cycles for HCLK to stabilize */ - cvmx_wait(64); - /* 3. Program the power-on reset field in the USBN clock-control register: - USBN_CLK_CTL[POR] = 0 */ - usbn_clk_ctl.s.por = 0; - __cvmx_usb_write_csr64(usb, CVMX_USBNX_CLK_CTL(usb->index), - usbn_clk_ctl.u64); - /* 4. Wait 1 ms for PHY clock to start */ - mdelay(1); - /* 5. Program the Reset input from automatic test equipment field in the - USBP control and status register: USBN_USBP_CTL_STATUS[ATE_RESET] = 1 */ - usbn_usbp_ctl_status.u64 = __cvmx_usb_read_csr64(usb, CVMX_USBNX_USBP_CTL_STATUS(usb->index)); - usbn_usbp_ctl_status.s.ate_reset = 1; - __cvmx_usb_write_csr64(usb, CVMX_USBNX_USBP_CTL_STATUS(usb->index), - usbn_usbp_ctl_status.u64); - /* 6. Wait 10 cycles */ - cvmx_wait(10); - /* 7. Clear ATE_RESET field in the USBN clock-control register: - USBN_USBP_CTL_STATUS[ATE_RESET] = 0 */ - usbn_usbp_ctl_status.s.ate_reset = 0; - __cvmx_usb_write_csr64(usb, CVMX_USBNX_USBP_CTL_STATUS(usb->index), - usbn_usbp_ctl_status.u64); - /* 8. Program the PHY reset field in the USBN clock-control register: - USBN_CLK_CTL[PRST] = 1 */ - usbn_clk_ctl.s.prst = 1; - __cvmx_usb_write_csr64(usb, CVMX_USBNX_CLK_CTL(usb->index), - usbn_clk_ctl.u64); - /* 9. Program the USBP control and status register to select host or - device mode. USBN_USBP_CTL_STATUS[HST_MODE] = 0 for host, = 1 for - device */ - usbn_usbp_ctl_status.s.hst_mode = 0; - __cvmx_usb_write_csr64(usb, CVMX_USBNX_USBP_CTL_STATUS(usb->index), - usbn_usbp_ctl_status.u64); - /* 10. Wait 1 us */ - udelay(1); - /* 11. Program the hreset_n field in the USBN clock-control register: - USBN_CLK_CTL[HRST] = 1 */ - usbn_clk_ctl.s.hrst = 1; - __cvmx_usb_write_csr64(usb, CVMX_USBNX_CLK_CTL(usb->index), - usbn_clk_ctl.u64); - /* 12. Proceed to USB core initialization */ - usbn_clk_ctl.s.enable = 1; - __cvmx_usb_write_csr64(usb, CVMX_USBNX_CLK_CTL(usb->index), - usbn_clk_ctl.u64); - udelay(1); - - /* USB Core Initialization */ - - /* 1. Read USBC_GHWCFG1, USBC_GHWCFG2, USBC_GHWCFG3, USBC_GHWCFG4 to - determine USB core configuration parameters. */ - /* Nothing needed */ - /* 2. Program the following fields in the global AHB configuration - register (USBC_GAHBCFG) - DMA mode, USBC_GAHBCFG[DMAEn]: 1 = DMA mode, 0 = slave mode - Burst length, USBC_GAHBCFG[HBSTLEN] = 0 - Nonperiodic TxFIFO empty level (slave mode only), - USBC_GAHBCFG[NPTXFEMPLVL] - Periodic TxFIFO empty level (slave mode only), - USBC_GAHBCFG[PTXFEMPLVL] - Global interrupt mask, USBC_GAHBCFG[GLBLINTRMSK] = 1 */ - { - cvmx_usbcx_gahbcfg_t usbcx_gahbcfg; - /* Due to an errata, CN31XX doesn't support DMA */ - if (OCTEON_IS_MODEL(OCTEON_CN31XX)) - usb->init_flags |= CVMX_USB_INITIALIZE_FLAGS_NO_DMA; - usbcx_gahbcfg.u32 = 0; - usbcx_gahbcfg.s.dmaen = !(usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA); - if (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA) - usb->idle_hardware_channels = 0x1; /* Only use one channel with non DMA */ - else if (OCTEON_IS_MODEL(OCTEON_CN5XXX)) - usb->idle_hardware_channels = 0xf7; /* CN5XXX have an errata with channel 3 */ - else - usb->idle_hardware_channels = 0xff; - usbcx_gahbcfg.s.hbstlen = 0; - usbcx_gahbcfg.s.nptxfemplvl = 1; - usbcx_gahbcfg.s.ptxfemplvl = 1; - usbcx_gahbcfg.s.glblintrmsk = 1; - __cvmx_usb_write_csr32(usb, CVMX_USBCX_GAHBCFG(usb->index), - usbcx_gahbcfg.u32); - } - /* 3. Program the following fields in USBC_GUSBCFG register. - HS/FS timeout calibration, USBC_GUSBCFG[TOUTCAL] = 0 - ULPI DDR select, USBC_GUSBCFG[DDRSEL] = 0 - USB turnaround time, USBC_GUSBCFG[USBTRDTIM] = 0x5 - PHY low-power clock select, USBC_GUSBCFG[PHYLPWRCLKSEL] = 0 */ - { - cvmx_usbcx_gusbcfg_t usbcx_gusbcfg; - usbcx_gusbcfg.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_GUSBCFG(usb->index)); - usbcx_gusbcfg.s.toutcal = 0; - usbcx_gusbcfg.s.ddrsel = 0; - usbcx_gusbcfg.s.usbtrdtim = 0x5; - usbcx_gusbcfg.s.phylpwrclksel = 0; - __cvmx_usb_write_csr32(usb, CVMX_USBCX_GUSBCFG(usb->index), - usbcx_gusbcfg.u32); - } - /* 4. The software must unmask the following bits in the USBC_GINTMSK - register. - OTG interrupt mask, USBC_GINTMSK[OTGINTMSK] = 1 - Mode mismatch interrupt mask, USBC_GINTMSK[MODEMISMSK] = 1 */ - { - cvmx_usbcx_gintmsk_t usbcx_gintmsk; - int channel; - - usbcx_gintmsk.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_GINTMSK(usb->index)); - usbcx_gintmsk.s.otgintmsk = 1; - usbcx_gintmsk.s.modemismsk = 1; - usbcx_gintmsk.s.hchintmsk = 1; - usbcx_gintmsk.s.sofmsk = 0; - /* We need RX FIFO interrupts if we don't have DMA */ - if (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA) - usbcx_gintmsk.s.rxflvlmsk = 1; - __cvmx_usb_write_csr32(usb, CVMX_USBCX_GINTMSK(usb->index), - usbcx_gintmsk.u32); - - /* Disable all channel interrupts. We'll enable them per channel later */ - for (channel=0; channel<8; channel++) - __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCINTMSKX(channel, usb->index), 0); - } - - { - /* Host Port Initialization */ - - /* 1. Program the host-port interrupt-mask field to unmask, - USBC_GINTMSK[PRTINT] = 1 */ - USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), cvmx_usbcx_gintmsk_t, - prtintmsk, 1); - USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), cvmx_usbcx_gintmsk_t, - disconnintmsk, 1); - /* 2. Program the USBC_HCFG register to select full-speed host or - high-speed host. */ - { - cvmx_usbcx_hcfg_t usbcx_hcfg; - usbcx_hcfg.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCFG(usb->index)); - usbcx_hcfg.s.fslssupp = 0; - usbcx_hcfg.s.fslspclksel = 0; - __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCFG(usb->index), usbcx_hcfg.u32); - } - /* 3. Program the port power bit to drive VBUS on the USB, - USBC_HPRT[PRTPWR] = 1 */ - USB_SET_FIELD32(CVMX_USBCX_HPRT(usb->index), cvmx_usbcx_hprt_t, prtpwr, 1); - - /* Steps 4-15 from the manual are done later in the port enable */ - } - - return 0; + cvmx_usbnx_clk_ctl_t usbn_clk_ctl; + cvmx_usbnx_usbp_ctl_status_t usbn_usbp_ctl_status; + cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; + + usb->init_flags = flags; + + /* Make sure that state is large enough to store the internal state */ + if (sizeof(*state) < sizeof(*usb)) + return -EINVAL; + /* At first allow 0-1 for the usb port number */ + if ((usb_port_number < 0) || (usb_port_number > 1)) + return -EINVAL; + /* For all chips except 52XX there is only one port */ + if (!OCTEON_IS_MODEL(OCTEON_CN52XX) && (usb_port_number > 0)) + return -EINVAL; + /* Try to determine clock type automatically */ + if ((flags & (CVMX_USB_INITIALIZE_FLAGS_CLOCK_XO_XI | + CVMX_USB_INITIALIZE_FLAGS_CLOCK_XO_GND)) == 0) { + if (octeon_usb_get_clock_type() == USB_CLOCK_TYPE_CRYSTAL_12) + flags |= CVMX_USB_INITIALIZE_FLAGS_CLOCK_XO_XI; /* Only 12 MHZ crystals are supported */ + else + flags |= CVMX_USB_INITIALIZE_FLAGS_CLOCK_XO_GND; + } + + if (flags & CVMX_USB_INITIALIZE_FLAGS_CLOCK_XO_GND) { + /* Check for auto ref clock frequency */ + if (!(flags & CVMX_USB_INITIALIZE_FLAGS_CLOCK_MHZ_MASK)) + switch (octeon_usb_get_clock_type()) { + case USB_CLOCK_TYPE_REF_12: + flags |= CVMX_USB_INITIALIZE_FLAGS_CLOCK_12MHZ; + break; + case USB_CLOCK_TYPE_REF_24: + flags |= CVMX_USB_INITIALIZE_FLAGS_CLOCK_24MHZ; + break; + case USB_CLOCK_TYPE_REF_48: + flags |= CVMX_USB_INITIALIZE_FLAGS_CLOCK_48MHZ; + break; + default: + return -EINVAL; + break; + } + } + + memset(usb, 0, sizeof(usb)); + usb->init_flags = flags; + + /* Initialize the USB state structure */ + { + int i; + usb->index = usb_port_number; + + /* Initialize the transaction double linked list */ + usb->free_transaction_head = NULL; + usb->free_transaction_tail = NULL; + for (i = 0; i < MAX_TRANSACTIONS; i++) + __cvmx_usb_free_transaction(usb, usb->transaction + i); + for (i = 0; i < MAX_PIPES; i++) + __cvmx_usb_append_pipe(&usb->free_pipes, usb->pipe + i); + } + + /* Power On Reset and PHY Initialization */ + + /* 1. Wait for DCOK to assert (nothing to do) */ + /* 2a. Write USBN0/1_CLK_CTL[POR] = 1 and + USBN0/1_CLK_CTL[HRST,PRST,HCLK_RST] = 0 */ + usbn_clk_ctl.u64 = __cvmx_usb_read_csr64(usb, CVMX_USBNX_CLK_CTL(usb->index)); + usbn_clk_ctl.s.por = 1; + usbn_clk_ctl.s.hrst = 0; + usbn_clk_ctl.s.prst = 0; + usbn_clk_ctl.s.hclk_rst = 0; + usbn_clk_ctl.s.enable = 0; + /* 2b. Select the USB reference clock/crystal parameters by writing + appropriate values to USBN0/1_CLK_CTL[P_C_SEL, P_RTYPE, P_COM_ON] */ + if (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_CLOCK_XO_GND) { + /* The USB port uses 12/24/48MHz 2.5V board clock + source at USB_XO. USB_XI should be tied to GND. + Most Octeon evaluation boards require this setting */ + if (OCTEON_IS_MODEL(OCTEON_CN3XXX)) { + usbn_clk_ctl.cn31xx.p_rclk = 1; /* From CN31XX,CN30XX manual */ + usbn_clk_ctl.cn31xx.p_xenbn = 0; + } else if (OCTEON_IS_MODEL(OCTEON_CN56XX) || OCTEON_IS_MODEL(OCTEON_CN50XX)) + usbn_clk_ctl.cn56xx.p_rtype = 2; /* From CN56XX,CN50XX manual */ + else + usbn_clk_ctl.cn52xx.p_rtype = 1; /* From CN52XX manual */ + + switch (flags & CVMX_USB_INITIALIZE_FLAGS_CLOCK_MHZ_MASK) { + case CVMX_USB_INITIALIZE_FLAGS_CLOCK_12MHZ: + usbn_clk_ctl.s.p_c_sel = 0; + break; + case CVMX_USB_INITIALIZE_FLAGS_CLOCK_24MHZ: + usbn_clk_ctl.s.p_c_sel = 1; + break; + case CVMX_USB_INITIALIZE_FLAGS_CLOCK_48MHZ: + usbn_clk_ctl.s.p_c_sel = 2; + break; + } + } else { + /* The USB port uses a 12MHz crystal as clock source + at USB_XO and USB_XI */ + if (OCTEON_IS_MODEL(OCTEON_CN3XXX)) { + usbn_clk_ctl.cn31xx.p_rclk = 1; /* From CN31XX,CN30XX manual */ + usbn_clk_ctl.cn31xx.p_xenbn = 1; + } else if (OCTEON_IS_MODEL(OCTEON_CN56XX) || OCTEON_IS_MODEL(OCTEON_CN50XX)) + usbn_clk_ctl.cn56xx.p_rtype = 0; /* From CN56XX,CN50XX manual */ + else + usbn_clk_ctl.cn52xx.p_rtype = 0; /* From CN52XX manual */ + + usbn_clk_ctl.s.p_c_sel = 0; + } + /* 2c. Select the HCLK via writing USBN0/1_CLK_CTL[DIVIDE, DIVIDE2] and + setting USBN0/1_CLK_CTL[ENABLE] = 1. Divide the core clock down such + that USB is as close as possible to 125Mhz */ + { + int divisor = (octeon_get_clock_rate()+125000000-1)/125000000; + if (divisor < 4) /* Lower than 4 doesn't seem to work properly */ + divisor = 4; + usbn_clk_ctl.s.divide = divisor; + usbn_clk_ctl.s.divide2 = 0; + } + __cvmx_usb_write_csr64(usb, CVMX_USBNX_CLK_CTL(usb->index), + usbn_clk_ctl.u64); + /* 2d. Write USBN0/1_CLK_CTL[HCLK_RST] = 1 */ + usbn_clk_ctl.s.hclk_rst = 1; + __cvmx_usb_write_csr64(usb, CVMX_USBNX_CLK_CTL(usb->index), + usbn_clk_ctl.u64); + /* 2e. Wait 64 core-clock cycles for HCLK to stabilize */ + cvmx_wait(64); + /* 3. Program the power-on reset field in the USBN clock-control register: + USBN_CLK_CTL[POR] = 0 */ + usbn_clk_ctl.s.por = 0; + __cvmx_usb_write_csr64(usb, CVMX_USBNX_CLK_CTL(usb->index), + usbn_clk_ctl.u64); + /* 4. Wait 1 ms for PHY clock to start */ + mdelay(1); + /* 5. Program the Reset input from automatic test equipment field in the + USBP control and status register: USBN_USBP_CTL_STATUS[ATE_RESET] = 1 */ + usbn_usbp_ctl_status.u64 = __cvmx_usb_read_csr64(usb, CVMX_USBNX_USBP_CTL_STATUS(usb->index)); + usbn_usbp_ctl_status.s.ate_reset = 1; + __cvmx_usb_write_csr64(usb, CVMX_USBNX_USBP_CTL_STATUS(usb->index), + usbn_usbp_ctl_status.u64); + /* 6. Wait 10 cycles */ + cvmx_wait(10); + /* 7. Clear ATE_RESET field in the USBN clock-control register: + USBN_USBP_CTL_STATUS[ATE_RESET] = 0 */ + usbn_usbp_ctl_status.s.ate_reset = 0; + __cvmx_usb_write_csr64(usb, CVMX_USBNX_USBP_CTL_STATUS(usb->index), + usbn_usbp_ctl_status.u64); + /* 8. Program the PHY reset field in the USBN clock-control register: + USBN_CLK_CTL[PRST] = 1 */ + usbn_clk_ctl.s.prst = 1; + __cvmx_usb_write_csr64(usb, CVMX_USBNX_CLK_CTL(usb->index), + usbn_clk_ctl.u64); + /* 9. Program the USBP control and status register to select host or + device mode. USBN_USBP_CTL_STATUS[HST_MODE] = 0 for host, = 1 for + device */ + usbn_usbp_ctl_status.s.hst_mode = 0; + __cvmx_usb_write_csr64(usb, CVMX_USBNX_USBP_CTL_STATUS(usb->index), + usbn_usbp_ctl_status.u64); + /* 10. Wait 1 us */ + udelay(1); + /* 11. Program the hreset_n field in the USBN clock-control register: + USBN_CLK_CTL[HRST] = 1 */ + usbn_clk_ctl.s.hrst = 1; + __cvmx_usb_write_csr64(usb, CVMX_USBNX_CLK_CTL(usb->index), + usbn_clk_ctl.u64); + /* 12. Proceed to USB core initialization */ + usbn_clk_ctl.s.enable = 1; + __cvmx_usb_write_csr64(usb, CVMX_USBNX_CLK_CTL(usb->index), + usbn_clk_ctl.u64); + udelay(1); + + /* USB Core Initialization */ + + /* 1. Read USBC_GHWCFG1, USBC_GHWCFG2, USBC_GHWCFG3, USBC_GHWCFG4 to + determine USB core configuration parameters. */ + /* Nothing needed */ + /* 2. Program the following fields in the global AHB configuration + register (USBC_GAHBCFG) + DMA mode, USBC_GAHBCFG[DMAEn]: 1 = DMA mode, 0 = slave mode + Burst length, USBC_GAHBCFG[HBSTLEN] = 0 + Nonperiodic TxFIFO empty level (slave mode only), + USBC_GAHBCFG[NPTXFEMPLVL] + Periodic TxFIFO empty level (slave mode only), + USBC_GAHBCFG[PTXFEMPLVL] + Global interrupt mask, USBC_GAHBCFG[GLBLINTRMSK] = 1 */ + { + cvmx_usbcx_gahbcfg_t usbcx_gahbcfg; + /* Due to an errata, CN31XX doesn't support DMA */ + if (OCTEON_IS_MODEL(OCTEON_CN31XX)) + usb->init_flags |= CVMX_USB_INITIALIZE_FLAGS_NO_DMA; + usbcx_gahbcfg.u32 = 0; + usbcx_gahbcfg.s.dmaen = !(usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA); + if (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA) + usb->idle_hardware_channels = 0x1; /* Only use one channel with non DMA */ + else if (OCTEON_IS_MODEL(OCTEON_CN5XXX)) + usb->idle_hardware_channels = 0xf7; /* CN5XXX have an errata with channel 3 */ + else + usb->idle_hardware_channels = 0xff; + usbcx_gahbcfg.s.hbstlen = 0; + usbcx_gahbcfg.s.nptxfemplvl = 1; + usbcx_gahbcfg.s.ptxfemplvl = 1; + usbcx_gahbcfg.s.glblintrmsk = 1; + __cvmx_usb_write_csr32(usb, CVMX_USBCX_GAHBCFG(usb->index), + usbcx_gahbcfg.u32); + } + /* 3. Program the following fields in USBC_GUSBCFG register. + HS/FS timeout calibration, USBC_GUSBCFG[TOUTCAL] = 0 + ULPI DDR select, USBC_GUSBCFG[DDRSEL] = 0 + USB turnaround time, USBC_GUSBCFG[USBTRDTIM] = 0x5 + PHY low-power clock select, USBC_GUSBCFG[PHYLPWRCLKSEL] = 0 */ + { + cvmx_usbcx_gusbcfg_t usbcx_gusbcfg; + usbcx_gusbcfg.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_GUSBCFG(usb->index)); + usbcx_gusbcfg.s.toutcal = 0; + usbcx_gusbcfg.s.ddrsel = 0; + usbcx_gusbcfg.s.usbtrdtim = 0x5; + usbcx_gusbcfg.s.phylpwrclksel = 0; + __cvmx_usb_write_csr32(usb, CVMX_USBCX_GUSBCFG(usb->index), + usbcx_gusbcfg.u32); + } + /* 4. The software must unmask the following bits in the USBC_GINTMSK + register. + OTG interrupt mask, USBC_GINTMSK[OTGINTMSK] = 1 + Mode mismatch interrupt mask, USBC_GINTMSK[MODEMISMSK] = 1 */ + { + cvmx_usbcx_gintmsk_t usbcx_gintmsk; + int channel; + + usbcx_gintmsk.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_GINTMSK(usb->index)); + usbcx_gintmsk.s.otgintmsk = 1; + usbcx_gintmsk.s.modemismsk = 1; + usbcx_gintmsk.s.hchintmsk = 1; + usbcx_gintmsk.s.sofmsk = 0; + /* We need RX FIFO interrupts if we don't have DMA */ + if (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA) + usbcx_gintmsk.s.rxflvlmsk = 1; + __cvmx_usb_write_csr32(usb, CVMX_USBCX_GINTMSK(usb->index), + usbcx_gintmsk.u32); + + /* Disable all channel interrupts. We'll enable them per channel later */ + for (channel = 0; channel < 8; channel++) + __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCINTMSKX(channel, usb->index), 0); + } + + { + /* Host Port Initialization */ + + /* 1. Program the host-port interrupt-mask field to unmask, + USBC_GINTMSK[PRTINT] = 1 */ + USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), cvmx_usbcx_gintmsk_t, + prtintmsk, 1); + USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), cvmx_usbcx_gintmsk_t, + disconnintmsk, 1); + /* 2. Program the USBC_HCFG register to select full-speed host or + high-speed host. */ + { + cvmx_usbcx_hcfg_t usbcx_hcfg; + usbcx_hcfg.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCFG(usb->index)); + usbcx_hcfg.s.fslssupp = 0; + usbcx_hcfg.s.fslspclksel = 0; + __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCFG(usb->index), usbcx_hcfg.u32); + } + /* 3. Program the port power bit to drive VBUS on the USB, + USBC_HPRT[PRTPWR] = 1 */ + USB_SET_FIELD32(CVMX_USBCX_HPRT(usb->index), cvmx_usbcx_hprt_t, prtpwr, 1); + + /* Steps 4-15 from the manual are done later in the port enable */ + } + + return 0; } @@ -787,33 +781,33 @@ int cvmx_usb_initialize(cvmx_usb_state_t *state, int usb_port_number, * function is called. * * @param state USB device state populated by - * cvmx_usb_initialize(). + * cvmx_usb_initialize(). * * @return 0 or a negative error code. */ int cvmx_usb_shutdown(cvmx_usb_state_t *state) { - cvmx_usbnx_clk_ctl_t usbn_clk_ctl; - cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; - - /* Make sure all pipes are closed */ - if (usb->idle_pipes.head || - usb->active_pipes[CVMX_USB_TRANSFER_ISOCHRONOUS].head || - usb->active_pipes[CVMX_USB_TRANSFER_INTERRUPT].head || - usb->active_pipes[CVMX_USB_TRANSFER_CONTROL].head || - usb->active_pipes[CVMX_USB_TRANSFER_BULK].head) - return -EBUSY; - - /* Disable the clocks and put them in power on reset */ - usbn_clk_ctl.u64 = __cvmx_usb_read_csr64(usb, CVMX_USBNX_CLK_CTL(usb->index)); - usbn_clk_ctl.s.enable = 1; - usbn_clk_ctl.s.por = 1; - usbn_clk_ctl.s.hclk_rst = 1; - usbn_clk_ctl.s.prst = 0; - usbn_clk_ctl.s.hrst = 0; - __cvmx_usb_write_csr64(usb, CVMX_USBNX_CLK_CTL(usb->index), - usbn_clk_ctl.u64); - return 0; + cvmx_usbnx_clk_ctl_t usbn_clk_ctl; + cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; + + /* Make sure all pipes are closed */ + if (usb->idle_pipes.head || + usb->active_pipes[CVMX_USB_TRANSFER_ISOCHRONOUS].head || + usb->active_pipes[CVMX_USB_TRANSFER_INTERRUPT].head || + usb->active_pipes[CVMX_USB_TRANSFER_CONTROL].head || + usb->active_pipes[CVMX_USB_TRANSFER_BULK].head) + return -EBUSY; + + /* Disable the clocks and put them in power on reset */ + usbn_clk_ctl.u64 = __cvmx_usb_read_csr64(usb, CVMX_USBNX_CLK_CTL(usb->index)); + usbn_clk_ctl.s.enable = 1; + usbn_clk_ctl.s.por = 1; + usbn_clk_ctl.s.hclk_rst = 1; + usbn_clk_ctl.s.prst = 0; + usbn_clk_ctl.s.hrst = 0; + __cvmx_usb_write_csr64(usb, CVMX_USBNX_CLK_CTL(usb->index), + usbn_clk_ctl.u64); + return 0; } @@ -822,79 +816,79 @@ int cvmx_usb_shutdown(cvmx_usb_state_t *state) * online and servicing requests. * * @param state USB device state populated by - * cvmx_usb_initialize(). + * cvmx_usb_initialize(). * * @return 0 or a negative error code. */ int cvmx_usb_enable(cvmx_usb_state_t *state) { - cvmx_usbcx_ghwcfg3_t usbcx_ghwcfg3; - cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; - - usb->usbcx_hprt.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HPRT(usb->index)); - - /* If the port is already enabled the just return. We don't need to do - anything */ - if (usb->usbcx_hprt.s.prtena) - return 0; - - /* If there is nothing plugged into the port then fail immediately */ - if (!usb->usbcx_hprt.s.prtconnsts) { - return -ETIMEDOUT; - } - - /* Program the port reset bit to start the reset process */ - USB_SET_FIELD32(CVMX_USBCX_HPRT(usb->index), cvmx_usbcx_hprt_t, prtrst, 1); - - /* Wait at least 50ms (high speed), or 10ms (full speed) for the reset - process to complete. */ - mdelay(50); - - /* Program the port reset bit to 0, USBC_HPRT[PRTRST] = 0 */ - USB_SET_FIELD32(CVMX_USBCX_HPRT(usb->index), cvmx_usbcx_hprt_t, prtrst, 0); - - /* Wait for the USBC_HPRT[PRTENA]. */ - if (CVMX_WAIT_FOR_FIELD32(CVMX_USBCX_HPRT(usb->index), cvmx_usbcx_hprt_t, - prtena, ==, 1, 100000)) - return -ETIMEDOUT; - - /* Read the port speed field to get the enumerated speed, USBC_HPRT[PRTSPD]. */ - usb->usbcx_hprt.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HPRT(usb->index)); - usbcx_ghwcfg3.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_GHWCFG3(usb->index)); - - /* 13. Program the USBC_GRXFSIZ register to select the size of the receive - FIFO (25%). */ - USB_SET_FIELD32(CVMX_USBCX_GRXFSIZ(usb->index), cvmx_usbcx_grxfsiz_t, - rxfdep, usbcx_ghwcfg3.s.dfifodepth / 4); - /* 14. Program the USBC_GNPTXFSIZ register to select the size and the - start address of the non- periodic transmit FIFO for nonperiodic - transactions (50%). */ - { - cvmx_usbcx_gnptxfsiz_t siz; - siz.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_GNPTXFSIZ(usb->index)); - siz.s.nptxfdep = usbcx_ghwcfg3.s.dfifodepth / 2; - siz.s.nptxfstaddr = usbcx_ghwcfg3.s.dfifodepth / 4; - __cvmx_usb_write_csr32(usb, CVMX_USBCX_GNPTXFSIZ(usb->index), siz.u32); - } - /* 15. Program the USBC_HPTXFSIZ register to select the size and start - address of the periodic transmit FIFO for periodic transactions (25%). */ - { - cvmx_usbcx_hptxfsiz_t siz; - siz.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HPTXFSIZ(usb->index)); - siz.s.ptxfsize = usbcx_ghwcfg3.s.dfifodepth / 4; - siz.s.ptxfstaddr = 3 * usbcx_ghwcfg3.s.dfifodepth / 4; - __cvmx_usb_write_csr32(usb, CVMX_USBCX_HPTXFSIZ(usb->index), siz.u32); - } - /* Flush all FIFOs */ - USB_SET_FIELD32(CVMX_USBCX_GRSTCTL(usb->index), cvmx_usbcx_grstctl_t, txfnum, 0x10); - USB_SET_FIELD32(CVMX_USBCX_GRSTCTL(usb->index), cvmx_usbcx_grstctl_t, txfflsh, 1); - CVMX_WAIT_FOR_FIELD32(CVMX_USBCX_GRSTCTL(usb->index), cvmx_usbcx_grstctl_t, - txfflsh, ==, 0, 100); - USB_SET_FIELD32(CVMX_USBCX_GRSTCTL(usb->index), cvmx_usbcx_grstctl_t, rxfflsh, 1); - CVMX_WAIT_FOR_FIELD32(CVMX_USBCX_GRSTCTL(usb->index), cvmx_usbcx_grstctl_t, - rxfflsh, ==, 0, 100); - - return 0; + cvmx_usbcx_ghwcfg3_t usbcx_ghwcfg3; + cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; + + usb->usbcx_hprt.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HPRT(usb->index)); + + /* If the port is already enabled the just return. We don't need to do + anything */ + if (usb->usbcx_hprt.s.prtena) + return 0; + + /* If there is nothing plugged into the port then fail immediately */ + if (!usb->usbcx_hprt.s.prtconnsts) { + return -ETIMEDOUT; + } + + /* Program the port reset bit to start the reset process */ + USB_SET_FIELD32(CVMX_USBCX_HPRT(usb->index), cvmx_usbcx_hprt_t, prtrst, 1); + + /* Wait at least 50ms (high speed), or 10ms (full speed) for the reset + process to complete. */ + mdelay(50); + + /* Program the port reset bit to 0, USBC_HPRT[PRTRST] = 0 */ + USB_SET_FIELD32(CVMX_USBCX_HPRT(usb->index), cvmx_usbcx_hprt_t, prtrst, 0); + + /* Wait for the USBC_HPRT[PRTENA]. */ + if (CVMX_WAIT_FOR_FIELD32(CVMX_USBCX_HPRT(usb->index), cvmx_usbcx_hprt_t, + prtena, ==, 1, 100000)) + return -ETIMEDOUT; + + /* Read the port speed field to get the enumerated speed, USBC_HPRT[PRTSPD]. */ + usb->usbcx_hprt.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HPRT(usb->index)); + usbcx_ghwcfg3.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_GHWCFG3(usb->index)); + + /* 13. Program the USBC_GRXFSIZ register to select the size of the receive + FIFO (25%). */ + USB_SET_FIELD32(CVMX_USBCX_GRXFSIZ(usb->index), cvmx_usbcx_grxfsiz_t, + rxfdep, usbcx_ghwcfg3.s.dfifodepth / 4); + /* 14. Program the USBC_GNPTXFSIZ register to select the size and the + start address of the non- periodic transmit FIFO for nonperiodic + transactions (50%). */ + { + cvmx_usbcx_gnptxfsiz_t siz; + siz.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_GNPTXFSIZ(usb->index)); + siz.s.nptxfdep = usbcx_ghwcfg3.s.dfifodepth / 2; + siz.s.nptxfstaddr = usbcx_ghwcfg3.s.dfifodepth / 4; + __cvmx_usb_write_csr32(usb, CVMX_USBCX_GNPTXFSIZ(usb->index), siz.u32); + } + /* 15. Program the USBC_HPTXFSIZ register to select the size and start + address of the periodic transmit FIFO for periodic transactions (25%). */ + { + cvmx_usbcx_hptxfsiz_t siz; + siz.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HPTXFSIZ(usb->index)); + siz.s.ptxfsize = usbcx_ghwcfg3.s.dfifodepth / 4; + siz.s.ptxfstaddr = 3 * usbcx_ghwcfg3.s.dfifodepth / 4; + __cvmx_usb_write_csr32(usb, CVMX_USBCX_HPTXFSIZ(usb->index), siz.u32); + } + /* Flush all FIFOs */ + USB_SET_FIELD32(CVMX_USBCX_GRSTCTL(usb->index), cvmx_usbcx_grstctl_t, txfnum, 0x10); + USB_SET_FIELD32(CVMX_USBCX_GRSTCTL(usb->index), cvmx_usbcx_grstctl_t, txfflsh, 1); + CVMX_WAIT_FOR_FIELD32(CVMX_USBCX_GRSTCTL(usb->index), cvmx_usbcx_grstctl_t, + txfflsh, ==, 0, 100); + USB_SET_FIELD32(CVMX_USBCX_GRSTCTL(usb->index), cvmx_usbcx_grstctl_t, rxfflsh, 1); + CVMX_WAIT_FOR_FIELD32(CVMX_USBCX_GRSTCTL(usb->index), cvmx_usbcx_grstctl_t, + rxfflsh, ==, 0, 100); + + return 0; } @@ -905,17 +899,17 @@ int cvmx_usb_enable(cvmx_usb_state_t *state) * associated callbacks. * * @param state USB device state populated by - * cvmx_usb_initialize(). + * cvmx_usb_initialize(). * * @return 0 or a negative error code. */ int cvmx_usb_disable(cvmx_usb_state_t *state) { - cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; + cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; - /* Disable the port */ - USB_SET_FIELD32(CVMX_USBCX_HPRT(usb->index), cvmx_usbcx_hprt_t, prtena, 1); - return 0; + /* Disable the port */ + USB_SET_FIELD32(CVMX_USBCX_HPRT(usb->index), cvmx_usbcx_hprt_t, prtena, 1); + return 0; } @@ -929,27 +923,27 @@ int cvmx_usb_disable(cvmx_usb_state_t *state) * them, you must update the status through cvmx_usb_set_status(). * * @param state USB device state populated by - * cvmx_usb_initialize(). + * cvmx_usb_initialize(). * * @return Port status information */ cvmx_usb_port_status_t cvmx_usb_get_status(cvmx_usb_state_t *state) { - cvmx_usbcx_hprt_t usbc_hprt; - cvmx_usb_port_status_t result; - cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; + cvmx_usbcx_hprt_t usbc_hprt; + cvmx_usb_port_status_t result; + cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; - memset(&result, 0, sizeof(result)); + memset(&result, 0, sizeof(result)); - usbc_hprt.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HPRT(usb->index)); - result.port_enabled = usbc_hprt.s.prtena; - result.port_over_current = usbc_hprt.s.prtovrcurract; - result.port_powered = usbc_hprt.s.prtpwr; - result.port_speed = usbc_hprt.s.prtspd; - result.connected = usbc_hprt.s.prtconnsts; - result.connect_change = (result.connected != usb->port_status.connected); + usbc_hprt.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HPRT(usb->index)); + result.port_enabled = usbc_hprt.s.prtena; + result.port_over_current = usbc_hprt.s.prtovrcurract; + result.port_powered = usbc_hprt.s.prtpwr; + result.port_speed = usbc_hprt.s.prtspd; + result.connected = usbc_hprt.s.prtconnsts; + result.connect_change = (result.connected != usb->port_status.connected); - return result; + return result; } @@ -961,15 +955,15 @@ cvmx_usb_port_status_t cvmx_usb_get_status(cvmx_usb_state_t *state) * changed through this call. * * @param state USB device state populated by - * cvmx_usb_initialize(). + * cvmx_usb_initialize(). * @param port_status - * Port status to set, most like returned by cvmx_usb_get_status() + * Port status to set, most like returned by cvmx_usb_get_status() */ void cvmx_usb_set_status(cvmx_usb_state_t *state, cvmx_usb_port_status_t port_status) { - cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; - usb->port_status = port_status; - return; + cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; + usb->port_status = port_status; + return; } @@ -978,17 +972,17 @@ void cvmx_usb_set_status(cvmx_usb_state_t *state, cvmx_usb_port_status_t port_st * Convert a USB transaction into a handle * * @param usb USB device state populated by - * cvmx_usb_initialize(). + * cvmx_usb_initialize(). * @param transaction - * Transaction to get handle for + * Transaction to get handle for * * @return Handle */ static inline int __cvmx_usb_get_submit_handle(cvmx_usb_internal_state_t *usb, - cvmx_usb_transaction_t *transaction) + cvmx_usb_transaction_t *transaction) { - return ((unsigned long)transaction - (unsigned long)usb->transaction) / - sizeof(*transaction); + return ((unsigned long)transaction - (unsigned long)usb->transaction) / + sizeof(*transaction); } @@ -997,15 +991,15 @@ static inline int __cvmx_usb_get_submit_handle(cvmx_usb_internal_state_t *usb, * Convert a USB pipe into a handle * * @param usb USB device state populated by - * cvmx_usb_initialize(). + * cvmx_usb_initialize(). * @param pipe Pipe to get handle for * * @return Handle */ static inline int __cvmx_usb_get_pipe_handle(cvmx_usb_internal_state_t *usb, - cvmx_usb_pipe_t *pipe) + cvmx_usb_pipe_t *pipe) { - return ((unsigned long)pipe - (unsigned long)usb->pipe) / sizeof(*pipe); + return ((unsigned long)pipe - (unsigned long)usb->pipe) / sizeof(*pipe); } @@ -1014,134 +1008,133 @@ static inline int __cvmx_usb_get_pipe_handle(cvmx_usb_internal_state_t *usb, * must be opened before data can be transferred between a device * and Octeon. * - * @param state USB device state populated by - * cvmx_usb_initialize(). - * @param flags Optional pipe flags defined in - * cvmx_usb_pipe_flags_t. + * @param state USB device state populated by + * cvmx_usb_initialize(). + * @param flags Optional pipe flags defined in + * cvmx_usb_pipe_flags_t. * @param device_addr - * USB device address to open the pipe to - * (0-127). + * USB device address to open the pipe to + * (0-127). * @param endpoint_num - * USB endpoint number to open the pipe to - * (0-15). + * USB endpoint number to open the pipe to + * (0-15). * @param device_speed - * The speed of the device the pipe is going - * to. This must match the device's speed, - * which may be different than the port speed. + * The speed of the device the pipe is going + * to. This must match the device's speed, + * which may be different than the port speed. * @param max_packet The maximum packet length the device can - * transmit/receive (low speed=0-8, full - * speed=0-1023, high speed=0-1024). This value - * comes from the standard endpoint descriptor - * field wMaxPacketSize bits <10:0>. + * transmit/receive (low speed=0-8, full + * speed=0-1023, high speed=0-1024). This value + * comes from the standard endpoint descriptor + * field wMaxPacketSize bits <10:0>. * @param transfer_type - * The type of transfer this pipe is for. + * The type of transfer this pipe is for. * @param transfer_dir - * The direction the pipe is in. This is not - * used for control pipes. + * The direction the pipe is in. This is not + * used for control pipes. * @param interval For ISOCHRONOUS and INTERRUPT transfers, - * this is how often the transfer is scheduled - * for. All other transfers should specify - * zero. The units are in frames (8000/sec at - * high speed, 1000/sec for full speed). + * this is how often the transfer is scheduled + * for. All other transfers should specify + * zero. The units are in frames (8000/sec at + * high speed, 1000/sec for full speed). * @param multi_count - * For high speed devices, this is the maximum - * allowed number of packet per microframe. - * Specify zero for non high speed devices. This - * value comes from the standard endpoint descriptor - * field wMaxPacketSize bits <12:11>. + * For high speed devices, this is the maximum + * allowed number of packet per microframe. + * Specify zero for non high speed devices. This + * value comes from the standard endpoint descriptor + * field wMaxPacketSize bits <12:11>. * @param hub_device_addr - * Hub device address this device is connected - * to. Devices connected directly to Octeon - * use zero. This is only used when the device - * is full/low speed behind a high speed hub. - * The address will be of the high speed hub, - * not and full speed hubs after it. + * Hub device address this device is connected + * to. Devices connected directly to Octeon + * use zero. This is only used when the device + * is full/low speed behind a high speed hub. + * The address will be of the high speed hub, + * not and full speed hubs after it. * @param hub_port Which port on the hub the device is - * connected. Use zero for devices connected - * directly to Octeon. Like hub_device_addr, - * this is only used for full/low speed - * devices behind a high speed hub. + * connected. Use zero for devices connected + * directly to Octeon. Like hub_device_addr, + * this is only used for full/low speed + * devices behind a high speed hub. * * @return A non negative value is a pipe handle. Negative - * values are error codes. + * values are error codes. */ int cvmx_usb_open_pipe(cvmx_usb_state_t *state, cvmx_usb_pipe_flags_t flags, - int device_addr, int endpoint_num, - cvmx_usb_speed_t device_speed, int max_packet, - cvmx_usb_transfer_t transfer_type, - cvmx_usb_direction_t transfer_dir, int interval, - int multi_count, int hub_device_addr, int hub_port) + int device_addr, int endpoint_num, + cvmx_usb_speed_t device_speed, int max_packet, + cvmx_usb_transfer_t transfer_type, + cvmx_usb_direction_t transfer_dir, int interval, + int multi_count, int hub_device_addr, int hub_port) { - cvmx_usb_pipe_t *pipe; - cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; - - if (unlikely((device_addr < 0) || (device_addr > MAX_USB_ADDRESS))) - return -EINVAL; - if (unlikely((endpoint_num < 0) || (endpoint_num > MAX_USB_ENDPOINT))) - return -EINVAL; - if (unlikely(device_speed > CVMX_USB_SPEED_LOW)) - return -EINVAL; - if (unlikely((max_packet <= 0) || (max_packet > 1024))) - return -EINVAL; - if (unlikely(transfer_type > CVMX_USB_TRANSFER_INTERRUPT)) - return -EINVAL; - if (unlikely((transfer_dir != CVMX_USB_DIRECTION_OUT) && - (transfer_dir != CVMX_USB_DIRECTION_IN))) - return -EINVAL; - if (unlikely(interval < 0)) - return -EINVAL; - if (unlikely((transfer_type == CVMX_USB_TRANSFER_CONTROL) && interval)) - return -EINVAL; - if (unlikely(multi_count < 0)) - return -EINVAL; - if (unlikely((device_speed != CVMX_USB_SPEED_HIGH) && - (multi_count != 0))) - return -EINVAL; - if (unlikely((hub_device_addr < 0) || (hub_device_addr > MAX_USB_ADDRESS))) - return -EINVAL; - if (unlikely((hub_port < 0) || (hub_port > MAX_USB_HUB_PORT))) - return -EINVAL; - - /* Find a free pipe */ - pipe = usb->free_pipes.head; - if (!pipe) - return -ENOMEM; - __cvmx_usb_remove_pipe(&usb->free_pipes, pipe); - pipe->flags = flags | __CVMX_USB_PIPE_FLAGS_OPEN; - if ((device_speed == CVMX_USB_SPEED_HIGH) && - (transfer_dir == CVMX_USB_DIRECTION_OUT) && - (transfer_type == CVMX_USB_TRANSFER_BULK)) - pipe->flags |= __CVMX_USB_PIPE_FLAGS_NEED_PING; - pipe->device_addr = device_addr; - pipe->endpoint_num = endpoint_num; - pipe->device_speed = device_speed; - pipe->max_packet = max_packet; - pipe->transfer_type = transfer_type; - pipe->transfer_dir = transfer_dir; - /* All pipes use interval to rate limit NAK processing. Force an interval - if one wasn't supplied */ - if (!interval) - interval = 1; - if (__cvmx_usb_pipe_needs_split(usb, pipe)) { - pipe->interval = interval*8; - /* Force start splits to be schedule on uFrame 0 */ - pipe->next_tx_frame = ((usb->frame_number+7)&~7) + pipe->interval; - } - else { - pipe->interval = interval; - pipe->next_tx_frame = usb->frame_number + pipe->interval; - } - pipe->multi_count = multi_count; - pipe->hub_device_addr = hub_device_addr; - pipe->hub_port = hub_port; - pipe->pid_toggle = 0; - pipe->split_sc_frame = -1; - __cvmx_usb_append_pipe(&usb->idle_pipes, pipe); - - /* We don't need to tell the hardware about this pipe yet since - it doesn't have any submitted requests */ - - return __cvmx_usb_get_pipe_handle(usb, pipe); + cvmx_usb_pipe_t *pipe; + cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; + + if (unlikely((device_addr < 0) || (device_addr > MAX_USB_ADDRESS))) + return -EINVAL; + if (unlikely((endpoint_num < 0) || (endpoint_num > MAX_USB_ENDPOINT))) + return -EINVAL; + if (unlikely(device_speed > CVMX_USB_SPEED_LOW)) + return -EINVAL; + if (unlikely((max_packet <= 0) || (max_packet > 1024))) + return -EINVAL; + if (unlikely(transfer_type > CVMX_USB_TRANSFER_INTERRUPT)) + return -EINVAL; + if (unlikely((transfer_dir != CVMX_USB_DIRECTION_OUT) && + (transfer_dir != CVMX_USB_DIRECTION_IN))) + return -EINVAL; + if (unlikely(interval < 0)) + return -EINVAL; + if (unlikely((transfer_type == CVMX_USB_TRANSFER_CONTROL) && interval)) + return -EINVAL; + if (unlikely(multi_count < 0)) + return -EINVAL; + if (unlikely((device_speed != CVMX_USB_SPEED_HIGH) && + (multi_count != 0))) + return -EINVAL; + if (unlikely((hub_device_addr < 0) || (hub_device_addr > MAX_USB_ADDRESS))) + return -EINVAL; + if (unlikely((hub_port < 0) || (hub_port > MAX_USB_HUB_PORT))) + return -EINVAL; + + /* Find a free pipe */ + pipe = usb->free_pipes.head; + if (!pipe) + return -ENOMEM; + __cvmx_usb_remove_pipe(&usb->free_pipes, pipe); + pipe->flags = flags | __CVMX_USB_PIPE_FLAGS_OPEN; + if ((device_speed == CVMX_USB_SPEED_HIGH) && + (transfer_dir == CVMX_USB_DIRECTION_OUT) && + (transfer_type == CVMX_USB_TRANSFER_BULK)) + pipe->flags |= __CVMX_USB_PIPE_FLAGS_NEED_PING; + pipe->device_addr = device_addr; + pipe->endpoint_num = endpoint_num; + pipe->device_speed = device_speed; + pipe->max_packet = max_packet; + pipe->transfer_type = transfer_type; + pipe->transfer_dir = transfer_dir; + /* All pipes use interval to rate limit NAK processing. Force an interval + if one wasn't supplied */ + if (!interval) + interval = 1; + if (__cvmx_usb_pipe_needs_split(usb, pipe)) { + pipe->interval = interval*8; + /* Force start splits to be schedule on uFrame 0 */ + pipe->next_tx_frame = ((usb->frame_number+7)&~7) + pipe->interval; + } else { + pipe->interval = interval; + pipe->next_tx_frame = usb->frame_number + pipe->interval; + } + pipe->multi_count = multi_count; + pipe->hub_device_addr = hub_device_addr; + pipe->hub_port = hub_port; + pipe->pid_toggle = 0; + pipe->split_sc_frame = -1; + __cvmx_usb_append_pipe(&usb->idle_pipes, pipe); + + /* We don't need to tell the hardware about this pipe yet since + it doesn't have any submitted requests */ + + return __cvmx_usb_get_pipe_handle(usb, pipe); } @@ -1151,43 +1144,43 @@ int cvmx_usb_open_pipe(cvmx_usb_state_t *state, cvmx_usb_pipe_flags_t flags, * in non DMA mode. It is very important that this function be called quickly * enough to prevent FIFO overflow. * - * @param usb USB device state populated by - * cvmx_usb_initialize(). + * @param usb USB device state populated by + * cvmx_usb_initialize(). */ static void __cvmx_usb_poll_rx_fifo(cvmx_usb_internal_state_t *usb) { - cvmx_usbcx_grxstsph_t rx_status; - int channel; - int bytes; - uint64_t address; - uint32_t *ptr; - - rx_status.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_GRXSTSPH(usb->index)); - /* Only read data if IN data is there */ - if (rx_status.s.pktsts != 2) - return; - /* Check if no data is available */ - if (!rx_status.s.bcnt) - return; - - channel = rx_status.s.chnum; - bytes = rx_status.s.bcnt; - if (!bytes) - return; - - /* Get where the DMA engine would have written this data */ - address = __cvmx_usb_read_csr64(usb, CVMX_USBNX_DMA0_INB_CHN0(usb->index) + channel*8); - ptr = cvmx_phys_to_ptr(address); - __cvmx_usb_write_csr64(usb, CVMX_USBNX_DMA0_INB_CHN0(usb->index) + channel*8, address + bytes); - - /* Loop writing the FIFO data for this packet into memory */ - while (bytes > 0) { - *ptr++ = __cvmx_usb_read_csr32(usb, USB_FIFO_ADDRESS(channel, usb->index)); - bytes -= 4; - } - CVMX_SYNCW; - - return; + cvmx_usbcx_grxstsph_t rx_status; + int channel; + int bytes; + uint64_t address; + uint32_t *ptr; + + rx_status.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_GRXSTSPH(usb->index)); + /* Only read data if IN data is there */ + if (rx_status.s.pktsts != 2) + return; + /* Check if no data is available */ + if (!rx_status.s.bcnt) + return; + + channel = rx_status.s.chnum; + bytes = rx_status.s.bcnt; + if (!bytes) + return; + + /* Get where the DMA engine would have written this data */ + address = __cvmx_usb_read_csr64(usb, CVMX_USBNX_DMA0_INB_CHN0(usb->index) + channel*8); + ptr = cvmx_phys_to_ptr(address); + __cvmx_usb_write_csr64(usb, CVMX_USBNX_DMA0_INB_CHN0(usb->index) + channel*8, address + bytes); + + /* Loop writing the FIFO data for this packet into memory */ + while (bytes > 0) { + *ptr++ = __cvmx_usb_read_csr32(usb, USB_FIFO_ADDRESS(channel, usb->index)); + bytes -= 4; + } + CVMX_SYNCW; + + return; } @@ -1195,85 +1188,85 @@ static void __cvmx_usb_poll_rx_fifo(cvmx_usb_internal_state_t *usb) * Fill the TX hardware fifo with data out of the software * fifos * - * @param usb USB device state populated by - * cvmx_usb_initialize(). - * @param fifo Software fifo to use + * @param usb USB device state populated by + * cvmx_usb_initialize(). + * @param fifo Software fifo to use * @param available Amount of space in the hardware fifo * * @return Non zero if the hardware fifo was too small and needs - * to be serviced again. + * to be serviced again. */ static int __cvmx_usb_fill_tx_hw(cvmx_usb_internal_state_t *usb, cvmx_usb_tx_fifo_t *fifo, int available) { - /* We're done either when there isn't anymore space or the software FIFO - is empty */ - while (available && (fifo->head != fifo->tail)) { - int i = fifo->tail; - const uint32_t *ptr = cvmx_phys_to_ptr(fifo->entry[i].address); - uint64_t csr_address = USB_FIFO_ADDRESS(fifo->entry[i].channel, usb->index) ^ 4; - int words = available; - - /* Limit the amount of data to waht the SW fifo has */ - if (fifo->entry[i].size <= available) { - words = fifo->entry[i].size; - fifo->tail++; - if (fifo->tail > MAX_CHANNELS) - fifo->tail = 0; - } - - /* Update the next locations and counts */ - available -= words; - fifo->entry[i].address += words * 4; - fifo->entry[i].size -= words; - - /* Write the HW fifo data. The read every three writes is due - to an errata on CN3XXX chips */ - while (words > 3) { - cvmx_write64_uint32(csr_address, *ptr++); - cvmx_write64_uint32(csr_address, *ptr++); - cvmx_write64_uint32(csr_address, *ptr++); - cvmx_read64_uint64(CVMX_USBNX_DMA0_INB_CHN0(usb->index)); - words -= 3; - } - cvmx_write64_uint32(csr_address, *ptr++); - if (--words) { - cvmx_write64_uint32(csr_address, *ptr++); - if (--words) - cvmx_write64_uint32(csr_address, *ptr++); - } - cvmx_read64_uint64(CVMX_USBNX_DMA0_INB_CHN0(usb->index)); - } - return fifo->head != fifo->tail; + /* We're done either when there isn't anymore space or the software FIFO + is empty */ + while (available && (fifo->head != fifo->tail)) { + int i = fifo->tail; + const uint32_t *ptr = cvmx_phys_to_ptr(fifo->entry[i].address); + uint64_t csr_address = USB_FIFO_ADDRESS(fifo->entry[i].channel, usb->index) ^ 4; + int words = available; + + /* Limit the amount of data to waht the SW fifo has */ + if (fifo->entry[i].size <= available) { + words = fifo->entry[i].size; + fifo->tail++; + if (fifo->tail > MAX_CHANNELS) + fifo->tail = 0; + } + + /* Update the next locations and counts */ + available -= words; + fifo->entry[i].address += words * 4; + fifo->entry[i].size -= words; + + /* Write the HW fifo data. The read every three writes is due + to an errata on CN3XXX chips */ + while (words > 3) { + cvmx_write64_uint32(csr_address, *ptr++); + cvmx_write64_uint32(csr_address, *ptr++); + cvmx_write64_uint32(csr_address, *ptr++); + cvmx_read64_uint64(CVMX_USBNX_DMA0_INB_CHN0(usb->index)); + words -= 3; + } + cvmx_write64_uint32(csr_address, *ptr++); + if (--words) { + cvmx_write64_uint32(csr_address, *ptr++); + if (--words) + cvmx_write64_uint32(csr_address, *ptr++); + } + cvmx_read64_uint64(CVMX_USBNX_DMA0_INB_CHN0(usb->index)); + } + return fifo->head != fifo->tail; } /** * Check the hardware FIFOs and fill them as needed * - * @param usb USB device state populated by - * cvmx_usb_initialize(). + * @param usb USB device state populated by + * cvmx_usb_initialize(). */ static void __cvmx_usb_poll_tx_fifo(cvmx_usb_internal_state_t *usb) { - if (usb->periodic.head != usb->periodic.tail) { - cvmx_usbcx_hptxsts_t tx_status; - tx_status.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HPTXSTS(usb->index)); - if (__cvmx_usb_fill_tx_hw(usb, &usb->periodic, tx_status.s.ptxfspcavail)) - USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), cvmx_usbcx_gintmsk_t, ptxfempmsk, 1); - else - USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), cvmx_usbcx_gintmsk_t, ptxfempmsk, 0); - } - - if (usb->nonperiodic.head != usb->nonperiodic.tail) { - cvmx_usbcx_gnptxsts_t tx_status; - tx_status.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_GNPTXSTS(usb->index)); - if (__cvmx_usb_fill_tx_hw(usb, &usb->nonperiodic, tx_status.s.nptxfspcavail)) - USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), cvmx_usbcx_gintmsk_t, nptxfempmsk, 1); - else - USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), cvmx_usbcx_gintmsk_t, nptxfempmsk, 0); - } - - return; + if (usb->periodic.head != usb->periodic.tail) { + cvmx_usbcx_hptxsts_t tx_status; + tx_status.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HPTXSTS(usb->index)); + if (__cvmx_usb_fill_tx_hw(usb, &usb->periodic, tx_status.s.ptxfspcavail)) + USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), cvmx_usbcx_gintmsk_t, ptxfempmsk, 1); + else + USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), cvmx_usbcx_gintmsk_t, ptxfempmsk, 0); + } + + if (usb->nonperiodic.head != usb->nonperiodic.tail) { + cvmx_usbcx_gnptxsts_t tx_status; + tx_status.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_GNPTXSTS(usb->index)); + if (__cvmx_usb_fill_tx_hw(usb, &usb->nonperiodic, tx_status.s.nptxfspcavail)) + USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), cvmx_usbcx_gintmsk_t, nptxfempmsk, 1); + else + USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), cvmx_usbcx_gintmsk_t, nptxfempmsk, 0); + } + + return; } @@ -1281,48 +1274,48 @@ static void __cvmx_usb_poll_tx_fifo(cvmx_usb_internal_state_t *usb) * @INTERNAL * Fill the TX FIFO with an outgoing packet * - * @param usb USB device state populated by - * cvmx_usb_initialize(). + * @param usb USB device state populated by + * cvmx_usb_initialize(). * @param channel Channel number to get packet from */ static void __cvmx_usb_fill_tx_fifo(cvmx_usb_internal_state_t *usb, int channel) { - cvmx_usbcx_hccharx_t hcchar; - cvmx_usbcx_hcspltx_t usbc_hcsplt; - cvmx_usbcx_hctsizx_t usbc_hctsiz; - cvmx_usb_tx_fifo_t *fifo; - - /* We only need to fill data on outbound channels */ - hcchar.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCCHARX(channel, usb->index)); - if (hcchar.s.epdir != CVMX_USB_DIRECTION_OUT) - return; - - /* OUT Splits only have data on the start and not the complete */ - usbc_hcsplt.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCSPLTX(channel, usb->index)); - if (usbc_hcsplt.s.spltena && usbc_hcsplt.s.compsplt) - return; - - /* Find out how many bytes we need to fill and convert it into 32bit words */ - usbc_hctsiz.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCTSIZX(channel, usb->index)); - if (!usbc_hctsiz.s.xfersize) - return; - - if ((hcchar.s.eptype == CVMX_USB_TRANSFER_INTERRUPT) || - (hcchar.s.eptype == CVMX_USB_TRANSFER_ISOCHRONOUS)) - fifo = &usb->periodic; - else - fifo = &usb->nonperiodic; - - fifo->entry[fifo->head].channel = channel; - fifo->entry[fifo->head].address = __cvmx_usb_read_csr64(usb, CVMX_USBNX_DMA0_OUTB_CHN0(usb->index) + channel*8); - fifo->entry[fifo->head].size = (usbc_hctsiz.s.xfersize+3)>>2; - fifo->head++; - if (fifo->head > MAX_CHANNELS) - fifo->head = 0; - - __cvmx_usb_poll_tx_fifo(usb); - - return; + cvmx_usbcx_hccharx_t hcchar; + cvmx_usbcx_hcspltx_t usbc_hcsplt; + cvmx_usbcx_hctsizx_t usbc_hctsiz; + cvmx_usb_tx_fifo_t *fifo; + + /* We only need to fill data on outbound channels */ + hcchar.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCCHARX(channel, usb->index)); + if (hcchar.s.epdir != CVMX_USB_DIRECTION_OUT) + return; + + /* OUT Splits only have data on the start and not the complete */ + usbc_hcsplt.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCSPLTX(channel, usb->index)); + if (usbc_hcsplt.s.spltena && usbc_hcsplt.s.compsplt) + return; + + /* Find out how many bytes we need to fill and convert it into 32bit words */ + usbc_hctsiz.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCTSIZX(channel, usb->index)); + if (!usbc_hctsiz.s.xfersize) + return; + + if ((hcchar.s.eptype == CVMX_USB_TRANSFER_INTERRUPT) || + (hcchar.s.eptype == CVMX_USB_TRANSFER_ISOCHRONOUS)) + fifo = &usb->periodic; + else + fifo = &usb->nonperiodic; + + fifo->entry[fifo->head].channel = channel; + fifo->entry[fifo->head].address = __cvmx_usb_read_csr64(usb, CVMX_USBNX_DMA0_OUTB_CHN0(usb->index) + channel*8); + fifo->entry[fifo->head].size = (usbc_hctsiz.s.xfersize+3)>>2; + fifo->head++; + if (fifo->head > MAX_CHANNELS) + fifo->head = 0; + + __cvmx_usb_poll_tx_fifo(usb); + + return; } /** @@ -1331,120 +1324,119 @@ static void __cvmx_usb_fill_tx_fifo(cvmx_usb_internal_state_t *usb, int channel) * the generic stuff will already have been done in * __cvmx_usb_start_channel() * - * @param usb USB device state populated by - * cvmx_usb_initialize(). + * @param usb USB device state populated by + * cvmx_usb_initialize(). * @param channel Channel to setup - * @param pipe Pipe for control transaction + * @param pipe Pipe for control transaction */ static void __cvmx_usb_start_channel_control(cvmx_usb_internal_state_t *usb, - int channel, - cvmx_usb_pipe_t *pipe) + int channel, + cvmx_usb_pipe_t *pipe) { - cvmx_usb_transaction_t *transaction = pipe->head; - cvmx_usb_control_header_t *header = cvmx_phys_to_ptr(transaction->control_header); - int bytes_to_transfer = transaction->buffer_length - transaction->actual_bytes; - int packets_to_transfer; - cvmx_usbcx_hctsizx_t usbc_hctsiz; - - usbc_hctsiz.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCTSIZX(channel, usb->index)); - - switch (transaction->stage) { - case CVMX_USB_STAGE_NON_CONTROL: - case CVMX_USB_STAGE_NON_CONTROL_SPLIT_COMPLETE: - cvmx_dprintf("%s: ERROR - Non control stage\n", __FUNCTION__); - break; - case CVMX_USB_STAGE_SETUP: - usbc_hctsiz.s.pid = 3; /* Setup */ - bytes_to_transfer = sizeof(*header); - /* All Control operations start with a setup going OUT */ - USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index), cvmx_usbcx_hccharx_t, epdir, CVMX_USB_DIRECTION_OUT); - /* Setup send the control header instead of the buffer data. The - buffer data will be used in the next stage */ - __cvmx_usb_write_csr64(usb, CVMX_USBNX_DMA0_OUTB_CHN0(usb->index) + channel*8, transaction->control_header); - break; - case CVMX_USB_STAGE_SETUP_SPLIT_COMPLETE: - usbc_hctsiz.s.pid = 3; /* Setup */ - bytes_to_transfer = 0; - /* All Control operations start with a setup going OUT */ - USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index), cvmx_usbcx_hccharx_t, epdir, CVMX_USB_DIRECTION_OUT); - USB_SET_FIELD32(CVMX_USBCX_HCSPLTX(channel, usb->index), cvmx_usbcx_hcspltx_t, compsplt, 1); - break; - case CVMX_USB_STAGE_DATA: - usbc_hctsiz.s.pid = __cvmx_usb_get_data_pid(pipe); - if (__cvmx_usb_pipe_needs_split(usb, pipe)) { - if (header->s.request_type & 0x80) - bytes_to_transfer = 0; - else if (bytes_to_transfer > pipe->max_packet) - bytes_to_transfer = pipe->max_packet; - } - USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index), - cvmx_usbcx_hccharx_t, epdir, - ((header->s.request_type & 0x80) ? - CVMX_USB_DIRECTION_IN : - CVMX_USB_DIRECTION_OUT)); - break; - case CVMX_USB_STAGE_DATA_SPLIT_COMPLETE: - usbc_hctsiz.s.pid = __cvmx_usb_get_data_pid(pipe); - if (!(header->s.request_type & 0x80)) - bytes_to_transfer = 0; - USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index), - cvmx_usbcx_hccharx_t, epdir, - ((header->s.request_type & 0x80) ? - CVMX_USB_DIRECTION_IN : - CVMX_USB_DIRECTION_OUT)); - USB_SET_FIELD32(CVMX_USBCX_HCSPLTX(channel, usb->index), cvmx_usbcx_hcspltx_t, compsplt, 1); - break; - case CVMX_USB_STAGE_STATUS: - usbc_hctsiz.s.pid = __cvmx_usb_get_data_pid(pipe); - bytes_to_transfer = 0; - USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index), cvmx_usbcx_hccharx_t, epdir, - ((header->s.request_type & 0x80) ? - CVMX_USB_DIRECTION_OUT : - CVMX_USB_DIRECTION_IN)); - break; - case CVMX_USB_STAGE_STATUS_SPLIT_COMPLETE: - usbc_hctsiz.s.pid = __cvmx_usb_get_data_pid(pipe); - bytes_to_transfer = 0; - USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index), cvmx_usbcx_hccharx_t, epdir, - ((header->s.request_type & 0x80) ? - CVMX_USB_DIRECTION_OUT : - CVMX_USB_DIRECTION_IN)); - USB_SET_FIELD32(CVMX_USBCX_HCSPLTX(channel, usb->index), cvmx_usbcx_hcspltx_t, compsplt, 1); - break; - } - - /* Make sure the transfer never exceeds the byte limit of the hardware. - Further bytes will be sent as continued transactions */ - if (bytes_to_transfer > MAX_TRANSFER_BYTES) { - /* Round MAX_TRANSFER_BYTES to a multiple of out packet size */ - bytes_to_transfer = MAX_TRANSFER_BYTES / pipe->max_packet; - bytes_to_transfer *= pipe->max_packet; - } - - /* Calculate the number of packets to transfer. If the length is zero - we still need to transfer one packet */ - packets_to_transfer = (bytes_to_transfer + pipe->max_packet - 1) / pipe->max_packet; - if (packets_to_transfer == 0) - packets_to_transfer = 1; - else if ((packets_to_transfer>1) && (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA)) { - /* Limit to one packet when not using DMA. Channels must be restarted - between every packet for IN transactions, so there is no reason to - do multiple packets in a row */ - packets_to_transfer = 1; - bytes_to_transfer = packets_to_transfer * pipe->max_packet; - } - else if (packets_to_transfer > MAX_TRANSFER_PACKETS) { - /* Limit the number of packet and data transferred to what the - hardware can handle */ - packets_to_transfer = MAX_TRANSFER_PACKETS; - bytes_to_transfer = packets_to_transfer * pipe->max_packet; - } - - usbc_hctsiz.s.xfersize = bytes_to_transfer; - usbc_hctsiz.s.pktcnt = packets_to_transfer; - - __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCTSIZX(channel, usb->index), usbc_hctsiz.u32); - return; + cvmx_usb_transaction_t *transaction = pipe->head; + cvmx_usb_control_header_t *header = cvmx_phys_to_ptr(transaction->control_header); + int bytes_to_transfer = transaction->buffer_length - transaction->actual_bytes; + int packets_to_transfer; + cvmx_usbcx_hctsizx_t usbc_hctsiz; + + usbc_hctsiz.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCTSIZX(channel, usb->index)); + + switch (transaction->stage) { + case CVMX_USB_STAGE_NON_CONTROL: + case CVMX_USB_STAGE_NON_CONTROL_SPLIT_COMPLETE: + cvmx_dprintf("%s: ERROR - Non control stage\n", __FUNCTION__); + break; + case CVMX_USB_STAGE_SETUP: + usbc_hctsiz.s.pid = 3; /* Setup */ + bytes_to_transfer = sizeof(*header); + /* All Control operations start with a setup going OUT */ + USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index), cvmx_usbcx_hccharx_t, epdir, CVMX_USB_DIRECTION_OUT); + /* Setup send the control header instead of the buffer data. The + buffer data will be used in the next stage */ + __cvmx_usb_write_csr64(usb, CVMX_USBNX_DMA0_OUTB_CHN0(usb->index) + channel*8, transaction->control_header); + break; + case CVMX_USB_STAGE_SETUP_SPLIT_COMPLETE: + usbc_hctsiz.s.pid = 3; /* Setup */ + bytes_to_transfer = 0; + /* All Control operations start with a setup going OUT */ + USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index), cvmx_usbcx_hccharx_t, epdir, CVMX_USB_DIRECTION_OUT); + USB_SET_FIELD32(CVMX_USBCX_HCSPLTX(channel, usb->index), cvmx_usbcx_hcspltx_t, compsplt, 1); + break; + case CVMX_USB_STAGE_DATA: + usbc_hctsiz.s.pid = __cvmx_usb_get_data_pid(pipe); + if (__cvmx_usb_pipe_needs_split(usb, pipe)) { + if (header->s.request_type & 0x80) + bytes_to_transfer = 0; + else if (bytes_to_transfer > pipe->max_packet) + bytes_to_transfer = pipe->max_packet; + } + USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index), + cvmx_usbcx_hccharx_t, epdir, + ((header->s.request_type & 0x80) ? + CVMX_USB_DIRECTION_IN : + CVMX_USB_DIRECTION_OUT)); + break; + case CVMX_USB_STAGE_DATA_SPLIT_COMPLETE: + usbc_hctsiz.s.pid = __cvmx_usb_get_data_pid(pipe); + if (!(header->s.request_type & 0x80)) + bytes_to_transfer = 0; + USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index), + cvmx_usbcx_hccharx_t, epdir, + ((header->s.request_type & 0x80) ? + CVMX_USB_DIRECTION_IN : + CVMX_USB_DIRECTION_OUT)); + USB_SET_FIELD32(CVMX_USBCX_HCSPLTX(channel, usb->index), cvmx_usbcx_hcspltx_t, compsplt, 1); + break; + case CVMX_USB_STAGE_STATUS: + usbc_hctsiz.s.pid = __cvmx_usb_get_data_pid(pipe); + bytes_to_transfer = 0; + USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index), cvmx_usbcx_hccharx_t, epdir, + ((header->s.request_type & 0x80) ? + CVMX_USB_DIRECTION_OUT : + CVMX_USB_DIRECTION_IN)); + break; + case CVMX_USB_STAGE_STATUS_SPLIT_COMPLETE: + usbc_hctsiz.s.pid = __cvmx_usb_get_data_pid(pipe); + bytes_to_transfer = 0; + USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index), cvmx_usbcx_hccharx_t, epdir, + ((header->s.request_type & 0x80) ? + CVMX_USB_DIRECTION_OUT : + CVMX_USB_DIRECTION_IN)); + USB_SET_FIELD32(CVMX_USBCX_HCSPLTX(channel, usb->index), cvmx_usbcx_hcspltx_t, compsplt, 1); + break; + } + + /* Make sure the transfer never exceeds the byte limit of the hardware. + Further bytes will be sent as continued transactions */ + if (bytes_to_transfer > MAX_TRANSFER_BYTES) { + /* Round MAX_TRANSFER_BYTES to a multiple of out packet size */ + bytes_to_transfer = MAX_TRANSFER_BYTES / pipe->max_packet; + bytes_to_transfer *= pipe->max_packet; + } + + /* Calculate the number of packets to transfer. If the length is zero + we still need to transfer one packet */ + packets_to_transfer = (bytes_to_transfer + pipe->max_packet - 1) / pipe->max_packet; + if (packets_to_transfer == 0) + packets_to_transfer = 1; + else if ((packets_to_transfer > 1) && (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA)) { + /* Limit to one packet when not using DMA. Channels must be restarted + between every packet for IN transactions, so there is no reason to + do multiple packets in a row */ + packets_to_transfer = 1; + bytes_to_transfer = packets_to_transfer * pipe->max_packet; + } else if (packets_to_transfer > MAX_TRANSFER_PACKETS) { + /* Limit the number of packet and data transferred to what the + hardware can handle */ + packets_to_transfer = MAX_TRANSFER_PACKETS; + bytes_to_transfer = packets_to_transfer * pipe->max_packet; + } + + usbc_hctsiz.s.xfersize = bytes_to_transfer; + usbc_hctsiz.s.pktcnt = packets_to_transfer; + + __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCTSIZX(channel, usb->index), usbc_hctsiz.u32); + return; } @@ -1452,273 +1444,270 @@ static void __cvmx_usb_start_channel_control(cvmx_usb_internal_state_t *usb, * @INTERNAL * Start a channel to perform the pipe's head transaction * - * @param usb USB device state populated by - * cvmx_usb_initialize(). + * @param usb USB device state populated by + * cvmx_usb_initialize(). * @param channel Channel to setup - * @param pipe Pipe to start + * @param pipe Pipe to start */ static void __cvmx_usb_start_channel(cvmx_usb_internal_state_t *usb, - int channel, - cvmx_usb_pipe_t *pipe) + int channel, + cvmx_usb_pipe_t *pipe) { - cvmx_usb_transaction_t *transaction = pipe->head; - - /* Make sure all writes to the DMA region get flushed */ - CVMX_SYNCW; - - /* Attach the channel to the pipe */ - usb->pipe_for_channel[channel] = pipe; - pipe->channel = channel; - pipe->flags |= __CVMX_USB_PIPE_FLAGS_SCHEDULED; - - /* Mark this channel as in use */ - usb->idle_hardware_channels &= ~(1<index)); - __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCINTX(channel, usb->index), usbc_hcint.u32); - - usbc_hcintmsk.u32 = 0; - usbc_hcintmsk.s.chhltdmsk = 1; - if (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA) { - /* Channels need these extra interrupts when we aren't in DMA mode */ - usbc_hcintmsk.s.datatglerrmsk = 1; - usbc_hcintmsk.s.frmovrunmsk = 1; - usbc_hcintmsk.s.bblerrmsk = 1; - usbc_hcintmsk.s.xacterrmsk = 1; - if (__cvmx_usb_pipe_needs_split(usb, pipe)) { - /* Splits don't generate xfercompl, so we need ACK and NYET */ - usbc_hcintmsk.s.nyetmsk = 1; - usbc_hcintmsk.s.ackmsk = 1; - } - usbc_hcintmsk.s.nakmsk = 1; - usbc_hcintmsk.s.stallmsk = 1; - usbc_hcintmsk.s.xfercomplmsk = 1; - } - __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCINTMSKX(channel, usb->index), usbc_hcintmsk.u32); - - /* Enable the channel interrupt to propagate */ - usbc_haintmsk.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HAINTMSK(usb->index)); - usbc_haintmsk.s.haintmsk |= 1<index), usbc_haintmsk.u32); - } - - /* Setup the locations the DMA engines use */ - { - uint64_t dma_address = transaction->buffer + transaction->actual_bytes; - if (transaction->type == CVMX_USB_TRANSFER_ISOCHRONOUS) - dma_address = transaction->buffer + transaction->iso_packets[0].offset + transaction->actual_bytes; - __cvmx_usb_write_csr64(usb, CVMX_USBNX_DMA0_OUTB_CHN0(usb->index) + channel*8, dma_address); - __cvmx_usb_write_csr64(usb, CVMX_USBNX_DMA0_INB_CHN0(usb->index) + channel*8, dma_address); - } - - /* Setup both the size of the transfer and the SPLIT characteristics */ - { - cvmx_usbcx_hcspltx_t usbc_hcsplt = {.u32 = 0}; - cvmx_usbcx_hctsizx_t usbc_hctsiz = {.u32 = 0}; - int packets_to_transfer; - int bytes_to_transfer = transaction->buffer_length - transaction->actual_bytes; - - /* ISOCHRONOUS transactions store each individual transfer size in the - packet structure, not the global buffer_length */ - if (transaction->type == CVMX_USB_TRANSFER_ISOCHRONOUS) - bytes_to_transfer = transaction->iso_packets[0].length - transaction->actual_bytes; - - /* We need to do split transactions when we are talking to non high - speed devices that are behind a high speed hub */ - if (__cvmx_usb_pipe_needs_split(usb, pipe)) { - /* On the start split phase (stage is even) record the frame number we - will need to send the split complete. We only store the lower two bits - since the time ahead can only be two frames */ - if ((transaction->stage&1) == 0) { - if (transaction->type == CVMX_USB_TRANSFER_BULK) - pipe->split_sc_frame = (usb->frame_number + 1) & 0x7f; - else - pipe->split_sc_frame = (usb->frame_number + 2) & 0x7f; - } - else - pipe->split_sc_frame = -1; - - usbc_hcsplt.s.spltena = 1; - usbc_hcsplt.s.hubaddr = pipe->hub_device_addr; - usbc_hcsplt.s.prtaddr = pipe->hub_port; - usbc_hcsplt.s.compsplt = (transaction->stage == CVMX_USB_STAGE_NON_CONTROL_SPLIT_COMPLETE); - - /* SPLIT transactions can only ever transmit one data packet so - limit the transfer size to the max packet size */ - if (bytes_to_transfer > pipe->max_packet) - bytes_to_transfer = pipe->max_packet; - - /* ISOCHRONOUS OUT splits are unique in that they limit - data transfers to 188 byte chunks representing the - begin/middle/end of the data or all */ - if (!usbc_hcsplt.s.compsplt && - (pipe->transfer_dir == CVMX_USB_DIRECTION_OUT) && - (pipe->transfer_type == CVMX_USB_TRANSFER_ISOCHRONOUS)) { - /* Clear the split complete frame number as there isn't going - to be a split complete */ - pipe->split_sc_frame = -1; - /* See if we've started this transfer and sent data */ - if (transaction->actual_bytes == 0) { - /* Nothing sent yet, this is either a begin or the - entire payload */ - if (bytes_to_transfer <= 188) - usbc_hcsplt.s.xactpos = 3; /* Entire payload in one go */ - else - usbc_hcsplt.s.xactpos = 2; /* First part of payload */ - } - else { - /* Continuing the previous data, we must either be - in the middle or at the end */ - if (bytes_to_transfer <= 188) - usbc_hcsplt.s.xactpos = 1; /* End of payload */ - else - usbc_hcsplt.s.xactpos = 0; /* Middle of payload */ - } - /* Again, the transfer size is limited to 188 bytes */ - if (bytes_to_transfer > 188) - bytes_to_transfer = 188; - } - } - - /* Make sure the transfer never exceeds the byte limit of the hardware. - Further bytes will be sent as continued transactions */ - if (bytes_to_transfer > MAX_TRANSFER_BYTES) { - /* Round MAX_TRANSFER_BYTES to a multiple of out packet size */ - bytes_to_transfer = MAX_TRANSFER_BYTES / pipe->max_packet; - bytes_to_transfer *= pipe->max_packet; - } - - /* Calculate the number of packets to transfer. If the length is zero - we still need to transfer one packet */ - packets_to_transfer = (bytes_to_transfer + pipe->max_packet - 1) / pipe->max_packet; - if (packets_to_transfer == 0) - packets_to_transfer = 1; - else if ((packets_to_transfer>1) && (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA)) { - /* Limit to one packet when not using DMA. Channels must be restarted - between every packet for IN transactions, so there is no reason to - do multiple packets in a row */ - packets_to_transfer = 1; - bytes_to_transfer = packets_to_transfer * pipe->max_packet; - } - else if (packets_to_transfer > MAX_TRANSFER_PACKETS) { - /* Limit the number of packet and data transferred to what the - hardware can handle */ - packets_to_transfer = MAX_TRANSFER_PACKETS; - bytes_to_transfer = packets_to_transfer * pipe->max_packet; - } - - usbc_hctsiz.s.xfersize = bytes_to_transfer; - usbc_hctsiz.s.pktcnt = packets_to_transfer; - - /* Update the DATA0/DATA1 toggle */ - usbc_hctsiz.s.pid = __cvmx_usb_get_data_pid(pipe); - /* High speed pipes may need a hardware ping before they start */ - if (pipe->flags & __CVMX_USB_PIPE_FLAGS_NEED_PING) - usbc_hctsiz.s.dopng = 1; - - __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCSPLTX(channel, usb->index), usbc_hcsplt.u32); - __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCTSIZX(channel, usb->index), usbc_hctsiz.u32); - } - - /* Setup the Host Channel Characteristics Register */ - { - cvmx_usbcx_hccharx_t usbc_hcchar = {.u32 = 0}; - - /* Set the startframe odd/even properly. This is only used for periodic */ - usbc_hcchar.s.oddfrm = usb->frame_number&1; - - /* Set the number of back to back packets allowed by this endpoint. - Split transactions interpret "ec" as the number of immediate - retries of failure. These retries happen too quickly, so we - disable these entirely for splits */ - if (__cvmx_usb_pipe_needs_split(usb, pipe)) - usbc_hcchar.s.ec = 1; - else if (pipe->multi_count < 1) - usbc_hcchar.s.ec = 1; - else if (pipe->multi_count > 3) - usbc_hcchar.s.ec = 3; - else - usbc_hcchar.s.ec = pipe->multi_count; - - /* Set the rest of the endpoint specific settings */ - usbc_hcchar.s.devaddr = pipe->device_addr; - usbc_hcchar.s.eptype = transaction->type; - usbc_hcchar.s.lspddev = (pipe->device_speed == CVMX_USB_SPEED_LOW); - usbc_hcchar.s.epdir = pipe->transfer_dir; - usbc_hcchar.s.epnum = pipe->endpoint_num; - usbc_hcchar.s.mps = pipe->max_packet; - __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCCHARX(channel, usb->index), usbc_hcchar.u32); - } - - /* Do transaction type specific fixups as needed */ - switch (transaction->type) { - case CVMX_USB_TRANSFER_CONTROL: - __cvmx_usb_start_channel_control(usb, channel, pipe); - break; - case CVMX_USB_TRANSFER_BULK: - case CVMX_USB_TRANSFER_INTERRUPT: - break; - case CVMX_USB_TRANSFER_ISOCHRONOUS: - if (!__cvmx_usb_pipe_needs_split(usb, pipe)) { - /* ISO transactions require different PIDs depending on direction - and how many packets are needed */ - if (pipe->transfer_dir == CVMX_USB_DIRECTION_OUT) { - if (pipe->multi_count < 2) /* Need DATA0 */ - USB_SET_FIELD32(CVMX_USBCX_HCTSIZX(channel, usb->index), cvmx_usbcx_hctsizx_t, pid, 0); - else /* Need MDATA */ - USB_SET_FIELD32(CVMX_USBCX_HCTSIZX(channel, usb->index), cvmx_usbcx_hctsizx_t, pid, 3); - } - } - break; - } - { - cvmx_usbcx_hctsizx_t usbc_hctsiz = {.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCTSIZX(channel, usb->index))}; - transaction->xfersize = usbc_hctsiz.s.xfersize; - transaction->pktcnt = usbc_hctsiz.s.pktcnt; - } - /* Remeber when we start a split transaction */ - if (__cvmx_usb_pipe_needs_split(usb, pipe)) - usb->active_split = transaction; - USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index), cvmx_usbcx_hccharx_t, chena, 1); - if (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA) - __cvmx_usb_fill_tx_fifo(usb, channel); - return; + cvmx_usb_transaction_t *transaction = pipe->head; + + /* Make sure all writes to the DMA region get flushed */ + CVMX_SYNCW; + + /* Attach the channel to the pipe */ + usb->pipe_for_channel[channel] = pipe; + pipe->channel = channel; + pipe->flags |= __CVMX_USB_PIPE_FLAGS_SCHEDULED; + + /* Mark this channel as in use */ + usb->idle_hardware_channels &= ~(1<index)); + __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCINTX(channel, usb->index), usbc_hcint.u32); + + usbc_hcintmsk.u32 = 0; + usbc_hcintmsk.s.chhltdmsk = 1; + if (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA) { + /* Channels need these extra interrupts when we aren't in DMA mode */ + usbc_hcintmsk.s.datatglerrmsk = 1; + usbc_hcintmsk.s.frmovrunmsk = 1; + usbc_hcintmsk.s.bblerrmsk = 1; + usbc_hcintmsk.s.xacterrmsk = 1; + if (__cvmx_usb_pipe_needs_split(usb, pipe)) { + /* Splits don't generate xfercompl, so we need ACK and NYET */ + usbc_hcintmsk.s.nyetmsk = 1; + usbc_hcintmsk.s.ackmsk = 1; + } + usbc_hcintmsk.s.nakmsk = 1; + usbc_hcintmsk.s.stallmsk = 1; + usbc_hcintmsk.s.xfercomplmsk = 1; + } + __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCINTMSKX(channel, usb->index), usbc_hcintmsk.u32); + + /* Enable the channel interrupt to propagate */ + usbc_haintmsk.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HAINTMSK(usb->index)); + usbc_haintmsk.s.haintmsk |= 1<index), usbc_haintmsk.u32); + } + + /* Setup the locations the DMA engines use */ + { + uint64_t dma_address = transaction->buffer + transaction->actual_bytes; + if (transaction->type == CVMX_USB_TRANSFER_ISOCHRONOUS) + dma_address = transaction->buffer + transaction->iso_packets[0].offset + transaction->actual_bytes; + __cvmx_usb_write_csr64(usb, CVMX_USBNX_DMA0_OUTB_CHN0(usb->index) + channel*8, dma_address); + __cvmx_usb_write_csr64(usb, CVMX_USBNX_DMA0_INB_CHN0(usb->index) + channel*8, dma_address); + } + + /* Setup both the size of the transfer and the SPLIT characteristics */ + { + cvmx_usbcx_hcspltx_t usbc_hcsplt = {.u32 = 0}; + cvmx_usbcx_hctsizx_t usbc_hctsiz = {.u32 = 0}; + int packets_to_transfer; + int bytes_to_transfer = transaction->buffer_length - transaction->actual_bytes; + + /* ISOCHRONOUS transactions store each individual transfer size in the + packet structure, not the global buffer_length */ + if (transaction->type == CVMX_USB_TRANSFER_ISOCHRONOUS) + bytes_to_transfer = transaction->iso_packets[0].length - transaction->actual_bytes; + + /* We need to do split transactions when we are talking to non high + speed devices that are behind a high speed hub */ + if (__cvmx_usb_pipe_needs_split(usb, pipe)) { + /* On the start split phase (stage is even) record the frame number we + will need to send the split complete. We only store the lower two bits + since the time ahead can only be two frames */ + if ((transaction->stage&1) == 0) { + if (transaction->type == CVMX_USB_TRANSFER_BULK) + pipe->split_sc_frame = (usb->frame_number + 1) & 0x7f; + else + pipe->split_sc_frame = (usb->frame_number + 2) & 0x7f; + } else + pipe->split_sc_frame = -1; + + usbc_hcsplt.s.spltena = 1; + usbc_hcsplt.s.hubaddr = pipe->hub_device_addr; + usbc_hcsplt.s.prtaddr = pipe->hub_port; + usbc_hcsplt.s.compsplt = (transaction->stage == CVMX_USB_STAGE_NON_CONTROL_SPLIT_COMPLETE); + + /* SPLIT transactions can only ever transmit one data packet so + limit the transfer size to the max packet size */ + if (bytes_to_transfer > pipe->max_packet) + bytes_to_transfer = pipe->max_packet; + + /* ISOCHRONOUS OUT splits are unique in that they limit + data transfers to 188 byte chunks representing the + begin/middle/end of the data or all */ + if (!usbc_hcsplt.s.compsplt && + (pipe->transfer_dir == CVMX_USB_DIRECTION_OUT) && + (pipe->transfer_type == CVMX_USB_TRANSFER_ISOCHRONOUS)) { + /* Clear the split complete frame number as there isn't going + to be a split complete */ + pipe->split_sc_frame = -1; + /* See if we've started this transfer and sent data */ + if (transaction->actual_bytes == 0) { + /* Nothing sent yet, this is either a begin or the + entire payload */ + if (bytes_to_transfer <= 188) + usbc_hcsplt.s.xactpos = 3; /* Entire payload in one go */ + else + usbc_hcsplt.s.xactpos = 2; /* First part of payload */ + } else { + /* Continuing the previous data, we must either be + in the middle or at the end */ + if (bytes_to_transfer <= 188) + usbc_hcsplt.s.xactpos = 1; /* End of payload */ + else + usbc_hcsplt.s.xactpos = 0; /* Middle of payload */ + } + /* Again, the transfer size is limited to 188 bytes */ + if (bytes_to_transfer > 188) + bytes_to_transfer = 188; + } + } + + /* Make sure the transfer never exceeds the byte limit of the hardware. + Further bytes will be sent as continued transactions */ + if (bytes_to_transfer > MAX_TRANSFER_BYTES) { + /* Round MAX_TRANSFER_BYTES to a multiple of out packet size */ + bytes_to_transfer = MAX_TRANSFER_BYTES / pipe->max_packet; + bytes_to_transfer *= pipe->max_packet; + } + + /* Calculate the number of packets to transfer. If the length is zero + we still need to transfer one packet */ + packets_to_transfer = (bytes_to_transfer + pipe->max_packet - 1) / pipe->max_packet; + if (packets_to_transfer == 0) + packets_to_transfer = 1; + else if ((packets_to_transfer > 1) && (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA)) { + /* Limit to one packet when not using DMA. Channels must be restarted + between every packet for IN transactions, so there is no reason to + do multiple packets in a row */ + packets_to_transfer = 1; + bytes_to_transfer = packets_to_transfer * pipe->max_packet; + } else if (packets_to_transfer > MAX_TRANSFER_PACKETS) { + /* Limit the number of packet and data transferred to what the + hardware can handle */ + packets_to_transfer = MAX_TRANSFER_PACKETS; + bytes_to_transfer = packets_to_transfer * pipe->max_packet; + } + + usbc_hctsiz.s.xfersize = bytes_to_transfer; + usbc_hctsiz.s.pktcnt = packets_to_transfer; + + /* Update the DATA0/DATA1 toggle */ + usbc_hctsiz.s.pid = __cvmx_usb_get_data_pid(pipe); + /* High speed pipes may need a hardware ping before they start */ + if (pipe->flags & __CVMX_USB_PIPE_FLAGS_NEED_PING) + usbc_hctsiz.s.dopng = 1; + + __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCSPLTX(channel, usb->index), usbc_hcsplt.u32); + __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCTSIZX(channel, usb->index), usbc_hctsiz.u32); + } + + /* Setup the Host Channel Characteristics Register */ + { + cvmx_usbcx_hccharx_t usbc_hcchar = {.u32 = 0}; + + /* Set the startframe odd/even properly. This is only used for periodic */ + usbc_hcchar.s.oddfrm = usb->frame_number&1; + + /* Set the number of back to back packets allowed by this endpoint. + Split transactions interpret "ec" as the number of immediate + retries of failure. These retries happen too quickly, so we + disable these entirely for splits */ + if (__cvmx_usb_pipe_needs_split(usb, pipe)) + usbc_hcchar.s.ec = 1; + else if (pipe->multi_count < 1) + usbc_hcchar.s.ec = 1; + else if (pipe->multi_count > 3) + usbc_hcchar.s.ec = 3; + else + usbc_hcchar.s.ec = pipe->multi_count; + + /* Set the rest of the endpoint specific settings */ + usbc_hcchar.s.devaddr = pipe->device_addr; + usbc_hcchar.s.eptype = transaction->type; + usbc_hcchar.s.lspddev = (pipe->device_speed == CVMX_USB_SPEED_LOW); + usbc_hcchar.s.epdir = pipe->transfer_dir; + usbc_hcchar.s.epnum = pipe->endpoint_num; + usbc_hcchar.s.mps = pipe->max_packet; + __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCCHARX(channel, usb->index), usbc_hcchar.u32); + } + + /* Do transaction type specific fixups as needed */ + switch (transaction->type) { + case CVMX_USB_TRANSFER_CONTROL: + __cvmx_usb_start_channel_control(usb, channel, pipe); + break; + case CVMX_USB_TRANSFER_BULK: + case CVMX_USB_TRANSFER_INTERRUPT: + break; + case CVMX_USB_TRANSFER_ISOCHRONOUS: + if (!__cvmx_usb_pipe_needs_split(usb, pipe)) { + /* ISO transactions require different PIDs depending on direction + and how many packets are needed */ + if (pipe->transfer_dir == CVMX_USB_DIRECTION_OUT) { + if (pipe->multi_count < 2) /* Need DATA0 */ + USB_SET_FIELD32(CVMX_USBCX_HCTSIZX(channel, usb->index), cvmx_usbcx_hctsizx_t, pid, 0); + else /* Need MDATA */ + USB_SET_FIELD32(CVMX_USBCX_HCTSIZX(channel, usb->index), cvmx_usbcx_hctsizx_t, pid, 3); + } + } + break; + } + { + cvmx_usbcx_hctsizx_t usbc_hctsiz = {.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCTSIZX(channel, usb->index))}; + transaction->xfersize = usbc_hctsiz.s.xfersize; + transaction->pktcnt = usbc_hctsiz.s.pktcnt; + } + /* Remeber when we start a split transaction */ + if (__cvmx_usb_pipe_needs_split(usb, pipe)) + usb->active_split = transaction; + USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index), cvmx_usbcx_hccharx_t, chena, 1); + if (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA) + __cvmx_usb_fill_tx_fifo(usb, channel); + return; } /** * @INTERNAL * Find a pipe that is ready to be scheduled to hardware. - * @param usb USB device state populated by - * cvmx_usb_initialize(). - * @param list Pipe list to search + * @param usb USB device state populated by + * cvmx_usb_initialize(). + * @param list Pipe list to search * @param current_frame - * Frame counter to use as a time reference. + * Frame counter to use as a time reference. * * @return Pipe or NULL if none are ready */ static cvmx_usb_pipe_t *__cvmx_usb_find_ready_pipe(cvmx_usb_internal_state_t *usb, cvmx_usb_pipe_list_t *list, uint64_t current_frame) { - cvmx_usb_pipe_t *pipe = list->head; - while (pipe) { - if (!(pipe->flags & __CVMX_USB_PIPE_FLAGS_SCHEDULED) && pipe->head && - (pipe->next_tx_frame <= current_frame) && - ((pipe->split_sc_frame == -1) || ((((int)current_frame - (int)pipe->split_sc_frame) & 0x7f) < 0x40)) && - (!usb->active_split || (usb->active_split == pipe->head))) { - CVMX_PREFETCH(pipe, 128); - CVMX_PREFETCH(pipe->head, 0); - return pipe; - } - pipe = pipe->next; - } - return NULL; + cvmx_usb_pipe_t *pipe = list->head; + while (pipe) { + if (!(pipe->flags & __CVMX_USB_PIPE_FLAGS_SCHEDULED) && pipe->head && + (pipe->next_tx_frame <= current_frame) && + ((pipe->split_sc_frame == -1) || ((((int)current_frame - (int)pipe->split_sc_frame) & 0x7f) < 0x40)) && + (!usb->active_split || (usb->active_split == pipe->head))) { + CVMX_PREFETCH(pipe, 128); + CVMX_PREFETCH(pipe->head, 0); + return pipe; + } + pipe = pipe->next; + } + return NULL; } @@ -1727,69 +1716,69 @@ static cvmx_usb_pipe_t *__cvmx_usb_find_ready_pipe(cvmx_usb_internal_state_t *us * Called whenever a pipe might need to be scheduled to the * hardware. * - * @param usb USB device state populated by - * cvmx_usb_initialize(). + * @param usb USB device state populated by + * cvmx_usb_initialize(). * @param is_sof True if this schedule was called on a SOF interrupt. */ static void __cvmx_usb_schedule(cvmx_usb_internal_state_t *usb, int is_sof) { - int channel; - cvmx_usb_pipe_t *pipe; - int need_sof; - cvmx_usb_transfer_t ttype; - - if (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA) { - /* Without DMA we need to be careful to not schedule something at the end of a frame and cause an overrun */ - cvmx_usbcx_hfnum_t hfnum = {.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HFNUM(usb->index))}; - cvmx_usbcx_hfir_t hfir = {.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HFIR(usb->index))}; - if (hfnum.s.frrem < hfir.s.frint/4) - goto done; - } - - while (usb->idle_hardware_channels) { - /* Find an idle channel */ - CVMX_CLZ(channel, usb->idle_hardware_channels); - channel = 31 - channel; - if (unlikely(channel > 7)) - break; - - /* Find a pipe needing service */ - pipe = NULL; - if (is_sof) { - /* Only process periodic pipes on SOF interrupts. This way we are - sure that the periodic data is sent in the beginning of the - frame */ - pipe = __cvmx_usb_find_ready_pipe(usb, usb->active_pipes + CVMX_USB_TRANSFER_ISOCHRONOUS, usb->frame_number); - if (likely(!pipe)) - pipe = __cvmx_usb_find_ready_pipe(usb, usb->active_pipes + CVMX_USB_TRANSFER_INTERRUPT, usb->frame_number); - } - if (likely(!pipe)) { - pipe = __cvmx_usb_find_ready_pipe(usb, usb->active_pipes + CVMX_USB_TRANSFER_CONTROL, usb->frame_number); - if (likely(!pipe)) - pipe = __cvmx_usb_find_ready_pipe(usb, usb->active_pipes + CVMX_USB_TRANSFER_BULK, usb->frame_number); - } - if (!pipe) - break; - - __cvmx_usb_start_channel(usb, channel, pipe); - } + int channel; + cvmx_usb_pipe_t *pipe; + int need_sof; + cvmx_usb_transfer_t ttype; + + if (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA) { + /* Without DMA we need to be careful to not schedule something at the end of a frame and cause an overrun */ + cvmx_usbcx_hfnum_t hfnum = {.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HFNUM(usb->index))}; + cvmx_usbcx_hfir_t hfir = {.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HFIR(usb->index))}; + if (hfnum.s.frrem < hfir.s.frint/4) + goto done; + } + + while (usb->idle_hardware_channels) { + /* Find an idle channel */ + CVMX_CLZ(channel, usb->idle_hardware_channels); + channel = 31 - channel; + if (unlikely(channel > 7)) + break; + + /* Find a pipe needing service */ + pipe = NULL; + if (is_sof) { + /* Only process periodic pipes on SOF interrupts. This way we are + sure that the periodic data is sent in the beginning of the + frame */ + pipe = __cvmx_usb_find_ready_pipe(usb, usb->active_pipes + CVMX_USB_TRANSFER_ISOCHRONOUS, usb->frame_number); + if (likely(!pipe)) + pipe = __cvmx_usb_find_ready_pipe(usb, usb->active_pipes + CVMX_USB_TRANSFER_INTERRUPT, usb->frame_number); + } + if (likely(!pipe)) { + pipe = __cvmx_usb_find_ready_pipe(usb, usb->active_pipes + CVMX_USB_TRANSFER_CONTROL, usb->frame_number); + if (likely(!pipe)) + pipe = __cvmx_usb_find_ready_pipe(usb, usb->active_pipes + CVMX_USB_TRANSFER_BULK, usb->frame_number); + } + if (!pipe) + break; + + __cvmx_usb_start_channel(usb, channel, pipe); + } done: - /* Only enable SOF interrupts when we have transactions pending in the - future that might need to be scheduled */ - need_sof = 0; - for (ttype=CVMX_USB_TRANSFER_CONTROL; ttype<=CVMX_USB_TRANSFER_INTERRUPT; ttype++) { - pipe = usb->active_pipes[ttype].head; - while (pipe) { - if (pipe->next_tx_frame > usb->frame_number) { - need_sof = 1; - break; - } - pipe=pipe->next; - } - } - USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), cvmx_usbcx_gintmsk_t, sofmsk, need_sof); - return; + /* Only enable SOF interrupts when we have transactions pending in the + future that might need to be scheduled */ + need_sof = 0; + for (ttype = CVMX_USB_TRANSFER_CONTROL; ttype <= CVMX_USB_TRANSFER_INTERRUPT; ttype++) { + pipe = usb->active_pipes[ttype].head; + while (pipe) { + if (pipe->next_tx_frame > usb->frame_number) { + need_sof = 1; + break; + } + pipe = pipe->next; + } + } + USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), cvmx_usbcx_gintmsk_t, sofmsk, need_sof); + return; } @@ -1797,45 +1786,45 @@ static void __cvmx_usb_schedule(cvmx_usb_internal_state_t *usb, int is_sof) * @INTERNAL * Call a user's callback for a specific reason. * - * @param usb USB device state populated by - * cvmx_usb_initialize(). - * @param pipe Pipe the callback is for or NULL + * @param usb USB device state populated by + * cvmx_usb_initialize(). + * @param pipe Pipe the callback is for or NULL * @param transaction - * Transaction the callback is for or NULL + * Transaction the callback is for or NULL * @param reason Reason this callback is being called * @param complete_code - * Completion code for the transaction, if any + * Completion code for the transaction, if any */ static void __cvmx_usb_perform_callback(cvmx_usb_internal_state_t *usb, - cvmx_usb_pipe_t *pipe, - cvmx_usb_transaction_t *transaction, - cvmx_usb_callback_t reason, - cvmx_usb_complete_t complete_code) + cvmx_usb_pipe_t *pipe, + cvmx_usb_transaction_t *transaction, + cvmx_usb_callback_t reason, + cvmx_usb_complete_t complete_code) { - cvmx_usb_callback_func_t callback = usb->callback[reason]; - void *user_data = usb->callback_data[reason]; - int submit_handle = -1; - int pipe_handle = -1; - int bytes_transferred = 0; - - if (pipe) - pipe_handle = __cvmx_usb_get_pipe_handle(usb, pipe); - - if (transaction) { - submit_handle = __cvmx_usb_get_submit_handle(usb, transaction); - bytes_transferred = transaction->actual_bytes; - /* Transactions are allowed to override the default callback */ - if ((reason == CVMX_USB_CALLBACK_TRANSFER_COMPLETE) && transaction->callback) { - callback = transaction->callback; - user_data = transaction->callback_data; - } - } - - if (!callback) - return; - - callback((cvmx_usb_state_t *)usb, reason, complete_code, pipe_handle, submit_handle, - bytes_transferred, user_data); + cvmx_usb_callback_func_t callback = usb->callback[reason]; + void *user_data = usb->callback_data[reason]; + int submit_handle = -1; + int pipe_handle = -1; + int bytes_transferred = 0; + + if (pipe) + pipe_handle = __cvmx_usb_get_pipe_handle(usb, pipe); + + if (transaction) { + submit_handle = __cvmx_usb_get_submit_handle(usb, transaction); + bytes_transferred = transaction->actual_bytes; + /* Transactions are allowed to override the default callback */ + if ((reason == CVMX_USB_CALLBACK_TRANSFER_COMPLETE) && transaction->callback) { + callback = transaction->callback; + user_data = transaction->callback_data; + } + } + + if (!callback) + return; + + callback((cvmx_usb_state_t *)usb, reason, complete_code, pipe_handle, submit_handle, + bytes_transferred, user_data); } @@ -1844,61 +1833,61 @@ static void __cvmx_usb_perform_callback(cvmx_usb_internal_state_t *usb, * Signal the completion of a transaction and free it. The * transaction will be removed from the pipe transaction list. * - * @param usb USB device state populated by - * cvmx_usb_initialize(). - * @param pipe Pipe the transaction is on + * @param usb USB device state populated by + * cvmx_usb_initialize(). + * @param pipe Pipe the transaction is on * @param transaction - * Transaction that completed + * Transaction that completed * @param complete_code - * Completion code + * Completion code */ -static void __cvmx_usb_perform_complete(cvmx_usb_internal_state_t * usb, - cvmx_usb_pipe_t *pipe, - cvmx_usb_transaction_t *transaction, - cvmx_usb_complete_t complete_code) +static void __cvmx_usb_perform_complete(cvmx_usb_internal_state_t *usb, + cvmx_usb_pipe_t *pipe, + cvmx_usb_transaction_t *transaction, + cvmx_usb_complete_t complete_code) { - /* If this was a split then clear our split in progress marker */ - if (usb->active_split == transaction) - usb->active_split = NULL; - - /* Isochronous transactions need extra processing as they might not be done - after a single data transfer */ - if (unlikely(transaction->type == CVMX_USB_TRANSFER_ISOCHRONOUS)) { - /* Update the number of bytes transferred in this ISO packet */ - transaction->iso_packets[0].length = transaction->actual_bytes; - transaction->iso_packets[0].status = complete_code; - - /* If there are more ISOs pending and we succeeded, schedule the next - one */ - if ((transaction->iso_number_packets > 1) && (complete_code == CVMX_USB_COMPLETE_SUCCESS)) { - transaction->actual_bytes = 0; /* No bytes transferred for this packet as of yet */ - transaction->iso_number_packets--; /* One less ISO waiting to transfer */ - transaction->iso_packets++; /* Increment to the next location in our packet array */ - transaction->stage = CVMX_USB_STAGE_NON_CONTROL; - goto done; - } - } - - /* Remove the transaction from the pipe list */ - if (transaction->next) - transaction->next->prev = transaction->prev; - else - pipe->tail = transaction->prev; - if (transaction->prev) - transaction->prev->next = transaction->next; - else - pipe->head = transaction->next; - if (!pipe->head) { - __cvmx_usb_remove_pipe(usb->active_pipes + pipe->transfer_type, pipe); - __cvmx_usb_append_pipe(&usb->idle_pipes, pipe); - - } - __cvmx_usb_perform_callback(usb, pipe, transaction, - CVMX_USB_CALLBACK_TRANSFER_COMPLETE, - complete_code); - __cvmx_usb_free_transaction(usb, transaction); + /* If this was a split then clear our split in progress marker */ + if (usb->active_split == transaction) + usb->active_split = NULL; + + /* Isochronous transactions need extra processing as they might not be done + after a single data transfer */ + if (unlikely(transaction->type == CVMX_USB_TRANSFER_ISOCHRONOUS)) { + /* Update the number of bytes transferred in this ISO packet */ + transaction->iso_packets[0].length = transaction->actual_bytes; + transaction->iso_packets[0].status = complete_code; + + /* If there are more ISOs pending and we succeeded, schedule the next + one */ + if ((transaction->iso_number_packets > 1) && (complete_code == CVMX_USB_COMPLETE_SUCCESS)) { + transaction->actual_bytes = 0; /* No bytes transferred for this packet as of yet */ + transaction->iso_number_packets--; /* One less ISO waiting to transfer */ + transaction->iso_packets++; /* Increment to the next location in our packet array */ + transaction->stage = CVMX_USB_STAGE_NON_CONTROL; + goto done; + } + } + + /* Remove the transaction from the pipe list */ + if (transaction->next) + transaction->next->prev = transaction->prev; + else + pipe->tail = transaction->prev; + if (transaction->prev) + transaction->prev->next = transaction->next; + else + pipe->head = transaction->next; + if (!pipe->head) { + __cvmx_usb_remove_pipe(usb->active_pipes + pipe->transfer_type, pipe); + __cvmx_usb_append_pipe(&usb->idle_pipes, pipe); + + } + __cvmx_usb_perform_callback(usb, pipe, transaction, + CVMX_USB_CALLBACK_TRANSFER_COMPLETE, + complete_code); + __cvmx_usb_free_transaction(usb, transaction); done: - return; + return; } @@ -1909,365 +1898,364 @@ static void __cvmx_usb_perform_complete(cvmx_usb_internal_state_t * usb, * * @param usb * @param pipe_handle - * Which pipe to submit to. Will be validated in this function. - * @param type Transaction type - * @param flags Flags for the transaction + * Which pipe to submit to. Will be validated in this function. + * @param type Transaction type + * @param flags Flags for the transaction * @param buffer User buffer for the transaction * @param buffer_length - * User buffer's length in bytes + * User buffer's length in bytes * @param control_header - * For control transactions, the 8 byte standard header + * For control transactions, the 8 byte standard header * @param iso_start_frame - * For ISO transactions, the start frame + * For ISO transactions, the start frame * @param iso_number_packets - * For ISO, the number of packet in the transaction. + * For ISO, the number of packet in the transaction. * @param iso_packets - * A description of each ISO packet + * A description of each ISO packet * @param callback User callback to call when the transaction completes * @param user_data User's data for the callback * * @return Submit handle or negative on failure. Matches the result - * in the external API. + * in the external API. */ static int __cvmx_usb_submit_transaction(cvmx_usb_internal_state_t *usb, - int pipe_handle, - cvmx_usb_transfer_t type, - int flags, - uint64_t buffer, - int buffer_length, - uint64_t control_header, - int iso_start_frame, - int iso_number_packets, - cvmx_usb_iso_packet_t *iso_packets, - cvmx_usb_callback_func_t callback, - void *user_data) + int pipe_handle, + cvmx_usb_transfer_t type, + int flags, + uint64_t buffer, + int buffer_length, + uint64_t control_header, + int iso_start_frame, + int iso_number_packets, + cvmx_usb_iso_packet_t *iso_packets, + cvmx_usb_callback_func_t callback, + void *user_data) { - int submit_handle; - cvmx_usb_transaction_t *transaction; - cvmx_usb_pipe_t *pipe = usb->pipe + pipe_handle; - - if (unlikely((pipe_handle < 0) || (pipe_handle >= MAX_PIPES))) - return -EINVAL; - /* Fail if the pipe isn't open */ - if (unlikely((pipe->flags & __CVMX_USB_PIPE_FLAGS_OPEN) == 0)) - return -EINVAL; - if (unlikely(pipe->transfer_type != type)) - return -EINVAL; - - transaction = __cvmx_usb_alloc_transaction(usb); - if (unlikely(!transaction)) - return -ENOMEM; - - transaction->type = type; - transaction->flags |= flags; - transaction->buffer = buffer; - transaction->buffer_length = buffer_length; - transaction->control_header = control_header; - transaction->iso_start_frame = iso_start_frame; // FIXME: This is not used, implement it - transaction->iso_number_packets = iso_number_packets; - transaction->iso_packets = iso_packets; - transaction->callback = callback; - transaction->callback_data = user_data; - if (transaction->type == CVMX_USB_TRANSFER_CONTROL) - transaction->stage = CVMX_USB_STAGE_SETUP; - else - transaction->stage = CVMX_USB_STAGE_NON_CONTROL; - - transaction->next = NULL; - if (pipe->tail) { - transaction->prev = pipe->tail; - transaction->prev->next = transaction; - } - else { - if (pipe->next_tx_frame < usb->frame_number) - pipe->next_tx_frame = usb->frame_number + pipe->interval - - (usb->frame_number - pipe->next_tx_frame) % pipe->interval; - transaction->prev = NULL; - pipe->head = transaction; - __cvmx_usb_remove_pipe(&usb->idle_pipes, pipe); - __cvmx_usb_append_pipe(usb->active_pipes + pipe->transfer_type, pipe); - } - pipe->tail = transaction; - - submit_handle = __cvmx_usb_get_submit_handle(usb, transaction); - - /* We may need to schedule the pipe if this was the head of the pipe */ - if (!transaction->prev) - __cvmx_usb_schedule(usb, 0); - - return submit_handle; + int submit_handle; + cvmx_usb_transaction_t *transaction; + cvmx_usb_pipe_t *pipe = usb->pipe + pipe_handle; + + if (unlikely((pipe_handle < 0) || (pipe_handle >= MAX_PIPES))) + return -EINVAL; + /* Fail if the pipe isn't open */ + if (unlikely((pipe->flags & __CVMX_USB_PIPE_FLAGS_OPEN) == 0)) + return -EINVAL; + if (unlikely(pipe->transfer_type != type)) + return -EINVAL; + + transaction = __cvmx_usb_alloc_transaction(usb); + if (unlikely(!transaction)) + return -ENOMEM; + + transaction->type = type; + transaction->flags |= flags; + transaction->buffer = buffer; + transaction->buffer_length = buffer_length; + transaction->control_header = control_header; + transaction->iso_start_frame = iso_start_frame; // FIXME: This is not used, implement it + transaction->iso_number_packets = iso_number_packets; + transaction->iso_packets = iso_packets; + transaction->callback = callback; + transaction->callback_data = user_data; + if (transaction->type == CVMX_USB_TRANSFER_CONTROL) + transaction->stage = CVMX_USB_STAGE_SETUP; + else + transaction->stage = CVMX_USB_STAGE_NON_CONTROL; + + transaction->next = NULL; + if (pipe->tail) { + transaction->prev = pipe->tail; + transaction->prev->next = transaction; + } else { + if (pipe->next_tx_frame < usb->frame_number) + pipe->next_tx_frame = usb->frame_number + pipe->interval - + (usb->frame_number - pipe->next_tx_frame) % pipe->interval; + transaction->prev = NULL; + pipe->head = transaction; + __cvmx_usb_remove_pipe(&usb->idle_pipes, pipe); + __cvmx_usb_append_pipe(usb->active_pipes + pipe->transfer_type, pipe); + } + pipe->tail = transaction; + + submit_handle = __cvmx_usb_get_submit_handle(usb, transaction); + + /* We may need to schedule the pipe if this was the head of the pipe */ + if (!transaction->prev) + __cvmx_usb_schedule(usb, 0); + + return submit_handle; } /** * Call to submit a USB Bulk transfer to a pipe. * - * @param state USB device state populated by - * cvmx_usb_initialize(). + * @param state USB device state populated by + * cvmx_usb_initialize(). * @param pipe_handle - * Handle to the pipe for the transfer. + * Handle to the pipe for the transfer. * @param buffer Physical address of the data buffer in - * memory. Note that this is NOT A POINTER, but - * the full 64bit physical address of the - * buffer. This may be zero if buffer_length is - * zero. + * memory. Note that this is NOT A POINTER, but + * the full 64bit physical address of the + * buffer. This may be zero if buffer_length is + * zero. * @param buffer_length - * Length of buffer in bytes. + * Length of buffer in bytes. * @param callback Function to call when this transaction - * completes. If the return value of this - * function isn't an error, then this function - * is guaranteed to be called when the - * transaction completes. If this parameter is - * NULL, then the generic callback registered - * through cvmx_usb_register_callback is - * called. If both are NULL, then there is no - * way to know when a transaction completes. + * completes. If the return value of this + * function isn't an error, then this function + * is guaranteed to be called when the + * transaction completes. If this parameter is + * NULL, then the generic callback registered + * through cvmx_usb_register_callback is + * called. If both are NULL, then there is no + * way to know when a transaction completes. * @param user_data User supplied data returned when the - * callback is called. This is only used if - * callback in not NULL. + * callback is called. This is only used if + * callback in not NULL. * * @return A submitted transaction handle or negative on - * failure. Negative values are error codes. + * failure. Negative values are error codes. */ int cvmx_usb_submit_bulk(cvmx_usb_state_t *state, int pipe_handle, - uint64_t buffer, int buffer_length, - cvmx_usb_callback_func_t callback, - void *user_data) + uint64_t buffer, int buffer_length, + cvmx_usb_callback_func_t callback, + void *user_data) { - int submit_handle; - cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; - - /* Pipe handle checking is done later in a common place */ - if (unlikely(!buffer)) - return -EINVAL; - if (unlikely(buffer_length < 0)) - return -EINVAL; - - submit_handle = __cvmx_usb_submit_transaction(usb, pipe_handle, - CVMX_USB_TRANSFER_BULK, - 0, /* flags */ - buffer, - buffer_length, - 0, /* control_header */ - 0, /* iso_start_frame */ - 0, /* iso_number_packets */ - NULL, /* iso_packets */ - callback, - user_data); - return submit_handle; + int submit_handle; + cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; + + /* Pipe handle checking is done later in a common place */ + if (unlikely(!buffer)) + return -EINVAL; + if (unlikely(buffer_length < 0)) + return -EINVAL; + + submit_handle = __cvmx_usb_submit_transaction(usb, pipe_handle, + CVMX_USB_TRANSFER_BULK, + 0, /* flags */ + buffer, + buffer_length, + 0, /* control_header */ + 0, /* iso_start_frame */ + 0, /* iso_number_packets */ + NULL, /* iso_packets */ + callback, + user_data); + return submit_handle; } /** * Call to submit a USB Interrupt transfer to a pipe. * - * @param state USB device state populated by - * cvmx_usb_initialize(). + * @param state USB device state populated by + * cvmx_usb_initialize(). * @param pipe_handle - * Handle to the pipe for the transfer. + * Handle to the pipe for the transfer. * @param buffer Physical address of the data buffer in - * memory. Note that this is NOT A POINTER, but - * the full 64bit physical address of the - * buffer. This may be zero if buffer_length is - * zero. + * memory. Note that this is NOT A POINTER, but + * the full 64bit physical address of the + * buffer. This may be zero if buffer_length is + * zero. * @param buffer_length - * Length of buffer in bytes. + * Length of buffer in bytes. * @param callback Function to call when this transaction - * completes. If the return value of this - * function isn't an error, then this function - * is guaranteed to be called when the - * transaction completes. If this parameter is - * NULL, then the generic callback registered - * through cvmx_usb_register_callback is - * called. If both are NULL, then there is no - * way to know when a transaction completes. + * completes. If the return value of this + * function isn't an error, then this function + * is guaranteed to be called when the + * transaction completes. If this parameter is + * NULL, then the generic callback registered + * through cvmx_usb_register_callback is + * called. If both are NULL, then there is no + * way to know when a transaction completes. * @param user_data User supplied data returned when the - * callback is called. This is only used if - * callback in not NULL. + * callback is called. This is only used if + * callback in not NULL. * * @return A submitted transaction handle or negative on - * failure. Negative values are error codes. + * failure. Negative values are error codes. */ int cvmx_usb_submit_interrupt(cvmx_usb_state_t *state, int pipe_handle, - uint64_t buffer, int buffer_length, - cvmx_usb_callback_func_t callback, - void *user_data) + uint64_t buffer, int buffer_length, + cvmx_usb_callback_func_t callback, + void *user_data) { - int submit_handle; - cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; - - /* Pipe handle checking is done later in a common place */ - if (unlikely(!buffer)) - return -EINVAL; - if (unlikely(buffer_length < 0)) - return -EINVAL; - - submit_handle = __cvmx_usb_submit_transaction(usb, pipe_handle, - CVMX_USB_TRANSFER_INTERRUPT, - 0, /* flags */ - buffer, - buffer_length, - 0, /* control_header */ - 0, /* iso_start_frame */ - 0, /* iso_number_packets */ - NULL, /* iso_packets */ - callback, - user_data); - return submit_handle; + int submit_handle; + cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; + + /* Pipe handle checking is done later in a common place */ + if (unlikely(!buffer)) + return -EINVAL; + if (unlikely(buffer_length < 0)) + return -EINVAL; + + submit_handle = __cvmx_usb_submit_transaction(usb, pipe_handle, + CVMX_USB_TRANSFER_INTERRUPT, + 0, /* flags */ + buffer, + buffer_length, + 0, /* control_header */ + 0, /* iso_start_frame */ + 0, /* iso_number_packets */ + NULL, /* iso_packets */ + callback, + user_data); + return submit_handle; } /** * Call to submit a USB Control transfer to a pipe. * - * @param state USB device state populated by - * cvmx_usb_initialize(). + * @param state USB device state populated by + * cvmx_usb_initialize(). * @param pipe_handle - * Handle to the pipe for the transfer. + * Handle to the pipe for the transfer. * @param control_header - * USB 8 byte control header physical address. - * Note that this is NOT A POINTER, but the - * full 64bit physical address of the buffer. + * USB 8 byte control header physical address. + * Note that this is NOT A POINTER, but the + * full 64bit physical address of the buffer. * @param buffer Physical address of the data buffer in - * memory. Note that this is NOT A POINTER, but - * the full 64bit physical address of the - * buffer. This may be zero if buffer_length is - * zero. + * memory. Note that this is NOT A POINTER, but + * the full 64bit physical address of the + * buffer. This may be zero if buffer_length is + * zero. * @param buffer_length - * Length of buffer in bytes. + * Length of buffer in bytes. * @param callback Function to call when this transaction - * completes. If the return value of this - * function isn't an error, then this function - * is guaranteed to be called when the - * transaction completes. If this parameter is - * NULL, then the generic callback registered - * through cvmx_usb_register_callback is - * called. If both are NULL, then there is no - * way to know when a transaction completes. + * completes. If the return value of this + * function isn't an error, then this function + * is guaranteed to be called when the + * transaction completes. If this parameter is + * NULL, then the generic callback registered + * through cvmx_usb_register_callback is + * called. If both are NULL, then there is no + * way to know when a transaction completes. * @param user_data User supplied data returned when the - * callback is called. This is only used if - * callback in not NULL. + * callback is called. This is only used if + * callback in not NULL. * * @return A submitted transaction handle or negative on - * failure. Negative values are error codes. + * failure. Negative values are error codes. */ int cvmx_usb_submit_control(cvmx_usb_state_t *state, int pipe_handle, - uint64_t control_header, - uint64_t buffer, int buffer_length, - cvmx_usb_callback_func_t callback, - void *user_data) + uint64_t control_header, + uint64_t buffer, int buffer_length, + cvmx_usb_callback_func_t callback, + void *user_data) { - int submit_handle; - cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; - cvmx_usb_control_header_t *header = cvmx_phys_to_ptr(control_header); - - /* Pipe handle checking is done later in a common place */ - if (unlikely(!control_header)) - return -EINVAL; - /* Some drivers send a buffer with a zero length. God only knows why */ - if (unlikely(buffer && (buffer_length < 0))) - return -EINVAL; - if (unlikely(!buffer && (buffer_length != 0))) - return -EINVAL; - if ((header->s.request_type & 0x80) == 0) - buffer_length = le16_to_cpu(header->s.length); - - submit_handle = __cvmx_usb_submit_transaction(usb, pipe_handle, - CVMX_USB_TRANSFER_CONTROL, - 0, /* flags */ - buffer, - buffer_length, - control_header, - 0, /* iso_start_frame */ - 0, /* iso_number_packets */ - NULL, /* iso_packets */ - callback, - user_data); - return submit_handle; + int submit_handle; + cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; + cvmx_usb_control_header_t *header = cvmx_phys_to_ptr(control_header); + + /* Pipe handle checking is done later in a common place */ + if (unlikely(!control_header)) + return -EINVAL; + /* Some drivers send a buffer with a zero length. God only knows why */ + if (unlikely(buffer && (buffer_length < 0))) + return -EINVAL; + if (unlikely(!buffer && (buffer_length != 0))) + return -EINVAL; + if ((header->s.request_type & 0x80) == 0) + buffer_length = le16_to_cpu(header->s.length); + + submit_handle = __cvmx_usb_submit_transaction(usb, pipe_handle, + CVMX_USB_TRANSFER_CONTROL, + 0, /* flags */ + buffer, + buffer_length, + control_header, + 0, /* iso_start_frame */ + 0, /* iso_number_packets */ + NULL, /* iso_packets */ + callback, + user_data); + return submit_handle; } /** * Call to submit a USB Isochronous transfer to a pipe. * - * @param state USB device state populated by - * cvmx_usb_initialize(). + * @param state USB device state populated by + * cvmx_usb_initialize(). * @param pipe_handle - * Handle to the pipe for the transfer. + * Handle to the pipe for the transfer. * @param start_frame - * Number of frames into the future to schedule - * this transaction. - * @param flags Flags to control the transfer. See - * cvmx_usb_isochronous_flags_t for the flag - * definitions. + * Number of frames into the future to schedule + * this transaction. + * @param flags Flags to control the transfer. See + * cvmx_usb_isochronous_flags_t for the flag + * definitions. * @param number_packets - * Number of sequential packets to transfer. - * "packets" is a pointer to an array of this - * many packet structures. + * Number of sequential packets to transfer. + * "packets" is a pointer to an array of this + * many packet structures. * @param packets Description of each transfer packet as - * defined by cvmx_usb_iso_packet_t. The array - * pointed to here must stay valid until the - * complete callback is called. + * defined by cvmx_usb_iso_packet_t. The array + * pointed to here must stay valid until the + * complete callback is called. * @param buffer Physical address of the data buffer in - * memory. Note that this is NOT A POINTER, but - * the full 64bit physical address of the - * buffer. This may be zero if buffer_length is - * zero. + * memory. Note that this is NOT A POINTER, but + * the full 64bit physical address of the + * buffer. This may be zero if buffer_length is + * zero. * @param buffer_length - * Length of buffer in bytes. + * Length of buffer in bytes. * @param callback Function to call when this transaction - * completes. If the return value of this - * function isn't an error, then this function - * is guaranteed to be called when the - * transaction completes. If this parameter is - * NULL, then the generic callback registered - * through cvmx_usb_register_callback is - * called. If both are NULL, then there is no - * way to know when a transaction completes. + * completes. If the return value of this + * function isn't an error, then this function + * is guaranteed to be called when the + * transaction completes. If this parameter is + * NULL, then the generic callback registered + * through cvmx_usb_register_callback is + * called. If both are NULL, then there is no + * way to know when a transaction completes. * @param user_data User supplied data returned when the - * callback is called. This is only used if - * callback in not NULL. + * callback is called. This is only used if + * callback in not NULL. * * @return A submitted transaction handle or negative on - * failure. Negative values are error codes. + * failure. Negative values are error codes. */ int cvmx_usb_submit_isochronous(cvmx_usb_state_t *state, int pipe_handle, - int start_frame, int flags, - int number_packets, - cvmx_usb_iso_packet_t packets[], - uint64_t buffer, int buffer_length, - cvmx_usb_callback_func_t callback, - void *user_data) + int start_frame, int flags, + int number_packets, + cvmx_usb_iso_packet_t packets[], + uint64_t buffer, int buffer_length, + cvmx_usb_callback_func_t callback, + void *user_data) { - int submit_handle; - cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; - - /* Pipe handle checking is done later in a common place */ - if (unlikely(start_frame < 0)) - return -EINVAL; - if (unlikely(flags & ~(CVMX_USB_ISOCHRONOUS_FLAGS_ALLOW_SHORT | CVMX_USB_ISOCHRONOUS_FLAGS_ASAP))) - return -EINVAL; - if (unlikely(number_packets < 1)) - return -EINVAL; - if (unlikely(!packets)) - return -EINVAL; - if (unlikely(!buffer)) - return -EINVAL; - if (unlikely(buffer_length < 0)) - return -EINVAL; - - submit_handle = __cvmx_usb_submit_transaction(usb, pipe_handle, - CVMX_USB_TRANSFER_ISOCHRONOUS, - flags, - buffer, - buffer_length, - 0, /* control_header */ - start_frame, - number_packets, - packets, - callback, - user_data); - return submit_handle; + int submit_handle; + cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; + + /* Pipe handle checking is done later in a common place */ + if (unlikely(start_frame < 0)) + return -EINVAL; + if (unlikely(flags & ~(CVMX_USB_ISOCHRONOUS_FLAGS_ALLOW_SHORT | CVMX_USB_ISOCHRONOUS_FLAGS_ASAP))) + return -EINVAL; + if (unlikely(number_packets < 1)) + return -EINVAL; + if (unlikely(!packets)) + return -EINVAL; + if (unlikely(!buffer)) + return -EINVAL; + if (unlikely(buffer_length < 0)) + return -EINVAL; + + submit_handle = __cvmx_usb_submit_transaction(usb, pipe_handle, + CVMX_USB_TRANSFER_ISOCHRONOUS, + flags, + buffer, + buffer_length, + 0, /* control_header */ + start_frame, + number_packets, + packets, + callback, + user_data); + return submit_handle; } @@ -2279,55 +2267,55 @@ int cvmx_usb_submit_isochronous(cvmx_usb_state_t *state, int pipe_handle, * associated callback. * * @param state USB device state populated by - * cvmx_usb_initialize(). + * cvmx_usb_initialize(). * @param pipe_handle - * Pipe handle to cancel requests in. + * Pipe handle to cancel requests in. * @param submit_handle - * Handle to transaction to cancel, returned by the submit function. + * Handle to transaction to cancel, returned by the submit function. * * @return 0 or a negative error code. */ int cvmx_usb_cancel(cvmx_usb_state_t *state, int pipe_handle, int submit_handle) { - cvmx_usb_transaction_t *transaction; - cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; - cvmx_usb_pipe_t *pipe = usb->pipe + pipe_handle; - - if (unlikely((pipe_handle < 0) || (pipe_handle >= MAX_PIPES))) - return -EINVAL; - if (unlikely((submit_handle < 0) || (submit_handle >= MAX_TRANSACTIONS))) - return -EINVAL; - - /* Fail if the pipe isn't open */ - if (unlikely((pipe->flags & __CVMX_USB_PIPE_FLAGS_OPEN) == 0)) - return -EINVAL; - - transaction = usb->transaction + submit_handle; - - /* Fail if this transaction already completed */ - if (unlikely((transaction->flags & __CVMX_USB_TRANSACTION_FLAGS_IN_USE) == 0)) - return -EINVAL; - - /* If the transaction is the HEAD of the queue and scheduled. We need to - treat it special */ - if ((pipe->head == transaction) && - (pipe->flags & __CVMX_USB_PIPE_FLAGS_SCHEDULED)) { - cvmx_usbcx_hccharx_t usbc_hcchar; - - usb->pipe_for_channel[pipe->channel] = NULL; - pipe->flags &= ~__CVMX_USB_PIPE_FLAGS_SCHEDULED; - - CVMX_SYNCW; - - usbc_hcchar.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCCHARX(pipe->channel, usb->index)); - /* If the channel isn't enabled then the transaction already completed */ - if (usbc_hcchar.s.chena) { - usbc_hcchar.s.chdis = 1; - __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCCHARX(pipe->channel, usb->index), usbc_hcchar.u32); - } - } - __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_CANCEL); - return 0; + cvmx_usb_transaction_t *transaction; + cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; + cvmx_usb_pipe_t *pipe = usb->pipe + pipe_handle; + + if (unlikely((pipe_handle < 0) || (pipe_handle >= MAX_PIPES))) + return -EINVAL; + if (unlikely((submit_handle < 0) || (submit_handle >= MAX_TRANSACTIONS))) + return -EINVAL; + + /* Fail if the pipe isn't open */ + if (unlikely((pipe->flags & __CVMX_USB_PIPE_FLAGS_OPEN) == 0)) + return -EINVAL; + + transaction = usb->transaction + submit_handle; + + /* Fail if this transaction already completed */ + if (unlikely((transaction->flags & __CVMX_USB_TRANSACTION_FLAGS_IN_USE) == 0)) + return -EINVAL; + + /* If the transaction is the HEAD of the queue and scheduled. We need to + treat it special */ + if ((pipe->head == transaction) && + (pipe->flags & __CVMX_USB_PIPE_FLAGS_SCHEDULED)) { + cvmx_usbcx_hccharx_t usbc_hcchar; + + usb->pipe_for_channel[pipe->channel] = NULL; + pipe->flags &= ~__CVMX_USB_PIPE_FLAGS_SCHEDULED; + + CVMX_SYNCW; + + usbc_hcchar.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCCHARX(pipe->channel, usb->index)); + /* If the channel isn't enabled then the transaction already completed */ + if (usbc_hcchar.s.chena) { + usbc_hcchar.s.chdis = 1; + __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCCHARX(pipe->channel, usb->index), usbc_hcchar.u32); + } + } + __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_CANCEL); + return 0; } @@ -2336,32 +2324,32 @@ int cvmx_usb_cancel(cvmx_usb_state_t *state, int pipe_handle, int submit_handle) * does is call cvmx_usb_cancel() in a loop. * * @param state USB device state populated by - * cvmx_usb_initialize(). + * cvmx_usb_initialize(). * @param pipe_handle - * Pipe handle to cancel requests in. + * Pipe handle to cancel requests in. * * @return 0 or a negative error code. */ int cvmx_usb_cancel_all(cvmx_usb_state_t *state, int pipe_handle) { - cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; - cvmx_usb_pipe_t *pipe = usb->pipe + pipe_handle; - - if (unlikely((pipe_handle < 0) || (pipe_handle >= MAX_PIPES))) - return -EINVAL; - - /* Fail if the pipe isn't open */ - if (unlikely((pipe->flags & __CVMX_USB_PIPE_FLAGS_OPEN) == 0)) - return -EINVAL; - - /* Simply loop through and attempt to cancel each transaction */ - while (pipe->head) { - int result = cvmx_usb_cancel(state, pipe_handle, - __cvmx_usb_get_submit_handle(usb, pipe->head)); - if (unlikely(result != 0)) - return result; - } - return 0; + cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; + cvmx_usb_pipe_t *pipe = usb->pipe + pipe_handle; + + if (unlikely((pipe_handle < 0) || (pipe_handle >= MAX_PIPES))) + return -EINVAL; + + /* Fail if the pipe isn't open */ + if (unlikely((pipe->flags & __CVMX_USB_PIPE_FLAGS_OPEN) == 0)) + return -EINVAL; + + /* Simply loop through and attempt to cancel each transaction */ + while (pipe->head) { + int result = cvmx_usb_cancel(state, pipe_handle, + __cvmx_usb_get_submit_handle(usb, pipe->head)); + if (unlikely(result != 0)) + return result; + } + return 0; } @@ -2369,42 +2357,42 @@ int cvmx_usb_cancel_all(cvmx_usb_state_t *state, int pipe_handle) * Close a pipe created with cvmx_usb_open_pipe(). * * @param state USB device state populated by - * cvmx_usb_initialize(). + * cvmx_usb_initialize(). * @param pipe_handle - * Pipe handle to close. + * Pipe handle to close. * * @return 0 or a negative error code. EBUSY is returned if the pipe has * outstanding transfers. */ int cvmx_usb_close_pipe(cvmx_usb_state_t *state, int pipe_handle) { - cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; - cvmx_usb_pipe_t *pipe = usb->pipe + pipe_handle; + cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; + cvmx_usb_pipe_t *pipe = usb->pipe + pipe_handle; - if (unlikely((pipe_handle < 0) || (pipe_handle >= MAX_PIPES))) - return -EINVAL; + if (unlikely((pipe_handle < 0) || (pipe_handle >= MAX_PIPES))) + return -EINVAL; - /* Fail if the pipe isn't open */ - if (unlikely((pipe->flags & __CVMX_USB_PIPE_FLAGS_OPEN) == 0)) - return -EINVAL; + /* Fail if the pipe isn't open */ + if (unlikely((pipe->flags & __CVMX_USB_PIPE_FLAGS_OPEN) == 0)) + return -EINVAL; - /* Fail if the pipe has pending transactions */ - if (unlikely(pipe->head)) - return -EBUSY; + /* Fail if the pipe has pending transactions */ + if (unlikely(pipe->head)) + return -EBUSY; - pipe->flags = 0; - __cvmx_usb_remove_pipe(&usb->idle_pipes, pipe); - __cvmx_usb_append_pipe(&usb->free_pipes, pipe); + pipe->flags = 0; + __cvmx_usb_remove_pipe(&usb->idle_pipes, pipe); + __cvmx_usb_append_pipe(&usb->free_pipes, pipe); - return 0; + return 0; } /** * Register a function to be called when various USB events occur. * - * @param state USB device state populated by - * cvmx_usb_initialize(). + * @param state USB device state populated by + * cvmx_usb_initialize(). * @param reason Which event to register for. * @param callback Function to call when the event occurs. * @param user_data User data parameter to the function. @@ -2416,17 +2404,17 @@ int cvmx_usb_register_callback(cvmx_usb_state_t *state, cvmx_usb_callback_func_t callback, void *user_data) { - cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; + cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; - if (unlikely(reason >= __CVMX_USB_CALLBACK_END)) - return -EINVAL; - if (unlikely(!callback)) - return -EINVAL; + if (unlikely(reason >= __CVMX_USB_CALLBACK_END)) + return -EINVAL; + if (unlikely(!callback)) + return -EINVAL; - usb->callback[reason] = callback; - usb->callback_data[reason] = user_data; + usb->callback[reason] = callback; + usb->callback_data[reason] = user_data; - return 0; + return 0; } @@ -2435,20 +2423,20 @@ int cvmx_usb_register_callback(cvmx_usb_state_t *state, * number is always in the range of 0-0x7ff. * * @param state USB device state populated by - * cvmx_usb_initialize(). + * cvmx_usb_initialize(). * * @return USB frame number */ int cvmx_usb_get_frame_number(cvmx_usb_state_t *state) { - int frame_number; - cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; - cvmx_usbcx_hfnum_t usbc_hfnum; + int frame_number; + cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; + cvmx_usbcx_hfnum_t usbc_hfnum; - usbc_hfnum.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HFNUM(usb->index)); - frame_number = usbc_hfnum.s.frnum; + usbc_hfnum.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HFNUM(usb->index)); + frame_number = usbc_hfnum.s.frnum; - return frame_number; + return frame_number; } @@ -2456,391 +2444,365 @@ int cvmx_usb_get_frame_number(cvmx_usb_state_t *state) * @INTERNAL * Poll a channel for status * - * @param usb USB device + * @param usb USB device * @param channel Channel to poll * * @return Zero on success */ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel) { - cvmx_usbcx_hcintx_t usbc_hcint; - cvmx_usbcx_hctsizx_t usbc_hctsiz; - cvmx_usbcx_hccharx_t usbc_hcchar; - cvmx_usb_pipe_t *pipe; - cvmx_usb_transaction_t *transaction; - int bytes_this_transfer; - int bytes_in_last_packet; - int packets_processed; - int buffer_space_left; - - /* Read the interrupt status bits for the channel */ - usbc_hcint.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCINTX(channel, usb->index)); - - if (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA) { - usbc_hcchar.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCCHARX(channel, usb->index)); - - if (usbc_hcchar.s.chena && usbc_hcchar.s.chdis) { - /* There seems to be a bug in CN31XX which can cause interrupt - IN transfers to get stuck until we do a write of HCCHARX - without changing things */ - __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCCHARX(channel, usb->index), usbc_hcchar.u32); - return 0; - } - - /* In non DMA mode the channels don't halt themselves. We need to - manually disable channels that are left running */ - if (!usbc_hcint.s.chhltd) { - if (usbc_hcchar.s.chena) { - cvmx_usbcx_hcintmskx_t hcintmsk; - /* Disable all interrupts except CHHLTD */ - hcintmsk.u32 = 0; - hcintmsk.s.chhltdmsk = 1; - __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCINTMSKX(channel, usb->index), hcintmsk.u32); - usbc_hcchar.s.chdis = 1; - __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCCHARX(channel, usb->index), usbc_hcchar.u32); - return 0; - } - else if (usbc_hcint.s.xfercompl) { - /* Successful IN/OUT with transfer complete. Channel halt isn't needed */ - } - else { - cvmx_dprintf("USB%d: Channel %d interrupt without halt\n", usb->index, channel); - return 0; - } - } - } - else { - /* There is are no interrupts that we need to process when the channel is - still running */ - if (!usbc_hcint.s.chhltd) - return 0; - } - - /* Disable the channel interrupts now that it is done */ - __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCINTMSKX(channel, usb->index), 0); - usb->idle_hardware_channels |= (1<pipe_for_channel[channel]; - CVMX_PREFETCH(pipe, 0); - CVMX_PREFETCH(pipe, 128); - if (!pipe) - return 0; - transaction = pipe->head; - CVMX_PREFETCH0(transaction); - - /* Disconnect this pipe from the HW channel. Later the schedule function will - figure out which pipe needs to go */ - usb->pipe_for_channel[channel] = NULL; - pipe->flags &= ~__CVMX_USB_PIPE_FLAGS_SCHEDULED; - - /* Read the channel config info so we can figure out how much data - transfered */ - usbc_hcchar.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCCHARX(channel, usb->index)); - usbc_hctsiz.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCTSIZX(channel, usb->index)); - - /* Calculating the number of bytes successfully transferred is dependent on - the transfer direction */ - packets_processed = transaction->pktcnt - usbc_hctsiz.s.pktcnt; - if (usbc_hcchar.s.epdir) { - /* IN transactions are easy. For every byte received the hardware - decrements xfersize. All we need to do is subtract the current - value of xfersize from its starting value and we know how many - bytes were written to the buffer */ - bytes_this_transfer = transaction->xfersize - usbc_hctsiz.s.xfersize; - } - else { - /* OUT transaction don't decrement xfersize. Instead pktcnt is - decremented on every successful packet send. The hardware does - this when it receives an ACK, or NYET. If it doesn't - receive one of these responses pktcnt doesn't change */ - bytes_this_transfer = packets_processed * usbc_hcchar.s.mps; - /* The last packet may not be a full transfer if we didn't have - enough data */ - if (bytes_this_transfer > transaction->xfersize) - bytes_this_transfer = transaction->xfersize; - } - /* Figure out how many bytes were in the last packet of the transfer */ - if (packets_processed) - bytes_in_last_packet = bytes_this_transfer - (packets_processed-1) * usbc_hcchar.s.mps; - else - bytes_in_last_packet = bytes_this_transfer; - - /* As a special case, setup transactions output the setup header, not - the user's data. For this reason we don't count setup data as bytes - transferred */ - if ((transaction->stage == CVMX_USB_STAGE_SETUP) || - (transaction->stage == CVMX_USB_STAGE_SETUP_SPLIT_COMPLETE)) - bytes_this_transfer = 0; - - /* Add the bytes transferred to the running total. It is important that - bytes_this_transfer doesn't count any data that needs to be - retransmitted */ - transaction->actual_bytes += bytes_this_transfer; - if (transaction->type == CVMX_USB_TRANSFER_ISOCHRONOUS) - buffer_space_left = transaction->iso_packets[0].length - transaction->actual_bytes; - else - buffer_space_left = transaction->buffer_length - transaction->actual_bytes; - - /* We need to remember the PID toggle state for the next transaction. The - hardware already updated it for the next transaction */ - pipe->pid_toggle = !(usbc_hctsiz.s.pid == 0); - - /* For high speed bulk out, assume the next transaction will need to do a - ping before proceeding. If this isn't true the ACK processing below - will clear this flag */ - if ((pipe->device_speed == CVMX_USB_SPEED_HIGH) && - (pipe->transfer_type == CVMX_USB_TRANSFER_BULK) && - (pipe->transfer_dir == CVMX_USB_DIRECTION_OUT)) - pipe->flags |= __CVMX_USB_PIPE_FLAGS_NEED_PING; - - if (usbc_hcint.s.stall) { - /* STALL as a response means this transaction cannot be completed - because the device can't process transactions. Tell the user. Any - data that was transferred will be counted on the actual bytes - transferred */ - pipe->pid_toggle = 0; - __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_STALL); - } - else if (usbc_hcint.s.xacterr) { - /* We know at least one packet worked if we get a ACK or NAK. Reset the retry counter */ - if (usbc_hcint.s.nak || usbc_hcint.s.ack) - transaction->retries = 0; - transaction->retries++; - if (transaction->retries > MAX_RETRIES) { - /* XactErr as a response means the device signaled something wrong with - the transfer. For example, PID toggle errors cause these */ - __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_XACTERR); - } - else { - /* If this was a split then clear our split in progress marker */ - if (usb->active_split == transaction) - usb->active_split = NULL; - /* Rewind to the beginning of the transaction by anding off the - split complete bit */ - transaction->stage &= ~1; - pipe->split_sc_frame = -1; - pipe->next_tx_frame += pipe->interval; - if (pipe->next_tx_frame < usb->frame_number) - pipe->next_tx_frame = usb->frame_number + pipe->interval - - (usb->frame_number - pipe->next_tx_frame) % pipe->interval; - } - } - else if (usbc_hcint.s.bblerr) - { - /* Babble Error (BblErr) */ - __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_BABBLEERR); - } - else if (usbc_hcint.s.datatglerr) - { - /* We'll retry the exact same transaction again */ - transaction->retries++; - } - else if (usbc_hcint.s.nyet) { - /* NYET as a response is only allowed in three cases: as a response to - a ping, as a response to a split transaction, and as a response to - a bulk out. The ping case is handled by hardware, so we only have - splits and bulk out */ - if (!__cvmx_usb_pipe_needs_split(usb, pipe)) { - transaction->retries = 0; - /* If there is more data to go then we need to try again. Otherwise - this transaction is complete */ - if ((buffer_space_left == 0) || (bytes_in_last_packet < pipe->max_packet)) - __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_SUCCESS); - } - else { - /* Split transactions retry the split complete 4 times then rewind - to the start split and do the entire transactions again */ - transaction->retries++; - if ((transaction->retries & 0x3) == 0) { - /* Rewind to the beginning of the transaction by anding off the - split complete bit */ - transaction->stage &= ~1; - pipe->split_sc_frame = -1; - } - } - } - else if (usbc_hcint.s.ack) { - transaction->retries = 0; - /* The ACK bit can only be checked after the other error bits. This is - because a multi packet transfer may succeed in a number of packets - and then get a different response on the last packet. In this case - both ACK and the last response bit will be set. If none of the - other response bits is set, then the last packet must have been an - ACK */ - - /* Since we got an ACK, we know we don't need to do a ping on this - pipe */ - pipe->flags &= ~__CVMX_USB_PIPE_FLAGS_NEED_PING; - - switch (transaction->type) - { - case CVMX_USB_TRANSFER_CONTROL: - switch (transaction->stage) - { - case CVMX_USB_STAGE_NON_CONTROL: - case CVMX_USB_STAGE_NON_CONTROL_SPLIT_COMPLETE: - /* This should be impossible */ - __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_ERROR); - break; - case CVMX_USB_STAGE_SETUP: - pipe->pid_toggle = 1; - if (__cvmx_usb_pipe_needs_split(usb, pipe)) - transaction->stage = CVMX_USB_STAGE_SETUP_SPLIT_COMPLETE; - else { - cvmx_usb_control_header_t *header = cvmx_phys_to_ptr(transaction->control_header); - if (header->s.length) - transaction->stage = CVMX_USB_STAGE_DATA; - else - transaction->stage = CVMX_USB_STAGE_STATUS; - } - break; - case CVMX_USB_STAGE_SETUP_SPLIT_COMPLETE: - { - cvmx_usb_control_header_t *header = cvmx_phys_to_ptr(transaction->control_header); - if (header->s.length) - transaction->stage = CVMX_USB_STAGE_DATA; - else - transaction->stage = CVMX_USB_STAGE_STATUS; - } - break; - case CVMX_USB_STAGE_DATA: - if (__cvmx_usb_pipe_needs_split(usb, pipe)) { - transaction->stage = CVMX_USB_STAGE_DATA_SPLIT_COMPLETE; - /* For setup OUT data that are splits, the hardware - doesn't appear to count transferred data. Here - we manually update the data transferred */ - if (!usbc_hcchar.s.epdir) { - if (buffer_space_left < pipe->max_packet) - transaction->actual_bytes += buffer_space_left; - else - transaction->actual_bytes += pipe->max_packet; - } - } - else if ((buffer_space_left == 0) || (bytes_in_last_packet < pipe->max_packet)) { - pipe->pid_toggle = 1; - transaction->stage = CVMX_USB_STAGE_STATUS; - } - break; - case CVMX_USB_STAGE_DATA_SPLIT_COMPLETE: - if ((buffer_space_left == 0) || (bytes_in_last_packet < pipe->max_packet)) { - pipe->pid_toggle = 1; - transaction->stage = CVMX_USB_STAGE_STATUS; - } - else { - transaction->stage = CVMX_USB_STAGE_DATA; - } - break; - case CVMX_USB_STAGE_STATUS: - if (__cvmx_usb_pipe_needs_split(usb, pipe)) - transaction->stage = CVMX_USB_STAGE_STATUS_SPLIT_COMPLETE; - else - __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_SUCCESS); - break; - case CVMX_USB_STAGE_STATUS_SPLIT_COMPLETE: - __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_SUCCESS); - break; - } - break; - case CVMX_USB_TRANSFER_BULK: - case CVMX_USB_TRANSFER_INTERRUPT: - /* The only time a bulk transfer isn't complete when - it finishes with an ACK is during a split transaction. For - splits we need to continue the transfer if more data is - needed */ - if (__cvmx_usb_pipe_needs_split(usb, pipe)) { - if (transaction->stage == CVMX_USB_STAGE_NON_CONTROL) - transaction->stage = CVMX_USB_STAGE_NON_CONTROL_SPLIT_COMPLETE; - else { - if (buffer_space_left && (bytes_in_last_packet == pipe->max_packet)) - transaction->stage = CVMX_USB_STAGE_NON_CONTROL; - else { - if (transaction->type == CVMX_USB_TRANSFER_INTERRUPT) - pipe->next_tx_frame += pipe->interval; - __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_SUCCESS); - } - } - } - else { - if ((pipe->device_speed == CVMX_USB_SPEED_HIGH) && - (pipe->transfer_type == CVMX_USB_TRANSFER_BULK) && - (pipe->transfer_dir == CVMX_USB_DIRECTION_OUT) && - (usbc_hcint.s.nak)) - pipe->flags |= __CVMX_USB_PIPE_FLAGS_NEED_PING; - if (!buffer_space_left || (bytes_in_last_packet < pipe->max_packet)) { - if (transaction->type == CVMX_USB_TRANSFER_INTERRUPT) - pipe->next_tx_frame += pipe->interval; - __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_SUCCESS); - } - } - break; - case CVMX_USB_TRANSFER_ISOCHRONOUS: - if (__cvmx_usb_pipe_needs_split(usb, pipe)) { - /* ISOCHRONOUS OUT splits don't require a complete split stage. - Instead they use a sequence of begin OUT splits to transfer - the data 188 bytes at a time. Once the transfer is complete, - the pipe sleeps until the next schedule interval */ - if (pipe->transfer_dir == CVMX_USB_DIRECTION_OUT) { - /* If no space left or this wasn't a max size packet then - this transfer is complete. Otherwise start it again - to send the next 188 bytes */ - if (!buffer_space_left || (bytes_this_transfer < 188)) { - pipe->next_tx_frame += pipe->interval; - __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_SUCCESS); - } - } - else { - if (transaction->stage == CVMX_USB_STAGE_NON_CONTROL_SPLIT_COMPLETE) { - /* We are in the incoming data phase. Keep getting - data until we run out of space or get a small - packet */ - if ((buffer_space_left == 0) || (bytes_in_last_packet < pipe->max_packet)) { - pipe->next_tx_frame += pipe->interval; - __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_SUCCESS); - } - } - else - transaction->stage = CVMX_USB_STAGE_NON_CONTROL_SPLIT_COMPLETE; - } - } - else { - pipe->next_tx_frame += pipe->interval; - __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_SUCCESS); - } - break; - } - } - else if (usbc_hcint.s.nak) { - /* If this was a split then clear our split in progress marker */ - if (usb->active_split == transaction) - usb->active_split = NULL; - /* NAK as a response means the device couldn't accept the transaction, - but it should be retried in the future. Rewind to the beginning of - the transaction by anding off the split complete bit. Retry in the - next interval */ - transaction->retries = 0; - transaction->stage &= ~1; - pipe->next_tx_frame += pipe->interval; - if (pipe->next_tx_frame < usb->frame_number) - pipe->next_tx_frame = usb->frame_number + pipe->interval - - (usb->frame_number - pipe->next_tx_frame) % pipe->interval; - } - else { - cvmx_usb_port_status_t port; - port = cvmx_usb_get_status((cvmx_usb_state_t *)usb); - if (port.port_enabled) - { - /* We'll retry the exact same transaction again */ - transaction->retries++; - } - else - { - /* We get channel halted interrupts with no result bits sets when the - cable is unplugged */ - __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_ERROR); - } - } - return 0; + cvmx_usbcx_hcintx_t usbc_hcint; + cvmx_usbcx_hctsizx_t usbc_hctsiz; + cvmx_usbcx_hccharx_t usbc_hcchar; + cvmx_usb_pipe_t *pipe; + cvmx_usb_transaction_t *transaction; + int bytes_this_transfer; + int bytes_in_last_packet; + int packets_processed; + int buffer_space_left; + + /* Read the interrupt status bits for the channel */ + usbc_hcint.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCINTX(channel, usb->index)); + + if (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA) { + usbc_hcchar.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCCHARX(channel, usb->index)); + + if (usbc_hcchar.s.chena && usbc_hcchar.s.chdis) { + /* There seems to be a bug in CN31XX which can cause interrupt + IN transfers to get stuck until we do a write of HCCHARX + without changing things */ + __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCCHARX(channel, usb->index), usbc_hcchar.u32); + return 0; + } + + /* In non DMA mode the channels don't halt themselves. We need to + manually disable channels that are left running */ + if (!usbc_hcint.s.chhltd) { + if (usbc_hcchar.s.chena) { + cvmx_usbcx_hcintmskx_t hcintmsk; + /* Disable all interrupts except CHHLTD */ + hcintmsk.u32 = 0; + hcintmsk.s.chhltdmsk = 1; + __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCINTMSKX(channel, usb->index), hcintmsk.u32); + usbc_hcchar.s.chdis = 1; + __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCCHARX(channel, usb->index), usbc_hcchar.u32); + return 0; + } else if (usbc_hcint.s.xfercompl) { + /* Successful IN/OUT with transfer complete. Channel halt isn't needed */ + } else { + cvmx_dprintf("USB%d: Channel %d interrupt without halt\n", usb->index, channel); + return 0; + } + } + } else { + /* There is are no interrupts that we need to process when the channel is + still running */ + if (!usbc_hcint.s.chhltd) + return 0; + } + + /* Disable the channel interrupts now that it is done */ + __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCINTMSKX(channel, usb->index), 0); + usb->idle_hardware_channels |= (1<pipe_for_channel[channel]; + CVMX_PREFETCH(pipe, 0); + CVMX_PREFETCH(pipe, 128); + if (!pipe) + return 0; + transaction = pipe->head; + CVMX_PREFETCH0(transaction); + + /* Disconnect this pipe from the HW channel. Later the schedule function will + figure out which pipe needs to go */ + usb->pipe_for_channel[channel] = NULL; + pipe->flags &= ~__CVMX_USB_PIPE_FLAGS_SCHEDULED; + + /* Read the channel config info so we can figure out how much data + transfered */ + usbc_hcchar.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCCHARX(channel, usb->index)); + usbc_hctsiz.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCTSIZX(channel, usb->index)); + + /* Calculating the number of bytes successfully transferred is dependent on + the transfer direction */ + packets_processed = transaction->pktcnt - usbc_hctsiz.s.pktcnt; + if (usbc_hcchar.s.epdir) { + /* IN transactions are easy. For every byte received the hardware + decrements xfersize. All we need to do is subtract the current + value of xfersize from its starting value and we know how many + bytes were written to the buffer */ + bytes_this_transfer = transaction->xfersize - usbc_hctsiz.s.xfersize; + } else { + /* OUT transaction don't decrement xfersize. Instead pktcnt is + decremented on every successful packet send. The hardware does + this when it receives an ACK, or NYET. If it doesn't + receive one of these responses pktcnt doesn't change */ + bytes_this_transfer = packets_processed * usbc_hcchar.s.mps; + /* The last packet may not be a full transfer if we didn't have + enough data */ + if (bytes_this_transfer > transaction->xfersize) + bytes_this_transfer = transaction->xfersize; + } + /* Figure out how many bytes were in the last packet of the transfer */ + if (packets_processed) + bytes_in_last_packet = bytes_this_transfer - (packets_processed-1) * usbc_hcchar.s.mps; + else + bytes_in_last_packet = bytes_this_transfer; + + /* As a special case, setup transactions output the setup header, not + the user's data. For this reason we don't count setup data as bytes + transferred */ + if ((transaction->stage == CVMX_USB_STAGE_SETUP) || + (transaction->stage == CVMX_USB_STAGE_SETUP_SPLIT_COMPLETE)) + bytes_this_transfer = 0; + + /* Add the bytes transferred to the running total. It is important that + bytes_this_transfer doesn't count any data that needs to be + retransmitted */ + transaction->actual_bytes += bytes_this_transfer; + if (transaction->type == CVMX_USB_TRANSFER_ISOCHRONOUS) + buffer_space_left = transaction->iso_packets[0].length - transaction->actual_bytes; + else + buffer_space_left = transaction->buffer_length - transaction->actual_bytes; + + /* We need to remember the PID toggle state for the next transaction. The + hardware already updated it for the next transaction */ + pipe->pid_toggle = !(usbc_hctsiz.s.pid == 0); + + /* For high speed bulk out, assume the next transaction will need to do a + ping before proceeding. If this isn't true the ACK processing below + will clear this flag */ + if ((pipe->device_speed == CVMX_USB_SPEED_HIGH) && + (pipe->transfer_type == CVMX_USB_TRANSFER_BULK) && + (pipe->transfer_dir == CVMX_USB_DIRECTION_OUT)) + pipe->flags |= __CVMX_USB_PIPE_FLAGS_NEED_PING; + + if (usbc_hcint.s.stall) { + /* STALL as a response means this transaction cannot be completed + because the device can't process transactions. Tell the user. Any + data that was transferred will be counted on the actual bytes + transferred */ + pipe->pid_toggle = 0; + __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_STALL); + } else if (usbc_hcint.s.xacterr) { + /* We know at least one packet worked if we get a ACK or NAK. Reset the retry counter */ + if (usbc_hcint.s.nak || usbc_hcint.s.ack) + transaction->retries = 0; + transaction->retries++; + if (transaction->retries > MAX_RETRIES) { + /* XactErr as a response means the device signaled something wrong with + the transfer. For example, PID toggle errors cause these */ + __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_XACTERR); + } else { + /* If this was a split then clear our split in progress marker */ + if (usb->active_split == transaction) + usb->active_split = NULL; + /* Rewind to the beginning of the transaction by anding off the + split complete bit */ + transaction->stage &= ~1; + pipe->split_sc_frame = -1; + pipe->next_tx_frame += pipe->interval; + if (pipe->next_tx_frame < usb->frame_number) + pipe->next_tx_frame = usb->frame_number + pipe->interval - + (usb->frame_number - pipe->next_tx_frame) % pipe->interval; + } + } else if (usbc_hcint.s.bblerr) { + /* Babble Error (BblErr) */ + __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_BABBLEERR); + } else if (usbc_hcint.s.datatglerr) { + /* We'll retry the exact same transaction again */ + transaction->retries++; + } else if (usbc_hcint.s.nyet) { + /* NYET as a response is only allowed in three cases: as a response to + a ping, as a response to a split transaction, and as a response to + a bulk out. The ping case is handled by hardware, so we only have + splits and bulk out */ + if (!__cvmx_usb_pipe_needs_split(usb, pipe)) { + transaction->retries = 0; + /* If there is more data to go then we need to try again. Otherwise + this transaction is complete */ + if ((buffer_space_left == 0) || (bytes_in_last_packet < pipe->max_packet)) + __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_SUCCESS); + } else { + /* Split transactions retry the split complete 4 times then rewind + to the start split and do the entire transactions again */ + transaction->retries++; + if ((transaction->retries & 0x3) == 0) { + /* Rewind to the beginning of the transaction by anding off the + split complete bit */ + transaction->stage &= ~1; + pipe->split_sc_frame = -1; + } + } + } else if (usbc_hcint.s.ack) { + transaction->retries = 0; + /* The ACK bit can only be checked after the other error bits. This is + because a multi packet transfer may succeed in a number of packets + and then get a different response on the last packet. In this case + both ACK and the last response bit will be set. If none of the + other response bits is set, then the last packet must have been an + ACK */ + + /* Since we got an ACK, we know we don't need to do a ping on this + pipe */ + pipe->flags &= ~__CVMX_USB_PIPE_FLAGS_NEED_PING; + + switch (transaction->type) { + case CVMX_USB_TRANSFER_CONTROL: + switch (transaction->stage) { + case CVMX_USB_STAGE_NON_CONTROL: + case CVMX_USB_STAGE_NON_CONTROL_SPLIT_COMPLETE: + /* This should be impossible */ + __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_ERROR); + break; + case CVMX_USB_STAGE_SETUP: + pipe->pid_toggle = 1; + if (__cvmx_usb_pipe_needs_split(usb, pipe)) + transaction->stage = CVMX_USB_STAGE_SETUP_SPLIT_COMPLETE; + else { + cvmx_usb_control_header_t *header = cvmx_phys_to_ptr(transaction->control_header); + if (header->s.length) + transaction->stage = CVMX_USB_STAGE_DATA; + else + transaction->stage = CVMX_USB_STAGE_STATUS; + } + break; + case CVMX_USB_STAGE_SETUP_SPLIT_COMPLETE: + { + cvmx_usb_control_header_t *header = cvmx_phys_to_ptr(transaction->control_header); + if (header->s.length) + transaction->stage = CVMX_USB_STAGE_DATA; + else + transaction->stage = CVMX_USB_STAGE_STATUS; + } + break; + case CVMX_USB_STAGE_DATA: + if (__cvmx_usb_pipe_needs_split(usb, pipe)) { + transaction->stage = CVMX_USB_STAGE_DATA_SPLIT_COMPLETE; + /* For setup OUT data that are splits, the hardware + doesn't appear to count transferred data. Here + we manually update the data transferred */ + if (!usbc_hcchar.s.epdir) { + if (buffer_space_left < pipe->max_packet) + transaction->actual_bytes += buffer_space_left; + else + transaction->actual_bytes += pipe->max_packet; + } + } else if ((buffer_space_left == 0) || (bytes_in_last_packet < pipe->max_packet)) { + pipe->pid_toggle = 1; + transaction->stage = CVMX_USB_STAGE_STATUS; + } + break; + case CVMX_USB_STAGE_DATA_SPLIT_COMPLETE: + if ((buffer_space_left == 0) || (bytes_in_last_packet < pipe->max_packet)) { + pipe->pid_toggle = 1; + transaction->stage = CVMX_USB_STAGE_STATUS; + } else { + transaction->stage = CVMX_USB_STAGE_DATA; + } + break; + case CVMX_USB_STAGE_STATUS: + if (__cvmx_usb_pipe_needs_split(usb, pipe)) + transaction->stage = CVMX_USB_STAGE_STATUS_SPLIT_COMPLETE; + else + __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_SUCCESS); + break; + case CVMX_USB_STAGE_STATUS_SPLIT_COMPLETE: + __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_SUCCESS); + break; + } + break; + case CVMX_USB_TRANSFER_BULK: + case CVMX_USB_TRANSFER_INTERRUPT: + /* The only time a bulk transfer isn't complete when + it finishes with an ACK is during a split transaction. For + splits we need to continue the transfer if more data is + needed */ + if (__cvmx_usb_pipe_needs_split(usb, pipe)) { + if (transaction->stage == CVMX_USB_STAGE_NON_CONTROL) + transaction->stage = CVMX_USB_STAGE_NON_CONTROL_SPLIT_COMPLETE; + else { + if (buffer_space_left && (bytes_in_last_packet == pipe->max_packet)) + transaction->stage = CVMX_USB_STAGE_NON_CONTROL; + else { + if (transaction->type == CVMX_USB_TRANSFER_INTERRUPT) + pipe->next_tx_frame += pipe->interval; + __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_SUCCESS); + } + } + } else { + if ((pipe->device_speed == CVMX_USB_SPEED_HIGH) && + (pipe->transfer_type == CVMX_USB_TRANSFER_BULK) && + (pipe->transfer_dir == CVMX_USB_DIRECTION_OUT) && + (usbc_hcint.s.nak)) + pipe->flags |= __CVMX_USB_PIPE_FLAGS_NEED_PING; + if (!buffer_space_left || (bytes_in_last_packet < pipe->max_packet)) { + if (transaction->type == CVMX_USB_TRANSFER_INTERRUPT) + pipe->next_tx_frame += pipe->interval; + __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_SUCCESS); + } + } + break; + case CVMX_USB_TRANSFER_ISOCHRONOUS: + if (__cvmx_usb_pipe_needs_split(usb, pipe)) { + /* ISOCHRONOUS OUT splits don't require a complete split stage. + Instead they use a sequence of begin OUT splits to transfer + the data 188 bytes at a time. Once the transfer is complete, + the pipe sleeps until the next schedule interval */ + if (pipe->transfer_dir == CVMX_USB_DIRECTION_OUT) { + /* If no space left or this wasn't a max size packet then + this transfer is complete. Otherwise start it again + to send the next 188 bytes */ + if (!buffer_space_left || (bytes_this_transfer < 188)) { + pipe->next_tx_frame += pipe->interval; + __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_SUCCESS); + } + } else { + if (transaction->stage == CVMX_USB_STAGE_NON_CONTROL_SPLIT_COMPLETE) { + /* We are in the incoming data phase. Keep getting + data until we run out of space or get a small + packet */ + if ((buffer_space_left == 0) || (bytes_in_last_packet < pipe->max_packet)) { + pipe->next_tx_frame += pipe->interval; + __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_SUCCESS); + } + } else + transaction->stage = CVMX_USB_STAGE_NON_CONTROL_SPLIT_COMPLETE; + } + } else { + pipe->next_tx_frame += pipe->interval; + __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_SUCCESS); + } + break; + } + } else if (usbc_hcint.s.nak) { + /* If this was a split then clear our split in progress marker */ + if (usb->active_split == transaction) + usb->active_split = NULL; + /* NAK as a response means the device couldn't accept the transaction, + but it should be retried in the future. Rewind to the beginning of + the transaction by anding off the split complete bit. Retry in the + next interval */ + transaction->retries = 0; + transaction->stage &= ~1; + pipe->next_tx_frame += pipe->interval; + if (pipe->next_tx_frame < usb->frame_number) + pipe->next_tx_frame = usb->frame_number + pipe->interval - + (usb->frame_number - pipe->next_tx_frame) % pipe->interval; + } else { + cvmx_usb_port_status_t port; + port = cvmx_usb_get_status((cvmx_usb_state_t *)usb); + if (port.port_enabled) { + /* We'll retry the exact same transaction again */ + transaction->retries++; + } else { + /* We get channel halted interrupts with no result bits sets when the + cable is unplugged */ + __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_ERROR); + } + } + return 0; } @@ -2850,93 +2812,93 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel) * handler for the USB controller. It can also be called * periodically in a loop for non-interrupt based operation. * - * @param state USB device state populated by - * cvmx_usb_initialize(). + * @param state USB device state populated by + * cvmx_usb_initialize(). * * @return 0 or a negative error code. */ int cvmx_usb_poll(cvmx_usb_state_t *state) { - cvmx_usbcx_hfnum_t usbc_hfnum; - cvmx_usbcx_gintsts_t usbc_gintsts; - cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t*)state; - - CVMX_PREFETCH(usb, 0); - CVMX_PREFETCH(usb, 1*128); - CVMX_PREFETCH(usb, 2*128); - CVMX_PREFETCH(usb, 3*128); - CVMX_PREFETCH(usb, 4*128); - - /* Update the frame counter */ - usbc_hfnum.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HFNUM(usb->index)); - if ((usb->frame_number&0x3fff) > usbc_hfnum.s.frnum) - usb->frame_number += 0x4000; - usb->frame_number &= ~0x3fffull; - usb->frame_number |= usbc_hfnum.s.frnum; - - /* Read the pending interrupts */ - usbc_gintsts.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_GINTSTS(usb->index)); - - /* Clear the interrupts now that we know about them */ - __cvmx_usb_write_csr32(usb, CVMX_USBCX_GINTSTS(usb->index), usbc_gintsts.u32); - - if (usbc_gintsts.s.rxflvl) { - /* RxFIFO Non-Empty (RxFLvl) - Indicates that there is at least one packet pending to be read - from the RxFIFO. */ - /* In DMA mode this is handled by hardware */ - if (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA) - __cvmx_usb_poll_rx_fifo(usb); - } - if (usbc_gintsts.s.ptxfemp || usbc_gintsts.s.nptxfemp) { - /* Fill the Tx FIFOs when not in DMA mode */ - if (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA) - __cvmx_usb_poll_tx_fifo(usb); - } - if (usbc_gintsts.s.disconnint || usbc_gintsts.s.prtint) { - cvmx_usbcx_hprt_t usbc_hprt; - /* Disconnect Detected Interrupt (DisconnInt) - Asserted when a device disconnect is detected. */ - - /* Host Port Interrupt (PrtInt) - The core sets this bit to indicate a change in port status of one - of the O2P USB core ports in Host mode. The application must - read the Host Port Control and Status (HPRT) register to - determine the exact event that caused this interrupt. The - application must clear the appropriate status bit in the Host Port - Control and Status register to clear this bit. */ - - /* Call the user's port callback */ - __cvmx_usb_perform_callback(usb, NULL, NULL, - CVMX_USB_CALLBACK_PORT_CHANGED, - CVMX_USB_COMPLETE_SUCCESS); - /* Clear the port change bits */ - usbc_hprt.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HPRT(usb->index)); - usbc_hprt.s.prtena = 0; - __cvmx_usb_write_csr32(usb, CVMX_USBCX_HPRT(usb->index), usbc_hprt.u32); - } - if (usbc_gintsts.s.hchint) { - /* Host Channels Interrupt (HChInt) - The core sets this bit to indicate that an interrupt is pending on - one of the channels of the core (in Host mode). The application - must read the Host All Channels Interrupt (HAINT) register to - determine the exact number of the channel on which the - interrupt occurred, and then read the corresponding Host - Channel-n Interrupt (HCINTn) register to determine the exact - cause of the interrupt. The application must clear the - appropriate status bit in the HCINTn register to clear this bit. */ - cvmx_usbcx_haint_t usbc_haint; - usbc_haint.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HAINT(usb->index)); - while (usbc_haint.u32) { - int channel; - CVMX_CLZ(channel, usbc_haint.u32); - channel = 31 - channel; - __cvmx_usb_poll_channel(usb, channel); - usbc_haint.u32 ^= 1<index)); + if ((usb->frame_number&0x3fff) > usbc_hfnum.s.frnum) + usb->frame_number += 0x4000; + usb->frame_number &= ~0x3fffull; + usb->frame_number |= usbc_hfnum.s.frnum; + + /* Read the pending interrupts */ + usbc_gintsts.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_GINTSTS(usb->index)); + + /* Clear the interrupts now that we know about them */ + __cvmx_usb_write_csr32(usb, CVMX_USBCX_GINTSTS(usb->index), usbc_gintsts.u32); + + if (usbc_gintsts.s.rxflvl) { + /* RxFIFO Non-Empty (RxFLvl) + Indicates that there is at least one packet pending to be read + from the RxFIFO. */ + /* In DMA mode this is handled by hardware */ + if (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA) + __cvmx_usb_poll_rx_fifo(usb); + } + if (usbc_gintsts.s.ptxfemp || usbc_gintsts.s.nptxfemp) { + /* Fill the Tx FIFOs when not in DMA mode */ + if (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA) + __cvmx_usb_poll_tx_fifo(usb); + } + if (usbc_gintsts.s.disconnint || usbc_gintsts.s.prtint) { + cvmx_usbcx_hprt_t usbc_hprt; + /* Disconnect Detected Interrupt (DisconnInt) + Asserted when a device disconnect is detected. */ + + /* Host Port Interrupt (PrtInt) + The core sets this bit to indicate a change in port status of one + of the O2P USB core ports in Host mode. The application must + read the Host Port Control and Status (HPRT) register to + determine the exact event that caused this interrupt. The + application must clear the appropriate status bit in the Host Port + Control and Status register to clear this bit. */ + + /* Call the user's port callback */ + __cvmx_usb_perform_callback(usb, NULL, NULL, + CVMX_USB_CALLBACK_PORT_CHANGED, + CVMX_USB_COMPLETE_SUCCESS); + /* Clear the port change bits */ + usbc_hprt.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HPRT(usb->index)); + usbc_hprt.s.prtena = 0; + __cvmx_usb_write_csr32(usb, CVMX_USBCX_HPRT(usb->index), usbc_hprt.u32); + } + if (usbc_gintsts.s.hchint) { + /* Host Channels Interrupt (HChInt) + The core sets this bit to indicate that an interrupt is pending on + one of the channels of the core (in Host mode). The application + must read the Host All Channels Interrupt (HAINT) register to + determine the exact number of the channel on which the + interrupt occurred, and then read the corresponding Host + Channel-n Interrupt (HCINTn) register to determine the exact + cause of the interrupt. The application must clear the + appropriate status bit in the HCINTn register to clear this bit. */ + cvmx_usbcx_haint_t usbc_haint; + usbc_haint.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HAINT(usb->index)); + while (usbc_haint.u32) { + int channel; + CVMX_CLZ(channel, usbc_haint.u32); + channel = 31 - channel; + __cvmx_usb_poll_channel(usb, channel); + usbc_haint.u32 ^= 1< Date: Mon, 29 Jul 2013 20:07:54 +0300 Subject: [PATCH 342/942] staging: octeon-usb: cvmx-usb: reformat long comments Reformat long comments according to multi-line comment style. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/cvmx-usb.c | 717 +++++++++++++++++--------- 1 file changed, 462 insertions(+), 255 deletions(-) diff --git a/drivers/staging/octeon-usb/cvmx-usb.c b/drivers/staging/octeon-usb/cvmx-usb.c index e8fad48b1bb50..025671a2d5b18 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.c +++ b/drivers/staging/octeon-usb/cvmx-usb.c @@ -78,9 +78,11 @@ #define MAX_TRANSFER_BYTES ((1<<19)-1) /* The low level hardware can transfer a maximum of this number of bytes in each transfer. The field is 19 bits wide */ #define MAX_TRANSFER_PACKETS ((1<<10)-1) /* The low level hardware can transfer a maximum of this number of packets in each transfer. The field is 10 bits wide */ -/* These defines disable the normal read and write csr. This is so I can add - extra debug stuff to the usb specific version and I won't use the normal - version by mistake */ +/* + * These defines disable the normal read and write csr. This is so I can add + * extra debug stuff to the usb specific version and I won't use the normal + * version by mistake + */ #define cvmx_read_csr use_cvmx_usb_read_csr64_instead_of_cvmx_read_csr #define cvmx_write_csr use_cvmx_usb_write_csr64_instead_of_cvmx_write_csr @@ -227,8 +229,10 @@ typedef struct { } while (0); \ result; }) -/* This macro logically sets a single field in a CSR. It does the sequence - read, modify, and write */ +/* + * This macro logically sets a single field in a CSR. It does the sequence + * read, modify, and write + */ #define USB_SET_FIELD32(address, type, field, value) \ do { \ type c; \ @@ -562,23 +566,30 @@ int cvmx_usb_initialize(cvmx_usb_state_t *state, int usb_port_number, __cvmx_usb_append_pipe(&usb->free_pipes, usb->pipe + i); } - /* Power On Reset and PHY Initialization */ - - /* 1. Wait for DCOK to assert (nothing to do) */ - /* 2a. Write USBN0/1_CLK_CTL[POR] = 1 and - USBN0/1_CLK_CTL[HRST,PRST,HCLK_RST] = 0 */ + /* + * Power On Reset and PHY Initialization + * + * 1. Wait for DCOK to assert (nothing to do) + * + * 2a. Write USBN0/1_CLK_CTL[POR] = 1 and + * USBN0/1_CLK_CTL[HRST,PRST,HCLK_RST] = 0 + */ usbn_clk_ctl.u64 = __cvmx_usb_read_csr64(usb, CVMX_USBNX_CLK_CTL(usb->index)); usbn_clk_ctl.s.por = 1; usbn_clk_ctl.s.hrst = 0; usbn_clk_ctl.s.prst = 0; usbn_clk_ctl.s.hclk_rst = 0; usbn_clk_ctl.s.enable = 0; - /* 2b. Select the USB reference clock/crystal parameters by writing - appropriate values to USBN0/1_CLK_CTL[P_C_SEL, P_RTYPE, P_COM_ON] */ + /* + * 2b. Select the USB reference clock/crystal parameters by writing + * appropriate values to USBN0/1_CLK_CTL[P_C_SEL, P_RTYPE, P_COM_ON] + */ if (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_CLOCK_XO_GND) { - /* The USB port uses 12/24/48MHz 2.5V board clock - source at USB_XO. USB_XI should be tied to GND. - Most Octeon evaluation boards require this setting */ + /* + * The USB port uses 12/24/48MHz 2.5V board clock + * source at USB_XO. USB_XI should be tied to GND. + * Most Octeon evaluation boards require this setting + */ if (OCTEON_IS_MODEL(OCTEON_CN3XXX)) { usbn_clk_ctl.cn31xx.p_rclk = 1; /* From CN31XX,CN30XX manual */ usbn_clk_ctl.cn31xx.p_xenbn = 0; @@ -599,8 +610,10 @@ int cvmx_usb_initialize(cvmx_usb_state_t *state, int usb_port_number, break; } } else { - /* The USB port uses a 12MHz crystal as clock source - at USB_XO and USB_XI */ + /* + * The USB port uses a 12MHz crystal as clock source + * at USB_XO and USB_XI + */ if (OCTEON_IS_MODEL(OCTEON_CN3XXX)) { usbn_clk_ctl.cn31xx.p_rclk = 1; /* From CN31XX,CN30XX manual */ usbn_clk_ctl.cn31xx.p_xenbn = 1; @@ -611,9 +624,11 @@ int cvmx_usb_initialize(cvmx_usb_state_t *state, int usb_port_number, usbn_clk_ctl.s.p_c_sel = 0; } - /* 2c. Select the HCLK via writing USBN0/1_CLK_CTL[DIVIDE, DIVIDE2] and - setting USBN0/1_CLK_CTL[ENABLE] = 1. Divide the core clock down such - that USB is as close as possible to 125Mhz */ + /* + * 2c. Select the HCLK via writing USBN0/1_CLK_CTL[DIVIDE, DIVIDE2] and + * setting USBN0/1_CLK_CTL[ENABLE] = 1. Divide the core clock down + * such that USB is as close as possible to 125Mhz + */ { int divisor = (octeon_get_clock_rate()+125000000-1)/125000000; if (divisor < 4) /* Lower than 4 doesn't seem to work properly */ @@ -629,41 +644,55 @@ int cvmx_usb_initialize(cvmx_usb_state_t *state, int usb_port_number, usbn_clk_ctl.u64); /* 2e. Wait 64 core-clock cycles for HCLK to stabilize */ cvmx_wait(64); - /* 3. Program the power-on reset field in the USBN clock-control register: - USBN_CLK_CTL[POR] = 0 */ + /* + * 3. Program the power-on reset field in the USBN clock-control + * register: + * USBN_CLK_CTL[POR] = 0 + */ usbn_clk_ctl.s.por = 0; __cvmx_usb_write_csr64(usb, CVMX_USBNX_CLK_CTL(usb->index), usbn_clk_ctl.u64); /* 4. Wait 1 ms for PHY clock to start */ mdelay(1); - /* 5. Program the Reset input from automatic test equipment field in the - USBP control and status register: USBN_USBP_CTL_STATUS[ATE_RESET] = 1 */ + /* + * 5. Program the Reset input from automatic test equipment field in the + * USBP control and status register: + * USBN_USBP_CTL_STATUS[ATE_RESET] = 1 + */ usbn_usbp_ctl_status.u64 = __cvmx_usb_read_csr64(usb, CVMX_USBNX_USBP_CTL_STATUS(usb->index)); usbn_usbp_ctl_status.s.ate_reset = 1; __cvmx_usb_write_csr64(usb, CVMX_USBNX_USBP_CTL_STATUS(usb->index), usbn_usbp_ctl_status.u64); /* 6. Wait 10 cycles */ cvmx_wait(10); - /* 7. Clear ATE_RESET field in the USBN clock-control register: - USBN_USBP_CTL_STATUS[ATE_RESET] = 0 */ + /* + * 7. Clear ATE_RESET field in the USBN clock-control register: + * USBN_USBP_CTL_STATUS[ATE_RESET] = 0 + */ usbn_usbp_ctl_status.s.ate_reset = 0; __cvmx_usb_write_csr64(usb, CVMX_USBNX_USBP_CTL_STATUS(usb->index), usbn_usbp_ctl_status.u64); - /* 8. Program the PHY reset field in the USBN clock-control register: - USBN_CLK_CTL[PRST] = 1 */ + /* + * 8. Program the PHY reset field in the USBN clock-control register: + * USBN_CLK_CTL[PRST] = 1 + */ usbn_clk_ctl.s.prst = 1; __cvmx_usb_write_csr64(usb, CVMX_USBNX_CLK_CTL(usb->index), usbn_clk_ctl.u64); - /* 9. Program the USBP control and status register to select host or - device mode. USBN_USBP_CTL_STATUS[HST_MODE] = 0 for host, = 1 for - device */ + /* + * 9. Program the USBP control and status register to select host or + * device mode. USBN_USBP_CTL_STATUS[HST_MODE] = 0 for host, = 1 for + * device + */ usbn_usbp_ctl_status.s.hst_mode = 0; __cvmx_usb_write_csr64(usb, CVMX_USBNX_USBP_CTL_STATUS(usb->index), usbn_usbp_ctl_status.u64); /* 10. Wait 1 us */ udelay(1); - /* 11. Program the hreset_n field in the USBN clock-control register: - USBN_CLK_CTL[HRST] = 1 */ + /* + * 11. Program the hreset_n field in the USBN clock-control register: + * USBN_CLK_CTL[HRST] = 1 + */ usbn_clk_ctl.s.hrst = 1; __cvmx_usb_write_csr64(usb, CVMX_USBNX_CLK_CTL(usb->index), usbn_clk_ctl.u64); @@ -673,20 +702,24 @@ int cvmx_usb_initialize(cvmx_usb_state_t *state, int usb_port_number, usbn_clk_ctl.u64); udelay(1); - /* USB Core Initialization */ - - /* 1. Read USBC_GHWCFG1, USBC_GHWCFG2, USBC_GHWCFG3, USBC_GHWCFG4 to - determine USB core configuration parameters. */ - /* Nothing needed */ - /* 2. Program the following fields in the global AHB configuration - register (USBC_GAHBCFG) - DMA mode, USBC_GAHBCFG[DMAEn]: 1 = DMA mode, 0 = slave mode - Burst length, USBC_GAHBCFG[HBSTLEN] = 0 - Nonperiodic TxFIFO empty level (slave mode only), - USBC_GAHBCFG[NPTXFEMPLVL] - Periodic TxFIFO empty level (slave mode only), - USBC_GAHBCFG[PTXFEMPLVL] - Global interrupt mask, USBC_GAHBCFG[GLBLINTRMSK] = 1 */ + /* + * USB Core Initialization + * + * 1. Read USBC_GHWCFG1, USBC_GHWCFG2, USBC_GHWCFG3, USBC_GHWCFG4 to + * determine USB core configuration parameters. + * + * Nothing needed + * + * 2. Program the following fields in the global AHB configuration + * register (USBC_GAHBCFG) + * DMA mode, USBC_GAHBCFG[DMAEn]: 1 = DMA mode, 0 = slave mode + * Burst length, USBC_GAHBCFG[HBSTLEN] = 0 + * Nonperiodic TxFIFO empty level (slave mode only), + * USBC_GAHBCFG[NPTXFEMPLVL] + * Periodic TxFIFO empty level (slave mode only), + * USBC_GAHBCFG[PTXFEMPLVL] + * Global interrupt mask, USBC_GAHBCFG[GLBLINTRMSK] = 1 + */ { cvmx_usbcx_gahbcfg_t usbcx_gahbcfg; /* Due to an errata, CN31XX doesn't support DMA */ @@ -707,11 +740,13 @@ int cvmx_usb_initialize(cvmx_usb_state_t *state, int usb_port_number, __cvmx_usb_write_csr32(usb, CVMX_USBCX_GAHBCFG(usb->index), usbcx_gahbcfg.u32); } - /* 3. Program the following fields in USBC_GUSBCFG register. - HS/FS timeout calibration, USBC_GUSBCFG[TOUTCAL] = 0 - ULPI DDR select, USBC_GUSBCFG[DDRSEL] = 0 - USB turnaround time, USBC_GUSBCFG[USBTRDTIM] = 0x5 - PHY low-power clock select, USBC_GUSBCFG[PHYLPWRCLKSEL] = 0 */ + /* + * 3. Program the following fields in USBC_GUSBCFG register. + * HS/FS timeout calibration, USBC_GUSBCFG[TOUTCAL] = 0 + * ULPI DDR select, USBC_GUSBCFG[DDRSEL] = 0 + * USB turnaround time, USBC_GUSBCFG[USBTRDTIM] = 0x5 + * PHY low-power clock select, USBC_GUSBCFG[PHYLPWRCLKSEL] = 0 + */ { cvmx_usbcx_gusbcfg_t usbcx_gusbcfg; usbcx_gusbcfg.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_GUSBCFG(usb->index)); @@ -722,10 +757,12 @@ int cvmx_usb_initialize(cvmx_usb_state_t *state, int usb_port_number, __cvmx_usb_write_csr32(usb, CVMX_USBCX_GUSBCFG(usb->index), usbcx_gusbcfg.u32); } - /* 4. The software must unmask the following bits in the USBC_GINTMSK - register. - OTG interrupt mask, USBC_GINTMSK[OTGINTMSK] = 1 - Mode mismatch interrupt mask, USBC_GINTMSK[MODEMISMSK] = 1 */ + /* + * 4. The software must unmask the following bits in the USBC_GINTMSK + * register. + * OTG interrupt mask, USBC_GINTMSK[OTGINTMSK] = 1 + * Mode mismatch interrupt mask, USBC_GINTMSK[MODEMISMSK] = 1 + */ { cvmx_usbcx_gintmsk_t usbcx_gintmsk; int channel; @@ -747,16 +784,20 @@ int cvmx_usb_initialize(cvmx_usb_state_t *state, int usb_port_number, } { - /* Host Port Initialization */ - - /* 1. Program the host-port interrupt-mask field to unmask, - USBC_GINTMSK[PRTINT] = 1 */ + /* + * Host Port Initialization + * + * 1. Program the host-port interrupt-mask field to unmask, + * USBC_GINTMSK[PRTINT] = 1 + */ USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), cvmx_usbcx_gintmsk_t, prtintmsk, 1); USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), cvmx_usbcx_gintmsk_t, disconnintmsk, 1); - /* 2. Program the USBC_HCFG register to select full-speed host or - high-speed host. */ + /* + * 2. Program the USBC_HCFG register to select full-speed host + * or high-speed host. + */ { cvmx_usbcx_hcfg_t usbcx_hcfg; usbcx_hcfg.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCFG(usb->index)); @@ -764,11 +805,15 @@ int cvmx_usb_initialize(cvmx_usb_state_t *state, int usb_port_number, usbcx_hcfg.s.fslspclksel = 0; __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCFG(usb->index), usbcx_hcfg.u32); } - /* 3. Program the port power bit to drive VBUS on the USB, - USBC_HPRT[PRTPWR] = 1 */ + /* + * 3. Program the port power bit to drive VBUS on the USB, + * USBC_HPRT[PRTPWR] = 1 + */ USB_SET_FIELD32(CVMX_USBCX_HPRT(usb->index), cvmx_usbcx_hprt_t, prtpwr, 1); - /* Steps 4-15 from the manual are done later in the port enable */ + /* + * Steps 4-15 from the manual are done later in the port enable + */ } return 0; @@ -827,8 +872,10 @@ int cvmx_usb_enable(cvmx_usb_state_t *state) usb->usbcx_hprt.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HPRT(usb->index)); - /* If the port is already enabled the just return. We don't need to do - anything */ + /* + * If the port is already enabled the just return. We don't need to do + * anything + */ if (usb->usbcx_hprt.s.prtena) return 0; @@ -840,8 +887,10 @@ int cvmx_usb_enable(cvmx_usb_state_t *state) /* Program the port reset bit to start the reset process */ USB_SET_FIELD32(CVMX_USBCX_HPRT(usb->index), cvmx_usbcx_hprt_t, prtrst, 1); - /* Wait at least 50ms (high speed), or 10ms (full speed) for the reset - process to complete. */ + /* + * Wait at least 50ms (high speed), or 10ms (full speed) for the reset + * process to complete. + */ mdelay(50); /* Program the port reset bit to 0, USBC_HPRT[PRTRST] = 0 */ @@ -856,13 +905,17 @@ int cvmx_usb_enable(cvmx_usb_state_t *state) usb->usbcx_hprt.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HPRT(usb->index)); usbcx_ghwcfg3.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_GHWCFG3(usb->index)); - /* 13. Program the USBC_GRXFSIZ register to select the size of the receive - FIFO (25%). */ + /* + * 13. Program the USBC_GRXFSIZ register to select the size of the + * receive FIFO (25%). + */ USB_SET_FIELD32(CVMX_USBCX_GRXFSIZ(usb->index), cvmx_usbcx_grxfsiz_t, rxfdep, usbcx_ghwcfg3.s.dfifodepth / 4); - /* 14. Program the USBC_GNPTXFSIZ register to select the size and the - start address of the non- periodic transmit FIFO for nonperiodic - transactions (50%). */ + /* + * 14. Program the USBC_GNPTXFSIZ register to select the size and the + * start address of the non- periodic transmit FIFO for nonperiodic + * transactions (50%). + */ { cvmx_usbcx_gnptxfsiz_t siz; siz.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_GNPTXFSIZ(usb->index)); @@ -870,8 +923,11 @@ int cvmx_usb_enable(cvmx_usb_state_t *state) siz.s.nptxfstaddr = usbcx_ghwcfg3.s.dfifodepth / 4; __cvmx_usb_write_csr32(usb, CVMX_USBCX_GNPTXFSIZ(usb->index), siz.u32); } - /* 15. Program the USBC_HPTXFSIZ register to select the size and start - address of the periodic transmit FIFO for periodic transactions (25%). */ + /* + * 15. Program the USBC_HPTXFSIZ register to select the size and start + * address of the periodic transmit FIFO for periodic transactions + * (25%). + */ { cvmx_usbcx_hptxfsiz_t siz; siz.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HPTXFSIZ(usb->index)); @@ -1112,8 +1168,10 @@ int cvmx_usb_open_pipe(cvmx_usb_state_t *state, cvmx_usb_pipe_flags_t flags, pipe->max_packet = max_packet; pipe->transfer_type = transfer_type; pipe->transfer_dir = transfer_dir; - /* All pipes use interval to rate limit NAK processing. Force an interval - if one wasn't supplied */ + /* + * All pipes use interval to rate limit NAK processing. Force an + * interval if one wasn't supplied + */ if (!interval) interval = 1; if (__cvmx_usb_pipe_needs_split(usb, pipe)) { @@ -1131,8 +1189,10 @@ int cvmx_usb_open_pipe(cvmx_usb_state_t *state, cvmx_usb_pipe_flags_t flags, pipe->split_sc_frame = -1; __cvmx_usb_append_pipe(&usb->idle_pipes, pipe); - /* We don't need to tell the hardware about this pipe yet since - it doesn't have any submitted requests */ + /* + * We don't need to tell the hardware about this pipe yet since + * it doesn't have any submitted requests + */ return __cvmx_usb_get_pipe_handle(usb, pipe); } @@ -1198,8 +1258,10 @@ static void __cvmx_usb_poll_rx_fifo(cvmx_usb_internal_state_t *usb) */ static int __cvmx_usb_fill_tx_hw(cvmx_usb_internal_state_t *usb, cvmx_usb_tx_fifo_t *fifo, int available) { - /* We're done either when there isn't anymore space or the software FIFO - is empty */ + /* + * We're done either when there isn't anymore space or the software FIFO + * is empty + */ while (available && (fifo->head != fifo->tail)) { int i = fifo->tail; const uint32_t *ptr = cvmx_phys_to_ptr(fifo->entry[i].address); @@ -1219,8 +1281,10 @@ static int __cvmx_usb_fill_tx_hw(cvmx_usb_internal_state_t *usb, cvmx_usb_tx_fif fifo->entry[i].address += words * 4; fifo->entry[i].size -= words; - /* Write the HW fifo data. The read every three writes is due - to an errata on CN3XXX chips */ + /* + * Write the HW fifo data. The read every three writes is due + * to an errata on CN3XXX chips + */ while (words > 3) { cvmx_write64_uint32(csr_address, *ptr++); cvmx_write64_uint32(csr_address, *ptr++); @@ -1351,8 +1415,10 @@ static void __cvmx_usb_start_channel_control(cvmx_usb_internal_state_t *usb, bytes_to_transfer = sizeof(*header); /* All Control operations start with a setup going OUT */ USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index), cvmx_usbcx_hccharx_t, epdir, CVMX_USB_DIRECTION_OUT); - /* Setup send the control header instead of the buffer data. The - buffer data will be used in the next stage */ + /* + * Setup send the control header instead of the buffer data. The + * buffer data will be used in the next stage + */ __cvmx_usb_write_csr64(usb, CVMX_USBNX_DMA0_OUTB_CHN0(usb->index) + channel*8, transaction->control_header); break; case CVMX_USB_STAGE_SETUP_SPLIT_COMPLETE: @@ -1406,28 +1472,36 @@ static void __cvmx_usb_start_channel_control(cvmx_usb_internal_state_t *usb, break; } - /* Make sure the transfer never exceeds the byte limit of the hardware. - Further bytes will be sent as continued transactions */ + /* + * Make sure the transfer never exceeds the byte limit of the hardware. + * Further bytes will be sent as continued transactions + */ if (bytes_to_transfer > MAX_TRANSFER_BYTES) { /* Round MAX_TRANSFER_BYTES to a multiple of out packet size */ bytes_to_transfer = MAX_TRANSFER_BYTES / pipe->max_packet; bytes_to_transfer *= pipe->max_packet; } - /* Calculate the number of packets to transfer. If the length is zero - we still need to transfer one packet */ + /* + * Calculate the number of packets to transfer. If the length is zero + * we still need to transfer one packet + */ packets_to_transfer = (bytes_to_transfer + pipe->max_packet - 1) / pipe->max_packet; if (packets_to_transfer == 0) packets_to_transfer = 1; else if ((packets_to_transfer > 1) && (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA)) { - /* Limit to one packet when not using DMA. Channels must be restarted - between every packet for IN transactions, so there is no reason to - do multiple packets in a row */ + /* + * Limit to one packet when not using DMA. Channels must be + * restarted between every packet for IN transactions, so there + * is no reason to do multiple packets in a row + */ packets_to_transfer = 1; bytes_to_transfer = packets_to_transfer * pipe->max_packet; } else if (packets_to_transfer > MAX_TRANSFER_PACKETS) { - /* Limit the number of packet and data transferred to what the - hardware can handle */ + /* + * Limit the number of packet and data transferred to what the + * hardware can handle + */ packets_to_transfer = MAX_TRANSFER_PACKETS; bytes_to_transfer = packets_to_transfer * pipe->max_packet; } @@ -1517,17 +1591,24 @@ static void __cvmx_usb_start_channel(cvmx_usb_internal_state_t *usb, int packets_to_transfer; int bytes_to_transfer = transaction->buffer_length - transaction->actual_bytes; - /* ISOCHRONOUS transactions store each individual transfer size in the - packet structure, not the global buffer_length */ + /* + * ISOCHRONOUS transactions store each individual transfer size + * in the packet structure, not the global buffer_length + */ if (transaction->type == CVMX_USB_TRANSFER_ISOCHRONOUS) bytes_to_transfer = transaction->iso_packets[0].length - transaction->actual_bytes; - /* We need to do split transactions when we are talking to non high - speed devices that are behind a high speed hub */ + /* + * We need to do split transactions when we are talking to non + * high speed devices that are behind a high speed hub + */ if (__cvmx_usb_pipe_needs_split(usb, pipe)) { - /* On the start split phase (stage is even) record the frame number we - will need to send the split complete. We only store the lower two bits - since the time ahead can only be two frames */ + /* + * On the start split phase (stage is even) record the + * frame number we will need to send the split complete. + * We only store the lower two bits since the time ahead + * can only be two frames + */ if ((transaction->stage&1) == 0) { if (transaction->type == CVMX_USB_TRANSFER_BULK) pipe->split_sc_frame = (usb->frame_number + 1) & 0x7f; @@ -1541,64 +1622,94 @@ static void __cvmx_usb_start_channel(cvmx_usb_internal_state_t *usb, usbc_hcsplt.s.prtaddr = pipe->hub_port; usbc_hcsplt.s.compsplt = (transaction->stage == CVMX_USB_STAGE_NON_CONTROL_SPLIT_COMPLETE); - /* SPLIT transactions can only ever transmit one data packet so - limit the transfer size to the max packet size */ + /* + * SPLIT transactions can only ever transmit one data + * packet so limit the transfer size to the max packet + * size + */ if (bytes_to_transfer > pipe->max_packet) bytes_to_transfer = pipe->max_packet; - /* ISOCHRONOUS OUT splits are unique in that they limit - data transfers to 188 byte chunks representing the - begin/middle/end of the data or all */ + /* + * ISOCHRONOUS OUT splits are unique in that they limit + * data transfers to 188 byte chunks representing the + * begin/middle/end of the data or all + */ if (!usbc_hcsplt.s.compsplt && (pipe->transfer_dir == CVMX_USB_DIRECTION_OUT) && (pipe->transfer_type == CVMX_USB_TRANSFER_ISOCHRONOUS)) { - /* Clear the split complete frame number as there isn't going - to be a split complete */ + /* + * Clear the split complete frame number as + * there isn't going to be a split complete + */ pipe->split_sc_frame = -1; - /* See if we've started this transfer and sent data */ + /* + * See if we've started this transfer and sent + * data + */ if (transaction->actual_bytes == 0) { - /* Nothing sent yet, this is either a begin or the - entire payload */ + /* + * Nothing sent yet, this is either a + * begin or the entire payload + */ if (bytes_to_transfer <= 188) usbc_hcsplt.s.xactpos = 3; /* Entire payload in one go */ else usbc_hcsplt.s.xactpos = 2; /* First part of payload */ } else { - /* Continuing the previous data, we must either be - in the middle or at the end */ + /* + * Continuing the previous data, we must + * either be in the middle or at the end + */ if (bytes_to_transfer <= 188) usbc_hcsplt.s.xactpos = 1; /* End of payload */ else usbc_hcsplt.s.xactpos = 0; /* Middle of payload */ } - /* Again, the transfer size is limited to 188 bytes */ + /* + * Again, the transfer size is limited to 188 + * bytes + */ if (bytes_to_transfer > 188) bytes_to_transfer = 188; } } - /* Make sure the transfer never exceeds the byte limit of the hardware. - Further bytes will be sent as continued transactions */ + /* + * Make sure the transfer never exceeds the byte limit of the + * hardware. Further bytes will be sent as continued + * transactions + */ if (bytes_to_transfer > MAX_TRANSFER_BYTES) { - /* Round MAX_TRANSFER_BYTES to a multiple of out packet size */ + /* + * Round MAX_TRANSFER_BYTES to a multiple of out packet + * size + */ bytes_to_transfer = MAX_TRANSFER_BYTES / pipe->max_packet; bytes_to_transfer *= pipe->max_packet; } - /* Calculate the number of packets to transfer. If the length is zero - we still need to transfer one packet */ + /* + * Calculate the number of packets to transfer. If the length is + * zero we still need to transfer one packet + */ packets_to_transfer = (bytes_to_transfer + pipe->max_packet - 1) / pipe->max_packet; if (packets_to_transfer == 0) packets_to_transfer = 1; else if ((packets_to_transfer > 1) && (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA)) { - /* Limit to one packet when not using DMA. Channels must be restarted - between every packet for IN transactions, so there is no reason to - do multiple packets in a row */ + /* + * Limit to one packet when not using DMA. Channels must + * be restarted between every packet for IN + * transactions, so there is no reason to do multiple + * packets in a row + */ packets_to_transfer = 1; bytes_to_transfer = packets_to_transfer * pipe->max_packet; } else if (packets_to_transfer > MAX_TRANSFER_PACKETS) { - /* Limit the number of packet and data transferred to what the - hardware can handle */ + /* + * Limit the number of packet and data transferred to + * what the hardware can handle + */ packets_to_transfer = MAX_TRANSFER_PACKETS; bytes_to_transfer = packets_to_transfer * pipe->max_packet; } @@ -1608,7 +1719,9 @@ static void __cvmx_usb_start_channel(cvmx_usb_internal_state_t *usb, /* Update the DATA0/DATA1 toggle */ usbc_hctsiz.s.pid = __cvmx_usb_get_data_pid(pipe); - /* High speed pipes may need a hardware ping before they start */ + /* + * High speed pipes may need a hardware ping before they start + */ if (pipe->flags & __CVMX_USB_PIPE_FLAGS_NEED_PING) usbc_hctsiz.s.dopng = 1; @@ -1620,13 +1733,18 @@ static void __cvmx_usb_start_channel(cvmx_usb_internal_state_t *usb, { cvmx_usbcx_hccharx_t usbc_hcchar = {.u32 = 0}; - /* Set the startframe odd/even properly. This is only used for periodic */ + /* + * Set the startframe odd/even properly. This is only used for + * periodic + */ usbc_hcchar.s.oddfrm = usb->frame_number&1; - /* Set the number of back to back packets allowed by this endpoint. - Split transactions interpret "ec" as the number of immediate - retries of failure. These retries happen too quickly, so we - disable these entirely for splits */ + /* + * Set the number of back to back packets allowed by this + * endpoint. Split transactions interpret "ec" as the number of + * immediate retries of failure. These retries happen too + * quickly, so we disable these entirely for splits + */ if (__cvmx_usb_pipe_needs_split(usb, pipe)) usbc_hcchar.s.ec = 1; else if (pipe->multi_count < 1) @@ -1656,8 +1774,10 @@ static void __cvmx_usb_start_channel(cvmx_usb_internal_state_t *usb, break; case CVMX_USB_TRANSFER_ISOCHRONOUS: if (!__cvmx_usb_pipe_needs_split(usb, pipe)) { - /* ISO transactions require different PIDs depending on direction - and how many packets are needed */ + /* + * ISO transactions require different PIDs depending on + * direction and how many packets are needed + */ if (pipe->transfer_dir == CVMX_USB_DIRECTION_OUT) { if (pipe->multi_count < 2) /* Need DATA0 */ USB_SET_FIELD32(CVMX_USBCX_HCTSIZX(channel, usb->index), cvmx_usbcx_hctsizx_t, pid, 0); @@ -1745,9 +1865,11 @@ static void __cvmx_usb_schedule(cvmx_usb_internal_state_t *usb, int is_sof) /* Find a pipe needing service */ pipe = NULL; if (is_sof) { - /* Only process periodic pipes on SOF interrupts. This way we are - sure that the periodic data is sent in the beginning of the - frame */ + /* + * Only process periodic pipes on SOF interrupts. This + * way we are sure that the periodic data is sent in the + * beginning of the frame + */ pipe = __cvmx_usb_find_ready_pipe(usb, usb->active_pipes + CVMX_USB_TRANSFER_ISOCHRONOUS, usb->frame_number); if (likely(!pipe)) pipe = __cvmx_usb_find_ready_pipe(usb, usb->active_pipes + CVMX_USB_TRANSFER_INTERRUPT, usb->frame_number); @@ -1764,8 +1886,10 @@ static void __cvmx_usb_schedule(cvmx_usb_internal_state_t *usb, int is_sof) } done: - /* Only enable SOF interrupts when we have transactions pending in the - future that might need to be scheduled */ + /* + * Only enable SOF interrupts when we have transactions pending in the + * future that might need to be scheduled + */ need_sof = 0; for (ttype = CVMX_USB_TRANSFER_CONTROL; ttype <= CVMX_USB_TRANSFER_INTERRUPT; ttype++) { pipe = usb->active_pipes[ttype].head; @@ -1850,15 +1974,19 @@ static void __cvmx_usb_perform_complete(cvmx_usb_internal_state_t *usb, if (usb->active_split == transaction) usb->active_split = NULL; - /* Isochronous transactions need extra processing as they might not be done - after a single data transfer */ + /* + * Isochronous transactions need extra processing as they might not be + * done after a single data transfer + */ if (unlikely(transaction->type == CVMX_USB_TRANSFER_ISOCHRONOUS)) { /* Update the number of bytes transferred in this ISO packet */ transaction->iso_packets[0].length = transaction->actual_bytes; transaction->iso_packets[0].status = complete_code; - /* If there are more ISOs pending and we succeeded, schedule the next - one */ + /* + * If there are more ISOs pending and we succeeded, schedule the + * next one + */ if ((transaction->iso_number_packets > 1) && (complete_code == CVMX_USB_COMPLETE_SUCCESS)) { transaction->actual_bytes = 0; /* No bytes transferred for this packet as of yet */ transaction->iso_number_packets--; /* One less ISO waiting to transfer */ @@ -2296,8 +2424,10 @@ int cvmx_usb_cancel(cvmx_usb_state_t *state, int pipe_handle, int submit_handle) if (unlikely((transaction->flags & __CVMX_USB_TRANSACTION_FLAGS_IN_USE) == 0)) return -EINVAL; - /* If the transaction is the HEAD of the queue and scheduled. We need to - treat it special */ + /* + * If the transaction is the HEAD of the queue and scheduled. We need to + * treat it special + */ if ((pipe->head == transaction) && (pipe->flags & __CVMX_USB_PIPE_FLAGS_SCHEDULED)) { cvmx_usbcx_hccharx_t usbc_hcchar; @@ -2468,15 +2598,19 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel) usbc_hcchar.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCCHARX(channel, usb->index)); if (usbc_hcchar.s.chena && usbc_hcchar.s.chdis) { - /* There seems to be a bug in CN31XX which can cause interrupt - IN transfers to get stuck until we do a write of HCCHARX - without changing things */ + /* + * There seems to be a bug in CN31XX which can cause + * interrupt IN transfers to get stuck until we do a + * write of HCCHARX without changing things + */ __cvmx_usb_write_csr32(usb, CVMX_USBCX_HCCHARX(channel, usb->index), usbc_hcchar.u32); return 0; } - /* In non DMA mode the channels don't halt themselves. We need to - manually disable channels that are left running */ + /* + * In non DMA mode the channels don't halt themselves. We need + * to manually disable channels that are left running + */ if (!usbc_hcint.s.chhltd) { if (usbc_hcchar.s.chena) { cvmx_usbcx_hcintmskx_t hcintmsk; @@ -2495,8 +2629,10 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel) } } } else { - /* There is are no interrupts that we need to process when the channel is - still running */ + /* + * There is are no interrupts that we need to process when the + * channel is still running + */ if (!usbc_hcint.s.chhltd) return 0; } @@ -2514,33 +2650,45 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel) transaction = pipe->head; CVMX_PREFETCH0(transaction); - /* Disconnect this pipe from the HW channel. Later the schedule function will - figure out which pipe needs to go */ + /* + * Disconnect this pipe from the HW channel. Later the schedule + * function will figure out which pipe needs to go + */ usb->pipe_for_channel[channel] = NULL; pipe->flags &= ~__CVMX_USB_PIPE_FLAGS_SCHEDULED; - /* Read the channel config info so we can figure out how much data - transfered */ + /* + * Read the channel config info so we can figure out how much data + * transfered + */ usbc_hcchar.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCCHARX(channel, usb->index)); usbc_hctsiz.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCTSIZX(channel, usb->index)); - /* Calculating the number of bytes successfully transferred is dependent on - the transfer direction */ + /* + * Calculating the number of bytes successfully transferred is dependent + * on the transfer direction + */ packets_processed = transaction->pktcnt - usbc_hctsiz.s.pktcnt; if (usbc_hcchar.s.epdir) { - /* IN transactions are easy. For every byte received the hardware - decrements xfersize. All we need to do is subtract the current - value of xfersize from its starting value and we know how many - bytes were written to the buffer */ + /* + * IN transactions are easy. For every byte received the + * hardware decrements xfersize. All we need to do is subtract + * the current value of xfersize from its starting value and we + * know how many bytes were written to the buffer + */ bytes_this_transfer = transaction->xfersize - usbc_hctsiz.s.xfersize; } else { - /* OUT transaction don't decrement xfersize. Instead pktcnt is - decremented on every successful packet send. The hardware does - this when it receives an ACK, or NYET. If it doesn't - receive one of these responses pktcnt doesn't change */ + /* + * OUT transaction don't decrement xfersize. Instead pktcnt is + * decremented on every successful packet send. The hardware + * does this when it receives an ACK, or NYET. If it doesn't + * receive one of these responses pktcnt doesn't change + */ bytes_this_transfer = packets_processed * usbc_hcchar.s.mps; - /* The last packet may not be a full transfer if we didn't have - enough data */ + /* + * The last packet may not be a full transfer if we didn't have + * enough data + */ if (bytes_this_transfer > transaction->xfersize) bytes_this_transfer = transaction->xfersize; } @@ -2550,56 +2698,77 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel) else bytes_in_last_packet = bytes_this_transfer; - /* As a special case, setup transactions output the setup header, not - the user's data. For this reason we don't count setup data as bytes - transferred */ + /* + * As a special case, setup transactions output the setup header, not + * the user's data. For this reason we don't count setup data as bytes + * transferred + */ if ((transaction->stage == CVMX_USB_STAGE_SETUP) || (transaction->stage == CVMX_USB_STAGE_SETUP_SPLIT_COMPLETE)) bytes_this_transfer = 0; - /* Add the bytes transferred to the running total. It is important that - bytes_this_transfer doesn't count any data that needs to be - retransmitted */ + /* + * Add the bytes transferred to the running total. It is important that + * bytes_this_transfer doesn't count any data that needs to be + * retransmitted + */ transaction->actual_bytes += bytes_this_transfer; if (transaction->type == CVMX_USB_TRANSFER_ISOCHRONOUS) buffer_space_left = transaction->iso_packets[0].length - transaction->actual_bytes; else buffer_space_left = transaction->buffer_length - transaction->actual_bytes; - /* We need to remember the PID toggle state for the next transaction. The - hardware already updated it for the next transaction */ + /* + * We need to remember the PID toggle state for the next transaction. + * The hardware already updated it for the next transaction + */ pipe->pid_toggle = !(usbc_hctsiz.s.pid == 0); - /* For high speed bulk out, assume the next transaction will need to do a - ping before proceeding. If this isn't true the ACK processing below - will clear this flag */ + /* + * For high speed bulk out, assume the next transaction will need to do + * a ping before proceeding. If this isn't true the ACK processing below + * will clear this flag + */ if ((pipe->device_speed == CVMX_USB_SPEED_HIGH) && (pipe->transfer_type == CVMX_USB_TRANSFER_BULK) && (pipe->transfer_dir == CVMX_USB_DIRECTION_OUT)) pipe->flags |= __CVMX_USB_PIPE_FLAGS_NEED_PING; if (usbc_hcint.s.stall) { - /* STALL as a response means this transaction cannot be completed - because the device can't process transactions. Tell the user. Any - data that was transferred will be counted on the actual bytes - transferred */ + /* + * STALL as a response means this transaction cannot be + * completed because the device can't process transactions. Tell + * the user. Any data that was transferred will be counted on + * the actual bytes transferred + */ pipe->pid_toggle = 0; __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_STALL); } else if (usbc_hcint.s.xacterr) { - /* We know at least one packet worked if we get a ACK or NAK. Reset the retry counter */ + /* + * We know at least one packet worked if we get a ACK or NAK. + * Reset the retry counter + */ if (usbc_hcint.s.nak || usbc_hcint.s.ack) transaction->retries = 0; transaction->retries++; if (transaction->retries > MAX_RETRIES) { - /* XactErr as a response means the device signaled something wrong with - the transfer. For example, PID toggle errors cause these */ + /* + * XactErr as a response means the device signaled + * something wrong with the transfer. For example, PID + * toggle errors cause these + */ __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_XACTERR); } else { - /* If this was a split then clear our split in progress marker */ + /* + * If this was a split then clear our split in progress + * marker + */ if (usb->active_split == transaction) usb->active_split = NULL; - /* Rewind to the beginning of the transaction by anding off the - split complete bit */ + /* + * Rewind to the beginning of the transaction by anding + * off the split complete bit + */ transaction->stage &= ~1; pipe->split_sc_frame = -1; pipe->next_tx_frame += pipe->interval; @@ -2614,38 +2783,49 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel) /* We'll retry the exact same transaction again */ transaction->retries++; } else if (usbc_hcint.s.nyet) { - /* NYET as a response is only allowed in three cases: as a response to - a ping, as a response to a split transaction, and as a response to - a bulk out. The ping case is handled by hardware, so we only have - splits and bulk out */ + /* + * NYET as a response is only allowed in three cases: as a + * response to a ping, as a response to a split transaction, and + * as a response to a bulk out. The ping case is handled by + * hardware, so we only have splits and bulk out + */ if (!__cvmx_usb_pipe_needs_split(usb, pipe)) { transaction->retries = 0; - /* If there is more data to go then we need to try again. Otherwise - this transaction is complete */ + /* + * If there is more data to go then we need to try + * again. Otherwise this transaction is complete + */ if ((buffer_space_left == 0) || (bytes_in_last_packet < pipe->max_packet)) __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_SUCCESS); } else { - /* Split transactions retry the split complete 4 times then rewind - to the start split and do the entire transactions again */ + /* + * Split transactions retry the split complete 4 times + * then rewind to the start split and do the entire + * transactions again + */ transaction->retries++; if ((transaction->retries & 0x3) == 0) { - /* Rewind to the beginning of the transaction by anding off the - split complete bit */ + /* + * Rewind to the beginning of the transaction by + * anding off the split complete bit + */ transaction->stage &= ~1; pipe->split_sc_frame = -1; } } } else if (usbc_hcint.s.ack) { transaction->retries = 0; - /* The ACK bit can only be checked after the other error bits. This is - because a multi packet transfer may succeed in a number of packets - and then get a different response on the last packet. In this case - both ACK and the last response bit will be set. If none of the - other response bits is set, then the last packet must have been an - ACK */ - - /* Since we got an ACK, we know we don't need to do a ping on this - pipe */ + /* + * The ACK bit can only be checked after the other error bits. + * This is because a multi packet transfer may succeed in a + * number of packets and then get a different response on the + * last packet. In this case both ACK and the last response bit + * will be set. If none of the other response bits is set, then + * the last packet must have been an ACK + * + * Since we got an ACK, we know we don't need to do a ping on + * this pipe + */ pipe->flags &= ~__CVMX_USB_PIPE_FLAGS_NEED_PING; switch (transaction->type) { @@ -2680,9 +2860,12 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel) case CVMX_USB_STAGE_DATA: if (__cvmx_usb_pipe_needs_split(usb, pipe)) { transaction->stage = CVMX_USB_STAGE_DATA_SPLIT_COMPLETE; - /* For setup OUT data that are splits, the hardware - doesn't appear to count transferred data. Here - we manually update the data transferred */ + /* + * For setup OUT data that are splits, + * the hardware doesn't appear to count + * transferred data. Here we manually + * update the data transferred + */ if (!usbc_hcchar.s.epdir) { if (buffer_space_left < pipe->max_packet) transaction->actual_bytes += buffer_space_left; @@ -2715,10 +2898,12 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel) break; case CVMX_USB_TRANSFER_BULK: case CVMX_USB_TRANSFER_INTERRUPT: - /* The only time a bulk transfer isn't complete when - it finishes with an ACK is during a split transaction. For - splits we need to continue the transfer if more data is - needed */ + /* + * The only time a bulk transfer isn't complete when it + * finishes with an ACK is during a split transaction. + * For splits we need to continue the transfer if more + * data is needed + */ if (__cvmx_usb_pipe_needs_split(usb, pipe)) { if (transaction->stage == CVMX_USB_STAGE_NON_CONTROL) transaction->stage = CVMX_USB_STAGE_NON_CONTROL_SPLIT_COMPLETE; @@ -2746,23 +2931,33 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel) break; case CVMX_USB_TRANSFER_ISOCHRONOUS: if (__cvmx_usb_pipe_needs_split(usb, pipe)) { - /* ISOCHRONOUS OUT splits don't require a complete split stage. - Instead they use a sequence of begin OUT splits to transfer - the data 188 bytes at a time. Once the transfer is complete, - the pipe sleeps until the next schedule interval */ + /* + * ISOCHRONOUS OUT splits don't require a + * complete split stage. Instead they use a + * sequence of begin OUT splits to transfer the + * data 188 bytes at a time. Once the transfer + * is complete, the pipe sleeps until the next + * schedule interval + */ if (pipe->transfer_dir == CVMX_USB_DIRECTION_OUT) { - /* If no space left or this wasn't a max size packet then - this transfer is complete. Otherwise start it again - to send the next 188 bytes */ + /* + * If no space left or this wasn't a max + * size packet then this transfer is + * complete. Otherwise start it again to + * send the next 188 bytes + */ if (!buffer_space_left || (bytes_this_transfer < 188)) { pipe->next_tx_frame += pipe->interval; __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_SUCCESS); } } else { if (transaction->stage == CVMX_USB_STAGE_NON_CONTROL_SPLIT_COMPLETE) { - /* We are in the incoming data phase. Keep getting - data until we run out of space or get a small - packet */ + /* + * We are in the incoming data + * phase. Keep getting data + * until we run out of space or + * get a small packet + */ if ((buffer_space_left == 0) || (bytes_in_last_packet < pipe->max_packet)) { pipe->next_tx_frame += pipe->interval; __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_SUCCESS); @@ -2780,10 +2975,12 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel) /* If this was a split then clear our split in progress marker */ if (usb->active_split == transaction) usb->active_split = NULL; - /* NAK as a response means the device couldn't accept the transaction, - but it should be retried in the future. Rewind to the beginning of - the transaction by anding off the split complete bit. Retry in the - next interval */ + /* + * NAK as a response means the device couldn't accept the + * transaction, but it should be retried in the future. Rewind + * to the beginning of the transaction by anding off the split + * complete bit. Retry in the next interval + */ transaction->retries = 0; transaction->stage &= ~1; pipe->next_tx_frame += pipe->interval; @@ -2797,8 +2994,10 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel) /* We'll retry the exact same transaction again */ transaction->retries++; } else { - /* We get channel halted interrupts with no result bits sets when the - cable is unplugged */ + /* + * We get channel halted interrupts with no result bits + * sets when the cable is unplugged + */ __cvmx_usb_perform_complete(usb, pipe, transaction, CVMX_USB_COMPLETE_ERROR); } } @@ -2843,10 +3042,13 @@ int cvmx_usb_poll(cvmx_usb_state_t *state) __cvmx_usb_write_csr32(usb, CVMX_USBCX_GINTSTS(usb->index), usbc_gintsts.u32); if (usbc_gintsts.s.rxflvl) { - /* RxFIFO Non-Empty (RxFLvl) - Indicates that there is at least one packet pending to be read - from the RxFIFO. */ - /* In DMA mode this is handled by hardware */ + /* + * RxFIFO Non-Empty (RxFLvl) + * Indicates that there is at least one packet pending to be + * read from the RxFIFO. + * + * In DMA mode this is handled by hardware + */ if (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA) __cvmx_usb_poll_rx_fifo(usb); } @@ -2857,18 +3059,20 @@ int cvmx_usb_poll(cvmx_usb_state_t *state) } if (usbc_gintsts.s.disconnint || usbc_gintsts.s.prtint) { cvmx_usbcx_hprt_t usbc_hprt; - /* Disconnect Detected Interrupt (DisconnInt) - Asserted when a device disconnect is detected. */ - - /* Host Port Interrupt (PrtInt) - The core sets this bit to indicate a change in port status of one - of the O2P USB core ports in Host mode. The application must - read the Host Port Control and Status (HPRT) register to - determine the exact event that caused this interrupt. The - application must clear the appropriate status bit in the Host Port - Control and Status register to clear this bit. */ - - /* Call the user's port callback */ + /* + * Disconnect Detected Interrupt (DisconnInt) + * Asserted when a device disconnect is detected. + * + * Host Port Interrupt (PrtInt) + * The core sets this bit to indicate a change in port status of + * one of the O2P USB core ports in Host mode. The application + * must read the Host Port Control and Status (HPRT) register to + * determine the exact event that caused this interrupt. The + * application must clear the appropriate status bit in the Host + * Port Control and Status register to clear this bit. + * + * Call the user's port callback + */ __cvmx_usb_perform_callback(usb, NULL, NULL, CVMX_USB_CALLBACK_PORT_CHANGED, CVMX_USB_COMPLETE_SUCCESS); @@ -2878,15 +3082,18 @@ int cvmx_usb_poll(cvmx_usb_state_t *state) __cvmx_usb_write_csr32(usb, CVMX_USBCX_HPRT(usb->index), usbc_hprt.u32); } if (usbc_gintsts.s.hchint) { - /* Host Channels Interrupt (HChInt) - The core sets this bit to indicate that an interrupt is pending on - one of the channels of the core (in Host mode). The application - must read the Host All Channels Interrupt (HAINT) register to - determine the exact number of the channel on which the - interrupt occurred, and then read the corresponding Host - Channel-n Interrupt (HCINTn) register to determine the exact - cause of the interrupt. The application must clear the - appropriate status bit in the HCINTn register to clear this bit. */ + /* + * Host Channels Interrupt (HChInt) + * The core sets this bit to indicate that an interrupt is + * pending on one of the channels of the core (in Host mode). + * The application must read the Host All Channels Interrupt + * (HAINT) register to determine the exact number of the channel + * on which the interrupt occurred, and then read the + * corresponding Host Channel-n Interrupt (HCINTn) register to + * determine the exact cause of the interrupt. The application + * must clear the appropriate status bit in the HCINTn register + * to clear this bit. + */ cvmx_usbcx_haint_t usbc_haint; usbc_haint.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HAINT(usb->index)); while (usbc_haint.u32) { -- GitLab From 6995ae41b301ab5487fe65518c018360f6809f69 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Mon, 29 Jul 2013 20:07:55 +0300 Subject: [PATCH 343/942] staging: octeon-usb: cvmx-usb: delete @INTERNAL Delete "@INTERNAL" from comments. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/cvmx-usb.c | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/drivers/staging/octeon-usb/cvmx-usb.c b/drivers/staging/octeon-usb/cvmx-usb.c index 025671a2d5b18..d3da546f3b627 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.c +++ b/drivers/staging/octeon-usb/cvmx-usb.c @@ -258,7 +258,6 @@ static int octeon_usb_get_clock_type(void) } /** - * @INTERNAL * Read a USB 32bit CSR. It performs the necessary address swizzle * for 32bit CSRs and logs the value in a readable format if * debugging is on. @@ -277,7 +276,6 @@ static inline uint32_t __cvmx_usb_read_csr32(cvmx_usb_internal_state_t *usb, /** - * @INTERNAL * Write a USB 32bit CSR. It performs the necessary address * swizzle for 32bit CSRs and logs the value in a readable format * if debugging is on. @@ -295,7 +293,6 @@ static inline void __cvmx_usb_write_csr32(cvmx_usb_internal_state_t *usb, /** - * @INTERNAL * Read a USB 64bit CSR. It logs the value in a readable format if * debugging is on. * @@ -313,7 +310,6 @@ static inline uint64_t __cvmx_usb_read_csr64(cvmx_usb_internal_state_t *usb, /** - * @INTERNAL * Write a USB 64bit CSR. It logs the value in a readable format * if debugging is on. * @@ -328,7 +324,6 @@ static inline void __cvmx_usb_write_csr64(cvmx_usb_internal_state_t *usb, } /** - * @INTERNAL * Return non zero if this pipe connects to a non HIGH speed * device through a high speed hub. * @@ -344,7 +339,6 @@ static inline int __cvmx_usb_pipe_needs_split(cvmx_usb_internal_state_t *usb, cv /** - * @INTERNAL * Trivial utility function to return the correct PID for a pipe * * @param pipe pipe to check @@ -392,7 +386,6 @@ int cvmx_usb_get_num_ports(void) /** - * @INTERNAL * Allocate a usb transaction for use * * @param usb USB device state populated by @@ -418,7 +411,6 @@ static inline cvmx_usb_transaction_t *__cvmx_usb_alloc_transaction(cvmx_usb_inte /** - * @INTERNAL * Free a usb transaction * * @param usb USB device state populated by @@ -441,7 +433,6 @@ static inline void __cvmx_usb_free_transaction(cvmx_usb_internal_state_t *usb, /** - * @INTERNAL * Add a pipe to the tail of a list * @param list List to add pipe to * @param pipe Pipe to add @@ -459,7 +450,6 @@ static inline void __cvmx_usb_append_pipe(cvmx_usb_pipe_list_t *list, cvmx_usb_p /** - * @INTERNAL * Remove a pipe from a list * @param list List to remove pipe from * @param pipe Pipe to remove @@ -1024,7 +1014,6 @@ void cvmx_usb_set_status(cvmx_usb_state_t *state, cvmx_usb_port_status_t port_st /** - * @INTERNAL * Convert a USB transaction into a handle * * @param usb USB device state populated by @@ -1043,7 +1032,6 @@ static inline int __cvmx_usb_get_submit_handle(cvmx_usb_internal_state_t *usb, /** - * @INTERNAL * Convert a USB pipe into a handle * * @param usb USB device state populated by @@ -1199,7 +1187,6 @@ int cvmx_usb_open_pipe(cvmx_usb_state_t *state, cvmx_usb_pipe_flags_t flags, /** - * @INTERNAL * Poll the RX FIFOs and remove data as needed. This function is only used * in non DMA mode. It is very important that this function be called quickly * enough to prevent FIFO overflow. @@ -1335,7 +1322,6 @@ static void __cvmx_usb_poll_tx_fifo(cvmx_usb_internal_state_t *usb) /** - * @INTERNAL * Fill the TX FIFO with an outgoing packet * * @param usb USB device state populated by @@ -1383,7 +1369,6 @@ static void __cvmx_usb_fill_tx_fifo(cvmx_usb_internal_state_t *usb, int channel) } /** - * @INTERNAL * Perform channel specific setup for Control transactions. All * the generic stuff will already have been done in * __cvmx_usb_start_channel() @@ -1515,7 +1500,6 @@ static void __cvmx_usb_start_channel_control(cvmx_usb_internal_state_t *usb, /** - * @INTERNAL * Start a channel to perform the pipe's head transaction * * @param usb USB device state populated by @@ -1803,7 +1787,6 @@ static void __cvmx_usb_start_channel(cvmx_usb_internal_state_t *usb, /** - * @INTERNAL * Find a pipe that is ready to be scheduled to hardware. * @param usb USB device state populated by * cvmx_usb_initialize(). @@ -1832,7 +1815,6 @@ static cvmx_usb_pipe_t *__cvmx_usb_find_ready_pipe(cvmx_usb_internal_state_t *us /** - * @INTERNAL * Called whenever a pipe might need to be scheduled to the * hardware. * @@ -1907,7 +1889,6 @@ static void __cvmx_usb_schedule(cvmx_usb_internal_state_t *usb, int is_sof) /** - * @INTERNAL * Call a user's callback for a specific reason. * * @param usb USB device state populated by @@ -1953,7 +1934,6 @@ static void __cvmx_usb_perform_callback(cvmx_usb_internal_state_t *usb, /** - * @INTERNAL * Signal the completion of a transaction and free it. The * transaction will be removed from the pipe transaction list. * @@ -2020,7 +2000,6 @@ static void __cvmx_usb_perform_complete(cvmx_usb_internal_state_t *usb, /** - * @INTERNAL * Submit a usb transaction to a pipe. Called for all types * of transactions. * @@ -2571,7 +2550,6 @@ int cvmx_usb_get_frame_number(cvmx_usb_state_t *state) /** - * @INTERNAL * Poll a channel for status * * @param usb USB device -- GitLab From a6945527d34c56ca07b5f0d081f1874e3a93aa48 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Mon, 29 Jul 2013 20:07:56 +0300 Subject: [PATCH 344/942] staging: octeon-usb: cvmx-usb: delete duplicated documentation from .h file Delete duplicated function call documentation from the .h file. These functions are just internal anyway, and the .h file will be completely removed in the future when the driver will be made a single self-contained .c file. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/cvmx-usb.h | 363 -------------------------- 1 file changed, 363 deletions(-) diff --git a/drivers/staging/octeon-usb/cvmx-usb.h b/drivers/staging/octeon-usb/cvmx-usb.h index dc366c8e71710..30d7213ed19e9 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.h +++ b/drivers/staging/octeon-usb/cvmx-usb.h @@ -409,160 +409,14 @@ typedef enum __CVMX_USB_PIPE_FLAGS_NEED_PING = 1<<18, /**< Used internally to determine if a high speed pipe is in the ping state. Do not use */ } cvmx_usb_pipe_flags_t; -/** - * Return the number of USB ports supported by this Octeon - * chip. If the chip doesn't support USB, or is not supported - * by this API, a zero will be returned. Most Octeon chips - * support one usb port, but some support two ports. - * cvmx_usb_initialize() must be called on independent - * cvmx_usb_state_t structures. - * - * @return Number of port, zero if usb isn't supported - */ extern int cvmx_usb_get_num_ports(void); - -/** - * Initialize a USB port for use. This must be called before any - * other access to the Octeon USB port is made. The port starts - * off in the disabled state. - * - * @param state Pointer to an empty cvmx_usb_state_t structure - * that will be populated by the initialize call. - * This structure is then passed to all other USB - * functions. - * @param usb_port_number - * Which Octeon USB port to initialize. - * @param flags Flags to control hardware initialization. See - * cvmx_usb_initialize_flags_t for the flag - * definitions. Some flags are mandatory. - * - * @return 0 or a negative error code. - */ extern int cvmx_usb_initialize(cvmx_usb_state_t *state, int usb_port_number, cvmx_usb_initialize_flags_t flags); - -/** - * Shutdown a USB port after a call to cvmx_usb_initialize(). - * The port should be disabled with all pipes closed when this - * function is called. - * - * @param state USB device state populated by - * cvmx_usb_initialize(). - * - * @return 0 or a negative error code. - */ extern int cvmx_usb_shutdown(cvmx_usb_state_t *state); - -/** - * Enable a USB port. After this call succeeds, the USB port is - * online and servicing requests. - * - * @param state USB device state populated by - * cvmx_usb_initialize(). - * - * @return 0 or a negative error code. - */ extern int cvmx_usb_enable(cvmx_usb_state_t *state); - -/** - * Disable a USB port. After this call the USB port will not - * generate data transfers and will not generate events. - * Transactions in process will fail and call their - * associated callbacks. - * - * @param state USB device state populated by - * cvmx_usb_initialize(). - * - * @return 0 or a negative error code. - */ extern int cvmx_usb_disable(cvmx_usb_state_t *state); - -/** - * Get the current state of the USB port. Use this call to - * determine if the usb port has anything connected, is enabled, - * or has some sort of error condition. The return value of this - * call has "changed" bits to signal of the value of some fields - * have changed between calls. These "changed" fields are based - * on the last call to cvmx_usb_set_status(). In order to clear - * them, you must update the status through cvmx_usb_set_status(). - * - * @param state USB device state populated by - * cvmx_usb_initialize(). - * - * @return Port status information - */ extern cvmx_usb_port_status_t cvmx_usb_get_status(cvmx_usb_state_t *state); - -/** - * Set the current state of the USB port. The status is used as - * a reference for the "changed" bits returned by - * cvmx_usb_get_status(). Other than serving as a reference, the - * status passed to this function is not used. No fields can be - * changed through this call. - * - * @param state USB device state populated by - * cvmx_usb_initialize(). - * @param port_status - * Port status to set, most like returned by cvmx_usb_get_status() - */ extern void cvmx_usb_set_status(cvmx_usb_state_t *state, cvmx_usb_port_status_t port_status); - -/** - * Open a virtual pipe between the host and a USB device. A pipe - * must be opened before data can be transferred between a device - * and Octeon. - * - * @param state USB device state populated by - * cvmx_usb_initialize(). - * @param flags Optional pipe flags defined in - * cvmx_usb_pipe_flags_t. - * @param device_addr - * USB device address to open the pipe to - * (0-127). - * @param endpoint_num - * USB endpoint number to open the pipe to - * (0-15). - * @param device_speed - * The speed of the device the pipe is going - * to. This must match the device's speed, - * which may be different than the port speed. - * @param max_packet The maximum packet length the device can - * transmit/receive (low speed=0-8, full - * speed=0-1023, high speed=0-1024). This value - * comes from the standard endpoint descriptor - * field wMaxPacketSize bits <10:0>. - * @param transfer_type - * The type of transfer this pipe is for. - * @param transfer_dir - * The direction the pipe is in. This is not - * used for control pipes. - * @param interval For ISOCHRONOUS and INTERRUPT transfers, - * this is how often the transfer is scheduled - * for. All other transfers should specify - * zero. The units are in frames (8000/sec at - * high speed, 1000/sec for full speed). - * @param multi_count - * For high speed devices, this is the maximum - * allowed number of packet per microframe. - * Specify zero for non high speed devices. This - * value comes from the standard endpoint descriptor - * field wMaxPacketSize bits <12:11>. - * @param hub_device_addr - * Hub device address this device is connected - * to. Devices connected directly to Octeon - * use zero. This is only used when the device - * is full/low speed behind a high speed hub. - * The address will be of the high speed hub, - * not and full speed hubs after it. - * @param hub_port Which port on the hub the device is - * connected. Use zero for devices connected - * directly to Octeon. Like hub_device_addr, - * this is only used for full/low speed - * devices behind a high speed hub. - * - * @return A non negative value is a pipe handle. Negative - * values are error codes. - */ extern int cvmx_usb_open_pipe(cvmx_usb_state_t *state, cvmx_usb_pipe_flags_t flags, int device_addr, int endpoint_num, @@ -571,111 +425,14 @@ extern int cvmx_usb_open_pipe(cvmx_usb_state_t *state, cvmx_usb_direction_t transfer_dir, int interval, int multi_count, int hub_device_addr, int hub_port); - -/** - * Call to submit a USB Bulk transfer to a pipe. - * - * @param state USB device state populated by - * cvmx_usb_initialize(). - * @param pipe_handle - * Handle to the pipe for the transfer. - * @param buffer Physical address of the data buffer in - * memory. Note that this is NOT A POINTER, but - * the full 64bit physical address of the - * buffer. This may be zero if buffer_length is - * zero. - * @param buffer_length - * Length of buffer in bytes. - * @param callback Function to call when this transaction - * completes. If the return value of this - * function isn't an error, then this function - * is guaranteed to be called when the - * transaction completes. If this parameter is - * NULL, then the generic callback registered - * through cvmx_usb_register_callback is - * called. If both are NULL, then there is no - * way to know when a transaction completes. - * @param user_data User supplied data returned when the - * callback is called. This is only used if - * callback in not NULL. - * - * @return A submitted transaction handle or negative on - * failure. Negative values are error codes. - */ extern int cvmx_usb_submit_bulk(cvmx_usb_state_t *state, int pipe_handle, uint64_t buffer, int buffer_length, cvmx_usb_callback_func_t callback, void *user_data); - -/** - * Call to submit a USB Interrupt transfer to a pipe. - * - * @param state USB device state populated by - * cvmx_usb_initialize(). - * @param pipe_handle - * Handle to the pipe for the transfer. - * @param buffer Physical address of the data buffer in - * memory. Note that this is NOT A POINTER, but - * the full 64bit physical address of the - * buffer. This may be zero if buffer_length is - * zero. - * @param buffer_length - * Length of buffer in bytes. - * @param callback Function to call when this transaction - * completes. If the return value of this - * function isn't an error, then this function - * is guaranteed to be called when the - * transaction completes. If this parameter is - * NULL, then the generic callback registered - * through cvmx_usb_register_callback is - * called. If both are NULL, then there is no - * way to know when a transaction completes. - * @param user_data User supplied data returned when the - * callback is called. This is only used if - * callback in not NULL. - * - * @return A submitted transaction handle or negative on - * failure. Negative values are error codes. - */ extern int cvmx_usb_submit_interrupt(cvmx_usb_state_t *state, int pipe_handle, uint64_t buffer, int buffer_length, cvmx_usb_callback_func_t callback, void *user_data); - -/** - * Call to submit a USB Control transfer to a pipe. - * - * @param state USB device state populated by - * cvmx_usb_initialize(). - * @param pipe_handle - * Handle to the pipe for the transfer. - * @param control_header - * USB 8 byte control header physical address. - * Note that this is NOT A POINTER, but the - * full 64bit physical address of the buffer. - * @param buffer Physical address of the data buffer in - * memory. Note that this is NOT A POINTER, but - * the full 64bit physical address of the - * buffer. This may be zero if buffer_length is - * zero. - * @param buffer_length - * Length of buffer in bytes. - * @param callback Function to call when this transaction - * completes. If the return value of this - * function isn't an error, then this function - * is guaranteed to be called when the - * transaction completes. If this parameter is - * NULL, then the generic callback registered - * through cvmx_usb_register_callback is - * called. If both are NULL, then there is no - * way to know when a transaction completes. - * @param user_data User supplied data returned when the - * callback is called. This is only used if - * callback in not NULL. - * - * @return A submitted transaction handle or negative on - * failure. Negative values are error codes. - */ extern int cvmx_usb_submit_control(cvmx_usb_state_t *state, int pipe_handle, uint64_t control_header, uint64_t buffer, int buffer_length, @@ -691,50 +448,6 @@ typedef enum CVMX_USB_ISOCHRONOUS_FLAGS_ASAP = 1<<1, /**< Schedule the transaction as soon as possible */ } cvmx_usb_isochronous_flags_t; -/** - * Call to submit a USB Isochronous transfer to a pipe. - * - * @param state USB device state populated by - * cvmx_usb_initialize(). - * @param pipe_handle - * Handle to the pipe for the transfer. - * @param start_frame - * Number of frames into the future to schedule - * this transaction. - * @param flags Flags to control the transfer. See - * cvmx_usb_isochronous_flags_t for the flag - * definitions. - * @param number_packets - * Number of sequential packets to transfer. - * "packets" is a pointer to an array of this - * many packet structures. - * @param packets Description of each transfer packet as - * defined by cvmx_usb_iso_packet_t. The array - * pointed to here must stay valid until the - * complete callback is called. - * @param buffer Physical address of the data buffer in - * memory. Note that this is NOT A POINTER, but - * the full 64bit physical address of the - * buffer. This may be zero if buffer_length is - * zero. - * @param buffer_length - * Length of buffer in bytes. - * @param callback Function to call when this transaction - * completes. If the return value of this - * function isn't an error, then this function - * is guaranteed to be called when the - * transaction completes. If this parameter is - * NULL, then the generic callback registered - * through cvmx_usb_register_callback is - * called. If both are NULL, then there is no - * way to know when a transaction completes. - * @param user_data User supplied data returned when the - * callback is called. This is only used if - * callback in not NULL. - * - * @return A submitted transaction handle or negative on - * failure. Negative values are error codes. - */ extern int cvmx_usb_submit_isochronous(cvmx_usb_state_t *state, int pipe_handle, int start_frame, int flags, int number_packets, @@ -742,91 +455,15 @@ extern int cvmx_usb_submit_isochronous(cvmx_usb_state_t *state, int pipe_handle, uint64_t buffer, int buffer_length, cvmx_usb_callback_func_t callback, void *user_data); - -/** - * Cancel one outstanding request in a pipe. Canceling a request - * can fail if the transaction has already completed before cancel - * is called. Even after a successful cancel call, it may take - * a frame or two for the cvmx_usb_poll() function to call the - * associated callback. - * - * @param state USB device state populated by - * cvmx_usb_initialize(). - * @param pipe_handle - * Pipe handle to cancel requests in. - * @param submit_handle - * Handle to transaction to cancel, returned by the submit function. - * - * @return 0 or a negative error code. - */ extern int cvmx_usb_cancel(cvmx_usb_state_t *state, int pipe_handle, int submit_handle); - - -/** - * Cancel all outstanding requests in a pipe. Logically all this - * does is call cvmx_usb_cancel() in a loop. - * - * @param state USB device state populated by - * cvmx_usb_initialize(). - * @param pipe_handle - * Pipe handle to cancel requests in. - * - * @return 0 or a negative error code. - */ extern int cvmx_usb_cancel_all(cvmx_usb_state_t *state, int pipe_handle); - -/** - * Close a pipe created with cvmx_usb_open_pipe(). - * - * @param state USB device state populated by - * cvmx_usb_initialize(). - * @param pipe_handle - * Pipe handle to close. - * - * @return 0 or a negative error code. EBUSY is returned if the pipe has - * outstanding transfers. - */ extern int cvmx_usb_close_pipe(cvmx_usb_state_t *state, int pipe_handle); - -/** - * Register a function to be called when various USB events occur. - * - * @param state USB device state populated by - * cvmx_usb_initialize(). - * @param reason Which event to register for. - * @param callback Function to call when the event occurs. - * @param user_data User data parameter to the function. - * - * @return 0 or a negative error code. - */ extern int cvmx_usb_register_callback(cvmx_usb_state_t *state, cvmx_usb_callback_t reason, cvmx_usb_callback_func_t callback, void *user_data); - -/** - * Get the current USB protocol level frame number. The frame - * number is always in the range of 0-0x7ff. - * - * @param state USB device state populated by - * cvmx_usb_initialize(). - * - * @return USB frame number - */ extern int cvmx_usb_get_frame_number(cvmx_usb_state_t *state); - -/** - * Poll the USB block for status and call all needed callback - * handlers. This function is meant to be called in the interrupt - * handler for the USB controller. It can also be called - * periodically in a loop for non-interrupt based operation. - * - * @param state USB device state populated by - * cvmx_usb_initialize(). - * - * @return 0 or a negative error code. - */ extern int cvmx_usb_poll(cvmx_usb_state_t *state); #endif /* __CVMX_USB_H__ */ -- GitLab From 116c163f99883be31da88c10ed38df6eb8e25b17 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Mon, 29 Jul 2013 20:07:57 +0300 Subject: [PATCH 345/942] staging: octeon-usb: cvmx-usb: convert @param Convert "@param name" inside comments to "@name:". Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/cvmx-usb.c | 268 +++++++++++++------------- 1 file changed, 134 insertions(+), 134 deletions(-) diff --git a/drivers/staging/octeon-usb/cvmx-usb.c b/drivers/staging/octeon-usb/cvmx-usb.c index d3da546f3b627..9a7b53ab0b210 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.c +++ b/drivers/staging/octeon-usb/cvmx-usb.c @@ -262,8 +262,8 @@ static int octeon_usb_get_clock_type(void) * for 32bit CSRs and logs the value in a readable format if * debugging is on. * - * @param usb USB block this access is for - * @param address 64bit address to read + * @usb: USB block this access is for + * @address: 64bit address to read * * @return Result of the read */ @@ -280,9 +280,9 @@ static inline uint32_t __cvmx_usb_read_csr32(cvmx_usb_internal_state_t *usb, * swizzle for 32bit CSRs and logs the value in a readable format * if debugging is on. * - * @param usb USB block this access is for - * @param address 64bit address to write - * @param value Value to write + * @usb: USB block this access is for + * @address: 64bit address to write + * @value: Value to write */ static inline void __cvmx_usb_write_csr32(cvmx_usb_internal_state_t *usb, uint64_t address, uint32_t value) @@ -296,8 +296,8 @@ static inline void __cvmx_usb_write_csr32(cvmx_usb_internal_state_t *usb, * Read a USB 64bit CSR. It logs the value in a readable format if * debugging is on. * - * @param usb USB block this access is for - * @param address 64bit address to read + * @usb: USB block this access is for + * @address: 64bit address to read * * @return Result of the read */ @@ -313,9 +313,9 @@ static inline uint64_t __cvmx_usb_read_csr64(cvmx_usb_internal_state_t *usb, * Write a USB 64bit CSR. It logs the value in a readable format * if debugging is on. * - * @param usb USB block this access is for - * @param address 64bit address to write - * @param value Value to write + * @usb: USB block this access is for + * @address: 64bit address to write + * @value: Value to write */ static inline void __cvmx_usb_write_csr64(cvmx_usb_internal_state_t *usb, uint64_t address, uint64_t value) @@ -327,8 +327,8 @@ static inline void __cvmx_usb_write_csr64(cvmx_usb_internal_state_t *usb, * Return non zero if this pipe connects to a non HIGH speed * device through a high speed hub. * - * @param usb USB block this access is for - * @param pipe Pipe to check + * @usb: USB block this access is for + * @pipe: Pipe to check * * @return Non zero if we need to do split transactions */ @@ -341,7 +341,7 @@ static inline int __cvmx_usb_pipe_needs_split(cvmx_usb_internal_state_t *usb, cv /** * Trivial utility function to return the correct PID for a pipe * - * @param pipe pipe to check + * @pipe: pipe to check * * @return PID for pipe */ @@ -388,7 +388,7 @@ int cvmx_usb_get_num_ports(void) /** * Allocate a usb transaction for use * - * @param usb USB device state populated by + * @usb: USB device state populated by * cvmx_usb_initialize(). * * @return Transaction or NULL @@ -413,9 +413,9 @@ static inline cvmx_usb_transaction_t *__cvmx_usb_alloc_transaction(cvmx_usb_inte /** * Free a usb transaction * - * @param usb USB device state populated by + * @usb: USB device state populated by * cvmx_usb_initialize(). - * @param transaction + * @transaction: * Transaction to free */ static inline void __cvmx_usb_free_transaction(cvmx_usb_internal_state_t *usb, @@ -434,8 +434,8 @@ static inline void __cvmx_usb_free_transaction(cvmx_usb_internal_state_t *usb, /** * Add a pipe to the tail of a list - * @param list List to add pipe to - * @param pipe Pipe to add + * @list: List to add pipe to + * @pipe: Pipe to add */ static inline void __cvmx_usb_append_pipe(cvmx_usb_pipe_list_t *list, cvmx_usb_pipe_t *pipe) { @@ -451,8 +451,8 @@ static inline void __cvmx_usb_append_pipe(cvmx_usb_pipe_list_t *list, cvmx_usb_p /** * Remove a pipe from a list - * @param list List to remove pipe from - * @param pipe Pipe to remove + * @list: List to remove pipe from + * @pipe: Pipe to remove */ static inline void __cvmx_usb_remove_pipe(cvmx_usb_pipe_list_t *list, cvmx_usb_pipe_t *pipe) { @@ -481,13 +481,13 @@ static inline void __cvmx_usb_remove_pipe(cvmx_usb_pipe_list_t *list, cvmx_usb_p * other access to the Octeon USB port is made. The port starts * off in the disabled state. * - * @param state Pointer to an empty cvmx_usb_state_t structure + * @state: Pointer to an empty cvmx_usb_state_t structure * that will be populated by the initialize call. * This structure is then passed to all other USB * functions. - * @param usb_port_number + * @usb_port_number: * Which Octeon USB port to initialize. - * @param flags Flags to control hardware initialization. See + * @flags: Flags to control hardware initialization. See * cvmx_usb_initialize_flags_t for the flag * definitions. Some flags are mandatory. * @@ -815,8 +815,8 @@ int cvmx_usb_initialize(cvmx_usb_state_t *state, int usb_port_number, * The port should be disabled with all pipes closed when this * function is called. * - * @param state USB device state populated by - * cvmx_usb_initialize(). + * @state: USB device state populated by + * cvmx_usb_initialize(). * * @return 0 or a negative error code. */ @@ -850,8 +850,8 @@ int cvmx_usb_shutdown(cvmx_usb_state_t *state) * Enable a USB port. After this call succeeds, the USB port is * online and servicing requests. * - * @param state USB device state populated by - * cvmx_usb_initialize(). + * @state: USB device state populated by + * cvmx_usb_initialize(). * * @return 0 or a negative error code. */ @@ -944,8 +944,8 @@ int cvmx_usb_enable(cvmx_usb_state_t *state) * Transactions in process will fail and call their * associated callbacks. * - * @param state USB device state populated by - * cvmx_usb_initialize(). + * @state: USB device state populated by + * cvmx_usb_initialize(). * * @return 0 or a negative error code. */ @@ -968,8 +968,8 @@ int cvmx_usb_disable(cvmx_usb_state_t *state) * on the last call to cvmx_usb_set_status(). In order to clear * them, you must update the status through cvmx_usb_set_status(). * - * @param state USB device state populated by - * cvmx_usb_initialize(). + * @state: USB device state populated by + * cvmx_usb_initialize(). * * @return Port status information */ @@ -1000,9 +1000,9 @@ cvmx_usb_port_status_t cvmx_usb_get_status(cvmx_usb_state_t *state) * status passed to this function is not used. No fields can be * changed through this call. * - * @param state USB device state populated by + * @state: USB device state populated by * cvmx_usb_initialize(). - * @param port_status + * @port_status: * Port status to set, most like returned by cvmx_usb_get_status() */ void cvmx_usb_set_status(cvmx_usb_state_t *state, cvmx_usb_port_status_t port_status) @@ -1016,9 +1016,9 @@ void cvmx_usb_set_status(cvmx_usb_state_t *state, cvmx_usb_port_status_t port_st /** * Convert a USB transaction into a handle * - * @param usb USB device state populated by + * @usb: USB device state populated by * cvmx_usb_initialize(). - * @param transaction + * @transaction: * Transaction to get handle for * * @return Handle @@ -1034,9 +1034,9 @@ static inline int __cvmx_usb_get_submit_handle(cvmx_usb_internal_state_t *usb, /** * Convert a USB pipe into a handle * - * @param usb USB device state populated by + * @usb: USB device state populated by * cvmx_usb_initialize(). - * @param pipe Pipe to get handle for + * @pipe: Pipe to get handle for * * @return Handle */ @@ -1052,49 +1052,49 @@ static inline int __cvmx_usb_get_pipe_handle(cvmx_usb_internal_state_t *usb, * must be opened before data can be transferred between a device * and Octeon. * - * @param state USB device state populated by + * @state: USB device state populated by * cvmx_usb_initialize(). - * @param flags Optional pipe flags defined in + * @flags: Optional pipe flags defined in * cvmx_usb_pipe_flags_t. - * @param device_addr + * @device_addr: * USB device address to open the pipe to * (0-127). - * @param endpoint_num + * @endpoint_num: * USB endpoint number to open the pipe to * (0-15). - * @param device_speed + * @device_speed: * The speed of the device the pipe is going * to. This must match the device's speed, * which may be different than the port speed. - * @param max_packet The maximum packet length the device can + * @max_packet: The maximum packet length the device can * transmit/receive (low speed=0-8, full * speed=0-1023, high speed=0-1024). This value * comes from the standard endpoint descriptor * field wMaxPacketSize bits <10:0>. - * @param transfer_type + * @transfer_type: * The type of transfer this pipe is for. - * @param transfer_dir + * @transfer_dir: * The direction the pipe is in. This is not * used for control pipes. - * @param interval For ISOCHRONOUS and INTERRUPT transfers, + * @interval: For ISOCHRONOUS and INTERRUPT transfers, * this is how often the transfer is scheduled * for. All other transfers should specify * zero. The units are in frames (8000/sec at * high speed, 1000/sec for full speed). - * @param multi_count + * @multi_count: * For high speed devices, this is the maximum * allowed number of packet per microframe. * Specify zero for non high speed devices. This * value comes from the standard endpoint descriptor * field wMaxPacketSize bits <12:11>. - * @param hub_device_addr + * @hub_device_addr: * Hub device address this device is connected * to. Devices connected directly to Octeon * use zero. This is only used when the device * is full/low speed behind a high speed hub. * The address will be of the high speed hub, * not and full speed hubs after it. - * @param hub_port Which port on the hub the device is + * @hub_port: Which port on the hub the device is * connected. Use zero for devices connected * directly to Octeon. Like hub_device_addr, * this is only used for full/low speed @@ -1191,7 +1191,7 @@ int cvmx_usb_open_pipe(cvmx_usb_state_t *state, cvmx_usb_pipe_flags_t flags, * in non DMA mode. It is very important that this function be called quickly * enough to prevent FIFO overflow. * - * @param usb USB device state populated by + * @usb: USB device state populated by * cvmx_usb_initialize(). */ static void __cvmx_usb_poll_rx_fifo(cvmx_usb_internal_state_t *usb) @@ -1235,10 +1235,10 @@ static void __cvmx_usb_poll_rx_fifo(cvmx_usb_internal_state_t *usb) * Fill the TX hardware fifo with data out of the software * fifos * - * @param usb USB device state populated by + * @usb: USB device state populated by * cvmx_usb_initialize(). - * @param fifo Software fifo to use - * @param available Amount of space in the hardware fifo + * @fifo: Software fifo to use + * @available: Amount of space in the hardware fifo * * @return Non zero if the hardware fifo was too small and needs * to be serviced again. @@ -1294,7 +1294,7 @@ static int __cvmx_usb_fill_tx_hw(cvmx_usb_internal_state_t *usb, cvmx_usb_tx_fif /** * Check the hardware FIFOs and fill them as needed * - * @param usb USB device state populated by + * @usb: USB device state populated by * cvmx_usb_initialize(). */ static void __cvmx_usb_poll_tx_fifo(cvmx_usb_internal_state_t *usb) @@ -1324,9 +1324,9 @@ static void __cvmx_usb_poll_tx_fifo(cvmx_usb_internal_state_t *usb) /** * Fill the TX FIFO with an outgoing packet * - * @param usb USB device state populated by + * @usb: USB device state populated by * cvmx_usb_initialize(). - * @param channel Channel number to get packet from + * @channel: Channel number to get packet from */ static void __cvmx_usb_fill_tx_fifo(cvmx_usb_internal_state_t *usb, int channel) { @@ -1373,10 +1373,10 @@ static void __cvmx_usb_fill_tx_fifo(cvmx_usb_internal_state_t *usb, int channel) * the generic stuff will already have been done in * __cvmx_usb_start_channel() * - * @param usb USB device state populated by + * @usb: USB device state populated by * cvmx_usb_initialize(). - * @param channel Channel to setup - * @param pipe Pipe for control transaction + * @channel: Channel to setup + * @pipe: Pipe for control transaction */ static void __cvmx_usb_start_channel_control(cvmx_usb_internal_state_t *usb, int channel, @@ -1502,10 +1502,10 @@ static void __cvmx_usb_start_channel_control(cvmx_usb_internal_state_t *usb, /** * Start a channel to perform the pipe's head transaction * - * @param usb USB device state populated by + * @usb: USB device state populated by * cvmx_usb_initialize(). - * @param channel Channel to setup - * @param pipe Pipe to start + * @channel: Channel to setup + * @pipe: Pipe to start */ static void __cvmx_usb_start_channel(cvmx_usb_internal_state_t *usb, int channel, @@ -1788,10 +1788,10 @@ static void __cvmx_usb_start_channel(cvmx_usb_internal_state_t *usb, /** * Find a pipe that is ready to be scheduled to hardware. - * @param usb USB device state populated by + * @usb: USB device state populated by * cvmx_usb_initialize(). - * @param list Pipe list to search - * @param current_frame + * @list: Pipe list to search + * @current_frame: * Frame counter to use as a time reference. * * @return Pipe or NULL if none are ready @@ -1818,9 +1818,9 @@ static cvmx_usb_pipe_t *__cvmx_usb_find_ready_pipe(cvmx_usb_internal_state_t *us * Called whenever a pipe might need to be scheduled to the * hardware. * - * @param usb USB device state populated by + * @usb: USB device state populated by * cvmx_usb_initialize(). - * @param is_sof True if this schedule was called on a SOF interrupt. + * @is_sof: True if this schedule was called on a SOF interrupt. */ static void __cvmx_usb_schedule(cvmx_usb_internal_state_t *usb, int is_sof) { @@ -1891,13 +1891,13 @@ static void __cvmx_usb_schedule(cvmx_usb_internal_state_t *usb, int is_sof) /** * Call a user's callback for a specific reason. * - * @param usb USB device state populated by + * @usb: USB device state populated by * cvmx_usb_initialize(). - * @param pipe Pipe the callback is for or NULL - * @param transaction + * @pipe: Pipe the callback is for or NULL + * @transaction: * Transaction the callback is for or NULL - * @param reason Reason this callback is being called - * @param complete_code + * @reason: Reason this callback is being called + * @complete_code: * Completion code for the transaction, if any */ static void __cvmx_usb_perform_callback(cvmx_usb_internal_state_t *usb, @@ -1937,12 +1937,12 @@ static void __cvmx_usb_perform_callback(cvmx_usb_internal_state_t *usb, * Signal the completion of a transaction and free it. The * transaction will be removed from the pipe transaction list. * - * @param usb USB device state populated by + * @usb: USB device state populated by * cvmx_usb_initialize(). - * @param pipe Pipe the transaction is on - * @param transaction + * @pipe: Pipe the transaction is on + * @transaction: * Transaction that completed - * @param complete_code + * @complete_code: * Completion code */ static void __cvmx_usb_perform_complete(cvmx_usb_internal_state_t *usb, @@ -2003,24 +2003,24 @@ static void __cvmx_usb_perform_complete(cvmx_usb_internal_state_t *usb, * Submit a usb transaction to a pipe. Called for all types * of transactions. * - * @param usb - * @param pipe_handle + * @usb: + * @pipe_handle: * Which pipe to submit to. Will be validated in this function. - * @param type Transaction type - * @param flags Flags for the transaction - * @param buffer User buffer for the transaction - * @param buffer_length + * @type: Transaction type + * @flags: Flags for the transaction + * @buffer: User buffer for the transaction + * @buffer_length: * User buffer's length in bytes - * @param control_header + * @control_header: * For control transactions, the 8 byte standard header - * @param iso_start_frame + * @iso_start_frame: * For ISO transactions, the start frame - * @param iso_number_packets + * @iso_number_packets: * For ISO, the number of packet in the transaction. - * @param iso_packets + * @iso_packets: * A description of each ISO packet - * @param callback User callback to call when the transaction completes - * @param user_data User's data for the callback + * @callback: User callback to call when the transaction completes + * @user_data: User's data for the callback * * @return Submit handle or negative on failure. Matches the result * in the external API. @@ -2097,18 +2097,18 @@ static int __cvmx_usb_submit_transaction(cvmx_usb_internal_state_t *usb, /** * Call to submit a USB Bulk transfer to a pipe. * - * @param state USB device state populated by + * @state: USB device state populated by * cvmx_usb_initialize(). - * @param pipe_handle + * @pipe_handle: * Handle to the pipe for the transfer. - * @param buffer Physical address of the data buffer in + * @buffer: Physical address of the data buffer in * memory. Note that this is NOT A POINTER, but * the full 64bit physical address of the * buffer. This may be zero if buffer_length is * zero. - * @param buffer_length + * @buffer_length: * Length of buffer in bytes. - * @param callback Function to call when this transaction + * @callback: Function to call when this transaction * completes. If the return value of this * function isn't an error, then this function * is guaranteed to be called when the @@ -2117,7 +2117,7 @@ static int __cvmx_usb_submit_transaction(cvmx_usb_internal_state_t *usb, * through cvmx_usb_register_callback is * called. If both are NULL, then there is no * way to know when a transaction completes. - * @param user_data User supplied data returned when the + * @user_data: User supplied data returned when the * callback is called. This is only used if * callback in not NULL. * @@ -2156,18 +2156,18 @@ int cvmx_usb_submit_bulk(cvmx_usb_state_t *state, int pipe_handle, /** * Call to submit a USB Interrupt transfer to a pipe. * - * @param state USB device state populated by + * @state: USB device state populated by * cvmx_usb_initialize(). - * @param pipe_handle + * @pipe_handle: * Handle to the pipe for the transfer. - * @param buffer Physical address of the data buffer in + * @buffer: Physical address of the data buffer in * memory. Note that this is NOT A POINTER, but * the full 64bit physical address of the * buffer. This may be zero if buffer_length is * zero. - * @param buffer_length + * @buffer_length: * Length of buffer in bytes. - * @param callback Function to call when this transaction + * @callback: Function to call when this transaction * completes. If the return value of this * function isn't an error, then this function * is guaranteed to be called when the @@ -2176,7 +2176,7 @@ int cvmx_usb_submit_bulk(cvmx_usb_state_t *state, int pipe_handle, * through cvmx_usb_register_callback is * called. If both are NULL, then there is no * way to know when a transaction completes. - * @param user_data User supplied data returned when the + * @user_data: User supplied data returned when the * callback is called. This is only used if * callback in not NULL. * @@ -2215,22 +2215,22 @@ int cvmx_usb_submit_interrupt(cvmx_usb_state_t *state, int pipe_handle, /** * Call to submit a USB Control transfer to a pipe. * - * @param state USB device state populated by + * @state: USB device state populated by * cvmx_usb_initialize(). - * @param pipe_handle + * @pipe_handle: * Handle to the pipe for the transfer. - * @param control_header + * @control_header: * USB 8 byte control header physical address. * Note that this is NOT A POINTER, but the * full 64bit physical address of the buffer. - * @param buffer Physical address of the data buffer in + * @buffer: Physical address of the data buffer in * memory. Note that this is NOT A POINTER, but * the full 64bit physical address of the * buffer. This may be zero if buffer_length is * zero. - * @param buffer_length + * @buffer_length: * Length of buffer in bytes. - * @param callback Function to call when this transaction + * @callback: Function to call when this transaction * completes. If the return value of this * function isn't an error, then this function * is guaranteed to be called when the @@ -2239,7 +2239,7 @@ int cvmx_usb_submit_interrupt(cvmx_usb_state_t *state, int pipe_handle, * through cvmx_usb_register_callback is * called. If both are NULL, then there is no * way to know when a transaction completes. - * @param user_data User supplied data returned when the + * @user_data: User supplied data returned when the * callback is called. This is only used if * callback in not NULL. * @@ -2285,32 +2285,32 @@ int cvmx_usb_submit_control(cvmx_usb_state_t *state, int pipe_handle, /** * Call to submit a USB Isochronous transfer to a pipe. * - * @param state USB device state populated by + * @state: USB device state populated by * cvmx_usb_initialize(). - * @param pipe_handle + * @pipe_handle: * Handle to the pipe for the transfer. - * @param start_frame + * @start_frame: * Number of frames into the future to schedule * this transaction. - * @param flags Flags to control the transfer. See + * @flags: Flags to control the transfer. See * cvmx_usb_isochronous_flags_t for the flag * definitions. - * @param number_packets + * @number_packets: * Number of sequential packets to transfer. * "packets" is a pointer to an array of this * many packet structures. - * @param packets Description of each transfer packet as + * @packets: Description of each transfer packet as * defined by cvmx_usb_iso_packet_t. The array * pointed to here must stay valid until the * complete callback is called. - * @param buffer Physical address of the data buffer in + * @buffer: Physical address of the data buffer in * memory. Note that this is NOT A POINTER, but * the full 64bit physical address of the * buffer. This may be zero if buffer_length is * zero. - * @param buffer_length + * @buffer_length: * Length of buffer in bytes. - * @param callback Function to call when this transaction + * @callback: Function to call when this transaction * completes. If the return value of this * function isn't an error, then this function * is guaranteed to be called when the @@ -2319,7 +2319,7 @@ int cvmx_usb_submit_control(cvmx_usb_state_t *state, int pipe_handle, * through cvmx_usb_register_callback is * called. If both are NULL, then there is no * way to know when a transaction completes. - * @param user_data User supplied data returned when the + * @user_data: User supplied data returned when the * callback is called. This is only used if * callback in not NULL. * @@ -2373,11 +2373,11 @@ int cvmx_usb_submit_isochronous(cvmx_usb_state_t *state, int pipe_handle, * a frame or two for the cvmx_usb_poll() function to call the * associated callback. * - * @param state USB device state populated by + * @state: USB device state populated by * cvmx_usb_initialize(). - * @param pipe_handle + * @pipe_handle: * Pipe handle to cancel requests in. - * @param submit_handle + * @submit_handle: * Handle to transaction to cancel, returned by the submit function. * * @return 0 or a negative error code. @@ -2432,9 +2432,9 @@ int cvmx_usb_cancel(cvmx_usb_state_t *state, int pipe_handle, int submit_handle) * Cancel all outstanding requests in a pipe. Logically all this * does is call cvmx_usb_cancel() in a loop. * - * @param state USB device state populated by + * @state: USB device state populated by * cvmx_usb_initialize(). - * @param pipe_handle + * @pipe_handle: * Pipe handle to cancel requests in. * * @return 0 or a negative error code. @@ -2465,9 +2465,9 @@ int cvmx_usb_cancel_all(cvmx_usb_state_t *state, int pipe_handle) /** * Close a pipe created with cvmx_usb_open_pipe(). * - * @param state USB device state populated by + * @state: USB device state populated by * cvmx_usb_initialize(). - * @param pipe_handle + * @pipe_handle: * Pipe handle to close. * * @return 0 or a negative error code. EBUSY is returned if the pipe has @@ -2500,11 +2500,11 @@ int cvmx_usb_close_pipe(cvmx_usb_state_t *state, int pipe_handle) /** * Register a function to be called when various USB events occur. * - * @param state USB device state populated by - * cvmx_usb_initialize(). - * @param reason Which event to register for. - * @param callback Function to call when the event occurs. - * @param user_data User data parameter to the function. + * @state: USB device state populated by + * cvmx_usb_initialize(). + * @reason: Which event to register for. + * @callback: Function to call when the event occurs. + * @user_data: User data parameter to the function. * * @return 0 or a negative error code. */ @@ -2531,8 +2531,8 @@ int cvmx_usb_register_callback(cvmx_usb_state_t *state, * Get the current USB protocol level frame number. The frame * number is always in the range of 0-0x7ff. * - * @param state USB device state populated by - * cvmx_usb_initialize(). + * @state: USB device state populated by + * cvmx_usb_initialize(). * * @return USB frame number */ @@ -2552,8 +2552,8 @@ int cvmx_usb_get_frame_number(cvmx_usb_state_t *state) /** * Poll a channel for status * - * @param usb USB device - * @param channel Channel to poll + * @usb: USB device + * @channel: Channel to poll * * @return Zero on success */ @@ -2989,7 +2989,7 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel) * handler for the USB controller. It can also be called * periodically in a loop for non-interrupt based operation. * - * @param state USB device state populated by + * @state: USB device state populated by * cvmx_usb_initialize(). * * @return 0 or a negative error code. -- GitLab From 46e0270c25dd5b0ca2616db3b274031e7c79188e Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Mon, 29 Jul 2013 20:07:58 +0300 Subject: [PATCH 346/942] staging: octeon-usb: cvmx-usb: convert @return Convert "@return" to "Returns: ". Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/cvmx-usb.c | 72 +++++++++++++-------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/drivers/staging/octeon-usb/cvmx-usb.c b/drivers/staging/octeon-usb/cvmx-usb.c index 9a7b53ab0b210..a3ac3406ea71b 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.c +++ b/drivers/staging/octeon-usb/cvmx-usb.c @@ -265,7 +265,7 @@ static int octeon_usb_get_clock_type(void) * @usb: USB block this access is for * @address: 64bit address to read * - * @return Result of the read + * Returns: Result of the read */ static inline uint32_t __cvmx_usb_read_csr32(cvmx_usb_internal_state_t *usb, uint64_t address) @@ -299,7 +299,7 @@ static inline void __cvmx_usb_write_csr32(cvmx_usb_internal_state_t *usb, * @usb: USB block this access is for * @address: 64bit address to read * - * @return Result of the read + * Returns: Result of the read */ static inline uint64_t __cvmx_usb_read_csr64(cvmx_usb_internal_state_t *usb, uint64_t address) @@ -330,7 +330,7 @@ static inline void __cvmx_usb_write_csr64(cvmx_usb_internal_state_t *usb, * @usb: USB block this access is for * @pipe: Pipe to check * - * @return Non zero if we need to do split transactions + * Returns: Non zero if we need to do split transactions */ static inline int __cvmx_usb_pipe_needs_split(cvmx_usb_internal_state_t *usb, cvmx_usb_pipe_t *pipe) { @@ -343,7 +343,7 @@ static inline int __cvmx_usb_pipe_needs_split(cvmx_usb_internal_state_t *usb, cv * * @pipe: pipe to check * - * @return PID for pipe + * Returns: PID for pipe */ static inline int __cvmx_usb_get_data_pid(cvmx_usb_pipe_t *pipe) { @@ -362,7 +362,7 @@ static inline int __cvmx_usb_get_data_pid(cvmx_usb_pipe_t *pipe) * cvmx_usb_initialize() must be called on independent * cvmx_usb_state_t structures. * - * @return Number of port, zero if usb isn't supported + * Returns: Number of port, zero if usb isn't supported */ int cvmx_usb_get_num_ports(void) { @@ -391,7 +391,7 @@ int cvmx_usb_get_num_ports(void) * @usb: USB device state populated by * cvmx_usb_initialize(). * - * @return Transaction or NULL + * Returns: Transaction or NULL */ static inline cvmx_usb_transaction_t *__cvmx_usb_alloc_transaction(cvmx_usb_internal_state_t *usb) { @@ -491,7 +491,7 @@ static inline void __cvmx_usb_remove_pipe(cvmx_usb_pipe_list_t *list, cvmx_usb_p * cvmx_usb_initialize_flags_t for the flag * definitions. Some flags are mandatory. * - * @return 0 or a negative error code. + * Returns: 0 or a negative error code. */ int cvmx_usb_initialize(cvmx_usb_state_t *state, int usb_port_number, cvmx_usb_initialize_flags_t flags) @@ -818,7 +818,7 @@ int cvmx_usb_initialize(cvmx_usb_state_t *state, int usb_port_number, * @state: USB device state populated by * cvmx_usb_initialize(). * - * @return 0 or a negative error code. + * Returns: 0 or a negative error code. */ int cvmx_usb_shutdown(cvmx_usb_state_t *state) { @@ -853,7 +853,7 @@ int cvmx_usb_shutdown(cvmx_usb_state_t *state) * @state: USB device state populated by * cvmx_usb_initialize(). * - * @return 0 or a negative error code. + * Returns: 0 or a negative error code. */ int cvmx_usb_enable(cvmx_usb_state_t *state) { @@ -947,7 +947,7 @@ int cvmx_usb_enable(cvmx_usb_state_t *state) * @state: USB device state populated by * cvmx_usb_initialize(). * - * @return 0 or a negative error code. + * Returns: 0 or a negative error code. */ int cvmx_usb_disable(cvmx_usb_state_t *state) { @@ -971,7 +971,7 @@ int cvmx_usb_disable(cvmx_usb_state_t *state) * @state: USB device state populated by * cvmx_usb_initialize(). * - * @return Port status information + * Returns: Port status information */ cvmx_usb_port_status_t cvmx_usb_get_status(cvmx_usb_state_t *state) { @@ -1021,7 +1021,7 @@ void cvmx_usb_set_status(cvmx_usb_state_t *state, cvmx_usb_port_status_t port_st * @transaction: * Transaction to get handle for * - * @return Handle + * Returns: Handle */ static inline int __cvmx_usb_get_submit_handle(cvmx_usb_internal_state_t *usb, cvmx_usb_transaction_t *transaction) @@ -1038,7 +1038,7 @@ static inline int __cvmx_usb_get_submit_handle(cvmx_usb_internal_state_t *usb, * cvmx_usb_initialize(). * @pipe: Pipe to get handle for * - * @return Handle + * Returns: Handle */ static inline int __cvmx_usb_get_pipe_handle(cvmx_usb_internal_state_t *usb, cvmx_usb_pipe_t *pipe) @@ -1100,8 +1100,8 @@ static inline int __cvmx_usb_get_pipe_handle(cvmx_usb_internal_state_t *usb, * this is only used for full/low speed * devices behind a high speed hub. * - * @return A non negative value is a pipe handle. Negative - * values are error codes. + * Returns: A non negative value is a pipe handle. Negative + * values are error codes. */ int cvmx_usb_open_pipe(cvmx_usb_state_t *state, cvmx_usb_pipe_flags_t flags, int device_addr, int endpoint_num, @@ -1240,8 +1240,8 @@ static void __cvmx_usb_poll_rx_fifo(cvmx_usb_internal_state_t *usb) * @fifo: Software fifo to use * @available: Amount of space in the hardware fifo * - * @return Non zero if the hardware fifo was too small and needs - * to be serviced again. + * Returns: Non zero if the hardware fifo was too small and needs + * to be serviced again. */ static int __cvmx_usb_fill_tx_hw(cvmx_usb_internal_state_t *usb, cvmx_usb_tx_fifo_t *fifo, int available) { @@ -1794,7 +1794,7 @@ static void __cvmx_usb_start_channel(cvmx_usb_internal_state_t *usb, * @current_frame: * Frame counter to use as a time reference. * - * @return Pipe or NULL if none are ready + * Returns: Pipe or NULL if none are ready */ static cvmx_usb_pipe_t *__cvmx_usb_find_ready_pipe(cvmx_usb_internal_state_t *usb, cvmx_usb_pipe_list_t *list, uint64_t current_frame) { @@ -2022,8 +2022,8 @@ static void __cvmx_usb_perform_complete(cvmx_usb_internal_state_t *usb, * @callback: User callback to call when the transaction completes * @user_data: User's data for the callback * - * @return Submit handle or negative on failure. Matches the result - * in the external API. + * Returns: Submit handle or negative on failure. Matches the result + * in the external API. */ static int __cvmx_usb_submit_transaction(cvmx_usb_internal_state_t *usb, int pipe_handle, @@ -2121,8 +2121,8 @@ static int __cvmx_usb_submit_transaction(cvmx_usb_internal_state_t *usb, * callback is called. This is only used if * callback in not NULL. * - * @return A submitted transaction handle or negative on - * failure. Negative values are error codes. + * Returns: A submitted transaction handle or negative on + * failure. Negative values are error codes. */ int cvmx_usb_submit_bulk(cvmx_usb_state_t *state, int pipe_handle, uint64_t buffer, int buffer_length, @@ -2180,8 +2180,8 @@ int cvmx_usb_submit_bulk(cvmx_usb_state_t *state, int pipe_handle, * callback is called. This is only used if * callback in not NULL. * - * @return A submitted transaction handle or negative on - * failure. Negative values are error codes. + * Returns: A submitted transaction handle or negative on + * failure. Negative values are error codes. */ int cvmx_usb_submit_interrupt(cvmx_usb_state_t *state, int pipe_handle, uint64_t buffer, int buffer_length, @@ -2243,8 +2243,8 @@ int cvmx_usb_submit_interrupt(cvmx_usb_state_t *state, int pipe_handle, * callback is called. This is only used if * callback in not NULL. * - * @return A submitted transaction handle or negative on - * failure. Negative values are error codes. + * Returns: A submitted transaction handle or negative on + * failure. Negative values are error codes. */ int cvmx_usb_submit_control(cvmx_usb_state_t *state, int pipe_handle, uint64_t control_header, @@ -2323,8 +2323,8 @@ int cvmx_usb_submit_control(cvmx_usb_state_t *state, int pipe_handle, * callback is called. This is only used if * callback in not NULL. * - * @return A submitted transaction handle or negative on - * failure. Negative values are error codes. + * Returns: A submitted transaction handle or negative on + * failure. Negative values are error codes. */ int cvmx_usb_submit_isochronous(cvmx_usb_state_t *state, int pipe_handle, int start_frame, int flags, @@ -2380,7 +2380,7 @@ int cvmx_usb_submit_isochronous(cvmx_usb_state_t *state, int pipe_handle, * @submit_handle: * Handle to transaction to cancel, returned by the submit function. * - * @return 0 or a negative error code. + * Returns: 0 or a negative error code. */ int cvmx_usb_cancel(cvmx_usb_state_t *state, int pipe_handle, int submit_handle) { @@ -2437,7 +2437,7 @@ int cvmx_usb_cancel(cvmx_usb_state_t *state, int pipe_handle, int submit_handle) * @pipe_handle: * Pipe handle to cancel requests in. * - * @return 0 or a negative error code. + * Returns: 0 or a negative error code. */ int cvmx_usb_cancel_all(cvmx_usb_state_t *state, int pipe_handle) { @@ -2470,8 +2470,8 @@ int cvmx_usb_cancel_all(cvmx_usb_state_t *state, int pipe_handle) * @pipe_handle: * Pipe handle to close. * - * @return 0 or a negative error code. EBUSY is returned if the pipe has - * outstanding transfers. + * Returns: 0 or a negative error code. EBUSY is returned if the pipe has + * outstanding transfers. */ int cvmx_usb_close_pipe(cvmx_usb_state_t *state, int pipe_handle) { @@ -2506,7 +2506,7 @@ int cvmx_usb_close_pipe(cvmx_usb_state_t *state, int pipe_handle) * @callback: Function to call when the event occurs. * @user_data: User data parameter to the function. * - * @return 0 or a negative error code. + * Returns: 0 or a negative error code. */ int cvmx_usb_register_callback(cvmx_usb_state_t *state, cvmx_usb_callback_t reason, @@ -2534,7 +2534,7 @@ int cvmx_usb_register_callback(cvmx_usb_state_t *state, * @state: USB device state populated by * cvmx_usb_initialize(). * - * @return USB frame number + * Returns: USB frame number */ int cvmx_usb_get_frame_number(cvmx_usb_state_t *state) { @@ -2555,7 +2555,7 @@ int cvmx_usb_get_frame_number(cvmx_usb_state_t *state) * @usb: USB device * @channel: Channel to poll * - * @return Zero on success + * Returns: Zero on success */ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel) { @@ -2992,7 +2992,7 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel) * @state: USB device state populated by * cvmx_usb_initialize(). * - * @return 0 or a negative error code. + * Returns: 0 or a negative error code. */ int cvmx_usb_poll(cvmx_usb_state_t *state) { -- GitLab From 3d1dc6adf09fa0d49625da72d39c179ab9d1e893 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Mon, 29 Jul 2013 20:07:59 +0300 Subject: [PATCH 347/942] staging: octeon-usb: cvmx-usb: delete CVS keyword markers Delete CVS keyword markers. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/cvmx-usb.c | 2 -- drivers/staging/octeon-usb/cvmx-usb.h | 2 -- 2 files changed, 4 deletions(-) diff --git a/drivers/staging/octeon-usb/cvmx-usb.c b/drivers/staging/octeon-usb/cvmx-usb.c index a3ac3406ea71b..fa029e3f8db13 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.c +++ b/drivers/staging/octeon-usb/cvmx-usb.c @@ -46,8 +46,6 @@ * systems. These functions provide a generic API to the Octeon * USB blocks, hiding the internal hardware specific * operations. - * - *
$Revision: 32636 $
*/ #include #include diff --git a/drivers/staging/octeon-usb/cvmx-usb.h b/drivers/staging/octeon-usb/cvmx-usb.h index 30d7213ed19e9..b8e9054da637a 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.h +++ b/drivers/staging/octeon-usb/cvmx-usb.h @@ -234,8 +234,6 @@ * * If you aren't using interrupts, simple call cvmx_usb_poll() * in your main processing loop. - * - *
$Revision: 32636 $
*/ #ifndef __CVMX_USB_H__ -- GitLab From 12aede9f2f8c77f3615fabb4a32bacea5eda848a Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Mon, 29 Jul 2013 20:08:00 +0300 Subject: [PATCH 348/942] staging: octeon-usb: cvmx-usb: reformat documentation Reformat the high-level documentation to human readable plain text by removing HTML and other tags. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/cvmx-usb.h | 101 ++++++++++++-------------- 1 file changed, 48 insertions(+), 53 deletions(-) diff --git a/drivers/staging/octeon-usb/cvmx-usb.h b/drivers/staging/octeon-usb/cvmx-usb.h index b8e9054da637a..4b425e5fa8ae5 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.h +++ b/drivers/staging/octeon-usb/cvmx-usb.h @@ -39,8 +39,6 @@ /** - * @file - * * "cvmx-usb.h" defines a set of low level USB functions to help * developers create Octeon USB drivers for various operating * systems. These functions provide a generic API to the Octeon @@ -49,24 +47,24 @@ * * At a high level the device driver needs to: * - * -# Call cvmx_usb_get_num_ports() to get the number of - * supported ports. - * -# Call cvmx_usb_initialize() for each Octeon USB port. - * -# Enable the port using cvmx_usb_enable(). - * -# Either periodically, or in an interrupt handler, call - * cvmx_usb_poll() to service USB events. - * -# Manage pipes using cvmx_usb_open_pipe() and - * cvmx_usb_close_pipe(). - * -# Manage transfers using cvmx_usb_submit_*() and - * cvmx_usb_cancel*(). - * -# Shutdown USB on unload using cvmx_usb_shutdown(). + * - Call cvmx_usb_get_num_ports() to get the number of + * supported ports. + * - Call cvmx_usb_initialize() for each Octeon USB port. + * - Enable the port using cvmx_usb_enable(). + * - Either periodically, or in an interrupt handler, call + * cvmx_usb_poll() to service USB events. + * - Manage pipes using cvmx_usb_open_pipe() and + * cvmx_usb_close_pipe(). + * - Manage transfers using cvmx_usb_submit_*() and + * cvmx_usb_cancel*(). + * - Shutdown USB on unload using cvmx_usb_shutdown(). * * To monitor USB status changes, the device driver must use * cvmx_usb_register_callback() to register for events that it * is interested in. Below are a few hints on successfully * implementing a driver on top of this API. * - *

Initialization

+ * == Initialization == * * When a driver is first loaded, it is normally not necessary * to bring up the USB port completely. Most operating systems @@ -75,24 +73,24 @@ * initialize anything found, and then enable the hardware. * * In the probe phase you should: - * -# Use cvmx_usb_get_num_ports() to determine the number of - * USB port to be supported. - * -# Allocate space for a cvmx_usb_state_t structure for each - * port. - * -# Tell the operating system about each port + * - Use cvmx_usb_get_num_ports() to determine the number of + * USB port to be supported. + * - Allocate space for a cvmx_usb_state_t structure for each + * port. + * - Tell the operating system about each port * * In the initialization phase you should: - * -# Use cvmx_usb_initialize() on each port. - * -# Do not call cvmx_usb_enable(). This leaves the USB port in - * the disabled state until the operating system is ready. + * - Use cvmx_usb_initialize() on each port. + * - Do not call cvmx_usb_enable(). This leaves the USB port in + * the disabled state until the operating system is ready. * * Finally, in the enable phase you should: - * -# Call cvmx_usb_enable() on the appropriate port. - * -# Note that some operating system use a RESET instead of an - * enable call. To implement RESET, you should call - * cvmx_usb_disable() followed by cvmx_usb_enable(). + * - Call cvmx_usb_enable() on the appropriate port. + * - Note that some operating system use a RESET instead of an + * enable call. To implement RESET, you should call + * cvmx_usb_disable() followed by cvmx_usb_enable(). * - *

Locking

+ * == Locking == * * All of the functions in the cvmx-usb API assume exclusive * access to the USB hardware and internal data structures. This @@ -112,7 +110,7 @@ * take a lock to make sure that another core cannot call * cvmx-usb. * - *

Port callback

+ * == Port callback == * * The port callback prototype needs to look as follows: * @@ -123,14 +121,13 @@ * int submit_handle, * int bytes_transferred, * void *user_data); - * - @b usb is the cvmx_usb_state_t for the port. - * - @b reason will always be - * CVMX_USB_CALLBACK_PORT_CHANGED. - * - @b status will always be CVMX_USB_COMPLETE_SUCCESS. - * - @b pipe_handle will always be -1. - * - @b submit_handle will always be -1. - * - @b bytes_transferred will always be 0. - * - @b user_data is the void pointer originally passed along + * - "usb" is the cvmx_usb_state_t for the port. + * - "reason" will always be CVMX_USB_CALLBACK_PORT_CHANGED. + * - "status" will always be CVMX_USB_COMPLETE_SUCCESS. + * - "pipe_handle" will always be -1. + * - "submit_handle" will always be -1. + * - "bytes_transferred" will always be 0. + * - "user_data" is the void pointer originally passed along * with the callback. Use this for any state information you * need. * @@ -140,12 +137,12 @@ * root port. Normally all the callback needs to do is tell the * operating system to poll the root hub for status. Under * Linux, this is performed by calling usb_hcd_poll_rh_status(). - * In the Linux driver we use @b user_data. to pass around the + * In the Linux driver we use "user_data". to pass around the * Linux "hcd" structure. Once the port callback completes, * Linux automatically calls octeon_usb_hub_status_data() which * uses cvmx_usb_get_status() to determine the root port status. * - *

Complete callback

+ * == Complete callback == * * The completion callback prototype needs to look as follows: * @@ -156,29 +153,27 @@ * int submit_handle, * int bytes_transferred, * void *user_data); - * - @b usb is the cvmx_usb_state_t for the port. - * - @b reason will always be - * CVMX_USB_CALLBACK_TRANSFER_COMPLETE. - * - @b status will be one of the cvmx_usb_complete_t - * enumerations. - * - @b pipe_handle is the handle to the pipe the transaction + * - "usb" is the cvmx_usb_state_t for the port. + * - "reason" will always be CVMX_USB_CALLBACK_TRANSFER_COMPLETE. + * - "status" will be one of the cvmx_usb_complete_t enumerations. + * - "pipe_handle" is the handle to the pipe the transaction * was originally submitted on. - * - @b submit_handle is the handle returned by the original + * - "submit_handle" is the handle returned by the original * cvmx_usb_submit_* call. - * - @b bytes_transferred is the number of bytes successfully + * - "bytes_transferred" is the number of bytes successfully * transferred in the transaction. This will be zero on most * error conditions. - * - @b user_data is the void pointer originally passed along + * - "user_data" is the void pointer originally passed along * with the callback. Use this for any state information you * need. For example, the Linux "urb" is stored in here in the * Linux driver. * - * In general your callback handler should use @b status and @b - * bytes_transferred to tell the operating system the how the + * In general your callback handler should use "status" and + * "bytes_transferred" to tell the operating system the how the * transaction completed. Normally the pipe is not changed in * this callback. * - *

Canceling transactions

+ * == Canceling transactions == * * When a transaction is cancelled using cvmx_usb_cancel*(), the * actual length of time until the complete callback is called @@ -188,7 +183,7 @@ * these cases, the complete handler will receive * CVMX_USB_COMPLETE_CANCEL. * - *

Handling pipes

+ * == Handling pipes == * * USB "pipes" is a software construct created by this API to * enable the ordering of usb transactions to a device endpoint. @@ -210,7 +205,7 @@ * destroy a pipe for every transaction. A sequence of * transaction to the same endpoint must use the same pipe. * - *

Root Hub

+ * == Root Hub == * * Some operating systems view the usb root port as a normal usb * hub. These systems attempt to control the root hub with @@ -219,7 +214,7 @@ * function to decode standard usb control messages into * equivalent cvmx-usb API calls. * - *

Interrupts

+ * == Interrupts == * * If you plan on using usb interrupts, cvmx_usb_poll() must be * called on every usb interrupt. It will read the usb state, -- GitLab From b9b9b35176316c3fc50ac50da9cf8796fbb7abd5 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 29 Jul 2013 12:27:40 -0700 Subject: [PATCH 349/942] staging: gdm724x: depend on CONFIG_TTY The driver uses the tty layer, so explicitly say that, to prevent randomconfig build errors. Reported-by: Randy Dunlap Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm724x/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/gdm724x/Kconfig b/drivers/staging/gdm724x/Kconfig index 8749e907d9944..0a1f090bbf389 100644 --- a/drivers/staging/gdm724x/Kconfig +++ b/drivers/staging/gdm724x/Kconfig @@ -4,7 +4,7 @@ config LTE_GDM724X tristate "GCT GDM724x LTE support" - depends on NET && USB && m + depends on NET && USB && TTY && m help This driver supports GCT GDM724x LTE chip based USB modem devices. It exposes 4 network devices to be used per PDN and 2 tty devices to be -- GitLab From 1c9962b434e347c4e9875b8eaf41f87665bc0162 Mon Sep 17 00:00:00 2001 From: Li Zefan Date: Wed, 31 Jul 2013 14:29:27 +0800 Subject: [PATCH 350/942] Staging: rtl8192e: add missing single_release() The debug file is opened with single_open(), but there's no single_release(). Signed-off-by: Li Zefan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib_module.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192e/rtllib_module.c b/drivers/staging/rtl8192e/rtllib_module.c index 84ea721d5d8e0..51d46e04d3f51 100644 --- a/drivers/staging/rtl8192e/rtllib_module.c +++ b/drivers/staging/rtl8192e/rtllib_module.c @@ -233,7 +233,8 @@ static const struct file_operations fops = { .open = open_debug_level, .read = seq_read, .llseek = seq_lseek, - .write = write_debug_level + .write = write_debug_level, + .release = single_release, }; int __init rtllib_init(void) -- GitLab From e8e6fda00b834a5c048214d58ca7eb00ddad734c Mon Sep 17 00:00:00 2001 From: Li Zefan Date: Wed, 31 Jul 2013 14:30:13 +0800 Subject: [PATCH 351/942] Staging: rtl8192u/ieee80211: add missing single_release() The debug file is opened with single_open(), but there's no single_release(). Signed-off-by: Li Zefan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211_module.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c index e0870c05a5e01..434c431271834 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c @@ -268,7 +268,8 @@ static const struct file_operations fops = { .open = open_debug_level, .read = seq_read, .llseek = seq_lseek, - .write = write_debug_level + .write = write_debug_level, + .release = single_release, }; int __init ieee80211_debug_init(void) -- GitLab From 7df68962899e667479632217862dd69ea9815238 Mon Sep 17 00:00:00 2001 From: Jens Frederich Date: Tue, 30 Jul 2013 20:11:34 +0200 Subject: [PATCH 352/942] staging: olpc_dcon: provide detailed FB_OLPC_DCON help section The FB_OLPC_DCON help section is to short according to checkpatch.pl. We want more information about the controller type, its task, its video pipeline position and so on. There are no style issues, remove checkpatch.pl TODO entry. Signed-off-by: Jens Frederich Acked-by: Andres Salomon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/olpc_dcon/Kconfig | 11 ++++++++--- drivers/staging/olpc_dcon/TODO | 1 - 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/staging/olpc_dcon/Kconfig b/drivers/staging/olpc_dcon/Kconfig index fe40e0b6f6752..2ff015d845099 100644 --- a/drivers/staging/olpc_dcon/Kconfig +++ b/drivers/staging/olpc_dcon/Kconfig @@ -4,9 +4,14 @@ config FB_OLPC_DCON select I2C select BACKLIGHT_CLASS_DEVICE ---help--- - Add support for the OLPC XO DCON controller. This controller is - only available on OLPC platforms. Unless you have one of these - platforms, you will want to say 'N'. + In order to support very low power operation, the XO laptop uses a + secondary Display CONtroller, or DCON. This secondary controller + is present in the video pipeline between the primary display + controller (integrate into the processor or chipset) and the LCD + panel. It allows the main processor/display controller to be + completely powered off while still retaining an image on the display. + This controller is only available on OLPC platforms. Unless you have + one of these platforms, you will want to say 'N'. config FB_OLPC_DCON_1 bool "OLPC XO-1 DCON support" diff --git a/drivers/staging/olpc_dcon/TODO b/drivers/staging/olpc_dcon/TODO index 35f9cda7be11e..f378e848b51a6 100644 --- a/drivers/staging/olpc_dcon/TODO +++ b/drivers/staging/olpc_dcon/TODO @@ -1,5 +1,4 @@ TODO: - - checkpatch.pl cleanups - see if vx855 gpio API can be made similar enough to cs5535 so we can share more code - allow simultaneous XO-1 and XO-1.5 support -- GitLab From 23cdad3360a39b1b81e1068b1027db25c9e16d97 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 13:48:01 -0700 Subject: [PATCH 353/942] staging: comedi: das16: "timer_mode" is always used for DMA As noted in the driver, a timer is always used by this driver to handle the DMA due to buggy DMA controllers and the lack of a hardware fifo in some of the supported boards. Remove all the non-timer mode specific code. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 95 +++----------------------- 1 file changed, 9 insertions(+), 86 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index 593ec38661468..2dd03da22a2e7 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -387,7 +387,6 @@ struct das16_private_struct { struct timer_list timer; /* for timed interrupt */ volatile short timer_running; - volatile short timer_mode; /* true if using timer mode */ unsigned long extra_iobase; }; @@ -516,49 +515,6 @@ static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s, return 0; } -/* utility function that suggests a dma transfer size in bytes */ -static unsigned int das16_suggest_transfer_size(struct comedi_device *dev, - const struct comedi_cmd *cmd) -{ - struct das16_private_struct *devpriv = dev->private; - unsigned int size; - unsigned int freq; - - /* if we are using timer interrupt, we don't care how long it - * will take to complete transfer since it will be interrupted - * by timer interrupt */ - if (devpriv->timer_mode) - return DAS16_DMA_SIZE; - - /* otherwise, we are relying on dma terminal count interrupt, - * so pick a reasonable size */ - if (cmd->convert_src == TRIG_TIMER) - freq = 1000000000 / cmd->convert_arg; - else if (cmd->scan_begin_src == TRIG_TIMER) - freq = (1000000000 / cmd->scan_begin_arg) * cmd->chanlist_len; - /* return some default value */ - else - freq = 0xffffffff; - - if (cmd->flags & TRIG_WAKE_EOS) { - size = sample_size * cmd->chanlist_len; - } else { - /* make buffer fill in no more than 1/3 second */ - size = (freq / 3) * sample_size; - } - - /* set a minimum and maximum size allowed */ - if (size > DAS16_DMA_SIZE) - size = DAS16_DMA_SIZE - DAS16_DMA_SIZE % sample_size; - else if (size < sample_size) - size = sample_size; - - if (cmd->stop_src == TRIG_COUNT && size > devpriv->adc_byte_count) - size = devpriv->adc_byte_count; - - return size; -} - static unsigned int das16_set_pacer(struct comedi_device *dev, unsigned int ns, int rounding_flags) { @@ -585,13 +541,6 @@ static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s) unsigned long flags; int range; - if (devpriv->dma_chan == 0 || (dev->irq == 0 - && devpriv->timer_mode == 0)) { - comedi_error(dev, - "irq (or use of 'timer mode') dma required to " - "execute comedi_cmd"); - return -1; - } if (cmd->flags & TRIG_RT) { comedi_error(dev, "isa dma transfers cannot be performed with " "TRIG_RT, aborting"); @@ -648,24 +597,16 @@ static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->current_buffer = 0; set_dma_addr(devpriv->dma_chan, devpriv->dma_buffer_addr[devpriv->current_buffer]); - /* set appropriate size of transfer */ - devpriv->dma_transfer_size = das16_suggest_transfer_size(dev, cmd); + devpriv->dma_transfer_size = DAS16_DMA_SIZE; set_dma_count(devpriv->dma_chan, devpriv->dma_transfer_size); enable_dma(devpriv->dma_chan); release_dma_lock(flags); /* set up interrupt */ - if (devpriv->timer_mode) { - devpriv->timer_running = 1; - devpriv->timer.expires = jiffies + timer_period(); - add_timer(&devpriv->timer); - devpriv->control_state &= ~DAS16_INTE; - } else { - /* clear interrupt bit */ - outb(0x00, dev->iobase + DAS16_STATUS); - /* enable interrupts */ - devpriv->control_state |= DAS16_INTE; - } + devpriv->timer_running = 1; + devpriv->timer.expires = jiffies + timer_period(); + add_timer(&devpriv->timer); + devpriv->control_state &= ~DAS16_INTE; devpriv->control_state |= DMA_ENABLE; devpriv->control_state &= ~PACING_MASK; if (cmd->convert_src == TRIG_EXT) @@ -696,7 +637,7 @@ static int das16_cancel(struct comedi_device *dev, struct comedi_subdevice *s) disable_dma(devpriv->dma_chan); /* disable SW timer */ - if (devpriv->timer_mode && devpriv->timer_running) { + if (devpriv->timer_running) { devpriv->timer_running = 0; del_timer(&devpriv->timer); } @@ -864,7 +805,6 @@ static int disable_dma_on_even(struct comedi_device *dev) static void das16_interrupt(struct comedi_device *dev) { - const struct das16_board *board = comedi_board(dev); struct das16_private_struct *devpriv = dev->private; unsigned long dma_flags, spin_flags; struct comedi_subdevice *s = dev->read_subdev; @@ -915,21 +855,12 @@ static void das16_interrupt(struct comedi_device *dev) devpriv->current_buffer = (devpriv->current_buffer + 1) % 2; devpriv->adc_byte_count -= num_bytes; - /* figure out how many bytes for next transfer */ - if (cmd->stop_src == TRIG_COUNT && devpriv->timer_mode == 0 && - devpriv->dma_transfer_size > devpriv->adc_byte_count) - devpriv->dma_transfer_size = devpriv->adc_byte_count; - /* re-enable dma */ if ((async->events & COMEDI_CB_EOA) == 0) { set_dma_addr(devpriv->dma_chan, devpriv->dma_buffer_addr[devpriv->current_buffer]); set_dma_count(devpriv->dma_chan, devpriv->dma_transfer_size); enable_dma(devpriv->dma_chan); - /* reenable conversions for das1600 mode, (stupid hardware) */ - if (board->size > 0x400 && devpriv->timer_mode == 0) - outb(0x00, dev->iobase + DAS1600_CONV); - } release_dma_lock(dma_flags); @@ -1077,20 +1008,15 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) int ret; unsigned int irq; unsigned int dma_chan; - int timer_mode; unsigned long flags; struct comedi_krange *user_ai_range, *user_ao_range; #if 0 irq = it->options[1]; - timer_mode = it->options[8]; #endif /* always use time_mode since using irq can drop samples while * waiting for dma done interrupt (due to hardware limitations) */ irq = 0; - timer_mode = 1; - if (timer_mode) - irq = 0; /* check that clock setting is valid */ if (it->options[3]) { @@ -1214,12 +1140,9 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) user_ao_range->flags = UNIT_volt; } - if (timer_mode) { - init_timer(&(devpriv->timer)); - devpriv->timer.function = das16_timer_interrupt; - devpriv->timer.data = (unsigned long)dev; - } - devpriv->timer_mode = timer_mode ? 1 : 0; + init_timer(&(devpriv->timer)); + devpriv->timer.function = das16_timer_interrupt; + devpriv->timer.data = (unsigned long)dev; ret = comedi_alloc_subdevices(dev, 5); if (ret) -- GitLab From 5589c7cc9f37e929754e0a14b85db7c23a28129f Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 13:48:19 -0700 Subject: [PATCH 354/942] staging: comedi: das16: remove DMA irq support As noted in the driver, a timer is always used by this driver to handle the DMA because samples could be dropped while waiting for the DMA done interrupt. Remove the irq setup code as well as the interrupt handler. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 42 -------------------------- 1 file changed, 42 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index 2dd03da22a2e7..52f98a71c80f1 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -872,24 +872,6 @@ static void das16_interrupt(struct comedi_device *dev) cfc_handle_events(dev, s); } -static irqreturn_t das16_dma_interrupt(int irq, void *d) -{ - int status; - struct comedi_device *dev = d; - - status = inb(dev->iobase + DAS16_STATUS); - - if ((status & DAS16_INT) == 0) { - DEBUG_PRINT("spurious interrupt\n"); - return IRQ_NONE; - } - - /* clear interrupt */ - outb(0x00, dev->iobase + DAS16_STATUS); - das16_interrupt(dev); - return IRQ_HANDLED; -} - static void das16_timer_interrupt(unsigned long arg) { struct comedi_device *dev = (struct comedi_device *)arg; @@ -1006,18 +988,10 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) struct das16_private_struct *devpriv; struct comedi_subdevice *s; int ret; - unsigned int irq; unsigned int dma_chan; unsigned long flags; struct comedi_krange *user_ai_range, *user_ao_range; -#if 0 - irq = it->options[1]; -#endif - /* always use time_mode since using irq can drop samples while - * waiting for dma done interrupt (due to hardware limitations) */ - irq = 0; - /* check that clock setting is valid */ if (it->options[3]) { if (it->options[3] != 0 && @@ -1065,22 +1039,6 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) das1600_mode_detect(dev); } - /* now for the irq */ - if (irq > 1 && irq < 8) { - ret = request_irq(irq, das16_dma_interrupt, 0, - dev->board_name, dev); - - if (ret < 0) - return ret; - dev->irq = irq; - printk(KERN_INFO " ( irq = %u )", irq); - } else if (irq == 0) { - printk(" ( no irq )"); - } else { - printk(" invalid irq\n"); - return -EINVAL; - } - /* initialize dma */ dma_chan = it->options[2]; if (dma_chan == 1 || dma_chan == 3) { -- GitLab From b0926a7afabe49021f4fbed9baac0419ad3aa56a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 13:48:38 -0700 Subject: [PATCH 355/942] staging: comedi: das16: fix DMA init during board attach DMA support is optional in this driver. To enable it, the user passes the desired DMA channel during the board attach. A timer is then used by the driver to periodically get the analog input data from the DMA. Since the DMA support is optional, modify the init code so that it only fails if the DMA channel is unavailable or the DMA buffers can not be allocated. Don't fail just because the user passed an invalid DMA channel (only DMA channels 1 and 3 are valid). Remove the printk() noise about the DMA. Change the printk() when the request_dma() fails into a dev_err(). Move the timer initialization so it's only setup if DMA is available. It's not needed otherwise. Also, only hook up the subdevice command support functions if DMA is available. This allows removing a couple sanity checks in the command support. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 72 ++++++++++++-------------- 1 file changed, 34 insertions(+), 38 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index 52f98a71c80f1..f35aabd960f91 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -633,8 +633,7 @@ static int das16_cancel(struct comedi_device *dev, struct comedi_subdevice *s) /* disable interrupts, dma and pacer clocked conversions */ devpriv->control_state &= ~DAS16_INTE & ~PACING_MASK & ~DMA_ENABLE; outb(devpriv->control_state, dev->iobase + DAS16_CONTROL); - if (devpriv->dma_chan) - disable_dma(devpriv->dma_chan); + disable_dma(devpriv->dma_chan); /* disable SW timer */ if (devpriv->timer_running) { @@ -821,11 +820,6 @@ static void das16_interrupt(struct comedi_device *dev) async = s->async; cmd = &async->cmd; - if (devpriv->dma_chan == 0) { - comedi_error(dev, "interrupt with no dma channel?"); - return; - } - spin_lock_irqsave(&dev->spinlock, spin_flags); if ((devpriv->control_state & DMA_ENABLE) == 0) { spin_unlock_irqrestore(&dev->spinlock, spin_flags); @@ -987,10 +981,10 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) const struct das16_board *board = comedi_board(dev); struct das16_private_struct *devpriv; struct comedi_subdevice *s; + struct comedi_krange *user_ai_range; + struct comedi_krange *user_ao_range; + unsigned int dma_chan = it->options[2]; int ret; - unsigned int dma_chan; - unsigned long flags; - struct comedi_krange *user_ai_range, *user_ao_range; /* check that clock setting is valid */ if (it->options[3]) { @@ -1039,35 +1033,38 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) das1600_mode_detect(dev); } - /* initialize dma */ - dma_chan = it->options[2]; + /* initialize dma */ if (dma_chan == 1 || dma_chan == 3) { - /* allocate dma buffers */ + unsigned long flags; int i; - for (i = 0; i < 2; i++) { - devpriv->dma_buffer[i] = pci_alloc_consistent( - NULL, DAS16_DMA_SIZE, - &devpriv->dma_buffer_addr[i]); - if (devpriv->dma_buffer[i] == NULL) - return -ENOMEM; - } if (request_dma(dma_chan, dev->board_name)) { - printk(KERN_ERR " failed to allocate dma channel %i\n", - dma_chan); + dev_err(dev->class_dev, + "failed to request dma channel %i\n", + dma_chan); return -EINVAL; } devpriv->dma_chan = dma_chan; + + /* allocate dma buffers */ + for (i = 0; i < 2; i++) { + void *p; + + p = pci_alloc_consistent(NULL, DAS16_DMA_SIZE, + &devpriv->dma_buffer_addr[i]); + if (!p) + return -ENOMEM; + devpriv->dma_buffer[i] = p; + } + flags = claim_dma_lock(); disable_dma(devpriv->dma_chan); set_dma_mode(devpriv->dma_chan, DMA_MODE_READ); release_dma_lock(flags); - printk(KERN_INFO " ( dma = %u)\n", dma_chan); - } else if (dma_chan == 0) { - printk(KERN_INFO " ( no dma )\n"); - } else { - printk(KERN_ERR " invalid dma channel\n"); - return -EINVAL; + + init_timer(&(devpriv->timer)); + devpriv->timer.function = das16_timer_interrupt; + devpriv->timer.data = (unsigned long)dev; } /* get any user-defined input range */ @@ -1098,20 +1095,15 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) user_ao_range->flags = UNIT_volt; } - init_timer(&(devpriv->timer)); - devpriv->timer.function = das16_timer_interrupt; - devpriv->timer.data = (unsigned long)dev; - ret = comedi_alloc_subdevices(dev, 5); if (ret) return ret; s = &dev->subdevices[0]; - dev->read_subdev = s; /* ai */ if (board->ai) { s->type = COMEDI_SUBD_AI; - s->subdev_flags = SDF_READABLE | SDF_CMD_READ; + s->subdev_flags = SDF_READABLE; if (devpriv->ai_singleended) { s->n_chan = 16; s->len_chanlist = 16; @@ -1130,10 +1122,14 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->range_table = das16_ai_bip_lranges[board->ai_pg]; } s->insn_read = board->ai; - s->do_cmdtest = das16_cmd_test; - s->do_cmd = das16_cmd_exec; - s->cancel = das16_cancel; - s->munge = das16_ai_munge; + if (devpriv->dma_chan) { + dev->read_subdev = s; + s->subdev_flags |= SDF_CMD_READ; + s->do_cmdtest = das16_cmd_test; + s->do_cmd = das16_cmd_exec; + s->cancel = das16_cancel; + s->munge = das16_ai_munge; + } } else { s->type = COMEDI_SUBD_UNUSED; } -- GitLab From 465e25b5e143a7de07f243d50ee0f265cc132aad Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 13:49:01 -0700 Subject: [PATCH 356/942] staging: comedi: das16: all supported board have analog inputs All the boards supported by this driver have analog inputs and all of then use the same function to handle the (*insn_read) for the subdevice. Remove the 'ai' member from the boardinfo and always initalize the analog input subdevice during the board attach. Tidy up the subdevice init a bit. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 86 +++++++++----------------- 1 file changed, 30 insertions(+), 56 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index f35aabd960f91..0b76af68f957d 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -338,7 +338,6 @@ struct munge_info { struct das16_board { const char *name; - void *ai; unsigned int ai_nbits; unsigned int ai_speed; /* max conversion speed in nanosec */ unsigned int ai_pg; @@ -659,8 +658,10 @@ static void das16_reset(struct comedi_device *dev) outb(0, dev->iobase + DAS16_CNTR_CONTROL); } -static int das16_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int das16_ai_insn_read(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { const struct das16_board *board = comedi_board(dev); struct das16_private_struct *devpriv = dev->private; @@ -1099,39 +1100,34 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (ret) return ret; + /* Analog Input subdevice */ s = &dev->subdevices[0]; - /* ai */ - if (board->ai) { - s->type = COMEDI_SUBD_AI; - s->subdev_flags = SDF_READABLE; - if (devpriv->ai_singleended) { - s->n_chan = 16; - s->len_chanlist = 16; - s->subdev_flags |= SDF_GROUND; - } else { - s->n_chan = 8; - s->len_chanlist = 8; - s->subdev_flags |= SDF_DIFF; - } - s->maxdata = (1 << board->ai_nbits) - 1; - if (devpriv->user_ai_range_table) { /* user defined ai range */ - s->range_table = devpriv->user_ai_range_table; - } else if (devpriv->ai_unipolar) { - s->range_table = das16_ai_uni_lranges[board->ai_pg]; - } else { - s->range_table = das16_ai_bip_lranges[board->ai_pg]; - } - s->insn_read = board->ai; - if (devpriv->dma_chan) { - dev->read_subdev = s; - s->subdev_flags |= SDF_CMD_READ; - s->do_cmdtest = das16_cmd_test; - s->do_cmd = das16_cmd_exec; - s->cancel = das16_cancel; - s->munge = das16_ai_munge; - } + s->type = COMEDI_SUBD_AI; + s->subdev_flags = SDF_READABLE; + if (devpriv->ai_singleended) { + s->subdev_flags |= SDF_GROUND; + s->n_chan = 16; } else { - s->type = COMEDI_SUBD_UNUSED; + s->subdev_flags |= SDF_DIFF; + s->n_chan = 8; + } + s->len_chanlist = s->n_chan; + s->maxdata = (1 << board->ai_nbits) - 1; + if (devpriv->user_ai_range_table) { /* user defined ai range */ + s->range_table = devpriv->user_ai_range_table; + } else if (devpriv->ai_unipolar) { + s->range_table = das16_ai_uni_lranges[board->ai_pg]; + } else { + s->range_table = das16_ai_bip_lranges[board->ai_pg]; + } + s->insn_read = das16_ai_insn_read; + if (devpriv->dma_chan) { + dev->read_subdev = s; + s->subdev_flags |= SDF_CMD_READ; + s->do_cmdtest = das16_cmd_test; + s->do_cmd = das16_cmd_exec; + s->cancel = das16_cancel; + s->munge = das16_ai_munge; } s = &dev->subdevices[1]; @@ -1232,7 +1228,6 @@ static void das16_detach(struct comedi_device *dev) static const struct das16_board das16_boards[] = { { .name = "das-16", - .ai = das16_ai_rinsn, .ai_nbits = 12, .ai_speed = 15000, .ai_pg = das16_pg_none, @@ -1246,7 +1241,6 @@ static const struct das16_board das16_boards[] = { .id = 0x00, }, { .name = "das-16g", - .ai = das16_ai_rinsn, .ai_nbits = 12, .ai_speed = 15000, .ai_pg = das16_pg_none, @@ -1260,7 +1254,6 @@ static const struct das16_board das16_boards[] = { .id = 0x00, }, { .name = "das-16f", - .ai = das16_ai_rinsn, .ai_nbits = 12, .ai_speed = 8500, .ai_pg = das16_pg_none, @@ -1274,7 +1267,6 @@ static const struct das16_board das16_boards[] = { .id = 0x00, }, { .name = "cio-das16", - .ai = das16_ai_rinsn, .ai_nbits = 12, .ai_speed = 20000, .ai_pg = das16_pg_none, @@ -1288,7 +1280,6 @@ static const struct das16_board das16_boards[] = { .id = 0x80, }, { .name = "cio-das16/f", - .ai = das16_ai_rinsn, .ai_nbits = 12, .ai_speed = 10000, .ai_pg = das16_pg_none, @@ -1302,7 +1293,6 @@ static const struct das16_board das16_boards[] = { .id = 0x80, }, { .name = "cio-das16/jr", - .ai = das16_ai_rinsn, .ai_nbits = 12, .ai_speed = 7692, .ai_pg = das16_pg_16jr, @@ -1315,7 +1305,6 @@ static const struct das16_board das16_boards[] = { .id = 0x00, }, { .name = "pc104-das16jr", - .ai = das16_ai_rinsn, .ai_nbits = 12, .ai_speed = 3300, .ai_pg = das16_pg_16jr, @@ -1328,7 +1317,6 @@ static const struct das16_board das16_boards[] = { .id = 0x00, }, { .name = "cio-das16jr/16", - .ai = das16_ai_rinsn, .ai_nbits = 16, .ai_speed = 10000, .ai_pg = das16_pg_16jr_16, @@ -1341,7 +1329,6 @@ static const struct das16_board das16_boards[] = { .id = 0x00, }, { .name = "pc104-das16jr/16", - .ai = das16_ai_rinsn, .ai_nbits = 16, .ai_speed = 10000, .ai_pg = das16_pg_16jr_16, @@ -1354,7 +1341,6 @@ static const struct das16_board das16_boards[] = { .id = 0x00, }, { .name = "das-1201", - .ai = das16_ai_rinsn, .ai_nbits = 12, .ai_speed = 20000, .ai_pg = das16_pg_none, @@ -1367,7 +1353,6 @@ static const struct das16_board das16_boards[] = { .id = 0x20, }, { .name = "das-1202", - .ai = das16_ai_rinsn, .ai_nbits = 12, .ai_speed = 10000, .ai_pg = das16_pg_none, @@ -1380,7 +1365,6 @@ static const struct das16_board das16_boards[] = { .id = 0x20, }, { .name = "das-1401", - .ai = das16_ai_rinsn, .ai_nbits = 12, .ai_speed = 10000, .ai_pg = das16_pg_1601, @@ -1393,7 +1377,6 @@ static const struct das16_board das16_boards[] = { .id = 0xc0, }, { .name = "das-1402", - .ai = das16_ai_rinsn, .ai_nbits = 12, .ai_speed = 10000, .ai_pg = das16_pg_1602, @@ -1406,7 +1389,6 @@ static const struct das16_board das16_boards[] = { .id = 0xc0, }, { .name = "das-1601", - .ai = das16_ai_rinsn, .ai_nbits = 12, .ai_speed = 10000, .ai_pg = das16_pg_1601, @@ -1420,7 +1402,6 @@ static const struct das16_board das16_boards[] = { .id = 0xc0, }, { .name = "das-1602", - .ai = das16_ai_rinsn, .ai_nbits = 12, .ai_speed = 10000, .ai_pg = das16_pg_1602, @@ -1434,7 +1415,6 @@ static const struct das16_board das16_boards[] = { .id = 0xc0, }, { .name = "cio-das1401/12", - .ai = das16_ai_rinsn, .ai_nbits = 12, .ai_speed = 6250, .ai_pg = das16_pg_1601, @@ -1447,7 +1427,6 @@ static const struct das16_board das16_boards[] = { .id = 0xc0, }, { .name = "cio-das1402/12", - .ai = das16_ai_rinsn, .ai_nbits = 12, .ai_speed = 6250, .ai_pg = das16_pg_1602, @@ -1460,7 +1439,6 @@ static const struct das16_board das16_boards[] = { .id = 0xc0, }, { .name = "cio-das1402/16", - .ai = das16_ai_rinsn, .ai_nbits = 16, .ai_speed = 10000, .ai_pg = das16_pg_1602, @@ -1473,7 +1451,6 @@ static const struct das16_board das16_boards[] = { .id = 0xc0, }, { .name = "cio-das1601/12", - .ai = das16_ai_rinsn, .ai_nbits = 12, .ai_speed = 6250, .ai_pg = das16_pg_1601, @@ -1487,7 +1464,6 @@ static const struct das16_board das16_boards[] = { .id = 0xc0, }, { .name = "cio-das1602/12", - .ai = das16_ai_rinsn, .ai_nbits = 12, .ai_speed = 10000, .ai_pg = das16_pg_1602, @@ -1501,7 +1477,6 @@ static const struct das16_board das16_boards[] = { .id = 0xc0, }, { .name = "cio-das1602/16", - .ai = das16_ai_rinsn, .ai_nbits = 16, .ai_speed = 10000, .ai_pg = das16_pg_1602, @@ -1515,7 +1490,6 @@ static const struct das16_board das16_boards[] = { .id = 0xc0, }, { .name = "cio-das16/330", - .ai = das16_ai_rinsn, .ai_nbits = 12, .ai_speed = 3030, .ai_pg = das16_pg_16jr, -- GitLab From 0dc7c5db134dcd216003ea1be2b7b93a5169ea26 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 13:49:21 -0700 Subject: [PATCH 357/942] staging: comedi: das16: change boardinfo 'ai_nbits' to 'ai_maxdata' The subdevice functions that used this boardinfo can use the subdevice 's->maxdata' value instead. Tidy up those functions. Change the boardinfo so that the calculation is not needed during the attach. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 71 +++++++++++++------------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index 0b76af68f957d..11e5787dd27ef 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -338,7 +338,7 @@ struct munge_info { struct das16_board { const char *name; - unsigned int ai_nbits; + unsigned int ai_maxdata; unsigned int ai_speed; /* max conversion speed in nanosec */ unsigned int ai_pg; void *ao; @@ -668,7 +668,6 @@ static int das16_ai_insn_read(struct comedi_device *dev, int i, n; int range; int chan; - int msb, lsb; /* disable interrupts and pacing */ devpriv->control_state &= ~DAS16_INTE & ~DMA_ENABLE & ~PACING_MASK; @@ -687,6 +686,8 @@ static int das16_ai_insn_read(struct comedi_device *dev, } for (n = 0; n < insn->n; n++) { + unsigned int val; + /* trigger conversion */ outb_p(0, dev->iobase + DAS16_TRIG); @@ -698,13 +699,14 @@ static int das16_ai_insn_read(struct comedi_device *dev, printk("das16: timeout\n"); return -ETIME; } - msb = inb(dev->iobase + DAS16_AI_MSB); - lsb = inb(dev->iobase + DAS16_AI_LSB); - if (board->ai_nbits == 12) - data[n] = ((lsb >> 4) & 0xf) | (msb << 4); - else - data[n] = lsb | (msb << 8); + val = inb(dev->iobase + DAS16_AI_MSB) << 8; + val |= inb(dev->iobase + DAS16_AI_LSB); + if (s->maxdata == 0x0fff) + data[n] >>= 4; + val &= s->maxdata; + + data[n] = val; } return n; @@ -957,15 +959,14 @@ static void das16_ai_munge(struct comedi_device *dev, unsigned int num_bytes, unsigned int start_chan_index) { - const struct das16_board *board = comedi_board(dev); unsigned int i, num_samples = num_bytes / sizeof(short); short *data = array; for (i = 0; i < num_samples; i++) { data[i] = le16_to_cpu(data[i]); - if (board->ai_nbits == 12) - data[i] = (data[i] >> 4) & 0xfff; - + if (s->maxdata == 0x0fff) + data[i] >>= 4; + data[i] &= s->maxdata; } } @@ -1112,7 +1113,7 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->n_chan = 8; } s->len_chanlist = s->n_chan; - s->maxdata = (1 << board->ai_nbits) - 1; + s->maxdata = board->ai_maxdata; if (devpriv->user_ai_range_table) { /* user defined ai range */ s->range_table = devpriv->user_ai_range_table; } else if (devpriv->ai_unipolar) { @@ -1228,7 +1229,7 @@ static void das16_detach(struct comedi_device *dev) static const struct das16_board das16_boards[] = { { .name = "das-16", - .ai_nbits = 12, + .ai_maxdata = 0x0fff, .ai_speed = 15000, .ai_pg = das16_pg_none, .ao = das16_ao_winsn, @@ -1241,7 +1242,7 @@ static const struct das16_board das16_boards[] = { .id = 0x00, }, { .name = "das-16g", - .ai_nbits = 12, + .ai_maxdata = 0x0fff, .ai_speed = 15000, .ai_pg = das16_pg_none, .ao = das16_ao_winsn, @@ -1254,7 +1255,7 @@ static const struct das16_board das16_boards[] = { .id = 0x00, }, { .name = "das-16f", - .ai_nbits = 12, + .ai_maxdata = 0x0fff, .ai_speed = 8500, .ai_pg = das16_pg_none, .ao = das16_ao_winsn, @@ -1267,7 +1268,7 @@ static const struct das16_board das16_boards[] = { .id = 0x00, }, { .name = "cio-das16", - .ai_nbits = 12, + .ai_maxdata = 0x0fff, .ai_speed = 20000, .ai_pg = das16_pg_none, .ao = das16_ao_winsn, @@ -1280,7 +1281,7 @@ static const struct das16_board das16_boards[] = { .id = 0x80, }, { .name = "cio-das16/f", - .ai_nbits = 12, + .ai_maxdata = 0x0fff, .ai_speed = 10000, .ai_pg = das16_pg_none, .ao = das16_ao_winsn, @@ -1293,7 +1294,7 @@ static const struct das16_board das16_boards[] = { .id = 0x80, }, { .name = "cio-das16/jr", - .ai_nbits = 12, + .ai_maxdata = 0x0fff, .ai_speed = 7692, .ai_pg = das16_pg_16jr, .ao = NULL, @@ -1305,7 +1306,7 @@ static const struct das16_board das16_boards[] = { .id = 0x00, }, { .name = "pc104-das16jr", - .ai_nbits = 12, + .ai_maxdata = 0x0fff, .ai_speed = 3300, .ai_pg = das16_pg_16jr, .ao = NULL, @@ -1317,7 +1318,7 @@ static const struct das16_board das16_boards[] = { .id = 0x00, }, { .name = "cio-das16jr/16", - .ai_nbits = 16, + .ai_maxdata = 0xffff, .ai_speed = 10000, .ai_pg = das16_pg_16jr_16, .ao = NULL, @@ -1329,7 +1330,7 @@ static const struct das16_board das16_boards[] = { .id = 0x00, }, { .name = "pc104-das16jr/16", - .ai_nbits = 16, + .ai_maxdata = 0xffff, .ai_speed = 10000, .ai_pg = das16_pg_16jr_16, .ao = NULL, @@ -1341,7 +1342,7 @@ static const struct das16_board das16_boards[] = { .id = 0x00, }, { .name = "das-1201", - .ai_nbits = 12, + .ai_maxdata = 0x0fff, .ai_speed = 20000, .ai_pg = das16_pg_none, .ao = NULL, @@ -1353,7 +1354,7 @@ static const struct das16_board das16_boards[] = { .id = 0x20, }, { .name = "das-1202", - .ai_nbits = 12, + .ai_maxdata = 0x0fff, .ai_speed = 10000, .ai_pg = das16_pg_none, .ao = NULL, @@ -1365,7 +1366,7 @@ static const struct das16_board das16_boards[] = { .id = 0x20, }, { .name = "das-1401", - .ai_nbits = 12, + .ai_maxdata = 0x0fff, .ai_speed = 10000, .ai_pg = das16_pg_1601, .ao = NULL, @@ -1377,7 +1378,7 @@ static const struct das16_board das16_boards[] = { .id = 0xc0, }, { .name = "das-1402", - .ai_nbits = 12, + .ai_maxdata = 0x0fff, .ai_speed = 10000, .ai_pg = das16_pg_1602, .ao = NULL, @@ -1389,7 +1390,7 @@ static const struct das16_board das16_boards[] = { .id = 0xc0, }, { .name = "das-1601", - .ai_nbits = 12, + .ai_maxdata = 0x0fff, .ai_speed = 10000, .ai_pg = das16_pg_1601, .ao = das16_ao_winsn, @@ -1402,7 +1403,7 @@ static const struct das16_board das16_boards[] = { .id = 0xc0, }, { .name = "das-1602", - .ai_nbits = 12, + .ai_maxdata = 0x0fff, .ai_speed = 10000, .ai_pg = das16_pg_1602, .ao = das16_ao_winsn, @@ -1415,7 +1416,7 @@ static const struct das16_board das16_boards[] = { .id = 0xc0, }, { .name = "cio-das1401/12", - .ai_nbits = 12, + .ai_maxdata = 0x0fff, .ai_speed = 6250, .ai_pg = das16_pg_1601, .ao = NULL, @@ -1427,7 +1428,7 @@ static const struct das16_board das16_boards[] = { .id = 0xc0, }, { .name = "cio-das1402/12", - .ai_nbits = 12, + .ai_maxdata = 0x0fff, .ai_speed = 6250, .ai_pg = das16_pg_1602, .ao = NULL, @@ -1439,7 +1440,7 @@ static const struct das16_board das16_boards[] = { .id = 0xc0, }, { .name = "cio-das1402/16", - .ai_nbits = 16, + .ai_maxdata = 0xffff, .ai_speed = 10000, .ai_pg = das16_pg_1602, .ao = NULL, @@ -1451,7 +1452,7 @@ static const struct das16_board das16_boards[] = { .id = 0xc0, }, { .name = "cio-das1601/12", - .ai_nbits = 12, + .ai_maxdata = 0x0fff, .ai_speed = 6250, .ai_pg = das16_pg_1601, .ao = das16_ao_winsn, @@ -1464,7 +1465,7 @@ static const struct das16_board das16_boards[] = { .id = 0xc0, }, { .name = "cio-das1602/12", - .ai_nbits = 12, + .ai_maxdata = 0x0fff, .ai_speed = 10000, .ai_pg = das16_pg_1602, .ao = das16_ao_winsn, @@ -1477,7 +1478,7 @@ static const struct das16_board das16_boards[] = { .id = 0xc0, }, { .name = "cio-das1602/16", - .ai_nbits = 16, + .ai_maxdata = 0xffff, .ai_speed = 10000, .ai_pg = das16_pg_1602, .ao = das16_ao_winsn, @@ -1490,7 +1491,7 @@ static const struct das16_board das16_boards[] = { .id = 0xc0, }, { .name = "cio-das16/330", - .ai_nbits = 12, + .ai_maxdata = 0x0fff, .ai_speed = 3030, .ai_pg = das16_pg_16jr, .ao = NULL, -- GitLab From fb1864ba9535353530f43ae60386f00bc629a5bb Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 13:54:09 -0700 Subject: [PATCH 358/942] staging: comedi: das16: all supported board have digital inputs All the boards supported by this driver have digital inputs and all of then use the same function to handle the (*insn_bits) for the subdevice. Remove the 'di' member from the boardinfo and always initialize the digital input subdevice during the board attach. Tidy up the subdevice init a bit as well as the (*insn_bits) function. The (*insn_bits) function does not need to clear data[0]. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 53 ++++++-------------------- 1 file changed, 12 insertions(+), 41 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index 11e5787dd27ef..3528c8257a5cf 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -343,7 +343,6 @@ struct das16_board { unsigned int ai_pg; void *ao; unsigned int ao_nbits; - void *di; void *do_; unsigned int i8255_offset; @@ -712,14 +711,12 @@ static int das16_ai_insn_read(struct comedi_device *dev, return n; } -static int das16_di_rbits(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int das16_di_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { - unsigned int bits; - - bits = inb(dev->iobase + DAS16_DIO) & 0xf; - data[1] = bits; - data[0] = 0; + data[1] = inb(dev->iobase + DAS16_DIO) & 0xf; return insn->n; } @@ -1149,18 +1146,14 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->type = COMEDI_SUBD_UNUSED; } + /* Digital Input subdevice */ s = &dev->subdevices[2]; - /* di */ - if (board->di) { - s->type = COMEDI_SUBD_DI; - s->subdev_flags = SDF_READABLE; - s->n_chan = 4; - s->maxdata = 1; - s->range_table = &range_digital; - s->insn_bits = board->di; - } else { - s->type = COMEDI_SUBD_UNUSED; - } + s->type = COMEDI_SUBD_DI; + s->subdev_flags = SDF_READABLE; + s->n_chan = 4; + s->maxdata = 1; + s->range_table = &range_digital; + s->insn_bits = das16_di_insn_bits; s = &dev->subdevices[3]; /* do */ @@ -1234,7 +1227,6 @@ static const struct das16_board das16_boards[] = { .ai_pg = das16_pg_none, .ao = das16_ao_winsn, .ao_nbits = 12, - .di = das16_di_rbits, .do_ = das16_do_wbits, .i8255_offset = 0x10, .i8254_offset = 0x0c, @@ -1247,7 +1239,6 @@ static const struct das16_board das16_boards[] = { .ai_pg = das16_pg_none, .ao = das16_ao_winsn, .ao_nbits = 12, - .di = das16_di_rbits, .do_ = das16_do_wbits, .i8255_offset = 0x10, .i8254_offset = 0x0c, @@ -1260,7 +1251,6 @@ static const struct das16_board das16_boards[] = { .ai_pg = das16_pg_none, .ao = das16_ao_winsn, .ao_nbits = 12, - .di = das16_di_rbits, .do_ = das16_do_wbits, .i8255_offset = 0x10, .i8254_offset = 0x0c, @@ -1273,7 +1263,6 @@ static const struct das16_board das16_boards[] = { .ai_pg = das16_pg_none, .ao = das16_ao_winsn, .ao_nbits = 12, - .di = das16_di_rbits, .do_ = das16_do_wbits, .i8255_offset = 0x10, .i8254_offset = 0x0c, @@ -1286,7 +1275,6 @@ static const struct das16_board das16_boards[] = { .ai_pg = das16_pg_none, .ao = das16_ao_winsn, .ao_nbits = 12, - .di = das16_di_rbits, .do_ = das16_do_wbits, .i8255_offset = 0x10, .i8254_offset = 0x0c, @@ -1298,7 +1286,6 @@ static const struct das16_board das16_boards[] = { .ai_speed = 7692, .ai_pg = das16_pg_16jr, .ao = NULL, - .di = das16_di_rbits, .do_ = das16_do_wbits, .i8255_offset = 0, .i8254_offset = 0x0c, @@ -1310,7 +1297,6 @@ static const struct das16_board das16_boards[] = { .ai_speed = 3300, .ai_pg = das16_pg_16jr, .ao = NULL, - .di = das16_di_rbits, .do_ = das16_do_wbits, .i8255_offset = 0, .i8254_offset = 0x0c, @@ -1322,7 +1308,6 @@ static const struct das16_board das16_boards[] = { .ai_speed = 10000, .ai_pg = das16_pg_16jr_16, .ao = NULL, - .di = das16_di_rbits, .do_ = das16_do_wbits, .i8255_offset = 0, .i8254_offset = 0x0c, @@ -1334,7 +1319,6 @@ static const struct das16_board das16_boards[] = { .ai_speed = 10000, .ai_pg = das16_pg_16jr_16, .ao = NULL, - .di = das16_di_rbits, .do_ = das16_do_wbits, .i8255_offset = 0, .i8254_offset = 0x0c, @@ -1346,7 +1330,6 @@ static const struct das16_board das16_boards[] = { .ai_speed = 20000, .ai_pg = das16_pg_none, .ao = NULL, - .di = das16_di_rbits, .do_ = das16_do_wbits, .i8255_offset = 0x400, .i8254_offset = 0x0c, @@ -1358,7 +1341,6 @@ static const struct das16_board das16_boards[] = { .ai_speed = 10000, .ai_pg = das16_pg_none, .ao = NULL, - .di = das16_di_rbits, .do_ = das16_do_wbits, .i8255_offset = 0x400, .i8254_offset = 0x0c, @@ -1370,7 +1352,6 @@ static const struct das16_board das16_boards[] = { .ai_speed = 10000, .ai_pg = das16_pg_1601, .ao = NULL, - .di = das16_di_rbits, .do_ = das16_do_wbits, .i8255_offset = 0x0, .i8254_offset = 0x0c, @@ -1382,7 +1363,6 @@ static const struct das16_board das16_boards[] = { .ai_speed = 10000, .ai_pg = das16_pg_1602, .ao = NULL, - .di = das16_di_rbits, .do_ = das16_do_wbits, .i8255_offset = 0x0, .i8254_offset = 0x0c, @@ -1395,7 +1375,6 @@ static const struct das16_board das16_boards[] = { .ai_pg = das16_pg_1601, .ao = das16_ao_winsn, .ao_nbits = 12, - .di = das16_di_rbits, .do_ = das16_do_wbits, .i8255_offset = 0x400, .i8254_offset = 0x0c, @@ -1408,7 +1387,6 @@ static const struct das16_board das16_boards[] = { .ai_pg = das16_pg_1602, .ao = das16_ao_winsn, .ao_nbits = 12, - .di = das16_di_rbits, .do_ = das16_do_wbits, .i8255_offset = 0x400, .i8254_offset = 0x0c, @@ -1420,7 +1398,6 @@ static const struct das16_board das16_boards[] = { .ai_speed = 6250, .ai_pg = das16_pg_1601, .ao = NULL, - .di = das16_di_rbits, .do_ = das16_do_wbits, .i8255_offset = 0, .i8254_offset = 0x0c, @@ -1432,7 +1409,6 @@ static const struct das16_board das16_boards[] = { .ai_speed = 6250, .ai_pg = das16_pg_1602, .ao = NULL, - .di = das16_di_rbits, .do_ = das16_do_wbits, .i8255_offset = 0, .i8254_offset = 0x0c, @@ -1444,7 +1420,6 @@ static const struct das16_board das16_boards[] = { .ai_speed = 10000, .ai_pg = das16_pg_1602, .ao = NULL, - .di = das16_di_rbits, .do_ = das16_do_wbits, .i8255_offset = 0, .i8254_offset = 0x0c, @@ -1457,7 +1432,6 @@ static const struct das16_board das16_boards[] = { .ai_pg = das16_pg_1601, .ao = das16_ao_winsn, .ao_nbits = 12, - .di = das16_di_rbits, .do_ = das16_do_wbits, .i8255_offset = 0x400, .i8254_offset = 0x0c, @@ -1470,7 +1444,6 @@ static const struct das16_board das16_boards[] = { .ai_pg = das16_pg_1602, .ao = das16_ao_winsn, .ao_nbits = 12, - .di = das16_di_rbits, .do_ = das16_do_wbits, .i8255_offset = 0x400, .i8254_offset = 0x0c, @@ -1483,7 +1456,6 @@ static const struct das16_board das16_boards[] = { .ai_pg = das16_pg_1602, .ao = das16_ao_winsn, .ao_nbits = 12, - .di = das16_di_rbits, .do_ = das16_do_wbits, .i8255_offset = 0x400, .i8254_offset = 0x0c, @@ -1495,7 +1467,6 @@ static const struct das16_board das16_boards[] = { .ai_speed = 3030, .ai_pg = das16_pg_16jr, .ao = NULL, - .di = das16_di_rbits, .do_ = das16_do_wbits, .i8255_offset = 0, .i8254_offset = 0x0c, -- GitLab From 6050cc918dd4c002ddebf76861c6d9f240c1a4dc Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 13:54:39 -0700 Subject: [PATCH 359/942] staging: comedi: das16: all supported board have digital outputs All the boards supported by this driver have digital outputs and all of then use the same function to handle the (*insn_bits) for the subdevice. Remove the 'do_' member from the boardinfo and always initialize the digital output subdevice during the board attach. Tidy up the subdevice init a bit as well as the (*insn_bits) function. Remove SDF_READABLE from the subdev_flags. This is a pure digital output subdevice and the outputs are not readable. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 74 +++++++++----------------- 1 file changed, 24 insertions(+), 50 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index 3528c8257a5cf..22d2bf423d661 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -343,7 +343,6 @@ struct das16_board { unsigned int ai_pg; void *ao; unsigned int ao_nbits; - void *do_; unsigned int i8255_offset; unsigned int i8254_offset; @@ -721,22 +720,22 @@ static int das16_di_insn_bits(struct comedi_device *dev, return insn->n; } -static int das16_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int das16_do_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { - unsigned int wbits; - - /* only set bits that have been masked */ - data[0] &= 0xf; - wbits = s->state; - /* zero bits that have been masked */ - wbits &= ~data[0]; - /* set masked bits */ - wbits |= data[0] & data[1]; - s->state = wbits; - data[1] = wbits; + unsigned int mask = data[0]; + unsigned int bits = data[1]; - outb(s->state, dev->iobase + DAS16_DIO); + if (mask) { + s->state &= ~mask; + s->state |= (bits & mask); + + outb(s->state, dev->iobase + DAS16_DIO); + } + + data[1] = s->state; return insn->n; } @@ -1155,20 +1154,17 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->range_table = &range_digital; s->insn_bits = das16_di_insn_bits; + /* Digital Output subdevice */ s = &dev->subdevices[3]; - /* do */ - if (board->do_) { - s->type = COMEDI_SUBD_DO; - s->subdev_flags = SDF_WRITABLE | SDF_READABLE; - s->n_chan = 4; - s->maxdata = 1; - s->range_table = &range_digital; - s->insn_bits = board->do_; - /* initialize digital output lines */ - outb(s->state, dev->iobase + DAS16_DIO); - } else { - s->type = COMEDI_SUBD_UNUSED; - } + s->type = COMEDI_SUBD_DO; + s->subdev_flags = SDF_WRITABLE; + s->n_chan = 4; + s->maxdata = 1; + s->range_table = &range_digital; + s->insn_bits = das16_do_insn_bits; + + /* initialize digital output lines */ + outb(s->state, dev->iobase + DAS16_DIO); s = &dev->subdevices[4]; /* 8255 */ @@ -1227,7 +1223,6 @@ static const struct das16_board das16_boards[] = { .ai_pg = das16_pg_none, .ao = das16_ao_winsn, .ao_nbits = 12, - .do_ = das16_do_wbits, .i8255_offset = 0x10, .i8254_offset = 0x0c, .size = 0x14, @@ -1239,7 +1234,6 @@ static const struct das16_board das16_boards[] = { .ai_pg = das16_pg_none, .ao = das16_ao_winsn, .ao_nbits = 12, - .do_ = das16_do_wbits, .i8255_offset = 0x10, .i8254_offset = 0x0c, .size = 0x14, @@ -1251,7 +1245,6 @@ static const struct das16_board das16_boards[] = { .ai_pg = das16_pg_none, .ao = das16_ao_winsn, .ao_nbits = 12, - .do_ = das16_do_wbits, .i8255_offset = 0x10, .i8254_offset = 0x0c, .size = 0x14, @@ -1263,7 +1256,6 @@ static const struct das16_board das16_boards[] = { .ai_pg = das16_pg_none, .ao = das16_ao_winsn, .ao_nbits = 12, - .do_ = das16_do_wbits, .i8255_offset = 0x10, .i8254_offset = 0x0c, .size = 0x14, @@ -1275,7 +1267,6 @@ static const struct das16_board das16_boards[] = { .ai_pg = das16_pg_none, .ao = das16_ao_winsn, .ao_nbits = 12, - .do_ = das16_do_wbits, .i8255_offset = 0x10, .i8254_offset = 0x0c, .size = 0x14, @@ -1286,7 +1277,6 @@ static const struct das16_board das16_boards[] = { .ai_speed = 7692, .ai_pg = das16_pg_16jr, .ao = NULL, - .do_ = das16_do_wbits, .i8255_offset = 0, .i8254_offset = 0x0c, .size = 0x10, @@ -1297,7 +1287,6 @@ static const struct das16_board das16_boards[] = { .ai_speed = 3300, .ai_pg = das16_pg_16jr, .ao = NULL, - .do_ = das16_do_wbits, .i8255_offset = 0, .i8254_offset = 0x0c, .size = 0x10, @@ -1308,7 +1297,6 @@ static const struct das16_board das16_boards[] = { .ai_speed = 10000, .ai_pg = das16_pg_16jr_16, .ao = NULL, - .do_ = das16_do_wbits, .i8255_offset = 0, .i8254_offset = 0x0c, .size = 0x10, @@ -1319,7 +1307,6 @@ static const struct das16_board das16_boards[] = { .ai_speed = 10000, .ai_pg = das16_pg_16jr_16, .ao = NULL, - .do_ = das16_do_wbits, .i8255_offset = 0, .i8254_offset = 0x0c, .size = 0x10, @@ -1330,7 +1317,6 @@ static const struct das16_board das16_boards[] = { .ai_speed = 20000, .ai_pg = das16_pg_none, .ao = NULL, - .do_ = das16_do_wbits, .i8255_offset = 0x400, .i8254_offset = 0x0c, .size = 0x408, @@ -1341,7 +1327,6 @@ static const struct das16_board das16_boards[] = { .ai_speed = 10000, .ai_pg = das16_pg_none, .ao = NULL, - .do_ = das16_do_wbits, .i8255_offset = 0x400, .i8254_offset = 0x0c, .size = 0x408, @@ -1352,7 +1337,6 @@ static const struct das16_board das16_boards[] = { .ai_speed = 10000, .ai_pg = das16_pg_1601, .ao = NULL, - .do_ = das16_do_wbits, .i8255_offset = 0x0, .i8254_offset = 0x0c, .size = 0x408, @@ -1363,7 +1347,6 @@ static const struct das16_board das16_boards[] = { .ai_speed = 10000, .ai_pg = das16_pg_1602, .ao = NULL, - .do_ = das16_do_wbits, .i8255_offset = 0x0, .i8254_offset = 0x0c, .size = 0x408, @@ -1375,7 +1358,6 @@ static const struct das16_board das16_boards[] = { .ai_pg = das16_pg_1601, .ao = das16_ao_winsn, .ao_nbits = 12, - .do_ = das16_do_wbits, .i8255_offset = 0x400, .i8254_offset = 0x0c, .size = 0x408, @@ -1387,7 +1369,6 @@ static const struct das16_board das16_boards[] = { .ai_pg = das16_pg_1602, .ao = das16_ao_winsn, .ao_nbits = 12, - .do_ = das16_do_wbits, .i8255_offset = 0x400, .i8254_offset = 0x0c, .size = 0x408, @@ -1398,7 +1379,6 @@ static const struct das16_board das16_boards[] = { .ai_speed = 6250, .ai_pg = das16_pg_1601, .ao = NULL, - .do_ = das16_do_wbits, .i8255_offset = 0, .i8254_offset = 0x0c, .size = 0x408, @@ -1409,7 +1389,6 @@ static const struct das16_board das16_boards[] = { .ai_speed = 6250, .ai_pg = das16_pg_1602, .ao = NULL, - .do_ = das16_do_wbits, .i8255_offset = 0, .i8254_offset = 0x0c, .size = 0x408, @@ -1420,7 +1399,6 @@ static const struct das16_board das16_boards[] = { .ai_speed = 10000, .ai_pg = das16_pg_1602, .ao = NULL, - .do_ = das16_do_wbits, .i8255_offset = 0, .i8254_offset = 0x0c, .size = 0x408, @@ -1432,7 +1410,6 @@ static const struct das16_board das16_boards[] = { .ai_pg = das16_pg_1601, .ao = das16_ao_winsn, .ao_nbits = 12, - .do_ = das16_do_wbits, .i8255_offset = 0x400, .i8254_offset = 0x0c, .size = 0x408, @@ -1444,7 +1421,6 @@ static const struct das16_board das16_boards[] = { .ai_pg = das16_pg_1602, .ao = das16_ao_winsn, .ao_nbits = 12, - .do_ = das16_do_wbits, .i8255_offset = 0x400, .i8254_offset = 0x0c, .size = 0x408, @@ -1456,7 +1432,6 @@ static const struct das16_board das16_boards[] = { .ai_pg = das16_pg_1602, .ao = das16_ao_winsn, .ao_nbits = 12, - .do_ = das16_do_wbits, .i8255_offset = 0x400, .i8254_offset = 0x0c, .size = 0x408, @@ -1467,7 +1442,6 @@ static const struct das16_board das16_boards[] = { .ai_speed = 3030, .ai_pg = das16_pg_16jr, .ao = NULL, - .do_ = das16_do_wbits, .i8255_offset = 0, .i8254_offset = 0x0c, .size = 0x14, -- GitLab From 6d063851933584ab812f59bb0cdfb16d584ac5b0 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 13:55:00 -0700 Subject: [PATCH 360/942] staging: comedi: das16: cleanup analog output subdevice All the boards supported by this driver that have analog outputs use the same function to handle the (*insn_write) for the subdevice. They all also have 12-bit resolution (maxdata = 0x0fff). Remove the 'ao' and 'ao_nbits' members from the boardinfo and replace them with a simple bit-field flag 'has_ao'. Tidy up the subdevice init a bit as well as the (*insn_write) function. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 95 +++++++++----------------- 1 file changed, 33 insertions(+), 62 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index 22d2bf423d661..bad39d79b2c3f 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -341,8 +341,7 @@ struct das16_board { unsigned int ai_maxdata; unsigned int ai_speed; /* max conversion speed in nanosec */ unsigned int ai_pg; - void *ao; - unsigned int ao_nbits; + unsigned int has_ao:1; unsigned int i8255_offset; unsigned int i8254_offset; @@ -740,29 +739,24 @@ static int das16_do_insn_bits(struct comedi_device *dev, return insn->n; } -static int das16_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int das16_ao_insn_write(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { - const struct das16_board *board = comedi_board(dev); + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned int val; int i; - int lsb, msb; - int chan; - - chan = CR_CHAN(insn->chanspec); for (i = 0; i < insn->n; i++) { - if (board->ao_nbits == 12) { - lsb = (data[i] << 4) & 0xff; - msb = (data[i] >> 4) & 0xff; - } else { - lsb = data[i] & 0xff; - msb = (data[i] >> 8) & 0xff; - } - outb(lsb, dev->iobase + DAS16_AO_LSB(chan)); - outb(msb, dev->iobase + DAS16_AO_MSB(chan)); + val = data[i]; + val <<= 4; + + outb(val & 0xff, dev->iobase + DAS16_AO_LSB(chan)); + outb((val >> 8) & 0xff, dev->iobase + DAS16_AO_MSB(chan)); } - return i; + return insn->n; } /* the pc104-das16jr (at least) has problems if the dma @@ -1127,22 +1121,21 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->munge = das16_ai_munge; } + /* Analog Output subdevice */ s = &dev->subdevices[1]; - /* ao */ - if (board->ao) { - s->type = COMEDI_SUBD_AO; - s->subdev_flags = SDF_WRITABLE; - s->n_chan = 2; - s->maxdata = (1 << board->ao_nbits) - 1; - /* user defined ao range */ + if (board->has_ao) { + s->type = COMEDI_SUBD_AO; + s->subdev_flags = SDF_WRITABLE; + s->n_chan = 2; + s->maxdata = 0x0fff; if (devpriv->user_ao_range_table) - s->range_table = devpriv->user_ao_range_table; + s->range_table = devpriv->user_ao_range_table; else - s->range_table = &range_unknown; + s->range_table = &range_unknown; - s->insn_write = board->ao; + s->insn_write = das16_ao_insn_write; } else { - s->type = COMEDI_SUBD_UNUSED; + s->type = COMEDI_SUBD_UNUSED; } /* Digital Input subdevice */ @@ -1221,8 +1214,7 @@ static const struct das16_board das16_boards[] = { .ai_maxdata = 0x0fff, .ai_speed = 15000, .ai_pg = das16_pg_none, - .ao = das16_ao_winsn, - .ao_nbits = 12, + .has_ao = 1, .i8255_offset = 0x10, .i8254_offset = 0x0c, .size = 0x14, @@ -1232,8 +1224,7 @@ static const struct das16_board das16_boards[] = { .ai_maxdata = 0x0fff, .ai_speed = 15000, .ai_pg = das16_pg_none, - .ao = das16_ao_winsn, - .ao_nbits = 12, + .has_ao = 1, .i8255_offset = 0x10, .i8254_offset = 0x0c, .size = 0x14, @@ -1243,8 +1234,7 @@ static const struct das16_board das16_boards[] = { .ai_maxdata = 0x0fff, .ai_speed = 8500, .ai_pg = das16_pg_none, - .ao = das16_ao_winsn, - .ao_nbits = 12, + .has_ao = 1, .i8255_offset = 0x10, .i8254_offset = 0x0c, .size = 0x14, @@ -1254,8 +1244,7 @@ static const struct das16_board das16_boards[] = { .ai_maxdata = 0x0fff, .ai_speed = 20000, .ai_pg = das16_pg_none, - .ao = das16_ao_winsn, - .ao_nbits = 12, + .has_ao = 1, .i8255_offset = 0x10, .i8254_offset = 0x0c, .size = 0x14, @@ -1265,8 +1254,7 @@ static const struct das16_board das16_boards[] = { .ai_maxdata = 0x0fff, .ai_speed = 10000, .ai_pg = das16_pg_none, - .ao = das16_ao_winsn, - .ao_nbits = 12, + .has_ao = 1, .i8255_offset = 0x10, .i8254_offset = 0x0c, .size = 0x14, @@ -1276,7 +1264,6 @@ static const struct das16_board das16_boards[] = { .ai_maxdata = 0x0fff, .ai_speed = 7692, .ai_pg = das16_pg_16jr, - .ao = NULL, .i8255_offset = 0, .i8254_offset = 0x0c, .size = 0x10, @@ -1286,7 +1273,6 @@ static const struct das16_board das16_boards[] = { .ai_maxdata = 0x0fff, .ai_speed = 3300, .ai_pg = das16_pg_16jr, - .ao = NULL, .i8255_offset = 0, .i8254_offset = 0x0c, .size = 0x10, @@ -1296,7 +1282,6 @@ static const struct das16_board das16_boards[] = { .ai_maxdata = 0xffff, .ai_speed = 10000, .ai_pg = das16_pg_16jr_16, - .ao = NULL, .i8255_offset = 0, .i8254_offset = 0x0c, .size = 0x10, @@ -1306,7 +1291,6 @@ static const struct das16_board das16_boards[] = { .ai_maxdata = 0xffff, .ai_speed = 10000, .ai_pg = das16_pg_16jr_16, - .ao = NULL, .i8255_offset = 0, .i8254_offset = 0x0c, .size = 0x10, @@ -1316,7 +1300,6 @@ static const struct das16_board das16_boards[] = { .ai_maxdata = 0x0fff, .ai_speed = 20000, .ai_pg = das16_pg_none, - .ao = NULL, .i8255_offset = 0x400, .i8254_offset = 0x0c, .size = 0x408, @@ -1326,7 +1309,6 @@ static const struct das16_board das16_boards[] = { .ai_maxdata = 0x0fff, .ai_speed = 10000, .ai_pg = das16_pg_none, - .ao = NULL, .i8255_offset = 0x400, .i8254_offset = 0x0c, .size = 0x408, @@ -1336,7 +1318,6 @@ static const struct das16_board das16_boards[] = { .ai_maxdata = 0x0fff, .ai_speed = 10000, .ai_pg = das16_pg_1601, - .ao = NULL, .i8255_offset = 0x0, .i8254_offset = 0x0c, .size = 0x408, @@ -1346,7 +1327,6 @@ static const struct das16_board das16_boards[] = { .ai_maxdata = 0x0fff, .ai_speed = 10000, .ai_pg = das16_pg_1602, - .ao = NULL, .i8255_offset = 0x0, .i8254_offset = 0x0c, .size = 0x408, @@ -1356,8 +1336,7 @@ static const struct das16_board das16_boards[] = { .ai_maxdata = 0x0fff, .ai_speed = 10000, .ai_pg = das16_pg_1601, - .ao = das16_ao_winsn, - .ao_nbits = 12, + .has_ao = 1, .i8255_offset = 0x400, .i8254_offset = 0x0c, .size = 0x408, @@ -1367,8 +1346,7 @@ static const struct das16_board das16_boards[] = { .ai_maxdata = 0x0fff, .ai_speed = 10000, .ai_pg = das16_pg_1602, - .ao = das16_ao_winsn, - .ao_nbits = 12, + .has_ao = 1, .i8255_offset = 0x400, .i8254_offset = 0x0c, .size = 0x408, @@ -1378,7 +1356,6 @@ static const struct das16_board das16_boards[] = { .ai_maxdata = 0x0fff, .ai_speed = 6250, .ai_pg = das16_pg_1601, - .ao = NULL, .i8255_offset = 0, .i8254_offset = 0x0c, .size = 0x408, @@ -1388,7 +1365,6 @@ static const struct das16_board das16_boards[] = { .ai_maxdata = 0x0fff, .ai_speed = 6250, .ai_pg = das16_pg_1602, - .ao = NULL, .i8255_offset = 0, .i8254_offset = 0x0c, .size = 0x408, @@ -1398,7 +1374,6 @@ static const struct das16_board das16_boards[] = { .ai_maxdata = 0xffff, .ai_speed = 10000, .ai_pg = das16_pg_1602, - .ao = NULL, .i8255_offset = 0, .i8254_offset = 0x0c, .size = 0x408, @@ -1408,8 +1383,7 @@ static const struct das16_board das16_boards[] = { .ai_maxdata = 0x0fff, .ai_speed = 6250, .ai_pg = das16_pg_1601, - .ao = das16_ao_winsn, - .ao_nbits = 12, + .has_ao = 1, .i8255_offset = 0x400, .i8254_offset = 0x0c, .size = 0x408, @@ -1419,8 +1393,7 @@ static const struct das16_board das16_boards[] = { .ai_maxdata = 0x0fff, .ai_speed = 10000, .ai_pg = das16_pg_1602, - .ao = das16_ao_winsn, - .ao_nbits = 12, + .has_ao = 1, .i8255_offset = 0x400, .i8254_offset = 0x0c, .size = 0x408, @@ -1430,8 +1403,7 @@ static const struct das16_board das16_boards[] = { .ai_maxdata = 0xffff, .ai_speed = 10000, .ai_pg = das16_pg_1602, - .ao = das16_ao_winsn, - .ao_nbits = 12, + .has_ao = 1, .i8255_offset = 0x400, .i8254_offset = 0x0c, .size = 0x408, @@ -1441,7 +1413,6 @@ static const struct das16_board das16_boards[] = { .ai_maxdata = 0x0fff, .ai_speed = 3030, .ai_pg = das16_pg_16jr, - .ao = NULL, .i8255_offset = 0, .i8254_offset = 0x0c, .size = 0x14, -- GitLab From 6d33b860cdfe5ab3c4dca57104abb8f0d4c9cb8b Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 13:55:20 -0700 Subject: [PATCH 361/942] staging: comedi: das16: tidy up the comedi_lrange tables Cleanup the whitespace in the tables. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 97 ++++++++++++++------------ 1 file changed, 51 insertions(+), 46 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index bad39d79b2c3f..93c3a8866bef4 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -238,62 +238,67 @@ static const int sample_size = 2; #define DAS1600_WS 0x02 #define DAS1600_CLK_10MHZ 0x01 -static const struct comedi_lrange range_das1x01_bip = { 4, { - BIP_RANGE(10), - BIP_RANGE(1), - BIP_RANGE(0.1), - BIP_RANGE(0.01), - } +static const struct comedi_lrange range_das1x01_bip = { + 4, { + BIP_RANGE(10), + BIP_RANGE(1), + BIP_RANGE(0.1), + BIP_RANGE(0.01) + } }; -static const struct comedi_lrange range_das1x01_unip = { 4, { - UNI_RANGE(10), - UNI_RANGE(1), - UNI_RANGE(0.1), - UNI_RANGE(0.01), - } +static const struct comedi_lrange range_das1x01_unip = { + 4, { + UNI_RANGE(10), + UNI_RANGE(1), + UNI_RANGE(0.1), + UNI_RANGE(0.01) + } }; -static const struct comedi_lrange range_das1x02_bip = { 4, { - BIP_RANGE(10), - BIP_RANGE(5), - BIP_RANGE(2.5), - BIP_RANGE(1.25), - } +static const struct comedi_lrange range_das1x02_bip = { + 4, { + BIP_RANGE(10), + BIP_RANGE(5), + BIP_RANGE(2.5), + BIP_RANGE(1.25) + } }; -static const struct comedi_lrange range_das1x02_unip = { 4, { - UNI_RANGE(10), - UNI_RANGE(5), - UNI_RANGE(2.5), - UNI_RANGE(1.25), - } +static const struct comedi_lrange range_das1x02_unip = { + 4, { + UNI_RANGE(10), + UNI_RANGE(5), + UNI_RANGE(2.5), + UNI_RANGE(1.25) + } }; -static const struct comedi_lrange range_das16jr = { 9, { - /* also used by 16/330 */ - BIP_RANGE(10), - BIP_RANGE(5), - BIP_RANGE(2.5), - BIP_RANGE(1.25), - BIP_RANGE(0.625), - UNI_RANGE(10), - UNI_RANGE(5), - UNI_RANGE(2.5), - UNI_RANGE(1.25), - } +static const struct comedi_lrange range_das16jr = { + 9, { + BIP_RANGE(10), + BIP_RANGE(5), + BIP_RANGE(2.5), + BIP_RANGE(1.25), + BIP_RANGE(0.625), + UNI_RANGE(10), + UNI_RANGE(5), + UNI_RANGE(2.5), + UNI_RANGE(1.25) + } }; -static const struct comedi_lrange range_das16jr_16 = { 8, { - BIP_RANGE(10), - BIP_RANGE(5), - BIP_RANGE(2.5), - BIP_RANGE(1.25), - UNI_RANGE(10), - UNI_RANGE(5), - UNI_RANGE(2.5), - UNI_RANGE(1.25), - } +static const struct comedi_lrange range_das16jr_16 = { + 8, { + BIP_RANGE(10), + BIP_RANGE(5), + BIP_RANGE(2.5), + BIP_RANGE(1.25), + UNI_RANGE(10), + UNI_RANGE(5), + UNI_RANGE(2.5), + UNI_RANGE(1.25) + } }; static const int das16jr_gainlist[] = { 8, 0, 1, 2, 3, 4, 5, 6, 7 }; -- GitLab From 0837e209b3519517dd252d31af02d42368ddfcc6 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 13:55:38 -0700 Subject: [PATCH 362/942] staging: comedi: das16: remove unused struct definition This struct is not used by the driver. Remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index 93c3a8866bef4..14d2aa057b882 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -336,11 +336,6 @@ static const struct comedi_lrange *const das16_ai_bip_lranges[] = { &range_das1x02_bip, }; -struct munge_info { - uint8_t byte; - unsigned have_byte:1; -}; - struct das16_board { const char *name; unsigned int ai_maxdata; -- GitLab From 1aa4694fb6bd5c0cdadb6d7ba0723186f5198c1b Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 13:56:02 -0700 Subject: [PATCH 363/942] staging: comedi: das16: remove 'ai_unipolar' and 'ai_singleended' These members in the private data are only used during the board attach. Move the reading of the status register to the board attach and just check the value where needed when initializing the analog input subdevice. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 28 +++++--------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index 14d2aa057b882..ccb0acde63340 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -360,8 +360,6 @@ static inline int timer_period(void) } struct das16_private_struct { - unsigned int ai_unipolar; /* unipolar flag */ - unsigned int ai_singleended; /* single ended flag */ unsigned int clockbase; /* master clock speed in ns */ volatile unsigned int control_state; /* dma, interrupt and trigger control bits */ volatile unsigned long adc_byte_count; /* number of bytes remaining */ @@ -891,28 +889,9 @@ static void reg_dump(struct comedi_device *dev) static int das16_probe(struct comedi_device *dev, struct comedi_devconfig *it) { const struct das16_board *board = comedi_board(dev); - struct das16_private_struct *devpriv = dev->private; - int status; int diobits; - /* status is available on all boards */ - - status = inb(dev->iobase + DAS16_STATUS); - - if ((status & UNIPOLAR)) - devpriv->ai_unipolar = 1; - else - devpriv->ai_unipolar = 0; - - - if ((status & DAS16_MUXBIT)) - devpriv->ai_singleended = 1; - else - devpriv->ai_singleended = 0; - - /* diobits indicates boards */ - diobits = inb(dev->iobase + DAS16_DIO) & 0xf0; printk(KERN_INFO " id bits are 0x%02x\n", diobits); @@ -976,6 +955,7 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) struct comedi_krange *user_ai_range; struct comedi_krange *user_ao_range; unsigned int dma_chan = it->options[2]; + unsigned int status; int ret; /* check that clock setting is valid */ @@ -1091,11 +1071,13 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (ret) return ret; + status = inb(dev->iobase + DAS16_STATUS); + /* Analog Input subdevice */ s = &dev->subdevices[0]; s->type = COMEDI_SUBD_AI; s->subdev_flags = SDF_READABLE; - if (devpriv->ai_singleended) { + if (status & DAS16_MUXBIT) { s->subdev_flags |= SDF_GROUND; s->n_chan = 16; } else { @@ -1106,7 +1088,7 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->maxdata = board->ai_maxdata; if (devpriv->user_ai_range_table) { /* user defined ai range */ s->range_table = devpriv->user_ai_range_table; - } else if (devpriv->ai_unipolar) { + } else if (status & UNIPOLAR) { s->range_table = das16_ai_uni_lranges[board->ai_pg]; } else { s->range_table = das16_ai_bip_lranges[board->ai_pg]; -- GitLab From 9960ad37cf501336450048137c61be21cb0c5672 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 13:56:21 -0700 Subject: [PATCH 364/942] staging: comedi: das16: remove reg_dump() This function just prints some development debug information. There is no reason to leave this in the final driver. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index ccb0acde63340..ae3a3eaef3d98 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -868,24 +868,6 @@ static void das16_timer_interrupt(unsigned long arg) mod_timer(&devpriv->timer, jiffies + timer_period()); } -static void reg_dump(struct comedi_device *dev) -{ - DEBUG_PRINT("********DAS1600 REGISTER DUMP********\n"); - DEBUG_PRINT("DAS16_MUX: %x\n", inb(dev->iobase + DAS16_MUX)); - DEBUG_PRINT("DAS16_DIO: %x\n", inb(dev->iobase + DAS16_DIO)); - DEBUG_PRINT("DAS16_STATUS: %x\n", inb(dev->iobase + DAS16_STATUS)); - DEBUG_PRINT("DAS16_CONTROL: %x\n", inb(dev->iobase + DAS16_CONTROL)); - DEBUG_PRINT("DAS16_PACER: %x\n", inb(dev->iobase + DAS16_PACER)); - DEBUG_PRINT("DAS16_GAIN: %x\n", inb(dev->iobase + DAS16_GAIN)); - DEBUG_PRINT("DAS16_CNTR_CONTROL: %x\n", - inb(dev->iobase + DAS16_CNTR_CONTROL)); - DEBUG_PRINT("DAS1600_CONV: %x\n", inb(dev->iobase + DAS1600_CONV)); - DEBUG_PRINT("DAS1600_BURST: %x\n", inb(dev->iobase + DAS1600_BURST)); - DEBUG_PRINT("DAS1600_ENABLE: %x\n", inb(dev->iobase + DAS1600_ENABLE)); - DEBUG_PRINT("DAS1600_STATUS_B: %x\n", - inb(dev->iobase + DAS1600_STATUS_B)); -} - static int das16_probe(struct comedi_device *dev, struct comedi_devconfig *it) { const struct das16_board *board = comedi_board(dev); @@ -918,8 +900,6 @@ static int das1600_mode_detect(struct comedi_device *dev) printk(KERN_INFO " 1MHz pacer clock\n"); } - reg_dump(dev); - return 0; } -- GitLab From 66eca8575525a725a105aec5ca3a5cfa57ecd524 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 13:56:38 -0700 Subject: [PATCH 365/942] staging: comedi: das16: remove DEBUG_PRINT macro This macro outputs some printk() debug info that is just added noise. Remove it as well as the DEBUG stuff. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index ae3a3eaef3d98..d86ed2cce7c0b 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -86,16 +86,6 @@ www.measurementcomputing.com #include "8255.h" #include "comedi_fc.h" -#undef DEBUG -/* #define DEBUG */ - -#ifdef DEBUG -#define DEBUG_PRINT(format, args...) \ - printk(KERN_DEBUG "das16: " format, ## args) -#else -#define DEBUG_PRINT(format, args...) -#endif - #define DAS16_SIZE 20 /* number of ioports */ #define DAS16_DMA_SIZE 0xff00 /* size in bytes of allocated dma buffer */ @@ -566,7 +556,6 @@ static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s) cmd->convert_arg = das16_set_pacer(dev, cmd->convert_arg, cmd->flags & TRIG_ROUND_MASK); - DEBUG_PRINT("pacer period: %d ns\n", cmd->convert_arg); /* enable counters */ byte = 0; @@ -814,7 +803,6 @@ static void das16_interrupt(struct comedi_device *dev) spin_lock_irqsave(&dev->spinlock, spin_flags); if ((devpriv->control_state & DMA_ENABLE) == 0) { spin_unlock_irqrestore(&dev->spinlock, spin_flags); - DEBUG_PRINT("interrupt while dma disabled?\n"); return; } -- GitLab From 6f63840447030b32662d8d425b36e8fabd7799cf Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 13:56:59 -0700 Subject: [PATCH 366/942] staging: comedi: das16: remove 'volatile' on private data variables As indicated by checkpatch.pl, "WARNING: Use of volatile is usually wrong: ...". The variables in the private data that are marked volatile don't need to be. Remove the volatile. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index d86ed2cce7c0b..95261a617623c 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -351,8 +351,8 @@ static inline int timer_period(void) struct das16_private_struct { unsigned int clockbase; /* master clock speed in ns */ - volatile unsigned int control_state; /* dma, interrupt and trigger control bits */ - volatile unsigned long adc_byte_count; /* number of bytes remaining */ + unsigned int control_state; /* dma, interrupt and trigger control bits */ + unsigned long adc_byte_count; /* number of bytes remaining */ /* divisor dividing master clock to get conversion frequency */ unsigned int divisor1; /* divisor dividing master clock to get conversion frequency */ @@ -361,7 +361,7 @@ struct das16_private_struct { uint16_t *dma_buffer[2]; dma_addr_t dma_buffer_addr[2]; unsigned int current_buffer; - volatile unsigned int dma_transfer_size; /* target number of bytes to transfer per dma shot */ + unsigned int dma_transfer_size; /* target number of bytes to transfer per dma shot */ /** * user-defined analog input and output ranges * defined from config options @@ -370,7 +370,7 @@ struct das16_private_struct { struct comedi_lrange *user_ao_range_table; struct timer_list timer; /* for timed interrupt */ - volatile short timer_running; + short timer_running; unsigned long extra_iobase; }; -- GitLab From 96334bfebf5697dce1dba23c0abdf1683a733c52 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 13:57:18 -0700 Subject: [PATCH 367/942] staging: comedi: das16: add a 'can_burst' flag to the private data If the boardinfo 'size' is > 0x400 it indicates that the board has additional registers that allow bursting of analog input data. To better indicate this add a flag to the private data. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 31 ++++++++++---------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index 95261a617623c..009c074b664bb 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -373,6 +373,7 @@ struct das16_private_struct { short timer_running; unsigned long extra_iobase; + unsigned int can_burst:1; }; static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s, @@ -389,15 +390,13 @@ static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s, err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW); mask = TRIG_FOLLOW; - /* if board supports burst mode */ - if (board->size > 0x400) + if (devpriv->can_burst) mask |= TRIG_TIMER | TRIG_EXT; err |= cfc_check_trigger_src(&cmd->scan_begin_src, mask); tmp = cmd->convert_src; mask = TRIG_TIMER | TRIG_EXT; - /* if board supports burst mode */ - if (board->size > 0x400) + if (devpriv->can_burst) mask |= TRIG_NOW; err |= cfc_check_trigger_src(&cmd->convert_src, mask); @@ -534,8 +533,7 @@ static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->adc_byte_count = cmd->stop_arg * cmd->chanlist_len * sizeof(uint16_t); - /* disable conversions for das1600 mode */ - if (board->size > 0x400) + if (devpriv->can_burst) outb(DAS1600_CONV_DISABLE, dev->iobase + DAS1600_CONV); /* set scan limits */ @@ -559,8 +557,7 @@ static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s) /* enable counters */ byte = 0; - /* Enable burst mode if appropriate. */ - if (board->size > 0x400) { + if (devpriv->can_burst) { if (cmd->convert_src == TRIG_NOW) { outb(DAS1600_BURST_VAL, dev->iobase + DAS1600_BURST); /* set burst length */ @@ -598,8 +595,7 @@ static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->control_state |= INT_PACER; outb(devpriv->control_state, dev->iobase + DAS16_CONTROL); - /* Enable conversions if using das1600 mode */ - if (board->size > 0x400) + if (devpriv->can_burst) outb(0, dev->iobase + DAS1600_CONV); @@ -608,7 +604,6 @@ static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s) static int das16_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { - const struct das16_board *board = comedi_board(dev); struct das16_private_struct *devpriv = dev->private; unsigned long flags; @@ -624,11 +619,9 @@ static int das16_cancel(struct comedi_device *dev, struct comedi_subdevice *s) del_timer(&devpriv->timer); } - /* disable burst mode */ - if (board->size > 0x400) + if (devpriv->can_burst) outb(0, dev->iobase + DAS1600_BURST); - spin_unlock_irqrestore(&dev->spinlock, flags); return 0; @@ -955,6 +948,7 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (ret) return ret; devpriv->extra_iobase = dev->iobase + 0x400; + devpriv->can_burst = 1; } /* probe id bits to make sure they are consistent */ @@ -964,13 +958,13 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) } /* get master clock speed */ - if (board->size < 0x400) { + if (devpriv->can_burst) { + das1600_mode_detect(dev); + } else { if (it->options[3]) devpriv->clockbase = 1000 / it->options[3]; else devpriv->clockbase = 1000; /* 1 MHz default */ - } else { - das1600_mode_detect(dev); } /* initialize dma */ @@ -1123,8 +1117,7 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) devpriv->control_state = DAS16_IRQ(dev->irq); outb(devpriv->control_state, dev->iobase + DAS16_CONTROL); - /* turn on das1600 mode if available */ - if (board->size > 0x400) { + if (devpriv->can_burst) { outb(DAS1600_ENABLE_VAL, dev->iobase + DAS1600_ENABLE); outb(0, dev->iobase + DAS1600_CONV); outb(0, dev->iobase + DAS1600_BURST); -- GitLab From 3f7890eb24f4e8ce4f70c39595a34bdd31293033 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 13:57:38 -0700 Subject: [PATCH 368/942] staging: comedi: das16: remove unused DAS16_SIZE This define is not used in the driver. Remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index 009c074b664bb..577e2a842845e 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -86,7 +86,6 @@ www.measurementcomputing.com #include "8255.h" #include "comedi_fc.h" -#define DAS16_SIZE 20 /* number of ioports */ #define DAS16_DMA_SIZE 0xff00 /* size in bytes of allocated dma buffer */ /* -- GitLab From 6f8f6b2d4f5255eb91d0cc2643daf3f7d48a14f1 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 13:57:58 -0700 Subject: [PATCH 369/942] staging: comedi: das16: remove unused static const variable This variable is not used in the driver. Remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index 577e2a842845e..96c081b48d07b 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -174,9 +174,6 @@ www.measurementcomputing.com */ -/* size in bytes of a sample from board */ -static const int sample_size = 2; - #define DAS16_TRIG 0 #define DAS16_AI_LSB 0 #define DAS16_AI_MSB 1 -- GitLab From 9336140c49465a16e0fdd8385753020e275ec7d4 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 13:58:17 -0700 Subject: [PATCH 370/942] staging: comedi: das16: remove the register map comments This is just extra cruft. Remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 87 +------------------------- 1 file changed, 2 insertions(+), 85 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index 96c081b48d07b..bd5f516f361cc 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -89,91 +89,8 @@ www.measurementcomputing.com #define DAS16_DMA_SIZE 0xff00 /* size in bytes of allocated dma buffer */ /* - cio-das16.pdf - - "das16" - "das16/f" - - 0 a/d bits 0-3 start 12 bit - 1 a/d bits 4-11 unused - 2 mux read mux set - 3 di 4 bit do 4 bit - 4 unused ao0_lsb - 5 unused ao0_msb - 6 unused ao1_lsb - 7 unused ao1_msb - 8 status eoc uni/bip interrupt reset - 9 dma, int, trig ctrl set dma, int - a pacer control unused - b reserved reserved - cdef 8254 - 0123 8255 - -*/ - -/* - cio-das16jr.pdf - - "das16jr" - - 0 a/d bits 0-3 start 12 bit - 1 a/d bits 4-11 unused - 2 mux read mux set - 3 di 4 bit do 4 bit - 4567 unused unused - 8 status eoc uni/bip interrupt reset - 9 dma, int, trig ctrl set dma, int - a pacer control unused - b gain status gain control - cdef 8254 - -*/ - -/* - cio-das16jr_16.pdf - - "das16jr_16" - - 0 a/d bits 0-7 start 16 bit - 1 a/d bits 8-15 unused - 2 mux read mux set - 3 di 4 bit do 4 bit - 4567 unused unused - 8 status eoc uni/bip interrupt reset - 9 dma, int, trig ctrl set dma, int - a pacer control unused - b gain status gain control - cdef 8254 - -*/ -/* - cio-das160x-1x.pdf - - "das1601/12" - "das1602/12" - "das1602/16" - - 0 a/d bits 0-3 start 12 bit - 1 a/d bits 4-11 unused - 2 mux read mux set - 3 di 4 bit do 4 bit - 4 unused ao0_lsb - 5 unused ao0_msb - 6 unused ao1_lsb - 7 unused ao1_msb - 8 status eoc uni/bip interrupt reset - 9 dma, int, trig ctrl set dma, int - a pacer control unused - b gain status gain control - cdef 8254 - 400 8255 - 404 unused conversion enable - 405 unused burst enable - 406 unused das1600 enable - 407 status - -*/ - + * Register I/O map + */ #define DAS16_TRIG 0 #define DAS16_AI_LSB 0 #define DAS16_AI_MSB 1 -- GitLab From b53ceaf71af836bfc209b68f5d6c7c93895c7329 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 13:58:36 -0700 Subject: [PATCH 371/942] staging: comedi: das16: introduce das16_ai_{en, dis}able() helpers Introduce a couple helper functions to enable and disable the analog input interrupt/dma conversions. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 53 ++++++++++++++++---------- 1 file changed, 33 insertions(+), 20 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index bd5f516f361cc..f6d0f7e868b27 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -264,7 +264,7 @@ static inline int timer_period(void) struct das16_private_struct { unsigned int clockbase; /* master clock speed in ns */ - unsigned int control_state; /* dma, interrupt and trigger control bits */ + unsigned int ctrl_reg; unsigned long adc_byte_count; /* number of bytes remaining */ /* divisor dividing master clock to get conversion frequency */ unsigned int divisor1; @@ -289,6 +289,30 @@ struct das16_private_struct { unsigned int can_burst:1; }; +static void das16_ai_enable(struct comedi_device *dev, + unsigned int mode, unsigned int src) +{ + struct das16_private_struct *devpriv = dev->private; + + devpriv->ctrl_reg &= ~(DAS16_INTE | DMA_ENABLE | PACING_MASK); + devpriv->ctrl_reg |= mode; + + if (src == TRIG_EXT) + devpriv->ctrl_reg |= EXT_PACER; + else + devpriv->ctrl_reg |= INT_PACER; + outb(devpriv->ctrl_reg, dev->iobase + DAS16_CONTROL); +} + +static void das16_ai_disable(struct comedi_device *dev) +{ + struct das16_private_struct *devpriv = dev->private; + + /* disable interrupts, dma and pacer clocked conversions */ + devpriv->ctrl_reg &= ~(DAS16_INTE | DMA_ENABLE | PACING_MASK); + outb(devpriv->ctrl_reg, dev->iobase + DAS16_CONTROL); +} + static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { @@ -499,19 +523,12 @@ static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->timer_running = 1; devpriv->timer.expires = jiffies + timer_period(); add_timer(&devpriv->timer); - devpriv->control_state &= ~DAS16_INTE; - devpriv->control_state |= DMA_ENABLE; - devpriv->control_state &= ~PACING_MASK; - if (cmd->convert_src == TRIG_EXT) - devpriv->control_state |= EXT_PACER; - else - devpriv->control_state |= INT_PACER; - outb(devpriv->control_state, dev->iobase + DAS16_CONTROL); + + das16_ai_enable(dev, DMA_ENABLE, cmd->convert_src); if (devpriv->can_burst) outb(0, dev->iobase + DAS1600_CONV); - return 0; } @@ -521,9 +538,8 @@ static int das16_cancel(struct comedi_device *dev, struct comedi_subdevice *s) unsigned long flags; spin_lock_irqsave(&dev->spinlock, flags); - /* disable interrupts, dma and pacer clocked conversions */ - devpriv->control_state &= ~DAS16_INTE & ~PACING_MASK & ~DMA_ENABLE; - outb(devpriv->control_state, dev->iobase + DAS16_CONTROL); + + das16_ai_disable(dev); disable_dma(devpriv->dma_chan); /* disable SW timer */ @@ -554,14 +570,11 @@ static int das16_ai_insn_read(struct comedi_device *dev, unsigned int *data) { const struct das16_board *board = comedi_board(dev); - struct das16_private_struct *devpriv = dev->private; int i, n; int range; int chan; - /* disable interrupts and pacing */ - devpriv->control_state &= ~DAS16_INTE & ~DMA_ENABLE & ~PACING_MASK; - outb(devpriv->control_state, dev->iobase + DAS16_CONTROL); + das16_ai_disable(dev); /* set multiplexer */ chan = CR_CHAN(insn->chanspec); @@ -707,7 +720,7 @@ static void das16_interrupt(struct comedi_device *dev) cmd = &async->cmd; spin_lock_irqsave(&dev->spinlock, spin_flags); - if ((devpriv->control_state & DMA_ENABLE) == 0) { + if ((devpriv->ctrl_reg & DMA_ENABLE) == 0) { spin_unlock_irqrestore(&dev->spinlock, spin_flags); return; } @@ -1027,8 +1040,8 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) das16_reset(dev); /* set the interrupt level */ - devpriv->control_state = DAS16_IRQ(dev->irq); - outb(devpriv->control_state, dev->iobase + DAS16_CONTROL); + devpriv->ctrl_reg = DAS16_IRQ(dev->irq); + outb(devpriv->ctrl_reg, dev->iobase + DAS16_CONTROL); if (devpriv->can_burst) { outb(DAS1600_ENABLE_VAL, dev->iobase + DAS1600_ENABLE); -- GitLab From 73ef2b5387ff95ac24487934250e9749e8aaa217 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 14:02:22 -0700 Subject: [PATCH 372/942] staging: comedi: das16: tidy up das16_ai_insn_read() Factor out the loop that waits for the ai conversion to complete. Tidy up the function a bit. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 50 ++++++++++++++------------ 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index f6d0f7e868b27..a482bd524e9ba 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -253,8 +253,6 @@ struct das16_board { unsigned int id; }; -#define DAS16_TIMEOUT 1000 - /* Period for timer interrupt in jiffies. It's a function * to deal with possibility of dynamic HZ patches */ static inline int timer_period(void) @@ -564,55 +562,61 @@ static void das16_reset(struct comedi_device *dev) outb(0, dev->iobase + DAS16_CNTR_CONTROL); } +static int das16_ai_wait_for_conv(struct comedi_device *dev, + unsigned int timeout) +{ + unsigned int status; + int i; + + for (i = 0; i < timeout; i++) { + status = inb(dev->iobase + DAS16_STATUS); + if (!(status & BUSY)) + return 0; + } + return -ETIME; +} + static int das16_ai_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { const struct das16_board *board = comedi_board(dev); - int i, n; - int range; - int chan; + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned int range = CR_RANGE(insn->chanspec); + unsigned int val; + int ret; + int i; das16_ai_disable(dev); /* set multiplexer */ - chan = CR_CHAN(insn->chanspec); - chan |= CR_CHAN(insn->chanspec) << 4; - outb(chan, dev->iobase + DAS16_MUX); + outb(chan | (chan << 4), dev->iobase + DAS16_MUX); /* set gain */ if (board->ai_pg != das16_pg_none) { - range = CR_RANGE(insn->chanspec); outb((das16_gainlists[board->ai_pg])[range], dev->iobase + DAS16_GAIN); } - for (n = 0; n < insn->n; n++) { - unsigned int val; - + for (i = 0; i < insn->n; i++) { /* trigger conversion */ outb_p(0, dev->iobase + DAS16_TRIG); - for (i = 0; i < DAS16_TIMEOUT; i++) { - if (!(inb(dev->iobase + DAS16_STATUS) & BUSY)) - break; - } - if (i == DAS16_TIMEOUT) { - printk("das16: timeout\n"); - return -ETIME; - } + ret = das16_ai_wait_for_conv(dev, 1000); + if (ret) + return ret; val = inb(dev->iobase + DAS16_AI_MSB) << 8; val |= inb(dev->iobase + DAS16_AI_LSB); if (s->maxdata == 0x0fff) - data[n] >>= 4; + val >>= 4; val &= s->maxdata; - data[n] = val; + data[i] = val; } - return n; + return insn->n; } static int das16_di_insn_bits(struct comedi_device *dev, -- GitLab From 372f3bb949482c6f0a53c03942d6def634fc2804 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 14:02:48 -0700 Subject: [PATCH 373/942] staging: comedi: das16: move some functions to improve readability For aesthetics, move some of the functions to make the code easier to follow. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 300 ++++++++++++------------- 1 file changed, 146 insertions(+), 154 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index a482bd524e9ba..cd2fa4cafc441 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -311,6 +311,116 @@ static void das16_ai_disable(struct comedi_device *dev) outb(devpriv->ctrl_reg, dev->iobase + DAS16_CONTROL); } +/* the pc104-das16jr (at least) has problems if the dma + transfer is interrupted in the middle of transferring + a 16 bit sample, so this function takes care to get + an even transfer count after disabling dma + channel. +*/ +static int disable_dma_on_even(struct comedi_device *dev) +{ + struct das16_private_struct *devpriv = dev->private; + int residue; + int i; + static const int disable_limit = 100; + static const int enable_timeout = 100; + + disable_dma(devpriv->dma_chan); + residue = get_dma_residue(devpriv->dma_chan); + for (i = 0; i < disable_limit && (residue % 2); ++i) { + int j; + enable_dma(devpriv->dma_chan); + for (j = 0; j < enable_timeout; ++j) { + int new_residue; + udelay(2); + new_residue = get_dma_residue(devpriv->dma_chan); + if (new_residue != residue) + break; + } + disable_dma(devpriv->dma_chan); + residue = get_dma_residue(devpriv->dma_chan); + } + if (i == disable_limit) { + comedi_error(dev, "failed to get an even dma transfer, " + "could be trouble."); + } + return residue; +} + +static void das16_interrupt(struct comedi_device *dev) +{ + struct das16_private_struct *devpriv = dev->private; + unsigned long dma_flags, spin_flags; + struct comedi_subdevice *s = dev->read_subdev; + struct comedi_async *async; + struct comedi_cmd *cmd; + int num_bytes, residue; + int buffer_index; + + if (!dev->attached) { + comedi_error(dev, "premature interrupt"); + return; + } + /* initialize async here to make sure it is not NULL */ + async = s->async; + cmd = &async->cmd; + + spin_lock_irqsave(&dev->spinlock, spin_flags); + if ((devpriv->ctrl_reg & DMA_ENABLE) == 0) { + spin_unlock_irqrestore(&dev->spinlock, spin_flags); + return; + } + + dma_flags = claim_dma_lock(); + clear_dma_ff(devpriv->dma_chan); + residue = disable_dma_on_even(dev); + + /* figure out how many points to read */ + if (residue > devpriv->dma_transfer_size) { + comedi_error(dev, "residue > transfer size!\n"); + async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA; + num_bytes = 0; + } else + num_bytes = devpriv->dma_transfer_size - residue; + + if (cmd->stop_src == TRIG_COUNT && + num_bytes >= devpriv->adc_byte_count) { + num_bytes = devpriv->adc_byte_count; + async->events |= COMEDI_CB_EOA; + } + + buffer_index = devpriv->current_buffer; + devpriv->current_buffer = (devpriv->current_buffer + 1) % 2; + devpriv->adc_byte_count -= num_bytes; + + /* re-enable dma */ + if ((async->events & COMEDI_CB_EOA) == 0) { + set_dma_addr(devpriv->dma_chan, + devpriv->dma_buffer_addr[devpriv->current_buffer]); + set_dma_count(devpriv->dma_chan, devpriv->dma_transfer_size); + enable_dma(devpriv->dma_chan); + } + release_dma_lock(dma_flags); + + spin_unlock_irqrestore(&dev->spinlock, spin_flags); + + cfc_write_array_to_buffer(s, + devpriv->dma_buffer[buffer_index], num_bytes); + + cfc_handle_events(dev, s); +} + +static void das16_timer_interrupt(unsigned long arg) +{ + struct comedi_device *dev = (struct comedi_device *)arg; + struct das16_private_struct *devpriv = dev->private; + + das16_interrupt(dev); + + if (devpriv->timer_running) + mod_timer(&devpriv->timer, jiffies + timer_period()); +} + static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { @@ -554,12 +664,20 @@ static int das16_cancel(struct comedi_device *dev, struct comedi_subdevice *s) return 0; } -static void das16_reset(struct comedi_device *dev) +static void das16_ai_munge(struct comedi_device *dev, + struct comedi_subdevice *s, void *array, + unsigned int num_bytes, + unsigned int start_chan_index) { - outb(0, dev->iobase + DAS16_STATUS); - outb(0, dev->iobase + DAS16_CONTROL); - outb(0, dev->iobase + DAS16_PACER); - outb(0, dev->iobase + DAS16_CNTR_CONTROL); + unsigned int i, num_samples = num_bytes / sizeof(short); + short *data = array; + + for (i = 0; i < num_samples; i++) { + data[i] = le16_to_cpu(data[i]); + if (s->maxdata == 0x0fff) + data[i] >>= 4; + data[i] &= s->maxdata; + } } static int das16_ai_wait_for_conv(struct comedi_device *dev, @@ -619,36 +737,6 @@ static int das16_ai_insn_read(struct comedi_device *dev, return insn->n; } -static int das16_di_insn_bits(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - data[1] = inb(dev->iobase + DAS16_DIO) & 0xf; - - return insn->n; -} - -static int das16_do_insn_bits(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - unsigned int mask = data[0]; - unsigned int bits = data[1]; - - if (mask) { - s->state &= ~mask; - s->state |= (bits & mask); - - outb(s->state, dev->iobase + DAS16_DIO); - } - - data[1] = s->state; - - return insn->n; -} - static int das16_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, @@ -669,114 +757,34 @@ static int das16_ao_insn_write(struct comedi_device *dev, return insn->n; } -/* the pc104-das16jr (at least) has problems if the dma - transfer is interrupted in the middle of transferring - a 16 bit sample, so this function takes care to get - an even transfer count after disabling dma - channel. -*/ -static int disable_dma_on_even(struct comedi_device *dev) +static int das16_di_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { - struct das16_private_struct *devpriv = dev->private; - int residue; - int i; - static const int disable_limit = 100; - static const int enable_timeout = 100; + data[1] = inb(dev->iobase + DAS16_DIO) & 0xf; - disable_dma(devpriv->dma_chan); - residue = get_dma_residue(devpriv->dma_chan); - for (i = 0; i < disable_limit && (residue % 2); ++i) { - int j; - enable_dma(devpriv->dma_chan); - for (j = 0; j < enable_timeout; ++j) { - int new_residue; - udelay(2); - new_residue = get_dma_residue(devpriv->dma_chan); - if (new_residue != residue) - break; - } - disable_dma(devpriv->dma_chan); - residue = get_dma_residue(devpriv->dma_chan); - } - if (i == disable_limit) { - comedi_error(dev, "failed to get an even dma transfer, " - "could be trouble."); - } - return residue; + return insn->n; } -static void das16_interrupt(struct comedi_device *dev) +static int das16_do_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { - struct das16_private_struct *devpriv = dev->private; - unsigned long dma_flags, spin_flags; - struct comedi_subdevice *s = dev->read_subdev; - struct comedi_async *async; - struct comedi_cmd *cmd; - int num_bytes, residue; - int buffer_index; - - if (!dev->attached) { - comedi_error(dev, "premature interrupt"); - return; - } - /* initialize async here to make sure it is not NULL */ - async = s->async; - cmd = &async->cmd; - - spin_lock_irqsave(&dev->spinlock, spin_flags); - if ((devpriv->ctrl_reg & DMA_ENABLE) == 0) { - spin_unlock_irqrestore(&dev->spinlock, spin_flags); - return; - } - - dma_flags = claim_dma_lock(); - clear_dma_ff(devpriv->dma_chan); - residue = disable_dma_on_even(dev); - - /* figure out how many points to read */ - if (residue > devpriv->dma_transfer_size) { - comedi_error(dev, "residue > transfer size!\n"); - async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA; - num_bytes = 0; - } else - num_bytes = devpriv->dma_transfer_size - residue; - - if (cmd->stop_src == TRIG_COUNT && - num_bytes >= devpriv->adc_byte_count) { - num_bytes = devpriv->adc_byte_count; - async->events |= COMEDI_CB_EOA; - } + unsigned int mask = data[0]; + unsigned int bits = data[1]; - buffer_index = devpriv->current_buffer; - devpriv->current_buffer = (devpriv->current_buffer + 1) % 2; - devpriv->adc_byte_count -= num_bytes; + if (mask) { + s->state &= ~mask; + s->state |= (bits & mask); - /* re-enable dma */ - if ((async->events & COMEDI_CB_EOA) == 0) { - set_dma_addr(devpriv->dma_chan, - devpriv->dma_buffer_addr[devpriv->current_buffer]); - set_dma_count(devpriv->dma_chan, devpriv->dma_transfer_size); - enable_dma(devpriv->dma_chan); + outb(s->state, dev->iobase + DAS16_DIO); } - release_dma_lock(dma_flags); - - spin_unlock_irqrestore(&dev->spinlock, spin_flags); - cfc_write_array_to_buffer(s, - devpriv->dma_buffer[buffer_index], num_bytes); - - cfc_handle_events(dev, s); -} - -static void das16_timer_interrupt(unsigned long arg) -{ - struct comedi_device *dev = (struct comedi_device *)arg; - struct das16_private_struct *devpriv = dev->private; - - das16_interrupt(dev); + data[1] = s->state; - if (devpriv->timer_running) - mod_timer(&devpriv->timer, jiffies + timer_period()); + return insn->n; } static int das16_probe(struct comedi_device *dev, struct comedi_devconfig *it) @@ -814,30 +822,14 @@ static int das1600_mode_detect(struct comedi_device *dev) return 0; } -static void das16_ai_munge(struct comedi_device *dev, - struct comedi_subdevice *s, void *array, - unsigned int num_bytes, - unsigned int start_chan_index) +static void das16_reset(struct comedi_device *dev) { - unsigned int i, num_samples = num_bytes / sizeof(short); - short *data = array; - - for (i = 0; i < num_samples; i++) { - data[i] = le16_to_cpu(data[i]); - if (s->maxdata == 0x0fff) - data[i] >>= 4; - data[i] &= s->maxdata; - } + outb(0, dev->iobase + DAS16_STATUS); + outb(0, dev->iobase + DAS16_CONTROL); + outb(0, dev->iobase + DAS16_PACER); + outb(0, dev->iobase + DAS16_CNTR_CONTROL); } -/* - * - * Options list: - * 0 I/O base - * 1 IRQ - * 2 DMA - * 3 Clock speed (in MHz) - */ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) { const struct das16_board *board = comedi_board(dev); -- GitLab From b65daeef1d2401a18ecdcc73fa8f263cb64cdd5d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 14:03:11 -0700 Subject: [PATCH 374/942] staging: comedi: das16: remove unnecessary test in das16_interrupt() The timer is only started by the ai subdevice in das16_cmd_exec() and this function can only be called if the device is attached. Remove the unnecessary sanity check. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index cd2fa4cafc441..df7bf1e26c5ed 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -350,21 +350,14 @@ static int disable_dma_on_even(struct comedi_device *dev) static void das16_interrupt(struct comedi_device *dev) { struct das16_private_struct *devpriv = dev->private; - unsigned long dma_flags, spin_flags; struct comedi_subdevice *s = dev->read_subdev; - struct comedi_async *async; - struct comedi_cmd *cmd; + struct comedi_async *async = s->async; + struct comedi_cmd *cmd = &async->cmd; + unsigned long spin_flags; + unsigned long dma_flags; int num_bytes, residue; int buffer_index; - if (!dev->attached) { - comedi_error(dev, "premature interrupt"); - return; - } - /* initialize async here to make sure it is not NULL */ - async = s->async; - cmd = &async->cmd; - spin_lock_irqsave(&dev->spinlock, spin_flags); if ((devpriv->ctrl_reg & DMA_ENABLE) == 0) { spin_unlock_irqrestore(&dev->spinlock, spin_flags); -- GitLab From 46399a84b730d9c27e9e967eabe45d280ee79163 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 14:03:28 -0700 Subject: [PATCH 375/942] staging: comedi: das16: move boardinfo declaration Now that the boardinfo does not require any forward declarations, move it near the definition of the struct. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 424 ++++++++++++------------- 1 file changed, 212 insertions(+), 212 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index df7bf1e26c5ed..b04b3ae6bf035 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -253,6 +253,218 @@ struct das16_board { unsigned int id; }; +static const struct das16_board das16_boards[] = { + { + .name = "das-16", + .ai_maxdata = 0x0fff, + .ai_speed = 15000, + .ai_pg = das16_pg_none, + .has_ao = 1, + .i8255_offset = 0x10, + .i8254_offset = 0x0c, + .size = 0x14, + .id = 0x00, + }, { + .name = "das-16g", + .ai_maxdata = 0x0fff, + .ai_speed = 15000, + .ai_pg = das16_pg_none, + .has_ao = 1, + .i8255_offset = 0x10, + .i8254_offset = 0x0c, + .size = 0x14, + .id = 0x00, + }, { + .name = "das-16f", + .ai_maxdata = 0x0fff, + .ai_speed = 8500, + .ai_pg = das16_pg_none, + .has_ao = 1, + .i8255_offset = 0x10, + .i8254_offset = 0x0c, + .size = 0x14, + .id = 0x00, + }, { + .name = "cio-das16", + .ai_maxdata = 0x0fff, + .ai_speed = 20000, + .ai_pg = das16_pg_none, + .has_ao = 1, + .i8255_offset = 0x10, + .i8254_offset = 0x0c, + .size = 0x14, + .id = 0x80, + }, { + .name = "cio-das16/f", + .ai_maxdata = 0x0fff, + .ai_speed = 10000, + .ai_pg = das16_pg_none, + .has_ao = 1, + .i8255_offset = 0x10, + .i8254_offset = 0x0c, + .size = 0x14, + .id = 0x80, + }, { + .name = "cio-das16/jr", + .ai_maxdata = 0x0fff, + .ai_speed = 7692, + .ai_pg = das16_pg_16jr, + .i8255_offset = 0, + .i8254_offset = 0x0c, + .size = 0x10, + .id = 0x00, + }, { + .name = "pc104-das16jr", + .ai_maxdata = 0x0fff, + .ai_speed = 3300, + .ai_pg = das16_pg_16jr, + .i8255_offset = 0, + .i8254_offset = 0x0c, + .size = 0x10, + .id = 0x00, + }, { + .name = "cio-das16jr/16", + .ai_maxdata = 0xffff, + .ai_speed = 10000, + .ai_pg = das16_pg_16jr_16, + .i8255_offset = 0, + .i8254_offset = 0x0c, + .size = 0x10, + .id = 0x00, + }, { + .name = "pc104-das16jr/16", + .ai_maxdata = 0xffff, + .ai_speed = 10000, + .ai_pg = das16_pg_16jr_16, + .i8255_offset = 0, + .i8254_offset = 0x0c, + .size = 0x10, + .id = 0x00, + }, { + .name = "das-1201", + .ai_maxdata = 0x0fff, + .ai_speed = 20000, + .ai_pg = das16_pg_none, + .i8255_offset = 0x400, + .i8254_offset = 0x0c, + .size = 0x408, + .id = 0x20, + }, { + .name = "das-1202", + .ai_maxdata = 0x0fff, + .ai_speed = 10000, + .ai_pg = das16_pg_none, + .i8255_offset = 0x400, + .i8254_offset = 0x0c, + .size = 0x408, + .id = 0x20, + }, { + .name = "das-1401", + .ai_maxdata = 0x0fff, + .ai_speed = 10000, + .ai_pg = das16_pg_1601, + .i8255_offset = 0x0, + .i8254_offset = 0x0c, + .size = 0x408, + .id = 0xc0, + }, { + .name = "das-1402", + .ai_maxdata = 0x0fff, + .ai_speed = 10000, + .ai_pg = das16_pg_1602, + .i8255_offset = 0x0, + .i8254_offset = 0x0c, + .size = 0x408, + .id = 0xc0, + }, { + .name = "das-1601", + .ai_maxdata = 0x0fff, + .ai_speed = 10000, + .ai_pg = das16_pg_1601, + .has_ao = 1, + .i8255_offset = 0x400, + .i8254_offset = 0x0c, + .size = 0x408, + .id = 0xc0, + }, { + .name = "das-1602", + .ai_maxdata = 0x0fff, + .ai_speed = 10000, + .ai_pg = das16_pg_1602, + .has_ao = 1, + .i8255_offset = 0x400, + .i8254_offset = 0x0c, + .size = 0x408, + .id = 0xc0, + }, { + .name = "cio-das1401/12", + .ai_maxdata = 0x0fff, + .ai_speed = 6250, + .ai_pg = das16_pg_1601, + .i8255_offset = 0, + .i8254_offset = 0x0c, + .size = 0x408, + .id = 0xc0, + }, { + .name = "cio-das1402/12", + .ai_maxdata = 0x0fff, + .ai_speed = 6250, + .ai_pg = das16_pg_1602, + .i8255_offset = 0, + .i8254_offset = 0x0c, + .size = 0x408, + .id = 0xc0, + }, { + .name = "cio-das1402/16", + .ai_maxdata = 0xffff, + .ai_speed = 10000, + .ai_pg = das16_pg_1602, + .i8255_offset = 0, + .i8254_offset = 0x0c, + .size = 0x408, + .id = 0xc0, + }, { + .name = "cio-das1601/12", + .ai_maxdata = 0x0fff, + .ai_speed = 6250, + .ai_pg = das16_pg_1601, + .has_ao = 1, + .i8255_offset = 0x400, + .i8254_offset = 0x0c, + .size = 0x408, + .id = 0xc0, + }, { + .name = "cio-das1602/12", + .ai_maxdata = 0x0fff, + .ai_speed = 10000, + .ai_pg = das16_pg_1602, + .has_ao = 1, + .i8255_offset = 0x400, + .i8254_offset = 0x0c, + .size = 0x408, + .id = 0xc0, + }, { + .name = "cio-das1602/16", + .ai_maxdata = 0xffff, + .ai_speed = 10000, + .ai_pg = das16_pg_1602, + .has_ao = 1, + .i8255_offset = 0x400, + .i8254_offset = 0x0c, + .size = 0x408, + .id = 0xc0, + }, { + .name = "cio-das16/330", + .ai_maxdata = 0x0fff, + .ai_speed = 3030, + .ai_pg = das16_pg_16jr, + .i8255_offset = 0, + .i8254_offset = 0x0c, + .size = 0x14, + .id = 0xf0, + }, +}; + /* Period for timer interrupt in jiffies. It's a function * to deal with possibility of dynamic HZ patches */ static inline int timer_period(void) @@ -1066,218 +1278,6 @@ static void das16_detach(struct comedi_device *dev) comedi_legacy_detach(dev); } -static const struct das16_board das16_boards[] = { - { - .name = "das-16", - .ai_maxdata = 0x0fff, - .ai_speed = 15000, - .ai_pg = das16_pg_none, - .has_ao = 1, - .i8255_offset = 0x10, - .i8254_offset = 0x0c, - .size = 0x14, - .id = 0x00, - }, { - .name = "das-16g", - .ai_maxdata = 0x0fff, - .ai_speed = 15000, - .ai_pg = das16_pg_none, - .has_ao = 1, - .i8255_offset = 0x10, - .i8254_offset = 0x0c, - .size = 0x14, - .id = 0x00, - }, { - .name = "das-16f", - .ai_maxdata = 0x0fff, - .ai_speed = 8500, - .ai_pg = das16_pg_none, - .has_ao = 1, - .i8255_offset = 0x10, - .i8254_offset = 0x0c, - .size = 0x14, - .id = 0x00, - }, { - .name = "cio-das16", - .ai_maxdata = 0x0fff, - .ai_speed = 20000, - .ai_pg = das16_pg_none, - .has_ao = 1, - .i8255_offset = 0x10, - .i8254_offset = 0x0c, - .size = 0x14, - .id = 0x80, - }, { - .name = "cio-das16/f", - .ai_maxdata = 0x0fff, - .ai_speed = 10000, - .ai_pg = das16_pg_none, - .has_ao = 1, - .i8255_offset = 0x10, - .i8254_offset = 0x0c, - .size = 0x14, - .id = 0x80, - }, { - .name = "cio-das16/jr", - .ai_maxdata = 0x0fff, - .ai_speed = 7692, - .ai_pg = das16_pg_16jr, - .i8255_offset = 0, - .i8254_offset = 0x0c, - .size = 0x10, - .id = 0x00, - }, { - .name = "pc104-das16jr", - .ai_maxdata = 0x0fff, - .ai_speed = 3300, - .ai_pg = das16_pg_16jr, - .i8255_offset = 0, - .i8254_offset = 0x0c, - .size = 0x10, - .id = 0x00, - }, { - .name = "cio-das16jr/16", - .ai_maxdata = 0xffff, - .ai_speed = 10000, - .ai_pg = das16_pg_16jr_16, - .i8255_offset = 0, - .i8254_offset = 0x0c, - .size = 0x10, - .id = 0x00, - }, { - .name = "pc104-das16jr/16", - .ai_maxdata = 0xffff, - .ai_speed = 10000, - .ai_pg = das16_pg_16jr_16, - .i8255_offset = 0, - .i8254_offset = 0x0c, - .size = 0x10, - .id = 0x00, - }, { - .name = "das-1201", - .ai_maxdata = 0x0fff, - .ai_speed = 20000, - .ai_pg = das16_pg_none, - .i8255_offset = 0x400, - .i8254_offset = 0x0c, - .size = 0x408, - .id = 0x20, - }, { - .name = "das-1202", - .ai_maxdata = 0x0fff, - .ai_speed = 10000, - .ai_pg = das16_pg_none, - .i8255_offset = 0x400, - .i8254_offset = 0x0c, - .size = 0x408, - .id = 0x20, - }, { - .name = "das-1401", - .ai_maxdata = 0x0fff, - .ai_speed = 10000, - .ai_pg = das16_pg_1601, - .i8255_offset = 0x0, - .i8254_offset = 0x0c, - .size = 0x408, - .id = 0xc0, - }, { - .name = "das-1402", - .ai_maxdata = 0x0fff, - .ai_speed = 10000, - .ai_pg = das16_pg_1602, - .i8255_offset = 0x0, - .i8254_offset = 0x0c, - .size = 0x408, - .id = 0xc0, - }, { - .name = "das-1601", - .ai_maxdata = 0x0fff, - .ai_speed = 10000, - .ai_pg = das16_pg_1601, - .has_ao = 1, - .i8255_offset = 0x400, - .i8254_offset = 0x0c, - .size = 0x408, - .id = 0xc0, - }, { - .name = "das-1602", - .ai_maxdata = 0x0fff, - .ai_speed = 10000, - .ai_pg = das16_pg_1602, - .has_ao = 1, - .i8255_offset = 0x400, - .i8254_offset = 0x0c, - .size = 0x408, - .id = 0xc0, - }, { - .name = "cio-das1401/12", - .ai_maxdata = 0x0fff, - .ai_speed = 6250, - .ai_pg = das16_pg_1601, - .i8255_offset = 0, - .i8254_offset = 0x0c, - .size = 0x408, - .id = 0xc0, - }, { - .name = "cio-das1402/12", - .ai_maxdata = 0x0fff, - .ai_speed = 6250, - .ai_pg = das16_pg_1602, - .i8255_offset = 0, - .i8254_offset = 0x0c, - .size = 0x408, - .id = 0xc0, - }, { - .name = "cio-das1402/16", - .ai_maxdata = 0xffff, - .ai_speed = 10000, - .ai_pg = das16_pg_1602, - .i8255_offset = 0, - .i8254_offset = 0x0c, - .size = 0x408, - .id = 0xc0, - }, { - .name = "cio-das1601/12", - .ai_maxdata = 0x0fff, - .ai_speed = 6250, - .ai_pg = das16_pg_1601, - .has_ao = 1, - .i8255_offset = 0x400, - .i8254_offset = 0x0c, - .size = 0x408, - .id = 0xc0, - }, { - .name = "cio-das1602/12", - .ai_maxdata = 0x0fff, - .ai_speed = 10000, - .ai_pg = das16_pg_1602, - .has_ao = 1, - .i8255_offset = 0x400, - .i8254_offset = 0x0c, - .size = 0x408, - .id = 0xc0, - }, { - .name = "cio-das1602/16", - .ai_maxdata = 0xffff, - .ai_speed = 10000, - .ai_pg = das16_pg_1602, - .has_ao = 1, - .i8255_offset = 0x400, - .i8254_offset = 0x0c, - .size = 0x408, - .id = 0xc0, - }, { - .name = "cio-das16/330", - .ai_maxdata = 0x0fff, - .ai_speed = 3030, - .ai_pg = das16_pg_16jr, - .i8255_offset = 0, - .i8254_offset = 0x0c, - .size = 0x14, - .id = 0xf0, - }, -}; - static struct comedi_driver das16_driver = { .driver_name = "das16", .module = THIS_MODULE, -- GitLab From 22cfc772f5e55341708ac31881df69e233787b8a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 14:03:46 -0700 Subject: [PATCH 376/942] staging: comedi: das16: remove 'i8254_offset' from boardinfo All the boards supported by this driver have an 8254 timer at offset 0x0c. Remove this unused information from the boardinfo. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index b04b3ae6bf035..c7b664ae5c79f 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -247,7 +247,6 @@ struct das16_board { unsigned int has_ao:1; unsigned int i8255_offset; - unsigned int i8254_offset; unsigned int size; unsigned int id; @@ -261,7 +260,6 @@ static const struct das16_board das16_boards[] = { .ai_pg = das16_pg_none, .has_ao = 1, .i8255_offset = 0x10, - .i8254_offset = 0x0c, .size = 0x14, .id = 0x00, }, { @@ -271,7 +269,6 @@ static const struct das16_board das16_boards[] = { .ai_pg = das16_pg_none, .has_ao = 1, .i8255_offset = 0x10, - .i8254_offset = 0x0c, .size = 0x14, .id = 0x00, }, { @@ -281,7 +278,6 @@ static const struct das16_board das16_boards[] = { .ai_pg = das16_pg_none, .has_ao = 1, .i8255_offset = 0x10, - .i8254_offset = 0x0c, .size = 0x14, .id = 0x00, }, { @@ -291,7 +287,6 @@ static const struct das16_board das16_boards[] = { .ai_pg = das16_pg_none, .has_ao = 1, .i8255_offset = 0x10, - .i8254_offset = 0x0c, .size = 0x14, .id = 0x80, }, { @@ -301,7 +296,6 @@ static const struct das16_board das16_boards[] = { .ai_pg = das16_pg_none, .has_ao = 1, .i8255_offset = 0x10, - .i8254_offset = 0x0c, .size = 0x14, .id = 0x80, }, { @@ -310,7 +304,6 @@ static const struct das16_board das16_boards[] = { .ai_speed = 7692, .ai_pg = das16_pg_16jr, .i8255_offset = 0, - .i8254_offset = 0x0c, .size = 0x10, .id = 0x00, }, { @@ -319,7 +312,6 @@ static const struct das16_board das16_boards[] = { .ai_speed = 3300, .ai_pg = das16_pg_16jr, .i8255_offset = 0, - .i8254_offset = 0x0c, .size = 0x10, .id = 0x00, }, { @@ -328,7 +320,6 @@ static const struct das16_board das16_boards[] = { .ai_speed = 10000, .ai_pg = das16_pg_16jr_16, .i8255_offset = 0, - .i8254_offset = 0x0c, .size = 0x10, .id = 0x00, }, { @@ -337,7 +328,6 @@ static const struct das16_board das16_boards[] = { .ai_speed = 10000, .ai_pg = das16_pg_16jr_16, .i8255_offset = 0, - .i8254_offset = 0x0c, .size = 0x10, .id = 0x00, }, { @@ -346,7 +336,6 @@ static const struct das16_board das16_boards[] = { .ai_speed = 20000, .ai_pg = das16_pg_none, .i8255_offset = 0x400, - .i8254_offset = 0x0c, .size = 0x408, .id = 0x20, }, { @@ -355,7 +344,6 @@ static const struct das16_board das16_boards[] = { .ai_speed = 10000, .ai_pg = das16_pg_none, .i8255_offset = 0x400, - .i8254_offset = 0x0c, .size = 0x408, .id = 0x20, }, { @@ -364,7 +352,6 @@ static const struct das16_board das16_boards[] = { .ai_speed = 10000, .ai_pg = das16_pg_1601, .i8255_offset = 0x0, - .i8254_offset = 0x0c, .size = 0x408, .id = 0xc0, }, { @@ -373,7 +360,6 @@ static const struct das16_board das16_boards[] = { .ai_speed = 10000, .ai_pg = das16_pg_1602, .i8255_offset = 0x0, - .i8254_offset = 0x0c, .size = 0x408, .id = 0xc0, }, { @@ -383,7 +369,6 @@ static const struct das16_board das16_boards[] = { .ai_pg = das16_pg_1601, .has_ao = 1, .i8255_offset = 0x400, - .i8254_offset = 0x0c, .size = 0x408, .id = 0xc0, }, { @@ -393,7 +378,6 @@ static const struct das16_board das16_boards[] = { .ai_pg = das16_pg_1602, .has_ao = 1, .i8255_offset = 0x400, - .i8254_offset = 0x0c, .size = 0x408, .id = 0xc0, }, { @@ -402,7 +386,6 @@ static const struct das16_board das16_boards[] = { .ai_speed = 6250, .ai_pg = das16_pg_1601, .i8255_offset = 0, - .i8254_offset = 0x0c, .size = 0x408, .id = 0xc0, }, { @@ -411,7 +394,6 @@ static const struct das16_board das16_boards[] = { .ai_speed = 6250, .ai_pg = das16_pg_1602, .i8255_offset = 0, - .i8254_offset = 0x0c, .size = 0x408, .id = 0xc0, }, { @@ -420,7 +402,6 @@ static const struct das16_board das16_boards[] = { .ai_speed = 10000, .ai_pg = das16_pg_1602, .i8255_offset = 0, - .i8254_offset = 0x0c, .size = 0x408, .id = 0xc0, }, { @@ -430,7 +411,6 @@ static const struct das16_board das16_boards[] = { .ai_pg = das16_pg_1601, .has_ao = 1, .i8255_offset = 0x400, - .i8254_offset = 0x0c, .size = 0x408, .id = 0xc0, }, { @@ -440,7 +420,6 @@ static const struct das16_board das16_boards[] = { .ai_pg = das16_pg_1602, .has_ao = 1, .i8255_offset = 0x400, - .i8254_offset = 0x0c, .size = 0x408, .id = 0xc0, }, { @@ -450,7 +429,6 @@ static const struct das16_board das16_boards[] = { .ai_pg = das16_pg_1602, .has_ao = 1, .i8255_offset = 0x400, - .i8254_offset = 0x0c, .size = 0x408, .id = 0xc0, }, { @@ -459,7 +437,6 @@ static const struct das16_board das16_boards[] = { .ai_speed = 3030, .ai_pg = das16_pg_16jr, .i8255_offset = 0, - .i8254_offset = 0x0c, .size = 0x14, .id = 0xf0, }, -- GitLab From 21b8f248976f7270595f27e878f0026baf99e6e3 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 14:04:13 -0700 Subject: [PATCH 377/942] staging: comedi: das16: tidy up 8255 digital i/o subdevice The 8255 digital i/o subdevice is only available on some of the boards supported by this driver. Currently the 'i8255_offset' member of the boardinfo is used to indicate that it is available. To clarify this support, add a 'has_8255' bit-field flag to the boardinfo. We can then use this flag to conditionally allocate the space for the subdevice only when it is needed. Also, make sure to check that subdev_8255_init() is successful and propagate any errors. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 39 ++++++++++++++------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index c7b664ae5c79f..8da7ee34d57dd 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -245,6 +245,7 @@ struct das16_board { unsigned int ai_speed; /* max conversion speed in nanosec */ unsigned int ai_pg; unsigned int has_ao:1; + unsigned int has_8255:1; unsigned int i8255_offset; @@ -259,6 +260,7 @@ static const struct das16_board das16_boards[] = { .ai_speed = 15000, .ai_pg = das16_pg_none, .has_ao = 1, + .has_8255 = 1, .i8255_offset = 0x10, .size = 0x14, .id = 0x00, @@ -268,6 +270,7 @@ static const struct das16_board das16_boards[] = { .ai_speed = 15000, .ai_pg = das16_pg_none, .has_ao = 1, + .has_8255 = 1, .i8255_offset = 0x10, .size = 0x14, .id = 0x00, @@ -277,6 +280,7 @@ static const struct das16_board das16_boards[] = { .ai_speed = 8500, .ai_pg = das16_pg_none, .has_ao = 1, + .has_8255 = 1, .i8255_offset = 0x10, .size = 0x14, .id = 0x00, @@ -286,6 +290,7 @@ static const struct das16_board das16_boards[] = { .ai_speed = 20000, .ai_pg = das16_pg_none, .has_ao = 1, + .has_8255 = 1, .i8255_offset = 0x10, .size = 0x14, .id = 0x80, @@ -295,6 +300,7 @@ static const struct das16_board das16_boards[] = { .ai_speed = 10000, .ai_pg = das16_pg_none, .has_ao = 1, + .has_8255 = 1, .i8255_offset = 0x10, .size = 0x14, .id = 0x80, @@ -303,7 +309,6 @@ static const struct das16_board das16_boards[] = { .ai_maxdata = 0x0fff, .ai_speed = 7692, .ai_pg = das16_pg_16jr, - .i8255_offset = 0, .size = 0x10, .id = 0x00, }, { @@ -311,7 +316,6 @@ static const struct das16_board das16_boards[] = { .ai_maxdata = 0x0fff, .ai_speed = 3300, .ai_pg = das16_pg_16jr, - .i8255_offset = 0, .size = 0x10, .id = 0x00, }, { @@ -319,7 +323,6 @@ static const struct das16_board das16_boards[] = { .ai_maxdata = 0xffff, .ai_speed = 10000, .ai_pg = das16_pg_16jr_16, - .i8255_offset = 0, .size = 0x10, .id = 0x00, }, { @@ -327,7 +330,6 @@ static const struct das16_board das16_boards[] = { .ai_maxdata = 0xffff, .ai_speed = 10000, .ai_pg = das16_pg_16jr_16, - .i8255_offset = 0, .size = 0x10, .id = 0x00, }, { @@ -335,6 +337,7 @@ static const struct das16_board das16_boards[] = { .ai_maxdata = 0x0fff, .ai_speed = 20000, .ai_pg = das16_pg_none, + .has_8255 = 1, .i8255_offset = 0x400, .size = 0x408, .id = 0x20, @@ -343,6 +346,7 @@ static const struct das16_board das16_boards[] = { .ai_maxdata = 0x0fff, .ai_speed = 10000, .ai_pg = das16_pg_none, + .has_8255 = 1, .i8255_offset = 0x400, .size = 0x408, .id = 0x20, @@ -351,7 +355,6 @@ static const struct das16_board das16_boards[] = { .ai_maxdata = 0x0fff, .ai_speed = 10000, .ai_pg = das16_pg_1601, - .i8255_offset = 0x0, .size = 0x408, .id = 0xc0, }, { @@ -359,7 +362,6 @@ static const struct das16_board das16_boards[] = { .ai_maxdata = 0x0fff, .ai_speed = 10000, .ai_pg = das16_pg_1602, - .i8255_offset = 0x0, .size = 0x408, .id = 0xc0, }, { @@ -368,6 +370,7 @@ static const struct das16_board das16_boards[] = { .ai_speed = 10000, .ai_pg = das16_pg_1601, .has_ao = 1, + .has_8255 = 1, .i8255_offset = 0x400, .size = 0x408, .id = 0xc0, @@ -377,6 +380,7 @@ static const struct das16_board das16_boards[] = { .ai_speed = 10000, .ai_pg = das16_pg_1602, .has_ao = 1, + .has_8255 = 1, .i8255_offset = 0x400, .size = 0x408, .id = 0xc0, @@ -385,7 +389,6 @@ static const struct das16_board das16_boards[] = { .ai_maxdata = 0x0fff, .ai_speed = 6250, .ai_pg = das16_pg_1601, - .i8255_offset = 0, .size = 0x408, .id = 0xc0, }, { @@ -393,7 +396,6 @@ static const struct das16_board das16_boards[] = { .ai_maxdata = 0x0fff, .ai_speed = 6250, .ai_pg = das16_pg_1602, - .i8255_offset = 0, .size = 0x408, .id = 0xc0, }, { @@ -401,7 +403,6 @@ static const struct das16_board das16_boards[] = { .ai_maxdata = 0xffff, .ai_speed = 10000, .ai_pg = das16_pg_1602, - .i8255_offset = 0, .size = 0x408, .id = 0xc0, }, { @@ -410,6 +411,7 @@ static const struct das16_board das16_boards[] = { .ai_speed = 6250, .ai_pg = das16_pg_1601, .has_ao = 1, + .has_8255 = 1, .i8255_offset = 0x400, .size = 0x408, .id = 0xc0, @@ -419,6 +421,7 @@ static const struct das16_board das16_boards[] = { .ai_speed = 10000, .ai_pg = das16_pg_1602, .has_ao = 1, + .has_8255 = 1, .i8255_offset = 0x400, .size = 0x408, .id = 0xc0, @@ -428,6 +431,7 @@ static const struct das16_board das16_boards[] = { .ai_speed = 10000, .ai_pg = das16_pg_1602, .has_ao = 1, + .has_8255 = 1, .i8255_offset = 0x400, .size = 0x408, .id = 0xc0, @@ -436,7 +440,6 @@ static const struct das16_board das16_boards[] = { .ai_maxdata = 0x0fff, .ai_speed = 3030, .ai_pg = das16_pg_16jr, - .i8255_offset = 0, .size = 0x14, .id = 0xf0, }, @@ -1133,7 +1136,7 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) user_ao_range->flags = UNIT_volt; } - ret = comedi_alloc_subdevices(dev, 5); + ret = comedi_alloc_subdevices(dev, 4 + board->has_8255); if (ret) return ret; @@ -1207,13 +1210,13 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) /* initialize digital output lines */ outb(s->state, dev->iobase + DAS16_DIO); - s = &dev->subdevices[4]; - /* 8255 */ - if (board->i8255_offset != 0) { - subdev_8255_init(dev, s, NULL, (dev->iobase + - board->i8255_offset)); - } else { - s->type = COMEDI_SUBD_UNUSED; + /* 8255 Digital I/O subdevice */ + if (board->has_8255) { + s = &dev->subdevices[4]; + ret = subdev_8255_init(dev, s, NULL, + dev->iobase + board->i8255_offset); + if (ret) + return ret; } das16_reset(dev); -- GitLab From 0f13a8d02741f3fd301c5c0184e2c2d734f31a85 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 14:04:41 -0700 Subject: [PATCH 378/942] staging: comedi: das16: tidy up the register map defines Add the suffix _REG to all the register defines to better indicate what they are. Add a prefix to all the register bit defines to avoid namespace clashes and to better indicate what they are. Tidy up the whitesapce. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 185 ++++++++++++------------- 1 file changed, 90 insertions(+), 95 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index 8da7ee34d57dd..97ba2bd88485b 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -91,55 +91,45 @@ www.measurementcomputing.com /* * Register I/O map */ -#define DAS16_TRIG 0 -#define DAS16_AI_LSB 0 -#define DAS16_AI_MSB 1 -#define DAS16_MUX 2 -#define DAS16_DIO 3 -#define DAS16_AO_LSB(x) ((x) ? 6 : 4) -#define DAS16_AO_MSB(x) ((x) ? 7 : 5) -#define DAS16_STATUS 8 -#define BUSY (1<<7) -#define UNIPOLAR (1<<6) -#define DAS16_MUXBIT (1<<5) -#define DAS16_INT (1<<4) -#define DAS16_CONTROL 9 -#define DAS16_INTE (1<<7) -#define DAS16_IRQ(x) (((x) & 0x7) << 4) -#define DMA_ENABLE (1<<2) -#define PACING_MASK 0x3 -#define INT_PACER 0x03 -#define EXT_PACER 0x02 -#define DAS16_SOFT 0x00 -#define DAS16_PACER 0x0A -#define DAS16_CTR0 (1<<1) -#define DAS16_TRIG0 (1<<0) -#define BURST_LEN_BITS(x) (((x) & 0xf) << 4) -#define DAS16_GAIN 0x0B -#define DAS16_CNTR0_DATA 0x0C -#define DAS16_CNTR1_DATA 0x0D -#define DAS16_CNTR2_DATA 0x0E -#define DAS16_CNTR_CONTROL 0x0F -#define DAS16_TERM_CNT 0x00 -#define DAS16_ONE_SHOT 0x02 -#define DAS16_RATE_GEN 0x04 -#define DAS16_CNTR_LSB_MSB 0x30 -#define DAS16_CNTR0 0x00 -#define DAS16_CNTR1 0x40 -#define DAS16_CNTR2 0x80 - -#define DAS1600_CONV 0x404 -#define DAS1600_CONV_DISABLE 0x40 -#define DAS1600_BURST 0x405 -#define DAS1600_BURST_VAL 0x40 -#define DAS1600_ENABLE 0x406 -#define DAS1600_ENABLE_VAL 0x40 -#define DAS1600_STATUS_B 0x407 -#define DAS1600_BME 0x40 -#define DAS1600_ME 0x20 -#define DAS1600_CD 0x10 -#define DAS1600_WS 0x02 -#define DAS1600_CLK_10MHZ 0x01 +#define DAS16_TRIG_REG 0x00 +#define DAS16_AI_LSB_REG 0x00 +#define DAS16_AI_MSB_REG 0x01 +#define DAS16_MUX_REG 0x02 +#define DAS16_DIO_REG 0x03 +#define DAS16_AO_LSB_REG(x) ((x) ? 0x06 : 0x04) +#define DAS16_AO_MSB_REG(x) ((x) ? 0x07 : 0x05) +#define DAS16_STATUS_REG 0x08 +#define DAS16_STATUS_BUSY (1 << 7) +#define DAS16_STATUS_UNIPOLAR (1 << 6) +#define DAS16_STATUS_MUXBIT (1 << 5) +#define DAS16_STATUS_INT (1 << 4) +#define DAS16_CTRL_REG 0x09 +#define DAS16_CTRL_INTE (1 << 7) +#define DAS16_CTRL_IRQ(x) (((x) & 0x7) << 4) +#define DAS16_CTRL_DMAE (1 << 2) +#define DAS16_CTRL_PACING_MASK (3 << 0) +#define DAS16_CTRL_INT_PACER (3 << 0) +#define DAS16_CTRL_EXT_PACER (2 << 0) +#define DAS16_CTRL_SOFT_PACER (0 << 0) +#define DAS16_PACER_REG 0x0a +#define DAS16_PACER_BURST_LEN(x) (((x) & 0xf) << 4) +#define DAS16_PACER_CTR0 (1 << 1) +#define DAS16_PACER_TRIG0 (1 << 0) +#define DAS16_GAIN_REG 0x0b +#define DAS16_TIMER_BASE_REG 0x0c /* to 0x0f */ + +#define DAS1600_CONV_REG 0x404 +#define DAS1600_CONV_DISABLE (1 << 6) +#define DAS1600_BURST_REG 0x405 +#define DAS1600_BURST_VAL (1 << 6) +#define DAS1600_ENABLE_REG 0x406 +#define DAS1600_ENABLE_VAL (1 << 6) +#define DAS1600_STATUS_REG 0x407 +#define DAS1600_STATUS_BME (1 << 6) +#define DAS1600_STATUS_ME (1 << 5) +#define DAS1600_STATUS_CD (1 << 4) +#define DAS1600_STATUS_WS (1 << 1) +#define DAS1600_STATUS_CLK_10MHZ (1 << 0) static const struct comedi_lrange range_das1x01_bip = { 4, { @@ -484,14 +474,16 @@ static void das16_ai_enable(struct comedi_device *dev, { struct das16_private_struct *devpriv = dev->private; - devpriv->ctrl_reg &= ~(DAS16_INTE | DMA_ENABLE | PACING_MASK); + devpriv->ctrl_reg &= ~(DAS16_CTRL_INTE | + DAS16_CTRL_DMAE | + DAS16_CTRL_PACING_MASK); devpriv->ctrl_reg |= mode; if (src == TRIG_EXT) - devpriv->ctrl_reg |= EXT_PACER; + devpriv->ctrl_reg |= DAS16_CTRL_EXT_PACER; else - devpriv->ctrl_reg |= INT_PACER; - outb(devpriv->ctrl_reg, dev->iobase + DAS16_CONTROL); + devpriv->ctrl_reg |= DAS16_CTRL_INT_PACER; + outb(devpriv->ctrl_reg, dev->iobase + DAS16_CTRL_REG); } static void das16_ai_disable(struct comedi_device *dev) @@ -499,8 +491,10 @@ static void das16_ai_disable(struct comedi_device *dev) struct das16_private_struct *devpriv = dev->private; /* disable interrupts, dma and pacer clocked conversions */ - devpriv->ctrl_reg &= ~(DAS16_INTE | DMA_ENABLE | PACING_MASK); - outb(devpriv->ctrl_reg, dev->iobase + DAS16_CONTROL); + devpriv->ctrl_reg &= ~(DAS16_CTRL_INTE | + DAS16_CTRL_DMAE | + DAS16_CTRL_PACING_MASK); + outb(devpriv->ctrl_reg, dev->iobase + DAS16_CTRL_REG); } /* the pc104-das16jr (at least) has problems if the dma @@ -551,7 +545,7 @@ static void das16_interrupt(struct comedi_device *dev) int buffer_index; spin_lock_irqsave(&dev->spinlock, spin_flags); - if ((devpriv->ctrl_reg & DMA_ENABLE) == 0) { + if (!(devpriv->ctrl_reg & DAS16_CTRL_DMAE)) { spin_unlock_irqrestore(&dev->spinlock, spin_flags); return; } @@ -732,14 +726,15 @@ static unsigned int das16_set_pacer(struct comedi_device *dev, unsigned int ns, int rounding_flags) { struct das16_private_struct *devpriv = dev->private; + unsigned long timer_base = dev->iobase + DAS16_TIMER_BASE_REG; i8253_cascade_ns_to_timer_2div(devpriv->clockbase, &(devpriv->divisor1), &(devpriv->divisor2), &ns, rounding_flags & TRIG_ROUND_MASK); /* Write the values of ctr1 and ctr2 into counters 1 and 2 */ - i8254_load(dev->iobase + DAS16_CNTR0_DATA, 0, 1, devpriv->divisor1, 2); - i8254_load(dev->iobase + DAS16_CNTR0_DATA, 0, 2, devpriv->divisor2, 2); + i8254_load(timer_base, 0, 1, devpriv->divisor1, 2); + i8254_load(timer_base, 0, 2, devpriv->divisor2, 2); return ns; } @@ -764,12 +759,12 @@ static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s) cmd->stop_arg * cmd->chanlist_len * sizeof(uint16_t); if (devpriv->can_burst) - outb(DAS1600_CONV_DISABLE, dev->iobase + DAS1600_CONV); + outb(DAS1600_CONV_DISABLE, dev->iobase + DAS1600_CONV_REG); /* set scan limits */ byte = CR_CHAN(cmd->chanlist[0]); byte |= CR_CHAN(cmd->chanlist[cmd->chanlist_len - 1]) << 4; - outb(byte, dev->iobase + DAS16_MUX); + outb(byte, dev->iobase + DAS16_MUX_REG); /* set gain (this is also burst rate register but according to * computer boards manual, burst rate does nothing, even on @@ -777,7 +772,7 @@ static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s) if (board->ai_pg != das16_pg_none) { range = CR_RANGE(cmd->chanlist[0]); outb((das16_gainlists[board->ai_pg])[range], - dev->iobase + DAS16_GAIN); + dev->iobase + DAS16_GAIN_REG); } /* set counter mode and counts */ @@ -789,14 +784,14 @@ static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s) byte = 0; if (devpriv->can_burst) { if (cmd->convert_src == TRIG_NOW) { - outb(DAS1600_BURST_VAL, dev->iobase + DAS1600_BURST); + outb(DAS1600_BURST_VAL, dev->iobase + DAS1600_BURST_REG); /* set burst length */ - byte |= BURST_LEN_BITS(cmd->chanlist_len - 1); + byte |= DAS16_PACER_BURST_LEN(cmd->chanlist_len - 1); } else { - outb(0, dev->iobase + DAS1600_BURST); + outb(0, dev->iobase + DAS1600_BURST_REG); } } - outb(byte, dev->iobase + DAS16_PACER); + outb(byte, dev->iobase + DAS16_PACER_REG); /* set up dma transfer */ flags = claim_dma_lock(); @@ -817,10 +812,10 @@ static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->timer.expires = jiffies + timer_period(); add_timer(&devpriv->timer); - das16_ai_enable(dev, DMA_ENABLE, cmd->convert_src); + das16_ai_enable(dev, DAS16_CTRL_DMAE, cmd->convert_src); if (devpriv->can_burst) - outb(0, dev->iobase + DAS1600_CONV); + outb(0, dev->iobase + DAS1600_CONV_REG); return 0; } @@ -842,7 +837,7 @@ static int das16_cancel(struct comedi_device *dev, struct comedi_subdevice *s) } if (devpriv->can_burst) - outb(0, dev->iobase + DAS1600_BURST); + outb(0, dev->iobase + DAS1600_BURST_REG); spin_unlock_irqrestore(&dev->spinlock, flags); @@ -872,8 +867,8 @@ static int das16_ai_wait_for_conv(struct comedi_device *dev, int i; for (i = 0; i < timeout; i++) { - status = inb(dev->iobase + DAS16_STATUS); - if (!(status & BUSY)) + status = inb(dev->iobase + DAS16_STATUS_REG); + if (!(status & DAS16_STATUS_BUSY)) return 0; } return -ETIME; @@ -894,24 +889,24 @@ static int das16_ai_insn_read(struct comedi_device *dev, das16_ai_disable(dev); /* set multiplexer */ - outb(chan | (chan << 4), dev->iobase + DAS16_MUX); + outb(chan | (chan << 4), dev->iobase + DAS16_MUX_REG); /* set gain */ if (board->ai_pg != das16_pg_none) { outb((das16_gainlists[board->ai_pg])[range], - dev->iobase + DAS16_GAIN); + dev->iobase + DAS16_GAIN_REG); } for (i = 0; i < insn->n; i++) { /* trigger conversion */ - outb_p(0, dev->iobase + DAS16_TRIG); + outb_p(0, dev->iobase + DAS16_TRIG_REG); ret = das16_ai_wait_for_conv(dev, 1000); if (ret) return ret; - val = inb(dev->iobase + DAS16_AI_MSB) << 8; - val |= inb(dev->iobase + DAS16_AI_LSB); + val = inb(dev->iobase + DAS16_AI_MSB_REG) << 8; + val |= inb(dev->iobase + DAS16_AI_LSB_REG); if (s->maxdata == 0x0fff) val >>= 4; val &= s->maxdata; @@ -935,8 +930,8 @@ static int das16_ao_insn_write(struct comedi_device *dev, val = data[i]; val <<= 4; - outb(val & 0xff, dev->iobase + DAS16_AO_LSB(chan)); - outb((val >> 8) & 0xff, dev->iobase + DAS16_AO_MSB(chan)); + outb(val & 0xff, dev->iobase + DAS16_AO_LSB_REG(chan)); + outb((val >> 8) & 0xff, dev->iobase + DAS16_AO_MSB_REG(chan)); } return insn->n; @@ -947,7 +942,7 @@ static int das16_di_insn_bits(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - data[1] = inb(dev->iobase + DAS16_DIO) & 0xf; + data[1] = inb(dev->iobase + DAS16_DIO_REG) & 0xf; return insn->n; } @@ -964,7 +959,7 @@ static int das16_do_insn_bits(struct comedi_device *dev, s->state &= ~mask; s->state |= (bits & mask); - outb(s->state, dev->iobase + DAS16_DIO); + outb(s->state, dev->iobase + DAS16_DIO_REG); } data[1] = s->state; @@ -978,7 +973,7 @@ static int das16_probe(struct comedi_device *dev, struct comedi_devconfig *it) int diobits; /* diobits indicates boards */ - diobits = inb(dev->iobase + DAS16_DIO) & 0xf0; + diobits = inb(dev->iobase + DAS16_DIO_REG) & 0xf0; printk(KERN_INFO " id bits are 0x%02x\n", diobits); if (board->id != diobits) { @@ -994,9 +989,9 @@ static int das1600_mode_detect(struct comedi_device *dev) struct das16_private_struct *devpriv = dev->private; int status = 0; - status = inb(dev->iobase + DAS1600_STATUS_B); + status = inb(dev->iobase + DAS1600_STATUS_REG); - if (status & DAS1600_CLK_10MHZ) { + if (status & DAS1600_STATUS_CLK_10MHZ) { devpriv->clockbase = 100; printk(KERN_INFO " 10MHz pacer clock\n"); } else { @@ -1009,10 +1004,10 @@ static int das1600_mode_detect(struct comedi_device *dev) static void das16_reset(struct comedi_device *dev) { - outb(0, dev->iobase + DAS16_STATUS); - outb(0, dev->iobase + DAS16_CONTROL); - outb(0, dev->iobase + DAS16_PACER); - outb(0, dev->iobase + DAS16_CNTR_CONTROL); + outb(0, dev->iobase + DAS16_STATUS_REG); + outb(0, dev->iobase + DAS16_CTRL_REG); + outb(0, dev->iobase + DAS16_PACER_REG); + outb(0, dev->iobase + DAS16_TIMER_BASE_REG + i8254_control_reg); } static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) @@ -1140,13 +1135,13 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (ret) return ret; - status = inb(dev->iobase + DAS16_STATUS); + status = inb(dev->iobase + DAS16_STATUS_REG); /* Analog Input subdevice */ s = &dev->subdevices[0]; s->type = COMEDI_SUBD_AI; s->subdev_flags = SDF_READABLE; - if (status & DAS16_MUXBIT) { + if (status & DAS16_STATUS_MUXBIT) { s->subdev_flags |= SDF_GROUND; s->n_chan = 16; } else { @@ -1157,7 +1152,7 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->maxdata = board->ai_maxdata; if (devpriv->user_ai_range_table) { /* user defined ai range */ s->range_table = devpriv->user_ai_range_table; - } else if (status & UNIPOLAR) { + } else if (status & DAS16_STATUS_UNIPOLAR) { s->range_table = das16_ai_uni_lranges[board->ai_pg]; } else { s->range_table = das16_ai_bip_lranges[board->ai_pg]; @@ -1208,7 +1203,7 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->insn_bits = das16_do_insn_bits; /* initialize digital output lines */ - outb(s->state, dev->iobase + DAS16_DIO); + outb(s->state, dev->iobase + DAS16_DIO_REG); /* 8255 Digital I/O subdevice */ if (board->has_8255) { @@ -1221,13 +1216,13 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) das16_reset(dev); /* set the interrupt level */ - devpriv->ctrl_reg = DAS16_IRQ(dev->irq); - outb(devpriv->ctrl_reg, dev->iobase + DAS16_CONTROL); + devpriv->ctrl_reg = DAS16_CTRL_IRQ(dev->irq); + outb(devpriv->ctrl_reg, dev->iobase + DAS16_CTRL_REG); if (devpriv->can_burst) { - outb(DAS1600_ENABLE_VAL, dev->iobase + DAS1600_ENABLE); - outb(0, dev->iobase + DAS1600_CONV); - outb(0, dev->iobase + DAS1600_BURST); + outb(DAS1600_ENABLE_VAL, dev->iobase + DAS1600_ENABLE_REG); + outb(0, dev->iobase + DAS1600_CONV_REG); + outb(0, dev->iobase + DAS1600_BURST_REG); } return 0; -- GitLab From b08c4015e6042113625d92f9e3e32bdaa652bf76 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 14:05:00 -0700 Subject: [PATCH 379/942] staging: comedi: das16: fail attach if board id is incorrect This driver probes the board id during the attach to ensure that the user is attempting to attach to the correct board type. Currently an error message is output if the ids are not consistent but the attach continues anyway. Make the attach fail if the id bits do not match. Also, cleanup the printk messages and use a dev_err() only if the probe fails. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index 97ba2bd88485b..8f4b3dd3170fa 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -974,11 +974,11 @@ static int das16_probe(struct comedi_device *dev, struct comedi_devconfig *it) /* diobits indicates boards */ diobits = inb(dev->iobase + DAS16_DIO_REG) & 0xf0; - - printk(KERN_INFO " id bits are 0x%02x\n", diobits); if (board->id != diobits) { - printk(KERN_INFO " requested board's id bits are 0x%x (ignore)\n", - board->id); + dev_err(dev->class_dev, + "requested board's id bits are incorrect (0x%x != 0x%x)\n", + board->id, diobits); + return -EINVAL; } return 0; @@ -1054,10 +1054,8 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) } /* probe id bits to make sure they are consistent */ - if (das16_probe(dev, it)) { - printk(KERN_ERR " id bits do not match selected board, aborting\n"); + if (das16_probe(dev, it)) return -EINVAL; - } /* get master clock speed */ if (devpriv->can_burst) { -- GitLab From ccb26aa72c9a5e7bf95ec148c734ca0821331922 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 14:05:20 -0700 Subject: [PATCH 380/942] staging: comedi: das16: cleanup printk message in board attach Convert this printk message into a dev_err(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index 8f4b3dd3170fa..2169cd7286556 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -1025,9 +1025,8 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (it->options[3]) { if (it->options[3] != 0 && it->options[3] != 1 && it->options[3] != 10) { - printk - ("\n Invalid option. Master clock must be set " - "to 1 or 10 (MHz)\n"); + dev_err(dev->class_dev, + "Invalid option. Master clock must be set to 1 or 10 (MHz)\n"); return -EINVAL; } } -- GitLab From f2e92ee1af58128b554203fafbbd2ae37f694fec Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 14:05:37 -0700 Subject: [PATCH 381/942] staging: comedi: das16: absorb das1600_mode_detect() into caller This function is only called during the board attach to determine the pacer clock speed for the boards capable of bursting. Absorb it into the caller and remove the attach noise. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index 2169cd7286556..7dae83e1f96a6 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -984,24 +984,6 @@ static int das16_probe(struct comedi_device *dev, struct comedi_devconfig *it) return 0; } -static int das1600_mode_detect(struct comedi_device *dev) -{ - struct das16_private_struct *devpriv = dev->private; - int status = 0; - - status = inb(dev->iobase + DAS1600_STATUS_REG); - - if (status & DAS1600_STATUS_CLK_10MHZ) { - devpriv->clockbase = 100; - printk(KERN_INFO " 10MHz pacer clock\n"); - } else { - devpriv->clockbase = 1000; - printk(KERN_INFO " 1MHz pacer clock\n"); - } - - return 0; -} - static void das16_reset(struct comedi_device *dev) { outb(0, dev->iobase + DAS16_STATUS_REG); @@ -1058,7 +1040,12 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) /* get master clock speed */ if (devpriv->can_burst) { - das1600_mode_detect(dev); + status = inb(dev->iobase + DAS1600_STATUS_REG); + + if (status & DAS1600_STATUS_CLK_10MHZ) + devpriv->clockbase = 100; + else + devpriv->clockbase = 1000; } else { if (it->options[3]) devpriv->clockbase = 1000 / it->options[3]; -- GitLab From 0541144e80e95265325160385bd267ecf9216ed2 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 14:05:59 -0700 Subject: [PATCH 382/942] staging: comedi: das16: fix a > 80 char line issue Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index 7dae83e1f96a6..c4f0853c72476 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -784,7 +784,8 @@ static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s) byte = 0; if (devpriv->can_burst) { if (cmd->convert_src == TRIG_NOW) { - outb(DAS1600_BURST_VAL, dev->iobase + DAS1600_BURST_REG); + outb(DAS1600_BURST_VAL, + dev->iobase + DAS1600_BURST_REG); /* set burst length */ byte |= DAS16_PACER_BURST_LEN(cmd->chanlist_len - 1); } else { -- GitLab From c04fc1a5898bb2ea7ba884bf747e17f548897afb Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 14:06:16 -0700 Subject: [PATCH 383/942] staging: comedi: das16: cleanup comedi_error() messages Some of these messages are missing the terminating '\n' and most of them have the quoted string split across lines. Change all of them to dev_err() messages and fix the issues. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index c4f0853c72476..fb3e0e07551d6 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -527,8 +527,8 @@ static int disable_dma_on_even(struct comedi_device *dev) residue = get_dma_residue(devpriv->dma_chan); } if (i == disable_limit) { - comedi_error(dev, "failed to get an even dma transfer, " - "could be trouble."); + dev_err(dev->class_dev, + "failed to get an even dma transfer, could be trouble\n"); } return residue; } @@ -556,7 +556,7 @@ static void das16_interrupt(struct comedi_device *dev) /* figure out how many points to read */ if (residue > devpriv->dma_transfer_size) { - comedi_error(dev, "residue > transfer size!\n"); + dev_err(dev->class_dev, "residue > transfer size!\n"); async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA; num_bytes = 0; } else @@ -702,16 +702,13 @@ static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s, for (i = 1; i < cmd->chanlist_len; i++) { if (CR_CHAN(cmd->chanlist[i]) != (start_chan + i) % s->n_chan) { - comedi_error(dev, - "entries in chanlist must be " - "consecutive channels, " - "counting upwards\n"); + dev_err(dev->class_dev, + "entries in chanlist must be consecutive channels, counting upwards\n"); err++; } if (CR_RANGE(cmd->chanlist[i]) != gain) { - comedi_error(dev, - "entries in chanlist must all " - "have the same gain\n"); + dev_err(dev->class_dev, + "entries in chanlist must all have the same gain\n"); err++; } } @@ -750,8 +747,8 @@ static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s) int range; if (cmd->flags & TRIG_RT) { - comedi_error(dev, "isa dma transfers cannot be performed with " - "TRIG_RT, aborting"); + dev_err(dev->class_dev, + "isa dma transfers cannot be performed with TRIG_RT, aborting\n"); return -1; } -- GitLab From 10206ef6328609cbb07b8c5b09cedfaa339c4d42 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 14:06:34 -0700 Subject: [PATCH 384/942] staging: comedi: das16: tidy up private data definition Remove the comments and add some whitespace to help readability. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 40 +++++++++++--------------- 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index fb3e0e07551d6..e7b7bcd9220c9 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -443,30 +443,22 @@ static inline int timer_period(void) } struct das16_private_struct { - unsigned int clockbase; /* master clock speed in ns */ - unsigned int ctrl_reg; - unsigned long adc_byte_count; /* number of bytes remaining */ - /* divisor dividing master clock to get conversion frequency */ - unsigned int divisor1; - /* divisor dividing master clock to get conversion frequency */ - unsigned int divisor2; - unsigned int dma_chan; /* dma channel */ - uint16_t *dma_buffer[2]; - dma_addr_t dma_buffer_addr[2]; - unsigned int current_buffer; - unsigned int dma_transfer_size; /* target number of bytes to transfer per dma shot */ - /** - * user-defined analog input and output ranges - * defined from config options - */ - struct comedi_lrange *user_ai_range_table; - struct comedi_lrange *user_ao_range_table; - - struct timer_list timer; /* for timed interrupt */ - short timer_running; - - unsigned long extra_iobase; - unsigned int can_burst:1; + unsigned int clockbase; + unsigned int ctrl_reg; + unsigned long adc_byte_count; + unsigned int divisor1; + unsigned int divisor2; + unsigned int dma_chan; + uint16_t *dma_buffer[2]; + dma_addr_t dma_buffer_addr[2]; + unsigned int current_buffer; + unsigned int dma_transfer_size; + struct comedi_lrange *user_ai_range_table; + struct comedi_lrange *user_ao_range_table; + struct timer_list timer; + short timer_running; + unsigned long extra_iobase; + unsigned int can_burst:1; }; static void das16_ai_enable(struct comedi_device *dev, -- GitLab From efb623168225ee2f49b607d5aaca15caed20e8e4 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 14:06:52 -0700 Subject: [PATCH 385/942] staging: comedi: das16: change MODULE_DESCRIPTION Change the MODULE_DESCRIPTION to something useful instead of the generic "Comedi low-level driver". Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index e7b7bcd9220c9..60895e658c43a 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -1239,5 +1239,5 @@ static struct comedi_driver das16_driver = { module_comedi_driver(das16_driver); MODULE_AUTHOR("Comedi http://www.comedi.org"); -MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_DESCRIPTION("Comedi driver for DAS16 compatible boards"); MODULE_LICENSE("GPL"); -- GitLab From cb09d912e29605bc5a7bc6a204dda8c8f01cf10d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 14:07:10 -0700 Subject: [PATCH 386/942] staging: comedi: das16: fix das16_detach() The function das16_reset() needs a valid dev->iobase. Since the iobase is requested after the devpriv has been allocated in the attach, move the das16_reset() call into the if (devpriv) and add a if (dev->iobase). Also, move the release of the extra iobase into the if (devpriv) to prevent an invalid memory access. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index 60895e658c43a..9944f715b5daf 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -1206,10 +1206,12 @@ static void das16_detach(struct comedi_device *dev) { const struct das16_board *board = comedi_board(dev); struct das16_private_struct *devpriv = dev->private; + int i; - das16_reset(dev); if (devpriv) { - int i; + if (dev->iobase) + das16_reset(dev); + for (i = 0; i < 2; i++) { if (devpriv->dma_buffer[i]) pci_free_consistent(NULL, DAS16_DMA_SIZE, @@ -1221,9 +1223,12 @@ static void das16_detach(struct comedi_device *dev) free_dma(devpriv->dma_chan); kfree(devpriv->user_ai_range_table); kfree(devpriv->user_ao_range_table); + + if (devpriv->extra_iobase) + release_region(devpriv->extra_iobase, + board->size & 0x3ff); } - if (devpriv->extra_iobase) - release_region(devpriv->extra_iobase, board->size & 0x3ff); + comedi_legacy_detach(dev); } -- GitLab From 3ffb03e62a12d82f7ce1b1aaa471f780e2e42743 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 14:07:30 -0700 Subject: [PATCH 387/942] staging: comedi: das16: remove an unnecessary check in the attach If the user does not specify the analog output range the private data 'user_ao_range_table' will not be allocated. The comedi core will detect the NULL s->range_table and automatically set it to &range_unknown. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index 9944f715b5daf..00ecb3c010d76 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -1148,11 +1148,7 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->subdev_flags = SDF_WRITABLE; s->n_chan = 2; s->maxdata = 0x0fff; - if (devpriv->user_ao_range_table) - s->range_table = devpriv->user_ao_range_table; - else - s->range_table = &range_unknown; - + s->range_table = devpriv->user_ao_range_table; s->insn_write = das16_ao_insn_write; } else { s->type = COMEDI_SUBD_UNUSED; -- GitLab From 05591eaf71a9c2ad57e2d59a398ade423a9bda00 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 14:07:53 -0700 Subject: [PATCH 388/942] staging: comedi: das16: tidy up user ai/ao range initialization The allocation of the user range tables could fail. Make sure to check for it. Change the kmalloc()'s to kzalloc()'s to make sure the allocated range tables are initialized to a known state. Change the local variables so they can be used for both the ai and ao range initialization and use shorter names to keep the lines < 80 chars. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 53 ++++++++++++++------------ 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index 00ecb3c010d76..da640803d825d 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -987,8 +987,8 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) const struct das16_board *board = comedi_board(dev); struct das16_private_struct *devpriv; struct comedi_subdevice *s; - struct comedi_krange *user_ai_range; - struct comedi_krange *user_ao_range; + struct comedi_lrange *lrange; + struct comedi_krange *krange; unsigned int dma_chan = it->options[2]; unsigned int status; int ret; @@ -1077,32 +1077,37 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) devpriv->timer.data = (unsigned long)dev; } - /* get any user-defined input range */ + /* get any user-defined input range */ if (board->ai_pg == das16_pg_none && (it->options[4] || it->options[5])) { - /* allocate single-range range table */ - devpriv->user_ai_range_table = - kmalloc(sizeof(struct comedi_lrange) + - sizeof(struct comedi_krange), GFP_KERNEL); - /* initialize ai range */ - devpriv->user_ai_range_table->length = 1; - user_ai_range = devpriv->user_ai_range_table->range; - user_ai_range->min = it->options[4]; - user_ai_range->max = it->options[5]; - user_ai_range->flags = UNIT_volt; + /* allocate single-range range table */ + lrange = kzalloc(sizeof(*lrange) + sizeof(*krange), GFP_KERNEL); + if (!lrange) + return -ENOMEM; + + /* initialize ai range */ + devpriv->user_ai_range_table = lrange; + lrange->length = 1; + krange = devpriv->user_ai_range_table->range; + krange->min = it->options[4]; + krange->max = it->options[5]; + krange->flags = UNIT_volt; } - /* get any user-defined output range */ + + /* get any user-defined output range */ if (it->options[6] || it->options[7]) { - /* allocate single-range range table */ - devpriv->user_ao_range_table = - kmalloc(sizeof(struct comedi_lrange) + - sizeof(struct comedi_krange), GFP_KERNEL); - /* initialize ao range */ - devpriv->user_ao_range_table->length = 1; - user_ao_range = devpriv->user_ao_range_table->range; - user_ao_range->min = it->options[6]; - user_ao_range->max = it->options[7]; - user_ao_range->flags = UNIT_volt; + /* allocate single-range range table */ + lrange = kzalloc(sizeof(*lrange) + sizeof(*krange), GFP_KERNEL); + if (!lrange) + return -ENOMEM; + + /* initialize ao range */ + devpriv->user_ao_range_table = lrange; + lrange->length = 1; + krange = devpriv->user_ao_range_table->range; + krange->min = it->options[6]; + krange->max = it->options[7]; + krange->flags = UNIT_volt; } ret = comedi_alloc_subdevices(dev, 4 + board->has_8255); -- GitLab From 27b579be13a4edbb71eeec2d16748a28e788888a Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 14:08:13 -0700 Subject: [PATCH 389/942] staging: comedi: das16: remove some unnecessary parentheses These parentheses are not necessary. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index da640803d825d..599be27d15700 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -668,9 +668,9 @@ static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int tmp = cmd->scan_begin_arg; /* set divisors, correct timing arguments */ i8253_cascade_ns_to_timer_2div(devpriv->clockbase, - &(devpriv->divisor1), - &(devpriv->divisor2), - &(cmd->scan_begin_arg), + &devpriv->divisor1, + &devpriv->divisor2, + &cmd->scan_begin_arg, cmd->flags & TRIG_ROUND_MASK); err += (tmp != cmd->scan_begin_arg); } @@ -678,9 +678,9 @@ static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int tmp = cmd->convert_arg; /* set divisors, correct timing arguments */ i8253_cascade_ns_to_timer_2div(devpriv->clockbase, - &(devpriv->divisor1), - &(devpriv->divisor2), - &(cmd->convert_arg), + &devpriv->divisor1, + &devpriv->divisor2, + &cmd->convert_arg, cmd->flags & TRIG_ROUND_MASK); err += (tmp != cmd->convert_arg); } @@ -717,8 +717,10 @@ static unsigned int das16_set_pacer(struct comedi_device *dev, unsigned int ns, struct das16_private_struct *devpriv = dev->private; unsigned long timer_base = dev->iobase + DAS16_TIMER_BASE_REG; - i8253_cascade_ns_to_timer_2div(devpriv->clockbase, &(devpriv->divisor1), - &(devpriv->divisor2), &ns, + i8253_cascade_ns_to_timer_2div(devpriv->clockbase, + &devpriv->divisor1, + &devpriv->divisor2, + &ns, rounding_flags & TRIG_ROUND_MASK); /* Write the values of ctr1 and ctr2 into counters 1 and 2 */ @@ -1072,7 +1074,7 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) set_dma_mode(devpriv->dma_chan, DMA_MODE_READ); release_dma_lock(flags); - init_timer(&(devpriv->timer)); + init_timer(&devpriv->timer); devpriv->timer.function = das16_timer_interrupt; devpriv->timer.data = (unsigned long)dev; } -- GitLab From 71c9e43b88576683685e8e763eb223bf9e8193c4 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 14:08:31 -0700 Subject: [PATCH 390/942] staging: comedi: das16: tidy up multi-line comments Tidy up the multi-line comments to follow the CodingStyle. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 147 +++++++++++++------------ 1 file changed, 77 insertions(+), 70 deletions(-) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index 599be27d15700..93a8f09173aa1 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -1,77 +1,84 @@ /* - comedi/drivers/das16.c - DAS16 driver - - COMEDI - Linux Control and Measurement Device Interface - Copyright (C) 2000 David A. Schleef - Copyright (C) 2000 Chris R. Baugher - Copyright (C) 2001,2002 Frank Mori Hess - - 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 the License, or - (at your option) any later version. - - 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. -*/ -/* -Driver: das16 -Description: DAS16 compatible boards -Author: Sam Moore, Warren Jasper, ds, Chris Baugher, Frank Hess, Roman Fietze -Devices: [Keithley Metrabyte] DAS-16 (das-16), DAS-16G (das-16g), - DAS-16F (das-16f), DAS-1201 (das-1201), DAS-1202 (das-1202), - DAS-1401 (das-1401), DAS-1402 (das-1402), DAS-1601 (das-1601), - DAS-1602 (das-1602), - [ComputerBoards] PC104-DAS16/JR (pc104-das16jr), - PC104-DAS16JR/16 (pc104-das16jr/16), - CIO-DAS16JR/16 (cio-das16jr/16), - CIO-DAS16/JR (cio-das16/jr), CIO-DAS1401/12 (cio-das1401/12), - CIO-DAS1402/12 (cio-das1402/12), CIO-DAS1402/16 (cio-das1402/16), - CIO-DAS1601/12 (cio-das1601/12), CIO-DAS1602/12 (cio-das1602/12), - CIO-DAS1602/16 (cio-das1602/16), CIO-DAS16/330 (cio-das16/330) -Status: works -Updated: 2003-10-12 - -A rewrite of the das16 and das1600 drivers. -Options: - [0] - base io address - [1] - irq (does nothing, irq is not used anymore) - [2] - dma (optional, required for comedi_command support) - [3] - master clock speed in MHz (optional, 1 or 10, ignored if - board can probe clock, defaults to 1) - [4] - analog input range lowest voltage in microvolts (optional, - only useful if your board does not have software - programmable gain) - [5] - analog input range highest voltage in microvolts (optional, - only useful if board does not have software programmable - gain) - [6] - analog output range lowest voltage in microvolts (optional) - [7] - analog output range highest voltage in microvolts (optional) - [8] - use timer mode for DMA. Timer mode is needed e.g. for - buggy DMA controllers in NS CS5530A (Geode Companion), and for - 'jr' cards that lack a hardware fifo. This option is no - longer needed, since timer mode is _always_ used. - -Passing a zero for an option is the same as leaving it unspecified. + * das16.c + * DAS16 driver + * + * COMEDI - Linux Control and Measurement Device Interface + * Copyright (C) 2000 David A. Schleef + * Copyright (C) 2000 Chris R. Baugher + * Copyright (C) 2001,2002 Frank Mori Hess + * + * 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 the License, or + * (at your option) any later version. + * + * 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. + */ -*/ /* + * Driver: das16 + * Description: DAS16 compatible boards + * Author: Sam Moore, Warren Jasper, ds, Chris Baugher, Frank Hess, Roman Fietze + * Devices: (Keithley Metrabyte) DAS-16 [das-16] + * (Keithley Metrabyte) DAS-16G [das-16g] + * (Keithley Metrabyte) DAS-16F [das-16f] + * (Keithley Metrabyte) DAS-1201 [das-1201] + * (Keithley Metrabyte) DAS-1202 [das-1202] + * (Keithley Metrabyte) DAS-1401 [das-1401] + * (Keithley Metrabyte) DAS-1402 [das-1402] + * (Keithley Metrabyte) DAS-1601 [das-1601] + * (Keithley Metrabyte) DAS-1602 [das-1602] + * (ComputerBoards) PC104-DAS16/JR [pc104-das16jr] + * (ComputerBoards) PC104-DAS16JR/16 [pc104-das16jr/16] + * (ComputerBoards) CIO-DAS16 [cio-das16] + * (ComputerBoards) CIO-DAS16F [cio-das16/f] + * (ComputerBoards) CIO-DAS16/JR [cio-das16/jr] + * (ComputerBoards) CIO-DAS16JR/16 [cio-das16jr/16] + * (ComputerBoards) CIO-DAS1401/12 [cio-das1401/12] + * (ComputerBoards) CIO-DAS1402/12 [cio-das1402/12] + * (ComputerBoards) CIO-DAS1402/16 [cio-das1402/16] + * (ComputerBoards) CIO-DAS1601/12 [cio-das1601/12] + * (ComputerBoards) CIO-DAS1602/12 [cio-das1602/12] + * (ComputerBoards) CIO-DAS1602/16 [cio-das1602/16] + * (ComputerBoards) CIO-DAS16/330 [cio-das16/330] + * Status: works + * Updated: 2003-10-12 + * + * A rewrite of the das16 and das1600 drivers. + * + * Options: + * [0] - base io address + * [1] - irq (does nothing, irq is not used anymore) + * [2] - dma channel (optional, required for comedi_command support) + * [3] - master clock speed in MHz (optional, 1 or 10, ignored if + * board can probe clock, defaults to 1) + * [4] - analog input range lowest voltage in microvolts (optional, + * only useful if your board does not have software + * programmable gain) + * [5] - analog input range highest voltage in microvolts (optional, + * only useful if board does not have software programmable + * gain) + * [6] - analog output range lowest voltage in microvolts (optional) + * [7] - analog output range highest voltage in microvolts (optional) + * + * Passing a zero for an option is the same as leaving it unspecified. + */ -Testing and debugging help provided by Daniel Koch. - -Keithley Manuals: - 2309.PDF (das16) - 4919.PDF (das1400, 1600) - 4922.PDF (das-1400) - 4923.PDF (das1200, 1400, 1600) - -Computer boards manuals also available from their website -www.measurementcomputing.com - -*/ +/* + * Testing and debugging help provided by Daniel Koch. + * + * Keithley Manuals: + * 2309.PDF (das16) + * 4919.PDF (das1400, 1600) + * 4922.PDF (das-1400) + * 4923.PDF (das1200, 1400, 1600) + * + * Computer boards manuals also available from their website + * www.measurementcomputing.com + */ #include #include -- GitLab From 853a57f2d3f1f1126c3bd6a04a1efdee851fe546 Mon Sep 17 00:00:00 2001 From: Eli Billauer Date: Wed, 31 Jul 2013 11:22:42 +0300 Subject: [PATCH 391/942] staging: xillybus: Removed dependency on OF_DEVICE in Kconfig This variable was removed from the kernel a while ago. Signed-off-by: Eli Billauer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xillybus/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/xillybus/Kconfig b/drivers/staging/xillybus/Kconfig index 459d050065f79..8a4181f846a10 100644 --- a/drivers/staging/xillybus/Kconfig +++ b/drivers/staging/xillybus/Kconfig @@ -4,7 +4,7 @@ config XILLYBUS tristate "Xillybus generic FPGA interface" - depends on PCI || (OF_ADDRESS && OF_DEVICE && OF_IRQ) && m + depends on PCI || (OF_ADDRESS && OF_IRQ) && m help Xillybus is a generic interface for peripherals designed on programmable logic (FPGA). The driver probes the hardware for @@ -23,7 +23,7 @@ config XILLYBUS_PCIE config XILLYBUS_OF tristate "Xillybus over Device Tree" - depends on XILLYBUS && OF_ADDRESS && OF_DEVICE && OF_IRQ + depends on XILLYBUS && OF_ADDRESS && OF_IRQ help Set to M if you want Xillybus to find its resources from the Open Firmware Flattened Device Tree. If the target is an embedded -- GitLab From 7ee9ded220199f3be0b5d587ff9e2a1fdf7b6e2c Mon Sep 17 00:00:00 2001 From: Eli Billauer Date: Wed, 31 Jul 2013 11:22:43 +0300 Subject: [PATCH 392/942] staging: xillybus: Fixed sparse errors Changes: * xillybus.h: __iomem added to struct xilly_endpoint -> registers to suppress "different address spaces" errors. * xillybus_core.c: __user added as required for the same reason. * The two member names of struct xilly_endpoint_hardware of the form sync_single_for_{cpu,device} were changed to something that won't look like the well-known functions. * All *.c files: Variables and functions made static as required. Reported-by: Greg Kroah-Hartman Signed-off-by: Eli Billauer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xillybus/xillybus.h | 6 ++--- drivers/staging/xillybus/xillybus_core.c | 28 ++++++++++++------------ drivers/staging/xillybus/xillybus_of.c | 6 ++--- drivers/staging/xillybus/xillybus_pcie.c | 6 ++--- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/drivers/staging/xillybus/xillybus.h b/drivers/staging/xillybus/xillybus.h index b62faeb31c532..d3fc8aa896de7 100644 --- a/drivers/staging/xillybus/xillybus.h +++ b/drivers/staging/xillybus/xillybus.h @@ -122,7 +122,7 @@ struct xilly_endpoint { struct list_head ep_list; int dma_using_dac; /* =1 if 64-bit DMA is used, =0 otherwise. */ - u32 *registers; + __iomem u32 *registers; int fatal_error; struct mutex register_mutex; @@ -150,11 +150,11 @@ struct xilly_endpoint { struct xilly_endpoint_hardware { struct module *owner; - void (*sync_single_for_cpu)(struct xilly_endpoint *, + void (*hw_sync_sgl_for_cpu)(struct xilly_endpoint *, dma_addr_t, size_t, int); - void (*sync_single_for_device)(struct xilly_endpoint *, + void (*hw_sync_sgl_for_device)(struct xilly_endpoint *, dma_addr_t, size_t, int); diff --git a/drivers/staging/xillybus/xillybus_core.c b/drivers/staging/xillybus/xillybus_core.c index 9ccd6aa7e8c5f..3d7471a72077a 100644 --- a/drivers/staging/xillybus/xillybus_core.c +++ b/drivers/staging/xillybus/xillybus_core.c @@ -71,7 +71,7 @@ static struct class *xillybus_class; static LIST_HEAD(list_of_endpoints); static struct mutex ep_list_lock; -struct workqueue_struct *xillybus_wq; +static struct workqueue_struct *xillybus_wq; /* * Locking scheme: Mutexes protect invocations of character device methods. @@ -145,7 +145,7 @@ irqreturn_t xillybus_isr(int irq, void *data) buf_size = ep->msg_buf_size/sizeof(u32); - ep->ephw->sync_single_for_cpu(ep, + ep->ephw->hw_sync_sgl_for_cpu(ep, ep->msgbuf_dma_addr, ep->msg_buf_size, DMA_FROM_DEVICE); @@ -163,7 +163,7 @@ irqreturn_t xillybus_isr(int irq, void *data) pr_err("xillybus: Lost sync with " "interrupt messages. Stopping.\n"); else { - ep->ephw->sync_single_for_device( + ep->ephw->hw_sync_sgl_for_device( ep, ep->msgbuf_dma_addr, ep->msg_buf_size, @@ -297,7 +297,7 @@ irqreturn_t xillybus_isr(int irq, void *data) } } - ep->ephw->sync_single_for_device(ep, + ep->ephw->hw_sync_sgl_for_device(ep, ep->msgbuf_dma_addr, ep->msg_buf_size, DMA_FROM_DEVICE); @@ -796,7 +796,7 @@ static int xilly_obtain_idt(struct xilly_endpoint *endpoint) return rc; } - endpoint->ephw->sync_single_for_cpu( + endpoint->ephw->hw_sync_sgl_for_cpu( channel->endpoint, channel->wr_buffers[0]->dma_addr, channel->wr_buf_size, @@ -832,8 +832,8 @@ static int xilly_obtain_idt(struct xilly_endpoint *endpoint) return 0; /* Success */ } -static ssize_t xillybus_read(struct file *filp, char *userbuf, size_t count, - loff_t *f_pos) +static ssize_t xillybus_read(struct file *filp, char __user *userbuf, + size_t count, loff_t *f_pos) { ssize_t rc; unsigned long flags; @@ -917,7 +917,7 @@ static ssize_t xillybus_read(struct file *filp, char *userbuf, size_t count, if (!empty) { /* Go on, now without the spinlock */ if (bufpos == 0) /* Position zero means it's virgin */ - channel->endpoint->ephw->sync_single_for_cpu( + channel->endpoint->ephw->hw_sync_sgl_for_cpu( channel->endpoint, channel->wr_buffers[bufidx]->dma_addr, channel->wr_buf_size, @@ -934,7 +934,7 @@ static ssize_t xillybus_read(struct file *filp, char *userbuf, size_t count, if (bufferdone) { channel->endpoint->ephw-> - sync_single_for_device + hw_sync_sgl_for_device ( channel->endpoint, channel->wr_buffers[bufidx]-> @@ -1243,7 +1243,7 @@ static int xillybus_myflush(struct xilly_channel *channel, long timeout) else channel->rd_host_buf_idx++; - channel->endpoint->ephw->sync_single_for_device( + channel->endpoint->ephw->hw_sync_sgl_for_device( channel->endpoint, channel->rd_buffers[bufidx]->dma_addr, channel->rd_buf_size, @@ -1362,7 +1362,7 @@ static void xillybus_autoflush(struct work_struct *work) } -static ssize_t xillybus_write(struct file *filp, const char *userbuf, +static ssize_t xillybus_write(struct file *filp, const char __user *userbuf, size_t count, loff_t *f_pos) { ssize_t rc; @@ -1471,7 +1471,7 @@ static ssize_t xillybus_write(struct file *filp, const char *userbuf, if ((bufpos == 0) || /* Zero means it's virgin */ (channel->rd_leftovers[3] != 0)) { - channel->endpoint->ephw->sync_single_for_cpu( + channel->endpoint->ephw->hw_sync_sgl_for_cpu( channel->endpoint, channel->rd_buffers[bufidx]->dma_addr, channel->rd_buf_size, @@ -1494,7 +1494,7 @@ static ssize_t xillybus_write(struct file *filp, const char *userbuf, if (bufferdone) { channel->endpoint->ephw-> - sync_single_for_device( + hw_sync_sgl_for_device( channel->endpoint, channel->rd_buffers[bufidx]-> dma_addr, @@ -1867,7 +1867,7 @@ static int xillybus_release(struct inode *inode, struct file *filp) return 0; } -loff_t xillybus_llseek(struct file *filp, loff_t offset, int whence) +static loff_t xillybus_llseek(struct file *filp, loff_t offset, int whence) { struct xilly_channel *channel = filp->private_data; loff_t pos = filp->f_pos; diff --git a/drivers/staging/xillybus/xillybus_of.c b/drivers/staging/xillybus/xillybus_of.c index 122d9ba1b28b0..92c2931f43484 100644 --- a/drivers/staging/xillybus/xillybus_of.c +++ b/drivers/staging/xillybus/xillybus_of.c @@ -85,7 +85,7 @@ static dma_addr_t xilly_map_single_of(struct xilly_cleanup *mem, return addr; } -void xilly_unmap_single_of(struct xilly_dma *entry) +static void xilly_unmap_single_of(struct xilly_dma *entry) { dma_unmap_single(entry->dev, entry->dma_addr, @@ -95,8 +95,8 @@ void xilly_unmap_single_of(struct xilly_dma *entry) static struct xilly_endpoint_hardware of_hw = { .owner = THIS_MODULE, - .sync_single_for_cpu = xilly_dma_sync_single_for_cpu_of, - .sync_single_for_device = xilly_dma_sync_single_for_device_of, + .hw_sync_sgl_for_cpu = xilly_dma_sync_single_for_cpu_of, + .hw_sync_sgl_for_device = xilly_dma_sync_single_for_device_of, .map_single = xilly_map_single_of, .unmap_single = xilly_unmap_single_of }; diff --git a/drivers/staging/xillybus/xillybus_pcie.c b/drivers/staging/xillybus/xillybus_pcie.c index ad45bdb2a715a..67013652358b9 100644 --- a/drivers/staging/xillybus/xillybus_pcie.c +++ b/drivers/staging/xillybus/xillybus_pcie.c @@ -112,7 +112,7 @@ static dma_addr_t xilly_map_single_pci(struct xilly_cleanup *mem, return addr; } -void xilly_unmap_single_pci(struct xilly_dma *entry) +static void xilly_unmap_single_pci(struct xilly_dma *entry) { pci_unmap_single(entry->pdev, entry->dma_addr, @@ -122,8 +122,8 @@ void xilly_unmap_single_pci(struct xilly_dma *entry) static struct xilly_endpoint_hardware pci_hw = { .owner = THIS_MODULE, - .sync_single_for_cpu = xilly_dma_sync_single_for_cpu_pci, - .sync_single_for_device = xilly_dma_sync_single_for_device_pci, + .hw_sync_sgl_for_cpu = xilly_dma_sync_single_for_cpu_pci, + .hw_sync_sgl_for_device = xilly_dma_sync_single_for_device_pci, .map_single = xilly_map_single_pci, .unmap_single = xilly_unmap_single_pci }; -- GitLab From 2cf8ed6031522ee62a09c539f275f05c3b64d95a Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Tue, 30 Jul 2013 21:03:13 +0100 Subject: [PATCH 393/942] staging: vt6656: dead code wCTSDuration. Always set to zero, so remove. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/device.h | 1 - drivers/staging/vt6656/main_usb.c | 1 - drivers/staging/vt6656/rxtx.c | 4 ---- 3 files changed, 6 deletions(-) diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h index f07ba242811bb..5324c2414baa4 100644 --- a/drivers/staging/vt6656/device.h +++ b/drivers/staging/vt6656/device.h @@ -591,7 +591,6 @@ struct vnt_private { u8 abyBSSID[ETH_ALEN]; u8 abyDesireBSSID[ETH_ALEN]; - u16 wCTSDuration; /* update while speed change */ u16 wACKDuration; u16 wRTSTransmitLen; u8 byRTSServiceField; diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index 0c9e60fd57f7f..3bc5834a13cc0 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -267,7 +267,6 @@ device_set_options(struct vnt_private *pDevice) { pDevice->bUpdateBBVGA = true; pDevice->byFOETuning = 0; pDevice->byAutoPwrTunning = 0; - pDevice->wCTSDuration = 0; pDevice->byPreambleType = 0; pDevice->bExistSWNetAddr = false; /* pDevice->bDiversityRegCtlON = true; */ diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 00e0c71187764..be0c9ce5af066 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -1005,15 +1005,12 @@ static void s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx, ); pBuf->wTransmitLength_b = cpu_to_le16(wLen); pBuf->wDuration_ba = (u16)s_uGetRTSCTSDuration(pDevice, CTSDUR_BA, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption); //3:CTSDuration_ba, 1:2.4G, 2,3:2.4G OFDM Data - pBuf->wDuration_ba += pDevice->wCTSDuration; pBuf->wDuration_ba = cpu_to_le16(pBuf->wDuration_ba); //Get CTSDuration_ba_f0 pBuf->wCTSDuration_ba_f0 = (u16)s_uGetRTSCTSDuration(pDevice, CTSDUR_BA_F0, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption); //8:CTSDuration_ba_f0, 1:2.4G, 2,3:2.4G OFDM Data - pBuf->wCTSDuration_ba_f0 += pDevice->wCTSDuration; pBuf->wCTSDuration_ba_f0 = cpu_to_le16(pBuf->wCTSDuration_ba_f0); //Get CTSDuration_ba_f1 pBuf->wCTSDuration_ba_f1 = (u16)s_uGetRTSCTSDuration(pDevice, CTSDUR_BA_F1, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption); //9:CTSDuration_ba_f1, 1:2.4G, 2,3:2.4G OFDM Data - pBuf->wCTSDuration_ba_f1 += pDevice->wCTSDuration; pBuf->wCTSDuration_ba_f1 = cpu_to_le16(pBuf->wCTSDuration_ba_f1); //Get CTS Frame body pBuf->Data.wDurationID = pBuf->wDuration_ba; @@ -1031,7 +1028,6 @@ static void s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx, pBuf->wTransmitLength_b = cpu_to_le16(wLen); //Get CTSDuration_ba pBuf->wDuration_ba = cpu_to_le16((u16)s_uGetRTSCTSDuration(pDevice, CTSDUR_BA, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption)); //3:CTSDuration_ba, 1:2.4G, 2,3:2.4G OFDM Data - pBuf->wDuration_ba += pDevice->wCTSDuration; pBuf->wDuration_ba = cpu_to_le16(pBuf->wDuration_ba); //Get CTS Frame body -- GitLab From 0260fe9380b6b457cf03df3735e7049e33b06953 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Tue, 30 Jul 2013 21:08:54 +0100 Subject: [PATCH 394/942] staging: vt6656: device.h unused variables wACKDuration wRTSTransmitLen byRTSServiceField byRTSSignalField Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/device.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h index 5324c2414baa4..49869108e7e0f 100644 --- a/drivers/staging/vt6656/device.h +++ b/drivers/staging/vt6656/device.h @@ -591,11 +591,6 @@ struct vnt_private { u8 abyBSSID[ETH_ALEN]; u8 abyDesireBSSID[ETH_ALEN]; - u16 wACKDuration; - u16 wRTSTransmitLen; - u8 byRTSServiceField; - u8 byRTSSignalField; - u32 dwMaxReceiveLifetime; /* dot11MaxReceiveLifetime */ int bCCK; -- GitLab From d0b31b8b92fc246bdd2b85bba38a28a8343f4909 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 17:43:16 -0700 Subject: [PATCH 395/942] staging: comedi: usbdux: generalize the usb_submit_urb functions Generalize a helper function to replace usbduxsub_submit_{in,out}urbs(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 47 ++++++++----------------- 1 file changed, 15 insertions(+), 32 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 7ff731fd804a2..bf6c9ffa93eee 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -531,7 +531,9 @@ static void usbduxsub_ao_isoc_irq(struct urb *urb) } } -static int usbduxsub_submit_inurbs(struct comedi_device *dev) +static int usbdux_submit_urbs(struct comedi_device *dev, + struct urb **urbs, int num_urbs, + int input_urb) { struct usb_device *usb = comedi_to_usb_dev(dev); struct usbdux_private *devpriv = dev->private; @@ -540,35 +542,12 @@ static int usbduxsub_submit_inurbs(struct comedi_device *dev) int i; /* Submit all URBs and start the transfer on the bus */ - for (i = 0; i < devpriv->n_ai_urbs; i++) { - urb = devpriv->ai_urbs[i]; - - /* in case of a resubmission after an unlink... */ - urb->interval = devpriv->ai_interval; - urb->context = dev; - urb->dev = usb; - urb->status = 0; - urb->transfer_flags = URB_ISO_ASAP; - - ret = usb_submit_urb(urb, GFP_ATOMIC); - if (ret) - return ret; - } - return 0; -} - -static int usbduxsub_submit_outurbs(struct comedi_device *dev) -{ - struct usb_device *usb = comedi_to_usb_dev(dev); - struct usbdux_private *devpriv = dev->private; - struct urb *urb; - int ret; - int i; - - for (i = 0; i < devpriv->n_ao_urbs; i++) { - urb = devpriv->ao_urbs[i]; + for (i = 0; i < num_urbs; i++) { + urb = urbs[i]; /* in case of a resubmission after an unlink... */ + if (input_urb) + urb->interval = devpriv->ai_interval; urb->context = dev; urb->dev = usb; urb->status = 0; @@ -725,7 +704,8 @@ static int usbdux_ai_inttrig(struct comedi_device *dev, if (!devpriv->ai_cmd_running) { devpriv->ai_cmd_running = 1; - ret = usbduxsub_submit_inurbs(dev); + ret = usbdux_submit_urbs(dev, devpriv->ai_urbs, + devpriv->n_ai_urbs, 1); if (ret < 0) { devpriv->ai_cmd_running = 0; goto ai_trig_exit; @@ -807,7 +787,8 @@ static int usbdux_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) if (cmd->start_src == TRIG_NOW) { /* enable this acquisition operation */ devpriv->ai_cmd_running = 1; - ret = usbduxsub_submit_inurbs(dev); + ret = usbdux_submit_urbs(dev, devpriv->ai_urbs, + devpriv->n_ai_urbs, 1); if (ret < 0) { devpriv->ai_cmd_running = 0; /* fixme: unlink here?? */ @@ -944,7 +925,8 @@ static int usbdux_ao_inttrig(struct comedi_device *dev, if (!devpriv->ao_cmd_running) { devpriv->ao_cmd_running = 1; - ret = usbduxsub_submit_outurbs(dev); + ret = usbdux_submit_urbs(dev, devpriv->ao_urbs, + devpriv->n_ao_urbs, 0); if (ret < 0) { devpriv->ao_cmd_running = 0; goto ao_trig_exit; @@ -1105,7 +1087,8 @@ static int usbdux_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) if (cmd->start_src == TRIG_NOW) { /* enable this acquisition operation */ devpriv->ao_cmd_running = 1; - ret = usbduxsub_submit_outurbs(dev); + ret = usbdux_submit_urbs(dev, devpriv->ao_urbs, + devpriv->n_ao_urbs, 0); if (ret < 0) { devpriv->ao_cmd_running = 0; /* fixme: unlink here?? */ -- GitLab From e0bc079c669a9b6f438f8801da5fc04947323b45 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 17:43:36 -0700 Subject: [PATCH 396/942] staging: comedi: usbduxsigma: generalize the ai/ao usb_kill_urb() Generalize a helper function to replace for() loops in usbduxsigma_{ai,ao}_stop() that call usb_kill_urb() to unlink all the urbs. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbduxsigma.c | 28 +++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c b/drivers/staging/comedi/drivers/usbduxsigma.c index 1af235407eb42..b31e400faf45f 100644 --- a/drivers/staging/comedi/drivers/usbduxsigma.c +++ b/drivers/staging/comedi/drivers/usbduxsigma.c @@ -195,18 +195,20 @@ struct usbduxsigma_private { struct semaphore sem; }; +static void usbduxsigma_unlink_urbs(struct urb **urbs, int num_urbs) +{ + int i; + + for (i = 0; i < num_urbs; i++) + usb_kill_urb(urbs[i]); +} + static void usbduxsigma_ai_stop(struct comedi_device *dev, int do_unlink) { struct usbduxsigma_private *devpriv = dev->private; - if (do_unlink) { - int i; - - for (i = 0; i < devpriv->n_ai_urbs; i++) { - if (devpriv->ai_urbs[i]) - usb_kill_urb(devpriv->ai_urbs[i]); - } - } + if (do_unlink && devpriv->ai_urbs) + usbduxsigma_unlink_urbs(devpriv->ai_urbs, devpriv->n_ai_urbs); devpriv->ai_cmd_running = 0; } @@ -342,14 +344,8 @@ static void usbduxsigma_ao_stop(struct comedi_device *dev, int do_unlink) { struct usbduxsigma_private *devpriv = dev->private; - if (do_unlink) { - int i; - - for (i = 0; i < devpriv->n_ao_urbs; i++) { - if (devpriv->ao_urbs[i]) - usb_kill_urb(devpriv->ao_urbs[i]); - } - } + if (do_unlink && devpriv->ao_urbs) + usbduxsigma_unlink_urbs(devpriv->ao_urbs, devpriv->n_ao_urbs); devpriv->ao_cmd_running = 0; } -- GitLab From b509a76aff183e5b12858da6feaf4f896cf2af09 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 17:43:55 -0700 Subject: [PATCH 397/942] staging: comedi: usbduxsigma: remove the usb endpoint defines The endpoint defines are each only used in one place and don't help clarify the code. Remove the defines and just open code the values. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbduxsigma.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c b/drivers/staging/comedi/drivers/usbduxsigma.c index b31e400faf45f..ca6d9528f8cbe 100644 --- a/drivers/staging/comedi/drivers/usbduxsigma.c +++ b/drivers/staging/comedi/drivers/usbduxsigma.c @@ -66,13 +66,6 @@ /* internal addresses of the 8051 processor */ #define USBDUXSUB_CPUCS 0xE600 -/* USB endpoints */ -#define USBDUXSIGMA_CMD_OUT_EP 1 /* command output */ -#define USBDUXSIGMA_ISO_OUT_EP 2 /* analog output ISO/IRQ */ -#define USBDUXSIGMA_PWM_OUT_EP 4 /* pwm output */ -#define USBDUXSIGMA_ISO_IN_EP 6 /* analog input ISO/IRQ */ -#define USBDUXSIGMA_CMD_IN_EP 8 /* command input */ - /* 300Hz max frequ under PWM */ #define MIN_PWM_PERIOD ((long)(1E9/300)) @@ -639,7 +632,7 @@ static int usbbuxsigma_send_cmd(struct comedi_device *dev, int cmd_type) devpriv->dux_commands[0] = cmd_type; - return usb_bulk_msg(usb, usb_sndbulkpipe(usb, USBDUXSIGMA_CMD_OUT_EP), + return usb_bulk_msg(usb, usb_sndbulkpipe(usb, 1), devpriv->dux_commands, SIZEOFDUXBUFFER, &nsent, BULK_TIMEOUT); } @@ -653,8 +646,7 @@ static int usbduxsigma_receive_cmd(struct comedi_device *dev, int command) int i; for (i = 0; i < RETRIES; i++) { - ret = usb_bulk_msg(usb, - usb_rcvbulkpipe(usb, USBDUXSIGMA_CMD_IN_EP), + ret = usb_bulk_msg(usb, usb_rcvbulkpipe(usb, 8), devpriv->insn_buf, SIZEINSNBUF, &nrec, BULK_TIMEOUT); if (ret < 0) @@ -1194,8 +1186,7 @@ static int usbduxsigma_submit_pwm_urb(struct comedi_device *dev) struct urb *urb = devpriv->pwm_urb; /* in case of a resubmission after an unlink... */ - usb_fill_bulk_urb(urb, - usb, usb_sndbulkpipe(usb, USBDUXSIGMA_PWM_OUT_EP), + usb_fill_bulk_urb(urb, usb, usb_sndbulkpipe(usb, 4), urb->transfer_buffer, devpriv->pwm_buf_sz, usbduxsigma_pwm_urb_complete, dev); @@ -1573,7 +1564,7 @@ static int usbduxsigma_alloc_usb_buffers(struct comedi_device *dev) /* will be filled later with a pointer to the comedi-device */ /* and ONLY then the urb should be submitted */ urb->context = NULL; - urb->pipe = usb_rcvisocpipe(usb, USBDUXSIGMA_ISO_IN_EP); + urb->pipe = usb_rcvisocpipe(usb, 6); urb->transfer_flags = URB_ISO_ASAP; urb->transfer_buffer = kzalloc(SIZEINBUF, GFP_KERNEL); if (!urb->transfer_buffer) @@ -1595,7 +1586,7 @@ static int usbduxsigma_alloc_usb_buffers(struct comedi_device *dev) /* will be filled later with a pointer to the comedi-device */ /* and ONLY then the urb should be submitted */ urb->context = NULL; - urb->pipe = usb_sndisocpipe(usb, USBDUXSIGMA_ISO_OUT_EP); + urb->pipe = usb_sndisocpipe(usb, 2); urb->transfer_flags = URB_ISO_ASAP; urb->transfer_buffer = kzalloc(SIZEOUTBUF, GFP_KERNEL); if (!urb->transfer_buffer) -- GitLab From 9fe4df4db1350a5075b617bfda40b423f161bb6f Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 17:44:14 -0700 Subject: [PATCH 398/942] staging: comedi: usbdux: tidy up usbdux_pwm_period() Rename the local variable used for the private data pointer to 'devpriv'. Fix the fx2delay calculation so it does not use floating point values. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index bf6c9ffa93eee..0683c8e644bb7 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -1347,20 +1347,21 @@ static int usbduxsub_submit_pwm_urbs(struct comedi_device *dev) } static int usbdux_pwm_period(struct comedi_device *dev, - struct comedi_subdevice *s, unsigned int period) + struct comedi_subdevice *s, + unsigned int period) { - struct usbdux_private *this_usbduxsub = dev->private; + struct usbdux_private *devpriv = dev->private; int fx2delay = 255; if (period < MIN_PWM_PERIOD) { return -EAGAIN; } else { - fx2delay = period / ((int)(6 * 512 * (1.0 / 0.033))) - 6; + fx2delay = (period / (6 * 512 * 1000 / 33)) - 6; if (fx2delay > 255) return -EAGAIN; } - this_usbduxsub->pwm_delay = fx2delay; - this_usbduxsub->pwm_period = period; + devpriv->pwm_delay = fx2delay; + devpriv->pwm_period = period; return 0; } -- GitLab From 3b2dc08b72a80009887a0e0b80d63fdaa1f2a8a9 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 17:44:32 -0700 Subject: [PATCH 399/942] staging: comedi: usbdux: tidy up usbdux_pwm_pattern() Rename the local variable used for the private data pointer to 'devpriv'. Remove the sanity check of the private data. This function can only be called if the private data was successfully allocated in the attach. Tidy up the function to make it more concise. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 53 +++++++++---------------- 1 file changed, 19 insertions(+), 34 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 0683c8e644bb7..72094d9abba70 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -1396,45 +1396,30 @@ static int usbdux_pwm_start(struct comedi_device *dev, return ret; } -/* generates the bit pattern for PWM with the optional sign bit */ static int usbdux_pwm_pattern(struct comedi_device *dev, - struct comedi_subdevice *s, int channel, - unsigned int value, unsigned int sign) + struct comedi_subdevice *s, + unsigned int chan, + unsigned int value, + unsigned int sign) { - struct usbdux_private *this_usbduxsub = dev->private; - int i, szbuf; - char *p_buf; - char pwm_mask; - char sgn_mask; - char c; - - if (!this_usbduxsub) - return -EFAULT; + struct usbdux_private *devpriv = dev->private; + char pwm_mask = (1 << chan); /* DIO bit for the PWM data */ + char sgn_mask = (16 << chan); /* DIO bit for the sign */ + char *buf = (char *)(devpriv->pwm_urb->transfer_buffer); + int szbuf = devpriv->pwm_buf_sz; + int i; - /* this is the DIO bit which carries the PWM data */ - pwm_mask = (1 << channel); - /* this is the DIO bit which carries the optional direction bit */ - sgn_mask = (16 << channel); - /* this is the buffer which will be filled with the with bit */ - /* pattern for one period */ - szbuf = this_usbduxsub->pwm_buf_sz; - p_buf = (char *)(this_usbduxsub->pwm_urb->transfer_buffer); for (i = 0; i < szbuf; i++) { - c = *p_buf; - /* reset bits */ - c = c & (~pwm_mask); - /* set the bit as long as the index is lower than the value */ + char c = *buf; + + c &= ~pwm_mask; if (i < value) - c = c | pwm_mask; - /* set the optional sign bit for a relay */ - if (!sign) { - /* positive value */ - c = c & (~sgn_mask); - } else { - /* negative value */ - c = c | sgn_mask; - } - *(p_buf++) = c; + c |= pwm_mask; + if (!sign) + c &= ~sgn_mask; + else + c |= sgn_mask; + *buf++ = c; } return 1; } -- GitLab From 5c63f094a75820b85f7aecf6ee84439d610017c0 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 17:44:50 -0700 Subject: [PATCH 400/942] staging: comedi: usbdux: tidy up usbdux_pwm_write() Remove the sanity check of the private data. This function can only be called if the private data was successfully allocated in the attach. Tidy up the function a bit. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 26 +++++++++++-------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 72094d9abba70..214a49f23ec56 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -1426,27 +1426,23 @@ static int usbdux_pwm_pattern(struct comedi_device *dev, static int usbdux_pwm_write(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { - struct usbdux_private *this_usbduxsub = dev->private; - - if (!this_usbduxsub) - return -EFAULT; + unsigned int chan = CR_CHAN(insn->chanspec); - if ((insn->n) != 1) { - /* - * doesn't make sense to have more than one value here because - * it would just overwrite the PWM buffer a couple of times - */ + /* + * It doesn't make sense to support more than one value here + * because it would just overwrite the PWM buffer. + */ + if (insn->n != 1) return -EINVAL; - } /* - * the sign is set via a special INSN only, this gives us 8 bits for - * normal operation - * relay sign 0 by default + * The sign is set via a special INSN only, this gives us 8 bits + * for normal operation, sign is 0 by default. */ - return usbdux_pwm_pattern(dev, s, CR_CHAN(insn->chanspec), data[0], 0); + return usbdux_pwm_pattern(dev, s, chan, data[0], 0); } static int usbdux_pwm_read(struct comedi_device *x1, -- GitLab From 64ffc665d7172ce9f13b6ad5fca107e8847d68d1 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 17:45:09 -0700 Subject: [PATCH 401/942] staging: comedi: usbdux: remove usbdux_pwm_read() The pwm subdevice is not readable so this callback function is not needed. Remove it. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 214a49f23ec56..9f97e3e1f1c69 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -1445,14 +1445,6 @@ static int usbdux_pwm_write(struct comedi_device *dev, return usbdux_pwm_pattern(dev, s, chan, data[0], 0); } -static int usbdux_pwm_read(struct comedi_device *x1, - struct comedi_subdevice *x2, struct comedi_insn *x3, - unsigned int *x4) -{ - /* not needed */ - return -EINVAL; -}; - /* switches on/off PWM */ static int usbdux_pwm_config(struct comedi_device *dev, struct comedi_subdevice *s, @@ -1819,7 +1811,6 @@ static int usbdux_auto_attach(struct comedi_device *dev, s->n_chan = 8; s->maxdata = devpriv->pwm_buf_sz; s->insn_write = usbdux_pwm_write; - s->insn_read = usbdux_pwm_read; s->insn_config = usbdux_pwm_config; usbdux_pwm_period(dev, s, PWM_DEFAULT_PERIOD); -- GitLab From 893a27785c93ac76514cceb812eb41d059cd8f55 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 17:45:28 -0700 Subject: [PATCH 402/942] staging: comedi: usbdux: tidy up usbdux_pwm_config() Rename the local variable used for the private data pointer to 'devpriv'. Tidy up the function a bit. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 32 ++++++++++--------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 9f97e3e1f1c69..b1fe32934e383 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -1445,15 +1445,16 @@ static int usbdux_pwm_write(struct comedi_device *dev, return usbdux_pwm_pattern(dev, s, chan, data[0], 0); } -/* switches on/off PWM */ static int usbdux_pwm_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { - struct usbdux_private *this_usbduxsub = dev->private; + struct usbdux_private *devpriv = dev->private; + unsigned int chan = CR_CHAN(insn->chanspec); + switch (data[0]) { case INSN_CONFIG_ARM: - /* switch it on */ /* * if not zero the PWM is limited to a certain time which is * not supported here @@ -1464,27 +1465,20 @@ static int usbdux_pwm_config(struct comedi_device *dev, case INSN_CONFIG_DISARM: return usbdux_pwm_cancel(dev, s); case INSN_CONFIG_GET_PWM_STATUS: - /* - * to check if the USB transmission has failed or in case PWM - * was limited to n cycles to check if it has terminated - */ - data[1] = this_usbduxsub->pwm_cmd_running; + data[1] = devpriv->pwm_cmd_running; return 0; case INSN_CONFIG_PWM_SET_PERIOD: return usbdux_pwm_period(dev, s, data[1]); case INSN_CONFIG_PWM_GET_PERIOD: - data[1] = this_usbduxsub->pwm_period; + data[1] = devpriv->pwm_period; return 0; case INSN_CONFIG_PWM_SET_H_BRIDGE: - /* value in the first byte and the sign in the second for a - relay */ - return usbdux_pwm_pattern(dev, s, - /* the channel number */ - CR_CHAN(insn->chanspec), - /* actual PWM data */ - data[1], - /* just a sign */ - (data[2] != 0)); + /* + * data[1] = value + * data[2] = sign (for a relay) + */ + return usbdux_pwm_pattern(dev, s, chan, + data[1], (data[2] != 0)); case INSN_CONFIG_PWM_GET_H_BRIDGE: /* values are not kept in this driver, nothing to return here */ return -EINVAL; -- GitLab From 89878614e24329209bf0d4efbb09fb5e431e7eb0 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 17:45:47 -0700 Subject: [PATCH 403/942] staging: comedi: usbdux: return void from usbdux_pwm_pattern() This function never fails and currently returns '1' so that the usbdux_pwm_write() function returns to proper value (insn->n). It's also called by usbdux_pwm_config() which also returns the '1' value. The proper return code for this function should be '0' to indicate success. Change the return type of the function to void and just have the callers return the proper values. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index b1fe32934e383..9dcb2978922f8 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -1396,11 +1396,11 @@ static int usbdux_pwm_start(struct comedi_device *dev, return ret; } -static int usbdux_pwm_pattern(struct comedi_device *dev, - struct comedi_subdevice *s, - unsigned int chan, - unsigned int value, - unsigned int sign) +static void usbdux_pwm_pattern(struct comedi_device *dev, + struct comedi_subdevice *s, + unsigned int chan, + unsigned int value, + unsigned int sign) { struct usbdux_private *devpriv = dev->private; char pwm_mask = (1 << chan); /* DIO bit for the PWM data */ @@ -1421,7 +1421,6 @@ static int usbdux_pwm_pattern(struct comedi_device *dev, c |= sgn_mask; *buf++ = c; } - return 1; } static int usbdux_pwm_write(struct comedi_device *dev, @@ -1442,7 +1441,9 @@ static int usbdux_pwm_write(struct comedi_device *dev, * The sign is set via a special INSN only, this gives us 8 bits * for normal operation, sign is 0 by default. */ - return usbdux_pwm_pattern(dev, s, chan, data[0], 0); + usbdux_pwm_pattern(dev, s, chan, data[0], 0); + + return insn->n; } static int usbdux_pwm_config(struct comedi_device *dev, @@ -1477,8 +1478,8 @@ static int usbdux_pwm_config(struct comedi_device *dev, * data[1] = value * data[2] = sign (for a relay) */ - return usbdux_pwm_pattern(dev, s, chan, - data[1], (data[2] != 0)); + usbdux_pwm_pattern(dev, s, chan, data[1], (data[2] != 0)); + return 0; case INSN_CONFIG_PWM_GET_H_BRIDGE: /* values are not kept in this driver, nothing to return here */ return -EINVAL; -- GitLab From aa25b91304bbca0c79c6b1d736236cd2f817ca03 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 17:46:07 -0700 Subject: [PATCH 404/942] staging: comedi: usbduxsigma: return void from usbduxsigma_pwm_pattern() This function never fails and currently returns '1' so that the usbduxsigma_pwm_write() function returns to proper value (insn->n). It's also called by usbduxsigma_pwm_config() which also returns the '1' value. The proper return code for this function should be '0' to indicate success. Change the return type of the function to void and just have the callers return the proper values. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbduxsigma.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c b/drivers/staging/comedi/drivers/usbduxsigma.c index ca6d9528f8cbe..660eec28540f3 100644 --- a/drivers/staging/comedi/drivers/usbduxsigma.c +++ b/drivers/staging/comedi/drivers/usbduxsigma.c @@ -1238,11 +1238,11 @@ static int usbduxsigma_pwm_start(struct comedi_device *dev, return 0; } -static int usbduxsigma_pwm_pattern(struct comedi_device *dev, - struct comedi_subdevice *s, - unsigned int chan, - unsigned int value, - unsigned int sign) +static void usbduxsigma_pwm_pattern(struct comedi_device *dev, + struct comedi_subdevice *s, + unsigned int chan, + unsigned int value, + unsigned int sign) { struct usbduxsigma_private *devpriv = dev->private; char pwm_mask = (1 << chan); /* DIO bit for the PWM data */ @@ -1263,7 +1263,6 @@ static int usbduxsigma_pwm_pattern(struct comedi_device *dev, c |= sgn_mask; *buf++ = c; } - return 1; } static int usbduxsigma_pwm_write(struct comedi_device *dev, @@ -1284,7 +1283,9 @@ static int usbduxsigma_pwm_write(struct comedi_device *dev, * The sign is set via a special INSN only, this gives us 8 bits * for normal operation, sign is 0 by default. */ - return usbduxsigma_pwm_pattern(dev, s, chan, data[0], 0); + usbduxsigma_pwm_pattern(dev, s, chan, data[0], 0); + + return insn->n; } static int usbduxsigma_pwm_config(struct comedi_device *dev, @@ -1319,8 +1320,8 @@ static int usbduxsigma_pwm_config(struct comedi_device *dev, * data[1] = value * data[2] = sign (for a relay) */ - return usbduxsigma_pwm_pattern(dev, s, chan, - data[1], (data[2] != 0)); + usbduxsigma_pwm_pattern(dev, s, chan, data[1], (data[2] != 0)); + return 0; case INSN_CONFIG_PWM_GET_H_BRIDGE: /* values are not kept in this driver, nothing to return */ return -EINVAL; -- GitLab From ef1e3c4a3b383c6da3979670fcb5c6e9c7de4741 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 17:46:27 -0700 Subject: [PATCH 405/942] staging: comedi: usbdux: tidy up usbdux_alloc_usb_buffers() Tidy up the error path by doing all the basic allocations then checking for failures. We have the comedi device now so fill in the urb->context. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 32 +++++-------------------- 1 file changed, 6 insertions(+), 26 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 9dcb2978922f8..75b2de33ffd59 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -1566,25 +1566,15 @@ static int usbdux_alloc_usb_buffers(struct comedi_device *dev) struct urb *urb; int i; - /* create space for the commands going to the usb device */ devpriv->dux_commands = kzalloc(SIZEOFDUXBUFFER, GFP_KERNEL); - if (!devpriv->dux_commands) - return -ENOMEM; - - /* create space for the in buffer and set it to zero */ devpriv->in_buf = kzalloc(SIZEINBUF, GFP_KERNEL); - if (!devpriv->in_buf) - return -ENOMEM; - - /* create space of the instruction buffer */ devpriv->insn_buf = kzalloc(SIZEINSNBUF, GFP_KERNEL); - if (!devpriv->insn_buf) - return -ENOMEM; - - /* in urbs */ devpriv->ai_urbs = kcalloc(devpriv->n_ai_urbs, sizeof(*urb), GFP_KERNEL); - if (!devpriv->ai_urbs) + devpriv->ao_urbs = kcalloc(devpriv->n_ao_urbs, sizeof(*urb), + GFP_KERNEL); + if (!devpriv->dux_commands || !devpriv->in_buf || !devpriv->insn_buf || + !devpriv->ai_urbs || !devpriv->ao_urbs) return -ENOMEM; for (i = 0; i < devpriv->n_ai_urbs; i++) { @@ -1595,9 +1585,7 @@ static int usbdux_alloc_usb_buffers(struct comedi_device *dev) devpriv->ai_urbs[i] = urb; urb->dev = usb; - /* will be filled later with a pointer to the comedi-device */ - /* and ONLY then the urb should be submitted */ - urb->context = NULL; + urb->context = dev; urb->pipe = usb_rcvisocpipe(usb, 6); urb->transfer_flags = URB_ISO_ASAP; urb->transfer_buffer = kzalloc(SIZEINBUF, GFP_KERNEL); @@ -1611,12 +1599,6 @@ static int usbdux_alloc_usb_buffers(struct comedi_device *dev) urb->iso_frame_desc[0].length = SIZEINBUF; } - /* out urbs */ - devpriv->ao_urbs = kcalloc(devpriv->n_ao_urbs, sizeof(*urb), - GFP_KERNEL); - if (!devpriv->ao_urbs) - return -ENOMEM; - for (i = 0; i < devpriv->n_ao_urbs; i++) { /* one frame: 1ms */ urb = usb_alloc_urb(1, GFP_KERNEL); @@ -1625,9 +1607,7 @@ static int usbdux_alloc_usb_buffers(struct comedi_device *dev) devpriv->ao_urbs[i] = urb; urb->dev = usb; - /* will be filled later with a pointer to the comedi-device */ - /* and ONLY then the urb should be submitted */ - urb->context = NULL; + urb->context = dev; urb->pipe = usb_sndisocpipe(usb, 2); urb->transfer_flags = URB_ISO_ASAP; urb->transfer_buffer = kzalloc(SIZEOUTBUF, GFP_KERNEL); -- GitLab From 315a276da9952f481edc2396deab455173dbaea8 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 17:46:46 -0700 Subject: [PATCH 406/942] staging: comedi: usbduxsigma: 'dac_commands' does not need to be kzalloc()'d The 'dac_commands' buffer is used to pass the ao channel list from usbduxsigma_ao_cmd() to the urb callback, usbduxsigma_ao_urb_complete(). This buffer does not need to be allocated. Change it into a simple array of the correct size. Rename the variable to 'ao_chanlist' to clarify what it actually is. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbduxsigma.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c b/drivers/staging/comedi/drivers/usbduxsigma.c index 660eec28540f3..df563953fc263 100644 --- a/drivers/staging/comedi/drivers/usbduxsigma.c +++ b/drivers/staging/comedi/drivers/usbduxsigma.c @@ -161,6 +161,7 @@ struct usbduxsigma_private { /* input buffer for single insn */ int8_t *insn_buf; + int8_t ao_chanlist[USBDUXSIGMA_NUM_AO_CHAN]; unsigned int ao_readback[USBDUXSIGMA_NUM_AO_CHAN]; unsigned high_speed:1; @@ -181,8 +182,6 @@ struct usbduxsigma_private { unsigned int ao_counter; /* interval in frames/uframes */ unsigned int ai_interval; - /* D/A commands */ - uint8_t *dac_commands; /* commands */ uint8_t *dux_commands; struct semaphore sem; @@ -421,7 +420,7 @@ static void usbduxsigma_ao_urb_complete(struct urb *urb) len = s->async->cmd.chanlist_len; *datap++ = len; for (i = 0; i < len; i++) { - unsigned int chan = devpriv->dac_commands[i]; + unsigned int chan = devpriv->ao_chanlist[i]; short val; ret = comedi_buf_get(s->async, &val); @@ -1011,7 +1010,7 @@ static int usbduxsigma_ao_cmd(struct comedi_device *dev, /* set current channel of the running acquisition to zero */ s->async->cur_chan = 0; for (i = 0; i < cmd->chanlist_len; ++i) - devpriv->dac_commands[i] = CR_CHAN(cmd->chanlist[i]); + devpriv->ao_chanlist[i] = CR_CHAN(cmd->chanlist[i]); devpriv->ao_counter = devpriv->ao_timer; @@ -1542,7 +1541,6 @@ static int usbduxsigma_alloc_usb_buffers(struct comedi_device *dev) struct urb *urb; int i; - devpriv->dac_commands = kzalloc(NUMOUTCHANNELS, GFP_KERNEL); devpriv->dux_commands = kzalloc(SIZEOFDUXBUFFER, GFP_KERNEL); devpriv->in_buf = kzalloc(SIZEINBUF, GFP_KERNEL); devpriv->insn_buf = kzalloc(SIZEINSNBUF, GFP_KERNEL); @@ -1550,8 +1548,7 @@ static int usbduxsigma_alloc_usb_buffers(struct comedi_device *dev) GFP_KERNEL); devpriv->ao_urbs = kcalloc(devpriv->n_ao_urbs, sizeof(*urb), GFP_KERNEL); - if (!devpriv->dac_commands || !devpriv->dux_commands || - !devpriv->in_buf || !devpriv->insn_buf || + if (!devpriv->dux_commands || !devpriv->in_buf || !devpriv->insn_buf || !devpriv->ai_urbs || !devpriv->ao_urbs) return -ENOMEM; @@ -1660,7 +1657,6 @@ static void usbduxsigma_free_usb_buffers(struct comedi_device *dev) kfree(devpriv->insn_buf); kfree(devpriv->in_buf); kfree(devpriv->dux_commands); - kfree(devpriv->dac_commands); } static int usbduxsigma_auto_attach(struct comedi_device *dev, -- GitLab From 1c379e94b38d5e575643212e6890de6a3380e6fe Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 17:47:06 -0700 Subject: [PATCH 407/942] staging: comedi: usbduxsigma: init 'pwm_buf_sz' in usbduxsigma_auto_attach() Initialize this variable with then_ai_urbs and n_ao_urbs in the attach. Then usbduxsigma_alloc_usb_buffers() can just check the variable to determine if the urb needs to be allocated. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbduxsigma.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c b/drivers/staging/comedi/drivers/usbduxsigma.c index df563953fc263..68a3cd2bb1736 100644 --- a/drivers/staging/comedi/drivers/usbduxsigma.c +++ b/drivers/staging/comedi/drivers/usbduxsigma.c @@ -1600,19 +1600,16 @@ static int usbduxsigma_alloc_usb_buffers(struct comedi_device *dev) urb->interval = 1; /* frames */ } - if (devpriv->high_speed) { - /* max bulk ep size in high speed */ - devpriv->pwm_buf_sz = 512; + if (devpriv->pwm_buf_sz) { urb = usb_alloc_urb(0, GFP_KERNEL); if (!urb) return -ENOMEM; devpriv->pwm_urb = urb; - urb->transfer_buffer = kzalloc(devpriv->pwm_buf_sz, GFP_KERNEL); + + urb->transfer_buffer = kzalloc(devpriv->pwm_buf_sz, + GFP_KERNEL); if (!urb->transfer_buffer) return -ENOMEM; - } else { - devpriv->pwm_urb = NULL; - devpriv->pwm_buf_sz = 0; } return 0; @@ -1687,9 +1684,11 @@ static int usbduxsigma_auto_attach(struct comedi_device *dev, if (devpriv->high_speed) { devpriv->n_ai_urbs = NUMOFINBUFFERSHIGH; devpriv->n_ao_urbs = NUMOFOUTBUFFERSHIGH; + devpriv->pwm_buf_sz = 512; } else { devpriv->n_ai_urbs = NUMOFINBUFFERSFULL; devpriv->n_ao_urbs = NUMOFOUTBUFFERSFULL; + devpriv->pwm_buf_sz = 0; } ret = usbduxsigma_alloc_usb_buffers(dev); -- GitLab From 71d7e1ee2c5505ffd2055eb36ab983e9cb52d5b7 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 17:47:26 -0700 Subject: [PATCH 408/942] staging: comedi: usbduxsigma: move urb unlink into usbduxsigma_detach() For aesthetics, move the final force unlink of the urbs from usbduxsigma_free_usb_buffers() to usbduxsigma_detach(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbduxsigma.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c b/drivers/staging/comedi/drivers/usbduxsigma.c index 68a3cd2bb1736..636209458a66d 100644 --- a/drivers/staging/comedi/drivers/usbduxsigma.c +++ b/drivers/staging/comedi/drivers/usbduxsigma.c @@ -1621,11 +1621,6 @@ static void usbduxsigma_free_usb_buffers(struct comedi_device *dev) struct urb *urb; int i; - /* force unlink all urbs */ - usbduxsigma_ai_stop(dev, 1); - usbduxsigma_ao_stop(dev, 1); - usbduxsigma_pwm_stop(dev, 1); - urb = devpriv->pwm_urb; if (urb) { kfree(urb->transfer_buffer); @@ -1714,7 +1709,14 @@ static void usbduxsigma_detach(struct comedi_device *dev) usb_set_intfdata(intf, NULL); down(&devpriv->sem); + + /* force unlink all urbs */ + usbduxsigma_ai_stop(dev, 1); + usbduxsigma_ao_stop(dev, 1); + usbduxsigma_pwm_stop(dev, 1); + usbduxsigma_free_usb_buffers(dev); + up(&devpriv->sem); } -- GitLab From 1da439008e972ad3dfceca8a9ff4950db20f3528 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 17:47:44 -0700 Subject: [PATCH 409/942] staging: comedi: usbduxsigma: always clear the usb intfdata in (*detach) Make sure the usb intfdata is always cleared when the device is detached. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbduxsigma.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c b/drivers/staging/comedi/drivers/usbduxsigma.c index 636209458a66d..60815a3ec540f 100644 --- a/drivers/staging/comedi/drivers/usbduxsigma.c +++ b/drivers/staging/comedi/drivers/usbduxsigma.c @@ -1703,11 +1703,11 @@ static void usbduxsigma_detach(struct comedi_device *dev) struct usb_interface *intf = comedi_to_usb_interface(dev); struct usbduxsigma_private *devpriv = dev->private; + usb_set_intfdata(intf, NULL); + if (!devpriv) return; - usb_set_intfdata(intf, NULL); - down(&devpriv->sem); /* force unlink all urbs */ -- GitLab From 4d9861b554bc08e72045098dbc03d8221d904490 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 17:48:04 -0700 Subject: [PATCH 410/942] staging: comedi: usbdux: tidy up usbdux_detach() Make sure the usb intfdata is always cleared when the device is detached. Refactor the code to remove an indent level. Always unlink the urbs when the device is detached. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 75b2de33ffd59..991c425bb8370 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -1799,20 +1799,21 @@ static void usbdux_detach(struct comedi_device *dev) struct usb_interface *intf = comedi_to_usb_interface(dev); struct usbdux_private *devpriv = dev->private; - if (devpriv) { - down(&devpriv->sem); + usb_set_intfdata(intf, NULL); - usb_set_intfdata(intf, NULL); + if (!devpriv) + return; + + down(&devpriv->sem); - /* stop and unlink any submitted urbs */ - usbdux_pwm_stop(dev, devpriv->pwm_cmd_running); - usbdux_ao_stop(dev, devpriv->ao_cmd_running); - usbdux_ai_stop(dev, devpriv->ai_cmd_running); + /* force unlink all urbs */ + usbdux_pwm_stop(dev, 1); + usbdux_ao_stop(dev, 1); + usbdux_ai_stop(dev, 1); - usbdux_free_usb_buffers(devpriv); + usbdux_free_usb_buffers(devpriv); - up(&devpriv->sem); - } + up(&devpriv->sem); } static struct comedi_driver usbdux_driver = { -- GitLab From 71500b272064410a3417ab764aec20572564d68d Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 17:48:25 -0700 Subject: [PATCH 411/942] staging: comedi: usbdux: tidy up usbdux_free_usb_buffers() For aesthetics, pass the comedi_device pointer to this function instead of the private data pointer. The usb_kill_urb() calls are not needed. All the urbs were unlinked before this function was called. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 991c425bb8370..689b45276e8dd 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -1642,15 +1642,15 @@ static int usbdux_alloc_usb_buffers(struct comedi_device *dev) return 0; } -static void usbdux_free_usb_buffers(struct usbdux_private *devpriv) +static void usbdux_free_usb_buffers(struct comedi_device *dev) { + struct usbdux_private *devpriv = dev->private; struct urb *urb; int i; urb = devpriv->pwm_urb; if (urb) { kfree(urb->transfer_buffer); - usb_kill_urb(urb); usb_free_urb(urb); } if (devpriv->ao_urbs) { @@ -1658,7 +1658,6 @@ static void usbdux_free_usb_buffers(struct usbdux_private *devpriv) urb = devpriv->ao_urbs[i]; if (urb) { kfree(urb->transfer_buffer); - usb_kill_urb(urb); usb_free_urb(urb); } } @@ -1669,7 +1668,6 @@ static void usbdux_free_usb_buffers(struct usbdux_private *devpriv) urb = devpriv->ai_urbs[i]; if (urb) { kfree(urb->transfer_buffer); - usb_kill_urb(urb); usb_free_urb(urb); } } @@ -1811,7 +1809,7 @@ static void usbdux_detach(struct comedi_device *dev) usbdux_ao_stop(dev, 1); usbdux_ai_stop(dev, 1); - usbdux_free_usb_buffers(devpriv); + usbdux_free_usb_buffers(dev); up(&devpriv->sem); } -- GitLab From 259ed07b6c391b10fd8ed8d3afe38c5b04bb7904 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 29 Jul 2013 17:48:50 -0700 Subject: [PATCH 412/942] staging: comedi: usbduxsigma: absorb usbduxsigma_attach_common() into caller This function is only called by usbduxsigma_auto_attach(). Absorb it and refactor the code a bit to match the usbdux driver. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbduxsigma.c | 171 +++++++++---------- 1 file changed, 76 insertions(+), 95 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c b/drivers/staging/comedi/drivers/usbduxsigma.c index 60815a3ec540f..fca89c367a68b 100644 --- a/drivers/staging/comedi/drivers/usbduxsigma.c +++ b/drivers/staging/comedi/drivers/usbduxsigma.c @@ -1379,90 +1379,6 @@ static int usbduxsigma_getstatusinfo(struct comedi_device *dev, int chan) return (int)val; } -static int usbduxsigma_attach_common(struct comedi_device *dev) -{ - struct usbduxsigma_private *devpriv = dev->private; - struct comedi_subdevice *s; - int n_subdevs; - int offset; - int ret; - - down(&devpriv->sem); - - if (devpriv->high_speed) - n_subdevs = 4; /* with pwm */ - else - n_subdevs = 3; /* without pwm */ - ret = comedi_alloc_subdevices(dev, n_subdevs); - if (ret) { - up(&devpriv->sem); - return ret; - } - - /* Analog Input subdevice */ - s = &dev->subdevices[0]; - dev->read_subdev = s; - s->type = COMEDI_SUBD_AI; - s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_CMD_READ | SDF_LSAMPL; - s->n_chan = NUMCHANNELS; - s->len_chanlist = NUMCHANNELS; - s->maxdata = 0x00ffffff; - s->range_table = &usbduxsigma_ai_range; - s->insn_read = usbduxsigma_ai_insn_read; - s->do_cmdtest = usbduxsigma_ai_cmdtest; - s->do_cmd = usbduxsigma_ai_cmd; - s->cancel = usbduxsigma_ai_cancel; - - /* Analog Output subdevice */ - s = &dev->subdevices[1]; - dev->write_subdev = s; - s->type = COMEDI_SUBD_AO; - s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_CMD_WRITE; - s->n_chan = USBDUXSIGMA_NUM_AO_CHAN; - s->len_chanlist = s->n_chan; - s->maxdata = 0x00ff; - s->range_table = &range_unipolar2_5; - s->insn_write = usbduxsigma_ao_insn_write; - s->insn_read = usbduxsigma_ao_insn_read; - s->do_cmdtest = usbduxsigma_ao_cmdtest; - s->do_cmd = usbduxsigma_ao_cmd; - s->cancel = usbduxsigma_ao_cancel; - - /* Digital I/O subdevice */ - s = &dev->subdevices[2]; - s->type = COMEDI_SUBD_DIO; - s->subdev_flags = SDF_READABLE | SDF_WRITABLE; - s->n_chan = 24; - s->maxdata = 1; - s->range_table = &range_digital; - s->insn_bits = usbduxsigma_dio_insn_bits; - s->insn_config = usbduxsigma_dio_insn_config; - - if (devpriv->high_speed) { - /* Timer / pwm subdevice */ - s = &dev->subdevices[3]; - s->type = COMEDI_SUBD_PWM; - s->subdev_flags = SDF_WRITABLE | SDF_PWM_HBRIDGE; - s->n_chan = 8; - s->maxdata = devpriv->pwm_buf_sz; - s->insn_write = usbduxsigma_pwm_write; - s->insn_config = usbduxsigma_pwm_config; - - usbduxsigma_pwm_period(dev, s, PWM_DEFAULT_PERIOD); - } - - up(&devpriv->sem); - - offset = usbduxsigma_getstatusinfo(dev, 0); - if (offset < 0) - dev_err(dev->class_dev, - "Communication to USBDUXSIGMA failed! Check firmware and cabling\n"); - - dev_info(dev->class_dev, "attached, ADC_zero = %x\n", offset); - - return 0; -} - static int usbduxsigma_firmware_upload(struct comedi_device *dev, const u8 *data, size_t size, unsigned long context) @@ -1657,6 +1573,8 @@ static int usbduxsigma_auto_attach(struct comedi_device *dev, struct usb_interface *intf = comedi_to_usb_interface(dev); struct usb_device *usb = comedi_to_usb_dev(dev); struct usbduxsigma_private *devpriv; + struct comedi_subdevice *s; + int offset; int ret; devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); @@ -1664,17 +1582,9 @@ static int usbduxsigma_auto_attach(struct comedi_device *dev, return -ENOMEM; sema_init(&devpriv->sem, 1); - usb_set_intfdata(intf, devpriv); - ret = usb_set_interface(usb, - intf->altsetting->desc.bInterfaceNumber, 3); - if (ret < 0) { - dev_err(dev->class_dev, - "could not set alternate setting 3 in high speed\n"); - return -ENODEV; - } + usb_set_intfdata(intf, devpriv); - /* test if it is high speed (USB 2.0) */ devpriv->high_speed = (usb->speed == USB_SPEED_HIGH); if (devpriv->high_speed) { devpriv->n_ai_urbs = NUMOFINBUFFERSHIGH; @@ -1683,19 +1593,90 @@ static int usbduxsigma_auto_attach(struct comedi_device *dev, } else { devpriv->n_ai_urbs = NUMOFINBUFFERSFULL; devpriv->n_ao_urbs = NUMOFOUTBUFFERSFULL; - devpriv->pwm_buf_sz = 0; } ret = usbduxsigma_alloc_usb_buffers(dev); if (ret) return ret; + /* setting to alternate setting 3: enabling iso ep and bulk ep. */ + ret = usb_set_interface(usb, intf->altsetting->desc.bInterfaceNumber, + 3); + if (ret < 0) { + dev_err(dev->class_dev, + "could not set alternate setting 3 in high speed\n"); + return ret; + } + ret = comedi_load_firmware(dev, &usb->dev, FIRMWARE, usbduxsigma_firmware_upload, 0); if (ret) return ret; - return usbduxsigma_attach_common(dev); + ret = comedi_alloc_subdevices(dev, (devpriv->high_speed) ? 4 : 3); + if (ret) + return ret; + + /* Analog Input subdevice */ + s = &dev->subdevices[0]; + dev->read_subdev = s; + s->type = COMEDI_SUBD_AI; + s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_CMD_READ | SDF_LSAMPL; + s->n_chan = NUMCHANNELS; + s->len_chanlist = NUMCHANNELS; + s->maxdata = 0x00ffffff; + s->range_table = &usbduxsigma_ai_range; + s->insn_read = usbduxsigma_ai_insn_read; + s->do_cmdtest = usbduxsigma_ai_cmdtest; + s->do_cmd = usbduxsigma_ai_cmd; + s->cancel = usbduxsigma_ai_cancel; + + /* Analog Output subdevice */ + s = &dev->subdevices[1]; + dev->write_subdev = s; + s->type = COMEDI_SUBD_AO; + s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_CMD_WRITE; + s->n_chan = USBDUXSIGMA_NUM_AO_CHAN; + s->len_chanlist = s->n_chan; + s->maxdata = 0x00ff; + s->range_table = &range_unipolar2_5; + s->insn_write = usbduxsigma_ao_insn_write; + s->insn_read = usbduxsigma_ao_insn_read; + s->do_cmdtest = usbduxsigma_ao_cmdtest; + s->do_cmd = usbduxsigma_ao_cmd; + s->cancel = usbduxsigma_ao_cancel; + + /* Digital I/O subdevice */ + s = &dev->subdevices[2]; + s->type = COMEDI_SUBD_DIO; + s->subdev_flags = SDF_READABLE | SDF_WRITABLE; + s->n_chan = 24; + s->maxdata = 1; + s->range_table = &range_digital; + s->insn_bits = usbduxsigma_dio_insn_bits; + s->insn_config = usbduxsigma_dio_insn_config; + + if (devpriv->high_speed) { + /* Timer / pwm subdevice */ + s = &dev->subdevices[3]; + s->type = COMEDI_SUBD_PWM; + s->subdev_flags = SDF_WRITABLE | SDF_PWM_HBRIDGE; + s->n_chan = 8; + s->maxdata = devpriv->pwm_buf_sz; + s->insn_write = usbduxsigma_pwm_write; + s->insn_config = usbduxsigma_pwm_config; + + usbduxsigma_pwm_period(dev, s, PWM_DEFAULT_PERIOD); + } + + offset = usbduxsigma_getstatusinfo(dev, 0); + if (offset < 0) + dev_err(dev->class_dev, + "Communication to USBDUXSIGMA failed! Check firmware and cabling\n"); + + dev_info(dev->class_dev, "attached, ADC_zero = %x\n", offset); + + return 0; } static void usbduxsigma_detach(struct comedi_device *dev) -- GitLab From 62bf50cdfe596c373e877e5809193e4df600ac0b Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 30 Jul 2013 09:39:49 -0700 Subject: [PATCH 413/942] staging: comedi: allow ISA and PC/104 drivers on non-ISA systems Embedded systems with a PC/104 bus might have a configuration that does not have ISA enabled. This creates a problem in Comedi where the PC/104 drivers cannot be enabled. Remove the 'depends on ISA' for the "Comedi ISA and PC/104 drivers" menu to allow the user to select these drivers on non-ISA systems. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/Kconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index 57362fee75930..a84aab47a1131 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -100,7 +100,6 @@ endif # COMEDI_MISC_DRIVERS menuconfig COMEDI_ISA_DRIVERS bool "Comedi ISA and PC/104 drivers" - depends on ISA ---help--- Enable comedi ISA and PC/104 drivers to be built -- GitLab From 70bcbc06b7c0c7ecb900a81250862440e80205f7 Mon Sep 17 00:00:00 2001 From: Shaun Laing Date: Tue, 30 Jul 2013 11:29:43 -0600 Subject: [PATCH 414/942] staging: comedi: dt9812: Resolve different base types warnings. Resolves warnings from the "sparse" checker of the form "warning: incorrect type in assignment (different base types)". Signed-off-by: Shaun Laing Reviewed-by: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt9812.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt9812.c b/drivers/staging/comedi/drivers/dt9812.c index 7d78c78a4a270..b5e6f33dc217c 100644 --- a/drivers/staging/comedi/drivers/dt9812.c +++ b/drivers/staging/comedi/drivers/dt9812.c @@ -187,8 +187,8 @@ enum { }; struct dt9812_flash_data { - u16 numbytes; - u16 address; + __le16 numbytes; + __le16 address; }; #define DT9812_MAX_NUM_MULTI_BYTE_RDS \ @@ -229,7 +229,7 @@ struct dt9812_rmw_multi { }; struct dt9812_usb_cmd { - u32 cmd; + __le32 cmd; union { struct dt9812_flash_data flash_data_info; struct dt9812_read_multi read_multi_info; -- GitLab From 8fd070077410b26847ef6f5856850df417e7b83e Mon Sep 17 00:00:00 2001 From: Rupesh Gujare Date: Tue, 30 Jul 2013 13:31:50 +0100 Subject: [PATCH 415/942] staging: ozwpan: High resolution timers Current implementation assumes HZ = 1000 for calculating all internal timer intervals, which creates problem on platforms where HZ != 1000. As well we need resolution of less than 10 mSec for heartbeat calculation, this creates problem on some platforms where HZ is configured as HZ = 100, or around, which restricts us to timer interval of 10 mSec. This is particularly found on embedded devices. This patch moves on to use high resolution timers to calculate all timer intervals as it allows us to have very small resolution of timer interval, removing dependency on HZ. Signed-off-by: Rupesh Gujare Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozhcd.c | 91 +++---- drivers/staging/ozwpan/ozpd.c | 31 ++- drivers/staging/ozwpan/ozpd.h | 18 +- drivers/staging/ozwpan/ozproto.c | 329 +++++++------------------ drivers/staging/ozwpan/ozproto.h | 24 +- drivers/staging/ozwpan/ozurbparanoia.c | 5 +- drivers/staging/ozwpan/ozusbsvc.c | 14 +- 7 files changed, 188 insertions(+), 324 deletions(-) diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c index 6b16bfc4cdd87..f81a0c53b39be 100644 --- a/drivers/staging/ozwpan/ozhcd.c +++ b/drivers/staging/ozwpan/ozhcd.c @@ -26,7 +26,6 @@ */ #include #include -#include #include #include #include "linux/usb/hcd.h" @@ -49,6 +48,9 @@ /* Get endpoint object from the containing link. */ #define ep_from_link(__e) container_of((__e), struct oz_endpoint, link) +/*EP0 timeout before ep0 request is again added to TX queue. (13*8 = 98mSec) + */ +#define EP0_TIMEOUT_COUNTER 13 /*------------------------------------------------------------------------------ * Used to link urbs together and also store some status information for each * urb. @@ -60,7 +62,7 @@ struct oz_urb_link { struct oz_port *port; u8 req_id; u8 ep_num; - unsigned long submit_jiffies; + unsigned submit_counter; }; /* Holds state information about a USB endpoint. @@ -69,7 +71,7 @@ struct oz_endpoint { struct list_head urb_list; /* List of oz_urb_link items. */ struct list_head link; /* For isoc ep, links in to isoc lists of oz_port. */ - unsigned long last_jiffies; + struct timespec timestamp; int credit; int credit_ceiling; u8 ep_num; @@ -187,6 +189,7 @@ static DEFINE_SPINLOCK(g_tasklet_lock); static struct tasklet_struct g_urb_process_tasklet; static struct tasklet_struct g_urb_cancel_tasklet; static atomic_t g_pending_urbs = ATOMIC_INIT(0); +static atomic_t g_usb_frame_number = ATOMIC_INIT(0); static const struct hc_driver g_oz_hc_drv = { .description = g_hcd_name, .product_desc = "Ozmo Devices WPAN", @@ -344,7 +347,7 @@ static struct oz_urb_link *oz_uncancel_urb(struct oz_hcd *ozhcd, struct urb *urb * Context: softirq or process */ static void oz_complete_urb(struct usb_hcd *hcd, struct urb *urb, - int status, unsigned long submit_jiffies) + int status) { struct oz_hcd *ozhcd = oz_hcd_private(hcd); unsigned long irq_state; @@ -372,12 +375,7 @@ static void oz_complete_urb(struct usb_hcd *hcd, struct urb *urb, if (oz_forget_urb(urb)) { oz_dbg(ON, "ERROR Unknown URB %p\n", urb); } else { - static unsigned long last_time; atomic_dec(&g_pending_urbs); - oz_dbg(URB, "%lu: giveback_urb(%p,%x) %lu %lu pending:%d\n", - jiffies, urb, status, jiffies-submit_jiffies, - jiffies-last_time, atomic_read(&g_pending_urbs)); - last_time = jiffies; usb_hcd_giveback_urb(hcd, urb, status); } spin_lock(&g_tasklet_lock); @@ -445,7 +443,7 @@ static void oz_complete_buffered_urb(struct oz_port *port, ep->buffered_units--; oz_dbg(ON, "Trying to give back buffered frame of size=%d\n", available_space); - oz_complete_urb(port->ozhcd->hcd, urb, 0, 0); + oz_complete_urb(port->ozhcd->hcd, urb, 0); } /*------------------------------------------------------------------------------ @@ -464,7 +462,7 @@ static int oz_enqueue_ep_urb(struct oz_port *port, u8 ep_addr, int in_dir, urbl = oz_alloc_urb_link(); if (!urbl) return -ENOMEM; - urbl->submit_jiffies = jiffies; + urbl->submit_counter = 0; urbl->urb = urb; urbl->req_id = req_id; urbl->ep_num = ep_addr; @@ -478,7 +476,7 @@ static int oz_enqueue_ep_urb(struct oz_port *port, u8 ep_addr, int in_dir, if (urb->unlinked) { spin_unlock_bh(&port->ozhcd->hcd_lock); oz_dbg(ON, "urb %p unlinked so complete immediately\n", urb); - oz_complete_urb(port->ozhcd->hcd, urb, 0, 0); + oz_complete_urb(port->ozhcd->hcd, urb, 0); oz_free_urb_link(urbl); return 0; } @@ -501,7 +499,7 @@ static int oz_enqueue_ep_urb(struct oz_port *port, u8 ep_addr, int in_dir, if (ep && port->hpd) { list_add_tail(&urbl->link, &ep->urb_list); if (!in_dir && ep_addr && (ep->credit < 0)) { - ep->last_jiffies = jiffies; + getrawmonotonic(&ep->timestamp); ep->credit = 0; } } else { @@ -790,7 +788,7 @@ void oz_hcd_get_desc_cnf(void *hport, u8 req_id, int status, const u8 *desc, } } urb->actual_length = total_size; - oz_complete_urb(port->ozhcd->hcd, urb, 0, 0); + oz_complete_urb(port->ozhcd->hcd, urb, 0); } /*------------------------------------------------------------------------------ * Context: softirq @@ -852,7 +850,7 @@ static void oz_hcd_complete_set_config(struct oz_port *port, struct urb *urb, } else { rc = -ENOMEM; } - oz_complete_urb(hcd, urb, rc, 0); + oz_complete_urb(hcd, urb, rc); } /*------------------------------------------------------------------------------ * Context: softirq @@ -877,7 +875,7 @@ static void oz_hcd_complete_set_interface(struct oz_port *port, struct urb *urb, } else { rc = -ENOMEM; } - oz_complete_urb(hcd, urb, rc, 0); + oz_complete_urb(hcd, urb, rc); } /*------------------------------------------------------------------------------ * Context: softirq @@ -914,7 +912,7 @@ void oz_hcd_control_cnf(void *hport, u8 req_id, u8 rcode, const u8 *data, (u8)windex, (u8)wvalue); break; default: - oz_complete_urb(hcd, urb, 0, 0); + oz_complete_urb(hcd, urb, 0); } } else { @@ -928,7 +926,7 @@ void oz_hcd_control_cnf(void *hport, u8 req_id, u8 rcode, const u8 *data, memcpy(urb->transfer_buffer, data, copy_len); urb->actual_length = copy_len; } - oz_complete_urb(hcd, urb, 0, 0); + oz_complete_urb(hcd, urb, 0); } } /*------------------------------------------------------------------------------ @@ -998,7 +996,7 @@ void oz_hcd_data_ind(void *hport, u8 endpoint, const u8 *data, int data_len) copy_len = urb->transfer_buffer_length; memcpy(urb->transfer_buffer, data, copy_len); urb->actual_length = copy_len; - oz_complete_urb(port->ozhcd->hcd, urb, 0, 0); + oz_complete_urb(port->ozhcd->hcd, urb, 0); return; } else { oz_dbg(ON, "buffering frame as URB is not available\n"); @@ -1017,7 +1015,7 @@ void oz_hcd_data_ind(void *hport, u8 endpoint, const u8 *data, int data_len) */ static inline int oz_usb_get_frame_number(void) { - return jiffies_to_msecs(get_jiffies_64()); + return atomic_inc_return(&g_usb_frame_number); } /*------------------------------------------------------------------------------ * Context: softirq @@ -1033,7 +1031,8 @@ int oz_hcd_heartbeat(void *hport) struct list_head *n; struct urb *urb; struct oz_endpoint *ep; - unsigned long now = jiffies; + struct timespec ts, delta; + getrawmonotonic(&ts); INIT_LIST_HEAD(&xfr_list); /* Check the OUT isoc endpoints to see if any URB data can be sent. */ @@ -1042,10 +1041,11 @@ int oz_hcd_heartbeat(void *hport) ep = ep_from_link(e); if (ep->credit < 0) continue; - ep->credit += jiffies_to_msecs(now - ep->last_jiffies); + delta = timespec_sub(ts, ep->timestamp); + ep->credit += timespec_to_ns(&delta) / NSEC_PER_MSEC; if (ep->credit > ep->credit_ceiling) ep->credit = ep->credit_ceiling; - ep->last_jiffies = now; + ep->timestamp = ts; while (ep->credit && !list_empty(&ep->urb_list)) { urbl = list_first_entry(&ep->urb_list, struct oz_urb_link, link); @@ -1053,6 +1053,8 @@ int oz_hcd_heartbeat(void *hport) if ((ep->credit + 1) < urb->number_of_packets) break; ep->credit -= urb->number_of_packets; + if (ep->credit < 0) + ep->credit = 0; list_move_tail(&urbl->link, &xfr_list); } } @@ -1060,16 +1062,14 @@ int oz_hcd_heartbeat(void *hport) /* Send to PD and complete URBs. */ list_for_each_safe(e, n, &xfr_list) { - unsigned long t; urbl = container_of(e, struct oz_urb_link, link); urb = urbl->urb; - t = urbl->submit_jiffies; list_del_init(e); urb->error_count = 0; urb->start_frame = oz_usb_get_frame_number(); oz_usb_send_isoc(port->hpd, urbl->ep_num, urb); oz_free_urb_link(urbl); - oz_complete_urb(port->ozhcd->hcd, urb, 0, t); + oz_complete_urb(port->ozhcd->hcd, urb, 0); } /* Check the IN isoc endpoints to see if any URBs can be completed. */ @@ -1080,13 +1080,14 @@ int oz_hcd_heartbeat(void *hport) if (ep->buffered_units >= OZ_IN_BUFFERING_UNITS) { ep->flags &= ~OZ_F_EP_BUFFERING; ep->credit = 0; - ep->last_jiffies = now; + ep->timestamp = ts; ep->start_frame = 0; } continue; } - ep->credit += jiffies_to_msecs(now - ep->last_jiffies); - ep->last_jiffies = now; + delta = timespec_sub(ts, ep->timestamp); + ep->credit += timespec_to_ns(&delta) / NSEC_PER_MSEC; + ep->timestamp = ts; while (!list_empty(&ep->urb_list)) { struct oz_urb_link *urbl = list_first_entry(&ep->urb_list, @@ -1095,7 +1096,7 @@ int oz_hcd_heartbeat(void *hport) int len = 0; int copy_len; int i; - if ((ep->credit + 1) < urb->number_of_packets) + if (ep->credit < urb->number_of_packets) break; if (ep->buffered_units < urb->number_of_packets) break; @@ -1141,7 +1142,7 @@ int oz_hcd_heartbeat(void *hport) urb = urbl->urb; list_del_init(e); oz_free_urb_link(urbl); - oz_complete_urb(port->ozhcd->hcd, urb, 0, 0); + oz_complete_urb(port->ozhcd->hcd, urb, 0); } /* Check if there are any ep0 requests that have timed out. * If so resent to PD. @@ -1153,11 +1154,12 @@ int oz_hcd_heartbeat(void *hport) spin_lock_bh(&ozhcd->hcd_lock); list_for_each_safe(e, n, &ep->urb_list) { urbl = container_of(e, struct oz_urb_link, link); - if (time_after(now, urbl->submit_jiffies+HZ/2)) { - oz_dbg(ON, "%ld: Request 0x%p timeout\n", - now, urbl->urb); - urbl->submit_jiffies = now; + if (urbl->submit_counter > EP0_TIMEOUT_COUNTER) { + oz_dbg(ON, "Request 0x%p timeout\n", urbl->urb); list_move_tail(e, &xfr_list); + urbl->submit_counter = 0; + } else { + urbl->submit_counter++; } } if (!list_empty(&ep->urb_list)) @@ -1382,7 +1384,7 @@ static void oz_process_ep0_urb(struct oz_hcd *ozhcd, struct urb *urb, int port_ix = -1; struct oz_port *port = NULL; - oz_dbg(URB, "%lu: %s: (%p)\n", jiffies, __func__, urb); + oz_dbg(URB, "[%s]:(%p)\n", __func__, urb); port_ix = oz_get_port_from_addr(ozhcd, urb->dev->devnum); if (port_ix < 0) { rc = -EPIPE; @@ -1505,7 +1507,7 @@ static void oz_process_ep0_urb(struct oz_hcd *ozhcd, struct urb *urb, out: if (rc || complete) { oz_dbg(ON, "Completing request locally\n"); - oz_complete_urb(ozhcd->hcd, urb, rc, 0); + oz_complete_urb(ozhcd->hcd, urb, rc); } else { oz_usb_request_heartbeat(port->hpd); } @@ -1569,7 +1571,7 @@ static void oz_urb_process_tasklet(unsigned long unused) oz_free_urb_link(urbl); rc = oz_urb_process(ozhcd, urb); if (rc) - oz_complete_urb(ozhcd->hcd, urb, rc, 0); + oz_complete_urb(ozhcd->hcd, urb, rc); spin_lock_irqsave(&g_tasklet_lock, irq_state); } spin_unlock_irqrestore(&g_tasklet_lock, irq_state); @@ -1638,7 +1640,7 @@ static void oz_urb_cancel(struct oz_port *port, u8 ep_num, struct urb *urb) if (urbl) { urb->actual_length = 0; oz_free_urb_link(urbl); - oz_complete_urb(ozhcd->hcd, urb, -EPIPE, 0); + oz_complete_urb(ozhcd->hcd, urb, -EPIPE); } } /*------------------------------------------------------------------------------ @@ -1678,7 +1680,7 @@ static void oz_hcd_clear_orphanage(struct oz_hcd *ozhcd, int status) urbl = list_first_entry(&ozhcd->orphanage, struct oz_urb_link, link); list_del(&urbl->link); - oz_complete_urb(ozhcd->hcd, urbl->urb, status, 0); + oz_complete_urb(ozhcd->hcd, urbl->urb, status); oz_free_urb_link(urbl); } } @@ -1720,14 +1722,13 @@ static int oz_hcd_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, struct oz_port *port; unsigned long irq_state; struct oz_urb_link *urbl; - oz_dbg(URB, "%lu: %s: (%p)\n", jiffies, __func__, urb); + oz_dbg(URB, "%s: (%p)\n", __func__, urb); if (unlikely(ozhcd == NULL)) { - oz_dbg(URB, "%lu: Refused urb(%p) not ozhcd\n", jiffies, urb); + oz_dbg(URB, "Refused urb(%p) not ozhcd\n", urb); return -EPIPE; } if (unlikely(hcd->state != HC_STATE_RUNNING)) { - oz_dbg(URB, "%lu: Refused urb(%p) not running\n", - jiffies, urb); + oz_dbg(URB, "Refused urb(%p) not running\n", urb); return -EPIPE; } port_ix = oz_get_port_from_addr(ozhcd, urb->dev->devnum); @@ -1795,7 +1796,7 @@ static int oz_hcd_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) struct oz_urb_link *urbl = NULL; int rc; unsigned long irq_state; - oz_dbg(URB, "%lu: %s: (%p)\n", jiffies, __func__, urb); + oz_dbg(URB, "%s: (%p)\n", __func__, urb); urbl = oz_alloc_urb_link(); if (unlikely(urbl == NULL)) return -ENOMEM; diff --git a/drivers/staging/ozwpan/ozpd.c b/drivers/staging/ozwpan/ozpd.c index 8a253ac07c266..86876bda29a5f 100644 --- a/drivers/staging/ozwpan/ozpd.c +++ b/drivers/staging/ozwpan/ozpd.c @@ -176,6 +176,14 @@ struct oz_pd *oz_pd_alloc(const u8 *mac_addr) pd->last_sent_frame = &pd->tx_queue; spin_lock_init(&pd->stream_lock); INIT_LIST_HEAD(&pd->stream_list); + tasklet_init(&pd->heartbeat_tasklet, oz_pd_heartbeat_handler, + (unsigned long)pd); + tasklet_init(&pd->timeout_tasklet, oz_pd_timeout_handler, + (unsigned long)pd); + hrtimer_init(&pd->heartbeat, CLOCK_MONOTONIC, HRTIMER_MODE_REL); + hrtimer_init(&pd->timeout, CLOCK_MONOTONIC, HRTIMER_MODE_REL); + pd->heartbeat.function = oz_pd_heartbeat_event; + pd->timeout.function = oz_pd_timeout_event; } return pd; } @@ -189,6 +197,13 @@ void oz_pd_destroy(struct oz_pd *pd) struct oz_isoc_stream *st; struct oz_farewell *fwell; oz_pd_dbg(pd, ON, "Destroying PD\n"); + if (hrtimer_active(&pd->timeout)) + hrtimer_cancel(&pd->timeout); + if (hrtimer_active(&pd->heartbeat)) + hrtimer_cancel(&pd->heartbeat); + /*Disable timer tasklets*/ + tasklet_kill(&pd->heartbeat_tasklet); + tasklet_kill(&pd->timeout_tasklet); /* Delete any streams. */ e = pd->stream_list.next; @@ -287,8 +302,8 @@ void oz_pd_heartbeat(struct oz_pd *pd, u16 apps) more = 1; } } - if (more) - oz_pd_request_heartbeat(pd); + if ((!more) && (hrtimer_active(&pd->heartbeat))) + hrtimer_cancel(&pd->heartbeat); if (pd->mode & OZ_F_ISOC_ANYTIME) { int count = 8; while (count-- && (oz_send_isoc_frame(pd) >= 0)) @@ -315,7 +330,6 @@ void oz_pd_stop(struct oz_pd *pd) list_del(&pd->link); oz_polling_unlock_bh(); oz_dbg(ON, "pd ref count = %d\n", atomic_read(&pd->ref_count)); - oz_timer_delete(pd, 0); oz_pd_put(pd); } /*------------------------------------------------------------------------------ @@ -330,21 +344,18 @@ int oz_pd_sleep(struct oz_pd *pd) oz_polling_unlock_bh(); return 0; } - if (pd->keep_alive_j && pd->session_id) { + if (pd->keep_alive && pd->session_id) oz_pd_set_state(pd, OZ_PD_S_SLEEP); - pd->pulse_time_j = jiffies + pd->keep_alive_j; - oz_dbg(ON, "Sleep Now %lu until %lu\n", - jiffies, pd->pulse_time_j); - } else { + else do_stop = 1; - } + stop_apps = pd->total_apps; oz_polling_unlock_bh(); if (do_stop) { oz_pd_stop(pd); } else { oz_services_stop(pd, stop_apps, 1); - oz_timer_add(pd, OZ_TIMER_STOP, jiffies + pd->keep_alive_j, 1); + oz_timer_add(pd, OZ_TIMER_STOP, pd->keep_alive); } return do_stop; } diff --git a/drivers/staging/ozwpan/ozpd.h b/drivers/staging/ozwpan/ozpd.h index fbf47cbab8a92..a281753774e63 100644 --- a/drivers/staging/ozwpan/ozpd.h +++ b/drivers/staging/ozwpan/ozpd.h @@ -6,6 +6,7 @@ #ifndef _OZPD_H_ #define _OZPD_H_ +#include #include "ozeltbuf.h" /* PD state @@ -68,18 +69,16 @@ struct oz_pd { u8 isoc_sent; u32 last_rx_pkt_num; u32 last_tx_pkt_num; + struct timespec last_rx_timestamp; u32 trigger_pkt_num; - unsigned long pulse_time_j; - unsigned long timeout_time_j; - unsigned long pulse_period_j; - unsigned long presleep_j; - unsigned long keep_alive_j; - unsigned long last_rx_time_j; + unsigned long pulse_time; + unsigned long pulse_period; + unsigned long presleep; + unsigned long keep_alive; struct oz_elt_buf elt_buff; void *app_ctx[OZ_APPID_MAX]; spinlock_t app_lock[OZ_APPID_MAX]; int max_tx_size; - u8 heartbeat_requested; u8 mode; u8 ms_per_isoc; unsigned isoc_latency; @@ -95,6 +94,11 @@ struct oz_pd { spinlock_t stream_lock; struct list_head stream_list; struct net_device *net_dev; + struct hrtimer heartbeat; + struct hrtimer timeout; + u8 timeout_type; + struct tasklet_struct heartbeat_tasklet; + struct tasklet_struct timeout_tasklet; }; #define OZ_MAX_QUEUED_FRAMES 4 diff --git a/drivers/staging/ozwpan/ozproto.c b/drivers/staging/ozwpan/ozproto.c index 760761df3845c..ed22729ea90d2 100644 --- a/drivers/staging/ozwpan/ozproto.c +++ b/drivers/staging/ozwpan/ozproto.c @@ -30,12 +30,6 @@ #define OZ_DO_STOP 1 #define OZ_DO_SLEEP 2 -/* States of the timer. - */ -#define OZ_TIMER_IDLE 0 -#define OZ_TIMER_SET 1 -#define OZ_TIMER_IN_HANDLER 2 - #define OZ_MAX_TIMER_POOL_SIZE 16 /*------------------------------------------------------------------------------ @@ -46,12 +40,6 @@ struct oz_binding { struct oz_binding *next; }; -struct oz_timer { - struct list_head link; - struct oz_pd *pd; - unsigned long due_time; - int type; -}; /*------------------------------------------------------------------------------ * Static external variables. */ @@ -63,15 +51,6 @@ static struct sk_buff_head g_rx_queue; static u8 g_session_id; static u16 g_apps = 0x1; static int g_processing_rx; -static struct timer_list g_timer; -static struct oz_timer *g_cur_timer; -static struct list_head *g_timer_pool; -static int g_timer_pool_count; -static int g_timer_state = OZ_TIMER_IDLE; -static LIST_HEAD(g_timer_list); -/*------------------------------------------------------------------------------ - */ -static void oz_protocol_timer_start(void); /*------------------------------------------------------------------------------ * Context: softirq-serialized */ @@ -138,33 +117,37 @@ static void pd_set_keepalive(struct oz_pd *pd, u8 kalive) switch (kalive & OZ_KALIVE_TYPE_MASK) { case OZ_KALIVE_SPECIAL: - pd->keep_alive_j = - oz_ms_to_jiffies(keep_alive * 1000*60*60*24*20); + pd->keep_alive = keep_alive * 1000*60*60*24*20; break; case OZ_KALIVE_SECS: - pd->keep_alive_j = oz_ms_to_jiffies(keep_alive*1000); + pd->keep_alive = keep_alive*1000; break; case OZ_KALIVE_MINS: - pd->keep_alive_j = oz_ms_to_jiffies(keep_alive*1000*60); + pd->keep_alive = keep_alive*1000*60; break; case OZ_KALIVE_HOURS: - pd->keep_alive_j = oz_ms_to_jiffies(keep_alive*1000*60*60); + pd->keep_alive = keep_alive*1000*60*60; break; default: - pd->keep_alive_j = 0; + pd->keep_alive = 0; } - oz_dbg(ON, "Keepalive = %lu jiffies\n", pd->keep_alive_j); + oz_dbg(ON, "Keepalive = %lu mSec\n", pd->keep_alive); } /*------------------------------------------------------------------------------ * Context: softirq-serialized */ -static void pd_set_presleep(struct oz_pd *pd, u8 presleep) +static void pd_set_presleep(struct oz_pd *pd, u8 presleep, u8 start_timer) { if (presleep) - pd->presleep_j = oz_ms_to_jiffies(presleep*100); + pd->presleep = presleep*100; else - pd->presleep_j = OZ_PRESLEEP_TOUT_J; - oz_dbg(ON, "Presleep time = %lu jiffies\n", pd->presleep_j); + pd->presleep = OZ_PRESLEEP_TOUT; + if (start_timer) { + spin_unlock(&g_polling_lock); + oz_timer_add(pd, OZ_TIMER_TOUT, pd->presleep); + spin_lock(&g_polling_lock); + } + oz_dbg(ON, "Presleep time = %lu mSec\n", pd->presleep); } /*------------------------------------------------------------------------------ * Context: softirq-serialized @@ -189,7 +172,7 @@ static struct oz_pd *oz_connect_req(struct oz_pd *cur_pd, struct oz_elt *elt, pd = oz_pd_alloc(pd_addr); if (pd == NULL) return NULL; - pd->last_rx_time_j = jiffies; + getnstimeofday(&pd->last_rx_timestamp); spin_lock_bh(&g_polling_lock); list_for_each(e, &g_pd_list) { pd2 = container_of(e, struct oz_pd, link); @@ -238,9 +221,8 @@ static struct oz_pd *oz_connect_req(struct oz_pd *cur_pd, struct oz_elt *elt, oz_dbg(ON, "Max frame:%u Ms per isoc:%u\n", pd->max_tx_size, pd->ms_per_isoc); pd->max_stream_buffering = 3*1024; - pd->timeout_time_j = jiffies + OZ_CONNECTION_TOUT_J; - pd->pulse_period_j = OZ_QUANTUM_J; - pd_set_presleep(pd, body->presleep); + pd->pulse_period = OZ_QUANTUM; + pd_set_presleep(pd, body->presleep, 0); pd_set_keepalive(pd, body->keep_alive); new_apps &= le16_to_cpu(get_unaligned(&body->apps)); @@ -272,7 +254,6 @@ static struct oz_pd *oz_connect_req(struct oz_pd *cur_pd, struct oz_elt *elt, u16 resume_apps = new_apps & pd->paused_apps & ~0x1; spin_unlock_bh(&g_polling_lock); oz_pd_set_state(pd, OZ_PD_S_CONNECTED); - oz_timer_delete(pd, OZ_TIMER_STOP); oz_dbg(ON, "new_apps=0x%x total_apps=0x%x paused_apps=0x%x\n", new_apps, pd->total_apps, pd->paused_apps); if (start_apps) { @@ -341,6 +322,7 @@ static void oz_rx_frame(struct sk_buff *skb) int length; struct oz_pd *pd = NULL; struct oz_hdr *oz_hdr = (struct oz_hdr *)skb_network_header(skb); + struct timespec current_time; int dup = 0; u32 pkt_num; @@ -361,9 +343,14 @@ static void oz_rx_frame(struct sk_buff *skb) pd = oz_pd_find(src_addr); if (pd) { - pd->last_rx_time_j = jiffies; - oz_timer_add(pd, OZ_TIMER_TOUT, - pd->last_rx_time_j + pd->presleep_j, 1); + if (!(pd->state & OZ_PD_S_CONNECTED)) + oz_pd_set_state(pd, OZ_PD_S_CONNECTED); + getnstimeofday(¤t_time); + if ((current_time.tv_sec != pd->last_rx_timestamp.tv_sec) || + (pd->presleep < MSEC_PER_SEC)) { + oz_timer_add(pd, OZ_TIMER_TOUT, pd->presleep); + pd->last_rx_timestamp = current_time; + } if (pkt_num != pd->last_rx_pkt_num) { pd->last_rx_pkt_num = pkt_num; } else { @@ -412,7 +399,7 @@ static void oz_rx_frame(struct sk_buff *skb) if (pd && (pd->state & OZ_PD_S_CONNECTED)) { spin_lock(&g_polling_lock); pd_set_keepalive(pd, body->keepalive); - pd_set_presleep(pd, body->presleep); + pd_set_presleep(pd, body->presleep, 1); spin_unlock(&g_polling_lock); } } @@ -450,8 +437,6 @@ static void oz_rx_frame(struct sk_buff *skb) */ void oz_protocol_term(void) { - struct list_head *chain; - del_timer_sync(&g_timer); /* Walk the list of bindings and remove each one. */ spin_lock_bh(&g_binding_lock); @@ -480,21 +465,35 @@ void oz_protocol_term(void) oz_pd_put(pd); spin_lock_bh(&g_polling_lock); } - chain = g_timer_pool; - g_timer_pool = NULL; spin_unlock_bh(&g_polling_lock); - while (chain) { - struct oz_timer *t = container_of(chain, struct oz_timer, link); - chain = chain->next; - kfree(t); - } oz_dbg(ON, "Protocol stopped\n"); } /*------------------------------------------------------------------------------ * Context: softirq */ -static void oz_pd_handle_timer(struct oz_pd *pd, int type) +void oz_pd_heartbeat_handler(unsigned long data) { + struct oz_pd *pd = (struct oz_pd *)data; + u16 apps = 0; + spin_lock_bh(&g_polling_lock); + if (pd->state & OZ_PD_S_CONNECTED) + apps = pd->total_apps; + spin_unlock_bh(&g_polling_lock); + if (apps) + oz_pd_heartbeat(pd, apps); + +} +/*------------------------------------------------------------------------------ + * Context: softirq + */ +void oz_pd_timeout_handler(unsigned long data) +{ + int type; + struct oz_pd *pd = (struct oz_pd *)data; + + spin_lock_bh(&g_polling_lock); + type = pd->timeout_type; + spin_unlock_bh(&g_polling_lock); switch (type) { case OZ_TIMER_TOUT: oz_pd_sleep(pd); @@ -502,218 +501,69 @@ static void oz_pd_handle_timer(struct oz_pd *pd, int type) case OZ_TIMER_STOP: oz_pd_stop(pd); break; - case OZ_TIMER_HEARTBEAT: { - u16 apps = 0; - spin_lock_bh(&g_polling_lock); - pd->heartbeat_requested = 0; - if (pd->state & OZ_PD_S_CONNECTED) - apps = pd->total_apps; - spin_unlock_bh(&g_polling_lock); - if (apps) - oz_pd_heartbeat(pd, apps); - } - break; } } /*------------------------------------------------------------------------------ - * Context: softirq + * Context: Interrupt */ -static void oz_protocol_timer(unsigned long arg) +enum hrtimer_restart oz_pd_heartbeat_event(struct hrtimer *timer) { - struct oz_timer *t; - struct oz_timer *t2; struct oz_pd *pd; - spin_lock_bh(&g_polling_lock); - if (!g_cur_timer) { - /* This happens if we remove the current timer but can't stop - * the timer from firing. In this case just get out. - */ - spin_unlock_bh(&g_polling_lock); - return; - } - g_timer_state = OZ_TIMER_IN_HANDLER; - t = g_cur_timer; - g_cur_timer = NULL; - list_del(&t->link); - spin_unlock_bh(&g_polling_lock); - do { - pd = t->pd; - oz_pd_handle_timer(pd, t->type); - spin_lock_bh(&g_polling_lock); - if (g_timer_pool_count < OZ_MAX_TIMER_POOL_SIZE) { - t->link.next = g_timer_pool; - g_timer_pool = &t->link; - g_timer_pool_count++; - t = NULL; - } - if (!list_empty(&g_timer_list)) { - t2 = container_of(g_timer_list.next, - struct oz_timer, link); - if (time_before_eq(t2->due_time, jiffies)) - list_del(&t2->link); - else - t2 = NULL; - } else { - t2 = NULL; - } - spin_unlock_bh(&g_polling_lock); - oz_pd_put(pd); - kfree(t); - t = t2; - } while (t); - g_timer_state = OZ_TIMER_IDLE; - oz_protocol_timer_start(); + + pd = container_of(timer, struct oz_pd, heartbeat); + hrtimer_forward_now(timer, ktime_set(pd->pulse_period / + MSEC_PER_SEC, (pd->pulse_period % MSEC_PER_SEC) * NSEC_PER_MSEC)); + tasklet_schedule(&pd->heartbeat_tasklet); + return HRTIMER_RESTART; } /*------------------------------------------------------------------------------ - * Context: softirq + * Context: Interrupt */ -static void oz_protocol_timer_start(void) +enum hrtimer_restart oz_pd_timeout_event(struct hrtimer *timer) { - spin_lock_bh(&g_polling_lock); - if (!list_empty(&g_timer_list)) { - g_cur_timer = - container_of(g_timer_list.next, struct oz_timer, link); - if (g_timer_state == OZ_TIMER_SET) { - mod_timer(&g_timer, g_cur_timer->due_time); - } else { - g_timer.expires = g_cur_timer->due_time; - g_timer.function = oz_protocol_timer; - g_timer.data = 0; - add_timer(&g_timer); - } - g_timer_state = OZ_TIMER_SET; - } else { - oz_dbg(ON, "No queued timers\n"); - } - spin_unlock_bh(&g_polling_lock); + struct oz_pd *pd; + + pd = container_of(timer, struct oz_pd, timeout); + tasklet_schedule(&pd->timeout_tasklet); + return HRTIMER_NORESTART; } /*------------------------------------------------------------------------------ * Context: softirq or process */ -void oz_timer_add(struct oz_pd *pd, int type, unsigned long due_time, - int remove) +void oz_timer_add(struct oz_pd *pd, int type, unsigned long due_time) { - struct list_head *e; - struct oz_timer *t = NULL; - int restart_needed = 0; - spin_lock(&g_polling_lock); - if (remove) { - list_for_each(e, &g_timer_list) { - t = container_of(e, struct oz_timer, link); - if ((t->pd == pd) && (t->type == type)) { - if (g_cur_timer == t) { - restart_needed = 1; - g_cur_timer = NULL; - } - list_del(e); - break; - } - t = NULL; - } - } - if (!t) { - if (g_timer_pool) { - t = container_of(g_timer_pool, struct oz_timer, link); - g_timer_pool = g_timer_pool->next; - g_timer_pool_count--; + spin_lock_bh(&g_polling_lock); + switch (type) { + case OZ_TIMER_TOUT: + case OZ_TIMER_STOP: + if (hrtimer_active(&pd->timeout)) { + hrtimer_set_expires(&pd->timeout, ktime_set(due_time / + MSEC_PER_SEC, (due_time % MSEC_PER_SEC) * + NSEC_PER_MSEC)); + hrtimer_start_expires(&pd->timeout, HRTIMER_MODE_REL); } else { - t = kmalloc(sizeof(struct oz_timer), GFP_ATOMIC); - } - if (t) { - t->pd = pd; - t->type = type; - oz_pd_get(pd); + hrtimer_start(&pd->timeout, ktime_set(due_time / + MSEC_PER_SEC, (due_time % MSEC_PER_SEC) * + NSEC_PER_MSEC), HRTIMER_MODE_REL); } + pd->timeout_type = type; + break; + case OZ_TIMER_HEARTBEAT: + if (!hrtimer_active(&pd->heartbeat)) + hrtimer_start(&pd->heartbeat, ktime_set(due_time / + MSEC_PER_SEC, (due_time % MSEC_PER_SEC) * + NSEC_PER_MSEC), HRTIMER_MODE_REL); + break; } - if (t) { - struct oz_timer *t2; - t->due_time = due_time; - list_for_each(e, &g_timer_list) { - t2 = container_of(e, struct oz_timer, link); - if (time_before(due_time, t2->due_time)) { - if (t2 == g_cur_timer) { - g_cur_timer = NULL; - restart_needed = 1; - } - break; - } - } - list_add_tail(&t->link, e); - } - if (g_timer_state == OZ_TIMER_IDLE) - restart_needed = 1; - else if (g_timer_state == OZ_TIMER_IN_HANDLER) - restart_needed = 0; - spin_unlock(&g_polling_lock); - if (restart_needed) - oz_protocol_timer_start(); -} -/*------------------------------------------------------------------------------ - * Context: softirq or process - */ -void oz_timer_delete(struct oz_pd *pd, int type) -{ - struct list_head *chain = NULL; - struct oz_timer *t; - struct oz_timer *n; - int restart_needed = 0; - int release = 0; - spin_lock(&g_polling_lock); - list_for_each_entry_safe(t, n, &g_timer_list, link) { - if ((t->pd == pd) && ((type == 0) || (t->type == type))) { - if (g_cur_timer == t) { - restart_needed = 1; - g_cur_timer = NULL; - del_timer(&g_timer); - } - list_del(&t->link); - release++; - if (g_timer_pool_count < OZ_MAX_TIMER_POOL_SIZE) { - t->link.next = g_timer_pool; - g_timer_pool = &t->link; - g_timer_pool_count++; - } else { - t->link.next = chain; - chain = &t->link; - } - if (type) - break; - } - } - if (g_timer_state == OZ_TIMER_IN_HANDLER) - restart_needed = 0; - else if (restart_needed) - g_timer_state = OZ_TIMER_IDLE; - spin_unlock(&g_polling_lock); - if (restart_needed) - oz_protocol_timer_start(); - while (release--) - oz_pd_put(pd); - while (chain) { - t = container_of(chain, struct oz_timer, link); - chain = chain->next; - kfree(t); - } + spin_unlock_bh(&g_polling_lock); } /*------------------------------------------------------------------------------ * Context: softirq or process */ void oz_pd_request_heartbeat(struct oz_pd *pd) { - unsigned long now = jiffies; - unsigned long t; - spin_lock(&g_polling_lock); - if (pd->heartbeat_requested) { - spin_unlock(&g_polling_lock); - return; - } - if (pd->pulse_period_j) - t = ((now / pd->pulse_period_j) + 1) * pd->pulse_period_j; - else - t = now + 1; - pd->heartbeat_requested = 1; - spin_unlock(&g_polling_lock); - oz_timer_add(pd, OZ_TIMER_HEARTBEAT, t, 0); + oz_timer_add(pd, OZ_TIMER_HEARTBEAT, pd->pulse_period > 0 ? + pd->pulse_period : OZ_QUANTUM); } /*------------------------------------------------------------------------------ * Context: softirq or process @@ -915,7 +765,6 @@ int oz_protocol_init(char *devs) oz_binding_add(d); } } - init_timer(&g_timer); return 0; } /*------------------------------------------------------------------------------ diff --git a/drivers/staging/ozwpan/ozproto.h b/drivers/staging/ozwpan/ozproto.h index 9bb0a6abfc881..305c5321022db 100644 --- a/drivers/staging/ozwpan/ozproto.h +++ b/drivers/staging/ozwpan/ozproto.h @@ -12,20 +12,11 @@ #define OZ_ALLOCATED_SPACE(__x) (LL_RESERVED_SPACE(__x)+(__x)->needed_tailroom) -/* Converts millisecs to jiffies. - */ -#define oz_ms_to_jiffies(__x) msecs_to_jiffies(__x) - -/* Quantum milliseconds. - */ -#define OZ_QUANTUM_MS 8 -/* Quantum jiffies - */ -#define OZ_QUANTUM_J (oz_ms_to_jiffies(OZ_QUANTUM_MS)) +/* Quantum in MS */ +#define OZ_QUANTUM 8 /* Default timeouts. */ -#define OZ_CONNECTION_TOUT_J (2*HZ) -#define OZ_PRESLEEP_TOUT_J (11*HZ) +#define OZ_PRESLEEP_TOUT 11 /* Maximun sizes of tx frames. */ #define OZ_MAX_TX_SIZE 1514 @@ -65,11 +56,16 @@ void oz_app_enable(int app_id, int enable); struct oz_pd *oz_pd_find(const u8 *mac_addr); void oz_binding_add(char *net_dev); void oz_binding_remove(char *net_dev); -void oz_timer_add(struct oz_pd *pd, int type, unsigned long due_time, - int remove); +void oz_timer_add(struct oz_pd *pd, int type, unsigned long due_time); void oz_timer_delete(struct oz_pd *pd, int type); void oz_pd_request_heartbeat(struct oz_pd *pd); void oz_polling_lock_bh(void); void oz_polling_unlock_bh(void); +void oz_pd_heartbeat_handler(unsigned long data); +void oz_pd_timeout_handler(unsigned long data); +enum hrtimer_restart oz_pd_heartbeat_event(struct hrtimer *timer); +enum hrtimer_restart oz_pd_timeout_event(struct hrtimer *timer); +int oz_get_pd_status_list(char *pd_list, int max_count); +int oz_get_binding_list(char *buf, int max_if); #endif /* _OZPROTO_H */ diff --git a/drivers/staging/ozwpan/ozurbparanoia.c b/drivers/staging/ozwpan/ozurbparanoia.c index 366584b75767c..d69e8ab9db9a3 100644 --- a/drivers/staging/ozwpan/ozurbparanoia.c +++ b/drivers/staging/ozwpan/ozurbparanoia.c @@ -24,7 +24,7 @@ void oz_remember_urb(struct urb *urb) spin_lock_irqsave(&g_urb_mem_lock, irq_state); if (g_nb_urbs < OZ_MAX_URBS) { g_urb_memory[g_nb_urbs++] = urb; - oz_dbg(ON, "%lu: urb up = %d %p\n", jiffies, g_nb_urbs, urb); + oz_dbg(ON, "urb up = %d %p\n", g_nb_urbs, urb); } else { oz_dbg(ON, "ERROR urb buffer full\n"); } @@ -44,8 +44,7 @@ int oz_forget_urb(struct urb *urb) if (--g_nb_urbs > i) memcpy(&g_urb_memory[i], &g_urb_memory[i+1], (g_nb_urbs - i) * sizeof(struct urb *)); - oz_dbg(ON, "%lu: urb down = %d %p\n", - jiffies, g_nb_urbs, urb); + oz_dbg(ON, "urb down = %d %p\n", g_nb_urbs, urb); } } spin_unlock_irqrestore(&g_urb_mem_lock, irq_state); diff --git a/drivers/staging/ozwpan/ozusbsvc.c b/drivers/staging/ozwpan/ozusbsvc.c index 816cac980586e..732face55e8ca 100644 --- a/drivers/staging/ozwpan/ozusbsvc.c +++ b/drivers/staging/ozwpan/ozusbsvc.c @@ -123,7 +123,8 @@ void oz_usb_stop(struct oz_pd *pd, int pause) pd->app_ctx[OZ_APPID_USB-1] = NULL; spin_unlock_bh(&pd->app_lock[OZ_APPID_USB-1]); if (usb_ctx) { - unsigned long tout = jiffies + HZ; + struct timespec ts, now; + getnstimeofday(&ts); oz_dbg(ON, "USB service stopping...\n"); usb_ctx->stopped = 1; /* At this point the reference count on the usb context should @@ -132,9 +133,12 @@ void oz_usb_stop(struct oz_pd *pd, int pause) * should get in but someone may already be in. So wait * until they leave but timeout after 1 second. */ - while ((atomic_read(&usb_ctx->ref_count) > 2) && - time_before(jiffies, tout)) - ; + while ((atomic_read(&usb_ctx->ref_count) > 2)) { + getnstimeofday(&now); + /*Approx 1 Sec. this is not perfect calculation*/ + if (now.tv_sec != ts.tv_sec) + break; + } oz_dbg(ON, "USB service stopped\n"); oz_hcd_pd_departed(usb_ctx->hport); /* Release the reference taken in oz_usb_start. @@ -155,7 +159,7 @@ void oz_usb_get(void *hpd) /*------------------------------------------------------------------------------ * This decrements the reference count of the context area for a specific PD * and destroys the context area if the reference count becomes zero. - * Context: softirq or process + * Context: irq or process */ void oz_usb_put(void *hpd) { -- GitLab From 4918072eb0fa3d430613c11b4cb287e6c3bf1879 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 30 Jul 2013 23:42:53 +0300 Subject: [PATCH 416/942] staging: octeon-usb: cvmx_usb_speed_t -> enum cvmx_usb_speed Replace cvmx_usb_speed_t with enum cvmx_usb_speed. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/cvmx-usb.c | 4 ++-- drivers/staging/octeon-usb/cvmx-usb.h | 21 ++++++++++++--------- drivers/staging/octeon-usb/octeon-hcd.c | 2 +- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/drivers/staging/octeon-usb/cvmx-usb.c b/drivers/staging/octeon-usb/cvmx-usb.c index fa029e3f8db13..44f4db0cfd9ac 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.c +++ b/drivers/staging/octeon-usb/cvmx-usb.c @@ -151,7 +151,7 @@ typedef struct cvmx_usb_pipe { uint64_t interval; /**< For periodic pipes, the interval between packets in frames */ uint64_t next_tx_frame; /**< The next frame this pipe is allowed to transmit on */ cvmx_usb_pipe_flags_t flags; /**< State flags for this pipe */ - cvmx_usb_speed_t device_speed; /**< Speed of device connected to this pipe */ + enum cvmx_usb_speed device_speed; /**< Speed of device connected to this pipe */ cvmx_usb_transfer_t transfer_type; /**< Type of transaction supported by this pipe */ cvmx_usb_direction_t transfer_dir; /**< IN or OUT. Ignored for Control */ int multi_count; /**< Max packet in a row for the device */ @@ -1103,7 +1103,7 @@ static inline int __cvmx_usb_get_pipe_handle(cvmx_usb_internal_state_t *usb, */ int cvmx_usb_open_pipe(cvmx_usb_state_t *state, cvmx_usb_pipe_flags_t flags, int device_addr, int endpoint_num, - cvmx_usb_speed_t device_speed, int max_packet, + enum cvmx_usb_speed device_speed, int max_packet, cvmx_usb_transfer_t transfer_type, cvmx_usb_direction_t transfer_dir, int interval, int multi_count, int hub_device_addr, int hub_port) diff --git a/drivers/staging/octeon-usb/cvmx-usb.h b/drivers/staging/octeon-usb/cvmx-usb.h index 4b425e5fa8ae5..c5ccda34b530a 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.h +++ b/drivers/staging/octeon-usb/cvmx-usb.h @@ -235,14 +235,17 @@ #define __CVMX_USB_H__ /** - * Enumerations representing the possible USB device speeds + * enum cvmx_usb_speed - the possible USB device speeds + * + * @CVMX_USB_SPEED_HIGH: Device is operation at 480Mbps + * @CVMX_USB_SPEED_FULL: Device is operation at 12Mbps + * @CVMX_USB_SPEED_LOW: Device is operation at 1.5Mbps */ -typedef enum -{ - CVMX_USB_SPEED_HIGH = 0, /**< Device is operation at 480Mbps */ - CVMX_USB_SPEED_FULL = 1, /**< Device is operation at 12Mbps */ - CVMX_USB_SPEED_LOW = 2, /**< Device is operation at 1.5Mbps */ -} cvmx_usb_speed_t; +enum cvmx_usb_speed { + CVMX_USB_SPEED_HIGH = 0, + CVMX_USB_SPEED_FULL = 1, + CVMX_USB_SPEED_LOW = 2, +}; /** * Enumeration representing the possible USB transfer types. @@ -290,7 +293,7 @@ typedef struct uint32_t port_enabled : 1; /**< 1 = Usb port is enabled, 0 = disabled */ uint32_t port_over_current : 1; /**< 1 = Over current detected, 0 = Over current not detected. Octeon doesn't support over current detection */ uint32_t port_powered : 1; /**< 1 = Port power is being supplied to the device, 0 = power is off. Octeon doesn't support turning port power off */ - cvmx_usb_speed_t port_speed : 2; /**< Current port speed */ + enum cvmx_usb_speed port_speed : 2; /**< Current port speed */ uint32_t connected : 1; /**< 1 = A device is connected to the port, 0 = No device is connected */ uint32_t connect_change : 1; /**< 1 = Device connected state changed since the last set status call */ } cvmx_usb_port_status_t; @@ -413,7 +416,7 @@ extern void cvmx_usb_set_status(cvmx_usb_state_t *state, cvmx_usb_port_status_t extern int cvmx_usb_open_pipe(cvmx_usb_state_t *state, cvmx_usb_pipe_flags_t flags, int device_addr, int endpoint_num, - cvmx_usb_speed_t device_speed, int max_packet, + enum cvmx_usb_speed device_speed, int max_packet, cvmx_usb_transfer_t transfer_type, cvmx_usb_direction_t transfer_dir, int interval, int multi_count, int hub_device_addr, diff --git a/drivers/staging/octeon-usb/octeon-hcd.c b/drivers/staging/octeon-usb/octeon-hcd.c index d156b603ae655..f32d8fc60200e 100644 --- a/drivers/staging/octeon-usb/octeon-hcd.c +++ b/drivers/staging/octeon-usb/octeon-hcd.c @@ -217,7 +217,7 @@ static int octeon_usb_urb_enqueue(struct usb_hcd *hcd, if (!ep->hcpriv) { cvmx_usb_transfer_t transfer_type; - cvmx_usb_speed_t speed; + enum cvmx_usb_speed speed; int split_device = 0; int split_port = 0; switch (usb_pipetype(urb->pipe)) { -- GitLab From 394d4e080f31cd59ccfd1ab8983dcf79c8f7e774 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 30 Jul 2013 23:42:54 +0300 Subject: [PATCH 417/942] staging: octeon-usb: cvmx_usb_transfer_t -> enum cvmx_usb_transfer Replace cvmx_usb_transfer_t with enum cvmx_usb_transfer. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/cvmx-usb.c | 10 +++++----- drivers/staging/octeon-usb/cvmx-usb.h | 26 ++++++++++++++++--------- drivers/staging/octeon-usb/octeon-hcd.c | 2 +- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/drivers/staging/octeon-usb/cvmx-usb.c b/drivers/staging/octeon-usb/cvmx-usb.c index 44f4db0cfd9ac..ff5d1706c423e 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.c +++ b/drivers/staging/octeon-usb/cvmx-usb.c @@ -122,7 +122,7 @@ typedef enum { typedef struct cvmx_usb_transaction { struct cvmx_usb_transaction *prev; /**< Transaction before this one in the pipe */ struct cvmx_usb_transaction *next; /**< Transaction after this one in the pipe */ - cvmx_usb_transfer_t type; /**< Type of transaction, duplicated of the pipe */ + enum cvmx_usb_transfer type; /**< Type of transaction, duplicated of the pipe */ cvmx_usb_transaction_flags_t flags; /**< State flags for this transaction */ uint64_t buffer; /**< User's physical buffer address to read/write */ int buffer_length; /**< Size of the user's buffer in bytes */ @@ -152,7 +152,7 @@ typedef struct cvmx_usb_pipe { uint64_t next_tx_frame; /**< The next frame this pipe is allowed to transmit on */ cvmx_usb_pipe_flags_t flags; /**< State flags for this pipe */ enum cvmx_usb_speed device_speed; /**< Speed of device connected to this pipe */ - cvmx_usb_transfer_t transfer_type; /**< Type of transaction supported by this pipe */ + enum cvmx_usb_transfer transfer_type; /**< Type of transaction supported by this pipe */ cvmx_usb_direction_t transfer_dir; /**< IN or OUT. Ignored for Control */ int multi_count; /**< Max packet in a row for the device */ uint16_t max_packet; /**< The device's maximum packet size in bytes */ @@ -1104,7 +1104,7 @@ static inline int __cvmx_usb_get_pipe_handle(cvmx_usb_internal_state_t *usb, int cvmx_usb_open_pipe(cvmx_usb_state_t *state, cvmx_usb_pipe_flags_t flags, int device_addr, int endpoint_num, enum cvmx_usb_speed device_speed, int max_packet, - cvmx_usb_transfer_t transfer_type, + enum cvmx_usb_transfer transfer_type, cvmx_usb_direction_t transfer_dir, int interval, int multi_count, int hub_device_addr, int hub_port) { @@ -1825,7 +1825,7 @@ static void __cvmx_usb_schedule(cvmx_usb_internal_state_t *usb, int is_sof) int channel; cvmx_usb_pipe_t *pipe; int need_sof; - cvmx_usb_transfer_t ttype; + enum cvmx_usb_transfer ttype; if (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA) { /* Without DMA we need to be careful to not schedule something at the end of a frame and cause an overrun */ @@ -2025,7 +2025,7 @@ static void __cvmx_usb_perform_complete(cvmx_usb_internal_state_t *usb, */ static int __cvmx_usb_submit_transaction(cvmx_usb_internal_state_t *usb, int pipe_handle, - cvmx_usb_transfer_t type, + enum cvmx_usb_transfer type, int flags, uint64_t buffer, int buffer_length, diff --git a/drivers/staging/octeon-usb/cvmx-usb.h b/drivers/staging/octeon-usb/cvmx-usb.h index c5ccda34b530a..0cb13ee21950b 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.h +++ b/drivers/staging/octeon-usb/cvmx-usb.h @@ -248,15 +248,23 @@ enum cvmx_usb_speed { }; /** - * Enumeration representing the possible USB transfer types. + * enum cvmx_usb_transfer - the possible USB transfer types + * + * @CVMX_USB_TRANSFER_CONTROL: USB transfer type control for hub and status + * transfers + * @CVMX_USB_TRANSFER_ISOCHRONOUS: USB transfer type isochronous for low + * priority periodic transfers + * @CVMX_USB_TRANSFER_BULK: USB transfer type bulk for large low priority + * transfers + * @CVMX_USB_TRANSFER_INTERRUPT: USB transfer type interrupt for high priority + * periodic transfers */ -typedef enum -{ - CVMX_USB_TRANSFER_CONTROL = 0, /**< USB transfer type control for hub and status transfers */ - CVMX_USB_TRANSFER_ISOCHRONOUS = 1, /**< USB transfer type isochronous for low priority periodic transfers */ - CVMX_USB_TRANSFER_BULK = 2, /**< USB transfer type bulk for large low priority transfers */ - CVMX_USB_TRANSFER_INTERRUPT = 3, /**< USB transfer type interrupt for high priority periodic transfers */ -} cvmx_usb_transfer_t; +enum cvmx_usb_transfer { + CVMX_USB_TRANSFER_CONTROL = 0, + CVMX_USB_TRANSFER_ISOCHRONOUS = 1, + CVMX_USB_TRANSFER_BULK = 2, + CVMX_USB_TRANSFER_INTERRUPT = 3, +}; /** * Enumeration of the transfer directions @@ -417,7 +425,7 @@ extern int cvmx_usb_open_pipe(cvmx_usb_state_t *state, cvmx_usb_pipe_flags_t flags, int device_addr, int endpoint_num, enum cvmx_usb_speed device_speed, int max_packet, - cvmx_usb_transfer_t transfer_type, + enum cvmx_usb_transfer transfer_type, cvmx_usb_direction_t transfer_dir, int interval, int multi_count, int hub_device_addr, int hub_port); diff --git a/drivers/staging/octeon-usb/octeon-hcd.c b/drivers/staging/octeon-usb/octeon-hcd.c index f32d8fc60200e..6ab78ed57e80c 100644 --- a/drivers/staging/octeon-usb/octeon-hcd.c +++ b/drivers/staging/octeon-usb/octeon-hcd.c @@ -216,7 +216,7 @@ static int octeon_usb_urb_enqueue(struct usb_hcd *hcd, spin_lock_irqsave(&priv->lock, flags); if (!ep->hcpriv) { - cvmx_usb_transfer_t transfer_type; + enum cvmx_usb_transfer transfer_type; enum cvmx_usb_speed speed; int split_device = 0; int split_port = 0; -- GitLab From f1e1c1f69e0d38ddbff9610faa6572f04d3eff20 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 30 Jul 2013 23:42:55 +0300 Subject: [PATCH 418/942] staging: octeon-usb: cvmx_usb_direction_t -> enum cvmx_usb_direction Replace cvmx_usb_direction_t with enum cvmx_usb_direction. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/cvmx-usb.c | 4 ++-- drivers/staging/octeon-usb/cvmx-usb.h | 16 +++++++++------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/staging/octeon-usb/cvmx-usb.c b/drivers/staging/octeon-usb/cvmx-usb.c index ff5d1706c423e..533ad5f388266 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.c +++ b/drivers/staging/octeon-usb/cvmx-usb.c @@ -153,7 +153,7 @@ typedef struct cvmx_usb_pipe { cvmx_usb_pipe_flags_t flags; /**< State flags for this pipe */ enum cvmx_usb_speed device_speed; /**< Speed of device connected to this pipe */ enum cvmx_usb_transfer transfer_type; /**< Type of transaction supported by this pipe */ - cvmx_usb_direction_t transfer_dir; /**< IN or OUT. Ignored for Control */ + enum cvmx_usb_direction transfer_dir; /**< IN or OUT. Ignored for Control */ int multi_count; /**< Max packet in a row for the device */ uint16_t max_packet; /**< The device's maximum packet size in bytes */ uint8_t device_addr; /**< USB device address at other end of pipe */ @@ -1105,7 +1105,7 @@ int cvmx_usb_open_pipe(cvmx_usb_state_t *state, cvmx_usb_pipe_flags_t flags, int device_addr, int endpoint_num, enum cvmx_usb_speed device_speed, int max_packet, enum cvmx_usb_transfer transfer_type, - cvmx_usb_direction_t transfer_dir, int interval, + enum cvmx_usb_direction transfer_dir, int interval, int multi_count, int hub_device_addr, int hub_port) { cvmx_usb_pipe_t *pipe; diff --git a/drivers/staging/octeon-usb/cvmx-usb.h b/drivers/staging/octeon-usb/cvmx-usb.h index 0cb13ee21950b..7c313ff9c3e67 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.h +++ b/drivers/staging/octeon-usb/cvmx-usb.h @@ -267,13 +267,15 @@ enum cvmx_usb_transfer { }; /** - * Enumeration of the transfer directions + * enum cvmx_usb_direction - the transfer directions + * + * @CVMX_USB_DIRECTION_OUT: Data is transferring from Octeon to the device/host + * @CVMX_USB_DIRECTION_IN: Data is transferring from the device/host to Octeon */ -typedef enum -{ - CVMX_USB_DIRECTION_OUT, /**< Data is transferring from Octeon to the device/host */ - CVMX_USB_DIRECTION_IN, /**< Data is transferring from the device/host to Octeon */ -} cvmx_usb_direction_t; +enum cvmx_usb_direction { + CVMX_USB_DIRECTION_OUT, + CVMX_USB_DIRECTION_IN, +}; /** * Enumeration of all possible status codes passed to callback @@ -426,7 +428,7 @@ extern int cvmx_usb_open_pipe(cvmx_usb_state_t *state, int device_addr, int endpoint_num, enum cvmx_usb_speed device_speed, int max_packet, enum cvmx_usb_transfer transfer_type, - cvmx_usb_direction_t transfer_dir, int interval, + enum cvmx_usb_direction transfer_dir, int interval, int multi_count, int hub_device_addr, int hub_port); extern int cvmx_usb_submit_bulk(cvmx_usb_state_t *state, int pipe_handle, -- GitLab From 1c1bdf2764c7e5d983b20548a2913c0e4df07a3c Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 30 Jul 2013 23:42:56 +0300 Subject: [PATCH 419/942] staging: octeon-usb: cvmx_usb_complete_t -> enum cvmx_usb_complete Replace cvmx_usb_complete_t with enum cvmx_usb_complete. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/cvmx-usb.c | 4 +- drivers/staging/octeon-usb/cvmx-usb.h | 55 ++++++++++++++++--------- drivers/staging/octeon-usb/octeon-hcd.c | 4 +- 3 files changed, 39 insertions(+), 24 deletions(-) diff --git a/drivers/staging/octeon-usb/cvmx-usb.c b/drivers/staging/octeon-usb/cvmx-usb.c index 533ad5f388266..d8035bb810b80 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.c +++ b/drivers/staging/octeon-usb/cvmx-usb.c @@ -1902,7 +1902,7 @@ static void __cvmx_usb_perform_callback(cvmx_usb_internal_state_t *usb, cvmx_usb_pipe_t *pipe, cvmx_usb_transaction_t *transaction, cvmx_usb_callback_t reason, - cvmx_usb_complete_t complete_code) + enum cvmx_usb_complete complete_code) { cvmx_usb_callback_func_t callback = usb->callback[reason]; void *user_data = usb->callback_data[reason]; @@ -1946,7 +1946,7 @@ static void __cvmx_usb_perform_callback(cvmx_usb_internal_state_t *usb, static void __cvmx_usb_perform_complete(cvmx_usb_internal_state_t *usb, cvmx_usb_pipe_t *pipe, cvmx_usb_transaction_t *transaction, - cvmx_usb_complete_t complete_code) + enum cvmx_usb_complete complete_code) { /* If this was a split then clear our split in progress marker */ if (usb->active_split == transaction) diff --git a/drivers/staging/octeon-usb/cvmx-usb.h b/drivers/staging/octeon-usb/cvmx-usb.h index 7c313ff9c3e67..ea1f2eefc241c 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.h +++ b/drivers/staging/octeon-usb/cvmx-usb.h @@ -116,7 +116,7 @@ * * void port_callback(cvmx_usb_state_t *usb, * cvmx_usb_callback_t reason, - * cvmx_usb_complete_t status, + * enum cvmx_usb_complete status, * int pipe_handle, * int submit_handle, * int bytes_transferred, @@ -148,14 +148,14 @@ * * void complete_callback(cvmx_usb_state_t *usb, * cvmx_usb_callback_t reason, - * cvmx_usb_complete_t status, + * enum cvmx_usb_complete status, * int pipe_handle, * int submit_handle, * int bytes_transferred, * void *user_data); * - "usb" is the cvmx_usb_state_t for the port. * - "reason" will always be CVMX_USB_CALLBACK_TRANSFER_COMPLETE. - * - "status" will be one of the cvmx_usb_complete_t enumerations. + * - "status" will be one of the cvmx_usb_complete enumerations. * - "pipe_handle" is the handle to the pipe the transaction * was originally submitted on. * - "submit_handle" is the handle returned by the original @@ -278,21 +278,36 @@ enum cvmx_usb_direction { }; /** - * Enumeration of all possible status codes passed to callback - * functions. + * enum cvmx_usb_complete - possible callback function status codes + * + * @CVMX_USB_COMPLETE_SUCCESS: The transaction / operation finished without + * any errors + * @CVMX_USB_COMPLETE_SHORT: FIXME: This is currently not implemented + * @CVMX_USB_COMPLETE_CANCEL: The transaction was canceled while in flight by + * a user call to cvmx_usb_cancel + * @CVMX_USB_COMPLETE_ERROR: The transaction aborted with an unexpected + * error status + * @CVMX_USB_COMPLETE_STALL: The transaction received a USB STALL response + * from the device + * @CVMX_USB_COMPLETE_XACTERR: The transaction failed with an error from the + * device even after a number of retries + * @CVMX_USB_COMPLETE_DATATGLERR: The transaction failed with a data toggle + * error even after a number of retries + * @CVMX_USB_COMPLETE_BABBLEERR: The transaction failed with a babble error + * @CVMX_USB_COMPLETE_FRAMEERR: The transaction failed with a frame error + * even after a number of retries */ -typedef enum -{ - CVMX_USB_COMPLETE_SUCCESS, /**< The transaction / operation finished without any errors */ - CVMX_USB_COMPLETE_SHORT, /**< FIXME: This is currently not implemented */ - CVMX_USB_COMPLETE_CANCEL, /**< The transaction was canceled while in flight by a user call to cvmx_usb_cancel* */ - CVMX_USB_COMPLETE_ERROR, /**< The transaction aborted with an unexpected error status */ - CVMX_USB_COMPLETE_STALL, /**< The transaction received a USB STALL response from the device */ - CVMX_USB_COMPLETE_XACTERR, /**< The transaction failed with an error from the device even after a number of retries */ - CVMX_USB_COMPLETE_DATATGLERR, /**< The transaction failed with a data toggle error even after a number of retries */ - CVMX_USB_COMPLETE_BABBLEERR, /**< The transaction failed with a babble error */ - CVMX_USB_COMPLETE_FRAMEERR, /**< The transaction failed with a frame error even after a number of retries */ -} cvmx_usb_complete_t; +enum cvmx_usb_complete { + CVMX_USB_COMPLETE_SUCCESS, + CVMX_USB_COMPLETE_SHORT, + CVMX_USB_COMPLETE_CANCEL, + CVMX_USB_COMPLETE_ERROR, + CVMX_USB_COMPLETE_STALL, + CVMX_USB_COMPLETE_XACTERR, + CVMX_USB_COMPLETE_DATATGLERR, + CVMX_USB_COMPLETE_BABBLEERR, + CVMX_USB_COMPLETE_FRAMEERR, +}; /** * Structure returned containing the USB port status information. @@ -331,7 +346,7 @@ typedef struct { int offset; /**< This is the offset in bytes into the main buffer where this data is stored */ int length; /**< This is the length in bytes of the data */ - cvmx_usb_complete_t status; /**< This is the status of this individual packet transfer */ + enum cvmx_usb_complete status; /**< This is the status of this individual packet transfer */ } cvmx_usb_iso_packet_t; /** @@ -368,7 +383,7 @@ typedef struct * cvmx_usb_initialize(). * - reason = The cvmx_usb_callback_t used to register * the callback. - * - status = The cvmx_usb_complete_t representing the + * - status = The enum cvmx_usb_complete representing the * status code of a transaction. * - pipe_handle = The Pipe that caused this callback, or * -1 if this callback wasn't associated with a pipe. @@ -381,7 +396,7 @@ typedef struct * cvmx_usb_register_callback() */ typedef void (*cvmx_usb_callback_func_t)(cvmx_usb_state_t *state, cvmx_usb_callback_t reason, - cvmx_usb_complete_t status, + enum cvmx_usb_complete status, int pipe_handle, int submit_handle, int bytes_transferred, void *user_data); diff --git a/drivers/staging/octeon-usb/octeon-hcd.c b/drivers/staging/octeon-usb/octeon-hcd.c index 6ab78ed57e80c..b3c287394e07c 100644 --- a/drivers/staging/octeon-usb/octeon-hcd.c +++ b/drivers/staging/octeon-usb/octeon-hcd.c @@ -60,7 +60,7 @@ static irqreturn_t octeon_usb_irq(struct usb_hcd *hcd) static void octeon_usb_port_callback(cvmx_usb_state_t *usb, cvmx_usb_callback_t reason, - cvmx_usb_complete_t status, + enum cvmx_usb_complete status, int pipe_handle, int submit_handle, int bytes_transferred, @@ -107,7 +107,7 @@ static int octeon_usb_get_frame_number(struct usb_hcd *hcd) static void octeon_usb_urb_complete_callback(cvmx_usb_state_t *usb, cvmx_usb_callback_t reason, - cvmx_usb_complete_t status, + enum cvmx_usb_complete status, int pipe_handle, int submit_handle, int bytes_transferred, -- GitLab From e53b624ae56919b6b5c3e65543667293f3dedf99 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 30 Jul 2013 23:42:57 +0300 Subject: [PATCH 420/942] staging: octeon-usb: cvmx_usb_callback_t -> enum cvmx_usb_callback Replace cvmx_usb_callback_t with enum cvmx_usb_callback. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/cvmx-usb.c | 4 +-- drivers/staging/octeon-usb/cvmx-usb.h | 45 ++++++++++++++----------- drivers/staging/octeon-usb/octeon-hcd.c | 4 +-- 3 files changed, 30 insertions(+), 23 deletions(-) diff --git a/drivers/staging/octeon-usb/cvmx-usb.c b/drivers/staging/octeon-usb/cvmx-usb.c index d8035bb810b80..9e4bf7194ac73 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.c +++ b/drivers/staging/octeon-usb/cvmx-usb.c @@ -1901,7 +1901,7 @@ static void __cvmx_usb_schedule(cvmx_usb_internal_state_t *usb, int is_sof) static void __cvmx_usb_perform_callback(cvmx_usb_internal_state_t *usb, cvmx_usb_pipe_t *pipe, cvmx_usb_transaction_t *transaction, - cvmx_usb_callback_t reason, + enum cvmx_usb_callback reason, enum cvmx_usb_complete complete_code) { cvmx_usb_callback_func_t callback = usb->callback[reason]; @@ -2507,7 +2507,7 @@ int cvmx_usb_close_pipe(cvmx_usb_state_t *state, int pipe_handle) * Returns: 0 or a negative error code. */ int cvmx_usb_register_callback(cvmx_usb_state_t *state, - cvmx_usb_callback_t reason, + enum cvmx_usb_callback reason, cvmx_usb_callback_func_t callback, void *user_data) { diff --git a/drivers/staging/octeon-usb/cvmx-usb.h b/drivers/staging/octeon-usb/cvmx-usb.h index ea1f2eefc241c..7e1e2986d9538 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.h +++ b/drivers/staging/octeon-usb/cvmx-usb.h @@ -115,7 +115,7 @@ * The port callback prototype needs to look as follows: * * void port_callback(cvmx_usb_state_t *usb, - * cvmx_usb_callback_t reason, + * enum cvmx_usb_callback reason, * enum cvmx_usb_complete status, * int pipe_handle, * int submit_handle, @@ -147,7 +147,7 @@ * The completion callback prototype needs to look as follows: * * void complete_callback(cvmx_usb_state_t *usb, - * cvmx_usb_callback_t reason, + * enum cvmx_usb_callback reason, * enum cvmx_usb_complete status, * int pipe_handle, * int submit_handle, @@ -350,21 +350,28 @@ typedef struct } cvmx_usb_iso_packet_t; /** - * Possible callback reasons for the USB API. + * enum cvmx_usb_callback - possible callback reasons for the USB API + * + * @CVMX_USB_CALLBACK_TRANSFER_COMPLETE: A callback of this type is called when + * a submitted transfer completes. The + * completion callback will be called even + * if the transfer fails or is canceled. + * The status parameter will contain + * details of why he callback was called. + * @CVMX_USB_CALLBACK_PORT_CHANGED: The status of the port changed. For + * example, someone may have plugged a + * device in. The status parameter + * contains CVMX_USB_COMPLETE_SUCCESS. Use + * cvmx_usb_get_status() to get the new + * port status. + * @__CVMX_USB_CALLBACK_END: Do not use. Used internally for array + * bounds. */ -typedef enum -{ - CVMX_USB_CALLBACK_TRANSFER_COMPLETE, - /**< A callback of this type is called when a submitted transfer - completes. The completion callback will be called even if the - transfer fails or is canceled. The status parameter will - contain details of why he callback was called. */ - CVMX_USB_CALLBACK_PORT_CHANGED, /**< The status of the port changed. For example, someone may have - plugged a device in. The status parameter contains - CVMX_USB_COMPLETE_SUCCESS. Use cvmx_usb_get_status() to get - the new port status. */ - __CVMX_USB_CALLBACK_END /**< Do not use. Used internally for array bounds */ -} cvmx_usb_callback_t; +enum cvmx_usb_callback { + CVMX_USB_CALLBACK_TRANSFER_COMPLETE, + CVMX_USB_CALLBACK_PORT_CHANGED, + __CVMX_USB_CALLBACK_END +}; /** * USB state internal data. The contents of this structure @@ -381,7 +388,7 @@ typedef struct * The parameters are as follows: * - state = USB device state populated by * cvmx_usb_initialize(). - * - reason = The cvmx_usb_callback_t used to register + * - reason = The enum cvmx_usb_callback used to register * the callback. * - status = The enum cvmx_usb_complete representing the * status code of a transaction. @@ -395,7 +402,7 @@ typedef struct * function cvmx_usb_submit() or * cvmx_usb_register_callback() */ typedef void (*cvmx_usb_callback_func_t)(cvmx_usb_state_t *state, - cvmx_usb_callback_t reason, + enum cvmx_usb_callback reason, enum cvmx_usb_complete status, int pipe_handle, int submit_handle, int bytes_transferred, void *user_data); @@ -481,7 +488,7 @@ extern int cvmx_usb_cancel(cvmx_usb_state_t *state, int pipe_handle, extern int cvmx_usb_cancel_all(cvmx_usb_state_t *state, int pipe_handle); extern int cvmx_usb_close_pipe(cvmx_usb_state_t *state, int pipe_handle); extern int cvmx_usb_register_callback(cvmx_usb_state_t *state, - cvmx_usb_callback_t reason, + enum cvmx_usb_callback reason, cvmx_usb_callback_func_t callback, void *user_data); extern int cvmx_usb_get_frame_number(cvmx_usb_state_t *state); diff --git a/drivers/staging/octeon-usb/octeon-hcd.c b/drivers/staging/octeon-usb/octeon-hcd.c index b3c287394e07c..5137da74c2b27 100644 --- a/drivers/staging/octeon-usb/octeon-hcd.c +++ b/drivers/staging/octeon-usb/octeon-hcd.c @@ -59,7 +59,7 @@ static irqreturn_t octeon_usb_irq(struct usb_hcd *hcd) } static void octeon_usb_port_callback(cvmx_usb_state_t *usb, - cvmx_usb_callback_t reason, + enum cvmx_usb_callback reason, enum cvmx_usb_complete status, int pipe_handle, int submit_handle, @@ -106,7 +106,7 @@ static int octeon_usb_get_frame_number(struct usb_hcd *hcd) } static void octeon_usb_urb_complete_callback(cvmx_usb_state_t *usb, - cvmx_usb_callback_t reason, + enum cvmx_usb_callback reason, enum cvmx_usb_complete status, int pipe_handle, int submit_handle, -- GitLab From 1c25754815e6ff06048afb1104754b016acc4202 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 30 Jul 2013 23:42:58 +0300 Subject: [PATCH 421/942] staging: octeon-usb: cvmx_usb_initialize_flags_t -> enum cvmx_usb_initialize_flags Replace cvmx_usb_initialize_flags_t with enum cvmx_usb_initialize_flags. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/cvmx-usb.c | 4 +-- drivers/staging/octeon-usb/cvmx-usb.h | 47 +++++++++++++++++---------- 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/drivers/staging/octeon-usb/cvmx-usb.c b/drivers/staging/octeon-usb/cvmx-usb.c index 9e4bf7194ac73..3993e3c4b8cca 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.c +++ b/drivers/staging/octeon-usb/cvmx-usb.c @@ -486,13 +486,13 @@ static inline void __cvmx_usb_remove_pipe(cvmx_usb_pipe_list_t *list, cvmx_usb_p * @usb_port_number: * Which Octeon USB port to initialize. * @flags: Flags to control hardware initialization. See - * cvmx_usb_initialize_flags_t for the flag + * enum cvmx_usb_initialize_flags for the flag * definitions. Some flags are mandatory. * * Returns: 0 or a negative error code. */ int cvmx_usb_initialize(cvmx_usb_state_t *state, int usb_port_number, - cvmx_usb_initialize_flags_t flags) + enum cvmx_usb_initialize_flags flags) { cvmx_usbnx_clk_ctl_t usbn_clk_ctl; cvmx_usbnx_usbp_ctl_status_t usbn_usbp_ctl_status; diff --git a/drivers/staging/octeon-usb/cvmx-usb.h b/drivers/staging/octeon-usb/cvmx-usb.h index 7e1e2986d9538..8c46ebd15bfd0 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.h +++ b/drivers/staging/octeon-usb/cvmx-usb.h @@ -408,23 +408,36 @@ typedef void (*cvmx_usb_callback_func_t)(cvmx_usb_state_t *state, int bytes_transferred, void *user_data); /** - * Flags to pass the initialization function. + * enum cvmx_usb_initialize_flags - flags to pass the initialization function + * + * @CVMX_USB_INITIALIZE_FLAGS_CLOCK_XO_XI: The USB port uses a 12MHz crystal + * as clock source at USB_XO and + * USB_XI. + * @CVMX_USB_INITIALIZE_FLAGS_CLOCK_XO_GND: The USB port uses 12/24/48MHz 2.5V + * board clock source at USB_XO. + * USB_XI should be tied to GND. + * @CVMX_USB_INITIALIZE_FLAGS_CLOCK_AUTO: Automatically determine clock type + * based on function in + * cvmx-helper-board.c. + * @CVMX_USB_INITIALIZE_FLAGS_CLOCK_MHZ_MASK: Mask for clock speed field + * @CVMX_USB_INITIALIZE_FLAGS_CLOCK_12MHZ: Speed of reference clock or + * crystal + * @CVMX_USB_INITIALIZE_FLAGS_CLOCK_24MHZ: Speed of reference clock + * @CVMX_USB_INITIALIZE_FLAGS_CLOCK_48MHZ: Speed of reference clock + * @CVMX_USB_INITIALIZE_FLAGS_NO_DMA: Disable DMA and used polled IO for + * data transfer use for the USB */ -typedef enum -{ - CVMX_USB_INITIALIZE_FLAGS_CLOCK_XO_XI = 1<<0, /**< The USB port uses a 12MHz crystal as clock source - at USB_XO and USB_XI. */ - CVMX_USB_INITIALIZE_FLAGS_CLOCK_XO_GND = 1<<1, /**< The USB port uses 12/24/48MHz 2.5V board clock - source at USB_XO. USB_XI should be tied to GND.*/ - CVMX_USB_INITIALIZE_FLAGS_CLOCK_AUTO = 0, /**< Automatically determine clock type based on function - in cvmx-helper-board.c. */ - CVMX_USB_INITIALIZE_FLAGS_CLOCK_MHZ_MASK = 3<<3, /**< Mask for clock speed field */ - CVMX_USB_INITIALIZE_FLAGS_CLOCK_12MHZ = 1<<3, /**< Speed of reference clock or crystal */ - CVMX_USB_INITIALIZE_FLAGS_CLOCK_24MHZ = 2<<3, /**< Speed of reference clock */ - CVMX_USB_INITIALIZE_FLAGS_CLOCK_48MHZ = 3<<3, /**< Speed of reference clock */ - /* Bits 3-4 used to encode the clock frequency */ - CVMX_USB_INITIALIZE_FLAGS_NO_DMA = 1<<5, /**< Disable DMA and used polled IO for data transfer use for the USB */ -} cvmx_usb_initialize_flags_t; +enum cvmx_usb_initialize_flags { + CVMX_USB_INITIALIZE_FLAGS_CLOCK_XO_XI = 1 << 0, + CVMX_USB_INITIALIZE_FLAGS_CLOCK_XO_GND = 1 << 1, + CVMX_USB_INITIALIZE_FLAGS_CLOCK_AUTO = 0, + CVMX_USB_INITIALIZE_FLAGS_CLOCK_MHZ_MASK = 3 << 3, + CVMX_USB_INITIALIZE_FLAGS_CLOCK_12MHZ = 1 << 3, + CVMX_USB_INITIALIZE_FLAGS_CLOCK_24MHZ = 2 << 3, + CVMX_USB_INITIALIZE_FLAGS_CLOCK_48MHZ = 3 << 3, + /* Bits 3-4 used to encode the clock frequency */ + CVMX_USB_INITIALIZE_FLAGS_NO_DMA = 1 << 5, +}; /** * Flags for passing when a pipe is created. Currently no flags @@ -439,7 +452,7 @@ typedef enum extern int cvmx_usb_get_num_ports(void); extern int cvmx_usb_initialize(cvmx_usb_state_t *state, int usb_port_number, - cvmx_usb_initialize_flags_t flags); + enum cvmx_usb_initialize_flags flags); extern int cvmx_usb_shutdown(cvmx_usb_state_t *state); extern int cvmx_usb_enable(cvmx_usb_state_t *state); extern int cvmx_usb_disable(cvmx_usb_state_t *state); -- GitLab From 3f937c51b4115c4943d76255591806d86f04a6c9 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 30 Jul 2013 23:42:59 +0300 Subject: [PATCH 422/942] staging: octeon-usb: cvmx_usb_pipe_flags_t -> enum cvmx_usb_pipe_flags Replace cvmx_usb_pipe_flags_t with enum cvmx_usb_pipe_flags. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/cvmx-usb.c | 6 +++--- drivers/staging/octeon-usb/cvmx-usb.h | 25 ++++++++++++++++--------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/drivers/staging/octeon-usb/cvmx-usb.c b/drivers/staging/octeon-usb/cvmx-usb.c index 3993e3c4b8cca..a77d9308b987c 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.c +++ b/drivers/staging/octeon-usb/cvmx-usb.c @@ -150,7 +150,7 @@ typedef struct cvmx_usb_pipe { cvmx_usb_transaction_t *tail; /**< The last pending transaction */ uint64_t interval; /**< For periodic pipes, the interval between packets in frames */ uint64_t next_tx_frame; /**< The next frame this pipe is allowed to transmit on */ - cvmx_usb_pipe_flags_t flags; /**< State flags for this pipe */ + enum cvmx_usb_pipe_flags flags; /**< State flags for this pipe */ enum cvmx_usb_speed device_speed; /**< Speed of device connected to this pipe */ enum cvmx_usb_transfer transfer_type; /**< Type of transaction supported by this pipe */ enum cvmx_usb_direction transfer_dir; /**< IN or OUT. Ignored for Control */ @@ -1053,7 +1053,7 @@ static inline int __cvmx_usb_get_pipe_handle(cvmx_usb_internal_state_t *usb, * @state: USB device state populated by * cvmx_usb_initialize(). * @flags: Optional pipe flags defined in - * cvmx_usb_pipe_flags_t. + * enum cvmx_usb_pipe_flags. * @device_addr: * USB device address to open the pipe to * (0-127). @@ -1101,7 +1101,7 @@ static inline int __cvmx_usb_get_pipe_handle(cvmx_usb_internal_state_t *usb, * Returns: A non negative value is a pipe handle. Negative * values are error codes. */ -int cvmx_usb_open_pipe(cvmx_usb_state_t *state, cvmx_usb_pipe_flags_t flags, +int cvmx_usb_open_pipe(cvmx_usb_state_t *state, enum cvmx_usb_pipe_flags flags, int device_addr, int endpoint_num, enum cvmx_usb_speed device_speed, int max_packet, enum cvmx_usb_transfer transfer_type, diff --git a/drivers/staging/octeon-usb/cvmx-usb.h b/drivers/staging/octeon-usb/cvmx-usb.h index 8c46ebd15bfd0..6c404b0882d73 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.h +++ b/drivers/staging/octeon-usb/cvmx-usb.h @@ -440,15 +440,22 @@ enum cvmx_usb_initialize_flags { }; /** - * Flags for passing when a pipe is created. Currently no flags - * need to be passed. + * enum cvmx_usb_pipe_flags - flags for passing when a pipe is created. + * Currently no flags need to be passed. + * + * @__CVMX_USB_PIPE_FLAGS_OPEN: Used internally to determine if a pipe is + * open. Do not use. + * @__CVMX_USB_PIPE_FLAGS_SCHEDULED: Used internally to determine if a pipe is + * actively using hardware. Do not use. + * @__CVMX_USB_PIPE_FLAGS_NEED_PING: Used internally to determine if a high + * speed pipe is in the ping state. Do not + * use. */ -typedef enum -{ - __CVMX_USB_PIPE_FLAGS_OPEN = 1<<16, /**< Used internally to determine if a pipe is open. Do not use */ - __CVMX_USB_PIPE_FLAGS_SCHEDULED = 1<<17, /**< Used internally to determine if a pipe is actively using hardware. Do not use */ - __CVMX_USB_PIPE_FLAGS_NEED_PING = 1<<18, /**< Used internally to determine if a high speed pipe is in the ping state. Do not use */ -} cvmx_usb_pipe_flags_t; +enum cvmx_usb_pipe_flags { + __CVMX_USB_PIPE_FLAGS_OPEN = 1 << 16, + __CVMX_USB_PIPE_FLAGS_SCHEDULED = 1 << 17, + __CVMX_USB_PIPE_FLAGS_NEED_PING = 1 << 18, +}; extern int cvmx_usb_get_num_ports(void); extern int cvmx_usb_initialize(cvmx_usb_state_t *state, int usb_port_number, @@ -459,7 +466,7 @@ extern int cvmx_usb_disable(cvmx_usb_state_t *state); extern cvmx_usb_port_status_t cvmx_usb_get_status(cvmx_usb_state_t *state); extern void cvmx_usb_set_status(cvmx_usb_state_t *state, cvmx_usb_port_status_t port_status); extern int cvmx_usb_open_pipe(cvmx_usb_state_t *state, - cvmx_usb_pipe_flags_t flags, + enum cvmx_usb_pipe_flags flags, int device_addr, int endpoint_num, enum cvmx_usb_speed device_speed, int max_packet, enum cvmx_usb_transfer transfer_type, -- GitLab From ff9a3e3982535c73d91209b0d26fff76852b784f Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 30 Jul 2013 23:43:00 +0300 Subject: [PATCH 423/942] staging: octeon-usb: cvmx_usb_isochronous_flags_t -> enum cvmx_usb_isochronous_flags Replace cvmx_usb_isochronous_flags_t with enum cvmx_usb_isochronous_flags. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/cvmx-usb.c | 2 +- drivers/staging/octeon-usb/cvmx-usb.h | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/staging/octeon-usb/cvmx-usb.c b/drivers/staging/octeon-usb/cvmx-usb.c index a77d9308b987c..2d9474aab979e 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.c +++ b/drivers/staging/octeon-usb/cvmx-usb.c @@ -2291,7 +2291,7 @@ int cvmx_usb_submit_control(cvmx_usb_state_t *state, int pipe_handle, * Number of frames into the future to schedule * this transaction. * @flags: Flags to control the transfer. See - * cvmx_usb_isochronous_flags_t for the flag + * enum cvmx_usb_isochronous_flags for the flag * definitions. * @number_packets: * Number of sequential packets to transfer. diff --git a/drivers/staging/octeon-usb/cvmx-usb.h b/drivers/staging/octeon-usb/cvmx-usb.h index 6c404b0882d73..cf49b13a806b4 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.h +++ b/drivers/staging/octeon-usb/cvmx-usb.h @@ -488,13 +488,19 @@ extern int cvmx_usb_submit_control(cvmx_usb_state_t *state, int pipe_handle, void *user_data); /** - * Flags to pass the cvmx_usb_submit_isochronous() function. + * enum cvmx_usb_isochronous_flags - flags to pass the + * cvmx_usb_submit_isochronous() function. + * + * @CVMX_USB_ISOCHRONOUS_FLAGS_ALLOW_SHORT: Do not return an error if a transfer + * is less than the maximum packet size + * of the device. + * @CVMX_USB_ISOCHRONOUS_FLAGS_ASAP: Schedule the transaction as soon as + * possible. */ -typedef enum -{ - CVMX_USB_ISOCHRONOUS_FLAGS_ALLOW_SHORT = 1<<0, /**< Do not return an error if a transfer is less than the maximum packet size of the device */ - CVMX_USB_ISOCHRONOUS_FLAGS_ASAP = 1<<1, /**< Schedule the transaction as soon as possible */ -} cvmx_usb_isochronous_flags_t; +enum cvmx_usb_isochronous_flags { + CVMX_USB_ISOCHRONOUS_FLAGS_ALLOW_SHORT = 1 << 0, + CVMX_USB_ISOCHRONOUS_FLAGS_ASAP = 1 << 1, +}; extern int cvmx_usb_submit_isochronous(cvmx_usb_state_t *state, int pipe_handle, int start_frame, int flags, -- GitLab From 4f1d6ba901151b5c56babbb544546ebb7a9e0308 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 30 Jul 2013 23:43:01 +0300 Subject: [PATCH 424/942] staging: octeon-usb: cvmx_usb_transaction_flags_t -> enum cvmx_usb_transaction_flags Replace cvmx_usb_transaction_flags_t with enum cvmx_usb_transaction_flags. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/cvmx-usb.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/octeon-usb/cvmx-usb.c b/drivers/staging/octeon-usb/cvmx-usb.c index 2d9474aab979e..b8af45da1c45d 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.c +++ b/drivers/staging/octeon-usb/cvmx-usb.c @@ -84,9 +84,9 @@ #define cvmx_read_csr use_cvmx_usb_read_csr64_instead_of_cvmx_read_csr #define cvmx_write_csr use_cvmx_usb_write_csr64_instead_of_cvmx_write_csr -typedef enum { +enum cvmx_usb_transaction_flags { __CVMX_USB_TRANSACTION_FLAGS_IN_USE = 1<<16, -} cvmx_usb_transaction_flags_t; +}; enum { USB_CLOCK_TYPE_REF_12, @@ -123,7 +123,7 @@ typedef struct cvmx_usb_transaction { struct cvmx_usb_transaction *prev; /**< Transaction before this one in the pipe */ struct cvmx_usb_transaction *next; /**< Transaction after this one in the pipe */ enum cvmx_usb_transfer type; /**< Type of transaction, duplicated of the pipe */ - cvmx_usb_transaction_flags_t flags; /**< State flags for this transaction */ + enum cvmx_usb_transaction_flags flags; /**< State flags for this transaction */ uint64_t buffer; /**< User's physical buffer address to read/write */ int buffer_length; /**< Size of the user's buffer in bytes */ uint64_t control_header; /**< For control transactions, physical address of the 8 byte standard header */ -- GitLab From 03f9adf44cef7423fa9493b3abc2f2d764157481 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 30 Jul 2013 23:43:02 +0300 Subject: [PATCH 425/942] staging: octeon-usb: cvmx_usb_stage_t -> enum cvmx_usb_stage Replace cvmx_usb_stage_t with enum cvmx_usb_stage. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/cvmx-usb.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/octeon-usb/cvmx-usb.c b/drivers/staging/octeon-usb/cvmx-usb.c index b8af45da1c45d..f5918979abd1f 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.c +++ b/drivers/staging/octeon-usb/cvmx-usb.c @@ -103,7 +103,7 @@ enum { * the NAK handler can backup to the previous low level * transaction with a simple clearing of bit 0. */ -typedef enum { +enum cvmx_usb_stage { CVMX_USB_STAGE_NON_CONTROL, CVMX_USB_STAGE_NON_CONTROL_SPLIT_COMPLETE, CVMX_USB_STAGE_SETUP, @@ -112,7 +112,7 @@ typedef enum { CVMX_USB_STAGE_DATA_SPLIT_COMPLETE, CVMX_USB_STAGE_STATUS, CVMX_USB_STAGE_STATUS_SPLIT_COMPLETE, -} cvmx_usb_stage_t; +}; /** * This structure describes each pending USB transaction @@ -134,7 +134,7 @@ typedef struct cvmx_usb_transaction { int pktcnt; int retries; int actual_bytes; /**< Actual bytes transfer for this transaction */ - cvmx_usb_stage_t stage; /**< For control transactions, the current stage */ + enum cvmx_usb_stage stage; /**< For control transactions, the current stage */ cvmx_usb_callback_func_t callback; /**< User's callback function when complete */ void *callback_data; /**< User's data */ } cvmx_usb_transaction_t; -- GitLab From 51a19621ccb10191915220de8d2ec69bcb9862ac Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 30 Jul 2013 23:43:03 +0300 Subject: [PATCH 426/942] staging: octeon-usb: cvmx_usb_port_status_t -> struct cvmx_usb_port_status Replace cvmx_usb_port_status_t with struct cvmx_usb_port_status. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/cvmx-usb.c | 10 +++---- drivers/staging/octeon-usb/cvmx-usb.h | 37 ++++++++++++++++--------- drivers/staging/octeon-usb/octeon-hcd.c | 4 +-- 3 files changed, 31 insertions(+), 20 deletions(-) diff --git a/drivers/staging/octeon-usb/cvmx-usb.c b/drivers/staging/octeon-usb/cvmx-usb.c index f5918979abd1f..c92b15f30feac 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.c +++ b/drivers/staging/octeon-usb/cvmx-usb.c @@ -196,7 +196,7 @@ typedef struct { cvmx_usb_callback_func_t callback[__CVMX_USB_CALLBACK_END]; /**< User global callbacks */ void *callback_data[__CVMX_USB_CALLBACK_END]; /**< User data for each callback */ int indent; /**< Used by debug output to indent functions */ - cvmx_usb_port_status_t port_status; /**< Last port status used for change notification */ + struct cvmx_usb_port_status port_status; /**< Last port status used for change notification */ cvmx_usb_pipe_list_t free_pipes; /**< List of all pipes that are currently closed */ cvmx_usb_pipe_list_t idle_pipes; /**< List of open pipes that have no transactions */ cvmx_usb_pipe_list_t active_pipes[4]; /**< Active pipes indexed by transfer type */ @@ -971,10 +971,10 @@ int cvmx_usb_disable(cvmx_usb_state_t *state) * * Returns: Port status information */ -cvmx_usb_port_status_t cvmx_usb_get_status(cvmx_usb_state_t *state) +struct cvmx_usb_port_status cvmx_usb_get_status(cvmx_usb_state_t *state) { cvmx_usbcx_hprt_t usbc_hprt; - cvmx_usb_port_status_t result; + struct cvmx_usb_port_status result; cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; memset(&result, 0, sizeof(result)); @@ -1003,7 +1003,7 @@ cvmx_usb_port_status_t cvmx_usb_get_status(cvmx_usb_state_t *state) * @port_status: * Port status to set, most like returned by cvmx_usb_get_status() */ -void cvmx_usb_set_status(cvmx_usb_state_t *state, cvmx_usb_port_status_t port_status) +void cvmx_usb_set_status(cvmx_usb_state_t *state, struct cvmx_usb_port_status port_status) { cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; usb->port_status = port_status; @@ -2964,7 +2964,7 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel) pipe->next_tx_frame = usb->frame_number + pipe->interval - (usb->frame_number - pipe->next_tx_frame) % pipe->interval; } else { - cvmx_usb_port_status_t port; + struct cvmx_usb_port_status port; port = cvmx_usb_get_status((cvmx_usb_state_t *)usb); if (port.port_enabled) { /* We'll retry the exact same transaction again */ diff --git a/drivers/staging/octeon-usb/cvmx-usb.h b/drivers/staging/octeon-usb/cvmx-usb.h index cf49b13a806b4..9c7ff4a6c52e4 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.h +++ b/drivers/staging/octeon-usb/cvmx-usb.h @@ -310,18 +310,29 @@ enum cvmx_usb_complete { }; /** - * Structure returned containing the USB port status information. + * struct cvmx_usb_port_status - the USB port status information + * + * @port_enabled: 1 = Usb port is enabled, 0 = disabled + * @port_over_current: 1 = Over current detected, 0 = Over current not + * detected. Octeon doesn't support over current detection. + * @port_powered: 1 = Port power is being supplied to the device, 0 = + * power is off. Octeon doesn't support turning port power + * off. + * @port_speed: Current port speed. + * @connected: 1 = A device is connected to the port, 0 = No device is + * connected. + * @connect_change: 1 = Device connected state changed since the last set + * status call. */ -typedef struct -{ - uint32_t reserved : 25; - uint32_t port_enabled : 1; /**< 1 = Usb port is enabled, 0 = disabled */ - uint32_t port_over_current : 1; /**< 1 = Over current detected, 0 = Over current not detected. Octeon doesn't support over current detection */ - uint32_t port_powered : 1; /**< 1 = Port power is being supplied to the device, 0 = power is off. Octeon doesn't support turning port power off */ - enum cvmx_usb_speed port_speed : 2; /**< Current port speed */ - uint32_t connected : 1; /**< 1 = A device is connected to the port, 0 = No device is connected */ - uint32_t connect_change : 1; /**< 1 = Device connected state changed since the last set status call */ -} cvmx_usb_port_status_t; +struct cvmx_usb_port_status { + uint32_t reserved : 25; + uint32_t port_enabled : 1; + uint32_t port_over_current : 1; + uint32_t port_powered : 1; + enum cvmx_usb_speed port_speed : 2; + uint32_t connected : 1; + uint32_t connect_change : 1; +}; /** * This is the structure of a Control packet header @@ -463,8 +474,8 @@ extern int cvmx_usb_initialize(cvmx_usb_state_t *state, int usb_port_number, extern int cvmx_usb_shutdown(cvmx_usb_state_t *state); extern int cvmx_usb_enable(cvmx_usb_state_t *state); extern int cvmx_usb_disable(cvmx_usb_state_t *state); -extern cvmx_usb_port_status_t cvmx_usb_get_status(cvmx_usb_state_t *state); -extern void cvmx_usb_set_status(cvmx_usb_state_t *state, cvmx_usb_port_status_t port_status); +extern struct cvmx_usb_port_status cvmx_usb_get_status(cvmx_usb_state_t *state); +extern void cvmx_usb_set_status(cvmx_usb_state_t *state, struct cvmx_usb_port_status port_status); extern int cvmx_usb_open_pipe(cvmx_usb_state_t *state, enum cvmx_usb_pipe_flags flags, int device_addr, int endpoint_num, diff --git a/drivers/staging/octeon-usb/octeon-hcd.c b/drivers/staging/octeon-usb/octeon-hcd.c index 5137da74c2b27..8a41d092b08b3 100644 --- a/drivers/staging/octeon-usb/octeon-hcd.c +++ b/drivers/staging/octeon-usb/octeon-hcd.c @@ -440,7 +440,7 @@ static void octeon_usb_endpoint_disable(struct usb_hcd *hcd, struct usb_host_end static int octeon_usb_hub_status_data(struct usb_hcd *hcd, char *buf) { struct octeon_hcd *priv = hcd_to_octeon(hcd); - cvmx_usb_port_status_t port_status; + struct cvmx_usb_port_status port_status; unsigned long flags; spin_lock_irqsave(&priv->lock, flags); @@ -456,7 +456,7 @@ static int octeon_usb_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, { struct octeon_hcd *priv = hcd_to_octeon(hcd); struct device *dev = hcd->self.controller; - cvmx_usb_port_status_t usb_port_status; + struct cvmx_usb_port_status usb_port_status; int port_status; struct usb_hub_descriptor *desc; unsigned long flags; -- GitLab From 6e0e1b006993e0a4e2d39421d7adbe1ad92b7cbf Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 30 Jul 2013 23:43:04 +0300 Subject: [PATCH 427/942] staging: octeon-usb: cvmx_usb_iso_packet_t -> struct cvmx_usb_iso_packet Replace cvmx_usb_iso_packet_t with struct cvmx_usb_iso_packet. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/cvmx-usb.c | 8 ++++---- drivers/staging/octeon-usb/cvmx-usb.h | 20 ++++++++++++-------- drivers/staging/octeon-usb/octeon-hcd.c | 9 ++++++--- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/drivers/staging/octeon-usb/cvmx-usb.c b/drivers/staging/octeon-usb/cvmx-usb.c index c92b15f30feac..6c79cc15b5168 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.c +++ b/drivers/staging/octeon-usb/cvmx-usb.c @@ -129,7 +129,7 @@ typedef struct cvmx_usb_transaction { uint64_t control_header; /**< For control transactions, physical address of the 8 byte standard header */ int iso_start_frame; /**< For ISO transactions, the starting frame number */ int iso_number_packets; /**< For ISO transactions, the number of packets in the request */ - cvmx_usb_iso_packet_t *iso_packets; /**< For ISO transactions, the sub packets in the request */ + struct cvmx_usb_iso_packet *iso_packets;/**< For ISO transactions, the sub packets in the request */ int xfersize; int pktcnt; int retries; @@ -2032,7 +2032,7 @@ static int __cvmx_usb_submit_transaction(cvmx_usb_internal_state_t *usb, uint64_t control_header, int iso_start_frame, int iso_number_packets, - cvmx_usb_iso_packet_t *iso_packets, + struct cvmx_usb_iso_packet *iso_packets, cvmx_usb_callback_func_t callback, void *user_data) { @@ -2298,7 +2298,7 @@ int cvmx_usb_submit_control(cvmx_usb_state_t *state, int pipe_handle, * "packets" is a pointer to an array of this * many packet structures. * @packets: Description of each transfer packet as - * defined by cvmx_usb_iso_packet_t. The array + * defined by struct cvmx_usb_iso_packet. The array * pointed to here must stay valid until the * complete callback is called. * @buffer: Physical address of the data buffer in @@ -2327,7 +2327,7 @@ int cvmx_usb_submit_control(cvmx_usb_state_t *state, int pipe_handle, int cvmx_usb_submit_isochronous(cvmx_usb_state_t *state, int pipe_handle, int start_frame, int flags, int number_packets, - cvmx_usb_iso_packet_t packets[], + struct cvmx_usb_iso_packet packets[], uint64_t buffer, int buffer_length, cvmx_usb_callback_func_t callback, void *user_data) diff --git a/drivers/staging/octeon-usb/cvmx-usb.h b/drivers/staging/octeon-usb/cvmx-usb.h index 9c7ff4a6c52e4..b0d0f6aab5d16 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.h +++ b/drivers/staging/octeon-usb/cvmx-usb.h @@ -351,14 +351,18 @@ typedef union } cvmx_usb_control_header_t; /** - * Descriptor for Isochronous packets + * struct cvmx_usb_iso_packet - descriptor for Isochronous packets + * + * @offset: This is the offset in bytes into the main buffer where this data + * is stored. + * @length: This is the length in bytes of the data. + * @status: This is the status of this individual packet transfer. */ -typedef struct -{ - int offset; /**< This is the offset in bytes into the main buffer where this data is stored */ - int length; /**< This is the length in bytes of the data */ - enum cvmx_usb_complete status; /**< This is the status of this individual packet transfer */ -} cvmx_usb_iso_packet_t; +struct cvmx_usb_iso_packet { + int offset; + int length; + enum cvmx_usb_complete status; +}; /** * enum cvmx_usb_callback - possible callback reasons for the USB API @@ -516,7 +520,7 @@ enum cvmx_usb_isochronous_flags { extern int cvmx_usb_submit_isochronous(cvmx_usb_state_t *state, int pipe_handle, int start_frame, int flags, int number_packets, - cvmx_usb_iso_packet_t packets[], + struct cvmx_usb_iso_packet packets[], uint64_t buffer, int buffer_length, cvmx_usb_callback_func_t callback, void *user_data); diff --git a/drivers/staging/octeon-usb/octeon-hcd.c b/drivers/staging/octeon-usb/octeon-hcd.c index 8a41d092b08b3..319f2e15662ad 100644 --- a/drivers/staging/octeon-usb/octeon-hcd.c +++ b/drivers/staging/octeon-usb/octeon-hcd.c @@ -141,7 +141,8 @@ static void octeon_usb_urb_complete_callback(cvmx_usb_state_t *usb, * The pointer to the private list is stored in the setup_packet * field. */ - cvmx_usb_iso_packet_t *iso_packet = (cvmx_usb_iso_packet_t *) urb->setup_packet; + struct cvmx_usb_iso_packet *iso_packet = + (struct cvmx_usb_iso_packet *) urb->setup_packet; /* Recalculate the transfer size by adding up each packet */ urb->actual_length = 0; for (i = 0; i < urb->number_of_packets; i++) { @@ -208,7 +209,7 @@ static int octeon_usb_urb_enqueue(struct usb_hcd *hcd, int submit_handle = -1; int pipe_handle; unsigned long flags; - cvmx_usb_iso_packet_t *iso_packet; + struct cvmx_usb_iso_packet *iso_packet; struct usb_host_endpoint *ep = urb->ep; urb->status = 0; @@ -305,7 +306,9 @@ static int octeon_usb_urb_enqueue(struct usb_hcd *hcd, * Allocate a structure to use for our private list of * isochronous packets. */ - iso_packet = kmalloc(urb->number_of_packets * sizeof(cvmx_usb_iso_packet_t), GFP_ATOMIC); + iso_packet = kmalloc(urb->number_of_packets * + sizeof(struct cvmx_usb_iso_packet), + GFP_ATOMIC); if (iso_packet) { int i; /* Fill the list with the data from the URB */ -- GitLab From a24ed35a19bd97e2803ad4fcc39732734d62fd93 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 30 Jul 2013 23:43:05 +0300 Subject: [PATCH 428/942] staging: octeon-usb: cvmx_usb_state_t -> struct cvmx_usb_state Replace cvmx_usb_state_t with struct cvmx_usb_state. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/cvmx-usb.c | 42 ++++++++++---------- drivers/staging/octeon-usb/cvmx-usb.h | 53 ++++++++++++------------- drivers/staging/octeon-usb/octeon-hcd.c | 8 ++-- 3 files changed, 51 insertions(+), 52 deletions(-) diff --git a/drivers/staging/octeon-usb/cvmx-usb.c b/drivers/staging/octeon-usb/cvmx-usb.c index 6c79cc15b5168..c7f7566048cf2 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.c +++ b/drivers/staging/octeon-usb/cvmx-usb.c @@ -358,7 +358,7 @@ static inline int __cvmx_usb_get_data_pid(cvmx_usb_pipe_t *pipe) * by this API, a zero will be returned. Most Octeon chips * support one usb port, but some support two ports. * cvmx_usb_initialize() must be called on independent - * cvmx_usb_state_t structures. + * struct cvmx_usb_state. * * Returns: Number of port, zero if usb isn't supported */ @@ -479,7 +479,7 @@ static inline void __cvmx_usb_remove_pipe(cvmx_usb_pipe_list_t *list, cvmx_usb_p * other access to the Octeon USB port is made. The port starts * off in the disabled state. * - * @state: Pointer to an empty cvmx_usb_state_t structure + * @state: Pointer to an empty struct cvmx_usb_state * that will be populated by the initialize call. * This structure is then passed to all other USB * functions. @@ -491,7 +491,7 @@ static inline void __cvmx_usb_remove_pipe(cvmx_usb_pipe_list_t *list, cvmx_usb_p * * Returns: 0 or a negative error code. */ -int cvmx_usb_initialize(cvmx_usb_state_t *state, int usb_port_number, +int cvmx_usb_initialize(struct cvmx_usb_state *state, int usb_port_number, enum cvmx_usb_initialize_flags flags) { cvmx_usbnx_clk_ctl_t usbn_clk_ctl; @@ -818,7 +818,7 @@ int cvmx_usb_initialize(cvmx_usb_state_t *state, int usb_port_number, * * Returns: 0 or a negative error code. */ -int cvmx_usb_shutdown(cvmx_usb_state_t *state) +int cvmx_usb_shutdown(struct cvmx_usb_state *state) { cvmx_usbnx_clk_ctl_t usbn_clk_ctl; cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; @@ -853,7 +853,7 @@ int cvmx_usb_shutdown(cvmx_usb_state_t *state) * * Returns: 0 or a negative error code. */ -int cvmx_usb_enable(cvmx_usb_state_t *state) +int cvmx_usb_enable(struct cvmx_usb_state *state) { cvmx_usbcx_ghwcfg3_t usbcx_ghwcfg3; cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; @@ -947,7 +947,7 @@ int cvmx_usb_enable(cvmx_usb_state_t *state) * * Returns: 0 or a negative error code. */ -int cvmx_usb_disable(cvmx_usb_state_t *state) +int cvmx_usb_disable(struct cvmx_usb_state *state) { cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; @@ -971,7 +971,7 @@ int cvmx_usb_disable(cvmx_usb_state_t *state) * * Returns: Port status information */ -struct cvmx_usb_port_status cvmx_usb_get_status(cvmx_usb_state_t *state) +struct cvmx_usb_port_status cvmx_usb_get_status(struct cvmx_usb_state *state) { cvmx_usbcx_hprt_t usbc_hprt; struct cvmx_usb_port_status result; @@ -1003,7 +1003,7 @@ struct cvmx_usb_port_status cvmx_usb_get_status(cvmx_usb_state_t *state) * @port_status: * Port status to set, most like returned by cvmx_usb_get_status() */ -void cvmx_usb_set_status(cvmx_usb_state_t *state, struct cvmx_usb_port_status port_status) +void cvmx_usb_set_status(struct cvmx_usb_state *state, struct cvmx_usb_port_status port_status) { cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; usb->port_status = port_status; @@ -1101,7 +1101,7 @@ static inline int __cvmx_usb_get_pipe_handle(cvmx_usb_internal_state_t *usb, * Returns: A non negative value is a pipe handle. Negative * values are error codes. */ -int cvmx_usb_open_pipe(cvmx_usb_state_t *state, enum cvmx_usb_pipe_flags flags, +int cvmx_usb_open_pipe(struct cvmx_usb_state *state, enum cvmx_usb_pipe_flags flags, int device_addr, int endpoint_num, enum cvmx_usb_speed device_speed, int max_packet, enum cvmx_usb_transfer transfer_type, @@ -1926,7 +1926,7 @@ static void __cvmx_usb_perform_callback(cvmx_usb_internal_state_t *usb, if (!callback) return; - callback((cvmx_usb_state_t *)usb, reason, complete_code, pipe_handle, submit_handle, + callback((struct cvmx_usb_state *)usb, reason, complete_code, pipe_handle, submit_handle, bytes_transferred, user_data); } @@ -2122,7 +2122,7 @@ static int __cvmx_usb_submit_transaction(cvmx_usb_internal_state_t *usb, * Returns: A submitted transaction handle or negative on * failure. Negative values are error codes. */ -int cvmx_usb_submit_bulk(cvmx_usb_state_t *state, int pipe_handle, +int cvmx_usb_submit_bulk(struct cvmx_usb_state *state, int pipe_handle, uint64_t buffer, int buffer_length, cvmx_usb_callback_func_t callback, void *user_data) @@ -2181,7 +2181,7 @@ int cvmx_usb_submit_bulk(cvmx_usb_state_t *state, int pipe_handle, * Returns: A submitted transaction handle or negative on * failure. Negative values are error codes. */ -int cvmx_usb_submit_interrupt(cvmx_usb_state_t *state, int pipe_handle, +int cvmx_usb_submit_interrupt(struct cvmx_usb_state *state, int pipe_handle, uint64_t buffer, int buffer_length, cvmx_usb_callback_func_t callback, void *user_data) @@ -2244,7 +2244,7 @@ int cvmx_usb_submit_interrupt(cvmx_usb_state_t *state, int pipe_handle, * Returns: A submitted transaction handle or negative on * failure. Negative values are error codes. */ -int cvmx_usb_submit_control(cvmx_usb_state_t *state, int pipe_handle, +int cvmx_usb_submit_control(struct cvmx_usb_state *state, int pipe_handle, uint64_t control_header, uint64_t buffer, int buffer_length, cvmx_usb_callback_func_t callback, @@ -2324,7 +2324,7 @@ int cvmx_usb_submit_control(cvmx_usb_state_t *state, int pipe_handle, * Returns: A submitted transaction handle or negative on * failure. Negative values are error codes. */ -int cvmx_usb_submit_isochronous(cvmx_usb_state_t *state, int pipe_handle, +int cvmx_usb_submit_isochronous(struct cvmx_usb_state *state, int pipe_handle, int start_frame, int flags, int number_packets, struct cvmx_usb_iso_packet packets[], @@ -2380,7 +2380,7 @@ int cvmx_usb_submit_isochronous(cvmx_usb_state_t *state, int pipe_handle, * * Returns: 0 or a negative error code. */ -int cvmx_usb_cancel(cvmx_usb_state_t *state, int pipe_handle, int submit_handle) +int cvmx_usb_cancel(struct cvmx_usb_state *state, int pipe_handle, int submit_handle) { cvmx_usb_transaction_t *transaction; cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; @@ -2437,7 +2437,7 @@ int cvmx_usb_cancel(cvmx_usb_state_t *state, int pipe_handle, int submit_handle) * * Returns: 0 or a negative error code. */ -int cvmx_usb_cancel_all(cvmx_usb_state_t *state, int pipe_handle) +int cvmx_usb_cancel_all(struct cvmx_usb_state *state, int pipe_handle) { cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; cvmx_usb_pipe_t *pipe = usb->pipe + pipe_handle; @@ -2471,7 +2471,7 @@ int cvmx_usb_cancel_all(cvmx_usb_state_t *state, int pipe_handle) * Returns: 0 or a negative error code. EBUSY is returned if the pipe has * outstanding transfers. */ -int cvmx_usb_close_pipe(cvmx_usb_state_t *state, int pipe_handle) +int cvmx_usb_close_pipe(struct cvmx_usb_state *state, int pipe_handle) { cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; cvmx_usb_pipe_t *pipe = usb->pipe + pipe_handle; @@ -2506,7 +2506,7 @@ int cvmx_usb_close_pipe(cvmx_usb_state_t *state, int pipe_handle) * * Returns: 0 or a negative error code. */ -int cvmx_usb_register_callback(cvmx_usb_state_t *state, +int cvmx_usb_register_callback(struct cvmx_usb_state *state, enum cvmx_usb_callback reason, cvmx_usb_callback_func_t callback, void *user_data) @@ -2534,7 +2534,7 @@ int cvmx_usb_register_callback(cvmx_usb_state_t *state, * * Returns: USB frame number */ -int cvmx_usb_get_frame_number(cvmx_usb_state_t *state) +int cvmx_usb_get_frame_number(struct cvmx_usb_state *state) { int frame_number; cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; @@ -2965,7 +2965,7 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel) (usb->frame_number - pipe->next_tx_frame) % pipe->interval; } else { struct cvmx_usb_port_status port; - port = cvmx_usb_get_status((cvmx_usb_state_t *)usb); + port = cvmx_usb_get_status((struct cvmx_usb_state *)usb); if (port.port_enabled) { /* We'll retry the exact same transaction again */ transaction->retries++; @@ -2992,7 +2992,7 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel) * * Returns: 0 or a negative error code. */ -int cvmx_usb_poll(cvmx_usb_state_t *state) +int cvmx_usb_poll(struct cvmx_usb_state *state) { cvmx_usbcx_hfnum_t usbc_hfnum; cvmx_usbcx_gintsts_t usbc_gintsts; diff --git a/drivers/staging/octeon-usb/cvmx-usb.h b/drivers/staging/octeon-usb/cvmx-usb.h index b0d0f6aab5d16..bd6a2fb07489c 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.h +++ b/drivers/staging/octeon-usb/cvmx-usb.h @@ -75,7 +75,7 @@ * In the probe phase you should: * - Use cvmx_usb_get_num_ports() to determine the number of * USB port to be supported. - * - Allocate space for a cvmx_usb_state_t structure for each + * - Allocate space for a struct cvmx_usb_state for each * port. * - Tell the operating system about each port * @@ -114,14 +114,14 @@ * * The port callback prototype needs to look as follows: * - * void port_callback(cvmx_usb_state_t *usb, + * void port_callback(struct cvmx_usb_state *usb, * enum cvmx_usb_callback reason, * enum cvmx_usb_complete status, * int pipe_handle, * int submit_handle, * int bytes_transferred, * void *user_data); - * - "usb" is the cvmx_usb_state_t for the port. + * - "usb" is the struct cvmx_usb_state for the port. * - "reason" will always be CVMX_USB_CALLBACK_PORT_CHANGED. * - "status" will always be CVMX_USB_COMPLETE_SUCCESS. * - "pipe_handle" will always be -1. @@ -146,14 +146,14 @@ * * The completion callback prototype needs to look as follows: * - * void complete_callback(cvmx_usb_state_t *usb, + * void complete_callback(struct cvmx_usb_state *usb, * enum cvmx_usb_callback reason, * enum cvmx_usb_complete status, * int pipe_handle, * int submit_handle, * int bytes_transferred, * void *user_data); - * - "usb" is the cvmx_usb_state_t for the port. + * - "usb" is the struct cvmx_usb_state for the port. * - "reason" will always be CVMX_USB_CALLBACK_TRANSFER_COMPLETE. * - "status" will be one of the cvmx_usb_complete enumerations. * - "pipe_handle" is the handle to the pipe the transaction @@ -393,10 +393,9 @@ enum cvmx_usb_callback { * may change in future SDKs. No data in it should be referenced * by user's of this API. */ -typedef struct -{ - char data[65536]; -} cvmx_usb_state_t; +struct cvmx_usb_state { + char data[65536]; +}; /** * USB callback functions are always of the following type. @@ -416,7 +415,7 @@ typedef struct * - user_data = The user pointer supplied to the * function cvmx_usb_submit() or * cvmx_usb_register_callback() */ -typedef void (*cvmx_usb_callback_func_t)(cvmx_usb_state_t *state, +typedef void (*cvmx_usb_callback_func_t)(struct cvmx_usb_state *state, enum cvmx_usb_callback reason, enum cvmx_usb_complete status, int pipe_handle, int submit_handle, @@ -473,14 +472,14 @@ enum cvmx_usb_pipe_flags { }; extern int cvmx_usb_get_num_ports(void); -extern int cvmx_usb_initialize(cvmx_usb_state_t *state, int usb_port_number, +extern int cvmx_usb_initialize(struct cvmx_usb_state *state, int usb_port_number, enum cvmx_usb_initialize_flags flags); -extern int cvmx_usb_shutdown(cvmx_usb_state_t *state); -extern int cvmx_usb_enable(cvmx_usb_state_t *state); -extern int cvmx_usb_disable(cvmx_usb_state_t *state); -extern struct cvmx_usb_port_status cvmx_usb_get_status(cvmx_usb_state_t *state); -extern void cvmx_usb_set_status(cvmx_usb_state_t *state, struct cvmx_usb_port_status port_status); -extern int cvmx_usb_open_pipe(cvmx_usb_state_t *state, +extern int cvmx_usb_shutdown(struct cvmx_usb_state *state); +extern int cvmx_usb_enable(struct cvmx_usb_state *state); +extern int cvmx_usb_disable(struct cvmx_usb_state *state); +extern struct cvmx_usb_port_status cvmx_usb_get_status(struct cvmx_usb_state *state); +extern void cvmx_usb_set_status(struct cvmx_usb_state *state, struct cvmx_usb_port_status port_status); +extern int cvmx_usb_open_pipe(struct cvmx_usb_state *state, enum cvmx_usb_pipe_flags flags, int device_addr, int endpoint_num, enum cvmx_usb_speed device_speed, int max_packet, @@ -488,15 +487,15 @@ extern int cvmx_usb_open_pipe(cvmx_usb_state_t *state, enum cvmx_usb_direction transfer_dir, int interval, int multi_count, int hub_device_addr, int hub_port); -extern int cvmx_usb_submit_bulk(cvmx_usb_state_t *state, int pipe_handle, +extern int cvmx_usb_submit_bulk(struct cvmx_usb_state *state, int pipe_handle, uint64_t buffer, int buffer_length, cvmx_usb_callback_func_t callback, void *user_data); -extern int cvmx_usb_submit_interrupt(cvmx_usb_state_t *state, int pipe_handle, +extern int cvmx_usb_submit_interrupt(struct cvmx_usb_state *state, int pipe_handle, uint64_t buffer, int buffer_length, cvmx_usb_callback_func_t callback, void *user_data); -extern int cvmx_usb_submit_control(cvmx_usb_state_t *state, int pipe_handle, +extern int cvmx_usb_submit_control(struct cvmx_usb_state *state, int pipe_handle, uint64_t control_header, uint64_t buffer, int buffer_length, cvmx_usb_callback_func_t callback, @@ -517,22 +516,22 @@ enum cvmx_usb_isochronous_flags { CVMX_USB_ISOCHRONOUS_FLAGS_ASAP = 1 << 1, }; -extern int cvmx_usb_submit_isochronous(cvmx_usb_state_t *state, int pipe_handle, +extern int cvmx_usb_submit_isochronous(struct cvmx_usb_state *state, int pipe_handle, int start_frame, int flags, int number_packets, struct cvmx_usb_iso_packet packets[], uint64_t buffer, int buffer_length, cvmx_usb_callback_func_t callback, void *user_data); -extern int cvmx_usb_cancel(cvmx_usb_state_t *state, int pipe_handle, +extern int cvmx_usb_cancel(struct cvmx_usb_state *state, int pipe_handle, int submit_handle); -extern int cvmx_usb_cancel_all(cvmx_usb_state_t *state, int pipe_handle); -extern int cvmx_usb_close_pipe(cvmx_usb_state_t *state, int pipe_handle); -extern int cvmx_usb_register_callback(cvmx_usb_state_t *state, +extern int cvmx_usb_cancel_all(struct cvmx_usb_state *state, int pipe_handle); +extern int cvmx_usb_close_pipe(struct cvmx_usb_state *state, int pipe_handle); +extern int cvmx_usb_register_callback(struct cvmx_usb_state *state, enum cvmx_usb_callback reason, cvmx_usb_callback_func_t callback, void *user_data); -extern int cvmx_usb_get_frame_number(cvmx_usb_state_t *state); -extern int cvmx_usb_poll(cvmx_usb_state_t *state); +extern int cvmx_usb_get_frame_number(struct cvmx_usb_state *state); +extern int cvmx_usb_poll(struct cvmx_usb_state *state); #endif /* __CVMX_USB_H__ */ diff --git a/drivers/staging/octeon-usb/octeon-hcd.c b/drivers/staging/octeon-usb/octeon-hcd.c index 319f2e15662ad..5dbbd14ec615a 100644 --- a/drivers/staging/octeon-usb/octeon-hcd.c +++ b/drivers/staging/octeon-usb/octeon-hcd.c @@ -26,7 +26,7 @@ struct octeon_hcd { spinlock_t lock; - cvmx_usb_state_t usb; + struct cvmx_usb_state usb; struct tasklet_struct dequeue_tasklet; struct list_head dequeue_list; }; @@ -42,7 +42,7 @@ static inline struct usb_hcd *octeon_to_hcd(struct octeon_hcd *p) return container_of((void *)p, struct usb_hcd, hcd_priv); } -static inline struct octeon_hcd *cvmx_usb_to_octeon(cvmx_usb_state_t *p) +static inline struct octeon_hcd *cvmx_usb_to_octeon(struct cvmx_usb_state *p) { return container_of(p, struct octeon_hcd, usb); } @@ -58,7 +58,7 @@ static irqreturn_t octeon_usb_irq(struct usb_hcd *hcd) return IRQ_HANDLED; } -static void octeon_usb_port_callback(cvmx_usb_state_t *usb, +static void octeon_usb_port_callback(struct cvmx_usb_state *usb, enum cvmx_usb_callback reason, enum cvmx_usb_complete status, int pipe_handle, @@ -105,7 +105,7 @@ static int octeon_usb_get_frame_number(struct usb_hcd *hcd) return cvmx_usb_get_frame_number(&priv->usb); } -static void octeon_usb_urb_complete_callback(cvmx_usb_state_t *usb, +static void octeon_usb_urb_complete_callback(struct cvmx_usb_state *usb, enum cvmx_usb_callback reason, enum cvmx_usb_complete status, int pipe_handle, -- GitLab From 48f61f832d6b369bf2d6d790ad7073cc19507045 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 30 Jul 2013 23:43:06 +0300 Subject: [PATCH 429/942] staging: octeon-usb: cvmx_usb_transaction_t -> struct cvmx_usb_transaction Replace cvmx_usb_transaction_t with struct cvmx_usb_transaction. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/cvmx-usb.c | 89 ++++++++++++++++----------- 1 file changed, 53 insertions(+), 36 deletions(-) diff --git a/drivers/staging/octeon-usb/cvmx-usb.c b/drivers/staging/octeon-usb/cvmx-usb.c index c7f7566048cf2..beb3963dd5e69 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.c +++ b/drivers/staging/octeon-usb/cvmx-usb.c @@ -115,29 +115,46 @@ enum cvmx_usb_stage { }; /** - * This structure describes each pending USB transaction - * regardless of type. These are linked together to form a list - * of pending requests for a pipe. + * struct cvmx_usb_transaction - describes each pending USB transaction + * regardless of type. These are linked together + * to form a list of pending requests for a pipe. + * + * @prev: Transaction before this one in the pipe. + * @next: Transaction after this one in the pipe. + * @type: Type of transaction, duplicated of the pipe. + * @flags: State flags for this transaction. + * @buffer: User's physical buffer address to read/write. + * @buffer_length: Size of the user's buffer in bytes. + * @control_header: For control transactions, physical address of the 8 + * byte standard header. + * @iso_start_frame: For ISO transactions, the starting frame number. + * @iso_number_packets: For ISO transactions, the number of packets in the + * request. + * @iso_packets: For ISO transactions, the sub packets in the request. + * @actual_bytes: Actual bytes transfer for this transaction. + * @stage: For control transactions, the current stage. + * @callback: User's callback function when complete. + * @callback_data: User's data. */ -typedef struct cvmx_usb_transaction { - struct cvmx_usb_transaction *prev; /**< Transaction before this one in the pipe */ - struct cvmx_usb_transaction *next; /**< Transaction after this one in the pipe */ - enum cvmx_usb_transfer type; /**< Type of transaction, duplicated of the pipe */ - enum cvmx_usb_transaction_flags flags; /**< State flags for this transaction */ - uint64_t buffer; /**< User's physical buffer address to read/write */ - int buffer_length; /**< Size of the user's buffer in bytes */ - uint64_t control_header; /**< For control transactions, physical address of the 8 byte standard header */ - int iso_start_frame; /**< For ISO transactions, the starting frame number */ - int iso_number_packets; /**< For ISO transactions, the number of packets in the request */ - struct cvmx_usb_iso_packet *iso_packets;/**< For ISO transactions, the sub packets in the request */ +struct cvmx_usb_transaction { + struct cvmx_usb_transaction *prev; + struct cvmx_usb_transaction *next; + enum cvmx_usb_transfer type; + enum cvmx_usb_transaction_flags flags; + uint64_t buffer; + int buffer_length; + uint64_t control_header; + int iso_start_frame; + int iso_number_packets; + struct cvmx_usb_iso_packet *iso_packets; int xfersize; int pktcnt; int retries; - int actual_bytes; /**< Actual bytes transfer for this transaction */ - enum cvmx_usb_stage stage; /**< For control transactions, the current stage */ - cvmx_usb_callback_func_t callback; /**< User's callback function when complete */ - void *callback_data; /**< User's data */ -} cvmx_usb_transaction_t; + int actual_bytes; + enum cvmx_usb_stage stage; + cvmx_usb_callback_func_t callback; + void *callback_data; +}; /** * A pipe represents a virtual connection between Octeon and some @@ -146,8 +163,8 @@ typedef struct cvmx_usb_transaction { typedef struct cvmx_usb_pipe { struct cvmx_usb_pipe *prev; /**< Pipe before this one in the list */ struct cvmx_usb_pipe *next; /**< Pipe after this one in the list */ - cvmx_usb_transaction_t *head; /**< The first pending transaction */ - cvmx_usb_transaction_t *tail; /**< The last pending transaction */ + struct cvmx_usb_transaction *head; /**< The first pending transaction */ + struct cvmx_usb_transaction *tail; /**< The last pending transaction */ uint64_t interval; /**< For periodic pipes, the interval between packets in frames */ uint64_t next_tx_frame; /**< The next frame this pipe is allowed to transmit on */ enum cvmx_usb_pipe_flags flags; /**< State flags for this pipe */ @@ -189,10 +206,10 @@ typedef struct { int idle_hardware_channels; /**< Bit set for every idle hardware channel */ cvmx_usbcx_hprt_t usbcx_hprt; /**< Stored port status so we don't need to read a CSR to determine splits */ cvmx_usb_pipe_t *pipe_for_channel[MAX_CHANNELS]; /**< Map channels to pipes */ - cvmx_usb_transaction_t *free_transaction_head; /**< List of free transactions head */ - cvmx_usb_transaction_t *free_transaction_tail; /**< List of free transactions tail */ + struct cvmx_usb_transaction *free_transaction_head; /**< List of free transactions head */ + struct cvmx_usb_transaction *free_transaction_tail; /**< List of free transactions tail */ cvmx_usb_pipe_t pipe[MAX_PIPES]; /**< Storage for pipes */ - cvmx_usb_transaction_t transaction[MAX_TRANSACTIONS]; /**< Storage for transactions */ + struct cvmx_usb_transaction transaction[MAX_TRANSACTIONS]; /**< Storage for transactions */ cvmx_usb_callback_func_t callback[__CVMX_USB_CALLBACK_END]; /**< User global callbacks */ void *callback_data[__CVMX_USB_CALLBACK_END]; /**< User data for each callback */ int indent; /**< Used by debug output to indent functions */ @@ -201,7 +218,7 @@ typedef struct { cvmx_usb_pipe_list_t idle_pipes; /**< List of open pipes that have no transactions */ cvmx_usb_pipe_list_t active_pipes[4]; /**< Active pipes indexed by transfer type */ uint64_t frame_number; /**< Increments every SOF interrupt for time keeping */ - cvmx_usb_transaction_t *active_split; /**< Points to the current active split, or NULL */ + struct cvmx_usb_transaction *active_split; /**< Points to the current active split, or NULL */ cvmx_usb_tx_fifo_t periodic; cvmx_usb_tx_fifo_t nonperiodic; } cvmx_usb_internal_state_t; @@ -391,9 +408,9 @@ int cvmx_usb_get_num_ports(void) * * Returns: Transaction or NULL */ -static inline cvmx_usb_transaction_t *__cvmx_usb_alloc_transaction(cvmx_usb_internal_state_t *usb) +static inline struct cvmx_usb_transaction *__cvmx_usb_alloc_transaction(cvmx_usb_internal_state_t *usb) { - cvmx_usb_transaction_t *t; + struct cvmx_usb_transaction *t; t = usb->free_transaction_head; if (t) { usb->free_transaction_head = t->next; @@ -417,7 +434,7 @@ static inline cvmx_usb_transaction_t *__cvmx_usb_alloc_transaction(cvmx_usb_inte * Transaction to free */ static inline void __cvmx_usb_free_transaction(cvmx_usb_internal_state_t *usb, - cvmx_usb_transaction_t *transaction) + struct cvmx_usb_transaction *transaction) { transaction->flags = 0; transaction->prev = NULL; @@ -1022,7 +1039,7 @@ void cvmx_usb_set_status(struct cvmx_usb_state *state, struct cvmx_usb_port_stat * Returns: Handle */ static inline int __cvmx_usb_get_submit_handle(cvmx_usb_internal_state_t *usb, - cvmx_usb_transaction_t *transaction) + struct cvmx_usb_transaction *transaction) { return ((unsigned long)transaction - (unsigned long)usb->transaction) / sizeof(*transaction); @@ -1380,7 +1397,7 @@ static void __cvmx_usb_start_channel_control(cvmx_usb_internal_state_t *usb, int channel, cvmx_usb_pipe_t *pipe) { - cvmx_usb_transaction_t *transaction = pipe->head; + struct cvmx_usb_transaction *transaction = pipe->head; cvmx_usb_control_header_t *header = cvmx_phys_to_ptr(transaction->control_header); int bytes_to_transfer = transaction->buffer_length - transaction->actual_bytes; int packets_to_transfer; @@ -1509,7 +1526,7 @@ static void __cvmx_usb_start_channel(cvmx_usb_internal_state_t *usb, int channel, cvmx_usb_pipe_t *pipe) { - cvmx_usb_transaction_t *transaction = pipe->head; + struct cvmx_usb_transaction *transaction = pipe->head; /* Make sure all writes to the DMA region get flushed */ CVMX_SYNCW; @@ -1900,7 +1917,7 @@ static void __cvmx_usb_schedule(cvmx_usb_internal_state_t *usb, int is_sof) */ static void __cvmx_usb_perform_callback(cvmx_usb_internal_state_t *usb, cvmx_usb_pipe_t *pipe, - cvmx_usb_transaction_t *transaction, + struct cvmx_usb_transaction *transaction, enum cvmx_usb_callback reason, enum cvmx_usb_complete complete_code) { @@ -1945,7 +1962,7 @@ static void __cvmx_usb_perform_callback(cvmx_usb_internal_state_t *usb, */ static void __cvmx_usb_perform_complete(cvmx_usb_internal_state_t *usb, cvmx_usb_pipe_t *pipe, - cvmx_usb_transaction_t *transaction, + struct cvmx_usb_transaction *transaction, enum cvmx_usb_complete complete_code) { /* If this was a split then clear our split in progress marker */ @@ -2037,7 +2054,7 @@ static int __cvmx_usb_submit_transaction(cvmx_usb_internal_state_t *usb, void *user_data) { int submit_handle; - cvmx_usb_transaction_t *transaction; + struct cvmx_usb_transaction *transaction; cvmx_usb_pipe_t *pipe = usb->pipe + pipe_handle; if (unlikely((pipe_handle < 0) || (pipe_handle >= MAX_PIPES))) @@ -2382,7 +2399,7 @@ int cvmx_usb_submit_isochronous(struct cvmx_usb_state *state, int pipe_handle, */ int cvmx_usb_cancel(struct cvmx_usb_state *state, int pipe_handle, int submit_handle) { - cvmx_usb_transaction_t *transaction; + struct cvmx_usb_transaction *transaction; cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; cvmx_usb_pipe_t *pipe = usb->pipe + pipe_handle; @@ -2561,7 +2578,7 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel) cvmx_usbcx_hctsizx_t usbc_hctsiz; cvmx_usbcx_hccharx_t usbc_hcchar; cvmx_usb_pipe_t *pipe; - cvmx_usb_transaction_t *transaction; + struct cvmx_usb_transaction *transaction; int bytes_this_transfer; int bytes_in_last_packet; int packets_processed; -- GitLab From 4ec3ae8412d0da9118cc441a807cce77fc0416bd Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 30 Jul 2013 23:43:07 +0300 Subject: [PATCH 430/942] staging: octeon-usb: cvmx_usb_pipe_t -> struct cvmx_usb_pipe Replace cvmx_usb_pipe_t with struct cvmx_usb_pipe. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/cvmx-usb.c | 114 ++++++++++++++++---------- 1 file changed, 69 insertions(+), 45 deletions(-) diff --git a/drivers/staging/octeon-usb/cvmx-usb.c b/drivers/staging/octeon-usb/cvmx-usb.c index beb3963dd5e69..93ce1176dbca3 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.c +++ b/drivers/staging/octeon-usb/cvmx-usb.c @@ -157,34 +157,58 @@ struct cvmx_usb_transaction { }; /** - * A pipe represents a virtual connection between Octeon and some - * USB device. It contains a list of pending request to the device. + * struct cvmx_usb_pipe - a pipe represents a virtual connection between Octeon + * and some USB device. It contains a list of pending + * request to the device. + * + * @prev: Pipe before this one in the list + * @next: Pipe after this one in the list + * @head: The first pending transaction + * @tail: The last pending transaction + * @interval: For periodic pipes, the interval between packets in + * frames + * @next_tx_frame: The next frame this pipe is allowed to transmit on + * @flags: State flags for this pipe + * @device_speed: Speed of device connected to this pipe + * @transfer_type: Type of transaction supported by this pipe + * @transfer_dir: IN or OUT. Ignored for Control + * @multi_count: Max packet in a row for the device + * @max_packet: The device's maximum packet size in bytes + * @device_addr: USB device address at other end of pipe + * @endpoint_num: USB endpoint number at other end of pipe + * @hub_device_addr: Hub address this device is connected to + * @hub_port: Hub port this device is connected to + * @pid_toggle: This toggles between 0/1 on every packet send to track + * the data pid needed + * @channel: Hardware DMA channel for this pipe + * @split_sc_frame: The low order bits of the frame number the split + * complete should be sent on */ -typedef struct cvmx_usb_pipe { - struct cvmx_usb_pipe *prev; /**< Pipe before this one in the list */ - struct cvmx_usb_pipe *next; /**< Pipe after this one in the list */ - struct cvmx_usb_transaction *head; /**< The first pending transaction */ - struct cvmx_usb_transaction *tail; /**< The last pending transaction */ - uint64_t interval; /**< For periodic pipes, the interval between packets in frames */ - uint64_t next_tx_frame; /**< The next frame this pipe is allowed to transmit on */ - enum cvmx_usb_pipe_flags flags; /**< State flags for this pipe */ - enum cvmx_usb_speed device_speed; /**< Speed of device connected to this pipe */ - enum cvmx_usb_transfer transfer_type; /**< Type of transaction supported by this pipe */ - enum cvmx_usb_direction transfer_dir; /**< IN or OUT. Ignored for Control */ - int multi_count; /**< Max packet in a row for the device */ - uint16_t max_packet; /**< The device's maximum packet size in bytes */ - uint8_t device_addr; /**< USB device address at other end of pipe */ - uint8_t endpoint_num; /**< USB endpoint number at other end of pipe */ - uint8_t hub_device_addr; /**< Hub address this device is connected to */ - uint8_t hub_port; /**< Hub port this device is connected to */ - uint8_t pid_toggle; /**< This toggles between 0/1 on every packet send to track the data pid needed */ - uint8_t channel; /**< Hardware DMA channel for this pipe */ - int8_t split_sc_frame; /**< The low order bits of the frame number the split complete should be sent on */ -} cvmx_usb_pipe_t; +struct cvmx_usb_pipe { + struct cvmx_usb_pipe *prev; + struct cvmx_usb_pipe *next; + struct cvmx_usb_transaction *head; + struct cvmx_usb_transaction *tail; + uint64_t interval; + uint64_t next_tx_frame; + enum cvmx_usb_pipe_flags flags; + enum cvmx_usb_speed device_speed; + enum cvmx_usb_transfer transfer_type; + enum cvmx_usb_direction transfer_dir; + int multi_count; + uint16_t max_packet; + uint8_t device_addr; + uint8_t endpoint_num; + uint8_t hub_device_addr; + uint8_t hub_port; + uint8_t pid_toggle; + uint8_t channel; + int8_t split_sc_frame; +}; typedef struct { - cvmx_usb_pipe_t *head; /**< Head of the list, or NULL if empty */ - cvmx_usb_pipe_t *tail; /**< Tail if the list, or NULL if empty */ + struct cvmx_usb_pipe *head; /**< Head of the list, or NULL if empty */ + struct cvmx_usb_pipe *tail; /**< Tail if the list, or NULL if empty */ } cvmx_usb_pipe_list_t; typedef struct { @@ -205,10 +229,10 @@ typedef struct { int index; /**< Which USB block this is for */ int idle_hardware_channels; /**< Bit set for every idle hardware channel */ cvmx_usbcx_hprt_t usbcx_hprt; /**< Stored port status so we don't need to read a CSR to determine splits */ - cvmx_usb_pipe_t *pipe_for_channel[MAX_CHANNELS]; /**< Map channels to pipes */ + struct cvmx_usb_pipe *pipe_for_channel[MAX_CHANNELS]; /**< Map channels to pipes */ struct cvmx_usb_transaction *free_transaction_head; /**< List of free transactions head */ struct cvmx_usb_transaction *free_transaction_tail; /**< List of free transactions tail */ - cvmx_usb_pipe_t pipe[MAX_PIPES]; /**< Storage for pipes */ + struct cvmx_usb_pipe pipe[MAX_PIPES]; /**< Storage for pipes */ struct cvmx_usb_transaction transaction[MAX_TRANSACTIONS]; /**< Storage for transactions */ cvmx_usb_callback_func_t callback[__CVMX_USB_CALLBACK_END]; /**< User global callbacks */ void *callback_data[__CVMX_USB_CALLBACK_END]; /**< User data for each callback */ @@ -347,7 +371,7 @@ static inline void __cvmx_usb_write_csr64(cvmx_usb_internal_state_t *usb, * * Returns: Non zero if we need to do split transactions */ -static inline int __cvmx_usb_pipe_needs_split(cvmx_usb_internal_state_t *usb, cvmx_usb_pipe_t *pipe) +static inline int __cvmx_usb_pipe_needs_split(cvmx_usb_internal_state_t *usb, struct cvmx_usb_pipe *pipe) { return ((pipe->device_speed != CVMX_USB_SPEED_HIGH) && (usb->usbcx_hprt.s.prtspd == CVMX_USB_SPEED_HIGH)); } @@ -360,7 +384,7 @@ static inline int __cvmx_usb_pipe_needs_split(cvmx_usb_internal_state_t *usb, cv * * Returns: PID for pipe */ -static inline int __cvmx_usb_get_data_pid(cvmx_usb_pipe_t *pipe) +static inline int __cvmx_usb_get_data_pid(struct cvmx_usb_pipe *pipe) { if (pipe->pid_toggle) return 2; /* Data1 */ @@ -452,7 +476,7 @@ static inline void __cvmx_usb_free_transaction(cvmx_usb_internal_state_t *usb, * @list: List to add pipe to * @pipe: Pipe to add */ -static inline void __cvmx_usb_append_pipe(cvmx_usb_pipe_list_t *list, cvmx_usb_pipe_t *pipe) +static inline void __cvmx_usb_append_pipe(cvmx_usb_pipe_list_t *list, struct cvmx_usb_pipe *pipe) { pipe->next = NULL; pipe->prev = list->tail; @@ -469,7 +493,7 @@ static inline void __cvmx_usb_append_pipe(cvmx_usb_pipe_list_t *list, cvmx_usb_p * @list: List to remove pipe from * @pipe: Pipe to remove */ -static inline void __cvmx_usb_remove_pipe(cvmx_usb_pipe_list_t *list, cvmx_usb_pipe_t *pipe) +static inline void __cvmx_usb_remove_pipe(cvmx_usb_pipe_list_t *list, struct cvmx_usb_pipe *pipe) { if (list->head == pipe) { list->head = pipe->next; @@ -1056,7 +1080,7 @@ static inline int __cvmx_usb_get_submit_handle(cvmx_usb_internal_state_t *usb, * Returns: Handle */ static inline int __cvmx_usb_get_pipe_handle(cvmx_usb_internal_state_t *usb, - cvmx_usb_pipe_t *pipe) + struct cvmx_usb_pipe *pipe) { return ((unsigned long)pipe - (unsigned long)usb->pipe) / sizeof(*pipe); } @@ -1125,7 +1149,7 @@ int cvmx_usb_open_pipe(struct cvmx_usb_state *state, enum cvmx_usb_pipe_flags fl enum cvmx_usb_direction transfer_dir, int interval, int multi_count, int hub_device_addr, int hub_port) { - cvmx_usb_pipe_t *pipe; + struct cvmx_usb_pipe *pipe; cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; if (unlikely((device_addr < 0) || (device_addr > MAX_USB_ADDRESS))) @@ -1395,7 +1419,7 @@ static void __cvmx_usb_fill_tx_fifo(cvmx_usb_internal_state_t *usb, int channel) */ static void __cvmx_usb_start_channel_control(cvmx_usb_internal_state_t *usb, int channel, - cvmx_usb_pipe_t *pipe) + struct cvmx_usb_pipe *pipe) { struct cvmx_usb_transaction *transaction = pipe->head; cvmx_usb_control_header_t *header = cvmx_phys_to_ptr(transaction->control_header); @@ -1524,7 +1548,7 @@ static void __cvmx_usb_start_channel_control(cvmx_usb_internal_state_t *usb, */ static void __cvmx_usb_start_channel(cvmx_usb_internal_state_t *usb, int channel, - cvmx_usb_pipe_t *pipe) + struct cvmx_usb_pipe *pipe) { struct cvmx_usb_transaction *transaction = pipe->head; @@ -1811,9 +1835,9 @@ static void __cvmx_usb_start_channel(cvmx_usb_internal_state_t *usb, * * Returns: Pipe or NULL if none are ready */ -static cvmx_usb_pipe_t *__cvmx_usb_find_ready_pipe(cvmx_usb_internal_state_t *usb, cvmx_usb_pipe_list_t *list, uint64_t current_frame) +static struct cvmx_usb_pipe *__cvmx_usb_find_ready_pipe(cvmx_usb_internal_state_t *usb, cvmx_usb_pipe_list_t *list, uint64_t current_frame) { - cvmx_usb_pipe_t *pipe = list->head; + struct cvmx_usb_pipe *pipe = list->head; while (pipe) { if (!(pipe->flags & __CVMX_USB_PIPE_FLAGS_SCHEDULED) && pipe->head && (pipe->next_tx_frame <= current_frame) && @@ -1840,7 +1864,7 @@ static cvmx_usb_pipe_t *__cvmx_usb_find_ready_pipe(cvmx_usb_internal_state_t *us static void __cvmx_usb_schedule(cvmx_usb_internal_state_t *usb, int is_sof) { int channel; - cvmx_usb_pipe_t *pipe; + struct cvmx_usb_pipe *pipe; int need_sof; enum cvmx_usb_transfer ttype; @@ -1916,7 +1940,7 @@ static void __cvmx_usb_schedule(cvmx_usb_internal_state_t *usb, int is_sof) * Completion code for the transaction, if any */ static void __cvmx_usb_perform_callback(cvmx_usb_internal_state_t *usb, - cvmx_usb_pipe_t *pipe, + struct cvmx_usb_pipe *pipe, struct cvmx_usb_transaction *transaction, enum cvmx_usb_callback reason, enum cvmx_usb_complete complete_code) @@ -1961,7 +1985,7 @@ static void __cvmx_usb_perform_callback(cvmx_usb_internal_state_t *usb, * Completion code */ static void __cvmx_usb_perform_complete(cvmx_usb_internal_state_t *usb, - cvmx_usb_pipe_t *pipe, + struct cvmx_usb_pipe *pipe, struct cvmx_usb_transaction *transaction, enum cvmx_usb_complete complete_code) { @@ -2055,7 +2079,7 @@ static int __cvmx_usb_submit_transaction(cvmx_usb_internal_state_t *usb, { int submit_handle; struct cvmx_usb_transaction *transaction; - cvmx_usb_pipe_t *pipe = usb->pipe + pipe_handle; + struct cvmx_usb_pipe *pipe = usb->pipe + pipe_handle; if (unlikely((pipe_handle < 0) || (pipe_handle >= MAX_PIPES))) return -EINVAL; @@ -2401,7 +2425,7 @@ int cvmx_usb_cancel(struct cvmx_usb_state *state, int pipe_handle, int submit_ha { struct cvmx_usb_transaction *transaction; cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; - cvmx_usb_pipe_t *pipe = usb->pipe + pipe_handle; + struct cvmx_usb_pipe *pipe = usb->pipe + pipe_handle; if (unlikely((pipe_handle < 0) || (pipe_handle >= MAX_PIPES))) return -EINVAL; @@ -2457,7 +2481,7 @@ int cvmx_usb_cancel(struct cvmx_usb_state *state, int pipe_handle, int submit_ha int cvmx_usb_cancel_all(struct cvmx_usb_state *state, int pipe_handle) { cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; - cvmx_usb_pipe_t *pipe = usb->pipe + pipe_handle; + struct cvmx_usb_pipe *pipe = usb->pipe + pipe_handle; if (unlikely((pipe_handle < 0) || (pipe_handle >= MAX_PIPES))) return -EINVAL; @@ -2491,7 +2515,7 @@ int cvmx_usb_cancel_all(struct cvmx_usb_state *state, int pipe_handle) int cvmx_usb_close_pipe(struct cvmx_usb_state *state, int pipe_handle) { cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; - cvmx_usb_pipe_t *pipe = usb->pipe + pipe_handle; + struct cvmx_usb_pipe *pipe = usb->pipe + pipe_handle; if (unlikely((pipe_handle < 0) || (pipe_handle >= MAX_PIPES))) return -EINVAL; @@ -2577,7 +2601,7 @@ static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel) cvmx_usbcx_hcintx_t usbc_hcint; cvmx_usbcx_hctsizx_t usbc_hctsiz; cvmx_usbcx_hccharx_t usbc_hcchar; - cvmx_usb_pipe_t *pipe; + struct cvmx_usb_pipe *pipe; struct cvmx_usb_transaction *transaction; int bytes_this_transfer; int bytes_in_last_packet; -- GitLab From bb06528d6eb9be3f857a2f1275c4c55ce1584a20 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 30 Jul 2013 23:43:08 +0300 Subject: [PATCH 431/942] staging: octeon-usb: cvmx_usb_pipe_list_t -> struct cvmx_usb_pipe_list Replace cvmx_usb_pipe_list_t with struct cvmx_usb_pipe_list. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/cvmx-usb.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/staging/octeon-usb/cvmx-usb.c b/drivers/staging/octeon-usb/cvmx-usb.c index 93ce1176dbca3..c5bf5d1db1f9d 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.c +++ b/drivers/staging/octeon-usb/cvmx-usb.c @@ -206,10 +206,16 @@ struct cvmx_usb_pipe { int8_t split_sc_frame; }; -typedef struct { - struct cvmx_usb_pipe *head; /**< Head of the list, or NULL if empty */ - struct cvmx_usb_pipe *tail; /**< Tail if the list, or NULL if empty */ -} cvmx_usb_pipe_list_t; +/** + * struct cvmx_usb_pipe_list + * + * @head: Head of the list, or NULL if empty. + * @tail: Tail if the list, or NULL if empty. + */ +struct cvmx_usb_pipe_list { + struct cvmx_usb_pipe *head; + struct cvmx_usb_pipe *tail; +}; typedef struct { struct { @@ -238,9 +244,9 @@ typedef struct { void *callback_data[__CVMX_USB_CALLBACK_END]; /**< User data for each callback */ int indent; /**< Used by debug output to indent functions */ struct cvmx_usb_port_status port_status; /**< Last port status used for change notification */ - cvmx_usb_pipe_list_t free_pipes; /**< List of all pipes that are currently closed */ - cvmx_usb_pipe_list_t idle_pipes; /**< List of open pipes that have no transactions */ - cvmx_usb_pipe_list_t active_pipes[4]; /**< Active pipes indexed by transfer type */ + struct cvmx_usb_pipe_list free_pipes; /**< List of all pipes that are currently closed */ + struct cvmx_usb_pipe_list idle_pipes; /**< List of open pipes that have no transactions */ + struct cvmx_usb_pipe_list active_pipes[4]; /**< Active pipes indexed by transfer type */ uint64_t frame_number; /**< Increments every SOF interrupt for time keeping */ struct cvmx_usb_transaction *active_split; /**< Points to the current active split, or NULL */ cvmx_usb_tx_fifo_t periodic; @@ -476,7 +482,7 @@ static inline void __cvmx_usb_free_transaction(cvmx_usb_internal_state_t *usb, * @list: List to add pipe to * @pipe: Pipe to add */ -static inline void __cvmx_usb_append_pipe(cvmx_usb_pipe_list_t *list, struct cvmx_usb_pipe *pipe) +static inline void __cvmx_usb_append_pipe(struct cvmx_usb_pipe_list *list, struct cvmx_usb_pipe *pipe) { pipe->next = NULL; pipe->prev = list->tail; @@ -493,7 +499,7 @@ static inline void __cvmx_usb_append_pipe(cvmx_usb_pipe_list_t *list, struct cvm * @list: List to remove pipe from * @pipe: Pipe to remove */ -static inline void __cvmx_usb_remove_pipe(cvmx_usb_pipe_list_t *list, struct cvmx_usb_pipe *pipe) +static inline void __cvmx_usb_remove_pipe(struct cvmx_usb_pipe_list *list, struct cvmx_usb_pipe *pipe) { if (list->head == pipe) { list->head = pipe->next; @@ -1835,7 +1841,7 @@ static void __cvmx_usb_start_channel(cvmx_usb_internal_state_t *usb, * * Returns: Pipe or NULL if none are ready */ -static struct cvmx_usb_pipe *__cvmx_usb_find_ready_pipe(cvmx_usb_internal_state_t *usb, cvmx_usb_pipe_list_t *list, uint64_t current_frame) +static struct cvmx_usb_pipe *__cvmx_usb_find_ready_pipe(cvmx_usb_internal_state_t *usb, struct cvmx_usb_pipe_list *list, uint64_t current_frame) { struct cvmx_usb_pipe *pipe = list->head; while (pipe) { -- GitLab From 0ff6ac84f9648260f0d4e5994f13cbb6538d9285 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 30 Jul 2013 23:43:09 +0300 Subject: [PATCH 432/942] staging: octeon-usb: cvmx_usb_tx_fifo_t -> struct cvmx_usb_tx_fifo Replace cvmx_usb_tx_fifo_t with struct cvmx_usb_tx_fifo_t. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/cvmx-usb.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/octeon-usb/cvmx-usb.c b/drivers/staging/octeon-usb/cvmx-usb.c index c5bf5d1db1f9d..468cdff3cccb6 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.c +++ b/drivers/staging/octeon-usb/cvmx-usb.c @@ -217,7 +217,7 @@ struct cvmx_usb_pipe_list { struct cvmx_usb_pipe *tail; }; -typedef struct { +struct cvmx_usb_tx_fifo { struct { int channel; int size; @@ -225,7 +225,7 @@ typedef struct { } entry[MAX_CHANNELS+1]; int head; int tail; -} cvmx_usb_tx_fifo_t; +}; /** * The state of the USB block is stored in this structure @@ -249,8 +249,8 @@ typedef struct { struct cvmx_usb_pipe_list active_pipes[4]; /**< Active pipes indexed by transfer type */ uint64_t frame_number; /**< Increments every SOF interrupt for time keeping */ struct cvmx_usb_transaction *active_split; /**< Points to the current active split, or NULL */ - cvmx_usb_tx_fifo_t periodic; - cvmx_usb_tx_fifo_t nonperiodic; + struct cvmx_usb_tx_fifo periodic; + struct cvmx_usb_tx_fifo nonperiodic; } cvmx_usb_internal_state_t; /* This macro spins on a field waiting for it to reach a value */ @@ -1288,7 +1288,7 @@ static void __cvmx_usb_poll_rx_fifo(cvmx_usb_internal_state_t *usb) * Returns: Non zero if the hardware fifo was too small and needs * to be serviced again. */ -static int __cvmx_usb_fill_tx_hw(cvmx_usb_internal_state_t *usb, cvmx_usb_tx_fifo_t *fifo, int available) +static int __cvmx_usb_fill_tx_hw(cvmx_usb_internal_state_t *usb, struct cvmx_usb_tx_fifo *fifo, int available) { /* * We're done either when there isn't anymore space or the software FIFO @@ -1378,7 +1378,7 @@ static void __cvmx_usb_fill_tx_fifo(cvmx_usb_internal_state_t *usb, int channel) cvmx_usbcx_hccharx_t hcchar; cvmx_usbcx_hcspltx_t usbc_hcsplt; cvmx_usbcx_hctsizx_t usbc_hctsiz; - cvmx_usb_tx_fifo_t *fifo; + struct cvmx_usb_tx_fifo *fifo; /* We only need to fill data on outbound channels */ hcchar.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCCHARX(channel, usb->index)); -- GitLab From 2bf249e482f42145890d39d8c575e502642b3307 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 30 Jul 2013 23:43:10 +0300 Subject: [PATCH 433/942] staging: octeon-usb: cvmx_usb_internal_state_t -> struct cvmx_usb_internal_state Replace cvmx_usb_internal_state_t with struct cvmx_usb_internal_state. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/cvmx-usb.c | 138 +++++++++++++++----------- 1 file changed, 79 insertions(+), 59 deletions(-) diff --git a/drivers/staging/octeon-usb/cvmx-usb.c b/drivers/staging/octeon-usb/cvmx-usb.c index 468cdff3cccb6..3cc315ded3f9f 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.c +++ b/drivers/staging/octeon-usb/cvmx-usb.c @@ -228,30 +228,50 @@ struct cvmx_usb_tx_fifo { }; /** - * The state of the USB block is stored in this structure + * struct cvmx_usb_internal_state - the state of the USB block + * + * init_flags: Flags passed to initialize. + * index: Which USB block this is for. + * idle_hardware_channels: Bit set for every idle hardware channel. + * usbcx_hprt: Stored port status so we don't need to read a CSR to + * determine splits. + * pipe_for_channel: Map channels to pipes. + * free_transaction_head: List of free transactions head. + * free_transaction_tail: List of free transactions tail. + * pipe: Storage for pipes. + * transaction: Storage for transactions. + * callback: User global callbacks. + * callback_data: User data for each callback. + * indent: Used by debug output to indent functions. + * port_status: Last port status used for change notification. + * free_pipes: List of all pipes that are currently closed. + * idle_pipes: List of open pipes that have no transactions. + * active_pipes: Active pipes indexed by transfer type. + * frame_number: Increments every SOF interrupt for time keeping. + * active_split: Points to the current active split, or NULL. */ -typedef struct { - int init_flags; /**< Flags passed to initialize */ - int index; /**< Which USB block this is for */ - int idle_hardware_channels; /**< Bit set for every idle hardware channel */ - cvmx_usbcx_hprt_t usbcx_hprt; /**< Stored port status so we don't need to read a CSR to determine splits */ - struct cvmx_usb_pipe *pipe_for_channel[MAX_CHANNELS]; /**< Map channels to pipes */ - struct cvmx_usb_transaction *free_transaction_head; /**< List of free transactions head */ - struct cvmx_usb_transaction *free_transaction_tail; /**< List of free transactions tail */ - struct cvmx_usb_pipe pipe[MAX_PIPES]; /**< Storage for pipes */ - struct cvmx_usb_transaction transaction[MAX_TRANSACTIONS]; /**< Storage for transactions */ - cvmx_usb_callback_func_t callback[__CVMX_USB_CALLBACK_END]; /**< User global callbacks */ - void *callback_data[__CVMX_USB_CALLBACK_END]; /**< User data for each callback */ - int indent; /**< Used by debug output to indent functions */ - struct cvmx_usb_port_status port_status; /**< Last port status used for change notification */ - struct cvmx_usb_pipe_list free_pipes; /**< List of all pipes that are currently closed */ - struct cvmx_usb_pipe_list idle_pipes; /**< List of open pipes that have no transactions */ - struct cvmx_usb_pipe_list active_pipes[4]; /**< Active pipes indexed by transfer type */ - uint64_t frame_number; /**< Increments every SOF interrupt for time keeping */ - struct cvmx_usb_transaction *active_split; /**< Points to the current active split, or NULL */ +struct cvmx_usb_internal_state { + int init_flags; + int index; + int idle_hardware_channels; + cvmx_usbcx_hprt_t usbcx_hprt; + struct cvmx_usb_pipe *pipe_for_channel[MAX_CHANNELS]; + struct cvmx_usb_transaction *free_transaction_head; + struct cvmx_usb_transaction *free_transaction_tail; + struct cvmx_usb_pipe pipe[MAX_PIPES]; + struct cvmx_usb_transaction transaction[MAX_TRANSACTIONS]; + cvmx_usb_callback_func_t callback[__CVMX_USB_CALLBACK_END]; + void *callback_data[__CVMX_USB_CALLBACK_END]; + int indent; + struct cvmx_usb_port_status port_status; + struct cvmx_usb_pipe_list free_pipes; + struct cvmx_usb_pipe_list idle_pipes; + struct cvmx_usb_pipe_list active_pipes[4]; + uint64_t frame_number; + struct cvmx_usb_transaction *active_split; struct cvmx_usb_tx_fifo periodic; struct cvmx_usb_tx_fifo nonperiodic; -} cvmx_usb_internal_state_t; +}; /* This macro spins on a field waiting for it to reach a value */ #define CVMX_WAIT_FOR_FIELD32(address, type, field, op, value, timeout_usec)\ @@ -312,7 +332,7 @@ static int octeon_usb_get_clock_type(void) * * Returns: Result of the read */ -static inline uint32_t __cvmx_usb_read_csr32(cvmx_usb_internal_state_t *usb, +static inline uint32_t __cvmx_usb_read_csr32(struct cvmx_usb_internal_state *usb, uint64_t address) { uint32_t result = cvmx_read64_uint32(address ^ 4); @@ -329,7 +349,7 @@ static inline uint32_t __cvmx_usb_read_csr32(cvmx_usb_internal_state_t *usb, * @address: 64bit address to write * @value: Value to write */ -static inline void __cvmx_usb_write_csr32(cvmx_usb_internal_state_t *usb, +static inline void __cvmx_usb_write_csr32(struct cvmx_usb_internal_state *usb, uint64_t address, uint32_t value) { cvmx_write64_uint32(address ^ 4, value); @@ -346,7 +366,7 @@ static inline void __cvmx_usb_write_csr32(cvmx_usb_internal_state_t *usb, * * Returns: Result of the read */ -static inline uint64_t __cvmx_usb_read_csr64(cvmx_usb_internal_state_t *usb, +static inline uint64_t __cvmx_usb_read_csr64(struct cvmx_usb_internal_state *usb, uint64_t address) { uint64_t result = cvmx_read64_uint64(address); @@ -362,7 +382,7 @@ static inline uint64_t __cvmx_usb_read_csr64(cvmx_usb_internal_state_t *usb, * @address: 64bit address to write * @value: Value to write */ -static inline void __cvmx_usb_write_csr64(cvmx_usb_internal_state_t *usb, +static inline void __cvmx_usb_write_csr64(struct cvmx_usb_internal_state *usb, uint64_t address, uint64_t value) { cvmx_write64_uint64(address, value); @@ -377,7 +397,7 @@ static inline void __cvmx_usb_write_csr64(cvmx_usb_internal_state_t *usb, * * Returns: Non zero if we need to do split transactions */ -static inline int __cvmx_usb_pipe_needs_split(cvmx_usb_internal_state_t *usb, struct cvmx_usb_pipe *pipe) +static inline int __cvmx_usb_pipe_needs_split(struct cvmx_usb_internal_state *usb, struct cvmx_usb_pipe *pipe) { return ((pipe->device_speed != CVMX_USB_SPEED_HIGH) && (usb->usbcx_hprt.s.prtspd == CVMX_USB_SPEED_HIGH)); } @@ -438,7 +458,7 @@ int cvmx_usb_get_num_ports(void) * * Returns: Transaction or NULL */ -static inline struct cvmx_usb_transaction *__cvmx_usb_alloc_transaction(cvmx_usb_internal_state_t *usb) +static inline struct cvmx_usb_transaction *__cvmx_usb_alloc_transaction(struct cvmx_usb_internal_state *usb) { struct cvmx_usb_transaction *t; t = usb->free_transaction_head; @@ -463,7 +483,7 @@ static inline struct cvmx_usb_transaction *__cvmx_usb_alloc_transaction(cvmx_usb * @transaction: * Transaction to free */ -static inline void __cvmx_usb_free_transaction(cvmx_usb_internal_state_t *usb, +static inline void __cvmx_usb_free_transaction(struct cvmx_usb_internal_state *usb, struct cvmx_usb_transaction *transaction) { transaction->flags = 0; @@ -543,7 +563,7 @@ int cvmx_usb_initialize(struct cvmx_usb_state *state, int usb_port_number, { cvmx_usbnx_clk_ctl_t usbn_clk_ctl; cvmx_usbnx_usbp_ctl_status_t usbn_usbp_ctl_status; - cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; + struct cvmx_usb_internal_state *usb = (struct cvmx_usb_internal_state *)state; usb->init_flags = flags; @@ -868,7 +888,7 @@ int cvmx_usb_initialize(struct cvmx_usb_state *state, int usb_port_number, int cvmx_usb_shutdown(struct cvmx_usb_state *state) { cvmx_usbnx_clk_ctl_t usbn_clk_ctl; - cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; + struct cvmx_usb_internal_state *usb = (struct cvmx_usb_internal_state *)state; /* Make sure all pipes are closed */ if (usb->idle_pipes.head || @@ -903,7 +923,7 @@ int cvmx_usb_shutdown(struct cvmx_usb_state *state) int cvmx_usb_enable(struct cvmx_usb_state *state) { cvmx_usbcx_ghwcfg3_t usbcx_ghwcfg3; - cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; + struct cvmx_usb_internal_state *usb = (struct cvmx_usb_internal_state *)state; usb->usbcx_hprt.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HPRT(usb->index)); @@ -996,7 +1016,7 @@ int cvmx_usb_enable(struct cvmx_usb_state *state) */ int cvmx_usb_disable(struct cvmx_usb_state *state) { - cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; + struct cvmx_usb_internal_state *usb = (struct cvmx_usb_internal_state *)state; /* Disable the port */ USB_SET_FIELD32(CVMX_USBCX_HPRT(usb->index), cvmx_usbcx_hprt_t, prtena, 1); @@ -1022,7 +1042,7 @@ struct cvmx_usb_port_status cvmx_usb_get_status(struct cvmx_usb_state *state) { cvmx_usbcx_hprt_t usbc_hprt; struct cvmx_usb_port_status result; - cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; + struct cvmx_usb_internal_state *usb = (struct cvmx_usb_internal_state *)state; memset(&result, 0, sizeof(result)); @@ -1052,7 +1072,7 @@ struct cvmx_usb_port_status cvmx_usb_get_status(struct cvmx_usb_state *state) */ void cvmx_usb_set_status(struct cvmx_usb_state *state, struct cvmx_usb_port_status port_status) { - cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; + struct cvmx_usb_internal_state *usb = (struct cvmx_usb_internal_state *)state; usb->port_status = port_status; return; } @@ -1068,7 +1088,7 @@ void cvmx_usb_set_status(struct cvmx_usb_state *state, struct cvmx_usb_port_stat * * Returns: Handle */ -static inline int __cvmx_usb_get_submit_handle(cvmx_usb_internal_state_t *usb, +static inline int __cvmx_usb_get_submit_handle(struct cvmx_usb_internal_state *usb, struct cvmx_usb_transaction *transaction) { return ((unsigned long)transaction - (unsigned long)usb->transaction) / @@ -1085,7 +1105,7 @@ static inline int __cvmx_usb_get_submit_handle(cvmx_usb_internal_state_t *usb, * * Returns: Handle */ -static inline int __cvmx_usb_get_pipe_handle(cvmx_usb_internal_state_t *usb, +static inline int __cvmx_usb_get_pipe_handle(struct cvmx_usb_internal_state *usb, struct cvmx_usb_pipe *pipe) { return ((unsigned long)pipe - (unsigned long)usb->pipe) / sizeof(*pipe); @@ -1156,7 +1176,7 @@ int cvmx_usb_open_pipe(struct cvmx_usb_state *state, enum cvmx_usb_pipe_flags fl int multi_count, int hub_device_addr, int hub_port) { struct cvmx_usb_pipe *pipe; - cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; + struct cvmx_usb_internal_state *usb = (struct cvmx_usb_internal_state *)state; if (unlikely((device_addr < 0) || (device_addr > MAX_USB_ADDRESS))) return -EINVAL; @@ -1239,7 +1259,7 @@ int cvmx_usb_open_pipe(struct cvmx_usb_state *state, enum cvmx_usb_pipe_flags fl * @usb: USB device state populated by * cvmx_usb_initialize(). */ -static void __cvmx_usb_poll_rx_fifo(cvmx_usb_internal_state_t *usb) +static void __cvmx_usb_poll_rx_fifo(struct cvmx_usb_internal_state *usb) { cvmx_usbcx_grxstsph_t rx_status; int channel; @@ -1288,7 +1308,7 @@ static void __cvmx_usb_poll_rx_fifo(cvmx_usb_internal_state_t *usb) * Returns: Non zero if the hardware fifo was too small and needs * to be serviced again. */ -static int __cvmx_usb_fill_tx_hw(cvmx_usb_internal_state_t *usb, struct cvmx_usb_tx_fifo *fifo, int available) +static int __cvmx_usb_fill_tx_hw(struct cvmx_usb_internal_state *usb, struct cvmx_usb_tx_fifo *fifo, int available) { /* * We're done either when there isn't anymore space or the software FIFO @@ -1342,7 +1362,7 @@ static int __cvmx_usb_fill_tx_hw(cvmx_usb_internal_state_t *usb, struct cvmx_usb * @usb: USB device state populated by * cvmx_usb_initialize(). */ -static void __cvmx_usb_poll_tx_fifo(cvmx_usb_internal_state_t *usb) +static void __cvmx_usb_poll_tx_fifo(struct cvmx_usb_internal_state *usb) { if (usb->periodic.head != usb->periodic.tail) { cvmx_usbcx_hptxsts_t tx_status; @@ -1373,7 +1393,7 @@ static void __cvmx_usb_poll_tx_fifo(cvmx_usb_internal_state_t *usb) * cvmx_usb_initialize(). * @channel: Channel number to get packet from */ -static void __cvmx_usb_fill_tx_fifo(cvmx_usb_internal_state_t *usb, int channel) +static void __cvmx_usb_fill_tx_fifo(struct cvmx_usb_internal_state *usb, int channel) { cvmx_usbcx_hccharx_t hcchar; cvmx_usbcx_hcspltx_t usbc_hcsplt; @@ -1423,7 +1443,7 @@ static void __cvmx_usb_fill_tx_fifo(cvmx_usb_internal_state_t *usb, int channel) * @channel: Channel to setup * @pipe: Pipe for control transaction */ -static void __cvmx_usb_start_channel_control(cvmx_usb_internal_state_t *usb, +static void __cvmx_usb_start_channel_control(struct cvmx_usb_internal_state *usb, int channel, struct cvmx_usb_pipe *pipe) { @@ -1552,7 +1572,7 @@ static void __cvmx_usb_start_channel_control(cvmx_usb_internal_state_t *usb, * @channel: Channel to setup * @pipe: Pipe to start */ -static void __cvmx_usb_start_channel(cvmx_usb_internal_state_t *usb, +static void __cvmx_usb_start_channel(struct cvmx_usb_internal_state *usb, int channel, struct cvmx_usb_pipe *pipe) { @@ -1841,7 +1861,7 @@ static void __cvmx_usb_start_channel(cvmx_usb_internal_state_t *usb, * * Returns: Pipe or NULL if none are ready */ -static struct cvmx_usb_pipe *__cvmx_usb_find_ready_pipe(cvmx_usb_internal_state_t *usb, struct cvmx_usb_pipe_list *list, uint64_t current_frame) +static struct cvmx_usb_pipe *__cvmx_usb_find_ready_pipe(struct cvmx_usb_internal_state *usb, struct cvmx_usb_pipe_list *list, uint64_t current_frame) { struct cvmx_usb_pipe *pipe = list->head; while (pipe) { @@ -1867,7 +1887,7 @@ static struct cvmx_usb_pipe *__cvmx_usb_find_ready_pipe(cvmx_usb_internal_state_ * cvmx_usb_initialize(). * @is_sof: True if this schedule was called on a SOF interrupt. */ -static void __cvmx_usb_schedule(cvmx_usb_internal_state_t *usb, int is_sof) +static void __cvmx_usb_schedule(struct cvmx_usb_internal_state *usb, int is_sof) { int channel; struct cvmx_usb_pipe *pipe; @@ -1945,7 +1965,7 @@ static void __cvmx_usb_schedule(cvmx_usb_internal_state_t *usb, int is_sof) * @complete_code: * Completion code for the transaction, if any */ -static void __cvmx_usb_perform_callback(cvmx_usb_internal_state_t *usb, +static void __cvmx_usb_perform_callback(struct cvmx_usb_internal_state *usb, struct cvmx_usb_pipe *pipe, struct cvmx_usb_transaction *transaction, enum cvmx_usb_callback reason, @@ -1990,7 +2010,7 @@ static void __cvmx_usb_perform_callback(cvmx_usb_internal_state_t *usb, * @complete_code: * Completion code */ -static void __cvmx_usb_perform_complete(cvmx_usb_internal_state_t *usb, +static void __cvmx_usb_perform_complete(struct cvmx_usb_internal_state *usb, struct cvmx_usb_pipe *pipe, struct cvmx_usb_transaction *transaction, enum cvmx_usb_complete complete_code) @@ -2070,7 +2090,7 @@ static void __cvmx_usb_perform_complete(cvmx_usb_internal_state_t *usb, * Returns: Submit handle or negative on failure. Matches the result * in the external API. */ -static int __cvmx_usb_submit_transaction(cvmx_usb_internal_state_t *usb, +static int __cvmx_usb_submit_transaction(struct cvmx_usb_internal_state *usb, int pipe_handle, enum cvmx_usb_transfer type, int flags, @@ -2175,7 +2195,7 @@ int cvmx_usb_submit_bulk(struct cvmx_usb_state *state, int pipe_handle, void *user_data) { int submit_handle; - cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; + struct cvmx_usb_internal_state *usb = (struct cvmx_usb_internal_state *)state; /* Pipe handle checking is done later in a common place */ if (unlikely(!buffer)) @@ -2234,7 +2254,7 @@ int cvmx_usb_submit_interrupt(struct cvmx_usb_state *state, int pipe_handle, void *user_data) { int submit_handle; - cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; + struct cvmx_usb_internal_state *usb = (struct cvmx_usb_internal_state *)state; /* Pipe handle checking is done later in a common place */ if (unlikely(!buffer)) @@ -2298,7 +2318,7 @@ int cvmx_usb_submit_control(struct cvmx_usb_state *state, int pipe_handle, void *user_data) { int submit_handle; - cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; + struct cvmx_usb_internal_state *usb = (struct cvmx_usb_internal_state *)state; cvmx_usb_control_header_t *header = cvmx_phys_to_ptr(control_header); /* Pipe handle checking is done later in a common place */ @@ -2380,7 +2400,7 @@ int cvmx_usb_submit_isochronous(struct cvmx_usb_state *state, int pipe_handle, void *user_data) { int submit_handle; - cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; + struct cvmx_usb_internal_state *usb = (struct cvmx_usb_internal_state *)state; /* Pipe handle checking is done later in a common place */ if (unlikely(start_frame < 0)) @@ -2430,7 +2450,7 @@ int cvmx_usb_submit_isochronous(struct cvmx_usb_state *state, int pipe_handle, int cvmx_usb_cancel(struct cvmx_usb_state *state, int pipe_handle, int submit_handle) { struct cvmx_usb_transaction *transaction; - cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; + struct cvmx_usb_internal_state *usb = (struct cvmx_usb_internal_state *)state; struct cvmx_usb_pipe *pipe = usb->pipe + pipe_handle; if (unlikely((pipe_handle < 0) || (pipe_handle >= MAX_PIPES))) @@ -2486,7 +2506,7 @@ int cvmx_usb_cancel(struct cvmx_usb_state *state, int pipe_handle, int submit_ha */ int cvmx_usb_cancel_all(struct cvmx_usb_state *state, int pipe_handle) { - cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; + struct cvmx_usb_internal_state *usb = (struct cvmx_usb_internal_state *)state; struct cvmx_usb_pipe *pipe = usb->pipe + pipe_handle; if (unlikely((pipe_handle < 0) || (pipe_handle >= MAX_PIPES))) @@ -2520,7 +2540,7 @@ int cvmx_usb_cancel_all(struct cvmx_usb_state *state, int pipe_handle) */ int cvmx_usb_close_pipe(struct cvmx_usb_state *state, int pipe_handle) { - cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; + struct cvmx_usb_internal_state *usb = (struct cvmx_usb_internal_state *)state; struct cvmx_usb_pipe *pipe = usb->pipe + pipe_handle; if (unlikely((pipe_handle < 0) || (pipe_handle >= MAX_PIPES))) @@ -2558,7 +2578,7 @@ int cvmx_usb_register_callback(struct cvmx_usb_state *state, cvmx_usb_callback_func_t callback, void *user_data) { - cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; + struct cvmx_usb_internal_state *usb = (struct cvmx_usb_internal_state *)state; if (unlikely(reason >= __CVMX_USB_CALLBACK_END)) return -EINVAL; @@ -2584,7 +2604,7 @@ int cvmx_usb_register_callback(struct cvmx_usb_state *state, int cvmx_usb_get_frame_number(struct cvmx_usb_state *state) { int frame_number; - cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; + struct cvmx_usb_internal_state *usb = (struct cvmx_usb_internal_state *)state; cvmx_usbcx_hfnum_t usbc_hfnum; usbc_hfnum.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HFNUM(usb->index)); @@ -2602,7 +2622,7 @@ int cvmx_usb_get_frame_number(struct cvmx_usb_state *state) * * Returns: Zero on success */ -static int __cvmx_usb_poll_channel(cvmx_usb_internal_state_t *usb, int channel) +static int __cvmx_usb_poll_channel(struct cvmx_usb_internal_state *usb, int channel) { cvmx_usbcx_hcintx_t usbc_hcint; cvmx_usbcx_hctsizx_t usbc_hctsiz; @@ -3043,7 +3063,7 @@ int cvmx_usb_poll(struct cvmx_usb_state *state) { cvmx_usbcx_hfnum_t usbc_hfnum; cvmx_usbcx_gintsts_t usbc_gintsts; - cvmx_usb_internal_state_t *usb = (cvmx_usb_internal_state_t *)state; + struct cvmx_usb_internal_state *usb = (struct cvmx_usb_internal_state *)state; CVMX_PREFETCH(usb, 0); CVMX_PREFETCH(usb, 1*128); -- GitLab From 47509e4a9c17e71a5ab61b5a05aeacb4310aacae Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 30 Jul 2013 23:43:11 +0300 Subject: [PATCH 434/942] staging: octeon-usb: cvmx_usb_control_header_t -> union cvmx_usb_control_header Replace cvmx_usb_control_header_t with union cvmx_usb_control_header. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/cvmx-usb.c | 12 +++++++---- drivers/staging/octeon-usb/cvmx-usb.h | 31 ++++++++++++++++----------- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/drivers/staging/octeon-usb/cvmx-usb.c b/drivers/staging/octeon-usb/cvmx-usb.c index 3cc315ded3f9f..8a9d94b80ea07 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.c +++ b/drivers/staging/octeon-usb/cvmx-usb.c @@ -1448,7 +1448,8 @@ static void __cvmx_usb_start_channel_control(struct cvmx_usb_internal_state *usb struct cvmx_usb_pipe *pipe) { struct cvmx_usb_transaction *transaction = pipe->head; - cvmx_usb_control_header_t *header = cvmx_phys_to_ptr(transaction->control_header); + union cvmx_usb_control_header *header = + cvmx_phys_to_ptr(transaction->control_header); int bytes_to_transfer = transaction->buffer_length - transaction->actual_bytes; int packets_to_transfer; cvmx_usbcx_hctsizx_t usbc_hctsiz; @@ -2319,7 +2320,8 @@ int cvmx_usb_submit_control(struct cvmx_usb_state *state, int pipe_handle, { int submit_handle; struct cvmx_usb_internal_state *usb = (struct cvmx_usb_internal_state *)state; - cvmx_usb_control_header_t *header = cvmx_phys_to_ptr(control_header); + union cvmx_usb_control_header *header = + cvmx_phys_to_ptr(control_header); /* Pipe handle checking is done later in a common place */ if (unlikely(!control_header)) @@ -2884,7 +2886,8 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_internal_state *usb, int chan if (__cvmx_usb_pipe_needs_split(usb, pipe)) transaction->stage = CVMX_USB_STAGE_SETUP_SPLIT_COMPLETE; else { - cvmx_usb_control_header_t *header = cvmx_phys_to_ptr(transaction->control_header); + union cvmx_usb_control_header *header = + cvmx_phys_to_ptr(transaction->control_header); if (header->s.length) transaction->stage = CVMX_USB_STAGE_DATA; else @@ -2893,7 +2896,8 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_internal_state *usb, int chan break; case CVMX_USB_STAGE_SETUP_SPLIT_COMPLETE: { - cvmx_usb_control_header_t *header = cvmx_phys_to_ptr(transaction->control_header); + union cvmx_usb_control_header *header = + cvmx_phys_to_ptr(transaction->control_header); if (header->s.length) transaction->stage = CVMX_USB_STAGE_DATA; else diff --git a/drivers/staging/octeon-usb/cvmx-usb.h b/drivers/staging/octeon-usb/cvmx-usb.h index bd6a2fb07489c..8bf36966ef15d 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.h +++ b/drivers/staging/octeon-usb/cvmx-usb.h @@ -335,20 +335,25 @@ struct cvmx_usb_port_status { }; /** - * This is the structure of a Control packet header + * union cvmx_usb_control_header - the structure of a Control packet header + * + * @s.request_type: Bit 7 tells the direction: 1=IN, 0=OUT + * @s.request The standard usb request to make + * @s.value Value parameter for the request in little endian format + * @s.index Index for the request in little endian format + * @s.length Length of the data associated with this request in + * little endian format */ -typedef union -{ - uint64_t u64; - struct - { - uint64_t request_type : 8; /**< Bit 7 tells the direction: 1=IN, 0=OUT */ - uint64_t request : 8; /**< The standard usb request to make */ - uint64_t value : 16; /**< Value parameter for the request in little endian format */ - uint64_t index : 16; /**< Index for the request in little endian format */ - uint64_t length : 16; /**< Length of the data associated with this request in little endian format */ - } s; -} cvmx_usb_control_header_t; +union cvmx_usb_control_header { + uint64_t u64; + struct { + uint64_t request_type : 8; + uint64_t request : 8; + uint64_t value : 16; + uint64_t index : 16; + uint64_t length : 16; + } s; +}; /** * struct cvmx_usb_iso_packet - descriptor for Isochronous packets -- GitLab From b9cc16c03dab5c43ad962b064f0b76a79a4bb5cb Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Tue, 30 Jul 2013 23:43:12 +0300 Subject: [PATCH 435/942] staging: octeon-usb: eliminate remaining typedef unions Remaining typedef unions can be trivially eliminated with the pattern: foo_t -> union foo Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/cvmx-usb.c | 136 +++++++++---------- drivers/staging/octeon-usb/cvmx-usbcx-defs.h | 23 ---- drivers/staging/octeon-usb/cvmx-usbnx-defs.h | 2 - 3 files changed, 68 insertions(+), 93 deletions(-) diff --git a/drivers/staging/octeon-usb/cvmx-usb.c b/drivers/staging/octeon-usb/cvmx-usb.c index 8a9d94b80ea07..d7b3c82b5ead0 100644 --- a/drivers/staging/octeon-usb/cvmx-usb.c +++ b/drivers/staging/octeon-usb/cvmx-usb.c @@ -254,7 +254,7 @@ struct cvmx_usb_internal_state { int init_flags; int index; int idle_hardware_channels; - cvmx_usbcx_hprt_t usbcx_hprt; + union cvmx_usbcx_hprt usbcx_hprt; struct cvmx_usb_pipe *pipe_for_channel[MAX_CHANNELS]; struct cvmx_usb_transaction *free_transaction_head; struct cvmx_usb_transaction *free_transaction_tail; @@ -561,8 +561,8 @@ static inline void __cvmx_usb_remove_pipe(struct cvmx_usb_pipe_list *list, struc int cvmx_usb_initialize(struct cvmx_usb_state *state, int usb_port_number, enum cvmx_usb_initialize_flags flags) { - cvmx_usbnx_clk_ctl_t usbn_clk_ctl; - cvmx_usbnx_usbp_ctl_status_t usbn_usbp_ctl_status; + union cvmx_usbnx_clk_ctl usbn_clk_ctl; + union cvmx_usbnx_usbp_ctl_status usbn_usbp_ctl_status; struct cvmx_usb_internal_state *usb = (struct cvmx_usb_internal_state *)state; usb->init_flags = flags; @@ -776,7 +776,7 @@ int cvmx_usb_initialize(struct cvmx_usb_state *state, int usb_port_number, * Global interrupt mask, USBC_GAHBCFG[GLBLINTRMSK] = 1 */ { - cvmx_usbcx_gahbcfg_t usbcx_gahbcfg; + union cvmx_usbcx_gahbcfg usbcx_gahbcfg; /* Due to an errata, CN31XX doesn't support DMA */ if (OCTEON_IS_MODEL(OCTEON_CN31XX)) usb->init_flags |= CVMX_USB_INITIALIZE_FLAGS_NO_DMA; @@ -803,7 +803,7 @@ int cvmx_usb_initialize(struct cvmx_usb_state *state, int usb_port_number, * PHY low-power clock select, USBC_GUSBCFG[PHYLPWRCLKSEL] = 0 */ { - cvmx_usbcx_gusbcfg_t usbcx_gusbcfg; + union cvmx_usbcx_gusbcfg usbcx_gusbcfg; usbcx_gusbcfg.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_GUSBCFG(usb->index)); usbcx_gusbcfg.s.toutcal = 0; usbcx_gusbcfg.s.ddrsel = 0; @@ -819,7 +819,7 @@ int cvmx_usb_initialize(struct cvmx_usb_state *state, int usb_port_number, * Mode mismatch interrupt mask, USBC_GINTMSK[MODEMISMSK] = 1 */ { - cvmx_usbcx_gintmsk_t usbcx_gintmsk; + union cvmx_usbcx_gintmsk usbcx_gintmsk; int channel; usbcx_gintmsk.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_GINTMSK(usb->index)); @@ -845,16 +845,16 @@ int cvmx_usb_initialize(struct cvmx_usb_state *state, int usb_port_number, * 1. Program the host-port interrupt-mask field to unmask, * USBC_GINTMSK[PRTINT] = 1 */ - USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), cvmx_usbcx_gintmsk_t, + USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), union cvmx_usbcx_gintmsk, prtintmsk, 1); - USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), cvmx_usbcx_gintmsk_t, + USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), union cvmx_usbcx_gintmsk, disconnintmsk, 1); /* * 2. Program the USBC_HCFG register to select full-speed host * or high-speed host. */ { - cvmx_usbcx_hcfg_t usbcx_hcfg; + union cvmx_usbcx_hcfg usbcx_hcfg; usbcx_hcfg.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCFG(usb->index)); usbcx_hcfg.s.fslssupp = 0; usbcx_hcfg.s.fslspclksel = 0; @@ -864,7 +864,7 @@ int cvmx_usb_initialize(struct cvmx_usb_state *state, int usb_port_number, * 3. Program the port power bit to drive VBUS on the USB, * USBC_HPRT[PRTPWR] = 1 */ - USB_SET_FIELD32(CVMX_USBCX_HPRT(usb->index), cvmx_usbcx_hprt_t, prtpwr, 1); + USB_SET_FIELD32(CVMX_USBCX_HPRT(usb->index), union cvmx_usbcx_hprt, prtpwr, 1); /* * Steps 4-15 from the manual are done later in the port enable @@ -887,7 +887,7 @@ int cvmx_usb_initialize(struct cvmx_usb_state *state, int usb_port_number, */ int cvmx_usb_shutdown(struct cvmx_usb_state *state) { - cvmx_usbnx_clk_ctl_t usbn_clk_ctl; + union cvmx_usbnx_clk_ctl usbn_clk_ctl; struct cvmx_usb_internal_state *usb = (struct cvmx_usb_internal_state *)state; /* Make sure all pipes are closed */ @@ -922,7 +922,7 @@ int cvmx_usb_shutdown(struct cvmx_usb_state *state) */ int cvmx_usb_enable(struct cvmx_usb_state *state) { - cvmx_usbcx_ghwcfg3_t usbcx_ghwcfg3; + union cvmx_usbcx_ghwcfg3 usbcx_ghwcfg3; struct cvmx_usb_internal_state *usb = (struct cvmx_usb_internal_state *)state; usb->usbcx_hprt.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HPRT(usb->index)); @@ -940,7 +940,7 @@ int cvmx_usb_enable(struct cvmx_usb_state *state) } /* Program the port reset bit to start the reset process */ - USB_SET_FIELD32(CVMX_USBCX_HPRT(usb->index), cvmx_usbcx_hprt_t, prtrst, 1); + USB_SET_FIELD32(CVMX_USBCX_HPRT(usb->index), union cvmx_usbcx_hprt, prtrst, 1); /* * Wait at least 50ms (high speed), or 10ms (full speed) for the reset @@ -949,10 +949,10 @@ int cvmx_usb_enable(struct cvmx_usb_state *state) mdelay(50); /* Program the port reset bit to 0, USBC_HPRT[PRTRST] = 0 */ - USB_SET_FIELD32(CVMX_USBCX_HPRT(usb->index), cvmx_usbcx_hprt_t, prtrst, 0); + USB_SET_FIELD32(CVMX_USBCX_HPRT(usb->index), union cvmx_usbcx_hprt, prtrst, 0); /* Wait for the USBC_HPRT[PRTENA]. */ - if (CVMX_WAIT_FOR_FIELD32(CVMX_USBCX_HPRT(usb->index), cvmx_usbcx_hprt_t, + if (CVMX_WAIT_FOR_FIELD32(CVMX_USBCX_HPRT(usb->index), union cvmx_usbcx_hprt, prtena, ==, 1, 100000)) return -ETIMEDOUT; @@ -964,7 +964,7 @@ int cvmx_usb_enable(struct cvmx_usb_state *state) * 13. Program the USBC_GRXFSIZ register to select the size of the * receive FIFO (25%). */ - USB_SET_FIELD32(CVMX_USBCX_GRXFSIZ(usb->index), cvmx_usbcx_grxfsiz_t, + USB_SET_FIELD32(CVMX_USBCX_GRXFSIZ(usb->index), union cvmx_usbcx_grxfsiz, rxfdep, usbcx_ghwcfg3.s.dfifodepth / 4); /* * 14. Program the USBC_GNPTXFSIZ register to select the size and the @@ -972,7 +972,7 @@ int cvmx_usb_enable(struct cvmx_usb_state *state) * transactions (50%). */ { - cvmx_usbcx_gnptxfsiz_t siz; + union cvmx_usbcx_gnptxfsiz siz; siz.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_GNPTXFSIZ(usb->index)); siz.s.nptxfdep = usbcx_ghwcfg3.s.dfifodepth / 2; siz.s.nptxfstaddr = usbcx_ghwcfg3.s.dfifodepth / 4; @@ -984,19 +984,19 @@ int cvmx_usb_enable(struct cvmx_usb_state *state) * (25%). */ { - cvmx_usbcx_hptxfsiz_t siz; + union cvmx_usbcx_hptxfsiz siz; siz.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HPTXFSIZ(usb->index)); siz.s.ptxfsize = usbcx_ghwcfg3.s.dfifodepth / 4; siz.s.ptxfstaddr = 3 * usbcx_ghwcfg3.s.dfifodepth / 4; __cvmx_usb_write_csr32(usb, CVMX_USBCX_HPTXFSIZ(usb->index), siz.u32); } /* Flush all FIFOs */ - USB_SET_FIELD32(CVMX_USBCX_GRSTCTL(usb->index), cvmx_usbcx_grstctl_t, txfnum, 0x10); - USB_SET_FIELD32(CVMX_USBCX_GRSTCTL(usb->index), cvmx_usbcx_grstctl_t, txfflsh, 1); - CVMX_WAIT_FOR_FIELD32(CVMX_USBCX_GRSTCTL(usb->index), cvmx_usbcx_grstctl_t, + USB_SET_FIELD32(CVMX_USBCX_GRSTCTL(usb->index), union cvmx_usbcx_grstctl, txfnum, 0x10); + USB_SET_FIELD32(CVMX_USBCX_GRSTCTL(usb->index), union cvmx_usbcx_grstctl, txfflsh, 1); + CVMX_WAIT_FOR_FIELD32(CVMX_USBCX_GRSTCTL(usb->index), union cvmx_usbcx_grstctl, txfflsh, ==, 0, 100); - USB_SET_FIELD32(CVMX_USBCX_GRSTCTL(usb->index), cvmx_usbcx_grstctl_t, rxfflsh, 1); - CVMX_WAIT_FOR_FIELD32(CVMX_USBCX_GRSTCTL(usb->index), cvmx_usbcx_grstctl_t, + USB_SET_FIELD32(CVMX_USBCX_GRSTCTL(usb->index), union cvmx_usbcx_grstctl, rxfflsh, 1); + CVMX_WAIT_FOR_FIELD32(CVMX_USBCX_GRSTCTL(usb->index), union cvmx_usbcx_grstctl, rxfflsh, ==, 0, 100); return 0; @@ -1019,7 +1019,7 @@ int cvmx_usb_disable(struct cvmx_usb_state *state) struct cvmx_usb_internal_state *usb = (struct cvmx_usb_internal_state *)state; /* Disable the port */ - USB_SET_FIELD32(CVMX_USBCX_HPRT(usb->index), cvmx_usbcx_hprt_t, prtena, 1); + USB_SET_FIELD32(CVMX_USBCX_HPRT(usb->index), union cvmx_usbcx_hprt, prtena, 1); return 0; } @@ -1040,7 +1040,7 @@ int cvmx_usb_disable(struct cvmx_usb_state *state) */ struct cvmx_usb_port_status cvmx_usb_get_status(struct cvmx_usb_state *state) { - cvmx_usbcx_hprt_t usbc_hprt; + union cvmx_usbcx_hprt usbc_hprt; struct cvmx_usb_port_status result; struct cvmx_usb_internal_state *usb = (struct cvmx_usb_internal_state *)state; @@ -1261,7 +1261,7 @@ int cvmx_usb_open_pipe(struct cvmx_usb_state *state, enum cvmx_usb_pipe_flags fl */ static void __cvmx_usb_poll_rx_fifo(struct cvmx_usb_internal_state *usb) { - cvmx_usbcx_grxstsph_t rx_status; + union cvmx_usbcx_grxstsph rx_status; int channel; int bytes; uint64_t address; @@ -1365,21 +1365,21 @@ static int __cvmx_usb_fill_tx_hw(struct cvmx_usb_internal_state *usb, struct cvm static void __cvmx_usb_poll_tx_fifo(struct cvmx_usb_internal_state *usb) { if (usb->periodic.head != usb->periodic.tail) { - cvmx_usbcx_hptxsts_t tx_status; + union cvmx_usbcx_hptxsts tx_status; tx_status.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HPTXSTS(usb->index)); if (__cvmx_usb_fill_tx_hw(usb, &usb->periodic, tx_status.s.ptxfspcavail)) - USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), cvmx_usbcx_gintmsk_t, ptxfempmsk, 1); + USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), union cvmx_usbcx_gintmsk, ptxfempmsk, 1); else - USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), cvmx_usbcx_gintmsk_t, ptxfempmsk, 0); + USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), union cvmx_usbcx_gintmsk, ptxfempmsk, 0); } if (usb->nonperiodic.head != usb->nonperiodic.tail) { - cvmx_usbcx_gnptxsts_t tx_status; + union cvmx_usbcx_gnptxsts tx_status; tx_status.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_GNPTXSTS(usb->index)); if (__cvmx_usb_fill_tx_hw(usb, &usb->nonperiodic, tx_status.s.nptxfspcavail)) - USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), cvmx_usbcx_gintmsk_t, nptxfempmsk, 1); + USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), union cvmx_usbcx_gintmsk, nptxfempmsk, 1); else - USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), cvmx_usbcx_gintmsk_t, nptxfempmsk, 0); + USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), union cvmx_usbcx_gintmsk, nptxfempmsk, 0); } return; @@ -1395,9 +1395,9 @@ static void __cvmx_usb_poll_tx_fifo(struct cvmx_usb_internal_state *usb) */ static void __cvmx_usb_fill_tx_fifo(struct cvmx_usb_internal_state *usb, int channel) { - cvmx_usbcx_hccharx_t hcchar; - cvmx_usbcx_hcspltx_t usbc_hcsplt; - cvmx_usbcx_hctsizx_t usbc_hctsiz; + union cvmx_usbcx_hccharx hcchar; + union cvmx_usbcx_hcspltx usbc_hcsplt; + union cvmx_usbcx_hctsizx usbc_hctsiz; struct cvmx_usb_tx_fifo *fifo; /* We only need to fill data on outbound channels */ @@ -1452,7 +1452,7 @@ static void __cvmx_usb_start_channel_control(struct cvmx_usb_internal_state *usb cvmx_phys_to_ptr(transaction->control_header); int bytes_to_transfer = transaction->buffer_length - transaction->actual_bytes; int packets_to_transfer; - cvmx_usbcx_hctsizx_t usbc_hctsiz; + union cvmx_usbcx_hctsizx usbc_hctsiz; usbc_hctsiz.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCTSIZX(channel, usb->index)); @@ -1465,7 +1465,7 @@ static void __cvmx_usb_start_channel_control(struct cvmx_usb_internal_state *usb usbc_hctsiz.s.pid = 3; /* Setup */ bytes_to_transfer = sizeof(*header); /* All Control operations start with a setup going OUT */ - USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index), cvmx_usbcx_hccharx_t, epdir, CVMX_USB_DIRECTION_OUT); + USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index), union cvmx_usbcx_hccharx, epdir, CVMX_USB_DIRECTION_OUT); /* * Setup send the control header instead of the buffer data. The * buffer data will be used in the next stage @@ -1476,8 +1476,8 @@ static void __cvmx_usb_start_channel_control(struct cvmx_usb_internal_state *usb usbc_hctsiz.s.pid = 3; /* Setup */ bytes_to_transfer = 0; /* All Control operations start with a setup going OUT */ - USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index), cvmx_usbcx_hccharx_t, epdir, CVMX_USB_DIRECTION_OUT); - USB_SET_FIELD32(CVMX_USBCX_HCSPLTX(channel, usb->index), cvmx_usbcx_hcspltx_t, compsplt, 1); + USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index), union cvmx_usbcx_hccharx, epdir, CVMX_USB_DIRECTION_OUT); + USB_SET_FIELD32(CVMX_USBCX_HCSPLTX(channel, usb->index), union cvmx_usbcx_hcspltx, compsplt, 1); break; case CVMX_USB_STAGE_DATA: usbc_hctsiz.s.pid = __cvmx_usb_get_data_pid(pipe); @@ -1488,7 +1488,7 @@ static void __cvmx_usb_start_channel_control(struct cvmx_usb_internal_state *usb bytes_to_transfer = pipe->max_packet; } USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index), - cvmx_usbcx_hccharx_t, epdir, + union cvmx_usbcx_hccharx, epdir, ((header->s.request_type & 0x80) ? CVMX_USB_DIRECTION_IN : CVMX_USB_DIRECTION_OUT)); @@ -1498,16 +1498,16 @@ static void __cvmx_usb_start_channel_control(struct cvmx_usb_internal_state *usb if (!(header->s.request_type & 0x80)) bytes_to_transfer = 0; USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index), - cvmx_usbcx_hccharx_t, epdir, + union cvmx_usbcx_hccharx, epdir, ((header->s.request_type & 0x80) ? CVMX_USB_DIRECTION_IN : CVMX_USB_DIRECTION_OUT)); - USB_SET_FIELD32(CVMX_USBCX_HCSPLTX(channel, usb->index), cvmx_usbcx_hcspltx_t, compsplt, 1); + USB_SET_FIELD32(CVMX_USBCX_HCSPLTX(channel, usb->index), union cvmx_usbcx_hcspltx, compsplt, 1); break; case CVMX_USB_STAGE_STATUS: usbc_hctsiz.s.pid = __cvmx_usb_get_data_pid(pipe); bytes_to_transfer = 0; - USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index), cvmx_usbcx_hccharx_t, epdir, + USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index), union cvmx_usbcx_hccharx, epdir, ((header->s.request_type & 0x80) ? CVMX_USB_DIRECTION_OUT : CVMX_USB_DIRECTION_IN)); @@ -1515,11 +1515,11 @@ static void __cvmx_usb_start_channel_control(struct cvmx_usb_internal_state *usb case CVMX_USB_STAGE_STATUS_SPLIT_COMPLETE: usbc_hctsiz.s.pid = __cvmx_usb_get_data_pid(pipe); bytes_to_transfer = 0; - USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index), cvmx_usbcx_hccharx_t, epdir, + USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index), union cvmx_usbcx_hccharx, epdir, ((header->s.request_type & 0x80) ? CVMX_USB_DIRECTION_OUT : CVMX_USB_DIRECTION_IN)); - USB_SET_FIELD32(CVMX_USBCX_HCSPLTX(channel, usb->index), cvmx_usbcx_hcspltx_t, compsplt, 1); + USB_SET_FIELD32(CVMX_USBCX_HCSPLTX(channel, usb->index), union cvmx_usbcx_hcspltx, compsplt, 1); break; } @@ -1592,9 +1592,9 @@ static void __cvmx_usb_start_channel(struct cvmx_usb_internal_state *usb, /* Enable the channel interrupt bits */ { - cvmx_usbcx_hcintx_t usbc_hcint; - cvmx_usbcx_hcintmskx_t usbc_hcintmsk; - cvmx_usbcx_haintmsk_t usbc_haintmsk; + union cvmx_usbcx_hcintx usbc_hcint; + union cvmx_usbcx_hcintmskx usbc_hcintmsk; + union cvmx_usbcx_haintmsk usbc_haintmsk; /* Clear all channel status bits */ usbc_hcint.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCINTX(channel, usb->index)); @@ -1636,8 +1636,8 @@ static void __cvmx_usb_start_channel(struct cvmx_usb_internal_state *usb, /* Setup both the size of the transfer and the SPLIT characteristics */ { - cvmx_usbcx_hcspltx_t usbc_hcsplt = {.u32 = 0}; - cvmx_usbcx_hctsizx_t usbc_hctsiz = {.u32 = 0}; + union cvmx_usbcx_hcspltx usbc_hcsplt = {.u32 = 0}; + union cvmx_usbcx_hctsizx usbc_hctsiz = {.u32 = 0}; int packets_to_transfer; int bytes_to_transfer = transaction->buffer_length - transaction->actual_bytes; @@ -1781,7 +1781,7 @@ static void __cvmx_usb_start_channel(struct cvmx_usb_internal_state *usb, /* Setup the Host Channel Characteristics Register */ { - cvmx_usbcx_hccharx_t usbc_hcchar = {.u32 = 0}; + union cvmx_usbcx_hccharx usbc_hcchar = {.u32 = 0}; /* * Set the startframe odd/even properly. This is only used for @@ -1830,22 +1830,22 @@ static void __cvmx_usb_start_channel(struct cvmx_usb_internal_state *usb, */ if (pipe->transfer_dir == CVMX_USB_DIRECTION_OUT) { if (pipe->multi_count < 2) /* Need DATA0 */ - USB_SET_FIELD32(CVMX_USBCX_HCTSIZX(channel, usb->index), cvmx_usbcx_hctsizx_t, pid, 0); + USB_SET_FIELD32(CVMX_USBCX_HCTSIZX(channel, usb->index), union cvmx_usbcx_hctsizx, pid, 0); else /* Need MDATA */ - USB_SET_FIELD32(CVMX_USBCX_HCTSIZX(channel, usb->index), cvmx_usbcx_hctsizx_t, pid, 3); + USB_SET_FIELD32(CVMX_USBCX_HCTSIZX(channel, usb->index), union cvmx_usbcx_hctsizx, pid, 3); } } break; } { - cvmx_usbcx_hctsizx_t usbc_hctsiz = {.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCTSIZX(channel, usb->index))}; + union cvmx_usbcx_hctsizx usbc_hctsiz = {.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HCTSIZX(channel, usb->index))}; transaction->xfersize = usbc_hctsiz.s.xfersize; transaction->pktcnt = usbc_hctsiz.s.pktcnt; } /* Remeber when we start a split transaction */ if (__cvmx_usb_pipe_needs_split(usb, pipe)) usb->active_split = transaction; - USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index), cvmx_usbcx_hccharx_t, chena, 1); + USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index), union cvmx_usbcx_hccharx, chena, 1); if (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA) __cvmx_usb_fill_tx_fifo(usb, channel); return; @@ -1897,8 +1897,8 @@ static void __cvmx_usb_schedule(struct cvmx_usb_internal_state *usb, int is_sof) if (usb->init_flags & CVMX_USB_INITIALIZE_FLAGS_NO_DMA) { /* Without DMA we need to be careful to not schedule something at the end of a frame and cause an overrun */ - cvmx_usbcx_hfnum_t hfnum = {.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HFNUM(usb->index))}; - cvmx_usbcx_hfir_t hfir = {.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HFIR(usb->index))}; + union cvmx_usbcx_hfnum hfnum = {.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HFNUM(usb->index))}; + union cvmx_usbcx_hfir hfir = {.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HFIR(usb->index))}; if (hfnum.s.frrem < hfir.s.frint/4) goto done; } @@ -1949,7 +1949,7 @@ static void __cvmx_usb_schedule(struct cvmx_usb_internal_state *usb, int is_sof) pipe = pipe->next; } } - USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), cvmx_usbcx_gintmsk_t, sofmsk, need_sof); + USB_SET_FIELD32(CVMX_USBCX_GINTMSK(usb->index), union cvmx_usbcx_gintmsk, sofmsk, need_sof); return; } @@ -2476,7 +2476,7 @@ int cvmx_usb_cancel(struct cvmx_usb_state *state, int pipe_handle, int submit_ha */ if ((pipe->head == transaction) && (pipe->flags & __CVMX_USB_PIPE_FLAGS_SCHEDULED)) { - cvmx_usbcx_hccharx_t usbc_hcchar; + union cvmx_usbcx_hccharx usbc_hcchar; usb->pipe_for_channel[pipe->channel] = NULL; pipe->flags &= ~__CVMX_USB_PIPE_FLAGS_SCHEDULED; @@ -2607,7 +2607,7 @@ int cvmx_usb_get_frame_number(struct cvmx_usb_state *state) { int frame_number; struct cvmx_usb_internal_state *usb = (struct cvmx_usb_internal_state *)state; - cvmx_usbcx_hfnum_t usbc_hfnum; + union cvmx_usbcx_hfnum usbc_hfnum; usbc_hfnum.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HFNUM(usb->index)); frame_number = usbc_hfnum.s.frnum; @@ -2626,9 +2626,9 @@ int cvmx_usb_get_frame_number(struct cvmx_usb_state *state) */ static int __cvmx_usb_poll_channel(struct cvmx_usb_internal_state *usb, int channel) { - cvmx_usbcx_hcintx_t usbc_hcint; - cvmx_usbcx_hctsizx_t usbc_hctsiz; - cvmx_usbcx_hccharx_t usbc_hcchar; + union cvmx_usbcx_hcintx usbc_hcint; + union cvmx_usbcx_hctsizx usbc_hctsiz; + union cvmx_usbcx_hccharx usbc_hcchar; struct cvmx_usb_pipe *pipe; struct cvmx_usb_transaction *transaction; int bytes_this_transfer; @@ -2658,7 +2658,7 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_internal_state *usb, int chan */ if (!usbc_hcint.s.chhltd) { if (usbc_hcchar.s.chena) { - cvmx_usbcx_hcintmskx_t hcintmsk; + union cvmx_usbcx_hcintmskx hcintmsk; /* Disable all interrupts except CHHLTD */ hcintmsk.u32 = 0; hcintmsk.s.chhltdmsk = 1; @@ -3065,8 +3065,8 @@ static int __cvmx_usb_poll_channel(struct cvmx_usb_internal_state *usb, int chan */ int cvmx_usb_poll(struct cvmx_usb_state *state) { - cvmx_usbcx_hfnum_t usbc_hfnum; - cvmx_usbcx_gintsts_t usbc_gintsts; + union cvmx_usbcx_hfnum usbc_hfnum; + union cvmx_usbcx_gintsts usbc_gintsts; struct cvmx_usb_internal_state *usb = (struct cvmx_usb_internal_state *)state; CVMX_PREFETCH(usb, 0); @@ -3105,7 +3105,7 @@ int cvmx_usb_poll(struct cvmx_usb_state *state) __cvmx_usb_poll_tx_fifo(usb); } if (usbc_gintsts.s.disconnint || usbc_gintsts.s.prtint) { - cvmx_usbcx_hprt_t usbc_hprt; + union cvmx_usbcx_hprt usbc_hprt; /* * Disconnect Detected Interrupt (DisconnInt) * Asserted when a device disconnect is detected. @@ -3141,7 +3141,7 @@ int cvmx_usb_poll(struct cvmx_usb_state *state) * must clear the appropriate status bit in the HCINTn register * to clear this bit. */ - cvmx_usbcx_haint_t usbc_haint; + union cvmx_usbcx_haint usbc_haint; usbc_haint.u32 = __cvmx_usb_read_csr32(usb, CVMX_USBCX_HAINT(usb->index)); while (usbc_haint.u32) { int channel; diff --git a/drivers/staging/octeon-usb/cvmx-usbcx-defs.h b/drivers/staging/octeon-usb/cvmx-usbcx-defs.h index 394e84662ce8f..d349d77bc3596 100644 --- a/drivers/staging/octeon-usb/cvmx-usbcx-defs.h +++ b/drivers/staging/octeon-usb/cvmx-usbcx-defs.h @@ -140,7 +140,6 @@ union cvmx_usbcx_gahbcfg { uint32_t glblintrmsk : 1; } s; }; -typedef union cvmx_usbcx_gahbcfg cvmx_usbcx_gahbcfg_t; /** * cvmx_usbc#_ghwcfg3 @@ -210,7 +209,6 @@ union cvmx_usbcx_ghwcfg3 { uint32_t xfersizewidth : 4; } s; }; -typedef union cvmx_usbcx_ghwcfg3 cvmx_usbcx_ghwcfg3_t; /** * cvmx_usbc#_gintmsk @@ -299,7 +297,6 @@ union cvmx_usbcx_gintmsk { uint32_t reserved_0_0 : 1; } s; }; -typedef union cvmx_usbcx_gintmsk cvmx_usbcx_gintmsk_t; /** * cvmx_usbc#_gintsts @@ -529,7 +526,6 @@ union cvmx_usbcx_gintsts { uint32_t curmod : 1; } s; }; -typedef union cvmx_usbcx_gintsts cvmx_usbcx_gintsts_t; /** * cvmx_usbc#_gnptxfsiz @@ -556,7 +552,6 @@ union cvmx_usbcx_gnptxfsiz { uint32_t nptxfstaddr : 16; } s; }; -typedef union cvmx_usbcx_gnptxfsiz cvmx_usbcx_gnptxfsiz_t; /** * cvmx_usbc#_gnptxsts @@ -609,7 +604,6 @@ union cvmx_usbcx_gnptxsts { uint32_t nptxfspcavail : 16; } s; }; -typedef union cvmx_usbcx_gnptxsts cvmx_usbcx_gnptxsts_t; /** * cvmx_usbc#_grstctl @@ -737,7 +731,6 @@ union cvmx_usbcx_grstctl { uint32_t csftrst : 1; } s; }; -typedef union cvmx_usbcx_grstctl cvmx_usbcx_grstctl_t; /** * cvmx_usbc#_grxfsiz @@ -761,7 +754,6 @@ union cvmx_usbcx_grxfsiz { uint32_t rxfdep : 16; } s; }; -typedef union cvmx_usbcx_grxfsiz cvmx_usbcx_grxfsiz_t; /** * cvmx_usbc#_grxstsph @@ -807,7 +799,6 @@ union cvmx_usbcx_grxstsph { uint32_t chnum : 4; } s; }; -typedef union cvmx_usbcx_grxstsph cvmx_usbcx_grxstsph_t; /** * cvmx_usbc#_gusbcfg @@ -896,7 +887,6 @@ union cvmx_usbcx_gusbcfg { uint32_t toutcal : 3; } s; }; -typedef union cvmx_usbcx_gusbcfg cvmx_usbcx_gusbcfg_t; /** * cvmx_usbc#_haint @@ -922,7 +912,6 @@ union cvmx_usbcx_haint { uint32_t haint : 16; } s; }; -typedef union cvmx_usbcx_haint cvmx_usbcx_haint_t; /** * cvmx_usbc#_haintmsk @@ -947,7 +936,6 @@ union cvmx_usbcx_haintmsk { uint32_t haintmsk : 16; } s; }; -typedef union cvmx_usbcx_haintmsk cvmx_usbcx_haintmsk_t; /** * cvmx_usbc#_hcchar# @@ -1027,7 +1015,6 @@ union cvmx_usbcx_hccharx { uint32_t mps : 11; } s; }; -typedef union cvmx_usbcx_hccharx cvmx_usbcx_hccharx_t; /** * cvmx_usbc#_hcfg @@ -1075,7 +1062,6 @@ union cvmx_usbcx_hcfg { uint32_t fslspclksel : 2; } s; }; -typedef union cvmx_usbcx_hcfg cvmx_usbcx_hcfg_t; /** * cvmx_usbc#_hcint# @@ -1126,7 +1112,6 @@ union cvmx_usbcx_hcintx { uint32_t xfercompl : 1; } s; }; -typedef union cvmx_usbcx_hcintx cvmx_usbcx_hcintx_t; /** * cvmx_usbc#_hcintmsk# @@ -1168,7 +1153,6 @@ union cvmx_usbcx_hcintmskx { uint32_t xfercomplmsk : 1; } s; }; -typedef union cvmx_usbcx_hcintmskx cvmx_usbcx_hcintmskx_t; /** * cvmx_usbc#_hcsplt# @@ -1213,7 +1197,6 @@ union cvmx_usbcx_hcspltx { uint32_t prtaddr : 7; } s; }; -typedef union cvmx_usbcx_hcspltx cvmx_usbcx_hcspltx_t; /** * cvmx_usbc#_hctsiz# @@ -1257,7 +1240,6 @@ union cvmx_usbcx_hctsizx { uint32_t xfersize : 19; } s; }; -typedef union cvmx_usbcx_hctsizx cvmx_usbcx_hctsizx_t; /** * cvmx_usbc#_hfir @@ -1293,7 +1275,6 @@ union cvmx_usbcx_hfir { uint32_t frint : 16; } s; }; -typedef union cvmx_usbcx_hfir cvmx_usbcx_hfir_t; /** * cvmx_usbc#_hfnum @@ -1323,7 +1304,6 @@ union cvmx_usbcx_hfnum { uint32_t frnum : 16; } s; }; -typedef union cvmx_usbcx_hfnum cvmx_usbcx_hfnum_t; /** * cvmx_usbc#_hprt @@ -1464,7 +1444,6 @@ union cvmx_usbcx_hprt { uint32_t prtconnsts : 1; } s; }; -typedef union cvmx_usbcx_hprt cvmx_usbcx_hprt_t; /** * cvmx_usbc#_hptxfsiz @@ -1489,7 +1468,6 @@ union cvmx_usbcx_hptxfsiz { uint32_t ptxfstaddr : 16; } s; }; -typedef union cvmx_usbcx_hptxfsiz cvmx_usbcx_hptxfsiz_t; /** * cvmx_usbc#_hptxsts @@ -1546,6 +1524,5 @@ union cvmx_usbcx_hptxsts { uint32_t ptxfspcavail : 16; } s; }; -typedef union cvmx_usbcx_hptxsts cvmx_usbcx_hptxsts_t; #endif diff --git a/drivers/staging/octeon-usb/cvmx-usbnx-defs.h b/drivers/staging/octeon-usb/cvmx-usbnx-defs.h index 96d706770fc65..e06aafa5726af 100644 --- a/drivers/staging/octeon-usb/cvmx-usbnx-defs.h +++ b/drivers/staging/octeon-usb/cvmx-usbnx-defs.h @@ -337,7 +337,6 @@ union cvmx_usbnx_clk_ctl { struct cvmx_usbnx_clk_ctl_cn50xx cn52xx; struct cvmx_usbnx_clk_ctl_cn50xx cn56xx; }; -typedef union cvmx_usbnx_clk_ctl cvmx_usbnx_clk_ctl_t; /** * cvmx_usbn#_usbp_ctl_status @@ -882,6 +881,5 @@ union cvmx_usbnx_usbp_ctl_status { uint64_t ate_reset : 1; } cn52xx; }; -typedef union cvmx_usbnx_usbp_ctl_status cvmx_usbnx_usbp_ctl_status_t; #endif -- GitLab From 0b99d58902dd82fa51216eb8e0d6ddd8c43e90e4 Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Thu, 1 Aug 2013 17:00:20 -0400 Subject: [PATCH 436/942] staging: dgnc: add dgnc digi driver This patch adds the DGNC driver. This is a TTY Serial Port Driver for the Digi International Neo and Classic PCI based product line by Digi International . This driver isn't hooked up to the build system because it doesn't build, it merely adds the driver written by Digi to the kernel tree so that it can be cleaned up and fixed up properly over time. Cc: Mark Hounschell Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/Kconfig | 6 + drivers/staging/dgnc/Makefile | 7 + drivers/staging/dgnc/Makefile.inc | 133 + drivers/staging/dgnc/dgnc_cls.c | 1412 +++++++++++ drivers/staging/dgnc/dgnc_cls.h | 90 + drivers/staging/dgnc/dgnc_driver.c | 1028 ++++++++ drivers/staging/dgnc/dgnc_driver.h | 566 +++++ drivers/staging/dgnc/dgnc_kcompat.h | 91 + drivers/staging/dgnc/dgnc_mgmt.c | 313 +++ drivers/staging/dgnc/dgnc_mgmt.h | 37 + drivers/staging/dgnc/dgnc_neo.c | 1977 +++++++++++++++ drivers/staging/dgnc/dgnc_neo.h | 157 ++ drivers/staging/dgnc/dgnc_pci.h | 77 + drivers/staging/dgnc/dgnc_proc.c | 1551 ++++++++++++ drivers/staging/dgnc/dgnc_proc.h | 147 ++ drivers/staging/dgnc/dgnc_sysfs.c | 761 ++++++ drivers/staging/dgnc/dgnc_sysfs.h | 49 + drivers/staging/dgnc/dgnc_trace.c | 187 ++ drivers/staging/dgnc/dgnc_trace.h | 45 + drivers/staging/dgnc/dgnc_tty.c | 3648 +++++++++++++++++++++++++++ drivers/staging/dgnc/dgnc_tty.h | 42 + drivers/staging/dgnc/dgnc_types.h | 36 + drivers/staging/dgnc/digi.h | 419 +++ drivers/staging/dgnc/dpacompat.h | 115 + 24 files changed, 12894 insertions(+) create mode 100644 drivers/staging/dgnc/Kconfig create mode 100644 drivers/staging/dgnc/Makefile create mode 100644 drivers/staging/dgnc/Makefile.inc create mode 100644 drivers/staging/dgnc/dgnc_cls.c create mode 100644 drivers/staging/dgnc/dgnc_cls.h create mode 100644 drivers/staging/dgnc/dgnc_driver.c create mode 100644 drivers/staging/dgnc/dgnc_driver.h create mode 100644 drivers/staging/dgnc/dgnc_kcompat.h create mode 100644 drivers/staging/dgnc/dgnc_mgmt.c create mode 100644 drivers/staging/dgnc/dgnc_mgmt.h create mode 100644 drivers/staging/dgnc/dgnc_neo.c create mode 100644 drivers/staging/dgnc/dgnc_neo.h create mode 100644 drivers/staging/dgnc/dgnc_pci.h create mode 100644 drivers/staging/dgnc/dgnc_proc.c create mode 100644 drivers/staging/dgnc/dgnc_proc.h create mode 100644 drivers/staging/dgnc/dgnc_sysfs.c create mode 100644 drivers/staging/dgnc/dgnc_sysfs.h create mode 100644 drivers/staging/dgnc/dgnc_trace.c create mode 100644 drivers/staging/dgnc/dgnc_trace.h create mode 100644 drivers/staging/dgnc/dgnc_tty.c create mode 100644 drivers/staging/dgnc/dgnc_tty.h create mode 100644 drivers/staging/dgnc/dgnc_types.h create mode 100644 drivers/staging/dgnc/digi.h create mode 100644 drivers/staging/dgnc/dpacompat.h diff --git a/drivers/staging/dgnc/Kconfig b/drivers/staging/dgnc/Kconfig new file mode 100644 index 0000000000000..23daaa5d520ee --- /dev/null +++ b/drivers/staging/dgnc/Kconfig @@ -0,0 +1,6 @@ +config DGNC + tristate "Digi Neo and Classic PCI Products" + default n + depends on TTY + ---help--- + Driver for the Digi International Neo and Classic PCI based product line. diff --git a/drivers/staging/dgnc/Makefile b/drivers/staging/dgnc/Makefile new file mode 100644 index 0000000000000..c4c96dc5a5414 --- /dev/null +++ b/drivers/staging/dgnc/Makefile @@ -0,0 +1,7 @@ +EXTRA_CFLAGS += -DDG_NAME=\"dgnc-1.3-16\" -DDG_PART=\"40002369_F\" + +obj-$(CONFIG_DGNC) += dgnc.o + +dgnc-objs := dgnc_cls.o dgnc_driver.o\ + dgnc_mgmt.o dgnc_neo.o\ + dgnc_proc.o dgnc_trace.o dgnc_tty.o dgnc_sysfs.o diff --git a/drivers/staging/dgnc/Makefile.inc b/drivers/staging/dgnc/Makefile.inc new file mode 100644 index 0000000000000..6ca38c731c390 --- /dev/null +++ b/drivers/staging/dgnc/Makefile.inc @@ -0,0 +1,133 @@ +# +# From Makefile.inc +# + +# +# Common definitions go here. +# + +# +# TRUE_VERSION is the version string used in the driver build, +# it is intended to be in the form: +# +# 2.0-0 +# +# A string noting a particular special modification could be +# used as well. This string will be reported when the driver +# is loaded, and will be exposed by its /proc/dgnc/info +# interface. +# +TRUE_VERSION="1.3-16" + +# +# DGNC_PART_NUM is the part number string for the driver package. +# It should be in the form: +# +# 40002369_A +# +DGNC_PART_NUM=40002369_F + +# +# DGNC_REL_NOTE is the part number string for the driver release +# notes. It should be in the form: +# +# 93000517_A +# +DGNC_REL_NOTE=93000517_F + +# +# DGNC_PKG_VER is the "version" number string included in the +# various documentation and packaging files. It should be +# in the form: +# +# 1.0 +# +DGNC_PKG_VER=1.3 + +# +# DGNC_PKG_REV is the "revision" of this version. Together, +# a linux module revision is built with: +# +# ${DGNC_PKG_VER}-${DGNC_PKG_REV} +# +DGNC_PKG_REV=16 + +# +# DRP_PKG_DATE is the "date" string included in (for now) the +# release notes. It should be in the form: +# +# 11/04/2003 +# +DGNC_PKG_DATE=10/17/2008 + +INIT_DIR= $(shell \ + if [ -d /etc/rc.d/init.d ]; \ + then echo "$(RPM_BUILD_ROOT)/etc/rc.d/init.d"; \ + else echo "$(RPM_BUILD_ROOT)/etc/init.d"; fi) + +# +# Miscelaneous path macro's +# + +PACKAGE= dgnc +DEVDIR= /dev/dg/$(PACKAGE) +SRCDIR= /usr/src/dg/$(PACKAGE) +BINDIR= /usr/bin +DRVLIBDIR= /etc/$(PACKAGE) +MANDIR= /usr/man +USRLIBDIR= /usr/lib +DGNCDIR= /etc/dgnc + + +INIT_DIR= $(shell \ + if [ -d /etc/rc.d/init.d ]; \ + then echo "/etc/rc.d/init.d"; \ + else echo "/etc/init.d"; fi) + + +# +# From Makefile +# +ifndef MYPWD +MYPWD = $(shell pwd) +endif + +ifeq ($(KERNDIR),) + KERNVERS := $(shell uname -r) + KERNDIR :=/lib/modules/${KERNVERS}/ +endif + +# Grab version and other important stuff + +RPMNAME := $(PACKAGE)-$(TRUE_VERSION) + +PARTNUM := $(DGNC_PART_NUM) + +RELNOTES := $(DGNC_REL_NOTE) + +MODDIR = $(shell echo $(BUILDROOT)/lib/modules/3.4.36-lcrs/misc) +LSMOD = /sbin/lsmod +RMMOD = /sbin/rmmod +INSMOD = /sbin/insmod +NEW_TTY_LOCKING = No +NEW_TTY_BUFFERING = No +REGISTER_TTYS_WITH_SYSFS = No + +# Send in some extra things... +EXTRA_CFLAGS += -I${MYPWD} -I${MYPWD}/include -I${MYPWD}/../../commoninc\ + -I${MYPWD}/../../dpa -DLINUX -DDG_NAME=\"$(RPMNAME)\"\ + -DDG_PART=\"$(PARTNUM)\" -DDGNC_TRACER + +ifeq ($(NEW_TTY_LOCKING),Yes) + EXTRA_CFLAGS += -DNEW_TTY_LOCKING +endif + +ifeq ($(NEW_TTY_BUFFERING),Yes) + EXTRA_CFLAGS += -DNEW_TTY_BUFFERING +endif + +ifeq ($(REGISTER_TTYS_WITH_SYSFS),Yes) + EXTRA_CFLAGS += -DREGISTER_TTYS_WITH_SYSFS +endif + +# Conform to correct kbuild conventions... diff --git a/drivers/staging/dgnc/dgnc_cls.c b/drivers/staging/dgnc/dgnc_cls.c new file mode 100644 index 0000000000000..83ded18e4ae23 --- /dev/null +++ b/drivers/staging/dgnc/dgnc_cls.c @@ -0,0 +1,1412 @@ +/* + * Copyright 2003 Digi International (www.digi.com) + * Scott H Kilau + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * + * NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE! + * + * This is shared code between Digi's CVS archive and the + * Linux Kernel sources. + * Changing the source just for reformatting needlessly breaks + * our CVS diff history. + * + * Send any bug fixes/changes to: Eng.Linux at digi dot com. + * Thank you. + * + * + * $Id: dgnc_cls.c,v 1.1.1.1 2009/05/20 12:19:19 markh Exp $ + */ + +#include +#include +#include /* For jiffies, task states */ +#include /* For tasklet and interrupt structs/defines */ +#include /* For udelay */ +#include /* For read[bwl]/write[bwl] */ +#include /* For struct async_serial */ +#include /* For the various UART offsets */ +#include + +#include "dgnc_driver.h" /* Driver main header file */ +#include "dgnc_cls.h" +#include "dgnc_tty.h" +#include "dgnc_trace.h" + +static inline void cls_parse_isr(struct board_t *brd, uint port); +static inline void cls_clear_break(struct channel_t *ch, int force); +static inline void cls_set_cts_flow_control(struct channel_t *ch); +static inline void cls_set_rts_flow_control(struct channel_t *ch); +static inline void cls_set_ixon_flow_control(struct channel_t *ch); +static inline void cls_set_ixoff_flow_control(struct channel_t *ch); +static inline void cls_set_no_output_flow_control(struct channel_t *ch); +static inline void cls_set_no_input_flow_control(struct channel_t *ch); +static void cls_parse_modem(struct channel_t *ch, uchar signals); +static void cls_tasklet(unsigned long data); +static void cls_vpd(struct board_t *brd); +static void cls_uart_init(struct channel_t *ch); +static void cls_uart_off(struct channel_t *ch); +static int cls_drain(struct tty_struct *tty, uint seconds); +static void cls_param(struct tty_struct *tty); +static void cls_assert_modem_signals(struct channel_t *ch); +static void cls_flush_uart_write(struct channel_t *ch); +static void cls_flush_uart_read(struct channel_t *ch); +static void cls_disable_receiver(struct channel_t *ch); +static void cls_enable_receiver(struct channel_t *ch); +static void cls_send_break(struct channel_t *ch, int msecs); +static void cls_send_start_character(struct channel_t *ch); +static void cls_send_stop_character(struct channel_t *ch); +static void cls_copy_data_from_uart_to_queue(struct channel_t *ch); +static void cls_copy_data_from_queue_to_uart(struct channel_t *ch); +static uint cls_get_uart_bytes_left(struct channel_t *ch); +static void cls_send_immediate_char(struct channel_t *ch, unsigned char); +static irqreturn_t cls_intr(int irq, void *voidbrd); + +struct board_ops dgnc_cls_ops = { + .tasklet = cls_tasklet, + .intr = cls_intr, + .uart_init = cls_uart_init, + .uart_off = cls_uart_off, + .drain = cls_drain, + .param = cls_param, + .vpd = cls_vpd, + .assert_modem_signals = cls_assert_modem_signals, + .flush_uart_write = cls_flush_uart_write, + .flush_uart_read = cls_flush_uart_read, + .disable_receiver = cls_disable_receiver, + .enable_receiver = cls_enable_receiver, + .send_break = cls_send_break, + .send_start_character = cls_send_start_character, + .send_stop_character = cls_send_stop_character, + .copy_data_from_queue_to_uart = cls_copy_data_from_queue_to_uart, + .get_uart_bytes_left = cls_get_uart_bytes_left, + .send_immediate_char = cls_send_immediate_char +}; + + +static inline void cls_set_cts_flow_control(struct channel_t *ch) +{ + uchar lcrb = readb(&ch->ch_cls_uart->lcr); + uchar ier = readb(&ch->ch_cls_uart->ier); + uchar isr_fcr = 0; + + DPR_PARAM(("Setting CTSFLOW\n")); + + /* + * The Enhanced Register Set may only be accessed when + * the Line Control Register is set to 0xBFh. + */ + writeb(UART_EXAR654_ENHANCED_REGISTER_SET, &ch->ch_cls_uart->lcr); + + isr_fcr = readb(&ch->ch_cls_uart->isr_fcr); + + /* Turn on CTS flow control, turn off IXON flow control */ + isr_fcr |= (UART_EXAR654_EFR_ECB | UART_EXAR654_EFR_CTSDSR); + isr_fcr &= ~(UART_EXAR654_EFR_IXON); + + writeb(isr_fcr, &ch->ch_cls_uart->isr_fcr); + + /* Write old LCR value back out, which turns enhanced access off */ + writeb(lcrb, &ch->ch_cls_uart->lcr); + + /* Enable interrupts for CTS flow, turn off interrupts for received XOFF chars */ + ier |= (UART_EXAR654_IER_CTSDSR); + ier &= ~(UART_EXAR654_IER_XOFF); + writeb(ier, &ch->ch_cls_uart->ier); + + /* Set the usual FIFO values */ + writeb((UART_FCR_ENABLE_FIFO), &ch->ch_cls_uart->isr_fcr); + + writeb((UART_FCR_ENABLE_FIFO | UART_16654_FCR_RXTRIGGER_56 | + UART_16654_FCR_TXTRIGGER_16 | UART_FCR_CLEAR_RCVR), + &ch->ch_cls_uart->isr_fcr); + + ch->ch_t_tlevel = 16; + +} + + +static inline void cls_set_ixon_flow_control(struct channel_t *ch) +{ + uchar lcrb = readb(&ch->ch_cls_uart->lcr); + uchar ier = readb(&ch->ch_cls_uart->ier); + uchar isr_fcr = 0; + + DPR_PARAM(("Setting IXON FLOW\n")); + + /* + * The Enhanced Register Set may only be accessed when + * the Line Control Register is set to 0xBFh. + */ + writeb(UART_EXAR654_ENHANCED_REGISTER_SET, &ch->ch_cls_uart->lcr); + + isr_fcr = readb(&ch->ch_cls_uart->isr_fcr); + + /* Turn on IXON flow control, turn off CTS flow control */ + isr_fcr |= (UART_EXAR654_EFR_ECB | UART_EXAR654_EFR_IXON); + isr_fcr &= ~(UART_EXAR654_EFR_CTSDSR); + + writeb(isr_fcr, &ch->ch_cls_uart->isr_fcr); + + /* Now set our current start/stop chars while in enhanced mode */ + writeb(ch->ch_startc, &ch->ch_cls_uart->mcr); + writeb(0, &ch->ch_cls_uart->lsr); + writeb(ch->ch_stopc, &ch->ch_cls_uart->msr); + writeb(0, &ch->ch_cls_uart->spr); + + /* Write old LCR value back out, which turns enhanced access off */ + writeb(lcrb, &ch->ch_cls_uart->lcr); + + /* Disable interrupts for CTS flow, turn on interrupts for received XOFF chars */ + ier &= ~(UART_EXAR654_IER_CTSDSR); + ier |= (UART_EXAR654_IER_XOFF); + writeb(ier, &ch->ch_cls_uart->ier); + + /* Set the usual FIFO values */ + writeb((UART_FCR_ENABLE_FIFO), &ch->ch_cls_uart->isr_fcr); + + writeb((UART_FCR_ENABLE_FIFO | UART_16654_FCR_RXTRIGGER_16 | + UART_16654_FCR_TXTRIGGER_16 | UART_FCR_CLEAR_RCVR), + &ch->ch_cls_uart->isr_fcr); + +} + + +static inline void cls_set_no_output_flow_control(struct channel_t *ch) +{ + uchar lcrb = readb(&ch->ch_cls_uart->lcr); + uchar ier = readb(&ch->ch_cls_uart->ier); + uchar isr_fcr = 0; + + DPR_PARAM(("Unsetting Output FLOW\n")); + + /* + * The Enhanced Register Set may only be accessed when + * the Line Control Register is set to 0xBFh. + */ + writeb(UART_EXAR654_ENHANCED_REGISTER_SET, &ch->ch_cls_uart->lcr); + + isr_fcr = readb(&ch->ch_cls_uart->isr_fcr); + + /* Turn off IXON flow control, turn off CTS flow control */ + isr_fcr |= (UART_EXAR654_EFR_ECB); + isr_fcr &= ~(UART_EXAR654_EFR_CTSDSR | UART_EXAR654_EFR_IXON); + + writeb(isr_fcr, &ch->ch_cls_uart->isr_fcr); + + /* Write old LCR value back out, which turns enhanced access off */ + writeb(lcrb, &ch->ch_cls_uart->lcr); + + /* Disable interrupts for CTS flow, turn off interrupts for received XOFF chars */ + ier &= ~(UART_EXAR654_IER_CTSDSR); + ier &= ~(UART_EXAR654_IER_XOFF); + writeb(ier, &ch->ch_cls_uart->ier); + + /* Set the usual FIFO values */ + writeb((UART_FCR_ENABLE_FIFO), &ch->ch_cls_uart->isr_fcr); + + writeb((UART_FCR_ENABLE_FIFO | UART_16654_FCR_RXTRIGGER_16 | + UART_16654_FCR_TXTRIGGER_16 | UART_FCR_CLEAR_RCVR), + &ch->ch_cls_uart->isr_fcr); + + ch->ch_r_watermark = 0; + ch->ch_t_tlevel = 16; + ch->ch_r_tlevel = 16; + +} + + +static inline void cls_set_rts_flow_control(struct channel_t *ch) +{ + uchar lcrb = readb(&ch->ch_cls_uart->lcr); + uchar ier = readb(&ch->ch_cls_uart->ier); + uchar isr_fcr = 0; + + DPR_PARAM(("Setting RTSFLOW\n")); + + /* + * The Enhanced Register Set may only be accessed when + * the Line Control Register is set to 0xBFh. + */ + writeb(UART_EXAR654_ENHANCED_REGISTER_SET, &ch->ch_cls_uart->lcr); + + isr_fcr = readb(&ch->ch_cls_uart->isr_fcr); + + /* Turn on RTS flow control, turn off IXOFF flow control */ + isr_fcr |= (UART_EXAR654_EFR_ECB | UART_EXAR654_EFR_RTSDTR); + isr_fcr &= ~(UART_EXAR654_EFR_IXOFF); + + writeb(isr_fcr, &ch->ch_cls_uart->isr_fcr); + + /* Write old LCR value back out, which turns enhanced access off */ + writeb(lcrb, &ch->ch_cls_uart->lcr); + + /* Enable interrupts for RTS flow */ + ier |= (UART_EXAR654_IER_RTSDTR); + writeb(ier, &ch->ch_cls_uart->ier); + + /* Set the usual FIFO values */ + writeb((UART_FCR_ENABLE_FIFO), &ch->ch_cls_uart->isr_fcr); + + writeb((UART_FCR_ENABLE_FIFO | UART_16654_FCR_RXTRIGGER_56 | + UART_16654_FCR_TXTRIGGER_16 | UART_FCR_CLEAR_RCVR), + &ch->ch_cls_uart->isr_fcr); + + + ch->ch_r_watermark = 4; + ch->ch_r_tlevel = 8; + +} + + +static inline void cls_set_ixoff_flow_control(struct channel_t *ch) +{ + uchar lcrb = readb(&ch->ch_cls_uart->lcr); + uchar ier = readb(&ch->ch_cls_uart->ier); + uchar isr_fcr = 0; + + DPR_PARAM(("Setting IXOFF FLOW\n")); + + /* + * The Enhanced Register Set may only be accessed when + * the Line Control Register is set to 0xBFh. + */ + writeb(UART_EXAR654_ENHANCED_REGISTER_SET, &ch->ch_cls_uart->lcr); + + isr_fcr = readb(&ch->ch_cls_uart->isr_fcr); + + /* Turn on IXOFF flow control, turn off RTS flow control */ + isr_fcr |= (UART_EXAR654_EFR_ECB | UART_EXAR654_EFR_IXOFF); + isr_fcr &= ~(UART_EXAR654_EFR_RTSDTR); + + writeb(isr_fcr, &ch->ch_cls_uart->isr_fcr); + + /* Now set our current start/stop chars while in enhanced mode */ + writeb(ch->ch_startc, &ch->ch_cls_uart->mcr); + writeb(0, &ch->ch_cls_uart->lsr); + writeb(ch->ch_stopc, &ch->ch_cls_uart->msr); + writeb(0, &ch->ch_cls_uart->spr); + + /* Write old LCR value back out, which turns enhanced access off */ + writeb(lcrb, &ch->ch_cls_uart->lcr); + + /* Disable interrupts for RTS flow */ + ier &= ~(UART_EXAR654_IER_RTSDTR); + writeb(ier, &ch->ch_cls_uart->ier); + + /* Set the usual FIFO values */ + writeb((UART_FCR_ENABLE_FIFO), &ch->ch_cls_uart->isr_fcr); + + writeb((UART_FCR_ENABLE_FIFO | UART_16654_FCR_RXTRIGGER_16 | + UART_16654_FCR_TXTRIGGER_16 | UART_FCR_CLEAR_RCVR), + &ch->ch_cls_uart->isr_fcr); + +} + + +static inline void cls_set_no_input_flow_control(struct channel_t *ch) +{ + uchar lcrb = readb(&ch->ch_cls_uart->lcr); + uchar ier = readb(&ch->ch_cls_uart->ier); + uchar isr_fcr = 0; + + DPR_PARAM(("Unsetting Input FLOW\n")); + + /* + * The Enhanced Register Set may only be accessed when + * the Line Control Register is set to 0xBFh. + */ + writeb(UART_EXAR654_ENHANCED_REGISTER_SET, &ch->ch_cls_uart->lcr); + + isr_fcr = readb(&ch->ch_cls_uart->isr_fcr); + + /* Turn off IXOFF flow control, turn off RTS flow control */ + isr_fcr |= (UART_EXAR654_EFR_ECB); + isr_fcr &= ~(UART_EXAR654_EFR_RTSDTR | UART_EXAR654_EFR_IXOFF); + + writeb(isr_fcr, &ch->ch_cls_uart->isr_fcr); + + /* Write old LCR value back out, which turns enhanced access off */ + writeb(lcrb, &ch->ch_cls_uart->lcr); + + /* Disable interrupts for RTS flow */ + ier &= ~(UART_EXAR654_IER_RTSDTR); + writeb(ier, &ch->ch_cls_uart->ier); + + /* Set the usual FIFO values */ + writeb((UART_FCR_ENABLE_FIFO), &ch->ch_cls_uart->isr_fcr); + + writeb((UART_FCR_ENABLE_FIFO | UART_16654_FCR_RXTRIGGER_16 | + UART_16654_FCR_TXTRIGGER_16 | UART_FCR_CLEAR_RCVR), + &ch->ch_cls_uart->isr_fcr); + + ch->ch_t_tlevel = 16; + ch->ch_r_tlevel = 16; + +} + + +/* + * cls_clear_break. + * Determines whether its time to shut off break condition. + * + * No locks are assumed to be held when calling this function. + * channel lock is held and released in this function. + */ +static inline void cls_clear_break(struct channel_t *ch, int force) +{ + ulong lock_flags; + + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return; + + DGNC_LOCK(ch->ch_lock, lock_flags); + + /* Bail if we aren't currently sending a break. */ + if (!ch->ch_stop_sending_break) { + DGNC_UNLOCK(ch->ch_lock, lock_flags); + return; + } + + /* Turn break off, and unset some variables */ + if (ch->ch_flags & CH_BREAK_SENDING) { + if ((jiffies >= ch->ch_stop_sending_break) || force) { + uchar temp = readb(&ch->ch_cls_uart->lcr); + writeb((temp & ~UART_LCR_SBC), &ch->ch_cls_uart->lcr); + ch->ch_flags &= ~(CH_BREAK_SENDING); + ch->ch_stop_sending_break = 0; + DPR_IOCTL(("Finishing UART_LCR_SBC! finished: %lx\n", jiffies)); + } + } + DGNC_UNLOCK(ch->ch_lock, lock_flags); +} + + +/* Parse the ISR register for the specific port */ +static inline void cls_parse_isr(struct board_t *brd, uint port) +{ + struct channel_t *ch; + uchar isr = 0; + ulong lock_flags; + + /* + * No need to verify board pointer, it was already + * verified in the interrupt routine. + */ + + if (port > brd->nasync) + return; + + ch = brd->channels[port]; + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return; + + /* Here we try to figure out what caused the interrupt to happen */ + while (1) { + + isr = readb(&ch->ch_cls_uart->isr_fcr); + + /* Bail if no pending interrupt on port */ + if (isr & UART_IIR_NO_INT) { + break; + } + + DPR_INTR(("%s:%d port: %x isr: %x\n", __FILE__, __LINE__, port, isr)); + + /* Receive Interrupt pending */ + if (isr & (UART_IIR_RDI | UART_IIR_RDI_TIMEOUT)) { + /* Read data from uart -> queue */ + brd->intr_rx++; + ch->ch_intr_rx++; + cls_copy_data_from_uart_to_queue(ch); + dgnc_check_queue_flow_control(ch); + } + + /* Transmit Hold register empty pending */ + if (isr & UART_IIR_THRI) { + /* Transfer data (if any) from Write Queue -> UART. */ + DGNC_LOCK(ch->ch_lock, lock_flags); + ch->ch_flags |= (CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM); + brd->intr_tx++; + ch->ch_intr_tx++; + DGNC_UNLOCK(ch->ch_lock, lock_flags); + cls_copy_data_from_queue_to_uart(ch); + } + + /* Received Xoff signal/Special character */ + if (isr & UART_IIR_XOFF) { + /* Empty */ + } + + /* CTS/RTS change of state */ + if (isr & UART_IIR_CTSRTS) { + brd->intr_modem++; + ch->ch_intr_modem++; + /* + * Don't need to do anything, the cls_parse_modem + * below will grab the updated modem signals. + */ + } + + /* Parse any modem signal changes */ + DPR_INTR(("MOD_STAT: sending to parse_modem_sigs\n")); + cls_parse_modem(ch, readb(&ch->ch_cls_uart->msr)); + } +} + + +/* + * cls_param() + * Send any/all changes to the line to the UART. + */ +static void cls_param(struct tty_struct *tty) +{ + uchar lcr = 0; + uchar uart_lcr = 0; + uchar ier = 0; + uchar uart_ier = 0; + uint baud = 9600; + int quot = 0; + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + + if (!tty || tty->magic != TTY_MAGIC) { + return; + } + + un = (struct un_t *) tty->driver_data; + if (!un || un->magic != DGNC_UNIT_MAGIC) { + return; + } + + ch = un->un_ch; + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) { + return; + } + + bd = ch->ch_bd; + if (!bd || bd->magic != DGNC_BOARD_MAGIC) { + return; + } + + DPR_PARAM(("param start: tdev: %x cflags: %x oflags: %x iflags: %x\n", + ch->ch_tun.un_dev, ch->ch_c_cflag, ch->ch_c_oflag, ch->ch_c_iflag)); + + /* + * If baud rate is zero, flush queues, and set mval to drop DTR. + */ + if ((ch->ch_c_cflag & (CBAUD)) == 0) { + ch->ch_r_head = ch->ch_r_tail = 0; + ch->ch_e_head = ch->ch_e_tail = 0; + ch->ch_w_head = ch->ch_w_tail = 0; + + cls_flush_uart_write(ch); + cls_flush_uart_read(ch); + + /* The baudrate is B0 so all modem lines are to be dropped. */ + ch->ch_flags |= (CH_BAUD0); + ch->ch_mostat &= ~(UART_MCR_RTS | UART_MCR_DTR); + cls_assert_modem_signals(ch); + ch->ch_old_baud = 0; + return; + } else if (ch->ch_custom_speed) { + + baud = ch->ch_custom_speed; + /* Handle transition from B0 */ + if (ch->ch_flags & CH_BAUD0) { + ch->ch_flags &= ~(CH_BAUD0); + + /* + * Bring back up RTS and DTR... + * Also handle RTS or DTR toggle if set. + */ + if (!(ch->ch_digi.digi_flags & DIGI_RTS_TOGGLE)) + ch->ch_mostat |= (UART_MCR_RTS); + if (!(ch->ch_digi.digi_flags & DIGI_DTR_TOGGLE)) + ch->ch_mostat |= (UART_MCR_DTR); + } + + } else { + int iindex = 0; + int jindex = 0; + + ulong bauds[4][16] = { + { /* slowbaud */ + 0, 50, 75, 110, + 134, 150, 200, 300, + 600, 1200, 1800, 2400, + 4800, 9600, 19200, 38400 }, + { /* slowbaud & CBAUDEX */ + 0, 57600, 115200, 230400, + 460800, 150, 200, 921600, + 600, 1200, 1800, 2400, + 4800, 9600, 19200, 38400 }, + { /* fastbaud */ + 0, 57600, 76800, 115200, + 131657, 153600, 230400, 460800, + 921600, 1200, 1800, 2400, + 4800, 9600, 19200, 38400 }, + { /* fastbaud & CBAUDEX */ + 0, 57600, 115200, 230400, + 460800, 150, 200, 921600, + 600, 1200, 1800, 2400, + 4800, 9600, 19200, 38400 } + }; + + /* Only use the TXPrint baud rate if the terminal unit is NOT open */ + if (!(ch->ch_tun.un_flags & UN_ISOPEN) && (un->un_type == DGNC_PRINT)) + baud = C_BAUD(ch->ch_pun.un_tty) & 0xff; + else + baud = C_BAUD(ch->ch_tun.un_tty) & 0xff; + + if (ch->ch_c_cflag & CBAUDEX) + iindex = 1; + + if (ch->ch_digi.digi_flags & DIGI_FAST) + iindex += 2; + + jindex = baud; + + if ((iindex >= 0) && (iindex < 4) && (jindex >= 0) && (jindex < 16)) { + baud = bauds[iindex][jindex]; + } else { + DPR_IOCTL(("baud indices were out of range (%d)(%d)", + iindex, jindex)); + baud = 0; + } + + if (baud == 0) + baud = 9600; + + /* Handle transition from B0 */ + if (ch->ch_flags & CH_BAUD0) { + ch->ch_flags &= ~(CH_BAUD0); + + /* + * Bring back up RTS and DTR... + * Also handle RTS or DTR toggle if set. + */ + if (!(ch->ch_digi.digi_flags & DIGI_RTS_TOGGLE)) + ch->ch_mostat |= (UART_MCR_RTS); + if (!(ch->ch_digi.digi_flags & DIGI_DTR_TOGGLE)) + ch->ch_mostat |= (UART_MCR_DTR); + } + } + + if (ch->ch_c_cflag & PARENB) { + lcr |= UART_LCR_PARITY; + } + + if (!(ch->ch_c_cflag & PARODD)) { + lcr |= UART_LCR_EPAR; + } + + /* + * Not all platforms support mark/space parity, + * so this will hide behind an ifdef. + */ +#ifdef CMSPAR + if (ch->ch_c_cflag & CMSPAR) + lcr |= UART_LCR_SPAR; +#endif + + if (ch->ch_c_cflag & CSTOPB) + lcr |= UART_LCR_STOP; + + switch (ch->ch_c_cflag & CSIZE) { + case CS5: + lcr |= UART_LCR_WLEN5; + break; + case CS6: + lcr |= UART_LCR_WLEN6; + break; + case CS7: + lcr |= UART_LCR_WLEN7; + break; + case CS8: + default: + lcr |= UART_LCR_WLEN8; + break; + } + + ier = uart_ier = readb(&ch->ch_cls_uart->ier); + uart_lcr = readb(&ch->ch_cls_uart->lcr); + + if (baud == 0) + baud = 9600; + + quot = ch->ch_bd->bd_dividend / baud; + + if (quot != 0 && ch->ch_old_baud != baud) { + ch->ch_old_baud = baud; + writeb(UART_LCR_DLAB, &ch->ch_cls_uart->lcr); + writeb((quot & 0xff), &ch->ch_cls_uart->txrx); + writeb((quot >> 8), &ch->ch_cls_uart->ier); + writeb(lcr, &ch->ch_cls_uart->lcr); + } + + if (uart_lcr != lcr) + writeb(lcr, &ch->ch_cls_uart->lcr); + + if (ch->ch_c_cflag & CREAD) { + ier |= (UART_IER_RDI | UART_IER_RLSI); + } + else { + ier &= ~(UART_IER_RDI | UART_IER_RLSI); + } + + /* + * Have the UART interrupt on modem signal changes ONLY when + * we are in hardware flow control mode, or CLOCAL/FORCEDCD is not set. + */ + if ((ch->ch_digi.digi_flags & CTSPACE) || (ch->ch_digi.digi_flags & RTSPACE) || + (ch->ch_c_cflag & CRTSCTS) || !(ch->ch_digi.digi_flags & DIGI_FORCEDCD) || + !(ch->ch_c_cflag & CLOCAL)) + { + ier |= UART_IER_MSI; + } + else { + ier &= ~UART_IER_MSI; + } + + ier |= UART_IER_THRI; + + if (ier != uart_ier) + writeb(ier, &ch->ch_cls_uart->ier); + + if (ch->ch_digi.digi_flags & CTSPACE || ch->ch_c_cflag & CRTSCTS) { + cls_set_cts_flow_control(ch); + } + else if (ch->ch_c_iflag & IXON) { + /* If start/stop is set to disable, then we should disable flow control */ + if ((ch->ch_startc == _POSIX_VDISABLE) || (ch->ch_stopc == _POSIX_VDISABLE)) + cls_set_no_output_flow_control(ch); + else + cls_set_ixon_flow_control(ch); + } + else { + cls_set_no_output_flow_control(ch); + } + + if (ch->ch_digi.digi_flags & RTSPACE || ch->ch_c_cflag & CRTSCTS) { + cls_set_rts_flow_control(ch); + } + else if (ch->ch_c_iflag & IXOFF) { + /* If start/stop is set to disable, then we should disable flow control */ + if ((ch->ch_startc == _POSIX_VDISABLE) || (ch->ch_stopc == _POSIX_VDISABLE)) + cls_set_no_input_flow_control(ch); + else + cls_set_ixoff_flow_control(ch); + } + else { + cls_set_no_input_flow_control(ch); + } + + cls_assert_modem_signals(ch); + + /* Get current status of the modem signals now */ + cls_parse_modem(ch, readb(&ch->ch_cls_uart->msr)); +} + + +/* + * Our board poller function. + */ +static void cls_tasklet(unsigned long data) +{ + struct board_t *bd = (struct board_t *) data; + struct channel_t *ch; + ulong lock_flags; + int i; + int state = 0; + int ports = 0; + + if (!bd || bd->magic != DGNC_BOARD_MAGIC) { + APR(("poll_tasklet() - NULL or bad bd.\n")); + return; + } + + /* Cache a couple board values */ + DGNC_LOCK(bd->bd_lock, lock_flags); + state = bd->state; + ports = bd->nasync; + DGNC_UNLOCK(bd->bd_lock, lock_flags); + + /* + * Do NOT allow the interrupt routine to read the intr registers + * Until we release this lock. + */ + DGNC_LOCK(bd->bd_intr_lock, lock_flags); + + /* + * If board is ready, parse deeper to see if there is anything to do. + */ + if ((state == BOARD_READY) && (ports > 0)) { + + /* Loop on each port */ + for (i = 0; i < ports; i++) { + ch = bd->channels[i]; + if (!ch) + continue; + + /* + * NOTE: Remember you CANNOT hold any channel + * locks when calling input. + * During input processing, its possible we + * will call ld, which might do callbacks back + * into us. + */ + dgnc_input(ch); + + /* + * Channel lock is grabbed and then released + * inside this routine. + */ + cls_copy_data_from_queue_to_uart(ch); + dgnc_wakeup_writes(ch); + + /* + * Check carrier function. + */ + dgnc_carrier(ch); + + /* + * The timing check of turning off the break is done + * inside clear_break() + */ + if (ch->ch_stop_sending_break) + cls_clear_break(ch, 0); + } + } + + DGNC_UNLOCK(bd->bd_intr_lock, lock_flags); + +} + + +/* + * cls_intr() + * + * Classic specific interrupt handler. + */ +static irqreturn_t cls_intr(int irq, void *voidbrd) +{ + struct board_t *brd = (struct board_t *) voidbrd; + uint i = 0; + uchar poll_reg; + unsigned long lock_flags; + + if (!brd) { + APR(("Received interrupt (%d) with null board associated\n", irq)); + return IRQ_NONE; + } + + /* + * Check to make sure its for us. + */ + if (brd->magic != DGNC_BOARD_MAGIC) { + APR(("Received interrupt (%d) with a board pointer that wasn't ours!\n", irq)); + return IRQ_NONE; + } + + DGNC_LOCK(brd->bd_intr_lock, lock_flags); + + brd->intr_count++; + + /* + * Check the board's global interrupt offset to see if we + * we actually do have an interrupt pending for us. + */ + poll_reg = readb(brd->re_map_membase + UART_CLASSIC_POLL_ADDR_OFFSET); + + /* If 0, no interrupts pending */ + if (!poll_reg) { + DPR_INTR(("Kernel interrupted to me, but no pending interrupts...\n")); + DGNC_UNLOCK(brd->bd_intr_lock, lock_flags); + return IRQ_NONE; + } + + DPR_INTR(("%s:%d poll_reg: %x\n", __FILE__, __LINE__, poll_reg)); + + /* Parse each port to find out what caused the interrupt */ + for (i = 0; i < brd->nasync; i++) { + cls_parse_isr(brd, i); + } + + /* + * Schedule tasklet to more in-depth servicing at a better time. + */ + tasklet_schedule(&brd->helper_tasklet); + + DGNC_UNLOCK(brd->bd_intr_lock, lock_flags); + + DPR_INTR(("dgnc_intr finish.\n")); + return IRQ_HANDLED; +} + + +static void cls_disable_receiver(struct channel_t *ch) +{ + uchar tmp = readb(&ch->ch_cls_uart->ier); + tmp &= ~(UART_IER_RDI); + writeb(tmp, &ch->ch_cls_uart->ier); +} + + +static void cls_enable_receiver(struct channel_t *ch) +{ + uchar tmp = readb(&ch->ch_cls_uart->ier); + tmp |= (UART_IER_RDI); + writeb(tmp, &ch->ch_cls_uart->ier); +} + + +static void cls_copy_data_from_uart_to_queue(struct channel_t *ch) +{ + int qleft = 0; + uchar linestatus = 0; + uchar error_mask = 0; + ushort head; + ushort tail; + ulong lock_flags; + + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return; + + DGNC_LOCK(ch->ch_lock, lock_flags); + + /* cache head and tail of queue */ + head = ch->ch_r_head; + tail = ch->ch_r_tail; + + /* Store how much space we have left in the queue */ + if ((qleft = tail - head - 1) < 0) + qleft += RQUEUEMASK + 1; + + /* + * Create a mask to determine whether we should + * insert the character (if any) into our queue. + */ + if (ch->ch_c_iflag & IGNBRK) + error_mask |= UART_LSR_BI; + + while (1) { + linestatus = readb(&ch->ch_cls_uart->lsr); + + if (!(linestatus & (UART_LSR_DR))) + break; + + /* + * Discard character if we are ignoring the error mask. + */ + if (linestatus & error_mask) { + uchar discard; + linestatus = 0; + discard = readb(&ch->ch_cls_uart->txrx); + continue; + } + + /* + * If our queue is full, we have no choice but to drop some data. + * The assumption is that HWFLOW or SWFLOW should have stopped + * things way way before we got to this point. + * + * I decided that I wanted to ditch the oldest data first, + * I hope thats okay with everyone? Yes? Good. + */ + while (qleft < 1) { + DPR_READ(("Queue full, dropping DATA:%x LSR:%x\n", + ch->ch_rqueue[tail], ch->ch_equeue[tail])); + + ch->ch_r_tail = tail = (tail + 1) & RQUEUEMASK; + ch->ch_err_overrun++; + qleft++; + } + + ch->ch_equeue[head] = linestatus & (UART_LSR_BI | UART_LSR_PE | UART_LSR_FE); + ch->ch_rqueue[head] = readb(&ch->ch_cls_uart->txrx); + dgnc_sniff_nowait_nolock(ch, "UART READ", ch->ch_rqueue + head, 1); + + qleft--; + + DPR_READ(("DATA/LSR pair: %x %x\n", ch->ch_rqueue[head], ch->ch_equeue[head])); + + if (ch->ch_equeue[head] & UART_LSR_PE) + ch->ch_err_parity++; + if (ch->ch_equeue[head] & UART_LSR_BI) + ch->ch_err_break++; + if (ch->ch_equeue[head] & UART_LSR_FE) + ch->ch_err_frame++; + + /* Add to, and flip head if needed */ + head = (head + 1) & RQUEUEMASK; + ch->ch_rxcount++; + } + + /* + * Write new final heads to channel structure. + */ + ch->ch_r_head = head & RQUEUEMASK; + ch->ch_e_head = head & EQUEUEMASK; + + DGNC_UNLOCK(ch->ch_lock, lock_flags); +} + + +/* + * This function basically goes to sleep for secs, or until + * it gets signalled that the port has fully drained. + */ +static int cls_drain(struct tty_struct *tty, uint seconds) +{ + ulong lock_flags; + struct channel_t *ch; + struct un_t *un; + int rc = 0; + + if (!tty || tty->magic != TTY_MAGIC) { + return (-ENXIO); + } + + un = (struct un_t *) tty->driver_data; + if (!un || un->magic != DGNC_UNIT_MAGIC) { + return (-ENXIO); + } + + ch = un->un_ch; + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) { + return (-ENXIO); + } + + DGNC_LOCK(ch->ch_lock, lock_flags); + un->un_flags |= UN_EMPTY; + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + /* + * NOTE: Do something with time passed in. + */ + rc = wait_event_interruptible(un->un_flags_wait, ((un->un_flags & UN_EMPTY) == 0)); + + /* If ret is non-zero, user ctrl-c'ed us */ + if (rc) + DPR_IOCTL(("%d Drain - User ctrl c'ed\n", __LINE__)); + + return (rc); +} + + +/* Channel lock MUST be held before calling this function! */ +static void cls_flush_uart_write(struct channel_t *ch) +{ + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) { + return; + } + + writeb((UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_XMIT), &ch->ch_cls_uart->isr_fcr); + udelay(10); + + ch->ch_flags |= (CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM); +} + + +/* Channel lock MUST be held before calling this function! */ +static void cls_flush_uart_read(struct channel_t *ch) +{ + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) { + return; + } + + /* + * For complete POSIX compatibility, we should be purging the + * read FIFO in the UART here. + * + * However, doing the statement below also incorrectly flushes + * write data as well as just basically trashing the FIFO. + * + * I believe this is a BUG in this UART. + * So for now, we will leave the code #ifdef'ed out... + */ +#if 0 + writeb((UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR), &ch->ch_cls_uart->isr_fcr); +#endif + udelay(10); +} + + +static void cls_copy_data_from_queue_to_uart(struct channel_t *ch) +{ + ushort head; + ushort tail; + int n; + int qlen; + uint len_written = 0; + ulong lock_flags; + + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return; + + DGNC_LOCK(ch->ch_lock, lock_flags); + + /* No data to write to the UART */ + if (ch->ch_w_tail == ch->ch_w_head) { + DGNC_UNLOCK(ch->ch_lock, lock_flags); + return; + } + + /* If port is "stopped", don't send any data to the UART */ + if ((ch->ch_flags & CH_FORCED_STOP) || (ch->ch_flags & CH_BREAK_SENDING)) { + DGNC_UNLOCK(ch->ch_lock, lock_flags); + return; + } + + if (!(ch->ch_flags & (CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM))) { + DGNC_UNLOCK(ch->ch_lock, lock_flags); + return; + } + + n = 32; + + /* cache head and tail of queue */ + head = ch->ch_w_head & WQUEUEMASK; + tail = ch->ch_w_tail & WQUEUEMASK; + qlen = (head - tail) & WQUEUEMASK; + + /* Find minimum of the FIFO space, versus queue length */ + n = min(n, qlen); + + while (n > 0) { + + /* + * If RTS Toggle mode is on, turn on RTS now if not already set, + * and make sure we get an event when the data transfer has completed. + */ + if (ch->ch_digi.digi_flags & DIGI_RTS_TOGGLE) { + if (!(ch->ch_mostat & UART_MCR_RTS)) { + ch->ch_mostat |= (UART_MCR_RTS); + cls_assert_modem_signals(ch); + } + ch->ch_tun.un_flags |= (UN_EMPTY); + } + + /* + * If DTR Toggle mode is on, turn on DTR now if not already set, + * and make sure we get an event when the data transfer has completed. + */ + if (ch->ch_digi.digi_flags & DIGI_DTR_TOGGLE) { + if (!(ch->ch_mostat & UART_MCR_DTR)) { + ch->ch_mostat |= (UART_MCR_DTR); + cls_assert_modem_signals(ch); + } + ch->ch_tun.un_flags |= (UN_EMPTY); + } + writeb(ch->ch_wqueue[ch->ch_w_tail], &ch->ch_cls_uart->txrx); + dgnc_sniff_nowait_nolock(ch, "UART WRITE", ch->ch_wqueue + ch->ch_w_tail, 1); + DPR_WRITE(("Tx data: %x\n", ch->ch_wqueue[ch->ch_w_tail])); + ch->ch_w_tail++; + ch->ch_w_tail &= WQUEUEMASK; + ch->ch_txcount++; + len_written++; + n--; + } + + if (len_written > 0) + ch->ch_flags &= ~(CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM); + + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + return; +} + + +static void cls_parse_modem(struct channel_t *ch, uchar signals) +{ + volatile uchar msignals = signals; + + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return; + + DPR_MSIGS(("cls_parse_modem: port: %d signals: %d\n", ch->ch_portnum, msignals)); + + /* + * Do altpin switching. Altpin switches DCD and DSR. + * This prolly breaks DSRPACE, so we should be more clever here. + */ + if (ch->ch_digi.digi_flags & DIGI_ALTPIN) { + uchar mswap = signals; + if (mswap & UART_MSR_DDCD) { + msignals &= ~UART_MSR_DDCD; + msignals |= UART_MSR_DDSR; + } + if (mswap & UART_MSR_DDSR) { + msignals &= ~UART_MSR_DDSR; + msignals |= UART_MSR_DDCD; + } + if (mswap & UART_MSR_DCD) { + msignals &= ~UART_MSR_DCD; + msignals |= UART_MSR_DSR; + } + if (mswap & UART_MSR_DSR) { + msignals &= ~UART_MSR_DSR; + msignals |= UART_MSR_DCD; + } + } + + /* Scrub off lower bits. They signify delta's, which I don't care about */ + signals &= 0xf0; + + if (msignals & UART_MSR_DCD) + ch->ch_mistat |= UART_MSR_DCD; + else + ch->ch_mistat &= ~UART_MSR_DCD; + + if (msignals & UART_MSR_DSR) + ch->ch_mistat |= UART_MSR_DSR; + else + ch->ch_mistat &= ~UART_MSR_DSR; + + if (msignals & UART_MSR_RI) + ch->ch_mistat |= UART_MSR_RI; + else + ch->ch_mistat &= ~UART_MSR_RI; + + if (msignals & UART_MSR_CTS) + ch->ch_mistat |= UART_MSR_CTS; + else + ch->ch_mistat &= ~UART_MSR_CTS; + + + DPR_MSIGS(("Port: %d DTR: %d RTS: %d CTS: %d DSR: %d " "RI: %d CD: %d\n", + ch->ch_portnum, + !!((ch->ch_mistat | ch->ch_mostat) & UART_MCR_DTR), + !!((ch->ch_mistat | ch->ch_mostat) & UART_MCR_RTS), + !!((ch->ch_mistat | ch->ch_mostat) & UART_MSR_CTS), + !!((ch->ch_mistat | ch->ch_mostat) & UART_MSR_DSR), + !!((ch->ch_mistat | ch->ch_mostat) & UART_MSR_RI), + !!((ch->ch_mistat | ch->ch_mostat) & UART_MSR_DCD))); +} + + +/* Make the UART raise any of the output signals we want up */ +static void cls_assert_modem_signals(struct channel_t *ch) +{ + uchar out; + + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return; + + out = ch->ch_mostat; + + if (ch->ch_flags & CH_LOOPBACK) + out |= UART_MCR_LOOP; + + writeb(out, &ch->ch_cls_uart->mcr); + + /* Give time for the UART to actually drop the signals */ + udelay(10); +} + + +static void cls_send_start_character(struct channel_t *ch) +{ + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return; + + if (ch->ch_startc != _POSIX_VDISABLE) { + ch->ch_xon_sends++; + writeb(ch->ch_startc, &ch->ch_cls_uart->txrx); + } +} + + +static void cls_send_stop_character(struct channel_t *ch) +{ + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return; + + if (ch->ch_stopc != _POSIX_VDISABLE) { + ch->ch_xoff_sends++; + writeb(ch->ch_stopc, &ch->ch_cls_uart->txrx); + } +} + + +/* Inits UART */ +static void cls_uart_init(struct channel_t *ch) +{ + uchar lcrb = readb(&ch->ch_cls_uart->lcr); + uchar isr_fcr = 0; + + writeb(0, &ch->ch_cls_uart->ier); + + /* + * The Enhanced Register Set may only be accessed when + * the Line Control Register is set to 0xBFh. + */ + writeb(UART_EXAR654_ENHANCED_REGISTER_SET, &ch->ch_cls_uart->lcr); + + isr_fcr = readb(&ch->ch_cls_uart->isr_fcr); + + /* Turn on Enhanced/Extended controls */ + isr_fcr |= (UART_EXAR654_EFR_ECB); + + writeb(isr_fcr, &ch->ch_cls_uart->isr_fcr); + + /* Write old LCR value back out, which turns enhanced access off */ + writeb(lcrb, &ch->ch_cls_uart->lcr); + + /* Clear out UART and FIFO */ + readb(&ch->ch_cls_uart->txrx); + + writeb((UART_FCR_ENABLE_FIFO|UART_FCR_CLEAR_RCVR|UART_FCR_CLEAR_XMIT), &ch->ch_cls_uart->isr_fcr); + udelay(10); + + ch->ch_flags |= (CH_FIFO_ENABLED | CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM); + + readb(&ch->ch_cls_uart->lsr); + readb(&ch->ch_cls_uart->msr); +} + + +/* + * Turns off UART. + */ +static void cls_uart_off(struct channel_t *ch) +{ + writeb(0, &ch->ch_cls_uart->ier); +} + + +/* + * cls_get_uarts_bytes_left. + * Returns 0 is nothing left in the FIFO, returns 1 otherwise. + * + * The channel lock MUST be held by the calling function. + */ +static uint cls_get_uart_bytes_left(struct channel_t *ch) +{ + uchar left = 0; + uchar lsr = 0; + + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return 0; + + lsr = readb(&ch->ch_cls_uart->lsr); + + /* Determine whether the Transmitter is empty or not */ + if (!(lsr & UART_LSR_TEMT)) { + if (ch->ch_flags & CH_TX_FIFO_EMPTY) { + tasklet_schedule(&ch->ch_bd->helper_tasklet); + } + left = 1; + } + else { + ch->ch_flags |= (CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM); + left = 0; + } + + return left; +} + + +/* + * cls_send_break. + * Starts sending a break thru the UART. + * + * The channel lock MUST be held by the calling function. + */ +static void cls_send_break(struct channel_t *ch, int msecs) +{ + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return; + + /* + * If we receive a time of 0, this means turn off the break. + */ + if (msecs == 0) { + /* Turn break off, and unset some variables */ + if (ch->ch_flags & CH_BREAK_SENDING) { + uchar temp = readb(&ch->ch_cls_uart->lcr); + writeb((temp & ~UART_LCR_SBC), &ch->ch_cls_uart->lcr); + ch->ch_flags &= ~(CH_BREAK_SENDING); + ch->ch_stop_sending_break = 0; + DPR_IOCTL(("Finishing UART_LCR_SBC! finished: %lx\n", jiffies)); + } + return; + } + + /* + * Set the time we should stop sending the break. + * If we are already sending a break, toss away the existing + * time to stop, and use this new value instead. + */ + ch->ch_stop_sending_break = jiffies + dgnc_jiffies_from_ms(msecs); + + /* Tell the UART to start sending the break */ + if (!(ch->ch_flags & CH_BREAK_SENDING)) { + uchar temp = readb(&ch->ch_cls_uart->lcr); + writeb((temp | UART_LCR_SBC), &ch->ch_cls_uart->lcr); + ch->ch_flags |= (CH_BREAK_SENDING); + DPR_IOCTL(("Port %d. Starting UART_LCR_SBC! start: %lx should end: %lx\n", + ch->ch_portnum, jiffies, ch->ch_stop_sending_break)); + } +} + + +/* + * cls_send_immediate_char. + * Sends a specific character as soon as possible to the UART, + * jumping over any bytes that might be in the write queue. + * + * The channel lock MUST be held by the calling function. + */ +static void cls_send_immediate_char(struct channel_t *ch, unsigned char c) +{ + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return; + + writeb(c, &ch->ch_cls_uart->txrx); +} + +static void cls_vpd(struct board_t *brd) +{ + ulong vpdbase; /* Start of io base of the card */ + uchar *re_map_vpdbase;/* Remapped memory of the card */ + int i = 0; + + + vpdbase = pci_resource_start(brd->pdev, 3); + + /* No VPD */ + if (!vpdbase) + return; + + re_map_vpdbase = ioremap(vpdbase, 0x400); + + if (!re_map_vpdbase) + return; + + /* Store the VPD into our buffer */ + for (i = 0; i < 0x40; i++) { + brd->vpd[i] = readb(re_map_vpdbase + i); + printk("%x ", brd->vpd[i]); + } + printk("\n"); + + if (re_map_vpdbase) + iounmap(re_map_vpdbase); +} + diff --git a/drivers/staging/dgnc/dgnc_cls.h b/drivers/staging/dgnc/dgnc_cls.h new file mode 100644 index 0000000000000..dca5ea38cd54d --- /dev/null +++ b/drivers/staging/dgnc/dgnc_cls.h @@ -0,0 +1,90 @@ +/* + * Copyright 2003 Digi International (www.digi.com) + * Scott H Kilau + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! + * + */ + +#ifndef __DGNC_CLS_H +#define __DGNC_CLS_H + +#include "dgnc_types.h" + + +/************************************************************************ + * Per channel/port Classic UART structure * + ************************************************************************ + * Base Structure Entries Usage Meanings to Host * + * * + * W = read write R = read only * + * U = Unused. * + ************************************************************************/ + +struct cls_uart_struct { + volatile uchar txrx; /* WR RHR/THR - Holding Reg */ + volatile uchar ier; /* WR IER - Interrupt Enable Reg */ + volatile uchar isr_fcr; /* WR ISR/FCR - Interrupt Status Reg/Fifo Control Reg */ + volatile uchar lcr; /* WR LCR - Line Control Reg */ + volatile uchar mcr; /* WR MCR - Modem Control Reg */ + volatile uchar lsr; /* WR LSR - Line Status Reg */ + volatile uchar msr; /* WR MSR - Modem Status Reg */ + volatile uchar spr; /* WR SPR - Scratch Pad Reg */ +}; + +/* Where to read the interrupt register (8bits) */ +#define UART_CLASSIC_POLL_ADDR_OFFSET 0x40 + +#define UART_EXAR654_ENHANCED_REGISTER_SET 0xBF + +#define UART_16654_FCR_TXTRIGGER_8 0x0 +#define UART_16654_FCR_TXTRIGGER_16 0x10 +#define UART_16654_FCR_TXTRIGGER_32 0x20 +#define UART_16654_FCR_TXTRIGGER_56 0x30 + +#define UART_16654_FCR_RXTRIGGER_8 0x0 +#define UART_16654_FCR_RXTRIGGER_16 0x40 +#define UART_16654_FCR_RXTRIGGER_56 0x80 +#define UART_16654_FCR_RXTRIGGER_60 0xC0 + +#define UART_IIR_XOFF 0x10 /* Received Xoff signal/Special character */ +#define UART_IIR_CTSRTS 0x20 /* Received CTS/RTS change of state */ +#define UART_IIR_RDI_TIMEOUT 0x0C /* Receiver data TIMEOUT */ + +/* + * These are the EXTENDED definitions for the Exar 654's Interrupt + * Enable Register. + */ +#define UART_EXAR654_EFR_ECB 0x10 /* Enhanced control bit */ +#define UART_EXAR654_EFR_IXON 0x2 /* Receiver compares Xon1/Xoff1 */ +#define UART_EXAR654_EFR_IXOFF 0x8 /* Transmit Xon1/Xoff1 */ +#define UART_EXAR654_EFR_RTSDTR 0x40 /* Auto RTS/DTR Flow Control Enable */ +#define UART_EXAR654_EFR_CTSDSR 0x80 /* Auto CTS/DSR Flow COntrol Enable */ + +#define UART_EXAR654_XOFF_DETECT 0x1 /* Indicates whether chip saw an incoming XOFF char */ +#define UART_EXAR654_XON_DETECT 0x2 /* Indicates whether chip saw an incoming XON char */ + +#define UART_EXAR654_IER_XOFF 0x20 /* Xoff Interrupt Enable */ +#define UART_EXAR654_IER_RTSDTR 0x40 /* Output Interrupt Enable */ +#define UART_EXAR654_IER_CTSDSR 0x80 /* Input Interrupt Enable */ + +/* + * Our Global Variables + */ +extern struct board_ops dgnc_cls_ops; + +#endif diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c new file mode 100644 index 0000000000000..7c88de7737453 --- /dev/null +++ b/drivers/staging/dgnc/dgnc_driver.c @@ -0,0 +1,1028 @@ +/* + * Copyright 2003 Digi International (www.digi.com) + * Scott H Kilau + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * + * NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE! + * + * This is shared code between Digi's CVS archive and the + * Linux Kernel sources. + * Changing the source just for reformatting needlessly breaks + * our CVS diff history. + * + * Send any bug fixes/changes to: Eng.Linux at digi dot com. + * Thank you. + * + * $Id: dgnc_driver.c,v 1.3 2011/06/23 12:47:35 markh Exp $ + * + */ + + +#include +#include +#include +#include + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39) +#include +#endif + +#include "dgnc_driver.h" +#include "dgnc_pci.h" +#include "dgnc_proc.h" +#include "dpacompat.h" +#include "dgnc_mgmt.h" +#include "dgnc_tty.h" +#include "dgnc_trace.h" +#include "dgnc_cls.h" +#include "dgnc_neo.h" +#include "dgnc_sysfs.h" + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Digi International, http://www.digi.com"); +MODULE_DESCRIPTION("Driver for the Digi International Neo and Classic PCI based product line"); +MODULE_SUPPORTED_DEVICE("dgnc"); + +/* + * insmod command line overrideable parameters + * + * NOTE: we use a set of macros to create the variables, which allows + * us to specify the variable type, name, initial value, and description. + */ +PARM_INT(debug, 0x00, 0644, "Driver debugging level"); +PARM_INT(rawreadok, 1, 0644, "Bypass flip buffers on input"); +PARM_INT(trcbuf_size, 0x100000, 0644, "Debugging trace buffer size."); + +/************************************************************************** + * + * protos for this file + * + */ +static int dgnc_start(void); +static int dgnc_finalize_board_init(struct board_t *brd); +static void dgnc_init_globals(void); +static int dgnc_found_board(struct pci_dev *pdev, int id); +static void dgnc_cleanup_board(struct board_t *brd); +static void dgnc_poll_handler(ulong dummy); +static int dgnc_init_pci(void); +static int dgnc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); +static void dgnc_remove_one(struct pci_dev *dev); +static int dgnc_probe1(struct pci_dev *pdev, int card_type); +static void dgnc_do_remap(struct board_t *brd); +static void dgnc_mbuf(struct board_t *brd, const char *fmt, ...); + + +/* Driver load/unload functions */ +int dgnc_init_module(void); +void dgnc_cleanup_module(void); + +module_init(dgnc_init_module); +module_exit(dgnc_cleanup_module); + + +/* + * File operations permitted on Control/Management major. + */ +static struct file_operations dgnc_BoardFops = +{ + .owner = THIS_MODULE, +#ifdef HAVE_UNLOCKED_IOCTL + .unlocked_ioctl = dgnc_mgmt_ioctl, +#else + .ioctl = dgnc_mgmt_ioctl, +#endif + .open = dgnc_mgmt_open, + .release = dgnc_mgmt_close +}; + + +/* + * Globals + */ +uint dgnc_NumBoards; +struct board_t *dgnc_Board[MAXBOARDS]; +DEFINE_SPINLOCK(dgnc_global_lock); +int dgnc_driver_state = DRIVER_INITIALIZED; +ulong dgnc_poll_counter; +uint dgnc_Major; +int dgnc_poll_tick = 20; /* Poll interval - 20 ms */ + +/* + * Static vars. + */ +static uint dgnc_Major_Control_Registered = FALSE; +static uint dgnc_driver_start = FALSE; + +static struct class *dgnc_class; + +/* + * Poller stuff + */ +static DEFINE_SPINLOCK(dgnc_poll_lock); /* Poll scheduling lock */ +static ulong dgnc_poll_time; /* Time of next poll */ +static uint dgnc_poll_stop; /* Used to tell poller to stop */ +static struct timer_list dgnc_poll_timer; + + +static struct pci_device_id dgnc_pci_tbl[] = { + { DIGI_VID, PCI_DEVICE_CLASSIC_4_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, + { DIGI_VID, PCI_DEVICE_CLASSIC_4_422_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1 }, + { DIGI_VID, PCI_DEVICE_CLASSIC_8_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2 }, + { DIGI_VID, PCI_DEVICE_CLASSIC_8_422_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 3 }, + { DIGI_VID, PCI_DEVICE_NEO_4_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4 }, + { DIGI_VID, PCI_DEVICE_NEO_8_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 5 }, + { DIGI_VID, PCI_DEVICE_NEO_2DB9_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 6 }, + { DIGI_VID, PCI_DEVICE_NEO_2DB9PRI_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 7 }, + { DIGI_VID, PCI_DEVICE_NEO_2RJ45_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 8 }, + { DIGI_VID, PCI_DEVICE_NEO_2RJ45PRI_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 9 }, + { DIGI_VID, PCI_DEVICE_NEO_1_422_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 10 }, + { DIGI_VID, PCI_DEVICE_NEO_1_422_485_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 11 }, + { DIGI_VID, PCI_DEVICE_NEO_2_422_485_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 12 }, + { DIGI_VID, PCI_DEVICE_NEO_EXPRESS_8_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 13 }, + { DIGI_VID, PCI_DEVICE_NEO_EXPRESS_4_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 14 }, + { DIGI_VID, PCI_DEVICE_NEO_EXPRESS_4RJ45_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 15 }, + { DIGI_VID, PCI_DEVICE_NEO_EXPRESS_8RJ45_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 16 }, + {0,} /* 0 terminated list. */ +}; +MODULE_DEVICE_TABLE(pci, dgnc_pci_tbl); + +struct board_id { + uchar *name; + uint maxports; + unsigned int is_pci_express; +}; + +static struct board_id dgnc_Ids[] = +{ + { PCI_DEVICE_CLASSIC_4_PCI_NAME, 4, 0 }, + { PCI_DEVICE_CLASSIC_4_422_PCI_NAME, 4, 0 }, + { PCI_DEVICE_CLASSIC_8_PCI_NAME, 8, 0 }, + { PCI_DEVICE_CLASSIC_8_422_PCI_NAME, 8, 0 }, + { PCI_DEVICE_NEO_4_PCI_NAME, 4, 0 }, + { PCI_DEVICE_NEO_8_PCI_NAME, 8, 0 }, + { PCI_DEVICE_NEO_2DB9_PCI_NAME, 2, 0 }, + { PCI_DEVICE_NEO_2DB9PRI_PCI_NAME, 2, 0 }, + { PCI_DEVICE_NEO_2RJ45_PCI_NAME, 2, 0 }, + { PCI_DEVICE_NEO_2RJ45PRI_PCI_NAME, 2, 0 }, + { PCI_DEVICE_NEO_1_422_PCI_NAME, 1, 0 }, + { PCI_DEVICE_NEO_1_422_485_PCI_NAME, 1, 0 }, + { PCI_DEVICE_NEO_2_422_485_PCI_NAME, 2, 0 }, + { PCI_DEVICE_NEO_EXPRESS_8_PCI_NAME, 8, 1 }, + { PCI_DEVICE_NEO_EXPRESS_4_PCI_NAME, 4, 1 }, + { PCI_DEVICE_NEO_EXPRESS_4RJ45_PCI_NAME, 4, 1 }, + { PCI_DEVICE_NEO_EXPRESS_8RJ45_PCI_NAME, 8, 1 }, + { NULL, 0, 0 } +}; + +static struct pci_driver dgnc_driver = { + .name = "dgnc", + .probe = dgnc_init_one, + .id_table = dgnc_pci_tbl, + .remove = dgnc_remove_one, +}; + + +char *dgnc_state_text[] = { + "Board Failed", + "Board Found", + "Board READY", +}; + +char *dgnc_driver_state_text[] = { + "Driver Initialized", + "Driver Ready." +}; + + + +/************************************************************************ + * + * Driver load/unload functions + * + ************************************************************************/ + + +/* + * init_module() + * + * Module load. This is where it all starts. + */ +int dgnc_init_module(void) +{ + int rc = 0; + + APR(("%s, Digi International Part Number %s\n", DG_NAME, DG_PART)); + + /* + * Initialize global stuff + */ + rc = dgnc_start(); + + if (rc < 0) { + return(rc); + } + + /* + * Find and configure all the cards + */ + rc = dgnc_init_pci(); + + /* + * If something went wrong in the scan, bail out of driver. + */ + if (rc < 0) { + /* Only unregister the pci driver if it was actually registered. */ + if (dgnc_NumBoards) + pci_unregister_driver(&dgnc_driver); + else + printk("WARNING: dgnc driver load failed. No Digi Neo or Classic boards found.\n"); + + dgnc_cleanup_module(); + } + else { + dgnc_create_driver_sysfiles(&dgnc_driver); + } + + DPR_INIT(("Finished init_module. Returning %d\n", rc)); + return (rc); +} + + +/* + * Start of driver. + */ +static int dgnc_start(void) +{ + int rc = 0; + unsigned long flags; + + if (dgnc_driver_start == FALSE) { + + dgnc_driver_start = TRUE; + + /* make sure that the globals are init'd before we do anything else */ + dgnc_init_globals(); + + dgnc_NumBoards = 0; + + APR(("For the tools package or updated drivers please visit http://www.digi.com\n")); + + /* + * Register our base character device into the kernel. + * This allows the download daemon to connect to the downld device + * before any of the boards are init'ed. + */ + if (!dgnc_Major_Control_Registered) { + /* + * Register management/dpa devices + */ + rc = register_chrdev(0, "dgnc", &dgnc_BoardFops); + if (rc <= 0) { + APR(("Can't register dgnc driver device (%d)\n", rc)); + rc = -ENXIO; + return(rc); + } + dgnc_Major = rc; + + dgnc_class = class_create(THIS_MODULE, "dgnc_mgmt"); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28) + device_create_drvdata(dgnc_class, NULL, + MKDEV(dgnc_Major, 0), + NULL, "dgnc_mgmt"); +#else + device_create(dgnc_class, NULL, + MKDEV(dgnc_Major, 0), + NULL, "dgnc_mgmt"); +#endif + + dgnc_Major_Control_Registered = TRUE; + } + + /* + * Register our basic stuff in /proc/dgnc + */ + dgnc_proc_register_basic_prescan(); + + /* + * Init any global tty stuff. + */ + rc = dgnc_tty_preinit(); + + if (rc < 0) { + APR(("tty preinit - not enough memory (%d)\n", rc)); + return(rc); + } + + /* Start the poller */ + DGNC_LOCK(dgnc_poll_lock, flags); + init_timer(&dgnc_poll_timer); + dgnc_poll_timer.function = dgnc_poll_handler; + dgnc_poll_timer.data = 0; + dgnc_poll_time = jiffies + dgnc_jiffies_from_ms(dgnc_poll_tick); + dgnc_poll_timer.expires = dgnc_poll_time; + DGNC_UNLOCK(dgnc_poll_lock, flags); + + add_timer(&dgnc_poll_timer); + + dgnc_driver_state = DRIVER_READY; + } + + return(rc); +} + +/* + * Register pci driver, and return how many boards we have. + */ +static int dgnc_init_pci(void) +{ + return pci_register_driver(&dgnc_driver); +} + + +/* returns count (>= 0), or negative on error */ +static int dgnc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) +{ + int rc; + + /* wake up and enable device */ + rc = pci_enable_device(pdev); + + if (rc < 0) { + rc = -EIO; + } else { + rc = dgnc_probe1(pdev, ent->driver_data); + if (rc == 0) { + dgnc_NumBoards++; + DPR_INIT(("Incrementing numboards to %d\n", dgnc_NumBoards)); + } + } + return rc; +} + +static int dgnc_probe1(struct pci_dev *pdev, int card_type) +{ + return dgnc_found_board(pdev, card_type); +} + + +static void dgnc_remove_one(struct pci_dev *dev) +{ + /* Do Nothing */ +} + +/* + * dgnc_cleanup_module() + * + * Module unload. This is where it all ends. + */ +void dgnc_cleanup_module(void) +{ + int i; + ulong lock_flags; + + DGNC_LOCK(dgnc_poll_lock, lock_flags); + dgnc_poll_stop = 1; + DGNC_UNLOCK(dgnc_poll_lock, lock_flags); + + /* Turn off poller right away. */ + del_timer_sync(&dgnc_poll_timer); + + dgnc_proc_unregister_all(); + + dgnc_remove_driver_sysfiles(&dgnc_driver); + + if (dgnc_Major_Control_Registered) { + device_destroy(dgnc_class, MKDEV(dgnc_Major, 0)); + class_destroy(dgnc_class); + unregister_chrdev(dgnc_Major, "dgnc"); + } + + for (i = 0; i < dgnc_NumBoards; ++i) { + dgnc_remove_ports_sysfiles(dgnc_Board[i]); + dgnc_tty_uninit(dgnc_Board[i]); + dgnc_cleanup_board(dgnc_Board[i]); + } + + dgnc_tty_post_uninit(); + +#if defined(DGNC_TRACER) + /* last thing, make sure we release the tracebuffer */ + dgnc_tracer_free(); +#endif + if (dgnc_NumBoards) + pci_unregister_driver(&dgnc_driver); +} + + +/* + * dgnc_cleanup_board() + * + * Free all the memory associated with a board + */ +static void dgnc_cleanup_board(struct board_t *brd) +{ + int i = 0; + + if(!brd || brd->magic != DGNC_BOARD_MAGIC) + return; + + switch (brd->device) { + case PCI_DEVICE_CLASSIC_4_DID: + case PCI_DEVICE_CLASSIC_8_DID: + case PCI_DEVICE_CLASSIC_4_422_DID: + case PCI_DEVICE_CLASSIC_8_422_DID: + + /* Tell card not to interrupt anymore. */ + outb(0, brd->iobase + 0x4c); + break; + + default: + break; + } + + if (brd->irq) + free_irq(brd->irq, brd); + + tasklet_kill(&brd->helper_tasklet); + + if (brd->re_map_membase) { + iounmap(brd->re_map_membase); + brd->re_map_membase = NULL; + } + + if (brd->msgbuf_head) { + unsigned long flags; + + DGNC_LOCK(dgnc_global_lock, flags); + brd->msgbuf = NULL; + printk(brd->msgbuf_head); + kfree(brd->msgbuf_head); + brd->msgbuf_head = NULL; + DGNC_UNLOCK(dgnc_global_lock, flags); + } + + /* Free all allocated channels structs */ + for (i = 0; i < MAXPORTS ; i++) { + if (brd->channels[i]) { + if (brd->channels[i]->ch_rqueue) + kfree(brd->channels[i]->ch_rqueue); + if (brd->channels[i]->ch_equeue) + kfree(brd->channels[i]->ch_equeue); + if (brd->channels[i]->ch_wqueue) + kfree(brd->channels[i]->ch_wqueue); + + kfree(brd->channels[i]); + brd->channels[i] = NULL; + } + } + + if (brd->flipbuf) + kfree(brd->flipbuf); + + dgnc_Board[brd->boardnum] = NULL; + + kfree(brd); +} + + +/* + * dgnc_found_board() + * + * A board has been found, init it. + */ +static int dgnc_found_board(struct pci_dev *pdev, int id) +{ + struct board_t *brd; + unsigned int pci_irq; + int i = 0; + int rc = 0; + unsigned long flags; + + /* get the board structure and prep it */ + brd = dgnc_Board[dgnc_NumBoards] = + (struct board_t *) dgnc_driver_kzmalloc(sizeof(struct board_t), GFP_KERNEL); + if (!brd) { + APR(("memory allocation for board structure failed\n")); + return(-ENOMEM); + } + + /* make a temporary message buffer for the boot messages */ + brd->msgbuf = brd->msgbuf_head = + (char *) dgnc_driver_kzmalloc(sizeof(char) * 8192, GFP_KERNEL); + if (!brd->msgbuf) { + kfree(brd); + APR(("memory allocation for board msgbuf failed\n")); + return(-ENOMEM); + } + + /* store the info for the board we've found */ + brd->magic = DGNC_BOARD_MAGIC; + brd->boardnum = dgnc_NumBoards; + brd->vendor = dgnc_pci_tbl[id].vendor; + brd->device = dgnc_pci_tbl[id].device; + brd->pdev = pdev; + brd->pci_bus = pdev->bus->number; + brd->pci_slot = PCI_SLOT(pdev->devfn); + brd->name = dgnc_Ids[id].name; + brd->maxports = dgnc_Ids[id].maxports; + if (dgnc_Ids[i].is_pci_express) + brd->bd_flags |= BD_IS_PCI_EXPRESS; + brd->dpastatus = BD_NOFEP; + init_waitqueue_head(&brd->state_wait); + + DGNC_SPINLOCK_INIT(brd->bd_lock); + DGNC_SPINLOCK_INIT(brd->bd_intr_lock); + + brd->state = BOARD_FOUND; + + for (i = 0; i < MAXPORTS; i++) { + brd->channels[i] = NULL; + } + + /* store which card & revision we have */ + pci_read_config_word(pdev, PCI_SUBSYSTEM_VENDOR_ID, &brd->subvendor); + pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, &brd->subdevice); + pci_read_config_byte(pdev, PCI_REVISION_ID, &brd->rev); + + pci_irq = pdev->irq; + brd->irq = pci_irq; + + + switch(brd->device) { + + case PCI_DEVICE_CLASSIC_4_DID: + case PCI_DEVICE_CLASSIC_8_DID: + case PCI_DEVICE_CLASSIC_4_422_DID: + case PCI_DEVICE_CLASSIC_8_422_DID: + + brd->dpatype = T_CLASSIC | T_PCIBUS; + + DPR_INIT(("dgnc_found_board - Classic.\n")); + + /* + * For PCI ClassicBoards + * PCI Local Address (i.e. "resource" number) space + * 0 PLX Memory Mapped Config + * 1 PLX I/O Mapped Config + * 2 I/O Mapped UARTs and Status + * 3 Memory Mapped VPD + * 4 Memory Mapped UARTs and Status + */ + + + /* get the PCI Base Address Registers */ + brd->membase = pci_resource_start(pdev, 4); + + if (!brd->membase) { + APR(("card has no PCI IO resources, failing board.\n")); + return -ENODEV; + } + + brd->membase_end = pci_resource_end(pdev, 4); + + if (brd->membase & 1) + brd->membase &= ~3; + else + brd->membase &= ~15; + + brd->iobase = pci_resource_start(pdev, 1); + brd->iobase_end = pci_resource_end(pdev, 1); + brd->iobase = ((unsigned int) (brd->iobase)) & 0xFFFE; + + /* Assign the board_ops struct */ + brd->bd_ops = &dgnc_cls_ops; + + brd->bd_uart_offset = 0x8; + brd->bd_dividend = 921600; + + dgnc_do_remap(brd); + + /* Get and store the board VPD, if it exists */ + brd->bd_ops->vpd(brd); + + /* + * Enable Local Interrupt 1 (0x1), + * Local Interrupt 1 Polarity Active high (0x2), + * Enable PCI interrupt (0x40) + */ + outb(0x43, brd->iobase + 0x4c); + + break; + + + case PCI_DEVICE_NEO_4_DID: + case PCI_DEVICE_NEO_8_DID: + case PCI_DEVICE_NEO_2DB9_DID: + case PCI_DEVICE_NEO_2DB9PRI_DID: + case PCI_DEVICE_NEO_2RJ45_DID: + case PCI_DEVICE_NEO_2RJ45PRI_DID: + case PCI_DEVICE_NEO_1_422_DID: + case PCI_DEVICE_NEO_1_422_485_DID: + case PCI_DEVICE_NEO_2_422_485_DID: + case PCI_DEVICE_NEO_EXPRESS_8_DID: + case PCI_DEVICE_NEO_EXPRESS_4_DID: + case PCI_DEVICE_NEO_EXPRESS_4RJ45_DID: + case PCI_DEVICE_NEO_EXPRESS_8RJ45_DID: + + /* + * This chip is set up 100% when we get to it. + * No need to enable global interrupts or anything. + */ + if (brd->bd_flags & BD_IS_PCI_EXPRESS) + brd->dpatype = T_NEO_EXPRESS | T_PCIBUS; + else + brd->dpatype = T_NEO | T_PCIBUS; + + DPR_INIT(("dgnc_found_board - NEO.\n")); + + /* get the PCI Base Address Registers */ + brd->membase = pci_resource_start(pdev, 0); + brd->membase_end = pci_resource_end(pdev, 0); + + if (brd->membase & 1) + brd->membase &= ~3; + else + brd->membase &= ~15; + + /* Assign the board_ops struct */ + brd->bd_ops = &dgnc_neo_ops; + + brd->bd_uart_offset = 0x200; + brd->bd_dividend = 921600; + + dgnc_do_remap(brd); + + if (brd->re_map_membase) { + + /* After remap is complete, we need to read and store the dvid */ + brd->dvid = readb(brd->re_map_membase + 0x8D); + + /* Get and store the board VPD, if it exists */ + brd->bd_ops->vpd(brd); + } + break; + + default: + APR(("Did not find any compatible Neo or Classic PCI boards in system.\n")); + return (-ENXIO); + + } + + /* + * Do tty device initialization. + */ + + rc = dgnc_tty_register(brd); + if (rc < 0) { + dgnc_tty_uninit(brd); + APR(("Can't register tty devices (%d)\n", rc)); + brd->state = BOARD_FAILED; + brd->dpastatus = BD_NOFEP; + goto failed; + } + + rc = dgnc_finalize_board_init(brd); + if (rc < 0) { + APR(("Can't finalize board init (%d)\n", rc)); + brd->state = BOARD_FAILED; + brd->dpastatus = BD_NOFEP; + + goto failed; + } + + rc = dgnc_tty_init(brd); + if (rc < 0) { + dgnc_tty_uninit(brd); + APR(("Can't init tty devices (%d)\n", rc)); + brd->state = BOARD_FAILED; + brd->dpastatus = BD_NOFEP; + + goto failed; + } + + brd->state = BOARD_READY; + brd->dpastatus = BD_RUNNING; + + dgnc_create_ports_sysfiles(brd); + + /* init our poll helper tasklet */ + tasklet_init(&brd->helper_tasklet, brd->bd_ops->tasklet, (unsigned long) brd); + + /* Log the information about the board */ + dgnc_mbuf(brd, DRVSTR": board %d: %s (rev %d), irq %d\n", + dgnc_NumBoards, brd->name, brd->rev, brd->irq); + + DPR_INIT(("dgnc_scan(%d) - printing out the msgbuf\n", i)); + DGNC_LOCK(dgnc_global_lock, flags); + brd->msgbuf = NULL; + printk(brd->msgbuf_head); + kfree(brd->msgbuf_head); + brd->msgbuf_head = NULL; + DGNC_UNLOCK(dgnc_global_lock, flags); + + /* + * allocate flip buffer for board. + * + * Okay to malloc with GFP_KERNEL, we are not at interrupt + * context, and there are no locks held. + */ + brd->flipbuf = dgnc_driver_kzmalloc(MYFLIPLEN, GFP_KERNEL); + + dgnc_proc_register_basic_postscan(dgnc_NumBoards); + + wake_up_interruptible(&brd->state_wait); + + return(0); + +failed: + + return (-ENXIO); + +} + + +static int dgnc_finalize_board_init(struct board_t *brd) { + int rc = 0; + + DPR_INIT(("dgnc_finalize_board_init() - start\n")); + + if (!brd || brd->magic != DGNC_BOARD_MAGIC) + return(-ENODEV); + + DPR_INIT(("dgnc_finalize_board_init() - start #2\n")); + + if (brd->irq) { + rc = request_irq(brd->irq, brd->bd_ops->intr, IRQF_SHARED, "DGNC", brd); + + if (rc) { + printk("Failed to hook IRQ %d\n",brd->irq); + brd->state = BOARD_FAILED; + brd->dpastatus = BD_NOFEP; + rc = -ENODEV; + } else { + DPR_INIT(("Requested and received usage of IRQ %d\n", brd->irq)); + } + } + return(rc); +} + +/* + * Remap PCI memory. + */ +static void dgnc_do_remap(struct board_t *brd) +{ + + if (!brd || brd->magic != DGNC_BOARD_MAGIC) + return; + + brd->re_map_membase = ioremap(brd->membase, 0x1000); + + DPR_INIT(("remapped mem: 0x%p\n", brd->re_map_membase)); +} + + +/***************************************************************************** +* +* Function: +* +* dgnc_poll_handler +* +* Author: +* +* Scott H Kilau +* +* Parameters: +* +* dummy -- ignored +* +* Return Values: +* +* none +* +* Description: +* +* As each timer expires, it determines (a) whether the "transmit" +* waiter needs to be woken up, and (b) whether the poller needs to +* be rescheduled. +* +******************************************************************************/ + +static void dgnc_poll_handler(ulong dummy) +{ + struct board_t *brd; + unsigned long lock_flags; + int i; + unsigned long new_time; + + dgnc_poll_counter++; + + /* + * Do not start the board state machine until + * driver tells us its up and running, and has + * everything it needs. + */ + if (dgnc_driver_state != DRIVER_READY) { + goto schedule_poller; + } + + /* Go thru each board, kicking off a tasklet for each if needed */ + for (i = 0; i < dgnc_NumBoards; i++) { + brd = dgnc_Board[i]; + + DGNC_LOCK(brd->bd_lock, lock_flags); + + /* If board is in a failed state, don't bother scheduling a tasklet */ + if (brd->state == BOARD_FAILED) { + DGNC_UNLOCK(brd->bd_lock, lock_flags); + continue; + } + + /* Schedule a poll helper task */ + tasklet_schedule(&brd->helper_tasklet); + + DGNC_UNLOCK(brd->bd_lock, lock_flags); + } + +schedule_poller: + + /* + * Schedule ourself back at the nominal wakeup interval. + */ + DGNC_LOCK(dgnc_poll_lock, lock_flags); + dgnc_poll_time += dgnc_jiffies_from_ms(dgnc_poll_tick); + + new_time = dgnc_poll_time - jiffies; + + if ((ulong) new_time >= 2 * dgnc_poll_tick) { + dgnc_poll_time = jiffies + dgnc_jiffies_from_ms(dgnc_poll_tick); + } + + init_timer(&dgnc_poll_timer); + dgnc_poll_timer.function = dgnc_poll_handler; + dgnc_poll_timer.data = 0; + dgnc_poll_timer.expires = dgnc_poll_time; + DGNC_UNLOCK(dgnc_poll_lock, lock_flags); + + if (!dgnc_poll_stop) + add_timer(&dgnc_poll_timer); +} + +/* + * dgnc_init_globals() + * + * This is where we initialize the globals from the static insmod + * configuration variables. These are declared near the head of + * this file. + */ +static void dgnc_init_globals(void) +{ + int i = 0; + + dgnc_rawreadok = rawreadok; + dgnc_trcbuf_size = trcbuf_size; + dgnc_debug = debug; + + for (i = 0; i < MAXBOARDS; i++) { + dgnc_Board[i] = NULL; + } + + init_timer(&dgnc_poll_timer); +} + + +/************************************************************************ + * + * Utility functions + * + ************************************************************************/ + + +/* + * dgnc_driver_kzmalloc() + * + * Malloc and clear memory, + */ +void *dgnc_driver_kzmalloc(size_t size, int priority) +{ + void *p = kmalloc(size, priority); + if(p) + memset(p, 0, size); + return(p); +} + + +/* + * dgnc_mbuf() + * + * Used to print to the message buffer during board init. + */ +static void dgnc_mbuf(struct board_t *brd, const char *fmt, ...) { + va_list ap; + char buf[1024]; + int i; + unsigned long flags; + + DGNC_LOCK(dgnc_global_lock, flags); + + /* Format buf using fmt and arguments contained in ap. */ + va_start(ap, fmt); + i = vsprintf(buf, fmt, ap); + va_end(ap); + + DPR((buf)); + + if (!brd || !brd->msgbuf) { + printk(buf); + DGNC_UNLOCK(dgnc_global_lock, flags); + return; + } + + memcpy(brd->msgbuf, buf, strlen(buf)); + brd->msgbuf += strlen(buf); + *brd->msgbuf = (char) NULL; + + DGNC_UNLOCK(dgnc_global_lock, flags); +} + + +/* + * dgnc_ms_sleep() + * + * Put the driver to sleep for x ms's + * + * Returns 0 if timed out, !0 (showing signal) if interrupted by a signal. + */ +int dgnc_ms_sleep(ulong ms) +{ + current->state = TASK_INTERRUPTIBLE; + schedule_timeout((ms * HZ) / 1000); + return (signal_pending(current)); +} + + + +/* + * dgnc_ioctl_name() : Returns a text version of each ioctl value. + */ +char *dgnc_ioctl_name(int cmd) +{ + switch(cmd) { + + case TCGETA: return("TCGETA"); + case TCGETS: return("TCGETS"); + case TCSETA: return("TCSETA"); + case TCSETS: return("TCSETS"); + case TCSETAW: return("TCSETAW"); + case TCSETSW: return("TCSETSW"); + case TCSETAF: return("TCSETAF"); + case TCSETSF: return("TCSETSF"); + case TCSBRK: return("TCSBRK"); + case TCXONC: return("TCXONC"); + case TCFLSH: return("TCFLSH"); + case TIOCGSID: return("TIOCGSID"); + + case TIOCGETD: return("TIOCGETD"); + case TIOCSETD: return("TIOCSETD"); + case TIOCGWINSZ: return("TIOCGWINSZ"); + case TIOCSWINSZ: return("TIOCSWINSZ"); + + case TIOCMGET: return("TIOCMGET"); + case TIOCMSET: return("TIOCMSET"); + case TIOCMBIS: return("TIOCMBIS"); + case TIOCMBIC: return("TIOCMBIC"); + + /* from digi.h */ + case DIGI_SETA: return("DIGI_SETA"); + case DIGI_SETAW: return("DIGI_SETAW"); + case DIGI_SETAF: return("DIGI_SETAF"); + case DIGI_SETFLOW: return("DIGI_SETFLOW"); + case DIGI_SETAFLOW: return("DIGI_SETAFLOW"); + case DIGI_GETFLOW: return("DIGI_GETFLOW"); + case DIGI_GETAFLOW: return("DIGI_GETAFLOW"); + case DIGI_GETA: return("DIGI_GETA"); + case DIGI_GEDELAY: return("DIGI_GEDELAY"); + case DIGI_SEDELAY: return("DIGI_SEDELAY"); + case DIGI_GETCUSTOMBAUD: return("DIGI_GETCUSTOMBAUD"); + case DIGI_SETCUSTOMBAUD: return("DIGI_SETCUSTOMBAUD"); + case TIOCMODG: return("TIOCMODG"); + case TIOCMODS: return("TIOCMODS"); + case TIOCSDTR: return("TIOCSDTR"); + case TIOCCDTR: return("TIOCCDTR"); + + default: return("unknown"); + } +} diff --git a/drivers/staging/dgnc/dgnc_driver.h b/drivers/staging/dgnc/dgnc_driver.h new file mode 100644 index 0000000000000..43177f47209bf --- /dev/null +++ b/drivers/staging/dgnc/dgnc_driver.h @@ -0,0 +1,566 @@ +/* + * Copyright 2003 Digi International (www.digi.com) + * Scott H Kilau + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! + * + ************************************************************************* + * + * Driver includes + * + *************************************************************************/ + +#ifndef __DGNC_DRIVER_H +#define __DGNC_DRIVER_H + +#include /* To get the current Linux version */ +#include /* To pick up the varions Linux types */ +#include /* To pick up the various tty structs/defines */ +#include /* For irqreturn_t type */ + +#include "dgnc_types.h" /* Additional types needed by the Digi header files */ +#include "digi.h" /* Digi specific ioctl header */ +#include "dgnc_kcompat.h" /* Kernel 2.4/2.6 compat includes */ +#include "dgnc_sysfs.h" /* Support for SYSFS */ + +/************************************************************************* + * + * Driver defines + * + *************************************************************************/ + +/* + * Driver identification, error and debugging statments + * + * In theory, you can change all occurances of "digi" in the next + * three lines, and the driver printk's will all automagically change. + * + * APR((fmt, args, ...)); Always prints message + * DPR((fmt, args, ...)); Only prints if DGNC_TRACER is defined at + * compile time and dgnc_debug!=0 + */ +#define PROCSTR "dgnc" /* /proc entries */ +#define DEVSTR "/dev/dg/dgnc" /* /dev entries */ +#define DRVSTR "dgnc" /* Driver name string + * displayed by APR */ +#define APR(args) do { PRINTF_TO_KMEM(args); printk(DRVSTR": "); printk args; \ + } while (0) +#define RAPR(args) do { PRINTF_TO_KMEM(args); printk args; } while (0) + +#define TRC_TO_CONSOLE 1 + +/* + * Debugging levels can be set using debug insmod variable + * They can also be compiled out completely. + */ + +#define DBG_INIT (dgnc_debug & 0x01) +#define DBG_BASIC (dgnc_debug & 0x02) +#define DBG_CORE (dgnc_debug & 0x04) + +#define DBG_OPEN (dgnc_debug & 0x08) +#define DBG_CLOSE (dgnc_debug & 0x10) +#define DBG_READ (dgnc_debug & 0x20) +#define DBG_WRITE (dgnc_debug & 0x40) + +#define DBG_IOCTL (dgnc_debug & 0x80) + +#define DBG_PROC (dgnc_debug & 0x100) +#define DBG_PARAM (dgnc_debug & 0x200) +#define DBG_PSCAN (dgnc_debug & 0x400) +#define DBG_EVENT (dgnc_debug & 0x800) + +#define DBG_DRAIN (dgnc_debug & 0x1000) +#define DBG_MSIGS (dgnc_debug & 0x2000) + +#define DBG_MGMT (dgnc_debug & 0x4000) +#define DBG_INTR (dgnc_debug & 0x8000) + +#define DBG_CARR (dgnc_debug & 0x10000) + + +#if defined(DGNC_TRACER) + +# if defined(TRC_TO_KMEM) +/* Choose one: */ +# define TRC_ON_OVERFLOW_WRAP_AROUND +# undef TRC_ON_OVERFLOW_SHIFT_BUFFER +# endif //TRC_TO_KMEM + +# define TRC_MAXMSG 1024 +# define TRC_OVERFLOW "(OVERFLOW)" +# define TRC_DTRC "/usr/bin/dtrc" + +#if defined TRC_TO_CONSOLE +#define PRINTF_TO_CONSOLE(args) { printk(DRVSTR": "); printk args; } +#else //!defined TRACE_TO_CONSOLE +#define PRINTF_TO_CONSOLE(args) +#endif + +#if defined TRC_TO_KMEM +#define PRINTF_TO_KMEM(args) dgnc_tracef args +#else //!defined TRC_TO_KMEM +#define PRINTF_TO_KMEM(args) +#endif + +#define TRC(args) { PRINTF_TO_KMEM(args); PRINTF_TO_CONSOLE(args) } + +# define DPR_INIT(ARGS) if (DBG_INIT) TRC(ARGS) +# define DPR_BASIC(ARGS) if (DBG_BASIC) TRC(ARGS) +# define DPR_CORE(ARGS) if (DBG_CORE) TRC(ARGS) +# define DPR_OPEN(ARGS) if (DBG_OPEN) TRC(ARGS) +# define DPR_CLOSE(ARGS) if (DBG_CLOSE) TRC(ARGS) +# define DPR_READ(ARGS) if (DBG_READ) TRC(ARGS) +# define DPR_WRITE(ARGS) if (DBG_WRITE) TRC(ARGS) +# define DPR_IOCTL(ARGS) if (DBG_IOCTL) TRC(ARGS) +# define DPR_PROC(ARGS) if (DBG_PROC) TRC(ARGS) +# define DPR_PARAM(ARGS) if (DBG_PARAM) TRC(ARGS) +# define DPR_PSCAN(ARGS) if (DBG_PSCAN) TRC(ARGS) +# define DPR_EVENT(ARGS) if (DBG_EVENT) TRC(ARGS) +# define DPR_DRAIN(ARGS) if (DBG_DRAIN) TRC(ARGS) +# define DPR_CARR(ARGS) if (DBG_CARR) TRC(ARGS) +# define DPR_MGMT(ARGS) if (DBG_MGMT) TRC(ARGS) +# define DPR_INTR(ARGS) if (DBG_INTR) TRC(ARGS) +# define DPR_MSIGS(ARGS) if (DBG_MSIGS) TRC(ARGS) + +# define DPR(ARGS) if (dgnc_debug) TRC(ARGS) +# define P(X) dgnc_tracef(#X "=%p\n", X) +# define X(X) dgnc_tracef(#X "=%x\n", X) + +#else//!defined DGNC_TRACER + +#define PRINTF_TO_KMEM(args) +# define TRC(ARGS) +# define DPR_INIT(ARGS) +# define DPR_BASIC(ARGS) +# define DPR_CORE(ARGS) +# define DPR_OPEN(ARGS) +# define DPR_CLOSE(ARGS) +# define DPR_READ(ARGS) +# define DPR_WRITE(ARGS) +# define DPR_IOCTL(ARGS) +# define DPR_PROC(ARGS) +# define DPR_PARAM(ARGS) +# define DPR_PSCAN(ARGS) +# define DPR_EVENT(ARGS) +# define DPR_DRAIN(ARGS) +# define DPR_CARR(ARGS) +# define DPR_MGMT(ARGS) +# define DPR_INTR(ARGS) +# define DPR_MSIGS(ARGS) + +# define DPR(args) + +#endif//DGNC_TRACER + +/* Number of boards we support at once. */ +#define MAXBOARDS 20 +#define MAXPORTS 8 +#define MAXTTYNAMELEN 200 + +/* Our 3 magic numbers for our board, channel and unit structs */ +#define DGNC_BOARD_MAGIC 0x5c6df104 +#define DGNC_CHANNEL_MAGIC 0x6c6df104 +#define DGNC_UNIT_MAGIC 0x7c6df104 + +/* Serial port types */ +#define DGNC_SERIAL 0 +#define DGNC_PRINT 1 + +#define SERIAL_TYPE_NORMAL 1 + +#define PORT_NUM(dev) ((dev) & 0x7f) +#define IS_PRINT(dev) (((dev) & 0xff) >= 0x80) + +/* MAX number of stop characters we will send when our read queue is getting full */ +#define MAX_STOPS_SENT 5 + +/* 4 extra for alignment play space */ +#define WRITEBUFLEN ((4096) + 4) +#define MYFLIPLEN N_TTY_BUF_SIZE + +#define dgnc_jiffies_from_ms(a) (((a) * HZ) / 1000) + +/* + * Define a local default termios struct. All ports will be created + * with this termios initially. This is the same structure that is defined + * as the default in tty_io.c with the same settings overriden as in serial.c + * + * In short, this should match the internal serial ports' defaults. + */ +#define DEFAULT_IFLAGS (ICRNL | IXON) +#define DEFAULT_OFLAGS (OPOST | ONLCR) +#define DEFAULT_CFLAGS (B9600 | CS8 | CREAD | HUPCL | CLOCAL) +#define DEFAULT_LFLAGS (ISIG | ICANON | ECHO | ECHOE | ECHOK | \ + ECHOCTL | ECHOKE | IEXTEN) + +#ifndef _POSIX_VDISABLE +#define _POSIX_VDISABLE '\0' +#endif + +#define SNIFF_MAX 65536 /* Sniff buffer size (2^n) */ +#define SNIFF_MASK (SNIFF_MAX - 1) /* Sniff wrap mask */ + +/* + * Lock function/defines. + * Makes spotting lock/unlock locations easier. + */ +# define DGNC_SPINLOCK_INIT(x) spin_lock_init(&(x)) +# define DGNC_LOCK(x,y) spin_lock_irqsave(&(x), y) +# define DGNC_UNLOCK(x,y) spin_unlock_irqrestore(&(x), y) + +/* + * All the possible states the driver can be while being loaded. + */ +enum { + DRIVER_INITIALIZED = 0, + DRIVER_READY +}; + +/* + * All the possible states the board can be while booting up. + */ +enum { + BOARD_FAILED = 0, + BOARD_FOUND, + BOARD_READY +}; + + +/************************************************************************* + * + * Structures and closely related defines. + * + *************************************************************************/ + +struct board_t; +struct channel_t; + +/************************************************************************ + * Per board operations structure * + ************************************************************************/ +struct board_ops { + void (*tasklet) (unsigned long data); + irqreturn_t (*intr) (int irq, void *voidbrd); + void (*uart_init) (struct channel_t *ch); + void (*uart_off) (struct channel_t *ch); + int (*drain) (struct tty_struct *tty, uint seconds); + void (*param) (struct tty_struct *tty); + void (*vpd) (struct board_t *brd); + void (*assert_modem_signals) (struct channel_t *ch); + void (*flush_uart_write) (struct channel_t *ch); + void (*flush_uart_read) (struct channel_t *ch); + void (*disable_receiver) (struct channel_t *ch); + void (*enable_receiver) (struct channel_t *ch); + void (*send_break) (struct channel_t *ch, int); + void (*send_start_character) (struct channel_t *ch); + void (*send_stop_character) (struct channel_t *ch); + void (*copy_data_from_queue_to_uart) (struct channel_t *ch); + uint (*get_uart_bytes_left) (struct channel_t *ch); + void (*send_immediate_char) (struct channel_t *ch, unsigned char); +}; + +/************************************************************************ + * Device flag definitions for bd_flags. + ************************************************************************/ +#define BD_IS_PCI_EXPRESS 0x0001 /* Is a PCI Express board */ + + +/* + * Per-board information + */ +struct board_t +{ + int magic; /* Board Magic number. */ + int boardnum; /* Board number: 0-32 */ + + int type; /* Type of board */ + char *name; /* Product Name */ + struct pci_dev *pdev; /* Pointer to the pci_dev struct */ + unsigned long bd_flags; /* Board flags */ + u16 vendor; /* PCI vendor ID */ + u16 device; /* PCI device ID */ + u16 subvendor; /* PCI subsystem vendor ID */ + u16 subdevice; /* PCI subsystem device ID */ + uchar rev; /* PCI revision ID */ + uint pci_bus; /* PCI bus value */ + uint pci_slot; /* PCI slot value */ + uint maxports; /* MAX ports this board can handle */ + uchar dvid; /* Board specific device id */ + uchar vpd[128]; /* VPD of board, if found */ + uchar serial_num[20]; /* Serial number of board, if found in VPD */ + + spinlock_t bd_lock; /* Used to protect board */ + + spinlock_t bd_intr_lock; /* Used to protect the poller tasklet and + * the interrupt routine from each other. + */ + + uint state; /* State of card. */ + wait_queue_head_t state_wait; /* Place to sleep on for state change */ + + struct tasklet_struct helper_tasklet; /* Poll helper tasklet */ + + uint nasync; /* Number of ports on card */ + + uint irq; /* Interrupt request number */ + ulong intr_count; /* Count of interrupts */ + ulong intr_modem; /* Count of interrupts */ + ulong intr_tx; /* Count of interrupts */ + ulong intr_rx; /* Count of interrupts */ + + ulong membase; /* Start of base memory of the card */ + ulong membase_end; /* End of base memory of the card */ + + uchar *re_map_membase;/* Remapped memory of the card */ + + ulong iobase; /* Start of io base of the card */ + ulong iobase_end; /* End of io base of the card */ + + uint bd_uart_offset; /* Space between each UART */ + + struct channel_t *channels[MAXPORTS]; /* array of pointers to our channels. */ + + struct tty_driver SerialDriver; + char SerialName[200]; + struct tty_driver PrintDriver; + char PrintName[200]; + + uint dgnc_Major_Serial_Registered; + uint dgnc_Major_TransparentPrint_Registered; + + uint dgnc_Serial_Major; + uint dgnc_TransparentPrint_Major; + + uint TtyRefCnt; + + char *flipbuf; /* Our flip buffer, alloced if board is found */ + + u16 dpatype; /* The board "type", as defined by DPA */ + u16 dpastatus; /* The board "status", as defined by DPA */ + + /* + * Mgmt data. + */ + char *msgbuf_head; + char *msgbuf; + + uint bd_dividend; /* Board/UARTs specific dividend */ + + struct board_ops *bd_ops; + + /* /proc/ entries */ + struct proc_dir_entry *proc_entry_pointer; + struct dgnc_proc_entry *dgnc_board_table; + +}; + + +/************************************************************************ + * Unit flag definitions for un_flags. + ************************************************************************/ +#define UN_ISOPEN 0x0001 /* Device is open */ +#define UN_CLOSING 0x0002 /* Line is being closed */ +#define UN_IMM 0x0004 /* Service immediately */ +#define UN_BUSY 0x0008 /* Some work this channel */ +#define UN_BREAKI 0x0010 /* Input break received */ +#define UN_PWAIT 0x0020 /* Printer waiting for terminal */ +#define UN_TIME 0x0040 /* Waiting on time */ +#define UN_EMPTY 0x0080 /* Waiting output queue empty */ +#define UN_LOW 0x0100 /* Waiting output low water mark*/ +#define UN_EXCL_OPEN 0x0200 /* Open for exclusive use */ +#define UN_WOPEN 0x0400 /* Device waiting for open */ +#define UN_WIOCTL 0x0800 /* Device waiting for open */ +#define UN_HANGUP 0x8000 /* Carrier lost */ + +struct device; + +/************************************************************************ + * Structure for terminal or printer unit. + ************************************************************************/ +struct un_t { + int magic; /* Unit Magic Number. */ + struct channel_t *un_ch; + ulong un_time; + uint un_type; + uint un_open_count; /* Counter of opens to port */ + struct tty_struct *un_tty;/* Pointer to unit tty structure */ + uint un_flags; /* Unit flags */ + wait_queue_head_t un_flags_wait; /* Place to sleep to wait on unit */ + uint un_dev; /* Minor device number */ + struct device *un_sysfs; +}; + + +/************************************************************************ + * Device flag definitions for ch_flags. + ************************************************************************/ +#define CH_PRON 0x0001 /* Printer on string */ +#define CH_STOP 0x0002 /* Output is stopped */ +#define CH_STOPI 0x0004 /* Input is stopped */ +#define CH_CD 0x0008 /* Carrier is present */ +#define CH_FCAR 0x0010 /* Carrier forced on */ +#define CH_HANGUP 0x0020 /* Hangup received */ + +#define CH_RECEIVER_OFF 0x0040 /* Receiver is off */ +#define CH_OPENING 0x0080 /* Port in fragile open state */ +#define CH_CLOSING 0x0100 /* Port in fragile close state */ +#define CH_FIFO_ENABLED 0x0200 /* Port has FIFOs enabled */ +#define CH_TX_FIFO_EMPTY 0x0400 /* TX Fifo is completely empty */ +#define CH_TX_FIFO_LWM 0x0800 /* TX Fifo is below Low Water */ +#define CH_BREAK_SENDING 0x1000 /* Break is being sent */ +#define CH_LOOPBACK 0x2000 /* Channel is in lookback mode */ +#define CH_FLIPBUF_IN_USE 0x4000 /* Channel's flipbuf is in use */ +#define CH_BAUD0 0x08000 /* Used for checking B0 transitions */ +#define CH_FORCED_STOP 0x20000 /* Output is forcibly stopped */ +#define CH_FORCED_STOPI 0x40000 /* Input is forcibly stopped */ + +/* + * Definitions for ch_sniff_flags + */ +#define SNIFF_OPEN 0x1 +#define SNIFF_WAIT_DATA 0x2 +#define SNIFF_WAIT_SPACE 0x4 + + +/* Our Read/Error/Write queue sizes */ +#define RQUEUEMASK 0x1FFF /* 8 K - 1 */ +#define EQUEUEMASK 0x1FFF /* 8 K - 1 */ +#define WQUEUEMASK 0x0FFF /* 4 K - 1 */ +#define RQUEUESIZE (RQUEUEMASK + 1) +#define EQUEUESIZE RQUEUESIZE +#define WQUEUESIZE (WQUEUEMASK + 1) + + +/************************************************************************ + * Channel information structure. + ************************************************************************/ +struct channel_t { + int magic; /* Channel Magic Number */ + struct board_t *ch_bd; /* Board structure pointer */ + struct digi_t ch_digi; /* Transparent Print structure */ + struct un_t ch_tun; /* Terminal unit info */ + struct un_t ch_pun; /* Printer unit info */ + + spinlock_t ch_lock; /* provide for serialization */ + wait_queue_head_t ch_flags_wait; + + uint ch_portnum; /* Port number, 0 offset. */ + uint ch_open_count; /* open count */ + uint ch_flags; /* Channel flags */ + + ulong ch_close_delay; /* How long we should drop RTS/DTR for */ + + ulong ch_cpstime; /* Time for CPS calculations */ + + tcflag_t ch_c_iflag; /* channel iflags */ + tcflag_t ch_c_cflag; /* channel cflags */ + tcflag_t ch_c_oflag; /* channel oflags */ + tcflag_t ch_c_lflag; /* channel lflags */ + uchar ch_stopc; /* Stop character */ + uchar ch_startc; /* Start character */ + + uint ch_old_baud; /* Cache of the current baud */ + uint ch_custom_speed;/* Custom baud, if set */ + + uint ch_wopen; /* Waiting for open process cnt */ + + uchar ch_mostat; /* FEP output modem status */ + uchar ch_mistat; /* FEP input modem status */ + + struct neo_uart_struct *ch_neo_uart; /* Pointer to the "mapped" UART struct */ + struct cls_uart_struct *ch_cls_uart; /* Pointer to the "mapped" UART struct */ + + uchar ch_cached_lsr; /* Cached value of the LSR register */ + + uchar *ch_rqueue; /* Our read queue buffer - malloc'ed */ + ushort ch_r_head; /* Head location of the read queue */ + ushort ch_r_tail; /* Tail location of the read queue */ + + uchar *ch_equeue; /* Our error queue buffer - malloc'ed */ + ushort ch_e_head; /* Head location of the error queue */ + ushort ch_e_tail; /* Tail location of the error queue */ + + uchar *ch_wqueue; /* Our write queue buffer - malloc'ed */ + ushort ch_w_head; /* Head location of the write queue */ + ushort ch_w_tail; /* Tail location of the write queue */ + + ulong ch_rxcount; /* total of data received so far */ + ulong ch_txcount; /* total of data transmitted so far */ + + uchar ch_r_tlevel; /* Receive Trigger level */ + uchar ch_t_tlevel; /* Transmit Trigger level */ + + uchar ch_r_watermark; /* Receive Watermark */ + + ulong ch_stop_sending_break; /* Time we should STOP sending a break */ + + uint ch_stops_sent; /* How many times I have sent a stop character + * to try to stop the other guy sending. + */ + ulong ch_err_parity; /* Count of parity errors on channel */ + ulong ch_err_frame; /* Count of framing errors on channel */ + ulong ch_err_break; /* Count of breaks on channel */ + ulong ch_err_overrun; /* Count of overruns on channel */ + + ulong ch_xon_sends; /* Count of xons transmitted */ + ulong ch_xoff_sends; /* Count of xoffs transmitted */ + + ulong ch_intr_modem; /* Count of interrupts */ + ulong ch_intr_tx; /* Count of interrupts */ + ulong ch_intr_rx; /* Count of interrupts */ + + + /* /proc// entries */ + struct proc_dir_entry *proc_entry_pointer; + struct dgnc_proc_entry *dgnc_channel_table; + + uint ch_sniff_in; + uint ch_sniff_out; + char *ch_sniff_buf; /* Sniff buffer for proc */ + ulong ch_sniff_flags; /* Channel flags */ + wait_queue_head_t ch_sniff_wait; +}; + + +/************************************************************************* + * + * Prototypes for non-static functions used in more than one module + * + *************************************************************************/ + +extern int dgnc_ms_sleep(ulong ms); +extern void *dgnc_driver_kzmalloc(size_t size, int priority); +extern char *dgnc_ioctl_name(int cmd); + +/* + * Our Global Variables. + */ +extern int dgnc_driver_state; /* The state of the driver */ +extern uint dgnc_Major; /* Our driver/mgmt major */ +extern int dgnc_debug; /* Debug variable */ +extern int dgnc_rawreadok; /* Set if user wants rawreads */ +extern int dgnc_poll_tick; /* Poll interval - 20 ms */ +extern int dgnc_trcbuf_size; /* Size of the ringbuffer */ +extern spinlock_t dgnc_global_lock; /* Driver global spinlock */ +extern uint dgnc_NumBoards; /* Total number of boards */ +extern struct board_t *dgnc_Board[MAXBOARDS]; /* Array of board structs */ +extern ulong dgnc_poll_counter; /* Times the poller has run */ +extern char *dgnc_state_text[]; /* Array of state text */ +extern char *dgnc_driver_state_text[];/* Array of driver state text */ + +#endif diff --git a/drivers/staging/dgnc/dgnc_kcompat.h b/drivers/staging/dgnc/dgnc_kcompat.h new file mode 100644 index 0000000000000..3f69e1dddcafa --- /dev/null +++ b/drivers/staging/dgnc/dgnc_kcompat.h @@ -0,0 +1,91 @@ +/* + * Copyright 2004 Digi International (www.digi.com) + * Scott H Kilau + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! + * + ************************************************************************* + * + * This file is intended to contain all the kernel "differences" between the + * various kernels that we support. + * + *************************************************************************/ + +#ifndef __DGNC_KCOMPAT_H +#define __DGNC_KCOMPAT_H + +# ifndef KERNEL_VERSION +# define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) +# endif + + +#if !defined(TTY_FLIPBUF_SIZE) +# define TTY_FLIPBUF_SIZE 512 +#endif + + +/* Sparse stuff */ +# ifndef __user +# define __user +# define __kernel +# define __safe +# define __force +# define __chk_user_ptr(x) (void)0 +# endif + + +# define PARM_STR(VAR, INIT, PERM, DESC) \ + static char *VAR = INIT; \ + char *dgnc_##VAR; \ + module_param(VAR, charp, PERM); \ + MODULE_PARM_DESC(VAR, DESC); + +# define PARM_INT(VAR, INIT, PERM, DESC) \ + static int VAR = INIT; \ + int dgnc_##VAR; \ + module_param(VAR, int, PERM); \ + MODULE_PARM_DESC(VAR, DESC); + +# define PARM_ULONG(VAR, INIT, PERM, DESC) \ + static ulong VAR = INIT; \ + ulong dgnc_##VAR; \ + module_param(VAR, long, PERM); \ + MODULE_PARM_DESC(VAR, DESC); + + + + + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) + + + +/* NOTHING YET */ + + + +# else + + + +# error "this driver does not support anything below the 2.6.27 kernel series." + + + +# endif + +#endif /* ! __DGNC_KCOMPAT_H */ diff --git a/drivers/staging/dgnc/dgnc_mgmt.c b/drivers/staging/dgnc/dgnc_mgmt.c new file mode 100644 index 0000000000000..b8e47920111df --- /dev/null +++ b/drivers/staging/dgnc/dgnc_mgmt.c @@ -0,0 +1,313 @@ +/* + * Copyright 2003 Digi International (www.digi.com) + * Scott H Kilau + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * + * NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE! + * + * This is shared code between Digi's CVS archive and the + * Linux Kernel sources. + * Changing the source just for reformatting needlessly breaks + * our CVS diff history. + * + * Send any bug fixes/changes to: Eng.Linux at digi dot com. + * Thank you. + * + */ + +/************************************************************************ + * + * This file implements the mgmt functionality for the + * Neo and ClassicBoard based product lines. + * + ************************************************************************ + * $Id: dgnc_mgmt.c,v 1.2 2010/12/14 20:08:29 markh Exp $ + */ +#include +#include +#include +#include /* For jiffies, task states */ +#include /* For tasklet and interrupt structs/defines */ +#include +#include +#include /* For copy_from_user/copy_to_user */ + +#include "dgnc_driver.h" +#include "dgnc_pci.h" +#include "dgnc_proc.h" +#include "dgnc_kcompat.h" /* Kernel 2.4/2.6 compat includes */ +#include "dgnc_mgmt.h" +#include "dpacompat.h" + + +/* Our "in use" variables, to enforce 1 open only */ +static int dgnc_mgmt_in_use[MAXMGMTDEVICES]; + + +/* + * dgnc_mgmt_open() + * + * Open the mgmt/downld/dpa device + */ +int dgnc_mgmt_open(struct inode *inode, struct file *file) +{ + unsigned long lock_flags; + unsigned int minor = iminor(inode); + + DPR_MGMT(("dgnc_mgmt_open start.\n")); + + DGNC_LOCK(dgnc_global_lock, lock_flags); + + /* mgmt device */ + if (minor < MAXMGMTDEVICES) { + /* Only allow 1 open at a time on mgmt device */ + if (dgnc_mgmt_in_use[minor]) { + DGNC_UNLOCK(dgnc_global_lock, lock_flags); + return (-EBUSY); + } + dgnc_mgmt_in_use[minor]++; + } + else { + DGNC_UNLOCK(dgnc_global_lock, lock_flags); + return (-ENXIO); + } + + DGNC_UNLOCK(dgnc_global_lock, lock_flags); + + DPR_MGMT(("dgnc_mgmt_open finish.\n")); + + return 0; +} + + +/* + * dgnc_mgmt_close() + * + * Open the mgmt/dpa device + */ +int dgnc_mgmt_close(struct inode *inode, struct file *file) +{ + unsigned long lock_flags; + unsigned int minor = iminor(inode); + + DPR_MGMT(("dgnc_mgmt_close start.\n")); + + DGNC_LOCK(dgnc_global_lock, lock_flags); + + /* mgmt device */ + if (minor < MAXMGMTDEVICES) { + if (dgnc_mgmt_in_use[minor]) { + dgnc_mgmt_in_use[minor] = 0; + } + } + DGNC_UNLOCK(dgnc_global_lock, lock_flags); + + DPR_MGMT(("dgnc_mgmt_close finish.\n")); + + return 0; +} + + +/* + * dgnc_mgmt_ioctl() + * + * ioctl the mgmt/dpa device + */ +#ifdef HAVE_UNLOCKED_IOCTL +long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +{ + struct inode *inode = file->f_dentry->d_inode; +#else +int dgnc_mgmt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) +{ +#endif + unsigned long lock_flags; + void __user *uarg = (void __user *) arg; + + DPR_MGMT(("dgnc_mgmt_ioctl start.\n")); + + switch (cmd) { + + case DIGI_GETDD: + { + /* + * This returns the total number of boards + * in the system, as well as driver version + * and has space for a reserved entry + */ + struct digi_dinfo ddi; + + DGNC_LOCK(dgnc_global_lock, lock_flags); + + ddi.dinfo_nboards = dgnc_NumBoards; + sprintf(ddi.dinfo_version, "%s", DG_PART); + + DGNC_UNLOCK(dgnc_global_lock, lock_flags); + + DPR_MGMT(("DIGI_GETDD returning numboards: %d version: %s\n", + ddi.dinfo_nboards, ddi.dinfo_version)); + + if (copy_to_user(uarg, &ddi, sizeof (ddi))) + return(-EFAULT); + + break; + } + + case DIGI_GETBD: + { + int brd; + + struct digi_info di; + + if (copy_from_user(&brd, uarg, sizeof(int))) { + return(-EFAULT); + } + + DPR_MGMT(("DIGI_GETBD asking about board: %d\n", brd)); + + if ((brd < 0) || (brd > dgnc_NumBoards) || (dgnc_NumBoards == 0)) + return (-ENODEV); + + memset(&di, 0, sizeof(di)); + + di.info_bdnum = brd; + + DGNC_LOCK(dgnc_Board[brd]->bd_lock, lock_flags); + + di.info_bdtype = dgnc_Board[brd]->dpatype; + di.info_bdstate = dgnc_Board[brd]->dpastatus; + di.info_ioport = 0; + di.info_physaddr = (ulong) dgnc_Board[brd]->membase; + di.info_physsize = (ulong) dgnc_Board[brd]->membase - dgnc_Board[brd]->membase_end; + if (dgnc_Board[brd]->state != BOARD_FAILED) + di.info_nports = dgnc_Board[brd]->nasync; + else + di.info_nports = 0; + + DGNC_UNLOCK(dgnc_Board[brd]->bd_lock, lock_flags); + + DPR_MGMT(("DIGI_GETBD returning type: %x state: %x ports: %x size: %x\n", + di.info_bdtype, di.info_bdstate, di.info_nports, di.info_physsize)); + + if (copy_to_user(uarg, &di, sizeof (di))) + return (-EFAULT); + + break; + } + + case DIGI_GET_NI_INFO: + { + struct channel_t *ch; + struct ni_info ni; + uchar mstat = 0; + uint board = 0; + uint channel = 0; + + if (copy_from_user(&ni, uarg, sizeof(struct ni_info))) { + return(-EFAULT); + } + + DPR_MGMT(("DIGI_GETBD asking about board: %d channel: %d\n", + ni.board, ni.channel)); + + board = ni.board; + channel = ni.channel; + + /* Verify boundaries on board */ + if ((board < 0) || (board > dgnc_NumBoards) || (dgnc_NumBoards == 0)) + return (-ENODEV); + + /* Verify boundaries on channel */ + if ((channel < 0) || (channel > dgnc_Board[board]->nasync)) + return (-ENODEV); + + ch = dgnc_Board[board]->channels[channel]; + + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return (-ENODEV); + + memset(&ni, 0, sizeof(ni)); + ni.board = board; + ni.channel = channel; + + DGNC_LOCK(ch->ch_lock, lock_flags); + + mstat = (ch->ch_mostat | ch->ch_mistat); + + if (mstat & UART_MCR_DTR) { + ni.mstat |= TIOCM_DTR; + ni.dtr = TIOCM_DTR; + } + if (mstat & UART_MCR_RTS) { + ni.mstat |= TIOCM_RTS; + ni.rts = TIOCM_RTS; + } + if (mstat & UART_MSR_CTS) { + ni.mstat |= TIOCM_CTS; + ni.cts = TIOCM_CTS; + } + if (mstat & UART_MSR_RI) { + ni.mstat |= TIOCM_RI; + ni.ri = TIOCM_RI; + } + if (mstat & UART_MSR_DCD) { + ni.mstat |= TIOCM_CD; + ni.dcd = TIOCM_CD; + } + if (mstat & UART_MSR_DSR) + ni.mstat |= TIOCM_DSR; + + ni.iflag = ch->ch_c_iflag; + ni.oflag = ch->ch_c_oflag; + ni.cflag = ch->ch_c_cflag; + ni.lflag = ch->ch_c_lflag; + + if (ch->ch_digi.digi_flags & CTSPACE || ch->ch_c_cflag & CRTSCTS) + ni.hflow = 1; + else + ni.hflow = 0; + + if ((ch->ch_flags & CH_STOPI) || (ch->ch_flags & CH_FORCED_STOPI)) + ni.recv_stopped = 1; + else + ni.recv_stopped = 0; + + if ((ch->ch_flags & CH_STOP) || (ch->ch_flags & CH_FORCED_STOP)) + ni.xmit_stopped = 1; + else + ni.xmit_stopped = 0; + + ni.curtx = ch->ch_txcount; + ni.currx = ch->ch_rxcount; + + ni.baud = ch->ch_old_baud; + + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + if (copy_to_user(uarg, &ni, sizeof(ni))) + return (-EFAULT); + + break; + } + + + } + + DPR_MGMT(("dgnc_mgmt_ioctl finish.\n")); + + return 0; +} diff --git a/drivers/staging/dgnc/dgnc_mgmt.h b/drivers/staging/dgnc/dgnc_mgmt.h new file mode 100644 index 0000000000000..a0d1338ee5457 --- /dev/null +++ b/drivers/staging/dgnc/dgnc_mgmt.h @@ -0,0 +1,37 @@ +/* + * Copyright 2003 Digi International (www.digi.com) + * Scott H Kilau + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! + */ + +#ifndef __DGNC_MGMT_H +#define __DGNC_MGMT_H + +#define MAXMGMTDEVICES 8 + +int dgnc_mgmt_open(struct inode *inode, struct file *file); +int dgnc_mgmt_close(struct inode *inode, struct file *file); + +#ifdef HAVE_UNLOCKED_IOCTL +long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg); +#else +int dgnc_mgmt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg); +#endif + +#endif + diff --git a/drivers/staging/dgnc/dgnc_neo.c b/drivers/staging/dgnc/dgnc_neo.c new file mode 100644 index 0000000000000..503db8fae166c --- /dev/null +++ b/drivers/staging/dgnc/dgnc_neo.c @@ -0,0 +1,1977 @@ +/* + * Copyright 2003 Digi International (www.digi.com) + * Scott H Kilau + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * + * NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE! + * + * This is shared code between Digi's CVS archive and the + * Linux Kernel sources. + * Changing the source just for reformatting needlessly breaks + * our CVS diff history. + * + * Send any bug fixes/changes to: Eng.Linux at digi dot com. + * Thank you. + * + * + * $Id: dgnc_neo.c,v 1.1.1.1 2009/05/20 12:19:19 markh Exp $ + */ + + +#include +#include +#include /* For jiffies, task states */ +#include /* For tasklet and interrupt structs/defines */ +#include /* For udelay */ +#include /* For read[bwl]/write[bwl] */ +#include /* For struct async_serial */ +#include /* For the various UART offsets */ + +#include "dgnc_driver.h" /* Driver main header file */ +#include "dgnc_neo.h" /* Our header file */ +#include "dgnc_tty.h" +#include "dgnc_trace.h" + +static inline void neo_parse_lsr(struct board_t *brd, uint port); +static inline void neo_parse_isr(struct board_t *brd, uint port); +static void neo_copy_data_from_uart_to_queue(struct channel_t *ch); +static inline void neo_clear_break(struct channel_t *ch, int force); +static inline void neo_set_cts_flow_control(struct channel_t *ch); +static inline void neo_set_rts_flow_control(struct channel_t *ch); +static inline void neo_set_ixon_flow_control(struct channel_t *ch); +static inline void neo_set_ixoff_flow_control(struct channel_t *ch); +static inline void neo_set_no_output_flow_control(struct channel_t *ch); +static inline void neo_set_no_input_flow_control(struct channel_t *ch); +static inline void neo_set_new_start_stop_chars(struct channel_t *ch); +static void neo_parse_modem(struct channel_t *ch, uchar signals); +static void neo_tasklet(unsigned long data); +static void neo_vpd(struct board_t *brd); +static void neo_uart_init(struct channel_t *ch); +static void neo_uart_off(struct channel_t *ch); +static int neo_drain(struct tty_struct *tty, uint seconds); +static void neo_param(struct tty_struct *tty); +static void neo_assert_modem_signals(struct channel_t *ch); +static void neo_flush_uart_write(struct channel_t *ch); +static void neo_flush_uart_read(struct channel_t *ch); +static void neo_disable_receiver(struct channel_t *ch); +static void neo_enable_receiver(struct channel_t *ch); +static void neo_send_break(struct channel_t *ch, int msecs); +static void neo_send_start_character(struct channel_t *ch); +static void neo_send_stop_character(struct channel_t *ch); +static void neo_copy_data_from_queue_to_uart(struct channel_t *ch); +static uint neo_get_uart_bytes_left(struct channel_t *ch); +static void neo_send_immediate_char(struct channel_t *ch, unsigned char c); +static irqreturn_t neo_intr(int irq, void *voidbrd); + + +struct board_ops dgnc_neo_ops = { + .tasklet = neo_tasklet, + .intr = neo_intr, + .uart_init = neo_uart_init, + .uart_off = neo_uart_off, + .drain = neo_drain, + .param = neo_param, + .vpd = neo_vpd, + .assert_modem_signals = neo_assert_modem_signals, + .flush_uart_write = neo_flush_uart_write, + .flush_uart_read = neo_flush_uart_read, + .disable_receiver = neo_disable_receiver, + .enable_receiver = neo_enable_receiver, + .send_break = neo_send_break, + .send_start_character = neo_send_start_character, + .send_stop_character = neo_send_stop_character, + .copy_data_from_queue_to_uart = neo_copy_data_from_queue_to_uart, + .get_uart_bytes_left = neo_get_uart_bytes_left, + .send_immediate_char = neo_send_immediate_char +}; + +static uint dgnc_offset_table[8] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 }; + + +/* + * This function allows calls to ensure that all outstanding + * PCI writes have been completed, by doing a PCI read against + * a non-destructive, read-only location on the Neo card. + * + * In this case, we are reading the DVID (Read-only Device Identification) + * value of the Neo card. + */ +static inline void neo_pci_posting_flush(struct board_t *bd) +{ + readb(bd->re_map_membase + 0x8D); +} + +static inline void neo_set_cts_flow_control(struct channel_t *ch) +{ + uchar ier = readb(&ch->ch_neo_uart->ier); + uchar efr = readb(&ch->ch_neo_uart->efr); + + + DPR_PARAM(("Setting CTSFLOW\n")); + + /* Turn on auto CTS flow control */ +#if 1 + ier |= (UART_17158_IER_CTSDSR); +#else + ier &= ~(UART_17158_IER_CTSDSR); +#endif + + efr |= (UART_17158_EFR_ECB | UART_17158_EFR_CTSDSR); + + /* Turn off auto Xon flow control */ + efr &= ~(UART_17158_EFR_IXON); + + /* Why? Becuz Exar's spec says we have to zero it out before setting it */ + writeb(0, &ch->ch_neo_uart->efr); + + /* Turn on UART enhanced bits */ + writeb(efr, &ch->ch_neo_uart->efr); + + /* Turn on table D, with 8 char hi/low watermarks */ + writeb((UART_17158_FCTR_TRGD | UART_17158_FCTR_RTS_4DELAY), &ch->ch_neo_uart->fctr); + + /* Feed the UART our trigger levels */ + writeb(8, &ch->ch_neo_uart->tfifo); + ch->ch_t_tlevel = 8; + + writeb(ier, &ch->ch_neo_uart->ier); + + neo_pci_posting_flush(ch->ch_bd); +} + + +static inline void neo_set_rts_flow_control(struct channel_t *ch) +{ + uchar ier = readb(&ch->ch_neo_uart->ier); + uchar efr = readb(&ch->ch_neo_uart->efr); + + DPR_PARAM(("Setting RTSFLOW\n")); + + /* Turn on auto RTS flow control */ +#if 1 + ier |= (UART_17158_IER_RTSDTR); +#else + ier &= ~(UART_17158_IER_RTSDTR); +#endif + efr |= (UART_17158_EFR_ECB | UART_17158_EFR_RTSDTR); + + /* Turn off auto Xoff flow control */ + ier &= ~(UART_17158_IER_XOFF); + efr &= ~(UART_17158_EFR_IXOFF); + + /* Why? Becuz Exar's spec says we have to zero it out before setting it */ + writeb(0, &ch->ch_neo_uart->efr); + + /* Turn on UART enhanced bits */ + writeb(efr, &ch->ch_neo_uart->efr); + + writeb((UART_17158_FCTR_TRGD | UART_17158_FCTR_RTS_4DELAY), &ch->ch_neo_uart->fctr); + ch->ch_r_watermark = 4; + + writeb(32, &ch->ch_neo_uart->rfifo); + ch->ch_r_tlevel = 32; + + writeb(ier, &ch->ch_neo_uart->ier); + + /* + * From the Neo UART spec sheet: + * The auto RTS/DTR function must be started by asserting + * RTS/DTR# output pin (MCR bit-0 or 1 to logic 1 after + * it is enabled. + */ + ch->ch_mostat |= (UART_MCR_RTS); + + neo_pci_posting_flush(ch->ch_bd); +} + + +static inline void neo_set_ixon_flow_control(struct channel_t *ch) +{ + uchar ier = readb(&ch->ch_neo_uart->ier); + uchar efr = readb(&ch->ch_neo_uart->efr); + + DPR_PARAM(("Setting IXON FLOW\n")); + + /* Turn off auto CTS flow control */ + ier &= ~(UART_17158_IER_CTSDSR); + efr &= ~(UART_17158_EFR_CTSDSR); + + /* Turn on auto Xon flow control */ + efr |= (UART_17158_EFR_ECB | UART_17158_EFR_IXON); + + /* Why? Becuz Exar's spec says we have to zero it out before setting it */ + writeb(0, &ch->ch_neo_uart->efr); + + /* Turn on UART enhanced bits */ + writeb(efr, &ch->ch_neo_uart->efr); + + writeb((UART_17158_FCTR_TRGD | UART_17158_FCTR_RTS_8DELAY), &ch->ch_neo_uart->fctr); + ch->ch_r_watermark = 4; + + writeb(32, &ch->ch_neo_uart->rfifo); + ch->ch_r_tlevel = 32; + + /* Tell UART what start/stop chars it should be looking for */ + writeb(ch->ch_startc, &ch->ch_neo_uart->xonchar1); + writeb(0, &ch->ch_neo_uart->xonchar2); + + writeb(ch->ch_stopc, &ch->ch_neo_uart->xoffchar1); + writeb(0, &ch->ch_neo_uart->xoffchar2); + + writeb(ier, &ch->ch_neo_uart->ier); + + neo_pci_posting_flush(ch->ch_bd); +} + + +static inline void neo_set_ixoff_flow_control(struct channel_t *ch) +{ + uchar ier = readb(&ch->ch_neo_uart->ier); + uchar efr = readb(&ch->ch_neo_uart->efr); + + DPR_PARAM(("Setting IXOFF FLOW\n")); + + /* Turn off auto RTS flow control */ + ier &= ~(UART_17158_IER_RTSDTR); + efr &= ~(UART_17158_EFR_RTSDTR); + + /* Turn on auto Xoff flow control */ + ier |= (UART_17158_IER_XOFF); + efr |= (UART_17158_EFR_ECB | UART_17158_EFR_IXOFF); + + /* Why? Becuz Exar's spec says we have to zero it out before setting it */ + writeb(0, &ch->ch_neo_uart->efr); + + /* Turn on UART enhanced bits */ + writeb(efr, &ch->ch_neo_uart->efr); + + /* Turn on table D, with 8 char hi/low watermarks */ + writeb((UART_17158_FCTR_TRGD | UART_17158_FCTR_RTS_8DELAY), &ch->ch_neo_uart->fctr); + + writeb(8, &ch->ch_neo_uart->tfifo); + ch->ch_t_tlevel = 8; + + /* Tell UART what start/stop chars it should be looking for */ + writeb(ch->ch_startc, &ch->ch_neo_uart->xonchar1); + writeb(0, &ch->ch_neo_uart->xonchar2); + + writeb(ch->ch_stopc, &ch->ch_neo_uart->xoffchar1); + writeb(0, &ch->ch_neo_uart->xoffchar2); + + writeb(ier, &ch->ch_neo_uart->ier); + + neo_pci_posting_flush(ch->ch_bd); +} + + +static inline void neo_set_no_input_flow_control(struct channel_t *ch) +{ + uchar ier = readb(&ch->ch_neo_uart->ier); + uchar efr = readb(&ch->ch_neo_uart->efr); + + DPR_PARAM(("Unsetting Input FLOW\n")); + + /* Turn off auto RTS flow control */ + ier &= ~(UART_17158_IER_RTSDTR); + efr &= ~(UART_17158_EFR_RTSDTR); + + /* Turn off auto Xoff flow control */ + ier &= ~(UART_17158_IER_XOFF); + if (ch->ch_c_iflag & IXON) + efr &= ~(UART_17158_EFR_IXOFF); + else + efr &= ~(UART_17158_EFR_ECB | UART_17158_EFR_IXOFF); + + + /* Why? Becuz Exar's spec says we have to zero it out before setting it */ + writeb(0, &ch->ch_neo_uart->efr); + + /* Turn on UART enhanced bits */ + writeb(efr, &ch->ch_neo_uart->efr); + + /* Turn on table D, with 8 char hi/low watermarks */ + writeb((UART_17158_FCTR_TRGD | UART_17158_FCTR_RTS_8DELAY), &ch->ch_neo_uart->fctr); + + ch->ch_r_watermark = 0; + + writeb(16, &ch->ch_neo_uart->tfifo); + ch->ch_t_tlevel = 16; + + writeb(16, &ch->ch_neo_uart->rfifo); + ch->ch_r_tlevel = 16; + + writeb(ier, &ch->ch_neo_uart->ier); + + neo_pci_posting_flush(ch->ch_bd); +} + + +static inline void neo_set_no_output_flow_control(struct channel_t *ch) +{ + uchar ier = readb(&ch->ch_neo_uart->ier); + uchar efr = readb(&ch->ch_neo_uart->efr); + + DPR_PARAM(("Unsetting Output FLOW\n")); + + /* Turn off auto CTS flow control */ + ier &= ~(UART_17158_IER_CTSDSR); + efr &= ~(UART_17158_EFR_CTSDSR); + + /* Turn off auto Xon flow control */ + if (ch->ch_c_iflag & IXOFF) + efr &= ~(UART_17158_EFR_IXON); + else + efr &= ~(UART_17158_EFR_ECB | UART_17158_EFR_IXON); + + /* Why? Becuz Exar's spec says we have to zero it out before setting it */ + writeb(0, &ch->ch_neo_uart->efr); + + /* Turn on UART enhanced bits */ + writeb(efr, &ch->ch_neo_uart->efr); + + /* Turn on table D, with 8 char hi/low watermarks */ + writeb((UART_17158_FCTR_TRGD | UART_17158_FCTR_RTS_8DELAY), &ch->ch_neo_uart->fctr); + + ch->ch_r_watermark = 0; + + writeb(16, &ch->ch_neo_uart->tfifo); + ch->ch_t_tlevel = 16; + + writeb(16, &ch->ch_neo_uart->rfifo); + ch->ch_r_tlevel = 16; + + writeb(ier, &ch->ch_neo_uart->ier); + + neo_pci_posting_flush(ch->ch_bd); +} + + +/* change UARTs start/stop chars */ +static inline void neo_set_new_start_stop_chars(struct channel_t *ch) +{ + + /* if hardware flow control is set, then skip this whole thing */ + if (ch->ch_digi.digi_flags & (CTSPACE | RTSPACE) || ch->ch_c_cflag & CRTSCTS) + return; + + DPR_PARAM(("In new start stop chars\n")); + + /* Tell UART what start/stop chars it should be looking for */ + writeb(ch->ch_startc, &ch->ch_neo_uart->xonchar1); + writeb(0, &ch->ch_neo_uart->xonchar2); + + writeb(ch->ch_stopc, &ch->ch_neo_uart->xoffchar1); + writeb(0, &ch->ch_neo_uart->xoffchar2); + + neo_pci_posting_flush(ch->ch_bd); +} + + +/* + * No locks are assumed to be held when calling this function. + */ +static inline void neo_clear_break(struct channel_t *ch, int force) +{ + ulong lock_flags; + + DGNC_LOCK(ch->ch_lock, lock_flags); + + /* Bail if we aren't currently sending a break. */ + if (!ch->ch_stop_sending_break) { + DGNC_UNLOCK(ch->ch_lock, lock_flags); + return; + } + + /* Turn break off, and unset some variables */ + if (ch->ch_flags & CH_BREAK_SENDING) { + if ((jiffies >= ch->ch_stop_sending_break) || force) { + uchar temp = readb(&ch->ch_neo_uart->lcr); + writeb((temp & ~UART_LCR_SBC), &ch->ch_neo_uart->lcr); + neo_pci_posting_flush(ch->ch_bd); + ch->ch_flags &= ~(CH_BREAK_SENDING); + ch->ch_stop_sending_break = 0; + DPR_IOCTL(("Finishing UART_LCR_SBC! finished: %lx\n", jiffies)); + } + } + DGNC_UNLOCK(ch->ch_lock, lock_flags); +} + + +/* + * Parse the ISR register. + */ +static inline void neo_parse_isr(struct board_t *brd, uint port) +{ + struct channel_t *ch; + uchar isr; + uchar cause; + ulong lock_flags; + + if (!brd || brd->magic != DGNC_BOARD_MAGIC) + return; + + if (port > brd->maxports) + return; + + ch = brd->channels[port]; + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return; + + /* Here we try to figure out what caused the interrupt to happen */ + while (1) { + + isr = readb(&ch->ch_neo_uart->isr_fcr); + + /* Bail if no pending interrupt */ + if (isr & UART_IIR_NO_INT) { + break; + } + + /* + * Yank off the upper 2 bits, which just show that the FIFO's are enabled. + */ + isr &= ~(UART_17158_IIR_FIFO_ENABLED); + + DPR_INTR(("%s:%d isr: %x\n", __FILE__, __LINE__, isr)); + + if (isr & (UART_17158_IIR_RDI_TIMEOUT | UART_IIR_RDI)) { + /* Read data from uart -> queue */ + brd->intr_rx++; + ch->ch_intr_rx++; + neo_copy_data_from_uart_to_queue(ch); + + /* Call our tty layer to enforce queue flow control if needed. */ + DGNC_LOCK(ch->ch_lock, lock_flags); + dgnc_check_queue_flow_control(ch); + DGNC_UNLOCK(ch->ch_lock, lock_flags); + } + + if (isr & UART_IIR_THRI) { + brd->intr_tx++; + ch->ch_intr_tx++; + /* Transfer data (if any) from Write Queue -> UART. */ + DGNC_LOCK(ch->ch_lock, lock_flags); + ch->ch_flags |= (CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM); + DGNC_UNLOCK(ch->ch_lock, lock_flags); + neo_copy_data_from_queue_to_uart(ch); + } + + if (isr & UART_17158_IIR_XONXOFF) { + cause = readb(&ch->ch_neo_uart->xoffchar1); + + DPR_INTR(("Port %d. Got ISR_XONXOFF: cause:%x\n", port, cause)); + + /* + * Since the UART detected either an XON or + * XOFF match, we need to figure out which + * one it was, so we can suspend or resume data flow. + */ + if (cause == UART_17158_XON_DETECT) { + /* Is output stopped right now, if so, resume it */ + if (brd->channels[port]->ch_flags & CH_STOP) { + DGNC_LOCK(ch->ch_lock, lock_flags); + ch->ch_flags &= ~(CH_STOP); + DGNC_UNLOCK(ch->ch_lock, lock_flags); + } + DPR_INTR(("Port %d. XON detected in incoming data\n", port)); + } + else if (cause == UART_17158_XOFF_DETECT) { + if (!(brd->channels[port]->ch_flags & CH_STOP)) { + DGNC_LOCK(ch->ch_lock, lock_flags); + ch->ch_flags |= CH_STOP; + DGNC_UNLOCK(ch->ch_lock, lock_flags); + DPR_INTR(("Setting CH_STOP\n")); + } + DPR_INTR(("Port: %d. XOFF detected in incoming data\n", port)); + } + } + + if (isr & UART_17158_IIR_HWFLOW_STATE_CHANGE) { + /* + * If we get here, this means the hardware is doing auto flow control. + * Check to see whether RTS/DTR or CTS/DSR caused this interrupt. + */ + brd->intr_modem++; + ch->ch_intr_modem++; + cause = readb(&ch->ch_neo_uart->mcr); + /* Which pin is doing auto flow? RTS or DTR? */ + if ((cause & 0x4) == 0) { + if (cause & UART_MCR_RTS) { + DGNC_LOCK(ch->ch_lock, lock_flags); + ch->ch_mostat |= UART_MCR_RTS; + DGNC_UNLOCK(ch->ch_lock, lock_flags); + } + else { + DGNC_LOCK(ch->ch_lock, lock_flags); + ch->ch_mostat &= ~(UART_MCR_RTS); + DGNC_UNLOCK(ch->ch_lock, lock_flags); + } + } else { + if (cause & UART_MCR_DTR) { + DGNC_LOCK(ch->ch_lock, lock_flags); + ch->ch_mostat |= UART_MCR_DTR; + DGNC_UNLOCK(ch->ch_lock, lock_flags); + } + else { + DGNC_LOCK(ch->ch_lock, lock_flags); + ch->ch_mostat &= ~(UART_MCR_DTR); + DGNC_UNLOCK(ch->ch_lock, lock_flags); + } + } + } + + /* Parse any modem signal changes */ + DPR_INTR(("MOD_STAT: sending to parse_modem_sigs\n")); + neo_parse_modem(ch, readb(&ch->ch_neo_uart->msr)); + } +} + + +static inline void neo_parse_lsr(struct board_t *brd, uint port) +{ + struct channel_t *ch; + int linestatus; + ulong lock_flags; + + if (!brd) + return; + + if (brd->magic != DGNC_BOARD_MAGIC) + return; + + if (port > brd->maxports) + return; + + ch = brd->channels[port]; + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return; + + linestatus = readb(&ch->ch_neo_uart->lsr); + + DPR_INTR(("%s:%d port: %d linestatus: %x\n", __FILE__, __LINE__, port, linestatus)); + + ch->ch_cached_lsr |= linestatus; + + if (ch->ch_cached_lsr & UART_LSR_DR) { + brd->intr_rx++; + ch->ch_intr_rx++; + /* Read data from uart -> queue */ + neo_copy_data_from_uart_to_queue(ch); + DGNC_LOCK(ch->ch_lock, lock_flags); + dgnc_check_queue_flow_control(ch); + DGNC_UNLOCK(ch->ch_lock, lock_flags); + } + + /* + * This is a special flag. It indicates that at least 1 + * RX error (parity, framing, or break) has happened. + * Mark this in our struct, which will tell me that I have + *to do the special RX+LSR read for this FIFO load. + */ + if (linestatus & UART_17158_RX_FIFO_DATA_ERROR) { + DPR_INTR(("%s:%d Port: %d Got an RX error, need to parse LSR\n", + __FILE__, __LINE__, port)); + } + + /* + * The next 3 tests should *NOT* happen, as the above test + * should encapsulate all 3... At least, thats what Exar says. + */ + + if (linestatus & UART_LSR_PE) { + ch->ch_err_parity++; + DPR_INTR(("%s:%d Port: %d. PAR ERR!\n", __FILE__, __LINE__, port)); + } + + if (linestatus & UART_LSR_FE) { + ch->ch_err_frame++; + DPR_INTR(("%s:%d Port: %d. FRM ERR!\n", __FILE__, __LINE__, port)); + } + + if (linestatus & UART_LSR_BI) { + ch->ch_err_break++; + DPR_INTR(("%s:%d Port: %d. BRK INTR!\n", __FILE__, __LINE__, port)); + } + + if (linestatus & UART_LSR_OE) { + /* + * Rx Oruns. Exar says that an orun will NOT corrupt + * the FIFO. It will just replace the holding register + * with this new data byte. So basically just ignore this. + * Probably we should eventually have an orun stat in our driver... + */ + ch->ch_err_overrun++; + DPR_INTR(("%s:%d Port: %d. Rx Overrun!\n", __FILE__, __LINE__, port)); + } + + if (linestatus & UART_LSR_THRE) { + brd->intr_tx++; + ch->ch_intr_tx++; + DGNC_LOCK(ch->ch_lock, lock_flags); + ch->ch_flags |= (CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM); + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + /* Transfer data (if any) from Write Queue -> UART. */ + neo_copy_data_from_queue_to_uart(ch); + } + else if (linestatus & UART_17158_TX_AND_FIFO_CLR) { + brd->intr_tx++; + ch->ch_intr_tx++; + DGNC_LOCK(ch->ch_lock, lock_flags); + ch->ch_flags |= (CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM); + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + /* Transfer data (if any) from Write Queue -> UART. */ + neo_copy_data_from_queue_to_uart(ch); + } +} + + +/* + * neo_param() + * Send any/all changes to the line to the UART. + */ +static void neo_param(struct tty_struct *tty) +{ + uchar lcr = 0; + uchar uart_lcr = 0; + uchar ier = 0; + uchar uart_ier = 0; + uint baud = 9600; + int quot = 0; + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + + if (!tty || tty->magic != TTY_MAGIC) { + return; + } + + un = (struct un_t *) tty->driver_data; + if (!un || un->magic != DGNC_UNIT_MAGIC) { + return; + } + + ch = un->un_ch; + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) { + return; + } + + bd = ch->ch_bd; + if (!bd || bd->magic != DGNC_BOARD_MAGIC) { + return; + } + + DPR_PARAM(("param start: tdev: %x cflags: %x oflags: %x iflags: %x\n", + ch->ch_tun.un_dev, ch->ch_c_cflag, ch->ch_c_oflag, ch->ch_c_iflag)); + + /* + * If baud rate is zero, flush queues, and set mval to drop DTR. + */ + if ((ch->ch_c_cflag & (CBAUD)) == 0) { + ch->ch_r_head = ch->ch_r_tail = 0; + ch->ch_e_head = ch->ch_e_tail = 0; + ch->ch_w_head = ch->ch_w_tail = 0; + + neo_flush_uart_write(ch); + neo_flush_uart_read(ch); + + /* The baudrate is B0 so all modem lines are to be dropped. */ + ch->ch_flags |= (CH_BAUD0); + ch->ch_mostat &= ~(UART_MCR_RTS | UART_MCR_DTR); + neo_assert_modem_signals(ch); + ch->ch_old_baud = 0; + return; + + } else if (ch->ch_custom_speed) { + + baud = ch->ch_custom_speed; + /* Handle transition from B0 */ + if (ch->ch_flags & CH_BAUD0) { + ch->ch_flags &= ~(CH_BAUD0); + + /* + * Bring back up RTS and DTR... + * Also handle RTS or DTR toggle if set. + */ + if (!(ch->ch_digi.digi_flags & DIGI_RTS_TOGGLE)) + ch->ch_mostat |= (UART_MCR_RTS); + if (!(ch->ch_digi.digi_flags & DIGI_DTR_TOGGLE)) + ch->ch_mostat |= (UART_MCR_DTR); + } + } else { + int iindex = 0; + int jindex = 0; + + ulong bauds[4][16] = { + { /* slowbaud */ + 0, 50, 75, 110, + 134, 150, 200, 300, + 600, 1200, 1800, 2400, + 4800, 9600, 19200, 38400 }, + { /* slowbaud & CBAUDEX */ + 0, 57600, 115200, 230400, + 460800, 150, 200, 921600, + 600, 1200, 1800, 2400, + 4800, 9600, 19200, 38400 }, + { /* fastbaud */ + 0, 57600, 76800, 115200, + 131657, 153600, 230400, 460800, + 921600, 1200, 1800, 2400, + 4800, 9600, 19200, 38400 }, + { /* fastbaud & CBAUDEX */ + 0, 57600, 115200, 230400, + 460800, 150, 200, 921600, + 600, 1200, 1800, 2400, + 4800, 9600, 19200, 38400 } + }; + + /* Only use the TXPrint baud rate if the terminal unit is NOT open */ + if (!(ch->ch_tun.un_flags & UN_ISOPEN) && (un->un_type == DGNC_PRINT)) + baud = C_BAUD(ch->ch_pun.un_tty) & 0xff; + else + baud = C_BAUD(ch->ch_tun.un_tty) & 0xff; + + if (ch->ch_c_cflag & CBAUDEX) + iindex = 1; + + if (ch->ch_digi.digi_flags & DIGI_FAST) + iindex += 2; + + jindex = baud; + + if ((iindex >= 0) && (iindex < 4) && (jindex >= 0) && (jindex < 16)) { + baud = bauds[iindex][jindex]; + } else { + DPR_IOCTL(("baud indices were out of range (%d)(%d)", + iindex, jindex)); + baud = 0; + } + + if (baud == 0) + baud = 9600; + + /* Handle transition from B0 */ + if (ch->ch_flags & CH_BAUD0) { + ch->ch_flags &= ~(CH_BAUD0); + + /* + * Bring back up RTS and DTR... + * Also handle RTS or DTR toggle if set. + */ + if (!(ch->ch_digi.digi_flags & DIGI_RTS_TOGGLE)) + ch->ch_mostat |= (UART_MCR_RTS); + if (!(ch->ch_digi.digi_flags & DIGI_DTR_TOGGLE)) + ch->ch_mostat |= (UART_MCR_DTR); + } + } + + if (ch->ch_c_cflag & PARENB) { + lcr |= UART_LCR_PARITY; + } + + if (!(ch->ch_c_cflag & PARODD)) { + lcr |= UART_LCR_EPAR; + } + + /* + * Not all platforms support mark/space parity, + * so this will hide behind an ifdef. + */ +#ifdef CMSPAR + if (ch->ch_c_cflag & CMSPAR) + lcr |= UART_LCR_SPAR; +#endif + + if (ch->ch_c_cflag & CSTOPB) + lcr |= UART_LCR_STOP; + + switch (ch->ch_c_cflag & CSIZE) { + case CS5: + lcr |= UART_LCR_WLEN5; + break; + case CS6: + lcr |= UART_LCR_WLEN6; + break; + case CS7: + lcr |= UART_LCR_WLEN7; + break; + case CS8: + default: + lcr |= UART_LCR_WLEN8; + break; + } + + ier = uart_ier = readb(&ch->ch_neo_uart->ier); + uart_lcr = readb(&ch->ch_neo_uart->lcr); + + if (baud == 0) + baud = 9600; + + quot = ch->ch_bd->bd_dividend / baud; + + if (quot != 0 && ch->ch_old_baud != baud) { + ch->ch_old_baud = baud; + writeb(UART_LCR_DLAB, &ch->ch_neo_uart->lcr); + writeb((quot & 0xff), &ch->ch_neo_uart->txrx); + writeb((quot >> 8), &ch->ch_neo_uart->ier); + writeb(lcr, &ch->ch_neo_uart->lcr); + } + + if (uart_lcr != lcr) + writeb(lcr, &ch->ch_neo_uart->lcr); + + if (ch->ch_c_cflag & CREAD) { + ier |= (UART_IER_RDI | UART_IER_RLSI); + } + else { + ier &= ~(UART_IER_RDI | UART_IER_RLSI); + } + + /* + * Have the UART interrupt on modem signal changes ONLY when + * we are in hardware flow control mode, or CLOCAL/FORCEDCD is not set. + */ + if ((ch->ch_digi.digi_flags & CTSPACE) || (ch->ch_digi.digi_flags & RTSPACE) || + (ch->ch_c_cflag & CRTSCTS) || !(ch->ch_digi.digi_flags & DIGI_FORCEDCD) || + !(ch->ch_c_cflag & CLOCAL)) + { + ier |= UART_IER_MSI; + } + else { + ier &= ~UART_IER_MSI; + } + + ier |= UART_IER_THRI; + + if (ier != uart_ier) + writeb(ier, &ch->ch_neo_uart->ier); + + /* Set new start/stop chars */ + neo_set_new_start_stop_chars(ch); + + if (ch->ch_digi.digi_flags & CTSPACE || ch->ch_c_cflag & CRTSCTS) { + neo_set_cts_flow_control(ch); + } + else if (ch->ch_c_iflag & IXON) { + /* If start/stop is set to disable, then we should disable flow control */ + if ((ch->ch_startc == _POSIX_VDISABLE) || (ch->ch_stopc == _POSIX_VDISABLE)) + neo_set_no_output_flow_control(ch); + else + neo_set_ixon_flow_control(ch); + } + else { + neo_set_no_output_flow_control(ch); + } + + if (ch->ch_digi.digi_flags & RTSPACE || ch->ch_c_cflag & CRTSCTS) { + neo_set_rts_flow_control(ch); + } + else if (ch->ch_c_iflag & IXOFF) { + /* If start/stop is set to disable, then we should disable flow control */ + if ((ch->ch_startc == _POSIX_VDISABLE) || (ch->ch_stopc == _POSIX_VDISABLE)) + neo_set_no_input_flow_control(ch); + else + neo_set_ixoff_flow_control(ch); + } + else { + neo_set_no_input_flow_control(ch); + } + + /* + * Adjust the RX FIFO Trigger level if baud is less than 9600. + * Not exactly elegant, but this is needed because of the Exar chip's + * delay on firing off the RX FIFO interrupt on slower baud rates. + */ + if (baud < 9600) { + writeb(1, &ch->ch_neo_uart->rfifo); + ch->ch_r_tlevel = 1; + } + + neo_assert_modem_signals(ch); + + /* Get current status of the modem signals now */ + neo_parse_modem(ch, readb(&ch->ch_neo_uart->msr)); +} + + +/* + * Our board poller function. + */ +static void neo_tasklet(unsigned long data) +{ + struct board_t *bd = (struct board_t *) data; + struct channel_t *ch; + ulong lock_flags; + int i; + int state = 0; + int ports = 0; + + if (!bd || bd->magic != DGNC_BOARD_MAGIC) { + APR(("poll_tasklet() - NULL or bad bd.\n")); + return; + } + + /* Cache a couple board values */ + DGNC_LOCK(bd->bd_lock, lock_flags); + state = bd->state; + ports = bd->nasync; + DGNC_UNLOCK(bd->bd_lock, lock_flags); + + /* + * Do NOT allow the interrupt routine to read the intr registers + * Until we release this lock. + */ + DGNC_LOCK(bd->bd_intr_lock, lock_flags); + + /* + * If board is ready, parse deeper to see if there is anything to do. + */ + if ((state == BOARD_READY) && (ports > 0)) { + /* Loop on each port */ + for (i = 0; i < ports; i++) { + ch = bd->channels[i]; + + /* Just being careful... */ + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + continue; + + /* + * NOTE: Remember you CANNOT hold any channel + * locks when calling the input routine. + * + * During input processing, its possible we + * will call the Linux ld, which might in turn, + * do a callback right back into us, resulting + * in us trying to grab the channel lock twice! + */ + dgnc_input(ch); + + /* + * Channel lock is grabbed and then released + * inside both of these routines, but neither + * call anything else that could call back into us. + */ + neo_copy_data_from_queue_to_uart(ch); + dgnc_wakeup_writes(ch); + + /* + * Call carrier carrier function, in case something + * has changed. + */ + dgnc_carrier(ch); + + /* + * Check to see if we need to turn off a sending break. + * The timing check is done inside clear_break() + */ + if (ch->ch_stop_sending_break) + neo_clear_break(ch, 0); + } + } + + /* Allow interrupt routine to access the interrupt register again */ + DGNC_UNLOCK(bd->bd_intr_lock, lock_flags); + +} + + +/* + * dgnc_neo_intr() + * + * Neo specific interrupt handler. + */ +static irqreturn_t neo_intr(int irq, void *voidbrd) +{ + struct board_t *brd = (struct board_t *) voidbrd; + struct channel_t *ch; + int port = 0; + int type = 0; + int current_port; + u32 tmp; + u32 uart_poll; + unsigned long lock_flags; + unsigned long lock_flags2; + + if (!brd) { + APR(("Received interrupt (%d) with null board associated\n", irq)); + return IRQ_NONE; + } + + /* + * Check to make sure its for us. + */ + if (brd->magic != DGNC_BOARD_MAGIC) { + APR(("Received interrupt (%d) with a board pointer that wasn't ours!\n", irq)); + return IRQ_NONE; + } + + brd->intr_count++; + + /* Lock out the slow poller from running on this board. */ + DGNC_LOCK(brd->bd_intr_lock, lock_flags); + + /* + * Read in "extended" IRQ information from the 32bit Neo register. + * Bits 0-7: What port triggered the interrupt. + * Bits 8-31: Each 3bits indicate what type of interrupt occurred. + */ + uart_poll = readl(brd->re_map_membase + UART_17158_POLL_ADDR_OFFSET); + + DPR_INTR(("%s:%d uart_poll: %x\n", __FILE__, __LINE__, uart_poll)); + + /* + * If 0, no interrupts pending. + * This can happen if the IRQ is shared among a couple Neo/Classic boards. + */ + if (!uart_poll) { + DPR_INTR(("Kernel interrupted to me, but no pending interrupts...\n")); + DGNC_UNLOCK(brd->bd_intr_lock, lock_flags); + return IRQ_NONE; + } + + /* At this point, we have at least SOMETHING to service, dig further... */ + + current_port = 0; + + /* Loop on each port */ + while ((uart_poll & 0xff) != 0) { + + tmp = uart_poll; + + /* Check current port to see if it has interrupt pending */ + if ((tmp & dgnc_offset_table[current_port]) != 0) { + port = current_port; + type = tmp >> (8 + (port * 3)); + type &= 0x7; + } else { + current_port++; + continue; + } + + DPR_INTR(("%s:%d port: %x type: %x\n", __FILE__, __LINE__, port, type)); + + /* Remove this port + type from uart_poll */ + uart_poll &= ~(dgnc_offset_table[port]); + + if (!type) { + /* If no type, just ignore it, and move onto next port */ + DPR_INTR(("Interrupt with no type! port: %d\n", port)); + continue; + } + + /* Switch on type of interrupt we have */ + switch (type) { + + case UART_17158_RXRDY_TIMEOUT: + /* + * RXRDY Time-out is cleared by reading data in the + * RX FIFO until it falls below the trigger level. + */ + + /* Verify the port is in range. */ + if (port > brd->nasync) + continue; + + ch = brd->channels[port]; + neo_copy_data_from_uart_to_queue(ch); + + /* Call our tty layer to enforce queue flow control if needed. */ + DGNC_LOCK(ch->ch_lock, lock_flags2); + dgnc_check_queue_flow_control(ch); + DGNC_UNLOCK(ch->ch_lock, lock_flags2); + + continue; + + case UART_17158_RX_LINE_STATUS: + /* + * RXRDY and RX LINE Status (logic OR of LSR[4:1]) + */ + neo_parse_lsr(brd, port); + continue; + + case UART_17158_TXRDY: + /* + * TXRDY interrupt clears after reading ISR register for the UART channel. + */ + + /* + * Yes, this is odd... + * Why would I check EVERY possibility of type of + * interrupt, when we know its TXRDY??? + * Becuz for some reason, even tho we got triggered for TXRDY, + * it seems to be occassionally wrong. Instead of TX, which + * it should be, I was getting things like RXDY too. Weird. + */ + neo_parse_isr(brd, port); + continue; + + case UART_17158_MSR: + /* + * MSR or flow control was seen. + */ + neo_parse_isr(brd, port); + continue; + + default: + /* + * The UART triggered us with a bogus interrupt type. + * It appears the Exar chip, when REALLY bogged down, will throw + * these once and awhile. + * Its harmless, just ignore it and move on. + */ + DPR_INTR(("%s:%d Unknown Interrupt type: %x\n", __FILE__, __LINE__, type)); + continue; + } + } + + /* + * Schedule tasklet to more in-depth servicing at a better time. + */ + tasklet_schedule(&brd->helper_tasklet); + + DGNC_UNLOCK(brd->bd_intr_lock, lock_flags); + + DPR_INTR(("dgnc_intr finish.\n")); + return IRQ_HANDLED; +} + + +/* + * Neo specific way of turning off the receiver. + * Used as a way to enforce queue flow control when in + * hardware flow control mode. + */ +static void neo_disable_receiver(struct channel_t *ch) +{ + uchar tmp = readb(&ch->ch_neo_uart->ier); + tmp &= ~(UART_IER_RDI); + writeb(tmp, &ch->ch_neo_uart->ier); + neo_pci_posting_flush(ch->ch_bd); +} + + +/* + * Neo specific way of turning on the receiver. + * Used as a way to un-enforce queue flow control when in + * hardware flow control mode. + */ +static void neo_enable_receiver(struct channel_t *ch) +{ + uchar tmp = readb(&ch->ch_neo_uart->ier); + tmp |= (UART_IER_RDI); + writeb(tmp, &ch->ch_neo_uart->ier); + neo_pci_posting_flush(ch->ch_bd); +} + + +static void neo_copy_data_from_uart_to_queue(struct channel_t *ch) +{ + int qleft = 0; + uchar linestatus = 0; + uchar error_mask = 0; + int n = 0; + int total = 0; + ushort head; + ushort tail; + ulong lock_flags; + + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return; + + DGNC_LOCK(ch->ch_lock, lock_flags); + + /* cache head and tail of queue */ + head = ch->ch_r_head & RQUEUEMASK; + tail = ch->ch_r_tail & RQUEUEMASK; + + /* Get our cached LSR */ + linestatus = ch->ch_cached_lsr; + ch->ch_cached_lsr = 0; + + /* Store how much space we have left in the queue */ + if ((qleft = tail - head - 1) < 0) + qleft += RQUEUEMASK + 1; + + /* + * If the UART is not in FIFO mode, force the FIFO copy to + * NOT be run, by setting total to 0. + * + * On the other hand, if the UART IS in FIFO mode, then ask + * the UART to give us an approximation of data it has RX'ed. + */ + if (!(ch->ch_flags & CH_FIFO_ENABLED)) + total = 0; + else { + total = readb(&ch->ch_neo_uart->rfifo); + + /* + * EXAR chip bug - RX FIFO COUNT - Fudge factor. + * + * This resolves a problem/bug with the Exar chip that sometimes + * returns a bogus value in the rfifo register. + * The count can be any where from 0-3 bytes "off". + * Bizarre, but true. + */ + if ((ch->ch_bd->dvid & 0xf0) >= UART_XR17E158_DVID) { + total -= 1; + } + else { + total -= 3; + } + } + + + /* + * Finally, bound the copy to make sure we don't overflow + * our own queue... + * The byte by byte copy loop below this loop this will + * deal with the queue overflow possibility. + */ + total = min(total, qleft); + + while (total > 0) { + + /* + * Grab the linestatus register, we need to check + * to see if there are any errors in the FIFO. + */ + linestatus = readb(&ch->ch_neo_uart->lsr); + + /* + * Break out if there is a FIFO error somewhere. + * This will allow us to go byte by byte down below, + * finding the exact location of the error. + */ + if (linestatus & UART_17158_RX_FIFO_DATA_ERROR) + break; + + /* Make sure we don't go over the end of our queue */ + n = min(((uint) total), (RQUEUESIZE - (uint) head)); + + /* + * Cut down n even further if needed, this is to fix + * a problem with memcpy_fromio() with the Neo on the + * IBM pSeries platform. + * 15 bytes max appears to be the magic number. + */ + n = min((uint) n, (uint) 12); + + /* + * Since we are grabbing the linestatus register, which + * will reset some bits after our read, we need to ensure + * we don't miss our TX FIFO emptys. + */ + if (linestatus & (UART_LSR_THRE | UART_17158_TX_AND_FIFO_CLR)) { + ch->ch_flags |= (CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM); + } + + linestatus = 0; + + /* Copy data from uart to the queue */ + memcpy_fromio(ch->ch_rqueue + head, &ch->ch_neo_uart->txrxburst, n); + dgnc_sniff_nowait_nolock(ch, "UART READ", ch->ch_rqueue + head, n); + + /* + * Since RX_FIFO_DATA_ERROR was 0, we are guarenteed + * that all the data currently in the FIFO is free of + * breaks and parity/frame/orun errors. + */ + memset(ch->ch_equeue + head, 0, n); + + /* Add to and flip head if needed */ + head = (head + n) & RQUEUEMASK; + total -= n; + qleft -= n; + ch->ch_rxcount += n; + } + + /* + * Create a mask to determine whether we should + * insert the character (if any) into our queue. + */ + if (ch->ch_c_iflag & IGNBRK) + error_mask |= UART_LSR_BI; + + /* + * Now cleanup any leftover bytes still in the UART. + * Also deal with any possible queue overflow here as well. + */ + while (1) { + + /* + * Its possible we have a linestatus from the loop above + * this, so we "OR" on any extra bits. + */ + linestatus |= readb(&ch->ch_neo_uart->lsr); + + /* + * If the chip tells us there is no more data pending to + * be read, we can then leave. + * But before we do, cache the linestatus, just in case. + */ + if (!(linestatus & UART_LSR_DR)) { + ch->ch_cached_lsr = linestatus; + break; + } + + /* No need to store this bit */ + linestatus &= ~UART_LSR_DR; + + /* + * Since we are grabbing the linestatus register, which + * will reset some bits after our read, we need to ensure + * we don't miss our TX FIFO emptys. + */ + if (linestatus & (UART_LSR_THRE | UART_17158_TX_AND_FIFO_CLR)) { + linestatus &= ~(UART_LSR_THRE | UART_17158_TX_AND_FIFO_CLR); + ch->ch_flags |= (CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM); + } + + /* + * Discard character if we are ignoring the error mask. + */ + if (linestatus & error_mask) { + uchar discard; + linestatus = 0; + memcpy_fromio(&discard, &ch->ch_neo_uart->txrxburst, 1); + continue; + } + + /* + * If our queue is full, we have no choice but to drop some data. + * The assumption is that HWFLOW or SWFLOW should have stopped + * things way way before we got to this point. + * + * I decided that I wanted to ditch the oldest data first, + * I hope thats okay with everyone? Yes? Good. + */ + while (qleft < 1) { + DPR_READ(("Queue full, dropping DATA:%x LSR:%x\n", + ch->ch_rqueue[tail], ch->ch_equeue[tail])); + + ch->ch_r_tail = tail = (tail + 1) & RQUEUEMASK; + ch->ch_err_overrun++; + qleft++; + } + + memcpy_fromio(ch->ch_rqueue + head, &ch->ch_neo_uart->txrxburst, 1); + ch->ch_equeue[head] = (uchar) linestatus; + dgnc_sniff_nowait_nolock(ch, "UART READ", ch->ch_rqueue + head, 1); + + DPR_READ(("DATA/LSR pair: %x %x\n", ch->ch_rqueue[head], ch->ch_equeue[head])); + + /* Ditch any remaining linestatus value. */ + linestatus = 0; + + /* Add to and flip head if needed */ + head = (head + 1) & RQUEUEMASK; + + qleft--; + ch->ch_rxcount++; + } + + /* + * Write new final heads to channel structure. + */ + ch->ch_r_head = head & RQUEUEMASK; + ch->ch_e_head = head & EQUEUEMASK; + + DGNC_UNLOCK(ch->ch_lock, lock_flags); +} + + +/* + * This function basically goes to sleep for secs, or until + * it gets signalled that the port has fully drained. + */ +static int neo_drain(struct tty_struct *tty, uint seconds) +{ + ulong lock_flags; + struct channel_t *ch; + struct un_t *un; + int rc = 0; + + if (!tty || tty->magic != TTY_MAGIC) { + return (-ENXIO); + } + + un = (struct un_t *) tty->driver_data; + if (!un || un->magic != DGNC_UNIT_MAGIC) { + return (-ENXIO); + } + + ch = un->un_ch; + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) { + return (-ENXIO); + } + + DPR_IOCTL(("%d Drain wait started.\n", __LINE__)); + + DGNC_LOCK(ch->ch_lock, lock_flags); + un->un_flags |= UN_EMPTY; + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + /* + * Go to sleep waiting for the tty layer to wake me back up when + * the empty flag goes away. + * + * NOTE: TODO: Do something with time passed in. + */ + rc = wait_event_interruptible(un->un_flags_wait, ((un->un_flags & UN_EMPTY) == 0)); + + /* If ret is non-zero, user ctrl-c'ed us */ + if (rc) { + DPR_IOCTL(("%d Drain - User ctrl c'ed\n", __LINE__)); + } + else { + DPR_IOCTL(("%d Drain wait finished.\n", __LINE__)); + } + + return (rc); +} + + +/* + * Flush the WRITE FIFO on the Neo. + * + * NOTE: Channel lock MUST be held before calling this function! + */ +static void neo_flush_uart_write(struct channel_t *ch) +{ + uchar tmp = 0; + int i = 0; + + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) { + return; + } + + writeb((UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_XMIT), &ch->ch_neo_uart->isr_fcr); + neo_pci_posting_flush(ch->ch_bd); + + for (i = 0; i < 10; i++) { + + /* Check to see if the UART feels it completely flushed the FIFO. */ + tmp = readb(&ch->ch_neo_uart->isr_fcr); + if (tmp & 4) { + DPR_IOCTL(("Still flushing TX UART... i: %d\n", i)); + udelay(10); + } + else + break; + } + + ch->ch_flags |= (CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM); +} + + +/* + * Flush the READ FIFO on the Neo. + * + * NOTE: Channel lock MUST be held before calling this function! + */ +static void neo_flush_uart_read(struct channel_t *ch) +{ + uchar tmp = 0; + int i = 0; + + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) { + return; + } + + writeb((UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR), &ch->ch_neo_uart->isr_fcr); + neo_pci_posting_flush(ch->ch_bd); + + for (i = 0; i < 10; i++) { + + /* Check to see if the UART feels it completely flushed the FIFO. */ + tmp = readb(&ch->ch_neo_uart->isr_fcr); + if (tmp & 2) { + DPR_IOCTL(("Still flushing RX UART... i: %d\n", i)); + udelay(10); + } + else + break; + } +} + + +static void neo_copy_data_from_queue_to_uart(struct channel_t *ch) +{ + ushort head; + ushort tail; + int n; + int s; + int qlen; + uint len_written = 0; + ulong lock_flags; + + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return; + + DGNC_LOCK(ch->ch_lock, lock_flags); + + /* No data to write to the UART */ + if (ch->ch_w_tail == ch->ch_w_head) { + DGNC_UNLOCK(ch->ch_lock, lock_flags); + return; + } + + /* If port is "stopped", don't send any data to the UART */ + if ((ch->ch_flags & CH_FORCED_STOP) || (ch->ch_flags & CH_BREAK_SENDING)) { + DGNC_UNLOCK(ch->ch_lock, lock_flags); + return; + } + + /* + * If FIFOs are disabled. Send data directly to txrx register + */ + if (!(ch->ch_flags & CH_FIFO_ENABLED)) { + uchar lsrbits = readb(&ch->ch_neo_uart->lsr); + + /* Cache the LSR bits for later parsing */ + ch->ch_cached_lsr |= lsrbits; + if (ch->ch_cached_lsr & UART_LSR_THRE) { + ch->ch_cached_lsr &= ~(UART_LSR_THRE); + + /* + * If RTS Toggle mode is on, turn on RTS now if not already set, + * and make sure we get an event when the data transfer has completed. + */ + if (ch->ch_digi.digi_flags & DIGI_RTS_TOGGLE) { + if (!(ch->ch_mostat & UART_MCR_RTS)) { + ch->ch_mostat |= (UART_MCR_RTS); + neo_assert_modem_signals(ch); + } + ch->ch_tun.un_flags |= (UN_EMPTY); + } + /* + * If DTR Toggle mode is on, turn on DTR now if not already set, + * and make sure we get an event when the data transfer has completed. + */ + if (ch->ch_digi.digi_flags & DIGI_DTR_TOGGLE) { + if (!(ch->ch_mostat & UART_MCR_DTR)) { + ch->ch_mostat |= (UART_MCR_DTR); + neo_assert_modem_signals(ch); + } + ch->ch_tun.un_flags |= (UN_EMPTY); + } + + writeb(ch->ch_wqueue[ch->ch_w_tail], &ch->ch_neo_uart->txrx); + DPR_WRITE(("Tx data: %x\n", ch->ch_wqueue[ch->ch_w_head])); + ch->ch_w_tail++; + ch->ch_w_tail &= WQUEUEMASK; + ch->ch_txcount++; + } + DGNC_UNLOCK(ch->ch_lock, lock_flags); + return; + } + + /* + * We have to do it this way, because of the EXAR TXFIFO count bug. + */ + if ((ch->ch_bd->dvid & 0xf0) < UART_XR17E158_DVID) { + if (!(ch->ch_flags & (CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM))) { + DGNC_UNLOCK(ch->ch_lock, lock_flags); + return; + } + + len_written = 0; + + n = readb(&ch->ch_neo_uart->tfifo); + + if ((unsigned int) n > ch->ch_t_tlevel) { + DGNC_UNLOCK(ch->ch_lock, lock_flags); + return; + } + + n = UART_17158_TX_FIFOSIZE - ch->ch_t_tlevel; + } + else { + n = UART_17158_TX_FIFOSIZE - readb(&ch->ch_neo_uart->tfifo); + } + + /* cache head and tail of queue */ + head = ch->ch_w_head & WQUEUEMASK; + tail = ch->ch_w_tail & WQUEUEMASK; + qlen = (head - tail) & WQUEUEMASK; + + /* Find minimum of the FIFO space, versus queue length */ + n = min(n, qlen); + + while (n > 0) { + + s = ((head >= tail) ? head : WQUEUESIZE) - tail; + s = min(s, n); + + if (s <= 0) + break; + + /* + * If RTS Toggle mode is on, turn on RTS now if not already set, + * and make sure we get an event when the data transfer has completed. + */ + if (ch->ch_digi.digi_flags & DIGI_RTS_TOGGLE) { + if (!(ch->ch_mostat & UART_MCR_RTS)) { + ch->ch_mostat |= (UART_MCR_RTS); + neo_assert_modem_signals(ch); + } + ch->ch_tun.un_flags |= (UN_EMPTY); + } + + /* + * If DTR Toggle mode is on, turn on DTR now if not already set, + * and make sure we get an event when the data transfer has completed. + */ + if (ch->ch_digi.digi_flags & DIGI_DTR_TOGGLE) { + if (!(ch->ch_mostat & UART_MCR_DTR)) { + ch->ch_mostat |= (UART_MCR_DTR); + neo_assert_modem_signals(ch); + } + ch->ch_tun.un_flags |= (UN_EMPTY); + } + + memcpy_toio(&ch->ch_neo_uart->txrxburst, ch->ch_wqueue + tail, s); + dgnc_sniff_nowait_nolock(ch, "UART WRITE", ch->ch_wqueue + tail, s); + + /* Add and flip queue if needed */ + tail = (tail + s) & WQUEUEMASK; + n -= s; + ch->ch_txcount += s; + len_written += s; + } + + /* Update the final tail */ + ch->ch_w_tail = tail & WQUEUEMASK; + + if (len_written > 0) { + neo_pci_posting_flush(ch->ch_bd); + ch->ch_flags &= ~(CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM); + } + + DGNC_UNLOCK(ch->ch_lock, lock_flags); +} + + +static void neo_parse_modem(struct channel_t *ch, uchar signals) +{ + volatile uchar msignals = signals; + + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return; + + DPR_MSIGS(("neo_parse_modem: port: %d msignals: %x\n", ch->ch_portnum, msignals)); + + /* + * Do altpin switching. Altpin switches DCD and DSR. + * This prolly breaks DSRPACE, so we should be more clever here. + */ + if (ch->ch_digi.digi_flags & DIGI_ALTPIN) { + uchar mswap = msignals; + + if (mswap & UART_MSR_DDCD) { + msignals &= ~UART_MSR_DDCD; + msignals |= UART_MSR_DDSR; + } + if (mswap & UART_MSR_DDSR) { + msignals &= ~UART_MSR_DDSR; + msignals |= UART_MSR_DDCD; + } + if (mswap & UART_MSR_DCD) { + msignals &= ~UART_MSR_DCD; + msignals |= UART_MSR_DSR; + } + if (mswap & UART_MSR_DSR) { + msignals &= ~UART_MSR_DSR; + msignals |= UART_MSR_DCD; + } + } + + /* Scrub off lower bits. They signify delta's, which I don't care about */ + msignals &= 0xf0; + + if (msignals & UART_MSR_DCD) + ch->ch_mistat |= UART_MSR_DCD; + else + ch->ch_mistat &= ~UART_MSR_DCD; + + if (msignals & UART_MSR_DSR) + ch->ch_mistat |= UART_MSR_DSR; + else + ch->ch_mistat &= ~UART_MSR_DSR; + + if (msignals & UART_MSR_RI) + ch->ch_mistat |= UART_MSR_RI; + else + ch->ch_mistat &= ~UART_MSR_RI; + + if (msignals & UART_MSR_CTS) + ch->ch_mistat |= UART_MSR_CTS; + else + ch->ch_mistat &= ~UART_MSR_CTS; + + DPR_MSIGS(("Port: %d DTR: %d RTS: %d CTS: %d DSR: %d " "RI: %d CD: %d\n", + ch->ch_portnum, + !!((ch->ch_mistat | ch->ch_mostat) & UART_MCR_DTR), + !!((ch->ch_mistat | ch->ch_mostat) & UART_MCR_RTS), + !!((ch->ch_mistat | ch->ch_mostat) & UART_MSR_CTS), + !!((ch->ch_mistat | ch->ch_mostat) & UART_MSR_DSR), + !!((ch->ch_mistat | ch->ch_mostat) & UART_MSR_RI), + !!((ch->ch_mistat | ch->ch_mostat) & UART_MSR_DCD))); +} + + +/* Make the UART raise any of the output signals we want up */ +static void neo_assert_modem_signals(struct channel_t *ch) +{ + uchar out; + + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return; + + out = ch->ch_mostat; + + if (ch->ch_flags & CH_LOOPBACK) + out |= UART_MCR_LOOP; + + writeb(out, &ch->ch_neo_uart->mcr); + neo_pci_posting_flush(ch->ch_bd); + + /* Give time for the UART to actually raise/drop the signals */ + udelay(10); +} + + +static void neo_send_start_character(struct channel_t *ch) +{ + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return; + + if (ch->ch_startc != _POSIX_VDISABLE) { + ch->ch_xon_sends++; + writeb(ch->ch_startc, &ch->ch_neo_uart->txrx); + neo_pci_posting_flush(ch->ch_bd); + udelay(10); + } +} + + +static void neo_send_stop_character(struct channel_t *ch) +{ + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return; + + if (ch->ch_stopc != _POSIX_VDISABLE) { + ch->ch_xoff_sends++; + writeb(ch->ch_stopc, &ch->ch_neo_uart->txrx); + neo_pci_posting_flush(ch->ch_bd); + udelay(10); + } +} + + +/* + * neo_uart_init + */ +static void neo_uart_init(struct channel_t *ch) +{ + + writeb(0, &ch->ch_neo_uart->ier); + writeb(0, &ch->ch_neo_uart->efr); + writeb(UART_EFR_ECB, &ch->ch_neo_uart->efr); + + + /* Clear out UART and FIFO */ + readb(&ch->ch_neo_uart->txrx); + writeb((UART_FCR_ENABLE_FIFO|UART_FCR_CLEAR_RCVR|UART_FCR_CLEAR_XMIT), &ch->ch_neo_uart->isr_fcr); + readb(&ch->ch_neo_uart->lsr); + readb(&ch->ch_neo_uart->msr); + + ch->ch_flags |= CH_FIFO_ENABLED; + + /* Assert any signals we want up */ + writeb(ch->ch_mostat, &ch->ch_neo_uart->mcr); + neo_pci_posting_flush(ch->ch_bd); +} + + +/* + * Make the UART completely turn off. + */ +static void neo_uart_off(struct channel_t *ch) +{ + /* Turn off UART enhanced bits */ + writeb(0, &ch->ch_neo_uart->efr); + + /* Stop all interrupts from occurring. */ + writeb(0, &ch->ch_neo_uart->ier); + neo_pci_posting_flush(ch->ch_bd); +} + + +static uint neo_get_uart_bytes_left(struct channel_t *ch) +{ + uchar left = 0; + uchar lsr = readb(&ch->ch_neo_uart->lsr); + + /* We must cache the LSR as some of the bits get reset once read... */ + ch->ch_cached_lsr |= lsr; + + /* Determine whether the Transmitter is empty or not */ + if (!(lsr & UART_LSR_TEMT)) { + if (ch->ch_flags & CH_TX_FIFO_EMPTY) { + tasklet_schedule(&ch->ch_bd->helper_tasklet); + } + left = 1; + } else { + ch->ch_flags |= (CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM); + left = 0; + } + + return left; +} + + +/* Channel lock MUST be held by the calling function! */ +static void neo_send_break(struct channel_t *ch, int msecs) +{ + /* + * If we receive a time of 0, this means turn off the break. + */ + if (msecs == 0) { + if (ch->ch_flags & CH_BREAK_SENDING) { + uchar temp = readb(&ch->ch_neo_uart->lcr); + writeb((temp & ~UART_LCR_SBC), &ch->ch_neo_uart->lcr); + neo_pci_posting_flush(ch->ch_bd); + ch->ch_flags &= ~(CH_BREAK_SENDING); + ch->ch_stop_sending_break = 0; + DPR_IOCTL(("Finishing UART_LCR_SBC! finished: %lx\n", jiffies)); + } + return; + } + + /* + * Set the time we should stop sending the break. + * If we are already sending a break, toss away the existing + * time to stop, and use this new value instead. + */ + ch->ch_stop_sending_break = jiffies + dgnc_jiffies_from_ms(msecs); + + /* Tell the UART to start sending the break */ + if (!(ch->ch_flags & CH_BREAK_SENDING)) { + uchar temp = readb(&ch->ch_neo_uart->lcr); + writeb((temp | UART_LCR_SBC), &ch->ch_neo_uart->lcr); + neo_pci_posting_flush(ch->ch_bd); + ch->ch_flags |= (CH_BREAK_SENDING); + DPR_IOCTL(("Port %d. Starting UART_LCR_SBC! start: %lx should end: %lx\n", + ch->ch_portnum, jiffies, ch->ch_stop_sending_break)); + } +} + + +/* + * neo_send_immediate_char. + * + * Sends a specific character as soon as possible to the UART, + * jumping over any bytes that might be in the write queue. + * + * The channel lock MUST be held by the calling function. + */ +static void neo_send_immediate_char(struct channel_t *ch, unsigned char c) +{ + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return; + + writeb(c, &ch->ch_neo_uart->txrx); + neo_pci_posting_flush(ch->ch_bd); +} + + +static unsigned int neo_read_eeprom(unsigned char *base, unsigned int address) +{ + unsigned int enable; + unsigned int bits; + unsigned int databit; + unsigned int val; + + /* enable chip select */ + writeb(NEO_EECS, base + NEO_EEREG); + /* READ */ + enable = (address | 0x180); + + for (bits = 9; bits--; ) { + databit = (enable & (1 << bits)) ? NEO_EEDI : 0; + /* Set read address */ + writeb(databit | NEO_EECS, base + NEO_EEREG); + writeb(databit | NEO_EECS | NEO_EECK, base + NEO_EEREG); + } + + val = 0; + + for (bits = 17; bits--; ) { + /* clock to EEPROM */ + writeb(NEO_EECS, base + NEO_EEREG); + writeb(NEO_EECS | NEO_EECK, base + NEO_EEREG); + val <<= 1; + /* read EEPROM */ + if (readb(base + NEO_EEREG) & NEO_EEDO) + val |= 1; + } + + /* clock falling edge */ + writeb(NEO_EECS, base + NEO_EEREG); + + /* drop chip select */ + writeb(0x00, base + NEO_EEREG); + + return val; +} + + +static void neo_vpd(struct board_t *brd) +{ + unsigned int i = 0; + unsigned int a; + + if (!brd || brd->magic != DGNC_BOARD_MAGIC) + return; + + if (!brd->re_map_membase) + return; + + /* Store the VPD into our buffer */ + for (i = 0; i < NEO_VPD_IMAGESIZE; i++) { + a = neo_read_eeprom(brd->re_map_membase, i); + brd->vpd[i*2] = a & 0xff; + brd->vpd[(i*2)+1] = (a >> 8) & 0xff; + } + + if (((brd->vpd[0x08] != 0x82) /* long resource name tag */ + && (brd->vpd[0x10] != 0x82)) /* long resource name tag (PCI-66 files)*/ + || (brd->vpd[0x7F] != 0x78)) /* small resource end tag */ + { + memset(brd->vpd, '\0', NEO_VPD_IMAGESIZE); + } + else { + /* Search for the serial number */ + for (i = 0; i < NEO_VPD_IMAGESIZE * 2; i++) { + if (brd->vpd[i] == 'S' && brd->vpd[i + 1] == 'N') { + strncpy(brd->serial_num, &(brd->vpd[i + 3]), 9); + } + } + } +} diff --git a/drivers/staging/dgnc/dgnc_neo.h b/drivers/staging/dgnc/dgnc_neo.h new file mode 100644 index 0000000000000..ffb42099b9fd3 --- /dev/null +++ b/drivers/staging/dgnc/dgnc_neo.h @@ -0,0 +1,157 @@ +/* + * Copyright 2003 Digi International (www.digi.com) + * Scott H Kilau + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! + * + */ + +#ifndef __DGNC_NEO_H +#define __DGNC_NEO_H + +#include "dgnc_types.h" +#include "dgnc_driver.h" + +/************************************************************************ + * Per channel/port NEO UART structure * + ************************************************************************ + * Base Structure Entries Usage Meanings to Host * + * * + * W = read write R = read only * + * U = Unused. * + ************************************************************************/ + +struct neo_uart_struct { + volatile uchar txrx; /* WR RHR/THR - Holding Reg */ + volatile uchar ier; /* WR IER - Interrupt Enable Reg */ + volatile uchar isr_fcr; /* WR ISR/FCR - Interrupt Status Reg/Fifo Control Reg */ + volatile uchar lcr; /* WR LCR - Line Control Reg */ + volatile uchar mcr; /* WR MCR - Modem Control Reg */ + volatile uchar lsr; /* WR LSR - Line Status Reg */ + volatile uchar msr; /* WR MSR - Modem Status Reg */ + volatile uchar spr; /* WR SPR - Scratch Pad Reg */ + volatile uchar fctr; /* WR FCTR - Feature Control Reg */ + volatile uchar efr; /* WR EFR - Enhanced Function Reg */ + volatile uchar tfifo; /* WR TXCNT/TXTRG - Transmit FIFO Reg */ + volatile uchar rfifo; /* WR RXCNT/RXTRG - Recieve FIFO Reg */ + volatile uchar xoffchar1; /* WR XOFF 1 - XOff Character 1 Reg */ + volatile uchar xoffchar2; /* WR XOFF 2 - XOff Character 2 Reg */ + volatile uchar xonchar1; /* WR XON 1 - Xon Character 1 Reg */ + volatile uchar xonchar2; /* WR XON 2 - XOn Character 2 Reg */ + + volatile uchar reserved1[0x2ff - 0x200]; /* U Reserved by Exar */ + volatile uchar txrxburst[64]; /* RW 64 bytes of RX/TX FIFO Data */ + volatile uchar reserved2[0x37f - 0x340]; /* U Reserved by Exar */ + volatile uchar rxburst_with_errors[64]; /* R 64 bytes of RX FIFO Data + LSR */ +}; + +/* Where to read the extended interrupt register (32bits instead of 8bits) */ +#define UART_17158_POLL_ADDR_OFFSET 0x80 + +/* These are the current dvid's of the Neo boards */ +#define UART_XR17C158_DVID 0x20 +#define UART_XR17D158_DVID 0x20 +#define UART_XR17E158_DVID 0x40 + +#define NEO_EECK 0x10 /* Clock */ +#define NEO_EECS 0x20 /* Chip Select */ +#define NEO_EEDI 0x40 /* Data In is an Output Pin */ +#define NEO_EEDO 0x80 /* Data Out is an Input Pin */ +#define NEO_EEREG 0x8E /* offset to EEPROM control reg */ + + +#define NEO_VPD_IMAGESIZE 0x40 /* size of image to read from EEPROM in words */ +#define NEO_VPD_IMAGEBYTES (NEO_VPD_IMAGESIZE * 2) + +/* + * These are the redefinitions for the FCTR on the XR17C158, since + * Exar made them different than their earlier design. (XR16C854) + */ + +/* These are only applicable when table D is selected */ +#define UART_17158_FCTR_RTS_NODELAY 0x00 +#define UART_17158_FCTR_RTS_4DELAY 0x01 +#define UART_17158_FCTR_RTS_6DELAY 0x02 +#define UART_17158_FCTR_RTS_8DELAY 0x03 +#define UART_17158_FCTR_RTS_12DELAY 0x12 +#define UART_17158_FCTR_RTS_16DELAY 0x05 +#define UART_17158_FCTR_RTS_20DELAY 0x13 +#define UART_17158_FCTR_RTS_24DELAY 0x06 +#define UART_17158_FCTR_RTS_28DELAY 0x14 +#define UART_17158_FCTR_RTS_32DELAY 0x07 +#define UART_17158_FCTR_RTS_36DELAY 0x16 +#define UART_17158_FCTR_RTS_40DELAY 0x08 +#define UART_17158_FCTR_RTS_44DELAY 0x09 +#define UART_17158_FCTR_RTS_48DELAY 0x10 +#define UART_17158_FCTR_RTS_52DELAY 0x11 + +#define UART_17158_FCTR_RTS_IRDA 0x10 +#define UART_17158_FCTR_RS485 0x20 +#define UART_17158_FCTR_TRGA 0x00 +#define UART_17158_FCTR_TRGB 0x40 +#define UART_17158_FCTR_TRGC 0x80 +#define UART_17158_FCTR_TRGD 0xC0 + +/* 17158 trigger table selects.. */ +#define UART_17158_FCTR_BIT6 0x40 +#define UART_17158_FCTR_BIT7 0x80 + +/* 17158 TX/RX memmapped buffer offsets */ +#define UART_17158_RX_FIFOSIZE 64 +#define UART_17158_TX_FIFOSIZE 64 + +/* 17158 Extended IIR's */ +#define UART_17158_IIR_RDI_TIMEOUT 0x0C /* Receiver data TIMEOUT */ +#define UART_17158_IIR_XONXOFF 0x10 /* Received an XON/XOFF char */ +#define UART_17158_IIR_HWFLOW_STATE_CHANGE 0x20 /* CTS/DSR or RTS/DTR state change */ +#define UART_17158_IIR_FIFO_ENABLED 0xC0 /* 16550 FIFOs are Enabled */ + +/* + * These are the extended interrupts that get sent + * back to us from the UART's 32bit interrupt register + */ +#define UART_17158_RX_LINE_STATUS 0x1 /* RX Ready */ +#define UART_17158_RXRDY_TIMEOUT 0x2 /* RX Ready Timeout */ +#define UART_17158_TXRDY 0x3 /* TX Ready */ +#define UART_17158_MSR 0x4 /* Modem State Change */ +#define UART_17158_TX_AND_FIFO_CLR 0x40 /* Transmitter Holding Reg Empty */ +#define UART_17158_RX_FIFO_DATA_ERROR 0x80 /* UART detected an RX FIFO Data error */ + +/* + * These are the EXTENDED definitions for the 17C158's Interrupt + * Enable Register. + */ +#define UART_17158_EFR_ECB 0x10 /* Enhanced control bit */ +#define UART_17158_EFR_IXON 0x2 /* Receiver compares Xon1/Xoff1 */ +#define UART_17158_EFR_IXOFF 0x8 /* Transmit Xon1/Xoff1 */ +#define UART_17158_EFR_RTSDTR 0x40 /* Auto RTS/DTR Flow Control Enable */ +#define UART_17158_EFR_CTSDSR 0x80 /* Auto CTS/DSR Flow COntrol Enable */ + +#define UART_17158_XOFF_DETECT 0x1 /* Indicates whether chip saw an incoming XOFF char */ +#define UART_17158_XON_DETECT 0x2 /* Indicates whether chip saw an incoming XON char */ + +#define UART_17158_IER_RSVD1 0x10 /* Reserved by Exar */ +#define UART_17158_IER_XOFF 0x20 /* Xoff Interrupt Enable */ +#define UART_17158_IER_RTSDTR 0x40 /* Output Interrupt Enable */ +#define UART_17158_IER_CTSDSR 0x80 /* Input Interrupt Enable */ + +/* + * Our Global Variables + */ +extern struct board_ops dgnc_neo_ops; + +#endif diff --git a/drivers/staging/dgnc/dgnc_pci.h b/drivers/staging/dgnc/dgnc_pci.h new file mode 100644 index 0000000000000..5550707ba1fb3 --- /dev/null +++ b/drivers/staging/dgnc/dgnc_pci.h @@ -0,0 +1,77 @@ +/* + * Copyright 2003 Digi International (www.digi.com) + * Scott H Kilau + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! + */ + +/* $Id: dgnc_pci.h,v 1.1.1.1 2009/05/20 12:19:19 markh Exp $ */ + +#ifndef __DGNC_PCI_H +#define __DGNC_PCI_H + +#define PCIMAX 32 /* maximum number of PCI boards */ + +#define DIGI_VID 0x114F + +#define PCI_DEVICE_CLASSIC_4_DID 0x0028 +#define PCI_DEVICE_CLASSIC_8_DID 0x0029 +#define PCI_DEVICE_CLASSIC_4_422_DID 0x00D0 +#define PCI_DEVICE_CLASSIC_8_422_DID 0x00D1 +#define PCI_DEVICE_NEO_4_DID 0x00B0 +#define PCI_DEVICE_NEO_8_DID 0x00B1 +#define PCI_DEVICE_NEO_2DB9_DID 0x00C8 +#define PCI_DEVICE_NEO_2DB9PRI_DID 0x00C9 +#define PCI_DEVICE_NEO_2RJ45_DID 0x00CA +#define PCI_DEVICE_NEO_2RJ45PRI_DID 0x00CB +#define PCI_DEVICE_NEO_1_422_DID 0x00CC +#define PCI_DEVICE_NEO_1_422_485_DID 0x00CD +#define PCI_DEVICE_NEO_2_422_485_DID 0x00CE +#define PCI_DEVICE_NEO_EXPRESS_8_DID 0x00F0 +#define PCI_DEVICE_NEO_EXPRESS_4_DID 0x00F1 +#define PCI_DEVICE_NEO_EXPRESS_4RJ45_DID 0x00F2 +#define PCI_DEVICE_NEO_EXPRESS_8RJ45_DID 0x00F3 +#define PCI_DEVICE_NEO_EXPRESS_4_IBM_DID 0x00F4 + +#define PCI_DEVICE_CLASSIC_4_PCI_NAME "ClassicBoard 4 PCI" +#define PCI_DEVICE_CLASSIC_8_PCI_NAME "ClassicBoard 8 PCI" +#define PCI_DEVICE_CLASSIC_4_422_PCI_NAME "ClassicBoard 4 422 PCI" +#define PCI_DEVICE_CLASSIC_8_422_PCI_NAME "ClassicBoard 8 422 PCI" +#define PCI_DEVICE_NEO_4_PCI_NAME "Neo 4 PCI" +#define PCI_DEVICE_NEO_8_PCI_NAME "Neo 8 PCI" +#define PCI_DEVICE_NEO_2DB9_PCI_NAME "Neo 2 - DB9 Universal PCI" +#define PCI_DEVICE_NEO_2DB9PRI_PCI_NAME "Neo 2 - DB9 Universal PCI - Powered Ring Indicator" +#define PCI_DEVICE_NEO_2RJ45_PCI_NAME "Neo 2 - RJ45 Universal PCI" +#define PCI_DEVICE_NEO_2RJ45PRI_PCI_NAME "Neo 2 - RJ45 Universal PCI - Powered Ring Indicator" +#define PCI_DEVICE_NEO_1_422_PCI_NAME "Neo 1 422 PCI" +#define PCI_DEVICE_NEO_1_422_485_PCI_NAME "Neo 1 422/485 PCI" +#define PCI_DEVICE_NEO_2_422_485_PCI_NAME "Neo 2 422/485 PCI" + +#define PCI_DEVICE_NEO_EXPRESS_8_PCI_NAME "Neo 8 PCI Express" +#define PCI_DEVICE_NEO_EXPRESS_4_PCI_NAME "Neo 4 PCI Express" +#define PCI_DEVICE_NEO_EXPRESS_4RJ45_PCI_NAME "Neo 4 PCI Express RJ45" +#define PCI_DEVICE_NEO_EXPRESS_8RJ45_PCI_NAME "Neo 8 PCI Express RJ45" +#define PCI_DEVICE_NEO_EXPRESS_4_IBM_PCI_NAME "Neo 4 PCI Express IBM" + + +/* Size of Memory and I/O for PCI (4 K) */ +#define PCI_RAM_SIZE 0x1000 + +/* Size of Memory (2MB) */ +#define PCI_MEM_SIZE 0x1000 + +#endif diff --git a/drivers/staging/dgnc/dgnc_proc.c b/drivers/staging/dgnc/dgnc_proc.c new file mode 100644 index 0000000000000..8fbaf3b38e609 --- /dev/null +++ b/drivers/staging/dgnc/dgnc_proc.c @@ -0,0 +1,1551 @@ +/* + * Copyright 2003 Digi International (www.digi.com) + * Scott H Kilau + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * + * NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE! + * + * This is shared code between Digi's CVS archive and the + * Linux Kernel sources. + * Changing the source just for reformatting needlessly breaks + * our CVS diff history. + * + * Send any bug fixes/changes to: Eng.Linux at digi dot com. + * Thank you. + * + * + * $Id: dgnc_proc.c,v 1.3 2011/06/22 12:16:35 markh Exp $ + */ + +#include +#include +#include /* For jiffies, task states */ +#include /* For tasklet and interrupt structs/defines */ +#include +#include +#include +#include +#include /* For in_egroup_p() */ +#include +#include /* For copy_from_user/copy_to_user */ + +#include "dgnc_driver.h" +#include "dgnc_proc.h" +#include "dgnc_mgmt.h" + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37) +#define init_MUTEX(sem) sema_init(sem, 1) +#define DECLARE_MUTEX(name) \ + struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) +#endif + + +/* The /proc/dgnc directory */ +static struct proc_dir_entry *ProcDGNC; + + +/* File operation declarations */ +static int dgnc_gen_proc_open(struct inode *, struct file *); +static int dgnc_gen_proc_close(struct inode *, struct file *); +static ssize_t dgnc_gen_proc_read(struct file *file, char __user *buf, size_t count, loff_t *ppos); +static ssize_t dgnc_gen_proc_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos); + +static int dgnc_proc_chk_perm(struct inode *, int); + +static const struct file_operations dgnc_proc_file_ops = +{ + .owner = THIS_MODULE, + .read = dgnc_gen_proc_read, /* read */ + .write = dgnc_gen_proc_write, /* write */ + .open = dgnc_gen_proc_open, /* open */ + .release = dgnc_gen_proc_close, /* release */ +}; + + +static struct inode_operations dgnc_proc_inode_ops = +{ + .permission = dgnc_proc_chk_perm +}; + + +static void dgnc_register_proc_table(struct dgnc_proc_entry *, struct proc_dir_entry *); +static void dgnc_unregister_proc_table(struct dgnc_proc_entry *, struct proc_dir_entry *); +static void dgnc_remove_proc_entry(struct proc_dir_entry *pde); + + +/* Stuff in /proc/ */ +static int dgnc_read_info(struct dgnc_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos); +static int dgnc_write_info(struct dgnc_proc_entry *table, int dir, struct file *filp, + const char __user *buffer, ssize_t *lenp, loff_t *ppos); + +static int dgnc_read_mknod(struct dgnc_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos); + +static struct dgnc_proc_entry dgnc_table[] = { + {DGNC_INFO, "info", 0600, NULL, NULL, NULL, &dgnc_read_info, &dgnc_write_info, + NULL, __SEMAPHORE_INITIALIZER(dgnc_table[0].excl_sem, 1), 0, NULL }, + {DGNC_MKNOD, "mknod", 0600, NULL, NULL, NULL, &dgnc_read_mknod, NULL, + NULL, __SEMAPHORE_INITIALIZER(dgnc_table[1].excl_sem, 1), 0, NULL }, + {0} +}; + + +/* Stuff in /proc// */ +static int dgnc_read_board_info(struct dgnc_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos); +static int dgnc_read_board_vpd(struct dgnc_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos); +static int dgnc_read_board_mknod(struct dgnc_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos); +static int dgnc_read_board_ttystats(struct dgnc_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos); +static int dgnc_read_board_ttyintr(struct dgnc_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos); +static int dgnc_read_board_ttyflags(struct dgnc_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos); + +static struct dgnc_proc_entry dgnc_board_table[] = { + {DGNC_BOARD_INFO, "info", 0600, NULL, NULL, NULL, &dgnc_read_board_info, NULL, + NULL, __SEMAPHORE_INITIALIZER(dgnc_board_table[0].excl_sem, 1), 0, NULL }, + {DGNC_BOARD_VPD, "vpd", 0600, NULL, NULL, NULL, &dgnc_read_board_vpd, NULL, + NULL, __SEMAPHORE_INITIALIZER(dgnc_board_table[1].excl_sem, 1), 0, NULL }, + {DGNC_BOARD_TTYSTATS, "stats", 0600, NULL, NULL, NULL, &dgnc_read_board_ttystats, NULL, + NULL, __SEMAPHORE_INITIALIZER(dgnc_board_table[2].excl_sem, 1), 0, NULL }, + {DGNC_BOARD_TTYINTR, "intr", 0600, NULL, NULL, NULL, &dgnc_read_board_ttyintr, NULL, + NULL, __SEMAPHORE_INITIALIZER(dgnc_board_table[3].excl_sem, 1), 0, NULL }, + {DGNC_BOARD_TTYFLAGS, "flags", 0600, NULL, NULL, NULL, &dgnc_read_board_ttyflags, NULL, + NULL, __SEMAPHORE_INITIALIZER(dgnc_board_table[4].excl_sem, 1), 0, NULL }, + {DGNC_BOARD_MKNOD, "mknod", 0600, NULL, NULL, NULL, &dgnc_read_board_mknod, NULL, + NULL, __SEMAPHORE_INITIALIZER(dgnc_board_table[5].excl_sem, 1), 0, NULL }, + {0} +}; + + +/* Stuff in /proc// */ +static int dgnc_read_channel_info(struct dgnc_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos); +static int dgnc_open_channel_sniff(struct dgnc_proc_entry *table, int dir, struct file *filp, + void *buffer, ssize_t *lenp, loff_t *ppos); +static int dgnc_close_channel_sniff(struct dgnc_proc_entry *table, int dir, struct file *filp, + void *buffer, ssize_t *lenp, loff_t *ppos); +static int dgnc_read_channel_sniff(struct dgnc_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos); +static int dgnc_read_channel_custom_ttyname(struct dgnc_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos); +static int dgnc_read_channel_custom_prname(struct dgnc_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos); + +static struct dgnc_proc_entry dgnc_channel_table[] = { + {DGNC_PORT_INFO, "info", 0600, NULL, NULL, NULL, &dgnc_read_channel_info, NULL, + NULL, __SEMAPHORE_INITIALIZER(dgnc_channel_table[0].excl_sem, 1), 0, NULL }, + {DGNC_PORT_SNIFF, "sniff", 0600, NULL, &dgnc_open_channel_sniff, &dgnc_close_channel_sniff, &dgnc_read_channel_sniff, NULL, + NULL, __SEMAPHORE_INITIALIZER(dgnc_channel_table[1].excl_sem, 1), 0, NULL}, + {DGNC_PORT_CUSTOM_TTYNAME, "ttyname", 0600, NULL, NULL, NULL, &dgnc_read_channel_custom_ttyname, NULL, + NULL, __SEMAPHORE_INITIALIZER(dgnc_channel_table[2].excl_sem, 1), 0, NULL }, + {DGNC_PORT_CUSTOM_PRNAME, "prname", 0600, NULL, NULL, NULL, &dgnc_read_channel_custom_prname, NULL, + NULL, __SEMAPHORE_INITIALIZER(dgnc_channel_table[3].excl_sem, 1), 0, NULL }, + {0} +}; + + +/* + * dgnc_test_perm does NOT grant the superuser all rights automatically, because + * some entries are readonly even to root. + */ +static inline int dgnc_test_perm(int mode, int op) +{ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) + if (!current->euid) +#else + if (!current_euid()) +#endif + mode >>= 6; + else if (in_egroup_p(0)) + mode >>= 3; + if ((mode & op & 0007) == op) + return 0; + if (capable(CAP_SYS_ADMIN)) + return 0; + return -EACCES; +} + + +/* + * /proc/sys support + */ +static inline int dgnc_proc_match(int len, const char *name, struct proc_dir_entry *de) +{ + if (!de || !de->low_ino) + return 0; + if (de->namelen != len) + return 0; + return !memcmp(name, de->name, len); +} + + +/* + * Scan the entries in table and add them all to /proc at the position + * referred to by "root" + */ +static void dgnc_register_proc_table(struct dgnc_proc_entry *table, struct proc_dir_entry *root) +{ + struct proc_dir_entry *de; + int len; + mode_t mode; + + for (; table->magic; table++) { + /* Can't do anything without a proc name. */ + if (!table->name) { + DPR_PROC(("dgnc_register_proc_table, no name...\n")); + continue; + } + + /* Maybe we can't do anything with it... */ + if (!table->read_handler && !table->write_handler && !table->child) { + DPR_PROC((KERN_WARNING "DGNC PROC: Can't register %s\n", table->name)); + continue; + } + + len = strlen(table->name); + mode = table->mode; + de = NULL; + + if (!table->child) { + mode |= S_IFREG; + } else { + mode |= S_IFDIR; + for (de = root->subdir; de; de = de->next) { + if (dgnc_proc_match(len, table->name, de)) + break; + } + + /* If the subdir exists already, de is non-NULL */ + } + + if (!de) { + de = create_proc_entry(table->name, mode, root); + if (!de) + continue; + de->data = (void *) table; + if (!table->child) { + de->proc_iops = &dgnc_proc_inode_ops; + de->proc_fops = &dgnc_proc_file_ops; + } + } + + table->de = de; + + if (de->mode & S_IFDIR) + dgnc_register_proc_table(table->child, de); + + } +} + + + +/* + * Unregister a /proc sysctl table and any subdirectories. + */ +static void dgnc_unregister_proc_table(struct dgnc_proc_entry *table, struct proc_dir_entry *root) +{ + struct proc_dir_entry *de; + + for (; table->magic; table++) { + if (!(de = table->de)) + continue; + + if (de->mode & S_IFDIR) { + if (!table->child) { + DPR_PROC((KERN_ALERT "Help - malformed sysctl tree on free\n")); + continue; + } + + /* recurse down into subdirectory... */ + DPR_PROC(("Recursing down a directory...\n")); + dgnc_unregister_proc_table(table->child, de); + + /* Don't unregister directories which still have entries.. */ + if (de->subdir) + continue; + } + + /* Don't unregister proc entries that are still being used.. */ + if ((atomic_read(&de->count)) != 1) { + DPR_PROC(("proc entry in use... Not removing...\n")); + continue; + } + + dgnc_remove_proc_entry(de); + table->de = NULL; + } +} + + + +static int dgnc_gen_proc_open(struct inode *inode, struct file *file) +{ + struct proc_dir_entry *de; + struct dgnc_proc_entry *entry; + int (*handler) (struct dgnc_proc_entry *table, int dir, struct file *filp, + void *buffer, ssize_t *lenp, loff_t *ppos); + int ret = 0, error = 0; + + de = (struct proc_dir_entry *) PDE(file->f_dentry->d_inode); + if (!de || !de->data) { + ret = -ENXIO; + goto done; + } + + entry = (struct dgnc_proc_entry *) de->data; + if (!entry) { + ret = -ENXIO; + goto done; + } + + down(&entry->excl_sem); + + if (entry->excl_cnt) { + ret = -EBUSY; + } else { + entry->excl_cnt++; + + handler = entry->open_handler; + if (handler) { + error = (*handler) (entry, OUTBOUND, file, NULL, NULL, NULL); + if (error) { + entry->excl_cnt--; + ret = error; + } + } + } + + up(&entry->excl_sem); + +done: + + return ret; +} + + +static int dgnc_gen_proc_close(struct inode *inode, struct file *file) +{ + struct proc_dir_entry *de; + int (*handler) (struct dgnc_proc_entry *table, int dir, struct file *filp, + void *buffer, ssize_t *lenp, loff_t *ppos); + struct dgnc_proc_entry *entry; + int error = 0; + + de = (struct proc_dir_entry *) PDE(file->f_dentry->d_inode); + if (!de || !de->data) + goto done; + + entry = (struct dgnc_proc_entry *) de->data; + if (!entry) + goto done; + + down(&entry->excl_sem); + + if (entry->excl_cnt) + entry->excl_cnt = 0; + + + handler = entry->close_handler; + if (handler) { + error = (*handler) (entry, OUTBOUND, file, NULL, NULL, NULL); + } + + up(&entry->excl_sem); + +done: + return 0; +} + + +static ssize_t dgnc_gen_proc_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) +{ + struct proc_dir_entry *de; + struct dgnc_proc_entry *entry; + int (*handler) (struct dgnc_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos2); + ssize_t res; + ssize_t error; + + de = (struct proc_dir_entry*) PDE(file->f_dentry->d_inode); + if (!de || !de->data) + return -ENXIO; + + entry = (struct dgnc_proc_entry *) de->data; + if (!entry) + return -ENXIO; + + /* Test for read permission */ + if (dgnc_test_perm(entry->mode, 4)) + return -EPERM; + + res = count; + + handler = entry->read_handler; + if (!handler) + return -ENXIO; + + error = (*handler) (entry, OUTBOUND, file, buf, &res, ppos); + if (error) + return error; + + return res; +} + + +static ssize_t dgnc_gen_proc_write(struct file *file, const char __user *buf, + size_t count, loff_t *ppos) +{ + struct proc_dir_entry *de; + struct dgnc_proc_entry *entry; + int (*handler) (struct dgnc_proc_entry *table, int dir, struct file *filp, + const char __user *buffer, ssize_t *lenp, loff_t *ppos2); + ssize_t res; + ssize_t error; + + de = (struct proc_dir_entry *) PDE(file->f_dentry->d_inode); + if (!de || !de->data) + return -ENXIO; + + entry = (struct dgnc_proc_entry *) de->data; + if (!entry) + return -ENXIO; + + /* Test for write permission */ + if (dgnc_test_perm(entry->mode, 2)) + return -EPERM; + + res = count; + + handler = entry->write_handler; + if (!handler) + return -ENXIO; + + error = (*handler) (entry, INBOUND, file, buf, &res, ppos); + if (error) + return error; + + return res; +} + + +static int dgnc_proc_chk_perm(struct inode *inode, int op) +{ + return dgnc_test_perm(inode->i_mode, op); +} + + +/* + * Return what is (hopefully) useful information about the + * driver. + */ +static int dgnc_read_info(struct dgnc_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos) +{ + static int done = 0; + static char buf[4096]; + char *p = buf; + + DPR_PROC(("dgnc_proc_info\n")); + + if (done) { + done = 0; + *lenp = 0; + return 0; + } + + p += sprintf(p, "Driver:\t\t%s\n", DG_NAME); + p += sprintf(p, "\n"); + p += sprintf(p, "Debug:\t\t0x%x\n", dgnc_debug); + p += sprintf(p, "Sysfs Support:\t0x1\n"); + p += sprintf(p, "Rawreadok:\t0x%x\n", dgnc_rawreadok); + p += sprintf(p, "Max Boards:\t%d\n", MAXBOARDS); + p += sprintf(p, "Total Boards:\t%d\n", dgnc_NumBoards); + p += sprintf(p, "Poll rate:\t%dms\n", dgnc_poll_tick); + p += sprintf(p, "Poll counter:\t%ld\n", dgnc_poll_counter); + p += sprintf(p, "State:\t\t%s\n", dgnc_driver_state_text[dgnc_driver_state]); + + if (copy_to_user(buffer, buf, (p - (char *) buf))) + return -EFAULT; + + *lenp = p - (char *) buf; + *ppos += p - (char *) buf; + done = 1; + return 0; +} + + +/* + * When writing to the "info" entry point, I actually allow one + * to modify certain variables. This may be a sleazy overload + * of this /proc entry, but I don't want: + * + * a. to clutter /proc more than I have to + * b. to overload the "config" entry, which would be somewhat + * more natural + * c. necessarily advertise the fact this ability exists + * + * The continued support of this feature has not yet been + * guaranteed. + * + * Writing operates on a "state machine" principle. + * + * State 0: waiting for a symbol to start. Waiting for anything + * which isn't " ' = or whitespace. + * State 1: reading a symbol. If the character is a space, move + * to state 2. If =, move to state 3. If " or ', move + * to state 0. + * State 2: Waiting for =... suck whitespace. If anything other + * than whitespace, drop to state 0. + * State 3: Got =. Suck whitespace waiting for value to start. + * If " or ', go to state 4 (and remember which quote it + * was). Otherwise, go to state 5. + * State 4: Reading value, within quotes. Everything is added to + * value up until the matching quote. When you hit the + * matching quote, try to set the variable, then state 0. + * State 5: Reading value, outside quotes. Everything not " ' = + * or whitespace goes in value. Hitting one of the + * terminators tosses us back to state 0 after trying to + * set the variable. + */ +typedef enum { + INFO_NONE, INFO_INT, INFO_CHAR, INFO_SHORT, + INFO_LONG, INFO_PTR, INFO_STRING, INFO_END +} info_proc_var_val; + +static struct { + char *name; + info_proc_var_val type; + int rw; /* 0=readonly */ + void *val_ptr; +} dgnc_info_vars[] = { + { "rawreadok", INFO_INT, 1, (void *) &dgnc_rawreadok }, + { "pollrate", INFO_INT, 1, (void *) &dgnc_poll_tick }, + { NULL, INFO_NONE, 0, NULL }, + { "debug", INFO_LONG, 1, (void *) &dgnc_debug }, + { NULL, INFO_END, 0, NULL } +}; + +static void dgnc_set_info_var(char *name, char *val) +{ + int i; + unsigned long newval; + unsigned char charval; + unsigned short shortval; + unsigned int intval; + + for (i = 0; dgnc_info_vars[i].type != INFO_END; i++) { + if (dgnc_info_vars[i].name) + if (!strcmp(name, dgnc_info_vars[i].name)) + break; + } + + if (dgnc_info_vars[i].type == INFO_END) + return; + if (dgnc_info_vars[i].rw == 0) + return; + if (dgnc_info_vars[i].val_ptr == NULL) + return; + + newval = simple_strtoul(val, NULL, 0 ); + + switch (dgnc_info_vars[i].type) { + case INFO_CHAR: + charval = newval & 0xff; + APR(("Modifying %s (%lx) <= 0x%02x (%d)\n", + name, (long)(dgnc_info_vars[i].val_ptr ), + charval, charval)); + *(uchar *)(dgnc_info_vars[i].val_ptr) = charval; + break; + case INFO_SHORT: + shortval = newval & 0xffff; + APR(("Modifying %s (%lx) <= 0x%04x (%d)\n", + name, (long)(dgnc_info_vars[i].val_ptr), + shortval, shortval)); + *(ushort *)(dgnc_info_vars[i].val_ptr) = shortval; + break; + case INFO_INT: + intval = newval & 0xffffffff; + APR(("Modifying %s (%lx) <= 0x%08x (%d)\n", + name, (long)(dgnc_info_vars[i].val_ptr), + intval, intval)); + *(uint *)(dgnc_info_vars[i].val_ptr) = intval; + break; + case INFO_LONG: + APR(("Modifying %s (%lx) <= 0x%lx (%ld)\n", + name, (long)(dgnc_info_vars[i].val_ptr), + newval, newval)); + *(ulong *)(dgnc_info_vars[i].val_ptr) = newval; + break; + case INFO_PTR: + case INFO_STRING: + case INFO_END: + case INFO_NONE: + default: + break; + } +} + +static int dgnc_write_info(struct dgnc_proc_entry *table, int dir, struct file *filp, + const char __user *buffer, ssize_t *lenp, loff_t *ppos) +{ + static int state = 0; + #define MAXSYM 255 + static int sympos, valpos; + static char sym[MAXSYM + 1]; + static char val[MAXSYM + 1]; + static int quotchar = 0; + + int i; + + long len; + #define INBUFLEN 256 + char inbuf[INBUFLEN]; + + if (*ppos == 0) { + state = 0; + sympos = 0; sym[0] = 0; + valpos = 0; val[0] = 0; + quotchar = 0; + } + + if ((!*lenp) || (dir != INBOUND)) { + *lenp = 0; + return 0; + } + + len = *lenp; + + if (len > INBUFLEN - 1) + len = INBUFLEN - 1; + + if (copy_from_user(inbuf, buffer, len)) + return -EFAULT; + + inbuf[len] = 0; + + for (i = 0; i < len; i++) { + unsigned char c = inbuf[i]; + + switch (state) { + case 0: + quotchar = sympos = valpos = sym[0] = val[0] = 0; + if (!isspace(c) && (c != '\"') && + (c != '\'') && (c != '=')) { + sym[sympos++] = c; + state = 1; + break; + } + break; + case 1: + if (isspace(c)) { + sym[sympos] = 0; + state = 2; + break; + } + if (c == '=') { + sym[sympos] = 0; + state = 3; + break; + } + if ((c == '\"' ) || ( c == '\'' )) { + state = 0; + break; + } + if (sympos < MAXSYM) sym[sympos++] = c; + break; + case 2: + if (isspace(c)) break; + if (c == '=') { + state = 3; + break; + } + if ((c != '\"') && (c != '\'')) { + quotchar = sympos = valpos = sym[0] = val[0] = 0; + sym[sympos++] = c; + state = 1; + break; + } + state = 0; + break; + case 3: + if (isspace(c)) break; + if (c == '=') { + state = 0; + break; + } + if ((c == '\"') || (c == '\'')) { + state = 4; + quotchar = c; + break; + } + val[valpos++] = c; + state = 5; + break; + case 4: + if (c == quotchar) { + val[valpos] = 0; + dgnc_set_info_var(sym, val); + state = 0; + break; + } + if (valpos < MAXSYM) val[valpos++] = c; + break; + case 5: + if (isspace(c) || (c == '\"') || + (c == '\'') || (c == '=')) { + val[valpos] = 0; + dgnc_set_info_var(sym, val); + state = 0; + break; + } + if (valpos < MAXSYM) val[valpos++] = c; + break; + default: + break; + } + } + + *lenp = len; + *ppos += len; + + return len; +} + + +/* + * Return mknod information for the driver's devices. + */ +static int dgnc_read_mknod(struct dgnc_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos) +{ + static int done = 0; + static char buf[4096]; + char *p = buf; + int i = 0; + + DPR_PROC(("dgnc_proc_info\n")); + + if (done) { + done = 0; + *lenp = 0; + return 0; + } + + DPR_PROC(("dgnc_proc_mknod\n")); + + p += sprintf(p, "#\tCreate the management devices.\n"); + + for (i = 0; i < MAXMGMTDEVICES; i++) { + char tmp[100]; + sprintf(tmp, "/dev/dg/dgnc/mgmt%d", i); + p += sprintf(p, "%s\t%d\t%d\t%d\n", + tmp, dgnc_Major, i, 1); + } + + if (copy_to_user(buffer, buf, (p - (char *) buf))) + return -EFAULT; + + *lenp = p - (char *) buf; + *ppos += p - (char *) buf; + done = 1; + return 0; +} + + +/* + * Return what is (hopefully) useful information about the specific board. + */ +static int dgnc_read_board_info(struct dgnc_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos) +{ + struct board_t *brd; + static int done = 0; + static char buf[4096]; + char *p = buf; + char *name; + + DPR_PROC(("dgnc_proc_brd_info\n")); + + brd = (struct board_t *) table->data; + + if (done || !brd || (brd->magic != DGNC_BOARD_MAGIC)) { + done = 0; + *lenp = 0; + return 0; + } + + name = brd->name; + + p += sprintf(p, "Board Name = %s\n", name); + if (brd->serial_num[0] == '\0') + p += sprintf(p, "Serial number = \n"); + else + p += sprintf(p, "Serial number = %s\n", brd->serial_num); + + p += sprintf(p, "Board Type = %d\n", brd->type); + p += sprintf(p, "Number of Ports = %d\n", brd->nasync); + + /* + * report some things about the PCI bus that are important + * to some applications + */ + p += sprintf(p, "Vendor ID = 0x%x\n", brd->vendor); + p += sprintf(p, "Device ID = 0x%x\n", brd->device); + p += sprintf(p, "Subvendor ID = 0x%x\n", brd->subvendor); + p += sprintf(p, "Subdevice ID = 0x%x\n", brd->subdevice); + p += sprintf(p, "Bus = %d\n", brd->pci_bus); + p += sprintf(p, "Slot = %d\n", brd->pci_slot); + + /* + * report the physical addresses assigned to us when we got + * registered + */ + p += sprintf(p, "Memory Base Address = 0x%lx\n", brd->membase); + p += sprintf(p, "Remapped Memory Base Address = 0x%p\n", brd->re_map_membase); + + p += sprintf(p, "Current state of board = %s\n", dgnc_state_text[brd->state]); + p += sprintf(p, "Interrupt #: %d. Times interrupted: %ld\n", + brd->irq, brd->intr_count); + + p += sprintf(p, "TX interrupts: %ld RX interrupts: %ld\n", + brd->intr_tx, brd->intr_rx); + p += sprintf(p, "Modem interrupts: %ld\n", brd->intr_modem); + + p += sprintf(p, "Majors allocated to board = TTY: %d PR: %d\n", + brd->SerialDriver.major, brd->PrintDriver.major); + + + if (copy_to_user(buffer, buf, (p - (char *) buf))) + return -EFAULT; + + *lenp = p - (char *) buf; + *ppos += p - (char *) buf; + done = 1; + return 0; +} + + + +static int dgnc_read_board_vpd(struct dgnc_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos) +{ + struct board_t *brd; + static int done = 0; + static char buf[4096]; + int i = 0, j = 0; + char *p = buf; + + DPR_PROC(("dgnc_proc_brd_info\n")); + + brd = (struct board_t *) table->data; + + if (done || !brd || (brd->magic != DGNC_BOARD_MAGIC)) { + done = 0; + *lenp = 0; + return 0; + } + + p += sprintf(p, "\n 0 1 2 3 4 5 6 7 8 9 A B C D E F ASCII\n"); + + for (i = 0; i < 0x40 * 2; i++) { + j = i; + if (!(i % 16)) { + if (j > 0) { + p += sprintf(p, " "); + for (j = i - 16; j < i; j++) { + if (0x20 <= brd->vpd[j] && brd->vpd[j] <= 0x7e) + p += sprintf(p, "%c", brd->vpd[j]); + else + p += sprintf(p, "."); + } + p += sprintf(p, "\n"); + } + p += sprintf(p, "%04X ", i); + } + p += sprintf(p, "%02X ", brd->vpd[i]); + } + if (!(i % 16)) { + p += sprintf(p, " "); + for (j = i - 16; j < i; j++) { + if (0x20 <= brd->vpd[j] && brd->vpd[j] <= 0x7e) + p += sprintf(p, "%c", brd->vpd[j]); + else + p += sprintf(p, "."); + } + p += sprintf(p, "\n"); + } + + p += sprintf(p, "\n"); + + if (copy_to_user(buffer, buf, (p - (char *) buf))) + return -EFAULT; + + *lenp = p - (char *) buf; + *ppos += p - (char *) buf; + done = 1; + return 0; +} + + +/* + * Return what is (hopefully) useful stats about the specific board's ttys + */ +static int dgnc_read_board_ttystats(struct dgnc_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos) +{ + struct board_t *brd; + static int done = 0; + static char buf[4096]; + char *p = buf; + int i = 0; + + DPR_PROC(("dgnc_proc_brd_info\n")); + + brd = (struct board_t *) table->data; + + if (done || !brd || (brd->magic != DGNC_BOARD_MAGIC)) { + done = 0; + *lenp = 0; + return 0; + } + + /* Prepare the Header Labels */ + p += sprintf(p, "%2s %10s %23s %10s %9s\n", + "Ch", "Chars Rx", " Rx Par--Brk--Frm--Ovr", + "Chars Tx", "XON XOFF"); + + for (i = 0; i < brd->nasync; i++) { + + struct channel_t *ch = brd->channels[i]; + + p += sprintf(p, "%2d ", i); + p += sprintf(p, "%10ld ", ch->ch_rxcount); + p += sprintf(p, " %4ld %4ld %4ld %4ld ", ch->ch_err_parity, + ch->ch_err_break, ch->ch_err_frame, ch->ch_err_overrun); + p += sprintf(p, "%10ld ", ch->ch_txcount); + p += sprintf(p, "%4ld %4ld ", ch->ch_xon_sends, ch->ch_xoff_sends); + + p += sprintf(p, "\n"); + } + + if (copy_to_user(buffer, buf, (p - (char *) buf))) + return -EFAULT; + + *lenp = p - (char *) buf; + *ppos += p - (char *) buf; + done = 1; + return 0; +} + + +/* + * Return what is (hopefully) useful stats about the specific board's tty intrs + */ +static int dgnc_read_board_ttyintr(struct dgnc_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos) +{ + struct board_t *brd; + static int done = 0; + static char buf[4096]; + char *p = buf; + int i = 0; + + DPR_PROC(("dgnc_proc_brd_info\n")); + + brd = (struct board_t *) table->data; + + if (done || !brd || (brd->magic != DGNC_BOARD_MAGIC)) { + done = 0; + *lenp = 0; + return 0; + } + + /* Prepare the Header Labels */ + p += sprintf(p, "%2s %14s %14s %14s\n", + "Ch", "TX interrupts", "RX interrupts", "Modem interrupts"); + + for (i = 0; i < brd->nasync; i++) { + + struct channel_t *ch = brd->channels[i]; + + p += sprintf(p, "%2d ", i); + + p += sprintf(p, " %14ld %14ld %14ld", + ch->ch_intr_tx, ch->ch_intr_rx, ch->ch_intr_modem); + + p += sprintf(p, "\n"); + } + + if (copy_to_user(buffer, buf, (p - (char *) buf))) + return -EFAULT; + + *lenp = p - (char *) buf; + *ppos += p - (char *) buf; + done = 1; + return 0; +} + + +/* + * Return what is (hopefully) useful flags about the specific board's ttys + */ +static int dgnc_read_board_ttyflags(struct dgnc_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos) +{ + struct board_t *brd; + static int done = 0; + static char buf[4096]; + char *p = buf; + int i = 0; + + DPR_PROC(("dgnc_proc_brd_info\n")); + + brd = (struct board_t *) table->data; + + if (done || !brd || (brd->magic != DGNC_BOARD_MAGIC)) { + done = 0; + *lenp = 0; + return 0; + } + + /* Prepare the Header Labels */ + p += sprintf(p, "%2s %5s %5s %5s %5s %5s %10s Line Status Flags\n", + "Ch", "CFlag", "IFlag", "OFlag", "LFlag", "DFlag", "Baud"); + + for (i = 0; i < brd->nasync; i++) { + + struct channel_t *ch = brd->channels[i]; + + p += sprintf(p, "%2d ", i); + p += sprintf(p, "%5x ", ch->ch_c_cflag); + p += sprintf(p, "%5x ", ch->ch_c_iflag); + p += sprintf(p, "%5x ", ch->ch_c_oflag); + p += sprintf(p, "%5x ", ch->ch_c_lflag); + p += sprintf(p, "%5x ", ch->ch_digi.digi_flags); + p += sprintf(p, "%10d ", ch->ch_old_baud); + + if (!ch->ch_open_count) { + p += sprintf(p, " -- -- -- -- -- -- --") ; + } else { + p += sprintf(p, " op %s %s %s %s %s %s", + (ch->ch_mostat & UART_MCR_RTS) ? "rs" : "--", + (ch->ch_mistat & UART_MSR_CTS) ? "cs" : "--", + (ch->ch_mostat & UART_MCR_DTR) ? "tr" : "--", + (ch->ch_mistat & UART_MSR_DSR) ? "mr" : "--", + (ch->ch_mistat & UART_MSR_DCD) ? "cd" : "--", + (ch->ch_mistat & UART_MSR_RI) ? "ri" : "--"); + } + + p += sprintf(p, "\n"); + } + if (copy_to_user(buffer, buf, (p - (char *) buf))) + return -EFAULT; + + *lenp = p - (char *) buf; + *ppos += p - (char *) buf; + done = 1; + return 0; +} + + +/* + * Return mknod information for the board's devices. + */ +static int dgnc_read_board_mknod(struct dgnc_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos) +{ + struct board_t *brd; + static int done = 0; + static char buf[4096]; + char str[MAXTTYNAMELEN]; + char *p = buf; + + DPR_PROC(("dgnc_proc_brd_info\n")); + + brd = (struct board_t *) table->data; + + if (done || !brd || (brd->magic != DGNC_BOARD_MAGIC)) { + done = 0; + *lenp = 0; + return 0; + } + + /* + * For each board, output the device information in + * a handy table format... + */ + p += sprintf(p, "# Create the TTY and PR devices\n"); + + /* TTY devices */ + sprintf(str, "ttyn%d%%p", brd->boardnum + 1); + p += sprintf(p, "%s\t\t\t%d\t%d\t%d\n", str, + brd->dgnc_Serial_Major, 0, brd->maxports); + + /* PR devices */ + sprintf(str, "prn%d%%p", brd->boardnum + 1); + p += sprintf(p, "%s\t\t\t%d\t%d\t%d\n", str, + brd->dgnc_TransparentPrint_Major, 128, brd->maxports); + + if (copy_to_user(buffer, buf, (p - (char *) buf))) + return -EFAULT; + + *lenp = p - (char *) buf; + *ppos += p - (char *) buf; + done = 1; + return 0; +} + + +/* + * Return what is (hopefully) useful information about the specific channel. + */ +static int dgnc_read_channel_info(struct dgnc_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos) +{ + struct channel_t *ch; + static int done = 0; + static char buf[4096]; + char *p = buf; + + DPR_PROC(("dgnc_proc_info\n")); + + ch = (struct channel_t *) table->data; + + if (done || !ch || (ch->magic != DGNC_CHANNEL_MAGIC)) { + done = 0; + *lenp = 0; + return 0; + } + + p += sprintf(p, "Port number:\t\t%d\n", ch->ch_portnum); + p += sprintf(p, "\n"); + + /* Prepare the Header Labels */ + p += sprintf(p, "%10s %23s %10s %9s\n", + "Chars Rx", " Rx Par--Brk--Frm--Ovr", + "Chars Tx", "XON XOFF"); + p += sprintf(p, "%10ld ", ch->ch_rxcount); + p += sprintf(p, " %4ld %4ld %4ld %4ld ", ch->ch_err_parity, + ch->ch_err_break, ch->ch_err_frame, ch->ch_err_overrun); + p += sprintf(p, "%10ld ", ch->ch_txcount); + p += sprintf(p, "%4ld %4ld ", ch->ch_xon_sends, ch->ch_xoff_sends); + p += sprintf(p, "\n\n"); + + /* Prepare the Header Labels */ + p += sprintf(p, "%5s %5s %5s %5s %5s %10s Line Status Flags\n", + "CFlag", "IFlag", "OFlag", "LFlag", "DFlag", "Baud"); + + p += sprintf(p, "%5x ", ch->ch_c_cflag); + p += sprintf(p, "%5x ", ch->ch_c_iflag); + p += sprintf(p, "%5x ", ch->ch_c_oflag); + p += sprintf(p, "%5x ", ch->ch_c_lflag); + p += sprintf(p, "%5x ", ch->ch_digi.digi_flags); + p += sprintf(p, "%10d ", ch->ch_old_baud); + if (!ch->ch_open_count) { + p += sprintf(p, " -- -- -- -- -- -- --") ; + } else { + p += sprintf(p, " op %s %s %s %s %s %s", + (ch->ch_mostat & UART_MCR_RTS) ? "rs" : "--", + (ch->ch_mistat & UART_MSR_CTS) ? "cs" : "--", + (ch->ch_mostat & UART_MCR_DTR) ? "tr" : "--", + (ch->ch_mistat & UART_MSR_DSR) ? "mr" : "--", + (ch->ch_mistat & UART_MSR_DCD) ? "cd" : "--", + (ch->ch_mistat & UART_MSR_RI) ? "ri" : "--"); + } + p += sprintf(p, "\n\n"); + + if (copy_to_user(buffer, buf, (p - (char *) buf))) + return -EFAULT; + + *lenp = p - (char *) buf; + *ppos += p - (char *) buf; + done = 1; + return 0; +} + + +/* + * Return mknod information for the board's devices. + */ +static int dgnc_read_channel_custom_ttyname(struct dgnc_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos) +{ + struct channel_t *ch; + struct board_t *brd; + static int done = 0; + static char buf[4096]; + char *p = buf; + int cn; + int bn; + + DPR_PROC(("dgnc_proc_brd_info\n")); + + ch = (struct channel_t *) table->data; + + if (done || !ch || (ch->magic != DGNC_CHANNEL_MAGIC)) { + done = 0; + *lenp = 0; + return 0; + } + + brd = ch->ch_bd; + + if (done || !brd || (brd->magic != DGNC_BOARD_MAGIC)) { + done = 0; + *lenp = 0; + return 0; + } + + bn = brd->boardnum; + cn = ch->ch_portnum; + + p += sprintf(p, "ttyn%d%c\n", bn + 1, 'a' + cn); + + if (copy_to_user(buffer, buf, (p - (char *) buf))) + return -EFAULT; + + *lenp = p - (char *) buf; + *ppos += p - (char *) buf; + done = 1; + return 0; +} + + + + +/* + * Return mknod information for the board's devices. + */ +static int dgnc_read_channel_custom_prname(struct dgnc_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos) +{ + struct channel_t *ch; + struct board_t *brd; + static int done = 0; + static char buf[4096]; + char *p = buf; + int cn; + int bn; + + DPR_PROC(("dgnc_proc_brd_info\n")); + + ch = (struct channel_t *) table->data; + + if (done || !ch || (ch->magic != DGNC_CHANNEL_MAGIC)) { + done = 0; + *lenp = 0; + return 0; + } + + brd = ch->ch_bd; + + if (done || !brd || (brd->magic != DGNC_BOARD_MAGIC)) { + done = 0; + *lenp = 0; + return 0; + } + + bn = brd->boardnum; + cn = ch->ch_portnum; + + p += sprintf(p, "prn%d%c\n", bn + 1, 'a' + cn); + + if (copy_to_user(buffer, buf, (p - (char *) buf))) + return -EFAULT; + + *lenp = p - (char *) buf; + *ppos += p - (char *) buf; + done = 1; + return 0; +} + + +static int dgnc_open_channel_sniff(struct dgnc_proc_entry *table, int dir, struct file *filp, + void *buffer, ssize_t *lenp, loff_t *ppos) +{ + struct channel_t *ch; + ulong lock_flags; + + ch = (struct channel_t *) table->data; + + if (!ch || (ch->magic != DGNC_CHANNEL_MAGIC)) + return 0; + + ch->ch_sniff_buf = dgnc_driver_kzmalloc(SNIFF_MAX, GFP_KERNEL); + + DGNC_LOCK(ch->ch_lock, lock_flags); + ch->ch_sniff_flags |= SNIFF_OPEN; + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + return 0; +} + +static int dgnc_close_channel_sniff(struct dgnc_proc_entry *table, int dir, struct file *filp, + void *buffer, ssize_t *lenp, loff_t *ppos) +{ + struct channel_t *ch; + ulong lock_flags; + + ch = (struct channel_t *) table->data; + + if (!ch || (ch->magic != DGNC_CHANNEL_MAGIC)) + return 0; + + DGNC_LOCK(ch->ch_lock, lock_flags); + ch->ch_sniff_flags &= ~(SNIFF_OPEN); + kfree(ch->ch_sniff_buf); + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + return 0; +} + + +/* + * Copy data from the monitoring buffer to the user, freeing space + * in the monitoring buffer for more messages + * + */ +static int dgnc_read_channel_sniff(struct dgnc_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos) +{ + struct channel_t *ch; + int n; + int r; + int offset = 0; + int res = 0; + ssize_t rtn = 0; + ulong lock_flags; + + ch = (struct channel_t *) table->data; + + if (!ch || (ch->magic != DGNC_CHANNEL_MAGIC)) { + rtn = -ENXIO; + goto done; + } + + /* + * Wait for some data to appear in the buffer. + */ + DGNC_LOCK(ch->ch_lock, lock_flags); + + for (;;) { + n = (ch->ch_sniff_in - ch->ch_sniff_out) & SNIFF_MASK; + + if (n != 0) + break; + + ch->ch_sniff_flags |= SNIFF_WAIT_DATA; + + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + /* + * Go to sleep waiting until the condition becomes true. + */ + rtn = wait_event_interruptible(ch->ch_sniff_wait, + ((ch->ch_sniff_flags & SNIFF_WAIT_DATA) == 0)); + + if (rtn) + goto done; + + DGNC_LOCK(ch->ch_lock, lock_flags); + } + + /* + * Read whatever is there. + */ + + if (n > *lenp) + n = *lenp; + + res = n; + + r = SNIFF_MAX - ch->ch_sniff_out; + + if (r <= n) { + DGNC_UNLOCK(ch->ch_lock, lock_flags); + rtn = copy_to_user(buffer, ch->ch_sniff_buf + ch->ch_sniff_out, r); + if (rtn) { + rtn = -EFAULT; + goto done; + } + + DGNC_LOCK(ch->ch_lock, lock_flags); + + ch->ch_sniff_out = 0; + n -= r; + offset = r; + } + + DGNC_UNLOCK(ch->ch_lock, lock_flags); + rtn = copy_to_user(buffer + offset, ch->ch_sniff_buf + ch->ch_sniff_out, n); + if (rtn) { + rtn = -EFAULT; + goto done; + } + DGNC_LOCK(ch->ch_lock, lock_flags); + + ch->ch_sniff_out += n; + *ppos += res; + rtn = res; +// rtn = 0; + + /* + * Wakeup any thread waiting for buffer space. + */ + + if (ch->ch_sniff_flags & SNIFF_WAIT_SPACE) { + ch->ch_sniff_flags &= ~SNIFF_WAIT_SPACE; + wake_up_interruptible(&ch->ch_sniff_wait); + } + + DGNC_UNLOCK(ch->ch_lock, lock_flags); + +done: + return rtn; +} + + +/* + * Register the basic /proc/dgnc files that appear whenever + * the driver is loaded. + */ +void dgnc_proc_register_basic_prescan(void) +{ + /* + * Register /proc/dgnc + */ + ProcDGNC = proc_create("dgnc", (0700 | S_IFDIR), NULL, &dgnc_proc_file_ops); + dgnc_register_proc_table(dgnc_table, ProcDGNC); +} + + +/* + * Register the basic /proc/dgnc files that appear whenever + * the driver is loaded. + */ +void dgnc_proc_register_basic_postscan(int board_num) +{ + int i, j; + char board[10]; + sprintf(board, "%d", board_num); + + /* Set proc board entry pointer */ + dgnc_Board[board_num]->proc_entry_pointer = create_proc_entry(board, (0700 | S_IFDIR), ProcDGNC); + + /* Create a new copy of the board_table... */ + dgnc_Board[board_num]->dgnc_board_table = dgnc_driver_kzmalloc(sizeof(dgnc_board_table), + GFP_KERNEL); + + /* Now copy the default table into that memory */ + memcpy(dgnc_Board[board_num]->dgnc_board_table, dgnc_board_table, sizeof(dgnc_board_table)); + + /* Initialize semaphores in each table slot */ + for (i = 0; i < 999; i++) { + if (!dgnc_Board[board_num]->dgnc_board_table[i].magic) { + break; + } + + init_MUTEX(&(dgnc_Board[board_num]->dgnc_board_table[i].excl_sem)); + dgnc_Board[board_num]->dgnc_board_table[i].data = dgnc_Board[board_num]; + + } + + /* Register board table into proc */ + dgnc_register_proc_table(dgnc_Board[board_num]->dgnc_board_table, + dgnc_Board[board_num]->proc_entry_pointer); + + /* + * Add new entries for each port. + */ + for (i = 0; i < dgnc_Board[board_num]->nasync; i++) { + + char channel[10]; + sprintf(channel, "%d", i); + + /* Set proc channel entry pointer */ + dgnc_Board[board_num]->channels[i]->proc_entry_pointer = + create_proc_entry(channel, (0700 | S_IFDIR), + dgnc_Board[board_num]->proc_entry_pointer); + + /* Create a new copy of the channel_table... */ + dgnc_Board[board_num]->channels[i]->dgnc_channel_table = + dgnc_driver_kzmalloc(sizeof(dgnc_channel_table), GFP_KERNEL); + + /* Now copy the default table into that memory */ + memcpy(dgnc_Board[board_num]->channels[i]->dgnc_channel_table, + dgnc_channel_table, sizeof(dgnc_channel_table)); + + /* Initialize semaphores in each table slot */ + for (j = 0; j < 999; j++) { + if (!dgnc_Board[board_num]->channels[i]->dgnc_channel_table[j].magic) { + break; + } + + init_MUTEX(&(dgnc_Board[board_num]->channels[i]->dgnc_channel_table[j].excl_sem)); + dgnc_Board[board_num]->channels[i]->dgnc_channel_table[j].data = + dgnc_Board[board_num]->channels[i]; + } + + /* Register channel table into proc */ + dgnc_register_proc_table(dgnc_Board[board_num]->channels[i]->dgnc_channel_table, + dgnc_Board[board_num]->channels[i]->proc_entry_pointer); + } +} + + +static void dgnc_remove_proc_entry(struct proc_dir_entry *pde) +{ + if (!pde) { + DPR_PROC(("dgnc_remove_proc_entry... NULL entry... not removing...\n")); + return; + } + + remove_proc_entry(pde->name, pde->parent); +} + + +void dgnc_proc_unregister_all(void) +{ + int i = 0, j = 0; + + /* Walk each board, blowing away their proc entries... */ + for (i = 0; i < dgnc_NumBoards; i++) { + + /* Walk each channel, blowing away their proc entries... */ + for (j = 0; j < dgnc_Board[i]->nasync; j++) { + + dgnc_unregister_proc_table(dgnc_Board[i]->channels[j]->dgnc_channel_table, + dgnc_Board[i]->channels[j]->proc_entry_pointer); + dgnc_remove_proc_entry(dgnc_Board[i]->channels[j]->proc_entry_pointer); + kfree(dgnc_Board[i]->channels[j]->dgnc_channel_table); + } + + dgnc_unregister_proc_table(dgnc_Board[i]->dgnc_board_table, + dgnc_Board[i]->proc_entry_pointer); + dgnc_remove_proc_entry(dgnc_Board[i]->proc_entry_pointer); + kfree(dgnc_Board[i]->dgnc_board_table); + } + + /* Blow away the top proc entry */ + dgnc_unregister_proc_table(dgnc_table, ProcDGNC); + dgnc_remove_proc_entry(ProcDGNC); +} diff --git a/drivers/staging/dgnc/dgnc_proc.h b/drivers/staging/dgnc/dgnc_proc.h new file mode 100644 index 0000000000000..19670e29d5706 --- /dev/null +++ b/drivers/staging/dgnc/dgnc_proc.h @@ -0,0 +1,147 @@ +/* + * Copyright 2003 Digi International (www.digi.com) + * Scott H Kilau + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! + * + * + * $Id: dgnc_proc.h,v 1.1.1.1 2009/05/20 12:19:19 markh Exp $ + * + * Description: + * + * Describes the private structures used to manipulate the "special" + * proc constructs (not read-only) used by the Digi Neo software. + * The concept is borrowed heavily from the "sysctl" interface of + * the kernel. I decided not to use the structures and functions + * provided by the kernel for two reasons: + * + * 1. Due to the planned use of "/proc" in the Neo driver, many + * of the functions of the "sysctl" interface would go unused. + * A simpler interface will be easier to maintain. + * + * 2. I'd rather divorce our "added package" from the kernel internals. + * If the "sysctl" structures should change, I will be insulated + * from those changes. These "/proc" entries won't be under the + * "sys" tree anyway, so there is no need to maintain a strict + * dependence relationship. + * + * Author: + * + * Scott H Kilau + * + */ + +#ifndef _DGNC_RW_PROC_H +#define _DGNC_RW_PROC_H + +/* + * The list of DGNC entries with r/w capabilities. + * These magic numbers are used for identification purposes. + */ +enum { + DGNC_INFO = 1, /* Get info about the running module */ + DGNC_MKNOD = 2, /* Get info about driver devices */ + DGNC_BOARD_INFO = 3, /* Get info about the specific board */ + DGNC_BOARD_VPD = 4, /* Get info about the board's VPD */ + DGNC_BOARD_TTYSTATS = 5, /* Get info about the board's tty stats */ + DGNC_BOARD_TTYINTR = 6, /* Get info about the board's tty intrs */ + DGNC_BOARD_TTYFLAGS = 7, /* Get info about the board's tty flags */ + DGNC_BOARD_MKNOD = 8, /* Get info about board devices */ + DGNC_PORT_INFO = 9, /* Get info about the specific port */ + DGNC_PORT_SNIFF = 10, /* Sniff data in/out of specific port */ + DGNC_PORT_CUSTOM_TTYNAME = 11, /* Get info about UDEV tty name */ + DGNC_PORT_CUSTOM_PRNAME = 12, /* Get info about UDEV pr name */ +}; + +/* + * Directions for proc handlers + */ +enum { + INBOUND = 1, /* Data being written to kernel */ + OUTBOUND = 2, /* Data being read from the kernel */ +}; + +/* + * Each entry in a DGNC proc directory is described with a + * "dgnc_proc_entry" structure. A collection of these + * entries (in an array) represents the members associated + * with a particular "/proc" directory, and is referred to + * as a table. All "tables" are terminated by an entry with + * zeros for every member. + * + * The structure members are as follows: + * + * int magic -- ID number associated with this particular + * entry. Should be unique across all of + * DGNC. + * + * const char *name -- ASCII name associated with the /proc entry. + * + * mode_t mode -- File access permisssions for the /proc entry. + * + * dgnc_proc_entry *child -- When set, this entry refers to a directory, + * and points to the table which describes the + * entries in the subdirectory + * + * dgnc_proc_handler *open_handler -- When set, points to the fxn which + * does any "extra" open stuff. + * + * dgnc_proc_handler *close_handler -- When set, points to the fxn which + * does any "extra" close stuff. + * + * dgnc_proc_handler *read_handler -- When set, points to the fxn which + * handle outbound data flow + * + * dgnc_proc_handler *write_handler -- When set, points to the fxn which + * handles inbound data flow + * + * struct proc_dir_entry *de -- Pointer to the directory entry for this + * object once registered. Used to grab + * the handle of the object for + * unregistration + * + * void *data; When set, points to the parent structure + * + */ + +struct dgnc_proc_entry { + int magic; /* Integer identifier */ + const char *name; /* ASCII identifier */ + mode_t mode; /* File access permissions */ + struct dgnc_proc_entry *child; /* Child pointer */ + + int (*open_handler) (struct dgnc_proc_entry *table, int dir, struct file *filp, + void *buffer, ssize_t *lenp, loff_t *ppos); + int (*close_handler) (struct dgnc_proc_entry *table, int dir, struct file *filp, + void *buffer, ssize_t *lenp, loff_t *ppos); + int (*read_handler) (struct dgnc_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos); + int (*write_handler) (struct dgnc_proc_entry *table, int dir, struct file *filp, + const char __user *buffer, ssize_t *lenp, loff_t *ppos); + + struct proc_dir_entry *de; /* proc entry pointer */ + struct semaphore excl_sem; /* Protects exclusive access var */ + int excl_cnt; /* Counts number of curr accesses */ + void *data; /* Allows storing a pointer to parent */ +}; + +void dgnc_proc_register_basic_prescan(void); +void dgnc_proc_register_basic_postscan(int board_num); +void dgnc_proc_unregister_all(void); + + +#endif /* _DGNC_RW_PROC_H */ diff --git a/drivers/staging/dgnc/dgnc_sysfs.c b/drivers/staging/dgnc/dgnc_sysfs.c new file mode 100644 index 0000000000000..af49e44382f51 --- /dev/null +++ b/drivers/staging/dgnc/dgnc_sysfs.c @@ -0,0 +1,761 @@ +/* + * Copyright 2004 Digi International (www.digi.com) + * Scott H Kilau + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * + * NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE! + * + * This is shared code between Digi's CVS archive and the + * Linux Kernel sources. + * Changing the source just for reformatting needlessly breaks + * our CVS diff history. + * + * Send any bug fixes/changes to: Eng.Linux at digi dot com. + * Thank you. + * + * + * + * $Id: dgnc_sysfs.c,v 1.1.1.1 2009/05/20 12:19:19 markh Exp $ + */ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "dgnc_driver.h" +#include "dgnc_proc.h" +#include "dgnc_mgmt.h" + + +static ssize_t dgnc_driver_version_show(struct device_driver *ddp, char *buf) +{ + return snprintf(buf, PAGE_SIZE, "%s\n", DG_PART); +} +static DRIVER_ATTR(version, S_IRUSR, dgnc_driver_version_show, NULL); + + +static ssize_t dgnc_driver_boards_show(struct device_driver *ddp, char *buf) +{ + return snprintf(buf, PAGE_SIZE, "%d\n", dgnc_NumBoards); +} +static DRIVER_ATTR(boards, S_IRUSR, dgnc_driver_boards_show, NULL); + + +static ssize_t dgnc_driver_maxboards_show(struct device_driver *ddp, char *buf) +{ + return snprintf(buf, PAGE_SIZE, "%d\n", MAXBOARDS); +} +static DRIVER_ATTR(maxboards, S_IRUSR, dgnc_driver_maxboards_show, NULL); + + +static ssize_t dgnc_driver_pollcounter_show(struct device_driver *ddp, char *buf) +{ + return snprintf(buf, PAGE_SIZE, "%ld\n", dgnc_poll_counter); +} +static DRIVER_ATTR(pollcounter, S_IRUSR, dgnc_driver_pollcounter_show, NULL); + + +static ssize_t dgnc_driver_state_show(struct device_driver *ddp, char *buf) +{ + return snprintf(buf, PAGE_SIZE, "%s\n", dgnc_driver_state_text[dgnc_driver_state]); +} +static DRIVER_ATTR(state, S_IRUSR, dgnc_driver_state_show, NULL); + + +static ssize_t dgnc_driver_debug_show(struct device_driver *ddp, char *buf) +{ + return snprintf(buf, PAGE_SIZE, "0x%x\n", dgnc_debug); +} + +static ssize_t dgnc_driver_debug_store(struct device_driver *ddp, const char *buf, size_t count) +{ + sscanf(buf, "0x%x\n", &dgnc_debug); + return count; +} +static DRIVER_ATTR(debug, (S_IRUSR | S_IWUSR), dgnc_driver_debug_show, dgnc_driver_debug_store); + + +static ssize_t dgnc_driver_rawreadok_show(struct device_driver *ddp, char *buf) +{ + return snprintf(buf, PAGE_SIZE, "0x%x\n", dgnc_rawreadok); +} + +static ssize_t dgnc_driver_rawreadok_store(struct device_driver *ddp, const char *buf, size_t count) +{ + sscanf(buf, "0x%x\n", &dgnc_rawreadok); + return count; +} +static DRIVER_ATTR(rawreadok, (S_IRUSR | S_IWUSR), dgnc_driver_rawreadok_show, dgnc_driver_rawreadok_store); + + +static ssize_t dgnc_driver_pollrate_show(struct device_driver *ddp, char *buf) +{ + return snprintf(buf, PAGE_SIZE, "%dms\n", dgnc_poll_tick); +} + +static ssize_t dgnc_driver_pollrate_store(struct device_driver *ddp, const char *buf, size_t count) +{ + sscanf(buf, "%d\n", &dgnc_poll_tick); + return count; +} +static DRIVER_ATTR(pollrate, (S_IRUSR | S_IWUSR), dgnc_driver_pollrate_show, dgnc_driver_pollrate_store); + + +void dgnc_create_driver_sysfiles(struct pci_driver *dgnc_driver) +{ + int rc = 0; + struct device_driver *driverfs = &dgnc_driver->driver; + + rc |= driver_create_file(driverfs, &driver_attr_version); + rc |= driver_create_file(driverfs, &driver_attr_boards); + rc |= driver_create_file(driverfs, &driver_attr_maxboards); + rc |= driver_create_file(driverfs, &driver_attr_debug); + rc |= driver_create_file(driverfs, &driver_attr_rawreadok); + rc |= driver_create_file(driverfs, &driver_attr_pollrate); + rc |= driver_create_file(driverfs, &driver_attr_pollcounter); + rc |= driver_create_file(driverfs, &driver_attr_state); + if (rc) { + printk(KERN_ERR "DGNC: sysfs driver_create_file failed!\n"); + } +} + + +void dgnc_remove_driver_sysfiles(struct pci_driver *dgnc_driver) +{ + struct device_driver *driverfs = &dgnc_driver->driver; + driver_remove_file(driverfs, &driver_attr_version); + driver_remove_file(driverfs, &driver_attr_boards); + driver_remove_file(driverfs, &driver_attr_maxboards); + driver_remove_file(driverfs, &driver_attr_debug); + driver_remove_file(driverfs, &driver_attr_rawreadok); + driver_remove_file(driverfs, &driver_attr_pollrate); + driver_remove_file(driverfs, &driver_attr_pollcounter); + driver_remove_file(driverfs, &driver_attr_state); +} + + +#define DGNC_VERIFY_BOARD(p, bd) \ + if (!p) \ + return (0); \ + \ + bd = dev_get_drvdata(p); \ + if (!bd || bd->magic != DGNC_BOARD_MAGIC) \ + return (0); \ + if (bd->state != BOARD_READY) \ + return (0); \ + + + +static ssize_t dgnc_vpd_show(struct device *p, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + int count = 0; + int i = 0; + + DGNC_VERIFY_BOARD(p, bd); + + count += sprintf(buf + count, "\n 0 1 2 3 4 5 6 7 8 9 A B C D E F"); + for (i = 0; i < 0x40 * 2; i++) { + if (!(i % 16)) + count += sprintf(buf + count, "\n%04X ", i * 2); + count += sprintf(buf + count, "%02X ", bd->vpd[i]); + } + count += sprintf(buf + count, "\n"); + + return count; +} +static DEVICE_ATTR(vpd, S_IRUSR, dgnc_vpd_show, NULL); + +static ssize_t dgnc_serial_number_show(struct device *p, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + int count = 0; + + DGNC_VERIFY_BOARD(p, bd); + + if (bd->serial_num[0] == '\0') + count += sprintf(buf + count, "\n"); + else + count += sprintf(buf + count, "%s\n", bd->serial_num); + + return count; +} +static DEVICE_ATTR(serial_number, S_IRUSR, dgnc_serial_number_show, NULL); + + +static ssize_t dgnc_ports_state_show(struct device *p, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + int count = 0; + int i = 0; + + DGNC_VERIFY_BOARD(p, bd); + + for (i = 0; i < bd->nasync; i++) { + count += snprintf(buf + count, PAGE_SIZE - count, + "%d %s\n", bd->channels[i]->ch_portnum, + bd->channels[i]->ch_open_count ? "Open" : "Closed"); + } + return count; +} +static DEVICE_ATTR(ports_state, S_IRUSR, dgnc_ports_state_show, NULL); + + +static ssize_t dgnc_ports_baud_show(struct device *p, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + int count = 0; + int i = 0; + + DGNC_VERIFY_BOARD(p, bd); + + for (i = 0; i < bd->nasync; i++) { + count += snprintf(buf + count, PAGE_SIZE - count, + "%d %d\n", bd->channels[i]->ch_portnum, bd->channels[i]->ch_old_baud); + } + return count; +} +static DEVICE_ATTR(ports_baud, S_IRUSR, dgnc_ports_baud_show, NULL); + + +static ssize_t dgnc_ports_msignals_show(struct device *p, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + int count = 0; + int i = 0; + + DGNC_VERIFY_BOARD(p, bd); + + for (i = 0; i < bd->nasync; i++) { + if (bd->channels[i]->ch_open_count) { + count += snprintf(buf + count, PAGE_SIZE - count, + "%d %s %s %s %s %s %s\n", bd->channels[i]->ch_portnum, + (bd->channels[i]->ch_mostat & UART_MCR_RTS) ? "RTS" : "", + (bd->channels[i]->ch_mistat & UART_MSR_CTS) ? "CTS" : "", + (bd->channels[i]->ch_mostat & UART_MCR_DTR) ? "DTR" : "", + (bd->channels[i]->ch_mistat & UART_MSR_DSR) ? "DSR" : "", + (bd->channels[i]->ch_mistat & UART_MSR_DCD) ? "DCD" : "", + (bd->channels[i]->ch_mistat & UART_MSR_RI) ? "RI" : ""); + } else { + count += snprintf(buf + count, PAGE_SIZE - count, + "%d\n", bd->channels[i]->ch_portnum); + } + } + return count; +} +static DEVICE_ATTR(ports_msignals, S_IRUSR, dgnc_ports_msignals_show, NULL); + + +static ssize_t dgnc_ports_iflag_show(struct device *p, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + int count = 0; + int i = 0; + + DGNC_VERIFY_BOARD(p, bd); + + for (i = 0; i < bd->nasync; i++) { + count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n", + bd->channels[i]->ch_portnum, bd->channels[i]->ch_c_iflag); + } + return count; +} +static DEVICE_ATTR(ports_iflag, S_IRUSR, dgnc_ports_iflag_show, NULL); + + +static ssize_t dgnc_ports_cflag_show(struct device *p, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + int count = 0; + int i = 0; + + DGNC_VERIFY_BOARD(p, bd); + + for (i = 0; i < bd->nasync; i++) { + count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n", + bd->channels[i]->ch_portnum, bd->channels[i]->ch_c_cflag); + } + return count; +} +static DEVICE_ATTR(ports_cflag, S_IRUSR, dgnc_ports_cflag_show, NULL); + + +static ssize_t dgnc_ports_oflag_show(struct device *p, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + int count = 0; + int i = 0; + + DGNC_VERIFY_BOARD(p, bd); + + for (i = 0; i < bd->nasync; i++) { + count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n", + bd->channels[i]->ch_portnum, bd->channels[i]->ch_c_oflag); + } + return count; +} +static DEVICE_ATTR(ports_oflag, S_IRUSR, dgnc_ports_oflag_show, NULL); + + +static ssize_t dgnc_ports_lflag_show(struct device *p, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + int count = 0; + int i = 0; + + DGNC_VERIFY_BOARD(p, bd); + + for (i = 0; i < bd->nasync; i++) { + count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n", + bd->channels[i]->ch_portnum, bd->channels[i]->ch_c_lflag); + } + return count; +} +static DEVICE_ATTR(ports_lflag, S_IRUSR, dgnc_ports_lflag_show, NULL); + + +static ssize_t dgnc_ports_digi_flag_show(struct device *p, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + int count = 0; + int i = 0; + + DGNC_VERIFY_BOARD(p, bd); + + for (i = 0; i < bd->nasync; i++) { + count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n", + bd->channels[i]->ch_portnum, bd->channels[i]->ch_digi.digi_flags); + } + return count; +} +static DEVICE_ATTR(ports_digi_flag, S_IRUSR, dgnc_ports_digi_flag_show, NULL); + + +static ssize_t dgnc_ports_rxcount_show(struct device *p, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + int count = 0; + int i = 0; + + DGNC_VERIFY_BOARD(p, bd); + + for (i = 0; i < bd->nasync; i++) { + count += snprintf(buf + count, PAGE_SIZE - count, "%d %ld\n", + bd->channels[i]->ch_portnum, bd->channels[i]->ch_rxcount); + } + return count; +} +static DEVICE_ATTR(ports_rxcount, S_IRUSR, dgnc_ports_rxcount_show, NULL); + + +static ssize_t dgnc_ports_txcount_show(struct device *p, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + int count = 0; + int i = 0; + + DGNC_VERIFY_BOARD(p, bd); + + for (i = 0; i < bd->nasync; i++) { + count += snprintf(buf + count, PAGE_SIZE - count, "%d %ld\n", + bd->channels[i]->ch_portnum, bd->channels[i]->ch_txcount); + } + return count; +} +static DEVICE_ATTR(ports_txcount, S_IRUSR, dgnc_ports_txcount_show, NULL); + + +/* this function creates the sys files that will export each signal status + * to sysfs each value will be put in a separate filename + */ +void dgnc_create_ports_sysfiles(struct board_t *bd) +{ + int rc = 0; + + dev_set_drvdata(&bd->pdev->dev, bd); + rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_state); + rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_baud); + rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_msignals); + rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_iflag); + rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_cflag); + rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_oflag); + rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_lflag); + rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_digi_flag); + rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_rxcount); + rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_txcount); + rc |= device_create_file(&(bd->pdev->dev), &dev_attr_vpd); + rc |= device_create_file(&(bd->pdev->dev), &dev_attr_serial_number); + if (rc) { + printk(KERN_ERR "DGNC: sysfs device_create_file failed!\n"); + } +} + + +/* removes all the sys files created for that port */ +void dgnc_remove_ports_sysfiles(struct board_t *bd) +{ + device_remove_file(&(bd->pdev->dev), &dev_attr_ports_state); + device_remove_file(&(bd->pdev->dev), &dev_attr_ports_baud); + device_remove_file(&(bd->pdev->dev), &dev_attr_ports_msignals); + device_remove_file(&(bd->pdev->dev), &dev_attr_ports_iflag); + device_remove_file(&(bd->pdev->dev), &dev_attr_ports_cflag); + device_remove_file(&(bd->pdev->dev), &dev_attr_ports_oflag); + device_remove_file(&(bd->pdev->dev), &dev_attr_ports_lflag); + device_remove_file(&(bd->pdev->dev), &dev_attr_ports_digi_flag); + device_remove_file(&(bd->pdev->dev), &dev_attr_ports_rxcount); + device_remove_file(&(bd->pdev->dev), &dev_attr_ports_txcount); + device_remove_file(&(bd->pdev->dev), &dev_attr_vpd); + device_remove_file(&(bd->pdev->dev), &dev_attr_serial_number); +} + + +static ssize_t dgnc_tty_state_show(struct device *d, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + + if (!d) + return (0); + un = (struct un_t *) dev_get_drvdata(d); + if (!un || un->magic != DGNC_UNIT_MAGIC) + return (0); + ch = un->un_ch; + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return (0); + bd = ch->ch_bd; + if (!bd || bd->magic != DGNC_BOARD_MAGIC) + return (0); + if (bd->state != BOARD_READY) + return (0); + + return snprintf(buf, PAGE_SIZE, "%s", un->un_open_count ? "Open" : "Closed"); +} +static DEVICE_ATTR(state, S_IRUSR, dgnc_tty_state_show, NULL); + + +static ssize_t dgnc_tty_baud_show(struct device *d, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + + if (!d) + return (0); + un = (struct un_t *) dev_get_drvdata(d); + if (!un || un->magic != DGNC_UNIT_MAGIC) + return (0); + ch = un->un_ch; + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return (0); + bd = ch->ch_bd; + if (!bd || bd->magic != DGNC_BOARD_MAGIC) + return (0); + if (bd->state != BOARD_READY) + return (0); + + return snprintf(buf, PAGE_SIZE, "%d\n", ch->ch_old_baud); +} +static DEVICE_ATTR(baud, S_IRUSR, dgnc_tty_baud_show, NULL); + + +static ssize_t dgnc_tty_msignals_show(struct device *d, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + + if (!d) + return (0); + un = (struct un_t *) dev_get_drvdata(d); + if (!un || un->magic != DGNC_UNIT_MAGIC) + return (0); + ch = un->un_ch; + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return (0); + bd = ch->ch_bd; + if (!bd || bd->magic != DGNC_BOARD_MAGIC) + return (0); + if (bd->state != BOARD_READY) + return (0); + + if (ch->ch_open_count) { + return snprintf(buf, PAGE_SIZE, "%s %s %s %s %s %s\n", + (ch->ch_mostat & UART_MCR_RTS) ? "RTS" : "", + (ch->ch_mistat & UART_MSR_CTS) ? "CTS" : "", + (ch->ch_mostat & UART_MCR_DTR) ? "DTR" : "", + (ch->ch_mistat & UART_MSR_DSR) ? "DSR" : "", + (ch->ch_mistat & UART_MSR_DCD) ? "DCD" : "", + (ch->ch_mistat & UART_MSR_RI) ? "RI" : ""); + } + return 0; +} +static DEVICE_ATTR(msignals, S_IRUSR, dgnc_tty_msignals_show, NULL); + + +static ssize_t dgnc_tty_iflag_show(struct device *d, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + + if (!d) + return (0); + un = (struct un_t *) dev_get_drvdata(d); + if (!un || un->magic != DGNC_UNIT_MAGIC) + return (0); + ch = un->un_ch; + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return (0); + bd = ch->ch_bd; + if (!bd || bd->magic != DGNC_BOARD_MAGIC) + return (0); + if (bd->state != BOARD_READY) + return (0); + + return snprintf(buf, PAGE_SIZE, "%x\n", ch->ch_c_iflag); +} +static DEVICE_ATTR(iflag, S_IRUSR, dgnc_tty_iflag_show, NULL); + + +static ssize_t dgnc_tty_cflag_show(struct device *d, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + + if (!d) + return (0); + un = (struct un_t *) dev_get_drvdata(d); + if (!un || un->magic != DGNC_UNIT_MAGIC) + return (0); + ch = un->un_ch; + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return (0); + bd = ch->ch_bd; + if (!bd || bd->magic != DGNC_BOARD_MAGIC) + return (0); + if (bd->state != BOARD_READY) + return (0); + + return snprintf(buf, PAGE_SIZE, "%x\n", ch->ch_c_cflag); +} +static DEVICE_ATTR(cflag, S_IRUSR, dgnc_tty_cflag_show, NULL); + + +static ssize_t dgnc_tty_oflag_show(struct device *d, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + + if (!d) + return (0); + un = (struct un_t *) dev_get_drvdata(d); + if (!un || un->magic != DGNC_UNIT_MAGIC) + return (0); + ch = un->un_ch; + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return (0); + bd = ch->ch_bd; + if (!bd || bd->magic != DGNC_BOARD_MAGIC) + return (0); + if (bd->state != BOARD_READY) + return (0); + + return snprintf(buf, PAGE_SIZE, "%x\n", ch->ch_c_oflag); +} +static DEVICE_ATTR(oflag, S_IRUSR, dgnc_tty_oflag_show, NULL); + + +static ssize_t dgnc_tty_lflag_show(struct device *d, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + + if (!d) + return (0); + un = (struct un_t *) dev_get_drvdata(d); + if (!un || un->magic != DGNC_UNIT_MAGIC) + return (0); + ch = un->un_ch; + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return (0); + bd = ch->ch_bd; + if (!bd || bd->magic != DGNC_BOARD_MAGIC) + return (0); + if (bd->state != BOARD_READY) + return (0); + + return snprintf(buf, PAGE_SIZE, "%x\n", ch->ch_c_lflag); +} +static DEVICE_ATTR(lflag, S_IRUSR, dgnc_tty_lflag_show, NULL); + + +static ssize_t dgnc_tty_digi_flag_show(struct device *d, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + + if (!d) + return (0); + un = (struct un_t *) dev_get_drvdata(d); + if (!un || un->magic != DGNC_UNIT_MAGIC) + return (0); + ch = un->un_ch; + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return (0); + bd = ch->ch_bd; + if (!bd || bd->magic != DGNC_BOARD_MAGIC) + return (0); + if (bd->state != BOARD_READY) + return (0); + + return snprintf(buf, PAGE_SIZE, "%x\n", ch->ch_digi.digi_flags); +} +static DEVICE_ATTR(digi_flag, S_IRUSR, dgnc_tty_digi_flag_show, NULL); + + +static ssize_t dgnc_tty_rxcount_show(struct device *d, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + + if (!d) + return (0); + un = (struct un_t *) dev_get_drvdata(d); + if (!un || un->magic != DGNC_UNIT_MAGIC) + return (0); + ch = un->un_ch; + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return (0); + bd = ch->ch_bd; + if (!bd || bd->magic != DGNC_BOARD_MAGIC) + return (0); + if (bd->state != BOARD_READY) + return (0); + + return snprintf(buf, PAGE_SIZE, "%ld\n", ch->ch_rxcount); +} +static DEVICE_ATTR(rxcount, S_IRUSR, dgnc_tty_rxcount_show, NULL); + + +static ssize_t dgnc_tty_txcount_show(struct device *d, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + + if (!d) + return (0); + un = (struct un_t *) dev_get_drvdata(d); + if (!un || un->magic != DGNC_UNIT_MAGIC) + return (0); + ch = un->un_ch; + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return (0); + bd = ch->ch_bd; + if (!bd || bd->magic != DGNC_BOARD_MAGIC) + return (0); + if (bd->state != BOARD_READY) + return (0); + + return snprintf(buf, PAGE_SIZE, "%ld\n", ch->ch_txcount); +} +static DEVICE_ATTR(txcount, S_IRUSR, dgnc_tty_txcount_show, NULL); + + +static ssize_t dgnc_tty_name_show(struct device *d, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + + if (!d) + return (0); + un = (struct un_t *) dev_get_drvdata(d); + if (!un || un->magic != DGNC_UNIT_MAGIC) + return (0); + ch = un->un_ch; + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return (0); + bd = ch->ch_bd; + if (!bd || bd->magic != DGNC_BOARD_MAGIC) + return (0); + if (bd->state != BOARD_READY) + return (0); + + return snprintf(buf, PAGE_SIZE, "%sn%d%c\n", + (un->un_type == DGNC_PRINT) ? "pr" : "tty", + bd->boardnum + 1, 'a' + ch->ch_portnum); +} +static DEVICE_ATTR(custom_name, S_IRUSR, dgnc_tty_name_show, NULL); + + +static struct attribute *dgnc_sysfs_tty_entries[] = { + &dev_attr_state.attr, + &dev_attr_baud.attr, + &dev_attr_msignals.attr, + &dev_attr_iflag.attr, + &dev_attr_cflag.attr, + &dev_attr_oflag.attr, + &dev_attr_lflag.attr, + &dev_attr_digi_flag.attr, + &dev_attr_rxcount.attr, + &dev_attr_txcount.attr, + &dev_attr_custom_name.attr, + NULL +}; + + +static struct attribute_group dgnc_tty_attribute_group = { + .name = NULL, + .attrs = dgnc_sysfs_tty_entries, +}; + + +void dgnc_create_tty_sysfs(struct un_t *un, struct device *c) +{ + int ret; + + ret = sysfs_create_group(&c->kobj, &dgnc_tty_attribute_group); + if (ret) { + printk(KERN_ERR "dgnc: failed to create sysfs tty device attributes.\n"); + sysfs_remove_group(&c->kobj, &dgnc_tty_attribute_group); + return; + } + + dev_set_drvdata(c, un); + +} + + +void dgnc_remove_tty_sysfs(struct device *c) +{ + sysfs_remove_group(&c->kobj, &dgnc_tty_attribute_group); +} + diff --git a/drivers/staging/dgnc/dgnc_sysfs.h b/drivers/staging/dgnc/dgnc_sysfs.h new file mode 100644 index 0000000000000..fe991103668c7 --- /dev/null +++ b/drivers/staging/dgnc/dgnc_sysfs.h @@ -0,0 +1,49 @@ +/* + * Copyright 2003 Digi International (www.digi.com) + * Scott H Kilau + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! + */ + +#ifndef __DGNC_SYSFS_H +#define __DGNC_SYSFS_H + +#include "dgnc_driver.h" + +#include + +struct board_t; +struct channel_t; +struct un_t; +struct pci_driver; +struct class_device; + +extern void dgnc_create_ports_sysfiles(struct board_t *bd); +extern void dgnc_remove_ports_sysfiles(struct board_t *bd); + +extern void dgnc_create_driver_sysfiles(struct pci_driver *); +extern void dgnc_remove_driver_sysfiles(struct pci_driver *); + +extern int dgnc_tty_class_init(void); +extern int dgnc_tty_class_destroy(void); + +extern void dgnc_create_tty_sysfs(struct un_t *un, struct device *c); +extern void dgnc_remove_tty_sysfs(struct device *c); + + + +#endif diff --git a/drivers/staging/dgnc/dgnc_trace.c b/drivers/staging/dgnc/dgnc_trace.c new file mode 100644 index 0000000000000..ea710e5657987 --- /dev/null +++ b/drivers/staging/dgnc/dgnc_trace.c @@ -0,0 +1,187 @@ +/* + * Copyright 2003 Digi International (www.digi.com) + * Scott H Kilau + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * + * NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE! + * + * This is shared code between Digi's CVS archive and the + * Linux Kernel sources. + * Changing the source just for reformatting needlessly breaks + * our CVS diff history. + * + * Send any bug fixes/changes to: Eng.Linux at digi dot com. + * Thank you. + * + */ + +/* $Id: dgnc_trace.c,v 1.1.1.1 2009/05/20 12:19:19 markh Exp $ */ + +#include +#include +#include /* For jiffies, task states */ +#include /* For tasklet and interrupt structs/defines */ +#include + +#include "dgnc_driver.h" + +#define TRC_TO_CONSOLE 1 + +/* file level globals */ +static char *dgnc_trcbuf; /* the ringbuffer */ + +#if defined(TRC_TO_KMEM) +static int dgnc_trcbufi = 0; /* index of the tilde at the end of */ +#endif + +#if defined(TRC_TO_KMEM) +static DEFINE_SPINLOCK(dgnc_tracef_lock); +#endif + + +#if 0 + +#if !defined(TRC_TO_KMEM) && !defined(TRC_TO_CONSOLE) + +void dgnc_tracef(const char *fmt, ...) +{ + return; +} + +#else /* !defined(TRC_TO_KMEM) && !defined(TRC_TO_CONSOLE) */ + +void dgnc_tracef(const char *fmt, ...) +{ + va_list ap; + char buf[TRC_MAXMSG+1]; + size_t lenbuf; + int i; + static int failed = FALSE; +# if defined(TRC_TO_KMEM) + unsigned long flags; +#endif + + if(failed) + return; +# if defined(TRC_TO_KMEM) + DGNC_LOCK(dgnc_tracef_lock, flags); +#endif + + /* Format buf using fmt and arguments contained in ap. */ + va_start(ap, fmt); + i = vsprintf(buf, fmt, ap); + va_end(ap); + lenbuf = strlen(buf); + +# if defined(TRC_TO_KMEM) + { + static int initd=0; + + /* + * Now, in addition to (or instead of) printing this stuff out + * (which is a buffered operation), also tuck it away into a + * corner of memory which can be examined post-crash in kdb. + */ + if (!initd) { + dgnc_trcbuf = (char *) vmalloc(dgnc_trcbuf_size); + if(!dgnc_trcbuf) { + failed = TRUE; + printk("dgnc: tracing init failed!\n"); + return; + } + + memset(dgnc_trcbuf, '\0', dgnc_trcbuf_size); + dgnc_trcbufi = 0; + initd++; + + printk("dgnc: tracing enabled - " TRC_DTRC + " 0x%lx 0x%x\n", + (unsigned long)dgnc_trcbuf, + dgnc_trcbuf_size); + } + +# if defined(TRC_ON_OVERFLOW_WRAP_AROUND) + /* + * This is the less CPU-intensive way to do things. We simply + * wrap around before we fall off the end of the buffer. A + * tilde (~) demarcates the current end of the trace. + * + * This method should be used if you are concerned about race + * conditions as it is less likely to affect the timing of + * things. + */ + + if (dgnc_trcbufi + lenbuf >= dgnc_trcbuf_size) { + /* We are wrapping, so wipe out the last tilde. */ + dgnc_trcbuf[dgnc_trcbufi] = '\0'; + /* put the new string at the beginning of the buffer */ + dgnc_trcbufi = 0; + } + + strcpy(&dgnc_trcbuf[dgnc_trcbufi], buf); + dgnc_trcbufi += lenbuf; + dgnc_trcbuf[dgnc_trcbufi] = '~'; + +# elif defined(TRC_ON_OVERFLOW_SHIFT_BUFFER) + /* + * This is the more CPU-intensive way to do things. If we + * venture into the last 1/8 of the buffer, we shift the + * last 7/8 of the buffer forward, wiping out the first 1/8. + * Advantage: No wrap-around, only truncation from the + * beginning. + * + * This method should not be used if you are concerned about + * timing changes affecting the behaviour of the driver (ie, + * race conditions). + */ + strcpy(&dgnc_trcbuf[dgnc_trcbufi], buf); + dgnc_trcbufi += lenbuf; + dgnc_trcbuf[dgnc_trcbufi] = '~'; + dgnc_trcbuf[dgnc_trcbufi+1] = '\0'; + + /* If we're near the end of the trace buffer... */ + if (dgnc_trcbufi > (dgnc_trcbuf_size/8)*7) { + /* Wipe out the first eighth to make some more room. */ + strcpy(dgnc_trcbuf, &dgnc_trcbuf[dgnc_trcbuf_size/8]); + dgnc_trcbufi = strlen(dgnc_trcbuf)-1; + /* Plop overflow message at the top of the buffer. */ + bcopy(TRC_OVERFLOW, dgnc_trcbuf, strlen(TRC_OVERFLOW)); + } +# else +# error "TRC_ON_OVERFLOW_WRAP_AROUND or TRC_ON_OVERFLOW_SHIFT_BUFFER?" +# endif + } + DGNC_UNLOCK(dgnc_tracef_lock, flags); + +# endif /* defined(TRC_TO_KMEM) */ +} + +#endif /* !defined(TRC_TO_KMEM) && !defined(TRC_TO_CONSOLE) */ + +#endif + + +/* + * dgnc_tracer_free() + * + * + */ +void dgnc_tracer_free(void) +{ + if(dgnc_trcbuf) + vfree(dgnc_trcbuf); +} diff --git a/drivers/staging/dgnc/dgnc_trace.h b/drivers/staging/dgnc/dgnc_trace.h new file mode 100644 index 0000000000000..1e8870bf8eeeb --- /dev/null +++ b/drivers/staging/dgnc/dgnc_trace.h @@ -0,0 +1,45 @@ +/* + * Copyright 2003 Digi International (www.digi.com) + * Scott H Kilau + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! + * + ***************************************************************************** + * Header file for dgnc_trace.c + * + * $Id: dgnc_trace.h,v 1.1.1.1 2009/05/20 12:19:19 markh Exp $ + */ + +#ifndef __DGNC_TRACE_H +#define __DGNC_TRACE_H + +#include "dgnc_driver.h" + +#if 0 + +# if !defined(TRC_TO_KMEM) && !defined(TRC_TO_CONSOLE) + void dgnc_tracef(const char *fmt, ...); +# else + void dgnc_tracef(const char *fmt, ...); +# endif + +#endif + +void dgnc_tracer_free(void); + +#endif + diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c new file mode 100644 index 0000000000000..461e88161808c --- /dev/null +++ b/drivers/staging/dgnc/dgnc_tty.c @@ -0,0 +1,3648 @@ +/* + * Copyright 2003 Digi International (www.digi.com) + * Scott H Kilau + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * + * NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE! + * + * This is shared code between Digi's CVS archive and the + * Linux Kernel sources. + * Changing the source just for reformatting needlessly breaks + * our CVS diff history. + * + * Send any bug fixes/changes to: Eng.Linux at digi dot com. + * Thank you. + */ + +/************************************************************************ + * + * This file implements the tty driver functionality for the + * Neo and ClassicBoard PCI based product lines. + * + ************************************************************************ + * + * $Id: dgnc_tty.c,v 1.5 2013/04/30 19:18:30 markh Exp $ + */ + +#include +#include +#include /* For jiffies, task states */ +#include /* For tasklet and interrupt structs/defines */ +#include +#include +#include +#include +#include +#include +#include /* For udelay */ +#include /* For copy_from_user/copy_to_user */ +#include + +#include "dgnc_driver.h" +#include "dgnc_tty.h" +#include "dgnc_types.h" +#include "dgnc_trace.h" +#include "dgnc_neo.h" +#include "dgnc_cls.h" +#include "dpacompat.h" +#include "dgnc_sysfs.h" + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37) +#define init_MUTEX(sem) sema_init(sem, 1) +#define DECLARE_MUTEX(name) \ + struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) +#endif + +/* + * internal variables + */ +static struct board_t *dgnc_BoardsByMajor[256]; +static uchar *dgnc_TmpWriteBuf = NULL; +static DECLARE_MUTEX(dgnc_TmpWriteSem); + +/* + * Default transparent print information. + */ +static struct digi_t dgnc_digi_init = { + .digi_flags = DIGI_COOK, /* Flags */ + .digi_maxcps = 100, /* Max CPS */ + .digi_maxchar = 50, /* Max chars in print queue */ + .digi_bufsize = 100, /* Printer buffer size */ + .digi_onlen = 4, /* size of printer on string */ + .digi_offlen = 4, /* size of printer off string */ + .digi_onstr = "\033[5i", /* ANSI printer on string ] */ + .digi_offstr = "\033[4i", /* ANSI printer off string ] */ + .digi_term = "ansi" /* default terminal type */ +}; + + +/* + * Define a local default termios struct. All ports will be created + * with this termios initially. + * + * This defines a raw port at 9600 baud, 8 data bits, no parity, + * 1 stop bit. + */ +static struct ktermios DgncDefaultTermios = +{ + .c_iflag = (DEFAULT_IFLAGS), /* iflags */ + .c_oflag = (DEFAULT_OFLAGS), /* oflags */ + .c_cflag = (DEFAULT_CFLAGS), /* cflags */ + .c_lflag = (DEFAULT_LFLAGS), /* lflags */ + .c_cc = INIT_C_CC, + .c_line = 0, +}; + + +/* Our function prototypes */ +static int dgnc_tty_open(struct tty_struct *tty, struct file *file); +static void dgnc_tty_close(struct tty_struct *tty, struct file *file); +static int dgnc_block_til_ready(struct tty_struct *tty, struct file *file, struct channel_t *ch); +static int dgnc_tty_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg); +static int dgnc_tty_digigeta(struct tty_struct *tty, struct digi_t __user *retinfo); +static int dgnc_tty_digiseta(struct tty_struct *tty, struct digi_t __user *new_info); +static int dgnc_tty_write_room(struct tty_struct* tty); +static int dgnc_tty_put_char(struct tty_struct *tty, unsigned char c); +static int dgnc_tty_chars_in_buffer(struct tty_struct* tty); +static void dgnc_tty_start(struct tty_struct *tty); +static void dgnc_tty_stop(struct tty_struct *tty); +static void dgnc_tty_throttle(struct tty_struct *tty); +static void dgnc_tty_unthrottle(struct tty_struct *tty); +static void dgnc_tty_flush_chars(struct tty_struct *tty); +static void dgnc_tty_flush_buffer(struct tty_struct *tty); +static void dgnc_tty_hangup(struct tty_struct *tty); +static int dgnc_set_modem_info(struct tty_struct *tty, unsigned int command, unsigned int __user *value); +static int dgnc_get_modem_info(struct channel_t *ch, unsigned int __user *value); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39) +static int dgnc_tty_tiocmget(struct tty_struct *tty); +static int dgnc_tty_tiocmset(struct tty_struct *tty, unsigned int set, unsigned int clear); +#else +static int dgnc_tty_tiocmget(struct tty_struct *tty, struct file *file); +static int dgnc_tty_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear); +#endif +static int dgnc_tty_send_break(struct tty_struct *tty, int msec); +static void dgnc_tty_wait_until_sent(struct tty_struct *tty, int timeout); +static int dgnc_tty_write(struct tty_struct *tty, const unsigned char *buf, int count); +static void dgnc_tty_set_termios(struct tty_struct *tty, struct ktermios *old_termios); +static void dgnc_tty_send_xchar(struct tty_struct *tty, char ch); + + +static const struct tty_operations dgnc_tty_ops = { + .open = dgnc_tty_open, + .close = dgnc_tty_close, + .write = dgnc_tty_write, + .write_room = dgnc_tty_write_room, + .flush_buffer = dgnc_tty_flush_buffer, + .chars_in_buffer = dgnc_tty_chars_in_buffer, + .flush_chars = dgnc_tty_flush_chars, + .ioctl = dgnc_tty_ioctl, + .set_termios = dgnc_tty_set_termios, + .stop = dgnc_tty_stop, + .start = dgnc_tty_start, + .throttle = dgnc_tty_throttle, + .unthrottle = dgnc_tty_unthrottle, + .hangup = dgnc_tty_hangup, + .put_char = dgnc_tty_put_char, + .tiocmget = dgnc_tty_tiocmget, + .tiocmset = dgnc_tty_tiocmset, + .break_ctl = dgnc_tty_send_break, + .wait_until_sent = dgnc_tty_wait_until_sent, + .send_xchar = dgnc_tty_send_xchar +}; + +/************************************************************************ + * + * TTY Initialization/Cleanup Functions + * + ************************************************************************/ + +/* + * dgnc_tty_preinit() + * + * Initialize any global tty related data before we download any boards. + */ +int dgnc_tty_preinit(void) +{ + /* + * Allocate a buffer for doing the copy from user space to + * kernel space in dgnc_write(). We only use one buffer and + * control access to it with a semaphore. If we are paging, we + * are already in trouble so one buffer won't hurt much anyway. + * + * We are okay to sleep in the malloc, as this routine + * is only called during module load, (not in interrupt context), + * and with no locks held. + */ + dgnc_TmpWriteBuf = kmalloc(WRITEBUFLEN, GFP_KERNEL); + + if (!dgnc_TmpWriteBuf) { + DPR_INIT(("unable to allocate tmp write buf")); + return (-ENOMEM); + } + + return(0); +} + + +/* + * dgnc_tty_register() + * + * Init the tty subsystem for this board. + */ +int dgnc_tty_register(struct board_t *brd) +{ + int rc = 0; + + DPR_INIT(("tty_register start\n")); + + memset(&brd->SerialDriver, 0, sizeof(struct tty_driver)); + memset(&brd->PrintDriver, 0, sizeof(struct tty_driver)); + + brd->SerialDriver.magic = TTY_DRIVER_MAGIC; + + snprintf(brd->SerialName, MAXTTYNAMELEN, "tty_dgnc_%d_", brd->boardnum); + + brd->SerialDriver.name = brd->SerialName; + brd->SerialDriver.name_base = 0; + brd->SerialDriver.major = 0; + brd->SerialDriver.minor_start = 0; + brd->SerialDriver.num = brd->maxports; + brd->SerialDriver.type = TTY_DRIVER_TYPE_SERIAL; + brd->SerialDriver.subtype = SERIAL_TYPE_NORMAL; + brd->SerialDriver.init_termios = DgncDefaultTermios; + brd->SerialDriver.driver_name = DRVSTR; + brd->SerialDriver.flags = (TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_HARDWARE_BREAK); + + /* + * The kernel wants space to store pointers to + * tty_struct's and termios's. + */ + brd->SerialDriver.ttys = dgnc_driver_kzmalloc(brd->maxports * sizeof(struct tty_struct *), GFP_KERNEL); + if (!brd->SerialDriver.ttys) + return(-ENOMEM); + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28) + brd->SerialDriver.refcount = brd->TtyRefCnt; +#else + kref_init(&brd->SerialDriver.kref); +#endif + + brd->SerialDriver.termios = dgnc_driver_kzmalloc(brd->maxports * sizeof(struct ktermios *), GFP_KERNEL); + if (!brd->SerialDriver.termios) + return(-ENOMEM); + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0) + brd->SerialDriver.termios_locked = dgnc_driver_kzmalloc(brd->maxports * sizeof(struct ktermios *), GFP_KERNEL); + if (!brd->SerialDriver.termios_locked) + return(-ENOMEM); +#endif + /* + * Entry points for driver. Called by the kernel from + * tty_io.c and n_tty.c. + */ + tty_set_operations(&brd->SerialDriver, &dgnc_tty_ops); + + if (!brd->dgnc_Major_Serial_Registered) { + /* Register tty devices */ + rc = tty_register_driver(&brd->SerialDriver); + if (rc < 0) { + APR(("Can't register tty device (%d)\n", rc)); + return(rc); + } + brd->dgnc_Major_Serial_Registered = TRUE; + } + + /* + * If we're doing transparent print, we have to do all of the above + * again, seperately so we don't get the LD confused about what major + * we are when we get into the dgnc_tty_open() routine. + */ + brd->PrintDriver.magic = TTY_DRIVER_MAGIC; + snprintf(brd->PrintName, MAXTTYNAMELEN, "pr_dgnc_%d_", brd->boardnum); + + brd->PrintDriver.name = brd->PrintName; + brd->PrintDriver.name_base = 0; + brd->PrintDriver.major = brd->SerialDriver.major; + brd->PrintDriver.minor_start = 0x80; + brd->PrintDriver.num = brd->maxports; + brd->PrintDriver.type = TTY_DRIVER_TYPE_SERIAL; + brd->PrintDriver.subtype = SERIAL_TYPE_NORMAL; + brd->PrintDriver.init_termios = DgncDefaultTermios; + brd->PrintDriver.driver_name = DRVSTR; + brd->PrintDriver.flags = (TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_HARDWARE_BREAK); + + /* + * The kernel wants space to store pointers to + * tty_struct's and termios's. Must be seperate from + * the Serial Driver so we don't get confused + */ + brd->PrintDriver.ttys = dgnc_driver_kzmalloc(brd->maxports * sizeof(struct tty_struct *), GFP_KERNEL); + if (!brd->PrintDriver.ttys) + return(-ENOMEM); + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28) + brd->PrintDriver.refcount = brd->TtyRefCnt; +#else + kref_init(&brd->PrintDriver.kref); +#endif + + brd->PrintDriver.termios = dgnc_driver_kzmalloc(brd->maxports * sizeof(struct ktermios *), GFP_KERNEL); + if (!brd->PrintDriver.termios) + return(-ENOMEM); + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0) + brd->PrintDriver.termios_locked = dgnc_driver_kzmalloc(brd->maxports * sizeof(struct ktermios *), GFP_KERNEL); + if (!brd->PrintDriver.termios_locked) + return(-ENOMEM); +#endif + + /* + * Entry points for driver. Called by the kernel from + * tty_io.c and n_tty.c. + */ + tty_set_operations(&brd->PrintDriver, &dgnc_tty_ops); + + if (!brd->dgnc_Major_TransparentPrint_Registered) { + /* Register Transparent Print devices */ + rc = tty_register_driver(&brd->PrintDriver); + if (rc < 0) { + APR(("Can't register Transparent Print device (%d)\n", rc)); + return(rc); + } + brd->dgnc_Major_TransparentPrint_Registered = TRUE; + } + + dgnc_BoardsByMajor[brd->SerialDriver.major] = brd; + brd->dgnc_Serial_Major = brd->SerialDriver.major; + brd->dgnc_TransparentPrint_Major = brd->PrintDriver.major; + + DPR_INIT(("DGNC REGISTER TTY: MAJOR: %d\n", brd->SerialDriver.major)); + + return (rc); +} + + +/* + * dgnc_tty_init() + * + * Init the tty subsystem. Called once per board after board has been + * downloaded and init'ed. + */ +int dgnc_tty_init(struct board_t *brd) +{ + int i; + uchar *vaddr; + struct channel_t *ch; + + if (!brd) + return (-ENXIO); + + DPR_INIT(("dgnc_tty_init start\n")); + + /* + * Initialize board structure elements. + */ + + vaddr = brd->re_map_membase; + + brd->nasync = brd->maxports; + + /* + * Allocate channel memory that might not have been allocated + * when the driver was first loaded. + */ + for (i = 0; i < brd->nasync; i++) { + if (!brd->channels[i]) { + + /* + * Okay to malloc with GFP_KERNEL, we are not at + * interrupt context, and there are no locks held. + */ + brd->channels[i] = dgnc_driver_kzmalloc(sizeof(struct channel_t), GFP_KERNEL); + if (!brd->channels[i]) { + DPR_CORE(("%s:%d Unable to allocate memory for channel struct\n", + __FILE__, __LINE__)); + } + } + } + + ch = brd->channels[0]; + vaddr = brd->re_map_membase; + + /* Set up channel variables */ + for (i = 0; i < brd->nasync; i++, ch = brd->channels[i]) { + + if (!brd->channels[i]) + continue; + + DGNC_SPINLOCK_INIT(ch->ch_lock); + + /* Store all our magic numbers */ + ch->magic = DGNC_CHANNEL_MAGIC; + ch->ch_tun.magic = DGNC_UNIT_MAGIC; + ch->ch_tun.un_ch = ch; + ch->ch_tun.un_type = DGNC_SERIAL; + ch->ch_tun.un_dev = i; + + ch->ch_pun.magic = DGNC_UNIT_MAGIC; + ch->ch_pun.un_ch = ch; + ch->ch_pun.un_type = DGNC_PRINT; + ch->ch_pun.un_dev = i + 128; + + if (brd->bd_uart_offset == 0x200) + ch->ch_neo_uart = (struct neo_uart_struct *) ((ulong) vaddr + (brd->bd_uart_offset * i)); + else + ch->ch_cls_uart = (struct cls_uart_struct *) ((ulong) vaddr + (brd->bd_uart_offset * i)); + + ch->ch_bd = brd; + ch->ch_portnum = i; + ch->ch_digi = dgnc_digi_init; + + /* .25 second delay */ + ch->ch_close_delay = 250; + + init_waitqueue_head(&ch->ch_flags_wait); + init_waitqueue_head(&ch->ch_tun.un_flags_wait); + init_waitqueue_head(&ch->ch_pun.un_flags_wait); + init_waitqueue_head(&ch->ch_sniff_wait); + + { + struct device *classp; + classp = tty_register_device(&brd->SerialDriver, i, + &(ch->ch_bd->pdev->dev)); + ch->ch_tun.un_sysfs = classp; + dgnc_create_tty_sysfs(&ch->ch_tun, classp); + + classp = tty_register_device(&brd->PrintDriver, i, + &(ch->ch_bd->pdev->dev)); + ch->ch_pun.un_sysfs = classp; + dgnc_create_tty_sysfs(&ch->ch_pun, classp); + } + + } + + DPR_INIT(("dgnc_tty_init finish\n")); + + return (0); +} + + +/* + * dgnc_tty_post_uninit() + * + * UnInitialize any global tty related data. + */ +void dgnc_tty_post_uninit(void) +{ + if (dgnc_TmpWriteBuf) { + kfree(dgnc_TmpWriteBuf); + dgnc_TmpWriteBuf = NULL; + } +} + + +/* + * dgnc_tty_uninit() + * + * Uninitialize the TTY portion of this driver. Free all memory and + * resources. + */ +void dgnc_tty_uninit(struct board_t *brd) +{ + int i = 0; + + if (brd->dgnc_Major_Serial_Registered) { + dgnc_BoardsByMajor[brd->SerialDriver.major] = NULL; + brd->dgnc_Serial_Major = 0; + for (i = 0; i < brd->nasync; i++) { + dgnc_remove_tty_sysfs(brd->channels[i]->ch_tun.un_sysfs); + tty_unregister_device(&brd->SerialDriver, i); + } + tty_unregister_driver(&brd->SerialDriver); + brd->dgnc_Major_Serial_Registered = FALSE; + } + + if (brd->dgnc_Major_TransparentPrint_Registered) { + dgnc_BoardsByMajor[brd->PrintDriver.major] = NULL; + brd->dgnc_TransparentPrint_Major = 0; + for (i = 0; i < brd->nasync; i++) { + dgnc_remove_tty_sysfs(brd->channels[i]->ch_pun.un_sysfs); + tty_unregister_device(&brd->PrintDriver, i); + } + tty_unregister_driver(&brd->PrintDriver); + brd->dgnc_Major_TransparentPrint_Registered = FALSE; + } + + if (brd->SerialDriver.ttys) { + kfree(brd->SerialDriver.ttys); + brd->SerialDriver.ttys = NULL; + } + if (brd->PrintDriver.ttys) { + kfree(brd->PrintDriver.ttys); + brd->PrintDriver.ttys = NULL; + } +} + + +#define TMPBUFLEN (1024) + +/* + * dgnc_sniff - Dump data out to the "sniff" buffer if the + * proc sniff file is opened... + */ +void dgnc_sniff_nowait_nolock(struct channel_t *ch, uchar *text, uchar *buf, int len) +{ + struct timeval tv; + int n; + int r; + int nbuf; + int i; + int tmpbuflen; + char tmpbuf[TMPBUFLEN]; + char *p = tmpbuf; + int too_much_data; + + /* Leave if sniff not open */ + if (!(ch->ch_sniff_flags & SNIFF_OPEN)) + return; + + do_gettimeofday(&tv); + + /* Create our header for data dump */ + p += sprintf(p, "<%ld %ld><%s><", tv.tv_sec, tv.tv_usec, text); + tmpbuflen = p - tmpbuf; + + do { + too_much_data = 0; + + for (i = 0; i < len && tmpbuflen < (TMPBUFLEN - 4); i++) { + p += sprintf(p, "%02x ", *buf); + buf++; + tmpbuflen = p - tmpbuf; + } + + if (tmpbuflen < (TMPBUFLEN - 4)) { + if (i > 0) + p += sprintf(p - 1, "%s\n", ">"); + else + p += sprintf(p, "%s\n", ">"); + } else { + too_much_data = 1; + len -= i; + } + + nbuf = strlen(tmpbuf); + p = tmpbuf; + + /* + * Loop while data remains. + */ + while (nbuf > 0 && ch->ch_sniff_buf != 0) { + /* + * Determine the amount of available space left in the + * buffer. If there's none, wait until some appears. + */ + n = (ch->ch_sniff_out - ch->ch_sniff_in - 1) & SNIFF_MASK; + + /* + * If there is no space left to write to in our sniff buffer, + * we have no choice but to drop the data. + * We *cannot* sleep here waiting for space, because this + * function was probably called by the interrupt/timer routines! + */ + if (n == 0) { + return; + } + + /* + * Copy as much data as will fit. + */ + + if (n > nbuf) + n = nbuf; + + r = SNIFF_MAX - ch->ch_sniff_in; + + if (r <= n) { + memcpy(ch->ch_sniff_buf + ch->ch_sniff_in, p, r); + + n -= r; + ch->ch_sniff_in = 0; + p += r; + nbuf -= r; + } + + memcpy(ch->ch_sniff_buf + ch->ch_sniff_in, p, n); + + ch->ch_sniff_in += n; + p += n; + nbuf -= n; + + /* + * Wakeup any thread waiting for data + */ + if (ch->ch_sniff_flags & SNIFF_WAIT_DATA) { + ch->ch_sniff_flags &= ~SNIFF_WAIT_DATA; + wake_up_interruptible(&ch->ch_sniff_wait); + } + } + + /* + * If the user sent us too much data to push into our tmpbuf, + * we need to keep looping around on all the data. + */ + if (too_much_data) { + p = tmpbuf; + tmpbuflen = 0; + } + + } while (too_much_data); +} + + +/*======================================================================= + * + * dgnc_wmove - Write data to transmit queue. + * + * ch - Pointer to channel structure. + * buf - Poiter to characters to be moved. + * n - Number of characters to move. + * + *=======================================================================*/ +static void dgnc_wmove(struct channel_t *ch, char *buf, uint n) +{ + int remain; + uint head; + + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return; + + head = ch->ch_w_head & WQUEUEMASK; + + /* + * If the write wraps over the top of the circular buffer, + * move the portion up to the wrap point, and reset the + * pointers to the bottom. + */ + remain = WQUEUESIZE - head; + + if (n >= remain) { + n -= remain; + memcpy(ch->ch_wqueue + head, buf, remain); + head = 0; + buf += remain; + } + + if (n > 0) { + /* + * Move rest of data. + */ + remain = n; + memcpy(ch->ch_wqueue + head, buf, remain); + head += remain; + } + + head &= WQUEUEMASK; + ch->ch_w_head = head; +} + + + + +/*======================================================================= + * + * dgnc_input - Process received data. + * + * ch - Pointer to channel structure. + * + *=======================================================================*/ +void dgnc_input(struct channel_t *ch) +{ + struct board_t *bd; + struct tty_struct *tp; + struct tty_ldisc *ld; + uint rmask; + ushort head; + ushort tail; + int data_len; + ulong lock_flags; + int flip_len; + int len = 0; + int n = 0; + char *buf = NULL; + int s = 0; + int i = 0; + + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return; + + tp = ch->ch_tun.un_tty; + + bd = ch->ch_bd; + if(!bd || bd->magic != DGNC_BOARD_MAGIC) + return; + + DGNC_LOCK(ch->ch_lock, lock_flags); + + /* + * Figure the number of characters in the buffer. + * Exit immediately if none. + */ + rmask = RQUEUEMASK; + head = ch->ch_r_head & rmask; + tail = ch->ch_r_tail & rmask; + data_len = (head - tail) & rmask; + + if (data_len == 0) { + DGNC_UNLOCK(ch->ch_lock, lock_flags); + return; + } + + DPR_READ(("dgnc_input start\n")); + + /* + * If the device is not open, or CREAD is off, + * flush input data and return immediately. + */ + if (!tp || (tp->magic != TTY_MAGIC) || !(ch->ch_tun.un_flags & UN_ISOPEN) || + !(tp->termios->c_cflag & CREAD) || (ch->ch_tun.un_flags & UN_CLOSING)) { + + DPR_READ(("input. dropping %d bytes on port %d...\n", data_len, ch->ch_portnum)); + DPR_READ(("input. tp: %p tp->magic: %x MAGIC:%x ch flags: %x\n", + tp, tp ? tp->magic : 0, TTY_MAGIC, ch->ch_tun.un_flags)); + + ch->ch_r_head = tail; + + /* Force queue flow control to be released, if needed */ + dgnc_check_queue_flow_control(ch); + + DGNC_UNLOCK(ch->ch_lock, lock_flags); + return; + } + + /* + * If we are throttled, simply don't read any data. + */ + if (ch->ch_flags & CH_FORCED_STOPI) { + DGNC_UNLOCK(ch->ch_lock, lock_flags); + DPR_READ(("Port %d throttled, not reading any data. head: %x tail: %x\n", + ch->ch_portnum, head, tail)); + return; + } + + DPR_READ(("dgnc_input start 2\n")); + + /* Decide how much data we can send into the tty layer */ + if (dgnc_rawreadok && tp->real_raw) + flip_len = MYFLIPLEN; + else + flip_len = TTY_FLIPBUF_SIZE; + + /* Chop down the length, if needed */ + len = min(data_len, flip_len); + len = min(len, (N_TTY_BUF_SIZE - 1) - tp->read_cnt); + + ld = tty_ldisc_ref(tp); + +#ifdef TTY_DONT_FLIP + /* + * If the DONT_FLIP flag is on, don't flush our buffer, and act + * like the ld doesn't have any space to put the data right now. + */ + if (test_bit(TTY_DONT_FLIP, &tp->flags)) + len = 0; +#endif + + /* + * If we were unable to get a reference to the ld, + * don't flush our buffer, and act like the ld doesn't + * have any space to put the data right now. + */ + if (!ld) { + len = 0; + } else { + /* + * If ld doesn't have a pointer to a receive_buf function, + * flush the data, then act like the ld doesn't have any + * space to put the data right now. + */ + if (!ld->ops->receive_buf) { + ch->ch_r_head = ch->ch_r_tail; + len = 0; + } + } + + if (len <= 0) { + DGNC_UNLOCK(ch->ch_lock, lock_flags); + if (ld) + tty_ldisc_deref(ld); + return; + } + + /* + * The tty layer in the kernel has changed in 2.6.16+. + * + * The flip buffers in the tty structure are no longer exposed, + * and probably will be going away eventually. + * + * If we are completely raw, we don't need to go through a lot + * of the tty layers that exist. + * In this case, we take the shortest and fastest route we + * can to relay the data to the user. + * + * On the other hand, if we are not raw, we need to go through + * the new 2.6.16+ tty layer, which has its API more well defined. + */ + if (dgnc_rawreadok && tp->real_raw) { + + if (ch->ch_flags & CH_FLIPBUF_IN_USE) { + DPR_READ(("DGNC - FLIPBUF in use. delaying input\n")); + DGNC_UNLOCK(ch->ch_lock, lock_flags); + if (ld) + tty_ldisc_deref(ld); + return; + } + + ch->ch_flags |= CH_FLIPBUF_IN_USE; + buf = ch->ch_bd->flipbuf; + + n = len; + + /* + * n now contains the most amount of data we can copy, + * bounded either by the flip buffer size or the amount + * of data the card actually has pending... + */ + while (n) { + s = ((head >= tail) ? head : RQUEUESIZE) - tail; + s = min(s, n); + + if (s <= 0) + break; + + memcpy(buf, ch->ch_rqueue + tail, s); + dgnc_sniff_nowait_nolock(ch, "USER READ", ch->ch_rqueue + tail, s); + + tail += s; + buf += s; + + n -= s; + /* Flip queue if needed */ + tail &= rmask; + } + + ch->ch_r_tail = tail & rmask; + ch->ch_e_tail = tail & rmask; + + dgnc_check_queue_flow_control(ch); + + /* !!! WE *MUST* LET GO OF ALL LOCKS BEFORE CALLING RECEIVE BUF !!! */ + + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + DPR_READ(("dgnc_input. %d real_raw len:%d calling receive_buf for buffer for board %d\n", + __LINE__, len, ch->ch_bd->boardnum)); + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30) + tp->ldisc->ops->receive_buf(tp, ch->ch_bd->flipbuf, NULL, len); +#else + tp->ldisc.ops->receive_buf(tp, ch->ch_bd->flipbuf, NULL, len); +#endif + + /* Allow use of channel flip buffer again */ + DGNC_LOCK(ch->ch_lock, lock_flags); + ch->ch_flags &= ~CH_FLIPBUF_IN_USE; + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + } + else { + len = tty_buffer_request_room(tp, len); + n = len; + + /* + * n now contains the most amount of data we can copy, + * bounded either by how much the Linux tty layer can handle, + * or the amount of data the card actually has pending... + */ + while (n) { + s = ((head >= tail) ? head : RQUEUESIZE) - tail; + s = min(s, n); + + if (s <= 0) + break; + + /* + * If conditions are such that ld needs to see all + * UART errors, we will have to walk each character + * and error byte and send them to the buffer one at + * a time. + */ + if (I_PARMRK(tp) || I_BRKINT(tp) || I_INPCK(tp)) { + for (i = 0; i < s; i++) { + if (*(ch->ch_equeue + tail + i) & UART_LSR_BI) + tty_insert_flip_char(tp, *(ch->ch_rqueue + tail + i), TTY_BREAK); + else if (*(ch->ch_equeue + tail + i) & UART_LSR_PE) + tty_insert_flip_char(tp, *(ch->ch_rqueue + tail + i), TTY_PARITY); + else if (*(ch->ch_equeue + tail + i) & UART_LSR_FE) + tty_insert_flip_char(tp, *(ch->ch_rqueue + tail + i), TTY_FRAME); + else + tty_insert_flip_char(tp, *(ch->ch_rqueue + tail + i), TTY_NORMAL); + } + } + else { + tty_insert_flip_string(tp, ch->ch_rqueue + tail, s); + } + + dgnc_sniff_nowait_nolock(ch, "USER READ", ch->ch_rqueue + tail, s); + + tail += s; + n -= s; + /* Flip queue if needed */ + tail &= rmask; + } + + ch->ch_r_tail = tail & rmask; + ch->ch_e_tail = tail & rmask; + dgnc_check_queue_flow_control(ch); + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + /* Tell the tty layer its okay to "eat" the data now */ + tty_flip_buffer_push(tp); + } + + if (ld) + tty_ldisc_deref(ld); + + DPR_READ(("dgnc_input - finish\n")); +} + + +/************************************************************************ + * Determines when CARRIER changes state and takes appropriate + * action. + ************************************************************************/ +void dgnc_carrier(struct channel_t *ch) +{ + struct board_t *bd; + + int virt_carrier = 0; + int phys_carrier = 0; + + DPR_CARR(("dgnc_carrier called...\n")); + + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return; + + bd = ch->ch_bd; + + if (!bd || bd->magic != DGNC_BOARD_MAGIC) + return; + + if (ch->ch_mistat & UART_MSR_DCD) { + DPR_CARR(("mistat: %x D_CD: %x\n", ch->ch_mistat, ch->ch_mistat & UART_MSR_DCD)); + phys_carrier = 1; + } + + if (ch->ch_digi.digi_flags & DIGI_FORCEDCD) { + virt_carrier = 1; + } + + if (ch->ch_c_cflag & CLOCAL) { + virt_carrier = 1; + } + + + DPR_CARR(("DCD: physical: %d virt: %d\n", phys_carrier, virt_carrier)); + + /* + * Test for a VIRTUAL carrier transition to HIGH. + */ + if (((ch->ch_flags & CH_FCAR) == 0) && (virt_carrier == 1)) { + + /* + * When carrier rises, wake any threads waiting + * for carrier in the open routine. + */ + + DPR_CARR(("carrier: virt DCD rose\n")); + + if (waitqueue_active(&(ch->ch_flags_wait))) + wake_up_interruptible(&ch->ch_flags_wait); + } + + /* + * Test for a PHYSICAL carrier transition to HIGH. + */ + if (((ch->ch_flags & CH_CD) == 0) && (phys_carrier == 1)) { + + /* + * When carrier rises, wake any threads waiting + * for carrier in the open routine. + */ + + DPR_CARR(("carrier: physical DCD rose\n")); + + if (waitqueue_active(&(ch->ch_flags_wait))) + wake_up_interruptible(&ch->ch_flags_wait); + } + + /* + * Test for a PHYSICAL transition to low, so long as we aren't + * currently ignoring physical transitions (which is what "virtual + * carrier" indicates). + * + * The transition of the virtual carrier to low really doesn't + * matter... it really only means "ignore carrier state", not + * "make pretend that carrier is there". + */ + if ((virt_carrier == 0) && ((ch->ch_flags & CH_CD) != 0) && + (phys_carrier == 0)) + { + + /* + * When carrier drops: + * + * Drop carrier on all open units. + * + * Flush queues, waking up any task waiting in the + * line discipline. + * + * Send a hangup to the control terminal. + * + * Enable all select calls. + */ + if (waitqueue_active(&(ch->ch_flags_wait))) + wake_up_interruptible(&ch->ch_flags_wait); + + if (ch->ch_tun.un_open_count > 0) { + DPR_CARR(("Sending tty hangup\n")); + tty_hangup(ch->ch_tun.un_tty); + } + + if (ch->ch_pun.un_open_count > 0) { + DPR_CARR(("Sending pr hangup\n")); + tty_hangup(ch->ch_pun.un_tty); + } + } + + /* + * Make sure that our cached values reflect the current reality. + */ + if (virt_carrier == 1) + ch->ch_flags |= CH_FCAR; + else + ch->ch_flags &= ~CH_FCAR; + + if (phys_carrier == 1) + ch->ch_flags |= CH_CD; + else + ch->ch_flags &= ~CH_CD; +} + +/* + * Assign the custom baud rate to the channel structure + */ +static void dgnc_set_custom_speed(struct channel_t *ch, uint newrate) +{ + int testdiv; + int testrate_high; + int testrate_low; + int deltahigh; + int deltalow; + + if (newrate < 0) + newrate = 0; + + /* + * Since the divisor is stored in a 16-bit integer, we make sure + * we don't allow any rates smaller than a 16-bit integer would allow. + * And of course, rates above the dividend won't fly. + */ + if (newrate && newrate < ((ch->ch_bd->bd_dividend / 0xFFFF) + 1)) + newrate = ((ch->ch_bd->bd_dividend / 0xFFFF) + 1); + + if (newrate && newrate > ch->ch_bd->bd_dividend) + newrate = ch->ch_bd->bd_dividend; + + while (newrate > 0) { + testdiv = ch->ch_bd->bd_dividend / newrate; + + /* + * If we try to figure out what rate the board would use + * with the test divisor, it will be either equal or higher + * than the requested baud rate. If we then determine the + * rate with a divisor one higher, we will get the next lower + * supported rate below the requested. + */ + testrate_high = ch->ch_bd->bd_dividend / testdiv; + testrate_low = ch->ch_bd->bd_dividend / (testdiv + 1); + + /* + * If the rate for the requested divisor is correct, just + * use it and be done. + */ + if (testrate_high == newrate ) + break; + + /* + * Otherwise, pick the rate that is closer (i.e. whichever rate + * has a smaller delta). + */ + deltahigh = testrate_high - newrate; + deltalow = newrate - testrate_low; + + if (deltahigh < deltalow) { + newrate = testrate_high; + } else { + newrate = testrate_low; + } + + break; + } + + ch->ch_custom_speed = newrate; + + return; +} + + +void dgnc_check_queue_flow_control(struct channel_t *ch) +{ + int qleft = 0; + + /* Store how much space we have left in the queue */ + if ((qleft = ch->ch_r_tail - ch->ch_r_head - 1) < 0) + qleft += RQUEUEMASK + 1; + + /* + * Check to see if we should enforce flow control on our queue because + * the ld (or user) isn't reading data out of our queue fast enuf. + * + * NOTE: This is done based on what the current flow control of the + * port is set for. + * + * 1) HWFLOW (RTS) - Turn off the UART's Receive interrupt. + * This will cause the UART's FIFO to back up, and force + * the RTS signal to be dropped. + * 2) SWFLOW (IXOFF) - Keep trying to send a stop character to + * the other side, in hopes it will stop sending data to us. + * 3) NONE - Nothing we can do. We will simply drop any extra data + * that gets sent into us when the queue fills up. + */ + if (qleft < 256) { + /* HWFLOW */ + if (ch->ch_digi.digi_flags & CTSPACE || ch->ch_c_cflag & CRTSCTS) { + if(!(ch->ch_flags & CH_RECEIVER_OFF)) { + ch->ch_bd->bd_ops->disable_receiver(ch); + ch->ch_flags |= (CH_RECEIVER_OFF); + DPR_READ(("Internal queue hit hilevel mark (%d)! Turning off interrupts.\n", + qleft)); + } + } + /* SWFLOW */ + else if (ch->ch_c_iflag & IXOFF) { + if (ch->ch_stops_sent <= MAX_STOPS_SENT) { + ch->ch_bd->bd_ops->send_stop_character(ch); + ch->ch_stops_sent++; + DPR_READ(("Sending stop char! Times sent: %x\n", ch->ch_stops_sent)); + } + } + /* No FLOW */ + else { + /* Empty... Can't do anything about the impending overflow... */ + } + } + + /* + * Check to see if we should unenforce flow control because + * ld (or user) finally read enuf data out of our queue. + * + * NOTE: This is done based on what the current flow control of the + * port is set for. + * + * 1) HWFLOW (RTS) - Turn back on the UART's Receive interrupt. + * This will cause the UART's FIFO to raise RTS back up, + * which will allow the other side to start sending data again. + * 2) SWFLOW (IXOFF) - Send a start character to + * the other side, so it will start sending data to us again. + * 3) NONE - Do nothing. Since we didn't do anything to turn off the + * other side, we don't need to do anything now. + */ + if (qleft > (RQUEUESIZE / 2)) { + /* HWFLOW */ + if (ch->ch_digi.digi_flags & RTSPACE || ch->ch_c_cflag & CRTSCTS) { + if (ch->ch_flags & CH_RECEIVER_OFF) { + ch->ch_bd->bd_ops->enable_receiver(ch); + ch->ch_flags &= ~(CH_RECEIVER_OFF); + DPR_READ(("Internal queue hit lowlevel mark (%d)! Turning on interrupts.\n", + qleft)); + } + } + /* SWFLOW */ + else if (ch->ch_c_iflag & IXOFF && ch->ch_stops_sent) { + ch->ch_stops_sent = 0; + ch->ch_bd->bd_ops->send_start_character(ch); + DPR_READ(("Sending start char!\n")); + } + /* No FLOW */ + else { + /* Nothing needed. */ + } + } +} + + +void dgnc_wakeup_writes(struct channel_t *ch) +{ + int qlen = 0; + ulong lock_flags; + + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return; + + DGNC_LOCK(ch->ch_lock, lock_flags); + + /* + * If channel now has space, wake up anyone waiting on the condition. + */ + if ((qlen = ch->ch_w_head - ch->ch_w_tail) < 0) + qlen += WQUEUESIZE; + + if (qlen >= (WQUEUESIZE - 256)) { + DGNC_UNLOCK(ch->ch_lock, lock_flags); + return; + } + + if (ch->ch_tun.un_flags & UN_ISOPEN) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30) + if ((ch->ch_tun.un_tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && + ch->ch_tun.un_tty->ldisc->ops->write_wakeup) + { + DGNC_UNLOCK(ch->ch_lock, lock_flags); + (ch->ch_tun.un_tty->ldisc->ops->write_wakeup)(ch->ch_tun.un_tty); + DGNC_LOCK(ch->ch_lock, lock_flags); + } +#else + if ((ch->ch_tun.un_tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && + ch->ch_tun.un_tty->ldisc.ops->write_wakeup) + { + DGNC_UNLOCK(ch->ch_lock, lock_flags); + (ch->ch_tun.un_tty->ldisc.ops->write_wakeup)(ch->ch_tun.un_tty); + DGNC_LOCK(ch->ch_lock, lock_flags); + } +#endif + + wake_up_interruptible(&ch->ch_tun.un_tty->write_wait); + + /* + * If unit is set to wait until empty, check to make sure + * the queue AND FIFO are both empty. + */ + if (ch->ch_tun.un_flags & UN_EMPTY) { + if ((qlen == 0) && (ch->ch_bd->bd_ops->get_uart_bytes_left(ch) == 0)) { + ch->ch_tun.un_flags &= ~(UN_EMPTY); + + /* + * If RTS Toggle mode is on, whenever + * the queue and UART is empty, keep RTS low. + */ + if (ch->ch_digi.digi_flags & DIGI_RTS_TOGGLE) { + ch->ch_mostat &= ~(UART_MCR_RTS); + ch->ch_bd->bd_ops->assert_modem_signals(ch); + } + + /* + * If DTR Toggle mode is on, whenever + * the queue and UART is empty, keep DTR low. + */ + if (ch->ch_digi.digi_flags & DIGI_DTR_TOGGLE) { + ch->ch_mostat &= ~(UART_MCR_DTR); + ch->ch_bd->bd_ops->assert_modem_signals(ch); + } + } + } + + wake_up_interruptible(&ch->ch_tun.un_flags_wait); + } + + if (ch->ch_pun.un_flags & UN_ISOPEN) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30) + if ((ch->ch_pun.un_tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && + ch->ch_pun.un_tty->ldisc->ops->write_wakeup) + { + DGNC_UNLOCK(ch->ch_lock, lock_flags); + (ch->ch_pun.un_tty->ldisc->ops->write_wakeup)(ch->ch_pun.un_tty); + DGNC_LOCK(ch->ch_lock, lock_flags); + } +#else + if ((ch->ch_pun.un_tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && + ch->ch_pun.un_tty->ldisc.ops->write_wakeup) + { + DGNC_UNLOCK(ch->ch_lock, lock_flags); + (ch->ch_pun.un_tty->ldisc.ops->write_wakeup)(ch->ch_pun.un_tty); + DGNC_LOCK(ch->ch_lock, lock_flags); + } +#endif + + wake_up_interruptible(&ch->ch_pun.un_tty->write_wait); + + /* + * If unit is set to wait until empty, check to make sure + * the queue AND FIFO are both empty. + */ + if (ch->ch_pun.un_flags & UN_EMPTY) { + if ((qlen == 0) && (ch->ch_bd->bd_ops->get_uart_bytes_left(ch) == 0)) { + ch->ch_pun.un_flags &= ~(UN_EMPTY); + } + } + + wake_up_interruptible(&ch->ch_pun.un_flags_wait); + } + + DGNC_UNLOCK(ch->ch_lock, lock_flags); +} + + + +/************************************************************************ + * + * TTY Entry points and helper functions + * + ************************************************************************/ + +/* + * dgnc_tty_open() + * + */ +static int dgnc_tty_open(struct tty_struct *tty, struct file *file) +{ + struct board_t *brd; + struct channel_t *ch; + struct un_t *un; + uint major = 0; + uint minor = 0; + int rc = 0; + ulong lock_flags; + + rc = 0; + + major = MAJOR(tty_devnum(tty)); + minor = MINOR(tty_devnum(tty)); + + if (major > 255) { + return -ENXIO; + } + + /* Get board pointer from our array of majors we have allocated */ + brd = dgnc_BoardsByMajor[major]; + if (!brd) { + return -ENXIO; + } + + /* + * If board is not yet up to a state of READY, go to + * sleep waiting for it to happen or they cancel the open. + */ + rc = wait_event_interruptible(brd->state_wait, + (brd->state & BOARD_READY)); + + if (rc) { + return rc; + } + + DGNC_LOCK(brd->bd_lock, lock_flags); + + /* If opened device is greater than our number of ports, bail. */ + if (PORT_NUM(minor) > brd->nasync) { + DGNC_UNLOCK(brd->bd_lock, lock_flags); + return -ENXIO; + } + + ch = brd->channels[PORT_NUM(minor)]; + if (!ch) { + DGNC_UNLOCK(brd->bd_lock, lock_flags); + return -ENXIO; + } + + /* Drop board lock */ + DGNC_UNLOCK(brd->bd_lock, lock_flags); + + /* Grab channel lock */ + DGNC_LOCK(ch->ch_lock, lock_flags); + + /* Figure out our type */ + if (!IS_PRINT(minor)) { + un = &brd->channels[PORT_NUM(minor)]->ch_tun; + un->un_type = DGNC_SERIAL; + } + else if (IS_PRINT(minor)) { + un = &brd->channels[PORT_NUM(minor)]->ch_pun; + un->un_type = DGNC_PRINT; + } + else { + DGNC_UNLOCK(ch->ch_lock, lock_flags); + DPR_OPEN(("%d Unknown TYPE!\n", __LINE__)); + return -ENXIO; + } + + /* + * If the port is still in a previous open, and in a state + * where we simply cannot safely keep going, wait until the + * state clears. + */ + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + rc = wait_event_interruptible(ch->ch_flags_wait, ((ch->ch_flags & CH_OPENING) == 0)); + + /* If ret is non-zero, user ctrl-c'ed us */ + if (rc) { + DPR_OPEN(("%d User ctrl c'ed\n", __LINE__)); + return -EINTR; + } + + /* + * If either unit is in the middle of the fragile part of close, + * we just cannot touch the channel safely. + * Go to sleep, knowing that when the channel can be + * touched safely, the close routine will signal the + * ch_flags_wait to wake us back up. + */ + rc = wait_event_interruptible(ch->ch_flags_wait, + (((ch->ch_tun.un_flags | ch->ch_pun.un_flags) & UN_CLOSING) == 0)); + + /* If ret is non-zero, user ctrl-c'ed us */ + if (rc) { + DPR_OPEN(("%d User ctrl c'ed\n", __LINE__)); + return -EINTR; + } + + DGNC_LOCK(ch->ch_lock, lock_flags); + + + /* Store our unit into driver_data, so we always have it available. */ + tty->driver_data = un; + + DPR_OPEN(("Open called. MAJOR: %d MINOR:%d PORT_NUM: %x unit: %p NAME: %s\n", + MAJOR(tty_devnum(tty)), MINOR(tty_devnum(tty)), PORT_NUM(minor), un, brd->name)); + + DPR_OPEN(("%d: tflag=%x pflag=%x\n", __LINE__, ch->ch_tun.un_flags, ch->ch_pun.un_flags)); + + /* + * Initialize tty's + */ + if (!(un->un_flags & UN_ISOPEN)) { + /* Store important variables. */ + un->un_tty = tty; + + /* Maybe do something here to the TTY struct as well? */ + } + + + /* + * Allocate channel buffers for read/write/error. + * Set flag, so we don't get trounced on. + */ + ch->ch_flags |= (CH_OPENING); + + /* Drop locks, as malloc with GFP_KERNEL can sleep */ + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + if (!ch->ch_rqueue) + ch->ch_rqueue = dgnc_driver_kzmalloc(RQUEUESIZE, GFP_KERNEL); + if (!ch->ch_equeue) + ch->ch_equeue = dgnc_driver_kzmalloc(EQUEUESIZE, GFP_KERNEL); + if (!ch->ch_wqueue) + ch->ch_wqueue = dgnc_driver_kzmalloc(WQUEUESIZE, GFP_KERNEL); + + DGNC_LOCK(ch->ch_lock, lock_flags); + + ch->ch_flags &= ~(CH_OPENING); + wake_up_interruptible(&ch->ch_flags_wait); + + /* + * Initialize if neither terminal or printer is open. + */ + if (!((ch->ch_tun.un_flags | ch->ch_pun.un_flags) & UN_ISOPEN)) { + + DPR_OPEN(("dgnc_open: initializing channel in open...\n")); + + /* + * Flush input queues. + */ + ch->ch_r_head = ch->ch_r_tail = 0; + ch->ch_e_head = ch->ch_e_tail = 0; + ch->ch_w_head = ch->ch_w_tail = 0; + + brd->bd_ops->flush_uart_write(ch); + brd->bd_ops->flush_uart_read(ch); + + ch->ch_flags = 0; + ch->ch_cached_lsr = 0; + ch->ch_stop_sending_break = 0; + ch->ch_stops_sent = 0; + + ch->ch_c_cflag = tty->termios->c_cflag; + ch->ch_c_iflag = tty->termios->c_iflag; + ch->ch_c_oflag = tty->termios->c_oflag; + ch->ch_c_lflag = tty->termios->c_lflag; + ch->ch_startc = tty->termios->c_cc[VSTART]; + ch->ch_stopc = tty->termios->c_cc[VSTOP]; + + /* + * Bring up RTS and DTR... + * Also handle RTS or DTR toggle if set. + */ + if (!(ch->ch_digi.digi_flags & DIGI_RTS_TOGGLE)) + ch->ch_mostat |= (UART_MCR_RTS); + if (!(ch->ch_digi.digi_flags & DIGI_DTR_TOGGLE)) + ch->ch_mostat |= (UART_MCR_DTR); + + /* Tell UART to init itself */ + brd->bd_ops->uart_init(ch); + } + + /* + * Run param in case we changed anything + */ + brd->bd_ops->param(tty); + + dgnc_carrier(ch); + + /* + * follow protocol for opening port + */ + + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + rc = dgnc_block_til_ready(tty, file, ch); + + if (rc) { + DPR_OPEN(("dgnc_tty_open returning after dgnc_block_til_ready " + "with %d\n", rc)); + } + + /* No going back now, increment our unit and channel counters */ + DGNC_LOCK(ch->ch_lock, lock_flags); + ch->ch_open_count++; + un->un_open_count++; + un->un_flags |= (UN_ISOPEN); + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + DPR_OPEN(("dgnc_tty_open finished\n")); + return (rc); +} + + +/* + * dgnc_block_til_ready() + * + * Wait for DCD, if needed. + */ +static int dgnc_block_til_ready(struct tty_struct *tty, struct file *file, struct channel_t *ch) +{ + int retval = 0; + struct un_t *un = NULL; + ulong lock_flags; + uint old_flags = 0; + int sleep_on_un_flags = 0; + + if (!tty || tty->magic != TTY_MAGIC || !file || !ch || ch->magic != DGNC_CHANNEL_MAGIC) { + return (-ENXIO); + } + + un = tty->driver_data; + if (!un || un->magic != DGNC_UNIT_MAGIC) { + return (-ENXIO); + } + + DPR_OPEN(("dgnc_block_til_ready - before block.\n")); + + DGNC_LOCK(ch->ch_lock, lock_flags); + + ch->ch_wopen++; + + /* Loop forever */ + while (1) { + + sleep_on_un_flags = 0; + + /* + * If board has failed somehow during our sleep, bail with error. + */ + if (ch->ch_bd->state == BOARD_FAILED) { + retval = -ENXIO; + break; + } + + /* If tty was hung up, break out of loop and set error. */ + if (tty_hung_up_p(file)) { + retval = -EAGAIN; + break; + } + + /* + * If either unit is in the middle of the fragile part of close, + * we just cannot touch the channel safely. + * Go back to sleep, knowing that when the channel can be + * touched safely, the close routine will signal the + * ch_wait_flags to wake us back up. + */ + if (!((ch->ch_tun.un_flags | ch->ch_pun.un_flags) & UN_CLOSING)) { + + /* + * Our conditions to leave cleanly and happily: + * 1) NONBLOCKING on the tty is set. + * 2) CLOCAL is set. + * 3) DCD (fake or real) is active. + */ + + if (file->f_flags & O_NONBLOCK) { + break; + } + + if (tty->flags & (1 << TTY_IO_ERROR)) { + retval = -EIO; + break; + } + + if (ch->ch_flags & CH_CD) { + DPR_OPEN(("%d: ch_flags: %x\n", __LINE__, ch->ch_flags)); + break; + } + + if (ch->ch_flags & CH_FCAR) { + DPR_OPEN(("%d: ch_flags: %x\n", __LINE__, ch->ch_flags)); + break; + } + } + else { + sleep_on_un_flags = 1; + } + + /* + * If there is a signal pending, the user probably + * interrupted (ctrl-c) us. + * Leave loop with error set. + */ + if (signal_pending(current)) { + DPR_OPEN(("%d: signal pending...\n", __LINE__)); + retval = -ERESTARTSYS; + break; + } + + DPR_OPEN(("dgnc_block_til_ready - blocking.\n")); + + /* + * Store the flags before we let go of channel lock + */ + if (sleep_on_un_flags) + old_flags = ch->ch_tun.un_flags | ch->ch_pun.un_flags; + else + old_flags = ch->ch_flags; + + /* + * Let go of channel lock before calling schedule. + * Our poller will get any FEP events and wake us up when DCD + * eventually goes active. + */ + + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + DPR_OPEN(("Going to sleep on %s flags...\n", + (sleep_on_un_flags ? "un" : "ch"))); + + /* + * Wait for something in the flags to change from the current value. + */ + if (sleep_on_un_flags) { + retval = wait_event_interruptible(un->un_flags_wait, + (old_flags != (ch->ch_tun.un_flags | ch->ch_pun.un_flags))); + } + else { + retval = wait_event_interruptible(ch->ch_flags_wait, + (old_flags != ch->ch_flags)); + } + + DPR_OPEN(("After sleep... retval: %x\n", retval)); + + /* + * We got woken up for some reason. + * Before looping around, grab our channel lock. + */ + DGNC_LOCK(ch->ch_lock, lock_flags); + } + + ch->ch_wopen--; + + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + DPR_OPEN(("dgnc_block_til_ready - after blocking.\n")); + + if (retval) { + DPR_OPEN(("dgnc_block_til_ready - done. error. retval: %x\n", retval)); + return(retval); + } + + DPR_OPEN(("dgnc_block_til_ready - done no error. jiffies: %lu\n", jiffies)); + + return(0); +} + + +/* + * dgnc_tty_hangup() + * + * Hangup the port. Like a close, but don't wait for output to drain. + */ +static void dgnc_tty_hangup(struct tty_struct *tty) +{ + struct un_t *un; + + if (!tty || tty->magic != TTY_MAGIC) + return; + + un = tty->driver_data; + if (!un || un->magic != DGNC_UNIT_MAGIC) + return; + + DPR_CLOSE(("dgnc_hangup called. ch->ch_open_count: %d un->un_open_count: %d\n", + un->un_ch->ch_open_count, un->un_open_count)); + + /* flush the transmit queues */ + dgnc_tty_flush_buffer(tty); + + DPR_CLOSE(("dgnc_hangup finished. ch->ch_open_count: %d un->un_open_count: %d\n", + un->un_ch->ch_open_count, un->un_open_count)); +} + + +/* + * dgnc_tty_close() + * + */ +static void dgnc_tty_close(struct tty_struct *tty, struct file *file) +{ + struct ktermios *ts; + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + ulong lock_flags; + int rc = 0; + + if (!tty || tty->magic != TTY_MAGIC) + return; + + un = tty->driver_data; + if (!un || un->magic != DGNC_UNIT_MAGIC) + return; + + ch = un->un_ch; + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return; + + bd = ch->ch_bd; + if (!bd || bd->magic != DGNC_BOARD_MAGIC) + return; + + ts = tty->termios; + + DPR_CLOSE(("Close called\n")); + + DGNC_LOCK(ch->ch_lock, lock_flags); + + /* + * Determine if this is the last close or not - and if we agree about + * which type of close it is with the Line Discipline + */ + if ((tty->count == 1) && (un->un_open_count != 1)) { + /* + * Uh, oh. tty->count is 1, which means that the tty + * structure will be freed. un_open_count should always + * be one in these conditions. If it's greater than + * one, we've got real problems, since it means the + * serial port won't be shutdown. + */ + APR(("tty->count is 1, un open count is %d\n", un->un_open_count)); + un->un_open_count = 1; + } + + if (--un->un_open_count < 0) { + APR(("bad serial port open count of %d\n", un->un_open_count)); + un->un_open_count = 0; + } + + ch->ch_open_count--; + + if (ch->ch_open_count && un->un_open_count) { + DPR_CLOSE(("dgnc_tty_close: not last close ch: %d un:%d\n", + ch->ch_open_count, un->un_open_count)); + + DGNC_UNLOCK(ch->ch_lock, lock_flags); + return; + } + + /* OK, its the last close on the unit */ + DPR_CLOSE(("dgnc_tty_close - last close on unit procedures\n")); + + un->un_flags |= UN_CLOSING; + + tty->closing = 1; + + + /* + * Only officially close channel if count is 0 and + * DIGI_PRINTER bit is not set. + */ + if ((ch->ch_open_count == 0) && !(ch->ch_digi.digi_flags & DIGI_PRINTER)) { + + ch->ch_flags &= ~(CH_STOPI | CH_FORCED_STOPI); + + /* + * turn off print device when closing print device. + */ + if ((un->un_type == DGNC_PRINT) && (ch->ch_flags & CH_PRON) ) { + dgnc_wmove(ch, ch->ch_digi.digi_offstr, + (int) ch->ch_digi.digi_offlen); + ch->ch_flags &= ~CH_PRON; + } + + DGNC_UNLOCK(ch->ch_lock, lock_flags); + /* wait for output to drain */ + /* This will also return if we take an interrupt */ + + DPR_CLOSE(("Calling wait_for_drain\n")); + rc = bd->bd_ops->drain(tty, 0); + + DPR_CLOSE(("After calling wait_for_drain\n")); + + if (rc) { + DPR_BASIC(("dgnc_tty_close - bad return: %d ", rc)); + } + + dgnc_tty_flush_buffer(tty); + tty_ldisc_flush(tty); + + DGNC_LOCK(ch->ch_lock, lock_flags); + + tty->closing = 0; + + /* + * If we have HUPCL set, lower DTR and RTS + */ + if (ch->ch_c_cflag & HUPCL) { + DPR_CLOSE(("Close. HUPCL set, dropping DTR/RTS\n")); + + /* Drop RTS/DTR */ + ch->ch_mostat &= ~(UART_MCR_DTR | UART_MCR_RTS); + bd->bd_ops->assert_modem_signals(ch); + + /* + * Go to sleep to ensure RTS/DTR + * have been dropped for modems to see it. + */ + if (ch->ch_close_delay) { + DPR_CLOSE(("Close. Sleeping for RTS/DTR drop\n")); + + DGNC_UNLOCK(ch->ch_lock, lock_flags); + dgnc_ms_sleep(ch->ch_close_delay); + DGNC_LOCK(ch->ch_lock, lock_flags); + + DPR_CLOSE(("Close. After sleeping for RTS/DTR drop\n")); + } + } + + ch->ch_old_baud = 0; + + /* Turn off UART interrupts for this port */ + ch->ch_bd->bd_ops->uart_off(ch); + } + else { + /* + * turn off print device when closing print device. + */ + if ((un->un_type == DGNC_PRINT) && (ch->ch_flags & CH_PRON) ) { + dgnc_wmove(ch, ch->ch_digi.digi_offstr, + (int) ch->ch_digi.digi_offlen); + ch->ch_flags &= ~CH_PRON; + } + } + + un->un_tty = NULL; + un->un_flags &= ~(UN_ISOPEN | UN_CLOSING); + + DPR_CLOSE(("Close. Doing wakeups\n")); + wake_up_interruptible(&ch->ch_flags_wait); + wake_up_interruptible(&un->un_flags_wait); + + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + DPR_BASIC(("dgnc_tty_close - complete\n")); +} + + +/* + * dgnc_tty_chars_in_buffer() + * + * Return number of characters that have not been transmitted yet. + * + * This routine is used by the line discipline to determine if there + * is data waiting to be transmitted/drained/flushed or not. + */ +static int dgnc_tty_chars_in_buffer(struct tty_struct *tty) +{ + struct channel_t *ch = NULL; + struct un_t *un = NULL; + ushort thead; + ushort ttail; + uint tmask; + uint chars = 0; + ulong lock_flags = 0; + + if (tty == NULL) + return(0); + + un = tty->driver_data; + if (!un || un->magic != DGNC_UNIT_MAGIC) + return (0); + + ch = un->un_ch; + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return (0); + + DGNC_LOCK(ch->ch_lock, lock_flags); + + tmask = WQUEUEMASK; + thead = ch->ch_w_head & tmask; + ttail = ch->ch_w_tail & tmask; + + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + if (ttail == thead) { + chars = 0; + } else { + if (thead >= ttail) + chars = thead - ttail; + else + chars = thead - ttail + WQUEUESIZE; + } + + DPR_WRITE(("dgnc_tty_chars_in_buffer. Port: %x - %d (head: %d tail: %d)\n", + ch->ch_portnum, chars, thead, ttail)); + + return(chars); +} + + +/* + * dgnc_maxcps_room + * + * Reduces bytes_available to the max number of characters + * that can be sent currently given the maxcps value, and + * returns the new bytes_available. This only affects printer + * output. + */ +static int dgnc_maxcps_room(struct tty_struct *tty, int bytes_available) +{ + struct channel_t *ch = NULL; + struct un_t *un = NULL; + + if (!tty) + return (bytes_available); + + un = tty->driver_data; + if (!un || un->magic != DGNC_UNIT_MAGIC) + return (bytes_available); + + ch = un->un_ch; + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return (bytes_available); + + /* + * If its not the Transparent print device, return + * the full data amount. + */ + if (un->un_type != DGNC_PRINT) + return (bytes_available); + + if (ch->ch_digi.digi_maxcps > 0 && ch->ch_digi.digi_bufsize > 0 ) { + int cps_limit = 0; + unsigned long current_time = jiffies; + unsigned long buffer_time = current_time + + (HZ * ch->ch_digi.digi_bufsize) / ch->ch_digi.digi_maxcps; + + if (ch->ch_cpstime < current_time) { + /* buffer is empty */ + ch->ch_cpstime = current_time; /* reset ch_cpstime */ + cps_limit = ch->ch_digi.digi_bufsize; + } + else if (ch->ch_cpstime < buffer_time) { + /* still room in the buffer */ + cps_limit = ((buffer_time - ch->ch_cpstime) * ch->ch_digi.digi_maxcps) / HZ; + } + else { + /* no room in the buffer */ + cps_limit = 0; + } + + bytes_available = min(cps_limit, bytes_available); + } + + return (bytes_available); +} + + +/* + * dgnc_tty_write_room() + * + * Return space available in Tx buffer + */ +static int dgnc_tty_write_room(struct tty_struct *tty) +{ + struct channel_t *ch = NULL; + struct un_t *un = NULL; + ushort head; + ushort tail; + ushort tmask; + int ret = 0; + ulong lock_flags = 0; + + if (tty == NULL || dgnc_TmpWriteBuf == NULL) + return(0); + + un = tty->driver_data; + if (!un || un->magic != DGNC_UNIT_MAGIC) + return (0); + + ch = un->un_ch; + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return (0); + + DGNC_LOCK(ch->ch_lock, lock_flags); + + tmask = WQUEUEMASK; + head = (ch->ch_w_head) & tmask; + tail = (ch->ch_w_tail) & tmask; + + if ((ret = tail - head - 1) < 0) + ret += WQUEUESIZE; + + /* Limit printer to maxcps */ + ret = dgnc_maxcps_room(tty, ret); + + /* + * If we are printer device, leave space for + * possibly both the on and off strings. + */ + if (un->un_type == DGNC_PRINT) { + if (!(ch->ch_flags & CH_PRON)) + ret -= ch->ch_digi.digi_onlen; + ret -= ch->ch_digi.digi_offlen; + } + else { + if (ch->ch_flags & CH_PRON) + ret -= ch->ch_digi.digi_offlen; + } + + if (ret < 0) + ret = 0; + + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + DPR_WRITE(("dgnc_tty_write_room - %d tail: %d head: %d\n", ret, tail, head)); + + return(ret); +} + + +/* + * dgnc_tty_put_char() + * + * Put a character into ch->ch_buf + * + * - used by the line discipline for OPOST processing + */ +static int dgnc_tty_put_char(struct tty_struct *tty, unsigned char c) +{ + /* + * Simply call tty_write. + */ + DPR_WRITE(("dgnc_tty_put_char called\n")); + dgnc_tty_write(tty, &c, 1); + return 1; +} + + +/* + * dgnc_tty_write() + * + * Take data from the user or kernel and send it out to the FEP. + * In here exists all the Transparent Print magic as well. + */ +static int dgnc_tty_write(struct tty_struct *tty, + const unsigned char *buf, int count) +{ + struct channel_t *ch = NULL; + struct un_t *un = NULL; + int bufcount = 0, n = 0; + int orig_count = 0; + ulong lock_flags; + ushort head; + ushort tail; + ushort tmask; + uint remain; + int from_user = 0; + + if (tty == NULL || dgnc_TmpWriteBuf == NULL) + return(0); + + un = tty->driver_data; + if (!un || un->magic != DGNC_UNIT_MAGIC) + return(0); + + ch = un->un_ch; + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return(0); + + if (!count) + return(0); + + DPR_WRITE(("dgnc_tty_write: Port: %x tty=%p user=%d len=%d\n", + ch->ch_portnum, tty, from_user, count)); + + /* + * Store original amount of characters passed in. + * This helps to figure out if we should ask the FEP + * to send us an event when it has more space available. + */ + orig_count = count; + + DGNC_LOCK(ch->ch_lock, lock_flags); + + /* Get our space available for the channel from the board */ + tmask = WQUEUEMASK; + head = (ch->ch_w_head) & tmask; + tail = (ch->ch_w_tail) & tmask; + + if ((bufcount = tail - head - 1) < 0) + bufcount += WQUEUESIZE; + + DPR_WRITE(("%d: bufcount: %x count: %x tail: %x head: %x tmask: %x\n", + __LINE__, bufcount, count, tail, head, tmask)); + + /* + * Limit printer output to maxcps overall, with bursts allowed + * up to bufsize characters. + */ + bufcount = dgnc_maxcps_room(tty, bufcount); + + /* + * Take minimum of what the user wants to send, and the + * space available in the FEP buffer. + */ + count = min(count, bufcount); + + /* + * Bail if no space left. + */ + if (count <= 0) { + DGNC_UNLOCK(ch->ch_lock, lock_flags); + return(0); + } + + /* + * Output the printer ON string, if we are in terminal mode, but + * need to be in printer mode. + */ + if ((un->un_type == DGNC_PRINT) && !(ch->ch_flags & CH_PRON)) { + dgnc_wmove(ch, ch->ch_digi.digi_onstr, + (int) ch->ch_digi.digi_onlen); + head = (ch->ch_w_head) & tmask; + ch->ch_flags |= CH_PRON; + } + + /* + * On the other hand, output the printer OFF string, if we are + * currently in printer mode, but need to output to the terminal. + */ + if ((un->un_type != DGNC_PRINT) && (ch->ch_flags & CH_PRON)) { + dgnc_wmove(ch, ch->ch_digi.digi_offstr, + (int) ch->ch_digi.digi_offlen); + head = (ch->ch_w_head) & tmask; + ch->ch_flags &= ~CH_PRON; + } + + /* + * If there is nothing left to copy, or I can't handle any more data, leave. + */ + if (count <= 0) { + DGNC_UNLOCK(ch->ch_lock, lock_flags); + return(0); + } + + if (from_user) { + + count = min(count, WRITEBUFLEN); + + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + /* + * If data is coming from user space, copy it into a temporary + * buffer so we don't get swapped out while doing the copy to + * the board. + */ + /* we're allowed to block if it's from_user */ + if (down_interruptible(&dgnc_TmpWriteSem)) { + return (-EINTR); + } + + /* + * copy_from_user() returns the number + * of bytes that could *NOT* be copied. + */ + count -= copy_from_user(dgnc_TmpWriteBuf, (const uchar __user *) buf, count); + + if (!count) { + up(&dgnc_TmpWriteSem); + return(-EFAULT); + } + + DGNC_LOCK(ch->ch_lock, lock_flags); + + buf = dgnc_TmpWriteBuf; + + } + + n = count; + + /* + * If the write wraps over the top of the circular buffer, + * move the portion up to the wrap point, and reset the + * pointers to the bottom. + */ + remain = WQUEUESIZE - head; + + if (n >= remain) { + n -= remain; + memcpy(ch->ch_wqueue + head, buf, remain); + dgnc_sniff_nowait_nolock(ch, "USER WRITE", ch->ch_wqueue + head, remain); + head = 0; + buf += remain; + } + + if (n > 0) { + /* + * Move rest of data. + */ + remain = n; + memcpy(ch->ch_wqueue + head, buf, remain); + dgnc_sniff_nowait_nolock(ch, "USER WRITE", ch->ch_wqueue + head, remain); + head += remain; + } + + if (count) { + head &= tmask; + ch->ch_w_head = head; + } + +#if 0 + /* + * If this is the print device, and the + * printer is still on, we need to turn it + * off before going idle. + */ + if (count == orig_count) { + if ((un->un_type == DGNC_PRINT) && (ch->ch_flags & CH_PRON)) { + head &= tmask; + ch->ch_w_head = head; + dgnc_wmove(ch, ch->ch_digi.digi_offstr, + (int) ch->ch_digi.digi_offlen); + head = (ch->ch_w_head) & tmask; + ch->ch_flags &= ~CH_PRON; + } + } +#endif + + /* Update printer buffer empty time. */ + if ((un->un_type == DGNC_PRINT) && (ch->ch_digi.digi_maxcps > 0) + && (ch->ch_digi.digi_bufsize > 0)) { + ch->ch_cpstime += (HZ * count) / ch->ch_digi.digi_maxcps; + } + + if (from_user) { + DGNC_UNLOCK(ch->ch_lock, lock_flags); + up(&dgnc_TmpWriteSem); + } else { + DGNC_UNLOCK(ch->ch_lock, lock_flags); + } + + DPR_WRITE(("Write finished - Write %d bytes of %d.\n", count, orig_count)); + + if (count) { + /* + * Channel lock is grabbed and then released + * inside this routine. + */ + ch->ch_bd->bd_ops->copy_data_from_queue_to_uart(ch); + } + + return (count); +} + + +/* + * Return modem signals to ld. + */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39) +static int dgnc_tty_tiocmget(struct tty_struct *tty) +#else +static int dgnc_tty_tiocmget(struct tty_struct *tty, struct file *file) +#endif +{ + struct channel_t *ch; + struct un_t *un; + int result = -EIO; + uchar mstat = 0; + ulong lock_flags; + + if (!tty || tty->magic != TTY_MAGIC) + return result; + + un = tty->driver_data; + if (!un || un->magic != DGNC_UNIT_MAGIC) + return result; + + ch = un->un_ch; + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return result; + + DPR_IOCTL(("dgnc_tty_tiocmget start\n")); + + DGNC_LOCK(ch->ch_lock, lock_flags); + + mstat = (ch->ch_mostat | ch->ch_mistat); + + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + result = 0; + + if (mstat & UART_MCR_DTR) + result |= TIOCM_DTR; + if (mstat & UART_MCR_RTS) + result |= TIOCM_RTS; + if (mstat & UART_MSR_CTS) + result |= TIOCM_CTS; + if (mstat & UART_MSR_DSR) + result |= TIOCM_DSR; + if (mstat & UART_MSR_RI) + result |= TIOCM_RI; + if (mstat & UART_MSR_DCD) + result |= TIOCM_CD; + + DPR_IOCTL(("dgnc_tty_tiocmget finish\n")); + + return result; +} + + +/* + * dgnc_tty_tiocmset() + * + * Set modem signals, called by ld. + */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39) +static int dgnc_tty_tiocmset(struct tty_struct *tty, + unsigned int set, unsigned int clear) +#else +static int dgnc_tty_tiocmset(struct tty_struct *tty, struct file *file, + unsigned int set, unsigned int clear) +#endif +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + int ret = -EIO; + ulong lock_flags; + + if (!tty || tty->magic != TTY_MAGIC) + return ret; + + un = tty->driver_data; + if (!un || un->magic != DGNC_UNIT_MAGIC) + return ret; + + ch = un->un_ch; + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return ret; + + bd = ch->ch_bd; + if (!bd || bd->magic != DGNC_BOARD_MAGIC) + return ret; + + DPR_IOCTL(("dgnc_tty_tiocmset start\n")); + + + DGNC_LOCK(ch->ch_lock, lock_flags); + + if (set & TIOCM_RTS) { + ch->ch_mostat |= UART_MCR_RTS; + } + + if (set & TIOCM_DTR) { + ch->ch_mostat |= UART_MCR_DTR; + } + + if (clear & TIOCM_RTS) { + ch->ch_mostat &= ~(UART_MCR_RTS); + } + + if (clear & TIOCM_DTR) { + ch->ch_mostat &= ~(UART_MCR_DTR); + } + + ch->ch_bd->bd_ops->assert_modem_signals(ch); + + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + DPR_IOCTL(("dgnc_tty_tiocmset finish\n")); + + return (0); +} + + +/* + * dgnc_tty_send_break() + * + * Send a Break, called by ld. + */ +static int dgnc_tty_send_break(struct tty_struct *tty, int msec) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + int ret = -EIO; + ulong lock_flags; + + if (!tty || tty->magic != TTY_MAGIC) + return ret; + + un = tty->driver_data; + if (!un || un->magic != DGNC_UNIT_MAGIC) + return ret; + + ch = un->un_ch; + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return ret; + + bd = ch->ch_bd; + if (!bd || bd->magic != DGNC_BOARD_MAGIC) + return ret; + + switch (msec) { + case -1: + msec = 0xFFFF; + break; + case 0: + msec = 0; + break; + default: + break; + } + + DPR_IOCTL(("dgnc_tty_send_break start 1. %lx\n", jiffies)); + + DGNC_LOCK(ch->ch_lock, lock_flags); + + ch->ch_bd->bd_ops->send_break(ch, msec); + + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + DPR_IOCTL(("dgnc_tty_send_break finish\n")); + + return (0); + +} + + +/* + * dgnc_tty_wait_until_sent() + * + * wait until data has been transmitted, called by ld. + */ +static void dgnc_tty_wait_until_sent(struct tty_struct *tty, int timeout) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + int rc; + + if (!tty || tty->magic != TTY_MAGIC) + return; + + un = tty->driver_data; + if (!un || un->magic != DGNC_UNIT_MAGIC) + return; + + ch = un->un_ch; + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return; + + bd = ch->ch_bd; + if (!bd || bd->magic != DGNC_BOARD_MAGIC) + return; + + rc = bd->bd_ops->drain(tty, 0); + if (rc) { + DPR_IOCTL(("dgnc_tty_ioctl - bad return: %d ", rc)); + return; + } + return; +} + + +/* + * dgnc_send_xchar() + * + * send a high priority character, called by ld. + */ +static void dgnc_tty_send_xchar(struct tty_struct *tty, char c) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + ulong lock_flags; + + if (!tty || tty->magic != TTY_MAGIC) + return; + + un = tty->driver_data; + if (!un || un->magic != DGNC_UNIT_MAGIC) + return; + + ch = un->un_ch; + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return; + + bd = ch->ch_bd; + if (!bd || bd->magic != DGNC_BOARD_MAGIC) + return; + + DPR_IOCTL(("dgnc_tty_send_xchar start\n")); + printk("dgnc_tty_send_xchar start\n"); + + DGNC_LOCK(ch->ch_lock, lock_flags); + bd->bd_ops->send_immediate_char(ch, c); + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + DPR_IOCTL(("dgnc_tty_send_xchar finish\n")); + printk("dgnc_tty_send_xchar finish\n"); + return; +} + + + + +/* + * Return modem signals to ld. + */ +static inline int dgnc_get_mstat(struct channel_t *ch) +{ + unsigned char mstat; + int result = -EIO; + ulong lock_flags; + + DPR_IOCTL(("dgnc_getmstat start\n")); + + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return(-ENXIO); + + DGNC_LOCK(ch->ch_lock, lock_flags); + + mstat = (ch->ch_mostat | ch->ch_mistat); + + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + result = 0; + + if (mstat & UART_MCR_DTR) + result |= TIOCM_DTR; + if (mstat & UART_MCR_RTS) + result |= TIOCM_RTS; + if (mstat & UART_MSR_CTS) + result |= TIOCM_CTS; + if (mstat & UART_MSR_DSR) + result |= TIOCM_DSR; + if (mstat & UART_MSR_RI) + result |= TIOCM_RI; + if (mstat & UART_MSR_DCD) + result |= TIOCM_CD; + + DPR_IOCTL(("dgnc_getmstat finish\n")); + + return(result); +} + + + +/* + * Return modem signals to ld. + */ +static int dgnc_get_modem_info(struct channel_t *ch, unsigned int __user *value) +{ + int result; + int rc; + + DPR_IOCTL(("dgnc_get_modem_info start\n")); + + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return(-ENXIO); + + result = dgnc_get_mstat(ch); + + if (result < 0) + return (-ENXIO); + + rc = put_user(result, value); + + DPR_IOCTL(("dgnc_get_modem_info finish\n")); + return(rc); +} + + +/* + * dgnc_set_modem_info() + * + * Set modem signals, called by ld. + */ +static int dgnc_set_modem_info(struct tty_struct *tty, unsigned int command, unsigned int __user *value) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + int ret = -ENXIO; + unsigned int arg = 0; + ulong lock_flags; + + if (!tty || tty->magic != TTY_MAGIC) + return ret; + + un = tty->driver_data; + if (!un || un->magic != DGNC_UNIT_MAGIC) + return ret; + + ch = un->un_ch; + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return ret; + + bd = ch->ch_bd; + if (!bd || bd->magic != DGNC_BOARD_MAGIC) + return ret; + + ret = 0; + + DPR_IOCTL(("dgnc_set_modem_info() start\n")); + + ret = get_user(arg, value); + if (ret) + return(ret); + + switch (command) { + case TIOCMBIS: + if (arg & TIOCM_RTS) { + ch->ch_mostat |= UART_MCR_RTS; + } + + if (arg & TIOCM_DTR) { + ch->ch_mostat |= UART_MCR_DTR; + } + + break; + + case TIOCMBIC: + if (arg & TIOCM_RTS) { + ch->ch_mostat &= ~(UART_MCR_RTS); + } + + if (arg & TIOCM_DTR) { + ch->ch_mostat &= ~(UART_MCR_DTR); + } + + break; + + case TIOCMSET: + + if (arg & TIOCM_RTS) { + ch->ch_mostat |= UART_MCR_RTS; + } + else { + ch->ch_mostat &= ~(UART_MCR_RTS); + } + + if (arg & TIOCM_DTR) { + ch->ch_mostat |= UART_MCR_DTR; + } + else { + ch->ch_mostat &= ~(UART_MCR_DTR); + } + + break; + + default: + return(-EINVAL); + } + + DGNC_LOCK(ch->ch_lock, lock_flags); + + ch->ch_bd->bd_ops->assert_modem_signals(ch); + + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + DPR_IOCTL(("dgnc_set_modem_info finish\n")); + + return (0); +} + + +/* + * dgnc_tty_digigeta() + * + * Ioctl to get the information for ditty. + * + * + * + */ +static int dgnc_tty_digigeta(struct tty_struct *tty, struct digi_t __user *retinfo) +{ + struct channel_t *ch; + struct un_t *un; + struct digi_t tmp; + ulong lock_flags; + + if (!retinfo) + return (-EFAULT); + + if (!tty || tty->magic != TTY_MAGIC) + return (-EFAULT); + + un = tty->driver_data; + if (!un || un->magic != DGNC_UNIT_MAGIC) + return (-EFAULT); + + ch = un->un_ch; + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return (-EFAULT); + + memset(&tmp, 0, sizeof(tmp)); + + DGNC_LOCK(ch->ch_lock, lock_flags); + memcpy(&tmp, &ch->ch_digi, sizeof(tmp)); + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) + return (-EFAULT); + + return (0); +} + + +/* + * dgnc_tty_digiseta() + * + * Ioctl to set the information for ditty. + * + * + * + */ +static int dgnc_tty_digiseta(struct tty_struct *tty, struct digi_t __user *new_info) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + struct digi_t new_digi; + ulong lock_flags; + + DPR_IOCTL(("DIGI_SETA start\n")); + + if (!tty || tty->magic != TTY_MAGIC) + return (-EFAULT); + + un = tty->driver_data; + if (!un || un->magic != DGNC_UNIT_MAGIC) + return (-EFAULT); + + ch = un->un_ch; + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return (-EFAULT); + + bd = ch->ch_bd; + if (!bd || bd->magic != DGNC_BOARD_MAGIC) + return (-EFAULT); + + if (copy_from_user(&new_digi, new_info, sizeof(struct digi_t))) { + DPR_IOCTL(("DIGI_SETA failed copy_from_user\n")); + return(-EFAULT); + } + + DGNC_LOCK(ch->ch_lock, lock_flags); + + /* + * Handle transistions to and from RTS Toggle. + */ + if (!(ch->ch_digi.digi_flags & DIGI_RTS_TOGGLE) && (new_digi.digi_flags & DIGI_RTS_TOGGLE)) + ch->ch_mostat &= ~(UART_MCR_RTS); + if ((ch->ch_digi.digi_flags & DIGI_RTS_TOGGLE) && !(new_digi.digi_flags & DIGI_RTS_TOGGLE)) + ch->ch_mostat |= (UART_MCR_RTS); + + /* + * Handle transistions to and from DTR Toggle. + */ + if (!(ch->ch_digi.digi_flags & DIGI_DTR_TOGGLE) && (new_digi.digi_flags & DIGI_DTR_TOGGLE)) + ch->ch_mostat &= ~(UART_MCR_DTR); + if ((ch->ch_digi.digi_flags & DIGI_DTR_TOGGLE) && !(new_digi.digi_flags & DIGI_DTR_TOGGLE)) + ch->ch_mostat |= (UART_MCR_DTR); + + memcpy(&ch->ch_digi, &new_digi, sizeof(struct digi_t)); + + if (ch->ch_digi.digi_maxcps < 1) + ch->ch_digi.digi_maxcps = 1; + + if (ch->ch_digi.digi_maxcps > 10000) + ch->ch_digi.digi_maxcps = 10000; + + if (ch->ch_digi.digi_bufsize < 10) + ch->ch_digi.digi_bufsize = 10; + + if (ch->ch_digi.digi_maxchar < 1) + ch->ch_digi.digi_maxchar = 1; + + if (ch->ch_digi.digi_maxchar > ch->ch_digi.digi_bufsize) + ch->ch_digi.digi_maxchar = ch->ch_digi.digi_bufsize; + + if (ch->ch_digi.digi_onlen > DIGI_PLEN) + ch->ch_digi.digi_onlen = DIGI_PLEN; + + if (ch->ch_digi.digi_offlen > DIGI_PLEN) + ch->ch_digi.digi_offlen = DIGI_PLEN; + + ch->ch_bd->bd_ops->param(tty); + + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + DPR_IOCTL(("DIGI_SETA finish\n")); + + return(0); +} + + +/* + * dgnc_set_termios() + */ +static void dgnc_tty_set_termios(struct tty_struct *tty, struct ktermios *old_termios) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + unsigned long lock_flags; + + if (!tty || tty->magic != TTY_MAGIC) + return; + + un = tty->driver_data; + if (!un || un->magic != DGNC_UNIT_MAGIC) + return; + + ch = un->un_ch; + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return; + + bd = ch->ch_bd; + if (!bd || bd->magic != DGNC_BOARD_MAGIC) + return; + + DGNC_LOCK(ch->ch_lock, lock_flags); + + ch->ch_c_cflag = tty->termios->c_cflag; + ch->ch_c_iflag = tty->termios->c_iflag; + ch->ch_c_oflag = tty->termios->c_oflag; + ch->ch_c_lflag = tty->termios->c_lflag; + ch->ch_startc = tty->termios->c_cc[VSTART]; + ch->ch_stopc = tty->termios->c_cc[VSTOP]; + + ch->ch_bd->bd_ops->param(tty); + dgnc_carrier(ch); + + DGNC_UNLOCK(ch->ch_lock, lock_flags); +} + + +static void dgnc_tty_throttle(struct tty_struct *tty) +{ + struct channel_t *ch; + struct un_t *un; + ulong lock_flags = 0; + + if (!tty || tty->magic != TTY_MAGIC) + return; + + un = tty->driver_data; + if (!un || un->magic != DGNC_UNIT_MAGIC) + return; + + ch = un->un_ch; + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return; + + DPR_IOCTL(("dgnc_tty_throttle start\n")); + + DGNC_LOCK(ch->ch_lock, lock_flags); + + ch->ch_flags |= (CH_FORCED_STOPI); + + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + DPR_IOCTL(("dgnc_tty_throttle finish\n")); +} + + +static void dgnc_tty_unthrottle(struct tty_struct *tty) +{ + struct channel_t *ch; + struct un_t *un; + ulong lock_flags; + + if (!tty || tty->magic != TTY_MAGIC) + return; + + un = tty->driver_data; + if (!un || un->magic != DGNC_UNIT_MAGIC) + return; + + ch = un->un_ch; + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return; + + DPR_IOCTL(("dgnc_tty_unthrottle start\n")); + + DGNC_LOCK(ch->ch_lock, lock_flags); + + ch->ch_flags &= ~(CH_FORCED_STOPI); + + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + DPR_IOCTL(("dgnc_tty_unthrottle finish\n")); +} + + +static void dgnc_tty_start(struct tty_struct *tty) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + ulong lock_flags; + + if (!tty || tty->magic != TTY_MAGIC) + return; + + un = tty->driver_data; + if (!un || un->magic != DGNC_UNIT_MAGIC) + return; + + ch = un->un_ch; + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return; + + bd = ch->ch_bd; + if (!bd || bd->magic != DGNC_BOARD_MAGIC) + return; + + DPR_IOCTL(("dgcn_tty_start start\n")); + + DGNC_LOCK(ch->ch_lock, lock_flags); + + ch->ch_flags &= ~(CH_FORCED_STOP); + + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + DPR_IOCTL(("dgnc_tty_start finish\n")); +} + + +static void dgnc_tty_stop(struct tty_struct *tty) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + ulong lock_flags; + + if (!tty || tty->magic != TTY_MAGIC) + return; + + un = tty->driver_data; + if (!un || un->magic != DGNC_UNIT_MAGIC) + return; + + ch = un->un_ch; + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return; + + bd = ch->ch_bd; + if (!bd || bd->magic != DGNC_BOARD_MAGIC) + return; + + DPR_IOCTL(("dgnc_tty_stop start\n")); + + DGNC_LOCK(ch->ch_lock, lock_flags); + + ch->ch_flags |= (CH_FORCED_STOP); + + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + DPR_IOCTL(("dgnc_tty_stop finish\n")); +} + + +/* + * dgnc_tty_flush_chars() + * + * Flush the cook buffer + * + * Note to self, and any other poor souls who venture here: + * + * flush in this case DOES NOT mean dispose of the data. + * instead, it means "stop buffering and send it if you + * haven't already." Just guess how I figured that out... SRW 2-Jun-98 + * + * It is also always called in interrupt context - JAR 8-Sept-99 + */ +static void dgnc_tty_flush_chars(struct tty_struct *tty) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + ulong lock_flags; + + if (!tty || tty->magic != TTY_MAGIC) + return; + + un = tty->driver_data; + if (!un || un->magic != DGNC_UNIT_MAGIC) + return; + + ch = un->un_ch; + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return; + + bd = ch->ch_bd; + if (!bd || bd->magic != DGNC_BOARD_MAGIC) + return; + + DPR_IOCTL(("dgnc_tty_flush_chars start\n")); + + DGNC_LOCK(ch->ch_lock, lock_flags); + + /* Do something maybe here */ + + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + DPR_IOCTL(("dgnc_tty_flush_chars finish\n")); +} + + + +/* + * dgnc_tty_flush_buffer() + * + * Flush Tx buffer (make in == out) + */ +static void dgnc_tty_flush_buffer(struct tty_struct *tty) +{ + struct channel_t *ch; + struct un_t *un; + ulong lock_flags; + + if (!tty || tty->magic != TTY_MAGIC) + return; + + un = tty->driver_data; + if (!un || un->magic != DGNC_UNIT_MAGIC) + return; + + ch = un->un_ch; + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return; + + DPR_IOCTL(("dgnc_tty_flush_buffer on port: %d start\n", ch->ch_portnum)); + + DGNC_LOCK(ch->ch_lock, lock_flags); + + ch->ch_flags &= ~CH_STOP; + + /* Flush our write queue */ + ch->ch_w_head = ch->ch_w_tail; + + /* Flush UARTs transmit FIFO */ + ch->ch_bd->bd_ops->flush_uart_write(ch); + + if (ch->ch_tun.un_flags & (UN_LOW|UN_EMPTY)) { + ch->ch_tun.un_flags &= ~(UN_LOW|UN_EMPTY); + wake_up_interruptible(&ch->ch_tun.un_flags_wait); + } + if (ch->ch_pun.un_flags & (UN_LOW|UN_EMPTY)) { + ch->ch_pun.un_flags &= ~(UN_LOW|UN_EMPTY); + wake_up_interruptible(&ch->ch_pun.un_flags_wait); + } + + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + DPR_IOCTL(("dgnc_tty_flush_buffer finish\n")); +} + + + +/***************************************************************************** + * + * The IOCTL function and all of its helpers + * + *****************************************************************************/ + +/* + * dgnc_tty_ioctl() + * + * The usual assortment of ioctl's + */ +static int dgnc_tty_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, + unsigned long arg) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + int rc; + ulong lock_flags; + void __user *uarg = (void __user *) arg; + + if (!tty || tty->magic != TTY_MAGIC) + return (-ENODEV); + + un = tty->driver_data; + if (!un || un->magic != DGNC_UNIT_MAGIC) + return (-ENODEV); + + ch = un->un_ch; + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return (-ENODEV); + + bd = ch->ch_bd; + if (!bd || bd->magic != DGNC_BOARD_MAGIC) + return (-ENODEV); + + DPR_IOCTL(("dgnc_tty_ioctl start on port %d - cmd %s (%x), arg %lx\n", + ch->ch_portnum, dgnc_ioctl_name(cmd), cmd, arg)); + + DGNC_LOCK(ch->ch_lock, lock_flags); + + if (un->un_open_count <= 0) { + DPR_BASIC(("dgnc_tty_ioctl - unit not open.\n")); + DGNC_UNLOCK(ch->ch_lock, lock_flags); + return(-EIO); + } + + switch (cmd) { + + /* Here are all the standard ioctl's that we MUST implement */ + + case TCSBRK: + /* + * TCSBRK is SVID version: non-zero arg --> no break + * this behaviour is exploited by tcdrain(). + * + * According to POSIX.1 spec (7.2.2.1.2) breaks should be + * between 0.25 and 0.5 seconds so we'll ask for something + * in the middle: 0.375 seconds. + */ + rc = tty_check_change(tty); + DGNC_UNLOCK(ch->ch_lock, lock_flags); + if (rc) { + return(rc); + } + + rc = ch->ch_bd->bd_ops->drain(tty, 0); + + if (rc) { + DPR_IOCTL(("dgnc_tty_ioctl - bad return: %d ", rc)); + return(-EINTR); + } + + DGNC_LOCK(ch->ch_lock, lock_flags); + + if(((cmd == TCSBRK) && (!arg)) || (cmd == TCSBRKP)) { + ch->ch_bd->bd_ops->send_break(ch, 250); + } + + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + DPR_IOCTL(("dgnc_tty_ioctl finish on port %d - cmd %s (%x), arg %lx\n", + ch->ch_portnum, dgnc_ioctl_name(cmd), cmd, arg)); + + return(0); + + + case TCSBRKP: + /* support for POSIX tcsendbreak() + * According to POSIX.1 spec (7.2.2.1.2) breaks should be + * between 0.25 and 0.5 seconds so we'll ask for something + * in the middle: 0.375 seconds. + */ + rc = tty_check_change(tty); + DGNC_UNLOCK(ch->ch_lock, lock_flags); + if (rc) { + return(rc); + } + + rc = ch->ch_bd->bd_ops->drain(tty, 0); + if (rc) { + DPR_IOCTL(("dgnc_tty_ioctl - bad return: %d ", rc)); + return(-EINTR); + } + + DGNC_LOCK(ch->ch_lock, lock_flags); + + ch->ch_bd->bd_ops->send_break(ch, 250); + + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + DPR_IOCTL(("dgnc_tty_ioctl finish on port %d - cmd %s (%x), arg %lx\n", + ch->ch_portnum, dgnc_ioctl_name(cmd), cmd, arg)); + + return(0); + + case TIOCSBRK: + rc = tty_check_change(tty); + DGNC_UNLOCK(ch->ch_lock, lock_flags); + if (rc) { + return(rc); + } + + rc = ch->ch_bd->bd_ops->drain(tty, 0); + if (rc) { + DPR_IOCTL(("dgnc_tty_ioctl - bad return: %d ", rc)); + return(-EINTR); + } + + DGNC_LOCK(ch->ch_lock, lock_flags); + + ch->ch_bd->bd_ops->send_break(ch, 250); + + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + DPR_IOCTL(("dgnc_tty_ioctl finish on port %d - cmd %s (%x), arg %lx\n", + ch->ch_portnum, dgnc_ioctl_name(cmd), cmd, arg)); + + return(0); + + case TIOCCBRK: + /* Do Nothing */ + DGNC_UNLOCK(ch->ch_lock, lock_flags); + return 0; + + case TIOCGSOFTCAR: + + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + rc = put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long __user *) arg); + return(rc); + + case TIOCSSOFTCAR: + + DGNC_UNLOCK(ch->ch_lock, lock_flags); + rc = get_user(arg, (unsigned long __user *) arg); + if (rc) + return(rc); + + DGNC_LOCK(ch->ch_lock, lock_flags); + tty->termios->c_cflag = ((tty->termios->c_cflag & ~CLOCAL) | (arg ? CLOCAL : 0)); + ch->ch_bd->bd_ops->param(tty); + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + return(0); + + case TIOCMGET: + DGNC_UNLOCK(ch->ch_lock, lock_flags); + return(dgnc_get_modem_info(ch, uarg)); + + case TIOCMBIS: + case TIOCMBIC: + case TIOCMSET: + DGNC_UNLOCK(ch->ch_lock, lock_flags); + return(dgnc_set_modem_info(tty, cmd, uarg)); + + /* + * Here are any additional ioctl's that we want to implement + */ + + case TCFLSH: + /* + * The linux tty driver doesn't have a flush + * input routine for the driver, assuming all backed + * up data is in the line disc. buffers. However, + * we all know that's not the case. Here, we + * act on the ioctl, but then lie and say we didn't + * so the line discipline will process the flush + * also. + */ + rc = tty_check_change(tty); + if (rc) { + DGNC_UNLOCK(ch->ch_lock, lock_flags); + return(rc); + } + + if ((arg == TCIFLUSH) || (arg == TCIOFLUSH)) { + ch->ch_r_head = ch->ch_r_tail; + ch->ch_bd->bd_ops->flush_uart_read(ch); + /* Force queue flow control to be released, if needed */ + dgnc_check_queue_flow_control(ch); + } + + if ((arg == TCOFLUSH) || (arg == TCIOFLUSH)) { + if (!(un->un_type == DGNC_PRINT)) { + ch->ch_w_head = ch->ch_w_tail; + ch->ch_bd->bd_ops->flush_uart_write(ch); + + if (ch->ch_tun.un_flags & (UN_LOW|UN_EMPTY)) { + ch->ch_tun.un_flags &= ~(UN_LOW|UN_EMPTY); + wake_up_interruptible(&ch->ch_tun.un_flags_wait); + } + + if (ch->ch_pun.un_flags & (UN_LOW|UN_EMPTY)) { + ch->ch_pun.un_flags &= ~(UN_LOW|UN_EMPTY); + wake_up_interruptible(&ch->ch_pun.un_flags_wait); + } + + } + } + + /* pretend we didn't recognize this IOCTL */ + DGNC_UNLOCK(ch->ch_lock, lock_flags); + return(-ENOIOCTLCMD); + +#ifdef TIOCGETP + case TIOCGETP: +#endif + case TCGETS: + case TCGETA: +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30) + if (tty->ldisc->ops->ioctl) { +#else + if (tty->ldisc.ops->ioctl) { +#endif + int retval = (-ENXIO); + + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + if (tty->termios) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30) + retval = ((tty->ldisc->ops->ioctl) (tty, file, cmd, arg)); +#else + retval = ((tty->ldisc.ops->ioctl) (tty, file, cmd, arg)); +#endif + } + + DPR_IOCTL(("dgnc_tty_ioctl (LINE:%d) finish on port %d - cmd %s (%x), arg %lx\n", + __LINE__, ch->ch_portnum, dgnc_ioctl_name(cmd), cmd, arg)); + return(retval); + } + + DGNC_UNLOCK(ch->ch_lock, lock_flags); + DPR_IOCTL(("dgnc_tty_ioctl (LINE:%d) finish on port %d - cmd %s (%x), arg %lx\n", + __LINE__, ch->ch_portnum, dgnc_ioctl_name(cmd), cmd, arg)); + + return(-ENOIOCTLCMD); + + case TCSETSF: + case TCSETSW: + /* + * The linux tty driver doesn't have a flush + * input routine for the driver, assuming all backed + * up data is in the line disc. buffers. However, + * we all know that's not the case. Here, we + * act on the ioctl, but then lie and say we didn't + * so the line discipline will process the flush + * also. + */ + if (cmd == TCSETSF) { + /* flush rx */ + ch->ch_flags &= ~CH_STOP; + ch->ch_r_head = ch->ch_r_tail; + ch->ch_bd->bd_ops->flush_uart_read(ch); + /* Force queue flow control to be released, if needed */ + dgnc_check_queue_flow_control(ch); + } + + /* now wait for all the output to drain */ + DGNC_UNLOCK(ch->ch_lock, lock_flags); + rc = ch->ch_bd->bd_ops->drain(tty, 0); + if (rc) { + DPR_IOCTL(("dgnc_tty_ioctl - bad return: %d\n", rc)); + return(-EINTR); + } + + DPR_IOCTL(("dgnc_tty_ioctl finish on port %d - cmd %s (%x), arg %lx\n", + ch->ch_portnum, dgnc_ioctl_name(cmd), cmd, arg)); + + /* pretend we didn't recognize this */ + return(-ENOIOCTLCMD); + + case TCSETAW: + + DGNC_UNLOCK(ch->ch_lock, lock_flags); + rc = ch->ch_bd->bd_ops->drain(tty, 0); + if (rc) { + DPR_IOCTL(("dgnc_tty_ioctl - bad return: %d ", rc)); + return(-EINTR); + } + + /* pretend we didn't recognize this */ + return(-ENOIOCTLCMD); + + case TCXONC: + DGNC_UNLOCK(ch->ch_lock, lock_flags); + /* Make the ld do it */ + return(-ENOIOCTLCMD); + + case DIGI_GETA: + /* get information for ditty */ + DGNC_UNLOCK(ch->ch_lock, lock_flags); + return(dgnc_tty_digigeta(tty, uarg)); + + case DIGI_SETAW: + case DIGI_SETAF: + + /* set information for ditty */ + if (cmd == (DIGI_SETAW)) { + + DGNC_UNLOCK(ch->ch_lock, lock_flags); + rc = ch->ch_bd->bd_ops->drain(tty, 0); + if (rc) { + DPR_IOCTL(("dgnc_tty_ioctl - bad return: %d ", rc)); + return(-EINTR); + } + DGNC_LOCK(ch->ch_lock, lock_flags); + } + else { + tty_ldisc_flush(tty); + } + /* fall thru */ + + case DIGI_SETA: + DGNC_UNLOCK(ch->ch_lock, lock_flags); + return(dgnc_tty_digiseta(tty, uarg)); + + case DIGI_LOOPBACK: + { + uint loopback = 0; + /* Let go of locks when accessing user space, could sleep */ + DGNC_UNLOCK(ch->ch_lock, lock_flags); + rc = get_user(loopback, (unsigned int __user *) arg); + if (rc) + return(rc); + DGNC_LOCK(ch->ch_lock, lock_flags); + + /* Enable/disable internal loopback for this port */ + if (loopback) + ch->ch_flags |= CH_LOOPBACK; + else + ch->ch_flags &= ~(CH_LOOPBACK); + + ch->ch_bd->bd_ops->param(tty); + DGNC_UNLOCK(ch->ch_lock, lock_flags); + return(0); + } + + case DIGI_GETCUSTOMBAUD: + DGNC_UNLOCK(ch->ch_lock, lock_flags); + rc = put_user(ch->ch_custom_speed, (unsigned int __user *) arg); + return(rc); + + case DIGI_SETCUSTOMBAUD: + { + uint new_rate; + /* Let go of locks when accessing user space, could sleep */ + DGNC_UNLOCK(ch->ch_lock, lock_flags); + rc = get_user(new_rate, (unsigned int __user *) arg); + if (rc) + return(rc); + DGNC_LOCK(ch->ch_lock, lock_flags); + dgnc_set_custom_speed(ch, new_rate); + ch->ch_bd->bd_ops->param(tty); + DGNC_UNLOCK(ch->ch_lock, lock_flags); + return(0); + } + + /* + * This ioctl allows insertion of a character into the front + * of any pending data to be transmitted. + * + * This ioctl is to satify the "Send Character Immediate" + * call that the RealPort protocol spec requires. + */ + case DIGI_REALPORT_SENDIMMEDIATE: + { + unsigned char c; + DGNC_UNLOCK(ch->ch_lock, lock_flags); + rc = get_user(c, (unsigned char __user *) arg); + if (rc) + return(rc); + DGNC_LOCK(ch->ch_lock, lock_flags); + ch->ch_bd->bd_ops->send_immediate_char(ch, c); + DGNC_UNLOCK(ch->ch_lock, lock_flags); + return(0); + } + + /* + * This ioctl returns all the current counts for the port. + * + * This ioctl is to satify the "Line Error Counters" + * call that the RealPort protocol spec requires. + */ + case DIGI_REALPORT_GETCOUNTERS: + { + struct digi_getcounter buf; + + buf.norun = ch->ch_err_overrun; + buf.noflow = 0; /* The driver doesn't keep this stat */ + buf.nframe = ch->ch_err_frame; + buf.nparity = ch->ch_err_parity; + buf.nbreak = ch->ch_err_break; + buf.rbytes = ch->ch_rxcount; + buf.tbytes = ch->ch_txcount; + + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + if (copy_to_user(uarg, &buf, sizeof(struct digi_getcounter))) { + return (-EFAULT); + } + return(0); + } + + /* + * This ioctl returns all current events. + * + * This ioctl is to satify the "Event Reporting" + * call that the RealPort protocol spec requires. + */ + case DIGI_REALPORT_GETEVENTS: + { + unsigned int events = 0; + + /* NOTE: MORE EVENTS NEEDS TO BE ADDED HERE */ + if (ch->ch_flags & CH_BREAK_SENDING) + events |= EV_TXB; + if ((ch->ch_flags & CH_STOP) || (ch->ch_flags & CH_FORCED_STOP)) { + events |= (EV_OPU | EV_OPS); + } + if ((ch->ch_flags & CH_STOPI) || (ch->ch_flags & CH_FORCED_STOPI)) { + events |= (EV_IPU | EV_IPS); + } + + DGNC_UNLOCK(ch->ch_lock, lock_flags); + rc = put_user(events, (unsigned int __user *) arg); + return(rc); + } + + /* + * This ioctl returns TOUT and TIN counters based + * upon the values passed in by the RealPort Server. + * It also passes back whether the UART Transmitter is + * empty as well. + */ + case DIGI_REALPORT_GETBUFFERS: + { + struct digi_getbuffer buf; + int tdist; + int count; + + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + /* + * Get data from user first. + */ + if (copy_from_user(&buf, uarg, sizeof(struct digi_getbuffer))) { + return (-EFAULT); + } + + DGNC_LOCK(ch->ch_lock, lock_flags); + + /* + * Figure out how much data is in our RX and TX queues. + */ + buf.rxbuf = (ch->ch_r_head - ch->ch_r_tail) & RQUEUEMASK; + buf.txbuf = (ch->ch_w_head - ch->ch_w_tail) & WQUEUEMASK; + + /* + * Is the UART empty? Add that value to whats in our TX queue. + */ + count = buf.txbuf + ch->ch_bd->bd_ops->get_uart_bytes_left(ch); + + /* + * Figure out how much data the RealPort Server believes should + * be in our TX queue. + */ + tdist = (buf.tIn - buf.tOut) & 0xffff; + + /* + * If we have more data than the RealPort Server believes we + * should have, reduce our count to its amount. + * + * This count difference CAN happen because the Linux LD can + * insert more characters into our queue for OPOST processing + * that the RealPort Server doesn't know about. + */ + if (buf.txbuf > tdist) { + buf.txbuf = tdist; + } + + /* + * Report whether our queue and UART TX are completely empty. + */ + if (count) { + buf.txdone = 0; + } else { + buf.txdone = 1; + } + + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + if (copy_to_user(uarg, &buf, sizeof(struct digi_getbuffer))) { + return (-EFAULT); + } + return(0); + } + default: + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + DPR_IOCTL(("dgnc_tty_ioctl - in default\n")); + DPR_IOCTL(("dgnc_tty_ioctl end - cmd %s (%x), arg %lx\n", + dgnc_ioctl_name(cmd), cmd, arg)); + + return(-ENOIOCTLCMD); + } + + DGNC_UNLOCK(ch->ch_lock, lock_flags); + + DPR_IOCTL(("dgnc_tty_ioctl end - cmd %s (%x), arg %lx\n", + dgnc_ioctl_name(cmd), cmd, arg)); + + return(0); +} diff --git a/drivers/staging/dgnc/dgnc_tty.h b/drivers/staging/dgnc/dgnc_tty.h new file mode 100644 index 0000000000000..deb388d2f4cff --- /dev/null +++ b/drivers/staging/dgnc/dgnc_tty.h @@ -0,0 +1,42 @@ +/* + * Copyright 2003 Digi International (www.digi.com) + * Scott H Kilau + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! + */ + +#ifndef __DGNC_TTY_H +#define __DGNC_TTY_H + +#include "dgnc_driver.h" + +int dgnc_tty_register(struct board_t *brd); + +int dgnc_tty_preinit(void); +int dgnc_tty_init(struct board_t *); + +void dgnc_tty_post_uninit(void); +void dgnc_tty_uninit(struct board_t *); + +void dgnc_input(struct channel_t *ch); +void dgnc_carrier(struct channel_t *ch); +void dgnc_wakeup_writes(struct channel_t *ch); +void dgnc_check_queue_flow_control(struct channel_t *ch); + +void dgnc_sniff_nowait_nolock(struct channel_t *ch, uchar *text, uchar *buf, int nbuf); + +#endif diff --git a/drivers/staging/dgnc/dgnc_types.h b/drivers/staging/dgnc/dgnc_types.h new file mode 100644 index 0000000000000..4fa358535f843 --- /dev/null +++ b/drivers/staging/dgnc/dgnc_types.h @@ -0,0 +1,36 @@ +/* + * Copyright 2003 Digi International (www.digi.com) + * Scott H Kilau + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! + */ + +#ifndef __DGNC_TYPES_H +#define __DGNC_TYPES_H + +#ifndef TRUE +# define TRUE 1 +#endif + +#ifndef FALSE +# define FALSE 0 +#endif + +/* Required for our shared headers! */ +typedef unsigned char uchar; + +#endif diff --git a/drivers/staging/dgnc/digi.h b/drivers/staging/dgnc/digi.h new file mode 100644 index 0000000000000..ab903823ab072 --- /dev/null +++ b/drivers/staging/dgnc/digi.h @@ -0,0 +1,419 @@ +/* + * Copyright 2003 Digi International (www.digi.com) + * Scott H Kilau + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id: digi.h,v 1.1.1.1 2009/05/20 12:19:19 markh Exp $ + * + * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! + */ + +#ifndef __DIGI_H +#define __DIGI_H + +/************************************************************************ + *** Definitions for Digi ditty(1) command. + ************************************************************************/ + + +/* + * Copyright (c) 1988-96 Digi International Inc., All Rights Reserved. + */ + +/************************************************************************ + * This module provides application access to special Digi + * serial line enhancements which are not standard UNIX(tm) features. + ************************************************************************/ + +#if !defined(TIOCMODG) + +#define TIOCMODG ('d'<<8) | 250 /* get modem ctrl state */ +#define TIOCMODS ('d'<<8) | 251 /* set modem ctrl state */ + +#ifndef TIOCM_LE +#define TIOCM_LE 0x01 /* line enable */ +#define TIOCM_DTR 0x02 /* data terminal ready */ +#define TIOCM_RTS 0x04 /* request to send */ +#define TIOCM_ST 0x08 /* secondary transmit */ +#define TIOCM_SR 0x10 /* secondary receive */ +#define TIOCM_CTS 0x20 /* clear to send */ +#define TIOCM_CAR 0x40 /* carrier detect */ +#define TIOCM_RNG 0x80 /* ring indicator */ +#define TIOCM_DSR 0x100 /* data set ready */ +#define TIOCM_RI TIOCM_RNG /* ring (alternate) */ +#define TIOCM_CD TIOCM_CAR /* carrier detect (alt) */ +#endif + +#endif + +#if !defined(TIOCMSET) +#define TIOCMSET ('d'<<8) | 252 /* set modem ctrl state */ +#define TIOCMGET ('d'<<8) | 253 /* set modem ctrl state */ +#endif + +#if !defined(TIOCMBIC) +#define TIOCMBIC ('d'<<8) | 254 /* set modem ctrl state */ +#define TIOCMBIS ('d'<<8) | 255 /* set modem ctrl state */ +#endif + + +#if !defined(TIOCSDTR) +#define TIOCSDTR ('e'<<8) | 0 /* set DTR */ +#define TIOCCDTR ('e'<<8) | 1 /* clear DTR */ +#endif + +/************************************************************************ + * Ioctl command arguments for DIGI parameters. + ************************************************************************/ +#define DIGI_GETA ('e'<<8) | 94 /* Read params */ + +#define DIGI_SETA ('e'<<8) | 95 /* Set params */ +#define DIGI_SETAW ('e'<<8) | 96 /* Drain & set params */ +#define DIGI_SETAF ('e'<<8) | 97 /* Drain, flush & set params */ + +#define DIGI_KME ('e'<<8) | 98 /* Read/Write Host */ + /* Adapter Memory */ + +#define DIGI_GETFLOW ('e'<<8) | 99 /* Get startc/stopc flow */ + /* control characters */ +#define DIGI_SETFLOW ('e'<<8) | 100 /* Set startc/stopc flow */ + /* control characters */ +#define DIGI_GETAFLOW ('e'<<8) | 101 /* Get Aux. startc/stopc */ + /* flow control chars */ +#define DIGI_SETAFLOW ('e'<<8) | 102 /* Set Aux. startc/stopc */ + /* flow control chars */ + +#define DIGI_GEDELAY ('d'<<8) | 246 /* Get edelay */ +#define DIGI_SEDELAY ('d'<<8) | 247 /* Set edelay */ + +struct digiflow_t { + unsigned char startc; /* flow cntl start char */ + unsigned char stopc; /* flow cntl stop char */ +}; + + +#ifdef FLOW_2200 +#define F2200_GETA ('e'<<8) | 104 /* Get 2x36 flow cntl flags */ +#define F2200_SETAW ('e'<<8) | 105 /* Set 2x36 flow cntl flags */ +#define F2200_MASK 0x03 /* 2200 flow cntl bit mask */ +#define FCNTL_2200 0x01 /* 2x36 terminal flow cntl */ +#define PCNTL_2200 0x02 /* 2x36 printer flow cntl */ +#define F2200_XON 0xf8 +#define P2200_XON 0xf9 +#define F2200_XOFF 0xfa +#define P2200_XOFF 0xfb + +#define FXOFF_MASK 0x03 /* 2200 flow status mask */ +#define RCVD_FXOFF 0x01 /* 2x36 Terminal XOFF rcvd */ +#define RCVD_PXOFF 0x02 /* 2x36 Printer XOFF rcvd */ +#endif + +/************************************************************************ + * Values for digi_flags + ************************************************************************/ +#define DIGI_IXON 0x0001 /* Handle IXON in the FEP */ +#define DIGI_FAST 0x0002 /* Fast baud rates */ +#define RTSPACE 0x0004 /* RTS input flow control */ +#define CTSPACE 0x0008 /* CTS output flow control */ +#define DSRPACE 0x0010 /* DSR output flow control */ +#define DCDPACE 0x0020 /* DCD output flow control */ +#define DTRPACE 0x0040 /* DTR input flow control */ +#define DIGI_COOK 0x0080 /* Cooked processing done in FEP */ +#define DIGI_FORCEDCD 0x0100 /* Force carrier */ +#define DIGI_ALTPIN 0x0200 /* Alternate RJ-45 pin config */ +#define DIGI_AIXON 0x0400 /* Aux flow control in fep */ +#define DIGI_PRINTER 0x0800 /* Hold port open for flow cntrl*/ +#define DIGI_PP_INPUT 0x1000 /* Change parallel port to input*/ +#define DIGI_DTR_TOGGLE 0x2000 /* Support DTR Toggle */ +#define DIGI_422 0x4000 /* for 422/232 selectable panel */ +#define DIGI_RTS_TOGGLE 0x8000 /* Support RTS Toggle */ + +/************************************************************************ + * These options are not supported on the comxi. + ************************************************************************/ +#define DIGI_COMXI (DIGI_FAST|DIGI_COOK|DSRPACE|DCDPACE|DTRPACE) + +#define DIGI_PLEN 28 /* String length */ +#define DIGI_TSIZ 10 /* Terminal string len */ + +/************************************************************************ + * Structure used with ioctl commands for DIGI parameters. + ************************************************************************/ +struct digi_t { + unsigned short digi_flags; /* Flags (see above) */ + unsigned short digi_maxcps; /* Max printer CPS */ + unsigned short digi_maxchar; /* Max chars in print queue */ + unsigned short digi_bufsize; /* Buffer size */ + unsigned char digi_onlen; /* Length of ON string */ + unsigned char digi_offlen; /* Length of OFF string */ + char digi_onstr[DIGI_PLEN]; /* Printer on string */ + char digi_offstr[DIGI_PLEN]; /* Printer off string */ + char digi_term[DIGI_TSIZ]; /* terminal string */ +}; + +/************************************************************************ + * KME definitions and structures. + ************************************************************************/ +#define RW_IDLE 0 /* Operation complete */ +#define RW_READ 1 /* Read Concentrator Memory */ +#define RW_WRITE 2 /* Write Concentrator Memory */ + +struct rw_t { + unsigned char rw_req; /* Request type */ + unsigned char rw_board; /* Host Adapter board number */ + unsigned char rw_conc; /* Concentrator number */ + unsigned char rw_reserved; /* Reserved for expansion */ + unsigned int rw_addr; /* Address in concentrator */ + unsigned short rw_size; /* Read/write request length */ + unsigned char rw_data[128]; /* Data to read/write */ +}; + +/*********************************************************************** + * Shrink Buffer and Board Information definitions and structures. + + ************************************************************************/ + /* Board type return codes */ +#define PCXI_TYPE 1 /* Board type at the designated port is a PC/Xi */ +#define PCXM_TYPE 2 /* Board type at the designated port is a PC/Xm */ +#define PCXE_TYPE 3 /* Board type at the designated port is a PC/Xe */ +#define MCXI_TYPE 4 /* Board type at the designated port is a MC/Xi */ +#define COMXI_TYPE 5 /* Board type at the designated port is a COM/Xi */ + + /* Non-Zero Result codes. */ +#define RESULT_NOBDFND 1 /* A Digi product at that port is not config installed */ +#define RESULT_NODESCT 2 /* A memory descriptor was not obtainable */ +#define RESULT_NOOSSIG 3 /* FEP/OS signature was not detected on the board */ +#define RESULT_TOOSML 4 /* Too small an area to shrink. */ +#define RESULT_NOCHAN 5 /* Channel structure for the board was not found */ + +struct shrink_buf_struct { + unsigned int shrink_buf_vaddr; /* Virtual address of board */ + unsigned int shrink_buf_phys; /* Physical address of board */ + unsigned int shrink_buf_bseg; /* Amount of board memory */ + unsigned int shrink_buf_hseg; /* '186 Begining of Dual-Port */ + + unsigned int shrink_buf_lseg; /* '186 Begining of freed memory */ + unsigned int shrink_buf_mseg; /* Linear address from start of + dual-port were freed memory + begins, host viewpoint. */ + + unsigned int shrink_buf_bdparam; /* Parameter for xxmemon and + xxmemoff */ + + unsigned int shrink_buf_reserva; /* Reserved */ + unsigned int shrink_buf_reservb; /* Reserved */ + unsigned int shrink_buf_reservc; /* Reserved */ + unsigned int shrink_buf_reservd; /* Reserved */ + + unsigned char shrink_buf_result; /* Reason for call failing + Zero is Good return */ + unsigned char shrink_buf_init; /* Non-Zero if it caused an + xxinit call. */ + + unsigned char shrink_buf_anports; /* Number of async ports */ + unsigned char shrink_buf_snports; /* Number of sync ports */ + unsigned char shrink_buf_type; /* Board type 1 = PC/Xi, + 2 = PC/Xm, + 3 = PC/Xe + 4 = MC/Xi + 5 = COMX/i */ + unsigned char shrink_buf_card; /* Card number */ + +}; + +/************************************************************************ + * Structure to get driver status information + ************************************************************************/ +struct digi_dinfo { + unsigned int dinfo_nboards; /* # boards configured */ + char dinfo_reserved[12]; /* for future expansion */ + char dinfo_version[16]; /* driver version */ +}; + +#define DIGI_GETDD ('d'<<8) | 248 /* get driver info */ + +/************************************************************************ + * Structure used with ioctl commands for per-board information + * + * physsize and memsize differ when board has "windowed" memory + ************************************************************************/ +struct digi_info { + unsigned int info_bdnum; /* Board number (0 based) */ + unsigned int info_ioport; /* io port address */ + unsigned int info_physaddr; /* memory address */ + unsigned int info_physsize; /* Size of host mem window */ + unsigned int info_memsize; /* Amount of dual-port mem */ + /* on board */ + unsigned short info_bdtype; /* Board type */ + unsigned short info_nports; /* number of ports */ + char info_bdstate; /* board state */ + char info_reserved[7]; /* for future expansion */ +}; + +#define DIGI_GETBD ('d'<<8) | 249 /* get board info */ + +struct digi_stat { + unsigned int info_chan; /* Channel number (0 based) */ + unsigned int info_brd; /* Board number (0 based) */ + unsigned int info_cflag; /* cflag for channel */ + unsigned int info_iflag; /* iflag for channel */ + unsigned int info_oflag; /* oflag for channel */ + unsigned int info_mstat; /* mstat for channel */ + unsigned int info_tx_data; /* tx_data for channel */ + unsigned int info_rx_data; /* rx_data for channel */ + unsigned int info_hflow; /* hflow for channel */ + unsigned int info_reserved[8]; /* for future expansion */ +}; + +#define DIGI_GETSTAT ('d'<<8) | 244 /* get board info */ +/************************************************************************ + * + * Structure used with ioctl commands for per-channel information + * + ************************************************************************/ +struct digi_ch { + unsigned int info_bdnum; /* Board number (0 based) */ + unsigned int info_channel; /* Channel index number */ + unsigned int info_ch_cflag; /* Channel cflag */ + unsigned int info_ch_iflag; /* Channel iflag */ + unsigned int info_ch_oflag; /* Channel oflag */ + unsigned int info_chsize; /* Channel structure size */ + unsigned int info_sleep_stat; /* sleep status */ + dev_t info_dev; /* device number */ + unsigned char info_initstate; /* Channel init state */ + unsigned char info_running; /* Channel running state */ + int reserved[8]; /* reserved for future use */ +}; + +/* +* This structure is used with the DIGI_FEPCMD ioctl to +* tell the driver which port to send the command for. +*/ +struct digi_cmd { + int cmd; + int word; + int ncmds; + int chan; /* channel index (zero based) */ + int bdid; /* board index (zero based) */ +}; + + +struct digi_getbuffer /* Struct for holding buffer use counts */ +{ + unsigned long tIn; + unsigned long tOut; + unsigned long rxbuf; + unsigned long txbuf; + unsigned long txdone; +}; + +struct digi_getcounter +{ + unsigned long norun; /* number of UART overrun errors */ + unsigned long noflow; /* number of buffer overflow errors */ + unsigned long nframe; /* number of framing errors */ + unsigned long nparity; /* number of parity errors */ + unsigned long nbreak; /* number of breaks received */ + unsigned long rbytes; /* number of received bytes */ + unsigned long tbytes; /* number of bytes transmitted fully */ +}; + +/* +* info_sleep_stat defines +*/ +#define INFO_RUNWAIT 0x0001 +#define INFO_WOPEN 0x0002 +#define INFO_TTIOW 0x0004 +#define INFO_CH_RWAIT 0x0008 +#define INFO_CH_WEMPTY 0x0010 +#define INFO_CH_WLOW 0x0020 +#define INFO_XXBUF_BUSY 0x0040 + +#define DIGI_GETCH ('d'<<8) | 245 /* get board info */ + +/* Board type definitions */ + +#define SUBTYPE 0007 +#define T_PCXI 0000 +#define T_PCXM 0001 +#define T_PCXE 0002 +#define T_PCXR 0003 +#define T_SP 0004 +#define T_SP_PLUS 0005 +# define T_HERC 0000 +# define T_HOU 0001 +# define T_LON 0002 +# define T_CHA 0003 +#define FAMILY 0070 +#define T_COMXI 0000 +#define T_PCXX 0010 +#define T_CX 0020 +#define T_EPC 0030 +#define T_PCLITE 0040 +#define T_SPXX 0050 +#define T_AVXX 0060 +#define T_DXB 0070 +#define T_A2K_4_8 0070 +#define BUSTYPE 0700 +#define T_ISABUS 0000 +#define T_MCBUS 0100 +#define T_EISABUS 0200 +#define T_PCIBUS 0400 + +/* Board State Definitions */ + +#define BD_RUNNING 0x0 +#define BD_REASON 0x7f +#define BD_NOTFOUND 0x1 +#define BD_NOIOPORT 0x2 +#define BD_NOMEM 0x3 +#define BD_NOBIOS 0x4 +#define BD_NOFEP 0x5 +#define BD_FAILED 0x6 +#define BD_ALLOCATED 0x7 +#define BD_TRIBOOT 0x8 +#define BD_BADKME 0x80 + +#define DIGI_SPOLL ('d'<<8) | 254 /* change poller rate */ + +#define DIGI_SETCUSTOMBAUD _IOW('e', 106, int) /* Set integer baud rate */ +#define DIGI_GETCUSTOMBAUD _IOR('e', 107, int) /* Get integer baud rate */ + +#define DIGI_REALPORT_GETBUFFERS ('e'<<8 ) | 108 +#define DIGI_REALPORT_SENDIMMEDIATE ('e'<<8 ) | 109 +#define DIGI_REALPORT_GETCOUNTERS ('e'<<8 ) | 110 +#define DIGI_REALPORT_GETEVENTS ('e'<<8 ) | 111 + +#define EV_OPU 0x0001 //! + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! + */ + + +/* + * This structure holds data needed for the intelligent <--> nonintelligent + * DPA translation + */ + struct ni_info { + int board; + int channel; + int dtr; + int rts; + int cts; + int dsr; + int ri; + int dcd; + int curtx; + int currx; + unsigned short iflag; + unsigned short oflag; + unsigned short cflag; + unsigned short lflag; + + unsigned int mstat; + unsigned char hflow; + + unsigned char xmit_stopped; + unsigned char recv_stopped; + + unsigned int baud; +}; + +#define RW_READ 1 +#define RW_WRITE 2 +#define DIGI_KME ('e'<<8) | 98 /* Read/Write Host */ + +#define SUBTYPE 0007 +#define T_PCXI 0000 +#define T_PCXEM 0001 +#define T_PCXE 0002 +#define T_PCXR 0003 +#define T_SP 0004 +#define T_SP_PLUS 0005 + +#define T_HERC 0000 +#define T_HOU 0001 +#define T_LON 0002 +#define T_CHA 0003 + +#define T_NEO 0000 +#define T_NEO_EXPRESS 0001 +#define T_CLASSIC 0002 + +#define FAMILY 0070 +#define T_COMXI 0000 +#define T_NI 0000 +#define T_PCXX 0010 +#define T_CX 0020 +#define T_EPC 0030 +#define T_PCLITE 0040 +#define T_SPXX 0050 +#define T_AVXX 0060 +#define T_DXB 0070 +#define T_A2K_4_8 0070 + +#define BUSTYPE 0700 +#define T_ISABUS 0000 +#define T_MCBUS 0100 +#define T_EISABUS 0200 +#define T_PCIBUS 0400 + +/* Board State Definitions */ + +#define BD_RUNNING 0x0 +#define BD_REASON 0x7f +#define BD_NOTFOUND 0x1 +#define BD_NOIOPORT 0x2 +#define BD_NOMEM 0x3 +#define BD_NOBIOS 0x4 +#define BD_NOFEP 0x5 +#define BD_FAILED 0x6 +#define BD_ALLOCATED 0x7 +#define BD_TRIBOOT 0x8 +#define BD_BADKME 0x80 + +#define DIGI_AIXON 0x0400 /* Aux flow control in fep */ + +/* Ioctls needed for dpa operation */ + +#define DIGI_GETDD ('d'<<8) | 248 /* get driver info */ +#define DIGI_GETBD ('d'<<8) | 249 /* get board info */ +#define DIGI_GET_NI_INFO ('d'<<8) | 250 /* nonintelligent state snfo */ + +/* Other special ioctls */ +#define DIGI_TIMERIRQ ('d'<<8) | 251 /* Enable/disable RS_TIMER use */ +#define DIGI_LOOPBACK ('d'<<8) | 252 /* Enable/disable UART internal loopback */ -- GitLab From 64cb7ce9d4c44e96b54f9d8125817c9024031465 Mon Sep 17 00:00:00 2001 From: Jingoo Han Date: Thu, 1 Aug 2013 09:32:29 +0900 Subject: [PATCH 437/942] staging: imx-drm: add missing MFD_SYSCON dependency for LDB Added missing MFD_SYSCON dependency for LVDS display bridge in order to fix the following link error. drivers/staging/imx-drm/imx-ldb.c:484: undefined reference to `syscon_regmap_lookup_by_phandle' Signed-off-by: Jingoo Han Acked-by: Philipp Zabel Signed-off-by: Greg Kroah-Hartman --- drivers/staging/imx-drm/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/imx-drm/Kconfig b/drivers/staging/imx-drm/Kconfig index 0f75afcc03c4b..394254f7d6b54 100644 --- a/drivers/staging/imx-drm/Kconfig +++ b/drivers/staging/imx-drm/Kconfig @@ -32,7 +32,7 @@ config DRM_IMX_TVE config DRM_IMX_LDB tristate "Support for LVDS displays" - depends on DRM_IMX + depends on DRM_IMX && MFD_SYSCON help Choose this to enable the internal LVDS Display Bridge (LDB) found on i.MX53 and i.MX6 processors. -- GitLab From 8a3cac62efd0c447e017180aa7bf2638603ee21c Mon Sep 17 00:00:00 2001 From: Rupesh Gujare Date: Thu, 1 Aug 2013 18:40:00 +0100 Subject: [PATCH 438/942] staging: ozwpan: Use kernel list function for managing interface list. Managing interface list, is easier if we use kernel list_* API than managing it on our own. Signed-off-by: Rupesh Gujare Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozproto.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/drivers/staging/ozwpan/ozproto.c b/drivers/staging/ozwpan/ozproto.c index ed22729ea90d2..500800f9f0ee7 100644 --- a/drivers/staging/ozwpan/ozproto.c +++ b/drivers/staging/ozwpan/ozproto.c @@ -37,7 +37,7 @@ struct oz_binding { struct packet_type ptype; char name[OZ_MAX_BINDING_LEN]; - struct oz_binding *next; + struct list_head link; }; /*------------------------------------------------------------------------------ @@ -45,7 +45,7 @@ struct oz_binding { */ static DEFINE_SPINLOCK(g_polling_lock); static LIST_HEAD(g_pd_list); -static struct oz_binding *g_binding ; +static LIST_HEAD(g_binding); static DEFINE_SPINLOCK(g_binding_lock); static struct sk_buff_head g_rx_queue; static u8 g_session_id; @@ -437,12 +437,13 @@ static void oz_rx_frame(struct sk_buff *skb) */ void oz_protocol_term(void) { + struct oz_binding *b, *t; + /* Walk the list of bindings and remove each one. */ spin_lock_bh(&g_binding_lock); - while (g_binding) { - struct oz_binding *b = g_binding; - g_binding = b->next; + list_for_each_entry_safe(b, t, &g_binding, link) { + list_del(&b->link); spin_unlock_bh(&g_binding_lock); dev_remove_pack(&b->ptype); if (b->ptype.dev) @@ -660,8 +661,7 @@ void oz_binding_add(char *net_dev) if (binding) { dev_add_pack(&binding->ptype); spin_lock_bh(&g_binding_lock); - binding->next = g_binding; - g_binding = binding; + list_add_tail(&binding->link, &g_binding); spin_unlock_bh(&g_binding_lock); } } @@ -710,28 +710,25 @@ static void pd_stop_all_for_device(struct net_device *net_dev) void oz_binding_remove(char *net_dev) { struct oz_binding *binding; - struct oz_binding **link; + int found = 0; + oz_dbg(ON, "Removing binding: %s\n", net_dev); spin_lock_bh(&g_binding_lock); - binding = g_binding; - link = &g_binding; - while (binding) { + list_for_each_entry(binding, &g_binding, link) { if (compare_binding_name(binding->name, net_dev)) { oz_dbg(ON, "Binding '%s' found\n", net_dev); - *link = binding->next; + found = 1; break; - } else { - link = &binding; - binding = binding->next; } } spin_unlock_bh(&g_binding_lock); - if (binding) { + if (found) { dev_remove_pack(&binding->ptype); if (binding->ptype.dev) { dev_put(binding->ptype.dev); pd_stop_all_for_device(binding->ptype.dev); } + list_del(&binding->link); kfree(binding); } } -- GitLab From 83e4817fc3a2092ac1545999705b799bea855bcb Mon Sep 17 00:00:00 2001 From: Rupesh Gujare Date: Thu, 1 Aug 2013 18:40:01 +0100 Subject: [PATCH 439/942] staging: ozwpan: Mark string as const Make sure that we mark const string so that it does not get modified. Signed-off-by: Rupesh Gujare Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozproto.c | 6 +++--- drivers/staging/ozwpan/ozproto.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/ozwpan/ozproto.c b/drivers/staging/ozwpan/ozproto.c index 500800f9f0ee7..2dbaba636e710 100644 --- a/drivers/staging/ozwpan/ozproto.c +++ b/drivers/staging/ozwpan/ozproto.c @@ -636,7 +636,7 @@ static int oz_pkt_recv(struct sk_buff *skb, struct net_device *dev, /*------------------------------------------------------------------------------ * Context: process */ -void oz_binding_add(char *net_dev) +void oz_binding_add(const char *net_dev) { struct oz_binding *binding; @@ -669,7 +669,7 @@ void oz_binding_add(char *net_dev) /*------------------------------------------------------------------------------ * Context: process */ -static int compare_binding_name(char *s1, char *s2) +static int compare_binding_name(const char *s1, const char *s2) { int i; for (i = 0; i < OZ_MAX_BINDING_LEN; i++) { @@ -707,7 +707,7 @@ static void pd_stop_all_for_device(struct net_device *net_dev) /*------------------------------------------------------------------------------ * Context: process */ -void oz_binding_remove(char *net_dev) +void oz_binding_remove(const char *net_dev) { struct oz_binding *binding; int found = 0; diff --git a/drivers/staging/ozwpan/ozproto.h b/drivers/staging/ozwpan/ozproto.h index 305c5321022db..e532347cfdfda 100644 --- a/drivers/staging/ozwpan/ozproto.h +++ b/drivers/staging/ozwpan/ozproto.h @@ -54,8 +54,8 @@ void oz_protocol_term(void); int oz_get_pd_list(struct oz_mac_addr *addr, int max_count); void oz_app_enable(int app_id, int enable); struct oz_pd *oz_pd_find(const u8 *mac_addr); -void oz_binding_add(char *net_dev); -void oz_binding_remove(char *net_dev); +void oz_binding_add(const char *net_dev); +void oz_binding_remove(const char *net_dev); void oz_timer_add(struct oz_pd *pd, int type, unsigned long due_time); void oz_timer_delete(struct oz_pd *pd, int type); void oz_pd_request_heartbeat(struct oz_pd *pd); -- GitLab From 4d6c9e57027940b6b492abac4c1b67710e38f366 Mon Sep 17 00:00:00 2001 From: Rupesh Gujare Date: Thu, 1 Aug 2013 18:40:02 +0100 Subject: [PATCH 440/942] staging: ozwpan: Use kernel strncmp function. Use kernel's strncmp() function instead of defining same within driver. Signed-off-by: Rupesh Gujare Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozproto.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/drivers/staging/ozwpan/ozproto.c b/drivers/staging/ozwpan/ozproto.c index 2dbaba636e710..ec602863fecac 100644 --- a/drivers/staging/ozwpan/ozproto.c +++ b/drivers/staging/ozwpan/ozproto.c @@ -666,21 +666,6 @@ void oz_binding_add(const char *net_dev) } } } -/*------------------------------------------------------------------------------ - * Context: process - */ -static int compare_binding_name(const char *s1, const char *s2) -{ - int i; - for (i = 0; i < OZ_MAX_BINDING_LEN; i++) { - if (*s1 != *s2) - return 0; - if (!*s1++) - return 1; - s2++; - } - return 1; -} /*------------------------------------------------------------------------------ * Context: process */ @@ -715,7 +700,7 @@ void oz_binding_remove(const char *net_dev) oz_dbg(ON, "Removing binding: %s\n", net_dev); spin_lock_bh(&g_binding_lock); list_for_each_entry(binding, &g_binding, link) { - if (compare_binding_name(binding->name, net_dev)) { + if (strncmp(binding->name, net_dev, OZ_MAX_BINDING_LEN) == 0) { oz_dbg(ON, "Binding '%s' found\n", net_dev); found = 1; break; -- GitLab From 2dc2ee5ccdaf88b41bf9c025acf14ebdc2959a21 Mon Sep 17 00:00:00 2001 From: Rupesh Gujare Date: Thu, 1 Aug 2013 18:40:03 +0100 Subject: [PATCH 441/942] staging: ozwpan: Drop oldest ISOC frame instead of dropping latest. In case of ISOC transfer, if TX queue is full then we start dropping latest frame, instead we should drop oldest frame & add latest frame to TX queue. Signed-off-by: Rupesh Gujare Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozpd.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/staging/ozwpan/ozpd.c b/drivers/staging/ozwpan/ozpd.c index 86876bda29a5f..17fd7b2aa88e4 100644 --- a/drivers/staging/ozwpan/ozpd.c +++ b/drivers/staging/ozwpan/ozpd.c @@ -844,9 +844,20 @@ int oz_send_isoc_unit(struct oz_pd *pd, u8 ep_num, const u8 *data, int len) struct oz_tx_frame *isoc_unit = NULL; int nb = pd->nb_queued_isoc_frames; if (nb >= pd->isoc_latency) { + struct list_head *e; + struct oz_tx_frame *f; oz_dbg(TX_FRAMES, "Dropping ISOC Unit nb= %d\n", nb); - goto out; + spin_lock(&pd->tx_frame_lock); + list_for_each(e, &pd->tx_queue) { + f = container_of(e, struct oz_tx_frame, + link); + if (f->skb != NULL) { + oz_tx_isoc_free(pd, f); + break; + } + } + spin_unlock(&pd->tx_frame_lock); } isoc_unit = oz_tx_frame_alloc(pd); if (isoc_unit == NULL) -- GitLab From baaaef1383d3708f02b2316d2d6f2bda0980fad7 Mon Sep 17 00:00:00 2001 From: Rupesh Gujare Date: Thu, 1 Aug 2013 18:45:01 +0100 Subject: [PATCH 442/942] staging: ozwpan: Increase farewell report size. Farewell report size can be bigger than one byte, increase array size to accomodate maximum 32 bytes of farewell report. Signed-off-by: Rupesh Gujare Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozpd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/ozwpan/ozpd.h b/drivers/staging/ozwpan/ozpd.h index a281753774e63..57e98c897711e 100644 --- a/drivers/staging/ozwpan/ozpd.h +++ b/drivers/staging/ozwpan/ozpd.h @@ -48,7 +48,7 @@ struct oz_farewell { struct list_head link; u8 ep_num; u8 index; - u8 report[1]; + u8 report[32]; u8 len; }; -- GitLab From b50c460a6c03284f7e1b4cfe9266df0f9169ad24 Mon Sep 17 00:00:00 2001 From: Rupesh Gujare Date: Thu, 1 Aug 2013 18:45:02 +0100 Subject: [PATCH 443/942] staging: ozwpan: Set farewell report length. Fixes a bug where we were not setting length field causing wrong report size to be copied. Signed-off-by: Rupesh Gujare Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozproto.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/ozwpan/ozproto.c b/drivers/staging/ozwpan/ozproto.c index ec602863fecac..084307a1083f1 100644 --- a/drivers/staging/ozwpan/ozproto.c +++ b/drivers/staging/ozwpan/ozproto.c @@ -296,6 +296,7 @@ static void oz_add_farewell(struct oz_pd *pd, u8 ep_num, u8 index, return; f->ep_num = ep_num; f->index = index; + f->len = len; memcpy(f->report, report, len); oz_dbg(ON, "RX: Adding farewell report\n"); spin_lock(&g_polling_lock); -- GitLab From 49126e47bf418081a4eb3686a8c736ca80da152c Mon Sep 17 00:00:00 2001 From: Xiong Zhou Date: Fri, 2 Aug 2013 13:50:48 +0800 Subject: [PATCH 444/942] staging/lustre: lloop depends on BLOCK MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a config option for llite/lloop in lustre driver, making it depends on BLOCK to fix this better: drivers/staging/lustre/lustre/fid/../include/linux/lustre_compat25.h:117:2: error: implicit declaration of function ‘unregister_blkdev' Also, remove the wrapper ll_unregister_blkdev which depends on BLOCK in the header and just call unregister_blkdev in lloop.c based on Peng Tao's comment. Drop the redundant dependency on STAGING for LUSTRE_FS, remove some unnecessary jdb header files which depends on BLOCK btw. Signed-off-by: Xiong Zhou Reviewed-by: Peng Tao Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/Kconfig | 7 ++++++- drivers/staging/lustre/lustre/fld/fld_cache.c | 1 - drivers/staging/lustre/lustre/fld/fld_request.c | 1 - .../staging/lustre/lustre/include/linux/lustre_compat25.h | 7 ------- drivers/staging/lustre/lustre/llite/Makefile | 2 +- drivers/staging/lustre/lustre/llite/lloop.c | 6 ++---- drivers/staging/lustre/lustre/lvfs/fsfilt.c | 1 - 7 files changed, 9 insertions(+), 16 deletions(-) diff --git a/drivers/staging/lustre/lustre/Kconfig b/drivers/staging/lustre/lustre/Kconfig index 0b45de0726f65..4e898e4918605 100644 --- a/drivers/staging/lustre/lustre/Kconfig +++ b/drivers/staging/lustre/lustre/Kconfig @@ -1,6 +1,6 @@ config LUSTRE_FS tristate "Lustre file system client support" - depends on STAGING && INET && BLOCK && m + depends on INET && m select LNET select CRYPTO select CRYPTO_CRC32 @@ -53,3 +53,8 @@ config LUSTRE_TRANSLATE_ERRNOS bool depends on LUSTRE_FS && !X86 default true + +config LUSTRE_LLITE_LLOOP + bool "Lustre virtual block device" + depends on LUSTRE_FS && BLOCK + default m diff --git a/drivers/staging/lustre/lustre/fld/fld_cache.c b/drivers/staging/lustre/lustre/fld/fld_cache.c index 347f2ae83bc8c..84101076a6560 100644 --- a/drivers/staging/lustre/lustre/fld/fld_cache.c +++ b/drivers/staging/lustre/lustre/fld/fld_cache.c @@ -45,7 +45,6 @@ # include # include -# include # include #include diff --git a/drivers/staging/lustre/lustre/fld/fld_request.c b/drivers/staging/lustre/lustre/fld/fld_request.c index c99b945cc8ef1..049322a791402 100644 --- a/drivers/staging/lustre/lustre/fld/fld_request.c +++ b/drivers/staging/lustre/lustre/fld/fld_request.c @@ -44,7 +44,6 @@ # include # include -# include # include #include diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h index 426533b5d1352..018e604490b78 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h @@ -111,13 +111,6 @@ static inline void ll_set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt, #define TREE_READ_LOCK_IRQ(mapping) spin_lock_irq(&(mapping)->tree_lock) #define TREE_READ_UNLOCK_IRQ(mapping) spin_unlock_irq(&(mapping)->tree_lock) -static inline -int ll_unregister_blkdev(unsigned int dev, const char *name) -{ - unregister_blkdev(dev, name); - return 0; -} - #define ll_invalidate_bdev(a,b) invalidate_bdev((a)) #ifndef FS_HAS_FIEMAP diff --git a/drivers/staging/lustre/lustre/llite/Makefile b/drivers/staging/lustre/lustre/llite/Makefile index dff0c0486e778..f493e0740004a 100644 --- a/drivers/staging/lustre/lustre/llite/Makefile +++ b/drivers/staging/lustre/lustre/llite/Makefile @@ -1,5 +1,5 @@ obj-$(CONFIG_LUSTRE_FS) += lustre.o -obj-$(CONFIG_LUSTRE_FS) += llite_lloop.o +obj-$(CONFIG_LUSTRE_LLITE_LLOOP) += llite_lloop.o lustre-y := dcache.o dir.o file.o llite_close.o llite_lib.o llite_nfs.o \ rw.o lproc_llite.o namei.o symlink.o llite_mmap.o \ xattr.o remote_perm.o llite_rmtacl.o llite_capa.o \ diff --git a/drivers/staging/lustre/lustre/llite/lloop.c b/drivers/staging/lustre/lustre/llite/lloop.c index e063efc23af91..ae3dc9d5b484c 100644 --- a/drivers/staging/lustre/lustre/llite/lloop.c +++ b/drivers/staging/lustre/lustre/llite/lloop.c @@ -848,10 +848,8 @@ static void lloop_exit(void) blk_cleanup_queue(loop_dev[i].lo_queue); put_disk(disks[i]); } - if (ll_unregister_blkdev(lloop_major, "lloop")) - CWARN("lloop: cannot unregister blkdev\n"); - else - CDEBUG(D_CONFIG, "unregistered lloop major %d\n", lloop_major); + + unregister_blkdev(lloop_major, "lloop"); OBD_FREE(disks, max_loop * sizeof(*disks)); OBD_FREE(loop_dev, max_loop * sizeof(*loop_dev)); diff --git a/drivers/staging/lustre/lustre/lvfs/fsfilt.c b/drivers/staging/lustre/lustre/lvfs/fsfilt.c index 064445cbdb572..ce71f805c6de8 100644 --- a/drivers/staging/lustre/lustre/lvfs/fsfilt.c +++ b/drivers/staging/lustre/lustre/lvfs/fsfilt.c @@ -35,7 +35,6 @@ #define DEBUG_SUBSYSTEM S_FILTER #include -#include #include #include #include -- GitLab From 418690b60f04a0047f50f8650dc974dabeba195d Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 2 Aug 2013 15:46:32 +0800 Subject: [PATCH 445/942] staging: lustre: remove ll_blkdev_put() It was a wrapper around blkdev_put(), totally useless. Cc: Peng Tao Cc: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/lustre/include/linux/lustre_compat25.h | 2 -- drivers/staging/lustre/lustre/llite/lloop.c | 6 +++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h index 018e604490b78..968cf7381a31c 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h @@ -92,8 +92,6 @@ static inline void ll_set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt, # define ll_generic_permission(inode, mask, flags, check_acl) \ generic_permission(inode, mask) -#define ll_blkdev_put(a, b) blkdev_put(a, b) - #define ll_dentry_open(a,b,c) dentry_open(a,b,c) #define ll_vfs_symlink(dir, dentry, mnt, path, mode) \ diff --git a/drivers/staging/lustre/lustre/llite/lloop.c b/drivers/staging/lustre/lustre/llite/lloop.c index ae3dc9d5b484c..83743c9d5333e 100644 --- a/drivers/staging/lustre/lustre/llite/lloop.c +++ b/drivers/staging/lustre/lustre/llite/lloop.c @@ -617,7 +617,7 @@ static int lo_ioctl(struct block_device *bdev, fmode_t mode, case LL_IOC_LLOOP_DETACH: { err = loop_clr_fd(lo, bdev, 2); if (err == 0) - ll_blkdev_put(bdev, 0); /* grabbed in LLOOP_ATTACH */ + blkdev_put(bdev, 0); /* grabbed in LLOOP_ATTACH */ break; } @@ -712,7 +712,7 @@ static enum llioc_iter lloop_ioctl(struct inode *unused, struct file *file, err = loop_set_fd(lo, NULL, bdev, file); if (err) { fput(file); - ll_blkdev_put(bdev, 0); + blkdev_put(bdev, 0); } break; @@ -736,7 +736,7 @@ static enum llioc_iter lloop_ioctl(struct inode *unused, struct file *file, bdev = lo->lo_device; err = loop_clr_fd(lo, bdev, 1); if (err == 0) - ll_blkdev_put(bdev, 0); /* grabbed in LLOOP_ATTACH */ + blkdev_put(bdev, 0); /* grabbed in LLOOP_ATTACH */ break; } -- GitLab From dd4c3a486bdc5e01a007144b92c85a2d393f8161 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 2 Aug 2013 15:51:34 +0800 Subject: [PATCH 446/942] staging: lustre: remove ll_dentry_open() It was a wrapper around dentry_open(), totally useless. Cc: Peng Tao Cc: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/linux/lustre_compat25.h | 2 -- drivers/staging/lustre/lustre/lvfs/lvfs_linux.c | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h index 968cf7381a31c..ac8f939fdaf35 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h @@ -92,8 +92,6 @@ static inline void ll_set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt, # define ll_generic_permission(inode, mask, flags, check_acl) \ generic_permission(inode, mask) -#define ll_dentry_open(a,b,c) dentry_open(a,b,c) - #define ll_vfs_symlink(dir, dentry, mnt, path, mode) \ vfs_symlink(dir, dentry, path) diff --git a/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c b/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c index 0f387913d6ff5..d342e976317b2 100644 --- a/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c +++ b/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c @@ -238,7 +238,7 @@ struct l_file *l_dentry_open(struct lvfs_run_ctxt *ctxt, struct l_dentry *de, .dentry = de, .mnt = ctxt->pwdmnt, }; - return ll_dentry_open(&path, flags, current_cred()); + return dentry_open(&path, flags, current_cred()); } EXPORT_SYMBOL(l_dentry_open); -- GitLab From 6f014339718fac7597a53d155a2aa1714091a9af Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 2 Aug 2013 15:56:22 +0800 Subject: [PATCH 447/942] staging: lustre: remove ll_generic_file_llseek_size() It was a wrapper around generic_file_llseek_size(), totally useless. Cc: Peng Tao Cc: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/linux/lustre_compat25.h | 4 ---- drivers/staging/lustre/lustre/llite/file.c | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h index ac8f939fdaf35..868f0742c77bc 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h @@ -95,10 +95,6 @@ static inline void ll_set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt, #define ll_vfs_symlink(dir, dentry, mnt, path, mode) \ vfs_symlink(dir, dentry, path) - -#define ll_generic_file_llseek_size(file, offset, origin, maxbytes, eof) \ - generic_file_llseek_size(file, offset, origin, maxbytes, eof); - /* inode_dio_wait(i) use as-is for write lock */ # define inode_dio_write_done(i) do {} while (0) /* for write unlock */ # define inode_dio_read(i) atomic_inc(&(i)->i_dio_count) diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index b1df7f52ffec7..56bd326e7221e 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -2147,7 +2147,7 @@ loff_t ll_file_seek(struct file *file, loff_t offset, int origin) eof = i_size_read(inode); } - retval = ll_generic_file_llseek_size(file, offset, origin, + retval = generic_file_llseek_size(file, offset, origin, ll_file_maxbytes(inode), eof); RETURN(retval); } -- GitLab From 9c5fb72cc87a00262207d243aeb93e9c61f33573 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 2 Aug 2013 16:01:26 +0800 Subject: [PATCH 448/942] staging: lustre: remove ll_permission() It was a wrapper around inode_permission(), totally useless. Cc: Peng Tao Cc: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/linux/lustre_compat25.h | 2 -- drivers/staging/lustre/lustre/llite/file.c | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h index 868f0742c77bc..65c7dd8eb9656 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h @@ -87,8 +87,6 @@ static inline void ll_set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt, #define LTIME_S(time) (time.tv_sec) -#define ll_permission(inode,mask,nd) inode_permission(inode,mask) - # define ll_generic_permission(inode, mask, flags, check_acl) \ generic_permission(inode, mask) diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 56bd326e7221e..0a6d28f7fb581 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -1756,8 +1756,8 @@ static int ll_swap_layouts(struct file *file1, struct file *file2, if (!S_ISREG(llss->inode2->i_mode)) GOTO(free, rc = -EINVAL); - if (ll_permission(llss->inode1, MAY_WRITE, NULL) || - ll_permission(llss->inode2, MAY_WRITE, NULL)) + if (inode_permission(llss->inode1, MAY_WRITE) || + inode_permission(llss->inode2, MAY_WRITE)) GOTO(free, rc = -EPERM); if (llss->inode2->i_sb != llss->inode1->i_sb) -- GitLab From 8707c96e960d34f9dfee15240b1797084512fcef Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 2 Aug 2013 16:08:01 +0800 Subject: [PATCH 449/942] staging: lustre: remove ll_generic_permission() It was a wrapper around generic_permission(), totally useless. Cc: Peng Tao Cc: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/linux/lustre_compat25.h | 3 --- drivers/staging/lustre/lustre/llite/file.c | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h index 65c7dd8eb9656..b44bc03c5b9e1 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h @@ -87,9 +87,6 @@ static inline void ll_set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt, #define LTIME_S(time) (time.tv_sec) -# define ll_generic_permission(inode, mask, flags, check_acl) \ - generic_permission(inode, mask) - #define ll_vfs_symlink(dir, dentry, mnt, path, mode) \ vfs_symlink(dir, dentry, path) diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 0a6d28f7fb581..20416fcf2e9c3 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -2721,7 +2721,7 @@ int ll_inode_permission(struct inode *inode, int mask) return lustre_check_remote_perm(inode, mask); ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_INODE_PERM, 1); - rc = ll_generic_permission(inode, mask, flags, ll_check_acl); + rc = generic_permission(inode, mask); RETURN(rc); } -- GitLab From 077069aec22866a20a466beb2f65afa42957b78e Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 2 Aug 2013 16:11:35 +0800 Subject: [PATCH 450/942] staging: lustre: remove ll_vfs_symlink() No one was ever even using it. Cc: Peng Tao Cc: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/linux/lustre_compat25.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h index b44bc03c5b9e1..8691aee0b4d44 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h @@ -87,9 +87,6 @@ static inline void ll_set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt, #define LTIME_S(time) (time.tv_sec) -#define ll_vfs_symlink(dir, dentry, mnt, path, mode) \ - vfs_symlink(dir, dentry, path) - /* inode_dio_wait(i) use as-is for write lock */ # define inode_dio_write_done(i) do {} while (0) /* for write unlock */ # define inode_dio_read(i) atomic_inc(&(i)->i_dio_count) -- GitLab From db7392c2fb2fb149a5c9243f4189748b445bc1a3 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 2 Aug 2013 16:17:04 +0800 Subject: [PATCH 451/942] staging: lustre: remove ll_invalidate_bdev() It was a wrapper around invalidate_bdev(), totally useless. Cc: Peng Tao Cc: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/include/linux/lustre_compat25.h | 2 -- drivers/staging/lustre/lustre/llite/lloop.c | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h index 8691aee0b4d44..6f2707275e5d4 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h @@ -95,8 +95,6 @@ static inline void ll_set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt, #define TREE_READ_LOCK_IRQ(mapping) spin_lock_irq(&(mapping)->tree_lock) #define TREE_READ_UNLOCK_IRQ(mapping) spin_unlock_irq(&(mapping)->tree_lock) -#define ll_invalidate_bdev(a,b) invalidate_bdev((a)) - #ifndef FS_HAS_FIEMAP #define FS_HAS_FIEMAP (0) #endif diff --git a/drivers/staging/lustre/lustre/llite/lloop.c b/drivers/staging/lustre/lustre/llite/lloop.c index 83743c9d5333e..2340458b8a04e 100644 --- a/drivers/staging/lustre/lustre/llite/lloop.c +++ b/drivers/staging/lustre/lustre/llite/lloop.c @@ -573,7 +573,7 @@ static int loop_clr_fd(struct lloop_device *lo, struct block_device *bdev, lo->lo_offset = 0; lo->lo_sizelimit = 0; lo->lo_flags = 0; - ll_invalidate_bdev(bdev, 0); + invalidate_bdev(bdev); set_capacity(disks[lo->lo_number], 0); bd_set_size(bdev, 0); mapping_set_gfp_mask(filp->f_mapping, gfp); -- GitLab From 20fbff1dfd9abcb15e368627986e1fed08b44ebe Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 2 Aug 2013 16:24:50 +0800 Subject: [PATCH 452/942] staging: lustre: remove ENTRY/EXIT_NESTING stuff These macros were empty, so remove them in anticipation of removing the entire ENTRY/EXIT macros. Cc: Peng Tao Cc: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h | 5 ----- drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h | 3 --- 2 files changed, 8 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h index dd8ac2f52c9f8..07082dc6fd861 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h @@ -272,7 +272,6 @@ long libcfs_log_return(struct libcfs_debug_msg_data *, long rc); #if BITS_PER_LONG > 32 #define RETURN(rc) \ do { \ - EXIT_NESTING; \ if (cfs_cdebug_show(D_TRACE, DEBUG_SUBSYSTEM)) { \ LIBCFS_DEBUG_MSG_DATA_DECL(msgdata, D_TRACE, NULL); \ return (typeof(rc))libcfs_log_return(&msgdata, \ @@ -289,7 +288,6 @@ do { \ */ #define RETURN(rc) \ do { \ - EXIT_NESTING; \ if (cfs_cdebug_show(D_TRACE, DEBUG_SUBSYSTEM)) { \ typeof(rc) __rc = (rc); \ LIBCFS_DEBUG_MSG_DATA_DECL(msgdata, D_TRACE, NULL); \ @@ -305,7 +303,6 @@ do { \ #define RETURN(rc) \ do { \ CDEBUG(D_TRACE, "Process leaving.\n"); \ - EXIT_NESTING; \ return (rc); \ } while (0) #else @@ -313,7 +310,6 @@ do { \ #endif /* __GNUC__ */ #define ENTRY \ -ENTRY_NESTING; \ do { \ CDEBUG(D_TRACE, "Process entered\n"); \ } while (0) @@ -321,7 +317,6 @@ do { \ #define EXIT \ do { \ CDEBUG(D_TRACE, "Process leaving\n"); \ - EXIT_NESTING; \ } while(0) #define RETURN_EXIT \ diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h index 292a3ba1fb96c..60ecaf63f9fb1 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h @@ -97,9 +97,6 @@ do { \ /* initial pid */ #define LUSTRE_LNET_PID 12345 -#define ENTRY_NESTING_SUPPORT (1) -#define ENTRY_NESTING do {;} while (0) -#define EXIT_NESTING do {;} while (0) #define __current_nesting_level() (0) /** -- GitLab From 29aaf4962a3bce337d37176858ef1025b9f29cc4 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 2 Aug 2013 18:14:51 +0800 Subject: [PATCH 453/942] staging: lustre: remove ENTRY macro We have a kernel-wide function tracing system, so use that instead of rolling a custom one just for one filesystem. Cc: Peng Tao Cc: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../include/linux/libcfs/libcfs_debug.h | 5 - .../lustre/lnet/klnds/socklnd/socklnd_cb.c | 4 - .../lnet/klnds/socklnd/socklnd_lib-linux.c | 1 - drivers/staging/lustre/lnet/lnet/lib-eq.c | 2 - drivers/staging/lustre/lnet/lnet/lib-msg.c | 2 - drivers/staging/lustre/lnet/lnet/module.c | 1 - .../staging/lustre/lustre/fid/fid_request.c | 12 -- drivers/staging/lustre/lustre/fid/lproc_fid.c | 7 - drivers/staging/lustre/lustre/fld/fld_cache.c | 10 -- .../staging/lustre/lustre/fld/fld_request.c | 12 +- drivers/staging/lustre/lustre/fld/lproc_fld.c | 4 - .../lustre/lustre/include/lustre_cfg.h | 5 +- .../lustre/lustre/include/lustre_lib.h | 2 - .../lustre/lustre/include/lustre_log.h | 8 -- .../lustre/lustre/include/lustre_mdc.h | 2 - .../staging/lustre/lustre/include/obd_class.h | 128 +++--------------- .../staging/lustre/lustre/lclient/glimpse.c | 5 - .../lustre/lustre/lclient/lcommon_cl.c | 12 -- .../lustre/lustre/lclient/lcommon_misc.c | 2 - .../lustre/lustre/ldlm/interval_tree.c | 16 --- .../staging/lustre/lustre/ldlm/ldlm_extent.c | 2 - .../staging/lustre/lustre/ldlm/ldlm_flock.c | 8 -- drivers/staging/lustre/lustre/ldlm/ldlm_lib.c | 10 -- .../staging/lustre/lustre/ldlm/ldlm_lock.c | 38 +----- .../staging/lustre/lustre/ldlm/ldlm_lockd.c | 18 +-- .../staging/lustre/lustre/ldlm/ldlm_pool.c | 10 -- .../staging/lustre/lustre/ldlm/ldlm_request.c | 36 +---- .../lustre/lustre/ldlm/ldlm_resource.c | 7 +- drivers/staging/lustre/lustre/libcfs/debug.c | 1 - drivers/staging/lustre/lustre/libcfs/hash.c | 8 -- .../lustre/lustre/libcfs/kernel_user_comm.c | 3 - .../lustre/lustre/libcfs/libcfs_string.c | 1 - .../lustre/libcfs/linux/linux-curproc.c | 1 - .../lustre/lustre/libcfs/linux/linux-debug.c | 3 - .../lustre/lustre/libcfs/linux/linux-module.c | 1 - drivers/staging/lustre/lustre/libcfs/module.c | 4 - .../staging/lustre/lustre/libcfs/nidstrings.c | 2 - .../lustre/lustre/libcfs/upcall_cache.c | 7 - drivers/staging/lustre/lustre/llite/dcache.c | 13 +- drivers/staging/lustre/lustre/llite/dir.c | 14 -- drivers/staging/lustre/lustre/llite/file.c | 51 ------- .../staging/lustre/lustre/llite/llite_capa.c | 6 - .../staging/lustre/lustre/llite/llite_close.c | 8 -- .../staging/lustre/lustre/llite/llite_lib.c | 22 --- .../staging/lustre/lustre/llite/llite_mmap.c | 8 -- .../staging/lustre/lustre/llite/llite_nfs.c | 5 - .../staging/lustre/lustre/llite/lproc_llite.c | 2 - drivers/staging/lustre/lustre/llite/namei.c | 20 +-- .../staging/lustre/lustre/llite/remote_perm.c | 3 - drivers/staging/lustre/lustre/llite/rw.c | 12 -- drivers/staging/lustre/lustre/llite/rw26.c | 3 - .../staging/lustre/lustre/llite/statahead.c | 15 -- drivers/staging/lustre/lustre/llite/symlink.c | 3 - drivers/staging/lustre/lustre/llite/vvp_dev.c | 1 - drivers/staging/lustre/lustre/llite/vvp_io.c | 12 -- .../staging/lustre/lustre/llite/vvp_lock.c | 1 - .../staging/lustre/lustre/llite/vvp_page.c | 3 - drivers/staging/lustre/lustre/llite/xattr.c | 2 - drivers/staging/lustre/lustre/lmv/lmv_fld.c | 2 - .../staging/lustre/lustre/lmv/lmv_intent.c | 4 - drivers/staging/lustre/lustre/lmv/lmv_obd.c | 54 -------- drivers/staging/lustre/lustre/lov/lov_dev.c | 5 - drivers/staging/lustre/lustre/lov/lov_io.c | 27 +--- drivers/staging/lustre/lustre/lov/lov_lock.c | 29 ---- drivers/staging/lustre/lustre/lov/lov_log.c | 6 - drivers/staging/lustre/lustre/lov/lov_merge.c | 2 - drivers/staging/lustre/lustre/lov/lov_obd.c | 44 +----- .../staging/lustre/lustre/lov/lov_object.c | 17 --- .../staging/lustre/lustre/lov/lov_offset.c | 1 - drivers/staging/lustre/lustre/lov/lov_pack.c | 7 - drivers/staging/lustre/lustre/lov/lov_page.c | 5 - drivers/staging/lustre/lustre/lov/lov_pool.c | 11 -- .../staging/lustre/lustre/lov/lov_request.c | 32 ----- .../staging/lustre/lustre/lov/lovsub_dev.c | 4 - .../staging/lustre/lustre/lov/lovsub_lock.c | 13 -- .../staging/lustre/lustre/lov/lovsub_object.c | 5 - .../staging/lustre/lustre/lov/lovsub_page.c | 1 - .../staging/lustre/lustre/lvfs/lvfs_linux.c | 1 - drivers/staging/lustre/lustre/mdc/lproc_mdc.c | 1 - drivers/staging/lustre/lustre/mdc/mdc_lib.c | 2 +- drivers/staging/lustre/lustre/mdc/mdc_locks.c | 19 +-- drivers/staging/lustre/lustre/mdc/mdc_reint.c | 6 - .../staging/lustre/lustre/mdc/mdc_request.c | 49 +------ drivers/staging/lustre/lustre/mgc/libmgc.c | 5 - .../staging/lustre/lustre/mgc/mgc_request.c | 33 ----- drivers/staging/lustre/lustre/obdclass/acl.c | 4 - drivers/staging/lustre/lustre/obdclass/capa.c | 2 - .../staging/lustre/lustre/obdclass/cl_io.c | 55 -------- .../staging/lustre/lustre/obdclass/cl_lock.c | 53 +------- .../lustre/lustre/obdclass/cl_object.c | 8 -- .../staging/lustre/lustre/obdclass/cl_page.c | 34 ----- .../lustre/lustre/obdclass/class_obd.c | 4 - .../lustre/lustre/obdclass/dt_object.c | 6 - .../staging/lustre/lustre/obdclass/genops.c | 19 --- .../lustre/obdclass/linux/linux-module.c | 8 -- drivers/staging/lustre/lustre/obdclass/llog.c | 32 ----- .../staging/lustre/lustre/obdclass/llog_cat.c | 17 --- .../lustre/lustre/obdclass/llog_ioctl.c | 9 -- .../lustre/lustre/obdclass/llog_lvfs.c | 15 -- .../staging/lustre/lustre/obdclass/llog_obd.c | 9 +- .../staging/lustre/lustre/obdclass/llog_osd.c | 28 ---- .../lustre/lustre/obdclass/llog_swab.c | 5 - .../lustre/lustre/obdclass/llog_test.c | 19 --- .../lustre/lustre/obdclass/local_storage.c | 12 -- .../lustre/lustre/obdclass/lprocfs_status.c | 4 - .../lustre/lustre/obdclass/lu_object.c | 2 - .../lustre/lustre/obdclass/lustre_handles.c | 3 - .../lustre/lustre/obdclass/lustre_peer.c | 1 - .../staging/lustre/lustre/obdclass/md_attrs.c | 3 - .../lustre/lustre/obdclass/obd_config.c | 23 ---- .../lustre/lustre/obdclass/obd_mount.c | 12 -- drivers/staging/lustre/lustre/obdecho/echo.c | 9 -- .../lustre/lustre/obdecho/echo_client.c | 52 ------- drivers/staging/lustre/lustre/osc/osc_cache.c | 31 ----- drivers/staging/lustre/lustre/osc/osc_dev.c | 1 - drivers/staging/lustre/lustre/osc/osc_io.c | 8 -- drivers/staging/lustre/lustre/osc/osc_lock.c | 9 -- .../staging/lustre/lustre/osc/osc_object.c | 1 - drivers/staging/lustre/lustre/osc/osc_page.c | 7 +- drivers/staging/lustre/lustre/osc/osc_quota.c | 7 - .../staging/lustre/lustre/osc/osc_request.c | 48 ------- drivers/staging/lustre/lustre/ptlrpc/client.c | 27 ---- .../staging/lustre/lustre/ptlrpc/connection.c | 7 - drivers/staging/lustre/lustre/ptlrpc/events.c | 5 - .../lustre/lustre/ptlrpc/gss/gss_bulk.c | 6 - .../lustre/lustre/ptlrpc/gss/gss_cli_upcall.c | 1 - .../lustre/lustre/ptlrpc/gss/gss_keyring.c | 11 -- .../lustre/lustre/ptlrpc/gss/gss_krb5_mech.c | 1 - .../lustre/lustre/ptlrpc/gss/gss_pipefs.c | 12 -- .../lustre/lustre/ptlrpc/gss/gss_svc_upcall.c | 5 - .../lustre/lustre/ptlrpc/gss/sec_gss.c | 22 --- drivers/staging/lustre/lustre/ptlrpc/import.c | 14 -- .../lustre/lustre/ptlrpc/llog_client.c | 5 - .../staging/lustre/lustre/ptlrpc/llog_net.c | 1 - .../lustre/lustre/ptlrpc/llog_server.c | 12 -- .../lustre/lustre/ptlrpc/lproc_ptlrpc.c | 3 - drivers/staging/lustre/lustre/ptlrpc/niobuf.c | 5 - drivers/staging/lustre/lustre/ptlrpc/nrs.c | 18 --- .../lustre/lustre/ptlrpc/pack_generic.c | 9 +- drivers/staging/lustre/lustre/ptlrpc/pinger.c | 8 -- .../lustre/lustre/ptlrpc/ptlrpc_module.c | 1 - .../staging/lustre/lustre/ptlrpc/ptlrpcd.c | 10 -- .../staging/lustre/lustre/ptlrpc/recover.c | 8 -- drivers/staging/lustre/lustre/ptlrpc/sec.c | 17 --- .../staging/lustre/lustre/ptlrpc/sec_config.c | 6 - .../staging/lustre/lustre/ptlrpc/sec_plain.c | 16 --- .../staging/lustre/lustre/ptlrpc/service.c | 26 ---- 147 files changed, 42 insertions(+), 1763 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h index 07082dc6fd861..feb7a6bc6efe6 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h @@ -309,11 +309,6 @@ do { \ # error "Unkown compiler" #endif /* __GNUC__ */ -#define ENTRY \ -do { \ - CDEBUG(D_TRACE, "Process entered\n"); \ -} while (0) - #define EXIT \ do { \ CDEBUG(D_TRACE, "Process leaving\n"); \ diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c index a3b8f77399bad..6a538497f9f89 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c @@ -343,7 +343,6 @@ ksocknal_receive (ksock_conn_t *conn) * Caller checks ksnc_rx_nob_wanted to determine * progress/completion. */ int rc; - ENTRY; if (ksocknal_data.ksnd_stall_rx != 0) { cfs_pause(cfs_time_seconds (ksocknal_data.ksnd_stall_rx)); @@ -389,7 +388,6 @@ ksocknal_tx_done (lnet_ni_t *ni, ksock_tx_t *tx) { lnet_msg_t *lnetmsg = tx->tx_lnetmsg; int rc = (tx->tx_resid == 0 && !tx->tx_zc_aborted) ? 0 : -EIO; - ENTRY; LASSERT(ni != NULL || tx->tx_conn != NULL); @@ -1562,7 +1560,6 @@ int ksocknal_scheduler(void *arg) void ksocknal_read_callback (ksock_conn_t *conn) { ksock_sched_t *sched; - ENTRY; sched = conn->ksnc_scheduler; @@ -1591,7 +1588,6 @@ void ksocknal_read_callback (ksock_conn_t *conn) void ksocknal_write_callback (ksock_conn_t *conn) { ksock_sched_t *sched; - ENTRY; sched = conn->ksnc_scheduler; diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c index 76e442be55823..6cfcf7758c041 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c @@ -964,7 +964,6 @@ static void ksocknal_data_ready (struct sock *sk, int n) { ksock_conn_t *conn; - ENTRY; /* interleave correctly with closing sockets... */ LASSERT(!in_irq()); diff --git a/drivers/staging/lustre/lnet/lnet/lib-eq.c b/drivers/staging/lustre/lnet/lnet/lib-eq.c index 78297a7d94e87..3b8808bf78d18 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-eq.c +++ b/drivers/staging/lustre/lnet/lnet/lib-eq.c @@ -244,7 +244,6 @@ lnet_eq_dequeue_event(lnet_eq_t *eq, lnet_event_t *ev) int new_index = eq->eq_deq_seq & (eq->eq_size - 1); lnet_event_t *new_event = &eq->eq_events[new_index]; int rc; - ENTRY; /* must called with lnet_eq_wait_lock hold */ if (LNET_SEQ_GT(eq->eq_deq_seq, new_event->sequence)) @@ -400,7 +399,6 @@ LNetEQPoll(lnet_handle_eq_t *eventqs, int neq, int timeout_ms, int wait = 1; int rc; int i; - ENTRY; LASSERT (the_lnet.ln_init); LASSERT (the_lnet.ln_refcount > 0); diff --git a/drivers/staging/lustre/lnet/lnet/lib-msg.c b/drivers/staging/lustre/lnet/lnet/lib-msg.c index 8f3a50bd5f69a..214bf38745aeb 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-msg.c +++ b/drivers/staging/lustre/lnet/lnet/lib-msg.c @@ -45,8 +45,6 @@ void lnet_build_unlink_event (lnet_libmd_t *md, lnet_event_t *ev) { - ENTRY; - memset(ev, 0, sizeof(*ev)); ev->status = 0; diff --git a/drivers/staging/lustre/lnet/lnet/module.c b/drivers/staging/lustre/lnet/lnet/module.c index c8323854580a8..c57e46a384cd2 100644 --- a/drivers/staging/lustre/lnet/lnet/module.c +++ b/drivers/staging/lustre/lnet/lnet/module.c @@ -114,7 +114,6 @@ int init_lnet(void) { int rc; - ENTRY; mutex_init(&lnet_config_mutex); diff --git a/drivers/staging/lustre/lustre/fid/fid_request.c b/drivers/staging/lustre/lustre/fid/fid_request.c index a279b5ae8e763..59ff87cea083f 100644 --- a/drivers/staging/lustre/lustre/fid/fid_request.c +++ b/drivers/staging/lustre/lustre/fid/fid_request.c @@ -63,7 +63,6 @@ static int seq_client_rpc(struct lu_client_seq *seq, __u32 *op; unsigned int debug_mask; int rc; - ENTRY; req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_SEQ_QUERY, LUSTRE_MDS_VERSION, SEQ_QUERY); @@ -145,7 +144,6 @@ int seq_client_alloc_super(struct lu_client_seq *seq, const struct lu_env *env) { int rc; - ENTRY; mutex_lock(&seq->lcs_mutex); @@ -171,7 +169,6 @@ static int seq_client_alloc_meta(const struct lu_env *env, struct lu_client_seq *seq) { int rc; - ENTRY; if (seq->lcs_srv) { rc = 0; @@ -194,7 +191,6 @@ static int seq_client_alloc_seq(const struct lu_env *env, struct lu_client_seq *seq, seqno_t *seqnr) { int rc; - ENTRY; LASSERT(range_is_sane(&seq->lcs_space)); @@ -307,7 +303,6 @@ int seq_client_alloc_fid(const struct lu_env *env, { wait_queue_t link; int rc; - ENTRY; LASSERT(seq != NULL); LASSERT(fid != NULL); @@ -407,7 +402,6 @@ EXPORT_SYMBOL(seq_client_flush); static void seq_client_proc_fini(struct lu_client_seq *seq) { #ifdef LPROCFS - ENTRY; if (seq->lcs_proc_dir) { if (!IS_ERR(seq->lcs_proc_dir)) lprocfs_remove(&seq->lcs_proc_dir); @@ -421,7 +415,6 @@ static int seq_client_proc_init(struct lu_client_seq *seq) { #ifdef LPROCFS int rc; - ENTRY; seq->lcs_proc_dir = lprocfs_register(seq->lcs_name, seq_type_proc_dir, @@ -460,7 +453,6 @@ int seq_client_init(struct lu_client_seq *seq, struct lu_server_seq *srv) { int rc; - ENTRY; LASSERT(seq != NULL); LASSERT(prefix != NULL); @@ -495,8 +487,6 @@ EXPORT_SYMBOL(seq_client_init); void seq_client_fini(struct lu_client_seq *seq) { - ENTRY; - seq_client_proc_fini(seq); if (seq->lcs_exp != NULL) { @@ -515,7 +505,6 @@ int client_fid_init(struct obd_device *obd, struct client_obd *cli = &obd->u.cli; char *prefix; int rc; - ENTRY; OBD_ALLOC_PTR(cli->cl_seq); if (cli->cl_seq == NULL) @@ -544,7 +533,6 @@ EXPORT_SYMBOL(client_fid_init); int client_fid_fini(struct obd_device *obd) { struct client_obd *cli = &obd->u.cli; - ENTRY; if (cli->cl_seq != NULL) { seq_client_fini(cli->cl_seq); diff --git a/drivers/staging/lustre/lustre/fid/lproc_fid.c b/drivers/staging/lustre/lustre/fid/lproc_fid.c index 20d04488c04f1..b1ad25706ed57 100644 --- a/drivers/staging/lustre/lustre/fid/lproc_fid.c +++ b/drivers/staging/lustre/lustre/fid/lproc_fid.c @@ -65,7 +65,6 @@ lprocfs_fid_write_common(const char *buffer, unsigned long count, { struct lu_seq_range tmp; int rc; - ENTRY; LASSERT(range != NULL); @@ -85,7 +84,6 @@ lprocfs_fid_space_seq_write(struct file *file, const char *buffer, { struct lu_client_seq *seq = ((struct seq_file *)file->private_data)->private; int rc; - ENTRY; LASSERT(seq != NULL); @@ -107,7 +105,6 @@ lprocfs_fid_space_seq_show(struct seq_file *m, void *unused) { struct lu_client_seq *seq = (struct lu_client_seq *)m->private; int rc; - ENTRY; LASSERT(seq != NULL); @@ -125,7 +122,6 @@ lprocfs_fid_width_seq_write(struct file *file, const char *buffer, struct lu_client_seq *seq = ((struct seq_file *)file->private_data)->private; __u64 max; int rc, val; - ENTRY; LASSERT(seq != NULL); @@ -158,7 +154,6 @@ lprocfs_fid_width_seq_show(struct seq_file *m, void *unused) { struct lu_client_seq *seq = (struct lu_client_seq *)m->private; int rc; - ENTRY; LASSERT(seq != NULL); @@ -174,7 +169,6 @@ lprocfs_fid_fid_seq_show(struct seq_file *m, void *unused) { struct lu_client_seq *seq = (struct lu_client_seq *)m->private; int rc; - ENTRY; LASSERT(seq != NULL); @@ -191,7 +185,6 @@ lprocfs_fid_server_seq_show(struct seq_file *m, void *unused) struct lu_client_seq *seq = (struct lu_client_seq *)m->private; struct client_obd *cli; int rc; - ENTRY; LASSERT(seq != NULL); diff --git a/drivers/staging/lustre/lustre/fld/fld_cache.c b/drivers/staging/lustre/lustre/fld/fld_cache.c index 84101076a6560..9f9f9b5c62900 100644 --- a/drivers/staging/lustre/lustre/fld/fld_cache.c +++ b/drivers/staging/lustre/lustre/fld/fld_cache.c @@ -66,7 +66,6 @@ struct fld_cache *fld_cache_init(const char *name, int cache_size, int cache_threshold) { struct fld_cache *cache; - ENTRY; LASSERT(name != NULL); LASSERT(cache_threshold < cache_size); @@ -102,7 +101,6 @@ struct fld_cache *fld_cache_init(const char *name, void fld_cache_fini(struct fld_cache *cache) { __u64 pct; - ENTRY; LASSERT(cache != NULL); fld_cache_flush(cache); @@ -146,7 +144,6 @@ static void fld_fix_new_list(struct fld_cache *cache) struct lu_seq_range *c_range; struct lu_seq_range *n_range; struct list_head *head = &cache->fci_entries_head; - ENTRY; restart_fixup: @@ -226,7 +223,6 @@ static int fld_cache_shrink(struct fld_cache *cache) struct fld_cache_entry *flde; struct list_head *curr; int num = 0; - ENTRY; LASSERT(cache != NULL); @@ -255,8 +251,6 @@ static int fld_cache_shrink(struct fld_cache *cache) */ void fld_cache_flush(struct fld_cache *cache) { - ENTRY; - write_lock(&cache->fci_lock); cache->fci_cache_size = 0; fld_cache_shrink(cache); @@ -279,7 +273,6 @@ void fld_cache_punch_hole(struct fld_cache *cache, const seqno_t new_end = range->lsr_end; struct fld_cache_entry *fldt; - ENTRY; OBD_ALLOC_GFP(fldt, sizeof *fldt, GFP_ATOMIC); if (!fldt) { OBD_FREE_PTR(f_new); @@ -404,7 +397,6 @@ int fld_cache_insert_nolock(struct fld_cache *cache, const seqno_t new_start = f_new->fce_range.lsr_start; const seqno_t new_end = f_new->fce_range.lsr_end; __u32 new_flags = f_new->fce_range.lsr_flags; - ENTRY; /* * Duplicate entries are eliminated in insert op. @@ -521,7 +513,6 @@ struct fld_cache_entry *fld_cache_entry_lookup(struct fld_cache *cache, struct lu_seq_range *range) { struct fld_cache_entry *got = NULL; - ENTRY; read_lock(&cache->fci_lock); got = fld_cache_entry_lookup_nolock(cache, range); @@ -538,7 +529,6 @@ int fld_cache_lookup(struct fld_cache *cache, struct fld_cache_entry *flde; struct fld_cache_entry *prev = NULL; struct list_head *head; - ENTRY; read_lock(&cache->fci_lock); head = &cache->fci_entries_head; diff --git a/drivers/staging/lustre/lustre/fld/fld_request.c b/drivers/staging/lustre/lustre/fld/fld_request.c index 049322a791402..0c928dea899ea 100644 --- a/drivers/staging/lustre/lustre/fld/fld_request.c +++ b/drivers/staging/lustre/lustre/fld/fld_request.c @@ -66,7 +66,7 @@ struct lu_context_key fld_thread_key; static int fld_req_avail(struct client_obd *cli, struct mdc_cache_waiter *mcw) { int rc; - ENTRY; + client_obd_list_lock(&cli->cl_loi_list_lock); rc = list_empty(&mcw->mcw_entry); client_obd_list_unlock(&cli->cl_loi_list_lock); @@ -124,7 +124,6 @@ fld_rrb_scan(struct lu_client_fld *fld, seqno_t seq) { struct lu_fld_target *target; int hash; - ENTRY; /* Because almost all of special sequence located in MDT0, * it should go to index 0 directly, instead of calculating @@ -180,7 +179,6 @@ static struct lu_fld_target * fld_client_get_target(struct lu_client_fld *fld, seqno_t seq) { struct lu_fld_target *target; - ENTRY; LASSERT(fld->lcf_hash != NULL); @@ -206,7 +204,6 @@ int fld_client_add_target(struct lu_client_fld *fld, { const char *name; struct lu_fld_target *target, *tmp; - ENTRY; LASSERT(tar != NULL); name = fld_target_name(tar); @@ -258,7 +255,6 @@ EXPORT_SYMBOL(fld_client_add_target); int fld_client_del_target(struct lu_client_fld *fld, __u64 idx) { struct lu_fld_target *target, *tmp; - ENTRY; spin_lock(&fld->lcf_lock); list_for_each_entry_safe(target, tmp, @@ -286,7 +282,6 @@ proc_dir_entry_t *fld_type_proc_dir = NULL; static int fld_client_proc_init(struct lu_client_fld *fld) { int rc; - ENTRY; fld->lcf_proc_dir = lprocfs_register(fld->lcf_name, fld_type_proc_dir, @@ -316,7 +311,6 @@ static int fld_client_proc_init(struct lu_client_fld *fld) void fld_client_proc_fini(struct lu_client_fld *fld) { - ENTRY; if (fld->lcf_proc_dir) { if (!IS_ERR(fld->lcf_proc_dir)) lprocfs_remove(&fld->lcf_proc_dir); @@ -348,7 +342,6 @@ int fld_client_init(struct lu_client_fld *fld, { int cache_size, cache_threshold; int rc; - ENTRY; LASSERT(fld != NULL); @@ -398,7 +391,6 @@ EXPORT_SYMBOL(fld_client_init); void fld_client_fini(struct lu_client_fld *fld) { struct lu_fld_target *target, *tmp; - ENTRY; spin_lock(&fld->lcf_lock); list_for_each_entry_safe(target, tmp, @@ -429,7 +421,6 @@ int fld_client_rpc(struct obd_export *exp, __u32 *op; int rc; struct obd_import *imp; - ENTRY; LASSERT(exp != NULL); @@ -479,7 +470,6 @@ int fld_client_lookup(struct lu_client_fld *fld, seqno_t seq, mdsno_t *mds, struct lu_seq_range res = { 0 }; struct lu_fld_target *target; int rc; - ENTRY; fld->lcf_flags |= LUSTRE_FLD_RUN; diff --git a/drivers/staging/lustre/lustre/fld/lproc_fld.c b/drivers/staging/lustre/lustre/fld/lproc_fld.c index 77322ba5bf312..cf1f765dcab8d 100644 --- a/drivers/staging/lustre/lustre/fld/lproc_fld.c +++ b/drivers/staging/lustre/lustre/fld/lproc_fld.c @@ -62,7 +62,6 @@ fld_proc_targets_seq_show(struct seq_file *m, void *unused) { struct lu_client_fld *fld = (struct lu_client_fld *)m->private; struct lu_fld_target *target; - ENTRY; LASSERT(fld != NULL); @@ -79,7 +78,6 @@ static int fld_proc_hash_seq_show(struct seq_file *m, void *unused) { struct lu_client_fld *fld = (struct lu_client_fld *)m->private; - ENTRY; LASSERT(fld != NULL); @@ -97,7 +95,6 @@ fld_proc_hash_seq_write(struct file *file, const char *buffer, struct lu_client_fld *fld = ((struct seq_file *)file->private_data)->private; struct lu_fld_hash *hash = NULL; int i; - ENTRY; LASSERT(fld != NULL); @@ -128,7 +125,6 @@ fld_proc_cache_flush_write(struct file *file, const char __user *buffer, size_t count, loff_t *pos) { struct lu_client_fld *fld = file->private_data; - ENTRY; LASSERT(fld != NULL); diff --git a/drivers/staging/lustre/lustre/include/lustre_cfg.h b/drivers/staging/lustre/lustre/include/lustre_cfg.h index fbf94a081ffd4..5004c9079a8bc 100644 --- a/drivers/staging/lustre/lustre/include/lustre_cfg.h +++ b/drivers/staging/lustre/lustre/include/lustre_cfg.h @@ -211,7 +211,6 @@ static inline int lustre_cfg_len(__u32 bufcount, __u32 *buflens) { int i; int len; - ENTRY; len = LCFG_HDR_SIZE(bufcount); for (i = 0; i < bufcount; i++) @@ -230,8 +229,6 @@ static inline struct lustre_cfg *lustre_cfg_new(int cmd, char *ptr; int i; - ENTRY; - OBD_ALLOC(lcfg, lustre_cfg_len(bufs->lcfg_bufcount, bufs->lcfg_buflen)); if (!lcfg) @@ -263,7 +260,7 @@ static inline void lustre_cfg_free(struct lustre_cfg *lcfg) static inline int lustre_cfg_sanity_check(void *buf, int len) { struct lustre_cfg *lcfg = (struct lustre_cfg *)buf; - ENTRY; + if (!lcfg) RETURN(-EINVAL); diff --git a/drivers/staging/lustre/lustre/include/lustre_lib.h b/drivers/staging/lustre/lustre/include/lustre_lib.h index bdfc5391c6d24..007b2ddc7a9c5 100644 --- a/drivers/staging/lustre/lustre/include/lustre_lib.h +++ b/drivers/staging/lustre/lustre/include/lustre_lib.h @@ -260,8 +260,6 @@ int obd_ioctl_popdata(void *arg, void *data, int len); static inline void obd_ioctl_freedata(char *buf, int len) { - ENTRY; - OBD_FREE_LARGE(buf, len); EXIT; return; diff --git a/drivers/staging/lustre/lustre/include/lustre_log.h b/drivers/staging/lustre/lustre/include/lustre_log.h index 714ab378e431c..8f642f3e01057 100644 --- a/drivers/staging/lustre/lustre/include/lustre_log.h +++ b/drivers/staging/lustre/lustre/include/lustre_log.h @@ -469,8 +469,6 @@ static inline int llog_destroy(const struct lu_env *env, struct llog_operations *lop; int rc; - ENTRY; - rc = llog_handle2ops(handle, &lop); if (rc) RETURN(rc); @@ -489,8 +487,6 @@ static inline int llog_next_block(const struct lu_env *env, struct llog_operations *lop; int rc; - ENTRY; - rc = llog_handle2ops(loghandle, &lop); if (rc) RETURN(rc); @@ -509,8 +505,6 @@ static inline int llog_prev_block(const struct lu_env *env, struct llog_operations *lop; int rc; - ENTRY; - rc = llog_handle2ops(loghandle, &lop); if (rc) RETURN(rc); @@ -528,8 +522,6 @@ static inline int llog_connect(struct llog_ctxt *ctxt, struct llog_operations *lop; int rc; - ENTRY; - rc = llog_obd2ops(ctxt, &lop); if (rc) RETURN(rc); diff --git a/drivers/staging/lustre/lustre/include/lustre_mdc.h b/drivers/staging/lustre/lustre/include/lustre_mdc.h index 82d1f2f130314..e09646ade9d36 100644 --- a/drivers/staging/lustre/lustre/include/lustre_mdc.h +++ b/drivers/staging/lustre/lustre/include/lustre_mdc.h @@ -84,8 +84,6 @@ static inline void mdc_init_rpc_lock(struct mdc_rpc_lock *lck) static inline void mdc_get_rpc_lock(struct mdc_rpc_lock *lck, struct lookup_intent *it) { - ENTRY; - if (it != NULL && (it->it_op == IT_GETATTR || it->it_op == IT_LOOKUP || it->it_op == IT_LAYOUT)) return; diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index de5c5853647fb..c42996ba4f9cf 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -495,7 +495,6 @@ static inline int obd_get_info(const struct lu_env *env, struct lov_stripe_md *lsm) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, get_info); EXP_COUNTER_INCREMENT(exp, get_info); @@ -511,7 +510,6 @@ static inline int obd_set_info_async(const struct lu_env *env, struct ptlrpc_request_set *set) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, set_info_async); EXP_COUNTER_INCREMENT(exp, set_info_async); @@ -547,7 +545,6 @@ static inline int obd_setup(struct obd_device *obd, struct lustre_cfg *cfg) { int rc; DECLARE_LU_VARS(ldt, d); - ENTRY; ldt = obd->obd_type->typ_lu; if (ldt != NULL) { @@ -585,7 +582,6 @@ static inline int obd_precleanup(struct obd_device *obd, { int rc; DECLARE_LU_VARS(ldt, d); - ENTRY; OBD_CHECK_DEV(obd); ldt = obd->obd_type->typ_lu; @@ -612,7 +608,6 @@ static inline int obd_cleanup(struct obd_device *obd) { int rc; DECLARE_LU_VARS(ldt, d); - ENTRY; OBD_CHECK_DEV(obd); @@ -637,8 +632,6 @@ static inline int obd_cleanup(struct obd_device *obd) static inline void obd_cleanup_client_import(struct obd_device *obd) { - ENTRY; - /* If we set up but never connected, the client import will not have been cleaned. */ down_write(&obd->u.cli.cl_sem); @@ -665,7 +658,6 @@ obd_process_config(struct obd_device *obd, int datalen, void *data) { int rc; DECLARE_LU_VARS(ldt, d); - ENTRY; OBD_CHECK_DEV(obd); @@ -702,7 +694,6 @@ static inline int obd_packmd(struct obd_export *exp, struct lov_stripe_md *mem_src) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, packmd); EXP_COUNTER_INCREMENT(exp, packmd); @@ -757,7 +748,6 @@ static inline int obd_unpackmd(struct obd_export *exp, int disk_len) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, unpackmd); EXP_COUNTER_INCREMENT(exp, unpackmd); @@ -790,7 +780,6 @@ static inline int obd_free_memmd(struct obd_export *exp, static inline int obd_precreate(struct obd_export *exp) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, precreate); OBD_COUNTER_INCREMENT(exp->exp_obd, precreate); @@ -805,7 +794,6 @@ static inline int obd_create_async(struct obd_export *exp, struct obd_trans_info *oti) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, create_async); EXP_COUNTER_INCREMENT(exp, create_async); @@ -819,7 +807,6 @@ static inline int obd_create(const struct lu_env *env, struct obd_export *exp, struct obd_trans_info *oti) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, create); EXP_COUNTER_INCREMENT(exp, create); @@ -834,7 +821,6 @@ static inline int obd_destroy(const struct lu_env *env, struct obd_export *exp, struct obd_export *md_exp, void *capa) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, destroy); EXP_COUNTER_INCREMENT(exp, destroy); @@ -847,7 +833,6 @@ static inline int obd_getattr(const struct lu_env *env, struct obd_export *exp, struct obd_info *oinfo) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, getattr); EXP_COUNTER_INCREMENT(exp, getattr); @@ -861,7 +846,6 @@ static inline int obd_getattr_async(struct obd_export *exp, struct ptlrpc_request_set *set) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, getattr_async); EXP_COUNTER_INCREMENT(exp, getattr_async); @@ -875,7 +859,6 @@ static inline int obd_setattr(const struct lu_env *env, struct obd_export *exp, struct obd_trans_info *oti) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, setattr); EXP_COUNTER_INCREMENT(exp, setattr); @@ -891,7 +874,6 @@ static inline int obd_setattr_rqset(struct obd_export *exp, { struct ptlrpc_request_set *set = NULL; int rc; - ENTRY; EXP_CHECK_DT_OP(exp, setattr_async); EXP_COUNTER_INCREMENT(exp, setattr_async); @@ -915,7 +897,6 @@ static inline int obd_setattr_async(struct obd_export *exp, struct ptlrpc_request_set *set) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, setattr_async); EXP_COUNTER_INCREMENT(exp, setattr_async); @@ -929,7 +910,6 @@ static inline int obd_add_conn(struct obd_import *imp, struct obd_uuid *uuid, { struct obd_device *obd = imp->imp_obd; int rc; - ENTRY; OBD_CHECK_DEV_ACTIVE(obd); OBD_CHECK_DT_OP(obd, add_conn, -EOPNOTSUPP); @@ -943,7 +923,6 @@ static inline int obd_del_conn(struct obd_import *imp, struct obd_uuid *uuid) { struct obd_device *obd = imp->imp_obd; int rc; - ENTRY; OBD_CHECK_DEV_ACTIVE(obd); OBD_CHECK_DT_OP(obd, del_conn, -EOPNOTSUPP); @@ -956,7 +935,6 @@ static inline int obd_del_conn(struct obd_import *imp, struct obd_uuid *uuid) static inline struct obd_uuid *obd_get_uuid(struct obd_export *exp) { struct obd_uuid *uuid; - ENTRY; OBD_CHECK_DT_OP(exp->exp_obd, get_uuid, NULL); EXP_COUNTER_INCREMENT(exp, get_uuid); @@ -979,7 +957,6 @@ static inline int obd_connect(const struct lu_env *env, int rc; __u64 ocf = data ? data->ocd_connect_flags : 0; /* for post-condition * check */ - ENTRY; OBD_CHECK_DEV_ACTIVE(obd); OBD_CHECK_DT_OP(obd, connect, -EOPNOTSUPP); @@ -1003,8 +980,6 @@ static inline int obd_reconnect(const struct lu_env *env, __u64 ocf = d ? d->ocd_connect_flags : 0; /* for post-condition * check */ - ENTRY; - OBD_CHECK_DEV_ACTIVE(obd); OBD_CHECK_DT_OP(obd, reconnect, 0); OBD_COUNTER_INCREMENT(obd, reconnect); @@ -1019,7 +994,6 @@ static inline int obd_reconnect(const struct lu_env *env, static inline int obd_disconnect(struct obd_export *exp) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, disconnect); EXP_COUNTER_INCREMENT(exp, disconnect); @@ -1032,7 +1006,6 @@ static inline int obd_fid_init(struct obd_device *obd, struct obd_export *exp, enum lu_cli_type type) { int rc; - ENTRY; OBD_CHECK_DT_OP(obd, fid_init, 0); OBD_COUNTER_INCREMENT(obd, fid_init); @@ -1044,7 +1017,6 @@ static inline int obd_fid_init(struct obd_device *obd, struct obd_export *exp, static inline int obd_fid_fini(struct obd_device *obd) { int rc; - ENTRY; OBD_CHECK_DT_OP(obd, fid_fini, 0); OBD_COUNTER_INCREMENT(obd, fid_fini); @@ -1058,7 +1030,6 @@ static inline int obd_fid_alloc(struct obd_export *exp, struct md_op_data *op_data) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, fid_alloc); EXP_COUNTER_INCREMENT(exp, fid_alloc); @@ -1070,7 +1041,6 @@ static inline int obd_fid_alloc(struct obd_export *exp, static inline int obd_ping(const struct lu_env *env, struct obd_export *exp) { int rc; - ENTRY; OBD_CHECK_DT_OP(exp->exp_obd, ping, 0); EXP_COUNTER_INCREMENT(exp, ping); @@ -1082,7 +1052,6 @@ static inline int obd_ping(const struct lu_env *env, struct obd_export *exp) static inline int obd_pool_new(struct obd_device *obd, char *poolname) { int rc; - ENTRY; OBD_CHECK_DT_OP(obd, pool_new, -EOPNOTSUPP); OBD_COUNTER_INCREMENT(obd, pool_new); @@ -1094,7 +1063,6 @@ static inline int obd_pool_new(struct obd_device *obd, char *poolname) static inline int obd_pool_del(struct obd_device *obd, char *poolname) { int rc; - ENTRY; OBD_CHECK_DT_OP(obd, pool_del, -EOPNOTSUPP); OBD_COUNTER_INCREMENT(obd, pool_del); @@ -1106,7 +1074,6 @@ static inline int obd_pool_del(struct obd_device *obd, char *poolname) static inline int obd_pool_add(struct obd_device *obd, char *poolname, char *ostname) { int rc; - ENTRY; OBD_CHECK_DT_OP(obd, pool_add, -EOPNOTSUPP); OBD_COUNTER_INCREMENT(obd, pool_add); @@ -1118,7 +1085,6 @@ static inline int obd_pool_add(struct obd_device *obd, char *poolname, char *ost static inline int obd_pool_rem(struct obd_device *obd, char *poolname, char *ostname) { int rc; - ENTRY; OBD_CHECK_DT_OP(obd, pool_rem, -EOPNOTSUPP); OBD_COUNTER_INCREMENT(obd, pool_rem); @@ -1129,7 +1095,6 @@ static inline int obd_pool_rem(struct obd_device *obd, char *poolname, char *ost static inline void obd_getref(struct obd_device *obd) { - ENTRY; if (OBT(obd) && OBP(obd, getref)) { OBD_COUNTER_INCREMENT(obd, getref); OBP(obd, getref)(obd); @@ -1139,7 +1104,6 @@ static inline void obd_getref(struct obd_device *obd) static inline void obd_putref(struct obd_device *obd) { - ENTRY; if (OBT(obd) && OBP(obd, putref)) { OBD_COUNTER_INCREMENT(obd, putref); OBP(obd, putref)(obd); @@ -1151,7 +1115,6 @@ static inline int obd_init_export(struct obd_export *exp) { int rc = 0; - ENTRY; if ((exp)->exp_obd != NULL && OBT((exp)->exp_obd) && OBP((exp)->exp_obd, init_export)) rc = OBP(exp->exp_obd, init_export)(exp); @@ -1160,7 +1123,6 @@ static inline int obd_init_export(struct obd_export *exp) static inline int obd_destroy_export(struct obd_export *exp) { - ENTRY; if ((exp)->exp_obd != NULL && OBT((exp)->exp_obd) && OBP((exp)->exp_obd, destroy_export)) OBP(exp->exp_obd, destroy_export)(exp); @@ -1172,7 +1134,7 @@ static inline int obd_extent_calc(struct obd_export *exp, int cmd, obd_off *offset) { int rc; - ENTRY; + EXP_CHECK_DT_OP(exp, extent_calc); rc = OBP(exp->exp_obd, extent_calc)(exp, md, cmd, offset); RETURN(rc); @@ -1198,7 +1160,6 @@ static inline int obd_statfs_async(struct obd_export *exp, { int rc = 0; struct obd_device *obd; - ENTRY; if (exp == NULL || exp->exp_obd == NULL) RETURN(-EINVAL); @@ -1234,7 +1195,6 @@ static inline int obd_statfs_rqset(struct obd_export *exp, struct ptlrpc_request_set *set = NULL; struct obd_info oinfo = { { { 0 } } }; int rc = 0; - ENTRY; set = ptlrpc_prep_set(); if (set == NULL) @@ -1258,7 +1218,6 @@ static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp, { int rc = 0; struct obd_device *obd = exp->exp_obd; - ENTRY; if (obd == NULL) RETURN(-EINVAL); @@ -1294,7 +1253,6 @@ static inline int obd_sync_rqset(struct obd_export *exp, struct obd_info *oinfo, { struct ptlrpc_request_set *set = NULL; int rc; - ENTRY; OBD_CHECK_DT_OP(exp->exp_obd, sync, -EOPNOTSUPP); EXP_COUNTER_INCREMENT(exp, sync); @@ -1315,7 +1273,6 @@ static inline int obd_sync(const struct lu_env *env, struct obd_export *exp, struct ptlrpc_request_set *set) { int rc; - ENTRY; OBD_CHECK_DT_OP(exp->exp_obd, sync, -EOPNOTSUPP); EXP_COUNTER_INCREMENT(exp, sync); @@ -1330,7 +1287,6 @@ static inline int obd_punch_rqset(struct obd_export *exp, { struct ptlrpc_request_set *set = NULL; int rc; - ENTRY; EXP_CHECK_DT_OP(exp, punch); EXP_COUNTER_INCREMENT(exp, punch); @@ -1351,7 +1307,6 @@ static inline int obd_punch(const struct lu_env *env, struct obd_export *exp, struct ptlrpc_request_set *rqset) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, punch); EXP_COUNTER_INCREMENT(exp, punch); @@ -1365,7 +1320,6 @@ static inline int obd_brw(int cmd, struct obd_export *exp, struct brw_page *pg, struct obd_trans_info *oti) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, brw); EXP_COUNTER_INCREMENT(exp, brw); @@ -1389,7 +1343,6 @@ static inline int obd_preprw(const struct lu_env *env, int cmd, struct lustre_capa *capa) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, preprw); EXP_COUNTER_INCREMENT(exp, preprw); @@ -1406,8 +1359,6 @@ static inline int obd_commitrw(const struct lu_env *env, int cmd, struct niobuf_local *local, struct obd_trans_info *oti, int rc) { - ENTRY; - EXP_CHECK_DT_OP(exp, commitrw); EXP_COUNTER_INCREMENT(exp, commitrw); @@ -1421,7 +1372,6 @@ static inline int obd_merge_lvb(struct obd_export *exp, struct ost_lvb *lvb, int kms_only) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, merge_lvb); EXP_COUNTER_INCREMENT(exp, merge_lvb); @@ -1435,7 +1385,6 @@ static inline int obd_adjust_kms(struct obd_export *exp, int shrink) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, adjust_kms); EXP_COUNTER_INCREMENT(exp, adjust_kms); @@ -1448,7 +1397,6 @@ static inline int obd_iocontrol(unsigned int cmd, struct obd_export *exp, int len, void *karg, void *uarg) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, iocontrol); EXP_COUNTER_INCREMENT(exp, iocontrol); @@ -1463,7 +1411,6 @@ static inline int obd_enqueue_rqset(struct obd_export *exp, { struct ptlrpc_request_set *set = NULL; int rc; - ENTRY; EXP_CHECK_DT_OP(exp, enqueue); EXP_COUNTER_INCREMENT(exp, enqueue); @@ -1485,7 +1432,6 @@ static inline int obd_enqueue(struct obd_export *exp, struct ptlrpc_request_set *set) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, enqueue); EXP_COUNTER_INCREMENT(exp, enqueue); @@ -1499,7 +1445,6 @@ static inline int obd_change_cbdata(struct obd_export *exp, ldlm_iterator_t it, void *data) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, change_cbdata); EXP_COUNTER_INCREMENT(exp, change_cbdata); @@ -1513,7 +1458,6 @@ static inline int obd_find_cbdata(struct obd_export *exp, ldlm_iterator_t it, void *data) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, find_cbdata); EXP_COUNTER_INCREMENT(exp, find_cbdata); @@ -1527,7 +1471,6 @@ static inline int obd_cancel(struct obd_export *exp, struct lustre_handle *lockh) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, cancel); EXP_COUNTER_INCREMENT(exp, cancel); @@ -1542,7 +1485,6 @@ static inline int obd_cancel_unused(struct obd_export *exp, void *opaque) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, cancel_unused); EXP_COUNTER_INCREMENT(exp, cancel_unused); @@ -1556,7 +1498,6 @@ static inline int obd_pin(struct obd_export *exp, const struct lu_fid *fid, int flag) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, pin); EXP_COUNTER_INCREMENT(exp, pin); @@ -1569,7 +1510,6 @@ static inline int obd_unpin(struct obd_export *exp, struct obd_client_handle *handle, int flag) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, unpin); EXP_COUNTER_INCREMENT(exp, unpin); @@ -1583,7 +1523,6 @@ static inline void obd_import_event(struct obd_device *obd, struct obd_import *imp, enum obd_import_event event) { - ENTRY; if (!obd) { CERROR("NULL device\n"); EXIT; @@ -1600,7 +1539,6 @@ static inline int obd_llog_connect(struct obd_export *exp, struct llogd_conn_body *body) { int rc; - ENTRY; OBD_CHECK_DT_OP(exp->exp_obd, llog_connect, 0); EXP_COUNTER_INCREMENT(exp, llog_connect); @@ -1616,7 +1554,7 @@ static inline int obd_notify(struct obd_device *obd, void *data) { int rc; - ENTRY; + OBD_CHECK_DEV(obd); /* the check for async_recov is a complete hack - I'm hereby @@ -1669,7 +1607,6 @@ static inline int obd_quotacheck(struct obd_export *exp, struct obd_quotactl *oqctl) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, quotacheck); EXP_COUNTER_INCREMENT(exp, quotacheck); @@ -1682,7 +1619,6 @@ static inline int obd_quotactl(struct obd_export *exp, struct obd_quotactl *oqctl) { int rc; - ENTRY; EXP_CHECK_DT_OP(exp, quotactl); EXP_COUNTER_INCREMENT(exp, quotactl); @@ -1702,7 +1638,6 @@ static inline int obd_health_check(const struct lu_env *env, * <0 on error */ int rc; - ENTRY; /* don't use EXP_CHECK_DT_OP, because NULL method is normal here */ if (obd == NULL || !OBT(obd)) { @@ -1721,7 +1656,6 @@ static inline int obd_health_check(const struct lu_env *env, static inline int obd_register_observer(struct obd_device *obd, struct obd_device *observer) { - ENTRY; OBD_CHECK_DEV(obd); down_write(&obd->obd_observer_link_sem); if (obd->obd_observer && observer) { @@ -1736,7 +1670,6 @@ static inline int obd_register_observer(struct obd_device *obd, static inline int obd_pin_observer(struct obd_device *obd, struct obd_device **observer) { - ENTRY; down_read(&obd->obd_observer_link_sem); if (!obd->obd_observer) { *observer = NULL; @@ -1749,7 +1682,6 @@ static inline int obd_pin_observer(struct obd_device *obd, static inline int obd_unpin_observer(struct obd_device *obd) { - ENTRY; up_read(&obd->obd_observer_link_sem); RETURN(0); } @@ -1760,7 +1692,6 @@ static inline int obd_register_page_removal_cb(struct obd_export *exp, obd_pin_extent_cb pin_cb) { int rc; - ENTRY; OBD_CHECK_DT_OP(exp->exp_obd, register_page_removal_cb, 0); OBD_COUNTER_INCREMENT(exp->exp_obd, register_page_removal_cb); @@ -1773,7 +1704,6 @@ static inline int obd_unregister_page_removal_cb(struct obd_export *exp, obd_page_removal_cb_t cb) { int rc; - ENTRY; OBD_CHECK_DT_OP(exp->exp_obd, unregister_page_removal_cb, 0); OBD_COUNTER_INCREMENT(exp->exp_obd, unregister_page_removal_cb); @@ -1786,7 +1716,6 @@ static inline int obd_register_lock_cancel_cb(struct obd_export *exp, obd_lock_cancel_cb cb) { int rc; - ENTRY; OBD_CHECK_DT_OP(exp->exp_obd, register_lock_cancel_cb, 0); OBD_COUNTER_INCREMENT(exp->exp_obd, register_lock_cancel_cb); @@ -1799,7 +1728,6 @@ static inline int obd_unregister_lock_cancel_cb(struct obd_export *exp, obd_lock_cancel_cb cb) { int rc; - ENTRY; OBD_CHECK_DT_OP(exp->exp_obd, unregister_lock_cancel_cb, 0); OBD_COUNTER_INCREMENT(exp->exp_obd, unregister_lock_cancel_cb); @@ -1814,7 +1742,6 @@ static inline int md_getstatus(struct obd_export *exp, struct lu_fid *fid, struct obd_capa **pc) { int rc; - ENTRY; EXP_CHECK_MD_OP(exp, getstatus); EXP_MD_COUNTER_INCREMENT(exp, getstatus); @@ -1826,7 +1753,7 @@ static inline int md_getattr(struct obd_export *exp, struct md_op_data *op_data, struct ptlrpc_request **request) { int rc; - ENTRY; + EXP_CHECK_MD_OP(exp, getattr); EXP_MD_COUNTER_INCREMENT(exp, getattr); rc = MDP(exp->exp_obd, getattr)(exp, op_data, request); @@ -1837,7 +1764,7 @@ static inline int md_null_inode(struct obd_export *exp, const struct lu_fid *fid) { int rc; - ENTRY; + EXP_CHECK_MD_OP(exp, null_inode); EXP_MD_COUNTER_INCREMENT(exp, null_inode); rc = MDP(exp->exp_obd, null_inode)(exp, fid); @@ -1849,7 +1776,7 @@ static inline int md_find_cbdata(struct obd_export *exp, ldlm_iterator_t it, void *data) { int rc; - ENTRY; + EXP_CHECK_MD_OP(exp, find_cbdata); EXP_MD_COUNTER_INCREMENT(exp, find_cbdata); rc = MDP(exp->exp_obd, find_cbdata)(exp, fid, it, data); @@ -1861,7 +1788,7 @@ static inline int md_close(struct obd_export *exp, struct md_op_data *op_data, struct ptlrpc_request **request) { int rc; - ENTRY; + EXP_CHECK_MD_OP(exp, close); EXP_MD_COUNTER_INCREMENT(exp, close); rc = MDP(exp->exp_obd, close)(exp, op_data, mod, request); @@ -1874,7 +1801,7 @@ static inline int md_create(struct obd_export *exp, struct md_op_data *op_data, struct ptlrpc_request **request) { int rc; - ENTRY; + EXP_CHECK_MD_OP(exp, create); EXP_MD_COUNTER_INCREMENT(exp, create); rc = MDP(exp->exp_obd, create)(exp, op_data, data, datalen, mode, @@ -1887,7 +1814,7 @@ static inline int md_done_writing(struct obd_export *exp, struct md_open_data *mod) { int rc; - ENTRY; + EXP_CHECK_MD_OP(exp, done_writing); EXP_MD_COUNTER_INCREMENT(exp, done_writing); rc = MDP(exp->exp_obd, done_writing)(exp, op_data, mod); @@ -1904,7 +1831,7 @@ static inline int md_enqueue(struct obd_export *exp, int extra_lock_flags) { int rc; - ENTRY; + EXP_CHECK_MD_OP(exp, enqueue); EXP_MD_COUNTER_INCREMENT(exp, enqueue); rc = MDP(exp->exp_obd, enqueue)(exp, einfo, it, op_data, lockh, @@ -1917,7 +1844,7 @@ static inline int md_getattr_name(struct obd_export *exp, struct ptlrpc_request **request) { int rc; - ENTRY; + EXP_CHECK_MD_OP(exp, getattr_name); EXP_MD_COUNTER_INCREMENT(exp, getattr_name); rc = MDP(exp->exp_obd, getattr_name)(exp, op_data, request); @@ -1932,7 +1859,7 @@ static inline int md_intent_lock(struct obd_export *exp, __u64 extra_lock_flags) { int rc; - ENTRY; + EXP_CHECK_MD_OP(exp, intent_lock); EXP_MD_COUNTER_INCREMENT(exp, intent_lock); rc = MDP(exp->exp_obd, intent_lock)(exp, op_data, lmm, lmmsize, @@ -1945,7 +1872,7 @@ static inline int md_link(struct obd_export *exp, struct md_op_data *op_data, struct ptlrpc_request **request) { int rc; - ENTRY; + EXP_CHECK_MD_OP(exp, link); EXP_MD_COUNTER_INCREMENT(exp, link); rc = MDP(exp->exp_obd, link)(exp, op_data, request); @@ -1957,7 +1884,7 @@ static inline int md_rename(struct obd_export *exp, struct md_op_data *op_data, int newlen, struct ptlrpc_request **request) { int rc; - ENTRY; + EXP_CHECK_MD_OP(exp, rename); EXP_MD_COUNTER_INCREMENT(exp, rename); rc = MDP(exp->exp_obd, rename)(exp, op_data, old, oldlen, new, @@ -1971,7 +1898,7 @@ static inline int md_is_subdir(struct obd_export *exp, struct ptlrpc_request **request) { int rc; - ENTRY; + EXP_CHECK_MD_OP(exp, is_subdir); EXP_MD_COUNTER_INCREMENT(exp, is_subdir); rc = MDP(exp->exp_obd, is_subdir)(exp, pfid, cfid, request); @@ -1984,7 +1911,7 @@ static inline int md_setattr(struct obd_export *exp, struct md_op_data *op_data, struct md_open_data **mod) { int rc; - ENTRY; + EXP_CHECK_MD_OP(exp, setattr); EXP_MD_COUNTER_INCREMENT(exp, setattr); rc = MDP(exp->exp_obd, setattr)(exp, op_data, ea, ealen, @@ -1996,7 +1923,7 @@ static inline int md_sync(struct obd_export *exp, const struct lu_fid *fid, struct obd_capa *oc, struct ptlrpc_request **request) { int rc; - ENTRY; + EXP_CHECK_MD_OP(exp, sync); EXP_MD_COUNTER_INCREMENT(exp, sync); rc = MDP(exp->exp_obd, sync)(exp, fid, oc, request); @@ -2008,7 +1935,7 @@ static inline int md_readpage(struct obd_export *exp, struct md_op_data *opdata, struct ptlrpc_request **request) { int rc; - ENTRY; + EXP_CHECK_MD_OP(exp, readpage); EXP_MD_COUNTER_INCREMENT(exp, readpage); rc = MDP(exp->exp_obd, readpage)(exp, opdata, pages, request); @@ -2019,7 +1946,7 @@ static inline int md_unlink(struct obd_export *exp, struct md_op_data *op_data, struct ptlrpc_request **request) { int rc; - ENTRY; + EXP_CHECK_MD_OP(exp, unlink); EXP_MD_COUNTER_INCREMENT(exp, unlink); rc = MDP(exp->exp_obd, unlink)(exp, op_data, request); @@ -2032,7 +1959,6 @@ static inline int md_get_lustre_md(struct obd_export *exp, struct obd_export *md_exp, struct lustre_md *md) { - ENTRY; EXP_CHECK_MD_OP(exp, get_lustre_md); EXP_MD_COUNTER_INCREMENT(exp, get_lustre_md); RETURN(MDP(exp->exp_obd, get_lustre_md)(exp, req, dt_exp, md_exp, md)); @@ -2041,7 +1967,6 @@ static inline int md_get_lustre_md(struct obd_export *exp, static inline int md_free_lustre_md(struct obd_export *exp, struct lustre_md *md) { - ENTRY; EXP_CHECK_MD_OP(exp, free_lustre_md); EXP_MD_COUNTER_INCREMENT(exp, free_lustre_md); RETURN(MDP(exp->exp_obd, free_lustre_md)(exp, md)); @@ -2054,7 +1979,6 @@ static inline int md_setxattr(struct obd_export *exp, int output_size, int flags, __u32 suppgid, struct ptlrpc_request **request) { - ENTRY; EXP_CHECK_MD_OP(exp, setxattr); EXP_MD_COUNTER_INCREMENT(exp, setxattr); RETURN(MDP(exp->exp_obd, setxattr)(exp, fid, oc, valid, name, input, @@ -2069,7 +1993,6 @@ static inline int md_getxattr(struct obd_export *exp, int output_size, int flags, struct ptlrpc_request **request) { - ENTRY; EXP_CHECK_MD_OP(exp, getxattr); EXP_MD_COUNTER_INCREMENT(exp, getxattr); RETURN(MDP(exp->exp_obd, getxattr)(exp, fid, oc, valid, name, input, @@ -2081,7 +2004,6 @@ static inline int md_set_open_replay_data(struct obd_export *exp, struct obd_client_handle *och, struct ptlrpc_request *open_req) { - ENTRY; EXP_CHECK_MD_OP(exp, set_open_replay_data); EXP_MD_COUNTER_INCREMENT(exp, set_open_replay_data); RETURN(MDP(exp->exp_obd, set_open_replay_data)(exp, och, open_req)); @@ -2090,7 +2012,6 @@ static inline int md_set_open_replay_data(struct obd_export *exp, static inline int md_clear_open_replay_data(struct obd_export *exp, struct obd_client_handle *och) { - ENTRY; EXP_CHECK_MD_OP(exp, clear_open_replay_data); EXP_MD_COUNTER_INCREMENT(exp, clear_open_replay_data); RETURN(MDP(exp->exp_obd, clear_open_replay_data)(exp, och)); @@ -2099,7 +2020,6 @@ static inline int md_clear_open_replay_data(struct obd_export *exp, static inline int md_set_lock_data(struct obd_export *exp, __u64 *lockh, void *data, __u64 *bits) { - ENTRY; EXP_CHECK_MD_OP(exp, set_lock_data); EXP_MD_COUNTER_INCREMENT(exp, set_lock_data); RETURN(MDP(exp->exp_obd, set_lock_data)(exp, lockh, data, bits)); @@ -2113,7 +2033,6 @@ static inline int md_cancel_unused(struct obd_export *exp, void *opaque) { int rc; - ENTRY; EXP_CHECK_MD_OP(exp, cancel_unused); EXP_MD_COUNTER_INCREMENT(exp, cancel_unused); @@ -2130,7 +2049,6 @@ static inline ldlm_mode_t md_lock_match(struct obd_export *exp, __u64 flags, ldlm_mode_t mode, struct lustre_handle *lockh) { - ENTRY; EXP_CHECK_MD_OP(exp, lock_match); EXP_MD_COUNTER_INCREMENT(exp, lock_match); RETURN(MDP(exp->exp_obd, lock_match)(exp, flags, fid, type, @@ -2140,7 +2058,6 @@ static inline ldlm_mode_t md_lock_match(struct obd_export *exp, __u64 flags, static inline int md_init_ea_size(struct obd_export *exp, int easize, int def_asize, int cookiesize) { - ENTRY; EXP_CHECK_MD_OP(exp, init_ea_size); EXP_MD_COUNTER_INCREMENT(exp, init_ea_size); RETURN(MDP(exp->exp_obd, init_ea_size)(exp, easize, def_asize, @@ -2152,7 +2069,6 @@ static inline int md_get_remote_perm(struct obd_export *exp, struct obd_capa *oc, __u32 suppgid, struct ptlrpc_request **request) { - ENTRY; EXP_CHECK_MD_OP(exp, get_remote_perm); EXP_MD_COUNTER_INCREMENT(exp, get_remote_perm); RETURN(MDP(exp->exp_obd, get_remote_perm)(exp, fid, oc, suppgid, @@ -2163,7 +2079,7 @@ static inline int md_renew_capa(struct obd_export *exp, struct obd_capa *ocapa, renew_capa_cb_t cb) { int rc; - ENTRY; + EXP_CHECK_MD_OP(exp, renew_capa); EXP_MD_COUNTER_INCREMENT(exp, renew_capa); rc = MDP(exp->exp_obd, renew_capa)(exp, ocapa, cb); @@ -2176,7 +2092,7 @@ static inline int md_unpack_capa(struct obd_export *exp, struct obd_capa **oc) { int rc; - ENTRY; + EXP_CHECK_MD_OP(exp, unpack_capa); EXP_MD_COUNTER_INCREMENT(exp, unpack_capa); rc = MDP(exp->exp_obd, unpack_capa)(exp, req, field, oc); @@ -2188,7 +2104,7 @@ static inline int md_intent_getattr_async(struct obd_export *exp, struct ldlm_enqueue_info *einfo) { int rc; - ENTRY; + EXP_CHECK_MD_OP(exp, intent_getattr_async); EXP_MD_COUNTER_INCREMENT(exp, intent_getattr_async); rc = MDP(exp->exp_obd, intent_getattr_async)(exp, minfo, einfo); @@ -2200,7 +2116,7 @@ static inline int md_revalidate_lock(struct obd_export *exp, struct lu_fid *fid, __u64 *bits) { int rc; - ENTRY; + EXP_CHECK_MD_OP(exp, revalidate_lock); EXP_MD_COUNTER_INCREMENT(exp, revalidate_lock); rc = MDP(exp->exp_obd, revalidate_lock)(exp, it, fid, bits); diff --git a/drivers/staging/lustre/lustre/lclient/glimpse.c b/drivers/staging/lustre/lustre/lclient/glimpse.c index 7f3974be1f922..db72d89573b66 100644 --- a/drivers/staging/lustre/lustre/lclient/glimpse.c +++ b/drivers/staging/lustre/lustre/lclient/glimpse.c @@ -93,7 +93,6 @@ int cl_glimpse_lock(const struct lu_env *env, struct cl_io *io, struct cl_lock *lock; int result; - ENTRY; result = 0; if (!(lli->lli_flags & LLIF_MDS_SIZE_LOCK)) { CDEBUG(D_DLMTRACE, "Glimpsing inode "DFID"\n", PFID(fid)); @@ -203,8 +202,6 @@ int cl_glimpse_size0(struct inode *inode, int agl) int result; int refcheck; - ENTRY; - result = cl_io_get(inode, &env, &io, &refcheck); if (result > 0) { again: @@ -240,8 +237,6 @@ int cl_local_size(struct inode *inode) int result; int refcheck; - ENTRY; - if (!cl_i2info(inode)->lli_has_smd) RETURN(0); diff --git a/drivers/staging/lustre/lustre/lclient/lcommon_cl.c b/drivers/staging/lustre/lustre/lclient/lcommon_cl.c index c8690cb7731d2..1d3c2340227b2 100644 --- a/drivers/staging/lustre/lustre/lclient/lcommon_cl.c +++ b/drivers/staging/lustre/lustre/lclient/lcommon_cl.c @@ -169,7 +169,6 @@ int ccc_device_init(const struct lu_env *env, struct lu_device *d, { struct ccc_device *vdv; int rc; - ENTRY; vdv = lu2ccc_dev(d); vdv->cdv_next = lu2cl_dev(next); @@ -201,7 +200,6 @@ struct lu_device *ccc_device_alloc(const struct lu_env *env, struct lu_device *lud; struct cl_site *site; int rc; - ENTRY; OBD_ALLOC_PTR(vdv); if (vdv == NULL) @@ -418,7 +416,6 @@ int ccc_object_glimpse(const struct lu_env *env, { struct inode *inode = ccc_object_inode(obj); - ENTRY; lvb->lvb_mtime = cl_inode_mtime(inode); lvb->lvb_atime = cl_inode_atime(inode); lvb->lvb_ctime = cl_inode_ctime(inode); @@ -479,8 +476,6 @@ int ccc_page_is_under_lock(const struct lu_env *env, int result; - ENTRY; - if (io->ci_type == CIT_READ || io->ci_type == CIT_WRITE || io->ci_type == CIT_FAULT) { if (cio->cui_fd->fd_flags & LL_FILE_GROUP_LOCKED) @@ -559,7 +554,6 @@ int ccc_transient_page_prep(const struct lu_env *env, const struct cl_page_slice *slice, struct cl_io *unused) { - ENTRY; /* transient page should always be sent. */ RETURN(0); } @@ -623,7 +617,6 @@ int ccc_lock_fits_into(const struct lu_env *env, const struct ccc_io *cio = ccc_env_io(env); int result; - ENTRY; /* * Work around DLM peculiarity: it assumes that glimpse * (LDLM_FL_HAS_INTENT) lock is always LCK_PR, and returns reads lock @@ -655,7 +648,6 @@ void ccc_lock_state(const struct lu_env *env, enum cl_lock_state state) { struct cl_lock *lock = slice->cls_lock; - ENTRY; /* * Refresh inode attributes when the lock is moving into CLS_HELD @@ -707,7 +699,6 @@ int ccc_io_one_lock_index(const struct lu_env *env, struct cl_io *io, struct cl_object *obj = io->ci_obj; CLOBINVRNT(env, obj, ccc_object_invariant(obj)); - ENTRY; CDEBUG(D_VFSTRACE, "lock: %d [%lu, %lu]\n", mode, start, end); @@ -986,8 +977,6 @@ int cl_setattr_ost(struct inode *inode, const struct iattr *attr, int result; int refcheck; - ENTRY; - env = cl_env_get(&refcheck); if (IS_ERR(env)) RETURN(PTR_ERR(env)); @@ -1295,7 +1284,6 @@ __u64 cl_fid_build_ino(const struct lu_fid *fid, int api32) __u32 cl_fid_build_gen(const struct lu_fid *fid) { __u32 gen; - ENTRY; if (fid_is_igif(fid)) { gen = lu_igif_gen(fid); diff --git a/drivers/staging/lustre/lustre/lclient/lcommon_misc.c b/drivers/staging/lustre/lustre/lclient/lcommon_misc.c index 8ecbef92753d2..d59a7a94e3529 100644 --- a/drivers/staging/lustre/lustre/lclient/lcommon_misc.c +++ b/drivers/staging/lustre/lustre/lclient/lcommon_misc.c @@ -57,7 +57,6 @@ int cl_init_ea_size(struct obd_export *md_exp, struct obd_export *dt_exp) int rc, easize, def_easize, cookiesize; struct lov_desc desc; __u16 stripes; - ENTRY; rc = obd_get_info(NULL, dt_exp, sizeof(KEY_LOVDESC), KEY_LOVDESC, &valsize, &desc, NULL); @@ -95,7 +94,6 @@ int cl_ocd_update(struct obd_device *host, __u64 flags; int result; - ENTRY; if (!strcmp(watched->obd_type->typ_name, LUSTRE_OSC_NAME)) { cli = &watched->u.cli; lco = owner; diff --git a/drivers/staging/lustre/lustre/ldlm/interval_tree.c b/drivers/staging/lustre/lustre/ldlm/interval_tree.c index ce90c7e3c4886..7de620aa295f4 100644 --- a/drivers/staging/lustre/lustre/ldlm/interval_tree.c +++ b/drivers/staging/lustre/lustre/ldlm/interval_tree.c @@ -133,8 +133,6 @@ for (node = interval_last(root); node != NULL; \ static struct interval_node *interval_first(struct interval_node *node) { - ENTRY; - if (!node) RETURN(NULL); while (node->in_left) @@ -144,8 +142,6 @@ static struct interval_node *interval_first(struct interval_node *node) static struct interval_node *interval_last(struct interval_node *node) { - ENTRY; - if (!node) RETURN(NULL); while (node->in_right) @@ -155,8 +151,6 @@ static struct interval_node *interval_last(struct interval_node *node) static struct interval_node *interval_next(struct interval_node *node) { - ENTRY; - if (!node) RETURN(NULL); if (node->in_right) @@ -168,8 +162,6 @@ static struct interval_node *interval_next(struct interval_node *node) static struct interval_node *interval_prev(struct interval_node *node) { - ENTRY; - if (!node) RETURN(NULL); @@ -188,7 +180,6 @@ enum interval_iter interval_iterate(struct interval_node *root, { struct interval_node *node; enum interval_iter rc = INTERVAL_ITER_CONT; - ENTRY; interval_for_each(node, root) { rc = func(node, data); @@ -206,7 +197,6 @@ enum interval_iter interval_iterate_reverse(struct interval_node *root, { struct interval_node *node; enum interval_iter rc = INTERVAL_ITER_CONT; - ENTRY; interval_for_each_reverse(node, root) { rc = func(node, data); @@ -225,7 +215,6 @@ struct interval_node *interval_find(struct interval_node *root, { struct interval_node *walk = root; int rc; - ENTRY; while (walk) { rc = extent_compare(ex, &walk->in_extent); @@ -326,7 +315,6 @@ static void interval_insert_color(struct interval_node *node, struct interval_node **root) { struct interval_node *parent, *gparent; - ENTRY; while ((parent = node->in_parent) && node_is_red(parent)) { gparent = parent->in_parent; @@ -381,7 +369,6 @@ struct interval_node *interval_insert(struct interval_node *node, { struct interval_node **p, *parent = NULL; - ENTRY; LASSERT(!interval_is_intree(node)); p = root; @@ -423,7 +410,6 @@ static void interval_erase_color(struct interval_node *node, struct interval_node **root) { struct interval_node *tmp; - ENTRY; while (node_is_black_or_0(node) && node != *root) { if (parent->in_left == node) { @@ -501,7 +487,6 @@ static void update_maxhigh(struct interval_node *node, __u64 old_maxhigh) { __u64 left_max, right_max; - ENTRY; while (node) { left_max = node->in_left ? node->in_left->in_max_high : 0; @@ -521,7 +506,6 @@ void interval_erase(struct interval_node *node, { struct interval_node *child, *parent; int color; - ENTRY; LASSERT(interval_is_intree(node)); node->in_intree = 0; diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c index f7432f78e3961..92fa314c669af 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c @@ -72,7 +72,6 @@ __u64 ldlm_extent_shift_kms(struct ldlm_lock *lock, __u64 old_kms) struct list_head *tmp; struct ldlm_lock *lck; __u64 kms = 0; - ENTRY; /* don't let another thread in ldlm_extent_shift_kms race in * just after we finish and take our lock into account in its @@ -103,7 +102,6 @@ struct kmem_cache *ldlm_interval_slab; struct ldlm_interval *ldlm_interval_alloc(struct ldlm_lock *lock) { struct ldlm_interval *node; - ENTRY; LASSERT(lock->l_resource->lr_type == LDLM_EXTENT); OBD_SLAB_ALLOC_PTR_GFP(node, ldlm_interval_slab, __GFP_IO); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c index 39973cb110a3b..b263121e2bf09 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c @@ -142,8 +142,6 @@ static inline void ldlm_flock_blocking_unlink(struct ldlm_lock *req) static inline void ldlm_flock_destroy(struct ldlm_lock *lock, ldlm_mode_t mode, __u64 flags) { - ENTRY; - LDLM_DEBUG(lock, "ldlm_flock_destroy(mode: %d, flags: 0x%llx)", mode, flags); @@ -254,7 +252,6 @@ ldlm_process_flock_lock(struct ldlm_lock *req, __u64 *flags, int first_enq, int splitted = 0; const struct ldlm_callback_suite null_cbs = { NULL }; int rc; - ENTRY; CDEBUG(D_DLMTRACE, "flags %#llx owner "LPU64" pid %u mode %u start " LPU64" end "LPU64"\n", *flags, @@ -546,7 +543,6 @@ static void ldlm_flock_interrupted_wait(void *data) { struct ldlm_lock *lock; - ENTRY; lock = ((struct ldlm_flock_wait_data *)data)->fwd_lock; @@ -581,7 +577,6 @@ ldlm_flock_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data) struct l_wait_info lwi; ldlm_error_t err; int rc = 0; - ENTRY; CDEBUG(D_DLMTRACE, "flags: 0x%llx data: %p getlk: %p\n", flags, data, getlk); @@ -705,8 +700,6 @@ EXPORT_SYMBOL(ldlm_flock_completion_ast); int ldlm_flock_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, void *data, int flag) { - ENTRY; - LASSERT(lock); LASSERT(flag == LDLM_CB_CANCELING); @@ -843,7 +836,6 @@ EXPORT_SYMBOL(ldlm_init_flock_export); void ldlm_destroy_flock_export(struct obd_export *exp) { - ENTRY; if (exp->exp_flock_hash) { cfs_hash_putref(exp->exp_flock_hash); exp->exp_flock_hash = NULL; diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c index 950f90acec043..d77156a98ad8b 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c @@ -60,7 +60,6 @@ static int import_set_conn(struct obd_import *imp, struct obd_uuid *uuid, struct ptlrpc_connection *ptlrpc_conn; struct obd_import_conn *imp_conn = NULL, *item; int rc = 0; - ENTRY; if (!create && !priority) { CDEBUG(D_HA, "Nothing to do\n"); @@ -141,7 +140,6 @@ int client_import_del_conn(struct obd_import *imp, struct obd_uuid *uuid) struct obd_import_conn *imp_conn; struct obd_export *dlmexp; int rc = -ENOENT; - ENTRY; spin_lock(&imp->imp_lock); if (list_empty(&imp->imp_conn_list)) { @@ -200,7 +198,6 @@ int client_import_find_conn(struct obd_import *imp, lnet_nid_t peer, { struct obd_import_conn *conn; int rc = -ENOENT; - ENTRY; spin_lock(&imp->imp_lock); list_for_each_entry(conn, &imp->imp_conn_list, oic_item) { @@ -267,7 +264,6 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg) ldlm_ns_type_t ns_type = LDLM_NS_TYPE_UNKNOWN; int rc; char *cli_name = lustre_cfg_buf(lcfg, 0); - ENTRY; /* In a more perfect world, we would hang a ptlrpc_client off of * obd_type and just use the values from there. */ @@ -466,8 +462,6 @@ EXPORT_SYMBOL(client_obd_setup); int client_obd_cleanup(struct obd_device *obddev) { - ENTRY; - ldlm_namespace_free_post(obddev->obd_namespace); obddev->obd_namespace = NULL; @@ -489,7 +483,6 @@ int client_connect_import(const struct lu_env *env, struct obd_connect_data *ocd; struct lustre_handle conn = { 0 }; int rc; - ENTRY; *exp = NULL; down_write(&cli->cl_sem); @@ -553,7 +546,6 @@ int client_disconnect_export(struct obd_export *exp) struct client_obd *cli; struct obd_import *imp; int rc = 0, err; - ENTRY; if (!obd) { CERROR("invalid export for disconnect: exp %p cookie "LPX64"\n", @@ -627,7 +619,6 @@ EXPORT_SYMBOL(client_disconnect_export); int target_pack_pool_reply(struct ptlrpc_request *req) { struct obd_device *obd; - ENTRY; /* Check that we still have all structures alive as this may * be some late RPC at shutdown time. */ @@ -674,7 +665,6 @@ void target_send_reply(struct ptlrpc_request *req, int rc, int fail_id) int netrc; struct ptlrpc_reply_state *rs; struct obd_export *exp; - ENTRY; if (req->rq_no_reply) { EXIT; diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index a9174209aa8f2..6b214d2ca562e 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -188,8 +188,6 @@ EXPORT_SYMBOL(ldlm_lock_get); */ void ldlm_lock_put(struct ldlm_lock *lock) { - ENTRY; - LASSERT(lock->l_resource != LP_POISON); LASSERT(atomic_read(&lock->l_refc) > 0); if (atomic_dec_and_test(&lock->l_refc)) { @@ -253,7 +251,6 @@ int ldlm_lock_remove_from_lru(struct ldlm_lock *lock) struct ldlm_namespace *ns = ldlm_lock_to_ns(lock); int rc; - ENTRY; if (lock->l_flags & LDLM_FL_NS_SRV) { LASSERT(list_empty(&lock->l_lru)); RETURN(0); @@ -289,7 +286,6 @@ void ldlm_lock_add_to_lru(struct ldlm_lock *lock) { struct ldlm_namespace *ns = ldlm_lock_to_ns(lock); - ENTRY; spin_lock(&ns->ns_lock); ldlm_lock_add_to_lru_nolock(lock); spin_unlock(&ns->ns_lock); @@ -304,7 +300,6 @@ void ldlm_lock_touch_in_lru(struct ldlm_lock *lock) { struct ldlm_namespace *ns = ldlm_lock_to_ns(lock); - ENTRY; if (lock->l_flags & LDLM_FL_NS_SRV) { LASSERT(list_empty(&lock->l_lru)); EXIT; @@ -341,8 +336,6 @@ void ldlm_lock_touch_in_lru(struct ldlm_lock *lock) */ int ldlm_lock_destroy_internal(struct ldlm_lock *lock) { - ENTRY; - if (lock->l_readers || lock->l_writers) { LDLM_ERROR(lock, "lock still has references"); LBUG(); @@ -393,7 +386,7 @@ int ldlm_lock_destroy_internal(struct ldlm_lock *lock) void ldlm_lock_destroy(struct ldlm_lock *lock) { int first; - ENTRY; + lock_res_and_lock(lock); first = ldlm_lock_destroy_internal(lock); unlock_res_and_lock(lock); @@ -412,7 +405,7 @@ void ldlm_lock_destroy(struct ldlm_lock *lock) void ldlm_lock_destroy_nolock(struct ldlm_lock *lock) { int first; - ENTRY; + first = ldlm_lock_destroy_internal(lock); /* drop reference from hashtable only for first destroy */ if (first) { @@ -450,7 +443,6 @@ struct portals_handle_ops lock_handle_ops = { static struct ldlm_lock *ldlm_lock_new(struct ldlm_resource *resource) { struct ldlm_lock *lock; - ENTRY; if (resource == NULL) LBUG(); @@ -507,7 +499,6 @@ int ldlm_lock_change_resource(struct ldlm_namespace *ns, struct ldlm_lock *lock, struct ldlm_resource *oldres = lock->l_resource; struct ldlm_resource *newres; int type; - ENTRY; LASSERT(ns_is_client(ns)); @@ -586,7 +577,6 @@ struct ldlm_lock *__ldlm_handle2lock(const struct lustre_handle *handle, __u64 flags) { struct ldlm_lock *lock; - ENTRY; LASSERT(handle); @@ -728,7 +718,6 @@ void ldlm_add_cp_work_item(struct ldlm_lock *lock, struct list_head *work_list) void ldlm_add_ast_work_item(struct ldlm_lock *lock, struct ldlm_lock *new, struct list_head *work_list) { - ENTRY; check_res_locked(lock->l_resource); if (new) ldlm_add_bl_work_item(lock, new, work_list); @@ -853,7 +842,6 @@ void ldlm_lock_decref_internal_nolock(struct ldlm_lock *lock, __u32 mode) void ldlm_lock_decref_internal(struct ldlm_lock *lock, __u32 mode) { struct ldlm_namespace *ns; - ENTRY; lock_res_and_lock(lock); @@ -940,7 +928,6 @@ EXPORT_SYMBOL(ldlm_lock_decref); void ldlm_lock_decref_and_cancel(struct lustre_handle *lockh, __u32 mode) { struct ldlm_lock *lock = __ldlm_handle2lock(lockh, 0); - ENTRY; LASSERT(lock != NULL); @@ -979,7 +966,6 @@ static void search_granted_lock(struct list_head *queue, { struct list_head *tmp; struct ldlm_lock *lock, *mode_end, *policy_end; - ENTRY; list_for_each(tmp, queue) { lock = list_entry(tmp, struct ldlm_lock, l_res_link); @@ -1062,7 +1048,6 @@ static void ldlm_granted_list_add_lock(struct ldlm_lock *lock, struct sl_insert_point *prev) { struct ldlm_resource *res = lock->l_resource; - ENTRY; check_res_locked(res); @@ -1099,7 +1084,6 @@ static void ldlm_granted_list_add_lock(struct ldlm_lock *lock, static void ldlm_grant_lock_with_skiplist(struct ldlm_lock *lock) { struct sl_insert_point prev; - ENTRY; LASSERT(lock->l_req_mode == lock->l_granted_mode); @@ -1122,7 +1106,6 @@ static void ldlm_grant_lock_with_skiplist(struct ldlm_lock *lock) void ldlm_grant_lock(struct ldlm_lock *lock, struct list_head *work_list) { struct ldlm_resource *res = lock->l_resource; - ENTRY; check_res_locked(res); @@ -1304,7 +1287,6 @@ ldlm_mode_t ldlm_lock_match(struct ldlm_namespace *ns, __u64 flags, struct ldlm_resource *res; struct ldlm_lock *lock, *old_lock = NULL; int rc = 0; - ENTRY; if (ns == NULL) { old_lock = ldlm_handle2lock(lockh); @@ -1425,7 +1407,6 @@ ldlm_mode_t ldlm_revalidate_lock_handle(struct lustre_handle *lockh, { struct ldlm_lock *lock; ldlm_mode_t mode = 0; - ENTRY; lock = ldlm_handle2lock(lockh); if (lock != NULL) { @@ -1459,7 +1440,6 @@ int ldlm_fill_lvb(struct ldlm_lock *lock, struct req_capsule *pill, enum req_location loc, void *data, int size) { void *lvb; - ENTRY; LASSERT(data != NULL); LASSERT(size >= 0); @@ -1567,7 +1547,6 @@ struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace *ns, { struct ldlm_lock *lock; struct ldlm_resource *res; - ENTRY; res = ldlm_resource_get(ns, NULL, res_id, type, 1); if (res == NULL) @@ -1634,7 +1613,6 @@ ldlm_error_t ldlm_lock_enqueue(struct ldlm_namespace *ns, int local = ns_is_client(ldlm_res_to_ns(res)); ldlm_error_t rc = ELDLM_OK; struct ldlm_interval *node = NULL; - ENTRY; lock->l_last_activity = cfs_time_current_sec(); /* policies are not executed on the client or during replay */ @@ -1736,7 +1714,6 @@ ldlm_work_bl_ast_lock(struct ptlrpc_request_set *rqset, void *opaq) struct ldlm_lock_desc d; int rc; struct ldlm_lock *lock; - ENTRY; if (list_empty(arg->list)) RETURN(-ENOENT); @@ -1773,7 +1750,6 @@ ldlm_work_cp_ast_lock(struct ptlrpc_request_set *rqset, void *opaq) int rc = 0; struct ldlm_lock *lock; ldlm_completion_callback completion_callback; - ENTRY; if (list_empty(arg->list)) RETURN(-ENOENT); @@ -1818,7 +1794,6 @@ ldlm_work_revoke_ast_lock(struct ptlrpc_request_set *rqset, void *opaq) struct ldlm_lock_desc desc; int rc; struct ldlm_lock *lock; - ENTRY; if (list_empty(arg->list)) RETURN(-ENOENT); @@ -1846,7 +1821,6 @@ int ldlm_work_gl_ast_lock(struct ptlrpc_request_set *rqset, void *opaq) struct ldlm_glimpse_work *gl_work; struct ldlm_lock *lock; int rc = 0; - ENTRY; if (list_empty(arg->list)) RETURN(-ENOENT); @@ -1958,8 +1932,6 @@ static int ldlm_reprocess_res(cfs_hash_t *hs, cfs_hash_bd_t *bd, */ void ldlm_reprocess_all_ns(struct ldlm_namespace *ns) { - ENTRY; - if (ns != NULL) { cfs_hash_for_each_nolock(ns->ns_rs_hash, ldlm_reprocess_res, NULL); @@ -1980,7 +1952,6 @@ void ldlm_reprocess_all(struct ldlm_resource *res) { LIST_HEAD(rpc_list); - ENTRY; if (!ns_is_client(ldlm_res_to_ns(res))) { CERROR("This is client-side-only module, cannot handle " "LDLM_NAMESPACE_SERVER resource type lock.\n"); @@ -2030,7 +2001,6 @@ void ldlm_lock_cancel(struct ldlm_lock *lock) { struct ldlm_resource *res; struct ldlm_namespace *ns; - ENTRY; lock_res_and_lock(lock); @@ -2077,7 +2047,6 @@ int ldlm_lock_set_data(struct lustre_handle *lockh, void *data) { struct ldlm_lock *lock = ldlm_handle2lock(lockh); int rc = -EINVAL; - ENTRY; if (lock) { if (lock->l_ast_data == NULL) @@ -2158,8 +2127,6 @@ void ldlm_cancel_locks_for_export(struct obd_export *exp) */ void ldlm_lock_downgrade(struct ldlm_lock *lock, int new_mode) { - ENTRY; - LASSERT(lock->l_granted_mode & (LCK_PW | LCK_EX)); LASSERT(new_mode == LCK_COS); @@ -2195,7 +2162,6 @@ struct ldlm_resource *ldlm_lock_convert(struct ldlm_lock *lock, int new_mode, struct ldlm_namespace *ns; int granted = 0; struct ldlm_interval *node; - ENTRY; /* Just return if mode is unchanged. */ if (new_mode == lock->l_granted_mode) { diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c index d18936a059d87..adab8b81c8528 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c @@ -146,7 +146,6 @@ void ldlm_handle_bl_callback(struct ldlm_namespace *ns, struct ldlm_lock_desc *ld, struct ldlm_lock *lock) { int do_ast; - ENTRY; LDLM_DEBUG(lock, "client blocking AST callback handler"); @@ -188,7 +187,6 @@ static void ldlm_handle_cp_callback(struct ptlrpc_request *req, int lvb_len; LIST_HEAD(ast_list); int rc = 0; - ENTRY; LDLM_DEBUG(lock, "client completion callback handler START"); @@ -332,7 +330,6 @@ static void ldlm_handle_gl_callback(struct ptlrpc_request *req, struct ldlm_lock *lock) { int rc = -ENOSYS; - ENTRY; LDLM_DEBUG(lock, "client glimpse AST callback handler"); @@ -382,7 +379,6 @@ static int __ldlm_bl_to_thread(struct ldlm_bl_work_item *blwi, ldlm_cancel_flags_t cancel_flags) { struct ldlm_bl_pool *blp = ldlm_state->ldlm_bl_pool; - ENTRY; spin_lock(&blp->blp_lock); if (blwi->blwi_lock && @@ -446,8 +442,6 @@ static int ldlm_bl_to_thread(struct ldlm_namespace *ns, struct list_head *cancels, int count, ldlm_cancel_flags_t cancel_flags) { - ENTRY; - if (cancels && count == 0) RETURN(0); @@ -494,7 +488,6 @@ static int ldlm_handle_setinfo(struct ptlrpc_request *req) void *val; int keylen, vallen; int rc = -ENOSYS; - ENTRY; DEBUG_REQ(D_HSM, req, "%s: handle setinfo\n", obd->obd_name); @@ -568,7 +561,6 @@ static int ldlm_callback_handler(struct ptlrpc_request *req) struct ldlm_request *dlm_req; struct ldlm_lock *lock; int rc; - ENTRY; /* Requests arrive in sender's byte order. The ptlrpc service * handler has already checked and, if necessary, byte-swapped the @@ -834,7 +826,6 @@ static int ldlm_bl_thread_start(struct ldlm_bl_pool *blp) static int ldlm_bl_thread_main(void *arg) { struct ldlm_bl_pool *blp; - ENTRY; { struct ldlm_bl_thread_data *bltd = arg; @@ -916,7 +907,7 @@ static int ldlm_cleanup(void); int ldlm_get_ref(void) { int rc = 0; - ENTRY; + mutex_lock(&ldlm_ref_mutex); if (++ldlm_refcount == 1) { rc = ldlm_setup(); @@ -931,7 +922,6 @@ EXPORT_SYMBOL(ldlm_get_ref); void ldlm_put_ref(void) { - ENTRY; mutex_lock(&ldlm_ref_mutex); if (ldlm_refcount == 1) { int rc = ldlm_cleanup(); @@ -1018,8 +1008,6 @@ static cfs_hash_ops_t ldlm_export_lock_ops = { int ldlm_init_export(struct obd_export *exp) { - ENTRY; - exp->exp_lock_hash = cfs_hash_create(obd_uuid2str(&exp->exp_client_uuid), HASH_EXP_LOCK_CUR_BITS, @@ -1039,7 +1027,6 @@ EXPORT_SYMBOL(ldlm_init_export); void ldlm_destroy_export(struct obd_export *exp) { - ENTRY; cfs_hash_putref(exp->exp_lock_hash); exp->exp_lock_hash = NULL; @@ -1054,7 +1041,6 @@ static int ldlm_setup(void) struct ldlm_bl_pool *blp = NULL; int rc = 0; int i; - ENTRY; if (ldlm_state != NULL) RETURN(-EALREADY); @@ -1150,8 +1136,6 @@ static int ldlm_setup(void) static int ldlm_cleanup(void) { - ENTRY; - if (!list_empty(ldlm_namespace_list(LDLM_NAMESPACE_SERVER)) || !list_empty(ldlm_namespace_list(LDLM_NAMESPACE_CLIENT))) { CERROR("ldlm still has namespaces; clean these up first.\n"); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c index 101af4be9ffb3..5a1d11e0159a4 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c @@ -335,7 +335,6 @@ static void ldlm_srv_pool_push_slv(struct ldlm_pool *pl) static int ldlm_srv_pool_recalc(struct ldlm_pool *pl) { time_t recalc_interval_sec; - ENTRY; recalc_interval_sec = cfs_time_current_sec() - pl->pl_recalc_time; if (recalc_interval_sec < pl->pl_recalc_period) @@ -473,7 +472,6 @@ static void ldlm_cli_pool_pop_slv(struct ldlm_pool *pl) static int ldlm_cli_pool_recalc(struct ldlm_pool *pl) { time_t recalc_interval_sec; - ENTRY; recalc_interval_sec = cfs_time_current_sec() - pl->pl_recalc_time; if (recalc_interval_sec < pl->pl_recalc_period) @@ -733,7 +731,6 @@ static int ldlm_pool_proc_init(struct ldlm_pool *pl) struct lprocfs_vars pool_vars[2]; char *var_name = NULL; int rc = 0; - ENTRY; OBD_ALLOC(var_name, MAX_STRING_SIZE + 1); if (!var_name) @@ -835,7 +832,6 @@ int ldlm_pool_init(struct ldlm_pool *pl, struct ldlm_namespace *ns, int idx, ldlm_side_t client) { int rc; - ENTRY; spin_lock_init(&pl->pl_lock); atomic_set(&pl->pl_granted, 0); @@ -873,7 +869,6 @@ EXPORT_SYMBOL(ldlm_pool_init); void ldlm_pool_fini(struct ldlm_pool *pl) { - ENTRY; ldlm_pool_proc_fini(pl); /* @@ -1302,7 +1297,6 @@ static int ldlm_pools_thread_main(void *arg) { struct ptlrpc_thread *thread = (struct ptlrpc_thread *)arg; int s_time, c_time; - ENTRY; thread_set_flags(thread, SVC_RUNNING); wake_up(&thread->t_ctl_waitq); @@ -1349,7 +1343,6 @@ static int ldlm_pools_thread_start(void) { struct l_wait_info lwi = { 0 }; task_t *task; - ENTRY; if (ldlm_pools_thread != NULL) RETURN(-EALREADY); @@ -1376,8 +1369,6 @@ static int ldlm_pools_thread_start(void) static void ldlm_pools_thread_stop(void) { - ENTRY; - if (ldlm_pools_thread == NULL) { EXIT; return; @@ -1400,7 +1391,6 @@ static void ldlm_pools_thread_stop(void) int ldlm_pools_init(void) { int rc; - ENTRY; rc = ldlm_pools_thread_start(); if (rc == 0) { diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c index 6f21a1204a645..0b6dc6a288a54 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c @@ -94,7 +94,6 @@ int ldlm_expired_completion_wait(void *data) struct obd_import *imp; struct obd_device *obd; - ENTRY; if (lock->l_conn_export == NULL) { static cfs_time_t next_dump = 0, last_dump = 0; @@ -184,8 +183,6 @@ static int ldlm_completion_tail(struct ldlm_lock *lock) */ int ldlm_completion_ast_async(struct ldlm_lock *lock, __u64 flags, void *data) { - ENTRY; - if (flags == LDLM_FL_WAIT_NOREPROC) { LDLM_DEBUG(lock, "client-side enqueue waiting on pending lock"); RETURN(0); @@ -234,7 +231,6 @@ int ldlm_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data) struct l_wait_info lwi; __u32 timeout; int rc = 0; - ENTRY; if (flags == LDLM_FL_WAIT_NOREPROC) { LDLM_DEBUG(lock, "client-side enqueue waiting on pending lock"); @@ -316,7 +312,6 @@ EXPORT_SYMBOL(ldlm_completion_ast); int ldlm_blocking_ast_nocheck(struct ldlm_lock *lock) { int do_ast; - ENTRY; lock->l_flags |= LDLM_FL_CBPENDING; do_ast = (!lock->l_readers && !lock->l_writers); @@ -355,8 +350,6 @@ EXPORT_SYMBOL(ldlm_blocking_ast_nocheck); int ldlm_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, void *data, int flag) { - ENTRY; - if (flag == LDLM_CB_CANCELING) { /* Don't need to do anything here. */ RETURN(0); @@ -424,7 +417,6 @@ int ldlm_cli_enqueue_local(struct ldlm_namespace *ns, .lcs_blocking = blocking, .lcs_glimpse = glimpse, }; - ENTRY; LASSERT(!(*flags & LDLM_FL_REPLAY)); if (unlikely(ns_is_client(ns))) { @@ -530,7 +522,6 @@ int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req, struct ldlm_reply *reply; int cleanup_phase = 1; int size = 0; - ENTRY; lock = ldlm_handle2lock(lockh); /* ldlm_cli_enqueue is holding a reference on this lock. */ @@ -763,7 +754,6 @@ int ldlm_prep_elc_req(struct obd_export *exp, struct ptlrpc_request *req, int flags, avail, to_free, pack = 0; LIST_HEAD(head); int rc; - ENTRY; if (cancels == NULL) cancels = &head; @@ -830,7 +820,6 @@ struct ptlrpc_request *ldlm_enqueue_pack(struct obd_export *exp, int lvb_len) { struct ptlrpc_request *req; int rc; - ENTRY; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_LDLM_ENQUEUE); if (req == NULL) @@ -872,7 +861,6 @@ int ldlm_cli_enqueue(struct obd_export *exp, struct ptlrpc_request **reqp, int req_passed_in = 1; int rc, err; struct ptlrpc_request *req; - ENTRY; LASSERT(exp != NULL); @@ -1010,7 +998,7 @@ static int ldlm_cli_convert_local(struct ldlm_lock *lock, int new_mode, { struct ldlm_resource *res; int rc; - ENTRY; + if (ns_is_client(ldlm_lock_to_ns(lock))) { CERROR("Trying to cancel local lock\n"); LBUG(); @@ -1041,7 +1029,6 @@ int ldlm_cli_convert(struct lustre_handle *lockh, int new_mode, __u32 *flags) struct ldlm_resource *res; struct ptlrpc_request *req; int rc; - ENTRY; lock = ldlm_handle2lock(lockh); if (!lock) { @@ -1114,7 +1101,6 @@ EXPORT_SYMBOL(ldlm_cli_convert); static __u64 ldlm_cli_cancel_local(struct ldlm_lock *lock) { __u64 rc = LDLM_FL_LOCAL_ONLY; - ENTRY; if (lock->l_conn_export) { bool local_only; @@ -1158,7 +1144,6 @@ static void ldlm_cancel_pack(struct ptlrpc_request *req, struct ldlm_request *dlm; struct ldlm_lock *lock; int max, packed = 0; - ENTRY; dlm = req_capsule_client_get(&req->rq_pill, &RMF_DLM_REQ); LASSERT(dlm != NULL); @@ -1196,7 +1181,6 @@ int ldlm_cli_cancel_req(struct obd_export *exp, struct list_head *cancels, struct obd_import *imp; int free, sent = 0; int rc = 0; - ENTRY; LASSERT(exp != NULL); LASSERT(count > 0); @@ -1289,7 +1273,7 @@ int ldlm_cli_update_pool(struct ptlrpc_request *req) struct obd_device *obd; __u64 new_slv; __u32 new_limit; - ENTRY; + if (unlikely(!req->rq_import || !req->rq_import->imp_obd || !imp_connect_lru_resize(req->rq_import))) { @@ -1345,7 +1329,6 @@ int ldlm_cli_cancel(struct lustre_handle *lockh, struct ldlm_namespace *ns; struct ldlm_lock *lock; LIST_HEAD(cancels); - ENTRY; /* concurrent cancels on the same handle can happen */ lock = ldlm_handle2lock_long(lockh, LDLM_FL_CANCELING); @@ -1630,7 +1613,6 @@ static int ldlm_prepare_lru_list(struct ldlm_namespace *ns, struct list_head *ca ldlm_cancel_lru_policy_t pf; struct ldlm_lock *lock, *next; int added = 0, unused, remained; - ENTRY; spin_lock(&ns->ns_lock); unused = ns->ns_nr_unused; @@ -1781,7 +1763,6 @@ int ldlm_cancel_lru(struct ldlm_namespace *ns, int nr, { LIST_HEAD(cancels); int count, rc; - ENTRY; /* Just prepare the list of locks, do not actually cancel them yet. * Locks are cancelled later in a separate thread. */ @@ -1806,7 +1787,6 @@ int ldlm_cancel_resource_local(struct ldlm_resource *res, { struct ldlm_lock *lock; int count = 0; - ENTRY; lock_res(res); list_for_each_entry(lock, &res->lr_granted, l_res_link) { @@ -1866,7 +1846,6 @@ int ldlm_cli_cancel_list(struct list_head *cancels, int count, { struct ldlm_lock *lock; int res = 0; - ENTRY; if (list_empty(cancels) || count == 0) RETURN(0); @@ -1925,7 +1904,6 @@ int ldlm_cli_cancel_unused_resource(struct ldlm_namespace *ns, LIST_HEAD(cancels); int count; int rc; - ENTRY; res = ldlm_resource_get(ns, NULL, res_id, 0, 0); if (res == NULL) { @@ -1985,8 +1963,6 @@ int ldlm_cli_cancel_unused(struct ldlm_namespace *ns, .lc_opaque = opaque, }; - ENTRY; - if (ns == NULL) RETURN(ELDLM_OK); @@ -2011,8 +1987,6 @@ int ldlm_resource_foreach(struct ldlm_resource *res, ldlm_iterator_t iter, struct ldlm_lock *lock; int rc = LDLM_ITER_CONTINUE; - ENTRY; - if (!res) RETURN(LDLM_ITER_CONTINUE); @@ -2090,7 +2064,6 @@ int ldlm_resource_iterate(struct ldlm_namespace *ns, { struct ldlm_resource *res; int rc; - ENTRY; if (ns == NULL) { CERROR("must pass in namespace\n"); @@ -2139,7 +2112,6 @@ static int replay_lock_interpret(const struct lu_env *env, struct ldlm_reply *reply; struct obd_export *exp; - ENTRY; atomic_dec(&req->rq_import->imp_replay_inflight); if (rc != ELDLM_OK) GOTO(out, rc); @@ -2189,8 +2161,6 @@ static int replay_one_lock(struct obd_import *imp, struct ldlm_lock *lock) struct ldlm_async_args *aa; struct ldlm_request *body; int flags; - ENTRY; - /* Bug 11974: Do not replay a lock which is actively being canceled */ if (lock->l_flags & LDLM_FL_CANCELING) { @@ -2302,8 +2272,6 @@ int ldlm_replay_locks(struct obd_import *imp) struct ldlm_lock *lock, *next; int rc = 0; - ENTRY; - LASSERT(atomic_read(&imp->imp_replay_inflight) == 0); /* don't replay locks if import failed recovery */ diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index 616cb17efc303..8b2b3fa16112d 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -95,7 +95,6 @@ int ldlm_proc_setup(void) { "cancel_unused_locks_before_replay", &ldlm_rw_uint_fops, &ldlm_cancel_unused_locks_before_replay }, { NULL }}; - ENTRY; LASSERT(ldlm_ns_proc_dir == NULL); ldlm_type_proc_dir = lprocfs_register(OBD_LDLM_DEVICENAME, @@ -568,7 +567,6 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name, cfs_hash_bd_t bd; int idx; int rc; - ENTRY; LASSERT(obd != NULL); @@ -808,8 +806,6 @@ EXPORT_SYMBOL(ldlm_namespace_cleanup); */ static int __ldlm_namespace_free(struct ldlm_namespace *ns, int force) { - ENTRY; - /* At shutdown time, don't call the cancellation callback */ ldlm_namespace_cleanup(ns, force ? LDLM_FL_LOCAL_ONLY : 0); @@ -864,7 +860,7 @@ void ldlm_namespace_free_prior(struct ldlm_namespace *ns, int force) { int rc; - ENTRY; + if (!ns) { EXIT; return; @@ -901,7 +897,6 @@ void ldlm_namespace_free_prior(struct ldlm_namespace *ns, */ void ldlm_namespace_free_post(struct ldlm_namespace *ns) { - ENTRY; if (!ns) { EXIT; return; diff --git a/drivers/staging/lustre/lustre/libcfs/debug.c b/drivers/staging/lustre/lustre/libcfs/debug.c index 5a87b08320742..20682d8e7f2a5 100644 --- a/drivers/staging/lustre/lustre/libcfs/debug.c +++ b/drivers/staging/lustre/lustre/libcfs/debug.c @@ -362,7 +362,6 @@ void libcfs_debug_dumplog(void) { wait_queue_t wait; task_t *dumper; - ENTRY; /* we're being careful to ensure that the kernel thread is * able to set our state to running as it exits before we diff --git a/drivers/staging/lustre/lustre/libcfs/hash.c b/drivers/staging/lustre/lustre/libcfs/hash.c index 98c76dfac3ddb..bc7497a9b0649 100644 --- a/drivers/staging/lustre/lustre/libcfs/hash.c +++ b/drivers/staging/lustre/lustre/libcfs/hash.c @@ -1026,8 +1026,6 @@ cfs_hash_create(char *name, unsigned cur_bits, unsigned max_bits, cfs_hash_t *hs; int len; - ENTRY; - CLASSERT(CFS_HASH_THETA_BITS < 15); LASSERT(name != NULL); @@ -1101,7 +1099,6 @@ cfs_hash_destroy(cfs_hash_t *hs) struct hlist_node *pos; cfs_hash_bd_t bd; int i; - ENTRY; LASSERT(hs != NULL); LASSERT(!cfs_hash_is_exiting(hs) && @@ -1449,7 +1446,6 @@ cfs_hash_for_each_tight(cfs_hash_t *hs, cfs_hash_for_each_cb_t func, int excl = !!remove_safe; int loop = 0; int i; - ENTRY; cfs_hash_for_each_enter(hs); @@ -1594,7 +1590,6 @@ cfs_hash_for_each_relax(cfs_hash_t *hs, cfs_hash_for_each_cb_t func, void *data) int stop_on_change; int rc; int i; - ENTRY; stop_on_change = cfs_hash_with_rehash_key(hs) || !cfs_hash_with_no_itemref(hs) || @@ -1649,8 +1644,6 @@ int cfs_hash_for_each_nolock(cfs_hash_t *hs, cfs_hash_for_each_cb_t func, void *data) { - ENTRY; - if (cfs_hash_with_no_lock(hs) || cfs_hash_with_rehash_key(hs) || !cfs_hash_with_no_itemref(hs)) @@ -1685,7 +1678,6 @@ cfs_hash_for_each_empty(cfs_hash_t *hs, cfs_hash_for_each_cb_t func, void *data) { unsigned i = 0; - ENTRY; if (cfs_hash_with_no_lock(hs)) return -EOPNOTSUPP; diff --git a/drivers/staging/lustre/lustre/libcfs/kernel_user_comm.c b/drivers/staging/lustre/lustre/libcfs/kernel_user_comm.c index d6d3b2e0f3074..39cf56a09247a 100644 --- a/drivers/staging/lustre/lustre/libcfs/kernel_user_comm.c +++ b/drivers/staging/lustre/lustre/libcfs/kernel_user_comm.c @@ -246,7 +246,6 @@ EXPORT_SYMBOL(libcfs_kkuc_group_add); int libcfs_kkuc_group_rem(int uid, int group) { struct kkuc_reg *reg, *next; - ENTRY; if (kkuc_groups[group].next == NULL) RETURN(0); @@ -284,7 +283,6 @@ int libcfs_kkuc_group_put(int group, void *payload) struct kkuc_reg *reg; int rc = 0; int one_success = 0; - ENTRY; down_read(&kg_sem); list_for_each_entry(reg, &kkuc_groups[group], kr_chain) { @@ -320,7 +318,6 @@ int libcfs_kkuc_group_foreach(int group, libcfs_kkuc_cb_t cb_func, { struct kkuc_reg *reg; int rc = 0; - ENTRY; if (group > KUC_GRP_MAX) { CDEBUG(D_WARNING, "Kernelcomm: bad group %d\n", group); diff --git a/drivers/staging/lustre/lustre/libcfs/libcfs_string.c b/drivers/staging/lustre/lustre/libcfs/libcfs_string.c index c7a19711bb6af..922debd0a4128 100644 --- a/drivers/staging/lustre/lustre/libcfs/libcfs_string.c +++ b/drivers/staging/lustre/lustre/libcfs/libcfs_string.c @@ -69,7 +69,6 @@ int cfs_str2mask(const char *str, const char *(*bit2str)(int bit), const char *debugstr; char op = 0; int newmask = minmask, i, len, found = 0; - ENTRY; /* must be a list of tokens separated by whitespace * and optionally an operator ('+' or '-'). If an operator diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c index 706dfb39fc287..833c889348e26 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c @@ -212,7 +212,6 @@ int cfs_get_environ(const char *key, char *value, int *val_len) int key_len = strlen(key); unsigned long addr; int rc; - ENTRY; buffer = kmalloc(buf_len, GFP_USER); if (!buffer) diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c index 9b57304e6caa2..3e61a0d4574b6 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c @@ -78,7 +78,6 @@ void libcfs_run_debug_log_upcall(char *file) "HOME=/", "PATH=/sbin:/bin:/usr/sbin:/usr/bin", NULL}; - ENTRY; argv[0] = lnet_debug_log_upcall; @@ -108,7 +107,6 @@ void libcfs_run_upcall(char **argv) "HOME=/", "PATH=/sbin:/bin:/usr/sbin:/usr/bin", NULL}; - ENTRY; argv[0] = lnet_upcall; argc = 1; @@ -141,7 +139,6 @@ void libcfs_run_lbug_upcall(struct libcfs_debug_msg_data *msgdata) char *argv[6]; char buf[32]; - ENTRY; snprintf (buf, sizeof buf, "%d", msgdata->msg_line); argv[1] = "LBUG"; diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c index 7449f4f186402..004ff71663af4 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c @@ -45,7 +45,6 @@ int libcfs_ioctl_getdata(char *buf, char *end, void *arg) struct libcfs_ioctl_hdr *hdr; struct libcfs_ioctl_data *data; int err; - ENTRY; hdr = (struct libcfs_ioctl_hdr *)buf; data = (struct libcfs_ioctl_data *)buf; diff --git a/drivers/staging/lustre/lustre/libcfs/module.c b/drivers/staging/lustre/lustre/libcfs/module.c index 52525bc7ddb08..2a6db77bd0622 100644 --- a/drivers/staging/lustre/lustre/libcfs/module.c +++ b/drivers/staging/lustre/lustre/libcfs/module.c @@ -155,7 +155,6 @@ kportal_memhog_alloc (struct libcfs_device_userstate *ldu, int npages, int flags static int libcfs_psdev_open(unsigned long flags, void *args) { struct libcfs_device_userstate *ldu; - ENTRY; try_module_get(THIS_MODULE); @@ -173,7 +172,6 @@ static int libcfs_psdev_open(unsigned long flags, void *args) static int libcfs_psdev_release(unsigned long flags, void *args) { struct libcfs_device_userstate *ldu; - ENTRY; ldu = (struct libcfs_device_userstate *)args; if (ldu != NULL) { @@ -222,7 +220,6 @@ static int libcfs_ioctl_int(struct cfs_psdev_file *pfile,unsigned long cmd, void *arg, struct libcfs_ioctl_data *data) { int err = -EINVAL; - ENTRY; switch (cmd) { case IOC_LIBCFS_CLEAR_DEBUG: @@ -330,7 +327,6 @@ static int libcfs_ioctl(struct cfs_psdev_file *pfile, unsigned long cmd, void *a char *buf; struct libcfs_ioctl_data *data; int err = 0; - ENTRY; LIBCFS_ALLOC_GFP(buf, 1024, GFP_IOFS); if (buf == NULL) diff --git a/drivers/staging/lustre/lustre/libcfs/nidstrings.c b/drivers/staging/lustre/lustre/libcfs/nidstrings.c index ccfd1078a906f..0260e69a14dd3 100644 --- a/drivers/staging/lustre/lustre/libcfs/nidstrings.c +++ b/drivers/staging/lustre/lustre/libcfs/nidstrings.c @@ -785,7 +785,6 @@ cfs_parse_nidlist(char *str, int len, struct list_head *nidlist) struct cfs_lstr src; struct cfs_lstr res; int rc; - ENTRY; src.ls_str = str; src.ls_len = len; @@ -834,7 +833,6 @@ int cfs_match_nid(lnet_nid_t nid, struct list_head *nidlist) { struct nidrange *nr; struct addrrange *ar; - ENTRY; list_for_each_entry(nr, nidlist, nr_link) { if (nr->nr_netstrfns->nf_type != LNET_NETTYP(LNET_NIDNET(nid))) diff --git a/drivers/staging/lustre/lustre/libcfs/upcall_cache.c b/drivers/staging/lustre/lustre/libcfs/upcall_cache.c index 18c68c3493b89..7663fb5683713 100644 --- a/drivers/staging/lustre/lustre/libcfs/upcall_cache.c +++ b/drivers/staging/lustre/lustre/libcfs/upcall_cache.c @@ -152,7 +152,6 @@ struct upcall_cache_entry *upcall_cache_get_entry(struct upcall_cache *cache, struct list_head *head; wait_queue_t wait; int rc, found; - ENTRY; LASSERT(cache); @@ -273,8 +272,6 @@ EXPORT_SYMBOL(upcall_cache_get_entry); void upcall_cache_put_entry(struct upcall_cache *cache, struct upcall_cache_entry *entry) { - ENTRY; - if (!entry) { EXIT; return; @@ -294,7 +291,6 @@ int upcall_cache_downcall(struct upcall_cache *cache, __u32 err, __u64 key, struct upcall_cache_entry *entry = NULL; struct list_head *head; int found = 0, rc = 0; - ENTRY; LASSERT(cache); @@ -364,7 +360,6 @@ static void cache_flush(struct upcall_cache *cache, int force) { struct upcall_cache_entry *entry, *next; int i; - ENTRY; spin_lock(&cache->uc_lock); for (i = 0; i < UC_CACHE_HASH_SIZE; i++) { @@ -399,7 +394,6 @@ void upcall_cache_flush_one(struct upcall_cache *cache, __u64 key, void *args) struct list_head *head; struct upcall_cache_entry *entry; int found = 0; - ENTRY; head = &cache->uc_hashtable[UC_CACHE_HASH_INDEX(key)]; @@ -431,7 +425,6 @@ struct upcall_cache *upcall_cache_init(const char *name, const char *upcall, { struct upcall_cache *cache; int i; - ENTRY; LIBCFS_ALLOC(cache, sizeof(*cache)); if (!cache) diff --git a/drivers/staging/lustre/lustre/llite/dcache.c b/drivers/staging/lustre/lustre/llite/dcache.c index 0d49e1bfb6bbf..628fae410bdbf 100644 --- a/drivers/staging/lustre/lustre/llite/dcache.c +++ b/drivers/staging/lustre/lustre/llite/dcache.c @@ -59,7 +59,7 @@ static void free_dentry_data(struct rcu_head *head) static void ll_release(struct dentry *de) { struct ll_dentry_data *lld; - ENTRY; + LASSERT(de != NULL); lld = ll_d2d(de); if (lld == NULL) /* NFS copies the de->d_op methods (bug 4655) */ @@ -87,8 +87,6 @@ static void ll_release(struct dentry *de) int ll_dcompare(const struct dentry *parent, const struct dentry *dentry, unsigned int len, const char *str, const struct qstr *name) { - ENTRY; - if (len != name->len) RETURN(1); @@ -127,7 +125,6 @@ static int find_cbdata(struct inode *inode) struct ll_sb_info *sbi = ll_i2sbi(inode); struct lov_stripe_md *lsm; int rc = 0; - ENTRY; LASSERT(inode); rc = md_find_cbdata(sbi->ll_md_exp, ll_inode2fid(inode), @@ -154,7 +151,6 @@ static int find_cbdata(struct inode *inode) */ static int ll_ddelete(const struct dentry *de) { - ENTRY; LASSERT(de); CDEBUG(D_DENTRY, "%s dentry %.*s (%p, parent %p, inode %p) %s%s\n", @@ -184,7 +180,6 @@ static int ll_ddelete(const struct dentry *de) static int ll_set_dd(struct dentry *de) { - ENTRY; LASSERT(de != NULL); CDEBUG(D_DENTRY, "ldd on dentry %.*s (%p) parent %p inode %p refc %d\n", @@ -259,8 +254,6 @@ void ll_intent_drop_lock(struct lookup_intent *it) void ll_intent_release(struct lookup_intent *it) { - ENTRY; - CDEBUG(D_INFO, "intent %p released\n", it); ll_intent_drop_lock(it); /* We are still holding extra reference on a request, need to free it */ @@ -281,7 +274,6 @@ void ll_invalidate_aliases(struct inode *inode) { struct dentry *dentry; struct ll_d_hlist_node *p; - ENTRY; LASSERT(inode != NULL); @@ -315,7 +307,6 @@ int ll_revalidate_it_finish(struct ptlrpc_request *request, struct dentry *de) { int rc = 0; - ENTRY; if (!request) RETURN(0); @@ -370,7 +361,6 @@ int ll_revalidate_it(struct dentry *de, int lookup_flags, struct inode *parent = de->d_parent->d_inode; int rc; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:name=%s,intent=%s\n", de->d_name.name, LL_IT2STR(it)); @@ -639,7 +629,6 @@ int ll_revalidate_nd(struct dentry *dentry, unsigned int flags) struct inode *parent = dentry->d_parent->d_inode; int unplug = 0; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:name=%s,flags=%u\n", dentry->d_name.name, flags); diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index 2ca8c4534bd5e..55256812ae207 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -157,7 +157,6 @@ static int ll_dir_filler(void *_hash, struct page *page0) int npages; int i; int rc; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p) hash "LPU64"\n", inode->i_ino, inode->i_generation, inode, hash); @@ -489,7 +488,6 @@ int ll_dir_read(struct inode *inode, struct dir_context *ctx) struct ll_dir_chain chain; int done = 0; int rc = 0; - ENTRY; ll_dir_chain_init(&chain); @@ -603,7 +601,6 @@ static int ll_readdir(struct file *filp, struct dir_context *ctx) int hash64 = sbi->ll_flags & LL_SBI_64BIT_HASH; int api32 = ll_need_32bit_api(sbi); int rc; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p) pos %lu/%llu " " 32bit_api %d\n", inode->i_ino, inode->i_generation, @@ -664,8 +661,6 @@ int ll_dir_setdirstripe(struct inode *dir, struct lmv_user_md *lump, int mode; int err; - ENTRY; - mode = (0755 & (S_IRWXUGO|S_ISVTX) & ~current->fs->umask) | S_IFDIR; op_data = ll_prep_md_op_data(NULL, dir, NULL, filename, strlen(filename), mode, LUSTRE_OPC_MKDIR, @@ -696,7 +691,6 @@ int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump, struct lustre_sb_info *lsi = s2lsi(inode->i_sb); struct obd_device *mgc = lsi->lsi_mgc; int lum_size; - ENTRY; if (lump != NULL) { /* @@ -870,7 +864,6 @@ int ll_get_mdt_idx(struct inode *inode) struct ll_sb_info *sbi = ll_i2sbi(inode); struct md_op_data *op_data; int rc, mdtidx; - ENTRY; op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0, LUSTRE_OPC_ANY, NULL); @@ -904,7 +897,6 @@ static int ll_ioc_copy_start(struct super_block *sb, struct hsm_copy *copy) struct ll_sb_info *sbi = ll_s2sbi(sb); struct hsm_progress_kernel hpk; int rc; - ENTRY; /* Forge a hsm_progress based on data from copy. */ hpk.hpk_fid = copy->hc_hai.hai_fid; @@ -977,7 +969,6 @@ static int ll_ioc_copy_end(struct super_block *sb, struct hsm_copy *copy) struct ll_sb_info *sbi = ll_s2sbi(sb); struct hsm_progress_kernel hpk; int rc; - ENTRY; /* If you modify the logic here, also check llapi_hsm_copy_end(). */ /* Take care: copy->hc_hai.hai_action, len, gid and data are not @@ -1082,7 +1073,6 @@ static int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl) int id = qctl->qc_id; int valid = qctl->qc_valid; int rc = 0; - ENTRY; switch (cmd) { case LUSTRE_Q_INVALIDATE: @@ -1243,7 +1233,6 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) struct ll_sb_info *sbi = ll_i2sbi(inode); struct obd_ioctl_data *data; int rc = 0; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p), cmd=%#x\n", inode->i_ino, inode->i_generation, inode, cmd); @@ -1907,7 +1896,6 @@ static loff_t ll_dir_seek(struct file *file, loff_t offset, int origin) struct ll_sb_info *sbi = ll_i2sbi(inode); int api32 = ll_need_32bit_api(sbi); loff_t ret = -EINVAL; - ENTRY; mutex_lock(&inode->i_mutex); switch (origin) { @@ -1953,13 +1941,11 @@ static loff_t ll_dir_seek(struct file *file, loff_t offset, int origin) int ll_dir_open(struct inode *inode, struct file *file) { - ENTRY; RETURN(ll_file_open(inode, file)); } int ll_dir_release(struct inode *inode, struct file *file) { - ENTRY; RETURN(ll_file_release(inode, file)); } diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 20416fcf2e9c3..79f5394ac6b25 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -95,8 +95,6 @@ void ll_pack_inode2opdata(struct inode *inode, struct md_op_data *op_data, static void ll_prepare_close(struct inode *inode, struct md_op_data *op_data, struct obd_client_handle *och) { - ENTRY; - op_data->op_attr.ia_valid = ATTR_MODE | ATTR_ATIME | ATTR_ATIME_SET | ATTR_MTIME | ATTR_MTIME_SET | ATTR_CTIME | ATTR_CTIME_SET; @@ -126,7 +124,6 @@ static int ll_close_inode_openhandle(struct obd_export *md_exp, struct obd_device *obd = class_exp2obd(exp); int epoch_close = 1; int rc; - ENTRY; if (obd == NULL) { /* @@ -204,7 +201,6 @@ int ll_md_real_close(struct inode *inode, int flags) struct obd_client_handle *och; __u64 *och_usecount; int rc = 0; - ENTRY; if (flags & FMODE_WRITE) { och_p = &lli->lli_mds_write_och; @@ -243,7 +239,6 @@ int ll_md_close(struct obd_export *md_exp, struct inode *inode, struct ll_file_data *fd = LUSTRE_FPRIVATE(file); struct ll_inode_info *lli = ll_i2info(inode); int rc = 0; - ENTRY; /* clear group lock, if present */ if (unlikely(fd->fd_flags & LL_FILE_GROUP_LOCKED)) @@ -303,7 +298,6 @@ int ll_file_release(struct inode *inode, struct file *file) struct ll_sb_info *sbi = ll_i2sbi(inode); struct ll_inode_info *lli = ll_i2info(inode); int rc; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino, inode->i_generation, inode); @@ -364,7 +358,6 @@ static int ll_intent_file_open(struct file *file, void *lmm, struct ptlrpc_request *req; __u32 opc = LUSTRE_OPC_ANY; int rc; - ENTRY; if (!parent) RETURN(-ENOENT); @@ -466,7 +459,6 @@ int ll_local_open(struct file *file, struct lookup_intent *it, { struct inode *inode = file->f_dentry->d_inode; struct ll_inode_info *lli = ll_i2info(inode); - ENTRY; LASSERT(!LUSTRE_FPRIVATE(file)); @@ -516,7 +508,6 @@ int ll_file_open(struct inode *inode, struct file *file) __u64 *och_usecount = NULL; struct ll_file_data *fd; int rc = 0, opendir_set = 0; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p), flags %o\n", inode->i_ino, inode->i_generation, inode, file->f_flags); @@ -702,8 +693,6 @@ static int ll_lsm_getattr(struct lov_stripe_md *lsm, struct obd_export *exp, struct obd_info oinfo = { { { 0 } } }; int rc; - ENTRY; - LASSERT(lsm != NULL); oinfo.oi_md = lsm; @@ -751,7 +740,6 @@ int ll_inode_getattr(struct inode *inode, struct obdo *obdo, struct obd_capa *capa = ll_mdscapa_get(inode); struct lov_stripe_md *lsm; int rc; - ENTRY; lsm = ccc_inode_lsm_get(inode); rc = ll_lsm_getattr(lsm, ll_i2dtexp(inode), @@ -778,8 +766,6 @@ int ll_merge_lvb(const struct lu_env *env, struct inode *inode) struct ost_lvb lvb; int rc = 0; - ENTRY; - ll_inode_size_lock(inode); /* merge timestamps the most recently obtained from mds with timestamps obtained from osts */ @@ -862,7 +848,6 @@ ll_file_io_generic(const struct lu_env *env, struct vvp_io_args *args, struct ll_file_data *fd = LUSTRE_FPRIVATE(file); struct cl_io *io; ssize_t result; - ENTRY; restart: io = ccc_env_thread_io(env); @@ -988,7 +973,6 @@ static ssize_t ll_file_aio_read(struct kiocb *iocb, const struct iovec *iov, size_t count; ssize_t result; int refcheck; - ENTRY; result = ll_file_get_iov_count(iov, &nr_segs, &count); if (result) @@ -1017,7 +1001,6 @@ static ssize_t ll_file_read(struct file *file, char *buf, size_t count, struct kiocb *kiocb; ssize_t result; int refcheck; - ENTRY; env = cl_env_get(&refcheck); if (IS_ERR(env)) @@ -1049,7 +1032,6 @@ static ssize_t ll_file_aio_write(struct kiocb *iocb, const struct iovec *iov, size_t count; ssize_t result; int refcheck; - ENTRY; result = ll_file_get_iov_count(iov, &nr_segs, &count); if (result) @@ -1078,7 +1060,6 @@ static ssize_t ll_file_write(struct file *file, const char *buf, size_t count, struct kiocb *kiocb; ssize_t result; int refcheck; - ENTRY; env = cl_env_get(&refcheck); if (IS_ERR(env)) @@ -1112,7 +1093,6 @@ static ssize_t ll_file_splice_read(struct file *in_file, loff_t *ppos, struct vvp_io_args *args; ssize_t result; int refcheck; - ENTRY; env = cl_env_get(&refcheck); if (IS_ERR(env)) @@ -1136,7 +1116,6 @@ static int ll_lov_recreate(struct inode *inode, struct ost_id *oi, int lsm_size; int rc = 0; struct lov_stripe_md *lsm = NULL, *lsm2; - ENTRY; OBDO_ALLOC(oa); if (oa == NULL) @@ -1177,7 +1156,6 @@ static int ll_lov_recreate_obj(struct inode *inode, unsigned long arg) { struct ll_recreate_obj ucreat; struct ost_id oi; - ENTRY; if (!cfs_capable(CFS_CAP_SYS_ADMIN)) RETURN(-EPERM); @@ -1196,7 +1174,6 @@ static int ll_lov_recreate_fid(struct inode *inode, unsigned long arg) struct lu_fid fid; struct ost_id oi; obd_count ost_idx; - ENTRY; if (!cfs_capable(CFS_CAP_SYS_ADMIN)) RETURN(-EPERM); @@ -1215,7 +1192,6 @@ int ll_lov_setstripe_ea_info(struct inode *inode, struct file *file, struct lov_stripe_md *lsm = NULL; struct lookup_intent oit = {.it_op = IT_OPEN, .it_flags = flags}; int rc = 0; - ENTRY; lsm = ccc_inode_lsm_get(inode); if (lsm != NULL) { @@ -1337,7 +1313,6 @@ static int ll_lov_setea(struct inode *inode, struct file *file, int lum_size = sizeof(struct lov_user_md) + sizeof(struct lov_user_ost_data); int rc; - ENTRY; if (!cfs_capable(CFS_CAP_SYS_ADMIN)) RETURN(-EPERM); @@ -1366,7 +1341,6 @@ static int ll_lov_setstripe(struct inode *inode, struct file *file, struct lov_user_md_v3 *lumv3p = (struct lov_user_md_v3 *)arg; int lum_size, rc; int flags = FMODE_WRITE; - ENTRY; /* first try with v1 which is smaller than v3 */ lum_size = sizeof(struct lov_user_md_v1); @@ -1399,7 +1373,6 @@ static int ll_lov_getstripe(struct inode *inode, unsigned long arg) { struct lov_stripe_md *lsm; int rc = -ENODATA; - ENTRY; lsm = ccc_inode_lsm_get(inode); if (lsm != NULL) @@ -1415,7 +1388,6 @@ int ll_get_grouplock(struct inode *inode, struct file *file, unsigned long arg) struct ll_file_data *fd = LUSTRE_FPRIVATE(file); struct ccc_grouplock grouplock; int rc; - ENTRY; if (ll_file_nolock(file)) RETURN(-EOPNOTSUPP); @@ -1456,7 +1428,6 @@ int ll_put_grouplock(struct inode *inode, struct file *file, unsigned long arg) struct ll_inode_info *lli = ll_i2info(inode); struct ll_file_data *fd = LUSTRE_FPRIVATE(file); struct ccc_grouplock grouplock; - ENTRY; spin_lock(&lli->lli_lock); if (!(fd->fd_flags & LL_FILE_GROUP_LOCKED)) { @@ -1497,7 +1468,6 @@ int ll_release_openhandle(struct dentry *dentry, struct lookup_intent *it) struct inode *inode = dentry->d_inode; struct obd_client_handle *och; int rc; - ENTRY; LASSERT(inode); @@ -1541,7 +1511,6 @@ int ll_do_fiemap(struct inode *inode, struct ll_user_fiemap *fiemap, struct ll_fiemap_info_key fm_key = { .name = KEY_FIEMAP, }; int vallen = num_bytes; int rc; - ENTRY; /* Checks for fiemap flags */ if (fiemap->fm_flags & ~LUSTRE_FIEMAP_FLAGS_COMPAT) { @@ -1595,7 +1564,6 @@ int ll_fid2path(struct inode *inode, void *arg) struct obd_export *exp = ll_i2mdexp(inode); struct getinfo_fid2path *gfout, *gfin; int outsize, rc; - ENTRY; if (!cfs_capable(CFS_CAP_DAC_READ_SEARCH) && !(ll_i2sbi(inode)->ll_flags & LL_SBI_USER_FID2PATH)) @@ -1700,7 +1668,6 @@ int ll_data_version(struct inode *inode, __u64 *data_version, struct ll_sb_info *sbi = ll_i2sbi(inode); struct obdo *obdo = NULL; int rc; - ENTRY; /* If no stripe, we consider version is 0. */ lsm = ccc_inode_lsm_get(inode); @@ -1895,7 +1862,6 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) struct inode *inode = file->f_dentry->d_inode; struct ll_file_data *fd = LUSTRE_FPRIVATE(file); int flags, rc; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p),cmd=%x\n", inode->i_ino, inode->i_generation, inode, cmd); @@ -2132,7 +2098,6 @@ loff_t ll_file_seek(struct file *file, loff_t offset, int origin) struct inode *inode = file->f_dentry->d_inode; loff_t retval, eof = 0; - ENTRY; retval = offset + ((origin == SEEK_END) ? i_size_read(inode) : (origin == SEEK_CUR) ? file->f_pos : 0); CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p), to=%llu=%#llx(%d)\n", @@ -2191,7 +2156,6 @@ int cl_sync_file_range(struct inode *inode, loff_t start, loff_t end, struct obd_capa *capa = NULL; struct cl_fsync_io *fio; int result; - ENTRY; if (mode != CL_FSYNC_NONE && mode != CL_FSYNC_LOCAL && mode != CL_FSYNC_DISCARD && mode != CL_FSYNC_ALL) @@ -2244,7 +2208,6 @@ int ll_fsync(struct file *file, loff_t start, loff_t end, int datasync) struct ptlrpc_request *req; struct obd_capa *oc; int rc, err; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino, inode->i_generation, inode); @@ -2306,7 +2269,6 @@ int ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock) int flags = 0; int rc; int rc2 = 0; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu file_lock=%p\n", inode->i_ino, file_lock); @@ -2423,8 +2385,6 @@ int ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock) int ll_file_noflock(struct file *file, int cmd, struct file_lock *file_lock) { - ENTRY; - RETURN(-ENOSYS); } @@ -2447,7 +2407,6 @@ int ll_have_md_lock(struct inode *inode, __u64 *bits, ldlm_mode_t l_req_mode) struct lu_fid *fid; __u64 flags; int i; - ENTRY; if (!inode) RETURN(0); @@ -2485,7 +2444,6 @@ ldlm_mode_t ll_take_md_lock(struct inode *inode, __u64 bits, ldlm_policy_data_t policy = { .l_inodebits = {bits}}; struct lu_fid *fid; ldlm_mode_t rc; - ENTRY; fid = &ll_i2info(inode)->lli_fid; CDEBUG(D_INFO, "trying to match res "DFID"\n", PFID(fid)); @@ -2522,7 +2480,6 @@ int __ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it, struct ptlrpc_request *req = NULL; struct obd_export *exp; int rc = 0; - ENTRY; LASSERT(inode != NULL); @@ -2617,7 +2574,6 @@ int ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it, { struct inode *inode = dentry->d_inode; int rc; - ENTRY; rc = __ll_inode_revalidate_it(dentry, it, ibits); if (rc != 0) @@ -2681,7 +2637,6 @@ struct posix_acl * ll_get_acl(struct inode *inode, int type) { struct ll_inode_info *lli = ll_i2info(inode); struct posix_acl *acl = NULL; - ENTRY; spin_lock(&lli->lli_lock); /* VFS' acl_permission_check->check_acl will release the refcount */ @@ -2695,7 +2650,6 @@ struct posix_acl * ll_get_acl(struct inode *inode, int type) int ll_inode_permission(struct inode *inode, int mask) { int rc = 0; - ENTRY; #ifdef MAY_NOT_BLOCK if (mask & MAY_NOT_BLOCK) @@ -2815,7 +2769,6 @@ void *ll_iocontrol_register(llioc_callback_t cb, int count, unsigned int *cmd) { unsigned int size; struct llioc_data *in_data = NULL; - ENTRY; if (cb == NULL || cmd == NULL || count > LLIOC_MAX_CMD || count < 0) @@ -2899,7 +2852,6 @@ int ll_layout_conf(struct inode *inode, const struct cl_object_conf *conf) struct cl_env_nest nest; struct lu_env *env; int result; - ENTRY; if (lli->lli_clob == NULL) RETURN(0); @@ -2939,7 +2891,6 @@ static int ll_layout_fetch(struct inode *inode, struct ldlm_lock *lock) void *lmm; int lmmsize; int rc; - ENTRY; CDEBUG(D_INODE, DFID" LVB_READY=%d l_lvb_data=%p l_lvb_len=%d\n", PFID(ll_inode2fid(inode)), !!(lock->l_flags & LDLM_FL_LVB_READY), @@ -3010,7 +2961,6 @@ static int ll_layout_lock_set(struct lustre_handle *lockh, ldlm_mode_t mode, int rc = 0; bool lvb_ready; bool wait_layout = false; - ENTRY; LASSERT(lustre_handle_is_used(lockh)); @@ -3132,7 +3082,6 @@ int ll_layout_refresh(struct inode *inode, __u32 *gen) .ei_cb_cp = ldlm_completion_ast, }; int rc; - ENTRY; *gen = lli->lli_layout_gen; if (!(sbi->ll_flags & LL_SBI_LAYOUT_LOCK)) diff --git a/drivers/staging/lustre/lustre/llite/llite_capa.c b/drivers/staging/lustre/lustre/llite/llite_capa.c index cfc5ad388c1cb..061a0a574b5d5 100644 --- a/drivers/staging/lustre/lustre/llite/llite_capa.c +++ b/drivers/staging/lustre/lustre/llite/llite_capa.c @@ -170,7 +170,6 @@ static int capa_thread_main(void *unused) struct inode *inode = NULL; struct l_wait_info lwi = { 0 }; int rc; - ENTRY; thread_set_flags(&ll_capa_thread, SVC_RUNNING); wake_up(&ll_capa_thread.t_ctl_waitq); @@ -291,7 +290,6 @@ void ll_capa_timer_callback(unsigned long unused) int ll_capa_thread_start(void) { task_t *task; - ENTRY; init_waitqueue_head(&ll_capa_thread.t_ctl_waitq); @@ -321,8 +319,6 @@ struct obd_capa *ll_osscapa_get(struct inode *inode, __u64 opc) struct obd_capa *ocapa; int found = 0; - ENTRY; - if ((ll_i2sbi(inode)->ll_flags & LL_SBI_OSS_CAPA) == 0) RETURN(NULL); @@ -376,7 +372,6 @@ struct obd_capa *ll_mdscapa_get(struct inode *inode) { struct ll_inode_info *lli = ll_i2info(inode); struct obd_capa *ocapa; - ENTRY; LASSERT(inode != NULL); @@ -524,7 +519,6 @@ int ll_update_capa(struct obd_capa *ocapa, struct lustre_capa *capa) { struct inode *inode = ocapa->u.cli.inode; int rc = 0; - ENTRY; LASSERT(ocapa); diff --git a/drivers/staging/lustre/lustre/llite/llite_close.c b/drivers/staging/lustre/lustre/llite/llite_close.c index 00b2b38d4c970..20481d8329b0a 100644 --- a/drivers/staging/lustre/lustre/llite/llite_close.c +++ b/drivers/staging/lustre/lustre/llite/llite_close.c @@ -50,7 +50,6 @@ void vvp_write_pending(struct ccc_object *club, struct ccc_page *page) { struct ll_inode_info *lli = ll_i2info(club->cob_inode); - ENTRY; spin_lock(&lli->lli_lock); lli->lli_flags |= LLIF_SOM_DIRTY; if (page != NULL && list_empty(&page->cpg_pending_linkage)) @@ -66,7 +65,6 @@ void vvp_write_complete(struct ccc_object *club, struct ccc_page *page) struct ll_inode_info *lli = ll_i2info(club->cob_inode); int rc = 0; - ENTRY; spin_lock(&lli->lli_lock); if (page != NULL && !list_empty(&page->cpg_pending_linkage)) { list_del_init(&page->cpg_pending_linkage); @@ -85,7 +83,6 @@ void ll_queue_done_writing(struct inode *inode, unsigned long flags) { struct ll_inode_info *lli = ll_i2info(inode); struct ccc_object *club = cl2ccc(ll_i2info(inode)->lli_clob); - ENTRY; spin_lock(&lli->lli_lock); lli->lli_flags |= flags; @@ -126,7 +123,6 @@ void ll_queue_done_writing(struct inode *inode, unsigned long flags) void ll_done_writing_attr(struct inode *inode, struct md_op_data *op_data) { struct ll_inode_info *lli = ll_i2info(inode); - ENTRY; op_data->op_flags |= MF_SOM_CHANGE; /* Check if Size-on-MDS attributes are valid. */ @@ -149,7 +145,6 @@ void ll_ioepoch_close(struct inode *inode, struct md_op_data *op_data, { struct ll_inode_info *lli = ll_i2info(inode); struct ccc_object *club = cl2ccc(ll_i2info(inode)->lli_clob); - ENTRY; spin_lock(&lli->lli_lock); if (!(list_empty(&club->cob_pending_list))) { @@ -225,7 +220,6 @@ int ll_som_update(struct inode *inode, struct md_op_data *op_data) __u32 old_flags; struct obdo *oa; int rc; - ENTRY; LASSERT(op_data != NULL); if (lli->lli_flags & LLIF_MDS_SIZE_LOCK) @@ -293,7 +287,6 @@ static void ll_done_writing(struct inode *inode) struct obd_client_handle *och = NULL; struct md_op_data *op_data; int rc; - ENTRY; LASSERT(exp_connect_som(ll_i2mdexp(inode))); @@ -347,7 +340,6 @@ static struct ll_inode_info *ll_close_next_lli(struct ll_close_queue *lcq) static int ll_close_thread(void *arg) { struct ll_close_queue *lcq = arg; - ENTRY; complete(&lcq->lcq_comp); diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index b44a3d6d0eddf..141243658d7c6 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -78,7 +78,6 @@ static struct ll_sb_info *ll_init_sbi(void) struct sysinfo si; class_uuid_t uuid; int i; - ENTRY; OBD_ALLOC(sbi, sizeof(*sbi)); if (!sbi) @@ -146,7 +145,6 @@ static struct ll_sb_info *ll_init_sbi(void) void ll_free_sbi(struct super_block *sb) { struct ll_sb_info *sbi = ll_s2sbi(sb); - ENTRY; if (sbi != NULL) { spin_lock(&ll_sb_lock); @@ -177,7 +175,6 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, struct lustre_md lmd; obd_valid valid; int size, err, checksum; - ENTRY; obd = class_name2obd(md); if (!obd) { @@ -677,7 +674,6 @@ void lustre_dump_dentry(struct dentry *dentry, int recur) void client_common_put_super(struct super_block *sb) { struct ll_sb_info *sbi = ll_s2sbi(sb); - ENTRY; #ifdef CONFIG_FS_POSIX_ACL if (sbi->ll_flags & LL_SBI_RMT_CLIENT) { @@ -712,8 +708,6 @@ void ll_kill_super(struct super_block *sb) { struct ll_sb_info *sbi; - ENTRY; - /* not init sb ?*/ if (!(sb->s_flags & MS_ACTIVE)) return; @@ -733,7 +727,6 @@ char *ll_read_opt(const char *opt, char *data) { char *value; char *retval; - ENTRY; CDEBUG(D_SUPER, "option: %s, data %s\n", opt, data); if (strncmp(opt, data, strlen(opt))) @@ -766,7 +759,6 @@ static int ll_options(char *options, int *flags) { int tmp; char *s1 = options, *s2; - ENTRY; if (!options) RETURN(0); @@ -978,7 +970,6 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt) /* %p for void* in printf needs 16+2 characters: 0xffffffffffffffff */ const int instlen = sizeof(cfg->cfg_instance) * 2 + 2; int err; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb); @@ -1070,7 +1061,6 @@ void ll_put_super(struct super_block *sb) struct ll_sb_info *sbi = ll_s2sbi(sb); char *profilenm = get_profile_name(sb); int next, force = 1; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op: sb %p - %s\n", sb, profilenm); @@ -1177,7 +1167,6 @@ void ll_clear_inode(struct inode *inode) { struct ll_inode_info *lli = ll_i2info(inode); struct ll_sb_info *sbi = ll_i2sbi(inode); - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino, inode->i_generation, inode); @@ -1250,7 +1239,6 @@ int ll_md_setattr(struct dentry *dentry, struct md_op_data *op_data, struct ll_sb_info *sbi = ll_i2sbi(inode); struct ptlrpc_request *request = NULL; int rc, ia_valid; - ENTRY; op_data = ll_prep_md_op_data(op_data, inode, NULL, NULL, 0, 0, LUSTRE_OPC_ANY, NULL); @@ -1309,7 +1297,6 @@ static int ll_setattr_done_writing(struct inode *inode, { struct ll_inode_info *lli = ll_i2info(inode); int rc = 0; - ENTRY; LASSERT(op_data != NULL); if (!S_ISREG(inode->i_mode)) @@ -1375,7 +1362,6 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr) struct md_op_data *op_data = NULL; struct md_open_data *mod = NULL; int rc = 0, rc1 = 0; - ENTRY; CDEBUG(D_VFSTRACE, "%s: setattr inode %p/fid:"DFID" from %llu to %llu, " "valid %x\n", ll_get_fsname(inode->i_sb, NULL, 0), inode, @@ -1540,7 +1526,6 @@ int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs, struct ll_sb_info *sbi = ll_s2sbi(sb); struct obd_statfs obd_osfs; int rc; - ENTRY; rc = obd_statfs(NULL, sbi->ll_md_exp, osfs, max_age, flags); if (rc) { @@ -1791,7 +1776,6 @@ void ll_read_inode2(struct inode *inode, void *opaque) { struct lustre_md *md = opaque; struct ll_inode_info *lli = ll_i2info(inode); - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:inode="DFID"(%p)\n", PFID(&lli->lli_fid), inode); @@ -1840,7 +1824,6 @@ void ll_read_inode2(struct inode *inode, void *opaque) void ll_delete_inode(struct inode *inode) { struct cl_inode_info *lli = cl_i2info(inode); - ENTRY; if (S_ISREG(inode->i_mode) && lli->lli_clob != NULL) /* discard all dirty pages before truncating them, required by @@ -1874,7 +1857,6 @@ int ll_iocontrol(struct inode *inode, struct file *file, struct ll_sb_info *sbi = ll_i2sbi(inode); struct ptlrpc_request *req = NULL; int rc, flags = 0; - ENTRY; switch(cmd) { case FSFILT_IOC_GETFLAGS: { @@ -1984,8 +1966,6 @@ void ll_umount_begin(struct super_block *sb) struct ll_sb_info *sbi = ll_s2sbi(sb); struct obd_device *obd; struct obd_ioctl_data *ioc_data; - ENTRY; - CDEBUG(D_VFSTRACE, "VFS Op: superblock %p count %d active %d\n", sb, sb->s_count, atomic_read(&sb->s_active)); @@ -2066,7 +2046,6 @@ int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req, struct ll_sb_info *sbi = NULL; struct lustre_md md; int rc; - ENTRY; LASSERT(*inode || sb); sbi = sb ? ll_s2sbi(sb) : ll_i2sbi(*inode); @@ -2321,7 +2300,6 @@ int ll_get_obd_name(struct inode *inode, unsigned int cmd, unsigned long arg) { struct ll_sb_info *sbi = ll_i2sbi(inode); struct obd_device *obd; - ENTRY; if (cmd == OBD_IOC_GETDTNAME) obd = class_exp2obd(sbi->ll_dt_exp); diff --git a/drivers/staging/lustre/lustre/llite/llite_mmap.c b/drivers/staging/lustre/lustre/llite/llite_mmap.c index b59cbd704ab65..d98a40f61bfce 100644 --- a/drivers/staging/lustre/lustre/llite/llite_mmap.c +++ b/drivers/staging/lustre/lustre/llite/llite_mmap.c @@ -70,7 +70,6 @@ struct vm_area_struct *our_vma(struct mm_struct *mm, unsigned long addr, size_t count) { struct vm_area_struct *vma, *ret = NULL; - ENTRY; /* mmap_sem must have been held by caller. */ LASSERT(!down_write_trylock(&mm->mmap_sem)); @@ -109,7 +108,6 @@ struct cl_io *ll_fault_io_init(struct vm_area_struct *vma, struct cl_fault_io *fio; struct lu_env *env; int rc; - ENTRY; *env_ret = NULL; if (ll_file_nolock(file)) @@ -182,7 +180,6 @@ static int ll_page_mkwrite0(struct vm_area_struct *vma, struct page *vmpage, sigset_t set; struct inode *inode; struct ll_inode_info *lli; - ENTRY; LASSERT(vmpage != NULL); @@ -306,7 +303,6 @@ static int ll_fault0(struct vm_area_struct *vma, struct vm_fault *vmf) struct cl_env_nest nest; int result; int fault_ret = 0; - ENTRY; io = ll_fault_io_init(vma, &env, &nest, vmf->pgoff, &ra_flags); if (IS_ERR(io)) @@ -433,7 +429,6 @@ static void ll_vm_open(struct vm_area_struct * vma) struct inode *inode = vma->vm_file->f_dentry->d_inode; struct ccc_object *vob = cl_inode2ccc(inode); - ENTRY; LASSERT(vma->vm_file); LASSERT(atomic_read(&vob->cob_mmap_cnt) >= 0); atomic_inc(&vob->cob_mmap_cnt); @@ -448,7 +443,6 @@ static void ll_vm_close(struct vm_area_struct *vma) struct inode *inode = vma->vm_file->f_dentry->d_inode; struct ccc_object *vob = cl_inode2ccc(inode); - ENTRY; LASSERT(vma->vm_file); atomic_dec(&vob->cob_mmap_cnt); LASSERT(atomic_read(&vob->cob_mmap_cnt) >= 0); @@ -468,7 +462,6 @@ static inline unsigned long file_to_user(struct vm_area_struct *vma, __u64 byte) int ll_teardown_mmaps(struct address_space *mapping, __u64 first, __u64 last) { int rc = -ENOENT; - ENTRY; LASSERTF(last > first, "last "LPU64" first "LPU64"\n", last, first); if (mapping_mapped(mapping)) { @@ -491,7 +484,6 @@ int ll_file_mmap(struct file *file, struct vm_area_struct * vma) { struct inode *inode = file->f_dentry->d_inode; int rc; - ENTRY; if (ll_file_nolock(file)) RETURN(-EOPNOTSUPP); diff --git a/drivers/staging/lustre/lustre/llite/llite_nfs.c b/drivers/staging/lustre/lustre/llite/llite_nfs.c index 32362ece2a7b3..d2661bb20db6b 100644 --- a/drivers/staging/lustre/lustre/llite/llite_nfs.c +++ b/drivers/staging/lustre/lustre/llite/llite_nfs.c @@ -91,7 +91,6 @@ struct inode *search_inode_for_lustre(struct super_block *sb, ll_need_32bit_api(sbi)); struct md_op_data *op_data; int rc; - ENTRY; CDEBUG(D_INFO, "searching inode for:(%lu,"DFID")\n", hash, PFID(fid)); @@ -139,7 +138,6 @@ ll_iget_for_nfs(struct super_block *sb, struct lu_fid *fid, struct lu_fid *paren { struct inode *inode; struct dentry *result; - ENTRY; CDEBUG(D_INFO, "Get dentry for fid: "DFID"\n", PFID(fid)); if (!fid_is_sane(fid)) @@ -192,7 +190,6 @@ static int ll_encode_fh(struct inode *inode, __u32 *fh, int *plen, struct inode *parent) { struct lustre_nfs_fid *nfs_fid = (void *)fh; - ENTRY; CDEBUG(D_INFO, "encoding for (%lu,"DFID") maxlen=%d minlen=%d\n", inode->i_ino, PFID(ll_inode2fid(inode)), *plen, @@ -236,7 +233,6 @@ static int ll_get_name(struct dentry *dentry, char *name, .lgd_fid = ll_i2info(child->d_inode)->lli_fid, .ctx.actor = ll_nfs_get_name_filldir, }; - ENTRY; if (!dir || !S_ISDIR(dir->i_mode)) GOTO(out, rc = -ENOTDIR); @@ -288,7 +284,6 @@ static struct dentry *ll_get_parent(struct dentry *dchild) struct md_op_data *op_data; int rc; int lmmsize; - ENTRY; LASSERT(dir && S_ISDIR(dir->i_mode)); diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 3ad391ae58945..8485aa166e43a 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -379,7 +379,6 @@ static ssize_t ll_max_cached_mb_seq_write(struct file *file, const char *buffer, int mult, rc, pages_number; int diff = 0; int nrpages = 0; - ENTRY; mult = 1 << (20 - PAGE_CACHE_SHIFT); buffer = lprocfs_find_named_value(buffer, "max_cached_mb:", &count); @@ -855,7 +854,6 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent, proc_dir_entry_t *dir; char name[MAX_STRING_SIZE + 1], *ptr; int err, id, len, rc; - ENTRY; memset(lvars, 0, sizeof(lvars)); diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c index 333e55f692f19..cc0d0a70bd1f7 100644 --- a/drivers/staging/lustre/lustre/llite/namei.c +++ b/drivers/staging/lustre/lustre/llite/namei.c @@ -77,8 +77,6 @@ static int ll_d_mountpoint(struct dentry *dparent, struct dentry *dchild, int ll_unlock(__u32 mode, struct lustre_handle *lockh) { - ENTRY; - ldlm_lock_decref(lockh, mode); RETURN(0); @@ -139,7 +137,6 @@ struct inode *ll_iget(struct super_block *sb, ino_t hash, struct lustre_md *md) { struct inode *inode; - ENTRY; LASSERT(hash != 0); inode = iget5_locked(sb, hash, ll_test_inode, ll_set_inode, md); @@ -200,7 +197,6 @@ int ll_md_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, { int rc; struct lustre_handle lockh; - ENTRY; switch (flag) { case LDLM_CB_BLOCKING: @@ -433,7 +429,6 @@ int ll_lookup_it_finish(struct ptlrpc_request *request, struct inode *inode = NULL; __u64 bits = 0; int rc; - ENTRY; /* NB 1 request reference will be taken away by ll_intent_lock() * when I return */ @@ -496,7 +491,6 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry, struct it_cb_data icbd; __u32 opc; int rc; - ENTRY; if (dentry->d_name.len > ll_i2sbi(parent)->ll_namelen) RETURN(ERR_PTR(-ENAMETOOLONG)); @@ -621,7 +615,6 @@ static int ll_atomic_open(struct inode *dir, struct dentry *dentry, struct dentry *de; long long lookup_flags = LOOKUP_OPEN; int rc = 0; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p),file %p," "open_flags %x,mode %x opened %d\n", @@ -703,7 +696,6 @@ static struct inode *ll_create_node(struct inode *dir, const char *name, struct ptlrpc_request *request = NULL; struct ll_sb_info *sbi = ll_i2sbi(dir); int rc; - ENTRY; LASSERT(it && it->d.lustre.it_disposition); @@ -747,7 +739,6 @@ static int ll_create_it(struct inode *dir, struct dentry *dentry, int mode, { struct inode *inode; int rc = 0; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p),intent=%s\n", dentry->d_name.len, dentry->d_name.name, dir->i_ino, @@ -798,7 +789,6 @@ static int ll_new_node(struct inode *dir, struct qstr *name, int tgt_len = 0; int err; - ENTRY; if (unlikely(tgt != NULL)) tgt_len = strlen(tgt) + 1; @@ -835,7 +825,6 @@ static int ll_mknod_generic(struct inode *dir, struct qstr *name, int mode, unsigned rdev, struct dentry *dchild) { int err; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p) mode %o dev %x\n", name->len, name->name, dir->i_ino, dir->i_generation, dir, @@ -895,7 +884,6 @@ static int ll_symlink_generic(struct inode *dir, struct qstr *name, const char *tgt, struct dentry *dchild) { int err; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p),target=%.*s\n", name->len, name->name, dir->i_ino, dir->i_generation, @@ -918,7 +906,6 @@ static int ll_link_generic(struct inode *src, struct inode *dir, struct md_op_data *op_data; int err; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op: inode=%lu/%u(%p), dir=%lu/%u(%p), target=%.*s\n", src->i_ino, src->i_generation, src, dir->i_ino, @@ -947,7 +934,6 @@ static int ll_mkdir_generic(struct inode *dir, struct qstr *name, { int err; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p)\n", name->len, name->name, dir->i_ino, dir->i_generation, dir); @@ -985,7 +971,6 @@ static int ll_rmdir_generic(struct inode *dir, struct dentry *dparent, struct ptlrpc_request *request = NULL; struct md_op_data *op_data; int rc; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p)\n", name->len, name->name, dir->i_ino, dir->i_generation, dir); @@ -1019,7 +1004,6 @@ int ll_rmdir_entry(struct inode *dir, char *name, int namelen) struct ptlrpc_request *request = NULL; struct md_op_data *op_data; int rc; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p)\n", namelen, name, dir->i_ino, dir->i_generation, dir); @@ -1049,7 +1033,6 @@ int ll_objects_destroy(struct ptlrpc_request *request, struct inode *dir) struct obdo *oa; struct obd_capa *oc = NULL; int rc; - ENTRY; /* req is swabbed so this is safe */ body = req_capsule_server_get(&request->rq_pill, &RMF_MDT_BODY); @@ -1126,7 +1109,6 @@ static int ll_unlink_generic(struct inode *dir, struct dentry *dparent, struct ptlrpc_request *request = NULL; struct md_op_data *op_data; int rc; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p)\n", name->len, name->name, dir->i_ino, dir->i_generation, dir); @@ -1167,7 +1149,7 @@ static int ll_rename_generic(struct inode *src, struct dentry *src_dparent, struct ll_sb_info *sbi = ll_i2sbi(src); struct md_op_data *op_data; int err; - ENTRY; + CDEBUG(D_VFSTRACE,"VFS Op:oldname=%.*s,src_dir=%lu/%u(%p),newname=%.*s," "tgt_dir=%lu/%u(%p)\n", src_name->len, src_name->name, src->i_ino, src->i_generation, src, tgt_name->len, diff --git a/drivers/staging/lustre/lustre/llite/remote_perm.c b/drivers/staging/lustre/lustre/llite/remote_perm.c index 0bc334803c900..1d29d7ccb70cc 100644 --- a/drivers/staging/lustre/lustre/llite/remote_perm.c +++ b/drivers/staging/lustre/lustre/llite/remote_perm.c @@ -123,7 +123,6 @@ static int do_check_remote_perm(struct ll_inode_info *lli, int mask) struct hlist_head *head; struct ll_remote_perm *lrp; int found = 0, rc; - ENTRY; if (!lli->lli_remote_perms) RETURN(-ENOENT); @@ -163,7 +162,6 @@ int ll_update_remote_perm(struct inode *inode, struct mdt_remote_perm *perm) struct ll_inode_info *lli = ll_i2info(inode); struct ll_remote_perm *lrp = NULL, *tmp = NULL; struct hlist_head *head, *perm_hash = NULL; - ENTRY; LASSERT(ll_i2sbi(inode)->ll_flags & LL_SBI_RMT_CLIENT); @@ -253,7 +251,6 @@ int lustre_check_remote_perm(struct inode *inode, int mask) struct obd_capa *oc; cfs_time_t save; int i = 0, rc; - ENTRY; do { save = lli->lli_rmtperm_time; diff --git a/drivers/staging/lustre/lustre/llite/rw.c b/drivers/staging/lustre/lustre/llite/rw.c index ab4e95c635541..41430004e270e 100644 --- a/drivers/staging/lustre/lustre/llite/rw.c +++ b/drivers/staging/lustre/lustre/llite/rw.c @@ -225,7 +225,6 @@ int ll_prepare_write(struct file *file, struct page *vmpage, unsigned from, { struct ll_cl_context *lcc; int result; - ENTRY; lcc = ll_cl_init(file, vmpage, 1); if (!IS_ERR(lcc)) { @@ -264,7 +263,6 @@ int ll_commit_write(struct file *file, struct page *vmpage, unsigned from, struct cl_io *io; struct cl_page *page; int result = 0; - ENTRY; lcc = ll_cl_get(); env = lcc->lcc_env; @@ -322,7 +320,6 @@ static unsigned long ll_ra_count_get(struct ll_sb_info *sbi, { struct ll_ra_info *ra = &sbi->ll_ra_info; long ret; - ENTRY; /* If read-ahead pages left are less than 1M, do not do read-ahead, * otherwise it will form small read RPC(< 1M), which hurt server @@ -465,8 +462,6 @@ static int cl_read_ahead_page(const struct lu_env *env, struct cl_io *io, struct ccc_page *cp; int rc; - ENTRY; - rc = 0; cl_page_assume(env, io, page); lu_ref_add(&page->cp_reference, "ra", current); @@ -513,8 +508,6 @@ static int ll_read_ahead_page(const struct lu_env *env, struct cl_io *io, int rc = 0; const char *msg = NULL; - ENTRY; - gfp_mask = GFP_HIGHUSER & ~__GFP_WAIT; #ifdef __GFP_NOWARN gfp_mask |= __GFP_NOWARN; @@ -719,7 +712,6 @@ int ll_readahead(const struct lu_env *env, struct cl_io *io, struct cl_object *clob; int ret = 0; __u64 kms; - ENTRY; inode = mapping->host; lli = ll_i2info(inode); @@ -996,7 +988,6 @@ void ras_update(struct ll_sb_info *sbi, struct inode *inode, { struct ll_ra_info *ra = &sbi->ll_ra_info; int zero = 0, stride_detect = 0, ra_miss = 0; - ENTRY; spin_lock(&ras->ras_lock); @@ -1152,7 +1143,6 @@ int ll_writepage(struct page *vmpage, struct writeback_control *wbc) bool redirtied = false; bool unlocked = false; int result; - ENTRY; LASSERT(PageLocked(vmpage)); LASSERT(!PageWriteback(vmpage)); @@ -1244,7 +1234,6 @@ int ll_writepages(struct address_space *mapping, struct writeback_control *wbc) int range_whole = 0; int result; int ignore_layout = 0; - ENTRY; if (wbc->range_cyclic) { start = mapping->writeback_index << PAGE_CACHE_SHIFT; @@ -1285,7 +1274,6 @@ int ll_readpage(struct file *file, struct page *vmpage) { struct ll_cl_context *lcc; int result; - ENTRY; lcc = ll_cl_init(file, vmpage, 0); if (!IS_ERR(lcc)) { diff --git a/drivers/staging/lustre/lustre/llite/rw26.c b/drivers/staging/lustre/lustre/llite/rw26.c index 256ee6356b313..1a804773e43c5 100644 --- a/drivers/staging/lustre/lustre/llite/rw26.c +++ b/drivers/staging/lustre/lustre/llite/rw26.c @@ -247,7 +247,6 @@ ssize_t ll_direct_rw_pages(const struct lu_env *env, struct cl_io *io, long page_size = cl_page_size(obj); bool do_io; int io_pages = 0; - ENTRY; queue = &io->ci_queue; cl_2queue_init(queue); @@ -381,7 +380,6 @@ static ssize_t ll_direct_IO_26(int rw, struct kiocb *iocb, unsigned long seg = 0; long size = MAX_DIO_SIZE; int refcheck; - ENTRY; if (!lli->lli_has_smd) RETURN(-EBADF); @@ -504,7 +502,6 @@ static int ll_write_begin(struct file *file, struct address_space *mapping, struct page *page; int rc; unsigned from = pos & (PAGE_CACHE_SIZE - 1); - ENTRY; page = grab_cache_page_write_begin(mapping, index, flags); if (!page) diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c index 7747f8f2079dc..be1c3a8887027 100644 --- a/drivers/staging/lustre/lustre/llite/statahead.c +++ b/drivers/staging/lustre/lustre/llite/statahead.c @@ -200,7 +200,6 @@ ll_sa_entry_alloc(struct ll_statahead_info *sai, __u64 index, struct ll_sa_entry *entry; int entry_size; char *dname; - ENTRY; entry_size = sizeof(struct ll_sa_entry) + (len & ~3) + 4; OBD_ALLOC(entry, entry_size); @@ -465,7 +464,6 @@ static struct ll_statahead_info *ll_sai_alloc(void) { struct ll_statahead_info *sai; int i; - ENTRY; OBD_ALLOC_PTR(sai); if (!sai) @@ -510,7 +508,6 @@ static void ll_sai_put(struct ll_statahead_info *sai) { struct inode *inode = sai->sai_inode; struct ll_inode_info *lli = ll_i2info(inode); - ENTRY; if (atomic_dec_and_lock(&sai->sai_refcount, &lli->lli_sa_lock)) { struct ll_sa_entry *entry, *next; @@ -560,7 +557,6 @@ static void ll_agl_trigger(struct inode *inode, struct ll_statahead_info *sai) struct ll_inode_info *lli = ll_i2info(inode); __u64 index = lli->lli_agl_index; int rc; - ENTRY; LASSERT(list_empty(&lli->lli_agl_list)); @@ -628,7 +624,6 @@ static void ll_post_statahead(struct ll_statahead_info *sai) struct ptlrpc_request *req; struct mdt_body *body; int rc = 0; - ENTRY; spin_lock(&lli->lli_sa_lock); if (unlikely(sa_received_empty(sai))) { @@ -713,7 +708,6 @@ static int ll_statahead_interpret(struct ptlrpc_request *req, struct ll_statahead_info *sai = NULL; struct ll_sa_entry *entry; int wakeup; - ENTRY; if (it_disposition(it, DISP_LOOKUP_NEG)) rc = -ENOENT; @@ -852,7 +846,6 @@ static int do_sa_lookup(struct inode *dir, struct ll_sa_entry *entry) struct ldlm_enqueue_info *einfo; struct obd_capa *capas[2]; int rc; - ENTRY; rc = sa_args_init(dir, NULL, entry, &minfo, &einfo, capas); if (rc) @@ -885,7 +878,6 @@ static int do_sa_revalidate(struct inode *dir, struct ll_sa_entry *entry, struct ldlm_enqueue_info *einfo; struct obd_capa *capas[2]; int rc; - ENTRY; if (unlikely(inode == NULL)) RETURN(1); @@ -934,7 +926,6 @@ static void ll_statahead_one(struct dentry *parent, const char* entry_name, struct ll_sa_entry *entry; int rc; int rc1; - ENTRY; entry = ll_sa_entry_alloc(sai, sai->sai_index, entry_name, entry_name_len); @@ -979,7 +970,6 @@ static int ll_agl_thread(void *arg) struct ll_statahead_info *sai = ll_sai_get(plli->lli_sai); struct ptlrpc_thread *thread = &sai->sai_agl_thread; struct l_wait_info lwi = { 0 }; - ENTRY; CDEBUG(D_READA, "agl thread started: [pid %d] [parent %.*s]\n", current_pid(), parent->d_name.len, parent->d_name.name); @@ -1038,7 +1028,6 @@ static void ll_start_agl(struct dentry *parent, struct ll_statahead_info *sai) struct l_wait_info lwi = { 0 }; struct ll_inode_info *plli; task_t *task; - ENTRY; CDEBUG(D_READA, "start agl thread: [pid %d] [parent %.*s]\n", current_pid(), parent->d_name.len, parent->d_name.name); @@ -1074,7 +1063,6 @@ static int ll_statahead_thread(void *arg) int rc = 0; struct ll_dir_chain chain; struct l_wait_info lwi = { 0 }; - ENTRY; CDEBUG(D_READA, "statahead thread started: [pid %d] [parent %.*s]\n", current_pid(), parent->d_name.len, parent->d_name.name); @@ -1369,7 +1357,6 @@ static int is_first_dirent(struct inode *dir, struct dentry *dentry) __u64 pos = 0; int dot_de; int rc = LS_NONE_FIRST_DE; - ENTRY; ll_dir_chain_init(&chain); page = ll_get_dir_page(dir, pos, &chain); @@ -1481,7 +1468,6 @@ ll_sai_unplug(struct ll_statahead_info *sai, struct ll_sa_entry *entry) struct ptlrpc_thread *thread = &sai->sai_thread; struct ll_sb_info *sbi = ll_i2sbi(sai->sai_inode); int hit; - ENTRY; if (entry != NULL && entry->se_stat == SA_ENTRY_SUCC) hit = 1; @@ -1540,7 +1526,6 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, struct l_wait_info lwi = { 0 }; int rc = 0; struct ll_inode_info *plli; - ENTRY; LASSERT(lli->lli_opendir_pid == current_pid()); diff --git a/drivers/staging/lustre/lustre/llite/symlink.c b/drivers/staging/lustre/lustre/llite/symlink.c index 9208afb95f12b..f64982afe6dc1 100644 --- a/drivers/staging/lustre/lustre/llite/symlink.c +++ b/drivers/staging/lustre/lustre/llite/symlink.c @@ -50,7 +50,6 @@ static int ll_readlink_internal(struct inode *inode, int rc, symlen = i_size_read(inode) + 1; struct mdt_body *body; struct md_op_data *op_data; - ENTRY; *request = NULL; @@ -122,7 +121,6 @@ static int ll_readlink(struct dentry *dentry, char *buffer, int buflen) struct ptlrpc_request *request; char *symname; int rc; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op\n"); @@ -144,7 +142,6 @@ static void *ll_follow_link(struct dentry *dentry, struct nameidata *nd) struct ptlrpc_request *request = NULL; int rc; char *symname; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op\n"); /* Limit the recursive symlink depth to 5 instead of default diff --git a/drivers/staging/lustre/lustre/llite/vvp_dev.c b/drivers/staging/lustre/lustre/llite/vvp_dev.c index 9254b990d31cb..760595f89e60f 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_dev.c +++ b/drivers/staging/lustre/lustre/llite/vvp_dev.c @@ -224,7 +224,6 @@ int cl_sb_fini(struct super_block *sb) int refcheck; int result; - ENTRY; sbi = ll_s2sbi(sb); env = cl_env_get(&refcheck); if (!IS_ERR(env)) { diff --git a/drivers/staging/lustre/lustre/llite/vvp_io.c b/drivers/staging/lustre/lustre/llite/vvp_io.c index 50a4c9104f6d7..27ddadf7cca6b 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_io.c +++ b/drivers/staging/lustre/lustre/llite/vvp_io.c @@ -176,7 +176,6 @@ static int vvp_mmap_locks(const struct lu_env *env, unsigned long seg; ssize_t count; int result; - ENTRY; LASSERT(io->ci_type == CIT_READ || io->ci_type == CIT_WRITE); @@ -255,7 +254,6 @@ static int vvp_io_rw_lock(const struct lu_env *env, struct cl_io *io, int ast_flags = 0; LASSERT(io->ci_type == CIT_READ || io->ci_type == CIT_WRITE); - ENTRY; ccc_io_update_iov(env, cio, io); @@ -274,7 +272,6 @@ static int vvp_io_read_lock(const struct lu_env *env, struct ll_inode_info *lli = ll_i2info(ccc_object_inode(io->ci_obj)); int result; - ENTRY; /* XXX: Layer violation, we shouldn't see lsm at llite level. */ if (lli->lli_has_smd) /* lsm-less file doesn't need to lock */ result = vvp_io_rw_lock(env, io, CLM_READ, @@ -556,8 +553,6 @@ static int vvp_io_write_start(const struct lu_env *env, loff_t pos = io->u.ci_wr.wr.crw_pos; size_t cnt = io->u.ci_wr.wr.crw_count; - ENTRY; - if (!can_populate_pages(env, io, inode)) return 0; @@ -807,8 +802,6 @@ static int vvp_io_read_page(const struct lu_env *env, CLOBINVRNT(env, obj, ccc_object_invariant(obj)); LASSERT(slice->cpl_obj == obj); - ENTRY; - if (sbi->ll_ra_info.ra_max_pages_per_file && sbi->ll_ra_info.ra_max_pages) ras_update(sbi, inode, ras, page->cp_index, @@ -923,8 +916,6 @@ static int vvp_io_prepare_write(const struct lu_env *env, int result; - ENTRY; - LINVRNT(cl_page_is_vmlocked(env, pg)); LASSERT(vmpage->mapping->host == ccc_object_inode(obj)); @@ -965,8 +956,6 @@ static int vvp_io_commit_write(const struct lu_env *env, int tallyop; loff_t size; - ENTRY; - LINVRNT(cl_page_is_vmlocked(env, pg)); LASSERT(vmpage->mapping->host == inode); @@ -1122,7 +1111,6 @@ int vvp_io_init(const struct lu_env *env, struct cl_object *obj, int result; CLOBINVRNT(env, obj, ccc_object_invariant(obj)); - ENTRY; CL_IO_SLICE_CLEAN(cio, cui_cl); cl_io_slice_add(io, &cio->cui_cl, obj, &vvp_io_ops); diff --git a/drivers/staging/lustre/lustre/llite/vvp_lock.c b/drivers/staging/lustre/lustre/llite/vvp_lock.c index 9b8712bccd92f..a48cd5984557d 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_lock.c +++ b/drivers/staging/lustre/lustre/llite/vvp_lock.c @@ -63,7 +63,6 @@ static unsigned long vvp_lock_weigh(const struct lu_env *env, { struct ccc_object *cob = cl2ccc(slice->cls_obj); - ENTRY; RETURN(atomic_read(&cob->cob_mmap_cnt) > 0 ? ~0UL >> 2 : 0); } diff --git a/drivers/staging/lustre/lustre/llite/vvp_page.c b/drivers/staging/lustre/lustre/llite/vvp_page.c index 4568e69bb9f0c..522632b525fbe 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_page.c +++ b/drivers/staging/lustre/lustre/llite/vvp_page.c @@ -218,7 +218,6 @@ static int vvp_page_prep_read(const struct lu_env *env, const struct cl_page_slice *slice, struct cl_io *unused) { - ENTRY; /* Skip the page already marked as PG_uptodate. */ RETURN(PageUptodate(cl2vm_page(slice)) ? -EALREADY : 0); } @@ -274,7 +273,6 @@ static void vvp_page_completion_read(const struct lu_env *env, struct page *vmpage = cp->cpg_page; struct cl_page *page = cl_page_top(slice->cpl_page); struct inode *inode = ccc_object_inode(page->cp_obj); - ENTRY; LASSERT(PageLocked(vmpage)); CL_PAGE_HEADER(D_PAGE, env, page, "completing READ with %d\n", ioret); @@ -301,7 +299,6 @@ static void vvp_page_completion_write(const struct lu_env *env, struct ccc_page *cp = cl2ccc_page(slice); struct cl_page *pg = slice->cpl_page; struct page *vmpage = cp->cpg_page; - ENTRY; LASSERT(ergo(pg->cp_sync_io != NULL, PageLocked(vmpage))); LASSERT(PageWriteback(vmpage)); diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c index 2e3ff6d088bc6..c501ac9344995 100644 --- a/drivers/staging/lustre/lustre/llite/xattr.c +++ b/drivers/staging/lustre/lustre/llite/xattr.c @@ -118,7 +118,6 @@ int ll_setxattr_common(struct inode *inode, const char *name, ext_acl_xattr_header *acl = NULL; #endif const char *pv = value; - ENTRY; xattr_type = get_xattr_type(name); rc = xattr_type_filter(sbi, xattr_type); @@ -287,7 +286,6 @@ int ll_getxattr_common(struct inode *inode, const char *name, void *xdata; struct obd_capa *oc; struct rmtacl_ctl_entry *rce = NULL; - ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p)\n", inode->i_ino, inode->i_generation, inode); diff --git a/drivers/staging/lustre/lustre/lmv/lmv_fld.c b/drivers/staging/lustre/lustre/lmv/lmv_fld.c index 08a5b69dc90db..7ca3fb50a9621 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_fld.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_fld.c @@ -57,8 +57,6 @@ int lmv_fld_lookup(struct lmv_obd *lmv, mdsno_t *mds) { int rc; - ENTRY; - /* FIXME: Currently ZFS still use local seq for ROOT unfortunately, and * this fid_is_local check should be removed once LU-2240 is fixed */ diff --git a/drivers/staging/lustre/lustre/lmv/lmv_intent.c b/drivers/staging/lustre/lustre/lmv/lmv_intent.c index 4bc8c6a5d6f20..3d0d1acddb13c 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_intent.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_intent.c @@ -69,7 +69,6 @@ static int lmv_intent_remote(struct obd_export *exp, void *lmm, struct mdt_body *body; int pmode; int rc = 0; - ENTRY; body = req_capsule_server_get(&(*reqp)->rq_pill, &RMF_MDT_BODY); if (body == NULL) @@ -168,7 +167,6 @@ int lmv_intent_open(struct obd_export *exp, struct md_op_data *op_data, struct lmv_tgt_desc *tgt; struct mdt_body *body; int rc; - ENTRY; tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1); if (IS_ERR(tgt)) @@ -252,7 +250,6 @@ int lmv_intent_lookup(struct obd_export *exp, struct md_op_data *op_data, struct lmv_tgt_desc *tgt = NULL; struct mdt_body *body; int rc = 0; - ENTRY; tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1); if (IS_ERR(tgt)) @@ -300,7 +297,6 @@ int lmv_intent_lock(struct obd_export *exp, struct md_op_data *op_data, { struct obd_device *obd = exp->exp_obd; int rc; - ENTRY; LASSERT(it != NULL); LASSERT(fid_is_sane(&op_data->op_fid1)); diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index 1987d4bae9b4a..2970f584539d9 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -80,7 +80,6 @@ static int lmv_set_mdc_active(struct lmv_obd *lmv, struct obd_uuid *uuid, struct obd_device *obd; int i; int rc = 0; - ENTRY; CDEBUG(D_INFO, "Searching in lmv %p for uuid %s (activate=%d)\n", lmv, uuid->uuid, activate); @@ -140,7 +139,6 @@ static int lmv_notify(struct obd_device *obd, struct obd_device *watched, struct lmv_obd *lmv = &obd->u.lmv; struct obd_uuid *uuid; int rc = 0; - ENTRY; if (strcmp(watched->obd_type->typ_name, LUSTRE_MDC_NAME)) { CERROR("unexpected notification of %s %s!\n", @@ -202,7 +200,6 @@ static int lmv_connect(const struct lu_env *env, struct lmv_obd *lmv = &obd->u.lmv; struct lustre_handle conn = { 0 }; int rc = 0; - ENTRY; /* * We don't want to actually do the underlying connections more than @@ -291,7 +288,6 @@ static int lmv_init_ea_size(struct obd_export *exp, int easize, int i; int rc = 0; int change = 0; - ENTRY; if (lmv->max_easize < easize) { lmv->max_easize = easize; @@ -342,7 +338,6 @@ int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) struct obd_export *mdc_exp; struct lu_fld_target target; int rc; - ENTRY; mdc_obd = class_find_client_obd(&tgt->ltd_uuid, LUSTRE_MDC_NAME, &obd->obd_uuid); @@ -452,7 +447,6 @@ static int lmv_add_target(struct obd_device *obd, struct obd_uuid *uuidp, struct lmv_obd *lmv = &obd->u.lmv; struct lmv_tgt_desc *tgt; int rc = 0; - ENTRY; CDEBUG(D_CONFIG, "Target uuid: %s. index %d\n", uuidp->uuid, index); @@ -551,7 +545,6 @@ int lmv_check_connect(struct obd_device *obd) int i; int rc; int easize; - ENTRY; if (lmv->connected) RETURN(0); @@ -618,7 +611,6 @@ static int lmv_disconnect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) struct lmv_obd *lmv = &obd->u.lmv; struct obd_device *mdc_obd; int rc; - ENTRY; LASSERT(tgt != NULL); LASSERT(obd != NULL); @@ -663,7 +655,6 @@ static int lmv_disconnect(struct obd_export *exp) struct lmv_obd *lmv = &obd->u.lmv; int rc; int i; - ENTRY; if (!lmv->tgts) goto out_local; @@ -828,7 +819,6 @@ static int lmv_hsm_ct_unregister(struct lmv_obd *lmv, unsigned int cmd, int len, struct lustre_kernelcomm *lk, void *uarg) { int i, rc = 0; - ENTRY; /* unregister request (call from llapi_hsm_copytool_fini) */ for (i = 0; i < lmv->desc.ld_tgt_count; i++) { @@ -852,7 +842,6 @@ static int lmv_hsm_ct_register(struct lmv_obd *lmv, unsigned int cmd, int len, int i, j, err; int rc = 0; bool any_set = false; - ENTRY; /* All or nothing: try to register to all MDS. * In case of failure, unregister from previous MDS, @@ -911,7 +900,6 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, int rc = 0; int set = 0; int count = lmv->desc.ld_tgt_count; - ENTRY; if (count == 0) RETURN(-ENOTTY); @@ -1215,7 +1203,6 @@ static int lmv_placement_policy(struct obd_device *obd, mdsno_t *mds) { struct lmv_obd *lmv = &obd->u.lmv; - ENTRY; LASSERT(mds != NULL); @@ -1257,7 +1244,6 @@ int __lmv_fid_alloc(struct lmv_obd *lmv, struct lu_fid *fid, { struct lmv_tgt_desc *tgt; int rc; - ENTRY; tgt = lmv_get_target(lmv, mds); if (IS_ERR(tgt)) @@ -1294,7 +1280,6 @@ int lmv_fid_alloc(struct obd_export *exp, struct lu_fid *fid, struct lmv_obd *lmv = &obd->u.lmv; mdsno_t mds = 0; int rc; - ENTRY; LASSERT(op_data != NULL); LASSERT(fid != NULL); @@ -1321,7 +1306,6 @@ static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg) struct lprocfs_static_vars lvars; struct lmv_desc *desc; int rc; - ENTRY; if (LUSTRE_CFG_BUFLEN(lcfg, 1) < 1) { CERROR("LMV setup requires a descriptor\n"); @@ -1379,7 +1363,6 @@ static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg) static int lmv_cleanup(struct obd_device *obd) { struct lmv_obd *lmv = &obd->u.lmv; - ENTRY; fld_client_fini(&lmv->lmv_fld); if (lmv->tgts != NULL) { @@ -1402,7 +1385,6 @@ static int lmv_process_config(struct obd_device *obd, obd_count len, void *buf) int gen; __u32 index; int rc; - ENTRY; switch (lcfg->lcfg_command) { case LCFG_ADD_MDC: @@ -1435,7 +1417,6 @@ static int lmv_statfs(const struct lu_env *env, struct obd_export *exp, struct obd_statfs *temp; int rc = 0; int i; - ENTRY; rc = lmv_check_connect(obd); if (rc) @@ -1489,7 +1470,6 @@ static int lmv_getstatus(struct obd_export *exp, struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; int rc; - ENTRY; rc = lmv_check_connect(obd); if (rc) @@ -1508,7 +1488,6 @@ static int lmv_getxattr(struct obd_export *exp, const struct lu_fid *fid, struct lmv_obd *lmv = &obd->u.lmv; struct lmv_tgt_desc *tgt; int rc; - ENTRY; rc = lmv_check_connect(obd); if (rc) @@ -1534,7 +1513,6 @@ static int lmv_setxattr(struct obd_export *exp, const struct lu_fid *fid, struct lmv_obd *lmv = &obd->u.lmv; struct lmv_tgt_desc *tgt; int rc; - ENTRY; rc = lmv_check_connect(obd); if (rc) @@ -1558,7 +1536,6 @@ static int lmv_getattr(struct obd_export *exp, struct md_op_data *op_data, struct lmv_obd *lmv = &obd->u.lmv; struct lmv_tgt_desc *tgt; int rc; - ENTRY; rc = lmv_check_connect(obd); if (rc) @@ -1584,7 +1561,6 @@ static int lmv_null_inode(struct obd_export *exp, const struct lu_fid *fid) struct lmv_obd *lmv = &obd->u.lmv; int i; int rc; - ENTRY; rc = lmv_check_connect(obd); if (rc) @@ -1613,7 +1589,6 @@ static int lmv_find_cbdata(struct obd_export *exp, const struct lu_fid *fid, struct lmv_obd *lmv = &obd->u.lmv; int i; int rc; - ENTRY; rc = lmv_check_connect(obd); if (rc) @@ -1645,7 +1620,6 @@ static int lmv_close(struct obd_export *exp, struct md_op_data *op_data, struct lmv_obd *lmv = &obd->u.lmv; struct lmv_tgt_desc *tgt; int rc; - ENTRY; rc = lmv_check_connect(obd); if (rc) @@ -1684,7 +1658,6 @@ int lmv_create(struct obd_export *exp, struct md_op_data *op_data, struct lmv_obd *lmv = &obd->u.lmv; struct lmv_tgt_desc *tgt; int rc; - ENTRY; rc = lmv_check_connect(obd); if (rc) @@ -1725,7 +1698,6 @@ static int lmv_done_writing(struct obd_export *exp, struct lmv_obd *lmv = &obd->u.lmv; struct lmv_tgt_desc *tgt; int rc; - ENTRY; rc = lmv_check_connect(obd); if (rc) @@ -1755,7 +1727,6 @@ lmv_enqueue_remote(struct obd_export *exp, struct ldlm_enqueue_info *einfo, struct mdt_body *body; int rc = 0; int pmode; - ENTRY; body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); LASSERT(body != NULL); @@ -1809,7 +1780,6 @@ lmv_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo, struct lmv_obd *lmv = &obd->u.lmv; struct lmv_tgt_desc *tgt; int rc; - ENTRY; rc = lmv_check_connect(obd); if (rc) @@ -1845,7 +1815,6 @@ lmv_getattr_name(struct obd_export *exp,struct md_op_data *op_data, struct lmv_tgt_desc *tgt; struct mdt_body *body; int rc; - ENTRY; rc = lmv_check_connect(obd); if (rc) @@ -1906,7 +1875,6 @@ static int lmv_early_cancel(struct obd_export *exp, struct md_op_data *op_data, struct lmv_tgt_desc *tgt; ldlm_policy_data_t policy = {{0}}; int rc = 0; - ENTRY; if (!fid_is_sane(fid)) RETURN(0); @@ -1942,7 +1910,6 @@ static int lmv_link(struct obd_export *exp, struct md_op_data *op_data, struct lmv_obd *lmv = &obd->u.lmv; struct lmv_tgt_desc *tgt; int rc; - ENTRY; rc = lmv_check_connect(obd); if (rc) @@ -1984,7 +1951,6 @@ static int lmv_rename(struct obd_export *exp, struct md_op_data *op_data, struct lmv_tgt_desc *src_tgt; struct lmv_tgt_desc *tgt_tgt; int rc; - ENTRY; LASSERT(oldlen != 0); @@ -2052,7 +2018,6 @@ static int lmv_setattr(struct obd_export *exp, struct md_op_data *op_data, struct lmv_obd *lmv = &obd->u.lmv; struct lmv_tgt_desc *tgt; int rc = 0; - ENTRY; rc = lmv_check_connect(obd); if (rc) @@ -2079,7 +2044,6 @@ static int lmv_sync(struct obd_export *exp, const struct lu_fid *fid, struct lmv_obd *lmv = &obd->u.lmv; struct lmv_tgt_desc *tgt; int rc; - ENTRY; rc = lmv_check_connect(obd); if (rc) @@ -2206,7 +2170,6 @@ static int lmv_readpage(struct obd_export *exp, struct md_op_data *op_data, int ncfspgs; /* pages read in PAGE_CACHE_SIZE */ int nlupgs; /* pages read in LU_PAGE_SIZE */ struct lmv_tgt_desc *tgt; - ENTRY; rc = lmv_check_connect(obd); if (rc) @@ -2245,7 +2208,6 @@ static int lmv_unlink(struct obd_export *exp, struct md_op_data *op_data, struct lmv_tgt_desc *tgt = NULL; struct mdt_body *body; int rc; - ENTRY; rc = lmv_check_connect(obd); if (rc) @@ -2352,7 +2314,6 @@ static int lmv_get_info(const struct lu_env *env, struct obd_export *exp, struct obd_device *obd; struct lmv_obd *lmv; int rc = 0; - ENTRY; obd = class_exp2obd(exp); if (obd == NULL) { @@ -2415,7 +2376,6 @@ int lmv_set_info_async(const struct lu_env *env, struct obd_export *exp, struct obd_device *obd; struct lmv_obd *lmv; int rc = 0; - ENTRY; obd = class_exp2obd(exp); if (obd == NULL) { @@ -2455,7 +2415,6 @@ int lmv_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, struct lmv_stripe_md *lsmp; int mea_size; int i; - ENTRY; mea_size = lmv_get_easize(lmv); if (!lmmp) @@ -2505,7 +2464,6 @@ int lmv_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, int mea_size; int i; __u32 magic; - ENTRY; mea_size = lmv_get_easize(lmv); if (lsmp == NULL) @@ -2559,7 +2517,6 @@ static int lmv_cancel_unused(struct obd_export *exp, const struct lu_fid *fid, int rc = 0; int err; int i; - ENTRY; LASSERT(fid != NULL); @@ -2581,7 +2538,6 @@ int lmv_set_lock_data(struct obd_export *exp, __u64 *lockh, void *data, { struct lmv_obd *lmv = &exp->exp_obd->u.lmv; int rc; - ENTRY; rc = md_set_lock_data(lmv->tgts[0]->ltd_exp, lockh, data, bits); RETURN(rc); @@ -2596,7 +2552,6 @@ ldlm_mode_t lmv_lock_match(struct obd_export *exp, __u64 flags, struct lmv_obd *lmv = &obd->u.lmv; ldlm_mode_t rc; int i; - ENTRY; CDEBUG(D_INODE, "Lock match for "DFID"\n", PFID(fid)); @@ -2634,7 +2589,6 @@ int lmv_free_lustre_md(struct obd_export *exp, struct lustre_md *md) { struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; - ENTRY; if (md->mea) obd_free_memmd(exp, (void *)&md->mea); @@ -2648,7 +2602,6 @@ int lmv_set_open_replay_data(struct obd_export *exp, struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; struct lmv_tgt_desc *tgt; - ENTRY; tgt = lmv_find_target(lmv, &och->och_fid); if (IS_ERR(tgt)) @@ -2663,7 +2616,6 @@ int lmv_clear_open_replay_data(struct obd_export *exp, struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; struct lmv_tgt_desc *tgt; - ENTRY; tgt = lmv_find_target(lmv, &och->och_fid); if (IS_ERR(tgt)) @@ -2681,7 +2633,6 @@ static int lmv_get_remote_perm(struct obd_export *exp, struct lmv_obd *lmv = &obd->u.lmv; struct lmv_tgt_desc *tgt; int rc; - ENTRY; rc = lmv_check_connect(obd); if (rc) @@ -2702,7 +2653,6 @@ static int lmv_renew_capa(struct obd_export *exp, struct obd_capa *oc, struct lmv_obd *lmv = &obd->u.lmv; struct lmv_tgt_desc *tgt; int rc; - ENTRY; rc = lmv_check_connect(obd); if (rc) @@ -2733,7 +2683,6 @@ int lmv_intent_getattr_async(struct obd_export *exp, struct lmv_obd *lmv = &obd->u.lmv; struct lmv_tgt_desc *tgt = NULL; int rc; - ENTRY; rc = lmv_check_connect(obd); if (rc) @@ -2754,7 +2703,6 @@ int lmv_revalidate_lock(struct obd_export *exp, struct lookup_intent *it, struct lmv_obd *lmv = &obd->u.lmv; struct lmv_tgt_desc *tgt; int rc; - ENTRY; rc = lmv_check_connect(obd); if (rc) @@ -2781,7 +2729,6 @@ int lmv_quotactl(struct obd_device *unused, struct obd_export *exp, struct lmv_tgt_desc *tgt = lmv->tgts[0]; int rc = 0, i; __u64 curspace, curinodes; - ENTRY; if (!lmv->desc.ld_tgt_count || !tgt->ltd_active) { CERROR("master lmv inactive\n"); @@ -2828,7 +2775,6 @@ int lmv_quotacheck(struct obd_device *unused, struct obd_export *exp, struct lmv_obd *lmv = &obd->u.lmv; struct lmv_tgt_desc *tgt; int i, rc = 0; - ENTRY; for (i = 0; i < lmv->desc.ld_tgt_count; i++) { int err; diff --git a/drivers/staging/lustre/lustre/lov/lov_dev.c b/drivers/staging/lustre/lustre/lov/lov_dev.c index f94f8d9d33d74..5d1b52284526f 100644 --- a/drivers/staging/lustre/lustre/lov/lov_dev.c +++ b/drivers/staging/lustre/lustre/lov/lov_dev.c @@ -122,7 +122,6 @@ static void lov_req_completion(const struct lu_env *env, { struct lov_req *lr; - ENTRY; lr = cl2lov_req(slice); OBD_SLAB_FREE_PTR(lr, lov_req_kmem); EXIT; @@ -260,7 +259,6 @@ static int lov_req_init(const struct lu_env *env, struct cl_device *dev, struct lov_req *lr; int result; - ENTRY; OBD_SLAB_ALLOC_PTR_GFP(lr, lov_req_kmem, __GFP_IO); if (lr != NULL) { cl_req_slice_add(req, &lr->lr_cl, dev, &lov_req_ops); @@ -311,7 +309,6 @@ static void lov_cl_del_target(const struct lu_env *env, struct lu_device *dev, __u32 index) { struct lov_device *ld = lu2lov_dev(dev); - ENTRY; if (ld->ld_target[index] != NULL) { cl_stack_fini(env, lovsub2cl_dev(ld->ld_target[index])); @@ -360,7 +357,6 @@ static int lov_expand_targets(const struct lu_env *env, struct lov_device *dev) __u32 tgt_size; __u32 sub_size; - ENTRY; result = 0; tgt_size = dev->ld_lov->lov_tgt_size; sub_size = dev->ld_target_nr; @@ -404,7 +400,6 @@ static int lov_cl_add_target(const struct lu_env *env, struct lu_device *dev, struct lovsub_device *lsd; struct cl_device *cl; int rc; - ENTRY; obd_getref(obd); diff --git a/drivers/staging/lustre/lustre/lov/lov_io.c b/drivers/staging/lustre/lustre/lov/lov_io.c index b316ce8cfeac7..0ef2293a65a0b 100644 --- a/drivers/staging/lustre/lustre/lov/lov_io.c +++ b/drivers/staging/lustre/lustre/lov/lov_io.c @@ -59,7 +59,6 @@ static inline void lov_sub_exit(struct lov_io_sub *sub) static void lov_io_sub_fini(const struct lu_env *env, struct lov_io *lio, struct lov_io_sub *sub) { - ENTRY; if (sub->sub_io != NULL) { if (sub->sub_io_initialized) { lov_sub_enter(sub); @@ -149,7 +148,6 @@ static int lov_io_sub_init(const struct lu_env *env, struct lov_io *lio, LASSERT(sub->sub_io == NULL); LASSERT(sub->sub_env == NULL); LASSERT(sub->sub_stripe < lio->lis_stripe_count); - ENTRY; result = 0; sub->sub_io_initialized = 0; @@ -220,7 +218,6 @@ struct lov_io_sub *lov_sub_get(const struct lu_env *env, struct lov_io_sub *sub = &lio->lis_subs[stripe]; LASSERT(stripe < lio->lis_stripe_count); - ENTRY; if (!sub->sub_io_initialized) { sub->sub_stripe = stripe; @@ -249,7 +246,6 @@ static int lov_page_stripe(const struct cl_page *page) { struct lovsub_object *subobj; - ENTRY; subobj = lu2lovsub( lu_object_locate(page->cp_child->cp_obj->co_lu.lo_header, &lovsub_device_type)); @@ -268,7 +264,6 @@ struct lov_io_sub *lov_page_subio(const struct lu_env *env, struct lov_io *lio, LASSERT(cl2lov(slice->cpl_obj) == lio->lis_object); LASSERT(lsm != NULL); LASSERT(lio->lis_nr_subios > 0); - ENTRY; stripe = lov_page_stripe(page); RETURN(lov_sub_get(env, lio, stripe)); @@ -282,7 +277,6 @@ static int lov_io_subio_init(const struct lu_env *env, struct lov_io *lio, int result; LASSERT(lio->lis_object != NULL); - ENTRY; /* * Need to be optimized, we can't afford to allocate a piece of memory @@ -303,8 +297,6 @@ static int lov_io_subio_init(const struct lu_env *env, struct lov_io *lio, static void lov_io_slice_init(struct lov_io *lio, struct lov_object *obj, struct cl_io *io) { - ENTRY; - io->ci_result = 0; lio->lis_object = obj; @@ -363,7 +355,6 @@ static void lov_io_fini(const struct lu_env *env, const struct cl_io_slice *ios) struct lov_object *lov = cl2lov(ios->cis_obj); int i; - ENTRY; if (lio->lis_subs != NULL) { for (i = 0; i < lio->lis_nr_subios; i++) lov_io_sub_fini(env, lio, &lio->lis_subs[i]); @@ -397,7 +388,6 @@ static int lov_io_iter_init(const struct lu_env *env, int stripe; int rc = 0; - ENTRY; endpos = lov_offset_mod(lio->lis_endpos, -1); for (stripe = 0; stripe < lio->lis_stripe_count; stripe++) { if (!lov_stripe_intersects(lsm, stripe, lio->lis_pos, @@ -435,7 +425,6 @@ static int lov_io_rw_iter_init(const struct lu_env *env, unsigned long ssize = lsm->lsm_stripe_size; LASSERT(io->ci_type == CIT_READ || io->ci_type == CIT_WRITE); - ENTRY; /* fast path for common case. */ if (lio->lis_nr_subios != 1 && !cl_io_is_append(io)) { @@ -468,7 +457,6 @@ static int lov_io_call(const struct lu_env *env, struct lov_io *lio, struct lov_io_sub *sub; int rc = 0; - ENTRY; list_for_each_entry(sub, &lio->lis_active, sub_linkage) { lov_sub_enter(sub); rc = iofunc(sub->sub_env, sub->sub_io); @@ -484,19 +472,16 @@ static int lov_io_call(const struct lu_env *env, struct lov_io *lio, static int lov_io_lock(const struct lu_env *env, const struct cl_io_slice *ios) { - ENTRY; RETURN(lov_io_call(env, cl2lov_io(env, ios), cl_io_lock)); } static int lov_io_start(const struct lu_env *env, const struct cl_io_slice *ios) { - ENTRY; RETURN(lov_io_call(env, cl2lov_io(env, ios), cl_io_start)); } static int lov_io_end_wrapper(const struct lu_env *env, struct cl_io *io) { - ENTRY; /* * It's possible that lov_io_start() wasn't called against this * sub-io, either because previous sub-io failed, or upper layer @@ -535,7 +520,6 @@ static void lov_io_iter_fini(const struct lu_env *env, struct lov_io *lio = cl2lov_io(env, ios); int rc; - ENTRY; rc = lov_io_call(env, lio, lov_io_iter_fini_wrapper); LASSERT(rc == 0); while (!list_empty(&lio->lis_active)) @@ -548,7 +532,6 @@ static void lov_io_unlock(const struct lu_env *env, { int rc; - ENTRY; rc = lov_io_call(env, cl2lov_io(env, ios), lov_io_unlock_wrapper); LASSERT(rc == 0); EXIT; @@ -596,7 +579,7 @@ static int lov_io_submit(const struct lu_env *env, int rc = 0; int alloc = !(current->flags & PF_MEMALLOC); - ENTRY; + if (lio->lis_active_subios == 1) { int idx = lio->lis_single_subio_index; struct lov_io_sub *sub; @@ -696,7 +679,6 @@ static int lov_io_prepare_write(const struct lu_env *env, struct lov_io_sub *sub; int result; - ENTRY; sub = lov_page_subio(env, lio, slice); if (!IS_ERR(sub)) { result = cl_io_prepare_write(sub->sub_env, sub->sub_io, @@ -717,7 +699,6 @@ static int lov_io_commit_write(const struct lu_env *env, struct lov_io_sub *sub; int result; - ENTRY; sub = lov_page_subio(env, lio, slice); if (!IS_ERR(sub)) { result = cl_io_commit_write(sub->sub_env, sub->sub_io, @@ -735,7 +716,6 @@ static int lov_io_fault_start(const struct lu_env *env, struct lov_io *lio; struct lov_io_sub *sub; - ENTRY; fio = &ios->cis_io->u.ci_fault; lio = cl2lov_io(env, ios); sub = lov_sub_get(env, lio, lov_page_stripe(fio->ft_page)); @@ -750,7 +730,6 @@ static void lov_io_fsync_end(const struct lu_env *env, struct lov_io *lio = cl2lov_io(env, ios); struct lov_io_sub *sub; unsigned int *written = &ios->cis_io->u.ci_fsync.fi_nr_written; - ENTRY; *written = 0; list_for_each_entry(sub, &lio->lis_active, sub_linkage) { @@ -839,7 +818,6 @@ static void lov_empty_io_fini(const struct lu_env *env, const struct cl_io_slice *ios) { struct lov_object *lov = cl2lov(ios->cis_obj); - ENTRY; if (atomic_dec_and_test(&lov->lo_active_ios)) wake_up_all(&lov->lo_waitq); @@ -913,7 +891,6 @@ int lov_io_init_raid0(const struct lu_env *env, struct cl_object *obj, struct lov_io *lio = lov_env_io(env); struct lov_object *lov = cl2lov(obj); - ENTRY; INIT_LIST_HEAD(&lio->lis_active); lov_io_slice_init(lio, lov, io); if (io->ci_result == 0) { @@ -932,7 +909,6 @@ int lov_io_init_empty(const struct lu_env *env, struct cl_object *obj, struct lov_object *lov = cl2lov(obj); struct lov_io *lio = lov_env_io(env); int result; - ENTRY; lio->lis_object = lov; switch (io->ci_type) { @@ -970,7 +946,6 @@ int lov_io_init_released(const struct lu_env *env, struct cl_object *obj, struct lov_object *lov = cl2lov(obj); struct lov_io *lio = lov_env_io(env); int result; - ENTRY; LASSERT(lov->lo_lsm != NULL); lio->lis_object = lov; diff --git a/drivers/staging/lustre/lustre/lov/lov_lock.c b/drivers/staging/lustre/lustre/lov/lov_lock.c index bdf3334e0c9ff..7cda7b6efc1e5 100644 --- a/drivers/staging/lustre/lustre/lov/lov_lock.c +++ b/drivers/staging/lustre/lustre/lov/lov_lock.c @@ -110,7 +110,6 @@ static void lov_sublock_adopt(const struct lu_env *env, struct lov_lock *lck, LASSERT(cl_lock_is_mutexed(parent)); LASSERT(cl_lock_is_mutexed(sublock)); - ENTRY; lsl = cl2sub_lock(sublock); /* @@ -145,7 +144,6 @@ static struct cl_lock *lov_sublock_alloc(const struct lu_env *env, struct lov_lock_link *link; LASSERT(idx < lck->lls_nr); - ENTRY; OBD_SLAB_ALLOC_PTR_GFP(link, lov_lock_link_kmem, __GFP_IO); if (link != NULL) { @@ -187,7 +185,6 @@ static void lov_sublock_unlock(const struct lu_env *env, struct cl_lock_closure *closure, struct lov_sublock_env *subenv) { - ENTRY; lov_sublock_env_put(subenv); lsl->lss_active = NULL; cl_lock_disclosure(env, closure); @@ -203,7 +200,6 @@ static int lov_sublock_lock(const struct lu_env *env, struct lovsub_lock *sublock; struct cl_lock *child; int result = 0; - ENTRY; LASSERT(list_empty(&closure->clc_list)); @@ -267,8 +263,6 @@ static int lov_subresult(int result, int rc) int result_rank; int rc_rank; - ENTRY; - LASSERTF(result <= 0 || result == CLO_REPEAT || result == CLO_WAIT, "result = %d", result); LASSERTF(rc <= 0 || rc == CLO_REPEAT || rc == CLO_WAIT, @@ -307,8 +301,6 @@ static int lov_lock_sub_init(const struct lu_env *env, struct lov_layout_raid0 *r0 = lov_r0(loo); struct cl_lock *parent = lck->lls_cl.cls_lock; - ENTRY; - lck->lls_orig = parent->cll_descr; file_start = cl_offset(lov2cl(loo), parent->cll_descr.cld_start); file_end = cl_offset(lov2cl(loo), parent->cll_descr.cld_end + 1) - 1; @@ -405,7 +397,6 @@ static int lov_sublock_release(const struct lu_env *env, struct lov_lock *lck, struct cl_lock *parent = lck->lls_cl.cls_lock; LASSERT(cl_lock_is_mutexed(parent)); - ENTRY; if (lck->lls_sub[i].sub_flags & LSF_HELD) { struct cl_lock *sublock; @@ -451,7 +442,6 @@ static void lov_sublock_hold(const struct lu_env *env, struct lov_lock *lck, struct cl_lock *parent = lck->lls_cl.cls_lock; LASSERT(cl_lock_is_mutexed(parent)); - ENTRY; if (!(lck->lls_sub[i].sub_flags & LSF_HELD)) { struct cl_lock *sublock; @@ -477,7 +467,6 @@ static void lov_lock_fini(const struct lu_env *env, struct lov_lock *lck; int i; - ENTRY; lck = cl2lov_lock(slice); LASSERT(lck->lls_nr_filled == 0); if (lck->lls_sub != NULL) { @@ -500,7 +489,6 @@ static int lov_lock_enqueue_wait(const struct lu_env *env, { struct cl_lock *lock = lck->lls_cl.cls_lock; int result; - ENTRY; LASSERT(cl_lock_is_mutexed(lock)); @@ -522,7 +510,6 @@ static int lov_lock_enqueue_one(const struct lu_env *env, struct lov_lock *lck, struct cl_io *io, __u32 enqflags, int last) { int result; - ENTRY; /* first, try to enqueue a sub-lock ... */ result = cl_enqueue_try(env, sublock, io, enqflags); @@ -600,8 +587,6 @@ static int lov_lock_enqueue(const struct lu_env *env, int result; enum cl_lock_state minstate; - ENTRY; - for (result = 0, minstate = CLS_FREEING, i = 0; i < lck->lls_nr; ++i) { int rc; struct lovsub_lock *sub; @@ -691,8 +676,6 @@ static int lov_lock_unuse(const struct lu_env *env, int i; int result; - ENTRY; - for (result = 0, i = 0; i < lck->lls_nr; ++i) { int rc; struct lovsub_lock *sub; @@ -740,8 +723,6 @@ static void lov_lock_cancel(const struct lu_env *env, int i; int result; - ENTRY; - for (result = 0, i = 0; i < lck->lls_nr; ++i) { int rc; struct lovsub_lock *sub; @@ -802,8 +783,6 @@ static int lov_lock_wait(const struct lu_env *env, int result; int i; - ENTRY; - again: for (result = 0, minstate = CLS_FREEING, i = 0, reenqueued = 0; i < lck->lls_nr; ++i) { @@ -851,7 +830,6 @@ static int lov_lock_use(const struct lu_env *env, int i; LASSERT(slice->cls_lock->cll_state == CLS_INTRANSIT); - ENTRY; for (result = 0, i = 0; i < lck->lls_nr; ++i) { int rc; @@ -1016,8 +994,6 @@ static int lov_lock_fits_into(const struct lu_env *env, LASSERT(cl_object_same(need->cld_obj, slice->cls_obj)); LASSERT(lov->lls_nr > 0); - ENTRY; - /* for top lock, it's necessary to match enq flags otherwise it will * run into problem if a sublock is missing and reenqueue. */ if (need->cld_enq_flags != lov->lls_orig.cld_enq_flags) @@ -1066,7 +1042,6 @@ void lov_lock_unlink(const struct lu_env *env, LASSERT(cl_lock_is_mutexed(parent)); LASSERT(cl_lock_is_mutexed(sub->lss_cl.cls_lock)); - ENTRY; list_del_init(&link->lll_list); LASSERT(lck->lls_sub[link->lll_idx].sub_lock == sub); @@ -1087,7 +1062,6 @@ struct lov_lock_link *lov_lock_link_find(const struct lu_env *env, struct lov_lock_link *scan; LASSERT(cl_lock_is_mutexed(sub->lss_cl.cls_lock)); - ENTRY; list_for_each_entry(scan, &sub->lss_parents, lll_list) { if (scan->lll_super == lck) @@ -1120,7 +1094,6 @@ static void lov_lock_delete(const struct lu_env *env, int i; LASSERT(slice->cls_lock->cll_state == CLS_FREEING); - ENTRY; for (i = 0; i < lck->lls_nr; ++i) { struct lov_lock_sub *lls = &lck->lls_sub[i]; @@ -1192,7 +1165,6 @@ int lov_lock_init_raid0(const struct lu_env *env, struct cl_object *obj, struct lov_lock *lck; int result; - ENTRY; OBD_SLAB_ALLOC_PTR_GFP(lck, lov_lock_kmem, __GFP_IO); if (lck != NULL) { cl_lock_slice_add(lock, &lck->lls_cl, obj, &lov_lock_ops); @@ -1228,7 +1200,6 @@ int lov_lock_init_empty(const struct lu_env *env, struct cl_object *obj, struct lov_lock *lck; int result = -ENOMEM; - ENTRY; OBD_SLAB_ALLOC_PTR_GFP(lck, lov_lock_kmem, __GFP_IO); if (lck != NULL) { cl_lock_slice_add(lock, &lck->lls_cl, obj, &lov_empty_lock_ops); diff --git a/drivers/staging/lustre/lustre/lov/lov_log.c b/drivers/staging/lustre/lustre/lov/lov_log.c index 63b7f8d3182fb..349579b59b6d5 100644 --- a/drivers/staging/lustre/lustre/lov/lov_log.c +++ b/drivers/staging/lustre/lustre/lov/lov_log.c @@ -71,7 +71,6 @@ static int lov_llog_origin_add(const struct lu_env *env, struct obd_device *obd = ctxt->loc_obd; struct lov_obd *lov = &obd->u.lov; int i, rc = 0, cookies = 0; - ENTRY; LASSERTF(logcookies && numcookies >= lsm->lsm_stripe_count, "logcookies %p, numcookies %d lsm->lsm_stripe_count %d \n", @@ -129,7 +128,6 @@ static int lov_llog_origin_connect(struct llog_ctxt *ctxt, struct obd_device *obd = ctxt->loc_obd; struct lov_obd *lov = &obd->u.lov; int i, rc = 0, err = 0; - ENTRY; obd_getref(obd); for (i = 0; i < lov->desc.ld_tgt_count; i++) { @@ -167,7 +165,6 @@ static int lov_llog_repl_cancel(const struct lu_env *env, struct lov_obd *lov; struct obd_device *obd = ctxt->loc_obd; int rc = 0, i; - ENTRY; LASSERT(lsm != NULL); LASSERT(count == lsm->lsm_stripe_count); @@ -212,7 +209,6 @@ int lov_llog_init(struct obd_device *obd, struct obd_llog_group *olg, struct lov_obd *lov = &obd->u.lov; struct obd_device *child; int i, rc = 0; - ENTRY; LASSERT(olg == &obd->obd_olg); rc = llog_setup(NULL, obd, olg, LLOG_MDS_OST_ORIG_CTXT, disk_obd, @@ -261,8 +257,6 @@ int lov_llog_finish(struct obd_device *obd, int count) { struct llog_ctxt *ctxt; - ENTRY; - /* cleanup our llogs only if the ctxts have been setup * (client lov doesn't setup, mds lov does). */ ctxt = llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT); diff --git a/drivers/staging/lustre/lustre/lov/lov_merge.c b/drivers/staging/lustre/lustre/lov/lov_merge.c index ddbac12202630..f062460aaf5c1 100644 --- a/drivers/staging/lustre/lustre/lov/lov_merge.c +++ b/drivers/staging/lustre/lustre/lov/lov_merge.c @@ -127,7 +127,6 @@ int lov_merge_lvb(struct obd_export *exp, int rc; __u64 kms; - ENTRY; lov_stripe_lock(lsm); rc = lov_merge_lvb_kms(lsm, lvb, &kms); lov_stripe_unlock(lsm); @@ -147,7 +146,6 @@ int lov_adjust_kms(struct obd_export *exp, struct lov_stripe_md *lsm, struct lov_oinfo *loi; int stripe = 0; __u64 kms; - ENTRY; LASSERT(spin_is_locked(&lsm->lsm_lock)); LASSERT(lsm->lsm_lock_owner == current_pid()); diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index c7c1a8cc25929..ba5bf1c1f146e 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -133,7 +133,6 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate, struct obd_import *imp; proc_dir_entry_t *lov_proc_dir; int rc; - ENTRY; if (!lov->lov_tgts[index]) RETURN(-EINVAL); @@ -227,7 +226,6 @@ static int lov_connect(const struct lu_env *env, struct lov_tgt_desc *tgt; struct lustre_handle conn; int i, rc; - ENTRY; CDEBUG(D_CONFIG, "connect #%d\n", lov->lov_connects); @@ -279,7 +277,6 @@ static int lov_disconnect_obd(struct obd_device *obd, struct lov_tgt_desc *tgt) struct lov_obd *lov = &obd->u.lov; struct obd_device *osc_obd; int rc; - ENTRY; osc_obd = class_exp2obd(tgt->ltd_exp); CDEBUG(D_CONFIG, "%s: disconnecting target %s\n", @@ -323,7 +320,6 @@ static int lov_disconnect(struct obd_export *exp) struct obd_device *obd = class_exp2obd(exp); struct lov_obd *lov = &obd->u.lov; int i, rc; - ENTRY; if (!lov->lov_tgts) goto out; @@ -366,7 +362,6 @@ static int lov_set_osc_active(struct obd_device *obd, struct obd_uuid *uuid, struct lov_obd *lov = &obd->u.lov; struct lov_tgt_desc *tgt; int index, activate, active; - ENTRY; CDEBUG(D_INFO, "Searching in lov %p for uuid %s event(%d)\n", lov, uuid->uuid, ev); @@ -446,7 +441,6 @@ static int lov_notify(struct obd_device *obd, struct obd_device *watched, { int rc = 0; struct lov_obd *lov = &obd->u.lov; - ENTRY; down_read(&lov->lov_notify_lock); if (!lov->lov_connects) { @@ -530,7 +524,6 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp, struct lov_tgt_desc *tgt; struct obd_device *tgt_obd; int rc; - ENTRY; CDEBUG(D_CONFIG, "uuid:%s idx:%d gen:%d active:%d\n", uuidp->uuid, index, gen, active); @@ -664,7 +657,6 @@ int lov_del_target(struct obd_device *obd, __u32 index, struct lov_obd *lov = &obd->u.lov; int count = lov->desc.ld_tgt_count; int rc = 0; - ENTRY; if (index >= count) { CERROR("LOV target index %d >= number of LOV OBDs %d.\n", @@ -780,7 +772,6 @@ int lov_setup(struct obd_device *obd, struct lustre_cfg *lcfg) struct lov_desc *desc; struct lov_obd *lov = &obd->u.lov; int rc; - ENTRY; if (LUSTRE_CFG_BUFLEN(lcfg, 1) < 1) { CERROR("LOV setup requires a descriptor\n"); @@ -859,8 +850,6 @@ static int lov_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) int rc = 0; struct lov_obd *lov = &obd->u.lov; - ENTRY; - switch (stage) { case OBD_CLEANUP_EARLY: { int i; @@ -886,7 +875,6 @@ static int lov_cleanup(struct obd_device *obd) struct lov_obd *lov = &obd->u.lov; struct list_head *pos, *tmp; struct pool_desc *pool; - ENTRY; list_for_each_safe(pos, tmp, &lov->lov_pool_list) { pool = list_entry(pos, struct pool_desc, pool_list); @@ -934,7 +922,6 @@ int lov_process_config_base(struct obd_device *obd, struct lustre_cfg *lcfg, struct obd_uuid obd_uuid; int cmd; int rc = 0; - ENTRY; switch(cmd = lcfg->lcfg_command) { case LCFG_LOV_ADD_OBD: @@ -1000,7 +987,6 @@ static int lov_recreate(struct obd_export *exp, struct obdo *src_oa, struct lov_obd *lov = &exp->exp_obd->u.lov; unsigned ost_idx; int rc, i; - ENTRY; LASSERT(src_oa->o_valid & OBD_MD_FLFLAGS && src_oa->o_flags & OBD_FL_RECREATE_OBJS); @@ -1042,7 +1028,6 @@ static int lov_create(const struct lu_env *env, struct obd_export *exp, { struct lov_obd *lov; int rc = 0; - ENTRY; LASSERT(ea != NULL); if (exp == NULL) @@ -1088,7 +1073,6 @@ static int lov_destroy(const struct lu_env *env, struct obd_export *exp, struct list_head *pos; struct lov_obd *lov; int rc = 0, err = 0; - ENTRY; ASSERT_LSM_MAGIC(lsm); @@ -1144,7 +1128,6 @@ static int lov_getattr(const struct lu_env *env, struct obd_export *exp, struct list_head *pos; struct lov_obd *lov; int err = 0, rc = 0; - ENTRY; LASSERT(oinfo); ASSERT_LSM_MAGIC(oinfo->oi_md); @@ -1190,7 +1173,6 @@ static int lov_getattr_interpret(struct ptlrpc_request_set *rqset, { struct lov_request_set *lovset = (struct lov_request_set *)data; int err; - ENTRY; /* don't do attribute merge if this aysnc op failed */ if (rc) @@ -1207,7 +1189,6 @@ static int lov_getattr_async(struct obd_export *exp, struct obd_info *oinfo, struct list_head *pos; struct lov_request *req; int rc = 0, err; - ENTRY; LASSERT(oinfo); ASSERT_LSM_MAGIC(oinfo->oi_md); @@ -1266,7 +1247,6 @@ static int lov_setattr(const struct lu_env *env, struct obd_export *exp, struct list_head *pos; struct lov_request *req; int err = 0, rc = 0; - ENTRY; LASSERT(oinfo); ASSERT_LSM_MAGIC(oinfo->oi_md); @@ -1315,7 +1295,6 @@ static int lov_setattr_interpret(struct ptlrpc_request_set *rqset, { struct lov_request_set *lovset = (struct lov_request_set *)data; int err; - ENTRY; if (rc) atomic_set(&lovset->set_completes, 0); @@ -1334,7 +1313,6 @@ static int lov_setattr_async(struct obd_export *exp, struct obd_info *oinfo, struct list_head *pos; struct lov_obd *lov; int rc = 0; - ENTRY; LASSERT(oinfo); ASSERT_LSM_MAGIC(oinfo->oi_md); @@ -1399,7 +1377,6 @@ static int lov_punch_interpret(struct ptlrpc_request_set *rqset, { struct lov_request_set *lovset = (struct lov_request_set *)data; int err; - ENTRY; if (rc) atomic_set(&lovset->set_completes, 0); @@ -1419,7 +1396,6 @@ static int lov_punch(const struct lu_env *env, struct obd_export *exp, struct list_head *pos; struct lov_request *req; int rc = 0; - ENTRY; LASSERT(oinfo); ASSERT_LSM_MAGIC(oinfo->oi_md); @@ -1465,7 +1441,6 @@ static int lov_sync_interpret(struct ptlrpc_request_set *rqset, { struct lov_request_set *lovset = data; int err; - ENTRY; if (rc) atomic_set(&lovset->set_completes, 0); @@ -1482,7 +1457,6 @@ static int lov_sync(const struct lu_env *env, struct obd_export *exp, struct list_head *pos; struct lov_request *req; int rc = 0; - ENTRY; ASSERT_LSM_MAGIC(oinfo->oi_md); LASSERT(rqset != NULL); @@ -1571,7 +1545,6 @@ static int lov_brw(int cmd, struct obd_export *exp, struct obd_info *oinfo, struct list_head *pos; struct lov_obd *lov = &exp->exp_obd->u.lov; int err, rc = 0; - ENTRY; ASSERT_LSM_MAGIC(oinfo->oi_md); @@ -1608,7 +1581,7 @@ static int lov_enqueue_interpret(struct ptlrpc_request_set *rqset, void *data, int rc) { struct lov_request_set *lovset = (struct lov_request_set *)data; - ENTRY; + rc = lov_fini_enqueue_set(lovset, lovset->set_ei->ei_mode, rc, rqset); RETURN(rc); } @@ -1623,7 +1596,6 @@ static int lov_enqueue(struct obd_export *exp, struct obd_info *oinfo, struct list_head *pos; struct lov_obd *lov; ldlm_error_t rc; - ENTRY; LASSERT(oinfo); ASSERT_LSM_MAGIC(oinfo->oi_md); @@ -1667,7 +1639,6 @@ static int lov_change_cbdata(struct obd_export *exp, { struct lov_obd *lov; int rc = 0, i; - ENTRY; ASSERT_LSM_MAGIC(lsm); @@ -1702,7 +1673,6 @@ static int lov_find_cbdata(struct obd_export *exp, { struct lov_obd *lov; int rc = 0, i; - ENTRY; ASSERT_LSM_MAGIC(lsm); @@ -1738,7 +1708,6 @@ static int lov_cancel(struct obd_export *exp, struct lov_stripe_md *lsm, struct lov_obd *lov; struct lustre_handle *lov_lockhp; int err = 0, rc = 0; - ENTRY; ASSERT_LSM_MAGIC(lsm); @@ -1778,7 +1747,6 @@ static int lov_cancel_unused(struct obd_export *exp, { struct lov_obd *lov; int rc = 0, i; - ENTRY; if (!exp || !exp->exp_obd) RETURN(-ENODEV); @@ -1834,7 +1802,6 @@ int lov_statfs_interpret(struct ptlrpc_request_set *rqset, void *data, int rc) { struct lov_request_set *lovset = (struct lov_request_set *)data; int err; - ENTRY; if (rc) atomic_set(&lovset->set_completes, 0); @@ -1852,7 +1819,6 @@ static int lov_statfs_async(struct obd_export *exp, struct obd_info *oinfo, struct list_head *pos; struct lov_obd *lov; int rc = 0; - ENTRY; LASSERT(oinfo != NULL); LASSERT(oinfo->oi_osfs != NULL); @@ -1890,8 +1856,6 @@ static int lov_statfs(const struct lu_env *env, struct obd_export *exp, struct ptlrpc_request_set *set = NULL; struct obd_info oinfo = { { { 0 } } }; int rc = 0; - ENTRY; - /* for obdclass we forbid using obd_statfs_rqset, but prefer using async * statfs requests */ @@ -1916,7 +1880,6 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, struct lov_obd *lov = &obddev->u.lov; int i = 0, rc = 0, count = lov->desc.ld_tgt_count; struct obd_uuid *uuidp; - ENTRY; switch (cmd) { case IOC_OBD_STATFS: { @@ -2469,7 +2432,6 @@ static int lov_get_info(const struct lu_env *env, struct obd_export *exp, struct obd_device *obddev = class_exp2obd(exp); struct lov_obd *lov = &obddev->u.lov; int i, rc; - ENTRY; if (!vallen || !val) RETURN(-EFAULT); @@ -2568,7 +2530,6 @@ static int lov_set_info_async(const struct lu_env *env, struct obd_export *exp, unsigned incr, check_uuid, do_inactive, no_set; unsigned next_id = 0, mds_con = 0, capa = 0; - ENTRY; incr = check_uuid = do_inactive = no_set = 0; if (set == NULL) { @@ -2719,7 +2680,6 @@ static int lov_quotactl(struct obd_device *obd, struct obd_export *exp, __u64 curspace = 0; __u64 bhardlimit = 0; int i, rc = 0; - ENTRY; if (oqctl->qc_cmd != LUSTRE_Q_QUOTAON && oqctl->qc_cmd != LUSTRE_Q_QUOTAOFF && @@ -2778,7 +2738,6 @@ static int lov_quotacheck(struct obd_device *obd, struct obd_export *exp, { struct lov_obd *lov = &obd->u.lov; int i, rc = 0; - ENTRY; obd_getref(obd); @@ -2870,7 +2829,6 @@ int __init lov_init(void) { struct lprocfs_static_vars lvars = { 0 }; int rc; - ENTRY; /* print an address of _any_ initialized kernel symbol from this * module, to allow debugging with gdb that doesn't support data diff --git a/drivers/staging/lustre/lustre/lov/lov_object.c b/drivers/staging/lustre/lustre/lov/lov_object.c index e7cc6502237f5..3bf8c0c08b6b1 100644 --- a/drivers/staging/lustre/lustre/lov/lov_object.c +++ b/drivers/staging/lustre/lustre/lov/lov_object.c @@ -116,7 +116,6 @@ static struct cl_object *lov_sub_find(const struct lu_env *env, { struct lu_object *o; - ENTRY; o = lu_object_find_at(env, cl2lu_dev(dev), fid, &conf->coc_lu); LASSERT(ergo(!IS_ERR(o), o->lo_dev->ld_type == &lovsub_device_type)); RETURN(lu2cl(o)); @@ -204,8 +203,6 @@ static int lov_init_raid0(const struct lu_env *env, struct lu_fid *ofid = <i->lti_fid; struct lov_layout_raid0 *r0 = &state->raid0; - ENTRY; - if (lsm->lsm_magic != LOV_MAGIC_V1 && lsm->lsm_magic != LOV_MAGIC_V3) { dump_lsm(D_ERROR, lsm); LASSERTF(0, "magic mismatch, expected %d/%d, actual %d.\n", @@ -338,8 +335,6 @@ static int lov_delete_raid0(const struct lu_env *env, struct lov_object *lov, struct lov_stripe_md *lsm = lov->lo_lsm; int i; - ENTRY; - dump_lsm(D_INODE, lsm); lov_layout_wait(env, lov); @@ -371,7 +366,6 @@ static void lov_fini_raid0(const struct lu_env *env, struct lov_object *lov, union lov_layout_state *state) { struct lov_layout_raid0 *r0 = &state->raid0; - ENTRY; if (r0->lo_sub != NULL) { OBD_FREE_LARGE(r0->lo_sub, r0->lo_nr * sizeof r0->lo_sub[0]); @@ -387,7 +381,6 @@ static void lov_fini_raid0(const struct lu_env *env, struct lov_object *lov, static void lov_fini_released(const struct lu_env *env, struct lov_object *lov, union lov_layout_state *state) { - ENTRY; dump_lsm(D_INODE, lov->lo_lsm); lov_free_memmd(&lov->lo_lsm); EXIT; @@ -453,8 +446,6 @@ static int lov_attr_get_raid0(const struct lu_env *env, struct cl_object *obj, struct cl_attr *lov_attr = &r0->lo_attr; int result = 0; - ENTRY; - /* this is called w/o holding type guard mutex, so it must be inside * an on going IO otherwise lsm may be replaced. * LU-2117: it turns out there exists one exception. For mmaped files, @@ -634,7 +625,6 @@ static void lov_conf_unlock(struct lov_object *lov) static int lov_layout_wait(const struct lu_env *env, struct lov_object *lov) { struct l_wait_info lwi = { 0 }; - ENTRY; while (atomic_read(&lov->lo_active_ios) > 0) { CDEBUG(D_INODE, "file:"DFID" wait for active IO, now: %d.\n", @@ -661,7 +651,6 @@ static int lov_layout_change(const struct lu_env *unused, void *cookie; struct lu_env *env; int refcheck; - ENTRY; LASSERT(0 <= lov->lo_type && lov->lo_type < ARRAY_SIZE(lov_dispatch)); @@ -721,7 +710,6 @@ int lov_object_init(const struct lu_env *env, struct lu_object *obj, const struct lov_layout_operations *ops; int result; - ENTRY; init_rwsem(&lov->lo_type_guard); atomic_set(&lov->lo_active_ios, 0); init_waitqueue_head(&lov->lo_waitq); @@ -743,7 +731,6 @@ static int lov_conf_set(const struct lu_env *env, struct cl_object *obj, struct lov_stripe_md *lsm = NULL; struct lov_object *lov = cl2lov(obj); int result = 0; - ENTRY; lov_conf_lock(lov); if (conf->coc_opc == OBJECT_CONF_INVALIDATE) { @@ -791,7 +778,6 @@ static void lov_object_delete(const struct lu_env *env, struct lu_object *obj) { struct lov_object *lov = lu2lov(obj); - ENTRY; LOV_2DISPATCH_VOID(lov, llo_delete, env, lov, &lov->u); EXIT; } @@ -800,7 +786,6 @@ static void lov_object_free(const struct lu_env *env, struct lu_object *obj) { struct lov_object *lov = lu2lov(obj); - ENTRY; LOV_2DISPATCH_VOID(lov, llo_fini, env, lov, &lov->u); lu_object_fini(obj); OBD_SLAB_FREE_PTR(lov, lov_object_kmem); @@ -887,7 +872,6 @@ struct lu_object *lov_object_alloc(const struct lu_env *env, struct lov_object *lov; struct lu_object *obj; - ENTRY; OBD_SLAB_ALLOC_PTR_GFP(lov, lov_object_kmem, __GFP_IO); if (lov != NULL) { obj = lov2lu(lov); @@ -958,7 +942,6 @@ int lov_read_and_clear_async_rc(struct cl_object *clob) { struct lu_object *luobj; int rc = 0; - ENTRY; luobj = lu_object_locate(&cl_object_header(clob)->coh_lu, &lov_device_type); diff --git a/drivers/staging/lustre/lustre/lov/lov_offset.c b/drivers/staging/lustre/lustre/lov/lov_offset.c index f62b7e53b6658..079ad5c90566c 100644 --- a/drivers/staging/lustre/lustre/lov/lov_offset.c +++ b/drivers/staging/lustre/lustre/lov/lov_offset.c @@ -52,7 +52,6 @@ obd_size lov_stripe_size(struct lov_stripe_md *lsm, obd_size ost_size, obd_off swidth; obd_size lov_size; int magic = lsm->lsm_magic; - ENTRY; if (ost_size == 0) RETURN(0); diff --git a/drivers/staging/lustre/lustre/lov/lov_pack.c b/drivers/staging/lustre/lustre/lov/lov_pack.c index 9c99e4a2c5d8c..5edcf8e28c0e2 100644 --- a/drivers/staging/lustre/lustre/lov/lov_pack.c +++ b/drivers/staging/lustre/lustre/lov/lov_pack.c @@ -143,7 +143,6 @@ int lov_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, int lmm_size, lmm_magic; int i; int cplen = 0; - ENTRY; if (lsm) { lmm_magic = lsm->lsm_magic; @@ -309,7 +308,6 @@ int lov_alloc_memmd(struct lov_stripe_md **lsmp, __u16 stripe_count, int pattern, int magic) { int i, lsm_size; - ENTRY; CDEBUG(D_INFO, "alloc lsm, stripe_count %d\n", stripe_count); @@ -363,7 +361,6 @@ int lov_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, __u16 stripe_count; __u32 magic; __u32 pattern; - ENTRY; /* If passed an MDS struct use values from there, otherwise defaults */ if (lmm) { @@ -420,7 +417,6 @@ static int __lov_setstripe(struct obd_export *exp, int max_lmm_size, __u16 stripe_count; int rc; int cplen = 0; - ENTRY; rc = lov_lum_swab_if_needed(lumv3, &lmm_magic, lump); if (rc) @@ -546,8 +542,6 @@ int lov_setea(struct obd_export *exp, struct lov_stripe_md **lsmp, obd_id last_id = 0; struct lov_user_ost_data_v1 *lmm_objects; - ENTRY; - if (lump->lmm_magic == LOV_USER_MAGIC_V3) lmm_objects = ((struct lov_user_md_v3 *)lump)->lmm_objects; else @@ -600,7 +594,6 @@ int lov_getstripe(struct obd_export *exp, struct lov_stripe_md *lsm, int rc, lmm_size; int lum_size; mm_segment_t seg; - ENTRY; if (!lsm) RETURN(-ENODATA); diff --git a/drivers/staging/lustre/lustre/lov/lov_page.c b/drivers/staging/lustre/lustre/lov/lov_page.c index 65790d684720c..f8b364f1e632e 100644 --- a/drivers/staging/lustre/lustre/lov/lov_page.c +++ b/drivers/staging/lustre/lustre/lov/lov_page.c @@ -69,7 +69,6 @@ static void lov_page_fini(const struct lu_env *env, struct cl_page *sub = lov_sub_page(slice); LINVRNT(lov_page_invariant(slice)); - ENTRY; if (sub != NULL) { LASSERT(sub->cp_state == CPS_FREEING); @@ -90,7 +89,6 @@ static int lov_page_own(const struct lu_env *env, LINVRNT(lov_page_invariant(slice)); LINVRNT(!cl2lov_page(slice)->lps_invalid); - ENTRY; sub = lov_page_subio(env, lio, slice); if (!IS_ERR(sub)) { @@ -117,7 +115,6 @@ static int lov_page_cache_add(const struct lu_env *env, LINVRNT(lov_page_invariant(slice)); LINVRNT(!cl2lov_page(slice)->lps_invalid); - ENTRY; sub = lov_page_subio(env, lio, slice); if (!IS_ERR(sub)) { @@ -172,7 +169,6 @@ int lov_page_init_raid0(const struct lu_env *env, struct cl_object *obj, obd_off suboff; int stripe; int rc; - ENTRY; offset = cl_offset(obj, page->cp_index); stripe = lov_stripe_number(loo->lo_lsm, offset); @@ -221,7 +217,6 @@ int lov_page_init_empty(const struct lu_env *env, struct cl_object *obj, { struct lov_page *lpg = cl_object_page_slice(obj, page); void *addr; - ENTRY; cl_page_slice_add(page, &lpg->lps_cl, obj, &lov_empty_page_ops); addr = kmap(vmpage); diff --git a/drivers/staging/lustre/lustre/lov/lov_pool.c b/drivers/staging/lustre/lustre/lov/lov_pool.c index a96f90880c640..63b94661702e7 100644 --- a/drivers/staging/lustre/lustre/lov/lov_pool.c +++ b/drivers/staging/lustre/lustre/lov/lov_pool.c @@ -322,8 +322,6 @@ void lov_dump_pool(int level, struct pool_desc *pool) #define LOV_POOL_INIT_COUNT 2 int lov_ost_pool_init(struct ost_pool *op, unsigned int count) { - ENTRY; - if (count == 0) count = LOV_POOL_INIT_COUNT; op->op_array = NULL; @@ -366,7 +364,6 @@ int lov_ost_pool_extend(struct ost_pool *op, unsigned int min_count) int lov_ost_pool_add(struct ost_pool *op, __u32 idx, unsigned int min_count) { int rc = 0, i; - ENTRY; down_write(&op->op_rw_sem); @@ -391,7 +388,6 @@ int lov_ost_pool_add(struct ost_pool *op, __u32 idx, unsigned int min_count) int lov_ost_pool_remove(struct ost_pool *op, __u32 idx) { int i; - ENTRY; down_write(&op->op_rw_sem); @@ -412,8 +408,6 @@ int lov_ost_pool_remove(struct ost_pool *op, __u32 idx) int lov_ost_pool_free(struct ost_pool *op) { - ENTRY; - if (op->op_size == 0) RETURN(0); @@ -434,7 +428,6 @@ int lov_pool_new(struct obd_device *obd, char *poolname) struct lov_obd *lov; struct pool_desc *new_pool; int rc; - ENTRY; lov = &(obd->u.lov); @@ -513,7 +506,6 @@ int lov_pool_del(struct obd_device *obd, char *poolname) { struct lov_obd *lov; struct pool_desc *pool; - ENTRY; lov = &(obd->u.lov); @@ -547,7 +539,6 @@ int lov_pool_add(struct obd_device *obd, char *poolname, char *ostname) struct pool_desc *pool; unsigned int lov_idx; int rc; - ENTRY; lov = &(obd->u.lov); @@ -594,7 +585,6 @@ int lov_pool_remove(struct obd_device *obd, char *poolname, char *ostname) struct pool_desc *pool; unsigned int lov_idx; int rc = 0; - ENTRY; lov = &(obd->u.lov); @@ -636,7 +626,6 @@ int lov_pool_remove(struct obd_device *obd, char *poolname, char *ostname) int lov_check_index_in_pool(__u32 idx, struct pool_desc *pool) { int i, rc; - ENTRY; /* caller may no have a ref on pool if it got the pool * without calling lov_find_pool() (e.g. go through the lov pool diff --git a/drivers/staging/lustre/lustre/lov/lov_request.c b/drivers/staging/lustre/lustre/lov/lov_request.c index 13f1637bc7004..fc1cd898f5c95 100644 --- a/drivers/staging/lustre/lustre/lov/lov_request.c +++ b/drivers/staging/lustre/lustre/lov/lov_request.c @@ -60,7 +60,6 @@ static void lov_init_set(struct lov_request_set *set) void lov_finish_set(struct lov_request_set *set) { struct list_head *pos, *n; - ENTRY; LASSERT(set); list_for_each_safe(pos, n, &set->set_list) { @@ -122,7 +121,6 @@ int lov_update_common_set(struct lov_request_set *set, struct lov_request *req, int rc) { struct lov_obd *lov = &set->set_exp->exp_obd->u.lov; - ENTRY; lov_update_set(set, req, rc); @@ -232,7 +230,6 @@ int lov_update_enqueue_set(struct lov_request *req, __u32 mode, int rc) struct lustre_handle *lov_lockhp; struct obd_info *oi = set->set_oi; struct lov_oinfo *loi; - ENTRY; LASSERT(oi != NULL); @@ -275,7 +272,6 @@ static int enqueue_done(struct lov_request_set *set, __u32 mode) struct lov_obd *lov = &set->set_exp->exp_obd->u.lov; int completes = atomic_read(&set->set_completes); int rc = 0; - ENTRY; /* enqueue/match success, just return */ if (completes && completes == atomic_read(&set->set_success)) @@ -312,7 +308,6 @@ int lov_fini_enqueue_set(struct lov_request_set *set, __u32 mode, int rc, struct ptlrpc_request_set *rqset) { int ret = 0; - ENTRY; if (set == NULL) RETURN(0); @@ -369,7 +364,6 @@ int lov_prep_enqueue_set(struct obd_export *exp, struct obd_info *oinfo, struct lov_obd *lov = &exp->exp_obd->u.lov; struct lov_request_set *set; int i, rc = 0; - ENTRY; OBD_ALLOC(set, sizeof(*set)); if (set == NULL) @@ -454,7 +448,6 @@ int lov_prep_enqueue_set(struct obd_export *exp, struct obd_info *oinfo, int lov_fini_match_set(struct lov_request_set *set, __u32 mode, int flags) { int rc = 0; - ENTRY; if (set == NULL) RETURN(0); @@ -477,7 +470,6 @@ int lov_prep_match_set(struct obd_export *exp, struct obd_info *oinfo, struct lov_obd *lov = &exp->exp_obd->u.lov; struct lov_request_set *set; int i, rc = 0; - ENTRY; OBD_ALLOC(set, sizeof(*set)); if (set == NULL) @@ -544,7 +536,6 @@ int lov_prep_match_set(struct obd_export *exp, struct obd_info *oinfo, int lov_fini_cancel_set(struct lov_request_set *set) { int rc = 0; - ENTRY; if (set == NULL) RETURN(0); @@ -565,7 +556,6 @@ int lov_prep_cancel_set(struct obd_export *exp, struct obd_info *oinfo, { struct lov_request_set *set; int i, rc = 0; - ENTRY; OBD_ALLOC(set, sizeof(*set)); if (set == NULL) @@ -628,7 +618,6 @@ static int common_attr_done(struct lov_request_set *set) struct lov_request *req; struct obdo *tmp_oa; int rc = 0, attrset = 0; - ENTRY; LASSERT(set->set_oi != NULL); @@ -680,7 +669,6 @@ static int brw_done(struct lov_request_set *set) struct lov_oinfo *loi = NULL; struct list_head *pos; struct lov_request *req; - ENTRY; list_for_each (pos, &set->set_list) { req = list_entry(pos, struct lov_request, rq_link); @@ -700,7 +688,6 @@ static int brw_done(struct lov_request_set *set) int lov_fini_brw_set(struct lov_request_set *set) { int rc = 0; - ENTRY; if (set == NULL) RETURN(0); @@ -727,7 +714,6 @@ int lov_prep_brw_set(struct obd_export *exp, struct obd_info *oinfo, struct lov_request_set *set; struct lov_obd *lov = &exp->exp_obd->u.lov; int rc = 0, i, shift; - ENTRY; OBD_ALLOC(set, sizeof(*set)); if (set == NULL) @@ -838,7 +824,6 @@ int lov_prep_brw_set(struct obd_export *exp, struct obd_info *oinfo, int lov_fini_getattr_set(struct lov_request_set *set) { int rc = 0; - ENTRY; if (set == NULL) RETURN(0); @@ -867,7 +852,6 @@ int lov_prep_getattr_set(struct obd_export *exp, struct obd_info *oinfo, struct lov_request_set *set; struct lov_obd *lov = &exp->exp_obd->u.lov; int rc = 0, i; - ENTRY; OBD_ALLOC(set, sizeof(*set)); if (set == NULL) @@ -921,8 +905,6 @@ int lov_prep_getattr_set(struct obd_export *exp, struct obd_info *oinfo, int lov_fini_destroy_set(struct lov_request_set *set) { - ENTRY; - if (set == NULL) RETURN(0); LASSERT(set->set_exp); @@ -943,7 +925,6 @@ int lov_prep_destroy_set(struct obd_export *exp, struct obd_info *oinfo, struct lov_request_set *set; struct lov_obd *lov = &exp->exp_obd->u.lov; int rc = 0, i; - ENTRY; OBD_ALLOC(set, sizeof(*set)); if (set == NULL) @@ -996,7 +977,6 @@ int lov_prep_destroy_set(struct obd_export *exp, struct obd_info *oinfo, int lov_fini_setattr_set(struct lov_request_set *set) { int rc = 0; - ENTRY; if (set == NULL) RETURN(0); @@ -1015,7 +995,6 @@ int lov_update_setattr_set(struct lov_request_set *set, { struct lov_obd *lov = &req->rq_rqset->set_exp->exp_obd->u.lov; struct lov_stripe_md *lsm = req->rq_rqset->set_oi->oi_md; - ENTRY; lov_update_set(set, req, rc); @@ -1056,7 +1035,6 @@ int lov_prep_setattr_set(struct obd_export *exp, struct obd_info *oinfo, struct lov_request_set *set; struct lov_obd *lov = &exp->exp_obd->u.lov; int rc = 0, i; - ENTRY; OBD_ALLOC(set, sizeof(*set)); if (set == NULL) @@ -1122,7 +1100,6 @@ int lov_prep_setattr_set(struct obd_export *exp, struct obd_info *oinfo, int lov_fini_punch_set(struct lov_request_set *set) { int rc = 0; - ENTRY; if (set == NULL) RETURN(0); @@ -1144,7 +1121,6 @@ int lov_update_punch_set(struct lov_request_set *set, { struct lov_obd *lov = &req->rq_rqset->set_exp->exp_obd->u.lov; struct lov_stripe_md *lsm = req->rq_rqset->set_oi->oi_md; - ENTRY; lov_update_set(set, req, rc); @@ -1182,7 +1158,6 @@ int lov_prep_punch_set(struct obd_export *exp, struct obd_info *oinfo, struct lov_request_set *set; struct lov_obd *lov = &exp->exp_obd->u.lov; int rc = 0, i; - ENTRY; OBD_ALLOC(set, sizeof(*set)); if (set == NULL) @@ -1247,7 +1222,6 @@ int lov_prep_punch_set(struct obd_export *exp, struct obd_info *oinfo, int lov_fini_sync_set(struct lov_request_set *set) { int rc = 0; - ENTRY; if (set == NULL) RETURN(0); @@ -1281,7 +1255,6 @@ int lov_prep_sync_set(struct obd_export *exp, struct obd_info *oinfo, struct lov_request_set *set; struct lov_obd *lov = &exp->exp_obd->u.lov; int rc = 0, i; - ENTRY; OBD_ALLOC_PTR(set); if (set == NULL) @@ -1347,8 +1320,6 @@ int lov_prep_sync_set(struct obd_export *exp, struct obd_info *oinfo, int lov_fini_statfs(struct obd_device *obd, struct obd_statfs *osfs,int success) { - ENTRY; - if (success) { __u32 expected_stripes = lov_get_stripecnt(&obd->u.lov, LOV_MAGIC, 0); @@ -1370,7 +1341,6 @@ int lov_fini_statfs(struct obd_device *obd, struct obd_statfs *osfs,int success) int lov_fini_statfs_set(struct lov_request_set *set) { int rc = 0; - ENTRY; if (set == NULL) RETURN(0); @@ -1450,7 +1420,6 @@ static int cb_statfs_update(void *cookie, int rc) struct lov_tgt_desc *tgt; struct obd_device *lovobd, *tgtobd; int success; - ENTRY; lovreq = container_of(oinfo, struct lov_request, rq_oi); set = lovreq->rq_rqset; @@ -1497,7 +1466,6 @@ int lov_prep_statfs_set(struct obd_device *obd, struct obd_info *oinfo, struct lov_request_set *set; struct lov_obd *lov = &obd->u.lov; int rc = 0, i; - ENTRY; OBD_ALLOC(set, sizeof(*set)); if (set == NULL) diff --git a/drivers/staging/lustre/lustre/lov/lovsub_dev.c b/drivers/staging/lustre/lustre/lov/lovsub_dev.c index 204ecd0b86390..05ad75e210d52 100644 --- a/drivers/staging/lustre/lustre/lov/lovsub_dev.c +++ b/drivers/staging/lustre/lustre/lov/lovsub_dev.c @@ -55,7 +55,6 @@ static void lovsub_req_completion(const struct lu_env *env, { struct lovsub_req *lsr; - ENTRY; lsr = cl2lovsub_req(slice); OBD_SLAB_FREE_PTR(lsr, lovsub_req_kmem); EXIT; @@ -73,7 +72,6 @@ static void lovsub_req_attr_set(const struct lu_env *env, { struct lovsub_object *subobj; - ENTRY; subobj = cl2lovsub(obj); /* * There is no OBD_MD_* flag for obdo::o_stripe_idx, so set it @@ -101,7 +99,6 @@ static int lovsub_device_init(const struct lu_env *env, struct lu_device *d, struct lu_device_type *ldt; int rc; - ENTRY; next->ld_site = d->ld_site; ldt = next->ld_type; LASSERT(ldt != NULL); @@ -123,7 +120,6 @@ static struct lu_device *lovsub_device_fini(const struct lu_env *env, struct lu_device *next; struct lovsub_device *lsd; - ENTRY; lsd = lu2lovsub_dev(d); next = cl2lu_dev(lsd->acid_next); lsd->acid_super = NULL; diff --git a/drivers/staging/lustre/lustre/lov/lovsub_lock.c b/drivers/staging/lustre/lustre/lov/lovsub_lock.c index 03bab17ccc64f..b73ad7a96669b 100644 --- a/drivers/staging/lustre/lustre/lov/lovsub_lock.c +++ b/drivers/staging/lustre/lustre/lov/lovsub_lock.c @@ -57,7 +57,6 @@ static void lovsub_lock_fini(const struct lu_env *env, { struct lovsub_lock *lsl; - ENTRY; lsl = cl2lovsub_lock(slice); LASSERT(list_empty(&lsl->lss_parents)); OBD_SLAB_FREE_PTR(lsl, lovsub_lock_kmem); @@ -68,7 +67,6 @@ static void lovsub_parent_lock(const struct lu_env *env, struct lov_lock *lov) { struct cl_lock *parent; - ENTRY; parent = lov->lls_cl.cls_lock; cl_lock_get(parent); lu_ref_add(&parent->cll_reference, "lovsub-parent", current); @@ -80,7 +78,6 @@ static void lovsub_parent_unlock(const struct lu_env *env, struct lov_lock *lov) { struct cl_lock *parent; - ENTRY; parent = lov->lls_cl.cls_lock; cl_lock_mutex_put(env, lov->lls_cl.cls_lock); lu_ref_del(&parent->cll_reference, "lovsub-parent", current); @@ -101,7 +98,6 @@ static void lovsub_lock_state(const struct lu_env *env, struct lov_lock_link *scan; LASSERT(cl_lock_is_mutexed(slice->cls_lock)); - ENTRY; list_for_each_entry(scan, &sub->lss_parents, lll_list) { struct lov_lock *lov = scan->lll_super; @@ -127,8 +123,6 @@ static unsigned long lovsub_lock_weigh(const struct lu_env *env, struct lov_lock *lov; unsigned long dumbbell; - ENTRY; - LASSERT(cl_lock_is_mutexed(slice->cls_lock)); if (!list_empty(&lock->lss_parents)) { @@ -162,7 +156,6 @@ static void lovsub_lock_descr_map(const struct cl_lock_descr *in, pgoff_t start; pgoff_t end; - ENTRY; start = in->cld_start; end = in->cld_end; @@ -241,8 +234,6 @@ static int lovsub_lock_modify(const struct lu_env *env, struct lov_lock *lov; int result = 0; - ENTRY; - LASSERT(cl_lock_mode_match(d->cld_mode, s->cls_lock->cll_descr.cld_mode)); list_for_each_entry(scan, &lock->lss_parents, lll_list) { @@ -267,7 +258,6 @@ static int lovsub_lock_closure(const struct lu_env *env, int result; LASSERT(cl_lock_is_mutexed(slice->cls_lock)); - ENTRY; sub = cl2lovsub_lock(slice); result = 0; @@ -290,7 +280,6 @@ static int lovsub_lock_delete_one(const struct lu_env *env, { struct cl_lock *parent; int result; - ENTRY; parent = lov->lls_cl.cls_lock; if (parent->cll_error) @@ -403,7 +392,6 @@ static void lovsub_lock_delete(const struct lu_env *env, LASSERT(cl_lock_is_mutexed(child)); - ENTRY; /* * Destruction of a sub-lock might take multiple iterations, because * when the last sub-lock of a given top-lock is deleted, top-lock is @@ -471,7 +459,6 @@ int lovsub_lock_init(const struct lu_env *env, struct cl_object *obj, struct lovsub_lock *lsk; int result; - ENTRY; OBD_SLAB_ALLOC_PTR_GFP(lsk, lovsub_lock_kmem, __GFP_IO); if (lsk != NULL) { INIT_LIST_HEAD(&lsk->lss_parents); diff --git a/drivers/staging/lustre/lustre/lov/lovsub_object.c b/drivers/staging/lustre/lustre/lov/lovsub_object.c index 1b83d9081c40f..7264ba31b9e61 100644 --- a/drivers/staging/lustre/lustre/lov/lovsub_object.c +++ b/drivers/staging/lustre/lustre/lov/lovsub_object.c @@ -61,7 +61,6 @@ int lovsub_object_init(const struct lu_env *env, struct lu_object *obj, int result; - ENTRY; under = &dev->acid_next->cd_lu_dev; below = under->ld_ops->ldo_object_alloc(env, obj->lo_header, under); if (below != NULL) { @@ -78,7 +77,6 @@ static void lovsub_object_free(const struct lu_env *env, struct lu_object *obj) { struct lovsub_object *los = lu2lovsub(obj); struct lov_object *lov = los->lso_super; - ENTRY; /* We can't assume lov was assigned here, because of the shadow * object handling in lu_object_find. @@ -110,7 +108,6 @@ static int lovsub_attr_set(const struct lu_env *env, struct cl_object *obj, { struct lov_object *lov = cl2lovsub(obj)->lso_super; - ENTRY; lov_r0(lov)->lo_attr_valid = 0; RETURN(0); } @@ -121,7 +118,6 @@ static int lovsub_object_glimpse(const struct lu_env *env, { struct lovsub_object *los = cl2lovsub(obj); - ENTRY; RETURN(cl_object_glimpse(env, &los->lso_super->lo_cl, lvb)); } @@ -150,7 +146,6 @@ struct lu_object *lovsub_object_alloc(const struct lu_env *env, struct lovsub_object *los; struct lu_object *obj; - ENTRY; OBD_SLAB_ALLOC_PTR_GFP(los, lovsub_object_kmem, __GFP_IO); if (los != NULL) { struct cl_object_header *hdr; diff --git a/drivers/staging/lustre/lustre/lov/lovsub_page.c b/drivers/staging/lustre/lustre/lov/lovsub_page.c index bc9e683968da4..3a738eca56926 100644 --- a/drivers/staging/lustre/lustre/lov/lovsub_page.c +++ b/drivers/staging/lustre/lustre/lov/lovsub_page.c @@ -63,7 +63,6 @@ int lovsub_page_init(const struct lu_env *env, struct cl_object *obj, struct cl_page *page, struct page *unused) { struct lovsub_page *lsb = cl_object_page_slice(obj, page); - ENTRY; cl_page_slice_add(page, &lsb->lsb_cl, obj, &lovsub_page_ops); RETURN(0); diff --git a/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c b/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c index d342e976317b2..71f62695b926b 100644 --- a/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c +++ b/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c @@ -203,7 +203,6 @@ int lustre_rename(struct dentry *dir, struct vfsmount *mnt, { struct dentry *dchild_old, *dchild_new; int err = 0; - ENTRY; ASSERT_KERNEL_CTXT("kernel doing rename outside kernel context\n"); CDEBUG(D_INODE, "renaming file %.*s to %.*s\n", diff --git a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c index 75300847f9128..30a8a1b2428df 100644 --- a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c +++ b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c @@ -92,7 +92,6 @@ static ssize_t mdc_kuc_write(struct file *file, const char *buffer, struct hsm_action_item *hai; int len; int fd, rc; - ENTRY; rc = lprocfs_write_helper(buffer, count, &fd); if (rc) diff --git a/drivers/staging/lustre/lustre/mdc/mdc_lib.c b/drivers/staging/lustre/lustre/mdc/mdc_lib.c index 2e5c7cef61ce2..4ab3b95faf8b4 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_lib.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_lib.c @@ -505,7 +505,7 @@ void mdc_close_pack(struct ptlrpc_request *req, struct md_op_data *op_data) static int mdc_req_avail(struct client_obd *cli, struct mdc_cache_waiter *mcw) { int rc; - ENTRY; + client_obd_list_lock(&cli->cl_loi_list_lock); rc = list_empty(&mcw->mcw_entry); client_obd_list_unlock(&cli->cl_loi_list_lock); diff --git a/drivers/staging/lustre/lustre/mdc/mdc_locks.c b/drivers/staging/lustre/lustre/mdc/mdc_locks.c index 803c390e1c35d..9025075d105b4 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_locks.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_locks.c @@ -115,7 +115,6 @@ int mdc_set_lock_data(struct obd_export *exp, __u64 *lockh, void *data, { struct ldlm_lock *lock; struct inode *new_inode = data; - ENTRY; if(bits) *bits = 0; @@ -154,7 +153,6 @@ ldlm_mode_t mdc_lock_match(struct obd_export *exp, __u64 flags, { struct ldlm_res_id res_id; ldlm_mode_t rc; - ENTRY; fid_build_reg_res_name(fid, &res_id); rc = ldlm_lock_match(class_exp2obd(exp)->obd_namespace, flags, @@ -173,8 +171,6 @@ int mdc_cancel_unused(struct obd_export *exp, struct obd_device *obd = class_exp2obd(exp); int rc; - ENTRY; - fid_build_reg_res_name(fid, &res_id); rc = ldlm_cli_cancel_unused_resource(obd->obd_namespace, &res_id, policy, mode, flags, opaque); @@ -187,7 +183,6 @@ int mdc_null_inode(struct obd_export *exp, struct ldlm_res_id res_id; struct ldlm_resource *res; struct ldlm_namespace *ns = class_exp2obd(exp)->obd_namespace; - ENTRY; LASSERTF(ns != NULL, "no namespace passed\n"); @@ -215,7 +210,6 @@ int mdc_find_cbdata(struct obd_export *exp, { struct ldlm_res_id res_id; int rc = 0; - ENTRY; fid_build_reg_res_name((struct lu_fid*)fid, &res_id); rc = ldlm_resource_iterate(class_exp2obd(exp)->obd_namespace, &res_id, @@ -281,7 +275,6 @@ static struct ptlrpc_request *mdc_intent_open_pack(struct obd_export *exp, int count = 0; int mode; int rc; - ENTRY; it->it_create_mode = (it->it_create_mode & ~S_IFMT) | S_IFREG; @@ -362,7 +355,6 @@ static struct ptlrpc_request *mdc_intent_unlink_pack(struct obd_export *exp, struct obd_device *obddev = class_exp2obd(exp); struct ldlm_intent *lit; int rc; - ENTRY; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_LDLM_INTENT_UNLINK); @@ -407,7 +399,6 @@ static struct ptlrpc_request *mdc_intent_getattr_pack(struct obd_export *exp, OBD_MD_FLRMTPERM : OBD_MD_FLACL); struct ldlm_intent *lit; int rc; - ENTRY; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_LDLM_INTENT_GETATTR); @@ -450,7 +441,6 @@ static struct ptlrpc_request *mdc_intent_layout_pack(struct obd_export *exp, struct ldlm_intent *lit; struct layout_intent *layout; int rc; - ENTRY; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_LDLM_INTENT_LAYOUT); @@ -485,7 +475,6 @@ mdc_enqueue_pack(struct obd_export *exp, int lvb_len) { struct ptlrpc_request *req; int rc; - ENTRY; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_LDLM_ENQUEUE); if (req == NULL) @@ -516,7 +505,6 @@ static int mdc_finish_enqueue(struct obd_export *exp, struct ldlm_lock *lock; void *lvb_data = NULL; int lvb_len = 0; - ENTRY; LASSERT(rc >= 0); /* Similarly, if we're going to replay this request, we don't want to @@ -738,7 +726,6 @@ int mdc_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo, int generation, resends = 0; struct ldlm_reply *lockrep; enum lvb_type lvb_type = 0; - ENTRY; LASSERTF(!it || einfo->ei_type == LDLM_IBITS, "lock type %d\n", einfo->ei_type); @@ -890,7 +877,6 @@ static int mdc_finish_intent_lock(struct obd_export *exp, struct mdt_body *mdt_body; struct ldlm_lock *lock; int rc; - ENTRY; LASSERT(request != NULL); LASSERT(request != LP_POISON); @@ -1006,7 +992,6 @@ int mdc_revalidate_lock(struct obd_export *exp, struct lookup_intent *it, struct lustre_handle lockh; ldlm_policy_data_t policy; ldlm_mode_t mode; - ENTRY; if (it->d.lustre.it_lock_handle) { lockh.cookie = it->d.lustre.it_lock_handle; @@ -1076,7 +1061,7 @@ int mdc_intent_lock(struct obd_export *exp, struct md_op_data *op_data, { struct lustre_handle lockh; int rc = 0; - ENTRY; + LASSERT(it); CDEBUG(D_DLMTRACE, "(name: %.*s,"DFID") in obj "DFID @@ -1153,7 +1138,6 @@ static int mdc_intent_getattr_async_interpret(const struct lu_env *env, struct obd_device *obddev; struct ldlm_reply *lockrep; __u64 flags = LDLM_FL_HAS_INTENT; - ENTRY; it = &minfo->mi_it; lockh = &minfo->mi_lockh; @@ -1210,7 +1194,6 @@ int mdc_intent_getattr_async(struct obd_export *exp, }; int rc = 0; __u64 flags = LDLM_FL_HAS_INTENT; - ENTRY; CDEBUG(D_DLMTRACE,"name: %.*s in inode "DFID", intent: %s flags %#o\n", op_data->op_namelen, op_data->op_name, PFID(&op_data->op_fid1), diff --git a/drivers/staging/lustre/lustre/mdc/mdc_reint.c b/drivers/staging/lustre/lustre/mdc/mdc_reint.c index 5e25a07c52bdf..be007a36f7df2 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_reint.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_reint.c @@ -75,7 +75,6 @@ int mdc_resource_get_unused(struct obd_export *exp, struct lu_fid *fid, struct ldlm_res_id res_id; struct ldlm_resource *res; int count; - ENTRY; /* Return, i.e. cancel nothing, only if ELC is supported (flag in * export) but disabled through procfs (flag in NS). @@ -111,7 +110,6 @@ int mdc_setattr(struct obd_export *exp, struct md_op_data *op_data, struct obd_device *obd = exp->exp_obd; int count = 0, rc; __u64 bits; - ENTRY; LASSERT(op_data != NULL); @@ -217,7 +215,6 @@ int mdc_create(struct obd_export *exp, struct md_op_data *op_data, struct obd_import *import = exp->exp_obd->u.cli.cl_import; int generation = import->imp_generation; LIST_HEAD(cancels); - ENTRY; /* For case if upper layer did not alloc fid, do it now. */ if (!fid_is_sane(&op_data->op_fid2)) { @@ -325,7 +322,6 @@ int mdc_unlink(struct obd_export *exp, struct md_op_data *op_data, struct obd_device *obd = class_exp2obd(exp); struct ptlrpc_request *req = *request; int count = 0, rc; - ENTRY; LASSERT(req == NULL); @@ -380,7 +376,6 @@ int mdc_link(struct obd_export *exp, struct md_op_data *op_data, struct obd_device *obd = exp->exp_obd; struct ptlrpc_request *req; int count = 0, rc; - ENTRY; if ((op_data->op_flags & MF_MDC_CANCEL_FID2) && (fid_is_sane(&op_data->op_fid2))) @@ -428,7 +423,6 @@ int mdc_rename(struct obd_export *exp, struct md_op_data *op_data, struct obd_device *obd = exp->exp_obd; struct ptlrpc_request *req; int count = 0, rc; - ENTRY; if ((op_data->op_flags & MF_MDC_CANCEL_FID1) && (fid_is_sane(&op_data->op_fid1))) diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index 2dabfc01d224d..f9e9184908ea3 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -65,7 +65,6 @@ int mdc_unpack_capa(struct obd_export *exp, struct ptlrpc_request *req, { struct lustre_capa *capa; struct obd_capa *c; - ENTRY; /* swabbed already in mdc_enqueue */ capa = req_capsule_server_get(&req->rq_pill, field); @@ -109,7 +108,6 @@ static int send_getstatus(struct obd_import *imp, struct lu_fid *rootfid, struct ptlrpc_request *req; struct mdt_body *body; int rc; - ENTRY; req = ptlrpc_request_alloc_pack(imp, &RQF_MDS_GETSTATUS, LUSTRE_MDS_VERSION, MDS_GETSTATUS); @@ -172,7 +170,6 @@ static int mdc_getattr_common(struct obd_export *exp, struct mdt_body *body; void *eadata; int rc; - ENTRY; /* Request message already built. */ rc = ptlrpc_queue_wait(req); @@ -220,7 +217,6 @@ int mdc_getattr(struct obd_export *exp, struct md_op_data *op_data, { struct ptlrpc_request *req; int rc; - ENTRY; /* Single MDS without an LMV case */ if (op_data->op_flags & MF_GET_MDT_IDX) { @@ -265,7 +261,6 @@ int mdc_getattr_name(struct obd_export *exp, struct md_op_data *op_data, { struct ptlrpc_request *req; int rc; - ENTRY; *request = NULL; req = ptlrpc_request_alloc(class_exp2cliimp(exp), @@ -314,8 +309,6 @@ static int mdc_is_subdir(struct obd_export *exp, struct ptlrpc_request *req; int rc; - ENTRY; - *request = NULL; req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_MDS_IS_SUBDIR, LUSTRE_MDS_VERSION, @@ -345,7 +338,6 @@ static int mdc_xattr_common(struct obd_export *exp,const struct req_format *fmt, int xattr_namelen = 0; char *tmp; int rc; - ENTRY; *request = NULL; req = ptlrpc_request_alloc(class_exp2cliimp(exp), fmt); @@ -453,7 +445,6 @@ static int mdc_unpack_acl(struct ptlrpc_request *req, struct lustre_md *md) struct posix_acl *acl; void *buf; int rc; - ENTRY; if (!body->aclsize) RETURN(0); @@ -490,7 +481,6 @@ int mdc_get_lustre_md(struct obd_export *exp, struct ptlrpc_request *req, { struct req_capsule *pill = &req->rq_pill; int rc; - ENTRY; LASSERT(md); memset(md, 0, sizeof(*md)); @@ -629,7 +619,6 @@ int mdc_get_lustre_md(struct obd_export *exp, struct ptlrpc_request *req, int mdc_free_lustre_md(struct obd_export *exp, struct lustre_md *md) { - ENTRY; RETURN(0); } @@ -644,7 +633,6 @@ void mdc_replay_open(struct ptlrpc_request *req) struct obd_client_handle *och; struct lustre_handle old; struct mdt_body *body; - ENTRY; if (mod == NULL) { DEBUG_REQ(D_ERROR, req, @@ -722,7 +710,6 @@ int mdc_set_open_replay_data(struct obd_export *exp, struct mdt_rec_create *rec; struct mdt_body *body; struct obd_import *imp = open_req->rq_import; - ENTRY; if (!open_req->rq_replay) RETURN(0); @@ -779,7 +766,6 @@ int mdc_clear_open_replay_data(struct obd_export *exp, struct obd_client_handle *och) { struct md_open_data *mod = och->och_mod; - ENTRY; /** * It is possible to not have \var mod in a case of eviction between @@ -819,7 +805,6 @@ int mdc_close(struct obd_export *exp, struct md_op_data *op_data, struct obd_device *obd = class_exp2obd(exp); struct ptlrpc_request *req; int rc; - ENTRY; *request = NULL; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_CLOSE); @@ -921,7 +906,6 @@ int mdc_done_writing(struct obd_export *exp, struct md_op_data *op_data, struct obd_device *obd = class_exp2obd(exp); struct ptlrpc_request *req; int rc; - ENTRY; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_DONE_WRITING); @@ -993,7 +977,6 @@ int mdc_readpage(struct obd_export *exp, struct md_op_data *op_data, int resends = 0; struct l_wait_info lwi; int rc; - ENTRY; *request = NULL; init_waitqueue_head(&waitq); @@ -1075,7 +1058,6 @@ static int mdc_statfs(const struct lu_env *env, struct obd_statfs *msfs; struct obd_import *imp = NULL; int rc; - ENTRY; /* * Since the request might also come from lprocfs, so we need @@ -1174,7 +1156,6 @@ static int mdc_ioc_hsm_progress(struct obd_export *exp, struct hsm_progress_kernel *req_hpk; struct ptlrpc_request *req; int rc; - ENTRY; req = ptlrpc_request_alloc_pack(imp, &RQF_MDS_HSM_PROGRESS, LUSTRE_MDS_VERSION, MDS_HSM_PROGRESS); @@ -1205,7 +1186,6 @@ static int mdc_ioc_hsm_ct_register(struct obd_import *imp, __u32 archives) __u32 *archive_mask; struct ptlrpc_request *req; int rc; - ENTRY; req = ptlrpc_request_alloc_pack(imp, &RQF_MDS_HSM_CT_REGISTER, LUSTRE_MDS_VERSION, @@ -1239,7 +1219,6 @@ static int mdc_ioc_hsm_current_action(struct obd_export *exp, struct hsm_current_action *req_hca; struct ptlrpc_request *req; int rc; - ENTRY; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_HSM_ACTION); @@ -1280,7 +1259,6 @@ static int mdc_ioc_hsm_ct_unregister(struct obd_import *imp) { struct ptlrpc_request *req; int rc; - ENTRY; req = ptlrpc_request_alloc_pack(imp, &RQF_MDS_HSM_CT_UNREGISTER, LUSTRE_MDS_VERSION, @@ -1306,7 +1284,6 @@ static int mdc_ioc_hsm_state_get(struct obd_export *exp, struct hsm_user_state *req_hus; struct ptlrpc_request *req; int rc; - ENTRY; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_HSM_STATE_GET); @@ -1349,7 +1326,6 @@ static int mdc_ioc_hsm_state_set(struct obd_export *exp, struct hsm_state_set *req_hss; struct ptlrpc_request *req; int rc; - ENTRY; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_HSM_STATE_SET); @@ -1393,7 +1369,6 @@ static int mdc_ioc_hsm_request(struct obd_export *exp, struct hsm_user_item *req_hui; char *req_opaque; int rc; - ENTRY; req = ptlrpc_request_alloc(imp, &RQF_MDS_HSM_REQUEST); if (req == NULL) @@ -1473,7 +1448,6 @@ static int changelog_kkuc_cb(const struct lu_env *env, struct llog_handle *llh, struct llog_changelog_rec *rec = (struct llog_changelog_rec *)hdr; struct kuc_hdr *lh; int len, rc; - ENTRY; if (rec->cr_hdr.lrh_type != CHANGELOG_REC) { rc = -EINVAL; @@ -1605,7 +1579,6 @@ static int mdc_quotacheck(struct obd_device *unused, struct obd_export *exp, struct ptlrpc_request *req; struct obd_quotactl *body; int rc; - ENTRY; req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_MDS_QUOTACHECK, LUSTRE_MDS_VERSION, @@ -1633,7 +1606,6 @@ static int mdc_quota_poll_check(struct obd_export *exp, { struct client_obd *cli = &exp->exp_obd->u.cli; int rc; - ENTRY; qchk->obd_uuid = cli->cl_target_uuid; memcpy(qchk->obd_type, LUSTRE_MDS_NAME, strlen(LUSTRE_MDS_NAME)); @@ -1651,7 +1623,6 @@ static int mdc_quotactl(struct obd_device *unused, struct obd_export *exp, struct ptlrpc_request *req; struct obd_quotactl *oqc; int rc; - ENTRY; req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_MDS_QUOTACTL, LUSTRE_MDS_VERSION, @@ -1689,7 +1660,6 @@ static int mdc_ioc_swap_layouts(struct obd_export *exp, struct ptlrpc_request *req; int rc, count; struct mdc_swap_layouts *msl, *payload; - ENTRY; msl = op_data->op_data; @@ -1747,7 +1717,6 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, struct obd_import *imp = obd->u.cli.cl_import; struct llog_ctxt *ctxt; int rc; - ENTRY; if (!try_module_get(THIS_MODULE)) { CERROR("Can't get module. Is it alive?"); @@ -1897,7 +1866,6 @@ int mdc_get_info_rpc(struct obd_export *exp, struct ptlrpc_request *req; char *tmp; int rc = -EINVAL; - ENTRY; req = ptlrpc_request_alloc(imp, &RQF_MDS_GET_INFO); if (req == NULL) @@ -2010,7 +1978,6 @@ static int mdc_hsm_copytool_send(int len, void *val) struct kuc_hdr *lh = (struct kuc_hdr *)val; struct hsm_action_list *hal = (struct hsm_action_list *)(lh + 1); int rc; - ENTRY; if (len < sizeof(*lh) + sizeof(*hal)) { CERROR("Short HSM message %d < %d\n", len, @@ -2075,7 +2042,6 @@ int mdc_set_info_async(const struct lu_env *env, { struct obd_import *imp = class_exp2cliimp(exp); int rc; - ENTRY; if (KEY_IS(KEY_READ_ONLY)) { if (vallen != sizeof(int)) @@ -2171,7 +2137,6 @@ static int mdc_pin(struct obd_export *exp, const struct lu_fid *fid, struct ptlrpc_request *req; struct mdt_body *body; int rc; - ENTRY; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_PIN); if (req == NULL) @@ -2224,7 +2189,6 @@ static int mdc_unpin(struct obd_export *exp, struct obd_client_handle *handle, struct ptlrpc_request *req; struct mdt_body *body; int rc; - ENTRY; req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_MDS_UNPIN, LUSTRE_MDS_VERSION, MDS_UNPIN); @@ -2256,7 +2220,6 @@ int mdc_sync(struct obd_export *exp, const struct lu_fid *fid, { struct ptlrpc_request *req; int rc; - ENTRY; *request = NULL; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_SYNC); @@ -2341,7 +2304,7 @@ int mdc_fid_alloc(struct obd_export *exp, struct lu_fid *fid, { struct client_obd *cli = &exp->exp_obd->u.cli; struct lu_client_seq *seq = cli->cl_seq; - ENTRY; + RETURN(seq_client_alloc_fid(NULL, seq, fid)); } @@ -2386,7 +2349,6 @@ static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg) struct client_obd *cli = &obd->u.cli; struct lprocfs_static_vars lvars = { 0 }; int rc; - ENTRY; OBD_ALLOC(cli->cl_rpc_lock, sizeof (*cli->cl_rpc_lock)); if (!cli->cl_rpc_lock) @@ -2437,7 +2399,6 @@ static int mdc_init_ea_size(struct obd_export *exp, int easize, { struct obd_device *obd = exp->exp_obd; struct client_obd *cli = &obd->u.cli; - ENTRY; if (cli->cl_max_mds_easize < easize) cli->cl_max_mds_easize = easize; @@ -2454,7 +2415,6 @@ static int mdc_init_ea_size(struct obd_export *exp, int easize, static int mdc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) { int rc = 0; - ENTRY; switch (stage) { case OBD_CLEANUP_EARLY: @@ -2495,8 +2455,6 @@ static int mdc_llog_init(struct obd_device *obd, struct obd_llog_group *olg, struct llog_ctxt *ctxt; int rc; - ENTRY; - LASSERT(olg == &obd->obd_olg); rc = llog_setup(NULL, obd, olg, LLOG_CHANGELOG_REPL_CTXT, tgt, @@ -2515,8 +2473,6 @@ static int mdc_llog_finish(struct obd_device *obd, int count) { struct llog_ctxt *ctxt; - ENTRY; - ctxt = llog_get_context(obd, LLOG_CHANGELOG_REPL_CTXT); if (ctxt) llog_cleanup(NULL, ctxt); @@ -2550,7 +2506,6 @@ int mdc_get_remote_perm(struct obd_export *exp, const struct lu_fid *fid, { struct ptlrpc_request *req; int rc; - ENTRY; LASSERT(client_is_remote(exp)); @@ -2589,7 +2544,6 @@ static int mdc_interpret_renew_capa(const struct lu_env *env, struct mdc_renew_capa_args *ra = args; struct mdt_body *body = NULL; struct lustre_capa *capa; - ENTRY; if (status) GOTO(out, capa = ERR_PTR(status)); @@ -2615,7 +2569,6 @@ static int mdc_renew_capa(struct obd_export *exp, struct obd_capa *oc, { struct ptlrpc_request *req; struct mdc_renew_capa_args *ra; - ENTRY; req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_MDS_GETATTR, LUSTRE_MDS_VERSION, MDS_GETATTR); diff --git a/drivers/staging/lustre/lustre/mgc/libmgc.c b/drivers/staging/lustre/lustre/mgc/libmgc.c index 442146cc7e608..412f5882225dd 100644 --- a/drivers/staging/lustre/lustre/mgc/libmgc.c +++ b/drivers/staging/lustre/lustre/mgc/libmgc.c @@ -56,7 +56,6 @@ static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) { int rc; - ENTRY; ptlrpcd_addref(); @@ -85,7 +84,6 @@ static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) static int mgc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) { int rc = 0; - ENTRY; switch (stage) { case OBD_CLEANUP_EARLY: @@ -103,7 +101,6 @@ static int mgc_cleanup(struct obd_device *obd) { struct client_obd *cli = &obd->u.cli; int rc; - ENTRY; LASSERT(cli->cl_mgc_vfsmnt == NULL); @@ -118,7 +115,6 @@ static int mgc_llog_init(struct obd_device *obd, struct obd_llog_group *olg, { struct llog_ctxt *ctxt; int rc; - ENTRY; LASSERT(olg == &obd->obd_olg); rc = llog_setup(NULL, obd, olg, LLOG_CONFIG_REPL_CTXT, tgt, @@ -137,7 +133,6 @@ static int mgc_llog_finish(struct obd_device *obd, int count) { struct llog_ctxt *ctxt; - ENTRY; ctxt = llog_get_context(obd, LLOG_CONFIG_REPL_CTXT); if (ctxt) diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c index 51677678fc754..069681507129f 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c @@ -118,7 +118,6 @@ static DEFINE_SPINLOCK(config_list_lock); /* Take a reference to a config log */ static int config_log_get(struct config_llog_data *cld) { - ENTRY; atomic_inc(&cld->cld_refcount); CDEBUG(D_INFO, "log %s refs %d\n", cld->cld_logname, atomic_read(&cld->cld_refcount)); @@ -129,8 +128,6 @@ static int config_log_get(struct config_llog_data *cld) we can free the config log data */ static void config_log_put(struct config_llog_data *cld) { - ENTRY; - CDEBUG(D_INFO, "log %s refs %d\n", cld->cld_logname, atomic_read(&cld->cld_refcount)); LASSERT(atomic_read(&cld->cld_refcount) > 0); @@ -164,7 +161,6 @@ struct config_llog_data *config_log_find(char *logname, struct config_llog_data *cld; struct config_llog_data *found = NULL; void * instance; - ENTRY; LASSERT(logname != NULL); @@ -198,7 +194,6 @@ struct config_llog_data *do_config_log_add(struct obd_device *obd, { struct config_llog_data *cld; int rc; - ENTRY; CDEBUG(D_MGC, "do adding config log %s:%p\n", logname, cfg ? cfg->cfg_instance : 0); @@ -296,7 +291,6 @@ static int config_log_add(struct obd_device *obd, char *logname, struct config_llog_data *sptlrpc_cld; char seclogname[32]; char *ptr; - ENTRY; CDEBUG(D_MGC, "adding config log %s:%p\n", logname, cfg->cfg_instance); @@ -357,7 +351,6 @@ static int config_log_end(char *logname, struct config_llog_instance *cfg) struct config_llog_data *cld_sptlrpc = NULL; struct config_llog_data *cld_recover = NULL; int rc = 0; - ENTRY; cld = config_log_find(logname, cfg); if (cld == NULL) @@ -415,7 +408,6 @@ int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data) struct obd_import *imp = obd->u.cli.cl_import; struct obd_connect_data *ocd = &imp->imp_connect_data; struct config_llog_data *cld; - ENTRY; seq_printf(m, "imperative_recovery: %s\n", OCD_HAS_FLAG(ocd, IMP_RECOV) ? "ENABLED" : "DISABLED"); @@ -445,7 +437,6 @@ static DECLARE_COMPLETION(rq_exit); static void do_requeue(struct config_llog_data *cld) { - ENTRY; LASSERT(atomic_read(&cld->cld_refcount) > 0); /* Do not run mgc_process_log on a disconnected export or an @@ -474,7 +465,6 @@ static void do_requeue(struct config_llog_data *cld) static int mgc_requeue_thread(void *data) { int rc = 0; - ENTRY; CDEBUG(D_MGC, "Starting requeue thread\n"); @@ -563,8 +553,6 @@ static int mgc_requeue_thread(void *data) We are responsible for dropping the config log reference from here on out. */ static void mgc_requeue_add(struct config_llog_data *cld) { - ENTRY; - CDEBUG(D_INFO, "log %s: requeue (r=%d sp=%d st=%x)\n", cld->cld_logname, atomic_read(&cld->cld_refcount), cld->cld_stopping, rq_state); @@ -605,7 +593,6 @@ static int mgc_fs_setup(struct obd_device *obd, struct super_block *sb, struct dentry *dentry; char *label; int err = 0; - ENTRY; LASSERT(lsi); LASSERT(lsi->lsi_srv_mnt == mnt); @@ -668,7 +655,6 @@ static int mgc_fs_cleanup(struct obd_device *obd) { struct client_obd *cli = &obd->u.cli; int rc = 0; - ENTRY; LASSERT(cli->cl_mgc_vfsmnt != NULL); @@ -694,7 +680,6 @@ static atomic_t mgc_count = ATOMIC_INIT(0); static int mgc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) { int rc = 0; - ENTRY; switch (stage) { case OBD_CLEANUP_EARLY: @@ -726,7 +711,6 @@ static int mgc_cleanup(struct obd_device *obd) { struct client_obd *cli = &obd->u.cli; int rc; - ENTRY; LASSERT(cli->cl_mgc_vfsmnt == NULL); @@ -747,7 +731,6 @@ static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) { struct lprocfs_static_vars lvars; int rc; - ENTRY; ptlrpcd_addref(); @@ -798,7 +781,6 @@ static int mgc_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, struct lustre_handle lockh; struct config_llog_data *cld = (struct config_llog_data *)data; int rc = 0; - ENTRY; switch (flag) { case LDLM_CB_BLOCKING: @@ -862,7 +844,6 @@ static int mgc_set_mgs_param(struct obd_export *exp, struct ptlrpc_request *req; struct mgs_send_param *req_msp, *rep_msp; int rc; - ENTRY; req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_MGS_SET_INFO, LUSTRE_MGS_VERSION, @@ -909,7 +890,6 @@ static int mgc_enqueue(struct obd_export *exp, struct lov_stripe_md *lsm, struct ptlrpc_request *req; int short_limit = cld_is_sptlrpc(cld); int rc; - ENTRY; CDEBUG(D_MGC, "Enqueue for %s (res "LPX64")\n", cld->cld_logname, cld->cld_resid.name[0]); @@ -944,8 +924,6 @@ static int mgc_enqueue(struct obd_export *exp, struct lov_stripe_md *lsm, static int mgc_cancel(struct obd_export *exp, struct lov_stripe_md *md, __u32 mode, struct lustre_handle *lockh) { - ENTRY; - ldlm_lock_decref(lockh, mode); RETURN(0); @@ -969,7 +947,6 @@ static int mgc_target_register(struct obd_export *exp, struct ptlrpc_request *req; struct mgs_target_info *req_mti, *rep_mti; int rc; - ENTRY; req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_MGS_TARGET_REG, LUSTRE_MGS_VERSION, @@ -1007,7 +984,6 @@ int mgc_set_info_async(const struct lu_env *env, struct obd_export *exp, void *val, struct ptlrpc_request_set *set) { int rc = -EINVAL; - ENTRY; /* Turn off initial_recov after we try all backup servers once */ if (KEY_IS(KEY_INIT_RECOV_BACKUP)) { @@ -1179,7 +1155,6 @@ static int mgc_llog_init(struct obd_device *obd, struct obd_llog_group *olg, { struct llog_ctxt *ctxt; int rc; - ENTRY; LASSERT(olg == &obd->obd_olg); @@ -1208,8 +1183,6 @@ static int mgc_llog_finish(struct obd_device *obd, int count) { struct llog_ctxt *ctxt; - ENTRY; - ctxt = llog_get_context(obd, LLOG_CONFIG_REPL_CTXT); if (ctxt) llog_cleanup(NULL, ctxt); @@ -1242,7 +1215,6 @@ static int mgc_apply_recover_logs(struct obd_device *mgc, int pos; int rc = 0; int off = 0; - ENTRY; LASSERT(cfg->cfg_instance != NULL); LASSERT(cfg->cfg_sb == cfg->cfg_instance); @@ -1443,7 +1415,6 @@ static int mgc_process_recover_log(struct obd_device *obd, int i; int ealen; int rc; - ENTRY; /* allocate buffer for bulk transfer. * if this is the first time for this mgs to read logs, @@ -1586,8 +1557,6 @@ static int mgc_process_cfg_log(struct obd_device *mgc, int rc = 0, must_pop = 0; bool sptlrpc_started = false; - ENTRY; - LASSERT(cld); LASSERT(mutex_is_locked(&cld->cld_lock)); @@ -1663,7 +1632,6 @@ int mgc_process_log(struct obd_device *mgc, struct config_llog_data *cld) struct lustre_handle lockh = { 0 }; __u64 flags = LDLM_FL_NO_LRU; int rc = 0, rcl; - ENTRY; LASSERT(cld); @@ -1737,7 +1705,6 @@ static int mgc_process_config(struct obd_device *obd, obd_count len, void *buf) struct config_llog_instance *cfg = NULL; char *logname; int rc = 0; - ENTRY; switch(lcfg->lcfg_command) { case LCFG_LOV_ADD_OBD: { diff --git a/drivers/staging/lustre/lustre/obdclass/acl.c b/drivers/staging/lustre/lustre/obdclass/acl.c index c2a6702c9f2c6..66fdd661cafce 100644 --- a/drivers/staging/lustre/lustre/obdclass/acl.c +++ b/drivers/staging/lustre/lustre/obdclass/acl.c @@ -144,7 +144,6 @@ lustre_posix_acl_xattr_2ext(posix_acl_xattr_header *header, int size) { int count, i, esize; ext_acl_xattr_header *new; - ENTRY; if (unlikely(size < 0)) RETURN(ERR_PTR(-EINVAL)); @@ -178,7 +177,6 @@ int lustre_posix_acl_xattr_filter(posix_acl_xattr_header *header, int size, int count, i, j, rc = 0; __u32 id; posix_acl_xattr_header *new; - ENTRY; if (unlikely(size < 0)) RETURN(-EINVAL); @@ -302,7 +300,6 @@ int lustre_acl_xattr_merge2posix(posix_acl_xattr_header *posix_header, int size, posix_acl_xattr_entry pe = {ACL_MASK, 0, ACL_UNDEFINED_ID}; posix_acl_xattr_header *new; ext_acl_xattr_entry *ee, ae; - ENTRY; lustre_posix_acl_cpu_to_le(&pe, &pe); ee = lustre_ext_acl_xattr_search(ext_header, &pe, &pos); @@ -420,7 +417,6 @@ lustre_acl_xattr_merge2ext(posix_acl_xattr_header *posix_header, int size, posix_acl_xattr_entry pae; ext_acl_xattr_header *new; ext_acl_xattr_entry *ee, eae; - ENTRY; if (unlikely(size < 0)) RETURN(ERR_PTR(-EINVAL)); diff --git a/drivers/staging/lustre/lustre/obdclass/capa.c b/drivers/staging/lustre/lustre/obdclass/capa.c index 5eea9bec054a0..60eb94d48ea8c 100644 --- a/drivers/staging/lustre/lustre/obdclass/capa.c +++ b/drivers/staging/lustre/lustre/obdclass/capa.c @@ -276,7 +276,6 @@ int capa_encrypt_id(__u32 *d, __u32 *s, __u8 *key, int keylen) unsigned int min; int rc; char alg[CRYPTO_MAX_ALG_NAME+1] = "aes"; - ENTRY; /* passing "aes" in a variable instead of a constant string keeps gcc * 4.3.2 happy */ @@ -329,7 +328,6 @@ int capa_decrypt_id(__u32 *d, __u32 *s, __u8 *key, int keylen) unsigned int min; int rc; char alg[CRYPTO_MAX_ALG_NAME+1] = "aes"; - ENTRY; /* passing "aes" in a variable instead of a constant string keeps gcc * 4.3.2 happy */ diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c index f3f03154f094e..96a299b4fb91e 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_io.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c @@ -106,7 +106,6 @@ void cl_io_fini(const struct lu_env *env, struct cl_io *io) LINVRNT(cl_io_type_is_valid(io->ci_type)); LINVRNT(cl_io_invariant(io)); - ENTRY; while (!list_empty(&io->ci_layers)) { slice = container_of(io->ci_layers.prev, struct cl_io_slice, @@ -157,7 +156,6 @@ static int cl_io_init0(const struct lu_env *env, struct cl_io *io, LINVRNT(io->ci_state == CIS_ZERO || io->ci_state == CIS_FINI); LINVRNT(cl_io_type_is_valid(iot)); LINVRNT(cl_io_invariant(io)); - ENTRY; io->ci_type = iot; INIT_LIST_HEAD(&io->ci_lockset.cls_todo); @@ -228,7 +226,6 @@ int cl_io_rw_init(const struct lu_env *env, struct cl_io *io, { LINVRNT(iot == CIT_READ || iot == CIT_WRITE); LINVRNT(io->ci_obj != NULL); - ENTRY; LU_OBJECT_HEADER(D_VFSTRACE, env, &io->ci_obj->co_lu, "io range: %u ["LPU64", "LPU64") %u %u\n", @@ -288,7 +285,6 @@ static void cl_io_locks_sort(struct cl_io *io) { int done = 0; - ENTRY; /* hidden treasure: bubble sort for now. */ do { struct cl_io_lock_link *curr; @@ -339,7 +335,6 @@ int cl_queue_match(const struct list_head *queue, { struct cl_io_lock_link *scan; - ENTRY; list_for_each_entry(scan, queue, cill_linkage) { if (cl_lock_descr_match(&scan->cill_descr, need)) RETURN(+1); @@ -353,7 +348,6 @@ static int cl_queue_merge(const struct list_head *queue, { struct cl_io_lock_link *scan; - ENTRY; list_for_each_entry(scan, queue, cill_linkage) { if (cl_lock_descr_cmp(&scan->cill_descr, need)) continue; @@ -388,8 +382,6 @@ static int cl_lockset_lock_one(const struct lu_env *env, struct cl_lock *lock; int result; - ENTRY; - lock = cl_lock_request(env, io, &link->cill_descr, "io", io); if (!IS_ERR(lock)) { @@ -412,7 +404,6 @@ static void cl_lock_link_fini(const struct lu_env *env, struct cl_io *io, { struct cl_lock *lock = link->cill_lock; - ENTRY; list_del_init(&link->cill_linkage); if (lock != NULL) { cl_lock_release(env, lock, "io", io); @@ -431,7 +422,6 @@ static int cl_lockset_lock(const struct lu_env *env, struct cl_io *io, struct cl_lock *lock; int result; - ENTRY; result = 0; list_for_each_entry_safe(link, temp, &set->cls_todo, cill_linkage) { if (!cl_lockset_match(set, &link->cill_descr)) { @@ -474,7 +464,6 @@ int cl_io_lock(const struct lu_env *env, struct cl_io *io) LINVRNT(io->ci_state == CIS_IT_STARTED); LINVRNT(cl_io_invariant(io)); - ENTRY; cl_io_for_each(scan, io) { if (scan->cis_iop->op[io->ci_type].cio_lock == NULL) continue; @@ -508,7 +497,6 @@ void cl_io_unlock(const struct lu_env *env, struct cl_io *io) LASSERT(CIS_IT_STARTED <= io->ci_state && io->ci_state < CIS_UNLOCKED); LINVRNT(cl_io_invariant(io)); - ENTRY; set = &io->ci_lockset; list_for_each_entry_safe(link, temp, &set->cls_todo, cill_linkage) @@ -547,7 +535,6 @@ int cl_io_iter_init(const struct lu_env *env, struct cl_io *io) LINVRNT(io->ci_state == CIS_INIT || io->ci_state == CIS_IT_ENDED); LINVRNT(cl_io_invariant(io)); - ENTRY; result = 0; cl_io_for_each(scan, io) { if (scan->cis_iop->op[io->ci_type].cio_iter_init == NULL) @@ -576,7 +563,6 @@ void cl_io_iter_fini(const struct lu_env *env, struct cl_io *io) LINVRNT(io->ci_state == CIS_UNLOCKED); LINVRNT(cl_io_invariant(io)); - ENTRY; cl_io_for_each_reverse(scan, io) { if (scan->cis_iop->op[io->ci_type].cio_iter_fini != NULL) scan->cis_iop->op[io->ci_type].cio_iter_fini(env, scan); @@ -598,8 +584,6 @@ void cl_io_rw_advance(const struct lu_env *env, struct cl_io *io, size_t nob) LINVRNT(cl_io_is_loopable(io)); LINVRNT(cl_io_invariant(io)); - ENTRY; - io->u.ci_rw.crw_pos += nob; io->u.ci_rw.crw_count -= nob; @@ -621,7 +605,6 @@ int cl_io_lock_add(const struct lu_env *env, struct cl_io *io, { int result; - ENTRY; if (cl_lockset_merge(&io->ci_lockset, &link->cill_descr)) result = +1; else { @@ -647,7 +630,6 @@ int cl_io_lock_alloc_add(const struct lu_env *env, struct cl_io *io, struct cl_io_lock_link *link; int result; - ENTRY; OBD_ALLOC_PTR(link); if (link != NULL) { link->cill_descr = *descr; @@ -673,7 +655,6 @@ int cl_io_start(const struct lu_env *env, struct cl_io *io) LINVRNT(cl_io_is_loopable(io)); LINVRNT(io->ci_state == CIS_LOCKED); LINVRNT(cl_io_invariant(io)); - ENTRY; io->ci_state = CIS_IO_GOING; cl_io_for_each(scan, io) { @@ -700,7 +681,6 @@ void cl_io_end(const struct lu_env *env, struct cl_io *io) LINVRNT(cl_io_is_loopable(io)); LINVRNT(io->ci_state == CIS_IO_GOING); LINVRNT(cl_io_invariant(io)); - ENTRY; cl_io_for_each_reverse(scan, io) { if (scan->cis_iop->op[io->ci_type].cio_end != NULL) @@ -774,7 +754,6 @@ int cl_io_read_page(const struct lu_env *env, struct cl_io *io, LINVRNT(io->ci_state == CIS_IO_GOING || io->ci_state == CIS_LOCKED); LINVRNT(cl_page_in_io(page, io)); LINVRNT(cl_io_invariant(io)); - ENTRY; queue = &io->ci_queue; @@ -827,7 +806,6 @@ int cl_io_prepare_write(const struct lu_env *env, struct cl_io *io, LINVRNT(io->ci_state == CIS_IO_GOING || io->ci_state == CIS_LOCKED); LINVRNT(cl_io_invariant(io)); LASSERT(cl_page_in_io(page, io)); - ENTRY; cl_io_for_each_reverse(scan, io) { if (scan->cis_iop->cio_prepare_write != NULL) { @@ -867,7 +845,6 @@ int cl_io_commit_write(const struct lu_env *env, struct cl_io *io, */ LASSERT(cl_page_is_owned(page, io) || page->cp_parent != NULL); LASSERT(cl_page_in_io(page, io)); - ENTRY; cl_io_for_each(scan, io) { if (scan->cis_iop->cio_commit_write != NULL) { @@ -903,7 +880,6 @@ int cl_io_submit_rw(const struct lu_env *env, struct cl_io *io, int result = 0; LINVRNT(crt < ARRAY_SIZE(scan->cis_iop->req_op)); - ENTRY; cl_io_for_each(scan, io) { if (scan->cis_iop->req_op[crt].cio_submit == NULL) @@ -1009,7 +985,6 @@ int cl_io_loop(const struct lu_env *env, struct cl_io *io) int result = 0; LINVRNT(cl_io_is_loopable(io)); - ENTRY; do { size_t nob; @@ -1064,7 +1039,6 @@ void cl_io_slice_add(struct cl_io *io, struct cl_io_slice *slice, LASSERT((linkage->prev == NULL && linkage->next == NULL) || list_empty(linkage)); - ENTRY; list_add_tail(linkage, &io->ci_layers); slice->cis_io = io; @@ -1080,7 +1054,6 @@ EXPORT_SYMBOL(cl_io_slice_add); */ void cl_page_list_init(struct cl_page_list *plist) { - ENTRY; plist->pl_nr = 0; INIT_LIST_HEAD(&plist->pl_pages); plist->pl_owner = current; @@ -1093,7 +1066,6 @@ EXPORT_SYMBOL(cl_page_list_init); */ void cl_page_list_add(struct cl_page_list *plist, struct cl_page *page) { - ENTRY; /* it would be better to check that page is owned by "current" io, but * it is not passed here. */ LASSERT(page->cp_owner != NULL); @@ -1120,7 +1092,6 @@ void cl_page_list_del(const struct lu_env *env, LASSERT(plist->pl_nr > 0); LINVRNT(plist->pl_owner == current); - ENTRY; list_del_init(&page->cp_batch); lockdep_off(); mutex_unlock(&page->cp_mutex); @@ -1142,7 +1113,6 @@ void cl_page_list_move(struct cl_page_list *dst, struct cl_page_list *src, LINVRNT(dst->pl_owner == current); LINVRNT(src->pl_owner == current); - ENTRY; list_move_tail(&page->cp_batch, &dst->pl_pages); --src->pl_nr; ++dst->pl_nr; @@ -1163,7 +1133,6 @@ void cl_page_list_splice(struct cl_page_list *list, struct cl_page_list *head) LINVRNT(list->pl_owner == current); LINVRNT(head->pl_owner == current); - ENTRY; cl_page_list_for_each_safe(page, tmp, list) cl_page_list_move(head, list, page); EXIT; @@ -1184,7 +1153,6 @@ void cl_page_list_disown(const struct lu_env *env, LINVRNT(plist->pl_owner == current); - ENTRY; cl_page_list_for_each_safe(page, temp, plist) { LASSERT(plist->pl_nr > 0); @@ -1220,7 +1188,6 @@ void cl_page_list_fini(const struct lu_env *env, struct cl_page_list *plist) LINVRNT(plist->pl_owner == current); - ENTRY; cl_page_list_for_each_safe(page, temp, plist) cl_page_list_del(env, plist, page); LASSERT(plist->pl_nr == 0); @@ -1241,7 +1208,6 @@ int cl_page_list_own(const struct lu_env *env, LINVRNT(plist->pl_owner == current); - ENTRY; result = 0; cl_page_list_for_each_safe(page, temp, plist) { LASSERT(index <= page->cp_index); @@ -1279,7 +1245,6 @@ void cl_page_list_discard(const struct lu_env *env, struct cl_io *io, struct cl_page *page; LINVRNT(plist->pl_owner == current); - ENTRY; cl_page_list_for_each(page, plist) cl_page_discard(env, io, page); EXIT; @@ -1296,7 +1261,6 @@ int cl_page_list_unmap(const struct lu_env *env, struct cl_io *io, int result; LINVRNT(plist->pl_owner == current); - ENTRY; result = 0; cl_page_list_for_each(page, plist) { result = cl_page_unmap(env, io, page); @@ -1312,7 +1276,6 @@ EXPORT_SYMBOL(cl_page_list_unmap); */ void cl_2queue_init(struct cl_2queue *queue) { - ENTRY; cl_page_list_init(&queue->c2_qin); cl_page_list_init(&queue->c2_qout); EXIT; @@ -1324,7 +1287,6 @@ EXPORT_SYMBOL(cl_2queue_init); */ void cl_2queue_add(struct cl_2queue *queue, struct cl_page *page) { - ENTRY; cl_page_list_add(&queue->c2_qin, page); EXIT; } @@ -1336,7 +1298,6 @@ EXPORT_SYMBOL(cl_2queue_add); void cl_2queue_disown(const struct lu_env *env, struct cl_io *io, struct cl_2queue *queue) { - ENTRY; cl_page_list_disown(env, io, &queue->c2_qin); cl_page_list_disown(env, io, &queue->c2_qout); EXIT; @@ -1349,7 +1310,6 @@ EXPORT_SYMBOL(cl_2queue_disown); void cl_2queue_discard(const struct lu_env *env, struct cl_io *io, struct cl_2queue *queue) { - ENTRY; cl_page_list_discard(env, io, &queue->c2_qin); cl_page_list_discard(env, io, &queue->c2_qout); EXIT; @@ -1372,7 +1332,6 @@ EXPORT_SYMBOL(cl_2queue_assume); */ void cl_2queue_fini(const struct lu_env *env, struct cl_2queue *queue) { - ENTRY; cl_page_list_fini(env, &queue->c2_qout); cl_page_list_fini(env, &queue->c2_qin); EXIT; @@ -1384,7 +1343,6 @@ EXPORT_SYMBOL(cl_2queue_fini); */ void cl_2queue_init_page(struct cl_2queue *queue, struct cl_page *page) { - ENTRY; cl_2queue_init(queue); cl_2queue_add(queue, page); EXIT; @@ -1398,7 +1356,6 @@ EXPORT_SYMBOL(cl_2queue_init_page); */ struct cl_io *cl_io_top(struct cl_io *io) { - ENTRY; while (io->ci_parent != NULL) io = io->ci_parent; RETURN(io); @@ -1426,7 +1383,6 @@ void cl_req_slice_add(struct cl_req *req, struct cl_req_slice *slice, struct cl_device *dev, const struct cl_req_operations *ops) { - ENTRY; list_add_tail(&slice->crs_linkage, &req->crq_layers); slice->crs_dev = dev; slice->crs_ops = ops; @@ -1443,7 +1399,6 @@ static void cl_req_free(const struct lu_env *env, struct cl_req *req) LASSERT(req->crq_nrpages == 0); LINVRNT(list_empty(&req->crq_layers)); LINVRNT(equi(req->crq_nrobjs > 0, req->crq_o != NULL)); - ENTRY; if (req->crq_o != NULL) { for (i = 0; i < req->crq_nrobjs; ++i) { @@ -1468,7 +1423,6 @@ static int cl_req_init(const struct lu_env *env, struct cl_req *req, struct cl_page_slice *slice; int result; - ENTRY; result = 0; page = cl_page_top(page); do { @@ -1494,7 +1448,6 @@ void cl_req_completion(const struct lu_env *env, struct cl_req *req, int rc) { struct cl_req_slice *slice; - ENTRY; /* * for the lack of list_for_each_entry_reverse_safe()... */ @@ -1519,7 +1472,6 @@ struct cl_req *cl_req_alloc(const struct lu_env *env, struct cl_page *page, struct cl_req *req; LINVRNT(nr_objects > 0); - ENTRY; OBD_ALLOC_PTR(req); if (req != NULL) { @@ -1554,7 +1506,6 @@ void cl_req_page_add(const struct lu_env *env, struct cl_req_obj *rqo; int i; - ENTRY; page = cl_page_top(page); LASSERT(list_empty(&page->cp_flight)); @@ -1588,7 +1539,6 @@ void cl_req_page_done(const struct lu_env *env, struct cl_page *page) { struct cl_req *req = page->cp_req; - ENTRY; page = cl_page_top(page); LASSERT(!list_empty(&page->cp_flight)); @@ -1611,7 +1561,6 @@ int cl_req_prep(const struct lu_env *env, struct cl_req *req) int result; const struct cl_req_slice *slice; - ENTRY; /* * Check that the caller of cl_req_alloc() didn't lie about the number * of objects. @@ -1644,7 +1593,6 @@ void cl_req_attr_set(const struct lu_env *env, struct cl_req *req, int i; LASSERT(!list_empty(&req->crq_pages)); - ENTRY; /* Take any page to use as a model. */ page = list_entry(req->crq_pages.next, struct cl_page, cp_flight); @@ -1676,7 +1624,6 @@ EXPORT_SYMBOL(cl_req_attr_set); */ void cl_sync_io_init(struct cl_sync_io *anchor, int nrpages) { - ENTRY; init_waitqueue_head(&anchor->csi_waitq); atomic_set(&anchor->csi_sync_nr, nrpages); atomic_set(&anchor->csi_barrier, nrpages > 0); @@ -1696,7 +1643,6 @@ int cl_sync_io_wait(const struct lu_env *env, struct cl_io *io, struct l_wait_info lwi = LWI_TIMEOUT_INTR(cfs_time_seconds(timeout), NULL, NULL, NULL); int rc; - ENTRY; LASSERT(timeout >= 0); @@ -1735,7 +1681,6 @@ EXPORT_SYMBOL(cl_sync_io_wait); */ void cl_sync_io_note(struct cl_sync_io *anchor, int ioret) { - ENTRY; if (anchor->csi_sync_rc == 0 && ioret < 0) anchor->csi_sync_rc = ioret; /* diff --git a/drivers/staging/lustre/lustre/obdclass/cl_lock.c b/drivers/staging/lustre/lustre/obdclass/cl_lock.c index 958c1e531cfba..adcf789541171 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_lock.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_lock.c @@ -191,7 +191,6 @@ void cl_lock_slice_add(struct cl_lock *lock, struct cl_lock_slice *slice, struct cl_object *obj, const struct cl_lock_operations *ops) { - ENTRY; slice->cls_lock = lock; list_add_tail(&slice->cls_linkage, &lock->cll_layers); slice->cls_obj = obj; @@ -254,7 +253,6 @@ static void cl_lock_free(const struct lu_env *env, struct cl_lock *lock) LINVRNT(!cl_lock_is_mutexed(lock)); - ENTRY; cl_lock_trace(D_DLMTRACE, env, "free lock", lock); might_sleep(); while (!list_empty(&lock->cll_layers)) { @@ -290,7 +288,6 @@ void cl_lock_put(const struct lu_env *env, struct cl_lock *lock) struct cl_object *obj; LINVRNT(cl_lock_invariant(env, lock)); - ENTRY; obj = lock->cll_descr.cld_obj; LINVRNT(obj != NULL); @@ -366,7 +363,6 @@ static struct cl_lock *cl_lock_alloc(const struct lu_env *env, struct cl_lock *lock; struct lu_object_header *head; - ENTRY; OBD_SLAB_ALLOC_PTR_GFP(lock, cl_lock_kmem, __GFP_IO); if (lock != NULL) { atomic_set(&lock->cll_ref, 1); @@ -468,7 +464,6 @@ static int cl_lock_fits_into(const struct lu_env *env, const struct cl_lock_slice *slice; LINVRNT(cl_lock_invariant_trusted(env, lock)); - ENTRY; list_for_each_entry(slice, &lock->cll_layers, cls_linkage) { if (slice->cls_ops->clo_fits_into != NULL && !slice->cls_ops->clo_fits_into(env, slice, need, io)) @@ -485,8 +480,6 @@ static struct cl_lock *cl_lock_lookup(const struct lu_env *env, struct cl_lock *lock; struct cl_object_header *head; - ENTRY; - head = cl_object_header(obj); LINVRNT(spin_is_locked(&head->coh_lock_guard)); CS_LOCK_INC(obj, lookup); @@ -528,8 +521,6 @@ static struct cl_lock *cl_lock_find(const struct lu_env *env, struct cl_object *obj; struct cl_lock *lock; - ENTRY; - obj = need->cld_obj; head = cl_object_header(obj); @@ -630,7 +621,6 @@ const struct cl_lock_slice *cl_lock_at(const struct cl_lock *lock, const struct cl_lock_slice *slice; LINVRNT(cl_lock_invariant_trusted(NULL, lock)); - ENTRY; list_for_each_entry(slice, &lock->cll_layers, cls_linkage) { if (slice->cls_obj->co_lu.lo_dev->ld_type == dtype) @@ -705,7 +695,6 @@ int cl_lock_mutex_try(const struct lu_env *env, struct cl_lock *lock) int result; LINVRNT(cl_lock_invariant_trusted(env, lock)); - ENTRY; result = 0; if (lock->cll_guarder == current) { @@ -784,7 +773,6 @@ static void cl_lock_cancel0(const struct lu_env *env, struct cl_lock *lock) { LINVRNT(cl_lock_is_mutexed(lock)); LINVRNT(cl_lock_invariant(env, lock)); - ENTRY; if (!(lock->cll_flags & CLF_CANCELLED)) { const struct cl_lock_slice *slice; @@ -806,7 +794,6 @@ static void cl_lock_delete0(const struct lu_env *env, struct cl_lock *lock) LINVRNT(cl_lock_is_mutexed(lock)); LINVRNT(cl_lock_invariant(env, lock)); - ENTRY; if (lock->cll_state < CLS_FREEING) { LASSERT(lock->cll_state != CLS_INTRANSIT); cl_lock_state_set(env, lock, CLS_FREEING); @@ -886,7 +873,6 @@ void cl_lock_hold_release(const struct lu_env *env, struct cl_lock *lock, LINVRNT(cl_lock_invariant(env, lock)); LASSERT(lock->cll_holds > 0); - ENTRY; cl_lock_trace(D_DLMTRACE, env, "hold release lock", lock); lu_ref_del(&lock->cll_holders, scope, source); cl_lock_hold_mod(env, lock, -1); @@ -939,7 +925,6 @@ int cl_lock_state_wait(const struct lu_env *env, struct cl_lock *lock) sigset_t blocked; int result; - ENTRY; LINVRNT(cl_lock_is_mutexed(lock)); LINVRNT(cl_lock_invariant(env, lock)); LASSERT(lock->cll_depth == 1); @@ -985,7 +970,6 @@ static void cl_lock_state_signal(const struct lu_env *env, struct cl_lock *lock, { const struct cl_lock_slice *slice; - ENTRY; LINVRNT(cl_lock_is_mutexed(lock)); LINVRNT(cl_lock_invariant(env, lock)); @@ -1005,7 +989,6 @@ static void cl_lock_state_signal(const struct lu_env *env, struct cl_lock *lock, */ void cl_lock_signal(const struct lu_env *env, struct cl_lock *lock) { - ENTRY; cl_lock_trace(D_DLMTRACE, env, "state signal lock", lock); cl_lock_state_signal(env, lock, lock->cll_state); EXIT; @@ -1025,7 +1008,6 @@ EXPORT_SYMBOL(cl_lock_signal); void cl_lock_state_set(const struct lu_env *env, struct cl_lock *lock, enum cl_lock_state state) { - ENTRY; LASSERT(lock->cll_state <= state || (lock->cll_state == CLS_CACHED && (state == CLS_HELD || /* lock found in cache */ @@ -1084,7 +1066,6 @@ int cl_use_try(const struct lu_env *env, struct cl_lock *lock, int atomic) int result; enum cl_lock_state state; - ENTRY; cl_lock_trace(D_DLMTRACE, env, "use lock", lock); LASSERT(lock->cll_state == CLS_CACHED); @@ -1144,7 +1125,6 @@ static int cl_enqueue_kick(const struct lu_env *env, int result; const struct cl_lock_slice *slice; - ENTRY; result = -ENOSYS; list_for_each_entry(slice, &lock->cll_layers, cls_linkage) { if (slice->cls_ops->clo_enqueue != NULL) { @@ -1176,7 +1156,6 @@ int cl_enqueue_try(const struct lu_env *env, struct cl_lock *lock, { int result; - ENTRY; cl_lock_trace(D_DLMTRACE, env, "enqueue lock", lock); do { LINVRNT(cl_lock_is_mutexed(lock)); @@ -1235,7 +1214,6 @@ int cl_lock_enqueue_wait(const struct lu_env *env, { struct cl_lock *conflict; int rc = 0; - ENTRY; LASSERT(cl_lock_is_mutexed(lock)); LASSERT(lock->cll_state == CLS_QUEUING); @@ -1274,8 +1252,6 @@ static int cl_enqueue_locked(const struct lu_env *env, struct cl_lock *lock, { int result; - ENTRY; - LINVRNT(cl_lock_is_mutexed(lock)); LINVRNT(cl_lock_invariant(env, lock)); LASSERT(lock->cll_holds > 0); @@ -1315,8 +1291,6 @@ int cl_enqueue(const struct lu_env *env, struct cl_lock *lock, { int result; - ENTRY; - cl_lock_lockdep_acquire(env, lock, enqflags); cl_lock_mutex_get(env, lock); result = cl_enqueue_locked(env, lock, io, enqflags); @@ -1346,7 +1320,6 @@ int cl_unuse_try(const struct lu_env *env, struct cl_lock *lock) int result; enum cl_lock_state state = CLS_NEW; - ENTRY; cl_lock_trace(D_DLMTRACE, env, "unuse lock", lock); if (lock->cll_users > 1) { @@ -1411,7 +1384,6 @@ EXPORT_SYMBOL(cl_unuse_try); static void cl_unuse_locked(const struct lu_env *env, struct cl_lock *lock) { int result; - ENTRY; result = cl_unuse_try(env, lock); if (result) @@ -1425,7 +1397,6 @@ static void cl_unuse_locked(const struct lu_env *env, struct cl_lock *lock) */ void cl_unuse(const struct lu_env *env, struct cl_lock *lock) { - ENTRY; cl_lock_mutex_get(env, lock); cl_unuse_locked(env, lock); cl_lock_mutex_put(env, lock); @@ -1449,7 +1420,6 @@ int cl_wait_try(const struct lu_env *env, struct cl_lock *lock) const struct cl_lock_slice *slice; int result; - ENTRY; cl_lock_trace(D_DLMTRACE, env, "wait lock try", lock); do { LINVRNT(cl_lock_is_mutexed(lock)); @@ -1506,7 +1476,6 @@ int cl_wait(const struct lu_env *env, struct cl_lock *lock) { int result; - ENTRY; cl_lock_mutex_get(env, lock); LINVRNT(cl_lock_invariant(env, lock)); @@ -1544,7 +1513,6 @@ unsigned long cl_lock_weigh(const struct lu_env *env, struct cl_lock *lock) unsigned long pound; unsigned long ounce; - ENTRY; LINVRNT(cl_lock_is_mutexed(lock)); LINVRNT(cl_lock_invariant(env, lock)); @@ -1579,7 +1547,6 @@ int cl_lock_modify(const struct lu_env *env, struct cl_lock *lock, struct cl_object_header *hdr = cl_object_header(obj); int result; - ENTRY; cl_lock_trace(D_DLMTRACE, env, "modify lock", lock); /* don't allow object to change */ LASSERT(obj == desc->cld_obj); @@ -1642,7 +1609,6 @@ int cl_lock_closure_build(const struct lu_env *env, struct cl_lock *lock, const struct cl_lock_slice *slice; int result; - ENTRY; LINVRNT(cl_lock_is_mutexed(closure->clc_origin)); LINVRNT(cl_lock_invariant(env, closure->clc_origin)); @@ -1674,7 +1640,7 @@ int cl_lock_enclosure(const struct lu_env *env, struct cl_lock *lock, struct cl_lock_closure *closure) { int result = 0; - ENTRY; + cl_lock_trace(D_DLMTRACE, env, "enclosure lock", lock); if (!cl_lock_mutex_try(env, lock)) { /* @@ -1766,7 +1732,6 @@ void cl_lock_delete(const struct lu_env *env, struct cl_lock *lock) LASSERT(ergo(cl_lock_nesting(lock) == CNL_TOP, cl_lock_nr_mutexed(env) == 1)); - ENTRY; cl_lock_trace(D_DLMTRACE, env, "delete lock", lock); if (lock->cll_holds == 0) cl_lock_delete0(env, lock); @@ -1791,7 +1756,6 @@ void cl_lock_error(const struct lu_env *env, struct cl_lock *lock, int error) LINVRNT(cl_lock_is_mutexed(lock)); LINVRNT(cl_lock_invariant(env, lock)); - ENTRY; if (lock->cll_error == 0 && error != 0) { cl_lock_trace(D_DLMTRACE, env, "set lock error", lock); lock->cll_error = error; @@ -1819,7 +1783,6 @@ void cl_lock_cancel(const struct lu_env *env, struct cl_lock *lock) LINVRNT(cl_lock_is_mutexed(lock)); LINVRNT(cl_lock_invariant(env, lock)); - ENTRY; cl_lock_trace(D_DLMTRACE, env, "cancel lock", lock); if (lock->cll_holds == 0) cl_lock_cancel0(env, lock); @@ -1843,8 +1806,6 @@ struct cl_lock *cl_lock_at_pgoff(const struct lu_env *env, struct cl_lock *lock; struct cl_lock_descr *need; - ENTRY; - head = cl_object_header(obj); need = &cl_env_info(env)->clt_descr; lock = NULL; @@ -1979,7 +1940,6 @@ int cl_lock_discard_pages(const struct lu_env *env, struct cl_lock *lock) int result; LINVRNT(cl_lock_invariant(env, lock)); - ENTRY; io->ci_obj = cl_object_top(descr->cld_obj); io->ci_ignore_layout = 1; @@ -2018,7 +1978,6 @@ void cl_locks_prune(const struct lu_env *env, struct cl_object *obj, int cancel) struct cl_object_header *head; struct cl_lock *lock; - ENTRY; head = cl_object_header(obj); /* * If locks are destroyed without cancellation, all pages must be @@ -2070,8 +2029,6 @@ static struct cl_lock *cl_lock_hold_mutex(const struct lu_env *env, { struct cl_lock *lock; - ENTRY; - while (1) { lock = cl_lock_find(env, io, need); if (IS_ERR(lock)) @@ -2103,8 +2060,6 @@ struct cl_lock *cl_lock_hold(const struct lu_env *env, const struct cl_io *io, { struct cl_lock *lock; - ENTRY; - lock = cl_lock_hold_mutex(env, io, need, scope, source); if (!IS_ERR(lock)) cl_lock_mutex_put(env, lock); @@ -2124,7 +2079,6 @@ struct cl_lock *cl_lock_request(const struct lu_env *env, struct cl_io *io, int rc; __u32 enqflags = need->cld_enq_flags; - ENTRY; do { lock = cl_lock_hold_mutex(env, io, need, scope, source); if (IS_ERR(lock)) @@ -2170,7 +2124,6 @@ void cl_lock_hold_add(const struct lu_env *env, struct cl_lock *lock, LINVRNT(cl_lock_invariant(env, lock)); LASSERT(lock->cll_state != CLS_FREEING); - ENTRY; cl_lock_hold_mod(env, lock, +1); cl_lock_get(lock); lu_ref_add(&lock->cll_holders, scope, source); @@ -2187,7 +2140,6 @@ void cl_lock_unhold(const struct lu_env *env, struct cl_lock *lock, const char *scope, const void *source) { LINVRNT(cl_lock_invariant(env, lock)); - ENTRY; cl_lock_hold_release(env, lock, scope, source); lu_ref_del(&lock->cll_reference, scope, source); cl_lock_put(env, lock); @@ -2202,7 +2154,6 @@ void cl_lock_release(const struct lu_env *env, struct cl_lock *lock, const char *scope, const void *source) { LINVRNT(cl_lock_invariant(env, lock)); - ENTRY; cl_lock_trace(D_DLMTRACE, env, "release lock", lock); cl_lock_mutex_get(env, lock); cl_lock_hold_release(env, lock, scope, source); @@ -2218,7 +2169,6 @@ void cl_lock_user_add(const struct lu_env *env, struct cl_lock *lock) LINVRNT(cl_lock_is_mutexed(lock)); LINVRNT(cl_lock_invariant(env, lock)); - ENTRY; cl_lock_used_mod(env, lock, +1); EXIT; } @@ -2230,7 +2180,6 @@ void cl_lock_user_del(const struct lu_env *env, struct cl_lock *lock) LINVRNT(cl_lock_invariant(env, lock)); LASSERT(lock->cll_users > 0); - ENTRY; cl_lock_used_mod(env, lock, -1); if (lock->cll_users == 0) wake_up_all(&lock->cll_wq); diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c index cdb5fba04591b..2abc4b5ddb370 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c @@ -79,7 +79,6 @@ int cl_object_header_init(struct cl_object_header *h) { int result; - ENTRY; result = lu_object_header_init(&h->coh_lu); if (result == 0) { spin_lock_init(&h->coh_page_guard); @@ -222,7 +221,6 @@ int cl_object_attr_get(const struct lu_env *env, struct cl_object *obj, int result; LASSERT(spin_is_locked(cl_object_attr_guard(obj))); - ENTRY; top = obj->co_lu.lo_header; result = 0; @@ -254,7 +252,6 @@ int cl_object_attr_set(const struct lu_env *env, struct cl_object *obj, int result; LASSERT(spin_is_locked(cl_object_attr_guard(obj))); - ENTRY; top = obj->co_lu.lo_header; result = 0; @@ -287,7 +284,6 @@ int cl_object_glimpse(const struct lu_env *env, struct cl_object *obj, struct lu_object_header *top; int result; - ENTRY; top = obj->co_lu.lo_header; result = 0; list_for_each_entry_reverse(obj, &top->loh_layers, @@ -316,7 +312,6 @@ int cl_conf_set(const struct lu_env *env, struct cl_object *obj, struct lu_object_header *top; int result; - ENTRY; top = obj->co_lu.lo_header; result = 0; list_for_each_entry(obj, &top->loh_layers, co_lu.lo_linkage) { @@ -362,7 +357,6 @@ EXPORT_SYMBOL(cl_object_kill); */ void cl_object_prune(const struct lu_env *env, struct cl_object *obj) { - ENTRY; cl_pages_prune(env, obj); cl_locks_prune(env, obj, 1); EXIT; @@ -941,7 +935,6 @@ EXPORT_SYMBOL(cl_env_nested_put); */ void cl_attr2lvb(struct ost_lvb *lvb, const struct cl_attr *attr) { - ENTRY; lvb->lvb_size = attr->cat_size; lvb->lvb_mtime = attr->cat_mtime; lvb->lvb_atime = attr->cat_atime; @@ -958,7 +951,6 @@ EXPORT_SYMBOL(cl_attr2lvb); */ void cl_lvb2attr(struct cl_attr *attr, const struct ost_lvb *lvb) { - ENTRY; attr->cat_size = lvb->lvb_size; attr->cat_mtime = lvb->lvb_mtime; attr->cat_atime = lvb->lvb_atime; diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c index d9ca5d5005707..3c6cf202bbd99 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_page.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c @@ -108,7 +108,6 @@ cl_page_at_trusted(const struct cl_page *page, const struct lu_device_type *dtype) { const struct cl_page_slice *slice; - ENTRY; page = cl_page_top_trusted((struct cl_page *)page); do { @@ -167,7 +166,6 @@ int cl_page_gang_lookup(const struct lu_env *env, struct cl_object *obj, unsigned int j; int res = CLP_GANG_OKAY; int tree_lock = 1; - ENTRY; idx = start; hdr = cl_object_header(obj); @@ -258,7 +256,6 @@ static void cl_page_free(const struct lu_env *env, struct cl_page *page) PASSERT(env, page, page->cp_parent == NULL); PASSERT(env, page, page->cp_state == CPS_FREEING); - ENTRY; might_sleep(); while (!list_empty(&page->cp_layers)) { struct cl_page_slice *slice; @@ -295,7 +292,6 @@ static struct cl_page *cl_page_alloc(const struct lu_env *env, struct cl_page *page; struct lu_object_header *head; - ENTRY; OBD_ALLOC_GFP(page, cl_object_header(o)->coh_page_bufsize, __GFP_IO); if (page != NULL) { @@ -365,8 +361,6 @@ static struct cl_page *cl_page_find0(const struct lu_env *env, LASSERT(type == CPT_CACHEABLE || type == CPT_TRANSIENT); might_sleep(); - ENTRY; - hdr = cl_object_header(o); CS_PAGE_INC(o, lookup); @@ -554,7 +548,6 @@ static void cl_page_state_set0(const struct lu_env *env, } }; - ENTRY; old = page->cp_state; PASSERT(env, page, allowed_transitions[old][state]); CL_PAGE_HEADER(D_TRACE, env, page, "%d -> %d\n", old, state); @@ -586,7 +579,6 @@ static void cl_page_state_set(const struct lu_env *env, */ void cl_page_get(struct cl_page *page) { - ENTRY; cl_page_get_trust(page); EXIT; } @@ -605,7 +597,6 @@ void cl_page_put(const struct lu_env *env, struct cl_page *page) { PASSERT(env, page, atomic_read(&page->cp_ref) > !!page->cp_parent); - ENTRY; CL_PAGE_HEADER(D_TRACE, env, page, "%d\n", atomic_read(&page->cp_ref)); @@ -657,7 +648,6 @@ struct cl_page *cl_vmpage_page(struct page *vmpage, struct cl_object *obj) struct cl_page *top; struct cl_page *page; - ENTRY; KLASSERT(PageLocked(vmpage)); /* @@ -786,7 +776,6 @@ static int cl_page_invoke(const struct lu_env *env, { PINVRNT(env, page, cl_object_same(page->cp_obj, io->ci_obj)); - ENTRY; RETURN(CL_PAGE_INVOKE(env, page, op, (const struct lu_env *, const struct cl_page_slice *, struct cl_io *), @@ -798,7 +787,6 @@ static void cl_page_invoid(const struct lu_env *env, { PINVRNT(env, page, cl_object_same(page->cp_obj, io->ci_obj)); - ENTRY; CL_PAGE_INVOID(env, page, op, (const struct lu_env *, const struct cl_page_slice *, struct cl_io *), io); @@ -807,7 +795,6 @@ static void cl_page_invoid(const struct lu_env *env, static void cl_page_owner_clear(struct cl_page *page) { - ENTRY; for (page = cl_page_top(page); page != NULL; page = page->cp_child) { if (page->cp_owner != NULL) { LASSERT(page->cp_owner->ci_owned_nr > 0); @@ -821,7 +808,6 @@ static void cl_page_owner_clear(struct cl_page *page) static void cl_page_owner_set(struct cl_page *page) { - ENTRY; for (page = cl_page_top(page); page != NULL; page = page->cp_child) { LASSERT(page->cp_owner != NULL); page->cp_owner->ci_owned_nr++; @@ -834,7 +820,6 @@ void cl_page_disown0(const struct lu_env *env, { enum cl_page_state state; - ENTRY; state = pg->cp_state; PINVRNT(env, pg, state == CPS_OWNED || state == CPS_FREEING); PINVRNT(env, pg, cl_page_invariant(pg)); @@ -860,7 +845,6 @@ void cl_page_disown0(const struct lu_env *env, int cl_page_is_owned(const struct cl_page *pg, const struct cl_io *io) { LINVRNT(cl_object_same(pg->cp_obj, io->ci_obj)); - ENTRY; RETURN(pg->cp_state == CPS_OWNED && pg->cp_owner == io); } EXPORT_SYMBOL(cl_page_is_owned); @@ -892,7 +876,6 @@ static int cl_page_own0(const struct lu_env *env, struct cl_io *io, PINVRNT(env, pg, !cl_page_is_owned(pg, io)); - ENTRY; pg = cl_page_top(pg); io = cl_io_top(io); @@ -961,7 +944,6 @@ void cl_page_assume(const struct lu_env *env, { PINVRNT(env, pg, cl_object_same(pg->cp_obj, io->ci_obj)); - ENTRY; pg = cl_page_top(pg); io = cl_io_top(io); @@ -992,7 +974,6 @@ void cl_page_unassume(const struct lu_env *env, PINVRNT(env, pg, cl_page_is_owned(pg, io)); PINVRNT(env, pg, cl_page_invariant(pg)); - ENTRY; pg = cl_page_top(pg); io = cl_io_top(io); cl_page_owner_clear(pg); @@ -1021,7 +1002,6 @@ void cl_page_disown(const struct lu_env *env, { PINVRNT(env, pg, cl_page_is_owned(pg, io)); - ENTRY; pg = cl_page_top(pg); io = cl_io_top(io); cl_page_disown0(env, io, pg); @@ -1058,7 +1038,6 @@ static void cl_page_delete0(const struct lu_env *env, struct cl_page *pg, int radix) { struct cl_page *tmp = pg; - ENTRY; PASSERT(env, pg, pg == cl_page_top(pg)); PASSERT(env, pg, pg->cp_state != CPS_FREEING); @@ -1135,7 +1114,6 @@ static void cl_page_delete0(const struct lu_env *env, struct cl_page *pg, void cl_page_delete(const struct lu_env *env, struct cl_page *pg) { PINVRNT(env, pg, cl_page_invariant(pg)); - ENTRY; cl_page_delete0(env, pg, 1); EXIT; } @@ -1187,7 +1165,6 @@ int cl_page_is_vmlocked(const struct lu_env *env, const struct cl_page *pg) int result; const struct cl_page_slice *slice; - ENTRY; pg = cl_page_top_trusted((struct cl_page *)pg); slice = container_of(pg->cp_layers.next, const struct cl_page_slice, cpl_linkage); @@ -1205,7 +1182,6 @@ EXPORT_SYMBOL(cl_page_is_vmlocked); static enum cl_page_state cl_req_type_state(enum cl_req_type crt) { - ENTRY; RETURN(crt == CRT_WRITE ? CPS_PAGEOUT : CPS_PAGEIN); } @@ -1215,7 +1191,6 @@ static void cl_page_io_start(const struct lu_env *env, /* * Page is queued for IO, change its state. */ - ENTRY; cl_page_owner_clear(pg); cl_page_state_set(env, pg, cl_req_type_state(crt)); EXIT; @@ -1281,7 +1256,6 @@ void cl_page_completion(const struct lu_env *env, PASSERT(env, pg, pg->cp_req == NULL); PASSERT(env, pg, pg->cp_state == cl_req_type_state(crt)); - ENTRY; CL_PAGE_HEADER(D_TRACE, env, pg, "%d %d\n", crt, ioret); if (crt == CRT_READ && ioret == 0) { PASSERT(env, pg, !(pg->cp_flags & CPF_READ_COMPLETED)); @@ -1329,7 +1303,6 @@ int cl_page_make_ready(const struct lu_env *env, struct cl_page *pg, PINVRNT(env, pg, crt < CRT_NR); - ENTRY; if (crt >= CRT_NR) RETURN(-EINVAL); result = CL_PAGE_INVOKE(env, pg, CL_PAGE_OP(io[crt].cpo_make_ready), @@ -1366,8 +1339,6 @@ int cl_page_cache_add(const struct lu_env *env, struct cl_io *io, PINVRNT(env, pg, cl_page_is_owned(pg, io)); PINVRNT(env, pg, cl_page_invariant(pg)); - ENTRY; - if (crt >= CRT_NR) RETURN(-EINVAL); @@ -1400,8 +1371,6 @@ int cl_page_flush(const struct lu_env *env, struct cl_io *io, PINVRNT(env, pg, cl_page_is_owned(pg, io)); PINVRNT(env, pg, cl_page_invariant(pg)); - ENTRY; - result = cl_page_invoke(env, io, pg, CL_PAGE_OP(cpo_flush)); CL_PAGE_HEADER(D_TRACE, env, pg, "%d\n", result); @@ -1423,7 +1392,6 @@ int cl_page_is_under_lock(const struct lu_env *env, struct cl_io *io, PINVRNT(env, page, cl_page_invariant(page)); - ENTRY; rc = CL_PAGE_INVOKE(env, page, CL_PAGE_OP(cpo_is_under_lock), (const struct lu_env *, const struct cl_page_slice *, struct cl_io *), @@ -1453,7 +1421,6 @@ int cl_pages_prune(const struct lu_env *env, struct cl_object *clobj) struct cl_io *io; int result; - ENTRY; info = cl_env_info(env); io = &info->clt_io; @@ -1587,7 +1554,6 @@ void cl_page_slice_add(struct cl_page *page, struct cl_page_slice *slice, struct cl_object *obj, const struct cl_page_operations *ops) { - ENTRY; list_add_tail(&slice->cpl_linkage, &page->cp_layers); slice->cpl_obj = obj; slice->cpl_ops = ops; diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c index deebf806cde04..07d7d2e7c5436 100644 --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c @@ -112,7 +112,6 @@ int lustre_get_jobid(char *jobid) { int jobid_len = JOBSTATS_JOBID_SIZE; int rc = 0; - ENTRY; memset(jobid, 0, JOBSTATS_JOBID_SIZE); /* Jobstats isn't enabled */ @@ -194,7 +193,6 @@ int class_resolve_dev_name(__u32 len, const char *name) int rc; int dev; - ENTRY; if (!len || !name) { CERROR("No name passed,!\n"); GOTO(out, rc = -EINVAL); @@ -225,7 +223,6 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) struct libcfs_debug_ioctl_data *debug_data; struct obd_device *obd = NULL; int err = 0, len = 0; - ENTRY; /* only for debugging */ if (cmd == LIBCFS_IOC_DEBUG_MASK) { @@ -639,7 +636,6 @@ static void cleanup_obdclass(void) int lustre_unregister_fs(void); __u64 memory_leaked, pages_leaked; __u64 memory_max, pages_max; - ENTRY; lustre_unregister_fs(); diff --git a/drivers/staging/lustre/lustre/obdclass/dt_object.c b/drivers/staging/lustre/lustre/obdclass/dt_object.c index 1c962dd3bd2f7..0d4eca7a55f52 100644 --- a/drivers/staging/lustre/lustre/obdclass/dt_object.c +++ b/drivers/staging/lustre/lustre/obdclass/dt_object.c @@ -219,7 +219,6 @@ struct dt_object *dt_locate_at(const struct lu_env *env, struct lu_device *top_dev) { struct lu_object *lo, *n; - ENTRY; lo = lu_object_find_at(env, top_dev, fid, NULL); if (IS_ERR(lo)) @@ -376,8 +375,6 @@ struct dt_object *dt_find_or_create(const struct lu_env *env, struct thandle *th; int rc; - ENTRY; - dto = dt_locate(env, dt, fid); if (IS_ERR(dto)) RETURN(dto); @@ -659,7 +656,6 @@ static int dt_index_page_build(const struct lu_env *env, union lu_page *lp, struct lu_idxpage *lip = &lp->lp_idx; char *entry; int rc, size; - ENTRY; /* no support for variable key & record size for now */ LASSERT((ii->ii_flags & II_FL_VARKEY) == 0); @@ -763,7 +759,6 @@ int dt_index_walk(const struct lu_env *env, struct dt_object *obj, const struct dt_it_ops *iops; unsigned int pageidx, nob, nlupgs = 0; int rc; - ENTRY; LASSERT(rdpg->rp_pages != NULL); LASSERT(obj->do_index_ops != NULL); @@ -855,7 +850,6 @@ int dt_index_read(const struct lu_env *env, struct dt_device *dev, const struct dt_index_features *feat; struct dt_object *obj; int rc; - ENTRY; /* rp_count shouldn't be null and should be a multiple of the container * size */ diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index ea041a34f5f7e..b2ec1067a29d8 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -163,7 +163,6 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, { struct obd_type *type; int rc = 0; - ENTRY; /* sanity check */ LASSERT(strnlen(name, CLASS_MAX_NAME) < CLASS_MAX_NAME); @@ -231,7 +230,6 @@ EXPORT_SYMBOL(class_register_type); int class_unregister_type(const char *name) { struct obd_type *type = class_search_type(name); - ENTRY; if (!type) { CERROR("unknown obd type\n"); @@ -285,7 +283,6 @@ struct obd_device *class_newdev(const char *type_name, const char *name) struct obd_type *type = NULL; int i; int new_obd_minor = 0; - ENTRY; if (strlen(name) >= MAX_OBD_NAME) { CERROR("name/uuid must be < %u bytes long\n", MAX_OBD_NAME); @@ -635,7 +632,6 @@ EXPORT_SYMBOL(class_notify_sptlrpc_conf); void obd_cleanup_caches(void) { - ENTRY; if (obd_device_cachep) { kmem_cache_destroy(obd_device_cachep); obd_device_cachep = NULL; @@ -657,8 +653,6 @@ void obd_cleanup_caches(void) int obd_init_caches(void) { - ENTRY; - LASSERT(obd_device_cachep == NULL); obd_device_cachep = kmem_cache_create("ll_obd_dev_cache", sizeof(struct obd_device), @@ -696,7 +690,6 @@ int obd_init_caches(void) struct obd_export *class_conn2export(struct lustre_handle *conn) { struct obd_export *export; - ENTRY; if (!conn) { CDEBUG(D_CACHE, "looking for null handle\n"); @@ -757,7 +750,6 @@ EXPORT_SYMBOL(class_conn2cliimp); static void class_export_destroy(struct obd_export *exp) { struct obd_device *obd = exp->exp_obd; - ENTRY; LASSERT_ATOMIC_ZERO(&exp->exp_refcount); LASSERT(obd != NULL); @@ -828,7 +820,6 @@ struct obd_export *class_new_export(struct obd_device *obd, struct obd_export *export; cfs_hash_t *hash = NULL; int rc = 0; - ENTRY; OBD_ALLOC_PTR(export); if (!export) @@ -936,8 +927,6 @@ EXPORT_SYMBOL(class_unlink_export); /* Import management functions */ void class_import_destroy(struct obd_import *imp) { - ENTRY; - CDEBUG(D_IOCTL, "destroying import %p for %s\n", imp, imp->imp_obd->obd_name); @@ -983,8 +972,6 @@ EXPORT_SYMBOL(class_import_get); void class_import_put(struct obd_import *imp) { - ENTRY; - LASSERT(list_empty(&imp->imp_zombie_chain)); LASSERT_ATOMIC_GT_LT(&imp->imp_refcount, 0, LI_POISON); @@ -1121,7 +1108,6 @@ int class_connect(struct lustre_handle *conn, struct obd_device *obd, LASSERT(conn != NULL); LASSERT(obd != NULL); LASSERT(cluuid != NULL); - ENTRY; export = class_new_export(obd, cluuid); if (IS_ERR(export)) @@ -1188,7 +1174,6 @@ void class_export_recovery_cleanup(struct obd_export *exp) int class_disconnect(struct obd_export *export) { int already_disconnected; - ENTRY; if (export == NULL) { CWARN("attempting to free NULL export %p\n", export); @@ -1243,7 +1228,6 @@ static void class_disconnect_export_list(struct list_head *list, { int rc; struct obd_export *exp; - ENTRY; /* It's possible that an export may disconnect itself, but * nothing else will be added to this list. */ @@ -1287,7 +1271,6 @@ static void class_disconnect_export_list(struct list_head *list, void class_disconnect_exports(struct obd_device *obd) { struct list_head work_list; - ENTRY; /* Move all of the exports from obd_exports to a work list, en masse. */ INIT_LIST_HEAD(&work_list); @@ -1316,7 +1299,6 @@ void class_disconnect_stale_exports(struct obd_device *obd, struct list_head work_list; struct obd_export *exp, *n; int evicted = 0; - ENTRY; INIT_LIST_HEAD(&work_list); spin_lock(&obd->obd_dev_lock); @@ -1585,7 +1567,6 @@ void obd_zombie_impexp_cull(void) { struct obd_import *import; struct obd_export *export; - ENTRY; do { spin_lock(&obd_zombie_impexp_lock); diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c index 9fe53f3a98ce8..a3cb92f6ae9ce 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c @@ -83,7 +83,6 @@ int obd_ioctl_getdata(char **buf, int *len, void *arg) struct obd_ioctl_data *data; int err; int offset = 0; - ENTRY; err = copy_from_user(&hdr, (void *)arg, sizeof(hdr)); if ( err ) @@ -169,8 +168,6 @@ EXPORT_SYMBOL(obd_ioctl_popdata); /* opening /dev/obd */ static int obd_class_open(struct inode * inode, struct file * file) { - ENTRY; - try_module_get(THIS_MODULE); RETURN(0); } @@ -178,8 +175,6 @@ static int obd_class_open(struct inode * inode, struct file * file) /* closing /dev/obd */ static int obd_class_release(struct inode * inode, struct file * file) { - ENTRY; - module_put(THIS_MODULE); RETURN(0); } @@ -189,7 +184,6 @@ static long obd_class_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { int err = 0; - ENTRY; /* Allow non-root access for OBD_IOC_PING_TARGET - used by lfs check */ if (!cfs_capable(CFS_CAP_SYS_ADMIN) && (cmd != OBD_IOC_PING_TARGET)) @@ -386,7 +380,6 @@ struct file_operations obd_device_list_fops = { int class_procfs_init(void) { int rc = 0; - ENTRY; obd_sysctl_init(); proc_lustre_root = lprocfs_register("fs/lustre", NULL, @@ -407,7 +400,6 @@ int class_procfs_init(void) int class_procfs_clean(void) { - ENTRY; if (proc_lustre_root) { lprocfs_remove(&proc_lustre_root); } diff --git a/drivers/staging/lustre/lustre/obdclass/llog.c b/drivers/staging/lustre/lustre/obdclass/llog.c index b1d215e56991e..a154cc5e57538 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog.c +++ b/drivers/staging/lustre/lustre/obdclass/llog.c @@ -111,7 +111,6 @@ int llog_cancel_rec(const struct lu_env *env, struct llog_handle *loghandle, { struct llog_log_hdr *llh = loghandle->lgh_hdr; int rc = 0; - ENTRY; CDEBUG(D_RPCTRACE, "Canceling %d in log "DOSTID"\n", index, POSTID(&loghandle->lgh_id.lgl_oi)); @@ -206,7 +205,6 @@ int llog_init_handle(const struct lu_env *env, struct llog_handle *handle, struct llog_log_hdr *llh; int rc; - ENTRY; LASSERT(handle->lgh_hdr == NULL); OBD_ALLOC_PTR(llh); @@ -277,7 +275,6 @@ int llog_copy_handler(const struct lu_env *env, char *cfg_buf = (char*) (rec + 1); struct lustre_cfg *lcfg; int rc = 0; - ENTRY; /* Append all records */ local_rec.lrh_len -= sizeof(*rec) + sizeof(struct llog_rec_tail); @@ -306,8 +303,6 @@ static int llog_process_thread(void *arg) int saved_index = 0; int last_called_index = 0; - ENTRY; - LASSERT(llh); OBD_ALLOC(buf, LLOG_CHUNK_SIZE); @@ -457,8 +452,6 @@ int llog_process_or_fork(const struct lu_env *env, struct llog_process_info *lpi; int rc; - ENTRY; - OBD_ALLOC_PTR(lpi); if (lpi == NULL) { CERROR("cannot alloc pointer\n"); @@ -516,7 +509,6 @@ int llog_reverse_process(const struct lu_env *env, struct llog_process_cat_data *cd = catdata; void *buf; int rc = 0, first_index = 1, index, idx; - ENTRY; OBD_ALLOC(buf, LLOG_CHUNK_SIZE); if (!buf) @@ -617,8 +609,6 @@ int llog_exist(struct llog_handle *loghandle) struct llog_operations *lop; int rc; - ENTRY; - rc = llog_handle2ops(loghandle, &lop); if (rc) RETURN(rc); @@ -636,8 +626,6 @@ int llog_declare_create(const struct lu_env *env, struct llog_operations *lop; int raised, rc; - ENTRY; - rc = llog_handle2ops(loghandle, &lop); if (rc) RETURN(rc); @@ -660,8 +648,6 @@ int llog_create(const struct lu_env *env, struct llog_handle *handle, struct llog_operations *lop; int raised, rc; - ENTRY; - rc = llog_handle2ops(handle, &lop); if (rc) RETURN(rc); @@ -686,8 +672,6 @@ int llog_declare_write_rec(const struct lu_env *env, struct llog_operations *lop; int raised, rc; - ENTRY; - rc = llog_handle2ops(handle, &lop); if (rc) RETURN(rc); @@ -712,8 +696,6 @@ int llog_write_rec(const struct lu_env *env, struct llog_handle *handle, struct llog_operations *lop; int raised, rc, buflen; - ENTRY; - rc = llog_handle2ops(handle, &lop); if (rc) RETURN(rc); @@ -746,8 +728,6 @@ int llog_add(const struct lu_env *env, struct llog_handle *lgh, { int raised, rc; - ENTRY; - if (lgh->lgh_logops->lop_add == NULL) RETURN(-EOPNOTSUPP); @@ -766,8 +746,6 @@ int llog_declare_add(const struct lu_env *env, struct llog_handle *lgh, { int raised, rc; - ENTRY; - if (lgh->lgh_logops->lop_declare_add == NULL) RETURN(-EOPNOTSUPP); @@ -792,8 +770,6 @@ int llog_open_create(const struct lu_env *env, struct llog_ctxt *ctxt, struct thandle *th; int rc; - ENTRY; - rc = llog_open(env, ctxt, res, logid, name, LLOG_OPEN_NEW); if (rc) RETURN(rc); @@ -838,8 +814,6 @@ int llog_erase(const struct lu_env *env, struct llog_ctxt *ctxt, struct llog_handle *handle; int rc = 0, rc2; - ENTRY; - /* nothing to erase */ if (name == NULL && logid == NULL) RETURN(0); @@ -870,8 +844,6 @@ int llog_write(const struct lu_env *env, struct llog_handle *loghandle, { int rc; - ENTRY; - LASSERT(loghandle); LASSERT(loghandle->lgh_ctxt); @@ -916,8 +888,6 @@ int llog_open(const struct lu_env *env, struct llog_ctxt *ctxt, int raised; int rc; - ENTRY; - LASSERT(ctxt); LASSERT(ctxt->loc_logops); @@ -951,8 +921,6 @@ int llog_close(const struct lu_env *env, struct llog_handle *loghandle) struct llog_operations *lop; int rc; - ENTRY; - rc = llog_handle2ops(loghandle, &lop); if (rc) GOTO(out, rc); diff --git a/drivers/staging/lustre/lustre/obdclass/llog_cat.c b/drivers/staging/lustre/lustre/obdclass/llog_cat.c index cf00b2f550acb..08b950802ae7f 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_cat.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_cat.c @@ -67,7 +67,6 @@ static int llog_cat_new_log(const struct lu_env *env, struct llog_log_hdr *llh; struct llog_logid_rec rec = { { 0 }, }; int rc, index, bitmap_size; - ENTRY; llh = cathandle->lgh_hdr; bitmap_size = LLOG_BITMAP_SIZE(llh); @@ -155,8 +154,6 @@ int llog_cat_id2handle(const struct lu_env *env, struct llog_handle *cathandle, struct llog_handle *loghandle; int rc = 0; - ENTRY; - if (cathandle == NULL) RETURN(-EBADF); @@ -217,8 +214,6 @@ int llog_cat_close(const struct lu_env *env, struct llog_handle *cathandle) struct llog_handle *loghandle, *n; int rc; - ENTRY; - list_for_each_entry_safe(loghandle, n, &cathandle->u.chd.chd_head, u.phd.phd_entry) { struct llog_log_hdr *llh = loghandle->lgh_hdr; @@ -272,7 +267,6 @@ static struct llog_handle *llog_cat_current_log(struct llog_handle *cathandle, struct thandle *th) { struct llog_handle *loghandle = NULL; - ENTRY; down_read_nested(&cathandle->lgh_lock, LLOGH_CAT); loghandle = cathandle->u.chd.chd_current_log; @@ -332,7 +326,6 @@ int llog_cat_add_rec(const struct lu_env *env, struct llog_handle *cathandle, { struct llog_handle *loghandle; int rc; - ENTRY; LASSERT(rec->lrh_len <= LLOG_CHUNK_SIZE); loghandle = llog_cat_current_log(cathandle, th); @@ -383,8 +376,6 @@ int llog_cat_declare_add_rec(const struct lu_env *env, struct llog_handle *loghandle, *next; int rc = 0; - ENTRY; - if (cathandle->u.chd.chd_current_log == NULL) { /* declare new plain llog */ down_write(&cathandle->lgh_lock); @@ -498,8 +489,6 @@ int llog_cat_cancel_records(const struct lu_env *env, { int i, index, rc = 0, failed = 0; - ENTRY; - for (i = 0; i < count; i++, cookies++) { struct llog_handle *loghandle; struct llog_logid *lgl = &cookies->lgc_lgl; @@ -545,7 +534,6 @@ int llog_cat_process_cb(const struct lu_env *env, struct llog_handle *cat_llh, struct llog_handle *llh; int rc; - ENTRY; if (rec->lrh_type != LLOG_LOGID_MAGIC) { CERROR("invalid record in catalog\n"); RETURN(-EINVAL); @@ -592,7 +580,6 @@ int llog_cat_process_or_fork(const struct lu_env *env, struct llog_process_data d; struct llog_log_hdr *llh = cat_llh->lgh_hdr; int rc; - ENTRY; LASSERT(llh->llh_flags & LLOG_F_IS_CAT); d.lpd_data = data; @@ -672,7 +659,6 @@ int llog_cat_reverse_process(const struct lu_env *env, struct llog_process_cat_data cd; struct llog_log_hdr *llh = cat_llh->lgh_hdr; int rc; - ENTRY; LASSERT(llh->llh_flags & LLOG_F_IS_CAT); d.lpd_data = data; @@ -709,7 +695,6 @@ int llog_cat_set_first_idx(struct llog_handle *cathandle, int index) { struct llog_log_hdr *llh = cathandle->lgh_hdr; int i, bitmap_size, idx; - ENTRY; bitmap_size = LLOG_BITMAP_SIZE(llh); if (llh->llh_cat_idx == (index - 1)) { @@ -774,8 +759,6 @@ int cat_cancel_cb(const struct lu_env *env, struct llog_handle *cathandle, struct llog_log_hdr *llh; int rc; - ENTRY; - if (rec->lrh_type != LLOG_LOGID_MAGIC) { CERROR("invalid record in catalog\n"); RETURN(-EINVAL); diff --git a/drivers/staging/lustre/lustre/obdclass/llog_ioctl.c b/drivers/staging/lustre/lustre/obdclass/llog_ioctl.c index 0732874e26c5c..1c83ec217ad5e 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_ioctl.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_ioctl.c @@ -45,7 +45,6 @@ static int str2logid(struct llog_logid *logid, char *str, int len) char *start, *end, *endp; __u64 id, seq; - ENTRY; start = str; if (*start != '#') RETURN(-EINVAL); @@ -96,8 +95,6 @@ static int llog_check_cb(const struct lu_env *env, struct llog_handle *handle, char *endp; int cur_index, rc = 0; - ENTRY; - if (ioc_data && ioc_data->ioc_inllen1 > 0) { l = 0; remains = ioc_data->ioc_inllen4 + @@ -182,7 +179,6 @@ static int llog_print_cb(const struct lu_env *env, struct llog_handle *handle, char *endp; int cur_index; - ENTRY; if (ioc_data != NULL && ioc_data->ioc_inllen1 > 0) { l = 0; remains = ioc_data->ioc_inllen4 + @@ -244,8 +240,6 @@ static int llog_remove_log(const struct lu_env *env, struct llog_handle *cat, struct llog_handle *log; int rc; - ENTRY; - rc = llog_cat_id2handle(env, cat, &log, logid); if (rc) { CDEBUG(D_IOCTL, "cannot find log #"DOSTID"#%08x\n", @@ -271,7 +265,6 @@ static int llog_delete_cb(const struct lu_env *env, struct llog_handle *handle, struct llog_logid_rec *lir = (struct llog_logid_rec *)rec; int rc; - ENTRY; if (rec->lrh_type != LLOG_LOGID_MAGIC) RETURN(-EINVAL); rc = llog_remove_log(env, handle, &lir->lid_id); @@ -287,8 +280,6 @@ int llog_ioctl(const struct lu_env *env, struct llog_ctxt *ctxt, int cmd, int rc = 0; struct llog_handle *handle = NULL; - ENTRY; - if (*data->ioc_inlbuf1 == '#') { rc = str2logid(&logid, data->ioc_inlbuf1, data->ioc_inllen1); if (rc) diff --git a/drivers/staging/lustre/lustre/obdclass/llog_lvfs.c b/drivers/staging/lustre/lustre/obdclass/llog_lvfs.c index 7e12dc62141f9..6543ba9b9e3db 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_lvfs.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_lvfs.c @@ -64,7 +64,6 @@ static int llog_lvfs_pad(struct obd_device *obd, struct l_file *file, struct llog_rec_hdr rec = { 0 }; struct llog_rec_tail tail; int rc; - ENTRY; LASSERT(len >= LLOG_MIN_REC_SIZE && (len & 0x7) == 0); @@ -97,8 +96,6 @@ static int llog_lvfs_write_blob(struct obd_device *obd, struct l_file *file, loff_t saved_off = file->f_pos; int buflen = rec->lrh_len; - ENTRY; - file->f_pos = off; if (buflen == 0) @@ -148,7 +145,6 @@ static int llog_lvfs_read_blob(struct obd_device *obd, struct l_file *file, { loff_t offset = off; int rc; - ENTRY; rc = fsfilt_read_record(obd, file, buf, size, &offset); if (rc) { @@ -163,7 +159,6 @@ static int llog_lvfs_read_header(const struct lu_env *env, { struct obd_device *obd; int rc; - ENTRY; LASSERT(sizeof(*handle->lgh_hdr) == LLOG_CHUNK_SIZE); @@ -223,7 +218,6 @@ static int llog_lvfs_write_rec(const struct lu_env *env, struct obd_device *obd; struct file *file; size_t left; - ENTRY; llh = loghandle->lgh_hdr; file = loghandle->lgh_file; @@ -391,7 +385,6 @@ static int llog_lvfs_next_block(const struct lu_env *env, int len) { int rc; - ENTRY; if (len == 0 || len & (LLOG_CHUNK_SIZE - 1)) RETURN(-EINVAL); @@ -484,7 +477,6 @@ static int llog_lvfs_prev_block(const struct lu_env *env, { __u64 cur_offset; int rc; - ENTRY; if (len == 0 || len & (LLOG_CHUNK_SIZE - 1)) RETURN(-EINVAL); @@ -593,8 +585,6 @@ static int llog_lvfs_open(const struct lu_env *env, struct llog_handle *handle, struct obd_device *obd; int rc = 0; - ENTRY; - LASSERT(ctxt); LASSERT(ctxt->loc_exp); LASSERT(ctxt->loc_exp->exp_obd); @@ -688,8 +678,6 @@ static int llog_lvfs_create(const struct lu_env *env, int rc = 0; int open_flags = O_RDWR | O_CREAT | O_LARGEFILE; - ENTRY; - LASSERT(ctxt); LASSERT(ctxt->loc_exp); obd = ctxt->loc_exp->exp_obd; @@ -744,8 +732,6 @@ static int llog_lvfs_close(const struct lu_env *env, { int rc; - ENTRY; - if (handle->lgh_file == NULL) RETURN(0); rc = filp_close(handle->lgh_file, 0); @@ -772,7 +758,6 @@ static int llog_lvfs_destroy(const struct lu_env *env, void *th; struct inode *inode; int rc, rc1; - ENTRY; dir = MOUNT_CONFIGS_DIR; diff --git a/drivers/staging/lustre/lustre/obdclass/llog_obd.c b/drivers/staging/lustre/lustre/obdclass/llog_obd.c index 7e2290796315b..7d6c94b463a37 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_obd.c @@ -110,7 +110,6 @@ int llog_cleanup(const struct lu_env *env, struct llog_ctxt *ctxt) struct l_wait_info lwi = LWI_INTR(LWI_ON_SIGNAL_NOOP, NULL); struct obd_llog_group *olg; int rc, idx; - ENTRY; LASSERT(ctxt != NULL); LASSERT(ctxt != LP_POISON); @@ -149,7 +148,6 @@ int llog_setup(const struct lu_env *env, struct obd_device *obd, { struct llog_ctxt *ctxt; int rc = 0; - ENTRY; if (index < 0 || index >= LLOG_MAX_CTXTS) RETURN(-EINVAL); @@ -217,7 +215,6 @@ EXPORT_SYMBOL(llog_setup); int llog_sync(struct llog_ctxt *ctxt, struct obd_export *exp, int flags) { int rc = 0; - ENTRY; if (!ctxt) RETURN(0); @@ -234,7 +231,6 @@ int llog_obd_add(const struct lu_env *env, struct llog_ctxt *ctxt, struct llog_cookie *logcookies, int numcookies) { int raised, rc; - ENTRY; if (!ctxt) { CERROR("No ctxt\n"); @@ -261,7 +257,6 @@ int llog_cancel(const struct lu_env *env, struct llog_ctxt *ctxt, struct llog_cookie *cookies, int flags) { int rc; - ENTRY; if (!ctxt) { CERROR("No ctxt\n"); @@ -278,7 +273,7 @@ int obd_llog_init(struct obd_device *obd, struct obd_llog_group *olg, struct obd_device *disk_obd, int *index) { int rc; - ENTRY; + OBD_CHECK_DT_OP(obd, llog_init, 0); OBD_COUNTER_INCREMENT(obd, llog_init); @@ -290,7 +285,7 @@ EXPORT_SYMBOL(obd_llog_init); int obd_llog_finish(struct obd_device *obd, int count) { int rc; - ENTRY; + OBD_CHECK_DT_OP(obd, llog_finish, 0); OBD_COUNTER_INCREMENT(obd, llog_finish); diff --git a/drivers/staging/lustre/lustre/obdclass/llog_osd.c b/drivers/staging/lustre/lustre/obdclass/llog_osd.c index 87d5012cfc563..5569d8d55e00a 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_osd.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_osd.c @@ -93,8 +93,6 @@ static int llog_osd_pad(const struct lu_env *env, struct dt_object *o, struct llog_thread_info *lgi = llog_info(env); int rc; - ENTRY; - LASSERT(th); LASSERT(off); LASSERT(len >= LLOG_MIN_REC_SIZE && (len & 0x7) == 0); @@ -133,8 +131,6 @@ static int llog_osd_write_blob(const struct lu_env *env, struct dt_object *o, int buflen = rec->lrh_len; int rc; - ENTRY; - LASSERT(env); LASSERT(o); @@ -210,8 +206,6 @@ static int llog_osd_read_header(const struct lu_env *env, struct llog_thread_info *lgi; int rc; - ENTRY; - LASSERT(sizeof(*handle->lgh_hdr) == LLOG_CHUNK_SIZE); o = handle->lgh_obj; @@ -278,8 +272,6 @@ static int llog_osd_declare_write_rec(const struct lu_env *env, struct dt_object *o; int rc; - ENTRY; - LASSERT(env); LASSERT(th); LASSERT(loghandle); @@ -329,8 +321,6 @@ static int llog_osd_write_rec(const struct lu_env *env, struct dt_object *o; size_t left; - ENTRY; - LASSERT(env); llh = loghandle->lgh_hdr; LASSERT(llh); @@ -537,8 +527,6 @@ static int llog_osd_next_block(const struct lu_env *env, struct dt_device *dt; int rc; - ENTRY; - LASSERT(env); LASSERT(lgi); @@ -664,8 +652,6 @@ static int llog_osd_prev_block(const struct lu_env *env, loff_t cur_offset; int rc; - ENTRY; - if (len == 0 || len & (LLOG_CHUNK_SIZE - 1)) RETURN(-EINVAL); @@ -794,8 +780,6 @@ static int llog_osd_open(const struct lu_env *env, struct llog_handle *handle, struct local_oid_storage *los; int rc = 0; - ENTRY; - LASSERT(env); LASSERT(ctxt); LASSERT(ctxt->loc_exp); @@ -887,8 +871,6 @@ static int llog_osd_declare_create(const struct lu_env *env, struct dt_object *o; int rc; - ENTRY; - LASSERT(res->lgh_obj); LASSERT(th); @@ -937,8 +919,6 @@ static int llog_osd_create(const struct lu_env *env, struct llog_handle *res, struct dt_object *o; int rc = 0; - ENTRY; - LASSERT(env); o = res->lgh_obj; LASSERT(o); @@ -988,8 +968,6 @@ static int llog_osd_close(const struct lu_env *env, struct llog_handle *handle) struct local_oid_storage *los; int rc = 0; - ENTRY; - LASSERT(handle->lgh_obj); lu_object_put(env, &handle->lgh_obj->do_lu); @@ -1014,8 +992,6 @@ static int llog_osd_destroy(const struct lu_env *env, char *name = NULL; int rc; - ENTRY; - ctxt = loghandle->lgh_ctxt; LASSERT(ctxt); @@ -1090,8 +1066,6 @@ static int llog_osd_setup(const struct lu_env *env, struct obd_device *obd, struct llog_ctxt *ctxt; int rc = 0; - ENTRY; - LASSERT(obd); LASSERT(olg->olg_ctxts[ctxt_idx]); @@ -1171,8 +1145,6 @@ int llog_osd_get_cat_list(const struct lu_env *env, struct dt_device *d, struct thandle *th; int rc, size; - ENTRY; - LASSERT(d); size = sizeof(*idarray) * count; diff --git a/drivers/staging/lustre/lustre/obdclass/llog_swab.c b/drivers/staging/lustre/lustre/obdclass/llog_swab.c index a75b04ee52725..5cf15d20bb1f2 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_swab.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_swab.c @@ -88,7 +88,6 @@ EXPORT_SYMBOL(lustre_swab_llog_id); void lustre_swab_llogd_body (struct llogd_body *d) { - ENTRY; print_llogd_body(d); lustre_swab_llog_id(&d->lgd_logid); __swab32s (&d->lgd_ctxt_idx); @@ -298,7 +297,6 @@ static void print_llog_hdr(struct llog_log_hdr *h) void lustre_swab_llog_hdr (struct llog_log_hdr *h) { - ENTRY; print_llog_hdr(h); lustre_swab_llog_rec(&h->llh_hdr); @@ -311,7 +309,6 @@ EXPORT_SYMBOL(lustre_swab_llog_hdr); static void print_lustre_cfg(struct lustre_cfg *lcfg) { int i; - ENTRY; if (!(libcfs_debug & D_OTHER)) /* don't loop on nothing */ return; @@ -334,7 +331,6 @@ static void print_lustre_cfg(struct lustre_cfg *lcfg) void lustre_swab_lustre_cfg(struct lustre_cfg *lcfg) { int i; - ENTRY; __swab32s(&lcfg->lcfg_version); @@ -377,7 +373,6 @@ struct cfg_marker32 { void lustre_swab_cfg_marker(struct cfg_marker *marker, int swab, int size) { struct cfg_marker32 *cm32 = (struct cfg_marker32*)marker; - ENTRY; if (swab) { __swab32s(&marker->cm_step); diff --git a/drivers/staging/lustre/lustre/obdclass/llog_test.c b/drivers/staging/lustre/lustre/obdclass/llog_test.c index d397f781ec434..d3fd2461a07ab 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_test.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_test.c @@ -105,8 +105,6 @@ static int llog_test_1(const struct lu_env *env, int rc; int rc2; - ENTRY; - CWARN("1a: create a log with name: %s\n", name); ctxt = llog_get_context(obd, LLOG_TEST_ORIG_CTXT); LASSERT(ctxt); @@ -146,8 +144,6 @@ static int llog_test_2(const struct lu_env *env, struct obd_device *obd, struct llog_logid logid; int rc; - ENTRY; - CWARN("2a: re-open a log with name: %s\n", name); ctxt = llog_get_context(obd, LLOG_TEST_ORIG_CTXT); LASSERT(ctxt); @@ -224,8 +220,6 @@ static int llog_test_3(const struct lu_env *env, struct obd_device *obd, int rc, i; int num_recs = 1; /* 1 for the header */ - ENTRY; - lgr.lgr_hdr.lrh_len = lgr.lgr_tail.lrt_len = sizeof(lgr); lgr.lgr_hdr.lrh_type = LLOG_GEN_REC; @@ -328,8 +322,6 @@ static int llog_test_4(const struct lu_env *env, struct obd_device *obd) char *buf; struct llog_rec_hdr rec; - ENTRY; - ctxt = llog_get_context(obd, LLOG_TEST_ORIG_CTXT); LASSERT(ctxt); @@ -505,8 +497,6 @@ static int llog_test_5(const struct lu_env *env, struct obd_device *obd) struct llog_mini_rec lmr; struct llog_ctxt *ctxt; - ENTRY; - ctxt = llog_get_context(obd, LLOG_TEST_ORIG_CTXT); LASSERT(ctxt); @@ -728,8 +718,6 @@ static int llog_test_7_sub(const struct lu_env *env, struct llog_ctxt *ctxt) int rc = 0, i, process_count; int num_recs = 0; - ENTRY; - rc = llog_open_create(env, ctxt, &llh, NULL, NULL); if (rc) { CERROR("7_sub: create log failed\n"); @@ -813,8 +801,6 @@ static int llog_test_7(const struct lu_env *env, struct obd_device *obd) struct llog_ctxt *ctxt; int rc; - ENTRY; - ctxt = llog_get_context(obd, LLOG_TEST_ORIG_CTXT); CWARN("7a: test llog_logid_rec\n"); @@ -908,7 +894,6 @@ static int llog_run_tests(const struct lu_env *env, struct obd_device *obd) int rc, err; char name[10]; - ENTRY; ctxt = llog_get_context(obd, LLOG_TEST_ORIG_CTXT); LASSERT(ctxt); @@ -970,8 +955,6 @@ static int llog_test_cleanup(struct obd_device *obd) struct lu_env env; int rc; - ENTRY; - rc = lu_env_init(&env, LCT_LOCAL | LCT_MG_THREAD); if (rc) RETURN(rc); @@ -993,8 +976,6 @@ static int llog_test_setup(struct obd_device *obd, struct lustre_cfg *lcfg) struct lu_context test_session; int rc; - ENTRY; - if (lcfg->lcfg_bufcount < 2) { CERROR("requires a TARGET OBD name\n"); RETURN(-EINVAL); diff --git a/drivers/staging/lustre/lustre/obdclass/local_storage.c b/drivers/staging/lustre/lustre/obdclass/local_storage.c index e1db7abd300a3..6d8d7e7aec50d 100644 --- a/drivers/staging/lustre/lustre/obdclass/local_storage.c +++ b/drivers/staging/lustre/lustre/obdclass/local_storage.c @@ -45,8 +45,6 @@ static int ls_object_init(const struct lu_env *env, struct lu_object *o, struct lu_object *below; struct lu_device *under; - ENTRY; - ls = container_of0(o->lo_dev, struct ls_device, ls_top_dev.dd_lu_dev); under = &ls->ls_osd->dd_lu_dev; below = under->ld_ops->ldo_object_alloc(env, o->lo_header, under); @@ -143,8 +141,6 @@ struct ls_device *ls_device_get(struct dt_device *dev) { struct ls_device *ls; - ENTRY; - mutex_lock(&ls_list_mutex); ls = __ls_find_dev(dev); if (ls) @@ -224,8 +220,6 @@ int local_object_declare_create(const struct lu_env *env, struct dt_thread_info *dti = dt_info(env); int rc; - ENTRY; - /* update fid generation file */ if (los != NULL) { LASSERT(dt_object_exists(los->los_obj)); @@ -255,8 +249,6 @@ int local_object_create(const struct lu_env *env, obd_id lastid; int rc; - ENTRY; - rc = dt_create(env, o, attr, NULL, dof, th); if (rc) RETURN(rc); @@ -588,8 +580,6 @@ int local_object_unlink(const struct lu_env *env, struct dt_device *dt, struct thandle *th; int rc; - ENTRY; - rc = dt_lookup_dir(env, parent, name, &dti->dti_fid); if (rc == -ENOENT) RETURN(0); @@ -761,8 +751,6 @@ int local_oid_storage_init(const struct lu_env *env, struct dt_device *dev, __u32 first_oid = fid_oid(first_fid); int rc = 0; - ENTRY; - ls = ls_device_get(dev); if (IS_ERR(ls)) RETURN(PTR_ERR(ls)); diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index e57a922eda591..090b669c35d1b 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -900,7 +900,6 @@ void lprocfs_free_per_client_stats(struct obd_device *obd) { cfs_hash_t *hash = obd->obd_nid_stats_hash; struct nid_stat *stat; - ENTRY; /* we need extra list - because hash_exit called to early */ /* not need locking because all clients is died */ @@ -1498,7 +1497,6 @@ EXPORT_SYMBOL(lprocfs_nid_stats_clear_read); static int lprocfs_nid_stats_clear_write_cb(void *obj, void *data) { struct nid_stat *stat = obj; - ENTRY; CDEBUG(D_INFO,"refcnt %d\n", atomic_read(&stat->nid_exp_ref_count)); if (atomic_read(&stat->nid_exp_ref_count) == 1) { @@ -1543,7 +1541,6 @@ int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int *newnid) proc_dir_entry_t *entry; char *buffer = NULL; int rc = 0; - ENTRY; *newnid = 0; @@ -1910,7 +1907,6 @@ int lprocfs_seq_create(proc_dir_entry_t *parent, void *data) { struct proc_dir_entry *entry; - ENTRY; /* Disallow secretly (un)writable entries. */ LASSERT((seq_fops->write == NULL) == ((mode & 0222) == 0)); diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c index 896f24a8b3b62..9efa8dc255b57 100644 --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c @@ -202,7 +202,6 @@ static struct lu_object *lu_object_alloc(const struct lu_env *env, struct list_head *layers; int clean; int result; - ENTRY; /* * Create top-level object slice. This will also create @@ -980,7 +979,6 @@ int lu_site_init(struct lu_site *s, struct lu_device *top) char name[16]; int bits; int i; - ENTRY; memset(s, 0, sizeof *s); bits = lu_htable_order(); diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c index 69d6499ef7314..de80aea70721c 100644 --- a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c +++ b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c @@ -65,7 +65,6 @@ void class_handle_hash(struct portals_handle *h, struct portals_handle_ops *ops) { struct handle_bucket *bucket; - ENTRY; LASSERT(h != NULL); LASSERT(list_empty(&h->h_link)); @@ -139,7 +138,6 @@ EXPORT_SYMBOL(class_handle_unhash); void class_handle_hash_back(struct portals_handle *h) { struct handle_bucket *bucket; - ENTRY; bucket = handle_hash + (h->h_cookie & HANDLE_HASH_MASK); @@ -157,7 +155,6 @@ void *class_handle2object(__u64 cookie) struct handle_bucket *bucket; struct portals_handle *h; void *retval = NULL; - ENTRY; LASSERT(handle_hash != NULL); diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_peer.c b/drivers/staging/lustre/lustre/obdclass/lustre_peer.c index 2fa2589dc8eb3..81ced81d32af5 100644 --- a/drivers/staging/lustre/lustre/obdclass/lustre_peer.c +++ b/drivers/staging/lustre/lustre/obdclass/lustre_peer.c @@ -191,7 +191,6 @@ int class_check_uuid(struct obd_uuid *uuid, __u64 nid) { struct uuid_nid_data *entry; int found = 0; - ENTRY; CDEBUG(D_INFO, "check if uuid %s has %s.\n", obd_uuid2str(uuid), libcfs_nid2str(nid)); diff --git a/drivers/staging/lustre/lustre/obdclass/md_attrs.c b/drivers/staging/lustre/lustre/obdclass/md_attrs.c index b71344a04c7ee..03795f3cbd714 100644 --- a/drivers/staging/lustre/lustre/obdclass/md_attrs.c +++ b/drivers/staging/lustre/lustre/obdclass/md_attrs.c @@ -99,7 +99,6 @@ EXPORT_SYMBOL(lustre_som_swab); int lustre_buf2som(void *buf, int rc, struct md_som_data *msd) { struct som_attrs *attrs = (struct som_attrs *)buf; - ENTRY; if (rc == 0 || rc == -ENODATA) /* no SOM attributes */ @@ -156,7 +155,6 @@ EXPORT_SYMBOL(lustre_hsm_swab); int lustre_buf2hsm(void *buf, int rc, struct md_hsm *mh) { struct hsm_attrs *attrs = (struct hsm_attrs *)buf; - ENTRY; if (rc == 0 || rc == -ENODATA) /* no HSM attributes */ @@ -188,7 +186,6 @@ EXPORT_SYMBOL(lustre_buf2hsm); void lustre_hsm2buf(void *buf, struct md_hsm *mh) { struct hsm_attrs *attrs = (struct hsm_attrs *)buf; - ENTRY; /* copy HSM attributes */ attrs->hsm_compat = mh->mh_compat; diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c index 8b5eb6c3b078b..278e7d2e103fa 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_config.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c @@ -335,7 +335,6 @@ int class_attach(struct lustre_cfg *lcfg) struct obd_device *obd = NULL; char *typename, *name, *uuid; int rc, len; - ENTRY; if (!LUSTRE_CFG_BUFLEN(lcfg, 1)) { CERROR("No type passed!\n"); @@ -449,7 +448,6 @@ int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg) { int err = 0; struct obd_export *exp; - ENTRY; LASSERT(obd != NULL); LASSERTF(obd == class_num2obd(obd->obd_minor), @@ -572,8 +570,6 @@ EXPORT_SYMBOL(class_setup); */ int class_detach(struct obd_device *obd, struct lustre_cfg *lcfg) { - ENTRY; - if (obd->obd_set_up) { CERROR("OBD device %d still set up\n", obd->obd_minor); RETURN(-EBUSY); @@ -604,7 +600,6 @@ int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg) { int err = 0; char *flag; - ENTRY; OBD_RACE(OBD_FAIL_LDLM_RECOV_CLIENTS); @@ -767,7 +762,6 @@ int class_add_conn(struct obd_device *obd, struct lustre_cfg *lcfg) struct obd_import *imp; struct obd_uuid uuid; int rc; - ENTRY; if (LUSTRE_CFG_BUFLEN(lcfg, 1) < 1 || LUSTRE_CFG_BUFLEN(lcfg, 1) > sizeof(struct obd_uuid)) { @@ -803,7 +797,6 @@ int class_del_conn(struct obd_device *obd, struct lustre_cfg *lcfg) struct obd_import *imp; struct obd_uuid uuid; int rc; - ENTRY; if (LUSTRE_CFG_BUFLEN(lcfg, 1) < 1 || LUSTRE_CFG_BUFLEN(lcfg, 1) > sizeof(struct obd_uuid)) { @@ -834,7 +827,6 @@ struct lustre_profile *class_get_profile(const char * prof) { struct lustre_profile *lprof; - ENTRY; list_for_each_entry(lprof, &lustre_profile_list, lp_list) { if (!strcmp(lprof->lp_profile, prof)) { RETURN(lprof); @@ -853,7 +845,6 @@ int class_add_profile(int proflen, char *prof, int osclen, char *osc, { struct lustre_profile *lprof; int err = 0; - ENTRY; CDEBUG(D_CONFIG, "Add profile %s\n", prof); @@ -899,7 +890,6 @@ int class_add_profile(int proflen, char *prof, int osclen, char *osc, void class_del_profile(const char *prof) { struct lustre_profile *lprof; - ENTRY; CDEBUG(D_CONFIG, "Del profile %s\n", prof); @@ -920,7 +910,6 @@ EXPORT_SYMBOL(class_del_profile); void class_del_profiles(void) { struct lustre_profile *lprof, *n; - ENTRY; list_for_each_entry_safe(lprof, n, &lustre_profile_list, lp_list) { list_del(&lprof->lp_list); @@ -936,7 +925,6 @@ EXPORT_SYMBOL(class_del_profiles); static int class_set_global(char *ptr, int val, struct lustre_cfg *lcfg) { - ENTRY; if (class_match_param(ptr, PARAM_AT_MIN, NULL) == 0) at_min = val; else if (class_match_param(ptr, PARAM_AT_MAX, NULL) == 0) @@ -991,7 +979,6 @@ struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg, char *value = NULL; int name_len = 0; int new_len = 0; - ENTRY; if (cfg == NULL || new_name == NULL) RETURN(ERR_PTR(-EINVAL)); @@ -1244,7 +1231,6 @@ int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars, int matched = 0, j = 0; int rc = 0; int skip = 0; - ENTRY; if (lcfg->lcfg_command != LCFG_PARAM) { CERROR("Unknown command: %d\n", lcfg->lcfg_command); @@ -1335,7 +1321,6 @@ int class_config_llog_handler(const struct lu_env *env, int cfg_len = rec->lrh_len; char *cfg_buf = (char*) (rec + 1); int rc = 0; - ENTRY; //class_config_dump_handler(handle, rec, data); @@ -1527,7 +1512,6 @@ int class_config_parse_llog(const struct lu_env *env, struct llog_ctxt *ctxt, struct llog_handle *llh; llog_cb_t callback; int rc; - ENTRY; CDEBUG(D_INFO, "looking up llog %s\n", name); rc = llog_open(env, ctxt, &llh, NULL, name, LLOG_OPEN_EXISTS); @@ -1574,8 +1558,6 @@ int class_config_parse_rec(struct llog_rec_hdr *rec, char *buf, int size) char *end = buf + size; int rc = 0; - ENTRY; - LASSERT(rec->lrh_type == OBD_CFG_REC); rc = lustre_cfg_sanity_check(lcfg, rec->lrh_len); if (rc < 0) @@ -1620,8 +1602,6 @@ int class_config_dump_handler(const struct lu_env *env, char *outstr; int rc = 0; - ENTRY; - OBD_ALLOC(outstr, 256); if (outstr == NULL) RETURN(-ENOMEM); @@ -1644,8 +1624,6 @@ int class_config_dump_llog(const struct lu_env *env, struct llog_ctxt *ctxt, struct llog_handle *llh; int rc; - ENTRY; - LCONSOLE_INFO("Dumping config log %s\n", name); rc = llog_open(env, ctxt, &llh, NULL, name, LLOG_OPEN_EXISTS); @@ -1674,7 +1652,6 @@ int class_manual_cleanup(struct obd_device *obd) struct lustre_cfg *lcfg; struct lustre_cfg_bufs bufs; int rc; - ENTRY; if (!obd) { CERROR("empty cleanup\n"); diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c b/drivers/staging/lustre/lustre/obdclass/obd_mount.c index 533a49395f328..607dfa7fa6aca 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c @@ -80,7 +80,6 @@ int lustre_process_log(struct super_block *sb, char *logname, struct lustre_sb_info *lsi = s2lsi(sb); struct obd_device *mgc = lsi->lsi_mgc; int rc; - ENTRY; LASSERT(mgc); LASSERT(cfg); @@ -130,7 +129,6 @@ int lustre_end_log(struct super_block *sb, char *logname, struct lustre_sb_info *lsi = s2lsi(sb); struct obd_device *mgc = lsi->lsi_mgc; int rc; - ENTRY; if (!mgc) RETURN(-ENOENT); @@ -223,7 +221,6 @@ int lustre_start_mgc(struct super_block *sb) char *ptr; int recov_bk; int rc = 0, i = 0, j, len; - ENTRY; LASSERT(lsi->lsi_lmd); @@ -485,7 +482,6 @@ static int lustre_stop_mgc(struct super_block *sb) struct obd_device *obd; char *niduuid = 0, *ptr = 0; int i, rc = 0, len = 0; - ENTRY; if (!lsi) RETURN(-ENOENT); @@ -555,7 +551,6 @@ static int lustre_stop_mgc(struct super_block *sb) struct lustre_sb_info *lustre_init_lsi(struct super_block *sb) { struct lustre_sb_info *lsi; - ENTRY; OBD_ALLOC_PTR(lsi); if (!lsi) @@ -582,7 +577,6 @@ struct lustre_sb_info *lustre_init_lsi(struct super_block *sb) static int lustre_free_lsi(struct super_block *sb) { struct lustre_sb_info *lsi = s2lsi(sb); - ENTRY; LASSERT(lsi != NULL); CDEBUG(D_MOUNT, "Freeing lsi %p\n", lsi); @@ -631,7 +625,6 @@ static int lustre_free_lsi(struct super_block *sb) int lustre_put_lsi(struct super_block *sb) { struct lustre_sb_info *lsi = s2lsi(sb); - ENTRY; LASSERT(lsi != NULL); @@ -764,7 +757,6 @@ EXPORT_SYMBOL(server_name2index); int lustre_common_put_super(struct super_block *sb) { int rc; - ENTRY; CDEBUG(D_MOUNT, "dropping sb %p\n", sb); @@ -820,7 +812,6 @@ int lustre_check_exclusion(struct super_block *sb, char *svname) struct lustre_mount_data *lmd = lsi->lsi_lmd; __u32 index; int i, rc; - ENTRY; rc = server_name2index(svname, &index, NULL); if (rc != LDD_F_SV_TYPE_OST) @@ -845,7 +836,6 @@ static int lmd_make_exclusion(struct lustre_mount_data *lmd, const char *ptr) const char *s1 = ptr, *s2; __u32 index, *exclude_list; int rc = 0, devmax; - ENTRY; /* The shortest an ost name can be is 8 chars: -OST0000. We don't actually know the fsname at this time, so in fact @@ -997,7 +987,6 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) char *s1, *s2, *devname = NULL; struct lustre_mount_data *raw = (struct lustre_mount_data *)options; int rc = 0; - ENTRY; LASSERT(lmd); if (!options) { @@ -1204,7 +1193,6 @@ int lustre_fill_super(struct super_block *sb, void *data, int silent) struct lustre_mount_data2 *lmd2 = data; struct lustre_sb_info *lsi; int rc; - ENTRY; CDEBUG(D_MOUNT|D_VFSTRACE, "VFS Op: sb %p\n", sb); diff --git a/drivers/staging/lustre/lustre/obdecho/echo.c b/drivers/staging/lustre/lustre/obdecho/echo.c index 9e64939af9dca..e0f49b083f7f8 100644 --- a/drivers/staging/lustre/lustre/obdecho/echo.c +++ b/drivers/staging/lustre/lustre/obdecho/echo.c @@ -96,8 +96,6 @@ static int echo_init_export(struct obd_export *exp) static int echo_destroy_export(struct obd_export *exp) { - ENTRY; - target_destroy_export(exp); ldlm_destroy_export(exp); @@ -151,7 +149,6 @@ static int echo_destroy(const struct lu_env *env, struct obd_export *exp, { struct obd_device *obd = class_exp2obd(exp); - ENTRY; if (!obd) { CERROR("invalid client cookie "LPX64"\n", exp->exp_handle.h_cookie); @@ -178,7 +175,6 @@ static int echo_getattr(const struct lu_env *env, struct obd_export *exp, struct obd_device *obd = class_exp2obd(exp); obd_id id = ostid_id(&oinfo->oi_oa->o_oi); - ENTRY; if (!obd) { CERROR("invalid client cookie "LPX64"\n", exp->exp_handle.h_cookie); @@ -203,7 +199,6 @@ static int echo_setattr(const struct lu_env *env, struct obd_export *exp, { struct obd_device *obd = class_exp2obd(exp); - ENTRY; if (!obd) { CERROR("invalid client cookie "LPX64"\n", exp->exp_handle.h_cookie); @@ -410,7 +405,6 @@ static int echo_preprw(const struct lu_env *env, int cmd, int tot_bytes = 0; int rc = 0; int i, left; - ENTRY; obd = export->exp_obd; if (obd == NULL) @@ -487,7 +481,6 @@ static int echo_commitrw(const struct lu_env *env, int cmd, struct obd_device *obd; int pgs = 0; int i; - ENTRY; obd = export->exp_obd; if (obd == NULL) @@ -565,7 +558,6 @@ static int echo_setup(struct obd_device *obd, struct lustre_cfg *lcfg) __u64 lock_flags = 0; struct ldlm_res_id res_id = {.name = {1}}; char ns_name[48]; - ENTRY; obd->u.echo.eo_obt.obt_magic = OBT_MAGIC; spin_lock_init(&obd->u.echo.eo_lock); @@ -606,7 +598,6 @@ static int echo_setup(struct obd_device *obd, struct lustre_cfg *lcfg) static int echo_cleanup(struct obd_device *obd) { int leaked; - ENTRY; lprocfs_obd_cleanup(obd); lprocfs_free_obd_stats(obd); diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c index 2e52ef2f92a9b..6fc0396f6cbb0 100644 --- a/drivers/staging/lustre/lustre/obdecho/echo_client.c +++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c @@ -313,7 +313,6 @@ static void echo_page_fini(const struct lu_env *env, struct echo_page *ep = cl2echo_page(slice); struct echo_object *eco = cl2echo_obj(slice->cpl_obj); struct page *vmpage = ep->ep_vmpage; - ENTRY; atomic_dec(&eco->eo_npages); page_cache_release(vmpage); @@ -409,7 +408,6 @@ static int echo_page_init(const struct lu_env *env, struct cl_object *obj, { struct echo_page *ep = cl_object_page_slice(obj, page); struct echo_object *eco = cl2echo_obj(obj); - ENTRY; ep->ep_vmpage = vmpage; page_cache_get(vmpage); @@ -430,7 +428,6 @@ static int echo_lock_init(const struct lu_env *env, const struct cl_io *unused) { struct echo_lock *el; - ENTRY; OBD_SLAB_ALLOC_PTR_GFP(el, echo_lock_kmem, __GFP_IO); if (el != NULL) { @@ -468,7 +465,6 @@ static int echo_object_init(const struct lu_env *env, struct lu_object *obj, struct echo_device *ed = cl2echo_dev(lu2cl_dev(obj->lo_dev)); struct echo_client_obd *ec = ed->ed_ec; struct echo_object *eco = cl2echo_obj(lu2cl(obj)); - ENTRY; if (ed->ed_next) { struct lu_object *below; @@ -511,8 +507,6 @@ static int echo_alloc_memmd(struct echo_device *ed, { int lsm_size; - ENTRY; - /* If export is lov/osc then use their obd method */ if (ed->ed_next != NULL) return obd_alloc_memmd(ed->ed_ec->ec_exp, lsmp); @@ -541,8 +535,6 @@ static int echo_free_memmd(struct echo_device *ed, struct lov_stripe_md **lsmp) { int lsm_size; - ENTRY; - /* If export is lov/osc then use their obd method */ if (ed->ed_next != NULL) return obd_free_memmd(ed->ed_ec->ec_exp, lsmp); @@ -560,7 +552,6 @@ static void echo_object_free(const struct lu_env *env, struct lu_object *obj) { struct echo_object *eco = cl2echo_obj(lu2cl(obj)); struct echo_client_obd *ec = eco->eo_dev->ed_ec; - ENTRY; LASSERT(atomic_read(&eco->eo_npages) == 0); @@ -607,7 +598,6 @@ static struct lu_object *echo_object_alloc(const struct lu_env *env, { struct echo_object *eco; struct lu_object *obj = NULL; - ENTRY; /* we're the top dev. */ LASSERT(hdr == NULL); @@ -738,7 +728,6 @@ static int echo_fid_init(struct echo_device *ed, char *obd_name, { char *prefix; int rc; - ENTRY; OBD_ALLOC_PTR(ed->ed_cl_seq); if (ed->ed_cl_seq == NULL) @@ -770,7 +759,6 @@ static int echo_fid_init(struct echo_device *ed, char *obd_name, static int echo_fid_fini(struct obd_device *obddev) { struct echo_device *ed = obd2echo_dev(obddev); - ENTRY; if (ed->ed_cl_seq != NULL) { seq_client_fini(ed->ed_cl_seq); @@ -793,7 +781,6 @@ static struct lu_device *echo_device_alloc(const struct lu_env *env, const char *tgt_type_name; int rc; int cleanup = 0; - ENTRY; OBD_ALLOC_PTR(ed); if (ed == NULL) @@ -1077,7 +1064,6 @@ static struct echo_object *cl_echo_object_find(struct echo_device *d, struct lu_fid *fid; int refcheck; int rc; - ENTRY; LASSERT(lsmp); lsm = *lsmp; @@ -1140,7 +1126,6 @@ static int cl_echo_object_put(struct echo_object *eco) struct lu_env *env; struct cl_object *obj = echo_obj2cl(eco); int refcheck; - ENTRY; env = cl_env_get(&refcheck); if (IS_ERR(env)) @@ -1168,7 +1153,6 @@ static int cl_echo_enqueue0(struct lu_env *env, struct echo_object *eco, struct cl_lock_descr *descr; struct echo_thread_info *info; int rc = -ENOMEM; - ENTRY; info = echo_env_info(env); io = &info->eti_io; @@ -1213,7 +1197,6 @@ static int cl_echo_enqueue(struct echo_object *eco, obd_off start, obd_off end, struct cl_io *io; int refcheck; int result; - ENTRY; env = cl_env_get(&refcheck); if (IS_ERR(env)) @@ -1244,7 +1227,6 @@ static int cl_echo_cancel0(struct lu_env *env, struct echo_device *ed, struct echo_lock *ecl = NULL; struct list_head *el; int found = 0, still_used = 0; - ENTRY; LASSERT(ec != NULL); spin_lock(&ec->ec_lock); @@ -1274,7 +1256,6 @@ static int cl_echo_cancel(struct echo_device *ed, __u64 cookie) struct lu_env *env; int refcheck; int rc; - ENTRY; env = cl_env_get(&refcheck); if (IS_ERR(env)) @@ -1292,7 +1273,6 @@ static int cl_echo_async_brw(const struct lu_env *env, struct cl_io *io, struct cl_page *clp; struct cl_page *temp; int result = 0; - ENTRY; cl_page_list_for_each_safe(clp, temp, &queue->c2_qin) { int rc; @@ -1319,7 +1299,6 @@ static int cl_echo_object_brw(struct echo_object *eco, int rw, obd_off offset, int refcheck; int rc; int i; - ENTRY; LASSERT((offset & ~CFS_PAGE_MASK) == 0); LASSERT(ed->ed_next != NULL); @@ -1468,8 +1447,6 @@ static int echo_big_lmm_get(const struct lu_env *env, struct md_object *o, struct echo_thread_info *info = echo_env_info(env); int rc; - ENTRY; - LASSERT(ma->ma_lmm_size > 0); rc = mo_xattr_get(env, o, &LU_BUF_NULL, XATTR_NAME_LOV); @@ -1518,8 +1495,6 @@ int echo_attr_get_complex(const struct lu_env *env, struct md_object *next, int need = ma->ma_need; int rc = 0, rc2; - ENTRY; - ma->ma_valid = 0; if (need & MA_INODE) { @@ -1588,8 +1563,6 @@ echo_md_create_internal(const struct lu_env *env, struct echo_device *ed, struct lu_object_conf conf = { .loc_flags = LOC_F_NEW }; int rc; - ENTRY; - rc = mdo_lookup(env, parent, lname, fid2, spec); if (rc == 0) return -EEXIST; @@ -1664,8 +1637,6 @@ static int echo_create_md_object(const struct lu_env *env, int rc = 0; int i; - ENTRY; - if (ec_parent == NULL) return -1; parent = lu_object_locate(ec_parent->lo_header, ld->ld_type); @@ -1732,7 +1703,6 @@ static struct lu_object *echo_md_lookup(const struct lu_env *env, struct lu_fid *fid = &info->eti_fid; struct lu_object *child; int rc; - ENTRY; CDEBUG(D_INFO, "lookup %s in parent "DFID" %p\n", lname->ln_name, PFID(fid), parent); @@ -1764,8 +1734,6 @@ static int echo_setattr_object(const struct lu_env *env, int rc = 0; int i; - ENTRY; - if (ec_parent == NULL) return -1; parent = lu_object_locate(ec_parent->lo_header, ld->ld_type); @@ -1829,8 +1797,6 @@ static int echo_getattr_object(const struct lu_env *env, int rc = 0; int i; - ENTRY; - if (ec_parent == NULL) return -1; parent = lu_object_locate(ec_parent->lo_header, ld->ld_type); @@ -1932,8 +1898,6 @@ static int echo_md_destroy_internal(const struct lu_env *env, struct lu_object *child; int rc; - ENTRY; - ec_child = echo_md_lookup(env, ed, parent, lname); if (IS_ERR(ec_child)) { CERROR("Can't find child %s: rc = %ld\n", lname->ln_name, @@ -1977,7 +1941,6 @@ static int echo_destroy_object(const struct lu_env *env, struct lu_object *parent; int rc = 0; int i; - ENTRY; parent = lu_object_locate(ec_parent->lo_header, ld->ld_type); if (parent == NULL) @@ -2029,7 +1992,6 @@ static struct lu_object *echo_resolve_path(const struct lu_env *env, struct lu_object *parent = NULL; struct lu_object *child = NULL; int rc = 0; - ENTRY; /*Only support MDD layer right now*/ rc = md->md_ops->mdo_root_get(env, md, fid); @@ -2134,7 +2096,6 @@ static int echo_md_handler(struct echo_device *ed, int command, char *name = NULL; int namelen = data->ioc_plen2; int rc = 0; - ENTRY; if (ld == NULL) { CERROR("MD echo client is not being initialized properly\n"); @@ -2248,7 +2209,6 @@ static int echo_create_object(const struct lu_env *env, struct echo_device *ed, struct lov_stripe_md *lsm = NULL; int rc; int created = 0; - ENTRY; if ((oa->o_valid & OBD_MD_FLID) == 0 && /* no obj id */ (on_target || /* set_stripe */ @@ -2338,7 +2298,6 @@ static int echo_get_object(struct echo_object **ecop, struct echo_device *ed, struct lov_stripe_md *lsm = NULL; struct echo_object *eco; int rc; - ENTRY; if ((oa->o_valid & OBD_MD_FLID) == 0 || ostid_id(&oa->o_oi) == 0) { /* disallow use of object id 0 */ @@ -2481,7 +2440,6 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa, int verify; int gfp_mask; int brw_flags = 0; - ENTRY; verify = (ostid_id(&oa->o_oi) != ECHO_PERSISTENT_OBJID && (oa->o_valid & OBD_MD_FLFLAGS) != 0 && @@ -2577,8 +2535,6 @@ static int echo_client_prep_commit(const struct lu_env *env, obd_size npages, tot_pages; int i, ret = 0, brw_flags = 0; - ENTRY; - if (count <= 0 || (count & (~CFS_PAGE_MASK)) != 0 || (lsm != NULL && ostid_id(&lsm->lsm_oi) != ostid_id(&oa->o_oi))) RETURN(-EINVAL); @@ -2682,7 +2638,6 @@ static int echo_client_brw_ioctl(const struct lu_env *env, int rw, int rc; int async = 1; long test_mode; - ENTRY; LASSERT(oa->o_valid & OBD_MD_FLGROUP); @@ -2736,7 +2691,6 @@ echo_client_enqueue(struct obd_export *exp, struct obdo *oa, struct echo_object *eco; obd_off end; int rc; - ENTRY; if (ed->ed_next == NULL) RETURN(-EOPNOTSUPP); @@ -2792,7 +2746,6 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len, int rw = OBD_BRW_READ; int rc = 0; int i; - ENTRY; memset(&dummy_oti, 0, sizeof(dummy_oti)); @@ -3009,7 +2962,6 @@ static int echo_client_setup(const struct lu_env *env, struct obd_uuid echo_uuid = { "ECHO_UUID" }; struct obd_connect_data *ocd = NULL; int rc; - ENTRY; if (lcfg->lcfg_bufcount < 2 || LUSTRE_CFG_BUFLEN(lcfg, 1) < 1) { CERROR("requires a TARGET OBD name\n"); @@ -3075,7 +3027,6 @@ static int echo_client_cleanup(struct obd_device *obddev) struct echo_device *ed = obd2echo_dev(obddev); struct echo_client_obd *ec = &obddev->u.echo_client; int rc; - ENTRY; /*Do nothing for Metadata echo client*/ if (ed == NULL ) @@ -3108,7 +3059,6 @@ static int echo_client_connect(const struct lu_env *env, int rc; struct lustre_handle conn = { 0 }; - ENTRY; rc = class_connect(&conn, src, cluuid); if (rc == 0) { *exp = class_conn2export(&conn); @@ -3125,7 +3075,6 @@ static int echo_client_disconnect(struct obd_export *exp) struct ec_lock *ecl; #endif int rc; - ENTRY; if (exp == NULL) GOTO(out, rc = -EINVAL); @@ -3200,7 +3149,6 @@ static int __init obdecho_init(void) struct lprocfs_static_vars lvars; int rc; - ENTRY; LCONSOLE_INFO("Echo OBD driver; http://www.lustre.org/\n"); LASSERT(PAGE_CACHE_SIZE % OBD_ECHO_BLOCK_SIZE == 0); diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index 6b0a842dfca0b..3e71f41bbb5ea 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -540,7 +540,6 @@ int osc_extent_release(const struct lu_env *env, struct osc_extent *ext) { struct osc_object *obj = ext->oe_obj; int rc = 0; - ENTRY; LASSERT(atomic_read(&ext->oe_users) > 0); LASSERT(sanity_check(ext) == 0); @@ -602,7 +601,6 @@ struct osc_extent *osc_extent_find(const struct lu_env *env, int ppc_bits; /* pages per chunk bits */ int chunk_mask; int rc; - ENTRY; cur = osc_extent_alloc(obj); if (cur == NULL) @@ -805,7 +803,6 @@ int osc_extent_finish(const struct lu_env *env, struct osc_extent *ext, int blocksize = cli->cl_import->imp_obd->obd_osfs.os_bsize ? : 4096; __u64 last_off = 0; int last_count = -1; - ENTRY; OSC_EXTENT_DUMP(D_CACHE, ext, "extent finished.\n"); @@ -870,7 +867,6 @@ static int osc_extent_wait(const struct lu_env *env, struct osc_extent *ext, struct l_wait_info lwi = LWI_TIMEOUT_INTR(cfs_time_seconds(600), NULL, LWI_ON_SIGNAL_NOOP, NULL); int rc = 0; - ENTRY; osc_object_lock(obj); LASSERT(sanity_check_nolock(ext) == 0); @@ -925,7 +921,6 @@ static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index, int grants = 0; int nr_pages = 0; int rc = 0; - ENTRY; LASSERT(sanity_check(ext) == 0); LASSERT(ext->oe_state == OES_TRUNC); @@ -1036,7 +1031,6 @@ static int osc_extent_make_ready(const struct lu_env *env, struct osc_object *obj = ext->oe_obj; int page_count = 0; int rc; - ENTRY; /* we're going to grab page lock, so object lock must not be taken. */ LASSERT(sanity_check(ext) == 0); @@ -1115,7 +1109,6 @@ static int osc_extent_expand(struct osc_extent *ext, pgoff_t index, int *grants) pgoff_t end_index; int chunksize = 1 << cli->cl_chunkbits; int rc = 0; - ENTRY; LASSERT(ext->oe_max_end >= index && ext->oe_start <= index); osc_object_lock(obj); @@ -1207,7 +1200,6 @@ static int osc_make_ready(const struct lu_env *env, struct osc_async_page *oap, LASSERT(cmd == OBD_BRW_WRITE); /* no cached reads */ - ENTRY; result = cl_page_make_ready(env, page, CRT_WRITE); if (result == 0) opg->ops_submit_time = cfs_time_current(); @@ -1255,8 +1247,6 @@ static int osc_completion(const struct lu_env *env, struct osc_async_page *oap, enum cl_req_type crt; int srvlock; - ENTRY; - cmd &= ~OBD_BRW_NOQUOTA; LASSERT(equi(page->cp_state == CPS_PAGEIN, cmd == OBD_BRW_READ)); LASSERT(equi(page->cp_state == CPS_PAGEOUT, cmd == OBD_BRW_WRITE)); @@ -1338,8 +1328,6 @@ static void osc_consume_write_grant(struct client_obd *cli, static void osc_release_write_grant(struct client_obd *cli, struct brw_page *pga) { - ENTRY; - LASSERT(spin_is_locked(&cli->cl_loi_list_lock.lock)); if (!(pga->flag & OBD_BRW_FROM_GRANT)) { EXIT; @@ -1503,7 +1491,6 @@ static int osc_enter_cache(const struct lu_env *env, struct client_obd *cli, struct osc_cache_waiter ocw; struct l_wait_info lwi = LWI_INTR(LWI_ON_SIGNAL_NOOP, NULL); int rc = -EDQUOT; - ENTRY; OSC_DUMP_GRANT(cli, "need:%d.\n", bytes); @@ -1570,7 +1557,6 @@ void osc_wake_cache_waiters(struct client_obd *cli) struct list_head *l, *tmp; struct osc_cache_waiter *ocw; - ENTRY; list_for_each_safe(l, tmp, &cli->cl_cache_waiters) { ocw = list_entry(l, struct osc_cache_waiter, ocw_entry); list_del_init(&ocw->ocw_entry); @@ -1613,7 +1599,6 @@ static int osc_makes_rpc(struct client_obd *cli, struct osc_object *osc, int cmd) { int invalid_import = 0; - ENTRY; /* if we have an invalid import we want to drain the queued pages * by forcing them through rpcs that immediately fail and complete @@ -1757,7 +1742,6 @@ static void osc_ap_completion(const struct lu_env *env, struct client_obd *cli, struct lov_oinfo *loi = osc->oo_oinfo; __u64 xid = 0; - ENTRY; if (oap->oap_request != NULL) { xid = ptlrpc_req_xid(oap->oap_request); ptlrpc_req_finished(oap->oap_request); @@ -1795,7 +1779,6 @@ static int try_to_add_extent_for_io(struct client_obd *cli, int *pc, unsigned int *max_pages) { struct osc_extent *tmp; - ENTRY; EASSERT((ext->oe_state == OES_CACHE || ext->oe_state == OES_LOCK_DONE), ext); @@ -1913,7 +1896,6 @@ osc_send_write_rpc(const struct lu_env *env, struct client_obd *cli, obd_count page_count = 0; int srvlock = 0; int rc = 0; - ENTRY; LASSERT(osc_object_is_locked(osc)); @@ -1985,7 +1967,6 @@ osc_send_read_rpc(const struct lu_env *env, struct client_obd *cli, int page_count = 0; unsigned int max_pages = cli->cl_max_pages_per_rpc; int rc = 0; - ENTRY; LASSERT(osc_object_is_locked(osc)); list_for_each_entry_safe(ext, next, @@ -2023,8 +2004,6 @@ osc_send_read_rpc(const struct lu_env *env, struct client_obd *cli, * we could be sending. These lists are maintained by osc_makes_rpc(). */ static struct osc_object *osc_next_obj(struct client_obd *cli) { - ENTRY; - /* First return objects that have blocked locks so that they * will be flushed quickly and other clients can get the lock, * then objects which have pages ready to be stuffed into RPCs */ @@ -2060,7 +2039,6 @@ static void osc_check_rpcs(const struct lu_env *env, struct client_obd *cli, { struct osc_object *osc; int rc = 0; - ENTRY; while ((osc = osc_next_obj(cli)) != NULL) { struct cl_object *obj = osc2cl(osc); @@ -2167,7 +2145,6 @@ int osc_prep_async_page(struct osc_object *osc, struct osc_page *ops, { struct obd_export *exp = osc_export(osc); struct osc_async_page *oap = &ops->ops_oap; - ENTRY; if (!page) return cfs_size_round(sizeof(*oap)); @@ -2206,7 +2183,6 @@ int osc_queue_async_io(const struct lu_env *env, struct cl_io *io, int cmd = OBD_BRW_WRITE; int need_release = 0; int rc = 0; - ENTRY; if (oap->oap_magic != OAP_MAGIC) RETURN(-EINVAL); @@ -2361,7 +2337,6 @@ int osc_teardown_async_page(const struct lu_env *env, struct osc_async_page *oap = &ops->ops_oap; struct osc_extent *ext = NULL; int rc = 0; - ENTRY; LASSERT(oap->oap_magic == OAP_MAGIC); @@ -2406,7 +2381,6 @@ int osc_flush_async_page(const struct lu_env *env, struct cl_io *io, struct osc_async_page *oap = &ops->ops_oap; bool unplug = false; int rc = 0; - ENTRY; osc_object_lock(obj); ext = osc_extent_lookup(obj, index); @@ -2484,7 +2458,6 @@ int osc_cancel_async_page(const struct lu_env *env, struct osc_page *ops) pgoff_t index = oap2cl_page(oap)->cp_index; int rc = -EBUSY; int cmd; - ENTRY; LASSERT(!oap->oap_interrupted); oap->oap_interrupted = 1; @@ -2541,7 +2514,6 @@ int osc_queue_sync_pages(const struct lu_env *env, struct osc_object *obj, int mppr = cli->cl_max_pages_per_rpc; pgoff_t start = CL_PAGE_EOF; pgoff_t end = 0; - ENTRY; list_for_each_entry(oap, list, oap_pending_item) { struct cl_page *cp = oap2cl_page(oap); @@ -2601,7 +2573,6 @@ int osc_cache_truncate_start(const struct lu_env *env, struct osc_io *oio, LIST_HEAD(list); int result = 0; bool partial; - ENTRY; /* pages with index greater or equal to index will be truncated. */ index = cl_index(osc2cl(obj), size); @@ -2758,7 +2729,6 @@ int osc_cache_wait_range(const struct lu_env *env, struct osc_object *obj, struct osc_extent *ext; pgoff_t index = start; int result = 0; - ENTRY; again: osc_object_lock(obj); @@ -2815,7 +2785,6 @@ int osc_cache_writeback_range(const struct lu_env *env, struct osc_object *obj, LIST_HEAD(discard_list); bool unplug = false; int result = 0; - ENTRY; osc_object_lock(obj); ext = osc_extent_search(obj, start); diff --git a/drivers/staging/lustre/lustre/osc/osc_dev.c b/drivers/staging/lustre/lustre/osc/osc_dev.c index 4208ddfd73b30..4059591f25b06 100644 --- a/drivers/staging/lustre/lustre/osc/osc_dev.c +++ b/drivers/staging/lustre/lustre/osc/osc_dev.c @@ -171,7 +171,6 @@ LU_TYPE_INIT_FINI(osc, &osc_key, &osc_session_key); static int osc_cl_process_config(const struct lu_env *env, struct lu_device *d, struct lustre_cfg *cfg) { - ENTRY; RETURN(osc_process_config_base(d->ld_obd, cfg)); } diff --git a/drivers/staging/lustre/lustre/osc/osc_io.c b/drivers/staging/lustre/lustre/osc/osc_io.c index 342c46e2c91d3..60e5c9d5cfa08 100644 --- a/drivers/staging/lustre/lustre/osc/osc_io.c +++ b/drivers/staging/lustre/lustre/osc/osc_io.c @@ -261,7 +261,6 @@ static int osc_io_prepare_write(const struct lu_env *env, struct obd_import *imp = class_exp2cliimp(dev->od_exp); struct osc_io *oio = cl2osc_io(env, ios); int result = 0; - ENTRY; /* * This implements OBD_BRW_CHECK logic from old client. @@ -288,7 +287,6 @@ static int osc_io_commit_write(const struct lu_env *env, struct osc_page *opg = cl2osc_page(slice); struct osc_object *obj = cl2osc(opg->ops_cl.cpl_obj); struct osc_async_page *oap = &opg->ops_oap; - ENTRY; LASSERT(to > 0); /* @@ -315,8 +313,6 @@ static int osc_io_fault_start(const struct lu_env *env, struct cl_io *io; struct cl_fault_io *fio; - ENTRY; - io = ios->cis_io; fio = &io->u.ci_fault; CDEBUG(D_INFO, "%lu %d %d\n", @@ -517,7 +513,6 @@ static int osc_io_read_start(const struct lu_env *env, struct cl_object *obj = slice->cis_obj; struct cl_attr *attr = &osc_env_info(env)->oti_attr; int result = 0; - ENTRY; if (oio->oi_lockless == 0) { cl_object_attr_lock(obj); @@ -539,7 +534,6 @@ static int osc_io_write_start(const struct lu_env *env, struct cl_object *obj = slice->cis_obj; struct cl_attr *attr = &osc_env_info(env)->oti_attr; int result = 0; - ENTRY; if (oio->oi_lockless == 0) { OBD_FAIL_TIMEOUT(OBD_FAIL_OSC_DELAY_SETTIME, 1); @@ -565,7 +559,6 @@ static int osc_fsync_ost(const struct lu_env *env, struct osc_object *obj, struct lov_oinfo *loi = obj->oo_oinfo; struct osc_async_cbargs *cbargs = &oio->oi_cbarg; int rc = 0; - ENTRY; memset(oa, 0, sizeof(*oa)); oa->o_oi = loi->loi_oi; @@ -598,7 +591,6 @@ static int osc_io_fsync_start(const struct lu_env *env, pgoff_t start = cl_index(obj, fio->fi_start); pgoff_t end = cl_index(obj, fio->fi_end); int result = 0; - ENTRY; if (fio->fi_end == OBD_OBJECT_EOF) end = CL_PAGE_EOF; diff --git a/drivers/staging/lustre/lustre/osc/osc_lock.c b/drivers/staging/lustre/lustre/osc/osc_lock.c index 98478d24f9be2..a13215dd4a9e9 100644 --- a/drivers/staging/lustre/lustre/osc/osc_lock.c +++ b/drivers/staging/lustre/lustre/osc/osc_lock.c @@ -343,8 +343,6 @@ static void osc_lock_lvb_update(const struct lu_env *env, struct osc_lock *olck, struct cl_attr *attr; unsigned valid; - ENTRY; - if (!(olck->ols_flags & LDLM_FL_LVB_READY)) RETURN_EXIT; @@ -412,7 +410,6 @@ static void osc_lock_granted(const struct lu_env *env, struct osc_lock *olck, LASSERT(dlmlock->l_granted_mode == dlmlock->l_req_mode); - ENTRY; if (olck->ols_state < OLS_GRANTED) { lock = olck->ols_cl.cls_lock; ext = &dlmlock->l_policy_data.l_extent; @@ -450,8 +447,6 @@ static void osc_lock_upcall0(const struct lu_env *env, struct osc_lock *olck) { struct ldlm_lock *dlmlock; - ENTRY; - dlmlock = ldlm_handle2lock_long(&olck->ols_handle, 0); LASSERT(dlmlock != NULL); @@ -497,7 +492,6 @@ static int osc_lock_upcall(void *cookie, int errcode) struct lu_env *env; struct cl_env_nest nest; - ENTRY; env = cl_env_nested_get(&nest); if (!IS_ERR(env)) { int rc; @@ -1023,7 +1017,6 @@ static int osc_lock_enqueue_wait(const struct lu_env *env, struct cl_lock *conflict= NULL; int lockless = osc_lock_is_lockless(olck); int rc = 0; - ENTRY; LASSERT(cl_lock_is_mutexed(lock)); @@ -1118,7 +1111,6 @@ static int osc_lock_enqueue(const struct lu_env *env, struct osc_lock *ols = cl2osc_lock(slice); struct cl_lock *lock = ols->ols_cl.cls_lock; int result; - ENTRY; LASSERT(cl_lock_is_mutexed(lock)); LASSERTF(ols->ols_state == OLS_NEW, @@ -1262,7 +1254,6 @@ static int osc_lock_flush(struct osc_lock *ols, int discard) struct cl_env_nest nest; struct lu_env *env; int result = 0; - ENTRY; env = cl_env_nested_get(&nest); if (!IS_ERR(env)) { diff --git a/drivers/staging/lustre/lustre/osc/osc_object.c b/drivers/staging/lustre/lustre/osc/osc_object.c index ca94e63313817..5d6c7630784c4 100644 --- a/drivers/staging/lustre/lustre/osc/osc_object.c +++ b/drivers/staging/lustre/lustre/osc/osc_object.c @@ -191,7 +191,6 @@ static int osc_object_glimpse(const struct lu_env *env, { struct lov_oinfo *oinfo = cl2osc(obj)->oo_oinfo; - ENTRY; lvb->lvb_size = oinfo->loi_kms; lvb->lvb_blocks = oinfo->loi_lvb.lvb_blocks; RETURN(0); diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c index baba959a74504..5f51dfa3a3e02 100644 --- a/drivers/staging/lustre/lustre/osc/osc_page.c +++ b/drivers/staging/lustre/lustre/osc/osc_page.c @@ -219,7 +219,6 @@ static int osc_page_cache_add(const struct lu_env *env, struct osc_io *oio = osc_env_io(env); struct osc_page *opg = cl2osc_page(slice); int result; - ENTRY; LINVRNT(osc_page_protected(env, opg, CLM_WRITE, 0)); @@ -294,7 +293,6 @@ static int osc_page_is_under_lock(const struct lu_env *env, struct cl_lock *lock; int result = -ENODATA; - ENTRY; lock = cl_lock_at_page(env, slice->cpl_obj, slice->cpl_page, NULL, 1, 0); if (lock != NULL) { @@ -421,7 +419,6 @@ static void osc_page_delete(const struct lu_env *env, LINVRNT(opg->ops_temp || osc_page_protected(env, opg, CLM_READ, 1)); - ENTRY; CDEBUG(D_TRACE, "%p\n", opg); osc_page_transfer_put(env, opg); rc = osc_teardown_async_page(env, obj, opg); @@ -481,7 +478,7 @@ static int osc_page_flush(const struct lu_env *env, { struct osc_page *opg = cl2osc_page(slice); int rc = 0; - ENTRY; + rc = osc_flush_async_page(env, io, opg); RETURN(rc); } @@ -666,7 +663,6 @@ int osc_lru_shrink(struct client_obd *cli, int target) int count = 0; int index = 0; int rc = 0; - ENTRY; LASSERT(atomic_read(&cli->cl_lru_in_list) >= 0); if (atomic_read(&cli->cl_lru_in_list) == 0 || target <= 0) @@ -881,7 +877,6 @@ static int osc_lru_reserve(const struct lu_env *env, struct osc_object *obj, struct l_wait_info lwi = LWI_INTR(LWI_ON_SIGNAL_NOOP, NULL); struct client_obd *cli = osc_cli(obj); int rc = 0; - ENTRY; if (cli->cl_cache == NULL) /* shall not be in LRU */ RETURN(0); diff --git a/drivers/staging/lustre/lustre/osc/osc_quota.c b/drivers/staging/lustre/lustre/osc/osc_quota.c index 69caab76ced32..b178e213eecdf 100644 --- a/drivers/staging/lustre/lustre/osc/osc_quota.c +++ b/drivers/staging/lustre/lustre/osc/osc_quota.c @@ -45,7 +45,6 @@ static inline struct osc_quota_info *osc_oqi_alloc(obd_uid id) int osc_quota_chkdq(struct client_obd *cli, const unsigned int qid[]) { int type; - ENTRY; for (type = 0; type < MAXQUOTAS; type++) { struct osc_quota_info *oqi; @@ -79,7 +78,6 @@ int osc_quota_setdq(struct client_obd *cli, const unsigned int qid[], { int type; int rc = 0; - ENTRY; if ((valid & (OBD_MD_FLUSRQUOTA | OBD_MD_FLGRPQUOTA)) == 0) RETURN(0); @@ -211,7 +209,6 @@ int osc_quota_setup(struct obd_device *obd) { struct client_obd *cli = &obd->u.cli; int i, type; - ENTRY; for (type = 0; type < MAXQUOTAS; type++) { cli->cl_quota_hash[type] = cfs_hash_create("QUOTA_HASH", @@ -240,7 +237,6 @@ int osc_quota_cleanup(struct obd_device *obd) { struct client_obd *cli = &obd->u.cli; int type; - ENTRY; for (type = 0; type < MAXQUOTAS; type++) cfs_hash_putref(cli->cl_quota_hash[type]); @@ -254,7 +250,6 @@ int osc_quotactl(struct obd_device *unused, struct obd_export *exp, struct ptlrpc_request *req; struct obd_quotactl *oqc; int rc; - ENTRY; req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_OST_QUOTACTL, LUSTRE_OST_VERSION, @@ -292,7 +287,6 @@ int osc_quotacheck(struct obd_device *unused, struct obd_export *exp, struct ptlrpc_request *req; struct obd_quotactl *body; int rc; - ENTRY; req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_OST_QUOTACHECK, LUSTRE_OST_VERSION, @@ -319,7 +313,6 @@ int osc_quota_poll_check(struct obd_export *exp, struct if_quotacheck *qchk) { struct client_obd *cli = &exp->exp_obd->u.cli; int rc; - ENTRY; qchk->obd_uuid = cli->cl_target_uuid; memcpy(qchk->obd_type, LUSTRE_OST_NAME, strlen(LUSTRE_OST_NAME)); diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index fea04ca8ba6a8..a27bbb5c1240c 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -69,7 +69,6 @@ static int osc_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, struct lov_stripe_md *lsm) { int lmm_size; - ENTRY; lmm_size = sizeof(**lmmp); if (lmmp == NULL) @@ -101,7 +100,6 @@ static int osc_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, { int lsm_size; struct obd_import *imp = class_exp2cliimp(exp); - ENTRY; if (lmm != NULL) { if (lmm_bytes < sizeof(*lmm)) { @@ -202,7 +200,6 @@ static int osc_getattr_interpret(const struct lu_env *env, struct osc_async_args *aa, int rc) { struct ost_body *body; - ENTRY; if (rc != 0) GOTO(out, rc); @@ -232,7 +229,6 @@ static int osc_getattr_async(struct obd_export *exp, struct obd_info *oinfo, struct ptlrpc_request *req; struct osc_async_args *aa; int rc; - ENTRY; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_GETATTR); if (req == NULL) @@ -264,7 +260,6 @@ static int osc_getattr(const struct lu_env *env, struct obd_export *exp, struct ptlrpc_request *req; struct ost_body *body; int rc; - ENTRY; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_GETATTR); if (req == NULL) @@ -308,7 +303,6 @@ static int osc_setattr(const struct lu_env *env, struct obd_export *exp, struct ptlrpc_request *req; struct ost_body *body; int rc; - ENTRY; LASSERT(oinfo->oi_oa->o_valid & OBD_MD_FLGROUP); @@ -349,7 +343,6 @@ static int osc_setattr_interpret(const struct lu_env *env, struct osc_setattr_args *sa, int rc) { struct ost_body *body; - ENTRY; if (rc != 0) GOTO(out, rc); @@ -373,7 +366,6 @@ int osc_setattr_async_base(struct obd_export *exp, struct obd_info *oinfo, struct ptlrpc_request *req; struct osc_setattr_args *sa; int rc; - ENTRY; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_SETATTR); if (req == NULL) @@ -431,7 +423,6 @@ int osc_real_create(struct obd_export *exp, struct obdo *oa, struct ost_body *body; struct lov_stripe_md *lsm; int rc; - ENTRY; LASSERT(oa); LASSERT(ea); @@ -517,7 +508,6 @@ int osc_punch_base(struct obd_export *exp, struct obd_info *oinfo, struct osc_setattr_args *sa; struct ost_body *body; int rc; - ENTRY; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_PUNCH); if (req == NULL) @@ -571,7 +561,6 @@ static int osc_sync_interpret(const struct lu_env *env, { struct osc_fsync_args *fa = arg; struct ost_body *body; - ENTRY; if (rc) GOTO(out, rc); @@ -596,7 +585,6 @@ int osc_sync_base(struct obd_export *exp, struct obd_info *oinfo, struct ost_body *body; struct osc_fsync_args *fa; int rc; - ENTRY; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_SYNC); if (req == NULL) @@ -637,8 +625,6 @@ static int osc_sync(const struct lu_env *env, struct obd_export *exp, struct obd_info *oinfo, obd_size start, obd_size end, struct ptlrpc_request_set *set) { - ENTRY; - if (!oinfo->oi_oa) { CDEBUG(D_INFO, "oa NULL\n"); RETURN(-EINVAL); @@ -662,7 +648,6 @@ static int osc_resource_get_unused(struct obd_export *exp, struct obdo *oa, struct ldlm_res_id res_id; struct ldlm_resource *res; int count; - ENTRY; /* Return, i.e. cancel nothing, only if ELC is supported (flag in * export) but disabled through procfs (flag in NS). @@ -720,7 +705,6 @@ int osc_create(const struct lu_env *env, struct obd_export *exp, struct obd_trans_info *oti) { int rc = 0; - ENTRY; LASSERT(oa); LASSERT(ea); @@ -760,7 +744,6 @@ static int osc_destroy(const struct lu_env *env, struct obd_export *exp, struct ost_body *body; LIST_HEAD(cancels); int rc, count; - ENTRY; if (!oa) { CDEBUG(D_INFO, "oa NULL\n"); @@ -948,7 +931,6 @@ int osc_shrink_grant_to_target(struct client_obd *cli, __u64 target_bytes) { int rc = 0; struct ost_body *body; - ENTRY; client_obd_list_lock(&cli->cl_loi_list_lock); /* Don't shrink if we are already above or below the desired limit @@ -1256,7 +1238,6 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,struct obdo *oa, struct req_capsule *pill; struct brw_page *pg_prev; - ENTRY; if (OBD_FAIL_CHECK(OBD_FAIL_OSC_BRW_PREP_REQ)) RETURN(-ENOMEM); /* Recoverable */ if (OBD_FAIL_CHECK(OBD_FAIL_OSC_BRW_PREP_REQ2)) @@ -1496,7 +1477,6 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, int rc) struct client_obd *cli = aa->aa_cli; struct ost_body *body; __u32 client_cksum = 0; - ENTRY; if (rc < 0 && rc != -EDQUOT) { DEBUG_REQ(D_INFO, req, "Failed request with rc = %d\n", rc); @@ -1655,8 +1635,6 @@ static int osc_brw_internal(int cmd, struct obd_export *exp, struct obdo *oa, int generation, resends = 0; struct l_wait_info lwi; - ENTRY; - init_waitqueue_head(&waitq); generation = exp->exp_obd->u.cli.cl_import->imp_generation; @@ -1720,7 +1698,6 @@ static int osc_brw_redo_request(struct ptlrpc_request *request, struct ptlrpc_request *new_req; struct osc_brw_async_args *new_aa; struct osc_async_page *oap; - ENTRY; DEBUG_REQ(rc == -EINPROGRESS ? D_RPCTRACE : D_ERROR, request, "redo for recoverable error %d", rc); @@ -1873,7 +1850,6 @@ static int osc_brw(int cmd, struct obd_export *exp, struct obd_info *oinfo, struct obd_import *imp = class_exp2cliimp(exp); struct client_obd *cli; int rc, page_count_orig; - ENTRY; LASSERT((imp != NULL) && (imp->imp_obd != NULL)); cli = &imp->imp_obd->u.cli; @@ -1946,7 +1922,6 @@ static int brw_interpret(const struct lu_env *env, struct osc_extent *tmp; struct cl_object *obj = NULL; struct client_obd *cli = aa->aa_cli; - ENTRY; rc = osc_brw_fini_request(req, rc); CDEBUG(D_INODE, "request %p aa %p rc %d\n", req, aa, rc); @@ -2072,7 +2047,6 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, int rc; LIST_HEAD(rpc_list); - ENTRY; LASSERT(!list_empty(ext_list)); /* add pages into rpc_list to build BRW rpc */ @@ -2337,7 +2311,6 @@ static int osc_enqueue_fini(struct ptlrpc_request *req, struct ost_lvb *lvb, __u64 *flags, int agl, int rc) { int intent = *flags & LDLM_FL_HAS_INTENT; - ENTRY; if (intent) { /* The request was created before ldlm_cli_enqueue call. */ @@ -2496,7 +2469,6 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id, int match_lvb = (agl != 0 ? 0 : LDLM_FL_LVB_READY); ldlm_mode_t mode; int rc; - ENTRY; /* Filesystem lock extents are extended to page boundaries so that * dealing with the page cache is a little smoother. */ @@ -2633,7 +2605,6 @@ static int osc_enqueue(struct obd_export *exp, struct obd_info *oinfo, { struct ldlm_res_id res_id; int rc; - ENTRY; ostid_build_res_name(&oinfo->oi_md->lsm_oi, &res_id); rc = osc_enqueue_base(exp, &res_id, &oinfo->oi_flags, &oinfo->oi_policy, @@ -2652,7 +2623,6 @@ int osc_match_base(struct obd_export *exp, struct ldlm_res_id *res_id, struct obd_device *obd = exp->exp_obd; int lflags = *flags; ldlm_mode_t rc; - ENTRY; if (OBD_FAIL_CHECK(OBD_FAIL_OSC_MATCH)) RETURN(-EIO); @@ -2690,8 +2660,6 @@ int osc_match_base(struct obd_export *exp, struct ldlm_res_id *res_id, int osc_cancel_base(struct lustre_handle *lockh, __u32 mode) { - ENTRY; - if (unlikely(mode == LCK_GROUP)) ldlm_lock_decref_and_cancel(lockh, mode); else @@ -2703,7 +2671,6 @@ int osc_cancel_base(struct lustre_handle *lockh, __u32 mode) static int osc_cancel(struct obd_export *exp, struct lov_stripe_md *md, __u32 mode, struct lustre_handle *lockh) { - ENTRY; RETURN(osc_cancel_base(lockh, mode)); } @@ -2728,7 +2695,6 @@ static int osc_statfs_interpret(const struct lu_env *env, struct osc_async_args *aa, int rc) { struct obd_statfs *msfs; - ENTRY; if (rc == -EBADR) /* The request has in fact never been sent @@ -2764,7 +2730,6 @@ static int osc_statfs_async(struct obd_export *exp, struct ptlrpc_request *req; struct osc_async_args *aa; int rc; - ENTRY; /* We could possibly pass max_age in the request (as an absolute * timestamp or a "seconds.usec ago") so the target can avoid doing @@ -2808,7 +2773,6 @@ static int osc_statfs(const struct lu_env *env, struct obd_export *exp, struct ptlrpc_request *req; struct obd_import *imp = NULL; int rc; - ENTRY; /*Since the request might also come from lprocfs, so we need *sync this with client_disconnect_export Bug15684*/ @@ -2876,7 +2840,6 @@ static int osc_getstripe(struct lov_stripe_md *lsm, struct lov_user_md *lump) struct lov_user_md_v3 lum, *lumk; struct lov_user_ost_data_v1 *lmm_objects; int rc = 0, lum_size; - ENTRY; if (!lsm) RETURN(-ENODATA); @@ -2934,7 +2897,6 @@ static int osc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, struct obd_device *obd = exp->exp_obd; struct obd_ioctl_data *data = karg; int err = 0; - ENTRY; if (!try_module_get(THIS_MODULE)) { CERROR("Can't get module. Is it alive?"); @@ -3018,7 +2980,6 @@ static int osc_get_info(const struct lu_env *env, struct obd_export *exp, obd_count keylen, void *key, __u32 *vallen, void *val, struct lov_stripe_md *lsm) { - ENTRY; if (!vallen || !val) RETURN(-EFAULT); @@ -3159,7 +3120,6 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp, struct obd_import *imp = class_exp2cliimp(exp); char *tmp; int rc; - ENTRY; OBD_FAIL_TIMEOUT(OBD_FAIL_OSC_SHUTDOWN, 10); @@ -3282,8 +3242,6 @@ static int osc_llog_finish(struct obd_device *obd, int count) { struct llog_ctxt *ctxt; - ENTRY; - ctxt = llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT); if (ctxt) { llog_cat_close(NULL, ctxt->loc_handle); @@ -3371,7 +3329,6 @@ static int osc_import_event(struct obd_device *obd, struct client_obd *cli; int rc = 0; - ENTRY; LASSERT(imp->imp_obd == obd); switch (event) { @@ -3480,7 +3437,6 @@ int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) struct client_obd *cli = &obd->u.cli; void *handler; int rc; - ENTRY; rc = ptlrpcd_addref(); if (rc) @@ -3533,7 +3489,6 @@ int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) static int osc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) { int rc = 0; - ENTRY; switch (stage) { case OBD_CLEANUP_EARLY: { @@ -3580,8 +3535,6 @@ int osc_cleanup(struct obd_device *obd) struct client_obd *cli = &obd->u.cli; int rc; - ENTRY; - /* lru cleanup */ if (cli->cl_cache != NULL) { LASSERT(atomic_read(&cli->cl_cache->ccc_users) > 0); @@ -3673,7 +3626,6 @@ int __init osc_init(void) { struct lprocfs_static_vars lvars = { 0 }; int rc; - ENTRY; /* print an address of _any_ initialized kernel symbol from this * module, to allow debugging with gdb that doesn't support data diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c index 22f7e654c9d8b..b860db61e854e 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c @@ -137,7 +137,6 @@ struct ptlrpc_bulk_desc *ptlrpc_prep_bulk_imp(struct ptlrpc_request *req, struct obd_import *imp = req->rq_import; struct ptlrpc_bulk_desc *desc; - ENTRY; LASSERT(type == BULK_PUT_SINK || type == BULK_GET_SOURCE); desc = ptlrpc_new_bulk(npages, max_brw, type, portal); if (desc == NULL) @@ -187,7 +186,6 @@ EXPORT_SYMBOL(__ptlrpc_prep_bulk_page); void __ptlrpc_free_bulk(struct ptlrpc_bulk_desc *desc, int unpin) { int i; - ENTRY; LASSERT(desc != NULL); LASSERT(desc->bd_iov_count != LI_POISON); /* not freed already */ @@ -336,7 +334,6 @@ static int ptlrpc_at_recv_early_reply(struct ptlrpc_request *req) struct ptlrpc_request *early_req; time_t olddl; int rc; - ENTRY; req->rq_early = 0; spin_unlock(&req->rq_lock); @@ -547,7 +544,6 @@ static int __ptlrpc_request_bufs_pack(struct ptlrpc_request *request, { struct obd_import *imp = request->rq_import; int rc; - ENTRY; if (unlikely(ctx)) request->rq_cli_ctx = sptlrpc_cli_ctx_get(ctx); @@ -822,7 +818,6 @@ struct ptlrpc_request_set *ptlrpc_prep_set(void) { struct ptlrpc_request_set *set; - ENTRY; OBD_ALLOC(set, sizeof *set); if (!set) RETURN(NULL); @@ -883,7 +878,6 @@ void ptlrpc_set_destroy(struct ptlrpc_request_set *set) struct list_head *next; int expected_phase; int n = 0; - ENTRY; /* Requests on the set should either all be completed, or all be new */ expected_phase = (atomic_read(&set->set_remaining) == 0) ? @@ -1027,7 +1021,6 @@ static int ptlrpc_import_delay_req(struct obd_import *imp, struct ptlrpc_request *req, int *status) { int delay = 0; - ENTRY; LASSERT (status != NULL); *status = 0; @@ -1120,7 +1113,6 @@ static int ptlrpc_console_allow(struct ptlrpc_request *req) static int ptlrpc_check_status(struct ptlrpc_request *req) { int err; - ENTRY; err = lustre_msg_get_status(req->rq_repmsg); if (lustre_msg_get_type(req->rq_repmsg) == PTL_RPC_MSG_ERR) { @@ -1156,7 +1148,6 @@ static void ptlrpc_save_versions(struct ptlrpc_request *req) struct lustre_msg *repmsg = req->rq_repmsg; struct lustre_msg *reqmsg = req->rq_reqmsg; __u64 *versions = lustre_msg_get_versions(repmsg); - ENTRY; if (lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY) return; @@ -1183,7 +1174,6 @@ static int after_reply(struct ptlrpc_request *req) int rc; struct timeval work_start; long timediff; - ENTRY; LASSERT(obd != NULL); /* repbuf must be unlinked */ @@ -1372,7 +1362,6 @@ static int ptlrpc_send_new_req(struct ptlrpc_request *req) { struct obd_import *imp = req->rq_import; int rc; - ENTRY; LASSERT(req->rq_phase == RQ_PHASE_NEW); if (req->rq_sent && (req->rq_sent > cfs_time_current_sec()) && @@ -1447,7 +1436,6 @@ static int ptlrpc_send_new_req(struct ptlrpc_request *req) static inline int ptlrpc_set_producer(struct ptlrpc_request_set *set) { int remaining, rc; - ENTRY; LASSERT(set->set_producer != NULL); @@ -1478,7 +1466,6 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set) { struct list_head *tmp, *next; int force_timer_recalc = 0; - ENTRY; if (atomic_read(&set->set_remaining) == 0) RETURN(1); @@ -1847,7 +1834,6 @@ int ptlrpc_expire_one_request(struct ptlrpc_request *req, int async_unlink) { struct obd_import *imp = req->rq_import; int rc = 0; - ENTRY; spin_lock(&req->rq_lock); req->rq_timedout = 1; @@ -1919,7 +1905,6 @@ int ptlrpc_expired_set(void *data) struct ptlrpc_request_set *set = data; struct list_head *tmp; time_t now = cfs_time_current_sec(); - ENTRY; LASSERT(set != NULL); @@ -2006,7 +1991,6 @@ int ptlrpc_set_next_timeout(struct ptlrpc_request_set *set) int timeout = 0; struct ptlrpc_request *req; int deadline; - ENTRY; SIGNAL_MASK_ASSERT(); /* XXX BUG 1511 */ @@ -2061,7 +2045,6 @@ int ptlrpc_set_wait(struct ptlrpc_request_set *set) struct ptlrpc_request *req; struct l_wait_info lwi; int rc, timeout; - ENTRY; if (set->set_producer) (void)ptlrpc_set_producer(set); @@ -2185,7 +2168,6 @@ EXPORT_SYMBOL(ptlrpc_set_wait); */ static void __ptlrpc_free_req(struct ptlrpc_request *request, int locked) { - ENTRY; if (request == NULL) { EXIT; return; @@ -2263,7 +2245,6 @@ EXPORT_SYMBOL(ptlrpc_req_finished_with_imp_lock); */ static int __ptlrpc_req_finished(struct ptlrpc_request *request, int locked) { - ENTRY; if (request == NULL) RETURN(1); @@ -2397,7 +2378,6 @@ void ptlrpc_free_committed(struct obd_import *imp) struct list_head *tmp, *saved; struct ptlrpc_request *req; struct ptlrpc_request *last_req = NULL; /* temporary fire escape */ - ENTRY; LASSERT(imp != NULL); @@ -2463,7 +2443,6 @@ void ptlrpc_free_committed(struct obd_import *imp) void ptlrpc_cleanup_client(struct obd_import *imp) { - ENTRY; EXIT; return; } @@ -2517,7 +2496,6 @@ EXPORT_SYMBOL(ptlrpc_restart_req); */ struct ptlrpc_request *ptlrpc_request_addref(struct ptlrpc_request *req) { - ENTRY; atomic_inc(&req->rq_refcount); RETURN(req); } @@ -2588,7 +2566,6 @@ int ptlrpc_queue_wait(struct ptlrpc_request *req) { struct ptlrpc_request_set *set; int rc; - ENTRY; LASSERT(req->rq_set == NULL); LASSERT(!req->rq_receiving_reply); @@ -2629,7 +2606,6 @@ static int ptlrpc_replay_interpret(const struct lu_env *env, struct ptlrpc_replay_async_args *aa = data; struct obd_import *imp = req->rq_import; - ENTRY; atomic_dec(&imp->imp_replay_inflight); if (!ptlrpc_client_replied(req)) { @@ -2721,7 +2697,6 @@ static int ptlrpc_replay_interpret(const struct lu_env *env, int ptlrpc_replay_req(struct ptlrpc_request *req) { struct ptlrpc_replay_async_args *aa; - ENTRY; LASSERT(req->rq_import->imp_state == LUSTRE_IMP_REPLAY); @@ -2761,7 +2736,6 @@ EXPORT_SYMBOL(ptlrpc_replay_req); void ptlrpc_abort_inflight(struct obd_import *imp) { struct list_head *tmp, *n; - ENTRY; /* Make sure that no new requests get processed for this import. * ptlrpc_{queue,set}_wait must (and does) hold imp_lock while testing @@ -2969,7 +2943,6 @@ void *ptlrpcd_alloc_work(struct obd_import *imp, { struct ptlrpc_request *req = NULL; struct ptlrpc_work_async_args *args; - ENTRY; might_sleep(); diff --git a/drivers/staging/lustre/lustre/ptlrpc/connection.c b/drivers/staging/lustre/lustre/ptlrpc/connection.c index a0757f372be55..c5c1d52094c88 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/connection.c +++ b/drivers/staging/lustre/lustre/ptlrpc/connection.c @@ -49,7 +49,6 @@ ptlrpc_connection_get(lnet_process_id_t peer, lnet_nid_t self, struct obd_uuid *uuid) { struct ptlrpc_connection *conn, *conn2; - ENTRY; conn = cfs_hash_lookup(conn_hash, &peer); if (conn) @@ -92,7 +91,6 @@ EXPORT_SYMBOL(ptlrpc_connection_get); int ptlrpc_connection_put(struct ptlrpc_connection *conn) { int rc = 0; - ENTRY; if (!conn) RETURN(rc); @@ -129,8 +127,6 @@ EXPORT_SYMBOL(ptlrpc_connection_put); struct ptlrpc_connection * ptlrpc_connection_addref(struct ptlrpc_connection *conn) { - ENTRY; - atomic_inc(&conn->c_refcount); CDEBUG(D_INFO, "conn=%p refcount %d to %s\n", conn, atomic_read(&conn->c_refcount), @@ -142,8 +138,6 @@ EXPORT_SYMBOL(ptlrpc_connection_addref); int ptlrpc_connection_init(void) { - ENTRY; - conn_hash = cfs_hash_create("CONN_HASH", HASH_CONN_CUR_BITS, HASH_CONN_MAX_BITS, @@ -159,7 +153,6 @@ int ptlrpc_connection_init(void) EXPORT_SYMBOL(ptlrpc_connection_init); void ptlrpc_connection_fini(void) { - ENTRY; cfs_hash_putref(conn_hash); EXIT; } diff --git a/drivers/staging/lustre/lustre/ptlrpc/events.c b/drivers/staging/lustre/lustre/ptlrpc/events.c index 0264c102cb3e2..d736a27301068 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/events.c +++ b/drivers/staging/lustre/lustre/ptlrpc/events.c @@ -55,7 +55,6 @@ void request_out_callback(lnet_event_t *ev) { struct ptlrpc_cb_id *cbid = ev->md.user_ptr; struct ptlrpc_request *req = cbid->cbid_arg; - ENTRY; LASSERT (ev->type == LNET_EVENT_SEND || ev->type == LNET_EVENT_UNLINK); @@ -90,7 +89,6 @@ void reply_in_callback(lnet_event_t *ev) { struct ptlrpc_cb_id *cbid = ev->md.user_ptr; struct ptlrpc_request *req = cbid->cbid_arg; - ENTRY; DEBUG_REQ(D_NET, req, "type %d, status %d", ev->type, ev->status); @@ -177,7 +175,6 @@ void client_bulk_callback (lnet_event_t *ev) struct ptlrpc_cb_id *cbid = ev->md.user_ptr; struct ptlrpc_bulk_desc *desc = cbid->cbid_arg; struct ptlrpc_request *req; - ENTRY; LASSERT ((desc->bd_type == BULK_PUT_SINK && ev->type == LNET_EVENT_PUT) || @@ -289,7 +286,6 @@ void request_in_callback(lnet_event_t *ev) struct ptlrpc_service_part *svcpt = rqbd->rqbd_svcpt; struct ptlrpc_service *service = svcpt->scp_service; struct ptlrpc_request *req; - ENTRY; LASSERT (ev->type == LNET_EVENT_PUT || ev->type == LNET_EVENT_UNLINK); @@ -389,7 +385,6 @@ void reply_out_callback(lnet_event_t *ev) struct ptlrpc_cb_id *cbid = ev->md.user_ptr; struct ptlrpc_reply_state *rs = cbid->cbid_arg; struct ptlrpc_service_part *svcpt = rs->rs_svcpt; - ENTRY; LASSERT (ev->type == LNET_EVENT_SEND || ev->type == LNET_EVENT_ACK || diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_bulk.c b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_bulk.c index ed95bbba95caf..6e34395422959 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_bulk.c +++ b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_bulk.c @@ -68,7 +68,6 @@ int gss_cli_ctx_wrap_bulk(struct ptlrpc_cli_ctx *ctx, __u32 maj; int offset; int rc; - ENTRY; LASSERT(req->rq_pack_bulk); LASSERT(req->rq_bulk_read || req->rq_bulk_write); @@ -171,7 +170,6 @@ int gss_cli_ctx_unwrap_bulk(struct ptlrpc_cli_ctx *ctx, rawobj_t token; __u32 maj; int roff, voff; - ENTRY; LASSERT(req->rq_pack_bulk); LASSERT(req->rq_bulk_read || req->rq_bulk_write); @@ -318,7 +316,6 @@ int gss_cli_prep_bulk(struct ptlrpc_request *req, struct ptlrpc_bulk_desc *desc) { int rc; - ENTRY; LASSERT(req->rq_cli_ctx); LASSERT(req->rq_pack_bulk); @@ -341,7 +338,6 @@ int gss_svc_prep_bulk(struct ptlrpc_request *req, struct gss_svc_reqctx *grctx; struct ptlrpc_bulk_sec_desc *bsd; int rc; - ENTRY; LASSERT(req->rq_svc_ctx); LASSERT(req->rq_pack_bulk); @@ -372,7 +368,6 @@ int gss_svc_unwrap_bulk(struct ptlrpc_request *req, struct ptlrpc_bulk_sec_desc *bsdr, *bsdv; rawobj_t token; __u32 maj; - ENTRY; LASSERT(req->rq_svc_ctx); LASSERT(req->rq_pack_bulk); @@ -444,7 +439,6 @@ int gss_svc_wrap_bulk(struct ptlrpc_request *req, rawobj_t token; __u32 maj; int rc; - ENTRY; LASSERT(req->rq_svc_ctx); LASSERT(req->rq_pack_bulk); diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_cli_upcall.c b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_cli_upcall.c index 142c789b1bc65..ca0640c1e9470 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_cli_upcall.c +++ b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_cli_upcall.c @@ -378,7 +378,6 @@ int gss_do_ctx_fini_rpc(struct gss_cli_ctx *gctx) struct ptlrpc_request *req; struct ptlrpc_user_desc *pud; int rc; - ENTRY; LASSERT(atomic_read(&ctx->cc_refcount) > 0); diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_keyring.c b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_keyring.c index bb571ae510545..07faa0e0516b0 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_keyring.c +++ b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_keyring.c @@ -524,7 +524,6 @@ void rvs_sec_install_root_ctx_kr(struct ptlrpc_sec *sec, struct gss_sec_keyring *gsec_kr = sec2gsec_keyring(sec); struct ptlrpc_cli_ctx *ctx; cfs_time_t now; - ENTRY; LASSERT(sec_is_reverse(sec)); @@ -569,7 +568,6 @@ struct ptlrpc_sec * gss_sec_create_kr(struct obd_import *imp, struct sptlrpc_flavor *sf) { struct gss_sec_keyring *gsec_kr; - ENTRY; OBD_ALLOC(gsec_kr, sizeof(*gsec_kr)); if (gsec_kr == NULL) @@ -683,7 +681,6 @@ struct ptlrpc_cli_ctx * gss_sec_lookup_ctx_kr(struct ptlrpc_sec *sec, char *coinfo; int coinfo_size; char *co_flags = ""; - ENTRY; LASSERT(imp != NULL); @@ -891,7 +888,6 @@ void flush_spec_ctx_cache_kr(struct ptlrpc_sec *sec, struct hlist_head freelist = HLIST_HEAD_INIT; struct hlist_node *next; struct ptlrpc_cli_ctx *ctx; - ENTRY; gsec_kr = sec2gsec_keyring(sec); @@ -937,8 +933,6 @@ static int gss_sec_flush_ctx_cache_kr(struct ptlrpc_sec *sec, uid_t uid, int grace, int force) { - ENTRY; - CDEBUG(D_SEC, "sec %p(%d, nctx %d), uid %d, grace %d, force %d\n", sec, atomic_read(&sec->ps_refcount), atomic_read(&sec->ps_nctx), @@ -959,7 +953,6 @@ void gss_sec_gc_ctx_kr(struct ptlrpc_sec *sec) struct hlist_head freelist = HLIST_HEAD_INIT; struct hlist_node *next; struct ptlrpc_cli_ctx *ctx; - ENTRY; CWARN("running gc\n"); @@ -993,7 +986,6 @@ int gss_sec_display_kr(struct ptlrpc_sec *sec, struct seq_file *seq) struct ptlrpc_cli_ctx *ctx; struct gss_cli_ctx *gctx; time_t now = cfs_time_current_sec(); - ENTRY; spin_lock(&sec->ps_lock); hlist_for_each_entry_safe(ctx, next, @@ -1148,7 +1140,6 @@ static int gss_kt_instantiate(struct key *key, const void *data, size_t datalen) { int rc; - ENTRY; if (data != NULL || datalen != 0) { CERROR("invalid: data %p, len %lu\n", data, (long)datalen); @@ -1198,7 +1189,6 @@ int gss_kt_update(struct key *key, const void *data, size_t datalen) rawobj_t tmpobj = RAWOBJ_EMPTY; __u32 datalen32 = (__u32) datalen; int rc; - ENTRY; if (data == NULL || datalen == 0) { CWARN("invalid: data %p, len %lu\n", data, (long)datalen); @@ -1316,7 +1306,6 @@ int gss_kt_match(const struct key *key, const void *desc) static void gss_kt_destroy(struct key *key) { - ENTRY; LASSERT(key->payload.data == NULL); CDEBUG(D_SEC, "destroy key %p\n", key); EXIT; diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_krb5_mech.c b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_krb5_mech.c index 91da7637756d6..4847f11b797aa 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_krb5_mech.c +++ b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_krb5_mech.c @@ -890,7 +890,6 @@ int krb5_encrypt_rawobjs(struct ll_crypto_cipher *tfm, __u8 local_iv[16] = {0}, *buf; __u32 datalen = 0; int i, rc; - ENTRY; buf = outobj->data; desc.tfm = tfm; diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_pipefs.c b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_pipefs.c index 3df7257b7fa0c..105d0d8bca9e1 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_pipefs.c +++ b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_pipefs.c @@ -262,7 +262,6 @@ void gss_sec_ctx_replace_pf(struct gss_sec *gsec, struct hlist_node *next; HLIST_HEAD(freelist); unsigned int hash; - ENTRY; gsec_pf = container_of(gsec, struct gss_sec_pipefs, gsp_base); @@ -297,7 +296,6 @@ int gss_install_rvs_cli_ctx_pf(struct gss_sec *gsec, struct vfs_cred vcred; struct ptlrpc_cli_ctx *cli_ctx; int rc; - ENTRY; vcred.vc_uid = 0; vcred.vc_gid = 0; @@ -324,7 +322,6 @@ void gss_ctx_cache_gc_pf(struct gss_sec_pipefs *gsec_pf, struct ptlrpc_cli_ctx *ctx; struct hlist_node *next; int i; - ENTRY; sec = &gsec_pf->gsp_base.gs_base; @@ -347,7 +344,6 @@ struct ptlrpc_sec* gss_sec_create_pf(struct obd_import *imp, { struct gss_sec_pipefs *gsec_pf; int alloc_size, hash_size, i; - ENTRY; #define GSS_SEC_PIPEFS_CTX_HASH_SIZE (32) @@ -423,7 +419,6 @@ struct ptlrpc_cli_ctx * gss_sec_lookup_ctx_pf(struct ptlrpc_sec *sec, struct hlist_node *next; HLIST_HEAD(freelist); unsigned int hash, gc = 0, found = 0; - ENTRY; might_sleep(); @@ -545,7 +540,6 @@ int gss_sec_flush_ctx_cache_pf(struct ptlrpc_sec *sec, struct hlist_node *next; HLIST_HEAD(freelist); int i, busy = 0; - ENTRY; might_sleep_if(grace); @@ -704,7 +698,6 @@ void upcall_msg_delist(struct gss_upcall_msg *msg) static void gss_release_msg(struct gss_upcall_msg *gmsg) { - ENTRY; LASSERT(atomic_read(&gmsg->gum_refcount) > 0); if (!atomic_dec_and_test(&gmsg->gum_refcount)) { @@ -809,7 +802,6 @@ ssize_t gss_pipe_upcall(struct file *filp, struct rpc_pipe_msg *msg, char *data = (char *)msg->data + msg->copied; ssize_t mlen = msg->len; ssize_t left; - ENTRY; if (mlen > buflen) mlen = buflen; @@ -835,7 +827,6 @@ ssize_t gss_pipe_downcall(struct file *filp, const char *src, size_t mlen) int datalen; int timeout, rc; __u32 mechidx, seq, gss_err; - ENTRY; mechidx = (__u32) (long) rpci->private; LASSERT(mechidx < MECH_MAX); @@ -949,7 +940,6 @@ void gss_pipe_destroy_msg(struct rpc_pipe_msg *msg) struct gss_upcall_msg *gmsg; struct gss_upcall_msg_data *gumd; static cfs_time_t ratelimit = 0; - ENTRY; LASSERT(list_empty(&msg->list)); @@ -988,7 +978,6 @@ void gss_pipe_release(struct inode *inode) { struct rpc_inode *rpci = RPC_I(inode); __u32 idx; - ENTRY; idx = (__u32) (long) rpci->private; LASSERT(idx < MECH_MAX); @@ -1041,7 +1030,6 @@ int gss_ctx_refresh_pf(struct ptlrpc_cli_ctx *ctx) struct gss_sec *gsec; struct gss_upcall_msg *gmsg; int rc = 0; - ENTRY; might_sleep(); diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_svc_upcall.c b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_svc_upcall.c index 31b50ea19c254..243f110cce349 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_svc_upcall.c +++ b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_svc_upcall.c @@ -259,8 +259,6 @@ static int rsi_parse(struct cache_detail *cd, char *mesg, int mlen) struct rsi rsii, *rsip = NULL; time_t expiry; int status = -EINVAL; - ENTRY; - memset(&rsii, 0, sizeof(rsii)); @@ -662,7 +660,6 @@ static void rsc_flush(rsc_entry_match *match, long data) struct cache_head **ch; struct rsc *rscp; int n; - ENTRY; write_lock(&rsc_cache.hash_lock); for (n = 0; n < RSC_HASHMAX; n++) { @@ -744,7 +741,6 @@ int gss_svc_upcall_install_rvs_ctx(struct obd_import *imp, unsigned long ctx_expiry; __u32 major; int rc; - ENTRY; memset(&rsci, 0, sizeof(rsci)); @@ -855,7 +851,6 @@ int gss_svc_upcall_handle_init(struct ptlrpc_request *req, struct gss_rep_header *rephdr; int first_check = 1; int rc = SECSVC_DROP; - ENTRY; memset(&rsikey, 0, sizeof(rsikey)); rsikey.lustre_svc = lustre_svc; diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/sec_gss.c b/drivers/staging/lustre/lustre/ptlrpc/gss/sec_gss.c index ebca858ca1830..0553965cc3688 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/sec_gss.c +++ b/drivers/staging/lustre/lustre/ptlrpc/gss/sec_gss.c @@ -280,7 +280,6 @@ __u32 gss_unseal_msg(struct gss_ctx *mechctx, __u8 *clear_buf; int clear_buflen; __u32 major; - ENTRY; if (msgbuf->lm_bufcount != 2) { CERROR("invalid bufcount %d\n", msgbuf->lm_bufcount); @@ -646,7 +645,6 @@ int gss_cli_ctx_sign(struct ptlrpc_cli_ctx *ctx, struct gss_cli_ctx *gctx = ctx2gctx(ctx); __u32 flags = 0, seq, svc; int rc; - ENTRY; LASSERT(req->rq_reqbuf); LASSERT(req->rq_reqbuf->lm_bufcount >= 2); @@ -765,7 +763,6 @@ int gss_cli_ctx_verify(struct ptlrpc_cli_ctx *ctx, struct lustre_msg *msg = req->rq_repdata; __u32 major; int pack_bulk, swabbed, rc = 0; - ENTRY; LASSERT(req->rq_cli_ctx == ctx); LASSERT(msg); @@ -889,7 +886,6 @@ int gss_cli_ctx_seal(struct ptlrpc_cli_ctx *ctx, struct gss_header *ghdr; __u32 buflens[2], major; int wiresize, rc; - ENTRY; LASSERT(req->rq_clrbuf); LASSERT(req->rq_cli_ctx == ctx); @@ -988,7 +984,6 @@ int gss_cli_ctx_unseal(struct ptlrpc_cli_ctx *ctx, struct lustre_msg *msg = req->rq_repdata; int msglen, pack_bulk, swabbed, rc; __u32 major; - ENTRY; LASSERT(req->rq_cli_ctx == ctx); LASSERT(req->rq_ctx_init == 0); @@ -1148,7 +1143,6 @@ int gss_sec_create_common(struct gss_sec *gsec, void gss_sec_destroy_common(struct gss_sec *gsec) { struct ptlrpc_sec *sec = &gsec->gs_base; - ENTRY; LASSERT(sec->ps_import); LASSERT(atomic_read(&sec->ps_refcount) == 0); @@ -1260,7 +1254,6 @@ int gss_alloc_reqbuf_intg(struct ptlrpc_sec *sec, int bufsize, txtsize; int bufcnt = 2; __u32 buflens[5]; - ENTRY; /* * on-wire data layout: @@ -1342,7 +1335,6 @@ int gss_alloc_reqbuf_priv(struct ptlrpc_sec *sec, __u32 ibuflens[3], wbuflens[2]; int ibufcnt; int clearsize, wiresize; - ENTRY; LASSERT(req->rq_clrbuf == NULL); LASSERT(req->rq_clrbuf_len == 0); @@ -1442,7 +1434,6 @@ void gss_free_reqbuf(struct ptlrpc_sec *sec, struct ptlrpc_request *req) { int privacy; - ENTRY; LASSERT(!req->rq_pool || req->rq_reqbuf); privacy = SPTLRPC_FLVR_SVC(req->rq_flvr.sf_rpc) == SPTLRPC_SVC_PRIV; @@ -1578,7 +1569,6 @@ int gss_alloc_repbuf(struct ptlrpc_sec *sec, int msgsize) { int svc = SPTLRPC_FLVR_SVC(req->rq_flvr.sf_rpc); - ENTRY; LASSERT(!req->rq_pack_bulk || (req->rq_bulk_read || req->rq_bulk_write)); @@ -1891,7 +1881,6 @@ int gss_svc_sign(struct ptlrpc_request *req, { __u32 flags = 0; int rc; - ENTRY; LASSERT(rs->rs_msg == lustre_msg_buf(rs->rs_repbuf, 1, 0)); @@ -1933,7 +1922,6 @@ int gss_pack_err_notify(struct ptlrpc_request *req, __u32 major, __u32 minor) struct gss_err_header *ghdr; int replen = sizeof(struct ptlrpc_body); int rc; - ENTRY; //if (OBD_FAIL_CHECK_ORSET(OBD_FAIL_SVCGSS_ERR_NOTIFY, OBD_FAIL_ONCE)) // RETURN(-EINVAL); @@ -1978,7 +1966,6 @@ int gss_svc_handle_init(struct ptlrpc_request *req, __u32 lustre_svc; __u32 *secdata, seclen; int swabbed, rc; - ENTRY; CDEBUG(D_SEC, "processing gss init(%d) request from %s\n", gw->gw_proc, libcfs_nid2str(req->rq_peer.nid)); @@ -2094,7 +2081,6 @@ int gss_svc_verify_request(struct ptlrpc_request *req, struct lustre_msg *msg = req->rq_reqbuf; int offset = 2; int swabbed; - ENTRY; *major = GSS_S_COMPLETE; @@ -2174,7 +2160,6 @@ int gss_svc_unseal_request(struct ptlrpc_request *req, struct gss_svc_ctx *gctx = grctx->src_ctx; struct lustre_msg *msg = req->rq_reqbuf; int swabbed, msglen, offset = 1; - ENTRY; if (gss_check_seq_num(&gctx->gsc_seqdata, gw->gw_seq, 0)) { CERROR("phase 0: discard replayed req: seq %u\n", gw->gw_seq); @@ -2249,7 +2234,6 @@ int gss_svc_handle_data(struct ptlrpc_request *req, struct gss_svc_reqctx *grctx = gss_svc_ctx2reqctx(req->rq_svc_ctx); __u32 major = 0; int rc = 0; - ENTRY; grctx->src_ctx = gss_svc_upcall_get_ctx(req, gw); if (!grctx->src_ctx) { @@ -2294,7 +2278,6 @@ int gss_svc_handle_destroy(struct ptlrpc_request *req, { struct gss_svc_reqctx *grctx = gss_svc_ctx2reqctx(req->rq_svc_ctx); __u32 major; - ENTRY; req->rq_ctx_fini = 1; req->rq_no_reply = 1; @@ -2343,7 +2326,6 @@ int gss_svc_accept(struct ptlrpc_sec_policy *policy, struct ptlrpc_request *req) struct gss_svc_reqctx *grctx; struct gss_wire_ctx *gw; int swabbed, rc; - ENTRY; LASSERT(req->rq_reqbuf); LASSERT(req->rq_svc_ctx == NULL); @@ -2434,7 +2416,6 @@ int gss_svc_accept(struct ptlrpc_sec_policy *policy, struct ptlrpc_request *req) void gss_svc_invalidate_ctx(struct ptlrpc_svc_ctx *svc_ctx) { struct gss_svc_reqctx *grctx; - ENTRY; if (svc_ctx == NULL) { EXIT; @@ -2496,7 +2477,6 @@ int gss_svc_alloc_rs(struct ptlrpc_request *req, int msglen) __u32 ibuflens[2], buflens[4]; int ibufcnt = 0, bufcnt; int txtsize, wmsg_size, rs_size; - ENTRY; LASSERT(msglen % 8 == 0); @@ -2619,7 +2599,6 @@ static int gss_svc_seal(struct ptlrpc_request *req, int token_buflen; __u32 buflens[2], major; int msglen, rc; - ENTRY; /* get clear data length. note embedded lustre_msg might * have been shrinked */ @@ -2712,7 +2691,6 @@ int gss_svc_authorize(struct ptlrpc_request *req) struct gss_svc_reqctx *grctx = gss_svc_ctx2reqctx(req->rq_svc_ctx); struct gss_wire_ctx *gw = &grctx->src_wirectx; int early, rc; - ENTRY; early = (req->rq_packed_final == 0); diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c index 47a3c05127392..3b1137b9ac9d0 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/import.c +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c @@ -195,7 +195,6 @@ int ptlrpc_set_import_discon(struct obd_import *imp, __u32 conn_cnt) /* Must be called with imp_lock held! */ static void ptlrpc_deactivate_and_unlock_import(struct obd_import *imp) { - ENTRY; LASSERT(spin_is_locked(&imp->imp_lock)); CDEBUG(D_HA, "setting import %s INVALID\n", obd2cli_tgt(imp->imp_obd)); @@ -394,8 +393,6 @@ EXPORT_SYMBOL(ptlrpc_activate_import); void ptlrpc_fail_import(struct obd_import *imp, __u32 conn_cnt) { - ENTRY; - LASSERT(!imp->imp_dlm_fake); if (ptlrpc_set_import_discon(imp, conn_cnt)) { @@ -461,7 +458,6 @@ static int import_select_connection(struct obd_import *imp) struct obd_export *dlmexp; char *target_start; int target_len, tried_all = 1; - ENTRY; spin_lock(&imp->imp_lock); @@ -602,7 +598,6 @@ int ptlrpc_connect_import(struct obd_import *imp) (char *)&imp->imp_connect_data }; struct ptlrpc_connect_async_args *aa; int rc; - ENTRY; spin_lock(&imp->imp_lock); if (imp->imp_state == LUSTRE_IMP_CLOSED) { @@ -756,7 +751,6 @@ static int ptlrpc_connect_interpret(const struct lu_env *env, struct obd_connect_data *ocd; struct obd_export *exp; int ret; - ENTRY; spin_lock(&imp->imp_lock); if (imp->imp_state == LUSTRE_IMP_CLOSED) { @@ -1183,7 +1177,6 @@ static int completed_replay_interpret(const struct lu_env *env, struct ptlrpc_request *req, void * data, int rc) { - ENTRY; atomic_dec(&req->rq_import->imp_replay_inflight); if (req->rq_status == 0 && !req->rq_import->imp_vbr_failed) { @@ -1212,7 +1205,6 @@ static int completed_replay_interpret(const struct lu_env *env, static int signal_completed_replay(struct obd_import *imp) { struct ptlrpc_request *req; - ENTRY; if (unlikely(OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_FINISH_REPLAY))) RETURN(0); @@ -1248,8 +1240,6 @@ static int ptlrpc_invalidate_import_thread(void *data) { struct obd_import *imp = data; - ENTRY; - unshare_fs_struct(); CDEBUG(D_HA, "thread invalidate import %s to %s@%s\n", @@ -1297,7 +1287,6 @@ int ptlrpc_import_recovery_state_machine(struct obd_import *imp) char *target_start; int target_len; - ENTRY; if (imp->imp_state == LUSTRE_IMP_EVICTED) { deuuidify(obd2cli_tgt(imp->imp_obd), NULL, &target_start, &target_len); @@ -1401,7 +1390,6 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose) struct ptlrpc_request *req; int rq_opc, rc = 0; int nowait = imp->imp_obd->obd_force; - ENTRY; if (nowait) GOTO(set_state, rc); @@ -1482,8 +1470,6 @@ EXPORT_SYMBOL(ptlrpc_disconnect_import); void ptlrpc_cleanup_imp(struct obd_import *imp) { - ENTRY; - spin_lock(&imp->imp_lock); IMPORT_SET_STATE_NOLOCK(imp, LUSTRE_IMP_CLOSED); imp->imp_generation++; diff --git a/drivers/staging/lustre/lustre/ptlrpc/llog_client.c b/drivers/staging/lustre/lustre/ptlrpc/llog_client.c index 367ca8ef7d60f..b3db05583641e 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/llog_client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/llog_client.c @@ -85,7 +85,6 @@ static int llog_client_open(const struct lu_env *env, struct llog_ctxt *ctxt = lgh->lgh_ctxt; struct ptlrpc_request *req = NULL; int rc; - ENTRY; LLOG_CLIENT_ENTRY(ctxt, imp); @@ -147,7 +146,6 @@ static int llog_client_destroy(const struct lu_env *env, struct ptlrpc_request *req = NULL; struct llogd_body *body; int rc; - ENTRY; LLOG_CLIENT_ENTRY(loghandle->lgh_ctxt, imp); req = ptlrpc_request_alloc_pack(imp, &RQF_LLOG_ORIGIN_HANDLE_DESTROY, @@ -184,7 +182,6 @@ static int llog_client_next_block(const struct lu_env *env, struct llogd_body *body; void *ptr; int rc; - ENTRY; LLOG_CLIENT_ENTRY(loghandle->lgh_ctxt, imp); req = ptlrpc_request_alloc_pack(imp, &RQF_LLOG_ORIGIN_HANDLE_NEXT_BLOCK, @@ -238,7 +235,6 @@ static int llog_client_prev_block(const struct lu_env *env, struct llogd_body *body; void *ptr; int rc; - ENTRY; LLOG_CLIENT_ENTRY(loghandle->lgh_ctxt, imp); req = ptlrpc_request_alloc_pack(imp, &RQF_LLOG_ORIGIN_HANDLE_PREV_BLOCK, @@ -287,7 +283,6 @@ static int llog_client_read_header(const struct lu_env *env, struct llog_log_hdr *hdr; struct llog_rec_hdr *llh_hdr; int rc; - ENTRY; LLOG_CLIENT_ENTRY(handle->lgh_ctxt, imp); req = ptlrpc_request_alloc_pack(imp,&RQF_LLOG_ORIGIN_HANDLE_READ_HEADER, diff --git a/drivers/staging/lustre/lustre/ptlrpc/llog_net.c b/drivers/staging/lustre/lustre/ptlrpc/llog_net.c index a81f557d7794a..963223d3ed1f3 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/llog_net.c +++ b/drivers/staging/lustre/lustre/ptlrpc/llog_net.c @@ -57,7 +57,6 @@ int llog_initiator_connect(struct llog_ctxt *ctxt) { struct obd_import *new_imp; - ENTRY; LASSERT(ctxt); new_imp = ctxt->loc_obd->u.cli.cl_import; diff --git a/drivers/staging/lustre/lustre/ptlrpc/llog_server.c b/drivers/staging/lustre/lustre/ptlrpc/llog_server.c index bc1fcd8c7e735..b5aec5e84ee62 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/llog_server.c +++ b/drivers/staging/lustre/lustre/ptlrpc/llog_server.c @@ -71,8 +71,6 @@ int llog_origin_handle_open(struct ptlrpc_request *req) char *name = NULL; int rc; - ENTRY; - body = req_capsule_client_get(&req->rq_pill, &RMF_LLOGD_BODY); if (body == NULL) RETURN(-EFAULT); @@ -127,8 +125,6 @@ int llog_origin_handle_destroy(struct ptlrpc_request *req) struct llog_ctxt *ctxt; int rc; - ENTRY; - body = req_capsule_client_get(&req->rq_pill, &RMF_LLOGD_BODY); if (body == NULL) RETURN(-EFAULT); @@ -169,8 +165,6 @@ int llog_origin_handle_next_block(struct ptlrpc_request *req) void *ptr; int rc; - ENTRY; - body = req_capsule_client_get(&req->rq_pill, &RMF_LLOGD_BODY); if (body == NULL) RETURN(-EFAULT); @@ -230,8 +224,6 @@ int llog_origin_handle_prev_block(struct ptlrpc_request *req) void *ptr; int rc; - ENTRY; - body = req_capsule_client_get(&req->rq_pill, &RMF_LLOGD_BODY); if (body == NULL) RETURN(-EFAULT); @@ -290,8 +282,6 @@ int llog_origin_handle_read_header(struct ptlrpc_request *req) __u32 flags; int rc; - ENTRY; - body = req_capsule_client_get(&req->rq_pill, &RMF_LLOGD_BODY); if (body == NULL) RETURN(-EFAULT); @@ -336,7 +326,6 @@ EXPORT_SYMBOL(llog_origin_handle_read_header); int llog_origin_handle_close(struct ptlrpc_request *req) { - ENTRY; /* Nothing to do */ RETURN(0); } @@ -352,7 +341,6 @@ int llog_origin_handle_cancel(struct ptlrpc_request *req) struct llog_handle *cathandle; struct inode *inode; void *handle; - ENTRY; logcookies = req_capsule_client_get(&req->rq_pill, &RMF_LOGCOOKIES); num_cookies = req_capsule_get_size(&req->rq_pill, &RMF_LOGCOOKIES, diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c index 2bd0d985bf1d2..602ce679508b4 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c @@ -480,7 +480,6 @@ static int ptlrpc_lprocfs_nrs_seq_show(struct seq_file *m, void *n) bool hp = false; int i; int rc = 0; - ENTRY; /** * Serialize NRS core lprocfs operations with policy registration/ @@ -638,7 +637,6 @@ static ssize_t ptlrpc_lprocfs_nrs_seq_write(struct file *file, const char *buffe char *cmd_copy = NULL; char *token; int rc = 0; - ENTRY; if (count >= LPROCFS_NRS_WR_MAX_CMD) GOTO(out, rc = -EINVAL); @@ -1217,7 +1215,6 @@ int lprocfs_wr_ping(struct file *file, const char *buffer, struct obd_device *obd = ((struct seq_file *)file->private_data)->private; struct ptlrpc_request *req; int rc; - ENTRY; LPROCFS_CLIMP_CHECK(obd); req = ptlrpc_prep_ping(obd->u.cli.cl_import); diff --git a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c index 5f1b889e52779..b5b5b486edbfe 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c +++ b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c @@ -54,7 +54,6 @@ static int ptl_send_buf (lnet_handle_md_t *mdh, void *base, int len, { int rc; lnet_md_t md; - ENTRY; LASSERT (portal != 0); LASSERT (conn != NULL); @@ -122,7 +121,6 @@ int ptlrpc_register_bulk(struct ptlrpc_request *req) __u64 xid; lnet_handle_me_t me_h; lnet_md_t md; - ENTRY; if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_BULK_GET_NET)) RETURN(0); @@ -247,7 +245,6 @@ int ptlrpc_unregister_bulk(struct ptlrpc_request *req, int async) wait_queue_head_t *wq; struct l_wait_info lwi; int rc; - ENTRY; LASSERT(!in_interrupt()); /* might sleep */ @@ -456,7 +453,6 @@ EXPORT_SYMBOL(ptlrpc_reply); int ptlrpc_send_error(struct ptlrpc_request *req, int may_be_difficult) { int rc; - ENTRY; if (req->rq_no_reply) RETURN(0); @@ -498,7 +494,6 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply) lnet_handle_me_t reply_me_h; lnet_md_t reply_md; struct obd_device *obd = request->rq_import->imp_obd; - ENTRY; if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_DROP_RPC)) RETURN(0); diff --git a/drivers/staging/lustre/lustre/ptlrpc/nrs.c b/drivers/staging/lustre/lustre/ptlrpc/nrs.c index 1996431e35ffb..352c0f1af4717 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/nrs.c +++ b/drivers/staging/lustre/lustre/ptlrpc/nrs.c @@ -91,7 +91,6 @@ static int nrs_policy_ctl_locked(struct ptlrpc_nrs_policy *policy, static void nrs_policy_stop0(struct ptlrpc_nrs_policy *policy) { struct ptlrpc_nrs *nrs = policy->pol_nrs; - ENTRY; if (policy->pol_desc->pd_ops->op_policy_stop != NULL) { spin_unlock(&nrs->nrs_lock); @@ -118,7 +117,6 @@ static void nrs_policy_stop0(struct ptlrpc_nrs_policy *policy) static int nrs_policy_stop_locked(struct ptlrpc_nrs_policy *policy) { struct ptlrpc_nrs *nrs = policy->pol_nrs; - ENTRY; if (nrs->nrs_policy_fallback == policy && !nrs->nrs_stopping) RETURN(-EPERM); @@ -158,7 +156,6 @@ static int nrs_policy_stop_locked(struct ptlrpc_nrs_policy *policy) static void nrs_policy_stop_primary(struct ptlrpc_nrs *nrs) { struct ptlrpc_nrs_policy *tmp = nrs->nrs_policy_primary; - ENTRY; if (tmp == NULL) { /** @@ -203,7 +200,6 @@ static int nrs_policy_start_locked(struct ptlrpc_nrs_policy *policy) { struct ptlrpc_nrs *nrs = policy->pol_nrs; int rc = 0; - ENTRY; /** * Don't allow multiple starting which is too complex, and has no real @@ -644,7 +640,6 @@ static int nrs_policy_ctl(struct ptlrpc_nrs *nrs, char *name, { struct ptlrpc_nrs_policy *policy; int rc = 0; - ENTRY; spin_lock(&nrs->nrs_lock); @@ -690,7 +685,6 @@ static int nrs_policy_ctl(struct ptlrpc_nrs *nrs, char *name, static int nrs_policy_unregister(struct ptlrpc_nrs *nrs, char *name) { struct ptlrpc_nrs_policy *policy = NULL; - ENTRY; spin_lock(&nrs->nrs_lock); @@ -751,7 +745,6 @@ static int nrs_policy_register(struct ptlrpc_nrs *nrs, struct ptlrpc_nrs_policy *tmp; struct ptlrpc_service_part *svcpt = nrs->nrs_svcpt; int rc; - ENTRY; LASSERT(svcpt != NULL); LASSERT(desc->pd_ops != NULL); @@ -844,7 +837,6 @@ static void ptlrpc_nrs_req_add_nolock(struct ptlrpc_request *req) static void ptlrpc_nrs_hpreq_add_nolock(struct ptlrpc_request *req) { int opc = lustre_msg_get_opc(req->rq_reqmsg); - ENTRY; spin_lock(&req->rq_lock); req->rq_hp = 1; @@ -891,7 +883,6 @@ static int nrs_register_policies_locked(struct ptlrpc_nrs *nrs) struct ptlrpc_service_part *svcpt = nrs->nrs_svcpt; struct ptlrpc_service *svc = svcpt->scp_service; int rc = -EINVAL; - ENTRY; LASSERT(mutex_is_locked(&nrs_core.nrs_mutex)); @@ -966,7 +957,6 @@ static int nrs_svcpt_setup_locked(struct ptlrpc_service_part *svcpt) { struct ptlrpc_nrs *nrs; int rc; - ENTRY; LASSERT(mutex_is_locked(&nrs_core.nrs_mutex)); @@ -1012,7 +1002,6 @@ static void nrs_svcpt_cleanup_locked(struct ptlrpc_service_part *svcpt) struct ptlrpc_nrs_policy *tmp; int rc; bool hp = false; - ENTRY; LASSERT(mutex_is_locked(&nrs_core.nrs_mutex)); @@ -1051,7 +1040,6 @@ static void nrs_svcpt_cleanup_locked(struct ptlrpc_service_part *svcpt) static struct ptlrpc_nrs_pol_desc *nrs_policy_find_desc_locked(const char *name) { struct ptlrpc_nrs_pol_desc *tmp; - ENTRY; list_for_each_entry(tmp, &nrs_core.nrs_policies, pd_list) { if (strncmp(tmp->pd_name, name, NRS_POL_NAME_MAX) == 0) @@ -1079,7 +1067,6 @@ static int nrs_policy_unregister_locked(struct ptlrpc_nrs_pol_desc *desc) struct ptlrpc_service_part *svcpt; int i; int rc = 0; - ENTRY; LASSERT(mutex_is_locked(&nrs_core.nrs_mutex)); LASSERT(mutex_is_locked(&ptlrpc_all_services_mutex)); @@ -1143,7 +1130,6 @@ int ptlrpc_nrs_policy_register(struct ptlrpc_nrs_pol_conf *conf) struct ptlrpc_service *svc; struct ptlrpc_nrs_pol_desc *desc; int rc = 0; - ENTRY; LASSERT(conf != NULL); LASSERT(conf->nc_ops != NULL); @@ -1296,7 +1282,6 @@ int ptlrpc_nrs_policy_unregister(struct ptlrpc_nrs_pol_conf *conf) { struct ptlrpc_nrs_pol_desc *desc; int rc; - ENTRY; LASSERT(conf != NULL); @@ -1630,7 +1615,6 @@ void ptlrpc_nrs_req_hp_move(struct ptlrpc_request *req) struct ptlrpc_nrs_request *nrq = &req->rq_nrq; struct ptlrpc_nrs_resource *res1[NRS_RES_MAX]; struct ptlrpc_nrs_resource *res2[NRS_RES_MAX]; - ENTRY; /** * Obtain the high-priority NRS head resources. @@ -1696,7 +1680,6 @@ int ptlrpc_nrs_policy_control(const struct ptlrpc_service *svc, struct ptlrpc_service_part *svcpt; int i; int rc = 0; - ENTRY; LASSERT(opc != PTLRPC_NRS_CTL_INVALID); @@ -1745,7 +1728,6 @@ extern struct ptlrpc_nrs_pol_conf nrs_conf_fifo; int ptlrpc_nrs_init(void) { int rc; - ENTRY; mutex_init(&nrs_core.nrs_mutex); INIT_LIST_HEAD(&nrs_core.nrs_policies); diff --git a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c index 9c20d0c606789..aae4fd67152a1 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c @@ -329,7 +329,6 @@ int lustre_pack_reply_v2(struct ptlrpc_request *req, int count, { struct ptlrpc_reply_state *rs; int msg_len, rc; - ENTRY; LASSERT(req->rq_reply_state == NULL); @@ -574,7 +573,6 @@ static int lustre_unpack_msg_v2(struct lustre_msg_v2 *m, int len) int __lustre_unpack_msg(struct lustre_msg *m, int len) { int required_len, rc; - ENTRY; /* We can provide a slightly better error log, if we check the * message magic and version first. In the future, struct @@ -1616,7 +1614,6 @@ int do_set_info_async(struct obd_import *imp, struct ptlrpc_request *req; char *tmp; int rc; - ENTRY; req = ptlrpc_request_alloc(imp, &RQF_OBD_SET_INFO); if (req == NULL) @@ -2166,7 +2163,6 @@ static void lustre_swab_lmm_oi(struct ost_id *oi) static void lustre_swab_lov_user_md_common(struct lov_user_md_v1 *lum) { - ENTRY; __swab32s(&lum->lmm_magic); __swab32s(&lum->lmm_pattern); lustre_swab_lmm_oi(&lum->lmm_oi); @@ -2179,7 +2175,6 @@ static void lustre_swab_lov_user_md_common(struct lov_user_md_v1 *lum) void lustre_swab_lov_user_md_v1(struct lov_user_md_v1 *lum) { - ENTRY; CDEBUG(D_IOCTL, "swabbing lov_user_md v1\n"); lustre_swab_lov_user_md_common(lum); EXIT; @@ -2188,7 +2183,6 @@ EXPORT_SYMBOL(lustre_swab_lov_user_md_v1); void lustre_swab_lov_user_md_v3(struct lov_user_md_v3 *lum) { - ENTRY; CDEBUG(D_IOCTL, "swabbing lov_user_md v3\n"); lustre_swab_lov_user_md_common((struct lov_user_md_v1 *)lum); /* lmm_pool_name nothing to do with char */ @@ -2198,7 +2192,6 @@ EXPORT_SYMBOL(lustre_swab_lov_user_md_v3); void lustre_swab_lov_mds_md(struct lov_mds_md *lmm) { - ENTRY; CDEBUG(D_IOCTL, "swabbing lov_mds_md\n"); __swab32s(&lmm->lmm_magic); __swab32s(&lmm->lmm_pattern); @@ -2214,7 +2207,7 @@ void lustre_swab_lov_user_md_objects(struct lov_user_ost_data *lod, int stripe_count) { int i; - ENTRY; + for (i = 0; i < stripe_count; i++) { lustre_swab_ost_id(&(lod[i].l_ost_oi)); __swab32s(&(lod[i].l_ost_gen)); diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c index 79e7d0852e957..74372914e8504 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c @@ -75,7 +75,6 @@ int ptlrpc_obd_ping(struct obd_device *obd) { int rc; struct ptlrpc_request *req; - ENTRY; req = ptlrpc_prep_ping(obd->u.cli.cl_import); if (req == NULL) @@ -94,7 +93,6 @@ EXPORT_SYMBOL(ptlrpc_obd_ping); int ptlrpc_ping(struct obd_import *imp) { struct ptlrpc_request *req; - ENTRY; req = ptlrpc_prep_ping(imp); if (req == NULL) { @@ -297,7 +295,6 @@ static void ptlrpc_pinger_process_import(struct obd_import *imp, static int ptlrpc_pinger_main(void *arg) { struct ptlrpc_thread *thread = (struct ptlrpc_thread *)arg; - ENTRY; /* Record that the thread is running */ thread_set_flags(thread, SVC_RUNNING); @@ -375,7 +372,6 @@ int ptlrpc_start_pinger(void) { struct l_wait_info lwi = { 0 }; int rc; - ENTRY; if (!thread_is_init(&pinger_thread) && !thread_is_stopped(&pinger_thread)) @@ -413,7 +409,6 @@ int ptlrpc_stop_pinger(void) { struct l_wait_info lwi = { 0 }; int rc = 0; - ENTRY; if (!thread_is_init(&pinger_thread) && !thread_is_stopped(&pinger_thread)) @@ -452,7 +447,6 @@ void ptlrpc_pinger_commit_expected(struct obd_import *imp) int ptlrpc_pinger_add_import(struct obd_import *imp) { - ENTRY; if (!list_empty(&imp->imp_pinger_chain)) RETURN(-EALREADY); @@ -475,7 +469,6 @@ EXPORT_SYMBOL(ptlrpc_pinger_add_import); int ptlrpc_pinger_del_import(struct obd_import *imp) { - ENTRY; if (list_empty(&imp->imp_pinger_chain)) RETURN(-ENOENT); @@ -652,7 +645,6 @@ static int ping_evictor_main(void *arg) struct obd_export *exp; struct l_wait_info lwi = { 0 }; time_t expire_time; - ENTRY; unshare_fs_struct(); diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c index f6ea80f0b1053..e8163805e685a 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c @@ -54,7 +54,6 @@ extern struct mutex ptlrpcd_mutex; __init int ptlrpc_init(void) { int rc, cleanup_phase = 0; - ENTRY; lustre_assert_wire_constants(); #if RS_DEBUG diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c index 5a66a1be42283..e0ee38e80ae2a 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c @@ -268,7 +268,6 @@ static int ptlrpcd_check(struct lu_env *env, struct ptlrpcd_ctl *pc) struct ptlrpc_request_set *set = pc->pc_set; int rc = 0; int rc2; - ENTRY; if (atomic_read(&set->set_new_count)) { spin_lock(&set->set_new_req_lock); @@ -383,7 +382,6 @@ static int ptlrpcd(void *arg) struct ptlrpc_request_set *set = pc->pc_set; struct lu_env env = { .le_ses = NULL }; int rc, exit = 0; - ENTRY; unshare_fs_struct(); #if defined(CONFIG_SMP) @@ -501,7 +499,6 @@ static int ptlrpcd_bind(int index, int max) #if defined(CONFIG_NUMA) cpumask_t mask; #endif - ENTRY; LASSERT(index <= max - 1); pc = &ptlrpcds->pd_threads[index]; @@ -604,7 +601,6 @@ int ptlrpcd_start(int index, int max, const char *name, struct ptlrpcd_ctl *pc) { int rc; int env = 0; - ENTRY; /* * Do not allow start second thread for one pc. @@ -668,8 +664,6 @@ int ptlrpcd_start(int index, int max, const char *name, struct ptlrpcd_ctl *pc) void ptlrpcd_stop(struct ptlrpcd_ctl *pc, int force) { - ENTRY; - if (!test_bit(LIOD_START, &pc->pc_flags)) { CWARN("Thread for pc %p was not started\n", pc); goto out; @@ -687,7 +681,6 @@ void ptlrpcd_stop(struct ptlrpcd_ctl *pc, int force) void ptlrpcd_free(struct ptlrpcd_ctl *pc) { struct ptlrpc_request_set *set = pc->pc_set; - ENTRY; if (!test_bit(LIOD_START, &pc->pc_flags)) { CWARN("Thread for pc %p was not started\n", pc); @@ -722,7 +715,6 @@ void ptlrpcd_free(struct ptlrpcd_ctl *pc) static void ptlrpcd_fini(void) { int i; - ENTRY; if (ptlrpcds != NULL) { for (i = 0; i < ptlrpcds->pd_nthreads; i++) @@ -743,7 +735,6 @@ static int ptlrpcd_init(void) int nthreads = num_online_cpus(); char name[16]; int size, i = -1, j, rc = 0; - ENTRY; if (max_ptlrpcds > 0 && max_ptlrpcds < nthreads) nthreads = max_ptlrpcds; @@ -806,7 +797,6 @@ static int ptlrpcd_init(void) int ptlrpcd_addref(void) { int rc = 0; - ENTRY; mutex_lock(&ptlrpcd_mutex); if (++ptlrpcd_users == 1) diff --git a/drivers/staging/lustre/lustre/ptlrpc/recover.c b/drivers/staging/lustre/lustre/ptlrpc/recover.c index 2960889834a21..29a9f0acc6720 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/recover.c +++ b/drivers/staging/lustre/lustre/ptlrpc/recover.c @@ -60,8 +60,6 @@ */ void ptlrpc_initiate_recovery(struct obd_import *imp) { - ENTRY; - CDEBUG(D_HA, "%s: starting recovery\n", obd2cli_tgt(imp->imp_obd)); ptlrpc_connect_import(imp); @@ -78,7 +76,6 @@ int ptlrpc_replay_next(struct obd_import *imp, int *inflight) struct list_head *tmp, *pos; struct ptlrpc_request *req = NULL; __u64 last_transno; - ENTRY; *inflight = 0; @@ -152,8 +149,6 @@ int ptlrpc_resend(struct obd_import *imp) { struct ptlrpc_request *req, *next; - ENTRY; - /* As long as we're in recovery, nothing should be added to the sending * list, so we don't need to hold the lock during this iteration and * resend process. @@ -203,7 +198,6 @@ EXPORT_SYMBOL(ptlrpc_wake_delayed); void ptlrpc_request_handle_notconn(struct ptlrpc_request *failed_req) { struct obd_import *imp = failed_req->rq_import; - ENTRY; CDEBUG(D_HA, "import %s of %s@%s abruptly disconnected: reconnecting\n", imp->imp_obd->obd_name, obd2cli_tgt(imp->imp_obd), @@ -246,7 +240,6 @@ int ptlrpc_set_import_active(struct obd_import *imp, int active) struct obd_device *obd = imp->imp_obd; int rc = 0; - ENTRY; LASSERT(obd); /* When deactivating, mark import invalid, and abort in-flight @@ -287,7 +280,6 @@ EXPORT_SYMBOL(ptlrpc_set_import_active); int ptlrpc_recover_import(struct obd_import *imp, char *new_uuid, int async) { int rc = 0; - ENTRY; spin_lock(&imp->imp_lock); if (imp->imp_state == LUSTRE_IMP_NEW || imp->imp_deactive || diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c b/drivers/staging/lustre/lustre/ptlrpc/sec.c index 349c57b6d78a3..9ec7157e7fd91 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c @@ -396,7 +396,6 @@ int sptlrpc_req_get_ctx(struct ptlrpc_request *req) struct obd_import *imp = req->rq_import; struct ptlrpc_sec *sec; int rc; - ENTRY; LASSERT(!req->rq_cli_ctx); LASSERT(imp); @@ -428,8 +427,6 @@ int sptlrpc_req_get_ctx(struct ptlrpc_request *req) */ void sptlrpc_req_put_ctx(struct ptlrpc_request *req, int sync) { - ENTRY; - LASSERT(req); LASSERT(req->rq_cli_ctx); @@ -520,7 +517,6 @@ int sptlrpc_req_replace_dead_ctx(struct ptlrpc_request *req) struct ptlrpc_cli_ctx *oldctx = req->rq_cli_ctx; struct ptlrpc_cli_ctx *newctx; int rc; - ENTRY; LASSERT(oldctx); @@ -639,7 +635,6 @@ int sptlrpc_req_refresh_ctx(struct ptlrpc_request *req, long timeout) struct ptlrpc_sec *sec; struct l_wait_info lwi; int rc; - ENTRY; LASSERT(ctx); @@ -889,7 +884,6 @@ int sptlrpc_import_check_ctx(struct obd_import *imp) struct ptlrpc_cli_ctx *ctx; struct ptlrpc_request *req = NULL; int rc; - ENTRY; might_sleep(); @@ -941,7 +935,6 @@ int sptlrpc_cli_wrap_request(struct ptlrpc_request *req) { struct ptlrpc_cli_ctx *ctx = req->rq_cli_ctx; int rc = 0; - ENTRY; LASSERT(ctx); LASSERT(ctx->cc_sec); @@ -984,7 +977,6 @@ static int do_cli_unwrap_reply(struct ptlrpc_request *req) { struct ptlrpc_cli_ctx *ctx = req->rq_cli_ctx; int rc; - ENTRY; LASSERT(ctx); LASSERT(ctx->cc_sec); @@ -1096,7 +1088,6 @@ int sptlrpc_cli_unwrap_early_reply(struct ptlrpc_request *req, char *early_buf; int early_bufsz, early_size; int rc; - ENTRY; OBD_ALLOC_PTR(early_req); if (early_req == NULL) @@ -1285,7 +1276,6 @@ struct ptlrpc_sec * sptlrpc_sec_create(struct obd_import *imp, struct ptlrpc_sec_policy *policy; struct ptlrpc_sec *sec; char str[32]; - ENTRY; if (svc_ctx) { LASSERT(imp->imp_dlm_fake == 1); @@ -1406,7 +1396,6 @@ int sptlrpc_import_sec_adapt(struct obd_import *imp, enum lustre_sec_part sp; char str[24]; int rc = 0; - ENTRY; might_sleep(); @@ -1669,7 +1658,6 @@ int sptlrpc_cli_alloc_repbuf(struct ptlrpc_request *req, int msgsize) { struct ptlrpc_cli_ctx *ctx = req->rq_cli_ctx; struct ptlrpc_sec_policy *policy; - ENTRY; LASSERT(ctx); LASSERT(ctx->cc_sec); @@ -1690,7 +1678,6 @@ void sptlrpc_cli_free_repbuf(struct ptlrpc_request *req) { struct ptlrpc_cli_ctx *ctx = req->rq_cli_ctx; struct ptlrpc_sec_policy *policy; - ENTRY; LASSERT(ctx); LASSERT(ctx->cc_sec); @@ -2033,7 +2020,6 @@ int sptlrpc_svc_unwrap_request(struct ptlrpc_request *req) struct ptlrpc_sec_policy *policy; struct lustre_msg *msg = req->rq_reqbuf; int rc; - ENTRY; LASSERT(msg); LASSERT(req->rq_reqmsg == NULL); @@ -2093,7 +2079,6 @@ int sptlrpc_svc_alloc_rs(struct ptlrpc_request *req, int msglen) struct ptlrpc_sec_policy *policy; struct ptlrpc_reply_state *rs; int rc; - ENTRY; LASSERT(req->rq_svc_ctx); LASSERT(req->rq_svc_ctx->sc_policy); @@ -2132,7 +2117,6 @@ int sptlrpc_svc_wrap_reply(struct ptlrpc_request *req) { struct ptlrpc_sec_policy *policy; int rc; - ENTRY; LASSERT(req->rq_svc_ctx); LASSERT(req->rq_svc_ctx->sc_policy); @@ -2153,7 +2137,6 @@ void sptlrpc_svc_free_rs(struct ptlrpc_reply_state *rs) { struct ptlrpc_sec_policy *policy; unsigned int prealloc; - ENTRY; LASSERT(rs->rs_svc_ctx); LASSERT(rs->rs_svc_ctx->sc_policy); diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_config.c b/drivers/staging/lustre/lustre/ptlrpc/sec_config.c index a45a3929b59f5..f12bdeb8b1f88 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_config.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_config.c @@ -661,7 +661,6 @@ static int __sptlrpc_process_config(struct lustre_cfg *lcfg, char fsname[MTI_NAME_MAXLEN]; struct sptlrpc_rule rule; int rc; - ENTRY; target = lustre_cfg_string(lcfg, 1); if (target == NULL) { @@ -905,7 +904,6 @@ EXPORT_SYMBOL(sptlrpc_target_choose_flavor); void sptlrpc_conf_client_adapt(struct obd_device *obd) { struct obd_import *imp; - ENTRY; LASSERT(strcmp(obd->obd_type->typ_name, LUSTRE_MDC_NAME) == 0 || strcmp(obd->obd_type->typ_name, LUSTRE_OSC_NAME) ==0); @@ -1011,7 +1009,6 @@ int sptlrpc_target_local_copy_conf(struct obd_device *obd, struct lvfs_run_ctxt saved; struct dentry *dentry; int rc; - ENTRY; ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT); if (ctxt == NULL) @@ -1068,7 +1065,6 @@ static int local_read_handler(const struct lu_env *env, struct sptlrpc_conf *conf = (struct sptlrpc_conf *) data; struct lustre_cfg *lcfg = (struct lustre_cfg *)(rec + 1); int cfg_len, rc; - ENTRY; if (rec->lrh_type != OBD_CFG_REC) { CERROR("unhandled lrh_type: %#x\n", rec->lrh_type); @@ -1100,7 +1096,6 @@ int sptlrpc_target_local_read_conf(struct obd_device *obd, struct llog_ctxt *ctxt; struct lvfs_run_ctxt saved; int rc; - ENTRY; LASSERT(conf->sc_updated == 0 && conf->sc_local == 0); @@ -1160,7 +1155,6 @@ int sptlrpc_conf_target_get_rules(struct obd_device *obd, enum lustre_sec_part sp_dst; char fsname[MTI_NAME_MAXLEN]; int rc = 0; - ENTRY; if (strcmp(obd->obd_type->typ_name, LUSTRE_MDT_NAME) == 0) { sp_dst = LUSTRE_SP_MDT; diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c index f552d2f182b1a..f5fbdbe0c85e4 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c @@ -192,7 +192,6 @@ int plain_ctx_sign(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req) { struct lustre_msg *msg = req->rq_reqbuf; struct plain_header *phdr; - ENTRY; msg->lm_secflvr = req->rq_flvr.sf_rpc; @@ -219,7 +218,6 @@ int plain_ctx_verify(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req) struct plain_header *phdr; __u32 cksum; int swabbed; - ENTRY; if (msg->lm_bufcount != PLAIN_PACK_SEGMENTS) { CERROR("unexpected reply buf count %u\n", msg->lm_bufcount); @@ -417,7 +415,6 @@ static void plain_destroy_sec(struct ptlrpc_sec *sec) { struct plain_sec *plsec = sec2plsec(sec); - ENTRY; LASSERT(sec->ps_policy == &plain_policy); LASSERT(sec->ps_import); @@ -445,7 +442,6 @@ struct ptlrpc_sec *plain_create_sec(struct obd_import *imp, struct plain_sec *plsec; struct ptlrpc_sec *sec; struct ptlrpc_cli_ctx *ctx; - ENTRY; LASSERT(SPTLRPC_FLVR_POLICY(sf->sf_rpc) == SPTLRPC_POLICY_PLAIN); @@ -491,7 +487,6 @@ struct ptlrpc_cli_ctx *plain_lookup_ctx(struct ptlrpc_sec *sec, { struct plain_sec *plsec = sec2plsec(sec); struct ptlrpc_cli_ctx *ctx; - ENTRY; read_lock(&plsec->pls_lock); ctx = plsec->pls_ctx; @@ -526,7 +521,6 @@ int plain_flush_ctx_cache(struct ptlrpc_sec *sec, { struct plain_sec *plsec = sec2plsec(sec); struct ptlrpc_cli_ctx *ctx; - ENTRY; /* do nothing unless caller want to flush for 'all' */ if (uid != -1) @@ -549,7 +543,6 @@ int plain_alloc_reqbuf(struct ptlrpc_sec *sec, { __u32 buflens[PLAIN_PACK_SEGMENTS] = { 0, }; int alloc_len; - ENTRY; buflens[PLAIN_PACK_HDR_OFF] = sizeof(struct plain_header); buflens[PLAIN_PACK_MSG_OFF] = msgsize; @@ -592,7 +585,6 @@ static void plain_free_reqbuf(struct ptlrpc_sec *sec, struct ptlrpc_request *req) { - ENTRY; if (!req->rq_pool) { OBD_FREE_LARGE(req->rq_reqbuf, req->rq_reqbuf_len); req->rq_reqbuf = NULL; @@ -608,7 +600,6 @@ int plain_alloc_repbuf(struct ptlrpc_sec *sec, { __u32 buflens[PLAIN_PACK_SEGMENTS] = { 0, }; int alloc_len; - ENTRY; buflens[PLAIN_PACK_HDR_OFF] = sizeof(struct plain_header); buflens[PLAIN_PACK_MSG_OFF] = msgsize; @@ -637,7 +628,6 @@ static void plain_free_repbuf(struct ptlrpc_sec *sec, struct ptlrpc_request *req) { - ENTRY; OBD_FREE_LARGE(req->rq_repbuf, req->rq_repbuf_len); req->rq_repbuf = NULL; req->rq_repbuf_len = 0; @@ -652,7 +642,6 @@ int plain_enlarge_reqbuf(struct ptlrpc_sec *sec, struct lustre_msg *newbuf; int oldsize; int newmsg_size, newbuf_size; - ENTRY; LASSERT(req->rq_reqbuf); LASSERT(req->rq_reqbuf_len >= req->rq_reqlen); @@ -715,7 +704,6 @@ int plain_accept(struct ptlrpc_request *req) struct lustre_msg *msg = req->rq_reqbuf; struct plain_header *phdr; int swabbed; - ENTRY; LASSERT(SPTLRPC_FLVR_POLICY(req->rq_flvr.sf_rpc) == SPTLRPC_POLICY_PLAIN); @@ -787,7 +775,6 @@ int plain_alloc_rs(struct ptlrpc_request *req, int msgsize) struct ptlrpc_reply_state *rs; __u32 buflens[PLAIN_PACK_SEGMENTS] = { 0, }; int rs_size = sizeof(*rs); - ENTRY; LASSERT(msgsize % 8 == 0); @@ -827,8 +814,6 @@ int plain_alloc_rs(struct ptlrpc_request *req, int msgsize) static void plain_free_rs(struct ptlrpc_reply_state *rs) { - ENTRY; - LASSERT(atomic_read(&rs->rs_svc_ctx->sc_refcount) > 1); atomic_dec(&rs->rs_svc_ctx->sc_refcount); @@ -844,7 +829,6 @@ int plain_authorize(struct ptlrpc_request *req) struct lustre_msg_v2 *msg = rs->rs_repbuf; struct plain_header *phdr; int len; - ENTRY; LASSERT(rs); LASSERT(msg); diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index 87bd63858b1c4..68afbc5db2231 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -369,7 +369,6 @@ static void rs_batch_fini(struct rs_batch *b) void ptlrpc_dispatch_difficult_reply(struct ptlrpc_reply_state *rs) { struct ptlrpc_hr_thread *hrt; - ENTRY; LASSERT(list_empty(&rs->rs_list)); @@ -386,8 +385,6 @@ void ptlrpc_dispatch_difficult_reply(struct ptlrpc_reply_state *rs) void ptlrpc_schedule_difficult_reply(struct ptlrpc_reply_state *rs) { - ENTRY; - LASSERT(spin_is_locked(&rs->rs_svcpt->scp_rep_lock)); LASSERT(spin_is_locked(&rs->rs_lock)); LASSERT (rs->rs_difficult); @@ -409,7 +406,6 @@ void ptlrpc_commit_replies(struct obd_export *exp) { struct ptlrpc_reply_state *rs, *nxt; DECLARE_RS_BATCH(batch); - ENTRY; rs_batch_init(&batch); /* Find any replies that have been committed and get their service @@ -702,7 +698,6 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf, int cpt; int rc; int i; - ENTRY; LASSERT(conf->psc_buf.bc_nbufs > 0); LASSERT(conf->psc_buf.bc_buf_size >= @@ -1037,8 +1032,6 @@ static void ptlrpc_update_export_timer(struct obd_export *exp, long extra_delay) struct obd_export *oldest_exp; time_t oldest_time, new_time; - ENTRY; - LASSERT(exp); /* Compensate for slow machines, etc, by faking our request time @@ -1261,7 +1254,6 @@ static int ptlrpc_at_send_early_reply(struct ptlrpc_request *req) cfs_duration_t olddl = req->rq_deadline - cfs_time_current_sec(); time_t newdl; int rc; - ENTRY; /* deadline is when the client expects us to reply, margin is the difference between clients' and servers' expectations */ @@ -1401,7 +1393,6 @@ static int ptlrpc_at_check_timed(struct ptlrpc_service_part *svcpt) time_t now = cfs_time_current_sec(); cfs_duration_t delay; int first, counter = 0; - ENTRY; spin_lock(&svcpt->scp_at_lock); if (svcpt->scp_at_check == 0) { @@ -1503,7 +1494,6 @@ static int ptlrpc_server_hpreq_init(struct ptlrpc_service_part *svcpt, struct ptlrpc_request *req) { int rc = 0; - ENTRY; if (svcpt->scp_service->srv_ops.so_hpreq_handler) { rc = svcpt->scp_service->srv_ops.so_hpreq_handler(req); @@ -1547,7 +1537,6 @@ static int ptlrpc_server_hpreq_init(struct ptlrpc_service_part *svcpt, /** Remove the request from the export list. */ static void ptlrpc_server_hpreq_fini(struct ptlrpc_request *req) { - ENTRY; if (req->rq_export && req->rq_ops) { /* refresh lock timeout again so that client has more * room to send lock cancel RPC. */ @@ -1589,7 +1578,6 @@ static int ptlrpc_server_request_add(struct ptlrpc_service_part *svcpt, struct ptlrpc_request *req) { int rc; - ENTRY; rc = ptlrpc_server_hpreq_init(svcpt, req); if (rc < 0) @@ -1703,7 +1691,6 @@ static struct ptlrpc_request * ptlrpc_server_request_get(struct ptlrpc_service_part *svcpt, bool force) { struct ptlrpc_request *req = NULL; - ENTRY; spin_lock(&svcpt->scp_req_lock); @@ -1753,7 +1740,6 @@ ptlrpc_server_handle_req_in(struct ptlrpc_service_part *svcpt, struct ptlrpc_request *req; __u32 deadline; int rc; - ENTRY; spin_lock(&svcpt->scp_lock); if (list_empty(&svcpt->scp_req_incoming)) { @@ -1900,7 +1886,6 @@ ptlrpc_server_handle_request(struct ptlrpc_service_part *svcpt, long timediff; int rc; int fail_opc = 0; - ENTRY; request = ptlrpc_server_request_get(svcpt, false); if (request == NULL) @@ -2057,7 +2042,6 @@ ptlrpc_handle_rs(struct ptlrpc_reply_state *rs) struct obd_export *exp; int nlocks; int been_handled; - ENTRY; exp = rs->rs_export; @@ -2294,7 +2278,6 @@ static int ptlrpc_main(void *arg) #endif struct lu_env *env; int counter = 0, rc = 0; - ENTRY; thread->t_pid = current_pid(); unshare_fs_struct(); @@ -2560,7 +2543,6 @@ static int ptlrpc_start_hr_threads(void) struct ptlrpc_hr_partition *hrp; int i; int j; - ENTRY; cfs_percpt_for_each(hrp, i, ptlrpc_hr.hr_partitions) { int rc = 0; @@ -2594,8 +2576,6 @@ static void ptlrpc_svcpt_stop_threads(struct ptlrpc_service_part *svcpt) struct ptlrpc_thread *thread; LIST_HEAD (zombie); - ENTRY; - CDEBUG(D_INFO, "Stopping threads for service %s\n", svcpt->scp_service->srv_name); @@ -2645,7 +2625,6 @@ void ptlrpc_stop_all_threads(struct ptlrpc_service *svc) { struct ptlrpc_service_part *svcpt; int i; - ENTRY; ptlrpc_service_for_each_part(svcpt, i, svc) { if (svcpt->scp_service != NULL) @@ -2661,7 +2640,6 @@ int ptlrpc_start_threads(struct ptlrpc_service *svc) int rc = 0; int i; int j; - ENTRY; /* We require 2 threads min, see note in ptlrpc_server_handle_request */ LASSERT(svc->srv_nthrs_cpt_init >= PTLRPC_NTHRS_INIT); @@ -2694,7 +2672,6 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait) struct ptlrpc_thread *thread; struct ptlrpc_service *svc; int rc; - ENTRY; LASSERT(svcpt != NULL); @@ -2801,7 +2778,6 @@ int ptlrpc_hr_init(void) int i; int j; int weight; - ENTRY; memset(&ptlrpc_hr, 0, sizeof(ptlrpc_hr)); ptlrpc_hr.hr_cpt_table = cfs_cpt_table; @@ -3068,8 +3044,6 @@ ptlrpc_service_free(struct ptlrpc_service *svc) int ptlrpc_unregister_service(struct ptlrpc_service *service) { - ENTRY; - CDEBUG(D_NET, "%s: tearing down\n", service->srv_name); service->srv_is_stopping = 1; -- GitLab From e05e02e42092dc5e432a9c84d46bd3109808172d Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 2 Aug 2013 18:20:34 +0800 Subject: [PATCH 454/942] staging: lustre: remove RETURN_EXIT macro We have a kernel-wide function tracing system, so use that instead of rolling a custom one just for one filesystem. Cc: Peng Tao Cc: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../lustre/include/linux/libcfs/libcfs_debug.h | 6 ------ drivers/staging/lustre/lustre/llite/dcache.c | 2 +- drivers/staging/lustre/lustre/llite/statahead.c | 14 +++++++------- drivers/staging/lustre/lustre/lov/lov_io.c | 1 - drivers/staging/lustre/lustre/mgc/mgc_request.c | 2 +- drivers/staging/lustre/lustre/osc/osc_lock.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/nrs.c | 5 ----- drivers/staging/lustre/lustre/ptlrpc/service.c | 4 ++-- 8 files changed, 12 insertions(+), 24 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h index feb7a6bc6efe6..17189d9e3cbaf 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h @@ -314,12 +314,6 @@ do { \ CDEBUG(D_TRACE, "Process leaving\n"); \ } while(0) -#define RETURN_EXIT \ -do { \ - EXIT; \ - return; \ -} while (0) - extern int libcfs_debug_msg(struct libcfs_debug_msg_data *msgdata, const char *format1, ...) __attribute__ ((format (printf, 2, 3))); diff --git a/drivers/staging/lustre/lustre/llite/dcache.c b/drivers/staging/lustre/lustre/llite/dcache.c index 628fae410bdbf..484af85f97d65 100644 --- a/drivers/staging/lustre/lustre/llite/dcache.c +++ b/drivers/staging/lustre/lustre/llite/dcache.c @@ -63,7 +63,7 @@ static void ll_release(struct dentry *de) LASSERT(de != NULL); lld = ll_d2d(de); if (lld == NULL) /* NFS copies the de->d_op methods (bug 4655) */ - RETURN_EXIT; + return; if (lld->lld_it) { ll_intent_release(lld->lld_it); diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c index be1c3a8887027..772e4ce31e6b4 100644 --- a/drivers/staging/lustre/lustre/llite/statahead.c +++ b/drivers/staging/lustre/lustre/llite/statahead.c @@ -516,7 +516,7 @@ static void ll_sai_put(struct ll_statahead_info *sai) /* It is race case, the interpret callback just hold * a reference count */ spin_unlock(&lli->lli_sa_lock); - RETURN_EXIT; + return; } LASSERT(lli->lli_opendir_key == NULL); @@ -564,7 +564,7 @@ static void ll_agl_trigger(struct inode *inode, struct ll_statahead_info *sai) if (is_omitted_entry(sai, index + 1)) { lli->lli_agl_index = 0; iput(inode); - RETURN_EXIT; + return; } /* Someone is in glimpse (sync or async), do nothing. */ @@ -572,7 +572,7 @@ static void ll_agl_trigger(struct inode *inode, struct ll_statahead_info *sai) if (rc == 0) { lli->lli_agl_index = 0; iput(inode); - RETURN_EXIT; + return; } /* @@ -593,7 +593,7 @@ static void ll_agl_trigger(struct inode *inode, struct ll_statahead_info *sai) up_write(&lli->lli_glimpse_sem); lli->lli_agl_index = 0; iput(inode); - RETURN_EXIT; + return; } CDEBUG(D_READA, "Handling (init) async glimpse: inode = " @@ -628,7 +628,7 @@ static void ll_post_statahead(struct ll_statahead_info *sai) spin_lock(&lli->lli_sa_lock); if (unlikely(sa_received_empty(sai))) { spin_unlock(&lli->lli_sa_lock); - RETURN_EXIT; + return; } entry = sa_first_received_entry(sai); atomic_inc(&entry->se_refcount); @@ -930,7 +930,7 @@ static void ll_statahead_one(struct dentry *parent, const char* entry_name, entry = ll_sa_entry_alloc(sai, sai->sai_index, entry_name, entry_name_len); if (IS_ERR(entry)) - RETURN_EXIT; + return; dentry = d_lookup(parent, &entry->se_qstr); if (!dentry) { @@ -1038,7 +1038,7 @@ static void ll_start_agl(struct dentry *parent, struct ll_statahead_info *sai) if (IS_ERR(task)) { CERROR("can't start ll_agl thread, rc: %ld\n", PTR_ERR(task)); thread_set_flags(thread, SVC_STOPPED); - RETURN_EXIT; + return; } l_wait_event(thread->t_ctl_waitq, diff --git a/drivers/staging/lustre/lustre/lov/lov_io.c b/drivers/staging/lustre/lustre/lov/lov_io.c index 0ef2293a65a0b..10e36c908443e 100644 --- a/drivers/staging/lustre/lustre/lov/lov_io.c +++ b/drivers/staging/lustre/lustre/lov/lov_io.c @@ -742,7 +742,6 @@ static void lov_io_fsync_end(const struct lu_env *env, if (subio->ci_result == 0) *written += subio->u.ci_fsync.fi_nr_written; } - RETURN_EXIT; } static const struct cl_io_operations lov_io_ops = { diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c index 069681507129f..6512b7f4d3dc4 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c @@ -561,7 +561,7 @@ static void mgc_requeue_add(struct config_llog_data *cld) mutex_lock(&cld->cld_lock); if (cld->cld_stopping || cld->cld_lostlock) { mutex_unlock(&cld->cld_lock); - RETURN_EXIT; + return; } /* this refcount will be released in mgc_requeue_thread. */ config_log_get(cld); diff --git a/drivers/staging/lustre/lustre/osc/osc_lock.c b/drivers/staging/lustre/lustre/osc/osc_lock.c index a13215dd4a9e9..ef6f1bb9150b0 100644 --- a/drivers/staging/lustre/lustre/osc/osc_lock.c +++ b/drivers/staging/lustre/lustre/osc/osc_lock.c @@ -344,7 +344,7 @@ static void osc_lock_lvb_update(const struct lu_env *env, struct osc_lock *olck, unsigned valid; if (!(olck->ols_flags & LDLM_FL_LVB_READY)) - RETURN_EXIT; + return; lvb = &olck->ols_lvb; obj = olck->ols_cl.cls_obj; diff --git a/drivers/staging/lustre/lustre/ptlrpc/nrs.c b/drivers/staging/lustre/lustre/ptlrpc/nrs.c index 352c0f1af4717..afc52326b1cb5 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/nrs.c +++ b/drivers/staging/lustre/lustre/ptlrpc/nrs.c @@ -158,11 +158,6 @@ static void nrs_policy_stop_primary(struct ptlrpc_nrs *nrs) struct ptlrpc_nrs_policy *tmp = nrs->nrs_policy_primary; if (tmp == NULL) { - /** - * XXX: This should really be RETURN_EXIT, but the latter does - * not currently print anything out, and possibly should be - * fixed to do so. - */ EXIT; return; } diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index 68afbc5db2231..1a73f8a57b418 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -1043,7 +1043,7 @@ static void ptlrpc_update_export_timer(struct obd_export *exp, long extra_delay) /* Do not pay attention on 1sec or smaller renewals. */ new_time = cfs_time_current_sec() + extra_delay; if (exp->exp_last_request_time + 1 /*second */ >= new_time) - RETURN_EXIT; + return; exp->exp_last_request_time = new_time; CDEBUG(D_HA, "updating export %s at "CFS_TIME_T" exp %p\n", @@ -1058,7 +1058,7 @@ static void ptlrpc_update_export_timer(struct obd_export *exp, long extra_delay) if (list_empty(&exp->exp_obd_chain_timed)) { /* this one is not timed */ spin_unlock(&exp->exp_obd->obd_dev_lock); - RETURN_EXIT; + return; } list_move_tail(&exp->exp_obd_chain_timed, -- GitLab From 23f14e79ace301c1e46b52344ce02e72254c57b6 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sat, 3 Aug 2013 06:01:58 +0800 Subject: [PATCH 455/942] staging: lustre: remove EXIT macro We have a kernel-wide function tracing system, so use that instead of rolling a custom one just for one filesystem. Cc: Peng Tao Cc: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../include/linux/libcfs/libcfs_debug.h | 5 ---- .../lustre/lnet/klnds/socklnd/socklnd_cb.c | 6 ---- .../lnet/klnds/socklnd/socklnd_lib-linux.c | 2 -- drivers/staging/lustre/lnet/lnet/lib-msg.c | 1 - .../staging/lustre/lustre/fid/fid_request.c | 3 -- drivers/staging/lustre/lustre/fld/fld_cache.c | 8 ----- .../staging/lustre/lustre/fld/fld_request.c | 5 ---- .../lustre/lustre/include/lustre_cfg.h | 1 - .../lustre/lustre/include/lustre_lib.h | 1 - .../lustre/lustre/include/lustre_mdc.h | 4 +-- .../staging/lustre/lustre/include/obd_class.h | 6 ---- .../lustre/lustre/lclient/lcommon_cl.c | 1 - .../lustre/lustre/ldlm/interval_tree.c | 4 --- .../staging/lustre/lustre/ldlm/ldlm_flock.c | 4 --- drivers/staging/lustre/lustre/ldlm/ldlm_lib.c | 7 ----- .../staging/lustre/lustre/ldlm/ldlm_lock.c | 30 ------------------- .../staging/lustre/lustre/ldlm/ldlm_lockd.c | 6 ---- .../staging/lustre/lustre/ldlm/ldlm_pool.c | 4 --- .../staging/lustre/lustre/ldlm/ldlm_request.c | 5 ---- .../lustre/lustre/ldlm/ldlm_resource.c | 4 --- drivers/staging/lustre/lustre/libcfs/hash.c | 2 -- .../lustre/lustre/libcfs/linux/linux-debug.c | 2 -- .../lustre/lustre/libcfs/upcall_cache.c | 3 -- drivers/staging/lustre/lustre/llite/dcache.c | 5 ---- drivers/staging/lustre/lustre/llite/dir.c | 4 --- drivers/staging/lustre/lustre/llite/file.c | 7 ----- .../staging/lustre/lustre/llite/llite_capa.c | 1 - .../staging/lustre/lustre/llite/llite_close.c | 7 ----- .../staging/lustre/lustre/llite/llite_lib.c | 20 ------------- .../staging/lustre/lustre/llite/llite_mmap.c | 3 -- .../staging/lustre/lustre/llite/llite_nfs.c | 2 -- drivers/staging/lustre/lustre/llite/namei.c | 3 -- drivers/staging/lustre/lustre/llite/rw.c | 1 - .../staging/lustre/lustre/llite/statahead.c | 15 ---------- drivers/staging/lustre/lustre/llite/vvp_io.c | 1 - .../staging/lustre/lustre/llite/vvp_page.c | 3 -- drivers/staging/lustre/lustre/llite/xattr.c | 1 - .../staging/lustre/lustre/lmv/lmv_intent.c | 1 - drivers/staging/lustre/lustre/lmv/lmv_obd.c | 4 --- drivers/staging/lustre/lustre/lov/lov_dev.c | 2 -- drivers/staging/lustre/lustre/lov/lov_io.c | 7 ----- drivers/staging/lustre/lustre/lov/lov_lock.c | 6 ---- .../staging/lustre/lustre/lov/lov_object.c | 6 ---- drivers/staging/lustre/lustre/lov/lov_page.c | 2 -- drivers/staging/lustre/lustre/lov/lov_pool.c | 7 ----- .../staging/lustre/lustre/lov/lov_request.c | 1 - .../staging/lustre/lustre/lov/lovsub_dev.c | 2 -- .../staging/lustre/lustre/lov/lovsub_lock.c | 6 ---- .../staging/lustre/lustre/lov/lovsub_object.c | 1 - drivers/staging/lustre/lustre/mdc/mdc_locks.c | 1 - .../staging/lustre/lustre/mdc/mdc_request.c | 10 ------- .../staging/lustre/lustre/mgc/mgc_request.c | 6 ---- drivers/staging/lustre/lustre/obdclass/acl.c | 3 -- drivers/staging/lustre/lustre/obdclass/capa.c | 4 --- .../staging/lustre/lustre/obdclass/cl_io.c | 30 ------------------- .../staging/lustre/lustre/obdclass/cl_lock.c | 21 ------------- .../lustre/lustre/obdclass/cl_object.c | 3 -- .../staging/lustre/lustre/obdclass/cl_page.c | 19 ------------ .../lustre/lustre/obdclass/class_obd.c | 2 -- .../staging/lustre/lustre/obdclass/genops.c | 8 ----- .../lustre/obdclass/linux/linux-module.c | 1 - .../staging/lustre/lustre/obdclass/llog_cat.c | 1 - .../staging/lustre/lustre/obdclass/llog_osd.c | 1 - .../lustre/lustre/obdclass/llog_swab.c | 6 ---- .../lustre/lustre/obdclass/lprocfs_status.c | 1 - .../lustre/lustre/obdclass/lustre_handles.c | 3 -- .../lustre/lustre/obdclass/obd_config.c | 2 -- .../lustre/lustre/obdecho/echo_client.c | 7 ----- drivers/staging/lustre/lustre/osc/osc_cache.c | 10 ------- drivers/staging/lustre/lustre/osc/osc_lock.c | 3 -- drivers/staging/lustre/lustre/osc/osc_page.c | 1 - .../staging/lustre/lustre/osc/osc_request.c | 4 --- drivers/staging/lustre/lustre/ptlrpc/client.c | 14 --------- .../staging/lustre/lustre/ptlrpc/connection.c | 5 ++-- drivers/staging/lustre/lustre/ptlrpc/events.c | 7 ----- .../lustre/lustre/ptlrpc/gss/gss_keyring.c | 4 --- .../lustre/lustre/ptlrpc/gss/gss_pipefs.c | 7 ----- .../lustre/lustre/ptlrpc/gss/gss_svc_upcall.c | 1 - .../lustre/lustre/ptlrpc/gss/sec_gss.c | 7 ----- drivers/staging/lustre/lustre/ptlrpc/import.c | 5 ---- .../lustre/lustre/ptlrpc/llog_client.c | 4 --- .../lustre/lustre/ptlrpc/llog_server.c | 4 --- drivers/staging/lustre/lustre/ptlrpc/nrs.c | 8 ----- .../lustre/lustre/ptlrpc/pack_generic.c | 5 ---- drivers/staging/lustre/lustre/ptlrpc/pinger.c | 1 - .../staging/lustre/lustre/ptlrpc/ptlrpcd.c | 8 +---- .../staging/lustre/lustre/ptlrpc/recover.c | 5 ---- drivers/staging/lustre/lustre/ptlrpc/sec.c | 3 -- .../staging/lustre/lustre/ptlrpc/sec_config.c | 1 - .../staging/lustre/lustre/ptlrpc/sec_plain.c | 4 --- .../staging/lustre/lustre/ptlrpc/service.c | 11 ------- 91 files changed, 4 insertions(+), 479 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h index 17189d9e3cbaf..e0ed2cf6e208c 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h @@ -309,11 +309,6 @@ do { \ # error "Unkown compiler" #endif /* __GNUC__ */ -#define EXIT \ -do { \ - CDEBUG(D_TRACE, "Process leaving\n"); \ -} while(0) - extern int libcfs_debug_msg(struct libcfs_debug_msg_data *msgdata, const char *format1, ...) __attribute__ ((format (printf, 2, 3))); diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c index 6a538497f9f89..cdaaca3727190 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c @@ -400,8 +400,6 @@ ksocknal_tx_done (lnet_ni_t *ni, ksock_tx_t *tx) ksocknal_free_tx (tx); if (lnetmsg != NULL) /* KSOCK_MSG_NOOP go without lnetmsg */ lnet_finalize (ni, lnetmsg, rc); - - EXIT; } void @@ -1577,8 +1575,6 @@ void ksocknal_read_callback (ksock_conn_t *conn) wake_up (&sched->kss_waitq); } spin_unlock_bh(&sched->kss_lock); - - EXIT; } /* @@ -1607,8 +1603,6 @@ void ksocknal_write_callback (ksock_conn_t *conn) } spin_unlock_bh(&sched->kss_lock); - - EXIT; } ksock_proto_t * diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c index 6cfcf7758c041..27392d8b3bfef 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c @@ -977,8 +977,6 @@ ksocknal_data_ready (struct sock *sk, int n) ksocknal_read_callback(conn); read_unlock(&ksocknal_data.ksnd_global_lock); - - EXIT; } static void diff --git a/drivers/staging/lustre/lnet/lnet/lib-msg.c b/drivers/staging/lustre/lnet/lnet/lib-msg.c index 214bf38745aeb..fc7ba42a4dd1a 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-msg.c +++ b/drivers/staging/lustre/lnet/lnet/lib-msg.c @@ -52,7 +52,6 @@ lnet_build_unlink_event (lnet_libmd_t *md, lnet_event_t *ev) ev->type = LNET_EVENT_UNLINK; lnet_md_deconstruct(md, &ev->md); lnet_md2handle(&ev->md_handle, md); - EXIT; } /* diff --git a/drivers/staging/lustre/lustre/fid/fid_request.c b/drivers/staging/lustre/lustre/fid/fid_request.c index 59ff87cea083f..5d25a336b8526 100644 --- a/drivers/staging/lustre/lustre/fid/fid_request.c +++ b/drivers/staging/lustre/lustre/fid/fid_request.c @@ -133,7 +133,6 @@ static int seq_client_rpc(struct lu_client_seq *seq, CDEBUG_LIMIT(debug_mask, "%s: Allocated %s-sequence "DRANGE"]\n", seq->lcs_name, opcname, PRANGE(output)); - EXIT; out_req: ptlrpc_req_finished(req); return rc; @@ -407,7 +406,6 @@ static void seq_client_proc_fini(struct lu_client_seq *seq) lprocfs_remove(&seq->lcs_proc_dir); seq->lcs_proc_dir = NULL; } - EXIT; #endif /* LPROCFS */ } @@ -495,7 +493,6 @@ void seq_client_fini(struct lu_client_seq *seq) } seq->lcs_srv = NULL; - EXIT; } EXPORT_SYMBOL(seq_client_fini); diff --git a/drivers/staging/lustre/lustre/fld/fld_cache.c b/drivers/staging/lustre/lustre/fld/fld_cache.c index 9f9f9b5c62900..b1672f773066a 100644 --- a/drivers/staging/lustre/lustre/fld/fld_cache.c +++ b/drivers/staging/lustre/lustre/fld/fld_cache.c @@ -118,8 +118,6 @@ void fld_cache_fini(struct fld_cache *cache) CDEBUG(D_INFO, " Cache hits: "LPU64"%%\n", pct); OBD_FREE_PTR(cache); - - EXIT; } /** @@ -196,8 +194,6 @@ static void fld_fix_new_list(struct fld_cache *cache) c_range->lsr_end == n_range->lsr_end) fld_cache_entry_delete(cache, f_curr); } - - EXIT; } /** @@ -255,8 +251,6 @@ void fld_cache_flush(struct fld_cache *cache) cache->fci_cache_size = 0; fld_cache_shrink(cache); write_unlock(&cache->fci_lock); - - EXIT; } /** @@ -276,7 +270,6 @@ void fld_cache_punch_hole(struct fld_cache *cache, OBD_ALLOC_GFP(fldt, sizeof *fldt, GFP_ATOMIC); if (!fldt) { OBD_FREE_PTR(f_new); - EXIT; /* overlap is not allowed, so dont mess up list. */ return; } @@ -299,7 +292,6 @@ void fld_cache_punch_hole(struct fld_cache *cache, fld_cache_entry_add(cache, fldt, &f_new->fce_list); /* no need to fixup */ - EXIT; } /** diff --git a/drivers/staging/lustre/lustre/fld/fld_request.c b/drivers/staging/lustre/lustre/fld/fld_request.c index 0c928dea899ea..9fe004681abdf 100644 --- a/drivers/staging/lustre/lustre/fld/fld_request.c +++ b/drivers/staging/lustre/lustre/fld/fld_request.c @@ -316,7 +316,6 @@ void fld_client_proc_fini(struct lu_client_fld *fld) lprocfs_remove(&fld->lcf_proc_dir); fld->lcf_proc_dir = NULL; } - EXIT; } #else static int fld_client_proc_init(struct lu_client_fld *fld) @@ -377,7 +376,6 @@ int fld_client_init(struct lu_client_fld *fld, rc = fld_client_proc_init(fld); if (rc) GOTO(out, rc); - EXIT; out: if (rc) fld_client_fini(fld); @@ -408,8 +406,6 @@ void fld_client_fini(struct lu_client_fld *fld) fld_cache_fini(fld->lcf_cache); fld->lcf_cache = NULL; } - - EXIT; } EXPORT_SYMBOL(fld_client_fini); @@ -458,7 +454,6 @@ int fld_client_rpc(struct obd_export *exp, if (prange == NULL) GOTO(out_req, rc = -EFAULT); *range = *prange; - EXIT; out_req: ptlrpc_req_finished(req); return rc; diff --git a/drivers/staging/lustre/lustre/include/lustre_cfg.h b/drivers/staging/lustre/lustre/include/lustre_cfg.h index 5004c9079a8bc..46d5aaf178931 100644 --- a/drivers/staging/lustre/lustre/include/lustre_cfg.h +++ b/drivers/staging/lustre/lustre/include/lustre_cfg.h @@ -253,7 +253,6 @@ static inline void lustre_cfg_free(struct lustre_cfg *lcfg) len = lustre_cfg_len(lcfg->lcfg_bufcount, lcfg->lcfg_buflens); OBD_FREE(lcfg, len); - EXIT; return; } diff --git a/drivers/staging/lustre/lustre/include/lustre_lib.h b/drivers/staging/lustre/lustre/include/lustre_lib.h index 007b2ddc7a9c5..e77a74540da7b 100644 --- a/drivers/staging/lustre/lustre/include/lustre_lib.h +++ b/drivers/staging/lustre/lustre/include/lustre_lib.h @@ -261,7 +261,6 @@ int obd_ioctl_popdata(void *arg, void *data, int len); static inline void obd_ioctl_freedata(char *buf, int len) { OBD_FREE_LARGE(buf, len); - EXIT; return; } diff --git a/drivers/staging/lustre/lustre/include/lustre_mdc.h b/drivers/staging/lustre/lustre/include/lustre_mdc.h index e09646ade9d36..19000259a5e4b 100644 --- a/drivers/staging/lustre/lustre/include/lustre_mdc.h +++ b/drivers/staging/lustre/lustre/include/lustre_mdc.h @@ -124,7 +124,7 @@ static inline void mdc_put_rpc_lock(struct mdc_rpc_lock *lck, { if (it != NULL && (it->it_op == IT_GETATTR || it->it_op == IT_LOOKUP || it->it_op == IT_LAYOUT)) - goto out; + return; if (lck->rpcl_it == MDC_FAKE_RPCL_IT) { /* OBD_FAIL_MDC_RPCS_SEM */ mutex_lock(&lck->rpcl_mutex); @@ -141,8 +141,6 @@ static inline void mdc_put_rpc_lock(struct mdc_rpc_lock *lck, } mutex_unlock(&lck->rpcl_mutex); - out: - EXIT; } static inline void mdc_update_max_ea_from_body(struct obd_export *exp, diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index c42996ba4f9cf..c10477f5faf51 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -649,8 +649,6 @@ static inline void obd_cleanup_client_import(struct obd_device *obd) obd->u.cli.cl_import = NULL; } up_write(&obd->u.cli.cl_sem); - - EXIT; } static inline int @@ -1099,7 +1097,6 @@ static inline void obd_getref(struct obd_device *obd) OBD_COUNTER_INCREMENT(obd, getref); OBP(obd, getref)(obd); } - EXIT; } static inline void obd_putref(struct obd_device *obd) @@ -1108,7 +1105,6 @@ static inline void obd_putref(struct obd_device *obd) OBD_COUNTER_INCREMENT(obd, putref); OBP(obd, putref)(obd); } - EXIT; } static inline int obd_init_export(struct obd_export *exp) @@ -1525,14 +1521,12 @@ static inline void obd_import_event(struct obd_device *obd, { if (!obd) { CERROR("NULL device\n"); - EXIT; return; } if (obd->obd_set_up && OBP(obd, import_event)) { OBD_COUNTER_INCREMENT(obd, import_event); OBP(obd, import_event)(obd, imp, event); } - EXIT; } static inline int obd_llog_connect(struct obd_export *exp, diff --git a/drivers/staging/lustre/lustre/lclient/lcommon_cl.c b/drivers/staging/lustre/lustre/lclient/lcommon_cl.c index 1d3c2340227b2..41168c2cbdf64 100644 --- a/drivers/staging/lustre/lustre/lclient/lcommon_cl.c +++ b/drivers/staging/lustre/lustre/lclient/lcommon_cl.c @@ -674,7 +674,6 @@ void ccc_lock_state(const struct lu_env *env, lock->cll_descr.cld_end == CL_PAGE_EOF) cl_merge_lvb(env, inode); } - EXIT; } /***************************************************************************** diff --git a/drivers/staging/lustre/lustre/ldlm/interval_tree.c b/drivers/staging/lustre/lustre/ldlm/interval_tree.c index 7de620aa295f4..400d28ef703cb 100644 --- a/drivers/staging/lustre/lustre/ldlm/interval_tree.c +++ b/drivers/staging/lustre/lustre/ldlm/interval_tree.c @@ -361,7 +361,6 @@ static void interval_insert_color(struct interval_node *node, } (*root)->in_color = INTERVAL_BLACK; - EXIT; } struct interval_node *interval_insert(struct interval_node *node, @@ -476,7 +475,6 @@ static void interval_erase_color(struct interval_node *node, } if (node) node->in_color = INTERVAL_BLACK; - EXIT; } /* @@ -498,7 +496,6 @@ static void update_maxhigh(struct interval_node *node, break; node = node->in_parent; } - EXIT; } void interval_erase(struct interval_node *node, @@ -570,7 +567,6 @@ void interval_erase(struct interval_node *node, color: if (color == INTERVAL_BLACK) interval_erase_color(child, parent, root); - EXIT; } EXPORT_SYMBOL(interval_erase); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c index b263121e2bf09..9e61144ea24f9 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c @@ -160,7 +160,6 @@ ldlm_flock_destroy(struct ldlm_lock *lock, ldlm_mode_t mode, __u64 flags) } ldlm_lock_destroy_nolock(lock); - EXIT; } /** @@ -553,8 +552,6 @@ ldlm_flock_interrupted_wait(void *data) /* client side - set flag to prevent lock from being put on LRU list */ lock->l_flags |= LDLM_FL_CBPENDING; unlock_res_and_lock(lock); - - EXIT; } /** @@ -840,6 +837,5 @@ void ldlm_destroy_flock_export(struct obd_export *exp) cfs_hash_putref(exp->exp_flock_hash); exp->exp_flock_hash = NULL; } - EXIT; } EXPORT_SYMBOL(ldlm_destroy_flock_export); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c index d77156a98ad8b..4b03e7d8d3ae4 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c @@ -525,8 +525,6 @@ int client_connect_import(const struct lu_env *env, ptlrpc_pinger_add_import(imp); - EXIT; - if (rc) { out_ldlm: cli->cl_conn_count--; @@ -597,8 +595,6 @@ int client_disconnect_export(struct obd_export *exp) ptlrpc_invalidate_import(imp); - EXIT; - out_disconnect: /* Use server style - class_disconnect should be always called for * o_disconnect. */ @@ -667,7 +663,6 @@ void target_send_reply(struct ptlrpc_request *req, int rc, int fail_id) struct obd_export *exp; if (req->rq_no_reply) { - EXIT; return; } @@ -676,7 +671,6 @@ void target_send_reply(struct ptlrpc_request *req, int rc, int fail_id) if (rs == NULL || !rs->rs_difficult) { /* no notifiers */ target_send_reply_msg (req, rc, fail_id); - EXIT; return; } @@ -747,7 +741,6 @@ void target_send_reply(struct ptlrpc_request *req, int rc, int fail_id) } spin_unlock(&rs->rs_lock); spin_unlock(&svcpt->scp_rep_lock); - EXIT; } EXPORT_SYMBOL(target_send_reply); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index 6b214d2ca562e..e0877b20eb94b 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -218,8 +218,6 @@ void ldlm_lock_put(struct ldlm_lock *lock) lu_ref_fini(&lock->l_reference); OBD_FREE_RCU(lock, sizeof(*lock), &lock->l_handle); } - - EXIT; } EXPORT_SYMBOL(ldlm_lock_put); @@ -259,7 +257,6 @@ int ldlm_lock_remove_from_lru(struct ldlm_lock *lock) spin_lock(&ns->ns_lock); rc = ldlm_lock_remove_from_lru_nolock(lock); spin_unlock(&ns->ns_lock); - EXIT; return rc; } @@ -289,7 +286,6 @@ void ldlm_lock_add_to_lru(struct ldlm_lock *lock) spin_lock(&ns->ns_lock); ldlm_lock_add_to_lru_nolock(lock); spin_unlock(&ns->ns_lock); - EXIT; } /** @@ -302,7 +298,6 @@ void ldlm_lock_touch_in_lru(struct ldlm_lock *lock) if (lock->l_flags & LDLM_FL_NS_SRV) { LASSERT(list_empty(&lock->l_lru)); - EXIT; return; } @@ -312,7 +307,6 @@ void ldlm_lock_touch_in_lru(struct ldlm_lock *lock) ldlm_lock_add_to_lru_nolock(lock); } spin_unlock(&ns->ns_lock); - EXIT; } /** @@ -348,7 +342,6 @@ int ldlm_lock_destroy_internal(struct ldlm_lock *lock) if (lock->l_flags & LDLM_FL_DESTROYED) { LASSERT(list_empty(&lock->l_lru)); - EXIT; return 0; } lock->l_flags |= LDLM_FL_DESTROYED; @@ -376,7 +369,6 @@ int ldlm_lock_destroy_internal(struct ldlm_lock *lock) if (lock->l_export && lock->l_completion_ast) lock->l_completion_ast(lock, 0); #endif - EXIT; return 1; } @@ -396,7 +388,6 @@ void ldlm_lock_destroy(struct ldlm_lock *lock) lu_ref_del(&lock->l_reference, "hash", lock); LDLM_LOCK_RELEASE(lock); } - EXIT; } /** @@ -412,7 +403,6 @@ void ldlm_lock_destroy_nolock(struct ldlm_lock *lock) lu_ref_del(&lock->l_reference, "hash", lock); LDLM_LOCK_RELEASE(lock); } - EXIT; } /* this is called by portals_handle2object with the handle lock taken */ @@ -723,7 +713,6 @@ void ldlm_add_ast_work_item(struct ldlm_lock *lock, struct ldlm_lock *new, ldlm_add_bl_work_item(lock, new, work_list); else ldlm_add_cp_work_item(lock, work_list); - EXIT; } /** @@ -902,8 +891,6 @@ void ldlm_lock_decref_internal(struct ldlm_lock *lock, __u32 mode) LDLM_DEBUG(lock, "do not add lock into lru list"); unlock_res_and_lock(lock); } - - EXIT; } /** @@ -985,7 +972,6 @@ static void search_granted_lock(struct list_head *queue, prev->res_link = &mode_end->l_res_link; prev->mode_link = &mode_end->l_sl_mode; prev->policy_link = &req->l_sl_policy; - EXIT; return; } else if (lock->l_resource->lr_type == LDLM_IBITS) { for (;;) { @@ -1004,7 +990,6 @@ static void search_granted_lock(struct list_head *queue, &policy_end->l_sl_mode; prev->policy_link = &policy_end->l_sl_policy; - EXIT; return; } @@ -1023,7 +1008,6 @@ static void search_granted_lock(struct list_head *queue, prev->res_link = &mode_end->l_res_link; prev->mode_link = &mode_end->l_sl_mode; prev->policy_link = &req->l_sl_policy; - EXIT; return; } else { LDLM_ERROR(lock,"is not LDLM_PLAIN or LDLM_IBITS lock"); @@ -1036,7 +1020,6 @@ static void search_granted_lock(struct list_head *queue, prev->res_link = queue->prev; prev->mode_link = &req->l_sl_mode; prev->policy_link = &req->l_sl_policy; - EXIT; return; } @@ -1073,8 +1056,6 @@ static void ldlm_granted_list_add_lock(struct ldlm_lock *lock, list_add(&lock->l_sl_mode, prev->mode_link); if (&lock->l_sl_policy != prev->policy_link) list_add(&lock->l_sl_policy, prev->policy_link); - - EXIT; } /** @@ -1089,7 +1070,6 @@ static void ldlm_grant_lock_with_skiplist(struct ldlm_lock *lock) search_granted_lock(&lock->l_resource->lr_granted, lock, &prev); ldlm_granted_list_add_lock(lock, &prev); - EXIT; } /** @@ -1124,7 +1104,6 @@ void ldlm_grant_lock(struct ldlm_lock *lock, struct list_head *work_list) ldlm_add_ast_work_item(lock, NULL, work_list); ldlm_pool_add(&ldlm_res_to_ns(res)->ns_pool, lock); - EXIT; } /** @@ -1322,7 +1301,6 @@ ldlm_mode_t ldlm_lock_match(struct ldlm_namespace *ns, __u64 flags, if (lock != NULL) GOTO(out, rc = 1); - EXIT; out: unlock_res(res); LDLM_RESOURCE_DELREF(res); @@ -1424,8 +1402,6 @@ ldlm_mode_t ldlm_revalidate_lock_handle(struct lustre_handle *lockh, ldlm_lock_addref_internal_nolock(lock, mode); } - EXIT; - out: if (lock != NULL) { unlock_res_and_lock(lock); @@ -1936,7 +1912,6 @@ void ldlm_reprocess_all_ns(struct ldlm_namespace *ns) cfs_hash_for_each_nolock(ns->ns_rs_hash, ldlm_reprocess_res, NULL); } - EXIT; } EXPORT_SYMBOL(ldlm_reprocess_all_ns); @@ -1957,7 +1932,6 @@ void ldlm_reprocess_all(struct ldlm_resource *res) "LDLM_NAMESPACE_SERVER resource type lock.\n"); LBUG(); } - EXIT; } /** @@ -2035,8 +2009,6 @@ void ldlm_lock_cancel(struct ldlm_lock *lock) * if not to zero out lock->l_granted_mode */ lock->l_granted_mode = LCK_MINMODE; unlock_res_and_lock(lock); - - EXIT; } EXPORT_SYMBOL(ldlm_lock_cancel); @@ -2142,8 +2114,6 @@ void ldlm_lock_downgrade(struct ldlm_lock *lock, int new_mode) ldlm_grant_lock(lock, NULL); unlock_res_and_lock(lock); ldlm_reprocess_all(lock->l_resource); - - EXIT; } EXPORT_SYMBOL(ldlm_lock_downgrade); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c index adab8b81c8528..cce0ad70f162a 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c @@ -171,7 +171,6 @@ void ldlm_handle_bl_callback(struct ldlm_namespace *ns, LDLM_DEBUG(lock, "client blocking callback handler END"); LDLM_LOCK_RELEASE(lock); - EXIT; } /** @@ -353,12 +352,10 @@ static void ldlm_handle_gl_callback(struct ptlrpc_request *req, if (ldlm_bl_to_thread_lock(ns, NULL, lock)) ldlm_handle_bl_callback(ns, NULL, lock); - EXIT; return; } unlock_res_and_lock(lock); LDLM_LOCK_RELEASE(lock); - EXIT; } static int ldlm_callback_reply(struct ptlrpc_request *req, int rc) @@ -933,8 +930,6 @@ void ldlm_put_ref(void) ldlm_refcount--; } mutex_unlock(&ldlm_ref_mutex); - - EXIT; } EXPORT_SYMBOL(ldlm_put_ref); @@ -1031,7 +1026,6 @@ void ldlm_destroy_export(struct obd_export *exp) exp->exp_lock_hash = NULL; ldlm_destroy_flock_export(exp); - EXIT; } EXPORT_SYMBOL(ldlm_destroy_export); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c index 5a1d11e0159a4..e500506c8683b 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c @@ -810,7 +810,6 @@ static int ldlm_pool_proc_init(struct ldlm_pool *pl) "recalc_timing", "sec"); rc = lprocfs_register_stats(pl->pl_proc_dir, "stats", pl->pl_stats); - EXIT; out_free_name: OBD_FREE(var_name, MAX_STRING_SIZE + 1); return rc; @@ -877,7 +876,6 @@ void ldlm_pool_fini(struct ldlm_pool *pl) * any abnormal using cases. */ POISON(pl, 0x5a, sizeof(*pl)); - EXIT; } EXPORT_SYMBOL(ldlm_pool_fini); @@ -1370,7 +1368,6 @@ static int ldlm_pools_thread_start(void) static void ldlm_pools_thread_stop(void) { if (ldlm_pools_thread == NULL) { - EXIT; return; } @@ -1385,7 +1382,6 @@ static void ldlm_pools_thread_stop(void) wait_for_completion(&ldlm_pools_comp); OBD_FREE_PTR(ldlm_pools_thread); ldlm_pools_thread = NULL; - EXIT; } int ldlm_pools_init(void) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c index 0b6dc6a288a54..6c2b94536d82d 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c @@ -456,7 +456,6 @@ int ldlm_cli_enqueue_local(struct ldlm_namespace *ns, lock->l_completion_ast(lock, *flags, NULL); LDLM_DEBUG(lock, "client-side local enqueue handler, new lock created"); - EXIT; out: LDLM_LOCK_RELEASE(lock); out_nolock: @@ -689,7 +688,6 @@ int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req, } LDLM_DEBUG(lock, "client-side enqueue END"); - EXIT; cleanup: if (cleanup_phase == 1 && rc) failed_lock_cleanup(ns, lock, mode); @@ -1083,7 +1081,6 @@ int ldlm_cli_convert(struct lustre_handle *lockh, int new_mode, __u32 *flags) } else { rc = LUSTRE_EDEADLK; } - EXIT; out: LDLM_LOCK_PUT(lock); ptlrpc_req_finished(req); @@ -1168,7 +1165,6 @@ static void ldlm_cancel_pack(struct ptlrpc_request *req, packed++; } CDEBUG(D_DLMTRACE, "%d locks packed\n", packed); - EXIT; } /** @@ -1253,7 +1249,6 @@ int ldlm_cli_cancel_req(struct obd_export *exp, struct list_head *cancels, } ptlrpc_req_finished(req); - EXIT; out: return sent ? sent : rc; } diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index 8b2b3fa16112d..f4d367c5978f9 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -862,7 +862,6 @@ void ldlm_namespace_free_prior(struct ldlm_namespace *ns, int rc; if (!ns) { - EXIT; return; } @@ -887,7 +886,6 @@ void ldlm_namespace_free_prior(struct ldlm_namespace *ns, rc = __ldlm_namespace_free(ns, 1); LASSERT(rc == 0); } - EXIT; } /** @@ -898,7 +896,6 @@ void ldlm_namespace_free_prior(struct ldlm_namespace *ns, void ldlm_namespace_free_post(struct ldlm_namespace *ns) { if (!ns) { - EXIT; return; } @@ -917,7 +914,6 @@ void ldlm_namespace_free_post(struct ldlm_namespace *ns) LASSERT(list_empty(&ns->ns_list_chain)); OBD_FREE_PTR(ns); ldlm_put_ref(); - EXIT; } /** diff --git a/drivers/staging/lustre/lustre/libcfs/hash.c b/drivers/staging/lustre/lustre/libcfs/hash.c index bc7497a9b0649..87f52563eab0b 100644 --- a/drivers/staging/lustre/lustre/libcfs/hash.c +++ b/drivers/staging/lustre/lustre/libcfs/hash.c @@ -1149,8 +1149,6 @@ cfs_hash_destroy(cfs_hash_t *hs) i = cfs_hash_with_bigname(hs) ? CFS_HASH_BIGNAME_LEN : CFS_HASH_NAME_LEN; LIBCFS_FREE(hs, offsetof(cfs_hash_t, hs_name[i])); - - EXIT; } cfs_hash_t *cfs_hash_getref(cfs_hash_t *hs) diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c index 3e61a0d4574b6..ec3d97664b1b8 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c @@ -95,8 +95,6 @@ void libcfs_run_debug_log_upcall(char *file) CDEBUG(D_HA, "Invoked LNET debug log upcall %s %s\n", argv[0], argv[1]); } - - EXIT; } void libcfs_run_upcall(char **argv) diff --git a/drivers/staging/lustre/lustre/libcfs/upcall_cache.c b/drivers/staging/lustre/lustre/libcfs/upcall_cache.c index 7663fb5683713..9b15c7c4e4462 100644 --- a/drivers/staging/lustre/lustre/libcfs/upcall_cache.c +++ b/drivers/staging/lustre/lustre/libcfs/upcall_cache.c @@ -273,7 +273,6 @@ void upcall_cache_put_entry(struct upcall_cache *cache, struct upcall_cache_entry *entry) { if (!entry) { - EXIT; return; } @@ -281,7 +280,6 @@ void upcall_cache_put_entry(struct upcall_cache *cache, spin_lock(&cache->uc_lock); put_entry(cache, entry); spin_unlock(&cache->uc_lock); - EXIT; } EXPORT_SYMBOL(upcall_cache_put_entry); @@ -374,7 +372,6 @@ static void cache_flush(struct upcall_cache *cache, int force) } } spin_unlock(&cache->uc_lock); - EXIT; } void upcall_cache_flush_idle(struct upcall_cache *cache) diff --git a/drivers/staging/lustre/lustre/llite/dcache.c b/drivers/staging/lustre/lustre/llite/dcache.c index 484af85f97d65..ff74783ef9d3c 100644 --- a/drivers/staging/lustre/lustre/llite/dcache.c +++ b/drivers/staging/lustre/lustre/llite/dcache.c @@ -73,8 +73,6 @@ static void ll_release(struct dentry *de) LASSERT(lld->lld_mnt_count == 0); de->d_fsdata = NULL; call_rcu(&lld->lld_rcu_head, free_dentry_data); - - EXIT; } /* Compare if two dentries are the same. Don't match if the existing dentry @@ -267,7 +265,6 @@ void ll_intent_release(struct lookup_intent *it) it->d.lustre.it_disposition = 0; it->d.lustre.it_data = NULL; - EXIT; } void ll_invalidate_aliases(struct inode *inode) @@ -298,8 +295,6 @@ void ll_invalidate_aliases(struct inode *inode) d_lustre_invalidate(dentry, 0); } ll_unlock_dcache(inode); - - EXIT; } int ll_revalidate_it_finish(struct ptlrpc_request *request, diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index 55256812ae207..09bdd3d1e6e65 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -237,7 +237,6 @@ static int ll_dir_filler(void *_hash, struct page *page0) if (page_pool != &page0) OBD_FREE(page_pool, sizeof(struct page *) * max_pages); - EXIT; return rc; } @@ -1300,7 +1299,6 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) GOTO(out_free, rc); } ptlrpc_req_finished(request); - EXIT; out_free: obd_ioctl_freedata(buf, len); return rc; @@ -1522,7 +1520,6 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) GOTO(out_req, rc = -EFAULT); } - EXIT; out_req: ptlrpc_req_finished(request); if (filename) @@ -1587,7 +1584,6 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) if (copy_to_user(&lumd->lmd_st, &st, sizeof(st))) GOTO(free_lsm, rc = -EFAULT); - EXIT; free_lsm: obd_free_memmd(sbi->ll_dt_exp, &lsm); free_lmm: diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 79f5394ac6b25..7f5435b18b65a 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -111,7 +111,6 @@ static void ll_prepare_close(struct inode *inode, struct md_op_data *op_data, ll_pack_inode2opdata(inode, op_data, &och->och_fh); ll_prep_md_op_data(op_data, inode, NULL, NULL, 0, 0, LUSTRE_OPC_ANY, NULL); - EXIT; } static int ll_close_inode_openhandle(struct obd_export *md_exp, @@ -177,9 +176,7 @@ static int ll_close_inode_openhandle(struct obd_export *md_exp, inode->i_ino, rc); } - EXIT; out: - if (exp_connect_som(exp) && !epoch_close && S_ISREG(inode->i_mode) && (och->och_flags & FMODE_WRITE)) { ll_queue_done_writing(inode, LLIF_DONE_WRITING); @@ -1690,7 +1687,6 @@ int ll_data_version(struct inode *inode, __u64 *data_version, } OBD_FREE_PTR(obdo); - EXIT; out: ccc_inode_lsm_put(inode, lsm); RETURN(rc); @@ -2939,8 +2935,6 @@ static int ll_layout_fetch(struct inode *inode, struct ldlm_lock *lock) lock->l_lvb_len = lmmsize; unlock_res_and_lock(lock); - EXIT; - out: ptlrpc_req_finished(req); return rc; @@ -3029,7 +3023,6 @@ static int ll_layout_lock_set(struct lustre_handle *lockh, ldlm_mode_t mode, /* refresh layout failed, need to wait */ wait_layout = rc == -EBUSY; - EXIT; out: LDLM_LOCK_PUT(lock); diff --git a/drivers/staging/lustre/lustre/llite/llite_capa.c b/drivers/staging/lustre/lustre/llite/llite_capa.c index 061a0a574b5d5..3b4f7f82dd422 100644 --- a/drivers/staging/lustre/lustre/llite/llite_capa.c +++ b/drivers/staging/lustre/lustre/llite/llite_capa.c @@ -568,7 +568,6 @@ int ll_update_capa(struct obd_capa *ocapa, struct lustre_capa *capa) if (capa_for_oss(capa)) inode_add_oss_capa(inode, ocapa); DEBUG_CAPA(D_SEC, capa, "renew"); - EXIT; retry: list_del_init(&ocapa->c_list); sort_add_capa(ocapa, ll_capa_list); diff --git a/drivers/staging/lustre/lustre/llite/llite_close.c b/drivers/staging/lustre/lustre/llite/llite_close.c index 20481d8329b0a..a9cd75f16e946 100644 --- a/drivers/staging/lustre/lustre/llite/llite_close.c +++ b/drivers/staging/lustre/lustre/llite/llite_close.c @@ -56,7 +56,6 @@ void vvp_write_pending(struct ccc_object *club, struct ccc_page *page) list_add(&page->cpg_pending_linkage, &club->cob_pending_list); spin_unlock(&lli->lli_lock); - EXIT; } /** records that a write has completed */ @@ -73,7 +72,6 @@ void vvp_write_complete(struct ccc_object *club, struct ccc_page *page) spin_unlock(&lli->lli_lock); if (rc) ll_queue_done_writing(club->cob_inode, 0); - EXIT; } /** Queues DONE_WRITING if @@ -116,7 +114,6 @@ void ll_queue_done_writing(struct inode *inode, unsigned long flags) spin_unlock(&lcq->lcq_lock); } spin_unlock(&lli->lli_lock); - EXIT; } /** Pack SOM attributes info @opdata for CLOSE, DONE_WRITING rpc. */ @@ -136,7 +133,6 @@ void ll_done_writing_attr(struct inode *inode, struct md_op_data *op_data) op_data->op_attr.ia_valid |= ATTR_MTIME_SET | ATTR_CTIME_SET | ATTR_ATIME_SET | ATTR_SIZE | ATTR_BLOCKS; } - EXIT; } /** Closes ioepoch and packs Size-on-MDS attribute if needed into @op_data. */ @@ -204,7 +200,6 @@ void ll_ioepoch_close(struct inode *inode, struct md_op_data *op_data, spin_unlock(&lli->lli_lock); ll_done_writing_attr(inode, op_data); - EXIT; out: return; } @@ -293,7 +288,6 @@ static void ll_done_writing(struct inode *inode) OBD_ALLOC_PTR(op_data); if (op_data == NULL) { CERROR("can't allocate op_data\n"); - EXIT; return; } @@ -317,7 +311,6 @@ static void ll_done_writing(struct inode *inode) md_clear_open_replay_data(ll_i2sbi(inode)->ll_md_exp, och); OBD_FREE_PTR(och); } - EXIT; } static struct ll_inode_info *ll_close_next_lli(struct ll_close_queue *lcq) diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 141243658d7c6..71b8fd9ff1a7f 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -152,7 +152,6 @@ void ll_free_sbi(struct super_block *sb) spin_unlock(&ll_sb_lock); OBD_FREE(sbi, sizeof(*sbi)); } - EXIT; } static struct dentry_operations ll_d_root_ops = { @@ -700,8 +699,6 @@ void client_common_put_super(struct super_block *sb) obd_fid_fini(sbi->ll_md_exp->exp_obd); obd_disconnect(sbi->ll_md_exp); sbi->ll_md_exp = NULL; - - EXIT; } void ll_kill_super(struct super_block *sb) @@ -720,7 +717,6 @@ void ll_kill_super(struct super_block *sb) sb->s_dev = sbi->ll_sdev_orig; sbi->ll_umounting = 1; } - EXIT; } char *ll_read_opt(const char *opt, char *data) @@ -1112,8 +1108,6 @@ void ll_put_super(struct super_block *sb) lustre_common_put_super(sb); module_put(THIS_MODULE); - - EXIT; } /* client_put_super */ struct inode *ll_inode_from_resource_lock(struct ldlm_lock *lock) @@ -1227,8 +1221,6 @@ void ll_clear_inode(struct inode *inode) */ cl_inode_fini(inode); lli->lli_has_smd = false; - - EXIT; } int ll_md_setattr(struct dentry *dentry, struct md_op_data *op_data, @@ -1469,7 +1461,6 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr) * setting times to past, but it is necessary due to possible * time de-synchronization between MDT inode and OST objects */ rc = ll_setattr_ost(inode, attr); - EXIT; out: if (op_data) { if (op_data->op_ioepoch) { @@ -1803,21 +1794,16 @@ void ll_read_inode2(struct inode *inode, void *opaque) inode->i_op = &ll_file_inode_operations; inode->i_fop = sbi->ll_fop; inode->i_mapping->a_ops = (struct address_space_operations *)&ll_aops; - EXIT; } else if (S_ISDIR(inode->i_mode)) { inode->i_op = &ll_dir_inode_operations; inode->i_fop = &ll_dir_operations; - EXIT; } else if (S_ISLNK(inode->i_mode)) { inode->i_op = &ll_fast_symlink_inode_operations; - EXIT; } else { inode->i_op = &ll_special_inode_operations; init_special_inode(inode, inode->i_mode, inode->i_rdev); - - EXIT; } } @@ -1847,8 +1833,6 @@ void ll_delete_inode(struct inode *inode) ll_clear_inode(inode); clear_inode(inode); - - EXIT; } int ll_iocontrol(struct inode *inode, struct file *file, @@ -1974,7 +1958,6 @@ void ll_umount_begin(struct super_block *sb) if (obd == NULL) { CERROR("Invalid MDC connection handle "LPX64"\n", sbi->ll_md_exp->exp_handle.h_cookie); - EXIT; return; } obd->obd_force = 1; @@ -1983,7 +1966,6 @@ void ll_umount_begin(struct super_block *sb) if (obd == NULL) { CERROR("Invalid LOV connection handle "LPX64"\n", sbi->ll_dt_exp->exp_handle.h_cookie); - EXIT; return; } obd->obd_force = 1; @@ -2004,8 +1986,6 @@ void ll_umount_begin(struct super_block *sb) * schedule() and sleep one second if needed, and hope. */ schedule(); - - EXIT; } int ll_remount_fs(struct super_block *sb, int *flags, char *data) diff --git a/drivers/staging/lustre/lustre/llite/llite_mmap.c b/drivers/staging/lustre/lustre/llite/llite_mmap.c index d98a40f61bfce..26a5247cbc29b 100644 --- a/drivers/staging/lustre/lustre/llite/llite_mmap.c +++ b/drivers/staging/lustre/lustre/llite/llite_mmap.c @@ -249,7 +249,6 @@ static int ll_page_mkwrite0(struct vm_area_struct *vma, struct page *vmpage, spin_unlock(&lli->lli_lock); } } - EXIT; out_io: cl_io_fini(env, io); @@ -432,7 +431,6 @@ static void ll_vm_open(struct vm_area_struct * vma) LASSERT(vma->vm_file); LASSERT(atomic_read(&vob->cob_mmap_cnt) >= 0); atomic_inc(&vob->cob_mmap_cnt); - EXIT; } /** @@ -446,7 +444,6 @@ static void ll_vm_close(struct vm_area_struct *vma) LASSERT(vma->vm_file); atomic_dec(&vob->cob_mmap_cnt); LASSERT(atomic_read(&vob->cob_mmap_cnt) >= 0); - EXIT; } diff --git a/drivers/staging/lustre/lustre/llite/llite_nfs.c b/drivers/staging/lustre/lustre/llite/llite_nfs.c index d2661bb20db6b..8b1a76da6c868 100644 --- a/drivers/staging/lustre/lustre/llite/llite_nfs.c +++ b/drivers/staging/lustre/lustre/llite/llite_nfs.c @@ -245,8 +245,6 @@ static int ll_get_name(struct dentry *dentry, char *name, mutex_unlock(&dir->i_mutex); if (!rc && !lgd.lgd_found) rc = -ENOENT; - EXIT; - out: return rc; } diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c index cc0d0a70bd1f7..494561af27c70 100644 --- a/drivers/staging/lustre/lustre/llite/namei.c +++ b/drivers/staging/lustre/lustre/llite/namei.c @@ -714,7 +714,6 @@ static struct inode *ll_create_node(struct inode *dir, const char *name, CDEBUG(D_DLMTRACE, "setting l_ast_data to inode %p (%lu/%u)\n", inode, inode->i_ino, inode->i_generation); ll_set_lock_data(sbi->ll_md_exp, inode, it, NULL); - EXIT; out: ptlrpc_req_finished(request); return inode; @@ -814,7 +813,6 @@ static int ll_new_node(struct inode *dir, struct qstr *name, d_instantiate(dchild, inode); } - EXIT; err_exit: ptlrpc_req_finished(request); @@ -923,7 +921,6 @@ static int ll_link_generic(struct inode *src, struct inode *dir, ll_update_times(request, dir); ll_stats_ops_tally(sbi, LPROC_LL_LINK, 1); - EXIT; out: ptlrpc_req_finished(request); RETURN(err); diff --git a/drivers/staging/lustre/lustre/llite/rw.c b/drivers/staging/lustre/lustre/llite/rw.c index 41430004e270e..b20f8b4635ced 100644 --- a/drivers/staging/lustre/lustre/llite/rw.c +++ b/drivers/staging/lustre/lustre/llite/rw.c @@ -1123,7 +1123,6 @@ void ras_update(struct ll_sb_info *sbi, struct inode *inode, if ((ras->ras_consecutive_requests > 1 || stride_detect) && !ras->ras_request_index) ras_increase_window(inode, ras, ra); - EXIT; out_unlock: RAS_CDEBUG(ras); ras->ras_request_index++; diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c index 772e4ce31e6b4..2fa29b3d94faa 100644 --- a/drivers/staging/lustre/lustre/llite/statahead.c +++ b/drivers/staging/lustre/lustre/llite/statahead.c @@ -547,8 +547,6 @@ static void ll_sai_put(struct ll_statahead_info *sai) iput(inode); OBD_FREE_PTR(sai); } - - EXIT; } /* Do NOT forget to drop inode refcount when into sai_entries_agl. */ @@ -609,8 +607,6 @@ static void ll_agl_trigger(struct inode *inode, struct ll_statahead_info *sai) PFID(&lli->lli_fid), index, rc); iput(inode); - - EXIT; } static void ll_post_statahead(struct ll_statahead_info *sai) @@ -685,8 +681,6 @@ static void ll_post_statahead(struct ll_statahead_info *sai) if (agl_should_run(sai, child)) ll_agl_add(sai, child, entry->se_index); - EXIT; - out: /* The "ll_sa_entry_to_stated()" will drop related ldlm ibits lock * reference count by calling "ll_intent_drop_lock()" in spite of the @@ -757,8 +751,6 @@ static int ll_statahead_interpret(struct ptlrpc_request *req, wake_up(&sai->sai_thread.t_ctl_waitq); } - EXIT; - out: if (rc != 0) { ll_intent_release(it); @@ -956,8 +948,6 @@ static void ll_statahead_one(struct dentry *parent, const char* entry_name, sai->sai_index++; /* drop one refcount on entry by ll_sa_entry_alloc */ ll_sa_entry_put(sai, entry); - - EXIT; } static int ll_agl_thread(void *arg) @@ -1044,7 +1034,6 @@ static void ll_start_agl(struct dentry *parent, struct ll_statahead_info *sai) l_wait_event(thread->t_ctl_waitq, thread_is_running(thread) || thread_is_stopped(thread), &lwi); - EXIT; } static int ll_statahead_thread(void *arg) @@ -1245,7 +1234,6 @@ static int ll_statahead_thread(void *arg) */ } } - EXIT; out: if (sai->sai_agl_valid) { @@ -1455,7 +1443,6 @@ static int is_first_dirent(struct inode *dir, struct dentry *dentry) ll_release_page(page, 1); } } - EXIT; out: ll_dir_chain_fini(&chain); @@ -1502,8 +1489,6 @@ ll_sai_unplug(struct ll_statahead_info *sai, struct ll_sa_entry *entry) if (!thread_is_stopped(thread)) wake_up(&thread->t_ctl_waitq); - - EXIT; } /** diff --git a/drivers/staging/lustre/lustre/llite/vvp_io.c b/drivers/staging/lustre/lustre/llite/vvp_io.c index 27ddadf7cca6b..c5827b4e16652 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_io.c +++ b/drivers/staging/lustre/lustre/llite/vvp_io.c @@ -764,7 +764,6 @@ static int vvp_io_fault_start(const struct lu_env *env, lu_ref_add(&page->cp_reference, "fault", io); fio->ft_page = page; - EXIT; out: /* return unlocked vmpage to avoid deadlocking */ diff --git a/drivers/staging/lustre/lustre/llite/vvp_page.c b/drivers/staging/lustre/lustre/llite/vvp_page.c index 522632b525fbe..78729190e74be 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_page.c +++ b/drivers/staging/lustre/lustre/llite/vvp_page.c @@ -288,8 +288,6 @@ static void vvp_page_completion_read(const struct lu_env *env, if (page->cp_sync_io == NULL) unlock_page(vmpage); - - EXIT; } static void vvp_page_completion_write(const struct lu_env *env, @@ -326,7 +324,6 @@ static void vvp_page_completion_write(const struct lu_env *env, vvp_vmpage_error(ccc_object_inode(pg->cp_obj), vmpage, ioret); end_page_writeback(vmpage); - EXIT; } /** diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c index c501ac9344995..cf1bb4fc36e65 100644 --- a/drivers/staging/lustre/lustre/llite/xattr.c +++ b/drivers/staging/lustre/lustre/llite/xattr.c @@ -413,7 +413,6 @@ int ll_getxattr_common(struct inode *inode, const char *name, memcpy(buffer, xdata, body->eadatasize); rc = body->eadatasize; } - EXIT; out: ptlrpc_req_finished(req); return rc; diff --git a/drivers/staging/lustre/lustre/lmv/lmv_intent.c b/drivers/staging/lustre/lustre/lmv/lmv_intent.c index 3d0d1acddb13c..9d97b5b8a35ba 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_intent.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_intent.c @@ -140,7 +140,6 @@ static int lmv_intent_remote(struct obd_export *exp, void *lmm, it->d.lustre.it_lock_handle = plock.cookie; it->d.lustre.it_lock_mode = pmode; - EXIT; out_free_op_data: OBD_FREE_PTR(op_data); out: diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index 2970f584539d9..48d80331f031e 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -118,7 +118,6 @@ static int lmv_set_mdc_active(struct lmv_obd *lmv, struct obd_uuid *uuid, CDEBUG(D_INFO, "Marking OBD %p %sactive\n", obd, activate ? "" : "in"); lmv_activate_target(lmv, tgt, activate); - EXIT; out_lmv_lock: spin_unlock(&lmv->lmv_lock); @@ -1267,7 +1266,6 @@ int __lmv_fid_alloc(struct lmv_obd *lmv, struct lu_fid *fid, rc = 0; } - EXIT; out: mutex_unlock(&tgt->ltd_fid_mutex); return rc; @@ -1457,7 +1455,6 @@ static int lmv_statfs(const struct lu_env *env, struct obd_export *exp, } } - EXIT; out_free_temp: OBD_FREE(temp, sizeof(*temp)); return rc; @@ -1764,7 +1761,6 @@ lmv_enqueue_remote(struct obd_export *exp, struct ldlm_enqueue_info *einfo, rc = md_enqueue(tgt->ltd_exp, einfo, it, rdata, lockh, lmm, lmmsize, NULL, extra_lock_flags); OBD_FREE_PTR(rdata); - EXIT; out: ldlm_lock_decref(&plock, pmode); return rc; diff --git a/drivers/staging/lustre/lustre/lov/lov_dev.c b/drivers/staging/lustre/lustre/lov/lov_dev.c index 5d1b52284526f..285164116c8a4 100644 --- a/drivers/staging/lustre/lustre/lov/lov_dev.c +++ b/drivers/staging/lustre/lustre/lov/lov_dev.c @@ -124,7 +124,6 @@ static void lov_req_completion(const struct lu_env *env, lr = cl2lov_req(slice); OBD_SLAB_FREE_PTR(lr, lov_req_kmem); - EXIT; } static const struct cl_req_operations lov_req_ops = { @@ -314,7 +313,6 @@ static void lov_cl_del_target(const struct lu_env *env, struct lu_device *dev, cl_stack_fini(env, lovsub2cl_dev(ld->ld_target[index])); ld->ld_target[index] = NULL; } - EXIT; } static struct lov_device_emerg **lov_emerg_alloc(int nr) diff --git a/drivers/staging/lustre/lustre/lov/lov_io.c b/drivers/staging/lustre/lustre/lov/lov_io.c index 10e36c908443e..8b978c36ab4c7 100644 --- a/drivers/staging/lustre/lustre/lov/lov_io.c +++ b/drivers/staging/lustre/lustre/lov/lov_io.c @@ -78,7 +78,6 @@ static void lov_io_sub_fini(const struct lu_env *env, struct lov_io *lio, cl_env_put(sub->sub_env, &sub->sub_refcheck); sub->sub_env = NULL; } - EXIT; } static void lov_io_sub_inherit(struct cl_io *io, struct lov_io *lio, @@ -345,8 +344,6 @@ static void lov_io_slice_init(struct lov_io *lio, default: LBUG(); } - - EXIT; } static void lov_io_fini(const struct lu_env *env, const struct cl_io_slice *ios) @@ -366,7 +363,6 @@ static void lov_io_fini(const struct lu_env *env, const struct cl_io_slice *ios) LASSERT(atomic_read(&lov->lo_active_ios) > 0); if (atomic_dec_and_test(&lov->lo_active_ios)) wake_up_all(&lov->lo_waitq); - EXIT; } static obd_off lov_offset_mod(obd_off val, int delta) @@ -524,7 +520,6 @@ static void lov_io_iter_fini(const struct lu_env *env, LASSERT(rc == 0); while (!list_empty(&lio->lis_active)) list_del_init(lio->lis_active.next); - EXIT; } static void lov_io_unlock(const struct lu_env *env, @@ -534,7 +529,6 @@ static void lov_io_unlock(const struct lu_env *env, rc = lov_io_call(env, cl2lov_io(env, ios), lov_io_unlock_wrapper); LASSERT(rc == 0); - EXIT; } @@ -820,7 +814,6 @@ static void lov_empty_io_fini(const struct lu_env *env, if (atomic_dec_and_test(&lov->lo_active_ios)) wake_up_all(&lov->lo_waitq); - EXIT; } static void lov_empty_impossible(const struct lu_env *env, diff --git a/drivers/staging/lustre/lustre/lov/lov_lock.c b/drivers/staging/lustre/lustre/lov/lov_lock.c index 7cda7b6efc1e5..757d6dec5245f 100644 --- a/drivers/staging/lustre/lustre/lov/lov_lock.c +++ b/drivers/staging/lustre/lustre/lov/lov_lock.c @@ -131,7 +131,6 @@ static void lov_sublock_adopt(const struct lu_env *env, struct lov_lock *lck, rc = lov_sublock_modify(env, lck, lsl, &sublock->cll_descr, idx); LASSERT(rc == 0); /* there is no way this can fail, currently */ - EXIT; } static struct cl_lock *lov_sublock_alloc(const struct lu_env *env, @@ -188,7 +187,6 @@ static void lov_sublock_unlock(const struct lu_env *env, lov_sublock_env_put(subenv); lsl->lss_active = NULL; cl_lock_disclosure(env, closure); - EXIT; } static int lov_sublock_lock(const struct lu_env *env, @@ -458,7 +456,6 @@ static void lov_sublock_hold(const struct lu_env *env, struct lov_lock *lck, cl_lock_user_add(env, sublock); cl_lock_put(env, sublock); } - EXIT; } static void lov_lock_fini(const struct lu_env *env, @@ -480,7 +477,6 @@ static void lov_lock_fini(const struct lu_env *env, lck->lls_nr * sizeof lck->lls_sub[0]); } OBD_SLAB_FREE_PTR(lck, lov_lock_kmem); - EXIT; } static int lov_lock_enqueue_wait(const struct lu_env *env, @@ -1052,7 +1048,6 @@ void lov_lock_unlink(const struct lu_env *env, lu_ref_del(&parent->cll_reference, "lov-child", sub->lss_cl.cls_lock); cl_lock_put(env, parent); OBD_SLAB_FREE_PTR(link, lov_lock_link_kmem); - EXIT; } struct lov_lock_link *lov_lock_link_find(const struct lu_env *env, @@ -1123,7 +1118,6 @@ static void lov_lock_delete(const struct lu_env *env, } cl_lock_closure_fini(closure); - EXIT; } static int lov_lock_print(const struct lu_env *env, void *cookie, diff --git a/drivers/staging/lustre/lustre/lov/lov_object.c b/drivers/staging/lustre/lustre/lov/lov_object.c index 3bf8c0c08b6b1..f869849135cfa 100644 --- a/drivers/staging/lustre/lustre/lov/lov_object.c +++ b/drivers/staging/lustre/lustre/lov/lov_object.c @@ -374,8 +374,6 @@ static void lov_fini_raid0(const struct lu_env *env, struct lov_object *lov, dump_lsm(D_INODE, lov->lo_lsm); lov_free_memmd(&lov->lo_lsm); - - EXIT; } static void lov_fini_released(const struct lu_env *env, struct lov_object *lov, @@ -383,7 +381,6 @@ static void lov_fini_released(const struct lu_env *env, struct lov_object *lov, { dump_lsm(D_INODE, lov->lo_lsm); lov_free_memmd(&lov->lo_lsm); - EXIT; } static int lov_print_empty(const struct lu_env *env, void *cookie, @@ -767,7 +764,6 @@ static int lov_conf_set(const struct lu_env *env, struct cl_object *obj, } lov->lo_layout_invalid = lov_layout_change(env, lov, conf); - EXIT; out: lov_conf_unlock(lov); @@ -779,7 +775,6 @@ static void lov_object_delete(const struct lu_env *env, struct lu_object *obj) struct lov_object *lov = lu2lov(obj); LOV_2DISPATCH_VOID(lov, llo_delete, env, lov, &lov->u); - EXIT; } static void lov_object_free(const struct lu_env *env, struct lu_object *obj) @@ -789,7 +784,6 @@ static void lov_object_free(const struct lu_env *env, struct lu_object *obj) LOV_2DISPATCH_VOID(lov, llo_fini, env, lov, &lov->u); lu_object_fini(obj); OBD_SLAB_FREE_PTR(lov, lov_object_kmem); - EXIT; } static int lov_object_print(const struct lu_env *env, void *cookie, diff --git a/drivers/staging/lustre/lustre/lov/lov_page.c b/drivers/staging/lustre/lustre/lov/lov_page.c index f8b364f1e632e..220e78f19ea7f 100644 --- a/drivers/staging/lustre/lustre/lov/lov_page.c +++ b/drivers/staging/lustre/lustre/lov/lov_page.c @@ -77,7 +77,6 @@ static void lov_page_fini(const struct lu_env *env, slice->cpl_page->cp_child = NULL; cl_page_put(env, sub); } - EXIT; } static int lov_page_own(const struct lu_env *env, @@ -201,7 +200,6 @@ int lov_page_init_raid0(const struct lu_env *env, struct cl_object *obj, LASSERT(0); } - EXIT; out: return rc; } diff --git a/drivers/staging/lustre/lustre/lov/lov_pool.c b/drivers/staging/lustre/lustre/lov/lov_pool.c index 63b94661702e7..e52f14c88f908 100644 --- a/drivers/staging/lustre/lustre/lov/lov_pool.c +++ b/drivers/staging/lustre/lustre/lov/lov_pool.c @@ -68,7 +68,6 @@ void lov_pool_putref(struct pool_desc *pool) lov_ost_pool_free(&(pool->pool_rr.lqr_pool)); lov_ost_pool_free(&(pool->pool_obds)); OBD_FREE_PTR(pool); - EXIT; } } @@ -333,7 +332,6 @@ int lov_ost_pool_init(struct ost_pool *op, unsigned int count) op->op_size = 0; RETURN(-ENOMEM); } - EXIT; return 0; } @@ -379,7 +377,6 @@ int lov_ost_pool_add(struct ost_pool *op, __u32 idx, unsigned int min_count) /* ost not found we add it */ op->op_array[op->op_count] = idx; op->op_count++; - EXIT; out: up_write(&op->op_rw_sem); return rc; @@ -397,7 +394,6 @@ int lov_ost_pool_remove(struct ost_pool *op, __u32 idx) (op->op_count - i - 1) * sizeof(op->op_array[0])); op->op_count--; up_write(&op->op_rw_sem); - EXIT; return 0; } } @@ -571,7 +567,6 @@ int lov_pool_add(struct obd_device *obd, char *poolname, char *ostname) CDEBUG(D_CONFIG, "Added %s to "LOV_POOLNAMEF" as member %d\n", ostname, poolname, pool_tgt_count(pool)); - EXIT; out: obd_putref(obd); lov_pool_putref(pool); @@ -616,7 +611,6 @@ int lov_pool_remove(struct obd_device *obd, char *poolname, char *ostname) CDEBUG(D_CONFIG, "%s removed from "LOV_POOLNAMEF"\n", ostname, poolname); - EXIT; out: obd_putref(obd); lov_pool_putref(pool); @@ -640,7 +634,6 @@ int lov_check_index_in_pool(__u32 idx, struct pool_desc *pool) GOTO(out, rc = 0); } rc = -ENOENT; - EXIT; out: up_read(&pool_tgt_rw_sem(pool)); diff --git a/drivers/staging/lustre/lustre/lov/lov_request.c b/drivers/staging/lustre/lustre/lov/lov_request.c index fc1cd898f5c95..d975fc550d853 100644 --- a/drivers/staging/lustre/lustre/lov/lov_request.c +++ b/drivers/staging/lustre/lustre/lov/lov_request.c @@ -86,7 +86,6 @@ void lov_finish_set(struct lov_request_set *set) lov_llh_put(set->set_lockh); OBD_FREE(set, sizeof(*set)); - EXIT; } int lov_set_finished(struct lov_request_set *set, int idempotent) diff --git a/drivers/staging/lustre/lustre/lov/lovsub_dev.c b/drivers/staging/lustre/lustre/lov/lovsub_dev.c index 05ad75e210d52..67cb287031fce 100644 --- a/drivers/staging/lustre/lustre/lov/lovsub_dev.c +++ b/drivers/staging/lustre/lustre/lov/lovsub_dev.c @@ -57,7 +57,6 @@ static void lovsub_req_completion(const struct lu_env *env, lsr = cl2lovsub_req(slice); OBD_SLAB_FREE_PTR(lsr, lovsub_req_kmem); - EXIT; } /** @@ -78,7 +77,6 @@ static void lovsub_req_attr_set(const struct lu_env *env, * unconditionally. It never changes anyway. */ attr->cra_oa->o_stripe_idx = subobj->lso_index; - EXIT; } static const struct cl_req_operations lovsub_req_ops = { diff --git a/drivers/staging/lustre/lustre/lov/lovsub_lock.c b/drivers/staging/lustre/lustre/lov/lovsub_lock.c index b73ad7a96669b..9a6b8c851a083 100644 --- a/drivers/staging/lustre/lustre/lov/lovsub_lock.c +++ b/drivers/staging/lustre/lustre/lov/lovsub_lock.c @@ -60,7 +60,6 @@ static void lovsub_lock_fini(const struct lu_env *env, lsl = cl2lovsub_lock(slice); LASSERT(list_empty(&lsl->lss_parents)); OBD_SLAB_FREE_PTR(lsl, lovsub_lock_kmem); - EXIT; } static void lovsub_parent_lock(const struct lu_env *env, struct lov_lock *lov) @@ -71,7 +70,6 @@ static void lovsub_parent_lock(const struct lu_env *env, struct lov_lock *lov) cl_lock_get(parent); lu_ref_add(&parent->cll_reference, "lovsub-parent", current); cl_lock_mutex_get(env, parent); - EXIT; } static void lovsub_parent_unlock(const struct lu_env *env, struct lov_lock *lov) @@ -82,7 +80,6 @@ static void lovsub_parent_unlock(const struct lu_env *env, struct lov_lock *lov) cl_lock_mutex_put(env, lov->lls_cl.cls_lock); lu_ref_del(&parent->cll_reference, "lovsub-parent", current); cl_lock_put(env, parent); - EXIT; } /** @@ -109,7 +106,6 @@ static void lovsub_lock_state(const struct lu_env *env, lovsub_parent_unlock(env, lov); } } - EXIT; } /** @@ -177,7 +173,6 @@ static void lovsub_lock_descr_map(const struct cl_lock_descr *in, } out->cld_start = start; out->cld_end = end; - EXIT; } /** @@ -422,7 +417,6 @@ static void lovsub_lock_delete(const struct lu_env *env, } } } while (restart); - EXIT; } static int lovsub_lock_print(const struct lu_env *env, void *cookie, diff --git a/drivers/staging/lustre/lustre/lov/lovsub_object.c b/drivers/staging/lustre/lustre/lov/lovsub_object.c index 7264ba31b9e61..13938c41a7288 100644 --- a/drivers/staging/lustre/lustre/lov/lovsub_object.c +++ b/drivers/staging/lustre/lustre/lov/lovsub_object.c @@ -92,7 +92,6 @@ static void lovsub_object_free(const struct lu_env *env, struct lu_object *obj) lu_object_fini(obj); lu_object_header_fini(&los->lso_header.coh_lu); OBD_SLAB_FREE_PTR(los, lovsub_object_kmem); - EXIT; } static int lovsub_object_print(const struct lu_env *env, void *cookie, diff --git a/drivers/staging/lustre/lustre/mdc/mdc_locks.c b/drivers/staging/lustre/lustre/mdc/mdc_locks.c index 9025075d105b4..b818cd987fa92 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_locks.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_locks.c @@ -1167,7 +1167,6 @@ static int mdc_intent_getattr_async_interpret(const struct lu_env *env, GOTO(out, rc); rc = mdc_finish_intent_lock(exp, req, &minfo->mi_data, it, lockh); - EXIT; out: OBD_FREE_PTR(einfo); diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index f9e9184908ea3..7da6eb8e8da5c 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -139,7 +139,6 @@ static int send_getstatus(struct obd_import *imp, struct lu_fid *rootfid, "root fid="DFID", last_committed="LPU64"\n", PFID(rootfid), lustre_msg_get_last_committed(req->rq_repmsg)); - EXIT; out: ptlrpc_req_finished(req); return rc; @@ -597,7 +596,6 @@ int mdc_get_lustre_md(struct obd_export *exp, struct ptlrpc_request *req, md->oss_capa = oc; } - EXIT; out: if (rc) { if (md->oss_capa) { @@ -637,7 +635,6 @@ void mdc_replay_open(struct ptlrpc_request *req) if (mod == NULL) { DEBUG_REQ(D_ERROR, req, "Can't properly replay without open data."); - EXIT; return; } @@ -671,7 +668,6 @@ void mdc_replay_open(struct ptlrpc_request *req) DEBUG_REQ(D_HA, close_req, "updating close body with new fh"); epoch->handle = body->handle; } - EXIT; } void mdc_commit_open(struct ptlrpc_request *req) @@ -1096,7 +1092,6 @@ static int mdc_statfs(const struct lu_env *env, GOTO(out, rc = -EPROTO); *osfs = *msfs; - EXIT; out: ptlrpc_req_finished(req); output: @@ -1249,7 +1244,6 @@ static int mdc_ioc_hsm_current_action(struct obd_export *exp, *hca = *req_hca; - EXIT; out: ptlrpc_req_finished(req); return rc; @@ -1313,7 +1307,6 @@ static int mdc_ioc_hsm_state_get(struct obd_export *exp, *hus = *req_hus; - EXIT; out: ptlrpc_req_finished(req); return rc; @@ -1354,7 +1347,6 @@ static int mdc_ioc_hsm_state_set(struct obd_export *exp, rc = mdc_queue_wait(req); GOTO(out, rc); - EXIT; out: ptlrpc_req_finished(req); return rc; @@ -1702,7 +1694,6 @@ static int mdc_ioc_swap_layouts(struct obd_export *exp, rc = ptlrpc_queue_wait(req); if (rc) GOTO(out, rc); - EXIT; out: ptlrpc_req_finished(req); @@ -2558,7 +2549,6 @@ static int mdc_interpret_renew_capa(const struct lu_env *env, capa = req_capsule_server_get(&req->rq_pill, &RMF_CAPA2); if (!capa) GOTO(out, capa = ERR_PTR(-EFAULT)); - EXIT; out: ra->ra_cb(ra->ra_oc, capa); return 0; diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c index 6512b7f4d3dc4..99a4099e2e0f8 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c @@ -149,8 +149,6 @@ static void config_log_put(struct config_llog_data *cld) class_export_put(cld->cld_mgcexp); OBD_FREE(cld, sizeof(*cld) + strlen(cld->cld_logname) + 1); } - - EXIT; } /* Find a config log by name */ @@ -451,8 +449,6 @@ static void do_requeue(struct config_llog_data *cld) cld->cld_logname); } up_read(&cld->cld_mgcexp->exp_obd->u.cli.cl_sem); - - EXIT; } /* this timeout represents how many seconds MGC should wait before @@ -579,7 +575,6 @@ static void mgc_requeue_add(struct config_llog_data *cld) spin_unlock(&config_list_lock); wake_up(&rq_waitq); } - EXIT; } /********************** class fns **********************/ @@ -1596,7 +1591,6 @@ static int mgc_process_cfg_log(struct obd_device *mgc, be updated here. */ rc = class_config_parse_llog(NULL, ctxt, cld->cld_logname, &cld->cld_cfg); - EXIT; out_pop: llog_ctxt_put(ctxt); diff --git a/drivers/staging/lustre/lustre/obdclass/acl.c b/drivers/staging/lustre/lustre/obdclass/acl.c index 66fdd661cafce..33bdf279868a0 100644 --- a/drivers/staging/lustre/lustre/obdclass/acl.c +++ b/drivers/staging/lustre/lustre/obdclass/acl.c @@ -226,7 +226,6 @@ int lustre_posix_acl_xattr_filter(posix_acl_xattr_header *header, int size, *out = new; rc = 0; } - EXIT; _out: if (rc) { @@ -394,7 +393,6 @@ int lustre_acl_xattr_merge2posix(posix_acl_xattr_header *posix_header, int size, *out = new; rc = 0; } - EXIT; _out: if (rc) { @@ -528,7 +526,6 @@ lustre_acl_xattr_merge2ext(posix_acl_xattr_header *posix_header, int size, new->a_count = cpu_to_le32(j); /* free unused space. */ rc = lustre_ext_acl_xattr_reduce_space(&new, ext_count); - EXIT; out: if (rc) { diff --git a/drivers/staging/lustre/lustre/obdclass/capa.c b/drivers/staging/lustre/lustre/obdclass/capa.c index 60eb94d48ea8c..9c5a05b1c5071 100644 --- a/drivers/staging/lustre/lustre/obdclass/capa.c +++ b/drivers/staging/lustre/lustre/obdclass/capa.c @@ -311,8 +311,6 @@ int capa_encrypt_id(__u32 *d, __u32 *s, __u8 *key, int keylen) GOTO(out, rc); } - EXIT; - out: ll_crypto_free_blkcipher(tfm); return rc; @@ -364,8 +362,6 @@ int capa_decrypt_id(__u32 *d, __u32 *s, __u8 *key, int keylen) GOTO(out, rc); } - EXIT; - out: ll_crypto_free_blkcipher(tfm); return rc; diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c index 96a299b4fb91e..d5b0bb8bed82e 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_io.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c @@ -143,7 +143,6 @@ void cl_io_fini(const struct lu_env *env, struct cl_io *io) default: LBUG(); } - EXIT; } EXPORT_SYMBOL(cl_io_fini); @@ -321,7 +320,6 @@ static void cl_io_locks_sort(struct cl_io *io) prev = curr; } } while (!done); - EXIT; } /** @@ -411,7 +409,6 @@ static void cl_lock_link_fini(const struct lu_env *env, struct cl_io *io, } if (link->cill_fini != NULL) link->cill_fini(env, link); - EXIT; } static int cl_lockset_lock(const struct lu_env *env, struct cl_io *io, @@ -515,7 +512,6 @@ void cl_io_unlock(const struct lu_env *env, struct cl_io *io) } io->ci_state = CIS_UNLOCKED; LASSERT(!cl_env_info(env)->clt_counters[CNL_TOP].ctc_nr_locks_acquired); - EXIT; } EXPORT_SYMBOL(cl_io_unlock); @@ -568,7 +564,6 @@ void cl_io_iter_fini(const struct lu_env *env, struct cl_io *io) scan->cis_iop->op[io->ci_type].cio_iter_fini(env, scan); } io->ci_state = CIS_IT_ENDED; - EXIT; } EXPORT_SYMBOL(cl_io_iter_fini); @@ -593,7 +588,6 @@ void cl_io_rw_advance(const struct lu_env *env, struct cl_io *io, size_t nob) scan->cis_iop->op[io->ci_type].cio_advance(env, scan, nob); } - EXIT; } EXPORT_SYMBOL(cl_io_rw_advance); @@ -688,7 +682,6 @@ void cl_io_end(const struct lu_env *env, struct cl_io *io) /* TODO: error handling. */ } io->ci_state = CIS_IO_FINISHED; - EXIT; } EXPORT_SYMBOL(cl_io_end); @@ -1044,7 +1037,6 @@ void cl_io_slice_add(struct cl_io *io, struct cl_io_slice *slice, slice->cis_io = io; slice->cis_obj = obj; slice->cis_iop = ops; - EXIT; } EXPORT_SYMBOL(cl_io_slice_add); @@ -1057,7 +1049,6 @@ void cl_page_list_init(struct cl_page_list *plist) plist->pl_nr = 0; INIT_LIST_HEAD(&plist->pl_pages); plist->pl_owner = current; - EXIT; } EXPORT_SYMBOL(cl_page_list_init); @@ -1079,7 +1070,6 @@ void cl_page_list_add(struct cl_page_list *plist, struct cl_page *page) ++plist->pl_nr; lu_ref_add_at(&page->cp_reference, &page->cp_queue_ref, "queue", plist); cl_page_get(page); - EXIT; } EXPORT_SYMBOL(cl_page_list_add); @@ -1099,7 +1089,6 @@ void cl_page_list_del(const struct lu_env *env, --plist->pl_nr; lu_ref_del_at(&page->cp_reference, &page->cp_queue_ref, "queue", plist); cl_page_put(env, page); - EXIT; } EXPORT_SYMBOL(cl_page_list_del); @@ -1118,7 +1107,6 @@ void cl_page_list_move(struct cl_page_list *dst, struct cl_page_list *src, ++dst->pl_nr; lu_ref_set_at(&page->cp_reference, &page->cp_queue_ref, "queue", src, dst); - EXIT; } EXPORT_SYMBOL(cl_page_list_move); @@ -1135,7 +1123,6 @@ void cl_page_list_splice(struct cl_page_list *list, struct cl_page_list *head) cl_page_list_for_each_safe(page, tmp, list) cl_page_list_move(head, list, page); - EXIT; } EXPORT_SYMBOL(cl_page_list_splice); @@ -1174,7 +1161,6 @@ void cl_page_list_disown(const struct lu_env *env, plist); cl_page_put(env, page); } - EXIT; } EXPORT_SYMBOL(cl_page_list_disown); @@ -1191,7 +1177,6 @@ void cl_page_list_fini(const struct lu_env *env, struct cl_page_list *plist) cl_page_list_for_each_safe(page, temp, plist) cl_page_list_del(env, plist, page); LASSERT(plist->pl_nr == 0); - EXIT; } EXPORT_SYMBOL(cl_page_list_fini); @@ -1247,7 +1232,6 @@ void cl_page_list_discard(const struct lu_env *env, struct cl_io *io, LINVRNT(plist->pl_owner == current); cl_page_list_for_each(page, plist) cl_page_discard(env, io, page); - EXIT; } EXPORT_SYMBOL(cl_page_list_discard); @@ -1278,7 +1262,6 @@ void cl_2queue_init(struct cl_2queue *queue) { cl_page_list_init(&queue->c2_qin); cl_page_list_init(&queue->c2_qout); - EXIT; } EXPORT_SYMBOL(cl_2queue_init); @@ -1288,7 +1271,6 @@ EXPORT_SYMBOL(cl_2queue_init); void cl_2queue_add(struct cl_2queue *queue, struct cl_page *page) { cl_page_list_add(&queue->c2_qin, page); - EXIT; } EXPORT_SYMBOL(cl_2queue_add); @@ -1300,7 +1282,6 @@ void cl_2queue_disown(const struct lu_env *env, { cl_page_list_disown(env, io, &queue->c2_qin); cl_page_list_disown(env, io, &queue->c2_qout); - EXIT; } EXPORT_SYMBOL(cl_2queue_disown); @@ -1312,7 +1293,6 @@ void cl_2queue_discard(const struct lu_env *env, { cl_page_list_discard(env, io, &queue->c2_qin); cl_page_list_discard(env, io, &queue->c2_qout); - EXIT; } EXPORT_SYMBOL(cl_2queue_discard); @@ -1334,7 +1314,6 @@ void cl_2queue_fini(const struct lu_env *env, struct cl_2queue *queue) { cl_page_list_fini(env, &queue->c2_qout); cl_page_list_fini(env, &queue->c2_qin); - EXIT; } EXPORT_SYMBOL(cl_2queue_fini); @@ -1345,7 +1324,6 @@ void cl_2queue_init_page(struct cl_2queue *queue, struct cl_page *page) { cl_2queue_init(queue); cl_2queue_add(queue, page); - EXIT; } EXPORT_SYMBOL(cl_2queue_init_page); @@ -1387,7 +1365,6 @@ void cl_req_slice_add(struct cl_req *req, struct cl_req_slice *slice, slice->crs_dev = dev; slice->crs_ops = ops; slice->crs_req = req; - EXIT; } EXPORT_SYMBOL(cl_req_slice_add); @@ -1413,7 +1390,6 @@ static void cl_req_free(const struct lu_env *env, struct cl_req *req) OBD_FREE(req->crq_o, req->crq_nrobjs * sizeof req->crq_o[0]); } OBD_FREE_PTR(req); - EXIT; } static int cl_req_init(const struct lu_env *env, struct cl_req *req, @@ -1459,7 +1435,6 @@ void cl_req_completion(const struct lu_env *env, struct cl_req *req, int rc) slice->crs_ops->cro_completion(env, slice, rc); } cl_req_free(env, req); - EXIT; } EXPORT_SYMBOL(cl_req_completion); @@ -1528,7 +1503,6 @@ void cl_req_page_add(const struct lu_env *env, } } LASSERT(i < req->crq_nrobjs); - EXIT; } EXPORT_SYMBOL(cl_req_page_add); @@ -1547,7 +1521,6 @@ void cl_req_page_done(const struct lu_env *env, struct cl_page *page) list_del_init(&page->cp_flight); --req->crq_nrpages; page->cp_req = NULL; - EXIT; } EXPORT_SYMBOL(cl_req_page_done); @@ -1611,7 +1584,6 @@ void cl_req_attr_set(const struct lu_env *env, struct cl_req *req, attr + i, flags); } } - EXIT; } EXPORT_SYMBOL(cl_req_attr_set); @@ -1628,7 +1600,6 @@ void cl_sync_io_init(struct cl_sync_io *anchor, int nrpages) atomic_set(&anchor->csi_sync_nr, nrpages); atomic_set(&anchor->csi_barrier, nrpages > 0); anchor->csi_sync_rc = 0; - EXIT; } EXPORT_SYMBOL(cl_sync_io_init); @@ -1694,6 +1665,5 @@ void cl_sync_io_note(struct cl_sync_io *anchor, int ioret) /* it's safe to nuke or reuse anchor now */ atomic_set(&anchor->csi_barrier, 0); } - EXIT; } EXPORT_SYMBOL(cl_sync_io_note); diff --git a/drivers/staging/lustre/lustre/obdclass/cl_lock.c b/drivers/staging/lustre/lustre/obdclass/cl_lock.c index adcf789541171..581e7da07bc59 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_lock.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_lock.c @@ -195,7 +195,6 @@ void cl_lock_slice_add(struct cl_lock *lock, struct cl_lock_slice *slice, list_add_tail(&slice->cls_linkage, &lock->cll_layers); slice->cls_obj = obj; slice->cls_ops = ops; - EXIT; } EXPORT_SYMBOL(cl_lock_slice_add); @@ -271,7 +270,6 @@ static void cl_lock_free(const struct lu_env *env, struct cl_lock *lock) lu_ref_fini(&lock->cll_holders); mutex_destroy(&lock->cll_guard); OBD_SLAB_FREE_PTR(lock, cl_lock_kmem); - EXIT; } /** @@ -301,7 +299,6 @@ void cl_lock_put(const struct lu_env *env, struct cl_lock *lock) } CS_LOCK_DEC(obj, busy); } - EXIT; } EXPORT_SYMBOL(cl_lock_put); @@ -783,7 +780,6 @@ static void cl_lock_cancel0(const struct lu_env *env, struct cl_lock *lock) slice->cls_ops->clo_cancel(env, slice); } } - EXIT; } static void cl_lock_delete0(const struct lu_env *env, struct cl_lock *lock) @@ -823,7 +819,6 @@ static void cl_lock_delete0(const struct lu_env *env, struct cl_lock *lock) * existing references goes away. */ } - EXIT; } /** @@ -896,7 +891,6 @@ void cl_lock_hold_release(const struct lu_env *env, struct cl_lock *lock, cl_lock_delete0(env, lock); } } - EXIT; } EXPORT_SYMBOL(cl_lock_hold_release); @@ -977,7 +971,6 @@ static void cl_lock_state_signal(const struct lu_env *env, struct cl_lock *lock, if (slice->cls_ops->clo_state != NULL) slice->cls_ops->clo_state(env, slice, state); wake_up_all(&lock->cll_wq); - EXIT; } /** @@ -991,7 +984,6 @@ void cl_lock_signal(const struct lu_env *env, struct cl_lock *lock) { cl_lock_trace(D_DLMTRACE, env, "state signal lock", lock); cl_lock_state_signal(env, lock, lock->cll_state); - EXIT; } EXPORT_SYMBOL(cl_lock_signal); @@ -1023,7 +1015,6 @@ void cl_lock_state_set(const struct lu_env *env, struct cl_lock *lock, cl_lock_state_signal(env, lock, state); lock->cll_state = state; } - EXIT; } EXPORT_SYMBOL(cl_lock_state_set); @@ -1388,8 +1379,6 @@ static void cl_unuse_locked(const struct lu_env *env, struct cl_lock *lock) result = cl_unuse_try(env, lock); if (result) CL_LOCK_DEBUG(D_ERROR, env, lock, "unuse return %d\n", result); - - EXIT; } /** @@ -1401,7 +1390,6 @@ void cl_unuse(const struct lu_env *env, struct cl_lock *lock) cl_unuse_locked(env, lock); cl_lock_mutex_put(env, lock); cl_lock_lockdep_release(env, lock); - EXIT; } EXPORT_SYMBOL(cl_unuse); @@ -1737,7 +1725,6 @@ void cl_lock_delete(const struct lu_env *env, struct cl_lock *lock) cl_lock_delete0(env, lock); else lock->cll_flags |= CLF_DOOMED; - EXIT; } EXPORT_SYMBOL(cl_lock_delete); @@ -1763,7 +1750,6 @@ void cl_lock_error(const struct lu_env *env, struct cl_lock *lock, int error) cl_lock_cancel(env, lock); cl_lock_delete(env, lock); } - EXIT; } EXPORT_SYMBOL(cl_lock_error); @@ -1788,7 +1774,6 @@ void cl_lock_cancel(const struct lu_env *env, struct cl_lock *lock) cl_lock_cancel0(env, lock); else lock->cll_flags |= CLF_CANCELPEND; - EXIT; } EXPORT_SYMBOL(cl_lock_cancel); @@ -2018,7 +2003,6 @@ void cl_locks_prune(const struct lu_env *env, struct cl_object *obj, int cancel) spin_lock(&head->coh_lock_guard); } spin_unlock(&head->coh_lock_guard); - EXIT; } EXPORT_SYMBOL(cl_locks_prune); @@ -2128,7 +2112,6 @@ void cl_lock_hold_add(const struct lu_env *env, struct cl_lock *lock, cl_lock_get(lock); lu_ref_add(&lock->cll_holders, scope, source); lu_ref_add(&lock->cll_reference, scope, source); - EXIT; } EXPORT_SYMBOL(cl_lock_hold_add); @@ -2143,7 +2126,6 @@ void cl_lock_unhold(const struct lu_env *env, struct cl_lock *lock, cl_lock_hold_release(env, lock, scope, source); lu_ref_del(&lock->cll_reference, scope, source); cl_lock_put(env, lock); - EXIT; } EXPORT_SYMBOL(cl_lock_unhold); @@ -2160,7 +2142,6 @@ void cl_lock_release(const struct lu_env *env, struct cl_lock *lock, cl_lock_mutex_put(env, lock); lu_ref_del(&lock->cll_reference, scope, source); cl_lock_put(env, lock); - EXIT; } EXPORT_SYMBOL(cl_lock_release); @@ -2170,7 +2151,6 @@ void cl_lock_user_add(const struct lu_env *env, struct cl_lock *lock) LINVRNT(cl_lock_invariant(env, lock)); cl_lock_used_mod(env, lock, +1); - EXIT; } EXPORT_SYMBOL(cl_lock_user_add); @@ -2183,7 +2163,6 @@ void cl_lock_user_del(const struct lu_env *env, struct cl_lock *lock) cl_lock_used_mod(env, lock, -1); if (lock->cll_users == 0) wake_up_all(&lock->cll_wq); - EXIT; } EXPORT_SYMBOL(cl_lock_user_del); diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c index 2abc4b5ddb370..ea1758065c62b 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c @@ -359,7 +359,6 @@ void cl_object_prune(const struct lu_env *env, struct cl_object *obj) { cl_pages_prune(env, obj); cl_locks_prune(env, obj, 1); - EXIT; } EXPORT_SYMBOL(cl_object_prune); @@ -940,7 +939,6 @@ void cl_attr2lvb(struct ost_lvb *lvb, const struct cl_attr *attr) lvb->lvb_atime = attr->cat_atime; lvb->lvb_ctime = attr->cat_ctime; lvb->lvb_blocks = attr->cat_blocks; - EXIT; } EXPORT_SYMBOL(cl_attr2lvb); @@ -956,7 +954,6 @@ void cl_lvb2attr(struct cl_attr *attr, const struct ost_lvb *lvb) attr->cat_atime = lvb->lvb_atime; attr->cat_ctime = lvb->lvb_ctime; attr->cat_blocks = lvb->lvb_blocks; - EXIT; } EXPORT_SYMBOL(cl_lvb2attr); diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c index 3c6cf202bbd99..028c72028fd5f 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_page.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c @@ -271,7 +271,6 @@ static void cl_page_free(const struct lu_env *env, struct cl_page *page) cl_object_put(env, obj); lu_ref_fini(&page->cp_reference); OBD_FREE(page, pagesize); - EXIT; } /** @@ -560,7 +559,6 @@ static void cl_page_state_set0(const struct lu_env *env, CS_PAGESTATE_INC(page->cp_obj, state); cl_page_state_set_trust(page, state); } - EXIT; } static void cl_page_state_set(const struct lu_env *env, @@ -580,7 +578,6 @@ static void cl_page_state_set(const struct lu_env *env, void cl_page_get(struct cl_page *page) { cl_page_get_trust(page); - EXIT; } EXPORT_SYMBOL(cl_page_get); @@ -612,8 +609,6 @@ void cl_page_put(const struct lu_env *env, struct cl_page *page) */ cl_page_free(env, page); } - - EXIT; } EXPORT_SYMBOL(cl_page_put); @@ -790,7 +785,6 @@ static void cl_page_invoid(const struct lu_env *env, CL_PAGE_INVOID(env, page, op, (const struct lu_env *, const struct cl_page_slice *, struct cl_io *), io); - EXIT; } static void cl_page_owner_clear(struct cl_page *page) @@ -803,7 +797,6 @@ static void cl_page_owner_clear(struct cl_page *page) page->cp_task = NULL; } } - EXIT; } static void cl_page_owner_set(struct cl_page *page) @@ -812,7 +805,6 @@ static void cl_page_owner_set(struct cl_page *page) LASSERT(page->cp_owner != NULL); page->cp_owner->ci_owned_nr++; } - EXIT; } void cl_page_disown0(const struct lu_env *env, @@ -836,7 +828,6 @@ void cl_page_disown0(const struct lu_env *env, (const struct lu_env *, const struct cl_page_slice *, struct cl_io *), io); - EXIT; } /** @@ -953,7 +944,6 @@ void cl_page_assume(const struct lu_env *env, pg->cp_task = current; cl_page_owner_set(pg); cl_page_state_set(env, pg, CPS_OWNED); - EXIT; } EXPORT_SYMBOL(cl_page_assume); @@ -982,7 +972,6 @@ void cl_page_unassume(const struct lu_env *env, (const struct lu_env *, const struct cl_page_slice *, struct cl_io *), io); - EXIT; } EXPORT_SYMBOL(cl_page_unassume); @@ -1005,7 +994,6 @@ void cl_page_disown(const struct lu_env *env, pg = cl_page_top(pg); io = cl_io_top(io); cl_page_disown0(env, io, pg); - EXIT; } EXPORT_SYMBOL(cl_page_disown); @@ -1082,8 +1070,6 @@ static void cl_page_delete0(const struct lu_env *env, struct cl_page *pg, cl_page_put(env, tmp); } } - - EXIT; } /** @@ -1115,7 +1101,6 @@ void cl_page_delete(const struct lu_env *env, struct cl_page *pg) { PINVRNT(env, pg, cl_page_invariant(pg)); cl_page_delete0(env, pg, 1); - EXIT; } EXPORT_SYMBOL(cl_page_delete); @@ -1193,7 +1178,6 @@ static void cl_page_io_start(const struct lu_env *env, */ cl_page_owner_clear(pg); cl_page_state_set(env, pg, cl_req_type_state(crt)); - EXIT; } /** @@ -1282,8 +1266,6 @@ void cl_page_completion(const struct lu_env *env, if (anchor) cl_sync_io_note(anchor, ioret); - - EXIT; } EXPORT_SYMBOL(cl_page_completion); @@ -1558,7 +1540,6 @@ void cl_page_slice_add(struct cl_page *page, struct cl_page_slice *slice, slice->cpl_obj = obj; slice->cpl_ops = ops; slice->cpl_page = page; - EXIT; } EXPORT_SYMBOL(cl_page_slice_add); diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c index 07d7d2e7c5436..09933b2f2aff9 100644 --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c @@ -675,8 +675,6 @@ static void cleanup_obdclass(void) CDEBUG((pages_leaked) ? D_ERROR : D_INFO, "obd_memory_pages max: "LPU64", leaked: "LPU64"\n", pages_max, pages_leaked); - - EXIT; } MODULE_AUTHOR("Sun Microsystems, Inc. "); diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index b2ec1067a29d8..c9180656dfd41 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -648,7 +648,6 @@ void obd_cleanup_caches(void) kmem_cache_destroy(capa_cachep); capa_cachep = NULL; } - EXIT; } int obd_init_caches(void) @@ -769,7 +768,6 @@ static void class_export_destroy(struct obd_export *exp) class_decref(obd, "export", exp); OBD_FREE_RCU(exp, sizeof(*exp), &exp->exp_handle); - EXIT; } static void export_handle_addref(void *export) @@ -947,7 +945,6 @@ void class_import_destroy(struct obd_import *imp) LASSERT(imp->imp_sec == NULL); class_decref(imp->imp_obd, "import", imp); OBD_FREE_RCU(imp, sizeof(*imp), &imp->imp_handle); - EXIT; } static void import_handle_addref(void *import) @@ -986,7 +983,6 @@ void class_import_put(struct obd_import *imp) /* catch possible import put race */ LASSERT_ATOMIC_GE_LT(&imp->imp_refcount, 0, LI_POISON); - EXIT; } EXPORT_SYMBOL(class_import_put); @@ -1265,7 +1261,6 @@ static void class_disconnect_export_list(struct list_head *list, obd_export_nid2str(exp), exp, rc); class_export_put(exp); } - EXIT; } void class_disconnect_exports(struct obd_device *obd) @@ -1287,7 +1282,6 @@ void class_disconnect_exports(struct obd_device *obd) } else CDEBUG(D_HA, "OBD device %d (%p) has no exports\n", obd->obd_minor, obd); - EXIT; } EXPORT_SYMBOL(class_disconnect_exports); @@ -1338,7 +1332,6 @@ void class_disconnect_stale_exports(struct obd_device *obd, class_disconnect_export_list(&work_list, exp_flags_from_obd(obd) | OBD_OPT_ABORT_RECOV); - EXIT; } EXPORT_SYMBOL(class_disconnect_stale_exports); @@ -1605,7 +1598,6 @@ void obd_zombie_impexp_cull(void) cond_resched(); } while (import != NULL || export != NULL); - EXIT; } static struct completion obd_zombie_start; diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c index a3cb92f6ae9ce..95de95e628be1 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c @@ -149,7 +149,6 @@ int obd_ioctl_getdata(char **buf, int *len, void *arg) data->ioc_inlbuf4 = &data->ioc_bulk[0] + offset; } - EXIT; return 0; } EXPORT_SYMBOL(obd_ioctl_getdata); diff --git a/drivers/staging/lustre/lustre/obdclass/llog_cat.c b/drivers/staging/lustre/lustre/obdclass/llog_cat.c index 08b950802ae7f..020af54e68af1 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_cat.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_cat.c @@ -202,7 +202,6 @@ int llog_cat_id2handle(const struct lu_env *env, struct llog_handle *cathandle, loghandle->u.phd.phd_cookie.lgc_lgl = cathandle->lgh_id; loghandle->u.phd.phd_cookie.lgc_index = loghandle->lgh_hdr->llh_cat_idx; - EXIT; out: llog_handle_get(loghandle); *res = loghandle; diff --git a/drivers/staging/lustre/lustre/obdclass/llog_osd.c b/drivers/staging/lustre/lustre/obdclass/llog_osd.c index 5569d8d55e00a..7ab6f59c0dc54 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_osd.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_osd.c @@ -1221,7 +1221,6 @@ int llog_osd_get_cat_list(const struct lu_env *env, struct dt_device *d, GOTO(out, rc); } - EXIT; out: lu_object_put(env, &o->do_lu); RETURN(rc); diff --git a/drivers/staging/lustre/lustre/obdclass/llog_swab.c b/drivers/staging/lustre/lustre/obdclass/llog_swab.c index 5cf15d20bb1f2..24ca099b01da5 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_swab.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_swab.c @@ -97,7 +97,6 @@ void lustre_swab_llogd_body (struct llogd_body *d) __swab32s (&d->lgd_len); __swab64s (&d->lgd_cur_offset); print_llogd_body(d); - EXIT; } EXPORT_SYMBOL(lustre_swab_llogd_body); @@ -302,7 +301,6 @@ void lustre_swab_llog_hdr (struct llog_log_hdr *h) lustre_swab_llog_rec(&h->llh_hdr); print_llog_hdr(h); - EXIT; } EXPORT_SYMBOL(lustre_swab_llog_hdr); @@ -325,7 +323,6 @@ static void print_lustre_cfg(struct lustre_cfg *lcfg) for (i = 0; i < lcfg->lcfg_bufcount; i++) CDEBUG(D_OTHER, "\tlcfg->lcfg_buflens[%d]: %d\n", i, lcfg->lcfg_buflens[i]); - EXIT; } void lustre_swab_lustre_cfg(struct lustre_cfg *lcfg) @@ -337,7 +334,6 @@ void lustre_swab_lustre_cfg(struct lustre_cfg *lcfg) if (lcfg->lcfg_version != LUSTRE_CFG_VERSION) { CERROR("not swabbing lustre_cfg version %#x (expecting %#x)\n", lcfg->lcfg_version, LUSTRE_CFG_VERSION); - EXIT; return; } @@ -350,7 +346,6 @@ void lustre_swab_lustre_cfg(struct lustre_cfg *lcfg) __swab32s(&lcfg->lcfg_buflens[i]); print_lustre_cfg(lcfg); - EXIT; return; } EXPORT_SYMBOL(lustre_swab_lustre_cfg); @@ -413,7 +408,6 @@ void lustre_swab_cfg_marker(struct cfg_marker *marker, int swab, int size) __swab64s(&marker->cm_canceltime); } - EXIT; return; } EXPORT_SYMBOL(lustre_swab_cfg_marker); diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index 090b669c35d1b..eaf45cb07b32a 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -910,7 +910,6 @@ void lprocfs_free_per_client_stats(struct obd_device *obd) cfs_hash_del(hash, &stat->nid, &stat->nid_hash); lprocfs_free_client_stats(stat); } - EXIT; } EXPORT_SYMBOL(lprocfs_free_per_client_stats); diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c index de80aea70721c..a748d8e70ec95 100644 --- a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c +++ b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c @@ -99,7 +99,6 @@ void class_handle_hash(struct portals_handle *h, CDEBUG(D_INFO, "added object %p with handle "LPX64" to hash\n", h, h->h_cookie); - EXIT; } EXPORT_SYMBOL(class_handle_hash); @@ -145,8 +144,6 @@ void class_handle_hash_back(struct portals_handle *h) list_add_rcu(&h->h_link, &bucket->head); h->h_in = 1; spin_unlock(&bucket->lock); - - EXIT; } EXPORT_SYMBOL(class_handle_hash_back); diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c index 278e7d2e103fa..6981f3ce63f3d 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_config.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c @@ -902,7 +902,6 @@ void class_del_profile(const char *prof) OBD_FREE(lprof->lp_md, strlen(lprof->lp_md) + 1); OBD_FREE(lprof, sizeof *lprof); } - EXIT; } EXPORT_SYMBOL(class_del_profile); @@ -919,7 +918,6 @@ void class_del_profiles(void) OBD_FREE(lprof->lp_md, strlen(lprof->lp_md) + 1); OBD_FREE(lprof, sizeof *lprof); } - EXIT; } EXPORT_SYMBOL(class_del_profiles); diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c index 6fc0396f6cbb0..80e3a951b95ad 100644 --- a/drivers/staging/lustre/lustre/obdecho/echo_client.c +++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c @@ -316,7 +316,6 @@ static void echo_page_fini(const struct lu_env *env, atomic_dec(&eco->eo_npages); page_cache_release(vmpage); - EXIT; } static int echo_page_prep(const struct lu_env *env, @@ -565,7 +564,6 @@ static void echo_object_free(const struct lu_env *env, struct lu_object *obj) if (eco->eo_lsm) echo_free_memmd(eco->eo_dev, &eco->eo_lsm); OBD_SLAB_FREE_PTR(eco, echo_object_kmem); - EXIT; } static int echo_object_print(const struct lu_env *env, void *cookie, @@ -1214,7 +1212,6 @@ static int cl_echo_enqueue(struct echo_object *eco, obd_off start, obd_off end, result = cl_echo_enqueue0(env, eco, start, end, mode, cookie, 0); cl_io_fini(env, io); - EXIT; out: cl_env_put(env, &refcheck); return result; @@ -1366,7 +1363,6 @@ static int cl_echo_object_brw(struct echo_object *eco, int rw, obd_off offset, } cl_echo_cancel0(env, ed, lh.cookie); - EXIT; error_lock: cl_2queue_discard(env, io, queue); cl_2queue_disown(env, io, queue); @@ -1597,7 +1593,6 @@ echo_md_create_internal(const struct lu_env *env, struct echo_device *ed, } CDEBUG(D_RPCTRACE, "End creating object "DFID" %s %p rc = %d\n", PFID(lu_object_fid(&parent->mo_lu)), lname->ln_name, parent, rc); - EXIT; out_put: lu_object_put(env, ec_child); return rc; @@ -2280,7 +2275,6 @@ static int echo_create_object(const struct lu_env *env, struct echo_device *ed, cl_echo_object_put(eco); CDEBUG(D_INFO, "oa oid "DOSTID"\n", POSTID(&oa->o_oi)); - EXIT; failed: if (created && rc) @@ -2938,7 +2932,6 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len, GOTO (out, rc = -ENOTTY); } - EXIT; out: lu_env_fini(env); OBD_FREE_PTR(env); diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index 3e71f41bbb5ea..daaab369c88b5 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -781,7 +781,6 @@ struct osc_extent *osc_extent_find(const struct lu_env *env, goto restart; } - EXIT; out: osc_extent_put(env, cur); @@ -1136,7 +1135,6 @@ static int osc_extent_expand(struct osc_extent *ext, pgoff_t index, int *grants) LASSERT(*grants >= 0); EASSERTF(osc_extent_is_overlapped(obj, ext) == 0, ext, "overlapped after expanding for %lu.\n", index); - EXIT; out: osc_object_unlock(obj); @@ -1330,7 +1328,6 @@ static void osc_release_write_grant(struct client_obd *cli, { LASSERT(spin_is_locked(&cli->cl_loi_list_lock.lock)); if (!(pga->flag & OBD_BRW_FROM_GRANT)) { - EXIT; return; } @@ -1342,7 +1339,6 @@ static void osc_release_write_grant(struct client_obd *cli, atomic_dec(&obd_dirty_transit_pages); cli->cl_dirty_transit -= PAGE_CACHE_SIZE; } - EXIT; } /** @@ -1544,7 +1540,6 @@ static int osc_enter_cache(const struct lu_env *env, struct client_obd *cli, if (osc_enter_cache_try(cli, oap, bytes, 0)) GOTO(out, rc = 0); } - EXIT; out: client_obd_list_unlock(&cli->cl_loi_list_lock); OSC_DUMP_GRANT(cli, "returned %d.\n", rc); @@ -1582,8 +1577,6 @@ void osc_wake_cache_waiters(struct client_obd *cli) wake_up(&ocw->ocw_waitq); } - - EXIT; } static int osc_max_rpc_in_flight(struct client_obd *cli, struct osc_object *osc) @@ -1765,8 +1758,6 @@ static void osc_ap_completion(const struct lu_env *env, struct client_obd *cli, if (rc) CERROR("completion on oap %p obj %p returns %d.\n", oap, osc, rc); - - EXIT; } /** @@ -2430,7 +2421,6 @@ int osc_flush_async_page(const struct lu_env *env, struct cl_io *io, unplug = true; } rc = 0; - EXIT; out: osc_object_unlock(obj); diff --git a/drivers/staging/lustre/lustre/osc/osc_lock.c b/drivers/staging/lustre/lustre/osc/osc_lock.c index ef6f1bb9150b0..d8fb36780070d 100644 --- a/drivers/staging/lustre/lustre/osc/osc_lock.c +++ b/drivers/staging/lustre/lustre/osc/osc_lock.c @@ -390,8 +390,6 @@ static void osc_lock_lvb_update(const struct lu_env *env, struct osc_lock *olck, cl_object_attr_set(env, obj, attr, valid); cl_object_attr_unlock(obj); - - EXIT; } /** @@ -439,7 +437,6 @@ static void osc_lock_granted(const struct lu_env *env, struct osc_lock *olck, LINVRNT(osc_lock_invariant(olck)); lock_res_and_lock(dlmlock); } - EXIT; } static void osc_lock_upcall0(const struct lu_env *env, struct osc_lock *olck) diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c index 5f51dfa3a3e02..6aa59e93a047a 100644 --- a/drivers/staging/lustre/lustre/osc/osc_page.c +++ b/drivers/staging/lustre/lustre/osc/osc_page.c @@ -437,7 +437,6 @@ static void osc_page_delete(const struct lu_env *env, spin_unlock(&obj->oo_seatbelt); osc_lru_del(osc_cli(obj), opg, true); - EXIT; } void osc_page_clip(const struct lu_env *env, const struct cl_page_slice *slice, diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index a27bbb5c1240c..1f73a698baef6 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -291,7 +291,6 @@ static int osc_getattr(const struct lu_env *env, struct obd_export *exp, oinfo->oi_oa->o_blksize = cli_brw_size(exp->exp_obd); oinfo->oi_oa->o_valid |= OBD_MD_FLBLKSZ; - EXIT; out: ptlrpc_req_finished(req); return rc; @@ -332,7 +331,6 @@ static int osc_setattr(const struct lu_env *env, struct obd_export *exp, lustre_get_wire_obdo(&req->rq_import->imp_connect_data, oinfo->oi_oa, &body->oa); - EXIT; out: ptlrpc_req_finished(req); RETURN(rc); @@ -2202,7 +2200,6 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, */ ptlrpcd_add_req(req, pol, -1); rc = 0; - EXIT; out: if (mem_tight != 0) @@ -2822,7 +2819,6 @@ static int osc_statfs(const struct lu_env *env, struct obd_export *exp, *osfs = *msfs; - EXIT; out: ptlrpc_req_finished(req); return rc; diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c index b860db61e854e..9bcfc4f65356d 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c @@ -206,7 +206,6 @@ void __ptlrpc_free_bulk(struct ptlrpc_bulk_desc *desc, int unpin) OBD_FREE(desc, offsetof(struct ptlrpc_bulk_desc, bd_iov[desc->bd_max_iov])); - EXIT; } EXPORT_SYMBOL(__ptlrpc_free_bulk); @@ -919,7 +918,6 @@ void ptlrpc_set_destroy(struct ptlrpc_request_set *set) LASSERT(atomic_read(&set->set_remaining) == 0); ptlrpc_reqset_put(set); - EXIT; } EXPORT_SYMBOL(ptlrpc_set_destroy); @@ -1156,8 +1154,6 @@ static void ptlrpc_save_versions(struct ptlrpc_request *req) lustre_msg_set_versions(reqmsg, versions); CDEBUG(D_INFO, "Client save versions ["LPX64"/"LPX64"]\n", versions[0], versions[1]); - - EXIT; } /** @@ -2169,7 +2165,6 @@ EXPORT_SYMBOL(ptlrpc_set_wait); static void __ptlrpc_free_req(struct ptlrpc_request *request, int locked) { if (request == NULL) { - EXIT; return; } @@ -2222,7 +2217,6 @@ static void __ptlrpc_free_req(struct ptlrpc_request *request, int locked) __ptlrpc_free_req_to_pool(request); else OBD_FREE(request, sizeof(*request)); - EXIT; } static int __ptlrpc_req_finished(struct ptlrpc_request *request, int locked); @@ -2388,7 +2382,6 @@ void ptlrpc_free_committed(struct obd_import *imp) imp->imp_generation == imp->imp_last_generation_checked) { CDEBUG(D_INFO, "%s: skip recheck: last_committed "LPU64"\n", imp->imp_obd->obd_name, imp->imp_peer_committed_transno); - EXIT; return; } CDEBUG(D_RPCTRACE, "%s: committing for last_committed "LPU64" gen %d\n", @@ -2436,15 +2429,10 @@ void ptlrpc_free_committed(struct obd_import *imp) list_del_init(&req->rq_replay_list); __ptlrpc_req_finished(req, 1); } - - EXIT; - return; } void ptlrpc_cleanup_client(struct obd_import *imp) { - EXIT; - return; } EXPORT_SYMBOL(ptlrpc_cleanup_client); @@ -2783,8 +2771,6 @@ void ptlrpc_abort_inflight(struct obd_import *imp) ptlrpc_free_committed(imp); spin_unlock(&imp->imp_lock); - - EXIT; } EXPORT_SYMBOL(ptlrpc_abort_inflight); diff --git a/drivers/staging/lustre/lustre/ptlrpc/connection.c b/drivers/staging/lustre/lustre/ptlrpc/connection.c index c5c1d52094c88..37a1e20ea716f 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/connection.c +++ b/drivers/staging/lustre/lustre/ptlrpc/connection.c @@ -79,7 +79,6 @@ ptlrpc_connection_get(lnet_process_id_t peer, lnet_nid_t self, OBD_FREE_PTR(conn); conn = conn2; } - EXIT; out: CDEBUG(D_INFO, "conn=%p refcount %d to %s\n", conn, atomic_read(&conn->c_refcount), @@ -152,9 +151,9 @@ int ptlrpc_connection_init(void) } EXPORT_SYMBOL(ptlrpc_connection_init); -void ptlrpc_connection_fini(void) { +void ptlrpc_connection_fini(void) +{ cfs_hash_putref(conn_hash); - EXIT; } EXPORT_SYMBOL(ptlrpc_connection_fini); diff --git a/drivers/staging/lustre/lustre/ptlrpc/events.c b/drivers/staging/lustre/lustre/ptlrpc/events.c index d736a27301068..58d089c3fef49 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/events.c +++ b/drivers/staging/lustre/lustre/ptlrpc/events.c @@ -78,8 +78,6 @@ void request_out_callback(lnet_event_t *ev) } ptlrpc_req_finished(req); - - EXIT; } /* @@ -164,7 +162,6 @@ void reply_in_callback(lnet_event_t *ev) * since we don't have our own ref */ ptlrpc_client_wake_req(req); spin_unlock(&req->rq_lock); - EXIT; } /* @@ -217,7 +214,6 @@ void client_bulk_callback (lnet_event_t *ev) ptlrpc_client_wake_req(desc->bd_req); spin_unlock(&desc->bd_lock); - EXIT; } /* @@ -374,7 +370,6 @@ void request_in_callback(lnet_event_t *ev) wake_up(&svcpt->scp_waitq); spin_unlock(&svcpt->scp_lock); - EXIT; } /* @@ -395,7 +390,6 @@ void reply_out_callback(lnet_event_t *ev) * net's ref on 'rs' */ LASSERT (ev->unlinked); ptlrpc_rs_decref(rs); - EXIT; return; } @@ -416,7 +410,6 @@ void reply_out_callback(lnet_event_t *ev) spin_unlock(&rs->rs_lock); spin_unlock(&svcpt->scp_rep_lock); } - EXIT; } diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_keyring.c b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_keyring.c index 07faa0e0516b0..5c51b82933afd 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_keyring.c +++ b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_keyring.c @@ -926,7 +926,6 @@ void flush_spec_ctx_cache_kr(struct ptlrpc_sec *sec, spin_unlock(&sec->ps_lock); dispose_ctx_list_kr(&freelist); - EXIT; } static @@ -974,8 +973,6 @@ void gss_sec_gc_ctx_kr(struct ptlrpc_sec *sec) spin_unlock(&sec->ps_lock); dispose_ctx_list_kr(&freelist); - EXIT; - return; } static @@ -1308,7 +1305,6 @@ void gss_kt_destroy(struct key *key) { LASSERT(key->payload.data == NULL); CDEBUG(D_SEC, "destroy key %p\n", key); - EXIT; } static diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_pipefs.c b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_pipefs.c index 105d0d8bca9e1..f2bd67f54f565 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_pipefs.c +++ b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_pipefs.c @@ -286,7 +286,6 @@ void gss_sec_ctx_replace_pf(struct gss_sec *gsec, spin_unlock(&gsec->gs_base.ps_lock); ctx_list_destroy_pf(&freelist); - EXIT; } static @@ -334,7 +333,6 @@ void gss_ctx_cache_gc_pf(struct gss_sec_pipefs *gsec_pf, } sec->ps_gc_next = cfs_time_current_sec() + sec->ps_gc_interval; - EXIT; } static @@ -701,7 +699,6 @@ void gss_release_msg(struct gss_upcall_msg *gmsg) LASSERT(atomic_read(&gmsg->gum_refcount) > 0); if (!atomic_dec_and_test(&gmsg->gum_refcount)) { - EXIT; return; } @@ -714,7 +711,6 @@ void gss_release_msg(struct gss_upcall_msg *gmsg) LASSERT(list_empty(&gmsg->gum_list)); LASSERT(list_empty(&gmsg->gum_base.list)); OBD_FREE_PTR(gmsg); - EXIT; } static @@ -945,7 +941,6 @@ void gss_pipe_destroy_msg(struct rpc_pipe_msg *msg) /* normally errno is >= 0 */ if (msg->errno >= 0) { - EXIT; return; } @@ -970,7 +965,6 @@ void gss_pipe_destroy_msg(struct rpc_pipe_msg *msg) } gss_msg_fail_ctx(gmsg); gss_release_msg(gmsg); - EXIT; } static @@ -1009,7 +1003,6 @@ void gss_pipe_release(struct inode *inode) upcall_list_lock(idx); } upcall_list_unlock(idx); - EXIT; } static struct rpc_pipe_ops gss_upcall_ops = { diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_svc_upcall.c b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_svc_upcall.c index 243f110cce349..245044b6d77a7 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_svc_upcall.c +++ b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_svc_upcall.c @@ -681,7 +681,6 @@ static void rsc_flush(rsc_entry_match *match, long data) } } write_unlock(&rsc_cache.hash_lock); - EXIT; } static int match_uid(struct rsc *rscp, long uid) diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/sec_gss.c b/drivers/staging/lustre/lustre/ptlrpc/gss/sec_gss.c index 0553965cc3688..95e4536f04847 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/sec_gss.c +++ b/drivers/staging/lustre/lustre/ptlrpc/gss/sec_gss.c @@ -1157,8 +1157,6 @@ void gss_sec_destroy_common(struct gss_sec *gsec) if (SPTLRPC_FLVR_BULK_SVC(sec->ps_flvr.sf_rpc) == SPTLRPC_BULK_SVC_PRIV) sptlrpc_enc_pool_del_user(); - - EXIT; } void gss_sec_kill(struct ptlrpc_sec *sec) @@ -1462,8 +1460,6 @@ void gss_free_reqbuf(struct ptlrpc_sec *sec, req->rq_reqbuf = NULL; req->rq_reqbuf_len = 0; } - - EXIT; } static int do_alloc_repbuf(struct ptlrpc_request *req, int bufsize) @@ -2418,7 +2414,6 @@ void gss_svc_invalidate_ctx(struct ptlrpc_svc_ctx *svc_ctx) struct gss_svc_reqctx *grctx; if (svc_ctx == NULL) { - EXIT; return; } @@ -2427,8 +2422,6 @@ void gss_svc_invalidate_ctx(struct ptlrpc_svc_ctx *svc_ctx) CWARN("gss svc invalidate ctx %p(%u)\n", grctx->src_ctx, grctx->src_ctx->gsc_uid); gss_svc_upcall_destroy_ctx(grctx->src_ctx); - - EXIT; } static inline diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c index 3b1137b9ac9d0..b8a00f562597c 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/import.c +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c @@ -204,8 +204,6 @@ static void ptlrpc_deactivate_and_unlock_import(struct obd_import *imp) ptlrpc_abort_inflight(imp); obd_import_event(imp->imp_obd, imp, IMP_EVENT_INACTIVE); - - EXIT; } /* @@ -414,7 +412,6 @@ void ptlrpc_fail_import(struct obd_import *imp, __u32 conn_cnt) ptlrpc_pinger_wake_up(); } - EXIT; } EXPORT_SYMBOL(ptlrpc_fail_import); @@ -1475,8 +1472,6 @@ void ptlrpc_cleanup_imp(struct obd_import *imp) imp->imp_generation++; spin_unlock(&imp->imp_lock); ptlrpc_abort_inflight(imp); - - EXIT; } EXPORT_SYMBOL(ptlrpc_cleanup_imp); diff --git a/drivers/staging/lustre/lustre/ptlrpc/llog_client.c b/drivers/staging/lustre/lustre/ptlrpc/llog_client.c index b3db05583641e..d771cb9f129fd 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/llog_client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/llog_client.c @@ -132,7 +132,6 @@ static int llog_client_open(const struct lu_env *env, lgh->lgh_id = body->lgd_logid; lgh->lgh_ctxt = ctxt; - EXIT; out: LLOG_CLIENT_EXIT(ctxt, imp); ptlrpc_req_finished(req); @@ -218,7 +217,6 @@ static int llog_client_next_block(const struct lu_env *env, *cur_offset = body->lgd_cur_offset; memcpy(buf, ptr, len); - EXIT; out: ptlrpc_req_finished(req); err_exit: @@ -266,7 +264,6 @@ static int llog_client_prev_block(const struct lu_env *env, GOTO(out, rc =-EFAULT); memcpy(buf, ptr, len); - EXIT; out: ptlrpc_req_finished(req); err_exit: @@ -321,7 +318,6 @@ static int llog_client_read_header(const struct lu_env *env, CERROR("you may need to re-run lconf --write_conf.\n"); rc = -EIO; } - EXIT; out: ptlrpc_req_finished(req); err_exit: diff --git a/drivers/staging/lustre/lustre/ptlrpc/llog_server.c b/drivers/staging/lustre/lustre/ptlrpc/llog_server.c index b5aec5e84ee62..711cbd1ecc290 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/llog_server.c +++ b/drivers/staging/lustre/lustre/ptlrpc/llog_server.c @@ -106,7 +106,6 @@ int llog_origin_handle_open(struct ptlrpc_request *req) body = req_capsule_server_get(&req->rq_pill, &RMF_LLOGD_BODY); body->lgd_logid = loghandle->lgh_id; - EXIT; out_close: llog_origin_close(req->rq_svc_thread->t_env, loghandle); out_pop: @@ -202,7 +201,6 @@ int llog_origin_handle_next_block(struct ptlrpc_request *req) &repbody->lgd_cur_offset, ptr, LLOG_CHUNK_SIZE); if (rc) GOTO(out_close, rc); - EXIT; out_close: llog_origin_close(req->rq_svc_thread->t_env, loghandle); out_pop: @@ -261,7 +259,6 @@ int llog_origin_handle_prev_block(struct ptlrpc_request *req) if (rc) GOTO(out_close, rc); - EXIT; out_close: llog_origin_close(req->rq_svc_thread->t_env, loghandle); out_pop: @@ -314,7 +311,6 @@ int llog_origin_handle_read_header(struct ptlrpc_request *req) hdr = req_capsule_server_get(&req->rq_pill, &RMF_LLOG_LOG_HDR); *hdr = *loghandle->lgh_hdr; - EXIT; out_close: llog_origin_close(req->rq_svc_thread->t_env, loghandle); out_pop: diff --git a/drivers/staging/lustre/lustre/ptlrpc/nrs.c b/drivers/staging/lustre/lustre/ptlrpc/nrs.c index afc52326b1cb5..226c9c0880640 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/nrs.c +++ b/drivers/staging/lustre/lustre/ptlrpc/nrs.c @@ -110,8 +110,6 @@ static void nrs_policy_stop0(struct ptlrpc_nrs_policy *policy) if (atomic_dec_and_test(&policy->pol_desc->pd_refs)) module_put(policy->pol_desc->pd_owner); - - EXIT; } static int nrs_policy_stop_locked(struct ptlrpc_nrs_policy *policy) @@ -158,7 +156,6 @@ static void nrs_policy_stop_primary(struct ptlrpc_nrs *nrs) struct ptlrpc_nrs_policy *tmp = nrs->nrs_policy_primary; if (tmp == NULL) { - EXIT; return; } @@ -169,7 +166,6 @@ static void nrs_policy_stop_primary(struct ptlrpc_nrs *nrs) if (tmp->pol_ref == 0) nrs_policy_stop0(tmp); - EXIT; } /** @@ -839,7 +835,6 @@ static void ptlrpc_nrs_hpreq_add_nolock(struct ptlrpc_request *req) if (opc != OBD_PING) DEBUG_REQ(D_NET, req, "high priority req"); spin_unlock(&req->rq_lock); - EXIT; } /** @@ -1020,8 +1015,6 @@ static void nrs_svcpt_cleanup_locked(struct ptlrpc_service_part *svcpt) if (hp) OBD_FREE_PTR(nrs); - - EXIT; } /** @@ -1639,7 +1632,6 @@ void ptlrpc_nrs_req_hp_move(struct ptlrpc_request *req) * returned false. */ nrs_resource_put_safe(res1); - EXIT; } /** diff --git a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c index aae4fd67152a1..d722c6451cea3 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c @@ -2170,14 +2170,12 @@ static void lustre_swab_lov_user_md_common(struct lov_user_md_v1 *lum) __swab16s(&lum->lmm_stripe_count); __swab16s(&lum->lmm_stripe_offset); print_lum(lum); - EXIT; } void lustre_swab_lov_user_md_v1(struct lov_user_md_v1 *lum) { CDEBUG(D_IOCTL, "swabbing lov_user_md v1\n"); lustre_swab_lov_user_md_common(lum); - EXIT; } EXPORT_SYMBOL(lustre_swab_lov_user_md_v1); @@ -2186,7 +2184,6 @@ void lustre_swab_lov_user_md_v3(struct lov_user_md_v3 *lum) CDEBUG(D_IOCTL, "swabbing lov_user_md v3\n"); lustre_swab_lov_user_md_common((struct lov_user_md_v1 *)lum); /* lmm_pool_name nothing to do with char */ - EXIT; } EXPORT_SYMBOL(lustre_swab_lov_user_md_v3); @@ -2199,7 +2196,6 @@ void lustre_swab_lov_mds_md(struct lov_mds_md *lmm) __swab32s(&lmm->lmm_stripe_size); __swab16s(&lmm->lmm_stripe_count); __swab16s(&lmm->lmm_layout_gen); - EXIT; } EXPORT_SYMBOL(lustre_swab_lov_mds_md); @@ -2213,7 +2209,6 @@ void lustre_swab_lov_user_md_objects(struct lov_user_ost_data *lod, __swab32s(&(lod[i].l_ost_gen)); __swab32s(&(lod[i].l_ost_idx)); } - EXIT; } EXPORT_SYMBOL(lustre_swab_lov_user_md_objects); diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c index 74372914e8504..481963df2023e 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c @@ -350,7 +350,6 @@ static int ptlrpc_pinger_main(void *arg) thread_is_event(thread), &lwi); if (thread_test_and_clear_flags(thread, SVC_STOPPING)) { - EXIT; break; } else { /* woken after adding import to reset timer */ diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c index e0ee38e80ae2a..8b654abd8f736 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c @@ -666,16 +666,13 @@ void ptlrpcd_stop(struct ptlrpcd_ctl *pc, int force) { if (!test_bit(LIOD_START, &pc->pc_flags)) { CWARN("Thread for pc %p was not started\n", pc); - goto out; + return; } set_bit(LIOD_STOP, &pc->pc_flags); if (force) set_bit(LIOD_FORCE, &pc->pc_flags); wake_up(&pc->pc_set->set_waitq); - -out: - EXIT; } void ptlrpcd_free(struct ptlrpcd_ctl *pc) @@ -709,7 +706,6 @@ void ptlrpcd_free(struct ptlrpcd_ctl *pc) pc->pc_partners = NULL; } pc->pc_npartners = 0; - EXIT; } static void ptlrpcd_fini(void) @@ -726,8 +722,6 @@ static void ptlrpcd_fini(void) OBD_FREE(ptlrpcds, ptlrpcds->pd_size); ptlrpcds = NULL; } - - EXIT; } static int ptlrpcd_init(void) diff --git a/drivers/staging/lustre/lustre/ptlrpc/recover.c b/drivers/staging/lustre/lustre/ptlrpc/recover.c index 29a9f0acc6720..682d97143c343 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/recover.c +++ b/drivers/staging/lustre/lustre/ptlrpc/recover.c @@ -62,8 +62,6 @@ void ptlrpc_initiate_recovery(struct obd_import *imp) { CDEBUG(D_HA, "%s: starting recovery\n", obd2cli_tgt(imp->imp_obd)); ptlrpc_connect_import(imp); - - EXIT; } /** @@ -224,8 +222,6 @@ void ptlrpc_request_handle_notconn(struct ptlrpc_request *failed_req) if (!failed_req->rq_no_resend) failed_req->rq_resend = 1; spin_unlock(&failed_req->rq_lock); - - EXIT; } /** @@ -329,7 +325,6 @@ int ptlrpc_recover_import(struct obd_import *imp, char *new_uuid, int async) CDEBUG(D_HA, "%s: recovery finished\n", obd2cli_tgt(imp->imp_obd)); } - EXIT; out: return rc; diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c b/drivers/staging/lustre/lustre/ptlrpc/sec.c index 9ec7157e7fd91..82b1c3ac05a43 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c @@ -441,7 +441,6 @@ void sptlrpc_req_put_ctx(struct ptlrpc_request *req, int sync) sptlrpc_cli_ctx_put(req->rq_cli_ctx, sync); req->rq_cli_ctx = NULL; - EXIT; } static @@ -1691,7 +1690,6 @@ void sptlrpc_cli_free_repbuf(struct ptlrpc_request *req) policy = ctx->cc_sec->ps_policy; policy->sp_cops->free_repbuf(ctx->cc_sec, req); req->rq_repmsg = NULL; - EXIT; } int sptlrpc_cli_install_rvs_ctx(struct obd_import *imp, @@ -2149,7 +2147,6 @@ void sptlrpc_svc_free_rs(struct ptlrpc_reply_state *rs) if (prealloc) lustre_put_emerg_rs(rs); - EXIT; } void sptlrpc_svc_ctx_addref(struct ptlrpc_request *req) diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_config.c b/drivers/staging/lustre/lustre/ptlrpc/sec_config.c index f12bdeb8b1f88..665cf1b2171d1 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_config.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_config.c @@ -922,7 +922,6 @@ void sptlrpc_conf_client_adapt(struct obd_device *obd) } up_read(&obd->u.cli.cl_sem); - EXIT; } EXPORT_SYMBOL(sptlrpc_conf_client_adapt); diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c index f5fbdbe0c85e4..ed33a7fecb467 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c @@ -425,7 +425,6 @@ void plain_destroy_sec(struct ptlrpc_sec *sec) class_import_put(sec->ps_import); OBD_FREE_PTR(plsec); - EXIT; } static @@ -590,7 +589,6 @@ void plain_free_reqbuf(struct ptlrpc_sec *sec, req->rq_reqbuf = NULL; req->rq_reqbuf_len = 0; } - EXIT; } static @@ -631,7 +629,6 @@ void plain_free_repbuf(struct ptlrpc_sec *sec, OBD_FREE_LARGE(req->rq_repbuf, req->rq_repbuf_len); req->rq_repbuf = NULL; req->rq_repbuf_len = 0; - EXIT; } static @@ -819,7 +816,6 @@ void plain_free_rs(struct ptlrpc_reply_state *rs) if (!rs->rs_prealloc) OBD_FREE_LARGE(rs, rs->rs_size); - EXIT; } static diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index 1a73f8a57b418..190c83f170df0 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -379,7 +379,6 @@ void ptlrpc_dispatch_difficult_reply(struct ptlrpc_reply_state *rs) spin_unlock(&hrt->hrt_lock); wake_up(&hrt->hrt_waitq); - EXIT; } void @@ -391,14 +390,12 @@ ptlrpc_schedule_difficult_reply(struct ptlrpc_reply_state *rs) rs->rs_scheduled_ever = 1; /* flag any notification attempt */ if (rs->rs_scheduled) { /* being set up or already notified */ - EXIT; return; } rs->rs_scheduled = 1; list_del_init(&rs->rs_list); ptlrpc_dispatch_difficult_reply(rs); - EXIT; } EXPORT_SYMBOL(ptlrpc_schedule_difficult_reply); @@ -425,7 +422,6 @@ void ptlrpc_commit_replies(struct obd_export *exp) } spin_unlock(&exp->exp_uncommitted_replies_lock); rs_batch_fini(&batch); - EXIT; } EXPORT_SYMBOL(ptlrpc_commit_replies); @@ -1071,7 +1067,6 @@ static void ptlrpc_update_export_timer(struct obd_export *exp, long extra_delay) if (exp->exp_obd->obd_recovering) { /* be nice to everyone during recovery */ - EXIT; return; } @@ -1100,8 +1095,6 @@ static void ptlrpc_update_export_timer(struct obd_export *exp, long extra_delay) exp->exp_obd->obd_eviction_timer = 0; } } - - EXIT; } /** @@ -1547,7 +1540,6 @@ static void ptlrpc_server_hpreq_fini(struct ptlrpc_request *req) list_del_init(&req->rq_exp_list); spin_unlock_bh(&req->rq_export->exp_rpc_lock); } - EXIT; } static int ptlrpc_hpreq_check(struct ptlrpc_request *req) @@ -2615,7 +2607,6 @@ static void ptlrpc_svcpt_stop_threads(struct ptlrpc_service_part *svcpt) list_del(&thread->t_link); OBD_FREE_PTR(thread); } - EXIT; } /** @@ -2630,8 +2621,6 @@ void ptlrpc_stop_all_threads(struct ptlrpc_service *svc) if (svcpt->scp_service != NULL) ptlrpc_svcpt_stop_threads(svcpt); } - - EXIT; } EXPORT_SYMBOL(ptlrpc_stop_all_threads); -- GitLab From 0a3bdb00710bf253ba8ba8f645645f22297c7a04 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sat, 3 Aug 2013 10:35:28 +0800 Subject: [PATCH 456/942] staging: lustre: remove RETURN macro We have a kernel-wide function tracing system, so use that instead of rolling a custom one just for one filesystem. Cc: Peng Tao Cc: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../lustre/include/linux/libcfs/bitmap.h | 4 +- .../lustre/include/linux/libcfs/libcfs.h | 12 - .../include/linux/libcfs/libcfs_debug.h | 47 --- .../lustre/lnet/klnds/socklnd/socklnd_cb.c | 2 +- drivers/staging/lustre/lnet/lnet/lib-eq.c | 12 +- drivers/staging/lustre/lnet/lnet/module.c | 4 +- .../staging/lustre/lustre/fid/fid_request.c | 28 +- drivers/staging/lustre/lustre/fid/lproc_fid.c | 18 +- drivers/staging/lustre/lustre/fld/fld_cache.c | 26 +- .../staging/lustre/lustre/fld/fld_request.c | 32 +- drivers/staging/lustre/lustre/fld/lproc_fld.c | 8 +- .../lustre/lustre/include/lustre_cfg.h | 20 +- .../lustre/lustre/include/lustre_fid.h | 8 +- .../lustre/lustre/include/lustre_log.h | 24 +- .../staging/lustre/lustre/include/obd_class.h | 258 ++++++------ .../staging/lustre/lustre/lclient/glimpse.c | 14 +- .../lustre/lustre/lclient/lcommon_cl.c | 28 +- .../lustre/lustre/lclient/lcommon_misc.c | 6 +- .../lustre/lustre/ldlm/interval_tree.c | 30 +- .../staging/lustre/lustre/ldlm/ldlm_extent.c | 8 +- .../staging/lustre/lustre/ldlm/ldlm_flock.c | 38 +- drivers/staging/lustre/lustre/ldlm/ldlm_lib.c | 36 +- .../staging/lustre/lustre/ldlm/ldlm_lock.c | 78 ++-- .../staging/lustre/lustre/ldlm/ldlm_lockd.c | 88 ++-- .../staging/lustre/lustre/ldlm/ldlm_pool.c | 35 +- .../staging/lustre/lustre/ldlm/ldlm_request.c | 122 +++--- .../lustre/lustre/ldlm/ldlm_resource.c | 16 +- drivers/staging/lustre/lustre/libcfs/debug.c | 8 - drivers/staging/lustre/lustre/libcfs/hash.c | 14 +- .../lustre/lustre/libcfs/kernel_user_comm.c | 12 +- .../lustre/libcfs/linux/linux-curproc.c | 4 +- .../lustre/lustre/libcfs/linux/linux-module.c | 14 +- drivers/staging/lustre/lustre/libcfs/module.c | 18 +- .../staging/lustre/lustre/libcfs/nidstrings.c | 12 +- .../lustre/lustre/libcfs/upcall_cache.c | 12 +- drivers/staging/lustre/lustre/llite/dcache.c | 48 +-- drivers/staging/lustre/lustre/llite/dir.c | 161 ++++---- drivers/staging/lustre/lustre/llite/file.c | 300 +++++++------- .../staging/lustre/lustre/llite/llite_capa.c | 16 +- .../staging/lustre/lustre/llite/llite_close.c | 6 +- .../staging/lustre/lustre/llite/llite_lib.c | 96 ++--- .../staging/lustre/lustre/llite/llite_mmap.c | 16 +- .../staging/lustre/lustre/llite/llite_nfs.c | 40 +- .../staging/lustre/lustre/llite/lproc_llite.c | 10 +- drivers/staging/lustre/lustre/llite/namei.c | 62 +-- .../staging/lustre/lustre/llite/remote_perm.c | 12 +- drivers/staging/lustre/lustre/llite/rw.c | 24 +- drivers/staging/lustre/lustre/llite/rw26.c | 16 +- .../staging/lustre/lustre/llite/statahead.c | 42 +- drivers/staging/lustre/lustre/llite/symlink.c | 12 +- drivers/staging/lustre/lustre/llite/vvp_dev.c | 4 +- drivers/staging/lustre/lustre/llite/vvp_io.c | 26 +- .../staging/lustre/lustre/llite/vvp_lock.c | 2 +- .../staging/lustre/lustre/llite/vvp_page.c | 4 +- drivers/staging/lustre/lustre/llite/xattr.c | 36 +- drivers/staging/lustre/lustre/lmv/lmv_fld.c | 4 +- .../staging/lustre/lustre/lmv/lmv_intent.c | 32 +- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 384 +++++++++--------- drivers/staging/lustre/lustre/lov/lov_dev.c | 26 +- drivers/staging/lustre/lustre/lov/lov_io.c | 44 +- drivers/staging/lustre/lustre/lov/lov_lock.c | 34 +- drivers/staging/lustre/lustre/lov/lov_log.c | 10 +- drivers/staging/lustre/lustre/lov/lov_merge.c | 8 +- drivers/staging/lustre/lustre/lov/lov_obd.c | 238 +++++------ .../staging/lustre/lustre/lov/lov_object.c | 22 +- .../staging/lustre/lustre/lov/lov_offset.c | 4 +- drivers/staging/lustre/lustre/lov/lov_pack.c | 56 +-- drivers/staging/lustre/lustre/lov/lov_page.c | 6 +- drivers/staging/lustre/lustre/lov/lov_pool.c | 22 +- .../staging/lustre/lustre/lov/lov_request.c | 124 +++--- .../staging/lustre/lustre/lov/lovsub_dev.c | 6 +- .../staging/lustre/lustre/lov/lovsub_lock.c | 12 +- .../staging/lustre/lustre/lov/lovsub_object.c | 8 +- .../staging/lustre/lustre/lov/lovsub_page.c | 2 +- drivers/staging/lustre/lustre/lvfs/fsfilt.c | 4 +- .../staging/lustre/lustre/lvfs/lvfs_linux.c | 8 +- drivers/staging/lustre/lustre/mdc/lproc_mdc.c | 8 +- drivers/staging/lustre/lustre/mdc/mdc_lib.c | 2 +- drivers/staging/lustre/lustre/mdc/mdc_locks.c | 104 ++--- drivers/staging/lustre/lustre/mdc/mdc_reint.c | 40 +- .../staging/lustre/lustre/mdc/mdc_request.c | 236 +++++------ drivers/staging/lustre/lustre/mgc/libmgc.c | 14 +- .../staging/lustre/lustre/mgc/mgc_request.c | 120 +++--- drivers/staging/lustre/lustre/obdclass/acl.c | 22 +- drivers/staging/lustre/lustre/obdclass/capa.c | 4 +- .../staging/lustre/lustre/obdclass/cl_io.c | 50 +-- .../staging/lustre/lustre/obdclass/cl_lock.c | 64 +-- .../lustre/lustre/obdclass/cl_object.c | 10 +- .../staging/lustre/lustre/obdclass/cl_page.c | 50 +-- .../lustre/lustre/obdclass/class_obd.c | 14 +- .../lustre/lustre/obdclass/dt_object.c | 22 +- .../staging/lustre/lustre/obdclass/genops.c | 48 +-- .../lustre/obdclass/linux/linux-module.c | 28 +- drivers/staging/lustre/lustre/obdclass/llog.c | 92 ++--- .../staging/lustre/lustre/obdclass/llog_cat.c | 74 ++-- .../lustre/lustre/obdclass/llog_ioctl.c | 70 ++-- .../lustre/lustre/obdclass/llog_lvfs.c | 84 ++-- .../staging/lustre/lustre/obdclass/llog_obd.c | 28 +- .../staging/lustre/lustre/obdclass/llog_osd.c | 88 ++-- .../lustre/lustre/obdclass/llog_test.c | 70 ++-- .../lustre/lustre/obdclass/local_storage.c | 30 +- .../lustre/lustre/obdclass/lprocfs_status.c | 20 +- .../lustre/lustre/obdclass/lu_object.c | 14 +- .../lustre/lustre/obdclass/lustre_handles.c | 2 +- .../lustre/lustre/obdclass/lustre_peer.c | 2 +- .../staging/lustre/lustre/obdclass/md_attrs.c | 14 +- .../lustre/lustre/obdclass/obd_config.c | 112 ++--- .../lustre/lustre/obdclass/obd_mount.c | 62 +-- drivers/staging/lustre/lustre/obdecho/echo.c | 38 +- .../lustre/lustre/obdecho/echo_client.c | 170 ++++---- drivers/staging/lustre/lustre/osc/osc_cache.c | 92 ++--- drivers/staging/lustre/lustre/osc/osc_dev.c | 10 +- drivers/staging/lustre/lustre/osc/osc_io.c | 14 +- drivers/staging/lustre/lustre/osc/osc_lock.c | 8 +- .../staging/lustre/lustre/osc/osc_object.c | 2 +- drivers/staging/lustre/lustre/osc/osc_page.c | 16 +- drivers/staging/lustre/lustre/osc/osc_quota.c | 24 +- .../staging/lustre/lustre/osc/osc_request.c | 268 ++++++------ drivers/staging/lustre/lustre/ptlrpc/client.c | 120 +++--- .../staging/lustre/lustre/ptlrpc/connection.c | 12 +- .../lustre/lustre/ptlrpc/gss/gss_bulk.c | 48 +-- .../lustre/lustre/ptlrpc/gss/gss_cli_upcall.c | 26 +- .../lustre/lustre/ptlrpc/gss/gss_keyring.c | 32 +- .../lustre/lustre/ptlrpc/gss/gss_krb5_mech.c | 4 +- .../lustre/lustre/ptlrpc/gss/gss_pipefs.c | 34 +- .../lustre/lustre/ptlrpc/gss/gss_rawobj.c | 2 +- .../lustre/lustre/ptlrpc/gss/gss_svc_upcall.c | 6 +- .../lustre/lustre/ptlrpc/gss/sec_gss.c | 190 ++++----- drivers/staging/lustre/lustre/ptlrpc/import.c | 40 +- .../lustre/lustre/ptlrpc/llog_client.c | 2 +- .../staging/lustre/lustre/ptlrpc/llog_net.c | 2 +- .../lustre/lustre/ptlrpc/llog_server.c | 30 +- .../lustre/lustre/ptlrpc/lproc_ptlrpc.c | 10 +- drivers/staging/lustre/lustre/ptlrpc/niobuf.c | 30 +- drivers/staging/lustre/lustre/ptlrpc/nrs.c | 74 ++-- .../lustre/lustre/ptlrpc/pack_generic.c | 14 +- drivers/staging/lustre/lustre/ptlrpc/pinger.c | 28 +- .../lustre/lustre/ptlrpc/ptlrpc_module.c | 6 +- .../staging/lustre/lustre/ptlrpc/ptlrpcd.c | 16 +- .../staging/lustre/lustre/ptlrpc/recover.c | 10 +- drivers/staging/lustre/lustre/ptlrpc/sec.c | 84 ++-- .../staging/lustre/lustre/ptlrpc/sec_config.c | 40 +- .../staging/lustre/lustre/ptlrpc/sec_plain.c | 70 ++-- .../staging/lustre/lustre/ptlrpc/service.c | 90 ++-- 144 files changed, 3136 insertions(+), 3207 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/bitmap.h b/drivers/staging/lustre/include/linux/libcfs/bitmap.h index 3f1c37b4bb7a0..f3d4a896a75a1 100644 --- a/drivers/staging/lustre/include/linux/libcfs/bitmap.h +++ b/drivers/staging/lustre/include/linux/libcfs/bitmap.h @@ -52,11 +52,11 @@ cfs_bitmap_t *CFS_ALLOCATE_BITMAP(int size) OBD_ALLOC(ptr, CFS_BITMAP_SIZE(size)); if (ptr == NULL) - RETURN(ptr); + return ptr; ptr->size = size; - RETURN (ptr); + return ptr; } #define CFS_FREE_BITMAP(ptr) OBD_FREE(ptr, CFS_BITMAP_SIZE(ptr->size)) diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/libcfs.h index 0f76da5c6c2df..b71046ea18cb9 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h @@ -80,20 +80,8 @@ static inline int __is_po2(unsigned long long val) #define LERRCHKSUM(hexnum) (((hexnum) & 0xf) ^ ((hexnum) >> 4 & 0xf) ^ \ ((hexnum) >> 8 & 0xf)) - -/* - * Some (nomina odiosa sunt) platforms define NULL as naked 0. This confuses - * Lustre RETURN(NULL) macro. - */ -#if defined(NULL) -#undef NULL -#endif - -#define NULL ((void *)0) - #define LUSTRE_SRV_LNET_PID LUSTRE_LNET_PID - #include #ifndef cfs_for_each_possible_cpu diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h index e0ed2cf6e208c..e6439d19f3e55 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h @@ -262,53 +262,6 @@ do { \ } while (0) -/* - * if rc == NULL, we need to code as RETURN((void *)NULL), otherwise - * there will be a warning in osx. - */ -#if defined(__GNUC__) - -long libcfs_log_return(struct libcfs_debug_msg_data *, long rc); -#if BITS_PER_LONG > 32 -#define RETURN(rc) \ -do { \ - if (cfs_cdebug_show(D_TRACE, DEBUG_SUBSYSTEM)) { \ - LIBCFS_DEBUG_MSG_DATA_DECL(msgdata, D_TRACE, NULL); \ - return (typeof(rc))libcfs_log_return(&msgdata, \ - (long)(rc)); \ - } \ - \ - return (rc); \ -} while (0) -#else /* BITS_PER_LONG == 32 */ -/* We need an on-stack variable, because we cannot case a 32-bit pointer - * directly to (long long) without generating a complier warning/error, yet - * casting directly to (long) will truncate 64-bit return values. The log - * values will print as 32-bit values, but they always have been. LU-1436 - */ -#define RETURN(rc) \ -do { \ - if (cfs_cdebug_show(D_TRACE, DEBUG_SUBSYSTEM)) { \ - typeof(rc) __rc = (rc); \ - LIBCFS_DEBUG_MSG_DATA_DECL(msgdata, D_TRACE, NULL); \ - libcfs_log_return(&msgdata, (long_ptr_t)__rc); \ - return __rc; \ - } \ - \ - return (rc); \ -} while (0) -#endif /* BITS_PER_LONG > 32 */ - -#elif defined(_MSC_VER) -#define RETURN(rc) \ -do { \ - CDEBUG(D_TRACE, "Process leaving.\n"); \ - return (rc); \ -} while (0) -#else -# error "Unkown compiler" -#endif /* __GNUC__ */ - extern int libcfs_debug_msg(struct libcfs_debug_msg_data *msgdata, const char *format1, ...) __attribute__ ((format (printf, 2, 3))); diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c index cdaaca3727190..617570439be6c 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c @@ -380,7 +380,7 @@ ksocknal_receive (ksock_conn_t *conn) } ksocknal_connsock_decref(conn); - RETURN (rc); + return rc; } void diff --git a/drivers/staging/lustre/lnet/lnet/lib-eq.c b/drivers/staging/lustre/lnet/lnet/lib-eq.c index 3b8808bf78d18..4ce68d3b09311 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-eq.c +++ b/drivers/staging/lustre/lnet/lnet/lib-eq.c @@ -247,7 +247,7 @@ lnet_eq_dequeue_event(lnet_eq_t *eq, lnet_event_t *ev) /* must called with lnet_eq_wait_lock hold */ if (LNET_SEQ_GT(eq->eq_deq_seq, new_event->sequence)) - RETURN(0); + return 0; /* We've got a new event... */ *ev = *new_event; @@ -267,7 +267,7 @@ lnet_eq_dequeue_event(lnet_eq_t *eq, lnet_event_t *ev) } eq->eq_deq_seq = new_event->sequence + 1; - RETURN(rc); + return rc; } /** @@ -404,7 +404,7 @@ LNetEQPoll(lnet_handle_eq_t *eventqs, int neq, int timeout_ms, LASSERT (the_lnet.ln_refcount > 0); if (neq < 1) - RETURN(-ENOENT); + return -ENOENT; lnet_eq_wait_lock(); @@ -414,14 +414,14 @@ LNetEQPoll(lnet_handle_eq_t *eventqs, int neq, int timeout_ms, if (eq == NULL) { lnet_eq_wait_unlock(); - RETURN(-ENOENT); + return -ENOENT; } rc = lnet_eq_dequeue_event(eq, event); if (rc != 0) { lnet_eq_wait_unlock(); *which = i; - RETURN(rc); + return rc; } } @@ -441,5 +441,5 @@ LNetEQPoll(lnet_handle_eq_t *eventqs, int neq, int timeout_ms, } lnet_eq_wait_unlock(); - RETURN(0); + return 0; } diff --git a/drivers/staging/lustre/lnet/lnet/module.c b/drivers/staging/lustre/lnet/lnet/module.c index c57e46a384cd2..8679b8d1b2f76 100644 --- a/drivers/staging/lustre/lnet/lnet/module.c +++ b/drivers/staging/lustre/lnet/lnet/module.c @@ -120,7 +120,7 @@ init_lnet(void) rc = LNetInit(); if (rc != 0) { CERROR("LNetInit: error %d\n", rc); - RETURN(rc); + return rc; } rc = libcfs_register_ioctl(&lnet_ioctl_handler); @@ -132,7 +132,7 @@ init_lnet(void) (void) kthread_run(lnet_configure, NULL, "lnet_initd"); } - RETURN(0); + return 0; } void diff --git a/drivers/staging/lustre/lustre/fid/fid_request.c b/drivers/staging/lustre/lustre/fid/fid_request.c index 5d25a336b8526..dc3948e4be391 100644 --- a/drivers/staging/lustre/lustre/fid/fid_request.c +++ b/drivers/staging/lustre/lustre/fid/fid_request.c @@ -67,7 +67,7 @@ static int seq_client_rpc(struct lu_client_seq *seq, req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_SEQ_QUERY, LUSTRE_MDS_VERSION, SEQ_QUERY); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; /* Init operation code */ op = req_capsule_client_get(&req->rq_pill, &RMF_SEQ_OPC); @@ -153,14 +153,14 @@ int seq_client_alloc_super(struct lu_client_seq *seq, * setup (lcs_exp != NULL) */ if (seq->lcs_exp == NULL) { mutex_unlock(&seq->lcs_mutex); - RETURN(-EINPROGRESS); + return -EINPROGRESS; } rc = seq_client_rpc(seq, &seq->lcs_space, SEQ_ALLOC_SUPER, "super"); } mutex_unlock(&seq->lcs_mutex); - RETURN(rc); + return rc; } /* Request sequence-controller node to allocate new meta-sequence. */ @@ -182,7 +182,7 @@ static int seq_client_alloc_meta(const struct lu_env *env, } while (rc == -EINPROGRESS || rc == -EAGAIN); } - RETURN(rc); + return rc; } /* Allocate new sequence for client. */ @@ -198,7 +198,7 @@ static int seq_client_alloc_seq(const struct lu_env *env, if (rc) { CERROR("%s: Can't allocate new meta-sequence," "rc %d\n", seq->lcs_name, rc); - RETURN(rc); + return rc; } else { CDEBUG(D_INFO, "%s: New range - "DRANGE"\n", seq->lcs_name, PRANGE(&seq->lcs_space)); @@ -214,7 +214,7 @@ static int seq_client_alloc_seq(const struct lu_env *env, CDEBUG(D_INFO, "%s: Allocated sequence ["LPX64"]\n", seq->lcs_name, *seqnr); - RETURN(rc); + return rc; } static int seq_fid_alloc_prep(struct lu_client_seq *seq, @@ -333,7 +333,7 @@ int seq_client_alloc_fid(const struct lu_env *env, "rc %d\n", seq->lcs_name, rc); seq_fid_alloc_fini(seq); mutex_unlock(&seq->lcs_mutex); - RETURN(rc); + return rc; } CDEBUG(D_INFO, "%s: Switch to sequence " @@ -357,7 +357,7 @@ int seq_client_alloc_fid(const struct lu_env *env, mutex_unlock(&seq->lcs_mutex); CDEBUG(D_INFO, "%s: Allocated FID "DFID"\n", seq->lcs_name, PFID(fid)); - RETURN(rc); + return rc; } EXPORT_SYMBOL(seq_client_alloc_fid); @@ -422,7 +422,7 @@ static int seq_client_proc_init(struct lu_client_seq *seq) CERROR("%s: LProcFS failed in seq-init\n", seq->lcs_name); rc = PTR_ERR(seq->lcs_proc_dir); - RETURN(rc); + return rc; } rc = lprocfs_add_vars(seq->lcs_proc_dir, @@ -433,7 +433,7 @@ static int seq_client_proc_init(struct lu_client_seq *seq) GOTO(out_cleanup, rc); } - RETURN(0); + return 0; out_cleanup: seq_client_proc_fini(seq); @@ -479,7 +479,7 @@ int seq_client_init(struct lu_client_seq *seq, rc = seq_client_proc_init(seq); if (rc) seq_client_fini(seq); - RETURN(rc); + return rc; } EXPORT_SYMBOL(seq_client_init); @@ -505,7 +505,7 @@ int client_fid_init(struct obd_device *obd, OBD_ALLOC_PTR(cli->cl_seq); if (cli->cl_seq == NULL) - RETURN(-ENOMEM); + return -ENOMEM; OBD_ALLOC(prefix, MAX_OBD_NAME + 5); if (prefix == NULL) @@ -519,7 +519,7 @@ int client_fid_init(struct obd_device *obd, if (rc) GOTO(out_free_seq, rc); - RETURN(rc); + return rc; out_free_seq: OBD_FREE_PTR(cli->cl_seq); cli->cl_seq = NULL; @@ -537,7 +537,7 @@ int client_fid_fini(struct obd_device *obd) cli->cl_seq = NULL; } - RETURN(0); + return 0; } EXPORT_SYMBOL(client_fid_fini); diff --git a/drivers/staging/lustre/lustre/fid/lproc_fid.c b/drivers/staging/lustre/lustre/fid/lproc_fid.c index b1ad25706ed57..294070da9d432 100644 --- a/drivers/staging/lustre/lustre/fid/lproc_fid.c +++ b/drivers/staging/lustre/lustre/fid/lproc_fid.c @@ -72,9 +72,9 @@ lprocfs_fid_write_common(const char *buffer, unsigned long count, (long long unsigned *)&tmp.lsr_start, (long long unsigned *)&tmp.lsr_end); if (rc != 2 || !range_is_sane(&tmp) || range_is_zero(&tmp)) - RETURN(-EINVAL); + return -EINVAL; *range = tmp; - RETURN(0); + return 0; } /* Client side procfs stuff */ @@ -97,7 +97,7 @@ lprocfs_fid_space_seq_write(struct file *file, const char *buffer, mutex_unlock(&seq->lcs_mutex); - RETURN(count); + return count; } static int @@ -112,7 +112,7 @@ lprocfs_fid_space_seq_show(struct seq_file *m, void *unused) rc = seq_printf(m, "["LPX64" - "LPX64"]:%x:%s\n", PRANGE(&seq->lcs_space)); mutex_unlock(&seq->lcs_mutex); - RETURN(rc); + return rc; } static ssize_t @@ -127,7 +127,7 @@ lprocfs_fid_width_seq_write(struct file *file, const char *buffer, rc = lprocfs_write_helper(buffer, count, &val); if (rc) - RETURN(rc); + return rc; mutex_lock(&seq->lcs_mutex); if (seq->lcs_type == LUSTRE_SEQ_DATA) @@ -146,7 +146,7 @@ lprocfs_fid_width_seq_write(struct file *file, const char *buffer, mutex_unlock(&seq->lcs_mutex); - RETURN(count); + return count; } static int @@ -161,7 +161,7 @@ lprocfs_fid_width_seq_show(struct seq_file *m, void *unused) rc = seq_printf(m, LPU64"\n", seq->lcs_width); mutex_unlock(&seq->lcs_mutex); - RETURN(rc); + return rc; } static int @@ -176,7 +176,7 @@ lprocfs_fid_fid_seq_show(struct seq_file *m, void *unused) rc = seq_printf(m, DFID"\n", PFID(&seq->lcs_fid)); mutex_unlock(&seq->lcs_mutex); - RETURN(rc); + return rc; } static int @@ -194,7 +194,7 @@ lprocfs_fid_server_seq_show(struct seq_file *m, void *unused) } else { rc = seq_printf(m, "%s\n", seq->lcs_srv->lss_name); } - RETURN(rc); + return rc; } LPROC_SEQ_FOPS(lprocfs_fid_space); diff --git a/drivers/staging/lustre/lustre/fld/fld_cache.c b/drivers/staging/lustre/lustre/fld/fld_cache.c index b1672f773066a..25099cbe37eb7 100644 --- a/drivers/staging/lustre/lustre/fld/fld_cache.c +++ b/drivers/staging/lustre/lustre/fld/fld_cache.c @@ -72,7 +72,7 @@ struct fld_cache *fld_cache_init(const char *name, OBD_ALLOC_PTR(cache); if (cache == NULL) - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); INIT_LIST_HEAD(&cache->fci_entries_head); INIT_LIST_HEAD(&cache->fci_lru); @@ -92,7 +92,7 @@ struct fld_cache *fld_cache_init(const char *name, CDEBUG(D_INFO, "%s: FLD cache - Size: %d, Threshold: %d\n", cache->fci_name, cache_size, cache_threshold); - RETURN(cache); + return cache; } /** @@ -223,7 +223,7 @@ static int fld_cache_shrink(struct fld_cache *cache) LASSERT(cache != NULL); if (cache->fci_cache_count < cache->fci_cache_size) - RETURN(0); + return 0; curr = cache->fci_lru.prev; @@ -239,7 +239,7 @@ static int fld_cache_shrink(struct fld_cache *cache) CDEBUG(D_INFO, "%s: FLD cache - Shrunk by " "%d entries\n", cache->fci_name, num); - RETURN(0); + return 0; } /** @@ -367,10 +367,10 @@ struct fld_cache_entry OBD_ALLOC_PTR(f_new); if (!f_new) - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); f_new->fce_range = *range; - RETURN(f_new); + return f_new; } /** @@ -424,7 +424,7 @@ int fld_cache_insert_nolock(struct fld_cache *cache, /* Add new entry to cache and lru list. */ fld_cache_entry_add(cache, f_new, prev); out: - RETURN(0); + return 0; } int fld_cache_insert(struct fld_cache *cache, @@ -435,7 +435,7 @@ int fld_cache_insert(struct fld_cache *cache, flde = fld_cache_entry_create(range); if (IS_ERR(flde)) - RETURN(PTR_ERR(flde)); + return PTR_ERR(flde); write_lock(&cache->fci_lock); rc = fld_cache_insert_nolock(cache, flde); @@ -443,7 +443,7 @@ int fld_cache_insert(struct fld_cache *cache, if (rc) OBD_FREE_PTR(flde); - RETURN(rc); + return rc; } void fld_cache_delete_nolock(struct fld_cache *cache, @@ -495,7 +495,7 @@ struct fld_cache_entry } } - RETURN(got); + return got; } /** @@ -509,7 +509,7 @@ struct fld_cache_entry read_lock(&cache->fci_lock); got = fld_cache_entry_lookup_nolock(cache, range); read_unlock(&cache->fci_lock); - RETURN(got); + return got; } /** @@ -539,9 +539,9 @@ int fld_cache_lookup(struct fld_cache *cache, cache->fci_stat.fst_cache++; read_unlock(&cache->fci_lock); - RETURN(0); + return 0; } } read_unlock(&cache->fci_lock); - RETURN(-ENOENT); + return -ENOENT; } diff --git a/drivers/staging/lustre/lustre/fld/fld_request.c b/drivers/staging/lustre/lustre/fld/fld_request.c index 9fe004681abdf..a08867ab63bf6 100644 --- a/drivers/staging/lustre/lustre/fld/fld_request.c +++ b/drivers/staging/lustre/lustre/fld/fld_request.c @@ -70,7 +70,7 @@ static int fld_req_avail(struct client_obd *cli, struct mdc_cache_waiter *mcw) client_obd_list_lock(&cli->cl_loi_list_lock); rc = list_empty(&mcw->mcw_entry); client_obd_list_unlock(&cli->cl_loi_list_lock); - RETURN(rc); + return rc; }; static void fld_enter_request(struct client_obd *cli) @@ -137,7 +137,7 @@ fld_rrb_scan(struct lu_client_fld *fld, seqno_t seq) list_for_each_entry(target, &fld->lcf_targets, ft_chain) { if (target->ft_idx == hash) - RETURN(target); + return target; } CERROR("%s: Can't find target by hash %d (seq "LPX64"). " @@ -161,7 +161,7 @@ fld_rrb_scan(struct lu_client_fld *fld, seqno_t seq) * LBUG() to catch this situation. */ LBUG(); - RETURN(NULL); + return NULL; } struct lu_fld_hash fld_hash[] = { @@ -192,7 +192,7 @@ fld_client_get_target(struct lu_client_fld *fld, seqno_t seq) target->ft_idx, seq); } - RETURN(target); + return target; } /* @@ -214,7 +214,7 @@ int fld_client_add_target(struct lu_client_fld *fld, CERROR("%s: Attempt to add target %s (idx "LPU64") " "on fly - skip it\n", fld->lcf_name, name, tar->ft_idx); - RETURN(0); + return 0; } else { CDEBUG(D_INFO, "%s: Adding target %s (idx " LPU64")\n", fld->lcf_name, name, tar->ft_idx); @@ -222,7 +222,7 @@ int fld_client_add_target(struct lu_client_fld *fld, OBD_ALLOC_PTR(target); if (target == NULL) - RETURN(-ENOMEM); + return -ENOMEM; spin_lock(&fld->lcf_lock); list_for_each_entry(tmp, &fld->lcf_targets, ft_chain) { @@ -231,7 +231,7 @@ int fld_client_add_target(struct lu_client_fld *fld, OBD_FREE_PTR(target); CERROR("Target %s exists in FLD and known as %s:#"LPU64"\n", name, fld_target_name(tmp), tmp->ft_idx); - RETURN(-EEXIST); + return -EEXIST; } } @@ -247,7 +247,7 @@ int fld_client_add_target(struct lu_client_fld *fld, fld->lcf_count++; spin_unlock(&fld->lcf_lock); - RETURN(0); + return 0; } EXPORT_SYMBOL(fld_client_add_target); @@ -268,11 +268,11 @@ int fld_client_del_target(struct lu_client_fld *fld, __u64 idx) class_export_put(target->ft_exp); OBD_FREE_PTR(target); - RETURN(0); + return 0; } } spin_unlock(&fld->lcf_lock); - RETURN(-ENOENT); + return -ENOENT; } EXPORT_SYMBOL(fld_client_del_target); @@ -291,7 +291,7 @@ static int fld_client_proc_init(struct lu_client_fld *fld) CERROR("%s: LProcFS failed in fld-init\n", fld->lcf_name); rc = PTR_ERR(fld->lcf_proc_dir); - RETURN(rc); + return rc; } rc = lprocfs_add_vars(fld->lcf_proc_dir, @@ -302,7 +302,7 @@ static int fld_client_proc_init(struct lu_client_fld *fld) GOTO(out_cleanup, rc); } - RETURN(0); + return 0; out_cleanup: fld_client_proc_fini(fld); @@ -350,7 +350,7 @@ int fld_client_init(struct lu_client_fld *fld, if (!hash_is_sane(hash)) { CERROR("%s: Wrong hash function %#x\n", fld->lcf_name, hash); - RETURN(-EINVAL); + return -EINVAL; } fld->lcf_count = 0; @@ -424,7 +424,7 @@ int fld_client_rpc(struct obd_export *exp, req = ptlrpc_request_alloc_pack(imp, &RQF_FLD_QUERY, LUSTRE_MDS_VERSION, FLD_QUERY); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; op = req_capsule_client_get(&req->rq_pill, &RMF_FLD_OPC); *op = fld_op; @@ -471,7 +471,7 @@ int fld_client_lookup(struct lu_client_fld *fld, seqno_t seq, mdsno_t *mds, rc = fld_cache_lookup(fld->lcf_cache, seq, &res); if (rc == 0) { *mds = res.lsr_index; - RETURN(0); + return 0; } /* Can not find it in the cache */ @@ -491,7 +491,7 @@ int fld_client_lookup(struct lu_client_fld *fld, seqno_t seq, mdsno_t *mds, fld_cache_insert(fld->lcf_cache, &res); } - RETURN(rc); + return rc; } EXPORT_SYMBOL(fld_client_lookup); diff --git a/drivers/staging/lustre/lustre/fld/lproc_fld.c b/drivers/staging/lustre/lustre/fld/lproc_fld.c index cf1f765dcab8d..052f7d51a07c6 100644 --- a/drivers/staging/lustre/lustre/fld/lproc_fld.c +++ b/drivers/staging/lustre/lustre/fld/lproc_fld.c @@ -71,7 +71,7 @@ fld_proc_targets_seq_show(struct seq_file *m, void *unused) seq_printf(m, "%s\n", fld_target_name(target)); spin_unlock(&fld->lcf_lock); - RETURN(0); + return 0; } static int @@ -85,7 +85,7 @@ fld_proc_hash_seq_show(struct seq_file *m, void *unused) seq_printf(m, "%s\n", fld->lcf_hash->fh_name); spin_unlock(&fld->lcf_lock); - RETURN(0); + return 0; } static ssize_t @@ -117,7 +117,7 @@ fld_proc_hash_seq_write(struct file *file, const char *buffer, fld->lcf_name, hash->fh_name); } - RETURN(count); + return count; } static ssize_t @@ -132,7 +132,7 @@ fld_proc_cache_flush_write(struct file *file, const char __user *buffer, CDEBUG(D_INFO, "%s: Lookup cache is flushed\n", fld->lcf_name); - RETURN(count); + return count; } static int fld_proc_cache_flush_open(struct inode *inode, struct file *file) diff --git a/drivers/staging/lustre/lustre/include/lustre_cfg.h b/drivers/staging/lustre/lustre/include/lustre_cfg.h index 46d5aaf178931..e14a5f674e852 100644 --- a/drivers/staging/lustre/lustre/include/lustre_cfg.h +++ b/drivers/staging/lustre/lustre/include/lustre_cfg.h @@ -216,7 +216,7 @@ static inline int lustre_cfg_len(__u32 bufcount, __u32 *buflens) for (i = 0; i < bufcount; i++) len += cfs_size_round(buflens[i]); - RETURN(cfs_size_round(len)); + return cfs_size_round(len); } @@ -232,7 +232,7 @@ static inline struct lustre_cfg *lustre_cfg_new(int cmd, OBD_ALLOC(lcfg, lustre_cfg_len(bufs->lcfg_bufcount, bufs->lcfg_buflen)); if (!lcfg) - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); lcfg->lcfg_version = LUSTRE_CFG_VERSION; lcfg->lcfg_command = cmd; @@ -243,7 +243,7 @@ static inline struct lustre_cfg *lustre_cfg_new(int cmd, lcfg->lcfg_buflens[i] = bufs->lcfg_buflen[i]; LOGL((char *)bufs->lcfg_buf[i], bufs->lcfg_buflen[i], ptr); } - RETURN(lcfg); + return lcfg; } static inline void lustre_cfg_free(struct lustre_cfg *lcfg) @@ -261,27 +261,27 @@ static inline int lustre_cfg_sanity_check(void *buf, int len) struct lustre_cfg *lcfg = (struct lustre_cfg *)buf; if (!lcfg) - RETURN(-EINVAL); + return -EINVAL; /* check that the first bits of the struct are valid */ if (len < LCFG_HDR_SIZE(0)) - RETURN(-EINVAL); + return -EINVAL; if (lcfg->lcfg_version != LUSTRE_CFG_VERSION) - RETURN(-EINVAL); + return -EINVAL; if (lcfg->lcfg_bufcount >= LUSTRE_CFG_MAX_BUFCOUNT) - RETURN(-EINVAL); + return -EINVAL; /* check that the buflens are valid */ if (len < LCFG_HDR_SIZE(lcfg->lcfg_bufcount)) - RETURN(-EINVAL); + return -EINVAL; /* make sure all the pointers point inside the data */ if (len < lustre_cfg_len(lcfg->lcfg_bufcount, lcfg->lcfg_buflens)) - RETURN(-EINVAL); + return -EINVAL; - RETURN(0); + return 0; } #include diff --git a/drivers/staging/lustre/lustre/include/lustre_fid.h b/drivers/staging/lustre/lustre/include/lustre_fid.h index f8f35c3fa091a..655119eda9a1c 100644 --- a/drivers/staging/lustre/lustre/include/lustre_fid.h +++ b/drivers/staging/lustre/lustre/include/lustre_fid.h @@ -677,14 +677,14 @@ static inline __u64 fid_flatten(const struct lu_fid *fid) if (fid_is_igif(fid)) { ino = lu_igif_ino(fid); - RETURN(ino); + return ino; } seq = fid_seq(fid); ino = (seq << 24) + ((seq >> 24) & 0xffffff0000ULL) + fid_oid(fid); - RETURN(ino ? ino : fid_oid(fid)); + return ino ? ino : fid_oid(fid); } static inline __u32 fid_hash(const struct lu_fid *f, int bits) @@ -703,7 +703,7 @@ static inline __u32 fid_flatten32(const struct lu_fid *fid) if (fid_is_igif(fid)) { ino = lu_igif_ino(fid); - RETURN(ino); + return ino; } seq = fid_seq(fid) - FID_SEQ_START; @@ -717,7 +717,7 @@ static inline __u32 fid_flatten32(const struct lu_fid *fid) (seq >> (64 - (40-8)) & 0xffffff00) + (fid_oid(fid) & 0xff000fff) + ((fid_oid(fid) & 0x00fff000) << 8); - RETURN(ino ? ino : fid_oid(fid)); + return ino ? ino : fid_oid(fid); } static inline int lu_fid_diff(struct lu_fid *fid1, struct lu_fid *fid2) diff --git a/drivers/staging/lustre/lustre/include/lustre_log.h b/drivers/staging/lustre/lustre/include/lustre_log.h index 8f642f3e01057..721aa05dff3b9 100644 --- a/drivers/staging/lustre/lustre/include/lustre_log.h +++ b/drivers/staging/lustre/lustre/include/lustre_log.h @@ -471,12 +471,12 @@ static inline int llog_destroy(const struct lu_env *env, rc = llog_handle2ops(handle, &lop); if (rc) - RETURN(rc); + return rc; if (lop->lop_destroy == NULL) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; rc = lop->lop_destroy(env, handle); - RETURN(rc); + return rc; } static inline int llog_next_block(const struct lu_env *env, @@ -489,13 +489,13 @@ static inline int llog_next_block(const struct lu_env *env, rc = llog_handle2ops(loghandle, &lop); if (rc) - RETURN(rc); + return rc; if (lop->lop_next_block == NULL) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; rc = lop->lop_next_block(env, loghandle, cur_idx, next_idx, cur_offset, buf, len); - RETURN(rc); + return rc; } static inline int llog_prev_block(const struct lu_env *env, @@ -507,12 +507,12 @@ static inline int llog_prev_block(const struct lu_env *env, rc = llog_handle2ops(loghandle, &lop); if (rc) - RETURN(rc); + return rc; if (lop->lop_prev_block == NULL) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; rc = lop->lop_prev_block(env, loghandle, prev_idx, buf, len); - RETURN(rc); + return rc; } static inline int llog_connect(struct llog_ctxt *ctxt, @@ -524,12 +524,12 @@ static inline int llog_connect(struct llog_ctxt *ctxt, rc = llog_obd2ops(ctxt, &lop); if (rc) - RETURN(rc); + return rc; if (lop->lop_connect == NULL) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; rc = lop->lop_connect(ctxt, logid, gen, uuid); - RETURN(rc); + return rc; } /* llog.c */ diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index c10477f5faf51..983718fe1e550 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -326,7 +326,7 @@ void obdo_le_to_cpu(struct obdo *dobdo, struct obdo *sobdo); do { \ if (!(obd)) { \ CERROR("NULL device\n"); \ - RETURN(-ENODEV); \ + return -ENODEV; \ } \ } while (0) @@ -337,7 +337,7 @@ do { \ if (!(obd)->obd_set_up || (obd)->obd_stopping) { \ CERROR("Device %d not setup\n", \ (obd)->obd_minor); \ - RETURN(-ENODEV); \ + return -ENODEV; \ } \ } while (0) @@ -424,7 +424,7 @@ do { \ if (err) \ CERROR("md_" #op ": dev %s/%d no operation\n", \ obd->obd_name, obd->obd_minor); \ - RETURN(err); \ + return err; \ } \ } while (0) @@ -432,17 +432,17 @@ do { \ do { \ if ((exp) == NULL) { \ CERROR("obd_" #op ": NULL export\n"); \ - RETURN(-ENODEV); \ + return -ENODEV; \ } \ if ((exp)->exp_obd == NULL || !OBT((exp)->exp_obd)) { \ CERROR("obd_" #op ": cleaned up obd\n"); \ - RETURN(-EOPNOTSUPP); \ + return -EOPNOTSUPP; \ } \ if (!OBT((exp)->exp_obd) || !MDP((exp)->exp_obd, op)) { \ CERROR("obd_" #op ": dev %s/%d no operation\n", \ (exp)->exp_obd->obd_name, \ (exp)->exp_obd->obd_minor); \ - RETURN(-EOPNOTSUPP); \ + return -EOPNOTSUPP; \ } \ } while (0) @@ -453,7 +453,7 @@ do { \ if (err) \ CERROR("obd_" #op ": dev %d no operation\n", \ obd->obd_minor); \ - RETURN(err); \ + return err; \ } \ } while (0) @@ -461,16 +461,16 @@ do { \ do { \ if ((exp) == NULL) { \ CERROR("obd_" #op ": NULL export\n"); \ - RETURN(-ENODEV); \ + return -ENODEV; \ } \ if ((exp)->exp_obd == NULL || !OBT((exp)->exp_obd)) { \ CERROR("obd_" #op ": cleaned up obd\n"); \ - RETURN(-EOPNOTSUPP); \ + return -EOPNOTSUPP; \ } \ if (!OBT((exp)->exp_obd) || !OBP((exp)->exp_obd, op)) { \ CERROR("obd_" #op ": dev %d no operation\n", \ (exp)->exp_obd->obd_minor); \ - RETURN(-EOPNOTSUPP); \ + return -EOPNOTSUPP; \ } \ } while (0) @@ -480,7 +480,7 @@ do { \ if (err) \ CERROR("lop_" #op ": dev %d no operation\n", \ ctxt->loc_obd->obd_minor); \ - RETURN(err); \ + return err; \ } \ } while (0) @@ -501,7 +501,7 @@ static inline int obd_get_info(const struct lu_env *env, rc = OBP(exp->exp_obd, get_info)(env, exp, keylen, key, vallen, val, lsm); - RETURN(rc); + return rc; } static inline int obd_set_info_async(const struct lu_env *env, @@ -516,7 +516,7 @@ static inline int obd_set_info_async(const struct lu_env *env, rc = OBP(exp->exp_obd, set_info_async)(env, exp, keylen, key, vallen, val, set); - RETURN(rc); + return rc; } /* @@ -574,7 +574,7 @@ static inline int obd_setup(struct obd_device *obd, struct lustre_cfg *cfg) OBD_COUNTER_INCREMENT(obd, setup); rc = OBP(obd, setup)(obd, cfg); } - RETURN(rc); + return rc; } static inline int obd_precleanup(struct obd_device *obd, @@ -601,7 +601,7 @@ static inline int obd_precleanup(struct obd_device *obd, OBD_COUNTER_INCREMENT(obd, precleanup); rc = OBP(obd, precleanup)(obd, cleanup_stage); - RETURN(rc); + return rc; } static inline int obd_cleanup(struct obd_device *obd) @@ -627,7 +627,7 @@ static inline int obd_cleanup(struct obd_device *obd) OBD_COUNTER_INCREMENT(obd, cleanup); rc = OBP(obd, cleanup)(obd); - RETURN(rc); + return rc; } static inline void obd_cleanup_client_import(struct obd_device *obd) @@ -677,7 +677,7 @@ obd_process_config(struct obd_device *obd, int datalen, void *data) OBD_COUNTER_INCREMENT(obd, process_config); obd->obd_process_conf = 0; - RETURN(rc); + return rc; } /* Pack an in-memory MD struct for storage on disk. @@ -697,7 +697,7 @@ static inline int obd_packmd(struct obd_export *exp, EXP_COUNTER_INCREMENT(exp, packmd); rc = OBP(exp->exp_obd, packmd)(exp, disk_tgt, mem_src); - RETURN(rc); + return rc; } static inline int obd_size_diskmd(struct obd_export *exp, @@ -751,7 +751,7 @@ static inline int obd_unpackmd(struct obd_export *exp, EXP_COUNTER_INCREMENT(exp, unpackmd); rc = OBP(exp->exp_obd, unpackmd)(exp, mem_tgt, disk_src, disk_len); - RETURN(rc); + return rc; } /* helper functions */ @@ -783,7 +783,7 @@ static inline int obd_precreate(struct obd_export *exp) OBD_COUNTER_INCREMENT(exp->exp_obd, precreate); rc = OBP(exp->exp_obd, precreate)(exp); - RETURN(rc); + return rc; } static inline int obd_create_async(struct obd_export *exp, @@ -797,7 +797,7 @@ static inline int obd_create_async(struct obd_export *exp, EXP_COUNTER_INCREMENT(exp, create_async); rc = OBP(exp->exp_obd, create_async)(exp, oinfo, ea, oti); - RETURN(rc); + return rc; } static inline int obd_create(const struct lu_env *env, struct obd_export *exp, @@ -810,7 +810,7 @@ static inline int obd_create(const struct lu_env *env, struct obd_export *exp, EXP_COUNTER_INCREMENT(exp, create); rc = OBP(exp->exp_obd, create)(env, exp, obdo, ea, oti); - RETURN(rc); + return rc; } static inline int obd_destroy(const struct lu_env *env, struct obd_export *exp, @@ -824,7 +824,7 @@ static inline int obd_destroy(const struct lu_env *env, struct obd_export *exp, EXP_COUNTER_INCREMENT(exp, destroy); rc = OBP(exp->exp_obd, destroy)(env, exp, obdo, ea, oti, md_exp, capa); - RETURN(rc); + return rc; } static inline int obd_getattr(const struct lu_env *env, struct obd_export *exp, @@ -836,7 +836,7 @@ static inline int obd_getattr(const struct lu_env *env, struct obd_export *exp, EXP_COUNTER_INCREMENT(exp, getattr); rc = OBP(exp->exp_obd, getattr)(env, exp, oinfo); - RETURN(rc); + return rc; } static inline int obd_getattr_async(struct obd_export *exp, @@ -849,7 +849,7 @@ static inline int obd_getattr_async(struct obd_export *exp, EXP_COUNTER_INCREMENT(exp, getattr_async); rc = OBP(exp->exp_obd, getattr_async)(exp, oinfo, set); - RETURN(rc); + return rc; } static inline int obd_setattr(const struct lu_env *env, struct obd_export *exp, @@ -862,7 +862,7 @@ static inline int obd_setattr(const struct lu_env *env, struct obd_export *exp, EXP_COUNTER_INCREMENT(exp, setattr); rc = OBP(exp->exp_obd, setattr)(env, exp, oinfo, oti); - RETURN(rc); + return rc; } /* This performs all the requests set init/wait/destroy actions. */ @@ -878,13 +878,13 @@ static inline int obd_setattr_rqset(struct obd_export *exp, set = ptlrpc_prep_set(); if (set == NULL) - RETURN(-ENOMEM); + return -ENOMEM; rc = OBP(exp->exp_obd, setattr_async)(exp, oinfo, oti, set); if (rc == 0) rc = ptlrpc_set_wait(set); ptlrpc_set_destroy(set); - RETURN(rc); + return rc; } /* This adds all the requests into @set if @set != NULL, otherwise @@ -900,7 +900,7 @@ static inline int obd_setattr_async(struct obd_export *exp, EXP_COUNTER_INCREMENT(exp, setattr_async); rc = OBP(exp->exp_obd, setattr_async)(exp, oinfo, oti, set); - RETURN(rc); + return rc; } static inline int obd_add_conn(struct obd_import *imp, struct obd_uuid *uuid, @@ -914,7 +914,7 @@ static inline int obd_add_conn(struct obd_import *imp, struct obd_uuid *uuid, OBD_COUNTER_INCREMENT(obd, add_conn); rc = OBP(obd, add_conn)(imp, uuid, priority); - RETURN(rc); + return rc; } static inline int obd_del_conn(struct obd_import *imp, struct obd_uuid *uuid) @@ -927,7 +927,7 @@ static inline int obd_del_conn(struct obd_import *imp, struct obd_uuid *uuid) OBD_COUNTER_INCREMENT(obd, del_conn); rc = OBP(obd, del_conn)(imp, uuid); - RETURN(rc); + return rc; } static inline struct obd_uuid *obd_get_uuid(struct obd_export *exp) @@ -938,7 +938,7 @@ static inline struct obd_uuid *obd_get_uuid(struct obd_export *exp) EXP_COUNTER_INCREMENT(exp, get_uuid); uuid = OBP(exp->exp_obd, get_uuid)(exp); - RETURN(uuid); + return uuid; } /** Create a new /a exp on device /a obd for the uuid /a cluuid @@ -964,7 +964,7 @@ static inline int obd_connect(const struct lu_env *env, /* check that only subset is granted */ LASSERT(ergo(data != NULL, (data->ocd_connect_flags & ocf) == data->ocd_connect_flags)); - RETURN(rc); + return rc; } static inline int obd_reconnect(const struct lu_env *env, @@ -986,7 +986,7 @@ static inline int obd_reconnect(const struct lu_env *env, /* check that only subset is granted */ LASSERT(ergo(d != NULL, (d->ocd_connect_flags & ocf) == d->ocd_connect_flags)); - RETURN(rc); + return rc; } static inline int obd_disconnect(struct obd_export *exp) @@ -997,7 +997,7 @@ static inline int obd_disconnect(struct obd_export *exp) EXP_COUNTER_INCREMENT(exp, disconnect); rc = OBP(exp->exp_obd, disconnect)(exp); - RETURN(rc); + return rc; } static inline int obd_fid_init(struct obd_device *obd, struct obd_export *exp, @@ -1009,7 +1009,7 @@ static inline int obd_fid_init(struct obd_device *obd, struct obd_export *exp, OBD_COUNTER_INCREMENT(obd, fid_init); rc = OBP(obd, fid_init)(obd, exp, type); - RETURN(rc); + return rc; } static inline int obd_fid_fini(struct obd_device *obd) @@ -1020,7 +1020,7 @@ static inline int obd_fid_fini(struct obd_device *obd) OBD_COUNTER_INCREMENT(obd, fid_fini); rc = OBP(obd, fid_fini)(obd); - RETURN(rc); + return rc; } static inline int obd_fid_alloc(struct obd_export *exp, @@ -1033,7 +1033,7 @@ static inline int obd_fid_alloc(struct obd_export *exp, EXP_COUNTER_INCREMENT(exp, fid_alloc); rc = OBP(exp->exp_obd, fid_alloc)(exp, fid, op_data); - RETURN(rc); + return rc; } static inline int obd_ping(const struct lu_env *env, struct obd_export *exp) @@ -1044,7 +1044,7 @@ static inline int obd_ping(const struct lu_env *env, struct obd_export *exp) EXP_COUNTER_INCREMENT(exp, ping); rc = OBP(exp->exp_obd, ping)(env, exp); - RETURN(rc); + return rc; } static inline int obd_pool_new(struct obd_device *obd, char *poolname) @@ -1055,7 +1055,7 @@ static inline int obd_pool_new(struct obd_device *obd, char *poolname) OBD_COUNTER_INCREMENT(obd, pool_new); rc = OBP(obd, pool_new)(obd, poolname); - RETURN(rc); + return rc; } static inline int obd_pool_del(struct obd_device *obd, char *poolname) @@ -1066,7 +1066,7 @@ static inline int obd_pool_del(struct obd_device *obd, char *poolname) OBD_COUNTER_INCREMENT(obd, pool_del); rc = OBP(obd, pool_del)(obd, poolname); - RETURN(rc); + return rc; } static inline int obd_pool_add(struct obd_device *obd, char *poolname, char *ostname) @@ -1077,7 +1077,7 @@ static inline int obd_pool_add(struct obd_device *obd, char *poolname, char *ost OBD_COUNTER_INCREMENT(obd, pool_add); rc = OBP(obd, pool_add)(obd, poolname, ostname); - RETURN(rc); + return rc; } static inline int obd_pool_rem(struct obd_device *obd, char *poolname, char *ostname) @@ -1088,7 +1088,7 @@ static inline int obd_pool_rem(struct obd_device *obd, char *poolname, char *ost OBD_COUNTER_INCREMENT(obd, pool_rem); rc = OBP(obd, pool_rem)(obd, poolname, ostname); - RETURN(rc); + return rc; } static inline void obd_getref(struct obd_device *obd) @@ -1114,7 +1114,7 @@ static inline int obd_init_export(struct obd_export *exp) if ((exp)->exp_obd != NULL && OBT((exp)->exp_obd) && OBP((exp)->exp_obd, init_export)) rc = OBP(exp->exp_obd, init_export)(exp); - RETURN(rc); + return rc; } static inline int obd_destroy_export(struct obd_export *exp) @@ -1122,7 +1122,7 @@ static inline int obd_destroy_export(struct obd_export *exp) if ((exp)->exp_obd != NULL && OBT((exp)->exp_obd) && OBP((exp)->exp_obd, destroy_export)) OBP(exp->exp_obd, destroy_export)(exp); - RETURN(0); + return 0; } static inline int obd_extent_calc(struct obd_export *exp, @@ -1133,7 +1133,7 @@ static inline int obd_extent_calc(struct obd_export *exp, EXP_CHECK_DT_OP(exp, extent_calc); rc = OBP(exp->exp_obd, extent_calc)(exp, md, cmd, offset); - RETURN(rc); + return rc; } static inline struct dentry * @@ -1158,7 +1158,7 @@ static inline int obd_statfs_async(struct obd_export *exp, struct obd_device *obd; if (exp == NULL || exp->exp_obd == NULL) - RETURN(-EINVAL); + return -EINVAL; obd = exp->exp_obd; OBD_CHECK_DT_OP(obd, statfs, -EOPNOTSUPP); @@ -1181,7 +1181,7 @@ static inline int obd_statfs_async(struct obd_export *exp, if (oinfo->oi_cb_up) oinfo->oi_cb_up(oinfo, 0); } - RETURN(rc); + return rc; } static inline int obd_statfs_rqset(struct obd_export *exp, @@ -1194,7 +1194,7 @@ static inline int obd_statfs_rqset(struct obd_export *exp, set = ptlrpc_prep_set(); if (set == NULL) - RETURN(-ENOMEM); + return -ENOMEM; oinfo.oi_osfs = osfs; oinfo.oi_flags = flags; @@ -1202,7 +1202,7 @@ static inline int obd_statfs_rqset(struct obd_export *exp, if (rc == 0) rc = ptlrpc_set_wait(set); ptlrpc_set_destroy(set); - RETURN(rc); + return rc; } /* @max_age is the oldest time in jiffies that we accept using a cached data. @@ -1216,7 +1216,7 @@ static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp, struct obd_device *obd = exp->exp_obd; if (obd == NULL) - RETURN(-EINVAL); + return -EINVAL; OBD_CHECK_DT_OP(obd, statfs, -EOPNOTSUPP); OBD_COUNTER_INCREMENT(obd, statfs); @@ -1241,7 +1241,7 @@ static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp, memcpy(osfs, &obd->obd_osfs, sizeof(*osfs)); spin_unlock(&obd->obd_osfs_lock); } - RETURN(rc); + return rc; } static inline int obd_sync_rqset(struct obd_export *exp, struct obd_info *oinfo, @@ -1255,13 +1255,13 @@ static inline int obd_sync_rqset(struct obd_export *exp, struct obd_info *oinfo, set = ptlrpc_prep_set(); if (set == NULL) - RETURN(-ENOMEM); + return -ENOMEM; rc = OBP(exp->exp_obd, sync)(NULL, exp, oinfo, start, end, set); if (rc == 0) rc = ptlrpc_set_wait(set); ptlrpc_set_destroy(set); - RETURN(rc); + return rc; } static inline int obd_sync(const struct lu_env *env, struct obd_export *exp, @@ -1274,7 +1274,7 @@ static inline int obd_sync(const struct lu_env *env, struct obd_export *exp, EXP_COUNTER_INCREMENT(exp, sync); rc = OBP(exp->exp_obd, sync)(env, exp, oinfo, start, end, set); - RETURN(rc); + return rc; } static inline int obd_punch_rqset(struct obd_export *exp, @@ -1289,13 +1289,13 @@ static inline int obd_punch_rqset(struct obd_export *exp, set = ptlrpc_prep_set(); if (set == NULL) - RETURN(-ENOMEM); + return -ENOMEM; rc = OBP(exp->exp_obd, punch)(NULL, exp, oinfo, oti, set); if (rc == 0) rc = ptlrpc_set_wait(set); ptlrpc_set_destroy(set); - RETURN(rc); + return rc; } static inline int obd_punch(const struct lu_env *env, struct obd_export *exp, @@ -1308,7 +1308,7 @@ static inline int obd_punch(const struct lu_env *env, struct obd_export *exp, EXP_COUNTER_INCREMENT(exp, punch); rc = OBP(exp->exp_obd, punch)(env, exp, oinfo, oti, rqset); - RETURN(rc); + return rc; } static inline int obd_brw(int cmd, struct obd_export *exp, @@ -1327,7 +1327,7 @@ static inline int obd_brw(int cmd, struct obd_export *exp, } rc = OBP(exp->exp_obd, brw)(cmd, exp, oinfo, oa_bufs, pg, oti); - RETURN(rc); + return rc; } static inline int obd_preprw(const struct lu_env *env, int cmd, @@ -1345,7 +1345,7 @@ static inline int obd_preprw(const struct lu_env *env, int cmd, rc = OBP(exp->exp_obd, preprw)(env, cmd, exp, oa, objcount, obj, remote, pages, local, oti, capa); - RETURN(rc); + return rc; } static inline int obd_commitrw(const struct lu_env *env, int cmd, @@ -1360,7 +1360,7 @@ static inline int obd_commitrw(const struct lu_env *env, int cmd, rc = OBP(exp->exp_obd, commitrw)(env, cmd, exp, oa, objcount, obj, rnb, pages, local, oti, rc); - RETURN(rc); + return rc; } static inline int obd_merge_lvb(struct obd_export *exp, @@ -1373,7 +1373,7 @@ static inline int obd_merge_lvb(struct obd_export *exp, EXP_COUNTER_INCREMENT(exp, merge_lvb); rc = OBP(exp->exp_obd, merge_lvb)(exp, lsm, lvb, kms_only); - RETURN(rc); + return rc; } static inline int obd_adjust_kms(struct obd_export *exp, @@ -1386,7 +1386,7 @@ static inline int obd_adjust_kms(struct obd_export *exp, EXP_COUNTER_INCREMENT(exp, adjust_kms); rc = OBP(exp->exp_obd, adjust_kms)(exp, lsm, size, shrink); - RETURN(rc); + return rc; } static inline int obd_iocontrol(unsigned int cmd, struct obd_export *exp, @@ -1398,7 +1398,7 @@ static inline int obd_iocontrol(unsigned int cmd, struct obd_export *exp, EXP_COUNTER_INCREMENT(exp, iocontrol); rc = OBP(exp->exp_obd, iocontrol)(cmd, exp, len, karg, uarg); - RETURN(rc); + return rc; } static inline int obd_enqueue_rqset(struct obd_export *exp, @@ -1413,13 +1413,13 @@ static inline int obd_enqueue_rqset(struct obd_export *exp, set = ptlrpc_prep_set(); if (set == NULL) - RETURN(-ENOMEM); + return -ENOMEM; rc = OBP(exp->exp_obd, enqueue)(exp, oinfo, einfo, set); if (rc == 0) rc = ptlrpc_set_wait(set); ptlrpc_set_destroy(set); - RETURN(rc); + return rc; } static inline int obd_enqueue(struct obd_export *exp, @@ -1433,7 +1433,7 @@ static inline int obd_enqueue(struct obd_export *exp, EXP_COUNTER_INCREMENT(exp, enqueue); rc = OBP(exp->exp_obd, enqueue)(exp, oinfo, einfo, set); - RETURN(rc); + return rc; } static inline int obd_change_cbdata(struct obd_export *exp, @@ -1446,7 +1446,7 @@ static inline int obd_change_cbdata(struct obd_export *exp, EXP_COUNTER_INCREMENT(exp, change_cbdata); rc = OBP(exp->exp_obd, change_cbdata)(exp, lsm, it, data); - RETURN(rc); + return rc; } static inline int obd_find_cbdata(struct obd_export *exp, @@ -1459,7 +1459,7 @@ static inline int obd_find_cbdata(struct obd_export *exp, EXP_COUNTER_INCREMENT(exp, find_cbdata); rc = OBP(exp->exp_obd, find_cbdata)(exp, lsm, it, data); - RETURN(rc); + return rc; } static inline int obd_cancel(struct obd_export *exp, @@ -1472,7 +1472,7 @@ static inline int obd_cancel(struct obd_export *exp, EXP_COUNTER_INCREMENT(exp, cancel); rc = OBP(exp->exp_obd, cancel)(exp, ea, mode, lockh); - RETURN(rc); + return rc; } static inline int obd_cancel_unused(struct obd_export *exp, @@ -1486,7 +1486,7 @@ static inline int obd_cancel_unused(struct obd_export *exp, EXP_COUNTER_INCREMENT(exp, cancel_unused); rc = OBP(exp->exp_obd, cancel_unused)(exp, ea, flags, opaque); - RETURN(rc); + return rc; } static inline int obd_pin(struct obd_export *exp, const struct lu_fid *fid, @@ -1499,7 +1499,7 @@ static inline int obd_pin(struct obd_export *exp, const struct lu_fid *fid, EXP_COUNTER_INCREMENT(exp, pin); rc = OBP(exp->exp_obd, pin)(exp, fid, oc, handle, flag); - RETURN(rc); + return rc; } static inline int obd_unpin(struct obd_export *exp, @@ -1511,7 +1511,7 @@ static inline int obd_unpin(struct obd_export *exp, EXP_COUNTER_INCREMENT(exp, unpin); rc = OBP(exp->exp_obd, unpin)(exp, handle, flag); - RETURN(rc); + return rc; } @@ -1538,7 +1538,7 @@ static inline int obd_llog_connect(struct obd_export *exp, EXP_COUNTER_INCREMENT(exp, llog_connect); rc = OBP(exp->exp_obd, llog_connect)(exp, body); - RETURN(rc); + return rc; } @@ -1557,17 +1557,17 @@ static inline int obd_notify(struct obd_device *obd, by this point, and it needs to get them to execute mds_postrecov. */ if (!obd->obd_set_up && !obd->obd_async_recov) { CDEBUG(D_HA, "obd %s not set up\n", obd->obd_name); - RETURN(-EINVAL); + return -EINVAL; } if (!OBP(obd, notify)) { CDEBUG(D_HA, "obd %s has no notify handler\n", obd->obd_name); - RETURN(-ENOSYS); + return -ENOSYS; } OBD_COUNTER_INCREMENT(obd, notify); rc = OBP(obd, notify)(obd, watched, ev, data); - RETURN(rc); + return rc; } static inline int obd_notify_observer(struct obd_device *observer, @@ -1606,7 +1606,7 @@ static inline int obd_quotacheck(struct obd_export *exp, EXP_COUNTER_INCREMENT(exp, quotacheck); rc = OBP(exp->exp_obd, quotacheck)(exp->exp_obd, exp, oqctl); - RETURN(rc); + return rc; } static inline int obd_quotactl(struct obd_export *exp, @@ -1618,7 +1618,7 @@ static inline int obd_quotactl(struct obd_export *exp, EXP_COUNTER_INCREMENT(exp, quotactl); rc = OBP(exp->exp_obd, quotactl)(exp->exp_obd, exp, oqctl); - RETURN(rc); + return rc; } static inline int obd_health_check(const struct lu_env *env, @@ -1636,15 +1636,15 @@ static inline int obd_health_check(const struct lu_env *env, /* don't use EXP_CHECK_DT_OP, because NULL method is normal here */ if (obd == NULL || !OBT(obd)) { CERROR("cleaned up obd\n"); - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; } if (!obd->obd_set_up || obd->obd_stopping) - RETURN(0); + return 0; if (!OBP(obd, health_check)) - RETURN(0); + return 0; rc = OBP(obd, health_check)(env, obd); - RETURN(rc); + return rc; } static inline int obd_register_observer(struct obd_device *obd, @@ -1654,11 +1654,11 @@ static inline int obd_register_observer(struct obd_device *obd, down_write(&obd->obd_observer_link_sem); if (obd->obd_observer && observer) { up_write(&obd->obd_observer_link_sem); - RETURN(-EALREADY); + return -EALREADY; } obd->obd_observer = observer; up_write(&obd->obd_observer_link_sem); - RETURN(0); + return 0; } static inline int obd_pin_observer(struct obd_device *obd, @@ -1668,16 +1668,16 @@ static inline int obd_pin_observer(struct obd_device *obd, if (!obd->obd_observer) { *observer = NULL; up_read(&obd->obd_observer_link_sem); - RETURN(-ENOENT); + return -ENOENT; } *observer = obd->obd_observer; - RETURN(0); + return 0; } static inline int obd_unpin_observer(struct obd_device *obd) { up_read(&obd->obd_observer_link_sem); - RETURN(0); + return 0; } #if 0 @@ -1691,7 +1691,7 @@ static inline int obd_register_page_removal_cb(struct obd_export *exp, OBD_COUNTER_INCREMENT(exp->exp_obd, register_page_removal_cb); rc = OBP(exp->exp_obd, register_page_removal_cb)(exp, cb, pin_cb); - RETURN(rc); + return rc; } static inline int obd_unregister_page_removal_cb(struct obd_export *exp, @@ -1703,7 +1703,7 @@ static inline int obd_unregister_page_removal_cb(struct obd_export *exp, OBD_COUNTER_INCREMENT(exp->exp_obd, unregister_page_removal_cb); rc = OBP(exp->exp_obd, unregister_page_removal_cb)(exp, cb); - RETURN(rc); + return rc; } static inline int obd_register_lock_cancel_cb(struct obd_export *exp, @@ -1715,7 +1715,7 @@ static inline int obd_register_lock_cancel_cb(struct obd_export *exp, OBD_COUNTER_INCREMENT(exp->exp_obd, register_lock_cancel_cb); rc = OBP(exp->exp_obd, register_lock_cancel_cb)(exp, cb); - RETURN(rc); + return rc; } static inline int obd_unregister_lock_cancel_cb(struct obd_export *exp, @@ -1727,7 +1727,7 @@ static inline int obd_unregister_lock_cancel_cb(struct obd_export *exp, OBD_COUNTER_INCREMENT(exp->exp_obd, unregister_lock_cancel_cb); rc = OBP(exp->exp_obd, unregister_lock_cancel_cb)(exp, cb); - RETURN(rc); + return rc; } #endif @@ -1740,7 +1740,7 @@ static inline int md_getstatus(struct obd_export *exp, EXP_CHECK_MD_OP(exp, getstatus); EXP_MD_COUNTER_INCREMENT(exp, getstatus); rc = MDP(exp->exp_obd, getstatus)(exp, fid, pc); - RETURN(rc); + return rc; } static inline int md_getattr(struct obd_export *exp, struct md_op_data *op_data, @@ -1751,7 +1751,7 @@ static inline int md_getattr(struct obd_export *exp, struct md_op_data *op_data, EXP_CHECK_MD_OP(exp, getattr); EXP_MD_COUNTER_INCREMENT(exp, getattr); rc = MDP(exp->exp_obd, getattr)(exp, op_data, request); - RETURN(rc); + return rc; } static inline int md_null_inode(struct obd_export *exp, @@ -1762,7 +1762,7 @@ static inline int md_null_inode(struct obd_export *exp, EXP_CHECK_MD_OP(exp, null_inode); EXP_MD_COUNTER_INCREMENT(exp, null_inode); rc = MDP(exp->exp_obd, null_inode)(exp, fid); - RETURN(rc); + return rc; } static inline int md_find_cbdata(struct obd_export *exp, @@ -1774,7 +1774,7 @@ static inline int md_find_cbdata(struct obd_export *exp, EXP_CHECK_MD_OP(exp, find_cbdata); EXP_MD_COUNTER_INCREMENT(exp, find_cbdata); rc = MDP(exp->exp_obd, find_cbdata)(exp, fid, it, data); - RETURN(rc); + return rc; } static inline int md_close(struct obd_export *exp, struct md_op_data *op_data, @@ -1786,7 +1786,7 @@ static inline int md_close(struct obd_export *exp, struct md_op_data *op_data, EXP_CHECK_MD_OP(exp, close); EXP_MD_COUNTER_INCREMENT(exp, close); rc = MDP(exp->exp_obd, close)(exp, op_data, mod, request); - RETURN(rc); + return rc; } static inline int md_create(struct obd_export *exp, struct md_op_data *op_data, @@ -1800,7 +1800,7 @@ static inline int md_create(struct obd_export *exp, struct md_op_data *op_data, EXP_MD_COUNTER_INCREMENT(exp, create); rc = MDP(exp->exp_obd, create)(exp, op_data, data, datalen, mode, uid, gid, cap_effective, rdev, request); - RETURN(rc); + return rc; } static inline int md_done_writing(struct obd_export *exp, @@ -1812,7 +1812,7 @@ static inline int md_done_writing(struct obd_export *exp, EXP_CHECK_MD_OP(exp, done_writing); EXP_MD_COUNTER_INCREMENT(exp, done_writing); rc = MDP(exp->exp_obd, done_writing)(exp, op_data, mod); - RETURN(rc); + return rc; } static inline int md_enqueue(struct obd_export *exp, @@ -1830,7 +1830,7 @@ static inline int md_enqueue(struct obd_export *exp, EXP_MD_COUNTER_INCREMENT(exp, enqueue); rc = MDP(exp->exp_obd, enqueue)(exp, einfo, it, op_data, lockh, lmm, lmmsize, req, extra_lock_flags); - RETURN(rc); + return rc; } static inline int md_getattr_name(struct obd_export *exp, @@ -1842,7 +1842,7 @@ static inline int md_getattr_name(struct obd_export *exp, EXP_CHECK_MD_OP(exp, getattr_name); EXP_MD_COUNTER_INCREMENT(exp, getattr_name); rc = MDP(exp->exp_obd, getattr_name)(exp, op_data, request); - RETURN(rc); + return rc; } static inline int md_intent_lock(struct obd_export *exp, @@ -1859,7 +1859,7 @@ static inline int md_intent_lock(struct obd_export *exp, rc = MDP(exp->exp_obd, intent_lock)(exp, op_data, lmm, lmmsize, it, lookup_flags, reqp, cb_blocking, extra_lock_flags); - RETURN(rc); + return rc; } static inline int md_link(struct obd_export *exp, struct md_op_data *op_data, @@ -1870,7 +1870,7 @@ static inline int md_link(struct obd_export *exp, struct md_op_data *op_data, EXP_CHECK_MD_OP(exp, link); EXP_MD_COUNTER_INCREMENT(exp, link); rc = MDP(exp->exp_obd, link)(exp, op_data, request); - RETURN(rc); + return rc; } static inline int md_rename(struct obd_export *exp, struct md_op_data *op_data, @@ -1883,7 +1883,7 @@ static inline int md_rename(struct obd_export *exp, struct md_op_data *op_data, EXP_MD_COUNTER_INCREMENT(exp, rename); rc = MDP(exp->exp_obd, rename)(exp, op_data, old, oldlen, new, newlen, request); - RETURN(rc); + return rc; } static inline int md_is_subdir(struct obd_export *exp, @@ -1896,7 +1896,7 @@ static inline int md_is_subdir(struct obd_export *exp, EXP_CHECK_MD_OP(exp, is_subdir); EXP_MD_COUNTER_INCREMENT(exp, is_subdir); rc = MDP(exp->exp_obd, is_subdir)(exp, pfid, cfid, request); - RETURN(rc); + return rc; } static inline int md_setattr(struct obd_export *exp, struct md_op_data *op_data, @@ -1910,7 +1910,7 @@ static inline int md_setattr(struct obd_export *exp, struct md_op_data *op_data, EXP_MD_COUNTER_INCREMENT(exp, setattr); rc = MDP(exp->exp_obd, setattr)(exp, op_data, ea, ealen, ea2, ea2len, request, mod); - RETURN(rc); + return rc; } static inline int md_sync(struct obd_export *exp, const struct lu_fid *fid, @@ -1921,7 +1921,7 @@ static inline int md_sync(struct obd_export *exp, const struct lu_fid *fid, EXP_CHECK_MD_OP(exp, sync); EXP_MD_COUNTER_INCREMENT(exp, sync); rc = MDP(exp->exp_obd, sync)(exp, fid, oc, request); - RETURN(rc); + return rc; } static inline int md_readpage(struct obd_export *exp, struct md_op_data *opdata, @@ -1933,7 +1933,7 @@ static inline int md_readpage(struct obd_export *exp, struct md_op_data *opdata, EXP_CHECK_MD_OP(exp, readpage); EXP_MD_COUNTER_INCREMENT(exp, readpage); rc = MDP(exp->exp_obd, readpage)(exp, opdata, pages, request); - RETURN(rc); + return rc; } static inline int md_unlink(struct obd_export *exp, struct md_op_data *op_data, @@ -1944,7 +1944,7 @@ static inline int md_unlink(struct obd_export *exp, struct md_op_data *op_data, EXP_CHECK_MD_OP(exp, unlink); EXP_MD_COUNTER_INCREMENT(exp, unlink); rc = MDP(exp->exp_obd, unlink)(exp, op_data, request); - RETURN(rc); + return rc; } static inline int md_get_lustre_md(struct obd_export *exp, @@ -1955,7 +1955,7 @@ static inline int md_get_lustre_md(struct obd_export *exp, { EXP_CHECK_MD_OP(exp, get_lustre_md); EXP_MD_COUNTER_INCREMENT(exp, get_lustre_md); - RETURN(MDP(exp->exp_obd, get_lustre_md)(exp, req, dt_exp, md_exp, md)); + return MDP(exp->exp_obd, get_lustre_md)(exp, req, dt_exp, md_exp, md); } static inline int md_free_lustre_md(struct obd_export *exp, @@ -1963,7 +1963,7 @@ static inline int md_free_lustre_md(struct obd_export *exp, { EXP_CHECK_MD_OP(exp, free_lustre_md); EXP_MD_COUNTER_INCREMENT(exp, free_lustre_md); - RETURN(MDP(exp->exp_obd, free_lustre_md)(exp, md)); + return MDP(exp->exp_obd, free_lustre_md)(exp, md); } static inline int md_setxattr(struct obd_export *exp, @@ -1975,9 +1975,9 @@ static inline int md_setxattr(struct obd_export *exp, { EXP_CHECK_MD_OP(exp, setxattr); EXP_MD_COUNTER_INCREMENT(exp, setxattr); - RETURN(MDP(exp->exp_obd, setxattr)(exp, fid, oc, valid, name, input, + return MDP(exp->exp_obd, setxattr)(exp, fid, oc, valid, name, input, input_size, output_size, flags, - suppgid, request)); + suppgid, request); } static inline int md_getxattr(struct obd_export *exp, @@ -1989,9 +1989,9 @@ static inline int md_getxattr(struct obd_export *exp, { EXP_CHECK_MD_OP(exp, getxattr); EXP_MD_COUNTER_INCREMENT(exp, getxattr); - RETURN(MDP(exp->exp_obd, getxattr)(exp, fid, oc, valid, name, input, + return MDP(exp->exp_obd, getxattr)(exp, fid, oc, valid, name, input, input_size, output_size, flags, - request)); + request); } static inline int md_set_open_replay_data(struct obd_export *exp, @@ -2000,7 +2000,7 @@ static inline int md_set_open_replay_data(struct obd_export *exp, { EXP_CHECK_MD_OP(exp, set_open_replay_data); EXP_MD_COUNTER_INCREMENT(exp, set_open_replay_data); - RETURN(MDP(exp->exp_obd, set_open_replay_data)(exp, och, open_req)); + return MDP(exp->exp_obd, set_open_replay_data)(exp, och, open_req); } static inline int md_clear_open_replay_data(struct obd_export *exp, @@ -2008,7 +2008,7 @@ static inline int md_clear_open_replay_data(struct obd_export *exp, { EXP_CHECK_MD_OP(exp, clear_open_replay_data); EXP_MD_COUNTER_INCREMENT(exp, clear_open_replay_data); - RETURN(MDP(exp->exp_obd, clear_open_replay_data)(exp, och)); + return MDP(exp->exp_obd, clear_open_replay_data)(exp, och); } static inline int md_set_lock_data(struct obd_export *exp, @@ -2016,7 +2016,7 @@ static inline int md_set_lock_data(struct obd_export *exp, { EXP_CHECK_MD_OP(exp, set_lock_data); EXP_MD_COUNTER_INCREMENT(exp, set_lock_data); - RETURN(MDP(exp->exp_obd, set_lock_data)(exp, lockh, data, bits)); + return MDP(exp->exp_obd, set_lock_data)(exp, lockh, data, bits); } static inline int md_cancel_unused(struct obd_export *exp, @@ -2033,7 +2033,7 @@ static inline int md_cancel_unused(struct obd_export *exp, rc = MDP(exp->exp_obd, cancel_unused)(exp, fid, policy, mode, flags, opaque); - RETURN(rc); + return rc; } static inline ldlm_mode_t md_lock_match(struct obd_export *exp, __u64 flags, @@ -2045,8 +2045,8 @@ static inline ldlm_mode_t md_lock_match(struct obd_export *exp, __u64 flags, { EXP_CHECK_MD_OP(exp, lock_match); EXP_MD_COUNTER_INCREMENT(exp, lock_match); - RETURN(MDP(exp->exp_obd, lock_match)(exp, flags, fid, type, - policy, mode, lockh)); + return MDP(exp->exp_obd, lock_match)(exp, flags, fid, type, + policy, mode, lockh); } static inline int md_init_ea_size(struct obd_export *exp, int easize, @@ -2054,8 +2054,8 @@ static inline int md_init_ea_size(struct obd_export *exp, int easize, { EXP_CHECK_MD_OP(exp, init_ea_size); EXP_MD_COUNTER_INCREMENT(exp, init_ea_size); - RETURN(MDP(exp->exp_obd, init_ea_size)(exp, easize, def_asize, - cookiesize)); + return MDP(exp->exp_obd, init_ea_size)(exp, easize, def_asize, + cookiesize); } static inline int md_get_remote_perm(struct obd_export *exp, @@ -2065,8 +2065,8 @@ static inline int md_get_remote_perm(struct obd_export *exp, { EXP_CHECK_MD_OP(exp, get_remote_perm); EXP_MD_COUNTER_INCREMENT(exp, get_remote_perm); - RETURN(MDP(exp->exp_obd, get_remote_perm)(exp, fid, oc, suppgid, - request)); + return MDP(exp->exp_obd, get_remote_perm)(exp, fid, oc, suppgid, + request); } static inline int md_renew_capa(struct obd_export *exp, struct obd_capa *ocapa, @@ -2077,7 +2077,7 @@ static inline int md_renew_capa(struct obd_export *exp, struct obd_capa *ocapa, EXP_CHECK_MD_OP(exp, renew_capa); EXP_MD_COUNTER_INCREMENT(exp, renew_capa); rc = MDP(exp->exp_obd, renew_capa)(exp, ocapa, cb); - RETURN(rc); + return rc; } static inline int md_unpack_capa(struct obd_export *exp, @@ -2090,7 +2090,7 @@ static inline int md_unpack_capa(struct obd_export *exp, EXP_CHECK_MD_OP(exp, unpack_capa); EXP_MD_COUNTER_INCREMENT(exp, unpack_capa); rc = MDP(exp->exp_obd, unpack_capa)(exp, req, field, oc); - RETURN(rc); + return rc; } static inline int md_intent_getattr_async(struct obd_export *exp, @@ -2102,7 +2102,7 @@ static inline int md_intent_getattr_async(struct obd_export *exp, EXP_CHECK_MD_OP(exp, intent_getattr_async); EXP_MD_COUNTER_INCREMENT(exp, intent_getattr_async); rc = MDP(exp->exp_obd, intent_getattr_async)(exp, minfo, einfo); - RETURN(rc); + return rc; } static inline int md_revalidate_lock(struct obd_export *exp, @@ -2114,7 +2114,7 @@ static inline int md_revalidate_lock(struct obd_export *exp, EXP_CHECK_MD_OP(exp, revalidate_lock); EXP_MD_COUNTER_INCREMENT(exp, revalidate_lock); rc = MDP(exp->exp_obd, revalidate_lock)(exp, it, fid, bits); - RETURN(rc); + return rc; } diff --git a/drivers/staging/lustre/lustre/lclient/glimpse.c b/drivers/staging/lustre/lustre/lclient/glimpse.c index db72d89573b66..7bbca4bf6b82a 100644 --- a/drivers/staging/lustre/lustre/lclient/glimpse.c +++ b/drivers/staging/lustre/lustre/lclient/glimpse.c @@ -130,10 +130,10 @@ int cl_glimpse_lock(const struct lu_env *env, struct cl_io *io, cio->cui_glimpse = 0; if (lock == NULL) - RETURN(0); + return 0; if (IS_ERR(lock)) - RETURN(PTR_ERR(lock)); + return PTR_ERR(lock); LASSERT(agl == 0); result = cl_wait(env, lock); @@ -158,7 +158,7 @@ int cl_glimpse_lock(const struct lu_env *env, struct cl_io *io, } } - RETURN(result); + return result; } static int cl_io_get(struct inode *inode, struct lu_env **envout, @@ -223,7 +223,7 @@ int cl_glimpse_size0(struct inode *inode, int agl) goto again; cl_env_put(env, &refcheck); } - RETURN(result); + return result; } int cl_local_size(struct inode *inode) @@ -238,11 +238,11 @@ int cl_local_size(struct inode *inode) int refcheck; if (!cl_i2info(inode)->lli_has_smd) - RETURN(0); + return 0; result = cl_io_get(inode, &env, &io, &refcheck); if (result <= 0) - RETURN(result); + return result; clob = io->ci_obj; result = cl_io_init(env, io, CIT_MISC, clob); @@ -265,5 +265,5 @@ int cl_local_size(struct inode *inode) } cl_io_fini(env, io); cl_env_put(env, &refcheck); - RETURN(result); + return result; } diff --git a/drivers/staging/lustre/lustre/lclient/lcommon_cl.c b/drivers/staging/lustre/lustre/lclient/lcommon_cl.c index 41168c2cbdf64..8ff38c64b7a1f 100644 --- a/drivers/staging/lustre/lustre/lclient/lcommon_cl.c +++ b/drivers/staging/lustre/lustre/lclient/lcommon_cl.c @@ -181,7 +181,7 @@ int ccc_device_init(const struct lu_env *env, struct lu_device *d, lu_device_get(next); lu_ref_add(&next->ld_reference, "lu-stack", &lu_site_init); } - RETURN(rc); + return rc; } struct lu_device *ccc_device_fini(const struct lu_env *env, @@ -203,7 +203,7 @@ struct lu_device *ccc_device_alloc(const struct lu_env *env, OBD_ALLOC_PTR(vdv); if (vdv == NULL) - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); lud = &vdv->cdv_cl.cd_lu_dev; cl_device_init(&vdv->cdv_cl, t); @@ -226,7 +226,7 @@ struct lu_device *ccc_device_alloc(const struct lu_env *env, ccc_device_free(env, lud); lud = ERR_PTR(rc); } - RETURN(lud); + return lud; } struct lu_device *ccc_device_free(const struct lu_env *env, @@ -426,7 +426,7 @@ int ccc_object_glimpse(const struct lu_env *env, */ if (lvb->lvb_size > 0 && lvb->lvb_blocks == 0) lvb->lvb_blocks = dirty_cnt(inode); - RETURN(0); + return 0; } @@ -490,7 +490,7 @@ int ccc_page_is_under_lock(const struct lu_env *env, } } else result = 0; - RETURN(result); + return result; } int ccc_fail(const struct lu_env *env, const struct cl_page_slice *slice) @@ -555,7 +555,7 @@ int ccc_transient_page_prep(const struct lu_env *env, struct cl_io *unused) { /* transient page should always be sent. */ - RETURN(0); + return 0; } /***************************************************************************** @@ -635,7 +635,7 @@ int ccc_lock_fits_into(const struct lu_env *env, result = lock->cll_state >= CLS_ENQUEUED; else result = 1; - RETURN(result); + return result; } /** @@ -715,7 +715,7 @@ int ccc_io_one_lock_index(const struct lu_env *env, struct cl_io *io, descr->cld_enq_flags = enqflags; cl_io_lock_add(env, io, &cio->cui_link); - RETURN(0); + return 0; } void ccc_io_update_iov(const struct lu_env *env, @@ -978,7 +978,7 @@ int cl_setattr_ost(struct inode *inode, const struct iattr *attr, env = cl_env_get(&refcheck); if (IS_ERR(env)) - RETURN(PTR_ERR(env)); + return PTR_ERR(env); io = ccc_env_thread_io(env); io->ci_obj = cl_i2info(inode)->lli_clob; @@ -1007,7 +1007,7 @@ int cl_setattr_ost(struct inode *inode, const struct iattr *attr, if (unlikely(io->ci_need_restart)) goto again; cl_env_put(env, &refcheck); - RETURN(result); + return result; } /***************************************************************************** @@ -1272,9 +1272,9 @@ __u16 ll_dirent_type_get(struct lu_dirent *ent) __u64 cl_fid_build_ino(const struct lu_fid *fid, int api32) { if (BITS_PER_LONG == 32 || api32) - RETURN(fid_flatten32(fid)); + return fid_flatten32(fid); else - RETURN(fid_flatten(fid)); + return fid_flatten(fid); } /** @@ -1286,11 +1286,11 @@ __u32 cl_fid_build_gen(const struct lu_fid *fid) if (fid_is_igif(fid)) { gen = lu_igif_gen(fid); - RETURN(gen); + return gen; } gen = (fid_flatten(fid) >> 32); - RETURN(gen); + return gen; } /* lsm is unreliable after hsm implementation as layout can be changed at diff --git a/drivers/staging/lustre/lustre/lclient/lcommon_misc.c b/drivers/staging/lustre/lustre/lclient/lcommon_misc.c index d59a7a94e3529..2b4dbeebcd5d6 100644 --- a/drivers/staging/lustre/lustre/lclient/lcommon_misc.c +++ b/drivers/staging/lustre/lustre/lclient/lcommon_misc.c @@ -61,7 +61,7 @@ int cl_init_ea_size(struct obd_export *md_exp, struct obd_export *dt_exp) rc = obd_get_info(NULL, dt_exp, sizeof(KEY_LOVDESC), KEY_LOVDESC, &valsize, &desc, NULL); if (rc) - RETURN(rc); + return rc; stripes = min(desc.ld_tgt_count, (__u32)LOV_MAX_STRIPE_COUNT); lsm.lsm_stripe_count = stripes; @@ -76,7 +76,7 @@ int cl_init_ea_size(struct obd_export *md_exp, struct obd_export *dt_exp) easize, cookiesize); rc = md_init_ea_size(md_exp, easize, def_easize, cookiesize); - RETURN(rc); + return rc; } /** @@ -114,7 +114,7 @@ int cl_ocd_update(struct obd_device *host, watched->obd_name); result = -EINVAL; } - RETURN(result); + return result; } #define GROUPLOCK_SCOPE "grouplock" diff --git a/drivers/staging/lustre/lustre/ldlm/interval_tree.c b/drivers/staging/lustre/lustre/ldlm/interval_tree.c index 400d28ef703cb..c65b13c800f96 100644 --- a/drivers/staging/lustre/lustre/ldlm/interval_tree.c +++ b/drivers/staging/lustre/lustre/ldlm/interval_tree.c @@ -134,44 +134,44 @@ for (node = interval_last(root); node != NULL; \ static struct interval_node *interval_first(struct interval_node *node) { if (!node) - RETURN(NULL); + return NULL; while (node->in_left) node = node->in_left; - RETURN(node); + return node; } static struct interval_node *interval_last(struct interval_node *node) { if (!node) - RETURN(NULL); + return NULL; while (node->in_right) node = node->in_right; - RETURN(node); + return node; } static struct interval_node *interval_next(struct interval_node *node) { if (!node) - RETURN(NULL); + return NULL; if (node->in_right) - RETURN(interval_first(node->in_right)); + return interval_first(node->in_right); while (node->in_parent && node_is_right_child(node)) node = node->in_parent; - RETURN(node->in_parent); + return node->in_parent; } static struct interval_node *interval_prev(struct interval_node *node) { if (!node) - RETURN(NULL); + return NULL; if (node->in_left) - RETURN(interval_last(node->in_left)); + return interval_last(node->in_left); while (node->in_parent && node_is_left_child(node)) node = node->in_parent; - RETURN(node->in_parent); + return node->in_parent; } enum interval_iter interval_iterate(struct interval_node *root, @@ -187,7 +187,7 @@ enum interval_iter interval_iterate(struct interval_node *root, break; } - RETURN(rc); + return rc; } EXPORT_SYMBOL(interval_iterate); @@ -204,7 +204,7 @@ enum interval_iter interval_iterate_reverse(struct interval_node *root, break; } - RETURN(rc); + return rc; } EXPORT_SYMBOL(interval_iterate_reverse); @@ -226,7 +226,7 @@ struct interval_node *interval_find(struct interval_node *root, walk = walk->in_right; } - RETURN(walk); + return walk; } EXPORT_SYMBOL(interval_find); @@ -374,7 +374,7 @@ struct interval_node *interval_insert(struct interval_node *node, while (*p) { parent = *p; if (node_equal(parent, node)) - RETURN(parent); + return parent; /* max_high field must be updated after each iteration */ if (parent->in_max_high < interval_high(node)) @@ -395,7 +395,7 @@ struct interval_node *interval_insert(struct interval_node *node, interval_insert_color(node, root); node->in_intree = 1; - RETURN(NULL); + return NULL; } EXPORT_SYMBOL(interval_insert); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c index 92fa314c669af..7e316637369b7 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c @@ -85,7 +85,7 @@ __u64 ldlm_extent_shift_kms(struct ldlm_lock *lock, __u64 old_kms) continue; if (lck->l_policy_data.l_extent.end >= old_kms) - RETURN(old_kms); + return old_kms; /* This extent _has_ to be smaller than old_kms (checked above) * so kms can only ever be smaller or the same as old_kms. */ @@ -94,7 +94,7 @@ __u64 ldlm_extent_shift_kms(struct ldlm_lock *lock, __u64 old_kms) } LASSERTF(kms <= old_kms, "kms "LPU64" old_kms "LPU64"\n", kms, old_kms); - RETURN(kms); + return kms; } EXPORT_SYMBOL(ldlm_extent_shift_kms); @@ -106,11 +106,11 @@ struct ldlm_interval *ldlm_interval_alloc(struct ldlm_lock *lock) LASSERT(lock->l_resource->lr_type == LDLM_EXTENT); OBD_SLAB_ALLOC_PTR_GFP(node, ldlm_interval_slab, __GFP_IO); if (node == NULL) - RETURN(NULL); + return NULL; INIT_LIST_HEAD(&node->li_group); ldlm_interval_attach(node, lock); - RETURN(node); + return node; } void ldlm_interval_free(struct ldlm_interval *node) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c index 9e61144ea24f9..c68ed27663334 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c @@ -305,12 +305,12 @@ ldlm_process_flock_lock(struct ldlm_lock *req, __u64 *flags, int first_enq, continue; if (!first_enq) - RETURN(LDLM_ITER_CONTINUE); + return LDLM_ITER_CONTINUE; if (*flags & LDLM_FL_BLOCK_NOWAIT) { ldlm_flock_destroy(req, mode, *flags); *err = -EAGAIN; - RETURN(LDLM_ITER_STOP); + return LDLM_ITER_STOP; } if (*flags & LDLM_FL_TEST_LOCK) { @@ -323,7 +323,7 @@ ldlm_process_flock_lock(struct ldlm_lock *req, __u64 *flags, int first_enq, req->l_policy_data.l_flock.end = lock->l_policy_data.l_flock.end; *flags |= LDLM_FL_LOCK_CHANGED; - RETURN(LDLM_ITER_STOP); + return LDLM_ITER_STOP; } /* add lock to blocking list before deadlock @@ -332,18 +332,18 @@ ldlm_process_flock_lock(struct ldlm_lock *req, __u64 *flags, int first_enq, if (rc) { ldlm_flock_destroy(req, mode, *flags); *err = rc; - RETURN(LDLM_ITER_STOP); + return LDLM_ITER_STOP; } if (ldlm_flock_deadlock(req, lock)) { ldlm_flock_blocking_unlink(req); ldlm_flock_destroy(req, mode, *flags); *err = -EDEADLK; - RETURN(LDLM_ITER_STOP); + return LDLM_ITER_STOP; } ldlm_resource_add_lock(res, &res->lr_waiting, req); *flags |= LDLM_FL_BLOCK_GRANTED; - RETURN(LDLM_ITER_STOP); + return LDLM_ITER_STOP; } } @@ -351,7 +351,7 @@ ldlm_process_flock_lock(struct ldlm_lock *req, __u64 *flags, int first_enq, ldlm_flock_destroy(req, mode, *flags); req->l_req_mode = LCK_NL; *flags |= LDLM_FL_LOCK_CHANGED; - RETURN(LDLM_ITER_STOP); + return LDLM_ITER_STOP; } /* In case we had slept on this lock request take it off of the @@ -463,7 +463,7 @@ ldlm_process_flock_lock(struct ldlm_lock *req, __u64 *flags, int first_enq, ldlm_flock_destroy(req, lock->l_granted_mode, *flags); *err = -ENOLCK; - RETURN(LDLM_ITER_STOP); + return LDLM_ITER_STOP; } goto reprocess; } @@ -530,7 +530,7 @@ ldlm_process_flock_lock(struct ldlm_lock *req, __u64 *flags, int first_enq, ldlm_flock_destroy(req, mode, *flags); ldlm_resource_dump(D_INFO, res); - RETURN(LDLM_ITER_CONTINUE); + return LDLM_ITER_CONTINUE; } struct ldlm_flock_wait_data { @@ -591,7 +591,7 @@ ldlm_flock_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data) /* Need to wake up the waiter if we were evicted */ wake_up(&lock->l_waitq); - RETURN(0); + return 0; } LASSERT(flags != LDLM_FL_WAIT_NOREPROC); @@ -603,7 +603,7 @@ ldlm_flock_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data) goto granted; /* CP AST RPC: lock get granted, wake it up */ wake_up(&lock->l_waitq); - RETURN(0); + return 0; } LDLM_DEBUG(lock, "client-side enqueue returned a blocked lock, " @@ -629,7 +629,7 @@ ldlm_flock_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data) if (rc) { LDLM_DEBUG(lock, "client-side enqueue waking up: failed (%d)", rc); - RETURN(rc); + return rc; } granted: @@ -637,18 +637,18 @@ ldlm_flock_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data) if (lock->l_flags & LDLM_FL_DESTROYED) { LDLM_DEBUG(lock, "client-side enqueue waking up: destroyed"); - RETURN(0); + return 0; } if (lock->l_flags & LDLM_FL_FAILED) { LDLM_DEBUG(lock, "client-side enqueue waking up: failed"); - RETURN(-EIO); + return -EIO; } if (rc) { LDLM_DEBUG(lock, "client-side enqueue waking up: failed (%d)", rc); - RETURN(rc); + return rc; } LDLM_DEBUG(lock, "client-side enqueue granted"); @@ -690,7 +690,7 @@ ldlm_flock_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data) ldlm_process_flock_lock(lock, &noreproc, 1, &err, NULL); } unlock_res_and_lock(lock); - RETURN(0); + return 0; } EXPORT_SYMBOL(ldlm_flock_completion_ast); @@ -704,7 +704,7 @@ int ldlm_flock_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, lock_res_and_lock(lock); ldlm_flock_blocking_unlink(lock); unlock_res_and_lock(lock); - RETURN(0); + return 0; } void ldlm_flock_policy_wire18_to_local(const ldlm_wire_policy_data_t *wpolicy, @@ -825,9 +825,9 @@ int ldlm_init_flock_export(struct obd_export *exp) &ldlm_export_flock_ops, CFS_HASH_DEFAULT | CFS_HASH_NBLK_CHANGE); if (!exp->exp_flock_hash) - RETURN(-ENOMEM); + return -ENOMEM; - RETURN(0); + return 0; } EXPORT_SYMBOL(ldlm_init_flock_export); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c index 4b03e7d8d3ae4..1a8c0d7005c7a 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c @@ -63,13 +63,13 @@ static int import_set_conn(struct obd_import *imp, struct obd_uuid *uuid, if (!create && !priority) { CDEBUG(D_HA, "Nothing to do\n"); - RETURN(-EINVAL); + return -EINVAL; } ptlrpc_conn = ptlrpc_uuid_to_connection(uuid); if (!ptlrpc_conn) { CDEBUG(D_HA, "can't find connection %s\n", uuid->uuid); - RETURN (-ENOENT); + return -ENOENT; } if (create) { @@ -114,13 +114,13 @@ static int import_set_conn(struct obd_import *imp, struct obd_uuid *uuid, } spin_unlock(&imp->imp_lock); - RETURN(0); + return 0; out_free: if (imp_conn) OBD_FREE(imp_conn, sizeof(*imp_conn)); out_put: ptlrpc_connection_put(ptlrpc_conn); - RETURN(rc); + return rc; } int import_set_conn_priority(struct obd_import *imp, struct obd_uuid *uuid) @@ -185,7 +185,7 @@ int client_import_del_conn(struct obd_import *imp, struct obd_uuid *uuid) spin_unlock(&imp->imp_lock); if (rc == -ENOENT) CERROR("connection %s not found\n", uuid->uuid); - RETURN(rc); + return rc; } EXPORT_SYMBOL(client_import_del_conn); @@ -209,7 +209,7 @@ int client_import_find_conn(struct obd_import *imp, lnet_nid_t peer, } } spin_unlock(&imp->imp_lock); - RETURN(rc); + return rc; } EXPORT_SYMBOL(client_import_find_conn); @@ -301,27 +301,27 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg) } else { CERROR("unknown client OBD type \"%s\", can't setup\n", name); - RETURN(-EINVAL); + return -EINVAL; } if (LUSTRE_CFG_BUFLEN(lcfg, 1) < 1) { CERROR("requires a TARGET UUID\n"); - RETURN(-EINVAL); + return -EINVAL; } if (LUSTRE_CFG_BUFLEN(lcfg, 1) > 37) { CERROR("client UUID must be less than 38 characters\n"); - RETURN(-EINVAL); + return -EINVAL; } if (LUSTRE_CFG_BUFLEN(lcfg, 2) < 1) { CERROR("setup requires a SERVER UUID\n"); - RETURN(-EINVAL); + return -EINVAL; } if (LUSTRE_CFG_BUFLEN(lcfg, 2) > 37) { CERROR("target UUID must be less than 38 characters\n"); - RETURN(-EINVAL); + return -EINVAL; } init_rwsem(&cli->cl_sem); @@ -448,14 +448,14 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg) cli->cl_qchk_stat = CL_NOT_QUOTACHECKED; - RETURN(rc); + return rc; err_import: class_destroy_import(imp); err_ldlm: ldlm_put_ref(); err: - RETURN(rc); + return rc; } EXPORT_SYMBOL(client_obd_setup); @@ -468,7 +468,7 @@ int client_obd_cleanup(struct obd_device *obddev) LASSERT(obddev->u.cli.cl_import == NULL); ldlm_put_ref(); - RETURN(0); + return 0; } EXPORT_SYMBOL(client_obd_cleanup); @@ -548,7 +548,7 @@ int client_disconnect_export(struct obd_export *exp) if (!obd) { CERROR("invalid export for disconnect: exp %p cookie "LPX64"\n", exp, exp ? exp->exp_handle.h_cookie : -1); - RETURN(-EINVAL); + return -EINVAL; } cli = &obd->u.cli; @@ -604,7 +604,7 @@ int client_disconnect_export(struct obd_export *exp) up_write(&cli->cl_sem); - RETURN(rc); + return rc; } EXPORT_SYMBOL(client_disconnect_export); @@ -622,7 +622,7 @@ int target_pack_pool_reply(struct ptlrpc_request *req) !exp_connect_lru_resize(req->rq_export))) { lustre_msg_set_slv(req->rq_repmsg, 0); lustre_msg_set_limit(req->rq_repmsg, 0); - RETURN(0); + return 0; } /* OBD is alive here as export is alive, which we checked above. */ @@ -633,7 +633,7 @@ int target_pack_pool_reply(struct ptlrpc_request *req) lustre_msg_set_limit(req->rq_repmsg, obd->obd_pool_limit); read_unlock(&obd->obd_pool_lock); - RETURN(0); + return 0; } EXPORT_SYMBOL(target_pack_pool_reply); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index e0877b20eb94b..6133b3f347182 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -251,7 +251,7 @@ int ldlm_lock_remove_from_lru(struct ldlm_lock *lock) if (lock->l_flags & LDLM_FL_NS_SRV) { LASSERT(list_empty(&lock->l_lru)); - RETURN(0); + return 0; } spin_lock(&ns->ns_lock); @@ -439,7 +439,7 @@ static struct ldlm_lock *ldlm_lock_new(struct ldlm_resource *resource) OBD_SLAB_ALLOC_PTR_GFP(lock, ldlm_lock_slab, __GFP_IO); if (lock == NULL) - RETURN(NULL); + return NULL; spin_lock_init(&lock->l_lock); lock->l_resource = resource; @@ -475,7 +475,7 @@ static struct ldlm_lock *ldlm_lock_new(struct ldlm_resource *resource) #endif INIT_LIST_HEAD(&lock->l_exp_list); - RETURN(lock); + return lock; } /** @@ -497,7 +497,7 @@ int ldlm_lock_change_resource(struct ldlm_namespace *ns, struct ldlm_lock *lock, sizeof(lock->l_resource->lr_name)) == 0) { /* Nothing to do */ unlock_res_and_lock(lock); - RETURN(0); + return 0; } LASSERT(new_resid->name[0] != 0); @@ -510,7 +510,7 @@ int ldlm_lock_change_resource(struct ldlm_namespace *ns, struct ldlm_lock *lock, newres = ldlm_resource_get(ns, NULL, new_resid, type, 1); if (newres == NULL) - RETURN(-ENOMEM); + return -ENOMEM; lu_ref_add(&newres->lr_reference, "lock", lock); /* @@ -538,7 +538,7 @@ int ldlm_lock_change_resource(struct ldlm_namespace *ns, struct ldlm_lock *lock, lu_ref_del(&oldres->lr_reference, "lock", lock); ldlm_resource_putref(oldres); - RETURN(0); + return 0; } EXPORT_SYMBOL(ldlm_lock_change_resource); @@ -572,13 +572,13 @@ struct ldlm_lock *__ldlm_handle2lock(const struct lustre_handle *handle, lock = class_handle2object(handle->cookie); if (lock == NULL) - RETURN(NULL); + return NULL; /* It's unlikely but possible that someone marked the lock as * destroyed after we did handle2object on it */ if (flags == 0 && ((lock->l_flags & LDLM_FL_DESTROYED)== 0)) { lu_ref_add(&lock->l_reference, "handle", current); - RETURN(lock); + return lock; } lock_res_and_lock(lock); @@ -590,20 +590,20 @@ struct ldlm_lock *__ldlm_handle2lock(const struct lustre_handle *handle, unlock_res_and_lock(lock); CDEBUG(D_INFO, "lock already destroyed: lock %p\n", lock); LDLM_LOCK_PUT(lock); - RETURN(NULL); + return NULL; } if (flags && (lock->l_flags & flags)) { unlock_res_and_lock(lock); LDLM_LOCK_PUT(lock); - RETURN(NULL); + return NULL; } if (flags) lock->l_flags |= flags; unlock_res_and_lock(lock); - RETURN(lock); + return lock; } EXPORT_SYMBOL(__ldlm_handle2lock); /** @} ldlm_handles */ @@ -1280,7 +1280,7 @@ ldlm_mode_t ldlm_lock_match(struct ldlm_namespace *ns, __u64 flags, res = ldlm_resource_get(ns, NULL, res_id, type, 0); if (res == NULL) { LASSERT(old_lock == NULL); - RETURN(0); + return 0; } LDLM_RESOURCE_ADDREF(res); @@ -1433,7 +1433,7 @@ int ldlm_fill_lvb(struct ldlm_lock *lock, struct req_capsule *pill, lustre_swab_ost_lvb); if (unlikely(lvb == NULL)) { LDLM_ERROR(lock, "no LVB"); - RETURN(-EPROTO); + return -EPROTO; } memcpy(data, lvb, size); @@ -1450,7 +1450,7 @@ int ldlm_fill_lvb(struct ldlm_lock *lock, struct req_capsule *pill, lustre_swab_ost_lvb_v1); if (unlikely(lvb == NULL)) { LDLM_ERROR(lock, "no LVB"); - RETURN(-EPROTO); + return -EPROTO; } memcpy(data, lvb, size); @@ -1460,7 +1460,7 @@ int ldlm_fill_lvb(struct ldlm_lock *lock, struct req_capsule *pill, } else { LDLM_ERROR(lock, "Replied unexpected ost LVB size %d", size); - RETURN(-EINVAL); + return -EINVAL; } break; case LVB_T_LQUOTA: @@ -1475,14 +1475,14 @@ int ldlm_fill_lvb(struct ldlm_lock *lock, struct req_capsule *pill, lustre_swab_lquota_lvb); if (unlikely(lvb == NULL)) { LDLM_ERROR(lock, "no LVB"); - RETURN(-EPROTO); + return -EPROTO; } memcpy(data, lvb, size); } else { LDLM_ERROR(lock, "Replied unexpected lquota LVB size %d", size); - RETURN(-EINVAL); + return -EINVAL; } break; case LVB_T_LAYOUT: @@ -1495,7 +1495,7 @@ int ldlm_fill_lvb(struct ldlm_lock *lock, struct req_capsule *pill, lvb = req_capsule_server_get(pill, &RMF_DLM_LVB); if (unlikely(lvb == NULL)) { LDLM_ERROR(lock, "no LVB"); - RETURN(-EPROTO); + return -EPROTO; } memcpy(data, lvb, size); @@ -1503,10 +1503,10 @@ int ldlm_fill_lvb(struct ldlm_lock *lock, struct req_capsule *pill, default: LDLM_ERROR(lock, "Unknown LVB type: %d\n", lock->l_lvb_type); dump_stack(); - RETURN(-EINVAL); + return -EINVAL; } - RETURN(0); + return 0; } /** @@ -1526,12 +1526,12 @@ struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace *ns, res = ldlm_resource_get(ns, NULL, res_id, type, 1); if (res == NULL) - RETURN(NULL); + return NULL; lock = ldlm_lock_new(res); if (lock == NULL) - RETURN(NULL); + return NULL; lock->l_req_mode = mode; lock->l_ast_data = data; @@ -1562,7 +1562,7 @@ struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace *ns, if (OBD_FAIL_CHECK(OBD_FAIL_LDLM_NEW_LOCK)) GOTO(out, 0); - RETURN(lock); + return lock; out: ldlm_lock_destroy(lock); @@ -1606,11 +1606,11 @@ ldlm_error_t ldlm_lock_enqueue(struct ldlm_namespace *ns, LDLM_LOCK_RELEASE(lock); } *flags |= LDLM_FL_LOCK_CHANGED; - RETURN(0); + return 0; } else if (rc != ELDLM_OK || (rc == ELDLM_OK && (*flags & LDLM_FL_INTENT_ONLY))) { ldlm_lock_destroy(lock); - RETURN(rc); + return rc; } } @@ -1692,7 +1692,7 @@ ldlm_work_bl_ast_lock(struct ptlrpc_request_set *rqset, void *opaq) struct ldlm_lock *lock; if (list_empty(arg->list)) - RETURN(-ENOENT); + return -ENOENT; lock = list_entry(arg->list->next, struct ldlm_lock, l_bl_ast); @@ -1713,7 +1713,7 @@ ldlm_work_bl_ast_lock(struct ptlrpc_request_set *rqset, void *opaq) lock->l_blocking_lock = NULL; LDLM_LOCK_RELEASE(lock); - RETURN(rc); + return rc; } /** @@ -1728,7 +1728,7 @@ ldlm_work_cp_ast_lock(struct ptlrpc_request_set *rqset, void *opaq) ldlm_completion_callback completion_callback; if (list_empty(arg->list)) - RETURN(-ENOENT); + return -ENOENT; lock = list_entry(arg->list->next, struct ldlm_lock, l_cp_ast); @@ -1757,7 +1757,7 @@ ldlm_work_cp_ast_lock(struct ptlrpc_request_set *rqset, void *opaq) rc = completion_callback(lock, 0, (void *)arg); LDLM_LOCK_RELEASE(lock); - RETURN(rc); + return rc; } /** @@ -1772,7 +1772,7 @@ ldlm_work_revoke_ast_lock(struct ptlrpc_request_set *rqset, void *opaq) struct ldlm_lock *lock; if (list_empty(arg->list)) - RETURN(-ENOENT); + return -ENOENT; lock = list_entry(arg->list->next, struct ldlm_lock, l_rk_ast); list_del_init(&lock->l_rk_ast); @@ -1785,7 +1785,7 @@ ldlm_work_revoke_ast_lock(struct ptlrpc_request_set *rqset, void *opaq) rc = lock->l_blocking_ast(lock, &desc, (void*)arg, LDLM_CB_BLOCKING); LDLM_LOCK_RELEASE(lock); - RETURN(rc); + return rc; } /** @@ -1799,7 +1799,7 @@ int ldlm_work_gl_ast_lock(struct ptlrpc_request_set *rqset, void *opaq) int rc = 0; if (list_empty(arg->list)) - RETURN(-ENOENT); + return -ENOENT; gl_work = list_entry(arg->list->next, struct ldlm_glimpse_work, gl_list); @@ -1819,7 +1819,7 @@ int ldlm_work_gl_ast_lock(struct ptlrpc_request_set *rqset, void *opaq) if ((gl_work->gl_flags & LDLM_GL_WORK_NOFREE) == 0) OBD_FREE_PTR(gl_work); - RETURN(rc); + return rc; } /** @@ -1836,11 +1836,11 @@ int ldlm_run_ast_work(struct ldlm_namespace *ns, struct list_head *rpc_list, int rc; if (list_empty(rpc_list)) - RETURN(0); + return 0; OBD_ALLOC_PTR(arg); if (arg == NULL) - RETURN(-ENOMEM); + return -ENOMEM; atomic_set(&arg->restart, 0); arg->list = rpc_list; @@ -2027,7 +2027,7 @@ int ldlm_lock_set_data(struct lustre_handle *lockh, void *data) rc = 0; LDLM_LOCK_PUT(lock); } - RETURN(rc); + return rc; } EXPORT_SYMBOL(ldlm_lock_set_data); @@ -2136,7 +2136,7 @@ struct ldlm_resource *ldlm_lock_convert(struct ldlm_lock *lock, int new_mode, /* Just return if mode is unchanged. */ if (new_mode == lock->l_granted_mode) { *flags |= LDLM_FL_BLOCK_GRANTED; - RETURN(lock->l_resource); + return lock->l_resource; } /* I can't check the type of lock here because the bitlock of lock @@ -2144,7 +2144,7 @@ struct ldlm_resource *ldlm_lock_convert(struct ldlm_lock *lock, int new_mode, OBD_SLAB_ALLOC_PTR_GFP(node, ldlm_interval_slab, __GFP_IO); if (node == NULL) /* Actually, this causes EDEADLOCK to be returned */ - RETURN(NULL); + return NULL; LASSERTF((new_mode == LCK_PW && lock->l_granted_mode == LCK_PR), "new_mode %u, granted %u\n", new_mode, lock->l_granted_mode); @@ -2203,7 +2203,7 @@ struct ldlm_resource *ldlm_lock_convert(struct ldlm_lock *lock, int new_mode, ldlm_run_ast_work(ns, &rpc_list, LDLM_WORK_CP_AST); if (node) OBD_SLAB_FREE(node, ldlm_interval_slab, sizeof(*node)); - RETURN(res); + return res; } EXPORT_SYMBOL(ldlm_lock_convert); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c index cce0ad70f162a..3ede1a444afd3 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c @@ -127,12 +127,12 @@ struct ldlm_bl_work_item { int ldlm_del_waiting_lock(struct ldlm_lock *lock) { - RETURN(0); + return 0; } int ldlm_refresh_waiting_lock(struct ldlm_lock *lock, int timeout) { - RETURN(0); + return 0; } @@ -395,7 +395,7 @@ static int __ldlm_bl_to_thread(struct ldlm_bl_work_item *blwi, if (!(cancel_flags & LCF_ASYNC)) wait_for_completion(&blwi->blwi_comp); - RETURN(0); + return 0; } static inline void init_blwi(struct ldlm_bl_work_item *blwi, @@ -440,17 +440,17 @@ static int ldlm_bl_to_thread(struct ldlm_namespace *ns, ldlm_cancel_flags_t cancel_flags) { if (cancels && count == 0) - RETURN(0); + return 0; if (cancel_flags & LCF_ASYNC) { struct ldlm_bl_work_item *blwi; OBD_ALLOC(blwi, sizeof(*blwi)); if (blwi == NULL) - RETURN(-ENOMEM); + return -ENOMEM; init_blwi(blwi, ns, ld, cancels, count, lock, cancel_flags); - RETURN(__ldlm_bl_to_thread(blwi, cancel_flags)); + return __ldlm_bl_to_thread(blwi, cancel_flags); } else { /* if it is synchronous call do minimum mem alloc, as it could * be triggered from kernel shrinker @@ -459,7 +459,7 @@ static int ldlm_bl_to_thread(struct ldlm_namespace *ns, memset(&blwi, 0, sizeof(blwi)); init_blwi(&blwi, ns, ld, cancels, count, lock, cancel_flags); - RETURN(__ldlm_bl_to_thread(&blwi, cancel_flags)); + return __ldlm_bl_to_thread(&blwi, cancel_flags); } } @@ -493,14 +493,14 @@ static int ldlm_handle_setinfo(struct ptlrpc_request *req) key = req_capsule_client_get(&req->rq_pill, &RMF_SETINFO_KEY); if (key == NULL) { DEBUG_REQ(D_IOCTL, req, "no set_info key"); - RETURN(-EFAULT); + return -EFAULT; } keylen = req_capsule_get_size(&req->rq_pill, &RMF_SETINFO_KEY, RCL_CLIENT); val = req_capsule_client_get(&req->rq_pill, &RMF_SETINFO_VAL); if (val == NULL) { DEBUG_REQ(D_IOCTL, req, "no set_info val"); - RETURN(-EFAULT); + return -EFAULT; } vallen = req_capsule_get_size(&req->rq_pill, &RMF_SETINFO_VAL, RCL_CLIENT); @@ -542,7 +542,7 @@ static int ldlm_handle_qc_callback(struct ptlrpc_request *req) oqctl = req_capsule_client_get(&req->rq_pill, &RMF_OBD_QUOTACTL); if (oqctl == NULL) { CERROR("Can't unpack obd_quotactl\n"); - RETURN(-EPROTO); + return -EPROTO; } oqctl->qc_stat = ptlrpc_status_ntoh(oqctl->qc_stat); @@ -566,7 +566,7 @@ static int ldlm_callback_handler(struct ptlrpc_request *req) /* do nothing for sec context finalize */ if (lustre_msg_get_opc(req->rq_reqmsg) == SEC_CTX_FINI) - RETURN(0); + return 0; req_capsule_init(&req->rq_pill, req, RCL_SERVER); @@ -574,7 +574,7 @@ static int ldlm_callback_handler(struct ptlrpc_request *req) rc = ldlm_callback_reply(req, -ENOTCONN); ldlm_callback_errmsg(req, "Operate on unconnected server", rc, NULL); - RETURN(0); + return 0; } LASSERT(req->rq_export != NULL); @@ -583,71 +583,71 @@ static int ldlm_callback_handler(struct ptlrpc_request *req) switch (lustre_msg_get_opc(req->rq_reqmsg)) { case LDLM_BL_CALLBACK: if (OBD_FAIL_CHECK(OBD_FAIL_LDLM_BL_CALLBACK_NET)) - RETURN(0); + return 0; break; case LDLM_CP_CALLBACK: if (OBD_FAIL_CHECK(OBD_FAIL_LDLM_CP_CALLBACK_NET)) - RETURN(0); + return 0; break; case LDLM_GL_CALLBACK: if (OBD_FAIL_CHECK(OBD_FAIL_LDLM_GL_CALLBACK_NET)) - RETURN(0); + return 0; break; case LDLM_SET_INFO: rc = ldlm_handle_setinfo(req); ldlm_callback_reply(req, rc); - RETURN(0); + return 0; case OBD_LOG_CANCEL: /* remove this eventually - for 1.4.0 compat */ CERROR("shouldn't be handling OBD_LOG_CANCEL on DLM thread\n"); req_capsule_set(&req->rq_pill, &RQF_LOG_CANCEL); if (OBD_FAIL_CHECK(OBD_FAIL_OBD_LOG_CANCEL_NET)) - RETURN(0); + return 0; rc = llog_origin_handle_cancel(req); if (OBD_FAIL_CHECK(OBD_FAIL_OBD_LOG_CANCEL_REP)) - RETURN(0); + return 0; ldlm_callback_reply(req, rc); - RETURN(0); + return 0; case LLOG_ORIGIN_HANDLE_CREATE: req_capsule_set(&req->rq_pill, &RQF_LLOG_ORIGIN_HANDLE_CREATE); if (OBD_FAIL_CHECK(OBD_FAIL_OBD_LOGD_NET)) - RETURN(0); + return 0; rc = llog_origin_handle_open(req); ldlm_callback_reply(req, rc); - RETURN(0); + return 0; case LLOG_ORIGIN_HANDLE_NEXT_BLOCK: req_capsule_set(&req->rq_pill, &RQF_LLOG_ORIGIN_HANDLE_NEXT_BLOCK); if (OBD_FAIL_CHECK(OBD_FAIL_OBD_LOGD_NET)) - RETURN(0); + return 0; rc = llog_origin_handle_next_block(req); ldlm_callback_reply(req, rc); - RETURN(0); + return 0; case LLOG_ORIGIN_HANDLE_READ_HEADER: req_capsule_set(&req->rq_pill, &RQF_LLOG_ORIGIN_HANDLE_READ_HEADER); if (OBD_FAIL_CHECK(OBD_FAIL_OBD_LOGD_NET)) - RETURN(0); + return 0; rc = llog_origin_handle_read_header(req); ldlm_callback_reply(req, rc); - RETURN(0); + return 0; case LLOG_ORIGIN_HANDLE_CLOSE: if (OBD_FAIL_CHECK(OBD_FAIL_OBD_LOGD_NET)) - RETURN(0); + return 0; rc = llog_origin_handle_close(req); ldlm_callback_reply(req, rc); - RETURN(0); + return 0; case OBD_QC_CALLBACK: req_capsule_set(&req->rq_pill, &RQF_QC_CALLBACK); if (OBD_FAIL_CHECK(OBD_FAIL_OBD_QC_CALLBACK_NET)) - RETURN(0); + return 0; rc = ldlm_handle_qc_callback(req); ldlm_callback_reply(req, rc); - RETURN(0); + return 0; default: CERROR("unknown opcode %u\n", lustre_msg_get_opc(req->rq_reqmsg)); ldlm_callback_reply(req, -EPROTO); - RETURN(0); + return 0; } ns = req->rq_export->exp_obd->obd_namespace; @@ -660,7 +660,7 @@ static int ldlm_callback_handler(struct ptlrpc_request *req) rc = ldlm_callback_reply(req, -EPROTO); ldlm_callback_errmsg(req, "Operate without parameter", rc, NULL); - RETURN(0); + return 0; } /* Force a known safe race, send a cancel to the server for a lock @@ -679,7 +679,7 @@ static int ldlm_callback_handler(struct ptlrpc_request *req) rc = ldlm_callback_reply(req, -EINVAL); ldlm_callback_errmsg(req, "Operate with invalid parameter", rc, &dlm_req->lock_handle[0]); - RETURN(0); + return 0; } if ((lock->l_flags & LDLM_FL_FAIL_LOC) && @@ -706,7 +706,7 @@ static int ldlm_callback_handler(struct ptlrpc_request *req) rc = ldlm_callback_reply(req, -EINVAL); ldlm_callback_errmsg(req, "Operate on stale lock", rc, &dlm_req->lock_handle[0]); - RETURN(0); + return 0; } /* BL_AST locks are not needed in LRU. * Let ldlm_cancel_lru() be fast. */ @@ -752,7 +752,7 @@ static int ldlm_callback_handler(struct ptlrpc_request *req) LBUG(); /* checked above */ } - RETURN(0); + return 0; } @@ -894,7 +894,7 @@ static int ldlm_bl_thread_main(void *arg) atomic_dec(&blp->blp_busy_threads); atomic_dec(&blp->blp_num_threads); complete(&blp->blp_comp); - RETURN(0); + return 0; } @@ -913,7 +913,7 @@ int ldlm_get_ref(void) } mutex_unlock(&ldlm_ref_mutex); - RETURN(rc); + return rc; } EXPORT_SYMBOL(ldlm_get_ref); @@ -1014,9 +1014,9 @@ int ldlm_init_export(struct obd_export *exp) CFS_HASH_NBLK_CHANGE); if (!exp->exp_lock_hash) - RETURN(-ENOMEM); + return -ENOMEM; - RETURN(0); + return 0; } EXPORT_SYMBOL(ldlm_init_export); @@ -1037,11 +1037,11 @@ static int ldlm_setup(void) int i; if (ldlm_state != NULL) - RETURN(-EALREADY); + return -EALREADY; OBD_ALLOC(ldlm_state, sizeof(*ldlm_state)); if (ldlm_state == NULL) - RETURN(-ENOMEM); + return -ENOMEM; #ifdef LPROCFS rc = ldlm_proc_setup(); @@ -1121,11 +1121,11 @@ static int ldlm_setup(void) CERROR("Failed to initialize LDLM pools: %d\n", rc); GOTO(out, rc); } - RETURN(0); + return 0; out: ldlm_cleanup(); - RETURN(rc); + return rc; } static int ldlm_cleanup(void) @@ -1135,7 +1135,7 @@ static int ldlm_cleanup(void) CERROR("ldlm still has namespaces; clean these up first.\n"); ldlm_dump_all_namespaces(LDLM_NAMESPACE_SERVER, D_DLMTRACE); ldlm_dump_all_namespaces(LDLM_NAMESPACE_CLIENT, D_DLMTRACE); - RETURN(-EBUSY); + return -EBUSY; } ldlm_pools_fini(); @@ -1168,7 +1168,7 @@ static int ldlm_cleanup(void) OBD_FREE(ldlm_state, sizeof(*ldlm_state)); ldlm_state = NULL; - RETURN(0); + return 0; } int ldlm_init(void) diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c index e500506c8683b..00ff0edd5a2b5 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c @@ -338,13 +338,13 @@ static int ldlm_srv_pool_recalc(struct ldlm_pool *pl) recalc_interval_sec = cfs_time_current_sec() - pl->pl_recalc_time; if (recalc_interval_sec < pl->pl_recalc_period) - RETURN(0); + return 0; spin_lock(&pl->pl_lock); recalc_interval_sec = cfs_time_current_sec() - pl->pl_recalc_time; if (recalc_interval_sec < pl->pl_recalc_period) { spin_unlock(&pl->pl_lock); - RETURN(0); + return 0; } /* * Recalc SLV after last period. This should be done @@ -366,7 +366,7 @@ static int ldlm_srv_pool_recalc(struct ldlm_pool *pl) lprocfs_counter_add(pl->pl_stats, LDLM_POOL_TIMING_STAT, recalc_interval_sec); spin_unlock(&pl->pl_lock); - RETURN(0); + return 0; } /** @@ -393,7 +393,7 @@ static int ldlm_srv_pool_shrink(struct ldlm_pool *pl, * and can't cancel anything. Let's catch this race. */ if (atomic_read(&pl->pl_granted) == 0) - RETURN(0); + return 0; spin_lock(&pl->pl_lock); @@ -475,7 +475,7 @@ static int ldlm_cli_pool_recalc(struct ldlm_pool *pl) recalc_interval_sec = cfs_time_current_sec() - pl->pl_recalc_time; if (recalc_interval_sec < pl->pl_recalc_period) - RETURN(0); + return 0; spin_lock(&pl->pl_lock); /* @@ -484,7 +484,7 @@ static int ldlm_cli_pool_recalc(struct ldlm_pool *pl) recalc_interval_sec = cfs_time_current_sec() - pl->pl_recalc_time; if (recalc_interval_sec < pl->pl_recalc_period) { spin_unlock(&pl->pl_lock); - RETURN(0); + return 0; } /* @@ -501,7 +501,7 @@ static int ldlm_cli_pool_recalc(struct ldlm_pool *pl) * Do not cancel locks in case lru resize is disabled for this ns. */ if (!ns_connect_lru_resize(ldlm_pl2ns(pl))) - RETURN(0); + return 0; /* * In the time of canceling locks on client we do not need to maintain @@ -509,8 +509,7 @@ static int ldlm_cli_pool_recalc(struct ldlm_pool *pl) * It may be called when SLV has changed much, this is why we do not * take into account pl->pl_recalc_time here. */ - RETURN(ldlm_cancel_lru(ldlm_pl2ns(pl), 0, LCF_ASYNC, - LDLM_CANCEL_LRUR)); + return ldlm_cancel_lru(ldlm_pl2ns(pl), 0, LCF_ASYNC, LDLM_CANCEL_LRUR); } /** @@ -530,7 +529,7 @@ static int ldlm_cli_pool_shrink(struct ldlm_pool *pl, * Do not cancel locks in case lru resize is disabled for this ns. */ if (!ns_connect_lru_resize(ns)) - RETURN(0); + return 0; /* * Make sure that pool knows last SLV and Limit from obd. @@ -734,7 +733,7 @@ static int ldlm_pool_proc_init(struct ldlm_pool *pl) OBD_ALLOC(var_name, MAX_STRING_SIZE + 1); if (!var_name) - RETURN(-ENOMEM); + return -ENOMEM; parent_ns_proc = ns->ns_proc_dir_entry; if (parent_ns_proc == NULL) { @@ -858,11 +857,11 @@ int ldlm_pool_init(struct ldlm_pool *pl, struct ldlm_namespace *ns, pl->pl_client_lock_volume = 0; rc = ldlm_pool_proc_init(pl); if (rc) - RETURN(rc); + return rc; CDEBUG(D_DLMTRACE, "Lock pool %s is initialized\n", pl->pl_name); - RETURN(rc); + return rc; } EXPORT_SYMBOL(ldlm_pool_init); @@ -1343,11 +1342,11 @@ static int ldlm_pools_thread_start(void) task_t *task; if (ldlm_pools_thread != NULL) - RETURN(-EALREADY); + return -EALREADY; OBD_ALLOC_PTR(ldlm_pools_thread); if (ldlm_pools_thread == NULL) - RETURN(-ENOMEM); + return -ENOMEM; init_completion(&ldlm_pools_comp); init_waitqueue_head(&ldlm_pools_thread->t_ctl_waitq); @@ -1358,11 +1357,11 @@ static int ldlm_pools_thread_start(void) CERROR("Can't start pool thread, error %ld\n", PTR_ERR(task)); OBD_FREE(ldlm_pools_thread, sizeof(*ldlm_pools_thread)); ldlm_pools_thread = NULL; - RETURN(PTR_ERR(task)); + return PTR_ERR(task); } l_wait_event(ldlm_pools_thread->t_ctl_waitq, thread_is_running(ldlm_pools_thread), &lwi); - RETURN(0); + return 0; } static void ldlm_pools_thread_stop(void) @@ -1397,7 +1396,7 @@ int ldlm_pools_init(void) set_shrinker(DEFAULT_SEEKS, ldlm_pools_cli_shrink); } - RETURN(rc); + return rc; } EXPORT_SYMBOL(ldlm_pools_init); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c index 6c2b94536d82d..21cb523ac4afc 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c @@ -98,7 +98,7 @@ int ldlm_expired_completion_wait(void *data) static cfs_time_t next_dump = 0, last_dump = 0; if (ptlrpc_check_suspend()) - RETURN(0); + return 0; LCONSOLE_WARN("lock timed out (enqueued at "CFS_TIME_T", " CFS_DURATION_T"s ago)\n", @@ -119,7 +119,7 @@ int ldlm_expired_completion_wait(void *data) if (last_dump == 0) libcfs_debug_dumplog(); } - RETURN(0); + return 0; } obd = lock->l_conn_export->exp_obd; @@ -131,7 +131,7 @@ int ldlm_expired_completion_wait(void *data) cfs_time_sub(cfs_time_current_sec(), lock->l_last_activity), obd2cli_tgt(obd), imp->imp_connection->c_remote_uuid.uuid); - RETURN(0); + return 0; } EXPORT_SYMBOL(ldlm_expired_completion_wait); @@ -185,19 +185,19 @@ int ldlm_completion_ast_async(struct ldlm_lock *lock, __u64 flags, void *data) { if (flags == LDLM_FL_WAIT_NOREPROC) { LDLM_DEBUG(lock, "client-side enqueue waiting on pending lock"); - RETURN(0); + return 0; } if (!(flags & (LDLM_FL_BLOCK_WAIT | LDLM_FL_BLOCK_GRANTED | LDLM_FL_BLOCK_CONV))) { wake_up(&lock->l_waitq); - RETURN(ldlm_completion_tail(lock)); + return ldlm_completion_tail(lock); } LDLM_DEBUG(lock, "client-side enqueue returned a blocked lock, " "going forward"); ldlm_reprocess_all(lock->l_resource); - RETURN(0); + return 0; } EXPORT_SYMBOL(ldlm_completion_ast_async); @@ -240,7 +240,7 @@ int ldlm_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data) if (!(flags & (LDLM_FL_BLOCK_WAIT | LDLM_FL_BLOCK_GRANTED | LDLM_FL_BLOCK_CONV))) { wake_up(&lock->l_waitq); - RETURN(0); + return 0; } LDLM_DEBUG(lock, "client-side enqueue returned a blocked lock, " @@ -291,10 +291,10 @@ int ldlm_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data) if (rc) { LDLM_DEBUG(lock, "client-side enqueue waking up: failed (%d)", rc); - RETURN(rc); + return rc; } - RETURN(ldlm_completion_tail(lock)); + return ldlm_completion_tail(lock); } EXPORT_SYMBOL(ldlm_completion_ast); @@ -330,7 +330,7 @@ int ldlm_blocking_ast_nocheck(struct ldlm_lock *lock) LDLM_DEBUG(lock, "Lock still has references, will be " "cancelled later"); } - RETURN(0); + return 0; } EXPORT_SYMBOL(ldlm_blocking_ast_nocheck); @@ -352,7 +352,7 @@ int ldlm_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, { if (flag == LDLM_CB_CANCELING) { /* Don't need to do anything here. */ - RETURN(0); + return 0; } lock_res_and_lock(lock); @@ -363,9 +363,9 @@ int ldlm_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, * early, if so. */ if (lock->l_blocking_ast != ldlm_blocking_ast) { unlock_res_and_lock(lock); - RETURN(0); + return 0; } - RETURN(ldlm_blocking_ast_nocheck(lock)); + return ldlm_blocking_ast_nocheck(lock); } EXPORT_SYMBOL(ldlm_blocking_ast); @@ -526,7 +526,7 @@ int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req, /* ldlm_cli_enqueue is holding a reference on this lock. */ if (!lock) { LASSERT(type == LDLM_FLOCK); - RETURN(-ENOLCK); + return -ENOLCK; } LASSERTF(ergo(lvb_len != 0, lvb_len == lock->l_lvb_len), @@ -782,7 +782,7 @@ int ldlm_prep_elc_req(struct obd_export *exp, struct ptlrpc_request *req, rc = ptlrpc_request_pack(req, version, opc); if (rc) { ldlm_lock_list_put(cancels, l_bl_ast, count); - RETURN(rc); + return rc; } if (ns_connect_cancelset(ns)) { @@ -802,7 +802,7 @@ int ldlm_prep_elc_req(struct obd_export *exp, struct ptlrpc_request *req, } else { ldlm_lock_list_put(cancels, l_bl_ast, count); } - RETURN(0); + return 0; } EXPORT_SYMBOL(ldlm_prep_elc_req); @@ -821,17 +821,17 @@ struct ptlrpc_request *ldlm_enqueue_pack(struct obd_export *exp, int lvb_len) req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_LDLM_ENQUEUE); if (req == NULL) - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); rc = ldlm_prep_enqueue_req(exp, req, NULL, 0); if (rc) { ptlrpc_request_free(req); - RETURN(ERR_PTR(rc)); + return ERR_PTR(rc); } req_capsule_set_size(&req->rq_pill, &RMF_DLM_LVB, RCL_SERVER, lvb_len); ptlrpc_request_set_replen(req); - RETURN(req); + return req; } EXPORT_SYMBOL(ldlm_enqueue_pack); @@ -881,7 +881,7 @@ int ldlm_cli_enqueue(struct obd_export *exp, struct ptlrpc_request **reqp, einfo->ei_mode, &cbs, einfo->ei_cbdata, lvb_len, lvb_type); if (lock == NULL) - RETURN(-ENOMEM); + return -ENOMEM; /* for the local lock, add the reference */ ldlm_lock_addref_internal(lock, einfo->ei_mode); ldlm_lock2handle(lock, lockh); @@ -922,7 +922,7 @@ int ldlm_cli_enqueue(struct obd_export *exp, struct ptlrpc_request **reqp, if (req == NULL) { failed_lock_cleanup(ns, lock, einfo->ei_mode); LDLM_LOCK_RELEASE(lock); - RETURN(-ENOMEM); + return -ENOMEM; } req_passed_in = 0; if (reqp) @@ -963,7 +963,7 @@ int ldlm_cli_enqueue(struct obd_export *exp, struct ptlrpc_request **reqp, if (async) { LASSERT(reqp != NULL); - RETURN(0); + return 0; } LDLM_DEBUG(lock, "sending request"); @@ -987,7 +987,7 @@ int ldlm_cli_enqueue(struct obd_export *exp, struct ptlrpc_request **reqp, *reqp = NULL; } - RETURN(rc); + return rc; } EXPORT_SYMBOL(ldlm_cli_enqueue); @@ -1012,7 +1012,7 @@ static int ldlm_cli_convert_local(struct ldlm_lock *lock, int new_mode, } LDLM_DEBUG(lock, "client-side local convert handler END"); LDLM_LOCK_PUT(lock); - RETURN(rc); + return rc; } /* FIXME: one of ldlm_cli_convert or the server side should reject attempted @@ -1031,12 +1031,12 @@ int ldlm_cli_convert(struct lustre_handle *lockh, int new_mode, __u32 *flags) lock = ldlm_handle2lock(lockh); if (!lock) { LBUG(); - RETURN(-EINVAL); + return -EINVAL; } *flags = 0; if (lock->l_conn_export == NULL) - RETURN(ldlm_cli_convert_local(lock, new_mode, flags)); + return ldlm_cli_convert_local(lock, new_mode, flags); LDLM_DEBUG(lock, "client-side convert"); @@ -1045,7 +1045,7 @@ int ldlm_cli_convert(struct lustre_handle *lockh, int new_mode, __u32 *flags) LDLM_CONVERT); if (req == NULL) { LDLM_LOCK_PUT(lock); - RETURN(-ENOMEM); + return -ENOMEM; } body = req_capsule_client_get(&req->rq_pill, &RMF_DLM_REQ); @@ -1129,7 +1129,7 @@ static __u64 ldlm_cli_cancel_local(struct ldlm_lock *lock) ldlm_reprocess_all(lock->l_resource); } - RETURN(rc); + return rc; } /** @@ -1184,7 +1184,7 @@ int ldlm_cli_cancel_req(struct obd_export *exp, struct list_head *cancels, CFS_FAIL_TIMEOUT(OBD_FAIL_LDLM_PAUSE_CANCEL, cfs_fail_val); if (CFS_FAIL_CHECK(OBD_FAIL_LDLM_CANCEL_RACE)) - RETURN(count); + return count; free = ldlm_format_handles_avail(class_exp2cliimp(exp), &RQF_LDLM_CANCEL, RCL_CLIENT, 0); @@ -1196,7 +1196,7 @@ int ldlm_cli_cancel_req(struct obd_export *exp, struct list_head *cancels, if (imp == NULL || imp->imp_invalid) { CDEBUG(D_DLMTRACE, "skipping cancel on invalid import %p\n", imp); - RETURN(count); + return count; } req = ptlrpc_request_alloc(imp, &RQF_LDLM_CANCEL); @@ -1275,7 +1275,7 @@ int ldlm_cli_update_pool(struct ptlrpc_request *req) /* * Do nothing for corner cases. */ - RETURN(0); + return 0; } /* In some cases RPC may contain SLV and limit zeroed out. This @@ -1289,7 +1289,7 @@ int ldlm_cli_update_pool(struct ptlrpc_request *req) "(SLV: "LPU64", Limit: %u)", lustre_msg_get_slv(req->rq_repmsg), lustre_msg_get_limit(req->rq_repmsg)); - RETURN(0); + return 0; } new_limit = lustre_msg_get_limit(req->rq_repmsg); @@ -1306,7 +1306,7 @@ int ldlm_cli_update_pool(struct ptlrpc_request *req) obd->obd_pool_limit = new_limit; write_unlock(&obd->obd_pool_lock); - RETURN(0); + return 0; } EXPORT_SYMBOL(ldlm_cli_update_pool); @@ -1329,13 +1329,13 @@ int ldlm_cli_cancel(struct lustre_handle *lockh, lock = ldlm_handle2lock_long(lockh, LDLM_FL_CANCELING); if (lock == NULL) { LDLM_DEBUG_NOLOCK("lock is already being destroyed\n"); - RETURN(0); + return 0; } rc = ldlm_cli_cancel_local(lock); if (rc == LDLM_FL_LOCAL_ONLY) { LDLM_LOCK_RELEASE(lock); - RETURN(0); + return 0; } /* Even if the lock is marked as LDLM_FL_BL_AST, this is a LDLM_CANCEL * RPC which goes to canceld portal, so we can cancel other LRU locks @@ -1357,7 +1357,7 @@ int ldlm_cli_cancel(struct lustre_handle *lockh, LCF_BL_AST, flags); } ldlm_cli_cancel_list(&cancels, count, NULL, cancel_flags); - RETURN(0); + return 0; } EXPORT_SYMBOL(ldlm_cli_cancel); @@ -1407,7 +1407,7 @@ int ldlm_cli_cancel_list_local(struct list_head *cancels, int count, ldlm_cli_cancel_list(&head, bl_ast, NULL, 0); } - RETURN(count); + return count; } EXPORT_SYMBOL(ldlm_cli_cancel_list_local); @@ -1439,7 +1439,7 @@ static ldlm_policy_res_t ldlm_cancel_no_wait_policy(struct ldlm_namespace *ns, } unlock_res_and_lock(lock); - RETURN(result); + return result; } /** @@ -1730,7 +1730,7 @@ static int ldlm_prepare_lru_list(struct ldlm_namespace *ns, struct list_head *ca unused--; } spin_unlock(&ns->ns_lock); - RETURN(added); + return added; } int ldlm_cancel_lru_local(struct ldlm_namespace *ns, struct list_head *cancels, @@ -1764,9 +1764,9 @@ int ldlm_cancel_lru(struct ldlm_namespace *ns, int nr, count = ldlm_prepare_lru_list(ns, &cancels, nr, 0, flags); rc = ldlm_bl_to_thread_list(ns, NULL, &cancels, count, cancel_flags); if (rc == 0) - RETURN(count); + return count; - RETURN(0); + return 0; } /** @@ -1822,7 +1822,7 @@ int ldlm_cancel_resource_local(struct ldlm_resource *res, } unlock_res(res); - RETURN(ldlm_cli_cancel_list_local(cancels, count, cancel_flags)); + return ldlm_cli_cancel_list_local(cancels, count, cancel_flags); } EXPORT_SYMBOL(ldlm_cancel_resource_local); @@ -1843,7 +1843,7 @@ int ldlm_cli_cancel_list(struct list_head *cancels, int count, int res = 0; if (list_empty(cancels) || count == 0) - RETURN(0); + return 0; /* XXX: requests (both batched and not) could be sent in parallel. * Usually it is enough to have just 1 RPC, but it is possible that @@ -1879,7 +1879,7 @@ int ldlm_cli_cancel_list(struct list_head *cancels, int count, ldlm_lock_list_put(cancels, l_bl_ast, res); } LASSERT(count == 0); - RETURN(0); + return 0; } EXPORT_SYMBOL(ldlm_cli_cancel_list); @@ -1904,7 +1904,7 @@ int ldlm_cli_cancel_unused_resource(struct ldlm_namespace *ns, if (res == NULL) { /* This is not a problem. */ CDEBUG(D_INFO, "No resource "LPU64"\n", res_id->name[0]); - RETURN(0); + return 0; } LDLM_RESOURCE_ADDREF(res); @@ -1916,7 +1916,7 @@ int ldlm_cli_cancel_unused_resource(struct ldlm_namespace *ns, LDLM_RESOURCE_DELREF(res); ldlm_resource_putref(res); - RETURN(0); + return 0; } EXPORT_SYMBOL(ldlm_cli_cancel_unused_resource); @@ -1959,16 +1959,16 @@ int ldlm_cli_cancel_unused(struct ldlm_namespace *ns, }; if (ns == NULL) - RETURN(ELDLM_OK); + return ELDLM_OK; if (res_id != NULL) { - RETURN(ldlm_cli_cancel_unused_resource(ns, res_id, NULL, + return ldlm_cli_cancel_unused_resource(ns, res_id, NULL, LCK_MINMODE, flags, - opaque)); + opaque); } else { cfs_hash_for_each_nolock(ns->ns_rs_hash, ldlm_cli_hash_cancel_unused, &arg); - RETURN(ELDLM_OK); + return ELDLM_OK; } } EXPORT_SYMBOL(ldlm_cli_cancel_unused); @@ -1983,7 +1983,7 @@ int ldlm_resource_foreach(struct ldlm_resource *res, ldlm_iterator_t iter, int rc = LDLM_ITER_CONTINUE; if (!res) - RETURN(LDLM_ITER_CONTINUE); + return LDLM_ITER_CONTINUE; lock_res(res); list_for_each_safe(tmp, next, &res->lr_granted) { @@ -2008,7 +2008,7 @@ int ldlm_resource_foreach(struct ldlm_resource *res, ldlm_iterator_t iter, } out: unlock_res(res); - RETURN(rc); + return rc; } EXPORT_SYMBOL(ldlm_resource_foreach); @@ -2067,13 +2067,13 @@ int ldlm_resource_iterate(struct ldlm_namespace *ns, res = ldlm_resource_get(ns, NULL, res_id, 0, 0); if (res == NULL) - RETURN(0); + return 0; LDLM_RESOURCE_ADDREF(res); rc = ldlm_resource_foreach(res, iter, data); LDLM_RESOURCE_DELREF(res); ldlm_resource_putref(res); - RETURN(rc); + return rc; } EXPORT_SYMBOL(ldlm_resource_iterate); @@ -2147,7 +2147,7 @@ static int replay_lock_interpret(const struct lu_env *env, if (rc != ELDLM_OK) ptlrpc_connect_import(req->rq_import); - RETURN(rc); + return rc; } static int replay_one_lock(struct obd_import *imp, struct ldlm_lock *lock) @@ -2160,7 +2160,7 @@ static int replay_one_lock(struct obd_import *imp, struct ldlm_lock *lock) /* Bug 11974: Do not replay a lock which is actively being canceled */ if (lock->l_flags & LDLM_FL_CANCELING) { LDLM_DEBUG(lock, "Not replaying canceled lock:"); - RETURN(0); + return 0; } /* If this is reply-less callback lock, we cannot replay it, since @@ -2169,7 +2169,7 @@ static int replay_one_lock(struct obd_import *imp, struct ldlm_lock *lock) if (lock->l_flags & LDLM_FL_CANCEL_ON_BLOCK) { LDLM_DEBUG(lock, "Not replaying reply-less lock:"); ldlm_lock_cancel(lock); - RETURN(0); + return 0; } /* @@ -2198,7 +2198,7 @@ static int replay_one_lock(struct obd_import *imp, struct ldlm_lock *lock) req = ptlrpc_request_alloc_pack(imp, &RQF_LDLM_ENQUEUE, LUSTRE_DLM_VERSION, LDLM_ENQUEUE); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; /* We're part of recovery, so don't wait for it. */ req->rq_send_state = LUSTRE_IMP_REPLAY_LOCKS; @@ -2228,7 +2228,7 @@ static int replay_one_lock(struct obd_import *imp, struct ldlm_lock *lock) req->rq_interpret_reply = (ptlrpc_interpterer_t)replay_lock_interpret; ptlrpcd_add_req(req, PDL_POLICY_LOCAL, -1); - RETURN(0); + return 0; } /** @@ -2271,7 +2271,7 @@ int ldlm_replay_locks(struct obd_import *imp) /* don't replay locks if import failed recovery */ if (imp->imp_vbr_failed) - RETURN(0); + return 0; /* ensure this doesn't fall to 0 before all have been queued */ atomic_inc(&imp->imp_replay_inflight); @@ -2293,6 +2293,6 @@ int ldlm_replay_locks(struct obd_import *imp) atomic_dec(&imp->imp_replay_inflight); - RETURN(rc); + return rc; } EXPORT_SYMBOL(ldlm_replay_locks); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index f4d367c5978f9..78327cf400724 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -78,7 +78,7 @@ static ssize_t lprocfs_wr_dump_ns(struct file *file, const char *buffer, { ldlm_dump_all_namespaces(LDLM_NAMESPACE_SERVER, D_DLMTRACE); ldlm_dump_all_namespaces(LDLM_NAMESPACE_CLIENT, D_DLMTRACE); - RETURN(count); + return count; } LPROC_SEQ_FOPS_WR_ONLY(ldlm, dump_ns); @@ -126,7 +126,7 @@ int ldlm_proc_setup(void) rc = lprocfs_add_vars(ldlm_type_proc_dir, list, NULL); - RETURN(0); + return 0; err_ns: lprocfs_remove(&ldlm_ns_proc_dir); @@ -136,7 +136,7 @@ int ldlm_proc_setup(void) ldlm_svc_proc_dir = NULL; ldlm_type_proc_dir = NULL; ldlm_ns_proc_dir = NULL; - RETURN(rc); + return rc; } void ldlm_proc_cleanup(void) @@ -573,7 +573,7 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name, rc = ldlm_get_ref(); if (rc) { CERROR("ldlm_get_ref failed: %d\n", rc); - RETURN(NULL); + return NULL; } for (idx = 0;;idx++) { @@ -647,7 +647,7 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name, } ldlm_namespace_register(ns, client); - RETURN(ns); + return ns; out_proc: ldlm_namespace_proc_unregister(ns); ldlm_namespace_cleanup(ns, 0); @@ -657,7 +657,7 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name, OBD_FREE_PTR(ns); out_ref: ldlm_put_ref(); - RETURN(NULL); + return NULL; } EXPORT_SYMBOL(ldlm_namespace_new); @@ -837,13 +837,13 @@ static int __ldlm_namespace_free(struct ldlm_namespace *ns, int force) "with %d resources in use, (rc=%d)\n", ldlm_ns_name(ns), atomic_read(&ns->ns_bref), rc); - RETURN(ELDLM_NAMESPACE_EXISTS); + return ELDLM_NAMESPACE_EXISTS; } CDEBUG(D_DLMTRACE, "dlm namespace %s free done waiting\n", ldlm_ns_name(ns)); } - RETURN(ELDLM_OK); + return ELDLM_OK; } /** diff --git a/drivers/staging/lustre/lustre/libcfs/debug.c b/drivers/staging/lustre/lustre/libcfs/debug.c index 20682d8e7f2a5..cf93b6c6d906a 100644 --- a/drivers/staging/lustre/lustre/libcfs/debug.c +++ b/drivers/staging/lustre/lustre/libcfs/debug.c @@ -458,14 +458,6 @@ void libcfs_debug_set_level(unsigned int debug_level) EXPORT_SYMBOL(libcfs_debug_set_level); -long libcfs_log_return(struct libcfs_debug_msg_data *msgdata, long rc) -{ - libcfs_debug_msg(msgdata, "Process leaving (rc=%lu : %ld : %lx)\n", - rc, rc, rc); - return rc; -} -EXPORT_SYMBOL(libcfs_log_return); - void libcfs_log_goto(struct libcfs_debug_msg_data *msgdata, const char *label, long_ptr_t rc) { diff --git a/drivers/staging/lustre/lustre/libcfs/hash.c b/drivers/staging/lustre/lustre/libcfs/hash.c index 87f52563eab0b..0dd12c8c91b61 100644 --- a/drivers/staging/lustre/lustre/libcfs/hash.c +++ b/drivers/staging/lustre/lustre/libcfs/hash.c @@ -1053,7 +1053,7 @@ cfs_hash_create(char *name, unsigned cur_bits, unsigned max_bits, CFS_HASH_NAME_LEN : CFS_HASH_BIGNAME_LEN; LIBCFS_ALLOC(hs, offsetof(cfs_hash_t, hs_name[len])); if (hs == NULL) - RETURN(NULL); + return NULL; strncpy(hs->hs_name, name, len); hs->hs_name[len - 1] = '\0'; @@ -1085,7 +1085,7 @@ cfs_hash_create(char *name, unsigned cur_bits, unsigned max_bits, return hs; LIBCFS_FREE(hs, offsetof(cfs_hash_t, hs_name[len])); - RETURN(NULL); + return NULL; } EXPORT_SYMBOL(cfs_hash_create); @@ -1483,7 +1483,7 @@ cfs_hash_for_each_tight(cfs_hash_t *hs, cfs_hash_for_each_cb_t func, cfs_hash_unlock(hs, 0); cfs_hash_for_each_exit(hs); - RETURN(count); + return count; } typedef struct { @@ -1645,18 +1645,18 @@ cfs_hash_for_each_nolock(cfs_hash_t *hs, if (cfs_hash_with_no_lock(hs) || cfs_hash_with_rehash_key(hs) || !cfs_hash_with_no_itemref(hs)) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; if (CFS_HOP(hs, get) == NULL || (CFS_HOP(hs, put) == NULL && CFS_HOP(hs, put_locked) == NULL)) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; cfs_hash_for_each_enter(hs); cfs_hash_for_each_relax(hs, func, data); cfs_hash_for_each_exit(hs); - RETURN(0); + return 0; } EXPORT_SYMBOL(cfs_hash_for_each_nolock); @@ -1691,7 +1691,7 @@ cfs_hash_for_each_empty(cfs_hash_t *hs, hs->hs_name, i++); } cfs_hash_for_each_exit(hs); - RETURN(0); + return 0; } EXPORT_SYMBOL(cfs_hash_for_each_empty); diff --git a/drivers/staging/lustre/lustre/libcfs/kernel_user_comm.c b/drivers/staging/lustre/lustre/libcfs/kernel_user_comm.c index 39cf56a09247a..74a0db5c154a5 100644 --- a/drivers/staging/lustre/lustre/libcfs/kernel_user_comm.c +++ b/drivers/staging/lustre/lustre/libcfs/kernel_user_comm.c @@ -248,7 +248,7 @@ int libcfs_kkuc_group_rem(int uid, int group) struct kkuc_reg *reg, *next; if (kkuc_groups[group].next == NULL) - RETURN(0); + return 0; if (uid == 0) { /* Broadcast a shutdown message */ @@ -274,7 +274,7 @@ int libcfs_kkuc_group_rem(int uid, int group) } up_write(&kg_sem); - RETURN(0); + return 0; } EXPORT_SYMBOL(libcfs_kkuc_group_rem); @@ -303,7 +303,7 @@ int libcfs_kkuc_group_put(int group, void *payload) if (one_success) rc = 0; - RETURN(rc); + return rc; } EXPORT_SYMBOL(libcfs_kkuc_group_put); @@ -321,12 +321,12 @@ int libcfs_kkuc_group_foreach(int group, libcfs_kkuc_cb_t cb_func, if (group > KUC_GRP_MAX) { CDEBUG(D_WARNING, "Kernelcomm: bad group %d\n", group); - RETURN(-EINVAL); + return -EINVAL; } /* no link for this group */ if (kkuc_groups[group].next == NULL) - RETURN(0); + return 0; down_read(&kg_sem); list_for_each_entry(reg, &kkuc_groups[group], kr_chain) { @@ -336,7 +336,7 @@ int libcfs_kkuc_group_foreach(int group, libcfs_kkuc_cb_t cb_func, } up_read(&kg_sem); - RETURN(rc); + return rc; } EXPORT_SYMBOL(libcfs_kkuc_group_foreach); diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c index 833c889348e26..ea9e9490031fc 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-curproc.c @@ -215,12 +215,12 @@ int cfs_get_environ(const char *key, char *value, int *val_len) buffer = kmalloc(buf_len, GFP_USER); if (!buffer) - RETURN(-ENOMEM); + return -ENOMEM; mm = get_task_mm(current); if (!mm) { kfree(buffer); - RETURN(-EINVAL); + return -EINVAL; } /* Avoid deadlocks on mmap_sem if called from sys_mmap_pgoff(), diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c index 004ff71663af4..55296a3591d51 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c @@ -51,31 +51,31 @@ int libcfs_ioctl_getdata(char *buf, char *end, void *arg) err = copy_from_user(buf, (void *)arg, sizeof(*hdr)); if (err) - RETURN(err); + return err; if (hdr->ioc_version != LIBCFS_IOCTL_VERSION) { CERROR("PORTALS: version mismatch kernel vs application\n"); - RETURN(-EINVAL); + return -EINVAL; } if (hdr->ioc_len + buf >= end) { CERROR("PORTALS: user buffer exceeds kernel buffer\n"); - RETURN(-EINVAL); + return -EINVAL; } if (hdr->ioc_len < sizeof(struct libcfs_ioctl_data)) { CERROR("PORTALS: user buffer too small for ioctl\n"); - RETURN(-EINVAL); + return -EINVAL; } err = copy_from_user(buf, (void *)arg, hdr->ioc_len); if (err) - RETURN(err); + return err; if (libcfs_ioctl_is_invalid(data)) { CERROR("PORTALS: ioctl not correctly formatted\n"); - RETURN(-EINVAL); + return -EINVAL; } if (data->ioc_inllen1) @@ -85,7 +85,7 @@ int libcfs_ioctl_getdata(char *buf, char *end, void *arg) data->ioc_inlbuf2 = &data->ioc_bulk[0] + cfs_size_round(data->ioc_inllen1); - RETURN(0); + return 0; } int libcfs_ioctl_popdata(void *arg, void *data, int size) diff --git a/drivers/staging/lustre/lustre/libcfs/module.c b/drivers/staging/lustre/lustre/libcfs/module.c index 2a6db77bd0622..432b55d3216c8 100644 --- a/drivers/staging/lustre/lustre/libcfs/module.c +++ b/drivers/staging/lustre/lustre/libcfs/module.c @@ -165,7 +165,7 @@ static int libcfs_psdev_open(unsigned long flags, void *args) } *(struct libcfs_device_userstate **)args = ldu; - RETURN(0); + return 0; } /* called when closing /dev/device */ @@ -180,7 +180,7 @@ static int libcfs_psdev_release(unsigned long flags, void *args) } module_put(THIS_MODULE); - RETURN(0); + return 0; } static struct rw_semaphore ioctl_list_sem; @@ -224,7 +224,7 @@ static int libcfs_ioctl_int(struct cfs_psdev_file *pfile,unsigned long cmd, switch (cmd) { case IOC_LIBCFS_CLEAR_DEBUG: libcfs_debug_clear_buffer(); - RETURN(0); + return 0; /* * case IOC_LIBCFS_PANIC: * Handled in arch/cfs_module.c @@ -232,9 +232,9 @@ static int libcfs_ioctl_int(struct cfs_psdev_file *pfile,unsigned long cmd, case IOC_LIBCFS_MARK_DEBUG: if (data->ioc_inlbuf1 == NULL || data->ioc_inlbuf1[data->ioc_inllen1 - 1] != '\0') - RETURN(-EINVAL); + return -EINVAL; libcfs_debug_mark_buffer(data->ioc_inlbuf1); - RETURN(0); + return 0; #if LWT_SUPPORT case IOC_LIBCFS_LWT_CONTROL: err = lwt_control ((data->ioc_flags & 1) != 0, @@ -298,7 +298,7 @@ static int libcfs_ioctl_int(struct cfs_psdev_file *pfile,unsigned long cmd, ping(data); symbol_put(kping_client); } - RETURN(0); + return 0; } default: { @@ -319,7 +319,7 @@ static int libcfs_ioctl_int(struct cfs_psdev_file *pfile,unsigned long cmd, } } - RETURN(err); + return err; } static int libcfs_ioctl(struct cfs_psdev_file *pfile, unsigned long cmd, void *arg) @@ -330,7 +330,7 @@ static int libcfs_ioctl(struct cfs_psdev_file *pfile, unsigned long cmd, void *a LIBCFS_ALLOC_GFP(buf, 1024, GFP_IOFS); if (buf == NULL) - RETURN(-ENOMEM); + return -ENOMEM; /* 'cmd' and permissions get checked in our arch-specific caller */ if (libcfs_ioctl_getdata(buf, buf + 800, (void *)arg)) { @@ -343,7 +343,7 @@ static int libcfs_ioctl(struct cfs_psdev_file *pfile, unsigned long cmd, void *a out: LIBCFS_FREE(buf, 1024); - RETURN(err); + return err; } diff --git a/drivers/staging/lustre/lustre/libcfs/nidstrings.c b/drivers/staging/lustre/lustre/libcfs/nidstrings.c index 0260e69a14dd3..99c9e9d2493ff 100644 --- a/drivers/staging/lustre/lustre/libcfs/nidstrings.c +++ b/drivers/staging/lustre/lustre/libcfs/nidstrings.c @@ -793,15 +793,15 @@ cfs_parse_nidlist(char *str, int len, struct list_head *nidlist) rc = cfs_gettok(&src, ' ', &res); if (rc == 0) { cfs_free_nidlist(nidlist); - RETURN(0); + return 0; } rc = parse_nidrange(&res, nidlist); if (rc == 0) { cfs_free_nidlist(nidlist); - RETURN(0); + return 0; } } - RETURN(1); + return 1; } /* @@ -840,13 +840,13 @@ int cfs_match_nid(lnet_nid_t nid, struct list_head *nidlist) if (nr->nr_netnum != LNET_NETNUM(LNET_NIDNET(nid))) continue; if (nr->nr_all) - RETURN(1); + return 1; list_for_each_entry(ar, &nr->nr_addrranges, ar_link) if (nr->nr_netstrfns->nf_match_addr(LNET_NIDADDR(nid), &ar->ar_numaddr_ranges)) - RETURN(1); + return 1; } - RETURN(0); + return 0; } diff --git a/drivers/staging/lustre/lustre/libcfs/upcall_cache.c b/drivers/staging/lustre/lustre/libcfs/upcall_cache.c index 9b15c7c4e4462..245b46f0dd960 100644 --- a/drivers/staging/lustre/lustre/libcfs/upcall_cache.c +++ b/drivers/staging/lustre/lustre/libcfs/upcall_cache.c @@ -175,7 +175,7 @@ struct upcall_cache_entry *upcall_cache_get_entry(struct upcall_cache *cache, new = alloc_entry(cache, key, args); if (!new) { CERROR("fail to alloc entry\n"); - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); } goto find_again; } else { @@ -265,7 +265,7 @@ struct upcall_cache_entry *upcall_cache_get_entry(struct upcall_cache *cache, /* Now we know it's good */ out: spin_unlock(&cache->uc_lock); - RETURN(entry); + return entry; } EXPORT_SYMBOL(upcall_cache_get_entry); @@ -308,7 +308,7 @@ int upcall_cache_downcall(struct upcall_cache *cache, __u32 err, __u64 key, cache->uc_name, key); /* haven't found, it's possible */ spin_unlock(&cache->uc_lock); - RETURN(-EINVAL); + return -EINVAL; } if (err) { @@ -350,7 +350,7 @@ int upcall_cache_downcall(struct upcall_cache *cache, __u32 err, __u64 key, wake_up_all(&entry->ue_waitq); put_entry(cache, entry); - RETURN(rc); + return rc; } EXPORT_SYMBOL(upcall_cache_downcall); @@ -425,7 +425,7 @@ struct upcall_cache *upcall_cache_init(const char *name, const char *upcall, LIBCFS_ALLOC(cache, sizeof(*cache)); if (!cache) - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); spin_lock_init(&cache->uc_lock); rwlock_init(&cache->uc_upcall_rwlock); @@ -438,7 +438,7 @@ struct upcall_cache *upcall_cache_init(const char *name, const char *upcall, cache->uc_acquire_expire = 30; cache->uc_ops = ops; - RETURN(cache); + return cache; } EXPORT_SYMBOL(upcall_cache_init); diff --git a/drivers/staging/lustre/lustre/llite/dcache.c b/drivers/staging/lustre/lustre/llite/dcache.c index ff74783ef9d3c..e7629be39739b 100644 --- a/drivers/staging/lustre/lustre/llite/dcache.c +++ b/drivers/staging/lustre/lustre/llite/dcache.c @@ -86,10 +86,10 @@ int ll_dcompare(const struct dentry *parent, const struct dentry *dentry, unsigned int len, const char *str, const struct qstr *name) { if (len != name->len) - RETURN(1); + return 1; if (memcmp(str, name->name, len)) - RETURN(1); + return 1; CDEBUG(D_DENTRY, "found name %.*s(%p) flags %#x refc %d\n", name->len, name->name, dentry, dentry->d_flags, @@ -97,12 +97,12 @@ int ll_dcompare(const struct dentry *parent, const struct dentry *dentry, /* mountpoint is always valid */ if (d_mountpoint((struct dentry *)dentry)) - RETURN(0); + return 0; if (d_lustre_invalid(dentry)) - RETURN(1); + return 1; - RETURN(0); + return 0; } static inline int return_if_equal(struct ldlm_lock *lock, void *data) @@ -128,16 +128,16 @@ static int find_cbdata(struct inode *inode) rc = md_find_cbdata(sbi->ll_md_exp, ll_inode2fid(inode), return_if_equal, NULL); if (rc != 0) - RETURN(rc); + return rc; lsm = ccc_inode_lsm_get(inode); if (lsm == NULL) - RETURN(rc); + return rc; rc = obd_find_cbdata(sbi->ll_dt_exp, lsm, return_if_equal, NULL); ccc_inode_lsm_put(inode, lsm); - RETURN(rc); + return rc; } /** @@ -172,8 +172,8 @@ static int ll_ddelete(const struct dentry *de) #endif if (d_lustre_invalid((struct dentry *)de)) - RETURN(1); - RETURN(0); + return 1; + return 0; } static int ll_set_dd(struct dentry *de) @@ -196,11 +196,11 @@ static int ll_set_dd(struct dentry *de) OBD_FREE_PTR(lld); spin_unlock(&de->d_lock); } else { - RETURN(-ENOMEM); + return -ENOMEM; } } - RETURN(0); + return 0; } int ll_dops_init(struct dentry *de, int block, int init_sa) @@ -304,14 +304,14 @@ int ll_revalidate_it_finish(struct ptlrpc_request *request, int rc = 0; if (!request) - RETURN(0); + return 0; if (it_disposition(it, DISP_LOOKUP_NEG)) - RETURN(-ENOENT); + return -ENOENT; rc = ll_prep_inode(&de->d_inode, request, NULL, it); - RETURN(rc); + return rc; } void ll_lookup_finish_locks(struct lookup_intent *it, struct dentry *dentry) @@ -368,10 +368,10 @@ int ll_revalidate_it(struct dentry *de, int lookup_flags, away this negative dentry and actually do the request to kernel to create whatever needs to be created (if possible)*/ if (it && (it->it_op & IT_CREAT)) - RETURN(0); + return 0; if (d_lustre_invalid(de)) - RETURN(0); + return 0; ibits = MDS_INODELOCK_UPDATE; rc = ll_have_md_lock(parent, &ibits, LCK_MINMODE); @@ -398,7 +398,7 @@ int ll_revalidate_it(struct dentry *de, int lookup_flags, LASSERT(it); if (it->it_op == IT_LOOKUP && !d_lustre_invalid(de)) - RETURN(1); + return 1; if (it->it_op == IT_OPEN) { struct inode *inode = de->d_inode; @@ -445,7 +445,7 @@ int ll_revalidate_it(struct dentry *de, int lookup_flags, if it would be, we'll reopen the open request to MDS later during file open path */ mutex_unlock(&lli->lli_och_mutex); - RETURN(1); + return 1; } else { mutex_unlock(&lli->lli_och_mutex); } @@ -464,7 +464,7 @@ int ll_revalidate_it(struct dentry *de, int lookup_flags, de->d_name.name, de->d_name.len, 0, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); if (!IS_POSIXACL(parent) || !exp_connect_umask(exp)) it->it_create_mode &= ~current_umask(); @@ -551,7 +551,7 @@ int ll_revalidate_it(struct dentry *de, int lookup_flags, mark: if (it != NULL && it->it_op == IT_GETATTR && rc > 0) ll_statahead_mark(parent, de); - RETURN(rc); + return rc; /* * This part is here to combat evil-evil race in real_lookup on 2.6 @@ -583,7 +583,7 @@ int ll_revalidate_it(struct dentry *de, int lookup_flags, LUSTRE_OPC_CREATE : LUSTRE_OPC_ANY), NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); rc = md_intent_lock(exp, op_data, NULL, 0, it, 0, &req, ll_md_blocking_ast, 0); @@ -630,7 +630,7 @@ int ll_revalidate_nd(struct dentry *dentry, unsigned int flags) if (!(flags & (LOOKUP_PARENT|LOOKUP_OPEN|LOOKUP_CREATE)) && ll_need_statahead(parent, dentry) > 0) { if (flags & LOOKUP_RCU) - RETURN(-ECHILD); + return -ECHILD; if (dentry->d_inode == NULL) unplug = 1; @@ -638,7 +638,7 @@ int ll_revalidate_nd(struct dentry *dentry, unsigned int flags) ll_statahead_mark(parent, dentry); } - RETURN(1); + return 1; } diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index 09bdd3d1e6e65..09844be5eec4f 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -589,7 +589,7 @@ int ll_dir_read(struct inode *inode, struct dir_context *ctx) ctx->pos = pos; ll_dir_chain_fini(&chain); - RETURN(rc); + return rc; } static int ll_readdir(struct file *filp, struct dir_context *ctx) @@ -629,7 +629,7 @@ static int ll_readdir(struct file *filp, struct dir_context *ctx) if (!rc) ll_stats_ops_tally(sbi, LPROC_LL_READDIR, 1); - RETURN(rc); + return rc; } int ll_send_mgc_param(struct obd_export *mgc, char *string) @@ -716,7 +716,7 @@ int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump, " %#08x != %#08x nor %#08x\n", lump->lmm_magic, LOV_USER_MAGIC_V1, LOV_USER_MAGIC_V3); - RETURN(-EINVAL); + return -EINVAL; } } } else { @@ -726,7 +726,7 @@ int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump, op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); if (lump != NULL && lump->lmm_magic == cpu_to_le32(LMV_USER_MAGIC)) op_data->op_cli_flags |= CLI_SET_MEA; @@ -782,7 +782,7 @@ int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump, if (param != NULL) OBD_FREE(param, MGS_PARAM_MAXLEN); } - RETURN(rc); + return rc; } int ll_dir_getstripe(struct inode *inode, struct lov_mds_md **lmmp, @@ -797,13 +797,13 @@ int ll_dir_getstripe(struct inode *inode, struct lov_mds_md **lmmp, rc = ll_get_max_mdsize(sbi, &lmmsize); if (rc) - RETURN(rc); + return rc; op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, lmmsize, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); op_data->op_valid = OBD_MD_FLEASIZE | OBD_MD_FLDIREA; rc = md_getattr(sbi->ll_md_exp, op_data, &req); @@ -867,7 +867,7 @@ int ll_get_mdt_idx(struct inode *inode) op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); op_data->op_flags |= MF_GET_MDT_IDX; rc = md_getattr(sbi->ll_md_exp, op_data, NULL); @@ -875,7 +875,7 @@ int ll_get_mdt_idx(struct inode *inode) ll_finish_md_op_data(op_data); if (rc < 0) { CDEBUG(D_INFO, "md_getattr_name: %d\n", rc); - RETURN(rc); + return rc; } return mdtidx; } @@ -945,7 +945,7 @@ static int ll_ioc_copy_start(struct super_block *sb, struct hsm_copy *copy) rc = obd_iocontrol(LL_IOC_HSM_PROGRESS, sbi->ll_md_exp, sizeof(hpk), &hpk, NULL); - RETURN(rc); + return rc; } /** @@ -1044,7 +1044,7 @@ static int ll_ioc_copy_end(struct super_block *sb, struct hsm_copy *copy) rc = obd_iocontrol(LL_IOC_HSM_PROGRESS, sbi->ll_md_exp, sizeof(hpk), &hpk, NULL); - RETURN(rc); + return rc; } @@ -1082,7 +1082,7 @@ static int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl) case Q_SETINFO: if (!cfs_capable(CFS_CAP_SYS_ADMIN) || sbi->ll_flags & LL_SBI_RMT_CLIENT) - RETURN(-EPERM); + return -EPERM; break; case Q_GETQUOTA: if (((type == USRQUOTA && @@ -1091,25 +1091,25 @@ static int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl) !in_egroup_p(make_kgid(&init_user_ns, id)))) && (!cfs_capable(CFS_CAP_SYS_ADMIN) || sbi->ll_flags & LL_SBI_RMT_CLIENT)) - RETURN(-EPERM); + return -EPERM; break; case Q_GETINFO: break; default: CERROR("unsupported quotactl op: %#x\n", cmd); - RETURN(-ENOTTY); + return -ENOTTY; } if (valid != QC_GENERAL) { if (sbi->ll_flags & LL_SBI_RMT_CLIENT) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; if (cmd == Q_GETINFO) qctl->qc_cmd = Q_GETOINFO; else if (cmd == Q_GETQUOTA) qctl->qc_cmd = Q_GETOQUOTA; else - RETURN(-EINVAL); + return -EINVAL; switch (valid) { case QC_MDTIDX: @@ -1134,7 +1134,7 @@ static int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl) } if (rc) - RETURN(rc); + return rc; qctl->qc_cmd = cmd; } else { @@ -1142,7 +1142,7 @@ static int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl) OBD_ALLOC_PTR(oqctl); if (oqctl == NULL) - RETURN(-ENOMEM); + return -ENOMEM; QCTL_COPY(oqctl, qctl); rc = obd_quotactl(sbi->ll_md_exp, oqctl); @@ -1152,7 +1152,7 @@ static int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl) obd_quotactl(sbi->ll_md_exp, oqctl); } OBD_FREE_PTR(oqctl); - RETURN(rc); + return rc; } /* If QIF_SPACE is not set, client should collect the * space usage from OSSs by itself */ @@ -1199,7 +1199,7 @@ static int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl) OBD_FREE_PTR(oqctl); } - RETURN(rc); + return rc; } static char * @@ -1244,10 +1244,10 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) switch(cmd) { case FSFILT_IOC_GETFLAGS: case FSFILT_IOC_SETFLAGS: - RETURN(ll_iocontrol(inode, file, cmd, arg)); + return ll_iocontrol(inode, file, cmd, arg); case FSFILT_IOC_GETVERSION_OLD: case FSFILT_IOC_GETVERSION: - RETURN(put_user(inode->i_generation, (int *)arg)); + return put_user(inode->i_generation, (int *)arg); /* We need to special case any other ioctls we want to handle, * to send them to the MDS/OST as appropriate and to properly * network encode the arg field. @@ -1259,10 +1259,10 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) mdtidx = ll_get_mdt_idx(inode); if (mdtidx < 0) - RETURN(mdtidx); + return mdtidx; if (put_user((int)mdtidx, (int*)arg)) - RETURN(-EFAULT); + return -EFAULT; return 0; } @@ -1275,7 +1275,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) rc = obd_ioctl_getdata(&buf, &len, (void *)arg); if (rc) - RETURN(rc); + return rc; data = (void *)buf; filename = data->ioc_inlbuf1; @@ -1314,7 +1314,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) rc = obd_ioctl_getdata(&buf, &len, (void *)arg); if (rc) - RETURN(rc); + return rc; data = (void *)buf; if (data->ioc_inlbuf1 == NULL || data->ioc_inlbuf2 == NULL || @@ -1345,7 +1345,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) rc = ll_dir_setdirstripe(inode, lum, filename); lmv_out_free: obd_ioctl_freedata(buf, len); - RETURN(rc); + return rc; } case LL_IOC_LOV_SETSTRIPE: { @@ -1361,11 +1361,11 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) sizeof(lumv3p->lmm_objects[0])); /* first try with v1 which is smaller than v3 */ if (copy_from_user(lumv1, lumv1p, sizeof(*lumv1))) - RETURN(-EFAULT); + return -EFAULT; if ((lumv1->lmm_magic == LOV_USER_MAGIC_V3) ) { if (copy_from_user(&lumv3, lumv3p, sizeof(lumv3))) - RETURN(-EFAULT); + return -EFAULT; } if (inode->i_sb->s_root == file->f_dentry) @@ -1374,7 +1374,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) /* in v1 and v3 cases lumv1 points to data */ rc = ll_dir_setstripe(inode, lumv1, set_default); - RETURN(rc); + return rc; } case LL_IOC_LMV_GETSTRIPE: { struct lmv_user_md *lump = (struct lmv_user_md *)arg; @@ -1385,10 +1385,10 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) int mdtindex; if (copy_from_user(&lum, lump, sizeof(struct lmv_user_md))) - RETURN(-EFAULT); + return -EFAULT; if (lum.lum_magic != LMV_MAGIC_V1) - RETURN(-EINVAL); + return -EINVAL; lum_size = lmv_user_md_size(1, LMV_MAGIC_V1); OBD_ALLOC(tmp, lum_size); @@ -1411,7 +1411,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) free_lmv: if (tmp) OBD_FREE(tmp, lum_size); - RETURN(rc); + return rc; } case LL_IOC_REMOVE_ENTRY: { char *filename = NULL; @@ -1428,7 +1428,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) filename = ll_getname((const char *)arg); if (IS_ERR(filename)) - RETURN(PTR_ERR(filename)); + return PTR_ERR(filename); namelen = strlen(filename); if (namelen < 1) @@ -1438,12 +1438,12 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) out_rmdir: if (filename) ll_putname(filename); - RETURN(rc); + return rc; } case LL_IOC_LOV_SWAP_LAYOUTS: - RETURN(-EPERM); + return -EPERM; case LL_IOC_OBD_STATFS: - RETURN(ll_obd_statfs(inode, (void *)arg)); + return ll_obd_statfs(inode, (void *)arg); case LL_IOC_LOV_GETSTRIPE: case LL_IOC_MDC_GETINFO: case IOC_MDC_GETFILEINFO: @@ -1459,7 +1459,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) cmd == IOC_MDC_GETFILESTRIPE) { filename = ll_getname((const char *)arg); if (IS_ERR(filename)) - RETURN(PTR_ERR(filename)); + return PTR_ERR(filename); rc = ll_lov_getstripe_ea_info(inode, filename, &lmm, &lmmsize, &request); @@ -1539,11 +1539,11 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) rc = ll_get_max_mdsize(sbi, &lmmsize); if (rc) - RETURN(rc); + return rc; OBD_ALLOC_LARGE(lmm, lmmsize); if (lmm == NULL) - RETURN(-ENOMEM); + return -ENOMEM; if (copy_from_user(lmm, lum, lmmsize)) GOTO(free_lmm, rc = -EFAULT); @@ -1591,7 +1591,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) return rc; } case OBD_IOC_LLOG_CATINFO: { - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; } case OBD_IOC_QUOTACHECK: { struct obd_quotactl *oqctl; @@ -1599,11 +1599,11 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) if (!cfs_capable(CFS_CAP_SYS_ADMIN) || sbi->ll_flags & LL_SBI_RMT_CLIENT) - RETURN(-EPERM); + return -EPERM; OBD_ALLOC_PTR(oqctl); if (!oqctl) - RETURN(-ENOMEM); + return -ENOMEM; oqctl->qc_type = arg; rc = obd_quotacheck(sbi->ll_md_exp, oqctl); if (rc < 0) { @@ -1623,11 +1623,11 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) if (!cfs_capable(CFS_CAP_SYS_ADMIN) || sbi->ll_flags & LL_SBI_RMT_CLIENT) - RETURN(-EPERM); + return -EPERM; OBD_ALLOC_PTR(check); if (!check) - RETURN(-ENOMEM); + return -ENOMEM; rc = obd_iocontrol(cmd, sbi->ll_md_exp, 0, (void *)check, NULL); @@ -1650,7 +1650,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) } out_poll: OBD_FREE_PTR(check); - RETURN(rc); + return rc; } #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 7, 50, 0) case LL_IOC_QUOTACTL_18: { @@ -1661,7 +1661,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) OBD_ALLOC_PTR(qctl_18); if (!qctl_18) - RETURN(-ENOMEM); + return -ENOMEM; OBD_ALLOC_PTR(qctl_20); if (!qctl_20) @@ -1701,7 +1701,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) OBD_FREE_PTR(qctl_20); out_quotactl_18: OBD_FREE_PTR(qctl_18); - RETURN(rc); + return rc; } #else #warning "remove old LL_IOC_QUOTACTL_18 compatibility code" @@ -1711,7 +1711,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) OBD_ALLOC_PTR(qctl); if (!qctl) - RETURN(-ENOMEM); + return -ENOMEM; if (copy_from_user(qctl, (void *)arg, sizeof(*qctl))) GOTO(out_quotactl, rc = -EFAULT); @@ -1723,13 +1723,13 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) out_quotactl: OBD_FREE_PTR(qctl); - RETURN(rc); + return rc; } case OBD_IOC_GETDTNAME: case OBD_IOC_GETMDNAME: - RETURN(ll_get_obd_name(inode, cmd, arg)); + return ll_get_obd_name(inode, cmd, arg); case LL_IOC_FLUSHCTX: - RETURN(ll_flush_ctx(inode)); + return ll_flush_ctx(inode); #ifdef CONFIG_FS_POSIX_ACL case LL_IOC_RMTACL: { if (sbi->ll_flags & LL_SBI_RMT_CLIENT && @@ -1740,9 +1740,9 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) rc = rct_add(&sbi->ll_rct, current_pid(), arg); if (!rc) fd->fd_flags |= LL_FILE_RMTACL; - RETURN(rc); + return rc; } else - RETURN(0); + return 0; } #endif case LL_IOC_GETOBDCOUNT: { @@ -1750,7 +1750,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) struct obd_export *exp; if (copy_from_user(&count, (int *)arg, sizeof(int))) - RETURN(-EFAULT); + return -EFAULT; /* get ost count when count is zero, get mdt count otherwise */ exp = count ? sbi->ll_md_exp : sbi->ll_dt_exp; @@ -1759,41 +1759,41 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) KEY_TGT_COUNT, &vallen, &count, NULL); if (rc) { CERROR("get target count failed: %d\n", rc); - RETURN(rc); + return rc; } if (copy_to_user((int *)arg, &count, sizeof(int))) - RETURN(-EFAULT); + return -EFAULT; - RETURN(0); + return 0; } case LL_IOC_PATH2FID: if (copy_to_user((void *)arg, ll_inode2fid(inode), sizeof(struct lu_fid))) - RETURN(-EFAULT); - RETURN(0); + return -EFAULT; + return 0; case LL_IOC_GET_CONNECT_FLAGS: { - RETURN(obd_iocontrol(cmd, sbi->ll_md_exp, 0, NULL, (void*)arg)); + return obd_iocontrol(cmd, sbi->ll_md_exp, 0, NULL, (void*)arg); } case OBD_IOC_CHANGELOG_SEND: case OBD_IOC_CHANGELOG_CLEAR: rc = copy_and_ioctl(cmd, sbi->ll_md_exp, (void *)arg, sizeof(struct ioc_changelog)); - RETURN(rc); + return rc; case OBD_IOC_FID2PATH: - RETURN(ll_fid2path(inode, (void *)arg)); + return ll_fid2path(inode, (void *)arg); case LL_IOC_HSM_REQUEST: { struct hsm_user_request *hur; int totalsize; OBD_ALLOC_PTR(hur); if (hur == NULL) - RETURN(-ENOMEM); + return -ENOMEM; /* We don't know the true size yet; copy the fixed-size part */ if (copy_from_user(hur, (void *)arg, sizeof(*hur))) { OBD_FREE_PTR(hur); - RETURN(-EFAULT); + return -EFAULT; } /* Compute the whole struct size */ @@ -1801,12 +1801,12 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) OBD_FREE_PTR(hur); OBD_ALLOC_LARGE(hur, totalsize); if (hur == NULL) - RETURN(-ENOMEM); + return -ENOMEM; /* Copy the whole struct */ if (copy_from_user(hur, (void *)arg, totalsize)) { OBD_FREE_LARGE(hur, totalsize); - RETURN(-EFAULT); + return -EFAULT; } rc = obd_iocontrol(cmd, ll_i2mdexp(inode), totalsize, @@ -1814,14 +1814,14 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) OBD_FREE_LARGE(hur, totalsize); - RETURN(rc); + return rc; } case LL_IOC_HSM_PROGRESS: { struct hsm_progress_kernel hpk; struct hsm_progress hp; if (copy_from_user(&hp, (void *)arg, sizeof(hp))) - RETURN(-EFAULT); + return -EFAULT; hpk.hpk_fid = hp.hp_fid; hpk.hpk_cookie = hp.hp_cookie; @@ -1834,12 +1834,12 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) * reported to Lustre root */ rc = obd_iocontrol(cmd, sbi->ll_md_exp, sizeof(hpk), &hpk, NULL); - RETURN(rc); + return rc; } case LL_IOC_HSM_CT_START: rc = copy_and_ioctl(cmd, sbi->ll_md_exp, (void *)arg, sizeof(struct lustre_kernelcomm)); - RETURN(rc); + return rc; case LL_IOC_HSM_COPY_START: { struct hsm_copy *copy; @@ -1847,10 +1847,10 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) OBD_ALLOC_PTR(copy); if (copy == NULL) - RETURN(-ENOMEM); + return -ENOMEM; if (copy_from_user(copy, (char *)arg, sizeof(*copy))) { OBD_FREE_PTR(copy); - RETURN(-EFAULT); + return -EFAULT; } rc = ll_ioc_copy_start(inode->i_sb, copy); @@ -1858,7 +1858,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) rc = -EFAULT; OBD_FREE_PTR(copy); - RETURN(rc); + return rc; } case LL_IOC_HSM_COPY_END: { struct hsm_copy *copy; @@ -1866,10 +1866,10 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) OBD_ALLOC_PTR(copy); if (copy == NULL) - RETURN(-ENOMEM); + return -ENOMEM; if (copy_from_user(copy, (char *)arg, sizeof(*copy))) { OBD_FREE_PTR(copy); - RETURN(-EFAULT); + return -EFAULT; } rc = ll_ioc_copy_end(inode->i_sb, copy); @@ -1877,11 +1877,10 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) rc = -EFAULT; OBD_FREE_PTR(copy); - RETURN(rc); + return rc; } default: - RETURN(obd_iocontrol(cmd, sbi->ll_dt_exp, 0, NULL, - (void *)arg)); + return obd_iocontrol(cmd, sbi->ll_dt_exp, 0, NULL, (void *)arg); } } @@ -1937,12 +1936,12 @@ static loff_t ll_dir_seek(struct file *file, loff_t offset, int origin) int ll_dir_open(struct inode *inode, struct file *file) { - RETURN(ll_file_open(inode, file)); + return ll_file_open(inode, file); } int ll_dir_release(struct inode *inode, struct file *file) { - RETURN(ll_file_release(inode, file)); + return ll_file_release(inode, file); } struct file_operations ll_dir_operations = { diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 7f5435b18b65a..253f02688f4fe 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -215,7 +215,7 @@ int ll_md_real_close(struct inode *inode, int flags) if (*och_usecount) { /* There are still users of this handle, so skip freeing it. */ mutex_unlock(&lli->lli_och_mutex); - RETURN(0); + return 0; } och=*och_p; *och_p = NULL; @@ -227,7 +227,7 @@ int ll_md_real_close(struct inode *inode, int flags) inode, och); } - RETURN(rc); + return rc; } int ll_md_close(struct obd_export *md_exp, struct inode *inode, @@ -281,7 +281,7 @@ int ll_md_close(struct obd_export *md_exp, struct inode *inode, ll_file_data_put(fd); ll_capa_close(inode); - RETURN(rc); + return rc; } /* While this returns an error code, fput() the caller does not, so we need @@ -328,7 +328,7 @@ int ll_file_release(struct inode *inode, struct file *file) if (inode->i_sb->s_root == file->f_dentry) { LUSTRE_FPRIVATE(file) = NULL; ll_file_data_put(fd); - RETURN(0); + return 0; } if (!S_ISDIR(inode->i_mode)) { @@ -341,7 +341,7 @@ int ll_file_release(struct inode *inode, struct file *file) if (CFS_FAIL_TIMEOUT_MS(OBD_FAIL_PTLRPC_DUMP_LOG, cfs_fail_val)) libcfs_debug_dumplog(); - RETURN(rc); + return rc; } static int ll_intent_file_open(struct file *file, void *lmm, @@ -357,7 +357,7 @@ static int ll_intent_file_open(struct file *file, void *lmm, int rc; if (!parent) - RETURN(-ENOENT); + return -ENOENT; /* Usually we come here only for NFSD, and we want open lock. But we can also get here with pre 2.6.15 patchless kernels, and in @@ -378,7 +378,7 @@ static int ll_intent_file_open(struct file *file, void *lmm, file->f_dentry->d_inode, name, len, O_RDWR, opc, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); itp->it_flags |= MDS_OPEN_BY_FID; rc = md_intent_lock(sbi->ll_md_exp, op_data, lmm, lmmsize, itp, @@ -414,7 +414,7 @@ static int ll_intent_file_open(struct file *file, void *lmm, it_clear_disposition(itp, DISP_ENQ_COMPLETE); ll_intent_drop_lock(itp); - RETURN(rc); + return rc; } /** @@ -468,7 +468,7 @@ int ll_local_open(struct file *file, struct lookup_intent *it, rc = ll_och_fill(ll_i2sbi(inode)->ll_md_exp, lli, it, och); if (rc) - RETURN(rc); + return rc; body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); if ((it->it_flags & FMODE_WRITE) && @@ -480,7 +480,7 @@ int ll_local_open(struct file *file, struct lookup_intent *it, LUSTRE_FPRIVATE(file) = fd; ll_readahead_init(inode, &fd->fd_ras); fd->fd_omode = it->it_flags; - RETURN(0); + return 0; } /* Open a file, and (for the very first open) create objects on the OSTs at @@ -530,7 +530,7 @@ int ll_file_open(struct inode *inode, struct file *file) if (inode->i_sb->s_root == file->f_dentry) { LUSTRE_FPRIVATE(file) = fd; - RETURN(0); + return 0; } if (!it || !it->d.lustre.it_disposition) { @@ -724,7 +724,7 @@ static int ll_lsm_getattr(struct lov_stripe_md *lsm, struct obd_export *exp, OBD_MD_FLATIME | OBD_MD_FLMTIME | OBD_MD_FLCTIME | OBD_MD_FLSIZE | OBD_MD_FLDATAVERSION); - RETURN(rc); + return rc; } /** @@ -752,7 +752,7 @@ int ll_inode_getattr(struct inode *inode, struct obdo *obdo, (unsigned long)ll_inode_blksize(inode)); } ccc_inode_lsm_put(inode, lsm); - RETURN(rc); + return rc; } int ll_merge_lvb(const struct lu_env *env, struct inode *inode) @@ -795,7 +795,7 @@ int ll_merge_lvb(const struct lu_env *env, struct inode *inode) } ll_inode_size_unlock(inode); - RETURN(rc); + return rc; } int ll_glimpse_ioctl(struct ll_sb_info *sbi, struct lov_stripe_md *lsm, @@ -973,11 +973,11 @@ static ssize_t ll_file_aio_read(struct kiocb *iocb, const struct iovec *iov, result = ll_file_get_iov_count(iov, &nr_segs, &count); if (result) - RETURN(result); + return result; env = cl_env_get(&refcheck); if (IS_ERR(env)) - RETURN(PTR_ERR(env)); + return PTR_ERR(env); args = vvp_env_args(env, IO_NORMAL); args->u.normal.via_iov = (struct iovec *)iov; @@ -987,7 +987,7 @@ static ssize_t ll_file_aio_read(struct kiocb *iocb, const struct iovec *iov, result = ll_file_io_generic(env, args, iocb->ki_filp, CIT_READ, &iocb->ki_pos, count); cl_env_put(env, &refcheck); - RETURN(result); + return result; } static ssize_t ll_file_read(struct file *file, char *buf, size_t count, @@ -1001,7 +1001,7 @@ static ssize_t ll_file_read(struct file *file, char *buf, size_t count, env = cl_env_get(&refcheck); if (IS_ERR(env)) - RETURN(PTR_ERR(env)); + return PTR_ERR(env); local_iov = &vvp_env_info(env)->vti_local_iov; kiocb = &vvp_env_info(env)->vti_kiocb; @@ -1015,7 +1015,7 @@ static ssize_t ll_file_read(struct file *file, char *buf, size_t count, *ppos = kiocb->ki_pos; cl_env_put(env, &refcheck); - RETURN(result); + return result; } /* @@ -1032,11 +1032,11 @@ static ssize_t ll_file_aio_write(struct kiocb *iocb, const struct iovec *iov, result = ll_file_get_iov_count(iov, &nr_segs, &count); if (result) - RETURN(result); + return result; env = cl_env_get(&refcheck); if (IS_ERR(env)) - RETURN(PTR_ERR(env)); + return PTR_ERR(env); args = vvp_env_args(env, IO_NORMAL); args->u.normal.via_iov = (struct iovec *)iov; @@ -1046,7 +1046,7 @@ static ssize_t ll_file_aio_write(struct kiocb *iocb, const struct iovec *iov, result = ll_file_io_generic(env, args, iocb->ki_filp, CIT_WRITE, &iocb->ki_pos, count); cl_env_put(env, &refcheck); - RETURN(result); + return result; } static ssize_t ll_file_write(struct file *file, const char *buf, size_t count, @@ -1060,7 +1060,7 @@ static ssize_t ll_file_write(struct file *file, const char *buf, size_t count, env = cl_env_get(&refcheck); if (IS_ERR(env)) - RETURN(PTR_ERR(env)); + return PTR_ERR(env); local_iov = &vvp_env_info(env)->vti_local_iov; kiocb = &vvp_env_info(env)->vti_kiocb; @@ -1074,7 +1074,7 @@ static ssize_t ll_file_write(struct file *file, const char *buf, size_t count, *ppos = kiocb->ki_pos; cl_env_put(env, &refcheck); - RETURN(result); + return result; } @@ -1093,7 +1093,7 @@ static ssize_t ll_file_splice_read(struct file *in_file, loff_t *ppos, env = cl_env_get(&refcheck); if (IS_ERR(env)) - RETURN(PTR_ERR(env)); + return PTR_ERR(env); args = vvp_env_args(env, IO_SPLICE); args->u.splice.via_pipe = pipe; @@ -1101,7 +1101,7 @@ static ssize_t ll_file_splice_read(struct file *in_file, loff_t *ppos, result = ll_file_io_generic(env, args, in_file, CIT_READ, ppos, count); cl_env_put(env, &refcheck); - RETURN(result); + return result; } static int ll_lov_recreate(struct inode *inode, struct ost_id *oi, @@ -1116,7 +1116,7 @@ static int ll_lov_recreate(struct inode *inode, struct ost_id *oi, OBDO_ALLOC(oa); if (oa == NULL) - RETURN(-ENOMEM); + return -ENOMEM; lsm = ccc_inode_lsm_get(inode); if (!lsm_has_objects(lsm)) @@ -1155,15 +1155,15 @@ static int ll_lov_recreate_obj(struct inode *inode, unsigned long arg) struct ost_id oi; if (!cfs_capable(CFS_CAP_SYS_ADMIN)) - RETURN(-EPERM); + return -EPERM; if (copy_from_user(&ucreat, (struct ll_recreate_obj *)arg, sizeof(ucreat))) - RETURN(-EFAULT); + return -EFAULT; ostid_set_seq_mdt0(&oi); ostid_set_id(&oi, ucreat.lrc_id); - RETURN(ll_lov_recreate(inode, &oi, ucreat.lrc_ost_idx)); + return ll_lov_recreate(inode, &oi, ucreat.lrc_ost_idx); } static int ll_lov_recreate_fid(struct inode *inode, unsigned long arg) @@ -1173,14 +1173,14 @@ static int ll_lov_recreate_fid(struct inode *inode, unsigned long arg) obd_count ost_idx; if (!cfs_capable(CFS_CAP_SYS_ADMIN)) - RETURN(-EPERM); + return -EPERM; if (copy_from_user(&fid, (struct lu_fid *)arg, sizeof(fid))) - RETURN(-EFAULT); + return -EFAULT; fid_to_ostid(&fid, &oi); ost_idx = (fid_seq(&fid) >> 16) & 0xffff; - RETURN(ll_lov_recreate(inode, &oi, ost_idx)); + return ll_lov_recreate(inode, &oi, ost_idx); } int ll_lov_setstripe_ea_info(struct inode *inode, struct file *file, @@ -1195,7 +1195,7 @@ int ll_lov_setstripe_ea_info(struct inode *inode, struct file *file, ccc_inode_lsm_put(inode, lsm); CDEBUG(D_IOCTL, "stripe already exists for ino %lu\n", inode->i_ino); - RETURN(-EEXIST); + return -EEXIST; } ll_inode_size_lock(inode); @@ -1212,7 +1212,7 @@ int ll_lov_setstripe_ea_info(struct inode *inode, struct file *file, ll_inode_size_unlock(inode); ll_intent_release(&oit); ccc_inode_lsm_put(inode, lsm); - RETURN(rc); + return rc; out_req_free: ptlrpc_req_finished((struct ptlrpc_request *) oit.d.lustre.it_data); goto out; @@ -1231,13 +1231,13 @@ int ll_lov_getstripe_ea_info(struct inode *inode, const char *filename, rc = ll_get_max_mdsize(sbi, &lmmsize); if (rc) - RETURN(rc); + return rc; op_data = ll_prep_md_op_data(NULL, inode, NULL, filename, strlen(filename), lmmsize, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); op_data->op_valid = OBD_MD_FLEASIZE | OBD_MD_FLDIREA; rc = md_getattr_name(sbi->ll_md_exp, op_data, &req); @@ -1312,21 +1312,21 @@ static int ll_lov_setea(struct inode *inode, struct file *file, int rc; if (!cfs_capable(CFS_CAP_SYS_ADMIN)) - RETURN(-EPERM); + return -EPERM; OBD_ALLOC_LARGE(lump, lum_size); if (lump == NULL) - RETURN(-ENOMEM); + return -ENOMEM; if (copy_from_user(lump, (struct lov_user_md *)arg, lum_size)) { OBD_FREE_LARGE(lump, lum_size); - RETURN(-EFAULT); + return -EFAULT; } rc = ll_lov_setstripe_ea_info(inode, file, flags, lump, lum_size); OBD_FREE_LARGE(lump, lum_size); - RETURN(rc); + return rc; } static int ll_lov_setstripe(struct inode *inode, struct file *file, @@ -1342,12 +1342,12 @@ static int ll_lov_setstripe(struct inode *inode, struct file *file, /* first try with v1 which is smaller than v3 */ lum_size = sizeof(struct lov_user_md_v1); if (copy_from_user(lumv1, lumv1p, lum_size)) - RETURN(-EFAULT); + return -EFAULT; if (lumv1->lmm_magic == LOV_USER_MAGIC_V3) { lum_size = sizeof(struct lov_user_md_v3); if (copy_from_user(&lumv3, lumv3p, lum_size)) - RETURN(-EFAULT); + return -EFAULT; } rc = ll_lov_setstripe_ea_info(inode, file, flags, lumv1, lum_size); @@ -1363,7 +1363,7 @@ static int ll_lov_setstripe(struct inode *inode, struct file *file, 0, lsm, (void *)arg); ccc_inode_lsm_put(inode, lsm); } - RETURN(rc); + return rc; } static int ll_lov_getstripe(struct inode *inode, unsigned long arg) @@ -1376,7 +1376,7 @@ static int ll_lov_getstripe(struct inode *inode, unsigned long arg) rc = obd_iocontrol(LL_IOC_LOV_GETSTRIPE, ll_i2dtexp(inode), 0, lsm, (void *)arg); ccc_inode_lsm_put(inode, lsm); - RETURN(rc); + return rc; } int ll_get_grouplock(struct inode *inode, struct file *file, unsigned long arg) @@ -1387,14 +1387,14 @@ int ll_get_grouplock(struct inode *inode, struct file *file, unsigned long arg) int rc; if (ll_file_nolock(file)) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; spin_lock(&lli->lli_lock); if (fd->fd_flags & LL_FILE_GROUP_LOCKED) { CWARN("group lock already existed with gid %lu\n", fd->fd_grouplock.cg_gid); spin_unlock(&lli->lli_lock); - RETURN(-EINVAL); + return -EINVAL; } LASSERT(fd->fd_grouplock.cg_lock == NULL); spin_unlock(&lli->lli_lock); @@ -1402,14 +1402,14 @@ int ll_get_grouplock(struct inode *inode, struct file *file, unsigned long arg) rc = cl_get_grouplock(cl_i2info(inode)->lli_clob, arg, (file->f_flags & O_NONBLOCK), &grouplock); if (rc) - RETURN(rc); + return rc; spin_lock(&lli->lli_lock); if (fd->fd_flags & LL_FILE_GROUP_LOCKED) { spin_unlock(&lli->lli_lock); CERROR("another thread just won the race\n"); cl_put_grouplock(&grouplock); - RETURN(-EINVAL); + return -EINVAL; } fd->fd_flags |= LL_FILE_GROUP_LOCKED; @@ -1417,7 +1417,7 @@ int ll_get_grouplock(struct inode *inode, struct file *file, unsigned long arg) spin_unlock(&lli->lli_lock); CDEBUG(D_INFO, "group lock %lu obtained\n", arg); - RETURN(0); + return 0; } int ll_put_grouplock(struct inode *inode, struct file *file, unsigned long arg) @@ -1430,7 +1430,7 @@ int ll_put_grouplock(struct inode *inode, struct file *file, unsigned long arg) if (!(fd->fd_flags & LL_FILE_GROUP_LOCKED)) { spin_unlock(&lli->lli_lock); CWARN("no group lock held\n"); - RETURN(-EINVAL); + return -EINVAL; } LASSERT(fd->fd_grouplock.cg_lock != NULL); @@ -1438,7 +1438,7 @@ int ll_put_grouplock(struct inode *inode, struct file *file, unsigned long arg) CWARN("group lock %lu doesn't match current id %lu\n", arg, fd->fd_grouplock.cg_gid); spin_unlock(&lli->lli_lock); - RETURN(-EINVAL); + return -EINVAL; } grouplock = fd->fd_grouplock; @@ -1448,7 +1448,7 @@ int ll_put_grouplock(struct inode *inode, struct file *file, unsigned long arg) cl_put_grouplock(&grouplock); CDEBUG(D_INFO, "group lock %lu released\n", arg); - RETURN(0); + return 0; } /** @@ -1470,11 +1470,11 @@ int ll_release_openhandle(struct dentry *dentry, struct lookup_intent *it) /* Root ? Do nothing. */ if (dentry->d_inode->i_sb->s_root == dentry) - RETURN(0); + return 0; /* No open handle to close? Move away */ if (!it_disposition(it, DISP_OPEN_OPEN)) - RETURN(0); + return 0; LASSERT(it_open_error(DISP_OPEN_OPEN, it) == 0); @@ -1493,7 +1493,7 @@ int ll_release_openhandle(struct dentry *dentry, struct lookup_intent *it) ptlrpc_req_finished(it->d.lustre.it_data); it_clear_disposition(it, DISP_ENQ_OPEN_REF); } - RETURN(rc); + return rc; } /** @@ -1553,7 +1553,7 @@ int ll_do_fiemap(struct inode *inode, struct ll_user_fiemap *fiemap, out: ccc_inode_lsm_put(inode, lsm); - RETURN(rc); + return rc; } int ll_fid2path(struct inode *inode, void *arg) @@ -1564,22 +1564,22 @@ int ll_fid2path(struct inode *inode, void *arg) if (!cfs_capable(CFS_CAP_DAC_READ_SEARCH) && !(ll_i2sbi(inode)->ll_flags & LL_SBI_USER_FID2PATH)) - RETURN(-EPERM); + return -EPERM; /* Need to get the buflen */ OBD_ALLOC_PTR(gfin); if (gfin == NULL) - RETURN(-ENOMEM); + return -ENOMEM; if (copy_from_user(gfin, arg, sizeof(*gfin))) { OBD_FREE_PTR(gfin); - RETURN(-EFAULT); + return -EFAULT; } outsize = sizeof(*gfout) + gfin->gf_pathlen; OBD_ALLOC(gfout, outsize); if (gfout == NULL) { OBD_FREE_PTR(gfin); - RETURN(-ENOMEM); + return -ENOMEM; } memcpy(gfout, gfin, sizeof(*gfout)); OBD_FREE_PTR(gfin); @@ -1594,7 +1594,7 @@ int ll_fid2path(struct inode *inode, void *arg) gf_free: OBD_FREE(gfout, outsize); - RETURN(rc); + return rc; } static int ll_ioctl_fiemap(struct inode *inode, unsigned long arg) @@ -1608,13 +1608,13 @@ static int ll_ioctl_fiemap(struct inode *inode, unsigned long arg) * required fiemap buffer */ if (get_user(extent_count, &((struct ll_user_fiemap __user *)arg)->fm_extent_count)) - RETURN(-EFAULT); + return -EFAULT; num_bytes = sizeof(*fiemap_s) + (extent_count * sizeof(struct ll_fiemap_extent)); OBD_ALLOC_LARGE(fiemap_s, num_bytes); if (fiemap_s == NULL) - RETURN(-ENOMEM); + return -ENOMEM; /* get the fiemap value */ if (copy_from_user(fiemap_s, (struct ll_user_fiemap __user *)arg, @@ -1646,7 +1646,7 @@ static int ll_ioctl_fiemap(struct inode *inode, unsigned long arg) error: OBD_FREE_LARGE(fiemap_s, num_bytes); - RETURN(rc); + return rc; } /* @@ -1689,7 +1689,7 @@ int ll_data_version(struct inode *inode, __u64 *data_version, OBD_FREE_PTR(obdo); out: ccc_inode_lsm_put(inode, lsm); - RETURN(rc); + return rc; } struct ll_swap_stack { @@ -1711,7 +1711,7 @@ static int ll_swap_layouts(struct file *file1, struct file *file2, OBD_ALLOC_PTR(llss); if (llss == NULL) - RETURN(-ENOMEM); + return -ENOMEM; llss->inode1 = file1->f_dentry->d_inode; llss->inode2 = file2->f_dentry->d_inode; @@ -1850,7 +1850,7 @@ static int ll_swap_layouts(struct file *file1, struct file *file2, if (llss != NULL) OBD_FREE_PTR(llss); - RETURN(rc); + return rc; } long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) @@ -1865,7 +1865,7 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) /* asm-ppc{,64} declares TCGETS, et. al. as type 't' not 'T' */ if (_IOC_TYPE(cmd) == 'T' || _IOC_TYPE(cmd) == 't') /* tty ioctls */ - RETURN(-ENOTTY); + return -ENOTTY; switch(cmd) { case LL_IOC_GETFLAGS: @@ -1878,66 +1878,66 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) * not abused, and to handle any flag side effects. */ if (get_user(flags, (int *) arg)) - RETURN(-EFAULT); + return -EFAULT; if (cmd == LL_IOC_SETFLAGS) { if ((flags & LL_FILE_IGNORE_LOCK) && !(file->f_flags & O_DIRECT)) { CERROR("%s: unable to disable locking on " "non-O_DIRECT file\n", current->comm); - RETURN(-EINVAL); + return -EINVAL; } fd->fd_flags |= flags; } else { fd->fd_flags &= ~flags; } - RETURN(0); + return 0; case LL_IOC_LOV_SETSTRIPE: - RETURN(ll_lov_setstripe(inode, file, arg)); + return ll_lov_setstripe(inode, file, arg); case LL_IOC_LOV_SETEA: - RETURN(ll_lov_setea(inode, file, arg)); + return ll_lov_setea(inode, file, arg); case LL_IOC_LOV_SWAP_LAYOUTS: { struct file *file2; struct lustre_swap_layouts lsl; if (copy_from_user(&lsl, (char *)arg, sizeof(struct lustre_swap_layouts))) - RETURN(-EFAULT); + return -EFAULT; if ((file->f_flags & O_ACCMODE) == 0) /* O_RDONLY */ - RETURN(-EPERM); + return -EPERM; file2 = fget(lsl.sl_fd); if (file2 == NULL) - RETURN(-EBADF); + return -EBADF; rc = -EPERM; if ((file2->f_flags & O_ACCMODE) != 0) /* O_WRONLY or O_RDWR */ rc = ll_swap_layouts(file, file2, &lsl); fput(file2); - RETURN(rc); + return rc; } case LL_IOC_LOV_GETSTRIPE: - RETURN(ll_lov_getstripe(inode, arg)); + return ll_lov_getstripe(inode, arg); case LL_IOC_RECREATE_OBJ: - RETURN(ll_lov_recreate_obj(inode, arg)); + return ll_lov_recreate_obj(inode, arg); case LL_IOC_RECREATE_FID: - RETURN(ll_lov_recreate_fid(inode, arg)); + return ll_lov_recreate_fid(inode, arg); case FSFILT_IOC_FIEMAP: - RETURN(ll_ioctl_fiemap(inode, arg)); + return ll_ioctl_fiemap(inode, arg); case FSFILT_IOC_GETFLAGS: case FSFILT_IOC_SETFLAGS: - RETURN(ll_iocontrol(inode, file, cmd, arg)); + return ll_iocontrol(inode, file, cmd, arg); case FSFILT_IOC_GETVERSION_OLD: case FSFILT_IOC_GETVERSION: - RETURN(put_user(inode->i_generation, (int *)arg)); + return put_user(inode->i_generation, (int *)arg); case LL_IOC_GROUP_LOCK: - RETURN(ll_get_grouplock(inode, file, arg)); + return ll_get_grouplock(inode, file, arg); case LL_IOC_GROUP_UNLOCK: - RETURN(ll_put_grouplock(inode, file, arg)); + return ll_put_grouplock(inode, file, arg); case IOC_OBD_STATFS: - RETURN(ll_obd_statfs(inode, (void *)arg)); + return ll_obd_statfs(inode, (void *)arg); /* We need to special case any other ioctls we want to handle, * to send them to the MDS/OST as appropriate and to properly @@ -1946,30 +1946,30 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) case FSFILT_IOC_SETVERSION: */ case LL_IOC_FLUSHCTX: - RETURN(ll_flush_ctx(inode)); + return ll_flush_ctx(inode); case LL_IOC_PATH2FID: { if (copy_to_user((void *)arg, ll_inode2fid(inode), sizeof(struct lu_fid))) - RETURN(-EFAULT); + return -EFAULT; - RETURN(0); + return 0; } case OBD_IOC_FID2PATH: - RETURN(ll_fid2path(inode, (void *)arg)); + return ll_fid2path(inode, (void *)arg); case LL_IOC_DATA_VERSION: { struct ioc_data_version idv; int rc; if (copy_from_user(&idv, (char *)arg, sizeof(idv))) - RETURN(-EFAULT); + return -EFAULT; rc = ll_data_version(inode, &idv.idv_version, !(idv.idv_flags & LL_DV_NOFLUSH)); if (rc == 0 && copy_to_user((char *) arg, &idv, sizeof(idv))) - RETURN(-EFAULT); + return -EFAULT; - RETURN(rc); + return rc; } case LL_IOC_GET_MDTIDX: { @@ -1977,16 +1977,16 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) mdtidx = ll_get_mdt_idx(inode); if (mdtidx < 0) - RETURN(mdtidx); + return mdtidx; if (put_user((int)mdtidx, (int*)arg)) - RETURN(-EFAULT); + return -EFAULT; - RETURN(0); + return 0; } case OBD_IOC_GETDTNAME: case OBD_IOC_GETMDNAME: - RETURN(ll_get_obd_name(inode, cmd, arg)); + return ll_get_obd_name(inode, cmd, arg); case LL_IOC_HSM_STATE_GET: { struct md_op_data *op_data; struct hsm_user_state *hus; @@ -1994,13 +1994,13 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) OBD_ALLOC_PTR(hus); if (hus == NULL) - RETURN(-ENOMEM); + return -ENOMEM; op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0, LUSTRE_OPC_ANY, hus); if (IS_ERR(op_data)) { OBD_FREE_PTR(hus); - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); } rc = obd_iocontrol(cmd, ll_i2mdexp(inode), sizeof(*op_data), @@ -2011,7 +2011,7 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ll_finish_md_op_data(op_data); OBD_FREE_PTR(hus); - RETURN(rc); + return rc; } case LL_IOC_HSM_STATE_SET: { struct md_op_data *op_data; @@ -2020,10 +2020,10 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) OBD_ALLOC_PTR(hss); if (hss == NULL) - RETURN(-ENOMEM); + return -ENOMEM; if (copy_from_user(hss, (char *)arg, sizeof(*hss))) { OBD_FREE_PTR(hss); - RETURN(-EFAULT); + return -EFAULT; } /* Non-root users are forbidden to set or clear flags which are @@ -2031,14 +2031,14 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) if (((hss->hss_setmask | hss->hss_clearmask) & ~HSM_USER_MASK) && !cfs_capable(CFS_CAP_SYS_ADMIN)) { OBD_FREE_PTR(hss); - RETURN(-EPERM); + return -EPERM; } op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0, LUSTRE_OPC_ANY, hss); if (IS_ERR(op_data)) { OBD_FREE_PTR(hss); - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); } rc = obd_iocontrol(cmd, ll_i2mdexp(inode), sizeof(*op_data), @@ -2047,7 +2047,7 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ll_finish_md_op_data(op_data); OBD_FREE_PTR(hss); - RETURN(rc); + return rc; } case LL_IOC_HSM_ACTION: { struct md_op_data *op_data; @@ -2056,13 +2056,13 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) OBD_ALLOC_PTR(hca); if (hca == NULL) - RETURN(-ENOMEM); + return -ENOMEM; op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0, LUSTRE_OPC_ANY, hca); if (IS_ERR(op_data)) { OBD_FREE_PTR(hca); - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); } rc = obd_iocontrol(cmd, ll_i2mdexp(inode), sizeof(*op_data), @@ -2073,17 +2073,17 @@ long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ll_finish_md_op_data(op_data); OBD_FREE_PTR(hca); - RETURN(rc); + return rc; } default: { int err; if (LLIOC_STOP == ll_iocontrol_call(inode, file, cmd, arg, &err)) - RETURN(err); + return err; - RETURN(obd_iocontrol(cmd, ll_i2dtexp(inode), 0, NULL, - (void *)arg)); + return obd_iocontrol(cmd, ll_i2dtexp(inode), 0, NULL, + (void *)arg); } } } @@ -2104,13 +2104,13 @@ loff_t ll_file_seek(struct file *file, loff_t offset, int origin) if (origin == SEEK_END || origin == SEEK_HOLE || origin == SEEK_DATA) { retval = ll_glimpse_size(inode); if (retval != 0) - RETURN(retval); + return retval; eof = i_size_read(inode); } retval = generic_file_llseek_size(file, offset, origin, ll_file_maxbytes(inode), eof); - RETURN(retval); + return retval; } int ll_flush(struct file *file, fl_owner_t id) @@ -2155,11 +2155,11 @@ int cl_sync_file_range(struct inode *inode, loff_t start, loff_t end, if (mode != CL_FSYNC_NONE && mode != CL_FSYNC_LOCAL && mode != CL_FSYNC_DISCARD && mode != CL_FSYNC_ALL) - RETURN(-EINVAL); + return -EINVAL; env = cl_env_nested_get(&nest); if (IS_ERR(env)) - RETURN(PTR_ERR(env)); + return PTR_ERR(env); capa = ll_osscapa_get(inode, CAPA_OPC_OSS_WRITE); @@ -2187,7 +2187,7 @@ int cl_sync_file_range(struct inode *inode, loff_t start, loff_t end, capa_put(capa); - RETURN(result); + return result; } /* @@ -2247,7 +2247,7 @@ int ll_fsync(struct file *file, loff_t start, loff_t end, int datasync) } mutex_unlock(&inode->i_mutex); - RETURN(rc); + return rc; } int ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock) @@ -2282,7 +2282,7 @@ int ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock) flock.l_flock.start = file_lock->fl_start; flock.l_flock.end = file_lock->fl_end; } else { - RETURN(-EINVAL); + return -EINVAL; } flock.l_flock.pid = file_lock->fl_pid; @@ -2317,7 +2317,7 @@ int ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock) default: CDEBUG(D_INFO, "Unknown fcntl lock type: %d\n", file_lock->fl_type); - RETURN (-ENOTSUPP); + return -ENOTSUPP; } switch (cmd) { @@ -2344,13 +2344,13 @@ int ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock) break; default: CERROR("unknown fcntl lock command: %d\n", cmd); - RETURN (-EINVAL); + return -EINVAL; } op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); CDEBUG(D_DLMTRACE, "inode=%lu, pid=%u, flags=%#x, mode=%u, " "start="LPU64", end="LPU64"\n", inode->i_ino, flock.l_flock.pid, @@ -2376,12 +2376,12 @@ int ll_file_flock(struct file *file, int cmd, struct file_lock *file_lock) ll_finish_md_op_data(op_data); - RETURN(rc); + return rc; } int ll_file_noflock(struct file *file, int cmd, struct file_lock *file_lock) { - RETURN(-ENOSYS); + return -ENOSYS; } /** @@ -2405,7 +2405,7 @@ int ll_have_md_lock(struct inode *inode, __u64 *bits, ldlm_mode_t l_req_mode) int i; if (!inode) - RETURN(0); + return 0; fid = &ll_i2info(inode)->lli_fid; CDEBUG(D_INFO, "trying to match res "DFID" mode %s\n", PFID(fid), @@ -2431,7 +2431,7 @@ int ll_have_md_lock(struct inode *inode, __u64 *bits, ldlm_mode_t l_req_mode) } } } - RETURN(*bits == 0); + return *bits == 0; } ldlm_mode_t ll_take_md_lock(struct inode *inode, __u64 bits, @@ -2447,7 +2447,7 @@ ldlm_mode_t ll_take_md_lock(struct inode *inode, __u64 bits, rc = md_lock_match(ll_i2mdexp(inode), LDLM_FL_BLOCK_GRANTED|flags, fid, LDLM_IBITS, &policy, LCK_CR|LCK_CW|LCK_PR|LCK_PW, lockh); - RETURN(rc); + return rc; } static int ll_inode_revalidate_fini(struct inode *inode, int rc) @@ -2499,7 +2499,7 @@ int __ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it, dentry->d_inode, NULL, 0, 0, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); oit.it_create_mode |= M_CHECK_STALE; rc = md_intent_lock(exp, op_data, NULL, 0, @@ -2537,7 +2537,7 @@ int __ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it, if (S_ISREG(inode->i_mode)) { rc = ll_get_max_mdsize(sbi, &ealen); if (rc) - RETURN(rc); + return rc; valid |= OBD_MD_FLEASIZE | OBD_MD_FLMODEASIZE; } @@ -2545,7 +2545,7 @@ int __ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it, 0, ealen, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); op_data->op_valid = valid; /* Once OBD_CONNECT_ATTRFID is not supported, we can't find one @@ -2555,7 +2555,7 @@ int __ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it, ll_finish_md_op_data(op_data); if (rc) { rc = ll_inode_revalidate_fini(inode, rc); - RETURN(rc); + return rc; } rc = ll_prep_inode(&inode, req, NULL, NULL); @@ -2573,7 +2573,7 @@ int ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it, rc = __ll_inode_revalidate_it(dentry, it, ibits); if (rc != 0) - RETURN(rc); + return rc; /* if object isn't regular file, don't validate size */ if (!S_ISREG(inode->i_mode)) { @@ -2583,7 +2583,7 @@ int ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it, } else { rc = ll_glimpse_size(inode); } - RETURN(rc); + return rc; } int ll_getattr_it(struct vfsmount *mnt, struct dentry *de, @@ -2639,7 +2639,7 @@ struct posix_acl * ll_get_acl(struct inode *inode, int type) acl = posix_acl_dup(lli->lli_posix_acl); spin_unlock(&lli->lli_lock); - RETURN(acl); + return acl; } @@ -2661,7 +2661,7 @@ int ll_inode_permission(struct inode *inode, int mask) rc = __ll_inode_revalidate_it(inode->i_sb->s_root, &it, MDS_INODELOCK_LOOKUP); if (rc) - RETURN(rc); + return rc; } CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p), inode mode %x mask %o\n", @@ -2673,7 +2673,7 @@ int ll_inode_permission(struct inode *inode, int mask) ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_INODE_PERM, 1); rc = generic_permission(inode, mask); - RETURN(rc); + return rc; } #define READ_METHOD aio_read @@ -2768,12 +2768,12 @@ void *ll_iocontrol_register(llioc_callback_t cb, int count, unsigned int *cmd) if (cb == NULL || cmd == NULL || count > LLIOC_MAX_CMD || count < 0) - RETURN(NULL); + return NULL; size = sizeof(*in_data) + count * sizeof(unsigned int); OBD_ALLOC(in_data, size); if (in_data == NULL) - RETURN(NULL); + return NULL; memset(in_data, 0, sizeof(*in_data)); in_data->iocd_size = size; @@ -2785,7 +2785,7 @@ void *ll_iocontrol_register(llioc_callback_t cb, int count, unsigned int *cmd) list_add_tail(&in_data->iocd_list, &llioc.ioc_head); up_write(&llioc.ioc_sem); - RETURN(in_data); + return in_data; } void ll_iocontrol_unregister(void *magic) @@ -2850,11 +2850,11 @@ int ll_layout_conf(struct inode *inode, const struct cl_object_conf *conf) int result; if (lli->lli_clob == NULL) - RETURN(0); + return 0; env = cl_env_nested_get(&nest); if (IS_ERR(env)) - RETURN(PTR_ERR(env)); + return PTR_ERR(env); result = cl_conf_set(env, lli->lli_clob, conf); cl_env_nested_put(&nest, env); @@ -2872,7 +2872,7 @@ int ll_layout_conf(struct inode *inode, const struct cl_object_conf *conf) ldlm_lock_allow_match(lock); } } - RETURN(result); + return result; } /* Fetch layout from MDT with getxattr request, if it's not ready yet */ @@ -2893,7 +2893,7 @@ static int ll_layout_fetch(struct inode *inode, struct ldlm_lock *lock) lock->l_lvb_data, lock->l_lvb_len); if ((lock->l_lvb_data != NULL) && (lock->l_flags & LDLM_FL_LVB_READY)) - RETURN(0); + return 0; /* if layout lock was granted right away, the layout is returned * within DLM_LVB of dlm reply; otherwise if the lock was ever @@ -2908,7 +2908,7 @@ static int ll_layout_fetch(struct inode *inode, struct ldlm_lock *lock) lmmsize, 0, &req); capa_put(oc); if (rc < 0) - RETURN(rc); + return rc; body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); if (body == NULL || body->eadatasize > lmmsize) @@ -3044,7 +3044,7 @@ static int ll_layout_lock_set(struct lustre_handle *lockh, ldlm_mode_t mode, CDEBUG(D_INODE, "file: "DFID" waiting layout return: %d.\n", PFID(&lli->lli_fid), rc); } - RETURN(rc); + return rc; } /** @@ -3078,7 +3078,7 @@ int ll_layout_refresh(struct inode *inode, __u32 *gen) *gen = lli->lli_layout_gen; if (!(sbi->ll_flags & LL_SBI_LAYOUT_LOCK)) - RETURN(0); + return 0; /* sanity checks */ LASSERT(fid_is_sane(ll_inode2fid(inode))); @@ -3090,7 +3090,7 @@ int ll_layout_refresh(struct inode *inode, __u32 *gen) if (mode != 0) { /* hit cached lock */ rc = ll_layout_lock_set(&lockh, mode, inode, gen, false); if (rc == 0) - RETURN(0); + return 0; /* better hold lli_layout_mutex to try again otherwise * it will have starvation problem. */ @@ -3108,14 +3108,14 @@ int ll_layout_refresh(struct inode *inode, __u32 *gen) goto again; mutex_unlock(&lli->lli_layout_mutex); - RETURN(rc); + return rc; } op_data = ll_prep_md_op_data(NULL, inode, inode, NULL, 0, 0, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) { mutex_unlock(&lli->lli_layout_mutex); - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); } /* have to enqueue one */ @@ -3148,5 +3148,5 @@ int ll_layout_refresh(struct inode *inode, __u32 *gen) } mutex_unlock(&lli->lli_layout_mutex); - RETURN(rc); + return rc; } diff --git a/drivers/staging/lustre/lustre/llite/llite_capa.c b/drivers/staging/lustre/lustre/llite/llite_capa.c index 3b4f7f82dd422..1d30181e3bcdc 100644 --- a/drivers/staging/lustre/lustre/llite/llite_capa.c +++ b/drivers/staging/lustre/lustre/llite/llite_capa.c @@ -279,7 +279,7 @@ static int capa_thread_main(void *unused) thread_set_flags(&ll_capa_thread, SVC_STOPPED); wake_up(&ll_capa_thread.t_ctl_waitq); - RETURN(0); + return 0; } void ll_capa_timer_callback(unsigned long unused) @@ -297,12 +297,12 @@ int ll_capa_thread_start(void) if (IS_ERR(task)) { CERROR("cannot start expired capa thread: rc %ld\n", PTR_ERR(task)); - RETURN(PTR_ERR(task)); + return PTR_ERR(task); } wait_event(ll_capa_thread.t_ctl_waitq, thread_is_running(&ll_capa_thread)); - RETURN(0); + return 0; } void ll_capa_thread_stop(void) @@ -320,7 +320,7 @@ struct obd_capa *ll_osscapa_get(struct inode *inode, __u64 opc) int found = 0; if ((ll_i2sbi(inode)->ll_flags & LL_SBI_OSS_CAPA) == 0) - RETURN(NULL); + return NULL; LASSERT(opc == CAPA_OPC_OSS_WRITE || opc == CAPA_OPC_OSS_RW || opc == CAPA_OPC_OSS_TRUNC); @@ -364,7 +364,7 @@ struct obd_capa *ll_osscapa_get(struct inode *inode, __u64 opc) } spin_unlock(&capa_lock); - RETURN(ocapa); + return ocapa; } EXPORT_SYMBOL(ll_osscapa_get); @@ -376,7 +376,7 @@ struct obd_capa *ll_mdscapa_get(struct inode *inode) LASSERT(inode != NULL); if ((ll_i2sbi(inode)->ll_flags & LL_SBI_MDS_CAPA) == 0) - RETURN(NULL); + return NULL; spin_lock(&capa_lock); ocapa = capa_get(lli->lli_mds_capa); @@ -386,7 +386,7 @@ struct obd_capa *ll_mdscapa_get(struct inode *inode) atomic_set(&ll_capa_debug, 0); } - RETURN(ocapa); + return ocapa; } static struct obd_capa *do_add_mds_capa(struct inode *inode, @@ -554,7 +554,7 @@ int ll_update_capa(struct obd_capa *ocapa, struct lustre_capa *capa) capa_put(ocapa); iput(inode); - RETURN(rc); + return rc; } spin_lock(&ocapa->c_lock); diff --git a/drivers/staging/lustre/lustre/llite/llite_close.c b/drivers/staging/lustre/lustre/llite/llite_close.c index a9cd75f16e946..487ce6851d96b 100644 --- a/drivers/staging/lustre/lustre/llite/llite_close.c +++ b/drivers/staging/lustre/lustre/llite/llite_close.c @@ -225,7 +225,7 @@ int ll_som_update(struct inode *inode, struct md_op_data *op_data) OBDO_ALLOC(oa); if (!oa) { CERROR("can't allocate memory for Size-on-MDS update.\n"); - RETURN(-ENOMEM); + return -ENOMEM; } old_flags = op_data->op_flags; @@ -255,7 +255,7 @@ int ll_som_update(struct inode *inode, struct md_op_data *op_data) ptlrpc_req_finished(request); OBDO_FREE(oa); - RETURN(rc); + return rc; } /** @@ -356,7 +356,7 @@ static int ll_close_thread(void *arg) CDEBUG(D_INFO, "ll_close exiting\n"); complete(&lcq->lcq_comp); - RETURN(0); + return 0; } int ll_close_thread_start(struct ll_close_queue **lcq_ret) diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 71b8fd9ff1a7f..b868c2bd58d2a 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -81,7 +81,7 @@ static struct ll_sb_info *ll_init_sbi(void) OBD_ALLOC(sbi, sizeof(*sbi)); if (!sbi) - RETURN(NULL); + return NULL; spin_lock_init(&sbi->ll_lock); mutex_init(&sbi->ll_lco.lco_lock); @@ -139,7 +139,7 @@ static struct ll_sb_info *ll_init_sbi(void) atomic_set(&sbi->ll_agl_total, 0); sbi->ll_flags |= LL_SBI_AGL_ENABLED; - RETURN(sbi); + return sbi; } void ll_free_sbi(struct super_block *sb) @@ -178,17 +178,17 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, obd = class_name2obd(md); if (!obd) { CERROR("MD %s: not setup or attached\n", md); - RETURN(-EINVAL); + return -EINVAL; } OBD_ALLOC_PTR(data); if (data == NULL) - RETURN(-ENOMEM); + return -ENOMEM; OBD_ALLOC_PTR(osfs); if (osfs == NULL) { OBD_FREE_PTR(data); - RETURN(-ENOMEM); + return -ENOMEM; } if (proc_lustre_fs_root) { @@ -588,7 +588,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, if (osfs != NULL) OBD_FREE_PTR(osfs); - RETURN(err); + return err; out_root: if (root) iput(root); @@ -624,7 +624,7 @@ int ll_get_max_mdsize(struct ll_sb_info *sbi, int *lmmsize) if (rc) CERROR("Get max mdsize error rc %d \n", rc); - RETURN(rc); + return rc; } void ll_dump_inode(struct inode *inode) @@ -726,20 +726,20 @@ char *ll_read_opt(const char *opt, char *data) CDEBUG(D_SUPER, "option: %s, data %s\n", opt, data); if (strncmp(opt, data, strlen(opt))) - RETURN(NULL); + return NULL; if ((value = strchr(data, '=')) == NULL) - RETURN(NULL); + return NULL; value++; OBD_ALLOC(retval, strlen(value) + 1); if (!retval) { CERROR("out of memory!\n"); - RETURN(NULL); + return NULL; } memcpy(retval, value, strlen(value)+1); CDEBUG(D_SUPER, "Assigned option: %s, value %s\n", opt, retval); - RETURN(retval); + return retval; } static inline int ll_set_opt(const char *opt, char *data, int fl) @@ -757,7 +757,7 @@ static int ll_options(char *options, int *flags) char *s1 = options, *s2; if (!options) - RETURN(0); + return 0; CDEBUG(D_CONFIG, "Parsing opts %s\n", options); @@ -880,7 +880,7 @@ static int ll_options(char *options, int *flags) } LCONSOLE_ERROR_MSG(0x152, "Unknown option '%s', won't mount.\n", s1); - RETURN(-EINVAL); + return -EINVAL; next: /* Find next opt */ @@ -889,7 +889,7 @@ static int ll_options(char *options, int *flags) break; s1 = s2 + 1; } - RETURN(0); + return 0; } void ll_lli_init(struct ll_inode_info *lli) @@ -971,7 +971,7 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt) OBD_ALLOC_PTR(cfg); if (cfg == NULL) - RETURN(-ENOMEM); + return -ENOMEM; try_module_get(THIS_MODULE); @@ -980,7 +980,7 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt) if (!sbi) { module_put(THIS_MODULE); OBD_FREE_PTR(cfg); - RETURN(-ENOMEM); + return -ENOMEM; } err = ll_options(lsi->lsi_lmd->lmd_opts, &sbi->ll_flags); @@ -1046,7 +1046,7 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt) LCONSOLE_WARN("Mounted %s\n", profilenm); OBD_FREE_PTR(cfg); - RETURN(err); + return err; } /* ll_fill_super */ void ll_put_super(struct super_block *sb) @@ -1235,7 +1235,7 @@ int ll_md_setattr(struct dentry *dentry, struct md_op_data *op_data, op_data = ll_prep_md_op_data(op_data, inode, NULL, NULL, 0, 0, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); rc = md_setattr(sbi->ll_md_exp, op_data, NULL, 0, NULL, 0, &request, mod); @@ -1255,14 +1255,14 @@ int ll_md_setattr(struct dentry *dentry, struct md_op_data *op_data, } else if (rc != -EPERM && rc != -EACCES && rc != -ETXTBSY) { CERROR("md_setattr fails: rc = %d\n", rc); } - RETURN(rc); + return rc; } rc = md_get_lustre_md(sbi->ll_md_exp, request, sbi->ll_dt_exp, sbi->ll_md_exp, &md); if (rc) { ptlrpc_req_finished(request); - RETURN(rc); + return rc; } ia_valid = op_data->op_attr.ia_valid; @@ -1279,7 +1279,7 @@ int ll_md_setattr(struct dentry *dentry, struct md_op_data *op_data, ll_update_inode(inode, &md); ptlrpc_req_finished(request); - RETURN(rc); + return rc; } /* Close IO epoch and send Size-on-MDS attribute update. */ @@ -1292,7 +1292,7 @@ static int ll_setattr_done_writing(struct inode *inode, LASSERT(op_data != NULL); if (!S_ISREG(inode->i_mode)) - RETURN(0); + return 0; CDEBUG(D_INODE, "Epoch "LPU64" closed on "DFID" for truncate\n", op_data->op_ioepoch, PFID(&lli->lli_fid)); @@ -1310,7 +1310,7 @@ static int ll_setattr_done_writing(struct inode *inode, CERROR("inode %lu mdc truncate failed: rc = %d\n", inode->i_ino, rc); } - RETURN(rc); + return rc; } static int ll_setattr_ost(struct inode *inode, struct iattr *attr) @@ -1364,7 +1364,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr) /* Check new size against VFS/VM file size limit and rlimit */ rc = inode_newsize_ok(inode, attr->ia_size); if (rc) - RETURN(rc); + return rc; /* The maximum Lustre file size is variable, based on the * OST maximum object size and number of stripes. This @@ -1373,7 +1373,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr) CDEBUG(D_INODE,"file "DFID" too large %llu > "LPU64"\n", PFID(&lli->lli_fid), attr->ia_size, ll_file_maxbytes(inode)); - RETURN(-EFBIG); + return -EFBIG; } attr->ia_valid |= ATTR_MTIME | ATTR_CTIME; @@ -1383,7 +1383,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr) if (attr->ia_valid & TIMES_SET_FLAGS) { if ((!uid_eq(current_fsuid(), inode->i_uid)) && !cfs_capable(CFS_CAP_FOWNER)) - RETURN(-EPERM); + return -EPERM; } /* We mark all of the fields "set" so MDS/OST does not re-set them */ @@ -1420,7 +1420,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr) OBD_ALLOC_PTR(op_data); if (op_data == NULL) - RETURN(-ENOMEM); + return -ENOMEM; if (!S_ISDIR(inode->i_mode)) { if (attr->ia_valid & ATTR_SIZE) @@ -1521,7 +1521,7 @@ int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs, rc = obd_statfs(NULL, sbi->ll_md_exp, osfs, max_age, flags); if (rc) { CERROR("md_statfs fails: rc = %d\n", rc); - RETURN(rc); + return rc; } osfs->os_type = sb->s_magic; @@ -1535,7 +1535,7 @@ int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs, rc = obd_statfs_rqset(sbi->ll_dt_exp, &obd_osfs, max_age, flags); if (rc) { CERROR("obd_statfs fails: rc = %d\n", rc); - RETURN(rc); + return rc; } CDEBUG(D_SUPER, "OSC blocks "LPU64"/"LPU64" objects "LPU64"/"LPU64"\n", @@ -1557,7 +1557,7 @@ int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs, osfs->os_ffree = obd_osfs.os_ffree; } - RETURN(rc); + return rc; } int ll_statfs(struct dentry *de, struct kstatfs *sfs) { @@ -1851,14 +1851,14 @@ int ll_iocontrol(struct inode *inode, struct file *file, 0, 0, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); op_data->op_valid = OBD_MD_FLFLAGS; rc = md_getattr(sbi->ll_md_exp, op_data, &req); ll_finish_md_op_data(op_data); if (rc) { CERROR("failure %d inode %lu\n", rc, inode->i_ino); - RETURN(-abs(rc)); + return -abs(rc); } body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); @@ -1867,7 +1867,7 @@ int ll_iocontrol(struct inode *inode, struct file *file, ptlrpc_req_finished(req); - RETURN(put_user(flags, (int *)arg)); + return put_user(flags, (int *)arg); } case FSFILT_IOC_SETFLAGS: { struct lov_stripe_md *lsm; @@ -1875,12 +1875,12 @@ int ll_iocontrol(struct inode *inode, struct file *file, struct md_op_data *op_data; if (get_user(flags, (int *)arg)) - RETURN(-EFAULT); + return -EFAULT; op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); ((struct ll_iattr *)&op_data->op_attr)->ia_attr_flags = flags; op_data->op_attr.ia_valid |= ATTR_ATTR_FLAG; @@ -1889,20 +1889,20 @@ int ll_iocontrol(struct inode *inode, struct file *file, ll_finish_md_op_data(op_data); ptlrpc_req_finished(req); if (rc) - RETURN(rc); + return rc; inode->i_flags = ll_ext_to_inode_flags(flags); lsm = ccc_inode_lsm_get(inode); if (!lsm_has_objects(lsm)) { ccc_inode_lsm_put(inode, lsm); - RETURN(0); + return 0; } OBDO_ALLOC(oinfo.oi_oa); if (!oinfo.oi_oa) { ccc_inode_lsm_put(inode, lsm); - RETURN(-ENOMEM); + return -ENOMEM; } oinfo.oi_md = lsm; oinfo.oi_oa->o_oi = lsm->lsm_oi; @@ -1919,13 +1919,13 @@ int ll_iocontrol(struct inode *inode, struct file *file, if (rc && rc != -EPERM && rc != -EACCES) CERROR("osc_setattr_async fails: rc = %d\n", rc); - RETURN(rc); + return rc; } default: - RETURN(-ENOSYS); + return -ENOSYS; } - RETURN(0); + return 0; } int ll_flush_ctx(struct inode *inode) @@ -2032,7 +2032,7 @@ int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req, rc = md_get_lustre_md(sbi->ll_md_exp, req, sbi->ll_dt_exp, sbi->ll_md_exp, &md); if (rc) - RETURN(rc); + return rc; if (*inode) { ll_update_inode(*inode, &md); @@ -2094,7 +2094,7 @@ int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req, if (md.lsm != NULL) obd_free_memmd(sbi->ll_dt_exp, &md.lsm); md_free_lustre_md(sbi->ll_md_exp, &md); - RETURN(rc); + return rc; } int ll_obd_statfs(struct inode *inode, void *arg) @@ -2270,7 +2270,7 @@ int ll_show_options(struct seq_file *seq, struct dentry *dentry) if (sbi->ll_flags & LL_SBI_USER_FID2PATH) seq_puts(seq, ",user_fid2path"); - RETURN(0); + return 0; } /** @@ -2286,16 +2286,16 @@ int ll_get_obd_name(struct inode *inode, unsigned int cmd, unsigned long arg) else if (cmd == OBD_IOC_GETMDNAME) obd = class_exp2obd(sbi->ll_md_exp); else - RETURN(-EINVAL); + return -EINVAL; if (!obd) - RETURN(-ENOENT); + return -ENOENT; if (copy_to_user((void *)arg, obd->obd_name, strlen(obd->obd_name) + 1)) - RETURN(-EFAULT); + return -EFAULT; - RETURN(0); + return 0; } /** diff --git a/drivers/staging/lustre/lustre/llite/llite_mmap.c b/drivers/staging/lustre/lustre/llite/llite_mmap.c index 26a5247cbc29b..caed6423e4ef2 100644 --- a/drivers/staging/lustre/lustre/llite/llite_mmap.c +++ b/drivers/staging/lustre/lustre/llite/llite_mmap.c @@ -82,7 +82,7 @@ struct vm_area_struct *our_vma(struct mm_struct *mm, unsigned long addr, break; } } - RETURN(ret); + return ret; } /** @@ -111,7 +111,7 @@ struct cl_io *ll_fault_io_init(struct vm_area_struct *vma, *env_ret = NULL; if (ll_file_nolock(file)) - RETURN(ERR_PTR(-EOPNOTSUPP)); + return ERR_PTR(-EOPNOTSUPP); /* * page fault can be called when lustre IO is @@ -122,7 +122,7 @@ struct cl_io *ll_fault_io_init(struct vm_area_struct *vma, */ env = cl_env_nested_get(nest); if (IS_ERR(env)) - RETURN(ERR_PTR(-EINVAL)); + return ERR_PTR(-EINVAL); *env_ret = env; @@ -305,7 +305,7 @@ static int ll_fault0(struct vm_area_struct *vma, struct vm_fault *vmf) io = ll_fault_io_init(vma, &env, &nest, vmf->pgoff, &ra_flags); if (IS_ERR(io)) - RETURN(to_fault_error(PTR_ERR(io))); + return to_fault_error(PTR_ERR(io)); result = io->ci_result; if (result == 0) { @@ -332,7 +332,7 @@ static int ll_fault0(struct vm_area_struct *vma, struct vm_fault *vmf) CDEBUG(D_MMAP, "%s fault %d/%d\n", current->comm, fault_ret, result); - RETURN(fault_ret); + return fault_ret; } static int ll_fault(struct vm_area_struct *vma, struct vm_fault *vmf) @@ -467,7 +467,7 @@ int ll_teardown_mmaps(struct address_space *mapping, __u64 first, __u64 last) last - first + 1, 0); } - RETURN(rc); + return rc; } static struct vm_operations_struct ll_file_vm_ops = { @@ -483,7 +483,7 @@ int ll_file_mmap(struct file *file, struct vm_area_struct * vma) int rc; if (ll_file_nolock(file)) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_MAP, 1); rc = generic_file_mmap(file, vma); @@ -494,5 +494,5 @@ int ll_file_mmap(struct file *file, struct vm_area_struct * vma) rc = ll_glimpse_size(inode); } - RETURN(rc); + return rc; } diff --git a/drivers/staging/lustre/lustre/llite/llite_nfs.c b/drivers/staging/lustre/lustre/llite/llite_nfs.c index 8b1a76da6c868..1767c741fb724 100644 --- a/drivers/staging/lustre/lustre/llite/llite_nfs.c +++ b/drivers/staging/lustre/lustre/llite/llite_nfs.c @@ -96,11 +96,11 @@ struct inode *search_inode_for_lustre(struct super_block *sb, inode = ilookup5(sb, hash, ll_nfs_test_inode, (void *)fid); if (inode) - RETURN(inode); + return inode; rc = ll_get_max_mdsize(sbi, &eadatalen); if (rc) - RETURN(ERR_PTR(rc)); + return ERR_PTR(rc); /* Because inode is NULL, ll_prep_md_op_data can not * be used here. So we allocate op_data ourselves */ @@ -118,14 +118,14 @@ struct inode *search_inode_for_lustre(struct super_block *sb, if (rc) { CERROR("can't get object attrs, fid "DFID", rc %d\n", PFID(fid), rc); - RETURN(ERR_PTR(rc)); + return ERR_PTR(rc); } rc = ll_prep_inode(&inode, req, sb, NULL); ptlrpc_req_finished(req); if (rc) - RETURN(ERR_PTR(rc)); + return ERR_PTR(rc); - RETURN(inode); + return inode; } struct lustre_nfs_fid { @@ -141,16 +141,16 @@ ll_iget_for_nfs(struct super_block *sb, struct lu_fid *fid, struct lu_fid *paren CDEBUG(D_INFO, "Get dentry for fid: "DFID"\n", PFID(fid)); if (!fid_is_sane(fid)) - RETURN(ERR_PTR(-ESTALE)); + return ERR_PTR(-ESTALE); inode = search_inode_for_lustre(sb, fid); if (IS_ERR(inode)) - RETURN(ERR_CAST(inode)); + return ERR_CAST(inode); if (is_bad_inode(inode)) { /* we didn't find the right inode.. */ iput(inode); - RETURN(ERR_PTR(-ESTALE)); + return ERR_PTR(-ESTALE); } /** @@ -168,11 +168,11 @@ ll_iget_for_nfs(struct super_block *sb, struct lu_fid *fid, struct lu_fid *paren result = d_obtain_alias(inode); if (IS_ERR(result)) - RETURN(result); + return result; ll_dops_init(result, 1, 0); - RETURN(result); + return result; } #define LUSTRE_NFS_FID 0x97 @@ -196,13 +196,13 @@ static int ll_encode_fh(struct inode *inode, __u32 *fh, int *plen, (int)sizeof(struct lustre_nfs_fid)); if (*plen < sizeof(struct lustre_nfs_fid) / 4) - RETURN(255); + return 255; nfs_fid->lnf_child = *ll_inode2fid(inode); nfs_fid->lnf_parent = *ll_inode2fid(parent); *plen = sizeof(struct lustre_nfs_fid) / 4; - RETURN(LUSTRE_NFS_FID); + return LUSTRE_NFS_FID; } static int ll_nfs_get_name_filldir(void *cookie, const char *name, int namelen, @@ -255,9 +255,9 @@ static struct dentry *ll_fh_to_dentry(struct super_block *sb, struct fid *fid, struct lustre_nfs_fid *nfs_fid = (struct lustre_nfs_fid *)fid; if (fh_type != LUSTRE_NFS_FID) - RETURN(ERR_PTR(-EPROTO)); + return ERR_PTR(-EPROTO); - RETURN(ll_iget_for_nfs(sb, &nfs_fid->lnf_child, &nfs_fid->lnf_parent)); + return ll_iget_for_nfs(sb, &nfs_fid->lnf_child, &nfs_fid->lnf_parent); } static struct dentry *ll_fh_to_parent(struct super_block *sb, struct fid *fid, @@ -266,9 +266,9 @@ static struct dentry *ll_fh_to_parent(struct super_block *sb, struct fid *fid, struct lustre_nfs_fid *nfs_fid = (struct lustre_nfs_fid *)fid; if (fh_type != LUSTRE_NFS_FID) - RETURN(ERR_PTR(-EPROTO)); + return ERR_PTR(-EPROTO); - RETURN(ll_iget_for_nfs(sb, &nfs_fid->lnf_parent, NULL)); + return ll_iget_for_nfs(sb, &nfs_fid->lnf_parent, NULL); } static struct dentry *ll_get_parent(struct dentry *dchild) @@ -292,19 +292,19 @@ static struct dentry *ll_get_parent(struct dentry *dchild) rc = ll_get_max_mdsize(sbi, &lmmsize); if (rc != 0) - RETURN(ERR_PTR(rc)); + return ERR_PTR(rc); op_data = ll_prep_md_op_data(NULL, dir, NULL, dotdot, strlen(dotdot), lmmsize, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN((void *)op_data); + return (void *)op_data; rc = md_getattr_name(sbi->ll_md_exp, op_data, &req); ll_finish_md_op_data(op_data); if (rc) { CERROR("failure %d inode %lu get parent\n", rc, dir->i_ino); - RETURN(ERR_PTR(rc)); + return ERR_PTR(rc); } body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); LASSERT(body->valid & OBD_MD_FLID); @@ -315,7 +315,7 @@ static struct dentry *ll_get_parent(struct dentry *dchild) result = ll_iget_for_nfs(dir->i_sb, &body->fid1, NULL); ptlrpc_req_finished(req); - RETURN(result); + return result; } struct export_operations lustre_export_operations = { diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 8485aa166e43a..179ea9abf68f4 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -384,17 +384,17 @@ static ssize_t ll_max_cached_mb_seq_write(struct file *file, const char *buffer, buffer = lprocfs_find_named_value(buffer, "max_cached_mb:", &count); rc = lprocfs_write_frac_helper(buffer, count, &pages_number, mult); if (rc) - RETURN(rc); + return rc; if (pages_number < 0 || pages_number > totalram_pages) { CERROR("%s: can't set max cache more than %lu MB\n", ll_get_fsname(sb, NULL, 0), totalram_pages >> (20 - PAGE_CACHE_SHIFT)); - RETURN(-ERANGE); + return -ERANGE; } if (sbi->ll_dt_exp == NULL) - RETURN(-ENODEV); + return -ENODEV; spin_lock(&sbi->ll_lock); diff = pages_number - cache->ccc_lru_max; @@ -878,7 +878,7 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent, if (IS_ERR(sbi->ll_proc_root)) { err = PTR_ERR(sbi->ll_proc_root); sbi->ll_proc_root = NULL; - RETURN(err); + return err; } rc = lprocfs_seq_create(sbi->ll_proc_root, "dump_page_cache", 0444, @@ -992,7 +992,7 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent, lprocfs_free_stats(&sbi->ll_ra_stats); lprocfs_free_stats(&sbi->ll_stats); } - RETURN(err); + return err; } void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi) diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c index 494561af27c70..34815b550e712 100644 --- a/drivers/staging/lustre/lustre/llite/namei.c +++ b/drivers/staging/lustre/lustre/llite/namei.c @@ -79,7 +79,7 @@ int ll_unlock(__u32 mode, struct lustre_handle *lockh) { ldlm_lock_decref(lockh, mode); - RETURN(0); + return 0; } @@ -166,7 +166,7 @@ struct inode *ll_iget(struct super_block *sb, ino_t hash, CDEBUG(D_VFSTRACE, "got inode: %p for "DFID"\n", inode, PFID(&md->body->fid1)); } - RETURN(inode); + return inode; } static void ll_invalidate_negative_children(struct inode *dir) @@ -204,7 +204,7 @@ int ll_md_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, rc = ldlm_cli_cancel(&lockh, LCF_ASYNC); if (rc < 0) { CDEBUG(D_INODE, "ldlm_cli_cancel: %d\n", rc); - RETURN(rc); + return rc; } break; case LDLM_CB_CANCELING: { @@ -296,7 +296,7 @@ int ll_md_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, LBUG(); } - RETURN(0); + return 0; } __u32 ll_i2suppgid(struct inode *i) @@ -437,7 +437,7 @@ int ll_lookup_it_finish(struct ptlrpc_request *request, if (!it_disposition(it, DISP_LOOKUP_NEG)) { rc = ll_prep_inode(&inode, request, (*de)->d_sb, it); if (rc) - RETURN(rc); + return rc; ll_set_lock_data(ll_i2sbi(parent)->ll_md_exp, inode, it, &bits); @@ -478,7 +478,7 @@ int ll_lookup_it_finish(struct ptlrpc_request *request, } } - RETURN(0); + return 0; } static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry, @@ -493,7 +493,7 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry, int rc; if (dentry->d_name.len > ll_i2sbi(parent)->ll_namelen) - RETURN(ERR_PTR(-ENAMETOOLONG)); + return ERR_PTR(-ENAMETOOLONG); CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p),intent=%s\n", dentry->d_name.len, dentry->d_name.name, parent->i_ino, @@ -511,7 +511,7 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry, rc = ll_inode_revalidate_it(parent->i_sb->s_root, it, MDS_INODELOCK_LOOKUP); if (rc) - RETURN(ERR_PTR(rc)); + return ERR_PTR(rc); } if (it->it_op == IT_GETATTR) { @@ -536,7 +536,7 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry, dentry->d_name.len, lookup_flags, opc, NULL); if (IS_ERR(op_data)) - RETURN((void *)op_data); + return (void *)op_data; /* enforce umask if acl disabled or MDS doesn't support umask */ if (!IS_POSIXACL(parent) || !exp_connect_umask(ll_i2mdexp(parent))) @@ -623,7 +623,7 @@ static int ll_atomic_open(struct inode *dir, struct dentry *dentry, OBD_ALLOC(it, sizeof(*it)); if (!it) - RETURN(-ENOMEM); + return -ENOMEM; it->it_op = IT_OPEN; if (mode) { @@ -682,7 +682,7 @@ static int ll_atomic_open(struct inode *dir, struct dentry *dentry, ll_intent_release(it); OBD_FREE(it, sizeof(*it)); - RETURN(rc); + return rc; } @@ -745,18 +745,18 @@ static int ll_create_it(struct inode *dir, struct dentry *dentry, int mode, rc = it_open_error(DISP_OPEN_CREATE, it); if (rc) - RETURN(rc); + return rc; inode = ll_create_node(dir, dentry->d_name.name, dentry->d_name.len, NULL, 0, mode, 0, it); if (IS_ERR(inode)) - RETURN(PTR_ERR(inode)); + return PTR_ERR(inode); if (filename_is_volatile(dentry->d_name.name, dentry->d_name.len, NULL)) ll_i2info(inode)->lli_volatile = true; d_instantiate(dentry, inode); - RETURN(0); + return 0; } static void ll_update_times(struct ptlrpc_request *request, @@ -852,7 +852,7 @@ static int ll_mknod_generic(struct inode *dir, struct qstr *name, int mode, if (!err) ll_stats_ops_tally(ll_i2sbi(dir), LPROC_LL_MKNOD, 1); - RETURN(err); + return err; } /* @@ -893,7 +893,7 @@ static int ll_symlink_generic(struct inode *dir, struct qstr *name, if (!err) ll_stats_ops_tally(ll_i2sbi(dir), LPROC_LL_SYMLINK, 1); - RETURN(err); + return err; } static int ll_link_generic(struct inode *src, struct inode *dir, @@ -912,7 +912,7 @@ static int ll_link_generic(struct inode *src, struct inode *dir, op_data = ll_prep_md_op_data(NULL, src, dir, name->name, name->len, 0, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); err = md_link(sbi->ll_md_exp, op_data, &request); ll_finish_md_op_data(op_data); @@ -923,7 +923,7 @@ static int ll_link_generic(struct inode *src, struct inode *dir, ll_stats_ops_tally(sbi, LPROC_LL_LINK, 1); out: ptlrpc_req_finished(request); - RETURN(err); + return err; } static int ll_mkdir_generic(struct inode *dir, struct qstr *name, @@ -943,7 +943,7 @@ static int ll_mkdir_generic(struct inode *dir, struct qstr *name, if (!err) ll_stats_ops_tally(ll_i2sbi(dir), LPROC_LL_MKDIR, 1); - RETURN(err); + return err; } /* Try to find the child dentry by its name. @@ -973,12 +973,12 @@ static int ll_rmdir_generic(struct inode *dir, struct dentry *dparent, name->len, name->name, dir->i_ino, dir->i_generation, dir); if (unlikely(ll_d_mountpoint(dparent, dchild, name))) - RETURN(-EBUSY); + return -EBUSY; op_data = ll_prep_md_op_data(NULL, dir, NULL, name->name, name->len, S_IFDIR, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); ll_get_child_fid(dir, name, &op_data->op_fid3); op_data->op_fid2 = op_data->op_fid3; @@ -990,7 +990,7 @@ static int ll_rmdir_generic(struct inode *dir, struct dentry *dparent, } ptlrpc_req_finished(request); - RETURN(rc); + return rc; } /** @@ -1008,7 +1008,7 @@ int ll_rmdir_entry(struct inode *dir, char *name, int namelen) op_data = ll_prep_md_op_data(NULL, dir, NULL, name, strlen(name), S_IFDIR, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); op_data->op_cli_flags |= CLI_RM_ENTRY; rc = md_unlink(ll_i2sbi(dir)->ll_md_exp, op_data, &request); ll_finish_md_op_data(op_data); @@ -1018,7 +1018,7 @@ int ll_rmdir_entry(struct inode *dir, char *name, int namelen) } ptlrpc_req_finished(request); - RETURN(rc); + return rc; } int ll_objects_destroy(struct ptlrpc_request *request, struct inode *dir) @@ -1034,7 +1034,7 @@ int ll_objects_destroy(struct ptlrpc_request *request, struct inode *dir) /* req is swabbed so this is safe */ body = req_capsule_server_get(&request->rq_pill, &RMF_MDT_BODY); if (!(body->valid & OBD_MD_FLEASIZE)) - RETURN(0); + return 0; if (body->eadatasize == 0) { CERROR("OBD_MD_FLEASIZE set but eadatasize zero\n"); @@ -1114,12 +1114,12 @@ static int ll_unlink_generic(struct inode *dir, struct dentry *dparent, * just check it as vfs_unlink does. */ if (unlikely(ll_d_mountpoint(dparent, dchild, name))) - RETURN(-EBUSY); + return -EBUSY; op_data = ll_prep_md_op_data(NULL, dir, NULL, name->name, name->len, 0, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); ll_get_child_fid(dir, name, &op_data->op_fid3); op_data->op_fid2 = op_data->op_fid3; @@ -1134,7 +1134,7 @@ static int ll_unlink_generic(struct inode *dir, struct dentry *dparent, rc = ll_objects_destroy(request, dir); out: ptlrpc_req_finished(request); - RETURN(rc); + return rc; } static int ll_rename_generic(struct inode *src, struct dentry *src_dparent, @@ -1154,12 +1154,12 @@ static int ll_rename_generic(struct inode *src, struct dentry *src_dparent, if (unlikely(ll_d_mountpoint(src_dparent, src_dchild, src_name) || ll_d_mountpoint(tgt_dparent, tgt_dchild, tgt_name))) - RETURN(-EBUSY); + return -EBUSY; op_data = ll_prep_md_op_data(NULL, src, tgt, NULL, 0, 0, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); ll_get_child_fid(src, src_name, &op_data->op_fid3); ll_get_child_fid(tgt, tgt_name, &op_data->op_fid4); @@ -1176,7 +1176,7 @@ static int ll_rename_generic(struct inode *src, struct dentry *src_dparent, ptlrpc_req_finished(request); - RETURN(err); + return err; } static int ll_mknod(struct inode *dir, struct dentry *dchild, ll_umode_t mode, diff --git a/drivers/staging/lustre/lustre/llite/remote_perm.c b/drivers/staging/lustre/lustre/llite/remote_perm.c index 1d29d7ccb70cc..dedd56ae1e6d5 100644 --- a/drivers/staging/lustre/lustre/llite/remote_perm.c +++ b/drivers/staging/lustre/lustre/llite/remote_perm.c @@ -125,7 +125,7 @@ static int do_check_remote_perm(struct ll_inode_info *lli, int mask) int found = 0, rc; if (!lli->lli_remote_perms) - RETURN(-ENOENT); + return -ENOENT; head = lli->lli_remote_perms + remote_perm_hashfunc(from_kuid(&init_user_ns, current_uid())); @@ -176,7 +176,7 @@ int ll_update_remote_perm(struct inode *inode, struct mdt_remote_perm *perm) perm->rp_uid, perm->rp_gid, perm->rp_fsuid, perm->rp_fsgid, current->uid, current->gid, current->fsuid, current->fsgid); - RETURN(-EAGAIN); + return -EAGAIN; } #endif @@ -184,7 +184,7 @@ int ll_update_remote_perm(struct inode *inode, struct mdt_remote_perm *perm) perm_hash = alloc_rmtperm_hash(); if (perm_hash == NULL) { CERROR("alloc lli_remote_perms failed!\n"); - RETURN(-ENOMEM); + return -ENOMEM; } } @@ -218,7 +218,7 @@ int ll_update_remote_perm(struct inode *inode, struct mdt_remote_perm *perm) lrp = alloc_ll_remote_perm(); if (!lrp) { CERROR("alloc memory for ll_remote_perm failed!\n"); - RETURN(-ENOMEM); + return -ENOMEM; } spin_lock(&lli->lli_lock); goto again; @@ -239,7 +239,7 @@ int ll_update_remote_perm(struct inode *inode, struct mdt_remote_perm *perm) lrp, lrp->lrp_uid, lrp->lrp_gid, lrp->lrp_fsuid, lrp->lrp_fsgid, lrp->lrp_access_perm); - RETURN(0); + return 0; } int lustre_check_remote_perm(struct inode *inode, int mask) @@ -301,7 +301,7 @@ int lustre_check_remote_perm(struct inode *inode, int mask) req = NULL; } while (1); ptlrpc_req_finished(req); - RETURN(rc); + return rc; } #if 0 /* NB: remote perms can't be freed in ll_mdc_blocking_ast of UPDATE lock, diff --git a/drivers/staging/lustre/lustre/llite/rw.c b/drivers/staging/lustre/lustre/llite/rw.c index b20f8b4635ced..ae0dc441d1d9d 100644 --- a/drivers/staging/lustre/lustre/llite/rw.c +++ b/drivers/staging/lustre/lustre/llite/rw.c @@ -252,7 +252,7 @@ int ll_prepare_write(struct file *file, struct page *vmpage, unsigned from, } else { result = PTR_ERR(lcc); } - RETURN(result); + return result; } int ll_commit_write(struct file *file, struct page *vmpage, unsigned from, @@ -282,7 +282,7 @@ int ll_commit_write(struct file *file, struct page *vmpage, unsigned from, lu_ref_del(&page->cp_reference, "prepare_write", current); cl_page_put(env, page); ll_cl_fini(lcc); - RETURN(result); + return result; } struct obd_capa *cl_capa_lookup(struct inode *inode, enum cl_req_type crt) @@ -351,7 +351,7 @@ static unsigned long ll_ra_count_get(struct ll_sb_info *sbi, } out: - RETURN(ret); + return ret; } void ll_ra_count_put(struct ll_sb_info *sbi, unsigned long len) @@ -483,7 +483,7 @@ static int cl_read_ahead_page(const struct lu_env *env, struct cl_io *io, } lu_ref_del(&page->cp_reference, "ra", current); cl_page_put(env, page); - RETURN(rc); + return rc; } /** @@ -544,7 +544,7 @@ static int ll_read_ahead_page(const struct lu_env *env, struct cl_io *io, ll_ra_stats_inc(mapping, which); CDEBUG(D_READA, "%s\n", msg); } - RETURN(rc); + return rc; } #define RIA_DEBUG(ria) \ @@ -724,11 +724,11 @@ int ll_readahead(const struct lu_env *env, struct cl_io *io, cl_object_attr_unlock(clob); if (ret != 0) - RETURN(ret); + return ret; kms = attr->cat_kms; if (kms == 0) { ll_ra_stats_inc(mapping, RA_STAT_ZERO_LEN); - RETURN(0); + return 0; } spin_lock(&ras->ras_lock); @@ -786,11 +786,11 @@ int ll_readahead(const struct lu_env *env, struct cl_io *io, if (end == 0) { ll_ra_stats_inc(mapping, RA_STAT_ZERO_WINDOW); - RETURN(0); + return 0; } len = ria_page_count(ria); if (len == 0) - RETURN(0); + return 0; reserved = ll_ra_count_get(ll_i2sbi(inode), ria, len); if (reserved < len) @@ -829,7 +829,7 @@ int ll_readahead(const struct lu_env *env, struct cl_io *io, spin_unlock(&ras->ras_lock); } - RETURN(ret); + return ret; } static void ras_set_start(struct inode *inode, struct ll_readahead_state *ras, @@ -1266,7 +1266,7 @@ int ll_writepages(struct address_space *mapping, struct writeback_control *wbc) end = i_size_read(inode); mapping->writeback_index = (end >> PAGE_CACHE_SHIFT) + 1; } - RETURN(result); + return result; } int ll_readpage(struct file *file, struct page *vmpage) @@ -1294,5 +1294,5 @@ int ll_readpage(struct file *file, struct page *vmpage) unlock_page(vmpage); result = PTR_ERR(lcc); } - RETURN(result); + return result; } diff --git a/drivers/staging/lustre/lustre/llite/rw26.c b/drivers/staging/lustre/lustre/llite/rw26.c index 1a804773e43c5..96c29ad2fc8c5 100644 --- a/drivers/staging/lustre/lustre/llite/rw26.c +++ b/drivers/staging/lustre/lustre/llite/rw26.c @@ -180,7 +180,7 @@ static int ll_set_page_dirty(struct page *vmpage) */ vvp_write_pending(obj, cpg); #endif - RETURN(__set_page_dirty_nobuffers(vmpage)); + return __set_page_dirty_nobuffers(vmpage); } #define MAX_DIRECTIO_SIZE 2*1024*1024*1024UL @@ -332,7 +332,7 @@ ssize_t ll_direct_rw_pages(const struct lu_env *env, struct cl_io *io, cl_2queue_discard(env, io, queue); cl_2queue_disown(env, io, queue); cl_2queue_fini(env, queue); - RETURN(rc); + return rc; } EXPORT_SYMBOL(ll_direct_rw_pages); @@ -382,11 +382,11 @@ static ssize_t ll_direct_IO_26(int rw, struct kiocb *iocb, int refcheck; if (!lli->lli_has_smd) - RETURN(-EBADF); + return -EBADF; /* FIXME: io smaller than PAGE_SIZE is broken on ia64 ??? */ if ((file_offset & ~CFS_PAGE_MASK) || (count & ~CFS_PAGE_MASK)) - RETURN(-EINVAL); + return -EINVAL; CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p), size=%lu (max %lu), " "offset=%lld=%llx, pages %lu (max %lu)\n", @@ -398,7 +398,7 @@ static ssize_t ll_direct_IO_26(int rw, struct kiocb *iocb, for (seg = 0; seg < nr_segs; seg++) { if (((unsigned long)iov[seg].iov_base & ~CFS_PAGE_MASK) || (iov[seg].iov_len & ~CFS_PAGE_MASK)) - RETURN(-EINVAL); + return -EINVAL; } env = cl_env_get(&refcheck); @@ -491,7 +491,7 @@ static ssize_t ll_direct_IO_26(int rw, struct kiocb *iocb, } cl_env_put(env, &refcheck); - RETURN(tot_bytes ? : result); + return tot_bytes ? : result; } static int ll_write_begin(struct file *file, struct address_space *mapping, @@ -505,7 +505,7 @@ static int ll_write_begin(struct file *file, struct address_space *mapping, page = grab_cache_page_write_begin(mapping, index, flags); if (!page) - RETURN(-ENOMEM); + return -ENOMEM; *pagep = page; @@ -514,7 +514,7 @@ static int ll_write_begin(struct file *file, struct address_space *mapping, unlock_page(page); page_cache_release(page); } - RETURN(rc); + return rc; } static int ll_write_end(struct file *file, struct address_space *mapping, diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c index 2fa29b3d94faa..2daca2e90b113 100644 --- a/drivers/staging/lustre/lustre/llite/statahead.c +++ b/drivers/staging/lustre/lustre/llite/statahead.c @@ -204,7 +204,7 @@ ll_sa_entry_alloc(struct ll_statahead_info *sai, __u64 index, entry_size = sizeof(struct ll_sa_entry) + (len & ~3) + 4; OBD_ALLOC(entry, entry_size); if (unlikely(entry == NULL)) - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); CDEBUG(D_READA, "alloc sa entry %.*s(%p) index "LPU64"\n", len, name, entry, index); @@ -253,7 +253,7 @@ ll_sa_entry_alloc(struct ll_statahead_info *sai, __u64 index, atomic_inc(&sai->sai_cache_count); - RETURN(entry); + return entry; } /* @@ -467,7 +467,7 @@ static struct ll_statahead_info *ll_sai_alloc(void) OBD_ALLOC_PTR(sai); if (!sai) - RETURN(NULL); + return NULL; atomic_set(&sai->sai_refcount, 1); @@ -494,7 +494,7 @@ static struct ll_statahead_info *ll_sai_alloc(void) } atomic_set(&sai->sai_cache_count, 0); - RETURN(sai); + return sai; } static inline struct ll_statahead_info * @@ -841,7 +841,7 @@ static int do_sa_lookup(struct inode *dir, struct ll_sa_entry *entry) rc = sa_args_init(dir, NULL, entry, &minfo, &einfo, capas); if (rc) - RETURN(rc); + return rc; rc = md_intent_getattr_async(ll_i2mdexp(dir), minfo, einfo); if (!rc) { @@ -851,7 +851,7 @@ static int do_sa_lookup(struct inode *dir, struct ll_sa_entry *entry) sa_args_fini(minfo, einfo); } - RETURN(rc); + return rc; } /** @@ -872,27 +872,27 @@ static int do_sa_revalidate(struct inode *dir, struct ll_sa_entry *entry, int rc; if (unlikely(inode == NULL)) - RETURN(1); + return 1; if (d_mountpoint(dentry)) - RETURN(1); + return 1; if (unlikely(dentry == dentry->d_sb->s_root)) - RETURN(1); + return 1; entry->se_inode = igrab(inode); rc = md_revalidate_lock(ll_i2mdexp(dir), &it, ll_inode2fid(inode),NULL); if (rc == 1) { entry->se_handle = it.d.lustre.it_lock_handle; ll_intent_release(&it); - RETURN(1); + return 1; } rc = sa_args_init(dir, inode, entry, &minfo, &einfo, capas); if (rc) { entry->se_inode = NULL; iput(inode); - RETURN(rc); + return rc; } rc = md_intent_getattr_async(ll_i2mdexp(dir), minfo, einfo); @@ -905,7 +905,7 @@ static int do_sa_revalidate(struct inode *dir, struct ll_sa_entry *entry, sa_args_fini(minfo, einfo); } - RETURN(rc); + return rc; } static void ll_statahead_one(struct dentry *parent, const char* entry_name, @@ -1009,7 +1009,7 @@ static int ll_agl_thread(void *arg) ll_sai_put(sai); CDEBUG(D_READA, "agl thread stopped: [pid %d] [parent %.*s]\n", current_pid(), parent->d_name.len, parent->d_name.name); - RETURN(0); + return 0; } static void ll_start_agl(struct dentry *parent, struct ll_statahead_info *sai) @@ -1520,7 +1520,7 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, list_empty(&sai->sai_entries_stated))) { /* to release resource */ ll_stop_statahead(dir, lli->lli_opendir_key); - RETURN(-EAGAIN); + return -EAGAIN; } if ((*dentryp)->d_name.name[0] == '.') { @@ -1546,14 +1546,14 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, * "sai_ls_all" enabled as above. */ sai->sai_miss_hidden++; - RETURN(-EAGAIN); + return -EAGAIN; } } entry = ll_sa_entry_get_byname(sai, &(*dentryp)->d_name); if (entry == NULL || only_unplug) { ll_sai_unplug(sai, entry); - RETURN(entry ? 1 : -EAGAIN); + return entry ? 1 : -EAGAIN; } /* if statahead is busy in readdir, help it do post-work */ @@ -1572,7 +1572,7 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, &lwi); if (rc < 0) { ll_sai_unplug(sai, entry); - RETURN(-EAGAIN); + return -EAGAIN; } } @@ -1602,7 +1602,7 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, inode->i_ino, inode->i_generation); ll_sai_unplug(sai, entry); - RETURN(-ESTALE); + return -ESTALE; } else { iput(inode); } @@ -1616,7 +1616,7 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, } ll_sai_unplug(sai, entry); - RETURN(rc); + return rc; } /* I am the "lli_opendir_pid" owner, only me can set "lli_sai". */ @@ -1668,7 +1668,7 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, thread_set_flags(&sai->sai_agl_thread, SVC_STOPPED); ll_sai_put(sai); LASSERT(lli->lli_sai == NULL); - RETURN(-EAGAIN); + return -EAGAIN; } l_wait_event(thread->t_ctl_waitq, @@ -1679,7 +1679,7 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp, * We don't stat-ahead for the first dirent since we are already in * lookup. */ - RETURN(-EAGAIN); + return -EAGAIN; out: if (sai != NULL) diff --git a/drivers/staging/lustre/lustre/llite/symlink.c b/drivers/staging/lustre/lustre/llite/symlink.c index f64982afe6dc1..ab06891f7fc7c 100644 --- a/drivers/staging/lustre/lustre/llite/symlink.c +++ b/drivers/staging/lustre/lustre/llite/symlink.c @@ -63,13 +63,13 @@ static int ll_readlink_internal(struct inode *inode, CDEBUG(D_INODE, "using cached symlink %s%.*s, len = %d\n", print_limit < symlen ? "..." : "", print_limit, (*symname) + symlen - print_limit, symlen); - RETURN(0); + return 0; } op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, symlen, LUSTRE_OPC_ANY, NULL); if (IS_ERR(op_data)) - RETURN(PTR_ERR(op_data)); + return PTR_ERR(op_data); op_data->op_valid = OBD_MD_LINKNAME; rc = md_getattr(sbi->ll_md_exp, op_data, request); @@ -109,10 +109,10 @@ static int ll_readlink_internal(struct inode *inode, memcpy(lli->lli_symlink_name, *symname, symlen); *symname = lli->lli_symlink_name; } - RETURN(0); + return 0; failed: - RETURN (rc); + return rc; } static int ll_readlink(struct dentry *dentry, char *buffer, int buflen) @@ -133,7 +133,7 @@ static int ll_readlink(struct dentry *dentry, char *buffer, int buflen) out: ptlrpc_req_finished(request); ll_inode_size_unlock(inode); - RETURN(rc); + return rc; } static void *ll_follow_link(struct dentry *dentry, struct nameidata *nd) @@ -166,7 +166,7 @@ static void *ll_follow_link(struct dentry *dentry, struct nameidata *nd) /* symname may contain a pointer to the request message buffer, * we delay request releasing until ll_put_link then. */ - RETURN(request); + return request; } static void ll_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie) diff --git a/drivers/staging/lustre/lustre/llite/vvp_dev.c b/drivers/staging/lustre/lustre/llite/vvp_dev.c index 760595f89e60f..be125b98b7f04 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_dev.c +++ b/drivers/staging/lustre/lustre/llite/vvp_dev.c @@ -213,7 +213,7 @@ int cl_sb_init(struct super_block *sb) cl_env_put(env, &refcheck); } else rc = PTR_ERR(env); - RETURN(rc); + return rc; } int cl_sb_fini(struct super_block *sb) @@ -246,7 +246,7 @@ int cl_sb_fini(struct super_block *sb) * automatically when last device is destroyed). */ lu_types_stop(); - RETURN(result); + return result; } /**************************************************************************** diff --git a/drivers/staging/lustre/lustre/llite/vvp_io.c b/drivers/staging/lustre/lustre/llite/vvp_io.c index c5827b4e16652..3ff664ce7503b 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_io.c +++ b/drivers/staging/lustre/lustre/llite/vvp_io.c @@ -180,14 +180,14 @@ static int vvp_mmap_locks(const struct lu_env *env, LASSERT(io->ci_type == CIT_READ || io->ci_type == CIT_WRITE); if (!cl_is_normalio(env, io)) - RETURN(0); + return 0; if (vio->cui_iov == NULL) /* nfs or loop back device write */ - RETURN(0); + return 0; /* No MM (e.g. NFS)? No vmas too. */ if (mm == NULL) - RETURN(0); + return 0; for (seg = 0; seg < vio->cui_nrsegs; seg++) { const struct iovec *iv = &vio->cui_iov[seg]; @@ -233,7 +233,7 @@ static int vvp_mmap_locks(const struct lu_env *env, descr->cld_end); if (result < 0) - RETURN(result); + return result; if (vma->vm_end - addr >= count) break; @@ -243,7 +243,7 @@ static int vvp_mmap_locks(const struct lu_env *env, } up_read(&mm->mmap_sem); } - RETURN(0); + return 0; } static int vvp_io_rw_lock(const struct lu_env *env, struct cl_io *io, @@ -262,7 +262,7 @@ static int vvp_io_rw_lock(const struct lu_env *env, struct cl_io *io, result = vvp_mmap_locks(env, cio, io); if (result == 0) result = ccc_io_one_lock(env, io, ast_flags, mode, start, end); - RETURN(result); + return result; } static int vvp_io_read_lock(const struct lu_env *env, @@ -280,7 +280,7 @@ static int vvp_io_read_lock(const struct lu_env *env, io->u.ci_rd.rd.crw_count - 1); else result = 0; - RETURN(result); + return result; } static int vvp_io_fault_lock(const struct lu_env *env, @@ -580,7 +580,7 @@ static int vvp_io_write_start(const struct lu_env *env, cio->cui_fd, pos, result, WRITE); result = 0; } - RETURN(result); + return result; } static int vvp_io_kernel_fault(struct vvp_fault_io *cfio) @@ -813,7 +813,7 @@ static int vvp_io_read_page(const struct lu_env *env, rc == -ENODATA ? "without a lock" : "match failed", rc); if (rc != -ENODATA) - RETURN(rc); + return rc; } if (cp->cpg_defer_uptodate) { @@ -830,7 +830,7 @@ static int vvp_io_read_page(const struct lu_env *env, ll_readahead(env, io, ras, vmpage->mapping, &queue->c2_qin, fd->fd_flags); - RETURN(0); + return 0; } static int vvp_page_sync_io(const struct lu_env *env, struct cl_io *io, @@ -934,7 +934,7 @@ static int vvp_io_prepare_write(const struct lu_env *env, pg, cp, from, to); } else CL_PAGE_HEADER(D_PAGE, env, pg, "uptodate\n"); - RETURN(result); + return result; } static int vvp_io_commit_write(const struct lu_env *env, @@ -1057,7 +1057,7 @@ static int vvp_io_commit_write(const struct lu_env *env, cl_page_discard(env, io, pg); } ll_inode_size_unlock(inode); - RETURN(result); + return result; } static const struct cl_io_operations vvp_io_ops = { @@ -1163,7 +1163,7 @@ int vvp_io_init(const struct lu_env *env, struct cl_object *obj, PFID(lu_object_fid(&obj->co_lu)), result); } - RETURN(result); + return result; } static struct vvp_io *cl2vvp_io(const struct lu_env *env, diff --git a/drivers/staging/lustre/lustre/llite/vvp_lock.c b/drivers/staging/lustre/lustre/llite/vvp_lock.c index a48cd5984557d..e16b31e4ff728 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_lock.c +++ b/drivers/staging/lustre/lustre/llite/vvp_lock.c @@ -63,7 +63,7 @@ static unsigned long vvp_lock_weigh(const struct lu_env *env, { struct ccc_object *cob = cl2ccc(slice->cls_obj); - RETURN(atomic_read(&cob->cob_mmap_cnt) > 0 ? ~0UL >> 2 : 0); + return atomic_read(&cob->cob_mmap_cnt) > 0 ? ~0UL >> 2 : 0; } static const struct cl_lock_operations vvp_lock_ops = { diff --git a/drivers/staging/lustre/lustre/llite/vvp_page.c b/drivers/staging/lustre/lustre/llite/vvp_page.c index 78729190e74be..1c02c128e0ee0 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_page.c +++ b/drivers/staging/lustre/lustre/llite/vvp_page.c @@ -219,7 +219,7 @@ static int vvp_page_prep_read(const struct lu_env *env, struct cl_io *unused) { /* Skip the page already marked as PG_uptodate. */ - RETURN(PageUptodate(cl2vm_page(slice)) ? -EALREADY : 0); + return PageUptodate(cl2vm_page(slice)) ? -EALREADY : 0; } static int vvp_page_prep_write(const struct lu_env *env, @@ -366,7 +366,7 @@ static int vvp_page_make_ready(const struct lu_env *env, LBUG(); } unlock_page(vmpage); - RETURN(result); + return result; } static int vvp_page_print(const struct lu_env *env, diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c index cf1bb4fc36e65..bcf86bac30a91 100644 --- a/drivers/staging/lustre/lustre/llite/xattr.c +++ b/drivers/staging/lustre/lustre/llite/xattr.c @@ -122,22 +122,22 @@ int ll_setxattr_common(struct inode *inode, const char *name, xattr_type = get_xattr_type(name); rc = xattr_type_filter(sbi, xattr_type); if (rc) - RETURN(rc); + return rc; /* b10667: ignore lustre special xattr for now */ if ((xattr_type == XATTR_TRUSTED_T && strcmp(name, "trusted.lov") == 0) || (xattr_type == XATTR_LUSTRE_T && strcmp(name, "lustre.lov") == 0)) - RETURN(0); + return 0; /* b15587: ignore security.capability xattr for now */ if ((xattr_type == XATTR_SECURITY_T && strcmp(name, "security.capability") == 0)) - RETURN(0); + return 0; /* LU-549: Disable security.selinux when selinux is disabled */ if (xattr_type == XATTR_SECURITY_T && !selinux_is_enabled() && strcmp(name, "security.selinux") == 0) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; #ifdef CONFIG_FS_POSIX_ACL if (sbi->ll_flags & LL_SBI_RMT_CLIENT && @@ -147,7 +147,7 @@ int ll_setxattr_common(struct inode *inode, const char *name, if (rce == NULL || (rce->rce_ops != RMT_LSETFACL && rce->rce_ops != RMT_RSETFACL)) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; if (rce->rce_ops == RMT_LSETFACL) { struct eacl_entry *ee; @@ -161,7 +161,7 @@ int ll_setxattr_common(struct inode *inode, const char *name, size, ee->ee_acl); if (IS_ERR(acl)) { ee_free(ee); - RETURN(PTR_ERR(acl)); + return PTR_ERR(acl); } size = CFS_ACL_XATTR_SIZE(\ le32_to_cpu(acl->a_count), \ @@ -174,11 +174,11 @@ int ll_setxattr_common(struct inode *inode, const char *name, (posix_acl_xattr_header *)value, size, &new_value); if (unlikely(size < 0)) - RETURN(size); + return size; pv = (const char *)new_value; } else - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; valid |= rce_ops2valid(rce->rce_ops); } @@ -200,11 +200,11 @@ int ll_setxattr_common(struct inode *inode, const char *name, "it is not supported on the server\n"); sbi->ll_flags &= ~LL_SBI_USER_XATTR; } - RETURN(rc); + return rc; } ptlrpc_req_finished(req); - RETURN(0); + return 0; } int ll_setxattr(struct dentry *dentry, const char *name, @@ -302,17 +302,17 @@ int ll_getxattr_common(struct inode *inode, const char *name, xattr_type = get_xattr_type(name); rc = xattr_type_filter(sbi, xattr_type); if (rc) - RETURN(rc); + return rc; /* b15587: ignore security.capability xattr for now */ if ((xattr_type == XATTR_SECURITY_T && strcmp(name, "security.capability") == 0)) - RETURN(-ENODATA); + return -ENODATA; /* LU-549: Disable security.selinux when selinux is disabled */ if (xattr_type == XATTR_SECURITY_T && !selinux_is_enabled() && strcmp(name, "security.selinux") == 0) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; #ifdef CONFIG_FS_POSIX_ACL if (sbi->ll_flags & LL_SBI_RMT_CLIENT && @@ -324,7 +324,7 @@ int ll_getxattr_common(struct inode *inode, const char *name, rce->rce_ops != RMT_LGETFACL && rce->rce_ops != RMT_RSETFACL && rce->rce_ops != RMT_RGETFACL)) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; } /* posix acl is under protection of LOOKUP lock. when calling to this, @@ -341,14 +341,14 @@ int ll_getxattr_common(struct inode *inode, const char *name, spin_unlock(&lli->lli_lock); if (!acl) - RETURN(-ENODATA); + return -ENODATA; rc = posix_acl_to_xattr(&init_user_ns, acl, buffer, size); posix_acl_release(acl); - RETURN(rc); + return rc; } if (xattr_type == XATTR_ACL_DEFAULT_T && !S_ISDIR(inode->i_mode)) - RETURN(-ENODATA); + return -ENODATA; #endif do_getxattr: @@ -363,7 +363,7 @@ int ll_getxattr_common(struct inode *inode, const char *name, "it is not supported on the server\n"); sbi->ll_flags &= ~LL_SBI_USER_XATTR; } - RETURN(rc); + return rc; } body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); diff --git a/drivers/staging/lustre/lustre/lmv/lmv_fld.c b/drivers/staging/lustre/lustre/lmv/lmv_fld.c index 7ca3fb50a9621..0b2d38d1362b7 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_fld.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_fld.c @@ -69,7 +69,7 @@ int lmv_fld_lookup(struct lmv_obd *lmv, if (rc) { CERROR("Error while looking for mds number. Seq "LPX64 ", err = %d\n", fid_seq(fid), rc); - RETURN(rc); + return rc; } CDEBUG(D_INODE, "FLD lookup got mds #%x for fid="DFID"\n", @@ -81,5 +81,5 @@ int lmv_fld_lookup(struct lmv_obd *lmv, PFID(fid)); rc = -EINVAL; } - RETURN(rc); + return rc; } diff --git a/drivers/staging/lustre/lustre/lmv/lmv_intent.c b/drivers/staging/lustre/lustre/lmv/lmv_intent.c index 9d97b5b8a35ba..511b3b4b699b9 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_intent.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_intent.c @@ -72,7 +72,7 @@ static int lmv_intent_remote(struct obd_export *exp, void *lmm, body = req_capsule_server_get(&(*reqp)->rq_pill, &RMF_MDT_BODY); if (body == NULL) - RETURN(-EPROTO); + return -EPROTO; LASSERT((body->valid & OBD_MD_MDS)); @@ -169,7 +169,7 @@ int lmv_intent_open(struct obd_export *exp, struct md_op_data *op_data, tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); /* If it is ready to open the file by FID, do not need * allocate FID at all, otherwise it will confuse MDT */ @@ -182,7 +182,7 @@ int lmv_intent_open(struct obd_export *exp, struct md_op_data *op_data, op_data->op_fid3 = op_data->op_fid2; rc = lmv_fid_alloc(exp, &op_data->op_fid2, op_data); if (rc != 0) - RETURN(rc); + return rc; } CDEBUG(D_INODE, "OPEN_INTENT with fid1="DFID", fid2="DFID"," @@ -192,7 +192,7 @@ int lmv_intent_open(struct obd_export *exp, struct md_op_data *op_data, rc = md_intent_lock(tgt->ltd_exp, op_data, lmm, lmmsize, it, flags, reqp, cb_blocking, extra_lock_flags); if (rc != 0) - RETURN(rc); + return rc; /* * Nothing is found, do not access body->fid1 as it is zero and thus * pointless. @@ -200,16 +200,16 @@ int lmv_intent_open(struct obd_export *exp, struct md_op_data *op_data, if ((it->d.lustre.it_disposition & DISP_LOOKUP_NEG) && !(it->d.lustre.it_disposition & DISP_OPEN_CREATE) && !(it->d.lustre.it_disposition & DISP_OPEN_OPEN)) - RETURN(rc); + return rc; body = req_capsule_server_get(&(*reqp)->rq_pill, &RMF_MDT_BODY); if (body == NULL) - RETURN(-EPROTO); + return -EPROTO; /* * Not cross-ref case, just get out of here. */ if (likely(!(body->valid & OBD_MD_MDS))) - RETURN(0); + return 0; /* * Okay, MDS has returned success. Probably name has been resolved in @@ -229,10 +229,10 @@ int lmv_intent_open(struct obd_export *exp, struct md_op_data *op_data, "%*s: %d\n", LL_IT2STR(it), PFID(&op_data->op_fid2), PFID(&op_data->op_fid1), op_data->op_namelen, op_data->op_name, rc); - RETURN(rc); + return rc; } - RETURN(rc); + return rc; } /* @@ -252,7 +252,7 @@ int lmv_intent_lookup(struct obd_export *exp, struct md_op_data *op_data, tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); if (!fid_is_sane(&op_data->op_fid2)) fid_zero(&op_data->op_fid2); @@ -269,7 +269,7 @@ int lmv_intent_lookup(struct obd_export *exp, struct md_op_data *op_data, flags, reqp, cb_blocking, extra_lock_flags); if (rc < 0 || *reqp == NULL) - RETURN(rc); + return rc; /* * MDS has returned success. Probably name has been resolved in @@ -277,15 +277,15 @@ int lmv_intent_lookup(struct obd_export *exp, struct md_op_data *op_data, */ body = req_capsule_server_get(&(*reqp)->rq_pill, &RMF_MDT_BODY); if (body == NULL) - RETURN(-EPROTO); + return -EPROTO; /* Not cross-ref case, just get out of here. */ if (likely(!(body->valid & OBD_MD_MDS))) - RETURN(0); + return 0; rc = lmv_intent_remote(exp, lmm, lmmsize, it, NULL, flags, reqp, cb_blocking, extra_lock_flags); - RETURN(rc); + return rc; } int lmv_intent_lock(struct obd_export *exp, struct md_op_data *op_data, @@ -306,7 +306,7 @@ int lmv_intent_lock(struct obd_export *exp, struct md_op_data *op_data, rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; if (it->it_op & (IT_LOOKUP | IT_GETATTR | IT_LAYOUT)) rc = lmv_intent_lookup(exp, op_data, lmm, lmmsize, it, @@ -318,5 +318,5 @@ int lmv_intent_lock(struct obd_export *exp, struct md_op_data *op_data, extra_lock_flags); else LBUG(); - RETURN(rc); + return rc; } diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index 48d80331f031e..bd2575aed08d9 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -143,7 +143,7 @@ static int lmv_notify(struct obd_device *obd, struct obd_device *watched, CERROR("unexpected notification of %s %s!\n", watched->obd_type->typ_name, watched->obd_name); - RETURN(-EINVAL); + return -EINVAL; } uuid = &watched->u.cli.cl_target_uuid; @@ -158,7 +158,7 @@ static int lmv_notify(struct obd_device *obd, struct obd_device *watched, CERROR("%sactivation of %s failed: %d\n", ev == OBD_NOTIFY_ACTIVE ? "" : "de", uuid->uuid, rc); - RETURN(rc); + return rc; } } else if (ev == OBD_NOTIFY_OCD) { conn_data = &watched->u.cli.cl_import->imp_connect_data; @@ -183,7 +183,7 @@ static int lmv_notify(struct obd_device *obd, struct obd_device *watched, if (obd->obd_observer) rc = obd_notify(obd->obd_observer, watched, ev, data); - RETURN(rc); + return rc; } /** @@ -207,13 +207,13 @@ static int lmv_connect(const struct lu_env *env, lmv->refcount++; if (lmv->refcount > 1) { *exp = NULL; - RETURN(0); + return 0; } rc = class_connect(&conn, obd, cluuid); if (rc) { CERROR("class_connection() returned %d\n", rc); - RETURN(rc); + return rc; } *exp = class_conn2export(&conn); @@ -253,7 +253,7 @@ static int lmv_connect(const struct lu_env *env, obd->obd_proc_private = NULL; } - RETURN(rc); + return rc; } static void lmv_set_timeouts(struct obd_device *obd) @@ -301,10 +301,10 @@ static int lmv_init_ea_size(struct obd_export *exp, int easize, change = 1; } if (change == 0) - RETURN(0); + return 0; if (lmv->connected == 0) - RETURN(0); + return 0; for (i = 0; i < lmv->desc.ld_tgt_count; i++) { if (lmv->tgts[i] == NULL || @@ -322,7 +322,7 @@ static int lmv_init_ea_size(struct obd_export *exp, int easize, break; } } - RETURN(rc); + return rc; } #define MAX_STRING_SIZE 128 @@ -342,7 +342,7 @@ int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) &obd->obd_uuid); if (!mdc_obd) { CERROR("target %s not attached\n", tgt->ltd_uuid.uuid); - RETURN(-EINVAL); + return -EINVAL; } CDEBUG(D_CONFIG, "connect to %s(%s) - %s, %s FOR %s\n", @@ -352,14 +352,14 @@ int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) if (!mdc_obd->obd_set_up) { CERROR("target %s is not set up\n", tgt->ltd_uuid.uuid); - RETURN(-EINVAL); + return -EINVAL; } rc = obd_connect(NULL, &mdc_exp, mdc_obd, &lmv_mdc_uuid, &lmv->conn_data, NULL); if (rc) { CERROR("target %s connect error %d\n", tgt->ltd_uuid.uuid, rc); - RETURN(rc); + return rc; } /* @@ -367,7 +367,7 @@ int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) */ rc = obd_fid_init(mdc_obd, mdc_exp, LUSTRE_SEQ_METADATA); if (rc) - RETURN(rc); + return rc; target.ft_srv = NULL; target.ft_exp = mdc_exp; @@ -380,7 +380,7 @@ int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) obd_disconnect(mdc_exp); CERROR("target %s register_observer error %d\n", tgt->ltd_uuid.uuid, rc); - RETURN(rc); + return rc; } if (obd->obd_observer) { @@ -392,7 +392,7 @@ int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) (void *)(tgt - lmv->tgts[0])); if (rc) { obd_disconnect(mdc_exp); - RETURN(rc); + return rc; } } @@ -427,7 +427,7 @@ int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) obd->obd_proc_private = NULL; } } - RETURN(0); + return 0; } static void lmv_del_target(struct lmv_obd *lmv, int index) @@ -460,7 +460,7 @@ static int lmv_add_target(struct obd_device *obd, struct obd_uuid *uuidp, lmv_init_unlock(lmv); CERROR("%s: Target %s not attached: rc = %d\n", obd->obd_name, uuidp->uuid, -EINVAL); - RETURN(-EINVAL); + return -EINVAL; } } @@ -470,7 +470,7 @@ static int lmv_add_target(struct obd_device *obd, struct obd_uuid *uuidp, " rc = %d\n", obd->obd_name, obd_uuid2str(&tgt->ltd_uuid), index, -EEXIST); lmv_init_unlock(lmv); - RETURN(-EEXIST); + return -EEXIST; } if (index >= lmv->tgts_size) { @@ -484,7 +484,7 @@ static int lmv_add_target(struct obd_device *obd, struct obd_uuid *uuidp, OBD_ALLOC(newtgts, sizeof(*newtgts) * newsize); if (newtgts == NULL) { lmv_init_unlock(lmv); - RETURN(-ENOMEM); + return -ENOMEM; } if (lmv->tgts_size) { @@ -507,7 +507,7 @@ static int lmv_add_target(struct obd_device *obd, struct obd_uuid *uuidp, OBD_ALLOC_PTR(tgt); if (!tgt) { lmv_init_unlock(lmv); - RETURN(-ENOMEM); + return -ENOMEM; } mutex_init(&tgt->ltd_fid_mutex); @@ -534,7 +534,7 @@ static int lmv_add_target(struct obd_device *obd, struct obd_uuid *uuidp, } lmv_init_unlock(lmv); - RETURN(rc); + return rc; } int lmv_check_connect(struct obd_device *obd) @@ -546,18 +546,18 @@ int lmv_check_connect(struct obd_device *obd) int easize; if (lmv->connected) - RETURN(0); + return 0; lmv_init_lock(lmv); if (lmv->connected) { lmv_init_unlock(lmv); - RETURN(0); + return 0; } if (lmv->desc.ld_tgt_count == 0) { lmv_init_unlock(lmv); CERROR("%s: no targets configured.\n", obd->obd_name); - RETURN(-EINVAL); + return -EINVAL; } CDEBUG(D_CONFIG, "Time to connect %s to %s\n", @@ -580,7 +580,7 @@ int lmv_check_connect(struct obd_device *obd) easize = lmv_get_easize(lmv); lmv_init_ea_size(obd->obd_self_export, easize, 0, 0); lmv_init_unlock(lmv); - RETURN(0); + return 0; out_disc: while (i-- > 0) { @@ -601,7 +601,7 @@ int lmv_check_connect(struct obd_device *obd) } class_disconnect(lmv->exp); lmv_init_unlock(lmv); - RETURN(rc); + return rc; } static int lmv_disconnect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) @@ -645,7 +645,7 @@ static int lmv_disconnect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) lmv_activate_target(lmv, tgt, 0); tgt->ltd_exp = NULL; - RETURN(0); + return 0; } static int lmv_disconnect(struct obd_export *exp) @@ -688,7 +688,7 @@ static int lmv_disconnect(struct obd_export *exp) rc = class_disconnect(exp); if (lmv->refcount == 0) lmv->connected = 0; - RETURN(rc); + return rc; } static int lmv_fid2path(struct obd_export *exp, int len, void *karg, void *uarg) @@ -704,7 +704,7 @@ static int lmv_fid2path(struct obd_export *exp, int len, void *karg, void *uarg) gf = (struct getinfo_fid2path *)karg; tgt = lmv_find_target(lmv, &gf->gf_fid); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); repeat_fid2path: rc = obd_iocontrol(OBD_IOC_FID2PATH, tgt->ltd_exp, len, gf, uarg); @@ -770,7 +770,7 @@ static int lmv_fid2path(struct obd_export *exp, int len, void *karg, void *uarg) out_fid2path: if (remote_gf != NULL) OBD_FREE(remote_gf, remote_gf_size); - RETURN(rc); + return rc; } static int lmv_hsm_req_count(struct lmv_obd *lmv, @@ -831,7 +831,7 @@ static int lmv_hsm_ct_unregister(struct lmv_obd *lmv, unsigned int cmd, int len, * and will unregister automatically. */ rc = libcfs_kkuc_group_rem(lk->lk_uid, lk->lk_group); - RETURN(rc); + return rc; } static int lmv_hsm_ct_register(struct lmv_obd *lmv, unsigned int cmd, int len, @@ -862,7 +862,7 @@ static int lmv_hsm_ct_register(struct lmv_obd *lmv, unsigned int cmd, int len, obd_iocontrol(cmd, lmv->tgts[j]->ltd_exp, len, lk, uarg); - RETURN(rc); + return rc; } /* else: transient error. * kuc will register to the missing MDT @@ -874,17 +874,17 @@ static int lmv_hsm_ct_register(struct lmv_obd *lmv, unsigned int cmd, int len, if (!any_set) /* no registration done: return error */ - RETURN(-ENOTCONN); + return -ENOTCONN; /* at least one registration done, with no failure */ filp = fget(lk->lk_wfd); if (filp == NULL) { - RETURN(-EBADF); + return -EBADF; } rc = libcfs_kkuc_group_add(filp, lk->lk_uid, lk->lk_group, lk->lk_data); if (rc != 0 && filp != NULL) fput(filp); - RETURN(rc); + return rc; } @@ -901,7 +901,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, int count = lmv->desc.ld_tgt_count; if (count == 0) - RETURN(-ENOTTY); + return -ENOTTY; switch (cmd) { case IOC_OBD_STATFS: { @@ -912,31 +912,31 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, memcpy(&index, data->ioc_inlbuf2, sizeof(__u32)); if ((index >= count)) - RETURN(-ENODEV); + return -ENODEV; if (lmv->tgts[index] == NULL || lmv->tgts[index]->ltd_active == 0) - RETURN(-ENODATA); + return -ENODATA; mdc_obd = class_exp2obd(lmv->tgts[index]->ltd_exp); if (!mdc_obd) - RETURN(-EINVAL); + return -EINVAL; /* copy UUID */ if (copy_to_user(data->ioc_pbuf2, obd2cli_tgt(mdc_obd), min((int) data->ioc_plen2, (int) sizeof(struct obd_uuid)))) - RETURN(-EFAULT); + return -EFAULT; rc = obd_statfs(NULL, lmv->tgts[index]->ltd_exp, &stat_buf, cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), 0); if (rc) - RETURN(rc); + return rc; if (copy_to_user(data->ioc_pbuf1, &stat_buf, min((int) data->ioc_plen1, (int) sizeof(stat_buf)))) - RETURN(-EFAULT); + return -EFAULT; break; } case OBD_IOC_QUOTACTL: { @@ -946,11 +946,11 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, if (qctl->qc_valid == QC_MDTIDX) { if (qctl->qc_idx < 0 || count <= qctl->qc_idx) - RETURN(-EINVAL); + return -EINVAL; tgt = lmv->tgts[qctl->qc_idx]; if (tgt == NULL || tgt->ltd_exp == NULL) - RETURN(-EINVAL); + return -EINVAL; } else if (qctl->qc_valid == QC_UUID) { for (i = 0; i < count; i++) { tgt = lmv->tgts[i]; @@ -961,21 +961,21 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, continue; if (tgt->ltd_exp == NULL) - RETURN(-EINVAL); + return -EINVAL; break; } } else { - RETURN(-EINVAL); + return -EINVAL; } if (i >= count) - RETURN(-EAGAIN); + return -EAGAIN; LASSERT(tgt && tgt->ltd_exp); OBD_ALLOC_PTR(oqctl); if (!oqctl) - RETURN(-ENOMEM); + return -ENOMEM; QCTL_COPY(oqctl, qctl); rc = obd_quotactl(tgt->ltd_exp, oqctl); @@ -992,19 +992,19 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, struct ioc_changelog *icc = karg; if (icc->icc_mdtindex >= count) - RETURN(-ENODEV); + return -ENODEV; if (lmv->tgts[icc->icc_mdtindex] == NULL || lmv->tgts[icc->icc_mdtindex]->ltd_exp == NULL || lmv->tgts[icc->icc_mdtindex]->ltd_active == 0) - RETURN(-ENODEV); + return -ENODEV; rc = obd_iocontrol(cmd, lmv->tgts[icc->icc_mdtindex]->ltd_exp, sizeof(*icc), icc, NULL); break; } case LL_IOC_GET_CONNECT_FLAGS: { if (lmv->tgts[0] == NULL) - RETURN(-ENODATA); + return -ENODATA; rc = obd_iocontrol(cmd, lmv->tgts[0]->ltd_exp, len, karg, uarg); break; } @@ -1020,10 +1020,10 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, tgt = lmv_find_target(lmv, &op_data->op_fid1); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); if (tgt->ltd_exp == NULL) - RETURN(-EINVAL); + return -EINVAL; rc = obd_iocontrol(cmd, tgt->ltd_exp, len, karg, uarg); break; @@ -1034,7 +1034,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, tgt = lmv_find_target(lmv, &hpk->hpk_fid); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); rc = obd_iocontrol(cmd, tgt->ltd_exp, len, karg, uarg); break; } @@ -1044,7 +1044,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, unsigned int reqcount = hur->hur_request.hr_itemcount; if (reqcount == 0) - RETURN(0); + return 0; /* if the request is about a single fid * or if there is a single MDS, no need to split @@ -1053,7 +1053,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, tgt = lmv_find_target(lmv, &hur->hur_user_item[0].hui_fid); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); rc = obd_iocontrol(cmd, tgt->ltd_exp, len, karg, uarg); } else { /* split fid list to their respective MDS */ @@ -1072,7 +1072,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, + hur->hur_request.hr_data_len; OBD_ALLOC_LARGE(req, reqlen); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; lmv_hsm_req_build(lmv, hur, lmv->tgts[i], req); @@ -1091,18 +1091,18 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, tgt1 = lmv_find_target(lmv, &op_data->op_fid1); if (IS_ERR(tgt1)) - RETURN(PTR_ERR(tgt1)); + return PTR_ERR(tgt1); tgt2 = lmv_find_target(lmv, &op_data->op_fid2); if (IS_ERR(tgt2)) - RETURN(PTR_ERR(tgt2)); + return PTR_ERR(tgt2); if ((tgt1->ltd_exp == NULL) || (tgt2->ltd_exp == NULL)) - RETURN(-EINVAL); + return -EINVAL; /* only files on same MDT can have their layouts swapped */ if (tgt1->ltd_idx != tgt2->ltd_idx) - RETURN(-EPERM); + return -EPERM; rc = obd_iocontrol(cmd, tgt1->ltd_exp, len, karg, uarg); break; @@ -1130,7 +1130,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, err = obd_iocontrol(cmd, lmv->tgts[i]->ltd_exp, len, karg, uarg); if (err == -ENODATA && cmd == OBD_IOC_POLL_QUOTACHECK) { - RETURN(err); + return err; } else if (err) { if (lmv->tgts[i]->ltd_active) { CERROR("error: iocontrol MDC %s on MDT" @@ -1146,7 +1146,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, if (!set && !rc) rc = -EIO; } - RETURN(rc); + return rc; } #if 0 @@ -1207,7 +1207,7 @@ static int lmv_placement_policy(struct obd_device *obd, if (lmv->desc.ld_tgt_count == 1) { *mds = 0; - RETURN(0); + return 0; } /** @@ -1225,17 +1225,17 @@ static int lmv_placement_policy(struct obd_device *obd, " rc = %d\n", obd->obd_name, lum->lum_stripe_offset, lmv->desc.ld_tgt_count, -ERANGE); - RETURN(-ERANGE); + return -ERANGE; } *mds = lum->lum_stripe_offset; - RETURN(0); + return 0; } } /* Allocate new fid on target according to operation type and parent * home mds. */ *mds = op_data->op_mds; - RETURN(0); + return 0; } int __lmv_fid_alloc(struct lmv_obd *lmv, struct lu_fid *fid, @@ -1246,7 +1246,7 @@ int __lmv_fid_alloc(struct lmv_obd *lmv, struct lu_fid *fid, tgt = lmv_get_target(lmv, mds); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); /* * New seq alloc and FLD setup should be atomic. Otherwise we may find @@ -1286,16 +1286,16 @@ int lmv_fid_alloc(struct obd_export *exp, struct lu_fid *fid, if (rc) { CERROR("Can't get target for allocating fid, " "rc %d\n", rc); - RETURN(rc); + return rc; } rc = __lmv_fid_alloc(lmv, fid, mds); if (rc) { CERROR("Can't alloc new fid, rc %d\n", rc); - RETURN(rc); + return rc; } - RETURN(rc); + return rc; } static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg) @@ -1307,19 +1307,19 @@ static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg) if (LUSTRE_CFG_BUFLEN(lcfg, 1) < 1) { CERROR("LMV setup requires a descriptor\n"); - RETURN(-EINVAL); + return -EINVAL; } desc = (struct lmv_desc *)lustre_cfg_buf(lcfg, 1); if (sizeof(*desc) > LUSTRE_CFG_BUFLEN(lcfg, 1)) { CERROR("Lmv descriptor size wrong: %d > %d\n", (int)sizeof(*desc), LUSTRE_CFG_BUFLEN(lcfg, 1)); - RETURN(-EINVAL); + return -EINVAL; } OBD_ALLOC(lmv->tgts, sizeof(*lmv->tgts) * 32); if (lmv->tgts == NULL) - RETURN(-ENOMEM); + return -ENOMEM; lmv->tgts_size = 32; obd_str2uuid(&lmv->desc.ld_uuid, desc->ld_uuid.uuid); @@ -1352,7 +1352,7 @@ static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg) GOTO(out, rc); } - RETURN(0); + return 0; out: return rc; @@ -1373,7 +1373,7 @@ static int lmv_cleanup(struct obd_device *obd) OBD_FREE(lmv->tgts, sizeof(*lmv->tgts) * lmv->tgts_size); lmv->tgts_size = 0; } - RETURN(0); + return 0; } static int lmv_process_config(struct obd_device *obd, obd_count len, void *buf) @@ -1404,7 +1404,7 @@ static int lmv_process_config(struct obd_device *obd, obd_count len, void *buf) GOTO(out, rc = -EINVAL); } out: - RETURN(rc); + return rc; } static int lmv_statfs(const struct lu_env *env, struct obd_export *exp, @@ -1418,11 +1418,11 @@ static int lmv_statfs(const struct lu_env *env, struct obd_export *exp, rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; OBD_ALLOC(temp, sizeof(*temp)); if (temp == NULL) - RETURN(-ENOMEM); + return -ENOMEM; for (i = 0; i < lmv->desc.ld_tgt_count; i++) { if (lmv->tgts[i] == NULL || lmv->tgts[i]->ltd_exp == NULL) @@ -1470,10 +1470,10 @@ static int lmv_getstatus(struct obd_export *exp, rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; rc = md_getstatus(lmv->tgts[0]->ltd_exp, fid, pc); - RETURN(rc); + return rc; } static int lmv_getxattr(struct obd_export *exp, const struct lu_fid *fid, @@ -1488,16 +1488,16 @@ static int lmv_getxattr(struct obd_export *exp, const struct lu_fid *fid, rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; tgt = lmv_find_target(lmv, fid); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); rc = md_getxattr(tgt->ltd_exp, fid, oc, valid, name, input, input_size, output_size, flags, request); - RETURN(rc); + return rc; } static int lmv_setxattr(struct obd_export *exp, const struct lu_fid *fid, @@ -1513,17 +1513,17 @@ static int lmv_setxattr(struct obd_export *exp, const struct lu_fid *fid, rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; tgt = lmv_find_target(lmv, fid); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); rc = md_setxattr(tgt->ltd_exp, fid, oc, valid, name, input, input_size, output_size, flags, suppgid, request); - RETURN(rc); + return rc; } static int lmv_getattr(struct obd_export *exp, struct md_op_data *op_data, @@ -1536,20 +1536,20 @@ static int lmv_getattr(struct obd_export *exp, struct md_op_data *op_data, rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; tgt = lmv_find_target(lmv, &op_data->op_fid1); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); if (op_data->op_flags & MF_GET_MDT_IDX) { op_data->op_mds = tgt->ltd_idx; - RETURN(0); + return 0; } rc = md_getattr(tgt->ltd_exp, op_data, request); - RETURN(rc); + return rc; } static int lmv_null_inode(struct obd_export *exp, const struct lu_fid *fid) @@ -1561,7 +1561,7 @@ static int lmv_null_inode(struct obd_export *exp, const struct lu_fid *fid) rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; CDEBUG(D_INODE, "CBDATA for "DFID"\n", PFID(fid)); @@ -1576,7 +1576,7 @@ static int lmv_null_inode(struct obd_export *exp, const struct lu_fid *fid) md_null_inode(lmv->tgts[i]->ltd_exp, fid); } - RETURN(0); + return 0; } static int lmv_find_cbdata(struct obd_export *exp, const struct lu_fid *fid, @@ -1589,7 +1589,7 @@ static int lmv_find_cbdata(struct obd_export *exp, const struct lu_fid *fid, rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; CDEBUG(D_INODE, "CBDATA for "DFID"\n", PFID(fid)); @@ -1603,10 +1603,10 @@ static int lmv_find_cbdata(struct obd_export *exp, const struct lu_fid *fid, continue; rc = md_find_cbdata(lmv->tgts[i]->ltd_exp, fid, it, data); if (rc) - RETURN(rc); + return rc; } - RETURN(rc); + return rc; } @@ -1620,15 +1620,15 @@ static int lmv_close(struct obd_export *exp, struct md_op_data *op_data, rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; tgt = lmv_find_target(lmv, &op_data->op_fid1); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); CDEBUG(D_INODE, "CLOSE "DFID"\n", PFID(&op_data->op_fid1)); rc = md_close(tgt->ltd_exp, op_data, mod, request); - RETURN(rc); + return rc; } struct lmv_tgt_desc @@ -1658,18 +1658,18 @@ int lmv_create(struct obd_export *exp, struct md_op_data *op_data, rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; if (!lmv->desc.ld_active_tgt_count) - RETURN(-EIO); + return -EIO; tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); rc = lmv_fid_alloc(exp, &op_data->op_fid2, op_data); if (rc) - RETURN(rc); + return rc; CDEBUG(D_INODE, "CREATE '%*s' on "DFID" -> mds #%x\n", op_data->op_namelen, op_data->op_name, PFID(&op_data->op_fid1), @@ -1681,10 +1681,10 @@ int lmv_create(struct obd_export *exp, struct md_op_data *op_data, if (rc == 0) { if (*request == NULL) - RETURN(rc); + return rc; CDEBUG(D_INODE, "Created - "DFID"\n", PFID(&op_data->op_fid2)); } - RETURN(rc); + return rc; } static int lmv_done_writing(struct obd_export *exp, @@ -1698,14 +1698,14 @@ static int lmv_done_writing(struct obd_export *exp, rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; tgt = lmv_find_target(lmv, &op_data->op_fid1); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); rc = md_done_writing(tgt->ltd_exp, op_data, mod); - RETURN(rc); + return rc; } static int @@ -1729,7 +1729,7 @@ lmv_enqueue_remote(struct obd_export *exp, struct ldlm_enqueue_info *einfo, LASSERT(body != NULL); if (!(body->valid & OBD_MD_MDS)) - RETURN(0); + return 0; CDEBUG(D_INODE, "REMOTE_ENQUEUE '%s' on "DFID" -> "DFID"\n", LL_IT2STR(it), PFID(&op_data->op_fid1), PFID(&body->fid1)); @@ -1779,14 +1779,14 @@ lmv_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo, rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; CDEBUG(D_INODE, "ENQUEUE '%s' on "DFID"\n", LL_IT2STR(it), PFID(&op_data->op_fid1)); tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); CDEBUG(D_INODE, "ENQUEUE '%s' on "DFID" -> mds #%d\n", LL_IT2STR(it), PFID(&op_data->op_fid1), tgt->ltd_idx); @@ -1798,7 +1798,7 @@ lmv_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo, rc = lmv_enqueue_remote(exp, einfo, it, op_data, lockh, lmm, lmmsize, extra_lock_flags); } - RETURN(rc); + return rc; } static int @@ -1814,11 +1814,11 @@ lmv_getattr_name(struct obd_export *exp,struct md_op_data *op_data, rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); CDEBUG(D_INODE, "GETATTR_NAME for %*s on "DFID" -> mds #%d\n", op_data->op_namelen, op_data->op_name, PFID(&op_data->op_fid1), @@ -1826,7 +1826,7 @@ lmv_getattr_name(struct obd_export *exp,struct md_op_data *op_data, rc = md_getattr_name(tgt->ltd_exp, op_data, request); if (rc != 0) - RETURN(rc); + return rc; body = req_capsule_server_get(&(*request)->rq_pill, &RMF_MDT_BODY); @@ -1840,7 +1840,7 @@ lmv_getattr_name(struct obd_export *exp,struct md_op_data *op_data, tgt = lmv_find_target(lmv, &rid); if (IS_ERR(tgt)) { ptlrpc_req_finished(*request); - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); } op_data->op_fid1 = rid; @@ -1852,7 +1852,7 @@ lmv_getattr_name(struct obd_export *exp,struct md_op_data *op_data, *request = req; } - RETURN(rc); + return rc; } #define md_op_data_fid(op_data, fl) \ @@ -1873,11 +1873,11 @@ static int lmv_early_cancel(struct obd_export *exp, struct md_op_data *op_data, int rc = 0; if (!fid_is_sane(fid)) - RETURN(0); + return 0; tgt = lmv_find_target(lmv, fid); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); if (tgt->ltd_idx != op_tgt) { CDEBUG(D_INODE, "EARLY_CANCEL on "DFID"\n", PFID(fid)); @@ -1892,7 +1892,7 @@ static int lmv_early_cancel(struct obd_export *exp, struct md_op_data *op_data, rc = 0; } - RETURN(rc); + return rc; } /* @@ -1909,7 +1909,7 @@ static int lmv_link(struct obd_export *exp, struct md_op_data *op_data, rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; LASSERT(op_data->op_namelen != 0); @@ -1922,7 +1922,7 @@ static int lmv_link(struct obd_export *exp, struct md_op_data *op_data, op_data->op_cap = cfs_curproc_cap_pack(); tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid2); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); /* * Cancel UPDATE lock on child (fid1). @@ -1931,11 +1931,11 @@ static int lmv_link(struct obd_export *exp, struct md_op_data *op_data, rc = lmv_early_cancel(exp, op_data, tgt->ltd_idx, LCK_EX, MDS_INODELOCK_UPDATE, MF_MDC_CANCEL_FID1); if (rc != 0) - RETURN(rc); + return rc; rc = md_link(tgt->ltd_exp, op_data, request); - RETURN(rc); + return rc; } static int lmv_rename(struct obd_export *exp, struct md_op_data *op_data, @@ -1956,18 +1956,18 @@ static int lmv_rename(struct obd_export *exp, struct md_op_data *op_data, rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; op_data->op_fsuid = from_kuid(&init_user_ns, current_fsuid()); op_data->op_fsgid = from_kgid(&init_user_ns, current_fsgid()); op_data->op_cap = cfs_curproc_cap_pack(); src_tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1); if (IS_ERR(src_tgt)) - RETURN(PTR_ERR(src_tgt)); + return PTR_ERR(src_tgt); tgt_tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid2); if (IS_ERR(tgt_tgt)) - RETURN(PTR_ERR(tgt_tgt)); + return PTR_ERR(tgt_tgt); /* * LOOKUP lock on src child (fid3) should also be cancelled for * src_tgt in mdc_rename. @@ -2002,7 +2002,7 @@ static int lmv_rename(struct obd_export *exp, struct md_op_data *op_data, if (rc == 0) rc = md_rename(src_tgt->ltd_exp, op_data, old, oldlen, new, newlen, request); - RETURN(rc); + return rc; } static int lmv_setattr(struct obd_export *exp, struct md_op_data *op_data, @@ -2017,7 +2017,7 @@ static int lmv_setattr(struct obd_export *exp, struct md_op_data *op_data, rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; CDEBUG(D_INODE, "SETATTR for "DFID", valid 0x%x\n", PFID(&op_data->op_fid1), op_data->op_attr.ia_valid); @@ -2025,12 +2025,12 @@ static int lmv_setattr(struct obd_export *exp, struct md_op_data *op_data, op_data->op_flags |= MF_MDC_CANCEL_FID1; tgt = lmv_find_target(lmv, &op_data->op_fid1); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); rc = md_setattr(tgt->ltd_exp, op_data, ea, ealen, ea2, ea2len, request, mod); - RETURN(rc); + return rc; } static int lmv_sync(struct obd_export *exp, const struct lu_fid *fid, @@ -2043,14 +2043,14 @@ static int lmv_sync(struct obd_export *exp, const struct lu_fid *fid, rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; tgt = lmv_find_target(lmv, fid); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); rc = md_sync(tgt->ltd_exp, fid, oc, request); - RETURN(rc); + return rc; } /* @@ -2169,18 +2169,18 @@ static int lmv_readpage(struct obd_export *exp, struct md_op_data *op_data, rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; CDEBUG(D_INODE, "READPAGE at "LPX64" from "DFID"\n", offset, PFID(&op_data->op_fid1)); tgt = lmv_find_target(lmv, &op_data->op_fid1); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); rc = md_readpage(tgt->ltd_exp, op_data, pages, request); if (rc != 0) - RETURN(rc); + return rc; ncfspgs = ((*request)->rq_bulk->bd_nob_transferred + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; @@ -2193,7 +2193,7 @@ static int lmv_readpage(struct obd_export *exp, struct md_op_data *op_data, lmv_adjust_dirpages(pages, ncfspgs, nlupgs); - RETURN(rc); + return rc; } static int lmv_unlink(struct obd_export *exp, struct md_op_data *op_data, @@ -2207,7 +2207,7 @@ static int lmv_unlink(struct obd_export *exp, struct md_op_data *op_data, rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; retry: /* Send unlink requests to the MDT where the child is located */ if (likely(!fid_is_zero(&op_data->op_fid2))) @@ -2215,7 +2215,7 @@ static int lmv_unlink(struct obd_export *exp, struct md_op_data *op_data, else tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); op_data->op_fsuid = from_kuid(&init_user_ns, current_fsuid()); op_data->op_fsgid = from_kgid(&init_user_ns, current_fsgid()); @@ -2237,22 +2237,22 @@ static int lmv_unlink(struct obd_export *exp, struct md_op_data *op_data, MDS_INODELOCK_FULL, MF_MDC_CANCEL_FID3); if (rc != 0) - RETURN(rc); + return rc; CDEBUG(D_INODE, "unlink with fid="DFID"/"DFID" -> mds #%d\n", PFID(&op_data->op_fid1), PFID(&op_data->op_fid2), tgt->ltd_idx); rc = md_unlink(tgt->ltd_exp, op_data, request); if (rc != 0 && rc != -EREMOTE) - RETURN(rc); + return rc; body = req_capsule_server_get(&(*request)->rq_pill, &RMF_MDT_BODY); if (body == NULL) - RETURN(-EPROTO); + return -EPROTO; /* Not cross-ref case, just get out of here. */ if (likely(!(body->valid & OBD_MD_MDS))) - RETURN(0); + return 0; CDEBUG(D_INODE, "%s: try unlink to another MDT for "DFID"\n", exp->exp_obd->obd_name, PFID(&body->fid1)); @@ -2300,7 +2300,7 @@ static int lmv_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) default: break; } - RETURN(rc); + return rc; } static int lmv_get_info(const struct lu_env *env, struct obd_export *exp, @@ -2315,7 +2315,7 @@ static int lmv_get_info(const struct lu_env *env, struct obd_export *exp, if (obd == NULL) { CDEBUG(D_IOCTL, "Invalid client cookie "LPX64"\n", exp->exp_handle.h_cookie); - RETURN(-EINVAL); + return -EINVAL; } lmv = &obd->u.lmv; @@ -2325,7 +2325,7 @@ static int lmv_get_info(const struct lu_env *env, struct obd_export *exp, rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; LASSERT(*vallen == sizeof(__u32)); for (i = 0; i < lmv->desc.ld_tgt_count; i++) { @@ -2338,13 +2338,13 @@ static int lmv_get_info(const struct lu_env *env, struct obd_export *exp, if (!obd_get_info(env, tgt->ltd_exp, keylen, key, vallen, val, NULL)) - RETURN(0); + return 0; } - RETURN(-EINVAL); + return -EINVAL; } else if (KEY_IS(KEY_MAX_EASIZE) || KEY_IS(KEY_CONN_DATA)) { rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; /* * Forwarding this request to first MDS, it should know LOV @@ -2354,14 +2354,14 @@ static int lmv_get_info(const struct lu_env *env, struct obd_export *exp, vallen, val, NULL); if (!rc && KEY_IS(KEY_CONN_DATA)) exp->exp_connect_data = *(struct obd_connect_data *)val; - RETURN(rc); + return rc; } else if (KEY_IS(KEY_TGT_COUNT)) { *((int *)val) = lmv->desc.ld_tgt_count; - RETURN(0); + return 0; } CDEBUG(D_IOCTL, "Invalid key\n"); - RETURN(-EINVAL); + return -EINVAL; } int lmv_set_info_async(const struct lu_env *env, struct obd_export *exp, @@ -2377,7 +2377,7 @@ int lmv_set_info_async(const struct lu_env *env, struct obd_export *exp, if (obd == NULL) { CDEBUG(D_IOCTL, "Invalid client cookie "LPX64"\n", exp->exp_handle.h_cookie); - RETURN(-EINVAL); + return -EINVAL; } lmv = &obd->u.lmv; @@ -2396,10 +2396,10 @@ int lmv_set_info_async(const struct lu_env *env, struct obd_export *exp, rc = err; } - RETURN(rc); + return rc; } - RETURN(-EINVAL); + return -EINVAL; } int lmv_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, @@ -2414,29 +2414,29 @@ int lmv_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, mea_size = lmv_get_easize(lmv); if (!lmmp) - RETURN(mea_size); + return mea_size; if (*lmmp && !lsm) { OBD_FREE_LARGE(*lmmp, mea_size); *lmmp = NULL; - RETURN(0); + return 0; } if (*lmmp == NULL) { OBD_ALLOC_LARGE(*lmmp, mea_size); if (*lmmp == NULL) - RETURN(-ENOMEM); + return -ENOMEM; } if (!lsm) - RETURN(mea_size); + return mea_size; lsmp = (struct lmv_stripe_md *)lsm; meap = (struct lmv_stripe_md *)*lmmp; if (lsmp->mea_magic != MEA_MAGIC_LAST_CHAR && lsmp->mea_magic != MEA_MAGIC_ALL_CHARS) - RETURN(-EINVAL); + return -EINVAL; meap->mea_magic = cpu_to_le32(lsmp->mea_magic); meap->mea_count = cpu_to_le32(lsmp->mea_count); @@ -2447,7 +2447,7 @@ int lmv_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, fid_cpu_to_le(&meap->mea_ids[i], &lsmp->mea_ids[i]); } - RETURN(mea_size); + return mea_size; } int lmv_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, @@ -2468,17 +2468,17 @@ int lmv_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, if (*lsmp != NULL && lmm == NULL) { OBD_FREE_LARGE(*tmea, mea_size); *lsmp = NULL; - RETURN(0); + return 0; } LASSERT(mea_size == lmm_size); OBD_ALLOC_LARGE(*tmea, mea_size); if (*tmea == NULL) - RETURN(-ENOMEM); + return -ENOMEM; if (!lmm) - RETURN(mea_size); + return mea_size; if (mea->mea_magic == MEA_MAGIC_LAST_CHAR || mea->mea_magic == MEA_MAGIC_ALL_CHARS || @@ -2501,7 +2501,7 @@ int lmv_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, (*tmea)->mea_ids[i] = mea->mea_ids[i]; fid_le_to_cpu(&(*tmea)->mea_ids[i], &(*tmea)->mea_ids[i]); } - RETURN(mea_size); + return mea_size; } static int lmv_cancel_unused(struct obd_export *exp, const struct lu_fid *fid, @@ -2526,7 +2526,7 @@ static int lmv_cancel_unused(struct obd_export *exp, const struct lu_fid *fid, if (!rc) rc = err; } - RETURN(rc); + return rc; } int lmv_set_lock_data(struct obd_export *exp, __u64 *lockh, void *data, @@ -2536,7 +2536,7 @@ int lmv_set_lock_data(struct obd_export *exp, __u64 *lockh, void *data, int rc; rc = md_set_lock_data(lmv->tgts[0]->ltd_exp, lockh, data, bits); - RETURN(rc); + return rc; } ldlm_mode_t lmv_lock_match(struct obd_export *exp, __u64 flags, @@ -2566,10 +2566,10 @@ ldlm_mode_t lmv_lock_match(struct obd_export *exp, __u64 flags, rc = md_lock_match(lmv->tgts[i]->ltd_exp, flags, fid, type, policy, mode, lockh); if (rc) - RETURN(rc); + return rc; } - RETURN(0); + return 0; } int lmv_get_lustre_md(struct obd_export *exp, struct ptlrpc_request *req, @@ -2588,7 +2588,7 @@ int lmv_free_lustre_md(struct obd_export *exp, struct lustre_md *md) if (md->mea) obd_free_memmd(exp, (void *)&md->mea); - RETURN(md_free_lustre_md(lmv->tgts[0]->ltd_exp, md)); + return md_free_lustre_md(lmv->tgts[0]->ltd_exp, md); } int lmv_set_open_replay_data(struct obd_export *exp, @@ -2601,9 +2601,9 @@ int lmv_set_open_replay_data(struct obd_export *exp, tgt = lmv_find_target(lmv, &och->och_fid); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); - RETURN(md_set_open_replay_data(tgt->ltd_exp, och, open_req)); + return md_set_open_replay_data(tgt->ltd_exp, och, open_req); } int lmv_clear_open_replay_data(struct obd_export *exp, @@ -2615,9 +2615,9 @@ int lmv_clear_open_replay_data(struct obd_export *exp, tgt = lmv_find_target(lmv, &och->och_fid); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); - RETURN(md_clear_open_replay_data(tgt->ltd_exp, och)); + return md_clear_open_replay_data(tgt->ltd_exp, och); } static int lmv_get_remote_perm(struct obd_export *exp, @@ -2632,14 +2632,14 @@ static int lmv_get_remote_perm(struct obd_export *exp, rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; tgt = lmv_find_target(lmv, fid); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); rc = md_get_remote_perm(tgt->ltd_exp, fid, oc, suppgid, request); - RETURN(rc); + return rc; } static int lmv_renew_capa(struct obd_export *exp, struct obd_capa *oc, @@ -2652,14 +2652,14 @@ static int lmv_renew_capa(struct obd_export *exp, struct obd_capa *oc, rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; tgt = lmv_find_target(lmv, &oc->c_capa.lc_fid); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); rc = md_renew_capa(tgt->ltd_exp, oc, cb); - RETURN(rc); + return rc; } int lmv_unpack_capa(struct obd_export *exp, struct ptlrpc_request *req, @@ -2682,14 +2682,14 @@ int lmv_intent_getattr_async(struct obd_export *exp, rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; tgt = lmv_find_target(lmv, &op_data->op_fid1); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); rc = md_intent_getattr_async(tgt->ltd_exp, minfo, einfo); - RETURN(rc); + return rc; } int lmv_revalidate_lock(struct obd_export *exp, struct lookup_intent *it, @@ -2702,14 +2702,14 @@ int lmv_revalidate_lock(struct obd_export *exp, struct lookup_intent *it, rc = lmv_check_connect(obd); if (rc) - RETURN(rc); + return rc; tgt = lmv_find_target(lmv, fid); if (IS_ERR(tgt)) - RETURN(PTR_ERR(tgt)); + return PTR_ERR(tgt); rc = md_revalidate_lock(tgt->ltd_exp, it, fid, bits); - RETURN(rc); + return rc; } /** @@ -2728,12 +2728,12 @@ int lmv_quotactl(struct obd_device *unused, struct obd_export *exp, if (!lmv->desc.ld_tgt_count || !tgt->ltd_active) { CERROR("master lmv inactive\n"); - RETURN(-EIO); + return -EIO; } if (oqctl->qc_cmd != Q_GETOQUOTA) { rc = obd_quotactl(tgt->ltd_exp, oqctl); - RETURN(rc); + return rc; } curspace = curinodes = 0; @@ -2761,7 +2761,7 @@ int lmv_quotactl(struct obd_device *unused, struct obd_export *exp, oqctl->qc_dqblk.dqb_curspace = curspace; oqctl->qc_dqblk.dqb_curinodes = curinodes; - RETURN(rc); + return rc; } int lmv_quotacheck(struct obd_device *unused, struct obd_export *exp, @@ -2777,7 +2777,7 @@ int lmv_quotacheck(struct obd_device *unused, struct obd_export *exp, tgt = lmv->tgts[i]; if (tgt == NULL || tgt->ltd_exp == NULL || !tgt->ltd_active) { CERROR("lmv idx %d inactive\n", i); - RETURN(-EIO); + return -EIO; } err = obd_quotacheck(tgt->ltd_exp, oqctl); @@ -2785,7 +2785,7 @@ int lmv_quotacheck(struct obd_device *unused, struct obd_export *exp, rc = err; } - RETURN(rc); + return rc; } struct obd_ops lmv_obd_ops = { diff --git a/drivers/staging/lustre/lustre/lov/lov_dev.c b/drivers/staging/lustre/lustre/lov/lov_dev.c index 285164116c8a4..a4006ef46ad2a 100644 --- a/drivers/staging/lustre/lustre/lov/lov_dev.c +++ b/drivers/staging/lustre/lustre/lov/lov_dev.c @@ -198,7 +198,7 @@ static struct lu_device *lov_device_fini(const struct lu_env *env, LASSERT(ld->ld_lov != NULL); if (ld->ld_target == NULL) - RETURN(NULL); + return NULL; lov_foreach_target(ld, i) { struct lovsub_device *lsd; @@ -209,7 +209,7 @@ static struct lu_device *lov_device_fini(const struct lu_env *env, ld->ld_target[i] = NULL; } } - RETURN(NULL); + return NULL; } static int lov_device_init(const struct lu_env *env, struct lu_device *d, @@ -221,7 +221,7 @@ static int lov_device_init(const struct lu_env *env, struct lu_device *d, LASSERT(d->ld_site != NULL); if (ld->ld_target == NULL) - RETURN(rc); + return rc; lov_foreach_target(ld, i) { struct lovsub_device *lsd; @@ -249,7 +249,7 @@ static int lov_device_init(const struct lu_env *env, struct lu_device *d, else ld->ld_flags |= LOV_DEV_INITIALIZED; - RETURN(rc); + return rc; } static int lov_req_init(const struct lu_env *env, struct cl_device *dev, @@ -264,7 +264,7 @@ static int lov_req_init(const struct lu_env *env, struct cl_device *dev, result = 0; } else result = -ENOMEM; - RETURN(result); + return result; } static const struct cl_device_operations lov_cl_ops = { @@ -365,7 +365,7 @@ static int lov_expand_targets(const struct lu_env *env, struct lov_device *dev) emerg = lov_emerg_alloc(tgt_size); if (IS_ERR(emerg)) - RETURN(PTR_ERR(emerg)); + return PTR_ERR(emerg); OBD_ALLOC(newd, tgt_size * sz); if (newd != NULL) { @@ -386,7 +386,7 @@ static int lov_expand_targets(const struct lu_env *env, struct lov_device *dev) result = -ENOMEM; } } - RETURN(result); + return result; } static int lov_cl_add_target(const struct lu_env *env, struct lu_device *dev, @@ -407,7 +407,7 @@ static int lov_cl_add_target(const struct lu_env *env, struct lu_device *dev, if (!tgt->ltd_obd->obd_set_up) { CERROR("Target %s not set up\n", obd_uuid2str(&tgt->ltd_uuid)); - RETURN(-EINVAL); + return -EINVAL; } rc = lov_expand_targets(env, ld); @@ -429,7 +429,7 @@ static int lov_cl_add_target(const struct lu_env *env, struct lu_device *dev, } } obd_putref(obd); - RETURN(rc); + return rc; } static int lov_process_config(const struct lu_env *env, @@ -459,7 +459,7 @@ static int lov_process_config(const struct lu_env *env, } } obd_putref(obd); - RETURN(rc); + return rc; } static const struct lu_device_operations lov_lu_ops = { @@ -478,7 +478,7 @@ static struct lu_device *lov_device_alloc(const struct lu_env *env, OBD_ALLOC_PTR(ld); if (ld == NULL) - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); cl_device_init(&ld->ld_cl, t); d = lov2lu_dev(ld); @@ -494,11 +494,11 @@ static struct lu_device *lov_device_alloc(const struct lu_env *env, rc = lov_setup(obd, cfg); if (rc) { lov_device_free(env, d); - RETURN(ERR_PTR(rc)); + return ERR_PTR(rc); } ld->ld_lov = &obd->u.lov; - RETURN(d); + return d; } static const struct lu_device_type_operations lov_device_type_ops = { diff --git a/drivers/staging/lustre/lustre/lov/lov_io.c b/drivers/staging/lustre/lustre/lov/lov_io.c index 8b978c36ab4c7..b611aa4e9dcb9 100644 --- a/drivers/staging/lustre/lustre/lov/lov_io.c +++ b/drivers/staging/lustre/lustre/lov/lov_io.c @@ -207,7 +207,7 @@ static int lov_io_sub_init(const struct lu_env *env, struct lov_io *lio, } if (result != 0) lov_io_sub_fini(env, lio, sub); - RETURN(result); + return result; } struct lov_io_sub *lov_sub_get(const struct lu_env *env, @@ -227,7 +227,7 @@ struct lov_io_sub *lov_sub_get(const struct lu_env *env, lov_sub_enter(sub); else sub = ERR_PTR(rc); - RETURN(sub); + return sub; } void lov_sub_put(struct lov_io_sub *sub) @@ -249,7 +249,7 @@ static int lov_page_stripe(const struct cl_page *page) lu_object_locate(page->cp_child->cp_obj->co_lu.lo_header, &lovsub_device_type)); LASSERT(subobj != NULL); - RETURN(subobj->lso_index); + return subobj->lso_index; } struct lov_io_sub *lov_page_subio(const struct lu_env *env, struct lov_io *lio, @@ -265,7 +265,7 @@ struct lov_io_sub *lov_page_subio(const struct lu_env *env, struct lov_io *lio, LASSERT(lio->lis_nr_subios > 0); stripe = lov_page_stripe(page); - RETURN(lov_sub_get(env, lio, stripe)); + return lov_sub_get(env, lio, stripe); } @@ -290,7 +290,7 @@ static int lov_io_subio_init(const struct lu_env *env, struct lov_io *lio, result = 0; } else result = -ENOMEM; - RETURN(result); + return result; } static void lov_io_slice_init(struct lov_io *lio, @@ -407,7 +407,7 @@ static int lov_io_iter_init(const struct lu_env *env, else break; } - RETURN(rc); + return rc; } static int lov_io_rw_iter_init(const struct lu_env *env, @@ -443,7 +443,7 @@ static int lov_io_rw_iter_init(const struct lu_env *env, * XXX The following call should be optimized: we know, that * [lio->lis_pos, lio->lis_endpos) intersects with exactly one stripe. */ - RETURN(lov_io_iter_init(env, ios)); + return lov_io_iter_init(env, ios); } static int lov_io_call(const struct lu_env *env, struct lov_io *lio, @@ -463,17 +463,17 @@ static int lov_io_call(const struct lu_env *env, struct lov_io *lio, if (parent->ci_result == 0) parent->ci_result = sub->sub_io->ci_result; } - RETURN(rc); + return rc; } static int lov_io_lock(const struct lu_env *env, const struct cl_io_slice *ios) { - RETURN(lov_io_call(env, cl2lov_io(env, ios), cl_io_lock)); + return lov_io_call(env, cl2lov_io(env, ios), cl_io_lock); } static int lov_io_start(const struct lu_env *env, const struct cl_io_slice *ios) { - RETURN(lov_io_call(env, cl2lov_io(env, ios), cl_io_start)); + return lov_io_call(env, cl2lov_io(env, ios), cl_io_start); } static int lov_io_end_wrapper(const struct lu_env *env, struct cl_io *io) @@ -487,19 +487,19 @@ static int lov_io_end_wrapper(const struct lu_env *env, struct cl_io *io) cl_io_end(env, io); else io->ci_state = CIS_IO_FINISHED; - RETURN(0); + return 0; } static int lov_io_iter_fini_wrapper(const struct lu_env *env, struct cl_io *io) { cl_io_iter_fini(env, io); - RETURN(0); + return 0; } static int lov_io_unlock_wrapper(const struct lu_env *env, struct cl_io *io) { cl_io_unlock(env, io); - RETURN(0); + return 0; } static void lov_io_end(const struct lu_env *env, const struct cl_io_slice *ios) @@ -585,7 +585,7 @@ static int lov_io_submit(const struct lu_env *env, rc = cl_io_submit_rw(sub->sub_env, sub->sub_io, crt, queue); lov_sub_put(sub); - RETURN(rc); + return rc; } LASSERT(lio->lis_subs != NULL); @@ -593,7 +593,7 @@ static int lov_io_submit(const struct lu_env *env, OBD_ALLOC_LARGE(stripes_qin, sizeof(*stripes_qin) * lio->lis_nr_subios); if (stripes_qin == NULL) - RETURN(-ENOMEM); + return -ENOMEM; for (stripe = 0; stripe < lio->lis_nr_subios; stripe++) cl_page_list_init(&stripes_qin[stripe]); @@ -659,7 +659,7 @@ static int lov_io_submit(const struct lu_env *env, mutex_unlock(&ld->ld_mutex); } - RETURN(rc); + return rc; #undef QIN } @@ -680,7 +680,7 @@ static int lov_io_prepare_write(const struct lu_env *env, lov_sub_put(sub); } else result = PTR_ERR(sub); - RETURN(result); + return result; } static int lov_io_commit_write(const struct lu_env *env, @@ -700,7 +700,7 @@ static int lov_io_commit_write(const struct lu_env *env, lov_sub_put(sub); } else result = PTR_ERR(sub); - RETURN(result); + return result; } static int lov_io_fault_start(const struct lu_env *env, @@ -715,7 +715,7 @@ static int lov_io_fault_start(const struct lu_env *env, sub = lov_sub_get(env, lio, lov_page_stripe(fio->ft_page)); sub->sub_io->u.ci_fault.ft_nob = fio->ft_nob; lov_sub_put(sub); - RETURN(lov_io_start(env, ios)); + return lov_io_start(env, ios); } static void lov_io_fsync_end(const struct lu_env *env, @@ -892,7 +892,7 @@ int lov_io_init_raid0(const struct lu_env *env, struct cl_object *obj, atomic_inc(&lov->lo_active_ios); } } - RETURN(io->ci_result); + return io->ci_result; } int lov_io_init_empty(const struct lu_env *env, struct cl_object *obj, @@ -929,7 +929,7 @@ int lov_io_init_empty(const struct lu_env *env, struct cl_object *obj, } io->ci_result = result < 0 ? result : 0; - RETURN(result != 0); + return result != 0; } int lov_io_init_released(const struct lu_env *env, struct cl_object *obj, @@ -963,6 +963,6 @@ int lov_io_init_released(const struct lu_env *env, struct cl_object *obj, } io->ci_result = result < 0 ? result : 0; - RETURN(result != 0); + return result != 0; } /** @} lov */ diff --git a/drivers/staging/lustre/lustre/lov/lov_lock.c b/drivers/staging/lustre/lustre/lov/lov_lock.c index 757d6dec5245f..ec297e87c2a2c 100644 --- a/drivers/staging/lustre/lustre/lov/lov_lock.c +++ b/drivers/staging/lustre/lustre/lov/lov_lock.c @@ -176,7 +176,7 @@ static struct cl_lock *lov_sublock_alloc(const struct lu_env *env, OBD_SLAB_FREE_PTR(link, lov_lock_link_kmem); } else sublock = ERR_PTR(-ENOMEM); - RETURN(sublock); + return sublock; } static void lov_sublock_unlock(const struct lu_env *env, @@ -237,7 +237,7 @@ static int lov_sublock_lock(const struct lu_env *env, } } } - RETURN(result); + return result; } /** @@ -273,7 +273,7 @@ static int lov_subresult(int result, int rc) if (result_rank < rc_rank) result = rc; - RETURN(result); + return result; } /** @@ -315,7 +315,7 @@ static int lov_lock_sub_init(const struct lu_env *env, LASSERT(nr > 0); OBD_ALLOC_LARGE(lck->lls_sub, nr * sizeof lck->lls_sub[0]); if (lck->lls_sub == NULL) - RETURN(-ENOMEM); + return -ENOMEM; lck->lls_nr = nr; /* @@ -386,7 +386,7 @@ static int lov_lock_sub_init(const struct lu_env *env, * because enqueue will create them anyway. Main duty of this function * is to fill in sub-lock descriptions in a race free manner. */ - RETURN(result); + return result; } static int lov_sublock_release(const struct lu_env *env, struct lov_lock *lck, @@ -431,7 +431,7 @@ static int lov_sublock_release(const struct lu_env *env, struct lov_lock *lck, * sub-lock is destroyed. */ } - RETURN(rc); + return rc; } static void lov_sublock_hold(const struct lu_env *env, struct lov_lock *lck, @@ -491,7 +491,7 @@ static int lov_lock_enqueue_wait(const struct lu_env *env, cl_lock_mutex_put(env, lock); result = cl_lock_enqueue_wait(env, sublock, 0); cl_lock_mutex_get(env, lock); - RETURN(result ?: CLO_REPEAT); + return result ?: CLO_REPEAT; } /** @@ -524,7 +524,7 @@ static int lov_lock_enqueue_one(const struct lu_env *env, struct lov_lock *lck, if ((result == CLO_WAIT) && (sublock->cll_state <= CLS_HELD) && (enqflags & CEF_ASYNC) && (!last || (enqflags & CEF_AGL))) result = 0; - RETURN(result); + return result; } /** @@ -661,7 +661,7 @@ static int lov_lock_enqueue(const struct lu_env *env, break; } cl_lock_closure_fini(closure); - RETURN(result ?: minstate >= CLS_ENQUEUED ? 0 : CLO_WAIT); + return result ?: minstate >= CLS_ENQUEUED ? 0 : CLO_WAIT; } static int lov_lock_unuse(const struct lu_env *env, @@ -707,7 +707,7 @@ static int lov_lock_unuse(const struct lu_env *env, result = -ESTALE; } cl_lock_closure_fini(closure); - RETURN(result); + return result; } @@ -814,7 +814,7 @@ static int lov_lock_wait(const struct lu_env *env, if (result == 0 && reenqueued != 0) goto again; cl_lock_closure_fini(closure); - RETURN(result ?: minstate >= CLS_HELD ? 0 : CLO_WAIT); + return result ?: minstate >= CLS_HELD ? 0 : CLO_WAIT; } static int lov_lock_use(const struct lu_env *env, @@ -882,7 +882,7 @@ static int lov_lock_use(const struct lu_env *env, result = -ESTALE; } cl_lock_closure_fini(closure); - RETURN(result); + return result; } #if 0 @@ -1027,7 +1027,7 @@ static int lov_lock_fits_into(const struct lu_env *env, PDESCR(&lov->lls_orig), PDESCR(&lov->lls_sub[0].sub_got), lov->lls_sub[0].sub_stripe, lov->lls_nr, lov_r0(obj)->lo_nr, result); - RETURN(result); + return result; } void lov_lock_unlink(const struct lu_env *env, @@ -1060,9 +1060,9 @@ struct lov_lock_link *lov_lock_link_find(const struct lu_env *env, list_for_each_entry(scan, &sub->lss_parents, lll_list) { if (scan->lll_super == lck) - RETURN(scan); + return scan; } - RETURN(NULL); + return NULL; } /** @@ -1165,7 +1165,7 @@ int lov_lock_init_raid0(const struct lu_env *env, struct cl_object *obj, result = lov_lock_sub_init(env, lck, io); } else result = -ENOMEM; - RETURN(result); + return result; } static void lov_empty_lock_fini(const struct lu_env *env, @@ -1200,7 +1200,7 @@ int lov_lock_init_empty(const struct lu_env *env, struct cl_object *obj, lck->lls_orig = lock->cll_descr; result = 0; } - RETURN(result); + return result; } static struct cl_lock_closure *lov_closure_get(const struct lu_env *env, diff --git a/drivers/staging/lustre/lustre/lov/lov_log.c b/drivers/staging/lustre/lustre/lov/lov_log.c index 349579b59b6d5..3eedd935d1bcf 100644 --- a/drivers/staging/lustre/lustre/lov/lov_log.c +++ b/drivers/staging/lustre/lustre/lov/lov_log.c @@ -117,7 +117,7 @@ static int lov_llog_origin_add(const struct lu_env *env, /* Note that rc is always 1 if llog_obd_add was successful */ cookies += rc; } - RETURN(cookies); + return cookies; } static int lov_llog_origin_connect(struct llog_ctxt *ctxt, @@ -152,7 +152,7 @@ static int lov_llog_origin_connect(struct llog_ctxt *ctxt, } obd_putref(obd); - RETURN(err); + return err; } /* the replicators commit callback */ @@ -191,7 +191,7 @@ static int lov_llog_repl_cancel(const struct lu_env *env, } } obd_putref(obd); - RETURN(rc); + return rc; } static struct llog_operations lov_mds_ost_orig_logops = { @@ -214,7 +214,7 @@ int lov_llog_init(struct obd_device *obd, struct obd_llog_group *olg, rc = llog_setup(NULL, obd, olg, LLOG_MDS_OST_ORIG_CTXT, disk_obd, &lov_mds_ost_orig_logops); if (rc) - RETURN(rc); + return rc; rc = llog_setup(NULL, obd, olg, LLOG_SIZE_REPL_CTXT, disk_obd, &lov_size_repl_logops); @@ -268,5 +268,5 @@ int lov_llog_finish(struct obd_device *obd, int count) llog_cleanup(NULL, ctxt); /* lov->tgt llogs are cleaned during osc_cleanup. */ - RETURN(0); + return 0; } diff --git a/drivers/staging/lustre/lustre/lov/lov_merge.c b/drivers/staging/lustre/lustre/lov/lov_merge.c index f062460aaf5c1..d204fedea3488 100644 --- a/drivers/staging/lustre/lustre/lov/lov_merge.c +++ b/drivers/staging/lustre/lustre/lov/lov_merge.c @@ -109,7 +109,7 @@ int lov_merge_lvb_kms(struct lov_stripe_md *lsm, lvb->lvb_mtime = current_mtime; lvb->lvb_atime = current_atime; lvb->lvb_ctime = current_ctime; - RETURN(rc); + return rc; } /** Merge the lock value block(&lvb) attributes from each of the stripes in a @@ -136,7 +136,7 @@ int lov_merge_lvb(struct obd_export *exp, CDEBUG(D_INODE, "merged for ID "DOSTID" s="LPU64" m="LPU64" a="LPU64 " c="LPU64" b="LPU64"\n", POSTID(&lsm->lsm_oi), lvb->lvb_size, lvb->lvb_mtime, lvb->lvb_atime, lvb->lvb_ctime, lvb->lvb_blocks); - RETURN(rc); + return rc; } /* Must be called under the lov_stripe_lock() */ @@ -160,7 +160,7 @@ int lov_adjust_kms(struct obd_export *exp, struct lov_stripe_md *lsm, loi->loi_kms, kms); loi_kms_set(loi, loi->loi_lvb.lvb_size = kms); } - RETURN(0); + return 0; } if (size > 0) @@ -173,7 +173,7 @@ int lov_adjust_kms(struct obd_export *exp, struct lov_stripe_md *lsm, if (kms > loi->loi_kms) loi_kms_set(loi, kms); - RETURN(0); + return 0; } void lov_merge_attrs(struct obdo *tgt, struct obdo *src, obd_valid valid, diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index ba5bf1c1f146e..a8c709e26a92b 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -135,14 +135,14 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate, int rc; if (!lov->lov_tgts[index]) - RETURN(-EINVAL); + return -EINVAL; tgt_uuid = &lov->lov_tgts[index]->ltd_uuid; tgt_obd = lov->lov_tgts[index]->ltd_obd; if (!tgt_obd->obd_set_up) { CERROR("Target %s not set up\n", obd_uuid2str(tgt_uuid)); - RETURN(-EINVAL); + return -EINVAL; } /* override the sp_me from lov */ @@ -167,14 +167,14 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate, if (rc) { CERROR("Target %s register_observer error %d\n", obd_uuid2str(tgt_uuid), rc); - RETURN(rc); + return rc; } if (imp->imp_invalid) { CDEBUG(D_CONFIG, "not connecting OSC %s; administratively " "disabled\n", obd_uuid2str(tgt_uuid)); - RETURN(0); + return 0; } rc = obd_connect(NULL, &lov->lov_tgts[index]->ltd_exp, tgt_obd, @@ -182,7 +182,7 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate, if (rc || !lov->lov_tgts[index]->ltd_exp) { CERROR("Target %s connect error %d\n", obd_uuid2str(tgt_uuid), rc); - RETURN(-ENODEV); + return -ENODEV; } lov->lov_tgts[index]->ltd_reap = 0; @@ -214,7 +214,7 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate, } } - RETURN(0); + return 0; } static int lov_connect(const struct lu_env *env, @@ -231,7 +231,7 @@ static int lov_connect(const struct lu_env *env, rc = class_connect(&conn, obd, cluuid); if (rc) - RETURN(rc); + return rc; *exp = class_conn2export(&conn); @@ -268,7 +268,7 @@ static int lov_connect(const struct lu_env *env, } obd_putref(obd); - RETURN(0); + return 0; } static int lov_disconnect_obd(struct obd_device *obd, struct lov_tgt_desc *tgt) @@ -312,7 +312,7 @@ static int lov_disconnect_obd(struct obd_device *obd, struct lov_tgt_desc *tgt) } tgt->ltd_exp = NULL; - RETURN(0); + return 0; } static int lov_disconnect(struct obd_export *exp) @@ -346,7 +346,7 @@ static int lov_disconnect(struct obd_export *exp) out: rc = class_disconnect(exp); /* bz 9811 */ - RETURN(rc); + return rc; } /* Error codes: @@ -433,7 +433,7 @@ static int lov_set_osc_active(struct obd_device *obd, struct obd_uuid *uuid, out: obd_putref(obd); - RETURN(index); + return index; } static int lov_notify(struct obd_device *obd, struct obd_device *watched, @@ -445,7 +445,7 @@ static int lov_notify(struct obd_device *obd, struct obd_device *watched, down_read(&lov->lov_notify_lock); if (!lov->lov_connects) { up_read(&lov->lov_notify_lock); - RETURN(rc); + return rc; } if (ev == OBD_NOTIFY_ACTIVE || ev == OBD_NOTIFY_INACTIVE || @@ -459,7 +459,7 @@ static int lov_notify(struct obd_device *obd, struct obd_device *watched, CERROR("unexpected notification of %s %s!\n", watched->obd_type->typ_name, watched->obd_name); - RETURN(-EINVAL); + return -EINVAL; } uuid = &watched->u.cli.cl_target_uuid; @@ -471,7 +471,7 @@ static int lov_notify(struct obd_device *obd, struct obd_device *watched, up_read(&lov->lov_notify_lock); CERROR("event(%d) of %s failed: %d\n", ev, obd_uuid2str(uuid), rc); - RETURN(rc); + return rc; } /* active event should be pass lov target index as data */ data = &rc; @@ -514,7 +514,7 @@ static int lov_notify(struct obd_device *obd, struct obd_device *watched, } up_read(&lov->lov_notify_lock); - RETURN(rc); + return rc; } static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp, @@ -531,13 +531,13 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp, if (gen <= 0) { CERROR("request to add OBD %s with invalid generation: %d\n", uuidp->uuid, gen); - RETURN(-EINVAL); + return -EINVAL; } tgt_obd = class_find_client_obd(uuidp, LUSTRE_OSC_NAME, &obd->obd_uuid); if (tgt_obd == NULL) - RETURN(-EINVAL); + return -EINVAL; mutex_lock(&lov->lov_lock); @@ -546,7 +546,7 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp, CERROR("UUID %s already assigned at LOV target index %d\n", obd_uuid2str(&tgt->ltd_uuid), index); mutex_unlock(&lov->lov_lock); - RETURN(-EEXIST); + return -EEXIST; } if (index >= lov->lov_tgt_size) { @@ -560,7 +560,7 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp, OBD_ALLOC(newtgts, sizeof(*newtgts) * newsize); if (newtgts == NULL) { mutex_unlock(&lov->lov_lock); - RETURN(-ENOMEM); + return -ENOMEM; } if (lov->lov_tgt_size) { @@ -583,14 +583,14 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp, OBD_ALLOC_PTR(tgt); if (!tgt) { mutex_unlock(&lov->lov_lock); - RETURN(-ENOMEM); + return -ENOMEM; } rc = lov_ost_pool_add(&lov->lov_packed, index, lov->lov_tgt_size); if (rc) { mutex_unlock(&lov->lov_lock); OBD_FREE_PTR(tgt); - RETURN(rc); + return rc; } tgt->ltd_uuid = *uuidp; @@ -614,7 +614,7 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp, /* lov_connect hasn't been called yet. We'll do the lov_connect_obd on this target when that fn first runs, because we don't know the connect flags yet. */ - RETURN(0); + return 0; } obd_getref(obd); @@ -647,7 +647,7 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp, lov_del_target(obd, index, 0, 0); } obd_putref(obd); - RETURN(rc); + return rc; } /* Schedule a target for deletion */ @@ -661,7 +661,7 @@ int lov_del_target(struct obd_device *obd, __u32 index, if (index >= count) { CERROR("LOV target index %d >= number of LOV OBDs %d.\n", index, count); - RETURN(-EINVAL); + return -EINVAL; } /* to make sure there's no ongoing lov_notify() now */ @@ -692,7 +692,7 @@ int lov_del_target(struct obd_device *obd, __u32 index, obd_putref(obd); up_write(&lov->lov_notify_lock); - RETURN(rc); + return rc; } static void __lov_del_obd(struct obd_device *obd, struct lov_tgt_desc *tgt) @@ -775,7 +775,7 @@ int lov_setup(struct obd_device *obd, struct lustre_cfg *lcfg) if (LUSTRE_CFG_BUFLEN(lcfg, 1) < 1) { CERROR("LOV setup requires a descriptor\n"); - RETURN(-EINVAL); + return -EINVAL; } desc = (struct lov_desc *)lustre_cfg_buf(lcfg, 1); @@ -783,7 +783,7 @@ int lov_setup(struct obd_device *obd, struct lustre_cfg *lcfg) if (sizeof(*desc) > LUSTRE_CFG_BUFLEN(lcfg, 1)) { CERROR("descriptor size wrong: %d > %d\n", (int)sizeof(*desc), LUSTRE_CFG_BUFLEN(lcfg, 1)); - RETURN(-EINVAL); + return -EINVAL; } if (desc->ld_magic != LOV_DESC_MAGIC) { @@ -794,7 +794,7 @@ int lov_setup(struct obd_device *obd, struct lustre_cfg *lcfg) } else { CERROR("%s: Bad lov desc magic: %#x\n", obd->obd_name, desc->ld_magic); - RETURN(-EINVAL); + return -EINVAL; } } @@ -839,7 +839,7 @@ int lov_setup(struct obd_device *obd, struct lustre_cfg *lcfg) obd->obd_proc_entry, NULL, NULL); - RETURN(0); + return 0; out: return rc; @@ -867,7 +867,7 @@ static int lov_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) CERROR("failed to cleanup llogging subsystems\n"); break; } - RETURN(rc); + return rc; } static int lov_cleanup(struct obd_device *obd) @@ -913,7 +913,7 @@ static int lov_cleanup(struct obd_device *obd) lov->lov_tgt_size); lov->lov_tgt_size = 0; } - RETURN(0); + return 0; } int lov_process_config_base(struct obd_device *obd, struct lustre_cfg *lcfg, @@ -977,7 +977,7 @@ int lov_process_config_base(struct obd_device *obd, struct lustre_cfg *lcfg, } } out: - RETURN(rc); + return rc; } static int lov_recreate(struct obd_export *exp, struct obdo *src_oa, @@ -993,7 +993,7 @@ static int lov_recreate(struct obd_export *exp, struct obdo *src_oa, OBD_ALLOC(obj_mdp, sizeof(*obj_mdp)); if (obj_mdp == NULL) - RETURN(-ENOMEM); + return -ENOMEM; ost_idx = src_oa->o_nlink; lsm = *ea; @@ -1018,7 +1018,7 @@ static int lov_recreate(struct obd_export *exp, struct obdo *src_oa, src_oa, &obj_mdp, oti); out: OBD_FREE(obj_mdp, sizeof(*obj_mdp)); - RETURN(rc); + return rc; } /* the LOV expects oa->o_id to be set to the LOV object id */ @@ -1031,7 +1031,7 @@ static int lov_create(const struct lu_env *env, struct obd_export *exp, LASSERT(ea != NULL); if (exp == NULL) - RETURN(-EINVAL); + return -EINVAL; if ((src_oa->o_valid & OBD_MD_FLFLAGS) && src_oa->o_flags == OBD_FL_DELORPHAN) { @@ -1041,7 +1041,7 @@ static int lov_create(const struct lu_env *env, struct obd_export *exp, lov = &exp->exp_obd->u.lov; if (!lov->desc.ld_active_tgt_count) - RETURN(-EIO); + return -EIO; obd_getref(exp->exp_obd); /* Recreate a specific object id at the given OST index */ @@ -1051,7 +1051,7 @@ static int lov_create(const struct lu_env *env, struct obd_export *exp, } obd_putref(exp->exp_obd); - RETURN(rc); + return rc; } #define ASSERT_LSM_MAGIC(lsmp) \ @@ -1077,7 +1077,7 @@ static int lov_destroy(const struct lu_env *env, struct obd_export *exp, ASSERT_LSM_MAGIC(lsm); if (!exp || !exp->exp_obd) - RETURN(-ENODEV); + return -ENODEV; if (oa->o_valid & OBD_MD_FLCOOKIE) { LASSERT(oti); @@ -1117,7 +1117,7 @@ static int lov_destroy(const struct lu_env *env, struct obd_export *exp, err = lov_fini_destroy_set(set); out: obd_putref(exp->exp_obd); - RETURN(rc ? rc : err); + return rc ? rc : err; } static int lov_getattr(const struct lu_env *env, struct obd_export *exp, @@ -1133,13 +1133,13 @@ static int lov_getattr(const struct lu_env *env, struct obd_export *exp, ASSERT_LSM_MAGIC(oinfo->oi_md); if (!exp || !exp->exp_obd) - RETURN(-ENODEV); + return -ENODEV; lov = &exp->exp_obd->u.lov; rc = lov_prep_getattr_set(exp, oinfo, &set); if (rc) - RETURN(rc); + return rc; list_for_each (pos, &set->set_list) { req = list_entry(pos, struct lov_request, rq_link); @@ -1165,7 +1165,7 @@ static int lov_getattr(const struct lu_env *env, struct obd_export *exp, rc = lov_fini_getattr_set(set); if (err) rc = err; - RETURN(rc); + return rc; } static int lov_getattr_interpret(struct ptlrpc_request_set *rqset, @@ -1178,7 +1178,7 @@ static int lov_getattr_interpret(struct ptlrpc_request_set *rqset, if (rc) atomic_set(&lovset->set_completes, 0); err = lov_fini_getattr_set(lovset); - RETURN(rc ? rc : err); + return rc ? rc : err; } static int lov_getattr_async(struct obd_export *exp, struct obd_info *oinfo, @@ -1194,13 +1194,13 @@ static int lov_getattr_async(struct obd_export *exp, struct obd_info *oinfo, ASSERT_LSM_MAGIC(oinfo->oi_md); if (!exp || !exp->exp_obd) - RETURN(-ENODEV); + return -ENODEV; lov = &exp->exp_obd->u.lov; rc = lov_prep_getattr_set(exp, oinfo, &lovset); if (rc) - RETURN(rc); + return rc; CDEBUG(D_INFO, "objid "DOSTID": %ux%u byte stripes\n", POSTID(&oinfo->oi_md->lsm_oi), oinfo->oi_md->lsm_stripe_count, @@ -1230,13 +1230,13 @@ static int lov_getattr_async(struct obd_export *exp, struct obd_info *oinfo, LASSERT (rqset->set_interpret == NULL); rqset->set_interpret = lov_getattr_interpret; rqset->set_arg = (void *)lovset; - RETURN(rc); + return rc; } out: if (rc) atomic_set(&lovset->set_completes, 0); err = lov_fini_getattr_set(lovset); - RETURN(rc ? rc : err); + return rc ? rc : err; } static int lov_setattr(const struct lu_env *env, struct obd_export *exp, @@ -1252,7 +1252,7 @@ static int lov_setattr(const struct lu_env *env, struct obd_export *exp, ASSERT_LSM_MAGIC(oinfo->oi_md); if (!exp || !exp->exp_obd) - RETURN(-ENODEV); + return -ENODEV; /* for now, we only expect the following updates here */ LASSERT(!(oinfo->oi_oa->o_valid & ~(OBD_MD_FLID | OBD_MD_FLTYPE | @@ -1265,7 +1265,7 @@ static int lov_setattr(const struct lu_env *env, struct obd_export *exp, lov = &exp->exp_obd->u.lov; rc = lov_prep_setattr_set(exp, oinfo, oti, &set); if (rc) - RETURN(rc); + return rc; list_for_each (pos, &set->set_list) { req = list_entry(pos, struct lov_request, rq_link); @@ -1287,7 +1287,7 @@ static int lov_setattr(const struct lu_env *env, struct obd_export *exp, err = lov_fini_setattr_set(set); if (!rc) rc = err; - RETURN(rc); + return rc; } static int lov_setattr_interpret(struct ptlrpc_request_set *rqset, @@ -1299,7 +1299,7 @@ static int lov_setattr_interpret(struct ptlrpc_request_set *rqset, if (rc) atomic_set(&lovset->set_completes, 0); err = lov_fini_setattr_set(lovset); - RETURN(rc ? rc : err); + return rc ? rc : err; } /* If @oti is given, the request goes from MDS and responses from OSTs are not @@ -1322,12 +1322,12 @@ static int lov_setattr_async(struct obd_export *exp, struct obd_info *oinfo, } if (!exp || !exp->exp_obd) - RETURN(-ENODEV); + return -ENODEV; lov = &exp->exp_obd->u.lov; rc = lov_prep_setattr_set(exp, oinfo, oti, &set); if (rc) - RETURN(rc); + return rc; CDEBUG(D_INFO, "objid "DOSTID": %ux%u byte stripes\n", POSTID(&oinfo->oi_md->lsm_oi), @@ -1362,14 +1362,14 @@ static int lov_setattr_async(struct obd_export *exp, struct obd_info *oinfo, if (rc) atomic_set(&set->set_completes, 0); err = lov_fini_setattr_set(set); - RETURN(rc ? rc : err); + return rc ? rc : err; } LASSERT(rqset->set_interpret == NULL); rqset->set_interpret = lov_setattr_interpret; rqset->set_arg = (void *)set; - RETURN(0); + return 0; } static int lov_punch_interpret(struct ptlrpc_request_set *rqset, @@ -1381,7 +1381,7 @@ static int lov_punch_interpret(struct ptlrpc_request_set *rqset, if (rc) atomic_set(&lovset->set_completes, 0); err = lov_fini_punch_set(lovset); - RETURN(rc ? rc : err); + return rc ? rc : err; } /* FIXME: maybe we'll just make one node the authoritative attribute node, then @@ -1401,12 +1401,12 @@ static int lov_punch(const struct lu_env *env, struct obd_export *exp, ASSERT_LSM_MAGIC(oinfo->oi_md); if (!exp || !exp->exp_obd) - RETURN(-ENODEV); + return -ENODEV; lov = &exp->exp_obd->u.lov; rc = lov_prep_punch_set(exp, oinfo, oti, &set); if (rc) - RETURN(rc); + return rc; list_for_each (pos, &set->set_list) { req = list_entry(pos, struct lov_request, rq_link); @@ -1426,14 +1426,14 @@ static int lov_punch(const struct lu_env *env, struct obd_export *exp, if (rc || list_empty(&rqset->set_requests)) { int err; err = lov_fini_punch_set(set); - RETURN(rc ? rc : err); + return rc ? rc : err; } LASSERT(rqset->set_interpret == NULL); rqset->set_interpret = lov_punch_interpret; rqset->set_arg = (void *)set; - RETURN(0); + return 0; } static int lov_sync_interpret(struct ptlrpc_request_set *rqset, @@ -1445,7 +1445,7 @@ static int lov_sync_interpret(struct ptlrpc_request_set *rqset, if (rc) atomic_set(&lovset->set_completes, 0); err = lov_fini_sync_set(lovset); - RETURN(rc ?: err); + return rc ?: err; } static int lov_sync(const struct lu_env *env, struct obd_export *exp, @@ -1462,12 +1462,12 @@ static int lov_sync(const struct lu_env *env, struct obd_export *exp, LASSERT(rqset != NULL); if (!exp->exp_obd) - RETURN(-ENODEV); + return -ENODEV; lov = &exp->exp_obd->u.lov; rc = lov_prep_sync_set(exp, oinfo, start, end, &set); if (rc) - RETURN(rc); + return rc; CDEBUG(D_INFO, "fsync objid "DOSTID" ["LPX64", "LPX64"]\n", POSTID(&set->set_oi->oi_oa->o_oi), start, end); @@ -1493,14 +1493,14 @@ static int lov_sync(const struct lu_env *env, struct obd_export *exp, if (rc || list_empty(&rqset->set_requests)) { int err = lov_fini_sync_set(set); - RETURN(rc ?: err); + return rc ?: err; } LASSERT(rqset->set_interpret == NULL); rqset->set_interpret = lov_sync_interpret; rqset->set_arg = (void *)set; - RETURN(0); + return 0; } static int lov_brw_check(struct lov_obd *lov, struct obd_info *lov_oinfo, @@ -1550,12 +1550,12 @@ static int lov_brw(int cmd, struct obd_export *exp, struct obd_info *oinfo, if (cmd == OBD_BRW_CHECK) { rc = lov_brw_check(lov, oinfo, oa_bufs, pga); - RETURN(rc); + return rc; } rc = lov_prep_brw_set(exp, oinfo, oa_bufs, pga, oti, &set); if (rc) - RETURN(rc); + return rc; list_for_each (pos, &set->set_list) { struct obd_export *sub_exp; @@ -1574,7 +1574,7 @@ static int lov_brw(int cmd, struct obd_export *exp, struct obd_info *oinfo, err = lov_fini_brw_set(set); if (!rc) rc = err; - RETURN(rc); + return rc; } static int lov_enqueue_interpret(struct ptlrpc_request_set *rqset, @@ -1583,7 +1583,7 @@ static int lov_enqueue_interpret(struct ptlrpc_request_set *rqset, struct lov_request_set *lovset = (struct lov_request_set *)data; rc = lov_fini_enqueue_set(lovset, lovset->set_ei->ei_mode, rc, rqset); - RETURN(rc); + return rc; } static int lov_enqueue(struct obd_export *exp, struct obd_info *oinfo, @@ -1605,12 +1605,12 @@ static int lov_enqueue(struct obd_export *exp, struct obd_info *oinfo, LASSERT((oinfo->oi_flags & LDLM_FL_REPLAY) == 0); if (!exp || !exp->exp_obd) - RETURN(-ENODEV); + return -ENODEV; lov = &exp->exp_obd->u.lov; rc = lov_prep_enqueue_set(exp, oinfo, einfo, &set); if (rc) - RETURN(rc); + return rc; list_for_each (pos, &set->set_list) { req = list_entry(pos, struct lov_request, rq_link); @@ -1626,11 +1626,11 @@ static int lov_enqueue(struct obd_export *exp, struct obd_info *oinfo, LASSERT(rqset->set_interpret == NULL); rqset->set_interpret = lov_enqueue_interpret; rqset->set_arg = (void *)set; - RETURN(rc); + return rc; } out: rc = lov_fini_enqueue_set(set, mode, rc, rqset); - RETURN(rc); + return rc; } static int lov_change_cbdata(struct obd_export *exp, @@ -1643,7 +1643,7 @@ static int lov_change_cbdata(struct obd_export *exp, ASSERT_LSM_MAGIC(lsm); if (!exp || !exp->exp_obd) - RETURN(-ENODEV); + return -ENODEV; lov = &exp->exp_obd->u.lov; for (i = 0; i < lsm->lsm_stripe_count; i++) { @@ -1660,7 +1660,7 @@ static int lov_change_cbdata(struct obd_export *exp, rc = obd_change_cbdata(lov->lov_tgts[loi->loi_ost_idx]->ltd_exp, &submd, it, data); } - RETURN(rc); + return rc; } /* find any ldlm lock of the inode in lov @@ -1677,7 +1677,7 @@ static int lov_find_cbdata(struct obd_export *exp, ASSERT_LSM_MAGIC(lsm); if (!exp || !exp->exp_obd) - RETURN(-ENODEV); + return -ENODEV; lov = &exp->exp_obd->u.lov; for (i = 0; i < lsm->lsm_stripe_count; i++) { @@ -1693,9 +1693,9 @@ static int lov_find_cbdata(struct obd_export *exp, rc = obd_find_cbdata(lov->lov_tgts[loi->loi_ost_idx]->ltd_exp, &submd, it, data); if (rc != 0) - RETURN(rc); + return rc; } - RETURN(rc); + return rc; } static int lov_cancel(struct obd_export *exp, struct lov_stripe_md *lsm, @@ -1712,13 +1712,13 @@ static int lov_cancel(struct obd_export *exp, struct lov_stripe_md *lsm, ASSERT_LSM_MAGIC(lsm); if (!exp || !exp->exp_obd) - RETURN(-ENODEV); + return -ENODEV; LASSERT(lockh); lov = &exp->exp_obd->u.lov; rc = lov_prep_cancel_set(exp, &oinfo, lsm, mode, lockh, &set); if (rc) - RETURN(rc); + return rc; list_for_each(pos, &set->set_list) { req = list_entry(pos, struct lov_request, rq_link); @@ -1738,7 +1738,7 @@ static int lov_cancel(struct obd_export *exp, struct lov_stripe_md *lsm, } lov_fini_cancel_set(set); - RETURN(err); + return err; } static int lov_cancel_unused(struct obd_export *exp, @@ -1749,7 +1749,7 @@ static int lov_cancel_unused(struct obd_export *exp, int rc = 0, i; if (!exp || !exp->exp_obd) - RETURN(-ENODEV); + return -ENODEV; lov = &exp->exp_obd->u.lov; if (lsm == NULL) { @@ -1763,7 +1763,7 @@ static int lov_cancel_unused(struct obd_export *exp, if (!rc) rc = err; } - RETURN(rc); + return rc; } ASSERT_LSM_MAGIC(lsm); @@ -1795,7 +1795,7 @@ static int lov_cancel_unused(struct obd_export *exp, rc = err; } } - RETURN(rc); + return rc; } int lov_statfs_interpret(struct ptlrpc_request_set *rqset, void *data, int rc) @@ -1807,7 +1807,7 @@ int lov_statfs_interpret(struct ptlrpc_request_set *rqset, void *data, int rc) atomic_set(&lovset->set_completes, 0); err = lov_fini_statfs_set(lovset); - RETURN(rc ? rc : err); + return rc ? rc : err; } static int lov_statfs_async(struct obd_export *exp, struct obd_info *oinfo, @@ -1826,7 +1826,7 @@ static int lov_statfs_async(struct obd_export *exp, struct obd_info *oinfo, lov = &obd->u.lov; rc = lov_prep_statfs_set(obd, oinfo, &set); if (rc) - RETURN(rc); + return rc; list_for_each (pos, &set->set_list) { req = list_entry(pos, struct lov_request, rq_link); @@ -1841,13 +1841,13 @@ static int lov_statfs_async(struct obd_export *exp, struct obd_info *oinfo, if (rc) atomic_set(&set->set_completes, 0); err = lov_fini_statfs_set(set); - RETURN(rc ? rc : err); + return rc ? rc : err; } LASSERT(rqset->set_interpret == NULL); rqset->set_interpret = lov_statfs_interpret; rqset->set_arg = (void *)set; - RETURN(0); + return 0; } static int lov_statfs(const struct lu_env *env, struct obd_export *exp, @@ -1861,7 +1861,7 @@ static int lov_statfs(const struct lu_env *env, struct obd_export *exp, * statfs requests */ set = ptlrpc_prep_set(); if (set == NULL) - RETURN(-ENOMEM); + return -ENOMEM; oinfo.oi_osfs = osfs; oinfo.oi_flags = flags; @@ -1870,7 +1870,7 @@ static int lov_statfs(const struct lu_env *env, struct obd_export *exp, rc = ptlrpc_set_wait(set); ptlrpc_set_destroy(set); - RETURN(rc); + return rc; } static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, @@ -1891,23 +1891,23 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, memcpy(&index, data->ioc_inlbuf2, sizeof(__u32)); if ((index >= count)) - RETURN(-ENODEV); + return -ENODEV; if (!lov->lov_tgts[index]) /* Try again with the next index */ - RETURN(-EAGAIN); + return -EAGAIN; if (!lov->lov_tgts[index]->ltd_active) - RETURN(-ENODATA); + return -ENODATA; osc_obd = class_exp2obd(lov->lov_tgts[index]->ltd_exp); if (!osc_obd) - RETURN(-EINVAL); + return -EINVAL; /* copy UUID */ if (copy_to_user(data->ioc_pbuf2, obd2cli_tgt(osc_obd), min((int) data->ioc_plen2, (int) sizeof(struct obd_uuid)))) - RETURN(-EFAULT); + return -EFAULT; flags = uarg ? *(__u32*)uarg : 0; /* got statfs data */ @@ -1915,11 +1915,11 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), flags); if (rc) - RETURN(rc); + return rc; if (copy_to_user(data->ioc_pbuf1, &stat_buf, min((int) data->ioc_plen1, (int) sizeof(stat_buf)))) - RETURN(-EFAULT); + return -EFAULT; break; } case OBD_IOC_LOV_GET_CONFIG: { @@ -1930,23 +1930,23 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, len = 0; if (obd_ioctl_getdata(&buf, &len, (void *)uarg)) - RETURN(-EINVAL); + return -EINVAL; data = (struct obd_ioctl_data *)buf; if (sizeof(*desc) > data->ioc_inllen1) { obd_ioctl_freedata(buf, len); - RETURN(-EINVAL); + return -EINVAL; } if (sizeof(uuidp->uuid) * count > data->ioc_inllen2) { obd_ioctl_freedata(buf, len); - RETURN(-EINVAL); + return -EINVAL; } if (sizeof(__u32) * count > data->ioc_inllen3) { obd_ioctl_freedata(buf, len); - RETURN(-EINVAL); + return -EINVAL; } desc = (struct lov_desc *)data->ioc_inlbuf1; @@ -1983,11 +1983,11 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, if (qctl->qc_valid == QC_OSTIDX) { if (qctl->qc_idx < 0 || count <= qctl->qc_idx) - RETURN(-EINVAL); + return -EINVAL; tgt = lov->lov_tgts[qctl->qc_idx]; if (!tgt || !tgt->ltd_exp) - RETURN(-EINVAL); + return -EINVAL; } else if (qctl->qc_valid == QC_UUID) { for (i = 0; i < count; i++) { tgt = lov->lov_tgts[i]; @@ -1997,21 +1997,21 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, continue; if (tgt->ltd_exp == NULL) - RETURN(-EINVAL); + return -EINVAL; break; } } else { - RETURN(-EINVAL); + return -EINVAL; } if (i >= count) - RETURN(-EAGAIN); + return -EAGAIN; LASSERT(tgt && tgt->ltd_exp); OBD_ALLOC_PTR(oqctl); if (!oqctl) - RETURN(-ENOMEM); + return -ENOMEM; QCTL_COPY(oqctl, qctl); rc = obd_quotactl(tgt->ltd_exp, oqctl); @@ -2027,7 +2027,7 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, int set = 0; if (count == 0) - RETURN(-ENOTTY); + return -ENOTTY; for (i = 0; i < count; i++) { int err; @@ -2044,7 +2044,7 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, err = obd_iocontrol(cmd, lov->lov_tgts[i]->ltd_exp, len, karg, uarg); if (err == -ENODATA && cmd == OBD_IOC_POLL_QUOTACHECK) { - RETURN(err); + return err; } else if (err) { if (lov->lov_tgts[i]->ltd_active) { CDEBUG(err == -ENOTTY ? @@ -2065,7 +2065,7 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, } } - RETURN(rc); + return rc; } #define FIEMAP_BUFFER_SIZE 4096 @@ -2434,7 +2434,7 @@ static int lov_get_info(const struct lu_env *env, struct obd_export *exp, int i, rc; if (!vallen || !val) - RETURN(-EFAULT); + return -EFAULT; obd_getref(obddev); @@ -2515,7 +2515,7 @@ static int lov_get_info(const struct lu_env *env, struct obd_export *exp, out: obd_putref(obddev); - RETURN(rc); + return rc; } static int lov_set_info_async(const struct lu_env *env, struct obd_export *exp, @@ -2536,7 +2536,7 @@ static int lov_set_info_async(const struct lu_env *env, struct obd_export *exp, no_set = 1; set = ptlrpc_prep_set(); if (!set) - RETURN(-ENOMEM); + return -ENOMEM; } obd_getref(obddev); @@ -2628,7 +2628,7 @@ static int lov_set_info_async(const struct lu_env *env, struct obd_export *exp, rc = err; ptlrpc_set_destroy(set); } - RETURN(rc); + return rc; } static int lov_extent_calc(struct obd_export *exp, struct lov_stripe_md *lsm, @@ -2652,7 +2652,7 @@ static int lov_extent_calc(struct obd_export *exp, struct lov_stripe_md *lsm, LBUG(); } - RETURN(0); + return 0; } void lov_stripe_lock(struct lov_stripe_md *md) @@ -2688,7 +2688,7 @@ static int lov_quotactl(struct obd_device *obd, struct obd_export *exp, oqctl->qc_cmd != LUSTRE_Q_SETQUOTA && oqctl->qc_cmd != Q_FINVALIDATE) { CERROR("bad quota opc %x for lov obd", oqctl->qc_cmd); - RETURN(-EFAULT); + return -EFAULT; } /* for lov tgt */ @@ -2730,7 +2730,7 @@ static int lov_quotactl(struct obd_device *obd, struct obd_export *exp, oqctl->qc_dqblk.dqb_curspace = curspace; oqctl->qc_dqblk.dqb_bhardlimit = bhardlimit; } - RETURN(rc); + return rc; } static int lov_quotacheck(struct obd_device *obd, struct obd_export *exp, @@ -2773,7 +2773,7 @@ static int lov_quotacheck(struct obd_device *obd, struct obd_export *exp, out: obd_putref(obd); - RETURN(rc); + return rc; } struct obd_ops lov_obd_ops = { @@ -2856,7 +2856,7 @@ int __init lov_init(void) lu_kmem_fini(lov_caches); } - RETURN(rc); + return rc; } static void /*__exit*/ lov_exit(void) diff --git a/drivers/staging/lustre/lustre/lov/lov_object.c b/drivers/staging/lustre/lustre/lov/lov_object.c index f869849135cfa..84e55ce3ccd22 100644 --- a/drivers/staging/lustre/lustre/lov/lov_object.c +++ b/drivers/staging/lustre/lustre/lov/lov_object.c @@ -118,7 +118,7 @@ static struct cl_object *lov_sub_find(const struct lu_env *env, o = lu_object_find_at(env, cl2lu_dev(dev), fid, &conf->coc_lu); LASSERT(ergo(!IS_ERR(o), o->lo_dev->ld_type == &lovsub_device_type)); - RETURN(lu2cl(o)); + return lu2cl(o); } static int lov_init_sub(const struct lu_env *env, struct lov_object *lov, @@ -252,7 +252,7 @@ static int lov_init_raid0(const struct lu_env *env, } else result = -ENOMEM; out: - RETURN(result); + return result; } static int lov_init_released(const struct lu_env *env, @@ -353,7 +353,7 @@ static int lov_delete_raid0(const struct lu_env *env, struct lov_object *lov, } } cl_object_prune(env, &lov->lo_cl); - RETURN(0); + return 0; } static void lov_fini_empty(const struct lu_env *env, struct lov_object *lov, @@ -497,7 +497,7 @@ static int lov_attr_get_raid0(const struct lu_env *env, struct cl_object *obj, if (attr->cat_mtime < lov_attr->cat_mtime) attr->cat_mtime = lov_attr->cat_mtime; } - RETURN(result); + return result; } const static struct lov_layout_operations lov_dispatch[] = { @@ -631,7 +631,7 @@ static int lov_layout_wait(const struct lu_env *env, struct lov_object *lov) l_wait_event(lov->lo_waitq, atomic_read(&lov->lo_active_ios) == 0, &lwi); } - RETURN(0); + return 0; } static int lov_layout_change(const struct lu_env *unused, @@ -659,7 +659,7 @@ static int lov_layout_change(const struct lu_env *unused, env = cl_env_get(&refcheck); if (IS_ERR(env)) { cl_env_reexit(cookie); - RETURN(PTR_ERR(env)); + return PTR_ERR(env); } old_ops = &lov_dispatch[lov->lo_type]; @@ -689,7 +689,7 @@ static int lov_layout_change(const struct lu_env *unused, cl_env_put(env, &refcheck); cl_env_reexit(cookie); - RETURN(result); + return result; } /***************************************************************************** @@ -719,7 +719,7 @@ int lov_object_init(const struct lu_env *env, struct lu_object *obj, result = ops->llo_init(env, dev, lov, cconf, set); if (result == 0) ops->llo_install(env, lov, set); - RETURN(result); + return result; } static int lov_conf_set(const struct lu_env *env, struct cl_object *obj, @@ -767,7 +767,7 @@ static int lov_conf_set(const struct lu_env *env, struct cl_object *obj, out: lov_conf_unlock(lov); - RETURN(result); + return result; } static void lov_object_delete(const struct lu_env *env, struct lu_object *obj) @@ -880,7 +880,7 @@ struct lu_object *lov_object_alloc(const struct lu_env *env, obj->lo_ops = &lov_lu_obj_ops; } else obj = NULL; - RETURN(obj); + return obj; } struct lov_stripe_md *lov_lsm_addref(struct lov_object *lov) @@ -965,7 +965,7 @@ int lov_read_and_clear_async_rc(struct cl_object *clob) } lov_conf_thaw(lov); } - RETURN(rc); + return rc; } EXPORT_SYMBOL(lov_read_and_clear_async_rc); diff --git a/drivers/staging/lustre/lustre/lov/lov_offset.c b/drivers/staging/lustre/lustre/lov/lov_offset.c index 079ad5c90566c..04863a7c5e0bd 100644 --- a/drivers/staging/lustre/lustre/lov/lov_offset.c +++ b/drivers/staging/lustre/lustre/lov/lov_offset.c @@ -54,7 +54,7 @@ obd_size lov_stripe_size(struct lov_stripe_md *lsm, obd_size ost_size, int magic = lsm->lsm_magic; if (ost_size == 0) - RETURN(0); + return 0; LASSERT(lsm_op_find(magic) != NULL); lsm_op_find(magic)->lsm_stripe_by_index(lsm, &stripeno, NULL, &swidth); @@ -66,7 +66,7 @@ obd_size lov_stripe_size(struct lov_stripe_md *lsm, obd_size ost_size, else lov_size = (ost_size - 1) * swidth + (stripeno + 1) * ssize; - RETURN(lov_size); + return lov_size; } /* we have an offset in file backed by an lov and want to find out where diff --git a/drivers/staging/lustre/lustre/lov/lov_pack.c b/drivers/staging/lustre/lustre/lov/lov_pack.c index 5edcf8e28c0e2..55ec26778f804 100644 --- a/drivers/staging/lustre/lustre/lov/lov_pack.c +++ b/drivers/staging/lustre/lustre/lov/lov_pack.c @@ -158,7 +158,7 @@ int lov_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, (lmm_magic != LOV_MAGIC_V3)) { CERROR("bad mem LOV MAGIC: 0x%08X != 0x%08X nor 0x%08X\n", lmm_magic, LOV_MAGIC_V1, LOV_MAGIC_V3); - RETURN(-EINVAL); + return -EINVAL; } @@ -189,20 +189,20 @@ int lov_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, lmm_size = lov_mds_md_size(stripe_count, lmm_magic); if (!lmmp) - RETURN(lmm_size); + return lmm_size; if (*lmmp && !lsm) { stripe_count = le16_to_cpu((*lmmp)->lmm_stripe_count); lmm_size = lov_mds_md_size(stripe_count, lmm_magic); OBD_FREE_LARGE(*lmmp, lmm_size); *lmmp = NULL; - RETURN(0); + return 0; } if (!*lmmp) { OBD_ALLOC_LARGE(*lmmp, lmm_size); if (!*lmmp) - RETURN(-ENOMEM); + return -ENOMEM; } CDEBUG(D_INFO, "lov_packmd: LOV_MAGIC 0x%08X, lmm_size = %d \n", @@ -216,7 +216,7 @@ int lov_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, lmmv1->lmm_magic = cpu_to_le32(LOV_MAGIC_V1); if (!lsm) - RETURN(lmm_size); + return lmm_size; /* lmmv1 and lmmv3 point to the same struct and have the * same first fields @@ -230,7 +230,7 @@ int lov_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, cplen = strlcpy(lmmv3->lmm_pool_name, lsm->lsm_pool_name, sizeof(lmmv3->lmm_pool_name)); if (cplen >= sizeof(lmmv3->lmm_pool_name)) - RETURN(-E2BIG); + return -E2BIG; lmm_objects = lmmv3->lmm_objects; } else { lmm_objects = lmmv1->lmm_objects; @@ -247,7 +247,7 @@ int lov_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, lmm_objects[i].l_ost_idx = cpu_to_le32(loi->loi_ost_idx); } - RETURN(lmm_size); + return lmm_size; } /* Find the max stripecount we should use */ @@ -314,7 +314,7 @@ int lov_alloc_memmd(struct lov_stripe_md **lsmp, __u16 stripe_count, *lsmp = lsm_alloc_plain(stripe_count, &lsm_size); if (!*lsmp) { CERROR("can't allocate lsmp stripe_count %d\n", stripe_count); - RETURN(-ENOMEM); + return -ENOMEM; } atomic_set(&(*lsmp)->lsm_refc, 1); @@ -331,7 +331,7 @@ int lov_alloc_memmd(struct lov_stripe_md **lsmp, __u16 stripe_count, for (i = 0; i < stripe_count; i++) loi_init((*lsmp)->lsm_oinfo[i]); - RETURN(lsm_size); + return lsm_size; } int lov_free_memmd(struct lov_stripe_md **lsmp) @@ -366,7 +366,7 @@ int lov_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, if (lmm) { rc = lov_verify_lmm(lmm, lmm_bytes, &stripe_count); if (rc) - RETURN(rc); + return rc; magic = le32_to_cpu(lmm->lmm_magic); } else { magic = LOV_MAGIC; @@ -377,31 +377,31 @@ int lov_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, if (!lsmp) { /* XXX LOV STACKING call into osc for sizes */ LBUG(); - RETURN(lov_stripe_md_size(stripe_count)); + return lov_stripe_md_size(stripe_count); } /* If we are passed an allocated struct but nothing to unpack, free */ if (*lsmp && !lmm) { lov_free_memmd(lsmp); - RETURN(0); + return 0; } pattern = le32_to_cpu(lmm->lmm_pattern); lsm_size = lov_alloc_memmd(lsmp, stripe_count, pattern, magic); if (lsm_size < 0) - RETURN(lsm_size); + return lsm_size; /* If we are passed a pointer but nothing to unpack, we only alloc */ if (!lmm) - RETURN(lsm_size); + return lsm_size; LASSERT(lsm_op_find(magic) != NULL); rc = lsm_op_find(magic)->lsm_unpackmd(lov, *lsmp, lmm); if (rc) { lov_free_memmd(lsmp); - RETURN(rc); + return rc; } - RETURN(lsm_size); + return lsm_size; } static int __lov_setstripe(struct obd_export *exp, int max_lmm_size, @@ -420,7 +420,7 @@ static int __lov_setstripe(struct obd_export *exp, int max_lmm_size, rc = lov_lum_swab_if_needed(lumv3, &lmm_magic, lump); if (rc) - RETURN(rc); + return rc; /* in the rest of the tests, as *lumv1 and lumv3 have the same * fields, we use lumv1 to avoid code duplication */ @@ -433,7 +433,7 @@ static int __lov_setstripe(struct obd_export *exp, int max_lmm_size, if (lov_pattern(lumv1->lmm_pattern) != LOV_PATTERN_RAID0) { CDEBUG(D_IOCTL, "bad userland stripe pattern: %#x\n", lumv1->lmm_pattern); - RETURN(-EINVAL); + return -EINVAL; } /* 64kB is the largest common page size we see (ia64), and matches the @@ -449,7 +449,7 @@ static int __lov_setstripe(struct obd_export *exp, int max_lmm_size, (typeof(lumv1->lmm_stripe_offset))(-1))) { CDEBUG(D_IOCTL, "stripe offset %u > number of OSTs %u\n", lumv1->lmm_stripe_offset, lov->desc.ld_tgt_count); - RETURN(-EINVAL); + return -EINVAL; } stripe_count = lov_get_stripecnt(lov, lmm_magic, lumv1->lmm_stripe_count); @@ -479,7 +479,7 @@ static int __lov_setstripe(struct obd_export *exp, int max_lmm_size, lumv3->lmm_stripe_offset, pool); if (rc < 0) { lov_pool_putref(pool); - RETURN(-EINVAL); + return -EINVAL; } } @@ -508,7 +508,7 @@ static int __lov_setstripe(struct obd_export *exp, int max_lmm_size, rc = 0; } - RETURN(rc); + return rc; } /* Configure object striping information on a new file. @@ -529,7 +529,7 @@ int lov_setstripe(struct obd_export *exp, int max_lmm_size, rc = __lov_setstripe(exp, max_lmm_size, lsmp, lump); set_fs(seg); - RETURN(rc); + return rc; } int lov_setea(struct obd_export *exp, struct lov_stripe_md **lsmp, @@ -553,26 +553,26 @@ int lov_setea(struct obd_export *exp, struct lov_stripe_md **lsmp, rc = obd_get_info(NULL, oexp, sizeof(KEY_LAST_ID), KEY_LAST_ID, &len, &last_id, NULL); if (rc) - RETURN(rc); + return rc; if (ostid_id(&lmm_objects[i].l_ost_oi) > last_id) { CERROR("Setting EA for object > than last id on" " ost idx %d "DOSTID" > "LPD64" \n", lmm_objects[i].l_ost_idx, POSTID(&lmm_objects[i].l_ost_oi), last_id); - RETURN(-EINVAL); + return -EINVAL; } } rc = lov_setstripe(exp, 0, lsmp, lump); if (rc) - RETURN(rc); + return rc; for (i = 0; i < lump->lmm_stripe_count; i++) { (*lsmp)->lsm_oinfo[i]->loi_ost_idx = lmm_objects[i].l_ost_idx; (*lsmp)->lsm_oinfo[i]->loi_oi = lmm_objects[i].l_ost_oi; } - RETURN(0); + return 0; } @@ -596,7 +596,7 @@ int lov_getstripe(struct obd_export *exp, struct lov_stripe_md *lsm, mm_segment_t seg; if (!lsm) - RETURN(-ENODATA); + return -ENODATA; /* * "Switch to kernel segment" to allow copying from kernel space by @@ -674,5 +674,5 @@ int lov_getstripe(struct obd_export *exp, struct lov_stripe_md *lsm, obd_free_diskmd(exp, &lmmk); out_set: set_fs(seg); - RETURN(rc); + return rc; } diff --git a/drivers/staging/lustre/lustre/lov/lov_page.c b/drivers/staging/lustre/lustre/lov/lov_page.c index 220e78f19ea7f..674e61781c20b 100644 --- a/drivers/staging/lustre/lustre/lov/lov_page.c +++ b/drivers/staging/lustre/lustre/lov/lov_page.c @@ -95,7 +95,7 @@ static int lov_page_own(const struct lu_env *env, lov_sub_put(sub); } else LBUG(); /* Arrgh */ - RETURN(0); + return 0; } static void lov_page_assume(const struct lu_env *env, @@ -124,7 +124,7 @@ static int lov_page_cache_add(const struct lu_env *env, rc = PTR_ERR(sub); CL_PAGE_DEBUG(D_ERROR, env, slice->cpl_page, "rc = %d\n", rc); } - RETURN(rc); + return rc; } static int lov_page_print(const struct lu_env *env, @@ -221,7 +221,7 @@ int lov_page_init_empty(const struct lu_env *env, struct cl_object *obj, memset(addr, 0, cl_page_size(obj)); kunmap(vmpage); cl_page_export(env, page, 1); - RETURN(0); + return 0; } diff --git a/drivers/staging/lustre/lustre/lov/lov_pool.c b/drivers/staging/lustre/lustre/lov/lov_pool.c index e52f14c88f908..dd3c07d5c4de4 100644 --- a/drivers/staging/lustre/lustre/lov/lov_pool.c +++ b/drivers/staging/lustre/lustre/lov/lov_pool.c @@ -330,7 +330,7 @@ int lov_ost_pool_init(struct ost_pool *op, unsigned int count) OBD_ALLOC(op->op_array, op->op_size * sizeof(op->op_array[0])); if (op->op_array == NULL) { op->op_size = 0; - RETURN(-ENOMEM); + return -ENOMEM; } return 0; } @@ -399,13 +399,13 @@ int lov_ost_pool_remove(struct ost_pool *op, __u32 idx) } up_write(&op->op_rw_sem); - RETURN(-EINVAL); + return -EINVAL; } int lov_ost_pool_free(struct ost_pool *op) { if (op->op_size == 0) - RETURN(0); + return 0; down_write(&op->op_rw_sem); @@ -415,7 +415,7 @@ int lov_ost_pool_free(struct ost_pool *op) op->op_size = 0; up_write(&op->op_rw_sem); - RETURN(0); + return 0; } @@ -428,11 +428,11 @@ int lov_pool_new(struct obd_device *obd, char *poolname) lov = &(obd->u.lov); if (strlen(poolname) > LOV_MAXPOOLNAME) - RETURN(-ENAMETOOLONG); + return -ENAMETOOLONG; OBD_ALLOC_PTR(new_pool); if (new_pool == NULL) - RETURN(-ENOMEM); + return -ENOMEM; strncpy(new_pool->pool_name, poolname, LOV_MAXPOOLNAME); new_pool->pool_name[LOV_MAXPOOLNAME] = '\0'; @@ -481,7 +481,7 @@ int lov_pool_new(struct obd_device *obd, char *poolname) CDEBUG(D_CONFIG, LOV_POOLNAMEF" is pool #%d\n", poolname, lov->lov_pool_count); - RETURN(0); + return 0; out_err: spin_lock(&obd->obd_dev_lock); @@ -508,7 +508,7 @@ int lov_pool_del(struct obd_device *obd, char *poolname) /* lookup and kill hash reference */ pool = cfs_hash_del_key(lov->lov_pools_hash_body, poolname); if (pool == NULL) - RETURN(-ENOENT); + return -ENOENT; if (pool->pool_proc_entry != NULL) { CDEBUG(D_INFO, "proc entry %p\n", pool->pool_proc_entry); @@ -524,7 +524,7 @@ int lov_pool_del(struct obd_device *obd, char *poolname) /* release last reference */ lov_pool_putref(pool); - RETURN(0); + return 0; } @@ -540,7 +540,7 @@ int lov_pool_add(struct obd_device *obd, char *poolname, char *ostname) pool = cfs_hash_lookup(lov->lov_pools_hash_body, poolname); if (pool == NULL) - RETURN(-ENOENT); + return -ENOENT; obd_str2uuid(&ost_uuid, ostname); @@ -585,7 +585,7 @@ int lov_pool_remove(struct obd_device *obd, char *poolname, char *ostname) pool = cfs_hash_lookup(lov->lov_pools_hash_body, poolname); if (pool == NULL) - RETURN(-ENOENT); + return -ENOENT; obd_str2uuid(&ost_uuid, ostname); diff --git a/drivers/staging/lustre/lustre/lov/lov_request.c b/drivers/staging/lustre/lustre/lov/lov_request.c index d975fc550d853..61e6d0b46c98e 100644 --- a/drivers/staging/lustre/lustre/lov/lov_request.c +++ b/drivers/staging/lustre/lustre/lov/lov_request.c @@ -129,7 +129,7 @@ int lov_update_common_set(struct lov_request_set *set, rc = 0; /* FIXME in raid1 regime, should return 0 */ - RETURN(rc); + return rc; } void lov_set_add_req(struct lov_request *req, struct lov_request_set *set) @@ -250,7 +250,7 @@ int lov_update_enqueue_set(struct lov_request *req, __u32 mode, int rc) req->rq_idx, &oi->oi_md->lsm_oi, rc); lov_stripe_unlock(oi->oi_md); lov_update_set(set, req, rc); - RETURN(rc); + return rc; } /* The callback for osc_enqueue that updates lov info for every OSC request. */ @@ -274,7 +274,7 @@ static int enqueue_done(struct lov_request_set *set, __u32 mode) /* enqueue/match success, just return */ if (completes && completes == atomic_read(&set->set_success)) - RETURN(0); + return 0; /* cancel enqueued/matched locks */ list_for_each_entry(req, &set->set_list, rq_link) { @@ -300,7 +300,7 @@ static int enqueue_done(struct lov_request_set *set, __u32 mode) } if (set->set_lockh) lov_llh_put(set->set_lockh); - RETURN(rc); + return rc; } int lov_fini_enqueue_set(struct lov_request_set *set, __u32 mode, int rc, @@ -309,7 +309,7 @@ int lov_fini_enqueue_set(struct lov_request_set *set, __u32 mode, int rc, int ret = 0; if (set == NULL) - RETURN(0); + return 0; LASSERT(set->set_exp); /* Do enqueue_done only for sync requests and if any request * succeeded. */ @@ -322,7 +322,7 @@ int lov_fini_enqueue_set(struct lov_request_set *set, __u32 mode, int rc, lov_put_reqset(set); - RETURN(rc ? rc : ret); + return rc ? rc : ret; } static void lov_llh_addref(void *llhp) @@ -366,7 +366,7 @@ int lov_prep_enqueue_set(struct obd_export *exp, struct obd_info *oinfo, OBD_ALLOC(set, sizeof(*set)); if (set == NULL) - RETURN(-ENOMEM); + return -ENOMEM; lov_init_set(set); set->set_exp = exp; @@ -438,10 +438,10 @@ int lov_prep_enqueue_set(struct obd_export *exp, struct obd_info *oinfo, if (!set->set_count) GOTO(out_set, rc = -EIO); *reqset = set; - RETURN(0); + return 0; out_set: lov_fini_enqueue_set(set, einfo->ei_mode, rc, NULL); - RETURN(rc); + return rc; } int lov_fini_match_set(struct lov_request_set *set, __u32 mode, int flags) @@ -449,7 +449,7 @@ int lov_fini_match_set(struct lov_request_set *set, __u32 mode, int flags) int rc = 0; if (set == NULL) - RETURN(0); + return 0; LASSERT(set->set_exp); rc = enqueue_done(set, mode); if ((set->set_count == atomic_read(&set->set_success)) && @@ -458,7 +458,7 @@ int lov_fini_match_set(struct lov_request_set *set, __u32 mode, int flags) lov_put_reqset(set); - RETURN(rc); + return rc; } int lov_prep_match_set(struct obd_export *exp, struct obd_info *oinfo, @@ -472,7 +472,7 @@ int lov_prep_match_set(struct obd_export *exp, struct obd_info *oinfo, OBD_ALLOC(set, sizeof(*set)); if (set == NULL) - RETURN(-ENOMEM); + return -ENOMEM; lov_init_set(set); set->set_exp = exp; @@ -526,10 +526,10 @@ int lov_prep_match_set(struct obd_export *exp, struct obd_info *oinfo, if (!set->set_count) GOTO(out_set, rc = -EIO); *reqset = set; - RETURN(rc); + return rc; out_set: lov_fini_match_set(set, mode, 0); - RETURN(rc); + return rc; } int lov_fini_cancel_set(struct lov_request_set *set) @@ -537,7 +537,7 @@ int lov_fini_cancel_set(struct lov_request_set *set) int rc = 0; if (set == NULL) - RETURN(0); + return 0; LASSERT(set->set_exp); if (set->set_lockh) @@ -545,7 +545,7 @@ int lov_fini_cancel_set(struct lov_request_set *set) lov_put_reqset(set); - RETURN(rc); + return rc; } int lov_prep_cancel_set(struct obd_export *exp, struct obd_info *oinfo, @@ -558,7 +558,7 @@ int lov_prep_cancel_set(struct obd_export *exp, struct obd_info *oinfo, OBD_ALLOC(set, sizeof(*set)); if (set == NULL) - RETURN(-ENOMEM); + return -ENOMEM; lov_init_set(set); set->set_exp = exp; @@ -606,10 +606,10 @@ int lov_prep_cancel_set(struct obd_export *exp, struct obd_info *oinfo, if (!set->set_count) GOTO(out_set, rc = -EIO); *reqset = set; - RETURN(rc); + return rc; out_set: lov_fini_cancel_set(set); - RETURN(rc); + return rc; } static int common_attr_done(struct lov_request_set *set) { @@ -621,10 +621,10 @@ static int common_attr_done(struct lov_request_set *set) LASSERT(set->set_oi != NULL); if (set->set_oi->oi_oa == NULL) - RETURN(0); + return 0; if (!atomic_read(&set->set_success)) - RETURN(-EIO); + return -EIO; OBDO_ALLOC(tmp_oa); if (tmp_oa == NULL) @@ -658,7 +658,7 @@ static int common_attr_done(struct lov_request_set *set) out: if (tmp_oa) OBDO_FREE(tmp_oa); - RETURN(rc); + return rc; } @@ -681,7 +681,7 @@ static int brw_done(struct lov_request_set *set) loi->loi_lvb.lvb_blocks = req->rq_oi.oi_oa->o_blocks; } - RETURN(0); + return 0; } int lov_fini_brw_set(struct lov_request_set *set) @@ -689,7 +689,7 @@ int lov_fini_brw_set(struct lov_request_set *set) int rc = 0; if (set == NULL) - RETURN(0); + return 0; LASSERT(set->set_exp); if (atomic_read(&set->set_completes)) { rc = brw_done(set); @@ -697,7 +697,7 @@ int lov_fini_brw_set(struct lov_request_set *set) } lov_put_reqset(set); - RETURN(rc); + return rc; } int lov_prep_brw_set(struct obd_export *exp, struct obd_info *oinfo, @@ -716,7 +716,7 @@ int lov_prep_brw_set(struct obd_export *exp, struct obd_info *oinfo, OBD_ALLOC(set, sizeof(*set)); if (set == NULL) - RETURN(-ENOMEM); + return -ENOMEM; lov_init_set(set); set->set_exp = exp; @@ -817,7 +817,7 @@ int lov_prep_brw_set(struct obd_export *exp, struct obd_info *oinfo, else lov_fini_brw_set(set); - RETURN(rc); + return rc; } int lov_fini_getattr_set(struct lov_request_set *set) @@ -825,14 +825,14 @@ int lov_fini_getattr_set(struct lov_request_set *set) int rc = 0; if (set == NULL) - RETURN(0); + return 0; LASSERT(set->set_exp); if (atomic_read(&set->set_completes)) rc = common_attr_done(set); lov_put_reqset(set); - RETURN(rc); + return rc; } /* The callback for osc_getattr_async that finilizes a request info when a @@ -854,7 +854,7 @@ int lov_prep_getattr_set(struct obd_export *exp, struct obd_info *oinfo, OBD_ALLOC(set, sizeof(*set)); if (set == NULL) - RETURN(-ENOMEM); + return -ENOMEM; lov_init_set(set); set->set_exp = exp; @@ -896,16 +896,16 @@ int lov_prep_getattr_set(struct obd_export *exp, struct obd_info *oinfo, if (!set->set_count) GOTO(out_set, rc = -EIO); *reqset = set; - RETURN(rc); + return rc; out_set: lov_fini_getattr_set(set); - RETURN(rc); + return rc; } int lov_fini_destroy_set(struct lov_request_set *set) { if (set == NULL) - RETURN(0); + return 0; LASSERT(set->set_exp); if (atomic_read(&set->set_completes)) { /* FIXME update qos data here */ @@ -913,7 +913,7 @@ int lov_fini_destroy_set(struct lov_request_set *set) lov_put_reqset(set); - RETURN(0); + return 0; } int lov_prep_destroy_set(struct obd_export *exp, struct obd_info *oinfo, @@ -927,7 +927,7 @@ int lov_prep_destroy_set(struct obd_export *exp, struct obd_info *oinfo, OBD_ALLOC(set, sizeof(*set)); if (set == NULL) - RETURN(-ENOMEM); + return -ENOMEM; lov_init_set(set); set->set_exp = exp; @@ -967,10 +967,10 @@ int lov_prep_destroy_set(struct obd_export *exp, struct obd_info *oinfo, if (!set->set_count) GOTO(out_set, rc = -EIO); *reqset = set; - RETURN(rc); + return rc; out_set: lov_fini_destroy_set(set); - RETURN(rc); + return rc; } int lov_fini_setattr_set(struct lov_request_set *set) @@ -978,7 +978,7 @@ int lov_fini_setattr_set(struct lov_request_set *set) int rc = 0; if (set == NULL) - RETURN(0); + return 0; LASSERT(set->set_exp); if (atomic_read(&set->set_completes)) { rc = common_attr_done(set); @@ -986,7 +986,7 @@ int lov_fini_setattr_set(struct lov_request_set *set) } lov_put_reqset(set); - RETURN(rc); + return rc; } int lov_update_setattr_set(struct lov_request_set *set, @@ -1014,7 +1014,7 @@ int lov_update_setattr_set(struct lov_request_set *set, req->rq_oi.oi_oa->o_atime; } - RETURN(rc); + return rc; } /* The callback for osc_setattr_async that finilizes a request info when a @@ -1037,7 +1037,7 @@ int lov_prep_setattr_set(struct obd_export *exp, struct obd_info *oinfo, OBD_ALLOC(set, sizeof(*set)); if (set == NULL) - RETURN(-ENOMEM); + return -ENOMEM; lov_init_set(set); set->set_exp = exp; @@ -1090,10 +1090,10 @@ int lov_prep_setattr_set(struct obd_export *exp, struct obd_info *oinfo, if (!set->set_count) GOTO(out_set, rc = -EIO); *reqset = set; - RETURN(rc); + return rc; out_set: lov_fini_setattr_set(set); - RETURN(rc); + return rc; } int lov_fini_punch_set(struct lov_request_set *set) @@ -1101,7 +1101,7 @@ int lov_fini_punch_set(struct lov_request_set *set) int rc = 0; if (set == NULL) - RETURN(0); + return 0; LASSERT(set->set_exp); if (atomic_read(&set->set_completes)) { rc = -EIO; @@ -1112,7 +1112,7 @@ int lov_fini_punch_set(struct lov_request_set *set) lov_put_reqset(set); - RETURN(rc); + return rc; } int lov_update_punch_set(struct lov_request_set *set, @@ -1137,7 +1137,7 @@ int lov_update_punch_set(struct lov_request_set *set, lov_stripe_unlock(lsm); } - RETURN(rc); + return rc; } /* The callback for osc_punch that finilizes a request info when a response @@ -1160,7 +1160,7 @@ int lov_prep_punch_set(struct obd_export *exp, struct obd_info *oinfo, OBD_ALLOC(set, sizeof(*set)); if (set == NULL) - RETURN(-ENOMEM); + return -ENOMEM; lov_init_set(set); set->set_oi = oinfo; @@ -1212,10 +1212,10 @@ int lov_prep_punch_set(struct obd_export *exp, struct obd_info *oinfo, if (!set->set_count) GOTO(out_set, rc = -EIO); *reqset = set; - RETURN(rc); + return rc; out_set: lov_fini_punch_set(set); - RETURN(rc); + return rc; } int lov_fini_sync_set(struct lov_request_set *set) @@ -1223,7 +1223,7 @@ int lov_fini_sync_set(struct lov_request_set *set) int rc = 0; if (set == NULL) - RETURN(0); + return 0; LASSERT(set->set_exp); if (atomic_read(&set->set_completes)) { if (!atomic_read(&set->set_success)) @@ -1233,7 +1233,7 @@ int lov_fini_sync_set(struct lov_request_set *set) lov_put_reqset(set); - RETURN(rc); + return rc; } /* The callback for osc_sync that finilizes a request info when a @@ -1257,7 +1257,7 @@ int lov_prep_sync_set(struct obd_export *exp, struct obd_info *oinfo, OBD_ALLOC_PTR(set); if (set == NULL) - RETURN(-ENOMEM); + return -ENOMEM; lov_init_set(set); set->set_exp = exp; @@ -1302,10 +1302,10 @@ int lov_prep_sync_set(struct obd_export *exp, struct obd_info *oinfo, if (!set->set_count) GOTO(out_set, rc = -EIO); *reqset = set; - RETURN(rc); + return rc; out_set: lov_fini_sync_set(set); - RETURN(rc); + return rc; } #define LOV_U64_MAX ((__u64)~0ULL) @@ -1331,10 +1331,10 @@ int lov_fini_statfs(struct obd_device *obd, struct obd_statfs *osfs,int success) memcpy(&obd->obd_osfs, osfs, sizeof(*osfs)); obd->obd_osfs_age = cfs_time_current_64(); spin_unlock(&obd->obd_osfs_lock); - RETURN(0); + return 0; } - RETURN(-EIO); + return -EIO; } int lov_fini_statfs_set(struct lov_request_set *set) @@ -1342,14 +1342,14 @@ int lov_fini_statfs_set(struct lov_request_set *set) int rc = 0; if (set == NULL) - RETURN(0); + return 0; if (atomic_read(&set->set_completes)) { rc = lov_fini_statfs(set->set_obd, set->set_oi->oi_osfs, atomic_read(&set->set_success)); } lov_put_reqset(set); - RETURN(rc); + return rc; } void lov_update_statfs(struct obd_statfs *osfs, struct obd_statfs *lov_sfs, @@ -1456,7 +1456,7 @@ static int cb_statfs_update(void *cookie, int rc) atomic_read(&set->set_success)); } - RETURN(0); + return 0; } int lov_prep_statfs_set(struct obd_device *obd, struct obd_info *oinfo, @@ -1468,7 +1468,7 @@ int lov_prep_statfs_set(struct obd_device *obd, struct obd_info *oinfo, OBD_ALLOC(set, sizeof(*set)); if (set == NULL) - RETURN(-ENOMEM); + return -ENOMEM; lov_init_set(set); set->set_obd = obd; @@ -1511,8 +1511,8 @@ int lov_prep_statfs_set(struct obd_device *obd, struct obd_info *oinfo, if (!set->set_count) GOTO(out_set, rc = -EIO); *reqset = set; - RETURN(rc); + return rc; out_set: lov_fini_statfs_set(set); - RETURN(rc); + return rc; } diff --git a/drivers/staging/lustre/lustre/lov/lovsub_dev.c b/drivers/staging/lustre/lustre/lov/lovsub_dev.c index 67cb287031fce..998ea1cbc7bb4 100644 --- a/drivers/staging/lustre/lustre/lov/lovsub_dev.c +++ b/drivers/staging/lustre/lustre/lov/lovsub_dev.c @@ -103,13 +103,13 @@ static int lovsub_device_init(const struct lu_env *env, struct lu_device *d, rc = ldt->ldt_ops->ldto_device_init(env, next, ldt->ldt_name, NULL); if (rc) { next->ld_site = NULL; - RETURN(rc); + return rc; } lu_device_get(next); lu_ref_add(&next->ld_reference, "lu-stack", &lu_site_init); lsd->acid_next = lu2cl_dev(next); - RETURN(rc); + return rc; } static struct lu_device *lovsub_device_fini(const struct lu_env *env, @@ -122,7 +122,7 @@ static struct lu_device *lovsub_device_fini(const struct lu_env *env, next = cl2lu_dev(lsd->acid_next); lsd->acid_super = NULL; lsd->acid_next = NULL; - RETURN(next); + return next; } static struct lu_device *lovsub_device_free(const struct lu_env *env, diff --git a/drivers/staging/lustre/lustre/lov/lovsub_lock.c b/drivers/staging/lustre/lustre/lov/lovsub_lock.c index 9a6b8c851a083..80305aa617123 100644 --- a/drivers/staging/lustre/lustre/lov/lovsub_lock.c +++ b/drivers/staging/lustre/lustre/lov/lovsub_lock.c @@ -136,7 +136,7 @@ static unsigned long lovsub_lock_weigh(const struct lu_env *env, } else dumbbell = 0; - RETURN(dumbbell); + return dumbbell; } /** @@ -240,7 +240,7 @@ static int lovsub_lock_modify(const struct lu_env *env, lovsub_parent_unlock(env, lov); result = result ?: rc; } - RETURN(result); + return result; } static int lovsub_lock_closure(const struct lu_env *env, @@ -263,7 +263,7 @@ static int lovsub_lock_closure(const struct lu_env *env, if (result != 0) break; } - RETURN(result); + return result; } /** @@ -278,7 +278,7 @@ static int lovsub_lock_delete_one(const struct lu_env *env, parent = lov->lls_cl.cls_lock; if (parent->cll_error) - RETURN(0); + return 0; result = 0; switch (parent->cll_state) { @@ -370,7 +370,7 @@ static int lovsub_lock_delete_one(const struct lu_env *env, break; } - RETURN(result); + return result; } /** @@ -460,7 +460,7 @@ int lovsub_lock_init(const struct lu_env *env, struct cl_object *obj, result = 0; } else result = -ENOMEM; - RETURN(result); + return result; } /** @} lov */ diff --git a/drivers/staging/lustre/lustre/lov/lovsub_object.c b/drivers/staging/lustre/lustre/lov/lovsub_object.c index 13938c41a7288..89760b3bf3f7a 100644 --- a/drivers/staging/lustre/lustre/lov/lovsub_object.c +++ b/drivers/staging/lustre/lustre/lov/lovsub_object.c @@ -69,7 +69,7 @@ int lovsub_object_init(const struct lu_env *env, struct lu_object *obj, result = 0; } else result = -ENOMEM; - RETURN(result); + return result; } @@ -108,7 +108,7 @@ static int lovsub_attr_set(const struct lu_env *env, struct cl_object *obj, struct lov_object *lov = cl2lovsub(obj)->lso_super; lov_r0(lov)->lo_attr_valid = 0; - RETURN(0); + return 0; } static int lovsub_object_glimpse(const struct lu_env *env, @@ -117,7 +117,7 @@ static int lovsub_object_glimpse(const struct lu_env *env, { struct lovsub_object *los = cl2lovsub(obj); - RETURN(cl_object_glimpse(env, &los->lso_super->lo_cl, lvb)); + return cl_object_glimpse(env, &los->lso_super->lo_cl, lvb); } @@ -158,7 +158,7 @@ struct lu_object *lovsub_object_alloc(const struct lu_env *env, obj->lo_ops = &lovsub_lu_obj_ops; } else obj = NULL; - RETURN(obj); + return obj; } /** @} lov */ diff --git a/drivers/staging/lustre/lustre/lov/lovsub_page.c b/drivers/staging/lustre/lustre/lov/lovsub_page.c index 3a738eca56926..3f00ce9677b77 100644 --- a/drivers/staging/lustre/lustre/lov/lovsub_page.c +++ b/drivers/staging/lustre/lustre/lov/lovsub_page.c @@ -65,7 +65,7 @@ int lovsub_page_init(const struct lu_env *env, struct cl_object *obj, struct lovsub_page *lsb = cl_object_page_slice(obj, page); cl_page_slice_add(page, &lsb->lsb_cl, obj, &lovsub_page_ops); - RETURN(0); + return 0; } /** @} lov */ diff --git a/drivers/staging/lustre/lustre/lvfs/fsfilt.c b/drivers/staging/lustre/lustre/lvfs/fsfilt.c index ce71f805c6de8..e86df7356cb1e 100644 --- a/drivers/staging/lustre/lustre/lvfs/fsfilt.c +++ b/drivers/staging/lustre/lustre/lvfs/fsfilt.c @@ -67,7 +67,7 @@ int fsfilt_register_ops(struct fsfilt_operations *fs_ops) CERROR("different operations for type %s\n", fs_ops->fs_type); /* unlock fsfilt_types list */ - RETURN(-EEXIST); + return -EEXIST; } } else { try_module_get(THIS_MODULE); @@ -119,7 +119,7 @@ struct fsfilt_operations *fsfilt_get_ops(const char *type) if (rc) { CERROR("Can't find %s interface\n", name); - RETURN(ERR_PTR(rc < 0 ? rc : -rc)); + return ERR_PTR(rc < 0 ? rc : -rc); /* unlock fsfilt_types list */ } } diff --git a/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c b/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c index 71f62695b926b..18e1b47a1d65a 100644 --- a/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c +++ b/drivers/staging/lustre/lustre/lvfs/lvfs_linux.c @@ -210,7 +210,7 @@ int lustre_rename(struct dentry *dir, struct vfsmount *mnt, dchild_old = ll_lookup_one_len(oldname, dir, strlen(oldname)); if (IS_ERR(dchild_old)) - RETURN(PTR_ERR(dchild_old)); + return PTR_ERR(dchild_old); if (!dchild_old->d_inode) GOTO(put_old, err = -ENOENT); @@ -225,7 +225,7 @@ int lustre_rename(struct dentry *dir, struct vfsmount *mnt, dput(dchild_new); put_old: dput(dchild_old); - RETURN(err); + return err; } EXPORT_SYMBOL(lustre_rename); @@ -250,7 +250,7 @@ __s64 lprocfs_read_helper(struct lprocfs_counter *lc, __s64 ret = 0; if (lc == NULL || header == NULL) - RETURN(0); + return 0; switch (field) { case LPROCFS_FIELDS_FLAGS_CONFIG: @@ -280,7 +280,7 @@ __s64 lprocfs_read_helper(struct lprocfs_counter *lc, break; }; - RETURN(ret); + return ret; } EXPORT_SYMBOL(lprocfs_read_helper); #endif /* LPROCFS */ diff --git a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c index 30a8a1b2428df..e0b8f18662530 100644 --- a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c +++ b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c @@ -95,10 +95,10 @@ static ssize_t mdc_kuc_write(struct file *file, const char *buffer, rc = lprocfs_write_helper(buffer, count, &fd); if (rc) - RETURN(rc); + return rc; if (fd < 0) - RETURN(-ERANGE); + return -ERANGE; CWARN("message to fd %d\n", fd); len = sizeof(*lh) + sizeof(*hal) + MTI_NAME_MAXLEN + @@ -139,8 +139,8 @@ static ssize_t mdc_kuc_write(struct file *file, const char *buffer, } OBD_FREE(lh, len); if (rc < 0) - RETURN(rc); - RETURN(count); + return rc; + return count; } struct file_operations mdc_kuc_fops = { diff --git a/drivers/staging/lustre/lustre/mdc/mdc_lib.c b/drivers/staging/lustre/lustre/mdc/mdc_lib.c index 4ab3b95faf8b4..b2de478036795 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_lib.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_lib.c @@ -509,7 +509,7 @@ static int mdc_req_avail(struct client_obd *cli, struct mdc_cache_waiter *mcw) client_obd_list_lock(&cli->cl_loi_list_lock); rc = list_empty(&mcw->mcw_entry); client_obd_list_unlock(&cli->cl_loi_list_lock); - RETURN(rc); + return rc; }; /* We record requests in flight in cli->cl_r_in_flight here. diff --git a/drivers/staging/lustre/lustre/mdc/mdc_locks.c b/drivers/staging/lustre/lustre/mdc/mdc_locks.c index b818cd987fa92..fb5a9959bf7ac 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_locks.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_locks.c @@ -120,7 +120,7 @@ int mdc_set_lock_data(struct obd_export *exp, __u64 *lockh, void *data, *bits = 0; if (!*lockh) - RETURN(0); + return 0; lock = ldlm_handle2lock((struct lustre_handle *)lockh); @@ -143,7 +143,7 @@ int mdc_set_lock_data(struct obd_export *exp, __u64 *lockh, void *data, unlock_res_and_lock(lock); LDLM_LOCK_PUT(lock); - RETURN(0); + return 0; } ldlm_mode_t mdc_lock_match(struct obd_export *exp, __u64 flags, @@ -157,7 +157,7 @@ ldlm_mode_t mdc_lock_match(struct obd_export *exp, __u64 flags, fid_build_reg_res_name(fid, &res_id); rc = ldlm_lock_match(class_exp2obd(exp)->obd_namespace, flags, &res_id, type, policy, mode, lockh, 0); - RETURN(rc); + return rc; } int mdc_cancel_unused(struct obd_export *exp, @@ -174,7 +174,7 @@ int mdc_cancel_unused(struct obd_export *exp, fid_build_reg_res_name(fid, &res_id); rc = ldlm_cli_cancel_unused_resource(obd->obd_namespace, &res_id, policy, mode, flags, opaque); - RETURN(rc); + return rc; } int mdc_null_inode(struct obd_export *exp, @@ -190,14 +190,14 @@ int mdc_null_inode(struct obd_export *exp, res = ldlm_resource_get(ns, NULL, &res_id, 0, 0); if(res == NULL) - RETURN(0); + return 0; lock_res(res); res->lr_lvb_inode = NULL; unlock_res(res); ldlm_resource_putref(res); - RETURN(0); + return 0; } /* find any ldlm lock of the inode in mdc @@ -215,10 +215,10 @@ int mdc_find_cbdata(struct obd_export *exp, rc = ldlm_resource_iterate(class_exp2obd(exp)->obd_namespace, &res_id, it, data); if (rc == LDLM_ITER_STOP) - RETURN(1); + return 1; else if (rc == LDLM_ITER_CONTINUE) - RETURN(0); - RETURN(rc); + return 0; + return rc; } static inline void mdc_clear_replay_flag(struct ptlrpc_request *req, int rc) @@ -307,7 +307,7 @@ static struct ptlrpc_request *mdc_intent_open_pack(struct obd_export *exp, &RQF_LDLM_INTENT_OPEN); if (req == NULL) { ldlm_lock_list_put(&cancels, l_bl_ast, count); - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); } /* parent capability */ @@ -359,7 +359,7 @@ static struct ptlrpc_request *mdc_intent_unlink_pack(struct obd_export *exp, req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_LDLM_INTENT_UNLINK); if (req == NULL) - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1); req_capsule_set_size(&req->rq_pill, &RMF_NAME, RCL_CLIENT, @@ -368,7 +368,7 @@ static struct ptlrpc_request *mdc_intent_unlink_pack(struct obd_export *exp, rc = ldlm_prep_enqueue_req(exp, req, NULL, 0); if (rc) { ptlrpc_request_free(req); - RETURN(ERR_PTR(rc)); + return ERR_PTR(rc); } /* pack the intent */ @@ -383,7 +383,7 @@ static struct ptlrpc_request *mdc_intent_unlink_pack(struct obd_export *exp, req_capsule_set_size(&req->rq_pill, &RMF_ACL, RCL_SERVER, obddev->u.cli.cl_max_mds_cookiesize); ptlrpc_request_set_replen(req); - RETURN(req); + return req; } static struct ptlrpc_request *mdc_intent_getattr_pack(struct obd_export *exp, @@ -403,7 +403,7 @@ static struct ptlrpc_request *mdc_intent_getattr_pack(struct obd_export *exp, req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_LDLM_INTENT_GETATTR); if (req == NULL) - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1); req_capsule_set_size(&req->rq_pill, &RMF_NAME, RCL_CLIENT, @@ -412,7 +412,7 @@ static struct ptlrpc_request *mdc_intent_getattr_pack(struct obd_export *exp, rc = ldlm_prep_enqueue_req(exp, req, NULL, 0); if (rc) { ptlrpc_request_free(req); - RETURN(ERR_PTR(rc)); + return ERR_PTR(rc); } /* pack the intent */ @@ -429,7 +429,7 @@ static struct ptlrpc_request *mdc_intent_getattr_pack(struct obd_export *exp, req_capsule_set_size(&req->rq_pill, &RMF_ACL, RCL_SERVER, sizeof(struct mdt_remote_perm)); ptlrpc_request_set_replen(req); - RETURN(req); + return req; } static struct ptlrpc_request *mdc_intent_layout_pack(struct obd_export *exp, @@ -445,13 +445,13 @@ static struct ptlrpc_request *mdc_intent_layout_pack(struct obd_export *exp, req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_LDLM_INTENT_LAYOUT); if (req == NULL) - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); req_capsule_set_size(&req->rq_pill, &RMF_EADATA, RCL_CLIENT, 0); rc = ldlm_prep_enqueue_req(exp, req, NULL, 0); if (rc) { ptlrpc_request_free(req); - RETURN(ERR_PTR(rc)); + return ERR_PTR(rc); } /* pack the intent */ @@ -467,7 +467,7 @@ static struct ptlrpc_request *mdc_intent_layout_pack(struct obd_export *exp, req_capsule_set_size(&req->rq_pill, &RMF_DLM_LVB, RCL_SERVER, obd->u.cli.cl_max_mds_easize); ptlrpc_request_set_replen(req); - RETURN(req); + return req; } static struct ptlrpc_request * @@ -478,17 +478,17 @@ mdc_enqueue_pack(struct obd_export *exp, int lvb_len) req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_LDLM_ENQUEUE); if (req == NULL) - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); rc = ldlm_prep_enqueue_req(exp, req, NULL, 0); if (rc) { ptlrpc_request_free(req); - RETURN(ERR_PTR(rc)); + return ERR_PTR(rc); } req_capsule_set_size(&req->rq_pill, &RMF_DLM_LVB, RCL_SERVER, lvb_len); ptlrpc_request_set_replen(req); - RETURN(req); + return req; } static int mdc_finish_enqueue(struct obd_export *exp, @@ -567,7 +567,7 @@ static int mdc_finish_enqueue(struct obd_export *exp, body = req_capsule_server_get(pill, &RMF_MDT_BODY); if (body == NULL) { CERROR ("Can't swab mdt_body\n"); - RETURN (-EPROTO); + return -EPROTO; } if (it_disposition(it, DISP_OPEN_OPEN) && @@ -593,7 +593,7 @@ static int mdc_finish_enqueue(struct obd_export *exp, eadata = req_capsule_server_sized_get(pill, &RMF_MDT_MD, body->eadatasize); if (eadata == NULL) - RETURN(-EPROTO); + return -EPROTO; /* save lvb data and length in case this is for layout * lock */ @@ -637,14 +637,14 @@ static int mdc_finish_enqueue(struct obd_export *exp, perm = req_capsule_server_swab_get(pill, &RMF_ACL, lustre_swab_mdt_remote_perm); if (perm == NULL) - RETURN(-EPROTO); + return -EPROTO; } if (body->valid & OBD_MD_FLMDSCAPA) { struct lustre_capa *capa, *p; capa = req_capsule_server_get(pill, &RMF_CAPA1); if (capa == NULL) - RETURN(-EPROTO); + return -EPROTO; if (it->it_op & IT_OPEN) { /* client fid capa will be checked in replay */ @@ -658,7 +658,7 @@ static int mdc_finish_enqueue(struct obd_export *exp, capa = req_capsule_server_get(pill, &RMF_CAPA2); if (capa == NULL) - RETURN(-EPROTO); + return -EPROTO; } } else if (it->it_op & IT_LAYOUT) { /* maybe the lock was granted right away and layout @@ -668,7 +668,7 @@ static int mdc_finish_enqueue(struct obd_export *exp, lvb_data = req_capsule_server_sized_get(pill, &RMF_DLM_LVB, lvb_len); if (lvb_data == NULL) - RETURN(-EPROTO); + return -EPROTO; } } @@ -683,7 +683,7 @@ static int mdc_finish_enqueue(struct obd_export *exp, OBD_ALLOC_LARGE(lmm, lvb_len); if (lmm == NULL) { LDLM_LOCK_PUT(lock); - RETURN(-ENOMEM); + return -ENOMEM; } memcpy(lmm, lvb_data, lvb_len); @@ -701,7 +701,7 @@ static int mdc_finish_enqueue(struct obd_export *exp, if (lock != NULL) LDLM_LOCK_PUT(lock); - RETURN(rc); + return rc; } /* We always reserve enough space in the reply packet for a stripe MD, because @@ -767,17 +767,17 @@ int mdc_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo, req = mdc_enqueue_pack(exp, 0); } else if (it->it_op & IT_LAYOUT) { if (!imp_connect_lvb_type(class_exp2cliimp(exp))) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; req = mdc_intent_layout_pack(exp, it, op_data); lvb_type = LVB_T_LAYOUT; } else { LBUG(); - RETURN(-EINVAL); + return -EINVAL; } if (IS_ERR(req)) - RETURN(PTR_ERR(req)); + return PTR_ERR(req); if (req != NULL && it && it->it_op & IT_CREAT) /* ask ptlrpc not to resend on EINPROGRESS since we have our own @@ -800,7 +800,7 @@ int mdc_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo, mdc_put_rpc_lock(obddev->u.cli.cl_rpc_lock, it); mdc_clear_replay_flag(req, 0); ptlrpc_req_finished(req); - RETURN(rc); + return rc; } } @@ -817,7 +817,7 @@ int mdc_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo, current FLocks upon exit) that can't be trashed */ if ((rc == -EINTR) || (rc == -ETIMEDOUT)) goto resend; - RETURN(rc); + return rc; } mdc_exit_request(&obddev->u.cli); @@ -827,7 +827,7 @@ int mdc_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo, CERROR("ldlm_cli_enqueue: %d\n", rc); mdc_clear_replay_flag(req, rc); ptlrpc_req_finished(req); - RETURN(rc); + return rc; } lockrep = req_capsule_server_get(&req->rq_pill, &RMF_DLM_REP); @@ -852,7 +852,7 @@ int mdc_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo, goto resend; } else { CDEBUG(D_HA, "resend cross eviction\n"); - RETURN(-EIO); + return -EIO; } } @@ -864,7 +864,7 @@ int mdc_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo, } ptlrpc_req_finished(req); } - RETURN(rc); + return rc; } static int mdc_finish_intent_lock(struct obd_export *exp, @@ -886,11 +886,11 @@ static int mdc_finish_intent_lock(struct obd_export *exp, /* The server failed before it even started executing the * intent, i.e. because it couldn't unpack the request. */ LASSERT(it->d.lustre.it_status != 0); - RETURN(it->d.lustre.it_status); + return it->d.lustre.it_status; } rc = it_open_error(DISP_IT_EXECD, it); if (rc) - RETURN(rc); + return rc; mdt_body = req_capsule_server_get(&request->rq_pill, &RMF_MDT_BODY); LASSERT(mdt_body != NULL); /* mdc_enqueue checked */ @@ -912,13 +912,13 @@ static int mdc_finish_intent_lock(struct obd_export *exp, CDEBUG(D_DENTRY, "Found stale data "DFID"("DFID")/"DFID "\n", PFID(&op_data->op_fid2), PFID(&op_data->op_fid2), PFID(&mdt_body->fid1)); - RETURN(-ESTALE); + return -ESTALE; } } rc = it_open_error(DISP_LOOKUP_EXECD, it); if (rc) - RETURN(rc); + return rc; /* keep requests around for the multiple phases of the call * this shows the DISP_XX must guarantee we make it into the call @@ -979,7 +979,7 @@ static int mdc_finish_intent_lock(struct obd_export *exp, CDEBUG(D_DENTRY,"D_IT dentry %.*s intent: %s status %d disp %x rc %d\n", op_data->op_namelen, op_data->op_name, ldlm_it2str(it->it_op), it->d.lustre.it_status, it->d.lustre.it_disposition, rc); - RETURN(rc); + return rc; } int mdc_revalidate_lock(struct obd_export *exp, struct lookup_intent *it, @@ -1023,7 +1023,7 @@ int mdc_revalidate_lock(struct obd_export *exp, struct lookup_intent *it, it->d.lustre.it_lock_mode = 0; } - RETURN(!!mode); + return !!mode; } /* @@ -1081,7 +1081,7 @@ int mdc_intent_lock(struct obd_export *exp, struct md_op_data *op_data, /* Only return failure if it was not GETATTR by cfid (from inode_revalidate) */ if (rc || op_data->op_namelen != 0) - RETURN(rc); + return rc; } /* lookup_it may be called only after revalidate_it has run, because @@ -1105,13 +1105,13 @@ int mdc_intent_lock(struct obd_export *exp, struct md_op_data *op_data, rc = mdc_fid_alloc(exp, &op_data->op_fid2, op_data); if (rc < 0) { CERROR("Can't alloc new fid, rc %d\n", rc); - RETURN(rc); + return rc; } } rc = mdc_enqueue(exp, &einfo, it, op_data, &lockh, lmm, lmmsize, NULL, extra_lock_flags); if (rc < 0) - RETURN(rc); + return rc; } else if (!fid_is_sane(&op_data->op_fid2) || !(it->it_create_mode & M_CHECK_STALE)) { /* DISP_ENQ_COMPLETE set means there is extra reference on @@ -1122,7 +1122,7 @@ int mdc_intent_lock(struct obd_export *exp, struct md_op_data *op_data, } *reqp = it->d.lustre.it_data; rc = mdc_finish_intent_lock(exp, *reqp, op_data, it, &lockh); - RETURN(rc); + return rc; } static int mdc_intent_getattr_async_interpret(const struct lu_env *env, @@ -1201,12 +1201,12 @@ int mdc_intent_getattr_async(struct obd_export *exp, fid_build_reg_res_name(&op_data->op_fid1, &res_id); req = mdc_intent_getattr_pack(exp, it, op_data); if (!req) - RETURN(-ENOMEM); + return -ENOMEM; rc = mdc_enter_request(&obddev->u.cli); if (rc != 0) { ptlrpc_req_finished(req); - RETURN(rc); + return rc; } rc = ldlm_cli_enqueue(exp, &req, einfo, &res_id, &policy, &flags, NULL, @@ -1214,7 +1214,7 @@ int mdc_intent_getattr_async(struct obd_export *exp, if (rc < 0) { mdc_exit_request(&obddev->u.cli); ptlrpc_req_finished(req); - RETURN(rc); + return rc; } CLASSERT(sizeof(*ga) <= sizeof(req->rq_async_args)); @@ -1226,5 +1226,5 @@ int mdc_intent_getattr_async(struct obd_export *exp, req->rq_interpret_reply = mdc_intent_getattr_async_interpret; ptlrpcd_add_req(req, PDL_POLICY_LOCAL, -1); - RETURN(0); + return 0; } diff --git a/drivers/staging/lustre/lustre/mdc/mdc_reint.c b/drivers/staging/lustre/lustre/mdc/mdc_reint.c index be007a36f7df2..9f3a345f34e04 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_reint.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_reint.c @@ -83,13 +83,13 @@ int mdc_resource_get_unused(struct obd_export *exp, struct lu_fid *fid, * when we still want to cancel locks in advance and just cancel them * locally, without sending any RPC. */ if (exp_connect_cancelset(exp) && !ns_connect_cancelset(ns)) - RETURN(0); + return 0; fid_build_reg_res_name(fid, &res_id); res = ldlm_resource_get(exp->exp_obd->obd_namespace, NULL, &res_id, 0, 0); if (res == NULL) - RETURN(0); + return 0; LDLM_RESOURCE_ADDREF(res); /* Initialize ibits lock policy. */ policy.l_inodebits.bits = bits; @@ -97,7 +97,7 @@ int mdc_resource_get_unused(struct obd_export *exp, struct lu_fid *fid, mode, 0, 0, NULL); LDLM_RESOURCE_DELREF(res); ldlm_resource_putref(res); - RETURN(count); + return count; } int mdc_setattr(struct obd_export *exp, struct md_op_data *op_data, @@ -125,7 +125,7 @@ int mdc_setattr(struct obd_export *exp, struct md_op_data *op_data, &RQF_MDS_REINT_SETATTR); if (req == NULL) { ldlm_lock_list_put(&cancels, l_bl_ast, count); - RETURN(-ENOMEM); + return -ENOMEM; } mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1); if ((op_data->op_flags & (MF_SOM_CHANGE | MF_EPOCH_OPEN)) == 0) @@ -138,7 +138,7 @@ int mdc_setattr(struct obd_export *exp, struct md_op_data *op_data, rc = mdc_prep_elc_req(exp, req, MDS_REINT, &cancels, count); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } rpc_lock = obd->u.cli.cl_rpc_lock; @@ -201,7 +201,7 @@ int mdc_setattr(struct obd_export *exp, struct md_op_data *op_data, obd_mod_put(*mod); req->rq_commit_cb(req); } - RETURN(rc); + return rc; } int mdc_create(struct obd_export *exp, struct md_op_data *op_data, @@ -225,7 +225,7 @@ int mdc_create(struct obd_export *exp, struct md_op_data *op_data, rc = mdc_fid_alloc(exp, &op_data->op_fid2, op_data); if (rc < 0) { CERROR("Can't alloc new fid, rc %d\n", rc); - RETURN(rc); + return rc; } } @@ -241,7 +241,7 @@ int mdc_create(struct obd_export *exp, struct md_op_data *op_data, &RQF_MDS_REINT_CREATE_RMT_ACL); if (req == NULL) { ldlm_lock_list_put(&cancels, l_bl_ast, count); - RETURN(-ENOMEM); + return -ENOMEM; } mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1); req_capsule_set_size(&req->rq_pill, &RMF_NAME, RCL_CLIENT, @@ -252,7 +252,7 @@ int mdc_create(struct obd_export *exp, struct md_op_data *op_data, rc = mdc_prep_elc_req(exp, req, MDS_REINT, &cancels, count); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } /* @@ -295,7 +295,7 @@ int mdc_create(struct obd_export *exp, struct md_op_data *op_data, goto rebuild; } else { CDEBUG(D_HA, "resend cross eviction\n"); - RETURN(-EIO); + return -EIO; } } else if (rc == 0) { struct mdt_body *body; @@ -312,7 +312,7 @@ int mdc_create(struct obd_export *exp, struct md_op_data *op_data, } *request = req; - RETURN(rc); + return rc; } int mdc_unlink(struct obd_export *exp, struct md_op_data *op_data, @@ -341,7 +341,7 @@ int mdc_unlink(struct obd_export *exp, struct md_op_data *op_data, &RQF_MDS_REINT_UNLINK); if (req == NULL) { ldlm_lock_list_put(&cancels, l_bl_ast, count); - RETURN(-ENOMEM); + return -ENOMEM; } mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1); req_capsule_set_size(&req->rq_pill, &RMF_NAME, RCL_CLIENT, @@ -350,7 +350,7 @@ int mdc_unlink(struct obd_export *exp, struct md_op_data *op_data, rc = mdc_prep_elc_req(exp, req, MDS_REINT, &cancels, count); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } mdc_unlink_pack(req, op_data); @@ -366,7 +366,7 @@ int mdc_unlink(struct obd_export *exp, struct md_op_data *op_data, rc = mdc_reint(req, obd->u.cli.cl_rpc_lock, LUSTRE_IMP_FULL); if (rc == -ERESTARTSYS) rc = 0; - RETURN(rc); + return rc; } int mdc_link(struct obd_export *exp, struct md_op_data *op_data, @@ -391,7 +391,7 @@ int mdc_link(struct obd_export *exp, struct md_op_data *op_data, req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_REINT_LINK); if (req == NULL) { ldlm_lock_list_put(&cancels, l_bl_ast, count); - RETURN(-ENOMEM); + return -ENOMEM; } mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1); mdc_set_capa_size(req, &RMF_CAPA2, op_data->op_capa2); @@ -401,7 +401,7 @@ int mdc_link(struct obd_export *exp, struct md_op_data *op_data, rc = mdc_prep_elc_req(exp, req, MDS_REINT, &cancels, count); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } mdc_link_pack(req, op_data); @@ -412,7 +412,7 @@ int mdc_link(struct obd_export *exp, struct md_op_data *op_data, if (rc == -ERESTARTSYS) rc = 0; - RETURN(rc); + return rc; } int mdc_rename(struct obd_export *exp, struct md_op_data *op_data, @@ -449,7 +449,7 @@ int mdc_rename(struct obd_export *exp, struct md_op_data *op_data, &RQF_MDS_REINT_RENAME); if (req == NULL) { ldlm_lock_list_put(&cancels, l_bl_ast, count); - RETURN(-ENOMEM); + return -ENOMEM; } mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1); @@ -460,7 +460,7 @@ int mdc_rename(struct obd_export *exp, struct md_op_data *op_data, rc = mdc_prep_elc_req(exp, req, MDS_REINT, &cancels, count); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } if (exp_connect_cancelset(exp) && req) @@ -479,5 +479,5 @@ int mdc_rename(struct obd_export *exp, struct md_op_data *op_data, if (rc == -ERESTARTSYS) rc = 0; - RETURN(rc); + return rc; } diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index 7da6eb8e8da5c..ed3a7a05557f3 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -69,16 +69,16 @@ int mdc_unpack_capa(struct obd_export *exp, struct ptlrpc_request *req, /* swabbed already in mdc_enqueue */ capa = req_capsule_server_get(&req->rq_pill, field); if (capa == NULL) - RETURN(-EPROTO); + return -EPROTO; c = alloc_capa(CAPA_SITE_CLIENT); if (IS_ERR(c)) { CDEBUG(D_INFO, "alloc capa failed!\n"); - RETURN(PTR_ERR(c)); + return PTR_ERR(c); } else { c->c_capa = *capa; *oc = c; - RETURN(0); + return 0; } } @@ -112,7 +112,7 @@ static int send_getstatus(struct obd_import *imp, struct lu_fid *rootfid, req = ptlrpc_request_alloc_pack(imp, &RQF_MDS_GETSTATUS, LUSTRE_MDS_VERSION, MDS_GETSTATUS); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; mdc_pack_body(req, NULL, NULL, 0, 0, -1, 0); lustre_msg_add_flags(req->rq_reqmsg, msg_flags); @@ -173,12 +173,12 @@ static int mdc_getattr_common(struct obd_export *exp, /* Request message already built. */ rc = ptlrpc_queue_wait(req); if (rc != 0) - RETURN(rc); + return rc; /* sanity check for the reply */ body = req_capsule_server_get(pill, &RMF_MDT_BODY); if (body == NULL) - RETURN(-EPROTO); + return -EPROTO; CDEBUG(D_NET, "mode: %o\n", body->mode); @@ -188,7 +188,7 @@ static int mdc_getattr_common(struct obd_export *exp, eadata = req_capsule_server_sized_get(pill, &RMF_MDT_MD, body->eadatasize); if (eadata == NULL) - RETURN(-EPROTO); + return -EPROTO; } if (body->valid & OBD_MD_FLRMTPERM) { @@ -198,17 +198,17 @@ static int mdc_getattr_common(struct obd_export *exp, perm = req_capsule_server_swab_get(pill, &RMF_ACL, lustre_swab_mdt_remote_perm); if (perm == NULL) - RETURN(-EPROTO); + return -EPROTO; } if (body->valid & OBD_MD_FLMDSCAPA) { struct lustre_capa *capa; capa = req_capsule_server_get(pill, &RMF_CAPA1); if (capa == NULL) - RETURN(-EPROTO); + return -EPROTO; } - RETURN(0); + return 0; } int mdc_getattr(struct obd_export *exp, struct md_op_data *op_data, @@ -220,19 +220,19 @@ int mdc_getattr(struct obd_export *exp, struct md_op_data *op_data, /* Single MDS without an LMV case */ if (op_data->op_flags & MF_GET_MDT_IDX) { op_data->op_mds = 0; - RETURN(0); + return 0; } *request = NULL; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_GETATTR); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1); rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_GETATTR); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } mdc_pack_body(req, &op_data->op_fid1, op_data->op_capa1, @@ -252,7 +252,7 @@ int mdc_getattr(struct obd_export *exp, struct md_op_data *op_data, ptlrpc_req_finished(req); else *request = req; - RETURN(rc); + return rc; } int mdc_getattr_name(struct obd_export *exp, struct md_op_data *op_data, @@ -265,7 +265,7 @@ int mdc_getattr_name(struct obd_export *exp, struct md_op_data *op_data, req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_GETATTR_NAME); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1); req_capsule_set_size(&req->rq_pill, &RMF_NAME, RCL_CLIENT, @@ -274,7 +274,7 @@ int mdc_getattr_name(struct obd_export *exp, struct md_op_data *op_data, rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_GETATTR_NAME); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } mdc_pack_body(req, &op_data->op_fid1, op_data->op_capa1, @@ -297,7 +297,7 @@ int mdc_getattr_name(struct obd_export *exp, struct md_op_data *op_data, ptlrpc_req_finished(req); else *request = req; - RETURN(rc); + return rc; } static int mdc_is_subdir(struct obd_export *exp, @@ -313,7 +313,7 @@ static int mdc_is_subdir(struct obd_export *exp, &RQF_MDS_IS_SUBDIR, LUSTRE_MDS_VERSION, MDS_IS_SUBDIR); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; mdc_is_subdir_pack(req, pfid, cfid, 0); ptlrpc_request_set_replen(req); @@ -323,7 +323,7 @@ static int mdc_is_subdir(struct obd_export *exp, ptlrpc_req_finished(req); else *request = req; - RETURN(rc); + return rc; } static int mdc_xattr_common(struct obd_export *exp,const struct req_format *fmt, @@ -341,7 +341,7 @@ static int mdc_xattr_common(struct obd_export *exp,const struct req_format *fmt, *request = NULL; req = ptlrpc_request_alloc(class_exp2cliimp(exp), fmt); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; mdc_set_capa_size(req, &RMF_CAPA1, oc); if (xattr_name) { @@ -358,7 +358,7 @@ static int mdc_xattr_common(struct obd_export *exp,const struct req_format *fmt, rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, opcode); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } if (opcode == MDS_REINT) { @@ -411,7 +411,7 @@ static int mdc_xattr_common(struct obd_export *exp,const struct req_format *fmt, ptlrpc_req_finished(req); else *request = req; - RETURN(rc); + return rc; } int mdc_setxattr(struct obd_export *exp, const struct lu_fid *fid, @@ -446,29 +446,29 @@ static int mdc_unpack_acl(struct ptlrpc_request *req, struct lustre_md *md) int rc; if (!body->aclsize) - RETURN(0); + return 0; buf = req_capsule_server_sized_get(pill, &RMF_ACL, body->aclsize); if (!buf) - RETURN(-EPROTO); + return -EPROTO; acl = posix_acl_from_xattr(&init_user_ns, buf, body->aclsize); if (IS_ERR(acl)) { rc = PTR_ERR(acl); CERROR("convert xattr to acl: %d\n", rc); - RETURN(rc); + return rc; } rc = posix_acl_valid(acl); if (rc) { CERROR("validate acl: %d\n", rc); posix_acl_release(acl); - RETURN(rc); + return rc; } md->posix_acl = acl; - RETURN(0); + return 0; } #else #define mdc_unpack_acl(req, md) 0 @@ -531,7 +531,7 @@ int mdc_get_lustre_md(struct obd_export *exp, struct ptlrpc_request *req, if (md->body->eadatasize == 0) { CDEBUG(D_INFO, "OBD_MD_FLDIREA is set, " "but eadatasize 0\n"); - RETURN(-EPROTO); + return -EPROTO; } if (md->body->valid & OBD_MD_MEA) { lmvsize = md->body->eadatasize; @@ -617,7 +617,7 @@ int mdc_get_lustre_md(struct obd_export *exp, struct ptlrpc_request *req, int mdc_free_lustre_md(struct obd_export *exp, struct lustre_md *md) { - RETURN(0); + return 0; } /** @@ -708,7 +708,7 @@ int mdc_set_open_replay_data(struct obd_export *exp, struct obd_import *imp = open_req->rq_import; if (!open_req->rq_replay) - RETURN(0); + return 0; rec = req_capsule_client_get(&open_req->rq_pill, &RMF_REC_REINT); body = req_capsule_server_get(&open_req->rq_pill, &RMF_MDT_BODY); @@ -723,7 +723,7 @@ int mdc_set_open_replay_data(struct obd_export *exp, if (mod == NULL) { DEBUG_REQ(D_ERROR, open_req, "Can't allocate md_open_data"); - RETURN(0); + return 0; } /** @@ -755,7 +755,7 @@ int mdc_set_open_replay_data(struct obd_export *exp, } DEBUG_REQ(D_RPCTRACE, open_req, "Set up open replay data"); - RETURN(0); + return 0; } int mdc_clear_open_replay_data(struct obd_export *exp, @@ -768,7 +768,7 @@ int mdc_clear_open_replay_data(struct obd_export *exp, * lookup and ll_file_open(). **/ if (mod == NULL) - RETURN(0); + return 0; LASSERT(mod != LP_POISON); @@ -776,7 +776,7 @@ int mdc_clear_open_replay_data(struct obd_export *exp, och->och_mod = NULL; obd_mod_put(mod); - RETURN(0); + return 0; } /* Prepares the request for the replay by the given reply */ @@ -805,14 +805,14 @@ int mdc_close(struct obd_export *exp, struct md_op_data *op_data, *request = NULL; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_CLOSE); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1); rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_CLOSE); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } /* To avoid a livelock (bug 7034), we need to send CLOSE RPCs to a @@ -893,7 +893,7 @@ int mdc_close(struct obd_export *exp, struct md_op_data *op_data, } *request = req; mdc_close_handle_reply(req, op_data, rc); - RETURN(rc); + return rc; } int mdc_done_writing(struct obd_export *exp, struct md_op_data *op_data, @@ -906,13 +906,13 @@ int mdc_done_writing(struct obd_export *exp, struct md_op_data *op_data, req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_DONE_WRITING); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1); rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_DONE_WRITING); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } if (mod != NULL) { @@ -959,7 +959,7 @@ int mdc_done_writing(struct obd_export *exp, struct md_op_data *op_data, mdc_close_handle_reply(req, op_data, rc); ptlrpc_req_finished(req); - RETURN(rc); + return rc; } @@ -980,14 +980,14 @@ int mdc_readpage(struct obd_export *exp, struct md_op_data *op_data, restart_bulk: req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_READPAGE); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1); rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_READPAGE); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } req->rq_request_portal = MDS_READPAGE_PORTAL; @@ -997,7 +997,7 @@ int mdc_readpage(struct obd_export *exp, struct md_op_data *op_data, MDS_BULK_PORTAL); if (desc == NULL) { ptlrpc_request_free(req); - RETURN(-ENOMEM); + return -ENOMEM; } /* NB req now owns desc and will free it when it gets freed */ @@ -1013,12 +1013,12 @@ int mdc_readpage(struct obd_export *exp, struct md_op_data *op_data, if (rc) { ptlrpc_req_finished(req); if (rc != -ETIMEDOUT) - RETURN(rc); + return rc; resends++; if (!client_should_resend(resends, &exp->exp_obd->u.cli)) { CERROR("too many resend retries, returning error\n"); - RETURN(-EIO); + return -EIO; } lwi = LWI_TIMEOUT_INTR(cfs_time_seconds(resends), NULL, NULL, NULL); l_wait_event(waitq, 0, &lwi); @@ -1030,7 +1030,7 @@ int mdc_readpage(struct obd_export *exp, struct md_op_data *op_data, req->rq_bulk->bd_nob_transferred); if (rc < 0) { ptlrpc_req_finished(req); - RETURN(rc); + return rc; } if (req->rq_bulk->bd_nob_transferred & ~LU_PAGE_MASK) { @@ -1038,11 +1038,11 @@ int mdc_readpage(struct obd_export *exp, struct md_op_data *op_data, req->rq_bulk->bd_nob_transferred, PAGE_CACHE_SIZE * op_data->op_npages); ptlrpc_req_finished(req); - RETURN(-EPROTO); + return -EPROTO; } *request = req; - RETURN(0); + return 0; } static int mdc_statfs(const struct lu_env *env, @@ -1064,7 +1064,7 @@ static int mdc_statfs(const struct lu_env *env, imp = class_import_get(obd->u.cli.cl_import); up_read(&obd->u.cli.cl_sem); if (!imp) - RETURN(-ENODEV); + return -ENODEV; req = ptlrpc_request_alloc_pack(imp, &RQF_MDS_STATFS, LUSTRE_MDS_VERSION, MDS_STATFS); @@ -1106,15 +1106,15 @@ static int mdc_ioc_fid2path(struct obd_export *exp, struct getinfo_fid2path *gf) int rc; if (gf->gf_pathlen > PATH_MAX) - RETURN(-ENAMETOOLONG); + return -ENAMETOOLONG; if (gf->gf_pathlen < 2) - RETURN(-EOVERFLOW); + return -EOVERFLOW; /* Key is KEY_FID2PATH + getinfo_fid2path description */ keylen = cfs_size_round(sizeof(KEY_FID2PATH)) + sizeof(*gf); OBD_ALLOC(key, keylen); if (key == NULL) - RETURN(-ENOMEM); + return -ENOMEM; memcpy(key, KEY_FID2PATH, sizeof(KEY_FID2PATH)); memcpy(key + cfs_size_round(sizeof(KEY_FID2PATH)), gf, sizeof(*gf)); @@ -1218,14 +1218,14 @@ static int mdc_ioc_hsm_current_action(struct obd_export *exp, req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_HSM_ACTION); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1); rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_HSM_ACTION); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } mdc_pack_body(req, &op_data->op_fid1, op_data->op_capa1, @@ -1282,14 +1282,14 @@ static int mdc_ioc_hsm_state_get(struct obd_export *exp, req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_HSM_STATE_GET); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1); rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_HSM_STATE_GET); if (rc != 0) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } mdc_pack_body(req, &op_data->op_fid1, op_data->op_capa1, @@ -1323,14 +1323,14 @@ static int mdc_ioc_hsm_state_set(struct obd_export *exp, req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_HSM_STATE_SET); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1); rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_HSM_STATE_SET); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } mdc_pack_body(req, &op_data->op_fid1, op_data->op_capa1, @@ -1375,7 +1375,7 @@ static int mdc_ioc_hsm_request(struct obd_export *exp, rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_HSM_REQUEST); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } mdc_pack_body(req, NULL, NULL, OBD_MD_FLRMTPERM, 0, 0, 0); @@ -1446,14 +1446,14 @@ static int changelog_kkuc_cb(const struct lu_env *env, struct llog_handle *llh, CERROR("%s: not a changelog rec %x/%d: rc = %d\n", cs->cs_obd->obd_name, rec->cr_hdr.lrh_type, rec->cr.cr_type, rc); - RETURN(rc); + return rc; } if (rec->cr.cr_index < cs->cs_startrec) { /* Skip entries earlier than what we are interested in */ CDEBUG(D_CHANGELOG, "rec="LPU64" start="LPU64"\n", rec->cr.cr_index, cs->cs_startrec); - RETURN(0); + return 0; } CDEBUG(D_CHANGELOG, LPU64" %02d%-5s "LPU64" 0x%x t="DFID" p="DFID @@ -1472,7 +1472,7 @@ static int changelog_kkuc_cb(const struct lu_env *env, struct llog_handle *llh, rc = libcfs_kkuc_msg_put(cs->cs_fp, lh); CDEBUG(D_CHANGELOG, "kucmsg fp %p len %d rc %d\n", cs->cs_fp, len,rc); - RETURN(rc); + return rc; } static int mdc_changelog_send_thread(void *csdata) @@ -1576,7 +1576,7 @@ static int mdc_quotacheck(struct obd_device *unused, struct obd_export *exp, &RQF_MDS_QUOTACHECK, LUSTRE_MDS_VERSION, MDS_QUOTACHECK); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; body = req_capsule_client_get(&req->rq_pill, &RMF_OBD_QUOTACTL); *body = *oqctl; @@ -1590,7 +1590,7 @@ static int mdc_quotacheck(struct obd_device *unused, struct obd_export *exp, if (rc) cli->cl_qchk_stat = rc; ptlrpc_req_finished(req); - RETURN(rc); + return rc; } static int mdc_quota_poll_check(struct obd_export *exp, @@ -1606,7 +1606,7 @@ static int mdc_quota_poll_check(struct obd_export *exp, /* the client is not the previous one */ if (rc == CL_NOT_QUOTACHECKED) rc = -EINTR; - RETURN(rc); + return rc; } static int mdc_quotactl(struct obd_device *unused, struct obd_export *exp, @@ -1620,7 +1620,7 @@ static int mdc_quotactl(struct obd_device *unused, struct obd_export *exp, &RQF_MDS_QUOTACTL, LUSTRE_MDS_VERSION, MDS_QUOTACTL); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; oqc = req_capsule_client_get(&req->rq_pill, &RMF_OBD_QUOTACTL); *oqc = *oqctl; @@ -1642,7 +1642,7 @@ static int mdc_quotactl(struct obd_device *unused, struct obd_export *exp, } ptlrpc_req_finished(req); - RETURN(rc); + return rc; } static int mdc_ioc_swap_layouts(struct obd_export *exp, @@ -1670,7 +1670,7 @@ static int mdc_ioc_swap_layouts(struct obd_export *exp, &RQF_MDS_SWAP_LAYOUTS); if (req == NULL) { ldlm_lock_list_put(&cancels, l_bl_ast, count); - RETURN(-ENOMEM); + return -ENOMEM; } mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1); @@ -1679,7 +1679,7 @@ static int mdc_ioc_swap_layouts(struct obd_export *exp, rc = mdc_prep_elc_req(exp, req, MDS_SWAP_LAYOUTS, &cancels, count); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } mdc_swap_layouts_pack(req, op_data); @@ -1815,7 +1815,7 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, OBD_ALLOC_PTR(oqctl); if (!oqctl) - RETURN(-ENOMEM); + return -ENOMEM; QCTL_COPY(oqctl, qctl); rc = obd_quotactl(exp, oqctl); @@ -1860,7 +1860,7 @@ int mdc_get_info_rpc(struct obd_export *exp, req = ptlrpc_request_alloc(imp, &RQF_MDS_GET_INFO); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; req_capsule_set_size(&req->rq_pill, &RMF_GETINFO_KEY, RCL_CLIENT, keylen); @@ -1870,7 +1870,7 @@ int mdc_get_info_rpc(struct obd_export *exp, rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_GET_INFO); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } tmp = req_capsule_client_get(&req->rq_pill, &RMF_GETINFO_KEY); @@ -1895,7 +1895,7 @@ int mdc_get_info_rpc(struct obd_export *exp, } ptlrpc_req_finished(req); - RETURN(rc); + return rc; } static void lustre_swab_hai(struct hsm_action_item *h) @@ -1973,14 +1973,14 @@ static int mdc_hsm_copytool_send(int len, void *val) if (len < sizeof(*lh) + sizeof(*hal)) { CERROR("Short HSM message %d < %d\n", len, (int) (sizeof(*lh) + sizeof(*hal))); - RETURN(-EPROTO); + return -EPROTO; } if (lh->kuc_magic == __swab16(KUC_MAGIC)) { lustre_swab_kuch(lh); lustre_swab_hal(hal); } else if (lh->kuc_magic != KUC_MAGIC) { CERROR("Bad magic %x!=%x\n", lh->kuc_magic, KUC_MAGIC); - RETURN(-EPROTO); + return -EPROTO; } CDEBUG(D_HSM, " Received message mg=%x t=%d m=%d l=%d actions=%d " @@ -1991,7 +1991,7 @@ static int mdc_hsm_copytool_send(int len, void *val) /* Broadcast to HSM listeners */ rc = libcfs_kkuc_group_put(KUC_GRP_HSM, lh); - RETURN(rc); + return rc; } /** @@ -2036,7 +2036,7 @@ int mdc_set_info_async(const struct lu_env *env, if (KEY_IS(KEY_READ_ONLY)) { if (vallen != sizeof(int)) - RETURN(-EINVAL); + return -EINVAL; spin_lock(&imp->imp_lock); if (*((int *)val)) { @@ -2052,15 +2052,15 @@ int mdc_set_info_async(const struct lu_env *env, rc = do_set_info_async(imp, MDS_SET_INFO, LUSTRE_MDS_VERSION, keylen, key, vallen, val, set); - RETURN(rc); + return rc; } if (KEY_IS(KEY_SPTLRPC_CONF)) { sptlrpc_conf_client_adapt(exp->exp_obd); - RETURN(0); + return 0; } if (KEY_IS(KEY_FLUSH_CTX)) { sptlrpc_import_flush_my_ctx(imp); - RETURN(0); + return 0; } if (KEY_IS(KEY_MDS_CONN)) { /* mds-mds import */ @@ -2069,20 +2069,20 @@ int mdc_set_info_async(const struct lu_env *env, spin_unlock(&imp->imp_lock); imp->imp_client->cli_request_portal = MDS_MDS_PORTAL; CDEBUG(D_OTHER, "%s: timeout / 2\n", exp->exp_obd->obd_name); - RETURN(0); + return 0; } if (KEY_IS(KEY_CHANGELOG_CLEAR)) { rc = do_set_info_async(imp, MDS_SET_INFO, LUSTRE_MDS_VERSION, keylen, key, vallen, val, set); - RETURN(rc); + return rc; } if (KEY_IS(KEY_HSM_COPYTOOL_SEND)) { rc = mdc_hsm_copytool_send(vallen, val); - RETURN(rc); + return rc; } CERROR("Unknown key %s\n", (char *)key); - RETURN(-EINVAL); + return -EINVAL; } int mdc_get_info(const struct lu_env *env, struct obd_export *exp, @@ -2095,30 +2095,30 @@ int mdc_get_info(const struct lu_env *env, struct obd_export *exp, int mdsize, *max_easize; if (*vallen != sizeof(int)) - RETURN(-EINVAL); + return -EINVAL; mdsize = *(int*)val; if (mdsize > exp->exp_obd->u.cli.cl_max_mds_easize) exp->exp_obd->u.cli.cl_max_mds_easize = mdsize; max_easize = val; *max_easize = exp->exp_obd->u.cli.cl_max_mds_easize; - RETURN(0); + return 0; } else if (KEY_IS(KEY_CONN_DATA)) { struct obd_import *imp = class_exp2cliimp(exp); struct obd_connect_data *data = val; if (*vallen != sizeof(*data)) - RETURN(-EINVAL); + return -EINVAL; *data = imp->imp_connect_data; - RETURN(0); + return 0; } else if (KEY_IS(KEY_TGT_COUNT)) { *((int *)val) = 1; - RETURN(0); + return 0; } rc = mdc_get_info_rpc(exp, keylen, key, *vallen, val); - RETURN(rc); + return rc; } static int mdc_pin(struct obd_export *exp, const struct lu_fid *fid, @@ -2131,14 +2131,14 @@ static int mdc_pin(struct obd_export *exp, const struct lu_fid *fid, req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_PIN); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; mdc_set_capa_size(req, &RMF_CAPA1, oc); rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_PIN); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } mdc_pack_body(req, fid, oc, 0, 0, -1, flags); @@ -2167,11 +2167,11 @@ static int mdc_pin(struct obd_export *exp, const struct lu_fid *fid, } handle->och_mod->mod_open_req = req; /* will be dropped by unpin */ - RETURN(0); + return 0; err_out: ptlrpc_req_finished(req); - RETURN(rc); + return rc; } static int mdc_unpin(struct obd_export *exp, struct obd_client_handle *handle, @@ -2184,7 +2184,7 @@ static int mdc_unpin(struct obd_export *exp, struct obd_client_handle *handle, req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_MDS_UNPIN, LUSTRE_MDS_VERSION, MDS_UNPIN); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; body = req_capsule_client_get(&req->rq_pill, &RMF_MDT_BODY); body->handle = handle->och_fh; @@ -2203,7 +2203,7 @@ static int mdc_unpin(struct obd_export *exp, struct obd_client_handle *handle, ptlrpc_req_finished(handle->och_mod->mod_open_req); obd_mod_put(handle->och_mod); - RETURN(rc); + return rc; } int mdc_sync(struct obd_export *exp, const struct lu_fid *fid, @@ -2215,14 +2215,14 @@ int mdc_sync(struct obd_export *exp, const struct lu_fid *fid, *request = NULL; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_SYNC); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; mdc_set_capa_size(req, &RMF_CAPA1, oc); rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_SYNC); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } mdc_pack_body(req, fid, oc, 0, 0, -1, 0); @@ -2234,7 +2234,7 @@ int mdc_sync(struct obd_export *exp, const struct lu_fid *fid, ptlrpc_req_finished(req); else *request = req; - RETURN(rc); + return rc; } static int mdc_import_event(struct obd_device *obd, struct obd_import *imp, @@ -2287,7 +2287,7 @@ static int mdc_import_event(struct obd_device *obd, struct obd_import *imp, CERROR("Unknown import event %x\n", event); LBUG(); } - RETURN(rc); + return rc; } int mdc_fid_alloc(struct obd_export *exp, struct lu_fid *fid, @@ -2296,7 +2296,7 @@ int mdc_fid_alloc(struct obd_export *exp, struct lu_fid *fid, struct client_obd *cli = &exp->exp_obd->u.cli; struct lu_client_seq *seq = cli->cl_seq; - RETURN(seq_client_alloc_fid(NULL, seq, fid)); + return seq_client_alloc_fid(NULL, seq, fid); } struct obd_uuid *mdc_get_uuid(struct obd_export *exp) { @@ -2312,15 +2312,15 @@ struct obd_uuid *mdc_get_uuid(struct obd_export *exp) { static int mdc_cancel_for_recovery(struct ldlm_lock *lock) { if (lock->l_resource->lr_type != LDLM_IBITS) - RETURN(0); + return 0; /* FIXME: if we ever get into a situation where there are too many * opened files with open locks on a single node, then we really * should replay these open locks to reget it */ if (lock->l_policy_data.l_inodebits.bits & MDS_INODELOCK_OPEN) - RETURN(0); + return 0; - RETURN(1); + return 1; } static int mdc_resource_inode_free(struct ldlm_resource *res) @@ -2343,7 +2343,7 @@ static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg) OBD_ALLOC(cli->cl_rpc_lock, sizeof (*cli->cl_rpc_lock)); if (!cli->cl_rpc_lock) - RETURN(-ENOMEM); + return -ENOMEM; mdc_init_rpc_lock(cli->cl_rpc_lock); ptlrpcd_addref(); @@ -2371,14 +2371,14 @@ static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg) CERROR("failed to setup llogging subsystems\n"); } - RETURN(rc); + return rc; err_close_lock: OBD_FREE(cli->cl_close_lock, sizeof (*cli->cl_close_lock)); err_rpc_lock: OBD_FREE(cli->cl_rpc_lock, sizeof (*cli->cl_rpc_lock)); ptlrpcd_decref(); - RETURN(rc); + return rc; } /* Initialize the default and maximum LOV EA and cookie sizes. This allows @@ -2400,7 +2400,7 @@ static int mdc_init_ea_size(struct obd_export *exp, int easize, if (cli->cl_max_mds_cookiesize < cookiesize) cli->cl_max_mds_cookiesize = cookiesize; - RETURN(0); + return 0; } static int mdc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) @@ -2424,7 +2424,7 @@ static int mdc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) CERROR("failed to cleanup llogging subsystems\n"); break; } - RETURN(rc); + return rc; } static int mdc_cleanup(struct obd_device *obd) @@ -2451,13 +2451,13 @@ static int mdc_llog_init(struct obd_device *obd, struct obd_llog_group *olg, rc = llog_setup(NULL, obd, olg, LLOG_CHANGELOG_REPL_CTXT, tgt, &llog_client_ops); if (rc) - RETURN(rc); + return rc; ctxt = llog_group_get_ctxt(olg, LLOG_CHANGELOG_REPL_CTXT); llog_initiator_connect(ctxt); llog_ctxt_put(ctxt); - RETURN(0); + return 0; } static int mdc_llog_finish(struct obd_device *obd, int count) @@ -2468,7 +2468,7 @@ static int mdc_llog_finish(struct obd_device *obd, int count) if (ctxt) llog_cleanup(NULL, ctxt); - RETURN(0); + return 0; } static int mdc_process_config(struct obd_device *obd, obd_count len, void *buf) @@ -2503,14 +2503,14 @@ int mdc_get_remote_perm(struct obd_export *exp, const struct lu_fid *fid, *request = NULL; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_GETATTR); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; mdc_set_capa_size(req, &RMF_CAPA1, oc); rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_GETATTR); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } mdc_pack_body(req, fid, oc, OBD_MD_FLRMTPERM, 0, suppgid, 0); @@ -2525,7 +2525,7 @@ int mdc_get_remote_perm(struct obd_export *exp, const struct lu_fid *fid, ptlrpc_req_finished(req); else *request = req; - RETURN(rc); + return rc; } static int mdc_interpret_renew_capa(const struct lu_env *env, @@ -2563,7 +2563,7 @@ static int mdc_renew_capa(struct obd_export *exp, struct obd_capa *oc, req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_MDS_GETATTR, LUSTRE_MDS_VERSION, MDS_GETATTR); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; /* NB, OBD_MD_FLOSSCAPA is set here, but it doesn't necessarily mean the * capa to renew is oss capa. @@ -2577,7 +2577,7 @@ static int mdc_renew_capa(struct obd_export *exp, struct obd_capa *oc, ra->ra_cb = cb; req->rq_interpret_reply = mdc_interpret_renew_capa; ptlrpcd_add_req(req, PDL_POLICY_LOCAL, -1); - RETURN(0); + return 0; } static int mdc_connect(const struct lu_env *env, @@ -2671,7 +2671,7 @@ int __init mdc_init(void) rc = class_register_type(&mdc_obd_ops, &mdc_md_ops, lvars.module_vars, LUSTRE_MDC_NAME, NULL); - RETURN(rc); + return rc; } static void /*__exit*/ mdc_exit(void) diff --git a/drivers/staging/lustre/lustre/mgc/libmgc.c b/drivers/staging/lustre/lustre/mgc/libmgc.c index 412f5882225dd..7b4947cec3a82 100644 --- a/drivers/staging/lustre/lustre/mgc/libmgc.c +++ b/drivers/staging/lustre/lustre/mgc/libmgc.c @@ -72,13 +72,13 @@ static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) GOTO(err_cleanup, rc); } - RETURN(rc); + return rc; err_cleanup: client_obd_cleanup(obd); err_decref: ptlrpcd_decref(); - RETURN(rc); + return rc; } static int mgc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) @@ -94,7 +94,7 @@ static int mgc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) CERROR("failed to cleanup llogging subsystems\n"); break; } - RETURN(rc); + return rc; } static int mgc_cleanup(struct obd_device *obd) @@ -107,7 +107,7 @@ static int mgc_cleanup(struct obd_device *obd) ptlrpcd_decref(); rc = client_obd_cleanup(obd); - RETURN(rc); + return rc; } static int mgc_llog_init(struct obd_device *obd, struct obd_llog_group *olg, @@ -120,13 +120,13 @@ static int mgc_llog_init(struct obd_device *obd, struct obd_llog_group *olg, rc = llog_setup(NULL, obd, olg, LLOG_CONFIG_REPL_CTXT, tgt, &llog_client_ops); if (rc < 0) - RETURN(rc); + return rc; ctxt = llog_group_get_ctxt(olg, LLOG_CONFIG_REPL_CTXT); llog_initiator_connect(ctxt); llog_ctxt_put(ctxt); - RETURN(rc); + return rc; } static int mgc_llog_finish(struct obd_device *obd, int count) @@ -138,7 +138,7 @@ static int mgc_llog_finish(struct obd_device *obd, int count) if (ctxt) llog_cleanup(NULL, ctxt); - RETURN(0); + return 0; } struct obd_ops mgc_obd_ops = { diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c index 99a4099e2e0f8..12a9ede21a856 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c @@ -121,7 +121,7 @@ static int config_log_get(struct config_llog_data *cld) atomic_inc(&cld->cld_refcount); CDEBUG(D_INFO, "log %s refs %d\n", cld->cld_logname, atomic_read(&cld->cld_refcount)); - RETURN(0); + return 0; } /* Drop a reference to a config log. When no longer referenced, @@ -180,7 +180,7 @@ struct config_llog_data *config_log_find(char *logname, LASSERT(found->cld_stopping == 0 || cld_is_sptlrpc(found) == 0); } spin_unlock(&config_list_lock); - RETURN(found); + return found; } static @@ -198,7 +198,7 @@ struct config_llog_data *do_config_log_add(struct obd_device *obd, OBD_ALLOC(cld, sizeof(*cld) + strlen(logname) + 1); if (!cld) - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); strcpy(cld->cld_logname, logname); if (cfg) @@ -228,7 +228,7 @@ struct config_llog_data *do_config_log_add(struct obd_device *obd, if (rc) { config_log_put(cld); - RETURN(ERR_PTR(rc)); + return ERR_PTR(rc); } if (cld_is_sptlrpc(cld)) { @@ -237,7 +237,7 @@ struct config_llog_data *do_config_log_add(struct obd_device *obd, CERROR("failed processing sptlrpc log: %d\n", rc); } - RETURN(cld); + return cld; } static struct config_llog_data *config_recover_log_add(struct obd_device *obd, @@ -299,7 +299,7 @@ static int config_log_add(struct obd_device *obd, char *logname, ptr = strrchr(logname, '-'); if (ptr == NULL || ptr - logname > 8) { CERROR("logname %s is too long\n", logname); - RETURN(-EINVAL); + return -EINVAL; } memcpy(seclogname, logname, ptr - logname); @@ -311,7 +311,7 @@ static int config_log_add(struct obd_device *obd, char *logname, CONFIG_T_SPTLRPC, NULL, NULL); if (IS_ERR(sptlrpc_cld)) { CERROR("can't create sptlrpc log: %s\n", seclogname); - RETURN(PTR_ERR(sptlrpc_cld)); + return PTR_ERR(sptlrpc_cld); } } @@ -319,7 +319,7 @@ static int config_log_add(struct obd_device *obd, char *logname, if (IS_ERR(cld)) { CERROR("can't create log: %s\n", logname); config_log_put(sptlrpc_cld); - RETURN(PTR_ERR(cld)); + return PTR_ERR(cld); } cld->cld_sptlrpc = sptlrpc_cld; @@ -331,12 +331,12 @@ static int config_log_add(struct obd_device *obd, char *logname, recover_cld = config_recover_log_add(obd, seclogname, cfg, sb); if (IS_ERR(recover_cld)) { config_log_put(cld); - RETURN(PTR_ERR(recover_cld)); + return PTR_ERR(recover_cld); } cld->cld_recover = recover_cld; } - RETURN(0); + return 0; } DEFINE_MUTEX(llog_process_lock); @@ -352,7 +352,7 @@ static int config_log_end(char *logname, struct config_llog_instance *cfg) cld = config_log_find(logname, cfg); if (cld == NULL) - RETURN(-ENOENT); + return -ENOENT; mutex_lock(&cld->cld_lock); /* @@ -366,7 +366,7 @@ static int config_log_end(char *logname, struct config_llog_instance *cfg) mutex_unlock(&cld->cld_lock); /* drop the ref from the find */ config_log_put(cld); - RETURN(rc); + return rc; } cld->cld_stopping = 1; @@ -397,7 +397,7 @@ static int config_log_end(char *logname, struct config_llog_instance *cfg) CDEBUG(D_MGC, "end config log %s (%d)\n", logname ? logname : "client", rc); - RETURN(rc); + return rc; } int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data) @@ -421,7 +421,7 @@ int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data) } spin_unlock(&config_list_lock); - RETURN(0); + return 0; } /* reenqueue any lost locks */ @@ -542,7 +542,7 @@ static int mgc_requeue_thread(void *data) complete(&rq_exit); CDEBUG(D_MGC, "Ending requeue thread\n"); - RETURN(rc); + return rc; } /* Add a cld to the list to requeue. Start the requeue thread if needed. @@ -602,7 +602,7 @@ static int mgc_fs_setup(struct obd_device *obd, struct super_block *sb, up(&cli->cl_mgc_sem); CERROR("%s: No fstype %s: rc = %ld\n", lsi->lsi_fstype, obd->obd_name, PTR_ERR(obd->obd_fsops)); - RETURN(PTR_ERR(obd->obd_fsops)); + return PTR_ERR(obd->obd_fsops); } cli->cl_mgc_vfsmnt = mnt; @@ -636,14 +636,14 @@ static int mgc_fs_setup(struct obd_device *obd, struct super_block *sb, CDEBUG(D_MGC, "MGC using disk labelled=%s\n", label); /* We keep the cl_mgc_sem until mgc_fs_cleanup */ - RETURN(0); + return 0; err_ops: fsfilt_put_ops(obd->obd_fsops); obd->obd_fsops = NULL; cli->cl_mgc_vfsmnt = NULL; up(&cli->cl_mgc_sem); - RETURN(err); + return err; } static int mgc_fs_cleanup(struct obd_device *obd) @@ -668,7 +668,7 @@ static int mgc_fs_cleanup(struct obd_device *obd) up(&cli->cl_mgc_sem); - RETURN(rc); + return rc; } static atomic_t mgc_count = ATOMIC_INIT(0); @@ -699,7 +699,7 @@ static int mgc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) CERROR("failed to cleanup llogging subsystems\n"); break; } - RETURN(rc); + return rc; } static int mgc_cleanup(struct obd_device *obd) @@ -719,7 +719,7 @@ static int mgc_cleanup(struct obd_device *obd) ptlrpcd_decref(); rc = client_obd_cleanup(obd); - RETURN(rc); + return rc; } static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) @@ -760,13 +760,13 @@ static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) rc = 0; } - RETURN(rc); + return rc; err_cleanup: client_obd_cleanup(obd); err_decref: ptlrpcd_decref(); - RETURN(rc); + return rc; } /* based on ll_mdc_blocking_ast */ @@ -824,7 +824,7 @@ static int mgc_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, LBUG(); } - RETURN(rc); + return rc; } /* Not sure where this should go... */ @@ -844,12 +844,12 @@ static int mgc_set_mgs_param(struct obd_export *exp, &RQF_MGS_SET_INFO, LUSTRE_MGS_VERSION, MGS_SET_INFO); if (!req) - RETURN(-ENOMEM); + return -ENOMEM; req_msp = req_capsule_client_get(&req->rq_pill, &RMF_MGS_SEND_PARAM); if (!req_msp) { ptlrpc_req_finished(req); - RETURN(-ENOMEM); + return -ENOMEM; } memcpy(req_msp, msp, sizeof(*req_msp)); @@ -865,7 +865,7 @@ static int mgc_set_mgs_param(struct obd_export *exp, ptlrpc_req_finished(req); - RETURN(rc); + return rc; } /* Take a config lock so we can get cancel notifications */ @@ -895,7 +895,7 @@ static int mgc_enqueue(struct obd_export *exp, struct lov_stripe_md *lsm, &RQF_LDLM_ENQUEUE, LUSTRE_DLM_VERSION, LDLM_ENQUEUE); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; req_capsule_set_size(&req->rq_pill, &RMF_DLM_LVB, RCL_SERVER, 0); ptlrpc_request_set_replen(req); @@ -913,7 +913,7 @@ static int mgc_enqueue(struct obd_export *exp, struct lov_stripe_md *lsm, /* A failed enqueue should still call the mgc_blocking_ast, where it will be requeued if needed ("grant failed"). */ ptlrpc_req_finished(req); - RETURN(rc); + return rc; } static int mgc_cancel(struct obd_export *exp, struct lov_stripe_md *md, @@ -921,7 +921,7 @@ static int mgc_cancel(struct obd_export *exp, struct lov_stripe_md *md, { ldlm_lock_decref(lockh, mode); - RETURN(0); + return 0; } static void mgc_notify_active(struct obd_device *unused) @@ -947,12 +947,12 @@ static int mgc_target_register(struct obd_export *exp, &RQF_MGS_TARGET_REG, LUSTRE_MGS_VERSION, MGS_TARGET_REG); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; req_mti = req_capsule_client_get(&req->rq_pill, &RMF_MGS_TARGET_INFO); if (!req_mti) { ptlrpc_req_finished(req); - RETURN(-ENOMEM); + return -ENOMEM; } memcpy(req_mti, mti, sizeof(*req_mti)); @@ -971,7 +971,7 @@ static int mgc_target_register(struct obd_export *exp, } ptlrpc_req_finished(req); - RETURN(rc); + return rc; } int mgc_set_info_async(const struct lu_env *env, struct obd_export *exp, @@ -985,7 +985,7 @@ int mgc_set_info_async(const struct lu_env *env, struct obd_export *exp, struct obd_import *imp = class_exp2cliimp(exp); int value; if (vallen != sizeof(int)) - RETURN(-EINVAL); + return -EINVAL; value = *(int *)val; CDEBUG(D_MGC, "InitRecov %s %d/d%d:i%d:r%d:or%d:%s\n", imp->imp_obd->obd_name, value, @@ -996,46 +996,46 @@ int mgc_set_info_async(const struct lu_env *env, struct obd_export *exp, if ((imp->imp_state != LUSTRE_IMP_FULL && imp->imp_state != LUSTRE_IMP_NEW) || value > 1) ptlrpc_reconnect_import(imp); - RETURN(0); + return 0; } /* FIXME move this to mgc_process_config */ if (KEY_IS(KEY_REGISTER_TARGET)) { struct mgs_target_info *mti; if (vallen != sizeof(struct mgs_target_info)) - RETURN(-EINVAL); + return -EINVAL; mti = (struct mgs_target_info *)val; CDEBUG(D_MGC, "register_target %s %#x\n", mti->mti_svname, mti->mti_flags); rc = mgc_target_register(exp, mti); - RETURN(rc); + return rc; } if (KEY_IS(KEY_SET_FS)) { struct super_block *sb = (struct super_block *)val; struct lustre_sb_info *lsi; if (vallen != sizeof(struct super_block)) - RETURN(-EINVAL); + return -EINVAL; lsi = s2lsi(sb); rc = mgc_fs_setup(exp->exp_obd, sb, lsi->lsi_srv_mnt); if (rc) { CERROR("set_fs got %d\n", rc); } - RETURN(rc); + return rc; } if (KEY_IS(KEY_CLEAR_FS)) { if (vallen != 0) - RETURN(-EINVAL); + return -EINVAL; rc = mgc_fs_cleanup(exp->exp_obd); if (rc) { CERROR("clear_fs got %d\n", rc); } - RETURN(rc); + return rc; } if (KEY_IS(KEY_SET_INFO)) { struct mgs_send_param *msp; msp = (struct mgs_send_param *)val; rc = mgc_set_mgs_param(exp, msp); - RETURN(rc); + return rc; } if (KEY_IS(KEY_MGSSEC)) { struct client_obd *cli = &exp->exp_obd->u.cli; @@ -1050,7 +1050,7 @@ int mgc_set_info_async(const struct lu_env *env, struct obd_export *exp, */ if (vallen == 0) { if (cli->cl_flvr_mgc.sf_rpc != SPTLRPC_FLVR_INVALID) - RETURN(0); + return 0; val = "null"; vallen = 4; } @@ -1059,7 +1059,7 @@ int mgc_set_info_async(const struct lu_env *env, struct obd_export *exp, if (rc) { CERROR("invalid sptlrpc flavor %s to MGS\n", (char *) val); - RETURN(rc); + return rc; } /* @@ -1078,10 +1078,10 @@ int mgc_set_info_async(const struct lu_env *env, struct obd_export *exp, (char *) val, str); rc = -EPERM; } - RETURN(rc); + return rc; } - RETURN(rc); + return rc; } static int mgc_get_info(const struct lu_env *env, struct obd_export *exp, @@ -1142,7 +1142,7 @@ static int mgc_import_event(struct obd_device *obd, CERROR("Unknown import event %#x\n", event); LBUG(); } - RETURN(rc); + return rc; } static int mgc_llog_init(struct obd_device *obd, struct obd_llog_group *olg, @@ -1166,12 +1166,12 @@ static int mgc_llog_init(struct obd_device *obd, struct obd_llog_group *olg, llog_initiator_connect(ctxt); llog_ctxt_put(ctxt); - RETURN(0); + return 0; out: ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT); if (ctxt) llog_cleanup(NULL, ctxt); - RETURN(rc); + return rc; } static int mgc_llog_finish(struct obd_device *obd, int count) @@ -1185,7 +1185,7 @@ static int mgc_llog_finish(struct obd_device *obd, int count) ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT); if (ctxt) llog_cleanup(NULL, ctxt); - RETURN(0); + return 0; } enum { @@ -1216,7 +1216,7 @@ static int mgc_apply_recover_logs(struct obd_device *mgc, OBD_ALLOC(inst, PAGE_CACHE_SIZE); if (inst == NULL) - RETURN(-ENOMEM); + return -ENOMEM; if (!IS_SERVER(lsi)) { pos = snprintf(inst, PAGE_CACHE_SIZE, "%p", cfg->cfg_instance); @@ -1230,7 +1230,7 @@ static int mgc_apply_recover_logs(struct obd_device *mgc, PAGE_CACHE_SIZE); if (rc) { OBD_FREE(inst, PAGE_CACHE_SIZE); - RETURN(-EINVAL); + return -EINVAL; } pos = strlen(inst); } @@ -1388,7 +1388,7 @@ static int mgc_apply_recover_logs(struct obd_device *mgc, } OBD_FREE(inst, PAGE_CACHE_SIZE); - RETURN(rc); + return rc; } /** @@ -1560,7 +1560,7 @@ static int mgc_process_cfg_log(struct obd_device *mgc, * read it up here. */ if (cld_is_sptlrpc(cld) && local_only) - RETURN(0); + return 0; if (cld->cld_cfg.cfg_sb) lsi = s2lsi(cld->cld_cfg.cfg_sb); @@ -1568,12 +1568,12 @@ static int mgc_process_cfg_log(struct obd_device *mgc, ctxt = llog_get_context(mgc, LLOG_CONFIG_REPL_CTXT); if (!ctxt) { CERROR("missing llog context\n"); - RETURN(-EINVAL); + return -EINVAL; } OBD_ALLOC_PTR(saved_ctxt); if (saved_ctxt == NULL) - RETURN(-ENOMEM); + return -ENOMEM; lctxt = llog_get_context(mgc, LLOG_CONFIG_ORIG_CTXT); @@ -1614,7 +1614,7 @@ static int mgc_process_cfg_log(struct obd_device *mgc, strlen("-sptlrpc")); } - RETURN(rc); + return rc; } /** Get a config log from the MGS and process it. @@ -1636,7 +1636,7 @@ int mgc_process_log(struct obd_device *mgc, struct config_llog_data *cld) mutex_lock(&cld->cld_lock); if (cld->cld_stopping) { mutex_unlock(&cld->cld_lock); - RETURN(0); + return 0; } OBD_FAIL_TIMEOUT(OBD_FAIL_MGC_PAUSE_PROCESS_LOG, 20); @@ -1685,7 +1685,7 @@ int mgc_process_log(struct obd_device *mgc, struct config_llog_data *cld) CERROR("Can't drop cfg lock: %d\n", rcl); } - RETURN(rc); + return rc; } @@ -1783,7 +1783,7 @@ static int mgc_process_config(struct obd_device *obd, obd_count len, void *buf) } } out: - RETURN(rc); + return rc; } struct obd_ops mgc_obd_ops = { diff --git a/drivers/staging/lustre/lustre/obdclass/acl.c b/drivers/staging/lustre/lustre/obdclass/acl.c index 33bdf279868a0..f0bb632a70aaf 100644 --- a/drivers/staging/lustre/lustre/obdclass/acl.c +++ b/drivers/staging/lustre/lustre/obdclass/acl.c @@ -146,7 +146,7 @@ lustre_posix_acl_xattr_2ext(posix_acl_xattr_header *header, int size) ext_acl_xattr_header *new; if (unlikely(size < 0)) - RETURN(ERR_PTR(-EINVAL)); + return ERR_PTR(-EINVAL); else if (!size) count = 0; else @@ -154,7 +154,7 @@ lustre_posix_acl_xattr_2ext(posix_acl_xattr_header *header, int size) esize = CFS_ACL_XATTR_SIZE(count, ext_acl_xattr); OBD_ALLOC(new, esize); if (unlikely(new == NULL)) - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); new->a_count = cpu_to_le32(count); for (i = 0; i < count; i++) { @@ -164,7 +164,7 @@ lustre_posix_acl_xattr_2ext(posix_acl_xattr_header *header, int size) new->a_entries[i].e_stat = cpu_to_le32(ES_UNK); } - RETURN(new); + return new; } EXPORT_SYMBOL(lustre_posix_acl_xattr_2ext); @@ -179,13 +179,13 @@ int lustre_posix_acl_xattr_filter(posix_acl_xattr_header *header, int size, posix_acl_xattr_header *new; if (unlikely(size < 0)) - RETURN(-EINVAL); + return -EINVAL; else if (!size) - RETURN(0); + return 0; OBD_ALLOC(new, size); if (unlikely(new == NULL)) - RETURN(-ENOMEM); + return -ENOMEM; new->a_version = cpu_to_le32(CFS_ACL_XATTR_VERSION); count = CFS_ACL_XATTR_COUNT(size, posix_acl_xattr); @@ -308,7 +308,7 @@ int lustre_acl_xattr_merge2posix(posix_acl_xattr_header *posix_header, int size, posix_size = CFS_ACL_XATTR_SIZE(posix_count, posix_acl_xattr); OBD_ALLOC(new, posix_size); if (unlikely(new == NULL)) - RETURN(-ENOMEM); + return -ENOMEM; new->a_version = cpu_to_le32(CFS_ACL_XATTR_VERSION); for (i = 0, j = 0; i < ext_count; i++) { @@ -345,7 +345,7 @@ int lustre_acl_xattr_merge2posix(posix_acl_xattr_header *posix_header, int size, int ori_posix_count; if (unlikely(size < 0)) - RETURN(-EINVAL); + return -EINVAL; else if (!size) ori_posix_count = 0; else @@ -356,7 +356,7 @@ int lustre_acl_xattr_merge2posix(posix_acl_xattr_header *posix_header, int size, CFS_ACL_XATTR_SIZE(posix_count, posix_acl_xattr); OBD_ALLOC(new, posix_size); if (unlikely(new == NULL)) - RETURN(-ENOMEM); + return -ENOMEM; new->a_version = cpu_to_le32(CFS_ACL_XATTR_VERSION); /* 1. process the unchanged ACL entries @@ -417,7 +417,7 @@ lustre_acl_xattr_merge2ext(posix_acl_xattr_header *posix_header, int size, ext_acl_xattr_entry *ee, eae; if (unlikely(size < 0)) - RETURN(ERR_PTR(-EINVAL)); + return ERR_PTR(-EINVAL); else if (!size) posix_count = 0; else @@ -428,7 +428,7 @@ lustre_acl_xattr_merge2ext(posix_acl_xattr_header *posix_header, int size, OBD_ALLOC(new, ext_size); if (unlikely(new == NULL)) - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); for (i = 0, j = 0; i < posix_count; i++) { lustre_posix_acl_le_to_cpu(&pae, &posix_header->a_entries[i]); diff --git a/drivers/staging/lustre/lustre/obdclass/capa.c b/drivers/staging/lustre/lustre/obdclass/capa.c index 9c5a05b1c5071..fe3fa8ec9f24c 100644 --- a/drivers/staging/lustre/lustre/obdclass/capa.c +++ b/drivers/staging/lustre/lustre/obdclass/capa.c @@ -282,7 +282,7 @@ int capa_encrypt_id(__u32 *d, __u32 *s, __u8 *key, int keylen) tfm = ll_crypto_alloc_blkcipher(alg, 0, 0 ); if (IS_ERR(tfm)) { CERROR("failed to load transform for aes\n"); - RETURN(PTR_ERR(tfm)); + return PTR_ERR(tfm); } min = ll_crypto_tfm_alg_min_keysize(tfm); @@ -332,7 +332,7 @@ int capa_decrypt_id(__u32 *d, __u32 *s, __u8 *key, int keylen) tfm = ll_crypto_alloc_blkcipher(alg, 0, 0 ); if (IS_ERR(tfm)) { CERROR("failed to load transform for aes\n"); - RETURN(PTR_ERR(tfm)); + return PTR_ERR(tfm); } min = ll_crypto_tfm_alg_min_keysize(tfm); diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c index d5b0bb8bed82e..4269793415549 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_io.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c @@ -172,7 +172,7 @@ static int cl_io_init0(const struct lu_env *env, struct cl_io *io, } if (result == 0) io->ci_state = CIS_INIT; - RETURN(result); + return result; } /** @@ -232,7 +232,7 @@ int cl_io_rw_init(const struct lu_env *env, struct cl_io *io, io->u.ci_rw.crw_nonblock, io->u.ci_wr.wr_append); io->u.ci_rw.crw_pos = pos; io->u.ci_rw.crw_count = count; - RETURN(cl_io_init(env, io, iot, io->ci_obj)); + return cl_io_init(env, io, iot, io->ci_obj); } EXPORT_SYMBOL(cl_io_rw_init); @@ -335,9 +335,9 @@ int cl_queue_match(const struct list_head *queue, list_for_each_entry(scan, queue, cill_linkage) { if (cl_lock_descr_match(&scan->cill_descr, need)) - RETURN(+1); + return +1; } - RETURN(0); + return 0; } EXPORT_SYMBOL(cl_queue_match); @@ -353,9 +353,9 @@ static int cl_queue_merge(const struct list_head *queue, CDEBUG(D_VFSTRACE, "lock: %d: [%lu, %lu]\n", scan->cill_descr.cld_mode, scan->cill_descr.cld_start, scan->cill_descr.cld_end); - RETURN(+1); + return +1; } - RETURN(0); + return 0; } @@ -394,7 +394,7 @@ static int cl_lockset_lock_one(const struct lu_env *env, result = 0; } else result = PTR_ERR(lock); - RETURN(result); + return result; } static void cl_lock_link_fini(const struct lu_env *env, struct cl_io *io, @@ -442,7 +442,7 @@ static int cl_lockset_lock(const struct lu_env *env, struct cl_io *io, break; } } - RETURN(result); + return result; } /** @@ -476,7 +476,7 @@ int cl_io_lock(const struct lu_env *env, struct cl_io *io) cl_io_unlock(env, io); else io->ci_state = CIS_LOCKED; - RETURN(result); + return result; } EXPORT_SYMBOL(cl_io_lock); @@ -542,7 +542,7 @@ int cl_io_iter_init(const struct lu_env *env, struct cl_io *io) } if (result == 0) io->ci_state = CIS_IT_STARTED; - RETURN(result); + return result; } EXPORT_SYMBOL(cl_io_iter_init); @@ -605,7 +605,7 @@ int cl_io_lock_add(const struct lu_env *env, struct cl_io *io, list_add(&link->cill_linkage, &io->ci_lockset.cls_todo); result = 0; } - RETURN(result); + return result; } EXPORT_SYMBOL(cl_io_lock_add); @@ -634,7 +634,7 @@ int cl_io_lock_alloc_add(const struct lu_env *env, struct cl_io *io, } else result = -ENOMEM; - RETURN(result); + return result; } EXPORT_SYMBOL(cl_io_lock_alloc_add); @@ -660,7 +660,7 @@ int cl_io_start(const struct lu_env *env, struct cl_io *io) } if (result >= 0) result = 0; - RETURN(result); + return result; } EXPORT_SYMBOL(cl_io_start); @@ -779,7 +779,7 @@ int cl_io_read_page(const struct lu_env *env, struct cl_io *io, */ cl_page_list_disown(env, io, &queue->c2_qin); cl_2queue_fini(env, queue); - RETURN(result); + return result; } EXPORT_SYMBOL(cl_io_read_page); @@ -812,7 +812,7 @@ int cl_io_prepare_write(const struct lu_env *env, struct cl_io *io, break; } } - RETURN(result); + return result; } EXPORT_SYMBOL(cl_io_prepare_write); @@ -852,7 +852,7 @@ int cl_io_commit_write(const struct lu_env *env, struct cl_io *io, } } LINVRNT(result <= 0); - RETURN(result); + return result; } EXPORT_SYMBOL(cl_io_commit_write); @@ -886,7 +886,7 @@ int cl_io_submit_rw(const struct lu_env *env, struct cl_io *io, * If ->cio_submit() failed, no pages were sent. */ LASSERT(ergo(result != 0, list_empty(&queue->c2_qout.pl_pages))); - RETURN(result); + return result; } EXPORT_SYMBOL(cl_io_submit_rw); @@ -1011,7 +1011,7 @@ int cl_io_loop(const struct lu_env *env, struct cl_io *io) } while (result == 0 && io->ci_continue); if (result == 0) result = io->ci_result; - RETURN(result < 0 ? result : 0); + return result < 0 ? result : 0; } EXPORT_SYMBOL(cl_io_loop); @@ -1202,7 +1202,7 @@ int cl_page_list_own(const struct lu_env *env, else cl_page_list_del(env, plist, page); } - RETURN(result); + return result; } EXPORT_SYMBOL(cl_page_list_own); @@ -1251,7 +1251,7 @@ int cl_page_list_unmap(const struct lu_env *env, struct cl_io *io, if (result != 0) break; } - RETURN(result); + return result; } EXPORT_SYMBOL(cl_page_list_unmap); @@ -1336,7 +1336,7 @@ struct cl_io *cl_io_top(struct cl_io *io) { while (io->ci_parent != NULL) io = io->ci_parent; - RETURN(io); + return io; } EXPORT_SYMBOL(cl_io_top); @@ -1413,7 +1413,7 @@ static int cl_req_init(const struct lu_env *env, struct cl_req *req, } page = page->cp_child; } while (page != NULL && result == 0); - RETURN(result); + return result; } /** @@ -1467,7 +1467,7 @@ struct cl_req *cl_req_alloc(const struct lu_env *env, struct cl_page *page, } } else req = ERR_PTR(-ENOMEM); - RETURN(req); + return req; } EXPORT_SYMBOL(cl_req_alloc); @@ -1549,7 +1549,7 @@ int cl_req_prep(const struct lu_env *env, struct cl_req *req) break; } } - RETURN(result); + return result; } EXPORT_SYMBOL(cl_req_prep); @@ -1643,7 +1643,7 @@ int cl_sync_io_wait(const struct lu_env *env, struct cl_io *io, } POISON(anchor, 0x5a, sizeof *anchor); - RETURN(rc); + return rc; } EXPORT_SYMBOL(cl_sync_io_wait); diff --git a/drivers/staging/lustre/lustre/obdclass/cl_lock.c b/drivers/staging/lustre/lustre/obdclass/cl_lock.c index 581e7da07bc59..749eb082f9797 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_lock.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_lock.c @@ -394,7 +394,7 @@ static struct cl_lock *cl_lock_alloc(const struct lu_env *env, } } else lock = ERR_PTR(-ENOMEM); - RETURN(lock); + return lock; } /** @@ -464,9 +464,9 @@ static int cl_lock_fits_into(const struct lu_env *env, list_for_each_entry(slice, &lock->cll_layers, cls_linkage) { if (slice->cls_ops->clo_fits_into != NULL && !slice->cls_ops->clo_fits_into(env, slice, need, io)) - RETURN(0); + return 0; } - RETURN(1); + return 1; } static struct cl_lock *cl_lock_lookup(const struct lu_env *env, @@ -494,10 +494,10 @@ static struct cl_lock *cl_lock_lookup(const struct lu_env *env, if (matched) { cl_lock_get_trust(lock); CS_LOCK_INC(obj, hit); - RETURN(lock); + return lock; } } - RETURN(NULL); + return NULL; } /** @@ -549,7 +549,7 @@ static struct cl_lock *cl_lock_find(const struct lu_env *env, } } } - RETURN(lock); + return lock; } /** @@ -621,9 +621,9 @@ const struct cl_lock_slice *cl_lock_at(const struct cl_lock *lock, list_for_each_entry(slice, &lock->cll_layers, cls_linkage) { if (slice->cls_obj->co_lu.lo_dev->ld_type == dtype) - RETURN(slice); + return slice; } - RETURN(NULL); + return NULL; } EXPORT_SYMBOL(cl_lock_at); @@ -703,7 +703,7 @@ int cl_lock_mutex_try(const struct lu_env *env, struct cl_lock *lock) cl_lock_mutex_tail(env, lock); } else result = -EBUSY; - RETURN(result); + return result; } EXPORT_SYMBOL(cl_lock_mutex_try); @@ -955,7 +955,7 @@ int cl_lock_state_wait(const struct lu_env *env, struct cl_lock *lock) /* Restore old blocked signals */ cfs_restore_sigs(blocked); } - RETURN(result); + return result; } EXPORT_SYMBOL(cl_lock_state_wait); @@ -1061,7 +1061,7 @@ int cl_use_try(const struct lu_env *env, struct cl_lock *lock, int atomic) LASSERT(lock->cll_state == CLS_CACHED); if (lock->cll_error) - RETURN(lock->cll_error); + return lock->cll_error; result = -ENOSYS; state = cl_lock_intransit(env, lock); @@ -1101,7 +1101,7 @@ int cl_use_try(const struct lu_env *env, struct cl_lock *lock, int atomic) } cl_lock_extransit(env, lock, state); - RETURN(result); + return result; } EXPORT_SYMBOL(cl_use_try); @@ -1126,7 +1126,7 @@ static int cl_enqueue_kick(const struct lu_env *env, } } LASSERT(result != -ENOSYS); - RETURN(result); + return result; } /** @@ -1189,7 +1189,7 @@ int cl_enqueue_try(const struct lu_env *env, struct cl_lock *lock, LBUG(); } } while (result == CLO_REPEAT); - RETURN(result); + return result; } EXPORT_SYMBOL(cl_enqueue_try); @@ -1234,7 +1234,7 @@ int cl_lock_enqueue_wait(const struct lu_env *env, cl_lock_mutex_get(env, lock); LASSERT(rc <= 0); - RETURN(rc); + return rc; } EXPORT_SYMBOL(cl_lock_enqueue_wait); @@ -1265,7 +1265,7 @@ static int cl_enqueue_locked(const struct lu_env *env, struct cl_lock *lock, LASSERT(ergo(result == 0 && !(enqflags & CEF_AGL), lock->cll_state == CLS_ENQUEUED || lock->cll_state == CLS_HELD)); - RETURN(result); + return result; } /** @@ -1290,7 +1290,7 @@ int cl_enqueue(const struct lu_env *env, struct cl_lock *lock, cl_lock_lockdep_release(env, lock); LASSERT(ergo(result == 0, lock->cll_state == CLS_ENQUEUED || lock->cll_state == CLS_HELD)); - RETURN(result); + return result; } EXPORT_SYMBOL(cl_enqueue); @@ -1315,14 +1315,14 @@ int cl_unuse_try(const struct lu_env *env, struct cl_lock *lock) if (lock->cll_users > 1) { cl_lock_user_del(env, lock); - RETURN(0); + return 0; } /* Only if the lock is in CLS_HELD or CLS_ENQUEUED state, it can hold * underlying resources. */ if (!(lock->cll_state == CLS_HELD || lock->cll_state == CLS_ENQUEUED)) { cl_lock_user_del(env, lock); - RETURN(0); + return 0; } /* @@ -1368,7 +1368,7 @@ int cl_unuse_try(const struct lu_env *env, struct cl_lock *lock) state = CLS_NEW; cl_lock_extransit(env, lock, state); } - RETURN(result ?: lock->cll_error); + return result ?: lock->cll_error; } EXPORT_SYMBOL(cl_unuse_try); @@ -1447,7 +1447,7 @@ int cl_wait_try(const struct lu_env *env, struct cl_lock *lock) cl_lock_state_set(env, lock, CLS_HELD); } } while (result == CLO_REPEAT); - RETURN(result); + return result; } EXPORT_SYMBOL(cl_wait_try); @@ -1487,7 +1487,7 @@ int cl_wait(const struct lu_env *env, struct cl_lock *lock) cl_lock_trace(D_DLMTRACE, env, "wait lock", lock); cl_lock_mutex_put(env, lock); LASSERT(ergo(result == 0, lock->cll_state == CLS_HELD)); - RETURN(result); + return result; } EXPORT_SYMBOL(cl_wait); @@ -1513,7 +1513,7 @@ unsigned long cl_lock_weigh(const struct lu_env *env, struct cl_lock *lock) pound = ~0UL; } } - RETURN(pound); + return pound; } EXPORT_SYMBOL(cl_lock_weigh); @@ -1545,7 +1545,7 @@ int cl_lock_modify(const struct lu_env *env, struct cl_lock *lock, if (slice->cls_ops->clo_modify != NULL) { result = slice->cls_ops->clo_modify(env, slice, desc); if (result != 0) - RETURN(result); + return result; } } CL_LOCK_DEBUG(D_DLMTRACE, env, lock, " -> "DDESCR"@"DFID"\n", @@ -1558,7 +1558,7 @@ int cl_lock_modify(const struct lu_env *env, struct cl_lock *lock, spin_lock(&hdr->coh_lock_guard); lock->cll_descr = *desc; spin_unlock(&hdr->coh_lock_guard); - RETURN(0); + return 0; } EXPORT_SYMBOL(cl_lock_modify); @@ -1613,7 +1613,7 @@ int cl_lock_closure_build(const struct lu_env *env, struct cl_lock *lock, } if (result != 0) cl_lock_disclosure(env, closure); - RETURN(result); + return result; } EXPORT_SYMBOL(cl_lock_closure_build); @@ -1660,7 +1660,7 @@ int cl_lock_enclosure(const struct lu_env *env, struct cl_lock *lock, } result = CLO_REPEAT; } - RETURN(result); + return result; } EXPORT_SYMBOL(cl_lock_enclosure); @@ -1824,7 +1824,7 @@ struct cl_lock *cl_lock_at_pgoff(const struct lu_env *env, } } spin_unlock(&head->coh_lock_guard); - RETURN(lock); + return lock; } EXPORT_SYMBOL(cl_lock_at_pgoff); @@ -1946,7 +1946,7 @@ int cl_lock_discard_pages(const struct lu_env *env, struct cl_lock *lock) } while (res != CLP_GANG_OKAY); out: cl_io_fini(env, io); - RETURN(result); + return result; } EXPORT_SYMBOL(cl_lock_discard_pages); @@ -2028,7 +2028,7 @@ static struct cl_lock *cl_lock_hold_mutex(const struct lu_env *env, cl_lock_mutex_put(env, lock); cl_lock_put(env, lock); } - RETURN(lock); + return lock; } /** @@ -2047,7 +2047,7 @@ struct cl_lock *cl_lock_hold(const struct lu_env *env, const struct cl_io *io, lock = cl_lock_hold_mutex(env, io, need, scope, source); if (!IS_ERR(lock)) cl_lock_mutex_put(env, lock); - RETURN(lock); + return lock; } EXPORT_SYMBOL(cl_lock_hold); @@ -2094,7 +2094,7 @@ struct cl_lock *cl_lock_request(const struct lu_env *env, struct cl_io *io, lock = ERR_PTR(rc); } } while (rc == 0); - RETURN(lock); + return lock; } EXPORT_SYMBOL(cl_lock_request); diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c index ea1758065c62b..7b0e9d26b6c10 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c @@ -93,7 +93,7 @@ int cl_object_header_init(struct cl_object_header *h) INIT_LIST_HEAD(&h->coh_locks); h->coh_page_bufsize = ALIGN(sizeof(struct cl_page), 8); } - RETURN(result); + return result; } EXPORT_SYMBOL(cl_object_header_init); @@ -234,7 +234,7 @@ int cl_object_attr_get(const struct lu_env *env, struct cl_object *obj, } } } - RETURN(result); + return result; } EXPORT_SYMBOL(cl_object_attr_get); @@ -266,7 +266,7 @@ int cl_object_attr_set(const struct lu_env *env, struct cl_object *obj, } } } - RETURN(result); + return result; } EXPORT_SYMBOL(cl_object_attr_set); @@ -299,7 +299,7 @@ int cl_object_glimpse(const struct lu_env *env, struct cl_object *obj, "ctime: "LPU64" blocks: "LPU64"\n", lvb->lvb_size, lvb->lvb_mtime, lvb->lvb_atime, lvb->lvb_ctime, lvb->lvb_blocks); - RETURN(result); + return result; } EXPORT_SYMBOL(cl_object_glimpse); @@ -321,7 +321,7 @@ int cl_conf_set(const struct lu_env *env, struct cl_object *obj, break; } } - RETURN(result); + return result; } EXPORT_SYMBOL(cl_conf_set); diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c index 028c72028fd5f..2a5ce376e5777 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_page.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c @@ -113,11 +113,11 @@ cl_page_at_trusted(const struct cl_page *page, do { list_for_each_entry(slice, &page->cp_layers, cpl_linkage) { if (slice->cpl_obj->co_lu.lo_dev->ld_type == dtype) - RETURN(slice); + return slice; } page = page->cp_child; } while (page != NULL); - RETURN(NULL); + return NULL; } /** @@ -241,7 +241,7 @@ int cl_page_gang_lookup(const struct lu_env *env, struct cl_object *obj, } if (tree_lock) spin_unlock(&hdr->coh_page_guard); - RETURN(res); + return res; } EXPORT_SYMBOL(cl_page_gang_lookup); @@ -332,7 +332,7 @@ static struct cl_page *cl_page_alloc(const struct lu_env *env, } else { page = ERR_PTR(-ENOMEM); } - RETURN(page); + return page; } /** @@ -389,13 +389,13 @@ static struct cl_page *cl_page_find0(const struct lu_env *env, if (page != NULL) { CS_PAGE_INC(o, hit); - RETURN(page); + return page; } /* allocate and initialize cl_page */ page = cl_page_alloc(env, o, idx, vmpage, type); if (IS_ERR(page)) - RETURN(page); + return page; if (type == CPT_TRANSIENT) { if (parent) { @@ -403,7 +403,7 @@ static struct cl_page *cl_page_find0(const struct lu_env *env, page->cp_parent = parent; parent->cp_child = page; } - RETURN(page); + return page; } /* @@ -444,7 +444,7 @@ static struct cl_page *cl_page_find0(const struct lu_env *env, cl_page_delete0(env, ghost, 0); cl_page_free(env, ghost); } - RETURN(page); + return page; } struct cl_page *cl_page_find(const struct lu_env *env, struct cl_object *o, @@ -627,7 +627,7 @@ struct page *cl_page_vmpage(const struct lu_env *env, struct cl_page *page) do { list_for_each_entry(slice, &page->cp_layers, cpl_linkage) { if (slice->cpl_ops->cpo_vmpage != NULL) - RETURN(slice->cpl_ops->cpo_vmpage(env, slice)); + return slice->cpl_ops->cpo_vmpage(env, slice); } page = page->cp_child; } while (page != NULL); @@ -657,7 +657,7 @@ struct cl_page *cl_vmpage_page(struct page *vmpage, struct cl_object *obj) */ top = (struct cl_page *)vmpage->private; if (top == NULL) - RETURN(NULL); + return NULL; for (page = top; page != NULL; page = page->cp_child) { if (cl_object_same(page->cp_obj, obj)) { @@ -666,7 +666,7 @@ struct cl_page *cl_vmpage_page(struct page *vmpage, struct cl_object *obj) } } LASSERT(ergo(page, page->cp_type == CPT_CACHEABLE)); - RETURN(page); + return page; } EXPORT_SYMBOL(cl_vmpage_page); @@ -771,10 +771,10 @@ static int cl_page_invoke(const struct lu_env *env, { PINVRNT(env, page, cl_object_same(page->cp_obj, io->ci_obj)); - RETURN(CL_PAGE_INVOKE(env, page, op, + return CL_PAGE_INVOKE(env, page, op, (const struct lu_env *, const struct cl_page_slice *, struct cl_io *), - io)); + io); } static void cl_page_invoid(const struct lu_env *env, @@ -836,7 +836,7 @@ void cl_page_disown0(const struct lu_env *env, int cl_page_is_owned(const struct cl_page *pg, const struct cl_io *io) { LINVRNT(cl_object_same(pg->cp_obj, io->ci_obj)); - RETURN(pg->cp_state == CPS_OWNED && pg->cp_owner == io); + return pg->cp_state == CPS_OWNED && pg->cp_owner == io; } EXPORT_SYMBOL(cl_page_is_owned); @@ -893,7 +893,7 @@ static int cl_page_own0(const struct lu_env *env, struct cl_io *io, } } PINVRNT(env, pg, ergo(result == 0, cl_page_invariant(pg))); - RETURN(result); + return result; } /** @@ -1161,13 +1161,13 @@ int cl_page_is_vmlocked(const struct lu_env *env, const struct cl_page *pg) */ result = slice->cpl_ops->cpo_is_vmlocked(env, slice); PASSERT(env, pg, result == -EBUSY || result == -ENODATA); - RETURN(result == -EBUSY); + return result == -EBUSY; } EXPORT_SYMBOL(cl_page_is_vmlocked); static enum cl_page_state cl_req_type_state(enum cl_req_type crt) { - RETURN(crt == CRT_WRITE ? CPS_PAGEOUT : CPS_PAGEIN); + return crt == CRT_WRITE ? CPS_PAGEOUT : CPS_PAGEIN; } static void cl_page_io_start(const struct lu_env *env, @@ -1286,7 +1286,7 @@ int cl_page_make_ready(const struct lu_env *env, struct cl_page *pg, PINVRNT(env, pg, crt < CRT_NR); if (crt >= CRT_NR) - RETURN(-EINVAL); + return -EINVAL; result = CL_PAGE_INVOKE(env, pg, CL_PAGE_OP(io[crt].cpo_make_ready), (const struct lu_env *, const struct cl_page_slice *)); @@ -1295,7 +1295,7 @@ int cl_page_make_ready(const struct lu_env *env, struct cl_page *pg, cl_page_io_start(env, pg, crt); } CL_PAGE_HEADER(D_TRACE, env, pg, "%d %d\n", crt, result); - RETURN(result); + return result; } EXPORT_SYMBOL(cl_page_make_ready); @@ -1322,7 +1322,7 @@ int cl_page_cache_add(const struct lu_env *env, struct cl_io *io, PINVRNT(env, pg, cl_page_invariant(pg)); if (crt >= CRT_NR) - RETURN(-EINVAL); + return -EINVAL; list_for_each_entry(scan, &pg->cp_layers, cpl_linkage) { if (scan->cpl_ops->io[crt].cpo_cache_add == NULL) @@ -1333,7 +1333,7 @@ int cl_page_cache_add(const struct lu_env *env, struct cl_io *io, break; } CL_PAGE_HEADER(D_TRACE, env, pg, "%d %d\n", crt, result); - RETURN(result); + return result; } EXPORT_SYMBOL(cl_page_cache_add); @@ -1356,7 +1356,7 @@ int cl_page_flush(const struct lu_env *env, struct cl_io *io, result = cl_page_invoke(env, io, pg, CL_PAGE_OP(cpo_flush)); CL_PAGE_HEADER(D_TRACE, env, pg, "%d\n", result); - RETURN(result); + return result; } EXPORT_SYMBOL(cl_page_flush); @@ -1379,7 +1379,7 @@ int cl_page_is_under_lock(const struct lu_env *env, struct cl_io *io, const struct cl_page_slice *, struct cl_io *), io); PASSERT(env, page, rc != 0); - RETURN(rc); + return rc; } EXPORT_SYMBOL(cl_page_is_under_lock); @@ -1415,7 +1415,7 @@ int cl_pages_prune(const struct lu_env *env, struct cl_object *clobj) result = cl_io_init(env, io, CIT_MISC, obj); if (result != 0) { cl_io_fini(env, io); - RETURN(io->ci_result); + return io->ci_result; } do { @@ -1426,7 +1426,7 @@ int cl_pages_prune(const struct lu_env *env, struct cl_object *clobj) } while (result != CLP_GANG_OKAY); cl_io_fini(env, io); - RETURN(result); + return result; } EXPORT_SYMBOL(cl_pages_prune); diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c index 09933b2f2aff9..44af41278a03f 100644 --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c @@ -116,14 +116,14 @@ int lustre_get_jobid(char *jobid) memset(jobid, 0, JOBSTATS_JOBID_SIZE); /* Jobstats isn't enabled */ if (strcmp(obd_jobid_var, JOBSTATS_DISABLE) == 0) - RETURN(0); + return 0; /* Use process name + fsuid as jobid */ if (strcmp(obd_jobid_var, JOBSTATS_PROCNAME_UID) == 0) { snprintf(jobid, JOBSTATS_JOBID_SIZE, "%s.%u", current_comm(), from_kuid(&init_user_ns, current_fsuid())); - RETURN(0); + return 0; } rc = cfs_get_environ(obd_jobid_var, jobid, &jobid_len); @@ -150,7 +150,7 @@ int lustre_get_jobid(char *jobid) obd_jobid_var, rc); } } - RETURN(rc); + return rc; } EXPORT_SYMBOL(lustre_get_jobid); @@ -213,7 +213,7 @@ int class_resolve_dev_name(__u32 len, const char *name) rc = dev; out: - RETURN(rc); + return rc; } int class_handle_ioctl(unsigned int cmd, unsigned long arg) @@ -235,7 +235,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) CDEBUG(D_IOCTL, "cmd = %x\n", cmd); if (obd_ioctl_getdata(&buf, &len, (void *)arg)) { CERROR("OBD ioctl: data error\n"); - RETURN(-EINVAL); + return -EINVAL; } data = (struct obd_ioctl_data *)buf; @@ -426,7 +426,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) out: if (buf) obd_ioctl_freedata(buf, len); - RETURN(err); + return err; } /* class_handle_ioctl */ extern struct miscdevice obd_psdev; @@ -522,7 +522,7 @@ static int __init init_obdclass(void) LPROCFS_STATS_FLAG_IRQ_SAFE); if (obd_memory == NULL) { CERROR("kmalloc of 'obd_memory' failed\n"); - RETURN(-ENOMEM); + return -ENOMEM; } lprocfs_counter_init(obd_memory, OBD_MEMORY_STAT, diff --git a/drivers/staging/lustre/lustre/obdclass/dt_object.c b/drivers/staging/lustre/lustre/obdclass/dt_object.c index 0d4eca7a55f52..1b164c7027b14 100644 --- a/drivers/staging/lustre/lustre/obdclass/dt_object.c +++ b/drivers/staging/lustre/lustre/obdclass/dt_object.c @@ -377,11 +377,11 @@ struct dt_object *dt_find_or_create(const struct lu_env *env, dto = dt_locate(env, dt, fid); if (IS_ERR(dto)) - RETURN(dto); + return dto; LASSERT(dto != NULL); if (dt_object_exists(dto)) - RETURN(dto); + return dto; th = dt_trans_create(env, dt); if (IS_ERR(th)) @@ -412,9 +412,9 @@ struct dt_object *dt_find_or_create(const struct lu_env *env, out: if (rc) { lu_object_put(env, &dto->do_lu); - RETURN(ERR_PTR(rc)); + return ERR_PTR(rc); } - RETURN(dto); + return dto; } EXPORT_SYMBOL(dt_find_or_create); @@ -765,14 +765,14 @@ int dt_index_walk(const struct lu_env *env, struct dt_object *obj, nob = rdpg->rp_count; if (nob <= 0) - RETURN(-EFAULT); + return -EFAULT; /* Iterate through index and fill containers from @rdpg */ iops = &obj->do_index_ops->dio_it; LASSERT(iops != NULL); it = iops->init(env, obj, rdpg->rp_attrs, BYPASS_CAPA); if (IS_ERR(it)) - RETURN(PTR_ERR(it)); + return PTR_ERR(it); rc = iops->load(env, it, rdpg->rp_hash); if (rc == 0) { @@ -826,7 +826,7 @@ int dt_index_walk(const struct lu_env *env, struct dt_object *obj, if (rc >= 0) rc = min_t(unsigned int, nlupgs * LU_PAGE_SIZE, rdpg->rp_count); - RETURN(rc); + return rc; } EXPORT_SYMBOL(dt_index_walk); @@ -854,21 +854,21 @@ int dt_index_read(const struct lu_env *env, struct dt_device *dev, /* rp_count shouldn't be null and should be a multiple of the container * size */ if (rdpg->rp_count <= 0 && (rdpg->rp_count & (LU_PAGE_SIZE - 1)) != 0) - RETURN(-EFAULT); + return -EFAULT; if (fid_seq(&ii->ii_fid) >= FID_SEQ_NORMAL) /* we don't support directory transfer via OBD_IDX_READ for the * time being */ - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; if (!fid_is_quota(&ii->ii_fid)) /* block access to all local files except quota files */ - RETURN(-EPERM); + return -EPERM; /* lookup index object subject to the transfer */ obj = dt_locate(env, dev, &ii->ii_fid); if (IS_ERR(obj)) - RETURN(PTR_ERR(obj)); + return PTR_ERR(obj); if (dt_object_exists(obj) == 0) GOTO(out, rc = -ENOENT); diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index c9180656dfd41..bba1b35360d0f 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -169,13 +169,13 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, if (class_search_type(name)) { CDEBUG(D_IOCTL, "Type %s already registered\n", name); - RETURN(-EEXIST); + return -EEXIST; } rc = -ENOMEM; OBD_ALLOC(type, sizeof(*type)); if (type == NULL) - RETURN(rc); + return rc; OBD_ALLOC_PTR(type->typ_dt_ops); OBD_ALLOC_PTR(type->typ_md_ops); @@ -213,7 +213,7 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, list_add(&type->typ_chain, &obd_types); spin_unlock(&obd_types_lock); - RETURN (0); + return 0; failed: if (type->typ_name != NULL) @@ -223,7 +223,7 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, if (type->typ_dt_ops != NULL) OBD_FREE_PTR(type->typ_dt_ops); OBD_FREE(type, sizeof(*type)); - RETURN(rc); + return rc; } EXPORT_SYMBOL(class_register_type); @@ -233,7 +233,7 @@ int class_unregister_type(const char *name) if (!type) { CERROR("unknown obd type\n"); - RETURN(-EINVAL); + return -EINVAL; } if (type->typ_refcnt) { @@ -242,7 +242,7 @@ int class_unregister_type(const char *name) /* Remove ops, but leave the name for debugging */ OBD_FREE_PTR(type->typ_dt_ops); OBD_FREE_PTR(type->typ_md_ops); - RETURN(-EBUSY); + return -EBUSY; } if (type->typ_procroot) { @@ -261,7 +261,7 @@ int class_unregister_type(const char *name) if (type->typ_md_ops != NULL) OBD_FREE_PTR(type->typ_md_ops); OBD_FREE(type, sizeof(*type)); - RETURN(0); + return 0; } /* class_unregister_type */ EXPORT_SYMBOL(class_unregister_type); @@ -286,13 +286,13 @@ struct obd_device *class_newdev(const char *type_name, const char *name) if (strlen(name) >= MAX_OBD_NAME) { CERROR("name/uuid must be < %u bytes long\n", MAX_OBD_NAME); - RETURN(ERR_PTR(-EINVAL)); + return ERR_PTR(-EINVAL); } type = class_get_type(type_name); if (type == NULL){ CERROR("OBD: unknown type: %s\n", type_name); - RETURN(ERR_PTR(-ENODEV)); + return ERR_PTR(-ENODEV); } newdev = obd_device_alloc(); @@ -346,7 +346,7 @@ struct obd_device *class_newdev(const char *type_name, const char *name) CDEBUG(D_IOCTL, "Adding new device %s (%p)\n", result->obd_name, result); - RETURN(result); + return result; out: obd_device_free(newdev); out_type: @@ -678,10 +678,10 @@ int obd_init_caches(void) if (!capa_cachep) GOTO(out, -ENOMEM); - RETURN(0); + return 0; out: obd_cleanup_caches(); - RETURN(-ENOMEM); + return -ENOMEM; } @@ -692,17 +692,17 @@ struct obd_export *class_conn2export(struct lustre_handle *conn) if (!conn) { CDEBUG(D_CACHE, "looking for null handle\n"); - RETURN(NULL); + return NULL; } if (conn->cookie == -1) { /* this means assign a new connection */ CDEBUG(D_CACHE, "want a new connection\n"); - RETURN(NULL); + return NULL; } CDEBUG(D_INFO, "looking for export cookie "LPX64"\n", conn->cookie); export = class_handle2object(conn->cookie); - RETURN(export); + return export; } EXPORT_SYMBOL(class_conn2export); @@ -888,7 +888,7 @@ struct obd_export *class_new_export(struct obd_device *obd, export->exp_obd->obd_num_exports++; spin_unlock(&obd->obd_dev_lock); cfs_hash_putref(hash); - RETURN(export); + return export; exit_unlock: spin_unlock(&obd->obd_dev_lock); @@ -1107,14 +1107,14 @@ int class_connect(struct lustre_handle *conn, struct obd_device *obd, export = class_new_export(obd, cluuid); if (IS_ERR(export)) - RETURN(PTR_ERR(export)); + return PTR_ERR(export); conn->cookie = export->exp_handle.h_cookie; class_export_put(export); CDEBUG(D_IOCTL, "connect: client %s, cookie "LPX64"\n", cluuid->uuid, conn->cookie); - RETURN(0); + return 0; } EXPORT_SYMBOL(class_connect); @@ -1173,7 +1173,7 @@ int class_disconnect(struct obd_export *export) if (export == NULL) { CWARN("attempting to free NULL export %p\n", export); - RETURN(-EINVAL); + return -EINVAL; } spin_lock(&export->exp_lock); @@ -1201,7 +1201,7 @@ int class_disconnect(struct obd_export *export) class_unlink_export(export); no_disconn: class_export_put(export); - RETURN(0); + return 0; } EXPORT_SYMBOL(class_disconnect); @@ -1622,7 +1622,7 @@ static int obd_zombie_impexp_check(void *arg) !test_bit(OBD_ZOMBIE_STOP, &obd_zombie_flags); spin_unlock(&obd_zombie_impexp_lock); - RETURN(rc); + return rc; } /** @@ -1724,7 +1724,7 @@ static int obd_zombie_impexp_thread(void *unused) complete(&obd_zombie_stop); - RETURN(0); + return 0; } @@ -1745,10 +1745,10 @@ int obd_zombie_impexp_init(void) task = kthread_run(obd_zombie_impexp_thread, NULL, "obd_zombid"); if (IS_ERR(task)) - RETURN(PTR_ERR(task)); + return PTR_ERR(task); wait_for_completion(&obd_zombie_start); - RETURN(0); + return 0; } /** * stop destroy zombie import/export thread diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c index 95de95e628be1..d1a57ebfda95d 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c @@ -86,23 +86,23 @@ int obd_ioctl_getdata(char **buf, int *len, void *arg) err = copy_from_user(&hdr, (void *)arg, sizeof(hdr)); if ( err ) - RETURN(err); + return err; if (hdr.ioc_version != OBD_IOCTL_VERSION) { CERROR("Version mismatch kernel (%x) vs application (%x)\n", OBD_IOCTL_VERSION, hdr.ioc_version); - RETURN(-EINVAL); + return -EINVAL; } if (hdr.ioc_len > OBD_MAX_IOCTL_BUFFER) { CERROR("User buffer len %d exceeds %d max buffer\n", hdr.ioc_len, OBD_MAX_IOCTL_BUFFER); - RETURN(-EINVAL); + return -EINVAL; } if (hdr.ioc_len < sizeof(struct obd_ioctl_data)) { CERROR("User buffer too small for ioctl (%d)\n", hdr.ioc_len); - RETURN(-EINVAL); + return -EINVAL; } /* When there are lots of processes calling vmalloc on multi-core @@ -113,7 +113,7 @@ int obd_ioctl_getdata(char **buf, int *len, void *arg) if (*buf == NULL) { CERROR("Cannot allocate control buffer of len %d\n", hdr.ioc_len); - RETURN(-EINVAL); + return -EINVAL; } *len = hdr.ioc_len; data = (struct obd_ioctl_data *)*buf; @@ -121,13 +121,13 @@ int obd_ioctl_getdata(char **buf, int *len, void *arg) err = copy_from_user(*buf, (void *)arg, hdr.ioc_len); if ( err ) { OBD_FREE_LARGE(*buf, hdr.ioc_len); - RETURN(err); + return err; } if (obd_ioctl_is_invalid(data)) { CERROR("ioctl not correctly formatted\n"); OBD_FREE_LARGE(*buf, hdr.ioc_len); - RETURN(-EINVAL); + return -EINVAL; } if (data->ioc_inllen1) { @@ -168,14 +168,14 @@ EXPORT_SYMBOL(obd_ioctl_popdata); static int obd_class_open(struct inode * inode, struct file * file) { try_module_get(THIS_MODULE); - RETURN(0); + return 0; } /* closing /dev/obd */ static int obd_class_release(struct inode * inode, struct file * file) { module_put(THIS_MODULE); - RETURN(0); + return 0; } /* to control /dev/obd */ @@ -186,13 +186,13 @@ static long obd_class_ioctl(struct file *filp, unsigned int cmd, /* Allow non-root access for OBD_IOC_PING_TARGET - used by lfs check */ if (!cfs_capable(CFS_CAP_SYS_ADMIN) && (cmd != OBD_IOC_PING_TARGET)) - RETURN(err = -EACCES); + return err = -EACCES; if ((cmd & 0xffffff00) == ((int)'T') << 8) /* ignore all tty ioctls */ - RETURN(err = -ENOTTY); + return err = -ENOTTY; err = class_handle_ioctl(cmd, (unsigned long)arg); - RETURN(err); + return err; } /* declare character device */ @@ -394,7 +394,7 @@ int class_procfs_init(void) out: if (rc) CERROR("error adding /proc/fs/lustre/devices file\n"); - RETURN(0); + return 0; } int class_procfs_clean(void) @@ -402,5 +402,5 @@ int class_procfs_clean(void) if (proc_lustre_root) { lprocfs_remove(&proc_lustre_root); } - RETURN(0); + return 0; } diff --git a/drivers/staging/lustre/lustre/obdclass/llog.c b/drivers/staging/lustre/lustre/obdclass/llog.c index a154cc5e57538..0cb44287502b7 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog.c +++ b/drivers/staging/lustre/lustre/obdclass/llog.c @@ -117,14 +117,14 @@ int llog_cancel_rec(const struct lu_env *env, struct llog_handle *loghandle, if (index == 0) { CERROR("Can't cancel index 0 which is header\n"); - RETURN(-EINVAL); + return -EINVAL; } spin_lock(&loghandle->lgh_hdr_lock); if (!ext2_clear_bit(index, llh->llh_bitmap)) { spin_unlock(&loghandle->lgh_hdr_lock); CDEBUG(D_RPCTRACE, "Catalog index %u already clear?\n", index); - RETURN(-ENOENT); + return -ENOENT; } llh->llh_count--; @@ -142,7 +142,7 @@ int llog_cancel_rec(const struct lu_env *env, struct llog_handle *loghandle, loghandle->lgh_id.lgl_ogen, rc); GOTO(out_err, rc); } - RETURN(1); + return 1; } spin_unlock(&loghandle->lgh_hdr_lock); @@ -155,7 +155,7 @@ int llog_cancel_rec(const struct lu_env *env, struct llog_handle *loghandle, loghandle->lgh_id.lgl_ogen, rc); GOTO(out_err, rc); } - RETURN(0); + return 0; out_err: spin_lock(&loghandle->lgh_hdr_lock); ext2_set_bit(index, llh->llh_bitmap); @@ -174,10 +174,10 @@ static int llog_read_header(const struct lu_env *env, rc = llog_handle2ops(handle, &lop); if (rc) - RETURN(rc); + return rc; if (lop->lop_read_header == NULL) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; rc = lop->lop_read_header(env, handle); if (rc == LLOG_EEMPTY) { @@ -209,7 +209,7 @@ int llog_init_handle(const struct lu_env *env, struct llog_handle *handle, OBD_ALLOC_PTR(llh); if (llh == NULL) - RETURN(-ENOMEM); + return -ENOMEM; handle->lgh_hdr = llh; /* first assign flags to use llog_client_ops */ llh->llh_flags = flags; @@ -261,7 +261,7 @@ int llog_init_handle(const struct lu_env *env, struct llog_handle *handle, OBD_FREE_PTR(llh); handle->lgh_hdr = NULL; } - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_init_handle); @@ -286,7 +286,7 @@ int llog_copy_handler(const struct lu_env *env, rec->lrh_index, rc, rec->lrh_len, lcfg->lcfg_command, lustre_cfg_string(lcfg, 0), lustre_cfg_string(lcfg, 1)); - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_copy_handler); @@ -308,7 +308,7 @@ static int llog_process_thread(void *arg) OBD_ALLOC(buf, LLOG_CHUNK_SIZE); if (!buf) { lpi->lpi_rc = -ENOMEM; - RETURN(0); + return 0; } if (cd != NULL) { @@ -455,7 +455,7 @@ int llog_process_or_fork(const struct lu_env *env, OBD_ALLOC_PTR(lpi); if (lpi == NULL) { CERROR("cannot alloc pointer\n"); - RETURN(-ENOMEM); + return -ENOMEM; } lpi->lpi_loghandle = loghandle; lpi->lpi_cb = cb; @@ -473,7 +473,7 @@ int llog_process_or_fork(const struct lu_env *env, CERROR("%s: cannot start thread: rc = %d\n", loghandle->lgh_ctxt->loc_obd->obd_name, rc); OBD_FREE_PTR(lpi); - RETURN(rc); + return rc; } wait_for_completion(&lpi->lpi_completion); } else { @@ -482,7 +482,7 @@ int llog_process_or_fork(const struct lu_env *env, } rc = lpi->lpi_rc; OBD_FREE_PTR(lpi); - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_process_or_fork); @@ -512,7 +512,7 @@ int llog_reverse_process(const struct lu_env *env, OBD_ALLOC(buf, LLOG_CHUNK_SIZE); if (!buf) - RETURN(-ENOMEM); + return -ENOMEM; if (cd != NULL) first_index = cd->lpcd_first_idx + 1; @@ -586,7 +586,7 @@ int llog_reverse_process(const struct lu_env *env, out: if (buf) OBD_FREE(buf, LLOG_CHUNK_SIZE); - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_reverse_process); @@ -611,12 +611,12 @@ int llog_exist(struct llog_handle *loghandle) rc = llog_handle2ops(loghandle, &lop); if (rc) - RETURN(rc); + return rc; if (lop->lop_exist == NULL) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; rc = lop->lop_exist(loghandle); - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_exist); @@ -628,9 +628,9 @@ int llog_declare_create(const struct lu_env *env, rc = llog_handle2ops(loghandle, &lop); if (rc) - RETURN(rc); + return rc; if (lop->lop_declare_create == NULL) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; raised = cfs_cap_raised(CFS_CAP_SYS_RESOURCE); if (!raised) @@ -638,7 +638,7 @@ int llog_declare_create(const struct lu_env *env, rc = lop->lop_declare_create(env, loghandle, th); if (!raised) cfs_cap_lower(CFS_CAP_SYS_RESOURCE); - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_declare_create); @@ -650,9 +650,9 @@ int llog_create(const struct lu_env *env, struct llog_handle *handle, rc = llog_handle2ops(handle, &lop); if (rc) - RETURN(rc); + return rc; if (lop->lop_create == NULL) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; raised = cfs_cap_raised(CFS_CAP_SYS_RESOURCE); if (!raised) @@ -660,7 +660,7 @@ int llog_create(const struct lu_env *env, struct llog_handle *handle, rc = lop->lop_create(env, handle, th); if (!raised) cfs_cap_lower(CFS_CAP_SYS_RESOURCE); - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_create); @@ -674,10 +674,10 @@ int llog_declare_write_rec(const struct lu_env *env, rc = llog_handle2ops(handle, &lop); if (rc) - RETURN(rc); + return rc; LASSERT(lop); if (lop->lop_declare_write_rec == NULL) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; raised = cfs_cap_raised(CFS_CAP_SYS_RESOURCE); if (!raised) @@ -685,7 +685,7 @@ int llog_declare_write_rec(const struct lu_env *env, rc = lop->lop_declare_write_rec(env, handle, rec, idx, th); if (!raised) cfs_cap_lower(CFS_CAP_SYS_RESOURCE); - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_declare_write_rec); @@ -698,11 +698,11 @@ int llog_write_rec(const struct lu_env *env, struct llog_handle *handle, rc = llog_handle2ops(handle, &lop); if (rc) - RETURN(rc); + return rc; LASSERT(lop); if (lop->lop_write_rec == NULL) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; if (buf) buflen = rec->lrh_len + sizeof(struct llog_rec_hdr) + @@ -718,7 +718,7 @@ int llog_write_rec(const struct lu_env *env, struct llog_handle *handle, buf, idx, th); if (!raised) cfs_cap_lower(CFS_CAP_SYS_RESOURCE); - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_write_rec); @@ -729,7 +729,7 @@ int llog_add(const struct lu_env *env, struct llog_handle *lgh, int raised, rc; if (lgh->lgh_logops->lop_add == NULL) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; raised = cfs_cap_raised(CFS_CAP_SYS_RESOURCE); if (!raised) @@ -737,7 +737,7 @@ int llog_add(const struct lu_env *env, struct llog_handle *lgh, rc = lgh->lgh_logops->lop_add(env, lgh, rec, logcookies, buf, th); if (!raised) cfs_cap_lower(CFS_CAP_SYS_RESOURCE); - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_add); @@ -747,7 +747,7 @@ int llog_declare_add(const struct lu_env *env, struct llog_handle *lgh, int raised, rc; if (lgh->lgh_logops->lop_declare_add == NULL) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; raised = cfs_cap_raised(CFS_CAP_SYS_RESOURCE); if (!raised) @@ -755,7 +755,7 @@ int llog_declare_add(const struct lu_env *env, struct llog_handle *lgh, rc = lgh->lgh_logops->lop_declare_add(env, lgh, rec, th); if (!raised) cfs_cap_lower(CFS_CAP_SYS_RESOURCE); - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_declare_add); @@ -772,10 +772,10 @@ int llog_open_create(const struct lu_env *env, struct llog_ctxt *ctxt, rc = llog_open(env, ctxt, res, logid, name, LLOG_OPEN_NEW); if (rc) - RETURN(rc); + return rc; if (llog_exist(*res)) - RETURN(0); + return 0; if ((*res)->lgh_obj != NULL) { struct dt_device *d; @@ -801,7 +801,7 @@ int llog_open_create(const struct lu_env *env, struct llog_ctxt *ctxt, out: if (rc) llog_close(env, *res); - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_open_create); @@ -816,11 +816,11 @@ int llog_erase(const struct lu_env *env, struct llog_ctxt *ctxt, /* nothing to erase */ if (name == NULL && logid == NULL) - RETURN(0); + return 0; rc = llog_open(env, ctxt, &handle, logid, name, LLOG_OPEN_EXISTS); if (rc < 0) - RETURN(rc); + return rc; rc = llog_init_handle(env, handle, LLOG_F_IS_PLAIN, NULL); if (rc == 0) @@ -829,7 +829,7 @@ int llog_erase(const struct lu_env *env, struct llog_ctxt *ctxt, rc2 = llog_close(env, handle); if (rc == 0) rc = rc2; - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_erase); @@ -855,7 +855,7 @@ int llog_write(const struct lu_env *env, struct llog_handle *loghandle, th = dt_trans_create(env, dt); if (IS_ERR(th)) - RETURN(PTR_ERR(th)); + return PTR_ERR(th); rc = llog_declare_write_rec(env, loghandle, rec, idx, th); if (rc) @@ -877,7 +877,7 @@ int llog_write(const struct lu_env *env, struct llog_handle *loghandle, cookiecount, buf, idx, NULL); up_write(&loghandle->lgh_lock); } - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_write); @@ -893,12 +893,12 @@ int llog_open(const struct lu_env *env, struct llog_ctxt *ctxt, if (ctxt->loc_logops->lop_open == NULL) { *lgh = NULL; - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; } *lgh = llog_alloc_handle(); if (*lgh == NULL) - RETURN(-ENOMEM); + return -ENOMEM; (*lgh)->lgh_ctxt = ctxt; (*lgh)->lgh_logops = ctxt->loc_logops; @@ -912,7 +912,7 @@ int llog_open(const struct lu_env *env, struct llog_ctxt *ctxt, llog_free_handle(*lgh); *lgh = NULL; } - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_open); @@ -929,6 +929,6 @@ int llog_close(const struct lu_env *env, struct llog_handle *loghandle) rc = lop->lop_close(env, loghandle); out: llog_handle_put(loghandle); - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_close); diff --git a/drivers/staging/lustre/lustre/obdclass/llog_cat.c b/drivers/staging/lustre/lustre/obdclass/llog_cat.c index 020af54e68af1..c0f3af7257479 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_cat.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_cat.c @@ -76,20 +76,20 @@ static int llog_cat_new_log(const struct lu_env *env, /* maximum number of available slots in catlog is bitmap_size - 2 */ if (llh->llh_cat_idx == index) { CERROR("no free catalog slots for log...\n"); - RETURN(-ENOSPC); + return -ENOSPC; } if (OBD_FAIL_CHECK(OBD_FAIL_MDS_LLOG_CREATE_FAILED)) - RETURN(-ENOSPC); + return -ENOSPC; rc = llog_create(env, loghandle, th); /* if llog is already created, no need to initialize it */ if (rc == -EEXIST) { - RETURN(0); + return 0; } else if (rc != 0) { CERROR("%s: can't create new plain llog in catalog: rc = %d\n", loghandle->lgh_ctxt->loc_obd->obd_name, rc); - RETURN(rc); + return rc; } rc = llog_init_handle(env, loghandle, @@ -133,10 +133,10 @@ static int llog_cat_new_log(const struct lu_env *env, GOTO(out_destroy, rc); loghandle->lgh_hdr->llh_cat_idx = index; - RETURN(0); + return 0; out_destroy: llog_destroy(env, loghandle); - RETURN(rc); + return rc; } /* Open an existent log handle and add it to the open list. @@ -155,7 +155,7 @@ int llog_cat_id2handle(const struct lu_env *env, struct llog_handle *cathandle, int rc = 0; if (cathandle == NULL) - RETURN(-EBADF); + return -EBADF; down_write(&cathandle->lgh_lock); list_for_each_entry(loghandle, &cathandle->u.chd.chd_head, @@ -184,14 +184,14 @@ int llog_cat_id2handle(const struct lu_env *env, struct llog_handle *cathandle, CERROR("%s: error opening log id "DOSTID":%x: rc = %d\n", cathandle->lgh_ctxt->loc_obd->obd_name, POSTID(&logid->lgl_oi), logid->lgl_ogen, rc); - RETURN(rc); + return rc; } rc = llog_init_handle(env, loghandle, LLOG_F_IS_PLAIN, NULL); if (rc < 0) { llog_close(env, loghandle); loghandle = NULL; - RETURN(rc); + return rc; } down_write(&cathandle->lgh_lock); @@ -240,7 +240,7 @@ int llog_cat_close(const struct lu_env *env, struct llog_handle *cathandle) if (cathandle->lgh_ctxt->loc_handle == cathandle) cathandle->lgh_ctxt->loc_handle = NULL; rc = llog_close(env, cathandle); - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_cat_close); @@ -277,7 +277,7 @@ static struct llog_handle *llog_cat_current_log(struct llog_handle *cathandle, if (llh == NULL || loghandle->lgh_last_idx < LLOG_BITMAP_SIZE(llh) - 1) { up_read(&cathandle->lgh_lock); - RETURN(loghandle); + return loghandle; } else { up_write(&loghandle->lgh_lock); } @@ -297,7 +297,7 @@ static struct llog_handle *llog_cat_current_log(struct llog_handle *cathandle, LASSERT(llh); if (loghandle->lgh_last_idx < LLOG_BITMAP_SIZE(llh) - 1) { up_write(&cathandle->lgh_lock); - RETURN(loghandle); + return loghandle; } else { up_write(&loghandle->lgh_lock); } @@ -311,7 +311,7 @@ static struct llog_handle *llog_cat_current_log(struct llog_handle *cathandle, down_write_nested(&loghandle->lgh_lock, LLOGH_LOG); up_write(&cathandle->lgh_lock); LASSERT(loghandle); - RETURN(loghandle); + return loghandle; } /* Add a single record to the recovery log(s) using a catalog @@ -335,7 +335,7 @@ int llog_cat_add_rec(const struct lu_env *env, struct llog_handle *cathandle, rc = llog_cat_new_log(env, cathandle, loghandle, th); if (rc < 0) { up_write(&loghandle->lgh_lock); - RETURN(rc); + return rc; } } /* now let's try to add the record */ @@ -353,7 +353,7 @@ int llog_cat_add_rec(const struct lu_env *env, struct llog_handle *cathandle, rc = llog_cat_new_log(env, cathandle, loghandle, th); if (rc < 0) { up_write(&loghandle->lgh_lock); - RETURN(rc); + return rc; } } /* now let's try to add the record */ @@ -364,7 +364,7 @@ int llog_cat_add_rec(const struct lu_env *env, struct llog_handle *cathandle, up_write(&loghandle->lgh_lock); } - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_cat_add_rec); @@ -427,7 +427,7 @@ int llog_cat_declare_add_rec(const struct lu_env *env, llog_declare_write_rec(env, next, rec, -1, th); } out: - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_cat_declare_add_rec); @@ -450,7 +450,7 @@ int llog_cat_add(const struct lu_env *env, struct llog_handle *cathandle, th = dt_trans_create(env, dt); if (IS_ERR(th)) - RETURN(PTR_ERR(th)); + return PTR_ERR(th); rc = llog_cat_declare_add_rec(env, cathandle, rec, th); if (rc) @@ -469,7 +469,7 @@ int llog_cat_add(const struct lu_env *env, struct llog_handle *cathandle, rc = llog_cat_add_rec(env, cathandle, rec, reccookie, buf, th); } - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_cat_add); @@ -521,7 +521,7 @@ int llog_cat_cancel_records(const struct lu_env *env, cathandle->lgh_ctxt->loc_obd->obd_name, failed, count, rc); - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_cat_cancel_records); @@ -535,7 +535,7 @@ int llog_cat_process_cb(const struct lu_env *env, struct llog_handle *cat_llh, if (rec->lrh_type != LLOG_LOGID_MAGIC) { CERROR("invalid record in catalog\n"); - RETURN(-EINVAL); + return -EINVAL; } CDEBUG(D_HA, "processing log "DOSTID":%x at index %u of catalog " DOSTID"\n", POSTID(&lir->lid_id.lgl_oi), lir->lid_id.lgl_ogen, @@ -546,12 +546,12 @@ int llog_cat_process_cb(const struct lu_env *env, struct llog_handle *cat_llh, CERROR("%s: cannot find handle for llog "DOSTID": %d\n", cat_llh->lgh_ctxt->loc_obd->obd_name, POSTID(&lir->lid_id.lgl_oi), rc); - RETURN(rc); + return rc; } if (rec->lrh_index < d->lpd_startcat) /* Skip processing of the logs until startcat */ - RETURN(0); + return 0; if (d->lpd_startidx > 0) { struct llog_process_cat_data cd; @@ -568,7 +568,7 @@ int llog_cat_process_cb(const struct lu_env *env, struct llog_handle *cat_llh, } llog_handle_put(llh); - RETURN(rc); + return rc; } int llog_cat_process_or_fork(const struct lu_env *env, @@ -597,7 +597,7 @@ int llog_cat_process_or_fork(const struct lu_env *env, rc = llog_process_or_fork(env, cat_llh, llog_cat_process_cb, &d, &cd, fork); if (rc != 0) - RETURN(rc); + return rc; cd.lpcd_first_idx = 0; cd.lpcd_last_idx = cat_llh->lgh_last_idx; @@ -608,7 +608,7 @@ int llog_cat_process_or_fork(const struct lu_env *env, &d, NULL, fork); } - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_cat_process_or_fork); @@ -631,7 +631,7 @@ static int llog_cat_reverse_process_cb(const struct lu_env *env, if (le32_to_cpu(rec->lrh_type) != LLOG_LOGID_MAGIC) { CERROR("invalid record in catalog\n"); - RETURN(-EINVAL); + return -EINVAL; } CDEBUG(D_HA, "processing log "DOSTID":%x at index %u of catalog " DOSTID"\n", POSTID(&lir->lid_id.lgl_oi), lir->lid_id.lgl_ogen, @@ -642,12 +642,12 @@ static int llog_cat_reverse_process_cb(const struct lu_env *env, CERROR("%s: cannot find handle for llog "DOSTID": %d\n", cat_llh->lgh_ctxt->loc_obd->obd_name, POSTID(&lir->lid_id.lgl_oi), rc); - RETURN(rc); + return rc; } rc = llog_reverse_process(env, llh, d->lpd_cb, d->lpd_data, NULL); llog_handle_put(llh); - RETURN(rc); + return rc; } int llog_cat_reverse_process(const struct lu_env *env, @@ -673,7 +673,7 @@ int llog_cat_reverse_process(const struct lu_env *env, llog_cat_reverse_process_cb, &d, &cd); if (rc != 0) - RETURN(rc); + return rc; cd.lpcd_first_idx = le32_to_cpu(llh->llh_cat_idx); cd.lpcd_last_idx = 0; @@ -686,7 +686,7 @@ int llog_cat_reverse_process(const struct lu_env *env, &d, NULL); } - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_cat_reverse_process); @@ -718,7 +718,7 @@ int llog_cat_set_first_idx(struct llog_handle *cathandle, int index) POSTID(&cathandle->lgh_id.lgl_oi), llh->llh_cat_idx); } - RETURN(0); + return 0; } /* Cleanup deleted plain llog traces from catalog */ @@ -760,7 +760,7 @@ int cat_cancel_cb(const struct lu_env *env, struct llog_handle *cathandle, if (rec->lrh_type != LLOG_LOGID_MAGIC) { CERROR("invalid record in catalog\n"); - RETURN(-EINVAL); + return -EINVAL; } CDEBUG(D_HA, "processing log "DOSTID":%x at index %u of catalog " @@ -776,7 +776,7 @@ int cat_cancel_cb(const struct lu_env *env, struct llog_handle *cathandle, /* remove index from catalog */ llog_cat_cleanup(env, cathandle, NULL, rec->lrh_index); } - RETURN(rc); + return rc; } llh = loghandle->lgh_hdr; @@ -792,7 +792,7 @@ int cat_cancel_cb(const struct lu_env *env, struct llog_handle *cathandle, } llog_handle_put(loghandle); - RETURN(rc); + return rc; } EXPORT_SYMBOL(cat_cancel_cb); @@ -804,12 +804,12 @@ int llog_cat_init_and_process(const struct lu_env *env, rc = llog_init_handle(env, llh, LLOG_F_IS_CAT, NULL); if (rc) - RETURN(rc); + return rc; rc = llog_process_or_fork(env, llh, cat_cancel_cb, NULL, NULL, false); if (rc) CERROR("%s: llog_process() with cat_cancel_cb failed: rc = " "%d\n", llh->lgh_ctxt->loc_obd->obd_name, rc); - RETURN(0); + return 0; } EXPORT_SYMBOL(llog_cat_init_and_process); diff --git a/drivers/staging/lustre/lustre/obdclass/llog_ioctl.c b/drivers/staging/lustre/lustre/obdclass/llog_ioctl.c index 1c83ec217ad5e..da558a5dc92b6 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_ioctl.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_ioctl.c @@ -47,43 +47,43 @@ static int str2logid(struct llog_logid *logid, char *str, int len) start = str; if (*start != '#') - RETURN(-EINVAL); + return -EINVAL; start++; if (start - str >= len - 1) - RETURN(-EINVAL); + return -EINVAL; end = strchr(start, '#'); if (end == NULL || end == start) - RETURN(-EINVAL); + return -EINVAL; *end = '\0'; id = simple_strtoull(start, &endp, 0); if (endp != end) - RETURN(-EINVAL); + return -EINVAL; start = ++end; if (start - str >= len - 1) - RETURN(-EINVAL); + return -EINVAL; end = strchr(start, '#'); if (end == NULL || end == start) - RETURN(-EINVAL); + return -EINVAL; *end = '\0'; seq = simple_strtoull(start, &endp, 0); if (endp != end) - RETURN(-EINVAL); + return -EINVAL; ostid_set_seq(&logid->lgl_oi, seq); ostid_set_id(&logid->lgl_oi, id); start = ++end; if (start - str >= len - 1) - RETURN(-EINVAL); + return -EINVAL; logid->lgl_ogen = simple_strtoul(start, &endp, 16); if (*endp != '\0') - RETURN(-EINVAL); + return -EINVAL; - RETURN(0); + return 0; } static int llog_check_cb(const struct lu_env *env, struct llog_handle *handle, @@ -103,19 +103,19 @@ static int llog_check_cb(const struct lu_env *env, struct llog_handle *handle, cfs_size_round(ioc_data->ioc_inllen3); from = simple_strtol(ioc_data->ioc_inlbuf2, &endp, 0); if (*endp != '\0') - RETURN(-EINVAL); + return -EINVAL; to = simple_strtol(ioc_data->ioc_inlbuf3, &endp, 0); if (*endp != '\0') - RETURN(-EINVAL); + return -EINVAL; ioc_data->ioc_inllen1 = 0; out = ioc_data->ioc_bulk; } cur_index = rec->lrh_index; if (cur_index < from) - RETURN(0); + return 0; if (to > 0 && cur_index > to) - RETURN(-LLOG_EEMPTY); + return -LLOG_EEMPTY; if (handle->lgh_hdr->llh_flags & LLOG_F_IS_CAT) { struct llog_logid_rec *lir = (struct llog_logid_rec *)rec; @@ -128,13 +128,13 @@ static int llog_check_cb(const struct lu_env *env, struct llog_handle *handle, rec->lrh_len); } if (handle->lgh_ctxt == NULL) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; rc = llog_cat_id2handle(env, handle, &loghandle, &lir->lid_id); if (rc) { CDEBUG(D_IOCTL, "cannot find log #"DOSTID"#%08x\n", POSTID(&lir->lid_id.lgl_oi), lir->lid_id.lgl_ogen); - RETURN(rc); + return rc; } rc = llog_process(env, loghandle, llog_check_cb, NULL, NULL); llog_handle_put(loghandle); @@ -164,10 +164,10 @@ static int llog_check_cb(const struct lu_env *env, struct llog_handle *handle, if (remains <= 0) { CERROR("%s: no space to print log records\n", handle->lgh_ctxt->loc_obd->obd_name); - RETURN(-LLOG_EEMPTY); + return -LLOG_EEMPTY; } } - RETURN(rc); + return rc; } static int llog_print_cb(const struct lu_env *env, struct llog_handle *handle, @@ -187,26 +187,26 @@ static int llog_print_cb(const struct lu_env *env, struct llog_handle *handle, cfs_size_round(ioc_data->ioc_inllen3); from = simple_strtol(ioc_data->ioc_inlbuf2, &endp, 0); if (*endp != '\0') - RETURN(-EINVAL); + return -EINVAL; to = simple_strtol(ioc_data->ioc_inlbuf3, &endp, 0); if (*endp != '\0') - RETURN(-EINVAL); + return -EINVAL; out = ioc_data->ioc_bulk; ioc_data->ioc_inllen1 = 0; } cur_index = rec->lrh_index; if (cur_index < from) - RETURN(0); + return 0; if (to > 0 && cur_index > to) - RETURN(-LLOG_EEMPTY); + return -LLOG_EEMPTY; if (handle->lgh_hdr->llh_flags & LLOG_F_IS_CAT) { struct llog_logid_rec *lir = (struct llog_logid_rec *)rec; if (rec->lrh_type != LLOG_LOGID_MAGIC) { CERROR("invalid record in catalog\n"); - RETURN(-EINVAL); + return -EINVAL; } l = snprintf(out, remains, @@ -218,7 +218,7 @@ static int llog_print_cb(const struct lu_env *env, struct llog_handle *handle, rc = class_config_parse_rec(rec, out, remains); if (rc < 0) - RETURN(rc); + return rc; l = rc; } else { l = snprintf(out, remains, @@ -229,10 +229,10 @@ static int llog_print_cb(const struct lu_env *env, struct llog_handle *handle, remains -= l; if (remains <= 0) { CERROR("not enough space for print log records\n"); - RETURN(-LLOG_EEMPTY); + return -LLOG_EEMPTY; } - RETURN(0); + return 0; } static int llog_remove_log(const struct lu_env *env, struct llog_handle *cat, struct llog_logid *logid) @@ -244,7 +244,7 @@ static int llog_remove_log(const struct lu_env *env, struct llog_handle *cat, if (rc) { CDEBUG(D_IOCTL, "cannot find log #"DOSTID"#%08x\n", POSTID(&logid->lgl_oi), logid->lgl_ogen); - RETURN(-ENOENT); + return -ENOENT; } rc = llog_destroy(env, log); @@ -255,7 +255,7 @@ static int llog_remove_log(const struct lu_env *env, struct llog_handle *cat, llog_cat_cleanup(env, cat, log, log->u.phd.phd_cookie.lgc_index); out: llog_handle_put(log); - RETURN(rc); + return rc; } @@ -266,10 +266,10 @@ static int llog_delete_cb(const struct lu_env *env, struct llog_handle *handle, int rc; if (rec->lrh_type != LLOG_LOGID_MAGIC) - RETURN(-EINVAL); + return -EINVAL; rc = llog_remove_log(env, handle, &lir->lid_id); - RETURN(rc); + return rc; } @@ -283,20 +283,20 @@ int llog_ioctl(const struct lu_env *env, struct llog_ctxt *ctxt, int cmd, if (*data->ioc_inlbuf1 == '#') { rc = str2logid(&logid, data->ioc_inlbuf1, data->ioc_inllen1); if (rc) - RETURN(rc); + return rc; rc = llog_open(env, ctxt, &handle, &logid, NULL, LLOG_OPEN_EXISTS); if (rc) - RETURN(rc); + return rc; } else if (*data->ioc_inlbuf1 == '$') { char *name = data->ioc_inlbuf1 + 1; rc = llog_open(env, ctxt, &handle, NULL, name, LLOG_OPEN_EXISTS); if (rc) - RETURN(rc); + return rc; } else { - RETURN(-EINVAL); + return -EINVAL; } rc = llog_init_handle(env, handle, 0, NULL); @@ -413,6 +413,6 @@ int llog_ioctl(const struct lu_env *env, struct llog_ctxt *ctxt, int cmd, llog_cat_close(env, handle); else llog_close(env, handle); - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_ioctl); diff --git a/drivers/staging/lustre/lustre/obdclass/llog_lvfs.c b/drivers/staging/lustre/lustre/obdclass/llog_lvfs.c index 6543ba9b9e3db..5385d8e658cff 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_lvfs.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_lvfs.c @@ -85,7 +85,7 @@ static int llog_lvfs_pad(struct obd_device *obd, struct l_file *file, } out: - RETURN(rc); + return rc; } static int llog_lvfs_write_blob(struct obd_device *obd, struct l_file *file, @@ -137,7 +137,7 @@ static int llog_lvfs_write_blob(struct obd_device *obd, struct l_file *file, if (saved_off > file->f_pos) file->f_pos = saved_off; LASSERT(rc <= 0); - RETURN(rc); + return rc; } static int llog_lvfs_read_blob(struct obd_device *obd, struct l_file *file, @@ -149,9 +149,9 @@ static int llog_lvfs_read_blob(struct obd_device *obd, struct l_file *file, rc = fsfilt_read_record(obd, file, buf, size, &offset); if (rc) { CERROR("error reading log record: rc %d\n", rc); - RETURN(rc); + return rc; } - RETURN(0); + return 0; } static int llog_lvfs_read_header(const struct lu_env *env, @@ -166,7 +166,7 @@ static int llog_lvfs_read_header(const struct lu_env *env, if (i_size_read(handle->lgh_file->f_dentry->d_inode) == 0) { CDEBUG(D_HA, "not reading header from 0-byte log\n"); - RETURN(LLOG_EEMPTY); + return LLOG_EEMPTY; } rc = llog_lvfs_read_blob(obd, handle->lgh_file, handle->lgh_hdr, @@ -201,7 +201,7 @@ static int llog_lvfs_read_header(const struct lu_env *env, handle->lgh_last_idx = handle->lgh_hdr->llh_tail.lrt_index; handle->lgh_file->f_pos = i_size_read(handle->lgh_file->f_dentry->d_inode); - RETURN(rc); + return rc; } /* returns negative in on error; 0 if success && reccookie == 0; 1 otherwise */ @@ -230,7 +230,7 @@ static int llog_lvfs_write_rec(const struct lu_env *env, else rc = (reclen > LLOG_CHUNK_SIZE) ? -E2BIG : 0; if (rc) - RETURN(rc); + return rc; if (buf) /* write_blob adds header and tail to lrh_len. */ @@ -247,7 +247,7 @@ static int llog_lvfs_write_rec(const struct lu_env *env, } if (idx && llh->llh_size && llh->llh_size != rec->lrh_len) - RETURN(-EINVAL); + return -EINVAL; if (!ext2_test_bit(idx, llh->llh_bitmap)) CERROR("Modify unset record %u\n", idx); @@ -257,7 +257,7 @@ static int llog_lvfs_write_rec(const struct lu_env *env, rc = llog_lvfs_write_blob(obd, file, &llh->llh_hdr, NULL, 0); /* we are done if we only write the header or on error */ if (rc || idx == 0) - RETURN(rc); + return rc; if (buf) { /* We assume that caller has set lgh_cur_* */ @@ -271,7 +271,7 @@ static int llog_lvfs_write_rec(const struct lu_env *env, if (rec->lrh_index != loghandle->lgh_cur_idx) { CERROR("modify idx mismatch %u/%d\n", idx, loghandle->lgh_cur_idx); - RETURN(-EFAULT); + return -EFAULT; } } else { /* Assumes constant lrh_len */ @@ -284,7 +284,7 @@ static int llog_lvfs_write_rec(const struct lu_env *env, reccookie->lgc_index = idx; rc = 1; } - RETURN(rc); + return rc; } /* Make sure that records don't cross a chunk boundary, so we can @@ -302,12 +302,12 @@ static int llog_lvfs_write_rec(const struct lu_env *env, index = loghandle->lgh_last_idx + 1; rc = llog_lvfs_pad(obd, file, left, index); if (rc) - RETURN(rc); + return rc; loghandle->lgh_last_idx++; /*for pad rec*/ } /* if it's the last idx in log file, then return -ENOSPC */ if (loghandle->lgh_last_idx >= LLOG_BITMAP_SIZE(llh) - 1) - RETURN(-ENOSPC); + return -ENOSPC; loghandle->lgh_last_idx++; index = loghandle->lgh_last_idx; LASSERT(index < LLOG_BITMAP_SIZE(llh)); @@ -333,11 +333,11 @@ static int llog_lvfs_write_rec(const struct lu_env *env, rc = llog_lvfs_write_blob(obd, file, &llh->llh_hdr, NULL, 0); if (rc) - RETURN(rc); + return rc; rc = llog_lvfs_write_blob(obd, file, rec, buf, file->f_pos); if (rc) - RETURN(rc); + return rc; CDEBUG(D_RPCTRACE, "added record "DOSTID": idx: %u, %u \n", POSTID(&loghandle->lgh_id.lgl_oi), index, rec->lrh_len); @@ -356,7 +356,7 @@ static int llog_lvfs_write_rec(const struct lu_env *env, if (rc == 0 && rec->lrh_type == LLOG_GEN_REC) rc = 1; - RETURN(rc); + return rc; } /* We can skip reading at least as many log blocks as the number of @@ -387,7 +387,7 @@ static int llog_lvfs_next_block(const struct lu_env *env, int rc; if (len == 0 || len & (LLOG_CHUNK_SIZE - 1)) - RETURN(-EINVAL); + return -EINVAL; CDEBUG(D_OTHER, "looking for log index %u (cur idx %u off "LPU64")\n", next_idx, *cur_idx, *cur_offset); @@ -412,7 +412,7 @@ static int llog_lvfs_next_block(const struct lu_env *env, POSTID(&loghandle->lgh_id.lgl_oi), loghandle->lgh_id.lgl_ogen, *cur_offset); - RETURN(rc); + return rc; } /* put number of bytes read into rc to make code simpler */ @@ -423,13 +423,13 @@ static int llog_lvfs_next_block(const struct lu_env *env, } if (rc == 0) /* end of file, nothing to do */ - RETURN(0); + return 0; if (rc < sizeof(*tail)) { CERROR("Invalid llog block at log id "DOSTID"/%u offset" LPU64"\n", POSTID(&loghandle->lgh_id.lgl_oi), loghandle->lgh_id.lgl_ogen, *cur_offset); - RETURN(-EINVAL); + return -EINVAL; } rec = buf; @@ -454,7 +454,7 @@ static int llog_lvfs_next_block(const struct lu_env *env, CERROR("Invalid llog tail at log id "DOSTID"/%u offset " LPU64"\n", POSTID(&loghandle->lgh_id.lgl_oi), loghandle->lgh_id.lgl_ogen, *cur_offset); - RETURN(-EINVAL); + return -EINVAL; } if (tail->lrt_index < next_idx) continue; @@ -464,11 +464,11 @@ static int llog_lvfs_next_block(const struct lu_env *env, if (rec->lrh_index > next_idx) { CERROR("missed desired record? %u > %u\n", rec->lrh_index, next_idx); - RETURN(-ENOENT); + return -ENOENT; } - RETURN(0); + return 0; } - RETURN(-EIO); + return -EIO; } static int llog_lvfs_prev_block(const struct lu_env *env, @@ -479,7 +479,7 @@ static int llog_lvfs_prev_block(const struct lu_env *env, int rc; if (len == 0 || len & (LLOG_CHUNK_SIZE - 1)) - RETURN(-EINVAL); + return -EINVAL; CDEBUG(D_OTHER, "looking for log index %u\n", prev_idx); @@ -500,20 +500,20 @@ static int llog_lvfs_prev_block(const struct lu_env *env, POSTID(&loghandle->lgh_id.lgl_oi), loghandle->lgh_id.lgl_ogen, cur_offset); - RETURN(rc); + return rc; } /* put number of bytes read into rc to make code simpler */ rc = cur_offset - ppos; if (rc == 0) /* end of file, nothing to do */ - RETURN(0); + return 0; if (rc < sizeof(*tail)) { CERROR("Invalid llog block at log id "DOSTID"/%u offset" LPU64"\n", POSTID(&loghandle->lgh_id.lgl_oi), loghandle->lgh_id.lgl_ogen, cur_offset); - RETURN(-EINVAL); + return -EINVAL; } rec = buf; @@ -536,7 +536,7 @@ static int llog_lvfs_prev_block(const struct lu_env *env, CERROR("Invalid llog tail at log id "DOSTID"/%u offset" LPU64"\n", POSTID(&loghandle->lgh_id.lgl_oi), loghandle->lgh_id.lgl_ogen, cur_offset); - RETURN(-EINVAL); + return -EINVAL; } if (tail->lrt_index < prev_idx) continue; @@ -546,11 +546,11 @@ static int llog_lvfs_prev_block(const struct lu_env *env, if (rec->lrh_index > prev_idx) { CERROR("missed desired record? %u > %u\n", rec->lrh_index, prev_idx); - RETURN(-ENOENT); + return -ENOENT; } - RETURN(0); + return 0; } - RETURN(-EIO); + return -EIO; } static struct file *llog_filp_open(char *dir, char *name, int flags, int mode) @@ -651,12 +651,12 @@ static int llog_lvfs_open(const struct lu_env *env, struct llog_handle *handle, if (open_param != LLOG_OPEN_NEW && handle->lgh_file == NULL) GOTO(out_name, rc = -ENOENT); - RETURN(0); + return 0; out_name: if (handle->lgh_name != NULL) OBD_FREE(handle->lgh_name, strlen(name) + 1); out: - RETURN(rc); + return rc; } static int llog_lvfs_exist(struct llog_handle *handle) @@ -687,7 +687,7 @@ static int llog_lvfs_create(const struct lu_env *env, file = llog_filp_open(MOUNT_CONFIGS_DIR, handle->lgh_name, open_flags, 0644); if (IS_ERR(file)) - RETURN(PTR_ERR(file)); + return PTR_ERR(file); lustre_build_llog_lvfs_oid(&handle->lgh_id, file->f_dentry->d_inode->i_ino, @@ -696,7 +696,7 @@ static int llog_lvfs_create(const struct lu_env *env, } else { OBDO_ALLOC(oa); if (oa == NULL) - RETURN(-ENOMEM); + return -ENOMEM; ostid_set_seq_llog(&oa->o_oi); oa->o_valid = OBD_MD_FLGENER | OBD_MD_FLGROUP; @@ -724,7 +724,7 @@ static int llog_lvfs_create(const struct lu_env *env, out: OBDO_FREE(oa); } - RETURN(rc); + return rc; } static int llog_lvfs_close(const struct lu_env *env, @@ -733,7 +733,7 @@ static int llog_lvfs_close(const struct lu_env *env, int rc; if (handle->lgh_file == NULL) - RETURN(0); + return 0; rc = filp_close(handle->lgh_file, 0); if (rc) CERROR("%s: error closing llog #"DOSTID"#%08x: " @@ -745,7 +745,7 @@ static int llog_lvfs_close(const struct lu_env *env, OBD_FREE(handle->lgh_name, strlen(handle->lgh_name) + 1); handle->lgh_name = NULL; } - RETURN(rc); + return rc; } static int llog_lvfs_destroy(const struct lu_env *env, @@ -780,12 +780,12 @@ static int llog_lvfs_destroy(const struct lu_env *env, dput(fdentry); pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); - RETURN(rc); + return rc; } OBDO_ALLOC(oa); if (oa == NULL) - RETURN(-ENOMEM); + return -ENOMEM; oa->o_oi = handle->lgh_id.lgl_oi; oa->o_generation = handle->lgh_id.lgl_ogen; @@ -810,7 +810,7 @@ static int llog_lvfs_destroy(const struct lu_env *env, rc = rc1; out: OBDO_FREE(oa); - RETURN(rc); + return rc; } static int llog_lvfs_declare_create(const struct lu_env *env, diff --git a/drivers/staging/lustre/lustre/obdclass/llog_obd.c b/drivers/staging/lustre/lustre/obdclass/llog_obd.c index 7d6c94b463a37..71817af75396f 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_obd.c @@ -138,7 +138,7 @@ int llog_cleanup(const struct lu_env *env, struct llog_ctxt *ctxt) l_wait_event(olg->olg_waitq, llog_group_ctxt_null(olg, idx), &lwi); - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_cleanup); @@ -150,13 +150,13 @@ int llog_setup(const struct lu_env *env, struct obd_device *obd, int rc = 0; if (index < 0 || index >= LLOG_MAX_CTXTS) - RETURN(-EINVAL); + return -EINVAL; LASSERT(olg != NULL); ctxt = llog_new_ctxt(obd); if (!ctxt) - RETURN(-ENOMEM); + return -ENOMEM; ctxt->loc_obd = obd; ctxt->loc_olg = olg; @@ -187,7 +187,7 @@ int llog_setup(const struct lu_env *env, struct obd_device *obd, } rc = 0; } - RETURN(rc); + return rc; } if (op->lop_setup) { @@ -208,7 +208,7 @@ int llog_setup(const struct lu_env *env, struct obd_device *obd, ctxt->loc_flags &= ~LLOG_CTXT_FLAG_UNINITIALIZED; } - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_setup); @@ -217,12 +217,12 @@ int llog_sync(struct llog_ctxt *ctxt, struct obd_export *exp, int flags) int rc = 0; if (!ctxt) - RETURN(0); + return 0; if (CTXTP(ctxt, sync)) rc = CTXTP(ctxt, sync)(ctxt, exp, flags); - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_sync); @@ -234,11 +234,11 @@ int llog_obd_add(const struct lu_env *env, struct llog_ctxt *ctxt, if (!ctxt) { CERROR("No ctxt\n"); - RETURN(-ENODEV); + return -ENODEV; } if (ctxt->loc_flags & LLOG_CTXT_FLAG_UNINITIALIZED) - RETURN(-ENXIO); + return -ENXIO; CTXT_CHECK_OP(ctxt, obd_add, -EOPNOTSUPP); raised = cfs_cap_raised(CFS_CAP_SYS_RESOURCE); @@ -248,7 +248,7 @@ int llog_obd_add(const struct lu_env *env, struct llog_ctxt *ctxt, numcookies); if (!raised) cfs_cap_lower(CFS_CAP_SYS_RESOURCE); - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_obd_add); @@ -260,12 +260,12 @@ int llog_cancel(const struct lu_env *env, struct llog_ctxt *ctxt, if (!ctxt) { CERROR("No ctxt\n"); - RETURN(-ENODEV); + return -ENODEV; } CTXT_CHECK_OP(ctxt, cancel, -EOPNOTSUPP); rc = CTXTP(ctxt, cancel)(env, ctxt, lsm, count, cookies, flags); - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_cancel); @@ -278,7 +278,7 @@ int obd_llog_init(struct obd_device *obd, struct obd_llog_group *olg, OBD_COUNTER_INCREMENT(obd, llog_init); rc = OBP(obd, llog_init)(obd, olg, disk_obd, index); - RETURN(rc); + return rc; } EXPORT_SYMBOL(obd_llog_init); @@ -290,7 +290,7 @@ int obd_llog_finish(struct obd_device *obd, int count) OBD_COUNTER_INCREMENT(obd, llog_finish); rc = OBP(obd, llog_finish)(obd, count); - RETURN(rc); + return rc; } EXPORT_SYMBOL(obd_llog_finish); diff --git a/drivers/staging/lustre/lustre/obdclass/llog_osd.c b/drivers/staging/lustre/lustre/obdclass/llog_osd.c index 7ab6f59c0dc54..654c8e1896530 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_osd.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_osd.c @@ -120,7 +120,7 @@ static int llog_osd_pad(const struct lu_env *env, struct dt_object *o, o->do_lu.lo_dev->ld_obd->obd_name, rc); out: dt_write_unlock(env, o); - RETURN(rc); + return rc; } static int llog_osd_write_blob(const struct lu_env *env, struct dt_object *o, @@ -195,7 +195,7 @@ static int llog_osd_write_blob(const struct lu_env *env, struct dt_object *o, dt_attr_set(env, o, &lgi->lgi_attr, th, BYPASS_CAPA); } - RETURN(rc); + return rc; } static int llog_osd_read_header(const struct lu_env *env, @@ -215,13 +215,13 @@ static int llog_osd_read_header(const struct lu_env *env, rc = dt_attr_get(env, o, &lgi->lgi_attr, NULL); if (rc) - RETURN(rc); + return rc; LASSERT(lgi->lgi_attr.la_valid & LA_SIZE); if (lgi->lgi_attr.la_size == 0) { CDEBUG(D_HA, "not reading header from 0-byte log\n"); - RETURN(LLOG_EEMPTY); + return LLOG_EEMPTY; } lgi->lgi_off = 0; @@ -233,7 +233,7 @@ static int llog_osd_read_header(const struct lu_env *env, CERROR("%s: error reading log header from "DFID": rc = %d\n", o->do_lu.lo_dev->ld_obd->obd_name, PFID(lu_object_fid(&o->do_lu)), rc); - RETURN(rc); + return rc; } llh_hdr = &handle->lgh_hdr->llh_hdr; @@ -246,7 +246,7 @@ static int llog_osd_read_header(const struct lu_env *env, handle->lgh_name ? handle->lgh_name : "", PFID(lu_object_fid(&o->do_lu)), llh_hdr->lrh_type, LLOG_HDR_MAGIC); - RETURN(-EIO); + return -EIO; } else if (llh_hdr->lrh_len != LLOG_CHUNK_SIZE) { CERROR("%s: incorrectly sized log %s "DFID" header: " "%#x (expected %#x)\n" @@ -255,12 +255,12 @@ static int llog_osd_read_header(const struct lu_env *env, handle->lgh_name ? handle->lgh_name : "", PFID(lu_object_fid(&o->do_lu)), llh_hdr->lrh_len, LLOG_CHUNK_SIZE); - RETURN(-EIO); + return -EIO; } handle->lgh_last_idx = handle->lgh_hdr->llh_tail.lrt_index; - RETURN(0); + return 0; } static int llog_osd_declare_write_rec(const struct lu_env *env, @@ -283,18 +283,18 @@ static int llog_osd_declare_write_rec(const struct lu_env *env, rc = dt_declare_record_write(env, o, sizeof(struct llog_log_hdr), 0, th); if (rc || idx == 0) /* if error or just header */ - RETURN(rc); + return rc; if (dt_object_exists(o)) { rc = dt_attr_get(env, o, &lgi->lgi_attr, BYPASS_CAPA); lgi->lgi_off = lgi->lgi_attr.la_size; LASSERT(ergo(rc == 0, lgi->lgi_attr.la_valid & LA_SIZE)); if (rc) - RETURN(rc); + return rc; rc = dt_declare_punch(env, o, lgi->lgi_off, OBD_OBJECT_EOF, th); if (rc) - RETURN(rc); + return rc; } else { lgi->lgi_off = 0; } @@ -302,7 +302,7 @@ static int llog_osd_declare_write_rec(const struct lu_env *env, /* XXX: implement declared window or multi-chunks approach */ rc = dt_declare_record_write(env, o, 32 * 1024, lgi->lgi_off, th); - RETURN(rc); + return rc; } /* returns negative in on error; 0 if success && reccookie == 0; 1 otherwise */ @@ -338,11 +338,11 @@ static int llog_osd_write_rec(const struct lu_env *env, else rc = (reclen > LLOG_CHUNK_SIZE) ? -E2BIG : 0; if (rc) - RETURN(rc); + return rc; rc = dt_attr_get(env, o, &lgi->lgi_attr, NULL); if (rc) - RETURN(rc); + return rc; if (buf) /* write_blob adds header and tail to lrh_len. */ @@ -355,7 +355,7 @@ static int llog_osd_write_rec(const struct lu_env *env, LBUG(); if (idx && llh->llh_size && llh->llh_size != rec->lrh_len) - RETURN(-EINVAL); + return -EINVAL; if (!ext2_test_bit(idx, llh->llh_bitmap)) CERROR("%s: modify unset record %u\n", @@ -370,7 +370,7 @@ static int llog_osd_write_rec(const struct lu_env *env, &lgi->lgi_off, th); /* we are done if we only write the header or on error */ if (rc || idx == 0) - RETURN(rc); + return rc; if (buf) { /* We assume that caller has set lgh_cur_* */ @@ -386,7 +386,7 @@ static int llog_osd_write_rec(const struct lu_env *env, CERROR("%s: modify idx mismatch %u/%d\n", o->do_lu.lo_dev->ld_obd->obd_name, idx, loghandle->lgh_cur_idx); - RETURN(-EFAULT); + return -EFAULT; } } else { /* Assumes constant lrh_len */ @@ -399,7 +399,7 @@ static int llog_osd_write_rec(const struct lu_env *env, reccookie->lgc_index = idx; rc = 1; } - RETURN(rc); + return rc; } /* Make sure that records don't cross a chunk boundary, so we can @@ -418,12 +418,12 @@ static int llog_osd_write_rec(const struct lu_env *env, index = loghandle->lgh_last_idx + 1; rc = llog_osd_pad(env, o, &lgi->lgi_off, left, index, th); if (rc) - RETURN(rc); + return rc; loghandle->lgh_last_idx++; /*for pad rec*/ } /* if it's the last idx in log file, then return -ENOSPC */ if (loghandle->lgh_last_idx >= LLOG_BITMAP_SIZE(llh) - 1) - RETURN(-ENOSPC); + return -ENOSPC; loghandle->lgh_last_idx++; index = loghandle->lgh_last_idx; @@ -495,7 +495,7 @@ static int llog_osd_write_rec(const struct lu_env *env, reccookie->lgc_subsys = -1; rc = 1; } - RETURN(rc); + return rc; } /* We can skip reading at least as many log blocks as the number of @@ -531,7 +531,7 @@ static int llog_osd_next_block(const struct lu_env *env, LASSERT(lgi); if (len == 0 || len & (LLOG_CHUNK_SIZE - 1)) - RETURN(-EINVAL); + return -EINVAL; CDEBUG(D_OTHER, "looking for log index %u (cur idx %u off "LPU64")\n", next_idx, *cur_idx, *cur_offset); @@ -653,7 +653,7 @@ static int llog_osd_prev_block(const struct lu_env *env, int rc; if (len == 0 || len & (LLOG_CHUNK_SIZE - 1)) - RETURN(-EINVAL); + return -EINVAL; CDEBUG(D_OTHER, "looking for log index %u\n", prev_idx); @@ -789,7 +789,7 @@ static int llog_osd_open(const struct lu_env *env, struct llog_handle *handle, ls = ls_device_get(dt); if (IS_ERR(ls)) - RETURN(PTR_ERR(ls)); + return PTR_ERR(ls); mutex_lock(&ls->ls_los_mutex); los = dt_los_find(ls, name != NULL ? FID_SEQ_LLOG_NAME : FID_SEQ_LLOG); @@ -844,7 +844,7 @@ static int llog_osd_open(const struct lu_env *env, struct llog_handle *handle, handle->private_data = los; LASSERT(handle->lgh_ctxt); - RETURN(rc); + return rc; out_put: lu_object_put(env, &o->do_lu); @@ -853,7 +853,7 @@ static int llog_osd_open(const struct lu_env *env, struct llog_handle *handle, OBD_FREE(handle->lgh_name, strlen(name) + 1); out: dt_los_put(los); - RETURN(rc); + return rc; } static int llog_osd_exist(struct llog_handle *handle) @@ -877,25 +877,25 @@ static int llog_osd_declare_create(const struct lu_env *env, /* object can be created by another thread */ o = res->lgh_obj; if (dt_object_exists(o)) - RETURN(0); + return 0; los = res->private_data; LASSERT(los); rc = llog_osd_declare_new_object(env, los, o, th); if (rc) - RETURN(rc); + return rc; rc = dt_declare_record_write(env, o, LLOG_CHUNK_SIZE, 0, th); if (rc) - RETURN(rc); + return rc; if (res->lgh_name) { struct dt_object *llog_dir; llog_dir = llog_osd_dir_get(env, res->lgh_ctxt); if (IS_ERR(llog_dir)) - RETURN(PTR_ERR(llog_dir)); + return PTR_ERR(llog_dir); logid_to_fid(&res->lgh_id, &lgi->lgi_fid); rc = dt_declare_insert(env, llog_dir, (struct dt_rec *)&lgi->lgi_fid, @@ -906,7 +906,7 @@ static int llog_osd_declare_create(const struct lu_env *env, o->do_lu.lo_dev->ld_obd->obd_name, res->lgh_name, rc); } - RETURN(rc); + return rc; } /* This is a callback from the llog_* functions. @@ -925,7 +925,7 @@ static int llog_osd_create(const struct lu_env *env, struct llog_handle *res, /* llog can be already created */ if (dt_object_exists(o)) - RETURN(-EEXIST); + return -EEXIST; los = res->private_data; LASSERT(los); @@ -938,14 +938,14 @@ static int llog_osd_create(const struct lu_env *env, struct llog_handle *res, dt_write_unlock(env, o); if (rc) - RETURN(rc); + return rc; if (res->lgh_name) { struct dt_object *llog_dir; llog_dir = llog_osd_dir_get(env, res->lgh_ctxt); if (IS_ERR(llog_dir)) - RETURN(PTR_ERR(llog_dir)); + return PTR_ERR(llog_dir); logid_to_fid(&res->lgh_id, &lgi->lgi_fid); dt_read_lock(env, llog_dir, 0); @@ -960,7 +960,7 @@ static int llog_osd_create(const struct lu_env *env, struct llog_handle *res, o->do_lu.lo_dev->ld_obd->obd_name, res->lgh_name, rc); } - RETURN(rc); + return rc; } static int llog_osd_close(const struct lu_env *env, struct llog_handle *handle) @@ -979,7 +979,7 @@ static int llog_osd_close(const struct lu_env *env, struct llog_handle *handle) if (handle->lgh_name) OBD_FREE(handle->lgh_name, strlen(handle->lgh_name) + 1); - RETURN(rc); + return rc; } static int llog_osd_destroy(const struct lu_env *env, @@ -1004,7 +1004,7 @@ static int llog_osd_destroy(const struct lu_env *env, th = dt_trans_create(env, d); if (IS_ERR(th)) - RETURN(PTR_ERR(th)); + return PTR_ERR(th); if (loghandle->lgh_name) { llog_dir = llog_osd_dir_get(env, ctxt); @@ -1054,7 +1054,7 @@ static int llog_osd_destroy(const struct lu_env *env, dt_trans_stop(env, d, th); if (llog_dir != NULL) lu_object_put(env, &llog_dir->do_lu); - RETURN(rc); + return rc; } static int llog_osd_setup(const struct lu_env *env, struct obd_device *obd, @@ -1101,7 +1101,7 @@ static int llog_osd_cleanup(const struct lu_env *env, struct llog_ctxt *ctxt) dt = ctxt->loc_exp->exp_obd->obd_lvfs_ctxt.dt; ls = ls_device_get(dt); if (IS_ERR(ls)) - RETURN(PTR_ERR(ls)); + return PTR_ERR(ls); mutex_lock(&ls->ls_los_mutex); los = dt_los_find(ls, FID_SEQ_LLOG); @@ -1154,7 +1154,7 @@ int llog_osd_get_cat_list(const struct lu_env *env, struct dt_device *d, o = dt_locate(env, d, &lgi->lgi_fid); if (IS_ERR(o)) - RETURN(PTR_ERR(o)); + return PTR_ERR(o); if (!dt_object_exists(o)) { th = dt_trans_create(env, d); @@ -1223,7 +1223,7 @@ int llog_osd_get_cat_list(const struct lu_env *env, struct dt_device *d, out: lu_object_put(env, &o->do_lu); - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_osd_get_cat_list); @@ -1237,7 +1237,7 @@ int llog_osd_put_cat_list(const struct lu_env *env, struct dt_device *d, int rc, size; if (!count) - RETURN(0); + return 0; LASSERT(d); @@ -1248,7 +1248,7 @@ int llog_osd_put_cat_list(const struct lu_env *env, struct dt_device *d, o = dt_locate(env, d, &lgi->lgi_fid); if (IS_ERR(o)) - RETURN(PTR_ERR(o)); + return PTR_ERR(o); if (!dt_object_exists(o)) GOTO(out, rc = -ENOENT); @@ -1285,6 +1285,6 @@ int llog_osd_put_cat_list(const struct lu_env *env, struct dt_device *d, dt_trans_stop(env, d, th); out: lu_object_put(env, &o->do_lu); - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_osd_put_cat_list); diff --git a/drivers/staging/lustre/lustre/obdclass/llog_test.c b/drivers/staging/lustre/lustre/obdclass/llog_test.c index d3fd2461a07ab..d9e6d12215f90 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_test.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_test.c @@ -78,22 +78,22 @@ static int verify_handle(char *test, struct llog_handle *llh, int num_recs) if (active_recs != num_recs) { CERROR("%s: expected %d active recs after write, found %d\n", test, num_recs, active_recs); - RETURN(-ERANGE); + return -ERANGE; } if (llh->lgh_hdr->llh_count != num_recs) { CERROR("%s: handle->count is %d, expected %d after write\n", test, llh->lgh_hdr->llh_count, num_recs); - RETURN(-ERANGE); + return -ERANGE; } if (llh->lgh_last_idx < last_idx) { CERROR("%s: handle->last_idx is %d, expected %d after write\n", test, llh->lgh_last_idx, last_idx); - RETURN(-ERANGE); + return -ERANGE; } - RETURN(0); + return 0; } /* Test named-log create/open, close */ @@ -132,7 +132,7 @@ static int llog_test_1(const struct lu_env *env, } out: llog_ctxt_put(ctxt); - RETURN(rc); + return rc; } /* Test named-log reopen; returns opened log on success */ @@ -209,7 +209,7 @@ static int llog_test_2(const struct lu_env *env, struct obd_device *obd, out_put: llog_ctxt_put(ctxt); - RETURN(rc); + return rc; } /* Test record writing, single and in bulk */ @@ -228,12 +228,12 @@ static int llog_test_3(const struct lu_env *env, struct obd_device *obd, num_recs++; if (rc < 0) { CERROR("3a: write one log record failed: %d\n", rc); - RETURN(rc); + return rc; } rc = verify_handle("3a", llh, num_recs); if (rc) - RETURN(rc); + return rc; CWARN("3b: write 10 cfg log records with 8 bytes bufs\n"); for (i = 0; i < 10; i++) { @@ -247,14 +247,14 @@ static int llog_test_3(const struct lu_env *env, struct obd_device *obd, if (rc < 0) { CERROR("3b: write 10 records failed at #%d: %d\n", i + 1, rc); - RETURN(rc); + return rc; } num_recs++; } rc = verify_handle("3b", llh, num_recs); if (rc) - RETURN(rc); + return rc; CWARN("3c: write 1000 more log records\n"); for (i = 0; i < 1000; i++) { @@ -262,14 +262,14 @@ static int llog_test_3(const struct lu_env *env, struct obd_device *obd, if (rc < 0) { CERROR("3c: write 1000 records failed at #%d: %d\n", i + 1, rc); - RETURN(rc); + return rc; } num_recs++; } rc = verify_handle("3c", llh, num_recs); if (rc) - RETURN(rc); + return rc; CWARN("3d: write log more than BITMAP_SIZE, return -ENOSPC\n"); for (i = 0; i < LLOG_BITMAP_SIZE(llh->lgh_hdr) + 1; i++) { @@ -293,20 +293,20 @@ static int llog_test_3(const struct lu_env *env, struct obd_device *obd, } else if (rc < 0) { CERROR("3d: write recs failed at #%d: %d\n", i + 1, rc); - RETURN(rc); + return rc; } num_recs++; } if (rc != -ENOSPC) { CWARN("3d: write record more than BITMAP size!\n"); - RETURN(-EINVAL); + return -EINVAL; } CWARN("3d: wrote %d more records before end of llog is reached\n", num_recs); rc = verify_handle("3d", llh, num_recs); - RETURN(rc); + return rc; } /* Test catalogue additions */ @@ -416,7 +416,7 @@ static int llog_test_4(const struct lu_env *env, struct obd_device *obd) } ctxt_release: llog_ctxt_put(ctxt); - RETURN(rc); + return rc; } static int cat_counter; @@ -429,7 +429,7 @@ static int cat_print_cb(const struct lu_env *env, struct llog_handle *llh, if (rec->lrh_type != LLOG_LOGID_MAGIC) { CERROR("invalid record in catalog\n"); - RETURN(-EINVAL); + return -EINVAL; } logid_to_fid(&lir->lid_id, &fid); @@ -440,7 +440,7 @@ static int cat_print_cb(const struct lu_env *env, struct llog_handle *llh, cat_counter++; - RETURN(0); + return 0; } static int plain_counter; @@ -452,7 +452,7 @@ static int plain_print_cb(const struct lu_env *env, struct llog_handle *llh, if (!(llh->lgh_hdr->llh_flags & LLOG_F_IS_PLAIN)) { CERROR("log is not plain\n"); - RETURN(-EINVAL); + return -EINVAL; } logid_to_fid(&llh->lgh_id, &fid); @@ -462,7 +462,7 @@ static int plain_print_cb(const struct lu_env *env, struct llog_handle *llh, plain_counter++; - RETURN(0); + return 0; } static int cancel_count; @@ -475,7 +475,7 @@ static int llog_cancel_rec_cb(const struct lu_env *env, if (!(llh->lgh_hdr->llh_flags & LLOG_F_IS_PLAIN)) { CERROR("log is not plain\n"); - RETURN(-EINVAL); + return -EINVAL; } cookie.lgc_lgl = llh->lgh_id; @@ -484,8 +484,8 @@ static int llog_cancel_rec_cb(const struct lu_env *env, llog_cat_cancel_records(env, llh->u.phd.phd_cat_handle, 1, &cookie); cancel_count++; if (cancel_count == LLOG_TEST_RECNUM) - RETURN(-LLOG_EEMPTY); - RETURN(0); + return -LLOG_EEMPTY; + return 0; } /* Test log and catalogue processing */ @@ -592,7 +592,7 @@ static int llog_test_5(const struct lu_env *env, struct obd_device *obd) out_put: llog_ctxt_put(ctxt); - RETURN(rc); + return rc; } /* Test client api; open log by name and process */ @@ -676,7 +676,7 @@ static int llog_test_6(const struct lu_env *env, struct obd_device *obd, llog_ctxt_put(nctxt); ctxt_release: llog_ctxt_put(ctxt); - RETURN(rc); + return rc; } static union { @@ -721,7 +721,7 @@ static int llog_test_7_sub(const struct lu_env *env, struct llog_ctxt *ctxt) rc = llog_open_create(env, ctxt, &llh, NULL, NULL); if (rc) { CERROR("7_sub: create log failed\n"); - RETURN(rc); + return rc; } rc = llog_init_handle(env, llh, @@ -792,7 +792,7 @@ static int llog_test_7_sub(const struct lu_env *env, struct llog_ctxt *ctxt) if (rc) llog_destroy(env, llh); llog_close(env, llh); - RETURN(rc); + return rc; } /* Test all llog records writing and processing */ @@ -881,7 +881,7 @@ static int llog_test_7(const struct lu_env *env, struct obd_device *obd) } out: llog_ctxt_put(ctxt); - RETURN(rc); + return rc; } /* ------------------------------------------------------------------------- @@ -957,14 +957,14 @@ static int llog_test_cleanup(struct obd_device *obd) rc = lu_env_init(&env, LCT_LOCAL | LCT_MG_THREAD); if (rc) - RETURN(rc); + return rc; tgt = obd->obd_lvfs_ctxt.dt->dd_lu_dev.ld_obd; rc = llog_cleanup(&env, llog_get_context(tgt, LLOG_TEST_ORIG_CTXT)); if (rc) CERROR("failed to llog_test_llog_finish: %d\n", rc); lu_env_fini(&env); - RETURN(rc); + return rc; } static int llog_test_setup(struct obd_device *obd, struct lustre_cfg *lcfg) @@ -978,12 +978,12 @@ static int llog_test_setup(struct obd_device *obd, struct lustre_cfg *lcfg) if (lcfg->lcfg_bufcount < 2) { CERROR("requires a TARGET OBD name\n"); - RETURN(-EINVAL); + return -EINVAL; } if (lcfg->lcfg_buflens[1] < 1) { CERROR("requires a TARGET OBD name\n"); - RETURN(-EINVAL); + return -EINVAL; } /* disk obd */ @@ -991,12 +991,12 @@ static int llog_test_setup(struct obd_device *obd, struct lustre_cfg *lcfg) if (!tgt || !tgt->obd_attached || !tgt->obd_set_up) { CERROR("target device not attached or not set up (%s)\n", lustre_cfg_string(lcfg, 1)); - RETURN(-EINVAL); + return -EINVAL; } rc = lu_env_init(&env, LCT_LOCAL | LCT_MG_THREAD); if (rc) - RETURN(rc); + return rc; rc = lu_context_init(&test_session, LCT_SESSION); if (rc) @@ -1037,7 +1037,7 @@ static int llog_test_setup(struct obd_device *obd, struct lustre_cfg *lcfg) lu_context_fini(&test_session); cleanup_env: lu_env_fini(&env); - RETURN(rc); + return rc; } static struct obd_ops llog_obd_ops = { diff --git a/drivers/staging/lustre/lustre/obdclass/local_storage.c b/drivers/staging/lustre/lustre/obdclass/local_storage.c index 6d8d7e7aec50d..cc19fbab0207c 100644 --- a/drivers/staging/lustre/lustre/obdclass/local_storage.c +++ b/drivers/staging/lustre/lustre/obdclass/local_storage.c @@ -49,11 +49,11 @@ static int ls_object_init(const struct lu_env *env, struct lu_object *o, under = &ls->ls_osd->dd_lu_dev; below = under->ld_ops->ldo_object_alloc(env, o->lo_header, under); if (below == NULL) - RETURN(-ENOMEM); + return -ENOMEM; lu_object_add(o, below); - RETURN(0); + return 0; } static void ls_object_free(const struct lu_env *env, struct lu_object *o) @@ -166,7 +166,7 @@ struct ls_device *ls_device_get(struct dt_device *dev) list_add(&ls->ls_linkage, &ls_list_head); out_ls: mutex_unlock(&ls_list_mutex); - RETURN(ls); + return ls; } void ls_device_put(const struct lu_env *env, struct ls_device *ls) @@ -226,18 +226,18 @@ int local_object_declare_create(const struct lu_env *env, rc = dt_declare_record_write(env, los->los_obj, sizeof(struct los_ondisk), 0, th); if (rc) - RETURN(rc); + return rc; } rc = dt_declare_create(env, o, attr, NULL, dof, th); if (rc) - RETURN(rc); + return rc; dti->dti_lb.lb_buf = NULL; dti->dti_lb.lb_len = sizeof(dti->dti_lma); rc = dt_declare_xattr_set(env, o, &dti->dti_lb, XATTR_NAME_LMA, 0, th); - RETURN(rc); + return rc; } int local_object_create(const struct lu_env *env, @@ -251,10 +251,10 @@ int local_object_create(const struct lu_env *env, rc = dt_create(env, o, attr, NULL, dof, th); if (rc) - RETURN(rc); + return rc; if (los == NULL) - RETURN(rc); + return rc; LASSERT(los->los_obj); LASSERT(dt_object_exists(los->los_obj)); @@ -275,7 +275,7 @@ int local_object_create(const struct lu_env *env, th); mutex_unlock(&los->los_id_lock); - RETURN(rc); + return rc; } /* @@ -296,7 +296,7 @@ struct dt_object *__local_file_create(const struct lu_env *env, dto = ls_locate(env, ls, fid); if (unlikely(IS_ERR(dto))) - RETURN(dto); + return dto; LASSERT(dto != NULL); if (dt_object_exists(dto)) @@ -369,7 +369,7 @@ struct dt_object *__local_file_create(const struct lu_env *env, lu_object_put_nocache(env, &dto->do_lu); dto = ERR_PTR(rc); } - RETURN(dto); + return dto; } /* @@ -582,13 +582,13 @@ int local_object_unlink(const struct lu_env *env, struct dt_device *dt, rc = dt_lookup_dir(env, parent, name, &dti->dti_fid); if (rc == -ENOENT) - RETURN(0); + return 0; else if (rc < 0) - RETURN(rc); + return rc; dto = dt_locate(env, dt, &dti->dti_fid); if (unlikely(IS_ERR(dto))) - RETURN(PTR_ERR(dto)); + return PTR_ERR(dto); th = dt_trans_create(env, dt); if (IS_ERR(th)) @@ -753,7 +753,7 @@ int local_oid_storage_init(const struct lu_env *env, struct dt_device *dev, ls = ls_device_get(dev); if (IS_ERR(ls)) - RETURN(PTR_ERR(ls)); + return PTR_ERR(ls); mutex_lock(&ls->ls_los_mutex); *los = dt_los_find(ls, fid_seq(first_fid)); diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index eaf45cb07b32a..6d9f25291757c 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -1503,13 +1503,13 @@ static int lprocfs_nid_stats_clear_write_cb(void *obj, void *data) spin_lock(&stat->nid_obd->obd_nid_lock); list_move(&stat->nid_list, data); spin_unlock(&stat->nid_obd->obd_nid_lock); - RETURN(1); + return 1; } /* we has reference to object - only clear data*/ if (stat->nid_stats) lprocfs_clear_stats(stat->nid_stats); - RETURN(0); + return 0; } int lprocfs_nid_stats_clear_write(struct file *file, const char *buffer, @@ -1545,13 +1545,13 @@ int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int *newnid) if (!exp || !exp->exp_obd || !exp->exp_obd->obd_proc_exports_entry || !exp->exp_obd->obd_nid_stats_hash) - RETURN(-EINVAL); + return -EINVAL; /* not test against zero because eric say: * You may only test nid against another nid, or LNET_NID_ANY. * Anything else is nonsense.*/ if (!nid || *nid == LNET_NID_ANY) - RETURN(0); + return 0; obd = exp->exp_obd; @@ -1559,7 +1559,7 @@ int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int *newnid) OBD_ALLOC_PTR(new_stat); if (new_stat == NULL) - RETURN(-ENOMEM); + return -ENOMEM; new_stat->nid = *nid; new_stat->nid_obd = exp->exp_obd; @@ -1627,7 +1627,7 @@ int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int *newnid) list_add(&new_stat->nid_list, &obd->obd_nid_stats); spin_unlock(&obd->obd_nid_lock); - RETURN(rc); + return rc; destroy_new_ns: if (new_stat->nid_proc != NULL) @@ -1637,7 +1637,7 @@ int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int *newnid) destroy_new: nidstat_putref(new_stat); OBD_FREE_PTR(new_stat); - RETURN(rc); + return rc; } EXPORT_SYMBOL(lprocfs_exp_setup); @@ -1646,7 +1646,7 @@ int lprocfs_exp_cleanup(struct obd_export *exp) struct nid_stat *stat = exp->exp_nid_stats; if(!stat || !exp->exp_obd) - RETURN(0); + return 0; nidstat_putref(exp->exp_nid_stats); exp->exp_nid_stats = NULL; @@ -1912,9 +1912,9 @@ int lprocfs_seq_create(proc_dir_entry_t *parent, entry = proc_create_data(name, mode, parent, seq_fops, data); if (entry == NULL) - RETURN(-ENOMEM); + return -ENOMEM; - RETURN(0); + return 0; } EXPORT_SYMBOL(lprocfs_seq_create); diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c index 9efa8dc255b57..c29ac1c2defd1 100644 --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c @@ -209,9 +209,9 @@ static struct lu_object *lu_object_alloc(const struct lu_env *env, */ top = dev->ld_ops->ldo_object_alloc(env, NULL, dev); if (top == NULL) - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); if (IS_ERR(top)) - RETURN(top); + return top; /* * This is the only place where object fid is assigned. It's constant * after this point. @@ -232,7 +232,7 @@ static struct lu_object *lu_object_alloc(const struct lu_env *env, result = scan->lo_ops->loo_object_init(env, scan, conf); if (result != 0) { lu_object_free(env, top); - RETURN(ERR_PTR(result)); + return ERR_PTR(result); } scan->lo_flags |= LU_OBJECT_ALLOCATED; } @@ -243,13 +243,13 @@ static struct lu_object *lu_object_alloc(const struct lu_env *env, result = scan->lo_ops->loo_object_start(env, scan); if (result != 0) { lu_object_free(env, top); - RETURN(ERR_PTR(result)); + return ERR_PTR(result); } } } lprocfs_counter_incr(dev->ld_site->ls_stats, LU_SS_CREATED); - RETURN(top); + return top; } /** @@ -316,7 +316,7 @@ int lu_site_purge(const struct lu_env *env, struct lu_site *s, int nr) int i; if (OBD_FAIL_CHECK(OBD_FAIL_OBD_NO_LRU)) - RETURN(0); + return 0; INIT_LIST_HEAD(&dispose); /* @@ -1039,7 +1039,7 @@ int lu_site_init(struct lu_site *s, struct lu_device *top) lu_dev_add_linkage(s, top); - RETURN(0); + return 0; } EXPORT_SYMBOL(lu_site_init); diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c index a748d8e70ec95..be31d32b82c88 100644 --- a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c +++ b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c @@ -174,7 +174,7 @@ void *class_handle2object(__u64 cookie) } rcu_read_unlock(); - RETURN(retval); + return retval; } EXPORT_SYMBOL(class_handle2object); diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_peer.c b/drivers/staging/lustre/lustre/obdclass/lustre_peer.c index 81ced81d32af5..df4936ad23750 100644 --- a/drivers/staging/lustre/lustre/obdclass/lustre_peer.c +++ b/drivers/staging/lustre/lustre/obdclass/lustre_peer.c @@ -212,6 +212,6 @@ int class_check_uuid(struct obd_uuid *uuid, __u64 nid) break; } spin_unlock(&g_uuid_lock); - RETURN(found); + return found; } EXPORT_SYMBOL(class_check_uuid); diff --git a/drivers/staging/lustre/lustre/obdclass/md_attrs.c b/drivers/staging/lustre/lustre/obdclass/md_attrs.c index 03795f3cbd714..f7187829e276f 100644 --- a/drivers/staging/lustre/lustre/obdclass/md_attrs.c +++ b/drivers/staging/lustre/lustre/obdclass/md_attrs.c @@ -102,15 +102,15 @@ int lustre_buf2som(void *buf, int rc, struct md_som_data *msd) if (rc == 0 || rc == -ENODATA) /* no SOM attributes */ - RETURN(-ENODATA); + return -ENODATA; if (rc < 0) /* error hit while fetching xattr */ - RETURN(rc); + return rc; /* check SOM compatibility */ if (attrs->som_incompat & ~cpu_to_le32(SOM_INCOMPAT_SUPP)) - RETURN(-ENODATA); + return -ENODATA; /* unpack SOM attributes */ lustre_som_swab(attrs); @@ -123,7 +123,7 @@ int lustre_buf2som(void *buf, int rc, struct md_som_data *msd) msd->msd_blocks = attrs->som_blocks; msd->msd_mountid = attrs->som_mountid; - RETURN(0); + return 0; } EXPORT_SYMBOL(lustre_buf2som); @@ -158,11 +158,11 @@ int lustre_buf2hsm(void *buf, int rc, struct md_hsm *mh) if (rc == 0 || rc == -ENODATA) /* no HSM attributes */ - RETURN(-ENODATA); + return -ENODATA; if (rc < 0) /* error hit while fetching xattr */ - RETURN(rc); + return rc; /* unpack HSM attributes */ lustre_hsm_swab(attrs); @@ -173,7 +173,7 @@ int lustre_buf2hsm(void *buf, int rc, struct md_hsm *mh) mh->mh_arch_id = attrs->hsm_arch_id; mh->mh_arch_ver = attrs->hsm_arch_ver; - RETURN(0); + return 0; } EXPORT_SYMBOL(lustre_buf2hsm); diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c index 6981f3ce63f3d..d0a64ff53581e 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_config.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c @@ -93,7 +93,7 @@ struct cfg_interop_param *class_find_old_param(const char *param, int name_len = 0; if (param == NULL || ptr == NULL) - RETURN(NULL); + return NULL; value = strchr(param, '='); if (value == NULL) @@ -104,11 +104,11 @@ struct cfg_interop_param *class_find_old_param(const char *param, while (ptr->old_param != NULL) { if (strncmp(param, ptr->old_param, name_len) == 0 && name_len == strlen(ptr->old_param)) - RETURN(ptr); + return ptr; ptr++; } - RETURN(NULL); + return NULL; } EXPORT_SYMBOL(class_find_old_param); @@ -338,19 +338,19 @@ int class_attach(struct lustre_cfg *lcfg) if (!LUSTRE_CFG_BUFLEN(lcfg, 1)) { CERROR("No type passed!\n"); - RETURN(-EINVAL); + return -EINVAL; } typename = lustre_cfg_string(lcfg, 1); if (!LUSTRE_CFG_BUFLEN(lcfg, 0)) { CERROR("No name passed!\n"); - RETURN(-EINVAL); + return -EINVAL; } name = lustre_cfg_string(lcfg, 0); if (!LUSTRE_CFG_BUFLEN(lcfg, 2)) { CERROR("No UUID passed!\n"); - RETURN(-EINVAL); + return -EINVAL; } uuid = lustre_cfg_string(lcfg, 2); @@ -432,7 +432,7 @@ int class_attach(struct lustre_cfg *lcfg) obd->obd_attached = 1; CDEBUG(D_IOCTL, "OBD: dev %d attached type %s with refcount %d\n", obd->obd_minor, typename, atomic_read(&obd->obd_refcount)); - RETURN(0); + return 0; out: if (obd != NULL) { class_release_dev(obd); @@ -460,13 +460,13 @@ int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg) /* have we attached a type to this device? */ if (!obd->obd_attached) { CERROR("Device %d not attached\n", obd->obd_minor); - RETURN(-ENODEV); + return -ENODEV; } if (obd->obd_set_up) { CERROR("Device %d already setup (type %s)\n", obd->obd_minor, obd->obd_type->typ_name); - RETURN(-EEXIST); + return -EEXIST; } /* is someone else setting us up right now? (attach inits spinlock) */ @@ -475,7 +475,7 @@ int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg) spin_unlock(&obd->obd_dev_lock); CERROR("Device %d setup in progress (type %s)\n", obd->obd_minor, obd->obd_type->typ_name); - RETURN(-EEXIST); + return -EEXIST; } /* just leave this on forever. I can't use obd_set_up here because other fns check that status, and we're not actually set up yet. */ @@ -540,7 +540,7 @@ int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg) CDEBUG(D_IOCTL, "finished setup of obd %s (uuid %s)\n", obd->obd_name, obd->obd_uuid.uuid); - RETURN(0); + return 0; err_exp: if (obd->obd_self_export) { class_unlink_export(obd->obd_self_export); @@ -572,14 +572,14 @@ int class_detach(struct obd_device *obd, struct lustre_cfg *lcfg) { if (obd->obd_set_up) { CERROR("OBD device %d still set up\n", obd->obd_minor); - RETURN(-EBUSY); + return -EBUSY; } spin_lock(&obd->obd_dev_lock); if (!obd->obd_attached) { spin_unlock(&obd->obd_dev_lock); CERROR("OBD device %d not attached\n", obd->obd_minor); - RETURN(-ENODEV); + return -ENODEV; } obd->obd_attached = 0; spin_unlock(&obd->obd_dev_lock); @@ -588,7 +588,7 @@ int class_detach(struct obd_device *obd, struct lustre_cfg *lcfg) obd->obd_name, obd->obd_uuid.uuid); class_decref(obd, "attach", obd); - RETURN(0); + return 0; } EXPORT_SYMBOL(class_detach); @@ -605,14 +605,14 @@ int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg) if (!obd->obd_set_up) { CERROR("Device %d not setup\n", obd->obd_minor); - RETURN(-ENODEV); + return -ENODEV; } spin_lock(&obd->obd_dev_lock); if (obd->obd_stopping) { spin_unlock(&obd->obd_dev_lock); CERROR("OBD %d already stopping\n", obd->obd_minor); - RETURN(-ENODEV); + return -ENODEV; } /* Leave this on forever */ obd->obd_stopping = 1; @@ -691,7 +691,7 @@ int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg) class_decref(obd, "setup", obd); obd->obd_set_up = 0; - RETURN(0); + return 0; } EXPORT_SYMBOL(class_cleanup); @@ -766,7 +766,7 @@ int class_add_conn(struct obd_device *obd, struct lustre_cfg *lcfg) if (LUSTRE_CFG_BUFLEN(lcfg, 1) < 1 || LUSTRE_CFG_BUFLEN(lcfg, 1) > sizeof(struct obd_uuid)) { CERROR("invalid conn_uuid\n"); - RETURN(-EINVAL); + return -EINVAL; } if (strcmp(obd->obd_type->typ_name, LUSTRE_MDC_NAME) && strcmp(obd->obd_type->typ_name, LUSTRE_OSC_NAME) && @@ -774,19 +774,19 @@ int class_add_conn(struct obd_device *obd, struct lustre_cfg *lcfg) strcmp(obd->obd_type->typ_name, LUSTRE_LWP_NAME) && strcmp(obd->obd_type->typ_name, LUSTRE_MGC_NAME)) { CERROR("can't add connection on non-client dev\n"); - RETURN(-EINVAL); + return -EINVAL; } imp = obd->u.cli.cl_import; if (!imp) { CERROR("try to add conn on immature client dev\n"); - RETURN(-EINVAL); + return -EINVAL; } obd_str2uuid(&uuid, lustre_cfg_string(lcfg, 1)); rc = obd_add_conn(imp, &uuid, lcfg->lcfg_num); - RETURN(rc); + return rc; } EXPORT_SYMBOL(class_add_conn); @@ -801,24 +801,24 @@ int class_del_conn(struct obd_device *obd, struct lustre_cfg *lcfg) if (LUSTRE_CFG_BUFLEN(lcfg, 1) < 1 || LUSTRE_CFG_BUFLEN(lcfg, 1) > sizeof(struct obd_uuid)) { CERROR("invalid conn_uuid\n"); - RETURN(-EINVAL); + return -EINVAL; } if (strcmp(obd->obd_type->typ_name, LUSTRE_MDC_NAME) && strcmp(obd->obd_type->typ_name, LUSTRE_OSC_NAME)) { CERROR("can't del connection on non-client dev\n"); - RETURN(-EINVAL); + return -EINVAL; } imp = obd->u.cli.cl_import; if (!imp) { CERROR("try to del conn on immature client dev\n"); - RETURN(-EINVAL); + return -EINVAL; } obd_str2uuid(&uuid, lustre_cfg_string(lcfg, 1)); rc = obd_del_conn(imp, &uuid); - RETURN(rc); + return rc; } LIST_HEAD(lustre_profile_list); @@ -829,10 +829,10 @@ struct lustre_profile *class_get_profile(const char * prof) list_for_each_entry(lprof, &lustre_profile_list, lp_list) { if (!strcmp(lprof->lp_profile, prof)) { - RETURN(lprof); + return lprof; } } - RETURN(NULL); + return NULL; } EXPORT_SYMBOL(class_get_profile); @@ -850,7 +850,7 @@ int class_add_profile(int proflen, char *prof, int osclen, char *osc, OBD_ALLOC(lprof, sizeof(*lprof)); if (lprof == NULL) - RETURN(-ENOMEM); + return -ENOMEM; INIT_LIST_HEAD(&lprof->lp_list); LASSERT(proflen == (strlen(prof) + 1)); @@ -874,7 +874,7 @@ int class_add_profile(int proflen, char *prof, int osclen, char *osc, } list_add(&lprof->lp_list, &lustre_profile_list); - RETURN(err); + return err; out: if (lprof->lp_md) @@ -884,7 +884,7 @@ int class_add_profile(int proflen, char *prof, int osclen, char *osc, if (lprof->lp_profile) OBD_FREE(lprof->lp_profile, proflen); OBD_FREE(lprof, sizeof(*lprof)); - RETURN(err); + return err; } void class_del_profile(const char *prof) @@ -937,10 +937,10 @@ static int class_set_global(char *ptr, int val, struct lustre_cfg *lcfg) strlcpy(obd_jobid_var, lustre_cfg_string(lcfg, 2), JOBSTATS_JOBID_VAR_MAX_LEN + 1); else - RETURN(-EINVAL); + return -EINVAL; CDEBUG(D_IOCTL, "global %s = %d\n", ptr, val); - RETURN(0); + return 0; } @@ -979,11 +979,11 @@ struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg, int new_len = 0; if (cfg == NULL || new_name == NULL) - RETURN(ERR_PTR(-EINVAL)); + return ERR_PTR(-EINVAL); param = lustre_cfg_string(cfg, 1); if (param == NULL) - RETURN(ERR_PTR(-EINVAL)); + return ERR_PTR(-EINVAL); value = strchr(param, '='); if (value == NULL) @@ -995,7 +995,7 @@ struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg, OBD_ALLOC(new_param, new_len); if (new_param == NULL) - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); strcpy(new_param, new_name); if (value != NULL) @@ -1004,7 +1004,7 @@ struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg, OBD_ALLOC_PTR(bufs); if (bufs == NULL) { OBD_FREE(new_param, new_len); - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); } lustre_cfg_bufs_reset(bufs, NULL); @@ -1016,14 +1016,14 @@ struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg, OBD_FREE(new_param, new_len); OBD_FREE_PTR(bufs); if (new_cfg == NULL) - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); new_cfg->lcfg_num = cfg->lcfg_num; new_cfg->lcfg_flags = cfg->lcfg_flags; new_cfg->lcfg_nid = cfg->lcfg_nid; new_cfg->lcfg_nal = cfg->lcfg_nal; - RETURN(new_cfg); + return new_cfg; } EXPORT_SYMBOL(lustre_cfg_rename); @@ -1232,7 +1232,7 @@ int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars, if (lcfg->lcfg_command != LCFG_PARAM) { CERROR("Unknown command: %d\n", lcfg->lcfg_command); - RETURN(-EINVAL); + return -EINVAL; } /* fake a seq file so that var->fops->write can work... */ @@ -1279,7 +1279,7 @@ int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars, /* If the prefix doesn't match, return error so we can pass it down the stack */ if (strnchr(key, keylen, '.')) - RETURN(-ENOSYS); + return -ENOSYS; CERROR("%s: unknown param %s\n", (char *)lustre_cfg_string(lcfg, 0), key); /* rc = -EINVAL; continue parsing other params */ @@ -1300,7 +1300,7 @@ int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars, rc = 0; if (!rc && skip) rc = skip; - RETURN(rc); + return rc; } EXPORT_SYMBOL(class_process_proc_param); @@ -1499,7 +1499,7 @@ int class_config_llog_handler(const struct lu_env *env, handle->lgh_ctxt->loc_obd->obd_name, rc); class_config_dump_handler(NULL, handle, rec, data); } - RETURN(rc); + return rc; } EXPORT_SYMBOL(class_config_llog_handler); @@ -1514,7 +1514,7 @@ int class_config_parse_llog(const struct lu_env *env, struct llog_ctxt *ctxt, CDEBUG(D_INFO, "looking up llog %s\n", name); rc = llog_open(env, ctxt, &llh, NULL, name, LLOG_OPEN_EXISTS); if (rc) - RETURN(rc); + return rc; rc = llog_init_handle(env, llh, LLOG_F_IS_PLAIN, NULL); if (rc) @@ -1540,7 +1540,7 @@ int class_config_parse_llog(const struct lu_env *env, struct llog_ctxt *ctxt, parse_out: llog_close(env, llh); - RETURN(rc); + return rc; } EXPORT_SYMBOL(class_config_parse_llog); @@ -1559,7 +1559,7 @@ int class_config_parse_rec(struct llog_rec_hdr *rec, char *buf, int size) LASSERT(rec->lrh_type == OBD_CFG_REC); rc = lustre_cfg_sanity_check(lcfg, rec->lrh_len); if (rc < 0) - RETURN(rc); + return rc; ptr += snprintf(ptr, end-ptr, "cmd=%05x ", lcfg->lcfg_command); if (lcfg->lcfg_flags) @@ -1590,7 +1590,7 @@ int class_config_parse_rec(struct llog_rec_hdr *rec, char *buf, int size) } /* return consumed bytes */ rc = ptr - buf; - RETURN(rc); + return rc; } int class_config_dump_handler(const struct lu_env *env, @@ -1602,7 +1602,7 @@ int class_config_dump_handler(const struct lu_env *env, OBD_ALLOC(outstr, 256); if (outstr == NULL) - RETURN(-ENOMEM); + return -ENOMEM; if (rec->lrh_type == OBD_CFG_REC) { class_config_parse_rec(rec, outstr, 256); @@ -1613,7 +1613,7 @@ int class_config_dump_handler(const struct lu_env *env, } OBD_FREE(outstr, 256); - RETURN(rc); + return rc; } int class_config_dump_llog(const struct lu_env *env, struct llog_ctxt *ctxt, @@ -1626,7 +1626,7 @@ int class_config_dump_llog(const struct lu_env *env, struct llog_ctxt *ctxt, rc = llog_open(env, ctxt, &llh, NULL, name, LLOG_OPEN_EXISTS); if (rc) - RETURN(rc); + return rc; rc = llog_init_handle(env, llh, LLOG_F_IS_PLAIN, NULL); if (rc) @@ -1637,7 +1637,7 @@ int class_config_dump_llog(const struct lu_env *env, struct llog_ctxt *ctxt, llog_close(env, llh); LCONSOLE_INFO("End config log %s\n", name); - RETURN(rc); + return rc; } EXPORT_SYMBOL(class_config_dump_llog); @@ -1653,7 +1653,7 @@ int class_manual_cleanup(struct obd_device *obd) if (!obd) { CERROR("empty cleanup\n"); - RETURN(-EALREADY); + return -EALREADY; } if (obd->obd_force) @@ -1668,7 +1668,7 @@ int class_manual_cleanup(struct obd_device *obd) lustre_cfg_bufs_set_string(&bufs, 1, flags); lcfg = lustre_cfg_new(LCFG_CLEANUP, &bufs); if (!lcfg) - RETURN(-ENOMEM); + return -ENOMEM; rc = class_process_config(lcfg); if (rc) { @@ -1683,7 +1683,7 @@ int class_manual_cleanup(struct obd_device *obd) CERROR("detach failed %d: %s\n", rc, obd->obd_name); out: lustre_cfg_free(lcfg); - RETURN(rc); + return rc; } EXPORT_SYMBOL(class_manual_cleanup); @@ -1775,7 +1775,7 @@ nid_key(struct hlist_node *hnode) exp = hlist_entry(hnode, struct obd_export, exp_nid_hash); - RETURN(&exp->exp_connection->c_peer.nid); + return &exp->exp_connection->c_peer.nid; } /* @@ -1790,8 +1790,8 @@ nid_kepcmp(const void *key, struct hlist_node *hnode) LASSERT(key); exp = hlist_entry(hnode, struct obd_export, exp_nid_hash); - RETURN(exp->exp_connection->c_peer.nid == *(lnet_nid_t *)key && - !exp->exp_failed); + return exp->exp_connection->c_peer.nid == *(lnet_nid_t *)key && + !exp->exp_failed; } static void * diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c b/drivers/staging/lustre/lustre/obdclass/obd_mount.c index 607dfa7fa6aca..68a4d6a0eb036 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c @@ -86,7 +86,7 @@ int lustre_process_log(struct super_block *sb, char *logname, OBD_ALLOC_PTR(bufs); if (bufs == NULL) - RETURN(-ENOMEM); + return -ENOMEM; /* mgc_process_config */ lustre_cfg_bufs_reset(bufs, mgc->obd_name); @@ -116,7 +116,7 @@ int lustre_process_log(struct super_block *sb, char *logname, rc); /* class_obd_list(); */ - RETURN(rc); + return rc; } EXPORT_SYMBOL(lustre_process_log); @@ -131,7 +131,7 @@ int lustre_end_log(struct super_block *sb, char *logname, int rc; if (!mgc) - RETURN(-ENOENT); + return -ENOENT; /* mgc_process_config */ lustre_cfg_bufs_reset(&bufs, mgc->obd_name); @@ -141,7 +141,7 @@ int lustre_end_log(struct super_block *sb, char *logname, lcfg = lustre_cfg_new(LCFG_LOG_END, &bufs); rc = obd_process_config(mgc, sizeof(*lcfg), lcfg); lustre_cfg_free(lcfg); - RETURN(rc); + return rc; } EXPORT_SYMBOL(lustre_end_log); @@ -249,7 +249,7 @@ int lustre_start_mgc(struct super_block *sb) } if (i == 0) { CERROR("No valid MGS nids found.\n"); - RETURN(-EINVAL); + return -EINVAL; } mutex_lock(&mgc_start_lock); @@ -473,7 +473,7 @@ int lustre_start_mgc(struct super_block *sb) OBD_FREE(mgcname, len); if (niduuid) OBD_FREE(niduuid, len + 2); - RETURN(rc); + return rc; } static int lustre_stop_mgc(struct super_block *sb) @@ -484,10 +484,10 @@ static int lustre_stop_mgc(struct super_block *sb) int i, rc = 0, len = 0; if (!lsi) - RETURN(-ENOENT); + return -ENOENT; obd = lsi->lsi_mgc; if (!obd) - RETURN(-ENOENT); + return -ENOENT; lsi->lsi_mgc = NULL; mutex_lock(&mgc_start_lock); @@ -543,7 +543,7 @@ static int lustre_stop_mgc(struct super_block *sb) /* class_import_put will get rid of the additional connections */ mutex_unlock(&mgc_start_lock); - RETURN(rc); + return rc; } /***************** lustre superblock **************/ @@ -554,11 +554,11 @@ struct lustre_sb_info *lustre_init_lsi(struct super_block *sb) OBD_ALLOC_PTR(lsi); if (!lsi) - RETURN(NULL); + return NULL; OBD_ALLOC_PTR(lsi->lsi_lmd); if (!lsi->lsi_lmd) { OBD_FREE_PTR(lsi); - RETURN(NULL); + return NULL; } lsi->lsi_lmd->lmd_exclude_count = 0; @@ -571,7 +571,7 @@ struct lustre_sb_info *lustre_init_lsi(struct super_block *sb) /* Default umount style */ lsi->lsi_flags = LSI_UMOUNT_FAILOVER; - RETURN(lsi); + return lsi; } static int lustre_free_lsi(struct super_block *sb) @@ -617,7 +617,7 @@ static int lustre_free_lsi(struct super_block *sb) OBD_FREE(lsi, sizeof(*lsi)); s2lsi_nocast(sb) = NULL; - RETURN(0); + return 0; } /* The lsi has one reference for every server that is using the disk - @@ -636,9 +636,9 @@ int lustre_put_lsi(struct super_block *sb) obd_zombie_barrier(); } lustre_free_lsi(sb); - RETURN(1); + return 1; } - RETURN(0); + return 0; } /*** SERVER NAME *** @@ -765,7 +765,7 @@ int lustre_common_put_super(struct super_block *sb) if (rc && (rc != -ENOENT)) { if (rc != -EBUSY) { CERROR("Can't stop MGC: %d\n", rc); - RETURN(rc); + return rc; } /* BUSY just means that there's some other obd that needs the mgc. Let him clean it up. */ @@ -774,7 +774,7 @@ int lustre_common_put_super(struct super_block *sb) /* Drop a ref to the mounted disk */ lustre_put_lsi(sb); lu_types_stop(); - RETURN(rc); + return rc; } EXPORT_SYMBOL(lustre_common_put_super); @@ -816,7 +816,7 @@ int lustre_check_exclusion(struct super_block *sb, char *svname) rc = server_name2index(svname, &index, NULL); if (rc != LDD_F_SV_TYPE_OST) /* Only exclude OSTs */ - RETURN(0); + return 0; CDEBUG(D_MOUNT, "Check exclusion %s (%d) in %d of %s\n", svname, index, lmd->lmd_exclude_count, lmd->lmd_dev); @@ -824,10 +824,10 @@ int lustre_check_exclusion(struct super_block *sb, char *svname) for(i = 0; i < lmd->lmd_exclude_count; i++) { if (index == lmd->lmd_exclude[i]) { CWARN("Excluding %s (on exclusion list)\n", svname); - RETURN(1); + return 1; } } - RETURN(0); + return 0; } /* mount -v -o exclude=lustre-OST0001:lustre-OST0002 -t lustre ... */ @@ -845,7 +845,7 @@ static int lmd_make_exclusion(struct lustre_mount_data *lmd, const char *ptr) /* temp storage until we figure out how many we have */ OBD_ALLOC(exclude_list, sizeof(index) * devmax); if (!exclude_list) - RETURN(-ENOMEM); + return -ENOMEM; /* we enter this fn pointing at the '=' */ while (*s1 && *s1 != ' ' && *s1 != ',') { @@ -883,7 +883,7 @@ static int lmd_make_exclusion(struct lustre_mount_data *lmd, const char *ptr) } } OBD_FREE(exclude_list, sizeof(index) * devmax); - RETURN(rc); + return rc; } static int lmd_parse_mgssec(struct lustre_mount_data *lmd, char *ptr) @@ -992,7 +992,7 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) if (!options) { LCONSOLE_ERROR_MSG(0x162, "Missing mount data: check that " "/sbin/mount.lustre is installed.\n"); - RETURN(-EINVAL); + return -EINVAL; } /* Options should be a string - try to detect old lmd data */ @@ -1000,13 +1000,13 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) LCONSOLE_ERROR_MSG(0x163, "You're using an old version of " "/sbin/mount.lustre. Please install " "version %s\n", LUSTRE_VERSION_STRING); - RETURN(-EINVAL); + return -EINVAL; } lmd->lmd_magic = LMD_MAGIC; OBD_ALLOC(lmd->lmd_params, 4096); if (lmd->lmd_params == NULL) - RETURN(-ENOMEM); + return -ENOMEM; lmd->lmd_params[0] = '\0'; /* Set default flags here */ @@ -1145,14 +1145,14 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) /* Freed in lustre_free_lsi */ OBD_ALLOC(lmd->lmd_profile, strlen(s1) + 8); if (!lmd->lmd_profile) - RETURN(-ENOMEM); + return -ENOMEM; sprintf(lmd->lmd_profile, "%s-client", s1); } /* Freed in lustre_free_lsi */ OBD_ALLOC(lmd->lmd_dev, strlen(devname) + 1); if (!lmd->lmd_dev) - RETURN(-ENOMEM); + return -ENOMEM; strcpy(lmd->lmd_dev, devname); /* Save mount options */ @@ -1163,18 +1163,18 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) /* Freed in lustre_free_lsi */ OBD_ALLOC(lmd->lmd_opts, strlen(options) + 1); if (!lmd->lmd_opts) - RETURN(-ENOMEM); + return -ENOMEM; strcpy(lmd->lmd_opts, options); } lmd_print(lmd); lmd->lmd_magic = LMD_MAGIC; - RETURN(rc); + return rc; invalid: CERROR("Bad mount options %s\n", options); - RETURN(-EINVAL); + return -EINVAL; } struct lustre_mount_data2 { @@ -1198,7 +1198,7 @@ int lustre_fill_super(struct super_block *sb, void *data, int silent) lsi = lustre_init_lsi(sb); if (!lsi) - RETURN(-ENOMEM); + return -ENOMEM; lmd = lsi->lsi_lmd; /* diff --git a/drivers/staging/lustre/lustre/obdecho/echo.c b/drivers/staging/lustre/lustre/obdecho/echo.c index e0f49b083f7f8..debb9cec4900a 100644 --- a/drivers/staging/lustre/lustre/obdecho/echo.c +++ b/drivers/staging/lustre/lustre/obdecho/echo.c @@ -99,7 +99,7 @@ static int echo_destroy_export(struct obd_export *exp) target_destroy_export(exp); ldlm_destroy_export(exp); - RETURN(0); + return 0; } static __u64 echo_next_id(struct obd_device *obddev) @@ -152,21 +152,21 @@ static int echo_destroy(const struct lu_env *env, struct obd_export *exp, if (!obd) { CERROR("invalid client cookie "LPX64"\n", exp->exp_handle.h_cookie); - RETURN(-EINVAL); + return -EINVAL; } if (!(oa->o_valid & OBD_MD_FLID)) { CERROR("obdo missing FLID valid flag: "LPX64"\n", oa->o_valid); - RETURN(-EINVAL); + return -EINVAL; } if (ostid_id(&oa->o_oi) > obd->u.echo.eo_lastino || ostid_id(&oa->o_oi) < ECHO_INIT_OID) { CERROR("bad destroy objid: "DOSTID"\n", POSTID(&oa->o_oi)); - RETURN(-EINVAL); + return -EINVAL; } - RETURN(0); + return 0; } static int echo_getattr(const struct lu_env *env, struct obd_export *exp, @@ -178,20 +178,20 @@ static int echo_getattr(const struct lu_env *env, struct obd_export *exp, if (!obd) { CERROR("invalid client cookie "LPX64"\n", exp->exp_handle.h_cookie); - RETURN(-EINVAL); + return -EINVAL; } if (!(oinfo->oi_oa->o_valid & OBD_MD_FLID)) { CERROR("obdo missing FLID valid flag: "LPX64"\n", oinfo->oi_oa->o_valid); - RETURN(-EINVAL); + return -EINVAL; } obdo_cpy_md(oinfo->oi_oa, &obd->u.echo.eo_oa, oinfo->oi_oa->o_valid); ostid_set_seq_echo(&oinfo->oi_oa->o_oi); ostid_set_id(&oinfo->oi_oa->o_oi, id); - RETURN(0); + return 0; } static int echo_setattr(const struct lu_env *env, struct obd_export *exp, @@ -202,13 +202,13 @@ static int echo_setattr(const struct lu_env *env, struct obd_export *exp, if (!obd) { CERROR("invalid client cookie "LPX64"\n", exp->exp_handle.h_cookie); - RETURN(-EINVAL); + return -EINVAL; } if (!(oinfo->oi_oa->o_valid & OBD_MD_FLID)) { CERROR("obdo missing FLID valid flag: "LPX64"\n", oinfo->oi_oa->o_valid); - RETURN(-EINVAL); + return -EINVAL; } memcpy(&obd->u.echo.eo_oa, oinfo->oi_oa, sizeof(*oinfo->oi_oa)); @@ -220,7 +220,7 @@ static int echo_setattr(const struct lu_env *env, struct obd_export *exp, oti->oti_ack_locks[0].lock = obd->u.echo.eo_nl_lock; } - RETURN(0); + return 0; } static void @@ -408,7 +408,7 @@ static int echo_preprw(const struct lu_env *env, int cmd, obd = export->exp_obd; if (obd == NULL) - RETURN(-EINVAL); + return -EINVAL; /* Temp fix to stop falling foul of osc_announce_cached() */ oa->o_valid &= ~(OBD_MD_FLBLOCKS | OBD_MD_FLGRANT); @@ -450,7 +450,7 @@ static int echo_preprw(const struct lu_env *env, int cmd, CDEBUG(D_PAGE, "%d pages allocated after prep\n", atomic_read(&obd->u.echo.eo_prep)); - RETURN(0); + return 0; preprw_cleanup: /* It is possible that we would rather handle errors by allow @@ -484,7 +484,7 @@ static int echo_commitrw(const struct lu_env *env, int cmd, obd = export->exp_obd; if (obd == NULL) - RETURN(-EINVAL); + return -EINVAL; if (rc) GOTO(commitrw_cleanup, rc); @@ -499,7 +499,7 @@ static int echo_commitrw(const struct lu_env *env, int cmd, if (niocount && res == NULL) { CERROR("NULL res niobuf with niocount %d\n", niocount); - RETURN(-EINVAL); + return -EINVAL; } LASSERT(oti == NULL || oti->oti_handle == (void *)DESC_PRIV); @@ -530,7 +530,7 @@ static int echo_commitrw(const struct lu_env *env, int cmd, CDEBUG(D_PAGE, "%d pages remain after commit\n", atomic_read(&obd->u.echo.eo_prep)); - RETURN(rc); + return rc; commitrw_cleanup: atomic_sub(pgs, &obd->u.echo.eo_prep); @@ -570,7 +570,7 @@ static int echo_setup(struct obd_device *obd, struct lustre_cfg *lcfg) LDLM_NS_TYPE_OST); if (obd->obd_namespace == NULL) { LBUG(); - RETURN(-ENOMEM); + return -ENOMEM; } rc = ldlm_cli_enqueue_local(obd->obd_namespace, &res_id, LDLM_PLAIN, @@ -592,7 +592,7 @@ static int echo_setup(struct obd_device *obd, struct lustre_cfg *lcfg) ptlrpc_init_client (LDLM_CB_REQUEST_PORTAL, LDLM_CB_REPLY_PORTAL, "echo_ldlm_cb_client", &obd->obd_ldlm_client); - RETURN(0); + return 0; } static int echo_cleanup(struct obd_device *obd) @@ -615,7 +615,7 @@ static int echo_cleanup(struct obd_device *obd) if (leaked != 0) CERROR("%d prep/commitrw pages leaked\n", leaked); - RETURN(0); + return 0; } struct obd_ops echo_obd_ops = { diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c index 80e3a951b95ad..25151b13fefdd 100644 --- a/drivers/staging/lustre/lustre/obdecho/echo_client.c +++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c @@ -413,7 +413,7 @@ static int echo_page_init(const struct lu_env *env, struct cl_object *obj, mutex_init(&ep->ep_lock); cl_page_slice_add(page, &ep->ep_cl, obj, &echo_page_ops); atomic_inc(&eco->eo_npages); - RETURN(0); + return 0; } static int echo_io_init(const struct lu_env *env, struct cl_object *obj, @@ -435,7 +435,7 @@ static int echo_lock_init(const struct lu_env *env, INIT_LIST_HEAD(&el->el_chain); atomic_set(&el->el_refcount, 0); } - RETURN(el == NULL ? -ENOMEM : 0); + return el == NULL ? -ENOMEM : 0; } static int echo_conf_set(const struct lu_env *env, struct cl_object *obj, @@ -473,7 +473,7 @@ static int echo_object_init(const struct lu_env *env, struct lu_object *obj, below = under->ld_ops->ldo_object_alloc(env, obj->lo_header, under); if (below == NULL) - RETURN(-ENOMEM); + return -ENOMEM; lu_object_add(obj, below); } @@ -497,7 +497,7 @@ static int echo_object_init(const struct lu_env *env, struct lu_object *obj, list_add_tail(&eco->eo_obj_chain, &ec->ec_objects); spin_unlock(&ec->ec_lock); - RETURN(0); + return 0; } /* taken from osc_unpackmd() */ @@ -515,19 +515,19 @@ static int echo_alloc_memmd(struct echo_device *ed, LASSERT(*lsmp == NULL); OBD_ALLOC(*lsmp, lsm_size); if (*lsmp == NULL) - RETURN(-ENOMEM); + return -ENOMEM; OBD_ALLOC((*lsmp)->lsm_oinfo[0], sizeof(struct lov_oinfo)); if ((*lsmp)->lsm_oinfo[0] == NULL) { OBD_FREE(*lsmp, lsm_size); - RETURN(-ENOMEM); + return -ENOMEM; } loi_init((*lsmp)->lsm_oinfo[0]); (*lsmp)->lsm_maxbytes = LUSTRE_STRIPE_MAXBYTES; ostid_set_seq_echo(&(*lsmp)->lsm_oi); - RETURN(lsm_size); + return lsm_size; } static int echo_free_memmd(struct echo_device *ed, struct lov_stripe_md **lsmp) @@ -544,7 +544,7 @@ static int echo_free_memmd(struct echo_device *ed, struct lov_stripe_md **lsmp) OBD_FREE((*lsmp)->lsm_oinfo[0], sizeof(struct lov_oinfo)); OBD_FREE(*lsmp, lsm_size); *lsmp = NULL; - RETURN(0); + return 0; } static void echo_object_free(const struct lu_env *env, struct lu_object *obj) @@ -611,7 +611,7 @@ static struct lu_object *echo_object_alloc(const struct lu_env *env, eco->eo_cl.co_ops = &echo_cl_obj_ops; obj->lo_ops = &echo_lu_obj_ops; } - RETURN(obj); + return obj; } static struct lu_device_operations echo_device_lu_ops = { @@ -729,7 +729,7 @@ static int echo_fid_init(struct echo_device *ed, char *obd_name, OBD_ALLOC_PTR(ed->ed_cl_seq); if (ed->ed_cl_seq == NULL) - RETURN(-ENOMEM); + return -ENOMEM; OBD_ALLOC(prefix, MAX_OBD_NAME + 5); if (prefix == NULL) @@ -746,12 +746,12 @@ static int echo_fid_init(struct echo_device *ed, char *obd_name, if (rc) GOTO(out_free_seq, rc); - RETURN(0); + return 0; out_free_seq: OBD_FREE_PTR(ed->ed_cl_seq); ed->ed_cl_seq = NULL; - RETURN(rc); + return rc; } static int echo_fid_fini(struct obd_device *obddev) @@ -764,7 +764,7 @@ static int echo_fid_fini(struct obd_device *obddev) ed->ed_cl_seq = NULL; } - RETURN(0); + return 0; } static struct lu_device *echo_device_alloc(const struct lu_env *env, @@ -902,7 +902,7 @@ static struct lu_device *echo_device_alloc(const struct lu_env *env, } ed->ed_next = next; - RETURN(&cd->cd_lu_dev); + return &cd->cd_lu_dev; out: switch(cleanup) { case 4: { @@ -1072,11 +1072,11 @@ static struct echo_object *cl_echo_object_find(struct echo_device *d, /* Never return an object if the obd is to be freed. */ if (echo_dev2cl(d)->cd_lu_dev.ld_obd->obd_stopping) - RETURN(ERR_PTR(-ENODEV)); + return ERR_PTR(-ENODEV); env = cl_env_get(&refcheck); if (IS_ERR(env)) - RETURN((void *)env); + return (void *)env; info = echo_env_info(env); conf = &info->eti_conf; @@ -1116,7 +1116,7 @@ static struct echo_object *cl_echo_object_find(struct echo_device *d, out: cl_env_put(env, &refcheck); - RETURN(eco); + return eco; } static int cl_echo_object_put(struct echo_object *eco) @@ -1127,7 +1127,7 @@ static int cl_echo_object_put(struct echo_object *eco) env = cl_env_get(&refcheck); if (IS_ERR(env)) - RETURN(PTR_ERR(env)); + return PTR_ERR(env); /* an external function to kill an object? */ if (eco->eo_deleted) { @@ -1138,7 +1138,7 @@ static int cl_echo_object_put(struct echo_object *eco) cl_object_put(env, obj); cl_env_put(env, &refcheck); - RETURN(0); + return 0; } static int cl_echo_enqueue0(struct lu_env *env, struct echo_object *eco, @@ -1184,7 +1184,7 @@ static int cl_echo_enqueue0(struct lu_env *env, struct echo_object *eco, cl_lock_release(env, lck, "ec enqueue", current); } } - RETURN(rc); + return rc; } static int cl_echo_enqueue(struct echo_object *eco, obd_off start, obd_off end, @@ -1198,7 +1198,7 @@ static int cl_echo_enqueue(struct echo_object *eco, obd_off start, obd_off end, env = cl_env_get(&refcheck); if (IS_ERR(env)) - RETURN(PTR_ERR(env)); + return PTR_ERR(env); info = echo_env_info(env); io = &info->eti_io; @@ -1242,10 +1242,10 @@ static int cl_echo_cancel0(struct lu_env *env, struct echo_device *ed, spin_unlock(&ec->ec_lock); if (!found) - RETURN(-ENOENT); + return -ENOENT; echo_lock_release(env, ecl, still_used); - RETURN(0); + return 0; } static int cl_echo_cancel(struct echo_device *ed, __u64 cookie) @@ -1256,12 +1256,12 @@ static int cl_echo_cancel(struct echo_device *ed, __u64 cookie) env = cl_env_get(&refcheck); if (IS_ERR(env)) - RETURN(PTR_ERR(env)); + return PTR_ERR(env); rc = cl_echo_cancel0(env, ed, cookie); cl_env_put(env, &refcheck); - RETURN(rc); + return rc; } static int cl_echo_async_brw(const struct lu_env *env, struct cl_io *io, @@ -1278,7 +1278,7 @@ static int cl_echo_async_brw(const struct lu_env *env, struct cl_io *io, continue; result = result ?: rc; } - RETURN(result); + return result; } static int cl_echo_object_brw(struct echo_object *eco, int rw, obd_off offset, @@ -1301,7 +1301,7 @@ static int cl_echo_object_brw(struct echo_object *eco, int rw, obd_off offset, LASSERT(ed->ed_next != NULL); env = cl_env_get(&refcheck); if (IS_ERR(env)) - RETURN(PTR_ERR(env)); + return PTR_ERR(env); info = echo_env_info(env); io = &info->eti_io; @@ -1447,7 +1447,7 @@ static int echo_big_lmm_get(const struct lu_env *env, struct md_object *o, rc = mo_xattr_get(env, o, &LU_BUF_NULL, XATTR_NAME_LOV); if (rc < 0) - RETURN(rc); + return rc; /* big_lmm may need to be grown */ if (info->eti_big_lmmsize < rc) { @@ -1464,7 +1464,7 @@ static int echo_big_lmm_get(const struct lu_env *env, struct md_object *o, OBD_ALLOC_LARGE(info->eti_big_lmm, size); if (info->eti_big_lmm == NULL) - RETURN(-ENOMEM); + return -ENOMEM; info->eti_big_lmmsize = size; } LASSERT(info->eti_big_lmmsize >= rc); @@ -1473,13 +1473,13 @@ static int echo_big_lmm_get(const struct lu_env *env, struct md_object *o, info->eti_buf.lb_len = info->eti_big_lmmsize; rc = mo_xattr_get(env, o, &info->eti_buf, XATTR_NAME_LOV); if (rc < 0) - RETURN(rc); + return rc; ma->ma_valid |= MA_LOV; ma->ma_lmm = info->eti_big_lmm; ma->ma_lmm_size = rc; - RETURN(0); + return 0; } int echo_attr_get_complex(const struct lu_env *env, struct md_object *next, @@ -1543,7 +1543,7 @@ int echo_attr_get_complex(const struct lu_env *env, struct md_object *next, ma->ma_need = need; CDEBUG(D_INODE, "after getattr rc = %d, ma_valid = "LPX64" ma_lmm=%p\n", rc, ma->ma_valid, ma->ma_lmm); - RETURN(rc); + return rc; } static int @@ -1570,7 +1570,7 @@ echo_md_create_internal(const struct lu_env *env, struct echo_device *ed, if (IS_ERR(ec_child)) { CERROR("Can not find the child "DFID": rc = %ld\n", PFID(fid), PTR_ERR(ec_child)); - RETURN(PTR_ERR(ec_child)); + return PTR_ERR(ec_child); } child = lu_object_locate(ec_child->lo_header, ld->ld_type); @@ -1636,7 +1636,7 @@ static int echo_create_md_object(const struct lu_env *env, return -1; parent = lu_object_locate(ec_parent->lo_header, ld->ld_type); if (parent == NULL) - RETURN(-ENXIO); + return -ENXIO; memset(ma, 0, sizeof(*ma)); memset(spec, 0, sizeof(*spec)); @@ -1666,7 +1666,7 @@ static int echo_create_md_object(const struct lu_env *env, /* If name is specified, only create one object by name */ rc = echo_md_create_internal(env, ed, lu2md(parent), fid, lname, spec, ma); - RETURN(rc); + return rc; } /* Create multiple object sequenced by id */ @@ -1686,7 +1686,7 @@ static int echo_create_md_object(const struct lu_env *env, fid->f_oid++; } - RETURN(rc); + return rc; } static struct lu_object *echo_md_lookup(const struct lu_env *env, @@ -1704,7 +1704,7 @@ static struct lu_object *echo_md_lookup(const struct lu_env *env, rc = mdo_lookup(env, parent, lname, fid, NULL); if (rc) { CERROR("lookup %s: rc = %d\n", lname->ln_name, rc); - RETURN(ERR_PTR(rc)); + return ERR_PTR(rc); } /* In the function below, .hs_keycmp resolves to @@ -1712,7 +1712,7 @@ static struct lu_object *echo_md_lookup(const struct lu_env *env, /* coverity[overrun-buffer-val] */ child = lu_object_find_at(env, &ed->ed_cl.cd_lu_dev, fid, NULL); - RETURN(child); + return child; } static int echo_setattr_object(const struct lu_env *env, @@ -1733,7 +1733,7 @@ static int echo_setattr_object(const struct lu_env *env, return -1; parent = lu_object_locate(ec_parent->lo_header, ld->ld_type); if (parent == NULL) - RETURN(-ENXIO); + return -ENXIO; for (i = 0; i < count; i++) { struct lu_object *ec_child, *child; @@ -1744,7 +1744,7 @@ static int echo_setattr_object(const struct lu_env *env, if (IS_ERR(ec_child)) { CERROR("Can't find child %s: rc = %ld\n", lname->ln_name, PTR_ERR(ec_child)); - RETURN(PTR_ERR(ec_child)); + return PTR_ERR(ec_child); } child = lu_object_locate(ec_child->lo_header, ld->ld_type); @@ -1775,7 +1775,7 @@ static int echo_setattr_object(const struct lu_env *env, id++; lu_object_put(env, ec_child); } - RETURN(rc); + return rc; } static int echo_getattr_object(const struct lu_env *env, @@ -1796,7 +1796,7 @@ static int echo_getattr_object(const struct lu_env *env, return -1; parent = lu_object_locate(ec_parent->lo_header, ld->ld_type); if (parent == NULL) - RETURN(-ENXIO); + return -ENXIO; memset(ma, 0, sizeof(*ma)); ma->ma_need |= MA_INODE | MA_LOV | MA_PFID | MA_HSM | MA_ACL_DEF; @@ -1814,14 +1814,14 @@ static int echo_getattr_object(const struct lu_env *env, if (IS_ERR(ec_child)) { CERROR("Can't find child %s: rc = %ld\n", lname->ln_name, PTR_ERR(ec_child)); - RETURN(PTR_ERR(ec_child)); + return PTR_ERR(ec_child); } child = lu_object_locate(ec_child->lo_header, ld->ld_type); if (child == NULL) { CERROR("Can not locate the child %s\n", lname->ln_name); lu_object_put(env, ec_child); - RETURN(-EINVAL); + return -EINVAL; } CDEBUG(D_RPCTRACE, "Start getattr object "DFID"\n", @@ -1839,7 +1839,7 @@ static int echo_getattr_object(const struct lu_env *env, lu_object_put(env, ec_child); } - RETURN(rc); + return rc; } static int echo_lookup_object(const struct lu_env *env, @@ -1897,7 +1897,7 @@ static int echo_md_destroy_internal(const struct lu_env *env, if (IS_ERR(ec_child)) { CERROR("Can't find child %s: rc = %ld\n", lname->ln_name, PTR_ERR(ec_child)); - RETURN(PTR_ERR(ec_child)); + return PTR_ERR(ec_child); } child = lu_object_locate(ec_child->lo_header, ld->ld_type); @@ -1939,7 +1939,7 @@ static int echo_destroy_object(const struct lu_env *env, parent = lu_object_locate(ec_parent->lo_header, ld->ld_type); if (parent == NULL) - RETURN(-EINVAL); + return -EINVAL; memset(ma, 0, sizeof(*ma)); ma->ma_attr.la_mode = mode; @@ -1953,7 +1953,7 @@ static int echo_destroy_object(const struct lu_env *env, lname->ln_namelen = namelen; rc = echo_md_destroy_internal(env, ed, lu2md(parent), lname, ma); - RETURN(rc); + return rc; } /*prepare the requests*/ @@ -1972,7 +1972,7 @@ static int echo_destroy_object(const struct lu_env *env, id++; } - RETURN(rc); + return rc; } static struct lu_object *echo_resolve_path(const struct lu_env *env, @@ -1992,7 +1992,7 @@ static struct lu_object *echo_resolve_path(const struct lu_env *env, rc = md->md_ops->mdo_root_get(env, md, fid); if (rc) { CERROR("get root error: rc = %d\n", rc); - RETURN(ERR_PTR(rc)); + return ERR_PTR(rc); } /* In the function below, .hs_keycmp resolves to @@ -2002,7 +2002,7 @@ static struct lu_object *echo_resolve_path(const struct lu_env *env, if (IS_ERR(parent)) { CERROR("Can not find the parent "DFID": rc = %ld\n", PFID(fid), PTR_ERR(parent)); - RETURN(parent); + return parent; } while (1) { @@ -2041,9 +2041,9 @@ static struct lu_object *echo_resolve_path(const struct lu_env *env, parent = child; } if (rc) - RETURN(ERR_PTR(rc)); + return ERR_PTR(rc); - RETURN(parent); + return parent; } static void echo_ucred_init(struct lu_env *env) @@ -2094,17 +2094,17 @@ static int echo_md_handler(struct echo_device *ed, int command, if (ld == NULL) { CERROR("MD echo client is not being initialized properly\n"); - RETURN(-EINVAL); + return -EINVAL; } if (strcmp(ld->ld_type->ldt_name, LUSTRE_MDD_NAME)) { CERROR("Only support MDD layer right now!\n"); - RETURN(-EINVAL); + return -EINVAL; } env = cl_env_get(&refcheck); if (IS_ERR(env)) - RETURN(PTR_ERR(env)); + return PTR_ERR(env); rc = lu_env_refill_by_tags(env, ECHO_MD_CTX_TAG, ECHO_MD_SES_TAG); if (rc != 0) @@ -2209,7 +2209,7 @@ static int echo_create_object(const struct lu_env *env, struct echo_device *ed, (on_target || /* set_stripe */ ec->ec_nstripes != 0)) { /* LOV */ CERROR ("No valid oid\n"); - RETURN(-EINVAL); + return -EINVAL; } rc = echo_alloc_memmd(ed, &lsm); @@ -2296,12 +2296,12 @@ static int echo_get_object(struct echo_object **ecop, struct echo_device *ed, if ((oa->o_valid & OBD_MD_FLID) == 0 || ostid_id(&oa->o_oi) == 0) { /* disallow use of object id 0 */ CERROR ("No valid oid\n"); - RETURN(-EINVAL); + return -EINVAL; } rc = echo_alloc_memmd(ed, &lsm); if (rc < 0) - RETURN(rc); + return rc; lsm->lsm_oi = oa->o_oi; if (!(oa->o_valid & OBD_MD_FLGROUP)) @@ -2315,7 +2315,7 @@ static int echo_get_object(struct echo_object **ecop, struct echo_device *ed, rc = PTR_ERR(eco); if (lsm) echo_free_memmd(ed, &lsm); - RETURN(rc); + return rc; } static void echo_put_object(struct echo_object *eco) @@ -2447,7 +2447,7 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa, if (count <= 0 || (count & (~CFS_PAGE_MASK)) != 0) - RETURN(-EINVAL); + return -EINVAL; /* XXX think again with misaligned I/O */ npages = count >> PAGE_CACHE_SHIFT; @@ -2457,12 +2457,12 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa, OBD_ALLOC(pga, npages * sizeof(*pga)); if (pga == NULL) - RETURN(-ENOMEM); + return -ENOMEM; OBD_ALLOC(pages, npages * sizeof(*pages)); if (pages == NULL) { OBD_FREE(pga, npages * sizeof(*pga)); - RETURN(-ENOMEM); + return -ENOMEM; } for (i = 0, pgp = pga, off = offset; @@ -2511,7 +2511,7 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa, } OBD_FREE(pga, npages * sizeof(*pga)); OBD_FREE(pages, npages * sizeof(*pages)); - RETURN(rc); + return rc; } static int echo_client_prep_commit(const struct lu_env *env, @@ -2531,7 +2531,7 @@ static int echo_client_prep_commit(const struct lu_env *env, if (count <= 0 || (count & (~CFS_PAGE_MASK)) != 0 || (lsm != NULL && ostid_id(&lsm->lsm_oi) != ostid_id(&oa->o_oi))) - RETURN(-EINVAL); + return -EINVAL; npages = batch >> PAGE_CACHE_SHIFT; tot_pages = count >> PAGE_CACHE_SHIFT; @@ -2616,7 +2616,7 @@ static int echo_client_prep_commit(const struct lu_env *env, OBD_FREE(lnb, npages * sizeof(struct niobuf_local)); if (rnb) OBD_FREE(rnb, npages * sizeof(struct niobuf_remote)); - RETURN(ret); + return ret; } static int echo_client_brw_ioctl(const struct lu_env *env, int rw, @@ -2637,7 +2637,7 @@ static int echo_client_brw_ioctl(const struct lu_env *env, int rw, rc = echo_get_object(&eco, ed, oa); if (rc) - RETURN(rc); + return rc; oa->o_valid &= ~OBD_MD_FLHANDLE; @@ -2673,7 +2673,7 @@ static int echo_client_brw_ioctl(const struct lu_env *env, int rw, rc = -EINVAL; } echo_put_object(eco); - RETURN(rc); + return rc; } static int @@ -2687,18 +2687,18 @@ echo_client_enqueue(struct obd_export *exp, struct obdo *oa, int rc; if (ed->ed_next == NULL) - RETURN(-EOPNOTSUPP); + return -EOPNOTSUPP; if (!(mode == LCK_PR || mode == LCK_PW)) - RETURN(-EINVAL); + return -EINVAL; if ((offset & (~CFS_PAGE_MASK)) != 0 || (nob & (~CFS_PAGE_MASK)) != 0) - RETURN(-EINVAL); + return -EINVAL; rc = echo_get_object (&eco, ed, oa); if (rc != 0) - RETURN(rc); + return rc; end = (nob == 0) ? ((obd_off) -1) : (offset + nob - 1); rc = cl_echo_enqueue(eco, offset, end, mode, &ulh->cookie); @@ -2707,7 +2707,7 @@ echo_client_enqueue(struct obd_export *exp, struct obdo *oa, CDEBUG(D_INFO, "Cookie is "LPX64"\n", ulh->cookie); } echo_put_object(eco); - RETURN(rc); + return rc; } static int @@ -2752,11 +2752,11 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len, /* This FID is unpacked just for validation at this point */ rc = ostid_to_fid(&fid, &oa->o_oi, 0); if (rc < 0) - RETURN(rc); + return rc; OBD_ALLOC_PTR(env); if (env == NULL) - RETURN(-ENOMEM); + return -ENOMEM; rc = lu_env_init(env, LCT_DT_THREAD); if (rc) @@ -2958,14 +2958,14 @@ static int echo_client_setup(const struct lu_env *env, if (lcfg->lcfg_bufcount < 2 || LUSTRE_CFG_BUFLEN(lcfg, 1) < 1) { CERROR("requires a TARGET OBD name\n"); - RETURN(-EINVAL); + return -EINVAL; } tgt = class_name2obd(lustre_cfg_string(lcfg, 1)); if (!tgt || !tgt->obd_attached || !tgt->obd_set_up) { CERROR("device not attached or not set up (%s)\n", lustre_cfg_string(lcfg, 1)); - RETURN(-EINVAL); + return -EINVAL; } spin_lock_init(&ec->ec_lock); @@ -2977,7 +2977,7 @@ static int echo_client_setup(const struct lu_env *env, if (!strcmp(tgt->obd_type->typ_name, LUSTRE_MDT_NAME)) { lu_context_tags_update(ECHO_MD_CTX_TAG); lu_session_tags_update(ECHO_MD_SES_TAG); - RETURN(0); + return 0; } OBD_ALLOC(ocd, sizeof(*ocd)); @@ -3012,7 +3012,7 @@ static int echo_client_setup(const struct lu_env *env, return (rc); } - RETURN(rc); + return rc; } static int echo_client_cleanup(struct obd_device *obddev) @@ -3023,17 +3023,17 @@ static int echo_client_cleanup(struct obd_device *obddev) /*Do nothing for Metadata echo client*/ if (ed == NULL ) - RETURN(0); + return 0; if (ed->ed_next_ismd) { lu_context_tags_clear(ECHO_MD_CTX_TAG); lu_session_tags_clear(ECHO_MD_SES_TAG); - RETURN(0); + return 0; } if (!list_empty(&obddev->obd_exports)) { CERROR("still has clients!\n"); - RETURN(-EBUSY); + return -EBUSY; } LASSERT(atomic_read(&ec->ec_exp->exp_refcount) > 0); @@ -3041,7 +3041,7 @@ static int echo_client_cleanup(struct obd_device *obddev) if (rc != 0) CERROR("fail to disconnect device: %d\n", rc); - RETURN(rc); + return rc; } static int echo_client_connect(const struct lu_env *env, @@ -3057,7 +3057,7 @@ static int echo_client_connect(const struct lu_env *env, *exp = class_conn2export(&conn); } - RETURN (rc); + return rc; } static int echo_client_disconnect(struct obd_export *exp) @@ -3151,7 +3151,7 @@ static int __init obdecho_init(void) rc = echo_client_init(); - RETURN(rc); + return rc; } static void /*__exit*/ obdecho_exit(void) diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index daaab369c88b5..00295da4ab3dd 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -571,7 +571,7 @@ int osc_extent_release(const struct lu_env *env, struct osc_extent *ext) osc_io_unplug_async(env, osc_cli(obj), obj); } osc_extent_put(env, ext); - RETURN(rc); + return rc; } static inline int overlapped(struct osc_extent *ex1, struct osc_extent *ex2) @@ -604,7 +604,7 @@ struct osc_extent *osc_extent_find(const struct lu_env *env, cur = osc_extent_alloc(obj); if (cur == NULL) - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); lock = cl_lock_at_pgoff(env, osc2cl(obj), index, NULL, 1, 0); LASSERT(lock != NULL); @@ -842,7 +842,7 @@ int osc_extent_finish(const struct lu_env *env, struct osc_extent *ext, osc_extent_remove(ext); /* put the refcount for RPC */ osc_extent_put(env, ext); - RETURN(0); + return 0; } static int extent_wait_cb(struct osc_extent *ext, int state) @@ -897,7 +897,7 @@ static int osc_extent_wait(const struct lu_env *env, struct osc_extent *ext, } if (rc == 0 && ext->oe_rc < 0) rc = ext->oe_rc; - RETURN(rc); + return rc; } /** @@ -1015,7 +1015,7 @@ static int osc_extent_truncate(struct osc_extent *ext, pgoff_t trunc_index, out: cl_io_fini(env, io); cl_env_nested_put(&nest, env); - RETURN(rc); + return rc; } /** @@ -1089,7 +1089,7 @@ static int osc_extent_make_ready(const struct lu_env *env, /* get a refcount for RPC. */ osc_extent_get(ext); - RETURN(0); + return 0; } /** @@ -1138,7 +1138,7 @@ static int osc_extent_expand(struct osc_extent *ext, pgoff_t index, int *grants) out: osc_object_unlock(obj); - RETURN(rc); + return rc; } static void osc_extent_tree_dump0(int level, struct osc_object *obj, @@ -1201,7 +1201,7 @@ static int osc_make_ready(const struct lu_env *env, struct osc_async_page *oap, result = cl_page_make_ready(env, page, CRT_WRITE); if (result == 0) opg->ops_submit_time = cfs_time_current(); - RETURN(result); + return result; } static int osc_refresh_count(const struct lu_env *env, @@ -1293,7 +1293,7 @@ static int osc_completion(const struct lu_env *env, struct osc_async_page *oap, cl_page_completion(env, page, crt, rc); - RETURN(0); + return 0; } #define OSC_DUMP_GRANT(cli, fmt, args...) do { \ @@ -1543,7 +1543,7 @@ static int osc_enter_cache(const struct lu_env *env, struct client_obd *cli, out: client_obd_list_unlock(&cli->cl_loi_list_lock); OSC_DUMP_GRANT(cli, "returned %d.\n", rc); - RETURN(rc); + return rc; } /* caller must hold loi_list_lock */ @@ -1602,42 +1602,42 @@ static int osc_makes_rpc(struct client_obd *cli, struct osc_object *osc, if (cmd & OBD_BRW_WRITE) { if (atomic_read(&osc->oo_nr_writes) == 0) - RETURN(0); + return 0; if (invalid_import) { CDEBUG(D_CACHE, "invalid import forcing RPC\n"); - RETURN(1); + return 1; } if (!list_empty(&osc->oo_hp_exts)) { CDEBUG(D_CACHE, "high prio request forcing RPC\n"); - RETURN(1); + return 1; } if (!list_empty(&osc->oo_urgent_exts)) { CDEBUG(D_CACHE, "urgent request forcing RPC\n"); - RETURN(1); + return 1; } /* trigger a write rpc stream as long as there are dirtiers * waiting for space. as they're waiting, they're not going to * create more pages to coalesce with what's waiting.. */ if (!list_empty(&cli->cl_cache_waiters)) { CDEBUG(D_CACHE, "cache waiters forcing RPC\n"); - RETURN(1); + return 1; } if (atomic_read(&osc->oo_nr_writes) >= cli->cl_max_pages_per_rpc) - RETURN(1); + return 1; } else { if (atomic_read(&osc->oo_nr_reads) == 0) - RETURN(0); + return 0; if (invalid_import) { CDEBUG(D_CACHE, "invalid import forcing RPC\n"); - RETURN(1); + return 1; } /* all read are urgent. */ if (!list_empty(&osc->oo_reading_exts)) - RETURN(1); + return 1; } - RETURN(0); + return 0; } static void osc_update_pending(struct osc_object *obj, int cmd, int delta) @@ -1776,7 +1776,7 @@ static int try_to_add_extent_for_io(struct client_obd *cli, *max_pages = max(ext->oe_mppr, *max_pages); if (*pc + ext->oe_nr_pages > *max_pages) - RETURN(0); + return 0; list_for_each_entry(tmp, rpclist, oe_link) { EASSERT(tmp->oe_owner == current, tmp); @@ -1789,7 +1789,7 @@ static int try_to_add_extent_for_io(struct client_obd *cli, if (tmp->oe_srvlock != ext->oe_srvlock || !tmp->oe_grants != !ext->oe_grants) - RETURN(0); + return 0; /* remove break for strict check */ break; @@ -1798,7 +1798,7 @@ static int try_to_add_extent_for_io(struct client_obd *cli, *pc += ext->oe_nr_pages; list_move_tail(&ext->oe_link, rpclist); ext->oe_owner = current; - RETURN(1); + return 1; } /** @@ -1894,7 +1894,7 @@ osc_send_write_rpc(const struct lu_env *env, struct client_obd *cli, LASSERT(equi(page_count == 0, list_empty(&rpclist))); if (list_empty(&rpclist)) - RETURN(0); + return 0; osc_update_pending(osc, OBD_BRW_WRITE, -page_count); @@ -1935,7 +1935,7 @@ osc_send_write_rpc(const struct lu_env *env, struct client_obd *cli, } osc_object_lock(osc); - RETURN(rc); + return rc; } /** @@ -1982,7 +1982,7 @@ osc_send_read_rpc(const struct lu_env *env, struct client_obd *cli, osc_object_lock(osc); } - RETURN(rc); + return rc; } #define list_to_obj(list, item) ({ \ @@ -1999,9 +1999,9 @@ static struct osc_object *osc_next_obj(struct client_obd *cli) * will be flushed quickly and other clients can get the lock, * then objects which have pages ready to be stuffed into RPCs */ if (!list_empty(&cli->cl_loi_hp_ready_list)) - RETURN(list_to_obj(&cli->cl_loi_hp_ready_list, hp_ready_item)); + return list_to_obj(&cli->cl_loi_hp_ready_list, hp_ready_item); if (!list_empty(&cli->cl_loi_ready_list)) - RETURN(list_to_obj(&cli->cl_loi_ready_list, ready_item)); + return list_to_obj(&cli->cl_loi_ready_list, ready_item); /* then if we have cache waiters, return all objects with queued * writes. This is especially important when many small files @@ -2009,19 +2009,17 @@ static struct osc_object *osc_next_obj(struct client_obd *cli) * they don't pass the nr_pending/object threshhold */ if (!list_empty(&cli->cl_cache_waiters) && !list_empty(&cli->cl_loi_write_list)) - RETURN(list_to_obj(&cli->cl_loi_write_list, write_item)); + return list_to_obj(&cli->cl_loi_write_list, write_item); /* then return all queued objects when we have an invalid import * so that they get flushed */ if (cli->cl_import == NULL || cli->cl_import->imp_invalid) { if (!list_empty(&cli->cl_loi_write_list)) - RETURN(list_to_obj(&cli->cl_loi_write_list, - write_item)); + return list_to_obj(&cli->cl_loi_write_list, write_item); if (!list_empty(&cli->cl_loi_read_list)) - RETURN(list_to_obj(&cli->cl_loi_read_list, - read_item)); + return list_to_obj(&cli->cl_loi_read_list, read_item); } - RETURN(NULL); + return NULL; } /* called with the loi list lock held */ @@ -2157,7 +2155,7 @@ int osc_prep_async_page(struct osc_object *osc, struct osc_page *ops, spin_lock_init(&oap->oap_lock); CDEBUG(D_INFO, "oap %p page %p obj off "LPU64"\n", oap, page, oap->oap_obj_off); - RETURN(0); + return 0; } int osc_queue_async_io(const struct lu_env *env, struct cl_io *io, @@ -2176,14 +2174,14 @@ int osc_queue_async_io(const struct lu_env *env, struct cl_io *io, int rc = 0; if (oap->oap_magic != OAP_MAGIC) - RETURN(-EINVAL); + return -EINVAL; if (cli->cl_import == NULL || cli->cl_import->imp_invalid) - RETURN(-EIO); + return -EIO; if (!list_empty(&oap->oap_pending_item) || !list_empty(&oap->oap_rpc_item)) - RETURN(-EBUSY); + return -EBUSY; /* Set the OBD_BRW_SRVLOCK before the page is queued. */ brw_flags |= ops->ops_srvlock ? OBD_BRW_SRVLOCK : 0; @@ -2211,7 +2209,7 @@ int osc_queue_async_io(const struct lu_env *env, struct cl_io *io, if (rc == 0 && osc_quota_chkdq(cli, qid) == NO_QUOTA) rc = -EDQUOT; if (rc) - RETURN(rc); + return rc; } oap->oap_cmd = cmd; @@ -2319,7 +2317,7 @@ int osc_queue_async_io(const struct lu_env *env, struct cl_io *io, list_add_tail(&oap->oap_pending_item, &ext->oe_pages); osc_object_unlock(osc); } - RETURN(rc); + return rc; } int osc_teardown_async_page(const struct lu_env *env, @@ -2352,7 +2350,7 @@ int osc_teardown_async_page(const struct lu_env *env, osc_object_unlock(obj); if (ext != NULL) osc_extent_put(env, ext); - RETURN(rc); + return rc; } /** @@ -2491,7 +2489,7 @@ int osc_cancel_async_page(const struct lu_env *env, struct osc_page *ops) } osc_list_maint(cli, obj); - RETURN(rc); + return rc; } int osc_queue_sync_pages(const struct lu_env *env, struct osc_object *obj, @@ -2521,7 +2519,7 @@ int osc_queue_sync_pages(const struct lu_env *env, struct osc_object *obj, list_del_init(&oap->oap_pending_item); osc_ap_completion(env, cli, oap, 0, -ENOMEM); } - RETURN(-ENOMEM); + return -ENOMEM; } ext->oe_rw = !!(cmd & OBD_BRW_READ); @@ -2547,7 +2545,7 @@ int osc_queue_sync_pages(const struct lu_env *env, struct osc_object *obj, osc_object_unlock(obj); osc_io_unplug(env, cli, obj, PDL_POLICY_ROUND); - RETURN(0); + return 0; } /** @@ -2668,7 +2666,7 @@ int osc_cache_truncate_start(const struct lu_env *env, struct osc_io *oio, waiting = NULL; goto again; } - RETURN(result); + return result; } /** @@ -2756,7 +2754,7 @@ int osc_cache_wait_range(const struct lu_env *env, struct osc_object *obj, osc_object_unlock(obj); OSC_IO_DEBUG(obj, "sync file range.\n"); - RETURN(result); + return result; } /** @@ -2871,7 +2869,7 @@ int osc_cache_writeback_range(const struct lu_env *env, struct osc_object *obj, } OSC_IO_DEBUG(obj, "cache page out.\n"); - RETURN(result); + return result; } /** @} osc */ diff --git a/drivers/staging/lustre/lustre/osc/osc_dev.c b/drivers/staging/lustre/lustre/osc/osc_dev.c index 4059591f25b06..35f2578676371 100644 --- a/drivers/staging/lustre/lustre/osc/osc_dev.c +++ b/drivers/staging/lustre/lustre/osc/osc_dev.c @@ -171,7 +171,7 @@ LU_TYPE_INIT_FINI(osc, &osc_key, &osc_session_key); static int osc_cl_process_config(const struct lu_env *env, struct lu_device *d, struct lustre_cfg *cfg) { - RETURN(osc_process_config_base(d->ld_obd, cfg)); + return osc_process_config_base(d->ld_obd, cfg); } static const struct lu_device_operations osc_lu_ops = { @@ -187,7 +187,7 @@ static const struct cl_device_operations osc_cl_ops = { static int osc_device_init(const struct lu_env *env, struct lu_device *d, const char *name, struct lu_device *next) { - RETURN(0); + return 0; } static struct lu_device *osc_device_fini(const struct lu_env *env, @@ -217,7 +217,7 @@ static struct lu_device *osc_device_alloc(const struct lu_env *env, OBD_ALLOC_PTR(od); if (od == NULL) - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); cl_device_init(&od->od_cl, t); d = osc2lu_dev(od); @@ -230,10 +230,10 @@ static struct lu_device *osc_device_alloc(const struct lu_env *env, rc = osc_setup(obd, cfg); if (rc) { osc_device_free(env, d); - RETURN(ERR_PTR(rc)); + return ERR_PTR(rc); } od->od_exp = obd->obd_self_export; - RETURN(d); + return d; } static const struct lu_device_type_operations osc_device_type_ops = { diff --git a/drivers/staging/lustre/lustre/osc/osc_io.c b/drivers/staging/lustre/lustre/osc/osc_io.c index 60e5c9d5cfa08..3aeaf845cf278 100644 --- a/drivers/staging/lustre/lustre/osc/osc_io.c +++ b/drivers/staging/lustre/lustre/osc/osc_io.c @@ -275,7 +275,7 @@ static int osc_io_prepare_write(const struct lu_env *env, * [from, to) bytes of this page to OST. -jay */ cl_page_export(env, slice->cpl_page, 1); - RETURN(result); + return result; } static int osc_io_commit_write(const struct lu_env *env, @@ -304,7 +304,7 @@ static int osc_io_commit_write(const struct lu_env *env, /* see osc_io_prepare_write() for lockless io handling. */ cl_page_clip(env, slice->cpl_page, from, to); - RETURN(0); + return 0; } static int osc_io_fault_start(const struct lu_env *env, @@ -325,7 +325,7 @@ static int osc_io_fault_start(const struct lu_env *env, if (fio->ft_writable) osc_page_touch_at(env, ios->cis_obj, fio->ft_index, fio->ft_nob); - RETURN(0); + return 0; } static int osc_async_upcall(void *a, int rc) @@ -524,7 +524,7 @@ static int osc_io_read_start(const struct lu_env *env, } cl_object_attr_unlock(obj); } - RETURN(result); + return result; } static int osc_io_write_start(const struct lu_env *env, @@ -547,7 +547,7 @@ static int osc_io_write_start(const struct lu_env *env, } cl_object_attr_unlock(obj); } - RETURN(result); + return result; } static int osc_fsync_ost(const struct lu_env *env, struct osc_object *obj, @@ -578,7 +578,7 @@ static int osc_fsync_ost(const struct lu_env *env, struct osc_object *obj, rc = osc_sync_base(osc_export(obj), oinfo, osc_async_upcall, cbargs, PTLRPCD_SET); - RETURN(rc); + return rc; } static int osc_io_fsync_start(const struct lu_env *env, @@ -617,7 +617,7 @@ static int osc_io_fsync_start(const struct lu_env *env, result = rc; } - RETURN(result); + return result; } static void osc_io_fsync_end(const struct lu_env *env, diff --git a/drivers/staging/lustre/lustre/osc/osc_lock.c b/drivers/staging/lustre/lustre/osc/osc_lock.c index d8fb36780070d..5d7bdbfc871af 100644 --- a/drivers/staging/lustre/lustre/osc/osc_lock.c +++ b/drivers/staging/lustre/lustre/osc/osc_lock.c @@ -580,7 +580,7 @@ static int osc_lock_upcall(void *cookie, int errcode) /* should never happen, similar to osc_ldlm_blocking_ast(). */ LBUG(); } - RETURN(errcode); + return errcode; } /** @@ -1084,7 +1084,7 @@ static int osc_lock_enqueue_wait(const struct lu_env *env, rc = CLO_WAIT; } } - RETURN(rc); + return rc; } /** @@ -1160,7 +1160,7 @@ static int osc_lock_enqueue(const struct lu_env *env, } } LASSERT(ergo(ols->ols_glimpse, !osc_lock_is_lockless(ols))); - RETURN(result); + return result; } static int osc_lock_wait(const struct lu_env *env, @@ -1280,7 +1280,7 @@ static int osc_lock_flush(struct osc_lock *ols, int discard) ols->ols_flush = 1; LINVRNT(!osc_lock_has_pages(ols)); } - RETURN(result); + return result; } /** diff --git a/drivers/staging/lustre/lustre/osc/osc_object.c b/drivers/staging/lustre/lustre/osc/osc_object.c index 5d6c7630784c4..9d34de873fac8 100644 --- a/drivers/staging/lustre/lustre/osc/osc_object.c +++ b/drivers/staging/lustre/lustre/osc/osc_object.c @@ -193,7 +193,7 @@ static int osc_object_glimpse(const struct lu_env *env, lvb->lvb_size = oinfo->loi_kms; lvb->lvb_blocks = oinfo->loi_lvb.lvb_blocks; - RETURN(0); + return 0; } diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c index 6aa59e93a047a..ed84df0a4e600 100644 --- a/drivers/staging/lustre/lustre/osc/osc_page.c +++ b/drivers/staging/lustre/lustre/osc/osc_page.c @@ -239,7 +239,7 @@ static int osc_page_cache_add(const struct lu_env *env, } } - RETURN(result); + return result; } void osc_index2policy(ldlm_policy_data_t *policy, const struct cl_object *obj, @@ -300,7 +300,7 @@ static int osc_page_is_under_lock(const struct lu_env *env, result = -EBUSY; cl_lock_put(env, lock); } - RETURN(result); + return result; } static void osc_page_disown(const struct lu_env *env, @@ -479,7 +479,7 @@ static int osc_page_flush(const struct lu_env *env, int rc = 0; rc = osc_flush_async_page(env, io, opg); - RETURN(rc); + return rc; } static const struct cl_page_operations osc_page_ops = { @@ -665,11 +665,11 @@ int osc_lru_shrink(struct client_obd *cli, int target) LASSERT(atomic_read(&cli->cl_lru_in_list) >= 0); if (atomic_read(&cli->cl_lru_in_list) == 0 || target <= 0) - RETURN(0); + return 0; env = cl_env_nested_get(&nest); if (IS_ERR(env)) - RETURN(PTR_ERR(env)); + return PTR_ERR(env); pvec = osc_env_info(env)->oti_pvec; io = &osc_env_info(env)->oti_io; @@ -752,7 +752,7 @@ int osc_lru_shrink(struct client_obd *cli, int target) cl_env_nested_put(&nest, env); atomic_dec(&cli->cl_lru_shrinkers); - RETURN(count > 0 ? count : rc); + return count > 0 ? count : rc; } static void osc_lru_add(struct client_obd *cli, struct osc_page *opg) @@ -878,7 +878,7 @@ static int osc_lru_reserve(const struct lu_env *env, struct osc_object *obj, int rc = 0; if (cli->cl_cache == NULL) /* shall not be in LRU */ - RETURN(0); + return 0; LASSERT(atomic_read(cli->cl_lru_left) >= 0); while (!cfs_atomic_add_unless(cli->cl_lru_left, -1, 0)) { @@ -915,7 +915,7 @@ static int osc_lru_reserve(const struct lu_env *env, struct osc_object *obj, rc = 0; } - RETURN(rc); + return rc; } /** @} osc */ diff --git a/drivers/staging/lustre/lustre/osc/osc_quota.c b/drivers/staging/lustre/lustre/osc/osc_quota.c index b178e213eecdf..9720c0e865c8d 100644 --- a/drivers/staging/lustre/lustre/osc/osc_quota.c +++ b/drivers/staging/lustre/lustre/osc/osc_quota.c @@ -61,11 +61,11 @@ int osc_quota_chkdq(struct client_obd *cli, const unsigned int qid[]) * quota space on this OST */ CDEBUG(D_QUOTA, "chkdq found noquota for %s %d\n", type == USRQUOTA ? "user" : "grout", qid[type]); - RETURN(NO_QUOTA); + return NO_QUOTA; } } - RETURN(QUOTA_OK); + return QUOTA_OK; } #define MD_QUOTA_FLAG(type) ((type == USRQUOTA) ? OBD_MD_FLUSRQUOTA \ @@ -80,7 +80,7 @@ int osc_quota_setdq(struct client_obd *cli, const unsigned int qid[], int rc = 0; if ((valid & (OBD_MD_FLUSRQUOTA | OBD_MD_FLGRPQUOTA)) == 0) - RETURN(0); + return 0; for (type = 0; type < MAXQUOTAS; type++) { struct osc_quota_info *oqi; @@ -132,7 +132,7 @@ int osc_quota_setdq(struct client_obd *cli, const unsigned int qid[], } } - RETURN(rc); + return rc; } /* @@ -225,12 +225,12 @@ int osc_quota_setup(struct obd_device *obd) } if (type == MAXQUOTAS) - RETURN(0); + return 0; for (i = 0; i < type; i++) cfs_hash_putref(cli->cl_quota_hash[i]); - RETURN(-ENOMEM); + return -ENOMEM; } int osc_quota_cleanup(struct obd_device *obd) @@ -241,7 +241,7 @@ int osc_quota_cleanup(struct obd_device *obd) for (type = 0; type < MAXQUOTAS; type++) cfs_hash_putref(cli->cl_quota_hash[type]); - RETURN(0); + return 0; } int osc_quotactl(struct obd_device *unused, struct obd_export *exp, @@ -255,7 +255,7 @@ int osc_quotactl(struct obd_device *unused, struct obd_export *exp, &RQF_OST_QUOTACTL, LUSTRE_OST_VERSION, OST_QUOTACTL); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; oqc = req_capsule_client_get(&req->rq_pill, &RMF_OBD_QUOTACTL); *oqc = *oqctl; @@ -277,7 +277,7 @@ int osc_quotactl(struct obd_device *unused, struct obd_export *exp, } ptlrpc_req_finished(req); - RETURN(rc); + return rc; } int osc_quotacheck(struct obd_device *unused, struct obd_export *exp, @@ -292,7 +292,7 @@ int osc_quotacheck(struct obd_device *unused, struct obd_export *exp, &RQF_OST_QUOTACHECK, LUSTRE_OST_VERSION, OST_QUOTACHECK); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; body = req_capsule_client_get(&req->rq_pill, &RMF_OBD_QUOTACTL); *body = *oqctl; @@ -306,7 +306,7 @@ int osc_quotacheck(struct obd_device *unused, struct obd_export *exp, if (rc) cli->cl_qchk_stat = rc; ptlrpc_req_finished(req); - RETURN(rc); + return rc; } int osc_quota_poll_check(struct obd_export *exp, struct if_quotacheck *qchk) @@ -321,5 +321,5 @@ int osc_quota_poll_check(struct obd_export *exp, struct if_quotacheck *qchk) /* the client is not the previous one */ if (rc == CL_NOT_QUOTACHECKED) rc = -EINTR; - RETURN(rc); + return rc; } diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 1f73a698baef6..611678c407a6a 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -72,26 +72,26 @@ static int osc_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, lmm_size = sizeof(**lmmp); if (lmmp == NULL) - RETURN(lmm_size); + return lmm_size; if (*lmmp != NULL && lsm == NULL) { OBD_FREE(*lmmp, lmm_size); *lmmp = NULL; - RETURN(0); + return 0; } else if (unlikely(lsm != NULL && ostid_id(&lsm->lsm_oi) == 0)) { - RETURN(-EBADF); + return -EBADF; } if (*lmmp == NULL) { OBD_ALLOC(*lmmp, lmm_size); if (*lmmp == NULL) - RETURN(-ENOMEM); + return -ENOMEM; } if (lsm) ostid_cpu_to_le(&lsm->lsm_oi, &(*lmmp)->lmm_oi); - RETURN(lmm_size); + return lmm_size; } /* Unpack OSC object metadata from disk storage (LE byte order). */ @@ -106,40 +106,40 @@ static int osc_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, CERROR("%s: lov_mds_md too small: %d, need %d\n", exp->exp_obd->obd_name, lmm_bytes, (int)sizeof(*lmm)); - RETURN(-EINVAL); + return -EINVAL; } /* XXX LOV_MAGIC etc check? */ if (unlikely(ostid_id(&lmm->lmm_oi) == 0)) { CERROR("%s: zero lmm_object_id: rc = %d\n", exp->exp_obd->obd_name, -EINVAL); - RETURN(-EINVAL); + return -EINVAL; } } lsm_size = lov_stripe_md_size(1); if (lsmp == NULL) - RETURN(lsm_size); + return lsm_size; if (*lsmp != NULL && lmm == NULL) { OBD_FREE((*lsmp)->lsm_oinfo[0], sizeof(struct lov_oinfo)); OBD_FREE(*lsmp, lsm_size); *lsmp = NULL; - RETURN(0); + return 0; } if (*lsmp == NULL) { OBD_ALLOC(*lsmp, lsm_size); if (unlikely(*lsmp == NULL)) - RETURN(-ENOMEM); + return -ENOMEM; OBD_ALLOC((*lsmp)->lsm_oinfo[0], sizeof(struct lov_oinfo)); if (unlikely((*lsmp)->lsm_oinfo[0] == NULL)) { OBD_FREE(*lsmp, lsm_size); - RETURN(-ENOMEM); + return -ENOMEM; } loi_init((*lsmp)->lsm_oinfo[0]); } else if (unlikely(ostid_id(&(*lsmp)->lsm_oi) == 0)) { - RETURN(-EBADF); + return -EBADF; } if (lmm != NULL) @@ -152,7 +152,7 @@ static int osc_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, else (*lsmp)->lsm_maxbytes = LUSTRE_STRIPE_MAXBYTES; - RETURN(lsm_size); + return lsm_size; } static inline void osc_pack_capa(struct ptlrpc_request *req, @@ -220,7 +220,7 @@ static int osc_getattr_interpret(const struct lu_env *env, } out: rc = aa->aa_oi->oi_cb_up(aa->aa_oi, rc); - RETURN(rc); + return rc; } static int osc_getattr_async(struct obd_export *exp, struct obd_info *oinfo, @@ -232,13 +232,13 @@ static int osc_getattr_async(struct obd_export *exp, struct obd_info *oinfo, req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_GETATTR); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; osc_set_capa_size(req, &RMF_CAPA1, oinfo->oi_capa); rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_GETATTR); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } osc_pack_req_body(req, oinfo); @@ -251,7 +251,7 @@ static int osc_getattr_async(struct obd_export *exp, struct obd_info *oinfo, aa->aa_oi = oinfo; ptlrpc_set_add_req(set, req); - RETURN(0); + return 0; } static int osc_getattr(const struct lu_env *env, struct obd_export *exp, @@ -263,13 +263,13 @@ static int osc_getattr(const struct lu_env *env, struct obd_export *exp, req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_GETATTR); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; osc_set_capa_size(req, &RMF_CAPA1, oinfo->oi_capa); rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_GETATTR); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } osc_pack_req_body(req, oinfo); @@ -307,13 +307,13 @@ static int osc_setattr(const struct lu_env *env, struct obd_export *exp, req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_SETATTR); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; osc_set_capa_size(req, &RMF_CAPA1, oinfo->oi_capa); rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_SETATTR); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } osc_pack_req_body(req, oinfo); @@ -333,7 +333,7 @@ static int osc_setattr(const struct lu_env *env, struct obd_export *exp, out: ptlrpc_req_finished(req); - RETURN(rc); + return rc; } static int osc_setattr_interpret(const struct lu_env *env, @@ -353,7 +353,7 @@ static int osc_setattr_interpret(const struct lu_env *env, &body->oa); out: rc = sa->sa_upcall(sa->sa_cookie, rc); - RETURN(rc); + return rc; } int osc_setattr_async_base(struct obd_export *exp, struct obd_info *oinfo, @@ -367,13 +367,13 @@ int osc_setattr_async_base(struct obd_export *exp, struct obd_info *oinfo, req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_SETATTR); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; osc_set_capa_size(req, &RMF_CAPA1, oinfo->oi_capa); rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_SETATTR); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } if (oti && oinfo->oi_oa->o_valid & OBD_MD_FLCOOKIE) @@ -403,7 +403,7 @@ int osc_setattr_async_base(struct obd_export *exp, struct obd_info *oinfo, ptlrpc_set_add_req(rqset, req); } - RETURN(0); + return 0; } static int osc_setattr_async(struct obd_export *exp, struct obd_info *oinfo, @@ -429,7 +429,7 @@ int osc_real_create(struct obd_export *exp, struct obdo *oa, if (!lsm) { rc = obd_alloc_memmd(exp, &lsm); if (rc < 0) - RETURN(rc); + return rc; } req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_CREATE); @@ -495,7 +495,7 @@ int osc_real_create(struct obd_export *exp, struct obdo *oa, out: if (rc && !*ea) obd_free_memmd(exp, &lsm); - RETURN(rc); + return rc; } int osc_punch_base(struct obd_export *exp, struct obd_info *oinfo, @@ -509,13 +509,13 @@ int osc_punch_base(struct obd_export *exp, struct obd_info *oinfo, req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_PUNCH); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; osc_set_capa_size(req, &RMF_CAPA1, oinfo->oi_capa); rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_PUNCH); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } req->rq_request_portal = OST_IO_PORTAL; /* bug 7198 */ ptlrpc_at_set_req_timeout(req); @@ -539,7 +539,7 @@ int osc_punch_base(struct obd_export *exp, struct obd_info *oinfo, else ptlrpc_set_add_req(rqset, req); - RETURN(0); + return 0; } static int osc_punch(const struct lu_env *env, struct obd_export *exp, @@ -572,7 +572,7 @@ static int osc_sync_interpret(const struct lu_env *env, *fa->fa_oi->oi_oa = body->oa; out: rc = fa->fa_upcall(fa->fa_cookie, rc); - RETURN(rc); + return rc; } int osc_sync_base(struct obd_export *exp, struct obd_info *oinfo, @@ -586,13 +586,13 @@ int osc_sync_base(struct obd_export *exp, struct obd_info *oinfo, req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_SYNC); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; osc_set_capa_size(req, &RMF_CAPA1, oinfo->oi_capa); rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_SYNC); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } /* overload the size and blocks fields in the oa with start/end */ @@ -616,7 +616,7 @@ int osc_sync_base(struct obd_export *exp, struct obd_info *oinfo, else ptlrpc_set_add_req(rqset, req); - RETURN (0); + return 0; } static int osc_sync(const struct lu_env *env, struct obd_export *exp, @@ -625,14 +625,14 @@ static int osc_sync(const struct lu_env *env, struct obd_export *exp, { if (!oinfo->oi_oa) { CDEBUG(D_INFO, "oa NULL\n"); - RETURN(-EINVAL); + return -EINVAL; } oinfo->oi_oa->o_size = start; oinfo->oi_oa->o_blocks = end; oinfo->oi_oa->o_valid |= (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS); - RETURN(osc_sync_base(exp, oinfo, oinfo->oi_cb_up, oinfo, set)); + return osc_sync_base(exp, oinfo, oinfo->oi_cb_up, oinfo, set); } /* Find and cancel locally locks matched by @mode in the resource found by @@ -654,19 +654,19 @@ static int osc_resource_get_unused(struct obd_export *exp, struct obdo *oa, * when we still want to cancel locks in advance and just cancel them * locally, without sending any RPC. */ if (exp_connect_cancelset(exp) && !ns_connect_cancelset(ns)) - RETURN(0); + return 0; ostid_build_res_name(&oa->o_oi, &res_id); res = ldlm_resource_get(ns, NULL, &res_id, 0, 0); if (res == NULL) - RETURN(0); + return 0; LDLM_RESOURCE_ADDREF(res); count = ldlm_cancel_resource_local(res, cancels, NULL, mode, lock_flags, 0, NULL); LDLM_RESOURCE_DELREF(res); ldlm_resource_putref(res); - RETURN(count); + return count; } static int osc_destroy_interpret(const struct lu_env *env, @@ -710,16 +710,16 @@ int osc_create(const struct lu_env *env, struct obd_export *exp, if ((oa->o_valid & OBD_MD_FLFLAGS) && oa->o_flags == OBD_FL_RECREATE_OBJS) { - RETURN(osc_real_create(exp, oa, ea, oti)); + return osc_real_create(exp, oa, ea, oti); } if (!fid_seq_is_mdt(ostid_seq(&oa->o_oi))) - RETURN(osc_real_create(exp, oa, ea, oti)); + return osc_real_create(exp, oa, ea, oti); /* we should not get here anymore */ LBUG(); - RETURN(rc); + return rc; } /* Destroy requests can be async always on the client, and we don't even really @@ -745,7 +745,7 @@ static int osc_destroy(const struct lu_env *env, struct obd_export *exp, if (!oa) { CDEBUG(D_INFO, "oa NULL\n"); - RETURN(-EINVAL); + return -EINVAL; } count = osc_resource_get_unused(exp, oa, &cancels, LCK_PW, @@ -754,7 +754,7 @@ static int osc_destroy(const struct lu_env *env, struct obd_export *exp, req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_DESTROY); if (req == NULL) { ldlm_lock_list_put(&cancels, l_bl_ast, count); - RETURN(-ENOMEM); + return -ENOMEM; } osc_set_capa_size(req, &RMF_CAPA1, (struct obd_capa *)capa); @@ -762,7 +762,7 @@ static int osc_destroy(const struct lu_env *env, struct obd_export *exp, 0, &cancels, count); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } req->rq_request_portal = OST_IO_PORTAL; /* bug 7198 */ @@ -798,7 +798,7 @@ static int osc_destroy(const struct lu_env *env, struct obd_export *exp, /* Do not wait for response */ ptlrpcd_add_req(req, PDL_POLICY_ROUND, -1); - RETURN(0); + return 0; } static void osc_announce_cached(struct client_obd *cli, struct obdo *oa, @@ -939,13 +939,13 @@ int osc_shrink_grant_to_target(struct client_obd *cli, __u64 target_bytes) if (target_bytes >= cli->cl_avail_grant) { client_obd_list_unlock(&cli->cl_loi_list_lock); - RETURN(0); + return 0; } client_obd_list_unlock(&cli->cl_loi_list_lock); OBD_ALLOC_PTR(body); if (!body) - RETURN(-ENOMEM); + return -ENOMEM; osc_announce_cached(cli, &body->oa, 0); @@ -966,7 +966,7 @@ int osc_shrink_grant_to_target(struct client_obd *cli, __u64 target_bytes) if (rc != 0) __osc_update_grant(cli, body->oa.o_grant); OBD_FREE_PTR(body); - RETURN(rc); + return rc; } static int osc_should_shrink_grant(struct client_obd *client) @@ -1237,9 +1237,9 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,struct obdo *oa, struct brw_page *pg_prev; if (OBD_FAIL_CHECK(OBD_FAIL_OSC_BRW_PREP_REQ)) - RETURN(-ENOMEM); /* Recoverable */ + return -ENOMEM; /* Recoverable */ if (OBD_FAIL_CHECK(OBD_FAIL_OSC_BRW_PREP_REQ2)) - RETURN(-EINVAL); /* Fatal */ + return -EINVAL; /* Fatal */ if ((cmd & OBD_BRW_WRITE) != 0) { opc = OST_WRITE; @@ -1251,7 +1251,7 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,struct obdo *oa, req = ptlrpc_request_alloc(cli->cl_import, &RQF_OST_BRW_READ); } if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; for (niocount = i = 1; i < page_count; i++) { if (!can_merge_pages(pga[i - 1], pga[i])) @@ -1268,7 +1268,7 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,struct obdo *oa, rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, opc); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } req->rq_request_portal = OST_IO_PORTAL; /* bug 7198 */ ptlrpc_at_set_req_timeout(req); @@ -1414,11 +1414,11 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,struct obdo *oa, aa->aa_ocapa = capa_get(ocapa); *reqp = req; - RETURN(0); + return 0; out: ptlrpc_req_finished(req); - RETURN(rc); + return rc; } static int check_write_checksum(struct obdo *oa, const lnet_process_id_t *peer, @@ -1478,14 +1478,14 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, int rc) if (rc < 0 && rc != -EDQUOT) { DEBUG_REQ(D_INFO, req, "Failed request with rc = %d\n", rc); - RETURN(rc); + return rc; } LASSERTF(req->rq_repmsg != NULL, "rc = %d\n", rc); body = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY); if (body == NULL) { DEBUG_REQ(D_INFO, req, "Can't unpack body\n"); - RETURN(-EPROTO); + return -EPROTO; } /* set/clear over quota flag for a uid/gid */ @@ -1502,7 +1502,7 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, int rc) osc_update_grant(cli, body); if (rc < 0) - RETURN(rc); + return rc; if (aa->aa_oa->o_valid & OBD_MD_FLCKSUM) client_cksum = aa->aa_oa->o_cksum; /* save for later */ @@ -1510,19 +1510,19 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, int rc) if (lustre_msg_get_opc(req->rq_reqmsg) == OST_WRITE) { if (rc > 0) { CERROR("Unexpected +ve rc %d\n", rc); - RETURN(-EPROTO); + return -EPROTO; } LASSERT(req->rq_bulk->bd_nob == aa->aa_requested_nob); if (sptlrpc_cli_unwrap_bulk_write(req, req->rq_bulk)) - RETURN(-EAGAIN); + return -EAGAIN; if ((aa->aa_oa->o_valid & OBD_MD_FLCKSUM) && client_cksum && check_write_checksum(&body->oa, peer, client_cksum, body->oa.o_cksum, aa->aa_requested_nob, aa->aa_page_count, aa->aa_ppga, cksum_type_unpack(aa->aa_oa->o_flags))) - RETURN(-EAGAIN); + return -EAGAIN; rc = check_write_rcs(req, aa->aa_requested_nob,aa->aa_nio_count, aa->aa_page_count, aa->aa_ppga); @@ -1539,7 +1539,7 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, int rc) if (rc > aa->aa_requested_nob) { CERROR("Unexpected rc %d (%d requested)\n", rc, aa->aa_requested_nob); - RETURN(-EPROTO); + return -EPROTO; } if (rc != req->rq_bulk->bd_nob_transferred) { @@ -1619,7 +1619,7 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, int rc) lustre_get_wire_obdo(&req->rq_import->imp_connect_data, aa->aa_oa, &body->oa); - RETURN(rc); + return rc; } static int osc_brw_internal(int cmd, struct obd_export *exp, struct obdo *oa, @@ -1687,7 +1687,7 @@ static int osc_brw_internal(int cmd, struct obd_export *exp, struct obdo *oa, out: if (rc == -EAGAIN || rc == -EINPROGRESS) rc = -EIO; - RETURN (rc); + return rc; } static int osc_brw_redo_request(struct ptlrpc_request *request, @@ -1707,7 +1707,7 @@ static int osc_brw_redo_request(struct ptlrpc_request *request, aa->aa_page_count, aa->aa_ppga, &new_req, aa->aa_ocapa, 0, 1); if (rc) - RETURN(rc); + return rc; list_for_each_entry(oap, &aa->aa_oaps, oap_rpc_item) { if (oap->oap_request != NULL) { @@ -1716,7 +1716,7 @@ static int osc_brw_redo_request(struct ptlrpc_request *request, request, oap->oap_request); if (oap->oap_interrupted) { ptlrpc_req_finished(new_req); - RETURN(-EINTR); + return -EINTR; } } } @@ -1759,7 +1759,7 @@ static int osc_brw_redo_request(struct ptlrpc_request *request, ptlrpcd_add_req(new_req, PDL_POLICY_SAME, -1); DEBUG_REQ(D_INFO, new_req, "new request"); - RETURN(0); + return 0; } /* @@ -1857,8 +1857,8 @@ static int osc_brw(int cmd, struct obd_export *exp, struct obd_info *oinfo, * I/O can succeed */ if (imp->imp_invalid) - RETURN(-EIO); - RETURN(0); + return -EIO; + return 0; } /* test_brw with a failed create can trip this, maybe others. */ @@ -1868,7 +1868,7 @@ static int osc_brw(int cmd, struct obd_export *exp, struct obd_info *oinfo, orig = ppga = osc_build_ppga(pga, page_count); if (ppga == NULL) - RETURN(-ENOMEM); + return -ENOMEM; page_count_orig = page_count; sort_brw_pages(ppga, page_count); @@ -1909,7 +1909,7 @@ static int osc_brw(int cmd, struct obd_export *exp, struct obd_info *oinfo, if (saved_oa != NULL) OBDO_FREE(saved_oa); - RETURN(rc); + return rc; } static int brw_interpret(const struct lu_env *env, @@ -1943,7 +1943,7 @@ static int brw_interpret(const struct lu_env *env, } if (rc == 0) - RETURN(0); + return 0; else if (rc == -EAGAIN || rc == -EINPROGRESS) rc = -EIO; } @@ -2013,7 +2013,7 @@ static int brw_interpret(const struct lu_env *env, client_obd_list_unlock(&cli->cl_loi_list_lock); osc_io_unplug(env, cli, NULL, PDL_POLICY_SAME); - RETURN(rc); + return rc; } /** @@ -2228,7 +2228,7 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, if (clerq && !IS_ERR(clerq)) cl_req_completion(env, clerq, rc); } - RETURN(rc); + return rc; } static int osc_set_lock_data_with_check(struct ldlm_lock *lock, @@ -2333,7 +2333,7 @@ static int osc_enqueue_fini(struct ptlrpc_request *req, struct ost_lvb *lvb, /* Call the update callback. */ rc = (*upcall)(cookie, rc); - RETURN(rc); + return rc; } static int osc_enqueue_interpret(const struct lu_env *env, @@ -2507,7 +2507,7 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id, * Return -ECANCELED to tell the caller. */ ldlm_lock_decref(lockh, mode); LDLM_LOCK_PUT(matched); - RETURN(-ECANCELED); + return -ECANCELED; } else if (osc_set_lock_data_with_check(matched, einfo)) { *flags |= LDLM_FL_LVB_READY; /* addref the lock only if not async requests and PW @@ -2532,7 +2532,7 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id, /* For async requests, decref the lock. */ ldlm_lock_decref(lockh, einfo->ei_mode); LDLM_LOCK_PUT(matched); - RETURN(ELDLM_OK); + return ELDLM_OK; } else { ldlm_lock_decref(lockh, mode); LDLM_LOCK_PUT(matched); @@ -2545,12 +2545,12 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id, req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_LDLM_ENQUEUE_LVB); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; rc = ldlm_prep_enqueue_req(exp, req, &cancels, 0); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } req_capsule_set_size(&req->rq_pill, &RMF_DLM_LVB, RCL_SERVER, @@ -2586,14 +2586,14 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id, } else if (intent) { ptlrpc_req_finished(req); } - RETURN(rc); + return rc; } rc = osc_enqueue_fini(req, lvb, upcall, cookie, flags, agl, rc); if (intent) ptlrpc_req_finished(req); - RETURN(rc); + return rc; } static int osc_enqueue(struct obd_export *exp, struct obd_info *oinfo, @@ -2609,7 +2609,7 @@ static int osc_enqueue(struct obd_export *exp, struct obd_info *oinfo, oinfo->oi_md->lsm_oinfo[0]->loi_kms_valid, oinfo->oi_cb_up, oinfo, einfo, oinfo->oi_lockh, rqset, rqset != NULL, 0); - RETURN(rc); + return rc; } int osc_match_base(struct obd_export *exp, struct ldlm_res_id *res_id, @@ -2622,7 +2622,7 @@ int osc_match_base(struct obd_export *exp, struct ldlm_res_id *res_id, ldlm_mode_t rc; if (OBD_FAIL_CHECK(OBD_FAIL_OSC_MATCH)) - RETURN(-EIO); + return -EIO; /* Filesystem lock extents are extended to page boundaries so that * dealing with the page cache is a little smoother */ @@ -2643,16 +2643,16 @@ int osc_match_base(struct obd_export *exp, struct ldlm_res_id *res_id, if (!osc_set_data_with_check(lockh, data)) { if (!(lflags & LDLM_FL_TEST_LOCK)) ldlm_lock_decref(lockh, rc); - RETURN(0); + return 0; } } if (!(lflags & LDLM_FL_TEST_LOCK) && mode != rc) { ldlm_lock_addref(lockh, LCK_PR); ldlm_lock_decref(lockh, LCK_PW); } - RETURN(rc); + return rc; } - RETURN(rc); + return rc; } int osc_cancel_base(struct lustre_handle *lockh, __u32 mode) @@ -2662,13 +2662,13 @@ int osc_cancel_base(struct lustre_handle *lockh, __u32 mode) else ldlm_lock_decref(lockh, mode); - RETURN(0); + return 0; } static int osc_cancel(struct obd_export *exp, struct lov_stripe_md *md, __u32 mode, struct lustre_handle *lockh) { - RETURN(osc_cancel_base(lockh, mode)); + return osc_cancel_base(lockh, mode); } static int osc_cancel_unused(struct obd_export *exp, @@ -2699,7 +2699,7 @@ static int osc_statfs_interpret(const struct lu_env *env, * Exit immediately since the caller is * aware of the problem and takes care * of the clean up */ - RETURN(rc); + return rc; if ((rc == -ENOTCONN || rc == -EAGAIN) && (aa->aa_oi->oi_flags & OBD_STATFS_NODELAY)) @@ -2716,7 +2716,7 @@ static int osc_statfs_interpret(const struct lu_env *env, *aa->aa_oi->oi_osfs = *msfs; out: rc = aa->aa_oi->oi_cb_up(aa->aa_oi, rc); - RETURN(rc); + return rc; } static int osc_statfs_async(struct obd_export *exp, @@ -2736,12 +2736,12 @@ static int osc_statfs_async(struct obd_export *exp, * timestamps are not ideal because they need time synchronization. */ req = ptlrpc_request_alloc(obd->u.cli.cl_import, &RQF_OST_STATFS); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_STATFS); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } ptlrpc_request_set_replen(req); req->rq_request_portal = OST_CREATE_PORTAL; @@ -2759,7 +2759,7 @@ static int osc_statfs_async(struct obd_export *exp, aa->aa_oi = oinfo; ptlrpc_set_add_req(rqset, req); - RETURN(0); + return 0; } static int osc_statfs(const struct lu_env *env, struct obd_export *exp, @@ -2778,7 +2778,7 @@ static int osc_statfs(const struct lu_env *env, struct obd_export *exp, imp = class_import_get(obd->u.cli.cl_import); up_read(&obd->u.cli.cl_sem); if (!imp) - RETURN(-ENODEV); + return -ENODEV; /* We could possibly pass max_age in the request (as an absolute * timestamp or a "seconds.usec ago") so the target can avoid doing @@ -2791,12 +2791,12 @@ static int osc_statfs(const struct lu_env *env, struct obd_export *exp, class_import_put(imp); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_STATFS); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } ptlrpc_request_set_replen(req); req->rq_request_portal = OST_CREATE_PORTAL; @@ -2838,17 +2838,17 @@ static int osc_getstripe(struct lov_stripe_md *lsm, struct lov_user_md *lump) int rc = 0, lum_size; if (!lsm) - RETURN(-ENODATA); + return -ENODATA; /* we only need the header part from user space to get lmm_magic and * lmm_stripe_count, (the header part is common to v1 and v3) */ lum_size = sizeof(struct lov_user_md_v1); if (copy_from_user(&lum, lump, lum_size)) - RETURN(-EFAULT); + return -EFAULT; if ((lum.lmm_magic != LOV_USER_MAGIC_V1) && (lum.lmm_magic != LOV_USER_MAGIC_V3)) - RETURN(-EINVAL); + return -EINVAL; /* lov_user_md_vX and lov_mds_md_vX must have the same size */ LASSERT(sizeof(struct lov_user_md_v1) == sizeof(struct lov_mds_md_v1)); @@ -2861,7 +2861,7 @@ static int osc_getstripe(struct lov_stripe_md *lsm, struct lov_user_md *lump) lum_size = lov_mds_md_size(lum.lmm_stripe_count, lum.lmm_magic); OBD_ALLOC(lumk, lum_size); if (!lumk) - RETURN(-ENOMEM); + return -ENOMEM; if (lum.lmm_magic == LOV_USER_MAGIC_V1) lmm_objects = @@ -2883,7 +2883,7 @@ static int osc_getstripe(struct lov_stripe_md *lsm, struct lov_user_md *lump) if (lumk != &lum) OBD_FREE(lumk, lum_size); - RETURN(rc); + return rc; } @@ -2977,13 +2977,13 @@ static int osc_get_info(const struct lu_env *env, struct obd_export *exp, struct lov_stripe_md *lsm) { if (!vallen || !val) - RETURN(-EFAULT); + return -EFAULT; if (KEY_IS(KEY_LOCK_TO_STRIPE)) { __u32 *stripe = val; *vallen = sizeof(*stripe); *stripe = 0; - RETURN(0); + return 0; } else if (KEY_IS(KEY_LAST_ID)) { struct ptlrpc_request *req; obd_id *reply; @@ -2993,14 +2993,14 @@ static int osc_get_info(const struct lu_env *env, struct obd_export *exp, req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_GET_INFO_LAST_ID); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; req_capsule_set_size(&req->rq_pill, &RMF_SETINFO_KEY, RCL_CLIENT, keylen); rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_GET_INFO); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } tmp = req_capsule_client_get(&req->rq_pill, &RMF_SETINFO_KEY); @@ -3019,7 +3019,7 @@ static int osc_get_info(const struct lu_env *env, struct obd_export *exp, *((obd_id *)val) = *reply; out: ptlrpc_req_finished(req); - RETURN(rc); + return rc; } else if (KEY_IS(KEY_FIEMAP)) { struct ll_fiemap_info_key *fm_key = (struct ll_fiemap_info_key *)key; @@ -3101,10 +3101,10 @@ static int osc_get_info(const struct lu_env *env, struct obd_export *exp, drop_lock: if (mode) ldlm_lock_decref(&lockh, LCK_PR); - RETURN(rc); + return rc; } - RETURN(-EINVAL); + return -EINVAL; } static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp, @@ -3121,19 +3121,19 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp, if (KEY_IS(KEY_CHECKSUM)) { if (vallen != sizeof(int)) - RETURN(-EINVAL); + return -EINVAL; exp->exp_obd->u.cli.cl_checksum = (*(int *)val) ? 1 : 0; - RETURN(0); + return 0; } if (KEY_IS(KEY_SPTLRPC_CONF)) { sptlrpc_conf_client_adapt(obd); - RETURN(0); + return 0; } if (KEY_IS(KEY_FLUSH_CTX)) { sptlrpc_import_flush_my_ctx(imp); - RETURN(0); + return 0; } if (KEY_IS(KEY_CACHE_SET)) { @@ -3150,7 +3150,7 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp, list_add(&cli->cl_lru_osc, &cli->cl_cache->ccc_lru); spin_unlock(&cli->cl_cache->ccc_lru_lock); - RETURN(0); + return 0; } if (KEY_IS(KEY_CACHE_LRU_SHRINK)) { @@ -3160,11 +3160,11 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp, nr = osc_lru_shrink(cli, min(nr, target)); *(int *)val -= nr; - RETURN(0); + return 0; } if (!set && !KEY_IS(KEY_GRANT_SHRINK)) - RETURN(-EINVAL); + return -EINVAL; /* We pass all other commands directly to OST. Since nobody calls osc methods directly and everybody is supposed to go through LOV, we @@ -3177,7 +3177,7 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp, &RQF_OST_SET_GRANT_INFO : &RQF_OBD_SET_INFO); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; req_capsule_set_size(&req->rq_pill, &RMF_SETINFO_KEY, RCL_CLIENT, keylen); @@ -3187,7 +3187,7 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp, rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_SET_INFO); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } tmp = req_capsule_client_get(&req->rq_pill, &RMF_SETINFO_KEY); @@ -3206,7 +3206,7 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp, OBDO_ALLOC(oa); if (!oa) { ptlrpc_req_finished(req); - RETURN(-ENOMEM); + return -ENOMEM; } *oa = ((struct ost_body *)val)->oa; aa->aa_oa = oa; @@ -3221,7 +3221,7 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp, } else ptlrpcd_add_req(req, PDL_POLICY_ROUND, -1); - RETURN(0); + return 0; } @@ -3247,7 +3247,7 @@ static int osc_llog_finish(struct obd_device *obd, int count) ctxt = llog_get_context(obd, LLOG_SIZE_REPL_CTXT); if (ctxt) llog_cleanup(NULL, ctxt); - RETURN(0); + return 0; } static int osc_reconnect(const struct lu_env *env, @@ -3273,7 +3273,7 @@ static int osc_reconnect(const struct lu_env *env, data->ocd_version, data->ocd_grant, lost_grant); } - RETURN(0); + return 0; } static int osc_disconnect(struct obd_export *exp) @@ -3388,7 +3388,7 @@ static int osc_import_event(struct obd_device *obd, CERROR("Unknown import event %d\n", event); LBUG(); } - RETURN(rc); + return rc; } /** @@ -3412,9 +3412,9 @@ static int osc_cancel_for_recovery(struct ldlm_lock *lock) (lock->l_granted_mode == LCK_PR || lock->l_granted_mode == LCK_CR) && (osc_dlm_lock_pageref(lock) == 0)) - RETURN(1); + return 1; - RETURN(0); + return 0; } static int brw_queue_work(const struct lu_env *env, void *data) @@ -3424,7 +3424,7 @@ static int brw_queue_work(const struct lu_env *env, void *data) CDEBUG(D_CACHE, "Run writeback work for client obd %p.\n", cli); osc_io_unplug(env, cli, NULL, PDL_POLICY_SAME); - RETURN(0); + return 0; } int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) @@ -3436,7 +3436,7 @@ int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) rc = ptlrpcd_addref(); if (rc) - RETURN(rc); + return rc; rc = client_obd_setup(obd, lcfg); if (rc) @@ -3471,7 +3471,7 @@ int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) INIT_LIST_HEAD(&cli->cl_grant_shrink_list); ns_register_cancel(obd->obd_namespace, osc_cancel_for_recovery); - RETURN(rc); + return rc; out_ptlrpcd_work: ptlrpcd_destroy_work(handler); @@ -3479,7 +3479,7 @@ int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) client_obd_cleanup(obd); out_ptlrpcd: ptlrpcd_decref(); - RETURN(rc); + return rc; } static int osc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) @@ -3523,7 +3523,7 @@ static int osc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) break; } } - RETURN(rc); + return rc; } int osc_cleanup(struct obd_device *obd) @@ -3548,7 +3548,7 @@ int osc_cleanup(struct obd_device *obd) rc = client_obd_cleanup(obd); ptlrpcd_decref(); - RETURN(rc); + return rc; } int osc_process_config_base(struct obd_device *obd, struct lustre_cfg *lcfg) @@ -3630,7 +3630,7 @@ int __init osc_init(void) rc = lu_kmem_init(osc_caches); if (rc) - RETURN(rc); + return rc; lprocfs_osc_init_vars(&lvars); @@ -3638,13 +3638,13 @@ int __init osc_init(void) LUSTRE_OSC_NAME, &osc_device_type); if (rc) { lu_kmem_fini(osc_caches); - RETURN(rc); + return rc; } spin_lock_init(&osc_ast_guard); lockdep_set_class(&osc_ast_guard, &osc_ast_guard_class); - RETURN(rc); + return rc; } static void /*__exit*/ osc_exit(void) diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c index 9bcfc4f65356d..810a458caed73 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c @@ -140,7 +140,7 @@ struct ptlrpc_bulk_desc *ptlrpc_prep_bulk_imp(struct ptlrpc_request *req, LASSERT(type == BULK_PUT_SINK || type == BULK_GET_SOURCE); desc = ptlrpc_new_bulk(npages, max_brw, type, portal); if (desc == NULL) - RETURN(NULL); + return NULL; desc->bd_import_generation = req->rq_import_generation; desc->bd_import = class_import_get(imp); @@ -340,7 +340,7 @@ static int ptlrpc_at_recv_early_reply(struct ptlrpc_request *req) rc = sptlrpc_cli_unwrap_early_reply(req, &early_req); if (rc) { spin_lock(&req->rq_lock); - RETURN(rc); + return rc; } rc = unpack_reply(early_req); @@ -356,7 +356,7 @@ static int ptlrpc_at_recv_early_reply(struct ptlrpc_request *req) if (rc != 0) { spin_lock(&req->rq_lock); - RETURN(rc); + return rc; } /* Adjust the local timeout for this req */ @@ -375,7 +375,7 @@ static int ptlrpc_at_recv_early_reply(struct ptlrpc_request *req) cfs_time_sub(req->rq_deadline, cfs_time_current_sec()), cfs_time_sub(req->rq_deadline, olddl)); - RETURN(rc); + return rc; } /** @@ -596,7 +596,7 @@ static int __ptlrpc_request_bufs_pack(struct ptlrpc_request *request, lustre_msg_set_opc(request->rq_reqmsg, opcode); - RETURN(0); + return 0; out_ctx: sptlrpc_cli_ctx_put(request->rq_cli_ctx, 1); out_free: @@ -819,7 +819,7 @@ struct ptlrpc_request_set *ptlrpc_prep_set(void) OBD_ALLOC(set, sizeof *set); if (!set) - RETURN(NULL); + return NULL; atomic_set(&set->set_refcount, 1); INIT_LIST_HEAD(&set->set_requests); init_waitqueue_head(&set->set_waitq); @@ -833,7 +833,7 @@ struct ptlrpc_request_set *ptlrpc_prep_set(void) set->set_producer_arg = NULL; set->set_rc = 0; - RETURN(set); + return set; } EXPORT_SYMBOL(ptlrpc_prep_set); @@ -853,13 +853,13 @@ struct ptlrpc_request_set *ptlrpc_prep_fcset(int max, set_producer_func func, set = ptlrpc_prep_set(); if (!set) - RETURN(NULL); + return NULL; set->set_max_inflight = max; set->set_producer = func; set->set_producer_arg = arg; - RETURN(set); + return set; } EXPORT_SYMBOL(ptlrpc_prep_fcset); @@ -933,13 +933,13 @@ int ptlrpc_set_add_cb(struct ptlrpc_request_set *set, OBD_ALLOC_PTR(cbdata); if (cbdata == NULL) - RETURN(-ENOMEM); + return -ENOMEM; cbdata->psc_interpret = fn; cbdata->psc_data = data; list_add_tail(&cbdata->psc_item, &set->set_cblist); - RETURN(0); + return 0; } EXPORT_SYMBOL(ptlrpc_set_add_cb); @@ -1069,7 +1069,7 @@ static int ptlrpc_import_delay_req(struct obd_import *imp, } } - RETURN(delay); + return delay; } /** @@ -1123,7 +1123,7 @@ static int ptlrpc_check_status(struct ptlrpc_request *req) libcfs_nid2str( imp->imp_connection->c_peer.nid), ll_opcode2str(opc), err); - RETURN(err < 0 ? err : -EINVAL); + return err < 0 ? err : -EINVAL; } if (err < 0) { @@ -1133,7 +1133,7 @@ static int ptlrpc_check_status(struct ptlrpc_request *req) DEBUG_REQ(D_INFO, req, "status is %d", err); } - RETURN(err); + return err; } /** @@ -1180,7 +1180,7 @@ static int after_reply(struct ptlrpc_request *req) DEBUG_REQ(D_ERROR, req, "reply buffer overflow," " expected: %d, actual size: %d", req->rq_nob_received, req->rq_repbuf_len); - RETURN(-EOVERFLOW); + return -EOVERFLOW; } sptlrpc_cli_free_repbuf(req); @@ -1191,7 +1191,7 @@ static int after_reply(struct ptlrpc_request *req) req->rq_replen = req->rq_nob_received; req->rq_nob_received = 0; req->rq_resend = 1; - RETURN(0); + return 0; } /* @@ -1201,18 +1201,18 @@ static int after_reply(struct ptlrpc_request *req) rc = sptlrpc_cli_unwrap_reply(req); if (rc) { DEBUG_REQ(D_ERROR, req, "unwrap reply failed (%d):", rc); - RETURN(rc); + return rc; } /* * Security layer unwrap might ask resend this request. */ if (req->rq_resend) - RETURN(0); + return 0; rc = unpack_reply(req); if (rc) - RETURN(rc); + return rc; /* retry indefinitely on EINPROGRESS */ if (lustre_msg_get_status(req->rq_repmsg) == -EINPROGRESS && @@ -1243,7 +1243,7 @@ static int after_reply(struct ptlrpc_request *req) else req->rq_sent = now + req->rq_nr_resend; - RETURN(0); + return 0; } do_gettimeofday(&work_start); @@ -1258,7 +1258,7 @@ static int after_reply(struct ptlrpc_request *req) lustre_msg_get_type(req->rq_repmsg) != PTL_RPC_MSG_ERR) { DEBUG_REQ(D_ERROR, req, "invalid packet received (type=%u)", lustre_msg_get_type(req->rq_repmsg)); - RETURN(-EPROTO); + return -EPROTO; } if (lustre_msg_get_opc(req->rq_reqmsg) != OBD_PING) @@ -1279,10 +1279,10 @@ static int after_reply(struct ptlrpc_request *req) if (ll_rpc_recoverable_error(rc)) { if (req->rq_send_state != LUSTRE_IMP_FULL || imp->imp_obd->obd_no_recov || imp->imp_dlm_fake) { - RETURN(rc); + return rc; } ptlrpc_request_handle_notconn(req); - RETURN(rc); + return rc; } } else { /* @@ -1346,7 +1346,7 @@ static int after_reply(struct ptlrpc_request *req) spin_unlock(&imp->imp_lock); } - RETURN(rc); + return rc; } /** @@ -1363,7 +1363,7 @@ static int ptlrpc_send_new_req(struct ptlrpc_request *req) if (req->rq_sent && (req->rq_sent > cfs_time_current_sec()) && (!req->rq_generation_set || req->rq_import_generation == imp->imp_generation)) - RETURN (0); + return 0; ptlrpc_rqphase_move(req, RQ_PHASE_RPC); @@ -1385,14 +1385,14 @@ static int ptlrpc_send_new_req(struct ptlrpc_request *req) list_add_tail(&req->rq_list, &imp->imp_delayed_list); atomic_inc(&req->rq_import->imp_inflight); spin_unlock(&imp->imp_lock); - RETURN(0); + return 0; } if (rc != 0) { spin_unlock(&imp->imp_lock); req->rq_status = rc; ptlrpc_rqphase_move(req, RQ_PHASE_INTERPRET); - RETURN(rc); + return rc; } LASSERT(list_empty(&req->rq_list)); @@ -1406,10 +1406,10 @@ static int ptlrpc_send_new_req(struct ptlrpc_request *req) if (rc) { if (req->rq_err) { req->rq_status = rc; - RETURN(1); + return 1; } else { req->rq_wait_ctx = 1; - RETURN(0); + return 0; } } @@ -1424,9 +1424,9 @@ static int ptlrpc_send_new_req(struct ptlrpc_request *req) if (rc) { DEBUG_REQ(D_HA, req, "send failed (%d); expect timeout", rc); req->rq_net_err = 1; - RETURN(rc); + return rc; } - RETURN(0); + return 0; } static inline int ptlrpc_set_producer(struct ptlrpc_request_set *set) @@ -1445,11 +1445,11 @@ static inline int ptlrpc_set_producer(struct ptlrpc_request_set *set) /* no more RPC to produce */ set->set_producer = NULL; set->set_producer_arg = NULL; - RETURN(0); + return 0; } } - RETURN((atomic_read(&set->set_remaining) - remaining)); + return (atomic_read(&set->set_remaining) - remaining); } /** @@ -1464,7 +1464,7 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set) int force_timer_recalc = 0; if (atomic_read(&set->set_remaining) == 0) - RETURN(1); + return 1; list_for_each_safe(tmp, next, &set->set_requests) { struct ptlrpc_request *req = @@ -1817,7 +1817,7 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set) } /* If we hit an error, we want to recover promptly. */ - RETURN(atomic_read(&set->set_remaining) == 0 || force_timer_recalc); + return atomic_read(&set->set_remaining) == 0 || force_timer_recalc; } EXPORT_SYMBOL(ptlrpc_check_set); @@ -1855,14 +1855,14 @@ int ptlrpc_expire_one_request(struct ptlrpc_request *req, int async_unlink) if (imp == NULL) { DEBUG_REQ(D_HA, req, "NULL import: already cleaned up?"); - RETURN(1); + return 1; } atomic_inc(&imp->imp_timeouts); /* The DLM server doesn't want recovery run on its imports. */ if (imp->imp_dlm_fake) - RETURN(1); + return 1; /* If this request is for recovery or other primordial tasks, * then error it out here. */ @@ -1876,7 +1876,7 @@ int ptlrpc_expire_one_request(struct ptlrpc_request *req, int async_unlink) req->rq_status = -ETIMEDOUT; req->rq_err = 1; spin_unlock(&req->rq_lock); - RETURN(1); + return 1; } /* if a request can't be resent we can't wait for an answer after @@ -1888,7 +1888,7 @@ int ptlrpc_expire_one_request(struct ptlrpc_request *req, int async_unlink) ptlrpc_fail_import(imp, lustre_msg_get_conn_cnt(req->rq_reqmsg)); - RETURN(rc); + return rc; } /** @@ -1936,7 +1936,7 @@ int ptlrpc_expired_set(void *data) * sleep so we can recalculate the timeout, or enable interrupts * if everyone's timed out. */ - RETURN(1); + return 1; } EXPORT_SYMBOL(ptlrpc_expired_set); @@ -2025,7 +2025,7 @@ int ptlrpc_set_next_timeout(struct ptlrpc_request_set *set) else if (timeout == 0 || timeout > deadline - now) timeout = deadline - now; } - RETURN(timeout); + return timeout; } EXPORT_SYMBOL(ptlrpc_set_next_timeout); @@ -2053,7 +2053,7 @@ int ptlrpc_set_wait(struct ptlrpc_request_set *set) } if (list_empty(&set->set_requests)) - RETURN(0); + return 0; do { timeout = ptlrpc_set_next_timeout(set); @@ -2150,7 +2150,7 @@ int ptlrpc_set_wait(struct ptlrpc_request_set *set) } } - RETURN(rc); + return rc; } EXPORT_SYMBOL(ptlrpc_set_wait); @@ -2240,13 +2240,13 @@ EXPORT_SYMBOL(ptlrpc_req_finished_with_imp_lock); static int __ptlrpc_req_finished(struct ptlrpc_request *request, int locked) { if (request == NULL) - RETURN(1); + return 1; if (request == LP_POISON || request->rq_reqmsg == LP_POISON) { CERROR("dereferencing freed request (bug 575)\n"); LBUG(); - RETURN(1); + return 1; } DEBUG_REQ(D_INFO, request, "refcount now %u", @@ -2254,10 +2254,10 @@ static int __ptlrpc_req_finished(struct ptlrpc_request *request, int locked) if (atomic_dec_and_test(&request->rq_refcount)) { __ptlrpc_free_req(request, locked); - RETURN(1); + return 1; } - RETURN(0); + return 0; } /** @@ -2307,7 +2307,7 @@ int ptlrpc_unregister_reply(struct ptlrpc_request *request, int async) * Nothing left to do. */ if (!ptlrpc_client_recv_or_unlink(request)) - RETURN(1); + return 1; LNetMDUnlink(request->rq_reply_md_h); @@ -2315,7 +2315,7 @@ int ptlrpc_unregister_reply(struct ptlrpc_request *request, int async) * Let's check it once again. */ if (!ptlrpc_client_recv_or_unlink(request)) - RETURN(1); + return 1; /* * Move to "Unregistering" phase as reply was not unlinked yet. @@ -2326,7 +2326,7 @@ int ptlrpc_unregister_reply(struct ptlrpc_request *request, int async) * Do not wait for unlink to finish. */ if (async) - RETURN(0); + return 0; /* * We have to l_wait_event() whatever the result, to give liblustre @@ -2347,7 +2347,7 @@ int ptlrpc_unregister_reply(struct ptlrpc_request *request, int async) &lwi); if (rc == 0) { ptlrpc_rqphase_move(request, request->rq_next_phase); - RETURN(1); + return 1; } LASSERT(rc == -ETIMEDOUT); @@ -2355,7 +2355,7 @@ int ptlrpc_unregister_reply(struct ptlrpc_request *request, int async) "rvcng=%d unlnk=%d", request->rq_receiving_reply, request->rq_must_unlink); } - RETURN(0); + return 0; } EXPORT_SYMBOL(ptlrpc_unregister_reply); @@ -2485,7 +2485,7 @@ EXPORT_SYMBOL(ptlrpc_restart_req); struct ptlrpc_request *ptlrpc_request_addref(struct ptlrpc_request *req) { atomic_inc(&req->rq_refcount); - RETURN(req); + return req; } EXPORT_SYMBOL(ptlrpc_request_addref); @@ -2561,7 +2561,7 @@ int ptlrpc_queue_wait(struct ptlrpc_request *req) set = ptlrpc_prep_set(); if (set == NULL) { CERROR("Unable to allocate ptlrpc set."); - RETURN(-ENOMEM); + return -ENOMEM; } /* for distributed debugging */ @@ -2573,7 +2573,7 @@ int ptlrpc_queue_wait(struct ptlrpc_request *req) rc = ptlrpc_set_wait(set); ptlrpc_set_destroy(set); - RETURN(rc); + return rc; } EXPORT_SYMBOL(ptlrpc_queue_wait); @@ -2674,7 +2674,7 @@ static int ptlrpc_replay_interpret(const struct lu_env *env, /* this replay failed, so restart recovery */ ptlrpc_connect_import(imp); - RETURN(rc); + return rc; } /** @@ -2714,7 +2714,7 @@ int ptlrpc_replay_req(struct ptlrpc_request *req) ptlrpc_request_addref(req); /* ptlrpcd needs a ref */ ptlrpcd_add_req(req, PDL_POLICY_LOCAL, -1); - RETURN(0); + return 0; } EXPORT_SYMBOL(ptlrpc_replay_req); @@ -2933,13 +2933,13 @@ void *ptlrpcd_alloc_work(struct obd_import *imp, might_sleep(); if (cb == NULL) - RETURN(ERR_PTR(-EINVAL)); + return ERR_PTR(-EINVAL); /* copy some code from deprecated fakereq. */ OBD_ALLOC_PTR(req); if (req == NULL) { CERROR("ptlrpc: run out of memory!\n"); - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); } req->rq_send_state = LUSTRE_IMP_FULL; @@ -2968,7 +2968,7 @@ void *ptlrpcd_alloc_work(struct obd_import *imp, args->cb = cb; args->cbdata = cbdata; - RETURN(req); + return req; } EXPORT_SYMBOL(ptlrpcd_alloc_work); diff --git a/drivers/staging/lustre/lustre/ptlrpc/connection.c b/drivers/staging/lustre/lustre/ptlrpc/connection.c index 37a1e20ea716f..17ca84208873f 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/connection.c +++ b/drivers/staging/lustre/lustre/ptlrpc/connection.c @@ -56,7 +56,7 @@ ptlrpc_connection_get(lnet_process_id_t peer, lnet_nid_t self, OBD_ALLOC_PTR(conn); if (!conn) - RETURN(NULL); + return NULL; conn->c_peer = peer; conn->c_self = self; @@ -92,7 +92,7 @@ int ptlrpc_connection_put(struct ptlrpc_connection *conn) int rc = 0; if (!conn) - RETURN(rc); + return rc; LASSERT(atomic_read(&conn->c_refcount) > 1); @@ -119,7 +119,7 @@ int ptlrpc_connection_put(struct ptlrpc_connection *conn) conn, atomic_read(&conn->c_refcount), libcfs_nid2str(conn->c_peer.nid)); - RETURN(rc); + return rc; } EXPORT_SYMBOL(ptlrpc_connection_put); @@ -131,7 +131,7 @@ ptlrpc_connection_addref(struct ptlrpc_connection *conn) conn, atomic_read(&conn->c_refcount), libcfs_nid2str(conn->c_peer.nid)); - RETURN(conn); + return conn; } EXPORT_SYMBOL(ptlrpc_connection_addref); @@ -145,9 +145,9 @@ int ptlrpc_connection_init(void) CFS_HASH_MAX_THETA, &conn_hash_ops, CFS_HASH_DEFAULT); if (!conn_hash) - RETURN(-ENOMEM); + return -ENOMEM; - RETURN(0); + return 0; } EXPORT_SYMBOL(ptlrpc_connection_init); diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_bulk.c b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_bulk.c index 6e34395422959..b518d8a0aaba9 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_bulk.c +++ b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_bulk.c @@ -103,7 +103,7 @@ int gss_cli_ctx_wrap_bulk(struct ptlrpc_cli_ctx *ctx, bsd->bsd_svc = SPTLRPC_FLVR_BULK_SVC(req->rq_flvr.sf_rpc); if (bsd->bsd_svc == SPTLRPC_BULK_SVC_NULL) - RETURN(0); + return 0; LASSERT(bsd->bsd_svc == SPTLRPC_BULK_SVC_INTG || bsd->bsd_svc == SPTLRPC_BULK_SVC_PRIV); @@ -131,18 +131,18 @@ int gss_cli_ctx_wrap_bulk(struct ptlrpc_cli_ctx *ctx, &token); if (maj != GSS_S_COMPLETE) { CWARN("failed to sign bulk data: %x\n", maj); - RETURN(-EACCES); + return -EACCES; } } else { /* privacy mode */ if (desc->bd_iov_count == 0) - RETURN(0); + return 0; rc = sptlrpc_enc_pool_get_pages(desc); if (rc) { CERROR("bulk write: failed to allocate " "encryption pages: %d\n", rc); - RETURN(rc); + return rc; } token.data = bsd->bsd_data; @@ -152,12 +152,12 @@ int gss_cli_ctx_wrap_bulk(struct ptlrpc_cli_ctx *ctx, maj = lgss_wrap_bulk(gctx->gc_mechctx, desc, &token, 0); if (maj != GSS_S_COMPLETE) { CWARN("fail to encrypt bulk data: %x\n", maj); - RETURN(-EACCES); + return -EACCES; } } } - RETURN(0); + return 0; } int gss_cli_ctx_unwrap_bulk(struct ptlrpc_cli_ctx *ctx, @@ -218,7 +218,7 @@ int gss_cli_ctx_unwrap_bulk(struct ptlrpc_cli_ctx *ctx, "(%u,%u,%u) != (%u,%u,%u)\n", bsdr->bsd_version, bsdr->bsd_type, bsdr->bsd_svc, bsdv->bsd_version, bsdv->bsd_type, bsdv->bsd_svc); - RETURN(-EPROTO); + return -EPROTO; } LASSERT(bsdv->bsd_svc == SPTLRPC_BULK_SVC_NULL || @@ -233,7 +233,7 @@ int gss_cli_ctx_unwrap_bulk(struct ptlrpc_cli_ctx *ctx, if (req->rq_bulk_write) { if (bsdv->bsd_flags & BSD_FL_ERR) { CERROR("server reported bulk i/o failure\n"); - RETURN(-EIO); + return -EIO; } if (bsdv->bsd_svc == SPTLRPC_BULK_SVC_PRIV) @@ -268,12 +268,12 @@ int gss_cli_ctx_unwrap_bulk(struct ptlrpc_cli_ctx *ctx, &token); if (maj != GSS_S_COMPLETE) { CERROR("failed to verify bulk read: %x\n", maj); - RETURN(-EACCES); + return -EACCES; } } else if (bsdv->bsd_svc == SPTLRPC_BULK_SVC_PRIV) { desc->bd_nob = bsdv->bsd_nob; if (desc->bd_nob == 0) - RETURN(0); + return 0; token.data = bsdv->bsd_data; token.len = lustre_msg_buflen(vmsg, voff) - @@ -284,14 +284,14 @@ int gss_cli_ctx_unwrap_bulk(struct ptlrpc_cli_ctx *ctx, if (maj != GSS_S_COMPLETE) { CERROR("failed to decrypt bulk read: %x\n", maj); - RETURN(-EACCES); + return -EACCES; } desc->bd_nob_transferred = desc->bd_nob; } } - RETURN(0); + return 0; } static int gss_prep_bulk(struct ptlrpc_bulk_desc *desc, @@ -322,14 +322,14 @@ int gss_cli_prep_bulk(struct ptlrpc_request *req, LASSERT(req->rq_bulk_read); if (SPTLRPC_FLVR_BULK_SVC(req->rq_flvr.sf_rpc) != SPTLRPC_BULK_SVC_PRIV) - RETURN(0); + return 0; rc = gss_prep_bulk(desc, ctx2gctx(req->rq_cli_ctx)->gc_mechctx); if (rc) CERROR("bulk read: failed to prepare encryption " "pages: %d\n", rc); - RETURN(rc); + return rc; } int gss_svc_prep_bulk(struct ptlrpc_request *req, @@ -351,14 +351,14 @@ int gss_svc_prep_bulk(struct ptlrpc_request *req, bsd = grctx->src_reqbsd; if (bsd->bsd_svc != SPTLRPC_BULK_SVC_PRIV) - RETURN(0); + return 0; rc = gss_prep_bulk(desc, grctx->src_ctx->gsc_mechctx); if (rc) CERROR("bulk write: failed to prepare encryption " "pages: %d\n", rc); - RETURN(rc); + return rc; } int gss_svc_unwrap_bulk(struct ptlrpc_request *req, @@ -399,7 +399,7 @@ int gss_svc_unwrap_bulk(struct ptlrpc_request *req, if (maj != GSS_S_COMPLETE) { bsdv->bsd_flags |= BSD_FL_ERR; CERROR("failed to verify bulk signature: %x\n", maj); - RETURN(-EACCES); + return -EACCES; } break; case SPTLRPC_BULK_SVC_PRIV: @@ -407,7 +407,7 @@ int gss_svc_unwrap_bulk(struct ptlrpc_request *req, bsdv->bsd_flags |= BSD_FL_ERR; CERROR("prepared nob %d doesn't match the actual " "nob %d\n", desc->bd_nob, bsdr->bsd_nob); - RETURN(-EPROTO); + return -EPROTO; } if (desc->bd_iov_count == 0) { @@ -423,12 +423,12 @@ int gss_svc_unwrap_bulk(struct ptlrpc_request *req, if (maj != GSS_S_COMPLETE) { bsdv->bsd_flags |= BSD_FL_ERR; CERROR("failed decrypt bulk data: %x\n", maj); - RETURN(-EACCES); + return -EACCES; } break; } - RETURN(0); + return 0; } int gss_svc_wrap_bulk(struct ptlrpc_request *req, @@ -470,7 +470,7 @@ int gss_svc_wrap_bulk(struct ptlrpc_request *req, if (maj != GSS_S_COMPLETE) { bsdv->bsd_flags |= BSD_FL_ERR; CERROR("failed to sign bulk data: %x\n", maj); - RETURN(-EACCES); + return -EACCES; } break; case SPTLRPC_BULK_SVC_PRIV: @@ -486,7 +486,7 @@ int gss_svc_wrap_bulk(struct ptlrpc_request *req, bsdv->bsd_flags |= BSD_FL_ERR; CERROR("bulk read: failed to allocate encryption " "pages: %d\n", rc); - RETURN(rc); + return rc; } token.data = bsdv->bsd_data; @@ -497,10 +497,10 @@ int gss_svc_wrap_bulk(struct ptlrpc_request *req, if (maj != GSS_S_COMPLETE) { bsdv->bsd_flags |= BSD_FL_ERR; CERROR("failed to encrypt bulk data: %x\n", maj); - RETURN(-EACCES); + return -EACCES; } break; } - RETURN(0); + return 0; } diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_cli_upcall.c b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_cli_upcall.c index ca0640c1e9470..55247af3910e6 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_cli_upcall.c +++ b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_cli_upcall.c @@ -243,41 +243,41 @@ int gss_do_ctx_init_rpc(__user char *buffer, unsigned long count) if (count != sizeof(param)) { CERROR("ioctl size %lu, expect %lu, please check lgss_keyring " "version\n", count, (unsigned long) sizeof(param)); - RETURN(-EINVAL); + return -EINVAL; } if (copy_from_user(¶m, buffer, sizeof(param))) { CERROR("failed copy data from lgssd\n"); - RETURN(-EFAULT); + return -EFAULT; } if (param.version != GSSD_INTERFACE_VERSION) { CERROR("gssd interface version %d (expect %d)\n", param.version, GSSD_INTERFACE_VERSION); - RETURN(-EINVAL); + return -EINVAL; } /* take name */ if (strncpy_from_user(obdname, param.uuid, sizeof(obdname)) <= 0) { CERROR("Invalid obdname pointer\n"); - RETURN(-EFAULT); + return -EFAULT; } obd = class_name2obd(obdname); if (!obd) { CERROR("no such obd %s\n", obdname); - RETURN(-EINVAL); + return -EINVAL; } if (unlikely(!obd->obd_set_up)) { CERROR("obd %s not setup\n", obdname); - RETURN(-EINVAL); + return -EINVAL; } spin_lock(&obd->obd_dev_lock); if (obd->obd_stopping) { CERROR("obd %s has stopped\n", obdname); spin_unlock(&obd->obd_dev_lock); - RETURN(-EINVAL); + return -EINVAL; } if (strcmp(obd->obd_type->typ_name, LUSTRE_MDC_NAME) && @@ -285,7 +285,7 @@ int gss_do_ctx_init_rpc(__user char *buffer, unsigned long count) strcmp(obd->obd_type->typ_name, LUSTRE_MGC_NAME)) { CERROR("obd %s is not a client device\n", obdname); spin_unlock(&obd->obd_dev_lock); - RETURN(-EINVAL); + return -EINVAL; } spin_unlock(&obd->obd_dev_lock); @@ -293,7 +293,7 @@ int gss_do_ctx_init_rpc(__user char *buffer, unsigned long count) if (obd->u.cli.cl_import == NULL) { CERROR("obd %s: import has gone\n", obd->obd_name); up_read(&obd->u.cli.cl_sem); - RETURN(-EINVAL); + return -EINVAL; } imp = class_import_get(obd->u.cli.cl_import); up_read(&obd->u.cli.cl_sem); @@ -301,7 +301,7 @@ int gss_do_ctx_init_rpc(__user char *buffer, unsigned long count) if (imp->imp_deactive) { CERROR("import has been deactivated\n"); class_import_put(imp); - RETURN(-EINVAL); + return -EINVAL; } req = ptlrpc_request_alloc_pack(imp, &RQF_SEC_CTX, LUSTRE_OBD_VERSION, @@ -368,7 +368,7 @@ int gss_do_ctx_init_rpc(__user char *buffer, unsigned long count) class_import_put(imp); ptlrpc_req_finished(req); - RETURN(rc); + return rc; } int gss_do_ctx_fini_rpc(struct gss_cli_ctx *gctx) @@ -385,7 +385,7 @@ int gss_do_ctx_fini_rpc(struct gss_cli_ctx *gctx) CDEBUG(D_SEC, "ctx %p(%u->%s) not uptodate, " "don't send destroy rpc\n", ctx, ctx->cc_vcred.vc_uid, sec2target_str(ctx->cc_sec)); - RETURN(0); + return 0; } might_sleep(); @@ -433,7 +433,7 @@ int gss_do_ctx_fini_rpc(struct gss_cli_ctx *gctx) out_ref: ptlrpc_req_finished(req); out: - RETURN(rc); + return rc; } int __init gss_init_cli_upcall(void) diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_keyring.c b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_keyring.c index 5c51b82933afd..188dbbfbd2f49 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_keyring.c +++ b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_keyring.c @@ -571,7 +571,7 @@ struct ptlrpc_sec * gss_sec_create_kr(struct obd_import *imp, OBD_ALLOC(gsec_kr, sizeof(*gsec_kr)); if (gsec_kr == NULL) - RETURN(NULL); + return NULL; INIT_HLIST_HEAD(&gsec_kr->gsk_clist); gsec_kr->gsk_root_ctx = NULL; @@ -590,11 +590,11 @@ struct ptlrpc_sec * gss_sec_create_kr(struct obd_import *imp, goto err_free; } - RETURN(&gsec_kr->gsk_base.gs_base); + return &gsec_kr->gsk_base.gs_base; err_free: OBD_FREE(gsec_kr, sizeof(*gsec_kr)); - RETURN(NULL); + return NULL; } static @@ -694,7 +694,7 @@ struct ptlrpc_cli_ctx * gss_sec_lookup_ctx_kr(struct ptlrpc_sec *sec, * always succeed. */ if (ctx || sec_is_reverse(sec)) - RETURN(ctx); + return ctx; } LASSERT(create != 0); @@ -818,7 +818,7 @@ struct ptlrpc_cli_ctx * gss_sec_lookup_ctx_kr(struct ptlrpc_sec *sec, out: if (is_root) mutex_unlock(&gsec_kr->gsk_root_uc_lock); - RETURN(ctx); + return ctx; } static @@ -942,7 +942,7 @@ int gss_sec_flush_ctx_cache_kr(struct ptlrpc_sec *sec, else flush_spec_ctx_cache_kr(sec, uid, grace, force); - RETURN(0); + return 0; } static @@ -1021,7 +1021,7 @@ int gss_sec_display_kr(struct ptlrpc_sec *sec, struct seq_file *seq) } spin_unlock(&sec->ps_lock); - RETURN(0); + return 0; } /**************************************** @@ -1140,12 +1140,12 @@ int gss_kt_instantiate(struct key *key, const void *data, size_t datalen) if (data != NULL || datalen != 0) { CERROR("invalid: data %p, len %lu\n", data, (long)datalen); - RETURN(-EINVAL); + return -EINVAL; } if (key->payload.data != 0) { CERROR("key already have payload\n"); - RETURN(-EINVAL); + return -EINVAL; } /* link the key to session keyring, so following context negotiation @@ -1167,11 +1167,11 @@ int gss_kt_instantiate(struct key *key, const void *data, size_t datalen) CERROR("failed to link key %08x to keyring %08x: %d\n", key->serial, key_tgcred(current)->session_keyring->serial, rc); - RETURN(rc); + return rc; } CDEBUG(D_SEC, "key %p instantiated, ctx %p\n", key, key->payload.data); - RETURN(0); + return 0; } /* @@ -1189,7 +1189,7 @@ int gss_kt_update(struct key *key, const void *data, size_t datalen) if (data == NULL || datalen == 0) { CWARN("invalid: data %p, len %lu\n", data, (long)datalen); - RETURN(-EINVAL); + return -EINVAL; } /* if upcall finished negotiation too fast (mostly likely because @@ -1203,9 +1203,9 @@ int gss_kt_update(struct key *key, const void *data, size_t datalen) rc = key_validate(key); if (rc == 0) - RETURN(-EAGAIN); + return -EAGAIN; else - RETURN(rc); + return rc; } LASSERT(atomic_read(&ctx->cc_refcount) > 0); @@ -1216,7 +1216,7 @@ int gss_kt_update(struct key *key, const void *data, size_t datalen) /* don't proceed if already refreshed */ if (cli_ctx_is_refreshed(ctx)) { CWARN("ctx already done refresh\n"); - RETURN(0); + return 0; } sptlrpc_cli_ctx_get(ctx); @@ -1291,7 +1291,7 @@ int gss_kt_update(struct key *key, const void *data, size_t datalen) /* let user space think it's a success */ sptlrpc_cli_ctx_put(ctx, 1); - RETURN(0); + return 0; } static diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_krb5_mech.c b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_krb5_mech.c index 4847f11b797aa..8fa802dd1f909 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_krb5_mech.c +++ b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_krb5_mech.c @@ -920,7 +920,7 @@ int krb5_encrypt_rawobjs(struct ll_crypto_cipher *tfm, if (rc) { CERROR("encrypt error %d\n", rc); - RETURN(rc); + return rc; } datalen += inobjs[i].len; @@ -928,7 +928,7 @@ int krb5_encrypt_rawobjs(struct ll_crypto_cipher *tfm, } outobj->len = datalen; - RETURN(0); + return 0; } /* diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_pipefs.c b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_pipefs.c index f2bd67f54f565..c624518c181ad 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_pipefs.c +++ b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_pipefs.c @@ -301,16 +301,16 @@ int gss_install_rvs_cli_ctx_pf(struct gss_sec *gsec, cli_ctx = ctx_create_pf(&gsec->gs_base, &vcred); if (!cli_ctx) - RETURN(-ENOMEM); + return -ENOMEM; rc = gss_copy_rvc_cli_ctx(cli_ctx, svc_ctx); if (rc) { ctx_destroy_pf(cli_ctx->cc_sec, cli_ctx); - RETURN(rc); + return rc; } gss_sec_ctx_replace_pf(gsec, cli_ctx); - RETURN(0); + return 0; } static @@ -356,7 +356,7 @@ struct ptlrpc_sec* gss_sec_create_pf(struct obd_import *imp, OBD_ALLOC(gsec_pf, alloc_size); if (!gsec_pf) - RETURN(NULL); + return NULL; gsec_pf->gsp_chash_size = hash_size; for (i = 0; i < hash_size; i++) @@ -374,13 +374,13 @@ struct ptlrpc_sec* gss_sec_create_pf(struct obd_import *imp, goto err_destroy; } - RETURN(&gsec_pf->gsp_base.gs_base); + return &gsec_pf->gsp_base.gs_base; err_destroy: gss_sec_destroy_common(&gsec_pf->gsp_base); err_free: OBD_FREE(gsec_pf, alloc_size); - RETURN(NULL); + return NULL; } static @@ -466,7 +466,7 @@ struct ptlrpc_cli_ctx * gss_sec_lookup_ctx_pf(struct ptlrpc_sec *sec, /* don't allocate for reverse sec */ if (sec_is_reverse(sec)) { spin_unlock(&sec->ps_lock); - RETURN(NULL); + return NULL; } if (new) { @@ -497,7 +497,7 @@ struct ptlrpc_cli_ctx * gss_sec_lookup_ctx_pf(struct ptlrpc_sec *sec, } ctx_list_destroy_pf(&freelist); - RETURN(ctx); + return ctx; } static @@ -576,7 +576,7 @@ int gss_sec_flush_ctx_cache_pf(struct ptlrpc_sec *sec, spin_unlock(&sec->ps_lock); ctx_list_destroy_pf(&freelist); - RETURN(busy); + return busy; } /**************************************** @@ -804,12 +804,12 @@ ssize_t gss_pipe_upcall(struct file *filp, struct rpc_pipe_msg *msg, left = copy_to_user(dst, data, mlen); if (left < 0) { msg->errno = left; - RETURN(left); + return left; } mlen -= left; msg->copied += mlen; msg->errno = 0; - RETURN(mlen); + return mlen; } static @@ -829,7 +829,7 @@ ssize_t gss_pipe_downcall(struct file *filp, const char *src, size_t mlen) OBD_ALLOC(buf, mlen); if (!buf) - RETURN(-ENOMEM); + return -ENOMEM; if (copy_from_user(buf, src, mlen)) { CERROR("failed copy user space data\n"); @@ -927,7 +927,7 @@ ssize_t gss_pipe_downcall(struct file *filp, const char *src, size_t mlen) * hack pipefs: always return asked length unless all following * downcalls might be messed up. */ rc = mlen; - RETURN(rc); + return rc; } static @@ -1033,14 +1033,14 @@ int gss_ctx_refresh_pf(struct ptlrpc_cli_ctx *ctx) imp = ctx->cc_sec->ps_import; if (!imp->imp_connection) { CERROR("import has no connection set\n"); - RETURN(-EINVAL); + return -EINVAL; } gsec = container_of(ctx->cc_sec, struct gss_sec, gs_base); OBD_ALLOC_PTR(gmsg); if (!gmsg) - RETURN(-ENOMEM); + return -ENOMEM; /* initialize pipefs base msg */ INIT_LIST_HEAD(&gmsg->gum_base.list); @@ -1088,10 +1088,10 @@ int gss_ctx_refresh_pf(struct ptlrpc_cli_ctx *ctx) goto err_free; } - RETURN(0); + return 0; err_free: OBD_FREE_PTR(gmsg); - RETURN(rc); + return rc; } static diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_rawobj.c b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_rawobj.c index 474ecf805307e..fb298aef66ebd 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_rawobj.c +++ b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_rawobj.c @@ -65,7 +65,7 @@ int rawobj_alloc(rawobj_t *obj, char *buf, int len) OBD_ALLOC_LARGE(obj->data, len); if (!obj->data) { obj->len = 0; - RETURN(-ENOMEM); + return -ENOMEM; } memcpy(obj->data, buf, len); } else diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_svc_upcall.c b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_svc_upcall.c index 245044b6d77a7..5b5365b4629ff 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_svc_upcall.c +++ b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_svc_upcall.c @@ -339,7 +339,7 @@ static int rsi_parse(struct cache_detail *cd, char *mesg, int mlen) if (status) CERROR("rsi parse error %d\n", status); - RETURN(status); + return status; } static struct cache_detail rsi_cache = { @@ -787,7 +787,7 @@ int gss_svc_upcall_install_rvs_ctx(struct obd_import *imp, if (rc) CERROR("create reverse svc ctx: idx "LPX64", rc %d\n", gsec->gs_rvs_hdl, rc); - RETURN(rc); + return rc; } int gss_svc_upcall_expire_rvs_ctx(rawobj_t *handle) @@ -1010,7 +1010,7 @@ int gss_svc_upcall_handle_init(struct ptlrpc_request *req, COMPAT_RSC_PUT(&rsci->h, &rsc_cache); } - RETURN(rc); + return rc; } struct gss_svc_ctx *gss_svc_upcall_get_ctx(struct ptlrpc_request *req, diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/sec_gss.c b/drivers/staging/lustre/lustre/ptlrpc/gss/sec_gss.c index 95e4536f04847..b42ddda9ee25e 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/sec_gss.c +++ b/drivers/staging/lustre/lustre/ptlrpc/gss/sec_gss.c @@ -283,7 +283,7 @@ __u32 gss_unseal_msg(struct gss_ctx *mechctx, if (msgbuf->lm_bufcount != 2) { CERROR("invalid bufcount %d\n", msgbuf->lm_bufcount); - RETURN(GSS_S_FAILURE); + return GSS_S_FAILURE; } /* allocate a temporary clear text buffer, same sized as token, @@ -291,7 +291,7 @@ __u32 gss_unseal_msg(struct gss_ctx *mechctx, clear_buflen = lustre_msg_buflen(msgbuf, 1); OBD_ALLOC_LARGE(clear_buf, clear_buflen); if (!clear_buf) - RETURN(GSS_S_FAILURE); + return GSS_S_FAILURE; /* buffer objects */ hdrobj.len = lustre_msg_buflen(msgbuf, 0); @@ -316,7 +316,7 @@ __u32 gss_unseal_msg(struct gss_ctx *mechctx, major = GSS_S_COMPLETE; out_free: OBD_FREE_LARGE(clear_buf, clear_buflen); - RETURN(major); + return major; } /******************************************** @@ -652,7 +652,7 @@ int gss_cli_ctx_sign(struct ptlrpc_cli_ctx *ctx, /* nothing to do for context negotiation RPCs */ if (req->rq_ctx_init) - RETURN(0); + return 0; svc = SPTLRPC_FLVR_SVC(req->rq_flvr.sf_rpc); if (req->rq_pack_bulk) @@ -668,7 +668,7 @@ int gss_cli_ctx_sign(struct ptlrpc_cli_ctx *ctx, flags, gctx->gc_proc, seq, svc, &gctx->gc_handle); if (rc < 0) - RETURN(rc); + return rc; /* gss_sign_msg() msg might take long time to finish, in which period * more rpcs could be wrapped up and sent out. if we found too many @@ -687,7 +687,7 @@ int gss_cli_ctx_sign(struct ptlrpc_cli_ctx *ctx, } req->rq_reqdata_len = rc; - RETURN(0); + return 0; } static @@ -774,12 +774,12 @@ int gss_cli_ctx_verify(struct ptlrpc_cli_ctx *ctx, if (req->rq_ctx_init && !req->rq_early) { req->rq_repmsg = lustre_msg_buf(msg, 1, 0); req->rq_replen = msg->lm_buflens[1]; - RETURN(0); + return 0; } if (msg->lm_bufcount < 2 || msg->lm_bufcount > 4) { CERROR("unexpected bufcount %u\n", msg->lm_bufcount); - RETURN(-EPROTO); + return -EPROTO; } swabbed = ptlrpc_rep_need_swab(req); @@ -787,7 +787,7 @@ int gss_cli_ctx_verify(struct ptlrpc_cli_ctx *ctx, ghdr = gss_swab_header(msg, 0, swabbed); if (ghdr == NULL) { CERROR("can't decode gss header\n"); - RETURN(-EPROTO); + return -EPROTO; } /* sanity checks */ @@ -797,7 +797,7 @@ int gss_cli_ctx_verify(struct ptlrpc_cli_ctx *ctx, if (ghdr->gh_version != reqhdr->gh_version) { CERROR("gss version %u mismatch, expect %u\n", ghdr->gh_version, reqhdr->gh_version); - RETURN(-EPROTO); + return -EPROTO; } switch (ghdr->gh_proc) { @@ -807,19 +807,19 @@ int gss_cli_ctx_verify(struct ptlrpc_cli_ctx *ctx, if (!req->rq_early && !equi(req->rq_pack_bulk == 1, pack_bulk)){ CERROR("%s bulk flag in reply\n", req->rq_pack_bulk ? "missing" : "unexpected"); - RETURN(-EPROTO); + return -EPROTO; } if (ghdr->gh_seq != reqhdr->gh_seq) { CERROR("seqnum %u mismatch, expect %u\n", ghdr->gh_seq, reqhdr->gh_seq); - RETURN(-EPROTO); + return -EPROTO; } if (ghdr->gh_svc != reqhdr->gh_svc) { CERROR("svc %u mismatch, expect %u\n", ghdr->gh_svc, reqhdr->gh_svc); - RETURN(-EPROTO); + return -EPROTO; } if (swabbed) @@ -828,7 +828,7 @@ int gss_cli_ctx_verify(struct ptlrpc_cli_ctx *ctx, major = gss_verify_msg(msg, gctx->gc_mechctx, reqhdr->gh_svc); if (major != GSS_S_COMPLETE) { CERROR("failed to verify reply: %x\n", major); - RETURN(-EPERM); + return -EPERM; } if (req->rq_early && reqhdr->gh_svc == SPTLRPC_SVC_NULL) { @@ -840,7 +840,7 @@ int gss_cli_ctx_verify(struct ptlrpc_cli_ctx *ctx, if (cksum != msg->lm_cksum) { CWARN("early reply checksum mismatch: " "%08x != %08x\n", cksum, msg->lm_cksum); - RETURN(-EPROTO); + return -EPROTO; } } @@ -849,13 +849,13 @@ int gss_cli_ctx_verify(struct ptlrpc_cli_ctx *ctx, if (msg->lm_bufcount < 3) { CERROR("Invalid reply bufcount %u\n", msg->lm_bufcount); - RETURN(-EPROTO); + return -EPROTO; } rc = bulk_sec_desc_unpack(msg, 2, swabbed); if (rc) { CERROR("unpack bulk desc: %d\n", rc); - RETURN(rc); + return rc; } } @@ -875,7 +875,7 @@ int gss_cli_ctx_verify(struct ptlrpc_cli_ctx *ctx, rc = -EPROTO; } - RETURN(rc); + return rc; } int gss_cli_ctx_seal(struct ptlrpc_cli_ctx *ctx, @@ -911,7 +911,7 @@ int gss_cli_ctx_seal(struct ptlrpc_cli_ctx *ctx, } else { OBD_ALLOC_LARGE(req->rq_reqbuf, wiresize); if (!req->rq_reqbuf) - RETURN(-ENOMEM); + return -ENOMEM; req->rq_reqbuf_len = wiresize; } @@ -965,7 +965,7 @@ int gss_cli_ctx_seal(struct ptlrpc_cli_ctx *ctx, /* now set the final wire data length */ req->rq_reqdata_len = lustre_shrink_msg(req->rq_reqbuf, 1, token.len,0); - RETURN(0); + return 0; err_free: if (!req->rq_pool) { @@ -973,7 +973,7 @@ int gss_cli_ctx_seal(struct ptlrpc_cli_ctx *ctx, req->rq_reqbuf = NULL; req->rq_reqbuf_len = 0; } - RETURN(rc); + return rc; } int gss_cli_ctx_unseal(struct ptlrpc_cli_ctx *ctx, @@ -995,14 +995,14 @@ int gss_cli_ctx_unseal(struct ptlrpc_cli_ctx *ctx, ghdr = gss_swab_header(msg, 0, swabbed); if (ghdr == NULL) { CERROR("can't decode gss header\n"); - RETURN(-EPROTO); + return -EPROTO; } /* sanity checks */ if (ghdr->gh_version != PTLRPC_GSS_VERSION) { CERROR("gss version %u mismatch, expect %u\n", ghdr->gh_version, PTLRPC_GSS_VERSION); - RETURN(-EPROTO); + return -EPROTO; } switch (ghdr->gh_proc) { @@ -1012,7 +1012,7 @@ int gss_cli_ctx_unseal(struct ptlrpc_cli_ctx *ctx, if (!req->rq_early && !equi(req->rq_pack_bulk == 1, pack_bulk)){ CERROR("%s bulk flag in reply\n", req->rq_pack_bulk ? "missing" : "unexpected"); - RETURN(-EPROTO); + return -EPROTO; } if (swabbed) @@ -1033,25 +1033,25 @@ int gss_cli_ctx_unseal(struct ptlrpc_cli_ctx *ctx, swabbed = __lustre_unpack_msg(msg, msglen); if (swabbed < 0) { CERROR("Failed to unpack after decryption\n"); - RETURN(-EPROTO); + return -EPROTO; } if (msg->lm_bufcount < 1) { CERROR("Invalid reply buffer: empty\n"); - RETURN(-EPROTO); + return -EPROTO; } if (pack_bulk) { if (msg->lm_bufcount < 2) { CERROR("bufcount %u: missing bulk sec desc\n", msg->lm_bufcount); - RETURN(-EPROTO); + return -EPROTO; } /* bulk checksum is the last segment */ if (bulk_sec_desc_unpack(msg, msg->lm_bufcount - 1, swabbed)) - RETURN(-EPROTO); + return -EPROTO; } req->rq_repmsg = lustre_msg_buf(msg, 0, 0); @@ -1072,7 +1072,7 @@ int gss_cli_ctx_unseal(struct ptlrpc_cli_ctx *ctx, rc = -EPERM; } - RETURN(rc); + return rc; } /********************************************* @@ -1303,7 +1303,7 @@ int gss_alloc_reqbuf_intg(struct ptlrpc_sec *sec, OBD_ALLOC_LARGE(req->rq_reqbuf, bufsize); if (!req->rq_reqbuf) - RETURN(-ENOMEM); + return -ENOMEM; req->rq_reqbuf_len = bufsize; } else { @@ -1322,7 +1322,7 @@ int gss_alloc_reqbuf_intg(struct ptlrpc_sec *sec, if (req->rq_pack_udesc) sptlrpc_pack_user_desc(req->rq_reqbuf, 2); - RETURN(0); + return 0; } static @@ -1389,7 +1389,7 @@ int gss_alloc_reqbuf_priv(struct ptlrpc_sec *sec, OBD_ALLOC_LARGE(req->rq_clrbuf, clearsize); if (!req->rq_clrbuf) - RETURN(-ENOMEM); + return -ENOMEM; } req->rq_clrbuf_len = clearsize; @@ -1399,7 +1399,7 @@ int gss_alloc_reqbuf_priv(struct ptlrpc_sec *sec, if (req->rq_pack_udesc) sptlrpc_pack_user_desc(req->rq_clrbuf, 1); - RETURN(0); + return 0; } /* @@ -1683,7 +1683,7 @@ int gss_enlarge_reqbuf_intg(struct ptlrpc_sec *sec, OBD_ALLOC_LARGE(newbuf, newbuf_size); if (newbuf == NULL) - RETURN(-ENOMEM); + return -ENOMEM; memcpy(newbuf, req->rq_reqbuf, req->rq_reqbuf_len); @@ -1703,7 +1703,7 @@ int gss_enlarge_reqbuf_intg(struct ptlrpc_sec *sec, _sptlrpc_enlarge_msg_inplace(req->rq_reqmsg, segment, newsize); req->rq_reqlen = newmsg_size; - RETURN(0); + return 0; } static @@ -1772,7 +1772,7 @@ int gss_enlarge_reqbuf_priv(struct ptlrpc_sec *sec, OBD_ALLOC_LARGE(newclrbuf, newclrbuf_size); if (newclrbuf == NULL) - RETURN(-ENOMEM); + return -ENOMEM; memcpy(newclrbuf, req->rq_clrbuf, req->rq_clrbuf_len); @@ -1792,7 +1792,7 @@ int gss_enlarge_reqbuf_priv(struct ptlrpc_sec *sec, _sptlrpc_enlarge_msg_inplace(req->rq_reqmsg, segment, newsize); req->rq_reqlen = newmsg_size; - RETURN(0); + return 0; } int gss_enlarge_reqbuf(struct ptlrpc_sec *sec, @@ -1891,7 +1891,7 @@ int gss_svc_sign(struct ptlrpc_request *req, LUSTRE_SP_ANY, flags, PTLRPC_GSS_PROC_DATA, grctx->src_wirectx.gw_seq, svc, NULL); if (rc < 0) - RETURN(rc); + return rc; rs->rs_repdata_len = rc; @@ -1908,7 +1908,7 @@ int gss_svc_sign(struct ptlrpc_request *req, req->rq_reply_off = 0; } - RETURN(0); + return 0; } int gss_pack_err_notify(struct ptlrpc_request *req, __u32 major, __u32 minor) @@ -1920,7 +1920,7 @@ int gss_pack_err_notify(struct ptlrpc_request *req, __u32 major, __u32 minor) int rc; //if (OBD_FAIL_CHECK_ORSET(OBD_FAIL_SVCGSS_ERR_NOTIFY, OBD_FAIL_ONCE)) - // RETURN(-EINVAL); + // return -EINVAL; grctx->src_err_notify = 1; grctx->src_reserve_len = 0; @@ -1928,7 +1928,7 @@ int gss_pack_err_notify(struct ptlrpc_request *req, __u32 major, __u32 minor) rc = lustre_pack_reply_v2(req, 1, &replen, NULL, 0); if (rc) { CERROR("could not pack reply, err %d\n", rc); - RETURN(rc); + return rc; } /* gss hdr */ @@ -1947,7 +1947,7 @@ int gss_pack_err_notify(struct ptlrpc_request *req, __u32 major, __u32 minor) CDEBUG(D_SEC, "prepare gss error notify(0x%x/0x%x) to %s\n", major, minor, libcfs_nid2str(req->rq_peer.nid)); - RETURN(0); + return 0; } static @@ -1970,18 +1970,18 @@ int gss_svc_handle_init(struct ptlrpc_request *req, if (gw->gw_flags & LUSTRE_GSS_PACK_BULK) { CERROR("unexpected bulk flag\n"); - RETURN(SECSVC_DROP); + return SECSVC_DROP; } if (gw->gw_proc == PTLRPC_GSS_PROC_INIT && gw->gw_handle.len != 0) { CERROR("proc %u: invalid handle length %u\n", gw->gw_proc, gw->gw_handle.len); - RETURN(SECSVC_DROP); + return SECSVC_DROP; } if (reqbuf->lm_bufcount < 3 || reqbuf->lm_bufcount > 4){ CERROR("Invalid bufcount %d\n", reqbuf->lm_bufcount); - RETURN(SECSVC_DROP); + return SECSVC_DROP; } swabbed = ptlrpc_req_need_swab(req); @@ -1992,7 +1992,7 @@ int gss_svc_handle_init(struct ptlrpc_request *req, if (seclen < 4 + 4) { CERROR("sec size %d too small\n", seclen); - RETURN(SECSVC_DROP); + return SECSVC_DROP; } /* lustre svc type */ @@ -2003,7 +2003,7 @@ int gss_svc_handle_init(struct ptlrpc_request *req, * because touched internal structure of obd_uuid */ if (rawobj_extract(&uuid_obj, &secdata, &seclen)) { CERROR("failed to extract target uuid\n"); - RETURN(SECSVC_DROP); + return SECSVC_DROP; } uuid_obj.data[uuid_obj.len - 1] = '\0'; @@ -2013,25 +2013,25 @@ int gss_svc_handle_init(struct ptlrpc_request *req, CERROR("target '%s' is not available for context init (%s)\n", uuid->uuid, target == NULL ? "no target" : (target->obd_stopping ? "stopping" : "not set up")); - RETURN(SECSVC_DROP); + return SECSVC_DROP; } /* extract reverse handle */ if (rawobj_extract(&rvs_hdl, &secdata, &seclen)) { CERROR("failed extract reverse handle\n"); - RETURN(SECSVC_DROP); + return SECSVC_DROP; } /* extract token */ if (rawobj_extract(&in_token, &secdata, &seclen)) { CERROR("can't extract token\n"); - RETURN(SECSVC_DROP); + return SECSVC_DROP; } rc = gss_svc_upcall_handle_init(req, grctx, gw, target, lustre_svc, &rvs_hdl, &in_token); if (rc != SECSVC_OK) - RETURN(rc); + return rc; if (grctx->src_ctx->gsc_usr_mds || grctx->src_ctx->gsc_usr_oss || grctx->src_ctx->gsc_usr_root) @@ -2047,11 +2047,11 @@ int gss_svc_handle_init(struct ptlrpc_request *req, if (gw->gw_flags & LUSTRE_GSS_PACK_USER) { if (reqbuf->lm_bufcount < 4) { CERROR("missing user descriptor\n"); - RETURN(SECSVC_DROP); + return SECSVC_DROP; } if (sptlrpc_unpack_user_desc(reqbuf, 2, swabbed)) { CERROR("Mal-formed user descriptor\n"); - RETURN(SECSVC_DROP); + return SECSVC_DROP; } req->rq_pack_udesc = 1; @@ -2061,7 +2061,7 @@ int gss_svc_handle_init(struct ptlrpc_request *req, req->rq_reqmsg = lustre_msg_buf(reqbuf, 1, 0); req->rq_reqlen = lustre_msg_buflen(reqbuf, 1); - RETURN(rc); + return rc; } /* @@ -2082,7 +2082,7 @@ int gss_svc_verify_request(struct ptlrpc_request *req, if (msg->lm_bufcount < 2) { CERROR("Too few segments (%u) in request\n", msg->lm_bufcount); - RETURN(-EINVAL); + return -EINVAL; } if (gw->gw_svc == SPTLRPC_SVC_NULL) @@ -2091,20 +2091,20 @@ int gss_svc_verify_request(struct ptlrpc_request *req, if (gss_check_seq_num(&gctx->gsc_seqdata, gw->gw_seq, 0)) { CERROR("phase 0: discard replayed req: seq %u\n", gw->gw_seq); *major = GSS_S_DUPLICATE_TOKEN; - RETURN(-EACCES); + return -EACCES; } *major = gss_verify_msg(msg, gctx->gsc_mechctx, gw->gw_svc); if (*major != GSS_S_COMPLETE) { CERROR("failed to verify request: %x\n", *major); - RETURN(-EACCES); + return -EACCES; } if (gctx->gsc_reverse == 0 && gss_check_seq_num(&gctx->gsc_seqdata, gw->gw_seq, 1)) { CERROR("phase 1+: discard replayed req: seq %u\n", gw->gw_seq); *major = GSS_S_DUPLICATE_TOKEN; - RETURN(-EACCES); + return -EACCES; } verified: @@ -2114,12 +2114,12 @@ int gss_svc_verify_request(struct ptlrpc_request *req, if (gw->gw_flags & LUSTRE_GSS_PACK_USER) { if (msg->lm_bufcount < (offset + 1)) { CERROR("no user desc included\n"); - RETURN(-EINVAL); + return -EINVAL; } if (sptlrpc_unpack_user_desc(msg, offset, swabbed)) { CERROR("Mal-formed user descriptor\n"); - RETURN(-EINVAL); + return -EINVAL; } req->rq_pack_udesc = 1; @@ -2131,11 +2131,11 @@ int gss_svc_verify_request(struct ptlrpc_request *req, if (gw->gw_flags & LUSTRE_GSS_PACK_BULK) { if (msg->lm_bufcount < (offset + 1)) { CERROR("missing bulk sec descriptor\n"); - RETURN(-EINVAL); + return -EINVAL; } if (bulk_sec_desc_unpack(msg, offset, swabbed)) - RETURN(-EINVAL); + return -EINVAL; req->rq_pack_bulk = 1; grctx->src_reqbsd = lustre_msg_buf(msg, offset, 0); @@ -2144,7 +2144,7 @@ int gss_svc_verify_request(struct ptlrpc_request *req, req->rq_reqmsg = lustre_msg_buf(msg, 1, 0); req->rq_reqlen = msg->lm_buflens[1]; - RETURN(0); + return 0; } static @@ -2160,43 +2160,43 @@ int gss_svc_unseal_request(struct ptlrpc_request *req, if (gss_check_seq_num(&gctx->gsc_seqdata, gw->gw_seq, 0)) { CERROR("phase 0: discard replayed req: seq %u\n", gw->gw_seq); *major = GSS_S_DUPLICATE_TOKEN; - RETURN(-EACCES); + return -EACCES; } *major = gss_unseal_msg(gctx->gsc_mechctx, msg, &msglen, req->rq_reqdata_len); if (*major != GSS_S_COMPLETE) { CERROR("failed to unwrap request: %x\n", *major); - RETURN(-EACCES); + return -EACCES; } if (gss_check_seq_num(&gctx->gsc_seqdata, gw->gw_seq, 1)) { CERROR("phase 1+: discard replayed req: seq %u\n", gw->gw_seq); *major = GSS_S_DUPLICATE_TOKEN; - RETURN(-EACCES); + return -EACCES; } swabbed = __lustre_unpack_msg(msg, msglen); if (swabbed < 0) { CERROR("Failed to unpack after decryption\n"); - RETURN(-EINVAL); + return -EINVAL; } req->rq_reqdata_len = msglen; if (msg->lm_bufcount < 1) { CERROR("Invalid buffer: is empty\n"); - RETURN(-EINVAL); + return -EINVAL; } if (gw->gw_flags & LUSTRE_GSS_PACK_USER) { if (msg->lm_bufcount < offset + 1) { CERROR("no user descriptor included\n"); - RETURN(-EINVAL); + return -EINVAL; } if (sptlrpc_unpack_user_desc(msg, offset, swabbed)) { CERROR("Mal-formed user descriptor\n"); - RETURN(-EINVAL); + return -EINVAL; } req->rq_pack_udesc = 1; @@ -2207,11 +2207,11 @@ int gss_svc_unseal_request(struct ptlrpc_request *req, if (gw->gw_flags & LUSTRE_GSS_PACK_BULK) { if (msg->lm_bufcount < offset + 1) { CERROR("no bulk checksum included\n"); - RETURN(-EINVAL); + return -EINVAL; } if (bulk_sec_desc_unpack(msg, offset, swabbed)) - RETURN(-EINVAL); + return -EINVAL; req->rq_pack_bulk = 1; grctx->src_reqbsd = lustre_msg_buf(msg, offset, 0); @@ -2220,7 +2220,7 @@ int gss_svc_unseal_request(struct ptlrpc_request *req, req->rq_reqmsg = lustre_msg_buf(req->rq_reqbuf, 0, 0); req->rq_reqlen = req->rq_reqbuf->lm_buflens[0]; - RETURN(0); + return 0; } static @@ -2252,7 +2252,7 @@ int gss_svc_handle_data(struct ptlrpc_request *req, } if (rc == 0) - RETURN(SECSVC_OK); + return SECSVC_OK; CERROR("svc %u failed: major 0x%08x: req xid "LPU64" ctx %p idx " LPX64"(%u->%s)\n", gw->gw_svc, major, req->rq_xid, @@ -2263,9 +2263,9 @@ int gss_svc_handle_data(struct ptlrpc_request *req, * might happen after server reboot, to allow recovery. */ if ((major == GSS_S_NO_CONTEXT || major == GSS_S_BAD_SIG) && gss_pack_err_notify(req, major, 0) == 0) - RETURN(SECSVC_COMPLETE); + return SECSVC_COMPLETE; - RETURN(SECSVC_DROP); + return SECSVC_DROP; } static @@ -2281,16 +2281,16 @@ int gss_svc_handle_destroy(struct ptlrpc_request *req, grctx->src_ctx = gss_svc_upcall_get_ctx(req, gw); if (!grctx->src_ctx) { CDEBUG(D_SEC, "invalid gss context handle for destroy.\n"); - RETURN(SECSVC_DROP); + return SECSVC_DROP; } if (gw->gw_svc != SPTLRPC_SVC_INTG) { CERROR("svc %u is not supported in destroy.\n", gw->gw_svc); - RETURN(SECSVC_DROP); + return SECSVC_DROP; } if (gss_svc_verify_request(req, grctx, gw, &major)) - RETURN(SECSVC_DROP); + return SECSVC_DROP; CWARN("destroy svc ctx %p idx "LPX64" (%u->%s)\n", grctx->src_ctx, gss_handle_to_u64(&gw->gw_handle), @@ -2301,19 +2301,19 @@ int gss_svc_handle_destroy(struct ptlrpc_request *req, if (gw->gw_flags & LUSTRE_GSS_PACK_USER) { if (req->rq_reqbuf->lm_bufcount < 4) { CERROR("missing user descriptor, ignore it\n"); - RETURN(SECSVC_OK); + return SECSVC_OK; } if (sptlrpc_unpack_user_desc(req->rq_reqbuf, 2, ptlrpc_req_need_swab(req))) { CERROR("Mal-formed user descriptor, ignore it\n"); - RETURN(SECSVC_OK); + return SECSVC_OK; } req->rq_pack_udesc = 1; req->rq_user_desc = lustre_msg_buf(req->rq_reqbuf, 2, 0); } - RETURN(SECSVC_OK); + return SECSVC_OK; } int gss_svc_accept(struct ptlrpc_sec_policy *policy, struct ptlrpc_request *req) @@ -2328,7 +2328,7 @@ int gss_svc_accept(struct ptlrpc_sec_policy *policy, struct ptlrpc_request *req) if (req->rq_reqbuf->lm_bufcount < 2) { CERROR("buf count only %d\n", req->rq_reqbuf->lm_bufcount); - RETURN(SECSVC_DROP); + return SECSVC_DROP; } swabbed = ptlrpc_req_need_swab(req); @@ -2336,14 +2336,14 @@ int gss_svc_accept(struct ptlrpc_sec_policy *policy, struct ptlrpc_request *req) ghdr = gss_swab_header(req->rq_reqbuf, 0, swabbed); if (ghdr == NULL) { CERROR("can't decode gss header\n"); - RETURN(SECSVC_DROP); + return SECSVC_DROP; } /* sanity checks */ if (ghdr->gh_version != PTLRPC_GSS_VERSION) { CERROR("gss version %u, expect %u\n", ghdr->gh_version, PTLRPC_GSS_VERSION); - RETURN(SECSVC_DROP); + return SECSVC_DROP; } req->rq_sp_from = ghdr->gh_sp; @@ -2351,7 +2351,7 @@ int gss_svc_accept(struct ptlrpc_sec_policy *policy, struct ptlrpc_request *req) /* alloc grctx data */ OBD_ALLOC_PTR(grctx); if (!grctx) - RETURN(SECSVC_DROP); + return SECSVC_DROP; grctx->src_base.sc_policy = sptlrpc_policy_get(policy); atomic_set(&grctx->src_base.sc_refcount, 1); @@ -2406,7 +2406,7 @@ int gss_svc_accept(struct ptlrpc_sec_policy *policy, struct ptlrpc_request *req) break; } - RETURN(rc); + return rc; } void gss_svc_invalidate_ctx(struct ptlrpc_svc_ctx *svc_ctx) @@ -2475,7 +2475,7 @@ int gss_svc_alloc_rs(struct ptlrpc_request *req, int msglen) if (req->rq_pack_bulk && !req->rq_bulk_read && !req->rq_bulk_write) { CERROR("client request bulk sec on non-bulk rpc\n"); - RETURN(-EPROTO); + return -EPROTO; } svc = SPTLRPC_FLVR_SVC(req->rq_flvr.sf_rpc); @@ -2548,7 +2548,7 @@ int gss_svc_alloc_rs(struct ptlrpc_request *req, int msglen) } else { OBD_ALLOC_LARGE(rs, rs_size); if (rs == NULL) - RETURN(-ENOMEM); + return -ENOMEM; rs->rs_size = rs_size; } @@ -2578,7 +2578,7 @@ int gss_svc_alloc_rs(struct ptlrpc_request *req, int msglen) LASSERT(rs->rs_msg); req->rq_reply_state = rs; - RETURN(0); + return 0; } static int gss_svc_seal(struct ptlrpc_request *req, @@ -2619,7 +2619,7 @@ static int gss_svc_seal(struct ptlrpc_request *req, token_buflen = gss_mech_payload(gctx->gsc_mechctx, msglen, 1); OBD_ALLOC_LARGE(token_buf, token_buflen); if (token_buf == NULL) - RETURN(-ENOMEM); + return -ENOMEM; hdrobj.len = PTLRPC_GSS_HEADER_SIZE; hdrobj.data = (__u8 *) ghdr; @@ -2675,7 +2675,7 @@ static int gss_svc_seal(struct ptlrpc_request *req, rc = 0; out_free: OBD_FREE_LARGE(token_buf, token_buflen); - RETURN(rc); + return rc; } int gss_svc_authorize(struct ptlrpc_request *req) @@ -2691,7 +2691,7 @@ int gss_svc_authorize(struct ptlrpc_request *req) LASSERT(rs->rs_repdata_len != 0); req->rq_reply_off = gss_at_reply_off_integ; - RETURN(0); + return 0; } /* early reply could happen in many cases */ @@ -2699,7 +2699,7 @@ int gss_svc_authorize(struct ptlrpc_request *req) gw->gw_proc != PTLRPC_GSS_PROC_DATA && gw->gw_proc != PTLRPC_GSS_PROC_DESTROY) { CERROR("proc %d not support\n", gw->gw_proc); - RETURN(-EINVAL); + return -EINVAL; } LASSERT(grctx->src_ctx); @@ -2720,7 +2720,7 @@ int gss_svc_authorize(struct ptlrpc_request *req) rc = 0; out: - RETURN(rc); + return rc; } void gss_svc_free_rs(struct ptlrpc_reply_state *rs) diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c index b8a00f562597c..2cdbb4d909c97 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/import.c +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c @@ -462,7 +462,7 @@ static int import_select_connection(struct obd_import *imp) CERROR("%s: no connections available\n", imp->imp_obd->obd_name); spin_unlock(&imp->imp_lock); - RETURN(-EINVAL); + return -EINVAL; } list_for_each_entry(conn, &imp->imp_conn_list, oic_item) { @@ -551,7 +551,7 @@ static int import_select_connection(struct obd_import *imp) spin_unlock(&imp->imp_lock); - RETURN(0); + return 0; } /* @@ -600,15 +600,15 @@ int ptlrpc_connect_import(struct obd_import *imp) if (imp->imp_state == LUSTRE_IMP_CLOSED) { spin_unlock(&imp->imp_lock); CERROR("can't connect to a closed import\n"); - RETURN(-EINVAL); + return -EINVAL; } else if (imp->imp_state == LUSTRE_IMP_FULL) { spin_unlock(&imp->imp_lock); CERROR("already connected\n"); - RETURN(0); + return 0; } else if (imp->imp_state == LUSTRE_IMP_CONNECTING) { spin_unlock(&imp->imp_lock); CERROR("already connecting\n"); - RETURN(-EALREADY); + return -EALREADY; } IMPORT_SET_STATE_NOLOCK(imp, LUSTRE_IMP_CONNECTING); @@ -708,7 +708,7 @@ int ptlrpc_connect_import(struct obd_import *imp) IMPORT_SET_STATE(imp, LUSTRE_IMP_DISCON); } - RETURN(rc); + return rc; } EXPORT_SYMBOL(ptlrpc_connect_import); @@ -753,7 +753,7 @@ static int ptlrpc_connect_interpret(const struct lu_env *env, if (imp->imp_state == LUSTRE_IMP_CLOSED) { imp->imp_connect_tried = 1; spin_unlock(&imp->imp_lock); - RETURN(0); + return 0; } if (rc) { @@ -975,7 +975,7 @@ static int ptlrpc_connect_interpret(const struct lu_env *env, imp->imp_connection->c_remote_uuid.uuid); ptlrpc_connect_import(imp); imp->imp_connect_tried = 1; - RETURN(0); + return 0; } } else { @@ -1128,7 +1128,7 @@ static int ptlrpc_connect_interpret(const struct lu_env *env, /* reply message might not be ready */ if (request->rq_repmsg == NULL) - RETURN(-EPROTO); + return -EPROTO; ocd = req_capsule_server_get(&request->rq_pill, &RMF_CONNECT_DATA); @@ -1152,7 +1152,7 @@ static int ptlrpc_connect_interpret(const struct lu_env *env, ptlrpc_deactivate_import(imp); IMPORT_SET_STATE(imp, LUSTRE_IMP_CLOSED); } - RETURN(-EPROTO); + return -EPROTO; } ptlrpc_maybe_ping_import_soon(imp); @@ -1163,7 +1163,7 @@ static int ptlrpc_connect_interpret(const struct lu_env *env, } wake_up_all(&imp->imp_recovery_waitq); - RETURN(rc); + return rc; } /** @@ -1192,7 +1192,7 @@ static int completed_replay_interpret(const struct lu_env *env, ptlrpc_connect_import(req->rq_import); } - RETURN(0); + return 0; } /** @@ -1204,7 +1204,7 @@ static int signal_completed_replay(struct obd_import *imp) struct ptlrpc_request *req; if (unlikely(OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_FINISH_REPLAY))) - RETURN(0); + return 0; LASSERT(atomic_read(&imp->imp_replay_inflight) == 0); atomic_inc(&imp->imp_replay_inflight); @@ -1213,7 +1213,7 @@ static int signal_completed_replay(struct obd_import *imp) OBD_PING); if (req == NULL) { atomic_dec(&imp->imp_replay_inflight); - RETURN(-ENOMEM); + return -ENOMEM; } ptlrpc_request_set_replen(req); @@ -1225,7 +1225,7 @@ static int signal_completed_replay(struct obd_import *imp) req->rq_interpret_reply = completed_replay_interpret; ptlrpcd_add_req(req, PDL_POLICY_ROUND, -1); - RETURN(0); + return 0; } /** @@ -1254,7 +1254,7 @@ static int ptlrpc_invalidate_import_thread(void *data) ptlrpc_import_recovery_state_machine(imp); class_import_put(imp); - RETURN(0); + return 0; } /** @@ -1320,7 +1320,7 @@ int ptlrpc_import_recovery_state_machine(struct obd_import *imp) } else { rc = 0; } - RETURN(rc); + return rc; } } @@ -1379,7 +1379,7 @@ int ptlrpc_import_recovery_state_machine(struct obd_import *imp) } out: - RETURN(rc); + return rc; } int ptlrpc_disconnect_import(struct obd_import *imp, int noclose) @@ -1398,7 +1398,7 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose) default: CERROR("don't know how to disconnect from %s (connect_op %d)\n", obd2cli_tgt(imp->imp_obd), imp->imp_connect_op); - RETURN(-EINVAL); + return -EINVAL; } if (ptlrpc_import_in_recovery(imp)) { @@ -1461,7 +1461,7 @@ int ptlrpc_disconnect_import(struct obd_import *imp, int noclose) memset(&imp->imp_remote_handle, 0, sizeof(imp->imp_remote_handle)); spin_unlock(&imp->imp_lock); - RETURN(rc); + return rc; } EXPORT_SYMBOL(ptlrpc_disconnect_import); diff --git a/drivers/staging/lustre/lustre/ptlrpc/llog_client.c b/drivers/staging/lustre/lustre/ptlrpc/llog_client.c index d771cb9f129fd..379e59477ea2d 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/llog_client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/llog_client.c @@ -167,7 +167,7 @@ static int llog_client_destroy(const struct lu_env *env, ptlrpc_req_finished(req); err_exit: LLOG_CLIENT_EXIT(loghandle->lgh_ctxt, imp); - RETURN(rc); + return rc; } diff --git a/drivers/staging/lustre/lustre/ptlrpc/llog_net.c b/drivers/staging/lustre/lustre/ptlrpc/llog_net.c index 963223d3ed1f3..17c06a32df629 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/llog_net.c +++ b/drivers/staging/lustre/lustre/ptlrpc/llog_net.c @@ -69,6 +69,6 @@ int llog_initiator_connect(struct llog_ctxt *ctxt) ctxt->loc_imp = class_import_get(new_imp); } mutex_unlock(&ctxt->loc_mutex); - RETURN(0); + return 0; } EXPORT_SYMBOL(llog_initiator_connect); diff --git a/drivers/staging/lustre/lustre/ptlrpc/llog_server.c b/drivers/staging/lustre/lustre/ptlrpc/llog_server.c index 711cbd1ecc290..af9d2ac391eff 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/llog_server.c +++ b/drivers/staging/lustre/lustre/ptlrpc/llog_server.c @@ -73,7 +73,7 @@ int llog_origin_handle_open(struct ptlrpc_request *req) body = req_capsule_client_get(&req->rq_pill, &RMF_LLOGD_BODY); if (body == NULL) - RETURN(-EFAULT); + return -EFAULT; if (ostid_id(&body->lgd_logid.lgl_oi) > 0) logid = &body->lgd_logid; @@ -81,7 +81,7 @@ int llog_origin_handle_open(struct ptlrpc_request *req) if (req_capsule_field_present(&req->rq_pill, &RMF_NAME, RCL_CLIENT)) { name = req_capsule_client_get(&req->rq_pill, &RMF_NAME); if (name == NULL) - RETURN(-EFAULT); + return -EFAULT; CDEBUG(D_INFO, "%s: opening log %s\n", obd->obd_name, name); } @@ -89,7 +89,7 @@ int llog_origin_handle_open(struct ptlrpc_request *req) if (ctxt == NULL) { CDEBUG(D_WARNING, "%s: no ctxt. group=%p idx=%d name=%s\n", obd->obd_name, &obd->obd_olg, body->lgd_ctxt_idx, name); - RETURN(-ENODEV); + return -ENODEV; } disk_obd = ctxt->loc_exp->exp_obd; push_ctxt(&saved, &disk_obd->obd_lvfs_ctxt, NULL); @@ -126,7 +126,7 @@ int llog_origin_handle_destroy(struct ptlrpc_request *req) body = req_capsule_client_get(&req->rq_pill, &RMF_LLOGD_BODY); if (body == NULL) - RETURN(-EFAULT); + return -EFAULT; if (ostid_id(&body->lgd_logid.lgl_oi) > 0) logid = &body->lgd_logid; @@ -137,7 +137,7 @@ int llog_origin_handle_destroy(struct ptlrpc_request *req) ctxt = llog_get_context(req->rq_export->exp_obd, body->lgd_ctxt_idx); if (ctxt == NULL) - RETURN(-ENODEV); + return -ENODEV; disk_obd = ctxt->loc_exp->exp_obd; push_ctxt(&saved, &disk_obd->obd_lvfs_ctxt, NULL); @@ -148,7 +148,7 @@ int llog_origin_handle_destroy(struct ptlrpc_request *req) rc = llog_erase(req->rq_svc_thread->t_env, ctxt, logid, NULL); pop_ctxt(&saved, &disk_obd->obd_lvfs_ctxt, NULL); llog_ctxt_put(ctxt); - RETURN(rc); + return rc; } EXPORT_SYMBOL(llog_origin_handle_destroy); @@ -166,11 +166,11 @@ int llog_origin_handle_next_block(struct ptlrpc_request *req) body = req_capsule_client_get(&req->rq_pill, &RMF_LLOGD_BODY); if (body == NULL) - RETURN(-EFAULT); + return -EFAULT; ctxt = llog_get_context(req->rq_export->exp_obd, body->lgd_ctxt_idx); if (ctxt == NULL) - RETURN(-ENODEV); + return -ENODEV; disk_obd = ctxt->loc_exp->exp_obd; push_ctxt(&saved, &disk_obd->obd_lvfs_ctxt, NULL); @@ -224,11 +224,11 @@ int llog_origin_handle_prev_block(struct ptlrpc_request *req) body = req_capsule_client_get(&req->rq_pill, &RMF_LLOGD_BODY); if (body == NULL) - RETURN(-EFAULT); + return -EFAULT; ctxt = llog_get_context(req->rq_export->exp_obd, body->lgd_ctxt_idx); if (ctxt == NULL) - RETURN(-ENODEV); + return -ENODEV; disk_obd = ctxt->loc_exp->exp_obd; push_ctxt(&saved, &disk_obd->obd_lvfs_ctxt, NULL); @@ -281,11 +281,11 @@ int llog_origin_handle_read_header(struct ptlrpc_request *req) body = req_capsule_client_get(&req->rq_pill, &RMF_LLOGD_BODY); if (body == NULL) - RETURN(-EFAULT); + return -EFAULT; ctxt = llog_get_context(req->rq_export->exp_obd, body->lgd_ctxt_idx); if (ctxt == NULL) - RETURN(-ENODEV); + return -ENODEV; disk_obd = ctxt->loc_exp->exp_obd; push_ctxt(&saved, &disk_obd->obd_lvfs_ctxt, NULL); @@ -323,7 +323,7 @@ EXPORT_SYMBOL(llog_origin_handle_read_header); int llog_origin_handle_close(struct ptlrpc_request *req) { /* Nothing to do */ - RETURN(0); + return 0; } EXPORT_SYMBOL(llog_origin_handle_close); @@ -343,13 +343,13 @@ int llog_origin_handle_cancel(struct ptlrpc_request *req) RCL_CLIENT) / sizeof(*logcookies); if (logcookies == NULL || num_cookies == 0) { DEBUG_REQ(D_HA, req, "No llog cookies sent"); - RETURN(-EFAULT); + return -EFAULT; } ctxt = llog_get_context(req->rq_export->exp_obd, logcookies->lgc_subsys); if (ctxt == NULL) - RETURN(-ENODEV); + return -ENODEV; disk_obd = ctxt->loc_exp->exp_obd; push_ctxt(&saved, &disk_obd->obd_lvfs_ctxt, NULL); diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c index 602ce679508b4..bea44a3d4a2f3 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c @@ -612,7 +612,7 @@ static int ptlrpc_lprocfs_nrs_seq_show(struct seq_file *m, void *n) mutex_unlock(&nrs_core.nrs_mutex); - RETURN(rc); + return rc; } /** @@ -696,7 +696,7 @@ static ssize_t ptlrpc_lprocfs_nrs_seq_write(struct file *file, const char *buffe if (cmd_copy) OBD_FREE(cmd_copy, LPROCFS_NRS_WR_MAX_CMD); - RETURN(rc < 0 ? rc : count); + return rc < 0 ? rc : count; } LPROC_SEQ_FOPS(ptlrpc_lprocfs_nrs); @@ -1220,7 +1220,7 @@ int lprocfs_wr_ping(struct file *file, const char *buffer, req = ptlrpc_prep_ping(obd->u.cli.cl_import); LPROCFS_CLIMP_EXIT(obd); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; req->rq_send_state = LUSTRE_IMP_FULL; @@ -1228,8 +1228,8 @@ int lprocfs_wr_ping(struct file *file, const char *buffer, ptlrpc_req_finished(req); if (rc >= 0) - RETURN(count); - RETURN(rc); + return count; + return rc; } EXPORT_SYMBOL(lprocfs_wr_ping); diff --git a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c index b5b5b486edbfe..a0e009717a5ad 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c +++ b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c @@ -75,7 +75,7 @@ static int ptl_send_buf (lnet_handle_md_t *mdh, void *base, int len, if (unlikely(rc != 0)) { CERROR ("LNetMDBind failed: %d\n", rc); LASSERT (rc == -ENOMEM); - RETURN (-ENOMEM); + return -ENOMEM; } CDEBUG(D_NET, "Sending %d bytes to portal %d, xid "LPD64", offset %u\n", @@ -94,7 +94,7 @@ static int ptl_send_buf (lnet_handle_md_t *mdh, void *base, int len, LASSERTF(rc2 == 0, "rc2 = %d\n", rc2); } - RETURN (0); + return 0; } static void mdunlink_iterate_helper(lnet_handle_md_t *bd_mds, int count) @@ -123,7 +123,7 @@ int ptlrpc_register_bulk(struct ptlrpc_request *req) lnet_md_t md; if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_BULK_GET_NET)) - RETURN(0); + return 0; /* NB no locking required until desc is on the network */ LASSERT(desc->bd_nob > 0); @@ -205,7 +205,7 @@ int ptlrpc_register_bulk(struct ptlrpc_request *req) LASSERT(desc->bd_md_count >= 0); mdunlink_iterate_helper(desc->bd_mds, desc->bd_md_max_brw); req->rq_status = -ENOMEM; - RETURN(-ENOMEM); + return -ENOMEM; } /* Set rq_xid to matchbits of the final bulk so that server can @@ -229,7 +229,7 @@ int ptlrpc_register_bulk(struct ptlrpc_request *req) desc->bd_iov_count, desc->bd_nob, desc->bd_last_xid, req->rq_xid, desc->bd_portal); - RETURN(0); + return 0; } EXPORT_SYMBOL(ptlrpc_register_bulk); @@ -254,7 +254,7 @@ int ptlrpc_unregister_bulk(struct ptlrpc_request *req, int async) req->rq_bulk_deadline = cfs_time_current_sec() + LONG_UNLINK; if (ptlrpc_client_bulk_active(req) == 0) /* completed or */ - RETURN(1); /* never registered */ + return 1; /* never registered */ LASSERT(desc->bd_req == req); /* bd_req NULL until registered */ @@ -265,14 +265,14 @@ int ptlrpc_unregister_bulk(struct ptlrpc_request *req, int async) mdunlink_iterate_helper(desc->bd_mds, desc->bd_md_max_brw); if (ptlrpc_client_bulk_active(req) == 0) /* completed or */ - RETURN(1); /* never registered */ + return 1; /* never registered */ /* Move to "Unregistering" phase as bulk was not unlinked yet. */ ptlrpc_rqphase_move(req, RQ_PHASE_UNREGISTERING); /* Do not wait for unlink to finish. */ if (async) - RETURN(0); + return 0; if (req->rq_set != NULL) wq = &req->rq_set->set_waitq; @@ -287,14 +287,14 @@ int ptlrpc_unregister_bulk(struct ptlrpc_request *req, int async) rc = l_wait_event(*wq, !ptlrpc_client_bulk_active(req), &lwi); if (rc == 0) { ptlrpc_rqphase_move(req, req->rq_next_phase); - RETURN(1); + return 1; } LASSERT(rc == -ETIMEDOUT); DEBUG_REQ(D_WARNING, req, "Unexpectedly long timeout: desc %p", desc); } - RETURN(0); + return 0; } EXPORT_SYMBOL(ptlrpc_unregister_bulk); @@ -455,12 +455,12 @@ int ptlrpc_send_error(struct ptlrpc_request *req, int may_be_difficult) int rc; if (req->rq_no_reply) - RETURN(0); + return 0; if (!req->rq_repmsg) { rc = lustre_pack_reply(req, 1, NULL, NULL); if (rc) - RETURN(rc); + return rc; } if (req->rq_status != -ENOSPC && req->rq_status != -EACCES && @@ -469,7 +469,7 @@ int ptlrpc_send_error(struct ptlrpc_request *req, int may_be_difficult) req->rq_type = PTL_RPC_MSG_ERR; rc = ptlrpc_send_reply(req, may_be_difficult); - RETURN(rc); + return rc; } EXPORT_SYMBOL(ptlrpc_send_error); @@ -496,7 +496,7 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply) struct obd_device *obd = request->rq_import->imp_obd; if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_DROP_RPC)) - RETURN(0); + return 0; LASSERT(request->rq_type == PTL_RPC_MSG_REQUEST); LASSERT(request->rq_wait_ctx == 0); @@ -512,7 +512,7 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply) /* this prevents us from waiting in ptlrpc_queue_wait */ request->rq_err = 1; request->rq_status = -ENODEV; - RETURN(-ENODEV); + return -ENODEV; } connection = request->rq_import->imp_connection; diff --git a/drivers/staging/lustre/lustre/ptlrpc/nrs.c b/drivers/staging/lustre/lustre/ptlrpc/nrs.c index 226c9c0880640..0abcd6d822737 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/nrs.c +++ b/drivers/staging/lustre/lustre/ptlrpc/nrs.c @@ -81,11 +81,11 @@ static int nrs_policy_ctl_locked(struct ptlrpc_nrs_policy *policy, * policy->pol_private will be NULL in such a case. */ if (policy->pol_state == NRS_POL_STATE_STOPPED) - RETURN(-ENODEV); + return -ENODEV; - RETURN(policy->pol_desc->pd_ops->op_policy_ctl != NULL ? + return policy->pol_desc->pd_ops->op_policy_ctl != NULL ? policy->pol_desc->pd_ops->op_policy_ctl(policy, opc, arg) : - -ENOSYS); + -ENOSYS; } static void nrs_policy_stop0(struct ptlrpc_nrs_policy *policy) @@ -117,14 +117,14 @@ static int nrs_policy_stop_locked(struct ptlrpc_nrs_policy *policy) struct ptlrpc_nrs *nrs = policy->pol_nrs; if (nrs->nrs_policy_fallback == policy && !nrs->nrs_stopping) - RETURN(-EPERM); + return -EPERM; if (policy->pol_state == NRS_POL_STATE_STARTING) - RETURN(-EAGAIN); + return -EAGAIN; /* In progress or already stopped */ if (policy->pol_state != NRS_POL_STATE_STARTED) - RETURN(0); + return 0; policy->pol_state = NRS_POL_STATE_STOPPING; @@ -141,7 +141,7 @@ static int nrs_policy_stop_locked(struct ptlrpc_nrs_policy *policy) if (policy->pol_ref == 1) nrs_policy_stop0(policy); - RETURN(0); + return 0; } /** @@ -197,12 +197,12 @@ static int nrs_policy_start_locked(struct ptlrpc_nrs_policy *policy) * benefit. */ if (nrs->nrs_policy_starting) - RETURN(-EAGAIN); + return -EAGAIN; LASSERT(policy->pol_state != NRS_POL_STATE_STARTING); if (policy->pol_state == NRS_POL_STATE_STOPPING) - RETURN(-EAGAIN); + return -EAGAIN; if (policy->pol_flags & PTLRPC_NRS_FL_FALLBACK) { /** @@ -213,7 +213,7 @@ static int nrs_policy_start_locked(struct ptlrpc_nrs_policy *policy) */ if (policy == nrs->nrs_policy_fallback) { nrs_policy_stop_primary(nrs); - RETURN(0); + return 0; } /** @@ -228,10 +228,10 @@ static int nrs_policy_start_locked(struct ptlrpc_nrs_policy *policy) * Shouldn't start primary policy if w/o fallback policy. */ if (nrs->nrs_policy_fallback == NULL) - RETURN(-EPERM); + return -EPERM; if (policy->pol_state == NRS_POL_STATE_STARTED) - RETURN(0); + return 0; } /** @@ -243,7 +243,7 @@ static int nrs_policy_start_locked(struct ptlrpc_nrs_policy *policy) atomic_dec(&policy->pol_desc->pd_refs); CERROR("NRS: cannot get module for policy %s; is it alive?\n", policy->pol_desc->pd_name); - RETURN(-ENODEV); + return -ENODEV; } /** @@ -290,7 +290,7 @@ static int nrs_policy_start_locked(struct ptlrpc_nrs_policy *policy) out: nrs->nrs_policy_starting = 0; - RETURN(rc); + return rc; } /** @@ -660,7 +660,7 @@ static int nrs_policy_ctl(struct ptlrpc_nrs *nrs, char *name, spin_unlock(&nrs->nrs_lock); - RETURN(rc); + return rc; } /** @@ -684,7 +684,7 @@ static int nrs_policy_unregister(struct ptlrpc_nrs *nrs, char *name) spin_unlock(&nrs->nrs_lock); CERROR("Can't find NRS policy %s\n", name); - RETURN(-ENOENT); + return -ENOENT; } if (policy->pol_ref > 1) { @@ -693,7 +693,7 @@ static int nrs_policy_unregister(struct ptlrpc_nrs *nrs, char *name) nrs_policy_put_locked(policy); spin_unlock(&nrs->nrs_lock); - RETURN(-EBUSY); + return -EBUSY; } LASSERT(policy->pol_req_queued == 0); @@ -716,7 +716,7 @@ static int nrs_policy_unregister(struct ptlrpc_nrs *nrs, char *name) LASSERT(policy->pol_private == NULL); OBD_FREE_PTR(policy); - RETURN(0); + return 0; } /** @@ -748,7 +748,7 @@ static int nrs_policy_register(struct ptlrpc_nrs *nrs, OBD_CPT_ALLOC_GFP(policy, svcpt->scp_service->srv_cptable, svcpt->scp_cpt, sizeof(*policy), __GFP_IO); if (policy == NULL) - RETURN(-ENOMEM); + return -ENOMEM; policy->pol_nrs = nrs; policy->pol_desc = desc; @@ -761,7 +761,7 @@ static int nrs_policy_register(struct ptlrpc_nrs *nrs, rc = nrs_policy_init(policy); if (rc != 0) { OBD_FREE_PTR(policy); - RETURN(rc); + return rc; } spin_lock(&nrs->nrs_lock); @@ -777,7 +777,7 @@ static int nrs_policy_register(struct ptlrpc_nrs *nrs, nrs_policy_fini(policy); OBD_FREE_PTR(policy); - RETURN(-EEXIST); + return -EEXIST; } list_add_tail(&policy->pol_list, &nrs->nrs_policy_list); @@ -791,7 +791,7 @@ static int nrs_policy_register(struct ptlrpc_nrs *nrs, if (rc != 0) (void) nrs_policy_unregister(nrs, policy->pol_desc->pd_name); - RETURN(rc); + return rc; } /** @@ -893,7 +893,7 @@ static int nrs_register_policies_locked(struct ptlrpc_nrs *nrs) } } - RETURN(rc); + return rc; } /** @@ -931,7 +931,7 @@ static int nrs_svcpt_setup_locked0(struct ptlrpc_nrs *nrs, rc = nrs_register_policies_locked(nrs); - RETURN(rc); + return rc; } /** @@ -974,7 +974,7 @@ static int nrs_svcpt_setup_locked(struct ptlrpc_service_part *svcpt) rc = nrs_svcpt_setup_locked0(nrs, svcpt); out: - RETURN(rc); + return rc; } /** @@ -1031,9 +1031,9 @@ static struct ptlrpc_nrs_pol_desc *nrs_policy_find_desc_locked(const char *name) list_for_each_entry(tmp, &nrs_core.nrs_policies, pd_list) { if (strncmp(tmp->pd_name, name, NRS_POL_NAME_MAX) == 0) - RETURN(tmp); + return tmp; } - RETURN(NULL); + return NULL; } /** @@ -1082,7 +1082,7 @@ static int nrs_policy_unregister_locked(struct ptlrpc_nrs_pol_desc *desc) "partition %d of service %s: %d\n", desc->pd_name, svcpt->scp_cpt, svcpt->scp_service->srv_name, rc); - RETURN(rc); + return rc; } if (!hp && nrs_svc_has_hp(svc)) { @@ -1095,7 +1095,7 @@ static int nrs_policy_unregister_locked(struct ptlrpc_nrs_pol_desc *desc) desc->pd_ops->op_lprocfs_fini(svc); } - RETURN(rc); + return rc; } /** @@ -1145,7 +1145,7 @@ int ptlrpc_nrs_policy_register(struct ptlrpc_nrs_pol_conf *conf) "policy flags; external policies cannot act as fallback " "policies, or be started immediately upon registration " "without interaction with lprocfs\n", conf->nc_name); - RETURN(-EINVAL); + return -EINVAL; } mutex_lock(&nrs_core.nrs_mutex); @@ -1248,7 +1248,7 @@ int ptlrpc_nrs_policy_register(struct ptlrpc_nrs_pol_conf *conf) fail: mutex_unlock(&nrs_core.nrs_mutex); - RETURN(rc); + return rc; } EXPORT_SYMBOL(ptlrpc_nrs_policy_register); @@ -1276,7 +1276,7 @@ int ptlrpc_nrs_policy_unregister(struct ptlrpc_nrs_pol_conf *conf) if (conf->nc_flags & PTLRPC_NRS_FL_FALLBACK) { CERROR("Unable to unregister a fallback policy, unless the " "PTLRPC service is stopping.\n"); - RETURN(-EPERM); + return -EPERM; } conf->nc_name[NRS_POL_NAME_MAX - 1] = '\0'; @@ -1314,7 +1314,7 @@ int ptlrpc_nrs_policy_unregister(struct ptlrpc_nrs_pol_conf *conf) not_exist: mutex_unlock(&nrs_core.nrs_mutex); - RETURN(rc); + return rc; } EXPORT_SYMBOL(ptlrpc_nrs_policy_unregister); @@ -1369,7 +1369,7 @@ int ptlrpc_service_nrs_setup(struct ptlrpc_service *svc) mutex_unlock(&nrs_core.nrs_mutex); - RETURN(rc); + return rc; } /** @@ -1698,7 +1698,7 @@ int ptlrpc_nrs_policy_control(const struct ptlrpc_service *svc, } } out: - RETURN(rc); + return rc; } @@ -1724,7 +1724,7 @@ int ptlrpc_nrs_init(void) GOTO(fail, rc); - RETURN(rc); + return rc; fail: /** * Since no PTLRPC services have been started at this point, all we need @@ -1732,7 +1732,7 @@ int ptlrpc_nrs_init(void) */ ptlrpc_nrs_fini(); - RETURN(rc); + return rc; } /** diff --git a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c index d722c6451cea3..cd2611a3b53d1 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c @@ -341,7 +341,7 @@ int lustre_pack_reply_v2(struct ptlrpc_request *req, int count, msg_len = lustre_msg_size_v2(count, lens); rc = sptlrpc_svc_alloc_rs(req, msg_len); if (rc) - RETURN(rc); + return rc; rs = req->rq_reply_state; atomic_set(&rs->rs_refcount, 1); /* 1 ref for rq_reply_state */ @@ -362,7 +362,7 @@ int lustre_pack_reply_v2(struct ptlrpc_request *req, int count, PTLRPC_RS_DEBUG_LRU_ADD(rs); - RETURN(0); + return 0; } EXPORT_SYMBOL(lustre_pack_reply_v2); @@ -586,12 +586,12 @@ int __lustre_unpack_msg(struct lustre_msg *m, int len) /* can't even look inside the message */ CERROR("message length %d too small for magic/version check\n", len); - RETURN(-EINVAL); + return -EINVAL; } rc = lustre_unpack_msg_v2(m, len); - RETURN(rc); + return rc; } EXPORT_SYMBOL(__lustre_unpack_msg); @@ -1617,7 +1617,7 @@ int do_set_info_async(struct obd_import *imp, req = ptlrpc_request_alloc(imp, &RQF_OBD_SET_INFO); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; req_capsule_set_size(&req->rq_pill, &RMF_SETINFO_KEY, RCL_CLIENT, keylen); @@ -1626,7 +1626,7 @@ int do_set_info_async(struct obd_import *imp, rc = ptlrpc_request_pack(req, version, opcode); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } tmp = req_capsule_client_get(&req->rq_pill, &RMF_SETINFO_KEY); @@ -1644,7 +1644,7 @@ int do_set_info_async(struct obd_import *imp, ptlrpc_req_finished(req); } - RETURN(rc); + return rc; } EXPORT_SYMBOL(do_set_info_async); diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c index 481963df2023e..a9206e955cd35 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c @@ -78,7 +78,7 @@ int ptlrpc_obd_ping(struct obd_device *obd) req = ptlrpc_prep_ping(obd->u.cli.cl_import); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; req->rq_send_state = LUSTRE_IMP_FULL; @@ -86,7 +86,7 @@ int ptlrpc_obd_ping(struct obd_device *obd) ptlrpc_req_finished(req); - RETURN(rc); + return rc; } EXPORT_SYMBOL(ptlrpc_obd_ping); @@ -99,14 +99,14 @@ int ptlrpc_ping(struct obd_import *imp) CERROR("OOM trying to ping %s->%s\n", imp->imp_obd->obd_uuid.uuid, obd2cli_tgt(imp->imp_obd)); - RETURN(-ENOMEM); + return -ENOMEM; } DEBUG_REQ(D_INFO, req, "pinging %s->%s", imp->imp_obd->obd_uuid.uuid, obd2cli_tgt(imp->imp_obd)); ptlrpcd_add_req(req, PDL_POLICY_ROUND, -1); - RETURN(0); + return 0; } void ptlrpc_update_next_ping(struct obd_import *imp, int soon) @@ -374,7 +374,7 @@ int ptlrpc_start_pinger(void) if (!thread_is_init(&pinger_thread) && !thread_is_stopped(&pinger_thread)) - RETURN(-EALREADY); + return -EALREADY; init_waitqueue_head(&pinger_thread.t_ctl_waitq); init_waitqueue_head(&suspend_timeouts_waitq); @@ -387,7 +387,7 @@ int ptlrpc_start_pinger(void) &pinger_thread, pinger_thread.t_name)); if (IS_ERR_VALUE(rc)) { CERROR("cannot start thread: %d\n", rc); - RETURN(rc); + return rc; } l_wait_event(pinger_thread.t_ctl_waitq, thread_is_running(&pinger_thread), &lwi); @@ -399,7 +399,7 @@ int ptlrpc_start_pinger(void) "(Search for the \"suppress_pings\" kernel module " "parameter.)\n"); - RETURN(0); + return 0; } int ptlrpc_pinger_remove_timeouts(void); @@ -411,7 +411,7 @@ int ptlrpc_stop_pinger(void) if (!thread_is_init(&pinger_thread) && !thread_is_stopped(&pinger_thread)) - RETURN(-EALREADY); + return -EALREADY; ptlrpc_pinger_remove_timeouts(); thread_set_flags(&pinger_thread, SVC_STOPPING); @@ -420,7 +420,7 @@ int ptlrpc_stop_pinger(void) l_wait_event(pinger_thread.t_ctl_waitq, thread_is_stopped(&pinger_thread), &lwi); - RETURN(rc); + return rc; } void ptlrpc_pinger_sending_on_import(struct obd_import *imp) @@ -447,7 +447,7 @@ void ptlrpc_pinger_commit_expected(struct obd_import *imp) int ptlrpc_pinger_add_import(struct obd_import *imp) { if (!list_empty(&imp->imp_pinger_chain)) - RETURN(-EALREADY); + return -EALREADY; mutex_lock(&pinger_mutex); CDEBUG(D_HA, "adding pingable import %s->%s\n", @@ -462,14 +462,14 @@ int ptlrpc_pinger_add_import(struct obd_import *imp) ptlrpc_pinger_wake_up(); mutex_unlock(&pinger_mutex); - RETURN(0); + return 0; } EXPORT_SYMBOL(ptlrpc_pinger_add_import); int ptlrpc_pinger_del_import(struct obd_import *imp) { if (list_empty(&imp->imp_pinger_chain)) - RETURN(-ENOENT); + return -ENOENT; mutex_lock(&pinger_mutex); list_del_init(&imp->imp_pinger_chain); @@ -479,7 +479,7 @@ int ptlrpc_pinger_del_import(struct obd_import *imp) imp->imp_obd->obd_no_recov = 1; class_import_put(imp); mutex_unlock(&pinger_mutex); - RETURN(0); + return 0; } EXPORT_SYMBOL(ptlrpc_pinger_del_import); @@ -715,7 +715,7 @@ static int ping_evictor_main(void *arg) } CDEBUG(D_HA, "Exiting Ping Evictor\n"); - RETURN(0); + return 0; } void ping_evictor_start(void) diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c index e8163805e685a..d26fce802b66d 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c @@ -66,11 +66,11 @@ __init int ptlrpc_init(void) rc = req_layout_init(); if (rc) - RETURN(rc); + return rc; rc = ptlrpc_hr_init(); if (rc) - RETURN(rc); + return rc; cleanup_phase = 1; @@ -109,7 +109,7 @@ __init int ptlrpc_init(void) rc = tgt_mod_init(); if (rc) GOTO(cleanup, rc); - RETURN(0); + return 0; cleanup: switch(cleanup_phase) { diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c index 8b654abd8f736..59c4f83af4468 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c @@ -301,7 +301,7 @@ static int ptlrpcd_check(struct lu_env *env, struct ptlrpcd_ctl *pc) * new modules are loaded, i.e., early during boot up. */ CERROR("Failure to refill session: %d\n", rc2); - RETURN(rc); + return rc; } if (atomic_read(&set->set_remaining)) @@ -367,7 +367,7 @@ static int ptlrpcd_check(struct lu_env *env, struct ptlrpcd_ctl *pc) } } - RETURN(rc); + return rc; } /** @@ -408,7 +408,7 @@ static int ptlrpcd(void *arg) complete(&pc->pc_starting); if (rc != 0) - RETURN(rc); + return rc; /* * This mainloop strongly resembles ptlrpc_set_wait() except that our @@ -593,7 +593,7 @@ static int ptlrpcd_bind(int index, int max) } } - RETURN(rc); + return rc; } @@ -608,7 +608,7 @@ int ptlrpcd_start(int index, int max, const char *name, struct ptlrpcd_ctl *pc) if (test_and_set_bit(LIOD_START, &pc->pc_flags)) { CWARN("Starting second thread (%s) for same pc %p\n", name, pc); - RETURN(0); + return 0; } pc->pc_index = index; @@ -659,7 +659,7 @@ int ptlrpcd_start(int index, int max, const char *name, struct ptlrpcd_ctl *pc) clear_bit(LIOD_BIND, &pc->pc_flags); clear_bit(LIOD_START, &pc->pc_flags); } - RETURN(rc); + return rc; } void ptlrpcd_stop(struct ptlrpcd_ctl *pc, int force) @@ -785,7 +785,7 @@ static int ptlrpcd_init(void) ptlrpcds = NULL; } - RETURN(0); + return 0; } int ptlrpcd_addref(void) @@ -796,7 +796,7 @@ int ptlrpcd_addref(void) if (++ptlrpcd_users == 1) rc = ptlrpcd_init(); mutex_unlock(&ptlrpcd_mutex); - RETURN(rc); + return rc; } EXPORT_SYMBOL(ptlrpcd_addref); diff --git a/drivers/staging/lustre/lustre/ptlrpc/recover.c b/drivers/staging/lustre/lustre/ptlrpc/recover.c index 682d97143c343..84c39e083ea4b 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/recover.c +++ b/drivers/staging/lustre/lustre/ptlrpc/recover.c @@ -132,11 +132,11 @@ int ptlrpc_replay_next(struct obd_import *imp, int *inflight) if (rc) { CERROR("recovery replay error %d for req " LPU64"\n", rc, req->rq_xid); - RETURN(rc); + return rc; } *inflight = 1; } - RETURN(rc); + return rc; } /** @@ -156,7 +156,7 @@ int ptlrpc_resend(struct obd_import *imp) spin_lock(&imp->imp_lock); if (imp->imp_state != LUSTRE_IMP_RECOVER) { spin_unlock(&imp->imp_lock); - RETURN(-1); + return -1; } list_for_each_entry_safe(req, next, &imp->imp_sending_list, @@ -169,7 +169,7 @@ int ptlrpc_resend(struct obd_import *imp) } spin_unlock(&imp->imp_lock); - RETURN(0); + return 0; } EXPORT_SYMBOL(ptlrpc_resend); @@ -268,7 +268,7 @@ int ptlrpc_set_import_active(struct obd_import *imp, int active) rc = ptlrpc_recover_import(imp, NULL, 0); } - RETURN(rc); + return rc; } EXPORT_SYMBOL(ptlrpc_set_import_active); diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c b/drivers/staging/lustre/lustre/ptlrpc/sec.c index 82b1c3ac05a43..962b31d163dea 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c @@ -402,7 +402,7 @@ int sptlrpc_req_get_ctx(struct ptlrpc_request *req) rc = import_sec_validate_get(imp, &sec); if (rc) - RETURN(rc); + return rc; req->rq_cli_ctx = get_my_ctx(sec); @@ -410,10 +410,10 @@ int sptlrpc_req_get_ctx(struct ptlrpc_request *req) if (!req->rq_cli_ctx) { CERROR("req %p: fail to get context\n", req); - RETURN(-ENOMEM); + return -ENOMEM; } - RETURN(0); + return 0; } /** @@ -528,7 +528,7 @@ int sptlrpc_req_replace_dead_ctx(struct ptlrpc_request *req) /* restore old ctx */ req->rq_cli_ctx = oldctx; - RETURN(rc); + return rc; } newctx = req->rq_cli_ctx; @@ -555,14 +555,14 @@ int sptlrpc_req_replace_dead_ctx(struct ptlrpc_request *req) /* restore old ctx */ sptlrpc_req_put_ctx(req, 0); req->rq_cli_ctx = oldctx; - RETURN(rc); + return rc; } LASSERT(req->rq_cli_ctx == newctx); } sptlrpc_cli_ctx_put(oldctx, 1); - RETURN(0); + return 0; } EXPORT_SYMBOL(sptlrpc_req_replace_dead_ctx); @@ -638,7 +638,7 @@ int sptlrpc_req_refresh_ctx(struct ptlrpc_request *req, long timeout) LASSERT(ctx); if (req->rq_ctx_init || req->rq_ctx_fini) - RETURN(0); + return 0; /* * during the process a request's context might change type even @@ -648,7 +648,7 @@ int sptlrpc_req_refresh_ctx(struct ptlrpc_request *req, long timeout) again: rc = import_sec_validate_get(req->rq_import, &sec); if (rc) - RETURN(rc); + return rc; if (sec->ps_flvr.sf_rpc != req->rq_flvr.sf_rpc) { CDEBUG(D_SEC, "req %p: flavor has changed %x -> %x\n", @@ -660,7 +660,7 @@ int sptlrpc_req_refresh_ctx(struct ptlrpc_request *req, long timeout) sptlrpc_sec_put(sec); if (cli_ctx_is_eternal(ctx)) - RETURN(0); + return 0; if (unlikely(test_bit(PTLRPC_CTX_NEW_BIT, &ctx->cc_flags))) { LASSERT(ctx->cc_ops->refresh); @@ -671,7 +671,7 @@ int sptlrpc_req_refresh_ctx(struct ptlrpc_request *req, long timeout) LASSERT(ctx->cc_ops->validate); if (ctx->cc_ops->validate(ctx) == 0) { req_off_ctx_list(req, ctx); - RETURN(0); + return 0; } if (unlikely(test_bit(PTLRPC_CTX_ERROR_BIT, &ctx->cc_flags))) { @@ -679,7 +679,7 @@ int sptlrpc_req_refresh_ctx(struct ptlrpc_request *req, long timeout) req->rq_err = 1; spin_unlock(&req->rq_lock); req_off_ctx_list(req, ctx); - RETURN(-EPERM); + return -EPERM; } /* @@ -713,7 +713,7 @@ int sptlrpc_req_refresh_ctx(struct ptlrpc_request *req, long timeout) unlikely(req->rq_reqmsg) && lustre_msg_get_flags(req->rq_reqmsg) & MSG_RESENT) { req_off_ctx_list(req, ctx); - RETURN(0); + return 0; } if (unlikely(test_bit(PTLRPC_CTX_DEAD_BIT, &ctx->cc_flags))) { @@ -725,7 +725,7 @@ int sptlrpc_req_refresh_ctx(struct ptlrpc_request *req, long timeout) spin_lock(&req->rq_lock); req->rq_err = 1; spin_unlock(&req->rq_lock); - RETURN(-EINTR); + return -EINTR; } rc = sptlrpc_req_replace_dead_ctx(req); @@ -736,7 +736,7 @@ int sptlrpc_req_refresh_ctx(struct ptlrpc_request *req, long timeout) spin_lock(&req->rq_lock); req->rq_err = 1; spin_unlock(&req->rq_lock); - RETURN(rc); + return rc; } ctx = req->rq_cli_ctx; @@ -753,7 +753,7 @@ int sptlrpc_req_refresh_ctx(struct ptlrpc_request *req, long timeout) spin_unlock(&ctx->cc_lock); if (timeout < 0) - RETURN(-EWOULDBLOCK); + return -EWOULDBLOCK; /* Clear any flags that may be present from previous sends */ LASSERT(req->rq_receiving_reply == 0); @@ -783,7 +783,7 @@ int sptlrpc_req_refresh_ctx(struct ptlrpc_request *req, long timeout) req_off_ctx_list(req, ctx); LASSERT(rc != 0); - RETURN(rc); + return rc; } goto again; @@ -891,22 +891,22 @@ int sptlrpc_import_check_ctx(struct obd_import *imp) sptlrpc_sec_put(sec); if (!ctx) - RETURN(-ENOMEM); + return -ENOMEM; if (cli_ctx_is_eternal(ctx) || ctx->cc_ops->validate(ctx) == 0) { sptlrpc_cli_ctx_put(ctx, 1); - RETURN(0); + return 0; } if (cli_ctx_is_error(ctx)) { sptlrpc_cli_ctx_put(ctx, 1); - RETURN(-EACCES); + return -EACCES; } OBD_ALLOC_PTR(req); if (!req) - RETURN(-ENOMEM); + return -ENOMEM; spin_lock_init(&req->rq_lock); atomic_set(&req->rq_refcount, 10000); @@ -922,7 +922,7 @@ int sptlrpc_import_check_ctx(struct obd_import *imp) sptlrpc_cli_ctx_put(req->rq_cli_ctx, 1); OBD_FREE_PTR(req); - RETURN(rc); + return rc; } /** @@ -945,7 +945,7 @@ int sptlrpc_cli_wrap_request(struct ptlrpc_request *req) if (req->rq_bulk) { rc = sptlrpc_cli_wrap_bulk(req, req->rq_bulk); if (rc) - RETURN(rc); + return rc; } switch (SPTLRPC_FLVR_SVC(req->rq_flvr.sf_rpc)) { @@ -969,7 +969,7 @@ int sptlrpc_cli_wrap_request(struct ptlrpc_request *req) LASSERT(req->rq_reqdata_len <= req->rq_reqbuf_len); } - RETURN(rc); + return rc; } static int do_cli_unwrap_reply(struct ptlrpc_request *req) @@ -993,13 +993,13 @@ static int do_cli_unwrap_reply(struct ptlrpc_request *req) break; default: CERROR("failed unpack reply: x"LPU64"\n", req->rq_xid); - RETURN(-EPROTO); + return -EPROTO; } if (req->rq_repdata_len < sizeof(struct lustre_msg)) { CERROR("replied data length %d too small\n", req->rq_repdata_len); - RETURN(-EPROTO); + return -EPROTO; } if (SPTLRPC_FLVR_POLICY(req->rq_repdata->lm_secflvr) != @@ -1007,7 +1007,7 @@ static int do_cli_unwrap_reply(struct ptlrpc_request *req) CERROR("reply policy %u doesn't match request policy %u\n", SPTLRPC_FLVR_POLICY(req->rq_repdata->lm_secflvr), SPTLRPC_FLVR_POLICY(req->rq_flvr.sf_rpc)); - RETURN(-EPROTO); + return -EPROTO; } switch (SPTLRPC_FLVR_SVC(req->rq_flvr.sf_rpc)) { @@ -1029,7 +1029,7 @@ static int do_cli_unwrap_reply(struct ptlrpc_request *req) if (SPTLRPC_FLVR_POLICY(req->rq_flvr.sf_rpc) != SPTLRPC_POLICY_NULL && !req->rq_ctx_init) req->rq_rep_swab_mask = 0; - RETURN(rc); + return rc; } /** @@ -1090,7 +1090,7 @@ int sptlrpc_cli_unwrap_early_reply(struct ptlrpc_request *req, OBD_ALLOC_PTR(early_req); if (early_req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; early_size = req->rq_nob_received; early_bufsz = size_roundup_power2(early_size); @@ -1153,7 +1153,7 @@ int sptlrpc_cli_unwrap_early_reply(struct ptlrpc_request *req, LASSERT(early_req->rq_repmsg); *req_ret = early_req; - RETURN(0); + return 0; err_ctx: sptlrpc_cli_ctx_put(early_req->rq_cli_ctx, 1); @@ -1161,7 +1161,7 @@ int sptlrpc_cli_unwrap_early_reply(struct ptlrpc_request *req, OBD_FREE_LARGE(early_buf, early_bufsz); err_req: OBD_FREE_PTR(early_req); - RETURN(rc); + return rc; } /** @@ -1297,7 +1297,7 @@ struct ptlrpc_sec * sptlrpc_sec_create(struct obd_import *imp, policy = sptlrpc_wireflavor2policy(sf->sf_rpc); if (!policy) { CERROR("invalid flavor 0x%x\n", sf->sf_rpc); - RETURN(NULL); + return NULL; } } @@ -1313,7 +1313,7 @@ struct ptlrpc_sec * sptlrpc_sec_create(struct obd_import *imp, sptlrpc_policy_put(policy); } - RETURN(sec); + return sec; } struct ptlrpc_sec *sptlrpc_import_sec_ref(struct obd_import *imp) @@ -1399,7 +1399,7 @@ int sptlrpc_import_sec_adapt(struct obd_import *imp, might_sleep(); if (imp == NULL) - RETURN(0); + return 0; conn = imp->imp_connection; @@ -1473,7 +1473,7 @@ int sptlrpc_import_sec_adapt(struct obd_import *imp, mutex_unlock(&imp->imp_sec_mutex); out: sptlrpc_sec_put(sec); - RETURN(rc); + return rc; } void sptlrpc_import_sec_put(struct obd_import *imp) @@ -1663,10 +1663,10 @@ int sptlrpc_cli_alloc_repbuf(struct ptlrpc_request *req, int msgsize) LASSERT(ctx->cc_sec->ps_policy); if (req->rq_repbuf) - RETURN(0); + return 0; policy = ctx->cc_sec->ps_policy; - RETURN(policy->sp_cops->alloc_repbuf(ctx->cc_sec, req, msgsize)); + return policy->sp_cops->alloc_repbuf(ctx->cc_sec, req, msgsize); } /** @@ -2035,7 +2035,7 @@ int sptlrpc_svc_unwrap_request(struct ptlrpc_request *req) default: CERROR("error unpacking request from %s x"LPU64"\n", libcfs_id2str(req->rq_peer), req->rq_xid); - RETURN(SECSVC_DROP); + return SECSVC_DROP; } req->rq_flvr.sf_rpc = WIRE_FLVR(msg->lm_secflvr); @@ -2046,7 +2046,7 @@ int sptlrpc_svc_unwrap_request(struct ptlrpc_request *req) policy = sptlrpc_wireflavor2policy(req->rq_flvr.sf_rpc); if (!policy) { CERROR("unsupported rpc flavor %x\n", req->rq_flvr.sf_rpc); - RETURN(SECSVC_DROP); + return SECSVC_DROP; } LASSERT(policy->sp_sops->accept); @@ -2064,7 +2064,7 @@ int sptlrpc_svc_unwrap_request(struct ptlrpc_request *req) /* sanity check for the request source */ rc = sptlrpc_svc_check_from(req, rc); - RETURN(rc); + return rc; } /** @@ -2089,7 +2089,7 @@ int sptlrpc_svc_alloc_rs(struct ptlrpc_request *req, int msglen) /* failed alloc, try emergency pool */ rs = lustre_get_emerg_rs(req->rq_rqbd->rqbd_svcpt); if (rs == NULL) - RETURN(-ENOMEM); + return -ENOMEM; req->rq_reply_state = rs; rc = policy->sp_sops->alloc_rs(req, msglen); @@ -2102,7 +2102,7 @@ int sptlrpc_svc_alloc_rs(struct ptlrpc_request *req, int msglen) LASSERT(rc != 0 || (req->rq_reply_state && req->rq_reply_state->rs_msg)); - RETURN(rc); + return rc; } /** @@ -2125,7 +2125,7 @@ int sptlrpc_svc_wrap_reply(struct ptlrpc_request *req) rc = policy->sp_sops->authorize(req); LASSERT(rc || req->rq_reply_state->rs_repdata_len); - RETURN(rc); + return rc; } /** diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_config.c b/drivers/staging/lustre/lustre/ptlrpc/sec_config.c index 665cf1b2171d1..6cc3f23c27ccf 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_config.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_config.c @@ -195,7 +195,7 @@ int sptlrpc_parse_rule(char *param, struct sptlrpc_rule *rule) flavor = strchr(param, '='); if (flavor == NULL) { CERROR("invalid param, no '='\n"); - RETURN(-EINVAL); + return -EINVAL; } *flavor++ = '\0'; @@ -208,7 +208,7 @@ int sptlrpc_parse_rule(char *param, struct sptlrpc_rule *rule) rule->sr_netid = libcfs_str2net(param); if (rule->sr_netid == LNET_NIDNET(LNET_NID_ANY)) { CERROR("invalid network name: %s\n", param); - RETURN(-EINVAL); + return -EINVAL; } } @@ -228,16 +228,16 @@ int sptlrpc_parse_rule(char *param, struct sptlrpc_rule *rule) rule->sr_to = LUSTRE_SP_MDT; } else { CERROR("invalid rule dir segment: %s\n", dir); - RETURN(-EINVAL); + return -EINVAL; } } /* 2.1 flavor */ rc = sptlrpc_parse_flavor(flavor, &rule->sr_flvr); if (rc) - RETURN(-EINVAL); + return -EINVAL; - RETURN(0); + return 0; } EXPORT_SYMBOL(sptlrpc_parse_rule); @@ -665,13 +665,13 @@ static int __sptlrpc_process_config(struct lustre_cfg *lcfg, target = lustre_cfg_string(lcfg, 1); if (target == NULL) { CERROR("missing target name\n"); - RETURN(-EINVAL); + return -EINVAL; } param = lustre_cfg_string(lcfg, 2); if (param == NULL) { CERROR("missing parameter\n"); - RETURN(-EINVAL); + return -EINVAL; } CDEBUG(D_SEC, "processing rule: %s.%s\n", target, param); @@ -679,13 +679,13 @@ static int __sptlrpc_process_config(struct lustre_cfg *lcfg, /* parse rule to make sure the format is correct */ if (strncmp(param, PARAM_SRPC_FLVR, sizeof(PARAM_SRPC_FLVR) - 1) != 0) { CERROR("Invalid sptlrpc parameter: %s\n", param); - RETURN(-EINVAL); + return -EINVAL; } param += sizeof(PARAM_SRPC_FLVR) - 1; rc = sptlrpc_parse_rule(param, &rule); if (rc) - RETURN(-EINVAL); + return -EINVAL; if (conf == NULL) { target2fsname(target, fsname, sizeof(fsname)); @@ -707,7 +707,7 @@ static int __sptlrpc_process_config(struct lustre_cfg *lcfg, if (rc == 0) conf->sc_modified++; - RETURN(rc); + return rc; } int sptlrpc_process_config(struct lustre_cfg *lcfg) @@ -1011,7 +1011,7 @@ int sptlrpc_target_local_copy_conf(struct obd_device *obd, ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT); if (ctxt == NULL) - RETURN(-EINVAL); + return -EINVAL; push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); @@ -1054,7 +1054,7 @@ int sptlrpc_target_local_copy_conf(struct obd_device *obd, llog_ctxt_put(ctxt); CDEBUG(D_SEC, "target %s: write local sptlrpc conf: rc = %d\n", obd->obd_name, rc); - RETURN(rc); + return rc; } static int local_read_handler(const struct lu_env *env, @@ -1067,7 +1067,7 @@ static int local_read_handler(const struct lu_env *env, if (rec->lrh_type != OBD_CFG_REC) { CERROR("unhandled lrh_type: %#x\n", rec->lrh_type); - RETURN(-EINVAL); + return -EINVAL; } cfg_len = rec->lrh_len - sizeof(struct llog_rec_hdr) - @@ -1076,15 +1076,15 @@ static int local_read_handler(const struct lu_env *env, rc = lustre_cfg_sanity_check(lcfg, cfg_len); if (rc) { CERROR("Insane cfg\n"); - RETURN(rc); + return rc; } if (lcfg->lcfg_command != LCFG_SPTLRPC_CONF) { CERROR("invalid command (%x)\n", lcfg->lcfg_command); - RETURN(-EINVAL); + return -EINVAL; } - RETURN(__sptlrpc_process_config(lcfg, conf)); + return __sptlrpc_process_config(lcfg, conf); } static @@ -1101,7 +1101,7 @@ int sptlrpc_target_local_read_conf(struct obd_device *obd, ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT); if (ctxt == NULL) { CERROR("missing llog context\n"); - RETURN(-EINVAL); + return -EINVAL; } push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); @@ -1137,7 +1137,7 @@ int sptlrpc_target_local_read_conf(struct obd_device *obd, llog_ctxt_put(ctxt); CDEBUG(D_SEC, "target %s: read local sptlrpc conf: rc = %d\n", obd->obd_name, rc); - RETURN(rc); + return rc; } @@ -1161,7 +1161,7 @@ int sptlrpc_conf_target_get_rules(struct obd_device *obd, sp_dst = LUSTRE_SP_OST; } else { CERROR("unexpected obd type %s\n", obd->obd_type->typ_name); - RETURN(-EINVAL); + return -EINVAL; } CDEBUG(D_SEC, "get rules for target %s\n", obd->obd_uuid.uuid); @@ -1203,7 +1203,7 @@ int sptlrpc_conf_target_get_rules(struct obd_device *obd, LUSTRE_SP_ANY, sp_dst, rset); out: mutex_unlock(&sptlrpc_conf_lock); - RETURN(rc); + return rc; } EXPORT_SYMBOL(sptlrpc_conf_target_get_rules); diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c index ed33a7fecb467..416401be6d4f7 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c @@ -208,7 +208,7 @@ int plain_ctx_sign(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req) req->rq_reqdata_len = lustre_msg_size_v2(msg->lm_bufcount, msg->lm_buflens); - RETURN(0); + return 0; } static @@ -221,7 +221,7 @@ int plain_ctx_verify(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req) if (msg->lm_bufcount != PLAIN_PACK_SEGMENTS) { CERROR("unexpected reply buf count %u\n", msg->lm_bufcount); - RETURN(-EPROTO); + return -EPROTO; } swabbed = ptlrpc_rep_need_swab(req); @@ -229,24 +229,24 @@ int plain_ctx_verify(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req) phdr = lustre_msg_buf(msg, PLAIN_PACK_HDR_OFF, sizeof(*phdr)); if (phdr == NULL) { CERROR("missing plain header\n"); - RETURN(-EPROTO); + return -EPROTO; } if (phdr->ph_ver != 0) { CERROR("Invalid header version\n"); - RETURN(-EPROTO); + return -EPROTO; } /* expect no user desc in reply */ if (phdr->ph_flags & PLAIN_FL_USER) { CERROR("Unexpected udesc flag in reply\n"); - RETURN(-EPROTO); + return -EPROTO; } if (phdr->ph_bulk_hash_alg != req->rq_flvr.u_bulk.hash.hash_alg) { CERROR("reply bulk flavor %u != %u\n", phdr->ph_bulk_hash_alg, req->rq_flvr.u_bulk.hash.hash_alg); - RETURN(-EPROTO); + return -EPROTO; } if (unlikely(req->rq_early)) { @@ -260,7 +260,7 @@ int plain_ctx_verify(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req) CDEBUG(D_SEC, "early reply checksum mismatch: %08x != %08x\n", cpu_to_le32(cksum), msg->lm_cksum); - RETURN(-EINVAL); + return -EINVAL; } } else { /* whether we sent with bulk or not, we expect the same @@ -270,18 +270,18 @@ int plain_ctx_verify(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req) phdr->ph_flags & PLAIN_FL_BULK)) { CERROR("%s bulk checksum in reply\n", req->rq_pack_bulk ? "Missing" : "Unexpected"); - RETURN(-EPROTO); + return -EPROTO; } if (phdr->ph_flags & PLAIN_FL_BULK) { if (plain_unpack_bsd(msg, swabbed)) - RETURN(-EPROTO); + return -EPROTO; } } req->rq_repmsg = lustre_msg_buf(msg, PLAIN_PACK_MSG_OFF, 0); req->rq_replen = lustre_msg_buflen(msg, PLAIN_PACK_MSG_OFF); - RETURN(0); + return 0; } static @@ -305,10 +305,10 @@ int plain_cli_wrap_bulk(struct ptlrpc_cli_ctx *ctx, bsd->bsd_svc = SPTLRPC_FLVR_BULK_SVC(req->rq_flvr.sf_rpc); if (bsd->bsd_svc == SPTLRPC_BULK_SVC_NULL) - RETURN(0); + return 0; if (req->rq_bulk_read) - RETURN(0); + return 0; rc = plain_generate_bulk_csum(desc, req->rq_flvr.u_bulk.hash.hash_alg, token); @@ -446,7 +446,7 @@ struct ptlrpc_sec *plain_create_sec(struct obd_import *imp, OBD_ALLOC_PTR(plsec); if (plsec == NULL) - RETURN(NULL); + return NULL; /* * initialize plain_sec @@ -471,12 +471,12 @@ struct ptlrpc_sec *plain_create_sec(struct obd_import *imp, ctx = plain_sec_install_ctx(plsec); if (ctx == NULL) { plain_destroy_sec(sec); - RETURN(NULL); + return NULL; } sptlrpc_cli_ctx_put(ctx, 1); } - RETURN(sec); + return sec; } static @@ -496,7 +496,7 @@ struct ptlrpc_cli_ctx *plain_lookup_ctx(struct ptlrpc_sec *sec, if (unlikely(ctx == NULL)) ctx = plain_sec_install_ctx(plsec); - RETURN(ctx); + return ctx; } static @@ -523,7 +523,7 @@ int plain_flush_ctx_cache(struct ptlrpc_sec *sec, /* do nothing unless caller want to flush for 'all' */ if (uid != -1) - RETURN(0); + return 0; write_lock(&plsec->pls_lock); ctx = plsec->pls_ctx; @@ -532,7 +532,7 @@ int plain_flush_ctx_cache(struct ptlrpc_sec *sec, if (ctx) sptlrpc_cli_ctx_put(ctx, 1); - RETURN(0); + return 0; } static @@ -562,7 +562,7 @@ int plain_alloc_reqbuf(struct ptlrpc_sec *sec, alloc_len = size_roundup_power2(alloc_len); OBD_ALLOC_LARGE(req->rq_reqbuf, alloc_len); if (!req->rq_reqbuf) - RETURN(-ENOMEM); + return -ENOMEM; req->rq_reqbuf_len = alloc_len; } else { @@ -577,7 +577,7 @@ int plain_alloc_reqbuf(struct ptlrpc_sec *sec, if (req->rq_pack_udesc) sptlrpc_pack_user_desc(req->rq_reqbuf, PLAIN_PACK_USER_OFF); - RETURN(0); + return 0; } static @@ -616,10 +616,10 @@ int plain_alloc_repbuf(struct ptlrpc_sec *sec, OBD_ALLOC_LARGE(req->rq_repbuf, alloc_len); if (!req->rq_repbuf) - RETURN(-ENOMEM); + return -ENOMEM; req->rq_repbuf_len = alloc_len; - RETURN(0); + return 0; } static @@ -667,7 +667,7 @@ int plain_enlarge_reqbuf(struct ptlrpc_sec *sec, OBD_ALLOC_LARGE(newbuf, newbuf_size); if (newbuf == NULL) - RETURN(-ENOMEM); + return -ENOMEM; memcpy(newbuf, req->rq_reqbuf, req->rq_reqbuf_len); @@ -683,7 +683,7 @@ int plain_enlarge_reqbuf(struct ptlrpc_sec *sec, _sptlrpc_enlarge_msg_inplace(req->rq_reqmsg, segment, newsize); req->rq_reqlen = newmsg_size; - RETURN(0); + return 0; } /**************************************** @@ -710,12 +710,12 @@ int plain_accept(struct ptlrpc_request *req) SPTLRPC_FLVR_BULK_TYPE(req->rq_flvr.sf_rpc) != SPTLRPC_FLVR_BULK_TYPE(SPTLRPC_FLVR_PLAIN)) { CERROR("Invalid rpc flavor %x\n", req->rq_flvr.sf_rpc); - RETURN(SECSVC_DROP); + return SECSVC_DROP; } if (msg->lm_bufcount < PLAIN_PACK_SEGMENTS) { CERROR("unexpected request buf count %u\n", msg->lm_bufcount); - RETURN(SECSVC_DROP); + return SECSVC_DROP; } swabbed = ptlrpc_req_need_swab(req); @@ -723,17 +723,17 @@ int plain_accept(struct ptlrpc_request *req) phdr = lustre_msg_buf(msg, PLAIN_PACK_HDR_OFF, sizeof(*phdr)); if (phdr == NULL) { CERROR("missing plain header\n"); - RETURN(-EPROTO); + return -EPROTO; } if (phdr->ph_ver != 0) { CERROR("Invalid header version\n"); - RETURN(-EPROTO); + return -EPROTO; } if (phdr->ph_bulk_hash_alg >= BULK_HASH_ALG_MAX) { CERROR("invalid hash algorithm: %u\n", phdr->ph_bulk_hash_alg); - RETURN(-EPROTO); + return -EPROTO; } req->rq_sp_from = phdr->ph_sp; @@ -743,7 +743,7 @@ int plain_accept(struct ptlrpc_request *req) if (sptlrpc_unpack_user_desc(msg, PLAIN_PACK_USER_OFF, swabbed)) { CERROR("Mal-formed user descriptor\n"); - RETURN(SECSVC_DROP); + return SECSVC_DROP; } req->rq_pack_udesc = 1; @@ -752,7 +752,7 @@ int plain_accept(struct ptlrpc_request *req) if (phdr->ph_flags & PLAIN_FL_BULK) { if (plain_unpack_bsd(msg, swabbed)) - RETURN(SECSVC_DROP); + return SECSVC_DROP; req->rq_pack_bulk = 1; } @@ -763,7 +763,7 @@ int plain_accept(struct ptlrpc_request *req) req->rq_svc_ctx = &plain_svc_ctx; atomic_inc(&req->rq_svc_ctx->sc_refcount); - RETURN(SECSVC_OK); + return SECSVC_OK; } static @@ -791,7 +791,7 @@ int plain_alloc_rs(struct ptlrpc_request *req, int msgsize) } else { OBD_ALLOC_LARGE(rs, rs_size); if (rs == NULL) - RETURN(-ENOMEM); + return -ENOMEM; rs->rs_size = rs_size; } @@ -805,7 +805,7 @@ int plain_alloc_rs(struct ptlrpc_request *req, int msgsize) rs->rs_msg = lustre_msg_buf_v2(rs->rs_repbuf, PLAIN_PACK_MSG_OFF, 0); req->rq_reply_state = rs; - RETURN(0); + return 0; } static @@ -862,7 +862,7 @@ int plain_authorize(struct ptlrpc_request *req) req->rq_reply_off = 0; } - RETURN(0); + return 0; } static diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index 190c83f170df0..d5628e0fedf7a 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -717,7 +717,7 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf, if (rc != 0) { CERROR("%s: invalid CPT pattern string: %s", conf->psc_name, cconf->cc_pattern); - RETURN(ERR_PTR(-EINVAL)); + return ERR_PTR(-EINVAL); } rc = cfs_expr_list_values(el, ncpts, &cpts); @@ -727,7 +727,7 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf, conf->psc_name, cconf->cc_pattern, rc); if (cpts != NULL) OBD_FREE(cpts, sizeof(*cpts) * ncpts); - RETURN(ERR_PTR(rc < 0 ? rc : -EINVAL)); + return ERR_PTR(rc < 0 ? rc : -EINVAL); } ncpts = rc; } @@ -737,7 +737,7 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf, if (service == NULL) { if (cpts != NULL) OBD_FREE(cpts, sizeof(*cpts) * ncpts); - RETURN(ERR_PTR(-ENOMEM)); + return ERR_PTR(-ENOMEM); } service->srv_cptable = cptable; @@ -816,10 +816,10 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf, GOTO(failed, rc); } - RETURN(service); + return service; failed: ptlrpc_unregister_service(service); - RETURN(ERR_PTR(rc)); + return ERR_PTR(rc); } EXPORT_SYMBOL(ptlrpc_register_service); @@ -1257,7 +1257,7 @@ static int ptlrpc_at_send_early_reply(struct ptlrpc_request *req) at_get(&svcpt->scp_at_estimate), at_extra); if (AT_OFF) - RETURN(0); + return 0; if (olddl < 0) { DEBUG_REQ(D_WARNING, req, "Already past deadline (%+lds), " @@ -1265,13 +1265,13 @@ static int ptlrpc_at_send_early_reply(struct ptlrpc_request *req) "at_early_margin (%d)?", olddl, at_early_margin); /* Return an error so we're not re-added to the timed list. */ - RETURN(-ETIMEDOUT); + return -ETIMEDOUT; } if ((lustre_msghdr_get_flags(req->rq_reqmsg) & MSGHDR_AT_SUPPORT) == 0){ DEBUG_REQ(D_INFO, req, "Wanted to ask client for more time, " "but no AT support"); - RETURN(-ENOSYS); + return -ENOSYS; } if (req->rq_export && @@ -1301,18 +1301,18 @@ static int ptlrpc_at_send_early_reply(struct ptlrpc_request *req) olddl, req->rq_arrival_time.tv_sec + at_get(&svcpt->scp_at_estimate) - cfs_time_current_sec()); - RETURN(-ETIMEDOUT); + return -ETIMEDOUT; } } newdl = cfs_time_current_sec() + at_get(&svcpt->scp_at_estimate); OBD_ALLOC(reqcopy, sizeof *reqcopy); if (reqcopy == NULL) - RETURN(-ENOMEM); + return -ENOMEM; OBD_ALLOC_LARGE(reqmsg, req->rq_reqlen); if (!reqmsg) { OBD_FREE(reqcopy, sizeof *reqcopy); - RETURN(-ENOMEM); + return -ENOMEM; } *reqcopy = *req; @@ -1371,7 +1371,7 @@ static int ptlrpc_at_send_early_reply(struct ptlrpc_request *req) sptlrpc_svc_ctx_decref(reqcopy); OBD_FREE_LARGE(reqmsg, req->rq_reqlen); OBD_FREE(reqcopy, sizeof *reqcopy); - RETURN(rc); + return rc; } /* Send early replies to everybody expiring within at_early_margin @@ -1390,14 +1390,14 @@ static int ptlrpc_at_check_timed(struct ptlrpc_service_part *svcpt) spin_lock(&svcpt->scp_at_lock); if (svcpt->scp_at_check == 0) { spin_unlock(&svcpt->scp_at_lock); - RETURN(0); + return 0; } delay = cfs_time_sub(cfs_time_current(), svcpt->scp_at_checktime); svcpt->scp_at_check = 0; if (array->paa_count == 0) { spin_unlock(&svcpt->scp_at_lock); - RETURN(0); + return 0; } /* The timer went off, but maybe the nearest rpc already completed. */ @@ -1406,7 +1406,7 @@ static int ptlrpc_at_check_timed(struct ptlrpc_service_part *svcpt) /* We've still got plenty of time. Reset the timer. */ ptlrpc_at_set_timer(svcpt); spin_unlock(&svcpt->scp_at_lock); - RETURN(0); + return 0; } /* We're close to a timeout, and we don't know how much longer the @@ -1476,7 +1476,7 @@ static int ptlrpc_at_check_timed(struct ptlrpc_service_part *svcpt) ptlrpc_server_drop_request(rq); } - RETURN(1); /* return "did_something" for liblustre */ + return 1; /* return "did_something" for liblustre */ } /** @@ -1491,7 +1491,7 @@ static int ptlrpc_server_hpreq_init(struct ptlrpc_service_part *svcpt, if (svcpt->scp_service->srv_ops.so_hpreq_handler) { rc = svcpt->scp_service->srv_ops.so_hpreq_handler(req); if (rc < 0) - RETURN(rc); + return rc; LASSERT(rc == 0); } if (req->rq_export && req->rq_ops) { @@ -1512,7 +1512,7 @@ static int ptlrpc_server_hpreq_init(struct ptlrpc_service_part *svcpt, * ost_brw_write(). */ if (rc < 0) - RETURN(rc); + return rc; LASSERT(rc == 0 || rc == 1); } @@ -1524,7 +1524,7 @@ static int ptlrpc_server_hpreq_init(struct ptlrpc_service_part *svcpt, ptlrpc_nrs_req_initialize(svcpt, req, rc); - RETURN(rc); + return rc; } /** Remove the request from the export list. */ @@ -1573,11 +1573,11 @@ static int ptlrpc_server_request_add(struct ptlrpc_service_part *svcpt, rc = ptlrpc_server_hpreq_init(svcpt, req); if (rc < 0) - RETURN(rc); + return rc; ptlrpc_nrs_req_add(svcpt, req, !!rc); - RETURN(0); + return 0; } /** @@ -1703,7 +1703,7 @@ ptlrpc_server_request_get(struct ptlrpc_service_part *svcpt, bool force) } spin_unlock(&svcpt->scp_req_lock); - RETURN(NULL); + return NULL; got_request: svcpt->scp_nreqs_active++; @@ -1715,7 +1715,7 @@ ptlrpc_server_request_get(struct ptlrpc_service_part *svcpt, bool force) if (likely(req->rq_export)) class_export_rpc_inc(req->rq_export); - RETURN(req); + return req; } /** @@ -1736,7 +1736,7 @@ ptlrpc_server_handle_req_in(struct ptlrpc_service_part *svcpt, spin_lock(&svcpt->scp_lock); if (list_empty(&svcpt->scp_req_incoming)) { spin_unlock(&svcpt->scp_lock); - RETURN(0); + return 0; } req = list_entry(svcpt->scp_req_incoming.next, @@ -1855,12 +1855,12 @@ ptlrpc_server_handle_req_in(struct ptlrpc_service_part *svcpt, GOTO(err_req, rc); wake_up(&svcpt->scp_waitq); - RETURN(1); + return 1; err_req: ptlrpc_server_finish_request(svcpt, req); - RETURN(1); + return 1; } /** @@ -1881,7 +1881,7 @@ ptlrpc_server_handle_request(struct ptlrpc_service_part *svcpt, request = ptlrpc_server_request_get(svcpt, false); if (request == NULL) - RETURN(0); + return 0; if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT)) fail_opc = OBD_FAIL_PTLRPC_HPREQ_NOTIMEOUT; @@ -2020,7 +2020,7 @@ ptlrpc_server_handle_request(struct ptlrpc_service_part *svcpt, out_req: ptlrpc_server_finish_active_request(svcpt, request); - RETURN(1); + return 1; } /** @@ -2119,12 +2119,12 @@ ptlrpc_handle_rs(struct ptlrpc_reply_state *rs) if (atomic_dec_and_test(&svcpt->scp_nreps_difficult) && svc->srv_is_stopping) wake_up_all(&svcpt->scp_waitq); - RETURN(1); + return 1; } /* still on the net; callback will schedule */ spin_unlock(&rs->rs_lock); - RETURN(1); + return 1; } @@ -2557,9 +2557,9 @@ static int ptlrpc_start_hr_threads(void) CERROR("Reply handling thread %d:%d Failed on starting: " "rc = %d\n", i, j, rc); ptlrpc_stop_hr_threads(); - RETURN(rc); + return rc; } - RETURN(0); + return 0; } static void ptlrpc_svcpt_stop_threads(struct ptlrpc_service_part *svcpt) @@ -2646,12 +2646,12 @@ int ptlrpc_start_threads(struct ptlrpc_service *svc) } } - RETURN(0); + return 0; failed: CERROR("cannot start %s thread #%d_%d: rc %d\n", svc->srv_thread_name, i, j, rc); ptlrpc_stop_all_threads(svc); - RETURN(rc); + return rc; } EXPORT_SYMBOL(ptlrpc_start_threads); @@ -2672,23 +2672,23 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait) again: if (unlikely(svc->srv_is_stopping)) - RETURN(-ESRCH); + return -ESRCH; if (!ptlrpc_threads_increasable(svcpt) || (OBD_FAIL_CHECK(OBD_FAIL_TGT_TOOMANY_THREADS) && svcpt->scp_nthrs_running == svc->srv_nthrs_cpt_init - 1)) - RETURN(-EMFILE); + return -EMFILE; OBD_CPT_ALLOC_PTR(thread, svc->srv_cptable, svcpt->scp_cpt); if (thread == NULL) - RETURN(-ENOMEM); + return -ENOMEM; init_waitqueue_head(&thread->t_ctl_waitq); spin_lock(&svcpt->scp_lock); if (!ptlrpc_threads_increasable(svcpt)) { spin_unlock(&svcpt->scp_lock); OBD_FREE_PTR(thread); - RETURN(-EMFILE); + return -EMFILE; } if (svcpt->scp_nthrs_starting != 0) { @@ -2706,7 +2706,7 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait) CDEBUG(D_INFO, "Creating thread %s #%d race, retry later\n", svc->srv_thread_name, svcpt->scp_thr_nextid); - RETURN(-EAGAIN); + return -EAGAIN; } svcpt->scp_nthrs_starting++; @@ -2744,18 +2744,18 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait) spin_unlock(&svcpt->scp_lock); OBD_FREE_PTR(thread); } - RETURN(rc); + return rc; } if (!wait) - RETURN(0); + return 0; l_wait_event(thread->t_ctl_waitq, thread_is_running(thread) || thread_is_stopped(thread), &lwi); rc = thread_is_stopped(thread) ? thread->t_id : 0; - RETURN(rc); + return rc; } int ptlrpc_hr_init(void) @@ -2774,7 +2774,7 @@ int ptlrpc_hr_init(void) ptlrpc_hr.hr_partitions = cfs_percpt_alloc(ptlrpc_hr.hr_cpt_table, sizeof(*hrp)); if (ptlrpc_hr.hr_partitions == NULL) - RETURN(-ENOMEM); + return -ENOMEM; init_waitqueue_head(&ptlrpc_hr.hr_waitq); @@ -2811,7 +2811,7 @@ int ptlrpc_hr_init(void) out: if (rc != 0) ptlrpc_hr_fini(); - RETURN(rc); + return rc; } void ptlrpc_hr_fini(void) @@ -3052,7 +3052,7 @@ int ptlrpc_unregister_service(struct ptlrpc_service *service) ptlrpc_service_free(service); - RETURN(0); + return 0; } EXPORT_SYMBOL(ptlrpc_unregister_service); -- GitLab From 2db1f402fa0eb06d0443dc943715dbcdb05fc398 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Fri, 2 Aug 2013 14:45:26 +0530 Subject: [PATCH 457/942] staging: dgnc: Remove duplicate header file inclusion sched.h was included twice. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_proc.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/dgnc/dgnc_proc.c b/drivers/staging/dgnc/dgnc_proc.c index 8fbaf3b38e609..c59c833f5e05a 100644 --- a/drivers/staging/dgnc/dgnc_proc.c +++ b/drivers/staging/dgnc/dgnc_proc.c @@ -39,7 +39,6 @@ #include #include #include -#include /* For in_egroup_p() */ #include #include /* For copy_from_user/copy_to_user */ -- GitLab From 6bd503362c93ac507a98f9dbf53b4e6a9e8f19ab Mon Sep 17 00:00:00 2001 From: Iker Pedrosa Date: Fri, 2 Aug 2013 13:37:56 +0200 Subject: [PATCH 458/942] Staging: winbond: wb35reg: fixed some line over 80 characters Fixed some coding style issues Signed-off-by: Iker Pedrosa Signed-off-by: Greg Kroah-Hartman --- drivers/staging/winbond/wb35reg.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/drivers/staging/winbond/wb35reg.c b/drivers/staging/winbond/wb35reg.c index 9be1b3b004b0b..35d3beb572cf2 100644 --- a/drivers/staging/winbond/wb35reg.c +++ b/drivers/staging/winbond/wb35reg.c @@ -14,7 +14,8 @@ extern void phy_calibration_winbond(struct hw_data *phw_data, u32 frequency); * Flag : AUTO_INCREMENT - RegisterNo will auto increment 4 * NO_INCREMENT - Function will write data into the same register */ -unsigned char Wb35Reg_BurstWrite(struct hw_data *pHwData, u16 RegisterNo, u32 *pRegisterData, u8 NumberOfData, u8 Flag) +unsigned char Wb35Reg_BurstWrite(struct hw_data *pHwData, u16 RegisterNo, + u32 *pRegisterData, u8 NumberOfData, u8 Flag) { struct wb35_reg *reg = &pHwData->reg; struct urb *urb = NULL; @@ -72,7 +73,7 @@ unsigned char Wb35Reg_BurstWrite(struct hw_data *pHwData, u16 RegisterNo, u32 *p return true; } -void Wb35Reg_Update(struct hw_data *pHwData, u16 RegisterNo, u32 RegisterValue) +void Wb35Reg_Update(struct hw_data *pHwData, u16 RegisterNo, u32 RegisterValue) { struct wb35_reg *reg = &pHwData->reg; switch (RegisterNo) { @@ -118,7 +119,8 @@ void Wb35Reg_Update(struct hw_data *pHwData, u16 RegisterNo, u32 RegisterValue * true : read command process successfully * false : register not support */ -unsigned char Wb35Reg_WriteSync(struct hw_data *pHwData, u16 RegisterNo, u32 RegisterValue) +unsigned char Wb35Reg_WriteSync(struct hw_data *pHwData, u16 RegisterNo, + u32 RegisterValue) { struct wb35_reg *reg = &pHwData->reg; int ret = -1; @@ -139,9 +141,10 @@ unsigned char Wb35Reg_WriteSync(struct hw_data *pHwData, u16 RegisterNo, u32 Reg /* Sync IoCallDriver */ reg->EP0vm_state = VM_RUNNING; ret = usb_control_msg(pHwData->udev, - usb_sndctrlpipe(pHwData->udev, 0), - 0x03, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, - 0x0, RegisterNo, &RegisterValue, 4, HZ * 100); + usb_sndctrlpipe(pHwData->udev, 0), + 0x03, + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, + 0x0, RegisterNo, &RegisterValue, 4, HZ * 100); reg->EP0vm_state = VM_STOP; reg->SyncIoPause = 0; @@ -159,7 +162,8 @@ unsigned char Wb35Reg_WriteSync(struct hw_data *pHwData, u16 RegisterNo, u32 Reg * true : read command process successfully * false : register not support */ -unsigned char Wb35Reg_Write(struct hw_data *pHwData, u16 RegisterNo, u32 RegisterValue) +unsigned char Wb35Reg_Write(struct hw_data *pHwData, u16 RegisterNo, + u32 RegisterValue) { struct wb35_reg *reg = &pHwData->reg; struct usb_ctrlrequest *dr; @@ -286,7 +290,8 @@ unsigned char Wb35Reg_WriteWithCallbackValue(struct hw_data *pHwData, * pRegisterValue : It must be a resident buffer due to * asynchronous read register. */ -unsigned char Wb35Reg_ReadSync(struct hw_data *pHwData, u16 RegisterNo, u32 *pRegisterValue) +unsigned char Wb35Reg_ReadSync(struct hw_data *pHwData, u16 RegisterNo, + u32 *pRegisterValue) { struct wb35_reg *reg = &pHwData->reg; u32 *pltmp = pRegisterValue; @@ -305,9 +310,10 @@ unsigned char Wb35Reg_ReadSync(struct hw_data *pHwData, u16 RegisterNo, u32 *pRe reg->EP0vm_state = VM_RUNNING; ret = usb_control_msg(pHwData->udev, - usb_rcvctrlpipe(pHwData->udev, 0), - 0x01, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, - 0x0, RegisterNo, pltmp, 4, HZ * 100); + usb_rcvctrlpipe(pHwData->udev, 0), + 0x01, + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, + 0x0, RegisterNo, pltmp, 4, HZ * 100); *pRegisterValue = cpu_to_le32(*pltmp); @@ -332,7 +338,8 @@ unsigned char Wb35Reg_ReadSync(struct hw_data *pHwData, u16 RegisterNo, u32 *pRe * pRegisterValue : It must be a resident buffer due to * asynchronous read register. */ -unsigned char Wb35Reg_Read(struct hw_data *pHwData, u16 RegisterNo, u32 *pRegisterValue) +unsigned char Wb35Reg_Read(struct hw_data *pHwData, u16 RegisterNo, + u32 *pRegisterValue) { struct wb35_reg *reg = &pHwData->reg; struct usb_ctrlrequest *dr; -- GitLab From 17cd641b9a08535e0cf3891c9830d6e4739ccf02 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Fri, 2 Aug 2013 14:40:12 +0530 Subject: [PATCH 459/942] staging: dgnc: Remove version.h header inclusion in dgnc_cls.c version.h header inclusion is not necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_cls.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/dgnc/dgnc_cls.c b/drivers/staging/dgnc/dgnc_cls.c index 83ded18e4ae23..83c0575ddb475 100644 --- a/drivers/staging/dgnc/dgnc_cls.c +++ b/drivers/staging/dgnc/dgnc_cls.c @@ -32,7 +32,6 @@ */ #include -#include #include /* For jiffies, task states */ #include /* For tasklet and interrupt structs/defines */ #include /* For udelay */ -- GitLab From 02f2dff6b9f240b33e0914e4364a86646fd6cdb6 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Fri, 2 Aug 2013 14:40:13 +0530 Subject: [PATCH 460/942] staging: dgnc: Remove version.h header inclusion in dgnc_driver.h version.h header inclusion is not necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_driver.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/dgnc/dgnc_driver.h b/drivers/staging/dgnc/dgnc_driver.h index 43177f47209bf..334faae506b14 100644 --- a/drivers/staging/dgnc/dgnc_driver.h +++ b/drivers/staging/dgnc/dgnc_driver.h @@ -27,7 +27,6 @@ #ifndef __DGNC_DRIVER_H #define __DGNC_DRIVER_H -#include /* To get the current Linux version */ #include /* To pick up the varions Linux types */ #include /* To pick up the various tty structs/defines */ #include /* For irqreturn_t type */ -- GitLab From c27cdf0a7c298c10a768773cf4839a8450054597 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Fri, 2 Aug 2013 14:40:14 +0530 Subject: [PATCH 461/942] staging: dgnc: Include version.h header in dgnc_kcompat.h version.h header inclusion is necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_kcompat.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/dgnc/dgnc_kcompat.h b/drivers/staging/dgnc/dgnc_kcompat.h index 3f69e1dddcafa..a0f58741cc39a 100644 --- a/drivers/staging/dgnc/dgnc_kcompat.h +++ b/drivers/staging/dgnc/dgnc_kcompat.h @@ -28,6 +28,8 @@ #ifndef __DGNC_KCOMPAT_H #define __DGNC_KCOMPAT_H +#include + # ifndef KERNEL_VERSION # define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) # endif -- GitLab From c397d5ecf59b3c1fb3c66a4254c4ccbbb6520c7c Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Fri, 2 Aug 2013 14:40:15 +0530 Subject: [PATCH 462/942] staging: dgnc: Remove version.h header inclusion in dgnc_mgmt.c version.h header inclusion is not necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_mgmt.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/dgnc/dgnc_mgmt.c b/drivers/staging/dgnc/dgnc_mgmt.c index b8e47920111df..96cf58b31322e 100644 --- a/drivers/staging/dgnc/dgnc_mgmt.c +++ b/drivers/staging/dgnc/dgnc_mgmt.c @@ -38,7 +38,6 @@ * $Id: dgnc_mgmt.c,v 1.2 2010/12/14 20:08:29 markh Exp $ */ #include -#include #include #include /* For jiffies, task states */ #include /* For tasklet and interrupt structs/defines */ -- GitLab From 253085a1e53f6daed43e0d46c3398a6d8ee7740a Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Fri, 2 Aug 2013 14:40:16 +0530 Subject: [PATCH 463/942] staging: dgnc: Remove version.h header inclusion in dgnc_neo.c version.h header inclusion is not necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_neo.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/dgnc/dgnc_neo.c b/drivers/staging/dgnc/dgnc_neo.c index 503db8fae166c..9ac71497edf42 100644 --- a/drivers/staging/dgnc/dgnc_neo.c +++ b/drivers/staging/dgnc/dgnc_neo.c @@ -33,7 +33,6 @@ #include -#include #include /* For jiffies, task states */ #include /* For tasklet and interrupt structs/defines */ #include /* For udelay */ -- GitLab From a111ea2eea27cc7558c398b89479e17343931fce Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Fri, 2 Aug 2013 14:40:17 +0530 Subject: [PATCH 464/942] staging: dgnc: Remove version.h header inclusion in dgnc_sysfs.c version.h header inclusion is not necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_sysfs.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/dgnc/dgnc_sysfs.c b/drivers/staging/dgnc/dgnc_sysfs.c index af49e44382f51..690d451e4821d 100644 --- a/drivers/staging/dgnc/dgnc_sysfs.c +++ b/drivers/staging/dgnc/dgnc_sysfs.c @@ -34,7 +34,6 @@ #include -#include #include #include #include -- GitLab From ee92d533fad362036c90a0de09713c348e6f0436 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Fri, 2 Aug 2013 14:40:18 +0530 Subject: [PATCH 465/942] staging: dgnc: Remove version.h header inclusion in dgnc_trace.c version.h header inclusion is not necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_trace.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/dgnc/dgnc_trace.c b/drivers/staging/dgnc/dgnc_trace.c index ea710e5657987..e613a28cc8204 100644 --- a/drivers/staging/dgnc/dgnc_trace.c +++ b/drivers/staging/dgnc/dgnc_trace.c @@ -32,7 +32,6 @@ /* $Id: dgnc_trace.c,v 1.1.1.1 2009/05/20 12:19:19 markh Exp $ */ #include -#include #include /* For jiffies, task states */ #include /* For tasklet and interrupt structs/defines */ #include -- GitLab From a7f24447d1362353e36f2b1effca538912fbcda8 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sat, 3 Aug 2013 14:00:50 +0800 Subject: [PATCH 466/942] staging: lustre: remove cfs_register_sysctl_table macro It was a wrapper around register_sysctl_table, so just remove it. Cc: Peng Tao Cc: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h | 2 -- .../lustre/include/linux/libcfs/linux/portals_compat25.h | 2 -- drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c | 2 +- drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c | 2 +- drivers/staging/lustre/lnet/lnet/router_proc.c | 2 +- drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c | 2 +- drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c | 2 +- 7 files changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h index e2a6c10ae4e69..029929a4fabcd 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h @@ -79,8 +79,6 @@ typedef struct ctl_table ctl_table_t; typedef struct ctl_table_header ctl_table_header_t; -#define cfs_register_sysctl_table(t, a) register_sysctl_table(t) - #define DECLARE_PROC_HANDLER(name) \ static int \ LL_PROC_PROTO(name) \ diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/portals_compat25.h b/drivers/staging/lustre/include/linux/libcfs/linux/portals_compat25.h index 6cf758dbf9ef4..2bbb4d5c40520 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/portals_compat25.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/portals_compat25.h @@ -104,6 +104,4 @@ int proc_call_handler(void *data, int write, #define cfs_for_each_possible_cpu(cpu) for_each_cpu(cpu) #endif -#define cfs_register_sysctl_table(t, a) register_sysctl_table(t) - #endif /* _PORTALS_COMPAT_H */ diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c index e21028b72302f..92dc5672e2ddf 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c @@ -404,7 +404,7 @@ kiblnd_sysctl_init (void) sizeof(ipif_basename_space)); kiblnd_tunables.kib_sysctl = - cfs_register_sysctl_table(kiblnd_top_ctl_table, 0); + register_sysctl_table(kiblnd_top_ctl_table); if (kiblnd_tunables.kib_sysctl == NULL) CWARN("Can't setup /proc tunables\n"); diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c index 27392d8b3bfef..a1c6a519bf5b7 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c @@ -316,7 +316,7 @@ ksocknal_lib_tunables_init () *ksocknal_tunables.ksnd_zc_recv_min_nfrags = LNET_MAX_IOV; ksocknal_tunables.ksnd_sysctl = - cfs_register_sysctl_table(ksocknal_top_ctl_table, 0); + register_sysctl_table(ksocknal_top_ctl_table); if (ksocknal_tunables.ksnd_sysctl == NULL) CWARN("Can't setup /proc tunables\n"); diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c index 3084b0c75983c..931f6ca25dc72 100644 --- a/drivers/staging/lustre/lnet/lnet/router_proc.c +++ b/drivers/staging/lustre/lnet/lnet/router_proc.c @@ -920,7 +920,7 @@ lnet_proc_init(void) { #ifdef CONFIG_SYSCTL if (lnet_table_header == NULL) - lnet_table_header = cfs_register_sysctl_table(top_table, 0); + lnet_table_header = register_sysctl_table(top_table); #endif } diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c index 80a9fab9b9c19..fc6c977494870 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c @@ -562,7 +562,7 @@ int insert_proc(void) { #ifdef CONFIG_SYSCTL if (lnet_table_header == NULL) - lnet_table_header = cfs_register_sysctl_table(top_table, 0); + lnet_table_header = register_sysctl_table(top_table); #endif return 0; } diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c index c4a740286ad11..acd2619227dfc 100644 --- a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c +++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c @@ -429,7 +429,7 @@ void obd_sysctl_init (void) { #ifdef CONFIG_SYSCTL if ( !obd_table_header ) - obd_table_header = cfs_register_sysctl_table(parent_table, 0); + obd_table_header = register_sysctl_table(parent_table); #endif } -- GitLab From 2b53313a6d49b67e274e929f6ec5f24289bdfa5e Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sat, 3 Aug 2013 14:29:11 +0800 Subject: [PATCH 467/942] staging: lustre: remove almost all crypto layer wrappers Almost all of these are just a straight function name rename, so fix them all up to call the crypto layer properly, no need for a #define to hide things. Cc: Peng Tao Cc: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../lustre/include/linux/lustre_compat25.h | 60 +--------- drivers/staging/lustre/lustre/obdclass/capa.c | 46 ++++++-- .../lustre/lustre/ptlrpc/gss/gss_krb5_mech.c | 107 +++++++++--------- 3 files changed, 91 insertions(+), 122 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h index 6f2707275e5d4..3ea520a8cbcda 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h @@ -100,74 +100,18 @@ static inline void ll_set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt, #endif - /* add a lustre compatible layer for crypto API */ #include -#define ll_crypto_hash crypto_hash -#define ll_crypto_cipher crypto_blkcipher -#define ll_crypto_alloc_hash(name, type, mask) crypto_alloc_hash(name, type, mask) -#define ll_crypto_hash_setkey(tfm, key, keylen) crypto_hash_setkey(tfm, key, keylen) -#define ll_crypto_hash_init(desc) crypto_hash_init(desc) -#define ll_crypto_hash_update(desc, sl, bytes) crypto_hash_update(desc, sl, bytes) -#define ll_crypto_hash_final(desc, out) crypto_hash_final(desc, out) -#define ll_crypto_blkcipher_setkey(tfm, key, keylen) \ - crypto_blkcipher_setkey(tfm, key, keylen) -#define ll_crypto_blkcipher_set_iv(tfm, src, len) \ - crypto_blkcipher_set_iv(tfm, src, len) -#define ll_crypto_blkcipher_get_iv(tfm, dst, len) \ - crypto_blkcipher_get_iv(tfm, dst, len) -#define ll_crypto_blkcipher_encrypt(desc, dst, src, bytes) \ - crypto_blkcipher_encrypt(desc, dst, src, bytes) -#define ll_crypto_blkcipher_decrypt(desc, dst, src, bytes) \ - crypto_blkcipher_decrypt(desc, dst, src, bytes) -#define ll_crypto_blkcipher_encrypt_iv(desc, dst, src, bytes) \ - crypto_blkcipher_encrypt_iv(desc, dst, src, bytes) -#define ll_crypto_blkcipher_decrypt_iv(desc, dst, src, bytes) \ - crypto_blkcipher_decrypt_iv(desc, dst, src, bytes) static inline -struct ll_crypto_cipher *ll_crypto_alloc_blkcipher(const char *name, +struct crypto_blkcipher *ll_crypto_alloc_blkcipher(const char *name, u32 type, u32 mask) { - struct ll_crypto_cipher *rtn = crypto_alloc_blkcipher(name, type, mask); + struct crypto_blkcipher *rtn = crypto_alloc_blkcipher(name, type, mask); return (rtn == NULL ? ERR_PTR(-ENOMEM) : rtn); } -static inline int ll_crypto_hmac(struct ll_crypto_hash *tfm, - u8 *key, unsigned int *keylen, - struct scatterlist *sg, - unsigned int size, u8 *result) -{ - struct hash_desc desc; - int rv; - desc.tfm = tfm; - desc.flags = 0; - rv = crypto_hash_setkey(desc.tfm, key, *keylen); - if (rv) { - CERROR("failed to hash setkey: %d\n", rv); - return rv; - } - return crypto_hash_digest(&desc, sg, size, result); -} -static inline -unsigned int ll_crypto_tfm_alg_max_keysize(struct crypto_blkcipher *tfm) -{ - return crypto_blkcipher_tfm(tfm)->__crt_alg->cra_blkcipher.max_keysize; -} -static inline -unsigned int ll_crypto_tfm_alg_min_keysize(struct crypto_blkcipher *tfm) -{ - return crypto_blkcipher_tfm(tfm)->__crt_alg->cra_blkcipher.min_keysize; -} - -#define ll_crypto_hash_blocksize(tfm) crypto_hash_blocksize(tfm) -#define ll_crypto_hash_digestsize(tfm) crypto_hash_digestsize(tfm) -#define ll_crypto_blkcipher_ivsize(tfm) crypto_blkcipher_ivsize(tfm) -#define ll_crypto_blkcipher_blocksize(tfm) crypto_blkcipher_blocksize(tfm) -#define ll_crypto_free_hash(tfm) crypto_free_hash(tfm) -#define ll_crypto_free_blkcipher(tfm) crypto_free_blkcipher(tfm) - #define ll_vfs_rmdir(dir,entry,mnt) vfs_rmdir(dir,entry) #define ll_vfs_mkdir(inode,dir,mnt,mode) vfs_mkdir(inode,dir,mode) #define ll_vfs_link(old,mnt,dir,new,mnt1) vfs_link(old,dir,new) diff --git a/drivers/staging/lustre/lustre/obdclass/capa.c b/drivers/staging/lustre/lustre/obdclass/capa.c index fe3fa8ec9f24c..8ec1ec9f6a68c 100644 --- a/drivers/staging/lustre/lustre/obdclass/capa.c +++ b/drivers/staging/lustre/lustre/obdclass/capa.c @@ -47,6 +47,7 @@ #include #include #include +#include #include #include @@ -76,6 +77,12 @@ EXPORT_SYMBOL(capa_list); EXPORT_SYMBOL(capa_lock); EXPORT_SYMBOL(capa_count); +static inline +unsigned int ll_crypto_tfm_alg_min_keysize(struct crypto_blkcipher *tfm) +{ + return crypto_blkcipher_tfm(tfm)->__crt_alg->cra_blkcipher.min_keysize; +} + struct hlist_head *init_capa_hash(void) { struct hlist_head *hash; @@ -234,9 +241,26 @@ struct obd_capa *capa_lookup(struct hlist_head *hash, struct lustre_capa *capa, } EXPORT_SYMBOL(capa_lookup); +static inline int ll_crypto_hmac(struct crypto_hash *tfm, + u8 *key, unsigned int *keylen, + struct scatterlist *sg, + unsigned int size, u8 *result) +{ + struct hash_desc desc; + int rv; + desc.tfm = tfm; + desc.flags = 0; + rv = crypto_hash_setkey(desc.tfm, key, *keylen); + if (rv) { + CERROR("failed to hash setkey: %d\n", rv); + return rv; + } + return crypto_hash_digest(&desc, sg, size, result); +} + int capa_hmac(__u8 *hmac, struct lustre_capa *capa, __u8 *key) { - struct ll_crypto_hash *tfm; + struct crypto_hash *tfm; struct capa_hmac_alg *alg; int keylen; struct scatterlist sl; @@ -248,7 +272,7 @@ int capa_hmac(__u8 *hmac, struct lustre_capa *capa, __u8 *key) alg = &capa_hmac_algs[capa_alg(capa)]; - tfm = ll_crypto_alloc_hash(alg->ha_name, 0, 0); + tfm = crypto_alloc_hash(alg->ha_name, 0, 0); if (!tfm) { CERROR("crypto_alloc_tfm failed, check whether your kernel" "has crypto support!\n"); @@ -261,7 +285,7 @@ int capa_hmac(__u8 *hmac, struct lustre_capa *capa, __u8 *key) (unsigned long)(capa) % PAGE_CACHE_SIZE); ll_crypto_hmac(tfm, key, &keylen, &sl, sl.length, hmac); - ll_crypto_free_hash(tfm); + crypto_free_hash(tfm); return 0; } @@ -269,7 +293,7 @@ EXPORT_SYMBOL(capa_hmac); int capa_encrypt_id(__u32 *d, __u32 *s, __u8 *key, int keylen) { - struct ll_crypto_cipher *tfm; + struct crypto_blkcipher *tfm; struct scatterlist sd; struct scatterlist ss; struct blkcipher_desc desc; @@ -291,7 +315,7 @@ int capa_encrypt_id(__u32 *d, __u32 *s, __u8 *key, int keylen) GOTO(out, rc = -EINVAL); } - rc = ll_crypto_blkcipher_setkey(tfm, key, min); + rc = crypto_blkcipher_setkey(tfm, key, min); if (rc) { CERROR("failed to setting key for aes\n"); GOTO(out, rc); @@ -305,21 +329,21 @@ int capa_encrypt_id(__u32 *d, __u32 *s, __u8 *key, int keylen) desc.tfm = tfm; desc.info = NULL; desc.flags = 0; - rc = ll_crypto_blkcipher_encrypt(&desc, &sd, &ss, 16); + rc = crypto_blkcipher_encrypt(&desc, &sd, &ss, 16); if (rc) { CERROR("failed to encrypt for aes\n"); GOTO(out, rc); } out: - ll_crypto_free_blkcipher(tfm); + crypto_free_blkcipher(tfm); return rc; } EXPORT_SYMBOL(capa_encrypt_id); int capa_decrypt_id(__u32 *d, __u32 *s, __u8 *key, int keylen) { - struct ll_crypto_cipher *tfm; + struct crypto_blkcipher *tfm; struct scatterlist sd; struct scatterlist ss; struct blkcipher_desc desc; @@ -341,7 +365,7 @@ int capa_decrypt_id(__u32 *d, __u32 *s, __u8 *key, int keylen) GOTO(out, rc = -EINVAL); } - rc = ll_crypto_blkcipher_setkey(tfm, key, min); + rc = crypto_blkcipher_setkey(tfm, key, min); if (rc) { CERROR("failed to setting key for aes\n"); GOTO(out, rc); @@ -356,14 +380,14 @@ int capa_decrypt_id(__u32 *d, __u32 *s, __u8 *key, int keylen) desc.tfm = tfm; desc.info = NULL; desc.flags = 0; - rc = ll_crypto_blkcipher_decrypt(&desc, &sd, &ss, 16); + rc = crypto_blkcipher_decrypt(&desc, &sd, &ss, 16); if (rc) { CERROR("failed to decrypt for aes\n"); GOTO(out, rc); } out: - ll_crypto_free_blkcipher(tfm); + crypto_free_blkcipher(tfm); return rc; } EXPORT_SYMBOL(capa_decrypt_id); diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_krb5_mech.c b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_krb5_mech.c index 8fa802dd1f909..900efeeee857b 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_krb5_mech.c +++ b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_krb5_mech.c @@ -54,6 +54,7 @@ #include #include #include +#include #include #include @@ -154,7 +155,7 @@ int keyblock_init(struct krb5_keyblock *kb, char *alg_name, int alg_mode) return -1; } - if (ll_crypto_blkcipher_setkey(kb->kb_tfm, kb->kb_key.data, kb->kb_key.len)) { + if (crypto_blkcipher_setkey(kb->kb_tfm, kb->kb_key.data, kb->kb_key.len)) { CERROR("failed to set %s key, len %d\n", alg_name, kb->kb_key.len); return -1; @@ -197,7 +198,7 @@ void keyblock_free(struct krb5_keyblock *kb) { rawobj_free(&kb->kb_key); if (kb->kb_tfm) - ll_crypto_free_blkcipher(kb->kb_tfm); + crypto_free_blkcipher(kb->kb_tfm); } static @@ -529,7 +530,7 @@ void buf_to_sg(struct scatterlist *sg, void *ptr, int len) } static -__u32 krb5_encrypt(struct ll_crypto_cipher *tfm, +__u32 krb5_encrypt(struct crypto_blkcipher *tfm, int decrypt, void * iv, void * in, @@ -546,27 +547,27 @@ __u32 krb5_encrypt(struct ll_crypto_cipher *tfm, desc.info = local_iv; desc.flags= 0; - if (length % ll_crypto_blkcipher_blocksize(tfm) != 0) { + if (length % crypto_blkcipher_blocksize(tfm) != 0) { CERROR("output length %d mismatch blocksize %d\n", - length, ll_crypto_blkcipher_blocksize(tfm)); + length, crypto_blkcipher_blocksize(tfm)); goto out; } - if (ll_crypto_blkcipher_ivsize(tfm) > 16) { - CERROR("iv size too large %d\n", ll_crypto_blkcipher_ivsize(tfm)); + if (crypto_blkcipher_ivsize(tfm) > 16) { + CERROR("iv size too large %d\n", crypto_blkcipher_ivsize(tfm)); goto out; } if (iv) - memcpy(local_iv, iv, ll_crypto_blkcipher_ivsize(tfm)); + memcpy(local_iv, iv, crypto_blkcipher_ivsize(tfm)); memcpy(out, in, length); buf_to_sg(&sg, out, length); if (decrypt) - ret = ll_crypto_blkcipher_decrypt_iv(&desc, &sg, &sg, length); + ret = crypto_blkcipher_decrypt_iv(&desc, &sg, &sg, length); else - ret = ll_crypto_blkcipher_encrypt_iv(&desc, &sg, &sg, length); + ret = crypto_blkcipher_encrypt_iv(&desc, &sg, &sg, length); out: return(ret); @@ -574,7 +575,7 @@ __u32 krb5_encrypt(struct ll_crypto_cipher *tfm, static inline -int krb5_digest_hmac(struct ll_crypto_hash *tfm, +int krb5_digest_hmac(struct crypto_hash *tfm, rawobj_t *key, struct krb5_header *khdr, int msgcnt, rawobj_t *msgs, @@ -585,17 +586,17 @@ int krb5_digest_hmac(struct ll_crypto_hash *tfm, struct scatterlist sg[1]; int i; - ll_crypto_hash_setkey(tfm, key->data, key->len); + crypto_hash_setkey(tfm, key->data, key->len); desc.tfm = tfm; desc.flags= 0; - ll_crypto_hash_init(&desc); + crypto_hash_init(&desc); for (i = 0; i < msgcnt; i++) { if (msgs[i].len == 0) continue; buf_to_sg(sg, (char *) msgs[i].data, msgs[i].len); - ll_crypto_hash_update(&desc, sg, msgs[i].len); + crypto_hash_update(&desc, sg, msgs[i].len); } for (i = 0; i < iovcnt; i++) { @@ -604,20 +605,20 @@ int krb5_digest_hmac(struct ll_crypto_hash *tfm, sg_set_page(&sg[0], iovs[i].kiov_page, iovs[i].kiov_len, iovs[i].kiov_offset); - ll_crypto_hash_update(&desc, sg, iovs[i].kiov_len); + crypto_hash_update(&desc, sg, iovs[i].kiov_len); } if (khdr) { buf_to_sg(sg, (char *) khdr, sizeof(*khdr)); - ll_crypto_hash_update(&desc, sg, sizeof(*khdr)); + crypto_hash_update(&desc, sg, sizeof(*khdr)); } - return ll_crypto_hash_final(&desc, cksum->data); + return crypto_hash_final(&desc, cksum->data); } static inline -int krb5_digest_norm(struct ll_crypto_hash *tfm, +int krb5_digest_norm(struct crypto_hash *tfm, struct krb5_keyblock *kb, struct krb5_header *khdr, int msgcnt, rawobj_t *msgs, @@ -632,13 +633,13 @@ int krb5_digest_norm(struct ll_crypto_hash *tfm, desc.tfm = tfm; desc.flags= 0; - ll_crypto_hash_init(&desc); + crypto_hash_init(&desc); for (i = 0; i < msgcnt; i++) { if (msgs[i].len == 0) continue; buf_to_sg(sg, (char *) msgs[i].data, msgs[i].len); - ll_crypto_hash_update(&desc, sg, msgs[i].len); + crypto_hash_update(&desc, sg, msgs[i].len); } for (i = 0; i < iovcnt; i++) { @@ -647,15 +648,15 @@ int krb5_digest_norm(struct ll_crypto_hash *tfm, sg_set_page(&sg[0], iovs[i].kiov_page, iovs[i].kiov_len, iovs[i].kiov_offset); - ll_crypto_hash_update(&desc, sg, iovs[i].kiov_len); + crypto_hash_update(&desc, sg, iovs[i].kiov_len); } if (khdr) { buf_to_sg(sg, (char *) khdr, sizeof(*khdr)); - ll_crypto_hash_update(&desc, sg, sizeof(*khdr)); + crypto_hash_update(&desc, sg, sizeof(*khdr)); } - ll_crypto_hash_final(&desc, cksum->data); + crypto_hash_final(&desc, cksum->data); return krb5_encrypt(kb->kb_tfm, 0, NULL, cksum->data, cksum->data, cksum->len); @@ -674,7 +675,7 @@ __s32 krb5_make_checksum(__u32 enctype, rawobj_t *cksum) { struct krb5_enctype *ke = &enctypes[enctype]; - struct ll_crypto_hash *tfm; + struct crypto_hash *tfm; __u32 code = GSS_S_FAILURE; int rc; @@ -683,7 +684,7 @@ __s32 krb5_make_checksum(__u32 enctype, return GSS_S_FAILURE; } - cksum->len = ll_crypto_hash_digestsize(tfm); + cksum->len = crypto_hash_digestsize(tfm); OBD_ALLOC_LARGE(cksum->data, cksum->len); if (!cksum->data) { cksum->len = 0; @@ -700,7 +701,7 @@ __s32 krb5_make_checksum(__u32 enctype, if (rc == 0) code = GSS_S_COMPLETE; out_tfm: - ll_crypto_free_hash(tfm); + crypto_free_hash(tfm); return code; } @@ -878,7 +879,7 @@ int add_padding(rawobj_t *msg, int msg_buflen, int blocksize) } static -int krb5_encrypt_rawobjs(struct ll_crypto_cipher *tfm, +int krb5_encrypt_rawobjs(struct crypto_blkcipher *tfm, int mode_ecb, int inobj_cnt, rawobj_t *inobjs, @@ -904,17 +905,17 @@ int krb5_encrypt_rawobjs(struct ll_crypto_cipher *tfm, if (mode_ecb) { if (enc) - rc = ll_crypto_blkcipher_encrypt( + rc = crypto_blkcipher_encrypt( &desc, &dst, &src, src.length); else - rc = ll_crypto_blkcipher_decrypt( + rc = crypto_blkcipher_decrypt( &desc, &dst, &src, src.length); } else { if (enc) - rc = ll_crypto_blkcipher_encrypt_iv( + rc = crypto_blkcipher_encrypt_iv( &desc, &dst, &src, src.length); else - rc = ll_crypto_blkcipher_decrypt_iv( + rc = crypto_blkcipher_decrypt_iv( &desc, &dst, &src, src.length); } @@ -935,7 +936,7 @@ int krb5_encrypt_rawobjs(struct ll_crypto_cipher *tfm, * if adj_nob != 0, we adjust desc->bd_nob to the actual cipher text size. */ static -int krb5_encrypt_bulk(struct ll_crypto_cipher *tfm, +int krb5_encrypt_bulk(struct crypto_blkcipher *tfm, struct krb5_header *khdr, char *confounder, struct ptlrpc_bulk_desc *desc, @@ -950,7 +951,7 @@ int krb5_encrypt_bulk(struct ll_crypto_cipher *tfm, LASSERT(desc->bd_iov_count); LASSERT(desc->bd_enc_iov); - blocksize = ll_crypto_blkcipher_blocksize(tfm); + blocksize = crypto_blkcipher_blocksize(tfm); LASSERT(blocksize > 1); LASSERT(cipher->len == blocksize + sizeof(*khdr)); @@ -962,7 +963,7 @@ int krb5_encrypt_bulk(struct ll_crypto_cipher *tfm, buf_to_sg(&src, confounder, blocksize); buf_to_sg(&dst, cipher->data, blocksize); - rc = ll_crypto_blkcipher_encrypt_iv(&ciph_desc, &dst, &src, blocksize); + rc = crypto_blkcipher_encrypt_iv(&ciph_desc, &dst, &src, blocksize); if (rc) { CERROR("error to encrypt confounder: %d\n", rc); return rc; @@ -982,7 +983,7 @@ int krb5_encrypt_bulk(struct ll_crypto_cipher *tfm, desc->bd_enc_iov[i].kiov_offset = dst.offset; desc->bd_enc_iov[i].kiov_len = dst.length; - rc = ll_crypto_blkcipher_encrypt_iv(&ciph_desc, &dst, &src, + rc = crypto_blkcipher_encrypt_iv(&ciph_desc, &dst, &src, src.length); if (rc) { CERROR("error to encrypt page: %d\n", rc); @@ -994,7 +995,7 @@ int krb5_encrypt_bulk(struct ll_crypto_cipher *tfm, buf_to_sg(&src, khdr, sizeof(*khdr)); buf_to_sg(&dst, cipher->data + blocksize, sizeof(*khdr)); - rc = ll_crypto_blkcipher_encrypt_iv(&ciph_desc, + rc = crypto_blkcipher_encrypt_iv(&ciph_desc, &dst, &src, sizeof(*khdr)); if (rc) { CERROR("error to encrypt krb5 header: %d\n", rc); @@ -1024,7 +1025,7 @@ int krb5_encrypt_bulk(struct ll_crypto_cipher *tfm, * should have been done by prep_bulk(). */ static -int krb5_decrypt_bulk(struct ll_crypto_cipher *tfm, +int krb5_decrypt_bulk(struct crypto_blkcipher *tfm, struct krb5_header *khdr, struct ptlrpc_bulk_desc *desc, rawobj_t *cipher, @@ -1041,7 +1042,7 @@ int krb5_decrypt_bulk(struct ll_crypto_cipher *tfm, LASSERT(desc->bd_enc_iov); LASSERT(desc->bd_nob_transferred); - blocksize = ll_crypto_blkcipher_blocksize(tfm); + blocksize = crypto_blkcipher_blocksize(tfm); LASSERT(blocksize > 1); LASSERT(cipher->len == blocksize + sizeof(*khdr)); @@ -1058,7 +1059,7 @@ int krb5_decrypt_bulk(struct ll_crypto_cipher *tfm, buf_to_sg(&src, cipher->data, blocksize); buf_to_sg(&dst, plain->data, blocksize); - rc = ll_crypto_blkcipher_decrypt_iv(&ciph_desc, &dst, &src, blocksize); + rc = crypto_blkcipher_decrypt_iv(&ciph_desc, &dst, &src, blocksize); if (rc) { CERROR("error to decrypt confounder: %d\n", rc); return rc; @@ -1101,7 +1102,7 @@ int krb5_decrypt_bulk(struct ll_crypto_cipher *tfm, if (desc->bd_iov[i].kiov_len % blocksize == 0) sg_assign_page(&dst, desc->bd_iov[i].kiov_page); - rc = ll_crypto_blkcipher_decrypt_iv(&ciph_desc, &dst, &src, + rc = crypto_blkcipher_decrypt_iv(&ciph_desc, &dst, &src, src.length); if (rc) { CERROR("error to decrypt page: %d\n", rc); @@ -1141,7 +1142,7 @@ int krb5_decrypt_bulk(struct ll_crypto_cipher *tfm, buf_to_sg(&src, cipher->data + blocksize, sizeof(*khdr)); buf_to_sg(&dst, cipher->data + blocksize, sizeof(*khdr)); - rc = ll_crypto_blkcipher_decrypt_iv(&ciph_desc, + rc = crypto_blkcipher_decrypt_iv(&ciph_desc, &dst, &src, sizeof(*khdr)); if (rc) { CERROR("error to decrypt tail: %d\n", rc); @@ -1176,7 +1177,7 @@ __u32 gss_wrap_kerberos(struct gss_ctx *gctx, LASSERT(ke->ke_conf_size <= GSS_MAX_CIPHER_BLOCK); LASSERT(kctx->kc_keye.kb_tfm == NULL || ke->ke_conf_size >= - ll_crypto_blkcipher_blocksize(kctx->kc_keye.kb_tfm)); + crypto_blkcipher_blocksize(kctx->kc_keye.kb_tfm)); /* * final token format: @@ -1200,7 +1201,7 @@ __u32 gss_wrap_kerberos(struct gss_ctx *gctx, blocksize = 1; } else { LASSERT(kctx->kc_keye.kb_tfm); - blocksize = ll_crypto_blkcipher_blocksize(kctx->kc_keye.kb_tfm); + blocksize = crypto_blkcipher_blocksize(kctx->kc_keye.kb_tfm); } LASSERT(blocksize <= ke->ke_conf_size); @@ -1247,7 +1248,7 @@ __u32 gss_wrap_kerberos(struct gss_ctx *gctx, if (kctx->kc_enctype == ENCTYPE_ARCFOUR_HMAC) { rawobj_t arc4_keye; - struct ll_crypto_cipher *arc4_tfm; + struct crypto_blkcipher *arc4_tfm; if (krb5_make_checksum(ENCTYPE_ARCFOUR_HMAC, &kctx->kc_keyi, NULL, 1, &cksum, 0, NULL, &arc4_keye)) { @@ -1261,7 +1262,7 @@ __u32 gss_wrap_kerberos(struct gss_ctx *gctx, GOTO(arc4_out_key, rc = -EACCES); } - if (ll_crypto_blkcipher_setkey(arc4_tfm, arc4_keye.data, + if (crypto_blkcipher_setkey(arc4_tfm, arc4_keye.data, arc4_keye.len)) { CERROR("failed to set arc4 key, len %d\n", arc4_keye.len); @@ -1271,7 +1272,7 @@ __u32 gss_wrap_kerberos(struct gss_ctx *gctx, rc = krb5_encrypt_rawobjs(arc4_tfm, 1, 3, data_desc, &cipher, 1); arc4_out_tfm: - ll_crypto_free_blkcipher(arc4_tfm); + crypto_free_blkcipher(arc4_tfm); arc4_out_key: rawobj_free(&arc4_keye); arc4_out: @@ -1309,7 +1310,7 @@ __u32 gss_prep_bulk_kerberos(struct gss_ctx *gctx, LASSERT(desc->bd_enc_iov); LASSERT(kctx->kc_keye.kb_tfm); - blocksize = ll_crypto_blkcipher_blocksize(kctx->kc_keye.kb_tfm); + blocksize = crypto_blkcipher_blocksize(kctx->kc_keye.kb_tfm); for (i = 0; i < desc->bd_iov_count; i++) { LASSERT(desc->bd_enc_iov[i].kiov_page); @@ -1370,7 +1371,7 @@ __u32 gss_wrap_bulk_kerberos(struct gss_ctx *gctx, blocksize = 1; } else { LASSERT(kctx->kc_keye.kb_tfm); - blocksize = ll_crypto_blkcipher_blocksize(kctx->kc_keye.kb_tfm); + blocksize = crypto_blkcipher_blocksize(kctx->kc_keye.kb_tfm); } /* @@ -1480,7 +1481,7 @@ __u32 gss_unwrap_kerberos(struct gss_ctx *gctx, blocksize = 1; } else { LASSERT(kctx->kc_keye.kb_tfm); - blocksize = ll_crypto_blkcipher_blocksize(kctx->kc_keye.kb_tfm); + blocksize = crypto_blkcipher_blocksize(kctx->kc_keye.kb_tfm); } /* expected token layout: @@ -1520,7 +1521,7 @@ __u32 gss_unwrap_kerberos(struct gss_ctx *gctx, if (kctx->kc_enctype == ENCTYPE_ARCFOUR_HMAC) { rawobj_t arc4_keye; - struct ll_crypto_cipher *arc4_tfm; + struct crypto_blkcipher *arc4_tfm; cksum.data = token->data + token->len - ke->ke_hash_size; cksum.len = ke->ke_hash_size; @@ -1537,7 +1538,7 @@ __u32 gss_unwrap_kerberos(struct gss_ctx *gctx, GOTO(arc4_out_key, rc = -EACCES); } - if (ll_crypto_blkcipher_setkey(arc4_tfm, + if (crypto_blkcipher_setkey(arc4_tfm, arc4_keye.data, arc4_keye.len)) { CERROR("failed to set arc4 key, len %d\n", arc4_keye.len); @@ -1547,7 +1548,7 @@ __u32 gss_unwrap_kerberos(struct gss_ctx *gctx, rc = krb5_encrypt_rawobjs(arc4_tfm, 1, 1, &cipher_in, &plain_out, 0); arc4_out_tfm: - ll_crypto_free_blkcipher(arc4_tfm); + crypto_free_blkcipher(arc4_tfm); arc4_out_key: rawobj_free(&arc4_keye); arc4_out: @@ -1646,7 +1647,7 @@ __u32 gss_unwrap_bulk_kerberos(struct gss_ctx *gctx, LBUG(); } else { LASSERT(kctx->kc_keye.kb_tfm); - blocksize = ll_crypto_blkcipher_blocksize(kctx->kc_keye.kb_tfm); + blocksize = crypto_blkcipher_blocksize(kctx->kc_keye.kb_tfm); } LASSERT(sizeof(*khdr) >= blocksize && sizeof(*khdr) % blocksize == 0); -- GitLab From 36e607a16b8def1b184d48a4489b716d6dbe3379 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sat, 3 Aug 2013 14:44:31 +0800 Subject: [PATCH 468/942] staging: lustre: remove ll_crypto_alloc_blkcipher Turns out that the ll_crypto_alloc_blkcipher() wrapper didn't even do anything, and is probably wrong, so it's not needed, just call the crypto core directly. Cc: Peng Tao Cc: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/include/linux/lustre_compat25.h | 13 ------------- drivers/staging/lustre/lustre/obdclass/capa.c | 4 ++-- .../lustre/lustre/ptlrpc/gss/gss_krb5_mech.c | 6 +++--- 3 files changed, 5 insertions(+), 18 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h index 3ea520a8cbcda..089f358b6b2eb 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h @@ -99,19 +99,6 @@ static inline void ll_set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt, #define FS_HAS_FIEMAP (0) #endif - -/* add a lustre compatible layer for crypto API */ -#include - -static inline -struct crypto_blkcipher *ll_crypto_alloc_blkcipher(const char *name, - u32 type, u32 mask) -{ - struct crypto_blkcipher *rtn = crypto_alloc_blkcipher(name, type, mask); - - return (rtn == NULL ? ERR_PTR(-ENOMEM) : rtn); -} - #define ll_vfs_rmdir(dir,entry,mnt) vfs_rmdir(dir,entry) #define ll_vfs_mkdir(inode,dir,mnt,mode) vfs_mkdir(inode,dir,mode) #define ll_vfs_link(old,mnt,dir,new,mnt1) vfs_link(old,dir,new) diff --git a/drivers/staging/lustre/lustre/obdclass/capa.c b/drivers/staging/lustre/lustre/obdclass/capa.c index 8ec1ec9f6a68c..68d797ba8ae45 100644 --- a/drivers/staging/lustre/lustre/obdclass/capa.c +++ b/drivers/staging/lustre/lustre/obdclass/capa.c @@ -303,7 +303,7 @@ int capa_encrypt_id(__u32 *d, __u32 *s, __u8 *key, int keylen) /* passing "aes" in a variable instead of a constant string keeps gcc * 4.3.2 happy */ - tfm = ll_crypto_alloc_blkcipher(alg, 0, 0 ); + tfm = crypto_alloc_blkcipher(alg, 0, 0 ); if (IS_ERR(tfm)) { CERROR("failed to load transform for aes\n"); return PTR_ERR(tfm); @@ -353,7 +353,7 @@ int capa_decrypt_id(__u32 *d, __u32 *s, __u8 *key, int keylen) /* passing "aes" in a variable instead of a constant string keeps gcc * 4.3.2 happy */ - tfm = ll_crypto_alloc_blkcipher(alg, 0, 0 ); + tfm = crypto_alloc_blkcipher(alg, 0, 0 ); if (IS_ERR(tfm)) { CERROR("failed to load transform for aes\n"); return PTR_ERR(tfm); diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_krb5_mech.c b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_krb5_mech.c index 900efeeee857b..c106a9e049a75 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_krb5_mech.c +++ b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_krb5_mech.c @@ -148,7 +148,7 @@ static const char * enctype2str(__u32 enctype) static int keyblock_init(struct krb5_keyblock *kb, char *alg_name, int alg_mode) { - kb->kb_tfm = ll_crypto_alloc_blkcipher(alg_name, alg_mode, 0); + kb->kb_tfm = crypto_alloc_blkcipher(alg_name, alg_mode, 0); if (IS_ERR(kb->kb_tfm)) { CERROR("failed to alloc tfm: %s, mode %d\n", alg_name, alg_mode); @@ -1256,7 +1256,7 @@ __u32 gss_wrap_kerberos(struct gss_ctx *gctx, GOTO(arc4_out, rc = -EACCES); } - arc4_tfm = ll_crypto_alloc_blkcipher("ecb(arc4)", 0, 0); + arc4_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, 0); if (IS_ERR(arc4_tfm)) { CERROR("failed to alloc tfm arc4 in ECB mode\n"); GOTO(arc4_out_key, rc = -EACCES); @@ -1532,7 +1532,7 @@ __u32 gss_unwrap_kerberos(struct gss_ctx *gctx, GOTO(arc4_out, rc = -EACCES); } - arc4_tfm = ll_crypto_alloc_blkcipher("ecb(arc4)", 0, 0); + arc4_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, 0); if (IS_ERR(arc4_tfm)) { CERROR("failed to alloc tfm arc4 in ECB mode\n"); GOTO(arc4_out_key, rc = -EACCES); -- GitLab From 23cde4d65cc7d11e2048d2b240cdf13927ac50d0 Mon Sep 17 00:00:00 2001 From: Denis CIOCCA Date: Wed, 19 Jun 2013 09:28:00 +0100 Subject: [PATCH 469/942] iio: Added ST-sensors platform data to select the DRDY interrupt pin This patch add support to redirect the DRDY interrupt on INT1 or INT2 on accelerometer and pressure sensors. Signed-off-by: Denis Ciocca Signed-off-by: Jonathan Cameron --- drivers/iio/accel/st_accel.h | 11 ++++- drivers/iio/accel/st_accel_core.c | 27 ++++++++---- drivers/iio/accel/st_accel_i2c.c | 2 +- drivers/iio/accel/st_accel_spi.c | 2 +- .../iio/common/st_sensors/st_sensors_core.c | 41 ++++++++++++++++--- drivers/iio/gyro/st_gyro.h | 11 ++++- drivers/iio/gyro/st_gyro_core.c | 13 +++--- drivers/iio/gyro/st_gyro_i2c.c | 3 +- drivers/iio/gyro/st_gyro_spi.c | 3 +- drivers/iio/magnetometer/st_magn.h | 3 +- drivers/iio/magnetometer/st_magn_core.c | 5 ++- drivers/iio/magnetometer/st_magn_i2c.c | 2 +- drivers/iio/magnetometer/st_magn_spi.c | 2 +- drivers/iio/pressure/st_pressure.h | 11 ++++- drivers/iio/pressure/st_pressure_core.c | 15 +++++-- drivers/iio/pressure/st_pressure_i2c.c | 2 +- drivers/iio/pressure/st_pressure_spi.c | 2 +- include/linux/iio/common/st_sensors.h | 14 +++++-- .../linux/platform_data/st_sensors_pdata.h | 24 +++++++++++ 19 files changed, 153 insertions(+), 40 deletions(-) create mode 100644 include/linux/platform_data/st_sensors_pdata.h diff --git a/drivers/iio/accel/st_accel.h b/drivers/iio/accel/st_accel.h index 37949b94377db..c3877630b2e4c 100644 --- a/drivers/iio/accel/st_accel.h +++ b/drivers/iio/accel/st_accel.h @@ -25,7 +25,16 @@ #define LSM303DLM_ACCEL_DEV_NAME "lsm303dlm_accel" #define LSM330_ACCEL_DEV_NAME "lsm330_accel" -int st_accel_common_probe(struct iio_dev *indio_dev); +/** +* struct st_sensors_platform_data - default accel platform data +* @drdy_int_pin: default accel DRDY is available on INT1 pin. +*/ +static const struct st_sensors_platform_data default_accel_pdata = { + .drdy_int_pin = 1, +}; + +int st_accel_common_probe(struct iio_dev *indio_dev, + struct st_sensors_platform_data *pdata); void st_accel_common_remove(struct iio_dev *indio_dev); #ifdef CONFIG_IIO_BUFFER diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c index 4aec121261d7b..aef3c9be73665 100644 --- a/drivers/iio/accel/st_accel_core.c +++ b/drivers/iio/accel/st_accel_core.c @@ -65,7 +65,8 @@ #define ST_ACCEL_1_BDU_ADDR 0x23 #define ST_ACCEL_1_BDU_MASK 0x80 #define ST_ACCEL_1_DRDY_IRQ_ADDR 0x22 -#define ST_ACCEL_1_DRDY_IRQ_MASK 0x10 +#define ST_ACCEL_1_DRDY_IRQ_INT1_MASK 0x10 +#define ST_ACCEL_1_DRDY_IRQ_INT2_MASK 0x08 #define ST_ACCEL_1_MULTIREAD_BIT true /* CUSTOM VALUES FOR SENSOR 2 */ @@ -89,7 +90,8 @@ #define ST_ACCEL_2_BDU_ADDR 0x23 #define ST_ACCEL_2_BDU_MASK 0x80 #define ST_ACCEL_2_DRDY_IRQ_ADDR 0x22 -#define ST_ACCEL_2_DRDY_IRQ_MASK 0x02 +#define ST_ACCEL_2_DRDY_IRQ_INT1_MASK 0x02 +#define ST_ACCEL_2_DRDY_IRQ_INT2_MASK 0x10 #define ST_ACCEL_2_MULTIREAD_BIT true /* CUSTOM VALUES FOR SENSOR 3 */ @@ -121,7 +123,8 @@ #define ST_ACCEL_3_BDU_ADDR 0x20 #define ST_ACCEL_3_BDU_MASK 0x08 #define ST_ACCEL_3_DRDY_IRQ_ADDR 0x23 -#define ST_ACCEL_3_DRDY_IRQ_MASK 0x80 +#define ST_ACCEL_3_DRDY_IRQ_INT1_MASK 0x80 +#define ST_ACCEL_3_DRDY_IRQ_INT2_MASK 0x00 #define ST_ACCEL_3_IG1_EN_ADDR 0x23 #define ST_ACCEL_3_IG1_EN_MASK 0x08 #define ST_ACCEL_3_MULTIREAD_BIT false @@ -224,7 +227,8 @@ static const struct st_sensors st_accel_sensors[] = { }, .drdy_irq = { .addr = ST_ACCEL_1_DRDY_IRQ_ADDR, - .mask = ST_ACCEL_1_DRDY_IRQ_MASK, + .mask_int1 = ST_ACCEL_1_DRDY_IRQ_INT1_MASK, + .mask_int2 = ST_ACCEL_1_DRDY_IRQ_INT2_MASK, }, .multi_read_bit = ST_ACCEL_1_MULTIREAD_BIT, .bootime = 2, @@ -285,7 +289,8 @@ static const struct st_sensors st_accel_sensors[] = { }, .drdy_irq = { .addr = ST_ACCEL_2_DRDY_IRQ_ADDR, - .mask = ST_ACCEL_2_DRDY_IRQ_MASK, + .mask_int1 = ST_ACCEL_2_DRDY_IRQ_INT1_MASK, + .mask_int2 = ST_ACCEL_2_DRDY_IRQ_INT2_MASK, }, .multi_read_bit = ST_ACCEL_2_MULTIREAD_BIT, .bootime = 2, @@ -358,7 +363,8 @@ static const struct st_sensors st_accel_sensors[] = { }, .drdy_irq = { .addr = ST_ACCEL_3_DRDY_IRQ_ADDR, - .mask = ST_ACCEL_3_DRDY_IRQ_MASK, + .mask_int1 = ST_ACCEL_3_DRDY_IRQ_INT1_MASK, + .mask_int2 = ST_ACCEL_3_DRDY_IRQ_INT2_MASK, .ig1 = { .en_addr = ST_ACCEL_3_IG1_EN_ADDR, .en_mask = ST_ACCEL_3_IG1_EN_MASK, @@ -443,7 +449,8 @@ static const struct iio_trigger_ops st_accel_trigger_ops = { #define ST_ACCEL_TRIGGER_OPS NULL #endif -int st_accel_common_probe(struct iio_dev *indio_dev) +int st_accel_common_probe(struct iio_dev *indio_dev, + struct st_sensors_platform_data *plat_data) { int err; struct st_sensor_data *adata = iio_priv(indio_dev); @@ -465,7 +472,11 @@ int st_accel_common_probe(struct iio_dev *indio_dev) &adata->sensor->fs.fs_avl[0]; adata->odr = adata->sensor->odr.odr_avl[0].hz; - err = st_sensors_init_sensor(indio_dev); + if (!plat_data) + plat_data = + (struct st_sensors_platform_data *)&default_accel_pdata; + + err = st_sensors_init_sensor(indio_dev, plat_data); if (err < 0) goto st_accel_common_probe_error; diff --git a/drivers/iio/accel/st_accel_i2c.c b/drivers/iio/accel/st_accel_i2c.c index ffc9d097e484b..58d164d90dca1 100644 --- a/drivers/iio/accel/st_accel_i2c.c +++ b/drivers/iio/accel/st_accel_i2c.c @@ -36,7 +36,7 @@ static int st_accel_i2c_probe(struct i2c_client *client, st_sensors_i2c_configure(indio_dev, client, adata); - err = st_accel_common_probe(indio_dev); + err = st_accel_common_probe(indio_dev, client->dev.platform_data); if (err < 0) goto st_accel_common_probe_error; diff --git a/drivers/iio/accel/st_accel_spi.c b/drivers/iio/accel/st_accel_spi.c index 22b35bfea7d2b..21ed9296311fc 100644 --- a/drivers/iio/accel/st_accel_spi.c +++ b/drivers/iio/accel/st_accel_spi.c @@ -35,7 +35,7 @@ static int st_accel_spi_probe(struct spi_device *spi) st_sensors_spi_configure(indio_dev, spi, adata); - err = st_accel_common_probe(indio_dev); + err = st_accel_common_probe(indio_dev, spi->dev.platform_data); if (err < 0) goto st_accel_common_probe_error; diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c index 865b1781df660..965ee22d3ac80 100644 --- a/drivers/iio/common/st_sensors/st_sensors_core.c +++ b/drivers/iio/common/st_sensors/st_sensors_core.c @@ -22,7 +22,7 @@ static inline u32 st_sensors_get_unaligned_le24(const u8 *p) { - return ((s32)((p[0] | p[1] << 8 | p[2] << 16) << 8) >> 8); + return (s32)((p[0] | p[1] << 8 | p[2] << 16) << 8) >> 8; } static int st_sensors_write_data_with_mask(struct iio_dev *indio_dev, @@ -118,7 +118,7 @@ static int st_sensors_match_fs(struct st_sensors *sensor, } static int st_sensors_set_fullscale(struct iio_dev *indio_dev, - unsigned int fs) + unsigned int fs) { int err, i = 0; struct st_sensor_data *sdata = iio_priv(indio_dev); @@ -198,13 +198,39 @@ int st_sensors_set_axis_enable(struct iio_dev *indio_dev, u8 axis_enable) } EXPORT_SYMBOL(st_sensors_set_axis_enable); -int st_sensors_init_sensor(struct iio_dev *indio_dev) +int st_sensors_init_sensor(struct iio_dev *indio_dev, + struct st_sensors_platform_data *pdata) { int err; struct st_sensor_data *sdata = iio_priv(indio_dev); mutex_init(&sdata->tb.buf_lock); + switch (pdata->drdy_int_pin) { + case 1: + if (sdata->sensor->drdy_irq.mask_int1 == 0) { + dev_err(&indio_dev->dev, + "DRDY on INT1 not available.\n"); + err = -EINVAL; + goto init_error; + } + sdata->drdy_int_pin = 1; + break; + case 2: + if (sdata->sensor->drdy_irq.mask_int2 == 0) { + dev_err(&indio_dev->dev, + "DRDY on INT2 not available.\n"); + err = -EINVAL; + goto init_error; + } + sdata->drdy_int_pin = 2; + break; + default: + dev_err(&indio_dev->dev, "DRDY on pdata not valid.\n"); + err = -EINVAL; + goto init_error; + } + err = st_sensors_set_enable(indio_dev, false); if (err < 0) goto init_error; @@ -234,6 +260,7 @@ EXPORT_SYMBOL(st_sensors_init_sensor); int st_sensors_set_dataready_irq(struct iio_dev *indio_dev, bool enable) { int err; + u8 drdy_mask; struct st_sensor_data *sdata = iio_priv(indio_dev); /* Enable/Disable the interrupt generator 1. */ @@ -245,10 +272,14 @@ int st_sensors_set_dataready_irq(struct iio_dev *indio_dev, bool enable) goto st_accel_set_dataready_irq_error; } + if (sdata->drdy_int_pin == 1) + drdy_mask = sdata->sensor->drdy_irq.mask_int1; + else + drdy_mask = sdata->sensor->drdy_irq.mask_int2; + /* Enable/Disable the interrupt generator for data ready. */ err = st_sensors_write_data_with_mask(indio_dev, - sdata->sensor->drdy_irq.addr, - sdata->sensor->drdy_irq.mask, (int)enable); + sdata->sensor->drdy_irq.addr, drdy_mask, (int)enable); st_accel_set_dataready_irq_error: return err; diff --git a/drivers/iio/gyro/st_gyro.h b/drivers/iio/gyro/st_gyro.h index 3ad9907bb154d..f8f2bf84a5a28 100644 --- a/drivers/iio/gyro/st_gyro.h +++ b/drivers/iio/gyro/st_gyro.h @@ -23,7 +23,16 @@ #define L3G4IS_GYRO_DEV_NAME "l3g4is_ui" #define LSM330_GYRO_DEV_NAME "lsm330_gyro" -int st_gyro_common_probe(struct iio_dev *indio_dev); +/** + * struct st_sensors_platform_data - gyro platform data + * @drdy_int_pin: DRDY on gyros is available only on INT2 pin. + */ +static const struct st_sensors_platform_data gyro_pdata = { + .drdy_int_pin = 2, +}; + +int st_gyro_common_probe(struct iio_dev *indio_dev, + struct st_sensors_platform_data *pdata); void st_gyro_common_remove(struct iio_dev *indio_dev); #ifdef CONFIG_IIO_BUFFER diff --git a/drivers/iio/gyro/st_gyro_core.c b/drivers/iio/gyro/st_gyro_core.c index f9ed3488c3145..85fa8d343bb28 100644 --- a/drivers/iio/gyro/st_gyro_core.c +++ b/drivers/iio/gyro/st_gyro_core.c @@ -60,7 +60,7 @@ #define ST_GYRO_1_BDU_ADDR 0x23 #define ST_GYRO_1_BDU_MASK 0x80 #define ST_GYRO_1_DRDY_IRQ_ADDR 0x22 -#define ST_GYRO_1_DRDY_IRQ_MASK 0x08 +#define ST_GYRO_1_DRDY_IRQ_INT2_MASK 0x08 #define ST_GYRO_1_MULTIREAD_BIT true /* CUSTOM VALUES FOR SENSOR 2 */ @@ -84,7 +84,7 @@ #define ST_GYRO_2_BDU_ADDR 0x23 #define ST_GYRO_2_BDU_MASK 0x80 #define ST_GYRO_2_DRDY_IRQ_ADDR 0x22 -#define ST_GYRO_2_DRDY_IRQ_MASK 0x08 +#define ST_GYRO_2_DRDY_IRQ_INT2_MASK 0x08 #define ST_GYRO_2_MULTIREAD_BIT true static const struct iio_chan_spec st_gyro_16bit_channels[] = { @@ -158,7 +158,7 @@ static const struct st_sensors st_gyro_sensors[] = { }, .drdy_irq = { .addr = ST_GYRO_1_DRDY_IRQ_ADDR, - .mask = ST_GYRO_1_DRDY_IRQ_MASK, + .mask_int2 = ST_GYRO_1_DRDY_IRQ_INT2_MASK, }, .multi_read_bit = ST_GYRO_1_MULTIREAD_BIT, .bootime = 2, @@ -221,7 +221,7 @@ static const struct st_sensors st_gyro_sensors[] = { }, .drdy_irq = { .addr = ST_GYRO_2_DRDY_IRQ_ADDR, - .mask = ST_GYRO_2_DRDY_IRQ_MASK, + .mask_int2 = ST_GYRO_2_DRDY_IRQ_INT2_MASK, }, .multi_read_bit = ST_GYRO_2_MULTIREAD_BIT, .bootime = 2, @@ -302,7 +302,8 @@ static const struct iio_trigger_ops st_gyro_trigger_ops = { #define ST_GYRO_TRIGGER_OPS NULL #endif -int st_gyro_common_probe(struct iio_dev *indio_dev) +int st_gyro_common_probe(struct iio_dev *indio_dev, + struct st_sensors_platform_data *pdata) { int err; struct st_sensor_data *gdata = iio_priv(indio_dev); @@ -324,7 +325,7 @@ int st_gyro_common_probe(struct iio_dev *indio_dev) &gdata->sensor->fs.fs_avl[0]; gdata->odr = gdata->sensor->odr.odr_avl[0].hz; - err = st_sensors_init_sensor(indio_dev); + err = st_sensors_init_sensor(indio_dev, pdata); if (err < 0) goto st_gyro_common_probe_error; diff --git a/drivers/iio/gyro/st_gyro_i2c.c b/drivers/iio/gyro/st_gyro_i2c.c index 8a310500573d9..c7a29a4d7e829 100644 --- a/drivers/iio/gyro/st_gyro_i2c.c +++ b/drivers/iio/gyro/st_gyro_i2c.c @@ -36,7 +36,8 @@ static int st_gyro_i2c_probe(struct i2c_client *client, st_sensors_i2c_configure(indio_dev, client, gdata); - err = st_gyro_common_probe(indio_dev); + err = st_gyro_common_probe(indio_dev, + (struct st_sensors_platform_data *)&gyro_pdata); if (err < 0) goto st_gyro_common_probe_error; diff --git a/drivers/iio/gyro/st_gyro_spi.c b/drivers/iio/gyro/st_gyro_spi.c index f3540390eb220..14b0762847f5b 100644 --- a/drivers/iio/gyro/st_gyro_spi.c +++ b/drivers/iio/gyro/st_gyro_spi.c @@ -35,7 +35,8 @@ static int st_gyro_spi_probe(struct spi_device *spi) st_sensors_spi_configure(indio_dev, spi, gdata); - err = st_gyro_common_probe(indio_dev); + err = st_gyro_common_probe(indio_dev, + (struct st_sensors_platform_data *)&gyro_pdata); if (err < 0) goto st_gyro_common_probe_error; diff --git a/drivers/iio/magnetometer/st_magn.h b/drivers/iio/magnetometer/st_magn.h index 7e81d00ef0c3d..694e33e0fb722 100644 --- a/drivers/iio/magnetometer/st_magn.h +++ b/drivers/iio/magnetometer/st_magn.h @@ -18,7 +18,8 @@ #define LSM303DLM_MAGN_DEV_NAME "lsm303dlm_magn" #define LIS3MDL_MAGN_DEV_NAME "lis3mdl" -int st_magn_common_probe(struct iio_dev *indio_dev); +int st_magn_common_probe(struct iio_dev *indio_dev, + struct st_sensors_platform_data *pdata); void st_magn_common_remove(struct iio_dev *indio_dev); #ifdef CONFIG_IIO_BUFFER diff --git a/drivers/iio/magnetometer/st_magn_core.c b/drivers/iio/magnetometer/st_magn_core.c index ebfe8f11a0c26..7cd784f522e55 100644 --- a/drivers/iio/magnetometer/st_magn_core.c +++ b/drivers/iio/magnetometer/st_magn_core.c @@ -345,7 +345,8 @@ static const struct iio_info magn_info = { .write_raw = &st_magn_write_raw, }; -int st_magn_common_probe(struct iio_dev *indio_dev) +int st_magn_common_probe(struct iio_dev *indio_dev, + struct st_sensors_platform_data *pdata) { int err; struct st_sensor_data *mdata = iio_priv(indio_dev); @@ -367,7 +368,7 @@ int st_magn_common_probe(struct iio_dev *indio_dev) &mdata->sensor->fs.fs_avl[0]; mdata->odr = mdata->sensor->odr.odr_avl[0].hz; - err = st_sensors_init_sensor(indio_dev); + err = st_sensors_init_sensor(indio_dev, pdata); if (err < 0) goto st_magn_common_probe_error; diff --git a/drivers/iio/magnetometer/st_magn_i2c.c b/drivers/iio/magnetometer/st_magn_i2c.c index e6adc4a864251..1bed117714c58 100644 --- a/drivers/iio/magnetometer/st_magn_i2c.c +++ b/drivers/iio/magnetometer/st_magn_i2c.c @@ -36,7 +36,7 @@ static int st_magn_i2c_probe(struct i2c_client *client, st_sensors_i2c_configure(indio_dev, client, mdata); - err = st_magn_common_probe(indio_dev); + err = st_magn_common_probe(indio_dev, NULL); if (err < 0) goto st_magn_common_probe_error; diff --git a/drivers/iio/magnetometer/st_magn_spi.c b/drivers/iio/magnetometer/st_magn_spi.c index 51adb797cb7d7..a2333a1e6061d 100644 --- a/drivers/iio/magnetometer/st_magn_spi.c +++ b/drivers/iio/magnetometer/st_magn_spi.c @@ -35,7 +35,7 @@ static int st_magn_spi_probe(struct spi_device *spi) st_sensors_spi_configure(indio_dev, spi, mdata); - err = st_magn_common_probe(indio_dev); + err = st_magn_common_probe(indio_dev, NULL); if (err < 0) goto st_magn_common_probe_error; diff --git a/drivers/iio/pressure/st_pressure.h b/drivers/iio/pressure/st_pressure.h index 414e45ac9b9b4..b0b630688da66 100644 --- a/drivers/iio/pressure/st_pressure.h +++ b/drivers/iio/pressure/st_pressure.h @@ -16,7 +16,16 @@ #define LPS331AP_PRESS_DEV_NAME "lps331ap" -int st_press_common_probe(struct iio_dev *indio_dev); +/** + * struct st_sensors_platform_data - default press platform data + * @drdy_int_pin: default press DRDY is available on INT1 pin. + */ +static const struct st_sensors_platform_data default_press_pdata = { + .drdy_int_pin = 1, +}; + +int st_press_common_probe(struct iio_dev *indio_dev, + struct st_sensors_platform_data *pdata); void st_press_common_remove(struct iio_dev *indio_dev); #ifdef CONFIG_IIO_BUFFER diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c index 3ffbc56917b48..81e2d5b030a60 100644 --- a/drivers/iio/pressure/st_pressure_core.c +++ b/drivers/iio/pressure/st_pressure_core.c @@ -58,7 +58,8 @@ #define ST_PRESS_1_BDU_ADDR 0x20 #define ST_PRESS_1_BDU_MASK 0x04 #define ST_PRESS_1_DRDY_IRQ_ADDR 0x22 -#define ST_PRESS_1_DRDY_IRQ_MASK 0x04 +#define ST_PRESS_1_DRDY_IRQ_INT1_MASK 0x04 +#define ST_PRESS_1_DRDY_IRQ_INT2_MASK 0x20 #define ST_PRESS_1_MULTIREAD_BIT true #define ST_PRESS_1_TEMP_OFFSET 42500 @@ -116,7 +117,8 @@ static const struct st_sensors st_press_sensors[] = { }, .drdy_irq = { .addr = ST_PRESS_1_DRDY_IRQ_ADDR, - .mask = ST_PRESS_1_DRDY_IRQ_MASK, + .mask_int1 = ST_PRESS_1_DRDY_IRQ_INT1_MASK, + .mask_int2 = ST_PRESS_1_DRDY_IRQ_INT2_MASK, }, .multi_read_bit = ST_PRESS_1_MULTIREAD_BIT, .bootime = 2, @@ -202,7 +204,8 @@ static const struct iio_trigger_ops st_press_trigger_ops = { #define ST_PRESS_TRIGGER_OPS NULL #endif -int st_press_common_probe(struct iio_dev *indio_dev) +int st_press_common_probe(struct iio_dev *indio_dev, + struct st_sensors_platform_data *plat_data) { int err; struct st_sensor_data *pdata = iio_priv(indio_dev); @@ -224,7 +227,11 @@ int st_press_common_probe(struct iio_dev *indio_dev) &pdata->sensor->fs.fs_avl[0]; pdata->odr = pdata->sensor->odr.odr_avl[0].hz; - err = st_sensors_init_sensor(indio_dev); + if (!plat_data) + plat_data = + (struct st_sensors_platform_data *)&default_press_pdata; + + err = st_sensors_init_sensor(indio_dev, plat_data); if (err < 0) goto st_press_common_probe_error; diff --git a/drivers/iio/pressure/st_pressure_i2c.c b/drivers/iio/pressure/st_pressure_i2c.c index 7cebcc73bfb09..306599307a962 100644 --- a/drivers/iio/pressure/st_pressure_i2c.c +++ b/drivers/iio/pressure/st_pressure_i2c.c @@ -36,7 +36,7 @@ static int st_press_i2c_probe(struct i2c_client *client, st_sensors_i2c_configure(indio_dev, client, pdata); - err = st_press_common_probe(indio_dev); + err = st_press_common_probe(indio_dev, client->dev.platform_data); if (err < 0) goto st_press_common_probe_error; diff --git a/drivers/iio/pressure/st_pressure_spi.c b/drivers/iio/pressure/st_pressure_spi.c index 17a14907940a2..b2aded6d2108d 100644 --- a/drivers/iio/pressure/st_pressure_spi.c +++ b/drivers/iio/pressure/st_pressure_spi.c @@ -35,7 +35,7 @@ static int st_press_spi_probe(struct spi_device *spi) st_sensors_spi_configure(indio_dev, spi, pdata); - err = st_press_common_probe(indio_dev); + err = st_press_common_probe(indio_dev, spi->dev.platform_data); if (err < 0) goto st_press_common_probe_error; diff --git a/include/linux/iio/common/st_sensors.h b/include/linux/iio/common/st_sensors.h index 72b26940730d7..e51f65480ea5a 100644 --- a/include/linux/iio/common/st_sensors.h +++ b/include/linux/iio/common/st_sensors.h @@ -17,6 +17,8 @@ #include #include +#include + #define ST_SENSORS_TX_MAX_LENGTH 2 #define ST_SENSORS_RX_MAX_LENGTH 6 @@ -118,14 +120,16 @@ struct st_sensor_bdu { /** * struct st_sensor_data_ready_irq - ST sensor device data-ready interrupt * @addr: address of the register. - * @mask: mask to write the on/off value. + * @mask_int1: mask to enable/disable IRQ on INT1 pin. + * @mask_int2: mask to enable/disable IRQ on INT2 pin. * struct ig1 - represents the Interrupt Generator 1 of sensors. * @en_addr: address of the enable ig1 register. * @en_mask: mask to write the on/off value for enable. */ struct st_sensor_data_ready_irq { u8 addr; - u8 mask; + u8 mask_int1; + u8 mask_int2; struct { u8 en_addr; u8 en_mask; @@ -201,6 +205,7 @@ struct st_sensors { * @buffer_data: Data used by buffer part. * @odr: Output data rate of the sensor [Hz]. * num_data_channels: Number of data channels used in buffer. + * @drdy_int_pin: Redirect DRDY on pin 1 (1) or pin 2 (2). * @get_irq_data_ready: Function to get the IRQ used for data ready signal. * @tf: Transfer function structure used by I/O operations. * @tb: Transfer buffers and mutex used by I/O operations. @@ -219,6 +224,8 @@ struct st_sensor_data { unsigned int odr; unsigned int num_data_channels; + u8 drdy_int_pin; + unsigned int (*get_irq_data_ready) (struct iio_dev *indio_dev); const struct st_sensor_transfer_function *tf; @@ -249,7 +256,8 @@ static inline void st_sensors_deallocate_trigger(struct iio_dev *indio_dev) } #endif -int st_sensors_init_sensor(struct iio_dev *indio_dev); +int st_sensors_init_sensor(struct iio_dev *indio_dev, + struct st_sensors_platform_data *pdata); int st_sensors_set_enable(struct iio_dev *indio_dev, bool enable); diff --git a/include/linux/platform_data/st_sensors_pdata.h b/include/linux/platform_data/st_sensors_pdata.h new file mode 100644 index 0000000000000..753839187ba0c --- /dev/null +++ b/include/linux/platform_data/st_sensors_pdata.h @@ -0,0 +1,24 @@ +/* + * STMicroelectronics sensors platform-data driver + * + * Copyright 2013 STMicroelectronics Inc. + * + * Denis Ciocca + * + * Licensed under the GPL-2. + */ + +#ifndef ST_SENSORS_PDATA_H +#define ST_SENSORS_PDATA_H + +/** + * struct st_sensors_platform_data - Platform data for the ST sensors + * @drdy_int_pin: Redirect DRDY on pin 1 (1) or pin 2 (2). + * Available only for accelerometer and pressure sensors. + * Accelerometer DRDY on LSM330 available only on pin 1 (see datasheet). + */ +struct st_sensors_platform_data { + u8 drdy_int_pin; +}; + +#endif /* ST_SENSORS_PDATA_H */ -- GitLab From 71866079dd90528f814c84918635be2096b78915 Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Sun, 23 Jun 2013 22:28:00 +0100 Subject: [PATCH 470/942] iio: fix typos in dac Kconfig Signed-off-by: Peter Meerwald Acked-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/iio/dac/Kconfig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iio/dac/Kconfig b/drivers/iio/dac/Kconfig index c9c33ce32d3a7..b9fd4c7bfd982 100644 --- a/drivers/iio/dac/Kconfig +++ b/drivers/iio/dac/Kconfig @@ -15,7 +15,7 @@ config AD5064 module will be called ad5064. config AD5360 - tristate "Analog Devices Analog Devices AD5360/61/62/63/70/71/73 DAC driver" + tristate "Analog Devices AD5360/61/62/63/70/71/73 DAC driver" depends on SPI help Say yes here to build support for Analog Devices AD5360, AD5361, @@ -68,7 +68,7 @@ config AD5446 module will be called ad5446. config AD5449 - tristate "Analog Device AD5449 and similar DACs driver" + tristate "Analog Devices AD5449 and similar DACs driver" depends on SPI_MASTER help Say yes here to build support for Analog Devices AD5415, AD5426, AD5429, @@ -131,7 +131,7 @@ config AD5686 module will be called ad5686. config AD7303 - tristate "Analog Devices Analog Devices AD7303 DAC driver" + tristate "Analog Devices AD7303 DAC driver" depends on SPI help Say yes here to build support for Analog Devices AD7303 Digital to Analog -- GitLab From 2ffdcd3dec720c6213b52f3fd8f5681e2d015cdf Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Sun, 23 Jun 2013 22:28:00 +0100 Subject: [PATCH 471/942] iio: use I2C_FUNC_SMBUS_I2C_BLOCK macro I do not see why the driver requires I2C_FUNC_SMBUS_I2C_BLOCK, actually only single bytes or words are transferred Signed-off-by: Peter Meerwald Cc: Ge Gao Signed-off-by: Jonathan Cameron --- drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c index fe4c61e219f38..6a1ff803862ca 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c @@ -663,8 +663,8 @@ static int inv_mpu_probe(struct i2c_client *client, int result; if (!i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_READ_I2C_BLOCK | - I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)) { + I2C_FUNC_SMBUS_I2C_BLOCK)) { + result = -ENOSYS; goto out_no_free; } -- GitLab From 93232cd56433c7495084b103b989c6ae7bdb203e Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Sun, 23 Jun 2013 22:28:00 +0100 Subject: [PATCH 472/942] iio: fix Kconfig typos Signed-off-by: Peter Meerwald Signed-off-by: Jonathan Cameron --- drivers/iio/Kconfig | 2 +- drivers/iio/pressure/Kconfig | 8 ++++---- drivers/iio/trigger/Kconfig | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/iio/Kconfig b/drivers/iio/Kconfig index 9af763a90d933..be8e303789af2 100644 --- a/drivers/iio/Kconfig +++ b/drivers/iio/Kconfig @@ -23,7 +23,7 @@ if IIO_BUFFER config IIO_BUFFER_CB boolean "IIO callback buffer used for push in-kernel interfaces" help - Should be selected by any drivers that do-inkernel push + Should be selected by any drivers that do in-kernel push usage. That is, those where the data is pushed to the consumer. config IIO_KFIFO_BUF diff --git a/drivers/iio/pressure/Kconfig b/drivers/iio/pressure/Kconfig index 9427f01e1499b..3cba7f551ebe5 100644 --- a/drivers/iio/pressure/Kconfig +++ b/drivers/iio/pressure/Kconfig @@ -1,18 +1,18 @@ # # Pressure drivers # -menu "Pressure Sensors" +menu "Pressure sensors" config IIO_ST_PRESS - tristate "STMicroelectronics pressures Driver" + tristate "STMicroelectronics pressure sensor Driver" depends on (I2C || SPI_MASTER) && SYSFS select IIO_ST_SENSORS_CORE select IIO_ST_PRESS_I2C if (I2C) select IIO_ST_PRESS_SPI if (SPI_MASTER) select IIO_TRIGGERED_BUFFER if (IIO_BUFFER) help - Say yes here to build support for STMicroelectronics pressures: - LPS331AP. + Say yes here to build support for STMicroelectronics pressure + sensors: LPS331AP. This driver can also be built as a module. If so, will be created these modules: diff --git a/drivers/iio/trigger/Kconfig b/drivers/iio/trigger/Kconfig index 360fd508b088c..0a4a5164963f6 100644 --- a/drivers/iio/trigger/Kconfig +++ b/drivers/iio/trigger/Kconfig @@ -17,7 +17,7 @@ config IIO_SYSFS_TRIGGER depends on SYSFS select IRQ_WORK help - Provides support for using SYSFS entry as IIO triggers. + Provides support for using SYSFS entries as IIO triggers. If unsure, say N (but it's safe to say "Y"). To compile this driver as a module, choose M here: the -- GitLab From 1b2bbe3e662950fb60ce2683d5511ec4e369424f Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Sun, 23 Jun 2013 22:28:00 +0100 Subject: [PATCH 473/942] iio: remove mention of ring buffer from CONFIG_IIO_KFIFO_BUF, CONFIG_IIO_TRIGGER description ring buffers are only in staging, don't mention them here Signed-off-by: Peter Meerwald Signed-off-by: Jonathan Cameron --- drivers/iio/Kconfig | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/iio/Kconfig b/drivers/iio/Kconfig index be8e303789af2..524380c9ae6cb 100644 --- a/drivers/iio/Kconfig +++ b/drivers/iio/Kconfig @@ -30,8 +30,7 @@ config IIO_KFIFO_BUF select IIO_TRIGGER tristate "Industrial I/O buffering based on kfifo" help - A simple fifo based on kfifo. Use this if you want a fifo - rather than a ring buffer. Note that this currently provides + A simple fifo based on kfifo. Note that this currently provides no buffer events so it is up to userspace to work out how often to read from the buffer. @@ -49,7 +48,7 @@ config IIO_TRIGGER help Provides IIO core support for triggers. Currently these are used to initialize capture of samples to push into - ring buffers. The triggers are effectively a 'capture + buffers. The triggers are effectively a 'capture data now' interrupt. config IIO_CONSUMERS_PER_TRIGGER -- GitLab From 341673f1412cda87bcccb66f6ac4f01861657122 Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Sun, 23 Jun 2013 22:28:00 +0100 Subject: [PATCH 474/942] iio: reword help text of several IIO_ST drivers Signed-off-by: Peter Meerwald Acked-by: "Denis Ciocca" Signed-off-by: Jonathan Cameron --- drivers/iio/accel/Kconfig | 4 ++-- drivers/iio/gyro/Kconfig | 4 ++-- drivers/iio/magnetometer/Kconfig | 4 ++-- drivers/iio/pressure/Kconfig | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/iio/accel/Kconfig b/drivers/iio/accel/Kconfig index 719d83fe51dd0..a00267525b661 100644 --- a/drivers/iio/accel/Kconfig +++ b/drivers/iio/accel/Kconfig @@ -33,8 +33,8 @@ config IIO_ST_ACCEL_3AXIS LSM303DLH, LSM303DLHC, LIS3DH, LSM330D, LSM330DL, LSM330DLC, LIS331DLH, LSM303DL, LSM303DLM, LSM330. - This driver can also be built as a module. If so, will be created - these modules: + This driver can also be built as a module. If so, these modules + will be created: - st_accel (core functions for the driver [it is mandatory]); - st_accel_i2c (necessary for the I2C devices [optional*]); - st_accel_spi (necessary for the SPI devices [optional*]); diff --git a/drivers/iio/gyro/Kconfig b/drivers/iio/gyro/Kconfig index 8498e9dcda685..1fdcc8451fdf0 100644 --- a/drivers/iio/gyro/Kconfig +++ b/drivers/iio/gyro/Kconfig @@ -58,8 +58,8 @@ config IIO_ST_GYRO_3AXIS Say yes here to build support for STMicroelectronics gyroscopes: L3G4200D, LSM330DL, L3GD20, L3GD20H, LSM330DLC, L3G4IS, LSM330. - This driver can also be built as a module. If so, will be created - these modules: + This driver can also be built as a module. If so, these modules + will be created: - st_gyro (core functions for the driver [it is mandatory]); - st_gyro_i2c (necessary for the I2C devices [optional*]); - st_gyro_spi (necessary for the SPI devices [optional*]); diff --git a/drivers/iio/magnetometer/Kconfig b/drivers/iio/magnetometer/Kconfig index c332b0ae4a3b8..4d55b1b851b31 100644 --- a/drivers/iio/magnetometer/Kconfig +++ b/drivers/iio/magnetometer/Kconfig @@ -36,8 +36,8 @@ config IIO_ST_MAGN_3AXIS Say yes here to build support for STMicroelectronics magnetometers: LSM303DLHC, LSM303DLM, LIS3MDL. - This driver can also be built as a module. If so, will be created - these modules: + This driver can also be built as a module. If so, these modules + will be created: - st_magn (core functions for the driver [it is mandatory]); - st_magn_i2c (necessary for the I2C devices [optional*]); - st_magn_spi (necessary for the SPI devices [optional*]); diff --git a/drivers/iio/pressure/Kconfig b/drivers/iio/pressure/Kconfig index 3cba7f551ebe5..56ae8905c8e11 100644 --- a/drivers/iio/pressure/Kconfig +++ b/drivers/iio/pressure/Kconfig @@ -14,8 +14,8 @@ config IIO_ST_PRESS Say yes here to build support for STMicroelectronics pressure sensors: LPS331AP. - This driver can also be built as a module. If so, will be created - these modules: + This driver can also be built as a module. If so, these modules + will be created: - st_pressure (core functions for the driver [it is mandatory]); - st_pressure_i2c (necessary for the I2C devices [optional*]); - st_pressure_spi (necessary for the SPI devices [optional*]); -- GitLab From f17b77d6cfbc0d130ba9d57b89e8579ff43a3350 Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Sun, 23 Jun 2013 22:30:00 +0100 Subject: [PATCH 475/942] iio: add store_eeprom to mcp4725 dac driver Signed-off-by: Peter Meerwald Signed-off-by: Jonathan Cameron --- drivers/iio/dac/mcp4725.c | 64 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 62 insertions(+), 2 deletions(-) diff --git a/drivers/iio/dac/mcp4725.c b/drivers/iio/dac/mcp4725.c index a612ec766d96f..cb9db90f0a214 100644 --- a/drivers/iio/dac/mcp4725.c +++ b/drivers/iio/dac/mcp4725.c @@ -12,14 +12,13 @@ * driver for the Microchip I2C 12-bit digital-to-analog converter (DAC) * (7-bit I2C slave address 0x60, the three LSBs can be configured in * hardware) - * - * writing the DAC value to EEPROM is not supported */ #include #include #include #include +#include #include #include @@ -64,6 +63,66 @@ static SIMPLE_DEV_PM_OPS(mcp4725_pm_ops, mcp4725_suspend, mcp4725_resume); #define MCP4725_PM_OPS NULL #endif +static int mcp4725_store_eeprom(struct device *dev, + struct device_attribute *attr, const char *buf, size_t len) +{ + struct iio_dev *indio_dev = dev_to_iio_dev(dev); + struct mcp4725_data *data = iio_priv(indio_dev); + int tries = 20; + u8 inoutbuf[3]; + bool state; + int ret; + + ret = strtobool(buf, &state); + if (ret < 0) + return ret; + + if (!state) + return 0; + + inoutbuf[0] = 0x60; /* write EEPROM */ + inoutbuf[1] = data->dac_value >> 4; + inoutbuf[2] = (data->dac_value & 0xf) << 4; + + ret = i2c_master_send(data->client, inoutbuf, 3); + if (ret < 0) + return ret; + else if (ret != 3) + return -EIO; + + /* wait for write complete, takes up to 50ms */ + while (tries--) { + msleep(20); + ret = i2c_master_recv(data->client, inoutbuf, 3); + if (ret < 0) + return ret; + else if (ret != 3) + return -EIO; + + if (inoutbuf[0] & 0x80) + break; + } + + if (tries < 0) { + dev_err(&data->client->dev, + "mcp4725_store_eeprom() failed, incomplete\n"); + return -EIO; + } + + return len; +} + +static IIO_DEVICE_ATTR(store_eeprom, S_IWUSR, NULL, mcp4725_store_eeprom, 0); + +static struct attribute *mcp4725_attributes[] = { + &iio_dev_attr_store_eeprom.dev_attr.attr, + NULL, +}; + +static const struct attribute_group mcp4725_attribute_group = { + .attrs = mcp4725_attributes, +}; + static const struct iio_chan_spec mcp4725_channel = { .type = IIO_VOLTAGE, .indexed = 1, @@ -138,6 +197,7 @@ static int mcp4725_write_raw(struct iio_dev *indio_dev, static const struct iio_info mcp4725_info = { .read_raw = mcp4725_read_raw, .write_raw = mcp4725_write_raw, + .attrs = &mcp4725_attribute_group, .driver_module = THIS_MODULE, }; -- GitLab From 155f1b4189d093b1e7c09d90e660dba774dc325a Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Sun, 23 Jun 2013 22:30:00 +0100 Subject: [PATCH 476/942] iio: add powerdown to mcp4725 dac drive Signed-off-by: Peter Meerwald Signed-off-by: Jonathan Cameron --- drivers/iio/dac/mcp4725.c | 87 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 85 insertions(+), 2 deletions(-) diff --git a/drivers/iio/dac/mcp4725.c b/drivers/iio/dac/mcp4725.c index cb9db90f0a214..f569738c94b1f 100644 --- a/drivers/iio/dac/mcp4725.c +++ b/drivers/iio/dac/mcp4725.c @@ -31,15 +31,19 @@ struct mcp4725_data { struct i2c_client *client; u16 vref_mv; u16 dac_value; + bool powerdown; + unsigned powerdown_mode; }; -#ifdef CONFIG_PM_SLEEP static int mcp4725_suspend(struct device *dev) { + struct iio_dev *indio_dev = dev_to_iio_dev(dev); + struct mcp4725_data *data = iio_priv(indio_dev); u8 outbuf[2]; - outbuf[0] = 0x3 << 4; /* power-down bits, 500 kOhm resistor */ + outbuf[0] = (data->powerdown_mode + 1) << 4; outbuf[1] = 0; + data->powerdown = true; return i2c_master_send(to_i2c_client(dev), outbuf, 2); } @@ -53,10 +57,12 @@ static int mcp4725_resume(struct device *dev) /* restore previous DAC value */ outbuf[0] = (data->dac_value >> 8) & 0xf; outbuf[1] = data->dac_value & 0xff; + data->powerdown = false; return i2c_master_send(to_i2c_client(dev), outbuf, 2); } +#ifdef CONFIG_PM_SLEEP static SIMPLE_DEV_PM_OPS(mcp4725_pm_ops, mcp4725_suspend, mcp4725_resume); #define MCP4725_PM_OPS (&mcp4725_pm_ops) #else @@ -123,6 +129,78 @@ static const struct attribute_group mcp4725_attribute_group = { .attrs = mcp4725_attributes, }; +static const char * const mcp4725_powerdown_modes[] = { + "1kohm_to_gnd", + "100kohm_to_gnd", + "500kohm_to_gnd" +}; + +static int mcp4725_get_powerdown_mode(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan) +{ + struct mcp4725_data *data = iio_priv(indio_dev); + + return data->powerdown_mode; +} + +static int mcp4725_set_powerdown_mode(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan, unsigned mode) +{ + struct mcp4725_data *data = iio_priv(indio_dev); + + data->powerdown_mode = mode; + + return 0; +} + +static ssize_t mcp4725_read_powerdown(struct iio_dev *indio_dev, + uintptr_t private, const struct iio_chan_spec *chan, char *buf) +{ + struct mcp4725_data *data = iio_priv(indio_dev); + + return sprintf(buf, "%d\n", data->powerdown); +} + +static ssize_t mcp4725_write_powerdown(struct iio_dev *indio_dev, + uintptr_t private, const struct iio_chan_spec *chan, + const char *buf, size_t len) +{ + struct mcp4725_data *data = iio_priv(indio_dev); + bool state; + int ret; + + ret = strtobool(buf, &state); + if (ret) + return ret; + + if (state) + ret = mcp4725_suspend(&data->client->dev); + else + ret = mcp4725_resume(&data->client->dev); + if (ret < 0) + return ret; + + return len; +} + +static const struct iio_enum mcp4725_powerdown_mode_enum = { + .items = mcp4725_powerdown_modes, + .num_items = ARRAY_SIZE(mcp4725_powerdown_modes), + .get = mcp4725_get_powerdown_mode, + .set = mcp4725_set_powerdown_mode, +}; + +static const struct iio_chan_spec_ext_info mcp4725_ext_info[] = { + { + .name = "powerdown", + .read = mcp4725_read_powerdown, + .write = mcp4725_write_powerdown, + }, + IIO_ENUM("powerdown_mode", false, &mcp4725_powerdown_mode_enum), + IIO_ENUM_AVAILABLE("powerdown_mode", &mcp4725_powerdown_mode_enum), + { }, +}; + static const struct iio_chan_spec mcp4725_channel = { .type = IIO_VOLTAGE, .indexed = 1, @@ -131,6 +209,7 @@ static const struct iio_chan_spec mcp4725_channel = { .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), .scan_type = IIO_ST('u', 12, 16, 0), + .ext_info = mcp4725_ext_info, }; static int mcp4725_set_value(struct iio_dev *indio_dev, int val) @@ -208,6 +287,7 @@ static int mcp4725_probe(struct i2c_client *client, struct iio_dev *indio_dev; struct mcp4725_platform_data *platform_data = client->dev.platform_data; u8 inbuf[3]; + u8 pd; int err; if (!platform_data || !platform_data->vref_mv) { @@ -239,6 +319,9 @@ static int mcp4725_probe(struct i2c_client *client, dev_err(&client->dev, "failed to read DAC value"); goto exit_free_device; } + pd = (inbuf[0] >> 1) & 0x3; + data->powerdown = pd > 0 ? true : false; + data->powerdown_mode = pd ? pd-1 : 2; /* 500kohm_to_gnd */ data->dac_value = (inbuf[1] << 4) | (inbuf[2] >> 4); err = iio_device_register(indio_dev); -- GitLab From bd53a414b860e4b12f88fbf553e4197384846dbd Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Sun, 23 Jun 2013 22:30:00 +0100 Subject: [PATCH 477/942] iio: add DAC 500kohm_to_gnd to possible powerdown_modes Signed-off-by: Peter Meerwald Signed-off-by: Jonathan Cameron --- Documentation/ABI/testing/sysfs-bus-iio | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio index dda81ffae5cfb..e49d84c00eeee 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio +++ b/Documentation/ABI/testing/sysfs-bus-iio @@ -351,6 +351,7 @@ Description: 6kohm_to_gnd: connected to ground via a 6kOhm resistor, 20kohm_to_gnd: connected to ground via a 20kOhm resistor, 100kohm_to_gnd: connected to ground via an 100kOhm resistor, + 500kohm_to_gnd: connected to ground via a 500kOhm resistor, three_state: left floating. For a list of available output power down options read outX_powerdown_mode_available. If Y is not present the -- GitLab From f7883d12a8f76378a1ebfde6fc2e48249b7f9093 Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Sun, 23 Jun 2013 22:30:00 +0100 Subject: [PATCH 478/942] iio: move ABI specification for store_eeprom; is used by ad9523, mcp4725 and ds1077 devices Signed-off-by: Peter Meerwald Reviewed-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- Documentation/ABI/testing/sysfs-bus-iio | 8 ++++++++ Documentation/ABI/testing/sysfs-bus-iio-frequency-ad9523 | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio index e49d84c00eeee..45ae709db4ffc 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio +++ b/Documentation/ABI/testing/sysfs-bus-iio @@ -793,3 +793,11 @@ Contact: linux-iio@vger.kernel.org Description: This attribute is used to read the amount of quadrature error present in the device at a given time. + +What: /sys/bus/iio/devices/iio:deviceX/store_eeprom +KernelVersion: 3.4.0 +Contact: linux-iio@vger.kernel.org +Description: + Writing '1' stores the current device configuration into + on-chip EEPROM. After power-up or chip reset the device will + automatically load the saved configuration. diff --git a/Documentation/ABI/testing/sysfs-bus-iio-frequency-ad9523 b/Documentation/ABI/testing/sysfs-bus-iio-frequency-ad9523 index 2ce9c3f68eeea..a91aeabe7b244 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio-frequency-ad9523 +++ b/Documentation/ABI/testing/sysfs-bus-iio-frequency-ad9523 @@ -18,14 +18,6 @@ Description: Reading returns either '1' or '0'. '1' means that the pllY is locked. -What: /sys/bus/iio/devices/iio:deviceX/store_eeprom -KernelVersion: 3.4.0 -Contact: linux-iio@vger.kernel.org -Description: - Writing '1' stores the current device configuration into - on-chip EEPROM. After power-up or chip reset the device will - automatically load the saved configuration. - What: /sys/bus/iio/devices/iio:deviceX/sync_dividers KernelVersion: 3.4.0 Contact: linux-iio@vger.kernel.org -- GitLab From 8b20be87e10bdacdc4acf313a380a042ee9a2912 Mon Sep 17 00:00:00 2001 From: Alexandre Belloni Date: Mon, 24 Jun 2013 18:24:00 +0100 Subject: [PATCH 479/942] iio: Add Nuvoton NAU7802 ADC driver The Nuvoton NAU7802 ADC is a 24-bit 2-channels I2C ADC, with adjustable gain and sampling rates. Signed-off-by: Alexandre Belloni Signed-off-by: Maxime Ripard Reviewed-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- .../bindings/iio/adc/nuvoton-nau7802.txt | 18 + drivers/iio/adc/Kconfig | 9 + drivers/iio/adc/Makefile | 1 + drivers/iio/adc/nau7802.c | 584 ++++++++++++++++++ 4 files changed, 612 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/adc/nuvoton-nau7802.txt create mode 100644 drivers/iio/adc/nau7802.c diff --git a/Documentation/devicetree/bindings/iio/adc/nuvoton-nau7802.txt b/Documentation/devicetree/bindings/iio/adc/nuvoton-nau7802.txt new file mode 100644 index 0000000000000..e9582e6fe3500 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/adc/nuvoton-nau7802.txt @@ -0,0 +1,18 @@ +* Nuvoton NAU7802 Analog to Digital Converter (ADC) + +Required properties: + - compatible: Should be "nuvoton,nau7802" + - reg: Should contain the ADC I2C address + +Optional properties: + - nuvoton,vldo: Internal reference voltage in millivolts to be + configured valid values are between 2400 mV and 4500 mV. + - interrupts: IRQ line for the ADC. If not used the driver will use + polling. + +Example: +adc2: nau7802@2a { + compatible = "nuvoton,nau7802"; + reg = <0x2a>; + nuvoton,vldo = <3000>; +}; diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index 93129ec4b649b..2eced9d53a0b5 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -143,6 +143,15 @@ config MCP320X This driver can also be built as a module. If so, the module will be called mcp320x. +config NAU7802 + tristate "Nuvoton NAU7802 ADC driver" + depends on I2C + help + Say yes here to build support for Nuvoton NAU7802 ADC. + + To compile this driver as a module, choose M here: the + module will be called nau7802. + config TI_ADC081C tristate "Texas Instruments ADC081C021/027" depends on I2C diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile index 8f475d31fe4d8..d184139d1cd78 100644 --- a/drivers/iio/adc/Makefile +++ b/drivers/iio/adc/Makefile @@ -15,6 +15,7 @@ obj-$(CONFIG_EXYNOS_ADC) += exynos_adc.o obj-$(CONFIG_LP8788_ADC) += lp8788_adc.o obj-$(CONFIG_MAX1363) += max1363.o obj-$(CONFIG_MCP320X) += mcp320x.o +obj-$(CONFIG_NAU7802) += nau7802.o obj-$(CONFIG_TI_ADC081C) += ti-adc081c.o obj-$(CONFIG_TI_AM335X_ADC) += ti_am335x_adc.o obj-$(CONFIG_VIPERBOARD_ADC) += viperboard_adc.o diff --git a/drivers/iio/adc/nau7802.c b/drivers/iio/adc/nau7802.c new file mode 100644 index 0000000000000..70fa17149d1a3 --- /dev/null +++ b/drivers/iio/adc/nau7802.c @@ -0,0 +1,584 @@ +/* + * Driver for the Nuvoton NAU7802 ADC + * + * Copyright 2013 Free Electrons + * + * Licensed under the GPLv2 or later. + */ + +#include +#include +#include +#include +#include +#include + +#include +#include + +#define NAU7802_REG_PUCTRL 0x00 +#define NAU7802_PUCTRL_RR(x) (x << 0) +#define NAU7802_PUCTRL_RR_BIT NAU7802_PUCTRL_RR(1) +#define NAU7802_PUCTRL_PUD(x) (x << 1) +#define NAU7802_PUCTRL_PUD_BIT NAU7802_PUCTRL_PUD(1) +#define NAU7802_PUCTRL_PUA(x) (x << 2) +#define NAU7802_PUCTRL_PUA_BIT NAU7802_PUCTRL_PUA(1) +#define NAU7802_PUCTRL_PUR(x) (x << 3) +#define NAU7802_PUCTRL_PUR_BIT NAU7802_PUCTRL_PUR(1) +#define NAU7802_PUCTRL_CS(x) (x << 4) +#define NAU7802_PUCTRL_CS_BIT NAU7802_PUCTRL_CS(1) +#define NAU7802_PUCTRL_CR(x) (x << 5) +#define NAU7802_PUCTRL_CR_BIT NAU7802_PUCTRL_CR(1) +#define NAU7802_PUCTRL_AVDDS(x) (x << 7) +#define NAU7802_PUCTRL_AVDDS_BIT NAU7802_PUCTRL_AVDDS(1) +#define NAU7802_REG_CTRL1 0x01 +#define NAU7802_CTRL1_VLDO(x) (x << 3) +#define NAU7802_CTRL1_GAINS(x) (x) +#define NAU7802_CTRL1_GAINS_BITS 0x07 +#define NAU7802_REG_CTRL2 0x02 +#define NAU7802_CTRL2_CHS(x) (x << 7) +#define NAU7802_CTRL2_CRS(x) (x << 4) +#define NAU7802_SAMP_FREQ_320 0x07 +#define NAU7802_CTRL2_CHS_BIT NAU7802_CTRL2_CHS(1) +#define NAU7802_REG_ADC_B2 0x12 +#define NAU7802_REG_ADC_B1 0x13 +#define NAU7802_REG_ADC_B0 0x14 +#define NAU7802_REG_ADC_CTRL 0x15 + +#define NAU7802_MIN_CONVERSIONS 6 + +struct nau7802_state { + struct i2c_client *client; + s32 last_value; + struct mutex lock; + struct mutex data_lock; + u32 vref_mv; + u32 conversion_count; + u32 min_conversions; + u8 sample_rate; + u32 scale_avail[8]; + struct completion value_ok; +}; + +#define NAU7802_CHANNEL(chan) { \ + .type = IIO_VOLTAGE, \ + .indexed = 1, \ + .channel = (chan), \ + .scan_index = (chan), \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \ + BIT(IIO_CHAN_INFO_SAMP_FREQ) \ +} + +static const struct iio_chan_spec nau7802_chan_array[] = { + NAU7802_CHANNEL(0), + NAU7802_CHANNEL(1), +}; + +static const u16 nau7802_sample_freq_avail[] = {10, 20, 40, 80, + 10, 10, 10, 320}; + +static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("10 40 80 320"); + +static struct attribute *nau7802_attributes[] = { + &iio_const_attr_sampling_frequency_available.dev_attr.attr, + NULL +}; + +static const struct attribute_group nau7802_attribute_group = { + .attrs = nau7802_attributes, +}; + +static int nau7802_set_gain(struct nau7802_state *st, int gain) +{ + int ret; + + mutex_lock(&st->lock); + st->conversion_count = 0; + + ret = i2c_smbus_read_byte_data(st->client, NAU7802_REG_CTRL1); + if (ret < 0) + goto nau7802_sysfs_set_gain_out; + ret = i2c_smbus_write_byte_data(st->client, NAU7802_REG_CTRL1, + (ret & (~NAU7802_CTRL1_GAINS_BITS)) | + gain); + +nau7802_sysfs_set_gain_out: + mutex_unlock(&st->lock); + + return ret; +} + +static int nau7802_read_conversion(struct nau7802_state *st) +{ + int data; + + mutex_lock(&st->data_lock); + data = i2c_smbus_read_byte_data(st->client, NAU7802_REG_ADC_B2); + if (data < 0) + goto nau7802_read_conversion_out; + st->last_value = data << 16; + + data = i2c_smbus_read_byte_data(st->client, NAU7802_REG_ADC_B1); + if (data < 0) + goto nau7802_read_conversion_out; + st->last_value |= data << 8; + + data = i2c_smbus_read_byte_data(st->client, NAU7802_REG_ADC_B0); + if (data < 0) + goto nau7802_read_conversion_out; + st->last_value |= data; + + st->last_value = sign_extend32(st->last_value, 23); + +nau7802_read_conversion_out: + mutex_unlock(&st->data_lock); + + return data; +} + +/* + * Conversions are synchronised on the rising edge of NAU7802_PUCTRL_CS_BIT + */ +static int nau7802_sync(struct nau7802_state *st) +{ + int ret; + + ret = i2c_smbus_read_byte_data(st->client, NAU7802_REG_PUCTRL); + if (ret < 0) + return ret; + ret = i2c_smbus_write_byte_data(st->client, NAU7802_REG_PUCTRL, + ret | NAU7802_PUCTRL_CS_BIT); + + return ret; +} + +static irqreturn_t nau7802_eoc_trigger(int irq, void *private) +{ + struct iio_dev *indio_dev = private; + struct nau7802_state *st = iio_priv(indio_dev); + int status; + + status = i2c_smbus_read_byte_data(st->client, NAU7802_REG_PUCTRL); + if (status < 0) + return IRQ_HANDLED; + + if (!(status & NAU7802_PUCTRL_CR_BIT)) + return IRQ_NONE; + + if (nau7802_read_conversion(st) < 0) + return IRQ_HANDLED; + + /* + * Because there is actually only one ADC for both channels, we have to + * wait for enough conversions to happen before getting a significant + * value when changing channels and the values are far apart. + */ + if (st->conversion_count < NAU7802_MIN_CONVERSIONS) + st->conversion_count++; + if (st->conversion_count >= NAU7802_MIN_CONVERSIONS) + complete_all(&st->value_ok); + + return IRQ_HANDLED; +} + +static int nau7802_read_irq(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val) +{ + struct nau7802_state *st = iio_priv(indio_dev); + int ret; + + INIT_COMPLETION(st->value_ok); + enable_irq(st->client->irq); + + nau7802_sync(st); + + /* read registers to ensure we flush everything */ + ret = nau7802_read_conversion(st); + if (ret < 0) + goto read_chan_info_failure; + + /* Wait for a conversion to finish */ + ret = wait_for_completion_interruptible_timeout(&st->value_ok, + msecs_to_jiffies(1000)); + if (ret == 0) + ret = -ETIMEDOUT; + + if (ret < 0) + goto read_chan_info_failure; + + disable_irq(st->client->irq); + + *val = st->last_value; + + return IIO_VAL_INT; + +read_chan_info_failure: + disable_irq(st->client->irq); + + return ret; +} + +static int nau7802_read_poll(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val) +{ + struct nau7802_state *st = iio_priv(indio_dev); + int ret; + + nau7802_sync(st); + + /* read registers to ensure we flush everything */ + ret = nau7802_read_conversion(st); + if (ret < 0) + return ret; + + /* + * Because there is actually only one ADC for both channels, we have to + * wait for enough conversions to happen before getting a significant + * value when changing channels and the values are far appart. + */ + do { + ret = i2c_smbus_read_byte_data(st->client, NAU7802_REG_PUCTRL); + if (ret < 0) + return ret; + + while (!(ret & NAU7802_PUCTRL_CR_BIT)) { + if (st->sample_rate != NAU7802_SAMP_FREQ_320) + msleep(20); + else + mdelay(4); + ret = i2c_smbus_read_byte_data(st->client, + NAU7802_REG_PUCTRL); + if (ret < 0) + return ret; + } + + ret = nau7802_read_conversion(st); + if (ret < 0) + return ret; + if (st->conversion_count < NAU7802_MIN_CONVERSIONS) + st->conversion_count++; + } while (st->conversion_count < NAU7802_MIN_CONVERSIONS); + + *val = st->last_value; + + return IIO_VAL_INT; +} + +static int nau7802_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, int *val2, long mask) +{ + struct nau7802_state *st = iio_priv(indio_dev); + int ret; + + switch (mask) { + case IIO_CHAN_INFO_RAW: + mutex_lock(&st->lock); + /* + * Select the channel to use + * - Channel 1 is value 0 in the CHS register + * - Channel 2 is value 1 in the CHS register + */ + ret = i2c_smbus_read_byte_data(st->client, NAU7802_REG_CTRL2); + if (ret < 0) { + mutex_unlock(&st->lock); + return ret; + } + + if (((ret & NAU7802_CTRL2_CHS_BIT) && !chan->channel) || + (!(ret & NAU7802_CTRL2_CHS_BIT) && + chan->channel)) { + st->conversion_count = 0; + ret = i2c_smbus_write_byte_data(st->client, + NAU7802_REG_CTRL2, + NAU7802_CTRL2_CHS(chan->channel) | + NAU7802_CTRL2_CRS(st->sample_rate)); + + if (ret < 0) { + mutex_unlock(&st->lock); + return ret; + } + } + + if (st->client->irq) + ret = nau7802_read_irq(indio_dev, chan, val); + else + ret = nau7802_read_poll(indio_dev, chan, val); + + mutex_unlock(&st->lock); + return ret; + + case IIO_CHAN_INFO_SCALE: + ret = i2c_smbus_read_byte_data(st->client, NAU7802_REG_CTRL1); + if (ret < 0) + return ret; + + /* + * We have 24 bits of signed data, that means 23 bits of data + * plus the sign bit + */ + *val = st->vref_mv; + *val2 = 23 + (ret & NAU7802_CTRL1_GAINS_BITS); + + return IIO_VAL_FRACTIONAL_LOG2; + + case IIO_CHAN_INFO_SAMP_FREQ: + *val = nau7802_sample_freq_avail[st->sample_rate]; + *val2 = 0; + return IIO_VAL_INT; + + default: + break; + } + + return -EINVAL; +} + +static int nau7802_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, int val2, long mask) +{ + struct nau7802_state *st = iio_priv(indio_dev); + int i, ret; + + switch (mask) { + case IIO_CHAN_INFO_SCALE: + for (i = 0; i < ARRAY_SIZE(st->scale_avail); i++) + if (val2 == st->scale_avail[i]) + return nau7802_set_gain(st, i); + + break; + + case IIO_CHAN_INFO_SAMP_FREQ: + for (i = 0; i < ARRAY_SIZE(nau7802_sample_freq_avail); i++) + if (val == nau7802_sample_freq_avail[i]) { + mutex_lock(&st->lock); + st->sample_rate = i; + st->conversion_count = 0; + ret = i2c_smbus_write_byte_data(st->client, + NAU7802_REG_CTRL2, + NAU7802_CTRL2_CRS(st->sample_rate)); + mutex_unlock(&st->lock); + return ret; + } + + break; + + default: + break; + } + + return -EINVAL; +} + +static int nau7802_write_raw_get_fmt(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + long mask) +{ + return IIO_VAL_INT_PLUS_NANO; +} + +static const struct iio_info nau7802_info = { + .driver_module = THIS_MODULE, + .read_raw = &nau7802_read_raw, + .write_raw = &nau7802_write_raw, + .write_raw_get_fmt = nau7802_write_raw_get_fmt, + .attrs = &nau7802_attribute_group, +}; + +static int nau7802_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct iio_dev *indio_dev; + struct nau7802_state *st; + struct device_node *np = client->dev.of_node; + int i, ret; + u8 data; + u32 tmp = 0; + + if (!client->dev.of_node) { + dev_err(&client->dev, "No device tree node available.\n"); + return -EINVAL; + } + + indio_dev = iio_device_alloc(sizeof(*st)); + if (indio_dev == NULL) + return -ENOMEM; + + st = iio_priv(indio_dev); + + i2c_set_clientdata(client, indio_dev); + + indio_dev->dev.parent = &client->dev; + indio_dev->name = dev_name(&client->dev); + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->info = &nau7802_info; + + st->client = client; + + /* Reset the device */ + ret = i2c_smbus_write_byte_data(st->client, NAU7802_REG_PUCTRL, + NAU7802_PUCTRL_RR_BIT); + if (ret < 0) + goto error_free_indio; + + /* Enter normal operation mode */ + ret = i2c_smbus_write_byte_data(st->client, NAU7802_REG_PUCTRL, + NAU7802_PUCTRL_PUD_BIT); + if (ret < 0) + goto error_free_indio; + + /* + * After about 200 usecs, the device should be ready and then + * the Power Up bit will be set to 1. If not, wait for it. + */ + udelay(210); + ret = i2c_smbus_read_byte_data(st->client, NAU7802_REG_PUCTRL); + if (ret < 0) + goto error_free_indio; + if (!(ret & NAU7802_PUCTRL_PUR_BIT)) + goto error_free_indio; + + of_property_read_u32(np, "nuvoton,vldo", &tmp); + st->vref_mv = tmp; + + data = NAU7802_PUCTRL_PUD_BIT | NAU7802_PUCTRL_PUA_BIT | + NAU7802_PUCTRL_CS_BIT; + if (tmp >= 2400) + data |= NAU7802_PUCTRL_AVDDS_BIT; + + ret = i2c_smbus_write_byte_data(st->client, NAU7802_REG_PUCTRL, data); + if (ret < 0) + goto error_free_indio; + ret = i2c_smbus_write_byte_data(st->client, NAU7802_REG_ADC_CTRL, 0x30); + if (ret < 0) + goto error_free_indio; + + if (tmp >= 2400) { + data = NAU7802_CTRL1_VLDO((4500 - tmp) / 300); + ret = i2c_smbus_write_byte_data(st->client, NAU7802_REG_CTRL1, + data); + if (ret < 0) + goto error_free_indio; + } + + /* Populate available ADC input ranges */ + for (i = 0; i < ARRAY_SIZE(st->scale_avail); i++) + st->scale_avail[i] = (((u64)st->vref_mv) * 1000000000ULL) + >> (23 + i); + + init_completion(&st->value_ok); + + /* + * The ADC fires continuously and we can't do anything about + * it. So we need to have the IRQ disabled by default, and we + * will enable them back when we will need them.. + */ + if (client->irq) { + ret = request_threaded_irq(client->irq, + NULL, + nau7802_eoc_trigger, + IRQF_TRIGGER_HIGH | IRQF_ONESHOT, + client->dev.driver->name, + indio_dev); + if (ret) { + /* + * What may happen here is that our IRQ controller is + * not able to get level interrupt but this is required + * by this ADC as when going over 40 sample per second, + * the interrupt line may stay high between conversions. + * So, we continue no matter what but we switch to + * polling mode. + */ + dev_info(&client->dev, + "Failed to allocate IRQ, using polling mode\n"); + client->irq = 0; + } else + disable_irq(client->irq); + } + + if (!client->irq) { + /* + * We are polling, use the fastest sample rate by + * default + */ + st->sample_rate = NAU7802_SAMP_FREQ_320; + ret = i2c_smbus_write_byte_data(st->client, NAU7802_REG_CTRL2, + NAU7802_CTRL2_CRS(st->sample_rate)); + if (ret) + goto error_free_irq; + } + + /* Setup the ADC channels available on the board */ + indio_dev->num_channels = ARRAY_SIZE(nau7802_chan_array); + indio_dev->channels = nau7802_chan_array; + + mutex_init(&st->lock); + mutex_init(&st->data_lock); + + ret = iio_device_register(indio_dev); + if (ret < 0) { + dev_err(&client->dev, "Couldn't register the device.\n"); + goto error_device_register; + } + + return 0; + +error_device_register: + mutex_destroy(&st->lock); + mutex_destroy(&st->data_lock); +error_free_irq: + if (client->irq) + free_irq(client->irq, indio_dev); +error_free_indio: + iio_device_free(indio_dev); + + return ret; +} + +static int nau7802_remove(struct i2c_client *client) +{ + struct iio_dev *indio_dev = i2c_get_clientdata(client); + struct nau7802_state *st = iio_priv(indio_dev); + + iio_device_unregister(indio_dev); + mutex_destroy(&st->lock); + mutex_destroy(&st->data_lock); + if (client->irq) + free_irq(client->irq, indio_dev); + iio_device_free(indio_dev); + + return 0; +} + +static const struct i2c_device_id nau7802_i2c_id[] = { + { "nau7802", 0 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, nau7802_i2c_id); + +static const struct of_device_id nau7802_dt_ids[] = { + { .compatible = "nuvoton,nau7802" }, + {}, +}; +MODULE_DEVICE_TABLE(of, nau7802_dt_ids); + +static struct i2c_driver nau7802_driver = { + .probe = nau7802_probe, + .remove = nau7802_remove, + .id_table = nau7802_i2c_id, + .driver = { + .name = "nau7802", + .of_match_table = of_match_ptr(nau7802_dt_ids), + }, +}; + +module_i2c_driver(nau7802_driver); + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("Nuvoton NAU7802 ADC Driver"); +MODULE_AUTHOR("Maxime Ripard "); +MODULE_AUTHOR("Alexandre Belloni "); -- GitLab From 7f7ce433ba17a1465a33181a085ddf8099c249d6 Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Sun, 7 Jul 2013 21:24:00 +0100 Subject: [PATCH 480/942] iio: staging: fix device.txt documentation Signed-off-by: Peter Meerwald Signed-off-by: Jonathan Cameron --- drivers/staging/iio/Documentation/device.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/iio/Documentation/device.txt b/drivers/staging/iio/Documentation/device.txt index ea08d6213373c..8be32e5a0af12 100644 --- a/drivers/staging/iio/Documentation/device.txt +++ b/drivers/staging/iio/Documentation/device.txt @@ -56,7 +56,7 @@ Then fill in the following: - indio_dev->modes: Specify whether direct access and / or ring buffer access is supported. -- indio_dev->ring: +- indio_dev->buffer: An optional associated buffer. - indio_dev->pollfunc: Poll function related elements. This controls what occurs when a trigger @@ -67,7 +67,7 @@ Then fill in the following: - indio_dev->num_channels: How many channels are there? -Once these are set up, a call to iio_device_register(indio_dev), +Once these are set up, a call to iio_device_register(indio_dev) will register the device with the iio core. Worth noting here is that, if a ring buffer is to be used, it can be -- GitLab From 69078517ac6214810b880add6b997a467426f097 Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Sun, 7 Jul 2013 21:24:00 +0100 Subject: [PATCH 481/942] iio: fix typo, Documentation/ABI/testing/sysfs-bus-iio-frequency-adf4350 Signed-off-by: Peter Meerwald Signed-off-by: Jonathan Cameron --- Documentation/ABI/testing/sysfs-bus-iio-frequency-adf4350 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/ABI/testing/sysfs-bus-iio-frequency-adf4350 b/Documentation/ABI/testing/sysfs-bus-iio-frequency-adf4350 index d89aded01c5ad..1254457a726e8 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio-frequency-adf4350 +++ b/Documentation/ABI/testing/sysfs-bus-iio-frequency-adf4350 @@ -18,4 +18,4 @@ Description: adjust the reference frequency accordingly. The value written has no effect until out_altvoltageY_frequency is updated. Consider to use out_altvoltageY_powerdown to power - down the PLL and it's RFOut buffers during REFin changes. + down the PLL and its RFOut buffers during REFin changes. -- GitLab From 7d241b27147035d7d50188119d133cf7207312c1 Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Sun, 7 Jul 2013 21:24:00 +0100 Subject: [PATCH 482/942] iio: staging: fix typo in ade758_ring.c Signed-off-by: Peter Meerwald Signed-off-by: Jonathan Cameron --- drivers/staging/iio/meter/ade7758_ring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/meter/ade7758_ring.c b/drivers/staging/iio/meter/ade7758_ring.c index b29e2d5d99377..7d5db71755788 100644 --- a/drivers/staging/iio/meter/ade7758_ring.c +++ b/drivers/staging/iio/meter/ade7758_ring.c @@ -54,7 +54,7 @@ static int ade7758_write_waveform_type(struct device *dev, unsigned type) return ret; } -/* Whilst this makes a lot of calls to iio_sw_ring functions - it is to device +/* Whilst this makes a lot of calls to iio_sw_ring functions - it is too device * specific to be rolled into the core. */ static irqreturn_t ade7758_trigger_handler(int irq, void *p) -- GitLab From 70ea35fba29e6c80f5f668d585203a0062caed96 Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Sun, 7 Jul 2013 21:24:00 +0100 Subject: [PATCH 483/942] iio: fix semicolon in io_core_trigger.h Signed-off-by: Peter Meerwald Signed-off-by: Jonathan Cameron --- drivers/iio/iio_core_trigger.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/iio/iio_core_trigger.h b/drivers/iio/iio_core_trigger.h index 6f7c56fcbe785..1fdb1e4ea4a5d 100644 --- a/drivers/iio/iio_core_trigger.h +++ b/drivers/iio/iio_core_trigger.h @@ -30,7 +30,7 @@ void iio_device_unregister_trigger_consumer(struct iio_dev *indio_dev); static int iio_device_register_trigger_consumer(struct iio_dev *indio_dev) { return 0; -}; +} /** * iio_device_unregister_trigger_consumer() - reverse the registration process @@ -38,9 +38,6 @@ static int iio_device_register_trigger_consumer(struct iio_dev *indio_dev) **/ static void iio_device_unregister_trigger_consumer(struct iio_dev *indio_dev) { -}; +} #endif /* CONFIG_TRIGGER_CONSUMER */ - - - -- GitLab From 947123d53fe0305536c202a36d5ba123ab83b362 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Wed, 10 Jul 2013 03:36:00 +0100 Subject: [PATCH 484/942] iio: mxs-lradc: Check the return value from stmp_reset_block() stmp_reset_block() may fail, so let's check its return value and propagate it in the case of error. Signed-off-by: Fabio Estevam Acked-by: Marek Vasut Signed-off-by: Jonathan Cameron --- drivers/staging/iio/adc/mxs-lradc.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/staging/iio/adc/mxs-lradc.c b/drivers/staging/iio/adc/mxs-lradc.c index 9f52a2857929f..37a4fd39b1e04 100644 --- a/drivers/staging/iio/adc/mxs-lradc.c +++ b/drivers/staging/iio/adc/mxs-lradc.c @@ -841,14 +841,16 @@ static const struct iio_chan_spec mxs_lradc_chan_spec[] = { MXS_ADC_CHAN(15, IIO_VOLTAGE), /* VDD5V */ }; -static void mxs_lradc_hw_init(struct mxs_lradc *lradc) +static int mxs_lradc_hw_init(struct mxs_lradc *lradc) { /* The ADC always uses DELAY CHANNEL 0. */ const uint32_t adc_cfg = (1 << (LRADC_DELAY_TRIGGER_DELAYS_OFFSET + 0)) | (LRADC_DELAY_TIMER_PER << LRADC_DELAY_DELAY_OFFSET); - stmp_reset_block(lradc->base); + int ret = stmp_reset_block(lradc->base); + if (ret) + return ret; /* Configure DELAY CHANNEL 0 for generic ADC sampling. */ writel(adc_cfg, lradc->base + LRADC_DELAY(0)); @@ -869,6 +871,8 @@ static void mxs_lradc_hw_init(struct mxs_lradc *lradc) /* Start internal temperature sensing. */ writel(0, lradc->base + LRADC_CTRL2); + + return 0; } static void mxs_lradc_hw_stop(struct mxs_lradc *lradc) @@ -976,7 +980,9 @@ static int mxs_lradc_probe(struct platform_device *pdev) goto err_trig; /* Configure the hardware. */ - mxs_lradc_hw_init(lradc); + ret = mxs_lradc_hw_init(lradc); + if (ret) + goto err_dev; /* Register the touchscreen input device. */ ret = mxs_lradc_ts_register(lradc); -- GitLab From 66c721f78f35ecf176efc7a63f775254ce259a82 Mon Sep 17 00:00:00 2001 From: Alexander Holler Date: Wed, 10 Jul 2013 09:31:00 +0100 Subject: [PATCH 485/942] iio: hid-sensor-accel-3d: add module alias for autoload Add a MODULE_DEVICE_TABLE in order to let hotplug mechanisms automatically load the driver. This makes it also possible to use the usual driver name instead of HID-SENSOR-2000xx which isn't very descriptive in kernel messages. Signed-off-by: Alexander Holler Acked-by:Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- drivers/iio/accel/hid-sensor-accel-3d.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c index bbcbd7101f337..275c5d7ea270b 100644 --- a/drivers/iio/accel/hid-sensor-accel-3d.c +++ b/drivers/iio/accel/hid-sensor-accel-3d.c @@ -30,10 +30,6 @@ #include #include "../common/hid-sensors/hid-sensor-trigger.h" -/*Format: HID-SENSOR-usage_id_in_hex*/ -/*Usage ID from spec for Accelerometer-3D: 0x200073*/ -#define DRIVER_NAME "HID-SENSOR-200073" - enum accel_3d_channel { CHANNEL_SCAN_INDEX_X, CHANNEL_SCAN_INDEX_Y, @@ -389,9 +385,19 @@ static int hid_accel_3d_remove(struct platform_device *pdev) return 0; } +static struct platform_device_id hid_accel_3d_ids[] = { + { + /* Format: HID-SENSOR-usage_id_in_hex_lowercase */ + .name = "HID-SENSOR-200073", + }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(platform, hid_accel_3d_ids); + static struct platform_driver hid_accel_3d_platform_driver = { + .id_table = hid_accel_3d_ids, .driver = { - .name = DRIVER_NAME, + .name = KBUILD_MODNAME, .owner = THIS_MODULE, }, .probe = hid_accel_3d_probe, -- GitLab From a411e735795620f5d260eb883bd80d33b6c7d968 Mon Sep 17 00:00:00 2001 From: Alexander Holler Date: Wed, 10 Jul 2013 09:31:00 +0100 Subject: [PATCH 486/942] iio: hid-sensor-gyro-3d: add module alias for autoload Add a MODULE_DEVICE_TABLE in order to let hotplug mechanisms automatically load the driver. This makes it also possible to use the usual driver name instead of HID-SENSOR-2000xx which isn't very descriptive in kernel messages. Signed-off-by: Alexander Holler Acked-by:Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- drivers/iio/gyro/hid-sensor-gyro-3d.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c index bc943dd47da5b..9cc8aa1102d7c 100644 --- a/drivers/iio/gyro/hid-sensor-gyro-3d.c +++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c @@ -30,10 +30,6 @@ #include #include "../common/hid-sensors/hid-sensor-trigger.h" -/*Format: HID-SENSOR-usage_id_in_hex*/ -/*Usage ID from spec for Gyro-3D: 0x200076*/ -#define DRIVER_NAME "HID-SENSOR-200076" - enum gyro_3d_channel { CHANNEL_SCAN_INDEX_X, CHANNEL_SCAN_INDEX_Y, @@ -389,9 +385,19 @@ static int hid_gyro_3d_remove(struct platform_device *pdev) return 0; } +static struct platform_device_id hid_gyro_3d_ids[] = { + { + /* Format: HID-SENSOR-usage_id_in_hex_lowercase */ + .name = "HID-SENSOR-200076", + }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(platform, hid_gyro_3d_ids); + static struct platform_driver hid_gyro_3d_platform_driver = { + .id_table = hid_gyro_3d_ids, .driver = { - .name = DRIVER_NAME, + .name = KBUILD_MODNAME, .owner = THIS_MODULE, }, .probe = hid_gyro_3d_probe, -- GitLab From 5b812ea536da6ae88f79b48fbde1df8ad1e32ff2 Mon Sep 17 00:00:00 2001 From: Alexander Holler Date: Wed, 10 Jul 2013 09:31:00 +0100 Subject: [PATCH 487/942] iio: hid-sensor-als: add module alias for autoload Add a MODULE_DEVICE_TABLE in order to let hotplug mechanisms automatically load the driver. This makes it also possible to use the usual driver name instead of HID-SENSOR-2000xx which isn't very descriptive in kernel messages. Signed-off-by: Alexander Holler Acked-by:Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- drivers/iio/light/hid-sensor-als.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c index cdc2cad0f01bf..9adfef07d8c25 100644 --- a/drivers/iio/light/hid-sensor-als.c +++ b/drivers/iio/light/hid-sensor-als.c @@ -30,10 +30,6 @@ #include #include "../common/hid-sensors/hid-sensor-trigger.h" -/*Format: HID-SENSOR-usage_id_in_hex*/ -/*Usage ID from spec for Ambiant-Light: 0x200041*/ -#define DRIVER_NAME "HID-SENSOR-200041" - #define CHANNEL_SCAN_INDEX_ILLUM 0 struct als_state { @@ -355,9 +351,19 @@ static int hid_als_remove(struct platform_device *pdev) return 0; } +static struct platform_device_id hid_als_ids[] = { + { + /* Format: HID-SENSOR-usage_id_in_hex_lowercase */ + .name = "HID-SENSOR-200041", + }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(platform, hid_als_ids); + static struct platform_driver hid_als_platform_driver = { + .id_table = hid_als_ids, .driver = { - .name = DRIVER_NAME, + .name = KBUILD_MODNAME, .owner = THIS_MODULE, }, .probe = hid_als_probe, -- GitLab From a67c385a2e11eac4132909efc3eb9ee030d665a5 Mon Sep 17 00:00:00 2001 From: Alexander Holler Date: Wed, 10 Jul 2013 09:32:00 +0100 Subject: [PATCH 488/942] iio: hid-sensor-magn-3d: add module alias for autoload Add a MODULE_DEVICE_TABLE in order to let hotplug mechanisms automatically load the driver. This makes it also possible to use the usual driver name instead of HID-SENSOR-2000xx which isn't very descriptive in kernel messages. Signed-off-by: Alexander Holler Acked-by:Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/hid-sensor-magn-3d.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/iio/magnetometer/hid-sensor-magn-3d.c b/drivers/iio/magnetometer/hid-sensor-magn-3d.c index 99f4e494513b7..e71127aeda09d 100644 --- a/drivers/iio/magnetometer/hid-sensor-magn-3d.c +++ b/drivers/iio/magnetometer/hid-sensor-magn-3d.c @@ -30,10 +30,6 @@ #include #include "../common/hid-sensors/hid-sensor-trigger.h" -/*Format: HID-SENSOR-usage_id_in_hex*/ -/*Usage ID from spec for Magnetometer-3D: 0x200083*/ -#define DRIVER_NAME "HID-SENSOR-200083" - enum magn_3d_channel { CHANNEL_SCAN_INDEX_X, CHANNEL_SCAN_INDEX_Y, @@ -390,9 +386,19 @@ static int hid_magn_3d_remove(struct platform_device *pdev) return 0; } +static struct platform_device_id hid_magn_3d_ids[] = { + { + /* Format: HID-SENSOR-usage_id_in_hex_lowercase */ + .name = "HID-SENSOR-200083", + }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(platform, hid_magn_3d_ids); + static struct platform_driver hid_magn_3d_platform_driver = { + .id_table = hid_magn_3d_ids, .driver = { - .name = DRIVER_NAME, + .name = KBUILD_MODNAME, .owner = THIS_MODULE, }, .probe = hid_magn_3d_probe, -- GitLab From 4fd313da0430cb122d469abaadd5990f3d8af3f7 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Fri, 12 Jul 2013 20:54:00 +0100 Subject: [PATCH 489/942] iio:dac:mcp4725 wrong return type of attribute _show function Should be ssize_t and is int. Signed-off-by: Jonathan Cameron Reported-by: Fengguan Wu Acked-by: Peter Meerwald --- drivers/iio/dac/mcp4725.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/dac/mcp4725.c b/drivers/iio/dac/mcp4725.c index f569738c94b1f..18a78cd21e883 100644 --- a/drivers/iio/dac/mcp4725.c +++ b/drivers/iio/dac/mcp4725.c @@ -69,7 +69,7 @@ static SIMPLE_DEV_PM_OPS(mcp4725_pm_ops, mcp4725_suspend, mcp4725_resume); #define MCP4725_PM_OPS NULL #endif -static int mcp4725_store_eeprom(struct device *dev, +static ssize_t mcp4725_store_eeprom(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); -- GitLab From 3edc84e6054616b87a3d155fe65fa51f2eae82aa Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 15 Jul 2013 08:45:00 +0100 Subject: [PATCH 490/942] iio: Add a comment to about alphabetical order to Kconfigs and Makefiles Keeping Makefile and Kconfig entries in alphabetical order usually works better than just appending new entries at the end, since it reduces the amount of conflicts. This patch adds a comment to the IIO Kconfig and Makefile files to document that the entries should be kept in alphabetical order. Also reorder those entries which weren't in alphabetical order yet. Signed-off-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/iio/accel/Kconfig | 16 +++++++------ drivers/iio/accel/Makefile | 4 ++-- drivers/iio/adc/Kconfig | 36 +++++++++++++++-------------- drivers/iio/adc/Makefile | 1 + drivers/iio/amplifiers/Kconfig | 2 ++ drivers/iio/amplifiers/Makefile | 1 + drivers/iio/common/Makefile | 1 + drivers/iio/dac/Kconfig | 38 ++++++++++++++++--------------- drivers/iio/dac/Makefile | 1 + drivers/iio/frequency/Kconfig | 1 + drivers/iio/frequency/Makefile | 1 + drivers/iio/gyro/Kconfig | 2 ++ drivers/iio/gyro/Makefile | 1 + drivers/iio/imu/Kconfig | 2 ++ drivers/iio/imu/Makefile | 1 + drivers/iio/light/Kconfig | 24 ++++++++++--------- drivers/iio/light/Makefile | 3 ++- drivers/iio/magnetometer/Kconfig | 2 ++ drivers/iio/magnetometer/Makefile | 1 + drivers/iio/pressure/Kconfig | 2 ++ drivers/iio/pressure/Makefile | 1 + drivers/iio/trigger/Kconfig | 2 ++ drivers/iio/trigger/Makefile | 1 + 23 files changed, 88 insertions(+), 56 deletions(-) diff --git a/drivers/iio/accel/Kconfig b/drivers/iio/accel/Kconfig index a00267525b661..61ca7ec0f3e71 100644 --- a/drivers/iio/accel/Kconfig +++ b/drivers/iio/accel/Kconfig @@ -1,6 +1,8 @@ # # Accelerometer drivers # +# When adding new entries keep the list in alphabetical order + menu "Accelerometers" config HID_SENSOR_ACCEL_3D @@ -14,13 +16,6 @@ config HID_SENSOR_ACCEL_3D Say yes here to build support for the HID SENSOR accelerometers 3D. -config KXSD9 - tristate "Kionix KXSD9 Accelerometer Driver" - depends on SPI - help - Say yes here to build support for the Kionix KXSD9 accelerometer. - Currently this only supports the device via an SPI interface. - config IIO_ST_ACCEL_3AXIS tristate "STMicroelectronics accelerometers 3-Axis Driver" depends on (I2C || SPI_MASTER) && SYSFS @@ -51,4 +46,11 @@ config IIO_ST_ACCEL_SPI_3AXIS depends on IIO_ST_ACCEL_3AXIS depends on IIO_ST_SENSORS_SPI +config KXSD9 + tristate "Kionix KXSD9 Accelerometer Driver" + depends on SPI + help + Say yes here to build support for the Kionix KXSD9 accelerometer. + Currently this only supports the device via an SPI interface. + endmenu diff --git a/drivers/iio/accel/Makefile b/drivers/iio/accel/Makefile index 87d8fa264894f..2f95a3dffa474 100644 --- a/drivers/iio/accel/Makefile +++ b/drivers/iio/accel/Makefile @@ -2,7 +2,9 @@ # Makefile for industrial I/O accelerometer drivers # +# When adding new entries keep the list in alphabetical order obj-$(CONFIG_HID_SENSOR_ACCEL_3D) += hid-sensor-accel-3d.o +obj-$(CONFIG_KXSD9) += kxsd9.o obj-$(CONFIG_IIO_ST_ACCEL_3AXIS) += st_accel.o st_accel-y := st_accel_core.o @@ -10,5 +12,3 @@ st_accel-$(CONFIG_IIO_BUFFER) += st_accel_buffer.o obj-$(CONFIG_IIO_ST_ACCEL_I2C_3AXIS) += st_accel_i2c.o obj-$(CONFIG_IIO_ST_ACCEL_SPI_3AXIS) += st_accel_spi.o - -obj-$(CONFIG_KXSD9) += kxsd9.o diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index 2eced9d53a0b5..dd6bd1bff4b7e 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -1,6 +1,8 @@ # # ADC drivers # +# When adding new entries keep the list in alphabetical order + menu "Analog to digital converters" config AD_SIGMA_DELTA @@ -30,17 +32,20 @@ config AD7298 To compile this driver as a module, choose M here: the module will be called ad7298. -config AD7923 - tristate "Analog Devices AD7923 and similar ADCs driver" +config AD7476 + tristate "Analog Devices AD7476 and similar 1-channel ADCs driver" depends on SPI select IIO_BUFFER select IIO_TRIGGERED_BUFFER help - Say yes here to build support for Analog Devices - AD7904, AD7914, AD7923, AD7924 4 Channel ADCs. + Say yes here to build support for Analog Devices AD7273, AD7274, AD7276, + AD7277, AD7278, AD7475, AD7476, AD7477, AD7478, AD7466, AD7467, AD7468, + AD7495, AD7910, AD7920, AD7920 SPI analog to digital converters (ADC). + + If unsure, say N (but it's safe to say "Y"). To compile this driver as a module, choose M here: the - module will be called ad7923. + module will be called ad7476. config AD7791 tristate "Analog Devices AD7791 ADC driver" @@ -66,33 +71,30 @@ config AD7793 To compile this driver as a module, choose M here: the module will be called AD7793. -config AD7476 - tristate "Analog Devices AD7476 and similar 1-channel ADCs driver" +config AD7887 + tristate "Analog Devices AD7887 ADC driver" depends on SPI select IIO_BUFFER select IIO_TRIGGERED_BUFFER help - Say yes here to build support for Analog Devices AD7273, AD7274, AD7276, - AD7277, AD7278, AD7475, AD7476, AD7477, AD7478, AD7466, AD7467, AD7468, - AD7495, AD7910, AD7920, AD7920 SPI analog to digital converters (ADC). - + Say yes here to build support for Analog Devices + AD7887 SPI analog to digital converter (ADC). If unsure, say N (but it's safe to say "Y"). To compile this driver as a module, choose M here: the - module will be called ad7476. + module will be called ad7887. -config AD7887 - tristate "Analog Devices AD7887 ADC driver" +config AD7923 + tristate "Analog Devices AD7923 and similar ADCs driver" depends on SPI select IIO_BUFFER select IIO_TRIGGERED_BUFFER help Say yes here to build support for Analog Devices - AD7887 SPI analog to digital converter (ADC). - If unsure, say N (but it's safe to say "Y"). + AD7904, AD7914, AD7923, AD7924 4 Channel ADCs. To compile this driver as a module, choose M here: the - module will be called ad7887. + module will be called ad7923. config AT91_ADC tristate "Atmel AT91 ADC" diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile index d184139d1cd78..2a4324ec7f14a 100644 --- a/drivers/iio/adc/Makefile +++ b/drivers/iio/adc/Makefile @@ -2,6 +2,7 @@ # Makefile for IIO ADC drivers # +# When adding new entries keep the list in alphabetical order obj-$(CONFIG_AD_SIGMA_DELTA) += ad_sigma_delta.o obj-$(CONFIG_AD7266) += ad7266.o obj-$(CONFIG_AD7298) += ad7298.o diff --git a/drivers/iio/amplifiers/Kconfig b/drivers/iio/amplifiers/Kconfig index 05d707ed7d4f9..e9c5f2cd92571 100644 --- a/drivers/iio/amplifiers/Kconfig +++ b/drivers/iio/amplifiers/Kconfig @@ -1,6 +1,8 @@ # # Gain Amplifiers, etc. # +# When adding new entries keep the list in alphabetical order + menu "Amplifiers" config AD8366 diff --git a/drivers/iio/amplifiers/Makefile b/drivers/iio/amplifiers/Makefile index a6ca366908e07..8da4b787898a9 100644 --- a/drivers/iio/amplifiers/Makefile +++ b/drivers/iio/amplifiers/Makefile @@ -2,4 +2,5 @@ # Makefile iio/amplifiers # +# When adding new entries keep the list in alphabetical order obj-$(CONFIG_AD8366) += ad8366.o diff --git a/drivers/iio/common/Makefile b/drivers/iio/common/Makefile index c2352beb5d973..3112df0060e91 100644 --- a/drivers/iio/common/Makefile +++ b/drivers/iio/common/Makefile @@ -6,5 +6,6 @@ # instead of duplicating in each module. # +# When adding new entries keep the list in alphabetical order obj-y += hid-sensors/ obj-y += st_sensors/ diff --git a/drivers/iio/dac/Kconfig b/drivers/iio/dac/Kconfig index b9fd4c7bfd982..3c6a78a75b788 100644 --- a/drivers/iio/dac/Kconfig +++ b/drivers/iio/dac/Kconfig @@ -1,6 +1,8 @@ # # DAC drivers # +# When adding new entries keep the list in alphabetical order + menu "Digital to analog converters" config AD5064 @@ -48,13 +50,6 @@ config AD5421 To compile this driver as module choose M here: the module will be called ad5421. -config AD5624R_SPI - tristate "Analog Devices AD5624/44/64R DAC spi driver" - depends on SPI - help - Say yes here to build support for Analog Devices AD5624R, AD5644R and - AD5664R converters (DAC). This driver uses the common SPI interface. - config AD5446 tristate "Analog Devices AD5446 and similar single channel DACs driver" depends on (SPI_MASTER && I2C!=m) || I2C @@ -87,6 +82,24 @@ config AD5504 To compile this driver as a module, choose M here: the module will be called ad5504. +config AD5624R_SPI + tristate "Analog Devices AD5624/44/64R DAC spi driver" + depends on SPI + help + Say yes here to build support for Analog Devices AD5624R, AD5644R and + AD5664R converters (DAC). This driver uses the common SPI interface. + +config AD5686 + tristate "Analog Devices AD5686R/AD5685R/AD5684R DAC SPI driver" + depends on SPI + help + Say yes here to build support for Analog Devices AD5686R, AD5685R, + AD5684R, AD5791 Voltage Output Digital to + Analog Converter. + + To compile this driver as a module, choose M here: the + module will be called ad5686. + config AD5755 tristate "Analog Devices AD5755/AD5755-1/AD5757/AD5735/AD5737 DAC driver" depends on SPI_MASTER @@ -119,17 +132,6 @@ config AD5791 To compile this driver as a module, choose M here: the module will be called ad5791. -config AD5686 - tristate "Analog Devices AD5686R/AD5685R/AD5684R DAC SPI driver" - depends on SPI - help - Say yes here to build support for Analog Devices AD5686R, AD5685R, - AD5684R, AD5791 Voltage Output Digital to - Analog Converter. - - To compile this driver as a module, choose M here: the - module will be called ad5686. - config AD7303 tristate "Analog Devices AD7303 DAC driver" depends on SPI diff --git a/drivers/iio/dac/Makefile b/drivers/iio/dac/Makefile index c8d7ab6bff01b..bb84ad64463f7 100644 --- a/drivers/iio/dac/Makefile +++ b/drivers/iio/dac/Makefile @@ -2,6 +2,7 @@ # Makefile for industrial I/O DAC drivers # +# When adding new entries keep the list in alphabetical order obj-$(CONFIG_AD5360) += ad5360.o obj-$(CONFIG_AD5380) += ad5380.o obj-$(CONFIG_AD5421) += ad5421.o diff --git a/drivers/iio/frequency/Kconfig b/drivers/iio/frequency/Kconfig index 6aaa33ef4544a..dc5e0b72882fa 100644 --- a/drivers/iio/frequency/Kconfig +++ b/drivers/iio/frequency/Kconfig @@ -4,6 +4,7 @@ # Clock Distribution device drivers # Phase-Locked Loop (PLL) frequency synthesizers # +# When adding new entries keep the list in alphabetical order menu "Frequency Synthesizers DDS/PLL" diff --git a/drivers/iio/frequency/Makefile b/drivers/iio/frequency/Makefile index 00d26e5d1dc2d..2bca03f3e2e3d 100644 --- a/drivers/iio/frequency/Makefile +++ b/drivers/iio/frequency/Makefile @@ -2,5 +2,6 @@ # Makefile iio/frequency # +# When adding new entries keep the list in alphabetical order obj-$(CONFIG_AD9523) += ad9523.o obj-$(CONFIG_ADF4350) += adf4350.o diff --git a/drivers/iio/gyro/Kconfig b/drivers/iio/gyro/Kconfig index 1fdcc8451fdf0..5913735bca9a3 100644 --- a/drivers/iio/gyro/Kconfig +++ b/drivers/iio/gyro/Kconfig @@ -1,6 +1,8 @@ # # IIO Digital Gyroscope Sensor drivers configuration # +# When adding new entries keep the list in alphabetical order + menu "Digital gyroscope sensors" config ADIS16080 diff --git a/drivers/iio/gyro/Makefile b/drivers/iio/gyro/Makefile index e9dc034aa18bc..36091d5a0f45e 100644 --- a/drivers/iio/gyro/Makefile +++ b/drivers/iio/gyro/Makefile @@ -2,6 +2,7 @@ # Makefile for industrial I/O gyroscope sensor drivers # +# When adding new entries keep the list in alphabetical order obj-$(CONFIG_ADIS16080) += adis16080.o obj-$(CONFIG_ADIS16130) += adis16130.o obj-$(CONFIG_ADIS16136) += adis16136.o diff --git a/drivers/iio/imu/Kconfig b/drivers/iio/imu/Kconfig index 4f40a10cb74f4..663e88a1a3c13 100644 --- a/drivers/iio/imu/Kconfig +++ b/drivers/iio/imu/Kconfig @@ -1,6 +1,8 @@ # # IIO imu drivers configuration # +# When adding new entries keep the list in alphabetical order + menu "Inertial measurement units" config ADIS16400 diff --git a/drivers/iio/imu/Makefile b/drivers/iio/imu/Makefile index f2f56ceaed26a..114d2c17cbe20 100644 --- a/drivers/iio/imu/Makefile +++ b/drivers/iio/imu/Makefile @@ -2,6 +2,7 @@ # Makefile for Inertial Measurement Units # +# When adding new entries keep the list in alphabetical order adis16400-y := adis16400_core.o adis16400-$(CONFIG_IIO_BUFFER) += adis16400_buffer.o obj-$(CONFIG_ADIS16400) += adis16400.o diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig index 5ef1a396e0c9b..3bd29f810e6df 100644 --- a/drivers/iio/light/Kconfig +++ b/drivers/iio/light/Kconfig @@ -1,6 +1,8 @@ # # Light sensors # +# When adding new entries keep the list in alphabetical order + menu "Light sensors" config ADJD_S311 @@ -15,6 +17,17 @@ config ADJD_S311 This driver can also be built as a module. If so, the module will be called adjd_s311. +config HID_SENSOR_ALS + depends on HID_SENSOR_HUB + select IIO_BUFFER + select IIO_TRIGGERED_BUFFER + select HID_SENSOR_IIO_COMMON + select HID_SENSOR_IIO_TRIGGER + tristate "HID ALS" + help + Say yes here to build support for the HID SENSOR + Ambient light sensor. + config SENSORS_LM3533 tristate "LM3533 ambient light sensor" depends on MFD_LM3533 @@ -52,15 +65,4 @@ config VCNL4000 To compile this driver as a module, choose M here: the module will be called vcnl4000. -config HID_SENSOR_ALS - depends on HID_SENSOR_HUB - select IIO_BUFFER - select IIO_TRIGGERED_BUFFER - select HID_SENSOR_IIO_COMMON - select HID_SENSOR_IIO_TRIGGER - tristate "HID ALS" - help - Say yes here to build support for the HID SENSOR - Ambient light sensor. - endmenu diff --git a/drivers/iio/light/Makefile b/drivers/iio/light/Makefile index 040d9c75f8e62..edef939861f02 100644 --- a/drivers/iio/light/Makefile +++ b/drivers/iio/light/Makefile @@ -2,8 +2,9 @@ # Makefile for IIO Light sensors # +# When adding new entries keep the list in alphabetical order obj-$(CONFIG_ADJD_S311) += adjd_s311.o +obj-$(CONFIG_HID_SENSOR_ALS) += hid-sensor-als.o obj-$(CONFIG_SENSORS_LM3533) += lm3533-als.o obj-$(CONFIG_SENSORS_TSL2563) += tsl2563.o obj-$(CONFIG_VCNL4000) += vcnl4000.o -obj-$(CONFIG_HID_SENSOR_ALS) += hid-sensor-als.o diff --git a/drivers/iio/magnetometer/Kconfig b/drivers/iio/magnetometer/Kconfig index 4d55b1b851b31..4fa923f37b971 100644 --- a/drivers/iio/magnetometer/Kconfig +++ b/drivers/iio/magnetometer/Kconfig @@ -1,6 +1,8 @@ # # Magnetometer sensors # +# When adding new entries keep the list in alphabetical order + menu "Magnetometer sensors" config AK8975 diff --git a/drivers/iio/magnetometer/Makefile b/drivers/iio/magnetometer/Makefile index 7f328e37fbab0..f91b1b68d3924 100644 --- a/drivers/iio/magnetometer/Makefile +++ b/drivers/iio/magnetometer/Makefile @@ -2,6 +2,7 @@ # Makefile for industrial I/O Magnetometer sensor drivers # +# When adding new entries keep the list in alphabetical order obj-$(CONFIG_AK8975) += ak8975.o obj-$(CONFIG_HID_SENSOR_MAGNETOMETER_3D) += hid-sensor-magn-3d.o diff --git a/drivers/iio/pressure/Kconfig b/drivers/iio/pressure/Kconfig index 56ae8905c8e11..26fdc0bdb99d5 100644 --- a/drivers/iio/pressure/Kconfig +++ b/drivers/iio/pressure/Kconfig @@ -1,6 +1,8 @@ # # Pressure drivers # +# When adding new entries keep the list in alphabetical order + menu "Pressure sensors" config IIO_ST_PRESS diff --git a/drivers/iio/pressure/Makefile b/drivers/iio/pressure/Makefile index d4bb33e5c8461..be71464c27525 100644 --- a/drivers/iio/pressure/Makefile +++ b/drivers/iio/pressure/Makefile @@ -2,6 +2,7 @@ # Makefile for industrial I/O pressure drivers # +# When adding new entries keep the list in alphabetical order obj-$(CONFIG_IIO_ST_PRESS) += st_pressure.o st_pressure-y := st_pressure_core.o st_pressure-$(CONFIG_IIO_BUFFER) += st_pressure_buffer.o diff --git a/drivers/iio/trigger/Kconfig b/drivers/iio/trigger/Kconfig index 0a4a5164963f6..79996123a71b9 100644 --- a/drivers/iio/trigger/Kconfig +++ b/drivers/iio/trigger/Kconfig @@ -1,6 +1,8 @@ # # Industrial I/O standalone triggers # +# When adding new entries keep the list in alphabetical order + menu "Triggers - standalone" config IIO_INTERRUPT_TRIGGER diff --git a/drivers/iio/trigger/Makefile b/drivers/iio/trigger/Makefile index ce319a51b6afb..0694daecaf228 100644 --- a/drivers/iio/trigger/Makefile +++ b/drivers/iio/trigger/Makefile @@ -2,5 +2,6 @@ # Makefile for triggers not associated with iio-devices # +# When adding new entries keep the list in alphabetical order obj-$(CONFIG_IIO_INTERRUPT_TRIGGER) += iio-trig-interrupt.o obj-$(CONFIG_IIO_SYSFS_TRIGGER) += iio-trig-sysfs.o -- GitLab From 98a5e9e99d05e9b6a14778b85631b55e8e349990 Mon Sep 17 00:00:00 2001 From: Otavio Salvador Date: Tue, 16 Jul 2013 13:56:00 +0100 Subject: [PATCH 491/942] iio: add configuration option for debug support Signed-off-by: Otavio Salvador Signed-off-by: Jonathan Cameron --- drivers/iio/Kconfig | 7 +++++++ drivers/iio/Makefile | 2 ++ 2 files changed, 9 insertions(+) diff --git a/drivers/iio/Kconfig b/drivers/iio/Kconfig index 524380c9ae6cb..b682f6f545017 100644 --- a/drivers/iio/Kconfig +++ b/drivers/iio/Kconfig @@ -12,6 +12,13 @@ menuconfig IIO if IIO +config IIO_DEBUG + boolean "Debug support for Industrial I/O" + depends on DEBUG_KERNEL + help + Say "yes" to enable debug messaging (like dev_dbg and pr_debug) + support in Industrial I/O subsystem and drivers. + config IIO_BUFFER bool "Enable buffer support within IIO" help diff --git a/drivers/iio/Makefile b/drivers/iio/Makefile index 7a3866c2d2a14..6e43e5b8d4ed2 100644 --- a/drivers/iio/Makefile +++ b/drivers/iio/Makefile @@ -2,6 +2,8 @@ # Makefile for the industrial I/O core. # +ccflags-$(CONFIG_IIO_DEBUG) := -DDEBUG + obj-$(CONFIG_IIO) += industrialio.o industrialio-y := industrialio-core.o industrialio-event.o inkern.o industrialio-$(CONFIG_IIO_BUFFER) += industrialio-buffer.o -- GitLab From be8309d69991956def20c86c3902ca46f9490e7b Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 16 Jul 2013 16:08:00 +0100 Subject: [PATCH 492/942] staging:iio:ad2s1210: Don't expose the chip reset to userspace There is no reason why userspace should want to trigger a manual reset of the device, so remove this functionality. Signed-off-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/staging/iio/resolver/ad2s1210.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c index 0d3356d4b7d2e..dcdadbbcf7e86 100644 --- a/drivers/staging/iio/resolver/ad2s1210.c +++ b/drivers/staging/iio/resolver/ad2s1210.c @@ -192,21 +192,6 @@ static inline int ad2s1210_soft_reset(struct ad2s1210_state *st) return ad2s1210_config_write(st, 0x0); } -static ssize_t ad2s1210_store_softreset(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev)); - int ret; - - mutex_lock(&st->lock); - ret = ad2s1210_soft_reset(st); - mutex_unlock(&st->lock); - - return ret < 0 ? ret : len; -} - static ssize_t ad2s1210_show_fclkin(struct device *dev, struct device_attribute *attr, char *buf) @@ -536,8 +521,6 @@ static int ad2s1210_read_raw(struct iio_dev *indio_dev, return ret; } -static IIO_DEVICE_ATTR(reset, S_IWUSR, - NULL, ad2s1210_store_softreset, 0); static IIO_DEVICE_ATTR(fclkin, S_IRUGO | S_IWUSR, ad2s1210_show_fclkin, ad2s1210_store_fclkin, 0); static IIO_DEVICE_ATTR(fexcit, S_IRUGO | S_IWUSR, @@ -587,7 +570,6 @@ static const struct iio_chan_spec ad2s1210_channels[] = { }; static struct attribute *ad2s1210_attributes[] = { - &iio_dev_attr_reset.dev_attr.attr, &iio_dev_attr_fclkin.dev_attr.attr, &iio_dev_attr_fexcit.dev_attr.attr, &iio_dev_attr_control.dev_attr.attr, -- GitLab From aae6e9eb9560dc5c80add68450a4319f9ff44f13 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 16 Jul 2013 16:08:00 +0100 Subject: [PATCH 493/942] staging:iio:adt7316: Don't expose the chip reset to userspace There is no reason why userspace should want to trigger a manual reset of the device, so remove this functionality. Signed-off-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/staging/iio/addac/adt7316.c | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index 506b5a7d96c88..1e1356825d6da 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -551,31 +551,6 @@ static IIO_DEVICE_ATTR(enable_smbus_timeout, S_IRUGO | S_IWUSR, adt7316_store_enable_smbus_timeout, 0); - -static ssize_t adt7316_store_reset(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) -{ - struct iio_dev *dev_info = dev_to_iio_dev(dev); - struct adt7316_chip_info *chip = iio_priv(dev_info); - u8 config2; - int ret; - - config2 = chip->config2 | ADT7316_RESET; - - ret = chip->bus.write(chip->bus.client, ADT7316_CONFIG2, config2); - if (ret) - return -EIO; - - return len; -} - -static IIO_DEVICE_ATTR(reset, S_IWUSR, - NULL, - adt7316_store_reset, - 0); - static ssize_t adt7316_show_powerdown(struct device *dev, struct device_attribute *attr, char *buf) @@ -1675,7 +1650,6 @@ static IIO_DEVICE_ATTR(bus_type, S_IRUGO, adt7316_show_bus_type, NULL, 0); static struct attribute *adt7316_attributes[] = { &iio_dev_attr_all_modes.dev_attr.attr, &iio_dev_attr_mode.dev_attr.attr, - &iio_dev_attr_reset.dev_attr.attr, &iio_dev_attr_enabled.dev_attr.attr, &iio_dev_attr_ad_channel.dev_attr.attr, &iio_dev_attr_all_ad_channels.dev_attr.attr, @@ -1719,7 +1693,6 @@ static struct attribute *adt7516_attributes[] = { &iio_dev_attr_all_modes.dev_attr.attr, &iio_dev_attr_mode.dev_attr.attr, &iio_dev_attr_select_ex_temp.dev_attr.attr, - &iio_dev_attr_reset.dev_attr.attr, &iio_dev_attr_enabled.dev_attr.attr, &iio_dev_attr_ad_channel.dev_attr.attr, &iio_dev_attr_all_ad_channels.dev_attr.attr, -- GitLab From 661a60b143216ac92a44c796070ec0cff28612db Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 16 Jul 2013 16:08:00 +0100 Subject: [PATCH 494/942] staging:iio:ade7xxx: Don't expose the chip reset to userspace There is no reason why userspace should want to trigger a manual reset of the device, so remove this functionality. Signed-off-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/staging/iio/meter/ade7753.c | 18 ------------------ drivers/staging/iio/meter/ade7754.c | 19 ------------------- drivers/staging/iio/meter/ade7758_core.c | 18 ------------------ drivers/staging/iio/meter/ade7759.c | 18 ------------------ drivers/staging/iio/meter/ade7854.c | 19 ------------------- 5 files changed, 92 deletions(-) diff --git a/drivers/staging/iio/meter/ade7753.c b/drivers/staging/iio/meter/ade7753.c index e5943e2287cfb..74025fbae6794 100644 --- a/drivers/staging/iio/meter/ade7753.c +++ b/drivers/staging/iio/meter/ade7753.c @@ -225,21 +225,6 @@ static int ade7753_reset(struct device *dev) return ade7753_spi_write_reg_16(dev, ADE7753_MODE, val); } -static ssize_t ade7753_write_reset(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t len) -{ - if (len < 1) - return -1; - switch (buf[0]) { - case '1': - case 'y': - case 'Y': - return ade7753_reset(dev); - } - return -1; -} - static IIO_DEV_ATTR_AENERGY(ade7753_read_24bit, ADE7753_AENERGY); static IIO_DEV_ATTR_LAENERGY(ade7753_read_24bit, ADE7753_LAENERGY); static IIO_DEV_ATTR_VAENERGY(ade7753_read_24bit, ADE7753_VAENERGY); @@ -458,8 +443,6 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO, ade7753_read_frequency, ade7753_write_frequency); -static IIO_DEV_ATTR_RESET(ade7753_write_reset); - static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("27900 14000 7000 3500"); static struct attribute *ade7753_attributes[] = { @@ -468,7 +451,6 @@ static struct attribute *ade7753_attributes[] = { &iio_const_attr_in_temp_scale.dev_attr.attr, &iio_dev_attr_sampling_frequency.dev_attr.attr, &iio_const_attr_sampling_frequency_available.dev_attr.attr, - &iio_dev_attr_reset.dev_attr.attr, &iio_dev_attr_phcal.dev_attr.attr, &iio_dev_attr_cfden.dev_attr.attr, &iio_dev_attr_aenergy.dev_attr.attr, diff --git a/drivers/staging/iio/meter/ade7754.c b/drivers/staging/iio/meter/ade7754.c index 7b6503bf9a74e..f649ebe55a04d 100644 --- a/drivers/staging/iio/meter/ade7754.c +++ b/drivers/staging/iio/meter/ade7754.c @@ -224,22 +224,6 @@ static int ade7754_reset(struct device *dev) return ade7754_spi_write_reg_8(dev, ADE7754_OPMODE, val); } - -static ssize_t ade7754_write_reset(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t len) -{ - if (len < 1) - return -1; - switch (buf[0]) { - case '1': - case 'y': - case 'Y': - return ade7754_reset(dev); - } - return -1; -} - static IIO_DEV_ATTR_AENERGY(ade7754_read_24bit, ADE7754_AENERGY); static IIO_DEV_ATTR_LAENERGY(ade7754_read_24bit, ADE7754_LAENERGY); static IIO_DEV_ATTR_VAENERGY(ade7754_read_24bit, ADE7754_VAENERGY); @@ -478,8 +462,6 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO, ade7754_read_frequency, ade7754_write_frequency); -static IIO_DEV_ATTR_RESET(ade7754_write_reset); - static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("26000 13000 65000 33000"); static struct attribute *ade7754_attributes[] = { @@ -488,7 +470,6 @@ static struct attribute *ade7754_attributes[] = { &iio_const_attr_in_temp_scale.dev_attr.attr, &iio_dev_attr_sampling_frequency.dev_attr.attr, &iio_const_attr_sampling_frequency_available.dev_attr.attr, - &iio_dev_attr_reset.dev_attr.attr, &iio_dev_attr_aenergy.dev_attr.attr, &iio_dev_attr_laenergy.dev_attr.attr, &iio_dev_attr_vaenergy.dev_attr.attr, diff --git a/drivers/staging/iio/meter/ade7758_core.c b/drivers/staging/iio/meter/ade7758_core.c index 8f5bcfab3563a..6005d4aab0c34 100644 --- a/drivers/staging/iio/meter/ade7758_core.c +++ b/drivers/staging/iio/meter/ade7758_core.c @@ -313,21 +313,6 @@ static int ade7758_reset(struct device *dev) return ret; } -static ssize_t ade7758_write_reset(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t len) -{ - if (len < 1) - return -1; - switch (buf[0]) { - case '1': - case 'y': - case 'Y': - return ade7758_reset(dev); - } - return len; -} - static IIO_DEV_ATTR_VPEAK(S_IWUSR | S_IRUGO, ade7758_read_8bit, ade7758_write_8bit, @@ -591,8 +576,6 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO, ade7758_read_frequency, ade7758_write_frequency); -static IIO_DEV_ATTR_RESET(ade7758_write_reset); - static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("26040 13020 6510 3255"); static struct attribute *ade7758_attributes[] = { @@ -601,7 +584,6 @@ static struct attribute *ade7758_attributes[] = { &iio_const_attr_in_temp_scale.dev_attr.attr, &iio_dev_attr_sampling_frequency.dev_attr.attr, &iio_const_attr_sampling_frequency_available.dev_attr.attr, - &iio_dev_attr_reset.dev_attr.attr, &iio_dev_attr_awatthr.dev_attr.attr, &iio_dev_attr_bwatthr.dev_attr.attr, &iio_dev_attr_cwatthr.dev_attr.attr, diff --git a/drivers/staging/iio/meter/ade7759.c b/drivers/staging/iio/meter/ade7759.c index 17dc373e1082f..d214ac4932cbe 100644 --- a/drivers/staging/iio/meter/ade7759.c +++ b/drivers/staging/iio/meter/ade7759.c @@ -229,21 +229,6 @@ static int ade7759_reset(struct device *dev) return ret; } -static ssize_t ade7759_write_reset(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t len) -{ - if (len < 1) - return -1; - switch (buf[0]) { - case '1': - case 'y': - case 'Y': - return ade7759_reset(dev); - } - return -1; -} - static IIO_DEV_ATTR_AENERGY(ade7759_read_40bit, ADE7759_AENERGY); static IIO_DEV_ATTR_CFDEN(S_IWUSR | S_IRUGO, ade7759_read_16bit, @@ -418,8 +403,6 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO, ade7759_read_frequency, ade7759_write_frequency); -static IIO_DEV_ATTR_RESET(ade7759_write_reset); - static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("27900 14000 7000 3500"); static struct attribute *ade7759_attributes[] = { @@ -428,7 +411,6 @@ static struct attribute *ade7759_attributes[] = { &iio_const_attr_in_temp_scale.dev_attr.attr, &iio_dev_attr_sampling_frequency.dev_attr.attr, &iio_const_attr_sampling_frequency_available.dev_attr.attr, - &iio_dev_attr_reset.dev_attr.attr, &iio_dev_attr_phcal.dev_attr.attr, &iio_dev_attr_cfden.dev_attr.attr, &iio_dev_attr_aenergy.dev_attr.attr, diff --git a/drivers/staging/iio/meter/ade7854.c b/drivers/staging/iio/meter/ade7854.c index c642da84842a5..e8379c0f1173f 100644 --- a/drivers/staging/iio/meter/ade7854.c +++ b/drivers/staging/iio/meter/ade7854.c @@ -186,22 +186,6 @@ static int ade7854_reset(struct device *dev) return st->write_reg_16(dev, ADE7854_CONFIG, val); } - -static ssize_t ade7854_write_reset(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t len) -{ - if (len < 1) - return -1; - switch (buf[0]) { - case '1': - case 'y': - case 'Y': - return ade7854_reset(dev); - } - return -1; -} - static IIO_DEV_ATTR_AIGAIN(S_IWUSR | S_IRUGO, ade7854_read_24bit, ade7854_write_24bit, @@ -468,8 +452,6 @@ static int ade7854_initial_setup(struct iio_dev *indio_dev) return ret; } -static IIO_DEV_ATTR_RESET(ade7854_write_reset); - static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("8000"); static IIO_CONST_ATTR(name, "ade7854"); @@ -515,7 +497,6 @@ static struct attribute *ade7854_attributes[] = { &iio_dev_attr_bvahr.dev_attr.attr, &iio_dev_attr_cvahr.dev_attr.attr, &iio_const_attr_sampling_frequency_available.dev_attr.attr, - &iio_dev_attr_reset.dev_attr.attr, &iio_const_attr_name.dev_attr.attr, &iio_dev_attr_vpeak.dev_attr.attr, &iio_dev_attr_ipeak.dev_attr.attr, -- GitLab From 60b188f0d679656a1a2603d3bc1fa005373f4b9c Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 16 Jul 2013 16:08:00 +0100 Subject: [PATCH 495/942] iio: Remove IIO_DEV_ATTR_RESET macro There are no users of this macro left and we have come to the conclusion that it is not a good idea to expose the raw chip reset to userspace so the macro is very unlikely to be used in new drivers. Signed-off-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- include/linux/iio/sysfs.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/include/linux/iio/sysfs.h b/include/linux/iio/sysfs.h index b7a934b9431b5..2958c960003a7 100644 --- a/include/linux/iio/sysfs.h +++ b/include/linux/iio/sysfs.h @@ -73,11 +73,6 @@ struct iio_const_attr { .dev_attr = __ATTR(_name, S_IRUGO, iio_read_const_attr, NULL)} /* Generic attributes of onetype or another */ -/** - * IIO_DEV_ATTR_RESET: resets the device - **/ -#define IIO_DEV_ATTR_RESET(_store) \ - IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, _store, 0) /** * IIO_DEV_ATTR_SAMP_FREQ - sets any internal clock frequency -- GitLab From 9dabaf5eddbafa21aded7c063cb38d2e8936c237 Mon Sep 17 00:00:00 2001 From: Grygorii Strashko Date: Thu, 18 Jul 2013 11:19:00 +0100 Subject: [PATCH 496/942] iio: core: implement devm_iio_device_alloc/devm_iio_device_free Add a resource managed devm_iio_device_alloc()/devm_iio_device_free() to automatically clean up any allocations made by IIO drivers, thus leading to simplified IIO drivers code. In addition, this will allow IIO drivers to use other devm_*() API (like devm_request_irq) and don't care about the race between iio_device_free() and the release of resources by Device core during driver removing. Signed-off-by: Grygorii Strashko Signed-off-by: Oleksandr Kravchenko Tested-by: Oleksandr Kravchenko Reviewed-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/iio/industrialio-core.c | 47 +++++++++++++++++++++++++++++++++ include/linux/iio/iio.h | 25 ++++++++++++++++++ 2 files changed, 72 insertions(+) diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index e145931ef1b82..d56d1229e2d6f 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -912,6 +912,53 @@ void iio_device_free(struct iio_dev *dev) } EXPORT_SYMBOL(iio_device_free); +static void devm_iio_device_release(struct device *dev, void *res) +{ + iio_device_free(*(struct iio_dev **)res); +} + +static int devm_iio_device_match(struct device *dev, void *res, void *data) +{ + struct iio_dev **r = res; + if (!r || !*r) { + WARN_ON(!r || !*r); + return 0; + } + return *r == data; +} + +struct iio_dev *devm_iio_device_alloc(struct device *dev, int sizeof_priv) +{ + struct iio_dev **ptr, *iio_dev; + + ptr = devres_alloc(devm_iio_device_release, sizeof(*ptr), + GFP_KERNEL); + if (!ptr) + return NULL; + + /* use raw alloc_dr for kmalloc caller tracing */ + iio_dev = iio_device_alloc(sizeof_priv); + if (iio_dev) { + *ptr = iio_dev; + devres_add(dev, ptr); + } else { + devres_free(ptr); + } + + return iio_dev; +} +EXPORT_SYMBOL_GPL(devm_iio_device_alloc); + +void devm_iio_device_free(struct device *dev, struct iio_dev *iio_dev) +{ + int rc; + + rc = devres_release(dev, devm_iio_device_release, + devm_iio_device_match, iio_dev); + WARN_ON(rc); +} +EXPORT_SYMBOL_GPL(devm_iio_device_free); + /** * iio_chrdev_open() - chrdev file open for buffer access and ioctls **/ diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h index 3d35b7023591f..61d220f89aca4 100644 --- a/include/linux/iio/iio.h +++ b/include/linux/iio/iio.h @@ -531,6 +531,31 @@ static inline struct iio_dev *iio_priv_to_dev(void *priv) **/ void iio_device_free(struct iio_dev *indio_dev); +/** + * devm_iio_device_alloc - Resource-managed iio_device_alloc() + * @dev: Device to allocate iio_dev for + * @sizeof_priv: Space to allocate for private structure. + * + * Managed iio_device_alloc. iio_dev allocated with this function is + * automatically freed on driver detach. + * + * If an iio_dev allocated with this function needs to be freed separately, + * devm_iio_device_free() must be used. + * + * RETURNS: + * Pointer to allocated iio_dev on success, NULL on failure. + */ +struct iio_dev *devm_iio_device_alloc(struct device *dev, int sizeof_priv); + +/** + * devm_iio_device_free - Resource-managed iio_device_free() + * @dev: Device this iio_dev belongs to + * @indio_dev: the iio_dev associated with the device + * + * Free indio_dev allocated with devm_iio_device_alloc(). + */ +void devm_iio_device_free(struct device *dev, struct iio_dev *iio_dev); + /** * iio_buffer_enabled() - helper function to test if the buffer is enabled * @indio_dev: IIO device structure for device -- GitLab From e6faed19c20571a413e8ddeab4d4ea1825b8e633 Mon Sep 17 00:00:00 2001 From: Oleksandr Kravchenko Date: Mon, 22 Jul 2013 14:11:00 +0100 Subject: [PATCH 497/942] of: Add Avago Technologies vendor prefix This commit adds a device tree vendor prefix for Avago Technologies. Signed-off-by: Oleksandr Kravchenko Signed-off-by: Jonathan Cameron --- Documentation/devicetree/bindings/vendor-prefixes.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt index 366ce9b872407..ec4d713674fa4 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.txt +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt @@ -11,6 +11,7 @@ amcc Applied Micro Circuits Corporation (APM, formally AMCC) apm Applied Micro Circuits Corporation (APM) arm ARM Ltd. atmel Atmel Corporation +avago Avago Technologies bosch Bosch Sensortec GmbH brcm Broadcom Corporation cavium Cavium, Inc. -- GitLab From 03eff7b60dc3e5d2539a5f9685a9fb9a530e01e8 Mon Sep 17 00:00:00 2001 From: Oleksandr Kravchenko Date: Mon, 22 Jul 2013 14:11:00 +0100 Subject: [PATCH 498/942] iio: add APDS9300 ambilent light sensor driver This patch adds IIO driver for APDS9300 ambient light sensor (ALS). http://www.avagotech.com/docs/AV02-1077EN The driver allows to read raw data from ADC registers or calculate lux value. It also can handle threshold interrupt. Signed-off-by: Oleksandr Kravchenko Signed-off-by: Jonathan Cameron --- .../bindings/iio/light/apds9300.txt | 22 + drivers/iio/light/Kconfig | 10 + drivers/iio/light/Makefile | 1 + drivers/iio/light/apds9300.c | 512 ++++++++++++++++++ 4 files changed, 545 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/light/apds9300.txt create mode 100644 drivers/iio/light/apds9300.c diff --git a/Documentation/devicetree/bindings/iio/light/apds9300.txt b/Documentation/devicetree/bindings/iio/light/apds9300.txt new file mode 100644 index 0000000000000..d6f66c73ddbf7 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/light/apds9300.txt @@ -0,0 +1,22 @@ +* Avago APDS9300 ambient light sensor + +http://www.avagotech.com/docs/AV02-1077EN + +Required properties: + + - compatible : should be "avago,apds9300" + - reg : the I2C address of the sensor + +Optional properties: + + - interrupt-parent : should be the phandle for the interrupt controller + - interrupts : interrupt mapping for GPIO IRQ + +Example: + +apds9300@39 { + compatible = "avago,apds9300"; + reg = <0x39>; + interrupt-parent = <&gpio2>; + interrupts = <29 8>; +}; diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig index 3bd29f810e6df..bf9fa0d7aff9c 100644 --- a/drivers/iio/light/Kconfig +++ b/drivers/iio/light/Kconfig @@ -17,6 +17,16 @@ config ADJD_S311 This driver can also be built as a module. If so, the module will be called adjd_s311. +config APDS9300 + tristate "APDS9300 ambient light sensor" + depends on I2C + help + Say Y here if you want to build a driver for the Avago APDS9300 + ambient light sensor. + + To compile this driver as a module, choose M here: the + module will be called apds9300. + config HID_SENSOR_ALS depends on HID_SENSOR_HUB select IIO_BUFFER diff --git a/drivers/iio/light/Makefile b/drivers/iio/light/Makefile index edef939861f02..354ee9ab2379a 100644 --- a/drivers/iio/light/Makefile +++ b/drivers/iio/light/Makefile @@ -4,6 +4,7 @@ # When adding new entries keep the list in alphabetical order obj-$(CONFIG_ADJD_S311) += adjd_s311.o +obj-$(CONFIG_APDS9300) += apds9300.o obj-$(CONFIG_HID_SENSOR_ALS) += hid-sensor-als.o obj-$(CONFIG_SENSORS_LM3533) += lm3533-als.o obj-$(CONFIG_SENSORS_TSL2563) += tsl2563.o diff --git a/drivers/iio/light/apds9300.c b/drivers/iio/light/apds9300.c new file mode 100644 index 0000000000000..66a58bda6dc89 --- /dev/null +++ b/drivers/iio/light/apds9300.c @@ -0,0 +1,512 @@ +/* + * apds9300.c - IIO driver for Avago APDS9300 ambient light sensor + * + * Copyright 2013 Oleksandr Kravchenko + * + * This file is subject to the terms and conditions of version 2 of + * the GNU General Public License. See the file COPYING in the main + * directory of this archive for more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define APDS9300_DRV_NAME "apds9300" +#define APDS9300_IRQ_NAME "apds9300_event" + +/* Command register bits */ +#define APDS9300_CMD BIT(7) /* Select command register. Must write as 1 */ +#define APDS9300_WORD BIT(5) /* I2C write/read: if 1 word, if 0 byte */ +#define APDS9300_CLEAR BIT(6) /* Interrupt clear. Clears pending interrupt */ + +/* Register set */ +#define APDS9300_CONTROL 0x00 /* Control of basic functions */ +#define APDS9300_THRESHLOWLOW 0x02 /* Low byte of low interrupt threshold */ +#define APDS9300_THRESHHIGHLOW 0x04 /* Low byte of high interrupt threshold */ +#define APDS9300_INTERRUPT 0x06 /* Interrupt control */ +#define APDS9300_DATA0LOW 0x0c /* Low byte of ADC channel 0 */ +#define APDS9300_DATA1LOW 0x0e /* Low byte of ADC channel 1 */ + +/* Power on/off value for APDS9300_CONTROL register */ +#define APDS9300_POWER_ON 0x03 +#define APDS9300_POWER_OFF 0x00 + +/* Interrupts */ +#define APDS9300_INTR_ENABLE 0x10 +/* Interrupt Persist Function: Any value outside of threshold range */ +#define APDS9300_THRESH_INTR 0x01 + +#define APDS9300_THRESH_MAX 0xffff /* Max threshold value */ + +struct apds9300_data { + struct i2c_client *client; + struct mutex mutex; + int power_state; + int thresh_low; + int thresh_hi; + int intr_en; +}; + +/* Lux calculation */ + +/* Calculated values 1000 * (CH1/CH0)^1.4 for CH1/CH0 from 0 to 0.52 */ +static const u16 apds9300_lux_ratio[] = { + 0, 2, 4, 7, 11, 15, 19, 24, 29, 34, 40, 45, 51, 57, 64, 70, 77, 84, 91, + 98, 105, 112, 120, 128, 136, 144, 152, 160, 168, 177, 185, 194, 203, + 212, 221, 230, 239, 249, 258, 268, 277, 287, 297, 307, 317, 327, 337, + 347, 358, 368, 379, 390, 400, +}; + +static unsigned long apds9300_calculate_lux(u16 ch0, u16 ch1) +{ + unsigned long lux, tmp; + + /* avoid division by zero */ + if (ch0 == 0) + return 0; + + tmp = DIV_ROUND_UP(ch1 * 100, ch0); + if (tmp <= 52) { + lux = 3150 * ch0 - (unsigned long)DIV_ROUND_UP_ULL(ch0 + * apds9300_lux_ratio[tmp] * 5930ull, 1000); + } else if (tmp <= 65) { + lux = 2290 * ch0 - 2910 * ch1; + } else if (tmp <= 80) { + lux = 1570 * ch0 - 1800 * ch1; + } else if (tmp <= 130) { + lux = 338 * ch0 - 260 * ch1; + } else { + lux = 0; + } + + return lux / 100000; +} + +static int apds9300_get_adc_val(struct apds9300_data *data, int adc_number) +{ + int ret; + u8 flags = APDS9300_CMD | APDS9300_WORD; + + if (!data->power_state) + return -EBUSY; + + /* Select ADC0 or ADC1 data register */ + flags |= adc_number ? APDS9300_DATA1LOW : APDS9300_DATA0LOW; + + ret = i2c_smbus_read_word_data(data->client, flags); + if (ret < 0) + dev_err(&data->client->dev, + "failed to read ADC%d value\n", adc_number); + + return ret; +} + +static int apds9300_set_thresh_low(struct apds9300_data *data, int value) +{ + int ret; + + if (!data->power_state) + return -EBUSY; + + if (value > APDS9300_THRESH_MAX) + return -EINVAL; + + ret = i2c_smbus_write_word_data(data->client, APDS9300_THRESHLOWLOW + | APDS9300_CMD | APDS9300_WORD, value); + if (ret) { + dev_err(&data->client->dev, "failed to set thresh_low\n"); + return ret; + } + data->thresh_low = value; + + return 0; +} + +static int apds9300_set_thresh_hi(struct apds9300_data *data, int value) +{ + int ret; + + if (!data->power_state) + return -EBUSY; + + if (value > APDS9300_THRESH_MAX) + return -EINVAL; + + ret = i2c_smbus_write_word_data(data->client, APDS9300_THRESHHIGHLOW + | APDS9300_CMD | APDS9300_WORD, value); + if (ret) { + dev_err(&data->client->dev, "failed to set thresh_hi\n"); + return ret; + } + data->thresh_hi = value; + + return 0; +} + +static int apds9300_set_intr_state(struct apds9300_data *data, int state) +{ + int ret; + u8 cmd; + + if (!data->power_state) + return -EBUSY; + + cmd = state ? APDS9300_INTR_ENABLE | APDS9300_THRESH_INTR : 0x00; + ret = i2c_smbus_write_byte_data(data->client, + APDS9300_INTERRUPT | APDS9300_CMD, cmd); + if (ret) { + dev_err(&data->client->dev, + "failed to set interrupt state %d\n", state); + return ret; + } + data->intr_en = state; + + return 0; +} + +static int apds9300_set_power_state(struct apds9300_data *data, int state) +{ + int ret; + u8 cmd; + + cmd = state ? APDS9300_POWER_ON : APDS9300_POWER_OFF; + ret = i2c_smbus_write_byte_data(data->client, + APDS9300_CONTROL | APDS9300_CMD, cmd); + if (ret) { + dev_err(&data->client->dev, + "failed to set power state %d\n", state); + return ret; + } + data->power_state = state; + + return 0; +} + +static void apds9300_clear_intr(struct apds9300_data *data) +{ + int ret; + + ret = i2c_smbus_write_byte(data->client, APDS9300_CLEAR | APDS9300_CMD); + if (ret < 0) + dev_err(&data->client->dev, "failed to clear interrupt\n"); +} + +static int apds9300_chip_init(struct apds9300_data *data) +{ + int ret; + + /* Need to set power off to ensure that the chip is off */ + ret = apds9300_set_power_state(data, 0); + if (ret < 0) + goto err; + /* + * Probe the chip. To do so we try to power up the device and then to + * read back the 0x03 code + */ + ret = apds9300_set_power_state(data, 1); + if (ret < 0) + goto err; + ret = i2c_smbus_read_byte_data(data->client, + APDS9300_CONTROL | APDS9300_CMD); + if (ret != APDS9300_POWER_ON) { + ret = -ENODEV; + goto err; + } + /* + * Disable interrupt to ensure thai it is doesn't enable + * i.e. after device soft reset + */ + ret = apds9300_set_intr_state(data, 0); + if (ret < 0) + goto err; + + return 0; + +err: + dev_err(&data->client->dev, "failed to init the chip\n"); + return ret; +} + +static int apds9300_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, int *val, int *val2, + long mask) +{ + int ch0, ch1, ret = -EINVAL; + struct apds9300_data *data = iio_priv(indio_dev); + + mutex_lock(&data->mutex); + switch (chan->type) { + case IIO_LIGHT: + ch0 = apds9300_get_adc_val(data, 0); + if (ch0 < 0) { + ret = ch0; + break; + } + ch1 = apds9300_get_adc_val(data, 1); + if (ch1 < 0) { + ret = ch1; + break; + } + *val = apds9300_calculate_lux(ch0, ch1); + ret = IIO_VAL_INT; + break; + case IIO_INTENSITY: + ret = apds9300_get_adc_val(data, chan->channel); + if (ret < 0) + break; + *val = ret; + ret = IIO_VAL_INT; + break; + default: + break; + } + mutex_unlock(&data->mutex); + + return ret; +} + +static int apds9300_read_thresh(struct iio_dev *indio_dev, u64 event_code, + int *val) +{ + struct apds9300_data *data = iio_priv(indio_dev); + + switch (IIO_EVENT_CODE_EXTRACT_DIR(event_code)) { + case IIO_EV_DIR_RISING: + *val = data->thresh_hi; + break; + case IIO_EV_DIR_FALLING: + *val = data->thresh_low; + break; + default: + return -EINVAL; + } + + return 0; +} + +static int apds9300_write_thresh(struct iio_dev *indio_dev, u64 event_code, + int val) +{ + struct apds9300_data *data = iio_priv(indio_dev); + int ret; + + mutex_lock(&data->mutex); + if (IIO_EVENT_CODE_EXTRACT_DIR(event_code) == IIO_EV_DIR_RISING) + ret = apds9300_set_thresh_hi(data, val); + else + ret = apds9300_set_thresh_low(data, val); + mutex_unlock(&data->mutex); + + return ret; +} + +static int apds9300_read_interrupt_config(struct iio_dev *indio_dev, + u64 event_code) +{ + struct apds9300_data *data = iio_priv(indio_dev); + + return data->intr_en; +} + +static int apds9300_write_interrupt_config(struct iio_dev *indio_dev, + u64 event_code, int state) +{ + struct apds9300_data *data = iio_priv(indio_dev); + int ret; + + mutex_lock(&data->mutex); + ret = apds9300_set_intr_state(data, state); + mutex_unlock(&data->mutex); + + return ret; +} + +static const struct iio_info apds9300_info_no_irq = { + .driver_module = THIS_MODULE, + .read_raw = apds9300_read_raw, +}; + +static const struct iio_info apds9300_info = { + .driver_module = THIS_MODULE, + .read_raw = apds9300_read_raw, + .read_event_value = apds9300_read_thresh, + .write_event_value = apds9300_write_thresh, + .read_event_config = apds9300_read_interrupt_config, + .write_event_config = apds9300_write_interrupt_config, +}; + +static const struct iio_chan_spec apds9300_channels[] = { + { + .type = IIO_LIGHT, + .channel = 0, + .indexed = true, + .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), + }, { + .type = IIO_INTENSITY, + .channel = 0, + .channel2 = IIO_MOD_LIGHT_BOTH, + .indexed = true, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + .event_mask = (IIO_EV_BIT(IIO_EV_TYPE_THRESH, + IIO_EV_DIR_RISING) | + IIO_EV_BIT(IIO_EV_TYPE_THRESH, + IIO_EV_DIR_FALLING)), + }, { + .type = IIO_INTENSITY, + .channel = 1, + .channel2 = IIO_MOD_LIGHT_IR, + .indexed = true, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + }, +}; + +static irqreturn_t apds9300_interrupt_handler(int irq, void *private) +{ + struct iio_dev *dev_info = private; + struct apds9300_data *data = iio_priv(dev_info); + + iio_push_event(dev_info, + IIO_UNMOD_EVENT_CODE(IIO_INTENSITY, 0, + IIO_EV_TYPE_THRESH, + IIO_EV_DIR_EITHER), + iio_get_time_ns()); + + apds9300_clear_intr(data); + + return IRQ_HANDLED; +} + +static int apds9300_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct apds9300_data *data; + struct iio_dev *indio_dev; + int ret; + + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); + if (!indio_dev) + return -ENOMEM; + + data = iio_priv(indio_dev); + i2c_set_clientdata(client, indio_dev); + data->client = client; + + ret = apds9300_chip_init(data); + if (ret < 0) + goto err; + + mutex_init(&data->mutex); + + indio_dev->dev.parent = &client->dev; + indio_dev->channels = apds9300_channels; + indio_dev->num_channels = ARRAY_SIZE(apds9300_channels); + indio_dev->name = APDS9300_DRV_NAME; + indio_dev->modes = INDIO_DIRECT_MODE; + + if (client->irq) + indio_dev->info = &apds9300_info; + else + indio_dev->info = &apds9300_info_no_irq; + + if (client->irq) { + ret = devm_request_threaded_irq(&client->dev, client->irq, + NULL, apds9300_interrupt_handler, + IRQF_TRIGGER_FALLING | IRQF_ONESHOT, + APDS9300_IRQ_NAME, indio_dev); + if (ret) { + dev_err(&client->dev, "irq request error %d\n", -ret); + goto err; + } + } + + ret = iio_device_register(indio_dev); + if (ret < 0) + goto err; + + return 0; + +err: + /* Ensure that power off in case of error */ + apds9300_set_power_state(data, 0); + return ret; +} + +static int apds9300_remove(struct i2c_client *client) +{ + struct iio_dev *indio_dev = i2c_get_clientdata(client); + struct apds9300_data *data = iio_priv(indio_dev); + + iio_device_unregister(indio_dev); + + /* Ensure that power off and interrupts are disabled */ + apds9300_set_intr_state(data, 0); + apds9300_set_power_state(data, 0); + + return 0; +} + +#ifdef CONFIG_PM_SLEEP +static int apds9300_suspend(struct device *dev) +{ + struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); + struct apds9300_data *data = iio_priv(indio_dev); + int ret; + + mutex_lock(&data->mutex); + ret = apds9300_set_power_state(data, 0); + mutex_unlock(&data->mutex); + + return ret; +} + +static int apds9300_resume(struct device *dev) +{ + struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); + struct apds9300_data *data = iio_priv(indio_dev); + int ret; + + mutex_lock(&data->mutex); + ret = apds9300_set_power_state(data, 1); + mutex_unlock(&data->mutex); + + return ret; +} + +static SIMPLE_DEV_PM_OPS(apds9300_pm_ops, apds9300_suspend, apds9300_resume); +#define APDS9300_PM_OPS (&apds9300_pm_ops) +#else +#define APDS9300_PM_OPS NULL +#endif + +static struct i2c_device_id apds9300_id[] = { + { APDS9300_DRV_NAME, 0 }, + { } +}; + +MODULE_DEVICE_TABLE(i2c, apds9300_id); + +static struct i2c_driver apds9300_driver = { + .driver = { + .name = APDS9300_DRV_NAME, + .owner = THIS_MODULE, + .pm = APDS9300_PM_OPS, + }, + .probe = apds9300_probe, + .remove = apds9300_remove, + .id_table = apds9300_id, +}; + +module_i2c_driver(apds9300_driver); + +MODULE_AUTHOR("Kravchenko Oleksandr "); +MODULE_AUTHOR("GlobalLogic inc."); +MODULE_DESCRIPTION("APDS9300 ambient light photo sensor driver"); +MODULE_LICENSE("GPL"); -- GitLab From ded4fef934768adee9d31f15831513d7d76c360b Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 23 Jul 2013 07:50:00 +0100 Subject: [PATCH 499/942] iio: adc: ad7266: Use devm_* APIs devm_* APIs are device managed and make code simpler. Signed-off-by: Sachin Kamat Acked-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ad7266.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/iio/adc/ad7266.c b/drivers/iio/adc/ad7266.c index c2744a75c3b09..371731df1634b 100644 --- a/drivers/iio/adc/ad7266.c +++ b/drivers/iio/adc/ad7266.c @@ -399,17 +399,17 @@ static int ad7266_probe(struct spi_device *spi) unsigned int i; int ret; - indio_dev = iio_device_alloc(sizeof(*st)); + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); if (indio_dev == NULL) return -ENOMEM; st = iio_priv(indio_dev); - st->reg = regulator_get(&spi->dev, "vref"); + st->reg = devm_regulator_get(&spi->dev, "vref"); if (!IS_ERR_OR_NULL(st->reg)) { ret = regulator_enable(st->reg); if (ret) - goto error_put_reg; + return ret; ret = regulator_get_voltage(st->reg); if (ret < 0) @@ -489,11 +489,6 @@ static int ad7266_probe(struct spi_device *spi) error_disable_reg: if (!IS_ERR_OR_NULL(st->reg)) regulator_disable(st->reg); -error_put_reg: - if (!IS_ERR_OR_NULL(st->reg)) - regulator_put(st->reg); - - iio_device_free(indio_dev); return ret; } @@ -507,11 +502,8 @@ static int ad7266_remove(struct spi_device *spi) iio_triggered_buffer_cleanup(indio_dev); if (!st->fixed_addr) gpio_free_array(st->gpios, ARRAY_SIZE(st->gpios)); - if (!IS_ERR_OR_NULL(st->reg)) { + if (!IS_ERR_OR_NULL(st->reg)) regulator_disable(st->reg); - regulator_put(st->reg); - } - iio_device_free(indio_dev); return 0; } -- GitLab From 7abe9007ca671bf27799922711d8c023bac56a88 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 23 Jul 2013 09:58:00 +0100 Subject: [PATCH 500/942] iio: adc: ad7298: Use devm_* APIs devm_* APIs are device managed and make code simpler. Signed-off-by: Sachin Kamat Acked-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ad7298.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/drivers/iio/adc/ad7298.c b/drivers/iio/adc/ad7298.c index 03b77189dbfe6..85d1481c312f6 100644 --- a/drivers/iio/adc/ad7298.c +++ b/drivers/iio/adc/ad7298.c @@ -296,9 +296,10 @@ static int ad7298_probe(struct spi_device *spi) { struct ad7298_platform_data *pdata = spi->dev.platform_data; struct ad7298_state *st; - struct iio_dev *indio_dev = iio_device_alloc(sizeof(*st)); + struct iio_dev *indio_dev; int ret; + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); if (indio_dev == NULL) return -ENOMEM; @@ -308,14 +309,13 @@ static int ad7298_probe(struct spi_device *spi) st->ext_ref = AD7298_EXTREF; if (st->ext_ref) { - st->reg = regulator_get(&spi->dev, "vref"); - if (IS_ERR(st->reg)) { - ret = PTR_ERR(st->reg); - goto error_free; - } + st->reg = devm_regulator_get(&spi->dev, "vref"); + if (IS_ERR(st->reg)) + return PTR_ERR(st->reg); + ret = regulator_enable(st->reg); if (ret) - goto error_put_reg; + return ret; } spi_set_drvdata(spi, indio_dev); @@ -361,11 +361,6 @@ static int ad7298_probe(struct spi_device *spi) error_disable_reg: if (st->ext_ref) regulator_disable(st->reg); -error_put_reg: - if (st->ext_ref) - regulator_put(st->reg); -error_free: - iio_device_free(indio_dev); return ret; } @@ -377,11 +372,8 @@ static int ad7298_remove(struct spi_device *spi) iio_device_unregister(indio_dev); iio_triggered_buffer_cleanup(indio_dev); - if (st->ext_ref) { + if (st->ext_ref) regulator_disable(st->reg); - regulator_put(st->reg); - } - iio_device_free(indio_dev); return 0; } -- GitLab From 4ea454d2c1a38dd8c75a185019fea14ea34401b8 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 23 Jul 2013 09:58:00 +0100 Subject: [PATCH 501/942] iio: adc: ad7476: Use devm_* APIs devm_* APIs are device managed and make code simpler. Signed-off-by: Sachin Kamat Acked-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ad7476.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/drivers/iio/adc/ad7476.c b/drivers/iio/adc/ad7476.c index 2e98bef4af673..6d2b1d8d1a1f0 100644 --- a/drivers/iio/adc/ad7476.c +++ b/drivers/iio/adc/ad7476.c @@ -213,24 +213,21 @@ static int ad7476_probe(struct spi_device *spi) struct iio_dev *indio_dev; int ret; - indio_dev = iio_device_alloc(sizeof(*st)); - if (indio_dev == NULL) { - ret = -ENOMEM; - goto error_ret; - } + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); + if (!indio_dev) + return -ENOMEM; + st = iio_priv(indio_dev); st->chip_info = &ad7476_chip_info_tbl[spi_get_device_id(spi)->driver_data]; - st->reg = regulator_get(&spi->dev, "vcc"); - if (IS_ERR(st->reg)) { - ret = PTR_ERR(st->reg); - goto error_free_dev; - } + st->reg = devm_regulator_get(&spi->dev, "vcc"); + if (IS_ERR(st->reg)) + return PTR_ERR(st->reg); ret = regulator_enable(st->reg); if (ret) - goto error_put_reg; + return ret; spi_set_drvdata(spi, indio_dev); @@ -268,12 +265,7 @@ static int ad7476_probe(struct spi_device *spi) iio_triggered_buffer_cleanup(indio_dev); error_disable_reg: regulator_disable(st->reg); -error_put_reg: - regulator_put(st->reg); -error_free_dev: - iio_device_free(indio_dev); -error_ret: return ret; } @@ -285,8 +277,6 @@ static int ad7476_remove(struct spi_device *spi) iio_device_unregister(indio_dev); iio_triggered_buffer_cleanup(indio_dev); regulator_disable(st->reg); - regulator_put(st->reg); - iio_device_free(indio_dev); return 0; } -- GitLab From eb8fe60784ee6d8bbe32f635254f71fdc4a10727 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 23 Jul 2013 09:58:00 +0100 Subject: [PATCH 502/942] iio: adc: ad7791: Use devm_* APIs devm_* APIs are device managed and make code simpler. Signed-off-by: Sachin Kamat Acked-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ad7791.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/drivers/iio/adc/ad7791.c b/drivers/iio/adc/ad7791.c index 5e8d1da6887fb..c20203577d2d1 100644 --- a/drivers/iio/adc/ad7791.c +++ b/drivers/iio/adc/ad7791.c @@ -361,21 +361,19 @@ static int ad7791_probe(struct spi_device *spi) return -ENXIO; } - indio_dev = iio_device_alloc(sizeof(*st)); + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); if (!indio_dev) return -ENOMEM; st = iio_priv(indio_dev); - st->reg = regulator_get(&spi->dev, "refin"); - if (IS_ERR(st->reg)) { - ret = PTR_ERR(st->reg); - goto err_iio_free; - } + st->reg = devm_regulator_get(&spi->dev, "refin"); + if (IS_ERR(st->reg)) + return PTR_ERR(st->reg); ret = regulator_enable(st->reg); if (ret) - goto error_put_reg; + return ret; st->info = &ad7791_chip_infos[spi_get_device_id(spi)->driver_data]; ad_sd_init(&st->sd, indio_dev, spi, &ad7791_sigma_delta_info); @@ -410,10 +408,6 @@ static int ad7791_probe(struct spi_device *spi) ad_sd_cleanup_buffer_and_trigger(indio_dev); error_disable_reg: regulator_disable(st->reg); -error_put_reg: - regulator_put(st->reg); -err_iio_free: - iio_device_free(indio_dev); return ret; } @@ -427,9 +421,6 @@ static int ad7791_remove(struct spi_device *spi) ad_sd_cleanup_buffer_and_trigger(indio_dev); regulator_disable(st->reg); - regulator_put(st->reg); - - iio_device_free(indio_dev); return 0; } -- GitLab From a35801326bc12e5fec28f00a09bb2e8a7af8be38 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 23 Jul 2013 09:58:00 +0100 Subject: [PATCH 503/942] iio: adc: ad7793: Use devm_* APIs devm_* APIs are device managed and make code simpler. Signed-off-by: Sachin Kamat Acked-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ad7793.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/drivers/iio/adc/ad7793.c b/drivers/iio/adc/ad7793.c index 334e31ff7a4ea..4dddeabdfbb02 100644 --- a/drivers/iio/adc/ad7793.c +++ b/drivers/iio/adc/ad7793.c @@ -757,7 +757,7 @@ static int ad7793_probe(struct spi_device *spi) return -ENODEV; } - indio_dev = iio_device_alloc(sizeof(*st)); + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); if (indio_dev == NULL) return -ENOMEM; @@ -766,15 +766,13 @@ static int ad7793_probe(struct spi_device *spi) ad_sd_init(&st->sd, indio_dev, spi, &ad7793_sigma_delta_info); if (pdata->refsel != AD7793_REFSEL_INTERNAL) { - st->reg = regulator_get(&spi->dev, "refin"); - if (IS_ERR(st->reg)) { - ret = PTR_ERR(st->reg); - goto error_device_free; - } + st->reg = devm_regulator_get(&spi->dev, "refin"); + if (IS_ERR(st->reg)) + return PTR_ERR(st->reg); ret = regulator_enable(st->reg); if (ret) - goto error_put_reg; + return ret; vref_mv = regulator_get_voltage(st->reg); if (vref_mv < 0) { @@ -818,11 +816,6 @@ static int ad7793_probe(struct spi_device *spi) error_disable_reg: if (pdata->refsel != AD7793_REFSEL_INTERNAL) regulator_disable(st->reg); -error_put_reg: - if (pdata->refsel != AD7793_REFSEL_INTERNAL) - regulator_put(st->reg); -error_device_free: - iio_device_free(indio_dev); return ret; } @@ -836,12 +829,8 @@ static int ad7793_remove(struct spi_device *spi) iio_device_unregister(indio_dev); ad_sd_cleanup_buffer_and_trigger(indio_dev); - if (pdata->refsel != AD7793_REFSEL_INTERNAL) { + if (pdata->refsel != AD7793_REFSEL_INTERNAL) regulator_disable(st->reg); - regulator_put(st->reg); - } - - iio_device_free(indio_dev); return 0; } -- GitLab From 82429e0d33ece550378852539827916cda0a6b69 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 23 Jul 2013 09:58:00 +0100 Subject: [PATCH 504/942] iio: adc: ad7887: Use devm_* APIs devm_* APIs are device managed and make code simpler. Signed-off-by: Sachin Kamat Acked-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ad7887.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/drivers/iio/adc/ad7887.c b/drivers/iio/adc/ad7887.c index dd15a5b0f701a..9dd077b787590 100644 --- a/drivers/iio/adc/ad7887.c +++ b/drivers/iio/adc/ad7887.c @@ -237,25 +237,24 @@ static int ad7887_probe(struct spi_device *spi) { struct ad7887_platform_data *pdata = spi->dev.platform_data; struct ad7887_state *st; - struct iio_dev *indio_dev = iio_device_alloc(sizeof(*st)); + struct iio_dev *indio_dev; uint8_t mode; int ret; + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); if (indio_dev == NULL) return -ENOMEM; st = iio_priv(indio_dev); if (!pdata || !pdata->use_onchip_ref) { - st->reg = regulator_get(&spi->dev, "vref"); - if (IS_ERR(st->reg)) { - ret = PTR_ERR(st->reg); - goto error_free; - } + st->reg = devm_regulator_get(&spi->dev, "vref"); + if (IS_ERR(st->reg)) + return PTR_ERR(st->reg); ret = regulator_enable(st->reg); if (ret) - goto error_put_reg; + return ret; } st->chip_info = @@ -331,11 +330,6 @@ static int ad7887_probe(struct spi_device *spi) error_disable_reg: if (st->reg) regulator_disable(st->reg); -error_put_reg: - if (st->reg) - regulator_put(st->reg); -error_free: - iio_device_free(indio_dev); return ret; } @@ -347,11 +341,8 @@ static int ad7887_remove(struct spi_device *spi) iio_device_unregister(indio_dev); iio_triggered_buffer_cleanup(indio_dev); - if (st->reg) { + if (st->reg) regulator_disable(st->reg); - regulator_put(st->reg); - } - iio_device_free(indio_dev); return 0; } -- GitLab From e59576d4beaf232d1048bac391393c94b1b00745 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 23 Jul 2013 09:58:00 +0100 Subject: [PATCH 505/942] iio: adc: ad7923: Use devm_* APIs devm_* APIs are device managed and make code simpler. Signed-off-by: Sachin Kamat Acked-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ad7923.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/drivers/iio/adc/ad7923.c b/drivers/iio/adc/ad7923.c index 97fa0d3dc4aaa..4108dbb28c3d8 100644 --- a/drivers/iio/adc/ad7923.c +++ b/drivers/iio/adc/ad7923.c @@ -275,10 +275,11 @@ static const struct iio_info ad7923_info = { static int ad7923_probe(struct spi_device *spi) { struct ad7923_state *st; - struct iio_dev *indio_dev = iio_device_alloc(sizeof(*st)); + struct iio_dev *indio_dev; const struct ad7923_chip_info *info; int ret; + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); if (indio_dev == NULL) return -ENOMEM; @@ -311,14 +312,13 @@ static int ad7923_probe(struct spi_device *spi) spi_message_add_tail(&st->scan_single_xfer[0], &st->scan_single_msg); spi_message_add_tail(&st->scan_single_xfer[1], &st->scan_single_msg); - st->reg = regulator_get(&spi->dev, "refin"); - if (IS_ERR(st->reg)) { - ret = PTR_ERR(st->reg); - goto error_free; - } + st->reg = devm_regulator_get(&spi->dev, "refin"); + if (IS_ERR(st->reg)) + return PTR_ERR(st->reg); + ret = regulator_enable(st->reg); if (ret) - goto error_put_reg; + return ret; ret = iio_triggered_buffer_setup(indio_dev, NULL, &ad7923_trigger_handler, NULL); @@ -335,10 +335,6 @@ static int ad7923_probe(struct spi_device *spi) iio_triggered_buffer_cleanup(indio_dev); error_disable_reg: regulator_disable(st->reg); -error_put_reg: - regulator_put(st->reg); -error_free: - iio_device_free(indio_dev); return ret; } @@ -351,8 +347,6 @@ static int ad7923_remove(struct spi_device *spi) iio_device_unregister(indio_dev); iio_triggered_buffer_cleanup(indio_dev); regulator_disable(st->reg); - regulator_put(st->reg); - iio_device_free(indio_dev); return 0; } -- GitLab From 8483aa5e0f0a4bdf8bdc54d83397715c7adb762d Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 23 Jul 2013 09:58:00 +0100 Subject: [PATCH 506/942] iio: adc: lp8788_adc: Use devm_* APIs devm_* APIs are device managed and make code simpler. Signed-off-by: Sachin Kamat Cc: Milo Kim Signed-off-by: Jonathan Cameron --- drivers/iio/adc/lp8788_adc.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/iio/adc/lp8788_adc.c b/drivers/iio/adc/lp8788_adc.c index 62bc39e9c94f2..5c8c91595f473 100644 --- a/drivers/iio/adc/lp8788_adc.c +++ b/drivers/iio/adc/lp8788_adc.c @@ -194,7 +194,7 @@ static int lp8788_adc_probe(struct platform_device *pdev) struct lp8788_adc *adc; int ret; - indio_dev = iio_device_alloc(sizeof(*adc)); + indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*adc)); if (!indio_dev) return -ENOMEM; @@ -205,7 +205,7 @@ static int lp8788_adc_probe(struct platform_device *pdev) indio_dev->dev.of_node = pdev->dev.of_node; ret = lp8788_iio_map_register(indio_dev, lp->pdata, adc); if (ret) - goto err_iio_map; + return ret; mutex_init(&adc->lock); @@ -226,8 +226,6 @@ static int lp8788_adc_probe(struct platform_device *pdev) err_iio_device: iio_map_array_unregister(indio_dev); -err_iio_map: - iio_device_free(indio_dev); return ret; } @@ -237,7 +235,6 @@ static int lp8788_adc_remove(struct platform_device *pdev) iio_device_unregister(indio_dev); iio_map_array_unregister(indio_dev); - iio_device_free(indio_dev); return 0; } -- GitLab From a726dea54741cf7edfd83175cad3f3483390c308 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 23 Jul 2013 09:58:00 +0100 Subject: [PATCH 507/942] iio: adc: mcp320x: Use devm_* APIs devm_* APIs are device managed and make code simpler. Signed-off-by: Sachin Kamat Cc: Oskar Andero Signed-off-by: Jonathan Cameron --- drivers/iio/adc/mcp320x.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/drivers/iio/adc/mcp320x.c b/drivers/iio/adc/mcp320x.c index ebc015922a792..28a086e487762 100644 --- a/drivers/iio/adc/mcp320x.c +++ b/drivers/iio/adc/mcp320x.c @@ -169,7 +169,7 @@ static int mcp320x_probe(struct spi_device *spi) const struct mcp3208_chip_info *chip_info; int ret; - indio_dev = iio_device_alloc(sizeof(*adc)); + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adc)); if (!indio_dev) return -ENOMEM; @@ -193,15 +193,13 @@ static int mcp320x_probe(struct spi_device *spi) spi_message_init_with_transfers(&adc->msg, adc->transfer, ARRAY_SIZE(adc->transfer)); - adc->reg = regulator_get(&spi->dev, "vref"); - if (IS_ERR(adc->reg)) { - ret = PTR_ERR(adc->reg); - goto iio_free; - } + adc->reg = devm_regulator_get(&spi->dev, "vref"); + if (IS_ERR(adc->reg)) + return PTR_ERR(adc->reg); ret = regulator_enable(adc->reg); if (ret < 0) - goto reg_free; + return ret; mutex_init(&adc->lock); @@ -213,10 +211,6 @@ static int mcp320x_probe(struct spi_device *spi) reg_disable: regulator_disable(adc->reg); -reg_free: - regulator_put(adc->reg); -iio_free: - iio_device_free(indio_dev); return ret; } @@ -228,8 +222,6 @@ static int mcp320x_remove(struct spi_device *spi) iio_device_unregister(indio_dev); regulator_disable(adc->reg); - regulator_put(adc->reg); - iio_device_free(indio_dev); return 0; } -- GitLab From ed6886c104c151c4d2d8fbce154da945c3d04dad Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 23 Jul 2013 09:58:00 +0100 Subject: [PATCH 508/942] iio: adc: nau7802: Use devm_iio_device_alloc Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat Acked-by: Maxime Ripard Signed-off-by: Jonathan Cameron --- drivers/iio/adc/nau7802.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/iio/adc/nau7802.c b/drivers/iio/adc/nau7802.c index 70fa17149d1a3..bdf03468f3b8d 100644 --- a/drivers/iio/adc/nau7802.c +++ b/drivers/iio/adc/nau7802.c @@ -404,7 +404,7 @@ static int nau7802_probe(struct i2c_client *client, return -EINVAL; } - indio_dev = iio_device_alloc(sizeof(*st)); + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*st)); if (indio_dev == NULL) return -ENOMEM; @@ -423,13 +423,13 @@ static int nau7802_probe(struct i2c_client *client, ret = i2c_smbus_write_byte_data(st->client, NAU7802_REG_PUCTRL, NAU7802_PUCTRL_RR_BIT); if (ret < 0) - goto error_free_indio; + return ret; /* Enter normal operation mode */ ret = i2c_smbus_write_byte_data(st->client, NAU7802_REG_PUCTRL, NAU7802_PUCTRL_PUD_BIT); if (ret < 0) - goto error_free_indio; + return ret; /* * After about 200 usecs, the device should be ready and then @@ -438,9 +438,9 @@ static int nau7802_probe(struct i2c_client *client, udelay(210); ret = i2c_smbus_read_byte_data(st->client, NAU7802_REG_PUCTRL); if (ret < 0) - goto error_free_indio; + return ret; if (!(ret & NAU7802_PUCTRL_PUR_BIT)) - goto error_free_indio; + return ret; of_property_read_u32(np, "nuvoton,vldo", &tmp); st->vref_mv = tmp; @@ -452,17 +452,17 @@ static int nau7802_probe(struct i2c_client *client, ret = i2c_smbus_write_byte_data(st->client, NAU7802_REG_PUCTRL, data); if (ret < 0) - goto error_free_indio; + return ret; ret = i2c_smbus_write_byte_data(st->client, NAU7802_REG_ADC_CTRL, 0x30); if (ret < 0) - goto error_free_indio; + return ret; if (tmp >= 2400) { data = NAU7802_CTRL1_VLDO((4500 - tmp) / 300); ret = i2c_smbus_write_byte_data(st->client, NAU7802_REG_CTRL1, data); if (ret < 0) - goto error_free_indio; + return ret; } /* Populate available ADC input ranges */ @@ -533,8 +533,6 @@ static int nau7802_probe(struct i2c_client *client, error_free_irq: if (client->irq) free_irq(client->irq, indio_dev); -error_free_indio: - iio_device_free(indio_dev); return ret; } @@ -549,7 +547,6 @@ static int nau7802_remove(struct i2c_client *client) mutex_destroy(&st->data_lock); if (client->irq) free_irq(client->irq, indio_dev); - iio_device_free(indio_dev); return 0; } -- GitLab From 99e94b6d567188275b1269d4bd72d78cc10df8c3 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 23 Jul 2013 09:58:00 +0100 Subject: [PATCH 509/942] iio: adc: ti-adc081c: Use devm_* APIs devm_* APIs are device managed and make code simpler. Signed-off-by: Sachin Kamat Reviewed-by: Thierry Reding Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ti-adc081c.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/drivers/iio/adc/ti-adc081c.c b/drivers/iio/adc/ti-adc081c.c index 2826faae706c1..ee5f72bffe5a8 100644 --- a/drivers/iio/adc/ti-adc081c.c +++ b/drivers/iio/adc/ti-adc081c.c @@ -74,22 +74,20 @@ static int adc081c_probe(struct i2c_client *client, if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WORD_DATA)) return -ENODEV; - iio = iio_device_alloc(sizeof(*adc)); + iio = devm_iio_device_alloc(&client->dev, sizeof(*adc)); if (!iio) return -ENOMEM; adc = iio_priv(iio); adc->i2c = client; - adc->ref = regulator_get(&client->dev, "vref"); - if (IS_ERR(adc->ref)) { - err = PTR_ERR(adc->ref); - goto iio_free; - } + adc->ref = devm_regulator_get(&client->dev, "vref"); + if (IS_ERR(adc->ref)) + return PTR_ERR(adc->ref); err = regulator_enable(adc->ref); if (err < 0) - goto regulator_put; + return err; iio->dev.parent = &client->dev; iio->name = dev_name(&client->dev); @@ -109,10 +107,6 @@ static int adc081c_probe(struct i2c_client *client, regulator_disable: regulator_disable(adc->ref); -regulator_put: - regulator_put(adc->ref); -iio_free: - iio_device_free(iio); return err; } @@ -124,8 +118,6 @@ static int adc081c_remove(struct i2c_client *client) iio_device_unregister(iio); regulator_disable(adc->ref); - regulator_put(adc->ref); - iio_device_free(iio); return 0; } -- GitLab From 3ef50f8830ecb911c3ae3faec4f2832d5ff55bff Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 23 Jul 2013 09:58:00 +0100 Subject: [PATCH 510/942] iio: adc: viperboard_adc: Use devm_iio_device_alloc Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat Cc: Lars Poeschel Signed-off-by: Jonathan Cameron --- drivers/iio/adc/viperboard_adc.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/iio/adc/viperboard_adc.c b/drivers/iio/adc/viperboard_adc.c index 56ac481c73c0b..09727a71e9fa1 100644 --- a/drivers/iio/adc/viperboard_adc.c +++ b/drivers/iio/adc/viperboard_adc.c @@ -124,7 +124,7 @@ static int vprbrd_adc_probe(struct platform_device *pdev) int ret; /* registering iio */ - indio_dev = iio_device_alloc(sizeof(*adc)); + indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*adc)); if (!indio_dev) { dev_err(&pdev->dev, "failed allocating iio device\n"); return -ENOMEM; @@ -142,16 +142,12 @@ static int vprbrd_adc_probe(struct platform_device *pdev) ret = iio_device_register(indio_dev); if (ret) { dev_err(&pdev->dev, "could not register iio (adc)"); - goto error; + return ret; } platform_set_drvdata(pdev, indio_dev); return 0; - -error: - iio_device_free(indio_dev); - return ret; } static int vprbrd_adc_remove(struct platform_device *pdev) @@ -159,7 +155,6 @@ static int vprbrd_adc_remove(struct platform_device *pdev) struct iio_dev *indio_dev = platform_get_drvdata(pdev); iio_device_unregister(indio_dev); - iio_device_free(indio_dev); return 0; } -- GitLab From f88375322d46e66a9e0983070b9970853d951fd6 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Mon, 22 Jul 2013 12:02:00 +0100 Subject: [PATCH 511/942] iio: at91: Use devm_iio_device_alloc Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat Cc: Maxime Ripard Signed-off-by: Jonathan Cameron --- drivers/iio/adc/at91_adc.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c index b6db6a0e09cd8..423e079460d3a 100644 --- a/drivers/iio/adc/at91_adc.c +++ b/drivers/iio/adc/at91_adc.c @@ -589,11 +589,9 @@ static int at91_adc_probe(struct platform_device *pdev) struct resource *res; u32 reg; - idev = iio_device_alloc(sizeof(struct at91_adc_state)); - if (idev == NULL) { - ret = -ENOMEM; - goto error_ret; - } + idev = devm_iio_device_alloc(&pdev->dev, sizeof(struct at91_adc_state)); + if (!idev) + return -ENOMEM; st = iio_priv(idev); @@ -604,8 +602,7 @@ static int at91_adc_probe(struct platform_device *pdev) if (ret) { dev_err(&pdev->dev, "No platform data available.\n"); - ret = -EINVAL; - goto error_free_device; + return -EINVAL; } platform_set_drvdata(pdev, idev); @@ -618,16 +615,14 @@ static int at91_adc_probe(struct platform_device *pdev) st->irq = platform_get_irq(pdev, 0); if (st->irq < 0) { dev_err(&pdev->dev, "No IRQ ID is designated\n"); - ret = -ENODEV; - goto error_free_device; + return -ENODEV; } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); st->reg_base = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(st->reg_base)) { - ret = PTR_ERR(st->reg_base); - goto error_free_device; + return PTR_ERR(st->reg_base); } /* @@ -642,7 +637,7 @@ static int at91_adc_probe(struct platform_device *pdev) idev); if (ret) { dev_err(&pdev->dev, "Failed to allocate IRQ.\n"); - goto error_free_device; + return ret; } st->clk = devm_clk_get(&pdev->dev, "adc_clk"); @@ -752,9 +747,6 @@ static int at91_adc_probe(struct platform_device *pdev) clk_disable_unprepare(st->clk); error_free_irq: free_irq(st->irq, idev); -error_free_device: - iio_device_free(idev); -error_ret: return ret; } @@ -769,7 +761,6 @@ static int at91_adc_remove(struct platform_device *pdev) clk_disable_unprepare(st->adc_clk); clk_disable_unprepare(st->clk); free_irq(st->irq, idev); - iio_device_free(idev); return 0; } -- GitLab From ebeb021af29826fe44818f986c898f3e41a4f77c Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Mon, 22 Jul 2013 12:02:00 +0100 Subject: [PATCH 512/942] iio: exynos_adc: Use devm_iio_device_alloc Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat Cc: Naveen Krishna Chatradhi Signed-off-by: Jonathan Cameron --- drivers/iio/adc/exynos_adc.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/drivers/iio/adc/exynos_adc.c b/drivers/iio/adc/exynos_adc.c index 9809fc9a35d2f..d25b262193a7d 100644 --- a/drivers/iio/adc/exynos_adc.c +++ b/drivers/iio/adc/exynos_adc.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -261,7 +262,7 @@ static int exynos_adc_probe(struct platform_device *pdev) if (!np) return ret; - indio_dev = iio_device_alloc(sizeof(struct exynos_adc)); + indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(struct exynos_adc)); if (!indio_dev) { dev_err(&pdev->dev, "failed allocating iio device\n"); return -ENOMEM; @@ -271,23 +272,18 @@ static int exynos_adc_probe(struct platform_device *pdev) mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); info->regs = devm_ioremap_resource(&pdev->dev, mem); - if (IS_ERR(info->regs)) { - ret = PTR_ERR(info->regs); - goto err_iio; - } + if (IS_ERR(info->regs)) + return PTR_ERR(info->regs); mem = platform_get_resource(pdev, IORESOURCE_MEM, 1); info->enable_reg = devm_ioremap_resource(&pdev->dev, mem); - if (IS_ERR(info->enable_reg)) { - ret = PTR_ERR(info->enable_reg); - goto err_iio; - } + if (IS_ERR(info->enable_reg)) + return PTR_ERR(info->enable_reg); irq = platform_get_irq(pdev, 0); if (irq < 0) { dev_err(&pdev->dev, "no irq resource?\n"); - ret = irq; - goto err_iio; + return irq; } info->irq = irq; @@ -299,7 +295,7 @@ static int exynos_adc_probe(struct platform_device *pdev) if (ret < 0) { dev_err(&pdev->dev, "failed requesting irq, irq = %d\n", info->irq); - goto err_iio; + return ret; } writel(1, info->enable_reg); @@ -365,8 +361,6 @@ static int exynos_adc_probe(struct platform_device *pdev) iio_device_unregister(indio_dev); err_irq: free_irq(info->irq, info); -err_iio: - iio_device_free(indio_dev); return ret; } @@ -382,7 +376,6 @@ static int exynos_adc_remove(struct platform_device *pdev) writel(0, info->enable_reg); iio_device_unregister(indio_dev); free_irq(info->irq, info); - iio_device_free(indio_dev); return 0; } -- GitLab From 6917e1d9af2c5087e933aa18f9117b95101d7cb1 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Mon, 22 Jul 2013 12:02:00 +0100 Subject: [PATCH 513/942] iio: max1363: Use devm_iio_device_alloc Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat Signed-off-by: Jonathan Cameron --- drivers/iio/adc/max1363.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/iio/adc/max1363.c b/drivers/iio/adc/max1363.c index f148d00b83f7d..4fb35d1d74943 100644 --- a/drivers/iio/adc/max1363.c +++ b/drivers/iio/adc/max1363.c @@ -1498,16 +1498,15 @@ static int max1363_probe(struct i2c_client *client, struct iio_dev *indio_dev; struct regulator *vref; - indio_dev = iio_device_alloc(sizeof(struct max1363_state)); - if (indio_dev == NULL) { - ret = -ENOMEM; - goto error_out; - } + indio_dev = devm_iio_device_alloc(&client->dev, + sizeof(struct max1363_state)); + if (!indio_dev) + return -ENOMEM; indio_dev->dev.of_node = client->dev.of_node; ret = iio_map_array_register(indio_dev, client->dev.platform_data); if (ret < 0) - goto error_free_device; + return ret; st = iio_priv(indio_dev); @@ -1590,9 +1589,6 @@ static int max1363_probe(struct i2c_client *client, regulator_disable(st->reg); error_unregister_map: iio_map_array_unregister(indio_dev); -error_free_device: - iio_device_free(indio_dev); -error_out: return ret; } @@ -1607,7 +1603,6 @@ static int max1363_remove(struct i2c_client *client) regulator_disable(st->vref); regulator_disable(st->reg); iio_map_array_unregister(indio_dev); - iio_device_free(indio_dev); return 0; } -- GitLab From a8b168a15f8d7b1c6ee54f486e51490634abe18f Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Mon, 22 Jul 2013 12:02:00 +0100 Subject: [PATCH 514/942] iio: frequency: adf4350: Use devm_* APIs devm_* APIs are device managed and make code simpler. This also takes care of missing clk_put function calls implicitly. Signed-off-by: Sachin Kamat Cc: Michael Hennerich Signed-off-by: Jonathan Cameron --- drivers/iio/frequency/adf4350.c | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/drivers/iio/frequency/adf4350.c b/drivers/iio/frequency/adf4350.c index a4157cdb314d5..a7b30be86ae06 100644 --- a/drivers/iio/frequency/adf4350.c +++ b/drivers/iio/frequency/adf4350.c @@ -515,7 +515,7 @@ static int adf4350_probe(struct spi_device *spi) } if (!pdata->clkin) { - clk = clk_get(&spi->dev, "clkin"); + clk = devm_clk_get(&spi->dev, "clkin"); if (IS_ERR(clk)) return -EPROBE_DEFER; @@ -524,17 +524,17 @@ static int adf4350_probe(struct spi_device *spi) return ret; } - indio_dev = iio_device_alloc(sizeof(*st)); + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); if (indio_dev == NULL) return -ENOMEM; st = iio_priv(indio_dev); - st->reg = regulator_get(&spi->dev, "vcc"); + st->reg = devm_regulator_get(&spi->dev, "vcc"); if (!IS_ERR(st->reg)) { ret = regulator_enable(st->reg); if (ret) - goto error_put_reg; + goto error_disable_clk; } spi_set_drvdata(spi, indio_dev); @@ -564,7 +564,8 @@ static int adf4350_probe(struct spi_device *spi) memset(st->regs_hw, 0xFF, sizeof(st->regs_hw)); if (gpio_is_valid(pdata->gpio_lock_detect)) { - ret = gpio_request(pdata->gpio_lock_detect, indio_dev->name); + ret = devm_gpio_request(&spi->dev, pdata->gpio_lock_detect, + indio_dev->name); if (ret) { dev_err(&spi->dev, "fail to request lock detect GPIO-%d", pdata->gpio_lock_detect); @@ -576,29 +577,21 @@ static int adf4350_probe(struct spi_device *spi) if (pdata->power_up_frequency) { ret = adf4350_set_freq(st, pdata->power_up_frequency); if (ret) - goto error_free_gpio; + goto error_disable_reg; } ret = iio_device_register(indio_dev); if (ret) - goto error_free_gpio; + goto error_disable_reg; return 0; -error_free_gpio: - if (gpio_is_valid(pdata->gpio_lock_detect)) - gpio_free(pdata->gpio_lock_detect); - error_disable_reg: if (!IS_ERR(st->reg)) regulator_disable(st->reg); -error_put_reg: - if (!IS_ERR(st->reg)) - regulator_put(st->reg); - +error_disable_clk: if (clk) clk_disable_unprepare(clk); - iio_device_free(indio_dev); return ret; } @@ -619,14 +612,8 @@ static int adf4350_remove(struct spi_device *spi) if (!IS_ERR(reg)) { regulator_disable(reg); - regulator_put(reg); } - if (gpio_is_valid(st->pdata->gpio_lock_detect)) - gpio_free(st->pdata->gpio_lock_detect); - - iio_device_free(indio_dev); - return 0; } -- GitLab From 073c33d55242cf9d9b89a5f49e7b4ba952c81045 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Mon, 22 Jul 2013 12:02:00 +0100 Subject: [PATCH 515/942] staging: iio: mxs-lradc: Use devm_iio_device_alloc Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat Reviewed-by: Marek Vasut Signed-off-by: Jonathan Cameron --- drivers/staging/iio/adc/mxs-lradc.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/drivers/staging/iio/adc/mxs-lradc.c b/drivers/staging/iio/adc/mxs-lradc.c index 37a4fd39b1e04..863f0861b7290 100644 --- a/drivers/staging/iio/adc/mxs-lradc.c +++ b/drivers/staging/iio/adc/mxs-lradc.c @@ -909,7 +909,7 @@ static int mxs_lradc_probe(struct platform_device *pdev) int i; /* Allocate the IIO device. */ - iio = iio_device_alloc(sizeof(*lradc)); + iio = devm_iio_device_alloc(dev, sizeof(*lradc)); if (!iio) { dev_err(dev, "Failed to allocate IIO device\n"); return -ENOMEM; @@ -921,10 +921,8 @@ static int mxs_lradc_probe(struct platform_device *pdev) iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); lradc->dev = &pdev->dev; lradc->base = devm_ioremap_resource(dev, iores); - if (IS_ERR(lradc->base)) { - ret = PTR_ERR(lradc->base); - goto err_addr; - } + if (IS_ERR(lradc->base)) + return PTR_ERR(lradc->base); INIT_WORK(&lradc->ts_work, mxs_lradc_ts_work); @@ -944,16 +942,14 @@ static int mxs_lradc_probe(struct platform_device *pdev) /* Grab all IRQ sources */ for (i = 0; i < of_cfg->irq_count; i++) { lradc->irq[i] = platform_get_irq(pdev, i); - if (lradc->irq[i] < 0) { - ret = -EINVAL; - goto err_addr; - } + if (lradc->irq[i] < 0) + return -EINVAL; ret = devm_request_irq(dev, lradc->irq[i], mxs_lradc_handle_irq, 0, of_cfg->irq_name[i], iio); if (ret) - goto err_addr; + return ret; } platform_set_drvdata(pdev, iio); @@ -973,7 +969,7 @@ static int mxs_lradc_probe(struct platform_device *pdev) &mxs_lradc_trigger_handler, &mxs_lradc_buffer_ops); if (ret) - goto err_addr; + return ret; ret = mxs_lradc_trigger_init(iio); if (ret) @@ -1004,8 +1000,6 @@ static int mxs_lradc_probe(struct platform_device *pdev) mxs_lradc_trigger_remove(iio); err_trig: iio_triggered_buffer_cleanup(iio); -err_addr: - iio_device_free(iio); return ret; } @@ -1021,7 +1015,6 @@ static int mxs_lradc_remove(struct platform_device *pdev) iio_device_unregister(iio); iio_triggered_buffer_cleanup(iio); mxs_lradc_trigger_remove(iio); - iio_device_free(iio); return 0; } -- GitLab From 8c7f6d562ed697ef559a535288e9ed1e730512bc Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Mon, 22 Jul 2013 12:02:00 +0100 Subject: [PATCH 516/942] staging: iio: spear_adc: Use devm_iio_device_alloc Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat Cc: Stefan Roese Cc: Viresh Kumar Signed-off-by: Jonathan Cameron --- drivers/staging/iio/adc/spear_adc.c | 30 ++++++++++++----------------- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/drivers/staging/iio/adc/spear_adc.c b/drivers/staging/iio/adc/spear_adc.c index 736219c30308f..20f2d555e7cdc 100644 --- a/drivers/staging/iio/adc/spear_adc.c +++ b/drivers/staging/iio/adc/spear_adc.c @@ -300,11 +300,10 @@ static int spear_adc_probe(struct platform_device *pdev) int ret = -ENODEV; int irq; - iodev = iio_device_alloc(sizeof(struct spear_adc_info)); + iodev = devm_iio_device_alloc(dev, sizeof(struct spear_adc_info)); if (!iodev) { dev_err(dev, "failed allocating iio device\n"); - ret = -ENOMEM; - goto errout1; + return -ENOMEM; } info = iio_priv(iodev); @@ -318,8 +317,7 @@ static int spear_adc_probe(struct platform_device *pdev) info->adc_base_spear6xx = of_iomap(np, 0); if (!info->adc_base_spear6xx) { dev_err(dev, "failed mapping memory\n"); - ret = -ENOMEM; - goto errout2; + return -ENOMEM; } info->adc_base_spear3xx = (struct adc_regs_spear3xx *)info->adc_base_spear6xx; @@ -327,33 +325,33 @@ static int spear_adc_probe(struct platform_device *pdev) info->clk = clk_get(dev, NULL); if (IS_ERR(info->clk)) { dev_err(dev, "failed getting clock\n"); - goto errout3; + goto errout1; } ret = clk_prepare_enable(info->clk); if (ret) { dev_err(dev, "failed enabling clock\n"); - goto errout4; + goto errout2; } irq = platform_get_irq(pdev, 0); if ((irq < 0) || (irq >= NR_IRQS)) { dev_err(dev, "failed getting interrupt resource\n"); ret = -EINVAL; - goto errout5; + goto errout3; } ret = devm_request_irq(dev, irq, spear_adc_isr, 0, MOD_NAME, info); if (ret < 0) { dev_err(dev, "failed requesting interrupt\n"); - goto errout5; + goto errout3; } if (of_property_read_u32(np, "sampling-frequency", &info->sampling_freq)) { dev_err(dev, "sampling-frequency missing in DT\n"); ret = -EINVAL; - goto errout5; + goto errout3; } /* @@ -383,21 +381,18 @@ static int spear_adc_probe(struct platform_device *pdev) ret = iio_device_register(iodev); if (ret) - goto errout5; + goto errout3; dev_info(dev, "SPEAR ADC driver loaded, IRQ %d\n", irq); return 0; -errout5: - clk_disable_unprepare(info->clk); -errout4: - clk_put(info->clk); errout3: - iounmap(info->adc_base_spear6xx); + clk_disable_unprepare(info->clk); errout2: - iio_device_free(iodev); + clk_put(info->clk); errout1: + iounmap(info->adc_base_spear6xx); return ret; } @@ -410,7 +405,6 @@ static int spear_adc_remove(struct platform_device *pdev) clk_disable_unprepare(info->clk); clk_put(info->clk); iounmap(info->adc_base_spear6xx); - iio_device_free(iodev); return 0; } -- GitLab From e434dcf3912d27a0c339db7b793a4b21613431c1 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Mon, 22 Jul 2013 12:03:00 +0100 Subject: [PATCH 517/942] staging: iio: light: isl29018: Use devm_iio_device_alloc Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat Acked-by: Rhyland Klein Signed-off-by: Jonathan Cameron --- drivers/staging/iio/light/isl29018.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/staging/iio/light/isl29018.c b/drivers/staging/iio/light/isl29018.c index 82478a59e42e7..351936c3efd69 100644 --- a/drivers/staging/iio/light/isl29018.c +++ b/drivers/staging/iio/light/isl29018.c @@ -550,11 +550,10 @@ static int isl29018_probe(struct i2c_client *client, struct iio_dev *indio_dev; int err; - indio_dev = iio_device_alloc(sizeof(*chip)); + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip)); if (indio_dev == NULL) { dev_err(&client->dev, "iio allocation fails\n"); - err = -ENOMEM; - goto exit; + return -ENOMEM; } chip = iio_priv(indio_dev); @@ -572,12 +571,12 @@ static int isl29018_probe(struct i2c_client *client, if (IS_ERR(chip->regmap)) { err = PTR_ERR(chip->regmap); dev_err(chip->dev, "regmap initialization failed: %d\n", err); - goto exit; + return err; } err = isl29018_chip_init(chip); if (err) - goto exit_iio_free; + return err; indio_dev->info = &isl29108_info; indio_dev->channels = isl29018_channels; @@ -588,14 +587,10 @@ static int isl29018_probe(struct i2c_client *client, err = iio_device_register(indio_dev); if (err) { dev_err(&client->dev, "iio registration fails\n"); - goto exit_iio_free; + return err; } return 0; -exit_iio_free: - iio_device_free(indio_dev); -exit: - return err; } static int isl29018_remove(struct i2c_client *client) @@ -604,7 +599,6 @@ static int isl29018_remove(struct i2c_client *client) dev_dbg(&client->dev, "%s()\n", __func__); iio_device_unregister(indio_dev); - iio_device_free(indio_dev); return 0; } -- GitLab From 80cab1da704e3f27fb4a631f95369fc31323e91c Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Mon, 22 Jul 2013 12:03:00 +0100 Subject: [PATCH 518/942] staging: iio: light: isl29028: Use devm_iio_device_alloc Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat Cc: Laxman Dewangan Signed-off-by: Jonathan Cameron --- drivers/staging/iio/light/isl29028.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/staging/iio/light/isl29028.c b/drivers/staging/iio/light/isl29028.c index 8bb0d03627f21..6014625920b04 100644 --- a/drivers/staging/iio/light/isl29028.c +++ b/drivers/staging/iio/light/isl29028.c @@ -482,7 +482,7 @@ static int isl29028_probe(struct i2c_client *client, struct iio_dev *indio_dev; int ret; - indio_dev = iio_device_alloc(sizeof(*chip)); + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip)); if (!indio_dev) { dev_err(&client->dev, "iio allocation fails\n"); return -ENOMEM; @@ -498,13 +498,13 @@ static int isl29028_probe(struct i2c_client *client, if (IS_ERR(chip->regmap)) { ret = PTR_ERR(chip->regmap); dev_err(chip->dev, "regmap initialization failed: %d\n", ret); - goto exit_iio_free; + return ret; } ret = isl29028_chip_init(chip); if (ret < 0) { dev_err(chip->dev, "chip initialization failed: %d\n", ret); - goto exit_iio_free; + return ret; } indio_dev->info = &isl29028_info; @@ -517,13 +517,9 @@ static int isl29028_probe(struct i2c_client *client, if (ret < 0) { dev_err(chip->dev, "iio registration fails with error %d\n", ret); - goto exit_iio_free; + return ret; } return 0; - -exit_iio_free: - iio_device_free(indio_dev); - return ret; } static int isl29028_remove(struct i2c_client *client) @@ -531,7 +527,6 @@ static int isl29028_remove(struct i2c_client *client) struct iio_dev *indio_dev = i2c_get_clientdata(client); iio_device_unregister(indio_dev); - iio_device_free(indio_dev); return 0; } -- GitLab From 6b545eed655e846c16fdf611e686dca54db76766 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 23 Jul 2013 07:47:00 +0100 Subject: [PATCH 519/942] iio: hid-sensor-accel-3d: Use devm_iio_device_alloc Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat Cc: Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- drivers/iio/accel/hid-sensor-accel-3d.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c index 275c5d7ea270b..68df3416b612e 100644 --- a/drivers/iio/accel/hid-sensor-accel-3d.c +++ b/drivers/iio/accel/hid-sensor-accel-3d.c @@ -282,11 +282,11 @@ static int hid_accel_3d_probe(struct platform_device *pdev) struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data; struct iio_chan_spec *channels; - indio_dev = iio_device_alloc(sizeof(struct accel_3d_state)); - if (indio_dev == NULL) { - ret = -ENOMEM; - goto error_ret; - } + indio_dev = devm_iio_device_alloc(&pdev->dev, + sizeof(struct accel_3d_state)); + if (indio_dev == NULL) + return -ENOMEM; + platform_set_drvdata(pdev, indio_dev); accel_state = iio_priv(indio_dev); @@ -298,15 +298,14 @@ static int hid_accel_3d_probe(struct platform_device *pdev) &accel_state->common_attributes); if (ret) { dev_err(&pdev->dev, "failed to setup common attributes\n"); - goto error_free_dev; + return ret; } channels = kmemdup(accel_3d_channels, sizeof(accel_3d_channels), GFP_KERNEL); if (!channels) { - ret = -ENOMEM; dev_err(&pdev->dev, "failed to duplicate channels\n"); - goto error_free_dev; + return -ENOMEM; } ret = accel_3d_parse_report(pdev, hsdev, channels, @@ -363,9 +362,6 @@ static int hid_accel_3d_probe(struct platform_device *pdev) iio_triggered_buffer_cleanup(indio_dev); error_free_dev_mem: kfree(indio_dev->channels); -error_free_dev: - iio_device_free(indio_dev); -error_ret: return ret; } @@ -380,7 +376,6 @@ static int hid_accel_3d_remove(struct platform_device *pdev) hid_sensor_remove_trigger(indio_dev); iio_triggered_buffer_cleanup(indio_dev); kfree(indio_dev->channels); - iio_device_free(indio_dev); return 0; } -- GitLab From 4ee309337e100042c1623c301a4b8ad2487b6330 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 23 Jul 2013 07:47:00 +0100 Subject: [PATCH 520/942] iio: accel: kxsd9: Use devm_iio_device_alloc Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat Signed-off-by: Jonathan Cameron --- drivers/iio/accel/kxsd9.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/iio/accel/kxsd9.c b/drivers/iio/accel/kxsd9.c index 7229645bf1d74..709c13259f14e 100644 --- a/drivers/iio/accel/kxsd9.c +++ b/drivers/iio/accel/kxsd9.c @@ -224,11 +224,10 @@ static int kxsd9_probe(struct spi_device *spi) struct kxsd9_state *st; int ret; - indio_dev = iio_device_alloc(sizeof(*st)); - if (indio_dev == NULL) { - ret = -ENOMEM; - goto error_ret; - } + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); + if (!indio_dev) + return -ENOMEM; + st = iio_priv(indio_dev); spi_set_drvdata(spi, indio_dev); @@ -247,20 +246,14 @@ static int kxsd9_probe(struct spi_device *spi) ret = iio_device_register(indio_dev); if (ret) - goto error_free_dev; + return ret; return 0; - -error_free_dev: - iio_device_free(indio_dev); -error_ret: - return ret; } static int kxsd9_remove(struct spi_device *spi) { iio_device_unregister(spi_get_drvdata(spi)); - iio_device_free(spi_get_drvdata(spi)); return 0; } -- GitLab From 6b7e0a9cd42a24e4e2c2a037773a12c375e25b69 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 23 Jul 2013 07:47:00 +0100 Subject: [PATCH 521/942] iio: accel: st_accel: Use devm_iio_device_alloc Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat Cc: Denis Ciocca Signed-off-by: Jonathan Cameron --- drivers/iio/accel/st_accel_core.c | 1 - drivers/iio/accel/st_accel_i2c.c | 15 ++++----------- drivers/iio/accel/st_accel_spi.c | 15 ++++----------- 3 files changed, 8 insertions(+), 23 deletions(-) diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c index aef3c9be73665..1458343f6f3fa 100644 --- a/drivers/iio/accel/st_accel_core.c +++ b/drivers/iio/accel/st_accel_core.c @@ -517,7 +517,6 @@ void st_accel_common_remove(struct iio_dev *indio_dev) st_sensors_deallocate_trigger(indio_dev); st_accel_deallocate_ring(indio_dev); } - iio_device_free(indio_dev); } EXPORT_SYMBOL(st_accel_common_remove); diff --git a/drivers/iio/accel/st_accel_i2c.c b/drivers/iio/accel/st_accel_i2c.c index 58d164d90dca1..d7bedbdfc81df 100644 --- a/drivers/iio/accel/st_accel_i2c.c +++ b/drivers/iio/accel/st_accel_i2c.c @@ -25,11 +25,9 @@ static int st_accel_i2c_probe(struct i2c_client *client, struct st_sensor_data *adata; int err; - indio_dev = iio_device_alloc(sizeof(*adata)); - if (indio_dev == NULL) { - err = -ENOMEM; - goto iio_device_alloc_error; - } + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*adata)); + if (!indio_dev) + return -ENOMEM; adata = iio_priv(indio_dev); adata->dev = &client->dev; @@ -38,14 +36,9 @@ static int st_accel_i2c_probe(struct i2c_client *client, err = st_accel_common_probe(indio_dev, client->dev.platform_data); if (err < 0) - goto st_accel_common_probe_error; + return err; return 0; - -st_accel_common_probe_error: - iio_device_free(indio_dev); -iio_device_alloc_error: - return err; } static int st_accel_i2c_remove(struct i2c_client *client) diff --git a/drivers/iio/accel/st_accel_spi.c b/drivers/iio/accel/st_accel_spi.c index 21ed9296311fc..195639646e342 100644 --- a/drivers/iio/accel/st_accel_spi.c +++ b/drivers/iio/accel/st_accel_spi.c @@ -24,11 +24,9 @@ static int st_accel_spi_probe(struct spi_device *spi) struct st_sensor_data *adata; int err; - indio_dev = iio_device_alloc(sizeof(*adata)); - if (indio_dev == NULL) { - err = -ENOMEM; - goto iio_device_alloc_error; - } + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adata)); + if (!indio_dev) + return -ENOMEM; adata = iio_priv(indio_dev); adata->dev = &spi->dev; @@ -37,14 +35,9 @@ static int st_accel_spi_probe(struct spi_device *spi) err = st_accel_common_probe(indio_dev, spi->dev.platform_data); if (err < 0) - goto st_accel_common_probe_error; + return err; return 0; - -st_accel_common_probe_error: - iio_device_free(indio_dev); -iio_device_alloc_error: - return err; } static int st_accel_spi_remove(struct spi_device *spi) -- GitLab From 224b995a88aacbe638b3282a674af5e9082bb770 Mon Sep 17 00:00:00 2001 From: Oleksandr Kravchenko Date: Tue, 23 Jul 2013 09:39:00 +0100 Subject: [PATCH 522/942] Documentation: devres: add IIO device alloc/free functions to list Add devm_iio_device_alloc() and devm_iio_device_free() functions to list of supported calls. Signed-off-by: Oleksandr Kravchenko Signed-off-by: Jonathan Cameron --- Documentation/driver-model/devres.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt index b4671459857f8..1d32332929896 100644 --- a/Documentation/driver-model/devres.txt +++ b/Documentation/driver-model/devres.txt @@ -237,6 +237,10 @@ MEM devm_kzalloc() devm_kfree() +IIO + devm_iio_device_alloc() + devm_iio_device_free() + IO region devm_request_region() devm_request_mem_region() -- GitLab From a064813079c203094a5a22cc6f74fef547720697 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 23 Jul 2013 09:46:00 +0100 Subject: [PATCH 523/942] iio: adc: ti_am335x_adc: Use devm_iio_device_alloc Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat Cc: Rachna Patil Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ti_am335x_adc.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c index 0ad208a69c298..b53867cb9cdc5 100644 --- a/drivers/iio/adc/ti_am335x_adc.c +++ b/drivers/iio/adc/ti_am335x_adc.c @@ -202,11 +202,11 @@ static int tiadc_probe(struct platform_device *pdev) return -EINVAL; } - indio_dev = iio_device_alloc(sizeof(struct tiadc_device)); + indio_dev = devm_iio_device_alloc(&pdev->dev, + sizeof(struct tiadc_device)); if (indio_dev == NULL) { dev_err(&pdev->dev, "failed to allocate iio device\n"); - err = -ENOMEM; - goto err_ret; + return -ENOMEM; } adc_dev = iio_priv(indio_dev); @@ -227,7 +227,7 @@ static int tiadc_probe(struct platform_device *pdev) err = tiadc_channel_init(indio_dev, adc_dev->channels); if (err < 0) - goto err_free_device; + return err; err = iio_device_register(indio_dev); if (err) @@ -239,9 +239,6 @@ static int tiadc_probe(struct platform_device *pdev) err_free_channels: tiadc_channels_remove(indio_dev); -err_free_device: - iio_device_free(indio_dev); -err_ret: return err; } @@ -257,8 +254,6 @@ static int tiadc_remove(struct platform_device *pdev) step_en = get_adc_step_mask(adc_dev); am335x_tsc_se_clr(adc_dev->mfd_tscadc, step_en); - iio_device_free(indio_dev); - return 0; } -- GitLab From be85697bfcde2eed7e9c55dbb2265ec8a8ea2f43 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 23 Jul 2013 09:46:00 +0100 Subject: [PATCH 524/942] iio: adc: Update ti_am335x_adc Kconfig entry Make the string more readable to distinguish it from other TI ADCs. Signed-off-by: Sachin Kamat Signed-off-by: Jonathan Cameron --- drivers/iio/adc/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index dd6bd1bff4b7e..f725b4581f046 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -165,7 +165,7 @@ config TI_ADC081C called ti-adc081c. config TI_AM335X_ADC - tristate "TI's ADC driver" + tristate "TI's AM335X ADC driver" depends on MFD_TI_AM335X_TSCADC help Say yes here to build support for Texas Instruments ADC -- GitLab From d9a0134e7aa048f3de4477d93598974ea8ecae7a Mon Sep 17 00:00:00 2001 From: Oleksandr Kravchenko Date: Mon, 22 Jul 2013 12:16:00 +0100 Subject: [PATCH 525/942] iio: core: Avoid double minus in sysfs output This patch fixes the issue with double minus in output when reading channels from sysfs for IIO_VAL_INT_PLUS_MICRO and IIO_VAL_INT_PLUS_NANO cases. Until this patch if val and val2 both are negatives output string contains "--" before digits. It is result of "-%d..." in sprintf() format. Signed-off-by: Oleksandr Kravchenko Signed-off-by: Jonathan Cameron --- drivers/iio/industrialio-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index d56d1229e2d6f..97f0297b120f4 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -383,14 +383,14 @@ static ssize_t iio_read_channel_info(struct device *dev, scale_db = true; case IIO_VAL_INT_PLUS_MICRO: if (val2 < 0) - return sprintf(buf, "-%d.%06u%s\n", val, -val2, + return sprintf(buf, "-%ld.%06u%s\n", abs(val), -val2, scale_db ? " dB" : ""); else return sprintf(buf, "%d.%06u%s\n", val, val2, scale_db ? " dB" : ""); case IIO_VAL_INT_PLUS_NANO: if (val2 < 0) - return sprintf(buf, "-%d.%09u\n", val, -val2); + return sprintf(buf, "-%ld.%09u\n", abs(val), -val2); else return sprintf(buf, "%d.%09u\n", val, val2); case IIO_VAL_FRACTIONAL: -- GitLab From f15304143e4aa3ddd23a96bc0d119a83a566cc0f Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 17 Jul 2013 15:44:00 +0100 Subject: [PATCH 526/942] staging:iio:adis16260: Fix reading calibscale Return the actual value read from the device and not just the mask. Signed-off-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/staging/iio/gyro/adis16260_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/gyro/adis16260_core.c b/drivers/staging/iio/gyro/adis16260_core.c index 620d63fd099bc..0b344921048b5 100644 --- a/drivers/staging/iio/gyro/adis16260_core.c +++ b/drivers/staging/iio/gyro/adis16260_core.c @@ -223,7 +223,7 @@ static int adis16260_read_raw(struct iio_dev *indio_dev, mutex_unlock(&indio_dev->mlock); return ret; } - *val = (1 << bits) - 1; + *val = val16; mutex_unlock(&indio_dev->mlock); return IIO_VAL_INT; } -- GitLab From 63892165fcd29cd670927c8b047142c310fa209e Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 17 Jul 2013 15:44:00 +0100 Subject: [PATCH 527/942] staging:iio:adis16260: Drop unused 'negate' property Remove the unused 'negate' property from the driver state struct. This also means we can now use the adis struct directly as the driver data. Signed-off-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/staging/iio/gyro/adis16260.h | 9 --- drivers/staging/iio/gyro/adis16260_core.c | 60 +++++++++---------- .../iio/gyro/adis16260_platform_data.h | 2 - 3 files changed, 28 insertions(+), 43 deletions(-) diff --git a/drivers/staging/iio/gyro/adis16260.h b/drivers/staging/iio/gyro/adis16260.h index df3c0b7e954a7..05bf27429c815 100644 --- a/drivers/staging/iio/gyro/adis16260.h +++ b/drivers/staging/iio/gyro/adis16260.h @@ -76,15 +76,6 @@ #define ADIS16260_SPI_BURST (u32)(1000 * 1000) #define ADIS16260_SPI_FAST (u32)(2000 * 1000) -/** - * struct adis16260_state - device instance specific data - * @negate: negate the scale parameter - **/ -struct adis16260_state { - unsigned negate:1; - struct adis adis; -}; - /* At the moment triggers are only used for ring buffer * filling. This may change! */ diff --git a/drivers/staging/iio/gyro/adis16260_core.c b/drivers/staging/iio/gyro/adis16260_core.c index 0b344921048b5..83ec32ea99217 100644 --- a/drivers/staging/iio/gyro/adis16260_core.c +++ b/drivers/staging/iio/gyro/adis16260_core.c @@ -29,8 +29,8 @@ static ssize_t adis16260_read_frequency_available(struct device *dev, char *buf) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); - struct adis16260_state *st = iio_priv(indio_dev); - if (spi_get_device_id(st->adis.spi)->driver_data) + struct adis *adis = iio_priv(indio_dev); + if (spi_get_device_id(adis->spi)->driver_data) return sprintf(buf, "%s\n", "0.129 ~ 256"); else return sprintf(buf, "%s\n", "256 2048"); @@ -41,15 +41,15 @@ static ssize_t adis16260_read_frequency(struct device *dev, char *buf) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); - struct adis16260_state *st = iio_priv(indio_dev); + struct adis *adis = iio_priv(indio_dev); int ret, len = 0; u16 t; int sps; - ret = adis_read_reg_16(&st->adis, ADIS16260_SMPL_PRD, &t); + ret = adis_read_reg_16(adis, ADIS16260_SMPL_PRD, &t); if (ret) return ret; - if (spi_get_device_id(st->adis.spi)->driver_data) /* If an adis16251 */ + if (spi_get_device_id(adis->spi)->driver_data) /* If an adis16251 */ sps = (t & ADIS16260_SMPL_PRD_TIME_BASE) ? 8 : 256; else sps = (t & ADIS16260_SMPL_PRD_TIME_BASE) ? 66 : 2048; @@ -64,7 +64,7 @@ static ssize_t adis16260_write_frequency(struct device *dev, size_t len) { struct iio_dev *indio_dev = dev_to_iio_dev(dev); - struct adis16260_state *st = iio_priv(indio_dev); + struct adis *adis = iio_priv(indio_dev); long val; int ret; u8 t; @@ -76,7 +76,7 @@ static ssize_t adis16260_write_frequency(struct device *dev, return -EINVAL; mutex_lock(&indio_dev->mlock); - if (spi_get_device_id(st->adis.spi)->driver_data) { + if (spi_get_device_id(adis->spi)->driver_data) { t = (256 / val); if (t > 0) t--; @@ -88,12 +88,10 @@ static ssize_t adis16260_write_frequency(struct device *dev, t &= ADIS16260_SMPL_PRD_DIV_MASK; } if ((t & ADIS16260_SMPL_PRD_DIV_MASK) >= 0x0A) - st->adis.spi->max_speed_hz = ADIS16260_SPI_SLOW; + adis->spi->max_speed_hz = ADIS16260_SPI_SLOW; else - st->adis.spi->max_speed_hz = ADIS16260_SPI_FAST; - ret = adis_write_reg_8(&st->adis, - ADIS16260_SMPL_PRD, - t); + adis->spi->max_speed_hz = ADIS16260_SPI_FAST; + ret = adis_write_reg_8(adis, ADIS16260_SMPL_PRD, t); mutex_unlock(&indio_dev->mlock); @@ -103,11 +101,11 @@ static ssize_t adis16260_write_frequency(struct device *dev, /* Power down the device */ static int adis16260_stop_device(struct iio_dev *indio_dev) { - struct adis16260_state *st = iio_priv(indio_dev); + struct adis *adis = iio_priv(indio_dev); int ret; u16 val = ADIS16260_SLP_CNT_POWER_OFF; - ret = adis_write_reg_16(&st->adis, ADIS16260_SLP_CNT, val); + ret = adis_write_reg_16(adis, ADIS16260_SLP_CNT, val); if (ret) dev_err(&indio_dev->dev, "problem with turning device off: SLP_CNT"); @@ -146,7 +144,7 @@ static int adis16260_read_raw(struct iio_dev *indio_dev, int *val, int *val2, long mask) { - struct adis16260_state *st = iio_priv(indio_dev); + struct adis *adis = iio_priv(indio_dev); int ret; int bits; u8 addr; @@ -160,7 +158,7 @@ static int adis16260_read_raw(struct iio_dev *indio_dev, switch (chan->type) { case IIO_ANGL_VEL: *val = 0; - if (spi_get_device_id(st->adis.spi)->driver_data) { + if (spi_get_device_id(adis->spi)->driver_data) { /* 0.01832 degree / sec */ *val2 = IIO_DEGREE_TO_RAD(18320); } else { @@ -198,7 +196,7 @@ static int adis16260_read_raw(struct iio_dev *indio_dev, } mutex_lock(&indio_dev->mlock); addr = adis16260_addresses[chan->scan_index][0]; - ret = adis_read_reg_16(&st->adis, addr, &val16); + ret = adis_read_reg_16(adis, addr, &val16); if (ret) { mutex_unlock(&indio_dev->mlock); return ret; @@ -218,7 +216,7 @@ static int adis16260_read_raw(struct iio_dev *indio_dev, } mutex_lock(&indio_dev->mlock); addr = adis16260_addresses[chan->scan_index][1]; - ret = adis_read_reg_16(&st->adis, addr, &val16); + ret = adis_read_reg_16(adis, addr, &val16); if (ret) { mutex_unlock(&indio_dev->mlock); return ret; @@ -236,7 +234,7 @@ static int adis16260_write_raw(struct iio_dev *indio_dev, int val2, long mask) { - struct adis16260_state *st = iio_priv(indio_dev); + struct adis *adis = iio_priv(indio_dev); int bits = 12; s16 val16; u8 addr; @@ -244,11 +242,11 @@ static int adis16260_write_raw(struct iio_dev *indio_dev, case IIO_CHAN_INFO_CALIBBIAS: val16 = val & ((1 << bits) - 1); addr = adis16260_addresses[chan->scan_index][0]; - return adis_write_reg_16(&st->adis, addr, val16); + return adis_write_reg_16(adis, addr, val16); case IIO_CHAN_INFO_CALIBSCALE: val16 = val & ((1 << bits) - 1); addr = adis16260_addresses[chan->scan_index][1]; - return adis_write_reg_16(&st->adis, addr, val16); + return adis_write_reg_16(adis, addr, val16); } return -EINVAL; } @@ -305,18 +303,16 @@ static int adis16260_probe(struct spi_device *spi) { int ret; struct adis16260_platform_data *pd = spi->dev.platform_data; - struct adis16260_state *st; struct iio_dev *indio_dev; + struct adis *adis; /* setup the industrialio driver allocated elements */ - indio_dev = iio_device_alloc(sizeof(*st)); + indio_dev = iio_device_alloc(sizeof(*adis)); if (indio_dev == NULL) { ret = -ENOMEM; goto error_ret; } - st = iio_priv(indio_dev); - if (pd) - st->negate = pd->negate; + adis = iio_priv(indio_dev); /* this is only used for removal purposes */ spi_set_drvdata(spi, indio_dev); @@ -344,11 +340,11 @@ static int adis16260_probe(struct spi_device *spi) indio_dev->num_channels = ARRAY_SIZE(adis16260_channels_x); indio_dev->modes = INDIO_DIRECT_MODE; - ret = adis_init(&st->adis, indio_dev, spi, &adis16260_data); + ret = adis_init(adis, indio_dev, spi, &adis16260_data); if (ret) goto error_free_dev; - ret = adis_setup_buffer_and_trigger(&st->adis, indio_dev, NULL); + ret = adis_setup_buffer_and_trigger(adis, indio_dev, NULL); if (ret) goto error_free_dev; @@ -367,7 +363,7 @@ static int adis16260_probe(struct spi_device *spi) } /* Get the device into a sane initial state */ - ret = adis_initial_startup(&st->adis); + ret = adis_initial_startup(adis); if (ret) goto error_cleanup_buffer_trigger; ret = iio_device_register(indio_dev); @@ -377,7 +373,7 @@ static int adis16260_probe(struct spi_device *spi) return 0; error_cleanup_buffer_trigger: - adis_cleanup_buffer_and_trigger(&st->adis, indio_dev); + adis_cleanup_buffer_and_trigger(adis, indio_dev); error_free_dev: iio_device_free(indio_dev); error_ret: @@ -387,11 +383,11 @@ static int adis16260_probe(struct spi_device *spi) static int adis16260_remove(struct spi_device *spi) { struct iio_dev *indio_dev = spi_get_drvdata(spi); - struct adis16260_state *st = iio_priv(indio_dev); + struct adis *adis = iio_priv(indio_dev); iio_device_unregister(indio_dev); adis16260_stop_device(indio_dev); - adis_cleanup_buffer_and_trigger(&st->adis, indio_dev); + adis_cleanup_buffer_and_trigger(adis, indio_dev); iio_device_free(indio_dev); return 0; diff --git a/drivers/staging/iio/gyro/adis16260_platform_data.h b/drivers/staging/iio/gyro/adis16260_platform_data.h index 12802e97be924..73c5899156050 100644 --- a/drivers/staging/iio/gyro/adis16260_platform_data.h +++ b/drivers/staging/iio/gyro/adis16260_platform_data.h @@ -11,9 +11,7 @@ /** * struct adis16260_platform_data - instance specific data * @direction: x y or z - * @negate: flag to indicate value should be inverted. **/ struct adis16260_platform_data { char direction; - unsigned negate:1; }; -- GitLab From e1b83f43eb94437847b70109870e47c334fdef29 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 17 Jul 2013 15:44:00 +0100 Subject: [PATCH 528/942] staging:iio:adis16260: Remove support for orientation mapping The adis16260 driver implements a unique feature in that it allows to change the orientation of the gyroscope channel by specifying the orientation in platform data. This feature is as far as I can see unused though and makes the driver unnecessarily complex. So this patch removes the support for it. If it turns out we need this, the cleanest approach to implement it is by adding support for orientation mapping inside the IIO core so it is available to all drivers. Signed-off-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/staging/iio/gyro/adis16260.h | 1 - drivers/staging/iio/gyro/adis16260_core.c | 49 +++++-------------- .../iio/gyro/adis16260_platform_data.h | 17 ------- 3 files changed, 13 insertions(+), 54 deletions(-) delete mode 100644 drivers/staging/iio/gyro/adis16260_platform_data.h diff --git a/drivers/staging/iio/gyro/adis16260.h b/drivers/staging/iio/gyro/adis16260.h index 05bf27429c815..00455afa2cfa5 100644 --- a/drivers/staging/iio/gyro/adis16260.h +++ b/drivers/staging/iio/gyro/adis16260.h @@ -1,7 +1,6 @@ #ifndef SPI_ADIS16260_H_ #define SPI_ADIS16260_H_ -#include "adis16260_platform_data.h" #include #define ADIS16260_STARTUP_DELAY 220 /* ms */ diff --git a/drivers/staging/iio/gyro/adis16260_core.c b/drivers/staging/iio/gyro/adis16260_core.c index 83ec32ea99217..5cec675101ffe 100644 --- a/drivers/staging/iio/gyro/adis16260_core.c +++ b/drivers/staging/iio/gyro/adis16260_core.c @@ -119,21 +119,16 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO, static IIO_DEVICE_ATTR(sampling_frequency_available, S_IRUGO, adis16260_read_frequency_available, NULL, 0); -#define ADIS16260_GYRO_CHANNEL_SET(axis, mod) \ -struct iio_chan_spec adis16260_channels_##axis[] = { \ - ADIS_GYRO_CHAN(mod, ADIS16260_GYRO_OUT, ADIS16260_SCAN_GYRO, \ - BIT(IIO_CHAN_INFO_CALIBBIAS) | \ - BIT(IIO_CHAN_INFO_CALIBSCALE), 14), \ - ADIS_INCLI_CHAN(mod, ADIS16260_ANGL_OUT, ADIS16260_SCAN_ANGL, 0, 14), \ - ADIS_TEMP_CHAN(ADIS16260_TEMP_OUT, ADIS16260_SCAN_TEMP, 12), \ - ADIS_SUPPLY_CHAN(ADIS16260_SUPPLY_OUT, ADIS16260_SCAN_SUPPLY, 12), \ - ADIS_AUX_ADC_CHAN(ADIS16260_AUX_ADC, ADIS16260_SCAN_AUX_ADC, 12), \ - IIO_CHAN_SOFT_TIMESTAMP(5), \ -} - -static const ADIS16260_GYRO_CHANNEL_SET(x, X); -static const ADIS16260_GYRO_CHANNEL_SET(y, Y); -static const ADIS16260_GYRO_CHANNEL_SET(z, Z); +static const struct iio_chan_spec adis16260_channels[] = { + ADIS_GYRO_CHAN(X, ADIS16260_GYRO_OUT, ADIS16260_SCAN_GYRO, + BIT(IIO_CHAN_INFO_CALIBBIAS) | + BIT(IIO_CHAN_INFO_CALIBSCALE), 14), + ADIS_INCLI_CHAN(X, ADIS16260_ANGL_OUT, ADIS16260_SCAN_ANGL, 0, 14), + ADIS_TEMP_CHAN(ADIS16260_TEMP_OUT, ADIS16260_SCAN_TEMP, 12), + ADIS_SUPPLY_CHAN(ADIS16260_SUPPLY_OUT, ADIS16260_SCAN_SUPPLY, 12), + ADIS_AUX_ADC_CHAN(ADIS16260_AUX_ADC, ADIS16260_SCAN_AUX_ADC, 12), + IIO_CHAN_SOFT_TIMESTAMP(5), +}; static const u8 adis16260_addresses[][2] = { [ADIS16260_SCAN_GYRO] = { ADIS16260_GYRO_OFF, ADIS16260_GYRO_SCALE }, @@ -301,10 +296,9 @@ static const struct adis_data adis16260_data = { static int adis16260_probe(struct spi_device *spi) { - int ret; - struct adis16260_platform_data *pd = spi->dev.platform_data; struct iio_dev *indio_dev; struct adis *adis; + int ret; /* setup the industrialio driver allocated elements */ indio_dev = iio_device_alloc(sizeof(*adis)); @@ -319,25 +313,8 @@ static int adis16260_probe(struct spi_device *spi) indio_dev->name = spi_get_device_id(spi)->name; indio_dev->dev.parent = &spi->dev; indio_dev->info = &adis16260_info; - indio_dev->num_channels - = ARRAY_SIZE(adis16260_channels_x); - if (pd && pd->direction) - switch (pd->direction) { - case 'x': - indio_dev->channels = adis16260_channels_x; - break; - case 'y': - indio_dev->channels = adis16260_channels_y; - break; - case 'z': - indio_dev->channels = adis16260_channels_z; - break; - default: - return -EINVAL; - } - else - indio_dev->channels = adis16260_channels_x; - indio_dev->num_channels = ARRAY_SIZE(adis16260_channels_x); + indio_dev->channels = adis16260_channels; + indio_dev->num_channels = ARRAY_SIZE(adis16260_channels); indio_dev->modes = INDIO_DIRECT_MODE; ret = adis_init(adis, indio_dev, spi, &adis16260_data); diff --git a/drivers/staging/iio/gyro/adis16260_platform_data.h b/drivers/staging/iio/gyro/adis16260_platform_data.h deleted file mode 100644 index 73c5899156050..0000000000000 --- a/drivers/staging/iio/gyro/adis16260_platform_data.h +++ /dev/null @@ -1,17 +0,0 @@ -/* - * ADIS16260 Programmable Digital Gyroscope Sensor Driver Platform Data - * - * Based on adis16255.h Matthia Brugger - * - * Copyright (C) 2010 Fraunhofer Institute for Integrated Circuits - * - * Licensed under the GPL-2 or later. - */ - -/** - * struct adis16260_platform_data - instance specific data - * @direction: x y or z - **/ -struct adis16260_platform_data { - char direction; -}; -- GitLab From 4dcef4af52b67c25abbe6a7fa72a9099fb48165c Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 17 Jul 2013 15:44:00 +0100 Subject: [PATCH 529/942] staging:iio:adis16260: Don't set default scan mask The recomentation for IIO driver is to leave all scan elements off by default and let userspace decide which channels need to be enabled. Signed-off-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/staging/iio/gyro/adis16260_core.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/drivers/staging/iio/gyro/adis16260_core.c b/drivers/staging/iio/gyro/adis16260_core.c index 5cec675101ffe..e42a581f27dbf 100644 --- a/drivers/staging/iio/gyro/adis16260_core.c +++ b/drivers/staging/iio/gyro/adis16260_core.c @@ -325,20 +325,6 @@ static int adis16260_probe(struct spi_device *spi) if (ret) goto error_free_dev; - if (indio_dev->buffer) { - /* Set default scan mode */ - iio_scan_mask_set(indio_dev, indio_dev->buffer, - ADIS16260_SCAN_SUPPLY); - iio_scan_mask_set(indio_dev, indio_dev->buffer, - ADIS16260_SCAN_GYRO); - iio_scan_mask_set(indio_dev, indio_dev->buffer, - ADIS16260_SCAN_AUX_ADC); - iio_scan_mask_set(indio_dev, indio_dev->buffer, - ADIS16260_SCAN_TEMP); - iio_scan_mask_set(indio_dev, indio_dev->buffer, - ADIS16260_SCAN_ANGL); - } - /* Get the device into a sane initial state */ ret = adis_initial_startup(adis); if (ret) -- GitLab From 988c79a95e30dac019777e818cbfab6fdc4057b4 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 17 Jul 2013 15:44:00 +0100 Subject: [PATCH 530/942] staging:iio:adis16260: Remove separate header The header is only used by a single C file, just put the register defines directly into that C file and remove the header. Signed-off-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/staging/iio/gyro/adis16260.h | 88 ----------------------- drivers/staging/iio/gyro/adis16260_core.c | 83 ++++++++++++++++++++- 2 files changed, 82 insertions(+), 89 deletions(-) delete mode 100644 drivers/staging/iio/gyro/adis16260.h diff --git a/drivers/staging/iio/gyro/adis16260.h b/drivers/staging/iio/gyro/adis16260.h deleted file mode 100644 index 00455afa2cfa5..0000000000000 --- a/drivers/staging/iio/gyro/adis16260.h +++ /dev/null @@ -1,88 +0,0 @@ -#ifndef SPI_ADIS16260_H_ -#define SPI_ADIS16260_H_ - -#include - -#define ADIS16260_STARTUP_DELAY 220 /* ms */ - -#define ADIS16260_FLASH_CNT 0x00 /* Flash memory write count */ -#define ADIS16260_SUPPLY_OUT 0x02 /* Power supply measurement */ -#define ADIS16260_GYRO_OUT 0x04 /* X-axis gyroscope output */ -#define ADIS16260_AUX_ADC 0x0A /* analog input channel measurement */ -#define ADIS16260_TEMP_OUT 0x0C /* internal temperature measurement */ -#define ADIS16260_ANGL_OUT 0x0E /* angle displacement */ -#define ADIS16260_GYRO_OFF 0x14 /* Calibration, offset/bias adjustment */ -#define ADIS16260_GYRO_SCALE 0x16 /* Calibration, scale adjustment */ -#define ADIS16260_ALM_MAG1 0x20 /* Alarm 1 magnitude/polarity setting */ -#define ADIS16260_ALM_MAG2 0x22 /* Alarm 2 magnitude/polarity setting */ -#define ADIS16260_ALM_SMPL1 0x24 /* Alarm 1 dynamic rate of change setting */ -#define ADIS16260_ALM_SMPL2 0x26 /* Alarm 2 dynamic rate of change setting */ -#define ADIS16260_ALM_CTRL 0x28 /* Alarm control */ -#define ADIS16260_AUX_DAC 0x30 /* Auxiliary DAC data */ -#define ADIS16260_GPIO_CTRL 0x32 /* Control, digital I/O line */ -#define ADIS16260_MSC_CTRL 0x34 /* Control, data ready, self-test settings */ -#define ADIS16260_SMPL_PRD 0x36 /* Control, internal sample rate */ -#define ADIS16260_SENS_AVG 0x38 /* Control, dynamic range, filtering */ -#define ADIS16260_SLP_CNT 0x3A /* Control, sleep mode initiation */ -#define ADIS16260_DIAG_STAT 0x3C /* Diagnostic, error flags */ -#define ADIS16260_GLOB_CMD 0x3E /* Control, global commands */ -#define ADIS16260_LOT_ID1 0x52 /* Lot Identification Code 1 */ -#define ADIS16260_LOT_ID2 0x54 /* Lot Identification Code 2 */ -#define ADIS16260_PROD_ID 0x56 /* Product identifier; - * convert to decimal = 16,265/16,260 */ -#define ADIS16260_SERIAL_NUM 0x58 /* Serial number */ - -#define ADIS16260_ERROR_ACTIVE (1<<14) -#define ADIS16260_NEW_DATA (1<<15) - -/* MSC_CTRL */ -#define ADIS16260_MSC_CTRL_MEM_TEST (1<<11) -/* Internal self-test enable */ -#define ADIS16260_MSC_CTRL_INT_SELF_TEST (1<<10) -#define ADIS16260_MSC_CTRL_NEG_SELF_TEST (1<<9) -#define ADIS16260_MSC_CTRL_POS_SELF_TEST (1<<8) -#define ADIS16260_MSC_CTRL_DATA_RDY_EN (1<<2) -#define ADIS16260_MSC_CTRL_DATA_RDY_POL_HIGH (1<<1) -#define ADIS16260_MSC_CTRL_DATA_RDY_DIO2 (1<<0) - -/* SMPL_PRD */ -/* Time base (tB): 0 = 1.953 ms, 1 = 60.54 ms */ -#define ADIS16260_SMPL_PRD_TIME_BASE (1<<7) -#define ADIS16260_SMPL_PRD_DIV_MASK 0x7F - -/* SLP_CNT */ -#define ADIS16260_SLP_CNT_POWER_OFF 0x80 - -/* DIAG_STAT */ -#define ADIS16260_DIAG_STAT_ALARM2 (1<<9) -#define ADIS16260_DIAG_STAT_ALARM1 (1<<8) -#define ADIS16260_DIAG_STAT_FLASH_CHK_BIT 6 -#define ADIS16260_DIAG_STAT_SELF_TEST_BIT 5 -#define ADIS16260_DIAG_STAT_OVERFLOW_BIT 4 -#define ADIS16260_DIAG_STAT_SPI_FAIL_BIT 3 -#define ADIS16260_DIAG_STAT_FLASH_UPT_BIT 2 -#define ADIS16260_DIAG_STAT_POWER_HIGH_BIT 1 -#define ADIS16260_DIAG_STAT_POWER_LOW_BIT 0 - -/* GLOB_CMD */ -#define ADIS16260_GLOB_CMD_SW_RESET (1<<7) -#define ADIS16260_GLOB_CMD_FLASH_UPD (1<<3) -#define ADIS16260_GLOB_CMD_DAC_LATCH (1<<2) -#define ADIS16260_GLOB_CMD_FAC_CALIB (1<<1) -#define ADIS16260_GLOB_CMD_AUTO_NULL (1<<0) - -#define ADIS16260_SPI_SLOW (u32)(300 * 1000) -#define ADIS16260_SPI_BURST (u32)(1000 * 1000) -#define ADIS16260_SPI_FAST (u32)(2000 * 1000) - -/* At the moment triggers are only used for ring buffer - * filling. This may change! - */ - -#define ADIS16260_SCAN_GYRO 0 -#define ADIS16260_SCAN_SUPPLY 1 -#define ADIS16260_SCAN_AUX_ADC 2 -#define ADIS16260_SCAN_TEMP 3 -#define ADIS16260_SCAN_ANGL 4 - -#endif /* SPI_ADIS16260_H_ */ diff --git a/drivers/staging/iio/gyro/adis16260_core.c b/drivers/staging/iio/gyro/adis16260_core.c index e42a581f27dbf..a01c2438302f1 100644 --- a/drivers/staging/iio/gyro/adis16260_core.c +++ b/drivers/staging/iio/gyro/adis16260_core.c @@ -21,8 +21,89 @@ #include #include #include +#include + +#define ADIS16260_STARTUP_DELAY 220 /* ms */ + +#define ADIS16260_FLASH_CNT 0x00 /* Flash memory write count */ +#define ADIS16260_SUPPLY_OUT 0x02 /* Power supply measurement */ +#define ADIS16260_GYRO_OUT 0x04 /* X-axis gyroscope output */ +#define ADIS16260_AUX_ADC 0x0A /* analog input channel measurement */ +#define ADIS16260_TEMP_OUT 0x0C /* internal temperature measurement */ +#define ADIS16260_ANGL_OUT 0x0E /* angle displacement */ +#define ADIS16260_GYRO_OFF 0x14 /* Calibration, offset/bias adjustment */ +#define ADIS16260_GYRO_SCALE 0x16 /* Calibration, scale adjustment */ +#define ADIS16260_ALM_MAG1 0x20 /* Alarm 1 magnitude/polarity setting */ +#define ADIS16260_ALM_MAG2 0x22 /* Alarm 2 magnitude/polarity setting */ +#define ADIS16260_ALM_SMPL1 0x24 /* Alarm 1 dynamic rate of change setting */ +#define ADIS16260_ALM_SMPL2 0x26 /* Alarm 2 dynamic rate of change setting */ +#define ADIS16260_ALM_CTRL 0x28 /* Alarm control */ +#define ADIS16260_AUX_DAC 0x30 /* Auxiliary DAC data */ +#define ADIS16260_GPIO_CTRL 0x32 /* Control, digital I/O line */ +#define ADIS16260_MSC_CTRL 0x34 /* Control, data ready, self-test settings */ +#define ADIS16260_SMPL_PRD 0x36 /* Control, internal sample rate */ +#define ADIS16260_SENS_AVG 0x38 /* Control, dynamic range, filtering */ +#define ADIS16260_SLP_CNT 0x3A /* Control, sleep mode initiation */ +#define ADIS16260_DIAG_STAT 0x3C /* Diagnostic, error flags */ +#define ADIS16260_GLOB_CMD 0x3E /* Control, global commands */ +#define ADIS16260_LOT_ID1 0x52 /* Lot Identification Code 1 */ +#define ADIS16260_LOT_ID2 0x54 /* Lot Identification Code 2 */ +#define ADIS16260_PROD_ID 0x56 /* Product identifier; + * convert to decimal = 16,265/16,260 */ +#define ADIS16260_SERIAL_NUM 0x58 /* Serial number */ + +#define ADIS16260_ERROR_ACTIVE (1<<14) +#define ADIS16260_NEW_DATA (1<<15) + +/* MSC_CTRL */ +#define ADIS16260_MSC_CTRL_MEM_TEST (1<<11) +/* Internal self-test enable */ +#define ADIS16260_MSC_CTRL_INT_SELF_TEST (1<<10) +#define ADIS16260_MSC_CTRL_NEG_SELF_TEST (1<<9) +#define ADIS16260_MSC_CTRL_POS_SELF_TEST (1<<8) +#define ADIS16260_MSC_CTRL_DATA_RDY_EN (1<<2) +#define ADIS16260_MSC_CTRL_DATA_RDY_POL_HIGH (1<<1) +#define ADIS16260_MSC_CTRL_DATA_RDY_DIO2 (1<<0) + +/* SMPL_PRD */ +/* Time base (tB): 0 = 1.953 ms, 1 = 60.54 ms */ +#define ADIS16260_SMPL_PRD_TIME_BASE (1<<7) +#define ADIS16260_SMPL_PRD_DIV_MASK 0x7F + +/* SLP_CNT */ +#define ADIS16260_SLP_CNT_POWER_OFF 0x80 + +/* DIAG_STAT */ +#define ADIS16260_DIAG_STAT_ALARM2 (1<<9) +#define ADIS16260_DIAG_STAT_ALARM1 (1<<8) +#define ADIS16260_DIAG_STAT_FLASH_CHK_BIT 6 +#define ADIS16260_DIAG_STAT_SELF_TEST_BIT 5 +#define ADIS16260_DIAG_STAT_OVERFLOW_BIT 4 +#define ADIS16260_DIAG_STAT_SPI_FAIL_BIT 3 +#define ADIS16260_DIAG_STAT_FLASH_UPT_BIT 2 +#define ADIS16260_DIAG_STAT_POWER_HIGH_BIT 1 +#define ADIS16260_DIAG_STAT_POWER_LOW_BIT 0 + +/* GLOB_CMD */ +#define ADIS16260_GLOB_CMD_SW_RESET (1<<7) +#define ADIS16260_GLOB_CMD_FLASH_UPD (1<<3) +#define ADIS16260_GLOB_CMD_DAC_LATCH (1<<2) +#define ADIS16260_GLOB_CMD_FAC_CALIB (1<<1) +#define ADIS16260_GLOB_CMD_AUTO_NULL (1<<0) + +#define ADIS16260_SPI_SLOW (u32)(300 * 1000) +#define ADIS16260_SPI_BURST (u32)(1000 * 1000) +#define ADIS16260_SPI_FAST (u32)(2000 * 1000) + +/* At the moment triggers are only used for ring buffer + * filling. This may change! + */ -#include "adis16260.h" +#define ADIS16260_SCAN_GYRO 0 +#define ADIS16260_SCAN_SUPPLY 1 +#define ADIS16260_SCAN_AUX_ADC 2 +#define ADIS16260_SCAN_TEMP 3 +#define ADIS16260_SCAN_ANGL 4 static ssize_t adis16260_read_frequency_available(struct device *dev, struct device_attribute *attr, -- GitLab From f4f87d04116ab2f1419f1e85c1c9504536858b88 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 17 Jul 2013 15:44:00 +0100 Subject: [PATCH 531/942] staging:iio:adis16260: Add value range check for calibscale/-bias Instead of just cutting of the upper bits of the value make sure that the value is in the valid range and return an error if it is not. Signed-off-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/staging/iio/gyro/adis16260_core.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/staging/iio/gyro/adis16260_core.c b/drivers/staging/iio/gyro/adis16260_core.c index a01c2438302f1..55e67959b0543 100644 --- a/drivers/staging/iio/gyro/adis16260_core.c +++ b/drivers/staging/iio/gyro/adis16260_core.c @@ -311,18 +311,21 @@ static int adis16260_write_raw(struct iio_dev *indio_dev, long mask) { struct adis *adis = iio_priv(indio_dev); - int bits = 12; - s16 val16; u8 addr; + switch (mask) { case IIO_CHAN_INFO_CALIBBIAS: - val16 = val & ((1 << bits) - 1); + if (val < -2048 || val >= 2048) + return -EINVAL; + addr = adis16260_addresses[chan->scan_index][0]; - return adis_write_reg_16(adis, addr, val16); + return adis_write_reg_16(adis, addr, val); case IIO_CHAN_INFO_CALIBSCALE: - val16 = val & ((1 << bits) - 1); + if (val < 0 || val >= 4096) + return -EINVAL; + addr = adis16260_addresses[chan->scan_index][1]; - return adis_write_reg_16(adis, addr, val16); + return adis_write_reg_16(adis, addr, val); } return -EINVAL; } -- GitLab From b45ae32bd027d7b7a65cc50ce5484446077f2648 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 17 Jul 2013 15:44:00 +0100 Subject: [PATCH 532/942] staging:iio:adis16260: Use sign_extend32() instead of open-coding it Signed-off-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/staging/iio/gyro/adis16260_core.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/iio/gyro/adis16260_core.c b/drivers/staging/iio/gyro/adis16260_core.c index 55e67959b0543..f060452f367e6 100644 --- a/drivers/staging/iio/gyro/adis16260_core.c +++ b/drivers/staging/iio/gyro/adis16260_core.c @@ -277,9 +277,7 @@ static int adis16260_read_raw(struct iio_dev *indio_dev, mutex_unlock(&indio_dev->mlock); return ret; } - val16 &= (1 << bits) - 1; - val16 = (s16)(val16 << (16 - bits)) >> (16 - bits); - *val = val16; + *val = sign_extend32(val16, bits - 1); mutex_unlock(&indio_dev->mlock); return IIO_VAL_INT; case IIO_CHAN_INFO_CALIBSCALE: -- GitLab From 73149badce2dbd9483e1af7010c4fb6425500ec0 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 17 Jul 2013 15:44:00 +0100 Subject: [PATCH 533/942] staging:iio:adis16260: Simplify calibscale and caliboffset reading All channels for this device have the same number of bits for calibscale and caliboffset, there is no need to determine it dynamically based on the channel type. Also there is no locking required since adis_read_reg_16() will take care of proper locking on its own. Signed-off-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/staging/iio/gyro/adis16260_core.c | 31 ++++------------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/drivers/staging/iio/gyro/adis16260_core.c b/drivers/staging/iio/gyro/adis16260_core.c index f060452f367e6..c70094f6afcee 100644 --- a/drivers/staging/iio/gyro/adis16260_core.c +++ b/drivers/staging/iio/gyro/adis16260_core.c @@ -222,7 +222,6 @@ static int adis16260_read_raw(struct iio_dev *indio_dev, { struct adis *adis = iio_priv(indio_dev); int ret; - int bits; u8 addr; s16 val16; @@ -263,40 +262,20 @@ static int adis16260_read_raw(struct iio_dev *indio_dev, *val = 250000 / 1453; /* 25 C = 0x00 */ return IIO_VAL_INT; case IIO_CHAN_INFO_CALIBBIAS: - switch (chan->type) { - case IIO_ANGL_VEL: - bits = 12; - break; - default: - return -EINVAL; - } - mutex_lock(&indio_dev->mlock); addr = adis16260_addresses[chan->scan_index][0]; ret = adis_read_reg_16(adis, addr, &val16); - if (ret) { - mutex_unlock(&indio_dev->mlock); + if (ret) return ret; - } - *val = sign_extend32(val16, bits - 1); - mutex_unlock(&indio_dev->mlock); + + *val = sign_extend32(val16, 11); return IIO_VAL_INT; case IIO_CHAN_INFO_CALIBSCALE: - switch (chan->type) { - case IIO_ANGL_VEL: - bits = 12; - break; - default: - return -EINVAL; - } - mutex_lock(&indio_dev->mlock); addr = adis16260_addresses[chan->scan_index][1]; ret = adis_read_reg_16(adis, addr, &val16); - if (ret) { - mutex_unlock(&indio_dev->mlock); + if (ret) return ret; - } + *val = val16; - mutex_unlock(&indio_dev->mlock); return IIO_VAL_INT; } return -EINVAL; -- GitLab From 8aa55d103c8de1a2fff8af28a4390140869c6c3c Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 17 Jul 2013 15:44:00 +0100 Subject: [PATCH 534/942] staging:iio:adis16260: Fix minor style issue Delete some extra whitespace. Signed-off-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/staging/iio/gyro/adis16260_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/iio/gyro/adis16260_core.c b/drivers/staging/iio/gyro/adis16260_core.c index c70094f6afcee..4b62000cc7b6d 100644 --- a/drivers/staging/iio/gyro/adis16260_core.c +++ b/drivers/staging/iio/gyro/adis16260_core.c @@ -131,9 +131,9 @@ static ssize_t adis16260_read_frequency(struct device *dev, return ret; if (spi_get_device_id(adis->spi)->driver_data) /* If an adis16251 */ - sps = (t & ADIS16260_SMPL_PRD_TIME_BASE) ? 8 : 256; + sps = (t & ADIS16260_SMPL_PRD_TIME_BASE) ? 8 : 256; else - sps = (t & ADIS16260_SMPL_PRD_TIME_BASE) ? 66 : 2048; + sps = (t & ADIS16260_SMPL_PRD_TIME_BASE) ? 66 : 2048; sps /= (t & ADIS16260_SMPL_PRD_DIV_MASK) + 1; len = sprintf(buf, "%d SPS\n", sps); return len; -- GitLab From 9aa5aad8724fc7dd9d57a71d8894415850ed349f Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 17 Jul 2013 15:44:00 +0100 Subject: [PATCH 535/942] staging:iio:adis16260: Remove 'SPS' suffix from samplerate attribute This is not part of the ABI. Signed-off-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/staging/iio/gyro/adis16260_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/gyro/adis16260_core.c b/drivers/staging/iio/gyro/adis16260_core.c index 4b62000cc7b6d..a140d73f688a5 100644 --- a/drivers/staging/iio/gyro/adis16260_core.c +++ b/drivers/staging/iio/gyro/adis16260_core.c @@ -135,7 +135,7 @@ static ssize_t adis16260_read_frequency(struct device *dev, else sps = (t & ADIS16260_SMPL_PRD_TIME_BASE) ? 66 : 2048; sps /= (t & ADIS16260_SMPL_PRD_DIV_MASK) + 1; - len = sprintf(buf, "%d SPS\n", sps); + len = sprintf(buf, "%d\n", sps); return len; } -- GitLab From ebdee941e24719b841dd5bd5df4620bdf1bcbe44 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 17 Jul 2013 15:44:00 +0100 Subject: [PATCH 536/942] staging:iio:adis16260: Add scale for the inclination channel While the inclination channel claims to support reading the scale the driver did not implement this, so trying to read the scale results in a -EINVAL. This patch fixes it. Signed-off-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/staging/iio/gyro/adis16260_core.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/staging/iio/gyro/adis16260_core.c b/drivers/staging/iio/gyro/adis16260_core.c index a140d73f688a5..48b0e63939b17 100644 --- a/drivers/staging/iio/gyro/adis16260_core.c +++ b/drivers/staging/iio/gyro/adis16260_core.c @@ -241,6 +241,10 @@ static int adis16260_read_raw(struct iio_dev *indio_dev, *val2 = IIO_DEGREE_TO_RAD(73260); } return IIO_VAL_INT_PLUS_MICRO; + case IIO_INCLI: + *val = 0; + *val2 = IIO_DEGREE_TO_RAD(36630); + return IIO_VAL_INT_PLUS_MICRO; case IIO_VOLTAGE: if (chan->channel == 0) { *val = 1; -- GitLab From 2a34013509065792f069c586c528480ad6196923 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 17 Jul 2013 15:44:00 +0100 Subject: [PATCH 537/942] staging:iio:adis16260: Remove unused includes Remove some unused includes from the driver. Signed-off-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/staging/iio/gyro/adis16260_core.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/iio/gyro/adis16260_core.c b/drivers/staging/iio/gyro/adis16260_core.c index 48b0e63939b17..b8a6a0457477f 100644 --- a/drivers/staging/iio/gyro/adis16260_core.c +++ b/drivers/staging/iio/gyro/adis16260_core.c @@ -7,15 +7,11 @@ */ #include -#include -#include #include #include #include #include -#include #include -#include #include #include -- GitLab From e4ddf314e22a512a494813636b2284d570fd7438 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 17 Jul 2013 15:44:00 +0100 Subject: [PATCH 538/942] staging:iio:adis16260: Add proper range checks to write_frequency() A negative sampling frequency is obviously invalid, so use kstrtouint() instead of strict_strtoul. Also when setting a sampling frequency smaller than the minimum supported frequency set the frequency to the minimum supported frequency instead of just cutting off the upper bits of the raw register value. Signed-off-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/staging/iio/gyro/adis16260_core.c | 29 ++++++++++------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/drivers/staging/iio/gyro/adis16260_core.c b/drivers/staging/iio/gyro/adis16260_core.c index b8a6a0457477f..d4e3dd7f94d99 100644 --- a/drivers/staging/iio/gyro/adis16260_core.c +++ b/drivers/staging/iio/gyro/adis16260_core.c @@ -142,29 +142,26 @@ static ssize_t adis16260_write_frequency(struct device *dev, { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct adis *adis = iio_priv(indio_dev); - long val; + unsigned int val; int ret; u8 t; - ret = strict_strtol(buf, 10, &val); + ret = kstrtouint(buf, 10, &val); if (ret) return ret; - if (val == 0) - return -EINVAL; mutex_lock(&indio_dev->mlock); - if (spi_get_device_id(adis->spi)->driver_data) { - t = (256 / val); - if (t > 0) - t--; - t &= ADIS16260_SMPL_PRD_DIV_MASK; - } else { - t = (2048 / val); - if (t > 0) - t--; - t &= ADIS16260_SMPL_PRD_DIV_MASK; - } - if ((t & ADIS16260_SMPL_PRD_DIV_MASK) >= 0x0A) + if (spi_get_device_id(adis->spi)->driver_data) + t = 256 / val; + else + t = 2048 / val; + + if (t > ADIS16260_SMPL_PRD_DIV_MASK) + t = ADIS16260_SMPL_PRD_DIV_MASK; + else if (t > 0) + t--; + + if (t >= 0x0A) adis->spi->max_speed_hz = ADIS16260_SPI_SLOW; else adis->spi->max_speed_hz = ADIS16260_SPI_FAST; -- GitLab From 446e0ee16d1b899224ec66d09f203ae0e522aa34 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 17 Jul 2013 15:44:00 +0100 Subject: [PATCH 539/942] staging:iio:adis16260: Remove sampling_frequency_available attribute The values presented here are completely bogus. Also ..._available attributes are supposed to be used for properties that only support discrete sets of values, but we accept continuous values and will round to the next supported frequency. Signed-off-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/staging/iio/gyro/adis16260_core.c | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/drivers/staging/iio/gyro/adis16260_core.c b/drivers/staging/iio/gyro/adis16260_core.c index d4e3dd7f94d99..b4cf800717ada 100644 --- a/drivers/staging/iio/gyro/adis16260_core.c +++ b/drivers/staging/iio/gyro/adis16260_core.c @@ -101,18 +101,6 @@ #define ADIS16260_SCAN_TEMP 3 #define ADIS16260_SCAN_ANGL 4 -static ssize_t adis16260_read_frequency_available(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct iio_dev *indio_dev = dev_to_iio_dev(dev); - struct adis *adis = iio_priv(indio_dev); - if (spi_get_device_id(adis->spi)->driver_data) - return sprintf(buf, "%s\n", "0.129 ~ 256"); - else - return sprintf(buf, "%s\n", "256 2048"); -} - static ssize_t adis16260_read_frequency(struct device *dev, struct device_attribute *attr, char *buf) @@ -190,9 +178,6 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO, adis16260_read_frequency, adis16260_write_frequency); -static IIO_DEVICE_ATTR(sampling_frequency_available, - S_IRUGO, adis16260_read_frequency_available, NULL, 0); - static const struct iio_chan_spec adis16260_channels[] = { ADIS_GYRO_CHAN(X, ADIS16260_GYRO_OUT, ADIS16260_SCAN_GYRO, BIT(IIO_CHAN_INFO_CALIBBIAS) | @@ -306,7 +291,6 @@ static int adis16260_write_raw(struct iio_dev *indio_dev, static struct attribute *adis16260_attributes[] = { &iio_dev_attr_sampling_frequency.dev_attr.attr, - &iio_dev_attr_sampling_frequency_available.dev_attr.attr, NULL }; -- GitLab From 555d5a9f17ef71849cae57fd2efda60b50d325ce Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Wed, 17 Jul 2013 15:44:00 +0100 Subject: [PATCH 540/942] staging:iio:adis16260: Move out of staging The drivers is in more or less good shape, conforms to the IIO ABI and none of the default static code checker report any problems, so move it out of staging. Signed-off-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/iio/gyro/Kconfig | 12 ++++++++++++ drivers/iio/gyro/Makefile | 1 + .../gyro/adis16260_core.c => iio/gyro/adis16260.c} | 0 drivers/staging/iio/gyro/Kconfig | 12 ------------ drivers/staging/iio/gyro/Makefile | 3 --- 5 files changed, 13 insertions(+), 15 deletions(-) rename drivers/{staging/iio/gyro/adis16260_core.c => iio/gyro/adis16260.c} (100%) diff --git a/drivers/iio/gyro/Kconfig b/drivers/iio/gyro/Kconfig index 5913735bca9a3..41c64a43bcab1 100644 --- a/drivers/iio/gyro/Kconfig +++ b/drivers/iio/gyro/Kconfig @@ -28,6 +28,18 @@ config ADIS16136 Say yes here to build support for the Analog Devices ADIS16133, ADIS16135, ADIS16136 gyroscope devices. +config ADIS16260 + tristate "Analog Devices ADIS16260 Digital Gyroscope Sensor SPI driver" + depends on SPI + select IIO_ADIS_LIB + select IIO_ADIS_LIB_BUFFER if IIO_BUFFER + help + Say yes here to build support for Analog Devices ADIS16260 ADIS16265 + ADIS16250 ADIS16255 and ADIS16251 programmable digital gyroscope sensors. + + This driver can also be built as a module. If so, the module + will be called adis16260. + config ADXRS450 tristate "Analog Devices ADXRS450/3 Digital Output Gyroscope SPI driver" depends on SPI diff --git a/drivers/iio/gyro/Makefile b/drivers/iio/gyro/Makefile index 36091d5a0f45e..2f2752a4ea83e 100644 --- a/drivers/iio/gyro/Makefile +++ b/drivers/iio/gyro/Makefile @@ -6,6 +6,7 @@ obj-$(CONFIG_ADIS16080) += adis16080.o obj-$(CONFIG_ADIS16130) += adis16130.o obj-$(CONFIG_ADIS16136) += adis16136.o +obj-$(CONFIG_ADIS16260) += adis16260.o obj-$(CONFIG_ADXRS450) += adxrs450.o obj-$(CONFIG_HID_SENSOR_GYRO_3D) += hid-sensor-gyro-3d.o diff --git a/drivers/staging/iio/gyro/adis16260_core.c b/drivers/iio/gyro/adis16260.c similarity index 100% rename from drivers/staging/iio/gyro/adis16260_core.c rename to drivers/iio/gyro/adis16260.c diff --git a/drivers/staging/iio/gyro/Kconfig b/drivers/staging/iio/gyro/Kconfig index b4333715536e2..88b199bb29269 100644 --- a/drivers/staging/iio/gyro/Kconfig +++ b/drivers/staging/iio/gyro/Kconfig @@ -10,16 +10,4 @@ config ADIS16060 Say yes here to build support for Analog Devices adis16060 wide bandwidth yaw rate gyroscope with SPI. -config ADIS16260 - tristate "Analog Devices ADIS16260 Digital Gyroscope Sensor SPI driver" - depends on SPI - select IIO_ADIS_LIB - select IIO_ADIS_LIB_BUFFER if IIO_BUFFER - help - Say yes here to build support for Analog Devices ADIS16260 ADIS16265 - ADIS16250 ADIS16255 and ADIS16251 programmable digital gyroscope sensors. - - This driver can also be built as a module. If so, the module - will be called adis16260. - endmenu diff --git a/drivers/staging/iio/gyro/Makefile b/drivers/staging/iio/gyro/Makefile index 975f95b141da3..cf22d6d55e27f 100644 --- a/drivers/staging/iio/gyro/Makefile +++ b/drivers/staging/iio/gyro/Makefile @@ -4,6 +4,3 @@ adis16060-y := adis16060_core.o obj-$(CONFIG_ADIS16060) += adis16060.o - -adis16260-y := adis16260_core.o -obj-$(CONFIG_ADIS16260) += adis16260.o -- GitLab From 907c0a0ae0e0f3b26d1d2bb6f05f116f0a9decc1 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Fri, 2 Aug 2013 11:08:00 +0100 Subject: [PATCH 541/942] iio: magnetometer: hid-sensor-magn-3d: Use devm_iio_device_alloc Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat Cc: Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/hid-sensor-magn-3d.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/drivers/iio/magnetometer/hid-sensor-magn-3d.c b/drivers/iio/magnetometer/hid-sensor-magn-3d.c index e71127aeda09d..5a6162d1a2c05 100644 --- a/drivers/iio/magnetometer/hid-sensor-magn-3d.c +++ b/drivers/iio/magnetometer/hid-sensor-magn-3d.c @@ -283,11 +283,11 @@ static int hid_magn_3d_probe(struct platform_device *pdev) struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data; struct iio_chan_spec *channels; - indio_dev = iio_device_alloc(sizeof(struct magn_3d_state)); - if (indio_dev == NULL) { - ret = -ENOMEM; - goto error_ret; - } + indio_dev = devm_iio_device_alloc(&pdev->dev, + sizeof(struct magn_3d_state)); + if (indio_dev == NULL) + return -ENOMEM; + platform_set_drvdata(pdev, indio_dev); magn_state = iio_priv(indio_dev); @@ -299,15 +299,14 @@ static int hid_magn_3d_probe(struct platform_device *pdev) &magn_state->common_attributes); if (ret) { dev_err(&pdev->dev, "failed to setup common attributes\n"); - goto error_free_dev; + return ret; } channels = kmemdup(magn_3d_channels, sizeof(magn_3d_channels), GFP_KERNEL); if (!channels) { - ret = -ENOMEM; dev_err(&pdev->dev, "failed to duplicate channels\n"); - goto error_free_dev; + return -ENOMEM; } ret = magn_3d_parse_report(pdev, hsdev, channels, @@ -364,9 +363,6 @@ static int hid_magn_3d_probe(struct platform_device *pdev) iio_triggered_buffer_cleanup(indio_dev); error_free_dev_mem: kfree(indio_dev->channels); -error_free_dev: - iio_device_free(indio_dev); -error_ret: return ret; } @@ -381,7 +377,6 @@ static int hid_magn_3d_remove(struct platform_device *pdev) hid_sensor_remove_trigger(indio_dev); iio_triggered_buffer_cleanup(indio_dev); kfree(indio_dev->channels); - iio_device_free(indio_dev); return 0; } -- GitLab From 7fc5ad7e97a690ccd05ad2556c1bfb687692f215 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Fri, 2 Aug 2013 11:08:00 +0100 Subject: [PATCH 542/942] iio: magnetometer: st_magn: Use devm_iio_device_alloc Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat Cc: Denis Ciocca Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/st_magn_core.c | 1 - drivers/iio/magnetometer/st_magn_i2c.c | 15 ++++----------- drivers/iio/magnetometer/st_magn_spi.c | 15 ++++----------- 3 files changed, 8 insertions(+), 23 deletions(-) diff --git a/drivers/iio/magnetometer/st_magn_core.c b/drivers/iio/magnetometer/st_magn_core.c index 7cd784f522e55..e8d2849cc81d9 100644 --- a/drivers/iio/magnetometer/st_magn_core.c +++ b/drivers/iio/magnetometer/st_magn_core.c @@ -407,7 +407,6 @@ void st_magn_common_remove(struct iio_dev *indio_dev) st_sensors_deallocate_trigger(indio_dev); st_magn_deallocate_ring(indio_dev); } - iio_device_free(indio_dev); } EXPORT_SYMBOL(st_magn_common_remove); diff --git a/drivers/iio/magnetometer/st_magn_i2c.c b/drivers/iio/magnetometer/st_magn_i2c.c index 1bed117714c58..892e0feeb5c1d 100644 --- a/drivers/iio/magnetometer/st_magn_i2c.c +++ b/drivers/iio/magnetometer/st_magn_i2c.c @@ -25,11 +25,9 @@ static int st_magn_i2c_probe(struct i2c_client *client, struct st_sensor_data *mdata; int err; - indio_dev = iio_device_alloc(sizeof(*mdata)); - if (indio_dev == NULL) { - err = -ENOMEM; - goto iio_device_alloc_error; - } + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*mdata)); + if (!indio_dev) + return -ENOMEM; mdata = iio_priv(indio_dev); mdata->dev = &client->dev; @@ -38,14 +36,9 @@ static int st_magn_i2c_probe(struct i2c_client *client, err = st_magn_common_probe(indio_dev, NULL); if (err < 0) - goto st_magn_common_probe_error; + return err; return 0; - -st_magn_common_probe_error: - iio_device_free(indio_dev); -iio_device_alloc_error: - return err; } static int st_magn_i2c_remove(struct i2c_client *client) diff --git a/drivers/iio/magnetometer/st_magn_spi.c b/drivers/iio/magnetometer/st_magn_spi.c index a2333a1e6061d..a6143ea51dfcb 100644 --- a/drivers/iio/magnetometer/st_magn_spi.c +++ b/drivers/iio/magnetometer/st_magn_spi.c @@ -24,11 +24,9 @@ static int st_magn_spi_probe(struct spi_device *spi) struct st_sensor_data *mdata; int err; - indio_dev = iio_device_alloc(sizeof(*mdata)); - if (indio_dev == NULL) { - err = -ENOMEM; - goto iio_device_alloc_error; - } + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*mdata)); + if (!indio_dev) + return -ENOMEM; mdata = iio_priv(indio_dev); mdata->dev = &spi->dev; @@ -37,14 +35,9 @@ static int st_magn_spi_probe(struct spi_device *spi) err = st_magn_common_probe(indio_dev, NULL); if (err < 0) - goto st_magn_common_probe_error; + return err; return 0; - -st_magn_common_probe_error: - iio_device_free(indio_dev); -iio_device_alloc_error: - return err; } static int st_magn_spi_remove(struct spi_device *spi) -- GitLab From 5b778b97d494653deb2f2320393900ee51c80894 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 30 Jul 2013 09:44:00 +0100 Subject: [PATCH 543/942] iio: imu: adis16400: Use devm_iio_device_alloc Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat Cc: Manuel Stahl Signed-off-by: Jonathan Cameron --- drivers/iio/imu/adis16400_core.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/iio/imu/adis16400_core.c b/drivers/iio/imu/adis16400_core.c index f60591f0b9257..3fb7757a10287 100644 --- a/drivers/iio/imu/adis16400_core.c +++ b/drivers/iio/imu/adis16400_core.c @@ -871,7 +871,7 @@ static int adis16400_probe(struct spi_device *spi) struct iio_dev *indio_dev; int ret; - indio_dev = iio_device_alloc(sizeof(*st)); + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); if (indio_dev == NULL) return -ENOMEM; @@ -893,12 +893,12 @@ static int adis16400_probe(struct spi_device *spi) ret = adis_init(&st->adis, indio_dev, spi, &adis16400_data); if (ret) - goto error_free_dev; + return ret; ret = adis_setup_buffer_and_trigger(&st->adis, indio_dev, adis16400_trigger_handler); if (ret) - goto error_free_dev; + return ret; /* Get the device into a sane initial state */ ret = adis16400_initial_setup(indio_dev); @@ -913,8 +913,6 @@ static int adis16400_probe(struct spi_device *spi) error_cleanup_buffer: adis_cleanup_buffer_and_trigger(&st->adis, indio_dev); -error_free_dev: - iio_device_free(indio_dev); return ret; } @@ -928,8 +926,6 @@ static int adis16400_remove(struct spi_device *spi) adis_cleanup_buffer_and_trigger(&st->adis, indio_dev); - iio_device_free(indio_dev); - return 0; } -- GitLab From 297c8876d9669dfa6d6a4c17bd4527495036f64f Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 30 Jul 2013 09:44:00 +0100 Subject: [PATCH 544/942] iio: imu: adis16480: Use devm_iio_device_alloc Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat Cc: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/iio/imu/adis16480.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/iio/imu/adis16480.c b/drivers/iio/imu/adis16480.c index b7db383762954..dd4206cac62d8 100644 --- a/drivers/iio/imu/adis16480.c +++ b/drivers/iio/imu/adis16480.c @@ -839,7 +839,7 @@ static int adis16480_probe(struct spi_device *spi) struct adis16480 *st; int ret; - indio_dev = iio_device_alloc(sizeof(*st)); + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); if (indio_dev == NULL) return -ENOMEM; @@ -857,11 +857,11 @@ static int adis16480_probe(struct spi_device *spi) ret = adis_init(&st->adis, indio_dev, spi, &adis16480_data); if (ret) - goto error_free_dev; + return ret; ret = adis_setup_buffer_and_trigger(&st->adis, indio_dev, NULL); if (ret) - goto error_free_dev; + return ret; ret = adis16480_initial_setup(indio_dev); if (ret) @@ -879,8 +879,6 @@ static int adis16480_probe(struct spi_device *spi) adis16480_stop_device(indio_dev); error_cleanup_buffer: adis_cleanup_buffer_and_trigger(&st->adis, indio_dev); -error_free_dev: - iio_device_free(indio_dev); return ret; } @@ -894,8 +892,6 @@ static int adis16480_remove(struct spi_device *spi) adis_cleanup_buffer_and_trigger(&st->adis, indio_dev); - iio_device_free(indio_dev); - return 0; } -- GitLab From 452204ae531f236696d69966d0ff2f5ca0ef02f7 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 30 Jul 2013 09:44:00 +0100 Subject: [PATCH 545/942] iio: imu: inv_mpu6050: Use devm_iio_device_alloc Using devm_iio_device_alloc makes code simpler. While at it include missing iio.h header file and do some cleanup. Signed-off-by: Sachin Kamat Signed-off-by: Jonathan Cameron --- drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 27 ++++++++-------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c index 6a1ff803862ca..df7f1e1157ae9 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "inv_mpu_iio.h" /* @@ -663,16 +664,13 @@ static int inv_mpu_probe(struct i2c_client *client, int result; if (!i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_I2C_BLOCK)) { + I2C_FUNC_SMBUS_I2C_BLOCK)) + return -ENOSYS; + + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*st)); + if (!indio_dev) + return -ENOMEM; - result = -ENOSYS; - goto out_no_free; - } - indio_dev = iio_device_alloc(sizeof(*st)); - if (indio_dev == NULL) { - result = -ENOMEM; - goto out_no_free; - } st = iio_priv(indio_dev); st->client = client; st->plat_data = *(struct inv_mpu6050_platform_data @@ -680,13 +678,13 @@ static int inv_mpu_probe(struct i2c_client *client, /* power is turned on inside check chip type*/ result = inv_check_and_setup_chip(st, id); if (result) - goto out_free; + return result; result = inv_mpu6050_init_config(indio_dev); if (result) { dev_err(&client->dev, "Could not initialize device.\n"); - goto out_free; + return result; } i2c_set_clientdata(client, indio_dev); @@ -705,7 +703,7 @@ static int inv_mpu_probe(struct i2c_client *client, if (result) { dev_err(&st->client->dev, "configure buffer fail %d\n", result); - goto out_free; + return result; } result = inv_mpu6050_probe_trigger(indio_dev); if (result) { @@ -727,10 +725,6 @@ static int inv_mpu_probe(struct i2c_client *client, inv_mpu6050_remove_trigger(st); out_unreg_ring: iio_triggered_buffer_cleanup(indio_dev); -out_free: - iio_device_free(indio_dev); -out_no_free: - return result; } @@ -742,7 +736,6 @@ static int inv_mpu_remove(struct i2c_client *client) iio_device_unregister(indio_dev); inv_mpu6050_remove_trigger(st); iio_triggered_buffer_cleanup(indio_dev); - iio_device_free(indio_dev); return 0; } -- GitLab From 47aff92ce081d8c9013f52e021cdfee5eebdbd2b Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 30 Jul 2013 09:44:00 +0100 Subject: [PATCH 546/942] iio: light: hid-sensor-als: Use devm_iio_device_alloc Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat Cc: Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- drivers/iio/light/hid-sensor-als.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c index 9adfef07d8c25..84cf0043c99da 100644 --- a/drivers/iio/light/hid-sensor-als.c +++ b/drivers/iio/light/hid-sensor-als.c @@ -249,11 +249,9 @@ static int hid_als_probe(struct platform_device *pdev) struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data; struct iio_chan_spec *channels; - indio_dev = iio_device_alloc(sizeof(struct als_state)); - if (indio_dev == NULL) { - ret = -ENOMEM; - goto error_ret; - } + indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(struct als_state)); + if (!indio_dev) + return -ENOMEM; platform_set_drvdata(pdev, indio_dev); als_state = iio_priv(indio_dev); @@ -264,14 +262,13 @@ static int hid_als_probe(struct platform_device *pdev) &als_state->common_attributes); if (ret) { dev_err(&pdev->dev, "failed to setup common attributes\n"); - goto error_free_dev; + return ret; } channels = kmemdup(als_channels, sizeof(als_channels), GFP_KERNEL); if (!channels) { - ret = -ENOMEM; dev_err(&pdev->dev, "failed to duplicate channels\n"); - goto error_free_dev; + return -ENOMEM; } ret = als_parse_report(pdev, hsdev, channels, @@ -329,9 +326,6 @@ static int hid_als_probe(struct platform_device *pdev) iio_triggered_buffer_cleanup(indio_dev); error_free_dev_mem: kfree(indio_dev->channels); -error_free_dev: - iio_device_free(indio_dev); -error_ret: return ret; } @@ -346,7 +340,6 @@ static int hid_als_remove(struct platform_device *pdev) hid_sensor_remove_trigger(indio_dev); iio_triggered_buffer_cleanup(indio_dev); kfree(indio_dev->channels); - iio_device_free(indio_dev); return 0; } -- GitLab From 3d0ccbaff396920eedeb6a8d0dbb3c95847e937e Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 30 Jul 2013 09:44:00 +0100 Subject: [PATCH 547/942] iio: light: lm3533-als: Use devm_iio_device_alloc Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat Cc: Johan Hovold Signed-off-by: Jonathan Cameron --- drivers/iio/light/lm3533-als.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/iio/light/lm3533-als.c b/drivers/iio/light/lm3533-als.c index 5fa31a4ef82a7..c1aadc6b865a7 100644 --- a/drivers/iio/light/lm3533-als.c +++ b/drivers/iio/light/lm3533-als.c @@ -847,7 +847,7 @@ static int lm3533_als_probe(struct platform_device *pdev) return -EINVAL; } - indio_dev = iio_device_alloc(sizeof(*als)); + indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*als)); if (!indio_dev) return -ENOMEM; @@ -870,7 +870,7 @@ static int lm3533_als_probe(struct platform_device *pdev) if (als->irq) { ret = lm3533_als_setup_irq(als, indio_dev); if (ret) - goto err_free_dev; + return ret; } ret = lm3533_als_setup(als, pdata); @@ -894,8 +894,6 @@ static int lm3533_als_probe(struct platform_device *pdev) err_free_irq: if (als->irq) free_irq(als->irq, indio_dev); -err_free_dev: - iio_device_free(indio_dev); return ret; } @@ -910,7 +908,6 @@ static int lm3533_als_remove(struct platform_device *pdev) lm3533_als_disable(als); if (als->irq) free_irq(als->irq, indio_dev); - iio_device_free(indio_dev); return 0; } -- GitLab From bace48f44adb954ad71e62779d1be52dae3f0caf Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 30 Jul 2013 09:44:00 +0100 Subject: [PATCH 548/942] iio: light: tsl2563: Use devm_* APIs devm_* APIs are device managed and make code simpler. Signed-off-by: Sachin Kamat Reviewed-by: Amit Kucheria Signed-off-by: Jonathan Cameron --- drivers/iio/light/tsl2563.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/drivers/iio/light/tsl2563.c b/drivers/iio/light/tsl2563.c index 1f529f36f138b..ebb962c5c323a 100644 --- a/drivers/iio/light/tsl2563.c +++ b/drivers/iio/light/tsl2563.c @@ -702,7 +702,7 @@ static int tsl2563_probe(struct i2c_client *client, int err = 0; u8 id = 0; - indio_dev = iio_device_alloc(sizeof(*chip)); + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip)); if (!indio_dev) return -ENOMEM; @@ -714,13 +714,13 @@ static int tsl2563_probe(struct i2c_client *client, err = tsl2563_detect(chip); if (err) { dev_err(&client->dev, "detect error %d\n", -err); - goto fail1; + return err; } err = tsl2563_read_id(chip, &id); if (err) { dev_err(&client->dev, "read id error %d\n", -err); - goto fail1; + return err; } mutex_init(&chip->lock); @@ -751,7 +751,7 @@ static int tsl2563_probe(struct i2c_client *client, indio_dev->info = &tsl2563_info_no_irq; if (client->irq) { - err = request_threaded_irq(client->irq, + err = devm_request_threaded_irq(&client->dev, client->irq, NULL, &tsl2563_event_handler, IRQF_TRIGGER_RISING | IRQF_ONESHOT, @@ -759,14 +759,14 @@ static int tsl2563_probe(struct i2c_client *client, indio_dev); if (err) { dev_err(&client->dev, "irq request error %d\n", -err); - goto fail1; + return err; } } err = tsl2563_configure(chip); if (err) { dev_err(&client->dev, "configure error %d\n", -err); - goto fail2; + return err; } INIT_DELAYED_WORK(&chip->poweroff_work, tsl2563_poweroff_work); @@ -777,19 +777,14 @@ static int tsl2563_probe(struct i2c_client *client, err = iio_device_register(indio_dev); if (err) { dev_err(&client->dev, "iio registration error %d\n", -err); - goto fail3; + goto fail; } return 0; -fail3: +fail: cancel_delayed_work(&chip->poweroff_work); flush_scheduled_work(); -fail2: - if (client->irq) - free_irq(client->irq, indio_dev); -fail1: - iio_device_free(indio_dev); return err; } @@ -807,10 +802,6 @@ static int tsl2563_remove(struct i2c_client *client) chip->intr); flush_scheduled_work(); tsl2563_set_power(chip, 0); - if (client->irq) - free_irq(client->irq, indio_dev); - - iio_device_free(indio_dev); return 0; } -- GitLab From 1003eb67baf00cca8aa51f5833090c61938aa82e Mon Sep 17 00:00:00 2001 From: Jacek Anaszewski Date: Tue, 2 Jul 2013 11:13:00 +0100 Subject: [PATCH 549/942] iio: lps331ap: Modify in_temp_scale calculation way This patch modifies the way how the in_temp_scale output value is calculated. With this implementation it is more clear how the value is obtained. Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park Signed-off-by: Jonathan Cameron --- drivers/iio/pressure/st_pressure_core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c index 81e2d5b030a60..43b3a55e1130a 100644 --- a/drivers/iio/pressure/st_pressure_core.c +++ b/drivers/iio/pressure/st_pressure_core.c @@ -31,6 +31,9 @@ #define ST_PRESS_LSB_PER_MBAR 4096UL #define ST_PRESS_KPASCAL_NANO_SCALE (100000000UL / \ ST_PRESS_LSB_PER_MBAR) +#define ST_PRESS_LSB_PER_CELSIUS 480UL +#define ST_PRESS_CELSIUS_NANO_SCALE (1000000000UL / \ + ST_PRESS_LSB_PER_CELSIUS) #define ST_PRESS_NUMBER_DATA_CHANNELS 1 /* DEFAULT VALUE FOR SENSORS */ @@ -53,8 +56,8 @@ #define ST_PRESS_1_FS_ADDR 0x23 #define ST_PRESS_1_FS_MASK 0x30 #define ST_PRESS_1_FS_AVL_1260_VAL 0x00 -#define ST_PRESS_1_FS_AVL_TEMP_GAIN 2083000 #define ST_PRESS_1_FS_AVL_1260_GAIN ST_PRESS_KPASCAL_NANO_SCALE +#define ST_PRESS_1_FS_AVL_TEMP_GAIN ST_PRESS_CELSIUS_NANO_SCALE #define ST_PRESS_1_BDU_ADDR 0x20 #define ST_PRESS_1_BDU_MASK 0x04 #define ST_PRESS_1_DRDY_IRQ_ADDR 0x22 -- GitLab From 36db8c72169489eedca06fe308b1643256d8c4fe Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 30 Jul 2013 07:24:00 +0100 Subject: [PATCH 550/942] iio: amplifiers: ad8366: Use devm_* APIs devm_* APIs are device managed and make code simpler. Signed-off-by: Sachin Kamat Cc: Michael Hennerich Signed-off-by: Jonathan Cameron --- drivers/iio/amplifiers/ad8366.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad8366.c index d354554b51b3e..d0a79a4bce1c8 100644 --- a/drivers/iio/amplifiers/ad8366.c +++ b/drivers/iio/amplifiers/ad8366.c @@ -139,17 +139,17 @@ static int ad8366_probe(struct spi_device *spi) struct ad8366_state *st; int ret; - indio_dev = iio_device_alloc(sizeof(*st)); + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); if (indio_dev == NULL) return -ENOMEM; st = iio_priv(indio_dev); - st->reg = regulator_get(&spi->dev, "vcc"); + st->reg = devm_regulator_get(&spi->dev, "vcc"); if (!IS_ERR(st->reg)) { ret = regulator_enable(st->reg); if (ret) - goto error_put_reg; + return ret; } spi_set_drvdata(spi, indio_dev); @@ -173,11 +173,6 @@ static int ad8366_probe(struct spi_device *spi) error_disable_reg: if (!IS_ERR(st->reg)) regulator_disable(st->reg); -error_put_reg: - if (!IS_ERR(st->reg)) - regulator_put(st->reg); - - iio_device_free(indio_dev); return ret; } @@ -195,8 +190,6 @@ static int ad8366_remove(struct spi_device *spi) regulator_put(reg); } - iio_device_free(indio_dev); - return 0; } -- GitLab From b46400c639de7b0b3abce226b7ba0cbb253a4806 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 30 Jul 2013 07:24:00 +0100 Subject: [PATCH 551/942] iio: frequency: ad9523: Use devm_* APIs devm_* APIs are device managed and make code simpler. Signed-off-by: Sachin Kamat Cc: Michael Hennerich Signed-off-by: Jonathan Cameron --- drivers/iio/frequency/ad9523.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/drivers/iio/frequency/ad9523.c b/drivers/iio/frequency/ad9523.c index 92276deeb026d..7c5245d9f99cc 100644 --- a/drivers/iio/frequency/ad9523.c +++ b/drivers/iio/frequency/ad9523.c @@ -961,17 +961,17 @@ static int ad9523_probe(struct spi_device *spi) return -EINVAL; } - indio_dev = iio_device_alloc(sizeof(*st)); + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); if (indio_dev == NULL) return -ENOMEM; st = iio_priv(indio_dev); - st->reg = regulator_get(&spi->dev, "vcc"); + st->reg = devm_regulator_get(&spi->dev, "vcc"); if (!IS_ERR(st->reg)) { ret = regulator_enable(st->reg); if (ret) - goto error_put_reg; + return ret; } spi_set_drvdata(spi, indio_dev); @@ -1001,11 +1001,6 @@ static int ad9523_probe(struct spi_device *spi) error_disable_reg: if (!IS_ERR(st->reg)) regulator_disable(st->reg); -error_put_reg: - if (!IS_ERR(st->reg)) - regulator_put(st->reg); - - iio_device_free(indio_dev); return ret; } @@ -1017,12 +1012,8 @@ static int ad9523_remove(struct spi_device *spi) iio_device_unregister(indio_dev); - if (!IS_ERR(st->reg)) { + if (!IS_ERR(st->reg)) regulator_disable(st->reg); - regulator_put(st->reg); - } - - iio_device_free(indio_dev); return 0; } -- GitLab From d0fe8c8b3b683979f31dfe2ebba6bb1eade21ccd Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 30 Jul 2013 07:24:00 +0100 Subject: [PATCH 552/942] iio: pressure: st_pressure: Use devm_iio_device_alloc Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat Cc: Denis Ciocca Signed-off-by: Jonathan Cameron --- drivers/iio/pressure/st_pressure_core.c | 1 - drivers/iio/pressure/st_pressure_i2c.c | 15 ++++----------- drivers/iio/pressure/st_pressure_spi.c | 15 ++++----------- 3 files changed, 8 insertions(+), 23 deletions(-) diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c index 43b3a55e1130a..ceebd3c27892b 100644 --- a/drivers/iio/pressure/st_pressure_core.c +++ b/drivers/iio/pressure/st_pressure_core.c @@ -275,7 +275,6 @@ void st_press_common_remove(struct iio_dev *indio_dev) st_sensors_deallocate_trigger(indio_dev); st_press_deallocate_ring(indio_dev); } - iio_device_free(indio_dev); } EXPORT_SYMBOL(st_press_common_remove); diff --git a/drivers/iio/pressure/st_pressure_i2c.c b/drivers/iio/pressure/st_pressure_i2c.c index 306599307a962..08aac5e6251dd 100644 --- a/drivers/iio/pressure/st_pressure_i2c.c +++ b/drivers/iio/pressure/st_pressure_i2c.c @@ -25,11 +25,9 @@ static int st_press_i2c_probe(struct i2c_client *client, struct st_sensor_data *pdata; int err; - indio_dev = iio_device_alloc(sizeof(*pdata)); - if (indio_dev == NULL) { - err = -ENOMEM; - goto iio_device_alloc_error; - } + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*pdata)); + if (!indio_dev) + return -ENOMEM; pdata = iio_priv(indio_dev); pdata->dev = &client->dev; @@ -38,14 +36,9 @@ static int st_press_i2c_probe(struct i2c_client *client, err = st_press_common_probe(indio_dev, client->dev.platform_data); if (err < 0) - goto st_press_common_probe_error; + return err; return 0; - -st_press_common_probe_error: - iio_device_free(indio_dev); -iio_device_alloc_error: - return err; } static int st_press_i2c_remove(struct i2c_client *client) diff --git a/drivers/iio/pressure/st_pressure_spi.c b/drivers/iio/pressure/st_pressure_spi.c index b2aded6d2108d..399a29b6017b2 100644 --- a/drivers/iio/pressure/st_pressure_spi.c +++ b/drivers/iio/pressure/st_pressure_spi.c @@ -24,11 +24,9 @@ static int st_press_spi_probe(struct spi_device *spi) struct st_sensor_data *pdata; int err; - indio_dev = iio_device_alloc(sizeof(*pdata)); - if (indio_dev == NULL) { - err = -ENOMEM; - goto iio_device_alloc_error; - } + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*pdata)); + if (indio_dev == NULL) + return -ENOMEM; pdata = iio_priv(indio_dev); pdata->dev = &spi->dev; @@ -37,14 +35,9 @@ static int st_press_spi_probe(struct spi_device *spi) err = st_press_common_probe(indio_dev, spi->dev.platform_data); if (err < 0) - goto st_press_common_probe_error; + return err; return 0; - -st_press_common_probe_error: - iio_device_free(indio_dev); -iio_device_alloc_error: - return err; } static int st_press_spi_remove(struct spi_device *spi) -- GitLab From ccf12c3310b489c39e78a3fc06c9ef15a4570078 Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Mon, 29 Jul 2013 23:18:00 +0100 Subject: [PATCH 553/942] iio:adjd_s311: Use devm_iio_device_alloc Signed-off-by: Peter Meerwald Signed-off-by: Jonathan Cameron --- drivers/iio/light/adjd_s311.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/iio/light/adjd_s311.c b/drivers/iio/light/adjd_s311.c index 5f4749e60b042..55b9e185d1649 100644 --- a/drivers/iio/light/adjd_s311.c +++ b/drivers/iio/light/adjd_s311.c @@ -293,11 +293,10 @@ static int adjd_s311_probe(struct i2c_client *client, struct iio_dev *indio_dev; int err; - indio_dev = iio_device_alloc(sizeof(*data)); - if (indio_dev == NULL) { - err = -ENOMEM; - goto exit; - } + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); + if (indio_dev == NULL) + return -ENOMEM; + data = iio_priv(indio_dev); i2c_set_clientdata(client, indio_dev); data->client = client; @@ -312,7 +311,7 @@ static int adjd_s311_probe(struct i2c_client *client, err = iio_triggered_buffer_setup(indio_dev, NULL, adjd_s311_trigger_handler, NULL); if (err < 0) - goto exit_free_device; + return err; err = iio_device_register(indio_dev); if (err) @@ -324,9 +323,6 @@ static int adjd_s311_probe(struct i2c_client *client, exit_unreg_buffer: iio_triggered_buffer_cleanup(indio_dev); -exit_free_device: - iio_device_free(indio_dev); -exit: return err; } @@ -338,7 +334,6 @@ static int adjd_s311_remove(struct i2c_client *client) iio_device_unregister(indio_dev); iio_triggered_buffer_cleanup(indio_dev); kfree(data->buffer); - iio_device_free(indio_dev); return 0; } -- GitLab From 2669d723ac6a01857273848a090c747f044a62d3 Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Mon, 29 Jul 2013 23:18:00 +0100 Subject: [PATCH 554/942] iio:vcnl4000: Use devm_iio_device_alloc Signed-off-by: Peter Meerwald Signed-off-by: Jonathan Cameron --- drivers/iio/light/vcnl4000.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c index 1014943d949a1..2bb304215b1d8 100644 --- a/drivers/iio/light/vcnl4000.c +++ b/drivers/iio/light/vcnl4000.c @@ -157,7 +157,7 @@ static int vcnl4000_probe(struct i2c_client *client, struct iio_dev *indio_dev; int ret; - indio_dev = iio_device_alloc(sizeof(*data)); + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); if (!indio_dev) return -ENOMEM; @@ -167,7 +167,7 @@ static int vcnl4000_probe(struct i2c_client *client, ret = i2c_smbus_read_byte_data(data->client, VCNL4000_PROD_REV); if (ret < 0) - goto error_free_dev; + return ret; dev_info(&client->dev, "VCNL4000 Ambient light/proximity sensor, Prod %02x, Rev: %02x\n", ret >> 4, ret & 0xf); @@ -181,22 +181,14 @@ static int vcnl4000_probe(struct i2c_client *client, ret = iio_device_register(indio_dev); if (ret < 0) - goto error_free_dev; + return ret; return 0; - -error_free_dev: - iio_device_free(indio_dev); - return ret; } static int vcnl4000_remove(struct i2c_client *client) { - struct iio_dev *indio_dev = i2c_get_clientdata(client); - - iio_device_unregister(indio_dev); - iio_device_free(indio_dev); - + iio_device_unregister(i2c_get_clientdata(client)); return 0; } -- GitLab From b6ff86f3f598a83715773923952565a36eafd952 Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Mon, 29 Jul 2013 23:18:00 +0100 Subject: [PATCH 555/942] iio:mcp4725: Use devm_iio_device_alloc Signed-off-by: Peter Meerwald Signed-off-by: Jonathan Cameron --- drivers/iio/dac/mcp4725.c | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/drivers/iio/dac/mcp4725.c b/drivers/iio/dac/mcp4725.c index 18a78cd21e883..1f4a48e6a82c3 100644 --- a/drivers/iio/dac/mcp4725.c +++ b/drivers/iio/dac/mcp4725.c @@ -292,15 +292,12 @@ static int mcp4725_probe(struct i2c_client *client, if (!platform_data || !platform_data->vref_mv) { dev_err(&client->dev, "invalid platform data"); - err = -EINVAL; - goto exit; + return -EINVAL; } - indio_dev = iio_device_alloc(sizeof(*data)); - if (indio_dev == NULL) { - err = -ENOMEM; - goto exit; - } + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); + if (indio_dev == NULL) + return -ENOMEM; data = iio_priv(indio_dev); i2c_set_clientdata(client, indio_dev); data->client = client; @@ -317,7 +314,7 @@ static int mcp4725_probe(struct i2c_client *client, err = i2c_master_recv(client, inbuf, 3); if (err < 0) { dev_err(&client->dev, "failed to read DAC value"); - goto exit_free_device; + return err; } pd = (inbuf[0] >> 1) & 0x3; data->powerdown = pd > 0 ? true : false; @@ -326,25 +323,16 @@ static int mcp4725_probe(struct i2c_client *client, err = iio_device_register(indio_dev); if (err) - goto exit_free_device; + return err; dev_info(&client->dev, "MCP4725 DAC registered\n"); return 0; - -exit_free_device: - iio_device_free(indio_dev); -exit: - return err; } static int mcp4725_remove(struct i2c_client *client) { - struct iio_dev *indio_dev = i2c_get_clientdata(client); - - iio_device_unregister(indio_dev); - iio_device_free(indio_dev); - + iio_device_unregister(i2c_get_clientdata(client)); return 0; } -- GitLab From 9bc541028b2b93962e0bebce62ce6e295aab2086 Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Mon, 29 Jul 2013 22:35:00 +0100 Subject: [PATCH 556/942] iio: Fix documentation of devm_iio_device_free() Signed-off-by: Peter Meerwald Cc: Grygorii Strashko Cc: Oleksandr Kravchenko Signed-off-by: Jonathan Cameron --- include/linux/iio/iio.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h index 61d220f89aca4..09ebe0a4d8e6a 100644 --- a/include/linux/iio/iio.h +++ b/include/linux/iio/iio.h @@ -552,9 +552,9 @@ struct iio_dev *devm_iio_device_alloc(struct device *dev, int sizeof_priv); * @dev: Device this iio_dev belongs to * @indio_dev: the iio_dev associated with the device * - * Free indio_dev allocated with devm_iio_device_alloc(). + * Free iio_dev allocated with devm_iio_device_alloc(). */ -void devm_iio_device_free(struct device *dev, struct iio_dev *iio_dev); +void devm_iio_device_free(struct device *dev, struct iio_dev *indio_dev); /** * iio_buffer_enabled() - helper function to test if the buffer is enabled -- GitLab From 7ac24edaf4e9af0d89efc571109dcbeec41e39be Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sun, 4 Aug 2013 07:36:31 +0800 Subject: [PATCH 557/942] staging: lustre: remove cfs_for_each_possible_cpu() It was just a wrapper around for_each_possible_cpu() Cc: Peng Tao Cc: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/include/linux/libcfs/libcfs.h | 4 ---- .../lustre/include/linux/libcfs/linux/linux-prim.h | 10 ---------- .../include/linux/libcfs/linux/portals_compat25.h | 8 -------- .../lustre/lustre/include/linux/lustre_compat25.h | 6 ------ drivers/staging/lustre/lustre/libcfs/tracefile.c | 8 ++++---- 5 files changed, 4 insertions(+), 32 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/libcfs.h index b71046ea18cb9..687dbab2c4ec4 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h @@ -84,10 +84,6 @@ static inline int __is_po2(unsigned long long val) #include -#ifndef cfs_for_each_possible_cpu -# error cfs_for_each_possible_cpu is not supported by kernel! -#endif - /* libcfs tcpip */ int libcfs_ipif_query(char *name, int *up, __u32 *ip, __u32 *mask); int libcfs_ipif_enumerate(char ***names); diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h index 029929a4fabcd..eb4188bc6b85c 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h @@ -63,16 +63,6 @@ #include - -/* - * CPU - */ -#ifdef for_each_possible_cpu -#define cfs_for_each_possible_cpu(cpu) for_each_possible_cpu(cpu) -#elif defined(for_each_cpu) -#define cfs_for_each_possible_cpu(cpu) for_each_cpu(cpu) -#endif - /* * Sysctl register */ diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/portals_compat25.h b/drivers/staging/lustre/include/linux/libcfs/linux/portals_compat25.h index 2bbb4d5c40520..fe4c63fb40a4f 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/portals_compat25.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/portals_compat25.h @@ -95,13 +95,5 @@ int proc_call_handler(void *data, int write, loff_t *ppos, void *buffer, size_t *lenp, int (*handler)(void *data, int write, loff_t pos, void *buffer, int len)); -/* - * CPU - */ -#ifdef for_each_possible_cpu -#define cfs_for_each_possible_cpu(cpu) for_each_possible_cpu(cpu) -#elif defined(for_each_cpu) -#define cfs_for_each_possible_cpu(cpu) for_each_cpu(cpu) -#endif #endif /* _PORTALS_COMPAT_H */ diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h index 089f358b6b2eb..9243dfab43d39 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_compat25.h @@ -108,12 +108,6 @@ static inline void ll_set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt, #define ll_vfs_rename(old,old_dir,mnt,new,new_dir,mnt1) \ vfs_rename(old,old_dir,new,new_dir) -#ifdef for_each_possible_cpu -#define cfs_for_each_possible_cpu(cpu) for_each_possible_cpu(cpu) -#elif defined(for_each_cpu) -#define cfs_for_each_possible_cpu(cpu) for_each_cpu(cpu) -#endif - #define cfs_bio_io_error(a,b) bio_io_error((a)) #define cfs_bio_endio(a,b,c) bio_endio((a),(c)) diff --git a/drivers/staging/lustre/lustre/libcfs/tracefile.c b/drivers/staging/lustre/lustre/libcfs/tracefile.c index 439e71dfae339..68c77d3813958 100644 --- a/drivers/staging/lustre/lustre/libcfs/tracefile.c +++ b/drivers/staging/lustre/lustre/libcfs/tracefile.c @@ -529,7 +529,7 @@ static void collect_pages_on_all_cpus(struct page_collection *pc) int i, cpu; spin_lock(&pc->pc_lock); - cfs_for_each_possible_cpu(cpu) { + for_each_possible_cpu(cpu) { cfs_tcd_for_each_type_lock(tcd, i, cpu) { list_splice_init(&tcd->tcd_pages, &pc->pc_pages); tcd->tcd_cur_pages = 0; @@ -562,7 +562,7 @@ static void put_pages_back_on_all_cpus(struct page_collection *pc) int i, cpu; spin_lock(&pc->pc_lock); - cfs_for_each_possible_cpu(cpu) { + for_each_possible_cpu(cpu) { cfs_tcd_for_each_type_lock(tcd, i, cpu) { cur_head = tcd->tcd_pages.next; @@ -630,7 +630,7 @@ static void put_pages_on_daemon_list(struct page_collection *pc) struct cfs_trace_cpu_data *tcd; int i, cpu; - cfs_for_each_possible_cpu(cpu) { + for_each_possible_cpu(cpu) { cfs_tcd_for_each_type_lock(tcd, i, cpu) put_pages_on_tcd_daemon_list(pc, tcd); } @@ -1159,7 +1159,7 @@ static void trace_cleanup_on_all_cpus(void) struct cfs_trace_page *tmp; int i, cpu; - cfs_for_each_possible_cpu(cpu) { + for_each_possible_cpu(cpu) { cfs_tcd_for_each_type_lock(tcd, i, cpu) { tcd->tcd_shutting_down = 1; -- GitLab From 409ccba9f222f4952843fee15432c67fbab53c74 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sun, 4 Aug 2013 07:42:22 +0800 Subject: [PATCH 558/942] staging: lustre: remove unused cfs_"symbol" macros These aren't used, so remove them. Cc: Peng Tao Cc: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../lustre/include/linux/libcfs/linux/linux-prim.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h index eb4188bc6b85c..e43ece6f808f5 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h @@ -80,14 +80,6 @@ LL_PROC_PROTO(name) \ __##name); \ } -/* - * Symbol register - */ -#define cfs_symbol_register(s, p) do {} while(0) -#define cfs_symbol_unregister(s) do {} while(0) -#define cfs_symbol_get(s) symbol_get(s) -#define cfs_symbol_put(s) symbol_put(s) - typedef struct module module_t; /* -- GitLab From c34d9cd855b48d9dbedbd801f5e3019776c86e4c Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sun, 4 Aug 2013 07:48:41 +0800 Subject: [PATCH 559/942] staging: lustre: remove typedef for module_t Use "struct module" like the rest of the kernel, not a typedef. Cc: Peng Tao Cc: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/include/linux/libcfs/linux/linux-prim.h | 2 -- drivers/staging/lustre/include/linux/libcfs/params_tree.h | 4 +--- drivers/staging/lustre/lustre/include/linux/lustre_fsfilt.h | 2 +- drivers/staging/lustre/lustre/include/lu_object.h | 2 +- drivers/staging/lustre/lustre/include/lustre_net.h | 4 ++-- drivers/staging/lustre/lustre/include/lustre_sec.h | 2 +- drivers/staging/lustre/lustre/include/obd.h | 2 +- drivers/staging/lustre/lustre/ptlrpc/gss/gss_api.h | 2 +- 8 files changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h index e43ece6f808f5..23bccf234af91 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h @@ -80,8 +80,6 @@ LL_PROC_PROTO(name) \ __##name); \ } -typedef struct module module_t; - /* * Proc file system APIs */ diff --git a/drivers/staging/lustre/include/linux/libcfs/params_tree.h b/drivers/staging/lustre/include/linux/libcfs/params_tree.h index 3f18a44670372..78a2c4ed4d6c5 100644 --- a/drivers/staging/lustre/include/linux/libcfs/params_tree.h +++ b/drivers/staging/lustre/include/linux/libcfs/params_tree.h @@ -54,7 +54,6 @@ typedef struct proc_inode cfs_proc_inode_t; typedef struct seq_file cfs_seq_file_t; typedef struct seq_operations cfs_seq_ops_t; typedef struct file_operations cfs_param_file_ops_t; -typedef module_t *cfs_param_module_t; typedef struct proc_dir_entry cfs_param_dentry_t; typedef struct poll_table_struct cfs_poll_table_t; #define CFS_PARAM_MODULE THIS_MODULE @@ -115,11 +114,10 @@ typedef struct cfs_seq_operations { int (*show) (cfs_seq_file_t *m, void *v); } cfs_seq_ops_t; -typedef void *cfs_param_module_t; typedef void *cfs_poll_table_t; typedef struct cfs_param_file_ops { - cfs_param_module_t owner; + struct module *owner; int (*open) (cfs_inode_t *, struct file *); loff_t (*llseek)(struct file *, loff_t, int); int (*release) (cfs_inode_t *, cfs_param_file_t *); diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_fsfilt.h b/drivers/staging/lustre/lustre/include/linux/lustre_fsfilt.h index e637006203ab5..4da6e372e00be 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_fsfilt.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_fsfilt.h @@ -54,7 +54,7 @@ typedef void (*fsfilt_cb_t)(struct obd_device *obd, __u64 last_rcvd, struct fsfilt_operations { struct list_head fs_list; - module_t *fs_owner; + struct module *fs_owner; char *fs_type; char *(* fs_getlabel)(struct super_block *sb); void *(* fs_start)(struct inode *inode, int op, void *desc_private, diff --git a/drivers/staging/lustre/lustre/include/lu_object.h b/drivers/staging/lustre/lustre/include/lu_object.h index 8077898e88ec9..fa31be886ef8c 100644 --- a/drivers/staging/lustre/lustre/include/lu_object.h +++ b/drivers/staging/lustre/lustre/include/lu_object.h @@ -1131,7 +1131,7 @@ struct lu_context_key { /** * Internal implementation detail: module for this key. */ - module_t *lct_owner; + struct module *lct_owner; /** * References to this key. For debugging. */ diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h index 8d7cc7ab00398..f315ef7752563 100644 --- a/drivers/staging/lustre/lustre/include/lustre_net.h +++ b/drivers/staging/lustre/lustre/include/lustre_net.h @@ -1136,7 +1136,7 @@ struct ptlrpc_nrs_pol_conf { * different module to the one the NRS framework is held within * (currently ptlrpc), should set this field to THIS_MODULE. */ - module_t *nc_owner; + struct module *nc_owner; /** * Policy registration flags; a bitmast of \e nrs_policy_flags */ @@ -1211,7 +1211,7 @@ struct ptlrpc_nrs_pol_desc { * then unregistration and lprocfs operations will be properly * serialized. */ - module_t *pd_owner; + struct module *pd_owner; /** * Bitmask of \e nrs_policy_flags */ diff --git a/drivers/staging/lustre/lustre/include/lustre_sec.h b/drivers/staging/lustre/lustre/include/lustre_sec.h index 9e0908e1c4d66..70b8b133a5c3c 100644 --- a/drivers/staging/lustre/lustre/include/lustre_sec.h +++ b/drivers/staging/lustre/lustre/include/lustre_sec.h @@ -796,7 +796,7 @@ struct ptlrpc_sec_sops { }; struct ptlrpc_sec_policy { - module_t *sp_owner; + struct module *sp_owner; char *sp_name; __u16 sp_policy; /* policy number */ struct ptlrpc_sec_cops *sp_cops; /* client ops */ diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index 003466498afe0..83b0b3287f1ef 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -1108,7 +1108,7 @@ struct md_enqueue_info { }; struct obd_ops { - module_t *o_owner; + struct module *o_owner; int (*o_iocontrol)(unsigned int cmd, struct obd_export *exp, int len, void *karg, void *uarg); int (*o_get_info)(const struct lu_env *env, struct obd_export *, diff --git a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_api.h b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_api.h index feac60482c97a..0e9f6c472a377 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/gss/gss_api.h +++ b/drivers/staging/lustre/lustre/ptlrpc/gss/gss_api.h @@ -100,7 +100,7 @@ struct subflavor_desc { /* Each mechanism is described by the following struct: */ struct gss_api_mech { struct list_head gm_list; - module_t *gm_owner; + struct module *gm_owner; char *gm_name; rawobj_t gm_oid; atomic_t gm_count; -- GitLab From c88a6cbb7750585f9aadf034ee536cf8228c9964 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sun, 4 Aug 2013 07:59:19 +0800 Subject: [PATCH 560/942] staging: lustre: remove typedef for group_info_t Use "struct group_info" like the rest of the kernel, not a typedef. Cc: Peng Tao Cc: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../include/linux/libcfs/linux/linux-prim.h | 25 ------------------- .../lustre/include/linux/libcfs/lucache.h | 2 +- .../lustre/lustre/include/lustre_idmap.h | 4 +-- .../staging/lustre/lustre/include/md_object.h | 2 +- .../staging/lustre/lustre/obdclass/idmap.c | 9 +++---- .../staging/lustre/lustre/ptlrpc/service.c | 2 +- 6 files changed, 9 insertions(+), 35 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h index 23bccf234af91..e210a90655b97 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h @@ -168,32 +168,7 @@ do { \ /* * atomic */ - - #define cfs_atomic_add_unless(atom, a, u) atomic_add_unless(atom, a, u) #define cfs_atomic_cmpxchg(atom, old, nv) atomic_cmpxchg(atom, old, nv) -/* - * membar - */ - - -/* - * interrupt - */ - - -/* - * might_sleep - */ - -/* - * group_info - */ -typedef struct group_info group_info_t; - - -/* - * Random bytes - */ #endif diff --git a/drivers/staging/lustre/include/linux/libcfs/lucache.h b/drivers/staging/lustre/include/linux/libcfs/lucache.h index 7ae36fc88d771..9668b397f0f60 100644 --- a/drivers/staging/lustre/include/linux/libcfs/lucache.h +++ b/drivers/staging/lustre/include/linux/libcfs/lucache.h @@ -77,7 +77,7 @@ struct md_identity { struct upcall_cache_entry *mi_uc_entry; uid_t mi_uid; gid_t mi_gid; - group_info_t *mi_ginfo; + struct group_info *mi_ginfo; int mi_nperms; struct md_perm *mi_perms; }; diff --git a/drivers/staging/lustre/lustre/include/lustre_idmap.h b/drivers/staging/lustre/lustre/include/lustre_idmap.h index 084bdd6ab4dba..2da859691d6a4 100644 --- a/drivers/staging/lustre/lustre/include/lustre_idmap.h +++ b/drivers/staging/lustre/lustre/include/lustre_idmap.h @@ -80,8 +80,8 @@ struct lustre_idmap_table { struct lu_ucred; -extern void lustre_groups_from_list(group_info_t *ginfo, gid_t *glist); -extern void lustre_groups_sort(group_info_t *group_info); +extern void lustre_groups_from_list(struct group_info *ginfo, gid_t *glist); +extern void lustre_groups_sort(struct group_info *group_info); extern int lustre_in_group_p(struct lu_ucred *mu, gid_t grp); extern int lustre_idmap_add(struct lustre_idmap_table *t, diff --git a/drivers/staging/lustre/lustre/include/md_object.h b/drivers/staging/lustre/lustre/include/md_object.h index 65b270a6d5909..daf93afe3febd 100644 --- a/drivers/staging/lustre/lustre/include/md_object.h +++ b/drivers/staging/lustre/lustre/include/md_object.h @@ -871,7 +871,7 @@ struct lu_ucred { __u32 uc_suppgids[2]; cfs_cap_t uc_cap; __u32 uc_umask; - group_info_t *uc_ginfo; + struct group_info *uc_ginfo; struct md_identity *uc_identity; }; diff --git a/drivers/staging/lustre/lustre/obdclass/idmap.c b/drivers/staging/lustre/lustre/obdclass/idmap.c index afb66a49f8285..ec2590f5cfe9c 100644 --- a/drivers/staging/lustre/lustre/obdclass/idmap.c +++ b/drivers/staging/lustre/lustre/obdclass/idmap.c @@ -59,8 +59,7 @@ * groups_search() is copied from linux kernel! * A simple bsearch. */ -static int lustre_groups_search(group_info_t *group_info, - gid_t grp) +static int lustre_groups_search(const struct group_info *group_info, gid_t grp) { int left, right; @@ -84,7 +83,7 @@ static int lustre_groups_search(group_info_t *group_info, return 0; } -void lustre_groups_from_list(group_info_t *ginfo, gid_t *glist) +void lustre_groups_from_list(struct group_info *ginfo, gid_t *glist) { int i; int count = ginfo->ngroups; @@ -103,7 +102,7 @@ EXPORT_SYMBOL(lustre_groups_from_list); /* groups_sort() is copied from linux kernel! */ /* a simple shell-metzner sort */ -void lustre_groups_sort(group_info_t *group_info) +void lustre_groups_sort(struct group_info *group_info) { int base, max, stride; int gidsetsize = group_info->ngroups; @@ -141,7 +140,7 @@ int lustre_in_group_p(struct lu_ucred *mu, gid_t grp) int rc = 1; if (grp != mu->uc_fsgid) { - group_info_t *group_info = NULL; + struct group_info *group_info = NULL; if (mu->uc_ginfo || !mu->uc_identity || mu->uc_valid == UCRED_OLD) diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index d5628e0fedf7a..4f0118cc75467 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -2266,7 +2266,7 @@ static int ptlrpc_main(void *arg) struct ptlrpc_service *svc = svcpt->scp_service; struct ptlrpc_reply_state *rs; #ifdef WITH_GROUP_INFO - group_info_t *ginfo = NULL; + struct group_info *ginfo = NULL; #endif struct lu_env *env; int counter = 0, rc = 0; -- GitLab From 305ec768ff192996b4dcb326c5980cd8a96fa948 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sun, 4 Aug 2013 08:03:39 +0800 Subject: [PATCH 561/942] staging: lustre: remove wrappers for two atomic functions Just call them directly, like the rest of the kernel does. Cc: Peng Tao Cc: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/include/linux/libcfs/linux/linux-prim.h | 6 ------ drivers/staging/lustre/lustre/llite/lproc_llite.c | 2 +- drivers/staging/lustre/lustre/osc/osc_page.c | 2 +- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h index e210a90655b97..722d90cfef162 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h @@ -165,10 +165,4 @@ do { \ #define cfs_waitq_wait_event_interruptible_timeout(wq, c, timeout, ret) \ ret = wait_event_interruptible_timeout(wq, c, timeout) -/* - * atomic - */ -#define cfs_atomic_add_unless(atom, a, u) atomic_add_unless(atom, a, u) -#define cfs_atomic_cmpxchg(atom, old, nv) atomic_cmpxchg(atom, old, nv) - #endif diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 179ea9abf68f4..db349f68e32e6 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -419,7 +419,7 @@ static ssize_t ll_max_cached_mb_seq_write(struct file *file, const char *buffer, break; nv = ov > diff ? ov - diff : 0; - rc = cfs_atomic_cmpxchg(&cache->ccc_lru_left, ov, nv); + rc = atomic_cmpxchg(&cache->ccc_lru_left, ov, nv); if (likely(ov == rc)) { diff -= ov - nv; nrpages += ov - nv; diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c index ed84df0a4e600..159dda07f43a5 100644 --- a/drivers/staging/lustre/lustre/osc/osc_page.c +++ b/drivers/staging/lustre/lustre/osc/osc_page.c @@ -881,7 +881,7 @@ static int osc_lru_reserve(const struct lu_env *env, struct osc_object *obj, return 0; LASSERT(atomic_read(cli->cl_lru_left) >= 0); - while (!cfs_atomic_add_unless(cli->cl_lru_left, -1, 0)) { + while (!atomic_add_unless(cli->cl_lru_left, -1, 0)) { int gen; /* run out of LRU spaces, try to drop some by itself */ -- GitLab From 6960736c01732ad952aa6c513976fa0b95166873 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sun, 4 Aug 2013 08:16:25 +0800 Subject: [PATCH 562/942] staging: lustre: remove cfs_module() macro Open code the module_init/module_exit lines, and also use MODULE_VERSION, as it seems that was intended, but just never hooked up at all. Cc: Peng Tao Cc: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../lustre/include/linux/libcfs/linux/linux-prim.h | 9 --------- drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c | 4 +++- drivers/staging/lustre/lnet/lnet/module.c | 4 +++- drivers/staging/lustre/lnet/selftest/module.c | 4 +++- drivers/staging/lustre/lustre/fid/fid_request.c | 4 +++- drivers/staging/lustre/lustre/libcfs/module.c | 4 +++- drivers/staging/lustre/lustre/lov/lov_obd.c | 4 +++- drivers/staging/lustre/lustre/obdclass/class_obd.c | 4 +++- drivers/staging/lustre/lustre/obdecho/echo_client.c | 4 +++- drivers/staging/lustre/lustre/osc/osc_request.c | 4 +++- drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c | 4 +++- 11 files changed, 30 insertions(+), 19 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h index 722d90cfef162..64e75c7bfc43b 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h @@ -107,15 +107,6 @@ typedef struct task_struct task_t; current->journal_info = journal_info; \ } while(0) -/* Module interfaces */ -#define cfs_module(name, version, init, fini) \ - module_init(init); \ - module_exit(fini) - -/* - * Signal - */ - /* * Timer */ diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c index d7b01e78ed7af..1f367638eec43 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c @@ -2898,5 +2898,7 @@ ksocknal_module_init (void) MODULE_AUTHOR("Sun Microsystems, Inc. "); MODULE_DESCRIPTION("Kernel TCP Socket LND v3.0.0"); MODULE_LICENSE("GPL"); +MODULE_VERSION("3.0.0"); -cfs_module(ksocknal, "3.0.0", ksocknal_module_init, ksocknal_module_fini); +module_init(ksocknal_module_init); +module_exit(ksocknal_module_fini); diff --git a/drivers/staging/lustre/lnet/lnet/module.c b/drivers/staging/lustre/lnet/lnet/module.c index 8679b8d1b2f76..afb81755cbad1 100644 --- a/drivers/staging/lustre/lnet/lnet/module.c +++ b/drivers/staging/lustre/lnet/lnet/module.c @@ -149,5 +149,7 @@ fini_lnet(void) MODULE_AUTHOR("Peter J. Braam "); MODULE_DESCRIPTION("Portals v3.1"); MODULE_LICENSE("GPL"); +MODULE_VERSION("1.0.0"); -cfs_module(lnet, "1.0.0", init_lnet, fini_lnet); +module_init(init_lnet); +module_exit(fini_lnet); diff --git a/drivers/staging/lustre/lnet/selftest/module.c b/drivers/staging/lustre/lnet/selftest/module.c index 5257e5630a0e3..6dd4309dc5ea7 100644 --- a/drivers/staging/lustre/lnet/selftest/module.c +++ b/drivers/staging/lustre/lnet/selftest/module.c @@ -165,5 +165,7 @@ lnet_selftest_init(void) MODULE_DESCRIPTION("LNet Selftest"); MODULE_LICENSE("GPL"); +MODULE_VERSION("0.9.0"); -cfs_module(lnet, "0.9.0", lnet_selftest_init, lnet_selftest_fini); +module_init(lnet_selftest_init); +module_exit(lnet_selftest_fini); diff --git a/drivers/staging/lustre/lustre/fid/fid_request.c b/drivers/staging/lustre/lustre/fid/fid_request.c index dc3948e4be391..66007b57018bd 100644 --- a/drivers/staging/lustre/lustre/fid/fid_request.c +++ b/drivers/staging/lustre/lustre/fid/fid_request.c @@ -564,5 +564,7 @@ static void __exit fid_mod_exit(void) MODULE_AUTHOR("Sun Microsystems, Inc. "); MODULE_DESCRIPTION("Lustre FID Module"); MODULE_LICENSE("GPL"); +MODULE_VERSION("0.1.0"); -cfs_module(fid, "0.1.0", fid_mod_init, fid_mod_exit); +module_init(fid_mod_init); +module_exit(fid_mod_exit); diff --git a/drivers/staging/lustre/lustre/libcfs/module.c b/drivers/staging/lustre/lustre/libcfs/module.c index 432b55d3216c8..f3108c7f818e9 100644 --- a/drivers/staging/lustre/lustre/libcfs/module.c +++ b/drivers/staging/lustre/lustre/libcfs/module.c @@ -491,4 +491,6 @@ static void exit_libcfs_module(void) libcfs_arch_cleanup(); } -cfs_module(libcfs, "1.0.0", init_libcfs_module, exit_libcfs_module); +MODULE_VERSION("1.0.0"); +module_init(init_libcfs_module); +module_exit(exit_libcfs_module); diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index a8c709e26a92b..71f5ef16e83da 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -2870,5 +2870,7 @@ static void /*__exit*/ lov_exit(void) MODULE_AUTHOR("Sun Microsystems, Inc. "); MODULE_DESCRIPTION("Lustre Logical Object Volume OBD driver"); MODULE_LICENSE("GPL"); +MODULE_VERSION(LUSTRE_VERSION_STRING); -cfs_module(lov, LUSTRE_VERSION_STRING, lov_init, lov_exit); +module_init(lov_init); +module_exit(lov_exit); diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c index 44af41278a03f..b1024a6d37dd9 100644 --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c @@ -680,5 +680,7 @@ static void cleanup_obdclass(void) MODULE_AUTHOR("Sun Microsystems, Inc. "); MODULE_DESCRIPTION("Lustre Class Driver Build Version: " BUILD_VERSION); MODULE_LICENSE("GPL"); +MODULE_VERSION(LUSTRE_VERSION_STRING); -cfs_module(obdclass, LUSTRE_VERSION_STRING, init_obdclass, cleanup_obdclass); +module_init(init_obdclass); +module_exit(cleanup_obdclass); diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c index 25151b13fefdd..2644edf438c1e 100644 --- a/drivers/staging/lustre/lustre/obdecho/echo_client.c +++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c @@ -3163,7 +3163,9 @@ static void /*__exit*/ obdecho_exit(void) MODULE_AUTHOR("Sun Microsystems, Inc. "); MODULE_DESCRIPTION("Lustre Testing Echo OBD driver"); MODULE_LICENSE("GPL"); +MODULE_VERSION(LUSTRE_VERSION_STRING); -cfs_module(obdecho, LUSTRE_VERSION_STRING, obdecho_init, obdecho_exit); +module_init(obdecho_init); +module_exit(obdecho_exit); /** @} echo_client */ diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 611678c407a6a..ee6707a5ea9d8 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -3656,5 +3656,7 @@ static void /*__exit*/ osc_exit(void) MODULE_AUTHOR("Sun Microsystems, Inc. "); MODULE_DESCRIPTION("Lustre Object Storage Client (OSC)"); MODULE_LICENSE("GPL"); +MODULE_VERSION(LUSTRE_VERSION_STRING); -cfs_module(osc, LUSTRE_VERSION_STRING, osc_init, osc_exit); +module_init(osc_init); +module_exit(osc_exit); diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c index d26fce802b66d..419e634854df0 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_module.c @@ -149,5 +149,7 @@ static void __exit ptlrpc_exit(void) MODULE_AUTHOR("Sun Microsystems, Inc. "); MODULE_DESCRIPTION("Lustre Request Processor and Lock Management"); MODULE_LICENSE("GPL"); +MODULE_VERSION("1.0.0"); -cfs_module(ptlrpc, "1.0.0", ptlrpc_init, ptlrpc_exit); +module_init(ptlrpc_init); +module_exit(ptlrpc_exit); -- GitLab From 8db0fc89312ec8132654a614bc0ff4a6bd2e49fa Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sun, 4 Aug 2013 08:20:58 +0800 Subject: [PATCH 563/942] staging: lustre: remove unused cfs_ waitqueue wrappers These weren't ever used, so just remove them. Cc: Peng Tao Cc: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../include/linux/libcfs/linux/linux-prim.h | 44 ------------------- 1 file changed, 44 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h index 64e75c7bfc43b..acf338b3eb36d 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h @@ -112,48 +112,4 @@ typedef struct task_struct task_t; */ typedef struct timer_list timer_list_t; - -#ifndef wait_event_timeout /* Only for RHEL3 2.4.21 kernel */ -#define __wait_event_timeout(wq, condition, timeout, ret) \ -do { \ - int __ret = 0; \ - if (!(condition)) { \ - wait_queue_t __wait; \ - unsigned long expire; \ - \ - init_waitqueue_entry(&__wait, current); \ - expire = timeout + jiffies; \ - add_wait_queue(&wq, &__wait); \ - for (;;) { \ - set_current_state(TASK_UNINTERRUPTIBLE); \ - if (condition) \ - break; \ - if (jiffies > expire) { \ - ret = jiffies - expire; \ - break; \ - } \ - schedule_timeout(timeout); \ - } \ - current->state = TASK_RUNNING; \ - remove_wait_queue(&wq, &__wait); \ - } \ -} while (0) -/* - retval == 0; condition met; we're good. - retval > 0; timed out. -*/ -#define cfs_waitq_wait_event_timeout(wq, condition, timeout, ret) \ -do { \ - ret = 0; \ - if (!(condition)) \ - __wait_event_timeout(wq, condition, timeout, ret); \ -} while (0) -#else -#define cfs_waitq_wait_event_timeout(wq, condition, timeout, ret) \ - ret = wait_event_timeout(wq, condition, timeout) -#endif - -#define cfs_waitq_wait_event_interruptible_timeout(wq, c, timeout, ret) \ - ret = wait_event_interruptible_timeout(wq, c, timeout) - #endif -- GitLab From 543193511670ecad75267ffd7c9aa110cd30dfdf Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sun, 4 Aug 2013 08:35:40 +0800 Subject: [PATCH 564/942] staging: lustre: remove timer_list_t typedef Use struct timer_list instead. Cc: Peng Tao Cc: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../lustre/include/linux/libcfs/libcfs_prim.h | 14 +++++++------- .../lustre/include/linux/libcfs/linux/linux-prim.h | 5 ----- drivers/staging/lustre/lustre/include/lustre_net.h | 2 +- drivers/staging/lustre/lustre/include/obd.h | 2 +- .../lustre/lustre/libcfs/linux/linux-prim.c | 14 +++++++------- .../staging/lustre/lustre/llite/llite_internal.h | 2 +- 6 files changed, 17 insertions(+), 22 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h index 36def3615d019..6384f6c693ff2 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h @@ -56,13 +56,13 @@ int64_t waitq_timedwait(wait_queue_t *, cfs_task_state_t, int64_t); void waitq_wait(wait_queue_t *, cfs_task_state_t); void add_wait_queue_exclusive_head(wait_queue_head_t *, wait_queue_t *); -void cfs_init_timer(timer_list_t *t); -void cfs_timer_init(timer_list_t *t, cfs_timer_func_t *func, void *arg); -void cfs_timer_done(timer_list_t *t); -void cfs_timer_arm(timer_list_t *t, cfs_time_t deadline); -void cfs_timer_disarm(timer_list_t *t); -int cfs_timer_is_armed(timer_list_t *t); -cfs_time_t cfs_timer_deadline(timer_list_t *t); +void cfs_init_timer(struct timer_list *t); +void cfs_timer_init(struct timer_list *t, cfs_timer_func_t *func, void *arg); +void cfs_timer_done(struct timer_list *t); +void cfs_timer_arm(struct timer_list *t, cfs_time_t deadline); +void cfs_timer_disarm(struct timer_list *t); +int cfs_timer_is_armed(struct timer_list *t); +cfs_time_t cfs_timer_deadline(struct timer_list *t); /* * Memory diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h index acf338b3eb36d..f0184e6eb1883 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h @@ -107,9 +107,4 @@ typedef struct task_struct task_t; current->journal_info = journal_info; \ } while(0) -/* - * Timer - */ -typedef struct timer_list timer_list_t; - #endif diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h index f315ef7752563..ce41bf9cc4651 100644 --- a/drivers/staging/lustre/lustre/include/lustre_net.h +++ b/drivers/staging/lustre/lustre/include/lustre_net.h @@ -2636,7 +2636,7 @@ struct ptlrpc_service_part { /** reqs waiting for replies */ struct ptlrpc_at_array scp_at_array; /** early reply timer */ - timer_list_t scp_at_timer; + struct timer_list scp_at_timer; /** debug */ cfs_time_t scp_at_checktime; /** check early replies */ diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index 83b0b3287f1ef..5cf687f1557b4 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -900,7 +900,7 @@ struct obd_device { int obd_requests_queued_for_recovery; wait_queue_head_t obd_next_transno_waitq; /* protected by obd_recovery_task_lock */ - timer_list_t obd_recovery_timer; + struct timer_list obd_recovery_timer; time_t obd_recovery_start; /* seconds */ time_t obd_recovery_end; /* seconds, for lprocfs_status */ int obd_recovery_time_hard; diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-prim.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-prim.c index b652a79a4811a..02e4466287a56 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-prim.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-prim.c @@ -112,13 +112,13 @@ cfs_pause(cfs_duration_t ticks) } EXPORT_SYMBOL(cfs_pause); -void cfs_init_timer(timer_list_t *t) +void cfs_init_timer(struct timer_list *t) { init_timer(t); } EXPORT_SYMBOL(cfs_init_timer); -void cfs_timer_init(timer_list_t *t, cfs_timer_func_t *func, void *arg) +void cfs_timer_init(struct timer_list *t, cfs_timer_func_t *func, void *arg) { init_timer(t); t->function = func; @@ -126,31 +126,31 @@ void cfs_timer_init(timer_list_t *t, cfs_timer_func_t *func, void *arg) } EXPORT_SYMBOL(cfs_timer_init); -void cfs_timer_done(timer_list_t *t) +void cfs_timer_done(struct timer_list *t) { return; } EXPORT_SYMBOL(cfs_timer_done); -void cfs_timer_arm(timer_list_t *t, cfs_time_t deadline) +void cfs_timer_arm(struct timer_list *t, cfs_time_t deadline) { mod_timer(t, deadline); } EXPORT_SYMBOL(cfs_timer_arm); -void cfs_timer_disarm(timer_list_t *t) +void cfs_timer_disarm(struct timer_list *t) { del_timer(t); } EXPORT_SYMBOL(cfs_timer_disarm); -int cfs_timer_is_armed(timer_list_t *t) +int cfs_timer_is_armed(struct timer_list *t) { return timer_pending(t); } EXPORT_SYMBOL(cfs_timer_is_armed); -cfs_time_t cfs_timer_deadline(timer_list_t *t) +cfs_time_t cfs_timer_deadline(struct timer_list *t) { return t->expires; } diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 28aed684364f9..47e443d90fe1a 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -1122,7 +1122,7 @@ int ll_update_remote_perm(struct inode *inode, struct mdt_remote_perm *perm); int lustre_check_remote_perm(struct inode *inode, int mask); /* llite/llite_capa.c */ -extern timer_list_t ll_capa_timer; +extern struct timer_list ll_capa_timer; int ll_capa_thread_start(void); void ll_capa_thread_stop(void); -- GitLab From 2f5723a1bf2d2f440b1cf8850bc6a9d8d4e82d3b Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sun, 4 Aug 2013 08:39:49 +0800 Subject: [PATCH 565/942] staging: lustre: remove CFS_DECL_WAITQ() macro Just use DECLARE_WAIT_QUEUE_HEAD() instead. Cc: Peng Tao Cc: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/include/linux/libcfs/linux/linux-prim.h | 4 ---- drivers/staging/lustre/lustre/osc/osc_page.c | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h index f0184e6eb1883..4b84feef05e2c 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h @@ -88,12 +88,8 @@ typedef struct proc_dir_entry proc_dir_entry_t; /* * Wait Queue */ - - typedef long cfs_task_state_t; -#define CFS_DECL_WAITQ(wq) DECLARE_WAIT_QUEUE_HEAD(wq) - /* * Task struct */ diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c index 159dda07f43a5..d272322b29b66 100644 --- a/drivers/staging/lustre/lustre/osc/osc_page.c +++ b/drivers/staging/lustre/lustre/osc/osc_page.c @@ -582,7 +582,7 @@ void osc_page_submit(const struct lu_env *env, struct osc_page *opg, * at any time. */ -static CFS_DECL_WAITQ(osc_lru_waitq); +static DECLARE_WAIT_QUEUE_HEAD(osc_lru_waitq); static atomic_t osc_lru_waiters = ATOMIC_INIT(0); /* LRU pages are freed in batch mode. OSC should at least free this * number of pages to avoid running out of LRU budget, and.. */ -- GitLab From e7e73793d17fc413d552bc00fd57a57439f6c293 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sun, 4 Aug 2013 08:48:26 +0800 Subject: [PATCH 566/942] staging: lustre: remove cfs_task_state_t It's just a long, so remove the typedef and use long. Side note, all the functions like waitq_* should be removed as well, they are wrapping functions that don't really do what it seems that they do based on their name. Cc: Peng Tao Cc: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h | 6 +++--- .../staging/lustre/include/linux/libcfs/linux/linux-prim.h | 5 ----- drivers/staging/lustre/lustre/libcfs/linux/linux-prim.c | 7 +++---- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h index 6384f6c693ff2..e6e417aeefd5b 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h @@ -49,11 +49,11 @@ void cfs_pause(cfs_duration_t ticks); * Timer */ typedef void (cfs_timer_func_t)(ulong_ptr_t); -void schedule_timeout_and_set_state(cfs_task_state_t, int64_t); +void schedule_timeout_and_set_state(long, int64_t); void init_waitqueue_entry_current(wait_queue_t *link); -int64_t waitq_timedwait(wait_queue_t *, cfs_task_state_t, int64_t); -void waitq_wait(wait_queue_t *, cfs_task_state_t); +int64_t waitq_timedwait(wait_queue_t *, long, int64_t); +void waitq_wait(wait_queue_t *, long); void add_wait_queue_exclusive_head(wait_queue_head_t *, wait_queue_t *); void cfs_init_timer(struct timer_list *t); diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h index 4b84feef05e2c..ae495a2ee4341 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h @@ -85,11 +85,6 @@ LL_PROC_PROTO(name) \ */ typedef struct proc_dir_entry proc_dir_entry_t; -/* - * Wait Queue - */ -typedef long cfs_task_state_t; - /* * Task struct */ diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-prim.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-prim.c index 02e4466287a56..cc9829ffbdcbf 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-prim.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-prim.c @@ -81,22 +81,21 @@ add_wait_queue_exclusive_head(wait_queue_head_t *waitq, wait_queue_t *link) EXPORT_SYMBOL(add_wait_queue_exclusive_head); void -waitq_wait(wait_queue_t *link, cfs_task_state_t state) +waitq_wait(wait_queue_t *link, long state) { schedule(); } EXPORT_SYMBOL(waitq_wait); int64_t -waitq_timedwait(wait_queue_t *link, cfs_task_state_t state, - int64_t timeout) +waitq_timedwait(wait_queue_t *link, long state, int64_t timeout) { return schedule_timeout(timeout); } EXPORT_SYMBOL(waitq_timedwait); void -schedule_timeout_and_set_state(cfs_task_state_t state, int64_t timeout) +schedule_timeout_and_set_state(long state, int64_t timeout) { set_current_state(state); schedule_timeout(timeout); -- GitLab From 68b636b68ebb58ef7a400886249be6479bdce96d Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sun, 4 Aug 2013 08:56:42 +0800 Subject: [PATCH 567/942] staging: lustre: remove task_t typedef Use struct task_struct instead. Also remove the unused libcfs_current() function, while I noticed it doing this conversion. Cc: Peng Tao Cc: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../lustre/include/linux/libcfs/linux/linux-prim.h | 4 ---- drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c | 2 +- drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 2 +- drivers/staging/lustre/lnet/selftest/timer.c | 2 +- drivers/staging/lustre/lustre/include/cl_object.h | 8 ++++---- drivers/staging/lustre/lustre/include/lustre_lib.h | 2 +- drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c | 2 +- drivers/staging/lustre/lustre/ldlm/ldlm_pool.c | 2 +- drivers/staging/lustre/lustre/libcfs/debug.c | 2 +- drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c | 9 --------- drivers/staging/lustre/lustre/libcfs/workitem.c | 3 ++- drivers/staging/lustre/lustre/llite/llite_capa.c | 2 +- drivers/staging/lustre/lustre/llite/llite_close.c | 2 +- drivers/staging/lustre/lustre/llite/statahead.c | 2 +- drivers/staging/lustre/lustre/lov/lov_cl_internal.h | 2 +- drivers/staging/lustre/lustre/obdclass/genops.c | 2 +- drivers/staging/lustre/lustre/osc/osc_cl_internal.h | 4 ++-- drivers/staging/lustre/lustre/ptlrpc/import.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/pinger.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c | 3 ++- drivers/staging/lustre/lustre/ptlrpc/sec_gc.c | 2 +- 21 files changed, 25 insertions(+), 36 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h index ae495a2ee4341..c78f71a235922 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h @@ -85,10 +85,6 @@ LL_PROC_PROTO(name) \ */ typedef struct proc_dir_entry proc_dir_entry_t; -/* - * Task struct - */ -typedef struct task_struct task_t; #define DECL_JOURNAL_DATA void *journal_info #define PUSH_JOURNAL do { \ journal_info = current->journal_info; \ diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c index 63a4258ac2615..086ca3d7241b2 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c @@ -1802,7 +1802,7 @@ kiblnd_recv (lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, int delayed, int kiblnd_thread_start(int (*fn)(void *arg), void *arg, char *name) { - task_t *task = kthread_run(fn, arg, name); + struct task_struct *task = kthread_run(fn, arg, name); if (IS_ERR(task)) return PTR_ERR(task); diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c index 617570439be6c..727f352e88609 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c @@ -1005,7 +1005,7 @@ ksocknal_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg) int ksocknal_thread_start(int (*fn)(void *arg), void *arg, char *name) { - task_t *task = kthread_run(fn, arg, name); + struct task_struct *task = kthread_run(fn, arg, name); if (IS_ERR(task)) return PTR_ERR(task); diff --git a/drivers/staging/lustre/lnet/selftest/timer.c b/drivers/staging/lustre/lnet/selftest/timer.c index 2c078550277b6..3bf4afb42ffe3 100644 --- a/drivers/staging/lustre/lnet/selftest/timer.c +++ b/drivers/staging/lustre/lnet/selftest/timer.c @@ -195,7 +195,7 @@ stt_timer_main (void *arg) int stt_start_timer_thread (void) { - task_t *task; + struct task_struct *task; LASSERT(!stt_data.stt_shuttingdown); diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h index 4a478504c45ee..edb40afe66f12 100644 --- a/drivers/staging/lustre/lustre/include/cl_object.h +++ b/drivers/staging/lustre/lustre/include/cl_object.h @@ -758,7 +758,7 @@ struct cl_page { /** * Debug information, the task is owning the page. */ - task_t *cp_task; + struct task_struct *cp_task; /** * Owning IO request in cl_page_state::CPS_PAGEOUT and * cl_page_state::CPS_PAGEIN states. This field is maintained only in @@ -1576,13 +1576,13 @@ struct cl_lock { * \see osc_lock_enqueue_wait(), lov_lock_cancel(), lov_sublock_wait(). */ struct mutex cll_guard; - task_t *cll_guarder; + struct task_struct *cll_guarder; int cll_depth; /** * the owner for INTRANSIT state */ - task_t *cll_intransit_owner; + struct task_struct *cll_intransit_owner; int cll_error; /** * Number of holds on a lock. A hold prevents a lock from being @@ -1869,7 +1869,7 @@ do { \ struct cl_page_list { unsigned pl_nr; struct list_head pl_pages; - task_t *pl_owner; + struct task_struct *pl_owner; }; /** diff --git a/drivers/staging/lustre/lustre/include/lustre_lib.h b/drivers/staging/lustre/lustre/include/lustre_lib.h index e77a74540da7b..5e11107d4c66d 100644 --- a/drivers/staging/lustre/lustre/include/lustre_lib.h +++ b/drivers/staging/lustre/lustre/include/lustre_lib.h @@ -96,7 +96,7 @@ void statfs_unpack(struct kstatfs *sfs, struct obd_statfs *osfs); /* l_lock.c */ struct lustre_lock { int l_depth; - task_t *l_owner; + struct task_struct *l_owner; struct semaphore l_sem; spinlock_t l_spin; }; diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c index 3ede1a444afd3..3916bda3004cf 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c @@ -796,7 +796,7 @@ static int ldlm_bl_thread_main(void *arg); static int ldlm_bl_thread_start(struct ldlm_bl_pool *blp) { struct ldlm_bl_thread_data bltd = { .bltd_blp = blp }; - task_t *task; + struct task_struct *task; init_completion(&bltd.bltd_comp); bltd.bltd_num = atomic_read(&blp->blp_num_threads); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c index 00ff0edd5a2b5..0593982f61c25 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c @@ -1339,7 +1339,7 @@ static int ldlm_pools_thread_main(void *arg) static int ldlm_pools_thread_start(void) { struct l_wait_info lwi = { 0 }; - task_t *task; + struct task_struct *task; if (ldlm_pools_thread != NULL) return -EALREADY; diff --git a/drivers/staging/lustre/lustre/libcfs/debug.c b/drivers/staging/lustre/lustre/libcfs/debug.c index cf93b6c6d906a..f7216de4cb4f1 100644 --- a/drivers/staging/lustre/lustre/libcfs/debug.c +++ b/drivers/staging/lustre/lustre/libcfs/debug.c @@ -361,7 +361,7 @@ int libcfs_debug_dumplog_thread(void *arg) void libcfs_debug_dumplog(void) { wait_queue_t wait; - task_t *dumper; + struct task_struct *dumper; /* we're being careful to ensure that the kernel thread is * able to set our state to running as it exits before we diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c index ec3d97664b1b8..ab1e731684724 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-debug.c @@ -170,12 +170,6 @@ void lbug_with_loc(struct libcfs_debug_msg_data *msgdata) schedule(); } -task_t *libcfs_current(void) -{ - CWARN("current task struct is %p\n", current); - return current; -} - static int panic_notifier(struct notifier_block *self, unsigned long unused1, void *unused2) { @@ -204,9 +198,6 @@ void libcfs_unregister_panic_notifier(void) atomic_notifier_chain_unregister(&panic_notifier_list, &libcfs_panic_notifier); } -EXPORT_SYMBOL(libcfs_current); - - EXPORT_SYMBOL(libcfs_run_upcall); EXPORT_SYMBOL(libcfs_run_lbug_upcall); EXPORT_SYMBOL(lbug_with_loc); diff --git a/drivers/staging/lustre/lustre/libcfs/workitem.c b/drivers/staging/lustre/lustre/libcfs/workitem.c index b533666c19000..462172d1a7569 100644 --- a/drivers/staging/lustre/lustre/libcfs/workitem.c +++ b/drivers/staging/lustre/lustre/libcfs/workitem.c @@ -376,7 +376,8 @@ cfs_wi_sched_create(char *name, struct cfs_cpt_table *cptab, rc = 0; while (nthrs > 0) { char name[16]; - task_t *task; + struct task_struct *task; + spin_lock(&cfs_wi_data.wi_glock); while (sched->ws_starting > 0) { spin_unlock(&cfs_wi_data.wi_glock); diff --git a/drivers/staging/lustre/lustre/llite/llite_capa.c b/drivers/staging/lustre/lustre/llite/llite_capa.c index 1d30181e3bcdc..edd512b20ee3a 100644 --- a/drivers/staging/lustre/lustre/llite/llite_capa.c +++ b/drivers/staging/lustre/lustre/llite/llite_capa.c @@ -289,7 +289,7 @@ void ll_capa_timer_callback(unsigned long unused) int ll_capa_thread_start(void) { - task_t *task; + struct task_struct *task; init_waitqueue_head(&ll_capa_thread.t_ctl_waitq); diff --git a/drivers/staging/lustre/lustre/llite/llite_close.c b/drivers/staging/lustre/lustre/llite/llite_close.c index 487ce6851d96b..1f5825c87a79c 100644 --- a/drivers/staging/lustre/lustre/llite/llite_close.c +++ b/drivers/staging/lustre/lustre/llite/llite_close.c @@ -362,7 +362,7 @@ static int ll_close_thread(void *arg) int ll_close_thread_start(struct ll_close_queue **lcq_ret) { struct ll_close_queue *lcq; - task_t *task; + struct task_struct *task; if (OBD_FAIL_CHECK(OBD_FAIL_LDLM_CLOSE_THREAD)) return -EINTR; diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c index 2daca2e90b113..8eaa38e91b992 100644 --- a/drivers/staging/lustre/lustre/llite/statahead.c +++ b/drivers/staging/lustre/lustre/llite/statahead.c @@ -1017,7 +1017,7 @@ static void ll_start_agl(struct dentry *parent, struct ll_statahead_info *sai) struct ptlrpc_thread *thread = &sai->sai_agl_thread; struct l_wait_info lwi = { 0 }; struct ll_inode_info *plli; - task_t *task; + struct task_struct *task; CDEBUG(D_READA, "start agl thread: [pid %d] [parent %.*s]\n", current_pid(), parent->d_name.len, parent->d_name.name); diff --git a/drivers/staging/lustre/lustre/lov/lov_cl_internal.h b/drivers/staging/lustre/lustre/lov/lov_cl_internal.h index a82dfeab59214..33d9ce68feddf 100644 --- a/drivers/staging/lustre/lustre/lov/lov_cl_internal.h +++ b/drivers/staging/lustre/lustre/lov/lov_cl_internal.h @@ -261,7 +261,7 @@ struct lov_object { * Thread that acquired lov_object::lo_type_guard in an exclusive * mode. */ - task_t *lo_owner; + struct task_struct *lo_owner; }; /** diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index bba1b35360d0f..68fe71c8a2a9d 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -1733,7 +1733,7 @@ static int obd_zombie_impexp_thread(void *unused) */ int obd_zombie_impexp_init(void) { - task_t *task; + struct task_struct *task; INIT_LIST_HEAD(&obd_zombie_imports); INIT_LIST_HEAD(&obd_zombie_exports); diff --git a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h index 158e8fff838f4..a3aa9b6596efc 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cl_internal.h +++ b/drivers/staging/lustre/lustre/osc/osc_cl_internal.h @@ -374,7 +374,7 @@ struct osc_page { /** * Thread that submitted this page for transfer. For debugging. */ - task_t *ops_submitter; + struct task_struct *ops_submitter; /** * Submit time - the time when the page is starting RPC. For debugging. */ @@ -660,7 +660,7 @@ struct osc_extent { /** lock covering this extent */ struct cl_lock *oe_osclock; /** terminator of this extent. Must be true if this extent is in IO. */ - task_t *oe_owner; + struct task_struct *oe_owner; /** return value of writeback. If somebody is waiting for this extent, * this value can be known by outside world. */ int oe_rc; diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c index 2cdbb4d909c97..5ca69aec72e15 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/import.c +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c @@ -1305,7 +1305,7 @@ int ptlrpc_import_recovery_state_machine(struct obd_import *imp) spin_unlock(&imp->imp_lock); { - task_t *task; + struct task_struct *task; /* bug 17802: XXX client_disconnect_export vs connect request * race. if client will evicted at this time, we start * invalidate thread without reference to import and import can diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c index a9206e955cd35..227a0ae9593bc 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c @@ -720,7 +720,7 @@ static int ping_evictor_main(void *arg) void ping_evictor_start(void) { - task_t *task; + struct task_struct *task; if (++pet_refcount > 1) return; diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c index 59c4f83af4468..fbdeff65d059d 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c +++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c @@ -630,7 +630,8 @@ int ptlrpcd_start(int index, int max, const char *name, struct ptlrpcd_ctl *pc) env = 1; { - task_t *task; + struct task_struct *task; + if (index >= 0) { rc = ptlrpcd_bind(index, max); if (rc < 0) diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c b/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c index 4c96a14a1bb61..d2eb20eb56dbc 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c @@ -217,7 +217,7 @@ static int sec_gc_main(void *arg) int sptlrpc_gc_init(void) { struct l_wait_info lwi = { 0 }; - task_t *task; + struct task_struct *task; mutex_init(&sec_gc_mutex); spin_lock_init(&sec_gc_list_lock); -- GitLab From 9733ac333081fb6eeb03d674e80bed5879f7ed1e Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sun, 4 Aug 2013 09:03:03 +0800 Subject: [PATCH 568/942] staging: lustre: remove strange journal macros into the one file using them This moves the PUSH_JOURNAL and friend macros into debug.c, as that's the only place they are used, so why are they even a macro? Cc: Peng Tao Cc: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../lustre/include/linux/libcfs/linux/linux-prim.h | 9 --------- drivers/staging/lustre/lustre/libcfs/debug.c | 8 +++++--- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h index c78f71a235922..383198acb1f47 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h @@ -85,13 +85,4 @@ LL_PROC_PROTO(name) \ */ typedef struct proc_dir_entry proc_dir_entry_t; -#define DECL_JOURNAL_DATA void *journal_info -#define PUSH_JOURNAL do { \ - journal_info = current->journal_info; \ - current->journal_info = NULL; \ - } while(0) -#define POP_JOURNAL do { \ - current->journal_info = journal_info; \ - } while(0) - #endif diff --git a/drivers/staging/lustre/lustre/libcfs/debug.c b/drivers/staging/lustre/lustre/libcfs/debug.c index f7216de4cb4f1..9b9c45116eee7 100644 --- a/drivers/staging/lustre/lustre/libcfs/debug.c +++ b/drivers/staging/lustre/lustre/libcfs/debug.c @@ -335,9 +335,10 @@ libcfs_debug_str2mask(int *mask, const char *str, int is_subsys) */ void libcfs_debug_dumplog_internal(void *arg) { - DECL_JOURNAL_DATA; + void *journal_info; - PUSH_JOURNAL; + journal_info = current->journal_info; + current->journal_info = NULL; if (strncmp(libcfs_debug_file_path_arr, "NONE", 4) != 0) { snprintf(debug_file_name, sizeof(debug_file_name) - 1, @@ -348,7 +349,8 @@ void libcfs_debug_dumplog_internal(void *arg) cfs_tracefile_dump_all_pages(debug_file_name); libcfs_run_debug_log_upcall(debug_file_name); } - POP_JOURNAL; + + current->journal_info = journal_info; } int libcfs_debug_dumplog_thread(void *arg) -- GitLab From b59fe845916db1812473c9310e490b6c375d6255 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sun, 4 Aug 2013 09:10:48 +0800 Subject: [PATCH 569/942] staging: lustre: remove proc_dir_entry_t typedef Use struct proc_dir_entry like the rest of the kernel does. Cc: Peng Tao Cc: Andreas Dilger Signed-off-by: Greg Kroah-Hartman --- .../include/linux/libcfs/linux/linux-prim.h | 5 ---- .../staging/lustre/lustre/fld/fld_internal.h | 2 +- .../staging/lustre/lustre/fld/fld_request.c | 2 +- .../lustre/lustre/include/lprocfs_status.h | 30 +++++++++---------- .../lustre/lustre/include/lustre_dlm.h | 2 +- .../lustre/lustre/include/lustre_fid.h | 4 +-- .../lustre/lustre/include/lustre_fld.h | 4 +-- .../lustre/lustre/include/lustre_net.h | 2 +- .../lustre/lustre/include/lustre_quota.h | 2 +- drivers/staging/lustre/lustre/include/obd.h | 12 ++++---- .../lustre/lustre/ldlm/ldlm_internal.h | 4 +-- .../staging/lustre/lustre/ldlm/ldlm_pool.c | 2 +- .../lustre/lustre/ldlm/ldlm_resource.c | 8 ++--- .../staging/lustre/lustre/llite/lproc_llite.c | 2 +- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 2 +- drivers/staging/lustre/lustre/lov/lov_obd.c | 6 ++-- .../lustre/lustre/obdclass/lprocfs_status.c | 8 ++--- .../staging/lustre/lustre/ptlrpc/service.c | 2 +- 18 files changed, 47 insertions(+), 52 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h index 383198acb1f47..1ec4ca1a6e32f 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-prim.h @@ -80,9 +80,4 @@ LL_PROC_PROTO(name) \ __##name); \ } -/* - * Proc file system APIs - */ -typedef struct proc_dir_entry proc_dir_entry_t; - #endif diff --git a/drivers/staging/lustre/lustre/fld/fld_internal.h b/drivers/staging/lustre/lustre/fld/fld_internal.h index 6e7ca9efe3371..56686b138ac15 100644 --- a/drivers/staging/lustre/lustre/fld/fld_internal.h +++ b/drivers/staging/lustre/lustre/fld/fld_internal.h @@ -190,5 +190,5 @@ fld_target_name(struct lu_fld_target *tar) return (const char *)tar->ft_exp->exp_obd->obd_name; } -extern proc_dir_entry_t *fld_type_proc_dir; +extern struct proc_dir_entry *fld_type_proc_dir; #endif /* __FLD_INTERNAL_H */ diff --git a/drivers/staging/lustre/lustre/fld/fld_request.c b/drivers/staging/lustre/lustre/fld/fld_request.c index a08867ab63bf6..078e98bda6841 100644 --- a/drivers/staging/lustre/lustre/fld/fld_request.c +++ b/drivers/staging/lustre/lustre/fld/fld_request.c @@ -277,7 +277,7 @@ int fld_client_del_target(struct lu_client_fld *fld, __u64 idx) EXPORT_SYMBOL(fld_client_del_target); #ifdef LPROCFS -proc_dir_entry_t *fld_type_proc_dir = NULL; +struct proc_dir_entry *fld_type_proc_dir = NULL; static int fld_client_proc_init(struct lu_client_fld *fld) { diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index d7f1be96189b3..56b05728f611d 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -345,7 +345,7 @@ enum { #define EXTRA_FIRST_OPC LDLM_GLIMPSE_ENQUEUE /* class_obd.c */ -extern proc_dir_entry_t *proc_lustre_root; +extern struct proc_dir_entry *proc_lustre_root; struct obd_device; struct obd_histogram; @@ -550,11 +550,11 @@ extern void lprocfs_free_md_stats(struct obd_device *obddev); struct obd_export; struct nid_stat; extern int lprocfs_add_clear_entry(struct obd_device * obd, - proc_dir_entry_t *entry); + struct proc_dir_entry *entry); extern int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *peer_nid, int *newnid); extern int lprocfs_exp_cleanup(struct obd_export *exp); -extern proc_dir_entry_t *lprocfs_add_simple(struct proc_dir_entry *root, +extern struct proc_dir_entry *lprocfs_add_simple(struct proc_dir_entry *root, char *name, void *data, struct file_operations *fops); @@ -567,27 +567,27 @@ lprocfs_nid_stats_clear_write(struct file *file, const char *buffer, unsigned long count, void *data); extern int lprocfs_nid_stats_clear_read(struct seq_file *m, void *data); -extern int lprocfs_register_stats(proc_dir_entry_t *root, const char *name, +extern int lprocfs_register_stats(struct proc_dir_entry *root, const char *name, struct lprocfs_stats *stats); /* lprocfs_status.c */ -extern int lprocfs_add_vars(proc_dir_entry_t *root, +extern int lprocfs_add_vars(struct proc_dir_entry *root, struct lprocfs_vars *var, void *data); -extern proc_dir_entry_t *lprocfs_register(const char *name, - proc_dir_entry_t *parent, +extern struct proc_dir_entry *lprocfs_register(const char *name, + struct proc_dir_entry *parent, struct lprocfs_vars *list, void *data); -extern void lprocfs_remove(proc_dir_entry_t **root); +extern void lprocfs_remove(struct proc_dir_entry **root); extern void lprocfs_remove_proc_entry(const char *name, struct proc_dir_entry *parent); extern int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list); extern int lprocfs_obd_cleanup(struct obd_device *obd); -extern int lprocfs_seq_create(proc_dir_entry_t *parent, const char *name, +extern int lprocfs_seq_create(struct proc_dir_entry *parent, const char *name, umode_t mode, const struct file_operations *seq_fops, void *data); @@ -838,7 +838,7 @@ static inline void lprocfs_clear_stats(struct lprocfs_stats *stats) { return; } static inline void lprocfs_free_stats(struct lprocfs_stats **stats) { return; } -static inline int lprocfs_register_stats(proc_dir_entry_t *root, +static inline int lprocfs_register_stats(struct proc_dir_entry *root, const char *name, struct lprocfs_stats *stats) { return 0; } @@ -869,7 +869,7 @@ static inline int lprocfs_exp_setup(struct obd_export *exp,lnet_nid_t *peer_nid, { return 0; } static inline int lprocfs_exp_cleanup(struct obd_export *exp) { return 0; } -static inline proc_dir_entry_t * +static inline struct proc_dir_entry * lprocfs_add_simple(struct proc_dir_entry *root, char *name, void *data, struct file_operations *fops) {return 0; } @@ -887,15 +887,15 @@ static inline int lprocfs_nid_stats_clear_read(struct seq_file *m, void *data) { return 0; } -static inline proc_dir_entry_t * -lprocfs_register(const char *name, proc_dir_entry_t *parent, +static inline struct proc_dir_entry * +lprocfs_register(const char *name, struct proc_dir_entry *parent, struct lprocfs_vars *list, void *data) { return NULL; } -static inline int lprocfs_add_vars(proc_dir_entry_t *root, +static inline int lprocfs_add_vars(struct proc_dir_entry *root, struct lprocfs_vars *var, void *data) { return 0; } -static inline void lprocfs_remove(proc_dir_entry_t **root) +static inline void lprocfs_remove(struct proc_dir_entry **root) { return; } static inline void lprocfs_remove_proc_entry(const char *name, struct proc_dir_entry *parent) diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h index 66db562c5caad..7020d9cd9eb2b 100644 --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h @@ -235,7 +235,7 @@ struct ldlm_pool_ops { */ struct ldlm_pool { /** Pool proc directory. */ - proc_dir_entry_t *pl_proc_dir; + struct proc_dir_entry *pl_proc_dir; /** Pool name, must be long enough to hold compound proc entry name. */ char pl_name[100]; /** Lock for protecting SLV/CLV updates. */ diff --git a/drivers/staging/lustre/lustre/include/lustre_fid.h b/drivers/staging/lustre/lustre/include/lustre_fid.h index 655119eda9a1c..d9d5814e318d9 100644 --- a/drivers/staging/lustre/lustre/include/lustre_fid.h +++ b/drivers/staging/lustre/lustre/include/lustre_fid.h @@ -346,7 +346,7 @@ struct lu_client_seq { struct lu_seq_range lcs_space; /* Seq related proc */ - proc_dir_entry_t *lcs_proc_dir; + struct proc_dir_entry *lcs_proc_dir; /* This holds last allocated fid in last obtained seq */ struct lu_fid lcs_fid; @@ -393,7 +393,7 @@ struct lu_server_seq { struct dt_object *lss_obj; /* Seq related proc */ - proc_dir_entry_t *lss_proc_dir; + struct proc_dir_entry *lss_proc_dir; /* LUSTRE_SEQ_SERVER or LUSTRE_SEQ_CONTROLLER */ enum lu_mgr_type lss_type; diff --git a/drivers/staging/lustre/lustre/include/lustre_fld.h b/drivers/staging/lustre/lustre/include/lustre_fld.h index 94b697dbe713a..550fff587458a 100644 --- a/drivers/staging/lustre/lustre/include/lustre_fld.h +++ b/drivers/staging/lustre/lustre/include/lustre_fld.h @@ -72,7 +72,7 @@ struct lu_fld_target { struct lu_server_fld { /** * Fld dir proc entry. */ - proc_dir_entry_t *lsf_proc_dir; + struct proc_dir_entry *lsf_proc_dir; /** * /fld file object device */ @@ -100,7 +100,7 @@ struct lu_server_fld { struct lu_client_fld { /** * Client side proc entry. */ - proc_dir_entry_t *lcf_proc_dir; + struct proc_dir_entry *lcf_proc_dir; /** * List of exports client FLD knows about. */ diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h index ce41bf9cc4651..e947002fae040 100644 --- a/drivers/staging/lustre/lustre/include/lustre_net.h +++ b/drivers/staging/lustre/lustre/include/lustre_net.h @@ -2489,7 +2489,7 @@ struct ptlrpc_service { /** limit of threads number for each partition */ int srv_nthrs_cpt_limit; /** Root of /proc dir tree for this service */ - proc_dir_entry_t *srv_procroot; + struct proc_dir_entry *srv_procroot; /** Pointer to statistic data for this service */ struct lprocfs_stats *srv_stats; /** # hp per lp reqs to handle */ diff --git a/drivers/staging/lustre/lustre/include/lustre_quota.h b/drivers/staging/lustre/lustre/include/lustre_quota.h index 1c3041f500498..71b5d97e03437 100644 --- a/drivers/staging/lustre/lustre/include/lustre_quota.h +++ b/drivers/staging/lustre/lustre/include/lustre_quota.h @@ -168,7 +168,7 @@ struct qsd_instance; * enforcement. Arguments are documented where each function is defined. */ struct qsd_instance *qsd_init(const struct lu_env *, char *, struct dt_device *, - proc_dir_entry_t *); + struct proc_dir_entry *); int qsd_prepare(const struct lu_env *, struct qsd_instance *); int qsd_start(const struct lu_env *, struct qsd_instance *); void qsd_fini(const struct lu_env *, struct qsd_instance *); diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index 5cf687f1557b4..a6122559d55d2 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -238,7 +238,7 @@ struct obd_type { struct list_head typ_chain; struct obd_ops *typ_dt_ops; struct md_ops *typ_md_ops; - proc_dir_entry_t *typ_procroot; + struct proc_dir_entry *typ_procroot; char *typ_name; int typ_refcnt; struct lu_device_type *typ_lu; @@ -537,7 +537,7 @@ struct pool_desc { struct lov_qos_rr pool_rr; /* round robin qos */ struct hlist_node pool_hash; /* access by poolname */ struct list_head pool_list; /* serial access */ - proc_dir_entry_t *pool_proc_entry; /* file in /proc */ + struct proc_dir_entry *pool_proc_entry; /* file in /proc */ struct obd_device *pool_lobd; /* obd of the lov/lod to which * this pool belongs */ }; @@ -558,7 +558,7 @@ struct lov_obd { int lov_pool_count; cfs_hash_t *lov_pools_hash_body; /* used for key access */ struct list_head lov_pool_list; /* used for sequential access */ - proc_dir_entry_t *lov_pool_proc_entry; + struct proc_dir_entry *lov_pool_proc_entry; enum lustre_sec_part lov_sp_me; /* Cached LRU pages from upper layer */ @@ -931,10 +931,10 @@ struct obd_device { unsigned int md_cntr_base; struct lprocfs_stats *md_stats; - proc_dir_entry_t *obd_proc_entry; + struct proc_dir_entry *obd_proc_entry; void *obd_proc_private; /* type private PDEs */ - proc_dir_entry_t *obd_proc_exports_entry; - proc_dir_entry_t *obd_svc_procroot; + struct proc_dir_entry *obd_proc_exports_entry; + struct proc_dir_entry *obd_svc_procroot; struct lprocfs_stats *obd_svc_stats; atomic_t obd_evict_inprogress; wait_queue_head_t obd_evict_inprogress_waitq; diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h index bf6f00341a768..8cd79633dea31 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h @@ -192,8 +192,8 @@ void ldlm_destroy_flock_export(struct obd_export *exp); void l_check_ns_lock(struct ldlm_namespace *ns); void l_check_no_ns_lock(struct ldlm_namespace *ns); -extern proc_dir_entry_t *ldlm_svc_proc_dir; -extern proc_dir_entry_t *ldlm_type_proc_dir; +extern struct proc_dir_entry *ldlm_svc_proc_dir; +extern struct proc_dir_entry *ldlm_type_proc_dir; struct ldlm_state { struct ptlrpc_service *ldlm_cb_service; diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c index 0593982f61c25..454027d68d546 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c @@ -142,7 +142,7 @@ */ #define LDLM_POOL_SLV_SHIFT (10) -extern proc_dir_entry_t *ldlm_ns_proc_dir; +extern struct proc_dir_entry *ldlm_ns_proc_dir; static inline __u64 dru(__u64 val, __u32 shift, int round_up) { diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index 78327cf400724..208751a154b3c 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -62,9 +62,9 @@ LIST_HEAD(ldlm_cli_active_namespace_list); /* Client namespaces that don't have any locks in them */ LIST_HEAD(ldlm_cli_inactive_namespace_list); -proc_dir_entry_t *ldlm_type_proc_dir = NULL; -proc_dir_entry_t *ldlm_ns_proc_dir = NULL; -proc_dir_entry_t *ldlm_svc_proc_dir = NULL; +struct proc_dir_entry *ldlm_type_proc_dir = NULL; +struct proc_dir_entry *ldlm_ns_proc_dir = NULL; +struct proc_dir_entry *ldlm_svc_proc_dir = NULL; extern unsigned int ldlm_cancel_unused_locks_before_replay; @@ -329,7 +329,7 @@ int ldlm_namespace_proc_register(struct ldlm_namespace *ns) { struct lprocfs_vars lock_vars[2]; char lock_name[MAX_STRING_SIZE + 1]; - proc_dir_entry_t *ns_pde; + struct proc_dir_entry *ns_pde; LASSERT(ns != NULL); LASSERT(ns->ns_rs_hash != NULL); diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index db349f68e32e6..d4d3c17547cae 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -851,7 +851,7 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent, struct lustre_sb_info *lsi = s2lsi(sb); struct ll_sb_info *sbi = ll_s2sbi(sb); struct obd_device *obd; - proc_dir_entry_t *dir; + struct proc_dir_entry *dir; char name[MAX_STRING_SIZE + 1], *ptr; int err, id, len, rc; diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index bd2575aed08d9..c2866046fc382 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -673,7 +673,7 @@ static int lmv_disconnect(struct obd_export *exp) } if (obd->obd_proc_private) - lprocfs_remove((proc_dir_entry_t **)&obd->obd_proc_private); + lprocfs_remove((struct proc_dir_entry **)&obd->obd_proc_private); else CERROR("/proc/fs/lustre/%s/%s/target_obds missing\n", obd->obd_type->typ_name, obd->obd_name); diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index 71f5ef16e83da..0b47aba1332a1 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -131,7 +131,7 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate, struct obd_device *tgt_obd; static struct obd_uuid lov_osc_uuid = { "LOV_OSC_UUID" }; struct obd_import *imp; - proc_dir_entry_t *lov_proc_dir; + struct proc_dir_entry *lov_proc_dir; int rc; if (!lov->lov_tgts[index]) @@ -193,7 +193,7 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate, lov_proc_dir = obd->obd_proc_private; if (lov_proc_dir) { struct obd_device *osc_obd = lov->lov_tgts[index]->ltd_exp->exp_obd; - proc_dir_entry_t *osc_symlink; + struct proc_dir_entry *osc_symlink; LASSERT(osc_obd != NULL); LASSERT(osc_obd->obd_magic == OBD_DEVICE_MAGIC); @@ -273,7 +273,7 @@ static int lov_connect(const struct lu_env *env, static int lov_disconnect_obd(struct obd_device *obd, struct lov_tgt_desc *tgt) { - proc_dir_entry_t *lov_proc_dir; + struct proc_dir_entry *lov_proc_dir; struct lov_obd *lov = &obd->u.lov; struct obd_device *osc_obd; int rc; diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index 6d9f25291757c..a95f60a4f90e7 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -68,11 +68,11 @@ EXPORT_SYMBOL(lprocfs_seq_release); /* lprocfs API calls */ -proc_dir_entry_t *lprocfs_add_simple(struct proc_dir_entry *root, +struct proc_dir_entry *lprocfs_add_simple(struct proc_dir_entry *root, char *name, void *data, struct file_operations *fops) { - proc_dir_entry_t *proc; + struct proc_dir_entry *proc; umode_t mode = 0; if (root == NULL || name == NULL || fops == NULL) @@ -1537,7 +1537,7 @@ int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int *newnid) { struct nid_stat *new_stat, *old_stat; struct obd_device *obd = NULL; - proc_dir_entry_t *entry; + struct proc_dir_entry *entry; char *buffer = NULL; int rc = 0; @@ -1899,7 +1899,7 @@ char *lprocfs_find_named_value(const char *buffer, const char *name, } EXPORT_SYMBOL(lprocfs_find_named_value); -int lprocfs_seq_create(proc_dir_entry_t *parent, +int lprocfs_seq_create(struct proc_dir_entry *parent, const char *name, umode_t mode, const struct file_operations *seq_fops, diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index 4f0118cc75467..ac8b5fd2300b5 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -683,7 +683,7 @@ ptlrpc_service_part_init(struct ptlrpc_service *svc, */ struct ptlrpc_service * ptlrpc_register_service(struct ptlrpc_service_conf *conf, - proc_dir_entry_t *proc_entry) + struct proc_dir_entry *proc_entry) { struct ptlrpc_service_cpt_conf *cconf = &conf->psc_cpt; struct ptlrpc_service *service; -- GitLab From 7561c301411a0cf9793ec6e9706094e01d66f48e Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Sat, 27 Jul 2013 16:31:00 +0100 Subject: [PATCH 570/942] staging:iio:hmc5843: Drop I2C detection code I2C is generally not probed for devices other than those commonly found on architectures where device treeor board files are not used. Note also that this implementation does not fill in the name field of the i2c_board_info structure as the documentation states it must. Hence it is unlikely anyone is actually using it. Signed-off-by: Peter Meerwald Cc: Shubhrajyoti Datta Signed-off-by: Jonathan Cameron --- drivers/staging/iio/magnetometer/hmc5843.c | 33 ---------------------- 1 file changed, 33 deletions(-) diff --git a/drivers/staging/iio/magnetometer/hmc5843.c b/drivers/staging/iio/magnetometer/hmc5843.c index 86c6bf9d5dd89..e5999d4947bff 100644 --- a/drivers/staging/iio/magnetometer/hmc5843.c +++ b/drivers/staging/iio/magnetometer/hmc5843.c @@ -52,14 +52,6 @@ enum hmc5843_ids { HMC5883L_ID, }; -/* - * Beware: identification of the HMC5883 is still "H43"; - * I2C address is also unchanged - */ -#define HMC5843_ID_REG_LENGTH 0x03 -#define HMC5843_ID_STRING "H43" -#define HMC5843_I2C_ADDRESS 0x1E - /* * Range gain settings in (+-)Ga * Beware: HMC5843 and HMC5883 have different recommended sensor field @@ -185,10 +177,6 @@ static const char * const hmc5883_regval_to_sample_freq[] = { "0.75", "1.5", "3", "7.5", "15", "30", "75", }; -/* Addresses to scan: 0x1E */ -static const unsigned short normal_i2c[] = { HMC5843_I2C_ADDRESS, - I2C_CLIENT_END }; - /* Describe chip variants */ struct hmc5843_chip_info { const struct iio_chan_spec *channels; @@ -621,25 +609,6 @@ static const struct hmc5843_chip_info hmc5843_chip_info_tbl[] = { }, }; -static int hmc5843_detect(struct i2c_client *client, - struct i2c_board_info *info) -{ - unsigned char id_str[HMC5843_ID_REG_LENGTH]; - - if (client->addr != HMC5843_I2C_ADDRESS) - return -ENODEV; - - if (i2c_smbus_read_i2c_block_data(client, HMC5843_ID_REG_A, - HMC5843_ID_REG_LENGTH, id_str) - != HMC5843_ID_REG_LENGTH) - return -ENODEV; - - if (0 != strncmp(id_str, HMC5843_ID_STRING, HMC5843_ID_REG_LENGTH)) - return -ENODEV; - - return 0; -} - /* Called when we have found a new HMC58X3 */ static void hmc5843_init_client(struct i2c_client *client, const struct i2c_device_id *id) @@ -756,8 +725,6 @@ static struct i2c_driver hmc5843_driver = { .id_table = hmc5843_id, .probe = hmc5843_probe, .remove = hmc5843_remove, - .detect = hmc5843_detect, - .address_list = normal_i2c, }; module_i2c_driver(hmc5843_driver); -- GitLab From a34778f3a7cf20ffb7f7f93fd96a9c456b2a96c6 Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Sat, 27 Jul 2013 16:31:00 +0100 Subject: [PATCH 571/942] staging:iio:hmc5843: Remove id register #defines, not used anymore Signed-off-by: Peter Meerwald Cc: Shubhrajyoti Datta Signed-off-by: Jonathan Cameron --- drivers/staging/iio/magnetometer/hmc5843.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/iio/magnetometer/hmc5843.c b/drivers/staging/iio/magnetometer/hmc5843.c index e5999d4947bff..c281342899ebc 100644 --- a/drivers/staging/iio/magnetometer/hmc5843.c +++ b/drivers/staging/iio/magnetometer/hmc5843.c @@ -42,9 +42,6 @@ #define HMC5883_DATA_OUT_Y_MSB_REG 0x07 #define HMC5883_DATA_OUT_Y_LSB_REG 0x08 #define HMC5843_STATUS_REG 0x09 -#define HMC5843_ID_REG_A 0x0A -#define HMC5843_ID_REG_B 0x0B -#define HMC5843_ID_REG_C 0x0C enum hmc5843_ids { HMC5843_ID, -- GitLab From 4dedf31cd1c28c732a17ddeb9cfdf90b5b860faa Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Sat, 27 Jul 2013 16:31:00 +0100 Subject: [PATCH 572/942] staging:iio:hmc5843: Implement timeout in read function avoid polling data ready bit forever; msleep() may be too long for high sampling frequencies but the driver interface does not support buffering Signed-off-by: Peter Meerwald Cc: Shubhrajyoti Datta Signed-off-by: Jonathan Cameron --- drivers/staging/iio/magnetometer/hmc5843.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/staging/iio/magnetometer/hmc5843.c b/drivers/staging/iio/magnetometer/hmc5843.c index c281342899ebc..79117ad978d10 100644 --- a/drivers/staging/iio/magnetometer/hmc5843.c +++ b/drivers/staging/iio/magnetometer/hmc5843.c @@ -26,6 +26,7 @@ #include #include #include +#include #define HMC5843_CONFIG_REG_A 0x00 #define HMC5843_CONFIG_REG_B 0x01 @@ -210,11 +211,22 @@ static int hmc5843_read_measurement(struct iio_dev *indio_dev, struct i2c_client *client = to_i2c_client(indio_dev->dev.parent); struct hmc5843_data *data = iio_priv(indio_dev); s32 result; + int tries = 150; mutex_lock(&data->lock); - result = i2c_smbus_read_byte_data(client, HMC5843_STATUS_REG); - while (!(result & HMC5843_DATA_READY)) - result = i2c_smbus_read_byte_data(client, HMC5843_STATUS_REG); + while (tries-- > 0) { + result = i2c_smbus_read_byte_data(client, + HMC5843_STATUS_REG); + if (result & HMC5843_DATA_READY) + break; + msleep(20); + } + + if (tries < 0) { + dev_err(&client->dev, "data not ready\n"); + mutex_unlock(&data->lock); + return -EIO; + } result = i2c_smbus_read_word_data(client, address); mutex_unlock(&data->lock); -- GitLab From e050b35b0983c81dd2e8dee6b9fbe07af813f55d Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Sat, 27 Jul 2013 16:31:00 +0100 Subject: [PATCH 573/942] staging:iio:hmc5843: 'add' is a poor abbreviation for address Signed-off-by: Peter Meerwald Cc: Shubhrajyoti Datta Signed-off-by: Jonathan Cameron --- drivers/staging/iio/magnetometer/hmc5843.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/iio/magnetometer/hmc5843.c b/drivers/staging/iio/magnetometer/hmc5843.c index 79117ad978d10..465dc2a93f280 100644 --- a/drivers/staging/iio/magnetometer/hmc5843.c +++ b/drivers/staging/iio/magnetometer/hmc5843.c @@ -556,14 +556,14 @@ static int hmc5843_read_raw(struct iio_dev *indio_dev, return -EINVAL; } -#define HMC5843_CHANNEL(axis, add) \ +#define HMC5843_CHANNEL(axis, addr) \ { \ .type = IIO_MAGN, \ .modified = 1, \ .channel2 = IIO_MOD_##axis, \ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ - .address = add \ + .address = addr \ } static const struct iio_chan_spec hmc5843_channels[] = { -- GitLab From f9e1170967b87c3453d00257d9cc2714164998fe Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Sat, 27 Jul 2013 16:31:00 +0100 Subject: [PATCH 574/942] staging:iio:hmc5843: Device has 3 channels, no need to store separately Signed-off-by: Peter Meerwald Cc: Shubhrajyoti Datta Signed-off-by: Jonathan Cameron --- drivers/staging/iio/magnetometer/hmc5843.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/staging/iio/magnetometer/hmc5843.c b/drivers/staging/iio/magnetometer/hmc5843.c index 465dc2a93f280..042467dbe1d9f 100644 --- a/drivers/staging/iio/magnetometer/hmc5843.c +++ b/drivers/staging/iio/magnetometer/hmc5843.c @@ -178,7 +178,6 @@ static const char * const hmc5883_regval_to_sample_freq[] = { /* Describe chip variants */ struct hmc5843_chip_info { const struct iio_chan_spec *channels; - int num_channels; const char * const *regval_to_sample_freq; const int *regval_to_input_field_mga; const int *regval_to_nanoscale; @@ -594,7 +593,6 @@ static const struct attribute_group hmc5843_group = { static const struct hmc5843_chip_info hmc5843_chip_info_tbl[] = { [HMC5843_ID] = { .channels = hmc5843_channels, - .num_channels = ARRAY_SIZE(hmc5843_channels), .regval_to_sample_freq = hmc5843_regval_to_sample_freq, .regval_to_input_field_mga = hmc5843_regval_to_input_field_mga, @@ -602,7 +600,6 @@ static const struct hmc5843_chip_info hmc5843_chip_info_tbl[] = { }, [HMC5883_ID] = { .channels = hmc5883_channels, - .num_channels = ARRAY_SIZE(hmc5883_channels), .regval_to_sample_freq = hmc5883_regval_to_sample_freq, .regval_to_input_field_mga = hmc5883_regval_to_input_field_mga, @@ -610,7 +607,6 @@ static const struct hmc5843_chip_info hmc5843_chip_info_tbl[] = { }, [HMC5883L_ID] = { .channels = hmc5883_channels, - .num_channels = ARRAY_SIZE(hmc5883_channels), .regval_to_sample_freq = hmc5883_regval_to_sample_freq, .regval_to_input_field_mga = hmc5883l_regval_to_input_field_mga, @@ -627,7 +623,7 @@ static void hmc5843_init_client(struct i2c_client *client, data->variant = &hmc5843_chip_info_tbl[id->driver_data]; indio_dev->channels = data->variant->channels; - indio_dev->num_channels = data->variant->num_channels; + indio_dev->num_channels = 3; hmc5843_set_meas_conf(client, data->meas_conf); hmc5843_set_rate(client, data->rate); hmc5843_configure(client, data->operating_mode); -- GitLab From f70d6694ed48363c422595faacaa459c2e256982 Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Sat, 27 Jul 2013 16:31:00 +0100 Subject: [PATCH 575/942] staging:iio:hmc5843: Drop unneeded #includes Signed-off-by: Peter Meerwald Signed-off-by: Jonathan Cameron --- drivers/staging/iio/magnetometer/hmc5843.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/iio/magnetometer/hmc5843.c b/drivers/staging/iio/magnetometer/hmc5843.c index 042467dbe1d9f..3204593c90d43 100644 --- a/drivers/staging/iio/magnetometer/hmc5843.c +++ b/drivers/staging/iio/magnetometer/hmc5843.c @@ -20,10 +20,7 @@ */ #include -#include #include -#include -#include #include #include #include -- GitLab From cd6fe06588423ff4cca85c85c4402027b04dccf1 Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Sat, 27 Jul 2013 16:31:00 +0100 Subject: [PATCH 576/942] staging:iio:hmc5843: Use i2c_smbus_read_word_swapped() Signed-off-by: Peter Meerwald Signed-off-by: Jonathan Cameron --- drivers/staging/iio/magnetometer/hmc5843.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/iio/magnetometer/hmc5843.c b/drivers/staging/iio/magnetometer/hmc5843.c index 3204593c90d43..d2748c329eae6 100644 --- a/drivers/staging/iio/magnetometer/hmc5843.c +++ b/drivers/staging/iio/magnetometer/hmc5843.c @@ -224,12 +224,12 @@ static int hmc5843_read_measurement(struct iio_dev *indio_dev, return -EIO; } - result = i2c_smbus_read_word_data(client, address); + result = i2c_smbus_read_word_swapped(client, address); mutex_unlock(&data->lock); if (result < 0) return -EINVAL; - *val = (s16)swab16((u16)result); + *val = result; return IIO_VAL_INT; } -- GitLab From 6a48a9d5d7b6cedf9998d45105463a03cb15af13 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 5 Aug 2013 14:21:10 +0800 Subject: [PATCH 577/942] Revert "iio: add configuration option for debug support" This reverts commit 98a5e9e99d05e9b6a14778b85631b55e8e349990. IIO, like the rest of the kernel, should rely on dynamic debugging, not have a special config option for it. That way, no user has to rebuild their kernel to have debug messages, which is a good thing, let's not revert back to the bad old days of the 2000's. Cc: Otavio Salvador Cc: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/iio/Kconfig | 7 ------- drivers/iio/Makefile | 2 -- 2 files changed, 9 deletions(-) diff --git a/drivers/iio/Kconfig b/drivers/iio/Kconfig index b682f6f545017..524380c9ae6cb 100644 --- a/drivers/iio/Kconfig +++ b/drivers/iio/Kconfig @@ -12,13 +12,6 @@ menuconfig IIO if IIO -config IIO_DEBUG - boolean "Debug support for Industrial I/O" - depends on DEBUG_KERNEL - help - Say "yes" to enable debug messaging (like dev_dbg and pr_debug) - support in Industrial I/O subsystem and drivers. - config IIO_BUFFER bool "Enable buffer support within IIO" help diff --git a/drivers/iio/Makefile b/drivers/iio/Makefile index 6e43e5b8d4ed2..7a3866c2d2a14 100644 --- a/drivers/iio/Makefile +++ b/drivers/iio/Makefile @@ -2,8 +2,6 @@ # Makefile for the industrial I/O core. # -ccflags-$(CONFIG_IIO_DEBUG) := -DDEBUG - obj-$(CONFIG_IIO) += industrialio.o industrialio-y := industrialio-core.o industrialio-event.o inkern.o industrialio-$(CONFIG_IIO_BUFFER) += industrialio-buffer.o -- GitLab From 98f62b7a082e1e9eb762c7329a704316f6e07698 Mon Sep 17 00:00:00 2001 From: Jie Liu Date: Sun, 4 Aug 2013 20:06:20 +0800 Subject: [PATCH 578/942] staging/zcache: Fix memory leak while dropping an o2net_sock_container object Free sc->sc_page when releasing a struct o2net_sock_container object to avoid memory leaks. This issue has been fixed by Younger Liu for OCFS2, so I sync that patch to zcache as we share the same network code base. Cc: Younger Liu Cc: Bob Liu Cc: Greg Kroah-Hartman Cc: Konrad Rzeszutek Wilk Signed-off-by: Jie Liu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/zcache/ramster/tcp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/staging/zcache/ramster/tcp.c b/drivers/staging/zcache/ramster/tcp.c index f6e1e5209d885..f74881e093425 100644 --- a/drivers/staging/zcache/ramster/tcp.c +++ b/drivers/staging/zcache/ramster/tcp.c @@ -403,6 +403,9 @@ static void sc_kref_release(struct kref *kref) sc->sc_node = NULL; r2net_debug_del_sc(sc); + + if (sc->sc_page) + __free_page(sc->sc_page); kfree(sc); } -- GitLab From 5cf9d2577f22eebf2263e6cd91b942b7016845d2 Mon Sep 17 00:00:00 2001 From: Rupesh Gujare Date: Mon, 5 Aug 2013 12:14:04 +0100 Subject: [PATCH 579/942] staging: ozwpan: Fix build warning. This patch fixes following build warning. drivers/built-in.o: In function `oz_hcd_heartbeat': >> (.text+0x30aadd): undefined reference to `__divdi3' drivers/built-in.o: In function `oz_hcd_heartbeat': >> (.text+0x30ac85): undefined reference to `__divdi3' Reported-by: Randy Dunlap Signed-off-by: Rupesh Gujare Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozhcd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c index f81a0c53b39be..ed63868e60274 100644 --- a/drivers/staging/ozwpan/ozhcd.c +++ b/drivers/staging/ozwpan/ozhcd.c @@ -1042,7 +1042,7 @@ int oz_hcd_heartbeat(void *hport) if (ep->credit < 0) continue; delta = timespec_sub(ts, ep->timestamp); - ep->credit += timespec_to_ns(&delta) / NSEC_PER_MSEC; + ep->credit += div_u64(timespec_to_ns(&delta), NSEC_PER_MSEC); if (ep->credit > ep->credit_ceiling) ep->credit = ep->credit_ceiling; ep->timestamp = ts; @@ -1086,7 +1086,7 @@ int oz_hcd_heartbeat(void *hport) continue; } delta = timespec_sub(ts, ep->timestamp); - ep->credit += timespec_to_ns(&delta) / NSEC_PER_MSEC; + ep->credit += div_u64(timespec_to_ns(&delta), NSEC_PER_MSEC); ep->timestamp = ts; while (!list_empty(&ep->urb_list)) { struct oz_urb_link *urbl = -- GitLab From b2271b5bdf1fd8b7d5442e2452e9242b88c56e8f Mon Sep 17 00:00:00 2001 From: Rupesh Gujare Date: Mon, 5 Aug 2013 12:28:33 +0100 Subject: [PATCH 580/942] staging: ozwpan: Fix farewell report. This patch fix following issues reported by Dan:- 1) There is no check limiting the size to 32 and it could be up to 253 bytes. 2) Use defines instead of magic numbers. 3) The oz_farewell struct is supposed to be a variable length struct but the variable part is put in the middle. It doesn't make any sense to put the length of the variable size array after then end of the array because we can never find it again! Put the variable size array at the end. Make it a zero length array. u8 len; u8 report[0]; 4) In oz_add_farewell() we do this: f = kmalloc(sizeof(struct oz_farewell) + len - 1, GFP_ATOMIC); The "- 1" refers to sizeof(f->report) but because it was a magic number then it was missed when the sizeof(f->report) changed. 5) In [patch 6/6] we set the ->len member. But because it is at the end of a variable length array with no limit check the remote attacker can just rewrite it using the memcpy() on the next line. Reported-by: Dan Carpenter Signed-off-by: Rupesh Gujare Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozpd.h | 2 +- drivers/staging/ozwpan/ozproto.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/ozwpan/ozpd.h b/drivers/staging/ozwpan/ozpd.h index 57e98c897711e..996ef65ed3156 100644 --- a/drivers/staging/ozwpan/ozpd.h +++ b/drivers/staging/ozwpan/ozpd.h @@ -48,8 +48,8 @@ struct oz_farewell { struct list_head link; u8 ep_num; u8 index; - u8 report[32]; u8 len; + u8 report[0]; }; /* Data structure that holds information on a specific peripheral device (PD). diff --git a/drivers/staging/ozwpan/ozproto.c b/drivers/staging/ozwpan/ozproto.c index 084307a1083f1..3d1a89f073552 100644 --- a/drivers/staging/ozwpan/ozproto.c +++ b/drivers/staging/ozwpan/ozproto.c @@ -291,7 +291,7 @@ static void oz_add_farewell(struct oz_pd *pd, u8 ep_num, u8 index, struct oz_farewell *f; struct oz_farewell *f2; int found = 0; - f = kmalloc(sizeof(struct oz_farewell) + len - 1, GFP_ATOMIC); + f = kmalloc(sizeof(struct oz_farewell) + len, GFP_ATOMIC); if (!f) return; f->ep_num = ep_num; -- GitLab From bc9aece00a7e7ec4b33900a232ca20455ae1f8b9 Mon Sep 17 00:00:00 2001 From: Rupesh Gujare Date: Mon, 5 Aug 2013 18:40:12 +0100 Subject: [PATCH 581/942] staging: ozwpan: Fixes crash due to invalid port aceess. This patch fixes kernel crash issue, when we receive URB request after de-enumerating device. Signed-off-by: Rupesh Gujare Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozhcd.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c index ed63868e60274..d313a636f2631 100644 --- a/drivers/staging/ozwpan/ozhcd.c +++ b/drivers/staging/ozwpan/ozhcd.c @@ -480,10 +480,14 @@ static int oz_enqueue_ep_urb(struct oz_port *port, u8 ep_addr, int in_dir, oz_free_urb_link(urbl); return 0; } - if (in_dir) + if (in_dir && port->in_ep[ep_addr]) ep = port->in_ep[ep_addr]; - else + else if (!in_dir && port->out_ep[ep_addr]) ep = port->out_ep[ep_addr]; + else { + err = -ENOMEM; + goto out; + } /*For interrupt endpoint check for buffered data * & complete urb @@ -505,6 +509,7 @@ static int oz_enqueue_ep_urb(struct oz_port *port, u8 ep_addr, int in_dir, } else { err = -EPIPE; } +out: spin_unlock_bh(&port->ozhcd->hcd_lock); if (err) oz_free_urb_link(urbl); -- GitLab From 3140b45808c06e418c01692a9e6325d3ac0cf628 Mon Sep 17 00:00:00 2001 From: Jens Frederich Date: Sun, 4 Aug 2013 20:57:43 +0200 Subject: [PATCH 582/942] Staging: olpc_dcon: updating MAINTAINERS Andres Salomon and Chris Ball are not longer at OLPC. Daniel Drake is the new OLPC go-to guy. And I wanna also be CC'd on DCON and other OLPC patches. Signed-off-by: Jens Frederich Signed-off-by: Greg Kroah-Hartman --- MAINTAINERS | 6 +++--- drivers/staging/olpc_dcon/TODO | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 7cacc88dc79c5..65e29558e0a6c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -7890,11 +7890,11 @@ S: Maintained F: drivers/staging/nvec/ STAGING - OLPC SECONDARY DISPLAY CONTROLLER (DCON) -M: Andres Salomon -M: Chris Ball +M: Jens Frederich +M: Daniel Drake M: Jon Nettleton W: http://wiki.laptop.org/go/DCON -S: Odd Fixes +S: Maintained F: drivers/staging/olpc_dcon/ STAGING - OZMO DEVICES USB OVER WIFI DRIVER diff --git a/drivers/staging/olpc_dcon/TODO b/drivers/staging/olpc_dcon/TODO index f378e848b51a6..901b891d38b23 100644 --- a/drivers/staging/olpc_dcon/TODO +++ b/drivers/staging/olpc_dcon/TODO @@ -10,6 +10,5 @@ TODO: Please send patches to Greg Kroah-Hartman and copy: - Andres Salomon - Chris Ball - Jon Nettleton + Daniel Drake + Jens Frederich -- GitLab From 2acb6111d77c2de27c4f46fed259dfd1231cb4ea Mon Sep 17 00:00:00 2001 From: Kumar Gaurav Date: Mon, 5 Aug 2013 00:11:02 +0530 Subject: [PATCH 583/942] Staging: xgifb: Fixed a warning of Space before semicolon Fixed issue by removing Space before semicolon Signed-off-by: Kumar Gaurav Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_setmode.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/xgifb/vb_setmode.h b/drivers/staging/xgifb/vb_setmode.h index f67d9478f7688..5301bec6440d2 100644 --- a/drivers/staging/xgifb/vb_setmode.h +++ b/drivers/staging/xgifb/vb_setmode.h @@ -11,7 +11,7 @@ extern void XGI_GetVBType(struct vb_device_info *); extern void XGI_SenseCRT1(struct vb_device_info *); extern unsigned char XGISetModeNew(struct xgifb_video_info *xgifb_info, struct xgi_hw_device_info *HwDeviceExtension, - unsigned short ModeNo) ; + unsigned short ModeNo); extern unsigned char XGI_SearchModeID(unsigned short ModeNo, unsigned short *ModeIdIndex); -- GitLab From 5cca8c013904e3ce313b71ebdd2b29ea44d60913 Mon Sep 17 00:00:00 2001 From: Iker Pedrosa Date: Mon, 5 Aug 2013 11:58:28 +0200 Subject: [PATCH 584/942] Staging: winbond: wb35reg: white space deleted White space deleted before a semicolon. Signed-off-by: Iker Pedrosa Acked-by: Pavel Machek Signed-off-by: Greg Kroah-Hartman --- drivers/staging/winbond/wb35reg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/winbond/wb35reg.c b/drivers/staging/winbond/wb35reg.c index 35d3beb572cf2..4369be62f2360 100644 --- a/drivers/staging/winbond/wb35reg.c +++ b/drivers/staging/winbond/wb35reg.c @@ -45,7 +45,7 @@ unsigned char Wb35Reg_BurstWrite(struct hw_data *pHwData, u16 RegisterNo, reg_queue->pBuffer = (u32 *)((u8 *)reg_queue + sizeof(struct wb35_reg_queue)); memcpy(reg_queue->pBuffer, pRegisterData, DataSize); /* the function for reversing register data from little endian to big endian */ - for (i = 0; i < NumberOfData ; i++) + for (i = 0; i < NumberOfData; i++) reg_queue->pBuffer[i] = cpu_to_le32(reg_queue->pBuffer[i]); dr = (struct usb_ctrlrequest *)((u8 *)reg_queue + sizeof(struct wb35_reg_queue) + DataSize); -- GitLab From 717d812fb2b99c12eb5bea6dd55d0a24f9542e14 Mon Sep 17 00:00:00 2001 From: Iker Pedrosa Date: Mon, 5 Aug 2013 11:58:29 +0200 Subject: [PATCH 585/942] Staging: winbond: wb35reg: avoided use of extern function Prototype of a function added to the header to avoid the use of extern. Signed-off-by: Iker Pedrosa Acked-by: Pavel Machek Signed-off-by: Greg Kroah-Hartman --- drivers/staging/winbond/phy_calibration.h | 1 + drivers/staging/winbond/wb35reg.c | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/winbond/phy_calibration.h b/drivers/staging/winbond/phy_calibration.h index 84f6e840a47a9..78fc68058607c 100644 --- a/drivers/staging/winbond/phy_calibration.h +++ b/drivers/staging/winbond/phy_calibration.h @@ -79,6 +79,7 @@ #define SHIFT_IQCAL_TONE_Q(x) ((x) >> 13) void phy_set_rf_data(struct hw_data *pHwData, u32 index, u32 value); +void phy_calibration_winbond(struct hw_data *phw_data, u32 frequency); #define phy_init_rf(_A) /* RFSynthesizer_initial(_A) */ #endif diff --git a/drivers/staging/winbond/wb35reg.c b/drivers/staging/winbond/wb35reg.c index 4369be62f2360..a5e255bb0f8b1 100644 --- a/drivers/staging/winbond/wb35reg.c +++ b/drivers/staging/winbond/wb35reg.c @@ -1,10 +1,9 @@ #include "wb35reg_f.h" +#include "phy_calibration.h" #include #include -extern void phy_calibration_winbond(struct hw_data *phw_data, u32 frequency); - /* * true : read command process successfully * false : register not support -- GitLab From a4f533fd5a2e4587ebfe6783931a2b35ee839531 Mon Sep 17 00:00:00 2001 From: Iker Pedrosa Date: Mon, 5 Aug 2013 11:58:30 +0200 Subject: [PATCH 586/942] Staging: winbond: mds: fixed some lines over 80 characters Fixed some coding style issues Signed-off-by: Iker Pedrosa Acked-by: Pavel Machek Signed-off-by: Greg Kroah-Hartman --- drivers/staging/winbond/mds.c | 56 +++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/drivers/staging/winbond/mds.c b/drivers/staging/winbond/mds.c index faa93f0ee1020..fcc3d2165ba9e 100644 --- a/drivers/staging/winbond/mds.c +++ b/drivers/staging/winbond/mds.c @@ -15,7 +15,8 @@ Mds_initial(struct wbsoft_priv *adapter) return hal_get_tx_buffer(&adapter->sHwData, &pMds->pTxBuffer); } -static void Mds_DurationSet(struct wbsoft_priv *adapter, struct wb35_descriptor *pDes, u8 *buffer) +static void Mds_DurationSet(struct wbsoft_priv *adapter, + struct wb35_descriptor *pDes, u8 *buffer) { struct T00_descriptor *pT00; struct T01_descriptor *pT01; @@ -43,10 +44,11 @@ static void Mds_DurationSet(struct wbsoft_priv *adapter, struct wb35_descriptor * Set RTS/CTS mechanism ******************************************/ if (!boGroupAddr) { - /* NOTE : If the protection mode is enabled and the MSDU will be fragmented, - * the tx rates of MPDUs will all be DSSS rates. So it will not use - * CTS-to-self in this case. CTS-To-self will only be used when without - * fragmentation. -- 20050112 */ + /* NOTE : If the protection mode is enabled and the MSDU will + * be fragmented, the tx rates of MPDUs will all be DSSS + * rates. So it will not use CTS-to-self in this case. + * CTS-To-self will only be used when without + * fragmentation. -- 20050112 */ BodyLen = (u16)pT00->T00_frame_length; /* include 802.11 header */ BodyLen += 4; /* CRC */ @@ -90,8 +92,8 @@ static void Mds_DurationSet(struct wbsoft_priv *adapter, struct wb35_descriptor * CTS Rate : 24 Mega bps * CTS frame length = 14 bytes */ Duration += (DEFAULT_SIFSTIME + - PREAMBLE_PLUS_SIGNAL_PLUS_SIGNALEXTENSION + - ((112 + 22 + 95)/96)*Tsym); + PREAMBLE_PLUS_SIGNAL_PLUS_SIGNALEXTENSION + + ((112 + 22 + 95)/96)*Tsym); } else { /* CTS + 1 SIFS + CTS duration * CTS Rate : ?? Mega bps @@ -101,7 +103,8 @@ static void Mds_DurationSet(struct wbsoft_priv *adapter, struct wb35_descriptor else Duration += SHORT_PREAMBLE_PLUS_PLCPHEADER_TIME; - Duration += (((112 + Rate-1) / Rate) + DEFAULT_SIFSTIME); + Duration += (((112 + Rate-1) / Rate) + + DEFAULT_SIFSTIME); } } @@ -127,9 +130,10 @@ static void Mds_DurationSet(struct wbsoft_priv *adapter, struct wb35_descriptor * Rate : ??Mega bps * ACK frame length = 14 bytes, tx rate = 24M */ Duration = PREAMBLE_PLUS_SIGNAL_PLUS_SIGNALEXTENSION * 3; - Duration += (((NextBodyLen*8 + 22 + Rate*4 - 1)/(Rate*4)) * Tsym + - (((2*14)*8 + 22 + 95)/96)*Tsym + - DEFAULT_SIFSTIME*3); + Duration += (((NextBodyLen*8 + 22 + Rate*4 - 1) + /(Rate*4)) * Tsym + + (((2*14)*8 + 22 + 95)/96)*Tsym + + DEFAULT_SIFSTIME*3); } else { /* DSSS * data transmit time + 2 ACK + 3 SIFS @@ -141,8 +145,9 @@ static void Mds_DurationSet(struct wbsoft_priv *adapter, struct wb35_descriptor else Duration = SHORT_PREAMBLE_PLUS_PLCPHEADER_TIME*3; - Duration += (((NextBodyLen + (2*14))*8 + Rate-1) / Rate + - DEFAULT_SIFSTIME*3); + Duration += (((NextBodyLen + (2*14))*8 + + Rate-1) / Rate + + DEFAULT_SIFSTIME*3); } ((u16 *)buffer)[5] = cpu_to_le16(Duration); /* 4 USHOR for skip 8B USB, 2USHORT=FC + Duration */ @@ -168,7 +173,8 @@ static void Mds_DurationSet(struct wbsoft_priv *adapter, struct wb35_descriptor * ACK frame length = 14 bytes */ Duration = PREAMBLE_PLUS_SIGNAL_PLUS_SIGNALEXTENSION; /* The Tx rate of ACK use 24M */ - Duration += (((112 + 22 + 95)/96)*Tsym + DEFAULT_SIFSTIME); + Duration += (((112 + 22 + 95)/96)*Tsym + + DEFAULT_SIFSTIME); } else { /* DSSS * 1 ACK + 1 SIFS @@ -191,7 +197,8 @@ static void Mds_DurationSet(struct wbsoft_priv *adapter, struct wb35_descriptor } /* The function return the 4n size of usb pk */ -static u16 Mds_BodyCopy(struct wbsoft_priv *adapter, struct wb35_descriptor *pDes, u8 *TargetBuffer) +static u16 Mds_BodyCopy(struct wbsoft_priv *adapter, + struct wb35_descriptor *pDes, u8 *TargetBuffer) { struct T00_descriptor *pT00; struct wb35_mds *pMds = &adapter->Mds; @@ -246,7 +253,7 @@ static u16 Mds_BodyCopy(struct wbsoft_priv *adapter, struct wb35_descriptor *pDe buf_index++; buf_index %= MAX_DESCRIPTOR_BUFFER_INDEX; } else { - u8 *pctmp = pDes->buffer_address[buf_index]; + u8 *pctmp = pDes->buffer_address[buf_index]; pctmp += CopySize; pDes->buffer_address[buf_index] = pctmp; pDes->buffer_size[buf_index] -= CopySize; @@ -290,7 +297,8 @@ static u16 Mds_BodyCopy(struct wbsoft_priv *adapter, struct wb35_descriptor *pDe return Size; } -static void Mds_HeaderCopy(struct wbsoft_priv *adapter, struct wb35_descriptor *pDes, u8 *TargetBuffer) +static void Mds_HeaderCopy(struct wbsoft_priv *adapter, + struct wb35_descriptor *pDes, u8 *TargetBuffer) { struct wb35_mds *pMds = &adapter->Mds; u8 *src_buffer = pDes->buffer_address[0]; /* 931130.5.g */ @@ -391,11 +399,12 @@ static void Mds_HeaderCopy(struct wbsoft_priv *adapter, struct wb35_descriptor * pDes->PreambleMode = WLAN_PREAMBLE_TYPE_LONG; else pDes->PreambleMode = CURRENT_PREAMBLE_MODE; - pT01->T01_plcp_header_length = pDes->PreambleMode; /* Set preamble */ + pT01->T01_plcp_header_length = pDes->PreambleMode; /* Set preamble */ } -static void MLME_GetNextPacket(struct wbsoft_priv *adapter, struct wb35_descriptor *desc) +static void MLME_GetNextPacket(struct wbsoft_priv *adapter, + struct wb35_descriptor *desc) { desc->InternalUsed = desc->buffer_start_index + desc->buffer_number; desc->InternalUsed %= MAX_DESCRIPTOR_BUFFER_INDEX; @@ -423,7 +432,8 @@ static void MLMEfreeMMPDUBuffer(struct wbsoft_priv *adapter, s8 *pData) } } -static void MLME_SendComplete(struct wbsoft_priv *adapter, u8 PacketID, unsigned char SendOK) +static void MLME_SendComplete(struct wbsoft_priv *adapter, u8 PacketID, + unsigned char SendOK) { /* Reclaim the data buffer */ adapter->sMlmeFrame.len = 0; @@ -440,9 +450,9 @@ Mds_Tx(struct wbsoft_priv *adapter) struct wb35_mds *pMds = &adapter->Mds; struct wb35_descriptor TxDes; struct wb35_descriptor *pTxDes = &TxDes; - u8 *XmitBufAddress; - u16 XmitBufSize, PacketSize, stmp, CurrentSize, FragmentThreshold; - u8 FillIndex, TxDesIndex, FragmentCount, FillCount; + u8 *XmitBufAddress; + u16 XmitBufSize, PacketSize, stmp, CurrentSize, FragmentThreshold; + u8 FillIndex, TxDesIndex, FragmentCount, FillCount; unsigned char BufferFilled = false; -- GitLab From 7a52a72e7c4fbb965b7f0cf16497351a1dd5e696 Mon Sep 17 00:00:00 2001 From: Iker Pedrosa Date: Mon, 5 Aug 2013 11:58:31 +0200 Subject: [PATCH 587/942] Staging: winbond: mds_f: fixed lines over 80 characters Fixed some coding style issues. Signed-off-by: Iker Pedrosa Acked-by: Pavel Machek Signed-off-by: Greg Kroah-Hartman --- drivers/staging/winbond/mds_f.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/staging/winbond/mds_f.h b/drivers/staging/winbond/mds_f.h index ce8be079e957c..ce5a78c27ce00 100644 --- a/drivers/staging/winbond/mds_f.h +++ b/drivers/staging/winbond/mds_f.h @@ -7,13 +7,17 @@ unsigned char Mds_initial(struct wbsoft_priv *adapter); void Mds_Tx(struct wbsoft_priv *adapter); void Mds_SendComplete(struct wbsoft_priv *adapter, struct T02_descriptor *pt02); -void Mds_MpduProcess(struct wbsoft_priv *adapter, struct wb35_descriptor *prxdes); +void Mds_MpduProcess(struct wbsoft_priv *adapter, + struct wb35_descriptor *prxdes); extern void DataDmp(u8 *pdata, u32 len, u32 offset); /* For data frame sending */ u16 MDS_GetPacketSize(struct wbsoft_priv *adapter); -void MDS_GetNextPacket(struct wbsoft_priv *adapter, struct wb35_descriptor *pdes); -void MDS_GetNextPacketComplete(struct wbsoft_priv *adapter, struct wb35_descriptor *pdes); -void MDS_SendResult(struct wbsoft_priv *adapter, u8 packetid, unsigned char sendok); +void MDS_GetNextPacket(struct wbsoft_priv *adapter, + struct wb35_descriptor *pdes); +void MDS_GetNextPacketComplete(struct wbsoft_priv *adapter, + struct wb35_descriptor *pdes); +void MDS_SendResult(struct wbsoft_priv *adapter, u8 packetid, + unsigned char sendok); #endif -- GitLab From dbd37ee59190469472a03a07fa4fdf21ce9e0cb6 Mon Sep 17 00:00:00 2001 From: Iker Pedrosa Date: Mon, 5 Aug 2013 11:58:32 +0200 Subject: [PATCH 588/942] Staging: winbond: mds_f: deleted extern function Deleted an extern function that wasn't used in this driver. Signed-off-by: Iker Pedrosa Acked-by: Pavel Machek Signed-off-by: Greg Kroah-Hartman --- drivers/staging/winbond/mds_f.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/winbond/mds_f.h b/drivers/staging/winbond/mds_f.h index ce5a78c27ce00..159b2eb366e89 100644 --- a/drivers/staging/winbond/mds_f.h +++ b/drivers/staging/winbond/mds_f.h @@ -9,7 +9,6 @@ void Mds_Tx(struct wbsoft_priv *adapter); void Mds_SendComplete(struct wbsoft_priv *adapter, struct T02_descriptor *pt02); void Mds_MpduProcess(struct wbsoft_priv *adapter, struct wb35_descriptor *prxdes); -extern void DataDmp(u8 *pdata, u32 len, u32 offset); /* For data frame sending */ u16 MDS_GetPacketSize(struct wbsoft_priv *adapter); -- GitLab From d772983d2a392a139c544a97014ed95554b09ad1 Mon Sep 17 00:00:00 2001 From: Rupesh Gujare Date: Mon, 5 Aug 2013 18:40:14 +0100 Subject: [PATCH 589/942] staging: ozwpan: Reset port configuration number. Make sure that we reset port configuration no. when PD departs. Signed-off-by: Rupesh Gujare Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozhcd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c index d313a636f2631..26eaa74e4a21b 100644 --- a/drivers/staging/ozwpan/ozhcd.c +++ b/drivers/staging/ozwpan/ozhcd.c @@ -715,6 +715,7 @@ void oz_hcd_pd_departed(void *hport) hpd = port->hpd; port->hpd = NULL; port->bus_addr = 0xff; + port->config_num = 0; port->flags &= ~(OZ_PORT_F_PRESENT | OZ_PORT_F_DYING); port->flags |= OZ_PORT_F_CHANGED; port->status &= ~USB_PORT_STAT_CONNECTION; -- GitLab From a66698110b7a286d57df023eaa6c0e50503c4d7b Mon Sep 17 00:00:00 2001 From: Rupesh Gujare Date: Mon, 5 Aug 2013 18:40:15 +0100 Subject: [PATCH 590/942] staging: ozwpan: Return correct hub status. Fix a bug where we were not returning correct hub status for 8th port. Signed-off-by: Rupesh Gujare Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozhcd.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c index 26eaa74e4a21b..f38d0365bddef 100644 --- a/drivers/staging/ozwpan/ozhcd.c +++ b/drivers/staging/ozwpan/ozhcd.c @@ -1865,17 +1865,24 @@ static int oz_hcd_hub_status_data(struct usb_hcd *hcd, char *buf) int i; buf[0] = 0; + buf[1] = 0; spin_lock_bh(&ozhcd->hcd_lock); for (i = 0; i < OZ_NB_PORTS; i++) { if (ozhcd->ports[i].flags & OZ_PORT_F_CHANGED) { oz_dbg(HUB, "Port %d changed\n", i); ozhcd->ports[i].flags &= ~OZ_PORT_F_CHANGED; - buf[0] |= 1<<(i+1); + if (i < 7) + buf[0] |= 1 << (i+1); + else + buf[1] |= 1 << (i-7); } } spin_unlock_bh(&ozhcd->hcd_lock); - return buf[0] ? 1 : 0; + if (buf[0] != 0 || buf[1] != 0) + return 2; + else + return 0; } /*------------------------------------------------------------------------------ * Context: process -- GitLab From c0de17e468a4a0469b6bba31a515c02b90b75edc Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 5 Aug 2013 21:09:14 +0100 Subject: [PATCH 591/942] staging: vt6656: rxtx.c: s_vGetFreeContext use single tx memset. memset to 0 structure _USB_SEND_CONTEXT pContext->Data to its size of MAX_TOTAL_SIZE_WITH_ALL_HEADERS as defined in device.h This removes the need for memset in the TX path. It also allows the removal of dead structure TX_BUFFER_CONTAINER BufferHeader; Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index be0c9ce5af066..137608f377c54 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -155,6 +155,7 @@ static void *s_vGetFreeContext(struct vnt_private *pDevice) pContext = pDevice->apTD[ii]; if (pContext->bBoolInUse == false) { pContext->bBoolInUse = true; + memset(pContext->Data, 0, MAX_TOTAL_SIZE_WITH_ALL_HEADERS); pReturnContext = pContext; break; } @@ -1206,7 +1207,6 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, } pTxBufHead = (PTX_BUFFER) usbPacketBuf; - memset(pTxBufHead, 0, sizeof(TX_BUFFER)); // Get pkt type if (ntohs(psEthHeader->h_proto) > ETH_DATA_LEN) { @@ -1582,8 +1582,6 @@ static void s_vGenerateMACHeader(struct vnt_private *pDevice, { struct ieee80211_hdr *pMACHeader = (struct ieee80211_hdr *)pbyBufferAddr; - memset(pMACHeader, 0, (sizeof(struct ieee80211_hdr))); - if (uDMAIdx == TYPE_ATIMDMA) { pMACHeader->frame_control = TYPE_802_11_ATIM; } else { @@ -1699,7 +1697,6 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice, cbFrameBodySize = pPacket->cbPayloadLen; pTxBufHead = (PSTxBufHead) pbyTxBufferAddr; wTxBufSize = sizeof(STxBufHead); - memset(pTxBufHead, 0, wTxBufSize); if (pDevice->byBBType == BB_TYPE_11A) { wCurrentRate = RATE_6M; @@ -1828,9 +1825,6 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice, cbHeaderSize = wTxBufSize + sizeof(SRrvTime_ab) + sizeof(STxDataHead_ab); } - memset((void *)(pbyTxBufferAddr + wTxBufSize), 0, - (cbHeaderSize - wTxBufSize)); - memcpy(&(sEthHeader.h_dest[0]), &(pPacket->p80211Header->sA3.abyAddr1[0]), ETH_ALEN); @@ -1968,7 +1962,6 @@ CMD_STATUS csBeacon_xmit(struct vnt_private *pDevice, pTxBufHead = (PSTxShortBufHead) pbyTxBufferAddr; wTxBufSize = sizeof(STxShortBufHead); - memset(pTxBufHead, 0, wTxBufSize); if (pDevice->byBBType == BB_TYPE_11A) { wCurrentRate = RATE_6M; @@ -2077,7 +2070,6 @@ void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb) pbyTxBufferAddr = (u8 *)(&pTX_Buffer->adwTxKey[0]); pTxBufHead = (PSTxBufHead) pbyTxBufferAddr; wTxBufSize = sizeof(STxBufHead); - memset(pTxBufHead, 0, wTxBufSize); if (pDevice->byBBType == BB_TYPE_11A) { wCurrentRate = RATE_6M; @@ -2233,8 +2225,6 @@ void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb) pvTxDataHd = (PSTxDataHead_ab) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab) + cbMICHDR); cbHeaderSize = wTxBufSize + sizeof(SRrvTime_ab) + cbMICHDR + sizeof(STxDataHead_ab); } - memset((void *)(pbyTxBufferAddr + wTxBufSize), 0, - (cbHeaderSize - wTxBufSize)); memcpy(&(sEthHeader.h_dest[0]), &(p80211Header->sA3.abyAddr1[0]), ETH_ALEN); -- GitLab From 0773893aaa8003ee7a8d1ab21084f7dafe32986a Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 5 Aug 2013 22:08:05 +0100 Subject: [PATCH 592/942] staging: vt6656: desc.h remove typedef struct tagSRTSData Replace structures with struct ieee80211_rts data. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/desc.h | 19 +--- drivers/staging/vt6656/rxtx.c | 183 ++++++++++++---------------------- 2 files changed, 69 insertions(+), 133 deletions(-) diff --git a/drivers/staging/vt6656/desc.h b/drivers/staging/vt6656/desc.h index 64cb046fe9885..aa5e249092a1d 100644 --- a/drivers/staging/vt6656/desc.h +++ b/drivers/staging/vt6656/desc.h @@ -33,6 +33,7 @@ #include #include +#include #include "tether.h" @@ -187,16 +188,6 @@ typedef const SRrvTime_atim *PCSRrvTime_atim; /* * RTS buffer header */ -typedef struct tagSRTSData { - u16 wFrameControl; - u16 wDurationID; - u8 abyRA[ETH_ALEN]; - u8 abyTA[ETH_ALEN]; -} __attribute__ ((__packed__)) -SRTSData, *PSRTSData; - -typedef const SRTSData *PCSRTSData; - typedef struct tagSRTS_g { u8 bySignalField_b; u8 byServiceField_b; @@ -208,7 +199,7 @@ typedef struct tagSRTS_g { u16 wDuration_aa; u16 wDuration_bb; u16 wReserved; - SRTSData Data; + struct ieee80211_rts data; } __attribute__ ((__packed__)) SRTS_g, *PSRTS_g; typedef const SRTS_g *PCSRTS_g; @@ -228,7 +219,7 @@ typedef struct tagSRTS_g_FB { u16 wRTSDuration_aa_f0; u16 wRTSDuration_ba_f1; u16 wRTSDuration_aa_f1; - SRTSData Data; + struct ieee80211_rts data; } __attribute__ ((__packed__)) SRTS_g_FB, *PSRTS_g_FB; @@ -240,7 +231,7 @@ typedef struct tagSRTS_ab { u16 wTransmitLength; u16 wDuration; u16 wReserved; - SRTSData Data; + struct ieee80211_rts data; } __attribute__ ((__packed__)) SRTS_ab, *PSRTS_ab; @@ -254,7 +245,7 @@ typedef struct tagSRTS_a_FB { u16 wReserved; u16 wRTSDuration_f0; u16 wRTSDuration_f1; - SRTSData Data; + struct ieee80211_rts data; } __attribute__ ((__packed__)) SRTS_a_FB, *PSRTS_a_FB; diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 137608f377c54..fd6f817fdda51 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -795,32 +795,20 @@ static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, pBuf->wDuration_bb = cpu_to_le16((u16)s_uGetRTSCTSDuration(pDevice, RTSDUR_BB, cbFrameLength, PK_TYPE_11B, pDevice->byTopCCKBasicRate, bNeedAck, byFBOption)); //0:RTSDuration_bb, 1:2.4G, 1:CCKData pBuf->wDuration_aa = cpu_to_le16((u16)s_uGetRTSCTSDuration(pDevice, RTSDUR_AA, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption)); //2:RTSDuration_aa, 1:2.4G, 2,3: 2.4G OFDMData pBuf->wDuration_ba = cpu_to_le16((u16)s_uGetRTSCTSDuration(pDevice, RTSDUR_BA, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption)); //1:RTSDuration_ba, 1:2.4G, 2,3:2.4G OFDM Data + pBuf->data.duration = pBuf->wDuration_aa; + /*Get RTS Frame body */ + pBuf->data.frame_control = TYPE_CTL_RTS; - pBuf->Data.wDurationID = pBuf->wDuration_aa; - //Get RTS Frame body - pBuf->Data.wFrameControl = TYPE_CTL_RTS;//0x00B4 + if (pDevice->eOPMode == OP_MODE_ADHOC || + pDevice->eOPMode == OP_MODE_AP) + memcpy(pBuf->data.ra, psEthHeader->h_dest, ETH_ALEN); + else + memcpy(pBuf->data.ra, pDevice->abyBSSID, ETH_ALEN); - if ((pDevice->eOPMode == OP_MODE_ADHOC) || - (pDevice->eOPMode == OP_MODE_AP)) { - memcpy(&(pBuf->Data.abyRA[0]), - &(psEthHeader->h_dest[0]), - ETH_ALEN); - } - else { - memcpy(&(pBuf->Data.abyRA[0]), - &(pDevice->abyBSSID[0]), - ETH_ALEN); - } - if (pDevice->eOPMode == OP_MODE_AP) { - memcpy(&(pBuf->Data.abyTA[0]), - &(pDevice->abyBSSID[0]), - ETH_ALEN); - } - else { - memcpy(&(pBuf->Data.abyTA[0]), - &(psEthHeader->h_source[0]), - ETH_ALEN); - } + if (pDevice->eOPMode == OP_MODE_AP) + memcpy(pBuf->data.ta, pDevice->abyBSSID, ETH_ALEN); + else + memcpy(pBuf->data.ta, psEthHeader->h_source, ETH_ALEN); } else { PSRTS_g_FB pBuf = (PSRTS_g_FB)pvRTS; @@ -841,33 +829,20 @@ static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, pBuf->wRTSDuration_aa_f0 = cpu_to_le16((u16)s_uGetRTSCTSDuration(pDevice, RTSDUR_AA_F0, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption)); //5:wRTSDuration_aa_f0, 1:2.4G, 1:CCKData pBuf->wRTSDuration_ba_f1 = cpu_to_le16((u16)s_uGetRTSCTSDuration(pDevice, RTSDUR_BA_F1, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption)); //6:wRTSDuration_ba_f1, 1:2.4G, 1:CCKData pBuf->wRTSDuration_aa_f1 = cpu_to_le16((u16)s_uGetRTSCTSDuration(pDevice, RTSDUR_AA_F1, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption)); //7:wRTSDuration_aa_f1, 1:2.4G, 1:CCKData - pBuf->Data.wDurationID = pBuf->wDuration_aa; - //Get RTS Frame body - pBuf->Data.wFrameControl = TYPE_CTL_RTS;//0x00B4 - - if ((pDevice->eOPMode == OP_MODE_ADHOC) || - (pDevice->eOPMode == OP_MODE_AP)) { - memcpy(&(pBuf->Data.abyRA[0]), - &(psEthHeader->h_dest[0]), - ETH_ALEN); - } - else { - memcpy(&(pBuf->Data.abyRA[0]), - &(pDevice->abyBSSID[0]), - ETH_ALEN); - } - - if (pDevice->eOPMode == OP_MODE_AP) { - memcpy(&(pBuf->Data.abyTA[0]), - &(pDevice->abyBSSID[0]), - ETH_ALEN); - } - else { - memcpy(&(pBuf->Data.abyTA[0]), - &(psEthHeader->h_source[0]), - ETH_ALEN); - } - + pBuf->data.duration = pBuf->wDuration_aa; + /*Get RTS Frame body*/ + pBuf->data.frame_control = TYPE_CTL_RTS; + + if (pDevice->eOPMode == OP_MODE_ADHOC || + pDevice->eOPMode == OP_MODE_AP) + memcpy(pBuf->data.ra, psEthHeader->h_dest, ETH_ALEN); + else + memcpy(pBuf->data.ra, pDevice->abyBSSID, ETH_ALEN); + + if (pDevice->eOPMode == OP_MODE_AP) + memcpy(pBuf->data.ta, pDevice->abyBSSID, ETH_ALEN); + else + memcpy(pBuf->data.ta, psEthHeader->h_source, ETH_ALEN); } // if (byFBOption == AUTO_FB_NONE) } else if (byPktType == PK_TYPE_11A) { @@ -880,31 +855,20 @@ static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, pBuf->wTransmitLength = cpu_to_le16(wLen); //Get Duration pBuf->wDuration = cpu_to_le16((u16)s_uGetRTSCTSDuration(pDevice, RTSDUR_AA, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption)); //0:RTSDuration_aa, 0:5G, 0: 5G OFDMData - pBuf->Data.wDurationID = pBuf->wDuration; - //Get RTS Frame body - pBuf->Data.wFrameControl = TYPE_CTL_RTS;//0x00B4 - - if ((pDevice->eOPMode == OP_MODE_ADHOC) || - (pDevice->eOPMode == OP_MODE_AP)) { - memcpy(&(pBuf->Data.abyRA[0]), - &(psEthHeader->h_dest[0]), - ETH_ALEN); - } else { - memcpy(&(pBuf->Data.abyRA[0]), - &(pDevice->abyBSSID[0]), - ETH_ALEN); - } + pBuf->data.duration = pBuf->wDuration; + /* Get RTS Frame body */ + pBuf->data.frame_control = TYPE_CTL_RTS; - if (pDevice->eOPMode == OP_MODE_AP) { - memcpy(&(pBuf->Data.abyTA[0]), - &(pDevice->abyBSSID[0]), - ETH_ALEN); - } else { - memcpy(&(pBuf->Data.abyTA[0]), - &(psEthHeader->h_source[0]), - ETH_ALEN); - } + if (pDevice->eOPMode == OP_MODE_ADHOC || + pDevice->eOPMode == OP_MODE_AP) + memcpy(pBuf->data.ra, psEthHeader->h_dest, ETH_ALEN); + else + memcpy(pBuf->data.ra, pDevice->abyBSSID, ETH_ALEN); + if (pDevice->eOPMode == OP_MODE_AP) + memcpy(pBuf->data.ta, pDevice->abyBSSID, ETH_ALEN); + else + memcpy(pBuf->data.ta, psEthHeader->h_source, ETH_ALEN); } else { PSRTS_a_FB pBuf = (PSRTS_a_FB)pvRTS; @@ -917,29 +881,20 @@ static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, pBuf->wDuration = cpu_to_le16((u16)s_uGetRTSCTSDuration(pDevice, RTSDUR_AA, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption)); //0:RTSDuration_aa, 0:5G, 0: 5G OFDMData pBuf->wRTSDuration_f0 = cpu_to_le16((u16)s_uGetRTSCTSDuration(pDevice, RTSDUR_AA_F0, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption)); //5:RTSDuration_aa_f0, 0:5G, 0: 5G OFDMData pBuf->wRTSDuration_f1 = cpu_to_le16((u16)s_uGetRTSCTSDuration(pDevice, RTSDUR_AA_F1, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption)); //7:RTSDuration_aa_f1, 0:5G, 0: - pBuf->Data.wDurationID = pBuf->wDuration; - //Get RTS Frame body - pBuf->Data.wFrameControl = TYPE_CTL_RTS;//0x00B4 + pBuf->data.duration = pBuf->wDuration; + /* Get RTS Frame body */ + pBuf->data.frame_control = TYPE_CTL_RTS; - if ((pDevice->eOPMode == OP_MODE_ADHOC) || - (pDevice->eOPMode == OP_MODE_AP)) { - memcpy(&(pBuf->Data.abyRA[0]), - &(psEthHeader->h_dest[0]), - ETH_ALEN); - } else { - memcpy(&(pBuf->Data.abyRA[0]), - &(pDevice->abyBSSID[0]), - ETH_ALEN); - } - if (pDevice->eOPMode == OP_MODE_AP) { - memcpy(&(pBuf->Data.abyTA[0]), - &(pDevice->abyBSSID[0]), - ETH_ALEN); - } else { - memcpy(&(pBuf->Data.abyTA[0]), - &(psEthHeader->h_source[0]), - ETH_ALEN); - } + if (pDevice->eOPMode == OP_MODE_ADHOC || + pDevice->eOPMode == OP_MODE_AP) + memcpy(pBuf->data.ra, psEthHeader->h_dest, ETH_ALEN); + else + memcpy(pBuf->data.ra, pDevice->abyBSSID, ETH_ALEN); + + if (pDevice->eOPMode == OP_MODE_AP) + memcpy(pBuf->data.ta, pDevice->abyBSSID, ETH_ALEN); + else + memcpy(pBuf->data.ta, psEthHeader->h_source, ETH_ALEN); } } else if (byPktType == PK_TYPE_11B) { @@ -951,31 +906,21 @@ static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, pBuf->wTransmitLength = cpu_to_le16(wLen); //Get Duration pBuf->wDuration = cpu_to_le16((u16)s_uGetRTSCTSDuration(pDevice, RTSDUR_BB, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption)); //0:RTSDuration_bb, 1:2.4G, 1:CCKData - pBuf->Data.wDurationID = pBuf->wDuration; - //Get RTS Frame body - pBuf->Data.wFrameControl = TYPE_CTL_RTS;//0x00B4 - if ((pDevice->eOPMode == OP_MODE_ADHOC) || - (pDevice->eOPMode == OP_MODE_AP)) { - memcpy(&(pBuf->Data.abyRA[0]), - &(psEthHeader->h_dest[0]), - ETH_ALEN); - } - else { - memcpy(&(pBuf->Data.abyRA[0]), - &(pDevice->abyBSSID[0]), - ETH_ALEN); - } + pBuf->data.duration = pBuf->wDuration; + /* Get RTS Frame body */ + pBuf->data.frame_control = TYPE_CTL_RTS; - if (pDevice->eOPMode == OP_MODE_AP) { - memcpy(&(pBuf->Data.abyTA[0]), - &(pDevice->abyBSSID[0]), - ETH_ALEN); - } else { - memcpy(&(pBuf->Data.abyTA[0]), - &(psEthHeader->h_source[0]), - ETH_ALEN); - } + if (pDevice->eOPMode == OP_MODE_ADHOC || + pDevice->eOPMode == OP_MODE_AP) + memcpy(pBuf->data.ra, psEthHeader->h_dest, ETH_ALEN); + else + memcpy(pBuf->data.ra, pDevice->abyBSSID, ETH_ALEN); + + if (pDevice->eOPMode == OP_MODE_AP) + memcpy(pBuf->data.ta, pDevice->abyBSSID, ETH_ALEN); + else + memcpy(pBuf->data.ta, psEthHeader->h_source, ETH_ALEN); } } -- GitLab From 14840cdd9647a80a988f26a707f2caa16abed5e5 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 5 Aug 2013 22:12:42 +0100 Subject: [PATCH 593/942] staging: vt6656: desc.h remove typedef struct tagSCTSData Replace structures with struct ieee80211_cts data typedef struct tagSCTSData include extra packing wReserved not in struct ieee80211_cts This is corrected by adding reserved2 to the structures. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/desc.h | 14 ++++---------- drivers/staging/vt6656/rxtx.c | 23 ++++++++--------------- 2 files changed, 12 insertions(+), 25 deletions(-) diff --git a/drivers/staging/vt6656/desc.h b/drivers/staging/vt6656/desc.h index aa5e249092a1d..1a1cf34e4113e 100644 --- a/drivers/staging/vt6656/desc.h +++ b/drivers/staging/vt6656/desc.h @@ -254,21 +254,14 @@ typedef const SRTS_a_FB *PCSRTS_a_FB; /* * CTS buffer header */ -typedef struct tagSCTSData { - u16 wFrameControl; - u16 wDurationID; - u8 abyRA[ETH_ALEN]; - u16 wReserved; -} __attribute__ ((__packed__)) -SCTSData, *PSCTSData; - typedef struct tagSCTS { u8 bySignalField_b; u8 byServiceField_b; u16 wTransmitLength_b; u16 wDuration_ba; u16 wReserved; - SCTSData Data; + struct ieee80211_cts data; + u16 reserved2; } __attribute__ ((__packed__)) SCTS, *PSCTS; @@ -282,7 +275,8 @@ typedef struct tagSCTS_FB { u16 wReserved; u16 wCTSDuration_ba_f0; u16 wCTSDuration_ba_f1; - SCTSData Data; + struct ieee80211_cts data; + u16 reserved2; } __attribute__ ((__packed__)) SCTS_FB, *PSCTS_FB; diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index fd6f817fdda51..1d58d1f2688fa 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -958,13 +958,10 @@ static void s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx, //Get CTSDuration_ba_f1 pBuf->wCTSDuration_ba_f1 = (u16)s_uGetRTSCTSDuration(pDevice, CTSDUR_BA_F1, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption); //9:CTSDuration_ba_f1, 1:2.4G, 2,3:2.4G OFDM Data pBuf->wCTSDuration_ba_f1 = cpu_to_le16(pBuf->wCTSDuration_ba_f1); - //Get CTS Frame body - pBuf->Data.wDurationID = pBuf->wDuration_ba; - pBuf->Data.wFrameControl = TYPE_CTL_CTS;//0x00C4 - pBuf->Data.wReserved = 0x0000; - memcpy(&(pBuf->Data.abyRA[0]), - &(pDevice->abyCurrentNetAddr[0]), - ETH_ALEN); + /* Get CTS Frame body */ + pBuf->data.duration = pBuf->wDuration_ba; + pBuf->data.frame_control = TYPE_CTL_CTS; + memcpy(pBuf->data.ra, pDevice->abyCurrentNetAddr, ETH_ALEN); } else { //if (byFBOption != AUTO_FB_NONE && uDMAIdx != TYPE_ATIMDMA && uDMAIdx != TYPE_BEACONDMA) PSCTS pBuf = (PSCTS)pvCTS; //Get SignalField,ServiceField,Length @@ -975,14 +972,10 @@ static void s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx, //Get CTSDuration_ba pBuf->wDuration_ba = cpu_to_le16((u16)s_uGetRTSCTSDuration(pDevice, CTSDUR_BA, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption)); //3:CTSDuration_ba, 1:2.4G, 2,3:2.4G OFDM Data pBuf->wDuration_ba = cpu_to_le16(pBuf->wDuration_ba); - - //Get CTS Frame body - pBuf->Data.wDurationID = pBuf->wDuration_ba; - pBuf->Data.wFrameControl = TYPE_CTL_CTS;//0x00C4 - pBuf->Data.wReserved = 0x0000; - memcpy(&(pBuf->Data.abyRA[0]), - &(pDevice->abyCurrentNetAddr[0]), - ETH_ALEN); + /*Get CTS Frame body*/ + pBuf->data.duration = pBuf->wDuration_ba; + pBuf->data.frame_control = TYPE_CTL_CTS; + memcpy(pBuf->data.ra, pDevice->abyCurrentNetAddr, ETH_ALEN); } } } -- GitLab From 4f76463d3b8f8cc0cac5bb292ec766848f3f4fa1 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 5 Aug 2013 15:00:05 -0700 Subject: [PATCH 594/942] staging: comedi: core: introduce comedi_dio_insn_config() DIO subdevices always handle the INSN_CONFIG_DIO_{INPUT,OUTPUT} instructions to configure the dio channels. They also always handle the INSN_CONFIG_DIO_QUERY instruction to query the configuration of a dio channel. Introduce a helper function to handle the (*insn_config) boilerplate for comedi DIO subdevices. This function has the same parameters as (*insn_config) functions with an additional parameter to allow the caller to pass a 'mask' value for grouped dio channels. This function returns: 0 if the instruction was successful but requires additional handling by the caller (INSN_CONFIG_DIO_{INPUT,OUTPUT} insn->n if the instruction was handled (INSN_CONFIG_DIO_QUERY) -EINVAL for all unhandled instructions The caller is responsible for actually configuring the hardware based on the configuration (s->io_bits). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedidev.h | 4 +++ drivers/staging/comedi/drivers.c | 40 ++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index 98058b9097e61..f2f75b9dfb863 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -342,6 +342,10 @@ void comedi_buf_memcpy_from(struct comedi_async *async, unsigned int offset, /* drivers.c - general comedi driver functions */ +int comedi_dio_insn_config(struct comedi_device *, struct comedi_subdevice *, + struct comedi_insn *, unsigned int *data, + unsigned int mask); + void *comedi_alloc_devpriv(struct comedi_device *, size_t); int comedi_alloc_subdevices(struct comedi_device *, int); diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index 791a26bd5f63c..60fd81c71a127 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -150,6 +150,46 @@ int insn_inval(struct comedi_device *dev, struct comedi_subdevice *s, return -EINVAL; } +/** + * comedi_dio_insn_config() - boilerplate (*insn_config) for DIO subdevices. + * @dev: comedi_device struct + * @s: comedi_subdevice struct + * @insn: comedi_insn struct + * @data: parameters for the @insn + * @mask: io_bits mask for grouped channels + */ +int comedi_dio_insn_config(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data, + unsigned int mask) +{ + unsigned int chan_mask = 1 << CR_CHAN(insn->chanspec); + + if (!mask) + mask = chan_mask; + + switch (data[0]) { + case INSN_CONFIG_DIO_INPUT: + s->io_bits &= ~mask; + break; + + case INSN_CONFIG_DIO_OUTPUT: + s->io_bits |= mask; + break; + + case INSN_CONFIG_DIO_QUERY: + data[1] = (s->io_bits & mask) ? COMEDI_OUTPUT : COMEDI_INPUT; + return insn->n; + + default: + return -EINVAL; + } + + return 0; +} +EXPORT_SYMBOL_GPL(comedi_dio_insn_config); + static int insn_rw_emulate_bits(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) -- GitLab From 42ef678bef336a83fd0ae0b03a56c0a93665a18b Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 5 Aug 2013 15:00:36 -0700 Subject: [PATCH 595/942] staging: comedi: skel: use comedi_dio_insn_config() Convert this driver to use the comedi_dio_insn_config() helper function. Tidy up the comments to reflect the new code. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/skel.c | 42 ++++++++++++--------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/drivers/staging/comedi/drivers/skel.c b/drivers/staging/comedi/drivers/skel.c index f76fd09e7bd31..9e964950a560e 100644 --- a/drivers/staging/comedi/drivers/skel.c +++ b/drivers/staging/comedi/drivers/skel.c @@ -362,31 +362,27 @@ static int skel_dio_insn_bits(struct comedi_device *dev, static int skel_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { - int chan = CR_CHAN(insn->chanspec); + int ret; - /* The input or output configuration of each digital line is - * configured by a special insn_config instruction. chanspec - * contains the channel to be changed, and data[0] contains the - * value COMEDI_INPUT or COMEDI_OUTPUT. */ - switch (data[0]) { - case INSN_CONFIG_DIO_OUTPUT: - s->io_bits |= 1 << chan; - break; - case INSN_CONFIG_DIO_INPUT: - s->io_bits &= ~(1 << chan); - break; - case INSN_CONFIG_DIO_QUERY: - data[1] = - (s->io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT; - return insn->n; - break; - default: - return -EINVAL; - break; - } - /* outw(s->io_bits,dev->iobase + SKEL_DIO_CONFIG); */ + /* + * The input or output configuration of each digital line is + * configured by special insn_config instructions. + * + * chanspec contains the channel to be changed + * data[0] contains the instruction to perform on the channel + * + * Normally the core provided comedi_dio_insn_config() function + * can be used to handle the boilerplpate. + */ + ret = comedi_dio_insn_config(dev, s, insn, data, 0); + if (ret) + return ret; + + /* Update the hardware to the new configuration */ + /* outw(s->io_bits, dev->iobase + SKEL_DIO_CONFIG); */ return insn->n; } -- GitLab From f21c53945cb95f66faa9636af5f23cb00ba73019 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 5 Aug 2013 15:01:25 -0700 Subject: [PATCH 596/942] staging: comedi: drivers: use comedi_dio_insn_config() for complex cases Convert the drivers with complex, port programmable i/o, to use the comedi_dio_insn_config() helper function. All of these drivers have some sort of 'port' programmable i/o where multiple i/o channels are configured as a group. The 'mask' associated with the group is passed to comedi_dio_insn_config() so that all the channels are configured. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/8255.c | 42 +++--- .../staging/comedi/drivers/addi_apci_16xx.c | 42 ++---- .../staging/comedi/drivers/addi_apci_3xxx.c | 36 ++--- drivers/staging/comedi/drivers/adv_pci1723.c | 43 +++--- .../comedi/drivers/amplc_dio200_common.c | 42 +++--- drivers/staging/comedi/drivers/cb_das16_cs.c | 31 ++--- drivers/staging/comedi/drivers/dt2801.c | 31 ++--- drivers/staging/comedi/drivers/dt3000.c | 41 +++--- drivers/staging/comedi/drivers/gsc_hpdi.c | 33 ++--- drivers/staging/comedi/drivers/ii_pci20kc.c | 37 ++---- drivers/staging/comedi/drivers/me4000.c | 123 ++++++------------ drivers/staging/comedi/drivers/me_daq.c | 50 +++---- drivers/staging/comedi/drivers/ni_at_ao.c | 55 ++++---- drivers/staging/comedi/drivers/pcm3724.c | 45 +++---- drivers/staging/comedi/drivers/s526.c | 45 ++++--- 15 files changed, 263 insertions(+), 433 deletions(-) diff --git a/drivers/staging/comedi/drivers/8255.c b/drivers/staging/comedi/drivers/8255.c index 1fa29ac4eb5df..2f070fdbbb1d3 100644 --- a/drivers/staging/comedi/drivers/8255.c +++ b/drivers/staging/comedi/drivers/8255.c @@ -184,39 +184,29 @@ static void subdev_8255_do_config(struct comedi_device *dev, static int subdev_8255_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { + unsigned int chan = CR_CHAN(insn->chanspec); unsigned int mask; - unsigned int bits; + int ret; - mask = 1 << CR_CHAN(insn->chanspec); - if (mask & 0x0000ff) - bits = 0x0000ff; - else if (mask & 0x00ff00) - bits = 0x00ff00; - else if (mask & 0x0f0000) - bits = 0x0f0000; + if (chan < 8) + mask = 0x0000ff; + else if (chan < 16) + mask = 0x00ff00; + else if (chan < 20) + mask = 0x0f0000; else - bits = 0xf00000; - - switch (data[0]) { - case INSN_CONFIG_DIO_INPUT: - s->io_bits &= ~bits; - break; - case INSN_CONFIG_DIO_OUTPUT: - s->io_bits |= bits; - break; - case INSN_CONFIG_DIO_QUERY: - data[1] = (s->io_bits & bits) ? COMEDI_OUTPUT : COMEDI_INPUT; - return insn->n; - break; - default: - return -EINVAL; - } + mask = 0xf00000; + + ret = comedi_dio_insn_config(dev, s, insn, data, mask); + if (ret) + return ret; subdev_8255_do_config(dev, s); - return 1; + return insn->n; } static int subdev_8255_cmdtest(struct comedi_device *dev, diff --git a/drivers/staging/comedi/drivers/addi_apci_16xx.c b/drivers/staging/comedi/drivers/addi_apci_16xx.c index 43296a6e7d4e6..96523744b8de5 100644 --- a/drivers/staging/comedi/drivers/addi_apci_16xx.c +++ b/drivers/staging/comedi/drivers/addi_apci_16xx.c @@ -60,36 +60,22 @@ static int apci16xx_insn_config(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - unsigned int chan_mask = 1 << CR_CHAN(insn->chanspec); - unsigned int bits; + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned int mask; + int ret; - /* - * Each 8-bit "port" is configurable as either input or - * output. Changing the configuration of any channel in - * a port changes the entire port. - */ - if (chan_mask & 0x000000ff) - bits = 0x000000ff; - else if (chan_mask & 0x0000ff00) - bits = 0x0000ff00; - else if (chan_mask & 0x00ff0000) - bits = 0x00ff0000; + if (chan < 8) + mask = 0x000000ff; + else if (chan < 16) + mask = 0x0000ff00; + else if (chan < 24) + mask = 0x00ff0000; else - bits = 0xff000000; - - switch (data[0]) { - case INSN_CONFIG_DIO_INPUT: - s->io_bits &= ~bits; - break; - case INSN_CONFIG_DIO_OUTPUT: - s->io_bits |= bits; - break; - case INSN_CONFIG_DIO_QUERY: - data[1] = (s->io_bits & bits) ? COMEDI_INPUT : COMEDI_OUTPUT; - return insn->n; - default: - return -EINVAL; - } + mask = 0xff000000; + + ret = comedi_dio_insn_config(dev, s, insn, data, mask); + if (ret) + return ret; outl(s->io_bits, dev->iobase + APCI16XX_DIR_REG(s->index)); diff --git a/drivers/staging/comedi/drivers/addi_apci_3xxx.c b/drivers/staging/comedi/drivers/addi_apci_3xxx.c index dbc0678027ca7..cf5dd10eaf91d 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3xxx.c +++ b/drivers/staging/comedi/drivers/addi_apci_3xxx.c @@ -686,38 +686,28 @@ static int apci3xxx_dio_insn_config(struct comedi_device *dev, unsigned int *data) { unsigned int chan = CR_CHAN(insn->chanspec); - unsigned int mask = 1 << chan; - unsigned int bits; + unsigned int mask; + int ret; /* * Port 0 (channels 0-7) are always inputs * Port 1 (channels 8-15) are always outputs * Port 2 (channels 16-23) are programmable i/o - * - * Changing any channel in port 2 changes the entire port. */ - if (mask & 0xff0000) - bits = 0xff0000; - else - bits = 0; - - switch (data[0]) { - case INSN_CONFIG_DIO_INPUT: - s->io_bits &= ~bits; - break; - case INSN_CONFIG_DIO_OUTPUT: - s->io_bits |= bits; - break; - case INSN_CONFIG_DIO_QUERY: - data[1] = (s->io_bits & bits) ? COMEDI_OUTPUT : COMEDI_INPUT; - return insn->n; - default: - return -EINVAL; + if (chan < 16) { + if (data[0] != INSN_CONFIG_DIO_QUERY) + return -EINVAL; + } else { + /* changing any channel in port 2 changes the entire port */ + mask = 0xff0000; } + ret = comedi_dio_insn_config(dev, s, insn, data, mask); + if (ret) + return ret; + /* update port 2 configuration */ - if (bits) - outl((s->io_bits >> 24) & 0xff, dev->iobase + 224); + outl((s->io_bits >> 24) & 0xff, dev->iobase + 224); return insn->n; } diff --git a/drivers/staging/comedi/drivers/adv_pci1723.c b/drivers/staging/comedi/drivers/adv_pci1723.c index f914fb1f571be..b793d6987b843 100644 --- a/drivers/staging/comedi/drivers/adv_pci1723.c +++ b/drivers/staging/comedi/drivers/adv_pci1723.c @@ -180,38 +180,29 @@ static int pci1723_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { + unsigned int chan = CR_CHAN(insn->chanspec); unsigned int mask; - unsigned int bits; - unsigned short dio_mode; + unsigned short mode; + int ret; - mask = 1 << CR_CHAN(insn->chanspec); - if (mask & 0x00FF) - bits = 0x00FF; + if (chan < 8) + mask = 0x00ff; else - bits = 0xFF00; + mask = 0xff00; - switch (data[0]) { - case INSN_CONFIG_DIO_INPUT: - s->io_bits &= ~bits; - break; - case INSN_CONFIG_DIO_OUTPUT: - s->io_bits |= bits; - break; - case INSN_CONFIG_DIO_QUERY: - data[1] = (s->io_bits & bits) ? COMEDI_OUTPUT : COMEDI_INPUT; - return insn->n; - default: - return -EINVAL; - } + ret = comedi_dio_insn_config(dev, s, insn, data, mask); + if (ret) + return ret; /* update hardware DIO mode */ - dio_mode = 0x0000; /* low byte output, high byte output */ - if ((s->io_bits & 0x00FF) == 0) - dio_mode |= 0x0001; /* low byte input */ - if ((s->io_bits & 0xFF00) == 0) - dio_mode |= 0x0002; /* high byte input */ - outw(dio_mode, dev->iobase + PCI1723_DIGITAL_IO_PORT_SET); - return 1; + mode = 0x0000; /* assume output */ + if (!(s->io_bits & 0x00ff)) + mode |= 0x0001; /* low byte input */ + if (!(s->io_bits & 0xff00)) + mode |= 0x0002; /* high byte input */ + outw(mode, dev->iobase + PCI1723_DIGITAL_IO_PORT_SET); + + return insn->n; } /* diff --git a/drivers/staging/comedi/drivers/amplc_dio200_common.c b/drivers/staging/comedi/drivers/amplc_dio200_common.c index 32c490b27b555..c1f723e861461 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200_common.c +++ b/drivers/staging/comedi/drivers/amplc_dio200_common.c @@ -976,34 +976,26 @@ static int dio200_subdev_8255_config(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { + unsigned int chan = CR_CHAN(insn->chanspec); unsigned int mask; - unsigned int bits; - - mask = 1 << CR_CHAN(insn->chanspec); - if (mask & 0x0000ff) - bits = 0x0000ff; - else if (mask & 0x00ff00) - bits = 0x00ff00; - else if (mask & 0x0f0000) - bits = 0x0f0000; + int ret; + + if (chan < 8) + mask = 0x0000ff; + else if (chan < 16) + mask = 0x00ff00; + else if (chan < 20) + mask = 0x0f0000; else - bits = 0xf00000; - switch (data[0]) { - case INSN_CONFIG_DIO_INPUT: - s->io_bits &= ~bits; - break; - case INSN_CONFIG_DIO_OUTPUT: - s->io_bits |= bits; - break; - case INSN_CONFIG_DIO_QUERY: - data[1] = (s->io_bits & bits) ? COMEDI_OUTPUT : COMEDI_INPUT; - return insn->n; - break; - default: - return -EINVAL; - } + mask = 0xf00000; + + ret = comedi_dio_insn_config(dev, s, insn, data, mask); + if (ret) + return ret; + dio200_subdev_8255_set_dir(dev, s); - return 1; + + return insn->n; } /* diff --git a/drivers/staging/comedi/drivers/cb_das16_cs.c b/drivers/staging/comedi/drivers/cb_das16_cs.c index 05e01a3b5af6a..0ce93da70847c 100644 --- a/drivers/staging/comedi/drivers/cb_das16_cs.c +++ b/drivers/staging/comedi/drivers/cb_das16_cs.c @@ -341,33 +341,22 @@ static int das16cs_dio_insn_bits(struct comedi_device *dev, static int das16cs_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { struct das16cs_private *devpriv = dev->private; - int chan = CR_CHAN(insn->chanspec); - int bits; + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned int mask; + int ret; if (chan < 4) - bits = 0x0f; + mask = 0x0f; else - bits = 0xf0; + mask = 0xf0; - switch (data[0]) { - case INSN_CONFIG_DIO_OUTPUT: - s->io_bits |= bits; - break; - case INSN_CONFIG_DIO_INPUT: - s->io_bits &= bits; - break; - case INSN_CONFIG_DIO_QUERY: - data[1] = - (s->io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT; - return insn->n; - break; - default: - return -EINVAL; - break; - } + ret = comedi_dio_insn_config(dev, s, insn, data, mask); + if (ret) + return ret; devpriv->status2 &= ~0x00c0; devpriv->status2 |= (s->io_bits & 0xf0) ? 0x0080 : 0; diff --git a/drivers/staging/comedi/drivers/dt2801.c b/drivers/staging/comedi/drivers/dt2801.c index e0e7beab7274b..38918a1198aa8 100644 --- a/drivers/staging/comedi/drivers/dt2801.c +++ b/drivers/staging/comedi/drivers/dt2801.c @@ -551,32 +551,19 @@ static int dt2801_dio_insn_bits(struct comedi_device *dev, static int dt2801_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { - int which = 0; + int ret; - if (s == &dev->subdevices[3]) - which = 1; + ret = comedi_dio_insn_config(dev, s, insn, data, 0xff); + if (ret) + return ret; - /* configure */ - switch (data[0]) { - case INSN_CONFIG_DIO_OUTPUT: - s->io_bits = 0xff; - dt2801_writecmd(dev, DT_C_SET_DIGOUT); - break; - case INSN_CONFIG_DIO_INPUT: - s->io_bits = 0; - dt2801_writecmd(dev, DT_C_SET_DIGIN); - break; - case INSN_CONFIG_DIO_QUERY: - data[1] = s->io_bits ? COMEDI_OUTPUT : COMEDI_INPUT; - return insn->n; - default: - return -EINVAL; - } - dt2801_writedata(dev, which); + dt2801_writecmd(dev, s->io_bits ? DT_C_SET_DIGOUT : DT_C_SET_DIGIN); + dt2801_writedata(dev, (s == &dev->subdevices[3]) ? 1 : 0); - return 1; + return insn->n; } /* diff --git a/drivers/staging/comedi/drivers/dt3000.c b/drivers/staging/comedi/drivers/dt3000.c index e4748da1993b8..64ef87598b607 100644 --- a/drivers/staging/comedi/drivers/dt3000.c +++ b/drivers/staging/comedi/drivers/dt3000.c @@ -642,32 +642,23 @@ static void dt3k_dio_config(struct comedi_device *dev, int bits) static int dt3k_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { - int mask; - - mask = (CR_CHAN(insn->chanspec) < 4) ? 0x0f : 0xf0; - - switch (data[0]) { - case INSN_CONFIG_DIO_OUTPUT: - s->io_bits |= mask; - break; - case INSN_CONFIG_DIO_INPUT: - s->io_bits &= ~mask; - break; - case INSN_CONFIG_DIO_QUERY: - data[1] = - (s-> - io_bits & (1 << CR_CHAN(insn->chanspec))) ? COMEDI_OUTPUT : - COMEDI_INPUT; - return insn->n; - break; - default: - return -EINVAL; - break; - } - mask = (s->io_bits & 0x01) | ((s->io_bits & 0x10) >> 3); - dt3k_dio_config(dev, mask); + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned int mask; + int ret; + + if (chan < 4) + mask = 0x0f; + else + mask = 0xf0; + + ret = comedi_dio_insn_config(dev, s, insn, data, mask); + if (ret) + return ret; + + dt3k_dio_config(dev, (s->io_bits & 0x01) | ((s->io_bits & 0x10) >> 3)); return insn->n; } diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c b/drivers/staging/comedi/drivers/gsc_hpdi.c index cdcc8f42e2093..559bf5583530c 100644 --- a/drivers/staging/comedi/drivers/gsc_hpdi.c +++ b/drivers/staging/comedi/drivers/gsc_hpdi.c @@ -224,37 +224,26 @@ struct hpdi_private { volatile uint32_t bits[24]; /* number of bytes at which to generate COMEDI_CB_BLOCK events */ volatile unsigned int block_size; - unsigned dio_config_output:1; }; static int dio_config_insn(struct comedi_device *dev, - struct comedi_subdevice *s, struct comedi_insn *insn, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - struct hpdi_private *devpriv = dev->private; + int ret; switch (data[0]) { - case INSN_CONFIG_DIO_OUTPUT: - devpriv->dio_config_output = 1; - return insn->n; - break; - case INSN_CONFIG_DIO_INPUT: - devpriv->dio_config_output = 0; - return insn->n; - break; - case INSN_CONFIG_DIO_QUERY: - data[1] = - devpriv->dio_config_output ? COMEDI_OUTPUT : COMEDI_INPUT; - return insn->n; - break; case INSN_CONFIG_BLOCK_SIZE: return dio_config_block_size(dev, data); - break; default: + ret = comedi_dio_insn_config(dev, s, insn, data, 0xffffffff); + if (ret) + return ret; break; } - return -EINVAL; + return insn->n; } static void disable_plx_interrupts(struct comedi_device *dev) @@ -673,9 +662,7 @@ static int di_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s, static int hpdi_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { - struct hpdi_private *devpriv = dev->private; - - if (devpriv->dio_config_output) + if (s->io_bits) return -EINVAL; else return di_cmd_test(dev, s, cmd); @@ -746,9 +733,7 @@ static int di_cmd(struct comedi_device *dev, struct comedi_subdevice *s) static int hpdi_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { - struct hpdi_private *devpriv = dev->private; - - if (devpriv->dio_config_output) + if (s->io_bits) return -EINVAL; else return di_cmd(dev, s); diff --git a/drivers/staging/comedi/drivers/ii_pci20kc.c b/drivers/staging/comedi/drivers/ii_pci20kc.c index 954c5397f33c8..5c3a318b46401 100644 --- a/drivers/staging/comedi/drivers/ii_pci20kc.c +++ b/drivers/staging/comedi/drivers/ii_pci20kc.c @@ -350,31 +350,22 @@ static int ii20k_dio_insn_config(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - unsigned int mask = 1 << CR_CHAN(insn->chanspec); - unsigned int bits; - - if (mask & 0x000000ff) - bits = 0x000000ff; - else if (mask & 0x0000ff00) - bits = 0x0000ff00; - else if (mask & 0x00ff0000) - bits = 0x00ff0000; + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned int mask; + int ret; + + if (chan < 8) + mask = 0x000000ff; + else if (chan < 16) + mask = 0x0000ff00; + else if (chan < 24) + mask = 0x00ff0000; else - bits = 0xff000000; + mask = 0xff000000; - switch (data[0]) { - case INSN_CONFIG_DIO_INPUT: - s->io_bits &= ~bits; - break; - case INSN_CONFIG_DIO_OUTPUT: - s->io_bits |= bits; - break; - case INSN_CONFIG_DIO_QUERY: - data[1] = (s->io_bits & bits) ? COMEDI_OUTPUT : COMEDI_INPUT; - return insn->n; - default: - return -EINVAL; - } + ret = comedi_dio_insn_config(dev, s, insn, data, mask); + if (ret) + return ret; ii20k_dio_config(dev, s); diff --git a/drivers/staging/comedi/drivers/me4000.c b/drivers/staging/comedi/drivers/me4000.c index 1eda40a9332ee..8f4afadab76a6 100644 --- a/drivers/staging/comedi/drivers/me4000.c +++ b/drivers/staging/comedi/drivers/me4000.c @@ -1358,98 +1358,57 @@ static int me4000_dio_insn_bits(struct comedi_device *dev, static int me4000_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { - unsigned long tmp; - int chan = CR_CHAN(insn->chanspec); + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned int mask; + unsigned int tmp; + int ret; - switch (data[0]) { - default: - return -EINVAL; - case INSN_CONFIG_DIO_QUERY: - data[1] = - (s->io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT; - return insn->n; - case INSN_CONFIG_DIO_INPUT: - case INSN_CONFIG_DIO_OUTPUT: - break; - } + if (chan < 8) + mask = 0x000000ff; + else if (chan < 16) + mask = 0x0000ff00; + else if (chan < 24) + mask = 0x00ff0000; + else + mask = 0xff000000; - /* - * The input or output configuration of each digital line is - * configured by a special insn_config instruction. chanspec - * contains the channel to be changed, and data[0] contains the - * value INSN_CONFIG_DIO_INPUT or INSN_CONFIG_DIO_OUTPUT. - * On the ME-4000 it is only possible to switch port wise (8 bit) - */ + ret = comedi_dio_insn_config(dev, s, insn, data, mask); + if (ret) + return ret; tmp = inl(dev->iobase + ME4000_DIO_CTRL_REG); + tmp &= ~(ME4000_DIO_CTRL_BIT_MODE_0 | ME4000_DIO_CTRL_BIT_MODE_1 | + ME4000_DIO_CTRL_BIT_MODE_2 | ME4000_DIO_CTRL_BIT_MODE_3 | + ME4000_DIO_CTRL_BIT_MODE_4 | ME4000_DIO_CTRL_BIT_MODE_5 | + ME4000_DIO_CTRL_BIT_MODE_6 | ME4000_DIO_CTRL_BIT_MODE_7); + if (s->io_bits & 0x000000ff) + tmp |= ME4000_DIO_CTRL_BIT_MODE_0; + if (s->io_bits & 0x0000ff00) + tmp |= ME4000_DIO_CTRL_BIT_MODE_2; + if (s->io_bits & 0x00ff0000) + tmp |= ME4000_DIO_CTRL_BIT_MODE_4; + if (s->io_bits & 0xff000000) + tmp |= ME4000_DIO_CTRL_BIT_MODE_6; - if (data[0] == INSN_CONFIG_DIO_OUTPUT) { - if (chan < 8) { - s->io_bits |= 0xFF; - tmp &= ~(ME4000_DIO_CTRL_BIT_MODE_0 | - ME4000_DIO_CTRL_BIT_MODE_1); - tmp |= ME4000_DIO_CTRL_BIT_MODE_0; - } else if (chan < 16) { - /* - * Chech for optoisolated ME-4000 version. - * If one the first port is a fixed output - * port and the second is a fixed input port. - */ - if (!inl(dev->iobase + ME4000_DIO_DIR_REG)) - return -ENODEV; - - s->io_bits |= 0xFF00; - tmp &= ~(ME4000_DIO_CTRL_BIT_MODE_2 | - ME4000_DIO_CTRL_BIT_MODE_3); - tmp |= ME4000_DIO_CTRL_BIT_MODE_2; - } else if (chan < 24) { - s->io_bits |= 0xFF0000; - tmp &= ~(ME4000_DIO_CTRL_BIT_MODE_4 | - ME4000_DIO_CTRL_BIT_MODE_5); - tmp |= ME4000_DIO_CTRL_BIT_MODE_4; - } else if (chan < 32) { - s->io_bits |= 0xFF000000; - tmp &= ~(ME4000_DIO_CTRL_BIT_MODE_6 | - ME4000_DIO_CTRL_BIT_MODE_7); - tmp |= ME4000_DIO_CTRL_BIT_MODE_6; - } else { - return -EINVAL; - } - } else { - if (chan < 8) { - /* - * Chech for optoisolated ME-4000 version. - * If one the first port is a fixed output - * port and the second is a fixed input port. - */ - if (!inl(dev->iobase + ME4000_DIO_DIR_REG)) - return -ENODEV; - - s->io_bits &= ~0xFF; - tmp &= ~(ME4000_DIO_CTRL_BIT_MODE_0 | - ME4000_DIO_CTRL_BIT_MODE_1); - } else if (chan < 16) { - s->io_bits &= ~0xFF00; - tmp &= ~(ME4000_DIO_CTRL_BIT_MODE_2 | - ME4000_DIO_CTRL_BIT_MODE_3); - } else if (chan < 24) { - s->io_bits &= ~0xFF0000; - tmp &= ~(ME4000_DIO_CTRL_BIT_MODE_4 | - ME4000_DIO_CTRL_BIT_MODE_5); - } else if (chan < 32) { - s->io_bits &= ~0xFF000000; - tmp &= ~(ME4000_DIO_CTRL_BIT_MODE_6 | - ME4000_DIO_CTRL_BIT_MODE_7); - } else { - return -EINVAL; - } + /* + * Check for optoisolated ME-4000 version. + * If one the first port is a fixed output + * port and the second is a fixed input port. + */ + if (inl(dev->iobase + ME4000_DIO_DIR_REG)) { + s->io_bits |= 0x000000ff; + s->io_bits &= ~0x0000ff00; + tmp |= ME4000_DIO_CTRL_BIT_MODE_0; + tmp &= ~(ME4000_DIO_CTRL_BIT_MODE_2 | + ME4000_DIO_CTRL_BIT_MODE_3); } outl(tmp, dev->iobase + ME4000_DIO_CTRL_REG); - return 1; + return insn->n; } /*============================================================================= diff --git a/drivers/staging/comedi/drivers/me_daq.c b/drivers/staging/comedi/drivers/me_daq.c index e8a743c2f9a16..a6f6d4a46587f 100644 --- a/drivers/staging/comedi/drivers/me_daq.c +++ b/drivers/staging/comedi/drivers/me_daq.c @@ -186,38 +186,30 @@ static int me_dio_insn_config(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct me_private_data *dev_private = dev->private; - unsigned int mask = 1 << CR_CHAN(insn->chanspec); - unsigned int bits; - unsigned int port; + struct me_private_data *devpriv = dev->private; + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned int mask; + int ret; - if (mask & 0x0000ffff) { - bits = 0x0000ffff; - port = ENABLE_PORT_A; - } else { - bits = 0xffff0000; - port = ENABLE_PORT_B; - } + if (chan < 16) + mask = 0x0000ffff; + else + mask = 0xffff0000; - switch (data[0]) { - case INSN_CONFIG_DIO_INPUT: - s->io_bits &= ~bits; - dev_private->control_2 &= ~port; - break; - case INSN_CONFIG_DIO_OUTPUT: - s->io_bits |= bits; - dev_private->control_2 |= port; - break; - case INSN_CONFIG_DIO_QUERY: - data[1] = (s->io_bits & bits) ? COMEDI_OUTPUT : COMEDI_INPUT; - return insn->n; - break; - default: - return -EINVAL; - } + ret = comedi_dio_insn_config(dev, s, insn, data, mask); + if (ret) + return ret; - /* Update the port configuration */ - writew(dev_private->control_2, dev_private->me_regbase + ME_CONTROL_2); + if (s->io_bits & 0x0000ffff) + devpriv->control_2 |= ENABLE_PORT_A; + else + devpriv->control_2 &= ~ENABLE_PORT_A; + if (s->io_bits & 0xffff0000) + devpriv->control_2 |= ENABLE_PORT_B; + else + devpriv->control_2 &= ~ENABLE_PORT_B; + + writew(devpriv->control_2, devpriv->me_regbase + ME_CONTROL_2); return insn->n; } diff --git a/drivers/staging/comedi/drivers/ni_at_ao.c b/drivers/staging/comedi/drivers/ni_at_ao.c index 0025496bc643c..b9122fd835e1e 100644 --- a/drivers/staging/comedi/drivers/ni_at_ao.c +++ b/drivers/staging/comedi/drivers/ni_at_ao.c @@ -248,42 +248,35 @@ static int atao_dio_insn_bits(struct comedi_device *dev, static int atao_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { struct atao_private *devpriv = dev->private; - int chan = CR_CHAN(insn->chanspec); - unsigned int mask, bit; - - /* The input or output configuration of each digital line is - * configured by a special insn_config instruction. chanspec - * contains the channel to be changed, and data[0] contains the - * value COMEDI_INPUT or COMEDI_OUTPUT. */ - - mask = (chan < 4) ? 0x0f : 0xf0; - bit = (chan < 4) ? DOUTEN1 : DOUTEN2; - - switch (data[0]) { - case INSN_CONFIG_DIO_OUTPUT: - s->io_bits |= mask; - devpriv->cfg3 |= bit; - break; - case INSN_CONFIG_DIO_INPUT: - s->io_bits &= ~mask; - devpriv->cfg3 &= ~bit; - break; - case INSN_CONFIG_DIO_QUERY: - data[1] = - (s->io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT; - return insn->n; - break; - default: - return -EINVAL; - break; - } + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned int mask; + int ret; + + if (chan < 4) + mask = 0x0f; + else + mask = 0xf0; + + ret = comedi_dio_insn_config(dev, s, insn, data, mask); + if (ret) + return ret; + + if (s->io_bits & 0x0f) + devpriv->cfg3 |= DOUTEN1; + else + devpriv->cfg3 &= ~DOUTEN1; + if (s->io_bits & 0xf0) + devpriv->cfg3 |= DOUTEN2; + else + devpriv->cfg3 &= ~DOUTEN2; outw(devpriv->cfg3, dev->iobase + ATAO_CFG3); - return 1; + return insn->n; } /* diff --git a/drivers/staging/comedi/drivers/pcm3724.c b/drivers/staging/comedi/drivers/pcm3724.c index cca972ebd010e..cc1dc7f66e5b5 100644 --- a/drivers/staging/comedi/drivers/pcm3724.c +++ b/drivers/staging/comedi/drivers/pcm3724.c @@ -184,39 +184,30 @@ static void enable_chan(struct comedi_device *dev, struct comedi_subdevice *s, /* overriding the 8255 insn config */ static int subdev_3724_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { + unsigned int chan = CR_CHAN(insn->chanspec); unsigned int mask; - unsigned int bits; - - mask = 1 << CR_CHAN(insn->chanspec); - if (mask & 0x0000ff) - bits = 0x0000ff; - else if (mask & 0x00ff00) - bits = 0x00ff00; - else if (mask & 0x0f0000) - bits = 0x0f0000; + int ret; + + if (chan < 8) + mask = 0x0000ff; + else if (chan < 16) + mask = 0x00ff00; + else if (chan < 20) + mask = 0x0f0000; else - bits = 0xf00000; - - switch (data[0]) { - case INSN_CONFIG_DIO_INPUT: - s->io_bits &= ~bits; - break; - case INSN_CONFIG_DIO_OUTPUT: - s->io_bits |= bits; - break; - case INSN_CONFIG_DIO_QUERY: - data[1] = (s->io_bits & bits) ? COMEDI_OUTPUT : COMEDI_INPUT; - return insn->n; - break; - default: - return -EINVAL; - } + mask = 0xf00000; + + ret = comedi_dio_insn_config(dev, s, insn, data, mask); + if (ret) + return ret; do_3724_config(dev, s, insn->chanspec); enable_chan(dev, s, insn->chanspec); - return 1; + + return insn->n; } static int pcm3724_attach(struct comedi_device *dev, diff --git a/drivers/staging/comedi/drivers/s526.c b/drivers/staging/comedi/drivers/s526.c index 6670b865256b3..d629463b85a2a 100644 --- a/drivers/staging/comedi/drivers/s526.c +++ b/drivers/staging/comedi/drivers/s526.c @@ -515,32 +515,35 @@ static int s526_dio_insn_bits(struct comedi_device *dev, static int s526_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { unsigned int chan = CR_CHAN(insn->chanspec); - int group, mask; + unsigned int mask; + int ret; + + if (chan < 4) + mask = 0x0f; + else + mask = 0xf0; + + ret = comedi_dio_insn_config(dev, s, insn, data, mask); + if (ret) + return ret; + + /* bit 10/11 set the group 1/2's mode */ + if (s->io_bits & 0x0f) + s->state |= (1 << 10); + else + s->state &= ~(1 << 10); + if (s->io_bits & 0xf0) + s->state |= (1 << 11); + else + s->state &= ~(1 << 11); - group = chan >> 2; - mask = 0xF << (group << 2); - switch (data[0]) { - case INSN_CONFIG_DIO_OUTPUT: - /* bit 10/11 set the group 1/2's mode */ - s->state |= 1 << (group + 10); - s->io_bits |= mask; - break; - case INSN_CONFIG_DIO_INPUT: - s->state &= ~(1 << (group + 10)); /* 1 is output, 0 is input. */ - s->io_bits &= ~mask; - break; - case INSN_CONFIG_DIO_QUERY: - data[1] = (s->io_bits & mask) ? COMEDI_OUTPUT : COMEDI_INPUT; - return insn->n; - default: - return -EINVAL; - } outw(s->state, dev->iobase + REG_DIO); - return 1; + return insn->n; } static int s526_attach(struct comedi_device *dev, struct comedi_devconfig *it) -- GitLab From 96256460487387d28b8398033928e06eb9e428f7 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 12 Aug 2013 15:07:49 -0700 Subject: [PATCH 597/942] staging: zcache: delete it zcache is obsolete and not used anymore, Bob Liu has rewritten it and is submitting it for inclusion through the main -mm tree, as it should have been done in the first place... Cc: Bob Liu Cc: Konrad Rzeszutek Wilk Cc: Kyungmin Park Cc: Wanpeng Li Signed-off-by: Greg Kroah-Hartman --- drivers/staging/Kconfig | 2 - drivers/staging/Makefile | 1 - drivers/staging/zcache/Kconfig | 59 - drivers/staging/zcache/Makefile | 8 - drivers/staging/zcache/TODO | 64 - drivers/staging/zcache/debug.c | 107 - drivers/staging/zcache/debug.h | 305 --- drivers/staging/zcache/ramster.h | 59 - drivers/staging/zcache/ramster/debug.c | 68 - drivers/staging/zcache/ramster/debug.h | 145 -- drivers/staging/zcache/ramster/heartbeat.c | 462 ---- drivers/staging/zcache/ramster/heartbeat.h | 87 - drivers/staging/zcache/ramster/masklog.c | 155 -- drivers/staging/zcache/ramster/masklog.h | 220 -- drivers/staging/zcache/ramster/nodemanager.c | 996 -------- drivers/staging/zcache/ramster/nodemanager.h | 88 - drivers/staging/zcache/ramster/r2net.c | 414 --- .../staging/zcache/ramster/ramster-howto.txt | 366 --- drivers/staging/zcache/ramster/ramster.c | 925 ------- drivers/staging/zcache/ramster/ramster.h | 161 -- .../zcache/ramster/ramster_nodemanager.h | 41 - drivers/staging/zcache/ramster/tcp.c | 2251 ----------------- drivers/staging/zcache/ramster/tcp.h | 159 -- drivers/staging/zcache/ramster/tcp_internal.h | 248 -- drivers/staging/zcache/tmem.c | 898 ------- drivers/staging/zcache/tmem.h | 259 -- drivers/staging/zcache/zbud.c | 1066 -------- drivers/staging/zcache/zbud.h | 33 - drivers/staging/zcache/zcache-main.c | 1943 -------------- drivers/staging/zcache/zcache.h | 53 - 30 files changed, 11643 deletions(-) delete mode 100644 drivers/staging/zcache/Kconfig delete mode 100644 drivers/staging/zcache/Makefile delete mode 100644 drivers/staging/zcache/TODO delete mode 100644 drivers/staging/zcache/debug.c delete mode 100644 drivers/staging/zcache/debug.h delete mode 100644 drivers/staging/zcache/ramster.h delete mode 100644 drivers/staging/zcache/ramster/debug.c delete mode 100644 drivers/staging/zcache/ramster/debug.h delete mode 100644 drivers/staging/zcache/ramster/heartbeat.c delete mode 100644 drivers/staging/zcache/ramster/heartbeat.h delete mode 100644 drivers/staging/zcache/ramster/masklog.c delete mode 100644 drivers/staging/zcache/ramster/masklog.h delete mode 100644 drivers/staging/zcache/ramster/nodemanager.c delete mode 100644 drivers/staging/zcache/ramster/nodemanager.h delete mode 100644 drivers/staging/zcache/ramster/r2net.c delete mode 100644 drivers/staging/zcache/ramster/ramster-howto.txt delete mode 100644 drivers/staging/zcache/ramster/ramster.c delete mode 100644 drivers/staging/zcache/ramster/ramster.h delete mode 100644 drivers/staging/zcache/ramster/ramster_nodemanager.h delete mode 100644 drivers/staging/zcache/ramster/tcp.c delete mode 100644 drivers/staging/zcache/ramster/tcp.h delete mode 100644 drivers/staging/zcache/ramster/tcp_internal.h delete mode 100644 drivers/staging/zcache/tmem.c delete mode 100644 drivers/staging/zcache/tmem.h delete mode 100644 drivers/staging/zcache/zbud.c delete mode 100644 drivers/staging/zcache/zbud.h delete mode 100644 drivers/staging/zcache/zcache-main.c delete mode 100644 drivers/staging/zcache/zcache.h diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index 869c488cfb72d..1665705e3e910 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -130,8 +130,6 @@ source "drivers/staging/sb105x/Kconfig" source "drivers/staging/fwserial/Kconfig" -source "drivers/staging/zcache/Kconfig" - source "drivers/staging/goldfish/Kconfig" source "drivers/staging/netlogic/Kconfig" diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index ca14ab70b7550..3f18f414f952a 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -58,7 +58,6 @@ obj-$(CONFIG_DRM_IMX) += imx-drm/ obj-$(CONFIG_DGRP) += dgrp/ obj-$(CONFIG_SB105X) += sb105x/ obj-$(CONFIG_FIREWIRE_SERIAL) += fwserial/ -obj-$(CONFIG_ZCACHE) += zcache/ obj-$(CONFIG_GOLDFISH) += goldfish/ obj-$(CONFIG_USB_DWC2) += dwc2/ obj-$(CONFIG_LUSTRE_FS) += lustre/ diff --git a/drivers/staging/zcache/Kconfig b/drivers/staging/zcache/Kconfig deleted file mode 100644 index 2d7b2da3b9e0a..0000000000000 --- a/drivers/staging/zcache/Kconfig +++ /dev/null @@ -1,59 +0,0 @@ -config ZCACHE - tristate "Dynamic compression of swap pages and clean pagecache pages" - depends on CRYPTO=y && SWAP=y && CLEANCACHE && FRONTSWAP - select CRYPTO_LZO - default n - help - Zcache doubles RAM efficiency while providing a significant - performance boosts on many workloads. Zcache uses - compression and an in-kernel implementation of transcendent - memory to store clean page cache pages and swap in RAM, - providing a noticeable reduction in disk I/O. - -config ZCACHE_DEBUG - bool "Enable debug statistics" - depends on DEBUG_FS && ZCACHE - default n - help - This is used to provide an debugfs directory with counters of - how zcache is doing. You probably want to set this to 'N'. - -config RAMSTER - tristate "Cross-machine RAM capacity sharing, aka peer-to-peer tmem" - depends on CONFIGFS_FS=y && SYSFS=y && !HIGHMEM && ZCACHE - depends on NET - # must ensure struct page is 8-byte aligned - select HAVE_ALIGNED_STRUCT_PAGE if !64BIT - default n - help - RAMster allows RAM on other machines in a cluster to be utilized - dynamically and symmetrically instead of swapping to a local swap - disk, thus improving performance on memory-constrained workloads - while minimizing total RAM across the cluster. RAMster, like - zcache2, compresses swap pages into local RAM, but then remotifies - the compressed pages to another node in the RAMster cluster. - -config RAMSTER_DEBUG - bool "Enable ramster debug statistics" - depends on DEBUG_FS && RAMSTER - default n - help - This is used to provide an debugfs directory with counters of - how ramster is doing. You probably want to set this to 'N'. - -# Depends on not-yet-upstreamed mm patches to export end_swap_bio_write and -# __add_to_swap_cache, and implement __swap_writepage (which is swap_writepage -# without the frontswap call. When these are in-tree, the dependency on -# BROKEN can be removed -config ZCACHE_WRITEBACK - bool "Allow compressed swap pages to be writtenback to swap disk" - depends on ZCACHE=y && BROKEN - default n - help - Zcache caches compressed swap pages (and other data) in RAM which - often improves performance by avoiding I/O's due to swapping. - In some workloads with very long-lived large processes, it can - instead reduce performance. Writeback decompresses zcache-compressed - pages (in LRU order) when under memory pressure and writes them to - the backing swap disk to ameliorate this problem. Policy driving - writeback is still under development. diff --git a/drivers/staging/zcache/Makefile b/drivers/staging/zcache/Makefile deleted file mode 100644 index 845a5c2721b53..0000000000000 --- a/drivers/staging/zcache/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -zcache-y := zcache-main.o tmem.o zbud.o -zcache-$(CONFIG_ZCACHE_DEBUG) += debug.o -zcache-$(CONFIG_RAMSTER_DEBUG) += ramster/debug.o -zcache-$(CONFIG_RAMSTER) += ramster/ramster.o ramster/r2net.o -zcache-$(CONFIG_RAMSTER) += ramster/nodemanager.o ramster/tcp.o -zcache-$(CONFIG_RAMSTER) += ramster/heartbeat.o ramster/masklog.o - -obj-$(CONFIG_ZCACHE) += zcache.o diff --git a/drivers/staging/zcache/TODO b/drivers/staging/zcache/TODO deleted file mode 100644 index d0c18fa957435..0000000000000 --- a/drivers/staging/zcache/TODO +++ /dev/null @@ -1,64 +0,0 @@ - -** ZCACHE PLAN FOR PROMOTION FROM STAGING ** - -Last updated: Feb 13, 2013 - -PLAN STEPS - -1. merge zcache and ramster to eliminate horrible code duplication -2. converge on a predictable, writeback-capable allocator -3. use debugfs instead of sysfs (per akpm feedback in 2011) -4. zcache side of cleancache/mm WasActive patch -5. zcache side of frontswap exclusive gets -6. zcache must be able to writeback to physical swap disk - (per Andrea Arcangeli feedback in 2011) -7. implement adequate policy for writeback -8. frontswap/cleancache work to allow zcache to be loaded - as a module -9. get core mm developer to review -10. incorporate feedback from review -11. get review/acks from 1-2 additional mm developers -12. incorporate any feedback from additional mm reviews -13. propose location/file-naming in mm tree -14. repeat 9-13 as necessary until akpm is happy and merges - -STATUS/OWNERSHIP - -1. DONE as part of "new" zcache; in staging/zcache for 3.9 -2. DONE as part of "new" zcache (cf zbud.[ch]); in staging/zcache for 3.9 - (this was the core of the zcache1 vs zcache2 flail) -3. DONE as part of "new" zcache; in staging/zcache for 3.9 -4. DONE (w/caveats) as part of "new" zcache; per cleancache performance - feedback see https://lkml.org/lkml/2011/8/17/351, in - staging/zcache for 3.9; dependent on proposed mm patch, see - https://lkml.org/lkml/2012/1/25/300 -5. DONE as part of "new" zcache; performance tuning only, - in staging/zcache for 3.9; dependent on frontswap patch - merged in 3.7 (33c2a174) -6. DONE (w/caveats), prototyped as part of "new" zcache, had - bad memory leak; reimplemented to use sjennings clever tricks - and proposed mm patches with new version in staging/zcache - for 3.9, see https://lkml.org/lkml/2013/2/6/437; -7. PROTOTYPED as part of "new" zcache; in staging/zcache for 3.9; - needs more review (plan to discuss at LSF/MM 2013) -9. IN PROGRESS; owned by Konrad Wilk; Mel Gorman provided - great feedback in August 2012 (unfortunately of "old" - zcache) -11. NOT DONE; owned by Konrad Wilk and Bob Liu -12. TBD (depends on quantity of feedback) -13. PROPOSED; one suggestion proposed by Dan; needs more ideas/feedback -14. TBD (depends on feedback) - -WHO NEEDS TO AGREE - -Not sure. Seth Jennings is now pursuing a separate but semi-parallel -track. Akpm clearly has to approve for any mm merge to happen. Minchan -Kim has interest but may be happy if/when zram is merged into mm. Konrad -Wilk may be maintainer if akpm decides compression is maintainable -separately from the rest of mm. (More LSF/MM 2013 discussion.) - -ZCACHE FUTURE NEW FUNCTIONALITY - -A. Support zsmalloc as an alternative high-density allocator - (See https://lkml.org/lkml/2013/1/23/511) -B. Possibly support three zbuds per pageframe when space allows diff --git a/drivers/staging/zcache/debug.c b/drivers/staging/zcache/debug.c deleted file mode 100644 index daa26919b8868..0000000000000 --- a/drivers/staging/zcache/debug.c +++ /dev/null @@ -1,107 +0,0 @@ -#include -#include "debug.h" - -#ifdef CONFIG_ZCACHE_DEBUG -#include - -ssize_t zcache_obj_count; -ssize_t zcache_obj_count_max; -ssize_t zcache_objnode_count; -ssize_t zcache_objnode_count_max; -u64 zcache_eph_zbytes; -u64 zcache_eph_zbytes_max; -u64 zcache_pers_zbytes_max; -ssize_t zcache_eph_pageframes_max; -ssize_t zcache_pers_pageframes_max; -ssize_t zcache_pageframes_alloced; -ssize_t zcache_pageframes_freed; -ssize_t zcache_eph_zpages; -ssize_t zcache_eph_zpages_max; -ssize_t zcache_pers_zpages_max; -ssize_t zcache_flush_total; -ssize_t zcache_flush_found; -ssize_t zcache_flobj_total; -ssize_t zcache_flobj_found; -ssize_t zcache_failed_eph_puts; -ssize_t zcache_failed_pers_puts; -ssize_t zcache_failed_getfreepages; -ssize_t zcache_failed_alloc; -ssize_t zcache_put_to_flush; -ssize_t zcache_compress_poor; -ssize_t zcache_mean_compress_poor; -ssize_t zcache_eph_ate_tail; -ssize_t zcache_eph_ate_tail_failed; -ssize_t zcache_pers_ate_eph; -ssize_t zcache_pers_ate_eph_failed; -ssize_t zcache_evicted_eph_zpages; -ssize_t zcache_evicted_eph_pageframes; -ssize_t zcache_zero_filled_pages; -ssize_t zcache_zero_filled_pages_max; - -#define ATTR(x) { .name = #x, .val = &zcache_##x, } -static struct debug_entry { - const char *name; - ssize_t *val; -} attrs[] = { - ATTR(obj_count), ATTR(obj_count_max), - ATTR(objnode_count), ATTR(objnode_count_max), - ATTR(flush_total), ATTR(flush_found), - ATTR(flobj_total), ATTR(flobj_found), - ATTR(failed_eph_puts), ATTR(failed_pers_puts), - ATTR(failed_getfreepages), ATTR(failed_alloc), - ATTR(put_to_flush), - ATTR(compress_poor), ATTR(mean_compress_poor), - ATTR(eph_ate_tail), ATTR(eph_ate_tail_failed), - ATTR(pers_ate_eph), ATTR(pers_ate_eph_failed), - ATTR(evicted_eph_zpages), ATTR(evicted_eph_pageframes), - ATTR(eph_pageframes), ATTR(eph_pageframes_max), - ATTR(pers_pageframes), ATTR(pers_pageframes_max), - ATTR(eph_zpages), ATTR(eph_zpages_max), - ATTR(pers_zpages), ATTR(pers_zpages_max), - ATTR(last_active_file_pageframes), - ATTR(last_inactive_file_pageframes), - ATTR(last_active_anon_pageframes), - ATTR(last_inactive_anon_pageframes), - ATTR(eph_nonactive_puts_ignored), - ATTR(pers_nonactive_puts_ignored), - ATTR(zero_filled_pages), -#ifdef CONFIG_ZCACHE_WRITEBACK - ATTR(outstanding_writeback_pages), - ATTR(writtenback_pages), -#endif -}; -#undef ATTR -int zcache_debugfs_init(void) -{ - unsigned int i; - struct dentry *root = debugfs_create_dir("zcache", NULL); - if (root == NULL) - return -ENXIO; - - for (i = 0; i < ARRAY_SIZE(attrs); i++) - if (!debugfs_create_size_t(attrs[i].name, S_IRUGO, root, attrs[i].val)) - goto out; - - debugfs_create_u64("eph_zbytes", S_IRUGO, root, &zcache_eph_zbytes); - debugfs_create_u64("eph_zbytes_max", S_IRUGO, root, &zcache_eph_zbytes_max); - debugfs_create_u64("pers_zbytes", S_IRUGO, root, &zcache_pers_zbytes); - debugfs_create_u64("pers_zbytes_max", S_IRUGO, root, &zcache_pers_zbytes_max); - - return 0; -out: - return -ENODEV; -} - -/* developers can call this in case of ooms, e.g. to find memory leaks */ -void zcache_dump(void) -{ - unsigned int i; - for (i = 0; i < ARRAY_SIZE(attrs); i++) - pr_debug("zcache: %s=%zu\n", attrs[i].name, *attrs[i].val); - - pr_debug("zcache: eph_zbytes=%llu\n", (unsigned long long)zcache_eph_zbytes); - pr_debug("zcache: eph_zbytes_max=%llu\n", (unsigned long long)zcache_eph_zbytes_max); - pr_debug("zcache: pers_zbytes=%llu\n", (unsigned long long)zcache_pers_zbytes); - pr_debug("zcache: pers_zbytes_max=%llu\n", (unsigned long long)zcache_pers_zbytes_max); -} -#endif diff --git a/drivers/staging/zcache/debug.h b/drivers/staging/zcache/debug.h deleted file mode 100644 index 8088d28f2dcea..0000000000000 --- a/drivers/staging/zcache/debug.h +++ /dev/null @@ -1,305 +0,0 @@ -#include - -#ifdef CONFIG_ZCACHE_DEBUG - -/* we try to keep these statistics SMP-consistent */ -extern ssize_t zcache_obj_count; -static atomic_t zcache_obj_atomic = ATOMIC_INIT(0); -extern ssize_t zcache_obj_count_max; -static inline void inc_zcache_obj_count(void) -{ - zcache_obj_count = atomic_inc_return(&zcache_obj_atomic); - if (zcache_obj_count > zcache_obj_count_max) - zcache_obj_count_max = zcache_obj_count; -} -static inline void dec_zcache_obj_count(void) -{ - zcache_obj_count = atomic_dec_return(&zcache_obj_atomic); - BUG_ON(zcache_obj_count < 0); -}; -extern ssize_t zcache_objnode_count; -static atomic_t zcache_objnode_atomic = ATOMIC_INIT(0); -extern ssize_t zcache_objnode_count_max; -static inline void inc_zcache_objnode_count(void) -{ - zcache_objnode_count = atomic_inc_return(&zcache_objnode_atomic); - if (zcache_objnode_count > zcache_objnode_count_max) - zcache_objnode_count_max = zcache_objnode_count; -}; -static inline void dec_zcache_objnode_count(void) -{ - zcache_objnode_count = atomic_dec_return(&zcache_objnode_atomic); - BUG_ON(zcache_objnode_count < 0); -}; -extern u64 zcache_eph_zbytes; -static atomic_long_t zcache_eph_zbytes_atomic = ATOMIC_INIT(0); -extern u64 zcache_eph_zbytes_max; -static inline void inc_zcache_eph_zbytes(unsigned clen) -{ - zcache_eph_zbytes = atomic_long_add_return(clen, &zcache_eph_zbytes_atomic); - if (zcache_eph_zbytes > zcache_eph_zbytes_max) - zcache_eph_zbytes_max = zcache_eph_zbytes; -}; -static inline void dec_zcache_eph_zbytes(unsigned zsize) -{ - zcache_eph_zbytes = atomic_long_sub_return(zsize, &zcache_eph_zbytes_atomic); -}; -extern u64 zcache_pers_zbytes; -static atomic_long_t zcache_pers_zbytes_atomic = ATOMIC_INIT(0); -extern u64 zcache_pers_zbytes_max; -static inline void inc_zcache_pers_zbytes(unsigned clen) -{ - zcache_pers_zbytes = atomic_long_add_return(clen, &zcache_pers_zbytes_atomic); - if (zcache_pers_zbytes > zcache_pers_zbytes_max) - zcache_pers_zbytes_max = zcache_pers_zbytes; -} -static inline void dec_zcache_pers_zbytes(unsigned zsize) -{ - zcache_pers_zbytes = atomic_long_sub_return(zsize, &zcache_pers_zbytes_atomic); -} -extern ssize_t zcache_eph_pageframes; -static atomic_t zcache_eph_pageframes_atomic = ATOMIC_INIT(0); -extern ssize_t zcache_eph_pageframes_max; -static inline void inc_zcache_eph_pageframes(void) -{ - zcache_eph_pageframes = atomic_inc_return(&zcache_eph_pageframes_atomic); - if (zcache_eph_pageframes > zcache_eph_pageframes_max) - zcache_eph_pageframes_max = zcache_eph_pageframes; -}; -static inline void dec_zcache_eph_pageframes(void) -{ - zcache_eph_pageframes = atomic_dec_return(&zcache_eph_pageframes_atomic); -}; -extern ssize_t zcache_pers_pageframes; -static atomic_t zcache_pers_pageframes_atomic = ATOMIC_INIT(0); -extern ssize_t zcache_pers_pageframes_max; -static inline void inc_zcache_pers_pageframes(void) -{ - zcache_pers_pageframes = atomic_inc_return(&zcache_pers_pageframes_atomic); - if (zcache_pers_pageframes > zcache_pers_pageframes_max) - zcache_pers_pageframes_max = zcache_pers_pageframes; -} -static inline void dec_zcache_pers_pageframes(void) -{ - zcache_pers_pageframes = atomic_dec_return(&zcache_pers_pageframes_atomic); -} -extern ssize_t zcache_pageframes_alloced; -static atomic_t zcache_pageframes_alloced_atomic = ATOMIC_INIT(0); -static inline void inc_zcache_pageframes_alloced(void) -{ - zcache_pageframes_alloced = atomic_inc_return(&zcache_pageframes_alloced_atomic); -}; -extern ssize_t zcache_pageframes_freed; -static atomic_t zcache_pageframes_freed_atomic = ATOMIC_INIT(0); -static inline void inc_zcache_pageframes_freed(void) -{ - zcache_pageframes_freed = atomic_inc_return(&zcache_pageframes_freed_atomic); -} -extern ssize_t zcache_eph_zpages; -static atomic_t zcache_eph_zpages_atomic = ATOMIC_INIT(0); -extern ssize_t zcache_eph_zpages_max; -static inline void inc_zcache_eph_zpages(void) -{ - zcache_eph_zpages = atomic_inc_return(&zcache_eph_zpages_atomic); - if (zcache_eph_zpages > zcache_eph_zpages_max) - zcache_eph_zpages_max = zcache_eph_zpages; -} -static inline void dec_zcache_eph_zpages(unsigned zpages) -{ - zcache_eph_zpages = atomic_sub_return(zpages, &zcache_eph_zpages_atomic); -} -extern ssize_t zcache_pers_zpages; -static atomic_t zcache_pers_zpages_atomic = ATOMIC_INIT(0); -extern ssize_t zcache_pers_zpages_max; -static inline void inc_zcache_pers_zpages(void) -{ - zcache_pers_zpages = atomic_inc_return(&zcache_pers_zpages_atomic); - if (zcache_pers_zpages > zcache_pers_zpages_max) - zcache_pers_zpages_max = zcache_pers_zpages; -} -static inline void dec_zcache_pers_zpages(unsigned zpages) -{ - zcache_pers_zpages = atomic_sub_return(zpages, &zcache_pers_zpages_atomic); -} - -extern ssize_t zcache_zero_filled_pages; -static atomic_t zcache_zero_filled_pages_atomic = ATOMIC_INIT(0); -extern ssize_t zcache_zero_filled_pages_max; -static inline void inc_zcache_zero_filled_pages(void) -{ - zcache_zero_filled_pages = atomic_inc_return( - &zcache_zero_filled_pages_atomic); - if (zcache_zero_filled_pages > zcache_zero_filled_pages_max) - zcache_zero_filled_pages_max = zcache_zero_filled_pages; -} -static inline void dec_zcache_zero_filled_pages(void) -{ - zcache_zero_filled_pages = atomic_dec_return( - &zcache_zero_filled_pages_atomic); -} -static inline unsigned long curr_pageframes_count(void) -{ - return zcache_pageframes_alloced - - atomic_read(&zcache_pageframes_freed_atomic) - - atomic_read(&zcache_eph_pageframes_atomic) - - atomic_read(&zcache_pers_pageframes_atomic); -}; -/* but for the rest of these, counting races are ok */ -extern ssize_t zcache_flush_total; -extern ssize_t zcache_flush_found; -extern ssize_t zcache_flobj_total; -extern ssize_t zcache_flobj_found; -extern ssize_t zcache_failed_eph_puts; -extern ssize_t zcache_failed_pers_puts; -extern ssize_t zcache_failed_getfreepages; -extern ssize_t zcache_failed_alloc; -extern ssize_t zcache_put_to_flush; -extern ssize_t zcache_compress_poor; -extern ssize_t zcache_mean_compress_poor; -extern ssize_t zcache_eph_ate_tail; -extern ssize_t zcache_eph_ate_tail_failed; -extern ssize_t zcache_pers_ate_eph; -extern ssize_t zcache_pers_ate_eph_failed; -extern ssize_t zcache_evicted_eph_zpages; -extern ssize_t zcache_evicted_eph_pageframes; - -extern ssize_t zcache_last_active_file_pageframes; -extern ssize_t zcache_last_inactive_file_pageframes; -extern ssize_t zcache_last_active_anon_pageframes; -extern ssize_t zcache_last_inactive_anon_pageframes; -static ssize_t zcache_eph_nonactive_puts_ignored; -static ssize_t zcache_pers_nonactive_puts_ignored; -#ifdef CONFIG_ZCACHE_WRITEBACK -extern ssize_t zcache_writtenback_pages; -extern ssize_t zcache_outstanding_writeback_pages; -#endif - -static inline void inc_zcache_flush_total(void) -{ - zcache_flush_total++; -}; -static inline void inc_zcache_flush_found(void) -{ - zcache_flush_found++; -}; -static inline void inc_zcache_flobj_total(void) -{ - zcache_flobj_total++; -}; -static inline void inc_zcache_flobj_found(void) -{ - zcache_flobj_found++; -}; -static inline void inc_zcache_failed_eph_puts(void) -{ - zcache_failed_eph_puts++; -}; -static inline void inc_zcache_failed_pers_puts(void) -{ - zcache_failed_pers_puts++; -}; -static inline void inc_zcache_failed_getfreepages(void) -{ - zcache_failed_getfreepages++; -}; -static inline void inc_zcache_failed_alloc(void) -{ - zcache_failed_alloc++; -}; -static inline void inc_zcache_put_to_flush(void) -{ - zcache_put_to_flush++; -}; -static inline void inc_zcache_compress_poor(void) -{ - zcache_compress_poor++; -}; -static inline void inc_zcache_mean_compress_poor(void) -{ - zcache_mean_compress_poor++; -}; -static inline void inc_zcache_eph_ate_tail(void) -{ - zcache_eph_ate_tail++; -}; -static inline void inc_zcache_eph_ate_tail_failed(void) -{ - zcache_eph_ate_tail_failed++; -}; -static inline void inc_zcache_pers_ate_eph(void) -{ - zcache_pers_ate_eph++; -}; -static inline void inc_zcache_pers_ate_eph_failed(void) -{ - zcache_pers_ate_eph_failed++; -}; -static inline void inc_zcache_evicted_eph_zpages(unsigned zpages) -{ - zcache_evicted_eph_zpages += zpages; -}; -static inline void inc_zcache_evicted_eph_pageframes(void) -{ - zcache_evicted_eph_pageframes++; -}; - -static inline void inc_zcache_eph_nonactive_puts_ignored(void) -{ - zcache_eph_nonactive_puts_ignored++; -}; -static inline void inc_zcache_pers_nonactive_puts_ignored(void) -{ - zcache_pers_nonactive_puts_ignored++; -}; - -int zcache_debugfs_init(void); -#else -static inline void inc_zcache_obj_count(void) { }; -static inline void dec_zcache_obj_count(void) { }; -static inline void inc_zcache_objnode_count(void) { }; -static inline void dec_zcache_objnode_count(void) { }; -static inline void inc_zcache_eph_zbytes(unsigned clen) { }; -static inline void dec_zcache_eph_zbytes(unsigned zsize) { }; -static inline void inc_zcache_pers_zbytes(unsigned clen) { }; -static inline void dec_zcache_pers_zbytes(unsigned zsize) { }; -static inline void inc_zcache_eph_pageframes(void) { }; -static inline void dec_zcache_eph_pageframes(void) { }; -static inline void inc_zcache_pers_pageframes(void) { }; -static inline void dec_zcache_pers_pageframes(void) { }; -static inline void inc_zcache_pageframes_alloced(void) { }; -static inline void inc_zcache_pageframes_freed(void) { }; -static inline void inc_zcache_eph_zpages(void) { }; -static inline void dec_zcache_eph_zpages(unsigned zpages) { }; -static inline void inc_zcache_pers_zpages(void) { }; -static inline void dec_zcache_pers_zpages(unsigned zpages) { }; -static inline void inc_zcache_zero_filled_pages(void) { }; -static inline void dec_zcache_zero_filled_pages(void) { }; -static inline unsigned long curr_pageframes_count(void) -{ - return 0; -}; -static inline int zcache_debugfs_init(void) -{ - return 0; -}; -static inline void inc_zcache_flush_total(void) { }; -static inline void inc_zcache_flush_found(void) { }; -static inline void inc_zcache_flobj_total(void) { }; -static inline void inc_zcache_flobj_found(void) { }; -static inline void inc_zcache_failed_eph_puts(void) { }; -static inline void inc_zcache_failed_pers_puts(void) { }; -static inline void inc_zcache_failed_getfreepages(void) { }; -static inline void inc_zcache_failed_alloc(void) { }; -static inline void inc_zcache_put_to_flush(void) { }; -static inline void inc_zcache_compress_poor(void) { }; -static inline void inc_zcache_mean_compress_poor(void) { }; -static inline void inc_zcache_eph_ate_tail(void) { }; -static inline void inc_zcache_eph_ate_tail_failed(void) { }; -static inline void inc_zcache_pers_ate_eph(void) { }; -static inline void inc_zcache_pers_ate_eph_failed(void) { }; -static inline void inc_zcache_evicted_eph_zpages(unsigned zpages) { }; -static inline void inc_zcache_evicted_eph_pageframes(void) { }; - -static inline void inc_zcache_eph_nonactive_puts_ignored(void) { }; -static inline void inc_zcache_pers_nonactive_puts_ignored(void) { }; -#endif diff --git a/drivers/staging/zcache/ramster.h b/drivers/staging/zcache/ramster.h deleted file mode 100644 index a858666eae68f..0000000000000 --- a/drivers/staging/zcache/ramster.h +++ /dev/null @@ -1,59 +0,0 @@ - -/* - * zcache/ramster.h - * - * Placeholder to resolve ramster references when !CONFIG_RAMSTER - * Real ramster.h lives in ramster subdirectory. - * - * Copyright (c) 2009-2012, Dan Magenheimer, Oracle Corp. - */ - -#ifndef _ZCACHE_RAMSTER_H_ -#define _ZCACHE_RAMSTER_H_ - -#ifdef CONFIG_RAMSTER -#include "ramster/ramster.h" -#else -static inline void ramster_init(bool x, bool y, bool z, bool w) -{ -} - -static inline void ramster_register_pamops(struct tmem_pamops *p) -{ -} - -static inline int ramster_remotify_pageframe(bool b) -{ - return 0; -} - -static inline void *ramster_pampd_free(void *v, struct tmem_pool *p, - struct tmem_oid *o, uint32_t u, bool b) -{ - return NULL; -} - -static inline int ramster_do_preload_flnode(struct tmem_pool *p) -{ - return -1; -} - -static inline bool pampd_is_remote(void *v) -{ - return false; -} - -static inline void ramster_count_foreign_pages(bool b, int i) -{ -} - -static inline void ramster_cpu_up(int cpu) -{ -} - -static inline void ramster_cpu_down(int cpu) -{ -} -#endif - -#endif /* _ZCACHE_RAMSTER_H */ diff --git a/drivers/staging/zcache/ramster/debug.c b/drivers/staging/zcache/ramster/debug.c deleted file mode 100644 index 5b26ee977c2f3..0000000000000 --- a/drivers/staging/zcache/ramster/debug.c +++ /dev/null @@ -1,68 +0,0 @@ -#include -#include "debug.h" - -ssize_t ramster_foreign_eph_pages; -ssize_t ramster_foreign_pers_pages; -#ifdef CONFIG_DEBUG_FS -#include - -ssize_t ramster_eph_pages_remoted; -ssize_t ramster_pers_pages_remoted; -ssize_t ramster_eph_pages_remote_failed; -ssize_t ramster_pers_pages_remote_failed; -ssize_t ramster_remote_eph_pages_succ_get; -ssize_t ramster_remote_pers_pages_succ_get; -ssize_t ramster_remote_eph_pages_unsucc_get; -ssize_t ramster_remote_pers_pages_unsucc_get; -ssize_t ramster_pers_pages_remote_nomem; -ssize_t ramster_remote_objects_flushed; -ssize_t ramster_remote_object_flushes_failed; -ssize_t ramster_remote_pages_flushed; -ssize_t ramster_remote_page_flushes_failed; - -#define ATTR(x) { .name = #x, .val = &ramster_##x, } -static struct debug_entry { - const char *name; - ssize_t *val; -} attrs[] = { - ATTR(eph_pages_remoted), - ATTR(pers_pages_remoted), - ATTR(eph_pages_remote_failed), - ATTR(pers_pages_remote_failed), - ATTR(remote_eph_pages_succ_get), - ATTR(remote_pers_pages_succ_get), - ATTR(remote_eph_pages_unsucc_get), - ATTR(remote_pers_pages_unsucc_get), - ATTR(pers_pages_remote_nomem), - ATTR(remote_objects_flushed), - ATTR(remote_pages_flushed), - ATTR(remote_object_flushes_failed), - ATTR(remote_page_flushes_failed), - ATTR(foreign_eph_pages), - ATTR(foreign_eph_pages_max), - ATTR(foreign_pers_pages), - ATTR(foreign_pers_pages_max), -}; -#undef ATTR - -int ramster_debugfs_init(void) -{ - int i; - struct dentry *root = debugfs_create_dir("ramster", NULL); - if (root == NULL) - return -ENXIO; - - for (i = 0; i < ARRAY_SIZE(attrs); i++) - if (!debugfs_create_size_t(attrs[i].name, - S_IRUGO, root, attrs[i].val)) - goto out; - return 0; -out: - return -ENODEV; -} -#else -static inline int ramster_debugfs_init(void) -{ - return 0; -} -#endif diff --git a/drivers/staging/zcache/ramster/debug.h b/drivers/staging/zcache/ramster/debug.h deleted file mode 100644 index 5ffab50807d81..0000000000000 --- a/drivers/staging/zcache/ramster/debug.h +++ /dev/null @@ -1,145 +0,0 @@ -#include - -#ifdef CONFIG_RAMSTER_DEBUG - -extern long ramster_flnodes; -static atomic_t ramster_flnodes_atomic = ATOMIC_INIT(0); -static unsigned long ramster_flnodes_max; -static inline void inc_ramster_flnodes(void) -{ - ramster_flnodes = atomic_inc_return(&ramster_flnodes_atomic); - if (ramster_flnodes > ramster_flnodes_max) - ramster_flnodes_max = ramster_flnodes; -} -static inline void dec_ramster_flnodes(void) -{ - ramster_flnodes = atomic_dec_return(&ramster_flnodes_atomic); -} -extern ssize_t ramster_foreign_eph_pages; -static atomic_t ramster_foreign_eph_pages_atomic = ATOMIC_INIT(0); -static ssize_t ramster_foreign_eph_pages_max; -static inline void inc_ramster_foreign_eph_pages(void) -{ - ramster_foreign_eph_pages = atomic_inc_return( - &ramster_foreign_eph_pages_atomic); - if (ramster_foreign_eph_pages > ramster_foreign_eph_pages_max) - ramster_foreign_eph_pages_max = ramster_foreign_eph_pages; -} -static inline void dec_ramster_foreign_eph_pages(void) -{ - ramster_foreign_eph_pages = atomic_dec_return( - &ramster_foreign_eph_pages_atomic); -} -extern ssize_t ramster_foreign_pers_pages; -static atomic_t ramster_foreign_pers_pages_atomic = ATOMIC_INIT(0); -static ssize_t ramster_foreign_pers_pages_max; -static inline void inc_ramster_foreign_pers_pages(void) -{ - ramster_foreign_pers_pages = atomic_inc_return( - &ramster_foreign_pers_pages_atomic); - if (ramster_foreign_pers_pages > ramster_foreign_pers_pages_max) - ramster_foreign_pers_pages_max = ramster_foreign_pers_pages; -} -static inline void dec_ramster_foreign_pers_pages(void) -{ - ramster_foreign_pers_pages = atomic_dec_return( - &ramster_foreign_pers_pages_atomic); -} - -extern ssize_t ramster_eph_pages_remoted; -extern ssize_t ramster_pers_pages_remoted; -extern ssize_t ramster_eph_pages_remote_failed; -extern ssize_t ramster_pers_pages_remote_failed; -extern ssize_t ramster_remote_eph_pages_succ_get; -extern ssize_t ramster_remote_pers_pages_succ_get; -extern ssize_t ramster_remote_eph_pages_unsucc_get; -extern ssize_t ramster_remote_pers_pages_unsucc_get; -extern ssize_t ramster_pers_pages_remote_nomem; -extern ssize_t ramster_remote_objects_flushed; -extern ssize_t ramster_remote_object_flushes_failed; -extern ssize_t ramster_remote_pages_flushed; -extern ssize_t ramster_remote_page_flushes_failed; - -int ramster_debugfs_init(void); - -static inline void inc_ramster_eph_pages_remoted(void) -{ - ramster_eph_pages_remoted++; -}; -static inline void inc_ramster_pers_pages_remoted(void) -{ - ramster_pers_pages_remoted++; -}; -static inline void inc_ramster_eph_pages_remote_failed(void) -{ - ramster_eph_pages_remote_failed++; -}; -static inline void inc_ramster_pers_pages_remote_failed(void) -{ - ramster_pers_pages_remote_failed++; -}; -static inline void inc_ramster_remote_eph_pages_succ_get(void) -{ - ramster_remote_eph_pages_succ_get++; -}; -static inline void inc_ramster_remote_pers_pages_succ_get(void) -{ - ramster_remote_pers_pages_succ_get++; -}; -static inline void inc_ramster_remote_eph_pages_unsucc_get(void) -{ - ramster_remote_eph_pages_unsucc_get++; -}; -static inline void inc_ramster_remote_pers_pages_unsucc_get(void) -{ - ramster_remote_pers_pages_unsucc_get++; -}; -static inline void inc_ramster_pers_pages_remote_nomem(void) -{ - ramster_pers_pages_remote_nomem++; -}; -static inline void inc_ramster_remote_objects_flushed(void) -{ - ramster_remote_objects_flushed++; -}; -static inline void inc_ramster_remote_object_flushes_failed(void) -{ - ramster_remote_object_flushes_failed++; -}; -static inline void inc_ramster_remote_pages_flushed(void) -{ - ramster_remote_pages_flushed++; -}; -static inline void inc_ramster_remote_page_flushes_failed(void) -{ - ramster_remote_page_flushes_failed++; -}; - -#else - -static inline void inc_ramster_flnodes(void) { }; -static inline void dec_ramster_flnodes(void) { }; -static inline void inc_ramster_foreign_eph_pages(void) { }; -static inline void dec_ramster_foreign_eph_pages(void) { }; -static inline void inc_ramster_foreign_pers_pages(void) { }; -static inline void dec_ramster_foreign_pers_pages(void) { }; - -static inline void inc_ramster_eph_pages_remoted(void) { }; -static inline void inc_ramster_pers_pages_remoted(void) { }; -static inline void inc_ramster_eph_pages_remote_failed(void) { }; -static inline void inc_ramster_pers_pages_remote_failed(void) { }; -static inline void inc_ramster_remote_eph_pages_succ_get(void) { }; -static inline void inc_ramster_remote_pers_pages_succ_get(void) { }; -static inline void inc_ramster_remote_eph_pages_unsucc_get(void) { }; -static inline void inc_ramster_remote_pers_pages_unsucc_get(void) { }; -static inline void inc_ramster_pers_pages_remote_nomem(void) { }; -static inline void inc_ramster_remote_objects_flushed(void) { }; -static inline void inc_ramster_remote_object_flushes_failed(void) { }; -static inline void inc_ramster_remote_pages_flushed(void) { }; -static inline void inc_ramster_remote_page_flushes_failed(void) { }; - -static inline int ramster_debugfs_init(void) -{ - return 0; -} -#endif diff --git a/drivers/staging/zcache/ramster/heartbeat.c b/drivers/staging/zcache/ramster/heartbeat.c deleted file mode 100644 index 75d3fe80b0551..0000000000000 --- a/drivers/staging/zcache/ramster/heartbeat.c +++ /dev/null @@ -1,462 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; -*- - * vim: noexpandtab sw=8 ts=8 sts=0: - * - * Copyright (C) 2004, 2005, 2012 Oracle. All rights reserved. - * - * 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 the License, or (at your option) any later version. - * - * 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. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 021110-1307, USA. - */ - -#include -#include -#include - -#include "heartbeat.h" -#include "tcp.h" -#include "nodemanager.h" - -#include "masklog.h" - -/* - * The first heartbeat pass had one global thread that would serialize all hb - * callback calls. This global serializing sem should only be removed once - * we've made sure that all callees can deal with being called concurrently - * from multiple hb region threads. - */ -static DECLARE_RWSEM(r2hb_callback_sem); - -/* - * multiple hb threads are watching multiple regions. A node is live - * whenever any of the threads sees activity from the node in its region. - */ -static DEFINE_SPINLOCK(r2hb_live_lock); -static unsigned long r2hb_live_node_bitmap[BITS_TO_LONGS(R2NM_MAX_NODES)]; - -static struct r2hb_callback { - struct list_head list; -} r2hb_callbacks[R2HB_NUM_CB]; - -enum r2hb_heartbeat_modes { - R2HB_HEARTBEAT_LOCAL = 0, - R2HB_HEARTBEAT_GLOBAL, - R2HB_HEARTBEAT_NUM_MODES, -}; - -char *r2hb_heartbeat_mode_desc[R2HB_HEARTBEAT_NUM_MODES] = { - "local", /* R2HB_HEARTBEAT_LOCAL */ - "global", /* R2HB_HEARTBEAT_GLOBAL */ -}; - -unsigned int r2hb_dead_threshold = R2HB_DEFAULT_DEAD_THRESHOLD; -unsigned int r2hb_heartbeat_mode = R2HB_HEARTBEAT_LOCAL; - -/* Only sets a new threshold if there are no active regions. - * - * No locking or otherwise interesting code is required for reading - * r2hb_dead_threshold as it can't change once regions are active and - * it's not interesting to anyone until then anyway. */ -static void r2hb_dead_threshold_set(unsigned int threshold) -{ - if (threshold > R2HB_MIN_DEAD_THRESHOLD) { - spin_lock(&r2hb_live_lock); - r2hb_dead_threshold = threshold; - spin_unlock(&r2hb_live_lock); - } -} - -static int r2hb_global_hearbeat_mode_set(unsigned int hb_mode) -{ - int ret = -1; - - if (hb_mode < R2HB_HEARTBEAT_NUM_MODES) { - spin_lock(&r2hb_live_lock); - r2hb_heartbeat_mode = hb_mode; - ret = 0; - spin_unlock(&r2hb_live_lock); - } - - return ret; -} - -void r2hb_exit(void) -{ -} - -int r2hb_init(void) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(r2hb_callbacks); i++) - INIT_LIST_HEAD(&r2hb_callbacks[i].list); - - memset(r2hb_live_node_bitmap, 0, sizeof(r2hb_live_node_bitmap)); - - return 0; -} - -/* if we're already in a callback then we're already serialized by the sem */ -static void r2hb_fill_node_map_from_callback(unsigned long *map, - unsigned bytes) -{ - BUG_ON(bytes < (BITS_TO_LONGS(R2NM_MAX_NODES) * sizeof(unsigned long))); - - memcpy(map, &r2hb_live_node_bitmap, bytes); -} - -/* - * get a map of all nodes that are heartbeating in any regions - */ -void r2hb_fill_node_map(unsigned long *map, unsigned bytes) -{ - /* callers want to serialize this map and callbacks so that they - * can trust that they don't miss nodes coming to the party */ - down_read(&r2hb_callback_sem); - spin_lock(&r2hb_live_lock); - r2hb_fill_node_map_from_callback(map, bytes); - spin_unlock(&r2hb_live_lock); - up_read(&r2hb_callback_sem); -} -EXPORT_SYMBOL_GPL(r2hb_fill_node_map); - -/* - * heartbeat configfs bits. The heartbeat set is a default set under - * the cluster set in nodemanager.c. - */ - -/* heartbeat set */ - -struct r2hb_hb_group { - struct config_group hs_group; - /* some stuff? */ -}; - -static struct r2hb_hb_group *to_r2hb_hb_group(struct config_group *group) -{ - return group ? - container_of(group, struct r2hb_hb_group, hs_group) - : NULL; -} - -static struct config_item r2hb_config_item; - -static struct config_item *r2hb_hb_group_make_item(struct config_group *group, - const char *name) -{ - int ret; - - if (strlen(name) > R2HB_MAX_REGION_NAME_LEN) { - ret = -ENAMETOOLONG; - goto free; - } - - config_item_put(&r2hb_config_item); - - return &r2hb_config_item; -free: - return ERR_PTR(ret); -} - -static void r2hb_hb_group_drop_item(struct config_group *group, - struct config_item *item) -{ - if (r2hb_global_heartbeat_active()) { - pr_notice("ramster: Heartbeat %s on region %s (%s)\n", - "stopped/aborted", config_item_name(item), - "no region"); - } - - config_item_put(item); -} - -struct r2hb_hb_group_attribute { - struct configfs_attribute attr; - ssize_t (*show)(struct r2hb_hb_group *, char *); - ssize_t (*store)(struct r2hb_hb_group *, const char *, size_t); -}; - -static ssize_t r2hb_hb_group_show(struct config_item *item, - struct configfs_attribute *attr, - char *page) -{ - struct r2hb_hb_group *reg = to_r2hb_hb_group(to_config_group(item)); - struct r2hb_hb_group_attribute *r2hb_hb_group_attr = - container_of(attr, struct r2hb_hb_group_attribute, attr); - ssize_t ret = 0; - - if (r2hb_hb_group_attr->show) - ret = r2hb_hb_group_attr->show(reg, page); - return ret; -} - -static ssize_t r2hb_hb_group_store(struct config_item *item, - struct configfs_attribute *attr, - const char *page, size_t count) -{ - struct r2hb_hb_group *reg = to_r2hb_hb_group(to_config_group(item)); - struct r2hb_hb_group_attribute *r2hb_hb_group_attr = - container_of(attr, struct r2hb_hb_group_attribute, attr); - ssize_t ret = -EINVAL; - - if (r2hb_hb_group_attr->store) - ret = r2hb_hb_group_attr->store(reg, page, count); - return ret; -} - -static ssize_t r2hb_hb_group_threshold_show(struct r2hb_hb_group *group, - char *page) -{ - return sprintf(page, "%u\n", r2hb_dead_threshold); -} - -static ssize_t r2hb_hb_group_threshold_store(struct r2hb_hb_group *group, - const char *page, - size_t count) -{ - unsigned long tmp; - char *p = (char *)page; - int err; - - err = kstrtoul(p, 10, &tmp); - if (err) - return err; - - /* this will validate ranges for us. */ - r2hb_dead_threshold_set((unsigned int) tmp); - - return count; -} - -static -ssize_t r2hb_hb_group_mode_show(struct r2hb_hb_group *group, - char *page) -{ - return sprintf(page, "%s\n", - r2hb_heartbeat_mode_desc[r2hb_heartbeat_mode]); -} - -static -ssize_t r2hb_hb_group_mode_store(struct r2hb_hb_group *group, - const char *page, size_t count) -{ - unsigned int i; - int ret; - size_t len; - - len = (page[count - 1] == '\n') ? count - 1 : count; - if (!len) - return -EINVAL; - - for (i = 0; i < R2HB_HEARTBEAT_NUM_MODES; ++i) { - if (strnicmp(page, r2hb_heartbeat_mode_desc[i], len)) - continue; - - ret = r2hb_global_hearbeat_mode_set(i); - if (!ret) - pr_notice("ramster: Heartbeat mode set to %s\n", - r2hb_heartbeat_mode_desc[i]); - return count; - } - - return -EINVAL; - -} - -static struct r2hb_hb_group_attribute r2hb_hb_group_attr_threshold = { - .attr = { .ca_owner = THIS_MODULE, - .ca_name = "dead_threshold", - .ca_mode = S_IRUGO | S_IWUSR }, - .show = r2hb_hb_group_threshold_show, - .store = r2hb_hb_group_threshold_store, -}; - -static struct r2hb_hb_group_attribute r2hb_hb_group_attr_mode = { - .attr = { .ca_owner = THIS_MODULE, - .ca_name = "mode", - .ca_mode = S_IRUGO | S_IWUSR }, - .show = r2hb_hb_group_mode_show, - .store = r2hb_hb_group_mode_store, -}; - -static struct configfs_attribute *r2hb_hb_group_attrs[] = { - &r2hb_hb_group_attr_threshold.attr, - &r2hb_hb_group_attr_mode.attr, - NULL, -}; - -static struct configfs_item_operations r2hb_hearbeat_group_item_ops = { - .show_attribute = r2hb_hb_group_show, - .store_attribute = r2hb_hb_group_store, -}; - -static struct configfs_group_operations r2hb_hb_group_group_ops = { - .make_item = r2hb_hb_group_make_item, - .drop_item = r2hb_hb_group_drop_item, -}; - -static struct config_item_type r2hb_hb_group_type = { - .ct_group_ops = &r2hb_hb_group_group_ops, - .ct_item_ops = &r2hb_hearbeat_group_item_ops, - .ct_attrs = r2hb_hb_group_attrs, - .ct_owner = THIS_MODULE, -}; - -/* this is just here to avoid touching group in heartbeat.h which the - * entire damn world #includes */ -struct config_group *r2hb_alloc_hb_set(void) -{ - struct r2hb_hb_group *hs = NULL; - struct config_group *ret = NULL; - - hs = kzalloc(sizeof(struct r2hb_hb_group), GFP_KERNEL); - if (hs == NULL) - goto out; - - config_group_init_type_name(&hs->hs_group, "heartbeat", - &r2hb_hb_group_type); - - ret = &hs->hs_group; -out: - if (ret == NULL) - kfree(hs); - return ret; -} - -void r2hb_free_hb_set(struct config_group *group) -{ - struct r2hb_hb_group *hs = to_r2hb_hb_group(group); - kfree(hs); -} - -/* hb callback registration and issuing */ - -static struct r2hb_callback *hbcall_from_type(enum r2hb_callback_type type) -{ - if (type == R2HB_NUM_CB) - return ERR_PTR(-EINVAL); - - return &r2hb_callbacks[type]; -} - -void r2hb_setup_callback(struct r2hb_callback_func *hc, - enum r2hb_callback_type type, - r2hb_cb_func *func, - void *data, - int priority) -{ - INIT_LIST_HEAD(&hc->hc_item); - hc->hc_func = func; - hc->hc_data = data; - hc->hc_priority = priority; - hc->hc_type = type; - hc->hc_magic = R2HB_CB_MAGIC; -} -EXPORT_SYMBOL_GPL(r2hb_setup_callback); - -int r2hb_register_callback(const char *region_uuid, - struct r2hb_callback_func *hc) -{ - struct r2hb_callback_func *tmp; - struct list_head *iter; - struct r2hb_callback *hbcall; - int ret; - - BUG_ON(hc->hc_magic != R2HB_CB_MAGIC); - BUG_ON(!list_empty(&hc->hc_item)); - - hbcall = hbcall_from_type(hc->hc_type); - if (IS_ERR(hbcall)) { - ret = PTR_ERR(hbcall); - goto out; - } - - down_write(&r2hb_callback_sem); - - list_for_each(iter, &hbcall->list) { - tmp = list_entry(iter, struct r2hb_callback_func, hc_item); - if (hc->hc_priority < tmp->hc_priority) { - list_add_tail(&hc->hc_item, iter); - break; - } - } - if (list_empty(&hc->hc_item)) - list_add_tail(&hc->hc_item, &hbcall->list); - - up_write(&r2hb_callback_sem); - ret = 0; -out: - mlog(ML_CLUSTER, "returning %d on behalf of %p for funcs %p\n", - ret, __builtin_return_address(0), hc); - return ret; -} -EXPORT_SYMBOL_GPL(r2hb_register_callback); - -void r2hb_unregister_callback(const char *region_uuid, - struct r2hb_callback_func *hc) -{ - BUG_ON(hc->hc_magic != R2HB_CB_MAGIC); - - mlog(ML_CLUSTER, "on behalf of %p for funcs %p\n", - __builtin_return_address(0), hc); - - /* XXX Can this happen _with_ a region reference? */ - if (list_empty(&hc->hc_item)) - return; - - down_write(&r2hb_callback_sem); - - list_del_init(&hc->hc_item); - - up_write(&r2hb_callback_sem); -} -EXPORT_SYMBOL_GPL(r2hb_unregister_callback); - -int r2hb_check_node_heartbeating_from_callback(u8 node_num) -{ - unsigned long testing_map[BITS_TO_LONGS(R2NM_MAX_NODES)]; - - r2hb_fill_node_map_from_callback(testing_map, sizeof(testing_map)); - if (!test_bit(node_num, testing_map)) { - mlog(ML_HEARTBEAT, - "node (%u) does not have heartbeating enabled.\n", - node_num); - return 0; - } - - return 1; -} -EXPORT_SYMBOL_GPL(r2hb_check_node_heartbeating_from_callback); - -void r2hb_stop_all_regions(void) -{ -} -EXPORT_SYMBOL_GPL(r2hb_stop_all_regions); - -/* - * this is just a hack until we get the plumbing which flips file systems - * read only and drops the hb ref instead of killing the node dead. - */ -int r2hb_global_heartbeat_active(void) -{ - return (r2hb_heartbeat_mode == R2HB_HEARTBEAT_GLOBAL); -} -EXPORT_SYMBOL(r2hb_global_heartbeat_active); - -/* added for RAMster */ -void r2hb_manual_set_node_heartbeating(int node_num) -{ - if (node_num < R2NM_MAX_NODES) - set_bit(node_num, r2hb_live_node_bitmap); -} -EXPORT_SYMBOL(r2hb_manual_set_node_heartbeating); diff --git a/drivers/staging/zcache/ramster/heartbeat.h b/drivers/staging/zcache/ramster/heartbeat.h deleted file mode 100644 index 6cbc775bd63be..0000000000000 --- a/drivers/staging/zcache/ramster/heartbeat.h +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; -*- - * vim: noexpandtab sw=8 ts=8 sts=0: - * - * heartbeat.h - * - * Function prototypes - * - * Copyright (C) 2004 Oracle. All rights reserved. - * - * 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 the License, or (at your option) any later version. - * - * 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. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 021110-1307, USA. - * - */ - -#ifndef R2CLUSTER_HEARTBEAT_H -#define R2CLUSTER_HEARTBEAT_H - -#define R2HB_REGION_TIMEOUT_MS 2000 - -#define R2HB_MAX_REGION_NAME_LEN 32 - -/* number of changes to be seen as live */ -#define R2HB_LIVE_THRESHOLD 2 -/* number of equal samples to be seen as dead */ -extern unsigned int r2hb_dead_threshold; -#define R2HB_DEFAULT_DEAD_THRESHOLD 31 -/* Otherwise MAX_WRITE_TIMEOUT will be zero... */ -#define R2HB_MIN_DEAD_THRESHOLD 2 -#define R2HB_MAX_WRITE_TIMEOUT_MS \ - (R2HB_REGION_TIMEOUT_MS * (r2hb_dead_threshold - 1)) - -#define R2HB_CB_MAGIC 0x51d1e4ec - -/* callback stuff */ -enum r2hb_callback_type { - R2HB_NODE_DOWN_CB = 0, - R2HB_NODE_UP_CB, - R2HB_NUM_CB -}; - -struct r2nm_node; -typedef void (r2hb_cb_func)(struct r2nm_node *, int, void *); - -struct r2hb_callback_func { - u32 hc_magic; - struct list_head hc_item; - r2hb_cb_func *hc_func; - void *hc_data; - int hc_priority; - enum r2hb_callback_type hc_type; -}; - -struct config_group *r2hb_alloc_hb_set(void); -void r2hb_free_hb_set(struct config_group *group); - -void r2hb_setup_callback(struct r2hb_callback_func *hc, - enum r2hb_callback_type type, - r2hb_cb_func *func, - void *data, - int priority); -int r2hb_register_callback(const char *region_uuid, - struct r2hb_callback_func *hc); -void r2hb_unregister_callback(const char *region_uuid, - struct r2hb_callback_func *hc); -void r2hb_fill_node_map(unsigned long *map, - unsigned bytes); -void r2hb_exit(void); -int r2hb_init(void); -int r2hb_check_node_heartbeating_from_callback(u8 node_num); -void r2hb_stop_all_regions(void); -int r2hb_get_all_regions(char *region_uuids, u8 numregions); -int r2hb_global_heartbeat_active(void); -void r2hb_manual_set_node_heartbeating(int); - -#endif /* R2CLUSTER_HEARTBEAT_H */ diff --git a/drivers/staging/zcache/ramster/masklog.c b/drivers/staging/zcache/ramster/masklog.c deleted file mode 100644 index 1261d8579aae6..0000000000000 --- a/drivers/staging/zcache/ramster/masklog.c +++ /dev/null @@ -1,155 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; -*- - * vim: noexpandtab sw=8 ts=8 sts=0: - * - * Copyright (C) 2004, 2005, 2012 Oracle. All rights reserved. - * - * 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 the License, or (at your option) any later version. - * - * 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. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 021110-1307, USA. - */ - -#include -#include -#include -#include -#include -#include - -#include "masklog.h" - -struct mlog_bits r2_mlog_and_bits = MLOG_BITS_RHS(MLOG_INITIAL_AND_MASK); -EXPORT_SYMBOL_GPL(r2_mlog_and_bits); -struct mlog_bits r2_mlog_not_bits = MLOG_BITS_RHS(0); -EXPORT_SYMBOL_GPL(r2_mlog_not_bits); - -static ssize_t mlog_mask_show(u64 mask, char *buf) -{ - char *state; - - if (__mlog_test_u64(mask, r2_mlog_and_bits)) - state = "allow"; - else if (__mlog_test_u64(mask, r2_mlog_not_bits)) - state = "deny"; - else - state = "off"; - - return snprintf(buf, PAGE_SIZE, "%s\n", state); -} - -static ssize_t mlog_mask_store(u64 mask, const char *buf, size_t count) -{ - if (!strnicmp(buf, "allow", 5)) { - __mlog_set_u64(mask, r2_mlog_and_bits); - __mlog_clear_u64(mask, r2_mlog_not_bits); - } else if (!strnicmp(buf, "deny", 4)) { - __mlog_set_u64(mask, r2_mlog_not_bits); - __mlog_clear_u64(mask, r2_mlog_and_bits); - } else if (!strnicmp(buf, "off", 3)) { - __mlog_clear_u64(mask, r2_mlog_not_bits); - __mlog_clear_u64(mask, r2_mlog_and_bits); - } else - return -EINVAL; - - return count; -} - -struct mlog_attribute { - struct attribute attr; - u64 mask; -}; - -#define to_mlog_attr(_attr) container_of(_attr, struct mlog_attribute, attr) - -#define define_mask(_name) { \ - .attr = { \ - .name = #_name, \ - .mode = S_IRUGO | S_IWUSR, \ - }, \ - .mask = ML_##_name, \ -} - -static struct mlog_attribute mlog_attrs[MLOG_MAX_BITS] = { - define_mask(TCP), - define_mask(MSG), - define_mask(SOCKET), - define_mask(HEARTBEAT), - define_mask(HB_BIO), - define_mask(DLMFS), - define_mask(DLM), - define_mask(DLM_DOMAIN), - define_mask(DLM_THREAD), - define_mask(DLM_MASTER), - define_mask(DLM_RECOVERY), - define_mask(DLM_GLUE), - define_mask(VOTE), - define_mask(CONN), - define_mask(QUORUM), - define_mask(BASTS), - define_mask(CLUSTER), - define_mask(ERROR), - define_mask(NOTICE), - define_mask(KTHREAD), -}; - -static struct attribute *mlog_attr_ptrs[MLOG_MAX_BITS] = {NULL, }; - -static ssize_t mlog_show(struct kobject *obj, struct attribute *attr, - char *buf) -{ - struct mlog_attribute *mlog_attr = to_mlog_attr(attr); - - return mlog_mask_show(mlog_attr->mask, buf); -} - -static ssize_t mlog_store(struct kobject *obj, struct attribute *attr, - const char *buf, size_t count) -{ - struct mlog_attribute *mlog_attr = to_mlog_attr(attr); - - return mlog_mask_store(mlog_attr->mask, buf, count); -} - -static const struct sysfs_ops mlog_attr_ops = { - .show = mlog_show, - .store = mlog_store, -}; - -static struct kobj_type mlog_ktype = { - .default_attrs = mlog_attr_ptrs, - .sysfs_ops = &mlog_attr_ops, -}; - -static struct kset mlog_kset = { - .kobj = {.ktype = &mlog_ktype}, -}; - -int r2_mlog_sys_init(struct kset *r2cb_kset) -{ - int i = 0; - - while (mlog_attrs[i].attr.mode) { - mlog_attr_ptrs[i] = &mlog_attrs[i].attr; - i++; - } - mlog_attr_ptrs[i] = NULL; - - kobject_set_name(&mlog_kset.kobj, "logmask"); - mlog_kset.kobj.kset = r2cb_kset; - return kset_register(&mlog_kset); -} - -void r2_mlog_sys_shutdown(void) -{ - kset_unregister(&mlog_kset); -} diff --git a/drivers/staging/zcache/ramster/masklog.h b/drivers/staging/zcache/ramster/masklog.h deleted file mode 100644 index 918ae110b6990..0000000000000 --- a/drivers/staging/zcache/ramster/masklog.h +++ /dev/null @@ -1,220 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; -*- - * vim: noexpandtab sw=8 ts=8 sts=0: - * - * Copyright (C) 2005, 2012 Oracle. All rights reserved. - * - * 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 the License, or (at your option) any later version. - * - * 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. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 021110-1307, USA. - */ - -#ifndef R2CLUSTER_MASKLOG_H -#define R2CLUSTER_MASKLOG_H - -/* - * For now this is a trivial wrapper around printk() that gives the critical - * ability to enable sets of debugging output at run-time. In the future this - * will almost certainly be redirected to relayfs so that it can pay a - * substantially lower heisenberg tax. - * - * Callers associate the message with a bitmask and a global bitmask is - * maintained with help from /proc. If any of the bits match the message is - * output. - * - * We must have efficient bit tests on i386 and it seems gcc still emits crazy - * code for the 64bit compare. It emits very good code for the dual unsigned - * long tests, though, completely avoiding tests that can never pass if the - * caller gives a constant bitmask that fills one of the longs with all 0s. So - * the desire is to have almost all of the calls decided on by comparing just - * one of the longs. This leads to having infrequently given bits that are - * frequently matched in the high bits. - * - * _ERROR and _NOTICE are used for messages that always go to the console and - * have appropriate KERN_ prefixes. We wrap these in our function instead of - * just calling printk() so that this can eventually make its way through - * relayfs along with the debugging messages. Everything else gets KERN_DEBUG. - * The inline tests and macro dance give GCC the opportunity to quite cleverly - * only emit the appropriage printk() when the caller passes in a constant - * mask, as is almost always the case. - * - * All this bitmask nonsense is managed from the files under - * /sys/fs/r2cb/logmask/. Reading the files gives a straightforward - * indication of which bits are allowed (allow) or denied (off/deny). - * ENTRY deny - * EXIT deny - * TCP off - * MSG off - * SOCKET off - * ERROR allow - * NOTICE allow - * - * Writing changes the state of a given bit and requires a strictly formatted - * single write() call: - * - * write(fd, "allow", 5); - * - * Echoing allow/deny/off string into the logmask files can flip the bits - * on or off as expected; here is the bash script for example: - * - * log_mask="/sys/fs/r2cb/log_mask" - * for node in ENTRY EXIT TCP MSG SOCKET ERROR NOTICE; do - * echo allow >"$log_mask"/"$node" - * done - * - * The debugfs.ramster tool can also flip the bits with the -l option: - * - * debugfs.ramster -l TCP allow - */ - -/* for task_struct */ -#include - -/* bits that are frequently given and infrequently matched in the low word */ -/* NOTE: If you add a flag, you need to also update masklog.c! */ -#define ML_TCP 0x0000000000000001ULL /* net cluster/tcp.c */ -#define ML_MSG 0x0000000000000002ULL /* net network messages */ -#define ML_SOCKET 0x0000000000000004ULL /* net socket lifetime */ -#define ML_HEARTBEAT 0x0000000000000008ULL /* hb all heartbeat tracking */ -#define ML_HB_BIO 0x0000000000000010ULL /* hb io tracing */ -#define ML_DLMFS 0x0000000000000020ULL /* dlm user dlmfs */ -#define ML_DLM 0x0000000000000040ULL /* dlm general debugging */ -#define ML_DLM_DOMAIN 0x0000000000000080ULL /* dlm domain debugging */ -#define ML_DLM_THREAD 0x0000000000000100ULL /* dlm domain thread */ -#define ML_DLM_MASTER 0x0000000000000200ULL /* dlm master functions */ -#define ML_DLM_RECOVERY 0x0000000000000400ULL /* dlm master functions */ -#define ML_DLM_GLUE 0x0000000000000800ULL /* ramster dlm glue layer */ -#define ML_VOTE 0x0000000000001000ULL /* ramster node messaging */ -#define ML_CONN 0x0000000000002000ULL /* net connection management */ -#define ML_QUORUM 0x0000000000004000ULL /* net connection quorum */ -#define ML_BASTS 0x0000000000008000ULL /* dlmglue asts and basts */ -#define ML_CLUSTER 0x0000000000010000ULL /* cluster stack */ - -/* bits that are infrequently given and frequently matched in the high word */ -#define ML_ERROR 0x1000000000000000ULL /* sent to KERN_ERR */ -#define ML_NOTICE 0x2000000000000000ULL /* setn to KERN_NOTICE */ -#define ML_KTHREAD 0x4000000000000000ULL /* kernel thread activity */ - -#define MLOG_INITIAL_AND_MASK (ML_ERROR|ML_NOTICE) -#ifndef MLOG_MASK_PREFIX -#define MLOG_MASK_PREFIX 0 -#endif - -/* - * When logging is disabled, force the bit test to 0 for anything other - * than errors and notices, allowing gcc to remove the code completely. - * When enabled, allow all masks. - */ -#if defined(CONFIG_RAMSTER_DEBUG_MASKLOG) -#define ML_ALLOWED_BITS (~0) -#else -#define ML_ALLOWED_BITS (ML_ERROR|ML_NOTICE) -#endif - -#define MLOG_MAX_BITS 64 - -struct mlog_bits { - unsigned long words[MLOG_MAX_BITS / BITS_PER_LONG]; -}; - -extern struct mlog_bits r2_mlog_and_bits, r2_mlog_not_bits; - -#if BITS_PER_LONG == 32 - -#define __mlog_test_u64(mask, bits) \ - ((u32)(mask & 0xffffffff) & bits.words[0] || \ - ((u64)(mask) >> 32) & bits.words[1]) -#define __mlog_set_u64(mask, bits) do { \ - bits.words[0] |= (u32)(mask & 0xffffffff); \ - bits.words[1] |= (u64)(mask) >> 32; \ -} while (0) -#define __mlog_clear_u64(mask, bits) do { \ - bits.words[0] &= ~((u32)(mask & 0xffffffff)); \ - bits.words[1] &= ~((u64)(mask) >> 32); \ -} while (0) -#define MLOG_BITS_RHS(mask) { \ - { \ - [0] = (u32)(mask & 0xffffffff), \ - [1] = (u64)(mask) >> 32, \ - } \ -} - -#else /* 32bit long above, 64bit long below */ - -#define __mlog_test_u64(mask, bits) ((mask) & bits.words[0]) -#define __mlog_set_u64(mask, bits) do { \ - bits.words[0] |= (mask); \ -} while (0) -#define __mlog_clear_u64(mask, bits) do { \ - bits.words[0] &= ~(mask); \ -} while (0) -#define MLOG_BITS_RHS(mask) { { (mask) } } - -#endif - -/* - * smp_processor_id() "helpfully" screams when called outside preemptible - * regions in current kernels. sles doesn't have the variants that don't - * scream. just do this instead of trying to guess which we're building - * against.. *sigh*. - */ -#define __mlog_cpu_guess ({ \ - unsigned long _cpu = get_cpu(); \ - put_cpu(); \ - _cpu; \ -}) - -/* In the following two macros, the whitespace after the ',' just - * before ##args is intentional. Otherwise, gcc 2.95 will eat the - * previous token if args expands to nothing. - */ -#define __mlog_printk(level, fmt, args...) \ - printk(level "(%s,%u,%lu):%s:%d " fmt, current->comm, \ - task_pid_nr(current), __mlog_cpu_guess, \ - __PRETTY_FUNCTION__, __LINE__ , ##args) - -#define mlog(mask, fmt, args...) do { \ - u64 __m = MLOG_MASK_PREFIX | (mask); \ - if ((__m & ML_ALLOWED_BITS) && \ - __mlog_test_u64(__m, r2_mlog_and_bits) && \ - !__mlog_test_u64(__m, r2_mlog_not_bits)) { \ - if (__m & ML_ERROR) \ - __mlog_printk(KERN_ERR, "ERROR: "fmt , ##args); \ - else if (__m & ML_NOTICE) \ - __mlog_printk(KERN_NOTICE, fmt , ##args); \ - else \ - __mlog_printk(KERN_INFO, fmt , ##args); \ - } \ -} while (0) - -#define mlog_errno(st) do { \ - int _st = (st); \ - if (_st != -ERESTARTSYS && _st != -EINTR && \ - _st != AOP_TRUNCATED_PAGE && _st != -ENOSPC) \ - mlog(ML_ERROR, "status = %lld\n", (long long)_st); \ -} while (0) - -#define mlog_bug_on_msg(cond, fmt, args...) do { \ - if (cond) { \ - mlog(ML_ERROR, "bug expression: " #cond "\n"); \ - mlog(ML_ERROR, fmt, ##args); \ - BUG(); \ - } \ -} while (0) - -#include -#include -int r2_mlog_sys_init(struct kset *r2cb_subsys); -void r2_mlog_sys_shutdown(void); - -#endif /* R2CLUSTER_MASKLOG_H */ diff --git a/drivers/staging/zcache/ramster/nodemanager.c b/drivers/staging/zcache/ramster/nodemanager.c deleted file mode 100644 index 2cfe93342c0d6..0000000000000 --- a/drivers/staging/zcache/ramster/nodemanager.c +++ /dev/null @@ -1,996 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; -*- - * vim: noexpandtab sw=8 ts=8 sts=0: - * - * Copyright (C) 2004, 2005, 2012 Oracle. All rights reserved. - * - * 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 the License, or (at your option) any later version. - * - * 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. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 021110-1307, USA. - */ - -#include -#include -#include -#include - -#include "tcp.h" -#include "nodemanager.h" -#include "heartbeat.h" -#include "masklog.h" - -/* for now we operate under the assertion that there can be only one - * cluster active at a time. Changing this will require trickling - * cluster references throughout where nodes are looked up */ -struct r2nm_cluster *r2nm_single_cluster; - -char *r2nm_fence_method_desc[R2NM_FENCE_METHODS] = { - "reset", /* R2NM_FENCE_RESET */ - "panic", /* R2NM_FENCE_PANIC */ -}; - -struct r2nm_node *r2nm_get_node_by_num(u8 node_num) -{ - struct r2nm_node *node = NULL; - - if (node_num >= R2NM_MAX_NODES || r2nm_single_cluster == NULL) - goto out; - - read_lock(&r2nm_single_cluster->cl_nodes_lock); - node = r2nm_single_cluster->cl_nodes[node_num]; - if (node) - config_item_get(&node->nd_item); - read_unlock(&r2nm_single_cluster->cl_nodes_lock); -out: - return node; -} -EXPORT_SYMBOL_GPL(r2nm_get_node_by_num); - -int r2nm_configured_node_map(unsigned long *map, unsigned bytes) -{ - struct r2nm_cluster *cluster = r2nm_single_cluster; - - BUG_ON(bytes < (sizeof(cluster->cl_nodes_bitmap))); - - if (cluster == NULL) - return -EINVAL; - - read_lock(&cluster->cl_nodes_lock); - memcpy(map, cluster->cl_nodes_bitmap, sizeof(cluster->cl_nodes_bitmap)); - read_unlock(&cluster->cl_nodes_lock); - - return 0; -} -EXPORT_SYMBOL_GPL(r2nm_configured_node_map); - -static struct r2nm_node *r2nm_node_ip_tree_lookup(struct r2nm_cluster *cluster, - __be32 ip_needle, - struct rb_node ***ret_p, - struct rb_node **ret_parent) -{ - struct rb_node **p = &cluster->cl_node_ip_tree.rb_node; - struct rb_node *parent = NULL; - struct r2nm_node *node, *ret = NULL; - - while (*p) { - int cmp; - - parent = *p; - node = rb_entry(parent, struct r2nm_node, nd_ip_node); - - cmp = memcmp(&ip_needle, &node->nd_ipv4_address, - sizeof(ip_needle)); - if (cmp < 0) - p = &(*p)->rb_left; - else if (cmp > 0) - p = &(*p)->rb_right; - else { - ret = node; - break; - } - } - - if (ret_p != NULL) - *ret_p = p; - if (ret_parent != NULL) - *ret_parent = parent; - - return ret; -} - -struct r2nm_node *r2nm_get_node_by_ip(__be32 addr) -{ - struct r2nm_node *node = NULL; - struct r2nm_cluster *cluster = r2nm_single_cluster; - - if (cluster == NULL) - goto out; - - read_lock(&cluster->cl_nodes_lock); - node = r2nm_node_ip_tree_lookup(cluster, addr, NULL, NULL); - if (node) - config_item_get(&node->nd_item); - read_unlock(&cluster->cl_nodes_lock); - -out: - return node; -} -EXPORT_SYMBOL_GPL(r2nm_get_node_by_ip); - -void r2nm_node_put(struct r2nm_node *node) -{ - config_item_put(&node->nd_item); -} -EXPORT_SYMBOL_GPL(r2nm_node_put); - -void r2nm_node_get(struct r2nm_node *node) -{ - config_item_get(&node->nd_item); -} -EXPORT_SYMBOL_GPL(r2nm_node_get); - -u8 r2nm_this_node(void) -{ - u8 node_num = R2NM_MAX_NODES; - - if (r2nm_single_cluster && r2nm_single_cluster->cl_has_local) - node_num = r2nm_single_cluster->cl_local_node; - - return node_num; -} -EXPORT_SYMBOL_GPL(r2nm_this_node); - -/* node configfs bits */ - -static struct r2nm_cluster *to_r2nm_cluster(struct config_item *item) -{ - return item ? - container_of(to_config_group(item), struct r2nm_cluster, - cl_group) - : NULL; -} - -static struct r2nm_node *to_r2nm_node(struct config_item *item) -{ - return item ? container_of(item, struct r2nm_node, nd_item) : NULL; -} - -static void r2nm_node_release(struct config_item *item) -{ - struct r2nm_node *node = to_r2nm_node(item); - kfree(node); -} - -static ssize_t r2nm_node_num_read(struct r2nm_node *node, char *page) -{ - return sprintf(page, "%d\n", node->nd_num); -} - -static struct r2nm_cluster *to_r2nm_cluster_from_node(struct r2nm_node *node) -{ - /* through the first node_set .parent - * mycluster/nodes/mynode == r2nm_cluster->r2nm_node_group->r2nm_node */ - return to_r2nm_cluster(node->nd_item.ci_parent->ci_parent); -} - -enum { - R2NM_NODE_ATTR_NUM = 0, - R2NM_NODE_ATTR_PORT, - R2NM_NODE_ATTR_ADDRESS, - R2NM_NODE_ATTR_LOCAL, -}; - -static ssize_t r2nm_node_num_write(struct r2nm_node *node, const char *page, - size_t count) -{ - struct r2nm_cluster *cluster = to_r2nm_cluster_from_node(node); - unsigned long tmp; - char *p = (char *)page; - int err; - - err = kstrtoul(p, 10, &tmp); - if (err) - return err; - - if (tmp >= R2NM_MAX_NODES) - return -ERANGE; - - /* once we're in the cl_nodes tree networking can look us up by - * node number and try to use our address and port attributes - * to connect to this node.. make sure that they've been set - * before writing the node attribute? */ - if (!test_bit(R2NM_NODE_ATTR_ADDRESS, &node->nd_set_attributes) || - !test_bit(R2NM_NODE_ATTR_PORT, &node->nd_set_attributes)) - return -EINVAL; /* XXX */ - - write_lock(&cluster->cl_nodes_lock); - if (cluster->cl_nodes[tmp]) - p = NULL; - else { - cluster->cl_nodes[tmp] = node; - node->nd_num = tmp; - set_bit(tmp, cluster->cl_nodes_bitmap); - } - write_unlock(&cluster->cl_nodes_lock); - if (p == NULL) - return -EEXIST; - - return count; -} -static ssize_t r2nm_node_ipv4_port_read(struct r2nm_node *node, char *page) -{ - return sprintf(page, "%u\n", ntohs(node->nd_ipv4_port)); -} - -static ssize_t r2nm_node_ipv4_port_write(struct r2nm_node *node, - const char *page, size_t count) -{ - unsigned long tmp; - char *p = (char *)page; - int err; - - err = kstrtoul(p, 10, &tmp); - if (err) - return err; - - if (tmp == 0) - return -EINVAL; - if (tmp >= (u16)-1) - return -ERANGE; - - node->nd_ipv4_port = htons(tmp); - - return count; -} - -static ssize_t r2nm_node_ipv4_address_read(struct r2nm_node *node, char *page) -{ - return sprintf(page, "%pI4\n", &node->nd_ipv4_address); -} - -static ssize_t r2nm_node_ipv4_address_write(struct r2nm_node *node, - const char *page, - size_t count) -{ - struct r2nm_cluster *cluster = to_r2nm_cluster_from_node(node); - int ret, i; - struct rb_node **p, *parent; - unsigned int octets[4]; - __be32 ipv4_addr = 0; - - ret = sscanf(page, "%3u.%3u.%3u.%3u", &octets[3], &octets[2], - &octets[1], &octets[0]); - if (ret != 4) - return -EINVAL; - - for (i = 0; i < ARRAY_SIZE(octets); i++) { - if (octets[i] > 255) - return -ERANGE; - be32_add_cpu(&ipv4_addr, octets[i] << (i * 8)); - } - - ret = 0; - write_lock(&cluster->cl_nodes_lock); - if (r2nm_node_ip_tree_lookup(cluster, ipv4_addr, &p, &parent)) - ret = -EEXIST; - else { - rb_link_node(&node->nd_ip_node, parent, p); - rb_insert_color(&node->nd_ip_node, &cluster->cl_node_ip_tree); - } - write_unlock(&cluster->cl_nodes_lock); - if (ret) - return ret; - - memcpy(&node->nd_ipv4_address, &ipv4_addr, sizeof(ipv4_addr)); - - return count; -} - -static ssize_t r2nm_node_local_read(struct r2nm_node *node, char *page) -{ - return sprintf(page, "%d\n", node->nd_local); -} - -static ssize_t r2nm_node_local_write(struct r2nm_node *node, const char *page, - size_t count) -{ - struct r2nm_cluster *cluster = to_r2nm_cluster_from_node(node); - unsigned long tmp; - char *p = (char *)page; - ssize_t ret; - int err; - - err = kstrtoul(p, 10, &tmp); - if (err) - return err; - - tmp = !!tmp; /* boolean of whether this node wants to be local */ - - /* setting local turns on networking rx for now so we require having - * set everything else first */ - if (!test_bit(R2NM_NODE_ATTR_ADDRESS, &node->nd_set_attributes) || - !test_bit(R2NM_NODE_ATTR_NUM, &node->nd_set_attributes) || - !test_bit(R2NM_NODE_ATTR_PORT, &node->nd_set_attributes)) - return -EINVAL; /* XXX */ - - /* the only failure case is trying to set a new local node - * when a different one is already set */ - if (tmp && tmp == cluster->cl_has_local && - cluster->cl_local_node != node->nd_num) - return -EBUSY; - - /* bring up the rx thread if we're setting the new local node. */ - if (tmp && !cluster->cl_has_local) { - ret = r2net_start_listening(node); - if (ret) - return ret; - } - - if (!tmp && cluster->cl_has_local && - cluster->cl_local_node == node->nd_num) { - r2net_stop_listening(node); - cluster->cl_local_node = R2NM_INVALID_NODE_NUM; - } - - node->nd_local = tmp; - if (node->nd_local) { - cluster->cl_has_local = tmp; - cluster->cl_local_node = node->nd_num; - } - - return count; -} - -struct r2nm_node_attribute { - struct configfs_attribute attr; - ssize_t (*show)(struct r2nm_node *, char *); - ssize_t (*store)(struct r2nm_node *, const char *, size_t); -}; - -static struct r2nm_node_attribute r2nm_node_attr_num = { - .attr = { .ca_owner = THIS_MODULE, - .ca_name = "num", - .ca_mode = S_IRUGO | S_IWUSR }, - .show = r2nm_node_num_read, - .store = r2nm_node_num_write, -}; - -static struct r2nm_node_attribute r2nm_node_attr_ipv4_port = { - .attr = { .ca_owner = THIS_MODULE, - .ca_name = "ipv4_port", - .ca_mode = S_IRUGO | S_IWUSR }, - .show = r2nm_node_ipv4_port_read, - .store = r2nm_node_ipv4_port_write, -}; - -static struct r2nm_node_attribute r2nm_node_attr_ipv4_address = { - .attr = { .ca_owner = THIS_MODULE, - .ca_name = "ipv4_address", - .ca_mode = S_IRUGO | S_IWUSR }, - .show = r2nm_node_ipv4_address_read, - .store = r2nm_node_ipv4_address_write, -}; - -static struct r2nm_node_attribute r2nm_node_attr_local = { - .attr = { .ca_owner = THIS_MODULE, - .ca_name = "local", - .ca_mode = S_IRUGO | S_IWUSR }, - .show = r2nm_node_local_read, - .store = r2nm_node_local_write, -}; - -static struct configfs_attribute *r2nm_node_attrs[] = { - [R2NM_NODE_ATTR_NUM] = &r2nm_node_attr_num.attr, - [R2NM_NODE_ATTR_PORT] = &r2nm_node_attr_ipv4_port.attr, - [R2NM_NODE_ATTR_ADDRESS] = &r2nm_node_attr_ipv4_address.attr, - [R2NM_NODE_ATTR_LOCAL] = &r2nm_node_attr_local.attr, - NULL, -}; - -static int r2nm_attr_index(struct configfs_attribute *attr) -{ - int i; - for (i = 0; i < ARRAY_SIZE(r2nm_node_attrs); i++) { - if (attr == r2nm_node_attrs[i]) - return i; - } - BUG(); - return 0; -} - -static ssize_t r2nm_node_show(struct config_item *item, - struct configfs_attribute *attr, - char *page) -{ - struct r2nm_node *node = to_r2nm_node(item); - struct r2nm_node_attribute *r2nm_node_attr = - container_of(attr, struct r2nm_node_attribute, attr); - ssize_t ret = 0; - - if (r2nm_node_attr->show) - ret = r2nm_node_attr->show(node, page); - return ret; -} - -static ssize_t r2nm_node_store(struct config_item *item, - struct configfs_attribute *attr, - const char *page, size_t count) -{ - struct r2nm_node *node = to_r2nm_node(item); - struct r2nm_node_attribute *r2nm_node_attr = - container_of(attr, struct r2nm_node_attribute, attr); - ssize_t ret; - int attr_index = r2nm_attr_index(attr); - - if (r2nm_node_attr->store == NULL) { - ret = -EINVAL; - goto out; - } - - if (test_bit(attr_index, &node->nd_set_attributes)) - return -EBUSY; - - ret = r2nm_node_attr->store(node, page, count); - if (ret < count) - goto out; - - set_bit(attr_index, &node->nd_set_attributes); -out: - return ret; -} - -static struct configfs_item_operations r2nm_node_item_ops = { - .release = r2nm_node_release, - .show_attribute = r2nm_node_show, - .store_attribute = r2nm_node_store, -}; - -static struct config_item_type r2nm_node_type = { - .ct_item_ops = &r2nm_node_item_ops, - .ct_attrs = r2nm_node_attrs, - .ct_owner = THIS_MODULE, -}; - -/* node set */ - -struct r2nm_node_group { - struct config_group ns_group; - /* some stuff? */ -}; - -#if 0 -static struct r2nm_node_group *to_r2nm_node_group(struct config_group *group) -{ - return group ? - container_of(group, struct r2nm_node_group, ns_group) - : NULL; -} -#endif - -struct r2nm_cluster_attribute { - struct configfs_attribute attr; - ssize_t (*show)(struct r2nm_cluster *, char *); - ssize_t (*store)(struct r2nm_cluster *, const char *, size_t); -}; - -static ssize_t r2nm_cluster_attr_write(const char *page, ssize_t count, - unsigned int *val) -{ - unsigned long tmp; - char *p = (char *)page; - int err; - - err = kstrtoul(p, 10, &tmp); - if (err) - return err; - - if (tmp == 0) - return -EINVAL; - if (tmp >= (u32)-1) - return -ERANGE; - - *val = tmp; - - return count; -} - -static ssize_t r2nm_cluster_attr_idle_timeout_ms_read( - struct r2nm_cluster *cluster, char *page) -{ - return sprintf(page, "%u\n", cluster->cl_idle_timeout_ms); -} - -static ssize_t r2nm_cluster_attr_idle_timeout_ms_write( - struct r2nm_cluster *cluster, const char *page, size_t count) -{ - ssize_t ret; - unsigned int val = 0; - - ret = r2nm_cluster_attr_write(page, count, &val); - - if (ret > 0) { - if (cluster->cl_idle_timeout_ms != val - && r2net_num_connected_peers()) { - mlog(ML_NOTICE, - "r2net: cannot change idle timeout after " - "the first peer has agreed to it." - " %d connected peers\n", - r2net_num_connected_peers()); - ret = -EINVAL; - } else if (val <= cluster->cl_keepalive_delay_ms) { - mlog(ML_NOTICE, - "r2net: idle timeout must be larger " - "than keepalive delay\n"); - ret = -EINVAL; - } else { - cluster->cl_idle_timeout_ms = val; - } - } - - return ret; -} - -static ssize_t r2nm_cluster_attr_keepalive_delay_ms_read( - struct r2nm_cluster *cluster, char *page) -{ - return sprintf(page, "%u\n", cluster->cl_keepalive_delay_ms); -} - -static ssize_t r2nm_cluster_attr_keepalive_delay_ms_write( - struct r2nm_cluster *cluster, const char *page, size_t count) -{ - ssize_t ret; - unsigned int val = 0; - - ret = r2nm_cluster_attr_write(page, count, &val); - - if (ret > 0) { - if (cluster->cl_keepalive_delay_ms != val - && r2net_num_connected_peers()) { - mlog(ML_NOTICE, - "r2net: cannot change keepalive delay after" - " the first peer has agreed to it." - " %d connected peers\n", - r2net_num_connected_peers()); - ret = -EINVAL; - } else if (val >= cluster->cl_idle_timeout_ms) { - mlog(ML_NOTICE, - "r2net: keepalive delay must be " - "smaller than idle timeout\n"); - ret = -EINVAL; - } else { - cluster->cl_keepalive_delay_ms = val; - } - } - - return ret; -} - -static ssize_t r2nm_cluster_attr_reconnect_delay_ms_read( - struct r2nm_cluster *cluster, char *page) -{ - return sprintf(page, "%u\n", cluster->cl_reconnect_delay_ms); -} - -static ssize_t r2nm_cluster_attr_reconnect_delay_ms_write( - struct r2nm_cluster *cluster, const char *page, size_t count) -{ - return r2nm_cluster_attr_write(page, count, - &cluster->cl_reconnect_delay_ms); -} - -static ssize_t r2nm_cluster_attr_fence_method_read( - struct r2nm_cluster *cluster, char *page) -{ - ssize_t ret = 0; - - if (cluster) - ret = sprintf(page, "%s\n", - r2nm_fence_method_desc[cluster->cl_fence_method]); - return ret; -} - -static ssize_t r2nm_cluster_attr_fence_method_write( - struct r2nm_cluster *cluster, const char *page, size_t count) -{ - unsigned int i; - - if (page[count - 1] != '\n') - goto bail; - - for (i = 0; i < R2NM_FENCE_METHODS; ++i) { - if (count != strlen(r2nm_fence_method_desc[i]) + 1) - continue; - if (strncasecmp(page, r2nm_fence_method_desc[i], count - 1)) - continue; - if (cluster->cl_fence_method != i) { - pr_info("ramster: Changing fence method to %s\n", - r2nm_fence_method_desc[i]); - cluster->cl_fence_method = i; - } - return count; - } - -bail: - return -EINVAL; -} - -static struct r2nm_cluster_attribute r2nm_cluster_attr_idle_timeout_ms = { - .attr = { .ca_owner = THIS_MODULE, - .ca_name = "idle_timeout_ms", - .ca_mode = S_IRUGO | S_IWUSR }, - .show = r2nm_cluster_attr_idle_timeout_ms_read, - .store = r2nm_cluster_attr_idle_timeout_ms_write, -}; - -static struct r2nm_cluster_attribute r2nm_cluster_attr_keepalive_delay_ms = { - .attr = { .ca_owner = THIS_MODULE, - .ca_name = "keepalive_delay_ms", - .ca_mode = S_IRUGO | S_IWUSR }, - .show = r2nm_cluster_attr_keepalive_delay_ms_read, - .store = r2nm_cluster_attr_keepalive_delay_ms_write, -}; - -static struct r2nm_cluster_attribute r2nm_cluster_attr_reconnect_delay_ms = { - .attr = { .ca_owner = THIS_MODULE, - .ca_name = "reconnect_delay_ms", - .ca_mode = S_IRUGO | S_IWUSR }, - .show = r2nm_cluster_attr_reconnect_delay_ms_read, - .store = r2nm_cluster_attr_reconnect_delay_ms_write, -}; - -static struct r2nm_cluster_attribute r2nm_cluster_attr_fence_method = { - .attr = { .ca_owner = THIS_MODULE, - .ca_name = "fence_method", - .ca_mode = S_IRUGO | S_IWUSR }, - .show = r2nm_cluster_attr_fence_method_read, - .store = r2nm_cluster_attr_fence_method_write, -}; - -static struct configfs_attribute *r2nm_cluster_attrs[] = { - &r2nm_cluster_attr_idle_timeout_ms.attr, - &r2nm_cluster_attr_keepalive_delay_ms.attr, - &r2nm_cluster_attr_reconnect_delay_ms.attr, - &r2nm_cluster_attr_fence_method.attr, - NULL, -}; -static ssize_t r2nm_cluster_show(struct config_item *item, - struct configfs_attribute *attr, - char *page) -{ - struct r2nm_cluster *cluster = to_r2nm_cluster(item); - struct r2nm_cluster_attribute *r2nm_cluster_attr = - container_of(attr, struct r2nm_cluster_attribute, attr); - ssize_t ret = 0; - - if (r2nm_cluster_attr->show) - ret = r2nm_cluster_attr->show(cluster, page); - return ret; -} - -static ssize_t r2nm_cluster_store(struct config_item *item, - struct configfs_attribute *attr, - const char *page, size_t count) -{ - struct r2nm_cluster *cluster = to_r2nm_cluster(item); - struct r2nm_cluster_attribute *r2nm_cluster_attr = - container_of(attr, struct r2nm_cluster_attribute, attr); - ssize_t ret; - - if (r2nm_cluster_attr->store == NULL) { - ret = -EINVAL; - goto out; - } - - ret = r2nm_cluster_attr->store(cluster, page, count); - if (ret < count) - goto out; -out: - return ret; -} - -static struct config_item *r2nm_node_group_make_item(struct config_group *group, - const char *name) -{ - struct r2nm_node *node = NULL; - - if (strlen(name) > R2NM_MAX_NAME_LEN) - return ERR_PTR(-ENAMETOOLONG); - - node = kzalloc(sizeof(struct r2nm_node), GFP_KERNEL); - if (node == NULL) - return ERR_PTR(-ENOMEM); - - strcpy(node->nd_name, name); /* use item.ci_namebuf instead? */ - config_item_init_type_name(&node->nd_item, name, &r2nm_node_type); - spin_lock_init(&node->nd_lock); - - mlog(ML_CLUSTER, "r2nm: Registering node %s\n", name); - - return &node->nd_item; -} - -static void r2nm_node_group_drop_item(struct config_group *group, - struct config_item *item) -{ - struct r2nm_node *node = to_r2nm_node(item); - struct r2nm_cluster *cluster = - to_r2nm_cluster(group->cg_item.ci_parent); - - r2net_disconnect_node(node); - - if (cluster->cl_has_local && - (cluster->cl_local_node == node->nd_num)) { - cluster->cl_has_local = 0; - cluster->cl_local_node = R2NM_INVALID_NODE_NUM; - r2net_stop_listening(node); - } - - /* XXX call into net to stop this node from trading messages */ - - write_lock(&cluster->cl_nodes_lock); - - /* XXX sloppy */ - if (node->nd_ipv4_address) - rb_erase(&node->nd_ip_node, &cluster->cl_node_ip_tree); - - /* nd_num might be 0 if the node number hasn't been set.. */ - if (cluster->cl_nodes[node->nd_num] == node) { - cluster->cl_nodes[node->nd_num] = NULL; - clear_bit(node->nd_num, cluster->cl_nodes_bitmap); - } - write_unlock(&cluster->cl_nodes_lock); - - mlog(ML_CLUSTER, "r2nm: Unregistered node %s\n", - config_item_name(&node->nd_item)); - - config_item_put(item); -} - -static struct configfs_group_operations r2nm_node_group_group_ops = { - .make_item = r2nm_node_group_make_item, - .drop_item = r2nm_node_group_drop_item, -}; - -static struct config_item_type r2nm_node_group_type = { - .ct_group_ops = &r2nm_node_group_group_ops, - .ct_owner = THIS_MODULE, -}; - -/* cluster */ - -static void r2nm_cluster_release(struct config_item *item) -{ - struct r2nm_cluster *cluster = to_r2nm_cluster(item); - - kfree(cluster->cl_group.default_groups); - kfree(cluster); -} - -static struct configfs_item_operations r2nm_cluster_item_ops = { - .release = r2nm_cluster_release, - .show_attribute = r2nm_cluster_show, - .store_attribute = r2nm_cluster_store, -}; - -static struct config_item_type r2nm_cluster_type = { - .ct_item_ops = &r2nm_cluster_item_ops, - .ct_attrs = r2nm_cluster_attrs, - .ct_owner = THIS_MODULE, -}; - -/* cluster set */ - -struct r2nm_cluster_group { - struct configfs_subsystem cs_subsys; - /* some stuff? */ -}; - -#if 0 -static struct r2nm_cluster_group * -to_r2nm_cluster_group(struct config_group *group) -{ - return group ? - container_of(to_configfs_subsystem(group), - struct r2nm_cluster_group, cs_subsys) - : NULL; -} -#endif - -static struct config_group * -r2nm_cluster_group_make_group(struct config_group *group, - const char *name) -{ - struct r2nm_cluster *cluster = NULL; - struct r2nm_node_group *ns = NULL; - struct config_group *r2hb_group = NULL, *ret = NULL; - void *defs = NULL; - - /* this runs under the parent dir's i_mutex; there can be only - * one caller in here at a time */ - if (r2nm_single_cluster) - return ERR_PTR(-ENOSPC); - - cluster = kzalloc(sizeof(struct r2nm_cluster), GFP_KERNEL); - ns = kzalloc(sizeof(struct r2nm_node_group), GFP_KERNEL); - defs = kcalloc(3, sizeof(struct config_group *), GFP_KERNEL); - r2hb_group = r2hb_alloc_hb_set(); - if (cluster == NULL || ns == NULL || r2hb_group == NULL || defs == NULL) - goto out; - - config_group_init_type_name(&cluster->cl_group, name, - &r2nm_cluster_type); - config_group_init_type_name(&ns->ns_group, "node", - &r2nm_node_group_type); - - cluster->cl_group.default_groups = defs; - cluster->cl_group.default_groups[0] = &ns->ns_group; - cluster->cl_group.default_groups[1] = r2hb_group; - cluster->cl_group.default_groups[2] = NULL; - rwlock_init(&cluster->cl_nodes_lock); - cluster->cl_node_ip_tree = RB_ROOT; - cluster->cl_reconnect_delay_ms = R2NET_RECONNECT_DELAY_MS_DEFAULT; - cluster->cl_idle_timeout_ms = R2NET_IDLE_TIMEOUT_MS_DEFAULT; - cluster->cl_keepalive_delay_ms = R2NET_KEEPALIVE_DELAY_MS_DEFAULT; - cluster->cl_fence_method = R2NM_FENCE_RESET; - - ret = &cluster->cl_group; - r2nm_single_cluster = cluster; - -out: - if (ret == NULL) { - kfree(cluster); - kfree(ns); - r2hb_free_hb_set(r2hb_group); - kfree(defs); - ret = ERR_PTR(-ENOMEM); - } - - return ret; -} - -static void r2nm_cluster_group_drop_item(struct config_group *group, - struct config_item *item) -{ - struct r2nm_cluster *cluster = to_r2nm_cluster(item); - int i; - struct config_item *killme; - - BUG_ON(r2nm_single_cluster != cluster); - r2nm_single_cluster = NULL; - - for (i = 0; cluster->cl_group.default_groups[i]; i++) { - killme = &cluster->cl_group.default_groups[i]->cg_item; - cluster->cl_group.default_groups[i] = NULL; - config_item_put(killme); - } - - config_item_put(item); -} - -static struct configfs_group_operations r2nm_cluster_group_group_ops = { - .make_group = r2nm_cluster_group_make_group, - .drop_item = r2nm_cluster_group_drop_item, -}; - -static struct config_item_type r2nm_cluster_group_type = { - .ct_group_ops = &r2nm_cluster_group_group_ops, - .ct_owner = THIS_MODULE, -}; - -static struct r2nm_cluster_group r2nm_cluster_group = { - .cs_subsys = { - .su_group = { - .cg_item = { - .ci_namebuf = "cluster", - .ci_type = &r2nm_cluster_group_type, - }, - }, - }, -}; - -int r2nm_depend_item(struct config_item *item) -{ - return configfs_depend_item(&r2nm_cluster_group.cs_subsys, item); -} - -void r2nm_undepend_item(struct config_item *item) -{ - configfs_undepend_item(&r2nm_cluster_group.cs_subsys, item); -} - -int r2nm_depend_this_node(void) -{ - int ret = 0; - struct r2nm_node *local_node; - - local_node = r2nm_get_node_by_num(r2nm_this_node()); - if (!local_node) { - ret = -EINVAL; - goto out; - } - - ret = r2nm_depend_item(&local_node->nd_item); - r2nm_node_put(local_node); - -out: - return ret; -} - -void r2nm_undepend_this_node(void) -{ - struct r2nm_node *local_node; - - local_node = r2nm_get_node_by_num(r2nm_this_node()); - BUG_ON(!local_node); - - r2nm_undepend_item(&local_node->nd_item); - r2nm_node_put(local_node); -} - - -static void __exit exit_r2nm(void) -{ - /* XXX sync with hb callbacks and shut down hb? */ - r2net_unregister_hb_callbacks(); - configfs_unregister_subsystem(&r2nm_cluster_group.cs_subsys); - - r2net_exit(); - r2hb_exit(); -} - -int r2nm_init(void) -{ - int ret = -1; - - ret = r2hb_init(); - if (ret) - goto out; - - ret = r2net_init(); - if (ret) - goto out_r2hb; - - ret = r2net_register_hb_callbacks(); - if (ret) - goto out_r2net; - - config_group_init(&r2nm_cluster_group.cs_subsys.su_group); - mutex_init(&r2nm_cluster_group.cs_subsys.su_mutex); - ret = configfs_register_subsystem(&r2nm_cluster_group.cs_subsys); - if (ret) { - pr_err("nodemanager: Registration returned %d\n", ret); - goto out_callbacks; - } - - if (!ret) - goto out; - - configfs_unregister_subsystem(&r2nm_cluster_group.cs_subsys); -out_callbacks: - r2net_unregister_hb_callbacks(); -out_r2net: - r2net_exit(); -out_r2hb: - r2hb_exit(); -out: - return ret; -} -EXPORT_SYMBOL_GPL(r2nm_init); - -MODULE_AUTHOR("Oracle"); -MODULE_LICENSE("GPL"); - -#ifndef CONFIG_RAMSTER_MODULE -late_initcall(r2nm_init); -#endif diff --git a/drivers/staging/zcache/ramster/nodemanager.h b/drivers/staging/zcache/ramster/nodemanager.h deleted file mode 100644 index 41a04df5842cb..0000000000000 --- a/drivers/staging/zcache/ramster/nodemanager.h +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; -*- - * vim: noexpandtab sw=8 ts=8 sts=0: - * - * nodemanager.h - * - * Function prototypes - * - * Copyright (C) 2004 Oracle. All rights reserved. - * - * 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 the License, or (at your option) any later version. - * - * 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. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 021110-1307, USA. - * - */ - -#ifndef R2CLUSTER_NODEMANAGER_H -#define R2CLUSTER_NODEMANAGER_H - -#include "ramster_nodemanager.h" - -/* This totally doesn't belong here. */ -#include -#include - -enum r2nm_fence_method { - R2NM_FENCE_RESET = 0, - R2NM_FENCE_PANIC, - R2NM_FENCE_METHODS, /* Number of fence methods */ -}; - -struct r2nm_node { - spinlock_t nd_lock; - struct config_item nd_item; - char nd_name[R2NM_MAX_NAME_LEN+1]; /* replace? */ - __u8 nd_num; - /* only one address per node, as attributes, for now. */ - __be32 nd_ipv4_address; - __be16 nd_ipv4_port; - struct rb_node nd_ip_node; - /* there can be only one local node for now */ - int nd_local; - - unsigned long nd_set_attributes; -}; - -struct r2nm_cluster { - struct config_group cl_group; - unsigned cl_has_local:1; - u8 cl_local_node; - rwlock_t cl_nodes_lock; - struct r2nm_node *cl_nodes[R2NM_MAX_NODES]; - struct rb_root cl_node_ip_tree; - unsigned int cl_idle_timeout_ms; - unsigned int cl_keepalive_delay_ms; - unsigned int cl_reconnect_delay_ms; - enum r2nm_fence_method cl_fence_method; - - /* part of a hack for disk bitmap.. will go eventually. - zab */ - unsigned long cl_nodes_bitmap[BITS_TO_LONGS(R2NM_MAX_NODES)]; -}; - -extern struct r2nm_cluster *r2nm_single_cluster; - -u8 r2nm_this_node(void); - -int r2nm_configured_node_map(unsigned long *map, unsigned bytes); -struct r2nm_node *r2nm_get_node_by_num(u8 node_num); -struct r2nm_node *r2nm_get_node_by_ip(__be32 addr); -void r2nm_node_get(struct r2nm_node *node); -void r2nm_node_put(struct r2nm_node *node); - -int r2nm_depend_item(struct config_item *item); -void r2nm_undepend_item(struct config_item *item); -int r2nm_depend_this_node(void); -void r2nm_undepend_this_node(void); - -#endif /* R2CLUSTER_NODEMANAGER_H */ diff --git a/drivers/staging/zcache/ramster/r2net.c b/drivers/staging/zcache/ramster/r2net.c deleted file mode 100644 index 34818dc656124..0000000000000 --- a/drivers/staging/zcache/ramster/r2net.c +++ /dev/null @@ -1,414 +0,0 @@ -/* - * r2net.c - * - * Copyright (c) 2011-2012, Dan Magenheimer, Oracle Corp. - * - * Ramster_r2net provides an interface between zcache and r2net. - * - * FIXME: support more than two nodes - */ - -#include -#include "tcp.h" -#include "nodemanager.h" -#include "../tmem.h" -#include "../zcache.h" -#include "ramster.h" - -#define RAMSTER_TESTING - -#define RMSTR_KEY 0x77347734 - -enum { - RMSTR_TMEM_PUT_EPH = 100, - RMSTR_TMEM_PUT_PERS, - RMSTR_TMEM_ASYNC_GET_REQUEST, - RMSTR_TMEM_ASYNC_GET_AND_FREE_REQUEST, - RMSTR_TMEM_ASYNC_GET_REPLY, - RMSTR_TMEM_FLUSH, - RMSTR_TMEM_FLOBJ, - RMSTR_TMEM_DESTROY_POOL, -}; - -#define RMSTR_R2NET_MAX_LEN \ - (R2NET_MAX_PAYLOAD_BYTES - sizeof(struct tmem_xhandle)) - -#include "tcp_internal.h" - -static struct r2nm_node *r2net_target_node; -static int r2net_target_nodenum; - -int r2net_remote_target_node_set(int node_num) -{ - int ret = -1; - - r2net_target_node = r2nm_get_node_by_num(node_num); - if (r2net_target_node != NULL) { - r2net_target_nodenum = node_num; - r2nm_node_put(r2net_target_node); - ret = 0; - } - return ret; -} - -/* FIXME following buffer should be per-cpu, protected by preempt_disable */ -static char ramster_async_get_buf[R2NET_MAX_PAYLOAD_BYTES]; - -static int ramster_remote_async_get_request_handler(struct r2net_msg *msg, - u32 len, void *data, void **ret_data) -{ - char *pdata; - struct tmem_xhandle xh; - int found; - size_t size = RMSTR_R2NET_MAX_LEN; - u16 msgtype = be16_to_cpu(msg->msg_type); - bool get_and_free = (msgtype == RMSTR_TMEM_ASYNC_GET_AND_FREE_REQUEST); - unsigned long flags; - - xh = *(struct tmem_xhandle *)msg->buf; - if (xh.xh_data_size > RMSTR_R2NET_MAX_LEN) - BUG(); - pdata = ramster_async_get_buf; - *(struct tmem_xhandle *)pdata = xh; - pdata += sizeof(struct tmem_xhandle); - local_irq_save(flags); - found = zcache_get_page(xh.client_id, xh.pool_id, &xh.oid, xh.index, - pdata, &size, true, get_and_free ? 1 : -1); - local_irq_restore(flags); - if (found < 0) { - /* a zero size indicates the get failed */ - size = 0; - } - if (size > RMSTR_R2NET_MAX_LEN) - BUG(); - *ret_data = pdata - sizeof(struct tmem_xhandle); - /* now make caller (r2net_process_message) handle specially */ - r2net_force_data_magic(msg, RMSTR_TMEM_ASYNC_GET_REPLY, RMSTR_KEY); - return size + sizeof(struct tmem_xhandle); -} - -static int ramster_remote_async_get_reply_handler(struct r2net_msg *msg, - u32 len, void *data, void **ret_data) -{ - char *in = (char *)msg->buf; - int datalen = len - sizeof(struct r2net_msg); - int ret = -1; - struct tmem_xhandle *xh = (struct tmem_xhandle *)in; - - in += sizeof(struct tmem_xhandle); - datalen -= sizeof(struct tmem_xhandle); - BUG_ON(datalen < 0 || datalen > PAGE_SIZE); - ret = ramster_localify(xh->pool_id, &xh->oid, xh->index, - in, datalen, xh->extra); -#ifdef RAMSTER_TESTING - if (ret == -EEXIST) - pr_err("TESTING ArrgREP, aborted overwrite on racy put\n"); -#endif - return ret; -} - -int ramster_remote_put_handler(struct r2net_msg *msg, - u32 len, void *data, void **ret_data) -{ - struct tmem_xhandle *xh; - char *p = (char *)msg->buf; - int datalen = len - sizeof(struct r2net_msg) - - sizeof(struct tmem_xhandle); - u16 msgtype = be16_to_cpu(msg->msg_type); - bool ephemeral = (msgtype == RMSTR_TMEM_PUT_EPH); - unsigned long flags; - int ret; - - xh = (struct tmem_xhandle *)p; - p += sizeof(struct tmem_xhandle); - zcache_autocreate_pool(xh->client_id, xh->pool_id, ephemeral); - local_irq_save(flags); - ret = zcache_put_page(xh->client_id, xh->pool_id, &xh->oid, xh->index, - p, datalen, true, ephemeral); - local_irq_restore(flags); - return ret; -} - -int ramster_remote_flush_handler(struct r2net_msg *msg, - u32 len, void *data, void **ret_data) -{ - struct tmem_xhandle *xh; - char *p = (char *)msg->buf; - - xh = (struct tmem_xhandle *)p; - p += sizeof(struct tmem_xhandle); - (void)zcache_flush_page(xh->client_id, xh->pool_id, - &xh->oid, xh->index); - return 0; -} - -int ramster_remote_flobj_handler(struct r2net_msg *msg, - u32 len, void *data, void **ret_data) -{ - struct tmem_xhandle *xh; - char *p = (char *)msg->buf; - - xh = (struct tmem_xhandle *)p; - p += sizeof(struct tmem_xhandle); - (void)zcache_flush_object(xh->client_id, xh->pool_id, &xh->oid); - return 0; -} - -int r2net_remote_async_get(struct tmem_xhandle *xh, bool free, int remotenode, - size_t expect_size, uint8_t expect_cksum, - void *extra) -{ - int nodenum, ret = -1, status; - struct r2nm_node *node = NULL; - struct kvec vec[1]; - size_t veclen = 1; - u32 msg_type; - struct r2net_node *nn; - - node = r2nm_get_node_by_num(remotenode); - if (node == NULL) - goto out; - xh->client_id = r2nm_this_node(); /* which node is getting */ - xh->xh_data_cksum = expect_cksum; - xh->xh_data_size = expect_size; - xh->extra = extra; - vec[0].iov_len = sizeof(*xh); - vec[0].iov_base = xh; - - node = r2net_target_node; - if (!node) - goto out; - - nodenum = r2net_target_nodenum; - - r2nm_node_get(node); - nn = r2net_nn_from_num(nodenum); - if (nn->nn_persistent_error || !nn->nn_sc_valid) { - ret = -ENOTCONN; - r2nm_node_put(node); - goto out; - } - - if (free) - msg_type = RMSTR_TMEM_ASYNC_GET_AND_FREE_REQUEST; - else - msg_type = RMSTR_TMEM_ASYNC_GET_REQUEST; - ret = r2net_send_message_vec(msg_type, RMSTR_KEY, - vec, veclen, remotenode, &status); - r2nm_node_put(node); - if (ret < 0) { - if (ret == -ENOTCONN || ret == -EHOSTDOWN) - goto out; - if (ret == -EAGAIN) - goto out; - /* FIXME handle bad message possibilities here? */ - pr_err("UNTESTED ret<0 in ramster_remote_async_get: ret=%d\n", - ret); - } - ret = status; -out: - return ret; -} - -#ifdef RAMSTER_TESTING -/* leave me here to see if it catches a weird crash */ -static void ramster_check_irq_counts(void) -{ - static int last_hardirq_cnt, last_softirq_cnt, last_preempt_cnt; - int cur_hardirq_cnt, cur_softirq_cnt, cur_preempt_cnt; - - cur_hardirq_cnt = hardirq_count() >> HARDIRQ_SHIFT; - if (cur_hardirq_cnt > last_hardirq_cnt) { - last_hardirq_cnt = cur_hardirq_cnt; - if (!(last_hardirq_cnt&(last_hardirq_cnt-1))) - pr_err("RAMSTER TESTING RRP hardirq_count=%d\n", - last_hardirq_cnt); - } - cur_softirq_cnt = softirq_count() >> SOFTIRQ_SHIFT; - if (cur_softirq_cnt > last_softirq_cnt) { - last_softirq_cnt = cur_softirq_cnt; - if (!(last_softirq_cnt&(last_softirq_cnt-1))) - pr_err("RAMSTER TESTING RRP softirq_count=%d\n", - last_softirq_cnt); - } - cur_preempt_cnt = preempt_count() & PREEMPT_MASK; - if (cur_preempt_cnt > last_preempt_cnt) { - last_preempt_cnt = cur_preempt_cnt; - if (!(last_preempt_cnt&(last_preempt_cnt-1))) - pr_err("RAMSTER TESTING RRP preempt_count=%d\n", - last_preempt_cnt); - } -} -#endif - -int r2net_remote_put(struct tmem_xhandle *xh, char *data, size_t size, - bool ephemeral, int *remotenode) -{ - int nodenum, ret = -1, status; - struct r2nm_node *node = NULL; - struct kvec vec[2]; - size_t veclen = 2; - u32 msg_type; - struct r2net_node *nn; - - BUG_ON(size > RMSTR_R2NET_MAX_LEN); - xh->client_id = r2nm_this_node(); /* which node is putting */ - vec[0].iov_len = sizeof(*xh); - vec[0].iov_base = xh; - vec[1].iov_len = size; - vec[1].iov_base = data; - - node = r2net_target_node; - if (!node) - goto out; - - nodenum = r2net_target_nodenum; - - r2nm_node_get(node); - - nn = r2net_nn_from_num(nodenum); - if (nn->nn_persistent_error || !nn->nn_sc_valid) { - ret = -ENOTCONN; - r2nm_node_put(node); - goto out; - } - - if (ephemeral) - msg_type = RMSTR_TMEM_PUT_EPH; - else - msg_type = RMSTR_TMEM_PUT_PERS; -#ifdef RAMSTER_TESTING - /* leave me here to see if it catches a weird crash */ - ramster_check_irq_counts(); -#endif - - ret = r2net_send_message_vec(msg_type, RMSTR_KEY, vec, veclen, - nodenum, &status); - if (ret < 0) - ret = -1; - else { - ret = status; - *remotenode = nodenum; - } - - r2nm_node_put(node); -out: - return ret; -} - -int r2net_remote_flush(struct tmem_xhandle *xh, int remotenode) -{ - int ret = -1, status; - struct r2nm_node *node = NULL; - struct kvec vec[1]; - size_t veclen = 1; - - node = r2nm_get_node_by_num(remotenode); - BUG_ON(node == NULL); - xh->client_id = r2nm_this_node(); /* which node is flushing */ - vec[0].iov_len = sizeof(*xh); - vec[0].iov_base = xh; - BUG_ON(irqs_disabled()); - BUG_ON(in_softirq()); - ret = r2net_send_message_vec(RMSTR_TMEM_FLUSH, RMSTR_KEY, - vec, veclen, remotenode, &status); - r2nm_node_put(node); - return ret; -} - -int r2net_remote_flush_object(struct tmem_xhandle *xh, int remotenode) -{ - int ret = -1, status; - struct r2nm_node *node = NULL; - struct kvec vec[1]; - size_t veclen = 1; - - node = r2nm_get_node_by_num(remotenode); - BUG_ON(node == NULL); - xh->client_id = r2nm_this_node(); /* which node is flobjing */ - vec[0].iov_len = sizeof(*xh); - vec[0].iov_base = xh; - ret = r2net_send_message_vec(RMSTR_TMEM_FLOBJ, RMSTR_KEY, - vec, veclen, remotenode, &status); - r2nm_node_put(node); - return ret; -} - -/* - * Handler registration - */ - -static LIST_HEAD(r2net_unreg_list); - -static void r2net_unregister_handlers(void) -{ - r2net_unregister_handler_list(&r2net_unreg_list); -} - -int r2net_register_handlers(void) -{ - int status; - - status = r2net_register_handler(RMSTR_TMEM_PUT_EPH, RMSTR_KEY, - RMSTR_R2NET_MAX_LEN, - ramster_remote_put_handler, - NULL, NULL, &r2net_unreg_list); - if (status) - goto bail; - - status = r2net_register_handler(RMSTR_TMEM_PUT_PERS, RMSTR_KEY, - RMSTR_R2NET_MAX_LEN, - ramster_remote_put_handler, - NULL, NULL, &r2net_unreg_list); - if (status) - goto bail; - - status = r2net_register_handler(RMSTR_TMEM_ASYNC_GET_REQUEST, RMSTR_KEY, - RMSTR_R2NET_MAX_LEN, - ramster_remote_async_get_request_handler, - NULL, NULL, - &r2net_unreg_list); - if (status) - goto bail; - - status = r2net_register_handler(RMSTR_TMEM_ASYNC_GET_AND_FREE_REQUEST, - RMSTR_KEY, RMSTR_R2NET_MAX_LEN, - ramster_remote_async_get_request_handler, - NULL, NULL, - &r2net_unreg_list); - if (status) - goto bail; - - status = r2net_register_handler(RMSTR_TMEM_ASYNC_GET_REPLY, RMSTR_KEY, - RMSTR_R2NET_MAX_LEN, - ramster_remote_async_get_reply_handler, - NULL, NULL, - &r2net_unreg_list); - if (status) - goto bail; - - status = r2net_register_handler(RMSTR_TMEM_FLUSH, RMSTR_KEY, - RMSTR_R2NET_MAX_LEN, - ramster_remote_flush_handler, - NULL, NULL, - &r2net_unreg_list); - if (status) - goto bail; - - status = r2net_register_handler(RMSTR_TMEM_FLOBJ, RMSTR_KEY, - RMSTR_R2NET_MAX_LEN, - ramster_remote_flobj_handler, - NULL, NULL, - &r2net_unreg_list); - if (status) - goto bail; - - pr_info("ramster: r2net handlers registered\n"); - -bail: - if (status) { - r2net_unregister_handlers(); - pr_err("ramster: couldn't register r2net handlers\n"); - } - return status; -} diff --git a/drivers/staging/zcache/ramster/ramster-howto.txt b/drivers/staging/zcache/ramster/ramster-howto.txt deleted file mode 100644 index 7b1ee3bbfdd50..0000000000000 --- a/drivers/staging/zcache/ramster/ramster-howto.txt +++ /dev/null @@ -1,366 +0,0 @@ - RAMSTER HOW-TO - -Author: Dan Magenheimer -Ramster maintainer: Konrad Wilk - -This is a HOWTO document for ramster which, as of this writing, is in -the kernel as a subdirectory of zcache in drivers/staging, called ramster. -(Zcache can be built with or without ramster functionality.) If enabled -and properly configured, ramster allows memory capacity load balancing -across multiple machines in a cluster. Further, the ramster code serves -as an example of asynchronous access for zcache (as well as cleancache and -frontswap) that may prove useful for future transcendent memory -implementations, such as KVM and NVRAM. While ramster works today on -any network connection that supports kernel sockets, its features may -become more interesting on future high-speed fabrics/interconnects. - -Ramster requires both kernel and userland support. The userland support, -called ramster-tools, is known to work with EL6-based distros, but is a -set of poorly-hacked slightly-modified cluster tools based on ocfs2, which -includes an init file, a config file, and a userland binary that interfaces -to the kernel. This state of userland support reflects the abysmal userland -skills of this suitably-embarrassed author; any help/patches to turn -ramster-tools into more distributable rpms/debs useful for a wider range -of distros would be appreciated. The source RPM that can be used as a -starting point is available at: - http://oss.oracle.com/projects/tmem/files/RAMster/ - -As a result of this author's ignorance, userland setup described in this -HOWTO assumes an EL6 distro and is described in EL6 syntax. Apologies -if this offends anyone! - -Kernel support has only been tested on x86_64. Systems with an active -ocfs2 filesystem should work, but since ramster leverages a lot of -code from ocfs2, there may be latent issues. A kernel configuration that -includes CONFIG_OCFS2_FS should build OK, and should certainly run OK -if no ocfs2 filesystem is mounted. - -This HOWTO demonstrates memory capacity load balancing for a two-node -cluster, where one node called the "local" node becomes overcommitted -and the other node called the "remote" node provides additional RAM -capacity for use by the local node. Ramster is capable of more complex -topologies; see the last section titled "ADVANCED RAMSTER TOPOLOGIES". - -If you find any terms in this HOWTO unfamiliar or don't understand the -motivation for ramster, the following LWN reading is recommended: --- Transcendent Memory in a Nutshell (lwn.net/Articles/454795) --- The future calculus of memory management (lwn.net/Articles/475681) -And since ramster is built on top of zcache, this article may be helpful: --- In-kernel memory compression (lwn.net/Articles/545244) - -Now that you've memorized the contents of those articles, let's get started! - -A. PRELIMINARY - -1) Install two x86_64 Linux systems that are known to work when - upgraded to a recent upstream Linux kernel version. - -On each system: - -2) Configure, build and install, then boot Linux, just to ensure it - can be done with an unmodified upstream kernel. Confirm you booted - the upstream kernel with "uname -a". - -3) If you plan to do any performance testing or unless you plan to - test only swapping, the "WasActive" patch is also highly recommended. - (Search lkml.org for WasActive, apply the patch, rebuild your kernel.) - For a demo or simple testing, the patch can be ignored. - -4) Install ramster-tools as root. An x86_64 rpm for EL6-based systems - can be found at: - http://oss.oracle.com/projects/tmem/files/RAMster/ - (Sorry but for now, non-EL6 users must recreate ramster-tools on - their own from source. See above.) - -5) Ensure that debugfs is mounted at each boot. Examples below assume it - is mounted at /sys/kernel/debug. - -B. BUILDING RAMSTER INTO THE KERNEL - -Do the following on each system: - -1) Using the kernel configuration mechanism of your choice, change - your config to include: - - CONFIG_CLEANCACHE=y - CONFIG_FRONTSWAP=y - CONFIG_STAGING=y - CONFIG_CONFIGFS_FS=y # NOTE: MUST BE y, not m - CONFIG_ZCACHE=y - CONFIG_RAMSTER=y - - For a linux-3.10 or later kernel, you should also set: - - CONFIG_ZCACHE_DEBUG=y - CONFIG_RAMSTER_DEBUG=y - - Before building the kernel please doublecheck your kernel config - file to ensure all of the settings are correct. - -2) Build this kernel and change your boot file (e.g. /etc/grub.conf) - so that the new kernel will boot. - -3) Add "zcache" and "ramster" as kernel boot parameters for the new kernel. - -4) Reboot each system approximately simultaneously. - -5) Check dmesg to ensure there are some messages from ramster, prefixed - by "ramster:" - - # dmesg | grep ramster - - You should also see a lot of files in: - - # ls /sys/kernel/debug/zcache - # ls /sys/kernel/debug/ramster - - These are mostly counters for various zcache and ramster activities. - You should also see files in: - - # ls /sys/kernel/mm/ramster - - These are sysfs files that control ramster as we shall see. - - Ramster now will act as a single-system zcache on each system - but doesn't yet know anything about the cluster so can't yet do - anything remotely. - -C. CONFIGURING THE RAMSTER CLUSTER - -This part can be error prone unless you are familiar with clustering -filesystems. We need to describe the cluster in a /etc/ramster.conf -file and the init scripts that parse it are extremely picky about -the syntax. - -1) Create a /etc/ramster.conf file and ensure it is identical on both - systems. This file mimics the ocfs2 format and there is a good amount - of documentation that can be searched for ocfs2.conf, but you can use: - - cluster: - name = ramster - node_count = 2 - node: - name = system1 - cluster = ramster - number = 0 - ip_address = my.ip.ad.r1 - ip_port = 7777 - node: - name = system2 - cluster = ramster - number = 1 - ip_address = my.ip.ad.r2 - ip_port = 7777 - - You must ensure that the "name" field in the file exactly matches - the output of "hostname" on each system; if "hostname" shows a - fully-qualified hostname, ensure the name is fully qualified in - /etc/ramster.conf. Obviously, substitute my.ip.ad.rx with proper - ip addresses. - -2) Enable the ramster service and configure it. If you used the - EL6 ramster-tools, this would be: - - # chkconfig --add ramster - # service ramster configure - - Set "load on boot" to "y", cluster to start is "ramster" (or whatever - name you chose in ramster.conf), heartbeat dead threshold as "500", - network idle timeout as "1000000". Leave the others as default. - -3) Reboot both systems. After reboot, try (assuming EL6 ramster-tools): - - # service ramster status - - You should see "Checking RAMSTER cluster "ramster": Online". If you do - not, something is wrong and ramster will not work. Note that you - should also see that the driver for "configfs" is loaded and mounted, - the driver for ocfs2_dlmfs is not loaded, and some numbers for network - parameters. You will also see "Checking RAMSTER heartbeat: Not active". - That's all OK. - -4) Now you need to start the cluster heartbeat; the cluster is not "up" - until all nodes detect a heartbeat. In a real cluster, heartbeat detection - is done via a cluster filesystem, but ramster doesn't require one. Some - hack-y kernel code in ramster can start the heartbeat for you though if - you tell it what nodes are "up". To enable the heartbeat, do: - - # echo 0 > /sys/kernel/mm/ramster/manual_node_up - # echo 1 > /sys/kernel/mm/ramster/manual_node_up - - This must be done on BOTH nodes and, to avoid timeouts, must be done - approximately concurrently on both nodes. On an EL6 system, it is - convenient to put these lines in /etc/rc.local. To confirm that the - cluster is now up, on both systems do: - - # dmesg | grep ramster - - You should see ramster "Accepted connection" messages in dmesg on both - nodes after this. Note that if you check userland status again with - - # service ramster status - - you will still see "Checking RAMSTER heartbeat: Not active". That's - still OK... the ramster kernel heartbeat hack doesn't communicate to - userland. - -5) You now must tell each node the node to which it should "remotify" pages. - On this two node cluster, we will assume the "local" node, node 0, has - memory overcommitted and will use ramster to utilize RAM capacity on - the "remote node", node 1. To configure this, on node 0, you do: - - # echo 1 > /sys/kernel/mm/ramster/remote_target_nodenum - - You should see "ramster: node 1 set as remotification target" in dmesg - on node 0. Again, on EL6, /etc/rc.local is a good place to put this - on node 0 so you don't forget to do it at each boot. - -6) One more step: By default, the ramster code does not "remotify" any - pages; this is primarily for testing purposes, but sometimes it is - useful. This may change in the future, but for now, on node 0, you do: - - # echo 1 > /sys/kernel/mm/ramster/pers_remotify_enable - # echo 1 > /sys/kernel/mm/ramster/eph_remotify_enable - - The first enables remotifying swap (persistent, aka frontswap) pages, - the second enables remotifying of page cache (ephemeral, cleancache) - pages. - - On EL6, these lines can also be put in /etc/rc.local (AFTER the - node_up lines), or at the beginning of a script that runs a workload. - -7) Note that most testing has been done with both/all machines booted - roughly simultaneously to avoid cluster timeouts. Ideally, you should - do this too unless you are trying to break ramster rather than just - use it. ;-) - -D. TESTING RAMSTER - -1) Note that ramster has no value unless pages get "remotified". For - swap/frontswap/persistent pages, this doesn't happen unless/until - the workload would cause swapping to occur, at which point pages - are put into frontswap/zcache, and the remotification thread starts - working. To get to the point where the system swaps, you either - need a workload for which the working set exceeds the RAM in the - system; or you need to somehow reduce the amount of RAM one of - the system sees. This latter is easy when testing in a VM, but - harder on physical systems. In some cases, "mem=xxxM" on the - kernel command line restricts memory, but for some values of xxx - the kernel may fail to boot. One may also try creating a fixed - RAMdisk, doing nothing with it, but ensuring that it eats up a fixed - amount of RAM. - -2) To see if ramster is working, on the "remote node", node 1, try: - - # grep . /sys/kernel/debug/ramster/foreign_* - # # note, that is space-dot-space between grep and the pathname - - to monitor the number (and max) ephemeral and persistent pages - that ramster has sent. If these stay at zero, ramster is not working - either because the workload on the local node (node 0) isn't creating - enough memory pressure or because "remotifying" isn't working. On the - local system, node 0, you can watch lots of useful information also. - Try: - - grep . /sys/kernel/debug/zcache/*pageframes* \ - /sys/kernel/debug/zcache/*zbytes* \ - /sys/kernel/debug/zcache/*zpages* \ - /sys/kernel/debug/ramster/*remote* - - Of particular note are the remote_*_pages_succ_get counters. These - show how many disk reads and/or disk writes have been avoided on the - overcommitted local system by storing pages remotely using ramster. - - At the risk of information overload, you can also grep: - - /sys/kernel/debug/cleancache/* and /sys/kernel/debug/frontswap/* - - These show, for example, how many disk reads and/or disk writes have - been avoided by using zcache to optimize RAM on the local system. - - -AUTOMATIC SWAP REPATRIATION - -You may notice that while the systems are idle, the foreign persistent -page count on the remote machine slowly decreases. This is because -ramster implements "frontswap selfshrinking": When possible, swap -pages that have been remotified are slowly repatriated to the local -machine. This is so that local RAM can be used when possible and -so that, in case of remote machine crash, the probability of loss -of data is reduced. - -REBOOTING / POWEROFF - -If a system is shut down while some of its swap pages still reside -on a remote system, the system may lock up during the shutdown -sequence. This will occur if the network is shut down before the -swap mechansim is shut down, which is the default ordering on many -distros. To avoid this annoying problem, simply shut off the swap -subsystem before starting the shutdown sequence, e.g.: - - # swapoff -a - # reboot - -Ideally, this swapoff-before-ifdown ordering should be enforced permanently -using shutdown scripts. - -KNOWN PROBLEMS - -1) You may periodically see messages such as: - - ramster_r2net, message length problem - - This is harmless but indicates that a node is sending messages - containing compressed pages that exceed the maximum for zcache - (PAGE_SIZE*15/16). The sender side needs to be fixed. - -2) If you see a "No longer connected to node..." message or a "No connection - established with node X after N seconds", it is possible you may - be in an unrecoverable state. If you are certain all of the - appropriate cluster configuration steps described above have been - performed, try rebooting the two servers concurrently to see if - the cluster starts. - - Note that "Connection to node... shutdown, state 7" is an intermediate - connection state. As long as you later see "Accepted connection", the - intermediate states are harmless. - -3) There are known issues in counting certain values. As a result - you may see periodic warnings from the kernel. Almost always you - will see "ramster: bad accounting for XXX". There are also "WARN_ONCE" - messages. If you see kernel warnings with a tombstone, please report - them. They are harmless but reflect bugs that need to be eventually fixed. - -ADVANCED RAMSTER TOPOLOGIES - -The kernel code for ramster can support up to eight nodes in a cluster, -but no testing has been done with more than three nodes. - -In the example described above, the "remote" node serves as a RAM -overflow for the "local" node. This can be made symmetric by appropriate -settings of the sysfs remote_target_nodenum file. For example, by setting: - - # echo 1 > /sys/kernel/mm/ramster/remote_target_nodenum - -on node 0, and - - # echo 0 > /sys/kernel/mm/ramster/remote_target_nodenum - -on node 1, each node can serve as a RAM overflow for the other. - -For more than two nodes, a "RAM server" can be configured. For a -three node system, set: - - # echo 0 > /sys/kernel/mm/ramster/remote_target_nodenum - -on node 1, and - - # echo 0 > /sys/kernel/mm/ramster/remote_target_nodenum - -on node 2. Then node 0 is a RAM server for node 1 and node 2. - -In this implementation of ramster, any remote node is potentially a single -point of failure (SPOF). Though the probability of failure is reduced -by automatic swap repatriation (see above), a proposed future enhancement -to ramster improves high-availability for the cluster by sending a copy -of each page of date to two other nodes. Patches welcome! diff --git a/drivers/staging/zcache/ramster/ramster.c b/drivers/staging/zcache/ramster/ramster.c deleted file mode 100644 index a937ce1fa27af..0000000000000 --- a/drivers/staging/zcache/ramster/ramster.c +++ /dev/null @@ -1,925 +0,0 @@ -/* - * ramster.c - * - * Copyright (c) 2010-2012, Dan Magenheimer, Oracle Corp. - * - * RAMster implements peer-to-peer transcendent memory, allowing a "cluster" of - * kernels to dynamically pool their RAM so that a RAM-hungry workload on one - * machine can temporarily and transparently utilize RAM on another machine - * which is presumably idle or running a non-RAM-hungry workload. - * - * RAMster combines a clustering and messaging foundation based on the ocfs2 - * cluster layer with the in-kernel compression implementation of zcache, and - * adds code to glue them together. When a page is "put" to RAMster, it is - * compressed and stored locally. Periodically, a thread will "remotify" these - * pages by sending them via messages to a remote machine. When the page is - * later needed as indicated by a page fault, a "get" is issued. If the data - * is local, it is uncompressed and the fault is resolved. If the data is - * remote, a message is sent to fetch the data and the faulting thread sleeps; - * when the data arrives, the thread awakens, the data is decompressed and - * the fault is resolved. - - * As of V5, clusters up to eight nodes are supported; each node can remotify - * pages to one specified node, so clusters can be configured as clients to - * a "memory server". Some simple policy is in place that will need to be - * refined over time. Larger clusters and fault-resistant protocols can also - * be added over time. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "../tmem.h" -#include "../zcache.h" -#include "../zbud.h" -#include "ramster.h" -#include "ramster_nodemanager.h" -#include "tcp.h" -#include "debug.h" - -#define RAMSTER_TESTING - -#ifndef CONFIG_SYSFS -#error "ramster needs sysfs to define cluster nodes to use" -#endif - -static bool use_cleancache __read_mostly; -static bool use_frontswap __read_mostly; -static bool use_frontswap_exclusive_gets __read_mostly; - -/* These must be sysfs not debugfs as they are checked/used by userland!! */ -static unsigned long ramster_interface_revision __read_mostly = - R2NM_API_VERSION; /* interface revision must match userspace! */ -static unsigned long ramster_pers_remotify_enable __read_mostly; -static unsigned long ramster_eph_remotify_enable __read_mostly; -static atomic_t ramster_remote_pers_pages = ATOMIC_INIT(0); -#define MANUAL_NODES 8 -static bool ramster_nodes_manual_up[MANUAL_NODES] __read_mostly; -static int ramster_remote_target_nodenum __read_mostly = -1; - -/* Used by this code. */ -long ramster_flnodes; -/* FIXME frontswap selfshrinking knobs in debugfs? */ - -static LIST_HEAD(ramster_rem_op_list); -static DEFINE_SPINLOCK(ramster_rem_op_list_lock); -static DEFINE_PER_CPU(struct ramster_preload, ramster_preloads); - -static DEFINE_PER_CPU(unsigned char *, ramster_remoteputmem1); -static DEFINE_PER_CPU(unsigned char *, ramster_remoteputmem2); - -static struct kmem_cache *ramster_flnode_cache __read_mostly; - -static struct flushlist_node *ramster_flnode_alloc(struct tmem_pool *pool) -{ - struct flushlist_node *flnode = NULL; - struct ramster_preload *kp; - - kp = &__get_cpu_var(ramster_preloads); - flnode = kp->flnode; - BUG_ON(flnode == NULL); - kp->flnode = NULL; - inc_ramster_flnodes(); - return flnode; -} - -/* the "flush list" asynchronously collects pages to remotely flush */ -#define FLUSH_ENTIRE_OBJECT ((uint32_t)-1) -static void ramster_flnode_free(struct flushlist_node *flnode, - struct tmem_pool *pool) -{ - dec_ramster_flnodes(); - BUG_ON(ramster_flnodes < 0); - kmem_cache_free(ramster_flnode_cache, flnode); -} - -int ramster_do_preload_flnode(struct tmem_pool *pool) -{ - struct ramster_preload *kp; - struct flushlist_node *flnode; - int ret = -ENOMEM; - - BUG_ON(!irqs_disabled()); - if (unlikely(ramster_flnode_cache == NULL)) - BUG(); - kp = &__get_cpu_var(ramster_preloads); - flnode = kmem_cache_alloc(ramster_flnode_cache, GFP_ATOMIC); - if (unlikely(flnode == NULL) && kp->flnode == NULL) - BUG(); /* FIXME handle more gracefully, but how??? */ - else if (kp->flnode == NULL) - kp->flnode = flnode; - else - kmem_cache_free(ramster_flnode_cache, flnode); - return ret; -} -EXPORT_SYMBOL_GPL(ramster_do_preload_flnode); - -/* - * Called by the message handler after a (still compressed) page has been - * fetched from the remote machine in response to an "is_remote" tmem_get - * or persistent tmem_localify. For a tmem_get, "extra" is the address of - * the page that is to be filled to successfully resolve the tmem_get; for - * a (persistent) tmem_localify, "extra" is NULL (as the data is placed only - * in the local zcache). "data" points to "size" bytes of (compressed) data - * passed in the message. In the case of a persistent remote get, if - * pre-allocation was successful (see ramster_repatriate_preload), the page - * is placed into both local zcache and at "extra". - */ -int ramster_localify(int pool_id, struct tmem_oid *oidp, uint32_t index, - char *data, unsigned int size, void *extra) -{ - int ret = -ENOENT; - unsigned long flags; - struct tmem_pool *pool; - bool eph, delete = false; - void *pampd, *saved_hb; - struct tmem_obj *obj; - - pool = zcache_get_pool_by_id(LOCAL_CLIENT, pool_id); - if (unlikely(pool == NULL)) - /* pool doesn't exist anymore */ - goto out; - eph = is_ephemeral(pool); - local_irq_save(flags); /* FIXME: maybe only disable softirqs? */ - pampd = tmem_localify_get_pampd(pool, oidp, index, &obj, &saved_hb); - if (pampd == NULL) { - /* hmmm... must have been a flush while waiting */ -#ifdef RAMSTER_TESTING - pr_err("UNTESTED pampd==NULL in ramster_localify\n"); -#endif - if (eph) - inc_ramster_remote_eph_pages_unsucc_get(); - else - inc_ramster_remote_pers_pages_unsucc_get(); - obj = NULL; - goto finish; - } else if (unlikely(!pampd_is_remote(pampd))) { - /* hmmm... must have been a dup put while waiting */ -#ifdef RAMSTER_TESTING - pr_err("UNTESTED dup while waiting in ramster_localify\n"); -#endif - if (eph) - inc_ramster_remote_eph_pages_unsucc_get(); - else - inc_ramster_remote_pers_pages_unsucc_get(); - obj = NULL; - pampd = NULL; - ret = -EEXIST; - goto finish; - } else if (size == 0) { - /* no remote data, delete the local is_remote pampd */ - pampd = NULL; - if (eph) - inc_ramster_remote_eph_pages_unsucc_get(); - else - BUG(); - delete = true; - goto finish; - } - if (pampd_is_intransit(pampd)) { - /* - * a pampd is marked intransit if it is remote and space has - * been allocated for it locally (note, only happens for - * persistent pages, in which case the remote copy is freed) - */ - BUG_ON(eph); - pampd = pampd_mask_intransit_and_remote(pampd); - zbud_copy_to_zbud(pampd, data, size); - } else { - /* - * setting pampd to NULL tells tmem_localify_finish to leave - * pampd alone... meaning it is left pointing to the - * remote copy - */ - pampd = NULL; - obj = NULL; - } - /* - * but in all cases, we decompress direct-to-memory to complete - * the remotify and return success - */ - BUG_ON(extra == NULL); - zcache_decompress_to_page(data, size, (struct page *)extra); - if (eph) - inc_ramster_remote_eph_pages_succ_get(); - else - inc_ramster_remote_pers_pages_succ_get(); - ret = 0; -finish: - tmem_localify_finish(obj, index, pampd, saved_hb, delete); - zcache_put_pool(pool); - local_irq_restore(flags); -out: - return ret; -} - -void ramster_pampd_new_obj(struct tmem_obj *obj) -{ - obj->extra = NULL; -} - -void ramster_pampd_free_obj(struct tmem_pool *pool, struct tmem_obj *obj, - bool pool_destroy) -{ - struct flushlist_node *flnode; - - BUG_ON(preemptible()); - if (obj->extra == NULL) - return; - if (pool_destroy && is_ephemeral(pool)) - /* FIXME don't bother with remote eph data for now */ - return; - BUG_ON(!pampd_is_remote(obj->extra)); - flnode = ramster_flnode_alloc(pool); - flnode->xh.client_id = pampd_remote_node(obj->extra); - flnode->xh.pool_id = pool->pool_id; - flnode->xh.oid = obj->oid; - flnode->xh.index = FLUSH_ENTIRE_OBJECT; - flnode->rem_op.op = RAMSTER_REMOTIFY_FLUSH_OBJ; - spin_lock(&ramster_rem_op_list_lock); - list_add(&flnode->rem_op.list, &ramster_rem_op_list); - spin_unlock(&ramster_rem_op_list_lock); -} - -/* - * Called on a remote persistent tmem_get to attempt to preallocate - * local storage for the data contained in the remote persistent page. - * If successfully preallocated, returns the pampd, marked as remote and - * in_transit. Else returns NULL. Note that the appropriate tmem data - * structure must be locked. - */ -void *ramster_pampd_repatriate_preload(void *pampd, struct tmem_pool *pool, - struct tmem_oid *oidp, uint32_t index, - bool *intransit) -{ - int clen = pampd_remote_size(pampd), c; - void *ret_pampd = NULL; - unsigned long flags; - struct tmem_handle th; - - BUG_ON(!pampd_is_remote(pampd)); - BUG_ON(is_ephemeral(pool)); - if (use_frontswap_exclusive_gets) - /* don't need local storage */ - goto out; - if (pampd_is_intransit(pampd)) { - /* - * to avoid multiple allocations (and maybe a memory leak) - * don't preallocate if already in the process of being - * repatriated - */ - *intransit = true; - goto out; - } - *intransit = false; - local_irq_save(flags); - th.client_id = pampd_remote_node(pampd); - th.pool_id = pool->pool_id; - th.oid = *oidp; - th.index = index; - ret_pampd = zcache_pampd_create(NULL, clen, true, false, &th); - if (ret_pampd != NULL) { - /* - * a pampd is marked intransit if it is remote and space has - * been allocated for it locally (note, only happens for - * persistent pages, in which case the remote copy is freed) - */ - ret_pampd = pampd_mark_intransit(ret_pampd); - c = atomic_dec_return(&ramster_remote_pers_pages); - WARN_ON_ONCE(c < 0); - } else { - inc_ramster_pers_pages_remote_nomem(); - } - local_irq_restore(flags); -out: - return ret_pampd; -} - -/* - * Called on a remote tmem_get to invoke a message to fetch the page. - * Might sleep so no tmem locks can be held. "extra" is passed - * all the way through the round-trip messaging to ramster_localify. - */ -int ramster_pampd_repatriate(void *fake_pampd, void *real_pampd, - struct tmem_pool *pool, - struct tmem_oid *oid, uint32_t index, - bool free, void *extra) -{ - struct tmem_xhandle xh; - int ret; - - if (pampd_is_intransit(real_pampd)) - /* have local space pre-reserved, so free remote copy */ - free = true; - xh = tmem_xhandle_fill(LOCAL_CLIENT, pool, oid, index); - /* unreliable request/response for now */ - ret = r2net_remote_async_get(&xh, free, - pampd_remote_node(fake_pampd), - pampd_remote_size(fake_pampd), - pampd_remote_cksum(fake_pampd), - extra); - return ret; -} - -bool ramster_pampd_is_remote(void *pampd) -{ - return pampd_is_remote(pampd); -} - -int ramster_pampd_replace_in_obj(void *new_pampd, struct tmem_obj *obj) -{ - int ret = -1; - - if (new_pampd != NULL) { - if (obj->extra == NULL) - obj->extra = new_pampd; - /* enforce that all remote pages in an object reside - * in the same node! */ - else if (pampd_remote_node(new_pampd) != - pampd_remote_node((void *)(obj->extra))) - BUG(); - ret = 0; - } - return ret; -} - -void *ramster_pampd_free(void *pampd, struct tmem_pool *pool, - struct tmem_oid *oid, uint32_t index, bool acct) -{ - bool eph = is_ephemeral(pool); - void *local_pampd = NULL; - int c; - - BUG_ON(preemptible()); - BUG_ON(!pampd_is_remote(pampd)); - WARN_ON(acct == false); - if (oid == NULL) { - /* - * a NULL oid means to ignore this pampd free - * as the remote freeing will be handled elsewhere - */ - } else if (eph) { - /* FIXME remote flush optional but probably good idea */ - } else if (pampd_is_intransit(pampd)) { - /* did a pers remote get_and_free, so just free local */ - local_pampd = pampd_mask_intransit_and_remote(pampd); - } else { - struct flushlist_node *flnode = - ramster_flnode_alloc(pool); - - flnode->xh.client_id = pampd_remote_node(pampd); - flnode->xh.pool_id = pool->pool_id; - flnode->xh.oid = *oid; - flnode->xh.index = index; - flnode->rem_op.op = RAMSTER_REMOTIFY_FLUSH_PAGE; - spin_lock(&ramster_rem_op_list_lock); - list_add(&flnode->rem_op.list, &ramster_rem_op_list); - spin_unlock(&ramster_rem_op_list_lock); - c = atomic_dec_return(&ramster_remote_pers_pages); - WARN_ON_ONCE(c < 0); - } - return local_pampd; -} -EXPORT_SYMBOL_GPL(ramster_pampd_free); - -void ramster_count_foreign_pages(bool eph, int count) -{ - BUG_ON(count != 1 && count != -1); - if (eph) { - if (count > 0) { - inc_ramster_foreign_eph_pages(); - } else { - dec_ramster_foreign_eph_pages(); -#ifdef CONFIG_RAMSTER_DEBUG - WARN_ON_ONCE(ramster_foreign_eph_pages < 0); -#endif - } - } else { - if (count > 0) { - inc_ramster_foreign_pers_pages(); - } else { - dec_ramster_foreign_pers_pages(); -#ifdef CONFIG_RAMSTER_DEBUG - WARN_ON_ONCE(ramster_foreign_pers_pages < 0); -#endif - } - } -} -EXPORT_SYMBOL_GPL(ramster_count_foreign_pages); - -/* - * For now, just push over a few pages every few seconds to - * ensure that it basically works - */ -static struct workqueue_struct *ramster_remotify_workqueue; -static void ramster_remotify_process(struct work_struct *work); -static DECLARE_DELAYED_WORK(ramster_remotify_worker, - ramster_remotify_process); - -static void ramster_remotify_queue_delayed_work(unsigned long delay) -{ - if (!queue_delayed_work(ramster_remotify_workqueue, - &ramster_remotify_worker, delay)) - pr_err("ramster_remotify: bad workqueue\n"); -} - -static void ramster_remote_flush_page(struct flushlist_node *flnode) -{ - struct tmem_xhandle *xh; - int remotenode, ret; - - preempt_disable(); - xh = &flnode->xh; - remotenode = flnode->xh.client_id; - ret = r2net_remote_flush(xh, remotenode); - if (ret >= 0) - inc_ramster_remote_pages_flushed(); - else - inc_ramster_remote_page_flushes_failed(); - preempt_enable_no_resched(); - ramster_flnode_free(flnode, NULL); -} - -static void ramster_remote_flush_object(struct flushlist_node *flnode) -{ - struct tmem_xhandle *xh; - int remotenode, ret; - - preempt_disable(); - xh = &flnode->xh; - remotenode = flnode->xh.client_id; - ret = r2net_remote_flush_object(xh, remotenode); - if (ret >= 0) - inc_ramster_remote_objects_flushed(); - else - inc_ramster_remote_object_flushes_failed(); - preempt_enable_no_resched(); - ramster_flnode_free(flnode, NULL); -} - -int ramster_remotify_pageframe(bool eph) -{ - struct tmem_xhandle xh; - unsigned int size; - int remotenode, ret, zbuds; - struct tmem_pool *pool; - unsigned long flags; - unsigned char cksum; - char *p; - int i, j; - unsigned char *tmpmem[2]; - struct tmem_handle th[2]; - unsigned int zsize[2]; - - tmpmem[0] = __get_cpu_var(ramster_remoteputmem1); - tmpmem[1] = __get_cpu_var(ramster_remoteputmem2); - local_bh_disable(); - zbuds = zbud_make_zombie_lru(&th[0], &tmpmem[0], &zsize[0], eph); - /* now OK to release lock set in caller */ - local_bh_enable(); - if (zbuds == 0) - goto out; - BUG_ON(zbuds > 2); - for (i = 0; i < zbuds; i++) { - xh.client_id = th[i].client_id; - xh.pool_id = th[i].pool_id; - xh.oid = th[i].oid; - xh.index = th[i].index; - size = zsize[i]; - BUG_ON(size == 0 || size > zbud_max_buddy_size()); - for (p = tmpmem[i], cksum = 0, j = 0; j < size; j++) - cksum += *p++; - ret = r2net_remote_put(&xh, tmpmem[i], size, eph, &remotenode); - if (ret != 0) { - /* - * This is some form of a memory leak... if the remote put - * fails, there will never be another attempt to remotify - * this page. But since we've dropped the zv pointer, - * the page may have been freed or the data replaced - * so we can't just "put it back" in the remote op list. - * Even if we could, not sure where to put it in the list - * because there may be flushes that must be strictly - * ordered vs the put. So leave this as a FIXME for now. - * But count them so we know if it becomes a problem. - */ - if (eph) - inc_ramster_eph_pages_remote_failed(); - else - inc_ramster_pers_pages_remote_failed(); - break; - } else { - if (!eph) - atomic_inc(&ramster_remote_pers_pages); - } - if (eph) - inc_ramster_eph_pages_remoted(); - else - inc_ramster_pers_pages_remoted(); - /* - * data was successfully remoted so change the local version to - * point to the remote node where it landed - */ - local_bh_disable(); - pool = zcache_get_pool_by_id(LOCAL_CLIENT, xh.pool_id); - local_irq_save(flags); - (void)tmem_replace(pool, &xh.oid, xh.index, - pampd_make_remote(remotenode, size, cksum)); - local_irq_restore(flags); - zcache_put_pool(pool); - local_bh_enable(); - } -out: - return zbuds; -} - -static void zcache_do_remotify_flushes(void) -{ - struct ramster_remotify_hdr *rem_op; - union remotify_list_node *u; - - while (1) { - spin_lock(&ramster_rem_op_list_lock); - if (list_empty(&ramster_rem_op_list)) { - spin_unlock(&ramster_rem_op_list_lock); - goto out; - } - rem_op = list_first_entry(&ramster_rem_op_list, - struct ramster_remotify_hdr, list); - list_del_init(&rem_op->list); - spin_unlock(&ramster_rem_op_list_lock); - u = (union remotify_list_node *)rem_op; - switch (rem_op->op) { - case RAMSTER_REMOTIFY_FLUSH_PAGE: - ramster_remote_flush_page((struct flushlist_node *)u); - break; - case RAMSTER_REMOTIFY_FLUSH_OBJ: - ramster_remote_flush_object((struct flushlist_node *)u); - break; - default: - BUG(); - } - } -out: - return; -} - -static void ramster_remotify_process(struct work_struct *work) -{ - static bool remotify_in_progress; - int i; - - BUG_ON(irqs_disabled()); - if (remotify_in_progress) - goto requeue; - if (ramster_remote_target_nodenum == -1) - goto requeue; - remotify_in_progress = true; - if (use_cleancache && ramster_eph_remotify_enable) { - for (i = 0; i < 100; i++) { - zcache_do_remotify_flushes(); - (void)ramster_remotify_pageframe(true); - } - } - if (use_frontswap && ramster_pers_remotify_enable) { - for (i = 0; i < 100; i++) { - zcache_do_remotify_flushes(); - (void)ramster_remotify_pageframe(false); - } - } - remotify_in_progress = false; -requeue: - ramster_remotify_queue_delayed_work(HZ); -} - -void ramster_remotify_init(void) -{ - unsigned long n = 60UL; - ramster_remotify_workqueue = - create_singlethread_workqueue("ramster_remotify"); - ramster_remotify_queue_delayed_work(n * HZ); -} - -static ssize_t ramster_manual_node_up_show(struct kobject *kobj, - struct kobj_attribute *attr, char *buf) -{ - int i; - char *p = buf; - for (i = 0; i < MANUAL_NODES; i++) - if (ramster_nodes_manual_up[i]) - p += sprintf(p, "%d ", i); - p += sprintf(p, "\n"); - return p - buf; -} - -static ssize_t ramster_manual_node_up_store(struct kobject *kobj, - struct kobj_attribute *attr, const char *buf, size_t count) -{ - int err; - unsigned long node_num; - - err = kstrtoul(buf, 10, &node_num); - if (err) { - pr_err("ramster: bad strtoul?\n"); - return -EINVAL; - } - if (node_num >= MANUAL_NODES) { - pr_err("ramster: bad node_num=%lu?\n", node_num); - return -EINVAL; - } - if (ramster_nodes_manual_up[node_num]) { - pr_err("ramster: node %d already up, ignoring\n", - (int)node_num); - } else { - ramster_nodes_manual_up[node_num] = true; - r2net_hb_node_up_manual((int)node_num); - } - return count; -} - -static struct kobj_attribute ramster_manual_node_up_attr = { - .attr = { .name = "manual_node_up", .mode = 0644 }, - .show = ramster_manual_node_up_show, - .store = ramster_manual_node_up_store, -}; - -static ssize_t ramster_remote_target_nodenum_show(struct kobject *kobj, - struct kobj_attribute *attr, char *buf) -{ - if (ramster_remote_target_nodenum == -1UL) - return sprintf(buf, "unset\n"); - else - return sprintf(buf, "%d\n", ramster_remote_target_nodenum); -} - -static ssize_t ramster_remote_target_nodenum_store(struct kobject *kobj, - struct kobj_attribute *attr, const char *buf, size_t count) -{ - int err; - unsigned long node_num; - - err = kstrtoul(buf, 10, &node_num); - if (err) { - pr_err("ramster: bad strtoul?\n"); - return -EINVAL; - } else if (node_num == -1UL) { - pr_err("ramster: disabling all remotification, " - "data may still reside on remote nodes however\n"); - return -EINVAL; - } else if (node_num >= MANUAL_NODES) { - pr_err("ramster: bad node_num=%lu?\n", node_num); - return -EINVAL; - } else if (!ramster_nodes_manual_up[node_num]) { - pr_err("ramster: node %d not up, ignoring setting " - "of remotification target\n", (int)node_num); - } else if (r2net_remote_target_node_set((int)node_num) >= 0) { - pr_info("ramster: node %d set as remotification target\n", - (int)node_num); - ramster_remote_target_nodenum = (int)node_num; - } else { - pr_err("ramster: bad num to node node_num=%d?\n", - (int)node_num); - return -EINVAL; - } - return count; -} - -static struct kobj_attribute ramster_remote_target_nodenum_attr = { - .attr = { .name = "remote_target_nodenum", .mode = 0644 }, - .show = ramster_remote_target_nodenum_show, - .store = ramster_remote_target_nodenum_store, -}; - -#define RAMSTER_SYSFS_RO(_name) \ - static ssize_t ramster_##_name##_show(struct kobject *kobj, \ - struct kobj_attribute *attr, char *buf) \ - { \ - return sprintf(buf, "%lu\n", ramster_##_name); \ - } \ - static struct kobj_attribute ramster_##_name##_attr = { \ - .attr = { .name = __stringify(_name), .mode = 0444 }, \ - .show = ramster_##_name##_show, \ - } - -#define RAMSTER_SYSFS_RW(_name) \ - static ssize_t ramster_##_name##_show(struct kobject *kobj, \ - struct kobj_attribute *attr, char *buf) \ - { \ - return sprintf(buf, "%lu\n", ramster_##_name); \ - } \ - static ssize_t ramster_##_name##_store(struct kobject *kobj, \ - struct kobj_attribute *attr, const char *buf, size_t count) \ - { \ - int err; \ - unsigned long enable; \ - err = kstrtoul(buf, 10, &enable); \ - if (err) \ - return -EINVAL; \ - ramster_##_name = enable; \ - return count; \ - } \ - static struct kobj_attribute ramster_##_name##_attr = { \ - .attr = { .name = __stringify(_name), .mode = 0644 }, \ - .show = ramster_##_name##_show, \ - .store = ramster_##_name##_store, \ - } - -#define RAMSTER_SYSFS_RO_ATOMIC(_name) \ - static ssize_t ramster_##_name##_show(struct kobject *kobj, \ - struct kobj_attribute *attr, char *buf) \ - { \ - return sprintf(buf, "%d\n", atomic_read(&ramster_##_name)); \ - } \ - static struct kobj_attribute ramster_##_name##_attr = { \ - .attr = { .name = __stringify(_name), .mode = 0444 }, \ - .show = ramster_##_name##_show, \ - } - -RAMSTER_SYSFS_RO(interface_revision); -RAMSTER_SYSFS_RO_ATOMIC(remote_pers_pages); -RAMSTER_SYSFS_RW(pers_remotify_enable); -RAMSTER_SYSFS_RW(eph_remotify_enable); - -static struct attribute *ramster_attrs[] = { - &ramster_interface_revision_attr.attr, - &ramster_remote_pers_pages_attr.attr, - &ramster_manual_node_up_attr.attr, - &ramster_remote_target_nodenum_attr.attr, - &ramster_pers_remotify_enable_attr.attr, - &ramster_eph_remotify_enable_attr.attr, - NULL, -}; - -static struct attribute_group ramster_attr_group = { - .attrs = ramster_attrs, - .name = "ramster", -}; - -/* - * frontswap selfshrinking - */ - -/* In HZ, controls frequency of worker invocation. */ -static unsigned int selfshrink_interval __read_mostly = 5; -/* Enable/disable with sysfs. */ -static bool frontswap_selfshrinking __read_mostly; - -static void selfshrink_process(struct work_struct *work); -static DECLARE_DELAYED_WORK(selfshrink_worker, selfshrink_process); - -#ifndef CONFIG_RAMSTER_MODULE -/* Enable/disable with kernel boot option. */ -static bool use_frontswap_selfshrink = true; -#endif - -/* - * The default values for the following parameters were deemed reasonable - * by experimentation, may be workload-dependent, and can all be - * adjusted via sysfs. - */ - -/* Control rate for frontswap shrinking. Higher hysteresis is slower. */ -static unsigned int frontswap_hysteresis __read_mostly = 20; - -/* - * Number of selfshrink worker invocations to wait before observing that - * frontswap selfshrinking should commence. Note that selfshrinking does - * not use a separate worker thread. - */ -static unsigned int frontswap_inertia __read_mostly = 3; - -/* Countdown to next invocation of frontswap_shrink() */ -static unsigned long frontswap_inertia_counter; - -/* - * Invoked by the selfshrink worker thread, uses current number of pages - * in frontswap (frontswap_curr_pages()), previous status, and control - * values (hysteresis and inertia) to determine if frontswap should be - * shrunk and what the new frontswap size should be. Note that - * frontswap_shrink is essentially a partial swapoff that immediately - * transfers pages from the "swap device" (frontswap) back into kernel - * RAM; despite the name, frontswap "shrinking" is very different from - * the "shrinker" interface used by the kernel MM subsystem to reclaim - * memory. - */ -static void frontswap_selfshrink(void) -{ - static unsigned long cur_frontswap_pages; - static unsigned long last_frontswap_pages; - static unsigned long tgt_frontswap_pages; - - last_frontswap_pages = cur_frontswap_pages; - cur_frontswap_pages = frontswap_curr_pages(); - if (!cur_frontswap_pages || - (cur_frontswap_pages > last_frontswap_pages)) { - frontswap_inertia_counter = frontswap_inertia; - return; - } - if (frontswap_inertia_counter && --frontswap_inertia_counter) - return; - if (cur_frontswap_pages <= frontswap_hysteresis) - tgt_frontswap_pages = 0; - else - tgt_frontswap_pages = cur_frontswap_pages - - (cur_frontswap_pages / frontswap_hysteresis); - frontswap_shrink(tgt_frontswap_pages); -} - -#ifndef CONFIG_RAMSTER_MODULE -static int __init ramster_nofrontswap_selfshrink_setup(char *s) -{ - use_frontswap_selfshrink = false; - return 1; -} - -__setup("noselfshrink", ramster_nofrontswap_selfshrink_setup); -#endif - -static void selfshrink_process(struct work_struct *work) -{ - if (frontswap_selfshrinking && frontswap_enabled) { - frontswap_selfshrink(); - schedule_delayed_work(&selfshrink_worker, - selfshrink_interval * HZ); - } -} - -void ramster_cpu_up(int cpu) -{ - unsigned char *p1 = kzalloc(PAGE_SIZE, GFP_KERNEL | __GFP_REPEAT); - unsigned char *p2 = kzalloc(PAGE_SIZE, GFP_KERNEL | __GFP_REPEAT); - BUG_ON(!p1 || !p2); - per_cpu(ramster_remoteputmem1, cpu) = p1; - per_cpu(ramster_remoteputmem2, cpu) = p2; -} -EXPORT_SYMBOL_GPL(ramster_cpu_up); - -void ramster_cpu_down(int cpu) -{ - struct ramster_preload *kp; - - kfree(per_cpu(ramster_remoteputmem1, cpu)); - per_cpu(ramster_remoteputmem1, cpu) = NULL; - kfree(per_cpu(ramster_remoteputmem2, cpu)); - per_cpu(ramster_remoteputmem2, cpu) = NULL; - kp = &per_cpu(ramster_preloads, cpu); - if (kp->flnode) { - kmem_cache_free(ramster_flnode_cache, kp->flnode); - kp->flnode = NULL; - } -} -EXPORT_SYMBOL_GPL(ramster_cpu_down); - -void ramster_register_pamops(struct tmem_pamops *pamops) -{ - pamops->free_obj = ramster_pampd_free_obj; - pamops->new_obj = ramster_pampd_new_obj; - pamops->replace_in_obj = ramster_pampd_replace_in_obj; - pamops->is_remote = ramster_pampd_is_remote; - pamops->repatriate = ramster_pampd_repatriate; - pamops->repatriate_preload = ramster_pampd_repatriate_preload; -} -EXPORT_SYMBOL_GPL(ramster_register_pamops); - -void ramster_init(bool cleancache, bool frontswap, - bool frontswap_exclusive_gets, - bool frontswap_selfshrink) -{ - int ret = 0; - - if (cleancache) - use_cleancache = true; - if (frontswap) - use_frontswap = true; - if (frontswap_exclusive_gets) - use_frontswap_exclusive_gets = true; - ramster_debugfs_init(); - ret = sysfs_create_group(mm_kobj, &ramster_attr_group); - if (ret) - pr_err("ramster: can't create sysfs for ramster\n"); - (void)r2net_register_handlers(); -#ifdef CONFIG_RAMSTER_MODULE - ret = r2nm_init(); - if (ret) - pr_err("ramster: can't init r2net\n"); - frontswap_selfshrinking = frontswap_selfshrink; -#else - frontswap_selfshrinking = use_frontswap_selfshrink; -#endif - INIT_LIST_HEAD(&ramster_rem_op_list); - ramster_flnode_cache = kmem_cache_create("ramster_flnode", - sizeof(struct flushlist_node), 0, 0, NULL); - if (frontswap_selfshrinking) { - pr_info("ramster: Initializing frontswap selfshrink driver.\n"); - schedule_delayed_work(&selfshrink_worker, - selfshrink_interval * HZ); - } - ramster_remotify_init(); -} -EXPORT_SYMBOL_GPL(ramster_init); diff --git a/drivers/staging/zcache/ramster/ramster.h b/drivers/staging/zcache/ramster/ramster.h deleted file mode 100644 index 6d41a7a772e37..0000000000000 --- a/drivers/staging/zcache/ramster/ramster.h +++ /dev/null @@ -1,161 +0,0 @@ -/* - * ramster.h - * - * Peer-to-peer transcendent memory - * - * Copyright (c) 2009-2012, Dan Magenheimer, Oracle Corp. - */ - -#ifndef _RAMSTER_RAMSTER_H_ -#define _RAMSTER_RAMSTER_H_ - -#include "../tmem.h" - -enum ramster_remotify_op { - RAMSTER_REMOTIFY_FLUSH_PAGE, - RAMSTER_REMOTIFY_FLUSH_OBJ, -}; - -struct ramster_remotify_hdr { - enum ramster_remotify_op op; - struct list_head list; -}; - -struct flushlist_node { - struct ramster_remotify_hdr rem_op; - struct tmem_xhandle xh; -}; - -struct ramster_preload { - struct flushlist_node *flnode; -}; - -union remotify_list_node { - struct ramster_remotify_hdr rem_op; - struct { - struct ramster_remotify_hdr rem_op; - struct tmem_handle th; - } zbud_hdr; - struct flushlist_node flist; -}; - -/* - * format of remote pampd: - * bit 0 is reserved for zbud (in-page buddy selection) - * bit 1 == intransit - * bit 2 == is_remote... if this bit is set, then - * bit 3-10 == remotenode - * bit 11-23 == size - * bit 24-31 == cksum - */ -#define FAKE_PAMPD_INTRANSIT_BITS 1 -#define FAKE_PAMPD_ISREMOTE_BITS 1 -#define FAKE_PAMPD_REMOTENODE_BITS 8 -#define FAKE_PAMPD_REMOTESIZE_BITS 13 -#define FAKE_PAMPD_CHECKSUM_BITS 8 - -#define FAKE_PAMPD_INTRANSIT_SHIFT 1 -#define FAKE_PAMPD_ISREMOTE_SHIFT (FAKE_PAMPD_INTRANSIT_SHIFT + \ - FAKE_PAMPD_INTRANSIT_BITS) -#define FAKE_PAMPD_REMOTENODE_SHIFT (FAKE_PAMPD_ISREMOTE_SHIFT + \ - FAKE_PAMPD_ISREMOTE_BITS) -#define FAKE_PAMPD_REMOTESIZE_SHIFT (FAKE_PAMPD_REMOTENODE_SHIFT + \ - FAKE_PAMPD_REMOTENODE_BITS) -#define FAKE_PAMPD_CHECKSUM_SHIFT (FAKE_PAMPD_REMOTESIZE_SHIFT + \ - FAKE_PAMPD_REMOTESIZE_BITS) - -#define FAKE_PAMPD_MASK(x) ((1UL << (x)) - 1) - -static inline void *pampd_make_remote(int remotenode, size_t size, - unsigned char cksum) -{ - unsigned long fake_pampd = 0; - fake_pampd |= 1UL << FAKE_PAMPD_ISREMOTE_SHIFT; - fake_pampd |= ((unsigned long)remotenode & - FAKE_PAMPD_MASK(FAKE_PAMPD_REMOTENODE_BITS)) << - FAKE_PAMPD_REMOTENODE_SHIFT; - fake_pampd |= ((unsigned long)size & - FAKE_PAMPD_MASK(FAKE_PAMPD_REMOTESIZE_BITS)) << - FAKE_PAMPD_REMOTESIZE_SHIFT; - fake_pampd |= ((unsigned long)cksum & - FAKE_PAMPD_MASK(FAKE_PAMPD_CHECKSUM_BITS)) << - FAKE_PAMPD_CHECKSUM_SHIFT; - return (void *)fake_pampd; -} - -static inline unsigned int pampd_remote_node(void *pampd) -{ - unsigned long fake_pampd = (unsigned long)pampd; - return (fake_pampd >> FAKE_PAMPD_REMOTENODE_SHIFT) & - FAKE_PAMPD_MASK(FAKE_PAMPD_REMOTENODE_BITS); -} - -static inline unsigned int pampd_remote_size(void *pampd) -{ - unsigned long fake_pampd = (unsigned long)pampd; - return (fake_pampd >> FAKE_PAMPD_REMOTESIZE_SHIFT) & - FAKE_PAMPD_MASK(FAKE_PAMPD_REMOTESIZE_BITS); -} - -static inline unsigned char pampd_remote_cksum(void *pampd) -{ - unsigned long fake_pampd = (unsigned long)pampd; - return (fake_pampd >> FAKE_PAMPD_CHECKSUM_SHIFT) & - FAKE_PAMPD_MASK(FAKE_PAMPD_CHECKSUM_BITS); -} - -static inline bool pampd_is_remote(void *pampd) -{ - unsigned long fake_pampd = (unsigned long)pampd; - return (fake_pampd >> FAKE_PAMPD_ISREMOTE_SHIFT) & - FAKE_PAMPD_MASK(FAKE_PAMPD_ISREMOTE_BITS); -} - -static inline bool pampd_is_intransit(void *pampd) -{ - unsigned long fake_pampd = (unsigned long)pampd; - return (fake_pampd >> FAKE_PAMPD_INTRANSIT_SHIFT) & - FAKE_PAMPD_MASK(FAKE_PAMPD_INTRANSIT_BITS); -} - -/* note that it is a BUG for intransit to be set without isremote also set */ -static inline void *pampd_mark_intransit(void *pampd) -{ - unsigned long fake_pampd = (unsigned long)pampd; - - fake_pampd |= 1UL << FAKE_PAMPD_ISREMOTE_SHIFT; - fake_pampd |= 1UL << FAKE_PAMPD_INTRANSIT_SHIFT; - return (void *)fake_pampd; -} - -static inline void *pampd_mask_intransit_and_remote(void *marked_pampd) -{ - unsigned long pampd = (unsigned long)marked_pampd; - - pampd &= ~(1UL << FAKE_PAMPD_INTRANSIT_SHIFT); - pampd &= ~(1UL << FAKE_PAMPD_ISREMOTE_SHIFT); - return (void *)pampd; -} - -extern int r2net_remote_async_get(struct tmem_xhandle *, - bool, int, size_t, uint8_t, void *extra); -extern int r2net_remote_put(struct tmem_xhandle *, char *, size_t, - bool, int *); -extern int r2net_remote_flush(struct tmem_xhandle *, int); -extern int r2net_remote_flush_object(struct tmem_xhandle *, int); -extern int r2net_register_handlers(void); -extern int r2net_remote_target_node_set(int); - -extern int ramster_remotify_pageframe(bool); -extern void ramster_init(bool, bool, bool, bool); -extern void ramster_register_pamops(struct tmem_pamops *); -extern int ramster_localify(int, struct tmem_oid *oidp, uint32_t, char *, - unsigned int, void *); -extern void *ramster_pampd_free(void *, struct tmem_pool *, struct tmem_oid *, - uint32_t, bool); -extern void ramster_count_foreign_pages(bool, int); -extern int ramster_do_preload_flnode(struct tmem_pool *); -extern void ramster_cpu_up(int); -extern void ramster_cpu_down(int); - -#endif /* _RAMSTER_RAMSTER_H */ diff --git a/drivers/staging/zcache/ramster/ramster_nodemanager.h b/drivers/staging/zcache/ramster/ramster_nodemanager.h deleted file mode 100644 index dbaae34ea6133..0000000000000 --- a/drivers/staging/zcache/ramster/ramster_nodemanager.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; -*- - * vim: noexpandtab sw=8 ts=8 sts=0: - * - * ramster_nodemanager.h - * - * Header describing the interface between userspace and the kernel - * for the ramster_nodemanager module. - * - * Copyright (C) 2002, 2004, 2012 Oracle. All rights reserved. - * - * 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 the License, or (at your option) any later version. - * - * 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. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 021110-1307, USA. - * - */ - -#ifndef _RAMSTER_NODEMANAGER_H -#define _RAMSTER_NODEMANAGER_H - -#define R2NM_API_VERSION 5 - -#define R2NM_MAX_NODES 255 -#define R2NM_INVALID_NODE_NUM 255 - -/* host name, group name, cluster name all 64 bytes */ -#define R2NM_MAX_NAME_LEN 64 /* __NEW_UTS_LEN */ - -extern int r2nm_init(void); - -#endif /* _RAMSTER_NODEMANAGER_H */ diff --git a/drivers/staging/zcache/ramster/tcp.c b/drivers/staging/zcache/ramster/tcp.c deleted file mode 100644 index f74881e093425..0000000000000 --- a/drivers/staging/zcache/ramster/tcp.c +++ /dev/null @@ -1,2251 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; -*- - * - * vim: noexpandtab sw=8 ts=8 sts=0: - * - * Copyright (C) 2004 Oracle. All rights reserved. - * - * 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 the License, or (at your option) any later version. - * - * 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. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 021110-1307, USA. - * - * ---- - * - * Callers for this were originally written against a very simple synchronus - * API. This implementation reflects those simple callers. Some day I'm sure - * we'll need to move to a more robust posting/callback mechanism. - * - * Transmit calls pass in kernel virtual addresses and block copying this into - * the socket's tx buffers via a usual blocking sendmsg. They'll block waiting - * for a failed socket to timeout. TX callers can also pass in a poniter to an - * 'int' which gets filled with an errno off the wire in response to the - * message they send. - * - * Handlers for unsolicited messages are registered. Each socket has a page - * that incoming data is copied into. First the header, then the data. - * Handlers are called from only one thread with a reference to this per-socket - * page. This page is destroyed after the handler call, so it can't be - * referenced beyond the call. Handlers may block but are discouraged from - * doing so. - * - * Any framing errors (bad magic, large payload lengths) close a connection. - * - * Our sock_container holds the state we associate with a socket. It's current - * framing state is held there as well as the refcounting we do around when it - * is safe to tear down the socket. The socket is only finally torn down from - * the container when the container loses all of its references -- so as long - * as you hold a ref on the container you can trust that the socket is valid - * for use with kernel socket APIs. - * - * Connections are initiated between a pair of nodes when the node with the - * higher node number gets a heartbeat callback which indicates that the lower - * numbered node has started heartbeating. The lower numbered node is passive - * and only accepts the connection if the higher numbered node is heartbeating. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#include "heartbeat.h" -#include "tcp.h" -#include "nodemanager.h" -#define MLOG_MASK_PREFIX ML_TCP -#include "masklog.h" - -#include "tcp_internal.h" - -#define SC_NODEF_FMT "node %s (num %u) at %pI4:%u" - -/* - * In the following two log macros, the whitespace after the ',' just - * before ##args is intentional. Otherwise, gcc 2.95 will eat the - * previous token if args expands to nothing. - */ -#define msglog(hdr, fmt, args...) do { \ - typeof(hdr) __hdr = (hdr); \ - mlog(ML_MSG, "[mag %u len %u typ %u stat %d sys_stat %d " \ - "key %08x num %u] " fmt, \ - be16_to_cpu(__hdr->magic), be16_to_cpu(__hdr->data_len), \ - be16_to_cpu(__hdr->msg_type), be32_to_cpu(__hdr->status), \ - be32_to_cpu(__hdr->sys_status), be32_to_cpu(__hdr->key), \ - be32_to_cpu(__hdr->msg_num) , ##args); \ -} while (0) - -#define sclog(sc, fmt, args...) do { \ - typeof(sc) __sc = (sc); \ - mlog(ML_SOCKET, "[sc %p refs %d sock %p node %u page %p " \ - "pg_off %zu] " fmt, __sc, \ - atomic_read(&__sc->sc_kref.refcount), __sc->sc_sock, \ - __sc->sc_node->nd_num, __sc->sc_page, __sc->sc_page_off , \ - ##args); \ -} while (0) - -static DEFINE_RWLOCK(r2net_handler_lock); -static struct rb_root r2net_handler_tree = RB_ROOT; - -static struct r2net_node r2net_nodes[R2NM_MAX_NODES]; - -/* XXX someday we'll need better accounting */ -static struct socket *r2net_listen_sock; - -/* - * listen work is only queued by the listening socket callbacks on the - * r2net_wq. teardown detaches the callbacks before destroying the workqueue. - * quorum work is queued as sock containers are shutdown.. stop_listening - * tears down all the node's sock containers, preventing future shutdowns - * and queued quorum work, before canceling delayed quorum work and - * destroying the work queue. - */ -static struct workqueue_struct *r2net_wq; -static struct work_struct r2net_listen_work; - -static struct r2hb_callback_func r2net_hb_up, r2net_hb_down; -#define R2NET_HB_PRI 0x1 - -static struct r2net_handshake *r2net_hand; -static struct r2net_msg *r2net_keep_req, *r2net_keep_resp; - -static int r2net_sys_err_translations[R2NET_ERR_MAX] = { - [R2NET_ERR_NONE] = 0, - [R2NET_ERR_NO_HNDLR] = -ENOPROTOOPT, - [R2NET_ERR_OVERFLOW] = -EOVERFLOW, - [R2NET_ERR_DIED] = -EHOSTDOWN,}; - -/* can't quite avoid *all* internal declarations :/ */ -static void r2net_sc_connect_completed(struct work_struct *work); -static void r2net_rx_until_empty(struct work_struct *work); -static void r2net_shutdown_sc(struct work_struct *work); -static void r2net_listen_data_ready(struct sock *sk, int bytes); -static void r2net_sc_send_keep_req(struct work_struct *work); -static void r2net_idle_timer(unsigned long data); -static void r2net_sc_postpone_idle(struct r2net_sock_container *sc); -static void r2net_sc_reset_idle_timer(struct r2net_sock_container *sc); - -#ifdef CONFIG_DEBUG_FS -static void r2net_init_nst(struct r2net_send_tracking *nst, u32 msgtype, - u32 msgkey, struct task_struct *task, u8 node) -{ - INIT_LIST_HEAD(&nst->st_net_debug_item); - nst->st_task = task; - nst->st_msg_type = msgtype; - nst->st_msg_key = msgkey; - nst->st_node = node; -} - -static inline void r2net_set_nst_sock_time(struct r2net_send_tracking *nst) -{ - nst->st_sock_time = ktime_get(); -} - -static inline void r2net_set_nst_send_time(struct r2net_send_tracking *nst) -{ - nst->st_send_time = ktime_get(); -} - -static inline void r2net_set_nst_status_time(struct r2net_send_tracking *nst) -{ - nst->st_status_time = ktime_get(); -} - -static inline void r2net_set_nst_sock_container(struct r2net_send_tracking *nst, - struct r2net_sock_container *sc) -{ - nst->st_sc = sc; -} - -static inline void r2net_set_nst_msg_id(struct r2net_send_tracking *nst, - u32 msg_id) -{ - nst->st_id = msg_id; -} - -static inline void r2net_set_sock_timer(struct r2net_sock_container *sc) -{ - sc->sc_tv_timer = ktime_get(); -} - -static inline void r2net_set_data_ready_time(struct r2net_sock_container *sc) -{ - sc->sc_tv_data_ready = ktime_get(); -} - -static inline void r2net_set_advance_start_time(struct r2net_sock_container *sc) -{ - sc->sc_tv_advance_start = ktime_get(); -} - -static inline void r2net_set_advance_stop_time(struct r2net_sock_container *sc) -{ - sc->sc_tv_advance_stop = ktime_get(); -} - -static inline void r2net_set_func_start_time(struct r2net_sock_container *sc) -{ - sc->sc_tv_func_start = ktime_get(); -} - -static inline void r2net_set_func_stop_time(struct r2net_sock_container *sc) -{ - sc->sc_tv_func_stop = ktime_get(); -} - -#else /* CONFIG_DEBUG_FS */ -# define r2net_init_nst(a, b, c, d, e) -# define r2net_set_nst_sock_time(a) -# define r2net_set_nst_send_time(a) -# define r2net_set_nst_status_time(a) -# define r2net_set_nst_sock_container(a, b) -# define r2net_set_nst_msg_id(a, b) -# define r2net_set_sock_timer(a) -# define r2net_set_data_ready_time(a) -# define r2net_set_advance_start_time(a) -# define r2net_set_advance_stop_time(a) -# define r2net_set_func_start_time(a) -# define r2net_set_func_stop_time(a) -#endif /* CONFIG_DEBUG_FS */ - -#ifdef CONFIG_RAMSTER_FS_STATS -static ktime_t r2net_get_func_run_time(struct r2net_sock_container *sc) -{ - return ktime_sub(sc->sc_tv_func_stop, sc->sc_tv_func_start); -} - -static void r2net_update_send_stats(struct r2net_send_tracking *nst, - struct r2net_sock_container *sc) -{ - sc->sc_tv_status_total = ktime_add(sc->sc_tv_status_total, - ktime_sub(ktime_get(), - nst->st_status_time)); - sc->sc_tv_send_total = ktime_add(sc->sc_tv_send_total, - ktime_sub(nst->st_status_time, - nst->st_send_time)); - sc->sc_tv_acquiry_total = ktime_add(sc->sc_tv_acquiry_total, - ktime_sub(nst->st_send_time, - nst->st_sock_time)); - sc->sc_send_count++; -} - -static void r2net_update_recv_stats(struct r2net_sock_container *sc) -{ - sc->sc_tv_process_total = ktime_add(sc->sc_tv_process_total, - r2net_get_func_run_time(sc)); - sc->sc_recv_count++; -} - -#else - -# define r2net_update_send_stats(a, b) - -# define r2net_update_recv_stats(sc) - -#endif /* CONFIG_RAMSTER_FS_STATS */ - -static inline int r2net_reconnect_delay(void) -{ - return r2nm_single_cluster->cl_reconnect_delay_ms; -} - -static inline int r2net_keepalive_delay(void) -{ - return r2nm_single_cluster->cl_keepalive_delay_ms; -} - -static inline int r2net_idle_timeout(void) -{ - return r2nm_single_cluster->cl_idle_timeout_ms; -} - -static inline int r2net_sys_err_to_errno(enum r2net_system_error err) -{ - int trans; - BUG_ON(err >= R2NET_ERR_MAX); - trans = r2net_sys_err_translations[err]; - - /* Just in case we mess up the translation table above */ - BUG_ON(err != R2NET_ERR_NONE && trans == 0); - return trans; -} - -struct r2net_node *r2net_nn_from_num(u8 node_num) -{ - BUG_ON(node_num >= ARRAY_SIZE(r2net_nodes)); - return &r2net_nodes[node_num]; -} - -static u8 r2net_num_from_nn(struct r2net_node *nn) -{ - BUG_ON(nn == NULL); - return nn - r2net_nodes; -} - -/* ------------------------------------------------------------ */ - -static int r2net_prep_nsw(struct r2net_node *nn, struct r2net_status_wait *nsw) -{ - int ret; - - spin_lock(&nn->nn_lock); - ret = idr_alloc(&nn->nn_status_idr, nsw, 0, 0, GFP_ATOMIC); - if (ret >= 0) { - nsw->ns_id = ret; - list_add_tail(&nsw->ns_node_item, &nn->nn_status_list); - } - spin_unlock(&nn->nn_lock); - - if (ret >= 0) { - init_waitqueue_head(&nsw->ns_wq); - nsw->ns_sys_status = R2NET_ERR_NONE; - nsw->ns_status = 0; - return 0; - } - return ret; -} - -static void r2net_complete_nsw_locked(struct r2net_node *nn, - struct r2net_status_wait *nsw, - enum r2net_system_error sys_status, - s32 status) -{ - assert_spin_locked(&nn->nn_lock); - - if (!list_empty(&nsw->ns_node_item)) { - list_del_init(&nsw->ns_node_item); - nsw->ns_sys_status = sys_status; - nsw->ns_status = status; - idr_remove(&nn->nn_status_idr, nsw->ns_id); - wake_up(&nsw->ns_wq); - } -} - -static void r2net_complete_nsw(struct r2net_node *nn, - struct r2net_status_wait *nsw, - u64 id, enum r2net_system_error sys_status, - s32 status) -{ - spin_lock(&nn->nn_lock); - if (nsw == NULL) { - if (id > INT_MAX) - goto out; - - nsw = idr_find(&nn->nn_status_idr, id); - if (nsw == NULL) - goto out; - } - - r2net_complete_nsw_locked(nn, nsw, sys_status, status); - -out: - spin_unlock(&nn->nn_lock); - return; -} - -static void r2net_complete_nodes_nsw(struct r2net_node *nn) -{ - struct r2net_status_wait *nsw, *tmp; - unsigned int num_kills = 0; - - assert_spin_locked(&nn->nn_lock); - - list_for_each_entry_safe(nsw, tmp, &nn->nn_status_list, ns_node_item) { - r2net_complete_nsw_locked(nn, nsw, R2NET_ERR_DIED, 0); - num_kills++; - } - - mlog(0, "completed %d messages for node %u\n", num_kills, - r2net_num_from_nn(nn)); -} - -static int r2net_nsw_completed(struct r2net_node *nn, - struct r2net_status_wait *nsw) -{ - int completed; - spin_lock(&nn->nn_lock); - completed = list_empty(&nsw->ns_node_item); - spin_unlock(&nn->nn_lock); - return completed; -} - -/* ------------------------------------------------------------ */ - -static void sc_kref_release(struct kref *kref) -{ - struct r2net_sock_container *sc = container_of(kref, - struct r2net_sock_container, sc_kref); - BUG_ON(timer_pending(&sc->sc_idle_timeout)); - - sclog(sc, "releasing\n"); - - if (sc->sc_sock) { - sock_release(sc->sc_sock); - sc->sc_sock = NULL; - } - - r2nm_undepend_item(&sc->sc_node->nd_item); - r2nm_node_put(sc->sc_node); - sc->sc_node = NULL; - - r2net_debug_del_sc(sc); - - if (sc->sc_page) - __free_page(sc->sc_page); - kfree(sc); -} - -static void sc_put(struct r2net_sock_container *sc) -{ - sclog(sc, "put\n"); - kref_put(&sc->sc_kref, sc_kref_release); -} -static void sc_get(struct r2net_sock_container *sc) -{ - sclog(sc, "get\n"); - kref_get(&sc->sc_kref); -} -static struct r2net_sock_container *sc_alloc(struct r2nm_node *node) -{ - struct r2net_sock_container *sc, *ret = NULL; - struct page *page = NULL; - int status = 0; - - page = alloc_page(GFP_NOFS); - sc = kzalloc(sizeof(*sc), GFP_NOFS); - if (sc == NULL || page == NULL) - goto out; - - kref_init(&sc->sc_kref); - r2nm_node_get(node); - sc->sc_node = node; - - /* pin the node item of the remote node */ - status = r2nm_depend_item(&node->nd_item); - if (status) { - mlog_errno(status); - r2nm_node_put(node); - goto out; - } - INIT_WORK(&sc->sc_connect_work, r2net_sc_connect_completed); - INIT_WORK(&sc->sc_rx_work, r2net_rx_until_empty); - INIT_WORK(&sc->sc_shutdown_work, r2net_shutdown_sc); - INIT_DELAYED_WORK(&sc->sc_keepalive_work, r2net_sc_send_keep_req); - - init_timer(&sc->sc_idle_timeout); - sc->sc_idle_timeout.function = r2net_idle_timer; - sc->sc_idle_timeout.data = (unsigned long)sc; - - sclog(sc, "alloced\n"); - - ret = sc; - sc->sc_page = page; - r2net_debug_add_sc(sc); - sc = NULL; - page = NULL; - -out: - if (page) - __free_page(page); - kfree(sc); - - return ret; -} - -/* ------------------------------------------------------------ */ - -static void r2net_sc_queue_work(struct r2net_sock_container *sc, - struct work_struct *work) -{ - sc_get(sc); - if (!queue_work(r2net_wq, work)) - sc_put(sc); -} -static void r2net_sc_queue_delayed_work(struct r2net_sock_container *sc, - struct delayed_work *work, - int delay) -{ - sc_get(sc); - if (!queue_delayed_work(r2net_wq, work, delay)) - sc_put(sc); -} -static void r2net_sc_cancel_delayed_work(struct r2net_sock_container *sc, - struct delayed_work *work) -{ - if (cancel_delayed_work(work)) - sc_put(sc); -} - -static atomic_t r2net_connected_peers = ATOMIC_INIT(0); - -int r2net_num_connected_peers(void) -{ - return atomic_read(&r2net_connected_peers); -} - -static void r2net_set_nn_state(struct r2net_node *nn, - struct r2net_sock_container *sc, - unsigned valid, int err) -{ - int was_valid = nn->nn_sc_valid; - int was_err = nn->nn_persistent_error; - struct r2net_sock_container *old_sc = nn->nn_sc; - - assert_spin_locked(&nn->nn_lock); - - if (old_sc && !sc) - atomic_dec(&r2net_connected_peers); - else if (!old_sc && sc) - atomic_inc(&r2net_connected_peers); - - /* the node num comparison and single connect/accept path should stop - * an non-null sc from being overwritten with another */ - BUG_ON(sc && nn->nn_sc && nn->nn_sc != sc); - mlog_bug_on_msg(err && valid, "err %d valid %u\n", err, valid); - mlog_bug_on_msg(valid && !sc, "valid %u sc %p\n", valid, sc); - - if (was_valid && !valid && err == 0) - err = -ENOTCONN; - - mlog(ML_CONN, "node %u sc: %p -> %p, valid %u -> %u, err %d -> %d\n", - r2net_num_from_nn(nn), nn->nn_sc, sc, nn->nn_sc_valid, valid, - nn->nn_persistent_error, err); - - nn->nn_sc = sc; - nn->nn_sc_valid = valid ? 1 : 0; - nn->nn_persistent_error = err; - - /* mirrors r2net_tx_can_proceed() */ - if (nn->nn_persistent_error || nn->nn_sc_valid) - wake_up(&nn->nn_sc_wq); - - if (!was_err && nn->nn_persistent_error) { - queue_delayed_work(r2net_wq, &nn->nn_still_up, - msecs_to_jiffies(R2NET_QUORUM_DELAY_MS)); - } - - if (was_valid && !valid) { - pr_notice("ramster: No longer connected to " SC_NODEF_FMT "\n", - old_sc->sc_node->nd_name, old_sc->sc_node->nd_num, - &old_sc->sc_node->nd_ipv4_address, - ntohs(old_sc->sc_node->nd_ipv4_port)); - r2net_complete_nodes_nsw(nn); - } - - if (!was_valid && valid) { - cancel_delayed_work(&nn->nn_connect_expired); - pr_notice("ramster: %s " SC_NODEF_FMT "\n", - r2nm_this_node() > sc->sc_node->nd_num ? - "Connected to" : "Accepted connection from", - sc->sc_node->nd_name, sc->sc_node->nd_num, - &sc->sc_node->nd_ipv4_address, - ntohs(sc->sc_node->nd_ipv4_port)); - } - - /* trigger the connecting worker func as long as we're not valid, - * it will back off if it shouldn't connect. This can be called - * from node config teardown and so needs to be careful about - * the work queue actually being up. */ - if (!valid && r2net_wq) { - unsigned long delay; - /* delay if we're within a RECONNECT_DELAY of the - * last attempt */ - delay = (nn->nn_last_connect_attempt + - msecs_to_jiffies(r2net_reconnect_delay())) - - jiffies; - if (delay > msecs_to_jiffies(r2net_reconnect_delay())) - delay = 0; - mlog(ML_CONN, "queueing conn attempt in %lu jiffies\n", delay); - queue_delayed_work(r2net_wq, &nn->nn_connect_work, delay); - - /* - * Delay the expired work after idle timeout. - * - * We might have lots of failed connection attempts that run - * through here but we only cancel the connect_expired work when - * a connection attempt succeeds. So only the first enqueue of - * the connect_expired work will do anything. The rest will see - * that it's already queued and do nothing. - */ - delay += msecs_to_jiffies(r2net_idle_timeout()); - queue_delayed_work(r2net_wq, &nn->nn_connect_expired, delay); - } - - /* keep track of the nn's sc ref for the caller */ - if ((old_sc == NULL) && sc) - sc_get(sc); - if (old_sc && (old_sc != sc)) { - r2net_sc_queue_work(old_sc, &old_sc->sc_shutdown_work); - sc_put(old_sc); - } -} - -/* see r2net_register_callbacks() */ -static void r2net_data_ready(struct sock *sk, int bytes) -{ - void (*ready)(struct sock *sk, int bytes); - - read_lock(&sk->sk_callback_lock); - if (sk->sk_user_data) { - struct r2net_sock_container *sc = sk->sk_user_data; - sclog(sc, "data_ready hit\n"); - r2net_set_data_ready_time(sc); - r2net_sc_queue_work(sc, &sc->sc_rx_work); - ready = sc->sc_data_ready; - } else { - ready = sk->sk_data_ready; - } - read_unlock(&sk->sk_callback_lock); - - ready(sk, bytes); -} - -/* see r2net_register_callbacks() */ -static void r2net_state_change(struct sock *sk) -{ - void (*state_change)(struct sock *sk); - struct r2net_sock_container *sc; - - read_lock(&sk->sk_callback_lock); - sc = sk->sk_user_data; - if (sc == NULL) { - state_change = sk->sk_state_change; - goto out; - } - - sclog(sc, "state_change to %d\n", sk->sk_state); - - state_change = sc->sc_state_change; - - switch (sk->sk_state) { - - /* ignore connecting sockets as they make progress */ - case TCP_SYN_SENT: - case TCP_SYN_RECV: - break; - case TCP_ESTABLISHED: - r2net_sc_queue_work(sc, &sc->sc_connect_work); - break; - default: - pr_info("ramster: Connection to " - SC_NODEF_FMT " shutdown, state %d\n", - sc->sc_node->nd_name, sc->sc_node->nd_num, - &sc->sc_node->nd_ipv4_address, - ntohs(sc->sc_node->nd_ipv4_port), sk->sk_state); - r2net_sc_queue_work(sc, &sc->sc_shutdown_work); - break; - - } -out: - read_unlock(&sk->sk_callback_lock); - state_change(sk); -} - -/* - * we register callbacks so we can queue work on events before calling - * the original callbacks. our callbacks are careful to test user_data - * to discover when they've reaced with r2net_unregister_callbacks(). - */ -static void r2net_register_callbacks(struct sock *sk, - struct r2net_sock_container *sc) -{ - write_lock_bh(&sk->sk_callback_lock); - - /* accepted sockets inherit the old listen socket data ready */ - if (sk->sk_data_ready == r2net_listen_data_ready) { - sk->sk_data_ready = sk->sk_user_data; - sk->sk_user_data = NULL; - } - - BUG_ON(sk->sk_user_data != NULL); - sk->sk_user_data = sc; - sc_get(sc); - - sc->sc_data_ready = sk->sk_data_ready; - sc->sc_state_change = sk->sk_state_change; - sk->sk_data_ready = r2net_data_ready; - sk->sk_state_change = r2net_state_change; - - mutex_init(&sc->sc_send_lock); - - write_unlock_bh(&sk->sk_callback_lock); -} - -static int r2net_unregister_callbacks(struct sock *sk, - struct r2net_sock_container *sc) -{ - int ret = 0; - - write_lock_bh(&sk->sk_callback_lock); - if (sk->sk_user_data == sc) { - ret = 1; - sk->sk_user_data = NULL; - sk->sk_data_ready = sc->sc_data_ready; - sk->sk_state_change = sc->sc_state_change; - } - write_unlock_bh(&sk->sk_callback_lock); - - return ret; -} - -/* - * this is a little helper that is called by callers who have seen a problem - * with an sc and want to detach it from the nn if someone already hasn't beat - * them to it. if an error is given then the shutdown will be persistent - * and pending transmits will be canceled. - */ -static void r2net_ensure_shutdown(struct r2net_node *nn, - struct r2net_sock_container *sc, - int err) -{ - spin_lock(&nn->nn_lock); - if (nn->nn_sc == sc) - r2net_set_nn_state(nn, NULL, 0, err); - spin_unlock(&nn->nn_lock); -} - -/* - * This work queue function performs the blocking parts of socket shutdown. A - * few paths lead here. set_nn_state will trigger this callback if it sees an - * sc detached from the nn. state_change will also trigger this callback - * directly when it sees errors. In that case we need to call set_nn_state - * ourselves as state_change couldn't get the nn_lock and call set_nn_state - * itself. - */ -static void r2net_shutdown_sc(struct work_struct *work) -{ - struct r2net_sock_container *sc = - container_of(work, struct r2net_sock_container, - sc_shutdown_work); - struct r2net_node *nn = r2net_nn_from_num(sc->sc_node->nd_num); - - sclog(sc, "shutting down\n"); - - /* drop the callbacks ref and call shutdown only once */ - if (r2net_unregister_callbacks(sc->sc_sock->sk, sc)) { - /* we shouldn't flush as we're in the thread, the - * races with pending sc work structs are harmless */ - del_timer_sync(&sc->sc_idle_timeout); - r2net_sc_cancel_delayed_work(sc, &sc->sc_keepalive_work); - sc_put(sc); - kernel_sock_shutdown(sc->sc_sock, SHUT_RDWR); - } - - /* not fatal so failed connects before the other guy has our - * heartbeat can be retried */ - r2net_ensure_shutdown(nn, sc, 0); - sc_put(sc); -} - -/* ------------------------------------------------------------ */ - -static int r2net_handler_cmp(struct r2net_msg_handler *nmh, u32 msg_type, - u32 key) -{ - int ret = memcmp(&nmh->nh_key, &key, sizeof(key)); - - if (ret == 0) - ret = memcmp(&nmh->nh_msg_type, &msg_type, sizeof(msg_type)); - - return ret; -} - -static struct r2net_msg_handler * -r2net_handler_tree_lookup(u32 msg_type, u32 key, struct rb_node ***ret_p, - struct rb_node **ret_parent) -{ - struct rb_node **p = &r2net_handler_tree.rb_node; - struct rb_node *parent = NULL; - struct r2net_msg_handler *nmh, *ret = NULL; - int cmp; - - while (*p) { - parent = *p; - nmh = rb_entry(parent, struct r2net_msg_handler, nh_node); - cmp = r2net_handler_cmp(nmh, msg_type, key); - - if (cmp < 0) - p = &(*p)->rb_left; - else if (cmp > 0) - p = &(*p)->rb_right; - else { - ret = nmh; - break; - } - } - - if (ret_p != NULL) - *ret_p = p; - if (ret_parent != NULL) - *ret_parent = parent; - - return ret; -} - -static void r2net_handler_kref_release(struct kref *kref) -{ - struct r2net_msg_handler *nmh; - nmh = container_of(kref, struct r2net_msg_handler, nh_kref); - - kfree(nmh); -} - -static void r2net_handler_put(struct r2net_msg_handler *nmh) -{ - kref_put(&nmh->nh_kref, r2net_handler_kref_release); -} - -/* max_len is protection for the handler func. incoming messages won't - * be given to the handler if their payload is longer than the max. */ -int r2net_register_handler(u32 msg_type, u32 key, u32 max_len, - r2net_msg_handler_func *func, void *data, - r2net_post_msg_handler_func *post_func, - struct list_head *unreg_list) -{ - struct r2net_msg_handler *nmh = NULL; - struct rb_node **p, *parent; - int ret = 0; - - if (max_len > R2NET_MAX_PAYLOAD_BYTES) { - mlog(0, "max_len for message handler out of range: %u\n", - max_len); - ret = -EINVAL; - goto out; - } - - if (!msg_type) { - mlog(0, "no message type provided: %u, %p\n", msg_type, func); - ret = -EINVAL; - goto out; - - } - if (!func) { - mlog(0, "no message handler provided: %u, %p\n", - msg_type, func); - ret = -EINVAL; - goto out; - } - - nmh = kzalloc(sizeof(struct r2net_msg_handler), GFP_NOFS); - if (nmh == NULL) { - ret = -ENOMEM; - goto out; - } - - nmh->nh_func = func; - nmh->nh_func_data = data; - nmh->nh_post_func = post_func; - nmh->nh_msg_type = msg_type; - nmh->nh_max_len = max_len; - nmh->nh_key = key; - /* the tree and list get this ref.. they're both removed in - * unregister when this ref is dropped */ - kref_init(&nmh->nh_kref); - INIT_LIST_HEAD(&nmh->nh_unregister_item); - - write_lock(&r2net_handler_lock); - if (r2net_handler_tree_lookup(msg_type, key, &p, &parent)) - ret = -EEXIST; - else { - rb_link_node(&nmh->nh_node, parent, p); - rb_insert_color(&nmh->nh_node, &r2net_handler_tree); - list_add_tail(&nmh->nh_unregister_item, unreg_list); - - mlog(ML_TCP, "registered handler func %p type %u key %08x\n", - func, msg_type, key); - /* we've had some trouble with handlers seemingly vanishing. */ - mlog_bug_on_msg(r2net_handler_tree_lookup(msg_type, key, &p, - &parent) == NULL, - "couldn't find handler we *just* registered " - "for type %u key %08x\n", msg_type, key); - } - write_unlock(&r2net_handler_lock); - if (ret) - goto out; - -out: - if (ret) - kfree(nmh); - - return ret; -} -EXPORT_SYMBOL_GPL(r2net_register_handler); - -void r2net_unregister_handler_list(struct list_head *list) -{ - struct r2net_msg_handler *nmh, *n; - - write_lock(&r2net_handler_lock); - list_for_each_entry_safe(nmh, n, list, nh_unregister_item) { - mlog(ML_TCP, "unregistering handler func %p type %u key %08x\n", - nmh->nh_func, nmh->nh_msg_type, nmh->nh_key); - rb_erase(&nmh->nh_node, &r2net_handler_tree); - list_del_init(&nmh->nh_unregister_item); - kref_put(&nmh->nh_kref, r2net_handler_kref_release); - } - write_unlock(&r2net_handler_lock); -} -EXPORT_SYMBOL_GPL(r2net_unregister_handler_list); - -static struct r2net_msg_handler *r2net_handler_get(u32 msg_type, u32 key) -{ - struct r2net_msg_handler *nmh; - - read_lock(&r2net_handler_lock); - nmh = r2net_handler_tree_lookup(msg_type, key, NULL, NULL); - if (nmh) - kref_get(&nmh->nh_kref); - read_unlock(&r2net_handler_lock); - - return nmh; -} - -/* ------------------------------------------------------------ */ - -static int r2net_recv_tcp_msg(struct socket *sock, void *data, size_t len) -{ - int ret; - mm_segment_t oldfs; - struct kvec vec = { - .iov_len = len, - .iov_base = data, - }; - struct msghdr msg = { - .msg_iovlen = 1, - .msg_iov = (struct iovec *)&vec, - .msg_flags = MSG_DONTWAIT, - }; - - oldfs = get_fs(); - set_fs(get_ds()); - ret = sock_recvmsg(sock, &msg, len, msg.msg_flags); - set_fs(oldfs); - - return ret; -} - -static int r2net_send_tcp_msg(struct socket *sock, struct kvec *vec, - size_t veclen, size_t total) -{ - int ret; - mm_segment_t oldfs; - struct msghdr msg = { - .msg_iov = (struct iovec *)vec, - .msg_iovlen = veclen, - }; - - if (sock == NULL) { - ret = -EINVAL; - goto out; - } - - oldfs = get_fs(); - set_fs(get_ds()); - ret = sock_sendmsg(sock, &msg, total); - set_fs(oldfs); - if (ret != total) { - mlog(ML_ERROR, "sendmsg returned %d instead of %zu\n", ret, - total); - if (ret >= 0) - ret = -EPIPE; /* should be smarter, I bet */ - goto out; - } - - ret = 0; -out: - if (ret < 0) - mlog(0, "returning error: %d\n", ret); - return ret; -} - -static void r2net_sendpage(struct r2net_sock_container *sc, - void *kmalloced_virt, - size_t size) -{ - struct r2net_node *nn = r2net_nn_from_num(sc->sc_node->nd_num); - ssize_t ret; - - while (1) { - mutex_lock(&sc->sc_send_lock); - ret = sc->sc_sock->ops->sendpage(sc->sc_sock, - virt_to_page(kmalloced_virt), - (long)kmalloced_virt & ~PAGE_MASK, - size, MSG_DONTWAIT); - mutex_unlock(&sc->sc_send_lock); - if (ret == size) - break; - if (ret == (ssize_t)-EAGAIN) { - mlog(0, "sendpage of size %zu to " SC_NODEF_FMT - " returned EAGAIN\n", size, sc->sc_node->nd_name, - sc->sc_node->nd_num, - &sc->sc_node->nd_ipv4_address, - ntohs(sc->sc_node->nd_ipv4_port)); - cond_resched(); - continue; - } - mlog(ML_ERROR, "sendpage of size %zu to " SC_NODEF_FMT - " failed with %zd\n", size, sc->sc_node->nd_name, - sc->sc_node->nd_num, &sc->sc_node->nd_ipv4_address, - ntohs(sc->sc_node->nd_ipv4_port), ret); - r2net_ensure_shutdown(nn, sc, 0); - break; - } -} - -static void r2net_init_msg(struct r2net_msg *msg, u16 data_len, - u16 msg_type, u32 key) -{ - memset(msg, 0, sizeof(struct r2net_msg)); - msg->magic = cpu_to_be16(R2NET_MSG_MAGIC); - msg->data_len = cpu_to_be16(data_len); - msg->msg_type = cpu_to_be16(msg_type); - msg->sys_status = cpu_to_be32(R2NET_ERR_NONE); - msg->status = 0; - msg->key = cpu_to_be32(key); -} - -static int r2net_tx_can_proceed(struct r2net_node *nn, - struct r2net_sock_container **sc_ret, - int *error) -{ - int ret = 0; - - spin_lock(&nn->nn_lock); - if (nn->nn_persistent_error) { - ret = 1; - *sc_ret = NULL; - *error = nn->nn_persistent_error; - } else if (nn->nn_sc_valid) { - kref_get(&nn->nn_sc->sc_kref); - - ret = 1; - *sc_ret = nn->nn_sc; - *error = 0; - } - spin_unlock(&nn->nn_lock); - - return ret; -} - -/* Get a map of all nodes to which this node is currently connected to */ -void r2net_fill_node_map(unsigned long *map, unsigned bytes) -{ - struct r2net_sock_container *sc; - int node, ret; - - BUG_ON(bytes < (BITS_TO_LONGS(R2NM_MAX_NODES) * sizeof(unsigned long))); - - memset(map, 0, bytes); - for (node = 0; node < R2NM_MAX_NODES; ++node) { - r2net_tx_can_proceed(r2net_nn_from_num(node), &sc, &ret); - if (!ret) { - set_bit(node, map); - sc_put(sc); - } - } -} -EXPORT_SYMBOL_GPL(r2net_fill_node_map); - -int r2net_send_message_vec(u32 msg_type, u32 key, struct kvec *caller_vec, - size_t caller_veclen, u8 target_node, int *status) -{ - int ret = 0; - struct r2net_msg *msg = NULL; - size_t veclen, caller_bytes = 0; - struct kvec *vec = NULL; - struct r2net_sock_container *sc = NULL; - struct r2net_node *nn = r2net_nn_from_num(target_node); - struct r2net_status_wait nsw = { - .ns_node_item = LIST_HEAD_INIT(nsw.ns_node_item), - }; - struct r2net_send_tracking nst; - - /* this may be a general bug fix */ - init_waitqueue_head(&nsw.ns_wq); - - r2net_init_nst(&nst, msg_type, key, current, target_node); - - if (r2net_wq == NULL) { - mlog(0, "attempt to tx without r2netd running\n"); - ret = -ESRCH; - goto out; - } - - if (caller_veclen == 0) { - mlog(0, "bad kvec array length\n"); - ret = -EINVAL; - goto out; - } - - caller_bytes = iov_length((struct iovec *)caller_vec, caller_veclen); - if (caller_bytes > R2NET_MAX_PAYLOAD_BYTES) { - mlog(0, "total payload len %zu too large\n", caller_bytes); - ret = -EINVAL; - goto out; - } - - if (target_node == r2nm_this_node()) { - ret = -ELOOP; - goto out; - } - - r2net_debug_add_nst(&nst); - - r2net_set_nst_sock_time(&nst); - - wait_event(nn->nn_sc_wq, r2net_tx_can_proceed(nn, &sc, &ret)); - if (ret) - goto out; - - r2net_set_nst_sock_container(&nst, sc); - - veclen = caller_veclen + 1; - vec = kmalloc(sizeof(struct kvec) * veclen, GFP_ATOMIC); - if (vec == NULL) { - mlog(0, "failed to %zu element kvec!\n", veclen); - ret = -ENOMEM; - goto out; - } - - msg = kmalloc(sizeof(struct r2net_msg), GFP_ATOMIC); - if (!msg) { - mlog(0, "failed to allocate a r2net_msg!\n"); - ret = -ENOMEM; - goto out; - } - - r2net_init_msg(msg, caller_bytes, msg_type, key); - - vec[0].iov_len = sizeof(struct r2net_msg); - vec[0].iov_base = msg; - memcpy(&vec[1], caller_vec, caller_veclen * sizeof(struct kvec)); - - ret = r2net_prep_nsw(nn, &nsw); - if (ret) - goto out; - - msg->msg_num = cpu_to_be32(nsw.ns_id); - r2net_set_nst_msg_id(&nst, nsw.ns_id); - - r2net_set_nst_send_time(&nst); - - /* finally, convert the message header to network byte-order - * and send */ - mutex_lock(&sc->sc_send_lock); - ret = r2net_send_tcp_msg(sc->sc_sock, vec, veclen, - sizeof(struct r2net_msg) + caller_bytes); - mutex_unlock(&sc->sc_send_lock); - msglog(msg, "sending returned %d\n", ret); - if (ret < 0) { - mlog(0, "error returned from r2net_send_tcp_msg=%d\n", ret); - goto out; - } - - /* wait on other node's handler */ - r2net_set_nst_status_time(&nst); - wait_event(nsw.ns_wq, r2net_nsw_completed(nn, &nsw) || - nn->nn_persistent_error || !nn->nn_sc_valid); - - r2net_update_send_stats(&nst, sc); - - /* Note that we avoid overwriting the callers status return - * variable if a system error was reported on the other - * side. Callers beware. */ - ret = r2net_sys_err_to_errno(nsw.ns_sys_status); - if (status && !ret) - *status = nsw.ns_status; - - mlog(0, "woken, returning system status %d, user status %d\n", - ret, nsw.ns_status); -out: - r2net_debug_del_nst(&nst); /* must be before dropping sc and node */ - if (sc) - sc_put(sc); - kfree(vec); - kfree(msg); - r2net_complete_nsw(nn, &nsw, 0, 0, 0); - return ret; -} -EXPORT_SYMBOL_GPL(r2net_send_message_vec); - -int r2net_send_message(u32 msg_type, u32 key, void *data, u32 len, - u8 target_node, int *status) -{ - struct kvec vec = { - .iov_base = data, - .iov_len = len, - }; - return r2net_send_message_vec(msg_type, key, &vec, 1, - target_node, status); -} -EXPORT_SYMBOL_GPL(r2net_send_message); - -static int r2net_send_status_magic(struct socket *sock, struct r2net_msg *hdr, - enum r2net_system_error syserr, int err) -{ - struct kvec vec = { - .iov_base = hdr, - .iov_len = sizeof(struct r2net_msg), - }; - - BUG_ON(syserr >= R2NET_ERR_MAX); - - /* leave other fields intact from the incoming message, msg_num - * in particular */ - hdr->sys_status = cpu_to_be32(syserr); - hdr->status = cpu_to_be32(err); - /* twiddle the magic */ - hdr->magic = cpu_to_be16(R2NET_MSG_STATUS_MAGIC); - hdr->data_len = 0; - - msglog(hdr, "about to send status magic %d\n", err); - /* hdr has been in host byteorder this whole time */ - return r2net_send_tcp_msg(sock, &vec, 1, sizeof(struct r2net_msg)); -} - -/* - * "data magic" is a long version of "status magic" where the message - * payload actually contains data to be passed in reply to certain messages - */ -static int r2net_send_data_magic(struct r2net_sock_container *sc, - struct r2net_msg *hdr, - void *data, size_t data_len, - enum r2net_system_error syserr, int err) -{ - struct kvec vec[2]; - int ret; - - vec[0].iov_base = hdr; - vec[0].iov_len = sizeof(struct r2net_msg); - vec[1].iov_base = data; - vec[1].iov_len = data_len; - - BUG_ON(syserr >= R2NET_ERR_MAX); - - /* leave other fields intact from the incoming message, msg_num - * in particular */ - hdr->sys_status = cpu_to_be32(syserr); - hdr->status = cpu_to_be32(err); - hdr->magic = cpu_to_be16(R2NET_MSG_DATA_MAGIC); /* twiddle magic */ - hdr->data_len = cpu_to_be16(data_len); - - msglog(hdr, "about to send data magic %d\n", err); - /* hdr has been in host byteorder this whole time */ - ret = r2net_send_tcp_msg(sc->sc_sock, vec, 2, - sizeof(struct r2net_msg) + data_len); - return ret; -} - -/* - * called by a message handler to convert an otherwise normal reply - * message into a "data magic" message - */ -void r2net_force_data_magic(struct r2net_msg *hdr, u16 msgtype, u32 msgkey) -{ - hdr->magic = cpu_to_be16(R2NET_MSG_DATA_MAGIC); - hdr->msg_type = cpu_to_be16(msgtype); - hdr->key = cpu_to_be32(msgkey); -} - -/* this returns -errno if the header was unknown or too large, etc. - * after this is called the buffer us reused for the next message */ -static int r2net_process_message(struct r2net_sock_container *sc, - struct r2net_msg *hdr) -{ - struct r2net_node *nn = r2net_nn_from_num(sc->sc_node->nd_num); - int ret = 0, handler_status; - enum r2net_system_error syserr; - struct r2net_msg_handler *nmh = NULL; - void *ret_data = NULL; - int data_magic = 0; - - msglog(hdr, "processing message\n"); - - r2net_sc_postpone_idle(sc); - - switch (be16_to_cpu(hdr->magic)) { - - case R2NET_MSG_STATUS_MAGIC: - /* special type for returning message status */ - r2net_complete_nsw(nn, NULL, be32_to_cpu(hdr->msg_num), - be32_to_cpu(hdr->sys_status), - be32_to_cpu(hdr->status)); - goto out; - case R2NET_MSG_KEEP_REQ_MAGIC: - r2net_sendpage(sc, r2net_keep_resp, sizeof(*r2net_keep_resp)); - goto out; - case R2NET_MSG_KEEP_RESP_MAGIC: - goto out; - case R2NET_MSG_MAGIC: - break; - case R2NET_MSG_DATA_MAGIC: - /* - * unlike a normal status magic, a data magic DOES - * (MUST) have a handler, so the control flow is - * a little funky here as a result - */ - data_magic = 1; - break; - default: - msglog(hdr, "bad magic\n"); - ret = -EINVAL; - goto out; - break; - } - - /* find a handler for it */ - handler_status = 0; - nmh = r2net_handler_get(be16_to_cpu(hdr->msg_type), - be32_to_cpu(hdr->key)); - if (!nmh) { - mlog(ML_TCP, "couldn't find handler for type %u key %08x\n", - be16_to_cpu(hdr->msg_type), be32_to_cpu(hdr->key)); - syserr = R2NET_ERR_NO_HNDLR; - goto out_respond; - } - - syserr = R2NET_ERR_NONE; - - if (be16_to_cpu(hdr->data_len) > nmh->nh_max_len) - syserr = R2NET_ERR_OVERFLOW; - - if (syserr != R2NET_ERR_NONE) { - pr_err("ramster_r2net, message length problem\n"); - goto out_respond; - } - - r2net_set_func_start_time(sc); - sc->sc_msg_key = be32_to_cpu(hdr->key); - sc->sc_msg_type = be16_to_cpu(hdr->msg_type); - handler_status = (nmh->nh_func)(hdr, sizeof(struct r2net_msg) + - be16_to_cpu(hdr->data_len), - nmh->nh_func_data, &ret_data); - if (data_magic) { - /* - * handler handled data sent in reply to request - * so complete the transaction - */ - r2net_complete_nsw(nn, NULL, be32_to_cpu(hdr->msg_num), - be32_to_cpu(hdr->sys_status), handler_status); - goto out; - } - /* - * handler changed magic to DATA_MAGIC to reply to request for data, - * implies ret_data points to data to return and handler_status - * is the number of bytes of data - */ - if (be16_to_cpu(hdr->magic) == R2NET_MSG_DATA_MAGIC) { - ret = r2net_send_data_magic(sc, hdr, - ret_data, handler_status, - syserr, 0); - hdr = NULL; - mlog(0, "sending data reply %d, syserr %d returned %d\n", - handler_status, syserr, ret); - r2net_set_func_stop_time(sc); - - r2net_update_recv_stats(sc); - goto out; - } - r2net_set_func_stop_time(sc); - - r2net_update_recv_stats(sc); - -out_respond: - /* this destroys the hdr, so don't use it after this */ - mutex_lock(&sc->sc_send_lock); - ret = r2net_send_status_magic(sc->sc_sock, hdr, syserr, - handler_status); - mutex_unlock(&sc->sc_send_lock); - hdr = NULL; - mlog(0, "sending handler status %d, syserr %d returned %d\n", - handler_status, syserr, ret); - - if (nmh) { - BUG_ON(ret_data != NULL && nmh->nh_post_func == NULL); - if (nmh->nh_post_func) - (nmh->nh_post_func)(handler_status, nmh->nh_func_data, - ret_data); - } - -out: - if (nmh) - r2net_handler_put(nmh); - return ret; -} - -static int r2net_check_handshake(struct r2net_sock_container *sc) -{ - struct r2net_handshake *hand = page_address(sc->sc_page); - struct r2net_node *nn = r2net_nn_from_num(sc->sc_node->nd_num); - - if (hand->protocol_version != cpu_to_be64(R2NET_PROTOCOL_VERSION)) { - pr_notice("ramster: " SC_NODEF_FMT " Advertised net " - "protocol version %llu but %llu is required. " - "Disconnecting.\n", sc->sc_node->nd_name, - sc->sc_node->nd_num, &sc->sc_node->nd_ipv4_address, - ntohs(sc->sc_node->nd_ipv4_port), - (unsigned long long)be64_to_cpu(hand->protocol_version), - R2NET_PROTOCOL_VERSION); - - /* don't bother reconnecting if its the wrong version. */ - r2net_ensure_shutdown(nn, sc, -ENOTCONN); - return -1; - } - - /* - * Ensure timeouts are consistent with other nodes, otherwise - * we can end up with one node thinking that the other must be down, - * but isn't. This can ultimately cause corruption. - */ - if (be32_to_cpu(hand->r2net_idle_timeout_ms) != - r2net_idle_timeout()) { - pr_notice("ramster: " SC_NODEF_FMT " uses a network " - "idle timeout of %u ms, but we use %u ms locally. " - "Disconnecting.\n", sc->sc_node->nd_name, - sc->sc_node->nd_num, &sc->sc_node->nd_ipv4_address, - ntohs(sc->sc_node->nd_ipv4_port), - be32_to_cpu(hand->r2net_idle_timeout_ms), - r2net_idle_timeout()); - r2net_ensure_shutdown(nn, sc, -ENOTCONN); - return -1; - } - - if (be32_to_cpu(hand->r2net_keepalive_delay_ms) != - r2net_keepalive_delay()) { - pr_notice("ramster: " SC_NODEF_FMT " uses a keepalive " - "delay of %u ms, but we use %u ms locally. " - "Disconnecting.\n", sc->sc_node->nd_name, - sc->sc_node->nd_num, &sc->sc_node->nd_ipv4_address, - ntohs(sc->sc_node->nd_ipv4_port), - be32_to_cpu(hand->r2net_keepalive_delay_ms), - r2net_keepalive_delay()); - r2net_ensure_shutdown(nn, sc, -ENOTCONN); - return -1; - } - - if (be32_to_cpu(hand->r2hb_heartbeat_timeout_ms) != - R2HB_MAX_WRITE_TIMEOUT_MS) { - pr_notice("ramster: " SC_NODEF_FMT " uses a heartbeat " - "timeout of %u ms, but we use %u ms locally. " - "Disconnecting.\n", sc->sc_node->nd_name, - sc->sc_node->nd_num, &sc->sc_node->nd_ipv4_address, - ntohs(sc->sc_node->nd_ipv4_port), - be32_to_cpu(hand->r2hb_heartbeat_timeout_ms), - R2HB_MAX_WRITE_TIMEOUT_MS); - r2net_ensure_shutdown(nn, sc, -ENOTCONN); - return -1; - } - - sc->sc_handshake_ok = 1; - - spin_lock(&nn->nn_lock); - /* set valid and queue the idle timers only if it hasn't been - * shut down already */ - if (nn->nn_sc == sc) { - r2net_sc_reset_idle_timer(sc); - atomic_set(&nn->nn_timeout, 0); - r2net_set_nn_state(nn, sc, 1, 0); - } - spin_unlock(&nn->nn_lock); - - /* shift everything up as though it wasn't there */ - sc->sc_page_off -= sizeof(struct r2net_handshake); - if (sc->sc_page_off) - memmove(hand, hand + 1, sc->sc_page_off); - - return 0; -} - -/* this demuxes the queued rx bytes into header or payload bits and calls - * handlers as each full message is read off the socket. it returns -error, - * == 0 eof, or > 0 for progress made.*/ -static int r2net_advance_rx(struct r2net_sock_container *sc) -{ - struct r2net_msg *hdr; - int ret = 0; - void *data; - size_t datalen; - - sclog(sc, "receiving\n"); - r2net_set_advance_start_time(sc); - - if (unlikely(sc->sc_handshake_ok == 0)) { - if (sc->sc_page_off < sizeof(struct r2net_handshake)) { - data = page_address(sc->sc_page) + sc->sc_page_off; - datalen = sizeof(struct r2net_handshake) - - sc->sc_page_off; - ret = r2net_recv_tcp_msg(sc->sc_sock, data, datalen); - if (ret > 0) - sc->sc_page_off += ret; - } - - if (sc->sc_page_off == sizeof(struct r2net_handshake)) { - r2net_check_handshake(sc); - if (unlikely(sc->sc_handshake_ok == 0)) - ret = -EPROTO; - } - goto out; - } - - /* do we need more header? */ - if (sc->sc_page_off < sizeof(struct r2net_msg)) { - data = page_address(sc->sc_page) + sc->sc_page_off; - datalen = sizeof(struct r2net_msg) - sc->sc_page_off; - ret = r2net_recv_tcp_msg(sc->sc_sock, data, datalen); - if (ret > 0) { - sc->sc_page_off += ret; - /* only swab incoming here.. we can - * only get here once as we cross from - * being under to over */ - if (sc->sc_page_off == sizeof(struct r2net_msg)) { - hdr = page_address(sc->sc_page); - if (be16_to_cpu(hdr->data_len) > - R2NET_MAX_PAYLOAD_BYTES) - ret = -EOVERFLOW; - WARN_ON_ONCE(ret == -EOVERFLOW); - } - } - if (ret <= 0) - goto out; - } - - if (sc->sc_page_off < sizeof(struct r2net_msg)) { - /* oof, still don't have a header */ - goto out; - } - - /* this was swabbed above when we first read it */ - hdr = page_address(sc->sc_page); - - msglog(hdr, "at page_off %zu\n", sc->sc_page_off); - - /* do we need more payload? */ - if (sc->sc_page_off - sizeof(struct r2net_msg) < - be16_to_cpu(hdr->data_len)) { - /* need more payload */ - data = page_address(sc->sc_page) + sc->sc_page_off; - datalen = (sizeof(struct r2net_msg) + - be16_to_cpu(hdr->data_len)) - - sc->sc_page_off; - ret = r2net_recv_tcp_msg(sc->sc_sock, data, datalen); - if (ret > 0) - sc->sc_page_off += ret; - if (ret <= 0) - goto out; - } - - if (sc->sc_page_off - sizeof(struct r2net_msg) == - be16_to_cpu(hdr->data_len)) { - /* we can only get here once, the first time we read - * the payload.. so set ret to progress if the handler - * works out. after calling this the message is toast */ - ret = r2net_process_message(sc, hdr); - if (ret == 0) - ret = 1; - sc->sc_page_off = 0; - } - -out: - sclog(sc, "ret = %d\n", ret); - r2net_set_advance_stop_time(sc); - return ret; -} - -/* this work func is triggerd by data ready. it reads until it can read no - * more. it interprets 0, eof, as fatal. if data_ready hits while we're doing - * our work the work struct will be marked and we'll be called again. */ -static void r2net_rx_until_empty(struct work_struct *work) -{ - struct r2net_sock_container *sc = - container_of(work, struct r2net_sock_container, sc_rx_work); - int ret; - - do { - ret = r2net_advance_rx(sc); - } while (ret > 0); - - if (ret <= 0 && ret != -EAGAIN) { - struct r2net_node *nn = r2net_nn_from_num(sc->sc_node->nd_num); - sclog(sc, "saw error %d, closing\n", ret); - /* not permanent so read failed handshake can retry */ - r2net_ensure_shutdown(nn, sc, 0); - } - sc_put(sc); -} - -static int r2net_set_nodelay(struct socket *sock) -{ - int ret, val = 1; - mm_segment_t oldfs; - - oldfs = get_fs(); - set_fs(KERNEL_DS); - - /* - * Dear unsuspecting programmer, - * - * Don't use sock_setsockopt() for SOL_TCP. It doesn't check its level - * argument and assumes SOL_SOCKET so, say, your TCP_NODELAY will - * silently turn into SO_DEBUG. - * - * Yours, - * Keeper of hilariously fragile interfaces. - */ - ret = sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, - (char __user *)&val, sizeof(val)); - - set_fs(oldfs); - return ret; -} - -static void r2net_initialize_handshake(void) -{ - r2net_hand->r2hb_heartbeat_timeout_ms = cpu_to_be32( - R2HB_MAX_WRITE_TIMEOUT_MS); - r2net_hand->r2net_idle_timeout_ms = cpu_to_be32(r2net_idle_timeout()); - r2net_hand->r2net_keepalive_delay_ms = cpu_to_be32( - r2net_keepalive_delay()); - r2net_hand->r2net_reconnect_delay_ms = cpu_to_be32( - r2net_reconnect_delay()); -} - -/* ------------------------------------------------------------ */ - -/* called when a connect completes and after a sock is accepted. the - * rx path will see the response and mark the sc valid */ -static void r2net_sc_connect_completed(struct work_struct *work) -{ - struct r2net_sock_container *sc = - container_of(work, struct r2net_sock_container, - sc_connect_work); - - mlog(ML_MSG, "sc sending handshake with ver %llu id %llx\n", - (unsigned long long)R2NET_PROTOCOL_VERSION, - (unsigned long long)be64_to_cpu(r2net_hand->connector_id)); - - r2net_initialize_handshake(); - r2net_sendpage(sc, r2net_hand, sizeof(*r2net_hand)); - sc_put(sc); -} - -/* this is called as a work_struct func. */ -static void r2net_sc_send_keep_req(struct work_struct *work) -{ - struct r2net_sock_container *sc = - container_of(work, struct r2net_sock_container, - sc_keepalive_work.work); - - r2net_sendpage(sc, r2net_keep_req, sizeof(*r2net_keep_req)); - sc_put(sc); -} - -/* socket shutdown does a del_timer_sync against this as it tears down. - * we can't start this timer until we've got to the point in sc buildup - * where shutdown is going to be involved */ -static void r2net_idle_timer(unsigned long data) -{ - struct r2net_sock_container *sc = (struct r2net_sock_container *)data; - struct r2net_node *nn = r2net_nn_from_num(sc->sc_node->nd_num); -#ifdef CONFIG_DEBUG_FS - unsigned long msecs = ktime_to_ms(ktime_get()) - - ktime_to_ms(sc->sc_tv_timer); -#else - unsigned long msecs = r2net_idle_timeout(); -#endif - - pr_notice("ramster: Connection to " SC_NODEF_FMT " has been " - "idle for %lu.%lu secs, shutting it down.\n", - sc->sc_node->nd_name, sc->sc_node->nd_num, - &sc->sc_node->nd_ipv4_address, ntohs(sc->sc_node->nd_ipv4_port), - msecs / 1000, msecs % 1000); - - /* - * Initialize the nn_timeout so that the next connection attempt - * will continue in r2net_start_connect. - */ - atomic_set(&nn->nn_timeout, 1); - r2net_sc_queue_work(sc, &sc->sc_shutdown_work); -} - -static void r2net_sc_reset_idle_timer(struct r2net_sock_container *sc) -{ - r2net_sc_cancel_delayed_work(sc, &sc->sc_keepalive_work); - r2net_sc_queue_delayed_work(sc, &sc->sc_keepalive_work, - msecs_to_jiffies(r2net_keepalive_delay())); - r2net_set_sock_timer(sc); - mod_timer(&sc->sc_idle_timeout, - jiffies + msecs_to_jiffies(r2net_idle_timeout())); -} - -static void r2net_sc_postpone_idle(struct r2net_sock_container *sc) -{ - /* Only push out an existing timer */ - if (timer_pending(&sc->sc_idle_timeout)) - r2net_sc_reset_idle_timer(sc); -} - -/* this work func is kicked whenever a path sets the nn state which doesn't - * have valid set. This includes seeing hb come up, losing a connection, - * having a connect attempt fail, etc. This centralizes the logic which decides - * if a connect attempt should be made or if we should give up and all future - * transmit attempts should fail */ -static void r2net_start_connect(struct work_struct *work) -{ - struct r2net_node *nn = - container_of(work, struct r2net_node, nn_connect_work.work); - struct r2net_sock_container *sc = NULL; - struct r2nm_node *node = NULL, *mynode = NULL; - struct socket *sock = NULL; - struct sockaddr_in myaddr = {0, }, remoteaddr = {0, }; - int ret = 0, stop; - unsigned int timeout; - - /* if we're greater we initiate tx, otherwise we accept */ - if (r2nm_this_node() <= r2net_num_from_nn(nn)) - goto out; - - /* watch for racing with tearing a node down */ - node = r2nm_get_node_by_num(r2net_num_from_nn(nn)); - if (node == NULL) { - ret = 0; - goto out; - } - - mynode = r2nm_get_node_by_num(r2nm_this_node()); - if (mynode == NULL) { - ret = 0; - goto out; - } - - spin_lock(&nn->nn_lock); - /* - * see if we already have one pending or have given up. - * For nn_timeout, it is set when we close the connection - * because of the idle time out. So it means that we have - * at least connected to that node successfully once, - * now try to connect to it again. - */ - timeout = atomic_read(&nn->nn_timeout); - stop = (nn->nn_sc || - (nn->nn_persistent_error && - (nn->nn_persistent_error != -ENOTCONN || timeout == 0))); - spin_unlock(&nn->nn_lock); - if (stop) - goto out; - - nn->nn_last_connect_attempt = jiffies; - - sc = sc_alloc(node); - if (sc == NULL) { - mlog(0, "couldn't allocate sc\n"); - ret = -ENOMEM; - goto out; - } - - ret = sock_create(PF_INET, SOCK_STREAM, IPPROTO_TCP, &sock); - if (ret < 0) { - mlog(0, "can't create socket: %d\n", ret); - goto out; - } - sc->sc_sock = sock; /* freed by sc_kref_release */ - - sock->sk->sk_allocation = GFP_ATOMIC; - - myaddr.sin_family = AF_INET; - myaddr.sin_addr.s_addr = mynode->nd_ipv4_address; - myaddr.sin_port = htons(0); /* any port */ - - ret = sock->ops->bind(sock, (struct sockaddr *)&myaddr, - sizeof(myaddr)); - if (ret) { - mlog(ML_ERROR, "bind failed with %d at address %pI4\n", - ret, &mynode->nd_ipv4_address); - goto out; - } - - ret = r2net_set_nodelay(sc->sc_sock); - if (ret) { - mlog(ML_ERROR, "setting TCP_NODELAY failed with %d\n", ret); - goto out; - } - - r2net_register_callbacks(sc->sc_sock->sk, sc); - - spin_lock(&nn->nn_lock); - /* handshake completion will set nn->nn_sc_valid */ - r2net_set_nn_state(nn, sc, 0, 0); - spin_unlock(&nn->nn_lock); - - remoteaddr.sin_family = AF_INET; - remoteaddr.sin_addr.s_addr = node->nd_ipv4_address; - remoteaddr.sin_port = node->nd_ipv4_port; - - ret = sc->sc_sock->ops->connect(sc->sc_sock, - (struct sockaddr *)&remoteaddr, - sizeof(remoteaddr), - O_NONBLOCK); - if (ret == -EINPROGRESS) - ret = 0; - -out: - if (ret) { - pr_notice("ramster: Connect attempt to " SC_NODEF_FMT - " failed with errno %d\n", sc->sc_node->nd_name, - sc->sc_node->nd_num, &sc->sc_node->nd_ipv4_address, - ntohs(sc->sc_node->nd_ipv4_port), ret); - /* 0 err so that another will be queued and attempted - * from set_nn_state */ - if (sc) - r2net_ensure_shutdown(nn, sc, 0); - } - if (sc) - sc_put(sc); - if (node) - r2nm_node_put(node); - if (mynode) - r2nm_node_put(mynode); - - return; -} - -static void r2net_connect_expired(struct work_struct *work) -{ - struct r2net_node *nn = - container_of(work, struct r2net_node, nn_connect_expired.work); - - spin_lock(&nn->nn_lock); - if (!nn->nn_sc_valid) { - pr_notice("ramster: No connection established with " - "node %u after %u.%u seconds, giving up.\n", - r2net_num_from_nn(nn), - r2net_idle_timeout() / 1000, - r2net_idle_timeout() % 1000); - - r2net_set_nn_state(nn, NULL, 0, -ENOTCONN); - } - spin_unlock(&nn->nn_lock); -} - -static void r2net_still_up(struct work_struct *work) -{ -} - -/* ------------------------------------------------------------ */ - -void r2net_disconnect_node(struct r2nm_node *node) -{ - struct r2net_node *nn = r2net_nn_from_num(node->nd_num); - - /* don't reconnect until it's heartbeating again */ - spin_lock(&nn->nn_lock); - atomic_set(&nn->nn_timeout, 0); - r2net_set_nn_state(nn, NULL, 0, -ENOTCONN); - spin_unlock(&nn->nn_lock); - - if (r2net_wq) { - cancel_delayed_work(&nn->nn_connect_expired); - cancel_delayed_work(&nn->nn_connect_work); - cancel_delayed_work(&nn->nn_still_up); - flush_workqueue(r2net_wq); - } -} - -static void r2net_hb_node_down_cb(struct r2nm_node *node, int node_num, - void *data) -{ - if (!node) - return; - - if (node_num != r2nm_this_node()) - r2net_disconnect_node(node); - - BUG_ON(atomic_read(&r2net_connected_peers) < 0); -} - -static void r2net_hb_node_up_cb(struct r2nm_node *node, int node_num, - void *data) -{ - struct r2net_node *nn = r2net_nn_from_num(node_num); - - BUG_ON(!node); - - /* ensure an immediate connect attempt */ - nn->nn_last_connect_attempt = jiffies - - (msecs_to_jiffies(r2net_reconnect_delay()) + 1); - - if (node_num != r2nm_this_node()) { - /* believe it or not, accept and node hearbeating testing - * can succeed for this node before we got here.. so - * only use set_nn_state to clear the persistent error - * if that hasn't already happened */ - spin_lock(&nn->nn_lock); - atomic_set(&nn->nn_timeout, 0); - if (nn->nn_persistent_error) - r2net_set_nn_state(nn, NULL, 0, 0); - spin_unlock(&nn->nn_lock); - } -} - -void r2net_unregister_hb_callbacks(void) -{ - r2hb_unregister_callback(NULL, &r2net_hb_up); - r2hb_unregister_callback(NULL, &r2net_hb_down); -} - -int r2net_register_hb_callbacks(void) -{ - int ret; - - r2hb_setup_callback(&r2net_hb_down, R2HB_NODE_DOWN_CB, - r2net_hb_node_down_cb, NULL, R2NET_HB_PRI); - r2hb_setup_callback(&r2net_hb_up, R2HB_NODE_UP_CB, - r2net_hb_node_up_cb, NULL, R2NET_HB_PRI); - - ret = r2hb_register_callback(NULL, &r2net_hb_up); - if (ret == 0) - ret = r2hb_register_callback(NULL, &r2net_hb_down); - - if (ret) - r2net_unregister_hb_callbacks(); - - return ret; -} - -/* ------------------------------------------------------------ */ - -static int r2net_accept_one(struct socket *sock) -{ - int ret, slen; - struct sockaddr_in sin; - struct socket *new_sock = NULL; - struct r2nm_node *node = NULL; - struct r2nm_node *local_node = NULL; - struct r2net_sock_container *sc = NULL; - struct r2net_node *nn; - - BUG_ON(sock == NULL); - ret = sock_create_lite(sock->sk->sk_family, sock->sk->sk_type, - sock->sk->sk_protocol, &new_sock); - if (ret) - goto out; - - new_sock->type = sock->type; - new_sock->ops = sock->ops; - ret = sock->ops->accept(sock, new_sock, O_NONBLOCK); - if (ret < 0) - goto out; - - new_sock->sk->sk_allocation = GFP_ATOMIC; - - ret = r2net_set_nodelay(new_sock); - if (ret) { - mlog(ML_ERROR, "setting TCP_NODELAY failed with %d\n", ret); - goto out; - } - - slen = sizeof(sin); - ret = new_sock->ops->getname(new_sock, (struct sockaddr *) &sin, - &slen, 1); - if (ret < 0) - goto out; - - node = r2nm_get_node_by_ip(sin.sin_addr.s_addr); - if (node == NULL) { - pr_notice("ramster: Attempt to connect from unknown " - "node at %pI4:%d\n", &sin.sin_addr.s_addr, - ntohs(sin.sin_port)); - ret = -EINVAL; - goto out; - } - - if (r2nm_this_node() >= node->nd_num) { - local_node = r2nm_get_node_by_num(r2nm_this_node()); - pr_notice("ramster: Unexpected connect attempt seen " - "at node '%s' (%u, %pI4:%d) from node '%s' (%u, " - "%pI4:%d)\n", local_node->nd_name, local_node->nd_num, - &(local_node->nd_ipv4_address), - ntohs(local_node->nd_ipv4_port), node->nd_name, - node->nd_num, &sin.sin_addr.s_addr, ntohs(sin.sin_port)); - ret = -EINVAL; - goto out; - } - - /* this happens all the time when the other node sees our heartbeat - * and tries to connect before we see their heartbeat */ - if (!r2hb_check_node_heartbeating_from_callback(node->nd_num)) { - mlog(ML_CONN, "attempt to connect from node '%s' at " - "%pI4:%d but it isn't heartbeating\n", - node->nd_name, &sin.sin_addr.s_addr, - ntohs(sin.sin_port)); - ret = -EINVAL; - goto out; - } - - nn = r2net_nn_from_num(node->nd_num); - - spin_lock(&nn->nn_lock); - if (nn->nn_sc) - ret = -EBUSY; - else - ret = 0; - spin_unlock(&nn->nn_lock); - if (ret) { - pr_notice("ramster: Attempt to connect from node '%s' " - "at %pI4:%d but it already has an open connection\n", - node->nd_name, &sin.sin_addr.s_addr, - ntohs(sin.sin_port)); - goto out; - } - - sc = sc_alloc(node); - if (sc == NULL) { - ret = -ENOMEM; - goto out; - } - - sc->sc_sock = new_sock; - new_sock = NULL; - - spin_lock(&nn->nn_lock); - atomic_set(&nn->nn_timeout, 0); - r2net_set_nn_state(nn, sc, 0, 0); - spin_unlock(&nn->nn_lock); - - r2net_register_callbacks(sc->sc_sock->sk, sc); - r2net_sc_queue_work(sc, &sc->sc_rx_work); - - r2net_initialize_handshake(); - r2net_sendpage(sc, r2net_hand, sizeof(*r2net_hand)); - -out: - if (new_sock) - sock_release(new_sock); - if (node) - r2nm_node_put(node); - if (local_node) - r2nm_node_put(local_node); - if (sc) - sc_put(sc); - return ret; -} - -static void r2net_accept_many(struct work_struct *work) -{ - struct socket *sock = r2net_listen_sock; - while (r2net_accept_one(sock) == 0) - cond_resched(); -} - -static void r2net_listen_data_ready(struct sock *sk, int bytes) -{ - void (*ready)(struct sock *sk, int bytes); - - read_lock(&sk->sk_callback_lock); - ready = sk->sk_user_data; - if (ready == NULL) { /* check for teardown race */ - ready = sk->sk_data_ready; - goto out; - } - - /* ->sk_data_ready is also called for a newly established child socket - * before it has been accepted and the acceptor has set up their - * data_ready.. we only want to queue listen work for our listening - * socket */ - if (sk->sk_state == TCP_LISTEN) { - mlog(ML_TCP, "bytes: %d\n", bytes); - queue_work(r2net_wq, &r2net_listen_work); - } - -out: - read_unlock(&sk->sk_callback_lock); - ready(sk, bytes); -} - -static int r2net_open_listening_sock(__be32 addr, __be16 port) -{ - struct socket *sock = NULL; - int ret; - struct sockaddr_in sin = { - .sin_family = PF_INET, - .sin_addr = { .s_addr = addr }, - .sin_port = port, - }; - - ret = sock_create(PF_INET, SOCK_STREAM, IPPROTO_TCP, &sock); - if (ret < 0) { - pr_err("ramster: Error %d while creating socket\n", ret); - goto out; - } - - sock->sk->sk_allocation = GFP_ATOMIC; - - write_lock_bh(&sock->sk->sk_callback_lock); - sock->sk->sk_user_data = sock->sk->sk_data_ready; - sock->sk->sk_data_ready = r2net_listen_data_ready; - write_unlock_bh(&sock->sk->sk_callback_lock); - - r2net_listen_sock = sock; - INIT_WORK(&r2net_listen_work, r2net_accept_many); - - sock->sk->sk_reuse = /* SK_CAN_REUSE FIXME FOR 3.4 */ 1; - ret = sock->ops->bind(sock, (struct sockaddr *)&sin, sizeof(sin)); - if (ret < 0) { - pr_err("ramster: Error %d while binding socket at %pI4:%u\n", - ret, &addr, ntohs(port)); - goto out; - } - - ret = sock->ops->listen(sock, 64); - if (ret < 0) - pr_err("ramster: Error %d while listening on %pI4:%u\n", - ret, &addr, ntohs(port)); - -out: - if (ret) { - r2net_listen_sock = NULL; - if (sock) - sock_release(sock); - } - return ret; -} - -/* - * called from node manager when we should bring up our network listening - * socket. node manager handles all the serialization to only call this - * once and to match it with r2net_stop_listening(). note, - * r2nm_this_node() doesn't work yet as we're being called while it - * is being set up. - */ -int r2net_start_listening(struct r2nm_node *node) -{ - int ret = 0; - - BUG_ON(r2net_wq != NULL); - BUG_ON(r2net_listen_sock != NULL); - - mlog(ML_KTHREAD, "starting r2net thread...\n"); - r2net_wq = create_singlethread_workqueue("r2net"); - if (r2net_wq == NULL) { - mlog(ML_ERROR, "unable to launch r2net thread\n"); - return -ENOMEM; /* ? */ - } - - ret = r2net_open_listening_sock(node->nd_ipv4_address, - node->nd_ipv4_port); - if (ret) { - destroy_workqueue(r2net_wq); - r2net_wq = NULL; - } - - return ret; -} - -/* again, r2nm_this_node() doesn't work here as we're involved in - * tearing it down */ -void r2net_stop_listening(struct r2nm_node *node) -{ - struct socket *sock = r2net_listen_sock; - size_t i; - - BUG_ON(r2net_wq == NULL); - BUG_ON(r2net_listen_sock == NULL); - - /* stop the listening socket from generating work */ - write_lock_bh(&sock->sk->sk_callback_lock); - sock->sk->sk_data_ready = sock->sk->sk_user_data; - sock->sk->sk_user_data = NULL; - write_unlock_bh(&sock->sk->sk_callback_lock); - - for (i = 0; i < ARRAY_SIZE(r2net_nodes); i++) { - struct r2nm_node *node = r2nm_get_node_by_num(i); - if (node) { - r2net_disconnect_node(node); - r2nm_node_put(node); - } - } - - /* finish all work and tear down the work queue */ - mlog(ML_KTHREAD, "waiting for r2net thread to exit....\n"); - destroy_workqueue(r2net_wq); - r2net_wq = NULL; - - sock_release(r2net_listen_sock); - r2net_listen_sock = NULL; -} - -void r2net_hb_node_up_manual(int node_num) -{ - struct r2nm_node dummy; - if (r2nm_single_cluster == NULL) - pr_err("ramster: cluster not alive, node_up_manual ignored\n"); - else { - r2hb_manual_set_node_heartbeating(node_num); - r2net_hb_node_up_cb(&dummy, node_num, NULL); - } -} - -/* ------------------------------------------------------------ */ - -int r2net_init(void) -{ - unsigned long i; - - if (r2net_debugfs_init()) - return -ENOMEM; - - r2net_hand = kzalloc(sizeof(struct r2net_handshake), GFP_KERNEL); - r2net_keep_req = kzalloc(sizeof(struct r2net_msg), GFP_KERNEL); - r2net_keep_resp = kzalloc(sizeof(struct r2net_msg), GFP_KERNEL); - if (!r2net_hand || !r2net_keep_req || !r2net_keep_resp) { - kfree(r2net_hand); - kfree(r2net_keep_req); - kfree(r2net_keep_resp); - return -ENOMEM; - } - - r2net_hand->protocol_version = cpu_to_be64(R2NET_PROTOCOL_VERSION); - r2net_hand->connector_id = cpu_to_be64(1); - - r2net_keep_req->magic = cpu_to_be16(R2NET_MSG_KEEP_REQ_MAGIC); - r2net_keep_resp->magic = cpu_to_be16(R2NET_MSG_KEEP_RESP_MAGIC); - - for (i = 0; i < ARRAY_SIZE(r2net_nodes); i++) { - struct r2net_node *nn = r2net_nn_from_num(i); - - atomic_set(&nn->nn_timeout, 0); - spin_lock_init(&nn->nn_lock); - INIT_DELAYED_WORK(&nn->nn_connect_work, r2net_start_connect); - INIT_DELAYED_WORK(&nn->nn_connect_expired, - r2net_connect_expired); - INIT_DELAYED_WORK(&nn->nn_still_up, r2net_still_up); - /* until we see hb from a node we'll return einval */ - nn->nn_persistent_error = -ENOTCONN; - init_waitqueue_head(&nn->nn_sc_wq); - idr_init(&nn->nn_status_idr); - INIT_LIST_HEAD(&nn->nn_status_list); - } - - return 0; -} - -void r2net_exit(void) -{ - kfree(r2net_hand); - kfree(r2net_keep_req); - kfree(r2net_keep_resp); - r2net_debugfs_exit(); -} diff --git a/drivers/staging/zcache/ramster/tcp.h b/drivers/staging/zcache/ramster/tcp.h deleted file mode 100644 index 9d05833452b59..0000000000000 --- a/drivers/staging/zcache/ramster/tcp.h +++ /dev/null @@ -1,159 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; -*- - * vim: noexpandtab sw=8 ts=8 sts=0: - * - * tcp.h - * - * Function prototypes - * - * Copyright (C) 2004 Oracle. All rights reserved. - * - * 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 the License, or (at your option) any later version. - * - * 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. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 021110-1307, USA. - * - */ - -#ifndef R2CLUSTER_TCP_H -#define R2CLUSTER_TCP_H - -#include -#ifdef __KERNEL__ -#include -#include -#else -#include -#endif -#include -#include - -struct r2net_msg { - __be16 magic; - __be16 data_len; - __be16 msg_type; - __be16 pad1; - __be32 sys_status; - __be32 status; - __be32 key; - __be32 msg_num; - __u8 buf[0]; -}; - -typedef int (r2net_msg_handler_func)(struct r2net_msg *msg, u32 len, void *data, - void **ret_data); -typedef void (r2net_post_msg_handler_func)(int status, void *data, - void *ret_data); - -#define R2NET_MAX_PAYLOAD_BYTES (4096 - sizeof(struct r2net_msg)) - -/* same as hb delay, we're waiting for another node to recognize our hb */ -#define R2NET_RECONNECT_DELAY_MS_DEFAULT 2000 - -#define R2NET_KEEPALIVE_DELAY_MS_DEFAULT 2000 -#define R2NET_IDLE_TIMEOUT_MS_DEFAULT 30000 - - -/* TODO: figure this out.... */ -static inline int r2net_link_down(int err, struct socket *sock) -{ - if (sock) { - if (sock->sk->sk_state != TCP_ESTABLISHED && - sock->sk->sk_state != TCP_CLOSE_WAIT) - return 1; - } - - if (err >= 0) - return 0; - switch (err) { - - /* ????????????????????????? */ - case -ERESTARTSYS: - case -EBADF: - /* When the server has died, an ICMP port unreachable - * message prompts ECONNREFUSED. */ - case -ECONNREFUSED: - case -ENOTCONN: - case -ECONNRESET: - case -EPIPE: - return 1; - - } - return 0; -} - -enum { - R2NET_DRIVER_UNINITED, - R2NET_DRIVER_READY, -}; - -int r2net_send_message(u32 msg_type, u32 key, void *data, u32 len, - u8 target_node, int *status); -int r2net_send_message_vec(u32 msg_type, u32 key, struct kvec *vec, - size_t veclen, u8 target_node, int *status); - -int r2net_register_handler(u32 msg_type, u32 key, u32 max_len, - r2net_msg_handler_func *func, void *data, - r2net_post_msg_handler_func *post_func, - struct list_head *unreg_list); -void r2net_unregister_handler_list(struct list_head *list); - -void r2net_fill_node_map(unsigned long *map, unsigned bytes); - -void r2net_force_data_magic(struct r2net_msg *, u16, u32); -void r2net_hb_node_up_manual(int); -struct r2net_node *r2net_nn_from_num(u8); - -struct r2nm_node; -int r2net_register_hb_callbacks(void); -void r2net_unregister_hb_callbacks(void); -int r2net_start_listening(struct r2nm_node *node); -void r2net_stop_listening(struct r2nm_node *node); -void r2net_disconnect_node(struct r2nm_node *node); -int r2net_num_connected_peers(void); - -int r2net_init(void); -void r2net_exit(void); - -struct r2net_send_tracking; -struct r2net_sock_container; - -#if 0 -int r2net_debugfs_init(void); -void r2net_debugfs_exit(void); -void r2net_debug_add_nst(struct r2net_send_tracking *nst); -void r2net_debug_del_nst(struct r2net_send_tracking *nst); -void r2net_debug_add_sc(struct r2net_sock_container *sc); -void r2net_debug_del_sc(struct r2net_sock_container *sc); -#else -static inline int r2net_debugfs_init(void) -{ - return 0; -} -static inline void r2net_debugfs_exit(void) -{ -} -static inline void r2net_debug_add_nst(struct r2net_send_tracking *nst) -{ -} -static inline void r2net_debug_del_nst(struct r2net_send_tracking *nst) -{ -} -static inline void r2net_debug_add_sc(struct r2net_sock_container *sc) -{ -} -static inline void r2net_debug_del_sc(struct r2net_sock_container *sc) -{ -} -#endif /* CONFIG_DEBUG_FS */ - -#endif /* R2CLUSTER_TCP_H */ diff --git a/drivers/staging/zcache/ramster/tcp_internal.h b/drivers/staging/zcache/ramster/tcp_internal.h deleted file mode 100644 index 4d8cc9f96fd28..0000000000000 --- a/drivers/staging/zcache/ramster/tcp_internal.h +++ /dev/null @@ -1,248 +0,0 @@ -/* -*- mode: c; c-basic-offset: 8; -*- - * vim: noexpandtab sw=8 ts=8 sts=0: - * - * Copyright (C) 2005 Oracle. All rights reserved. - * - * 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 the License, or (at your option) any later version. - * - * 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. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 021110-1307, USA. - */ - -#ifndef R2CLUSTER_TCP_INTERNAL_H -#define R2CLUSTER_TCP_INTERNAL_H - -#define R2NET_MSG_MAGIC ((u16)0xfa55) -#define R2NET_MSG_STATUS_MAGIC ((u16)0xfa56) -#define R2NET_MSG_KEEP_REQ_MAGIC ((u16)0xfa57) -#define R2NET_MSG_KEEP_RESP_MAGIC ((u16)0xfa58) -/* - * "data magic" is a long version of "status magic" where the message - * payload actually contains data to be passed in reply to certain messages - */ -#define R2NET_MSG_DATA_MAGIC ((u16)0xfa59) - -/* we're delaying our quorum decision so that heartbeat will have timed - * out truly dead nodes by the time we come around to making decisions - * on their number */ -#define R2NET_QUORUM_DELAY_MS \ - ((r2hb_dead_threshold + 2) * R2HB_REGION_TIMEOUT_MS) - -/* - * This version number represents quite a lot, unfortunately. It not - * only represents the raw network message protocol on the wire but also - * locking semantics of the file system using the protocol. It should - * be somewhere else, I'm sure, but right now it isn't. - * - * With version 11, we separate out the filesystem locking portion. The - * filesystem now has a major.minor version it negotiates. Version 11 - * introduces this negotiation to the r2dlm protocol, and as such the - * version here in tcp_internal.h should not need to be bumped for - * filesystem locking changes. - * - * New in version 11 - * - Negotiation of filesystem locking in the dlm join. - * - * New in version 10: - * - Meta/data locks combined - * - * New in version 9: - * - All votes removed - * - * New in version 8: - * - Replace delete inode votes with a cluster lock - * - * New in version 7: - * - DLM join domain includes the live nodemap - * - * New in version 6: - * - DLM lockres remote refcount fixes. - * - * New in version 5: - * - Network timeout checking protocol - * - * New in version 4: - * - Remove i_generation from lock names for better stat performance. - * - * New in version 3: - * - Replace dentry votes with a cluster lock - * - * New in version 2: - * - full 64 bit i_size in the metadata lock lvbs - * - introduction of "rw" lock and pushing meta/data locking down - */ -#define R2NET_PROTOCOL_VERSION 11ULL -struct r2net_handshake { - __be64 protocol_version; - __be64 connector_id; - __be32 r2hb_heartbeat_timeout_ms; - __be32 r2net_idle_timeout_ms; - __be32 r2net_keepalive_delay_ms; - __be32 r2net_reconnect_delay_ms; -}; - -struct r2net_node { - /* this is never called from int/bh */ - spinlock_t nn_lock; - - /* set the moment an sc is allocated and a connect is started */ - struct r2net_sock_container *nn_sc; - /* _valid is only set after the handshake passes and tx can happen */ - unsigned nn_sc_valid:1; - /* if this is set tx just returns it */ - int nn_persistent_error; - /* It is only set to 1 after the idle time out. */ - atomic_t nn_timeout; - - /* threads waiting for an sc to arrive wait on the wq for generation - * to increase. it is increased when a connecting socket succeeds - * or fails or when an accepted socket is attached. */ - wait_queue_head_t nn_sc_wq; - - struct idr nn_status_idr; - struct list_head nn_status_list; - - /* connects are attempted from when heartbeat comes up until either hb - * goes down, the node is unconfigured, no connect attempts succeed - * before R2NET_CONN_IDLE_DELAY, or a connect succeeds. connect_work - * is queued from set_nn_state both from hb up and from itself if a - * connect attempt fails and so can be self-arming. shutdown is - * careful to first mark the nn such that no connects will be attempted - * before canceling delayed connect work and flushing the queue. */ - struct delayed_work nn_connect_work; - unsigned long nn_last_connect_attempt; - - /* this is queued as nodes come up and is canceled when a connection is - * established. this expiring gives up on the node and errors out - * transmits */ - struct delayed_work nn_connect_expired; - - /* after we give up on a socket we wait a while before deciding - * that it is still heartbeating and that we should do some - * quorum work */ - struct delayed_work nn_still_up; -}; - -struct r2net_sock_container { - struct kref sc_kref; - /* the next two are valid for the life time of the sc */ - struct socket *sc_sock; - struct r2nm_node *sc_node; - - /* all of these sc work structs hold refs on the sc while they are - * queued. they should not be able to ref a freed sc. the teardown - * race is with r2net_wq destruction in r2net_stop_listening() */ - - /* rx and connect work are generated from socket callbacks. sc - * shutdown removes the callbacks and then flushes the work queue */ - struct work_struct sc_rx_work; - struct work_struct sc_connect_work; - /* shutdown work is triggered in two ways. the simple way is - * for a code path calls ensure_shutdown which gets a lock, removes - * the sc from the nn, and queues the work. in this case the - * work is single-shot. the work is also queued from a sock - * callback, though, and in this case the work will find the sc - * still on the nn and will call ensure_shutdown itself.. this - * ends up triggering the shutdown work again, though nothing - * will be done in that second iteration. so work queue teardown - * has to be careful to remove the sc from the nn before waiting - * on the work queue so that the shutdown work doesn't remove the - * sc and rearm itself. - */ - struct work_struct sc_shutdown_work; - - struct timer_list sc_idle_timeout; - struct delayed_work sc_keepalive_work; - - unsigned sc_handshake_ok:1; - - struct page *sc_page; - size_t sc_page_off; - - /* original handlers for the sockets */ - void (*sc_state_change)(struct sock *sk); - void (*sc_data_ready)(struct sock *sk, int bytes); - - u32 sc_msg_key; - u16 sc_msg_type; - -#ifdef CONFIG_DEBUG_FS - struct list_head sc_net_debug_item; - ktime_t sc_tv_timer; - ktime_t sc_tv_data_ready; - ktime_t sc_tv_advance_start; - ktime_t sc_tv_advance_stop; - ktime_t sc_tv_func_start; - ktime_t sc_tv_func_stop; -#endif -#ifdef CONFIG_RAMSTER_FS_STATS - ktime_t sc_tv_acquiry_total; - ktime_t sc_tv_send_total; - ktime_t sc_tv_status_total; - u32 sc_send_count; - u32 sc_recv_count; - ktime_t sc_tv_process_total; -#endif - struct mutex sc_send_lock; -}; - -struct r2net_msg_handler { - struct rb_node nh_node; - u32 nh_max_len; - u32 nh_msg_type; - u32 nh_key; - r2net_msg_handler_func *nh_func; - r2net_msg_handler_func *nh_func_data; - r2net_post_msg_handler_func - *nh_post_func; - struct kref nh_kref; - struct list_head nh_unregister_item; -}; - -enum r2net_system_error { - R2NET_ERR_NONE = 0, - R2NET_ERR_NO_HNDLR, - R2NET_ERR_OVERFLOW, - R2NET_ERR_DIED, - R2NET_ERR_MAX -}; - -struct r2net_status_wait { - enum r2net_system_error ns_sys_status; - s32 ns_status; - int ns_id; - wait_queue_head_t ns_wq; - struct list_head ns_node_item; -}; - -#ifdef CONFIG_DEBUG_FS -/* just for state dumps */ -struct r2net_send_tracking { - struct list_head st_net_debug_item; - struct task_struct *st_task; - struct r2net_sock_container *st_sc; - u32 st_id; - u32 st_msg_type; - u32 st_msg_key; - u8 st_node; - ktime_t st_sock_time; - ktime_t st_send_time; - ktime_t st_status_time; -}; -#else -struct r2net_send_tracking { - u32 dummy; -}; -#endif /* CONFIG_DEBUG_FS */ - -#endif /* R2CLUSTER_TCP_INTERNAL_H */ diff --git a/drivers/staging/zcache/tmem.c b/drivers/staging/zcache/tmem.c deleted file mode 100644 index d7e51e4152ebe..0000000000000 --- a/drivers/staging/zcache/tmem.c +++ /dev/null @@ -1,898 +0,0 @@ -/* - * In-kernel transcendent memory (generic implementation) - * - * Copyright (c) 2009-2012, Dan Magenheimer, Oracle Corp. - * - * The primary purpose of Transcedent Memory ("tmem") is to map object-oriented - * "handles" (triples containing a pool id, and object id, and an index), to - * pages in a page-accessible memory (PAM). Tmem references the PAM pages via - * an abstract "pampd" (PAM page-descriptor), which can be operated on by a - * set of functions (pamops). Each pampd contains some representation of - * PAGE_SIZE bytes worth of data. For those familiar with key-value stores, - * the tmem handle is a three-level hierarchical key, and the value is always - * reconstituted (but not necessarily stored) as PAGE_SIZE bytes and is - * referenced in the datastore by the pampd. The hierarchy is required - * to ensure that certain invalidation functions can be performed efficiently - * (i.e. flush all indexes associated with this object_id, or - * flush all objects associated with this pool). - * - * Tmem must support potentially millions of pages and must be able to insert, - * find, and delete these pages at a potential frequency of thousands per - * second concurrently across many CPUs, (and, if used with KVM, across many - * vcpus across many guests). Tmem is tracked with a hierarchy of data - * structures, organized by the elements in the handle-tuple: pool_id, - * object_id, and page index. One or more "clients" (e.g. guests) each - * provide one or more tmem_pools. Each pool, contains a hash table of - * rb_trees of tmem_objs. Each tmem_obj contains a radix-tree-like tree - * of pointers, with intermediate nodes called tmem_objnodes. Each leaf - * pointer in this tree points to a pampd, which is accessible only through - * a small set of callbacks registered by the PAM implementation (see - * tmem_register_pamops). Tmem only needs to memory allocation for objs - * and objnodes and this is done via a set of callbacks that must be - * registered by the tmem host implementation (e.g. see tmem_register_hostops). - */ - -#include -#include -#include -#include -#if defined(CONFIG_RAMSTER) || defined(CONFIG_RAMSTER_MODULE) -#include -#endif - -#include "tmem.h" - -/* data structure sentinels used for debugging... see tmem.h */ -#define POOL_SENTINEL 0x87658765 -#define OBJ_SENTINEL 0x12345678 -#define OBJNODE_SENTINEL 0xfedcba09 - -/* - * A tmem host implementation must use this function to register callbacks - * for memory allocation. - */ -static struct tmem_hostops tmem_hostops; - -static void tmem_objnode_tree_init(void); - -void tmem_register_hostops(struct tmem_hostops *m) -{ - tmem_objnode_tree_init(); - tmem_hostops = *m; -} - -/* - * A tmem host implementation must use this function to register - * callbacks for a page-accessible memory (PAM) implementation. - */ -static struct tmem_pamops tmem_pamops; - -void tmem_register_pamops(struct tmem_pamops *m) -{ - tmem_pamops = *m; -} - -/* - * Oid's are potentially very sparse and tmem_objs may have an indeterminately - * short life, being added and deleted at a relatively high frequency. - * So an rb_tree is an ideal data structure to manage tmem_objs. But because - * of the potentially huge number of tmem_objs, each pool manages a hashtable - * of rb_trees to reduce search, insert, delete, and rebalancing time. - * Each hashbucket also has a lock to manage concurrent access and no - * searches, inserts, or deletions can be performed unless the lock is held. - * As a result, care must be taken to ensure tmem routines are not called - * recursively; the vast majority of the time, a recursive call may work - * but a deadlock will occur a small fraction of the time due to the - * hashbucket lock. - * - * The following routines manage tmem_objs. In all of these routines, - * the hashbucket lock is already held. - */ - -/* Search for object==oid in pool, returns object if found. */ -static struct tmem_obj *__tmem_obj_find(struct tmem_hashbucket *hb, - struct tmem_oid *oidp, - struct rb_node **parent, - struct rb_node ***link) -{ - struct rb_node *_parent = NULL, **rbnode; - struct tmem_obj *obj = NULL; - - rbnode = &hb->obj_rb_root.rb_node; - while (*rbnode) { - BUG_ON(RB_EMPTY_NODE(*rbnode)); - _parent = *rbnode; - obj = rb_entry(*rbnode, struct tmem_obj, - rb_tree_node); - switch (tmem_oid_compare(oidp, &obj->oid)) { - case 0: /* equal */ - goto out; - case -1: - rbnode = &(*rbnode)->rb_left; - break; - case 1: - rbnode = &(*rbnode)->rb_right; - break; - } - } - - if (parent) - *parent = _parent; - if (link) - *link = rbnode; - obj = NULL; -out: - return obj; -} - -static struct tmem_obj *tmem_obj_find(struct tmem_hashbucket *hb, - struct tmem_oid *oidp) -{ - return __tmem_obj_find(hb, oidp, NULL, NULL); -} - -static void tmem_pampd_destroy_all_in_obj(struct tmem_obj *, bool); - -/* Free an object that has no more pampds in it. */ -static void tmem_obj_free(struct tmem_obj *obj, struct tmem_hashbucket *hb) -{ - struct tmem_pool *pool; - - BUG_ON(obj == NULL); - ASSERT_SENTINEL(obj, OBJ); - BUG_ON(obj->pampd_count > 0); - pool = obj->pool; - BUG_ON(pool == NULL); - if (obj->objnode_tree_root != NULL) /* may be "stump" with no leaves */ - tmem_pampd_destroy_all_in_obj(obj, false); - BUG_ON(obj->objnode_tree_root != NULL); - BUG_ON((long)obj->objnode_count != 0); - atomic_dec(&pool->obj_count); - BUG_ON(atomic_read(&pool->obj_count) < 0); - INVERT_SENTINEL(obj, OBJ); - obj->pool = NULL; - tmem_oid_set_invalid(&obj->oid); - rb_erase(&obj->rb_tree_node, &hb->obj_rb_root); -} - -/* - * Initialize, and insert an tmem_object_root (called only if find failed). - */ -static void tmem_obj_init(struct tmem_obj *obj, struct tmem_hashbucket *hb, - struct tmem_pool *pool, - struct tmem_oid *oidp) -{ - struct rb_root *root = &hb->obj_rb_root; - struct rb_node **new = NULL, *parent = NULL; - - BUG_ON(pool == NULL); - atomic_inc(&pool->obj_count); - obj->objnode_tree_height = 0; - obj->objnode_tree_root = NULL; - obj->pool = pool; - obj->oid = *oidp; - obj->objnode_count = 0; - obj->pampd_count = 0; -#ifdef CONFIG_RAMSTER - if (tmem_pamops.new_obj != NULL) - (*tmem_pamops.new_obj)(obj); -#endif - SET_SENTINEL(obj, OBJ); - - if (__tmem_obj_find(hb, oidp, &parent, &new)) - BUG(); - - rb_link_node(&obj->rb_tree_node, parent, new); - rb_insert_color(&obj->rb_tree_node, root); -} - -/* - * Tmem is managed as a set of tmem_pools with certain attributes, such as - * "ephemeral" vs "persistent". These attributes apply to all tmem_objs - * and all pampds that belong to a tmem_pool. A tmem_pool is created - * or deleted relatively rarely (for example, when a filesystem is - * mounted or unmounted). - */ - -/* flush all data from a pool and, optionally, free it */ -static void tmem_pool_flush(struct tmem_pool *pool, bool destroy) -{ - struct rb_node *rbnode; - struct tmem_obj *obj; - struct tmem_hashbucket *hb = &pool->hashbucket[0]; - int i; - - BUG_ON(pool == NULL); - for (i = 0; i < TMEM_HASH_BUCKETS; i++, hb++) { - spin_lock(&hb->lock); - rbnode = rb_first(&hb->obj_rb_root); - while (rbnode != NULL) { - obj = rb_entry(rbnode, struct tmem_obj, rb_tree_node); - rbnode = rb_next(rbnode); - tmem_pampd_destroy_all_in_obj(obj, true); - tmem_obj_free(obj, hb); - (*tmem_hostops.obj_free)(obj, pool); - } - spin_unlock(&hb->lock); - } - if (destroy) - list_del(&pool->pool_list); -} - -/* - * A tmem_obj contains a radix-tree-like tree in which the intermediate - * nodes are called tmem_objnodes. (The kernel lib/radix-tree.c implementation - * is very specialized and tuned for specific uses and is not particularly - * suited for use from this code, though some code from the core algorithms has - * been reused, thus the copyright notices below). Each tmem_objnode contains - * a set of pointers which point to either a set of intermediate tmem_objnodes - * or a set of of pampds. - * - * Portions Copyright (C) 2001 Momchil Velikov - * Portions Copyright (C) 2001 Christoph Hellwig - * Portions Copyright (C) 2005 SGI, Christoph Lameter - */ - -struct tmem_objnode_tree_path { - struct tmem_objnode *objnode; - int offset; -}; - -/* objnode height_to_maxindex translation */ -static unsigned long tmem_objnode_tree_h2max[OBJNODE_TREE_MAX_PATH + 1]; - -static void tmem_objnode_tree_init(void) -{ - unsigned int ht, tmp; - - for (ht = 0; ht < ARRAY_SIZE(tmem_objnode_tree_h2max); ht++) { - tmp = ht * OBJNODE_TREE_MAP_SHIFT; - if (tmp >= OBJNODE_TREE_INDEX_BITS) - tmem_objnode_tree_h2max[ht] = ~0UL; - else - tmem_objnode_tree_h2max[ht] = - (~0UL >> (OBJNODE_TREE_INDEX_BITS - tmp - 1)) >> 1; - } -} - -static struct tmem_objnode *tmem_objnode_alloc(struct tmem_obj *obj) -{ - struct tmem_objnode *objnode; - - ASSERT_SENTINEL(obj, OBJ); - BUG_ON(obj->pool == NULL); - ASSERT_SENTINEL(obj->pool, POOL); - objnode = (*tmem_hostops.objnode_alloc)(obj->pool); - if (unlikely(objnode == NULL)) - goto out; - objnode->obj = obj; - SET_SENTINEL(objnode, OBJNODE); - memset(&objnode->slots, 0, sizeof(objnode->slots)); - objnode->slots_in_use = 0; - obj->objnode_count++; -out: - return objnode; -} - -static void tmem_objnode_free(struct tmem_objnode *objnode) -{ - struct tmem_pool *pool; - int i; - - BUG_ON(objnode == NULL); - for (i = 0; i < OBJNODE_TREE_MAP_SIZE; i++) - BUG_ON(objnode->slots[i] != NULL); - ASSERT_SENTINEL(objnode, OBJNODE); - INVERT_SENTINEL(objnode, OBJNODE); - BUG_ON(objnode->obj == NULL); - ASSERT_SENTINEL(objnode->obj, OBJ); - pool = objnode->obj->pool; - BUG_ON(pool == NULL); - ASSERT_SENTINEL(pool, POOL); - objnode->obj->objnode_count--; - objnode->obj = NULL; - (*tmem_hostops.objnode_free)(objnode, pool); -} - -/* - * Lookup index in object and return associated pampd (or NULL if not found). - */ -static void **__tmem_pampd_lookup_in_obj(struct tmem_obj *obj, uint32_t index) -{ - unsigned int height, shift; - struct tmem_objnode **slot = NULL; - - BUG_ON(obj == NULL); - ASSERT_SENTINEL(obj, OBJ); - BUG_ON(obj->pool == NULL); - ASSERT_SENTINEL(obj->pool, POOL); - - height = obj->objnode_tree_height; - if (index > tmem_objnode_tree_h2max[obj->objnode_tree_height]) - goto out; - if (height == 0 && obj->objnode_tree_root) { - slot = &obj->objnode_tree_root; - goto out; - } - shift = (height-1) * OBJNODE_TREE_MAP_SHIFT; - slot = &obj->objnode_tree_root; - while (height > 0) { - if (*slot == NULL) - goto out; - slot = (struct tmem_objnode **) - ((*slot)->slots + - ((index >> shift) & OBJNODE_TREE_MAP_MASK)); - shift -= OBJNODE_TREE_MAP_SHIFT; - height--; - } -out: - return slot != NULL ? (void **)slot : NULL; -} - -static void *tmem_pampd_lookup_in_obj(struct tmem_obj *obj, uint32_t index) -{ - struct tmem_objnode **slot; - - slot = (struct tmem_objnode **)__tmem_pampd_lookup_in_obj(obj, index); - return slot != NULL ? *slot : NULL; -} - -#ifdef CONFIG_RAMSTER -static void *tmem_pampd_replace_in_obj(struct tmem_obj *obj, uint32_t index, - void *new_pampd, bool no_free) -{ - struct tmem_objnode **slot; - void *ret = NULL; - - slot = (struct tmem_objnode **)__tmem_pampd_lookup_in_obj(obj, index); - if ((slot != NULL) && (*slot != NULL)) { - void *old_pampd = *(void **)slot; - *(void **)slot = new_pampd; - if (!no_free) - (*tmem_pamops.free)(old_pampd, obj->pool, - NULL, 0, false); - ret = new_pampd; - } - return ret; -} -#endif - -static int tmem_pampd_add_to_obj(struct tmem_obj *obj, uint32_t index, - void *pampd) -{ - int ret = 0; - struct tmem_objnode *objnode = NULL, *newnode, *slot; - unsigned int height, shift; - int offset = 0; - - /* if necessary, extend the tree to be higher */ - if (index > tmem_objnode_tree_h2max[obj->objnode_tree_height]) { - height = obj->objnode_tree_height + 1; - if (index > tmem_objnode_tree_h2max[height]) - while (index > tmem_objnode_tree_h2max[height]) - height++; - if (obj->objnode_tree_root == NULL) { - obj->objnode_tree_height = height; - goto insert; - } - do { - newnode = tmem_objnode_alloc(obj); - if (!newnode) { - ret = -ENOMEM; - goto out; - } - newnode->slots[0] = obj->objnode_tree_root; - newnode->slots_in_use = 1; - obj->objnode_tree_root = newnode; - obj->objnode_tree_height++; - } while (height > obj->objnode_tree_height); - } -insert: - slot = obj->objnode_tree_root; - height = obj->objnode_tree_height; - shift = (height-1) * OBJNODE_TREE_MAP_SHIFT; - while (height > 0) { - if (slot == NULL) { - /* add a child objnode. */ - slot = tmem_objnode_alloc(obj); - if (!slot) { - ret = -ENOMEM; - goto out; - } - if (objnode) { - - objnode->slots[offset] = slot; - objnode->slots_in_use++; - } else - obj->objnode_tree_root = slot; - } - /* go down a level */ - offset = (index >> shift) & OBJNODE_TREE_MAP_MASK; - objnode = slot; - slot = objnode->slots[offset]; - shift -= OBJNODE_TREE_MAP_SHIFT; - height--; - } - BUG_ON(slot != NULL); - if (objnode) { - objnode->slots_in_use++; - objnode->slots[offset] = pampd; - } else - obj->objnode_tree_root = pampd; - obj->pampd_count++; -out: - return ret; -} - -static void *tmem_pampd_delete_from_obj(struct tmem_obj *obj, uint32_t index) -{ - struct tmem_objnode_tree_path path[OBJNODE_TREE_MAX_PATH + 1]; - struct tmem_objnode_tree_path *pathp = path; - struct tmem_objnode *slot = NULL; - unsigned int height, shift; - int offset; - - BUG_ON(obj == NULL); - ASSERT_SENTINEL(obj, OBJ); - BUG_ON(obj->pool == NULL); - ASSERT_SENTINEL(obj->pool, POOL); - height = obj->objnode_tree_height; - if (index > tmem_objnode_tree_h2max[height]) - goto out; - slot = obj->objnode_tree_root; - if (height == 0 && obj->objnode_tree_root) { - obj->objnode_tree_root = NULL; - goto out; - } - shift = (height - 1) * OBJNODE_TREE_MAP_SHIFT; - pathp->objnode = NULL; - do { - if (slot == NULL) - goto out; - pathp++; - offset = (index >> shift) & OBJNODE_TREE_MAP_MASK; - pathp->offset = offset; - pathp->objnode = slot; - slot = slot->slots[offset]; - shift -= OBJNODE_TREE_MAP_SHIFT; - height--; - } while (height > 0); - if (slot == NULL) - goto out; - while (pathp->objnode) { - pathp->objnode->slots[pathp->offset] = NULL; - pathp->objnode->slots_in_use--; - if (pathp->objnode->slots_in_use) { - if (pathp->objnode == obj->objnode_tree_root) { - while (obj->objnode_tree_height > 0 && - obj->objnode_tree_root->slots_in_use == 1 && - obj->objnode_tree_root->slots[0]) { - struct tmem_objnode *to_free = - obj->objnode_tree_root; - - obj->objnode_tree_root = - to_free->slots[0]; - obj->objnode_tree_height--; - to_free->slots[0] = NULL; - to_free->slots_in_use = 0; - tmem_objnode_free(to_free); - } - } - goto out; - } - tmem_objnode_free(pathp->objnode); /* 0 slots used, free it */ - pathp--; - } - obj->objnode_tree_height = 0; - obj->objnode_tree_root = NULL; - -out: - if (slot != NULL) - obj->pampd_count--; - BUG_ON(obj->pampd_count < 0); - return slot; -} - -/* Recursively walk the objnode_tree destroying pampds and objnodes. */ -static void tmem_objnode_node_destroy(struct tmem_obj *obj, - struct tmem_objnode *objnode, - unsigned int ht) -{ - int i; - - if (ht == 0) - return; - for (i = 0; i < OBJNODE_TREE_MAP_SIZE; i++) { - if (objnode->slots[i]) { - if (ht == 1) { - obj->pampd_count--; - (*tmem_pamops.free)(objnode->slots[i], - obj->pool, NULL, 0, true); - objnode->slots[i] = NULL; - continue; - } - tmem_objnode_node_destroy(obj, objnode->slots[i], ht-1); - tmem_objnode_free(objnode->slots[i]); - objnode->slots[i] = NULL; - } - } -} - -static void tmem_pampd_destroy_all_in_obj(struct tmem_obj *obj, - bool pool_destroy) -{ - if (obj->objnode_tree_root == NULL) - return; - if (obj->objnode_tree_height == 0) { - obj->pampd_count--; - (*tmem_pamops.free)(obj->objnode_tree_root, - obj->pool, NULL, 0, true); - } else { - tmem_objnode_node_destroy(obj, obj->objnode_tree_root, - obj->objnode_tree_height); - tmem_objnode_free(obj->objnode_tree_root); - obj->objnode_tree_height = 0; - } - obj->objnode_tree_root = NULL; -#ifdef CONFIG_RAMSTER - if (tmem_pamops.free_obj != NULL) - (*tmem_pamops.free_obj)(obj->pool, obj, pool_destroy); -#endif -} - -/* - * Tmem is operated on by a set of well-defined actions: - * "put", "get", "flush", "flush_object", "new pool" and "destroy pool". - * (The tmem ABI allows for subpages and exchanges but these operations - * are not included in this implementation.) - * - * These "tmem core" operations are implemented in the following functions. - */ - -/* - * "Put" a page, e.g. associate the passed pampd with the passed handle. - * Tmem_put is complicated by a corner case: What if a page with matching - * handle already exists in tmem? To guarantee coherency, one of two - * actions is necessary: Either the data for the page must be overwritten, - * or the page must be "flushed" so that the data is not accessible to a - * subsequent "get". Since these "duplicate puts" are relatively rare, - * this implementation always flushes for simplicity. - */ -int tmem_put(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index, - bool raw, void *pampd_to_use) -{ - struct tmem_obj *obj = NULL, *objfound = NULL, *objnew = NULL; - void *pampd = NULL, *pampd_del = NULL; - int ret = -ENOMEM; - struct tmem_hashbucket *hb; - - hb = &pool->hashbucket[tmem_oid_hash(oidp)]; - spin_lock(&hb->lock); - obj = objfound = tmem_obj_find(hb, oidp); - if (obj != NULL) { - pampd = tmem_pampd_lookup_in_obj(objfound, index); - if (pampd != NULL) { - /* if found, is a dup put, flush the old one */ - pampd_del = tmem_pampd_delete_from_obj(obj, index); - BUG_ON(pampd_del != pampd); - (*tmem_pamops.free)(pampd, pool, oidp, index, true); - if (obj->pampd_count == 0) { - objnew = obj; - objfound = NULL; - } - pampd = NULL; - } - } else { - obj = objnew = (*tmem_hostops.obj_alloc)(pool); - if (unlikely(obj == NULL)) { - ret = -ENOMEM; - goto out; - } - tmem_obj_init(obj, hb, pool, oidp); - } - BUG_ON(obj == NULL); - BUG_ON(((objnew != obj) && (objfound != obj)) || (objnew == objfound)); - pampd = pampd_to_use; - BUG_ON(pampd_to_use == NULL); - ret = tmem_pampd_add_to_obj(obj, index, pampd); - if (unlikely(ret == -ENOMEM)) - /* may have partially built objnode tree ("stump") */ - goto delete_and_free; - (*tmem_pamops.create_finish)(pampd, is_ephemeral(pool)); - goto out; - -delete_and_free: - (void)tmem_pampd_delete_from_obj(obj, index); - if (pampd) - (*tmem_pamops.free)(pampd, pool, NULL, 0, true); - if (objnew) { - tmem_obj_free(objnew, hb); - (*tmem_hostops.obj_free)(objnew, pool); - } -out: - spin_unlock(&hb->lock); - return ret; -} - -#ifdef CONFIG_RAMSTER -/* - * For ramster only: The following routines provide a two-step sequence - * to allow the caller to replace a pampd in the tmem data structures with - * another pampd. Here, we lookup the passed handle and, if found, return the - * associated pampd and object, leaving the hashbucket locked and returning - * a reference to it. The caller is expected to immediately call the - * matching tmem_localify_finish routine which will handles the replacement - * and unlocks the hashbucket. - */ -void *tmem_localify_get_pampd(struct tmem_pool *pool, struct tmem_oid *oidp, - uint32_t index, struct tmem_obj **ret_obj, - void **saved_hb) -{ - struct tmem_hashbucket *hb; - struct tmem_obj *obj = NULL; - void *pampd = NULL; - - hb = &pool->hashbucket[tmem_oid_hash(oidp)]; - spin_lock(&hb->lock); - obj = tmem_obj_find(hb, oidp); - if (likely(obj != NULL)) - pampd = tmem_pampd_lookup_in_obj(obj, index); - *ret_obj = obj; - *saved_hb = (void *)hb; - /* note, hashbucket remains locked */ - return pampd; -} -EXPORT_SYMBOL_GPL(tmem_localify_get_pampd); - -void tmem_localify_finish(struct tmem_obj *obj, uint32_t index, - void *pampd, void *saved_hb, bool delete) -{ - struct tmem_hashbucket *hb = (struct tmem_hashbucket *)saved_hb; - - BUG_ON(!spin_is_locked(&hb->lock)); - if (pampd != NULL) { - BUG_ON(obj == NULL); - (void)tmem_pampd_replace_in_obj(obj, index, pampd, 1); - (*tmem_pamops.create_finish)(pampd, is_ephemeral(obj->pool)); - } else if (delete) { - BUG_ON(obj == NULL); - (void)tmem_pampd_delete_from_obj(obj, index); - } - spin_unlock(&hb->lock); -} -EXPORT_SYMBOL_GPL(tmem_localify_finish); - -/* - * For ramster only. Helper function to support asynchronous tmem_get. - */ -static int tmem_repatriate(void **ppampd, struct tmem_hashbucket *hb, - struct tmem_pool *pool, struct tmem_oid *oidp, - uint32_t index, bool free, char *data) -{ - void *old_pampd = *ppampd, *new_pampd = NULL; - bool intransit = false; - int ret = 0; - - if (!is_ephemeral(pool)) - new_pampd = (*tmem_pamops.repatriate_preload)( - old_pampd, pool, oidp, index, &intransit); - if (intransit) - ret = -EAGAIN; - else if (new_pampd != NULL) - *ppampd = new_pampd; - /* must release the hb->lock else repatriate can't sleep */ - spin_unlock(&hb->lock); - if (!intransit) - ret = (*tmem_pamops.repatriate)(old_pampd, new_pampd, pool, - oidp, index, free, data); - if (ret == -EAGAIN) { - /* rare I think, but should cond_resched()??? */ - usleep_range(10, 1000); - } else if (ret == -ENOTCONN || ret == -EHOSTDOWN) { - ret = -1; - } else if (ret != 0 && ret != -ENOENT) { - ret = -1; - } - /* note hb->lock has now been unlocked */ - return ret; -} - -/* - * For ramster only. If a page in tmem matches the handle, replace the - * page so that any subsequent "get" gets the new page. Returns 0 if - * there was a page to replace, else returns -1. - */ -int tmem_replace(struct tmem_pool *pool, struct tmem_oid *oidp, - uint32_t index, void *new_pampd) -{ - struct tmem_obj *obj; - int ret = -1; - struct tmem_hashbucket *hb; - - hb = &pool->hashbucket[tmem_oid_hash(oidp)]; - spin_lock(&hb->lock); - obj = tmem_obj_find(hb, oidp); - if (obj == NULL) - goto out; - new_pampd = tmem_pampd_replace_in_obj(obj, index, new_pampd, 0); - /* if we bug here, pamops wasn't properly set up for ramster */ - BUG_ON(tmem_pamops.replace_in_obj == NULL); - ret = (*tmem_pamops.replace_in_obj)(new_pampd, obj); -out: - spin_unlock(&hb->lock); - return ret; -} -EXPORT_SYMBOL_GPL(tmem_replace); -#endif - -/* - * "Get" a page, e.g. if a pampd can be found matching the passed handle, - * use a pamops callback to recreated the page from the pampd with the - * matching handle. By tmem definition, when a "get" is successful on - * an ephemeral page, the page is "flushed", and when a "get" is successful - * on a persistent page, the page is retained in tmem. Note that to preserve - * coherency, "get" can never be skipped if tmem contains the data. - * That is, if a get is done with a certain handle and fails, any - * subsequent "get" must also fail (unless of course there is a - * "put" done with the same handle). - */ -int tmem_get(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index, - char *data, size_t *sizep, bool raw, int get_and_free) -{ - struct tmem_obj *obj; - void *pampd = NULL; - bool ephemeral = is_ephemeral(pool); - int ret = -1; - struct tmem_hashbucket *hb; - bool free = (get_and_free == 1) || ((get_and_free == 0) && ephemeral); - bool lock_held = false; - void **ppampd; - - do { - hb = &pool->hashbucket[tmem_oid_hash(oidp)]; - spin_lock(&hb->lock); - lock_held = true; - obj = tmem_obj_find(hb, oidp); - if (obj == NULL) - goto out; - ppampd = __tmem_pampd_lookup_in_obj(obj, index); - if (ppampd == NULL) - goto out; -#ifdef CONFIG_RAMSTER - if ((tmem_pamops.is_remote != NULL) && - tmem_pamops.is_remote(*ppampd)) { - ret = tmem_repatriate(ppampd, hb, pool, oidp, - index, free, data); - /* tmem_repatriate releases hb->lock */ - lock_held = false; - *sizep = PAGE_SIZE; - if (ret != -EAGAIN) - goto out; - } -#endif - } while (ret == -EAGAIN); - if (free) - pampd = tmem_pampd_delete_from_obj(obj, index); - else - pampd = tmem_pampd_lookup_in_obj(obj, index); - if (pampd == NULL) - goto out; - if (free) { - if (obj->pampd_count == 0) { - tmem_obj_free(obj, hb); - (*tmem_hostops.obj_free)(obj, pool); - obj = NULL; - } - } - if (free) - ret = (*tmem_pamops.get_data_and_free)( - data, sizep, raw, pampd, pool, oidp, index); - else - ret = (*tmem_pamops.get_data)( - data, sizep, raw, pampd, pool, oidp, index); - if (ret < 0) - goto out; - ret = 0; -out: - if (lock_held) - spin_unlock(&hb->lock); - return ret; -} - -/* - * If a page in tmem matches the handle, "flush" this page from tmem such - * that any subsequent "get" does not succeed (unless, of course, there - * was another "put" with the same handle). - */ -int tmem_flush_page(struct tmem_pool *pool, - struct tmem_oid *oidp, uint32_t index) -{ - struct tmem_obj *obj; - void *pampd; - int ret = -1; - struct tmem_hashbucket *hb; - - hb = &pool->hashbucket[tmem_oid_hash(oidp)]; - spin_lock(&hb->lock); - obj = tmem_obj_find(hb, oidp); - if (obj == NULL) - goto out; - pampd = tmem_pampd_delete_from_obj(obj, index); - if (pampd == NULL) - goto out; - (*tmem_pamops.free)(pampd, pool, oidp, index, true); - if (obj->pampd_count == 0) { - tmem_obj_free(obj, hb); - (*tmem_hostops.obj_free)(obj, pool); - } - ret = 0; - -out: - spin_unlock(&hb->lock); - return ret; -} - -/* - * "Flush" all pages in tmem matching this oid. - */ -int tmem_flush_object(struct tmem_pool *pool, struct tmem_oid *oidp) -{ - struct tmem_obj *obj; - struct tmem_hashbucket *hb; - int ret = -1; - - hb = &pool->hashbucket[tmem_oid_hash(oidp)]; - spin_lock(&hb->lock); - obj = tmem_obj_find(hb, oidp); - if (obj == NULL) - goto out; - tmem_pampd_destroy_all_in_obj(obj, false); - tmem_obj_free(obj, hb); - (*tmem_hostops.obj_free)(obj, pool); - ret = 0; - -out: - spin_unlock(&hb->lock); - return ret; -} - -/* - * "Flush" all pages (and tmem_objs) from this tmem_pool and disable - * all subsequent access to this tmem_pool. - */ -int tmem_destroy_pool(struct tmem_pool *pool) -{ - int ret = -1; - - if (pool == NULL) - goto out; - tmem_pool_flush(pool, 1); - ret = 0; -out: - return ret; -} - -static LIST_HEAD(tmem_global_pool_list); - -/* - * Create a new tmem_pool with the provided flag and return - * a pool id provided by the tmem host implementation. - */ -void tmem_new_pool(struct tmem_pool *pool, uint32_t flags) -{ - int persistent = flags & TMEM_POOL_PERSIST; - int shared = flags & TMEM_POOL_SHARED; - struct tmem_hashbucket *hb = &pool->hashbucket[0]; - int i; - - for (i = 0; i < TMEM_HASH_BUCKETS; i++, hb++) { - hb->obj_rb_root = RB_ROOT; - spin_lock_init(&hb->lock); - } - INIT_LIST_HEAD(&pool->pool_list); - atomic_set(&pool->obj_count, 0); - SET_SENTINEL(pool, POOL); - list_add_tail(&pool->pool_list, &tmem_global_pool_list); - pool->persistent = persistent; - pool->shared = shared; -} diff --git a/drivers/staging/zcache/tmem.h b/drivers/staging/zcache/tmem.h deleted file mode 100644 index d128ce290f1f8..0000000000000 --- a/drivers/staging/zcache/tmem.h +++ /dev/null @@ -1,259 +0,0 @@ -/* - * tmem.h - * - * Transcendent memory - * - * Copyright (c) 2009-2012, Dan Magenheimer, Oracle Corp. - */ - -#ifndef _TMEM_H_ -#define _TMEM_H_ - -#include -#include -#include -#include - -/* - * These are defined by the Xen<->Linux ABI so should remain consistent - */ -#define TMEM_POOL_PERSIST 1 -#define TMEM_POOL_SHARED 2 -#define TMEM_POOL_PRECOMPRESSED 4 -#define TMEM_POOL_PAGESIZE_SHIFT 4 -#define TMEM_POOL_PAGESIZE_MASK 0xf -#define TMEM_POOL_RESERVED_BITS 0x00ffff00 - -/* - * sentinels have proven very useful for debugging but can be removed - * or disabled before final merge. - */ -#undef SENTINELS -#ifdef SENTINELS -#define DECL_SENTINEL uint32_t sentinel; -#define SET_SENTINEL(_x, _y) (_x->sentinel = _y##_SENTINEL) -#define INVERT_SENTINEL(_x, _y) (_x->sentinel = ~_y##_SENTINEL) -#define ASSERT_SENTINEL(_x, _y) WARN_ON(_x->sentinel != _y##_SENTINEL) -#define ASSERT_INVERTED_SENTINEL(_x, _y) WARN_ON(_x->sentinel != ~_y##_SENTINEL) -#else -#define DECL_SENTINEL -#define SET_SENTINEL(_x, _y) do { } while (0) -#define INVERT_SENTINEL(_x, _y) do { } while (0) -#define ASSERT_SENTINEL(_x, _y) do { } while (0) -#define ASSERT_INVERTED_SENTINEL(_x, _y) do { } while (0) -#endif - -#define ASSERT_SPINLOCK(_l) lockdep_assert_held(_l) - -/* - * A pool is the highest-level data structure managed by tmem and - * usually corresponds to a large independent set of pages such as - * a filesystem. Each pool has an id, and certain attributes and counters. - * It also contains a set of hash buckets, each of which contains an rbtree - * of objects and a lock to manage concurrency within the pool. - */ - -#define TMEM_HASH_BUCKET_BITS 8 -#define TMEM_HASH_BUCKETS (1<persistent) -#define is_ephemeral(_p) (!(_p->persistent)) - -/* - * An object id ("oid") is large: 192-bits (to ensure, for example, files - * in a modern filesystem can be uniquely identified). - */ - -struct tmem_oid { - uint64_t oid[3]; -}; - -static inline void tmem_oid_set_invalid(struct tmem_oid *oidp) -{ - oidp->oid[0] = oidp->oid[1] = oidp->oid[2] = -1UL; -} - -static inline bool tmem_oid_valid(struct tmem_oid *oidp) -{ - return oidp->oid[0] != -1UL || oidp->oid[1] != -1UL || - oidp->oid[2] != -1UL; -} - -static inline int tmem_oid_compare(struct tmem_oid *left, - struct tmem_oid *right) -{ - int ret; - - if (left->oid[2] == right->oid[2]) { - if (left->oid[1] == right->oid[1]) { - if (left->oid[0] == right->oid[0]) - ret = 0; - else if (left->oid[0] < right->oid[0]) - ret = -1; - else - return 1; - } else if (left->oid[1] < right->oid[1]) - ret = -1; - else - ret = 1; - } else if (left->oid[2] < right->oid[2]) - ret = -1; - else - ret = 1; - return ret; -} - -static inline unsigned tmem_oid_hash(struct tmem_oid *oidp) -{ - return hash_long(oidp->oid[0] ^ oidp->oid[1] ^ oidp->oid[2], - TMEM_HASH_BUCKET_BITS); -} - -#if defined(CONFIG_RAMSTER) || defined(CONFIG_RAMSTER_MODULE) -struct tmem_xhandle { - uint8_t client_id; - uint8_t xh_data_cksum; - uint16_t xh_data_size; - uint16_t pool_id; - struct tmem_oid oid; - uint32_t index; - void *extra; -}; - -static inline struct tmem_xhandle tmem_xhandle_fill(uint16_t client_id, - struct tmem_pool *pool, - struct tmem_oid *oidp, - uint32_t index) -{ - struct tmem_xhandle xh; - xh.client_id = client_id; - xh.xh_data_cksum = (uint8_t)-1; - xh.xh_data_size = (uint16_t)-1; - xh.pool_id = pool->pool_id; - xh.oid = *oidp; - xh.index = index; - return xh; -} -#endif - - -/* - * A tmem_obj contains an identifier (oid), pointers to the parent - * pool and the rb_tree to which it belongs, counters, and an ordered - * set of pampds, structured in a radix-tree-like tree. The intermediate - * nodes of the tree are called tmem_objnodes. - */ - -struct tmem_objnode; - -struct tmem_obj { - struct tmem_oid oid; - struct tmem_pool *pool; - struct rb_node rb_tree_node; - struct tmem_objnode *objnode_tree_root; - unsigned int objnode_tree_height; - unsigned long objnode_count; - long pampd_count; -#if defined(CONFIG_RAMSTER) || defined(CONFIG_RAMSTER_MODULE) - /* - * for current design of ramster, all pages belonging to - * an object reside on the same remotenode and extra is - * used to record the number of the remotenode so a - * flush-object operation can specify it - */ - void *extra; /* for private use by pampd implementation */ -#endif - DECL_SENTINEL -}; - -#define OBJNODE_TREE_MAP_SHIFT 6 -#define OBJNODE_TREE_MAP_SIZE (1UL << OBJNODE_TREE_MAP_SHIFT) -#define OBJNODE_TREE_MAP_MASK (OBJNODE_TREE_MAP_SIZE-1) -#define OBJNODE_TREE_INDEX_BITS (8 /* CHAR_BIT */ * sizeof(unsigned long)) -#define OBJNODE_TREE_MAX_PATH \ - (OBJNODE_TREE_INDEX_BITS/OBJNODE_TREE_MAP_SHIFT + 2) - -struct tmem_objnode { - struct tmem_obj *obj; - DECL_SENTINEL - void *slots[OBJNODE_TREE_MAP_SIZE]; - unsigned int slots_in_use; -}; - -struct tmem_handle { - struct tmem_oid oid; /* 24 bytes */ - uint32_t index; - uint16_t pool_id; - uint16_t client_id; -}; - - -/* pampd abstract datatype methods provided by the PAM implementation */ -struct tmem_pamops { - void (*create_finish)(void *, bool); - int (*get_data)(char *, size_t *, bool, void *, struct tmem_pool *, - struct tmem_oid *, uint32_t); - int (*get_data_and_free)(char *, size_t *, bool, void *, - struct tmem_pool *, struct tmem_oid *, - uint32_t); - void (*free)(void *, struct tmem_pool *, - struct tmem_oid *, uint32_t, bool); -#if defined(CONFIG_RAMSTER) || defined(CONFIG_RAMSTER_MODULE) - void (*new_obj)(struct tmem_obj *); - void (*free_obj)(struct tmem_pool *, struct tmem_obj *, bool); - void *(*repatriate_preload)(void *, struct tmem_pool *, - struct tmem_oid *, uint32_t, bool *); - int (*repatriate)(void *, void *, struct tmem_pool *, - struct tmem_oid *, uint32_t, bool, void *); - bool (*is_remote)(void *); - int (*replace_in_obj)(void *, struct tmem_obj *); -#endif -}; -extern void tmem_register_pamops(struct tmem_pamops *m); - -/* memory allocation methods provided by the host implementation */ -struct tmem_hostops { - struct tmem_obj *(*obj_alloc)(struct tmem_pool *); - void (*obj_free)(struct tmem_obj *, struct tmem_pool *); - struct tmem_objnode *(*objnode_alloc)(struct tmem_pool *); - void (*objnode_free)(struct tmem_objnode *, struct tmem_pool *); -}; -extern void tmem_register_hostops(struct tmem_hostops *m); - -/* core tmem accessor functions */ -extern int tmem_put(struct tmem_pool *, struct tmem_oid *, uint32_t index, - bool, void *); -extern int tmem_get(struct tmem_pool *, struct tmem_oid *, uint32_t index, - char *, size_t *, bool, int); -extern int tmem_flush_page(struct tmem_pool *, struct tmem_oid *, - uint32_t index); -extern int tmem_flush_object(struct tmem_pool *, struct tmem_oid *); -extern int tmem_destroy_pool(struct tmem_pool *); -extern void tmem_new_pool(struct tmem_pool *, uint32_t); -#if defined(CONFIG_RAMSTER) || defined(CONFIG_RAMSTER_MODULE) -extern int tmem_replace(struct tmem_pool *, struct tmem_oid *, uint32_t index, - void *); -extern void *tmem_localify_get_pampd(struct tmem_pool *, struct tmem_oid *, - uint32_t index, struct tmem_obj **, - void **); -extern void tmem_localify_finish(struct tmem_obj *, uint32_t index, - void *, void *, bool); -#endif -#endif /* _TMEM_H */ diff --git a/drivers/staging/zcache/zbud.c b/drivers/staging/zcache/zbud.c deleted file mode 100644 index 6cda4ed9ed311..0000000000000 --- a/drivers/staging/zcache/zbud.c +++ /dev/null @@ -1,1066 +0,0 @@ -/* - * zbud.c - Compression buddies allocator - * - * Copyright (c) 2010-2012, Dan Magenheimer, Oracle Corp. - * - * Compression buddies ("zbud") provides for efficiently packing two - * (or, possibly in the future, more) compressed pages ("zpages") into - * a single "raw" pageframe and for tracking both zpages and pageframes - * so that whole pageframes can be easily reclaimed in LRU-like order. - * It is designed to be used in conjunction with transcendent memory - * ("tmem"); for example separate LRU lists are maintained for persistent - * vs. ephemeral pages. - * - * A zbudpage is an overlay for a struct page and thus each zbudpage - * refers to a physical pageframe of RAM. When the caller passes a - * struct page from the kernel's page allocator, zbud "transforms" it - * to a zbudpage which sets/uses a different set of fields than the - * struct-page and thus must "untransform" it back by reinitializing - * certain fields before the struct-page can be freed. The fields - * of a zbudpage include a page lock for controlling access to the - * corresponding pageframe, and there is a size field for each zpage. - * Each zbudpage also lives on two linked lists: a "budlist" which is - * used to support efficient buddying of zpages; and an "lru" which - * is used for reclaiming pageframes in approximately least-recently-used - * order. - * - * A zbudpageframe is a pageframe divided up into aligned 64-byte "chunks" - * which contain the compressed data for zero, one, or two zbuds. Contained - * with the compressed data is a tmem_handle which is a key to allow - * the same data to be found via the tmem interface so the zpage can - * be invalidated (for ephemeral pages) or repatriated to the swap cache - * (for persistent pages). The contents of a zbudpageframe must never - * be accessed without holding the page lock for the corresponding - * zbudpage and, to accomodate highmem machines, the contents may - * only be examined or changes when kmapped. Thus, when in use, a - * kmapped zbudpageframe is referred to in the zbud code as "void *zbpg". - * - * Note that the term "zbud" refers to the combination of a zpage and - * a tmem_handle that is stored as one of possibly two "buddied" zpages; - * it also generically refers to this allocator... sorry for any confusion. - * - * A zbudref is a pointer to a struct zbudpage (which can be cast to a - * struct page), with the LSB either cleared or set to indicate, respectively, - * the first or second zpage in the zbudpageframe. Since a zbudref can be - * cast to a pointer, it is used as the tmem "pampd" pointer and uniquely - * references a stored tmem page and so is the only zbud data structure - * externally visible to zbud.c/zbud.h. - * - * Since we wish to reclaim entire pageframes but zpages may be randomly - * added and deleted to any given pageframe, we approximate LRU by - * promoting a pageframe to MRU when a zpage is added to it, but - * leaving it at the current place in the list when a zpage is deleted - * from it. As a side effect, zpages that are difficult to buddy (e.g. - * very large paages) will be reclaimed faster than average, which seems - * reasonable. - * - * In the current implementation, no more than two zpages may be stored in - * any pageframe and no zpage ever crosses a pageframe boundary. While - * other zpage allocation mechanisms may allow greater density, this two - * zpage-per-pageframe limit both ensures simple reclaim of pageframes - * (including garbage collection of references to the contents of those - * pageframes from tmem data structures) AND avoids the need for compaction. - * With additional complexity, zbud could be modified to support storing - * up to three zpages per pageframe or, to handle larger average zpages, - * up to three zpages per pair of pageframes, but it is not clear if the - * additional complexity would be worth it. So consider it an exercise - * for future developers. - * - * Note also that zbud does no page allocation or freeing. This is so - * that the caller has complete control over and, for accounting, visibility - * into if/when pages are allocated and freed. - * - * Finally, note that zbud limits the size of zpages it can store; the - * caller must check the zpage size with zbud_max_buddy_size before - * storing it, else BUGs will result. User beware. - */ - -#include -#include -#include -#include -#include -#include -#include -#include "tmem.h" -#include "zcache.h" -#include "zbud.h" - -/* - * We need to ensure that a struct zbudpage is never larger than a - * struct page. This is checked with a BUG_ON in zbud_init. - * - * The unevictable field indicates that a zbud is being added to the - * zbudpage. Since this is a two-phase process (due to tmem locking), - * this field locks the zbudpage against eviction when a zbud match - * or creation is in process. Since this addition process may occur - * in parallel for two zbuds in one zbudpage, the field is a counter - * that must not exceed two. - */ -struct zbudpage { - union { - struct page page; - struct { - unsigned long space_for_flags; - struct { - unsigned zbud0_size:PAGE_SHIFT; - unsigned zbud1_size:PAGE_SHIFT; - unsigned unevictable:2; - }; - struct list_head budlist; - struct list_head lru; - }; - }; -}; -#if (PAGE_SHIFT * 2) + 2 > BITS_PER_LONG -#error "zbud won't work for this arch, PAGE_SIZE is too large" -#endif - -struct zbudref { - union { - struct zbudpage *zbudpage; - unsigned long zbudref; - }; -}; - -#define CHUNK_SHIFT 6 -#define CHUNK_SIZE (1 << CHUNK_SHIFT) -#define CHUNK_MASK (~(CHUNK_SIZE-1)) -#define NCHUNKS (PAGE_SIZE >> CHUNK_SHIFT) -#define MAX_CHUNK (NCHUNKS-1) - -/* - * The following functions deal with the difference between struct - * page and struct zbudpage. Note the hack of using the pageflags - * from struct page; this is to avoid duplicating all the complex - * pageflag macros. - */ -static inline void zbudpage_spin_lock(struct zbudpage *zbudpage) -{ - struct page *page = (struct page *)zbudpage; - - while (unlikely(test_and_set_bit_lock(PG_locked, &page->flags))) { - do { - cpu_relax(); - } while (test_bit(PG_locked, &page->flags)); - } -} - -static inline void zbudpage_spin_unlock(struct zbudpage *zbudpage) -{ - struct page *page = (struct page *)zbudpage; - - clear_bit(PG_locked, &page->flags); -} - -static inline int zbudpage_spin_trylock(struct zbudpage *zbudpage) -{ - return trylock_page((struct page *)zbudpage); -} - -static inline int zbudpage_is_locked(struct zbudpage *zbudpage) -{ - return PageLocked((struct page *)zbudpage); -} - -static inline void *kmap_zbudpage_atomic(struct zbudpage *zbudpage) -{ - return kmap_atomic((struct page *)zbudpage); -} - -/* - * A dying zbudpage is an ephemeral page in the process of being evicted. - * Any data contained in the zbudpage is invalid and we are just waiting for - * the tmem pampds to be invalidated before freeing the page - */ -static inline int zbudpage_is_dying(struct zbudpage *zbudpage) -{ - struct page *page = (struct page *)zbudpage; - - return test_bit(PG_reclaim, &page->flags); -} - -static inline void zbudpage_set_dying(struct zbudpage *zbudpage) -{ - struct page *page = (struct page *)zbudpage; - - set_bit(PG_reclaim, &page->flags); -} - -static inline void zbudpage_clear_dying(struct zbudpage *zbudpage) -{ - struct page *page = (struct page *)zbudpage; - - clear_bit(PG_reclaim, &page->flags); -} - -/* - * A zombie zbudpage is a persistent page in the process of being evicted. - * The data contained in the zbudpage is valid and we are just waiting for - * the tmem pampds to be invalidated before freeing the page - */ -static inline int zbudpage_is_zombie(struct zbudpage *zbudpage) -{ - struct page *page = (struct page *)zbudpage; - - return test_bit(PG_dirty, &page->flags); -} - -static inline void zbudpage_set_zombie(struct zbudpage *zbudpage) -{ - struct page *page = (struct page *)zbudpage; - - set_bit(PG_dirty, &page->flags); -} - -static inline void zbudpage_clear_zombie(struct zbudpage *zbudpage) -{ - struct page *page = (struct page *)zbudpage; - - clear_bit(PG_dirty, &page->flags); -} - -static inline void kunmap_zbudpage_atomic(void *zbpg) -{ - kunmap_atomic(zbpg); -} - -/* - * zbud "translation" and helper functions - */ - -static inline struct zbudpage *zbudref_to_zbudpage(struct zbudref *zref) -{ - unsigned long zbud = (unsigned long)zref; - zbud &= ~1UL; - return (struct zbudpage *)zbud; -} - -static inline struct zbudref *zbudpage_to_zbudref(struct zbudpage *zbudpage, - unsigned budnum) -{ - unsigned long zbud = (unsigned long)zbudpage; - BUG_ON(budnum > 1); - zbud |= budnum; - return (struct zbudref *)zbud; -} - -static inline int zbudref_budnum(struct zbudref *zbudref) -{ - unsigned long zbud = (unsigned long)zbudref; - return zbud & 1UL; -} - -static inline unsigned zbud_max_size(void) -{ - return MAX_CHUNK << CHUNK_SHIFT; -} - -static inline unsigned zbud_size_to_chunks(unsigned size) -{ - BUG_ON(size == 0 || size > zbud_max_size()); - return (size + CHUNK_SIZE - 1) >> CHUNK_SHIFT; -} - -/* can only be used between kmap_zbudpage_atomic/kunmap_zbudpage_atomic! */ -static inline char *zbud_data(void *zbpg, - unsigned budnum, unsigned size) -{ - char *p; - - BUG_ON(size == 0 || size > zbud_max_size()); - p = (char *)zbpg; - if (budnum == 1) - p += PAGE_SIZE - ((size + CHUNK_SIZE - 1) & CHUNK_MASK); - return p; -} - -/* - * These are all informative and exposed through debugfs... except for - * the arrays... anyone know how to do that? To avoid confusion for - * debugfs viewers, some of these should also be atomic_long_t, but - * I don't know how to expose atomics via debugfs either... - */ -static ssize_t zbud_eph_pageframes; -static ssize_t zbud_pers_pageframes; -static ssize_t zbud_eph_zpages; -static ssize_t zbud_pers_zpages; -static u64 zbud_eph_zbytes; -static u64 zbud_pers_zbytes; -static ssize_t zbud_eph_evicted_pageframes; -static ssize_t zbud_pers_evicted_pageframes; -static ssize_t zbud_eph_cumul_zpages; -static ssize_t zbud_pers_cumul_zpages; -static u64 zbud_eph_cumul_zbytes; -static u64 zbud_pers_cumul_zbytes; -static ssize_t zbud_eph_cumul_chunk_counts[NCHUNKS]; -static ssize_t zbud_pers_cumul_chunk_counts[NCHUNKS]; -static ssize_t zbud_eph_buddied_count; -static ssize_t zbud_pers_buddied_count; -static ssize_t zbud_eph_unbuddied_count; -static ssize_t zbud_pers_unbuddied_count; -static ssize_t zbud_eph_zombie_count; -static ssize_t zbud_pers_zombie_count; -static atomic_t zbud_eph_zombie_atomic; -static atomic_t zbud_pers_zombie_atomic; - -#ifdef CONFIG_DEBUG_FS -#include -#define zdfs debugfs_create_size_t -#define zdfs64 debugfs_create_u64 -static int zbud_debugfs_init(void) -{ - struct dentry *root = debugfs_create_dir("zbud", NULL); - if (root == NULL) - return -ENXIO; - - /* - * would be nice to dump the sizes of the unbuddied - * arrays, like was done with sysfs, but it doesn't - * look like debugfs is flexible enough to do that - */ - zdfs64("eph_zbytes", S_IRUGO, root, &zbud_eph_zbytes); - zdfs64("eph_cumul_zbytes", S_IRUGO, root, &zbud_eph_cumul_zbytes); - zdfs64("pers_zbytes", S_IRUGO, root, &zbud_pers_zbytes); - zdfs64("pers_cumul_zbytes", S_IRUGO, root, &zbud_pers_cumul_zbytes); - zdfs("eph_cumul_zpages", S_IRUGO, root, &zbud_eph_cumul_zpages); - zdfs("eph_evicted_pageframes", S_IRUGO, root, - &zbud_eph_evicted_pageframes); - zdfs("eph_zpages", S_IRUGO, root, &zbud_eph_zpages); - zdfs("eph_pageframes", S_IRUGO, root, &zbud_eph_pageframes); - zdfs("eph_buddied_count", S_IRUGO, root, &zbud_eph_buddied_count); - zdfs("eph_unbuddied_count", S_IRUGO, root, &zbud_eph_unbuddied_count); - zdfs("pers_cumul_zpages", S_IRUGO, root, &zbud_pers_cumul_zpages); - zdfs("pers_evicted_pageframes", S_IRUGO, root, - &zbud_pers_evicted_pageframes); - zdfs("pers_zpages", S_IRUGO, root, &zbud_pers_zpages); - zdfs("pers_pageframes", S_IRUGO, root, &zbud_pers_pageframes); - zdfs("pers_buddied_count", S_IRUGO, root, &zbud_pers_buddied_count); - zdfs("pers_unbuddied_count", S_IRUGO, root, &zbud_pers_unbuddied_count); - zdfs("pers_zombie_count", S_IRUGO, root, &zbud_pers_zombie_count); - return 0; -} -#undef zdfs -#undef zdfs64 -#else -static inline int zbud_debugfs_init(void) -{ - return 0; -} -#endif - -/* protects the buddied list and all unbuddied lists */ -static DEFINE_SPINLOCK(zbud_eph_lists_lock); -static DEFINE_SPINLOCK(zbud_pers_lists_lock); - -struct zbud_unbuddied { - struct list_head list; - unsigned count; -}; - -/* list N contains pages with N chunks USED and NCHUNKS-N unused */ -/* element 0 is never used but optimizing that isn't worth it */ -static struct zbud_unbuddied zbud_eph_unbuddied[NCHUNKS]; -static struct zbud_unbuddied zbud_pers_unbuddied[NCHUNKS]; -static LIST_HEAD(zbud_eph_lru_list); -static LIST_HEAD(zbud_pers_lru_list); -static LIST_HEAD(zbud_eph_buddied_list); -static LIST_HEAD(zbud_pers_buddied_list); -static LIST_HEAD(zbud_eph_zombie_list); -static LIST_HEAD(zbud_pers_zombie_list); - -/* - * Given a struct page, transform it to a zbudpage so that it can be - * used by zbud and initialize fields as necessary. - */ -static inline struct zbudpage *zbud_init_zbudpage(struct page *page, bool eph) -{ - struct zbudpage *zbudpage = (struct zbudpage *)page; - - BUG_ON(page == NULL); - INIT_LIST_HEAD(&zbudpage->budlist); - INIT_LIST_HEAD(&zbudpage->lru); - zbudpage->zbud0_size = 0; - zbudpage->zbud1_size = 0; - zbudpage->unevictable = 0; - if (eph) - zbud_eph_pageframes++; - else - zbud_pers_pageframes++; - return zbudpage; -} - -/* "Transform" a zbudpage back to a struct page suitable to free. */ -static inline struct page *zbud_unuse_zbudpage(struct zbudpage *zbudpage, - bool eph) -{ - struct page *page = (struct page *)zbudpage; - - BUG_ON(!list_empty(&zbudpage->budlist)); - BUG_ON(!list_empty(&zbudpage->lru)); - BUG_ON(zbudpage->zbud0_size != 0); - BUG_ON(zbudpage->zbud1_size != 0); - BUG_ON(!PageLocked(page)); - BUG_ON(zbudpage->unevictable != 0); - BUG_ON(zbudpage_is_dying(zbudpage)); - BUG_ON(zbudpage_is_zombie(zbudpage)); - if (eph) - zbud_eph_pageframes--; - else - zbud_pers_pageframes--; - zbudpage_spin_unlock(zbudpage); - page_mapcount_reset(page); - init_page_count(page); - page->index = 0; - return page; -} - -/* Mark a zbud as unused and do accounting */ -static inline void zbud_unuse_zbud(struct zbudpage *zbudpage, - int budnum, bool eph) -{ - unsigned size; - - BUG_ON(!zbudpage_is_locked(zbudpage)); - if (budnum == 0) { - size = zbudpage->zbud0_size; - zbudpage->zbud0_size = 0; - } else { - size = zbudpage->zbud1_size; - zbudpage->zbud1_size = 0; - } - if (eph) { - zbud_eph_zbytes -= size; - zbud_eph_zpages--; - } else { - zbud_pers_zbytes -= size; - zbud_pers_zpages--; - } -} - -/* - * Given a zbudpage/budnum/size, a tmem handle, and a kmapped pointer - * to some data, set up the zbud appropriately including data copying - * and accounting. Note that if cdata is NULL, the data copying is - * skipped. (This is useful for lazy writes such as for RAMster.) - */ -static void zbud_init_zbud(struct zbudpage *zbudpage, struct tmem_handle *th, - bool eph, void *cdata, - unsigned budnum, unsigned size) -{ - char *to; - void *zbpg; - struct tmem_handle *to_th; - unsigned nchunks = zbud_size_to_chunks(size); - - BUG_ON(!zbudpage_is_locked(zbudpage)); - zbpg = kmap_zbudpage_atomic(zbudpage); - to = zbud_data(zbpg, budnum, size); - to_th = (struct tmem_handle *)to; - to_th->index = th->index; - to_th->oid = th->oid; - to_th->pool_id = th->pool_id; - to_th->client_id = th->client_id; - to += sizeof(struct tmem_handle); - if (cdata != NULL) - memcpy(to, cdata, size - sizeof(struct tmem_handle)); - kunmap_zbudpage_atomic(zbpg); - if (budnum == 0) - zbudpage->zbud0_size = size; - else - zbudpage->zbud1_size = size; - if (eph) { - zbud_eph_cumul_chunk_counts[nchunks]++; - zbud_eph_zpages++; - zbud_eph_cumul_zpages++; - zbud_eph_zbytes += size; - zbud_eph_cumul_zbytes += size; - } else { - zbud_pers_cumul_chunk_counts[nchunks]++; - zbud_pers_zpages++; - zbud_pers_cumul_zpages++; - zbud_pers_zbytes += size; - zbud_pers_cumul_zbytes += size; - } -} - -/* - * Given a locked dying zbudpage, read out the tmem handles from the data, - * unlock the page, then use the handles to tell tmem to flush out its - * references - */ -static void zbud_evict_tmem(struct zbudpage *zbudpage) -{ - int i, j; - uint32_t pool_id[2], client_id[2]; - uint32_t index[2]; - struct tmem_oid oid[2]; - struct tmem_pool *pool; - void *zbpg; - struct tmem_handle *th; - unsigned size; - - /* read out the tmem handles from the data and set aside */ - zbpg = kmap_zbudpage_atomic(zbudpage); - for (i = 0, j = 0; i < 2; i++) { - size = (i == 0) ? zbudpage->zbud0_size : zbudpage->zbud1_size; - if (size) { - th = (struct tmem_handle *)zbud_data(zbpg, i, size); - client_id[j] = th->client_id; - pool_id[j] = th->pool_id; - oid[j] = th->oid; - index[j] = th->index; - j++; - zbud_unuse_zbud(zbudpage, i, true); - } - } - kunmap_zbudpage_atomic(zbpg); - zbudpage_spin_unlock(zbudpage); - /* zbudpage is now an unlocked dying... tell tmem to flush pointers */ - for (i = 0; i < j; i++) { - pool = zcache_get_pool_by_id(client_id[i], pool_id[i]); - if (pool != NULL) { - tmem_flush_page(pool, &oid[i], index[i]); - zcache_put_pool(pool); - } - } -} - -/* - * Externally callable zbud handling routines. - */ - -/* - * Return the maximum size compressed page that can be stored (secretly - * setting aside space for the tmem handle. - */ -unsigned int zbud_max_buddy_size(void) -{ - return zbud_max_size() - sizeof(struct tmem_handle); -} - -/* - * Given a zbud reference, free the corresponding zbud from all lists, - * mark it as unused, do accounting, and if the freeing of the zbud - * frees up an entire pageframe, return it to the caller (else NULL). - */ -struct page *zbud_free_and_delist(struct zbudref *zref, bool eph, - unsigned int *zsize, unsigned int *zpages) -{ - unsigned long budnum = zbudref_budnum(zref); - struct zbudpage *zbudpage = zbudref_to_zbudpage(zref); - struct page *page = NULL; - unsigned chunks, bud_size, other_bud_size; - spinlock_t *lists_lock = - eph ? &zbud_eph_lists_lock : &zbud_pers_lists_lock; - struct zbud_unbuddied *unbud = - eph ? zbud_eph_unbuddied : zbud_pers_unbuddied; - - - spin_lock(lists_lock); - zbudpage_spin_lock(zbudpage); - if (zbudpage_is_dying(zbudpage)) { - /* ignore dying zbudpage... see zbud_evict_pageframe_lru() */ - zbudpage_spin_unlock(zbudpage); - spin_unlock(lists_lock); - *zpages = 0; - *zsize = 0; - goto out; - } - if (budnum == 0) { - bud_size = zbudpage->zbud0_size; - other_bud_size = zbudpage->zbud1_size; - } else { - bud_size = zbudpage->zbud1_size; - other_bud_size = zbudpage->zbud0_size; - } - *zsize = bud_size - sizeof(struct tmem_handle); - *zpages = 1; - zbud_unuse_zbud(zbudpage, budnum, eph); - if (other_bud_size == 0) { /* was unbuddied: unlist and free */ - chunks = zbud_size_to_chunks(bud_size) ; - if (zbudpage_is_zombie(zbudpage)) { - if (eph) - zbud_pers_zombie_count = - atomic_dec_return(&zbud_eph_zombie_atomic); - else - zbud_pers_zombie_count = - atomic_dec_return(&zbud_pers_zombie_atomic); - zbudpage_clear_zombie(zbudpage); - } else { - BUG_ON(list_empty(&unbud[chunks].list)); - list_del_init(&zbudpage->budlist); - unbud[chunks].count--; - } - list_del_init(&zbudpage->lru); - spin_unlock(lists_lock); - if (eph) - zbud_eph_unbuddied_count--; - else - zbud_pers_unbuddied_count--; - page = zbud_unuse_zbudpage(zbudpage, eph); - } else { /* was buddied: move remaining buddy to unbuddied list */ - chunks = zbud_size_to_chunks(other_bud_size) ; - if (!zbudpage_is_zombie(zbudpage)) { - list_del_init(&zbudpage->budlist); - list_add_tail(&zbudpage->budlist, &unbud[chunks].list); - unbud[chunks].count++; - } - if (eph) { - zbud_eph_buddied_count--; - zbud_eph_unbuddied_count++; - } else { - zbud_pers_unbuddied_count++; - zbud_pers_buddied_count--; - } - /* don't mess with lru, no need to move it */ - zbudpage_spin_unlock(zbudpage); - spin_unlock(lists_lock); - } -out: - return page; -} - -/* - * Given a tmem handle, and a kmapped pointer to compressed data of - * the given size, try to find an unbuddied zbudpage in which to - * create a zbud. If found, put it there, mark the zbudpage unevictable, - * and return a zbudref to it. Else return NULL. - */ -struct zbudref *zbud_match_prep(struct tmem_handle *th, bool eph, - void *cdata, unsigned size) -{ - struct zbudpage *zbudpage = NULL, *zbudpage2; - unsigned long budnum = 0UL; - unsigned nchunks; - int i, found_good_buddy = 0; - spinlock_t *lists_lock = - eph ? &zbud_eph_lists_lock : &zbud_pers_lists_lock; - struct zbud_unbuddied *unbud = - eph ? zbud_eph_unbuddied : zbud_pers_unbuddied; - - size += sizeof(struct tmem_handle); - nchunks = zbud_size_to_chunks(size); - for (i = MAX_CHUNK - nchunks + 1; i > 0; i--) { - spin_lock(lists_lock); - if (!list_empty(&unbud[i].list)) { - list_for_each_entry_safe(zbudpage, zbudpage2, - &unbud[i].list, budlist) { - if (zbudpage_spin_trylock(zbudpage)) { - found_good_buddy = i; - goto found_unbuddied; - } - } - } - spin_unlock(lists_lock); - } - zbudpage = NULL; - goto out; - -found_unbuddied: - BUG_ON(!zbudpage_is_locked(zbudpage)); - BUG_ON(!((zbudpage->zbud0_size == 0) ^ (zbudpage->zbud1_size == 0))); - if (zbudpage->zbud0_size == 0) - budnum = 0UL; - else if (zbudpage->zbud1_size == 0) - budnum = 1UL; - list_del_init(&zbudpage->budlist); - if (eph) { - list_add_tail(&zbudpage->budlist, &zbud_eph_buddied_list); - unbud[found_good_buddy].count--; - zbud_eph_unbuddied_count--; - zbud_eph_buddied_count++; - /* "promote" raw zbudpage to most-recently-used */ - list_del_init(&zbudpage->lru); - list_add_tail(&zbudpage->lru, &zbud_eph_lru_list); - } else { - list_add_tail(&zbudpage->budlist, &zbud_pers_buddied_list); - unbud[found_good_buddy].count--; - zbud_pers_unbuddied_count--; - zbud_pers_buddied_count++; - /* "promote" raw zbudpage to most-recently-used */ - list_del_init(&zbudpage->lru); - list_add_tail(&zbudpage->lru, &zbud_pers_lru_list); - } - zbud_init_zbud(zbudpage, th, eph, cdata, budnum, size); - zbudpage->unevictable++; - BUG_ON(zbudpage->unevictable == 3); - zbudpage_spin_unlock(zbudpage); - spin_unlock(lists_lock); -out: - return zbudpage_to_zbudref(zbudpage, budnum); - -} - -/* - * Given a tmem handle, and a kmapped pointer to compressed data of - * the given size, and a newly allocated struct page, create an unevictable - * zbud in that new page and return a zbudref to it. - */ -struct zbudref *zbud_create_prep(struct tmem_handle *th, bool eph, - void *cdata, unsigned size, - struct page *newpage) -{ - struct zbudpage *zbudpage; - unsigned long budnum = 0; - unsigned nchunks; - spinlock_t *lists_lock = - eph ? &zbud_eph_lists_lock : &zbud_pers_lists_lock; - struct zbud_unbuddied *unbud = - eph ? zbud_eph_unbuddied : zbud_pers_unbuddied; - -#if 0 - /* this may be worth it later to support decompress-in-place? */ - static unsigned long counter; - budnum = counter++ & 1; /* alternate using zbud0 and zbud1 */ -#endif - - if (size > zbud_max_buddy_size()) - return NULL; - if (newpage == NULL) - return NULL; - - size += sizeof(struct tmem_handle); - nchunks = zbud_size_to_chunks(size) ; - spin_lock(lists_lock); - zbudpage = zbud_init_zbudpage(newpage, eph); - zbudpage_spin_lock(zbudpage); - list_add_tail(&zbudpage->budlist, &unbud[nchunks].list); - if (eph) { - list_add_tail(&zbudpage->lru, &zbud_eph_lru_list); - zbud_eph_unbuddied_count++; - } else { - list_add_tail(&zbudpage->lru, &zbud_pers_lru_list); - zbud_pers_unbuddied_count++; - } - unbud[nchunks].count++; - zbud_init_zbud(zbudpage, th, eph, cdata, budnum, size); - zbudpage->unevictable++; - BUG_ON(zbudpage->unevictable == 3); - zbudpage_spin_unlock(zbudpage); - spin_unlock(lists_lock); - return zbudpage_to_zbudref(zbudpage, budnum); -} - -/* - * Finish creation of a zbud by, assuming another zbud isn't being created - * in parallel, marking it evictable. - */ -void zbud_create_finish(struct zbudref *zref, bool eph) -{ - struct zbudpage *zbudpage = zbudref_to_zbudpage(zref); - spinlock_t *lists_lock = - eph ? &zbud_eph_lists_lock : &zbud_pers_lists_lock; - - spin_lock(lists_lock); - zbudpage_spin_lock(zbudpage); - BUG_ON(zbudpage_is_dying(zbudpage)); - zbudpage->unevictable--; - BUG_ON((int)zbudpage->unevictable < 0); - zbudpage_spin_unlock(zbudpage); - spin_unlock(lists_lock); -} - -/* - * Given a zbudref and a struct page, decompress the data from - * the zbud into the physical page represented by the struct page - * by upcalling to zcache_decompress - */ -int zbud_decompress(struct page *data_page, struct zbudref *zref, bool eph, - void (*decompress)(char *, unsigned int, char *)) -{ - struct zbudpage *zbudpage = zbudref_to_zbudpage(zref); - unsigned long budnum = zbudref_budnum(zref); - void *zbpg; - char *to_va, *from_va; - unsigned size; - int ret = -1; - spinlock_t *lists_lock = - eph ? &zbud_eph_lists_lock : &zbud_pers_lists_lock; - - spin_lock(lists_lock); - zbudpage_spin_lock(zbudpage); - if (zbudpage_is_dying(zbudpage)) { - /* ignore dying zbudpage... see zbud_evict_pageframe_lru() */ - goto out; - } - zbpg = kmap_zbudpage_atomic(zbudpage); - to_va = kmap_atomic(data_page); - if (budnum == 0) - size = zbudpage->zbud0_size; - else - size = zbudpage->zbud1_size; - BUG_ON(size == 0 || size > zbud_max_size()); - from_va = zbud_data(zbpg, budnum, size); - from_va += sizeof(struct tmem_handle); - size -= sizeof(struct tmem_handle); - decompress(from_va, size, to_va); - kunmap_atomic(to_va); - kunmap_zbudpage_atomic(zbpg); - ret = 0; -out: - zbudpage_spin_unlock(zbudpage); - spin_unlock(lists_lock); - return ret; -} - -/* - * Given a zbudref and a kernel pointer, copy the data from - * the zbud to the kernel pointer. - */ -int zbud_copy_from_zbud(char *to_va, struct zbudref *zref, - size_t *sizep, bool eph) -{ - struct zbudpage *zbudpage = zbudref_to_zbudpage(zref); - unsigned long budnum = zbudref_budnum(zref); - void *zbpg; - char *from_va; - unsigned size; - int ret = -1; - spinlock_t *lists_lock = - eph ? &zbud_eph_lists_lock : &zbud_pers_lists_lock; - - spin_lock(lists_lock); - zbudpage_spin_lock(zbudpage); - if (zbudpage_is_dying(zbudpage)) { - /* ignore dying zbudpage... see zbud_evict_pageframe_lru() */ - goto out; - } - zbpg = kmap_zbudpage_atomic(zbudpage); - if (budnum == 0) - size = zbudpage->zbud0_size; - else - size = zbudpage->zbud1_size; - BUG_ON(size == 0 || size > zbud_max_size()); - from_va = zbud_data(zbpg, budnum, size); - from_va += sizeof(struct tmem_handle); - size -= sizeof(struct tmem_handle); - *sizep = size; - memcpy(to_va, from_va, size); - - kunmap_zbudpage_atomic(zbpg); - ret = 0; -out: - zbudpage_spin_unlock(zbudpage); - spin_unlock(lists_lock); - return ret; -} - -/* - * Given a zbudref and a kernel pointer, copy the data from - * the kernel pointer to the zbud. - */ -int zbud_copy_to_zbud(struct zbudref *zref, char *from_va, bool eph) -{ - struct zbudpage *zbudpage = zbudref_to_zbudpage(zref); - unsigned long budnum = zbudref_budnum(zref); - void *zbpg; - char *to_va; - unsigned size; - int ret = -1; - spinlock_t *lists_lock = - eph ? &zbud_eph_lists_lock : &zbud_pers_lists_lock; - - spin_lock(lists_lock); - zbudpage_spin_lock(zbudpage); - if (zbudpage_is_dying(zbudpage)) { - /* ignore dying zbudpage... see zbud_evict_pageframe_lru() */ - goto out; - } - zbpg = kmap_zbudpage_atomic(zbudpage); - if (budnum == 0) - size = zbudpage->zbud0_size; - else - size = zbudpage->zbud1_size; - BUG_ON(size == 0 || size > zbud_max_size()); - to_va = zbud_data(zbpg, budnum, size); - to_va += sizeof(struct tmem_handle); - size -= sizeof(struct tmem_handle); - memcpy(to_va, from_va, size); - - kunmap_zbudpage_atomic(zbpg); - ret = 0; -out: - zbudpage_spin_unlock(zbudpage); - spin_unlock(lists_lock); - return ret; -} - -/* - * Choose an ephemeral LRU zbudpage that is evictable (not locked), ensure - * there are no references to it remaining, and return the now unused - * (and re-init'ed) struct page and the total amount of compressed - * data that was evicted. - */ -struct page *zbud_evict_pageframe_lru(unsigned int *zsize, unsigned int *zpages) -{ - struct zbudpage *zbudpage = NULL, *zbudpage2; - struct zbud_unbuddied *unbud = zbud_eph_unbuddied; - struct page *page = NULL; - bool irqs_disabled = irqs_disabled(); - - /* - * Since this can be called indirectly from cleancache_put, which - * has interrupts disabled, as well as frontswap_put, which does not, - * we need to be able to handle both cases, even though it is ugly. - */ - if (irqs_disabled) - spin_lock(&zbud_eph_lists_lock); - else - spin_lock_bh(&zbud_eph_lists_lock); - *zsize = 0; - if (list_empty(&zbud_eph_lru_list)) - goto unlock_out; - list_for_each_entry_safe(zbudpage, zbudpage2, &zbud_eph_lru_list, lru) { - /* skip a locked zbudpage */ - if (unlikely(!zbudpage_spin_trylock(zbudpage))) - continue; - /* skip an unevictable zbudpage */ - if (unlikely(zbudpage->unevictable != 0)) { - zbudpage_spin_unlock(zbudpage); - continue; - } - /* got a locked evictable page */ - goto evict_page; - - } -unlock_out: - /* no unlocked evictable pages, give up */ - if (irqs_disabled) - spin_unlock(&zbud_eph_lists_lock); - else - spin_unlock_bh(&zbud_eph_lists_lock); - goto out; - -evict_page: - list_del_init(&zbudpage->budlist); - list_del_init(&zbudpage->lru); - zbudpage_set_dying(zbudpage); - /* - * the zbudpage is now "dying" and attempts to read, write, - * or delete data from it will be ignored - */ - if (zbudpage->zbud0_size != 0 && zbudpage->zbud1_size != 0) { - *zsize = zbudpage->zbud0_size + zbudpage->zbud1_size - - (2 * sizeof(struct tmem_handle)); - *zpages = 2; - } else if (zbudpage->zbud0_size != 0) { - unbud[zbud_size_to_chunks(zbudpage->zbud0_size)].count--; - *zsize = zbudpage->zbud0_size - sizeof(struct tmem_handle); - *zpages = 1; - } else if (zbudpage->zbud1_size != 0) { - unbud[zbud_size_to_chunks(zbudpage->zbud1_size)].count--; - *zsize = zbudpage->zbud1_size - sizeof(struct tmem_handle); - *zpages = 1; - } else { - BUG(); - } - spin_unlock(&zbud_eph_lists_lock); - zbud_eph_evicted_pageframes++; - if (*zpages == 1) - zbud_eph_unbuddied_count--; - else - zbud_eph_buddied_count--; - zbud_evict_tmem(zbudpage); - zbudpage_spin_lock(zbudpage); - zbudpage_clear_dying(zbudpage); - page = zbud_unuse_zbudpage(zbudpage, true); - if (!irqs_disabled) - local_bh_enable(); -out: - return page; -} - -/* - * Choose a persistent LRU zbudpage that is evictable (not locked), zombify it, - * read the tmem_handle(s) out of it into the passed array, and return the - * number of zbuds. Caller must perform necessary tmem functions and, - * indirectly, zbud functions to fetch any valid data and cause the - * now-zombified zbudpage to eventually be freed. We track the zombified - * zbudpage count so it is possible to observe if there is a leak. - FIXME: describe (ramster) case where data pointers are passed in for memcpy - */ -unsigned int zbud_make_zombie_lru(struct tmem_handle *th, unsigned char **data, - unsigned int *zsize, bool eph) -{ - struct zbudpage *zbudpage = NULL, *zbudpag2; - struct tmem_handle *thfrom; - char *from_va; - void *zbpg; - unsigned size; - int ret = 0, i; - spinlock_t *lists_lock = - eph ? &zbud_eph_lists_lock : &zbud_pers_lists_lock; - struct list_head *lru_list = - eph ? &zbud_eph_lru_list : &zbud_pers_lru_list; - - spin_lock_bh(lists_lock); - if (list_empty(lru_list)) - goto out; - list_for_each_entry_safe(zbudpage, zbudpag2, lru_list, lru) { - /* skip a locked zbudpage */ - if (unlikely(!zbudpage_spin_trylock(zbudpage))) - continue; - /* skip an unevictable zbudpage */ - if (unlikely(zbudpage->unevictable != 0)) { - zbudpage_spin_unlock(zbudpage); - continue; - } - /* got a locked evictable page */ - goto zombify_page; - } - /* no unlocked evictable pages, give up */ - goto out; - -zombify_page: - /* got an unlocked evictable page, zombify it */ - list_del_init(&zbudpage->budlist); - zbudpage_set_zombie(zbudpage); - /* FIXME what accounting do I need to do here? */ - list_del_init(&zbudpage->lru); - if (eph) { - list_add_tail(&zbudpage->lru, &zbud_eph_zombie_list); - zbud_eph_zombie_count = - atomic_inc_return(&zbud_eph_zombie_atomic); - } else { - list_add_tail(&zbudpage->lru, &zbud_pers_zombie_list); - zbud_pers_zombie_count = - atomic_inc_return(&zbud_pers_zombie_atomic); - } - /* FIXME what accounting do I need to do here? */ - zbpg = kmap_zbudpage_atomic(zbudpage); - for (i = 0; i < 2; i++) { - size = (i == 0) ? zbudpage->zbud0_size : zbudpage->zbud1_size; - if (size) { - from_va = zbud_data(zbpg, i, size); - thfrom = (struct tmem_handle *)from_va; - from_va += sizeof(struct tmem_handle); - size -= sizeof(struct tmem_handle); - if (th != NULL) - th[ret] = *thfrom; - if (data != NULL) - memcpy(data[ret], from_va, size); - if (zsize != NULL) - *zsize++ = size; - ret++; - } - } - kunmap_zbudpage_atomic(zbpg); - zbudpage_spin_unlock(zbudpage); -out: - spin_unlock_bh(lists_lock); - return ret; -} - -void zbud_init(void) -{ - int i; - - zbud_debugfs_init(); - BUG_ON((sizeof(struct tmem_handle) * 2 > CHUNK_SIZE)); - BUG_ON(sizeof(struct zbudpage) > sizeof(struct page)); - for (i = 0; i < NCHUNKS; i++) { - INIT_LIST_HEAD(&zbud_eph_unbuddied[i].list); - INIT_LIST_HEAD(&zbud_pers_unbuddied[i].list); - } -} diff --git a/drivers/staging/zcache/zbud.h b/drivers/staging/zcache/zbud.h deleted file mode 100644 index 891e8a7d5aa5d..0000000000000 --- a/drivers/staging/zcache/zbud.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * zbud.h - * - * Copyright (c) 2010-2012, Dan Magenheimer, Oracle Corp. - * - */ - -#ifndef _ZBUD_H_ -#define _ZBUD_H_ - -#include "tmem.h" - -struct zbudref; - -extern unsigned int zbud_max_buddy_size(void); -extern struct zbudref *zbud_match_prep(struct tmem_handle *th, bool eph, - void *cdata, unsigned size); -extern struct zbudref *zbud_create_prep(struct tmem_handle *th, bool eph, - void *cdata, unsigned size, - struct page *newpage); -extern void zbud_create_finish(struct zbudref *, bool); -extern int zbud_decompress(struct page *, struct zbudref *, bool, - void (*func)(char *, unsigned int, char *)); -extern int zbud_copy_from_zbud(char *, struct zbudref *, size_t *, bool); -extern int zbud_copy_to_zbud(struct zbudref *, char *, bool); -extern struct page *zbud_free_and_delist(struct zbudref *, bool eph, - unsigned int *, unsigned int *); -extern struct page *zbud_evict_pageframe_lru(unsigned int *, unsigned int *); -extern unsigned int zbud_make_zombie_lru(struct tmem_handle *, unsigned char **, - unsigned int *, bool); -extern void zbud_init(void); - -#endif /* _ZBUD_H_ */ diff --git a/drivers/staging/zcache/zcache-main.c b/drivers/staging/zcache/zcache-main.c deleted file mode 100644 index 81972fa47beba..0000000000000 --- a/drivers/staging/zcache/zcache-main.c +++ /dev/null @@ -1,1943 +0,0 @@ -/* - * zcache.c - * - * Copyright (c) 2010-2012, Dan Magenheimer, Oracle Corp. - * Copyright (c) 2010,2011, Nitin Gupta - * - * Zcache provides an in-kernel "host implementation" for transcendent memory - * ("tmem") and, thus indirectly, for cleancache and frontswap. Zcache uses - * lzo1x compression to improve density and an embedded allocator called - * "zbud" which "buddies" two compressed pages semi-optimally in each physical - * pageframe. Zbud is integrally tied into tmem to allow pageframes to - * be "reclaimed" efficiently. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include "tmem.h" -#include "zcache.h" -#include "zbud.h" -#include "ramster.h" -#include "debug.h" -#ifdef CONFIG_RAMSTER -static bool ramster_enabled __read_mostly; -static int disable_frontswap_selfshrink; -#else -#define ramster_enabled false -#define disable_frontswap_selfshrink 0 -#endif - -#ifndef __PG_WAS_ACTIVE -static inline bool PageWasActive(struct page *page) -{ - return true; -} - -static inline void SetPageWasActive(struct page *page) -{ -} -#endif - -#ifdef FRONTSWAP_HAS_EXCLUSIVE_GETS -static bool frontswap_has_exclusive_gets __read_mostly = true; -#else -static bool frontswap_has_exclusive_gets __read_mostly; -static inline void frontswap_tmem_exclusive_gets(bool b) -{ -} -#endif - -/* - * mark pampd to special value in order that later - * retrieve will identify zero-filled pages - */ -#define ZERO_FILLED 0x2 - -/* enable (or fix code) when Seth's patches are accepted upstream */ -#define zcache_writeback_enabled 0 - -static bool zcache_enabled __read_mostly; -static bool disable_cleancache __read_mostly; -static bool disable_frontswap __read_mostly; -static bool disable_frontswap_ignore_nonactive __read_mostly; -static bool disable_cleancache_ignore_nonactive __read_mostly; -static char *namestr __read_mostly = "zcache"; - -#define ZCACHE_GFP_MASK \ - (__GFP_FS | __GFP_NORETRY | __GFP_NOWARN | __GFP_NOMEMALLOC) - -/* crypto API for zcache */ -#ifdef CONFIG_ZCACHE_MODULE -static char *zcache_comp_name = "lzo"; -#else -#define ZCACHE_COMP_NAME_SZ CRYPTO_MAX_ALG_NAME -static char zcache_comp_name[ZCACHE_COMP_NAME_SZ] __read_mostly; -#endif -static struct crypto_comp * __percpu *zcache_comp_pcpu_tfms __read_mostly; - -enum comp_op { - ZCACHE_COMPOP_COMPRESS, - ZCACHE_COMPOP_DECOMPRESS -}; - -static inline int zcache_comp_op(enum comp_op op, - const u8 *src, unsigned int slen, - u8 *dst, unsigned int *dlen) -{ - struct crypto_comp *tfm; - int ret = -1; - - BUG_ON(!zcache_comp_pcpu_tfms); - tfm = *per_cpu_ptr(zcache_comp_pcpu_tfms, get_cpu()); - BUG_ON(!tfm); - switch (op) { - case ZCACHE_COMPOP_COMPRESS: - ret = crypto_comp_compress(tfm, src, slen, dst, dlen); - break; - case ZCACHE_COMPOP_DECOMPRESS: - ret = crypto_comp_decompress(tfm, src, slen, dst, dlen); - break; - default: - ret = -EINVAL; - } - put_cpu(); - return ret; -} - -/* - * policy parameters - */ - -/* - * byte count defining poor compression; pages with greater zsize will be - * rejected - */ -static unsigned int zbud_max_zsize __read_mostly = (PAGE_SIZE / 8) * 7; -/* - * byte count defining poor *mean* compression; pages with greater zsize - * will be rejected until sufficient better-compressed pages are accepted - * driving the mean below this threshold - */ -static unsigned int zbud_max_mean_zsize __read_mostly = (PAGE_SIZE / 8) * 5; - -/* - * for now, used named slabs so can easily track usage; later can - * either just use kmalloc, or perhaps add a slab-like allocator - * to more carefully manage total memory utilization - */ -static struct kmem_cache *zcache_objnode_cache; -static struct kmem_cache *zcache_obj_cache; - -static DEFINE_PER_CPU(struct zcache_preload, zcache_preloads) = { 0, }; - -/* Used by debug.c */ -ssize_t zcache_pers_zpages; -u64 zcache_pers_zbytes; -ssize_t zcache_eph_pageframes; -ssize_t zcache_pers_pageframes; - -/* Used by this code. */ -ssize_t zcache_last_active_file_pageframes; -ssize_t zcache_last_inactive_file_pageframes; -ssize_t zcache_last_active_anon_pageframes; -ssize_t zcache_last_inactive_anon_pageframes; -#ifdef CONFIG_ZCACHE_WRITEBACK -ssize_t zcache_writtenback_pages; -ssize_t zcache_outstanding_writeback_pages; -#endif -/* - * zcache core code starts here - */ - -static struct zcache_client zcache_host; -static struct zcache_client zcache_clients[MAX_CLIENTS]; - -static inline bool is_local_client(struct zcache_client *cli) -{ - return cli == &zcache_host; -} - -static struct zcache_client *zcache_get_client_by_id(uint16_t cli_id) -{ - struct zcache_client *cli = &zcache_host; - - if (cli_id != LOCAL_CLIENT) { - if (cli_id >= MAX_CLIENTS) - goto out; - cli = &zcache_clients[cli_id]; - } -out: - return cli; -} - -/* - * Tmem operations assume the poolid implies the invoking client. - * Zcache only has one client (the kernel itself): LOCAL_CLIENT. - * RAMster has each client numbered by cluster node, and a KVM version - * of zcache would have one client per guest and each client might - * have a poolid==N. - */ -struct tmem_pool *zcache_get_pool_by_id(uint16_t cli_id, uint16_t poolid) -{ - struct tmem_pool *pool = NULL; - struct zcache_client *cli = NULL; - - cli = zcache_get_client_by_id(cli_id); - if (cli == NULL) - goto out; - if (!is_local_client(cli)) - atomic_inc(&cli->refcount); - if (poolid < MAX_POOLS_PER_CLIENT) { - pool = cli->tmem_pools[poolid]; - if (pool != NULL) - atomic_inc(&pool->refcount); - } -out: - return pool; -} - -void zcache_put_pool(struct tmem_pool *pool) -{ - struct zcache_client *cli = NULL; - - if (pool == NULL) - BUG(); - cli = pool->client; - atomic_dec(&pool->refcount); - if (!is_local_client(cli)) - atomic_dec(&cli->refcount); -} - -int zcache_new_client(uint16_t cli_id) -{ - struct zcache_client *cli; - int ret = -1; - - cli = zcache_get_client_by_id(cli_id); - if (cli == NULL) - goto out; - if (cli->allocated) - goto out; - cli->allocated = 1; - ret = 0; -out: - return ret; -} - -/* - * zcache implementation for tmem host ops - */ - -static struct tmem_objnode *zcache_objnode_alloc(struct tmem_pool *pool) -{ - struct tmem_objnode *objnode = NULL; - struct zcache_preload *kp; - int i; - - kp = &__get_cpu_var(zcache_preloads); - for (i = 0; i < ARRAY_SIZE(kp->objnodes); i++) { - objnode = kp->objnodes[i]; - if (objnode != NULL) { - kp->objnodes[i] = NULL; - break; - } - } - BUG_ON(objnode == NULL); - inc_zcache_objnode_count(); - return objnode; -} - -static void zcache_objnode_free(struct tmem_objnode *objnode, - struct tmem_pool *pool) -{ - dec_zcache_objnode_count(); - kmem_cache_free(zcache_objnode_cache, objnode); -} - -static struct tmem_obj *zcache_obj_alloc(struct tmem_pool *pool) -{ - struct tmem_obj *obj = NULL; - struct zcache_preload *kp; - - kp = &__get_cpu_var(zcache_preloads); - obj = kp->obj; - BUG_ON(obj == NULL); - kp->obj = NULL; - inc_zcache_obj_count(); - return obj; -} - -static void zcache_obj_free(struct tmem_obj *obj, struct tmem_pool *pool) -{ - dec_zcache_obj_count(); - kmem_cache_free(zcache_obj_cache, obj); -} - -/* - * Compressing zero-filled pages will waste memory and introduce - * serious fragmentation, skip it to avoid overhead. - */ -static bool page_is_zero_filled(struct page *p) -{ - unsigned int pos; - char *page; - - page = kmap_atomic(p); - for (pos = 0; pos < PAGE_SIZE / sizeof(*page); pos++) { - if (page[pos]) { - kunmap_atomic(page); - return false; - } - } - kunmap_atomic(page); - - return true; -} - -static void handle_zero_filled_page(void *p) -{ - void *user_mem; - struct page *page = (struct page *)p; - - user_mem = kmap_atomic(page); - memset(user_mem, 0, PAGE_SIZE); - kunmap_atomic(user_mem); - - flush_dcache_page(page); -} - -static struct tmem_hostops zcache_hostops = { - .obj_alloc = zcache_obj_alloc, - .obj_free = zcache_obj_free, - .objnode_alloc = zcache_objnode_alloc, - .objnode_free = zcache_objnode_free, -}; - -static struct page *zcache_alloc_page(void) -{ - struct page *page = alloc_page(ZCACHE_GFP_MASK); - - if (page != NULL) - inc_zcache_pageframes_alloced(); - return page; -} - -static void zcache_free_page(struct page *page) -{ - long curr_pageframes; - static long max_pageframes, min_pageframes; - - if (page == NULL) - BUG(); - __free_page(page); - inc_zcache_pageframes_freed(); - curr_pageframes = curr_pageframes_count(); - if (curr_pageframes > max_pageframes) - max_pageframes = curr_pageframes; - if (curr_pageframes < min_pageframes) - min_pageframes = curr_pageframes; -#ifdef CONFIG_ZCACHE_DEBUG - if (curr_pageframes > 2L || curr_pageframes < -2L) { - /* pr_info here */ - } -#endif -} - -/* - * zcache implementations for PAM page descriptor ops - */ - -/* forward reference */ -static void zcache_compress(struct page *from, - void **out_va, unsigned *out_len); - -static struct page *zcache_evict_eph_pageframe(void); - -static void *zcache_pampd_eph_create(char *data, size_t size, bool raw, - struct tmem_handle *th) -{ - void *pampd = NULL, *cdata = data; - unsigned clen = size; - bool zero_filled = false; - struct page *page = (struct page *)(data), *newpage; - - if (page_is_zero_filled(page)) { - clen = 0; - zero_filled = true; - inc_zcache_zero_filled_pages(); - goto got_pampd; - } - - if (!raw) { - zcache_compress(page, &cdata, &clen); - if (clen > zbud_max_buddy_size()) { - inc_zcache_compress_poor(); - goto out; - } - } else { - BUG_ON(clen > zbud_max_buddy_size()); - } - - /* look for space via an existing match first */ - pampd = (void *)zbud_match_prep(th, true, cdata, clen); - if (pampd != NULL) - goto got_pampd; - - /* no match, now we need to find (or free up) a full page */ - newpage = zcache_alloc_page(); - if (newpage != NULL) - goto create_in_new_page; - - inc_zcache_failed_getfreepages(); - /* can't allocate a page, evict an ephemeral page via LRU */ - newpage = zcache_evict_eph_pageframe(); - if (newpage == NULL) { - inc_zcache_eph_ate_tail_failed(); - goto out; - } - inc_zcache_eph_ate_tail(); - -create_in_new_page: - pampd = (void *)zbud_create_prep(th, true, cdata, clen, newpage); - BUG_ON(pampd == NULL); - inc_zcache_eph_pageframes(); - -got_pampd: - inc_zcache_eph_zbytes(clen); - inc_zcache_eph_zpages(); - if (ramster_enabled && raw && !zero_filled) - ramster_count_foreign_pages(true, 1); - if (zero_filled) - pampd = (void *)ZERO_FILLED; -out: - return pampd; -} - -static void *zcache_pampd_pers_create(char *data, size_t size, bool raw, - struct tmem_handle *th) -{ - void *pampd = NULL, *cdata = data; - unsigned clen = size; - bool zero_filled = false; - struct page *page = (struct page *)(data), *newpage; - unsigned long zbud_mean_zsize; - unsigned long curr_pers_zpages, total_zsize; - - if (data == NULL) { - BUG_ON(!ramster_enabled); - goto create_pampd; - } - - if (page_is_zero_filled(page)) { - clen = 0; - zero_filled = true; - inc_zcache_zero_filled_pages(); - goto got_pampd; - } - - curr_pers_zpages = zcache_pers_zpages; -/* FIXME CONFIG_RAMSTER... subtract atomic remote_pers_pages here? */ - if (!raw) - zcache_compress(page, &cdata, &clen); - /* reject if compression is too poor */ - if (clen > zbud_max_zsize) { - inc_zcache_compress_poor(); - goto out; - } - /* reject if mean compression is too poor */ - if ((clen > zbud_max_mean_zsize) && (curr_pers_zpages > 0)) { - total_zsize = zcache_pers_zbytes; - if ((long)total_zsize < 0) - total_zsize = 0; - zbud_mean_zsize = div_u64(total_zsize, - curr_pers_zpages); - if (zbud_mean_zsize > zbud_max_mean_zsize) { - inc_zcache_mean_compress_poor(); - goto out; - } - } - -create_pampd: - /* look for space via an existing match first */ - pampd = (void *)zbud_match_prep(th, false, cdata, clen); - if (pampd != NULL) - goto got_pampd; - - /* no match, now we need to find (or free up) a full page */ - newpage = zcache_alloc_page(); - if (newpage != NULL) - goto create_in_new_page; - /* - * FIXME do the following only if eph is oversized? - * if (zcache_eph_pageframes > - * (global_page_state(NR_LRU_BASE + LRU_ACTIVE_FILE) + - * global_page_state(NR_LRU_BASE + LRU_INACTIVE_FILE))) - */ - inc_zcache_failed_getfreepages(); - /* can't allocate a page, evict an ephemeral page via LRU */ - newpage = zcache_evict_eph_pageframe(); - if (newpage == NULL) { - inc_zcache_pers_ate_eph_failed(); - goto out; - } - inc_zcache_pers_ate_eph(); - -create_in_new_page: - pampd = (void *)zbud_create_prep(th, false, cdata, clen, newpage); - BUG_ON(pampd == NULL); - inc_zcache_pers_pageframes(); - -got_pampd: - inc_zcache_pers_zpages(); - inc_zcache_pers_zbytes(clen); - if (ramster_enabled && raw && !zero_filled) - ramster_count_foreign_pages(false, 1); - if (zero_filled) - pampd = (void *)ZERO_FILLED; -out: - return pampd; -} - -/* - * This is called directly from zcache_put_page to pre-allocate space - * to store a zpage. - */ -void *zcache_pampd_create(char *data, unsigned int size, bool raw, - int eph, struct tmem_handle *th) -{ - void *pampd = NULL; - struct zcache_preload *kp; - struct tmem_objnode *objnode; - struct tmem_obj *obj; - int i; - - BUG_ON(!irqs_disabled()); - /* pre-allocate per-cpu metadata */ - BUG_ON(zcache_objnode_cache == NULL); - BUG_ON(zcache_obj_cache == NULL); - kp = &__get_cpu_var(zcache_preloads); - for (i = 0; i < ARRAY_SIZE(kp->objnodes); i++) { - objnode = kp->objnodes[i]; - if (objnode == NULL) { - objnode = kmem_cache_alloc(zcache_objnode_cache, - ZCACHE_GFP_MASK); - if (unlikely(objnode == NULL)) { - inc_zcache_failed_alloc(); - goto out; - } - kp->objnodes[i] = objnode; - } - } - if (kp->obj == NULL) { - obj = kmem_cache_alloc(zcache_obj_cache, ZCACHE_GFP_MASK); - kp->obj = obj; - } - if (unlikely(kp->obj == NULL)) { - inc_zcache_failed_alloc(); - goto out; - } - /* - * ok, have all the metadata pre-allocated, now do the data - * but since how we allocate the data is dependent on ephemeral - * or persistent, we split the call here to different sub-functions - */ - if (eph) - pampd = zcache_pampd_eph_create(data, size, raw, th); - else - pampd = zcache_pampd_pers_create(data, size, raw, th); -out: - return pampd; -} - -/* - * This is a pamops called via tmem_put and is necessary to "finish" - * a pampd creation. - */ -void zcache_pampd_create_finish(void *pampd, bool eph) -{ - if (pampd != (void *)ZERO_FILLED) - zbud_create_finish((struct zbudref *)pampd, eph); -} - -/* - * This is passed as a function parameter to zbud_decompress so that - * zbud need not be familiar with the details of crypto. It assumes that - * the bytes from_va and to_va through from_va+size-1 and to_va+size-1 are - * kmapped. It must be successful, else there is a logic bug somewhere. - */ -static void zcache_decompress(char *from_va, unsigned int size, char *to_va) -{ - int ret; - unsigned int outlen = PAGE_SIZE; - - ret = zcache_comp_op(ZCACHE_COMPOP_DECOMPRESS, from_va, size, - to_va, &outlen); - BUG_ON(ret); - BUG_ON(outlen != PAGE_SIZE); -} - -/* - * Decompress from the kernel va to a pageframe - */ -void zcache_decompress_to_page(char *from_va, unsigned int size, - struct page *to_page) -{ - char *to_va = kmap_atomic(to_page); - zcache_decompress(from_va, size, to_va); - kunmap_atomic(to_va); -} - -/* - * fill the pageframe corresponding to the struct page with the data - * from the passed pampd - */ -static int zcache_pampd_get_data(char *data, size_t *sizep, bool raw, - void *pampd, struct tmem_pool *pool, - struct tmem_oid *oid, uint32_t index) -{ - int ret; - bool eph = !is_persistent(pool); - - BUG_ON(preemptible()); - BUG_ON(eph); /* fix later if shared pools get implemented */ - BUG_ON(pampd_is_remote(pampd)); - - if (pampd == (void *)ZERO_FILLED) { - handle_zero_filled_page(data); - if (!raw) - *sizep = PAGE_SIZE; - return 0; - } - - if (raw) - ret = zbud_copy_from_zbud(data, (struct zbudref *)pampd, - sizep, eph); - else { - ret = zbud_decompress((struct page *)(data), - (struct zbudref *)pampd, false, - zcache_decompress); - *sizep = PAGE_SIZE; - } - return ret; -} - -/* - * fill the pageframe corresponding to the struct page with the data - * from the passed pampd - */ -static int zcache_pampd_get_data_and_free(char *data, size_t *sizep, bool raw, - void *pampd, struct tmem_pool *pool, - struct tmem_oid *oid, uint32_t index) -{ - int ret = 0; - bool eph = !is_persistent(pool), zero_filled = false; - struct page *page = NULL; - unsigned int zsize, zpages; - - BUG_ON(preemptible()); - BUG_ON(pampd_is_remote(pampd)); - - if (pampd == (void *)ZERO_FILLED) { - handle_zero_filled_page(data); - zero_filled = true; - zsize = 0; - zpages = 1; - if (!raw) - *sizep = PAGE_SIZE; - dec_zcache_zero_filled_pages(); - goto zero_fill; - } - - if (raw) - ret = zbud_copy_from_zbud(data, (struct zbudref *)pampd, - sizep, eph); - else { - ret = zbud_decompress((struct page *)(data), - (struct zbudref *)pampd, eph, - zcache_decompress); - *sizep = PAGE_SIZE; - } - page = zbud_free_and_delist((struct zbudref *)pampd, eph, - &zsize, &zpages); -zero_fill: - if (eph) { - if (page) - dec_zcache_eph_pageframes(); - dec_zcache_eph_zpages(zpages); - dec_zcache_eph_zbytes(zsize); - } else { - if (page) - dec_zcache_pers_pageframes(); - dec_zcache_pers_zpages(zpages); - dec_zcache_pers_zbytes(zsize); - } - if (!is_local_client(pool->client) && !zero_filled) - ramster_count_foreign_pages(eph, -1); - if (page && !zero_filled) - zcache_free_page(page); - return ret; -} - -/* - * free the pampd and remove it from any zcache lists - * pampd must no longer be pointed to from any tmem data structures! - */ -static void zcache_pampd_free(void *pampd, struct tmem_pool *pool, - struct tmem_oid *oid, uint32_t index, bool acct) -{ - struct page *page = NULL; - unsigned int zsize, zpages; - bool zero_filled = false; - - BUG_ON(preemptible()); - - if (pampd == (void *)ZERO_FILLED) { - zero_filled = true; - zsize = 0; - zpages = 1; - dec_zcache_zero_filled_pages(); - } - - if (pampd_is_remote(pampd) && !zero_filled) { - BUG_ON(!ramster_enabled); - pampd = ramster_pampd_free(pampd, pool, oid, index, acct); - if (pampd == NULL) - return; - } - if (is_ephemeral(pool)) { - if (!zero_filled) - page = zbud_free_and_delist((struct zbudref *)pampd, - true, &zsize, &zpages); - if (page) - dec_zcache_eph_pageframes(); - dec_zcache_eph_zpages(zpages); - dec_zcache_eph_zbytes(zsize); - /* FIXME CONFIG_RAMSTER... check acct parameter? */ - } else { - if (!zero_filled) - page = zbud_free_and_delist((struct zbudref *)pampd, - false, &zsize, &zpages); - if (page) - dec_zcache_pers_pageframes(); - dec_zcache_pers_zpages(zpages); - dec_zcache_pers_zbytes(zsize); - } - if (!is_local_client(pool->client) && !zero_filled) - ramster_count_foreign_pages(is_ephemeral(pool), -1); - if (page && !zero_filled) - zcache_free_page(page); -} - -static struct tmem_pamops zcache_pamops = { - .create_finish = zcache_pampd_create_finish, - .get_data = zcache_pampd_get_data, - .get_data_and_free = zcache_pampd_get_data_and_free, - .free = zcache_pampd_free, -}; - -/* - * zcache compression/decompression and related per-cpu stuff - */ - -static DEFINE_PER_CPU(unsigned char *, zcache_dstmem); -#define ZCACHE_DSTMEM_ORDER 1 - -static void zcache_compress(struct page *from, void **out_va, unsigned *out_len) -{ - int ret; - unsigned char *dmem = __get_cpu_var(zcache_dstmem); - char *from_va; - - BUG_ON(!irqs_disabled()); - /* no buffer or no compressor so can't compress */ - BUG_ON(dmem == NULL); - *out_len = PAGE_SIZE << ZCACHE_DSTMEM_ORDER; - from_va = kmap_atomic(from); - mb(); - ret = zcache_comp_op(ZCACHE_COMPOP_COMPRESS, from_va, PAGE_SIZE, dmem, - out_len); - BUG_ON(ret); - *out_va = dmem; - kunmap_atomic(from_va); -} - -static int zcache_comp_cpu_up(int cpu) -{ - struct crypto_comp *tfm; - - tfm = crypto_alloc_comp(zcache_comp_name, 0, 0); - if (IS_ERR(tfm)) - return NOTIFY_BAD; - *per_cpu_ptr(zcache_comp_pcpu_tfms, cpu) = tfm; - return NOTIFY_OK; -} - -static void zcache_comp_cpu_down(int cpu) -{ - struct crypto_comp *tfm; - - tfm = *per_cpu_ptr(zcache_comp_pcpu_tfms, cpu); - crypto_free_comp(tfm); - *per_cpu_ptr(zcache_comp_pcpu_tfms, cpu) = NULL; -} - -static int zcache_cpu_notifier(struct notifier_block *nb, - unsigned long action, void *pcpu) -{ - int ret, i, cpu = (long)pcpu; - struct zcache_preload *kp; - - switch (action) { - case CPU_UP_PREPARE: - ret = zcache_comp_cpu_up(cpu); - if (ret != NOTIFY_OK) { - pr_err("%s: can't allocate compressor xform\n", - namestr); - return ret; - } - per_cpu(zcache_dstmem, cpu) = (void *)__get_free_pages( - GFP_KERNEL | __GFP_REPEAT, ZCACHE_DSTMEM_ORDER); - if (ramster_enabled) - ramster_cpu_up(cpu); - break; - case CPU_DEAD: - case CPU_UP_CANCELED: - zcache_comp_cpu_down(cpu); - free_pages((unsigned long)per_cpu(zcache_dstmem, cpu), - ZCACHE_DSTMEM_ORDER); - per_cpu(zcache_dstmem, cpu) = NULL; - kp = &per_cpu(zcache_preloads, cpu); - for (i = 0; i < ARRAY_SIZE(kp->objnodes); i++) { - if (kp->objnodes[i]) - kmem_cache_free(zcache_objnode_cache, - kp->objnodes[i]); - } - if (kp->obj) { - kmem_cache_free(zcache_obj_cache, kp->obj); - kp->obj = NULL; - } - if (ramster_enabled) - ramster_cpu_down(cpu); - break; - default: - break; - } - return NOTIFY_OK; -} - -static struct notifier_block zcache_cpu_notifier_block = { - .notifier_call = zcache_cpu_notifier -}; - -/* - * The following code interacts with the zbud eviction and zbud - * zombify code to access LRU pages - */ - -static struct page *zcache_evict_eph_pageframe(void) -{ - struct page *page; - unsigned int zsize = 0, zpages = 0; - - page = zbud_evict_pageframe_lru(&zsize, &zpages); - if (page == NULL) - goto out; - dec_zcache_eph_zbytes(zsize); - dec_zcache_eph_zpages(zpages); - inc_zcache_evicted_eph_zpages(zpages); - dec_zcache_eph_pageframes(); - inc_zcache_evicted_eph_pageframes(); -out: - return page; -} - -#ifdef CONFIG_ZCACHE_WRITEBACK - -static atomic_t zcache_outstanding_writeback_pages_atomic = ATOMIC_INIT(0); - -static inline void inc_zcache_outstanding_writeback_pages(void) -{ - zcache_outstanding_writeback_pages = - atomic_inc_return(&zcache_outstanding_writeback_pages_atomic); -} -static inline void dec_zcache_outstanding_writeback_pages(void) -{ - zcache_outstanding_writeback_pages = - atomic_dec_return(&zcache_outstanding_writeback_pages_atomic); -}; -static void unswiz(struct tmem_oid oid, u32 index, - unsigned *type, pgoff_t *offset); - -/* - * Choose an LRU persistent pageframe and attempt to write it back to - * the backing swap disk by calling frontswap_writeback on both zpages. - * - * This is work-in-progress. - */ - -static void zcache_end_swap_write(struct bio *bio, int err) -{ - end_swap_bio_write(bio, err); - dec_zcache_outstanding_writeback_pages(); - zcache_writtenback_pages++; -} - -/* - * zcache_get_swap_cache_page - * - * This is an adaption of read_swap_cache_async() - * - * If success, page is returned in retpage - * Returns 0 if page was already in the swap cache, page is not locked - * Returns 1 if the new page needs to be populated, page is locked - */ -static int zcache_get_swap_cache_page(int type, pgoff_t offset, - struct page *new_page) -{ - struct page *found_page; - swp_entry_t entry = swp_entry(type, offset); - int err; - - BUG_ON(new_page == NULL); - do { - /* - * First check the swap cache. Since this is normally - * called after lookup_swap_cache() failed, re-calling - * that would confuse statistics. - */ - found_page = find_get_page(&swapper_space, entry.val); - if (found_page) - return 0; - - /* - * call radix_tree_preload() while we can wait. - */ - err = radix_tree_preload(GFP_KERNEL); - if (err) - break; - - /* - * Swap entry may have been freed since our caller observed it. - */ - err = swapcache_prepare(entry); - if (err == -EEXIST) { /* seems racy */ - radix_tree_preload_end(); - continue; - } - if (err) { /* swp entry is obsolete ? */ - radix_tree_preload_end(); - break; - } - - /* May fail (-ENOMEM) if radix-tree node allocation failed. */ - __set_page_locked(new_page); - SetPageSwapBacked(new_page); - err = __add_to_swap_cache(new_page, entry); - if (likely(!err)) { - radix_tree_preload_end(); - lru_cache_add_anon(new_page); - return 1; - } - radix_tree_preload_end(); - ClearPageSwapBacked(new_page); - __clear_page_locked(new_page); - /* - * add_to_swap_cache() doesn't return -EEXIST, so we can safely - * clear SWAP_HAS_CACHE flag. - */ - swapcache_free(entry, NULL); - /* FIXME: is it possible to get here without err==-ENOMEM? - * If not, we can dispense with the do loop, use goto retry */ - } while (err != -ENOMEM); - - return -ENOMEM; -} - -/* - * Given a frontswap zpage in zcache (identified by type/offset) and - * an empty page, put the page into the swap cache, use frontswap - * to get the page from zcache into the empty page, then give it - * to the swap subsystem to send to disk (carefully avoiding the - * possibility that frontswap might snatch it back). - * Returns < 0 if error, 0 if successful, and 1 if successful but - * the newpage passed in not needed and should be freed. - */ -static int zcache_frontswap_writeback_zpage(int type, pgoff_t offset, - struct page *newpage) -{ - struct page *page = newpage; - int ret; - struct writeback_control wbc = { - .sync_mode = WB_SYNC_NONE, - }; - - ret = zcache_get_swap_cache_page(type, offset, page); - if (ret < 0) - return ret; - else if (ret == 0) { - /* more uptodate page is already in swapcache */ - __frontswap_invalidate_page(type, offset); - return 1; - } - - BUG_ON(!frontswap_has_exclusive_gets); /* load must also invalidate */ - /* FIXME: how is it possible to get here when page is unlocked? */ - __frontswap_load(page); - SetPageUptodate(page); /* above does SetPageDirty, is that enough? */ - - /* start writeback */ - SetPageReclaim(page); - /* - * Return value is ignored here because it doesn't change anything - * for us. Page is returned unlocked. - */ - (void)__swap_writepage(page, &wbc, zcache_end_swap_write); - page_cache_release(page); - inc_zcache_outstanding_writeback_pages(); - - return 0; -} - -/* - * The following is still a magic number... we want to allow forward progress - * for writeback because it clears out needed RAM when under pressure, but - * we don't want to allow writeback to absorb and queue too many GFP_KERNEL - * pages if the swap device is very slow. - */ -#define ZCACHE_MAX_OUTSTANDING_WRITEBACK_PAGES 6400 - -/* - * Try to allocate two free pages, first using a non-aggressive alloc, - * then by evicting zcache ephemeral (clean pagecache) pages, and last - * by aggressive GFP_KERNEL alloc. We allow zbud to choose a pageframe - * consisting of 1-2 zbuds/zpages, then call the writeback_zpage helper - * function above for each. - */ -static int zcache_frontswap_writeback(void) -{ - struct tmem_handle th[2]; - int ret = 0; - int nzbuds, writeback_ret; - unsigned type; - struct page *znewpage1 = NULL, *znewpage2 = NULL; - struct page *evictpage1 = NULL, *evictpage2 = NULL; - struct page *newpage1 = NULL, *newpage2 = NULL; - struct page *page1 = NULL, *page2 = NULL; - pgoff_t offset; - - znewpage1 = alloc_page(ZCACHE_GFP_MASK); - znewpage2 = alloc_page(ZCACHE_GFP_MASK); - if (znewpage1 == NULL) - evictpage1 = zcache_evict_eph_pageframe(); - if (znewpage2 == NULL) - evictpage2 = zcache_evict_eph_pageframe(); - - if ((evictpage1 == NULL || evictpage2 == NULL) && - atomic_read(&zcache_outstanding_writeback_pages_atomic) > - ZCACHE_MAX_OUTSTANDING_WRITEBACK_PAGES) { - goto free_and_out; - } - if (znewpage1 == NULL && evictpage1 == NULL) - newpage1 = alloc_page(GFP_KERNEL); - if (znewpage2 == NULL && evictpage2 == NULL) - newpage2 = alloc_page(GFP_KERNEL); - if (newpage1 == NULL || newpage2 == NULL) - goto free_and_out; - - /* ok, we have two pageframes pre-allocated, get a pair of zbuds */ - nzbuds = zbud_make_zombie_lru(&th[0], NULL, NULL, false); - if (nzbuds == 0) { - ret = -ENOENT; - goto free_and_out; - } - - /* process the first zbud */ - unswiz(th[0].oid, th[0].index, &type, &offset); - page1 = (znewpage1 != NULL) ? znewpage1 : - ((newpage1 != NULL) ? newpage1 : evictpage1); - writeback_ret = zcache_frontswap_writeback_zpage(type, offset, page1); - if (writeback_ret < 0) { - ret = -ENOMEM; - goto free_and_out; - } - if (evictpage1 != NULL) - zcache_pageframes_freed = - atomic_inc_return(&zcache_pageframes_freed_atomic); - if (writeback_ret == 0) { - /* zcache_get_swap_cache_page will free, don't double free */ - znewpage1 = NULL; - newpage1 = NULL; - evictpage1 = NULL; - } - if (nzbuds < 2) - goto free_and_out; - - /* if there is a second zbud, process it */ - unswiz(th[1].oid, th[1].index, &type, &offset); - page2 = (znewpage2 != NULL) ? znewpage2 : - ((newpage2 != NULL) ? newpage2 : evictpage2); - writeback_ret = zcache_frontswap_writeback_zpage(type, offset, page2); - if (writeback_ret < 0) { - ret = -ENOMEM; - goto free_and_out; - } - if (evictpage2 != NULL) - zcache_pageframes_freed = - atomic_inc_return(&zcache_pageframes_freed_atomic); - if (writeback_ret == 0) { - znewpage2 = NULL; - newpage2 = NULL; - evictpage2 = NULL; - } - -free_and_out: - if (znewpage1 != NULL) - page_cache_release(znewpage1); - if (znewpage2 != NULL) - page_cache_release(znewpage2); - if (newpage1 != NULL) - page_cache_release(newpage1); - if (newpage2 != NULL) - page_cache_release(newpage2); - if (evictpage1 != NULL) - zcache_free_page(evictpage1); - if (evictpage2 != NULL) - zcache_free_page(evictpage2); - return ret; -} -#endif /* CONFIG_ZCACHE_WRITEBACK */ - -/* - * When zcache is disabled ("frozen"), pools can be created and destroyed, - * but all puts (and thus all other operations that require memory allocation) - * must fail. If zcache is unfrozen, accepts puts, then frozen again, - * data consistency requires all puts while frozen to be converted into - * flushes. - */ -static bool zcache_freeze; - -/* - * This zcache shrinker interface reduces the number of ephemeral pageframes - * used by zcache to approximately the same as the total number of LRU_FILE - * pageframes in use, and now also reduces the number of persistent pageframes - * used by zcache to approximately the same as the total number of LRU_ANON - * pageframes in use. FIXME POLICY: Probably the writeback should only occur - * if the eviction doesn't free enough pages. - */ -static int shrink_zcache_memory(struct shrinker *shrink, - struct shrink_control *sc) -{ - static bool in_progress; - int ret = -1; - int nr = sc->nr_to_scan; - int nr_evict = 0; - int nr_writeback = 0; - struct page *page; - int file_pageframes_inuse, anon_pageframes_inuse; - - if (nr <= 0) - goto skip_evict; - - /* don't allow more than one eviction thread at a time */ - if (in_progress) - goto skip_evict; - - in_progress = true; - - /* we are going to ignore nr, and target a different value */ - zcache_last_active_file_pageframes = - global_page_state(NR_LRU_BASE + LRU_ACTIVE_FILE); - zcache_last_inactive_file_pageframes = - global_page_state(NR_LRU_BASE + LRU_INACTIVE_FILE); - file_pageframes_inuse = zcache_last_active_file_pageframes + - zcache_last_inactive_file_pageframes; - if (zcache_eph_pageframes > file_pageframes_inuse) - nr_evict = zcache_eph_pageframes - file_pageframes_inuse; - else - nr_evict = 0; - while (nr_evict-- > 0) { - page = zcache_evict_eph_pageframe(); - if (page == NULL) - break; - zcache_free_page(page); - } - - zcache_last_active_anon_pageframes = - global_page_state(NR_LRU_BASE + LRU_ACTIVE_ANON); - zcache_last_inactive_anon_pageframes = - global_page_state(NR_LRU_BASE + LRU_INACTIVE_ANON); - anon_pageframes_inuse = zcache_last_active_anon_pageframes + - zcache_last_inactive_anon_pageframes; - if (zcache_pers_pageframes > anon_pageframes_inuse) - nr_writeback = zcache_pers_pageframes - anon_pageframes_inuse; - else - nr_writeback = 0; - while (nr_writeback-- > 0) { -#ifdef CONFIG_ZCACHE_WRITEBACK - int writeback_ret; - writeback_ret = zcache_frontswap_writeback(); - if (writeback_ret == -ENOMEM) -#endif - break; - } - in_progress = false; - -skip_evict: - /* resample: has changed, but maybe not all the way yet */ - zcache_last_active_file_pageframes = - global_page_state(NR_LRU_BASE + LRU_ACTIVE_FILE); - zcache_last_inactive_file_pageframes = - global_page_state(NR_LRU_BASE + LRU_INACTIVE_FILE); - ret = zcache_eph_pageframes - zcache_last_active_file_pageframes + - zcache_last_inactive_file_pageframes; - if (ret < 0) - ret = 0; - return ret; -} - -static struct shrinker zcache_shrinker = { - .shrink = shrink_zcache_memory, - .seeks = DEFAULT_SEEKS, -}; - -/* - * zcache shims between cleancache/frontswap ops and tmem - */ - -/* FIXME rename these core routines to zcache_tmemput etc? */ -int zcache_put_page(int cli_id, int pool_id, struct tmem_oid *oidp, - uint32_t index, void *page, - unsigned int size, bool raw, int ephemeral) -{ - struct tmem_pool *pool; - struct tmem_handle th; - int ret = -1; - void *pampd = NULL; - - BUG_ON(!irqs_disabled()); - pool = zcache_get_pool_by_id(cli_id, pool_id); - if (unlikely(pool == NULL)) - goto out; - if (!zcache_freeze) { - ret = 0; - th.client_id = cli_id; - th.pool_id = pool_id; - th.oid = *oidp; - th.index = index; - pampd = zcache_pampd_create((char *)page, size, raw, - ephemeral, &th); - if (pampd == NULL) { - ret = -ENOMEM; - if (ephemeral) - inc_zcache_failed_eph_puts(); - else - inc_zcache_failed_pers_puts(); - } else { - if (ramster_enabled) - ramster_do_preload_flnode(pool); - ret = tmem_put(pool, oidp, index, 0, pampd); - if (ret < 0) - BUG(); - } - zcache_put_pool(pool); - } else { - inc_zcache_put_to_flush(); - if (ramster_enabled) - ramster_do_preload_flnode(pool); - if (atomic_read(&pool->obj_count) > 0) - /* the put fails whether the flush succeeds or not */ - (void)tmem_flush_page(pool, oidp, index); - zcache_put_pool(pool); - } -out: - return ret; -} - -int zcache_get_page(int cli_id, int pool_id, struct tmem_oid *oidp, - uint32_t index, void *page, - size_t *sizep, bool raw, int get_and_free) -{ - struct tmem_pool *pool; - int ret = -1; - bool eph; - - if (!raw) { - BUG_ON(irqs_disabled()); - BUG_ON(in_softirq()); - } - pool = zcache_get_pool_by_id(cli_id, pool_id); - eph = is_ephemeral(pool); - if (likely(pool != NULL)) { - if (atomic_read(&pool->obj_count) > 0) - ret = tmem_get(pool, oidp, index, (char *)(page), - sizep, raw, get_and_free); - zcache_put_pool(pool); - } - WARN_ONCE((!is_ephemeral(pool) && (ret != 0)), - "zcache_get fails on persistent pool, " - "bad things are very likely to happen soon\n"); -#ifdef RAMSTER_TESTING - if (ret != 0 && ret != -1 && !(ret == -EINVAL && is_ephemeral(pool))) - pr_err("TESTING zcache_get tmem_get returns ret=%d\n", ret); -#endif - return ret; -} - -int zcache_flush_page(int cli_id, int pool_id, - struct tmem_oid *oidp, uint32_t index) -{ - struct tmem_pool *pool; - int ret = -1; - unsigned long flags; - - local_irq_save(flags); - inc_zcache_flush_total(); - pool = zcache_get_pool_by_id(cli_id, pool_id); - if (ramster_enabled) - ramster_do_preload_flnode(pool); - if (likely(pool != NULL)) { - if (atomic_read(&pool->obj_count) > 0) - ret = tmem_flush_page(pool, oidp, index); - zcache_put_pool(pool); - } - if (ret >= 0) - inc_zcache_flush_found(); - local_irq_restore(flags); - return ret; -} - -int zcache_flush_object(int cli_id, int pool_id, - struct tmem_oid *oidp) -{ - struct tmem_pool *pool; - int ret = -1; - unsigned long flags; - - local_irq_save(flags); - inc_zcache_flobj_total(); - pool = zcache_get_pool_by_id(cli_id, pool_id); - if (ramster_enabled) - ramster_do_preload_flnode(pool); - if (likely(pool != NULL)) { - if (atomic_read(&pool->obj_count) > 0) - ret = tmem_flush_object(pool, oidp); - zcache_put_pool(pool); - } - if (ret >= 0) - inc_zcache_flobj_found(); - local_irq_restore(flags); - return ret; -} - -static int zcache_client_destroy_pool(int cli_id, int pool_id) -{ - struct tmem_pool *pool = NULL; - struct zcache_client *cli = NULL; - int ret = -1; - - if (pool_id < 0) - goto out; - if (cli_id == LOCAL_CLIENT) - cli = &zcache_host; - else if ((unsigned int)cli_id < MAX_CLIENTS) - cli = &zcache_clients[cli_id]; - if (cli == NULL) - goto out; - atomic_inc(&cli->refcount); - pool = cli->tmem_pools[pool_id]; - if (pool == NULL) - goto out; - cli->tmem_pools[pool_id] = NULL; - /* wait for pool activity on other cpus to quiesce */ - while (atomic_read(&pool->refcount) != 0) - ; - atomic_dec(&cli->refcount); - local_bh_disable(); - ret = tmem_destroy_pool(pool); - local_bh_enable(); - kfree(pool); - if (cli_id == LOCAL_CLIENT) - pr_info("%s: destroyed local pool id=%d\n", namestr, pool_id); - else - pr_info("%s: destroyed pool id=%d, client=%d\n", - namestr, pool_id, cli_id); -out: - return ret; -} - -int zcache_new_pool(uint16_t cli_id, uint32_t flags) -{ - int poolid = -1; - struct tmem_pool *pool; - struct zcache_client *cli = NULL; - - if (cli_id == LOCAL_CLIENT) - cli = &zcache_host; - else if ((unsigned int)cli_id < MAX_CLIENTS) - cli = &zcache_clients[cli_id]; - if (cli == NULL) - goto out; - atomic_inc(&cli->refcount); - pool = kmalloc(sizeof(struct tmem_pool), GFP_ATOMIC); - if (pool == NULL) - goto out; - - for (poolid = 0; poolid < MAX_POOLS_PER_CLIENT; poolid++) - if (cli->tmem_pools[poolid] == NULL) - break; - if (poolid >= MAX_POOLS_PER_CLIENT) { - pr_info("%s: pool creation failed: max exceeded\n", namestr); - kfree(pool); - poolid = -1; - goto out; - } - atomic_set(&pool->refcount, 0); - pool->client = cli; - pool->pool_id = poolid; - tmem_new_pool(pool, flags); - cli->tmem_pools[poolid] = pool; - if (cli_id == LOCAL_CLIENT) - pr_info("%s: created %s local tmem pool, id=%d\n", namestr, - flags & TMEM_POOL_PERSIST ? "persistent" : "ephemeral", - poolid); - else - pr_info("%s: created %s tmem pool, id=%d, client=%d\n", namestr, - flags & TMEM_POOL_PERSIST ? "persistent" : "ephemeral", - poolid, cli_id); -out: - if (cli != NULL) - atomic_dec(&cli->refcount); - return poolid; -} - -static int zcache_local_new_pool(uint32_t flags) -{ - return zcache_new_pool(LOCAL_CLIENT, flags); -} - -int zcache_autocreate_pool(unsigned int cli_id, unsigned int pool_id, bool eph) -{ - struct tmem_pool *pool; - struct zcache_client *cli = NULL; - uint32_t flags = eph ? 0 : TMEM_POOL_PERSIST; - int ret = -1; - - BUG_ON(!ramster_enabled); - if (cli_id == LOCAL_CLIENT) - goto out; - if (pool_id >= MAX_POOLS_PER_CLIENT) - goto out; - if (cli_id >= MAX_CLIENTS) - goto out; - - cli = &zcache_clients[cli_id]; - if ((eph && disable_cleancache) || (!eph && disable_frontswap)) { - pr_err("zcache_autocreate_pool: pool type disabled\n"); - goto out; - } - if (!cli->allocated) { - if (zcache_new_client(cli_id)) { - pr_err("zcache_autocreate_pool: can't create client\n"); - goto out; - } - cli = &zcache_clients[cli_id]; - } - atomic_inc(&cli->refcount); - pool = cli->tmem_pools[pool_id]; - if (pool != NULL) { - if (pool->persistent && eph) { - pr_err("zcache_autocreate_pool: type mismatch\n"); - goto out; - } - ret = 0; - goto out; - } - pool = kmalloc(sizeof(struct tmem_pool), GFP_KERNEL); - if (pool == NULL) - goto out; - - atomic_set(&pool->refcount, 0); - pool->client = cli; - pool->pool_id = pool_id; - tmem_new_pool(pool, flags); - cli->tmem_pools[pool_id] = pool; - pr_info("%s: AUTOcreated %s tmem poolid=%d, for remote client=%d\n", - namestr, flags & TMEM_POOL_PERSIST ? "persistent" : "ephemeral", - pool_id, cli_id); - ret = 0; -out: - if (cli != NULL) - atomic_dec(&cli->refcount); - return ret; -} - -/********** - * Two kernel functionalities currently can be layered on top of tmem. - * These are "cleancache" which is used as a second-chance cache for clean - * page cache pages; and "frontswap" which is used for swap pages - * to avoid writes to disk. A generic "shim" is provided here for each - * to translate in-kernel semantics to zcache semantics. - */ - -static void zcache_cleancache_put_page(int pool_id, - struct cleancache_filekey key, - pgoff_t index, struct page *page) -{ - u32 ind = (u32) index; - struct tmem_oid oid = *(struct tmem_oid *)&key; - - if (!disable_cleancache_ignore_nonactive && !PageWasActive(page)) { - inc_zcache_eph_nonactive_puts_ignored(); - return; - } - if (likely(ind == index)) - (void)zcache_put_page(LOCAL_CLIENT, pool_id, &oid, index, - page, PAGE_SIZE, false, 1); -} - -static int zcache_cleancache_get_page(int pool_id, - struct cleancache_filekey key, - pgoff_t index, struct page *page) -{ - u32 ind = (u32) index; - struct tmem_oid oid = *(struct tmem_oid *)&key; - size_t size; - int ret = -1; - - if (likely(ind == index)) { - ret = zcache_get_page(LOCAL_CLIENT, pool_id, &oid, index, - page, &size, false, 0); - BUG_ON(ret >= 0 && size != PAGE_SIZE); - if (ret == 0) - SetPageWasActive(page); - } - return ret; -} - -static void zcache_cleancache_flush_page(int pool_id, - struct cleancache_filekey key, - pgoff_t index) -{ - u32 ind = (u32) index; - struct tmem_oid oid = *(struct tmem_oid *)&key; - - if (likely(ind == index)) - (void)zcache_flush_page(LOCAL_CLIENT, pool_id, &oid, ind); -} - -static void zcache_cleancache_flush_inode(int pool_id, - struct cleancache_filekey key) -{ - struct tmem_oid oid = *(struct tmem_oid *)&key; - - (void)zcache_flush_object(LOCAL_CLIENT, pool_id, &oid); -} - -static void zcache_cleancache_flush_fs(int pool_id) -{ - if (pool_id >= 0) - (void)zcache_client_destroy_pool(LOCAL_CLIENT, pool_id); -} - -static int zcache_cleancache_init_fs(size_t pagesize) -{ - BUG_ON(sizeof(struct cleancache_filekey) != - sizeof(struct tmem_oid)); - BUG_ON(pagesize != PAGE_SIZE); - return zcache_local_new_pool(0); -} - -static int zcache_cleancache_init_shared_fs(char *uuid, size_t pagesize) -{ - /* shared pools are unsupported and map to private */ - BUG_ON(sizeof(struct cleancache_filekey) != - sizeof(struct tmem_oid)); - BUG_ON(pagesize != PAGE_SIZE); - return zcache_local_new_pool(0); -} - -static struct cleancache_ops zcache_cleancache_ops = { - .put_page = zcache_cleancache_put_page, - .get_page = zcache_cleancache_get_page, - .invalidate_page = zcache_cleancache_flush_page, - .invalidate_inode = zcache_cleancache_flush_inode, - .invalidate_fs = zcache_cleancache_flush_fs, - .init_shared_fs = zcache_cleancache_init_shared_fs, - .init_fs = zcache_cleancache_init_fs -}; - -struct cleancache_ops *zcache_cleancache_register_ops(void) -{ - struct cleancache_ops *old_ops = - cleancache_register_ops(&zcache_cleancache_ops); - - return old_ops; -} - -/* a single tmem poolid is used for all frontswap "types" (swapfiles) */ -static int zcache_frontswap_poolid __read_mostly = -1; - -/* - * Swizzling increases objects per swaptype, increasing tmem concurrency - * for heavy swaploads. Later, larger nr_cpus -> larger SWIZ_BITS - * Setting SWIZ_BITS to 27 basically reconstructs the swap entry from - * frontswap_get_page(), but has side-effects. Hence using 8. - */ -#define SWIZ_BITS 8 -#define SWIZ_MASK ((1 << SWIZ_BITS) - 1) -#define _oswiz(_type, _ind) ((_type << SWIZ_BITS) | (_ind & SWIZ_MASK)) -#define iswiz(_ind) (_ind >> SWIZ_BITS) - -static inline struct tmem_oid oswiz(unsigned type, u32 ind) -{ - struct tmem_oid oid = { .oid = { 0 } }; - oid.oid[0] = _oswiz(type, ind); - return oid; -} - -#ifdef CONFIG_ZCACHE_WRITEBACK -static void unswiz(struct tmem_oid oid, u32 index, - unsigned *type, pgoff_t *offset) -{ - *type = (unsigned)(oid.oid[0] >> SWIZ_BITS); - *offset = (pgoff_t)((index << SWIZ_BITS) | - (oid.oid[0] & SWIZ_MASK)); -} -#endif - -static int zcache_frontswap_put_page(unsigned type, pgoff_t offset, - struct page *page) -{ - u64 ind64 = (u64)offset; - u32 ind = (u32)offset; - struct tmem_oid oid = oswiz(type, ind); - int ret = -1; - unsigned long flags; - - BUG_ON(!PageLocked(page)); - if (!disable_frontswap_ignore_nonactive && !PageWasActive(page)) { - inc_zcache_pers_nonactive_puts_ignored(); - ret = -ERANGE; - goto out; - } - if (likely(ind64 == ind)) { - local_irq_save(flags); - ret = zcache_put_page(LOCAL_CLIENT, zcache_frontswap_poolid, - &oid, iswiz(ind), - page, PAGE_SIZE, false, 0); - local_irq_restore(flags); - } -out: - return ret; -} - -/* returns 0 if the page was successfully gotten from frontswap, -1 if - * was not present (should never happen!) */ -static int zcache_frontswap_get_page(unsigned type, pgoff_t offset, - struct page *page) -{ - u64 ind64 = (u64)offset; - u32 ind = (u32)offset; - struct tmem_oid oid = oswiz(type, ind); - size_t size; - int ret = -1, get_and_free; - - if (frontswap_has_exclusive_gets) - get_and_free = 1; - else - get_and_free = -1; - BUG_ON(!PageLocked(page)); - if (likely(ind64 == ind)) { - ret = zcache_get_page(LOCAL_CLIENT, zcache_frontswap_poolid, - &oid, iswiz(ind), - page, &size, false, get_and_free); - BUG_ON(ret >= 0 && size != PAGE_SIZE); - } - return ret; -} - -/* flush a single page from frontswap */ -static void zcache_frontswap_flush_page(unsigned type, pgoff_t offset) -{ - u64 ind64 = (u64)offset; - u32 ind = (u32)offset; - struct tmem_oid oid = oswiz(type, ind); - - if (likely(ind64 == ind)) - (void)zcache_flush_page(LOCAL_CLIENT, zcache_frontswap_poolid, - &oid, iswiz(ind)); -} - -/* flush all pages from the passed swaptype */ -static void zcache_frontswap_flush_area(unsigned type) -{ - struct tmem_oid oid; - int ind; - - for (ind = SWIZ_MASK; ind >= 0; ind--) { - oid = oswiz(type, ind); - (void)zcache_flush_object(LOCAL_CLIENT, - zcache_frontswap_poolid, &oid); - } -} - -static void zcache_frontswap_init(unsigned ignored) -{ - /* a single tmem poolid is used for all frontswap "types" (swapfiles) */ - if (zcache_frontswap_poolid < 0) - zcache_frontswap_poolid = - zcache_local_new_pool(TMEM_POOL_PERSIST); -} - -static struct frontswap_ops zcache_frontswap_ops = { - .store = zcache_frontswap_put_page, - .load = zcache_frontswap_get_page, - .invalidate_page = zcache_frontswap_flush_page, - .invalidate_area = zcache_frontswap_flush_area, - .init = zcache_frontswap_init -}; - -struct frontswap_ops *zcache_frontswap_register_ops(void) -{ - struct frontswap_ops *old_ops = - frontswap_register_ops(&zcache_frontswap_ops); - - return old_ops; -} - -/* - * zcache initialization - * NOTE FOR NOW zcache or ramster MUST BE PROVIDED AS A KERNEL BOOT PARAMETER - * OR NOTHING HAPPENS! - */ - -#ifndef CONFIG_ZCACHE_MODULE -static int __init enable_zcache(char *s) -{ - zcache_enabled = true; - return 1; -} -__setup("zcache", enable_zcache); - -static int __init enable_ramster(char *s) -{ - zcache_enabled = true; -#ifdef CONFIG_RAMSTER - ramster_enabled = true; -#endif - return 1; -} -__setup("ramster", enable_ramster); - -/* allow independent dynamic disabling of cleancache and frontswap */ - -static int __init no_cleancache(char *s) -{ - disable_cleancache = true; - return 1; -} - -__setup("nocleancache", no_cleancache); - -static int __init no_frontswap(char *s) -{ - disable_frontswap = true; - return 1; -} - -__setup("nofrontswap", no_frontswap); - -static int __init no_frontswap_exclusive_gets(char *s) -{ - frontswap_has_exclusive_gets = false; - return 1; -} - -__setup("nofrontswapexclusivegets", no_frontswap_exclusive_gets); - -static int __init no_frontswap_ignore_nonactive(char *s) -{ - disable_frontswap_ignore_nonactive = true; - return 1; -} - -__setup("nofrontswapignorenonactive", no_frontswap_ignore_nonactive); - -static int __init no_cleancache_ignore_nonactive(char *s) -{ - disable_cleancache_ignore_nonactive = true; - return 1; -} - -__setup("nocleancacheignorenonactive", no_cleancache_ignore_nonactive); - -static int __init enable_zcache_compressor(char *s) -{ - strlcpy(zcache_comp_name, s, sizeof(zcache_comp_name)); - zcache_enabled = true; - return 1; -} -__setup("zcache=", enable_zcache_compressor); -#endif - - -static int zcache_comp_init(void) -{ - int ret = 0; - - /* check crypto algorithm */ -#ifdef CONFIG_ZCACHE_MODULE - ret = crypto_has_comp(zcache_comp_name, 0, 0); - if (!ret) { - ret = -1; - goto out; - } -#else - if (*zcache_comp_name != '\0') { - ret = crypto_has_comp(zcache_comp_name, 0, 0); - if (!ret) { - pr_info("zcache: %s not supported\n", - zcache_comp_name); - ret = 1; - goto out; - } - } - if (!ret) - strcpy(zcache_comp_name, "lzo"); - ret = crypto_has_comp(zcache_comp_name, 0, 0); - if (!ret) { - ret = 1; - goto out; - } -#endif - pr_info("zcache: using %s compressor\n", zcache_comp_name); - - /* alloc percpu transforms */ - ret = 0; - zcache_comp_pcpu_tfms = alloc_percpu(struct crypto_comp *); - if (!zcache_comp_pcpu_tfms) - ret = 1; -out: - return ret; -} - -static int zcache_init(void) -{ - int ret = 0; - -#ifdef CONFIG_ZCACHE_MODULE - zcache_enabled = 1; -#endif - if (ramster_enabled) { - namestr = "ramster"; - ramster_register_pamops(&zcache_pamops); - } - zcache_debugfs_init(); - if (zcache_enabled) { - unsigned int cpu; - - tmem_register_hostops(&zcache_hostops); - tmem_register_pamops(&zcache_pamops); - ret = register_cpu_notifier(&zcache_cpu_notifier_block); - if (ret) { - pr_err("%s: can't register cpu notifier\n", namestr); - goto out; - } - ret = zcache_comp_init(); - if (ret) { - pr_err("%s: compressor initialization failed\n", - namestr); - goto out; - } - for_each_online_cpu(cpu) { - void *pcpu = (void *)(long)cpu; - zcache_cpu_notifier(&zcache_cpu_notifier_block, - CPU_UP_PREPARE, pcpu); - } - } - zcache_objnode_cache = kmem_cache_create("zcache_objnode", - sizeof(struct tmem_objnode), 0, 0, NULL); - zcache_obj_cache = kmem_cache_create("zcache_obj", - sizeof(struct tmem_obj), 0, 0, NULL); - ret = zcache_new_client(LOCAL_CLIENT); - if (ret) { - pr_err("%s: can't create client\n", namestr); - goto out; - } - zbud_init(); - if (zcache_enabled && !disable_cleancache) { - struct cleancache_ops *old_ops; - - register_shrinker(&zcache_shrinker); - old_ops = zcache_cleancache_register_ops(); - pr_info("%s: cleancache enabled using kernel transcendent " - "memory and compression buddies\n", namestr); -#ifdef CONFIG_ZCACHE_DEBUG - pr_info("%s: cleancache: ignorenonactive = %d\n", - namestr, !disable_cleancache_ignore_nonactive); -#endif - if (old_ops != NULL) - pr_warn("%s: cleancache_ops overridden\n", namestr); - } - if (zcache_enabled && !disable_frontswap) { - struct frontswap_ops *old_ops; - - old_ops = zcache_frontswap_register_ops(); - if (frontswap_has_exclusive_gets) - frontswap_tmem_exclusive_gets(true); - pr_info("%s: frontswap enabled using kernel transcendent " - "memory and compression buddies\n", namestr); -#ifdef CONFIG_ZCACHE_DEBUG - pr_info("%s: frontswap: excl gets = %d active only = %d\n", - namestr, frontswap_has_exclusive_gets, - !disable_frontswap_ignore_nonactive); -#endif - if (IS_ERR(old_ops) || old_ops) { - if (IS_ERR(old_ops)) - return PTR_RET(old_ops); - pr_warn("%s: frontswap_ops overridden\n", namestr); - } - } - if (ramster_enabled) - ramster_init(!disable_cleancache, !disable_frontswap, - frontswap_has_exclusive_gets, - !disable_frontswap_selfshrink); -out: - return ret; -} - -#ifdef CONFIG_ZCACHE_MODULE -#ifdef CONFIG_RAMSTER -module_param(ramster_enabled, bool, S_IRUGO); -module_param(disable_frontswap_selfshrink, int, S_IRUGO); -#endif -module_param(disable_cleancache, bool, S_IRUGO); -module_param(disable_frontswap, bool, S_IRUGO); -#ifdef FRONTSWAP_HAS_EXCLUSIVE_GETS -module_param(frontswap_has_exclusive_gets, bool, S_IRUGO); -#endif -module_param(disable_frontswap_ignore_nonactive, bool, S_IRUGO); -module_param(zcache_comp_name, charp, S_IRUGO); -module_init(zcache_init); -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Dan Magenheimer "); -MODULE_DESCRIPTION("In-kernel compression of cleancache/frontswap pages"); -#else -late_initcall(zcache_init); -#endif diff --git a/drivers/staging/zcache/zcache.h b/drivers/staging/zcache/zcache.h deleted file mode 100644 index 849120095e798..0000000000000 --- a/drivers/staging/zcache/zcache.h +++ /dev/null @@ -1,53 +0,0 @@ - -/* - * zcache.h - * - * Copyright (c) 2012, Dan Magenheimer, Oracle Corp. - */ - -#ifndef _ZCACHE_H_ -#define _ZCACHE_H_ - -struct zcache_preload { - struct tmem_obj *obj; - struct tmem_objnode *objnodes[OBJNODE_TREE_MAX_PATH]; -}; - -struct tmem_pool; - -#define MAX_POOLS_PER_CLIENT 16 - -#define MAX_CLIENTS 16 -#define LOCAL_CLIENT ((uint16_t)-1) - -struct zcache_client { - struct tmem_pool *tmem_pools[MAX_POOLS_PER_CLIENT]; - bool allocated; - atomic_t refcount; -}; - -extern struct tmem_pool *zcache_get_pool_by_id(uint16_t cli_id, - uint16_t poolid); -extern void zcache_put_pool(struct tmem_pool *pool); - -extern int zcache_put_page(int, int, struct tmem_oid *, - uint32_t, void *, - unsigned int, bool, int); -extern int zcache_get_page(int, int, struct tmem_oid *, uint32_t, - void *, size_t *, bool, int); -extern int zcache_flush_page(int, int, struct tmem_oid *, uint32_t); -extern int zcache_flush_object(int, int, struct tmem_oid *); -extern void zcache_decompress_to_page(char *, unsigned int, struct page *); - -#if defined(CONFIG_RAMSTER) || defined(CONFIG_RAMSTER_MODULE) -extern void *zcache_pampd_create(char *, unsigned int, bool, int, - struct tmem_handle *); -int zcache_autocreate_pool(unsigned int cli_id, unsigned int pool_id, bool eph); -#endif - -#define MAX_POOLS_PER_CLIENT 16 - -#define MAX_CLIENTS 16 -#define LOCAL_CLIENT ((uint16_t)-1) - -#endif /* _ZCACHE_H_ */ -- GitLab From 3457bfd6dfb38f7bb66a227fe3473bad4773de06 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 12 Aug 2013 15:14:18 -0700 Subject: [PATCH 598/942] Revert "staging: comedi: drivers: use comedi_dio_insn_config() for complex cases" This reverts commit f21c53945cb95f66faa9636af5f23cb00ba73019. I applied the wrong patch :( Cc: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/8255.c | 42 +++--- .../staging/comedi/drivers/addi_apci_16xx.c | 42 ++++-- .../staging/comedi/drivers/addi_apci_3xxx.c | 36 +++-- drivers/staging/comedi/drivers/adv_pci1723.c | 43 +++--- .../comedi/drivers/amplc_dio200_common.c | 42 +++--- drivers/staging/comedi/drivers/cb_das16_cs.c | 31 +++-- drivers/staging/comedi/drivers/dt2801.c | 31 +++-- drivers/staging/comedi/drivers/dt3000.c | 41 +++--- drivers/staging/comedi/drivers/gsc_hpdi.c | 33 +++-- drivers/staging/comedi/drivers/ii_pci20kc.c | 37 ++++-- drivers/staging/comedi/drivers/me4000.c | 123 ++++++++++++------ drivers/staging/comedi/drivers/me_daq.c | 50 ++++--- drivers/staging/comedi/drivers/ni_at_ao.c | 55 ++++---- drivers/staging/comedi/drivers/pcm3724.c | 45 ++++--- drivers/staging/comedi/drivers/s526.c | 45 +++---- 15 files changed, 433 insertions(+), 263 deletions(-) diff --git a/drivers/staging/comedi/drivers/8255.c b/drivers/staging/comedi/drivers/8255.c index 2f070fdbbb1d3..1fa29ac4eb5df 100644 --- a/drivers/staging/comedi/drivers/8255.c +++ b/drivers/staging/comedi/drivers/8255.c @@ -184,29 +184,39 @@ static void subdev_8255_do_config(struct comedi_device *dev, static int subdev_8255_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) + struct comedi_insn *insn, unsigned int *data) { - unsigned int chan = CR_CHAN(insn->chanspec); unsigned int mask; - int ret; + unsigned int bits; - if (chan < 8) - mask = 0x0000ff; - else if (chan < 16) - mask = 0x00ff00; - else if (chan < 20) - mask = 0x0f0000; + mask = 1 << CR_CHAN(insn->chanspec); + if (mask & 0x0000ff) + bits = 0x0000ff; + else if (mask & 0x00ff00) + bits = 0x00ff00; + else if (mask & 0x0f0000) + bits = 0x0f0000; else - mask = 0xf00000; - - ret = comedi_dio_insn_config(dev, s, insn, data, mask); - if (ret) - return ret; + bits = 0xf00000; + + switch (data[0]) { + case INSN_CONFIG_DIO_INPUT: + s->io_bits &= ~bits; + break; + case INSN_CONFIG_DIO_OUTPUT: + s->io_bits |= bits; + break; + case INSN_CONFIG_DIO_QUERY: + data[1] = (s->io_bits & bits) ? COMEDI_OUTPUT : COMEDI_INPUT; + return insn->n; + break; + default: + return -EINVAL; + } subdev_8255_do_config(dev, s); - return insn->n; + return 1; } static int subdev_8255_cmdtest(struct comedi_device *dev, diff --git a/drivers/staging/comedi/drivers/addi_apci_16xx.c b/drivers/staging/comedi/drivers/addi_apci_16xx.c index 96523744b8de5..43296a6e7d4e6 100644 --- a/drivers/staging/comedi/drivers/addi_apci_16xx.c +++ b/drivers/staging/comedi/drivers/addi_apci_16xx.c @@ -60,22 +60,36 @@ static int apci16xx_insn_config(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - unsigned int chan = CR_CHAN(insn->chanspec); - unsigned int mask; - int ret; + unsigned int chan_mask = 1 << CR_CHAN(insn->chanspec); + unsigned int bits; - if (chan < 8) - mask = 0x000000ff; - else if (chan < 16) - mask = 0x0000ff00; - else if (chan < 24) - mask = 0x00ff0000; + /* + * Each 8-bit "port" is configurable as either input or + * output. Changing the configuration of any channel in + * a port changes the entire port. + */ + if (chan_mask & 0x000000ff) + bits = 0x000000ff; + else if (chan_mask & 0x0000ff00) + bits = 0x0000ff00; + else if (chan_mask & 0x00ff0000) + bits = 0x00ff0000; else - mask = 0xff000000; - - ret = comedi_dio_insn_config(dev, s, insn, data, mask); - if (ret) - return ret; + bits = 0xff000000; + + switch (data[0]) { + case INSN_CONFIG_DIO_INPUT: + s->io_bits &= ~bits; + break; + case INSN_CONFIG_DIO_OUTPUT: + s->io_bits |= bits; + break; + case INSN_CONFIG_DIO_QUERY: + data[1] = (s->io_bits & bits) ? COMEDI_INPUT : COMEDI_OUTPUT; + return insn->n; + default: + return -EINVAL; + } outl(s->io_bits, dev->iobase + APCI16XX_DIR_REG(s->index)); diff --git a/drivers/staging/comedi/drivers/addi_apci_3xxx.c b/drivers/staging/comedi/drivers/addi_apci_3xxx.c index cf5dd10eaf91d..dbc0678027ca7 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3xxx.c +++ b/drivers/staging/comedi/drivers/addi_apci_3xxx.c @@ -686,28 +686,38 @@ static int apci3xxx_dio_insn_config(struct comedi_device *dev, unsigned int *data) { unsigned int chan = CR_CHAN(insn->chanspec); - unsigned int mask; - int ret; + unsigned int mask = 1 << chan; + unsigned int bits; /* * Port 0 (channels 0-7) are always inputs * Port 1 (channels 8-15) are always outputs * Port 2 (channels 16-23) are programmable i/o + * + * Changing any channel in port 2 changes the entire port. */ - if (chan < 16) { - if (data[0] != INSN_CONFIG_DIO_QUERY) - return -EINVAL; - } else { - /* changing any channel in port 2 changes the entire port */ - mask = 0xff0000; + if (mask & 0xff0000) + bits = 0xff0000; + else + bits = 0; + + switch (data[0]) { + case INSN_CONFIG_DIO_INPUT: + s->io_bits &= ~bits; + break; + case INSN_CONFIG_DIO_OUTPUT: + s->io_bits |= bits; + break; + case INSN_CONFIG_DIO_QUERY: + data[1] = (s->io_bits & bits) ? COMEDI_OUTPUT : COMEDI_INPUT; + return insn->n; + default: + return -EINVAL; } - ret = comedi_dio_insn_config(dev, s, insn, data, mask); - if (ret) - return ret; - /* update port 2 configuration */ - outl((s->io_bits >> 24) & 0xff, dev->iobase + 224); + if (bits) + outl((s->io_bits >> 24) & 0xff, dev->iobase + 224); return insn->n; } diff --git a/drivers/staging/comedi/drivers/adv_pci1723.c b/drivers/staging/comedi/drivers/adv_pci1723.c index b793d6987b843..f914fb1f571be 100644 --- a/drivers/staging/comedi/drivers/adv_pci1723.c +++ b/drivers/staging/comedi/drivers/adv_pci1723.c @@ -180,29 +180,38 @@ static int pci1723_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - unsigned int chan = CR_CHAN(insn->chanspec); unsigned int mask; - unsigned short mode; - int ret; + unsigned int bits; + unsigned short dio_mode; - if (chan < 8) - mask = 0x00ff; + mask = 1 << CR_CHAN(insn->chanspec); + if (mask & 0x00FF) + bits = 0x00FF; else - mask = 0xff00; + bits = 0xFF00; - ret = comedi_dio_insn_config(dev, s, insn, data, mask); - if (ret) - return ret; + switch (data[0]) { + case INSN_CONFIG_DIO_INPUT: + s->io_bits &= ~bits; + break; + case INSN_CONFIG_DIO_OUTPUT: + s->io_bits |= bits; + break; + case INSN_CONFIG_DIO_QUERY: + data[1] = (s->io_bits & bits) ? COMEDI_OUTPUT : COMEDI_INPUT; + return insn->n; + default: + return -EINVAL; + } /* update hardware DIO mode */ - mode = 0x0000; /* assume output */ - if (!(s->io_bits & 0x00ff)) - mode |= 0x0001; /* low byte input */ - if (!(s->io_bits & 0xff00)) - mode |= 0x0002; /* high byte input */ - outw(mode, dev->iobase + PCI1723_DIGITAL_IO_PORT_SET); - - return insn->n; + dio_mode = 0x0000; /* low byte output, high byte output */ + if ((s->io_bits & 0x00FF) == 0) + dio_mode |= 0x0001; /* low byte input */ + if ((s->io_bits & 0xFF00) == 0) + dio_mode |= 0x0002; /* high byte input */ + outw(dio_mode, dev->iobase + PCI1723_DIGITAL_IO_PORT_SET); + return 1; } /* diff --git a/drivers/staging/comedi/drivers/amplc_dio200_common.c b/drivers/staging/comedi/drivers/amplc_dio200_common.c index c1f723e861461..32c490b27b555 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200_common.c +++ b/drivers/staging/comedi/drivers/amplc_dio200_common.c @@ -976,26 +976,34 @@ static int dio200_subdev_8255_config(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - unsigned int chan = CR_CHAN(insn->chanspec); unsigned int mask; - int ret; - - if (chan < 8) - mask = 0x0000ff; - else if (chan < 16) - mask = 0x00ff00; - else if (chan < 20) - mask = 0x0f0000; + unsigned int bits; + + mask = 1 << CR_CHAN(insn->chanspec); + if (mask & 0x0000ff) + bits = 0x0000ff; + else if (mask & 0x00ff00) + bits = 0x00ff00; + else if (mask & 0x0f0000) + bits = 0x0f0000; else - mask = 0xf00000; - - ret = comedi_dio_insn_config(dev, s, insn, data, mask); - if (ret) - return ret; - + bits = 0xf00000; + switch (data[0]) { + case INSN_CONFIG_DIO_INPUT: + s->io_bits &= ~bits; + break; + case INSN_CONFIG_DIO_OUTPUT: + s->io_bits |= bits; + break; + case INSN_CONFIG_DIO_QUERY: + data[1] = (s->io_bits & bits) ? COMEDI_OUTPUT : COMEDI_INPUT; + return insn->n; + break; + default: + return -EINVAL; + } dio200_subdev_8255_set_dir(dev, s); - - return insn->n; + return 1; } /* diff --git a/drivers/staging/comedi/drivers/cb_das16_cs.c b/drivers/staging/comedi/drivers/cb_das16_cs.c index 0ce93da70847c..05e01a3b5af6a 100644 --- a/drivers/staging/comedi/drivers/cb_das16_cs.c +++ b/drivers/staging/comedi/drivers/cb_das16_cs.c @@ -341,22 +341,33 @@ static int das16cs_dio_insn_bits(struct comedi_device *dev, static int das16cs_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) + struct comedi_insn *insn, unsigned int *data) { struct das16cs_private *devpriv = dev->private; - unsigned int chan = CR_CHAN(insn->chanspec); - unsigned int mask; - int ret; + int chan = CR_CHAN(insn->chanspec); + int bits; if (chan < 4) - mask = 0x0f; + bits = 0x0f; else - mask = 0xf0; + bits = 0xf0; - ret = comedi_dio_insn_config(dev, s, insn, data, mask); - if (ret) - return ret; + switch (data[0]) { + case INSN_CONFIG_DIO_OUTPUT: + s->io_bits |= bits; + break; + case INSN_CONFIG_DIO_INPUT: + s->io_bits &= bits; + break; + case INSN_CONFIG_DIO_QUERY: + data[1] = + (s->io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT; + return insn->n; + break; + default: + return -EINVAL; + break; + } devpriv->status2 &= ~0x00c0; devpriv->status2 |= (s->io_bits & 0xf0) ? 0x0080 : 0; diff --git a/drivers/staging/comedi/drivers/dt2801.c b/drivers/staging/comedi/drivers/dt2801.c index 38918a1198aa8..e0e7beab7274b 100644 --- a/drivers/staging/comedi/drivers/dt2801.c +++ b/drivers/staging/comedi/drivers/dt2801.c @@ -551,19 +551,32 @@ static int dt2801_dio_insn_bits(struct comedi_device *dev, static int dt2801_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) + struct comedi_insn *insn, unsigned int *data) { - int ret; + int which = 0; - ret = comedi_dio_insn_config(dev, s, insn, data, 0xff); - if (ret) - return ret; + if (s == &dev->subdevices[3]) + which = 1; - dt2801_writecmd(dev, s->io_bits ? DT_C_SET_DIGOUT : DT_C_SET_DIGIN); - dt2801_writedata(dev, (s == &dev->subdevices[3]) ? 1 : 0); + /* configure */ + switch (data[0]) { + case INSN_CONFIG_DIO_OUTPUT: + s->io_bits = 0xff; + dt2801_writecmd(dev, DT_C_SET_DIGOUT); + break; + case INSN_CONFIG_DIO_INPUT: + s->io_bits = 0; + dt2801_writecmd(dev, DT_C_SET_DIGIN); + break; + case INSN_CONFIG_DIO_QUERY: + data[1] = s->io_bits ? COMEDI_OUTPUT : COMEDI_INPUT; + return insn->n; + default: + return -EINVAL; + } + dt2801_writedata(dev, which); - return insn->n; + return 1; } /* diff --git a/drivers/staging/comedi/drivers/dt3000.c b/drivers/staging/comedi/drivers/dt3000.c index 64ef87598b607..e4748da1993b8 100644 --- a/drivers/staging/comedi/drivers/dt3000.c +++ b/drivers/staging/comedi/drivers/dt3000.c @@ -642,23 +642,32 @@ static void dt3k_dio_config(struct comedi_device *dev, int bits) static int dt3k_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) + struct comedi_insn *insn, unsigned int *data) { - unsigned int chan = CR_CHAN(insn->chanspec); - unsigned int mask; - int ret; - - if (chan < 4) - mask = 0x0f; - else - mask = 0xf0; - - ret = comedi_dio_insn_config(dev, s, insn, data, mask); - if (ret) - return ret; - - dt3k_dio_config(dev, (s->io_bits & 0x01) | ((s->io_bits & 0x10) >> 3)); + int mask; + + mask = (CR_CHAN(insn->chanspec) < 4) ? 0x0f : 0xf0; + + switch (data[0]) { + case INSN_CONFIG_DIO_OUTPUT: + s->io_bits |= mask; + break; + case INSN_CONFIG_DIO_INPUT: + s->io_bits &= ~mask; + break; + case INSN_CONFIG_DIO_QUERY: + data[1] = + (s-> + io_bits & (1 << CR_CHAN(insn->chanspec))) ? COMEDI_OUTPUT : + COMEDI_INPUT; + return insn->n; + break; + default: + return -EINVAL; + break; + } + mask = (s->io_bits & 0x01) | ((s->io_bits & 0x10) >> 3); + dt3k_dio_config(dev, mask); return insn->n; } diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c b/drivers/staging/comedi/drivers/gsc_hpdi.c index 559bf5583530c..cdcc8f42e2093 100644 --- a/drivers/staging/comedi/drivers/gsc_hpdi.c +++ b/drivers/staging/comedi/drivers/gsc_hpdi.c @@ -224,26 +224,37 @@ struct hpdi_private { volatile uint32_t bits[24]; /* number of bytes at which to generate COMEDI_CB_BLOCK events */ volatile unsigned int block_size; + unsigned dio_config_output:1; }; static int dio_config_insn(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, + struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - int ret; + struct hpdi_private *devpriv = dev->private; switch (data[0]) { + case INSN_CONFIG_DIO_OUTPUT: + devpriv->dio_config_output = 1; + return insn->n; + break; + case INSN_CONFIG_DIO_INPUT: + devpriv->dio_config_output = 0; + return insn->n; + break; + case INSN_CONFIG_DIO_QUERY: + data[1] = + devpriv->dio_config_output ? COMEDI_OUTPUT : COMEDI_INPUT; + return insn->n; + break; case INSN_CONFIG_BLOCK_SIZE: return dio_config_block_size(dev, data); + break; default: - ret = comedi_dio_insn_config(dev, s, insn, data, 0xffffffff); - if (ret) - return ret; break; } - return insn->n; + return -EINVAL; } static void disable_plx_interrupts(struct comedi_device *dev) @@ -662,7 +673,9 @@ static int di_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s, static int hpdi_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { - if (s->io_bits) + struct hpdi_private *devpriv = dev->private; + + if (devpriv->dio_config_output) return -EINVAL; else return di_cmd_test(dev, s, cmd); @@ -733,7 +746,9 @@ static int di_cmd(struct comedi_device *dev, struct comedi_subdevice *s) static int hpdi_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { - if (s->io_bits) + struct hpdi_private *devpriv = dev->private; + + if (devpriv->dio_config_output) return -EINVAL; else return di_cmd(dev, s); diff --git a/drivers/staging/comedi/drivers/ii_pci20kc.c b/drivers/staging/comedi/drivers/ii_pci20kc.c index 5c3a318b46401..954c5397f33c8 100644 --- a/drivers/staging/comedi/drivers/ii_pci20kc.c +++ b/drivers/staging/comedi/drivers/ii_pci20kc.c @@ -350,22 +350,31 @@ static int ii20k_dio_insn_config(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - unsigned int chan = CR_CHAN(insn->chanspec); - unsigned int mask; - int ret; - - if (chan < 8) - mask = 0x000000ff; - else if (chan < 16) - mask = 0x0000ff00; - else if (chan < 24) - mask = 0x00ff0000; + unsigned int mask = 1 << CR_CHAN(insn->chanspec); + unsigned int bits; + + if (mask & 0x000000ff) + bits = 0x000000ff; + else if (mask & 0x0000ff00) + bits = 0x0000ff00; + else if (mask & 0x00ff0000) + bits = 0x00ff0000; else - mask = 0xff000000; + bits = 0xff000000; - ret = comedi_dio_insn_config(dev, s, insn, data, mask); - if (ret) - return ret; + switch (data[0]) { + case INSN_CONFIG_DIO_INPUT: + s->io_bits &= ~bits; + break; + case INSN_CONFIG_DIO_OUTPUT: + s->io_bits |= bits; + break; + case INSN_CONFIG_DIO_QUERY: + data[1] = (s->io_bits & bits) ? COMEDI_OUTPUT : COMEDI_INPUT; + return insn->n; + default: + return -EINVAL; + } ii20k_dio_config(dev, s); diff --git a/drivers/staging/comedi/drivers/me4000.c b/drivers/staging/comedi/drivers/me4000.c index 8f4afadab76a6..1eda40a9332ee 100644 --- a/drivers/staging/comedi/drivers/me4000.c +++ b/drivers/staging/comedi/drivers/me4000.c @@ -1358,57 +1358,98 @@ static int me4000_dio_insn_bits(struct comedi_device *dev, static int me4000_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) + struct comedi_insn *insn, unsigned int *data) { - unsigned int chan = CR_CHAN(insn->chanspec); - unsigned int mask; - unsigned int tmp; - int ret; + unsigned long tmp; + int chan = CR_CHAN(insn->chanspec); - if (chan < 8) - mask = 0x000000ff; - else if (chan < 16) - mask = 0x0000ff00; - else if (chan < 24) - mask = 0x00ff0000; - else - mask = 0xff000000; + switch (data[0]) { + default: + return -EINVAL; + case INSN_CONFIG_DIO_QUERY: + data[1] = + (s->io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT; + return insn->n; + case INSN_CONFIG_DIO_INPUT: + case INSN_CONFIG_DIO_OUTPUT: + break; + } - ret = comedi_dio_insn_config(dev, s, insn, data, mask); - if (ret) - return ret; + /* + * The input or output configuration of each digital line is + * configured by a special insn_config instruction. chanspec + * contains the channel to be changed, and data[0] contains the + * value INSN_CONFIG_DIO_INPUT or INSN_CONFIG_DIO_OUTPUT. + * On the ME-4000 it is only possible to switch port wise (8 bit) + */ tmp = inl(dev->iobase + ME4000_DIO_CTRL_REG); - tmp &= ~(ME4000_DIO_CTRL_BIT_MODE_0 | ME4000_DIO_CTRL_BIT_MODE_1 | - ME4000_DIO_CTRL_BIT_MODE_2 | ME4000_DIO_CTRL_BIT_MODE_3 | - ME4000_DIO_CTRL_BIT_MODE_4 | ME4000_DIO_CTRL_BIT_MODE_5 | - ME4000_DIO_CTRL_BIT_MODE_6 | ME4000_DIO_CTRL_BIT_MODE_7); - if (s->io_bits & 0x000000ff) - tmp |= ME4000_DIO_CTRL_BIT_MODE_0; - if (s->io_bits & 0x0000ff00) - tmp |= ME4000_DIO_CTRL_BIT_MODE_2; - if (s->io_bits & 0x00ff0000) - tmp |= ME4000_DIO_CTRL_BIT_MODE_4; - if (s->io_bits & 0xff000000) - tmp |= ME4000_DIO_CTRL_BIT_MODE_6; - /* - * Check for optoisolated ME-4000 version. - * If one the first port is a fixed output - * port and the second is a fixed input port. - */ - if (inl(dev->iobase + ME4000_DIO_DIR_REG)) { - s->io_bits |= 0x000000ff; - s->io_bits &= ~0x0000ff00; - tmp |= ME4000_DIO_CTRL_BIT_MODE_0; - tmp &= ~(ME4000_DIO_CTRL_BIT_MODE_2 | - ME4000_DIO_CTRL_BIT_MODE_3); + if (data[0] == INSN_CONFIG_DIO_OUTPUT) { + if (chan < 8) { + s->io_bits |= 0xFF; + tmp &= ~(ME4000_DIO_CTRL_BIT_MODE_0 | + ME4000_DIO_CTRL_BIT_MODE_1); + tmp |= ME4000_DIO_CTRL_BIT_MODE_0; + } else if (chan < 16) { + /* + * Chech for optoisolated ME-4000 version. + * If one the first port is a fixed output + * port and the second is a fixed input port. + */ + if (!inl(dev->iobase + ME4000_DIO_DIR_REG)) + return -ENODEV; + + s->io_bits |= 0xFF00; + tmp &= ~(ME4000_DIO_CTRL_BIT_MODE_2 | + ME4000_DIO_CTRL_BIT_MODE_3); + tmp |= ME4000_DIO_CTRL_BIT_MODE_2; + } else if (chan < 24) { + s->io_bits |= 0xFF0000; + tmp &= ~(ME4000_DIO_CTRL_BIT_MODE_4 | + ME4000_DIO_CTRL_BIT_MODE_5); + tmp |= ME4000_DIO_CTRL_BIT_MODE_4; + } else if (chan < 32) { + s->io_bits |= 0xFF000000; + tmp &= ~(ME4000_DIO_CTRL_BIT_MODE_6 | + ME4000_DIO_CTRL_BIT_MODE_7); + tmp |= ME4000_DIO_CTRL_BIT_MODE_6; + } else { + return -EINVAL; + } + } else { + if (chan < 8) { + /* + * Chech for optoisolated ME-4000 version. + * If one the first port is a fixed output + * port and the second is a fixed input port. + */ + if (!inl(dev->iobase + ME4000_DIO_DIR_REG)) + return -ENODEV; + + s->io_bits &= ~0xFF; + tmp &= ~(ME4000_DIO_CTRL_BIT_MODE_0 | + ME4000_DIO_CTRL_BIT_MODE_1); + } else if (chan < 16) { + s->io_bits &= ~0xFF00; + tmp &= ~(ME4000_DIO_CTRL_BIT_MODE_2 | + ME4000_DIO_CTRL_BIT_MODE_3); + } else if (chan < 24) { + s->io_bits &= ~0xFF0000; + tmp &= ~(ME4000_DIO_CTRL_BIT_MODE_4 | + ME4000_DIO_CTRL_BIT_MODE_5); + } else if (chan < 32) { + s->io_bits &= ~0xFF000000; + tmp &= ~(ME4000_DIO_CTRL_BIT_MODE_6 | + ME4000_DIO_CTRL_BIT_MODE_7); + } else { + return -EINVAL; + } } outl(tmp, dev->iobase + ME4000_DIO_CTRL_REG); - return insn->n; + return 1; } /*============================================================================= diff --git a/drivers/staging/comedi/drivers/me_daq.c b/drivers/staging/comedi/drivers/me_daq.c index a6f6d4a46587f..e8a743c2f9a16 100644 --- a/drivers/staging/comedi/drivers/me_daq.c +++ b/drivers/staging/comedi/drivers/me_daq.c @@ -186,30 +186,38 @@ static int me_dio_insn_config(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct me_private_data *devpriv = dev->private; - unsigned int chan = CR_CHAN(insn->chanspec); - unsigned int mask; - int ret; - - if (chan < 16) - mask = 0x0000ffff; - else - mask = 0xffff0000; + struct me_private_data *dev_private = dev->private; + unsigned int mask = 1 << CR_CHAN(insn->chanspec); + unsigned int bits; + unsigned int port; - ret = comedi_dio_insn_config(dev, s, insn, data, mask); - if (ret) - return ret; + if (mask & 0x0000ffff) { + bits = 0x0000ffff; + port = ENABLE_PORT_A; + } else { + bits = 0xffff0000; + port = ENABLE_PORT_B; + } - if (s->io_bits & 0x0000ffff) - devpriv->control_2 |= ENABLE_PORT_A; - else - devpriv->control_2 &= ~ENABLE_PORT_A; - if (s->io_bits & 0xffff0000) - devpriv->control_2 |= ENABLE_PORT_B; - else - devpriv->control_2 &= ~ENABLE_PORT_B; + switch (data[0]) { + case INSN_CONFIG_DIO_INPUT: + s->io_bits &= ~bits; + dev_private->control_2 &= ~port; + break; + case INSN_CONFIG_DIO_OUTPUT: + s->io_bits |= bits; + dev_private->control_2 |= port; + break; + case INSN_CONFIG_DIO_QUERY: + data[1] = (s->io_bits & bits) ? COMEDI_OUTPUT : COMEDI_INPUT; + return insn->n; + break; + default: + return -EINVAL; + } - writew(devpriv->control_2, devpriv->me_regbase + ME_CONTROL_2); + /* Update the port configuration */ + writew(dev_private->control_2, dev_private->me_regbase + ME_CONTROL_2); return insn->n; } diff --git a/drivers/staging/comedi/drivers/ni_at_ao.c b/drivers/staging/comedi/drivers/ni_at_ao.c index b9122fd835e1e..0025496bc643c 100644 --- a/drivers/staging/comedi/drivers/ni_at_ao.c +++ b/drivers/staging/comedi/drivers/ni_at_ao.c @@ -248,35 +248,42 @@ static int atao_dio_insn_bits(struct comedi_device *dev, static int atao_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) + struct comedi_insn *insn, unsigned int *data) { struct atao_private *devpriv = dev->private; - unsigned int chan = CR_CHAN(insn->chanspec); - unsigned int mask; - int ret; - - if (chan < 4) - mask = 0x0f; - else - mask = 0xf0; - - ret = comedi_dio_insn_config(dev, s, insn, data, mask); - if (ret) - return ret; - - if (s->io_bits & 0x0f) - devpriv->cfg3 |= DOUTEN1; - else - devpriv->cfg3 &= ~DOUTEN1; - if (s->io_bits & 0xf0) - devpriv->cfg3 |= DOUTEN2; - else - devpriv->cfg3 &= ~DOUTEN2; + int chan = CR_CHAN(insn->chanspec); + unsigned int mask, bit; + + /* The input or output configuration of each digital line is + * configured by a special insn_config instruction. chanspec + * contains the channel to be changed, and data[0] contains the + * value COMEDI_INPUT or COMEDI_OUTPUT. */ + + mask = (chan < 4) ? 0x0f : 0xf0; + bit = (chan < 4) ? DOUTEN1 : DOUTEN2; + + switch (data[0]) { + case INSN_CONFIG_DIO_OUTPUT: + s->io_bits |= mask; + devpriv->cfg3 |= bit; + break; + case INSN_CONFIG_DIO_INPUT: + s->io_bits &= ~mask; + devpriv->cfg3 &= ~bit; + break; + case INSN_CONFIG_DIO_QUERY: + data[1] = + (s->io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT; + return insn->n; + break; + default: + return -EINVAL; + break; + } outw(devpriv->cfg3, dev->iobase + ATAO_CFG3); - return insn->n; + return 1; } /* diff --git a/drivers/staging/comedi/drivers/pcm3724.c b/drivers/staging/comedi/drivers/pcm3724.c index cc1dc7f66e5b5..cca972ebd010e 100644 --- a/drivers/staging/comedi/drivers/pcm3724.c +++ b/drivers/staging/comedi/drivers/pcm3724.c @@ -184,30 +184,39 @@ static void enable_chan(struct comedi_device *dev, struct comedi_subdevice *s, /* overriding the 8255 insn config */ static int subdev_3724_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) + struct comedi_insn *insn, unsigned int *data) { - unsigned int chan = CR_CHAN(insn->chanspec); unsigned int mask; - int ret; - - if (chan < 8) - mask = 0x0000ff; - else if (chan < 16) - mask = 0x00ff00; - else if (chan < 20) - mask = 0x0f0000; + unsigned int bits; + + mask = 1 << CR_CHAN(insn->chanspec); + if (mask & 0x0000ff) + bits = 0x0000ff; + else if (mask & 0x00ff00) + bits = 0x00ff00; + else if (mask & 0x0f0000) + bits = 0x0f0000; else - mask = 0xf00000; - - ret = comedi_dio_insn_config(dev, s, insn, data, mask); - if (ret) - return ret; + bits = 0xf00000; + + switch (data[0]) { + case INSN_CONFIG_DIO_INPUT: + s->io_bits &= ~bits; + break; + case INSN_CONFIG_DIO_OUTPUT: + s->io_bits |= bits; + break; + case INSN_CONFIG_DIO_QUERY: + data[1] = (s->io_bits & bits) ? COMEDI_OUTPUT : COMEDI_INPUT; + return insn->n; + break; + default: + return -EINVAL; + } do_3724_config(dev, s, insn->chanspec); enable_chan(dev, s, insn->chanspec); - - return insn->n; + return 1; } static int pcm3724_attach(struct comedi_device *dev, diff --git a/drivers/staging/comedi/drivers/s526.c b/drivers/staging/comedi/drivers/s526.c index d629463b85a2a..6670b865256b3 100644 --- a/drivers/staging/comedi/drivers/s526.c +++ b/drivers/staging/comedi/drivers/s526.c @@ -515,35 +515,32 @@ static int s526_dio_insn_bits(struct comedi_device *dev, static int s526_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) + struct comedi_insn *insn, unsigned int *data) { unsigned int chan = CR_CHAN(insn->chanspec); - unsigned int mask; - int ret; - - if (chan < 4) - mask = 0x0f; - else - mask = 0xf0; - - ret = comedi_dio_insn_config(dev, s, insn, data, mask); - if (ret) - return ret; - - /* bit 10/11 set the group 1/2's mode */ - if (s->io_bits & 0x0f) - s->state |= (1 << 10); - else - s->state &= ~(1 << 10); - if (s->io_bits & 0xf0) - s->state |= (1 << 11); - else - s->state &= ~(1 << 11); + int group, mask; + group = chan >> 2; + mask = 0xF << (group << 2); + switch (data[0]) { + case INSN_CONFIG_DIO_OUTPUT: + /* bit 10/11 set the group 1/2's mode */ + s->state |= 1 << (group + 10); + s->io_bits |= mask; + break; + case INSN_CONFIG_DIO_INPUT: + s->state &= ~(1 << (group + 10)); /* 1 is output, 0 is input. */ + s->io_bits &= ~mask; + break; + case INSN_CONFIG_DIO_QUERY: + data[1] = (s->io_bits & mask) ? COMEDI_OUTPUT : COMEDI_INPUT; + return insn->n; + default: + return -EINVAL; + } outw(s->state, dev->iobase + REG_DIO); - return insn->n; + return 1; } static int s526_attach(struct comedi_device *dev, struct comedi_devconfig *it) -- GitLab From e495dd833b2345f89888378c6ec7456995791087 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Mon, 12 Aug 2013 14:39:22 +0300 Subject: [PATCH 599/942] staging: lustre: re-use kbasename() common helper To get the name of a file from a pathname we may use kbasename() helper. Signed-off-by: Andy Shevchenko Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/libcfs/tracefile.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/lustre/lustre/libcfs/tracefile.c b/drivers/staging/lustre/lustre/libcfs/tracefile.c index 68c77d3813958..357f40079ae09 100644 --- a/drivers/staging/lustre/lustre/libcfs/tracefile.c +++ b/drivers/staging/lustre/lustre/libcfs/tracefile.c @@ -275,12 +275,9 @@ int libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata, int i; int remain; int mask = msgdata->msg_mask; - char *file = (char *)msgdata->msg_file; + const char *file = kbasename(msgdata->msg_file); cfs_debug_limit_state_t *cdls = msgdata->msg_cdls; - if (strchr(file, '/')) - file = strrchr(file, '/') + 1; - tcd = cfs_trace_get_tcd(); /* cfs_trace_get_tcd() grabs a lock, which disables preemption and -- GitLab From 5dacadcca3176e2b1f8db662e503c080484d71fa Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 6 Aug 2013 09:33:05 -0700 Subject: [PATCH 600/942] staging: comedi: drivers: use comedi_dio_insn_config() for complex cases Convert the drivers with complex, port programmable i/o, to use the comedi_dio_insn_config() helper function. All of these drivers have some sort of 'port' programmable i/o where multiple i/o channels are configured as a group. The 'mask' associated with the group is passed to comedi_dio_insn_config() so that all the channels are configured. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Cc: Greg Kroah-Hartman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/8255.c | 42 +++--- .../staging/comedi/drivers/addi_apci_16xx.c | 42 ++---- .../staging/comedi/drivers/addi_apci_3xxx.c | 36 ++--- drivers/staging/comedi/drivers/adv_pci1723.c | 43 +++--- .../comedi/drivers/amplc_dio200_common.c | 42 +++--- drivers/staging/comedi/drivers/cb_das16_cs.c | 31 ++--- drivers/staging/comedi/drivers/dt2801.c | 31 ++--- drivers/staging/comedi/drivers/dt3000.c | 41 +++--- drivers/staging/comedi/drivers/gsc_hpdi.c | 33 ++--- drivers/staging/comedi/drivers/ii_pci20kc.c | 37 ++---- drivers/staging/comedi/drivers/me4000.c | 123 ++++++------------ drivers/staging/comedi/drivers/me_daq.c | 50 +++---- drivers/staging/comedi/drivers/ni_at_ao.c | 55 ++++---- drivers/staging/comedi/drivers/pcm3724.c | 45 +++---- drivers/staging/comedi/drivers/s526.c | 45 ++++--- 15 files changed, 263 insertions(+), 433 deletions(-) diff --git a/drivers/staging/comedi/drivers/8255.c b/drivers/staging/comedi/drivers/8255.c index 1fa29ac4eb5df..2f070fdbbb1d3 100644 --- a/drivers/staging/comedi/drivers/8255.c +++ b/drivers/staging/comedi/drivers/8255.c @@ -184,39 +184,29 @@ static void subdev_8255_do_config(struct comedi_device *dev, static int subdev_8255_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { + unsigned int chan = CR_CHAN(insn->chanspec); unsigned int mask; - unsigned int bits; + int ret; - mask = 1 << CR_CHAN(insn->chanspec); - if (mask & 0x0000ff) - bits = 0x0000ff; - else if (mask & 0x00ff00) - bits = 0x00ff00; - else if (mask & 0x0f0000) - bits = 0x0f0000; + if (chan < 8) + mask = 0x0000ff; + else if (chan < 16) + mask = 0x00ff00; + else if (chan < 20) + mask = 0x0f0000; else - bits = 0xf00000; - - switch (data[0]) { - case INSN_CONFIG_DIO_INPUT: - s->io_bits &= ~bits; - break; - case INSN_CONFIG_DIO_OUTPUT: - s->io_bits |= bits; - break; - case INSN_CONFIG_DIO_QUERY: - data[1] = (s->io_bits & bits) ? COMEDI_OUTPUT : COMEDI_INPUT; - return insn->n; - break; - default: - return -EINVAL; - } + mask = 0xf00000; + + ret = comedi_dio_insn_config(dev, s, insn, data, mask); + if (ret) + return ret; subdev_8255_do_config(dev, s); - return 1; + return insn->n; } static int subdev_8255_cmdtest(struct comedi_device *dev, diff --git a/drivers/staging/comedi/drivers/addi_apci_16xx.c b/drivers/staging/comedi/drivers/addi_apci_16xx.c index 43296a6e7d4e6..96523744b8de5 100644 --- a/drivers/staging/comedi/drivers/addi_apci_16xx.c +++ b/drivers/staging/comedi/drivers/addi_apci_16xx.c @@ -60,36 +60,22 @@ static int apci16xx_insn_config(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - unsigned int chan_mask = 1 << CR_CHAN(insn->chanspec); - unsigned int bits; + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned int mask; + int ret; - /* - * Each 8-bit "port" is configurable as either input or - * output. Changing the configuration of any channel in - * a port changes the entire port. - */ - if (chan_mask & 0x000000ff) - bits = 0x000000ff; - else if (chan_mask & 0x0000ff00) - bits = 0x0000ff00; - else if (chan_mask & 0x00ff0000) - bits = 0x00ff0000; + if (chan < 8) + mask = 0x000000ff; + else if (chan < 16) + mask = 0x0000ff00; + else if (chan < 24) + mask = 0x00ff0000; else - bits = 0xff000000; - - switch (data[0]) { - case INSN_CONFIG_DIO_INPUT: - s->io_bits &= ~bits; - break; - case INSN_CONFIG_DIO_OUTPUT: - s->io_bits |= bits; - break; - case INSN_CONFIG_DIO_QUERY: - data[1] = (s->io_bits & bits) ? COMEDI_INPUT : COMEDI_OUTPUT; - return insn->n; - default: - return -EINVAL; - } + mask = 0xff000000; + + ret = comedi_dio_insn_config(dev, s, insn, data, mask); + if (ret) + return ret; outl(s->io_bits, dev->iobase + APCI16XX_DIR_REG(s->index)); diff --git a/drivers/staging/comedi/drivers/addi_apci_3xxx.c b/drivers/staging/comedi/drivers/addi_apci_3xxx.c index dbc0678027ca7..cf5dd10eaf91d 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3xxx.c +++ b/drivers/staging/comedi/drivers/addi_apci_3xxx.c @@ -686,38 +686,28 @@ static int apci3xxx_dio_insn_config(struct comedi_device *dev, unsigned int *data) { unsigned int chan = CR_CHAN(insn->chanspec); - unsigned int mask = 1 << chan; - unsigned int bits; + unsigned int mask; + int ret; /* * Port 0 (channels 0-7) are always inputs * Port 1 (channels 8-15) are always outputs * Port 2 (channels 16-23) are programmable i/o - * - * Changing any channel in port 2 changes the entire port. */ - if (mask & 0xff0000) - bits = 0xff0000; - else - bits = 0; - - switch (data[0]) { - case INSN_CONFIG_DIO_INPUT: - s->io_bits &= ~bits; - break; - case INSN_CONFIG_DIO_OUTPUT: - s->io_bits |= bits; - break; - case INSN_CONFIG_DIO_QUERY: - data[1] = (s->io_bits & bits) ? COMEDI_OUTPUT : COMEDI_INPUT; - return insn->n; - default: - return -EINVAL; + if (chan < 16) { + if (data[0] != INSN_CONFIG_DIO_QUERY) + return -EINVAL; + } else { + /* changing any channel in port 2 changes the entire port */ + mask = 0xff0000; } + ret = comedi_dio_insn_config(dev, s, insn, data, mask); + if (ret) + return ret; + /* update port 2 configuration */ - if (bits) - outl((s->io_bits >> 24) & 0xff, dev->iobase + 224); + outl((s->io_bits >> 24) & 0xff, dev->iobase + 224); return insn->n; } diff --git a/drivers/staging/comedi/drivers/adv_pci1723.c b/drivers/staging/comedi/drivers/adv_pci1723.c index f914fb1f571be..b793d6987b843 100644 --- a/drivers/staging/comedi/drivers/adv_pci1723.c +++ b/drivers/staging/comedi/drivers/adv_pci1723.c @@ -180,38 +180,29 @@ static int pci1723_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { + unsigned int chan = CR_CHAN(insn->chanspec); unsigned int mask; - unsigned int bits; - unsigned short dio_mode; + unsigned short mode; + int ret; - mask = 1 << CR_CHAN(insn->chanspec); - if (mask & 0x00FF) - bits = 0x00FF; + if (chan < 8) + mask = 0x00ff; else - bits = 0xFF00; + mask = 0xff00; - switch (data[0]) { - case INSN_CONFIG_DIO_INPUT: - s->io_bits &= ~bits; - break; - case INSN_CONFIG_DIO_OUTPUT: - s->io_bits |= bits; - break; - case INSN_CONFIG_DIO_QUERY: - data[1] = (s->io_bits & bits) ? COMEDI_OUTPUT : COMEDI_INPUT; - return insn->n; - default: - return -EINVAL; - } + ret = comedi_dio_insn_config(dev, s, insn, data, mask); + if (ret) + return ret; /* update hardware DIO mode */ - dio_mode = 0x0000; /* low byte output, high byte output */ - if ((s->io_bits & 0x00FF) == 0) - dio_mode |= 0x0001; /* low byte input */ - if ((s->io_bits & 0xFF00) == 0) - dio_mode |= 0x0002; /* high byte input */ - outw(dio_mode, dev->iobase + PCI1723_DIGITAL_IO_PORT_SET); - return 1; + mode = 0x0000; /* assume output */ + if (!(s->io_bits & 0x00ff)) + mode |= 0x0001; /* low byte input */ + if (!(s->io_bits & 0xff00)) + mode |= 0x0002; /* high byte input */ + outw(mode, dev->iobase + PCI1723_DIGITAL_IO_PORT_SET); + + return insn->n; } /* diff --git a/drivers/staging/comedi/drivers/amplc_dio200_common.c b/drivers/staging/comedi/drivers/amplc_dio200_common.c index 32c490b27b555..c1f723e861461 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200_common.c +++ b/drivers/staging/comedi/drivers/amplc_dio200_common.c @@ -976,34 +976,26 @@ static int dio200_subdev_8255_config(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { + unsigned int chan = CR_CHAN(insn->chanspec); unsigned int mask; - unsigned int bits; - - mask = 1 << CR_CHAN(insn->chanspec); - if (mask & 0x0000ff) - bits = 0x0000ff; - else if (mask & 0x00ff00) - bits = 0x00ff00; - else if (mask & 0x0f0000) - bits = 0x0f0000; + int ret; + + if (chan < 8) + mask = 0x0000ff; + else if (chan < 16) + mask = 0x00ff00; + else if (chan < 20) + mask = 0x0f0000; else - bits = 0xf00000; - switch (data[0]) { - case INSN_CONFIG_DIO_INPUT: - s->io_bits &= ~bits; - break; - case INSN_CONFIG_DIO_OUTPUT: - s->io_bits |= bits; - break; - case INSN_CONFIG_DIO_QUERY: - data[1] = (s->io_bits & bits) ? COMEDI_OUTPUT : COMEDI_INPUT; - return insn->n; - break; - default: - return -EINVAL; - } + mask = 0xf00000; + + ret = comedi_dio_insn_config(dev, s, insn, data, mask); + if (ret) + return ret; + dio200_subdev_8255_set_dir(dev, s); - return 1; + + return insn->n; } /* diff --git a/drivers/staging/comedi/drivers/cb_das16_cs.c b/drivers/staging/comedi/drivers/cb_das16_cs.c index 05e01a3b5af6a..0ce93da70847c 100644 --- a/drivers/staging/comedi/drivers/cb_das16_cs.c +++ b/drivers/staging/comedi/drivers/cb_das16_cs.c @@ -341,33 +341,22 @@ static int das16cs_dio_insn_bits(struct comedi_device *dev, static int das16cs_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { struct das16cs_private *devpriv = dev->private; - int chan = CR_CHAN(insn->chanspec); - int bits; + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned int mask; + int ret; if (chan < 4) - bits = 0x0f; + mask = 0x0f; else - bits = 0xf0; + mask = 0xf0; - switch (data[0]) { - case INSN_CONFIG_DIO_OUTPUT: - s->io_bits |= bits; - break; - case INSN_CONFIG_DIO_INPUT: - s->io_bits &= bits; - break; - case INSN_CONFIG_DIO_QUERY: - data[1] = - (s->io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT; - return insn->n; - break; - default: - return -EINVAL; - break; - } + ret = comedi_dio_insn_config(dev, s, insn, data, mask); + if (ret) + return ret; devpriv->status2 &= ~0x00c0; devpriv->status2 |= (s->io_bits & 0xf0) ? 0x0080 : 0; diff --git a/drivers/staging/comedi/drivers/dt2801.c b/drivers/staging/comedi/drivers/dt2801.c index e0e7beab7274b..38918a1198aa8 100644 --- a/drivers/staging/comedi/drivers/dt2801.c +++ b/drivers/staging/comedi/drivers/dt2801.c @@ -551,32 +551,19 @@ static int dt2801_dio_insn_bits(struct comedi_device *dev, static int dt2801_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { - int which = 0; + int ret; - if (s == &dev->subdevices[3]) - which = 1; + ret = comedi_dio_insn_config(dev, s, insn, data, 0xff); + if (ret) + return ret; - /* configure */ - switch (data[0]) { - case INSN_CONFIG_DIO_OUTPUT: - s->io_bits = 0xff; - dt2801_writecmd(dev, DT_C_SET_DIGOUT); - break; - case INSN_CONFIG_DIO_INPUT: - s->io_bits = 0; - dt2801_writecmd(dev, DT_C_SET_DIGIN); - break; - case INSN_CONFIG_DIO_QUERY: - data[1] = s->io_bits ? COMEDI_OUTPUT : COMEDI_INPUT; - return insn->n; - default: - return -EINVAL; - } - dt2801_writedata(dev, which); + dt2801_writecmd(dev, s->io_bits ? DT_C_SET_DIGOUT : DT_C_SET_DIGIN); + dt2801_writedata(dev, (s == &dev->subdevices[3]) ? 1 : 0); - return 1; + return insn->n; } /* diff --git a/drivers/staging/comedi/drivers/dt3000.c b/drivers/staging/comedi/drivers/dt3000.c index e4748da1993b8..64ef87598b607 100644 --- a/drivers/staging/comedi/drivers/dt3000.c +++ b/drivers/staging/comedi/drivers/dt3000.c @@ -642,32 +642,23 @@ static void dt3k_dio_config(struct comedi_device *dev, int bits) static int dt3k_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { - int mask; - - mask = (CR_CHAN(insn->chanspec) < 4) ? 0x0f : 0xf0; - - switch (data[0]) { - case INSN_CONFIG_DIO_OUTPUT: - s->io_bits |= mask; - break; - case INSN_CONFIG_DIO_INPUT: - s->io_bits &= ~mask; - break; - case INSN_CONFIG_DIO_QUERY: - data[1] = - (s-> - io_bits & (1 << CR_CHAN(insn->chanspec))) ? COMEDI_OUTPUT : - COMEDI_INPUT; - return insn->n; - break; - default: - return -EINVAL; - break; - } - mask = (s->io_bits & 0x01) | ((s->io_bits & 0x10) >> 3); - dt3k_dio_config(dev, mask); + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned int mask; + int ret; + + if (chan < 4) + mask = 0x0f; + else + mask = 0xf0; + + ret = comedi_dio_insn_config(dev, s, insn, data, mask); + if (ret) + return ret; + + dt3k_dio_config(dev, (s->io_bits & 0x01) | ((s->io_bits & 0x10) >> 3)); return insn->n; } diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c b/drivers/staging/comedi/drivers/gsc_hpdi.c index cdcc8f42e2093..559bf5583530c 100644 --- a/drivers/staging/comedi/drivers/gsc_hpdi.c +++ b/drivers/staging/comedi/drivers/gsc_hpdi.c @@ -224,37 +224,26 @@ struct hpdi_private { volatile uint32_t bits[24]; /* number of bytes at which to generate COMEDI_CB_BLOCK events */ volatile unsigned int block_size; - unsigned dio_config_output:1; }; static int dio_config_insn(struct comedi_device *dev, - struct comedi_subdevice *s, struct comedi_insn *insn, + struct comedi_subdevice *s, + struct comedi_insn *insn, unsigned int *data) { - struct hpdi_private *devpriv = dev->private; + int ret; switch (data[0]) { - case INSN_CONFIG_DIO_OUTPUT: - devpriv->dio_config_output = 1; - return insn->n; - break; - case INSN_CONFIG_DIO_INPUT: - devpriv->dio_config_output = 0; - return insn->n; - break; - case INSN_CONFIG_DIO_QUERY: - data[1] = - devpriv->dio_config_output ? COMEDI_OUTPUT : COMEDI_INPUT; - return insn->n; - break; case INSN_CONFIG_BLOCK_SIZE: return dio_config_block_size(dev, data); - break; default: + ret = comedi_dio_insn_config(dev, s, insn, data, 0xffffffff); + if (ret) + return ret; break; } - return -EINVAL; + return insn->n; } static void disable_plx_interrupts(struct comedi_device *dev) @@ -673,9 +662,7 @@ static int di_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s, static int hpdi_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_cmd *cmd) { - struct hpdi_private *devpriv = dev->private; - - if (devpriv->dio_config_output) + if (s->io_bits) return -EINVAL; else return di_cmd_test(dev, s, cmd); @@ -746,9 +733,7 @@ static int di_cmd(struct comedi_device *dev, struct comedi_subdevice *s) static int hpdi_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { - struct hpdi_private *devpriv = dev->private; - - if (devpriv->dio_config_output) + if (s->io_bits) return -EINVAL; else return di_cmd(dev, s); diff --git a/drivers/staging/comedi/drivers/ii_pci20kc.c b/drivers/staging/comedi/drivers/ii_pci20kc.c index 954c5397f33c8..5c3a318b46401 100644 --- a/drivers/staging/comedi/drivers/ii_pci20kc.c +++ b/drivers/staging/comedi/drivers/ii_pci20kc.c @@ -350,31 +350,22 @@ static int ii20k_dio_insn_config(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - unsigned int mask = 1 << CR_CHAN(insn->chanspec); - unsigned int bits; - - if (mask & 0x000000ff) - bits = 0x000000ff; - else if (mask & 0x0000ff00) - bits = 0x0000ff00; - else if (mask & 0x00ff0000) - bits = 0x00ff0000; + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned int mask; + int ret; + + if (chan < 8) + mask = 0x000000ff; + else if (chan < 16) + mask = 0x0000ff00; + else if (chan < 24) + mask = 0x00ff0000; else - bits = 0xff000000; + mask = 0xff000000; - switch (data[0]) { - case INSN_CONFIG_DIO_INPUT: - s->io_bits &= ~bits; - break; - case INSN_CONFIG_DIO_OUTPUT: - s->io_bits |= bits; - break; - case INSN_CONFIG_DIO_QUERY: - data[1] = (s->io_bits & bits) ? COMEDI_OUTPUT : COMEDI_INPUT; - return insn->n; - default: - return -EINVAL; - } + ret = comedi_dio_insn_config(dev, s, insn, data, mask); + if (ret) + return ret; ii20k_dio_config(dev, s); diff --git a/drivers/staging/comedi/drivers/me4000.c b/drivers/staging/comedi/drivers/me4000.c index 1eda40a9332ee..8f4afadab76a6 100644 --- a/drivers/staging/comedi/drivers/me4000.c +++ b/drivers/staging/comedi/drivers/me4000.c @@ -1358,98 +1358,57 @@ static int me4000_dio_insn_bits(struct comedi_device *dev, static int me4000_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { - unsigned long tmp; - int chan = CR_CHAN(insn->chanspec); + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned int mask; + unsigned int tmp; + int ret; - switch (data[0]) { - default: - return -EINVAL; - case INSN_CONFIG_DIO_QUERY: - data[1] = - (s->io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT; - return insn->n; - case INSN_CONFIG_DIO_INPUT: - case INSN_CONFIG_DIO_OUTPUT: - break; - } + if (chan < 8) + mask = 0x000000ff; + else if (chan < 16) + mask = 0x0000ff00; + else if (chan < 24) + mask = 0x00ff0000; + else + mask = 0xff000000; - /* - * The input or output configuration of each digital line is - * configured by a special insn_config instruction. chanspec - * contains the channel to be changed, and data[0] contains the - * value INSN_CONFIG_DIO_INPUT or INSN_CONFIG_DIO_OUTPUT. - * On the ME-4000 it is only possible to switch port wise (8 bit) - */ + ret = comedi_dio_insn_config(dev, s, insn, data, mask); + if (ret) + return ret; tmp = inl(dev->iobase + ME4000_DIO_CTRL_REG); + tmp &= ~(ME4000_DIO_CTRL_BIT_MODE_0 | ME4000_DIO_CTRL_BIT_MODE_1 | + ME4000_DIO_CTRL_BIT_MODE_2 | ME4000_DIO_CTRL_BIT_MODE_3 | + ME4000_DIO_CTRL_BIT_MODE_4 | ME4000_DIO_CTRL_BIT_MODE_5 | + ME4000_DIO_CTRL_BIT_MODE_6 | ME4000_DIO_CTRL_BIT_MODE_7); + if (s->io_bits & 0x000000ff) + tmp |= ME4000_DIO_CTRL_BIT_MODE_0; + if (s->io_bits & 0x0000ff00) + tmp |= ME4000_DIO_CTRL_BIT_MODE_2; + if (s->io_bits & 0x00ff0000) + tmp |= ME4000_DIO_CTRL_BIT_MODE_4; + if (s->io_bits & 0xff000000) + tmp |= ME4000_DIO_CTRL_BIT_MODE_6; - if (data[0] == INSN_CONFIG_DIO_OUTPUT) { - if (chan < 8) { - s->io_bits |= 0xFF; - tmp &= ~(ME4000_DIO_CTRL_BIT_MODE_0 | - ME4000_DIO_CTRL_BIT_MODE_1); - tmp |= ME4000_DIO_CTRL_BIT_MODE_0; - } else if (chan < 16) { - /* - * Chech for optoisolated ME-4000 version. - * If one the first port is a fixed output - * port and the second is a fixed input port. - */ - if (!inl(dev->iobase + ME4000_DIO_DIR_REG)) - return -ENODEV; - - s->io_bits |= 0xFF00; - tmp &= ~(ME4000_DIO_CTRL_BIT_MODE_2 | - ME4000_DIO_CTRL_BIT_MODE_3); - tmp |= ME4000_DIO_CTRL_BIT_MODE_2; - } else if (chan < 24) { - s->io_bits |= 0xFF0000; - tmp &= ~(ME4000_DIO_CTRL_BIT_MODE_4 | - ME4000_DIO_CTRL_BIT_MODE_5); - tmp |= ME4000_DIO_CTRL_BIT_MODE_4; - } else if (chan < 32) { - s->io_bits |= 0xFF000000; - tmp &= ~(ME4000_DIO_CTRL_BIT_MODE_6 | - ME4000_DIO_CTRL_BIT_MODE_7); - tmp |= ME4000_DIO_CTRL_BIT_MODE_6; - } else { - return -EINVAL; - } - } else { - if (chan < 8) { - /* - * Chech for optoisolated ME-4000 version. - * If one the first port is a fixed output - * port and the second is a fixed input port. - */ - if (!inl(dev->iobase + ME4000_DIO_DIR_REG)) - return -ENODEV; - - s->io_bits &= ~0xFF; - tmp &= ~(ME4000_DIO_CTRL_BIT_MODE_0 | - ME4000_DIO_CTRL_BIT_MODE_1); - } else if (chan < 16) { - s->io_bits &= ~0xFF00; - tmp &= ~(ME4000_DIO_CTRL_BIT_MODE_2 | - ME4000_DIO_CTRL_BIT_MODE_3); - } else if (chan < 24) { - s->io_bits &= ~0xFF0000; - tmp &= ~(ME4000_DIO_CTRL_BIT_MODE_4 | - ME4000_DIO_CTRL_BIT_MODE_5); - } else if (chan < 32) { - s->io_bits &= ~0xFF000000; - tmp &= ~(ME4000_DIO_CTRL_BIT_MODE_6 | - ME4000_DIO_CTRL_BIT_MODE_7); - } else { - return -EINVAL; - } + /* + * Check for optoisolated ME-4000 version. + * If one the first port is a fixed output + * port and the second is a fixed input port. + */ + if (inl(dev->iobase + ME4000_DIO_DIR_REG)) { + s->io_bits |= 0x000000ff; + s->io_bits &= ~0x0000ff00; + tmp |= ME4000_DIO_CTRL_BIT_MODE_0; + tmp &= ~(ME4000_DIO_CTRL_BIT_MODE_2 | + ME4000_DIO_CTRL_BIT_MODE_3); } outl(tmp, dev->iobase + ME4000_DIO_CTRL_REG); - return 1; + return insn->n; } /*============================================================================= diff --git a/drivers/staging/comedi/drivers/me_daq.c b/drivers/staging/comedi/drivers/me_daq.c index e8a743c2f9a16..a6f6d4a46587f 100644 --- a/drivers/staging/comedi/drivers/me_daq.c +++ b/drivers/staging/comedi/drivers/me_daq.c @@ -186,38 +186,30 @@ static int me_dio_insn_config(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct me_private_data *dev_private = dev->private; - unsigned int mask = 1 << CR_CHAN(insn->chanspec); - unsigned int bits; - unsigned int port; + struct me_private_data *devpriv = dev->private; + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned int mask; + int ret; - if (mask & 0x0000ffff) { - bits = 0x0000ffff; - port = ENABLE_PORT_A; - } else { - bits = 0xffff0000; - port = ENABLE_PORT_B; - } + if (chan < 16) + mask = 0x0000ffff; + else + mask = 0xffff0000; - switch (data[0]) { - case INSN_CONFIG_DIO_INPUT: - s->io_bits &= ~bits; - dev_private->control_2 &= ~port; - break; - case INSN_CONFIG_DIO_OUTPUT: - s->io_bits |= bits; - dev_private->control_2 |= port; - break; - case INSN_CONFIG_DIO_QUERY: - data[1] = (s->io_bits & bits) ? COMEDI_OUTPUT : COMEDI_INPUT; - return insn->n; - break; - default: - return -EINVAL; - } + ret = comedi_dio_insn_config(dev, s, insn, data, mask); + if (ret) + return ret; - /* Update the port configuration */ - writew(dev_private->control_2, dev_private->me_regbase + ME_CONTROL_2); + if (s->io_bits & 0x0000ffff) + devpriv->control_2 |= ENABLE_PORT_A; + else + devpriv->control_2 &= ~ENABLE_PORT_A; + if (s->io_bits & 0xffff0000) + devpriv->control_2 |= ENABLE_PORT_B; + else + devpriv->control_2 &= ~ENABLE_PORT_B; + + writew(devpriv->control_2, devpriv->me_regbase + ME_CONTROL_2); return insn->n; } diff --git a/drivers/staging/comedi/drivers/ni_at_ao.c b/drivers/staging/comedi/drivers/ni_at_ao.c index 0025496bc643c..b9122fd835e1e 100644 --- a/drivers/staging/comedi/drivers/ni_at_ao.c +++ b/drivers/staging/comedi/drivers/ni_at_ao.c @@ -248,42 +248,35 @@ static int atao_dio_insn_bits(struct comedi_device *dev, static int atao_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { struct atao_private *devpriv = dev->private; - int chan = CR_CHAN(insn->chanspec); - unsigned int mask, bit; - - /* The input or output configuration of each digital line is - * configured by a special insn_config instruction. chanspec - * contains the channel to be changed, and data[0] contains the - * value COMEDI_INPUT or COMEDI_OUTPUT. */ - - mask = (chan < 4) ? 0x0f : 0xf0; - bit = (chan < 4) ? DOUTEN1 : DOUTEN2; - - switch (data[0]) { - case INSN_CONFIG_DIO_OUTPUT: - s->io_bits |= mask; - devpriv->cfg3 |= bit; - break; - case INSN_CONFIG_DIO_INPUT: - s->io_bits &= ~mask; - devpriv->cfg3 &= ~bit; - break; - case INSN_CONFIG_DIO_QUERY: - data[1] = - (s->io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT; - return insn->n; - break; - default: - return -EINVAL; - break; - } + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned int mask; + int ret; + + if (chan < 4) + mask = 0x0f; + else + mask = 0xf0; + + ret = comedi_dio_insn_config(dev, s, insn, data, mask); + if (ret) + return ret; + + if (s->io_bits & 0x0f) + devpriv->cfg3 |= DOUTEN1; + else + devpriv->cfg3 &= ~DOUTEN1; + if (s->io_bits & 0xf0) + devpriv->cfg3 |= DOUTEN2; + else + devpriv->cfg3 &= ~DOUTEN2; outw(devpriv->cfg3, dev->iobase + ATAO_CFG3); - return 1; + return insn->n; } /* diff --git a/drivers/staging/comedi/drivers/pcm3724.c b/drivers/staging/comedi/drivers/pcm3724.c index cca972ebd010e..cc1dc7f66e5b5 100644 --- a/drivers/staging/comedi/drivers/pcm3724.c +++ b/drivers/staging/comedi/drivers/pcm3724.c @@ -184,39 +184,30 @@ static void enable_chan(struct comedi_device *dev, struct comedi_subdevice *s, /* overriding the 8255 insn config */ static int subdev_3724_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { + unsigned int chan = CR_CHAN(insn->chanspec); unsigned int mask; - unsigned int bits; - - mask = 1 << CR_CHAN(insn->chanspec); - if (mask & 0x0000ff) - bits = 0x0000ff; - else if (mask & 0x00ff00) - bits = 0x00ff00; - else if (mask & 0x0f0000) - bits = 0x0f0000; + int ret; + + if (chan < 8) + mask = 0x0000ff; + else if (chan < 16) + mask = 0x00ff00; + else if (chan < 20) + mask = 0x0f0000; else - bits = 0xf00000; - - switch (data[0]) { - case INSN_CONFIG_DIO_INPUT: - s->io_bits &= ~bits; - break; - case INSN_CONFIG_DIO_OUTPUT: - s->io_bits |= bits; - break; - case INSN_CONFIG_DIO_QUERY: - data[1] = (s->io_bits & bits) ? COMEDI_OUTPUT : COMEDI_INPUT; - return insn->n; - break; - default: - return -EINVAL; - } + mask = 0xf00000; + + ret = comedi_dio_insn_config(dev, s, insn, data, mask); + if (ret) + return ret; do_3724_config(dev, s, insn->chanspec); enable_chan(dev, s, insn->chanspec); - return 1; + + return insn->n; } static int pcm3724_attach(struct comedi_device *dev, diff --git a/drivers/staging/comedi/drivers/s526.c b/drivers/staging/comedi/drivers/s526.c index 6670b865256b3..d629463b85a2a 100644 --- a/drivers/staging/comedi/drivers/s526.c +++ b/drivers/staging/comedi/drivers/s526.c @@ -515,32 +515,35 @@ static int s526_dio_insn_bits(struct comedi_device *dev, static int s526_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { unsigned int chan = CR_CHAN(insn->chanspec); - int group, mask; + unsigned int mask; + int ret; + + if (chan < 4) + mask = 0x0f; + else + mask = 0xf0; + + ret = comedi_dio_insn_config(dev, s, insn, data, mask); + if (ret) + return ret; + + /* bit 10/11 set the group 1/2's mode */ + if (s->io_bits & 0x0f) + s->state |= (1 << 10); + else + s->state &= ~(1 << 10); + if (s->io_bits & 0xf0) + s->state |= (1 << 11); + else + s->state &= ~(1 << 11); - group = chan >> 2; - mask = 0xF << (group << 2); - switch (data[0]) { - case INSN_CONFIG_DIO_OUTPUT: - /* bit 10/11 set the group 1/2's mode */ - s->state |= 1 << (group + 10); - s->io_bits |= mask; - break; - case INSN_CONFIG_DIO_INPUT: - s->state &= ~(1 << (group + 10)); /* 1 is output, 0 is input. */ - s->io_bits &= ~mask; - break; - case INSN_CONFIG_DIO_QUERY: - data[1] = (s->io_bits & mask) ? COMEDI_OUTPUT : COMEDI_INPUT; - return insn->n; - default: - return -EINVAL; - } outw(s->state, dev->iobase + REG_DIO); - return 1; + return insn->n; } static int s526_attach(struct comedi_device *dev, struct comedi_devconfig *it) -- GitLab From 99ac7cccb50fcbacdc21620a898e6d64b58a2282 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 12 Aug 2013 15:16:24 -0700 Subject: [PATCH 601/942] Revert "staging: comedi: core: introduce comedi_dio_insn_config()" This reverts commit 4f76463d3b8f8cc0cac5bb292ec766848f3f4fa1. I applied an incorrect version here as well :( Cc: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedidev.h | 4 --- drivers/staging/comedi/drivers.c | 40 ------------------------------ 2 files changed, 44 deletions(-) diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index f2f75b9dfb863..98058b9097e61 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -342,10 +342,6 @@ void comedi_buf_memcpy_from(struct comedi_async *async, unsigned int offset, /* drivers.c - general comedi driver functions */ -int comedi_dio_insn_config(struct comedi_device *, struct comedi_subdevice *, - struct comedi_insn *, unsigned int *data, - unsigned int mask); - void *comedi_alloc_devpriv(struct comedi_device *, size_t); int comedi_alloc_subdevices(struct comedi_device *, int); diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index 60fd81c71a127..791a26bd5f63c 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -150,46 +150,6 @@ int insn_inval(struct comedi_device *dev, struct comedi_subdevice *s, return -EINVAL; } -/** - * comedi_dio_insn_config() - boilerplate (*insn_config) for DIO subdevices. - * @dev: comedi_device struct - * @s: comedi_subdevice struct - * @insn: comedi_insn struct - * @data: parameters for the @insn - * @mask: io_bits mask for grouped channels - */ -int comedi_dio_insn_config(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data, - unsigned int mask) -{ - unsigned int chan_mask = 1 << CR_CHAN(insn->chanspec); - - if (!mask) - mask = chan_mask; - - switch (data[0]) { - case INSN_CONFIG_DIO_INPUT: - s->io_bits &= ~mask; - break; - - case INSN_CONFIG_DIO_OUTPUT: - s->io_bits |= mask; - break; - - case INSN_CONFIG_DIO_QUERY: - data[1] = (s->io_bits & mask) ? COMEDI_OUTPUT : COMEDI_INPUT; - return insn->n; - - default: - return -EINVAL; - } - - return 0; -} -EXPORT_SYMBOL_GPL(comedi_dio_insn_config); - static int insn_rw_emulate_bits(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) -- GitLab From 987f3c86a14a67d16bcc648d062bfa46cbd2e552 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 12 Aug 2013 15:17:17 -0700 Subject: [PATCH 602/942] Revert "staging: comedi: skel: use comedi_dio_insn_config()" This reverts commit 42ef678bef336a83fd0ae0b03a56c0a93665a18b. It's incorrect as well... time for more coffee... Cc: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/skel.c | 42 +++++++++++++++------------ 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/drivers/staging/comedi/drivers/skel.c b/drivers/staging/comedi/drivers/skel.c index 9e964950a560e..f76fd09e7bd31 100644 --- a/drivers/staging/comedi/drivers/skel.c +++ b/drivers/staging/comedi/drivers/skel.c @@ -362,27 +362,31 @@ static int skel_dio_insn_bits(struct comedi_device *dev, static int skel_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) + struct comedi_insn *insn, unsigned int *data) { - int ret; - - /* - * The input or output configuration of each digital line is - * configured by special insn_config instructions. - * - * chanspec contains the channel to be changed - * data[0] contains the instruction to perform on the channel - * - * Normally the core provided comedi_dio_insn_config() function - * can be used to handle the boilerplpate. - */ - ret = comedi_dio_insn_config(dev, s, insn, data, 0); - if (ret) - return ret; + int chan = CR_CHAN(insn->chanspec); - /* Update the hardware to the new configuration */ - /* outw(s->io_bits, dev->iobase + SKEL_DIO_CONFIG); */ + /* The input or output configuration of each digital line is + * configured by a special insn_config instruction. chanspec + * contains the channel to be changed, and data[0] contains the + * value COMEDI_INPUT or COMEDI_OUTPUT. */ + switch (data[0]) { + case INSN_CONFIG_DIO_OUTPUT: + s->io_bits |= 1 << chan; + break; + case INSN_CONFIG_DIO_INPUT: + s->io_bits &= ~(1 << chan); + break; + case INSN_CONFIG_DIO_QUERY: + data[1] = + (s->io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT; + return insn->n; + break; + default: + return -EINVAL; + break; + } + /* outw(s->io_bits,dev->iobase + SKEL_DIO_CONFIG); */ return insn->n; } -- GitLab From e523c6c86232eb5564662aa17199c676d127bc5e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 6 Aug 2013 09:31:35 -0700 Subject: [PATCH 603/942] staging: comedi: drivers: introduce comedi_dio_insn_config() DIO subdevices always handle the INSN_CONFIG_DIO_{INPUT,OUTPUT} instructions to configure the DIO channels. They also always handle the INSN_CONFIG_DIO_QUERY instruction to query the configuration of a DIO channel. Introduce a helper function to handle the (*insn_config) boilerplate for comedi DIO subdevices. This function has the same paramters as (*insn_config) functions with an additional parameter to allow the caller to pass a 'mask' value for grouped DIO channels. This function returns: 0 if the instruction was successful but requires additional handling by the caller (INSN_CONFIG_DIO_{INPUT,OUTPUT} insn->n if the instruction was handled (INSN_CONFIG_DIO_QUERY) -EINVAL for all unhandled instructions The caller is responsible for actually configuring the hardware based on the configuration (s->io_bits). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Cc: Greg Kroah-Hartman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedidev.h | 4 +++ drivers/staging/comedi/drivers.c | 40 ++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index 98058b9097e61..f2f75b9dfb863 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -342,6 +342,10 @@ void comedi_buf_memcpy_from(struct comedi_async *async, unsigned int offset, /* drivers.c - general comedi driver functions */ +int comedi_dio_insn_config(struct comedi_device *, struct comedi_subdevice *, + struct comedi_insn *, unsigned int *data, + unsigned int mask); + void *comedi_alloc_devpriv(struct comedi_device *, size_t); int comedi_alloc_subdevices(struct comedi_device *, int); diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index 791a26bd5f63c..60fd81c71a127 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -150,6 +150,46 @@ int insn_inval(struct comedi_device *dev, struct comedi_subdevice *s, return -EINVAL; } +/** + * comedi_dio_insn_config() - boilerplate (*insn_config) for DIO subdevices. + * @dev: comedi_device struct + * @s: comedi_subdevice struct + * @insn: comedi_insn struct + * @data: parameters for the @insn + * @mask: io_bits mask for grouped channels + */ +int comedi_dio_insn_config(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data, + unsigned int mask) +{ + unsigned int chan_mask = 1 << CR_CHAN(insn->chanspec); + + if (!mask) + mask = chan_mask; + + switch (data[0]) { + case INSN_CONFIG_DIO_INPUT: + s->io_bits &= ~mask; + break; + + case INSN_CONFIG_DIO_OUTPUT: + s->io_bits |= mask; + break; + + case INSN_CONFIG_DIO_QUERY: + data[1] = (s->io_bits & mask) ? COMEDI_OUTPUT : COMEDI_INPUT; + return insn->n; + + default: + return -EINVAL; + } + + return 0; +} +EXPORT_SYMBOL_GPL(comedi_dio_insn_config); + static int insn_rw_emulate_bits(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) -- GitLab From f3508b2294516d39d60d68ddab67dd658721bdc9 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 6 Aug 2013 09:31:59 -0700 Subject: [PATCH 604/942] staging: comedi: skel: use comedi_dio_insn_config() Convert this driver to use the comedi_dio_insn_config() helper function. Tidy up the comments to reflect the new code. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Cc: Greg Kroah-Hartman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/skel.c | 42 ++++++++++++--------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/drivers/staging/comedi/drivers/skel.c b/drivers/staging/comedi/drivers/skel.c index f76fd09e7bd31..9e964950a560e 100644 --- a/drivers/staging/comedi/drivers/skel.c +++ b/drivers/staging/comedi/drivers/skel.c @@ -362,31 +362,27 @@ static int skel_dio_insn_bits(struct comedi_device *dev, static int skel_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { - int chan = CR_CHAN(insn->chanspec); + int ret; - /* The input or output configuration of each digital line is - * configured by a special insn_config instruction. chanspec - * contains the channel to be changed, and data[0] contains the - * value COMEDI_INPUT or COMEDI_OUTPUT. */ - switch (data[0]) { - case INSN_CONFIG_DIO_OUTPUT: - s->io_bits |= 1 << chan; - break; - case INSN_CONFIG_DIO_INPUT: - s->io_bits &= ~(1 << chan); - break; - case INSN_CONFIG_DIO_QUERY: - data[1] = - (s->io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT; - return insn->n; - break; - default: - return -EINVAL; - break; - } - /* outw(s->io_bits,dev->iobase + SKEL_DIO_CONFIG); */ + /* + * The input or output configuration of each digital line is + * configured by special insn_config instructions. + * + * chanspec contains the channel to be changed + * data[0] contains the instruction to perform on the channel + * + * Normally the core provided comedi_dio_insn_config() function + * can be used to handle the boilerplpate. + */ + ret = comedi_dio_insn_config(dev, s, insn, data, 0); + if (ret) + return ret; + + /* Update the hardware to the new configuration */ + /* outw(s->io_bits, dev->iobase + SKEL_DIO_CONFIG); */ return insn->n; } -- GitLab From ddf62f2c7bd041d35095b525ab33e3a3e0829aaa Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 6 Aug 2013 09:32:33 -0700 Subject: [PATCH 605/942] staging: comedi: drivers: use comedi_dio_insn_config() for simple cases Convert the drivers with simple, per channel programmable i/o, to use the comedi_dio_insn_config() helper function. All of these pass a 'mask' of '0' to comedi_dio_insn_config() this causes the per channel mask to be used to configure the i/o direction. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas64.c | 25 ++---- drivers/staging/comedi/drivers/ni_670x.c | 25 ++---- drivers/staging/comedi/drivers/ni_daq_700.c | 24 +++--- .../staging/comedi/drivers/ni_mio_common.c | 57 +++----------- drivers/staging/comedi/drivers/ni_pcidio.c | 29 ++----- drivers/staging/comedi/drivers/pcmmio.c | 71 ++++------------- drivers/staging/comedi/drivers/pcmuio.c | 24 ++---- drivers/staging/comedi/drivers/rtd520.c | 20 +---- drivers/staging/comedi/drivers/s626.c | 22 ++---- drivers/staging/comedi/drivers/ssv_dnp.c | 78 +++++++------------ drivers/staging/comedi/drivers/usbdux.c | 19 +---- drivers/staging/comedi/drivers/usbduxsigma.c | 20 +---- 12 files changed, 113 insertions(+), 301 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index e6e456163a29c..388dbd7a5d27f 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -3510,31 +3510,20 @@ static int do_wbits(struct comedi_device *dev, struct comedi_subdevice *s, static int dio_60xx_config_insn(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { struct pcidas64_private *devpriv = dev->private; - unsigned int mask; - - mask = 1 << CR_CHAN(insn->chanspec); + int ret; - switch (data[0]) { - case INSN_CONFIG_DIO_INPUT: - s->io_bits &= ~mask; - break; - case INSN_CONFIG_DIO_OUTPUT: - s->io_bits |= mask; - break; - case INSN_CONFIG_DIO_QUERY: - data[1] = (s->io_bits & mask) ? COMEDI_OUTPUT : COMEDI_INPUT; - return 2; - default: - return -EINVAL; - } + ret = comedi_dio_insn_config(dev, s, insn, data, 0); + if (ret) + return ret; writeb(s->io_bits, devpriv->dio_counter_iobase + DIO_DIRECTION_60XX_REG); - return 1; + return insn->n; } static int dio_60xx_wbits(struct comedi_device *dev, struct comedi_subdevice *s, diff --git a/drivers/staging/comedi/drivers/ni_670x.c b/drivers/staging/comedi/drivers/ni_670x.c index 02016258bd4e2..e2926ce3fb24b 100644 --- a/drivers/staging/comedi/drivers/ni_670x.c +++ b/drivers/staging/comedi/drivers/ni_670x.c @@ -158,27 +158,16 @@ static int ni_670x_dio_insn_bits(struct comedi_device *dev, static int ni_670x_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { struct ni_670x_private *devpriv = dev->private; - int chan = CR_CHAN(insn->chanspec); + int ret; + + ret = comedi_dio_insn_config(dev, s, insn, data, 0); + if (ret) + return ret; - switch (data[0]) { - case INSN_CONFIG_DIO_OUTPUT: - s->io_bits |= 1 << chan; - break; - case INSN_CONFIG_DIO_INPUT: - s->io_bits &= ~(1 << chan); - break; - case INSN_CONFIG_DIO_QUERY: - data[1] = - (s->io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT; - return insn->n; - break; - default: - return -EINVAL; - break; - } writel(s->io_bits, devpriv->mite->daq_io_addr + DIO_PORT0_DIR_OFFSET); return insn->n; diff --git a/drivers/staging/comedi/drivers/ni_daq_700.c b/drivers/staging/comedi/drivers/ni_daq_700.c index 41659652a491f..404f83de276da 100644 --- a/drivers/staging/comedi/drivers/ni_daq_700.c +++ b/drivers/staging/comedi/drivers/ni_daq_700.c @@ -90,21 +90,17 @@ static int daq700_dio_insn_bits(struct comedi_device *dev, static int daq700_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { - unsigned int chan = 1 << CR_CHAN(insn->chanspec); - - switch (data[0]) { - case INSN_CONFIG_DIO_INPUT: - break; - case INSN_CONFIG_DIO_OUTPUT: - break; - case INSN_CONFIG_DIO_QUERY: - data[1] = (s->io_bits & chan) ? COMEDI_OUTPUT : COMEDI_INPUT; - break; - default: - return -EINVAL; - } + int ret; + + ret = comedi_dio_insn_config(dev, s, insn, data, 0); + if (ret) + return ret; + + /* The DIO channels are not configurable, fix the io_bits */ + s->io_bits = 0x00ff; return insn->n; } diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 04f4b7dce332d..4e02770e834bd 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -3528,37 +3528,21 @@ static int ni_ao_reset(struct comedi_device *dev, struct comedi_subdevice *s) static int ni_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { struct ni_private *devpriv = dev->private; + int ret; -#ifdef DEBUG_DIO - printk("ni_dio_insn_config() chan=%d io=%d\n", - CR_CHAN(insn->chanspec), data[0]); -#endif - switch (data[0]) { - case INSN_CONFIG_DIO_OUTPUT: - s->io_bits |= 1 << CR_CHAN(insn->chanspec); - break; - case INSN_CONFIG_DIO_INPUT: - s->io_bits &= ~(1 << CR_CHAN(insn->chanspec)); - break; - case INSN_CONFIG_DIO_QUERY: - data[1] = - (s-> - io_bits & (1 << CR_CHAN(insn->chanspec))) ? COMEDI_OUTPUT : - COMEDI_INPUT; - return insn->n; - break; - default: - return -EINVAL; - } + ret = comedi_dio_insn_config(dev, s, insn, data, 0); + if (ret) + return ret; devpriv->dio_control &= ~DIO_Pins_Dir_Mask; devpriv->dio_control |= DIO_Pins_Dir(s->io_bits); devpriv->stc_writew(dev, devpriv->dio_control, DIO_Control_Register); - return 1; + return insn->n; } static int ni_dio_insn_bits(struct comedi_device *dev, @@ -3596,32 +3580,15 @@ static int ni_m_series_dio_insn_config(struct comedi_device *dev, unsigned int *data) { struct ni_private *devpriv __maybe_unused = dev->private; + int ret; -#ifdef DEBUG_DIO - printk("ni_m_series_dio_insn_config() chan=%d io=%d\n", - CR_CHAN(insn->chanspec), data[0]); -#endif - switch (data[0]) { - case INSN_CONFIG_DIO_OUTPUT: - s->io_bits |= 1 << CR_CHAN(insn->chanspec); - break; - case INSN_CONFIG_DIO_INPUT: - s->io_bits &= ~(1 << CR_CHAN(insn->chanspec)); - break; - case INSN_CONFIG_DIO_QUERY: - data[1] = - (s-> - io_bits & (1 << CR_CHAN(insn->chanspec))) ? COMEDI_OUTPUT : - COMEDI_INPUT; - return insn->n; - break; - default: - return -EINVAL; - } + ret = comedi_dio_insn_config(dev, s, insn, data, 0); + if (ret) + return ret; ni_writel(s->io_bits, M_Offset_DIO_Direction); - return 1; + return insn->n; } static int ni_m_series_dio_insn_bits(struct comedi_device *dev, diff --git a/drivers/staging/comedi/drivers/ni_pcidio.c b/drivers/staging/comedi/drivers/ni_pcidio.c index 8ac7a7cce0e6e..fad81bc97b6e0 100644 --- a/drivers/staging/comedi/drivers/ni_pcidio.c +++ b/drivers/staging/comedi/drivers/ni_pcidio.c @@ -640,32 +640,19 @@ static void debug_int(struct comedi_device *dev) static int ni_pcidio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { struct nidio96_private *devpriv = dev->private; + int ret; + + ret = comedi_dio_insn_config(dev, s, insn, data, 0); + if (ret) + return ret; - if (insn->n != 1) - return -EINVAL; - switch (data[0]) { - case INSN_CONFIG_DIO_OUTPUT: - s->io_bits |= 1 << CR_CHAN(insn->chanspec); - break; - case INSN_CONFIG_DIO_INPUT: - s->io_bits &= ~(1 << CR_CHAN(insn->chanspec)); - break; - case INSN_CONFIG_DIO_QUERY: - data[1] = - (s-> - io_bits & (1 << CR_CHAN(insn->chanspec))) ? COMEDI_OUTPUT : - COMEDI_INPUT; - return insn->n; - break; - default: - return -EINVAL; - } writel(s->io_bits, devpriv->mite->daq_io_addr + Port_Pin_Directions(0)); - return 1; + return insn->n; } static int ni_pcidio_insn_bits(struct comedi_device *dev, diff --git a/drivers/staging/comedi/drivers/pcmmio.c b/drivers/staging/comedi/drivers/pcmmio.c index fab93a73651da..aa3c0307483d0 100644 --- a/drivers/staging/comedi/drivers/pcmmio.c +++ b/drivers/staging/comedi/drivers/pcmmio.c @@ -310,68 +310,27 @@ static int pcmmio_dio_insn_bits(struct comedi_device *dev, return insn->n; } -/* The input or output configuration of each digital line is - * configured by a special insn_config instruction. chanspec - * contains the channel to be changed, and data[0] contains the - * value COMEDI_INPUT or COMEDI_OUTPUT. */ static int pcmmio_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { - int chan = CR_CHAN(insn->chanspec), byte_no = chan / 8, bit_no = - chan % 8; - unsigned long ioaddr; - unsigned char byte; - - /* Compute ioaddr for this channel */ - ioaddr = subpriv->iobases[byte_no]; - - /* NOTE: - writing a 0 an IO channel's bit sets the channel to INPUT - and pulls the line high as well - - writing a 1 to an IO channel's bit pulls the line low - - All channels are implicitly always in OUTPUT mode -- but when - they are high they can be considered to be in INPUT mode.. - - Thus, we only force channels low if the config request was INPUT, - otherwise we do nothing to the hardware. */ - - switch (data[0]) { - case INSN_CONFIG_DIO_OUTPUT: - /* save to io_bits -- don't actually do anything since - all input channels are also output channels... */ - s->io_bits |= 1 << chan; - break; - case INSN_CONFIG_DIO_INPUT: - /* write a 0 to the actual register representing the channel - to set it to 'input'. 0 means "float high". */ - byte = inb(ioaddr); - byte &= ~(1 << bit_no); - /**< set input channel to '0' */ - - /* - * write out byte -- this is the only time we actually affect - * the hardware as all channels are implicitly output - * -- but input channels are set to float-high - */ - outb(byte, ioaddr); + unsigned int chan = CR_CHAN(insn->chanspec); + int byte_no = chan / 8; + int bit_no = chan % 8; + int ret; - /* save to io_bits */ - s->io_bits &= ~(1 << chan); - break; + ret = comedi_dio_insn_config(dev, s, insn, data, 0); + if (ret) + return ret; - case INSN_CONFIG_DIO_QUERY: - /* retrieve from shadow register */ - data[1] = - (s->io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT; - return insn->n; - break; + if (data[0] == INSN_CONFIG_DIO_INPUT) { + unsigned long ioaddr = subpriv->iobases[byte_no]; + unsigned char val; - default: - return -EINVAL; - break; + val = inb(ioaddr); + val &= ~(1 << bit_no); + outb(val, ioaddr); } return insn->n; diff --git a/drivers/staging/comedi/drivers/pcmuio.c b/drivers/staging/comedi/drivers/pcmuio.c index 13f1943f5b8bc..f9424554539d7 100644 --- a/drivers/staging/comedi/drivers/pcmuio.c +++ b/drivers/staging/comedi/drivers/pcmuio.c @@ -233,27 +233,19 @@ static int pcmuio_dio_insn_bits(struct comedi_device *dev, static int pcmuio_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { - unsigned int chan_mask = 1 << CR_CHAN(insn->chanspec); int asic = s->index / 2; int port = (s->index % 2) ? 3 : 0; + int ret; - switch (data[0]) { - case INSN_CONFIG_DIO_OUTPUT: - s->io_bits |= chan_mask; - break; - case INSN_CONFIG_DIO_INPUT: - s->io_bits &= ~chan_mask; + ret = comedi_dio_insn_config(dev, s, insn, data, 0); + if (ret) + return ret; + + if (data[0] == INSN_CONFIG_DIO_INPUT) pcmuio_write(dev, s->io_bits, asic, 0, port); - break; - case INSN_CONFIG_DIO_QUERY: - data[1] = (s->io_bits & chan_mask) ? COMEDI_OUTPUT : COMEDI_INPUT; - break; - default: - return -EINVAL; - break; - } return insn->n; } diff --git a/drivers/staging/comedi/drivers/rtd520.c b/drivers/staging/comedi/drivers/rtd520.c index 635c8f5cd8f68..93c980c62a23a 100644 --- a/drivers/staging/comedi/drivers/rtd520.c +++ b/drivers/staging/comedi/drivers/rtd520.c @@ -1238,23 +1238,11 @@ static int rtd_dio_insn_config(struct comedi_device *dev, unsigned int *data) { struct rtd_private *devpriv = dev->private; - unsigned int chan = CR_CHAN(insn->chanspec); - unsigned int mask = 1 << chan; + int ret; - switch (data[0]) { - case INSN_CONFIG_DIO_OUTPUT: - s->io_bits |= mask; - break; - case INSN_CONFIG_DIO_INPUT: - s->io_bits &= ~mask; - break; - case INSN_CONFIG_DIO_QUERY: - data[1] = (s->io_bits & mask) ? COMEDI_OUTPUT : COMEDI_INPUT; - return insn->n; - break; - default: - return -EINVAL; - } + ret = comedi_dio_insn_config(dev, s, insn, data, 0); + if (ret) + return ret; /* TODO support digital match interrupts and strobes */ diff --git a/drivers/staging/comedi/drivers/s626.c b/drivers/staging/comedi/drivers/s626.c index b0ba9b9b433b3..d22b95dcb9bdf 100644 --- a/drivers/staging/comedi/drivers/s626.c +++ b/drivers/staging/comedi/drivers/s626.c @@ -1662,24 +1662,12 @@ static int s626_dio_insn_config(struct comedi_device *dev, unsigned int *data) { unsigned long group = (unsigned long)s->private; - unsigned int chan = CR_CHAN(insn->chanspec); - unsigned int mask = 1 << chan; + int ret; + + ret = comedi_dio_insn_config(dev, s, insn, data, 0); + if (ret) + return ret; - switch (data[0]) { - case INSN_CONFIG_DIO_QUERY: - data[1] = (s->io_bits & mask) ? COMEDI_OUTPUT : COMEDI_INPUT; - return insn->n; - break; - case COMEDI_INPUT: - s->io_bits &= ~mask; - break; - case COMEDI_OUTPUT: - s->io_bits |= mask; - break; - default: - return -EINVAL; - break; - } DEBIwrite(dev, LP_WRDOUT(group), s->io_bits); return insn->n; diff --git a/drivers/staging/comedi/drivers/ssv_dnp.c b/drivers/staging/comedi/drivers/ssv_dnp.c index 4da4d3208fdbb..11758a515c1bf 100644 --- a/drivers/staging/comedi/drivers/ssv_dnp.c +++ b/drivers/staging/comedi/drivers/ssv_dnp.c @@ -93,68 +93,48 @@ static int dnp_dio_insn_bits(struct comedi_device *dev, } -/* ------------------------------------------------------------------------- */ -/* Configure the direction of the bidirectional digital i/o pins. chanspec */ -/* contains the channel to be changed and data[0] contains either */ -/* COMEDI_INPUT or COMEDI_OUTPUT. */ -/* ------------------------------------------------------------------------- */ - static int dnp_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned int mask; + unsigned int val; + int ret; - u8 register_buffer; - - /* reduces chanspec to lower 16 bits */ - int chan = CR_CHAN(insn->chanspec); - - switch (data[0]) { - case INSN_CONFIG_DIO_OUTPUT: - case INSN_CONFIG_DIO_INPUT: - break; - case INSN_CONFIG_DIO_QUERY: - data[1] = - (inb(CSCDR) & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT; - return insn->n; - break; - default: - return -EINVAL; - break; - } - /* Test: which port does the channel belong to? */ - - /* We have to pay attention with port C: this is the meaning of PCMR: */ - /* Bit in PCMR: 7 6 5 4 3 2 1 0 */ - /* Corresponding port C pin: d 3 d 2 d 1 d 0 d= don't touch */ + ret = comedi_dio_insn_config(dev, s, insn, data, 0); + if (ret) + return ret; - if ((chan >= 0) && (chan <= 7)) { - /* this is port A */ + if (chan < 8) { /* Port A */ + mask = 1 << chan; outb(PAMR, CSCIR); - } else if ((chan >= 8) && (chan <= 15)) { - /* this is port B */ - chan -= 8; + } else if (chan < 16) { /* Port B */ + mask = 1 << (chan - 8); outb(PBMR, CSCIR); - } else if ((chan >= 16) && (chan <= 19)) { - /* this is port C; multiplication with 2 brings bits into */ - /* correct position for PCMR! */ - chan -= 16; - chan *= 2; + } else { /* Port C */ + /* + * We have to pay attention with port C. + * This is the meaning of PCMR: + * Bit in PCMR: 7 6 5 4 3 2 1 0 + * Corresponding port C pin: d 3 d 2 d 1 d 0 d= don't touch + * + * Multiplication by 2 brings bits into correct position + * for PCMR! + */ + mask = 1 << ((chan - 16) * 2); outb(PCMR, CSCIR); - } else { - return -EINVAL; } - /* read 'old' direction of the port and set bits (out=1, in=0) */ - register_buffer = inb(CSCDR); + val = inb(CSCDR); if (data[0] == COMEDI_OUTPUT) - register_buffer |= (1 << chan); + val |= mask; else - register_buffer &= ~(1 << chan); - - outb(register_buffer, CSCDR); + val &= ~mask; + outb(val, CSCDR); - return 1; + return insn->n; } diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 689b45276e8dd..7e91f1506a39c 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -1113,22 +1113,11 @@ static int usbdux_dio_insn_config(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - unsigned int mask = 1 << CR_CHAN(insn->chanspec); + int ret; - switch (data[0]) { - case INSN_CONFIG_DIO_OUTPUT: - s->io_bits |= mask; - break; - case INSN_CONFIG_DIO_INPUT: - s->io_bits &= ~mask; - break; - case INSN_CONFIG_DIO_QUERY: - data[1] = (s->io_bits & mask) ? COMEDI_OUTPUT : COMEDI_INPUT; - break; - default: - return -EINVAL; - break; - } + ret = comedi_dio_insn_config(dev, s, insn, data, 0); + if (ret) + return ret; /* * We don't tell the firmware here as it would take 8 frames diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c b/drivers/staging/comedi/drivers/usbduxsigma.c index fca89c367a68b..c47f4087568fc 100644 --- a/drivers/staging/comedi/drivers/usbduxsigma.c +++ b/drivers/staging/comedi/drivers/usbduxsigma.c @@ -1040,23 +1040,11 @@ static int usbduxsigma_dio_insn_config(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - unsigned int chan = CR_CHAN(insn->chanspec); - unsigned int mask = 1 << chan; + int ret; - switch (data[0]) { - case INSN_CONFIG_DIO_OUTPUT: - s->io_bits |= mask; - break; - case INSN_CONFIG_DIO_INPUT: - s->io_bits &= ~mask; - break; - case INSN_CONFIG_DIO_QUERY: - data[1] = (s->io_bits & mask) ? COMEDI_OUTPUT : COMEDI_INPUT; - break; - default: - return -EINVAL; - break; - } + ret = comedi_dio_insn_config(dev, s, insn, data, 0); + if (ret) + return ret; /* * We don't tell the firmware here as it would take 8 frames -- GitLab From 59aabd6a223de6af2a513bfac1bb783764820c72 Mon Sep 17 00:00:00 2001 From: Iker Pedrosa Date: Thu, 8 Aug 2013 12:56:44 +0200 Subject: [PATCH 606/942] Staging: rtl8192e: rtllib_rx: checking NULL value after doing dev_alloc_skb Checking the return of dev_alloc_skb as stated in the following bug: https://bugzilla.kernel.org/show_bug.cgi?id=60401 Reported-by: RUC_Soft_Sec rucsoftsec@gmail.com Cc: Dan Carpenter Signed-off-by: Iker Pedrosa Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib_rx.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index e75364e3eb434..6a51f29e0737f 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -777,6 +777,8 @@ static u8 parse_subframe(struct rtllib_device *ieee, struct sk_buff *skb, /* Allocate new skb for releasing to upper layer */ sub_skb = dev_alloc_skb(RTLLIB_SKBBUFFER_SIZE); + if (!sub_skb) + return 0; skb_reserve(sub_skb, 12); data_ptr = (u8 *)skb_put(sub_skb, skb->len); memcpy(data_ptr, skb->data, skb->len); @@ -825,6 +827,8 @@ static u8 parse_subframe(struct rtllib_device *ieee, struct sk_buff *skb, /* Allocate new skb for releasing to upper layer */ sub_skb = dev_alloc_skb(nSubframe_Length + 12); + if (!sub_skb) + return 0; skb_reserve(sub_skb, 12); data_ptr = (u8 *)skb_put(sub_skb, nSubframe_Length); memcpy(data_ptr, skb->data, nSubframe_Length); -- GitLab From a539c72a195c081d950475c2945cb82d80be9b66 Mon Sep 17 00:00:00 2001 From: Kumar Gaurav Date: Thu, 8 Aug 2013 23:53:24 +0530 Subject: [PATCH 607/942] Staging: zram: zram_drv.c: Fixed Error of trailing whitespace Fixed by removing trailing whitespace Signed-off-by: Kumar Gaurav Signed-off-by: Greg Kroah-Hartman --- drivers/staging/zram/zram_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/zram/zram_drv.c b/drivers/staging/zram/zram_drv.c index 7ebf91d347f53..44949d21b59c3 100644 --- a/drivers/staging/zram/zram_drv.c +++ b/drivers/staging/zram/zram_drv.c @@ -169,7 +169,7 @@ static inline int is_partial_io(struct bio_vec *bvec) static inline int valid_io_request(struct zram *zram, struct bio *bio) { u64 start, end, bound; - + /* unaligned request */ if (unlikely(bio->bi_sector & (ZRAM_SECTOR_PER_LOGICAL_BLOCK - 1))) return 0; -- GitLab From 37ca35c47b9eda39bad70a4546c0ec01e8b0e576 Mon Sep 17 00:00:00 2001 From: Shaun Laing Date: Fri, 9 Aug 2013 07:54:24 -0600 Subject: [PATCH 608/942] staging: cxt1e1: Remove #define SBE_INCLUDE_SYMBOLS Removed the unneeded SBE_INCLUDE_SYMBOLS #define, and the associated STATIC #define, and replaced all occurances of STATIC with 'static'. This was in response to sparse warnings of the form "symbol 'XYZ' was not declared. Should it be static?". Removed a function prototype (musycc_init_port) as adding the 'static' declaration produced a new gcc warning. (musycc_init_port is only declared if SBE_WAN256T3_ENABLE is set) Signed-off-by: Shaun Laing Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cxt1e1/Makefile | 1 - drivers/staging/cxt1e1/comet.c | 23 ++++------- drivers/staging/cxt1e1/functions.c | 9 +---- drivers/staging/cxt1e1/hwprobe.c | 8 +--- drivers/staging/cxt1e1/linux.c | 52 +++++++++++-------------- drivers/staging/cxt1e1/musycc.c | 15 ++----- drivers/staging/cxt1e1/pmc93x6_eeprom.c | 15 ++----- drivers/staging/cxt1e1/pmcc4_drv.c | 11 +----- drivers/staging/cxt1e1/sbeid.c | 7 ---- 9 files changed, 43 insertions(+), 98 deletions(-) diff --git a/drivers/staging/cxt1e1/Makefile b/drivers/staging/cxt1e1/Makefile index b9ccb76502511..2f217e9daac11 100644 --- a/drivers/staging/cxt1e1/Makefile +++ b/drivers/staging/cxt1e1/Makefile @@ -2,7 +2,6 @@ obj-$(CONFIG_CXT1E1) += cxt1e1.o ccflags-y := -DSBE_PMCC4_ENABLE ccflags-y += -DSBE_ISR_TASKLET -ccflags-y += -DSBE_INCLUDE_SYMBOLS cxt1e1-y := \ ossiRelease.o \ diff --git a/drivers/staging/cxt1e1/comet.c b/drivers/staging/cxt1e1/comet.c index fabfd779c6681..d71aea541811c 100644 --- a/drivers/staging/cxt1e1/comet.c +++ b/drivers/staging/cxt1e1/comet.c @@ -22,22 +22,15 @@ #include "comet.h" #include "comet_tables.h" -#ifdef SBE_INCLUDE_SYMBOLS -#define STATIC -#else -#define STATIC static -#endif - - extern int cxt1e1_log_level; #define COMET_NUM_SAMPLES 24 /* Number of entries in the waveform table */ #define COMET_NUM_UNITS 5 /* Number of points per entry in table */ /* forward references */ -STATIC void SetPwrLevel(comet_t *comet); -STATIC void WrtRcvEqualizerTbl(ci_t *ci, comet_t *comet, u_int32_t *table); -STATIC void WrtXmtWaveformTbl(ci_t *ci, comet_t *comet, u_int8_t table[COMET_NUM_SAMPLES][COMET_NUM_UNITS]); +static void SetPwrLevel(comet_t *comet); +static void WrtRcvEqualizerTbl(ci_t *ci, comet_t *comet, u_int32_t *table); +static void WrtXmtWaveformTbl(ci_t *ci, comet_t *comet, u_int8_t table[COMET_NUM_SAMPLES][COMET_NUM_UNITS]); void *TWV_table[12] = { @@ -407,7 +400,7 @@ void init_comet(void *ci, comet_t *comet, u_int32_t port_mode, int clockmaster, ** Write the data to the Pulse Waveform Storage Data register. ** Returns: Nothing */ -STATIC void +static void WrtXmtWaveform(ci_t *ci, comet_t *comet, u_int32_t sample, u_int32_t unit, u_int8_t data) { u_int8_t WaveformAddr; @@ -425,7 +418,7 @@ WrtXmtWaveform(ci_t *ci, comet_t *comet, u_int32_t sample, u_int32_t unit, u_int ** for driving the transmitter DAC. ** Returns: Nothing */ -STATIC void +static void WrtXmtWaveformTbl(ci_t *ci, comet_t *comet, u_int8_t table[COMET_NUM_SAMPLES][COMET_NUM_UNITS]) { @@ -452,7 +445,7 @@ WrtXmtWaveformTbl(ci_t *ci, comet_t *comet, ** is coded with early setup of indirect address. */ -STATIC void +static void WrtRcvEqualizerTbl(ci_t *ci, comet_t *comet, u_int32_t *table) { u_int32_t ramaddr; @@ -516,7 +509,7 @@ WrtRcvEqualizerTbl(ci_t *ci, comet_t *comet, u_int32_t *table) ** Returns: Nothing */ -STATIC void +static void SetPwrLevel(comet_t *comet) { volatile u_int32_t temp; @@ -558,7 +551,7 @@ SetPwrLevel(comet_t *comet) ** Returns: Nothing */ #if 0 -STATIC void +static void SetCometOps(comet_t *comet) { volatile u_int8_t rd_value; diff --git a/drivers/staging/cxt1e1/functions.c b/drivers/staging/cxt1e1/functions.c index 6167dc5745778..d021b312ffa28 100644 --- a/drivers/staging/cxt1e1/functions.c +++ b/drivers/staging/cxt1e1/functions.c @@ -24,13 +24,6 @@ #include "libsbew.h" #include "pmcc4.h" - -#ifdef SBE_INCLUDE_SYMBOLS -#define STATIC -#else -#define STATIC static -#endif - #if defined(CONFIG_SBE_HDLC_V7) || defined(CONFIG_SBE_WAN256T3_HDLC_V7) || \ defined(CONFIG_SBE_HDLC_V7_MODULE) || defined(CONFIG_SBE_WAN256T3_HDLC_V7_MODULE) #define _v7_hdlc_ 1 @@ -111,7 +104,7 @@ pci_flush_write (ci_t *ci) } -STATIC void +static void watchdog_func (unsigned long arg) { struct watchdog *wd = (void *) arg; diff --git a/drivers/staging/cxt1e1/hwprobe.c b/drivers/staging/cxt1e1/hwprobe.c index 110c252d38d7f..53e923701ae6d 100644 --- a/drivers/staging/cxt1e1/hwprobe.c +++ b/drivers/staging/cxt1e1/hwprobe.c @@ -31,12 +31,6 @@ #include "sbeproc.h" #endif -#ifdef SBE_INCLUDE_SYMBOLS -#define STATIC -#else -#define STATIC static -#endif - extern int cxt1e1_log_level; extern int error_flag; extern int drvr_state; @@ -221,7 +215,7 @@ cleanup_devs (void) } -STATIC int __init +static int __init c4_hdw_init (struct pci_dev *pdev, int found) { hdw_info_t *hi; diff --git a/drivers/staging/cxt1e1/linux.c b/drivers/staging/cxt1e1/linux.c index e5889ef190a21..142691c8d8d1c 100644 --- a/drivers/staging/cxt1e1/linux.c +++ b/drivers/staging/cxt1e1/linux.c @@ -52,12 +52,6 @@ /*****************************************************************************************/ -#ifdef SBE_INCLUDE_SYMBOLS -#define STATIC -#else -#define STATIC static -#endif - #define CHANNAME "hdlc" /*******************************************************************/ @@ -285,7 +279,7 @@ void_open (struct net_device *ndev) } -STATIC int +static int chan_open (struct net_device *ndev) { hdlc_device *hdlc = dev_to_hdlc (ndev); @@ -305,7 +299,7 @@ chan_open (struct net_device *ndev) } -STATIC int +static int chan_close (struct net_device *ndev) { hdlc_device *hdlc = dev_to_hdlc (ndev); @@ -319,14 +313,14 @@ chan_close (struct net_device *ndev) } -STATIC int +static int chan_dev_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd) { return hdlc_ioctl (dev, ifr, cmd); } -STATIC int +static int chan_attach_noop (struct net_device *ndev, unsigned short foo_1, unsigned short foo_2) { return 0; /* our driver has nothing to do here, show's @@ -334,7 +328,7 @@ chan_attach_noop (struct net_device *ndev, unsigned short foo_1, unsigned short } -STATIC struct net_device_stats * +static struct net_device_stats * chan_get_stats (struct net_device *ndev) { mch_t *ch; @@ -394,7 +388,7 @@ get_ci_by_dev (struct net_device *ndev) } -STATIC int +static int c4_linux_xmit (struct sk_buff *skb, struct net_device *ndev) { const struct c4_priv *priv; @@ -416,7 +410,7 @@ static const struct net_device_ops chan_ops = { .ndo_get_stats = chan_get_stats, }; -STATIC struct net_device * +static struct net_device * create_chan (struct net_device *ndev, ci_t *ci, struct sbecom_chan_param *cp) { @@ -509,7 +503,7 @@ create_chan (struct net_device *ndev, ci_t *ci, /* the idea here is to get port information and pass it back (using pointer) */ -STATIC status_t +static status_t do_get_port (struct net_device *ndev, void *data) { int ret; @@ -534,7 +528,7 @@ do_get_port (struct net_device *ndev, void *data) } /* this function copys the user data and then calls the real action function */ -STATIC status_t +static status_t do_set_port (struct net_device *ndev, void *data) { ci_t *ci; /* ci stands for card information */ @@ -556,7 +550,7 @@ do_set_port (struct net_device *ndev, void *data) } /* work the port loopback mode as per directed */ -STATIC status_t +static status_t do_port_loop (struct net_device *ndev, void *data) { struct sbecom_port_param pp; @@ -571,7 +565,7 @@ do_port_loop (struct net_device *ndev, void *data) } /* set the specified register with the given value / or just read it */ -STATIC status_t +static status_t do_framer_rw (struct net_device *ndev, void *data) { struct sbecom_port_param pp; @@ -592,7 +586,7 @@ do_framer_rw (struct net_device *ndev, void *data) } /* set the specified register with the given value / or just read it */ -STATIC status_t +static status_t do_pld_rw (struct net_device *ndev, void *data) { struct sbecom_port_param pp; @@ -613,7 +607,7 @@ do_pld_rw (struct net_device *ndev, void *data) } /* set the specified register with the given value / or just read it */ -STATIC status_t +static status_t do_musycc_rw (struct net_device *ndev, void *data) { struct c4_musycc_param mp; @@ -633,7 +627,7 @@ do_musycc_rw (struct net_device *ndev, void *data) return 0; } -STATIC status_t +static status_t do_get_chan (struct net_device *ndev, void *data) { struct sbecom_chan_param cp; @@ -651,7 +645,7 @@ do_get_chan (struct net_device *ndev, void *data) return 0; } -STATIC status_t +static status_t do_set_chan (struct net_device *ndev, void *data) { struct sbecom_chan_param cp; @@ -672,7 +666,7 @@ do_set_chan (struct net_device *ndev, void *data) } } -STATIC status_t +static status_t do_create_chan (struct net_device *ndev, void *data) { ci_t *ci; @@ -699,7 +693,7 @@ do_create_chan (struct net_device *ndev, void *data) return ret; } -STATIC status_t +static status_t do_get_chan_stats (struct net_device *ndev, void *data) { struct c4_chan_stats_wrap ccs; @@ -720,7 +714,7 @@ do_get_chan_stats (struct net_device *ndev, void *data) return -EFAULT; return 0; } -STATIC status_t +static status_t do_set_loglevel (struct net_device *ndev, void *data) { unsigned int cxt1e1_log_level; @@ -731,7 +725,7 @@ do_set_loglevel (struct net_device *ndev, void *data) return 0; } -STATIC status_t +static status_t do_deluser (struct net_device *ndev, int lockit) { if (ndev->flags & IFF_UP) @@ -826,7 +820,7 @@ do_reset_chan_stats (struct net_device *musycc_dev, void *data) return mkret (c4_del_chan_stats (cp.channum)); } -STATIC status_t +static status_t c4_ioctl (struct net_device *ndev, struct ifreq *ifr, int cmd) { ci_t *ci; @@ -1102,7 +1096,7 @@ c4_add_dev (hdw_info_t *hi, int brdno, unsigned long f0, unsigned long f1, return ndev; } -STATIC int __init +static int __init c4_mod_init (void) { int rtn; @@ -1144,7 +1138,7 @@ c4_mod_init (void) * do_deluser() */ -STATIC void __exit +static void __exit cleanup_hdlc (void) { hdw_info_t *hi; @@ -1168,7 +1162,7 @@ cleanup_hdlc (void) } -STATIC void __exit +static void __exit c4_mod_remove (void) { cleanup_hdlc(); /* delete any missed channels */ diff --git a/drivers/staging/cxt1e1/musycc.c b/drivers/staging/cxt1e1/musycc.c index 1037086d00a70..52b6d7f5fd475 100644 --- a/drivers/staging/cxt1e1/musycc.c +++ b/drivers/staging/cxt1e1/musycc.c @@ -35,12 +35,6 @@ unsigned int max_bh = 0; #include "pmcc4.h" #include "musycc.h" -#ifdef SBE_INCLUDE_SYMBOLS -#define STATIC -#else -#define STATIC static -#endif - #define sd_find_chan(ci,ch) c4_find_chan(ch) @@ -65,7 +59,6 @@ void c4_wk_chan_restart(mch_t *); void musycc_bh_tx_eom(mpi_t *, int); int musycc_chan_up(ci_t *, int); status_t __init musycc_init(ci_t *); -STATIC void __init musycc_init_port(mpi_t *); void musycc_intr_bh_tasklet(ci_t *); void musycc_serv_req(mpi_t *, u_int32_t); void musycc_update_timeslots(mpi_t *); @@ -73,7 +66,7 @@ void musycc_update_timeslots(mpi_t *); /*******************************************************************/ #if 1 -STATIC int +static int musycc_dump_rxbuffer_ring(mch_t *ch, int lockit) { struct mdesc *m; @@ -139,7 +132,7 @@ musycc_dump_rxbuffer_ring(mch_t *ch, int lockit) #endif #if 1 -STATIC int +static int musycc_dump_txbuffer_ring(mch_t *ch, int lockit) { struct mdesc *m; @@ -702,7 +695,7 @@ musycc_chan_proto(int proto) } #ifdef SBE_WAN256T3_ENABLE -STATIC void __init +static void __init musycc_init_port(mpi_t *pi) { pci_write_32((u_int32_t *) &pi->reg->gbp, OS_vtophys(pi->regram)); @@ -1009,7 +1002,7 @@ musycc_bh_tx_eom(mpi_t *pi, int gchan) } -STATIC void +static void musycc_bh_rx_eom(mpi_t *pi, int gchan) { mch_t *ch; diff --git a/drivers/staging/cxt1e1/pmc93x6_eeprom.c b/drivers/staging/cxt1e1/pmc93x6_eeprom.c index 62b12fb45fcc7..137b63cb5537c 100644 --- a/drivers/staging/cxt1e1/pmc93x6_eeprom.c +++ b/drivers/staging/cxt1e1/pmc93x6_eeprom.c @@ -34,13 +34,6 @@ #define FALSE 0 #endif -#ifdef SBE_INCLUDE_SYMBOLS -#define STATIC -#else -#define STATIC static -#endif - - /*------------------------------------------------------------------------ * EEPROM address definitions *------------------------------------------------------------------------ @@ -120,7 +113,7 @@ short mfg_template[sizeof (FLD_TYPE2)] = * (the MSB becomes the LSB etc.). */ -STATIC void +static void BuildByteReverse (void) { long half; /* Used to build by powers to 2 */ @@ -141,7 +134,7 @@ BuildByteReverse (void) *------------------------------------------------------------------------ */ -STATIC void +static void eeprom_delay (void) { int timeout; @@ -224,7 +217,7 @@ eeprom_get_byte (long addr) * Issue the EEPROM command to disable writes. */ -STATIC void +static void disable_pmc_eeprom (long addr) { eeprom_put_byte (addr, EPROM_EWDS, SIZE_ADDR_OP); @@ -241,7 +234,7 @@ disable_pmc_eeprom (long addr) * Issue the EEPROM command to enable writes. */ -STATIC void +static void enable_pmc_eeprom (long addr) { eeprom_put_byte (addr, EPROM_EWEN, SIZE_ADDR_OP); diff --git a/drivers/staging/cxt1e1/pmcc4_drv.c b/drivers/staging/cxt1e1/pmcc4_drv.c index 32d7a216a4192..2383c609bf390 100644 --- a/drivers/staging/cxt1e1/pmcc4_drv.c +++ b/drivers/staging/cxt1e1/pmcc4_drv.c @@ -39,13 +39,6 @@ #include "comet.h" #include "sbe_bid.h" -#ifdef SBE_INCLUDE_SYMBOLS -#define STATIC -#else -#define STATIC static -#endif - - #define KERN_WARN KERN_WARNING /* forward references */ @@ -458,7 +451,7 @@ checkPorts (ci_t *ci) } -STATIC void +static void c4_watchdog (ci_t *ci) { if (drvr_state != SBE_DRVR_AVAILABLE) @@ -1184,7 +1177,7 @@ c4_get_chan_stats (int channum, struct sbecom_chan_stats *p) return 0; } -STATIC int +static int c4_fifo_alloc (mpi_t *pi, int chan, int *len) { int i, l = 0, start = 0, max = 0, maxstart = 0; diff --git a/drivers/staging/cxt1e1/sbeid.c b/drivers/staging/cxt1e1/sbeid.c index 0f9bd5f8136c1..791993fec96ba 100644 --- a/drivers/staging/cxt1e1/sbeid.c +++ b/drivers/staging/cxt1e1/sbeid.c @@ -19,13 +19,6 @@ #include "pmcc4.h" #include "sbe_bid.h" -#ifdef SBE_INCLUDE_SYMBOLS -#define STATIC -#else -#define STATIC static -#endif - - char * sbeid_get_bdname (ci_t *ci) { -- GitLab From 89911e583a00dbad4cd60e5acf1ad0e63c76c32e Mon Sep 17 00:00:00 2001 From: Andreas Werner Date: Sun, 11 Aug 2013 17:20:23 +0200 Subject: [PATCH 609/942] Staging: imx-drm: imx-tve.c Fixed 80 character line coding style issue Fixed a coding style issue of 80 character per line. Signed-off-by: Andreas Werner Signed-off-by: Greg Kroah-Hartman --- drivers/staging/imx-drm/imx-tve.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/staging/imx-drm/imx-tve.c b/drivers/staging/imx-drm/imx-tve.c index 12a3940de6954..dba1b47b3bdaf 100644 --- a/drivers/staging/imx-drm/imx-tve.c +++ b/drivers/staging/imx-drm/imx-tve.c @@ -166,7 +166,10 @@ static void tve_enable(struct imx_tve *tve) regmap_write(tve->regmap, TVE_INT_CONT_REG, 0); else regmap_write(tve->regmap, TVE_INT_CONT_REG, - TVE_CD_SM_IEN | TVE_CD_LM_IEN | TVE_CD_MON_END_IEN); + TVE_CD_SM_IEN | + TVE_CD_LM_IEN | + TVE_CD_MON_END_IEN); + spin_unlock_irqrestore(&tve->enable_lock, flags); } @@ -467,7 +470,9 @@ static int clk_tve_di_set_rate(struct clk_hw *hw, unsigned long rate, else val = TVE_DAC_FULL_RATE; - ret = regmap_update_bits(tve->regmap, TVE_COM_CONF_REG, TVE_DAC_SAMP_RATE_MASK, val); + ret = regmap_update_bits(tve->regmap, TVE_COM_CONF_REG, + TVE_DAC_SAMP_RATE_MASK, val); + if (ret < 0) { dev_err(tve->dev, "failed to set divider: %d\n", ret); return ret; @@ -611,13 +616,17 @@ static int imx_tve_probe(struct platform_device *pdev) } if (tve->mode == TVE_MODE_VGA) { - ret = of_property_read_u32(np, "fsl,hsync-pin", &tve->hsync_pin); + ret = of_property_read_u32(np, "fsl,hsync-pin", + &tve->hsync_pin); + if (ret < 0) { dev_err(&pdev->dev, "failed to get vsync pin\n"); return ret; } - ret |= of_property_read_u32(np, "fsl,vsync-pin", &tve->vsync_pin); + ret |= of_property_read_u32(np, "fsl,vsync-pin", + &tve->vsync_pin); + if (ret < 0) { dev_err(&pdev->dev, "failed to get vsync pin\n"); return ret; -- GitLab From 725acc861b55c159d9a352cf19debb023fbe1d78 Mon Sep 17 00:00:00 2001 From: Paul Zimmerman Date: Sun, 11 Aug 2013 12:50:17 -0700 Subject: [PATCH 610/942] staging: dwc2: reorder some kernel doc comments and struct members Reorder the kernel doc comments for 'struct dwc2_core_params' to match the ordering in the struct itself. Reorder the members of 'struct dwc2_qh' (and its kerneldoc comments) to minimize the amount of structure padding. Signed-off-by: Paul Zimmerman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dwc2/core.h | 34 +++++++++++++++++----------------- drivers/staging/dwc2/hcd.h | 22 +++++++++++----------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/drivers/staging/dwc2/core.h b/drivers/staging/dwc2/core.h index e771e405453f6..e5b4dc8948a38 100644 --- a/drivers/staging/dwc2/core.h +++ b/drivers/staging/dwc2/core.h @@ -74,6 +74,9 @@ enum dwc2_lx_state { * 0 - HNP and SRP capable (default) * 1 - SRP Only capable * 2 - No HNP/SRP capable + * @otg_ver: OTG version supported + * 0 - 1.3 + * 1 - 2.0 * @dma_enable: Specifies whether to use slave or DMA mode for accessing * the data FIFOs. The driver will automatically detect the * value for this parameter if none is specified. @@ -90,20 +93,10 @@ enum dwc2_lx_state { * the attached device and the value of phy_type. * 0 - High Speed (default) * 1 - Full Speed - * @host_support_fs_ls_low_power: Specifies whether low power mode is supported - * when attached to a Full Speed or Low Speed device in - * host mode. - * 0 - Don't support low power mode (default) - * 1 - Support low power mode - * @host_ls_low_power_phy_clk: Specifies the PHY clock rate in low power mode - * when connected to a Low Speed device in host mode. This - * parameter is applicable only if - * host_support_fs_ls_low_power is enabled. If phy_type is - * set to FS then defaults to 6 MHZ otherwise 48 MHZ. - * 0 - 48 MHz - * 1 - 6 MHz * @enable_dynamic_fifo: 0 - Use coreConsultant-specified FIFO size parameters * 1 - Allow dynamic FIFO sizing (default) + * @en_multiple_tx_fifo: Specifies whether dedicated per-endpoint transmit FIFOs + * are enabled * @host_rx_fifo_size: Number of 4-byte words in the Rx FIFO in host mode when * dynamic FIFO sizing is enabled * 16 to 32768 (default 1024) @@ -145,9 +138,19 @@ enum dwc2_lx_state { * 0 - No (default) * 1 - Yes * @ulpi_fs_ls: True to make ULPI phy operate in FS/LS mode only + * @host_support_fs_ls_low_power: Specifies whether low power mode is supported + * when attached to a Full Speed or Low Speed device in + * host mode. + * 0 - Don't support low power mode (default) + * 1 - Support low power mode + * @host_ls_low_power_phy_clk: Specifies the PHY clock rate in low power mode + * when connected to a Low Speed device in host mode. This + * parameter is applicable only if + * host_support_fs_ls_low_power is enabled. If phy_type is + * set to FS then defaults to 6 MHZ otherwise 48 MHZ. + * 0 - 48 MHz + * 1 - 6 MHz * @ts_dline: True to enable Term Select Dline pulsing - * @en_multiple_tx_fifo: Specifies whether dedicated per-endpoint transmit FIFOs - * are enabled * @reload_ctl: True to allow dynamic reloading of HFIR register during * runtime * @ahbcfg: This field allows the default value of the GAHBCFG @@ -155,9 +158,6 @@ enum dwc2_lx_state { * -1 - GAHBCFG value will not be overridden * all others - GAHBCFG value will be overridden with * this value - * @otg_ver: OTG version supported - * 0 - 1.3 - * 1 - 2.0 * * The following parameters may be specified when starting the module. These * parameters define how the DWC_otg controller should be configured. diff --git a/drivers/staging/dwc2/hcd.h b/drivers/staging/dwc2/hcd.h index 933e8d1999bfa..3b060247c7fc8 100644 --- a/drivers/staging/dwc2/hcd.h +++ b/drivers/staging/dwc2/hcd.h @@ -232,16 +232,19 @@ enum dwc2_transaction_type { * - DWC2_HC_PID_DATA1 * @ping_state: Ping state * @do_split: Full/low speed endpoint on high-speed hub requires split - * @qtd_list: List of QTDs for this QH - * @channel: Host channel currently processing transfers for this QH + * @td_first: Index of first activated isochronous transfer descriptor + * @td_last: Index of last activated isochronous transfer descriptor * @usecs: Bandwidth in microseconds per (micro)frame * @interval: Interval between transfers in (micro)frames - * @sched_frame: (micro)frame to initialize a periodic transfer. + * @sched_frame: (Micro)frame to initialize a periodic transfer. * The transfer executes in the following (micro)frame. * @start_split_frame: (Micro)frame at which last start split was initialized + * @ntd: Actual number of transfer descriptors in a list * @dw_align_buf: Used instead of original buffer if its physical address * is not dword-aligned * @dw_align_buf_dma: DMA address for align_buf + * @qtd_list: List of QTDs for this QH + * @channel: Host channel currently processing transfers for this QH * @qh_list_entry: Entry for QH in either the periodic or non-periodic * schedule * @desc_list: List of transfer descriptors @@ -249,9 +252,6 @@ enum dwc2_transaction_type { * @n_bytes: Xfer Bytes array. Each element corresponds to a transfer * descriptor and indicates original XferSize value for the * descriptor - * @ntd: Actual number of transfer descriptors in a list - * @td_first: Index of first activated isochronous transfer descriptor - * @td_last: Index of last activated isochronous transfer descriptor * @tt_buffer_dirty True if clear_tt_buffer_complete is pending * * A Queue Head (QH) holds the static characteristics of an endpoint and @@ -266,21 +266,21 @@ struct dwc2_qh { u8 data_toggle; u8 ping_state; u8 do_split; - struct list_head qtd_list; - struct dwc2_host_chan *channel; + u8 td_first; + u8 td_last; u16 usecs; u16 interval; u16 sched_frame; u16 start_split_frame; + u16 ntd; u8 *dw_align_buf; dma_addr_t dw_align_buf_dma; + struct list_head qtd_list; + struct dwc2_host_chan *channel; struct list_head qh_list_entry; struct dwc2_hcd_dma_desc *desc_list; dma_addr_t desc_list_dma; u32 *n_bytes; - u16 ntd; - u8 td_first; - u8 td_last; unsigned tt_buffer_dirty:1; }; -- GitLab From 2b86ab9cc29fcd435cde9378c3b9ffe8b5c76128 Mon Sep 17 00:00:00 2001 From: Minchan Kim Date: Mon, 12 Aug 2013 15:13:55 +0900 Subject: [PATCH 611/942] zram: fix invalid memory access [1] tried to fix invalid memory access on zram->disk but it didn't fix properly because get_disk failed during module exit path. Actually, we don't need to reset zram->disk's capacity to zero in module exit path so that this patch introduces new argument "reset_capacity" on zram_reset_divice and it only reset it when reset_store is called. [1] 6030ea9b, zram: avoid invalid memory access in zram_exit() Cc: Nitin Gupta Cc: Jiang Liu Cc: stable@vger.kernel.org Signed-off-by: Minchan Kim Signed-off-by: Greg Kroah-Hartman --- drivers/staging/zram/zram_drv.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/staging/zram/zram_drv.c b/drivers/staging/zram/zram_drv.c index 44949d21b59c3..2a85b953e00e4 100644 --- a/drivers/staging/zram/zram_drv.c +++ b/drivers/staging/zram/zram_drv.c @@ -523,7 +523,7 @@ static int zram_bvec_rw(struct zram *zram, struct bio_vec *bvec, u32 index, return ret; } -static void zram_reset_device(struct zram *zram) +static void zram_reset_device(struct zram *zram, bool reset_capacity) { size_t index; struct zram_meta *meta; @@ -552,7 +552,8 @@ static void zram_reset_device(struct zram *zram) memset(&zram->stats, 0, sizeof(zram->stats)); zram->disksize = 0; - set_capacity(zram->disk, 0); + if (reset_capacity) + set_capacity(zram->disk, 0); up_write(&zram->init_lock); } @@ -636,7 +637,7 @@ static ssize_t reset_store(struct device *dev, if (bdev) fsync_bdev(bdev); - zram_reset_device(zram); + zram_reset_device(zram, true); return len; } @@ -903,10 +904,12 @@ static void __exit zram_exit(void) for (i = 0; i < num_devices; i++) { zram = &zram_devices[i]; - get_disk(zram->disk); destroy_device(zram); - zram_reset_device(zram); - put_disk(zram->disk); + /* + * Shouldn't access zram->disk after destroy_device + * because destroy_device already released zram->disk. + */ + zram_reset_device(zram, false); } unregister_blkdev(zram_major, "zram"); -- GitLab From a0c516cbfc7452c8cbd564525fef66d9f20b46d1 Mon Sep 17 00:00:00 2001 From: Minchan Kim Date: Mon, 12 Aug 2013 15:13:56 +0900 Subject: [PATCH 612/942] zram: don't grab mutex in zram_slot_free_noity [1] introduced down_write in zram_slot_free_notify to prevent race between zram_slot_free_notify and zram_bvec_[read|write]. The race could happen if somebody who has right permission to open swap device is reading swap device while it is used by swap in parallel. However, zram_slot_free_notify is called with holding spin_lock of swap layer so we shouldn't avoid holing mutex. Otherwise, lockdep warns it. This patch adds new list to handle free slot and workqueue so zram_slot_free_notify just registers slot index to be freed and registers the request to workqueue. If workqueue is expired, it holds mutex_lock so there is no problem any more. If any I/O is issued, zram handles pending slot-free request caused by zram_slot_free_notify right before handling issued request because workqueue wouldn't be expired yet so zram I/O request handling function can miss it. Lastly, when zram is reset, flush_work could handle all of pending free request so we shouldn't have memory leak. NOTE: If zram_slot_free_notify's kmalloc with GFP_ATOMIC would be failed, the slot will be freed when next write I/O write the slot. [1] [57ab0485, zram: use zram->lock to protect zram_free_page() in swap free notify path] * from v2 * refactoring * from v1 * totally redesign Cc: Nitin Gupta Cc: Jiang Liu Cc: stable@vger.kernel.org Signed-off-by: Minchan Kim Signed-off-by: Greg Kroah-Hartman --- drivers/staging/zram/zram_drv.c | 60 +++++++++++++++++++++++++++++++-- drivers/staging/zram/zram_drv.h | 10 ++++++ 2 files changed, 67 insertions(+), 3 deletions(-) diff --git a/drivers/staging/zram/zram_drv.c b/drivers/staging/zram/zram_drv.c index 2a85b953e00e4..91d94b564433a 100644 --- a/drivers/staging/zram/zram_drv.c +++ b/drivers/staging/zram/zram_drv.c @@ -440,6 +440,14 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index, goto out; } + /* + * zram_slot_free_notify could miss free so that let's + * double check. + */ + if (unlikely(meta->table[index].handle || + zram_test_flag(meta, index, ZRAM_ZERO))) + zram_free_page(zram, index); + ret = lzo1x_1_compress(uncmem, PAGE_SIZE, src, &clen, meta->compress_workmem); @@ -505,6 +513,20 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index, return ret; } +static void handle_pending_slot_free(struct zram *zram) +{ + struct zram_slot_free *free_rq; + + spin_lock(&zram->slot_free_lock); + while (zram->slot_free_rq) { + free_rq = zram->slot_free_rq; + zram->slot_free_rq = free_rq->next; + zram_free_page(zram, free_rq->index); + kfree(free_rq); + } + spin_unlock(&zram->slot_free_lock); +} + static int zram_bvec_rw(struct zram *zram, struct bio_vec *bvec, u32 index, int offset, struct bio *bio, int rw) { @@ -512,10 +534,12 @@ static int zram_bvec_rw(struct zram *zram, struct bio_vec *bvec, u32 index, if (rw == READ) { down_read(&zram->lock); + handle_pending_slot_free(zram); ret = zram_bvec_read(zram, bvec, index, offset, bio); up_read(&zram->lock); } else { down_write(&zram->lock); + handle_pending_slot_free(zram); ret = zram_bvec_write(zram, bvec, index, offset); up_write(&zram->lock); } @@ -528,6 +552,8 @@ static void zram_reset_device(struct zram *zram, bool reset_capacity) size_t index; struct zram_meta *meta; + flush_work(&zram->free_work); + down_write(&zram->init_lock); if (!zram->init_done) { up_write(&zram->init_lock); @@ -722,16 +748,40 @@ static void zram_make_request(struct request_queue *queue, struct bio *bio) bio_io_error(bio); } +static void zram_slot_free(struct work_struct *work) +{ + struct zram *zram; + + zram = container_of(work, struct zram, free_work); + down_write(&zram->lock); + handle_pending_slot_free(zram); + up_write(&zram->lock); +} + +static void add_slot_free(struct zram *zram, struct zram_slot_free *free_rq) +{ + spin_lock(&zram->slot_free_lock); + free_rq->next = zram->slot_free_rq; + zram->slot_free_rq = free_rq; + spin_unlock(&zram->slot_free_lock); +} + static void zram_slot_free_notify(struct block_device *bdev, unsigned long index) { struct zram *zram; + struct zram_slot_free *free_rq; zram = bdev->bd_disk->private_data; - down_write(&zram->lock); - zram_free_page(zram, index); - up_write(&zram->lock); atomic64_inc(&zram->stats.notify_free); + + free_rq = kmalloc(sizeof(struct zram_slot_free), GFP_ATOMIC); + if (!free_rq) + return; + + free_rq->index = index; + add_slot_free(zram, free_rq); + schedule_work(&zram->free_work); } static const struct block_device_operations zram_devops = { @@ -778,6 +828,10 @@ static int create_device(struct zram *zram, int device_id) init_rwsem(&zram->lock); init_rwsem(&zram->init_lock); + INIT_WORK(&zram->free_work, zram_slot_free); + spin_lock_init(&zram->slot_free_lock); + zram->slot_free_rq = NULL; + zram->queue = blk_alloc_queue(GFP_KERNEL); if (!zram->queue) { pr_err("Error allocating disk queue for device %d\n", diff --git a/drivers/staging/zram/zram_drv.h b/drivers/staging/zram/zram_drv.h index 9e57bfb29b4f3..97a3acf6ab761 100644 --- a/drivers/staging/zram/zram_drv.h +++ b/drivers/staging/zram/zram_drv.h @@ -94,11 +94,20 @@ struct zram_meta { struct zs_pool *mem_pool; }; +struct zram_slot_free { + unsigned long index; + struct zram_slot_free *next; +}; + struct zram { struct zram_meta *meta; struct rw_semaphore lock; /* protect compression buffers, table, * 32bit stat counters against concurrent * notifications, reads and writes */ + + struct work_struct free_work; /* handle pending free request */ + struct zram_slot_free *slot_free_rq; /* list head of free request */ + struct request_queue *queue; struct gendisk *disk; int init_done; @@ -109,6 +118,7 @@ struct zram { * we can store in a disk. */ u64 disksize; /* bytes */ + spinlock_t slot_free_lock; struct zram_stats stats; }; -- GitLab From 0005cb008c16df6c09df0aa0bb155df97dd356b4 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 7 Aug 2013 21:26:12 +0100 Subject: [PATCH 613/942] staging: vt6656: rxtx.c: s_uGetDataDuration remove First Frag or Mid Frag dead code. The driver always calls s_uGetDataDuration with; uFragIdx = 0, cbLastFragmentSize = 0 and uMACfragNum = 1 uFragIdx == (uMACfragNum-1) is always true and bLastFrag = 1. Remove dead First Frag or Mid Frag if/else and variables. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 105 +--------------------------------- 1 file changed, 1 insertion(+), 104 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 1d58d1f2688fa..b0354e5d2f618 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -392,147 +392,44 @@ static u32 s_uGetDataDuration(struct vnt_private *pDevice, u8 byDurType, u32 uFragIdx, u32 cbLastFragmentSize, u32 uMACfragNum, u8 byFBOption) { - int bLastFrag = 0; - u32 uAckTime = 0, uNextPktTime = 0; - - if (uFragIdx == (uMACfragNum-1)) { - bLastFrag = 1; - } + u32 uAckTime = 0; switch (byDurType) { case DATADUR_B: //DATADUR_B - if (((uMACfragNum == 1)) || (bLastFrag == 1)) {//Non Frag or Last Frag if (bNeedAck) { uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate); return (pDevice->uSIFS + uAckTime); } else { return 0; } - } - else {//First Frag or Mid Frag - if (uFragIdx == (uMACfragNum-2)) { - uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wRate, bNeedAck); - } else { - uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, bNeedAck); - } - if (bNeedAck) { - uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate); - return (pDevice->uSIFS + uAckTime + uNextPktTime); - } else { - return (pDevice->uSIFS + uNextPktTime); - } - } break; case DATADUR_A: //DATADUR_A - if (((uMACfragNum==1)) || (bLastFrag==1)) {//Non Frag or Last Frag if(bNeedAck){ uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); return (pDevice->uSIFS + uAckTime); } else { return 0; } - } - else {//First Frag or Mid Frag - if(uFragIdx == (uMACfragNum-2)){ - uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wRate, bNeedAck); - } else { - uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wRate, bNeedAck); - } - if(bNeedAck){ - uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); - return (pDevice->uSIFS + uAckTime + uNextPktTime); - } else { - return (pDevice->uSIFS + uNextPktTime); - } - } break; case DATADUR_A_F0: //DATADUR_A_F0 - if (((uMACfragNum==1)) || (bLastFrag==1)) {//Non Frag or Last Frag if(bNeedAck){ uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); return (pDevice->uSIFS + uAckTime); } else { return 0; } - } - else { //First Frag or Mid Frag - if (byFBOption == AUTO_FB_0) { - if (wRate < RATE_18M) - wRate = RATE_18M; - else if (wRate > RATE_54M) - wRate = RATE_54M; - - if(uFragIdx == (uMACfragNum-2)){ - uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wFB_Opt0[FB_RATE0][wRate-RATE_18M], bNeedAck); - } else { - uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE0][wRate-RATE_18M], bNeedAck); - } - } else { // (byFBOption == AUTO_FB_1) - if (wRate < RATE_18M) - wRate = RATE_18M; - else if (wRate > RATE_54M) - wRate = RATE_54M; - - if(uFragIdx == (uMACfragNum-2)){ - uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wFB_Opt1[FB_RATE0][wRate-RATE_18M], bNeedAck); - } else { - uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE0][wRate-RATE_18M], bNeedAck); - } - } - - if(bNeedAck){ - uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); - return (pDevice->uSIFS + uAckTime + uNextPktTime); - } else { - return (pDevice->uSIFS + uNextPktTime); - } - } break; case DATADUR_A_F1: //DATADUR_A_F1 - if (((uMACfragNum==1)) || (bLastFrag==1)) {//Non Frag or Last Frag if(bNeedAck){ uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); return (pDevice->uSIFS + uAckTime); } else { return 0; } - } - else { //First Frag or Mid Frag - if (byFBOption == AUTO_FB_0) { - if (wRate < RATE_18M) - wRate = RATE_18M; - else if (wRate > RATE_54M) - wRate = RATE_54M; - - if(uFragIdx == (uMACfragNum-2)){ - uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wFB_Opt0[FB_RATE1][wRate-RATE_18M], bNeedAck); - } else { - uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt0[FB_RATE1][wRate-RATE_18M], bNeedAck); - } - - } else { // (byFBOption == AUTO_FB_1) - if (wRate < RATE_18M) - wRate = RATE_18M; - else if (wRate > RATE_54M) - wRate = RATE_54M; - - if(uFragIdx == (uMACfragNum-2)){ - uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbLastFragmentSize, wFB_Opt1[FB_RATE1][wRate-RATE_18M], bNeedAck); - } else { - uNextPktTime = s_uGetTxRsvTime(pDevice, byPktType, cbFrameLength, wFB_Opt1[FB_RATE1][wRate-RATE_18M], bNeedAck); - } - } - if(bNeedAck){ - uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); - return (pDevice->uSIFS + uAckTime + uNextPktTime); - } else { - return (pDevice->uSIFS + uNextPktTime); - } - } break; default: -- GitLab From 3ed210ef59229debe6d8e6509382c1e7c6104409 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 7 Aug 2013 21:28:45 +0100 Subject: [PATCH 614/942] staging: vt6656: rxtx.c: s_uGetDataDuration remove dead variables. As result of patch staging: vt6656: rxtx.c s_uGetDataDuration remove First Frag or Mid Frag dead code. cbFrameLength, wRate, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption are dead variables. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 74 ++++++++++++++--------------------- 1 file changed, 30 insertions(+), 44 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index b0354e5d2f618..b8d8d2a1bd3b6 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -135,9 +135,7 @@ static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, struct ethhdr *psEthHeader, u16 wCurrentRate, u8 byFBOption); static u32 s_uGetDataDuration(struct vnt_private *pDevice, u8 byDurType, - u32 cbFrameLength, u8 byPktType, u16 wRate, int bNeedAck, - u32 uFragIdx, u32 cbLastFragmentSize, u32 uMACfragNum, - u8 byFBOption); + u8 byPktType, int bNeedAck); static unsigned int s_uGetRTSCTSDuration(struct vnt_private *pDevice, u8 byDurType, u32 cbFrameLength, u8 byPktType, u16 wRate, @@ -388,9 +386,7 @@ static u32 s_uGetRTSCTSRsvTime(struct vnt_private *pDevice, //byFreqType 0: 5GHz, 1:2.4Ghz static u32 s_uGetDataDuration(struct vnt_private *pDevice, u8 byDurType, - u32 cbFrameLength, u8 byPktType, u16 wRate, int bNeedAck, - u32 uFragIdx, u32 cbLastFragmentSize, u32 uMACfragNum, - u8 byFBOption) + u8 byPktType, int bNeedAck) { u32 uAckTime = 0; @@ -545,10 +541,8 @@ static u32 s_uFillDataHead(struct vnt_private *pDevice, (u16 *)&(pBuf->wTransmitLength), (u8 *)&(pBuf->byServiceField), (u8 *)&(pBuf->bySignalField) ); //Get Duration and TimeStampOff - pBuf->wDuration = (u16)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameLength, byPktType, - wCurrentRate, bNeedAck, uFragIdx, - cbLastFragmentSize, uMACfragNum, - byFBOption); //1: 2.4GHz + pBuf->wDuration = (u16)s_uGetDataDuration(pDevice, DATADUR_A, + byPktType, bNeedAck); if(uDMAIdx!=TYPE_ATIMDMA) { pBuf->wTimeStampOff = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]; } @@ -565,14 +559,10 @@ static u32 s_uFillDataHead(struct vnt_private *pDevice, (u16 *)&(pBuf->wTransmitLength_b), (u8 *)&(pBuf->byServiceField_b), (u8 *)&(pBuf->bySignalField_b) ); //Get Duration and TimeStamp - pBuf->wDuration_a = (u16)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameLength, - byPktType, wCurrentRate, bNeedAck, uFragIdx, - cbLastFragmentSize, uMACfragNum, - byFBOption); //1: 2.4GHz - pBuf->wDuration_b = (u16)s_uGetDataDuration(pDevice, DATADUR_B, cbFrameLength, - PK_TYPE_11B, pDevice->byTopCCKBasicRate, - bNeedAck, uFragIdx, cbLastFragmentSize, - uMACfragNum, byFBOption); //1: 2.4GHz + pBuf->wDuration_a = (u16)s_uGetDataDuration(pDevice, DATADUR_A, + byPktType, bNeedAck); + pBuf->wDuration_b = (u16)s_uGetDataDuration(pDevice, DATADUR_B, + PK_TYPE_11B, bNeedAck); pBuf->wTimeStampOff_a = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]; pBuf->wTimeStampOff_b = wTimeStampOff[pDevice->byPreambleType%2][pDevice->byTopCCKBasicRate%MAX_RATE]; @@ -588,14 +578,14 @@ static u32 s_uFillDataHead(struct vnt_private *pDevice, (u16 *)&(pBuf->wTransmitLength_b), (u8 *)&(pBuf->byServiceField_b), (u8 *)&(pBuf->bySignalField_b) ); //Get Duration and TimeStamp - pBuf->wDuration_a = (u16)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameLength, byPktType, - wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption); //1: 2.4GHz - pBuf->wDuration_b = (u16)s_uGetDataDuration(pDevice, DATADUR_B, cbFrameLength, PK_TYPE_11B, - pDevice->byTopCCKBasicRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption); //1: 2.4GHz - pBuf->wDuration_a_f0 = (u16)s_uGetDataDuration(pDevice, DATADUR_A_F0, cbFrameLength, byPktType, - wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption); //1: 2.4GHz - pBuf->wDuration_a_f1 = (u16)s_uGetDataDuration(pDevice, DATADUR_A_F1, cbFrameLength, byPktType, - wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption); //1: 2.4GHz + pBuf->wDuration_a = (u16)s_uGetDataDuration(pDevice, DATADUR_A, + byPktType, bNeedAck); + pBuf->wDuration_b = (u16)s_uGetDataDuration(pDevice, DATADUR_B, + PK_TYPE_11B, bNeedAck); + pBuf->wDuration_a_f0 = (u16)s_uGetDataDuration(pDevice, + DATADUR_A_F0, byPktType, bNeedAck); + pBuf->wDuration_a_f1 = (u16)s_uGetDataDuration(pDevice, + DATADUR_A_F1, byPktType, bNeedAck); pBuf->wTimeStampOff_a = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]; pBuf->wTimeStampOff_b = wTimeStampOff[pDevice->byPreambleType%2][pDevice->byTopCCKBasicRate%MAX_RATE]; return (pBuf->wDuration_a); @@ -611,12 +601,12 @@ static u32 s_uFillDataHead(struct vnt_private *pDevice, (u16 *)&(pBuf->wTransmitLength), (u8 *)&(pBuf->byServiceField), (u8 *)&(pBuf->bySignalField) ); //Get Duration and TimeStampOff - pBuf->wDuration = (u16)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameLength, byPktType, - wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption); //0: 5GHz - pBuf->wDuration_f0 = (u16)s_uGetDataDuration(pDevice, DATADUR_A_F0, cbFrameLength, byPktType, - wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption); //0: 5GHz - pBuf->wDuration_f1 = (u16)s_uGetDataDuration(pDevice, DATADUR_A_F1, cbFrameLength, byPktType, - wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption); //0: 5GHz + pBuf->wDuration = (u16)s_uGetDataDuration(pDevice, DATADUR_A, + byPktType, bNeedAck); + pBuf->wDuration_f0 = (u16)s_uGetDataDuration(pDevice, + DATADUR_A_F0, byPktType, bNeedAck); + pBuf->wDuration_f1 = (u16)s_uGetDataDuration(pDevice, + DATADUR_A_F1, byPktType, bNeedAck); if(uDMAIdx!=TYPE_ATIMDMA) { pBuf->wTimeStampOff = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]; } @@ -628,10 +618,8 @@ static u32 s_uFillDataHead(struct vnt_private *pDevice, (u16 *)&(pBuf->wTransmitLength), (u8 *)&(pBuf->byServiceField), (u8 *)&(pBuf->bySignalField) ); //Get Duration and TimeStampOff - pBuf->wDuration = (u16)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameLength, byPktType, - wCurrentRate, bNeedAck, uFragIdx, - cbLastFragmentSize, uMACfragNum, - byFBOption); + pBuf->wDuration = (u16)s_uGetDataDuration(pDevice, DATADUR_A, + byPktType, bNeedAck); if(uDMAIdx!=TYPE_ATIMDMA) { pBuf->wTimeStampOff = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]; @@ -646,10 +634,8 @@ static u32 s_uFillDataHead(struct vnt_private *pDevice, (u16 *)&(pBuf->wTransmitLength), (u8 *)&(pBuf->byServiceField), (u8 *)&(pBuf->bySignalField) ); //Get Duration and TimeStampOff - pBuf->wDuration = (u16)s_uGetDataDuration(pDevice, DATADUR_B, cbFrameLength, byPktType, - wCurrentRate, bNeedAck, uFragIdx, - cbLastFragmentSize, uMACfragNum, - byFBOption); + pBuf->wDuration = (u16)s_uGetDataDuration(pDevice, DATADUR_B, + byPktType, bNeedAck); if (uDMAIdx != TYPE_ATIMDMA) { pBuf->wTimeStampOff = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]; } @@ -1806,8 +1792,8 @@ CMD_STATUS csBeacon_xmit(struct vnt_private *pDevice, (u16 *)&(pTxDataHead->wTransmitLength), (u8 *)&(pTxDataHead->byServiceField), (u8 *)&(pTxDataHead->bySignalField) ); //Get Duration and TimeStampOff - pTxDataHead->wDuration = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameSize, PK_TYPE_11A, - wCurrentRate, false, 0, 0, 1, AUTO_FB_NONE)); + pTxDataHead->wDuration = cpu_to_le16((u16)s_uGetDataDuration(pDevice, + DATADUR_A, PK_TYPE_11A, false)); pTxDataHead->wTimeStampOff = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]; cbHeaderSize = wTxBufSize + sizeof(STxDataHead_ab); } else { @@ -1819,8 +1805,8 @@ CMD_STATUS csBeacon_xmit(struct vnt_private *pDevice, (u16 *)&(pTxDataHead->wTransmitLength), (u8 *)&(pTxDataHead->byServiceField), (u8 *)&(pTxDataHead->bySignalField) ); //Get Duration and TimeStampOff - pTxDataHead->wDuration = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_B, cbFrameSize, PK_TYPE_11B, - wCurrentRate, false, 0, 0, 1, AUTO_FB_NONE)); + pTxDataHead->wDuration = cpu_to_le16((u16)s_uGetDataDuration(pDevice, + DATADUR_B, PK_TYPE_11B, false)); pTxDataHead->wTimeStampOff = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]; cbHeaderSize = wTxBufSize + sizeof(STxDataHead_ab); } -- GitLab From ab01fedce8a6a1beb89576fc4fb64a73e5e03fad Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 7 Aug 2013 21:31:48 +0100 Subject: [PATCH 615/942] staging: vt6656: rxtx.c s_uFillDataHead remove dead variables. As result of patches staging: vt6656: rxtx.c: s_uGetDataDuration remove First Frag or Mid Frag dead code staging: vt6656: rxtx.c: s_uGetDataDuration remove dead variables. variables uFragIdx, cbLastFragmentSize, uMACfragNum are dead. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index b8d8d2a1bd3b6..c8e3e7e85cbec 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -106,8 +106,7 @@ static void s_vGenerateTxParameter(struct vnt_private *pDevice, static u32 s_uFillDataHead(struct vnt_private *pDevice, u8 byPktType, u16 wCurrentRate, void *pTxDataHead, u32 cbFrameLength, - u32 uDMAIdx, int bNeedAck, u32 uFragIdx, u32 cbLastFragmentSize, - u32 uMACfragNum, u8 byFBOption); + u32 uDMAIdx, int bNeedAck, u8 byFBOption); static void s_vGenerateMACHeader(struct vnt_private *pDevice, u8 *pbyBufferAddr, u16 wDuration, struct ethhdr *psEthHeader, @@ -525,8 +524,7 @@ static u32 s_uGetRTSCTSDuration(struct vnt_private *pDevice, u8 byDurType, static u32 s_uFillDataHead(struct vnt_private *pDevice, u8 byPktType, u16 wCurrentRate, void *pTxDataHead, u32 cbFrameLength, - u32 uDMAIdx, int bNeedAck, u32 uFragIdx, u32 cbLastFragmentSize, - u32 uMACfragNum, u8 byFBOption) + u32 uDMAIdx, int bNeedAck, u8 byFBOption) { if (pTxDataHead == NULL) { @@ -1244,7 +1242,7 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, cbFrameSize, bNeedACK, uDMAIdx, psEthHeader); //Fill DataHead uDuration = s_uFillDataHead(pDevice, byPktType, wCurrentRate, pvTxDataHd, cbFrameSize, uDMAIdx, bNeedACK, - 0, 0, 1/*uMACfragNum*/, byFBOption); + byFBOption); // Generate TX MAC Header s_vGenerateMACHeader(pDevice, pbyMacHdr, (u16)uDuration, psEthHeader, bNeedEncryption, byFragType, uDMAIdx, 0); @@ -1663,7 +1661,7 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice, //Fill DataHead uDuration = s_uFillDataHead(pDevice, byPktType, wCurrentRate, pvTxDataHd, cbFrameSize, TYPE_TXDMA0, bNeedACK, - 0, 0, 1, AUTO_FB_NONE); + AUTO_FB_NONE); pMACHeader = (struct ieee80211_hdr *) (pbyTxBufferAddr + cbHeaderSize); @@ -2063,7 +2061,7 @@ void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb) //Fill DataHead uDuration = s_uFillDataHead(pDevice, byPktType, wCurrentRate, pvTxDataHd, cbFrameSize, TYPE_TXDMA0, bNeedACK, - 0, 0, 1, AUTO_FB_NONE); + AUTO_FB_NONE); pMACHeader = (struct ieee80211_hdr *) (pbyTxBufferAddr + cbHeaderSize); -- GitLab From d27727b50219f9a7033e1a1be3fc45644881210f Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Tue, 13 Aug 2013 15:49:51 -0400 Subject: [PATCH 616/942] staging: dgnc: removes Makefile.inc The Makefile contains the variables needed for the driver to build. The Makefile.inc isn't needed. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/Makefile.inc | 133 ------------------------------ 1 file changed, 133 deletions(-) delete mode 100644 drivers/staging/dgnc/Makefile.inc diff --git a/drivers/staging/dgnc/Makefile.inc b/drivers/staging/dgnc/Makefile.inc deleted file mode 100644 index 6ca38c731c390..0000000000000 --- a/drivers/staging/dgnc/Makefile.inc +++ /dev/null @@ -1,133 +0,0 @@ -# -# From Makefile.inc -# - -# -# Common definitions go here. -# - -# -# TRUE_VERSION is the version string used in the driver build, -# it is intended to be in the form: -# -# 2.0-0 -# -# A string noting a particular special modification could be -# used as well. This string will be reported when the driver -# is loaded, and will be exposed by its /proc/dgnc/info -# interface. -# -TRUE_VERSION="1.3-16" - -# -# DGNC_PART_NUM is the part number string for the driver package. -# It should be in the form: -# -# 40002369_A -# -DGNC_PART_NUM=40002369_F - -# -# DGNC_REL_NOTE is the part number string for the driver release -# notes. It should be in the form: -# -# 93000517_A -# -DGNC_REL_NOTE=93000517_F - -# -# DGNC_PKG_VER is the "version" number string included in the -# various documentation and packaging files. It should be -# in the form: -# -# 1.0 -# -DGNC_PKG_VER=1.3 - -# -# DGNC_PKG_REV is the "revision" of this version. Together, -# a linux module revision is built with: -# -# ${DGNC_PKG_VER}-${DGNC_PKG_REV} -# -DGNC_PKG_REV=16 - -# -# DRP_PKG_DATE is the "date" string included in (for now) the -# release notes. It should be in the form: -# -# 11/04/2003 -# -DGNC_PKG_DATE=10/17/2008 - -INIT_DIR= $(shell \ - if [ -d /etc/rc.d/init.d ]; \ - then echo "$(RPM_BUILD_ROOT)/etc/rc.d/init.d"; \ - else echo "$(RPM_BUILD_ROOT)/etc/init.d"; fi) - -# -# Miscelaneous path macro's -# - -PACKAGE= dgnc -DEVDIR= /dev/dg/$(PACKAGE) -SRCDIR= /usr/src/dg/$(PACKAGE) -BINDIR= /usr/bin -DRVLIBDIR= /etc/$(PACKAGE) -MANDIR= /usr/man -USRLIBDIR= /usr/lib -DGNCDIR= /etc/dgnc - - -INIT_DIR= $(shell \ - if [ -d /etc/rc.d/init.d ]; \ - then echo "/etc/rc.d/init.d"; \ - else echo "/etc/init.d"; fi) - - -# -# From Makefile -# -ifndef MYPWD -MYPWD = $(shell pwd) -endif - -ifeq ($(KERNDIR),) - KERNVERS := $(shell uname -r) - KERNDIR :=/lib/modules/${KERNVERS}/ -endif - -# Grab version and other important stuff - -RPMNAME := $(PACKAGE)-$(TRUE_VERSION) - -PARTNUM := $(DGNC_PART_NUM) - -RELNOTES := $(DGNC_REL_NOTE) - -MODDIR = $(shell echo $(BUILDROOT)/lib/modules/3.4.36-lcrs/misc) -LSMOD = /sbin/lsmod -RMMOD = /sbin/rmmod -INSMOD = /sbin/insmod -NEW_TTY_LOCKING = No -NEW_TTY_BUFFERING = No -REGISTER_TTYS_WITH_SYSFS = No - -# Send in some extra things... -EXTRA_CFLAGS += -I${MYPWD} -I${MYPWD}/include -I${MYPWD}/../../commoninc\ - -I${MYPWD}/../../dpa -DLINUX -DDG_NAME=\"$(RPMNAME)\"\ - -DDG_PART=\"$(PARTNUM)\" -DDGNC_TRACER - -ifeq ($(NEW_TTY_LOCKING),Yes) - EXTRA_CFLAGS += -DNEW_TTY_LOCKING -endif - -ifeq ($(NEW_TTY_BUFFERING),Yes) - EXTRA_CFLAGS += -DNEW_TTY_BUFFERING -endif - -ifeq ($(REGISTER_TTYS_WITH_SYSFS),Yes) - EXTRA_CFLAGS += -DREGISTER_TTYS_WITH_SYSFS -endif - -# Conform to correct kbuild conventions... -- GitLab From 22e3de76ab7f4e02825a158cb2575feb5be6b062 Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Tue, 13 Aug 2013 15:49:53 -0400 Subject: [PATCH 617/942] staging: dgnc: fixes termios error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch fixes this error: invalid type argument of ‘->’ (have ‘struct ktermios’). There were changes in the tty layer's API. Access to the termios flags changed from tty->termios->*flag* to tty->termios.*flag*. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_tty.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c index 461e88161808c..63b80e280e08b 100644 --- a/drivers/staging/dgnc/dgnc_tty.c +++ b/drivers/staging/dgnc/dgnc_tty.c @@ -719,7 +719,7 @@ void dgnc_input(struct channel_t *ch) * flush input data and return immediately. */ if (!tp || (tp->magic != TTY_MAGIC) || !(ch->ch_tun.un_flags & UN_ISOPEN) || - !(tp->termios->c_cflag & CREAD) || (ch->ch_tun.un_flags & UN_CLOSING)) { + !(tp->termios.c_cflag & CREAD) || (ch->ch_tun.un_flags & UN_CLOSING)) { DPR_READ(("input. dropping %d bytes on port %d...\n", data_len, ch->ch_portnum)); DPR_READ(("input. tp: %p tp->magic: %x MAGIC:%x ch flags: %x\n", @@ -1495,12 +1495,12 @@ static int dgnc_tty_open(struct tty_struct *tty, struct file *file) ch->ch_stop_sending_break = 0; ch->ch_stops_sent = 0; - ch->ch_c_cflag = tty->termios->c_cflag; - ch->ch_c_iflag = tty->termios->c_iflag; - ch->ch_c_oflag = tty->termios->c_oflag; - ch->ch_c_lflag = tty->termios->c_lflag; - ch->ch_startc = tty->termios->c_cc[VSTART]; - ch->ch_stopc = tty->termios->c_cc[VSTOP]; + ch->ch_c_cflag = tty->termios.c_cflag; + ch->ch_c_iflag = tty->termios.c_iflag; + ch->ch_c_oflag = tty->termios.c_oflag; + ch->ch_c_lflag = tty->termios.c_lflag; + ch->ch_startc = tty->termios.c_cc[VSTART]; + ch->ch_stopc = tty->termios.c_cc[VSTOP]; /* * Bring up RTS and DTR... @@ -2874,12 +2874,12 @@ static void dgnc_tty_set_termios(struct tty_struct *tty, struct ktermios *old_te DGNC_LOCK(ch->ch_lock, lock_flags); - ch->ch_c_cflag = tty->termios->c_cflag; - ch->ch_c_iflag = tty->termios->c_iflag; - ch->ch_c_oflag = tty->termios->c_oflag; - ch->ch_c_lflag = tty->termios->c_lflag; - ch->ch_startc = tty->termios->c_cc[VSTART]; - ch->ch_stopc = tty->termios->c_cc[VSTOP]; + ch->ch_c_cflag = tty->termios.c_cflag; + ch->ch_c_iflag = tty->termios.c_iflag; + ch->ch_c_oflag = tty->termios.c_oflag; + ch->ch_c_lflag = tty->termios.c_lflag; + ch->ch_startc = tty->termios.c_cc[VSTART]; + ch->ch_stopc = tty->termios.c_cc[VSTOP]; ch->ch_bd->bd_ops->param(tty); dgnc_carrier(ch); @@ -3272,7 +3272,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, struct file *file, unsigned in return(rc); DGNC_LOCK(ch->ch_lock, lock_flags); - tty->termios->c_cflag = ((tty->termios->c_cflag & ~CLOCAL) | (arg ? CLOCAL : 0)); + tty->termios.c_cflag = ((tty->termios.c_cflag & ~CLOCAL) | (arg ? CLOCAL : 0)); ch->ch_bd->bd_ops->param(tty); DGNC_UNLOCK(ch->ch_lock, lock_flags); -- GitLab From bf0f2ebff31adf786b59bc84d0522fed246c9471 Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Tue, 13 Aug 2013 15:49:54 -0400 Subject: [PATCH 618/942] staging: dgnc: fixes tty_port and tty_struct params The functions tty_flip_buffer_push, tty_insert_flip_string, tty_insert_flip_char and tty_buffer_request_room now require a struct of type tty_port instead of struct tty_struct. This patch makes those changes. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_tty.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c index 63b80e280e08b..a00fe2bcaad88 100644 --- a/drivers/staging/dgnc/dgnc_tty.c +++ b/drivers/staging/dgnc/dgnc_tty.c @@ -870,7 +870,7 @@ void dgnc_input(struct channel_t *ch) } else { - len = tty_buffer_request_room(tp, len); + len = tty_buffer_request_room(tp->port, len); n = len; /* @@ -894,17 +894,17 @@ void dgnc_input(struct channel_t *ch) if (I_PARMRK(tp) || I_BRKINT(tp) || I_INPCK(tp)) { for (i = 0; i < s; i++) { if (*(ch->ch_equeue + tail + i) & UART_LSR_BI) - tty_insert_flip_char(tp, *(ch->ch_rqueue + tail + i), TTY_BREAK); + tty_insert_flip_char(tp->port, *(ch->ch_rqueue + tail + i), TTY_BREAK); else if (*(ch->ch_equeue + tail + i) & UART_LSR_PE) - tty_insert_flip_char(tp, *(ch->ch_rqueue + tail + i), TTY_PARITY); + tty_insert_flip_char(tp->port, *(ch->ch_rqueue + tail + i), TTY_PARITY); else if (*(ch->ch_equeue + tail + i) & UART_LSR_FE) - tty_insert_flip_char(tp, *(ch->ch_rqueue + tail + i), TTY_FRAME); + tty_insert_flip_char(tp->port, *(ch->ch_rqueue + tail + i), TTY_FRAME); else - tty_insert_flip_char(tp, *(ch->ch_rqueue + tail + i), TTY_NORMAL); + tty_insert_flip_char(tp->port, *(ch->ch_rqueue + tail + i), TTY_NORMAL); } } else { - tty_insert_flip_string(tp, ch->ch_rqueue + tail, s); + tty_insert_flip_string(tp->port, ch->ch_rqueue + tail, s); } dgnc_sniff_nowait_nolock(ch, "USER READ", ch->ch_rqueue + tail, s); @@ -921,7 +921,7 @@ void dgnc_input(struct channel_t *ch) DGNC_UNLOCK(ch->ch_lock, lock_flags); /* Tell the tty layer its okay to "eat" the data now */ - tty_flip_buffer_push(tp); + tty_flip_buffer_push(tp->port); } if (ld) -- GitLab From 5857a0b5f11b424911cc44034357d69abba85f8b Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Tue, 13 Aug 2013 15:49:55 -0400 Subject: [PATCH 619/942] staging: dgnc: dereferences ts var in dgnc_tty_close() The value tty->termios needed to be dereferenced to be assigned to the variable ts. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_tty.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c index a00fe2bcaad88..c174bf8063ebf 100644 --- a/drivers/staging/dgnc/dgnc_tty.c +++ b/drivers/staging/dgnc/dgnc_tty.c @@ -1758,7 +1758,7 @@ static void dgnc_tty_close(struct tty_struct *tty, struct file *file) if (!bd || bd->magic != DGNC_BOARD_MAGIC) return; - ts = tty->termios; + ts = &tty->termios; DPR_CLOSE(("Close called\n")); -- GitLab From 9b03ffaf7fb99316a2c21302e9dc1e4fef18a420 Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Tue, 13 Aug 2013 15:49:56 -0400 Subject: [PATCH 620/942] staging: dgcn: removes unnecessary commands in ioctl The commands TIOCGETP, TCGETS, and TCGETA are not supposed to be seen by the ioctl. This patch removes the switch cases for these commands. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_tty.c | 34 --------------------------------- 1 file changed, 34 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c index c174bf8063ebf..9dbe7bd0d2ff2 100644 --- a/drivers/staging/dgnc/dgnc_tty.c +++ b/drivers/staging/dgnc/dgnc_tty.c @@ -3336,40 +3336,6 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, struct file *file, unsigned in /* pretend we didn't recognize this IOCTL */ DGNC_UNLOCK(ch->ch_lock, lock_flags); return(-ENOIOCTLCMD); - -#ifdef TIOCGETP - case TIOCGETP: -#endif - case TCGETS: - case TCGETA: -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30) - if (tty->ldisc->ops->ioctl) { -#else - if (tty->ldisc.ops->ioctl) { -#endif - int retval = (-ENXIO); - - DGNC_UNLOCK(ch->ch_lock, lock_flags); - - if (tty->termios) { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30) - retval = ((tty->ldisc->ops->ioctl) (tty, file, cmd, arg)); -#else - retval = ((tty->ldisc.ops->ioctl) (tty, file, cmd, arg)); -#endif - } - - DPR_IOCTL(("dgnc_tty_ioctl (LINE:%d) finish on port %d - cmd %s (%x), arg %lx\n", - __LINE__, ch->ch_portnum, dgnc_ioctl_name(cmd), cmd, arg)); - return(retval); - } - - DGNC_UNLOCK(ch->ch_lock, lock_flags); - DPR_IOCTL(("dgnc_tty_ioctl (LINE:%d) finish on port %d - cmd %s (%x), arg %lx\n", - __LINE__, ch->ch_portnum, dgnc_ioctl_name(cmd), cmd, arg)); - - return(-ENOIOCTLCMD); - case TCSETSF: case TCSETSW: /* -- GitLab From a31cefa2648205a972b65c4b8d520823ae4be1b6 Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Tue, 13 Aug 2013 15:49:57 -0400 Subject: [PATCH 621/942] staging: dgnc: fixes ioctl param list The declaration for the ioctl function has changed. The previous version of this declaration took struct file *file as a parameter and the new one does not. This patch removes that parameter. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_tty.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c index 9dbe7bd0d2ff2..6f2ddb33176cf 100644 --- a/drivers/staging/dgnc/dgnc_tty.c +++ b/drivers/staging/dgnc/dgnc_tty.c @@ -112,7 +112,7 @@ static struct ktermios DgncDefaultTermios = static int dgnc_tty_open(struct tty_struct *tty, struct file *file); static void dgnc_tty_close(struct tty_struct *tty, struct file *file); static int dgnc_block_til_ready(struct tty_struct *tty, struct file *file, struct channel_t *ch); -static int dgnc_tty_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg); +static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg); static int dgnc_tty_digigeta(struct tty_struct *tty, struct digi_t __user *retinfo); static int dgnc_tty_digiseta(struct tty_struct *tty, struct digi_t __user *new_info); static int dgnc_tty_write_room(struct tty_struct* tty); @@ -3123,7 +3123,7 @@ static void dgnc_tty_flush_buffer(struct tty_struct *tty) * * The usual assortment of ioctl's */ -static int dgnc_tty_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, +static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg) { struct board_t *bd; -- GitLab From 100013fa1d15181dfefc22e61a2744e8e0ca3c00 Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Tue, 13 Aug 2013 15:49:58 -0400 Subject: [PATCH 622/942] staging: dgnc: removes read_cnt, real_raw, rawreadok and buf This patch removes the use of read_cnt, real_raw, buf and rawreadok. The variable buf is never used in the code. The variables rawreadok read_cnt and real_raw don't exist in the new API. Reading the data raw is no longer supported by the tty layer. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_tty.c | 155 +++++++++----------------------- 1 file changed, 43 insertions(+), 112 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c index 6f2ddb33176cf..2acf9348388c3 100644 --- a/drivers/staging/dgnc/dgnc_tty.c +++ b/drivers/staging/dgnc/dgnc_tty.c @@ -683,7 +683,6 @@ void dgnc_input(struct channel_t *ch) int flip_len; int len = 0; int n = 0; - char *buf = NULL; int s = 0; int i = 0; @@ -746,15 +745,11 @@ void dgnc_input(struct channel_t *ch) DPR_READ(("dgnc_input start 2\n")); - /* Decide how much data we can send into the tty layer */ - if (dgnc_rawreadok && tp->real_raw) - flip_len = MYFLIPLEN; - else - flip_len = TTY_FLIPBUF_SIZE; + flip_len = TTY_FLIPBUF_SIZE; /* Chop down the length, if needed */ len = min(data_len, flip_len); - len = min(len, (N_TTY_BUF_SIZE - 1) - tp->read_cnt); + len = min(len, (N_TTY_BUF_SIZE - 1)); ld = tty_ldisc_ref(tp); @@ -807,122 +802,58 @@ void dgnc_input(struct channel_t *ch) * On the other hand, if we are not raw, we need to go through * the new 2.6.16+ tty layer, which has its API more well defined. */ - if (dgnc_rawreadok && tp->real_raw) { - - if (ch->ch_flags & CH_FLIPBUF_IN_USE) { - DPR_READ(("DGNC - FLIPBUF in use. delaying input\n")); - DGNC_UNLOCK(ch->ch_lock, lock_flags); - if (ld) - tty_ldisc_deref(ld); - return; - } + len = tty_buffer_request_room(tp->port, len); + n = len; - ch->ch_flags |= CH_FLIPBUF_IN_USE; - buf = ch->ch_bd->flipbuf; + /* + * n now contains the most amount of data we can copy, + * bounded either by how much the Linux tty layer can handle, + * or the amount of data the card actually has pending... + */ + while (n) { + s = ((head >= tail) ? head : RQUEUESIZE) - tail; + s = min(s, n); - n = len; + if (s <= 0) + break; /* - * n now contains the most amount of data we can copy, - * bounded either by the flip buffer size or the amount - * of data the card actually has pending... + * If conditions are such that ld needs to see all + * UART errors, we will have to walk each character + * and error byte and send them to the buffer one at + * a time. */ - while (n) { - s = ((head >= tail) ? head : RQUEUESIZE) - tail; - s = min(s, n); - - if (s <= 0) - break; - - memcpy(buf, ch->ch_rqueue + tail, s); - dgnc_sniff_nowait_nolock(ch, "USER READ", ch->ch_rqueue + tail, s); - - tail += s; - buf += s; - - n -= s; - /* Flip queue if needed */ - tail &= rmask; + if (I_PARMRK(tp) || I_BRKINT(tp) || I_INPCK(tp)) { + for (i = 0; i < s; i++) { + if (*(ch->ch_equeue + tail + i) & UART_LSR_BI) + tty_insert_flip_char(tp->port, *(ch->ch_rqueue + tail + i), TTY_BREAK); + else if (*(ch->ch_equeue + tail + i) & UART_LSR_PE) + tty_insert_flip_char(tp->port, *(ch->ch_rqueue + tail + i), TTY_PARITY); + else if (*(ch->ch_equeue + tail + i) & UART_LSR_FE) + tty_insert_flip_char(tp->port, *(ch->ch_rqueue + tail + i), TTY_FRAME); + else + tty_insert_flip_char(tp->port, *(ch->ch_rqueue + tail + i), TTY_NORMAL); + } + } + else { + tty_insert_flip_string(tp->port, ch->ch_rqueue + tail, s); } - ch->ch_r_tail = tail & rmask; - ch->ch_e_tail = tail & rmask; - - dgnc_check_queue_flow_control(ch); - - /* !!! WE *MUST* LET GO OF ALL LOCKS BEFORE CALLING RECEIVE BUF !!! */ - - DGNC_UNLOCK(ch->ch_lock, lock_flags); - - DPR_READ(("dgnc_input. %d real_raw len:%d calling receive_buf for buffer for board %d\n", - __LINE__, len, ch->ch_bd->boardnum)); - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30) - tp->ldisc->ops->receive_buf(tp, ch->ch_bd->flipbuf, NULL, len); -#else - tp->ldisc.ops->receive_buf(tp, ch->ch_bd->flipbuf, NULL, len); -#endif - - /* Allow use of channel flip buffer again */ - DGNC_LOCK(ch->ch_lock, lock_flags); - ch->ch_flags &= ~CH_FLIPBUF_IN_USE; - DGNC_UNLOCK(ch->ch_lock, lock_flags); + dgnc_sniff_nowait_nolock(ch, "USER READ", ch->ch_rqueue + tail, s); + tail += s; + n -= s; + /* Flip queue if needed */ + tail &= rmask; } - else { - len = tty_buffer_request_room(tp->port, len); - n = len; - - /* - * n now contains the most amount of data we can copy, - * bounded either by how much the Linux tty layer can handle, - * or the amount of data the card actually has pending... - */ - while (n) { - s = ((head >= tail) ? head : RQUEUESIZE) - tail; - s = min(s, n); - - if (s <= 0) - break; - /* - * If conditions are such that ld needs to see all - * UART errors, we will have to walk each character - * and error byte and send them to the buffer one at - * a time. - */ - if (I_PARMRK(tp) || I_BRKINT(tp) || I_INPCK(tp)) { - for (i = 0; i < s; i++) { - if (*(ch->ch_equeue + tail + i) & UART_LSR_BI) - tty_insert_flip_char(tp->port, *(ch->ch_rqueue + tail + i), TTY_BREAK); - else if (*(ch->ch_equeue + tail + i) & UART_LSR_PE) - tty_insert_flip_char(tp->port, *(ch->ch_rqueue + tail + i), TTY_PARITY); - else if (*(ch->ch_equeue + tail + i) & UART_LSR_FE) - tty_insert_flip_char(tp->port, *(ch->ch_rqueue + tail + i), TTY_FRAME); - else - tty_insert_flip_char(tp->port, *(ch->ch_rqueue + tail + i), TTY_NORMAL); - } - } - else { - tty_insert_flip_string(tp->port, ch->ch_rqueue + tail, s); - } - - dgnc_sniff_nowait_nolock(ch, "USER READ", ch->ch_rqueue + tail, s); - - tail += s; - n -= s; - /* Flip queue if needed */ - tail &= rmask; - } - - ch->ch_r_tail = tail & rmask; - ch->ch_e_tail = tail & rmask; - dgnc_check_queue_flow_control(ch); - DGNC_UNLOCK(ch->ch_lock, lock_flags); + ch->ch_r_tail = tail & rmask; + ch->ch_e_tail = tail & rmask; + dgnc_check_queue_flow_control(ch); + DGNC_UNLOCK(ch->ch_lock, lock_flags); - /* Tell the tty layer its okay to "eat" the data now */ - tty_flip_buffer_push(tp->port); - } + /* Tell the tty layer its okay to "eat" the data now */ + tty_flip_buffer_push(tp->port); if (ld) tty_ldisc_deref(ld); -- GitLab From 18f8191e1f35d65221ad3b7c68c08fe1c09edb1d Mon Sep 17 00:00:00 2001 From: Rupesh Gujare Date: Tue, 13 Aug 2013 18:24:21 +0100 Subject: [PATCH 623/942] staging: ozwpan: Add a blank line between declaraction and code. This patch adds blank line between declaration & code for readability. Signed-off-by: Rupesh Gujare Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozcdev.c | 6 ++++++ drivers/staging/ozwpan/ozeltbuf.c | 7 +++++++ drivers/staging/ozwpan/ozhcd.c | 28 ++++++++++++++++++++++++++ drivers/staging/ozwpan/ozpd.c | 22 ++++++++++++++++++++ drivers/staging/ozwpan/ozproto.c | 7 +++++++ drivers/staging/ozwpan/ozurbparanoia.c | 2 ++ drivers/staging/ozwpan/ozusbsvc.c | 8 ++++++++ drivers/staging/ozwpan/ozusbsvc1.c | 9 +++++++++ 8 files changed, 89 insertions(+) diff --git a/drivers/staging/ozwpan/ozcdev.c b/drivers/staging/ozwpan/ozcdev.c index 73b582cdf424a..0c79fd0105553 100644 --- a/drivers/staging/ozwpan/ozcdev.c +++ b/drivers/staging/ozwpan/ozcdev.c @@ -49,6 +49,7 @@ static struct class *g_oz_class; static struct oz_serial_ctx *oz_cdev_claim_ctx(struct oz_pd *pd) { struct oz_serial_ctx *ctx; + spin_lock_bh(&pd->app_lock[OZ_APPID_SERIAL-1]); ctx = (struct oz_serial_ctx *)pd->app_ctx[OZ_APPID_SERIAL-1]; if (ctx) @@ -202,6 +203,7 @@ static int oz_set_active_pd(const u8 *addr) int rc = 0; struct oz_pd *pd; struct oz_pd *old_pd; + pd = oz_pd_find(addr); if (pd) { spin_lock_bh(&g_cdev.lock); @@ -234,6 +236,7 @@ static long oz_cdev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { int rc = 0; + if (_IOC_TYPE(cmd) != OZ_IOCTL_MAGIC) return -ENOTTY; if (_IOC_NR(cmd) > OZ_IOCTL_MAX) @@ -300,6 +303,7 @@ static unsigned int oz_cdev_poll(struct file *filp, poll_table *wait) { unsigned int ret = 0; struct oz_cdev *dev = filp->private_data; + oz_dbg(ON, "Poll called wait = %p\n", wait); spin_lock_bh(&dev->lock); if (dev->active_pd) { @@ -405,6 +409,7 @@ int oz_cdev_start(struct oz_pd *pd, int resume) { struct oz_serial_ctx *ctx; struct oz_serial_ctx *old_ctx; + if (resume) { oz_dbg(ON, "Serial service resumed\n"); return 0; @@ -440,6 +445,7 @@ int oz_cdev_start(struct oz_pd *pd, int resume) void oz_cdev_stop(struct oz_pd *pd, int pause) { struct oz_serial_ctx *ctx; + if (pause) { oz_dbg(ON, "Serial service paused\n"); return; diff --git a/drivers/staging/ozwpan/ozeltbuf.c b/drivers/staging/ozwpan/ozeltbuf.c index 5e98aeb8bc6bf..0b8b46851f9f7 100644 --- a/drivers/staging/ozwpan/ozeltbuf.c +++ b/drivers/staging/ozwpan/ozeltbuf.c @@ -35,6 +35,7 @@ void oz_elt_buf_term(struct oz_elt_buf *buf) { struct list_head *e; int i; + /* Free any elements in the order or isoc lists. */ for (i = 0; i < 2; i++) { struct list_head *list; @@ -65,6 +66,7 @@ void oz_elt_buf_term(struct oz_elt_buf *buf) struct oz_elt_info *oz_elt_info_alloc(struct oz_elt_buf *buf) { struct oz_elt_info *ei = NULL; + spin_lock_bh(&buf->lock); if (buf->free_elts && buf->elt_pool) { ei = container_of(buf->elt_pool, struct oz_elt_info, link); @@ -115,6 +117,7 @@ void oz_elt_info_free(struct oz_elt_buf *buf, struct oz_elt_info *ei) void oz_elt_info_free_chain(struct oz_elt_buf *buf, struct list_head *list) { struct list_head *e; + e = list->next; spin_lock_bh(&buf->lock); while (e != list) { @@ -151,6 +154,7 @@ int oz_elt_stream_delete(struct oz_elt_buf *buf, u8 id) { struct list_head *e; struct oz_elt_stream *st = NULL; + oz_dbg(ON, "%s: (0x%x)\n", __func__, id); spin_lock_bh(&buf->lock); e = buf->stream_list.next; @@ -208,6 +212,7 @@ int oz_queue_elt_info(struct oz_elt_buf *buf, u8 isoc, u8 id, { struct oz_elt_stream *st = NULL; struct list_head *e; + if (id) { list_for_each(e, &buf->stream_list) { st = container_of(e, struct oz_elt_stream, link); @@ -269,6 +274,7 @@ int oz_select_elts_for_tx(struct oz_elt_buf *buf, u8 isoc, unsigned *len, struct list_head *e; struct list_head *el; struct oz_elt_info *ei; + spin_lock_bh(&buf->lock); if (isoc) el = &buf->isoc_list; @@ -317,6 +323,7 @@ void oz_trim_elt_pool(struct oz_elt_buf *buf) { struct list_head *free = NULL; struct list_head *e; + spin_lock_bh(&buf->lock); while (buf->free_elts > buf->max_free_elts) { e = buf->elt_pool; diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c index f38d0365bddef..8ec125ced3176 100644 --- a/drivers/staging/ozwpan/ozhcd.c +++ b/drivers/staging/ozwpan/ozhcd.c @@ -238,6 +238,7 @@ static inline struct oz_hcd *oz_hcd_private(struct usb_hcd *hcd) static int oz_get_port_from_addr(struct oz_hcd *ozhcd, u8 bus_addr) { int i; + for (i = 0; i < OZ_NB_PORTS; i++) { if (ozhcd->ports[i].bus_addr == bus_addr) return i; @@ -252,6 +253,7 @@ static struct oz_urb_link *oz_alloc_urb_link(void) { struct oz_urb_link *urbl = NULL; unsigned long irq_state; + spin_lock_irqsave(&g_link_lock, irq_state); if (g_link_pool) { urbl = container_of(g_link_pool, struct oz_urb_link, link); @@ -291,6 +293,7 @@ static void oz_empty_link_pool(void) { struct list_head *e; unsigned long irq_state; + spin_lock_irqsave(&g_link_lock, irq_state); e = g_link_pool; g_link_pool = NULL; @@ -332,6 +335,7 @@ static struct oz_urb_link *oz_uncancel_urb(struct oz_hcd *ozhcd, struct urb *urb { struct oz_urb_link *urbl; struct list_head *e; + list_for_each(e, &ozhcd->urb_cancel_list) { urbl = container_of(e, struct oz_urb_link, link); if (urb == urbl->urb) { @@ -352,6 +356,7 @@ static void oz_complete_urb(struct usb_hcd *hcd, struct urb *urb, struct oz_hcd *ozhcd = oz_hcd_private(hcd); unsigned long irq_state; struct oz_urb_link *cancel_urbl = NULL; + spin_lock_irqsave(&g_tasklet_lock, irq_state); usb_hcd_unlink_urb_from_ep(hcd, urb); /* Clear hcpriv which will prevent it being put in the cancel list @@ -455,6 +460,7 @@ static int oz_enqueue_ep_urb(struct oz_port *port, u8 ep_addr, int in_dir, struct oz_urb_link *urbl; struct oz_endpoint *ep; int err = 0; + if (ep_addr >= OZ_NB_ENDPOINTS) { oz_dbg(ON, "%s: Invalid endpoint number\n", __func__); return -EINVAL; @@ -525,6 +531,7 @@ static int oz_dequeue_ep_urb(struct oz_port *port, u8 ep_addr, int in_dir, { struct oz_urb_link *urbl = NULL; struct oz_endpoint *ep; + spin_lock_bh(&port->ozhcd->hcd_lock); if (in_dir) ep = port->in_ep[ep_addr]; @@ -598,6 +605,7 @@ static void oz_acquire_port(struct oz_port *port, void *hpd) static struct oz_hcd *oz_hcd_claim(void) { struct oz_hcd *ozhcd; + spin_lock_bh(&g_hcdlock); ozhcd = g_ozhcd; if (ozhcd) @@ -631,6 +639,7 @@ void *oz_hcd_pd_arrived(void *hpd) void *hport = NULL; struct oz_hcd *ozhcd = NULL; struct oz_endpoint *ep; + ozhcd = oz_hcd_claim(); if (ozhcd == NULL) return NULL; @@ -742,6 +751,7 @@ void oz_hcd_pd_reset(void *hpd, void *hport) */ struct oz_port *port = (struct oz_port *)hport; struct oz_hcd *ozhcd = port->ozhcd; + oz_dbg(ON, "PD Reset\n"); spin_lock_bh(&port->port_lock); port->flags |= OZ_PORT_F_CHANGED; @@ -846,6 +856,7 @@ static void oz_hcd_complete_set_config(struct oz_port *port, struct urb *urb, { int rc = 0; struct usb_hcd *hcd = port->ozhcd->hcd; + if (rcode == 0) { port->config_num = config_num; oz_clean_endpoints_for_config(hcd, port); @@ -866,6 +877,7 @@ static void oz_hcd_complete_set_interface(struct oz_port *port, struct urb *urb, { struct usb_hcd *hcd = port->ozhcd->hcd; int rc = 0; + if (rcode == 0) { struct usb_host_config *config; struct usb_host_interface *intf; @@ -943,6 +955,7 @@ static int oz_hcd_buffer_data(struct oz_endpoint *ep, const u8 *data, { int space; int copy_len; + if (!ep->buffer) return -1; space = ep->out_ix-ep->in_ix-1; @@ -979,6 +992,7 @@ void oz_hcd_data_ind(void *hport, u8 endpoint, const u8 *data, int data_len) struct oz_port *port = (struct oz_port *)hport; struct oz_endpoint *ep; struct oz_hcd *ozhcd = port->ozhcd; + spin_lock_bh(&ozhcd->hcd_lock); ep = port->in_ep[endpoint & USB_ENDPOINT_NUMBER_MASK]; if (ep == NULL) @@ -1038,6 +1052,7 @@ int oz_hcd_heartbeat(void *hport) struct urb *urb; struct oz_endpoint *ep; struct timespec ts, delta; + getrawmonotonic(&ts); INIT_LIST_HEAD(&xfr_list); /* Check the OUT isoc endpoints to see if any URB data can be sent. @@ -1193,6 +1208,7 @@ static int oz_build_endpoints_for_interface(struct usb_hcd *hcd, int i; int if_ix = intf->desc.bInterfaceNumber; int request_heartbeat = 0; + oz_dbg(ON, "interface[%d] = %p\n", if_ix, intf); for (i = 0; i < intf->desc.bNumEndpoints; i++) { struct usb_host_endpoint *hep = &intf->endpoint[i]; @@ -1314,6 +1330,7 @@ static int oz_build_endpoints_for_config(struct usb_hcd *hcd, struct oz_hcd *ozhcd = port->ozhcd; int i; int num_iface = config->desc.bNumInterfaces; + if (num_iface) { struct oz_interface *iface; @@ -1346,6 +1363,7 @@ static void oz_clean_endpoints_for_config(struct usb_hcd *hcd, { struct oz_hcd *ozhcd = port->ozhcd; int i; + oz_dbg(ON, "Deleting endpoints for configuration\n"); for (i = 0; i < port->num_iface; i++) oz_clean_endpoints_for_interface(hcd, port, i); @@ -1365,6 +1383,7 @@ static void *oz_claim_hpd(struct oz_port *port) { void *hpd = NULL; struct oz_hcd *ozhcd = port->ozhcd; + spin_lock_bh(&ozhcd->hcd_lock); hpd = port->hpd; if (hpd) @@ -1526,6 +1545,7 @@ static int oz_urb_process(struct oz_hcd *ozhcd, struct urb *urb) int rc = 0; struct oz_port *port = urb->hcpriv; u8 ep_addr; + /* When we are paranoid we keep a list of urbs which we check against * before handing one back. This is just for debugging during * development and should be turned off in the released driver. @@ -1560,6 +1580,7 @@ static void oz_urb_process_tasklet(unsigned long unused) struct urb *urb; struct oz_hcd *ozhcd = oz_hcd_claim(); int rc = 0; + if (ozhcd == NULL) return; /* This is called from a tasklet so is in softirq context but the urb @@ -1599,6 +1620,7 @@ static void oz_urb_cancel(struct oz_port *port, u8 ep_num, struct urb *urb) struct oz_hcd *ozhcd; unsigned long irq_state; u8 ix; + if (port == NULL) { oz_dbg(ON, "%s: ERROR: (%p) port is null\n", __func__, urb); return; @@ -1657,6 +1679,7 @@ static void oz_urb_cancel_tasklet(unsigned long unused) unsigned long irq_state; struct urb *urb; struct oz_hcd *ozhcd = oz_hcd_claim(); + if (ozhcd == NULL) return; spin_lock_irqsave(&g_tasklet_lock, irq_state); @@ -1728,6 +1751,7 @@ static int oz_hcd_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, struct oz_port *port; unsigned long irq_state; struct oz_urb_link *urbl; + oz_dbg(URB, "%s: (%p)\n", __func__, urb); if (unlikely(ozhcd == NULL)) { oz_dbg(URB, "Refused urb(%p) not ozhcd\n", urb); @@ -1776,6 +1800,7 @@ static struct oz_urb_link *oz_remove_urb(struct oz_endpoint *ep, { struct oz_urb_link *urbl = NULL; struct list_head *e; + if (unlikely(ep == NULL)) return NULL; list_for_each(e, &ep->urb_list) { @@ -1802,6 +1827,7 @@ static int oz_hcd_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) struct oz_urb_link *urbl = NULL; int rc; unsigned long irq_state; + oz_dbg(URB, "%s: (%p)\n", __func__, urb); urbl = oz_alloc_urb_link(); if (unlikely(urbl == NULL)) @@ -2054,6 +2080,7 @@ static int oz_get_port_status(struct usb_hcd *hcd, u16 windex, char *buf) { struct oz_hcd *ozhcd; u32 status = 0; + if ((windex < 1) || (windex > OZ_NB_PORTS)) return -EPIPE; ozhcd = oz_hcd_private(hcd); @@ -2222,6 +2249,7 @@ static int oz_plat_resume(struct platform_device *dev) int oz_hcd_init(void) { int err; + if (usb_disabled()) return -ENODEV; tasklet_init(&g_urb_process_tasklet, oz_urb_process_tasklet, 0); diff --git a/drivers/staging/ozwpan/ozpd.c b/drivers/staging/ozwpan/ozpd.c index 17fd7b2aa88e4..14fea77459b72 100644 --- a/drivers/staging/ozwpan/ozpd.c +++ b/drivers/staging/ozwpan/ozpd.c @@ -157,6 +157,7 @@ void oz_pd_put(struct oz_pd *pd) struct oz_pd *oz_pd_alloc(const u8 *mac_addr) { struct oz_pd *pd = kzalloc(sizeof(struct oz_pd), GFP_ATOMIC); + if (pd) { int i; atomic_set(&pd->ref_count, 2); @@ -196,6 +197,7 @@ void oz_pd_destroy(struct oz_pd *pd) struct oz_tx_frame *f; struct oz_isoc_stream *st; struct oz_farewell *fwell; + oz_pd_dbg(pd, ON, "Destroying PD\n"); if (hrtimer_active(&pd->timeout)) hrtimer_cancel(&pd->timeout); @@ -249,6 +251,7 @@ int oz_services_start(struct oz_pd *pd, u16 apps, int resume) { const struct oz_app_if *ai; int rc = 0; + oz_pd_dbg(pd, ON, "%s: (0x%x) resume(%d)\n", __func__, apps, resume); for (ai = g_app_if; ai < &g_app_if[OZ_APPID_MAX]; ai++) { if (apps & (1<app_id)) { @@ -274,6 +277,7 @@ int oz_services_start(struct oz_pd *pd, u16 apps, int resume) void oz_services_stop(struct oz_pd *pd, u16 apps, int pause) { const struct oz_app_if *ai; + oz_pd_dbg(pd, ON, "%s: (0x%x) pause(%d)\n", __func__, apps, pause); for (ai = g_app_if; ai < &g_app_if[OZ_APPID_MAX]; ai++) { if (apps & (1<app_id)) { @@ -296,6 +300,7 @@ void oz_pd_heartbeat(struct oz_pd *pd, u16 apps) { const struct oz_app_if *ai; int more = 0; + for (ai = g_app_if; ai < &g_app_if[OZ_APPID_MAX]; ai++) { if (ai->heartbeat && (apps & (1<app_id))) { if (ai->heartbeat(pd)) @@ -316,6 +321,7 @@ void oz_pd_heartbeat(struct oz_pd *pd, u16 apps) void oz_pd_stop(struct oz_pd *pd) { u16 stop_apps = 0; + oz_dbg(ON, "oz_pd_stop() State = 0x%x\n", pd->state); oz_pd_indicate_farewells(pd); oz_polling_lock_bh(); @@ -339,6 +345,7 @@ int oz_pd_sleep(struct oz_pd *pd) { int do_stop = 0; u16 stop_apps = 0; + oz_polling_lock_bh(); if (pd->state & (OZ_PD_S_SLEEP | OZ_PD_S_STOPPED)) { oz_polling_unlock_bh(); @@ -365,6 +372,7 @@ int oz_pd_sleep(struct oz_pd *pd) static struct oz_tx_frame *oz_tx_frame_alloc(struct oz_pd *pd) { struct oz_tx_frame *f = NULL; + spin_lock_bh(&pd->tx_frame_lock); if (pd->tx_pool) { f = container_of(pd->tx_pool, struct oz_tx_frame, link); @@ -419,6 +427,7 @@ static void oz_tx_frame_free(struct oz_pd *pd, struct oz_tx_frame *f) static void oz_set_more_bit(struct sk_buff *skb) { struct oz_hdr *oz_hdr = (struct oz_hdr *)skb_network_header(skb); + oz_hdr->control |= OZ_F_MORE_DATA; } /*------------------------------------------------------------------------------ @@ -427,6 +436,7 @@ static void oz_set_more_bit(struct sk_buff *skb) static void oz_set_last_pkt_nb(struct oz_pd *pd, struct sk_buff *skb) { struct oz_hdr *oz_hdr = (struct oz_hdr *)skb_network_header(skb); + oz_hdr->last_pkt_num = pd->trigger_pkt_num & OZ_LAST_PN_MASK; } /*------------------------------------------------------------------------------ @@ -435,6 +445,7 @@ static void oz_set_last_pkt_nb(struct oz_pd *pd, struct sk_buff *skb) int oz_prepare_frame(struct oz_pd *pd, int empty) { struct oz_tx_frame *f; + if ((pd->mode & OZ_MODE_MASK) != OZ_MODE_TRIGGERED) return -1; if (pd->nb_queued_frames >= OZ_MAX_QUEUED_FRAMES) @@ -469,6 +480,7 @@ static struct sk_buff *oz_build_frame(struct oz_pd *pd, struct oz_tx_frame *f) struct oz_hdr *oz_hdr; struct oz_elt *elt; struct list_head *e; + /* Allocate skb with enough space for the lower layers as well * as the space we need. */ @@ -510,6 +522,7 @@ static void oz_retire_frame(struct oz_pd *pd, struct oz_tx_frame *f) { struct list_head *e; struct oz_elt_info *ei; + e = f->elt_list.next; while (e != &f->elt_list) { ei = container_of(e, struct oz_elt_info, link); @@ -533,6 +546,7 @@ static int oz_send_next_queued_frame(struct oz_pd *pd, int more_data) struct sk_buff *skb; struct oz_tx_frame *f; struct list_head *e; + spin_lock(&pd->tx_frame_lock); e = pd->last_sent_frame->next; if (e == &pd->tx_queue) { @@ -628,6 +642,7 @@ static int oz_send_isoc_frame(struct oz_pd *pd) struct list_head *e; struct list_head list; int total_size = sizeof(struct oz_hdr); + INIT_LIST_HEAD(&list); oz_select_elts_for_tx(&pd->elt_buff, 1, &total_size, @@ -713,6 +728,7 @@ static struct oz_isoc_stream *pd_stream_find(struct oz_pd *pd, u8 ep_num) { struct list_head *e; struct oz_isoc_stream *st; + list_for_each(e, &pd->stream_list) { st = container_of(e, struct oz_isoc_stream, link); if (st->ep_num == ep_num) @@ -753,6 +769,7 @@ static void oz_isoc_stream_free(struct oz_isoc_stream *st) int oz_isoc_stream_delete(struct oz_pd *pd, u8 ep_num) { struct oz_isoc_stream *st; + spin_lock_bh(&pd->stream_lock); st = pd_stream_find(pd, ep_num); if (st) @@ -780,6 +797,7 @@ int oz_send_isoc_unit(struct oz_pd *pd, u8 ep_num, const u8 *data, int len) struct sk_buff *skb = NULL; struct oz_hdr *oz_hdr = NULL; int size = 0; + spin_lock_bh(&pd->stream_lock); st = pd_stream_find(pd, ep_num); if (st) { @@ -895,6 +913,7 @@ out: kfree_skb(skb); void oz_apps_init(void) { int i; + for (i = 0; i < OZ_APPID_MAX; i++) if (g_app_if[i].init) g_app_if[i].init(); @@ -905,6 +924,7 @@ void oz_apps_init(void) void oz_apps_term(void) { int i; + /* Terminate all the apps. */ for (i = 0; i < OZ_APPID_MAX; i++) if (g_app_if[i].term) @@ -916,6 +936,7 @@ void oz_apps_term(void) void oz_handle_app_elt(struct oz_pd *pd, u8 app_id, struct oz_elt *elt) { const struct oz_app_if *ai; + if (app_id == 0 || app_id > OZ_APPID_MAX) return; ai = &g_app_if[app_id-1]; @@ -928,6 +949,7 @@ void oz_pd_indicate_farewells(struct oz_pd *pd) { struct oz_farewell *f; const struct oz_app_if *ai = &g_app_if[OZ_APPID_USB-1]; + while (1) { oz_polling_lock_bh(); if (list_empty(&pd->farewell_list)) { diff --git a/drivers/staging/ozwpan/ozproto.c b/drivers/staging/ozwpan/ozproto.c index 3d1a89f073552..7072f538bd8d8 100644 --- a/drivers/staging/ozwpan/ozproto.c +++ b/drivers/staging/ozwpan/ozproto.c @@ -74,6 +74,7 @@ static void oz_send_conn_rsp(struct oz_pd *pd, u8 status) struct oz_hdr *oz_hdr; struct oz_elt *elt; struct oz_elt_connect_rsp *body; + int sz = sizeof(struct oz_hdr) + sizeof(struct oz_elt) + sizeof(struct oz_elt_connect_rsp); skb = alloc_skb(sz + OZ_ALLOCATED_SPACE(dev), GFP_ATOMIC); @@ -163,6 +164,7 @@ static struct oz_pd *oz_connect_req(struct oz_pd *cur_pd, struct oz_elt *elt, u16 new_apps = g_apps; struct net_device *old_net_dev = NULL; struct oz_pd *free_pd = NULL; + if (cur_pd) { pd = cur_pd; spin_lock_bh(&g_polling_lock); @@ -291,6 +293,7 @@ static void oz_add_farewell(struct oz_pd *pd, u8 ep_num, u8 index, struct oz_farewell *f; struct oz_farewell *f2; int found = 0; + f = kmalloc(sizeof(struct oz_farewell) + len, GFP_ATOMIC); if (!f) return; @@ -477,6 +480,7 @@ void oz_pd_heartbeat_handler(unsigned long data) { struct oz_pd *pd = (struct oz_pd *)data; u16 apps = 0; + spin_lock_bh(&g_polling_lock); if (pd->state & OZ_PD_S_CONNECTED) apps = pd->total_apps; @@ -574,6 +578,7 @@ struct oz_pd *oz_pd_find(const u8 *mac_addr) { struct oz_pd *pd; struct list_head *e; + spin_lock_bh(&g_polling_lock); list_for_each(e, &g_pd_list) { pd = container_of(e, struct oz_pd, link); @@ -675,6 +680,7 @@ static void pd_stop_all_for_device(struct net_device *net_dev) struct list_head h; struct oz_pd *pd; struct oz_pd *n; + INIT_LIST_HEAD(&h); spin_lock_bh(&g_polling_lock); list_for_each_entry_safe(pd, n, &g_pd_list, link) { @@ -758,6 +764,7 @@ int oz_get_pd_list(struct oz_mac_addr *addr, int max_count) struct oz_pd *pd; struct list_head *e; int count = 0; + spin_lock_bh(&g_polling_lock); list_for_each(e, &g_pd_list) { if (count >= max_count) diff --git a/drivers/staging/ozwpan/ozurbparanoia.c b/drivers/staging/ozwpan/ozurbparanoia.c index d69e8ab9db9a3..6aab9a7fc9f88 100644 --- a/drivers/staging/ozwpan/ozurbparanoia.c +++ b/drivers/staging/ozwpan/ozurbparanoia.c @@ -21,6 +21,7 @@ DEFINE_SPINLOCK(g_urb_mem_lock); void oz_remember_urb(struct urb *urb) { unsigned long irq_state; + spin_lock_irqsave(&g_urb_mem_lock, irq_state); if (g_nb_urbs < OZ_MAX_URBS) { g_urb_memory[g_nb_urbs++] = urb; @@ -37,6 +38,7 @@ int oz_forget_urb(struct urb *urb) unsigned long irq_state; int i; int rc = -1; + spin_lock_irqsave(&g_urb_mem_lock, irq_state); for (i = 0; i < g_nb_urbs; i++) { if (g_urb_memory[i] == urb) { diff --git a/drivers/staging/ozwpan/ozusbsvc.c b/drivers/staging/ozwpan/ozusbsvc.c index 732face55e8ca..ab9db8cb30e25 100644 --- a/drivers/staging/ozwpan/ozusbsvc.c +++ b/drivers/staging/ozwpan/ozusbsvc.c @@ -53,6 +53,7 @@ int oz_usb_start(struct oz_pd *pd, int resume) int rc = 0; struct oz_usb_ctx *usb_ctx; struct oz_usb_ctx *old_ctx; + if (resume) { oz_dbg(ON, "USB service resumed\n"); return 0; @@ -114,6 +115,7 @@ int oz_usb_start(struct oz_pd *pd, int resume) void oz_usb_stop(struct oz_pd *pd, int pause) { struct oz_usb_ctx *usb_ctx; + if (pause) { oz_dbg(ON, "USB service paused\n"); return; @@ -154,6 +156,7 @@ void oz_usb_stop(struct oz_pd *pd, int pause) void oz_usb_get(void *hpd) { struct oz_usb_ctx *usb_ctx = (struct oz_usb_ctx *)hpd; + atomic_inc(&usb_ctx->ref_count); } /*------------------------------------------------------------------------------ @@ -164,6 +167,7 @@ void oz_usb_get(void *hpd) void oz_usb_put(void *hpd) { struct oz_usb_ctx *usb_ctx = (struct oz_usb_ctx *)hpd; + if (atomic_dec_and_test(&usb_ctx->ref_count)) { oz_dbg(ON, "Dealloc USB context\n"); oz_pd_put(usb_ctx->pd); @@ -177,6 +181,7 @@ int oz_usb_heartbeat(struct oz_pd *pd) { struct oz_usb_ctx *usb_ctx; int rc = 0; + spin_lock_bh(&pd->app_lock[OZ_APPID_USB-1]); usb_ctx = (struct oz_usb_ctx *)pd->app_ctx[OZ_APPID_USB-1]; if (usb_ctx) @@ -200,6 +205,7 @@ int oz_usb_stream_create(void *hpd, u8 ep_num) { struct oz_usb_ctx *usb_ctx = (struct oz_usb_ctx *)hpd; struct oz_pd *pd = usb_ctx->pd; + oz_dbg(ON, "%s: (0x%x)\n", __func__, ep_num); if (pd->mode & OZ_F_ISOC_NO_ELTS) { oz_isoc_stream_create(pd, ep_num); @@ -219,6 +225,7 @@ int oz_usb_stream_create(void *hpd, u8 ep_num) int oz_usb_stream_delete(void *hpd, u8 ep_num) { struct oz_usb_ctx *usb_ctx = (struct oz_usb_ctx *)hpd; + if (usb_ctx) { struct oz_pd *pd = usb_ctx->pd; if (pd) { @@ -240,6 +247,7 @@ int oz_usb_stream_delete(void *hpd, u8 ep_num) void oz_usb_request_heartbeat(void *hpd) { struct oz_usb_ctx *usb_ctx = (struct oz_usb_ctx *)hpd; + if (usb_ctx && usb_ctx->pd) oz_pd_request_heartbeat(usb_ctx->pd); } diff --git a/drivers/staging/ozwpan/ozusbsvc1.c b/drivers/staging/ozwpan/ozusbsvc1.c index 50d21bf4f927b..34133efddb429 100644 --- a/drivers/staging/ozwpan/ozusbsvc1.c +++ b/drivers/staging/ozwpan/ozusbsvc1.c @@ -33,6 +33,7 @@ static int oz_usb_submit_elt(struct oz_elt_buf *eb, struct oz_elt_info *ei, int ret; struct oz_elt *elt = (struct oz_elt *)ei->data; struct oz_app_hdr *app_hdr = (struct oz_app_hdr *)(elt+1); + elt->type = OZ_ELT_APP_DATA; ei->app_id = OZ_APPID_USB; ei->length = elt->length + sizeof(struct oz_elt); @@ -61,6 +62,7 @@ int oz_usb_get_desc_req(void *hpd, u8 req_id, u8 req_type, u8 desc_type, struct oz_get_desc_req *body; struct oz_elt_buf *eb = &pd->elt_buff; struct oz_elt_info *ei = oz_elt_info_alloc(&pd->elt_buff); + oz_dbg(ON, " req_type = 0x%x\n", req_type); oz_dbg(ON, " desc_type = 0x%x\n", desc_type); oz_dbg(ON, " index = 0x%x\n", index); @@ -95,6 +97,7 @@ static int oz_usb_set_config_req(void *hpd, u8 req_id, u8 index) struct oz_elt_buf *eb = &pd->elt_buff; struct oz_elt_info *ei = oz_elt_info_alloc(&pd->elt_buff); struct oz_set_config_req *body; + if (ei == NULL) return -1; elt = (struct oz_elt *)ei->data; @@ -116,6 +119,7 @@ static int oz_usb_set_interface_req(void *hpd, u8 req_id, u8 index, u8 alt) struct oz_elt_buf *eb = &pd->elt_buff; struct oz_elt_info *ei = oz_elt_info_alloc(&pd->elt_buff); struct oz_set_interface_req *body; + if (ei == NULL) return -1; elt = (struct oz_elt *)ei->data; @@ -139,6 +143,7 @@ static int oz_usb_set_clear_feature_req(void *hpd, u8 req_id, u8 type, struct oz_elt_buf *eb = &pd->elt_buff; struct oz_elt_info *ei = oz_elt_info_alloc(&pd->elt_buff); struct oz_feature_req *body; + if (ei == NULL) return -1; elt = (struct oz_elt *)ei->data; @@ -163,6 +168,7 @@ static int oz_usb_vendor_class_req(void *hpd, u8 req_id, u8 req_type, struct oz_elt_buf *eb = &pd->elt_buff; struct oz_elt_info *ei = oz_elt_info_alloc(&pd->elt_buff); struct oz_vendor_class_req *body; + if (ei == NULL) return -1; elt = (struct oz_elt *)ei->data; @@ -188,6 +194,7 @@ int oz_usb_control_req(void *hpd, u8 req_id, struct usb_ctrlrequest *setup, unsigned windex = le16_to_cpu(setup->wIndex); unsigned wlength = le16_to_cpu(setup->wLength); int rc = 0; + if ((setup->bRequestType & USB_TYPE_MASK) == USB_TYPE_STANDARD) { switch (setup->bRequest) { case USB_REQ_GET_DESCRIPTOR: @@ -303,6 +310,7 @@ static void oz_usb_handle_ep_data(struct oz_usb_ctx *usb_ctx, struct oz_usb_hdr *usb_hdr, int len) { struct oz_data *data_hdr = (struct oz_data *)usb_hdr; + switch (data_hdr->format) { case OZ_DATA_F_MULTIPLE_FIXED: { struct oz_multiple_fixed *body = @@ -416,6 +424,7 @@ void oz_usb_rx(struct oz_pd *pd, struct oz_elt *elt) void oz_usb_farewell(struct oz_pd *pd, u8 ep_num, u8 *data, u8 len) { struct oz_usb_ctx *usb_ctx; + spin_lock_bh(&pd->app_lock[OZ_APPID_USB-1]); usb_ctx = (struct oz_usb_ctx *)pd->app_ctx[OZ_APPID_USB-1]; if (usb_ctx) -- GitLab From 6e244a8319ab80acdda424795e85687fb6af0be2 Mon Sep 17 00:00:00 2001 From: Rupesh Gujare Date: Tue, 13 Aug 2013 18:24:22 +0100 Subject: [PATCH 624/942] staging: ozwpan: Add a blank line between functions & declarations. This patch adds a blank line between global declarations & functions for readability. Signed-off-by: Rupesh Gujare Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozcdev.c | 17 +++++++ drivers/staging/ozwpan/ozeltbuf.c | 12 +++++ drivers/staging/ozwpan/ozhcd.c | 68 ++++++++++++++++++++++++++ drivers/staging/ozwpan/ozmain.c | 3 ++ drivers/staging/ozwpan/ozpd.c | 40 +++++++++++++++ drivers/staging/ozwpan/ozproto.c | 26 ++++++++++ drivers/staging/ozwpan/ozurbparanoia.c | 2 + drivers/staging/ozwpan/ozusbsvc.c | 9 ++++ drivers/staging/ozwpan/ozusbsvc1.c | 12 +++++ 9 files changed, 189 insertions(+) diff --git a/drivers/staging/ozwpan/ozcdev.c b/drivers/staging/ozwpan/ozcdev.c index 0c79fd0105553..01673d4d5c4c3 100644 --- a/drivers/staging/ozwpan/ozcdev.c +++ b/drivers/staging/ozwpan/ozcdev.c @@ -43,6 +43,7 @@ struct oz_serial_ctx { */ static struct oz_cdev g_cdev; static struct class *g_oz_class; + /*------------------------------------------------------------------------------ * Context: process and softirq */ @@ -57,6 +58,7 @@ static struct oz_serial_ctx *oz_cdev_claim_ctx(struct oz_pd *pd) spin_unlock_bh(&pd->app_lock[OZ_APPID_SERIAL-1]); return ctx; } + /*------------------------------------------------------------------------------ * Context: softirq or process */ @@ -67,6 +69,7 @@ static void oz_cdev_release_ctx(struct oz_serial_ctx *ctx) kfree(ctx); } } + /*------------------------------------------------------------------------------ * Context: process */ @@ -79,6 +82,7 @@ static int oz_cdev_open(struct inode *inode, struct file *filp) filp->private_data = dev; return 0; } + /*------------------------------------------------------------------------------ * Context: process */ @@ -86,6 +90,7 @@ static int oz_cdev_release(struct inode *inode, struct file *filp) { return 0; } + /*------------------------------------------------------------------------------ * Context: process */ @@ -138,6 +143,7 @@ static ssize_t oz_cdev_read(struct file *filp, char __user *buf, size_t count, oz_pd_put(pd); return count; } + /*------------------------------------------------------------------------------ * Context: process */ @@ -195,6 +201,7 @@ static ssize_t oz_cdev_write(struct file *filp, const char __user *buf, oz_pd_put(pd); return count; } + /*------------------------------------------------------------------------------ * Context: process */ @@ -229,6 +236,7 @@ static int oz_set_active_pd(const u8 *addr) } return rc; } + /*------------------------------------------------------------------------------ * Context: process */ @@ -296,6 +304,7 @@ static long oz_cdev_ioctl(struct file *filp, unsigned int cmd, } return rc; } + /*------------------------------------------------------------------------------ * Context: process */ @@ -319,6 +328,7 @@ static unsigned int oz_cdev_poll(struct file *filp, poll_table *wait) poll_wait(filp, &dev->rdq, wait); return ret; } + /*------------------------------------------------------------------------------ */ static const struct file_operations oz_fops = { @@ -330,6 +340,7 @@ static const struct file_operations oz_fops = { .unlocked_ioctl = oz_cdev_ioctl, .poll = oz_cdev_poll }; + /*------------------------------------------------------------------------------ * Context: process */ @@ -374,6 +385,7 @@ int oz_cdev_register(void) unregister_chrdev_region(g_cdev.devnum, 1); return err; } + /*------------------------------------------------------------------------------ * Context: process */ @@ -387,6 +399,7 @@ int oz_cdev_deregister(void) } return 0; } + /*------------------------------------------------------------------------------ * Context: process */ @@ -395,6 +408,7 @@ int oz_cdev_init(void) oz_app_enable(OZ_APPID_SERIAL, 1); return 0; } + /*------------------------------------------------------------------------------ * Context: process */ @@ -402,6 +416,7 @@ void oz_cdev_term(void) { oz_app_enable(OZ_APPID_SERIAL, 0); } + /*------------------------------------------------------------------------------ * Context: softirq-serialized */ @@ -439,6 +454,7 @@ int oz_cdev_start(struct oz_pd *pd, int resume) oz_dbg(ON, "Serial service started\n"); return 0; } + /*------------------------------------------------------------------------------ * Context: softirq or process */ @@ -468,6 +484,7 @@ void oz_cdev_stop(struct oz_pd *pd, int pause) } oz_dbg(ON, "Serial service stopped\n"); } + /*------------------------------------------------------------------------------ * Context: softirq-serialized */ diff --git a/drivers/staging/ozwpan/ozeltbuf.c b/drivers/staging/ozwpan/ozeltbuf.c index 0b8b46851f9f7..4844d9f3cfe57 100644 --- a/drivers/staging/ozwpan/ozeltbuf.c +++ b/drivers/staging/ozwpan/ozeltbuf.c @@ -28,6 +28,7 @@ int oz_elt_buf_init(struct oz_elt_buf *buf) spin_lock_init(&buf->lock); return 0; } + /*------------------------------------------------------------------------------ * Context: softirq or process */ @@ -60,6 +61,7 @@ void oz_elt_buf_term(struct oz_elt_buf *buf) } buf->free_elts = 0; } + /*------------------------------------------------------------------------------ * Context: softirq or process */ @@ -93,6 +95,7 @@ struct oz_elt_info *oz_elt_info_alloc(struct oz_elt_buf *buf) } return ei; } + /*------------------------------------------------------------------------------ * Precondition: oz_elt_buf.lock must be held. * Context: softirq or process @@ -111,6 +114,7 @@ void oz_elt_info_free(struct oz_elt_buf *buf, struct oz_elt_info *ei) } } } + /*------------------------------------------------------------------------------ * Context: softirq */ @@ -128,6 +132,7 @@ void oz_elt_info_free_chain(struct oz_elt_buf *buf, struct list_head *list) } spin_unlock_bh(&buf->lock); } + /*------------------------------------------------------------------------------ */ int oz_elt_stream_create(struct oz_elt_buf *buf, u8 id, int max_buf_count) @@ -148,6 +153,7 @@ int oz_elt_stream_create(struct oz_elt_buf *buf, u8 id, int max_buf_count) spin_unlock_bh(&buf->lock); return 0; } + /*------------------------------------------------------------------------------ */ int oz_elt_stream_delete(struct oz_elt_buf *buf, u8 id) @@ -187,12 +193,14 @@ int oz_elt_stream_delete(struct oz_elt_buf *buf, u8 id) oz_elt_stream_put(st); return 0; } + /*------------------------------------------------------------------------------ */ void oz_elt_stream_get(struct oz_elt_stream *st) { atomic_inc(&st->ref_count); } + /*------------------------------------------------------------------------------ */ void oz_elt_stream_put(struct oz_elt_stream *st) @@ -202,6 +210,7 @@ void oz_elt_stream_put(struct oz_elt_stream *st) kfree(st); } } + /*------------------------------------------------------------------------------ * Precondition: Element buffer lock must be held. * If this function fails the caller is responsible for deallocating the elt @@ -265,6 +274,7 @@ int oz_queue_elt_info(struct oz_elt_buf *buf, u8 isoc, u8 id, &buf->isoc_list : &buf->order_list); return 0; } + /*------------------------------------------------------------------------------ */ int oz_select_elts_for_tx(struct oz_elt_buf *buf, u8 isoc, unsigned *len, @@ -311,12 +321,14 @@ int oz_select_elts_for_tx(struct oz_elt_buf *buf, u8 isoc, unsigned *len, spin_unlock_bh(&buf->lock); return count; } + /*------------------------------------------------------------------------------ */ int oz_are_elts_available(struct oz_elt_buf *buf) { return buf->order_list.next != &buf->order_list; } + /*------------------------------------------------------------------------------ */ void oz_trim_elt_pool(struct oz_elt_buf *buf) diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c index 8ec125ced3176..5a417c833400d 100644 --- a/drivers/staging/ozwpan/ozhcd.c +++ b/drivers/staging/ozwpan/ozhcd.c @@ -34,23 +34,29 @@ #include "ozusbif.h" #include "ozurbparanoia.h" #include "ozhcd.h" + /*------------------------------------------------------------------------------ * Number of units of buffering to capture for an isochronous IN endpoint before * allowing data to be indicated up. */ #define OZ_IN_BUFFERING_UNITS 50 + /* Name of our platform device. */ #define OZ_PLAT_DEV_NAME "ozwpan" + /* Maximum number of free urb links that can be kept in the pool. */ #define OZ_MAX_LINK_POOL_SIZE 16 + /* Get endpoint object from the containing link. */ #define ep_from_link(__e) container_of((__e), struct oz_endpoint, link) + /*EP0 timeout before ep0 request is again added to TX queue. (13*8 = 98mSec) */ #define EP0_TIMEOUT_COUNTER 13 + /*------------------------------------------------------------------------------ * Used to link urbs together and also store some status information for each * urb. @@ -84,6 +90,7 @@ struct oz_endpoint { unsigned flags; int start_frame; }; + /* Bits in the flags field. */ #define OZ_F_EP_BUFFERING 0x1 #define OZ_F_EP_HAVE_STREAM 0x2 @@ -114,6 +121,7 @@ struct oz_port { struct list_head isoc_out_ep; struct list_head isoc_in_ep; }; + #define OZ_PORT_F_PRESENT 0x1 #define OZ_PORT_F_CHANGED 0x2 #define OZ_PORT_F_DYING 0x4 @@ -131,6 +139,7 @@ struct oz_hcd { uint flags; struct usb_hcd *hcd; }; + /* Bits in flags field. */ #define OZ_HDC_F_SUSPENDED 0x1 @@ -175,6 +184,7 @@ static void oz_process_ep0_urb(struct oz_hcd *ozhcd, struct urb *urb, static struct oz_urb_link *oz_remove_urb(struct oz_endpoint *ep, struct urb *urb); static void oz_hcd_clear_orphanage(struct oz_hcd *ozhcd, int status); + /*------------------------------------------------------------------------------ * Static external variables. */ @@ -220,6 +230,7 @@ static struct platform_driver g_oz_plat_drv = { .owner = THIS_MODULE, }, }; + /*------------------------------------------------------------------------------ * Gets our private context area (which is of type struct oz_hcd) from the * usb_hcd structure. @@ -229,6 +240,7 @@ static inline struct oz_hcd *oz_hcd_private(struct usb_hcd *hcd) { return (struct oz_hcd *)hcd->hcd_priv; } + /*------------------------------------------------------------------------------ * Searches list of ports to find the index of the one with a specified USB * bus address. If none of the ports has the bus address then the connection @@ -245,6 +257,7 @@ static int oz_get_port_from_addr(struct oz_hcd *ozhcd, u8 bus_addr) } return ozhcd->conn_port; } + /*------------------------------------------------------------------------------ * Allocates an urb link, first trying the pool but going to heap if empty. * Context: any @@ -265,6 +278,7 @@ static struct oz_urb_link *oz_alloc_urb_link(void) urbl = kmalloc(sizeof(struct oz_urb_link), GFP_ATOMIC); return urbl; } + /*------------------------------------------------------------------------------ * Frees an urb link by putting it in the pool if there is enough space or * deallocating it to heap otherwise. @@ -285,6 +299,7 @@ static void oz_free_urb_link(struct oz_urb_link *urbl) kfree(urbl); } } + /*------------------------------------------------------------------------------ * Deallocates all the urb links in the pool. * Context: unknown @@ -306,6 +321,7 @@ static void oz_empty_link_pool(void) kfree(urbl); } } + /*------------------------------------------------------------------------------ * Allocates endpoint structure and optionally a buffer. If a buffer is * allocated it immediately follows the endpoint structure. @@ -326,6 +342,7 @@ static struct oz_endpoint *oz_ep_alloc(gfp_t mem_flags, int buffer_size) } return ep; } + /*------------------------------------------------------------------------------ * Pre-condition: Must be called with g_tasklet_lock held and interrupts * disabled. @@ -345,6 +362,7 @@ static struct oz_urb_link *oz_uncancel_urb(struct oz_hcd *ozhcd, struct urb *urb } return NULL; } + /*------------------------------------------------------------------------------ * This is called when we have finished processing an urb. It unlinks it from * the ep and returns it to the core. @@ -388,6 +406,7 @@ static void oz_complete_urb(struct usb_hcd *hcd, struct urb *urb, if (cancel_urbl) oz_free_urb_link(cancel_urbl); } + /*------------------------------------------------------------------------------ * Deallocates an endpoint including deallocating any associated stream and * returning any queued urbs to the core. @@ -412,6 +431,7 @@ static void oz_ep_free(struct oz_port *port, struct oz_endpoint *ep) oz_dbg(ON, "Freeing endpoint memory\n"); kfree(ep); } + /*------------------------------------------------------------------------------ * Context: softirq */ @@ -521,6 +541,7 @@ static int oz_enqueue_ep_urb(struct oz_port *port, u8 ep_addr, int in_dir, oz_free_urb_link(urbl); return err; } + /*------------------------------------------------------------------------------ * Removes an urb from the queue in the endpoint. * Returns 0 if it is found and -EIDRM otherwise. @@ -553,6 +574,7 @@ static int oz_dequeue_ep_urb(struct oz_port *port, u8 ep_addr, int in_dir, oz_free_urb_link(urbl); return urbl ? 0 : -EIDRM; } + /*------------------------------------------------------------------------------ * Finds an urb given its request id. * Context: softirq @@ -585,6 +607,7 @@ static struct urb *oz_find_urb_by_id(struct oz_port *port, int ep_ix, oz_free_urb_link(urbl); return urb; } + /*------------------------------------------------------------------------------ * Pre-condition: Port lock must be held. * Context: softirq @@ -599,6 +622,7 @@ static void oz_acquire_port(struct oz_port *port, void *hpd) oz_usb_get(hpd); port->hpd = hpd; } + /*------------------------------------------------------------------------------ * Context: softirq */ @@ -613,6 +637,7 @@ static struct oz_hcd *oz_hcd_claim(void) spin_unlock_bh(&g_hcdlock); return ozhcd; } + /*------------------------------------------------------------------------------ * Context: softirq */ @@ -621,6 +646,7 @@ static inline void oz_hcd_put(struct oz_hcd *ozhcd) if (ozhcd) usb_put_hcd(ozhcd->hcd); } + /*------------------------------------------------------------------------------ * This is called by the protocol handler to notify that a PD has arrived. * We allocate a port to associate with the PD and create a structure for @@ -686,6 +712,7 @@ void *oz_hcd_pd_arrived(void *hpd) oz_hcd_put(ozhcd); return hport; } + /*------------------------------------------------------------------------------ * This is called by the protocol handler to notify that the PD has gone away. * We need to deallocate all resources and then request that the root hub is @@ -742,6 +769,7 @@ void oz_hcd_pd_departed(void *hport) usb_hcd_poll_rh_status(ozhcd->hcd); oz_usb_put(hpd); } + /*------------------------------------------------------------------------------ * Context: softirq */ @@ -761,6 +789,7 @@ void oz_hcd_pd_reset(void *hpd, void *hport) oz_clean_endpoints_for_config(ozhcd->hcd, port); usb_hcd_poll_rh_status(ozhcd->hcd); } + /*------------------------------------------------------------------------------ * Context: softirq */ @@ -806,6 +835,7 @@ void oz_hcd_get_desc_cnf(void *hport, u8 req_id, int status, const u8 *desc, urb->actual_length = total_size; oz_complete_urb(port->ozhcd->hcd, urb, 0); } + /*------------------------------------------------------------------------------ * Context: softirq */ @@ -869,6 +899,7 @@ static void oz_hcd_complete_set_config(struct oz_port *port, struct urb *urb, } oz_complete_urb(hcd, urb, rc); } + /*------------------------------------------------------------------------------ * Context: softirq */ @@ -895,6 +926,7 @@ static void oz_hcd_complete_set_interface(struct oz_port *port, struct urb *urb, } oz_complete_urb(hcd, urb, rc); } + /*------------------------------------------------------------------------------ * Context: softirq */ @@ -947,6 +979,7 @@ void oz_hcd_control_cnf(void *hport, u8 req_id, u8 rcode, const u8 *data, oz_complete_urb(hcd, urb, 0); } } + /*------------------------------------------------------------------------------ * Context: softirq-serialized */ @@ -984,6 +1017,7 @@ static int oz_hcd_buffer_data(struct oz_endpoint *ep, const u8 *data, ep->buffered_units++; return 0; } + /*------------------------------------------------------------------------------ * Context: softirq-serialized */ @@ -1030,6 +1064,7 @@ void oz_hcd_data_ind(void *hport, u8 endpoint, const u8 *data, int data_len) done: spin_unlock_bh(&ozhcd->hcd_lock); } + /*------------------------------------------------------------------------------ * Context: unknown */ @@ -1037,6 +1072,7 @@ static inline int oz_usb_get_frame_number(void) { return atomic_inc_return(&g_usb_frame_number); } + /*------------------------------------------------------------------------------ * Context: softirq */ @@ -1197,6 +1233,7 @@ int oz_hcd_heartbeat(void *hport) } return rc; } + /*------------------------------------------------------------------------------ * Context: softirq */ @@ -1275,6 +1312,7 @@ static int oz_build_endpoints_for_interface(struct usb_hcd *hcd, } return 0; } + /*------------------------------------------------------------------------------ * Context: softirq */ @@ -1320,6 +1358,7 @@ static void oz_clean_endpoints_for_interface(struct usb_hcd *hcd, oz_ep_free(port, ep); } } + /*------------------------------------------------------------------------------ * Context: softirq */ @@ -1355,6 +1394,7 @@ static int oz_build_endpoints_for_config(struct usb_hcd *hcd, oz_clean_endpoints_for_config(hcd, port); return -1; } + /*------------------------------------------------------------------------------ * Context: softirq */ @@ -1376,6 +1416,7 @@ static void oz_clean_endpoints_for_config(struct usb_hcd *hcd, port->num_iface = 0; spin_unlock_bh(&ozhcd->hcd_lock); } + /*------------------------------------------------------------------------------ * Context: tasklet */ @@ -1391,6 +1432,7 @@ static void *oz_claim_hpd(struct oz_port *port) spin_unlock_bh(&ozhcd->hcd_lock); return hpd; } + /*------------------------------------------------------------------------------ * Context: tasklet */ @@ -1537,6 +1579,7 @@ static void oz_process_ep0_urb(struct oz_hcd *ozhcd, struct urb *urb, oz_usb_request_heartbeat(port->hpd); } } + /*------------------------------------------------------------------------------ * Context: tasklet */ @@ -1571,6 +1614,7 @@ static int oz_urb_process(struct oz_hcd *ozhcd, struct urb *urb) } return rc; } + /*------------------------------------------------------------------------------ * Context: tasklet */ @@ -1604,6 +1648,7 @@ static void oz_urb_process_tasklet(unsigned long unused) spin_unlock_irqrestore(&g_tasklet_lock, irq_state); oz_hcd_put(ozhcd); } + /*------------------------------------------------------------------------------ * This function searches for the urb in any of the lists it could be in. * If it is found it is removed from the list and completed. If the urb is @@ -1671,6 +1716,7 @@ static void oz_urb_cancel(struct oz_port *port, u8 ep_num, struct urb *urb) oz_complete_urb(ozhcd->hcd, urb, -EPIPE); } } + /*------------------------------------------------------------------------------ * Context: tasklet */ @@ -1698,6 +1744,7 @@ static void oz_urb_cancel_tasklet(unsigned long unused) spin_unlock_irqrestore(&g_tasklet_lock, irq_state); oz_hcd_put(ozhcd); } + /*------------------------------------------------------------------------------ * Context: unknown */ @@ -1714,6 +1761,7 @@ static void oz_hcd_clear_orphanage(struct oz_hcd *ozhcd, int status) } } } + /*------------------------------------------------------------------------------ * Context: unknown */ @@ -1724,18 +1772,21 @@ static int oz_hcd_start(struct usb_hcd *hcd) hcd->uses_new_polling = 1; return 0; } + /*------------------------------------------------------------------------------ * Context: unknown */ static void oz_hcd_stop(struct usb_hcd *hcd) { } + /*------------------------------------------------------------------------------ * Context: unknown */ static void oz_hcd_shutdown(struct usb_hcd *hcd) { } + /*------------------------------------------------------------------------------ * Called to queue an urb for the device. * This function should return a non-zero error code if it fails the urb but @@ -1792,6 +1843,7 @@ static int oz_hcd_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, atomic_inc(&g_pending_urbs); return 0; } + /*------------------------------------------------------------------------------ * Context: tasklet */ @@ -1817,6 +1869,7 @@ static struct oz_urb_link *oz_remove_urb(struct oz_endpoint *ep, } return NULL; } + /*------------------------------------------------------------------------------ * Called to dequeue a previously submitted urb for the device. * Context: any @@ -1858,6 +1911,7 @@ static int oz_hcd_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) } return rc; } + /*------------------------------------------------------------------------------ * Context: unknown */ @@ -1865,6 +1919,7 @@ static void oz_hcd_endpoint_disable(struct usb_hcd *hcd, struct usb_host_endpoint *ep) { } + /*------------------------------------------------------------------------------ * Context: unknown */ @@ -1872,6 +1927,7 @@ static void oz_hcd_endpoint_reset(struct usb_hcd *hcd, struct usb_host_endpoint *ep) { } + /*------------------------------------------------------------------------------ * Context: unknown */ @@ -1880,6 +1936,7 @@ static int oz_hcd_get_frame_number(struct usb_hcd *hcd) oz_dbg(ON, "oz_hcd_get_frame_number\n"); return oz_usb_get_frame_number(); } + /*------------------------------------------------------------------------------ * Context: softirq * This is called as a consquence of us calling usb_hcd_poll_rh_status() and we @@ -1910,6 +1967,7 @@ static int oz_hcd_hub_status_data(struct usb_hcd *hcd, char *buf) else return 0; } + /*------------------------------------------------------------------------------ * Context: process */ @@ -1923,6 +1981,7 @@ static void oz_get_hub_descriptor(struct usb_hcd *hcd, __constant_cpu_to_le16(0x0001); desc->bNbrPorts = OZ_NB_PORTS; } + /*------------------------------------------------------------------------------ * Context: process */ @@ -1998,6 +2057,7 @@ static int oz_set_port_feature(struct usb_hcd *hcd, u16 wvalue, u16 windex) oz_dbg(HUB, "Port[%d] status = 0x%x\n", port_id, port->status); return err; } + /*------------------------------------------------------------------------------ * Context: process */ @@ -2073,6 +2133,7 @@ static int oz_clear_port_feature(struct usb_hcd *hcd, u16 wvalue, u16 windex) port_id, ozhcd->ports[port_id-1].status); return err; } + /*------------------------------------------------------------------------------ * Context: process */ @@ -2090,6 +2151,7 @@ static int oz_get_port_status(struct usb_hcd *hcd, u16 windex, char *buf) oz_dbg(HUB, "Port[%d] status = %x\n", windex, status); return 0; } + /*------------------------------------------------------------------------------ * Context: process */ @@ -2127,6 +2189,7 @@ static int oz_hcd_hub_control(struct usb_hcd *hcd, u16 req_type, u16 wvalue, } return err; } + /*------------------------------------------------------------------------------ * Context: process */ @@ -2141,6 +2204,7 @@ static int oz_hcd_bus_suspend(struct usb_hcd *hcd) spin_unlock_bh(&ozhcd->hcd_lock); return 0; } + /*------------------------------------------------------------------------------ * Context: process */ @@ -2155,6 +2219,7 @@ static int oz_hcd_bus_resume(struct usb_hcd *hcd) spin_unlock_bh(&ozhcd->hcd_lock); return 0; } + /*------------------------------------------------------------------------------ */ static void oz_plat_shutdown(struct platform_device *dev) @@ -2203,6 +2268,7 @@ static int oz_plat_probe(struct platform_device *dev) spin_unlock_bh(&g_hcdlock); return 0; } + /*------------------------------------------------------------------------------ * Context: unknown */ @@ -2235,6 +2301,7 @@ static int oz_plat_suspend(struct platform_device *dev, pm_message_t msg) return 0; } + /*------------------------------------------------------------------------------ * Context: unknown */ @@ -2279,6 +2346,7 @@ int oz_hcd_init(void) oz_dbg(ON, "oz_hcd_init() failed %d\n", err); return err; } + /*------------------------------------------------------------------------------ * Context: process */ diff --git a/drivers/staging/ozwpan/ozmain.c b/drivers/staging/ozwpan/ozmain.c index e26d6bee44d23..707ab287b6a5c 100644 --- a/drivers/staging/ozwpan/ozmain.c +++ b/drivers/staging/ozwpan/ozmain.c @@ -25,6 +25,7 @@ unsigned int oz_dbg_mask = OZ_DEFAULT_DBG_MASK; * netcards. Bindings can be added later using an IOCTL. */ static char *g_net_dev = ""; + /*------------------------------------------------------------------------------ * Context: process */ @@ -36,6 +37,7 @@ static int __init ozwpan_init(void) oz_apps_init(); return 0; } + /*------------------------------------------------------------------------------ * Context: process */ @@ -45,6 +47,7 @@ static void __exit ozwpan_exit(void) oz_apps_term(); oz_cdev_deregister(); } + /*------------------------------------------------------------------------------ */ module_param(g_net_dev, charp, S_IRUGO); diff --git a/drivers/staging/ozwpan/ozpd.c b/drivers/staging/ozwpan/ozpd.c index 14fea77459b72..95109fd7f458e 100644 --- a/drivers/staging/ozwpan/ozpd.c +++ b/drivers/staging/ozwpan/ozpd.c @@ -24,6 +24,7 @@ /*------------------------------------------------------------------------------ */ #define OZ_MAX_TX_POOL_SIZE 6 + /*------------------------------------------------------------------------------ */ static struct oz_tx_frame *oz_tx_frame_alloc(struct oz_pd *pd); @@ -40,10 +41,12 @@ static void oz_def_app_term(void); static int oz_def_app_start(struct oz_pd *pd, int resume); static void oz_def_app_stop(struct oz_pd *pd, int pause); static void oz_def_app_rx(struct oz_pd *pd, struct oz_elt *elt); + /*------------------------------------------------------------------------------ * Counts the uncompleted isoc frames submitted to netcard. */ static atomic_t g_submitted_isoc = ATOMIC_INIT(0); + /* Application handler functions. */ static const struct oz_app_if g_app_if[OZ_APPID_MAX] = { @@ -83,6 +86,7 @@ static const struct oz_app_if g_app_if[OZ_APPID_MAX] = { NULL, OZ_APPID_SERIAL}, }; + /*------------------------------------------------------------------------------ * Context: process */ @@ -90,12 +94,14 @@ static int oz_def_app_init(void) { return 0; } + /*------------------------------------------------------------------------------ * Context: process */ static void oz_def_app_term(void) { } + /*------------------------------------------------------------------------------ * Context: softirq */ @@ -103,18 +109,21 @@ static int oz_def_app_start(struct oz_pd *pd, int resume) { return 0; } + /*------------------------------------------------------------------------------ * Context: softirq */ static void oz_def_app_stop(struct oz_pd *pd, int pause) { } + /*------------------------------------------------------------------------------ * Context: softirq */ static void oz_def_app_rx(struct oz_pd *pd, struct oz_elt *elt) { } + /*------------------------------------------------------------------------------ * Context: softirq or process */ @@ -136,6 +145,7 @@ void oz_pd_set_state(struct oz_pd *pd, unsigned state) break; } } + /*------------------------------------------------------------------------------ * Context: softirq or process */ @@ -143,6 +153,7 @@ void oz_pd_get(struct oz_pd *pd) { atomic_inc(&pd->ref_count); } + /*------------------------------------------------------------------------------ * Context: softirq or process */ @@ -151,6 +162,7 @@ void oz_pd_put(struct oz_pd *pd) if (atomic_dec_and_test(&pd->ref_count)) oz_pd_destroy(pd); } + /*------------------------------------------------------------------------------ * Context: softirq-serialized */ @@ -188,6 +200,7 @@ struct oz_pd *oz_pd_alloc(const u8 *mac_addr) } return pd; } + /*------------------------------------------------------------------------------ * Context: softirq or process */ @@ -244,6 +257,7 @@ void oz_pd_destroy(struct oz_pd *pd) dev_put(pd->net_dev); kfree(pd); } + /*------------------------------------------------------------------------------ * Context: softirq-serialized */ @@ -271,6 +285,7 @@ int oz_services_start(struct oz_pd *pd, u16 apps, int resume) } return rc; } + /*------------------------------------------------------------------------------ * Context: softirq or process */ @@ -293,6 +308,7 @@ void oz_services_stop(struct oz_pd *pd, u16 apps, int pause) } } } + /*------------------------------------------------------------------------------ * Context: softirq */ @@ -315,6 +331,7 @@ void oz_pd_heartbeat(struct oz_pd *pd, u16 apps) ; } } + /*------------------------------------------------------------------------------ * Context: softirq or process */ @@ -338,6 +355,7 @@ void oz_pd_stop(struct oz_pd *pd) oz_dbg(ON, "pd ref count = %d\n", atomic_read(&pd->ref_count)); oz_pd_put(pd); } + /*------------------------------------------------------------------------------ * Context: softirq */ @@ -366,6 +384,7 @@ int oz_pd_sleep(struct oz_pd *pd) } return do_stop; } + /*------------------------------------------------------------------------------ * Context: softirq */ @@ -389,6 +408,7 @@ static struct oz_tx_frame *oz_tx_frame_alloc(struct oz_pd *pd) } return f; } + /*------------------------------------------------------------------------------ * Context: softirq or process */ @@ -406,6 +426,7 @@ static void oz_tx_isoc_free(struct oz_pd *pd, struct oz_tx_frame *f) oz_dbg(TX_FRAMES, "Releasing ISOC Frame isoc_nb= %d\n", pd->nb_queued_isoc_frames); } + /*------------------------------------------------------------------------------ * Context: softirq or process */ @@ -421,6 +442,7 @@ static void oz_tx_frame_free(struct oz_pd *pd, struct oz_tx_frame *f) spin_unlock_bh(&pd->tx_frame_lock); kfree(f); } + /*------------------------------------------------------------------------------ * Context: softirq-serialized */ @@ -430,6 +452,7 @@ static void oz_set_more_bit(struct sk_buff *skb) oz_hdr->control |= OZ_F_MORE_DATA; } + /*------------------------------------------------------------------------------ * Context: softirq-serialized */ @@ -439,6 +462,7 @@ static void oz_set_last_pkt_nb(struct oz_pd *pd, struct sk_buff *skb) oz_hdr->last_pkt_num = pd->trigger_pkt_num & OZ_LAST_PN_MASK; } + /*------------------------------------------------------------------------------ * Context: softirq */ @@ -470,6 +494,7 @@ int oz_prepare_frame(struct oz_pd *pd, int empty) spin_unlock(&pd->tx_frame_lock); return 0; } + /*------------------------------------------------------------------------------ * Context: softirq-serialized */ @@ -515,6 +540,7 @@ static struct sk_buff *oz_build_frame(struct oz_pd *pd, struct oz_tx_frame *f) kfree_skb(skb); return NULL; } + /*------------------------------------------------------------------------------ * Context: softirq or process */ @@ -538,6 +564,7 @@ static void oz_retire_frame(struct oz_pd *pd, struct oz_tx_frame *f) if (pd->elt_buff.free_elts > pd->elt_buff.max_free_elts) oz_trim_elt_pool(&pd->elt_buff); } + /*------------------------------------------------------------------------------ * Context: softirq-serialized */ @@ -592,6 +619,7 @@ static int oz_send_next_queued_frame(struct oz_pd *pd, int more_data) } return 0; } + /*------------------------------------------------------------------------------ * Context: softirq-serialized */ @@ -630,6 +658,7 @@ void oz_send_queued_frames(struct oz_pd *pd, int backlog) out: oz_prepare_frame(pd, 1); oz_send_next_queued_frame(pd, 0); } + /*------------------------------------------------------------------------------ * Context: softirq */ @@ -679,6 +708,7 @@ static int oz_send_isoc_frame(struct oz_pd *pd) oz_elt_info_free_chain(&pd->elt_buff, &list); return 0; } + /*------------------------------------------------------------------------------ * Context: softirq-serialized */ @@ -720,6 +750,7 @@ void oz_retire_tx_frames(struct oz_pd *pd, u8 lpn) oz_retire_frame(pd, f); } } + /*------------------------------------------------------------------------------ * Precondition: stream_lock must be held. * Context: softirq @@ -736,6 +767,7 @@ static struct oz_isoc_stream *pd_stream_find(struct oz_pd *pd, u8 ep_num) } return NULL; } + /*------------------------------------------------------------------------------ * Context: softirq */ @@ -755,6 +787,7 @@ int oz_isoc_stream_create(struct oz_pd *pd, u8 ep_num) kfree(st); return 0; } + /*------------------------------------------------------------------------------ * Context: softirq or process */ @@ -763,6 +796,7 @@ static void oz_isoc_stream_free(struct oz_isoc_stream *st) kfree_skb(st->skb); kfree(st); } + /*------------------------------------------------------------------------------ * Context: softirq */ @@ -779,6 +813,7 @@ int oz_isoc_stream_delete(struct oz_pd *pd, u8 ep_num) oz_isoc_stream_free(st); return 0; } + /*------------------------------------------------------------------------------ * Context: any */ @@ -786,6 +821,7 @@ static void oz_isoc_destructor(struct sk_buff *skb) { atomic_dec(&g_submitted_isoc); } + /*------------------------------------------------------------------------------ * Context: softirq */ @@ -907,6 +943,7 @@ out: kfree_skb(skb); } return 0; } + /*------------------------------------------------------------------------------ * Context: process */ @@ -918,6 +955,7 @@ void oz_apps_init(void) if (g_app_if[i].init) g_app_if[i].init(); } + /*------------------------------------------------------------------------------ * Context: process */ @@ -930,6 +968,7 @@ void oz_apps_term(void) if (g_app_if[i].term) g_app_if[i].term(); } + /*------------------------------------------------------------------------------ * Context: softirq-serialized */ @@ -942,6 +981,7 @@ void oz_handle_app_elt(struct oz_pd *pd, u8 app_id, struct oz_elt *elt) ai = &g_app_if[app_id-1]; ai->rx(pd, elt); } + /*------------------------------------------------------------------------------ * Context: softirq or process */ diff --git a/drivers/staging/ozwpan/ozproto.c b/drivers/staging/ozwpan/ozproto.c index 7072f538bd8d8..8c2200b90d596 100644 --- a/drivers/staging/ozwpan/ozproto.c +++ b/drivers/staging/ozwpan/ozproto.c @@ -22,6 +22,7 @@ #include #include #include + /*------------------------------------------------------------------------------ */ #define OZ_CF_CONN_SUCCESS 1 @@ -51,6 +52,7 @@ static struct sk_buff_head g_rx_queue; static u8 g_session_id; static u16 g_apps = 0x1; static int g_processing_rx; + /*------------------------------------------------------------------------------ * Context: softirq-serialized */ @@ -64,6 +66,7 @@ static u8 oz_get_new_session_id(u8 exclude) } return g_session_id; } + /*------------------------------------------------------------------------------ * Context: softirq-serialized */ @@ -109,6 +112,7 @@ static void oz_send_conn_rsp(struct oz_pd *pd, u8 status) dev_queue_xmit(skb); return; } + /*------------------------------------------------------------------------------ * Context: softirq-serialized */ @@ -134,6 +138,7 @@ static void pd_set_keepalive(struct oz_pd *pd, u8 kalive) } oz_dbg(ON, "Keepalive = %lu mSec\n", pd->keep_alive); } + /*------------------------------------------------------------------------------ * Context: softirq-serialized */ @@ -150,6 +155,7 @@ static void pd_set_presleep(struct oz_pd *pd, u8 presleep, u8 start_timer) } oz_dbg(ON, "Presleep time = %lu mSec\n", pd->presleep); } + /*------------------------------------------------------------------------------ * Context: softirq-serialized */ @@ -284,6 +290,7 @@ static struct oz_pd *oz_connect_req(struct oz_pd *cur_pd, struct oz_elt *elt, oz_pd_destroy(free_pd); return pd; } + /*------------------------------------------------------------------------------ * Context: softirq-serialized */ @@ -315,6 +322,7 @@ static void oz_add_farewell(struct oz_pd *pd, u8 ep_num, u8 index, if (found) kfree(f2); } + /*------------------------------------------------------------------------------ * Context: softirq-serialized */ @@ -436,6 +444,7 @@ static void oz_rx_frame(struct sk_buff *skb) oz_pd_put(pd); consume_skb(skb); } + /*------------------------------------------------------------------------------ * Context: process */ @@ -473,6 +482,7 @@ void oz_protocol_term(void) spin_unlock_bh(&g_polling_lock); oz_dbg(ON, "Protocol stopped\n"); } + /*------------------------------------------------------------------------------ * Context: softirq */ @@ -489,6 +499,7 @@ void oz_pd_heartbeat_handler(unsigned long data) oz_pd_heartbeat(pd, apps); } + /*------------------------------------------------------------------------------ * Context: softirq */ @@ -509,6 +520,7 @@ void oz_pd_timeout_handler(unsigned long data) break; } } + /*------------------------------------------------------------------------------ * Context: Interrupt */ @@ -522,6 +534,7 @@ enum hrtimer_restart oz_pd_heartbeat_event(struct hrtimer *timer) tasklet_schedule(&pd->heartbeat_tasklet); return HRTIMER_RESTART; } + /*------------------------------------------------------------------------------ * Context: Interrupt */ @@ -533,6 +546,7 @@ enum hrtimer_restart oz_pd_timeout_event(struct hrtimer *timer) tasklet_schedule(&pd->timeout_tasklet); return HRTIMER_NORESTART; } + /*------------------------------------------------------------------------------ * Context: softirq or process */ @@ -563,6 +577,7 @@ void oz_timer_add(struct oz_pd *pd, int type, unsigned long due_time) } spin_unlock_bh(&g_polling_lock); } + /*------------------------------------------------------------------------------ * Context: softirq or process */ @@ -571,6 +586,7 @@ void oz_pd_request_heartbeat(struct oz_pd *pd) oz_timer_add(pd, OZ_TIMER_HEARTBEAT, pd->pulse_period > 0 ? pd->pulse_period : OZ_QUANTUM); } + /*------------------------------------------------------------------------------ * Context: softirq or process */ @@ -591,6 +607,7 @@ struct oz_pd *oz_pd_find(const u8 *mac_addr) spin_unlock_bh(&g_polling_lock); return NULL; } + /*------------------------------------------------------------------------------ * Context: process */ @@ -605,6 +622,7 @@ void oz_app_enable(int app_id, int enable) spin_unlock_bh(&g_polling_lock); } } + /*------------------------------------------------------------------------------ * Context: softirq */ @@ -639,6 +657,7 @@ static int oz_pkt_recv(struct sk_buff *skb, struct net_device *dev, } return 0; } + /*------------------------------------------------------------------------------ * Context: process */ @@ -672,6 +691,7 @@ void oz_binding_add(const char *net_dev) } } } + /*------------------------------------------------------------------------------ * Context: process */ @@ -696,6 +716,7 @@ static void pd_stop_all_for_device(struct net_device *net_dev) oz_pd_put(pd); } } + /*------------------------------------------------------------------------------ * Context: process */ @@ -724,6 +745,7 @@ void oz_binding_remove(const char *net_dev) kfree(binding); } } + /*------------------------------------------------------------------------------ * Context: process */ @@ -738,6 +760,7 @@ static char *oz_get_next_device_name(char *s, char *dname, int max_size) *dname = 0; return s; } + /*------------------------------------------------------------------------------ * Context: process */ @@ -756,6 +779,7 @@ int oz_protocol_init(char *devs) } return 0; } + /*------------------------------------------------------------------------------ * Context: process */ @@ -775,12 +799,14 @@ int oz_get_pd_list(struct oz_mac_addr *addr, int max_count) spin_unlock_bh(&g_polling_lock); return count; } + /*------------------------------------------------------------------------------ */ void oz_polling_lock_bh(void) { spin_lock_bh(&g_polling_lock); } + /*------------------------------------------------------------------------------ */ void oz_polling_unlock_bh(void) diff --git a/drivers/staging/ozwpan/ozurbparanoia.c b/drivers/staging/ozwpan/ozurbparanoia.c index 6aab9a7fc9f88..d779877ef6f0b 100644 --- a/drivers/staging/ozwpan/ozurbparanoia.c +++ b/drivers/staging/ozwpan/ozurbparanoia.c @@ -16,6 +16,7 @@ struct urb *g_urb_memory[OZ_MAX_URBS]; int g_nb_urbs; DEFINE_SPINLOCK(g_urb_mem_lock); + /*----------------------------------------------------------------------------- */ void oz_remember_urb(struct urb *urb) @@ -31,6 +32,7 @@ void oz_remember_urb(struct urb *urb) } spin_unlock_irqrestore(&g_urb_mem_lock, irq_state); } + /*------------------------------------------------------------------------------ */ int oz_forget_urb(struct urb *urb) diff --git a/drivers/staging/ozwpan/ozusbsvc.c b/drivers/staging/ozwpan/ozusbsvc.c index ab9db8cb30e25..404941d55d787 100644 --- a/drivers/staging/ozwpan/ozusbsvc.c +++ b/drivers/staging/ozwpan/ozusbsvc.c @@ -36,6 +36,7 @@ int oz_usb_init(void) { return oz_hcd_init(); } + /*------------------------------------------------------------------------------ * This is called once when the driver is unloaded to terminate the USB service. * Context: process @@ -44,6 +45,7 @@ void oz_usb_term(void) { oz_hcd_term(); } + /*------------------------------------------------------------------------------ * This is called when the USB service is started or resumed for a PD. * Context: softirq @@ -108,6 +110,7 @@ int oz_usb_start(struct oz_pd *pd, int resume) oz_usb_put(usb_ctx); return rc; } + /*------------------------------------------------------------------------------ * This is called when the USB service is stopped or paused for a PD. * Context: softirq or process @@ -148,6 +151,7 @@ void oz_usb_stop(struct oz_pd *pd, int pause) oz_usb_put(usb_ctx); } } + /*------------------------------------------------------------------------------ * This increments the reference count of the context area for a specific PD. * This ensures this context area does not disappear while still in use. @@ -159,6 +163,7 @@ void oz_usb_get(void *hpd) atomic_inc(&usb_ctx->ref_count); } + /*------------------------------------------------------------------------------ * This decrements the reference count of the context area for a specific PD * and destroys the context area if the reference count becomes zero. @@ -174,6 +179,7 @@ void oz_usb_put(void *hpd) kfree(usb_ctx); } } + /*------------------------------------------------------------------------------ * Context: softirq */ @@ -198,6 +204,7 @@ int oz_usb_heartbeat(struct oz_pd *pd) oz_usb_put(usb_ctx); return rc; } + /*------------------------------------------------------------------------------ * Context: softirq */ @@ -219,6 +226,7 @@ int oz_usb_stream_create(void *hpd, u8 ep_num) } return 0; } + /*------------------------------------------------------------------------------ * Context: softirq */ @@ -241,6 +249,7 @@ int oz_usb_stream_delete(void *hpd, u8 ep_num) } return 0; } + /*------------------------------------------------------------------------------ * Context: softirq or process */ diff --git a/drivers/staging/ozwpan/ozusbsvc1.c b/drivers/staging/ozwpan/ozusbsvc1.c index 34133efddb429..4ec21b54f94b3 100644 --- a/drivers/staging/ozwpan/ozusbsvc1.c +++ b/drivers/staging/ozwpan/ozusbsvc1.c @@ -21,9 +21,11 @@ #include "ozusbif.h" #include "ozhcd.h" #include "ozusbsvc.h" + /*------------------------------------------------------------------------------ */ #define MAX_ISOC_FIXED_DATA (253-sizeof(struct oz_isoc_fixed)) + /*------------------------------------------------------------------------------ * Context: softirq */ @@ -50,6 +52,7 @@ static int oz_usb_submit_elt(struct oz_elt_buf *eb, struct oz_elt_info *ei, spin_unlock_bh(&eb->lock); return ret; } + /*------------------------------------------------------------------------------ * Context: softirq */ @@ -86,6 +89,7 @@ int oz_usb_get_desc_req(void *hpd, u8 req_id, u8 req_type, u8 desc_type, body->index = index; return oz_usb_submit_elt(eb, ei, usb_ctx, 0, 0); } + /*------------------------------------------------------------------------------ * Context: tasklet */ @@ -108,6 +112,7 @@ static int oz_usb_set_config_req(void *hpd, u8 req_id, u8 index) body->index = index; return oz_usb_submit_elt(eb, ei, usb_ctx, 0, 0); } + /*------------------------------------------------------------------------------ * Context: tasklet */ @@ -131,6 +136,7 @@ static int oz_usb_set_interface_req(void *hpd, u8 req_id, u8 index, u8 alt) body->alternative = alt; return oz_usb_submit_elt(eb, ei, usb_ctx, 0, 0); } + /*------------------------------------------------------------------------------ * Context: tasklet */ @@ -156,6 +162,7 @@ static int oz_usb_set_clear_feature_req(void *hpd, u8 req_id, u8 type, put_unaligned(feature, &body->feature); return oz_usb_submit_elt(eb, ei, usb_ctx, 0, 0); } + /*------------------------------------------------------------------------------ * Context: tasklet */ @@ -184,6 +191,7 @@ static int oz_usb_vendor_class_req(void *hpd, u8 req_id, u8 req_type, memcpy(body->data, data, data_len); return oz_usb_submit_elt(eb, ei, usb_ctx, 0, 0); } + /*------------------------------------------------------------------------------ * Context: tasklet */ @@ -232,6 +240,7 @@ int oz_usb_control_req(void *hpd, u8 req_id, struct usb_ctrlrequest *setup, } return rc; } + /*------------------------------------------------------------------------------ * Context: softirq */ @@ -303,6 +312,7 @@ int oz_usb_send_isoc(void *hpd, u8 ep_num, struct urb *urb) } return 0; } + /*------------------------------------------------------------------------------ * Context: softirq-serialized */ @@ -346,6 +356,7 @@ static void oz_usb_handle_ep_data(struct oz_usb_ctx *usb_ctx, } } + /*------------------------------------------------------------------------------ * This is called when the PD has received a USB element. The type of element * is determined and is then passed to an appropriate handler function. @@ -418,6 +429,7 @@ void oz_usb_rx(struct oz_pd *pd, struct oz_elt *elt) done: oz_usb_put(usb_ctx); } + /*------------------------------------------------------------------------------ * Context: softirq, process */ -- GitLab From 2c66335c0c74d7994bb3a5d41f6f6ae46079cdd9 Mon Sep 17 00:00:00 2001 From: Rupesh Gujare Date: Tue, 13 Aug 2013 18:24:23 +0100 Subject: [PATCH 625/942] staging: ozwpan: Simply if condition Making code simpler for readability. Reported-by: Dan Carpenter Signed-off-by: Rupesh Gujare Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozhcd.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c index 5a417c833400d..4b658d4adabcb 100644 --- a/drivers/staging/ozwpan/ozhcd.c +++ b/drivers/staging/ozwpan/ozhcd.c @@ -478,7 +478,7 @@ static int oz_enqueue_ep_urb(struct oz_port *port, u8 ep_addr, int in_dir, struct urb *urb, u8 req_id) { struct oz_urb_link *urbl; - struct oz_endpoint *ep; + struct oz_endpoint *ep = NULL; int err = 0; if (ep_addr >= OZ_NB_ENDPOINTS) { @@ -506,11 +506,12 @@ static int oz_enqueue_ep_urb(struct oz_port *port, u8 ep_addr, int in_dir, oz_free_urb_link(urbl); return 0; } - if (in_dir && port->in_ep[ep_addr]) + + if (in_dir) ep = port->in_ep[ep_addr]; - else if (!in_dir && port->out_ep[ep_addr]) + else ep = port->out_ep[ep_addr]; - else { + if (!ep) { err = -ENOMEM; goto out; } -- GitLab From 0535281e4b3bd5192ff425dad0f8b7976acd5172 Mon Sep 17 00:00:00 2001 From: Rupesh Gujare Date: Tue, 13 Aug 2013 18:24:24 +0100 Subject: [PATCH 626/942] staging: ozwpan: Fix coding style. Put spaces around math operations. Reported-by: Dan Carpenter Signed-off-by: Rupesh Gujare Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozhcd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c index 4b658d4adabcb..2be15f4160ed5 100644 --- a/drivers/staging/ozwpan/ozhcd.c +++ b/drivers/staging/ozwpan/ozhcd.c @@ -1957,9 +1957,9 @@ static int oz_hcd_hub_status_data(struct usb_hcd *hcd, char *buf) oz_dbg(HUB, "Port %d changed\n", i); ozhcd->ports[i].flags &= ~OZ_PORT_F_CHANGED; if (i < 7) - buf[0] |= 1 << (i+1); + buf[0] |= 1 << (i + 1); else - buf[1] |= 1 << (i-7); + buf[1] |= 1 << (i - 7); } } spin_unlock_bh(&ozhcd->hcd_lock); -- GitLab From c45905a726d2a979c9070a84a197ffa4b4474475 Mon Sep 17 00:00:00 2001 From: Rupesh Gujare Date: Tue, 13 Aug 2013 18:29:21 +0100 Subject: [PATCH 627/942] staging: ozwpan: Remove unnecessary pointer check. We are already checking "ep" earlier in function. Do not need to check again. Reported-by: Dan Carpenter Signed-off-by: Rupesh Gujare Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozhcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c index 2be15f4160ed5..8633f0c3e82e8 100644 --- a/drivers/staging/ozwpan/ozhcd.c +++ b/drivers/staging/ozwpan/ozhcd.c @@ -527,7 +527,7 @@ static int oz_enqueue_ep_urb(struct oz_port *port, u8 ep_addr, int in_dir, return 0; } - if (ep && port->hpd) { + if (port->hpd) { list_add_tail(&urbl->link, &ep->urb_list); if (!in_dir && ep_addr && (ep->credit < 0)) { getrawmonotonic(&ep->timestamp); -- GitLab From 0503d202c61d524d44f5d2af7e3ff9c2f17e15ec Mon Sep 17 00:00:00 2001 From: Rupesh Gujare Date: Tue, 13 Aug 2013 18:29:22 +0100 Subject: [PATCH 628/942] staging: ozwpan: Make oz_hcd_pd_arrived() return a struct pointer oz_hcd_pd_arrived returns struct oz_port *, change function declaration to avoid ambiguity. Reported-by: Dan Carpenter Signed-off-by: Rupesh Gujare Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozhcd.c | 4 ++-- drivers/staging/ozwpan/ozhcd.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c index 8633f0c3e82e8..73d80f21a50f7 100644 --- a/drivers/staging/ozwpan/ozhcd.c +++ b/drivers/staging/ozwpan/ozhcd.c @@ -660,10 +660,10 @@ static inline void oz_hcd_put(struct oz_hcd *ozhcd) * probably very rare indeed. * Context: softirq */ -void *oz_hcd_pd_arrived(void *hpd) +struct oz_port *oz_hcd_pd_arrived(void *hpd) { int i; - void *hport = NULL; + struct oz_port *hport = NULL; struct oz_hcd *ozhcd = NULL; struct oz_endpoint *ep; diff --git a/drivers/staging/ozwpan/ozhcd.h b/drivers/staging/ozwpan/ozhcd.h index 9b30dfd09973a..ef3202fa79ff3 100644 --- a/drivers/staging/ozwpan/ozhcd.h +++ b/drivers/staging/ozwpan/ozhcd.h @@ -7,8 +7,8 @@ int oz_hcd_init(void); void oz_hcd_term(void); -void *oz_hcd_pd_arrived(void *ctx); void oz_hcd_pd_departed(void *ctx); +struct oz_port *oz_hcd_pd_arrived(void *ctx); void oz_hcd_pd_reset(void *hpd, void *hport); #endif /* _OZHCD_H */ -- GitLab From 25403813148a49492726b9b062af4c58c6b240db Mon Sep 17 00:00:00 2001 From: Rupesh Gujare Date: Tue, 13 Aug 2013 18:29:23 +0100 Subject: [PATCH 629/942] staging: ozwpan: Make oz_hcd_pd_departed() take a struct pointer. oz_hcd_pd_departed() takes struct oz_port pointer instead of void *, change function declaration to avoid ambiguity. Reported-by: Dan Carpenter Signed-off-by: Rupesh Gujare Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozhcd.c | 4 ++-- drivers/staging/ozwpan/ozhcd.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c index 73d80f21a50f7..ed3ffeba12ab8 100644 --- a/drivers/staging/ozwpan/ozhcd.c +++ b/drivers/staging/ozwpan/ozhcd.c @@ -720,9 +720,9 @@ struct oz_port *oz_hcd_pd_arrived(void *hpd) * polled. We release the reference we hold on the PD. * Context: softirq */ -void oz_hcd_pd_departed(void *hport) +void oz_hcd_pd_departed(struct oz_port *hport) { - struct oz_port *port = (struct oz_port *)hport; + struct oz_port *port = hport; struct oz_hcd *ozhcd; void *hpd; struct oz_endpoint *ep = NULL; diff --git a/drivers/staging/ozwpan/ozhcd.h b/drivers/staging/ozwpan/ozhcd.h index ef3202fa79ff3..55e97b1c70793 100644 --- a/drivers/staging/ozwpan/ozhcd.h +++ b/drivers/staging/ozwpan/ozhcd.h @@ -7,8 +7,8 @@ int oz_hcd_init(void); void oz_hcd_term(void); -void oz_hcd_pd_departed(void *ctx); struct oz_port *oz_hcd_pd_arrived(void *ctx); +void oz_hcd_pd_departed(struct oz_port *hport); void oz_hcd_pd_reset(void *hpd, void *hport); #endif /* _OZHCD_H */ -- GitLab From a15e042e262bb62cd8dd9a7ccda9137c9e65cedc Mon Sep 17 00:00:00 2001 From: Rupesh Gujare Date: Tue, 13 Aug 2013 18:29:24 +0100 Subject: [PATCH 630/942] staging: ozwpan: Remove unneeded initializers Remove variable initialization wherever it is not required. Signed-off-by: Rupesh Gujare Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozeltbuf.c | 2 +- drivers/staging/ozwpan/ozhcd.c | 18 +++++++++--------- drivers/staging/ozwpan/ozpd.c | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/ozwpan/ozeltbuf.c b/drivers/staging/ozwpan/ozeltbuf.c index 4844d9f3cfe57..cfc0f3996b4c1 100644 --- a/drivers/staging/ozwpan/ozeltbuf.c +++ b/drivers/staging/ozwpan/ozeltbuf.c @@ -67,7 +67,7 @@ void oz_elt_buf_term(struct oz_elt_buf *buf) */ struct oz_elt_info *oz_elt_info_alloc(struct oz_elt_buf *buf) { - struct oz_elt_info *ei = NULL; + struct oz_elt_info *ei; spin_lock_bh(&buf->lock); if (buf->free_elts && buf->elt_pool) { diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c index ed3ffeba12ab8..0fd3feaa3f2a7 100644 --- a/drivers/staging/ozwpan/ozhcd.c +++ b/drivers/staging/ozwpan/ozhcd.c @@ -373,7 +373,7 @@ static void oz_complete_urb(struct usb_hcd *hcd, struct urb *urb, { struct oz_hcd *ozhcd = oz_hcd_private(hcd); unsigned long irq_state; - struct oz_urb_link *cancel_urbl = NULL; + struct oz_urb_link *cancel_urbl; spin_lock_irqsave(&g_tasklet_lock, irq_state); usb_hcd_unlink_urb_from_ep(hcd, urb); @@ -585,7 +585,7 @@ static struct urb *oz_find_urb_by_id(struct oz_port *port, int ep_ix, { struct oz_hcd *ozhcd = port->ozhcd; struct urb *urb = NULL; - struct oz_urb_link *urbl = NULL; + struct oz_urb_link *urbl; struct oz_endpoint *ep; spin_lock_bh(&ozhcd->hcd_lock); @@ -664,7 +664,7 @@ struct oz_port *oz_hcd_pd_arrived(void *hpd) { int i; struct oz_port *hport = NULL; - struct oz_hcd *ozhcd = NULL; + struct oz_hcd *ozhcd; struct oz_endpoint *ep; ozhcd = oz_hcd_claim(); @@ -1423,7 +1423,7 @@ static void oz_clean_endpoints_for_config(struct usb_hcd *hcd, */ static void *oz_claim_hpd(struct oz_port *port) { - void *hpd = NULL; + void *hpd; struct oz_hcd *ozhcd = port->ozhcd; spin_lock_bh(&ozhcd->hcd_lock); @@ -1444,7 +1444,7 @@ static void oz_process_ep0_urb(struct oz_hcd *ozhcd, struct urb *urb, unsigned windex; unsigned wvalue; unsigned wlength; - void *hpd = NULL; + void *hpd; u8 req_id; int rc = 0; unsigned complete = 0; @@ -1798,7 +1798,7 @@ static int oz_hcd_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags) { struct oz_hcd *ozhcd = oz_hcd_private(hcd); - int rc = 0; + int rc; int port_ix; struct oz_port *port; unsigned long irq_state; @@ -1851,7 +1851,7 @@ static int oz_hcd_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, static struct oz_urb_link *oz_remove_urb(struct oz_endpoint *ep, struct urb *urb) { - struct oz_urb_link *urbl = NULL; + struct oz_urb_link *urbl; struct list_head *e; if (unlikely(ep == NULL)) @@ -1878,7 +1878,7 @@ static struct oz_urb_link *oz_remove_urb(struct oz_endpoint *ep, static int oz_hcd_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) { struct oz_hcd *ozhcd = oz_hcd_private(hcd); - struct oz_urb_link *urbl = NULL; + struct oz_urb_link *urbl; int rc; unsigned long irq_state; @@ -2141,7 +2141,7 @@ static int oz_clear_port_feature(struct usb_hcd *hcd, u16 wvalue, u16 windex) static int oz_get_port_status(struct usb_hcd *hcd, u16 windex, char *buf) { struct oz_hcd *ozhcd; - u32 status = 0; + u32 status; if ((windex < 1) || (windex > OZ_NB_PORTS)) return -EPIPE; diff --git a/drivers/staging/ozwpan/ozpd.c b/drivers/staging/ozwpan/ozpd.c index 95109fd7f458e..2514d79a8ff41 100644 --- a/drivers/staging/ozwpan/ozpd.c +++ b/drivers/staging/ozwpan/ozpd.c @@ -337,7 +337,7 @@ void oz_pd_heartbeat(struct oz_pd *pd, u16 apps) */ void oz_pd_stop(struct oz_pd *pd) { - u16 stop_apps = 0; + u16 stop_apps; oz_dbg(ON, "oz_pd_stop() State = 0x%x\n", pd->state); oz_pd_indicate_farewells(pd); @@ -362,7 +362,7 @@ void oz_pd_stop(struct oz_pd *pd) int oz_pd_sleep(struct oz_pd *pd) { int do_stop = 0; - u16 stop_apps = 0; + u16 stop_apps; oz_polling_lock_bh(); if (pd->state & (OZ_PD_S_SLEEP | OZ_PD_S_STOPPED)) { -- GitLab From 5f1f7b110fc43b03af241302e99addca4c124638 Mon Sep 17 00:00:00 2001 From: Rupesh Gujare Date: Tue, 13 Aug 2013 18:29:25 +0100 Subject: [PATCH 631/942] staging: ozwpan: Swap arguments of oz_ep_alloc() to match kmalloc() Swap arguments of oz_ep_alloc() to match kmalloc() for better readability. Signed-off-by: Rupesh Gujare Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozhcd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c index 0fd3feaa3f2a7..0b21c9f4d2e3e 100644 --- a/drivers/staging/ozwpan/ozhcd.c +++ b/drivers/staging/ozwpan/ozhcd.c @@ -327,7 +327,7 @@ static void oz_empty_link_pool(void) * allocated it immediately follows the endpoint structure. * Context: softirq */ -static struct oz_endpoint *oz_ep_alloc(gfp_t mem_flags, int buffer_size) +static struct oz_endpoint *oz_ep_alloc(int buffer_size, gfp_t mem_flags) { struct oz_endpoint *ep = kzalloc(sizeof(struct oz_endpoint)+buffer_size, mem_flags); @@ -673,7 +673,7 @@ struct oz_port *oz_hcd_pd_arrived(void *hpd) /* Allocate an endpoint object in advance (before holding hcd lock) to * use for out endpoint 0. */ - ep = oz_ep_alloc(GFP_ATOMIC, 0); + ep = oz_ep_alloc(0, GFP_ATOMIC); spin_lock_bh(&ozhcd->hcd_lock); if (ozhcd->conn_port >= 0) { spin_unlock_bh(&ozhcd->hcd_lock); @@ -1268,7 +1268,7 @@ static int oz_build_endpoints_for_interface(struct usb_hcd *hcd, } } - ep = oz_ep_alloc(mem_flags, buffer_size); + ep = oz_ep_alloc(buffer_size, mem_flags); if (!ep) { oz_clean_endpoints_for_interface(hcd, port, if_ix); return -ENOMEM; -- GitLab From 95b20b8b060ae9dbd4cf3de63c176935eef71837 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 13 Aug 2013 18:29:26 +0100 Subject: [PATCH 632/942] staging: ozwpan: Separate success & failure case for oz_hcd_pd_arrived() This patch separates success & failure block along with fixing following issues:- 1. The way oz_hcd_pd_arrived() looks now it's easy to think we free "ep" but actually we do this spaghetti thing of setting it to NULL on success. 2. It is hard to read it because there are unlocks scattered throughout. 3. Currently we set "ep" to NULL on the success path and then test it and or free it. In current code you have to scroll to the start of the function to read code. Original patch was submitted by Dan here :- http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2013-August/040113.html Signed-off-by: Dan Carpenter Signed-off-by: Rupesh Gujare Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozhcd.c | 54 +++++++++++++++++----------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c index 0b21c9f4d2e3e..4cd08daf51119 100644 --- a/drivers/staging/ozwpan/ozhcd.c +++ b/drivers/staging/ozwpan/ozhcd.c @@ -668,50 +668,50 @@ struct oz_port *oz_hcd_pd_arrived(void *hpd) struct oz_endpoint *ep; ozhcd = oz_hcd_claim(); - if (ozhcd == NULL) + if (!ozhcd) return NULL; /* Allocate an endpoint object in advance (before holding hcd lock) to * use for out endpoint 0. */ ep = oz_ep_alloc(0, GFP_ATOMIC); + if (!ep) + goto err_put; + spin_lock_bh(&ozhcd->hcd_lock); - if (ozhcd->conn_port >= 0) { - spin_unlock_bh(&ozhcd->hcd_lock); - oz_dbg(ON, "conn_port >= 0\n"); - goto out; - } + if (ozhcd->conn_port >= 0) + goto err_unlock; + for (i = 0; i < OZ_NB_PORTS; i++) { struct oz_port *port = &ozhcd->ports[i]; + spin_lock(&port->port_lock); - if ((port->flags & OZ_PORT_F_PRESENT) == 0) { + if (!(port->flags & OZ_PORT_F_PRESENT)) { oz_acquire_port(port, hpd); spin_unlock(&port->port_lock); break; } spin_unlock(&port->port_lock); } - if (i < OZ_NB_PORTS) { - oz_dbg(ON, "Setting conn_port = %d\n", i); - ozhcd->conn_port = i; - /* Attach out endpoint 0. - */ - ozhcd->ports[i].out_ep[0] = ep; - ep = NULL; - hport = &ozhcd->ports[i]; - spin_unlock_bh(&ozhcd->hcd_lock); - if (ozhcd->flags & OZ_HDC_F_SUSPENDED) { - oz_dbg(ON, "Resuming root hub\n"); - usb_hcd_resume_root_hub(ozhcd->hcd); - } - usb_hcd_poll_rh_status(ozhcd->hcd); - } else { - spin_unlock_bh(&ozhcd->hcd_lock); - } -out: - if (ep) /* ep is non-null if not used. */ - oz_ep_free(NULL, ep); + if (i == OZ_NB_PORTS) + goto err_unlock; + + ozhcd->conn_port = i; + hport = &ozhcd->ports[i]; + hport->out_ep[0] = ep; + spin_unlock_bh(&ozhcd->hcd_lock); + if (ozhcd->flags & OZ_HDC_F_SUSPENDED) + usb_hcd_resume_root_hub(ozhcd->hcd); + usb_hcd_poll_rh_status(ozhcd->hcd); oz_hcd_put(ozhcd); + return hport; + +err_unlock: + spin_unlock_bh(&ozhcd->hcd_lock); + oz_ep_free(NULL, ep); +err_put: + oz_hcd_put(ozhcd); + return NULL; } /*------------------------------------------------------------------------------ -- GitLab From 629a9e65734e7a0d1b7528529ab99f5974f6069d Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Tue, 13 Aug 2013 19:47:08 +0100 Subject: [PATCH 633/942] staging: vt6656: rxtx.h always pack BEACON_BUFFER/TX_BUFFER All structure members of BEACON_BUFFER/TX_BUFFER should be packed. Only the first 4 members of these structures are live. The forth member is referenced at run-time by packed structures. typedef struct tagSTxBufHead typedef struct tagSTxShortBufHead in desc.h If these structures are not packed the alignment of these members will be wrong. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.h b/drivers/staging/vt6656/rxtx.h index dd7e85dde1a28..d854b383d647f 100644 --- a/drivers/staging/vt6656/rxtx.h +++ b/drivers/staging/vt6656/rxtx.h @@ -609,7 +609,7 @@ typedef struct tagSTX_BUFFER // Actual message TX_BUFFER_CONTAINER BufferHeader; -} TX_BUFFER, *PTX_BUFFER; +} __packed TX_BUFFER, *PTX_BUFFER; // // Remote NDIS message format @@ -626,7 +626,7 @@ typedef struct tagSBEACON_BUFFER // Actual message TX_BUFFER_CONTAINER BufferHeader; -} BEACON_BUFFER, *PBEACON_BUFFER; +} __packed BEACON_BUFFER, *PBEACON_BUFFER; void vDMA0_tx_80211(struct vnt_private *, struct sk_buff *skb); int nsDMA_tx_packet(struct vnt_private *, u32 uDMAIdx, struct sk_buff *skb); -- GitLab From 18ee00a6e10e54e6e5ebddba7913ee5738344297 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Tue, 13 Aug 2013 19:52:08 +0100 Subject: [PATCH 634/942] staging: vt6656: rxtx.h dead code typedef union tagUTX_BUFFER_CONTAINER This is part of the Remote NDIS message format with patch vt6656: rxtx.c: s_vGetFreeContext use single tx memset. there is not need for this structure and its members. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.h | 573 ---------------------------------- 1 file changed, 573 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.h b/drivers/staging/vt6656/rxtx.h index d854b383d647f..3e2a877a3b034 100644 --- a/drivers/staging/vt6656/rxtx.h +++ b/drivers/staging/vt6656/rxtx.h @@ -32,568 +32,6 @@ #include "device.h" #include "wcmd.h" -// -// RTS buffer header -// -typedef struct tagSRTSDataF { - u16 wFrameControl; - u16 wDurationID; - u8 abyRA[ETH_ALEN]; - u8 abyTA[ETH_ALEN]; -} SRTSDataF, *PSRTSDataF; - -// -// CTS buffer header -// -typedef struct tagSCTSDataF { - u16 wFrameControl; - u16 wDurationID; - u8 abyRA[ETH_ALEN]; - u16 wReserved; -} SCTSDataF, *PSCTSDataF; - -// -// MICHDR data header -// -typedef struct tagSMICHDR { - u32 adwHDR0[4]; - u32 adwHDR1[4]; - u32 adwHDR2[4]; -} SMICHDR, *PSMICHDR; - -typedef struct tagSTX_NAF_G_RTS -{ - //RsvTime - u16 wRTSTxRrvTime_ba; - u16 wRTSTxRrvTime_aa; - u16 wRTSTxRrvTime_bb; - u16 wReserved2; - u16 wTxRrvTime_b; - u16 wTxRrvTime_a; - - //RTS - u8 byRTSSignalField_b; - u8 byRTSServiceField_b; - u16 wRTSTransmitLength_b; - u8 byRTSSignalField_a; - u8 byRTSServiceField_a; - u16 wRTSTransmitLength_a; - u16 wRTSDuration_ba; - u16 wRTSDuration_aa; - u16 wRTSDuration_bb; - u16 wReserved3; - SRTSDataF sRTS; - - //Data - u8 bySignalField_b; - u8 byServiceField_b; - u16 wTransmitLength_b; - u8 bySignalField_a; - u8 byServiceField_a; - u16 wTransmitLength_a; - u16 wDuration_b; - u16 wDuration_a; - u16 wTimeStampOff_b; - u16 wTimeStampOff_a; - -} TX_NAF_G_RTS, *PTX_NAF_G_RTS; - -typedef struct tagSTX_NAF_G_RTS_MIC -{ - //RsvTime - u16 wRTSTxRrvTime_ba; - u16 wRTSTxRrvTime_aa; - u16 wRTSTxRrvTime_bb; - u16 wReserved2; - u16 wTxRrvTime_b; - u16 wTxRrvTime_a; - - SMICHDR sMICHDR; - - //RTS - u8 byRTSSignalField_b; - u8 byRTSServiceField_b; - u16 wRTSTransmitLength_b; - u8 byRTSSignalField_a; - u8 byRTSServiceField_a; - u16 wRTSTransmitLength_a; - u16 wRTSDuration_ba; - u16 wRTSDuration_aa; - u16 wRTSDuration_bb; - u16 wReserved3; - SRTSDataF sRTS; - - //Data - u8 bySignalField_b; - u8 byServiceField_b; - u16 wTransmitLength_b; - u8 bySignalField_a; - u8 byServiceField_a; - u16 wTransmitLength_a; - u16 wDuration_b; - u16 wDuration_a; - u16 wTimeStampOff_b; - u16 wTimeStampOff_a; - -} TX_NAF_G_RTS_MIC, *PTX_NAF_G_RTS_MIC; - -typedef struct tagSTX_NAF_G_CTS -{ - //RsvTime - u16 wCTSTxRrvTime_ba; - u16 wReserved2; - u16 wTxRrvTime_b; - u16 wTxRrvTime_a; - - //CTS - u8 byCTSSignalField_b; - u8 byCTSServiceField_b; - u16 wCTSTransmitLength_b; - u16 wCTSDuration_ba; - u16 wReserved3; - SCTSDataF sCTS; - - //Data - u8 bySignalField_b; - u8 byServiceField_b; - u16 wTransmitLength_b; - u8 bySignalField_a; - u8 byServiceField_a; - u16 wTransmitLength_a; - u16 wDuration_b; - u16 wDuration_a; - u16 wTimeStampOff_b; - u16 wTimeStampOff_a; - -} TX_NAF_G_CTS, *PTX_NAF_G_CTS; - -typedef struct tagSTX_NAF_G_CTS_MIC -{ - //RsvTime - u16 wCTSTxRrvTime_ba; - u16 wReserved2; - u16 wTxRrvTime_b; - u16 wTxRrvTime_a; - - SMICHDR sMICHDR; - - //CTS - u8 byCTSSignalField_b; - u8 byCTSServiceField_b; - u16 wCTSTransmitLength_b; - u16 wCTSDuration_ba; - u16 wReserved3; - SCTSDataF sCTS; - - //Data - u8 bySignalField_b; - u8 byServiceField_b; - u16 wTransmitLength_b; - u8 bySignalField_a; - u8 byServiceField_a; - u16 wTransmitLength_a; - u16 wDuration_b; - u16 wDuration_a; - u16 wTimeStampOff_b; - u16 wTimeStampOff_a; - -} TX_NAF_G_CTS_MIC, *PTX_NAF_G_CTS_MIC; - -typedef struct tagSTX_NAF_G_BEACON -{ - u16 wFIFOCtl; - u16 wTimeStamp; - - //CTS - u8 byCTSSignalField_b; - u8 byCTSServiceField_b; - u16 wCTSTransmitLength_b; - u16 wCTSDuration_ba; - u16 wReserved1; - SCTSDataF sCTS; - - //Data - u8 bySignalField_a; - u8 byServiceField_a; - u16 wTransmitLength_a; - u16 wDuration_a; - u16 wTimeStampOff_a; - -} TX_NAF_G_BEACON, *PTX_NAF_G_BEACON; - -typedef struct tagSTX_NAF_AB_RTS -{ - //RsvTime - u16 wRTSTxRrvTime_ab; - u16 wTxRrvTime_ab; - - //RTS - u8 byRTSSignalField_ab; - u8 byRTSServiceField_ab; - u16 wRTSTransmitLength_ab; - u16 wRTSDuration_ab; - u16 wReserved2; - SRTSDataF sRTS; - - //Data - u8 bySignalField_ab; - u8 byServiceField_ab; - u16 wTransmitLength_ab; - u16 wDuration_ab; - u16 wTimeStampOff_ab; - -} TX_NAF_AB_RTS, *PTX_NAF_AB_RTS; - -typedef struct tagSTX_NAF_AB_RTS_MIC -{ - //RsvTime - u16 wRTSTxRrvTime_ab; - u16 wTxRrvTime_ab; - - SMICHDR sMICHDR; - - //RTS - u8 byRTSSignalField_ab; - u8 byRTSServiceField_ab; - u16 wRTSTransmitLength_ab; - u16 wRTSDuration_ab; - u16 wReserved2; - SRTSDataF sRTS; - - //Data - u8 bySignalField_ab; - u8 byServiceField_ab; - u16 wTransmitLength_ab; - u16 wDuration_ab; - u16 wTimeStampOff_ab; - -} TX_NAF_AB_RTS_MIC, *PTX_NAF_AB_RTS_MIC; - -typedef struct tagSTX_NAF_AB_CTS -{ - //RsvTime - u16 wReserved2; - u16 wTxRrvTime_ab; - - //Data - u8 bySignalField_ab; - u8 byServiceField_ab; - u16 wTransmitLength_ab; - u16 wDuration_ab; - u16 wTimeStampOff_ab; - -} TX_NAF_AB_CTS, *PTX_NAF_AB_CTS; - -typedef struct tagSTX_NAF_AB_CTS_MIC -{ - //RsvTime - u16 wReserved2; - u16 wTxRrvTime_ab; - - SMICHDR sMICHDR; - - //Data - u8 bySignalField_ab; - u8 byServiceField_ab; - u16 wTransmitLength_ab; - u16 wDuration_ab; - u16 wTimeStampOff_ab; - -} TX_NAF_AB_CTS_MIC, *PTX_NAF_AB_CTS_MIC; - -typedef struct tagSTX_NAF_AB_BEACON -{ - u16 wFIFOCtl; - u16 wTimeStamp; - - //Data - u8 bySignalField_ab; - u8 byServiceField_ab; - u16 wTransmitLength_ab; - u16 wDuration_ab; - u16 wTimeStampOff_ab; - -} TX_NAF_AB_BEACON, *PTX_NAF_AB_BEACON; - -typedef struct tagSTX_AF_G_RTS -{ - //RsvTime - u16 wRTSTxRrvTime_ba; - u16 wRTSTxRrvTime_aa; - u16 wRTSTxRrvTime_bb; - u16 wReserved2; - u16 wTxRrvTime_b; - u16 wTxRrvTime_a; - - //RTS - u8 byRTSSignalField_b; - u8 byRTSServiceField_b; - u16 wRTSTransmitLength_b; - u8 byRTSSignalField_a; - u8 byRTSServiceField_a; - u16 wRTSTransmitLength_a; - u16 wRTSDuration_ba; - u16 wRTSDuration_aa; - u16 wRTSDuration_bb; - u16 wReserved3; - u16 wRTSDuration_ba_f0; - u16 wRTSDuration_aa_f0; - u16 wRTSDuration_ba_f1; - u16 wRTSDuration_aa_f1; - SRTSDataF sRTS; - - //Data - u8 bySignalField_b; - u8 byServiceField_b; - u16 wTransmitLength_b; - u8 bySignalField_a; - u8 byServiceField_a; - u16 wTransmitLength_a; - u16 wDuration_b; - u16 wDuration_a; - u16 wDuration_a_f0; - u16 wDuration_a_f1; - u16 wTimeStampOff_b; - u16 wTimeStampOff_a; - -} TX_AF_G_RTS, *PTX_AF_G_RTS; - -typedef struct tagSTX_AF_G_RTS_MIC -{ - //RsvTime - u16 wRTSTxRrvTime_ba; - u16 wRTSTxRrvTime_aa; - u16 wRTSTxRrvTime_bb; - u16 wReserved2; - u16 wTxRrvTime_b; - u16 wTxRrvTime_a; - - SMICHDR sMICHDR; - - //RTS - u8 byRTSSignalField_b; - u8 byRTSServiceField_b; - u16 wRTSTransmitLength_b; - u8 byRTSSignalField_a; - u8 byRTSServiceField_a; - u16 wRTSTransmitLength_a; - u16 wRTSDuration_ba; - u16 wRTSDuration_aa; - u16 wRTSDuration_bb; - u16 wReserved3; - u16 wRTSDuration_ba_f0; - u16 wRTSDuration_aa_f0; - u16 wRTSDuration_ba_f1; - u16 wRTSDuration_aa_f1; - SRTSDataF sRTS; - - //Data - u8 bySignalField_b; - u8 byServiceField_b; - u16 wTransmitLength_b; - u8 bySignalField_a; - u8 byServiceField_a; - u16 wTransmitLength_a; - u16 wDuration_b; - u16 wDuration_a; - u16 wDuration_a_f0; - u16 wDuration_a_f1; - u16 wTimeStampOff_b; - u16 wTimeStampOff_a; - -} TX_AF_G_RTS_MIC, *PTX_AF_G_RTS_MIC; - -typedef struct tagSTX_AF_G_CTS -{ - //RsvTime - u16 wCTSTxRrvTime_ba; - u16 wReserved2; - u16 wTxRrvTime_b; - u16 wTxRrvTime_a; - - //CTS - u8 byCTSSignalField_b; - u8 byCTSServiceField_b; - u16 wCTSTransmitLength_b; - u16 wCTSDuration_ba; - u16 wReserved3; - u16 wCTSDuration_ba_f0; - u16 wCTSDuration_ba_f1; - SCTSDataF sCTS; - - //Data - u8 bySignalField_b; - u8 byServiceField_b; - u16 wTransmitLength_b; - u8 bySignalField_a; - u8 byServiceField_a; - u16 wTransmitLength_a; - u16 wDuration_b; - u16 wDuration_a; - u16 wDuration_a_f0; - u16 wDuration_a_f1; - u16 wTimeStampOff_b; - u16 wTimeStampOff_a; - -} TX_AF_G_CTS, *PTX_AF_G_CTS; - -typedef struct tagSTX_AF_G_CTS_MIC -{ - //RsvTime - u16 wCTSTxRrvTime_ba; - u16 wReserved2; - u16 wTxRrvTime_b; - u16 wTxRrvTime_a; - - SMICHDR sMICHDR; - - //CTS - u8 byCTSSignalField_b; - u8 byCTSServiceField_b; - u16 wCTSTransmitLength_b; - u16 wCTSDuration_ba; - u16 wReserved3; - u16 wCTSDuration_ba_f0; - u16 wCTSDuration_ba_f1; - SCTSDataF sCTS; - - //Data - u8 bySignalField_b; - u8 byServiceField_b; - u16 wTransmitLength_b; - u8 bySignalField_a; - u8 byServiceField_a; - u16 wTransmitLength_a; - u16 wDuration_b; - u16 wDuration_a; - u16 wDuration_a_f0; - u16 wDuration_a_f1; - u16 wTimeStampOff_b; - u16 wTimeStampOff_a; - -} TX_AF_G_CTS_MIC, *PTX_AF_G_CTS_MIC; - -typedef struct tagSTX_AF_A_RTS -{ - //RsvTime - u16 wRTSTxRrvTime_a; - u16 wTxRrvTime_a; - - //RTS - u8 byRTSSignalField_a; - u8 byRTSServiceField_a; - u16 wRTSTransmitLength_a; - u16 wRTSDuration_a; - u16 wReserved2; - u16 wRTSDuration_a_f0; - u16 wRTSDuration_a_f1; - SRTSDataF sRTS; - - //Data - u8 bySignalField_a; - u8 byServiceField_a; - u16 wTransmitLength_a; - u16 wDuration_a; - u16 wTimeStampOff_a; - u16 wDuration_a_f0; - u16 wDuration_a_f1; - -} TX_AF_A_RTS, *PTX_AF_A_RTS; - -typedef struct tagSTX_AF_A_RTS_MIC -{ - //RsvTime - u16 wRTSTxRrvTime_a; - u16 wTxRrvTime_a; - - SMICHDR sMICHDR; - - //RTS - u8 byRTSSignalField_a; - u8 byRTSServiceField_a; - u16 wRTSTransmitLength_a; - u16 wRTSDuration_a; - u16 wReserved2; - u16 wRTSDuration_a_f0; - u16 wRTSDuration_a_f1; - SRTSDataF sRTS; - - //Data - u8 bySignalField_a; - u8 byServiceField_a; - u16 wTransmitLength_a; - u16 wDuration_a; - u16 wTimeStampOff_a; - u16 wDuration_a_f0; - u16 wDuration_a_f1; - -} TX_AF_A_RTS_MIC, *PTX_AF_A_RTS_MIC; - -typedef struct tagSTX_AF_A_CTS -{ - //RsvTime - u16 wReserved2; - u16 wTxRrvTime_a; - - //Data - u8 bySignalField_a; - u8 byServiceField_a; - u16 wTransmitLength_a; - u16 wDuration_a; - u16 wTimeStampOff_a; - u16 wDuration_a_f0; - u16 wDuration_a_f1; - -} TX_AF_A_CTS, *PTX_AF_A_CTS; - -typedef struct tagSTX_AF_A_CTS_MIC -{ - //RsvTime - u16 wReserved2; - u16 wTxRrvTime_a; - - SMICHDR sMICHDR; - - //Data - u8 bySignalField_a; - u8 byServiceField_a; - u16 wTransmitLength_a; - u16 wDuration_a; - u16 wTimeStampOff_a; - u16 wDuration_a_f0; - u16 wDuration_a_f1; - -} TX_AF_A_CTS_MIC, *PTX_AF_A_CTS_MIC; - -// -// union with all of the TX Buffer Type -// -typedef union tagUTX_BUFFER_CONTAINER -{ - TX_NAF_G_RTS RTS_G; - TX_NAF_G_RTS_MIC RTS_G_MIC; - TX_NAF_G_CTS CTS_G; - TX_NAF_G_CTS_MIC CTS_G_MIC; - //TX_NAF_G_BEACON Beacon_G; - TX_NAF_AB_RTS RTS_AB; - TX_NAF_AB_RTS_MIC RTS_AB_MIC; - TX_NAF_AB_CTS CTS_AB; - TX_NAF_AB_CTS_MIC CTS_AB_MIC; - //TX_NAF_AB_BEACON Beacon_AB; - TX_AF_G_RTS RTS_G_AutoFB; - TX_AF_G_RTS_MIC RTS_G_AutoFB_MIC; - TX_AF_G_CTS CTS_G_AutoFB; - TX_AF_G_CTS_MIC CTS_G_AutoFB_MIC; - TX_AF_A_RTS RTS_A_AutoFB; - TX_AF_A_RTS_MIC RTS_A_AutoFB_MIC; - TX_AF_A_CTS CTS_A_AutoFB; - TX_AF_A_CTS_MIC CTS_A_AutoFB_MIC; - -} TX_BUFFER_CONTAINER, *PTX_BUFFER_CONTAINER; - -// -// Remote NDIS message format -// typedef struct tagSTX_BUFFER { u8 byType; @@ -605,15 +43,8 @@ typedef struct tagSTX_BUFFER u16 wTimeStamp; u16 wFragCtl; u16 wReserved; - - // Actual message - TX_BUFFER_CONTAINER BufferHeader; - } __packed TX_BUFFER, *PTX_BUFFER; -// -// Remote NDIS message format -// typedef struct tagSBEACON_BUFFER { u8 byType; @@ -622,10 +53,6 @@ typedef struct tagSBEACON_BUFFER u16 wFIFOCtl; u16 wTimeStamp; - - // Actual message - TX_BUFFER_CONTAINER BufferHeader; - } __packed BEACON_BUFFER, *PBEACON_BUFFER; void vDMA0_tx_80211(struct vnt_private *, struct sk_buff *skb); -- GitLab From b02ccd5957281b7d2c364e5a34f3260961a691cb Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Tue, 13 Aug 2013 19:59:31 +0100 Subject: [PATCH 635/942] staging: vt6656: rxtx.c s:_uGetDataDuration simplify structure. A value is only returned when bNeedAck is true. Only when byDurType == DATADUR_B is different. Remove switch statement and simplify with if structure. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 50 +++++++---------------------------- 1 file changed, 9 insertions(+), 41 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index c8e3e7e85cbec..a701120e64938 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -389,47 +389,15 @@ static u32 s_uGetDataDuration(struct vnt_private *pDevice, u8 byDurType, { u32 uAckTime = 0; - switch (byDurType) { - - case DATADUR_B: //DATADUR_B - if (bNeedAck) { - uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate); - return (pDevice->uSIFS + uAckTime); - } else { - return 0; - } - break; - - case DATADUR_A: //DATADUR_A - if(bNeedAck){ - uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); - return (pDevice->uSIFS + uAckTime); - } else { - return 0; - } - break; - - case DATADUR_A_F0: //DATADUR_A_F0 - if(bNeedAck){ - uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); - return (pDevice->uSIFS + uAckTime); - } else { - return 0; - } - break; - - case DATADUR_A_F1: //DATADUR_A_F1 - if(bNeedAck){ - uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); - return (pDevice->uSIFS + uAckTime); - } else { - return 0; - } - break; - - default: - break; - } + if (bNeedAck) { + if (byDurType == DATADUR_B) + uAckTime = BBuGetFrameTime(pDevice->byPreambleType, + byPktType, 14, pDevice->byTopCCKBasicRate); + else + uAckTime = BBuGetFrameTime(pDevice->byPreambleType, + byPktType, 14, pDevice->byTopOFDMBasicRate); + return pDevice->uSIFS + uAckTime; + } return 0; } -- GitLab From e34f9dbe8611458941bcdab3f4fae57aff9e0266 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Tue, 13 Aug 2013 20:17:11 +0100 Subject: [PATCH 636/942] staging: vt6656: rxtx.c s_uGetRTSCTSDuration return endian u16 The return value of uGetRTSCTSDuration always needs to be corrected to a u16 little endian corrected value. Some places the endian correction is done on the next line Change uGetRTSCTSDuration return u16 little endian corrected value. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 93 ++++++++++++++++++++++++----------- 1 file changed, 63 insertions(+), 30 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index a701120e64938..9cd4158e627ae 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -136,7 +136,7 @@ static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, static u32 s_uGetDataDuration(struct vnt_private *pDevice, u8 byDurType, u8 byPktType, int bNeedAck); -static unsigned int s_uGetRTSCTSDuration(struct vnt_private *pDevice, +static u16 s_uGetRTSCTSDuration(struct vnt_private *pDevice, u8 byDurType, u32 cbFrameLength, u8 byPktType, u16 wRate, int bNeedAck, u8 byFBOption); @@ -403,7 +403,7 @@ static u32 s_uGetDataDuration(struct vnt_private *pDevice, u8 byDurType, } //byFreqType: 0=>5GHZ 1=>2.4GHZ -static u32 s_uGetRTSCTSDuration(struct vnt_private *pDevice, u8 byDurType, +static u16 s_uGetRTSCTSDuration(struct vnt_private *pDevice, u8 byDurType, u32 cbFrameLength, u8 byPktType, u16 wRate, int bNeedAck, u8 byFBOption) { @@ -486,8 +486,7 @@ static u32 s_uGetRTSCTSDuration(struct vnt_private *pDevice, u8 byDurType, break; } - return uDurTime; - + return cpu_to_le16((u16)uDurTime); } static u32 s_uFillDataHead(struct vnt_private *pDevice, @@ -641,9 +640,15 @@ static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, ); pBuf->wTransmitLength_a = cpu_to_le16(wLen); //Get Duration - pBuf->wDuration_bb = cpu_to_le16((u16)s_uGetRTSCTSDuration(pDevice, RTSDUR_BB, cbFrameLength, PK_TYPE_11B, pDevice->byTopCCKBasicRate, bNeedAck, byFBOption)); //0:RTSDuration_bb, 1:2.4G, 1:CCKData - pBuf->wDuration_aa = cpu_to_le16((u16)s_uGetRTSCTSDuration(pDevice, RTSDUR_AA, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption)); //2:RTSDuration_aa, 1:2.4G, 2,3: 2.4G OFDMData - pBuf->wDuration_ba = cpu_to_le16((u16)s_uGetRTSCTSDuration(pDevice, RTSDUR_BA, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption)); //1:RTSDuration_ba, 1:2.4G, 2,3:2.4G OFDM Data + pBuf->wDuration_bb = s_uGetRTSCTSDuration(pDevice, RTSDUR_BB, + cbFrameLength, PK_TYPE_11B, + pDevice->byTopCCKBasicRate, bNeedAck, byFBOption); + pBuf->wDuration_aa = s_uGetRTSCTSDuration(pDevice, RTSDUR_AA, + cbFrameLength, byPktType, + wCurrentRate, bNeedAck, byFBOption); + pBuf->wDuration_ba = s_uGetRTSCTSDuration(pDevice, RTSDUR_BA, + cbFrameLength, byPktType, + wCurrentRate, bNeedAck, byFBOption); pBuf->data.duration = pBuf->wDuration_aa; /*Get RTS Frame body */ pBuf->data.frame_control = TYPE_CTL_RTS; @@ -671,13 +676,27 @@ static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, ); pBuf->wTransmitLength_a = cpu_to_le16(wLen); //Get Duration - pBuf->wDuration_bb = cpu_to_le16((u16)s_uGetRTSCTSDuration(pDevice, RTSDUR_BB, cbFrameLength, PK_TYPE_11B, pDevice->byTopCCKBasicRate, bNeedAck, byFBOption)); //0:RTSDuration_bb, 1:2.4G, 1:CCKData - pBuf->wDuration_aa = cpu_to_le16((u16)s_uGetRTSCTSDuration(pDevice, RTSDUR_AA, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption)); //2:RTSDuration_aa, 1:2.4G, 2,3:2.4G OFDMData - pBuf->wDuration_ba = cpu_to_le16((u16)s_uGetRTSCTSDuration(pDevice, RTSDUR_BA, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption)); //1:RTSDuration_ba, 1:2.4G, 2,3:2.4G OFDMData - pBuf->wRTSDuration_ba_f0 = cpu_to_le16((u16)s_uGetRTSCTSDuration(pDevice, RTSDUR_BA_F0, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption)); //4:wRTSDuration_ba_f0, 1:2.4G, 1:CCKData - pBuf->wRTSDuration_aa_f0 = cpu_to_le16((u16)s_uGetRTSCTSDuration(pDevice, RTSDUR_AA_F0, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption)); //5:wRTSDuration_aa_f0, 1:2.4G, 1:CCKData - pBuf->wRTSDuration_ba_f1 = cpu_to_le16((u16)s_uGetRTSCTSDuration(pDevice, RTSDUR_BA_F1, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption)); //6:wRTSDuration_ba_f1, 1:2.4G, 1:CCKData - pBuf->wRTSDuration_aa_f1 = cpu_to_le16((u16)s_uGetRTSCTSDuration(pDevice, RTSDUR_AA_F1, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption)); //7:wRTSDuration_aa_f1, 1:2.4G, 1:CCKData + pBuf->wDuration_bb = s_uGetRTSCTSDuration(pDevice, RTSDUR_BB, + cbFrameLength, PK_TYPE_11B, + pDevice->byTopCCKBasicRate, bNeedAck, byFBOption); + pBuf->wDuration_aa = s_uGetRTSCTSDuration(pDevice, RTSDUR_AA, + cbFrameLength, byPktType, + wCurrentRate, bNeedAck, byFBOption); + pBuf->wDuration_ba = s_uGetRTSCTSDuration(pDevice, RTSDUR_BA, + cbFrameLength, byPktType, + wCurrentRate, bNeedAck, byFBOption); + pBuf->wRTSDuration_ba_f0 = s_uGetRTSCTSDuration(pDevice, + RTSDUR_BA_F0, cbFrameLength, byPktType, wCurrentRate, + bNeedAck, byFBOption); + pBuf->wRTSDuration_aa_f0 = s_uGetRTSCTSDuration(pDevice, + RTSDUR_AA_F0, cbFrameLength, byPktType, + wCurrentRate, bNeedAck, byFBOption); + pBuf->wRTSDuration_ba_f1 = s_uGetRTSCTSDuration(pDevice, + RTSDUR_BA_F1, cbFrameLength, byPktType, wCurrentRate, + bNeedAck, byFBOption); + pBuf->wRTSDuration_aa_f1 = s_uGetRTSCTSDuration(pDevice, + RTSDUR_AA_F1, cbFrameLength, byPktType, wCurrentRate, + bNeedAck, byFBOption); pBuf->data.duration = pBuf->wDuration_aa; /*Get RTS Frame body*/ pBuf->data.frame_control = TYPE_CTL_RTS; @@ -703,7 +722,9 @@ static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, ); pBuf->wTransmitLength = cpu_to_le16(wLen); //Get Duration - pBuf->wDuration = cpu_to_le16((u16)s_uGetRTSCTSDuration(pDevice, RTSDUR_AA, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption)); //0:RTSDuration_aa, 0:5G, 0: 5G OFDMData + pBuf->wDuration = s_uGetRTSCTSDuration(pDevice, RTSDUR_AA, + cbFrameLength, byPktType, wCurrentRate, + bNeedAck, byFBOption); pBuf->data.duration = pBuf->wDuration; /* Get RTS Frame body */ pBuf->data.frame_control = TYPE_CTL_RTS; @@ -727,9 +748,15 @@ static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, ); pBuf->wTransmitLength = cpu_to_le16(wLen); //Get Duration - pBuf->wDuration = cpu_to_le16((u16)s_uGetRTSCTSDuration(pDevice, RTSDUR_AA, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption)); //0:RTSDuration_aa, 0:5G, 0: 5G OFDMData - pBuf->wRTSDuration_f0 = cpu_to_le16((u16)s_uGetRTSCTSDuration(pDevice, RTSDUR_AA_F0, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption)); //5:RTSDuration_aa_f0, 0:5G, 0: 5G OFDMData - pBuf->wRTSDuration_f1 = cpu_to_le16((u16)s_uGetRTSCTSDuration(pDevice, RTSDUR_AA_F1, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption)); //7:RTSDuration_aa_f1, 0:5G, 0: + pBuf->wDuration = s_uGetRTSCTSDuration(pDevice, RTSDUR_AA, + cbFrameLength, byPktType, wCurrentRate, + bNeedAck, byFBOption); + pBuf->wRTSDuration_f0 = s_uGetRTSCTSDuration(pDevice, + RTSDUR_AA_F0, cbFrameLength, byPktType, + wCurrentRate, bNeedAck, byFBOption); + pBuf->wRTSDuration_f1 = s_uGetRTSCTSDuration(pDevice, + RTSDUR_AA_F1, cbFrameLength, byPktType, + wCurrentRate, bNeedAck, byFBOption); pBuf->data.duration = pBuf->wDuration; /* Get RTS Frame body */ pBuf->data.frame_control = TYPE_CTL_RTS; @@ -754,7 +781,9 @@ static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, ); pBuf->wTransmitLength = cpu_to_le16(wLen); //Get Duration - pBuf->wDuration = cpu_to_le16((u16)s_uGetRTSCTSDuration(pDevice, RTSDUR_BB, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption)); //0:RTSDuration_bb, 1:2.4G, 1:CCKData + pBuf->wDuration = s_uGetRTSCTSDuration(pDevice, RTSDUR_BB, + cbFrameLength, byPktType, wCurrentRate, + bNeedAck, byFBOption); pBuf->data.duration = pBuf->wDuration; /* Get RTS Frame body */ @@ -799,14 +828,17 @@ static void s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx, (u16 *)&(wLen), (u8 *)&(pBuf->byServiceField_b), (u8 *)&(pBuf->bySignalField_b) ); pBuf->wTransmitLength_b = cpu_to_le16(wLen); - pBuf->wDuration_ba = (u16)s_uGetRTSCTSDuration(pDevice, CTSDUR_BA, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption); //3:CTSDuration_ba, 1:2.4G, 2,3:2.4G OFDM Data - pBuf->wDuration_ba = cpu_to_le16(pBuf->wDuration_ba); - //Get CTSDuration_ba_f0 - pBuf->wCTSDuration_ba_f0 = (u16)s_uGetRTSCTSDuration(pDevice, CTSDUR_BA_F0, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption); //8:CTSDuration_ba_f0, 1:2.4G, 2,3:2.4G OFDM Data - pBuf->wCTSDuration_ba_f0 = cpu_to_le16(pBuf->wCTSDuration_ba_f0); - //Get CTSDuration_ba_f1 - pBuf->wCTSDuration_ba_f1 = (u16)s_uGetRTSCTSDuration(pDevice, CTSDUR_BA_F1, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption); //9:CTSDuration_ba_f1, 1:2.4G, 2,3:2.4G OFDM Data - pBuf->wCTSDuration_ba_f1 = cpu_to_le16(pBuf->wCTSDuration_ba_f1); + pBuf->wDuration_ba = s_uGetRTSCTSDuration(pDevice, CTSDUR_BA, + cbFrameLength, byPktType, + wCurrentRate, bNeedAck, byFBOption); + /* Get CTSDuration_ba_f0 */ + pBuf->wCTSDuration_ba_f0 = s_uGetRTSCTSDuration(pDevice, + CTSDUR_BA_F0, cbFrameLength, byPktType, wCurrentRate, + bNeedAck, byFBOption); + /* Get CTSDuration_ba_f1 */ + pBuf->wCTSDuration_ba_f1 = s_uGetRTSCTSDuration(pDevice, + CTSDUR_BA_F1, cbFrameLength, byPktType, wCurrentRate, + bNeedAck, byFBOption); /* Get CTS Frame body */ pBuf->data.duration = pBuf->wDuration_ba; pBuf->data.frame_control = TYPE_CTL_CTS; @@ -818,9 +850,10 @@ static void s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx, (u16 *)&(wLen), (u8 *)&(pBuf->byServiceField_b), (u8 *)&(pBuf->bySignalField_b) ); pBuf->wTransmitLength_b = cpu_to_le16(wLen); - //Get CTSDuration_ba - pBuf->wDuration_ba = cpu_to_le16((u16)s_uGetRTSCTSDuration(pDevice, CTSDUR_BA, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption)); //3:CTSDuration_ba, 1:2.4G, 2,3:2.4G OFDM Data - pBuf->wDuration_ba = cpu_to_le16(pBuf->wDuration_ba); + /* Get CTSDuration_ba */ + pBuf->wDuration_ba = s_uGetRTSCTSDuration(pDevice, + CTSDUR_BA, cbFrameLength, byPktType, + wCurrentRate, bNeedAck, byFBOption); /*Get CTS Frame body*/ pBuf->data.duration = pBuf->wDuration_ba; pBuf->data.frame_control = TYPE_CTL_CTS; -- GitLab From 41506a9f83c5ef8abda07d205c52b9e35d6d229a Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Tue, 13 Aug 2013 13:55:48 -0700 Subject: [PATCH 637/942] drivers/staging/comedi/drivers/das16.c: needs slab.h alpha allmodconfig: drivers/staging/comedi/drivers/das16.c: In function 'das16_detach': drivers/staging/comedi/drivers/das16.c:1234: error: implicit declaration of function 'kfree' Cc: Ian Abbott Reviewed-by: H Hartley Sweeten Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das16.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index 93a8f09173aa1..1b0793f33b9f1 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -81,6 +81,7 @@ */ #include +#include #include #include #include -- GitLab From 35cf90459312fc3b6bc4bbf31aa5fe47b73922d4 Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Thu, 15 Aug 2013 10:28:22 -0400 Subject: [PATCH 638/942] staging: dgnc: removes proc code This patch removes the dgnc_proc.c and dgnc_proc.h files and all references to proc functions in dgnc_driver.c. This also removes proc.h from the include headers in driver.c, mgmt.c and sysfs.c and proc.o from the Makefile. Drivers now use sysfs instead of proc. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/Makefile | 2 +- drivers/staging/dgnc/dgnc_driver.c | 10 - drivers/staging/dgnc/dgnc_mgmt.c | 1 - drivers/staging/dgnc/dgnc_proc.c | 1550 ---------------------------- drivers/staging/dgnc/dgnc_proc.h | 147 --- drivers/staging/dgnc/dgnc_sysfs.c | 1 - 6 files changed, 1 insertion(+), 1710 deletions(-) delete mode 100644 drivers/staging/dgnc/dgnc_proc.c delete mode 100644 drivers/staging/dgnc/dgnc_proc.h diff --git a/drivers/staging/dgnc/Makefile b/drivers/staging/dgnc/Makefile index c4c96dc5a5414..888c4334236b0 100644 --- a/drivers/staging/dgnc/Makefile +++ b/drivers/staging/dgnc/Makefile @@ -4,4 +4,4 @@ obj-$(CONFIG_DGNC) += dgnc.o dgnc-objs := dgnc_cls.o dgnc_driver.o\ dgnc_mgmt.o dgnc_neo.o\ - dgnc_proc.o dgnc_trace.o dgnc_tty.o dgnc_sysfs.o + dgnc_trace.o dgnc_tty.o dgnc_sysfs.o diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c index 7c88de7737453..e8de7a411255f 100644 --- a/drivers/staging/dgnc/dgnc_driver.c +++ b/drivers/staging/dgnc/dgnc_driver.c @@ -43,7 +43,6 @@ #include "dgnc_driver.h" #include "dgnc_pci.h" -#include "dgnc_proc.h" #include "dpacompat.h" #include "dgnc_mgmt.h" #include "dgnc_tty.h" @@ -312,11 +311,6 @@ static int dgnc_start(void) dgnc_Major_Control_Registered = TRUE; } - /* - * Register our basic stuff in /proc/dgnc - */ - dgnc_proc_register_basic_prescan(); - /* * Init any global tty stuff. */ @@ -401,8 +395,6 @@ void dgnc_cleanup_module(void) /* Turn off poller right away. */ del_timer_sync(&dgnc_poll_timer); - dgnc_proc_unregister_all(); - dgnc_remove_driver_sysfiles(&dgnc_driver); if (dgnc_Major_Control_Registered) { @@ -742,8 +734,6 @@ static int dgnc_found_board(struct pci_dev *pdev, int id) */ brd->flipbuf = dgnc_driver_kzmalloc(MYFLIPLEN, GFP_KERNEL); - dgnc_proc_register_basic_postscan(dgnc_NumBoards); - wake_up_interruptible(&brd->state_wait); return(0); diff --git a/drivers/staging/dgnc/dgnc_mgmt.c b/drivers/staging/dgnc/dgnc_mgmt.c index 96cf58b31322e..bbd65db524cd1 100644 --- a/drivers/staging/dgnc/dgnc_mgmt.c +++ b/drivers/staging/dgnc/dgnc_mgmt.c @@ -47,7 +47,6 @@ #include "dgnc_driver.h" #include "dgnc_pci.h" -#include "dgnc_proc.h" #include "dgnc_kcompat.h" /* Kernel 2.4/2.6 compat includes */ #include "dgnc_mgmt.h" #include "dpacompat.h" diff --git a/drivers/staging/dgnc/dgnc_proc.c b/drivers/staging/dgnc/dgnc_proc.c deleted file mode 100644 index c59c833f5e05a..0000000000000 --- a/drivers/staging/dgnc/dgnc_proc.c +++ /dev/null @@ -1,1550 +0,0 @@ -/* - * Copyright 2003 Digi International (www.digi.com) - * Scott H Kilau - * - * 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, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * - * NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE! - * - * This is shared code between Digi's CVS archive and the - * Linux Kernel sources. - * Changing the source just for reformatting needlessly breaks - * our CVS diff history. - * - * Send any bug fixes/changes to: Eng.Linux at digi dot com. - * Thank you. - * - * - * $Id: dgnc_proc.c,v 1.3 2011/06/22 12:16:35 markh Exp $ - */ - -#include -#include -#include /* For jiffies, task states */ -#include /* For tasklet and interrupt structs/defines */ -#include -#include -#include -#include -#include -#include /* For copy_from_user/copy_to_user */ - -#include "dgnc_driver.h" -#include "dgnc_proc.h" -#include "dgnc_mgmt.h" - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37) -#define init_MUTEX(sem) sema_init(sem, 1) -#define DECLARE_MUTEX(name) \ - struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) -#endif - - -/* The /proc/dgnc directory */ -static struct proc_dir_entry *ProcDGNC; - - -/* File operation declarations */ -static int dgnc_gen_proc_open(struct inode *, struct file *); -static int dgnc_gen_proc_close(struct inode *, struct file *); -static ssize_t dgnc_gen_proc_read(struct file *file, char __user *buf, size_t count, loff_t *ppos); -static ssize_t dgnc_gen_proc_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos); - -static int dgnc_proc_chk_perm(struct inode *, int); - -static const struct file_operations dgnc_proc_file_ops = -{ - .owner = THIS_MODULE, - .read = dgnc_gen_proc_read, /* read */ - .write = dgnc_gen_proc_write, /* write */ - .open = dgnc_gen_proc_open, /* open */ - .release = dgnc_gen_proc_close, /* release */ -}; - - -static struct inode_operations dgnc_proc_inode_ops = -{ - .permission = dgnc_proc_chk_perm -}; - - -static void dgnc_register_proc_table(struct dgnc_proc_entry *, struct proc_dir_entry *); -static void dgnc_unregister_proc_table(struct dgnc_proc_entry *, struct proc_dir_entry *); -static void dgnc_remove_proc_entry(struct proc_dir_entry *pde); - - -/* Stuff in /proc/ */ -static int dgnc_read_info(struct dgnc_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos); -static int dgnc_write_info(struct dgnc_proc_entry *table, int dir, struct file *filp, - const char __user *buffer, ssize_t *lenp, loff_t *ppos); - -static int dgnc_read_mknod(struct dgnc_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos); - -static struct dgnc_proc_entry dgnc_table[] = { - {DGNC_INFO, "info", 0600, NULL, NULL, NULL, &dgnc_read_info, &dgnc_write_info, - NULL, __SEMAPHORE_INITIALIZER(dgnc_table[0].excl_sem, 1), 0, NULL }, - {DGNC_MKNOD, "mknod", 0600, NULL, NULL, NULL, &dgnc_read_mknod, NULL, - NULL, __SEMAPHORE_INITIALIZER(dgnc_table[1].excl_sem, 1), 0, NULL }, - {0} -}; - - -/* Stuff in /proc// */ -static int dgnc_read_board_info(struct dgnc_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos); -static int dgnc_read_board_vpd(struct dgnc_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos); -static int dgnc_read_board_mknod(struct dgnc_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos); -static int dgnc_read_board_ttystats(struct dgnc_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos); -static int dgnc_read_board_ttyintr(struct dgnc_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos); -static int dgnc_read_board_ttyflags(struct dgnc_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos); - -static struct dgnc_proc_entry dgnc_board_table[] = { - {DGNC_BOARD_INFO, "info", 0600, NULL, NULL, NULL, &dgnc_read_board_info, NULL, - NULL, __SEMAPHORE_INITIALIZER(dgnc_board_table[0].excl_sem, 1), 0, NULL }, - {DGNC_BOARD_VPD, "vpd", 0600, NULL, NULL, NULL, &dgnc_read_board_vpd, NULL, - NULL, __SEMAPHORE_INITIALIZER(dgnc_board_table[1].excl_sem, 1), 0, NULL }, - {DGNC_BOARD_TTYSTATS, "stats", 0600, NULL, NULL, NULL, &dgnc_read_board_ttystats, NULL, - NULL, __SEMAPHORE_INITIALIZER(dgnc_board_table[2].excl_sem, 1), 0, NULL }, - {DGNC_BOARD_TTYINTR, "intr", 0600, NULL, NULL, NULL, &dgnc_read_board_ttyintr, NULL, - NULL, __SEMAPHORE_INITIALIZER(dgnc_board_table[3].excl_sem, 1), 0, NULL }, - {DGNC_BOARD_TTYFLAGS, "flags", 0600, NULL, NULL, NULL, &dgnc_read_board_ttyflags, NULL, - NULL, __SEMAPHORE_INITIALIZER(dgnc_board_table[4].excl_sem, 1), 0, NULL }, - {DGNC_BOARD_MKNOD, "mknod", 0600, NULL, NULL, NULL, &dgnc_read_board_mknod, NULL, - NULL, __SEMAPHORE_INITIALIZER(dgnc_board_table[5].excl_sem, 1), 0, NULL }, - {0} -}; - - -/* Stuff in /proc// */ -static int dgnc_read_channel_info(struct dgnc_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos); -static int dgnc_open_channel_sniff(struct dgnc_proc_entry *table, int dir, struct file *filp, - void *buffer, ssize_t *lenp, loff_t *ppos); -static int dgnc_close_channel_sniff(struct dgnc_proc_entry *table, int dir, struct file *filp, - void *buffer, ssize_t *lenp, loff_t *ppos); -static int dgnc_read_channel_sniff(struct dgnc_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos); -static int dgnc_read_channel_custom_ttyname(struct dgnc_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos); -static int dgnc_read_channel_custom_prname(struct dgnc_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos); - -static struct dgnc_proc_entry dgnc_channel_table[] = { - {DGNC_PORT_INFO, "info", 0600, NULL, NULL, NULL, &dgnc_read_channel_info, NULL, - NULL, __SEMAPHORE_INITIALIZER(dgnc_channel_table[0].excl_sem, 1), 0, NULL }, - {DGNC_PORT_SNIFF, "sniff", 0600, NULL, &dgnc_open_channel_sniff, &dgnc_close_channel_sniff, &dgnc_read_channel_sniff, NULL, - NULL, __SEMAPHORE_INITIALIZER(dgnc_channel_table[1].excl_sem, 1), 0, NULL}, - {DGNC_PORT_CUSTOM_TTYNAME, "ttyname", 0600, NULL, NULL, NULL, &dgnc_read_channel_custom_ttyname, NULL, - NULL, __SEMAPHORE_INITIALIZER(dgnc_channel_table[2].excl_sem, 1), 0, NULL }, - {DGNC_PORT_CUSTOM_PRNAME, "prname", 0600, NULL, NULL, NULL, &dgnc_read_channel_custom_prname, NULL, - NULL, __SEMAPHORE_INITIALIZER(dgnc_channel_table[3].excl_sem, 1), 0, NULL }, - {0} -}; - - -/* - * dgnc_test_perm does NOT grant the superuser all rights automatically, because - * some entries are readonly even to root. - */ -static inline int dgnc_test_perm(int mode, int op) -{ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) - if (!current->euid) -#else - if (!current_euid()) -#endif - mode >>= 6; - else if (in_egroup_p(0)) - mode >>= 3; - if ((mode & op & 0007) == op) - return 0; - if (capable(CAP_SYS_ADMIN)) - return 0; - return -EACCES; -} - - -/* - * /proc/sys support - */ -static inline int dgnc_proc_match(int len, const char *name, struct proc_dir_entry *de) -{ - if (!de || !de->low_ino) - return 0; - if (de->namelen != len) - return 0; - return !memcmp(name, de->name, len); -} - - -/* - * Scan the entries in table and add them all to /proc at the position - * referred to by "root" - */ -static void dgnc_register_proc_table(struct dgnc_proc_entry *table, struct proc_dir_entry *root) -{ - struct proc_dir_entry *de; - int len; - mode_t mode; - - for (; table->magic; table++) { - /* Can't do anything without a proc name. */ - if (!table->name) { - DPR_PROC(("dgnc_register_proc_table, no name...\n")); - continue; - } - - /* Maybe we can't do anything with it... */ - if (!table->read_handler && !table->write_handler && !table->child) { - DPR_PROC((KERN_WARNING "DGNC PROC: Can't register %s\n", table->name)); - continue; - } - - len = strlen(table->name); - mode = table->mode; - de = NULL; - - if (!table->child) { - mode |= S_IFREG; - } else { - mode |= S_IFDIR; - for (de = root->subdir; de; de = de->next) { - if (dgnc_proc_match(len, table->name, de)) - break; - } - - /* If the subdir exists already, de is non-NULL */ - } - - if (!de) { - de = create_proc_entry(table->name, mode, root); - if (!de) - continue; - de->data = (void *) table; - if (!table->child) { - de->proc_iops = &dgnc_proc_inode_ops; - de->proc_fops = &dgnc_proc_file_ops; - } - } - - table->de = de; - - if (de->mode & S_IFDIR) - dgnc_register_proc_table(table->child, de); - - } -} - - - -/* - * Unregister a /proc sysctl table and any subdirectories. - */ -static void dgnc_unregister_proc_table(struct dgnc_proc_entry *table, struct proc_dir_entry *root) -{ - struct proc_dir_entry *de; - - for (; table->magic; table++) { - if (!(de = table->de)) - continue; - - if (de->mode & S_IFDIR) { - if (!table->child) { - DPR_PROC((KERN_ALERT "Help - malformed sysctl tree on free\n")); - continue; - } - - /* recurse down into subdirectory... */ - DPR_PROC(("Recursing down a directory...\n")); - dgnc_unregister_proc_table(table->child, de); - - /* Don't unregister directories which still have entries.. */ - if (de->subdir) - continue; - } - - /* Don't unregister proc entries that are still being used.. */ - if ((atomic_read(&de->count)) != 1) { - DPR_PROC(("proc entry in use... Not removing...\n")); - continue; - } - - dgnc_remove_proc_entry(de); - table->de = NULL; - } -} - - - -static int dgnc_gen_proc_open(struct inode *inode, struct file *file) -{ - struct proc_dir_entry *de; - struct dgnc_proc_entry *entry; - int (*handler) (struct dgnc_proc_entry *table, int dir, struct file *filp, - void *buffer, ssize_t *lenp, loff_t *ppos); - int ret = 0, error = 0; - - de = (struct proc_dir_entry *) PDE(file->f_dentry->d_inode); - if (!de || !de->data) { - ret = -ENXIO; - goto done; - } - - entry = (struct dgnc_proc_entry *) de->data; - if (!entry) { - ret = -ENXIO; - goto done; - } - - down(&entry->excl_sem); - - if (entry->excl_cnt) { - ret = -EBUSY; - } else { - entry->excl_cnt++; - - handler = entry->open_handler; - if (handler) { - error = (*handler) (entry, OUTBOUND, file, NULL, NULL, NULL); - if (error) { - entry->excl_cnt--; - ret = error; - } - } - } - - up(&entry->excl_sem); - -done: - - return ret; -} - - -static int dgnc_gen_proc_close(struct inode *inode, struct file *file) -{ - struct proc_dir_entry *de; - int (*handler) (struct dgnc_proc_entry *table, int dir, struct file *filp, - void *buffer, ssize_t *lenp, loff_t *ppos); - struct dgnc_proc_entry *entry; - int error = 0; - - de = (struct proc_dir_entry *) PDE(file->f_dentry->d_inode); - if (!de || !de->data) - goto done; - - entry = (struct dgnc_proc_entry *) de->data; - if (!entry) - goto done; - - down(&entry->excl_sem); - - if (entry->excl_cnt) - entry->excl_cnt = 0; - - - handler = entry->close_handler; - if (handler) { - error = (*handler) (entry, OUTBOUND, file, NULL, NULL, NULL); - } - - up(&entry->excl_sem); - -done: - return 0; -} - - -static ssize_t dgnc_gen_proc_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) -{ - struct proc_dir_entry *de; - struct dgnc_proc_entry *entry; - int (*handler) (struct dgnc_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos2); - ssize_t res; - ssize_t error; - - de = (struct proc_dir_entry*) PDE(file->f_dentry->d_inode); - if (!de || !de->data) - return -ENXIO; - - entry = (struct dgnc_proc_entry *) de->data; - if (!entry) - return -ENXIO; - - /* Test for read permission */ - if (dgnc_test_perm(entry->mode, 4)) - return -EPERM; - - res = count; - - handler = entry->read_handler; - if (!handler) - return -ENXIO; - - error = (*handler) (entry, OUTBOUND, file, buf, &res, ppos); - if (error) - return error; - - return res; -} - - -static ssize_t dgnc_gen_proc_write(struct file *file, const char __user *buf, - size_t count, loff_t *ppos) -{ - struct proc_dir_entry *de; - struct dgnc_proc_entry *entry; - int (*handler) (struct dgnc_proc_entry *table, int dir, struct file *filp, - const char __user *buffer, ssize_t *lenp, loff_t *ppos2); - ssize_t res; - ssize_t error; - - de = (struct proc_dir_entry *) PDE(file->f_dentry->d_inode); - if (!de || !de->data) - return -ENXIO; - - entry = (struct dgnc_proc_entry *) de->data; - if (!entry) - return -ENXIO; - - /* Test for write permission */ - if (dgnc_test_perm(entry->mode, 2)) - return -EPERM; - - res = count; - - handler = entry->write_handler; - if (!handler) - return -ENXIO; - - error = (*handler) (entry, INBOUND, file, buf, &res, ppos); - if (error) - return error; - - return res; -} - - -static int dgnc_proc_chk_perm(struct inode *inode, int op) -{ - return dgnc_test_perm(inode->i_mode, op); -} - - -/* - * Return what is (hopefully) useful information about the - * driver. - */ -static int dgnc_read_info(struct dgnc_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos) -{ - static int done = 0; - static char buf[4096]; - char *p = buf; - - DPR_PROC(("dgnc_proc_info\n")); - - if (done) { - done = 0; - *lenp = 0; - return 0; - } - - p += sprintf(p, "Driver:\t\t%s\n", DG_NAME); - p += sprintf(p, "\n"); - p += sprintf(p, "Debug:\t\t0x%x\n", dgnc_debug); - p += sprintf(p, "Sysfs Support:\t0x1\n"); - p += sprintf(p, "Rawreadok:\t0x%x\n", dgnc_rawreadok); - p += sprintf(p, "Max Boards:\t%d\n", MAXBOARDS); - p += sprintf(p, "Total Boards:\t%d\n", dgnc_NumBoards); - p += sprintf(p, "Poll rate:\t%dms\n", dgnc_poll_tick); - p += sprintf(p, "Poll counter:\t%ld\n", dgnc_poll_counter); - p += sprintf(p, "State:\t\t%s\n", dgnc_driver_state_text[dgnc_driver_state]); - - if (copy_to_user(buffer, buf, (p - (char *) buf))) - return -EFAULT; - - *lenp = p - (char *) buf; - *ppos += p - (char *) buf; - done = 1; - return 0; -} - - -/* - * When writing to the "info" entry point, I actually allow one - * to modify certain variables. This may be a sleazy overload - * of this /proc entry, but I don't want: - * - * a. to clutter /proc more than I have to - * b. to overload the "config" entry, which would be somewhat - * more natural - * c. necessarily advertise the fact this ability exists - * - * The continued support of this feature has not yet been - * guaranteed. - * - * Writing operates on a "state machine" principle. - * - * State 0: waiting for a symbol to start. Waiting for anything - * which isn't " ' = or whitespace. - * State 1: reading a symbol. If the character is a space, move - * to state 2. If =, move to state 3. If " or ', move - * to state 0. - * State 2: Waiting for =... suck whitespace. If anything other - * than whitespace, drop to state 0. - * State 3: Got =. Suck whitespace waiting for value to start. - * If " or ', go to state 4 (and remember which quote it - * was). Otherwise, go to state 5. - * State 4: Reading value, within quotes. Everything is added to - * value up until the matching quote. When you hit the - * matching quote, try to set the variable, then state 0. - * State 5: Reading value, outside quotes. Everything not " ' = - * or whitespace goes in value. Hitting one of the - * terminators tosses us back to state 0 after trying to - * set the variable. - */ -typedef enum { - INFO_NONE, INFO_INT, INFO_CHAR, INFO_SHORT, - INFO_LONG, INFO_PTR, INFO_STRING, INFO_END -} info_proc_var_val; - -static struct { - char *name; - info_proc_var_val type; - int rw; /* 0=readonly */ - void *val_ptr; -} dgnc_info_vars[] = { - { "rawreadok", INFO_INT, 1, (void *) &dgnc_rawreadok }, - { "pollrate", INFO_INT, 1, (void *) &dgnc_poll_tick }, - { NULL, INFO_NONE, 0, NULL }, - { "debug", INFO_LONG, 1, (void *) &dgnc_debug }, - { NULL, INFO_END, 0, NULL } -}; - -static void dgnc_set_info_var(char *name, char *val) -{ - int i; - unsigned long newval; - unsigned char charval; - unsigned short shortval; - unsigned int intval; - - for (i = 0; dgnc_info_vars[i].type != INFO_END; i++) { - if (dgnc_info_vars[i].name) - if (!strcmp(name, dgnc_info_vars[i].name)) - break; - } - - if (dgnc_info_vars[i].type == INFO_END) - return; - if (dgnc_info_vars[i].rw == 0) - return; - if (dgnc_info_vars[i].val_ptr == NULL) - return; - - newval = simple_strtoul(val, NULL, 0 ); - - switch (dgnc_info_vars[i].type) { - case INFO_CHAR: - charval = newval & 0xff; - APR(("Modifying %s (%lx) <= 0x%02x (%d)\n", - name, (long)(dgnc_info_vars[i].val_ptr ), - charval, charval)); - *(uchar *)(dgnc_info_vars[i].val_ptr) = charval; - break; - case INFO_SHORT: - shortval = newval & 0xffff; - APR(("Modifying %s (%lx) <= 0x%04x (%d)\n", - name, (long)(dgnc_info_vars[i].val_ptr), - shortval, shortval)); - *(ushort *)(dgnc_info_vars[i].val_ptr) = shortval; - break; - case INFO_INT: - intval = newval & 0xffffffff; - APR(("Modifying %s (%lx) <= 0x%08x (%d)\n", - name, (long)(dgnc_info_vars[i].val_ptr), - intval, intval)); - *(uint *)(dgnc_info_vars[i].val_ptr) = intval; - break; - case INFO_LONG: - APR(("Modifying %s (%lx) <= 0x%lx (%ld)\n", - name, (long)(dgnc_info_vars[i].val_ptr), - newval, newval)); - *(ulong *)(dgnc_info_vars[i].val_ptr) = newval; - break; - case INFO_PTR: - case INFO_STRING: - case INFO_END: - case INFO_NONE: - default: - break; - } -} - -static int dgnc_write_info(struct dgnc_proc_entry *table, int dir, struct file *filp, - const char __user *buffer, ssize_t *lenp, loff_t *ppos) -{ - static int state = 0; - #define MAXSYM 255 - static int sympos, valpos; - static char sym[MAXSYM + 1]; - static char val[MAXSYM + 1]; - static int quotchar = 0; - - int i; - - long len; - #define INBUFLEN 256 - char inbuf[INBUFLEN]; - - if (*ppos == 0) { - state = 0; - sympos = 0; sym[0] = 0; - valpos = 0; val[0] = 0; - quotchar = 0; - } - - if ((!*lenp) || (dir != INBOUND)) { - *lenp = 0; - return 0; - } - - len = *lenp; - - if (len > INBUFLEN - 1) - len = INBUFLEN - 1; - - if (copy_from_user(inbuf, buffer, len)) - return -EFAULT; - - inbuf[len] = 0; - - for (i = 0; i < len; i++) { - unsigned char c = inbuf[i]; - - switch (state) { - case 0: - quotchar = sympos = valpos = sym[0] = val[0] = 0; - if (!isspace(c) && (c != '\"') && - (c != '\'') && (c != '=')) { - sym[sympos++] = c; - state = 1; - break; - } - break; - case 1: - if (isspace(c)) { - sym[sympos] = 0; - state = 2; - break; - } - if (c == '=') { - sym[sympos] = 0; - state = 3; - break; - } - if ((c == '\"' ) || ( c == '\'' )) { - state = 0; - break; - } - if (sympos < MAXSYM) sym[sympos++] = c; - break; - case 2: - if (isspace(c)) break; - if (c == '=') { - state = 3; - break; - } - if ((c != '\"') && (c != '\'')) { - quotchar = sympos = valpos = sym[0] = val[0] = 0; - sym[sympos++] = c; - state = 1; - break; - } - state = 0; - break; - case 3: - if (isspace(c)) break; - if (c == '=') { - state = 0; - break; - } - if ((c == '\"') || (c == '\'')) { - state = 4; - quotchar = c; - break; - } - val[valpos++] = c; - state = 5; - break; - case 4: - if (c == quotchar) { - val[valpos] = 0; - dgnc_set_info_var(sym, val); - state = 0; - break; - } - if (valpos < MAXSYM) val[valpos++] = c; - break; - case 5: - if (isspace(c) || (c == '\"') || - (c == '\'') || (c == '=')) { - val[valpos] = 0; - dgnc_set_info_var(sym, val); - state = 0; - break; - } - if (valpos < MAXSYM) val[valpos++] = c; - break; - default: - break; - } - } - - *lenp = len; - *ppos += len; - - return len; -} - - -/* - * Return mknod information for the driver's devices. - */ -static int dgnc_read_mknod(struct dgnc_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos) -{ - static int done = 0; - static char buf[4096]; - char *p = buf; - int i = 0; - - DPR_PROC(("dgnc_proc_info\n")); - - if (done) { - done = 0; - *lenp = 0; - return 0; - } - - DPR_PROC(("dgnc_proc_mknod\n")); - - p += sprintf(p, "#\tCreate the management devices.\n"); - - for (i = 0; i < MAXMGMTDEVICES; i++) { - char tmp[100]; - sprintf(tmp, "/dev/dg/dgnc/mgmt%d", i); - p += sprintf(p, "%s\t%d\t%d\t%d\n", - tmp, dgnc_Major, i, 1); - } - - if (copy_to_user(buffer, buf, (p - (char *) buf))) - return -EFAULT; - - *lenp = p - (char *) buf; - *ppos += p - (char *) buf; - done = 1; - return 0; -} - - -/* - * Return what is (hopefully) useful information about the specific board. - */ -static int dgnc_read_board_info(struct dgnc_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos) -{ - struct board_t *brd; - static int done = 0; - static char buf[4096]; - char *p = buf; - char *name; - - DPR_PROC(("dgnc_proc_brd_info\n")); - - brd = (struct board_t *) table->data; - - if (done || !brd || (brd->magic != DGNC_BOARD_MAGIC)) { - done = 0; - *lenp = 0; - return 0; - } - - name = brd->name; - - p += sprintf(p, "Board Name = %s\n", name); - if (brd->serial_num[0] == '\0') - p += sprintf(p, "Serial number = \n"); - else - p += sprintf(p, "Serial number = %s\n", brd->serial_num); - - p += sprintf(p, "Board Type = %d\n", brd->type); - p += sprintf(p, "Number of Ports = %d\n", brd->nasync); - - /* - * report some things about the PCI bus that are important - * to some applications - */ - p += sprintf(p, "Vendor ID = 0x%x\n", brd->vendor); - p += sprintf(p, "Device ID = 0x%x\n", brd->device); - p += sprintf(p, "Subvendor ID = 0x%x\n", brd->subvendor); - p += sprintf(p, "Subdevice ID = 0x%x\n", brd->subdevice); - p += sprintf(p, "Bus = %d\n", brd->pci_bus); - p += sprintf(p, "Slot = %d\n", brd->pci_slot); - - /* - * report the physical addresses assigned to us when we got - * registered - */ - p += sprintf(p, "Memory Base Address = 0x%lx\n", brd->membase); - p += sprintf(p, "Remapped Memory Base Address = 0x%p\n", brd->re_map_membase); - - p += sprintf(p, "Current state of board = %s\n", dgnc_state_text[brd->state]); - p += sprintf(p, "Interrupt #: %d. Times interrupted: %ld\n", - brd->irq, brd->intr_count); - - p += sprintf(p, "TX interrupts: %ld RX interrupts: %ld\n", - brd->intr_tx, brd->intr_rx); - p += sprintf(p, "Modem interrupts: %ld\n", brd->intr_modem); - - p += sprintf(p, "Majors allocated to board = TTY: %d PR: %d\n", - brd->SerialDriver.major, brd->PrintDriver.major); - - - if (copy_to_user(buffer, buf, (p - (char *) buf))) - return -EFAULT; - - *lenp = p - (char *) buf; - *ppos += p - (char *) buf; - done = 1; - return 0; -} - - - -static int dgnc_read_board_vpd(struct dgnc_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos) -{ - struct board_t *brd; - static int done = 0; - static char buf[4096]; - int i = 0, j = 0; - char *p = buf; - - DPR_PROC(("dgnc_proc_brd_info\n")); - - brd = (struct board_t *) table->data; - - if (done || !brd || (brd->magic != DGNC_BOARD_MAGIC)) { - done = 0; - *lenp = 0; - return 0; - } - - p += sprintf(p, "\n 0 1 2 3 4 5 6 7 8 9 A B C D E F ASCII\n"); - - for (i = 0; i < 0x40 * 2; i++) { - j = i; - if (!(i % 16)) { - if (j > 0) { - p += sprintf(p, " "); - for (j = i - 16; j < i; j++) { - if (0x20 <= brd->vpd[j] && brd->vpd[j] <= 0x7e) - p += sprintf(p, "%c", brd->vpd[j]); - else - p += sprintf(p, "."); - } - p += sprintf(p, "\n"); - } - p += sprintf(p, "%04X ", i); - } - p += sprintf(p, "%02X ", brd->vpd[i]); - } - if (!(i % 16)) { - p += sprintf(p, " "); - for (j = i - 16; j < i; j++) { - if (0x20 <= brd->vpd[j] && brd->vpd[j] <= 0x7e) - p += sprintf(p, "%c", brd->vpd[j]); - else - p += sprintf(p, "."); - } - p += sprintf(p, "\n"); - } - - p += sprintf(p, "\n"); - - if (copy_to_user(buffer, buf, (p - (char *) buf))) - return -EFAULT; - - *lenp = p - (char *) buf; - *ppos += p - (char *) buf; - done = 1; - return 0; -} - - -/* - * Return what is (hopefully) useful stats about the specific board's ttys - */ -static int dgnc_read_board_ttystats(struct dgnc_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos) -{ - struct board_t *brd; - static int done = 0; - static char buf[4096]; - char *p = buf; - int i = 0; - - DPR_PROC(("dgnc_proc_brd_info\n")); - - brd = (struct board_t *) table->data; - - if (done || !brd || (brd->magic != DGNC_BOARD_MAGIC)) { - done = 0; - *lenp = 0; - return 0; - } - - /* Prepare the Header Labels */ - p += sprintf(p, "%2s %10s %23s %10s %9s\n", - "Ch", "Chars Rx", " Rx Par--Brk--Frm--Ovr", - "Chars Tx", "XON XOFF"); - - for (i = 0; i < brd->nasync; i++) { - - struct channel_t *ch = brd->channels[i]; - - p += sprintf(p, "%2d ", i); - p += sprintf(p, "%10ld ", ch->ch_rxcount); - p += sprintf(p, " %4ld %4ld %4ld %4ld ", ch->ch_err_parity, - ch->ch_err_break, ch->ch_err_frame, ch->ch_err_overrun); - p += sprintf(p, "%10ld ", ch->ch_txcount); - p += sprintf(p, "%4ld %4ld ", ch->ch_xon_sends, ch->ch_xoff_sends); - - p += sprintf(p, "\n"); - } - - if (copy_to_user(buffer, buf, (p - (char *) buf))) - return -EFAULT; - - *lenp = p - (char *) buf; - *ppos += p - (char *) buf; - done = 1; - return 0; -} - - -/* - * Return what is (hopefully) useful stats about the specific board's tty intrs - */ -static int dgnc_read_board_ttyintr(struct dgnc_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos) -{ - struct board_t *brd; - static int done = 0; - static char buf[4096]; - char *p = buf; - int i = 0; - - DPR_PROC(("dgnc_proc_brd_info\n")); - - brd = (struct board_t *) table->data; - - if (done || !brd || (brd->magic != DGNC_BOARD_MAGIC)) { - done = 0; - *lenp = 0; - return 0; - } - - /* Prepare the Header Labels */ - p += sprintf(p, "%2s %14s %14s %14s\n", - "Ch", "TX interrupts", "RX interrupts", "Modem interrupts"); - - for (i = 0; i < brd->nasync; i++) { - - struct channel_t *ch = brd->channels[i]; - - p += sprintf(p, "%2d ", i); - - p += sprintf(p, " %14ld %14ld %14ld", - ch->ch_intr_tx, ch->ch_intr_rx, ch->ch_intr_modem); - - p += sprintf(p, "\n"); - } - - if (copy_to_user(buffer, buf, (p - (char *) buf))) - return -EFAULT; - - *lenp = p - (char *) buf; - *ppos += p - (char *) buf; - done = 1; - return 0; -} - - -/* - * Return what is (hopefully) useful flags about the specific board's ttys - */ -static int dgnc_read_board_ttyflags(struct dgnc_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos) -{ - struct board_t *brd; - static int done = 0; - static char buf[4096]; - char *p = buf; - int i = 0; - - DPR_PROC(("dgnc_proc_brd_info\n")); - - brd = (struct board_t *) table->data; - - if (done || !brd || (brd->magic != DGNC_BOARD_MAGIC)) { - done = 0; - *lenp = 0; - return 0; - } - - /* Prepare the Header Labels */ - p += sprintf(p, "%2s %5s %5s %5s %5s %5s %10s Line Status Flags\n", - "Ch", "CFlag", "IFlag", "OFlag", "LFlag", "DFlag", "Baud"); - - for (i = 0; i < brd->nasync; i++) { - - struct channel_t *ch = brd->channels[i]; - - p += sprintf(p, "%2d ", i); - p += sprintf(p, "%5x ", ch->ch_c_cflag); - p += sprintf(p, "%5x ", ch->ch_c_iflag); - p += sprintf(p, "%5x ", ch->ch_c_oflag); - p += sprintf(p, "%5x ", ch->ch_c_lflag); - p += sprintf(p, "%5x ", ch->ch_digi.digi_flags); - p += sprintf(p, "%10d ", ch->ch_old_baud); - - if (!ch->ch_open_count) { - p += sprintf(p, " -- -- -- -- -- -- --") ; - } else { - p += sprintf(p, " op %s %s %s %s %s %s", - (ch->ch_mostat & UART_MCR_RTS) ? "rs" : "--", - (ch->ch_mistat & UART_MSR_CTS) ? "cs" : "--", - (ch->ch_mostat & UART_MCR_DTR) ? "tr" : "--", - (ch->ch_mistat & UART_MSR_DSR) ? "mr" : "--", - (ch->ch_mistat & UART_MSR_DCD) ? "cd" : "--", - (ch->ch_mistat & UART_MSR_RI) ? "ri" : "--"); - } - - p += sprintf(p, "\n"); - } - if (copy_to_user(buffer, buf, (p - (char *) buf))) - return -EFAULT; - - *lenp = p - (char *) buf; - *ppos += p - (char *) buf; - done = 1; - return 0; -} - - -/* - * Return mknod information for the board's devices. - */ -static int dgnc_read_board_mknod(struct dgnc_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos) -{ - struct board_t *brd; - static int done = 0; - static char buf[4096]; - char str[MAXTTYNAMELEN]; - char *p = buf; - - DPR_PROC(("dgnc_proc_brd_info\n")); - - brd = (struct board_t *) table->data; - - if (done || !brd || (brd->magic != DGNC_BOARD_MAGIC)) { - done = 0; - *lenp = 0; - return 0; - } - - /* - * For each board, output the device information in - * a handy table format... - */ - p += sprintf(p, "# Create the TTY and PR devices\n"); - - /* TTY devices */ - sprintf(str, "ttyn%d%%p", brd->boardnum + 1); - p += sprintf(p, "%s\t\t\t%d\t%d\t%d\n", str, - brd->dgnc_Serial_Major, 0, brd->maxports); - - /* PR devices */ - sprintf(str, "prn%d%%p", brd->boardnum + 1); - p += sprintf(p, "%s\t\t\t%d\t%d\t%d\n", str, - brd->dgnc_TransparentPrint_Major, 128, brd->maxports); - - if (copy_to_user(buffer, buf, (p - (char *) buf))) - return -EFAULT; - - *lenp = p - (char *) buf; - *ppos += p - (char *) buf; - done = 1; - return 0; -} - - -/* - * Return what is (hopefully) useful information about the specific channel. - */ -static int dgnc_read_channel_info(struct dgnc_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos) -{ - struct channel_t *ch; - static int done = 0; - static char buf[4096]; - char *p = buf; - - DPR_PROC(("dgnc_proc_info\n")); - - ch = (struct channel_t *) table->data; - - if (done || !ch || (ch->magic != DGNC_CHANNEL_MAGIC)) { - done = 0; - *lenp = 0; - return 0; - } - - p += sprintf(p, "Port number:\t\t%d\n", ch->ch_portnum); - p += sprintf(p, "\n"); - - /* Prepare the Header Labels */ - p += sprintf(p, "%10s %23s %10s %9s\n", - "Chars Rx", " Rx Par--Brk--Frm--Ovr", - "Chars Tx", "XON XOFF"); - p += sprintf(p, "%10ld ", ch->ch_rxcount); - p += sprintf(p, " %4ld %4ld %4ld %4ld ", ch->ch_err_parity, - ch->ch_err_break, ch->ch_err_frame, ch->ch_err_overrun); - p += sprintf(p, "%10ld ", ch->ch_txcount); - p += sprintf(p, "%4ld %4ld ", ch->ch_xon_sends, ch->ch_xoff_sends); - p += sprintf(p, "\n\n"); - - /* Prepare the Header Labels */ - p += sprintf(p, "%5s %5s %5s %5s %5s %10s Line Status Flags\n", - "CFlag", "IFlag", "OFlag", "LFlag", "DFlag", "Baud"); - - p += sprintf(p, "%5x ", ch->ch_c_cflag); - p += sprintf(p, "%5x ", ch->ch_c_iflag); - p += sprintf(p, "%5x ", ch->ch_c_oflag); - p += sprintf(p, "%5x ", ch->ch_c_lflag); - p += sprintf(p, "%5x ", ch->ch_digi.digi_flags); - p += sprintf(p, "%10d ", ch->ch_old_baud); - if (!ch->ch_open_count) { - p += sprintf(p, " -- -- -- -- -- -- --") ; - } else { - p += sprintf(p, " op %s %s %s %s %s %s", - (ch->ch_mostat & UART_MCR_RTS) ? "rs" : "--", - (ch->ch_mistat & UART_MSR_CTS) ? "cs" : "--", - (ch->ch_mostat & UART_MCR_DTR) ? "tr" : "--", - (ch->ch_mistat & UART_MSR_DSR) ? "mr" : "--", - (ch->ch_mistat & UART_MSR_DCD) ? "cd" : "--", - (ch->ch_mistat & UART_MSR_RI) ? "ri" : "--"); - } - p += sprintf(p, "\n\n"); - - if (copy_to_user(buffer, buf, (p - (char *) buf))) - return -EFAULT; - - *lenp = p - (char *) buf; - *ppos += p - (char *) buf; - done = 1; - return 0; -} - - -/* - * Return mknod information for the board's devices. - */ -static int dgnc_read_channel_custom_ttyname(struct dgnc_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos) -{ - struct channel_t *ch; - struct board_t *brd; - static int done = 0; - static char buf[4096]; - char *p = buf; - int cn; - int bn; - - DPR_PROC(("dgnc_proc_brd_info\n")); - - ch = (struct channel_t *) table->data; - - if (done || !ch || (ch->magic != DGNC_CHANNEL_MAGIC)) { - done = 0; - *lenp = 0; - return 0; - } - - brd = ch->ch_bd; - - if (done || !brd || (brd->magic != DGNC_BOARD_MAGIC)) { - done = 0; - *lenp = 0; - return 0; - } - - bn = brd->boardnum; - cn = ch->ch_portnum; - - p += sprintf(p, "ttyn%d%c\n", bn + 1, 'a' + cn); - - if (copy_to_user(buffer, buf, (p - (char *) buf))) - return -EFAULT; - - *lenp = p - (char *) buf; - *ppos += p - (char *) buf; - done = 1; - return 0; -} - - - - -/* - * Return mknod information for the board's devices. - */ -static int dgnc_read_channel_custom_prname(struct dgnc_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos) -{ - struct channel_t *ch; - struct board_t *brd; - static int done = 0; - static char buf[4096]; - char *p = buf; - int cn; - int bn; - - DPR_PROC(("dgnc_proc_brd_info\n")); - - ch = (struct channel_t *) table->data; - - if (done || !ch || (ch->magic != DGNC_CHANNEL_MAGIC)) { - done = 0; - *lenp = 0; - return 0; - } - - brd = ch->ch_bd; - - if (done || !brd || (brd->magic != DGNC_BOARD_MAGIC)) { - done = 0; - *lenp = 0; - return 0; - } - - bn = brd->boardnum; - cn = ch->ch_portnum; - - p += sprintf(p, "prn%d%c\n", bn + 1, 'a' + cn); - - if (copy_to_user(buffer, buf, (p - (char *) buf))) - return -EFAULT; - - *lenp = p - (char *) buf; - *ppos += p - (char *) buf; - done = 1; - return 0; -} - - -static int dgnc_open_channel_sniff(struct dgnc_proc_entry *table, int dir, struct file *filp, - void *buffer, ssize_t *lenp, loff_t *ppos) -{ - struct channel_t *ch; - ulong lock_flags; - - ch = (struct channel_t *) table->data; - - if (!ch || (ch->magic != DGNC_CHANNEL_MAGIC)) - return 0; - - ch->ch_sniff_buf = dgnc_driver_kzmalloc(SNIFF_MAX, GFP_KERNEL); - - DGNC_LOCK(ch->ch_lock, lock_flags); - ch->ch_sniff_flags |= SNIFF_OPEN; - DGNC_UNLOCK(ch->ch_lock, lock_flags); - - return 0; -} - -static int dgnc_close_channel_sniff(struct dgnc_proc_entry *table, int dir, struct file *filp, - void *buffer, ssize_t *lenp, loff_t *ppos) -{ - struct channel_t *ch; - ulong lock_flags; - - ch = (struct channel_t *) table->data; - - if (!ch || (ch->magic != DGNC_CHANNEL_MAGIC)) - return 0; - - DGNC_LOCK(ch->ch_lock, lock_flags); - ch->ch_sniff_flags &= ~(SNIFF_OPEN); - kfree(ch->ch_sniff_buf); - DGNC_UNLOCK(ch->ch_lock, lock_flags); - - return 0; -} - - -/* - * Copy data from the monitoring buffer to the user, freeing space - * in the monitoring buffer for more messages - * - */ -static int dgnc_read_channel_sniff(struct dgnc_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos) -{ - struct channel_t *ch; - int n; - int r; - int offset = 0; - int res = 0; - ssize_t rtn = 0; - ulong lock_flags; - - ch = (struct channel_t *) table->data; - - if (!ch || (ch->magic != DGNC_CHANNEL_MAGIC)) { - rtn = -ENXIO; - goto done; - } - - /* - * Wait for some data to appear in the buffer. - */ - DGNC_LOCK(ch->ch_lock, lock_flags); - - for (;;) { - n = (ch->ch_sniff_in - ch->ch_sniff_out) & SNIFF_MASK; - - if (n != 0) - break; - - ch->ch_sniff_flags |= SNIFF_WAIT_DATA; - - DGNC_UNLOCK(ch->ch_lock, lock_flags); - - /* - * Go to sleep waiting until the condition becomes true. - */ - rtn = wait_event_interruptible(ch->ch_sniff_wait, - ((ch->ch_sniff_flags & SNIFF_WAIT_DATA) == 0)); - - if (rtn) - goto done; - - DGNC_LOCK(ch->ch_lock, lock_flags); - } - - /* - * Read whatever is there. - */ - - if (n > *lenp) - n = *lenp; - - res = n; - - r = SNIFF_MAX - ch->ch_sniff_out; - - if (r <= n) { - DGNC_UNLOCK(ch->ch_lock, lock_flags); - rtn = copy_to_user(buffer, ch->ch_sniff_buf + ch->ch_sniff_out, r); - if (rtn) { - rtn = -EFAULT; - goto done; - } - - DGNC_LOCK(ch->ch_lock, lock_flags); - - ch->ch_sniff_out = 0; - n -= r; - offset = r; - } - - DGNC_UNLOCK(ch->ch_lock, lock_flags); - rtn = copy_to_user(buffer + offset, ch->ch_sniff_buf + ch->ch_sniff_out, n); - if (rtn) { - rtn = -EFAULT; - goto done; - } - DGNC_LOCK(ch->ch_lock, lock_flags); - - ch->ch_sniff_out += n; - *ppos += res; - rtn = res; -// rtn = 0; - - /* - * Wakeup any thread waiting for buffer space. - */ - - if (ch->ch_sniff_flags & SNIFF_WAIT_SPACE) { - ch->ch_sniff_flags &= ~SNIFF_WAIT_SPACE; - wake_up_interruptible(&ch->ch_sniff_wait); - } - - DGNC_UNLOCK(ch->ch_lock, lock_flags); - -done: - return rtn; -} - - -/* - * Register the basic /proc/dgnc files that appear whenever - * the driver is loaded. - */ -void dgnc_proc_register_basic_prescan(void) -{ - /* - * Register /proc/dgnc - */ - ProcDGNC = proc_create("dgnc", (0700 | S_IFDIR), NULL, &dgnc_proc_file_ops); - dgnc_register_proc_table(dgnc_table, ProcDGNC); -} - - -/* - * Register the basic /proc/dgnc files that appear whenever - * the driver is loaded. - */ -void dgnc_proc_register_basic_postscan(int board_num) -{ - int i, j; - char board[10]; - sprintf(board, "%d", board_num); - - /* Set proc board entry pointer */ - dgnc_Board[board_num]->proc_entry_pointer = create_proc_entry(board, (0700 | S_IFDIR), ProcDGNC); - - /* Create a new copy of the board_table... */ - dgnc_Board[board_num]->dgnc_board_table = dgnc_driver_kzmalloc(sizeof(dgnc_board_table), - GFP_KERNEL); - - /* Now copy the default table into that memory */ - memcpy(dgnc_Board[board_num]->dgnc_board_table, dgnc_board_table, sizeof(dgnc_board_table)); - - /* Initialize semaphores in each table slot */ - for (i = 0; i < 999; i++) { - if (!dgnc_Board[board_num]->dgnc_board_table[i].magic) { - break; - } - - init_MUTEX(&(dgnc_Board[board_num]->dgnc_board_table[i].excl_sem)); - dgnc_Board[board_num]->dgnc_board_table[i].data = dgnc_Board[board_num]; - - } - - /* Register board table into proc */ - dgnc_register_proc_table(dgnc_Board[board_num]->dgnc_board_table, - dgnc_Board[board_num]->proc_entry_pointer); - - /* - * Add new entries for each port. - */ - for (i = 0; i < dgnc_Board[board_num]->nasync; i++) { - - char channel[10]; - sprintf(channel, "%d", i); - - /* Set proc channel entry pointer */ - dgnc_Board[board_num]->channels[i]->proc_entry_pointer = - create_proc_entry(channel, (0700 | S_IFDIR), - dgnc_Board[board_num]->proc_entry_pointer); - - /* Create a new copy of the channel_table... */ - dgnc_Board[board_num]->channels[i]->dgnc_channel_table = - dgnc_driver_kzmalloc(sizeof(dgnc_channel_table), GFP_KERNEL); - - /* Now copy the default table into that memory */ - memcpy(dgnc_Board[board_num]->channels[i]->dgnc_channel_table, - dgnc_channel_table, sizeof(dgnc_channel_table)); - - /* Initialize semaphores in each table slot */ - for (j = 0; j < 999; j++) { - if (!dgnc_Board[board_num]->channels[i]->dgnc_channel_table[j].magic) { - break; - } - - init_MUTEX(&(dgnc_Board[board_num]->channels[i]->dgnc_channel_table[j].excl_sem)); - dgnc_Board[board_num]->channels[i]->dgnc_channel_table[j].data = - dgnc_Board[board_num]->channels[i]; - } - - /* Register channel table into proc */ - dgnc_register_proc_table(dgnc_Board[board_num]->channels[i]->dgnc_channel_table, - dgnc_Board[board_num]->channels[i]->proc_entry_pointer); - } -} - - -static void dgnc_remove_proc_entry(struct proc_dir_entry *pde) -{ - if (!pde) { - DPR_PROC(("dgnc_remove_proc_entry... NULL entry... not removing...\n")); - return; - } - - remove_proc_entry(pde->name, pde->parent); -} - - -void dgnc_proc_unregister_all(void) -{ - int i = 0, j = 0; - - /* Walk each board, blowing away their proc entries... */ - for (i = 0; i < dgnc_NumBoards; i++) { - - /* Walk each channel, blowing away their proc entries... */ - for (j = 0; j < dgnc_Board[i]->nasync; j++) { - - dgnc_unregister_proc_table(dgnc_Board[i]->channels[j]->dgnc_channel_table, - dgnc_Board[i]->channels[j]->proc_entry_pointer); - dgnc_remove_proc_entry(dgnc_Board[i]->channels[j]->proc_entry_pointer); - kfree(dgnc_Board[i]->channels[j]->dgnc_channel_table); - } - - dgnc_unregister_proc_table(dgnc_Board[i]->dgnc_board_table, - dgnc_Board[i]->proc_entry_pointer); - dgnc_remove_proc_entry(dgnc_Board[i]->proc_entry_pointer); - kfree(dgnc_Board[i]->dgnc_board_table); - } - - /* Blow away the top proc entry */ - dgnc_unregister_proc_table(dgnc_table, ProcDGNC); - dgnc_remove_proc_entry(ProcDGNC); -} diff --git a/drivers/staging/dgnc/dgnc_proc.h b/drivers/staging/dgnc/dgnc_proc.h deleted file mode 100644 index 19670e29d5706..0000000000000 --- a/drivers/staging/dgnc/dgnc_proc.h +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright 2003 Digi International (www.digi.com) - * Scott H Kilau - * - * 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, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! - * - * - * $Id: dgnc_proc.h,v 1.1.1.1 2009/05/20 12:19:19 markh Exp $ - * - * Description: - * - * Describes the private structures used to manipulate the "special" - * proc constructs (not read-only) used by the Digi Neo software. - * The concept is borrowed heavily from the "sysctl" interface of - * the kernel. I decided not to use the structures and functions - * provided by the kernel for two reasons: - * - * 1. Due to the planned use of "/proc" in the Neo driver, many - * of the functions of the "sysctl" interface would go unused. - * A simpler interface will be easier to maintain. - * - * 2. I'd rather divorce our "added package" from the kernel internals. - * If the "sysctl" structures should change, I will be insulated - * from those changes. These "/proc" entries won't be under the - * "sys" tree anyway, so there is no need to maintain a strict - * dependence relationship. - * - * Author: - * - * Scott H Kilau - * - */ - -#ifndef _DGNC_RW_PROC_H -#define _DGNC_RW_PROC_H - -/* - * The list of DGNC entries with r/w capabilities. - * These magic numbers are used for identification purposes. - */ -enum { - DGNC_INFO = 1, /* Get info about the running module */ - DGNC_MKNOD = 2, /* Get info about driver devices */ - DGNC_BOARD_INFO = 3, /* Get info about the specific board */ - DGNC_BOARD_VPD = 4, /* Get info about the board's VPD */ - DGNC_BOARD_TTYSTATS = 5, /* Get info about the board's tty stats */ - DGNC_BOARD_TTYINTR = 6, /* Get info about the board's tty intrs */ - DGNC_BOARD_TTYFLAGS = 7, /* Get info about the board's tty flags */ - DGNC_BOARD_MKNOD = 8, /* Get info about board devices */ - DGNC_PORT_INFO = 9, /* Get info about the specific port */ - DGNC_PORT_SNIFF = 10, /* Sniff data in/out of specific port */ - DGNC_PORT_CUSTOM_TTYNAME = 11, /* Get info about UDEV tty name */ - DGNC_PORT_CUSTOM_PRNAME = 12, /* Get info about UDEV pr name */ -}; - -/* - * Directions for proc handlers - */ -enum { - INBOUND = 1, /* Data being written to kernel */ - OUTBOUND = 2, /* Data being read from the kernel */ -}; - -/* - * Each entry in a DGNC proc directory is described with a - * "dgnc_proc_entry" structure. A collection of these - * entries (in an array) represents the members associated - * with a particular "/proc" directory, and is referred to - * as a table. All "tables" are terminated by an entry with - * zeros for every member. - * - * The structure members are as follows: - * - * int magic -- ID number associated with this particular - * entry. Should be unique across all of - * DGNC. - * - * const char *name -- ASCII name associated with the /proc entry. - * - * mode_t mode -- File access permisssions for the /proc entry. - * - * dgnc_proc_entry *child -- When set, this entry refers to a directory, - * and points to the table which describes the - * entries in the subdirectory - * - * dgnc_proc_handler *open_handler -- When set, points to the fxn which - * does any "extra" open stuff. - * - * dgnc_proc_handler *close_handler -- When set, points to the fxn which - * does any "extra" close stuff. - * - * dgnc_proc_handler *read_handler -- When set, points to the fxn which - * handle outbound data flow - * - * dgnc_proc_handler *write_handler -- When set, points to the fxn which - * handles inbound data flow - * - * struct proc_dir_entry *de -- Pointer to the directory entry for this - * object once registered. Used to grab - * the handle of the object for - * unregistration - * - * void *data; When set, points to the parent structure - * - */ - -struct dgnc_proc_entry { - int magic; /* Integer identifier */ - const char *name; /* ASCII identifier */ - mode_t mode; /* File access permissions */ - struct dgnc_proc_entry *child; /* Child pointer */ - - int (*open_handler) (struct dgnc_proc_entry *table, int dir, struct file *filp, - void *buffer, ssize_t *lenp, loff_t *ppos); - int (*close_handler) (struct dgnc_proc_entry *table, int dir, struct file *filp, - void *buffer, ssize_t *lenp, loff_t *ppos); - int (*read_handler) (struct dgnc_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos); - int (*write_handler) (struct dgnc_proc_entry *table, int dir, struct file *filp, - const char __user *buffer, ssize_t *lenp, loff_t *ppos); - - struct proc_dir_entry *de; /* proc entry pointer */ - struct semaphore excl_sem; /* Protects exclusive access var */ - int excl_cnt; /* Counts number of curr accesses */ - void *data; /* Allows storing a pointer to parent */ -}; - -void dgnc_proc_register_basic_prescan(void); -void dgnc_proc_register_basic_postscan(int board_num); -void dgnc_proc_unregister_all(void); - - -#endif /* _DGNC_RW_PROC_H */ diff --git a/drivers/staging/dgnc/dgnc_sysfs.c b/drivers/staging/dgnc/dgnc_sysfs.c index 690d451e4821d..f9c167e6e6e2a 100644 --- a/drivers/staging/dgnc/dgnc_sysfs.c +++ b/drivers/staging/dgnc/dgnc_sysfs.c @@ -43,7 +43,6 @@ #include #include "dgnc_driver.h" -#include "dgnc_proc.h" #include "dgnc_mgmt.h" -- GitLab From 3bc0d88243af70a45cd4658723bd4a0aaf5bb6f1 Mon Sep 17 00:00:00 2001 From: Rupesh Gujare Date: Thu, 15 Aug 2013 12:00:21 +0100 Subject: [PATCH 639/942] staging: ozwpan: Remove unneeded variable initializer We are assigning value to hport before returning, there is no need to initialize it. Signed-off-by: Rupesh Gujare Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozhcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c index 4cd08daf51119..9a374fd3d2c9c 100644 --- a/drivers/staging/ozwpan/ozhcd.c +++ b/drivers/staging/ozwpan/ozhcd.c @@ -663,7 +663,7 @@ static inline void oz_hcd_put(struct oz_hcd *ozhcd) struct oz_port *oz_hcd_pd_arrived(void *hpd) { int i; - struct oz_port *hport = NULL; + struct oz_port *hport; struct oz_hcd *ozhcd; struct oz_endpoint *ep; -- GitLab From 83db51fe7286b96a3b90df26e6734c1506879e8e Mon Sep 17 00:00:00 2001 From: Rupesh Gujare Date: Thu, 15 Aug 2013 12:00:22 +0100 Subject: [PATCH 640/942] staging: ozwpan: Remove extra variable. We should not use extra variable just to copy pointer value, renaming parameter name serves pupose & removes extra variable. Signed-off-by: Rupesh Gujare Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozhcd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c index 9a374fd3d2c9c..2b67107db6b24 100644 --- a/drivers/staging/ozwpan/ozhcd.c +++ b/drivers/staging/ozwpan/ozhcd.c @@ -720,9 +720,8 @@ struct oz_port *oz_hcd_pd_arrived(void *hpd) * polled. We release the reference we hold on the PD. * Context: softirq */ -void oz_hcd_pd_departed(struct oz_port *hport) +void oz_hcd_pd_departed(struct oz_port *port) { - struct oz_port *port = hport; struct oz_hcd *ozhcd; void *hpd; struct oz_endpoint *ep = NULL; -- GitLab From f39c0d8e30c74a01b9883044e41fb339b97c006f Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Thu, 15 Aug 2013 19:34:37 +0100 Subject: [PATCH 641/942] staging: vt6656: rxtx.c remove typdef PTX_BUFFER Rename to vnt_tx_buffer. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 20 ++++++++++---------- drivers/staging/vt6656/rxtx.h | 20 +++++++++----------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 9cd4158e627ae..083f58f33d9d3 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -996,8 +996,8 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, u32 uNodeIndex, u16 wCurrentRate, u32 *pcbHeaderLen, u32 *pcbTotalLen) { struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + struct vnt_tx_buffer *pTxBufHead; u32 cbFrameSize, cbFrameBodySize; - PTX_BUFFER pTxBufHead; u32 cb802_1_H_len; u32 cbIVlen = 0, cbICVlen = 0, cbMIClen = 0, cbMACHdLen = 0; u32 cbFCSlen = 4, cbMICHDR = 0; @@ -1026,7 +1026,7 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, bSoftWEP = true; /* WEP 256 */ } - pTxBufHead = (PTX_BUFFER) usbPacketBuf; + pTxBufHead = (struct vnt_tx_buffer *)usbPacketBuf; // Get pkt type if (ntohs(psEthHeader->h_proto) > ETH_DATA_LEN) { @@ -1489,7 +1489,7 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice, struct vnt_tx_mgmt *pPacket) { struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; - PTX_BUFFER pTX_Buffer; + struct vnt_tx_buffer *pTX_Buffer; PSTxBufHead pTxBufHead; PUSB_SEND_CONTEXT pContext; struct ieee80211_hdr *pMACHeader; @@ -1512,7 +1512,7 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice, return CMD_STATUS_RESOURCES; } - pTX_Buffer = (PTX_BUFFER) (&pContext->Data[0]); + pTX_Buffer = (struct vnt_tx_buffer *)&pContext->Data[0]; pbyTxBufferAddr = (u8 *)&(pTX_Buffer->adwTxKey[0]); cbFrameBodySize = pPacket->cbPayloadLen; pTxBufHead = (PSTxBufHead) pbyTxBufferAddr; @@ -1838,6 +1838,7 @@ CMD_STATUS csBeacon_xmit(struct vnt_private *pDevice, void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb) { struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + struct vnt_tx_buffer *pTX_Buffer; u8 byPktType; u8 *pbyTxBufferAddr; void *pvRTS, *pvCTS, *pvTxDataHd; @@ -1865,7 +1866,6 @@ void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb) PSKeyItem pTransmitKey = NULL; u8 *pbyIVHead, *pbyPayloadHead, *pbyMacHdr; u32 cbExtSuppRate = 0; - PTX_BUFFER pTX_Buffer; PUSB_SEND_CONTEXT pContext; pvRrvTime = pMICHDR = pvRTS = pvCTS = pvTxDataHd = NULL; @@ -1886,7 +1886,7 @@ void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb) return ; } - pTX_Buffer = (PTX_BUFFER)(&pContext->Data[0]); + pTX_Buffer = (struct vnt_tx_buffer *)&pContext->Data[0]; pbyTxBufferAddr = (u8 *)(&pTX_Buffer->adwTxKey[0]); pTxBufHead = (PSTxBufHead) pbyTxBufferAddr; wTxBufSize = sizeof(STxBufHead); @@ -2218,6 +2218,7 @@ int nsDMA_tx_packet(struct vnt_private *pDevice, { struct net_device_stats *pStats = &pDevice->stats; struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + struct vnt_tx_buffer *pTX_Buffer; u32 BytesToWrite = 0, uHeaderLen = 0; u32 uNodeIndex = 0; u8 byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80}; @@ -2233,7 +2234,6 @@ int nsDMA_tx_packet(struct vnt_private *pDevice, int bNodeExist = false; PUSB_SEND_CONTEXT pContext; bool fConvertedPacket; - PTX_BUFFER pTX_Buffer; u32 status; u16 wKeepRate = pDevice->wCurrentRate; int bTxeapol_key = false; @@ -2564,7 +2564,7 @@ int nsDMA_tx_packet(struct vnt_private *pDevice, } } - pTX_Buffer = (PTX_BUFFER)&(pContext->Data[0]); + pTX_Buffer = (struct vnt_tx_buffer *)&pContext->Data[0]; pTX_Buffer->byPKTNO = (u8) (((pDevice->wCurrentRate<<4) &0x00F0) | ((pDevice->wSeqCounter - 1) & 0x000F)); pTX_Buffer->wTxByteCount = (u16)BytesToWrite; @@ -2611,6 +2611,7 @@ int bRelayPacketSend(struct vnt_private *pDevice, u8 *pbySkbData, u32 uDataLen, u32 uNodeIndex) { struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; + struct vnt_tx_buffer *pTX_Buffer; u32 BytesToWrite = 0, uHeaderLen = 0; u8 byPktType = PK_TYPE_11B; int bNeedEncryption = false; @@ -2620,7 +2621,6 @@ int bRelayPacketSend(struct vnt_private *pDevice, u8 *pbySkbData, u32 uDataLen, PUSB_SEND_CONTEXT pContext; u8 byPktTyp; int fConvertedPacket; - PTX_BUFFER pTX_Buffer; u32 status; u16 wKeepRate = pDevice->wCurrentRate; @@ -2714,7 +2714,7 @@ int bRelayPacketSend(struct vnt_private *pDevice, u8 *pbySkbData, u32 uDataLen, return false; } - pTX_Buffer = (PTX_BUFFER)&(pContext->Data[0]); + pTX_Buffer = (struct vnt_tx_buffer *)&pContext->Data[0]; pTX_Buffer->byPKTNO = (u8) (((pDevice->wCurrentRate<<4) &0x00F0) | ((pDevice->wSeqCounter - 1) & 0x000F)); pTX_Buffer->wTxByteCount = (u16)BytesToWrite; diff --git a/drivers/staging/vt6656/rxtx.h b/drivers/staging/vt6656/rxtx.h index 3e2a877a3b034..bd1f9e2a04878 100644 --- a/drivers/staging/vt6656/rxtx.h +++ b/drivers/staging/vt6656/rxtx.h @@ -32,18 +32,16 @@ #include "device.h" #include "wcmd.h" -typedef struct tagSTX_BUFFER -{ - u8 byType; - u8 byPKTNO; - u16 wTxByteCount; - +struct vnt_tx_buffer { + u8 byType; + u8 byPKTNO; + u16 wTxByteCount; u32 adwTxKey[4]; - u16 wFIFOCtl; - u16 wTimeStamp; - u16 wFragCtl; - u16 wReserved; -} __packed TX_BUFFER, *PTX_BUFFER; + u16 wFIFOCtl; + u16 wTimeStamp; + u16 wFragCtl; + u16 wReserved; +} __packed; typedef struct tagSBEACON_BUFFER { -- GitLab From d0a2b8fa7663a09b66f54b77dbbf460fb762aa7d Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Thu, 15 Aug 2013 19:37:04 +0100 Subject: [PATCH 642/942] staging: vt6656: rxtx.c : s_bPacketToWirelessUsb remove usbPacketBuf. Move vnt_tx_buffer *pTxBufHead to argument u8 *usbPacketBuf position. Fix the calling to s_bPacketToWirelessUsb so it attached to the calling struct vnt_tx_buffer pTX_Buffer. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 083f58f33d9d3..e37e82c8a378f 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -991,12 +991,12 @@ static void s_vGenerateTxParameter(struct vnt_private *pDevice, */ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, - u8 *usbPacketBuf, int bNeedEncryption, u32 uSkbPacketLen, u32 uDMAIdx, - struct ethhdr *psEthHeader, u8 *pPacket, PSKeyItem pTransmitKey, - u32 uNodeIndex, u16 wCurrentRate, u32 *pcbHeaderLen, u32 *pcbTotalLen) + struct vnt_tx_buffer *pTxBufHead, int bNeedEncryption, + u32 uSkbPacketLen, u32 uDMAIdx, struct ethhdr *psEthHeader, + u8 *pPacket, PSKeyItem pTransmitKey, u32 uNodeIndex, u16 wCurrentRate, + u32 *pcbHeaderLen, u32 *pcbTotalLen) { struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; - struct vnt_tx_buffer *pTxBufHead; u32 cbFrameSize, cbFrameBodySize; u32 cb802_1_H_len; u32 cbIVlen = 0, cbICVlen = 0, cbMIClen = 0, cbMACHdLen = 0; @@ -1026,8 +1026,6 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, bSoftWEP = true; /* WEP 256 */ } - pTxBufHead = (struct vnt_tx_buffer *)usbPacketBuf; - // Get pkt type if (ntohs(psEthHeader->h_proto) > ETH_DATA_LEN) { if (pDevice->dwDiagRefCount == 0) { @@ -2541,8 +2539,10 @@ int nsDMA_tx_packet(struct vnt_private *pDevice, } } + pTX_Buffer = (struct vnt_tx_buffer *)&pContext->Data[0]; + fConvertedPacket = s_bPacketToWirelessUsb(pDevice, byPktType, - (u8 *)(&pContext->Data[0]), bNeedEncryption, + pTX_Buffer, bNeedEncryption, skb->len, uDMAIdx, &pDevice->sTxEthHeader, (u8 *)skb->data, pTransmitKey, uNodeIndex, pDevice->wCurrentRate, @@ -2564,7 +2564,6 @@ int nsDMA_tx_packet(struct vnt_private *pDevice, } } - pTX_Buffer = (struct vnt_tx_buffer *)&pContext->Data[0]; pTX_Buffer->byPKTNO = (u8) (((pDevice->wCurrentRate<<4) &0x00F0) | ((pDevice->wSeqCounter - 1) & 0x000F)); pTX_Buffer->wTxByteCount = (u16)BytesToWrite; @@ -2701,8 +2700,10 @@ int bRelayPacketSend(struct vnt_private *pDevice, u8 *pbySkbData, u32 uDataLen, // Convert the packet to an usb frame and copy into our buffer // and send the irp. + pTX_Buffer = (struct vnt_tx_buffer *)&pContext->Data[0]; + fConvertedPacket = s_bPacketToWirelessUsb(pDevice, byPktType, - (u8 *)(&pContext->Data[0]), bNeedEncryption, + pTX_Buffer, bNeedEncryption, uDataLen, TYPE_AC0DMA, &pDevice->sTxEthHeader, pbySkbData, pTransmitKey, uNodeIndex, pDevice->wCurrentRate, @@ -2714,7 +2715,6 @@ int bRelayPacketSend(struct vnt_private *pDevice, u8 *pbySkbData, u32 uDataLen, return false; } - pTX_Buffer = (struct vnt_tx_buffer *)&pContext->Data[0]; pTX_Buffer->byPKTNO = (u8) (((pDevice->wCurrentRate<<4) &0x00F0) | ((pDevice->wSeqCounter - 1) & 0x000F)); pTX_Buffer->wTxByteCount = (u16)BytesToWrite; -- GitLab From 01f865ba4a1ee95d4828b4f3fa69d68f9ac4b9ba Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Thu, 15 Aug 2013 19:40:08 +0100 Subject: [PATCH 643/942] staging: vt6656: rxtx.h : remove typedef struct tagSBEACON_BUFFER Replace with struct vnt_beacon_buffer. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 5 +++-- drivers/staging/vt6656/rxtx.h | 16 +++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index e37e82c8a378f..7a4ebbc40d2fe 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -1753,6 +1753,7 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice, CMD_STATUS csBeacon_xmit(struct vnt_private *pDevice, struct vnt_tx_mgmt *pPacket) { + struct vnt_beacon_buffer *pTX_Buffer; u32 cbFrameSize = pPacket->cbMPDULen + WLAN_FCS_LEN; u32 cbHeaderSize = 0; u16 wTxBufSize = sizeof(STxShortBufHead); @@ -1762,7 +1763,6 @@ CMD_STATUS csBeacon_xmit(struct vnt_private *pDevice, u16 wCurrentRate; u32 cbFrameBodySize; u32 cbReqCount; - PBEACON_BUFFER pTX_Buffer; u8 *pbyTxBufferAddr; PUSB_SEND_CONTEXT pContext; CMD_STATUS status; @@ -1773,7 +1773,8 @@ CMD_STATUS csBeacon_xmit(struct vnt_private *pDevice, DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ManagementSend TX...NO CONTEXT!\n"); return status ; } - pTX_Buffer = (PBEACON_BUFFER) (&pContext->Data[0]); + + pTX_Buffer = (struct vnt_beacon_buffer *)&pContext->Data[0]; pbyTxBufferAddr = (u8 *)&(pTX_Buffer->wFIFOCtl); cbFrameBodySize = pPacket->cbPayloadLen; diff --git a/drivers/staging/vt6656/rxtx.h b/drivers/staging/vt6656/rxtx.h index bd1f9e2a04878..3e347a932ede8 100644 --- a/drivers/staging/vt6656/rxtx.h +++ b/drivers/staging/vt6656/rxtx.h @@ -43,15 +43,13 @@ struct vnt_tx_buffer { u16 wReserved; } __packed; -typedef struct tagSBEACON_BUFFER -{ - u8 byType; - u8 byPKTNO; - u16 wTxByteCount; - - u16 wFIFOCtl; - u16 wTimeStamp; -} __packed BEACON_BUFFER, *PBEACON_BUFFER; +struct vnt_beacon_buffer { + u8 byType; + u8 byPKTNO; + u16 wTxByteCount; + u16 wFIFOCtl; + u16 wTimeStamp; +} __packed; void vDMA0_tx_80211(struct vnt_private *, struct sk_buff *skb); int nsDMA_tx_packet(struct vnt_private *, u32 uDMAIdx, struct sk_buff *skb); -- GitLab From 98d4f93c79b002f85480320fe63fefaa31d58b6c Mon Sep 17 00:00:00 2001 From: Jens Frederich Date: Thu, 15 Aug 2013 21:34:55 +0200 Subject: [PATCH 644/942] Staging: olpc_dcon: replace some magic numbers This patch replace some magic numbers. I believe it makes the driver more readable. The magic number 0x26 is the XO system embedded controller (EC) command 'DCON power enable/disable'. Number 0x41, and 0x42 are special memory controller settings register. The 0x41 initialize bit sequence 0x101 means: enable memory power down function and special SDRAM clock delay for synchronize SDRAM output and clock signal. The 0x42 initialize squence 0x101 is wrong. According to the specification Bit 8 is reserved, thus not in use. I removed it. Signed-off-by: Jens Frederich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/olpc_dcon/olpc_dcon.c | 13 +++++++------ drivers/staging/olpc_dcon/olpc_dcon.h | 27 ++++++++++++++++++--------- include/linux/olpc-ec.h | 1 + 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/drivers/staging/olpc_dcon/olpc_dcon.c b/drivers/staging/olpc_dcon/olpc_dcon.c index 7c460f2c0d230..5ca4fa4fd246b 100644 --- a/drivers/staging/olpc_dcon/olpc_dcon.c +++ b/drivers/staging/olpc_dcon/olpc_dcon.c @@ -90,9 +90,10 @@ static int dcon_hw_init(struct dcon_priv *dcon, int is_init) /* SDRAM setup/hold time */ dcon_write(dcon, 0x3a, 0xc040); - dcon_write(dcon, 0x41, 0x0000); - dcon_write(dcon, 0x41, 0x0101); - dcon_write(dcon, 0x42, 0x0101); + dcon_write(dcon, DCON_REG_MEM_OPT_A, 0x0000); /* clear option bits */ + dcon_write(dcon, DCON_REG_MEM_OPT_A, + MEM_DLL_CLOCK_DELAY | MEM_POWER_DOWN); + dcon_write(dcon, DCON_REG_MEM_OPT_B, MEM_SOFT_RESET); /* Colour swizzle, AA, no passthrough, backlight */ if (is_init) { @@ -126,7 +127,7 @@ static int dcon_bus_stabilize(struct dcon_priv *dcon, int is_powered_down) power_up: if (is_powered_down) { x = 1; - x = olpc_ec_cmd(0x26, (unsigned char *)&x, 1, NULL, 0); + x = olpc_ec_cmd(EC_DCON_POWER_MODE, (u8 *)&x, 1, NULL, 0); if (x) { pr_warn("unable to force dcon to power up: %d!\n", x); return x; @@ -144,7 +145,7 @@ static int dcon_bus_stabilize(struct dcon_priv *dcon, int is_powered_down) pr_err("unable to stabilize dcon's smbus, reasserting power and praying.\n"); BUG_ON(olpc_board_at_least(olpc_board(0xc2))); x = 0; - olpc_ec_cmd(0x26, (unsigned char *)&x, 1, NULL, 0); + olpc_ec_cmd(EC_DCON_POWER_MODE, (u8 *)&x, 1, NULL, 0); msleep(100); is_powered_down = 1; goto power_up; /* argh, stupid hardware.. */ @@ -208,7 +209,7 @@ static void dcon_sleep(struct dcon_priv *dcon, bool sleep) if (sleep) { x = 0; - x = olpc_ec_cmd(0x26, (unsigned char *)&x, 1, NULL, 0); + x = olpc_ec_cmd(EC_DCON_POWER_MODE, (u8 *)&x, 1, NULL, 0); if (x) pr_warn("unable to force dcon to power down: %d!\n", x); else diff --git a/drivers/staging/olpc_dcon/olpc_dcon.h b/drivers/staging/olpc_dcon/olpc_dcon.h index 997bded2949f2..524ee49fbacb4 100644 --- a/drivers/staging/olpc_dcon/olpc_dcon.h +++ b/drivers/staging/olpc_dcon/olpc_dcon.h @@ -22,15 +22,24 @@ #define MODE_DEBUG (1<<14) #define MODE_SELFTEST (1<<15) -#define DCON_REG_HRES 2 -#define DCON_REG_HTOTAL 3 -#define DCON_REG_HSYNC_WIDTH 4 -#define DCON_REG_VRES 5 -#define DCON_REG_VTOTAL 6 -#define DCON_REG_VSYNC_WIDTH 7 -#define DCON_REG_TIMEOUT 8 -#define DCON_REG_SCAN_INT 9 -#define DCON_REG_BRIGHT 10 +#define DCON_REG_HRES 0x2 +#define DCON_REG_HTOTAL 0x3 +#define DCON_REG_HSYNC_WIDTH 0x4 +#define DCON_REG_VRES 0x5 +#define DCON_REG_VTOTAL 0x6 +#define DCON_REG_VSYNC_WIDTH 0x7 +#define DCON_REG_TIMEOUT 0x8 +#define DCON_REG_SCAN_INT 0x9 +#define DCON_REG_BRIGHT 0x10 +#define DCON_REG_MEM_OPT_A 0x41 +#define DCON_REG_MEM_OPT_B 0x42 + +/* Load Delay Locked Loop (DLL) settings for clock delay */ +#define MEM_DLL_CLOCK_DELAY (1<<0) +/* Memory controller power down function */ +#define MEM_POWER_DOWN (1<<8) +/* Memory controller software reset */ +#define MEM_SOFT_RESET (1<<0) /* Status values */ diff --git a/include/linux/olpc-ec.h b/include/linux/olpc-ec.h index 5bb6e760aa612..2925df3ce78a3 100644 --- a/include/linux/olpc-ec.h +++ b/include/linux/olpc-ec.h @@ -6,6 +6,7 @@ #define EC_WRITE_SCI_MASK 0x1b #define EC_WAKE_UP_WLAN 0x24 #define EC_WLAN_LEAVE_RESET 0x25 +#define EC_DCON_POWER_MODE 0x26 #define EC_READ_EB_MODE 0x2a #define EC_SET_SCI_INHIBIT 0x32 #define EC_SET_SCI_INHIBIT_RELEASE 0x34 -- GitLab From 24b7ed475e2b71eba68ee9714b29c712f8dc41f6 Mon Sep 17 00:00:00 2001 From: Jens Frederich Date: Thu, 15 Aug 2013 21:40:01 +0200 Subject: [PATCH 645/942] Staging: olpc_dcon: more big endian conformity Using an int which is casted to unsigned char as inbuf is messy. The code won't work on big endian systems. The patch should fix this. Signed-off-by: Jens Frederich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/olpc_dcon/olpc_dcon.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/staging/olpc_dcon/olpc_dcon.c b/drivers/staging/olpc_dcon/olpc_dcon.c index 5ca4fa4fd246b..198595e8d742f 100644 --- a/drivers/staging/olpc_dcon/olpc_dcon.c +++ b/drivers/staging/olpc_dcon/olpc_dcon.c @@ -122,12 +122,13 @@ static int dcon_hw_init(struct dcon_priv *dcon, int is_init) static int dcon_bus_stabilize(struct dcon_priv *dcon, int is_powered_down) { unsigned long timeout; + u8 pm; int x; power_up: if (is_powered_down) { - x = 1; - x = olpc_ec_cmd(EC_DCON_POWER_MODE, (u8 *)&x, 1, NULL, 0); + pm = 1; + x = olpc_ec_cmd(EC_DCON_POWER_MODE, &pm, 1, NULL, 0); if (x) { pr_warn("unable to force dcon to power up: %d!\n", x); return x; @@ -144,8 +145,8 @@ static int dcon_bus_stabilize(struct dcon_priv *dcon, int is_powered_down) if (x < 0) { pr_err("unable to stabilize dcon's smbus, reasserting power and praying.\n"); BUG_ON(olpc_board_at_least(olpc_board(0xc2))); - x = 0; - olpc_ec_cmd(EC_DCON_POWER_MODE, (u8 *)&x, 1, NULL, 0); + pm = 0; + olpc_ec_cmd(EC_DCON_POWER_MODE, &pm, 1, NULL, 0); msleep(100); is_powered_down = 1; goto power_up; /* argh, stupid hardware.. */ @@ -208,8 +209,8 @@ static void dcon_sleep(struct dcon_priv *dcon, bool sleep) return; if (sleep) { - x = 0; - x = olpc_ec_cmd(EC_DCON_POWER_MODE, (u8 *)&x, 1, NULL, 0); + u8 pm = 0; + x = olpc_ec_cmd(EC_DCON_POWER_MODE, &pm, 1, NULL, 0); if (x) pr_warn("unable to force dcon to power down: %d!\n", x); else -- GitLab From c521cb58880c153683c983a51e54517b21d04daf Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Thu, 15 Aug 2013 21:23:25 +0100 Subject: [PATCH 646/942] staging: vt6656: desc.h Remove typedef struct tagSRTS_* to new strutures in rxtx.h The new structures being typedef struct tagSRTS_g -> struct vnt_rts_g typedef struct tagSRTS_g_FB -> struct vnt_rts_g_fb typedef struct tagSRTS_ab -> struct vnt_rts_ab typedef struct tagSRTS_a_FB -> struct vnt_rts_a_fb These are only needed by rxtc.c so moved to rxtx.h and will eventually form part of the structure of struct vnt_tx_buffer. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/desc.h | 66 ----------------------------------- drivers/staging/vt6656/rxtx.c | 51 ++++++++++++++++++--------- drivers/staging/vt6656/rxtx.h | 53 ++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+), 83 deletions(-) diff --git a/drivers/staging/vt6656/desc.h b/drivers/staging/vt6656/desc.h index 1a1cf34e4113e..4e2eb1886936b 100644 --- a/drivers/staging/vt6656/desc.h +++ b/drivers/staging/vt6656/desc.h @@ -185,72 +185,6 @@ SRrvTime_atim, *PSRrvTime_atim; typedef const SRrvTime_atim *PCSRrvTime_atim; -/* - * RTS buffer header - */ -typedef struct tagSRTS_g { - u8 bySignalField_b; - u8 byServiceField_b; - u16 wTransmitLength_b; - u8 bySignalField_a; - u8 byServiceField_a; - u16 wTransmitLength_a; - u16 wDuration_ba; - u16 wDuration_aa; - u16 wDuration_bb; - u16 wReserved; - struct ieee80211_rts data; -} __attribute__ ((__packed__)) -SRTS_g, *PSRTS_g; -typedef const SRTS_g *PCSRTS_g; - -typedef struct tagSRTS_g_FB { - u8 bySignalField_b; - u8 byServiceField_b; - u16 wTransmitLength_b; - u8 bySignalField_a; - u8 byServiceField_a; - u16 wTransmitLength_a; - u16 wDuration_ba; - u16 wDuration_aa; - u16 wDuration_bb; - u16 wReserved; - u16 wRTSDuration_ba_f0; - u16 wRTSDuration_aa_f0; - u16 wRTSDuration_ba_f1; - u16 wRTSDuration_aa_f1; - struct ieee80211_rts data; -} __attribute__ ((__packed__)) -SRTS_g_FB, *PSRTS_g_FB; - -typedef const SRTS_g_FB *PCSRTS_g_FB; - -typedef struct tagSRTS_ab { - u8 bySignalField; - u8 byServiceField; - u16 wTransmitLength; - u16 wDuration; - u16 wReserved; - struct ieee80211_rts data; -} __attribute__ ((__packed__)) -SRTS_ab, *PSRTS_ab; - -typedef const SRTS_ab *PCSRTS_ab; - -typedef struct tagSRTS_a_FB { - u8 bySignalField; - u8 byServiceField; - u16 wTransmitLength; - u16 wDuration; - u16 wReserved; - u16 wRTSDuration_f0; - u16 wRTSDuration_f1; - struct ieee80211_rts data; -} __attribute__ ((__packed__)) -SRTS_a_FB, *PSRTS_a_FB; - -typedef const SRTS_a_FB *PCSRTS_a_FB; - /* * CTS buffer header */ diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 7a4ebbc40d2fe..e7ff84520fe26 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -629,7 +629,7 @@ static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, // Otherwise, we need to modified codes for them. if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { if (byFBOption == AUTO_FB_NONE) { - PSRTS_g pBuf = (PSRTS_g)pvRTS; + struct vnt_rts_g *pBuf = (struct vnt_rts_g *)pvRTS; //Get SignalField,ServiceField,Length BBvCalculateParameter(pDevice, uRTSFrameLen, pDevice->byTopCCKBasicRate, PK_TYPE_11B, (u16 *)&(wLen), (u8 *)&(pBuf->byServiceField_b), (u8 *)&(pBuf->bySignalField_b) @@ -665,7 +665,7 @@ static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, memcpy(pBuf->data.ta, psEthHeader->h_source, ETH_ALEN); } else { - PSRTS_g_FB pBuf = (PSRTS_g_FB)pvRTS; + struct vnt_rts_g_fb *pBuf = (struct vnt_rts_g_fb *)pvRTS; //Get SignalField,ServiceField,Length BBvCalculateParameter(pDevice, uRTSFrameLen, pDevice->byTopCCKBasicRate, PK_TYPE_11B, (u16 *)&(wLen), (u8 *)&(pBuf->byServiceField_b), (u8 *)&(pBuf->bySignalField_b) @@ -715,7 +715,7 @@ static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, } else if (byPktType == PK_TYPE_11A) { if (byFBOption == AUTO_FB_NONE) { - PSRTS_ab pBuf = (PSRTS_ab)pvRTS; + struct vnt_rts_ab *pBuf = (struct vnt_rts_ab *)pvRTS; //Get SignalField,ServiceField,Length BBvCalculateParameter(pDevice, uRTSFrameLen, pDevice->byTopOFDMBasicRate, byPktType, (u16 *)&(wLen), (u8 *)&(pBuf->byServiceField), (u8 *)&(pBuf->bySignalField) @@ -741,7 +741,7 @@ static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, memcpy(pBuf->data.ta, psEthHeader->h_source, ETH_ALEN); } else { - PSRTS_a_FB pBuf = (PSRTS_a_FB)pvRTS; + struct vnt_rts_a_fb *pBuf = (struct vnt_rts_a_fb *)pvRTS; //Get SignalField,ServiceField,Length BBvCalculateParameter(pDevice, uRTSFrameLen, pDevice->byTopOFDMBasicRate, byPktType, (u16 *)&(wLen), (u8 *)&(pBuf->byServiceField), (u8 *)&(pBuf->bySignalField) @@ -774,7 +774,7 @@ static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, } } else if (byPktType == PK_TYPE_11B) { - PSRTS_ab pBuf = (PSRTS_ab)pvRTS; + struct vnt_rts_ab *pBuf = (struct vnt_rts_ab *)pvRTS; //Get SignalField,ServiceField,Length BBvCalculateParameter(pDevice, uRTSFrameLen, pDevice->byTopCCKBasicRate, PK_TYPE_11B, (u16 *)&(wLen), (u8 *)&(pBuf->byServiceField), (u8 *)&(pBuf->bySignalField) @@ -1151,10 +1151,15 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, if (bRTS == true) {//RTS_need pvRrvTime = (PSRrvTime_gRTS) (pbyTxBufferAddr + wTxBufSize); pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gRTS)); - pvRTS = (PSRTS_g) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gRTS) + cbMICHDR); + pvRTS = (struct vnt_rts_g *) (pbyTxBufferAddr + wTxBufSize + + sizeof(SRrvTime_gRTS) + cbMICHDR); pvCTS = NULL; - pvTxDataHd = (PSTxDataHead_g) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gRTS) + cbMICHDR + sizeof(SRTS_g)); - cbHeaderLength = wTxBufSize + sizeof(SRrvTime_gRTS) + cbMICHDR + sizeof(SRTS_g) + sizeof(STxDataHead_g); + pvTxDataHd = (PSTxDataHead_g) (pbyTxBufferAddr + wTxBufSize + + sizeof(SRrvTime_gRTS) + cbMICHDR + + sizeof(struct vnt_rts_g)); + cbHeaderLength = wTxBufSize + sizeof(SRrvTime_gRTS) + + cbMICHDR + sizeof(struct vnt_rts_g) + + sizeof(STxDataHead_g); } else { //RTS_needless pvRrvTime = (PSRrvTime_gCTS) (pbyTxBufferAddr + wTxBufSize); @@ -1169,10 +1174,14 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, if (bRTS == true) {//RTS_need pvRrvTime = (PSRrvTime_gRTS) (pbyTxBufferAddr + wTxBufSize); pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gRTS)); - pvRTS = (PSRTS_g_FB) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gRTS) + cbMICHDR); + pvRTS = (struct vnt_rts_g_fb *) (pbyTxBufferAddr + wTxBufSize + + sizeof(SRrvTime_gRTS) + cbMICHDR); pvCTS = NULL; - pvTxDataHd = (PSTxDataHead_g_FB) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gRTS) + cbMICHDR + sizeof(SRTS_g_FB)); - cbHeaderLength = wTxBufSize + sizeof(SRrvTime_gRTS) + cbMICHDR + sizeof(SRTS_g_FB) + sizeof(STxDataHead_g_FB); + pvTxDataHd = (PSTxDataHead_g_FB) (pbyTxBufferAddr + wTxBufSize + + sizeof(SRrvTime_gRTS) + cbMICHDR + + sizeof(struct vnt_rts_g_fb)); + cbHeaderLength = wTxBufSize + sizeof(SRrvTime_gRTS) + cbMICHDR + + sizeof(struct vnt_rts_g_fb) + sizeof(STxDataHead_g_FB); } else if (bRTS == false) { //RTS_needless pvRrvTime = (PSRrvTime_gCTS) (pbyTxBufferAddr + wTxBufSize); @@ -1189,10 +1198,14 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, if (bRTS == true) {//RTS_need pvRrvTime = (PSRrvTime_ab) (pbyTxBufferAddr + wTxBufSize); pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab)); - pvRTS = (PSRTS_ab) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab) + cbMICHDR); + pvRTS = (struct vnt_rts_ab *) (pbyTxBufferAddr + wTxBufSize + + sizeof(SRrvTime_ab) + cbMICHDR); pvCTS = NULL; - pvTxDataHd = (PSTxDataHead_ab) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab) + cbMICHDR + sizeof(SRTS_ab)); - cbHeaderLength = wTxBufSize + sizeof(PSRrvTime_ab) + cbMICHDR + sizeof(SRTS_ab) + sizeof(STxDataHead_ab); + pvTxDataHd = (PSTxDataHead_ab) (pbyTxBufferAddr + wTxBufSize + + sizeof(SRrvTime_ab) + cbMICHDR + + sizeof(struct vnt_rts_ab)); + cbHeaderLength = wTxBufSize + sizeof(PSRrvTime_ab) + cbMICHDR + + sizeof(struct vnt_rts_ab) + sizeof(STxDataHead_ab); } else if (bRTS == false) { //RTS_needless, no MICHDR pvRrvTime = (PSRrvTime_ab) (pbyTxBufferAddr + wTxBufSize); @@ -1207,10 +1220,14 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, if (bRTS == true) {//RTS_need pvRrvTime = (PSRrvTime_ab) (pbyTxBufferAddr + wTxBufSize); pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab)); - pvRTS = (PSRTS_a_FB) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab) + cbMICHDR); + pvRTS = (struct vnt_rts_a_fb *) (pbyTxBufferAddr + wTxBufSize + + sizeof(SRrvTime_ab) + cbMICHDR); pvCTS = NULL; - pvTxDataHd = (PSTxDataHead_a_FB) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab) + cbMICHDR + sizeof(SRTS_a_FB)); - cbHeaderLength = wTxBufSize + sizeof(PSRrvTime_ab) + cbMICHDR + sizeof(SRTS_a_FB) + sizeof(STxDataHead_a_FB); + pvTxDataHd = (PSTxDataHead_a_FB) (pbyTxBufferAddr + wTxBufSize + + sizeof(SRrvTime_ab) + cbMICHDR + + sizeof(struct vnt_rts_a_fb)); + cbHeaderLength = wTxBufSize + sizeof(PSRrvTime_ab) + cbMICHDR + + sizeof(struct vnt_rts_a_fb) + sizeof(STxDataHead_a_FB); } else if (bRTS == false) { //RTS_needless pvRrvTime = (PSRrvTime_ab) (pbyTxBufferAddr + wTxBufSize); diff --git a/drivers/staging/vt6656/rxtx.h b/drivers/staging/vt6656/rxtx.h index 3e347a932ede8..8ce5bfcd737a5 100644 --- a/drivers/staging/vt6656/rxtx.h +++ b/drivers/staging/vt6656/rxtx.h @@ -32,6 +32,59 @@ #include "device.h" #include "wcmd.h" +/* RTS buffer header */ +struct vnt_rts_g { + u8 bySignalField_b; + u8 byServiceField_b; + u16 wTransmitLength_b; + u8 bySignalField_a; + u8 byServiceField_a; + u16 wTransmitLength_a; + u16 wDuration_ba; + u16 wDuration_aa; + u16 wDuration_bb; + u16 wReserved; + struct ieee80211_rts data; +} __packed; + +struct vnt_rts_g_fb { + u8 bySignalField_b; + u8 byServiceField_b; + u16 wTransmitLength_b; + u8 bySignalField_a; + u8 byServiceField_a; + u16 wTransmitLength_a; + u16 wDuration_ba; + u16 wDuration_aa; + u16 wDuration_bb; + u16 wReserved; + u16 wRTSDuration_ba_f0; + u16 wRTSDuration_aa_f0; + u16 wRTSDuration_ba_f1; + u16 wRTSDuration_aa_f1; + struct ieee80211_rts data; +} __packed; + +struct vnt_rts_ab { + u8 bySignalField; + u8 byServiceField; + u16 wTransmitLength; + u16 wDuration; + u16 wReserved; + struct ieee80211_rts data; +} __packed; + +struct vnt_rts_a_fb { + u8 bySignalField; + u8 byServiceField; + u16 wTransmitLength; + u16 wDuration; + u16 wReserved; + u16 wRTSDuration_f0; + u16 wRTSDuration_f1; + struct ieee80211_rts data; +} __packed; + struct vnt_tx_buffer { u8 byType; u8 byPKTNO; -- GitLab From f0c5ba2815d589854dff557b913a1b61b22bb458 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Thu, 15 Aug 2013 21:27:22 +0100 Subject: [PATCH 647/942] staging: vt6656: desc.h Move typedef struct tagSCTS* to new structures in rxtx.h The new structures being typedef struct tagSCTS -> struct vnt_cts typedef struct tagSCTS_FB -> struct vnt_cts_fb These are only needed by rxtc.c so moved to rxtx.h and will eventually form part of the structure of struct vnt_tx_buffer. The linux/ieee80211.h in desc.h is no longer needed. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/desc.h | 32 ------------------------- drivers/staging/vt6656/rxtx.c | 45 +++++++++++++++++++++++------------ drivers/staging/vt6656/rxtx.h | 23 ++++++++++++++++++ 3 files changed, 53 insertions(+), 47 deletions(-) diff --git a/drivers/staging/vt6656/desc.h b/drivers/staging/vt6656/desc.h index 4e2eb1886936b..d770a78e37dec 100644 --- a/drivers/staging/vt6656/desc.h +++ b/drivers/staging/vt6656/desc.h @@ -33,7 +33,6 @@ #include #include -#include #include "tether.h" @@ -185,37 +184,6 @@ SRrvTime_atim, *PSRrvTime_atim; typedef const SRrvTime_atim *PCSRrvTime_atim; -/* - * CTS buffer header - */ -typedef struct tagSCTS { - u8 bySignalField_b; - u8 byServiceField_b; - u16 wTransmitLength_b; - u16 wDuration_ba; - u16 wReserved; - struct ieee80211_cts data; - u16 reserved2; -} __attribute__ ((__packed__)) -SCTS, *PSCTS; - -typedef const SCTS *PCSCTS; - -typedef struct tagSCTS_FB { - u8 bySignalField_b; - u8 byServiceField_b; - u16 wTransmitLength_b; - u16 wDuration_ba; - u16 wReserved; - u16 wCTSDuration_ba_f0; - u16 wCTSDuration_ba_f1; - struct ieee80211_cts data; - u16 reserved2; -} __attribute__ ((__packed__)) -SCTS_FB, *PSCTS_FB; - -typedef const SCTS_FB *PCSCTS_FB; - /* * TX FIFO header */ diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index e7ff84520fe26..d9827b31cfef9 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -822,7 +822,7 @@ static void s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx, if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { if (byFBOption != AUTO_FB_NONE && uDMAIdx != TYPE_ATIMDMA && uDMAIdx != TYPE_BEACONDMA) { // Auto Fall back - PSCTS_FB pBuf = (PSCTS_FB)pvCTS; + struct vnt_cts_fb *pBuf = (struct vnt_cts_fb *)pvCTS; //Get SignalField,ServiceField,Length BBvCalculateParameter(pDevice, uCTSFrameLen, pDevice->byTopCCKBasicRate, PK_TYPE_11B, (u16 *)&(wLen), (u8 *)&(pBuf->byServiceField_b), (u8 *)&(pBuf->bySignalField_b) @@ -844,7 +844,7 @@ static void s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx, pBuf->data.frame_control = TYPE_CTL_CTS; memcpy(pBuf->data.ra, pDevice->abyCurrentNetAddr, ETH_ALEN); } else { //if (byFBOption != AUTO_FB_NONE && uDMAIdx != TYPE_ATIMDMA && uDMAIdx != TYPE_BEACONDMA) - PSCTS pBuf = (PSCTS)pvCTS; + struct vnt_cts *pBuf = (struct vnt_cts *)pvCTS; //Get SignalField,ServiceField,Length BBvCalculateParameter(pDevice, uCTSFrameLen, pDevice->byTopCCKBasicRate, PK_TYPE_11B, (u16 *)&(wLen), (u8 *)&(pBuf->byServiceField_b), (u8 *)&(pBuf->bySignalField_b) @@ -1165,9 +1165,13 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, pvRrvTime = (PSRrvTime_gCTS) (pbyTxBufferAddr + wTxBufSize); pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gCTS)); pvRTS = NULL; - pvCTS = (PSCTS) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gCTS) + cbMICHDR); - pvTxDataHd = (PSTxDataHead_g) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gCTS) + cbMICHDR + sizeof(SCTS)); - cbHeaderLength = wTxBufSize + sizeof(SRrvTime_gCTS) + cbMICHDR + sizeof(SCTS) + sizeof(STxDataHead_g); + pvCTS = (struct vnt_cts *) (pbyTxBufferAddr + wTxBufSize + + sizeof(SRrvTime_gCTS) + cbMICHDR); + pvTxDataHd = (PSTxDataHead_g) (pbyTxBufferAddr + wTxBufSize + + sizeof(SRrvTime_gCTS) + cbMICHDR + + sizeof(struct vnt_cts)); + cbHeaderLength = wTxBufSize + sizeof(SRrvTime_gCTS) + cbMICHDR + + sizeof(struct vnt_cts) + sizeof(STxDataHead_g); } } else { // Auto Fall Back @@ -1187,9 +1191,14 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, pvRrvTime = (PSRrvTime_gCTS) (pbyTxBufferAddr + wTxBufSize); pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gCTS)); pvRTS = NULL; - pvCTS = (PSCTS_FB) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gCTS) + cbMICHDR); - pvTxDataHd = (PSTxDataHead_g_FB) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gCTS) + cbMICHDR + sizeof(SCTS_FB)); - cbHeaderLength = wTxBufSize + sizeof(SRrvTime_gCTS) + cbMICHDR + sizeof(SCTS_FB) + sizeof(STxDataHead_g_FB); + pvCTS = (struct vnt_cts_fb *) (pbyTxBufferAddr + wTxBufSize + + sizeof(SRrvTime_gCTS) + cbMICHDR); + pvTxDataHd = (PSTxDataHead_g_FB) (pbyTxBufferAddr + + wTxBufSize + sizeof(SRrvTime_gCTS) + cbMICHDR + + sizeof(struct vnt_cts_fb)); + cbHeaderLength = wTxBufSize + sizeof(SRrvTime_gCTS) + + cbMICHDR + sizeof(struct vnt_cts_fb) + + sizeof(STxDataHead_g_FB); } } // Auto Fall Back } @@ -1508,7 +1517,7 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice, PSTxBufHead pTxBufHead; PUSB_SEND_CONTEXT pContext; struct ieee80211_hdr *pMACHeader; - PSCTS pCTS; + struct vnt_cts *pCTS; struct ethhdr sEthHeader; u8 byPktType, *pbyTxBufferAddr; void *pvRTS, *pvTxDataHd, *pvRrvTime, *pMICHDR; @@ -1647,9 +1656,12 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice, pvRrvTime = (PSRrvTime_gCTS) (pbyTxBufferAddr + wTxBufSize); pMICHDR = NULL; pvRTS = NULL; - pCTS = (PSCTS) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gCTS)); - pvTxDataHd = (PSTxDataHead_g) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gCTS) + sizeof(SCTS)); - cbHeaderSize = wTxBufSize + sizeof(SRrvTime_gCTS) + sizeof(SCTS) + sizeof(STxDataHead_g); + pCTS = (struct vnt_cts *) (pbyTxBufferAddr + wTxBufSize + + sizeof(SRrvTime_gCTS)); + pvTxDataHd = (PSTxDataHead_g) (pbyTxBufferAddr + wTxBufSize + + sizeof(SRrvTime_gCTS) + sizeof(struct vnt_cts)); + cbHeaderSize = wTxBufSize + sizeof(SRrvTime_gCTS) + + sizeof(struct vnt_cts) + sizeof(STxDataHead_g); } else { // 802.11a/b packet pvRrvTime = (PSRrvTime_ab) (pbyTxBufferAddr + wTxBufSize); @@ -2047,9 +2059,12 @@ void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb) pvRrvTime = (PSRrvTime_gCTS) (pbyTxBufferAddr + wTxBufSize); pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gCTS)); pvRTS = NULL; - pvCTS = (PSCTS) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gCTS) + cbMICHDR); - pvTxDataHd = (PSTxDataHead_g) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gCTS) + cbMICHDR + sizeof(SCTS)); - cbHeaderSize = wTxBufSize + sizeof(SRrvTime_gCTS) + cbMICHDR + sizeof(SCTS) + sizeof(STxDataHead_g); + pvCTS = (struct vnt_cts *) (pbyTxBufferAddr + wTxBufSize + + sizeof(SRrvTime_gCTS) + cbMICHDR); + pvTxDataHd = (PSTxDataHead_g) (pbyTxBufferAddr + wTxBufSize + + sizeof(SRrvTime_gCTS) + cbMICHDR + sizeof(struct vnt_cts)); + cbHeaderSize = wTxBufSize + sizeof(SRrvTime_gCTS) + cbMICHDR + + sizeof(struct vnt_cts) + sizeof(STxDataHead_g); } else {//802.11a/b packet diff --git a/drivers/staging/vt6656/rxtx.h b/drivers/staging/vt6656/rxtx.h index 8ce5bfcd737a5..8fd5be175e6b0 100644 --- a/drivers/staging/vt6656/rxtx.h +++ b/drivers/staging/vt6656/rxtx.h @@ -85,6 +85,29 @@ struct vnt_rts_a_fb { struct ieee80211_rts data; } __packed; +/* CTS buffer header */ +struct vnt_cts { + u8 bySignalField_b; + u8 byServiceField_b; + u16 wTransmitLength_b; + u16 wDuration_ba; + u16 wReserved; + struct ieee80211_cts data; + u16 reserved2; +} __packed; + +struct vnt_cts_fb { + u8 bySignalField_b; + u8 byServiceField_b; + u16 wTransmitLength_b; + u16 wDuration_ba; + u16 wReserved; + u16 wCTSDuration_ba_f0; + u16 wCTSDuration_ba_f1; + struct ieee80211_cts data; + u16 reserved2; +} __packed; + struct vnt_tx_buffer { u8 byType; u8 byPKTNO; -- GitLab From 45acea57335ece628bdf96dc35d2ebdefd1efb9e Mon Sep 17 00:00:00 2001 From: Yann Droneaud Date: Thu, 15 Aug 2013 15:10:53 +0200 Subject: [PATCH 648/942] android/sw_sync: use get_unused_fd_flags(O_CLOEXEC) instead of get_unused_fd() Macro get_unused_fd() is used to allocate a file descriptor with default flags. Those default flags (0) can be "unsafe": O_CLOEXEC must be used by default to not leak file descriptor across exec(). Instead of macro get_unused_fd(), functions anon_inode_getfd() or get_unused_fd_flags() should be used with flags given by userspace. If not possible, flags should be set to O_CLOEXEC to provide userspace with a default safe behavor. In a further patch, get_unused_fd() will be removed so that new code start using anon_inode_getfd() or get_unused_fd_flags() with correct flags. This patch replaces calls to get_unused_fd() with call to get_unused_fd_flags(O_CLOEXEC) following advice from Erik Gilling. Signed-off-by: Yann Droneaud Cc: Erik Gilling Cc: Colin Cross Link: http://lkml.kernel.org/r/CACSP8SjZcpcpEtQHzcGYhf-MP7QGo0XpN7-uN7rmD=vNtopG=w@mail.gmail.com Link: http://lkml.kernel.org/r/cover.1376327678.git.ydroneaud@opteya.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/sw_sync.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/android/sw_sync.c b/drivers/staging/android/sw_sync.c index 765c757b120f2..f24493ac65e3e 100644 --- a/drivers/staging/android/sw_sync.c +++ b/drivers/staging/android/sw_sync.c @@ -163,7 +163,7 @@ static int sw_sync_release(struct inode *inode, struct file *file) static long sw_sync_ioctl_create_fence(struct sw_sync_timeline *obj, unsigned long arg) { - int fd = get_unused_fd(); + int fd = get_unused_fd_flags(O_CLOEXEC); int err; struct sync_pt *pt; struct sync_fence *fence; -- GitLab From 9c6cd3b39048c8bbb83c5cd936f4dffc847321c6 Mon Sep 17 00:00:00 2001 From: Yann Droneaud Date: Thu, 15 Aug 2013 15:10:54 +0200 Subject: [PATCH 649/942] android/sync: use get_unused_fd_flags(O_CLOEXEC) instead of get_unused_fd() Macro get_unused_fd() is used to allocate a file descriptor with default flags. Those default flags (0) can be "unsafe": O_CLOEXEC must be used by default to not leak file descriptor across exec(). Instead of macro get_unused_fd(), functions anon_inode_getfd() or get_unused_fd_flags() should be used with flags given by userspace. If not possible, flags should be set to O_CLOEXEC to provide userspace with a default safe behavor. In a further patch, get_unused_fd() will be removed so that new code start using anon_inode_getfd() or get_unused_fd_flags() with correct flags. This patch replaces calls to get_unused_fd() with call to get_unused_fd_flags(O_CLOEXEC) following advice from Erik Gilling. Signed-off-by: Yann Droneaud Cc: Erik Gilling Cc: Colin Cross Link: http://lkml.kernel.org/r/CACSP8SjXGMk2_kX_+RgzqqQwqKernvF1Wt3K5tw991W5dfAnCA@mail.gmail.com Link: http://lkml.kernel.org/r/cover.1376327678.git.ydroneaud@opteya.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/sync.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c index 2996077fedef1..38e5d3b5ed9b6 100644 --- a/drivers/staging/android/sync.c +++ b/drivers/staging/android/sync.c @@ -697,7 +697,7 @@ static long sync_fence_ioctl_wait(struct sync_fence *fence, unsigned long arg) static long sync_fence_ioctl_merge(struct sync_fence *fence, unsigned long arg) { - int fd = get_unused_fd(); + int fd = get_unused_fd_flags(O_CLOEXEC); int err; struct sync_fence *fence2, *fence3; struct sync_merge_data data; -- GitLab From e5a639421821c7cd11832fd7fbe6376bfb304880 Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Thu, 8 Aug 2013 17:39:00 +0100 Subject: [PATCH 650/942] iio: Add tmp006 IR temperature sensor the TI TMP006 is a non-contact temperature sensor with I2C interface; it measures the surface temperature of a distance object using a thermopile to absorb IR energy emitted from the object the sensor has two channels: IR sensor voltage (16-bit) and reference temperature of the chip (14-bit); datasheet is here: http://www.ti.com/lit/ds/symlink/tmp006.pdf v2 (thanks to Grygorii Strashko, Lars-Peter Clausen, Jonathan Cameron for review comments): * power down device on driver remove * use sign_extend32() * style cleanup * add comments what channel raw LSBs mean * spelling of thermopile Signed-off-by: Peter Meerwald Cc: Grygorii Strashko Cc: Lars-Peter Clausen Cc: Jonathan Cameron Cc: LM Sensors Signed-off-by: Jonathan Cameron --- drivers/iio/Kconfig | 1 + drivers/iio/Makefile | 1 + drivers/iio/temperature/Kconfig | 16 ++ drivers/iio/temperature/Makefile | 5 + drivers/iio/temperature/tmp006.c | 291 +++++++++++++++++++++++++++++++ 5 files changed, 314 insertions(+) create mode 100644 drivers/iio/temperature/Kconfig create mode 100644 drivers/iio/temperature/Makefile create mode 100644 drivers/iio/temperature/tmp006.c diff --git a/drivers/iio/Kconfig b/drivers/iio/Kconfig index 524380c9ae6cb..cbea3271c1b1a 100644 --- a/drivers/iio/Kconfig +++ b/drivers/iio/Kconfig @@ -73,5 +73,6 @@ if IIO_TRIGGER source "drivers/iio/trigger/Kconfig" endif #IIO_TRIGGER source "drivers/iio/pressure/Kconfig" +source "drivers/iio/temperature/Kconfig" endif # IIO diff --git a/drivers/iio/Makefile b/drivers/iio/Makefile index 7a3866c2d2a14..a0547f59e88f9 100644 --- a/drivers/iio/Makefile +++ b/drivers/iio/Makefile @@ -21,5 +21,6 @@ obj-y += frequency/ obj-y += imu/ obj-y += light/ obj-y += magnetometer/ +obj-y += temperature/ obj-y += trigger/ obj-y += pressure/ diff --git a/drivers/iio/temperature/Kconfig b/drivers/iio/temperature/Kconfig new file mode 100644 index 0000000000000..372f8fb3085fa --- /dev/null +++ b/drivers/iio/temperature/Kconfig @@ -0,0 +1,16 @@ +# +# Temperature sensor drivers +# +menu "Temperature sensors" + +config TMP006 + tristate "TMP006 infrared thermopile sensor" + depends on I2C + help + If you say yes here you get support for the Texas Instruments + TMP006 infrared thermopile sensor. + + This driver can also be built as a module. If so, the module will + be called tmp006. + +endmenu diff --git a/drivers/iio/temperature/Makefile b/drivers/iio/temperature/Makefile new file mode 100644 index 0000000000000..24d7b602db3ec --- /dev/null +++ b/drivers/iio/temperature/Makefile @@ -0,0 +1,5 @@ +# +# Makefile for industrial I/O temperature drivers +# + +obj-$(CONFIG_TMP006) += tmp006.o diff --git a/drivers/iio/temperature/tmp006.c b/drivers/iio/temperature/tmp006.c new file mode 100644 index 0000000000000..64ccde3f1f7a6 --- /dev/null +++ b/drivers/iio/temperature/tmp006.c @@ -0,0 +1,291 @@ +/* + * tmp006.c - Support for TI TMP006 IR thermopile sensor + * + * Copyright (c) 2013 Peter Meerwald + * + * This file is subject to the terms and conditions of version 2 of + * the GNU General Public License. See the file COPYING in the main + * directory of this archive for more details. + * + * Driver for the Texas Instruments I2C 16-bit IR thermopile sensor + * + * (7-bit I2C slave address 0x40, changeable via ADR pins) + * + * TODO: data ready irq + */ + +#include +#include +#include +#include +#include +#include + +#include +#include + +#define TMP006_VOBJECT 0x00 +#define TMP006_TAMBIENT 0x01 +#define TMP006_CONFIG 0x02 +#define TMP006_MANUFACTURER_ID 0xfe +#define TMP006_DEVICE_ID 0xff + +#define TMP006_TAMBIENT_SHIFT 2 + +#define TMP006_CONFIG_RESET BIT(15) +#define TMP006_CONFIG_DRDY_EN BIT(8) +#define TMP006_CONFIG_DRDY BIT(7) + +#define TMP006_CONFIG_MOD_MASK 0x7000 + +#define TMP006_CONFIG_CR_MASK 0x0e00 +#define TMP006_CONFIG_CR_SHIFT 9 + +#define MANUFACTURER_MAGIC 0x5449 +#define DEVICE_MAGIC 0x0067 + +struct tmp006_data { + struct i2c_client *client; + u16 config; +}; + +static int tmp006_read_measurement(struct tmp006_data *data, u8 reg) +{ + s32 ret; + int tries = 50; + + while (tries-- > 0) { + ret = i2c_smbus_read_word_swapped(data->client, + TMP006_CONFIG); + if (ret < 0) + return ret; + if (ret & TMP006_CONFIG_DRDY) + break; + msleep(100); + } + + if (tries < 0) + return -EIO; + + return i2c_smbus_read_word_swapped(data->client, reg); +} + +static int tmp006_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *channel, int *val, + int *val2, long mask) +{ + struct tmp006_data *data = iio_priv(indio_dev); + s32 ret; + + switch (mask) { + case IIO_CHAN_INFO_RAW: + if (channel->type == IIO_VOLTAGE) { + /* LSB is 156.25 nV */ + ret = tmp006_read_measurement(data, TMP006_VOBJECT); + if (ret < 0) + return ret; + *val = sign_extend32(ret, 15); + } else if (channel->type == IIO_TEMP) { + /* LSB is 0.03125 degrees Celsius */ + ret = tmp006_read_measurement(data, TMP006_TAMBIENT); + if (ret < 0) + return ret; + *val = sign_extend32(ret, 15) >> TMP006_TAMBIENT_SHIFT; + } else { + break; + } + return IIO_VAL_INT; + case IIO_CHAN_INFO_SCALE: + if (channel->type == IIO_VOLTAGE) { + *val = 0; + *val2 = 156250; + } else if (channel->type == IIO_TEMP) { + *val = 31; + *val2 = 250000; + } else { + break; + } + return IIO_VAL_INT_PLUS_MICRO; + default: + break; + } + + return -EINVAL; +} + +static const char * const tmp006_freqs[] = { "4", "2", "1", "0.5", "0.25" }; + +static ssize_t tmp006_show_freq(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct tmp006_data *data = iio_priv(dev_to_iio_dev(dev)); + int cr = (data->config & TMP006_CONFIG_CR_MASK) + >> TMP006_CONFIG_CR_SHIFT; + return sprintf(buf, "%s\n", tmp006_freqs[cr]); +} + +static ssize_t tmp006_store_freq(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t len) +{ + struct iio_dev *indio_dev = dev_to_iio_dev(dev); + struct tmp006_data *data = iio_priv(indio_dev); + int i; + bool found = false; + + for (i = 0; i < ARRAY_SIZE(tmp006_freqs); i++) + if (sysfs_streq(buf, tmp006_freqs[i])) { + found = true; + break; + } + if (!found) + return -EINVAL; + + data->config &= ~TMP006_CONFIG_CR_MASK; + data->config |= i << TMP006_CONFIG_CR_SHIFT; + + return i2c_smbus_write_word_swapped(data->client, TMP006_CONFIG, + data->config); +} + +static IIO_DEV_ATTR_SAMP_FREQ(S_IRUGO | S_IWUSR, + tmp006_show_freq, tmp006_store_freq); + +static IIO_CONST_ATTR(sampling_frequency_available, "4 2 1 0.5 0.25"); + +static struct attribute *tmp006_attributes[] = { + &iio_dev_attr_sampling_frequency.dev_attr.attr, + &iio_const_attr_sampling_frequency_available.dev_attr.attr, + NULL +}; + +static const struct attribute_group tmp006_attribute_group = { + .attrs = tmp006_attributes, +}; + +static const struct iio_chan_spec tmp006_channels[] = { + { + .type = IIO_VOLTAGE, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE), + }, + { + .type = IIO_TEMP, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE), + } +}; + +static const struct iio_info tmp006_info = { + .read_raw = tmp006_read_raw, + .attrs = &tmp006_attribute_group, + .driver_module = THIS_MODULE, +}; + +static bool tmp006_check_identification(struct i2c_client *client) +{ + int mid, did; + + mid = i2c_smbus_read_word_swapped(client, TMP006_MANUFACTURER_ID); + if (mid < 0) + return false; + + did = i2c_smbus_read_word_swapped(client, TMP006_DEVICE_ID); + if (did < 0) + return false; + + return mid == MANUFACTURER_MAGIC && did == DEVICE_MAGIC; +} + +static int tmp006_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct iio_dev *indio_dev; + struct tmp006_data *data; + int ret; + + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WORD_DATA)) + return -ENODEV; + + if (!tmp006_check_identification(client)) { + dev_err(&client->dev, "no TMP006 sensor\n"); + return -ENODEV; + } + + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); + if (!indio_dev) + return -ENOMEM; + + data = iio_priv(indio_dev); + i2c_set_clientdata(client, indio_dev); + data->client = client; + + indio_dev->dev.parent = &client->dev; + indio_dev->name = dev_name(&client->dev); + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->info = &tmp006_info; + + indio_dev->channels = tmp006_channels; + indio_dev->num_channels = ARRAY_SIZE(tmp006_channels); + + ret = i2c_smbus_read_word_swapped(data->client, TMP006_CONFIG); + if (ret < 0) + return ret; + data->config = ret; + + return iio_device_register(indio_dev); +} + +static int tmp006_powerdown(struct tmp006_data *data) +{ + return i2c_smbus_write_word_swapped(data->client, TMP006_CONFIG, + data->config & ~TMP006_CONFIG_MOD_MASK); +} + +static int tmp006_remove(struct i2c_client *client) +{ + struct iio_dev *indio_dev = i2c_get_clientdata(client); + + iio_device_unregister(indio_dev); + tmp006_powerdown(iio_priv(indio_dev)); + + return 0; +} + +#ifdef CONFIG_PM_SLEEP +static int tmp006_suspend(struct device *dev) +{ + return tmp006_powerdown(iio_priv(dev_to_iio_dev(dev))); +} + +static int tmp006_resume(struct device *dev) +{ + struct tmp006_data *data = iio_priv(dev_to_iio_dev(dev)); + return i2c_smbus_write_word_swapped(data->client, TMP006_CONFIG, + data->config | TMP006_CONFIG_MOD_MASK); +} +#endif + +static SIMPLE_DEV_PM_OPS(tmp006_pm_ops, tmp006_suspend, tmp006_resume); + +static const struct i2c_device_id tmp006_id[] = { + { "tmp006", 0 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, tmp006_id); + +static struct i2c_driver tmp006_driver = { + .driver = { + .name = "tmp006", + .pm = &tmp006_pm_ops, + .owner = THIS_MODULE, + }, + .probe = tmp006_probe, + .remove = tmp006_remove, + .id_table = tmp006_id, +}; +module_i2c_driver(tmp006_driver); + +MODULE_AUTHOR("Peter Meerwald "); +MODULE_DESCRIPTION("TI TMP006 IR thermopile sensor driver"); +MODULE_LICENSE("GPL"); -- GitLab From a5db3609989f7a496bf645783f22dfc2c285d37e Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Thu, 8 Aug 2013 17:39:00 +0100 Subject: [PATCH 651/942] iio: Restore alphabetic order in Makefile Signed-off-by: Peter Meerwald Signed-off-by: Jonathan Cameron --- drivers/iio/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/Makefile b/drivers/iio/Makefile index a0547f59e88f9..bcf7e9e3b053b 100644 --- a/drivers/iio/Makefile +++ b/drivers/iio/Makefile @@ -21,6 +21,6 @@ obj-y += frequency/ obj-y += imu/ obj-y += light/ obj-y += magnetometer/ +obj-y += pressure/ obj-y += temperature/ obj-y += trigger/ -obj-y += pressure/ -- GitLab From da419463d8819b66c2795b0fdbf462a1766d9ace Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 13 Aug 2013 07:34:00 +0100 Subject: [PATCH 652/942] iio: gyro: adis16080: Use devm_iio_device_alloc Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat Acked-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/iio/gyro/adis16080.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/drivers/iio/gyro/adis16080.c b/drivers/iio/gyro/adis16080.c index e1bb5f994a548..e9ec022ae2250 100644 --- a/drivers/iio/gyro/adis16080.c +++ b/drivers/iio/gyro/adis16080.c @@ -192,16 +192,13 @@ static const struct adis16080_chip_info adis16080_chip_info[] = { static int adis16080_probe(struct spi_device *spi) { const struct spi_device_id *id = spi_get_device_id(spi); - int ret; struct adis16080_state *st; struct iio_dev *indio_dev; /* setup the industrialio driver allocated elements */ - indio_dev = iio_device_alloc(sizeof(*st)); - if (indio_dev == NULL) { - ret = -ENOMEM; - goto error_ret; - } + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); + if (!indio_dev) + return -ENOMEM; st = iio_priv(indio_dev); /* this is only used for removal purposes */ spi_set_drvdata(spi, indio_dev); @@ -217,22 +214,12 @@ static int adis16080_probe(struct spi_device *spi) indio_dev->info = &adis16080_info; indio_dev->modes = INDIO_DIRECT_MODE; - ret = iio_device_register(indio_dev); - if (ret) - goto error_free_dev; - return 0; - -error_free_dev: - iio_device_free(indio_dev); -error_ret: - return ret; + return iio_device_register(indio_dev); } static int adis16080_remove(struct spi_device *spi) { iio_device_unregister(spi_get_drvdata(spi)); - iio_device_free(spi_get_drvdata(spi)); - return 0; } -- GitLab From 42aceff5a26713a50239504ff30ce78beac66b6a Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 13 Aug 2013 07:34:00 +0100 Subject: [PATCH 653/942] iio: gyro: adis16130: Use devm_iio_device_alloc Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat Acked-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/iio/gyro/adis16130.c | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/drivers/iio/gyro/adis16130.c b/drivers/iio/gyro/adis16130.c index 129acdf801a40..ac66fc184042e 100644 --- a/drivers/iio/gyro/adis16130.c +++ b/drivers/iio/gyro/adis16130.c @@ -148,16 +148,13 @@ static const struct iio_info adis16130_info = { static int adis16130_probe(struct spi_device *spi) { - int ret; struct adis16130_state *st; struct iio_dev *indio_dev; /* setup the industrialio driver allocated elements */ - indio_dev = iio_device_alloc(sizeof(*st)); - if (indio_dev == NULL) { - ret = -ENOMEM; - goto error_ret; - } + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); + if (!indio_dev) + return -ENOMEM; st = iio_priv(indio_dev); /* this is only used for removal purposes */ spi_set_drvdata(spi, indio_dev); @@ -170,24 +167,12 @@ static int adis16130_probe(struct spi_device *spi) indio_dev->info = &adis16130_info; indio_dev->modes = INDIO_DIRECT_MODE; - ret = iio_device_register(indio_dev); - if (ret) - goto error_free_dev; - - return 0; - -error_free_dev: - iio_device_free(indio_dev); - -error_ret: - return ret; + return iio_device_register(indio_dev); } static int adis16130_remove(struct spi_device *spi) { iio_device_unregister(spi_get_drvdata(spi)); - iio_device_free(spi_get_drvdata(spi)); - return 0; } -- GitLab From c0ca6d31a519682445e4c672b92f27ff7e0c5a7f Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 13 Aug 2013 07:34:00 +0100 Subject: [PATCH 654/942] iio: gyro: adis16136: Use devm_iio_device_alloc Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat Cc: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/iio/gyro/adis16136.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/iio/gyro/adis16136.c b/drivers/iio/gyro/adis16136.c index 058e6d5c955fa..591bd555e1f39 100644 --- a/drivers/iio/gyro/adis16136.c +++ b/drivers/iio/gyro/adis16136.c @@ -497,7 +497,7 @@ static int adis16136_probe(struct spi_device *spi) struct iio_dev *indio_dev; int ret; - indio_dev = iio_device_alloc(sizeof(*adis16136)); + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adis16136)); if (indio_dev == NULL) return -ENOMEM; @@ -515,11 +515,11 @@ static int adis16136_probe(struct spi_device *spi) ret = adis_init(&adis16136->adis, indio_dev, spi, &adis16136_data); if (ret) - goto error_free_dev; + return ret; ret = adis_setup_buffer_and_trigger(&adis16136->adis, indio_dev, NULL); if (ret) - goto error_free_dev; + return ret; ret = adis16136_initial_setup(indio_dev); if (ret) @@ -537,8 +537,6 @@ static int adis16136_probe(struct spi_device *spi) adis16136_stop_device(indio_dev); error_cleanup_buffer: adis_cleanup_buffer_and_trigger(&adis16136->adis, indio_dev); -error_free_dev: - iio_device_free(indio_dev); return ret; } @@ -552,8 +550,6 @@ static int adis16136_remove(struct spi_device *spi) adis_cleanup_buffer_and_trigger(&adis16136->adis, indio_dev); - iio_device_free(indio_dev); - return 0; } -- GitLab From 827b14a8ece91f3502ae4efe454197ce3210a231 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 13 Aug 2013 07:34:00 +0100 Subject: [PATCH 655/942] iio: gyro: adis16260: Use devm_iio_device_alloc Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat Acked-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/iio/gyro/adis16260.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/iio/gyro/adis16260.c b/drivers/iio/gyro/adis16260.c index b4cf800717ada..06541162fc021 100644 --- a/drivers/iio/gyro/adis16260.c +++ b/drivers/iio/gyro/adis16260.c @@ -343,11 +343,9 @@ static int adis16260_probe(struct spi_device *spi) int ret; /* setup the industrialio driver allocated elements */ - indio_dev = iio_device_alloc(sizeof(*adis)); - if (indio_dev == NULL) { - ret = -ENOMEM; - goto error_ret; - } + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adis)); + if (!indio_dev) + return -ENOMEM; adis = iio_priv(indio_dev); /* this is only used for removal purposes */ spi_set_drvdata(spi, indio_dev); @@ -361,11 +359,11 @@ static int adis16260_probe(struct spi_device *spi) ret = adis_init(adis, indio_dev, spi, &adis16260_data); if (ret) - goto error_free_dev; + return ret; ret = adis_setup_buffer_and_trigger(adis, indio_dev, NULL); if (ret) - goto error_free_dev; + return ret; /* Get the device into a sane initial state */ ret = adis_initial_startup(adis); @@ -379,9 +377,6 @@ static int adis16260_probe(struct spi_device *spi) error_cleanup_buffer_trigger: adis_cleanup_buffer_and_trigger(adis, indio_dev); -error_free_dev: - iio_device_free(indio_dev); -error_ret: return ret; } @@ -393,7 +388,6 @@ static int adis16260_remove(struct spi_device *spi) iio_device_unregister(indio_dev); adis16260_stop_device(indio_dev); adis_cleanup_buffer_and_trigger(adis, indio_dev); - iio_device_free(indio_dev); return 0; } -- GitLab From 1ba15cf249061c2f55f4a883ee142002261003a8 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 13 Aug 2013 07:34:00 +0100 Subject: [PATCH 656/942] iio: hid-sensor-gyro-3d: Use devm_iio_device_alloc Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat Cc: Srinivas Pandruvada Signed-off-by: Jonathan Cameron --- drivers/iio/gyro/hid-sensor-gyro-3d.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c index 9cc8aa1102d7c..d9d7befdd77b4 100644 --- a/drivers/iio/gyro/hid-sensor-gyro-3d.c +++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c @@ -282,11 +282,9 @@ static int hid_gyro_3d_probe(struct platform_device *pdev) struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data; struct iio_chan_spec *channels; - indio_dev = iio_device_alloc(sizeof(struct gyro_3d_state)); - if (indio_dev == NULL) { - ret = -ENOMEM; - goto error_ret; - } + indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*gyro_state)); + if (!indio_dev) + return -ENOMEM; platform_set_drvdata(pdev, indio_dev); gyro_state = iio_priv(indio_dev); @@ -298,15 +296,14 @@ static int hid_gyro_3d_probe(struct platform_device *pdev) &gyro_state->common_attributes); if (ret) { dev_err(&pdev->dev, "failed to setup common attributes\n"); - goto error_free_dev; + return ret; } channels = kmemdup(gyro_3d_channels, sizeof(gyro_3d_channels), GFP_KERNEL); if (!channels) { - ret = -ENOMEM; dev_err(&pdev->dev, "failed to duplicate channels\n"); - goto error_free_dev; + return -ENOMEM; } ret = gyro_3d_parse_report(pdev, hsdev, channels, @@ -363,9 +360,6 @@ static int hid_gyro_3d_probe(struct platform_device *pdev) iio_triggered_buffer_cleanup(indio_dev); error_free_dev_mem: kfree(indio_dev->channels); -error_free_dev: - iio_device_free(indio_dev); -error_ret: return ret; } @@ -380,7 +374,6 @@ static int hid_gyro_3d_remove(struct platform_device *pdev) hid_sensor_remove_trigger(indio_dev); iio_triggered_buffer_cleanup(indio_dev); kfree(indio_dev->channels); - iio_device_free(indio_dev); return 0; } -- GitLab From 6694cf9652c718b624c459867e7833c759665225 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 13 Aug 2013 07:34:00 +0100 Subject: [PATCH 657/942] iio: gyro: adxrs450: Use devm_iio_device_alloc Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat Signed-off-by: Jonathan Cameron --- drivers/iio/gyro/adxrs450.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/iio/gyro/adxrs450.c b/drivers/iio/gyro/adxrs450.c index 8bd72b490b7f1..6dab2995f0f26 100644 --- a/drivers/iio/gyro/adxrs450.c +++ b/drivers/iio/gyro/adxrs450.c @@ -426,11 +426,9 @@ static int adxrs450_probe(struct spi_device *spi) struct iio_dev *indio_dev; /* setup the industrialio driver allocated elements */ - indio_dev = iio_device_alloc(sizeof(*st)); - if (indio_dev == NULL) { - ret = -ENOMEM; - goto error_ret; - } + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); + if (!indio_dev) + return -ENOMEM; st = iio_priv(indio_dev); st->us = spi; mutex_init(&st->buf_lock); @@ -447,7 +445,7 @@ static int adxrs450_probe(struct spi_device *spi) ret = iio_device_register(indio_dev); if (ret) - goto error_free_dev; + return ret; /* Get the device into a sane initial state */ ret = adxrs450_initial_setup(indio_dev); @@ -456,17 +454,12 @@ static int adxrs450_probe(struct spi_device *spi) return 0; error_initial: iio_device_unregister(indio_dev); -error_free_dev: - iio_device_free(indio_dev); - -error_ret: return ret; } static int adxrs450_remove(struct spi_device *spi) { iio_device_unregister(spi_get_drvdata(spi)); - iio_device_free(spi_get_drvdata(spi)); return 0; } -- GitLab From d243b3c06d4d462ccc8d29dacb894cb25d56972f Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 13 Aug 2013 07:34:00 +0100 Subject: [PATCH 658/942] iio: gyro: itg3200_core: Use devm_iio_device_alloc Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat Cc: Christian Strobel Signed-off-by: Jonathan Cameron --- drivers/iio/gyro/itg3200_core.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/iio/gyro/itg3200_core.c b/drivers/iio/gyro/itg3200_core.c index d66605d2629d8..4d3f3b92b361e 100644 --- a/drivers/iio/gyro/itg3200_core.c +++ b/drivers/iio/gyro/itg3200_core.c @@ -309,11 +309,9 @@ static int itg3200_probe(struct i2c_client *client, dev_dbg(&client->dev, "probe I2C dev with IRQ %i", client->irq); - indio_dev = iio_device_alloc(sizeof(*st)); - if (indio_dev == NULL) { - ret = -ENOMEM; - goto error_ret; - } + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*st)); + if (!indio_dev) + return -ENOMEM; st = iio_priv(indio_dev); @@ -330,7 +328,7 @@ static int itg3200_probe(struct i2c_client *client, ret = itg3200_buffer_configure(indio_dev); if (ret) - goto error_free_dev; + return ret; if (client->irq) { ret = itg3200_probe_trigger(indio_dev); @@ -353,9 +351,6 @@ static int itg3200_probe(struct i2c_client *client, itg3200_remove_trigger(indio_dev); error_unconfigure_buffer: itg3200_buffer_unconfigure(indio_dev); -error_free_dev: - iio_device_free(indio_dev); -error_ret: return ret; } @@ -370,8 +365,6 @@ static int itg3200_remove(struct i2c_client *client) itg3200_buffer_unconfigure(indio_dev); - iio_device_free(indio_dev); - return 0; } -- GitLab From 7a842ed6e38807dba811b814d9b14813f33c0b4c Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 13 Aug 2013 07:34:00 +0100 Subject: [PATCH 659/942] iio: gyro: st_gyro: Use devm_iio_device_alloc Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat Cc: Denis Ciocca Signed-off-by: Jonathan Cameron --- drivers/iio/gyro/st_gyro_core.c | 1 - drivers/iio/gyro/st_gyro_i2c.c | 15 ++++----------- drivers/iio/gyro/st_gyro_spi.c | 15 ++++----------- 3 files changed, 8 insertions(+), 23 deletions(-) diff --git a/drivers/iio/gyro/st_gyro_core.c b/drivers/iio/gyro/st_gyro_core.c index 85fa8d343bb28..e13c2b0bf3d1a 100644 --- a/drivers/iio/gyro/st_gyro_core.c +++ b/drivers/iio/gyro/st_gyro_core.c @@ -366,7 +366,6 @@ void st_gyro_common_remove(struct iio_dev *indio_dev) st_sensors_deallocate_trigger(indio_dev); st_gyro_deallocate_ring(indio_dev); } - iio_device_free(indio_dev); } EXPORT_SYMBOL(st_gyro_common_remove); diff --git a/drivers/iio/gyro/st_gyro_i2c.c b/drivers/iio/gyro/st_gyro_i2c.c index c7a29a4d7e829..16b8b8d70bf12 100644 --- a/drivers/iio/gyro/st_gyro_i2c.c +++ b/drivers/iio/gyro/st_gyro_i2c.c @@ -25,11 +25,9 @@ static int st_gyro_i2c_probe(struct i2c_client *client, struct st_sensor_data *gdata; int err; - indio_dev = iio_device_alloc(sizeof(*gdata)); - if (indio_dev == NULL) { - err = -ENOMEM; - goto iio_device_alloc_error; - } + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*gdata)); + if (!indio_dev) + return -ENOMEM; gdata = iio_priv(indio_dev); gdata->dev = &client->dev; @@ -39,14 +37,9 @@ static int st_gyro_i2c_probe(struct i2c_client *client, err = st_gyro_common_probe(indio_dev, (struct st_sensors_platform_data *)&gyro_pdata); if (err < 0) - goto st_gyro_common_probe_error; + return err; return 0; - -st_gyro_common_probe_error: - iio_device_free(indio_dev); -iio_device_alloc_error: - return err; } static int st_gyro_i2c_remove(struct i2c_client *client) diff --git a/drivers/iio/gyro/st_gyro_spi.c b/drivers/iio/gyro/st_gyro_spi.c index 14b0762847f5b..94763e25caf99 100644 --- a/drivers/iio/gyro/st_gyro_spi.c +++ b/drivers/iio/gyro/st_gyro_spi.c @@ -24,11 +24,9 @@ static int st_gyro_spi_probe(struct spi_device *spi) struct st_sensor_data *gdata; int err; - indio_dev = iio_device_alloc(sizeof(*gdata)); - if (indio_dev == NULL) { - err = -ENOMEM; - goto iio_device_alloc_error; - } + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*gdata)); + if (!indio_dev) + return -ENOMEM; gdata = iio_priv(indio_dev); gdata->dev = &spi->dev; @@ -38,14 +36,9 @@ static int st_gyro_spi_probe(struct spi_device *spi) err = st_gyro_common_probe(indio_dev, (struct st_sensors_platform_data *)&gyro_pdata); if (err < 0) - goto st_gyro_common_probe_error; + return err; return 0; - -st_gyro_common_probe_error: - iio_device_free(indio_dev); -iio_device_alloc_error: - return err; } static int st_gyro_spi_remove(struct spi_device *spi) -- GitLab From 1f5ac5279891140036e1000276b74adbc6c0b039 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Tue, 13 Aug 2013 07:34:00 +0100 Subject: [PATCH 660/942] iio: gyro: adis16060_core: Use devm_iio_device_alloc Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat Acked-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/staging/iio/gyro/adis16060_core.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/drivers/staging/iio/gyro/adis16060_core.c b/drivers/staging/iio/gyro/adis16060_core.c index c67d3a832aef9..6d3d771154f3c 100644 --- a/drivers/staging/iio/gyro/adis16060_core.c +++ b/drivers/staging/iio/gyro/adis16060_core.c @@ -151,11 +151,9 @@ static int adis16060_r_probe(struct spi_device *spi) struct iio_dev *indio_dev; /* setup the industrialio driver allocated elements */ - indio_dev = iio_device_alloc(sizeof(*st)); - if (indio_dev == NULL) { - ret = -ENOMEM; - goto error_ret; - } + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); + if (!indio_dev) + return -ENOMEM; /* this is only used for removal purposes */ spi_set_drvdata(spi, indio_dev); st = iio_priv(indio_dev); @@ -171,23 +169,16 @@ static int adis16060_r_probe(struct spi_device *spi) ret = iio_device_register(indio_dev); if (ret) - goto error_free_dev; + return ret; adis16060_iio_dev = indio_dev; return 0; - -error_free_dev: - iio_device_free(indio_dev); -error_ret: - return ret; } /* fixme, confirm ordering in this function */ static int adis16060_r_remove(struct spi_device *spi) { iio_device_unregister(spi_get_drvdata(spi)); - iio_device_free(spi_get_drvdata(spi)); - return 0; } -- GitLab From 1eb70a97452cacbe7aae752879b782e1e97a3484 Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Mon, 22 Jul 2013 15:03:00 +0100 Subject: [PATCH 661/942] iio: mxs-lradc: change the realbits to 12 The LRADC virtual channels have an 18 bit field to store the sum of up to 2^5 accumulated samples. The read_raw function however only operates over a single sample (12 bit resolution). In order to use this field for scaling operations, we need it to be the exact resolution value of the LRADC. Besides, the driver was using an 18 bit mask (LRADC_CH_VALUE_MASK) to report touch coordinates to userland. A 12 bit mask should be used instead or else the touch libraries will expect a coordinates range between 0 and 0x3ffff (18 bits), instead of between 0 and 0xfff (12 bits). Signed-off-by: Hector Palacios Acked-by: Marek Vasut Acked-by: Alexandre Belloni Signed-off-by: Jonathan Cameron --- drivers/staging/iio/adc/mxs-lradc.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/adc/mxs-lradc.c b/drivers/staging/iio/adc/mxs-lradc.c index 863f0861b7290..a08c1736458b4 100644 --- a/drivers/staging/iio/adc/mxs-lradc.c +++ b/drivers/staging/iio/adc/mxs-lradc.c @@ -225,6 +225,9 @@ struct mxs_lradc { #define LRADC_CTRL4_LRADCSELECT_MASK(n) (0xf << ((n) * 4)) #define LRADC_CTRL4_LRADCSELECT_OFFSET(n) ((n) * 4) +#define LRADC_RESOLUTION 12 +#define LRADC_SINGLE_SAMPLE_MASK ((1 << LRADC_RESOLUTION) - 1) + /* * Raw I/O operations */ @@ -540,9 +543,10 @@ static int mxs_lradc_ts_register(struct mxs_lradc *lradc) __set_bit(EV_ABS, input->evbit); __set_bit(EV_KEY, input->evbit); __set_bit(BTN_TOUCH, input->keybit); - input_set_abs_params(input, ABS_X, 0, LRADC_CH_VALUE_MASK, 0, 0); - input_set_abs_params(input, ABS_Y, 0, LRADC_CH_VALUE_MASK, 0, 0); - input_set_abs_params(input, ABS_PRESSURE, 0, LRADC_CH_VALUE_MASK, 0, 0); + input_set_abs_params(input, ABS_X, 0, LRADC_SINGLE_SAMPLE_MASK, 0, 0); + input_set_abs_params(input, ABS_Y, 0, LRADC_SINGLE_SAMPLE_MASK, 0, 0); + input_set_abs_params(input, ABS_PRESSURE, 0, LRADC_SINGLE_SAMPLE_MASK, + 0, 0); lradc->ts_input = input; input_set_drvdata(input, lradc); @@ -817,7 +821,7 @@ static const struct iio_buffer_setup_ops mxs_lradc_buffer_ops = { .channel = (idx), \ .scan_type = { \ .sign = 'u', \ - .realbits = 18, \ + .realbits = LRADC_RESOLUTION, \ .storagebits = 32, \ }, \ } -- GitLab From 1696f36482e7063051a1dad86a54be83fd847f4f Mon Sep 17 00:00:00 2001 From: Oleksandr Kozaruk Date: Thu, 25 Jul 2013 14:26:00 +0100 Subject: [PATCH 662/942] iio: twl6030-gpadc: TWL6030, TWL6032 GPADC driver The GPADC is general purpose ADC found on TWL6030, and TWL6032 PMIC, known also as Phoenix and PhoenixLite. The TWL6030 and TWL6032 have GPADC with 17 and 19 channels respectively. Some channels have current source and are used for measuring voltage drop on resistive load for detecting battery ID resistance, or measuring voltage drop on NTC resistors for external temperature measurements. Some channels measure voltage, (i.e. battery voltage), and have voltage dividers, thus, capable to scale voltage. Some channels are dedicated for measuring die temperature. Some channels are calibrated in 2 points, having offsets from ideal values kept in trim registers. This is used to correct measurements. The differences between GPADC in TWL6030 and TWL6032: - 10 bit vs 12 bit ADC; - 17 vs 19 channels; - channels have different purpose(i.e. battery voltage channel 8 vs channel 18); - trim values are interpreted differently. Based on the driver patched from Balaji TK, Graeme Gregory, Ambresh K, Girish S Ghongdemath. Signed-off-by: Balaji T K Signed-off-by: Graeme Gregory Signed-off-by: Oleksandr Kozaruk Signed-off-by: Jonathan Cameron --- drivers/iio/adc/Kconfig | 14 + drivers/iio/adc/Makefile | 1 + drivers/iio/adc/twl6030-gpadc.c | 1029 +++++++++++++++++++++++++++++++ 3 files changed, 1044 insertions(+) create mode 100644 drivers/iio/adc/twl6030-gpadc.c diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index f725b4581f046..09371cbc9dc12 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -171,6 +171,20 @@ config TI_AM335X_ADC Say yes here to build support for Texas Instruments ADC driver which is also a MFD client. +config TWL6030_GPADC + tristate "TWL6030 GPADC (General Purpose A/D Converter) Support" + depends on TWL4030_CORE + default n + help + Say yes here if you want support for the TWL6030/TWL6032 General + Purpose A/D Converter. This will add support for battery type + detection, battery voltage and temperature measurement, die + temperature measurement, system supply voltage, audio accessory, + USB ID detection. + + This driver can also be built as a module. If so, the module will be + called twl6030-gpadc. + config VIPERBOARD_ADC tristate "Viperboard ADC support" depends on MFD_VIPERBOARD && USB diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile index 2a4324ec7f14a..33656ef7d1f60 100644 --- a/drivers/iio/adc/Makefile +++ b/drivers/iio/adc/Makefile @@ -19,4 +19,5 @@ obj-$(CONFIG_MCP320X) += mcp320x.o obj-$(CONFIG_NAU7802) += nau7802.o obj-$(CONFIG_TI_ADC081C) += ti-adc081c.o obj-$(CONFIG_TI_AM335X_ADC) += ti_am335x_adc.o +obj-$(CONFIG_TWL6030_GPADC) += twl6030-gpadc.o obj-$(CONFIG_VIPERBOARD_ADC) += viperboard_adc.o diff --git a/drivers/iio/adc/twl6030-gpadc.c b/drivers/iio/adc/twl6030-gpadc.c new file mode 100644 index 0000000000000..a80a049c9a55b --- /dev/null +++ b/drivers/iio/adc/twl6030-gpadc.c @@ -0,0 +1,1029 @@ +/* + * TWL6030 GPADC module driver + * + * Copyright (C) 2009-2013 Texas Instruments Inc. + * Nishant Kamat + * Balaji T K + * Graeme Gregory + * Girish S Ghongdemath + * Ambresh K + * Oleksandr Kozaruk + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + * + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DRIVER_NAME "twl6030_gpadc" + +/* + * twl6030 per TRM has 17 channels, and twl6032 has 19 channels + * 2 test network channels are not used, + * 2 die temperature channels are not used either, as it is not + * defined how to convert ADC value to temperature + */ +#define TWL6030_GPADC_USED_CHANNELS 13 +#define TWL6030_GPADC_MAX_CHANNELS 15 +#define TWL6032_GPADC_USED_CHANNELS 15 +#define TWL6032_GPADC_MAX_CHANNELS 19 +#define TWL6030_GPADC_NUM_TRIM_REGS 16 + +#define TWL6030_GPADC_CTRL_P1 0x05 + +#define TWL6032_GPADC_GPSELECT_ISB 0x07 +#define TWL6032_GPADC_CTRL_P1 0x08 + +#define TWL6032_GPADC_GPCH0_LSB 0x0d +#define TWL6032_GPADC_GPCH0_MSB 0x0e + +#define TWL6030_GPADC_CTRL_P1_SP1 BIT(3) + +#define TWL6030_GPADC_GPCH0_LSB (0x29) + +#define TWL6030_GPADC_RT_SW1_EOC_MASK BIT(5) + +#define TWL6030_GPADC_TRIM1 0xCD + +#define TWL6030_REG_TOGGLE1 0x90 +#define TWL6030_GPADCS BIT(1) +#define TWL6030_GPADCR BIT(0) + +/** + * struct twl6030_chnl_calib - channel calibration + * @gain: slope coefficient for ideal curve + * @gain_error: gain error + * @offset_error: offset of the real curve + */ +struct twl6030_chnl_calib { + s32 gain; + s32 gain_error; + s32 offset_error; +}; + +/** + * struct twl6030_ideal_code - GPADC calibration parameters + * GPADC is calibrated in two points: close to the beginning and + * to the and of the measurable input range + * + * @channel: channel number + * @code1: ideal code for the input at the beginning + * @code2: ideal code for at the end of the range + * @volt1: voltage input at the beginning(low voltage) + * @volt2: voltage input at the end(high voltage) + */ +struct twl6030_ideal_code { + int channel; + u16 code1; + u16 code2; + u16 volt1; + u16 volt2; +}; + +struct twl6030_gpadc_data; + +/** + * struct twl6030_gpadc_platform_data - platform specific data + * @nchannels: number of GPADC channels + * @iio_channels: iio channels + * @twl6030_ideal: pointer to calibration parameters + * @start_conversion: pointer to ADC start conversion function + * @channel_to_reg pointer to ADC function to convert channel to + * register address for reading conversion result + * @calibrate: pointer to calibration function + */ +struct twl6030_gpadc_platform_data { + const int nchannels; + const struct iio_chan_spec *iio_channels; + const struct twl6030_ideal_code *ideal; + int (*start_conversion)(int channel); + u8 (*channel_to_reg)(int channel); + int (*calibrate)(struct twl6030_gpadc_data *gpadc); +}; + +/** + * struct twl6030_gpadc_data - GPADC data + * @dev: device pointer + * @lock: mutual exclusion lock for the structure + * @irq_complete: completion to signal end of conversion + * @twl6030_cal_tbl: pointer to calibration data for each + * channel with gain error and offset + * @pdata: pointer to device specific data + */ +struct twl6030_gpadc_data { + struct device *dev; + struct mutex lock; + struct completion irq_complete; + struct twl6030_chnl_calib *twl6030_cal_tbl; + const struct twl6030_gpadc_platform_data *pdata; +}; + +/* + * channels 11, 12, 13, 15 and 16 have no calibration data + * calibration offset is same for channels 1, 3, 4, 5 + * + * The data is taken from GPADC_TRIM registers description. + * GPADC_TRIM registers keep difference between the code measured + * at volt1 and volt2 input voltages and corresponding code1 and code2 + */ +static const struct twl6030_ideal_code + twl6030_ideal[TWL6030_GPADC_USED_CHANNELS] = { + [0] = { /* ch 0, external, battery type, resistor value */ + .channel = 0, + .code1 = 116, + .code2 = 745, + .volt1 = 141, + .volt2 = 910, + }, + [1] = { /* ch 1, external, battery temperature, NTC resistor value */ + .channel = 1, + .code1 = 82, + .code2 = 900, + .volt1 = 100, + .volt2 = 1100, + }, + [2] = { /* ch 2, external, audio accessory/general purpose */ + .channel = 2, + .code1 = 55, + .code2 = 818, + .volt1 = 101, + .volt2 = 1499, + }, + [3] = { /* ch 3, external, general purpose */ + .channel = 3, + .code1 = 82, + .code2 = 900, + .volt1 = 100, + .volt2 = 1100, + }, + [4] = { /* ch 4, external, temperature measurement/general purpose */ + .channel = 4, + .code1 = 82, + .code2 = 900, + .volt1 = 100, + .volt2 = 1100, + }, + [5] = { /* ch 5, external, general purpose */ + .channel = 5, + .code1 = 82, + .code2 = 900, + .volt1 = 100, + .volt2 = 1100, + }, + [6] = { /* ch 6, external, general purpose */ + .channel = 6, + .code1 = 82, + .code2 = 900, + .volt1 = 100, + .volt2 = 1100, + }, + [7] = { /* ch 7, internal, main battery */ + .channel = 7, + .code1 = 614, + .code2 = 941, + .volt1 = 3001, + .volt2 = 4599, + }, + [8] = { /* ch 8, internal, backup battery */ + .channel = 8, + .code1 = 82, + .code2 = 688, + .volt1 = 501, + .volt2 = 4203, + }, + [9] = { /* ch 9, internal, external charger input */ + .channel = 9, + .code1 = 182, + .code2 = 818, + .volt1 = 2001, + .volt2 = 8996, + }, + [10] = { /* ch 10, internal, VBUS */ + .channel = 10, + .code1 = 149, + .code2 = 818, + .volt1 = 1001, + .volt2 = 5497, + }, + [11] = { /* ch 11, internal, VBUS charging current */ + .channel = 11, + }, + /* ch 12, internal, Die temperature */ + /* ch 13, internal, Die temperature */ + [12] = { /* ch 14, internal, USB ID line */ + .channel = 14, + .code1 = 48, + .code2 = 714, + .volt1 = 323, + .volt2 = 4800, + }, +}; + +static const struct twl6030_ideal_code + twl6032_ideal[TWL6032_GPADC_USED_CHANNELS] = { + [0] = { /* ch 0, external, battery type, resistor value */ + .channel = 0, + .code1 = 1441, + .code2 = 3276, + .volt1 = 440, + .volt2 = 1000, + }, + [1] = { /* ch 1, external, battery temperature, NTC resistor value */ + .channel = 1, + .code1 = 1441, + .code2 = 3276, + .volt1 = 440, + .volt2 = 1000, + }, + [2] = { /* ch 2, external, audio accessory/general purpose */ + .channel = 2, + .code1 = 1441, + .code2 = 3276, + .volt1 = 660, + .volt2 = 1500, + }, + [3] = { /* ch 3, external, temperature with external diode/general + purpose */ + .channel = 3, + .code1 = 1441, + .code2 = 3276, + .volt1 = 440, + .volt2 = 1000, + }, + [4] = { /* ch 4, external, temperature measurement/general purpose */ + .channel = 4, + .code1 = 1441, + .code2 = 3276, + .volt1 = 440, + .volt2 = 1000, + }, + [5] = { /* ch 5, external, general purpose */ + .channel = 5, + .code1 = 1441, + .code2 = 3276, + .volt1 = 440, + .volt2 = 1000, + }, + [6] = { /* ch 6, external, general purpose */ + .channel = 6, + .code1 = 1441, + .code2 = 3276, + .volt1 = 440, + .volt2 = 1000, + }, + [7] = { /* ch7, internal, system supply */ + .channel = 7, + .code1 = 1441, + .code2 = 3276, + .volt1 = 2200, + .volt2 = 5000, + }, + [8] = { /* ch8, internal, backup battery */ + .channel = 8, + .code1 = 1441, + .code2 = 3276, + .volt1 = 2200, + .volt2 = 5000, + }, + [9] = { /* ch 9, internal, external charger input */ + .channel = 9, + .code1 = 1441, + .code2 = 3276, + .volt1 = 3960, + .volt2 = 9000, + }, + [10] = { /* ch10, internal, VBUS */ + .channel = 10, + .code1 = 150, + .code2 = 751, + .volt1 = 1000, + .volt2 = 5000, + }, + [11] = { /* ch 11, internal, VBUS DC-DC output current */ + .channel = 11, + .code1 = 1441, + .code2 = 3276, + .volt1 = 660, + .volt2 = 1500, + }, + /* ch 12, internal, Die temperature */ + /* ch 13, internal, Die temperature */ + [12] = { /* ch 14, internal, USB ID line */ + .channel = 14, + .code1 = 1441, + .code2 = 3276, + .volt1 = 2420, + .volt2 = 5500, + }, + /* ch 15, internal, test network */ + /* ch 16, internal, test network */ + [13] = { /* ch 17, internal, battery charging current */ + .channel = 17, + }, + [14] = { /* ch 18, internal, battery voltage */ + .channel = 18, + .code1 = 1441, + .code2 = 3276, + .volt1 = 2200, + .volt2 = 5000, + }, +}; + +static inline int twl6030_gpadc_write(u8 reg, u8 val) +{ + return twl_i2c_write_u8(TWL6030_MODULE_GPADC, val, reg); +} + +static inline int twl6030_gpadc_read(u8 reg, u8 *val) +{ + + return twl_i2c_read(TWL6030_MODULE_GPADC, val, reg, 2); +} + +static int twl6030_gpadc_enable_irq(u8 mask) +{ + int ret; + + ret = twl6030_interrupt_unmask(mask, REG_INT_MSK_LINE_B); + if (ret < 0) + return ret; + + ret = twl6030_interrupt_unmask(mask, REG_INT_MSK_STS_B); + + return ret; +} + +static void twl6030_gpadc_disable_irq(u8 mask) +{ + twl6030_interrupt_mask(mask, REG_INT_MSK_LINE_B); + twl6030_interrupt_mask(mask, REG_INT_MSK_STS_B); +} + +static irqreturn_t twl6030_gpadc_irq_handler(int irq, void *indio_dev) +{ + struct twl6030_gpadc_data *gpadc = iio_priv(indio_dev); + + complete(&gpadc->irq_complete); + + return IRQ_HANDLED; +} + +static int twl6030_start_conversion(int channel) +{ + return twl6030_gpadc_write(TWL6030_GPADC_CTRL_P1, + TWL6030_GPADC_CTRL_P1_SP1); +} + +static int twl6032_start_conversion(int channel) +{ + int ret; + + ret = twl6030_gpadc_write(TWL6032_GPADC_GPSELECT_ISB, channel); + if (ret) + return ret; + + return twl6030_gpadc_write(TWL6032_GPADC_CTRL_P1, + TWL6030_GPADC_CTRL_P1_SP1); +} + +static u8 twl6030_channel_to_reg(int channel) +{ + return TWL6030_GPADC_GPCH0_LSB + 2 * channel; +} + +static u8 twl6032_channel_to_reg(int channel) +{ + /* + * for any prior chosen channel, when the conversion is ready + * the result is avalable in GPCH0_LSB, GPCH0_MSB. + */ + + return TWL6032_GPADC_GPCH0_LSB; +} + +static int twl6030_gpadc_lookup(const struct twl6030_ideal_code *ideal, + int channel, int size) +{ + int i; + + for (i = 0; i < size; i++) + if (ideal[i].channel == channel) + break; + + return i; +} + +static int twl6030_channel_calibrated(const struct twl6030_gpadc_platform_data + *pdata, int channel) +{ + const struct twl6030_ideal_code *ideal = pdata->ideal; + int i; + + i = twl6030_gpadc_lookup(ideal, channel, pdata->nchannels); + /* not calibrated channels have 0 in all structure members */ + return pdata->ideal[i].code2; +} + +static int twl6030_gpadc_make_correction(struct twl6030_gpadc_data *gpadc, + int channel, int raw_code) +{ + const struct twl6030_ideal_code *ideal = gpadc->pdata->ideal; + int corrected_code; + int i; + + i = twl6030_gpadc_lookup(ideal, channel, gpadc->pdata->nchannels); + corrected_code = ((raw_code * 1000) - + gpadc->twl6030_cal_tbl[i].offset_error) / + gpadc->twl6030_cal_tbl[i].gain_error; + + return corrected_code; +} + +static int twl6030_gpadc_get_raw(struct twl6030_gpadc_data *gpadc, + int channel, int *res) +{ + u8 reg = gpadc->pdata->channel_to_reg(channel); + __le16 val; + int raw_code; + int ret; + + ret = twl6030_gpadc_read(reg, (u8 *)&val); + if (ret) { + dev_dbg(gpadc->dev, "unable to read register 0x%X\n", reg); + return ret; + } + + raw_code = le16_to_cpu(val); + dev_dbg(gpadc->dev, "GPADC raw code: %d", raw_code); + + if (twl6030_channel_calibrated(gpadc->pdata, channel)) + *res = twl6030_gpadc_make_correction(gpadc, channel, raw_code); + else + *res = raw_code; + + return ret; +} + +static int twl6030_gpadc_get_processed(struct twl6030_gpadc_data *gpadc, + int channel, int *val) +{ + const struct twl6030_ideal_code *ideal = gpadc->pdata->ideal; + int corrected_code; + int channel_value; + int i; + int ret; + + ret = twl6030_gpadc_get_raw(gpadc, channel, &corrected_code); + if (ret) + return ret; + + i = twl6030_gpadc_lookup(ideal, channel, gpadc->pdata->nchannels); + channel_value = corrected_code * + gpadc->twl6030_cal_tbl[i].gain; + + /* Shift back into mV range */ + channel_value /= 1000; + + dev_dbg(gpadc->dev, "GPADC corrected code: %d", corrected_code); + dev_dbg(gpadc->dev, "GPADC value: %d", channel_value); + + *val = channel_value; + + return ret; +} + +static int twl6030_gpadc_read_raw(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan, + int *val, int *val2, long mask) +{ + struct twl6030_gpadc_data *gpadc = iio_priv(indio_dev); + int ret; + long timeout; + + mutex_lock(&gpadc->lock); + + ret = gpadc->pdata->start_conversion(chan->channel); + if (ret) { + dev_err(gpadc->dev, "failed to start conversion\n"); + goto err; + } + /* wait for conversion to complete */ + timeout = wait_for_completion_interruptible_timeout( + &gpadc->irq_complete, msecs_to_jiffies(5000)); + if (timeout == 0) { + ret = -ETIMEDOUT; + goto err; + } else if (timeout < 0) { + goto err; + ret = -EINTR; + } + + switch (mask) { + case IIO_CHAN_INFO_RAW: + ret = twl6030_gpadc_get_raw(gpadc, chan->channel, val); + ret = ret ? -EIO : IIO_VAL_INT; + break; + + case IIO_CHAN_INFO_PROCESSED: + ret = twl6030_gpadc_get_processed(gpadc, chan->channel, val); + ret = ret ? -EIO : IIO_VAL_INT; + break; + + default: + break; + } +err: + mutex_unlock(&gpadc->lock); + + return ret; +} + +/* + * The GPADC channels are calibrated using a two point calibration method. + * The channels measured with two known values: volt1 and volt2, and + * ideal corresponding output codes are known: code1, code2. + * The difference(d1, d2) between ideal and measured codes stored in trim + * registers. + * The goal is to find offset and gain of the real curve for each calibrated + * channel. + * gain: k = 1 + ((d2 - d1) / (x2 - x1)) + * offset: b = d1 + (k - 1) * x1 + */ +static void twl6030_calibrate_channel(struct twl6030_gpadc_data *gpadc, + int channel, int d1, int d2) +{ + int b, k, gain, x1, x2, i; + const struct twl6030_ideal_code *ideal = gpadc->pdata->ideal; + + i = twl6030_gpadc_lookup(ideal, channel, gpadc->pdata->nchannels); + + /* Gain */ + gain = ((ideal[i].volt2 - ideal[i].volt1) * 1000) / + (ideal[i].code2 - ideal[i].code1); + + x1 = ideal[i].code1; + x2 = ideal[i].code2; + + /* k - real curve gain */ + k = 1000 + (((d2 - d1) * 1000) / (x2 - x1)); + + /* b - offset of the real curve gain */ + b = (d1 * 1000) - (k - 1000) * x1; + + gpadc->twl6030_cal_tbl[i].gain = gain; + gpadc->twl6030_cal_tbl[i].gain_error = k; + gpadc->twl6030_cal_tbl[i].offset_error = b; + + dev_dbg(gpadc->dev, "GPADC d1 for Chn: %d = %d\n", channel, d1); + dev_dbg(gpadc->dev, "GPADC d2 for Chn: %d = %d\n", channel, d2); + dev_dbg(gpadc->dev, "GPADC x1 for Chn: %d = %d\n", channel, x1); + dev_dbg(gpadc->dev, "GPADC x2 for Chn: %d = %d\n", channel, x2); + dev_dbg(gpadc->dev, "GPADC Gain for Chn: %d = %d\n", channel, gain); + dev_dbg(gpadc->dev, "GPADC k for Chn: %d = %d\n", channel, k); + dev_dbg(gpadc->dev, "GPADC b for Chn: %d = %d\n", channel, b); +} + +static inline int twl6030_gpadc_get_trim_offset(s8 d) +{ + /* + * XXX NOTE! + * bit 0 - sign, bit 7 - reserved, 6..1 - trim value + * though, the documentation states that trim value + * is absolute value, the correct conversion results are + * obtained if the value is interpreted as 2's complement. + */ + __u32 temp = ((d & 0x7f) >> 1) | ((d & 1) << 6); + + return sign_extend32(temp, 6); +} + +static int twl6030_calibration(struct twl6030_gpadc_data *gpadc) +{ + int ret; + int chn; + u8 trim_regs[TWL6030_GPADC_NUM_TRIM_REGS]; + s8 d1, d2; + + /* + * for calibration two measurements have been performed at + * factory, for some channels, during the production test and + * have been stored in registers. This two stored values are + * used to correct the measurements. The values represent + * offsets for the given input from the output on ideal curve. + */ + ret = twl_i2c_read(TWL6030_MODULE_ID2, trim_regs, + TWL6030_GPADC_TRIM1, TWL6030_GPADC_NUM_TRIM_REGS); + if (ret < 0) { + dev_err(gpadc->dev, "calibration failed\n"); + return ret; + } + + for (chn = 0; chn < TWL6030_GPADC_MAX_CHANNELS; chn++) { + + switch (chn) { + case 0: + d1 = trim_regs[0]; + d2 = trim_regs[1]; + break; + case 1: + case 3: + case 4: + case 5: + case 6: + d1 = trim_regs[4]; + d2 = trim_regs[5]; + break; + case 2: + d1 = trim_regs[12]; + d2 = trim_regs[13]; + break; + case 7: + d1 = trim_regs[6]; + d2 = trim_regs[7]; + break; + case 8: + d1 = trim_regs[2]; + d2 = trim_regs[3]; + break; + case 9: + d1 = trim_regs[8]; + d2 = trim_regs[9]; + break; + case 10: + d1 = trim_regs[10]; + d2 = trim_regs[11]; + break; + case 14: + d1 = trim_regs[14]; + d2 = trim_regs[15]; + break; + default: + continue; + } + + d1 = twl6030_gpadc_get_trim_offset(d1); + d2 = twl6030_gpadc_get_trim_offset(d2); + + twl6030_calibrate_channel(gpadc, chn, d1, d2); + } + + return 0; +} + +static int twl6032_get_trim_value(u8 *trim_regs, unsigned int reg0, + unsigned int reg1, unsigned int mask0, unsigned int mask1, + unsigned int shift0) +{ + int val; + + val = (trim_regs[reg0] & mask0) << shift0; + val |= (trim_regs[reg1] & mask1) >> 1; + if (trim_regs[reg1] & 0x01) + val = -val; + + return val; +} + +static int twl6032_calibration(struct twl6030_gpadc_data *gpadc) +{ + int chn, d1 = 0, d2 = 0, temp; + u8 trim_regs[TWL6030_GPADC_NUM_TRIM_REGS]; + int ret; + + ret = twl_i2c_read(TWL6030_MODULE_ID2, trim_regs, + TWL6030_GPADC_TRIM1, TWL6030_GPADC_NUM_TRIM_REGS); + if (ret < 0) { + dev_err(gpadc->dev, "calibration failed\n"); + return ret; + } + + /* + * Loop to calculate the value needed for returning voltages from + * GPADC not values. + * + * gain is calculated to 3 decimal places fixed point. + */ + for (chn = 0; chn < TWL6032_GPADC_MAX_CHANNELS; chn++) { + + switch (chn) { + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 11: + case 14: + d1 = twl6032_get_trim_value(trim_regs, 2, 0, 0x1f, + 0x06, 2); + d2 = twl6032_get_trim_value(trim_regs, 3, 1, 0x3f, + 0x06, 2); + break; + case 8: + temp = twl6032_get_trim_value(trim_regs, 2, 0, 0x1f, + 0x06, 2); + d1 = temp + twl6032_get_trim_value(trim_regs, 7, 6, + 0x18, 0x1E, 1); + + temp = twl6032_get_trim_value(trim_regs, 3, 1, 0x3F, + 0x06, 2); + d2 = temp + twl6032_get_trim_value(trim_regs, 9, 7, + 0x1F, 0x06, 2); + break; + case 9: + temp = twl6032_get_trim_value(trim_regs, 2, 0, 0x1f, + 0x06, 2); + d1 = temp + twl6032_get_trim_value(trim_regs, 13, 11, + 0x18, 0x1E, 1); + + temp = twl6032_get_trim_value(trim_regs, 3, 1, 0x3f, + 0x06, 2); + d2 = temp + twl6032_get_trim_value(trim_regs, 15, 13, + 0x1F, 0x06, 1); + break; + case 10: + d1 = twl6032_get_trim_value(trim_regs, 10, 8, 0x0f, + 0x0E, 3); + d2 = twl6032_get_trim_value(trim_regs, 14, 12, 0x0f, + 0x0E, 3); + break; + case 7: + case 18: + temp = twl6032_get_trim_value(trim_regs, 2, 0, 0x1f, + 0x06, 2); + + d1 = (trim_regs[4] & 0x7E) >> 1; + if (trim_regs[4] & 0x01) + d1 = -d1; + d1 += temp; + + temp = twl6032_get_trim_value(trim_regs, 3, 1, 0x3f, + 0x06, 2); + + d2 = (trim_regs[5] & 0xFE) >> 1; + if (trim_regs[5] & 0x01) + d2 = -d2; + + d2 += temp; + break; + default: + /* No data for other channels */ + continue; + } + + twl6030_calibrate_channel(gpadc, chn, d1, d2); + } + + return 0; +} + +#define TWL6030_GPADC_CHAN(chn, _type, chan_info) { \ + .type = _type, \ + .channel = chn, \ + .info_mask_separate = BIT(chan_info), \ + .indexed = 1, \ +} + +static const struct iio_chan_spec twl6030_gpadc_iio_channels[] = { + TWL6030_GPADC_CHAN(0, IIO_VOLTAGE, IIO_CHAN_INFO_PROCESSED), + TWL6030_GPADC_CHAN(1, IIO_TEMP, IIO_CHAN_INFO_RAW), + TWL6030_GPADC_CHAN(2, IIO_VOLTAGE, IIO_CHAN_INFO_PROCESSED), + TWL6030_GPADC_CHAN(3, IIO_VOLTAGE, IIO_CHAN_INFO_PROCESSED), + TWL6030_GPADC_CHAN(4, IIO_TEMP, IIO_CHAN_INFO_RAW), + TWL6030_GPADC_CHAN(5, IIO_VOLTAGE, IIO_CHAN_INFO_PROCESSED), + TWL6030_GPADC_CHAN(6, IIO_VOLTAGE, IIO_CHAN_INFO_PROCESSED), + TWL6030_GPADC_CHAN(7, IIO_VOLTAGE, IIO_CHAN_INFO_PROCESSED), + TWL6030_GPADC_CHAN(8, IIO_VOLTAGE, IIO_CHAN_INFO_PROCESSED), + TWL6030_GPADC_CHAN(9, IIO_VOLTAGE, IIO_CHAN_INFO_PROCESSED), + TWL6030_GPADC_CHAN(10, IIO_VOLTAGE, IIO_CHAN_INFO_PROCESSED), + TWL6030_GPADC_CHAN(11, IIO_VOLTAGE, IIO_CHAN_INFO_RAW), + TWL6030_GPADC_CHAN(14, IIO_VOLTAGE, IIO_CHAN_INFO_PROCESSED), +}; + +static const struct iio_chan_spec twl6032_gpadc_iio_channels[] = { + TWL6030_GPADC_CHAN(0, IIO_VOLTAGE, IIO_CHAN_INFO_PROCESSED), + TWL6030_GPADC_CHAN(1, IIO_TEMP, IIO_CHAN_INFO_RAW), + TWL6030_GPADC_CHAN(2, IIO_VOLTAGE, IIO_CHAN_INFO_PROCESSED), + TWL6030_GPADC_CHAN(3, IIO_VOLTAGE, IIO_CHAN_INFO_PROCESSED), + TWL6030_GPADC_CHAN(4, IIO_TEMP, IIO_CHAN_INFO_RAW), + TWL6030_GPADC_CHAN(5, IIO_VOLTAGE, IIO_CHAN_INFO_PROCESSED), + TWL6030_GPADC_CHAN(6, IIO_VOLTAGE, IIO_CHAN_INFO_PROCESSED), + TWL6030_GPADC_CHAN(7, IIO_VOLTAGE, IIO_CHAN_INFO_PROCESSED), + TWL6030_GPADC_CHAN(8, IIO_VOLTAGE, IIO_CHAN_INFO_PROCESSED), + TWL6030_GPADC_CHAN(9, IIO_VOLTAGE, IIO_CHAN_INFO_PROCESSED), + TWL6030_GPADC_CHAN(10, IIO_VOLTAGE, IIO_CHAN_INFO_PROCESSED), + TWL6030_GPADC_CHAN(11, IIO_VOLTAGE, IIO_CHAN_INFO_PROCESSED), + TWL6030_GPADC_CHAN(14, IIO_VOLTAGE, IIO_CHAN_INFO_PROCESSED), + TWL6030_GPADC_CHAN(17, IIO_VOLTAGE, IIO_CHAN_INFO_RAW), + TWL6030_GPADC_CHAN(18, IIO_VOLTAGE, IIO_CHAN_INFO_PROCESSED), +}; + +static const struct iio_info twl6030_gpadc_iio_info = { + .read_raw = &twl6030_gpadc_read_raw, + .driver_module = THIS_MODULE, +}; + +static const struct twl6030_gpadc_platform_data twl6030_pdata = { + .iio_channels = twl6030_gpadc_iio_channels, + .nchannels = TWL6030_GPADC_USED_CHANNELS, + .ideal = twl6030_ideal, + .start_conversion = twl6030_start_conversion, + .channel_to_reg = twl6030_channel_to_reg, + .calibrate = twl6030_calibration, +}; + +static const struct twl6030_gpadc_platform_data twl6032_pdata = { + .iio_channels = twl6032_gpadc_iio_channels, + .nchannels = TWL6032_GPADC_USED_CHANNELS, + .ideal = twl6032_ideal, + .start_conversion = twl6032_start_conversion, + .channel_to_reg = twl6032_channel_to_reg, + .calibrate = twl6032_calibration, +}; + +static const struct of_device_id of_twl6030_match_tbl[] = { + { + .compatible = "ti,twl6030-gpadc", + .data = &twl6030_pdata, + }, + { + .compatible = "ti,twl6032-gpadc", + .data = &twl6032_pdata, + }, + { /* end */ } +}; + +static int twl6030_gpadc_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct twl6030_gpadc_data *gpadc; + const struct twl6030_gpadc_platform_data *pdata; + const struct of_device_id *match; + struct iio_dev *indio_dev; + int irq; + int ret; + + match = of_match_device(of_match_ptr(of_twl6030_match_tbl), dev); + if (!match) + return -EINVAL; + + pdata = match->data; + + indio_dev = iio_device_alloc(sizeof(*gpadc)); + if (!indio_dev) { + dev_err(dev, "failed allocating iio device\n"); + ret = -ENOMEM; + } + + gpadc = iio_priv(indio_dev); + + gpadc->twl6030_cal_tbl = devm_kzalloc(dev, + sizeof(*gpadc->twl6030_cal_tbl) * + pdata->nchannels, GFP_KERNEL); + if (!gpadc->twl6030_cal_tbl) + goto err_free_device; + + gpadc->dev = dev; + gpadc->pdata = pdata; + + platform_set_drvdata(pdev, indio_dev); + mutex_init(&gpadc->lock); + init_completion(&gpadc->irq_complete); + + ret = pdata->calibrate(gpadc); + if (ret < 0) { + dev_err(&pdev->dev, "failed to read calibration registers\n"); + goto err_free_device; + } + + irq = platform_get_irq(pdev, 0); + if (irq < 0) { + dev_err(&pdev->dev, "failed to get irq\n"); + goto err_free_device; + } + + ret = request_threaded_irq(irq, NULL, twl6030_gpadc_irq_handler, + IRQF_ONESHOT, "twl6030_gpadc", indio_dev); + if (ret) { + dev_dbg(&pdev->dev, "could not request irq\n"); + goto err_free_device; + } + + ret = twl6030_gpadc_enable_irq(TWL6030_GPADC_RT_SW1_EOC_MASK); + if (ret < 0) { + dev_err(&pdev->dev, "failed to enable GPADC interrupt\n"); + goto err_free_irq; + } + + ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, TWL6030_GPADCS, + TWL6030_REG_TOGGLE1); + if (ret < 0) { + dev_err(&pdev->dev, "failed to enable GPADC module\n"); + goto err_free_irq; + } + + indio_dev->name = DRIVER_NAME; + indio_dev->dev.parent = dev; + indio_dev->info = &twl6030_gpadc_iio_info; + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->channels = pdata->iio_channels; + indio_dev->num_channels = pdata->nchannels; + + ret = iio_device_register(indio_dev); + if (ret) + goto err_free_irq; + + return ret; + +err_free_irq: + free_irq(irq, indio_dev); +err_free_device: + iio_device_free(indio_dev); + + return ret; +} + +static int twl6030_gpadc_remove(struct platform_device *pdev) +{ + struct iio_dev *indio_dev = platform_get_drvdata(pdev); + + twl6030_gpadc_disable_irq(TWL6030_GPADC_RT_SW1_EOC_MASK); + free_irq(platform_get_irq(pdev, 0), indio_dev); + iio_device_unregister(indio_dev); + iio_device_free(indio_dev); + + return 0; +} + +#ifdef CONFIG_PM_SLEEP +static int twl6030_gpadc_suspend(struct device *pdev) +{ + int ret; + + ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, TWL6030_GPADCR, + TWL6030_REG_TOGGLE1); + if (ret) + dev_err(pdev, "error reseting GPADC (%d)!\n", ret); + + return 0; +}; + +static int twl6030_gpadc_resume(struct device *pdev) +{ + int ret; + + ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, TWL6030_GPADCS, + TWL6030_REG_TOGGLE1); + if (ret) + dev_err(pdev, "error setting GPADC (%d)!\n", ret); + + return 0; +}; +#endif + +static SIMPLE_DEV_PM_OPS(twl6030_gpadc_pm_ops, twl6030_gpadc_suspend, + twl6030_gpadc_resume); + +static struct platform_driver twl6030_gpadc_driver = { + .probe = twl6030_gpadc_probe, + .remove = twl6030_gpadc_remove, + .driver = { + .name = DRIVER_NAME, + .owner = THIS_MODULE, + .pm = &twl6030_gpadc_pm_ops, + .of_match_table = of_twl6030_match_tbl, + }, +}; + +module_platform_driver(twl6030_gpadc_driver); + +MODULE_ALIAS("platform: " DRIVER_NAME); +MODULE_AUTHOR("Balaji T K "); +MODULE_AUTHOR("Graeme Gregory "); +MODULE_AUTHOR("Oleksandr Kozaruk Date: Fri, 16 Aug 2013 14:11:00 +0100 Subject: [PATCH 663/942] iio: trigger: implement devm_iio_trigger_alloc/devm_iio_triger_free Add a resource managed devm_iio_trigger_alloc()/devm_iio_triger_free() to automatically clean up triggers allocated by IIO drivers, thus leading to simplified IIO drivers code. Signed-off-by: Jacek Anaszewski Signed-off-by: Kyunmin Park Signed-off-by: Jonathan Cameron --- Documentation/driver-model/devres.txt | 2 + drivers/iio/industrialio-trigger.c | 72 +++++++++++++++++++++++++-- include/linux/iio/iio.h | 29 +++++++++++ 3 files changed, 99 insertions(+), 4 deletions(-) diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt index 1d32332929896..fb57d85e73160 100644 --- a/Documentation/driver-model/devres.txt +++ b/Documentation/driver-model/devres.txt @@ -240,6 +240,8 @@ MEM IIO devm_iio_device_alloc() devm_iio_device_free() + devm_iio_trigger_alloc() + devm_iio_trigger_free() IO region devm_request_region() diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c index 0dd9bb8731301..bf5e70a32d3fb 100644 --- a/drivers/iio/industrialio-trigger.c +++ b/drivers/iio/industrialio-trigger.c @@ -424,9 +424,8 @@ static void iio_trig_subirqunmask(struct irq_data *d) trig->subirqs[d->irq - trig->subirq_base].enabled = true; } -struct iio_trigger *iio_trigger_alloc(const char *fmt, ...) +static struct iio_trigger *viio_trigger_alloc(const char *fmt, va_list vargs) { - va_list vargs; struct iio_trigger *trig; trig = kzalloc(sizeof *trig, GFP_KERNEL); if (trig) { @@ -444,9 +443,8 @@ struct iio_trigger *iio_trigger_alloc(const char *fmt, ...) kfree(trig); return NULL; } - va_start(vargs, fmt); + trig->name = kvasprintf(GFP_KERNEL, fmt, vargs); - va_end(vargs); if (trig->name == NULL) { irq_free_descs(trig->subirq_base, CONFIG_IIO_CONSUMERS_PER_TRIGGER); @@ -467,6 +465,19 @@ struct iio_trigger *iio_trigger_alloc(const char *fmt, ...) } get_device(&trig->dev); } + + return trig; +} + +struct iio_trigger *iio_trigger_alloc(const char *fmt, ...) +{ + struct iio_trigger *trig; + va_list vargs; + + va_start(vargs, fmt); + trig = viio_trigger_alloc(fmt, vargs); + va_end(vargs); + return trig; } EXPORT_SYMBOL(iio_trigger_alloc); @@ -478,6 +489,59 @@ void iio_trigger_free(struct iio_trigger *trig) } EXPORT_SYMBOL(iio_trigger_free); +static void devm_iio_trigger_release(struct device *dev, void *res) +{ + iio_trigger_free(*(struct iio_trigger **)res); +} + +static int devm_iio_trigger_match(struct device *dev, void *res, void *data) +{ + struct iio_trigger **r = res; + + if (!r || !*r) { + WARN_ON(!r || !*r); + return 0; + } + + return *r == data; +} + +struct iio_trigger *devm_iio_trigger_alloc(struct device *dev, + const char *fmt, ...) +{ + struct iio_trigger **ptr, *trig; + va_list vargs; + + ptr = devres_alloc(devm_iio_trigger_release, sizeof(*ptr), + GFP_KERNEL); + if (!ptr) + return NULL; + + /* use raw alloc_dr for kmalloc caller tracing */ + va_start(vargs, fmt); + trig = viio_trigger_alloc(fmt, vargs); + va_end(vargs); + if (trig) { + *ptr = trig; + devres_add(dev, ptr); + } else { + devres_free(ptr); + } + + return trig; +} +EXPORT_SYMBOL_GPL(devm_iio_trigger_alloc); + +void devm_iio_trigger_free(struct device *dev, struct iio_trigger *iio_trig) +{ + int rc; + + rc = devres_release(dev, devm_iio_trigger_release, + devm_iio_trigger_match, iio_trig); + WARN_ON(rc); +} +EXPORT_SYMBOL_GPL(devm_iio_trigger_free); + void iio_device_register_trigger_consumer(struct iio_dev *indio_dev) { indio_dev->groups[indio_dev->groupcounter++] = diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h index 09ebe0a4d8e6a..2103cc32a5fb9 100644 --- a/include/linux/iio/iio.h +++ b/include/linux/iio/iio.h @@ -556,6 +556,35 @@ struct iio_dev *devm_iio_device_alloc(struct device *dev, int sizeof_priv); */ void devm_iio_device_free(struct device *dev, struct iio_dev *indio_dev); +/** + * devm_iio_trigger_alloc - Resource-managed iio_trigger_alloc() + * @dev: Device to allocate iio_trigger for + * @fmt: trigger name format. If it includes format + * specifiers, the additional arguments following + * format are formatted and inserted in the resulting + * string replacing their respective specifiers. + * + * Managed iio_trigger_alloc. iio_trigger allocated with this function is + * automatically freed on driver detach. + * + * If an iio_trigger allocated with this function needs to be freed separately, + * devm_iio_trigger_free() must be used. + * + * RETURNS: + * Pointer to allocated iio_trigger on success, NULL on failure. + */ +struct iio_trigger *devm_iio_trigger_alloc(struct device *dev, + const char *fmt, ...); + +/** + * devm_iio_trigger_free - Resource-managed iio_trigger_free() + * @dev: Device this iio_dev belongs to + * @iio_trig: the iio_trigger associated with the device + * + * Free iio_trigger allocated with devm_iio_trigger_alloc(). + */ +void devm_iio_trigger_free(struct device *dev, struct iio_trigger *iio_trig); + /** * iio_buffer_enabled() - helper function to test if the buffer is enabled * @indio_dev: IIO device structure for device -- GitLab From 0c0427acd5bfd25a44c074ac0a517d667ddf0a27 Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Sun, 18 Aug 2013 14:07:00 +0100 Subject: [PATCH 664/942] iio: Remove unnecessary _write_raw_get_fmt() in several hid-sensor drivers IIO_VAL_INT_PLUS_MICRO is the default, no need to return it explicitly Signed-off-by: Peter Meerwald Acked-by: srinivas pandruvada Signed-off-by: Jonathan Cameron --- drivers/iio/accel/hid-sensor-accel-3d.c | 8 -------- drivers/iio/gyro/hid-sensor-gyro-3d.c | 8 -------- drivers/iio/light/hid-sensor-als.c | 8 -------- drivers/iio/magnetometer/hid-sensor-magn-3d.c | 8 -------- 4 files changed, 32 deletions(-) diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c index 68df3416b612e..46d22f3fb1a9b 100644 --- a/drivers/iio/accel/hid-sensor-accel-3d.c +++ b/drivers/iio/accel/hid-sensor-accel-3d.c @@ -175,18 +175,10 @@ static int accel_3d_write_raw(struct iio_dev *indio_dev, return ret; } -static int accel_3d_write_raw_get_fmt(struct iio_dev *indio_dev, - struct iio_chan_spec const *chan, - long mask) -{ - return IIO_VAL_INT_PLUS_MICRO; -} - static const struct iio_info accel_3d_info = { .driver_module = THIS_MODULE, .read_raw = &accel_3d_read_raw, .write_raw = &accel_3d_write_raw, - .write_raw_get_fmt = &accel_3d_write_raw_get_fmt, }; /* Function to push data to buffer */ diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c index d9d7befdd77b4..c688d974d3e3e 100644 --- a/drivers/iio/gyro/hid-sensor-gyro-3d.c +++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c @@ -175,18 +175,10 @@ static int gyro_3d_write_raw(struct iio_dev *indio_dev, return ret; } -static int gyro_3d_write_raw_get_fmt(struct iio_dev *indio_dev, - struct iio_chan_spec const *chan, - long mask) -{ - return IIO_VAL_INT_PLUS_MICRO; -} - static const struct iio_info gyro_3d_info = { .driver_module = THIS_MODULE, .read_raw = &gyro_3d_read_raw, .write_raw = &gyro_3d_write_raw, - .write_raw_get_fmt = &gyro_3d_write_raw_get_fmt, }; /* Function to push data to buffer */ diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c index 84cf0043c99da..e59d00c3139c0 100644 --- a/drivers/iio/light/hid-sensor-als.c +++ b/drivers/iio/light/hid-sensor-als.c @@ -154,18 +154,10 @@ static int als_write_raw(struct iio_dev *indio_dev, return ret; } -static int als_write_raw_get_fmt(struct iio_dev *indio_dev, - struct iio_chan_spec const *chan, - long mask) -{ - return IIO_VAL_INT_PLUS_MICRO; -} - static const struct iio_info als_info = { .driver_module = THIS_MODULE, .read_raw = &als_read_raw, .write_raw = &als_write_raw, - .write_raw_get_fmt = &als_write_raw_get_fmt, }; /* Function to push data to buffer */ diff --git a/drivers/iio/magnetometer/hid-sensor-magn-3d.c b/drivers/iio/magnetometer/hid-sensor-magn-3d.c index 5a6162d1a2c05..a98460b15e4b6 100644 --- a/drivers/iio/magnetometer/hid-sensor-magn-3d.c +++ b/drivers/iio/magnetometer/hid-sensor-magn-3d.c @@ -176,18 +176,10 @@ static int magn_3d_write_raw(struct iio_dev *indio_dev, return ret; } -static int magn_3d_write_raw_get_fmt(struct iio_dev *indio_dev, - struct iio_chan_spec const *chan, - long mask) -{ - return IIO_VAL_INT_PLUS_MICRO; -} - static const struct iio_info magn_3d_info = { .driver_module = THIS_MODULE, .read_raw = &magn_3d_read_raw, .write_raw = &magn_3d_write_raw, - .write_raw_get_fmt = &magn_3d_write_raw_get_fmt, }; /* Function to push data to buffer */ -- GitLab From 4c730292656675000a3631b12cefb6238c57d1e3 Mon Sep 17 00:00:00 2001 From: Peter Meerwald Date: Sun, 18 Aug 2013 13:59:00 +0100 Subject: [PATCH 665/942] iio: adjd_s311: Cleanup unused #defines using word reads, no need for HI/LO register #defines Signed-off-by: Peter Meerwald Signed-off-by: Jonathan Cameron --- drivers/iio/light/adjd_s311.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/drivers/iio/light/adjd_s311.c b/drivers/iio/light/adjd_s311.c index 55b9e185d1649..00ab980f8e3c2 100644 --- a/drivers/iio/light/adjd_s311.c +++ b/drivers/iio/light/adjd_s311.c @@ -37,22 +37,14 @@ #define ADJD_S311_CAP_GREEN 0x07 #define ADJD_S311_CAP_BLUE 0x08 #define ADJD_S311_CAP_CLEAR 0x09 -#define ADJD_S311_INT_RED_LO 0x0a -#define ADJD_S311_INT_RED_HI 0x0b -#define ADJD_S311_INT_GREEN_LO 0x0c -#define ADJD_S311_INT_GREEN_HI 0x0d -#define ADJD_S311_INT_BLUE_LO 0x0e -#define ADJD_S311_INT_BLUE_HI 0x0f -#define ADJD_S311_INT_CLEAR_LO 0x10 -#define ADJD_S311_INT_CLEAR_HI 0x11 -#define ADJD_S311_DATA_RED_LO 0x40 -#define ADJD_S311_DATA_RED_HI 0x41 -#define ADJD_S311_DATA_GREEN_LO 0x42 -#define ADJD_S311_DATA_GREEN_HI 0x43 -#define ADJD_S311_DATA_BLUE_LO 0x44 -#define ADJD_S311_DATA_BLUE_HI 0x45 -#define ADJD_S311_DATA_CLEAR_LO 0x46 -#define ADJD_S311_DATA_CLEAR_HI 0x47 +#define ADJD_S311_INT_RED 0x0a +#define ADJD_S311_INT_GREEN 0x0c +#define ADJD_S311_INT_BLUE 0x0e +#define ADJD_S311_INT_CLEAR 0x10 +#define ADJD_S311_DATA_RED 0x40 +#define ADJD_S311_DATA_GREEN 0x42 +#define ADJD_S311_DATA_BLUE 0x44 +#define ADJD_S311_DATA_CLEAR 0x46 #define ADJD_S311_OFFSET_RED 0x48 #define ADJD_S311_OFFSET_GREEN 0x49 #define ADJD_S311_OFFSET_BLUE 0x4a @@ -73,8 +65,8 @@ enum adjd_s311_channel_idx { IDX_RED, IDX_GREEN, IDX_BLUE, IDX_CLEAR }; -#define ADJD_S311_DATA_REG(chan) (ADJD_S311_DATA_RED_LO + (chan) * 2) -#define ADJD_S311_INT_REG(chan) (ADJD_S311_INT_RED_LO + (chan) * 2) +#define ADJD_S311_DATA_REG(chan) (ADJD_S311_DATA_RED + (chan) * 2) +#define ADJD_S311_INT_REG(chan) (ADJD_S311_INT_RED + (chan) * 2) #define ADJD_S311_CAP_REG(chan) (ADJD_S311_CAP_RED + (chan)) static int adjd_s311_req_data(struct iio_dev *indio_dev) -- GitLab From fa659a40b80b06140390c364362d7ca942e2b2f6 Mon Sep 17 00:00:00 2001 From: Oleksandr Kozaruk Date: Mon, 19 Aug 2013 12:09:00 +0100 Subject: [PATCH 666/942] iio: adc: twl6030-gpadc: Use devm_* API family Using devm_iio_device_alloc and devm_request_threaded_irq makes code simpler. Signed-off-by: Oleksandr Kozaruk Signed-off-by: Jonathan Cameron --- drivers/iio/adc/twl6030-gpadc.c | 36 +++++++++------------------------ 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/drivers/iio/adc/twl6030-gpadc.c b/drivers/iio/adc/twl6030-gpadc.c index a80a049c9a55b..a558516d140d2 100644 --- a/drivers/iio/adc/twl6030-gpadc.c +++ b/drivers/iio/adc/twl6030-gpadc.c @@ -893,11 +893,9 @@ static int twl6030_gpadc_probe(struct platform_device *pdev) pdata = match->data; - indio_dev = iio_device_alloc(sizeof(*gpadc)); - if (!indio_dev) { - dev_err(dev, "failed allocating iio device\n"); - ret = -ENOMEM; - } + indio_dev = devm_iio_device_alloc(dev, sizeof(*gpadc)); + if (!indio_dev) + return -ENOMEM; gpadc = iio_priv(indio_dev); @@ -905,7 +903,7 @@ static int twl6030_gpadc_probe(struct platform_device *pdev) sizeof(*gpadc->twl6030_cal_tbl) * pdata->nchannels, GFP_KERNEL); if (!gpadc->twl6030_cal_tbl) - goto err_free_device; + return -ENOMEM; gpadc->dev = dev; gpadc->pdata = pdata; @@ -917,33 +915,30 @@ static int twl6030_gpadc_probe(struct platform_device *pdev) ret = pdata->calibrate(gpadc); if (ret < 0) { dev_err(&pdev->dev, "failed to read calibration registers\n"); - goto err_free_device; + return ret; } irq = platform_get_irq(pdev, 0); if (irq < 0) { dev_err(&pdev->dev, "failed to get irq\n"); - goto err_free_device; + return irq; } - ret = request_threaded_irq(irq, NULL, twl6030_gpadc_irq_handler, + ret = devm_request_threaded_irq(dev, irq, NULL, + twl6030_gpadc_irq_handler, IRQF_ONESHOT, "twl6030_gpadc", indio_dev); - if (ret) { - dev_dbg(&pdev->dev, "could not request irq\n"); - goto err_free_device; - } ret = twl6030_gpadc_enable_irq(TWL6030_GPADC_RT_SW1_EOC_MASK); if (ret < 0) { dev_err(&pdev->dev, "failed to enable GPADC interrupt\n"); - goto err_free_irq; + return ret; } ret = twl_i2c_write_u8(TWL6030_MODULE_ID1, TWL6030_GPADCS, TWL6030_REG_TOGGLE1); if (ret < 0) { dev_err(&pdev->dev, "failed to enable GPADC module\n"); - goto err_free_irq; + return ret; } indio_dev->name = DRIVER_NAME; @@ -954,15 +949,6 @@ static int twl6030_gpadc_probe(struct platform_device *pdev) indio_dev->num_channels = pdata->nchannels; ret = iio_device_register(indio_dev); - if (ret) - goto err_free_irq; - - return ret; - -err_free_irq: - free_irq(irq, indio_dev); -err_free_device: - iio_device_free(indio_dev); return ret; } @@ -972,9 +958,7 @@ static int twl6030_gpadc_remove(struct platform_device *pdev) struct iio_dev *indio_dev = platform_get_drvdata(pdev); twl6030_gpadc_disable_irq(TWL6030_GPADC_RT_SW1_EOC_MASK); - free_irq(platform_get_irq(pdev, 0), indio_dev); iio_device_unregister(indio_dev); - iio_device_free(indio_dev); return 0; } -- GitLab From c367982ad9b927ec1b1fd66a462b72950fe5370b Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Mon, 19 Aug 2013 12:38:00 +0100 Subject: [PATCH 667/942] iio: dac: ad5064: Use devm_* APIs devm_* APIs are device managed and make code simpler. Signed-off-by: Sachin Kamat Signed-off-by: Jonathan Cameron --- drivers/iio/dac/ad5064.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/drivers/iio/dac/ad5064.c b/drivers/iio/dac/ad5064.c index aa26d50ab6385..a3a52be4852cb 100644 --- a/drivers/iio/dac/ad5064.c +++ b/drivers/iio/dac/ad5064.c @@ -442,7 +442,7 @@ static int ad5064_probe(struct device *dev, enum ad5064_type type, unsigned int i; int ret; - indio_dev = iio_device_alloc(sizeof(*st)); + indio_dev = devm_iio_device_alloc(dev, sizeof(*st)); if (indio_dev == NULL) return -ENOMEM; @@ -456,23 +456,23 @@ static int ad5064_probe(struct device *dev, enum ad5064_type type, for (i = 0; i < ad5064_num_vref(st); ++i) st->vref_reg[i].supply = ad5064_vref_name(st, i); - ret = regulator_bulk_get(dev, ad5064_num_vref(st), + ret = devm_regulator_bulk_get(dev, ad5064_num_vref(st), st->vref_reg); if (ret) { if (!st->chip_info->internal_vref) - goto error_free; + return ret; st->use_internal_vref = true; ret = ad5064_write(st, AD5064_CMD_CONFIG, 0, AD5064_CONFIG_INT_VREF_ENABLE, 0); if (ret) { dev_err(dev, "Failed to enable internal vref: %d\n", ret); - goto error_free; + return ret; } } else { ret = regulator_bulk_enable(ad5064_num_vref(st), st->vref_reg); if (ret) - goto error_free_reg; + return ret; } indio_dev->dev.parent = dev; @@ -498,11 +498,6 @@ static int ad5064_probe(struct device *dev, enum ad5064_type type, error_disable_reg: if (!st->use_internal_vref) regulator_bulk_disable(ad5064_num_vref(st), st->vref_reg); -error_free_reg: - if (!st->use_internal_vref) - regulator_bulk_free(ad5064_num_vref(st), st->vref_reg); -error_free: - iio_device_free(indio_dev); return ret; } @@ -514,12 +509,8 @@ static int ad5064_remove(struct device *dev) iio_device_unregister(indio_dev); - if (!st->use_internal_vref) { + if (!st->use_internal_vref) regulator_bulk_disable(ad5064_num_vref(st), st->vref_reg); - regulator_bulk_free(ad5064_num_vref(st), st->vref_reg); - } - - iio_device_free(indio_dev); return 0; } -- GitLab From 400d36e68de56135223ace631f4bb067d9ccb44d Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Mon, 19 Aug 2013 12:38:00 +0100 Subject: [PATCH 668/942] iio: dac: ad5360: Use devm_* APIs devm_* APIs are device managed and make code simpler. Signed-off-by: Sachin Kamat Signed-off-by: Jonathan Cameron --- drivers/iio/dac/ad5360.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/iio/dac/ad5360.c b/drivers/iio/dac/ad5360.c index 80923af424f27..d2da71ece740c 100644 --- a/drivers/iio/dac/ad5360.c +++ b/drivers/iio/dac/ad5360.c @@ -459,7 +459,7 @@ static int ad5360_probe(struct spi_device *spi) unsigned int i; int ret; - indio_dev = iio_device_alloc(sizeof(*st)); + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); if (indio_dev == NULL) { dev_err(&spi->dev, "Failed to allocate iio device\n"); return -ENOMEM; @@ -480,13 +480,13 @@ static int ad5360_probe(struct spi_device *spi) ret = ad5360_alloc_channels(indio_dev); if (ret) { dev_err(&spi->dev, "Failed to allocate channel spec: %d\n", ret); - goto error_free; + return ret; } for (i = 0; i < st->chip_info->num_vrefs; ++i) st->vref_reg[i].supply = ad5360_vref_name[i]; - ret = regulator_bulk_get(&st->spi->dev, st->chip_info->num_vrefs, + ret = devm_regulator_bulk_get(&st->spi->dev, st->chip_info->num_vrefs, st->vref_reg); if (ret) { dev_err(&spi->dev, "Failed to request vref regulators: %d\n", ret); @@ -496,7 +496,7 @@ static int ad5360_probe(struct spi_device *spi) ret = regulator_bulk_enable(st->chip_info->num_vrefs, st->vref_reg); if (ret) { dev_err(&spi->dev, "Failed to enable vref regulators: %d\n", ret); - goto error_free_reg; + goto error_free_channels; } ret = iio_device_register(indio_dev); @@ -509,12 +509,8 @@ static int ad5360_probe(struct spi_device *spi) error_disable_reg: regulator_bulk_disable(st->chip_info->num_vrefs, st->vref_reg); -error_free_reg: - regulator_bulk_free(st->chip_info->num_vrefs, st->vref_reg); error_free_channels: kfree(indio_dev->channels); -error_free: - iio_device_free(indio_dev); return ret; } @@ -529,9 +525,6 @@ static int ad5360_remove(struct spi_device *spi) kfree(indio_dev->channels); regulator_bulk_disable(st->chip_info->num_vrefs, st->vref_reg); - regulator_bulk_free(st->chip_info->num_vrefs, st->vref_reg); - - iio_device_free(indio_dev); return 0; } -- GitLab From c815ad372be668bd6f173439be1f67e0d7dc4e5b Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Mon, 19 Aug 2013 12:38:00 +0100 Subject: [PATCH 669/942] iio: dac: ad5380: Use devm_* APIs devm_* APIs are device managed and make code simpler. Signed-off-by: Sachin Kamat Signed-off-by: Jonathan Cameron --- drivers/iio/dac/ad5380.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/drivers/iio/dac/ad5380.c b/drivers/iio/dac/ad5380.c index bf2db02215c28..1c44ae3920e25 100644 --- a/drivers/iio/dac/ad5380.c +++ b/drivers/iio/dac/ad5380.c @@ -369,11 +369,10 @@ static int ad5380_probe(struct device *dev, struct regmap *regmap, unsigned int ctrl = 0; int ret; - indio_dev = iio_device_alloc(sizeof(*st)); + indio_dev = devm_iio_device_alloc(dev, sizeof(*st)); if (indio_dev == NULL) { dev_err(dev, "Failed to allocate iio device\n"); - ret = -ENOMEM; - goto error_out; + return -ENOMEM; } st = iio_priv(indio_dev); @@ -391,13 +390,13 @@ static int ad5380_probe(struct device *dev, struct regmap *regmap, ret = ad5380_alloc_channels(indio_dev); if (ret) { dev_err(dev, "Failed to allocate channel spec: %d\n", ret); - goto error_free; + return ret; } if (st->chip_info->int_vref == 2500000) ctrl |= AD5380_CTRL_INT_VREF_2V5; - st->vref_reg = regulator_get(dev, "vref"); + st->vref_reg = devm_regulator_get(dev, "vref"); if (!IS_ERR(st->vref_reg)) { ret = regulator_enable(st->vref_reg); if (ret) { @@ -434,13 +433,7 @@ static int ad5380_probe(struct device *dev, struct regmap *regmap, if (!IS_ERR(st->vref_reg)) regulator_disable(st->vref_reg); error_free_reg: - if (!IS_ERR(st->vref_reg)) - regulator_put(st->vref_reg); - kfree(indio_dev->channels); -error_free: - iio_device_free(indio_dev); -error_out: return ret; } @@ -456,11 +449,8 @@ static int ad5380_remove(struct device *dev) if (!IS_ERR(st->vref_reg)) { regulator_disable(st->vref_reg); - regulator_put(st->vref_reg); } - iio_device_free(indio_dev); - return 0; } -- GitLab From 62a308a62d3d9ce3b167ce35a6643b22e66282e1 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Mon, 19 Aug 2013 12:38:00 +0100 Subject: [PATCH 670/942] iio: dac: ad5421: Use devm_* APIs devm_* APIs are device managed and make code simpler. Signed-off-by: Sachin Kamat Signed-off-by: Jonathan Cameron --- drivers/iio/dac/ad5421.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/drivers/iio/dac/ad5421.c b/drivers/iio/dac/ad5421.c index 98f24407c3cee..1f78b14abb7dc 100644 --- a/drivers/iio/dac/ad5421.c +++ b/drivers/iio/dac/ad5421.c @@ -451,7 +451,7 @@ static int ad5421_probe(struct spi_device *spi) struct ad5421_state *st; int ret; - indio_dev = iio_device_alloc(sizeof(*st)); + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); if (indio_dev == NULL) { dev_err(&spi->dev, "Failed to allocate iio device\n"); return -ENOMEM; @@ -484,31 +484,23 @@ static int ad5421_probe(struct spi_device *spi) ad5421_update_ctrl(indio_dev, 0, 0); if (spi->irq) { - ret = request_threaded_irq(spi->irq, + ret = devm_request_threaded_irq(&spi->dev, spi->irq, NULL, ad5421_fault_handler, IRQF_TRIGGER_HIGH | IRQF_ONESHOT, "ad5421 fault", indio_dev); if (ret) - goto error_free; + return ret; } ret = iio_device_register(indio_dev); if (ret) { dev_err(&spi->dev, "Failed to register iio device: %d\n", ret); - goto error_free_irq; + return ret; } return 0; - -error_free_irq: - if (spi->irq) - free_irq(spi->irq, indio_dev); -error_free: - iio_device_free(indio_dev); - - return ret; } static int ad5421_remove(struct spi_device *spi) @@ -516,9 +508,6 @@ static int ad5421_remove(struct spi_device *spi) struct iio_dev *indio_dev = spi_get_drvdata(spi); iio_device_unregister(indio_dev); - if (spi->irq) - free_irq(spi->irq, indio_dev); - iio_device_free(indio_dev); return 0; } -- GitLab From ba7272954ec933eca3e459ac45003c0073a86993 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Mon, 19 Aug 2013 12:38:00 +0100 Subject: [PATCH 671/942] iio: dac: ad5446: Use devm_* APIs devm_* APIs are device managed and make code simpler. Signed-off-by: Sachin Kamat Signed-off-by: Jonathan Cameron --- drivers/iio/dac/ad5446.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/drivers/iio/dac/ad5446.c b/drivers/iio/dac/ad5446.c index cae8f6056ac33..96e9ed4c2d016 100644 --- a/drivers/iio/dac/ad5446.c +++ b/drivers/iio/dac/ad5446.c @@ -220,11 +220,11 @@ static int ad5446_probe(struct device *dev, const char *name, struct regulator *reg; int ret, voltage_uv = 0; - reg = regulator_get(dev, "vcc"); + reg = devm_regulator_get(dev, "vcc"); if (!IS_ERR(reg)) { ret = regulator_enable(reg); if (ret) - goto error_put_reg; + return ret; ret = regulator_get_voltage(reg); if (ret < 0) @@ -233,7 +233,7 @@ static int ad5446_probe(struct device *dev, const char *name, voltage_uv = ret; } - indio_dev = iio_device_alloc(sizeof(*st)); + indio_dev = devm_iio_device_alloc(dev, sizeof(*st)); if (indio_dev == NULL) { ret = -ENOMEM; goto error_disable_reg; @@ -264,19 +264,13 @@ static int ad5446_probe(struct device *dev, const char *name, ret = iio_device_register(indio_dev); if (ret) - goto error_free_device; + goto error_disable_reg; return 0; -error_free_device: - iio_device_free(indio_dev); error_disable_reg: if (!IS_ERR(reg)) regulator_disable(reg); -error_put_reg: - if (!IS_ERR(reg)) - regulator_put(reg); - return ret; } @@ -286,11 +280,8 @@ static int ad5446_remove(struct device *dev) struct ad5446_state *st = iio_priv(indio_dev); iio_device_unregister(indio_dev); - if (!IS_ERR(st->reg)) { + if (!IS_ERR(st->reg)) regulator_disable(st->reg); - regulator_put(st->reg); - } - iio_device_free(indio_dev); return 0; } -- GitLab From cd5e5785417591deba06b5fe3e78137137d2a9d3 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Mon, 19 Aug 2013 12:38:00 +0100 Subject: [PATCH 672/942] iio: dac: ad5449: Use devm_* APIs devm_* APIs are device managed and make code simpler. Signed-off-by: Sachin Kamat Signed-off-by: Jonathan Cameron --- drivers/iio/dac/ad5449.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/iio/dac/ad5449.c b/drivers/iio/dac/ad5449.c index ba1c914b0399a..fff7d0762c0cb 100644 --- a/drivers/iio/dac/ad5449.c +++ b/drivers/iio/dac/ad5449.c @@ -275,7 +275,7 @@ static int ad5449_spi_probe(struct spi_device *spi) unsigned int i; int ret; - indio_dev = iio_device_alloc(sizeof(*st)); + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); if (indio_dev == NULL) return -ENOMEM; @@ -288,14 +288,14 @@ static int ad5449_spi_probe(struct spi_device *spi) for (i = 0; i < st->chip_info->num_channels; ++i) st->vref_reg[i].supply = ad5449_vref_name(st, i); - ret = regulator_bulk_get(&spi->dev, st->chip_info->num_channels, + ret = devm_regulator_bulk_get(&spi->dev, st->chip_info->num_channels, st->vref_reg); if (ret) - goto error_free; + return ret; ret = regulator_bulk_enable(st->chip_info->num_channels, st->vref_reg); if (ret) - goto error_free_reg; + return ret; indio_dev->dev.parent = &spi->dev; indio_dev->name = id->name; @@ -325,10 +325,6 @@ static int ad5449_spi_probe(struct spi_device *spi) error_disable_reg: regulator_bulk_disable(st->chip_info->num_channels, st->vref_reg); -error_free_reg: - regulator_bulk_free(st->chip_info->num_channels, st->vref_reg); -error_free: - iio_device_free(indio_dev); return ret; } @@ -341,9 +337,6 @@ static int ad5449_spi_remove(struct spi_device *spi) iio_device_unregister(indio_dev); regulator_bulk_disable(st->chip_info->num_channels, st->vref_reg); - regulator_bulk_free(st->chip_info->num_channels, st->vref_reg); - - iio_device_free(indio_dev); return 0; } -- GitLab From 8571ebf7fc1892beadd83dd7af385c599c3ec0d3 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Mon, 19 Aug 2013 12:38:00 +0100 Subject: [PATCH 673/942] iio: dac: ad5504: Use devm_* APIs devm_* APIs are device managed and make code simpler. Signed-off-by: Sachin Kamat Signed-off-by: Jonathan Cameron --- drivers/iio/dac/ad5504.c | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/drivers/iio/dac/ad5504.c b/drivers/iio/dac/ad5504.c index 139206e84cb7b..caffb16bc05c0 100644 --- a/drivers/iio/dac/ad5504.c +++ b/drivers/iio/dac/ad5504.c @@ -281,16 +281,14 @@ static int ad5504_probe(struct spi_device *spi) struct regulator *reg; int ret, voltage_uv = 0; - indio_dev = iio_device_alloc(sizeof(*st)); - if (indio_dev == NULL) { - ret = -ENOMEM; - goto error_ret; - } - reg = regulator_get(&spi->dev, "vcc"); + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); + if (!indio_dev) + return -ENOMEM; + reg = devm_regulator_get(&spi->dev, "vcc"); if (!IS_ERR(reg)) { ret = regulator_enable(reg); if (ret) - goto error_put_reg; + return ret; ret = regulator_get_voltage(reg); if (ret < 0) @@ -321,7 +319,7 @@ static int ad5504_probe(struct spi_device *spi) indio_dev->modes = INDIO_DIRECT_MODE; if (spi->irq) { - ret = request_threaded_irq(spi->irq, + ret = devm_request_threaded_irq(&spi->dev, spi->irq, NULL, &ad5504_event_handler, IRQF_TRIGGER_FALLING | IRQF_ONESHOT, @@ -333,22 +331,14 @@ static int ad5504_probe(struct spi_device *spi) ret = iio_device_register(indio_dev); if (ret) - goto error_free_irq; + goto error_disable_reg; return 0; -error_free_irq: - if (spi->irq) - free_irq(spi->irq, indio_dev); error_disable_reg: if (!IS_ERR(reg)) regulator_disable(reg); -error_put_reg: - if (!IS_ERR(reg)) - regulator_put(reg); - iio_device_free(indio_dev); -error_ret: return ret; } @@ -358,14 +348,9 @@ static int ad5504_remove(struct spi_device *spi) struct ad5504_state *st = iio_priv(indio_dev); iio_device_unregister(indio_dev); - if (spi->irq) - free_irq(spi->irq, indio_dev); - if (!IS_ERR(st->reg)) { + if (!IS_ERR(st->reg)) regulator_disable(st->reg); - regulator_put(st->reg); - } - iio_device_free(indio_dev); return 0; } -- GitLab From 75238230cce22b99e648e96bbc043725832c6ad5 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Mon, 19 Aug 2013 12:38:00 +0100 Subject: [PATCH 674/942] iio: dac: ad5624r_spi: Use devm_* APIs devm_* APIs are device managed and make code simpler. Signed-off-by: Sachin Kamat Signed-off-by: Jonathan Cameron --- drivers/iio/dac/ad5624r_spi.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/drivers/iio/dac/ad5624r_spi.c b/drivers/iio/dac/ad5624r_spi.c index bb298aaff321f..714af757cd561 100644 --- a/drivers/iio/dac/ad5624r_spi.c +++ b/drivers/iio/dac/ad5624r_spi.c @@ -226,17 +226,15 @@ static int ad5624r_probe(struct spi_device *spi) struct iio_dev *indio_dev; int ret, voltage_uv = 0; - indio_dev = iio_device_alloc(sizeof(*st)); - if (indio_dev == NULL) { - ret = -ENOMEM; - goto error_ret; - } + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); + if (!indio_dev) + return -ENOMEM; st = iio_priv(indio_dev); - st->reg = regulator_get(&spi->dev, "vcc"); + st->reg = devm_regulator_get(&spi->dev, "vcc"); if (!IS_ERR(st->reg)) { ret = regulator_enable(st->reg); if (ret) - goto error_put_reg; + return ret; ret = regulator_get_voltage(st->reg); if (ret < 0) @@ -277,11 +275,6 @@ static int ad5624r_probe(struct spi_device *spi) error_disable_reg: if (!IS_ERR(st->reg)) regulator_disable(st->reg); -error_put_reg: - if (!IS_ERR(st->reg)) - regulator_put(st->reg); - iio_device_free(indio_dev); -error_ret: return ret; } @@ -292,11 +285,8 @@ static int ad5624r_remove(struct spi_device *spi) struct ad5624r_state *st = iio_priv(indio_dev); iio_device_unregister(indio_dev); - if (!IS_ERR(st->reg)) { + if (!IS_ERR(st->reg)) regulator_disable(st->reg); - regulator_put(st->reg); - } - iio_device_free(indio_dev); return 0; } -- GitLab From edf3fd4141f17fa81497e7417aba7a45d1a36af9 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Mon, 19 Aug 2013 12:38:00 +0100 Subject: [PATCH 675/942] iio: dac: ad5686: Use devm_* APIs devm_* APIs are device managed and make code simpler. Signed-off-by: Sachin Kamat Signed-off-by: Jonathan Cameron --- drivers/iio/dac/ad5686.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c index 06439b1af9b6f..57825ead7db2e 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -314,18 +314,18 @@ static int ad5686_probe(struct spi_device *spi) struct iio_dev *indio_dev; int ret, regdone = 0, voltage_uv = 0; - indio_dev = iio_device_alloc(sizeof(*st)); + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); if (indio_dev == NULL) return -ENOMEM; st = iio_priv(indio_dev); spi_set_drvdata(spi, indio_dev); - st->reg = regulator_get(&spi->dev, "vcc"); + st->reg = devm_regulator_get(&spi->dev, "vcc"); if (!IS_ERR(st->reg)) { ret = regulator_enable(st->reg); if (ret) - goto error_put_reg; + return ret; ret = regulator_get_voltage(st->reg); if (ret < 0) @@ -369,12 +369,6 @@ static int ad5686_probe(struct spi_device *spi) error_disable_reg: if (!IS_ERR(st->reg)) regulator_disable(st->reg); -error_put_reg: - if (!IS_ERR(st->reg)) - regulator_put(st->reg); - - iio_device_free(indio_dev); - return ret; } @@ -384,11 +378,8 @@ static int ad5686_remove(struct spi_device *spi) struct ad5686_state *st = iio_priv(indio_dev); iio_device_unregister(indio_dev); - if (!IS_ERR(st->reg)) { + if (!IS_ERR(st->reg)) regulator_disable(st->reg); - regulator_put(st->reg); - } - iio_device_free(indio_dev); return 0; } -- GitLab From fd047294e279779c36cbca589d9fef06e881e67a Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Mon, 19 Aug 2013 12:38:00 +0100 Subject: [PATCH 676/942] iio: dac: ad5755: Use devm_iio_device_alloc Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat Signed-off-by: Jonathan Cameron --- drivers/iio/dac/ad5755.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/iio/dac/ad5755.c b/drivers/iio/dac/ad5755.c index 12bb315e55f85..36a4361aece12 100644 --- a/drivers/iio/dac/ad5755.c +++ b/drivers/iio/dac/ad5755.c @@ -565,7 +565,7 @@ static int ad5755_probe(struct spi_device *spi) struct ad5755_state *st; int ret; - indio_dev = iio_device_alloc(sizeof(*st)); + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); if (indio_dev == NULL) { dev_err(&spi->dev, "Failed to allocate iio device\n"); return -ENOMEM; @@ -589,24 +589,19 @@ static int ad5755_probe(struct spi_device *spi) ret = ad5755_init_channels(indio_dev, pdata); if (ret) - goto error_free; + return ret; ret = ad5755_setup_pdata(indio_dev, pdata); if (ret) - goto error_free; + return ret; ret = iio_device_register(indio_dev); if (ret) { dev_err(&spi->dev, "Failed to register iio device: %d\n", ret); - goto error_free; + return ret; } return 0; - -error_free: - iio_device_free(indio_dev); - - return ret; } static int ad5755_remove(struct spi_device *spi) @@ -614,7 +609,6 @@ static int ad5755_remove(struct spi_device *spi) struct iio_dev *indio_dev = spi_get_drvdata(spi); iio_device_unregister(indio_dev); - iio_device_free(indio_dev); return 0; } -- GitLab From 7ff0de3faaeb0db80c2c9f03c119167e89594879 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Mon, 19 Aug 2013 12:38:00 +0100 Subject: [PATCH 677/942] iio: dac: ad5764: Use devm_* APIs devm_* APIs are device managed and make code simpler. Signed-off-by: Sachin Kamat Signed-off-by: Jonathan Cameron --- drivers/iio/dac/ad5764.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/drivers/iio/dac/ad5764.c b/drivers/iio/dac/ad5764.c index 7a53f7d70dacf..df7e028d9db5e 100644 --- a/drivers/iio/dac/ad5764.c +++ b/drivers/iio/dac/ad5764.c @@ -275,7 +275,7 @@ static int ad5764_probe(struct spi_device *spi) struct ad5764_state *st; int ret; - indio_dev = iio_device_alloc(sizeof(*st)); + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); if (indio_dev == NULL) { dev_err(&spi->dev, "Failed to allocate iio device\n"); return -ENOMEM; @@ -298,12 +298,12 @@ static int ad5764_probe(struct spi_device *spi) st->vref_reg[0].supply = "vrefAB"; st->vref_reg[1].supply = "vrefCD"; - ret = regulator_bulk_get(&st->spi->dev, + ret = devm_regulator_bulk_get(&st->spi->dev, ARRAY_SIZE(st->vref_reg), st->vref_reg); if (ret) { dev_err(&spi->dev, "Failed to request vref regulators: %d\n", ret); - goto error_free; + return ret; } ret = regulator_bulk_enable(ARRAY_SIZE(st->vref_reg), @@ -311,7 +311,7 @@ static int ad5764_probe(struct spi_device *spi) if (ret) { dev_err(&spi->dev, "Failed to enable vref regulators: %d\n", ret); - goto error_free_reg; + return ret; } } @@ -326,12 +326,6 @@ static int ad5764_probe(struct spi_device *spi) error_disable_reg: if (st->chip_info->int_vref == 0) regulator_bulk_disable(ARRAY_SIZE(st->vref_reg), st->vref_reg); -error_free_reg: - if (st->chip_info->int_vref == 0) - regulator_bulk_free(ARRAY_SIZE(st->vref_reg), st->vref_reg); -error_free: - iio_device_free(indio_dev); - return ret; } @@ -342,12 +336,8 @@ static int ad5764_remove(struct spi_device *spi) iio_device_unregister(indio_dev); - if (st->chip_info->int_vref == 0) { + if (st->chip_info->int_vref == 0) regulator_bulk_disable(ARRAY_SIZE(st->vref_reg), st->vref_reg); - regulator_bulk_free(ARRAY_SIZE(st->vref_reg), st->vref_reg); - } - - iio_device_free(indio_dev); return 0; } -- GitLab From 0d7c04d33f3e2f9e3da0a545be747731b4410e32 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Mon, 19 Aug 2013 12:38:00 +0100 Subject: [PATCH 678/942] iio: dac: ad5791: Use devm_* APIs devm_* APIs are device managed and make code simpler. Signed-off-by: Sachin Kamat Signed-off-by: Jonathan Cameron --- drivers/iio/dac/ad5791.c | 35 +++++++++-------------------------- 1 file changed, 9 insertions(+), 26 deletions(-) diff --git a/drivers/iio/dac/ad5791.c b/drivers/iio/dac/ad5791.c index 97c1e5d780dfc..ce7458963309a 100644 --- a/drivers/iio/dac/ad5791.c +++ b/drivers/iio/dac/ad5791.c @@ -349,17 +349,15 @@ static int ad5791_probe(struct spi_device *spi) struct ad5791_state *st; int ret, pos_voltage_uv = 0, neg_voltage_uv = 0; - indio_dev = iio_device_alloc(sizeof(*st)); - if (indio_dev == NULL) { - ret = -ENOMEM; - goto error_ret; - } + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); + if (!indio_dev) + return -ENOMEM; st = iio_priv(indio_dev); - st->reg_vdd = regulator_get(&spi->dev, "vdd"); + st->reg_vdd = devm_regulator_get(&spi->dev, "vdd"); if (!IS_ERR(st->reg_vdd)) { ret = regulator_enable(st->reg_vdd); if (ret) - goto error_put_reg_pos; + return ret; ret = regulator_get_voltage(st->reg_vdd); if (ret < 0) @@ -368,11 +366,11 @@ static int ad5791_probe(struct spi_device *spi) pos_voltage_uv = ret; } - st->reg_vss = regulator_get(&spi->dev, "vss"); + st->reg_vss = devm_regulator_get(&spi->dev, "vss"); if (!IS_ERR(st->reg_vss)) { ret = regulator_enable(st->reg_vss); if (ret) - goto error_put_reg_neg; + goto error_disable_reg_pos; ret = regulator_get_voltage(st->reg_vss); if (ret < 0) @@ -428,19 +426,9 @@ static int ad5791_probe(struct spi_device *spi) error_disable_reg_neg: if (!IS_ERR(st->reg_vss)) regulator_disable(st->reg_vss); -error_put_reg_neg: - if (!IS_ERR(st->reg_vss)) - regulator_put(st->reg_vss); - error_disable_reg_pos: if (!IS_ERR(st->reg_vdd)) regulator_disable(st->reg_vdd); -error_put_reg_pos: - if (!IS_ERR(st->reg_vdd)) - regulator_put(st->reg_vdd); - iio_device_free(indio_dev); -error_ret: - return ret; } @@ -450,16 +438,11 @@ static int ad5791_remove(struct spi_device *spi) struct ad5791_state *st = iio_priv(indio_dev); iio_device_unregister(indio_dev); - if (!IS_ERR(st->reg_vdd)) { + if (!IS_ERR(st->reg_vdd)) regulator_disable(st->reg_vdd); - regulator_put(st->reg_vdd); - } - if (!IS_ERR(st->reg_vss)) { + if (!IS_ERR(st->reg_vss)) regulator_disable(st->reg_vss); - regulator_put(st->reg_vss); - } - iio_device_free(indio_dev); return 0; } -- GitLab From 66e670aa0805e553e2647da37502759967f026d3 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Mon, 19 Aug 2013 12:38:00 +0100 Subject: [PATCH 679/942] iio: dac: ad7303: Use devm_* APIs devm_* APIs are device managed and make code simpler. Signed-off-by: Sachin Kamat Signed-off-by: Jonathan Cameron --- drivers/iio/dac/ad7303.c | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/drivers/iio/dac/ad7303.c b/drivers/iio/dac/ad7303.c index d546f50f9258b..ed2d276477bd9 100644 --- a/drivers/iio/dac/ad7303.c +++ b/drivers/iio/dac/ad7303.c @@ -203,7 +203,7 @@ static int ad7303_probe(struct spi_device *spi) bool ext_ref; int ret; - indio_dev = iio_device_alloc(sizeof(*st)); + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); if (indio_dev == NULL) return -ENOMEM; @@ -212,15 +212,13 @@ static int ad7303_probe(struct spi_device *spi) st->spi = spi; - st->vdd_reg = regulator_get(&spi->dev, "Vdd"); - if (IS_ERR(st->vdd_reg)) { - ret = PTR_ERR(st->vdd_reg); - goto err_free; - } + st->vdd_reg = devm_regulator_get(&spi->dev, "Vdd"); + if (IS_ERR(st->vdd_reg)) + return PTR_ERR(st->vdd_reg); ret = regulator_enable(st->vdd_reg); if (ret) - goto err_put_vdd_reg; + return ret; if (spi->dev.of_node) { ext_ref = of_property_read_bool(spi->dev.of_node, @@ -234,7 +232,7 @@ static int ad7303_probe(struct spi_device *spi) } if (ext_ref) { - st->vref_reg = regulator_get(&spi->dev, "REF"); + st->vref_reg = devm_regulator_get(&spi->dev, "REF"); if (IS_ERR(st->vref_reg)) { ret = PTR_ERR(st->vref_reg); goto err_disable_vdd_reg; @@ -242,7 +240,7 @@ static int ad7303_probe(struct spi_device *spi) ret = regulator_enable(st->vref_reg); if (ret) - goto err_put_vref_reg; + goto err_disable_vdd_reg; st->config |= AD7303_CFG_EXTERNAL_VREF; } @@ -263,16 +261,8 @@ static int ad7303_probe(struct spi_device *spi) err_disable_vref_reg: if (st->vref_reg) regulator_disable(st->vref_reg); -err_put_vref_reg: - if (st->vref_reg) - regulator_put(st->vref_reg); err_disable_vdd_reg: regulator_disable(st->vdd_reg); -err_put_vdd_reg: - regulator_put(st->vdd_reg); -err_free: - iio_device_free(indio_dev); - return ret; } @@ -283,14 +273,9 @@ static int ad7303_remove(struct spi_device *spi) iio_device_unregister(indio_dev); - if (st->vref_reg) { + if (st->vref_reg) regulator_disable(st->vref_reg); - regulator_put(st->vref_reg); - } regulator_disable(st->vdd_reg); - regulator_put(st->vdd_reg); - - iio_device_free(indio_dev); return 0; } -- GitLab From cc566fd5e52d64554d294b4d36f9d593cbe797d5 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Mon, 19 Aug 2013 12:38:00 +0100 Subject: [PATCH 680/942] iio: dac: max517: Use devm_iio_device_alloc Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat Cc: Roland Stigge Signed-off-by: Jonathan Cameron --- drivers/iio/dac/max517.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/drivers/iio/dac/max517.c b/drivers/iio/dac/max517.c index ebfaa4156246f..83adcbf1a205e 100644 --- a/drivers/iio/dac/max517.c +++ b/drivers/iio/dac/max517.c @@ -164,11 +164,9 @@ static int max517_probe(struct i2c_client *client, struct max517_platform_data *platform_data = client->dev.platform_data; int err; - indio_dev = iio_device_alloc(sizeof(*data)); - if (indio_dev == NULL) { - err = -ENOMEM; - goto exit; - } + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); + if (!indio_dev) + return -ENOMEM; data = iio_priv(indio_dev); i2c_set_clientdata(client, indio_dev); data->client = client; @@ -198,23 +196,16 @@ static int max517_probe(struct i2c_client *client, err = iio_device_register(indio_dev); if (err) - goto exit_free_device; + return err; dev_info(&client->dev, "DAC registered\n"); return 0; - -exit_free_device: - iio_device_free(indio_dev); -exit: - return err; } static int max517_remove(struct i2c_client *client) { iio_device_unregister(i2c_get_clientdata(client)); - iio_device_free(i2c_get_clientdata(client)); - return 0; } -- GitLab From 9467d11b0d419ed9d4a5408ddb79d16d2f38b9fa Mon Sep 17 00:00:00 2001 From: Jens Frederich Date: Sat, 17 Aug 2013 16:20:54 +0200 Subject: [PATCH 681/942] Staging: olpc_dcon: fix typo in olpc_dcon.h The backlight brightness register (DCON_REG_BRIGHT) address is 0xa. Signed-off-by: Jens Frederich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/olpc_dcon/olpc_dcon.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/olpc_dcon/olpc_dcon.h b/drivers/staging/olpc_dcon/olpc_dcon.h index 524ee49fbacb4..e2663b189c66d 100644 --- a/drivers/staging/olpc_dcon/olpc_dcon.h +++ b/drivers/staging/olpc_dcon/olpc_dcon.h @@ -30,7 +30,7 @@ #define DCON_REG_VSYNC_WIDTH 0x7 #define DCON_REG_TIMEOUT 0x8 #define DCON_REG_SCAN_INT 0x9 -#define DCON_REG_BRIGHT 0x10 +#define DCON_REG_BRIGHT 0xa #define DCON_REG_MEM_OPT_A 0x41 #define DCON_REG_MEM_OPT_B 0x42 -- GitLab From 7d5b640dfa19a9d55bb5c9dd34f607200cb199c3 Mon Sep 17 00:00:00 2001 From: Jens Frederich Date: Sat, 17 Aug 2013 16:20:29 +0200 Subject: [PATCH 682/942] Staging: olpc_dcon: Already completed TODO entry removed The TODO entry - drop global variables, use a proper olpc_dcon_priv struct - is already finished. The driver has no global variables. It uses the private structure 'dcon_priv'. Signed-off-by: Jens Frederich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/olpc_dcon/TODO | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/olpc_dcon/TODO b/drivers/staging/olpc_dcon/TODO index 901b891d38b23..885399196de21 100644 --- a/drivers/staging/olpc_dcon/TODO +++ b/drivers/staging/olpc_dcon/TODO @@ -3,7 +3,6 @@ TODO: share more code - allow simultaneous XO-1 and XO-1.5 support - console event notifier support - - drop global variables, use a proper olpc_dcon_priv struct - audit code for unnecessary code; old unsupported prototype workarounds, ancient variables (noaa?), etc - verify sane i2c API usage, update to new stuff if necessary -- GitLab From 7ee4c1b94958837015f8b8a1db6101810c211a8c Mon Sep 17 00:00:00 2001 From: Won Kang Date: Fri, 16 Aug 2013 13:13:43 +0900 Subject: [PATCH 683/942] staging: gdm7240: a TTY rewrite according to the latest TTY APIs Removed the old style reference countings and termios. Renamed variables to meaninful ones. Signed-off-by: Won Kang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm724x/gdm_tty.c | 294 ++++++++++++++---------------- drivers/staging/gdm724x/gdm_tty.h | 5 +- 2 files changed, 142 insertions(+), 157 deletions(-) diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c index 912022b84c03d..5bcf88224e903 100644 --- a/drivers/staging/gdm724x/gdm_tty.c +++ b/drivers/staging/gdm724x/gdm_tty.c @@ -45,141 +45,138 @@ #define gdm_tty_send_control(n, r, v, d, l) (\ n->tty_dev->send_control(n->tty_dev->priv_dev, r, v, d, l)) -#define acm_set_comm_feature(n, v) \ - gdm_tty_send_control(n, 0x02, v, NULL, 0) +#define GDM_TTY_READY(gdm) (gdm && gdm->tty_dev && gdm->port.count) -#define GDM_TTY_READY(tty_str) (tty_str && tty_str->tty_dev && tty_str->port.count) - -struct tty_driver *g_tty_drv[TTY_MAX_COUNT] = {NULL, }; -struct tty_str *g_tty_str[TTY_MAX_COUNT][GDM_TTY_MINOR] = {{NULL, }, }; +struct tty_driver *gdm_driver[TTY_MAX_COUNT]; +struct gdm *gdm_table[TTY_MAX_COUNT][GDM_TTY_MINOR]; +static DEFINE_MUTEX(gdm_table_lock); static char *DRIVER_STRING[TTY_MAX_COUNT] = {"GCTATC", "GCTDM"}; static char *DEVICE_STRING[TTY_MAX_COUNT] = {"GCT-ATC", "GCT-DM"}; -static DEFINE_MUTEX(open_mutex); +static void gdm_port_destruct(struct tty_port *port) +{ + struct gdm *gdm = container_of(port, struct gdm, port); + + mutex_lock(&gdm_table_lock); + gdm_table[gdm->index][gdm->minor] = NULL; + mutex_unlock(&gdm_table_lock); + + kfree(gdm); +} -static struct tty_port_operations gdm_tty_port_ops = { +static struct tty_port_operations gdm_port_ops = { + .destruct = gdm_port_destruct, }; -static int gdm_tty_open(struct tty_struct *tty, struct file *filp) +static int gdm_tty_install(struct tty_driver *driver, struct tty_struct *tty) { - struct tty_str *tty_str = NULL; + struct gdm *gdm = NULL; + int ret; int i; - int ret = 0; - - mutex_lock(&open_mutex); + int j; + j = GDM_TTY_MINOR; for (i = 0; i < TTY_MAX_COUNT; i++) { if (!strcmp(tty->driver->driver_name, DRIVER_STRING[i])) { - tty_str = g_tty_str[i][tty->index]; + j = tty->index; break; } } - if (!tty_str) { - pr_info("no tty device\n"); - mutex_unlock(&open_mutex); + if (j == GDM_TTY_MINOR) return -ENODEV; - } - set_bit(TTY_NO_WRITE_SPLIT, &tty->flags); + mutex_lock(&gdm_table_lock); + gdm = gdm_table[i][j]; + mutex_unlock(&gdm_table_lock); + if (gdm == NULL) + return -ENODEV; - tty->driver_data = tty_str; - tty_port_tty_set(&tty_str->port, tty); - tty_str->port.count++; - set_bit(ASYNCB_INITIALIZED, &tty_str->port.flags); - ret = tty_port_block_til_ready(&tty_str->port, tty, filp); + tty_port_get(&gdm->port); - mutex_unlock(&open_mutex); + ret = tty_standard_install(driver, tty); + if (ret) { + tty_port_put(&gdm->port); + return ret; + } - return ret; + tty->driver_data = gdm; + + return 0; } -static void gdm_tty_close(struct tty_struct *tty, struct file *filp) +static int gdm_tty_open(struct tty_struct *tty, struct file *filp) { - struct tty_str *tty_str = tty->driver_data; - int i; - - if (!tty_str) { - pr_info("tty device already closed\n"); - return; - } - - if (tty_str->port.count != 0) { - tty_port_close_start(&tty_str->port, tty, filp); - tty_port_close_end(&tty_str->port, tty); + struct gdm *gdm = tty->driver_data; + return tty_port_open(&gdm->port, tty, filp); +} - if (tty_str->port.count == 0) - tty_port_tty_set(&tty_str->port, NULL); - tty_str->port.tty = NULL; - } +static void gdm_tty_cleanup(struct tty_struct *tty) +{ + struct gdm *gdm = tty->driver_data; + tty_port_put(&gdm->port); +} - if (!tty_str->tty_dev) { - for (i = 0; i < TTY_MAX_COUNT; i++) { - if (!strcmp(tty->driver->driver_name, DRIVER_STRING[i])) - break; - } +static void gdm_tty_hangup(struct tty_struct *tty) +{ + struct gdm *gdm = tty->driver_data; + tty_port_hangup(&gdm->port); +} - if (i < TTY_MAX_COUNT) { - tty_unregister_device(g_tty_drv[i], tty->index); - tty_port_tty_set(&tty_str->port, NULL); - kfree(tty_str); - g_tty_str[i][tty->index] = NULL; - } - } +static void gdm_tty_close(struct tty_struct *tty, struct file *filp) +{ + struct gdm *gdm = tty->driver_data; + tty_port_close(&gdm->port, tty, filp); } static int gdm_tty_recv_complete(void *data, int len, int index, int minor, int complete) { - struct tty_str *tty_str = g_tty_str[index][minor]; - struct tty_port *tty_port; + struct gdm *gdm; - if (!GDM_TTY_READY(tty_str)) { + mutex_lock(&gdm_table_lock); + gdm = gdm_table[index][minor]; + mutex_unlock(&gdm_table_lock); + + if (!GDM_TTY_READY(gdm)) { if (complete == RECV_PACKET_PROCESS_COMPLETE) - gdm_tty_recv(tty_str, gdm_tty_recv_complete); + gdm_tty_recv(gdm, gdm_tty_recv_complete); return TO_HOST_PORT_CLOSE; } - if (!data || !len) - goto complete_routine; - - tty_port = &tty_str->port; - - if (tty_buffer_request_room(tty_port, len) == len) { - tty_insert_flip_string(tty_port, data, len); - tty_flip_buffer_push(tty_port); - } else { - return TO_HOST_BUFFER_REQUEST_FAIL; + if (data && len) { + if (tty_buffer_request_room(&gdm->port, len) == len) { + tty_insert_flip_string(&gdm->port, data, len); + tty_flip_buffer_push(&gdm->port); + } else { + return TO_HOST_BUFFER_REQUEST_FAIL; + } } -complete_routine: if (complete == RECV_PACKET_PROCESS_COMPLETE) - gdm_tty_recv(tty_str, gdm_tty_recv_complete); + gdm_tty_recv(gdm, gdm_tty_recv_complete); return 0; } static void gdm_tty_send_complete(void *arg) { - struct tty_str *tty_str = (struct tty_str *)arg; - struct tty_struct *tty; + struct gdm *gdm = (struct gdm *)arg; - if (!GDM_TTY_READY(tty_str)) + if (!GDM_TTY_READY(gdm)) return; - tty = tty_port_tty_get(&tty_str->port); - tty_wakeup(tty); - tty_kref_put(tty); + tty_port_tty_wakeup(&gdm->port); } static int gdm_tty_write(struct tty_struct *tty, const unsigned char *buf, int len) { - struct tty_str *tty_str = tty->driver_data; + struct gdm *gdm = tty->driver_data; int remain = len; int sent_len = 0; int sending_len = 0; - if (!GDM_TTY_READY(tty_str)) + if (!GDM_TTY_READY(gdm)) return -ENODEV; if (!len) @@ -187,12 +184,12 @@ static int gdm_tty_write(struct tty_struct *tty, const unsigned char *buf, int l while (1) { sending_len = remain > MUX_TX_MAX_SIZE ? MUX_TX_MAX_SIZE : remain; - gdm_tty_send(tty_str, + gdm_tty_send(gdm, (void *)(buf+sent_len), sending_len, - tty_str->tty_drv_index, + gdm->index, gdm_tty_send_complete, - tty_str + gdm ); sent_len += sending_len; remain -= sending_len; @@ -205,131 +202,113 @@ static int gdm_tty_write(struct tty_struct *tty, const unsigned char *buf, int l static int gdm_tty_write_room(struct tty_struct *tty) { - struct tty_str *tty_str = tty->driver_data; + struct gdm *gdm = tty->driver_data; - if (!GDM_TTY_READY(tty_str)) + if (!GDM_TTY_READY(gdm)) return -ENODEV; return WRITE_SIZE; } -static int gdm_tty_tiocmget(struct tty_struct *tty) -{ - struct tty_str *tty_str = tty->driver_data; - - if (!GDM_TTY_READY(tty_str)) - return -ENODEV; - - return (0 & ACM_CTRL_DTR ? TIOCM_DTR : 0) | - (0 & ACM_CTRL_RTS ? TIOCM_RTS : 0) | - (0 & ACM_CTRL_DSR ? TIOCM_DSR : 0) | - (0 & ACM_CTRL_RI ? TIOCM_RI : 0) | - (0 & ACM_CTRL_DCD ? TIOCM_CD : 0) | - TIOCM_CTS; -} - -static int gdm_tty_tiocmset(struct tty_struct *tty, unsigned int set, unsigned int clear) +int register_lte_tty_device(struct tty_dev *tty_dev, struct device *device) { - struct tty_str *tty_str = tty->driver_data; + struct gdm *gdm; + int i; + int j; - if (!GDM_TTY_READY(tty_str)) - return -ENODEV; + for (i = 0; i < TTY_MAX_COUNT; i++) { - return 1; -} + gdm = kmalloc(sizeof(struct gdm), GFP_KERNEL); + if (!gdm) + return -ENOMEM; -int register_lte_tty_device(struct tty_dev *tty_dev, struct device *dev) -{ - struct tty_str *tty_str; - int i, j; + mutex_lock(&gdm_table_lock); - for (i = 0; i < TTY_MAX_COUNT; i++) { for (j = 0; j < GDM_TTY_MINOR; j++) { - if (!g_tty_str[i][j]) + if (!gdm_table[i][j]) break; } if (j == GDM_TTY_MINOR) { - tty_dev->minor[i] = j; - return -1; + tty_dev->minor[i] = GDM_TTY_MINOR; + mutex_unlock(&gdm_table_lock); + return -EINVAL; } - tty_str = kmalloc(sizeof(struct tty_str), GFP_KERNEL); - if (!tty_str) - return -ENOMEM; + gdm_table[i][j] = gdm; - g_tty_str[i][j] = tty_str; + mutex_unlock(&gdm_table_lock); - tty_str->tty_dev = tty_dev; - tty_str->tty_drv_index = i; tty_dev->minor[i] = j; - tty_port_init(&tty_str->port); - tty_str->port.ops = &gdm_tty_port_ops; - if (strcmp(DEVICE_STRING[i], "GCT-ATC") != 0) - dev = NULL; - tty_register_device(g_tty_drv[i], j, dev); - } + tty_port_init(&gdm->port); + gdm->port.ops = &gdm_port_ops; + gdm->index = i; + gdm->minor = j; + gdm->tty_dev = tty_dev; - acm_set_comm_feature(tty_str, 1); + tty_port_register_device(&gdm->port, gdm_driver[i], j, device); + } for (i = 0; i < MAX_ISSUE_NUM; i++) - gdm_tty_recv(tty_str, gdm_tty_recv_complete); + gdm_tty_recv(gdm, gdm_tty_recv_complete); return 0; } void unregister_lte_tty_device(struct tty_dev *tty_dev) { - struct tty_str *tty_str; + struct gdm *gdm; + struct tty_struct *tty; int i; + int j; for (i = 0; i < TTY_MAX_COUNT; i++) { - if (tty_dev->minor[i] >= GDM_TTY_MINOR) - continue; - tty_str = g_tty_str[i][tty_dev->minor[i]]; - if (!tty_str) + j = tty_dev->minor[i]; + + if (j >= GDM_TTY_MINOR) continue; - tty_str->tty_dev = NULL; + mutex_lock(&gdm_table_lock); + gdm = gdm_table[i][j]; + mutex_unlock(&gdm_table_lock); - if (!tty_str->port.count) { - tty_unregister_device(g_tty_drv[i], tty_dev->minor[i]); - tty_port_tty_set(&tty_str->port, NULL); - kfree(tty_str); - g_tty_str[i][tty_dev->minor[i]] = NULL; + if (!gdm) + continue; + + tty = tty_port_tty_get(&gdm->port); + if (tty) { + tty_vhangup(tty); + tty_kref_put(tty); } - } -} -static void gdm_tty_set_termios(struct tty_struct *tty, struct ktermios *termios_old) -{ - return; + tty_unregister_device(gdm_driver[i], j); + tty_port_put(&gdm->port); + + } } static const struct tty_operations gdm_tty_ops = { - .open = gdm_tty_open, - .close = gdm_tty_close, - .write = gdm_tty_write, - .write_room = gdm_tty_write_room, - .tiocmget = gdm_tty_tiocmget, - .tiocmset = gdm_tty_tiocmset, - .set_termios = gdm_tty_set_termios, + .install = gdm_tty_install, + .open = gdm_tty_open, + .close = gdm_tty_close, + .cleanup = gdm_tty_cleanup, + .hangup = gdm_tty_hangup, + .write = gdm_tty_write, + .write_room = gdm_tty_write_room, }; int register_lte_tty_driver(void) { - struct tty_driver *tty_driver = NULL; + struct tty_driver *tty_driver; int i; int ret; for (i = 0; i < TTY_MAX_COUNT; i++) { tty_driver = alloc_tty_driver(GDM_TTY_MINOR); - if (!tty_driver) { - pr_err("alloc_tty_driver fail\n"); + if (!tty_driver) return -ENOMEM; - } tty_driver->owner = THIS_MODULE; tty_driver->driver_name = DRIVER_STRING[i]; @@ -344,8 +323,12 @@ int register_lte_tty_driver(void) tty_set_operations(tty_driver, &gdm_tty_ops); ret = tty_register_driver(tty_driver); + if (ret) { + put_tty_driver(tty_driver); + return ret; + } - g_tty_drv[i] = tty_driver; + gdm_driver[i] = tty_driver; } return ret; @@ -357,10 +340,11 @@ void unregister_lte_tty_driver(void) int i; for (i = 0; i < TTY_MAX_COUNT; i++) { - tty_driver = g_tty_drv[i]; + tty_driver = gdm_driver[i]; if (tty_driver) { tty_unregister_driver(tty_driver); put_tty_driver(tty_driver); } } } + diff --git a/drivers/staging/gdm724x/gdm_tty.h b/drivers/staging/gdm724x/gdm_tty.h index a75be1df01001..64db5e63e3890 100644 --- a/drivers/staging/gdm724x/gdm_tty.h +++ b/drivers/staging/gdm724x/gdm_tty.h @@ -44,10 +44,11 @@ struct tty_dev { u8 minor[2]; }; -struct tty_str { +struct gdm { struct tty_dev *tty_dev; - int tty_drv_index; struct tty_port port; + unsigned int index; + unsigned int minor; }; int register_lte_tty_driver(void); -- GitLab From bf0373f1c61dd0e0356aeed4e51786e052bb4de8 Mon Sep 17 00:00:00 2001 From: Won Kang Date: Fri, 16 Aug 2013 13:13:44 +0900 Subject: [PATCH 684/942] staging: gdm7240: a TTY rewrite according to the latest TTY APIs Fixed mis-use of mutex for gdm_table. gdm_table is refered to only inside tty_install and port destrcut, and usb callbacks use internal reference which was saved during urb submission Signed-off-by: Won Kang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm724x/gdm_mux.c | 9 +++---- drivers/staging/gdm724x/gdm_mux.h | 14 +++++++--- drivers/staging/gdm724x/gdm_tty.c | 45 +++++++++++++------------------ drivers/staging/gdm724x/gdm_tty.h | 33 +++++++++++++++-------- 4 files changed, 56 insertions(+), 45 deletions(-) diff --git a/drivers/staging/gdm724x/gdm_mux.c b/drivers/staging/gdm724x/gdm_mux.c index b630babb57af6..9e217ff3b15b2 100644 --- a/drivers/staging/gdm724x/gdm_mux.c +++ b/drivers/staging/gdm724x/gdm_mux.c @@ -25,7 +25,6 @@ #include #include "gdm_mux.h" -#include "gdm_tty.h" struct workqueue_struct *mux_rx_wq; @@ -196,7 +195,7 @@ static int up_to_host(struct mux_rx *r) ret = r->callback(mux_header->data, payload_size, index, - mux_dev->minor[index], + mux_dev->tty_dev, RECV_PACKET_PROCESS_CONTINUE ); if (ret == TO_HOST_BUFFER_REQUEST_FAIL) { @@ -209,7 +208,7 @@ static int up_to_host(struct mux_rx *r) ret = r->callback(NULL, 0, index, - mux_dev->minor[index], + mux_dev->tty_dev, RECV_PACKET_PROCESS_COMPLETE ); break; @@ -283,7 +282,7 @@ static void gdm_mux_rcv_complete(struct urb *urb) } static int gdm_mux_recv(void *priv_dev, - int (*cb)(void *data, int len, int tty_index, int minor, int complete) + int (*cb)(void *data, int len, int tty_index, struct tty_dev *tty_dev, int complete) ) { struct mux_dev *mux_dev = priv_dev; @@ -562,7 +561,7 @@ static int gdm_mux_probe(struct usb_interface *intf, const struct usb_device_id goto out; } for (i = 0; i < TTY_MAX_COUNT; i++) - mux_dev->minor[i] = tty_dev->minor[i]; + mux_dev->tty_dev = tty_dev; out: if (ret < 0) { diff --git a/drivers/staging/gdm724x/gdm_mux.h b/drivers/staging/gdm724x/gdm_mux.h index d5b0b54dd539b..0163b243d3e05 100644 --- a/drivers/staging/gdm724x/gdm_mux.h +++ b/drivers/staging/gdm724x/gdm_mux.h @@ -18,6 +18,8 @@ #include #include +#include "gdm_tty.h" + #define PM_NORMAL 0 #define PM_SUSPEND 1 @@ -57,7 +59,10 @@ struct mux_rx { void *mux_dev; u32 offset; u32 len; - int (*callback)(void *data, int len, int tty_index, int minor, + int (*callback)(void *data, + int len, + int tty_index, + struct tty_dev *tty_dev, int complete); }; @@ -78,10 +83,13 @@ struct mux_dev { struct delayed_work work_rx; struct usb_interface *intf; int usb_state; - int (*rx_cb)(void *data, int len, int tty_index, int minor, + int (*rx_cb)(void *data, + int len, + int tty_index, + struct tty_dev *tty_dev, int complete); spinlock_t write_lock; - u8 minor[2]; + struct tty_dev *tty_dev; }; #endif /* _GDM_MUX_H_ */ diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c index 5bcf88224e903..c1530b76cd860 100644 --- a/drivers/staging/gdm724x/gdm_tty.c +++ b/drivers/staging/gdm724x/gdm_tty.c @@ -89,19 +89,22 @@ static int gdm_tty_install(struct tty_driver *driver, struct tty_struct *tty) mutex_lock(&gdm_table_lock); gdm = gdm_table[i][j]; - mutex_unlock(&gdm_table_lock); - if (gdm == NULL) + if (gdm == NULL) { + mutex_unlock(&gdm_table_lock); return -ENODEV; + } tty_port_get(&gdm->port); ret = tty_standard_install(driver, tty); if (ret) { tty_port_put(&gdm->port); + mutex_unlock(&gdm_table_lock); return ret; } tty->driver_data = gdm; + mutex_unlock(&gdm_table_lock); return 0; } @@ -130,14 +133,13 @@ static void gdm_tty_close(struct tty_struct *tty, struct file *filp) tty_port_close(&gdm->port, tty, filp); } -static int gdm_tty_recv_complete(void *data, int len, int index, int minor, int complete) +static int gdm_tty_recv_complete(void *data, + int len, + int index, + struct tty_dev *tty_dev, + int complete) { - struct gdm *gdm; - - mutex_lock(&gdm_table_lock); - gdm = gdm_table[index][minor]; - mutex_unlock(&gdm_table_lock); - + struct gdm *gdm = tty_dev->gdm[index]; if (!GDM_TTY_READY(gdm)) { if (complete == RECV_PACKET_PROCESS_COMPLETE) gdm_tty_recv(gdm, gdm_tty_recv_complete); @@ -223,31 +225,29 @@ int register_lte_tty_device(struct tty_dev *tty_dev, struct device *device) return -ENOMEM; mutex_lock(&gdm_table_lock); - for (j = 0; j < GDM_TTY_MINOR; j++) { if (!gdm_table[i][j]) break; } if (j == GDM_TTY_MINOR) { - tty_dev->minor[i] = GDM_TTY_MINOR; + kfree(gdm); mutex_unlock(&gdm_table_lock); return -EINVAL; } gdm_table[i][j] = gdm; - mutex_unlock(&gdm_table_lock); - tty_dev->minor[i] = j; - + tty_dev->gdm[i] = gdm; tty_port_init(&gdm->port); + gdm->port.ops = &gdm_port_ops; gdm->index = i; gdm->minor = j; gdm->tty_dev = tty_dev; - tty_port_register_device(&gdm->port, gdm_driver[i], j, device); + tty_port_register_device(&gdm->port, gdm_driver[i], gdm->minor, device); } for (i = 0; i < MAX_ISSUE_NUM; i++) @@ -261,31 +261,24 @@ void unregister_lte_tty_device(struct tty_dev *tty_dev) struct gdm *gdm; struct tty_struct *tty; int i; - int j; for (i = 0; i < TTY_MAX_COUNT; i++) { - - j = tty_dev->minor[i]; - - if (j >= GDM_TTY_MINOR) + gdm = tty_dev->gdm[i]; + if (!gdm) continue; mutex_lock(&gdm_table_lock); - gdm = gdm_table[i][j]; + gdm_table[gdm->index][gdm->minor] = NULL; mutex_unlock(&gdm_table_lock); - if (!gdm) - continue; - tty = tty_port_tty_get(&gdm->port); if (tty) { tty_vhangup(tty); tty_kref_put(tty); } - tty_unregister_device(gdm_driver[i], j); + tty_unregister_device(gdm_driver[i], gdm->minor); tty_port_put(&gdm->port); - } } diff --git a/drivers/staging/gdm724x/gdm_tty.h b/drivers/staging/gdm724x/gdm_tty.h index 64db5e63e3890..297438b4ddcbc 100644 --- a/drivers/staging/gdm724x/gdm_tty.h +++ b/drivers/staging/gdm724x/gdm_tty.h @@ -33,17 +33,6 @@ enum RECV_PACKET_PROCESS { RECV_PACKET_PROCESS_CONTINUE = 1, }; -struct tty_dev { - void *priv_dev; - int (*send_func)(void *priv_dev, void *data, int len, int tty_index, - void (*cb)(void *cb_data), void *cb_data); - int (*recv_func)(void *priv_dev, int (*cb)(void *data, int len, - int tty_index, int minor, int complete)); - int (*send_control)(void *priv_dev, int request, int value, void *data, - int len); - u8 minor[2]; -}; - struct gdm { struct tty_dev *tty_dev; struct tty_port port; @@ -51,6 +40,28 @@ struct gdm { unsigned int minor; }; +struct tty_dev { + void *priv_dev; + int (*send_func)(void *priv_dev, + void *data, + int len, + int tty_index, + void (*cb)(void *cb_data), + void *cb_data); + int (*recv_func)(void *priv_dev, + int (*cb)(void *data, + int len, + int tty_index, + struct tty_dev *tty_dev, + int complete)); + int (*send_control)(void *priv_dev, + int request, + int value, + void *data, + int len); + struct gdm *gdm[2]; +}; + int register_lte_tty_driver(void); void unregister_lte_tty_driver(void); int register_lte_tty_device(struct tty_dev *tty_dev, struct device *dev); -- GitLab From ecc837accaa76cb0378d5db4e8dac03cb37d0f11 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Mon, 19 Aug 2013 14:46:25 +0530 Subject: [PATCH 685/942] staging: dgrp: add __init/__exit macros add __init/__exit macros to related init/cleanup functions. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgrp/dgrp_driver.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/staging/dgrp/dgrp_driver.c b/drivers/staging/dgrp/dgrp_driver.c index e456dc6cb367c..08eedf0867e6c 100644 --- a/drivers/staging/dgrp/dgrp_driver.c +++ b/drivers/staging/dgrp/dgrp_driver.c @@ -52,19 +52,12 @@ MODULE_PARM_DESC(register_prdevices, "Turn on/off registering transparent print module_param_named(pollrate, dgrp_poll_tick, int, 0644); MODULE_PARM_DESC(pollrate, "Poll interval in ms"); -/* Driver load/unload functions */ -static int dgrp_init_module(void); -static void dgrp_cleanup_module(void); - -module_init(dgrp_init_module); -module_exit(dgrp_cleanup_module); - /* * init_module() * * Module load. This is where it all starts. */ -static int dgrp_init_module(void) +static int __init dgrp_init_module(void) { int ret; @@ -89,7 +82,7 @@ static int dgrp_init_module(void) /* * Module unload. This is where it all ends. */ -static void dgrp_cleanup_module(void) +static void __exit dgrp_cleanup_module(void) { struct nd_struct *nd, *next; @@ -108,3 +101,6 @@ static void dgrp_cleanup_module(void) kfree(nd); } } + +module_init(dgrp_init_module); +module_exit(dgrp_cleanup_module); -- GitLab From 9379fd547ea81378791433fd8de44eda788d62d6 Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Mon, 19 Aug 2013 13:33:48 +0900 Subject: [PATCH 686/942] staging: xillybus: Fix typo in comment Correct spelling typo in comments. Signed-off-by: Masanari Iida Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xillybus/xillybus_core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/xillybus/xillybus_core.c b/drivers/staging/xillybus/xillybus_core.c index 3d7471a72077a..efc56987a60b5 100644 --- a/drivers/staging/xillybus/xillybus_core.c +++ b/drivers/staging/xillybus/xillybus_core.c @@ -1876,7 +1876,7 @@ static loff_t xillybus_llseek(struct file *filp, loff_t offset, int whence) /* * Take both mutexes not allowing interrupts, since it seems like * common applications don't expect an -EINTR here. Besides, multiple - * access to a single file desriptor on seekable devices is a mess + * access to a single file descriptor on seekable devices is a mess * anyhow. */ @@ -2171,8 +2171,8 @@ int xillybus_endpoint_discovery(struct xilly_endpoint *endpoint) INIT_LIST_HEAD(&tmpmem.to_unmap); /* - * Writing the value 0x00000001 to Endianess register signals which - * endianess this processor is using, so the FPGA can swap words as + * Writing the value 0x00000001 to Endianness register signals which + * endianness this processor is using, so the FPGA can swap words as * necessary. */ -- GitLab From 85d0b7809b912b566c3d19c5c96e044c0698ce2d Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Sun, 18 Aug 2013 21:40:02 -0300 Subject: [PATCH 687/942] imx-drm: ipu-di: Check the return value from clk_prepare_enable() clk_prepare_enable() may fail, so let's check its return value and propagate it in the case of error. Signed-off-by: Fabio Estevam Acked-by: Sascha Hauer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/imx-drm/ipu-v3/ipu-di.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-di.c b/drivers/staging/imx-drm/ipu-v3/ipu-di.c index 0b6806e2069c3..948a49b289ef1 100644 --- a/drivers/staging/imx-drm/ipu-v3/ipu-di.c +++ b/drivers/staging/imx-drm/ipu-v3/ipu-di.c @@ -654,7 +654,9 @@ EXPORT_SYMBOL_GPL(ipu_di_init_sync_panel); int ipu_di_enable(struct ipu_di *di) { - clk_prepare_enable(di->clk_di_pixel); + int ret = clk_prepare_enable(di->clk_di_pixel); + if (ret) + return ret; ipu_module_enable(di->ipu, di->module); -- GitLab From bc627387a9518cdbb6beb0ceeb4e9bd0ce4f9ab7 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Sun, 18 Aug 2013 21:40:03 -0300 Subject: [PATCH 688/942] imx-drm: imx-ldb: Add MODULE_ALIAS() Add MODULE_ALIAS, so that auto module loading can work. Signed-off-by: Fabio Estevam Acked-by: Sascha Hauer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/imx-drm/imx-ldb.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/imx-drm/imx-ldb.c b/drivers/staging/imx-drm/imx-ldb.c index bb7da0e4dc038..af733ea485656 100644 --- a/drivers/staging/imx-drm/imx-ldb.c +++ b/drivers/staging/imx-drm/imx-ldb.c @@ -623,3 +623,4 @@ module_platform_driver(imx_ldb_driver); MODULE_DESCRIPTION("i.MX LVDS driver"); MODULE_AUTHOR("Sascha Hauer, Pengutronix"); MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:" DRIVER_NAME); -- GitLab From 52db752c3de5570292d9b86332cb2b5e0e00a1af Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Sun, 18 Aug 2013 21:40:04 -0300 Subject: [PATCH 689/942] imx-drm: imx-tve: Add MODULE_ALIAS() Add MODULE_ALIAS, so that auto module loading can work. Signed-off-by: Fabio Estevam Acked-by: Sascha Hauer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/imx-drm/imx-tve.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/imx-drm/imx-tve.c b/drivers/staging/imx-drm/imx-tve.c index dba1b47b3bdaf..3c024b40b4f88 100644 --- a/drivers/staging/imx-drm/imx-tve.c +++ b/drivers/staging/imx-drm/imx-tve.c @@ -749,3 +749,4 @@ module_platform_driver(imx_tve_driver); MODULE_DESCRIPTION("i.MX Television Encoder driver"); MODULE_AUTHOR("Philipp Zabel, Pengutronix"); MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:imx-tve"); -- GitLab From b2da05ff4797c5771316bfa47b55e039a1319714 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Sun, 18 Aug 2013 21:40:05 -0300 Subject: [PATCH 690/942] imx-drm: parallel-display: Add MODULE_ALIAS() Add MODULE_ALIAS, so that auto module loading can work. Signed-off-by: Fabio Estevam Acked-by: Sascha Hauer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/imx-drm/parallel-display.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/imx-drm/parallel-display.c b/drivers/staging/imx-drm/parallel-display.c index cea9f14fff4a1..24aa9beedcfb6 100644 --- a/drivers/staging/imx-drm/parallel-display.c +++ b/drivers/staging/imx-drm/parallel-display.c @@ -272,3 +272,4 @@ module_platform_driver(imx_pd_driver); MODULE_DESCRIPTION("i.MX parallel display driver"); MODULE_AUTHOR("Sascha Hauer, Pengutronix"); MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:imx-parallel-display"); -- GitLab From ce9c1cef9b4ea4b5a323b7e84a4b92f6b5350209 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Sun, 18 Aug 2013 21:40:06 -0300 Subject: [PATCH 691/942] imx-drm: ipuv3-crtc: Add MODULE_ALIAS() Add MODULE_ALIAS, so that auto module loading can work. Signed-off-by: Fabio Estevam Acked-by: Sascha Hauer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/imx-drm/ipuv3-crtc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/imx-drm/ipuv3-crtc.c b/drivers/staging/imx-drm/ipuv3-crtc.c index 9176a8171e6fc..bae0e2e81916d 100644 --- a/drivers/staging/imx-drm/ipuv3-crtc.c +++ b/drivers/staging/imx-drm/ipuv3-crtc.c @@ -562,3 +562,4 @@ module_platform_driver(ipu_drm_driver); MODULE_AUTHOR("Sascha Hauer "); MODULE_DESCRIPTION(DRIVER_DESC); MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:imx-ipuv3-crtc"); -- GitLab From 6398a59becb56e44df4f8cd600bb0efed1827e9b Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Fri, 16 Aug 2013 21:26:55 +0100 Subject: [PATCH 692/942] staging: vt6656: desc.h: Move typedef tagSRrvTime_gRTS to new structure in rxtx.h To new structure. typedef struct tagSRrvTime_gRTS -> struct vnt_rrv_time_rts This is only needed by rxtc.c so moved to rxtx.h and will eventually form part of the structure of struct vnt_tx_buffer. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/desc.h | 12 ------------ drivers/staging/vt6656/rxtx.c | 30 ++++++++++++++++++------------ drivers/staging/vt6656/rxtx.h | 10 ++++++++++ 3 files changed, 28 insertions(+), 24 deletions(-) diff --git a/drivers/staging/vt6656/desc.h b/drivers/staging/vt6656/desc.h index d770a78e37dec..89b580db22019 100644 --- a/drivers/staging/vt6656/desc.h +++ b/drivers/staging/vt6656/desc.h @@ -146,18 +146,6 @@ /* * RsvTime buffer header */ -typedef struct tagSRrvTime_gRTS { - u16 wRTSTxRrvTime_ba; - u16 wRTSTxRrvTime_aa; - u16 wRTSTxRrvTime_bb; - u16 wReserved; - u16 wTxRrvTime_b; - u16 wTxRrvTime_a; -} __attribute__ ((__packed__)) -SRrvTime_gRTS, *PSRrvTime_gRTS; - -typedef const SRrvTime_gRTS *PCSRrvTime_gRTS; - typedef struct tagSRrvTime_gCTS { u16 wCTSTxRrvTime_ba; u16 wReserved; diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index d9827b31cfef9..c9dceae646a99 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -919,7 +919,8 @@ static void s_vGenerateTxParameter(struct vnt_private *pDevice, if (pvRTS != NULL) { //RTS_need //Fill RsvTime if (pvRrvTime) { - PSRrvTime_gRTS pBuf = (PSRrvTime_gRTS)pvRrvTime; + struct vnt_rrv_time_rts *pBuf = + (struct vnt_rrv_time_rts *)pvRrvTime; pBuf->wRTSTxRrvTime_aa = cpu_to_le16((u16)s_uGetRTSCTSRsvTime(pDevice, 2, byPktType, cbFrameSize, wCurrentRate));//2:RTSTxRrvTime_aa, 1:2.4GHz pBuf->wRTSTxRrvTime_ba = cpu_to_le16((u16)s_uGetRTSCTSRsvTime(pDevice, 1, byPktType, cbFrameSize, wCurrentRate));//1:RTSTxRrvTime_ba, 1:2.4GHz pBuf->wRTSTxRrvTime_bb = cpu_to_le16((u16)s_uGetRTSCTSRsvTime(pDevice, 0, byPktType, cbFrameSize, wCurrentRate));//0:RTSTxRrvTime_bb, 1:2.4GHz @@ -1149,15 +1150,17 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) {//802.11g packet if (byFBOption == AUTO_FB_NONE) { if (bRTS == true) {//RTS_need - pvRrvTime = (PSRrvTime_gRTS) (pbyTxBufferAddr + wTxBufSize); - pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gRTS)); + pvRrvTime = (struct vnt_rrv_time_rts *) + (pbyTxBufferAddr + wTxBufSize); + pMICHDR = (PSMICHDRHead)(pbyTxBufferAddr + wTxBufSize + + sizeof(struct vnt_rrv_time_rts)); pvRTS = (struct vnt_rts_g *) (pbyTxBufferAddr + wTxBufSize + - sizeof(SRrvTime_gRTS) + cbMICHDR); + sizeof(struct vnt_rrv_time_rts) + cbMICHDR); pvCTS = NULL; pvTxDataHd = (PSTxDataHead_g) (pbyTxBufferAddr + wTxBufSize + - sizeof(SRrvTime_gRTS) + cbMICHDR + + sizeof(struct vnt_rrv_time_rts) + cbMICHDR + sizeof(struct vnt_rts_g)); - cbHeaderLength = wTxBufSize + sizeof(SRrvTime_gRTS) + + cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_rts) + cbMICHDR + sizeof(struct vnt_rts_g) + sizeof(STxDataHead_g); } @@ -1176,16 +1179,19 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, } else { // Auto Fall Back if (bRTS == true) {//RTS_need - pvRrvTime = (PSRrvTime_gRTS) (pbyTxBufferAddr + wTxBufSize); - pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gRTS)); + pvRrvTime = (struct vnt_rrv_time_rts *)(pbyTxBufferAddr + + wTxBufSize); + pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + + sizeof(struct vnt_rrv_time_rts)); pvRTS = (struct vnt_rts_g_fb *) (pbyTxBufferAddr + wTxBufSize + - sizeof(SRrvTime_gRTS) + cbMICHDR); + sizeof(struct vnt_rrv_time_rts) + cbMICHDR); pvCTS = NULL; pvTxDataHd = (PSTxDataHead_g_FB) (pbyTxBufferAddr + wTxBufSize + - sizeof(SRrvTime_gRTS) + cbMICHDR + + sizeof(struct vnt_rrv_time_rts) + cbMICHDR + sizeof(struct vnt_rts_g_fb)); - cbHeaderLength = wTxBufSize + sizeof(SRrvTime_gRTS) + cbMICHDR + - sizeof(struct vnt_rts_g_fb) + sizeof(STxDataHead_g_FB); + cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_rts) + + cbMICHDR + sizeof(struct vnt_rts_g_fb) + + sizeof(STxDataHead_g_FB); } else if (bRTS == false) { //RTS_needless pvRrvTime = (PSRrvTime_gCTS) (pbyTxBufferAddr + wTxBufSize); diff --git a/drivers/staging/vt6656/rxtx.h b/drivers/staging/vt6656/rxtx.h index 8fd5be175e6b0..8afade2d51183 100644 --- a/drivers/staging/vt6656/rxtx.h +++ b/drivers/staging/vt6656/rxtx.h @@ -32,6 +32,16 @@ #include "device.h" #include "wcmd.h" +/* RsvTime buffer header */ +struct vnt_rrv_time_rts { + u16 wRTSTxRrvTime_ba; + u16 wRTSTxRrvTime_aa; + u16 wRTSTxRrvTime_bb; + u16 wReserved; + u16 wTxRrvTime_b; + u16 wTxRrvTime_a; +} __packed; + /* RTS buffer header */ struct vnt_rts_g { u8 bySignalField_b; -- GitLab From 4f990057bc8fa4d1a2ba98ec238bb0e709b190f5 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Fri, 16 Aug 2013 23:38:57 +0100 Subject: [PATCH 693/942] staging: vt6656: desc.h: Move typedef struct tagSRrvTime_gCTS to new structure in rxtx.h To new structure. typedef struct tagSRrvTime_gCTS -> struct vnt_rrv_time_cts This is only needed by rxtc.c so moved to rxtx.h and will eventually form part of the structure of struct vnt_tx_buffer. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/desc.h | 10 ------- drivers/staging/vt6656/rxtx.c | 53 ++++++++++++++++++++--------------- drivers/staging/vt6656/rxtx.h | 7 +++++ 3 files changed, 37 insertions(+), 33 deletions(-) diff --git a/drivers/staging/vt6656/desc.h b/drivers/staging/vt6656/desc.h index 89b580db22019..ae0ce51d5a18e 100644 --- a/drivers/staging/vt6656/desc.h +++ b/drivers/staging/vt6656/desc.h @@ -146,16 +146,6 @@ /* * RsvTime buffer header */ -typedef struct tagSRrvTime_gCTS { - u16 wCTSTxRrvTime_ba; - u16 wReserved; - u16 wTxRrvTime_b; - u16 wTxRrvTime_a; -} __attribute__ ((__packed__)) -SRrvTime_gCTS, *PSRrvTime_gCTS; - -typedef const SRrvTime_gCTS *PCSRrvTime_gCTS; - typedef struct tagSRrvTime_ab { u16 wRTSTxRrvTime; u16 wTxRrvTime; diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index c9dceae646a99..9c52c313aba49 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -934,7 +934,8 @@ static void s_vGenerateTxParameter(struct vnt_private *pDevice, //Fill RsvTime if (pvRrvTime) { - PSRrvTime_gCTS pBuf = (PSRrvTime_gCTS)pvRrvTime; + struct vnt_rrv_time_cts *pBuf = + (struct vnt_rrv_time_cts *)pvRrvTime; pBuf->wTxRrvTime_a = cpu_to_le16((u16)s_uGetTxRsvTime(pDevice, byPktType, cbFrameSize, wCurrentRate, bNeedACK));//2.4G OFDM pBuf->wTxRrvTime_b = cpu_to_le16((u16)s_uGetTxRsvTime(pDevice, PK_TYPE_11B, cbFrameSize, pDevice->byTopCCKBasicRate, bNeedACK));//1:CCK pBuf->wCTSTxRrvTime_ba = cpu_to_le16((u16)s_uGetRTSCTSRsvTime(pDevice, 3, byPktType, cbFrameSize, wCurrentRate));//3:CTSTxRrvTime_Ba, 1:2.4GHz @@ -1165,16 +1166,19 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, sizeof(STxDataHead_g); } else { //RTS_needless - pvRrvTime = (PSRrvTime_gCTS) (pbyTxBufferAddr + wTxBufSize); - pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gCTS)); + pvRrvTime = (struct vnt_rrv_time_cts *) + (pbyTxBufferAddr + wTxBufSize); + pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + + sizeof(struct vnt_rrv_time_cts)); pvRTS = NULL; pvCTS = (struct vnt_cts *) (pbyTxBufferAddr + wTxBufSize + - sizeof(SRrvTime_gCTS) + cbMICHDR); + sizeof(struct vnt_rrv_time_cts) + cbMICHDR); pvTxDataHd = (PSTxDataHead_g) (pbyTxBufferAddr + wTxBufSize + - sizeof(SRrvTime_gCTS) + cbMICHDR + + sizeof(struct vnt_rrv_time_cts) + cbMICHDR + sizeof(struct vnt_cts)); - cbHeaderLength = wTxBufSize + sizeof(SRrvTime_gCTS) + cbMICHDR + - sizeof(struct vnt_cts) + sizeof(STxDataHead_g); + cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_cts) + + cbMICHDR + sizeof(struct vnt_cts) + + sizeof(STxDataHead_g); } } else { // Auto Fall Back @@ -1194,15 +1198,17 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, sizeof(STxDataHead_g_FB); } else if (bRTS == false) { //RTS_needless - pvRrvTime = (PSRrvTime_gCTS) (pbyTxBufferAddr + wTxBufSize); - pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gCTS)); + pvRrvTime = (struct vnt_rrv_time_cts *) + (pbyTxBufferAddr + wTxBufSize); + pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + + sizeof(struct vnt_rrv_time_cts)); pvRTS = NULL; pvCTS = (struct vnt_cts_fb *) (pbyTxBufferAddr + wTxBufSize + - sizeof(SRrvTime_gCTS) + cbMICHDR); + sizeof(struct vnt_rrv_time_cts) + cbMICHDR); pvTxDataHd = (PSTxDataHead_g_FB) (pbyTxBufferAddr + - wTxBufSize + sizeof(SRrvTime_gCTS) + cbMICHDR + - sizeof(struct vnt_cts_fb)); - cbHeaderLength = wTxBufSize + sizeof(SRrvTime_gCTS) + + wTxBufSize + sizeof(struct vnt_rrv_time_cts) + + cbMICHDR + sizeof(struct vnt_cts_fb)); + cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_cts) + cbMICHDR + sizeof(struct vnt_cts_fb) + sizeof(STxDataHead_g_FB); } @@ -1659,14 +1665,14 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice, //Set RrvTime/RTS/CTS Buffer if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) {//802.11g packet - pvRrvTime = (PSRrvTime_gCTS) (pbyTxBufferAddr + wTxBufSize); + pvRrvTime = (struct vnt_rrv_time_cts *) (pbyTxBufferAddr + wTxBufSize); pMICHDR = NULL; pvRTS = NULL; pCTS = (struct vnt_cts *) (pbyTxBufferAddr + wTxBufSize + - sizeof(SRrvTime_gCTS)); + sizeof(struct vnt_rrv_time_cts)); pvTxDataHd = (PSTxDataHead_g) (pbyTxBufferAddr + wTxBufSize + - sizeof(SRrvTime_gCTS) + sizeof(struct vnt_cts)); - cbHeaderSize = wTxBufSize + sizeof(SRrvTime_gCTS) + + sizeof(struct vnt_rrv_time_cts) + sizeof(struct vnt_cts)); + cbHeaderSize = wTxBufSize + sizeof(struct vnt_rrv_time_cts) + sizeof(struct vnt_cts) + sizeof(STxDataHead_g); } else { // 802.11a/b packet @@ -2061,15 +2067,16 @@ void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb) //the rest of pTxBufHead->wFragCtl:FragTyp will be set later in s_vFillFragParameter() if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) {//802.11g packet - - pvRrvTime = (PSRrvTime_gCTS) (pbyTxBufferAddr + wTxBufSize); - pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_gCTS)); + pvRrvTime = (struct vnt_rrv_time_cts *) (pbyTxBufferAddr + wTxBufSize); + pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + + sizeof(struct vnt_rrv_time_cts)); pvRTS = NULL; pvCTS = (struct vnt_cts *) (pbyTxBufferAddr + wTxBufSize + - sizeof(SRrvTime_gCTS) + cbMICHDR); + sizeof(struct vnt_rrv_time_cts) + cbMICHDR); pvTxDataHd = (PSTxDataHead_g) (pbyTxBufferAddr + wTxBufSize + - sizeof(SRrvTime_gCTS) + cbMICHDR + sizeof(struct vnt_cts)); - cbHeaderSize = wTxBufSize + sizeof(SRrvTime_gCTS) + cbMICHDR + + sizeof(struct vnt_rrv_time_cts) + cbMICHDR + + sizeof(struct vnt_cts)); + cbHeaderSize = wTxBufSize + sizeof(struct vnt_rrv_time_cts) + cbMICHDR + sizeof(struct vnt_cts) + sizeof(STxDataHead_g); } diff --git a/drivers/staging/vt6656/rxtx.h b/drivers/staging/vt6656/rxtx.h index 8afade2d51183..35a6b476b12be 100644 --- a/drivers/staging/vt6656/rxtx.h +++ b/drivers/staging/vt6656/rxtx.h @@ -42,6 +42,13 @@ struct vnt_rrv_time_rts { u16 wTxRrvTime_a; } __packed; +struct vnt_rrv_time_cts { + u16 wCTSTxRrvTime_ba; + u16 wReserved; + u16 wTxRrvTime_b; + u16 wTxRrvTime_a; +} __packed; + /* RTS buffer header */ struct vnt_rts_g { u8 bySignalField_b; -- GitLab From 976467d3cbcdadca343a0d9e0e2cfeeb16c48d4f Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Fri, 16 Aug 2013 23:44:04 +0100 Subject: [PATCH 694/942] staging: vt6656: desc.h remove typedef SRrvTime_ab to new structure. To new structure. typedef struct tagSRrvTime_ab -> struct vnt_rrv_time_ab This is only needed by rxtc.c so moved to rxtx.h and will eventually form part of the structure of struct vnt_tx_buffer. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/desc.h | 8 ---- drivers/staging/vt6656/rxtx.c | 85 ++++++++++++++++++++++------------- drivers/staging/vt6656/rxtx.h | 5 +++ 3 files changed, 59 insertions(+), 39 deletions(-) diff --git a/drivers/staging/vt6656/desc.h b/drivers/staging/vt6656/desc.h index ae0ce51d5a18e..c2dec3bb90555 100644 --- a/drivers/staging/vt6656/desc.h +++ b/drivers/staging/vt6656/desc.h @@ -146,14 +146,6 @@ /* * RsvTime buffer header */ -typedef struct tagSRrvTime_ab { - u16 wRTSTxRrvTime; - u16 wTxRrvTime; -} __attribute__ ((__packed__)) -SRrvTime_ab, *PSRrvTime_ab; - -typedef const SRrvTime_ab *PCSRrvTime_ab; - typedef struct tagSRrvTime_atim { u16 wCTSTxRrvTime_ba; u16 wTxRrvTime_a; diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 9c52c313aba49..b21a4963f90dd 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -949,7 +949,8 @@ static void s_vGenerateTxParameter(struct vnt_private *pDevice, if (pvRTS != NULL) {//RTS_need, non PCF mode //Fill RsvTime if (pvRrvTime) { - PSRrvTime_ab pBuf = (PSRrvTime_ab)pvRrvTime; + struct vnt_rrv_time_ab *pBuf = + (struct vnt_rrv_time_ab *)pvRrvTime; pBuf->wRTSTxRrvTime = cpu_to_le16((u16)s_uGetRTSCTSRsvTime(pDevice, 2, byPktType, cbFrameSize, wCurrentRate));//2:RTSTxRrvTime_aa, 0:5GHz pBuf->wTxRrvTime = cpu_to_le16((u16)s_uGetTxRsvTime(pDevice, byPktType, cbFrameSize, wCurrentRate, bNeedACK));//0:OFDM } @@ -959,7 +960,8 @@ static void s_vGenerateTxParameter(struct vnt_private *pDevice, else if (pvRTS == NULL) {//RTS_needless, non PCF mode //Fill RsvTime if (pvRrvTime) { - PSRrvTime_ab pBuf = (PSRrvTime_ab)pvRrvTime; + struct vnt_rrv_time_ab *pBuf = + (struct vnt_rrv_time_ab *)pvRrvTime; pBuf->wTxRrvTime = cpu_to_le16((u16)s_uGetTxRsvTime(pDevice, PK_TYPE_11A, cbFrameSize, wCurrentRate, bNeedACK)); //0:OFDM } } @@ -969,7 +971,8 @@ static void s_vGenerateTxParameter(struct vnt_private *pDevice, if ((pvRTS != NULL)) {//RTS_need, non PCF mode //Fill RsvTime if (pvRrvTime) { - PSRrvTime_ab pBuf = (PSRrvTime_ab)pvRrvTime; + struct vnt_rrv_time_ab *pBuf = + (struct vnt_rrv_time_ab *)pvRrvTime; pBuf->wRTSTxRrvTime = cpu_to_le16((u16)s_uGetRTSCTSRsvTime(pDevice, 0, byPktType, cbFrameSize, wCurrentRate));//0:RTSTxRrvTime_bb, 1:2.4GHz pBuf->wTxRrvTime = cpu_to_le16((u16)s_uGetTxRsvTime(pDevice, PK_TYPE_11B, cbFrameSize, wCurrentRate, bNeedACK));//1:CCK } @@ -979,7 +982,8 @@ static void s_vGenerateTxParameter(struct vnt_private *pDevice, else { //RTS_needless, non PCF mode //Fill RsvTime if (pvRrvTime) { - PSRrvTime_ab pBuf = (PSRrvTime_ab)pvRrvTime; + struct vnt_rrv_time_ab *pBuf = + (struct vnt_rrv_time_ab *)pvRrvTime; pBuf->wTxRrvTime = cpu_to_le16((u16)s_uGetTxRsvTime(pDevice, PK_TYPE_11B, cbFrameSize, wCurrentRate, bNeedACK)); //1:CCK } } @@ -1217,46 +1221,60 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, else {//802.11a/b packet if (byFBOption == AUTO_FB_NONE) { if (bRTS == true) {//RTS_need - pvRrvTime = (PSRrvTime_ab) (pbyTxBufferAddr + wTxBufSize); - pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab)); + pvRrvTime = (struct vnt_rrv_time_ab *) (pbyTxBufferAddr + + wTxBufSize); + pMICHDR = (PSMICHDRHead)(pbyTxBufferAddr + wTxBufSize + + sizeof(struct vnt_rrv_time_ab)); pvRTS = (struct vnt_rts_ab *) (pbyTxBufferAddr + wTxBufSize + - sizeof(SRrvTime_ab) + cbMICHDR); + sizeof(struct vnt_rrv_time_ab) + cbMICHDR); pvCTS = NULL; pvTxDataHd = (PSTxDataHead_ab) (pbyTxBufferAddr + wTxBufSize + - sizeof(SRrvTime_ab) + cbMICHDR + + sizeof(struct vnt_rrv_time_ab) + cbMICHDR + sizeof(struct vnt_rts_ab)); - cbHeaderLength = wTxBufSize + sizeof(PSRrvTime_ab) + cbMICHDR + - sizeof(struct vnt_rts_ab) + sizeof(STxDataHead_ab); + cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_ab) + + cbMICHDR + sizeof(struct vnt_rts_ab) + + sizeof(STxDataHead_ab); } else if (bRTS == false) { //RTS_needless, no MICHDR - pvRrvTime = (PSRrvTime_ab) (pbyTxBufferAddr + wTxBufSize); - pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab)); + pvRrvTime = (struct vnt_rrv_time_ab *)(pbyTxBufferAddr + + wTxBufSize); + pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + + sizeof(struct vnt_rrv_time_ab)); pvRTS = NULL; pvCTS = NULL; - pvTxDataHd = (PSTxDataHead_ab) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab) + cbMICHDR); - cbHeaderLength = wTxBufSize + sizeof(SRrvTime_ab) + cbMICHDR + sizeof(STxDataHead_ab); + pvTxDataHd = (PSTxDataHead_ab) (pbyTxBufferAddr + wTxBufSize + + sizeof(struct vnt_rrv_time_ab) + cbMICHDR); + cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_ab) + + cbMICHDR + sizeof(STxDataHead_ab); } } else { // Auto Fall Back if (bRTS == true) {//RTS_need - pvRrvTime = (PSRrvTime_ab) (pbyTxBufferAddr + wTxBufSize); - pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab)); + pvRrvTime = (struct vnt_rrv_time_ab *)(pbyTxBufferAddr + + wTxBufSize); + pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + + sizeof(struct vnt_rrv_time_ab)); pvRTS = (struct vnt_rts_a_fb *) (pbyTxBufferAddr + wTxBufSize + - sizeof(SRrvTime_ab) + cbMICHDR); + sizeof(struct vnt_rrv_time_ab) + cbMICHDR); pvCTS = NULL; pvTxDataHd = (PSTxDataHead_a_FB) (pbyTxBufferAddr + wTxBufSize + - sizeof(SRrvTime_ab) + cbMICHDR + + sizeof(struct vnt_rrv_time_ab) + cbMICHDR + sizeof(struct vnt_rts_a_fb)); - cbHeaderLength = wTxBufSize + sizeof(PSRrvTime_ab) + cbMICHDR + - sizeof(struct vnt_rts_a_fb) + sizeof(STxDataHead_a_FB); + cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_ab) + + cbMICHDR + sizeof(struct vnt_rts_a_fb) + + sizeof(STxDataHead_a_FB); } else if (bRTS == false) { //RTS_needless - pvRrvTime = (PSRrvTime_ab) (pbyTxBufferAddr + wTxBufSize); - pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab)); + pvRrvTime = (struct vnt_rrv_time_ab *)(pbyTxBufferAddr + + wTxBufSize); + pMICHDR = (PSMICHDRHead)(pbyTxBufferAddr + wTxBufSize + + sizeof(struct vnt_rrv_time_ab)); pvRTS = NULL; pvCTS = NULL; - pvTxDataHd = (PSTxDataHead_a_FB) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab) + cbMICHDR); - cbHeaderLength = wTxBufSize + sizeof(SRrvTime_ab) + cbMICHDR + sizeof(STxDataHead_a_FB); + pvTxDataHd = (PSTxDataHead_a_FB) (pbyTxBufferAddr + wTxBufSize + + sizeof(struct vnt_rrv_time_ab) + cbMICHDR); + cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_ab) + + cbMICHDR + sizeof(STxDataHead_a_FB); } } // Auto Fall Back } @@ -1676,12 +1694,14 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice, sizeof(struct vnt_cts) + sizeof(STxDataHead_g); } else { // 802.11a/b packet - pvRrvTime = (PSRrvTime_ab) (pbyTxBufferAddr + wTxBufSize); + pvRrvTime = (struct vnt_rrv_time_ab *) (pbyTxBufferAddr + wTxBufSize); pMICHDR = NULL; pvRTS = NULL; pCTS = NULL; - pvTxDataHd = (PSTxDataHead_ab) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab)); - cbHeaderSize = wTxBufSize + sizeof(SRrvTime_ab) + sizeof(STxDataHead_ab); + pvTxDataHd = (PSTxDataHead_ab) (pbyTxBufferAddr + wTxBufSize + + sizeof(struct vnt_rrv_time_ab)); + cbHeaderSize = wTxBufSize + sizeof(struct vnt_rrv_time_ab) + + sizeof(STxDataHead_ab); } memcpy(&(sEthHeader.h_dest[0]), @@ -2082,12 +2102,15 @@ void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb) } else {//802.11a/b packet - pvRrvTime = (PSRrvTime_ab) (pbyTxBufferAddr + wTxBufSize); - pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab)); + pvRrvTime = (struct vnt_rrv_time_ab *) (pbyTxBufferAddr + wTxBufSize); + pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + + sizeof(struct vnt_rrv_time_ab)); pvRTS = NULL; pvCTS = NULL; - pvTxDataHd = (PSTxDataHead_ab) (pbyTxBufferAddr + wTxBufSize + sizeof(SRrvTime_ab) + cbMICHDR); - cbHeaderSize = wTxBufSize + sizeof(SRrvTime_ab) + cbMICHDR + sizeof(STxDataHead_ab); + pvTxDataHd = (PSTxDataHead_ab) (pbyTxBufferAddr + wTxBufSize + + sizeof(struct vnt_rrv_time_ab) + cbMICHDR); + cbHeaderSize = wTxBufSize + sizeof(struct vnt_rrv_time_ab) + cbMICHDR + + sizeof(STxDataHead_ab); } memcpy(&(sEthHeader.h_dest[0]), &(p80211Header->sA3.abyAddr1[0]), diff --git a/drivers/staging/vt6656/rxtx.h b/drivers/staging/vt6656/rxtx.h index 35a6b476b12be..75737608d170c 100644 --- a/drivers/staging/vt6656/rxtx.h +++ b/drivers/staging/vt6656/rxtx.h @@ -49,6 +49,11 @@ struct vnt_rrv_time_cts { u16 wTxRrvTime_a; } __packed; +struct vnt_rrv_time_ab { + u16 wRTSTxRrvTime; + u16 wTxRrvTime; +} __packed; + /* RTS buffer header */ struct vnt_rts_g { u8 bySignalField_b; -- GitLab From 57107d4364a8cb426605279a18e2c7efba08430b Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Fri, 16 Aug 2013 23:46:49 +0100 Subject: [PATCH 695/942] staging: vt6656: desc.h remove dead code typedef struct tagSRrvTime_atim. Remove dead structure tagSRrvTime_atim. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/desc.h | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/drivers/staging/vt6656/desc.h b/drivers/staging/vt6656/desc.h index c2dec3bb90555..dc089ac27905a 100644 --- a/drivers/staging/vt6656/desc.h +++ b/drivers/staging/vt6656/desc.h @@ -143,17 +143,6 @@ #define TD_FLAGS_PRIV_SKB 0x02 /* check if called from private skb(hostap) */ #define TD_FLAGS_PS_RETRY 0x04 /* check if PS STA frame re-transmit */ -/* - * RsvTime buffer header - */ -typedef struct tagSRrvTime_atim { - u16 wCTSTxRrvTime_ba; - u16 wTxRrvTime_a; -} __attribute__ ((__packed__)) -SRrvTime_atim, *PSRrvTime_atim; - -typedef const SRrvTime_atim *PCSRrvTime_atim; - /* * TX FIFO header */ -- GitLab From 7e60a3de27db69ba072f9a9809aea21f8ff089eb Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Fri, 16 Aug 2013 23:48:03 +0100 Subject: [PATCH 696/942] staging: vt6656: desc.h: remove typedef struct tagSTxDataHead_g to new structure in rxtx.h To new structure. typedef struct tagSTxDataHead_g -> struct vnt_tx_datahead_g This is only needed by rxtc.c so moved to rxtx.h visible to vnt_rts*/vnt_cts* structures which it will eventually form part of their structure. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/desc.h | 16 ------------ drivers/staging/vt6656/rxtx.c | 49 +++++++++++++++++++---------------- drivers/staging/vt6656/rxtx.h | 14 ++++++++++ 3 files changed, 41 insertions(+), 38 deletions(-) diff --git a/drivers/staging/vt6656/desc.h b/drivers/staging/vt6656/desc.h index dc089ac27905a..b0cb8c430c5ca 100644 --- a/drivers/staging/vt6656/desc.h +++ b/drivers/staging/vt6656/desc.h @@ -166,22 +166,6 @@ typedef const STxShortBufHead *PCSTxShortBufHead; /* * TX data header */ -typedef struct tagSTxDataHead_g { - u8 bySignalField_b; - u8 byServiceField_b; - u16 wTransmitLength_b; - u8 bySignalField_a; - u8 byServiceField_a; - u16 wTransmitLength_a; - u16 wDuration_b; - u16 wDuration_a; - u16 wTimeStampOff_b; - u16 wTimeStampOff_a; -} __attribute__ ((__packed__)) -STxDataHead_g, *PSTxDataHead_g; - -typedef const STxDataHead_g *PCSTxDataHead_g; - typedef struct tagSTxDataHead_g_FB { u8 bySignalField_b; u8 byServiceField_b; diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index b21a4963f90dd..585a2e327151c 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -515,7 +515,8 @@ static u32 s_uFillDataHead(struct vnt_private *pDevice, } else { // DATA & MANAGE Frame if (byFBOption == AUTO_FB_NONE) { - PSTxDataHead_g pBuf = (PSTxDataHead_g)pTxDataHead; + struct vnt_tx_datahead_g *pBuf = + (struct vnt_tx_datahead_g *)pTxDataHead; //Get SignalField,ServiceField,Length BBvCalculateParameter(pDevice, cbFrameLength, wCurrentRate, byPktType, (u16 *)&(pBuf->wTransmitLength_a), (u8 *)&(pBuf->byServiceField_a), (u8 *)&(pBuf->bySignalField_a) @@ -1162,12 +1163,12 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, pvRTS = (struct vnt_rts_g *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_rts) + cbMICHDR); pvCTS = NULL; - pvTxDataHd = (PSTxDataHead_g) (pbyTxBufferAddr + wTxBufSize + - sizeof(struct vnt_rrv_time_rts) + cbMICHDR + - sizeof(struct vnt_rts_g)); + pvTxDataHd = (struct vnt_tx_datahead_g *) (pbyTxBufferAddr + + wTxBufSize + sizeof(struct vnt_rrv_time_rts) + + cbMICHDR + sizeof(struct vnt_rts_g)); cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_rts) + cbMICHDR + sizeof(struct vnt_rts_g) + - sizeof(STxDataHead_g); + sizeof(struct vnt_tx_datahead_g); } else { //RTS_needless pvRrvTime = (struct vnt_rrv_time_cts *) @@ -1177,12 +1178,12 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, pvRTS = NULL; pvCTS = (struct vnt_cts *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_cts) + cbMICHDR); - pvTxDataHd = (PSTxDataHead_g) (pbyTxBufferAddr + wTxBufSize + - sizeof(struct vnt_rrv_time_cts) + cbMICHDR + - sizeof(struct vnt_cts)); + pvTxDataHd = (struct vnt_tx_datahead_g *)(pbyTxBufferAddr + + wTxBufSize + sizeof(struct vnt_rrv_time_cts) + + cbMICHDR + sizeof(struct vnt_cts)); cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_cts) + cbMICHDR + sizeof(struct vnt_cts) + - sizeof(STxDataHead_g); + sizeof(struct vnt_tx_datahead_g); } } else { // Auto Fall Back @@ -1688,10 +1689,10 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice, pvRTS = NULL; pCTS = (struct vnt_cts *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_cts)); - pvTxDataHd = (PSTxDataHead_g) (pbyTxBufferAddr + wTxBufSize + + pvTxDataHd = (struct vnt_tx_datahead_g *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_cts) + sizeof(struct vnt_cts)); cbHeaderSize = wTxBufSize + sizeof(struct vnt_rrv_time_cts) + - sizeof(struct vnt_cts) + sizeof(STxDataHead_g); + sizeof(struct vnt_cts) + sizeof(struct vnt_tx_datahead_g); } else { // 802.11a/b packet pvRrvTime = (struct vnt_rrv_time_ab *) (pbyTxBufferAddr + wTxBufSize); @@ -1784,10 +1785,12 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice, // This will cause AID-field of PS-POLL packet be incorrect (Because PS-POLL's AID field is // in the same place of other packet's Duration-field). // And it will cause Cisco-AP to issue Disassociation-packet - if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { - ((PSTxDataHead_g)pvTxDataHd)->wDuration_a = cpu_to_le16(pPacket->p80211Header->sA2.wDurationID); - ((PSTxDataHead_g)pvTxDataHd)->wDuration_b = cpu_to_le16(pPacket->p80211Header->sA2.wDurationID); - } else { + if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { + ((struct vnt_tx_datahead_g *)pvTxDataHd)->wDuration_a = + cpu_to_le16(pPacket->p80211Header->sA2.wDurationID); + ((struct vnt_tx_datahead_g *)pvTxDataHd)->wDuration_b = + cpu_to_le16(pPacket->p80211Header->sA2.wDurationID); + } else { ((PSTxDataHead_ab)pvTxDataHd)->wDuration = cpu_to_le16(pPacket->p80211Header->sA2.wDurationID); } } @@ -2093,11 +2096,11 @@ void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb) pvRTS = NULL; pvCTS = (struct vnt_cts *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_cts) + cbMICHDR); - pvTxDataHd = (PSTxDataHead_g) (pbyTxBufferAddr + wTxBufSize + - sizeof(struct vnt_rrv_time_cts) + cbMICHDR + + pvTxDataHd = (struct vnt_tx_datahead_g *) (pbyTxBufferAddr + + wTxBufSize + sizeof(struct vnt_rrv_time_cts) + cbMICHDR + sizeof(struct vnt_cts)); cbHeaderSize = wTxBufSize + sizeof(struct vnt_rrv_time_cts) + cbMICHDR + - sizeof(struct vnt_cts) + sizeof(STxDataHead_g); + sizeof(struct vnt_cts) + sizeof(struct vnt_tx_datahead_g); } else {//802.11a/b packet @@ -2238,10 +2241,12 @@ void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb) // This will cause AID-field of PS-POLL packet be incorrect (Because PS-POLL's AID field is // in the same place of other packet's Duration-field). // And it will cause Cisco-AP to issue Disassociation-packet - if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { - ((PSTxDataHead_g)pvTxDataHd)->wDuration_a = cpu_to_le16(p80211Header->sA2.wDurationID); - ((PSTxDataHead_g)pvTxDataHd)->wDuration_b = cpu_to_le16(p80211Header->sA2.wDurationID); - } else { + if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { + ((struct vnt_tx_datahead_g *)pvTxDataHd)->wDuration_a = + cpu_to_le16(p80211Header->sA2.wDurationID); + ((struct vnt_tx_datahead_g *)pvTxDataHd)->wDuration_b = + cpu_to_le16(p80211Header->sA2.wDurationID); + } else { ((PSTxDataHead_ab)pvTxDataHd)->wDuration = cpu_to_le16(p80211Header->sA2.wDurationID); } } diff --git a/drivers/staging/vt6656/rxtx.h b/drivers/staging/vt6656/rxtx.h index 75737608d170c..3c8262321795a 100644 --- a/drivers/staging/vt6656/rxtx.h +++ b/drivers/staging/vt6656/rxtx.h @@ -54,6 +54,20 @@ struct vnt_rrv_time_ab { u16 wTxRrvTime; } __packed; +/* TX data header */ +struct vnt_tx_datahead_g { + u8 bySignalField_b; + u8 byServiceField_b; + u16 wTransmitLength_b; + u8 bySignalField_a; + u8 byServiceField_a; + u16 wTransmitLength_a; + u16 wDuration_b; + u16 wDuration_a; + u16 wTimeStampOff_b; + u16 wTimeStampOff_a; +} __packed; + /* RTS buffer header */ struct vnt_rts_g { u8 bySignalField_b; -- GitLab From 7c05c5451dcce15e10447a98403ac7d255451d7c Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Fri, 16 Aug 2013 23:49:15 +0100 Subject: [PATCH 697/942] staging: vt6656: desc.h remove typedef tagSTxDataHead_g_FB to new structure in rxtx.h To new structure. typedef struct tagSTxDataHead_g_FB -> struct vnt_tx_datahead_g_fb This is only needed by rxtc.c so moved to rxtx.h visible to vnt_rts*/vnt_cts* structures which it will eventually form part of their structure. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/desc.h | 17 ----------------- drivers/staging/vt6656/rxtx.c | 15 ++++++++------- drivers/staging/vt6656/rxtx.h | 15 +++++++++++++++ 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/drivers/staging/vt6656/desc.h b/drivers/staging/vt6656/desc.h index b0cb8c430c5ca..1ee0331757c54 100644 --- a/drivers/staging/vt6656/desc.h +++ b/drivers/staging/vt6656/desc.h @@ -166,23 +166,6 @@ typedef const STxShortBufHead *PCSTxShortBufHead; /* * TX data header */ -typedef struct tagSTxDataHead_g_FB { - u8 bySignalField_b; - u8 byServiceField_b; - u16 wTransmitLength_b; - u8 bySignalField_a; - u8 byServiceField_a; - u16 wTransmitLength_a; - u16 wDuration_b; - u16 wDuration_a; - u16 wDuration_a_f0; - u16 wDuration_a_f1; - u16 wTimeStampOff_b; - u16 wTimeStampOff_a; -} __attribute__ ((__packed__)) -STxDataHead_g_FB, *PSTxDataHead_g_FB; -typedef const STxDataHead_g_FB *PCSTxDataHead_g_FB; - typedef struct tagSTxDataHead_ab { u8 bySignalField; u8 byServiceField; diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 585a2e327151c..20c4656e03599 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -535,7 +535,8 @@ static u32 s_uFillDataHead(struct vnt_private *pDevice, return (pBuf->wDuration_a); } else { // Auto Fallback - PSTxDataHead_g_FB pBuf = (PSTxDataHead_g_FB)pTxDataHead; + struct vnt_tx_datahead_g_fb *pBuf = + (struct vnt_tx_datahead_g_fb *)pTxDataHead; //Get SignalField,ServiceField,Length BBvCalculateParameter(pDevice, cbFrameLength, wCurrentRate, byPktType, (u16 *)&(pBuf->wTransmitLength_a), (u8 *)&(pBuf->byServiceField_a), (u8 *)&(pBuf->bySignalField_a) @@ -1195,12 +1196,12 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, pvRTS = (struct vnt_rts_g_fb *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_rts) + cbMICHDR); pvCTS = NULL; - pvTxDataHd = (PSTxDataHead_g_FB) (pbyTxBufferAddr + wTxBufSize + - sizeof(struct vnt_rrv_time_rts) + cbMICHDR + - sizeof(struct vnt_rts_g_fb)); + pvTxDataHd = (struct vnt_tx_datahead_g_fb *) (pbyTxBufferAddr + + wTxBufSize + sizeof(struct vnt_rrv_time_rts) + + cbMICHDR + sizeof(struct vnt_rts_g_fb)); cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_rts) + cbMICHDR + sizeof(struct vnt_rts_g_fb) + - sizeof(STxDataHead_g_FB); + sizeof(struct vnt_tx_datahead_g_fb); } else if (bRTS == false) { //RTS_needless pvRrvTime = (struct vnt_rrv_time_cts *) @@ -1210,12 +1211,12 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, pvRTS = NULL; pvCTS = (struct vnt_cts_fb *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_cts) + cbMICHDR); - pvTxDataHd = (PSTxDataHead_g_FB) (pbyTxBufferAddr + + pvTxDataHd = (struct vnt_tx_datahead_g_fb *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_cts) + cbMICHDR + sizeof(struct vnt_cts_fb)); cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_cts) + cbMICHDR + sizeof(struct vnt_cts_fb) + - sizeof(STxDataHead_g_FB); + sizeof(struct vnt_tx_datahead_g_fb); } } // Auto Fall Back } diff --git a/drivers/staging/vt6656/rxtx.h b/drivers/staging/vt6656/rxtx.h index 3c8262321795a..ba80271d11b41 100644 --- a/drivers/staging/vt6656/rxtx.h +++ b/drivers/staging/vt6656/rxtx.h @@ -68,6 +68,21 @@ struct vnt_tx_datahead_g { u16 wTimeStampOff_a; } __packed; +struct vnt_tx_datahead_g_fb { + u8 bySignalField_b; + u8 byServiceField_b; + u16 wTransmitLength_b; + u8 bySignalField_a; + u8 byServiceField_a; + u16 wTransmitLength_a; + u16 wDuration_b; + u16 wDuration_a; + u16 wDuration_a_f0; + u16 wDuration_a_f1; + u16 wTimeStampOff_b; + u16 wTimeStampOff_a; +} __packed; + /* RTS buffer header */ struct vnt_rts_g { u8 bySignalField_b; -- GitLab From 558becf1888eb8945a74af2e2430908ac6373131 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Fri, 16 Aug 2013 23:50:32 +0100 Subject: [PATCH 698/942] staging: vt6656: desc.h remove typedef tagSTxDataHead_ab to new structure in rxtx.h To new structure. typedef struct tagSTxDataHead_ab -> struct vnt_tx_datahead_ab This is only needed by rxtc.c so moved to rxtx.h visible to vnt_rts* structures which it will eventually form part of their structure. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/desc.h | 10 ------- drivers/staging/vt6656/rxtx.c | 55 ++++++++++++++++++++--------------- drivers/staging/vt6656/rxtx.h | 8 +++++ 3 files changed, 39 insertions(+), 34 deletions(-) diff --git a/drivers/staging/vt6656/desc.h b/drivers/staging/vt6656/desc.h index 1ee0331757c54..d350fd3873c34 100644 --- a/drivers/staging/vt6656/desc.h +++ b/drivers/staging/vt6656/desc.h @@ -166,16 +166,6 @@ typedef const STxShortBufHead *PCSTxShortBufHead; /* * TX data header */ -typedef struct tagSTxDataHead_ab { - u8 bySignalField; - u8 byServiceField; - u16 wTransmitLength; - u16 wDuration; - u16 wTimeStampOff; -} __attribute__ ((__packed__)) -STxDataHead_ab, *PSTxDataHead_ab; -typedef const STxDataHead_ab *PCSTxDataHead_ab; - typedef struct tagSTxDataHead_a_FB { u8 bySignalField; u8 byServiceField; diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 20c4656e03599..a4d372886b934 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -500,7 +500,8 @@ static u32 s_uFillDataHead(struct vnt_private *pDevice, if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { if ((uDMAIdx == TYPE_ATIMDMA) || (uDMAIdx == TYPE_BEACONDMA)) { - PSTxDataHead_ab pBuf = (PSTxDataHead_ab) pTxDataHead; + struct vnt_tx_datahead_ab *pBuf = + (struct vnt_tx_datahead_ab *)pTxDataHead; //Get SignalField,ServiceField,Length BBvCalculateParameter(pDevice, cbFrameLength, wCurrentRate, byPktType, (u16 *)&(pBuf->wTransmitLength), (u8 *)&(pBuf->byServiceField), (u8 *)&(pBuf->bySignalField) @@ -579,7 +580,8 @@ static u32 s_uFillDataHead(struct vnt_private *pDevice, } return (pBuf->wDuration); } else { - PSTxDataHead_ab pBuf = (PSTxDataHead_ab)pTxDataHead; + struct vnt_tx_datahead_ab *pBuf = + (struct vnt_tx_datahead_ab *)pTxDataHead; //Get SignalField,ServiceField,Length BBvCalculateParameter(pDevice, cbFrameLength, wCurrentRate, byPktType, (u16 *)&(pBuf->wTransmitLength), (u8 *)&(pBuf->byServiceField), (u8 *)&(pBuf->bySignalField) @@ -595,7 +597,8 @@ static u32 s_uFillDataHead(struct vnt_private *pDevice, } } else if (byPktType == PK_TYPE_11B) { - PSTxDataHead_ab pBuf = (PSTxDataHead_ab)pTxDataHead; + struct vnt_tx_datahead_ab *pBuf = + (struct vnt_tx_datahead_ab *)pTxDataHead; //Get SignalField,ServiceField,Length BBvCalculateParameter(pDevice, cbFrameLength, wCurrentRate, byPktType, (u16 *)&(pBuf->wTransmitLength), (u8 *)&(pBuf->byServiceField), (u8 *)&(pBuf->bySignalField) @@ -1230,12 +1233,12 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, pvRTS = (struct vnt_rts_ab *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab) + cbMICHDR); pvCTS = NULL; - pvTxDataHd = (PSTxDataHead_ab) (pbyTxBufferAddr + wTxBufSize + - sizeof(struct vnt_rrv_time_ab) + cbMICHDR + + pvTxDataHd = (struct vnt_tx_datahead_ab *)(pbyTxBufferAddr + + wTxBufSize + sizeof(struct vnt_rrv_time_ab) + cbMICHDR + sizeof(struct vnt_rts_ab)); cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_ab) + cbMICHDR + sizeof(struct vnt_rts_ab) + - sizeof(STxDataHead_ab); + sizeof(struct vnt_tx_datahead_ab); } else if (bRTS == false) { //RTS_needless, no MICHDR pvRrvTime = (struct vnt_rrv_time_ab *)(pbyTxBufferAddr + @@ -1244,10 +1247,10 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, sizeof(struct vnt_rrv_time_ab)); pvRTS = NULL; pvCTS = NULL; - pvTxDataHd = (PSTxDataHead_ab) (pbyTxBufferAddr + wTxBufSize + - sizeof(struct vnt_rrv_time_ab) + cbMICHDR); + pvTxDataHd = (struct vnt_tx_datahead_ab *)(pbyTxBufferAddr + + wTxBufSize + sizeof(struct vnt_rrv_time_ab) + cbMICHDR); cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_ab) + - cbMICHDR + sizeof(STxDataHead_ab); + cbMICHDR + sizeof(struct vnt_tx_datahead_ab); } } else { // Auto Fall Back @@ -1700,10 +1703,10 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice, pMICHDR = NULL; pvRTS = NULL; pCTS = NULL; - pvTxDataHd = (PSTxDataHead_ab) (pbyTxBufferAddr + wTxBufSize + - sizeof(struct vnt_rrv_time_ab)); + pvTxDataHd = (struct vnt_tx_datahead_ab *) (pbyTxBufferAddr + + wTxBufSize + sizeof(struct vnt_rrv_time_ab)); cbHeaderSize = wTxBufSize + sizeof(struct vnt_rrv_time_ab) + - sizeof(STxDataHead_ab); + sizeof(struct vnt_tx_datahead_ab); } memcpy(&(sEthHeader.h_dest[0]), @@ -1792,8 +1795,9 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice, ((struct vnt_tx_datahead_g *)pvTxDataHd)->wDuration_b = cpu_to_le16(pPacket->p80211Header->sA2.wDurationID); } else { - ((PSTxDataHead_ab)pvTxDataHd)->wDuration = cpu_to_le16(pPacket->p80211Header->sA2.wDurationID); - } + ((struct vnt_tx_datahead_ab *)pvTxDataHd)->wDuration = + cpu_to_le16(pPacket->p80211Header->sA2.wDurationID); + } } pTX_Buffer->wTxByteCount = cpu_to_le16((u16)(cbReqCount)); @@ -1824,7 +1828,7 @@ CMD_STATUS csBeacon_xmit(struct vnt_private *pDevice, u16 wTxBufSize = sizeof(STxShortBufHead); PSTxShortBufHead pTxBufHead; struct ieee80211_hdr *pMACHeader; - PSTxDataHead_ab pTxDataHead; + struct vnt_tx_datahead_ab *pTxDataHead; u16 wCurrentRate; u32 cbFrameBodySize; u32 cbReqCount; @@ -1849,7 +1853,8 @@ CMD_STATUS csBeacon_xmit(struct vnt_private *pDevice, if (pDevice->byBBType == BB_TYPE_11A) { wCurrentRate = RATE_6M; - pTxDataHead = (PSTxDataHead_ab) (pbyTxBufferAddr + wTxBufSize); + pTxDataHead = (struct vnt_tx_datahead_ab *) + (pbyTxBufferAddr + wTxBufSize); //Get SignalField,ServiceField,Length BBvCalculateParameter(pDevice, cbFrameSize, wCurrentRate, PK_TYPE_11A, (u16 *)&(pTxDataHead->wTransmitLength), (u8 *)&(pTxDataHead->byServiceField), (u8 *)&(pTxDataHead->bySignalField) @@ -1858,11 +1863,12 @@ CMD_STATUS csBeacon_xmit(struct vnt_private *pDevice, pTxDataHead->wDuration = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A, PK_TYPE_11A, false)); pTxDataHead->wTimeStampOff = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]; - cbHeaderSize = wTxBufSize + sizeof(STxDataHead_ab); + cbHeaderSize = wTxBufSize + sizeof(struct vnt_tx_datahead_ab); } else { wCurrentRate = RATE_1M; pTxBufHead->wFIFOCtl |= FIFOCTL_11B; - pTxDataHead = (PSTxDataHead_ab) (pbyTxBufferAddr + wTxBufSize); + pTxDataHead = (struct vnt_tx_datahead_ab *) + (pbyTxBufferAddr + wTxBufSize); //Get SignalField,ServiceField,Length BBvCalculateParameter(pDevice, cbFrameSize, wCurrentRate, PK_TYPE_11B, (u16 *)&(pTxDataHead->wTransmitLength), (u8 *)&(pTxDataHead->byServiceField), (u8 *)&(pTxDataHead->bySignalField) @@ -1871,7 +1877,7 @@ CMD_STATUS csBeacon_xmit(struct vnt_private *pDevice, pTxDataHead->wDuration = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_B, PK_TYPE_11B, false)); pTxDataHead->wTimeStampOff = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]; - cbHeaderSize = wTxBufSize + sizeof(STxDataHead_ab); + cbHeaderSize = wTxBufSize + sizeof(struct vnt_tx_datahead_ab); } //Generate Beacon Header @@ -2111,10 +2117,10 @@ void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb) sizeof(struct vnt_rrv_time_ab)); pvRTS = NULL; pvCTS = NULL; - pvTxDataHd = (PSTxDataHead_ab) (pbyTxBufferAddr + wTxBufSize + - sizeof(struct vnt_rrv_time_ab) + cbMICHDR); + pvTxDataHd = (struct vnt_tx_datahead_ab *)(pbyTxBufferAddr + + wTxBufSize + sizeof(struct vnt_rrv_time_ab) + cbMICHDR); cbHeaderSize = wTxBufSize + sizeof(struct vnt_rrv_time_ab) + cbMICHDR + - sizeof(STxDataHead_ab); + sizeof(struct vnt_tx_datahead_ab); } memcpy(&(sEthHeader.h_dest[0]), &(p80211Header->sA3.abyAddr1[0]), @@ -2248,8 +2254,9 @@ void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb) ((struct vnt_tx_datahead_g *)pvTxDataHd)->wDuration_b = cpu_to_le16(p80211Header->sA2.wDurationID); } else { - ((PSTxDataHead_ab)pvTxDataHd)->wDuration = cpu_to_le16(p80211Header->sA2.wDurationID); - } + ((struct vnt_tx_datahead_ab *)pvTxDataHd)->wDuration = + cpu_to_le16(p80211Header->sA2.wDurationID); + } } pTX_Buffer->wTxByteCount = cpu_to_le16((u16)(cbReqCount)); diff --git a/drivers/staging/vt6656/rxtx.h b/drivers/staging/vt6656/rxtx.h index ba80271d11b41..d66d71dde4374 100644 --- a/drivers/staging/vt6656/rxtx.h +++ b/drivers/staging/vt6656/rxtx.h @@ -83,6 +83,14 @@ struct vnt_tx_datahead_g_fb { u16 wTimeStampOff_a; } __packed; +struct vnt_tx_datahead_ab { + u8 bySignalField; + u8 byServiceField; + u16 wTransmitLength; + u16 wDuration; + u16 wTimeStampOff; +} __packed; + /* RTS buffer header */ struct vnt_rts_g { u8 bySignalField_b; -- GitLab From 1da4ee2050b8751fc55d79cd4ba89a10c2a9e1be Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Fri, 16 Aug 2013 23:51:38 +0100 Subject: [PATCH 699/942] staging: vt6656: desc.h remove typedef tagSTxDataHead_a_FB to new structure in rxtx.h To new structure. typedef struct tagSTxDataHead_a_FB -> struct vnt_tx_datahead_a_fb This is only needed by rxtc.c so moved to rxtx.h visible to vnt_rts* structures which it will eventually form part of their structure. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/desc.h | 15 --------------- drivers/staging/vt6656/rxtx.c | 15 ++++++++------- drivers/staging/vt6656/rxtx.h | 10 ++++++++++ 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/drivers/staging/vt6656/desc.h b/drivers/staging/vt6656/desc.h index d350fd3873c34..b3e8cc106d125 100644 --- a/drivers/staging/vt6656/desc.h +++ b/drivers/staging/vt6656/desc.h @@ -163,21 +163,6 @@ typedef struct tagSTxShortBufHead { STxShortBufHead, *PSTxShortBufHead; typedef const STxShortBufHead *PCSTxShortBufHead; -/* - * TX data header - */ -typedef struct tagSTxDataHead_a_FB { - u8 bySignalField; - u8 byServiceField; - u16 wTransmitLength; - u16 wDuration; - u16 wTimeStampOff; - u16 wDuration_f0; - u16 wDuration_f1; -} __attribute__ ((__packed__)) -STxDataHead_a_FB, *PSTxDataHead_a_FB; -typedef const STxDataHead_a_FB *PCSTxDataHead_a_FB; - /* * MICHDR data header */ diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index a4d372886b934..d7f920de25f79 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -563,7 +563,8 @@ static u32 s_uFillDataHead(struct vnt_private *pDevice, else if (byPktType == PK_TYPE_11A) { if ((byFBOption != AUTO_FB_NONE) && (uDMAIdx != TYPE_ATIMDMA) && (uDMAIdx != TYPE_BEACONDMA)) { // Auto Fallback - PSTxDataHead_a_FB pBuf = (PSTxDataHead_a_FB)pTxDataHead; + struct vnt_tx_datahead_a_fb *pBuf = + (struct vnt_tx_datahead_a_fb *)pTxDataHead; //Get SignalField,ServiceField,Length BBvCalculateParameter(pDevice, cbFrameLength, wCurrentRate, byPktType, (u16 *)&(pBuf->wTransmitLength), (u8 *)&(pBuf->byServiceField), (u8 *)&(pBuf->bySignalField) @@ -1262,12 +1263,12 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, pvRTS = (struct vnt_rts_a_fb *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab) + cbMICHDR); pvCTS = NULL; - pvTxDataHd = (PSTxDataHead_a_FB) (pbyTxBufferAddr + wTxBufSize + - sizeof(struct vnt_rrv_time_ab) + cbMICHDR + + pvTxDataHd = (struct vnt_tx_datahead_a_fb *)(pbyTxBufferAddr + + wTxBufSize + sizeof(struct vnt_rrv_time_ab) + cbMICHDR + sizeof(struct vnt_rts_a_fb)); cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_ab) + cbMICHDR + sizeof(struct vnt_rts_a_fb) + - sizeof(STxDataHead_a_FB); + sizeof(struct vnt_tx_datahead_a_fb); } else if (bRTS == false) { //RTS_needless pvRrvTime = (struct vnt_rrv_time_ab *)(pbyTxBufferAddr + @@ -1276,10 +1277,10 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, sizeof(struct vnt_rrv_time_ab)); pvRTS = NULL; pvCTS = NULL; - pvTxDataHd = (PSTxDataHead_a_FB) (pbyTxBufferAddr + wTxBufSize + - sizeof(struct vnt_rrv_time_ab) + cbMICHDR); + pvTxDataHd = (struct vnt_tx_datahead_a_fb *)(pbyTxBufferAddr + + wTxBufSize + sizeof(struct vnt_rrv_time_ab) + cbMICHDR); cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_ab) + - cbMICHDR + sizeof(STxDataHead_a_FB); + cbMICHDR + sizeof(struct vnt_tx_datahead_a_fb); } } // Auto Fall Back } diff --git a/drivers/staging/vt6656/rxtx.h b/drivers/staging/vt6656/rxtx.h index d66d71dde4374..b1ef90eac4ea3 100644 --- a/drivers/staging/vt6656/rxtx.h +++ b/drivers/staging/vt6656/rxtx.h @@ -91,6 +91,16 @@ struct vnt_tx_datahead_ab { u16 wTimeStampOff; } __packed; +struct vnt_tx_datahead_a_fb { + u8 bySignalField; + u8 byServiceField; + u16 wTransmitLength; + u16 wDuration; + u16 wTimeStampOff; + u16 wDuration_f0; + u16 wDuration_f1; +} __packed; + /* RTS buffer header */ struct vnt_rts_g { u8 bySignalField_b; -- GitLab From f1900e78cf599df78bbd7fe7762dd1a22d3c56a0 Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Tue, 20 Aug 2013 14:15:35 -0400 Subject: [PATCH 700/942] staging: dgnc: driver.c: fixes warning about assigning pointer This patch fixes a warning associated with assigining a pointer in the dgnc_mbuf function. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c index e8de7a411255f..e5d021f8bd961 100644 --- a/drivers/staging/dgnc/dgnc_driver.c +++ b/drivers/staging/dgnc/dgnc_driver.c @@ -943,7 +943,7 @@ static void dgnc_mbuf(struct board_t *brd, const char *fmt, ...) { memcpy(brd->msgbuf, buf, strlen(buf)); brd->msgbuf += strlen(buf); - *brd->msgbuf = (char) NULL; + *brd->msgbuf = '\0'; DGNC_UNLOCK(dgnc_global_lock, flags); } -- GitLab From 62a86e50e73f60300f51e30a62ba04a76888b4da Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Tue, 20 Aug 2013 14:15:36 -0400 Subject: [PATCH 701/942] staging: dgnc: removes ifdef HAVE_UNLOCKED_IOCTL conditionals This patch removes the HAVE_UNLOCKED_IOCTL conditional statements from driver.c, mgmt.c and mgmt.h. This was used to support older kernels. It isn't needed now. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_driver.c | 4 ---- drivers/staging/dgnc/dgnc_mgmt.c | 7 +------ drivers/staging/dgnc/dgnc_mgmt.h | 6 ------ 3 files changed, 1 insertion(+), 16 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c index e5d021f8bd961..937134749e3e4 100644 --- a/drivers/staging/dgnc/dgnc_driver.c +++ b/drivers/staging/dgnc/dgnc_driver.c @@ -99,11 +99,7 @@ module_exit(dgnc_cleanup_module); static struct file_operations dgnc_BoardFops = { .owner = THIS_MODULE, -#ifdef HAVE_UNLOCKED_IOCTL .unlocked_ioctl = dgnc_mgmt_ioctl, -#else - .ioctl = dgnc_mgmt_ioctl, -#endif .open = dgnc_mgmt_open, .release = dgnc_mgmt_close }; diff --git a/drivers/staging/dgnc/dgnc_mgmt.c b/drivers/staging/dgnc/dgnc_mgmt.c index bbd65db524cd1..200da36caa781 100644 --- a/drivers/staging/dgnc/dgnc_mgmt.c +++ b/drivers/staging/dgnc/dgnc_mgmt.c @@ -125,14 +125,9 @@ int dgnc_mgmt_close(struct inode *inode, struct file *file) * * ioctl the mgmt/dpa device */ -#ifdef HAVE_UNLOCKED_IOCTL + long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { - struct inode *inode = file->f_dentry->d_inode; -#else -int dgnc_mgmt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) -{ -#endif unsigned long lock_flags; void __user *uarg = (void __user *) arg; diff --git a/drivers/staging/dgnc/dgnc_mgmt.h b/drivers/staging/dgnc/dgnc_mgmt.h index a0d1338ee5457..567f687b18ddb 100644 --- a/drivers/staging/dgnc/dgnc_mgmt.h +++ b/drivers/staging/dgnc/dgnc_mgmt.h @@ -26,12 +26,6 @@ int dgnc_mgmt_open(struct inode *inode, struct file *file); int dgnc_mgmt_close(struct inode *inode, struct file *file); - -#ifdef HAVE_UNLOCKED_IOCTL long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg); -#else -int dgnc_mgmt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg); -#endif - #endif -- GitLab From 53c55fa228ba115146f93a0dfbed324b757b4fe3 Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Tue, 20 Aug 2013 20:56:58 -0400 Subject: [PATCH 702/942] staging: dgnc: add driver to kernel build This patch adds the dgnc driver to the kernel build process. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/Kconfig | 2 ++ drivers/staging/Makefile | 1 + 2 files changed, 3 insertions(+) diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index 1665705e3e910..0d9d92b275ba5 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -142,4 +142,6 @@ source "drivers/staging/btmtk_usb/Kconfig" source "drivers/staging/xillybus/Kconfig" +source "drivers/staging/dgnc/Kconfig" + endif # STAGING diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index 3f18f414f952a..0086ceb3285de 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -63,3 +63,4 @@ obj-$(CONFIG_USB_DWC2) += dwc2/ obj-$(CONFIG_LUSTRE_FS) += lustre/ obj-$(CONFIG_USB_BTMTK) += btmtk_usb/ obj-$(CONFIG_XILLYBUS) += xillybus/ +obj-$(CONFIG_DGNC) += dgnc/ -- GitLab From 5ca46fd4c814de9189b21ce4c29d00022f100152 Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Wed, 21 Aug 2013 11:08:00 -0400 Subject: [PATCH 703/942] staging: dgnc: cls.c: removes trailing whitespace This patch removes trailing whitespace in the dgnc_cls.c file. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_cls.c | 48 ++++++++++++++++----------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_cls.c b/drivers/staging/dgnc/dgnc_cls.c index 83c0575ddb475..cf997bea4bc1c 100644 --- a/drivers/staging/dgnc/dgnc_cls.c +++ b/drivers/staging/dgnc/dgnc_cls.c @@ -6,12 +6,12 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -111,7 +111,7 @@ static inline void cls_set_cts_flow_control(struct channel_t *ch) writeb(UART_EXAR654_ENHANCED_REGISTER_SET, &ch->ch_cls_uart->lcr); isr_fcr = readb(&ch->ch_cls_uart->isr_fcr); - + /* Turn on CTS flow control, turn off IXON flow control */ isr_fcr |= (UART_EXAR654_EFR_ECB | UART_EXAR654_EFR_CTSDSR); isr_fcr &= ~(UART_EXAR654_EFR_IXON); @@ -153,7 +153,7 @@ static inline void cls_set_ixon_flow_control(struct channel_t *ch) writeb(UART_EXAR654_ENHANCED_REGISTER_SET, &ch->ch_cls_uart->lcr); isr_fcr = readb(&ch->ch_cls_uart->isr_fcr); - + /* Turn on IXON flow control, turn off CTS flow control */ isr_fcr |= (UART_EXAR654_EFR_ECB | UART_EXAR654_EFR_IXON); isr_fcr &= ~(UART_EXAR654_EFR_CTSDSR); @@ -199,7 +199,7 @@ static inline void cls_set_no_output_flow_control(struct channel_t *ch) writeb(UART_EXAR654_ENHANCED_REGISTER_SET, &ch->ch_cls_uart->lcr); isr_fcr = readb(&ch->ch_cls_uart->isr_fcr); - + /* Turn off IXON flow control, turn off CTS flow control */ isr_fcr |= (UART_EXAR654_EFR_ECB); isr_fcr &= ~(UART_EXAR654_EFR_CTSDSR | UART_EXAR654_EFR_IXON); @@ -243,7 +243,7 @@ static inline void cls_set_rts_flow_control(struct channel_t *ch) writeb(UART_EXAR654_ENHANCED_REGISTER_SET, &ch->ch_cls_uart->lcr); isr_fcr = readb(&ch->ch_cls_uart->isr_fcr); - + /* Turn on RTS flow control, turn off IXOFF flow control */ isr_fcr |= (UART_EXAR654_EFR_ECB | UART_EXAR654_EFR_RTSDTR); isr_fcr &= ~(UART_EXAR654_EFR_IXOFF); @@ -286,7 +286,7 @@ static inline void cls_set_ixoff_flow_control(struct channel_t *ch) writeb(UART_EXAR654_ENHANCED_REGISTER_SET, &ch->ch_cls_uart->lcr); isr_fcr = readb(&ch->ch_cls_uart->isr_fcr); - + /* Turn on IXOFF flow control, turn off RTS flow control */ isr_fcr |= (UART_EXAR654_EFR_ECB | UART_EXAR654_EFR_IXOFF); isr_fcr &= ~(UART_EXAR654_EFR_RTSDTR); @@ -331,7 +331,7 @@ static inline void cls_set_no_input_flow_control(struct channel_t *ch) writeb(UART_EXAR654_ENHANCED_REGISTER_SET, &ch->ch_cls_uart->lcr); isr_fcr = readb(&ch->ch_cls_uart->isr_fcr); - + /* Turn off IXOFF flow control, turn off RTS flow control */ isr_fcr |= (UART_EXAR654_EFR_ECB); isr_fcr &= ~(UART_EXAR654_EFR_RTSDTR | UART_EXAR654_EFR_IXOFF); @@ -492,7 +492,7 @@ static void cls_param(struct tty_struct *tty) return; } - ch = un->un_ch; + ch = un->un_ch; if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) { return; } @@ -581,7 +581,7 @@ static void cls_param(struct tty_struct *tty) jindex = baud; if ((iindex >= 0) && (iindex < 4) && (jindex >= 0) && (jindex < 16)) { - baud = bauds[iindex][jindex]; + baud = bauds[iindex][jindex]; } else { DPR_IOCTL(("baud indices were out of range (%d)(%d)", iindex, jindex)); @@ -620,7 +620,7 @@ static void cls_param(struct tty_struct *tty) */ #ifdef CMSPAR if (ch->ch_c_cflag & CMSPAR) - lcr |= UART_LCR_SPAR; + lcr |= UART_LCR_SPAR; #endif if (ch->ch_c_cflag & CSTOPB) @@ -663,7 +663,7 @@ static void cls_param(struct tty_struct *tty) if (ch->ch_c_cflag & CREAD) { ier |= (UART_IER_RDI | UART_IER_RLSI); - } + } else { ier &= ~(UART_IER_RDI | UART_IER_RLSI); } @@ -710,7 +710,7 @@ static void cls_param(struct tty_struct *tty) cls_set_no_input_flow_control(ch); else cls_set_ixoff_flow_control(ch); - } + } else { cls_set_no_input_flow_control(ch); } @@ -827,7 +827,7 @@ static irqreturn_t cls_intr(int irq, void *voidbrd) brd->intr_count++; /* - * Check the board's global interrupt offset to see if we + * Check the board's global interrupt offset to see if we * we actually do have an interrupt pending for us. */ poll_reg = readb(brd->re_map_membase + UART_CLASSIC_POLL_ADDR_OFFSET); @@ -986,7 +986,7 @@ static int cls_drain(struct tty_struct *tty, uint seconds) return (-ENXIO); } - ch = un->un_ch; + ch = un->un_ch; if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) { return (-ENXIO); } @@ -1006,7 +1006,7 @@ static int cls_drain(struct tty_struct *tty, uint seconds) return (rc); } - + /* Channel lock MUST be held before calling this function! */ static void cls_flush_uart_write(struct channel_t *ch) @@ -1032,7 +1032,7 @@ static void cls_flush_uart_read(struct channel_t *ch) /* * For complete POSIX compatibility, we should be purging the * read FIFO in the UART here. - * + * * However, doing the statement below also incorrectly flushes * write data as well as just basically trashing the FIFO. * @@ -1163,7 +1163,7 @@ static void cls_parse_modem(struct channel_t *ch, uchar signals) msignals |= UART_MSR_DCD; } } - + /* Scrub off lower bits. They signify delta's, which I don't care about */ signals &= 0xf0; @@ -1192,8 +1192,8 @@ static void cls_parse_modem(struct channel_t *ch, uchar signals) ch->ch_portnum, !!((ch->ch_mistat | ch->ch_mostat) & UART_MCR_DTR), !!((ch->ch_mistat | ch->ch_mostat) & UART_MCR_RTS), - !!((ch->ch_mistat | ch->ch_mostat) & UART_MSR_CTS), - !!((ch->ch_mistat | ch->ch_mostat) & UART_MSR_DSR), + !!((ch->ch_mistat | ch->ch_mostat) & UART_MSR_CTS), + !!((ch->ch_mistat | ch->ch_mostat) & UART_MSR_DSR), !!((ch->ch_mistat | ch->ch_mostat) & UART_MSR_RI), !!((ch->ch_mistat | ch->ch_mostat) & UART_MSR_DCD))); } @@ -1258,7 +1258,7 @@ static void cls_uart_init(struct channel_t *ch) writeb(UART_EXAR654_ENHANCED_REGISTER_SET, &ch->ch_cls_uart->lcr); isr_fcr = readb(&ch->ch_cls_uart->isr_fcr); - + /* Turn on Enhanced/Extended controls */ isr_fcr |= (UART_EXAR654_EFR_ECB); @@ -1380,7 +1380,7 @@ static void cls_send_immediate_char(struct channel_t *ch, unsigned char c) writeb(c, &ch->ch_cls_uart->txrx); } -static void cls_vpd(struct board_t *brd) +static void cls_vpd(struct board_t *brd) { ulong vpdbase; /* Start of io base of the card */ uchar *re_map_vpdbase;/* Remapped memory of the card */ -- GitLab From 1ef56a42e93c7c27243943b6b8ef99a3abc2e674 Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Wed, 21 Aug 2013 11:08:01 -0400 Subject: [PATCH 704/942] staging: dgnc: cls.h: removes trailing whitespace This patch removes trailing whitespace in the dgnc_cls.h file. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_cls.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_cls.h b/drivers/staging/dgnc/dgnc_cls.h index dca5ea38cd54d..a27338573f752 100644 --- a/drivers/staging/dgnc/dgnc_cls.h +++ b/drivers/staging/dgnc/dgnc_cls.h @@ -26,12 +26,12 @@ #include "dgnc_types.h" -/************************************************************************ +/************************************************************************ * Per channel/port Classic UART structure * ************************************************************************ * Base Structure Entries Usage Meanings to Host * * * - * W = read write R = read only * + * W = read write R = read only * * U = Unused. * ************************************************************************/ @@ -82,7 +82,7 @@ struct cls_uart_struct { #define UART_EXAR654_IER_RTSDTR 0x40 /* Output Interrupt Enable */ #define UART_EXAR654_IER_CTSDSR 0x80 /* Input Interrupt Enable */ -/* +/* * Our Global Variables */ extern struct board_ops dgnc_cls_ops; -- GitLab From 817b7847165ca22064bd52a6aea6ecb5fcc45eda Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Wed, 21 Aug 2013 11:08:02 -0400 Subject: [PATCH 705/942] staging: dgnc: driver.c: removes trailing whitespace This patch removes trailing whitespace in the dgnc_driver.c file. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_driver.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c index 937134749e3e4..ad7a8f1353b89 100644 --- a/drivers/staging/dgnc/dgnc_driver.c +++ b/drivers/staging/dgnc/dgnc_driver.c @@ -6,12 +6,12 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -345,7 +345,7 @@ static int dgnc_init_pci(void) /* returns count (>= 0), or negative on error */ static int dgnc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) -{ +{ int rc; /* wake up and enable device */ @@ -516,7 +516,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id) APR(("memory allocation for board msgbuf failed\n")); return(-ENOMEM); } - + /* store the info for the board we've found */ brd->magic = DGNC_BOARD_MAGIC; brd->boardnum = dgnc_NumBoards; @@ -566,7 +566,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id) * PCI Local Address (i.e. "resource" number) space * 0 PLX Memory Mapped Config * 1 PLX I/O Mapped Config - * 2 I/O Mapped UARTs and Status + * 2 I/O Mapped UARTs and Status * 3 Memory Mapped VPD * 4 Memory Mapped UARTs and Status */ @@ -628,7 +628,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id) /* * This chip is set up 100% when we get to it. - * No need to enable global interrupts or anything. + * No need to enable global interrupts or anything. */ if (brd->bd_flags & BD_IS_PCI_EXPRESS) brd->dpatype = T_NEO_EXPRESS | T_PCIBUS; @@ -784,23 +784,23 @@ static void dgnc_do_remap(struct board_t *brd) /***************************************************************************** * * Function: -* +* * dgnc_poll_handler * * Author: * * Scott H Kilau -* +* * Parameters: * -* dummy -- ignored +* dummy -- ignored * * Return Values: * * none * -* Description: -* +* Description: +* * As each timer expires, it determines (a) whether the "transmit" * waiter needs to be woken up, and (b) whether the poller needs to * be rescheduled. -- GitLab From 4c1c56e62c655f8617082f10f642b74866416840 Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Wed, 21 Aug 2013 11:08:03 -0400 Subject: [PATCH 706/942] staging: dgnc: driver.h: removes trailing whitespace This patch removes trailing whitespace in the driver.h file. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_driver.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_driver.h b/drivers/staging/dgnc/dgnc_driver.h index 334faae506b14..84727a7151360 100644 --- a/drivers/staging/dgnc/dgnc_driver.h +++ b/drivers/staging/dgnc/dgnc_driver.h @@ -32,7 +32,7 @@ #include /* For irqreturn_t type */ #include "dgnc_types.h" /* Additional types needed by the Digi header files */ -#include "digi.h" /* Digi specific ioctl header */ +#include "digi.h" /* Digi specific ioctl header */ #include "dgnc_kcompat.h" /* Kernel 2.4/2.6 compat includes */ #include "dgnc_sysfs.h" /* Support for SYSFS */ @@ -54,7 +54,7 @@ */ #define PROCSTR "dgnc" /* /proc entries */ #define DEVSTR "/dev/dg/dgnc" /* /dev entries */ -#define DRVSTR "dgnc" /* Driver name string +#define DRVSTR "dgnc" /* Driver name string * displayed by APR */ #define APR(args) do { PRINTF_TO_KMEM(args); printk(DRVSTR": "); printk args; \ } while (0) @@ -111,7 +111,7 @@ #endif #if defined TRC_TO_KMEM -#define PRINTF_TO_KMEM(args) dgnc_tracef args +#define PRINTF_TO_KMEM(args) dgnc_tracef args #else //!defined TRC_TO_KMEM #define PRINTF_TO_KMEM(args) #endif @@ -273,7 +273,7 @@ struct board_ops { void (*send_immediate_char) (struct channel_t *ch, unsigned char); }; -/************************************************************************ +/************************************************************************ * Device flag definitions for bd_flags. ************************************************************************/ #define BD_IS_PCI_EXPRESS 0x0001 /* Is a PCI Express board */ @@ -369,7 +369,7 @@ struct board_t }; -/************************************************************************ +/************************************************************************ * Unit flag definitions for un_flags. ************************************************************************/ #define UN_ISOPEN 0x0001 /* Device is open */ @@ -389,7 +389,7 @@ struct board_t struct device; /************************************************************************ - * Structure for terminal or printer unit. + * Structure for terminal or printer unit. ************************************************************************/ struct un_t { int magic; /* Unit Magic Number. */ @@ -405,7 +405,7 @@ struct un_t { }; -/************************************************************************ +/************************************************************************ * Device flag definitions for ch_flags. ************************************************************************/ #define CH_PRON 0x0001 /* Printer on string */ @@ -425,7 +425,7 @@ struct un_t { #define CH_LOOPBACK 0x2000 /* Channel is in lookback mode */ #define CH_FLIPBUF_IN_USE 0x4000 /* Channel's flipbuf is in use */ #define CH_BAUD0 0x08000 /* Used for checking B0 transitions */ -#define CH_FORCED_STOP 0x20000 /* Output is forcibly stopped */ +#define CH_FORCED_STOP 0x20000 /* Output is forcibly stopped */ #define CH_FORCED_STOPI 0x40000 /* Input is forcibly stopped */ /* @@ -445,7 +445,7 @@ struct un_t { #define WQUEUESIZE (WQUEUEMASK + 1) -/************************************************************************ +/************************************************************************ * Channel information structure. ************************************************************************/ struct channel_t { -- GitLab From 013c951d540d9c231ba5c59ca982bd364967c748 Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Wed, 21 Aug 2013 11:08:04 -0400 Subject: [PATCH 707/942] staging: dgnc: kcompat.h: removes trailing whitespace This patch removes trailing whitespace in the kcompat.h file. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_kcompat.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_kcompat.h b/drivers/staging/dgnc/dgnc_kcompat.h index a0f58741cc39a..00f589a13ab9d 100644 --- a/drivers/staging/dgnc/dgnc_kcompat.h +++ b/drivers/staging/dgnc/dgnc_kcompat.h @@ -35,8 +35,8 @@ # endif -#if !defined(TTY_FLIPBUF_SIZE) -# define TTY_FLIPBUF_SIZE 512 +#if !defined(TTY_FLIPBUF_SIZE) +# define TTY_FLIPBUF_SIZE 512 #endif -- GitLab From 0986cda11eea9c97cddfabb0657688ad8dcaaf9a Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Wed, 21 Aug 2013 11:08:05 -0400 Subject: [PATCH 708/942] staging: dgnc: mgmt.c: removes trailing whitespace This patch removes trailing whitespace in the dgnc_mgmt.c file. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_mgmt.c | 38 ++++++++++++++++---------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_mgmt.c b/drivers/staging/dgnc/dgnc_mgmt.c index 200da36caa781..c86303985c1d5 100644 --- a/drivers/staging/dgnc/dgnc_mgmt.c +++ b/drivers/staging/dgnc/dgnc_mgmt.c @@ -17,23 +17,23 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * - * NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE! + * NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE! * * This is shared code between Digi's CVS archive and the * Linux Kernel sources. * Changing the source just for reformatting needlessly breaks * our CVS diff history. * - * Send any bug fixes/changes to: Eng.Linux at digi dot com. - * Thank you. + * Send any bug fixes/changes to: Eng.Linux at digi dot com. + * Thank you. * */ /************************************************************************ - * + * * This file implements the mgmt functionality for the * Neo and ClassicBoard based product lines. - * + * ************************************************************************ * $Id: dgnc_mgmt.c,v 1.2 2010/12/14 20:08:29 markh Exp $ */ @@ -57,10 +57,10 @@ static int dgnc_mgmt_in_use[MAXMGMTDEVICES]; /* - * dgnc_mgmt_open() + * dgnc_mgmt_open() * * Open the mgmt/downld/dpa device - */ + */ int dgnc_mgmt_open(struct inode *inode, struct file *file) { unsigned long lock_flags; @@ -68,23 +68,23 @@ int dgnc_mgmt_open(struct inode *inode, struct file *file) DPR_MGMT(("dgnc_mgmt_open start.\n")); - DGNC_LOCK(dgnc_global_lock, lock_flags); + DGNC_LOCK(dgnc_global_lock, lock_flags); /* mgmt device */ if (minor < MAXMGMTDEVICES) { /* Only allow 1 open at a time on mgmt device */ if (dgnc_mgmt_in_use[minor]) { - DGNC_UNLOCK(dgnc_global_lock, lock_flags); + DGNC_UNLOCK(dgnc_global_lock, lock_flags); return (-EBUSY); } dgnc_mgmt_in_use[minor]++; } else { - DGNC_UNLOCK(dgnc_global_lock, lock_flags); + DGNC_UNLOCK(dgnc_global_lock, lock_flags); return (-ENXIO); } - DGNC_UNLOCK(dgnc_global_lock, lock_flags); + DGNC_UNLOCK(dgnc_global_lock, lock_flags); DPR_MGMT(("dgnc_mgmt_open finish.\n")); @@ -96,7 +96,7 @@ int dgnc_mgmt_open(struct inode *inode, struct file *file) * dgnc_mgmt_close() * * Open the mgmt/dpa device - */ + */ int dgnc_mgmt_close(struct inode *inode, struct file *file) { unsigned long lock_flags; @@ -104,7 +104,7 @@ int dgnc_mgmt_close(struct inode *inode, struct file *file) DPR_MGMT(("dgnc_mgmt_close start.\n")); - DGNC_LOCK(dgnc_global_lock, lock_flags); + DGNC_LOCK(dgnc_global_lock, lock_flags); /* mgmt device */ if (minor < MAXMGMTDEVICES) { @@ -112,7 +112,7 @@ int dgnc_mgmt_close(struct inode *inode, struct file *file) dgnc_mgmt_in_use[minor] = 0; } } - DGNC_UNLOCK(dgnc_global_lock, lock_flags); + DGNC_UNLOCK(dgnc_global_lock, lock_flags); DPR_MGMT(("dgnc_mgmt_close finish.\n")); @@ -124,7 +124,7 @@ int dgnc_mgmt_close(struct inode *inode, struct file *file) * dgnc_mgmt_ioctl() * * ioctl the mgmt/dpa device - */ + */ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { @@ -144,12 +144,12 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg) */ struct digi_dinfo ddi; - DGNC_LOCK(dgnc_global_lock, lock_flags); + DGNC_LOCK(dgnc_global_lock, lock_flags); ddi.dinfo_nboards = dgnc_NumBoards; sprintf(ddi.dinfo_version, "%s", DG_PART); - DGNC_UNLOCK(dgnc_global_lock, lock_flags); + DGNC_UNLOCK(dgnc_global_lock, lock_flags); DPR_MGMT(("DIGI_GETDD returning numboards: %d version: %s\n", ddi.dinfo_nboards, ddi.dinfo_version)); @@ -179,7 +179,7 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg) di.info_bdnum = brd; - DGNC_LOCK(dgnc_Board[brd]->bd_lock, lock_flags); + DGNC_LOCK(dgnc_Board[brd]->bd_lock, lock_flags); di.info_bdtype = dgnc_Board[brd]->dpatype; di.info_bdstate = dgnc_Board[brd]->dpastatus; @@ -191,7 +191,7 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg) else di.info_nports = 0; - DGNC_UNLOCK(dgnc_Board[brd]->bd_lock, lock_flags); + DGNC_UNLOCK(dgnc_Board[brd]->bd_lock, lock_flags); DPR_MGMT(("DIGI_GETBD returning type: %x state: %x ports: %x size: %x\n", di.info_bdtype, di.info_bdstate, di.info_nports, di.info_physsize)); -- GitLab From 5ba5b89ab6e68b309d1fcabb4be0d0b521aff3db Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Wed, 21 Aug 2013 11:08:06 -0400 Subject: [PATCH 709/942] staging: dgnc: neo.c: removes trailing whitespace This patch removes trailing whitespace in the dgnc_neo.c file. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_neo.c | 46 ++++++++++++++++----------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_neo.c b/drivers/staging/dgnc/dgnc_neo.c index 9ac71497edf42..9ca143ec8dba2 100644 --- a/drivers/staging/dgnc/dgnc_neo.c +++ b/drivers/staging/dgnc/dgnc_neo.c @@ -6,12 +6,12 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. - * + * * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @@ -97,7 +97,7 @@ struct board_ops dgnc_neo_ops = { .get_uart_bytes_left = neo_get_uart_bytes_left, .send_immediate_char = neo_send_immediate_char }; - + static uint dgnc_offset_table[8] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 }; @@ -131,7 +131,7 @@ static inline void neo_set_cts_flow_control(struct channel_t *ch) efr |= (UART_17158_EFR_ECB | UART_17158_EFR_CTSDSR); - /* Turn off auto Xon flow control */ + /* Turn off auto Xon flow control */ efr &= ~(UART_17158_EFR_IXON); /* Why? Becuz Exar's spec says we have to zero it out before setting it */ @@ -487,7 +487,7 @@ static inline void neo_parse_isr(struct board_t *brd, uint port) DGNC_UNLOCK(ch->ch_lock, lock_flags); } DPR_INTR(("Port %d. XON detected in incoming data\n", port)); - } + } else if (cause == UART_17158_XOFF_DETECT) { if (!(brd->channels[port]->ch_flags & CH_STOP)) { DGNC_LOCK(ch->ch_lock, lock_flags); @@ -665,7 +665,7 @@ static void neo_param(struct tty_struct *tty) return; } - ch = un->un_ch; + ch = un->un_ch; if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) { return; } @@ -677,7 +677,7 @@ static void neo_param(struct tty_struct *tty) DPR_PARAM(("param start: tdev: %x cflags: %x oflags: %x iflags: %x\n", ch->ch_tun.un_dev, ch->ch_c_cflag, ch->ch_c_oflag, ch->ch_c_iflag)); - + /* * If baud rate is zero, flush queues, and set mval to drop DTR. */ @@ -754,7 +754,7 @@ static void neo_param(struct tty_struct *tty) jindex = baud; if ((iindex >= 0) && (iindex < 4) && (jindex >= 0) && (jindex < 16)) { - baud = bauds[iindex][jindex]; + baud = bauds[iindex][jindex]; } else { DPR_IOCTL(("baud indices were out of range (%d)(%d)", iindex, jindex)); @@ -787,12 +787,12 @@ static void neo_param(struct tty_struct *tty) lcr |= UART_LCR_EPAR; } - /* + /* * Not all platforms support mark/space parity, * so this will hide behind an ifdef. */ #ifdef CMSPAR - if (ch->ch_c_cflag & CMSPAR) + if (ch->ch_c_cflag & CMSPAR) lcr |= UART_LCR_SPAR; #endif @@ -886,7 +886,7 @@ static void neo_param(struct tty_struct *tty) neo_set_no_input_flow_control(ch); else neo_set_ixoff_flow_control(ch); - } + } else { neo_set_no_input_flow_control(ch); } @@ -1125,7 +1125,7 @@ static irqreturn_t neo_intr(int irq, void *voidbrd) */ neo_parse_isr(brd, port); continue; - + default: /* * The UART triggered us with a bogus interrupt type. @@ -1184,7 +1184,7 @@ static void neo_copy_data_from_uart_to_queue(struct channel_t *ch) uchar linestatus = 0; uchar error_mask = 0; int n = 0; - int total = 0; + int total = 0; ushort head; ushort tail; ulong lock_flags; @@ -1243,7 +1243,7 @@ static void neo_copy_data_from_uart_to_queue(struct channel_t *ch) */ total = min(total, qleft); - while (total > 0) { + while (total > 0) { /* * Grab the linestatus register, we need to check @@ -1414,7 +1414,7 @@ static int neo_drain(struct tty_struct *tty, uint seconds) return (-ENXIO); } - ch = un->un_ch; + ch = un->un_ch; if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) { return (-ENXIO); } @@ -1443,7 +1443,7 @@ static int neo_drain(struct tty_struct *tty, uint seconds) return (rc); } - + /* * Flush the WRITE FIFO on the Neo. @@ -1727,8 +1727,8 @@ static void neo_parse_modem(struct channel_t *ch, uchar signals) ch->ch_portnum, !!((ch->ch_mistat | ch->ch_mostat) & UART_MCR_DTR), !!((ch->ch_mistat | ch->ch_mostat) & UART_MCR_RTS), - !!((ch->ch_mistat | ch->ch_mostat) & UART_MSR_CTS), - !!((ch->ch_mistat | ch->ch_mostat) & UART_MSR_DSR), + !!((ch->ch_mistat | ch->ch_mostat) & UART_MSR_CTS), + !!((ch->ch_mistat | ch->ch_mostat) & UART_MSR_DSR), !!((ch->ch_mistat | ch->ch_mostat) & UART_MSR_RI), !!((ch->ch_mistat | ch->ch_mostat) & UART_MSR_DCD))); } @@ -1792,7 +1792,7 @@ static void neo_uart_init(struct channel_t *ch) writeb(0, &ch->ch_neo_uart->ier); writeb(0, &ch->ch_neo_uart->efr); writeb(UART_EFR_ECB, &ch->ch_neo_uart->efr); - + /* Clear out UART and FIFO */ readb(&ch->ch_neo_uart->txrx); @@ -1829,7 +1829,7 @@ static uint neo_get_uart_bytes_left(struct channel_t *ch) /* We must cache the LSR as some of the bits get reset once read... */ ch->ch_cached_lsr |= lsr; - + /* Determine whether the Transmitter is empty or not */ if (!(lsr & UART_LSR_TEMT)) { if (ch->ch_flags & CH_TX_FIFO_EMPTY) { @@ -1885,7 +1885,7 @@ static void neo_send_break(struct channel_t *ch, int msecs) /* * neo_send_immediate_char. * - * Sends a specific character as soon as possible to the UART, + * Sends a specific character as soon as possible to the UART, * jumping over any bytes that might be in the write queue. * * The channel lock MUST be held by the calling function. -- GitLab From bae4f6886f566a1e064c3168931229e60204da9b Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Wed, 21 Aug 2013 11:08:07 -0400 Subject: [PATCH 710/942] staging: dgnc: neo.h: removes trailing whitespace This patch removes trailing whitespace in the neo.h file. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_neo.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_neo.h b/drivers/staging/dgnc/dgnc_neo.h index ffb42099b9fd3..f7f569b3de933 100644 --- a/drivers/staging/dgnc/dgnc_neo.h +++ b/drivers/staging/dgnc/dgnc_neo.h @@ -26,12 +26,12 @@ #include "dgnc_types.h" #include "dgnc_driver.h" -/************************************************************************ +/************************************************************************ * Per channel/port NEO UART structure * ************************************************************************ * Base Structure Entries Usage Meanings to Host * * * - * W = read write R = read only * + * W = read write R = read only * * U = Unused. * ************************************************************************/ @@ -46,7 +46,7 @@ struct neo_uart_struct { volatile uchar spr; /* WR SPR - Scratch Pad Reg */ volatile uchar fctr; /* WR FCTR - Feature Control Reg */ volatile uchar efr; /* WR EFR - Enhanced Function Reg */ - volatile uchar tfifo; /* WR TXCNT/TXTRG - Transmit FIFO Reg */ + volatile uchar tfifo; /* WR TXCNT/TXTRG - Transmit FIFO Reg */ volatile uchar rfifo; /* WR RXCNT/RXTRG - Recieve FIFO Reg */ volatile uchar xoffchar1; /* WR XOFF 1 - XOff Character 1 Reg */ volatile uchar xoffchar2; /* WR XOFF 2 - XOff Character 2 Reg */ @@ -74,7 +74,7 @@ struct neo_uart_struct { #define NEO_EEREG 0x8E /* offset to EEPROM control reg */ -#define NEO_VPD_IMAGESIZE 0x40 /* size of image to read from EEPROM in words */ +#define NEO_VPD_IMAGESIZE 0x40 /* size of image to read from EEPROM in words */ #define NEO_VPD_IMAGEBYTES (NEO_VPD_IMAGESIZE * 2) /* @@ -111,8 +111,8 @@ struct neo_uart_struct { #define UART_17158_FCTR_BIT7 0x80 /* 17158 TX/RX memmapped buffer offsets */ -#define UART_17158_RX_FIFOSIZE 64 -#define UART_17158_TX_FIFOSIZE 64 +#define UART_17158_RX_FIFOSIZE 64 +#define UART_17158_TX_FIFOSIZE 64 /* 17158 Extended IIR's */ #define UART_17158_IIR_RDI_TIMEOUT 0x0C /* Receiver data TIMEOUT */ -- GitLab From 7a97deb209485cb6a4d8962e4b617e74f5f8dcb4 Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Wed, 21 Aug 2013 11:08:08 -0400 Subject: [PATCH 711/942] staging: dgnc: sysfs.c: removes trailing whitespace This patch removes trailing whitespace in the sysfs.c file. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_sysfs.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_sysfs.c b/drivers/staging/dgnc/dgnc_sysfs.c index f9c167e6e6e2a..1ed456ec53498 100644 --- a/drivers/staging/dgnc/dgnc_sysfs.c +++ b/drivers/staging/dgnc/dgnc_sysfs.c @@ -1,7 +1,7 @@ /* * Copyright 2004 Digi International (www.digi.com) * Scott H Kilau - * + * * 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, or (at your option) @@ -9,14 +9,14 @@ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * + * * NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE! * * This is shared code between Digi's CVS archive and the @@ -28,8 +28,8 @@ * Thank you. * * - * - * $Id: dgnc_sysfs.c,v 1.1.1.1 2009/05/20 12:19:19 markh Exp $ + * + * $Id: dgnc_sysfs.c,v 1.1.1.1 2009/05/20 12:19:19 markh Exp $ */ @@ -41,7 +41,7 @@ #include #include #include - + #include "dgnc_driver.h" #include "dgnc_mgmt.h" @@ -129,7 +129,7 @@ void dgnc_create_driver_sysfiles(struct pci_driver *dgnc_driver) rc |= driver_create_file(driverfs, &driver_attr_boards); rc |= driver_create_file(driverfs, &driver_attr_maxboards); rc |= driver_create_file(driverfs, &driver_attr_debug); - rc |= driver_create_file(driverfs, &driver_attr_rawreadok); + rc |= driver_create_file(driverfs, &driver_attr_rawreadok); rc |= driver_create_file(driverfs, &driver_attr_pollrate); rc |= driver_create_file(driverfs, &driver_attr_pollcounter); rc |= driver_create_file(driverfs, &driver_attr_state); @@ -720,7 +720,7 @@ static struct attribute *dgnc_sysfs_tty_entries[] = { &dev_attr_msignals.attr, &dev_attr_iflag.attr, &dev_attr_cflag.attr, - &dev_attr_oflag.attr, + &dev_attr_oflag.attr, &dev_attr_lflag.attr, &dev_attr_digi_flag.attr, &dev_attr_rxcount.attr, @@ -751,7 +751,7 @@ void dgnc_create_tty_sysfs(struct un_t *un, struct device *c) } - + void dgnc_remove_tty_sysfs(struct device *c) { sysfs_remove_group(&c->kobj, &dgnc_tty_attribute_group); -- GitLab From abbb82df2c2edd06534948d957a9aca9e61b4b24 Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Wed, 21 Aug 2013 11:08:09 -0400 Subject: [PATCH 712/942] staging: dgnc: sysfs.h: removes trailing whitespace This patch removes trailing whitespace in the dgnc_sysfs.h file. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_sysfs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/dgnc/dgnc_sysfs.h b/drivers/staging/dgnc/dgnc_sysfs.h index fe991103668c7..4b87ce1cc7a24 100644 --- a/drivers/staging/dgnc/dgnc_sysfs.h +++ b/drivers/staging/dgnc/dgnc_sysfs.h @@ -32,7 +32,7 @@ struct un_t; struct pci_driver; struct class_device; -extern void dgnc_create_ports_sysfiles(struct board_t *bd); +extern void dgnc_create_ports_sysfiles(struct board_t *bd); extern void dgnc_remove_ports_sysfiles(struct board_t *bd); extern void dgnc_create_driver_sysfiles(struct pci_driver *); -- GitLab From cfa4ccc9ab20a80079e92026379e3093a17ca9c0 Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Wed, 21 Aug 2013 11:08:10 -0400 Subject: [PATCH 713/942] staging: dgnc: trace.c: removes trailing whitespace This patch removes trailing whitespace in the dgnc_trace.c file. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_trace.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_trace.c b/drivers/staging/dgnc/dgnc_trace.c index e613a28cc8204..0f00ddcdeeea1 100644 --- a/drivers/staging/dgnc/dgnc_trace.c +++ b/drivers/staging/dgnc/dgnc_trace.c @@ -17,15 +17,15 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * - * NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE! + * NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE! * * This is shared code between Digi's CVS archive and the * Linux Kernel sources. * Changing the source just for reformatting needlessly breaks * our CVS diff history. * - * Send any bug fixes/changes to: Eng.Linux at digi dot com. - * Thank you. + * Send any bug fixes/changes to: Eng.Linux at digi dot com. + * Thank you. * */ @@ -107,16 +107,16 @@ void dgnc_tracef(const char *fmt, ...) dgnc_trcbufi = 0; initd++; - printk("dgnc: tracing enabled - " TRC_DTRC + printk("dgnc: tracing enabled - " TRC_DTRC " 0x%lx 0x%x\n", - (unsigned long)dgnc_trcbuf, + (unsigned long)dgnc_trcbuf, dgnc_trcbuf_size); } # if defined(TRC_ON_OVERFLOW_WRAP_AROUND) /* * This is the less CPU-intensive way to do things. We simply - * wrap around before we fall off the end of the buffer. A + * wrap around before we fall off the end of the buffer. A * tilde (~) demarcates the current end of the trace. * * This method should be used if you are concerned about race @@ -131,14 +131,14 @@ void dgnc_tracef(const char *fmt, ...) dgnc_trcbufi = 0; } - strcpy(&dgnc_trcbuf[dgnc_trcbufi], buf); + strcpy(&dgnc_trcbuf[dgnc_trcbufi], buf); dgnc_trcbufi += lenbuf; dgnc_trcbuf[dgnc_trcbufi] = '~'; # elif defined(TRC_ON_OVERFLOW_SHIFT_BUFFER) /* * This is the more CPU-intensive way to do things. If we - * venture into the last 1/8 of the buffer, we shift the + * venture into the last 1/8 of the buffer, we shift the * last 7/8 of the buffer forward, wiping out the first 1/8. * Advantage: No wrap-around, only truncation from the * beginning. -- GitLab From 8b07d521c6844f577abd0ae1d30ead5401f5f47d Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Wed, 21 Aug 2013 11:08:11 -0400 Subject: [PATCH 714/942] staging: dgnc: tty.c: removes trailing whitespace This patch removes trailing whitespace in the dgnc_tty.c file. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_tty.c | 178 ++++++++++++++++---------------- 1 file changed, 89 insertions(+), 89 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c index 2acf9348388c3..feb0124a84179 100644 --- a/drivers/staging/dgnc/dgnc_tty.c +++ b/drivers/staging/dgnc/dgnc_tty.c @@ -17,22 +17,22 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * - * NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE! + * NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE! * * This is shared code between Digi's CVS archive and the * Linux Kernel sources. * Changing the source just for reformatting needlessly breaks * our CVS diff history. * - * Send any bug fixes/changes to: Eng.Linux at digi dot com. - * Thank you. + * Send any bug fixes/changes to: Eng.Linux at digi dot com. + * Thank you. */ /************************************************************************ - * + * * This file implements the tty driver functionality for the * Neo and ClassicBoard PCI based product lines. - * + * ************************************************************************ * * $Id: dgnc_tty.c,v 1.5 2013/04/30 19:18:30 markh Exp $ @@ -165,11 +165,11 @@ static const struct tty_operations dgnc_tty_ops = { }; /************************************************************************ - * + * * TTY Initialization/Cleanup Functions - * + * ************************************************************************/ - + /* * dgnc_tty_preinit() * @@ -213,7 +213,7 @@ int dgnc_tty_register(struct board_t *brd) memset(&brd->PrintDriver, 0, sizeof(struct tty_driver)); brd->SerialDriver.magic = TTY_DRIVER_MAGIC; - + snprintf(brd->SerialName, MAXTTYNAMELEN, "tty_dgnc_%d_", brd->boardnum); brd->SerialDriver.name = brd->SerialName; @@ -221,15 +221,15 @@ int dgnc_tty_register(struct board_t *brd) brd->SerialDriver.major = 0; brd->SerialDriver.minor_start = 0; brd->SerialDriver.num = brd->maxports; - brd->SerialDriver.type = TTY_DRIVER_TYPE_SERIAL; - brd->SerialDriver.subtype = SERIAL_TYPE_NORMAL; + brd->SerialDriver.type = TTY_DRIVER_TYPE_SERIAL; + brd->SerialDriver.subtype = SERIAL_TYPE_NORMAL; brd->SerialDriver.init_termios = DgncDefaultTermios; brd->SerialDriver.driver_name = DRVSTR; brd->SerialDriver.flags = (TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_HARDWARE_BREAK); - /* + /* * The kernel wants space to store pointers to - * tty_struct's and termios's. + * tty_struct's and termios's. */ brd->SerialDriver.ttys = dgnc_driver_kzmalloc(brd->maxports * sizeof(struct tty_struct *), GFP_KERNEL); if (!brd->SerialDriver.ttys) @@ -279,7 +279,7 @@ int dgnc_tty_register(struct board_t *brd) brd->PrintDriver.major = brd->SerialDriver.major; brd->PrintDriver.minor_start = 0x80; brd->PrintDriver.num = brd->maxports; - brd->PrintDriver.type = TTY_DRIVER_TYPE_SERIAL; + brd->PrintDriver.type = TTY_DRIVER_TYPE_SERIAL; brd->PrintDriver.subtype = SERIAL_TYPE_NORMAL; brd->PrintDriver.init_termios = DgncDefaultTermios; brd->PrintDriver.driver_name = DRVSTR; @@ -459,7 +459,7 @@ void dgnc_tty_post_uninit(void) * dgnc_tty_uninit() * * Uninitialize the TTY portion of this driver. Free all memory and - * resources. + * resources. */ void dgnc_tty_uninit(struct board_t *brd) { @@ -567,7 +567,7 @@ void dgnc_sniff_nowait_nolock(struct channel_t *ch, uchar *text, uchar *buf, int if (n == 0) { return; } - + /* * Copy as much data as will fit. */ @@ -630,7 +630,7 @@ static void dgnc_wmove(struct channel_t *ch, char *buf, uint n) if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) return; - + head = ch->ch_w_head & WQUEUEMASK; /* @@ -641,7 +641,7 @@ static void dgnc_wmove(struct channel_t *ch, char *buf, uint n) remain = WQUEUESIZE - head; if (n >= remain) { - n -= remain; + n -= remain; memcpy(ch->ch_wqueue + head, buf, remain); head = 0; buf += remain; @@ -666,9 +666,9 @@ static void dgnc_wmove(struct channel_t *ch, char *buf, uint n) /*======================================================================= * * dgnc_input - Process received data. - * + * * ch - Pointer to channel structure. - * + * *=======================================================================*/ void dgnc_input(struct channel_t *ch) { @@ -697,8 +697,8 @@ void dgnc_input(struct channel_t *ch) DGNC_LOCK(ch->ch_lock, lock_flags); - /* - * Figure the number of characters in the buffer. + /* + * Figure the number of characters in the buffer. * Exit immediately if none. */ rmask = RQUEUEMASK; @@ -717,7 +717,7 @@ void dgnc_input(struct channel_t *ch) * If the device is not open, or CREAD is off, * flush input data and return immediately. */ - if (!tp || (tp->magic != TTY_MAGIC) || !(ch->ch_tun.un_flags & UN_ISOPEN) || + if (!tp || (tp->magic != TTY_MAGIC) || !(ch->ch_tun.un_flags & UN_ISOPEN) || !(tp->termios.c_cflag & CREAD) || (ch->ch_tun.un_flags & UN_CLOSING)) { DPR_READ(("input. dropping %d bytes on port %d...\n", data_len, ch->ch_portnum)); @@ -778,7 +778,7 @@ void dgnc_input(struct channel_t *ch) if (!ld->ops->receive_buf) { ch->ch_r_head = ch->ch_r_tail; len = 0; - } + } } if (len <= 0) { @@ -793,7 +793,7 @@ void dgnc_input(struct channel_t *ch) * * The flip buffers in the tty structure are no longer exposed, * and probably will be going away eventually. - * + * * If we are completely raw, we don't need to go through a lot * of the tty layers that exist. * In this case, we take the shortest and fastest route we @@ -818,7 +818,7 @@ void dgnc_input(struct channel_t *ch) break; /* - * If conditions are such that ld needs to see all + * If conditions are such that ld needs to see all * UART errors, we will have to walk each character * and error byte and send them to the buffer one at * a time. @@ -862,9 +862,9 @@ void dgnc_input(struct channel_t *ch) } -/************************************************************************ +/************************************************************************ * Determines when CARRIER changes state and takes appropriate - * action. + * action. ************************************************************************/ void dgnc_carrier(struct channel_t *ch) { @@ -872,7 +872,7 @@ void dgnc_carrier(struct channel_t *ch) int virt_carrier = 0; int phys_carrier = 0; - + DPR_CARR(("dgnc_carrier called...\n")); if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) @@ -890,11 +890,11 @@ void dgnc_carrier(struct channel_t *ch) if (ch->ch_digi.digi_flags & DIGI_FORCEDCD) { virt_carrier = 1; - } + } if (ch->ch_c_cflag & CLOCAL) { virt_carrier = 1; - } + } DPR_CARR(("DCD: physical: %d virt: %d\n", phys_carrier, virt_carrier)); @@ -941,7 +941,7 @@ void dgnc_carrier(struct channel_t *ch) * "make pretend that carrier is there". */ if ((virt_carrier == 0) && ((ch->ch_flags & CH_CD) != 0) && - (phys_carrier == 0)) + (phys_carrier == 0)) { /* @@ -964,7 +964,7 @@ void dgnc_carrier(struct channel_t *ch) tty_hangup(ch->ch_tun.un_tty); } - if (ch->ch_pun.un_open_count > 0) { + if (ch->ch_pun.un_open_count > 0) { DPR_CARR(("Sending pr hangup\n")); tty_hangup(ch->ch_pun.un_tty); } @@ -975,7 +975,7 @@ void dgnc_carrier(struct channel_t *ch) */ if (virt_carrier == 1) ch->ch_flags |= CH_FCAR; - else + else ch->ch_flags &= ~CH_FCAR; if (phys_carrier == 1) @@ -991,7 +991,7 @@ static void dgnc_set_custom_speed(struct channel_t *ch, uint newrate) { int testdiv; int testrate_high; - int testrate_low; + int testrate_low; int deltahigh; int deltalow; @@ -1016,7 +1016,7 @@ static void dgnc_set_custom_speed(struct channel_t *ch, uint newrate) * If we try to figure out what rate the board would use * with the test divisor, it will be either equal or higher * than the requested baud rate. If we then determine the - * rate with a divisor one higher, we will get the next lower + * rate with a divisor one higher, we will get the next lower * supported rate below the requested. */ testrate_high = ch->ch_bd->bd_dividend / testdiv; @@ -1044,7 +1044,7 @@ static void dgnc_set_custom_speed(struct channel_t *ch, uint newrate) break; } - + ch->ch_custom_speed = newrate; return; @@ -1250,9 +1250,9 @@ void dgnc_wakeup_writes(struct channel_t *ch) /************************************************************************ - * + * * TTY Entry points and helper functions - * + * ************************************************************************/ /* @@ -1453,7 +1453,7 @@ static int dgnc_tty_open(struct tty_struct *tty, struct file *file) dgnc_carrier(ch); - /* + /* * follow protocol for opening port */ @@ -1478,13 +1478,13 @@ static int dgnc_tty_open(struct tty_struct *tty, struct file *file) } -/* +/* * dgnc_block_til_ready() * * Wait for DCD, if needed. */ static int dgnc_block_til_ready(struct tty_struct *tty, struct file *file, struct channel_t *ch) -{ +{ int retval = 0; struct un_t *un = NULL; ulong lock_flags; @@ -1529,7 +1529,7 @@ static int dgnc_block_til_ready(struct tty_struct *tty, struct file *file, struc * If either unit is in the middle of the fragile part of close, * we just cannot touch the channel safely. * Go back to sleep, knowing that when the channel can be - * touched safely, the close routine will signal the + * touched safely, the close routine will signal the * ch_wait_flags to wake us back up. */ if (!((ch->ch_tun.un_flags | ch->ch_pun.un_flags) & UN_CLOSING)) { @@ -1638,7 +1638,7 @@ static int dgnc_block_til_ready(struct tty_struct *tty, struct file *file, struc * dgnc_tty_hangup() * * Hangup the port. Like a close, but don't wait for output to drain. - */ + */ static void dgnc_tty_hangup(struct tty_struct *tty) { struct un_t *un; @@ -1709,7 +1709,7 @@ static void dgnc_tty_close(struct tty_struct *tty, struct file *file) */ APR(("tty->count is 1, un open count is %d\n", un->un_open_count)); un->un_open_count = 1; - } + } if (--un->un_open_count < 0) { APR(("bad serial port open count of %d\n", un->un_open_count)); @@ -1782,7 +1782,7 @@ static void dgnc_tty_close(struct tty_struct *tty, struct file *file) bd->bd_ops->assert_modem_signals(ch); /* - * Go to sleep to ensure RTS/DTR + * Go to sleep to ensure RTS/DTR * have been dropped for modems to see it. */ if (ch->ch_close_delay) { @@ -1871,21 +1871,21 @@ static int dgnc_tty_chars_in_buffer(struct tty_struct *tty) chars = thead - ttail + WQUEUESIZE; } - DPR_WRITE(("dgnc_tty_chars_in_buffer. Port: %x - %d (head: %d tail: %d)\n", + DPR_WRITE(("dgnc_tty_chars_in_buffer. Port: %x - %d (head: %d tail: %d)\n", ch->ch_portnum, chars, thead, ttail)); return(chars); } -/* +/* * dgnc_maxcps_room * * Reduces bytes_available to the max number of characters * that can be sent currently given the maxcps value, and * returns the new bytes_available. This only affects printer * output. - */ + */ static int dgnc_maxcps_room(struct tty_struct *tty, int bytes_available) { struct channel_t *ch = NULL; @@ -1926,7 +1926,7 @@ static int dgnc_maxcps_room(struct tty_struct *tty, int bytes_available) } else { /* no room in the buffer */ - cps_limit = 0; + cps_limit = 0; } bytes_available = min(cps_limit, bytes_available); @@ -1940,7 +1940,7 @@ static int dgnc_maxcps_room(struct tty_struct *tty, int bytes_available) * dgnc_tty_write_room() * * Return space available in Tx buffer - */ + */ static int dgnc_tty_write_room(struct tty_struct *tty) { struct channel_t *ch = NULL; @@ -1975,7 +1975,7 @@ static int dgnc_tty_write_room(struct tty_struct *tty) ret = dgnc_maxcps_room(tty, ret); /* - * If we are printer device, leave space for + * If we are printer device, leave space for * possibly both the on and off strings. */ if (un->un_type == DGNC_PRINT) { @@ -1992,7 +1992,7 @@ static int dgnc_tty_write_room(struct tty_struct *tty) ret = 0; DGNC_UNLOCK(ch->ch_lock, lock_flags); - + DPR_WRITE(("dgnc_tty_write_room - %d tail: %d head: %d\n", ret, tail, head)); return(ret); @@ -2003,7 +2003,7 @@ static int dgnc_tty_write_room(struct tty_struct *tty) * dgnc_tty_put_char() * * Put a character into ch->ch_buf - * + * * - used by the line discipline for OPOST processing */ static int dgnc_tty_put_char(struct tty_struct *tty, unsigned char c) @@ -2118,7 +2118,7 @@ static int dgnc_tty_write(struct tty_struct *tty, /* * If there is nothing left to copy, or I can't handle any more data, leave. - */ + */ if (count <= 0) { DGNC_UNLOCK(ch->ch_lock, lock_flags); return(0); @@ -2330,11 +2330,11 @@ static int dgnc_tty_tiocmset(struct tty_struct *tty, struct file *file, if (set & TIOCM_RTS) { ch->ch_mostat |= UART_MCR_RTS; - } + } if (set & TIOCM_DTR) { ch->ch_mostat |= UART_MCR_DTR; - } + } if (clear & TIOCM_RTS) { ch->ch_mostat &= ~(UART_MCR_RTS); @@ -2441,7 +2441,7 @@ static void dgnc_tty_wait_until_sent(struct tty_struct *tty, int timeout) return; } return; -} +} /* @@ -2481,7 +2481,7 @@ static void dgnc_tty_send_xchar(struct tty_struct *tty, char c) DPR_IOCTL(("dgnc_tty_send_xchar finish\n")); printk("dgnc_tty_send_xchar finish\n"); return; -} +} @@ -2648,7 +2648,7 @@ static int dgnc_set_modem_info(struct tty_struct *tty, unsigned int command, uns /* - * dgnc_tty_digigeta() + * dgnc_tty_digigeta() * * Ioctl to get the information for ditty. * @@ -2690,7 +2690,7 @@ static int dgnc_tty_digigeta(struct tty_struct *tty, struct digi_t __user *retin /* - * dgnc_tty_digiseta() + * dgnc_tty_digiseta() * * Ioctl to set the information for ditty. * @@ -2747,10 +2747,10 @@ static int dgnc_tty_digiseta(struct tty_struct *tty, struct digi_t __user *new_i memcpy(&ch->ch_digi, &new_digi, sizeof(struct digi_t)); - if (ch->ch_digi.digi_maxcps < 1) + if (ch->ch_digi.digi_maxcps < 1) ch->ch_digi.digi_maxcps = 1; - if (ch->ch_digi.digi_maxcps > 10000) + if (ch->ch_digi.digi_maxcps > 10000) ch->ch_digi.digi_maxcps = 10000; if (ch->ch_digi.digi_bufsize < 10) @@ -2831,7 +2831,7 @@ static void dgnc_tty_throttle(struct tty_struct *tty) un = tty->driver_data; if (!un || un->magic != DGNC_UNIT_MAGIC) return; - + ch = un->un_ch; if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) return; @@ -2860,7 +2860,7 @@ static void dgnc_tty_unthrottle(struct tty_struct *tty) un = tty->driver_data; if (!un || un->magic != DGNC_UNIT_MAGIC) return; - + ch = un->un_ch; if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) return; @@ -2890,7 +2890,7 @@ static void dgnc_tty_start(struct tty_struct *tty) un = tty->driver_data; if (!un || un->magic != DGNC_UNIT_MAGIC) return; - + ch = un->un_ch; if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) return; @@ -2924,7 +2924,7 @@ static void dgnc_tty_stop(struct tty_struct *tty) un = tty->driver_data; if (!un || un->magic != DGNC_UNIT_MAGIC) return; - + ch = un->un_ch; if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) return; @@ -2945,7 +2945,7 @@ static void dgnc_tty_stop(struct tty_struct *tty) } -/* +/* * dgnc_tty_flush_chars() * * Flush the cook buffer @@ -2971,7 +2971,7 @@ static void dgnc_tty_flush_chars(struct tty_struct *tty) un = tty->driver_data; if (!un || un->magic != DGNC_UNIT_MAGIC) return; - + ch = un->un_ch; if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) return; @@ -2995,7 +2995,7 @@ static void dgnc_tty_flush_chars(struct tty_struct *tty) /* * dgnc_tty_flush_buffer() - * + * * Flush Tx buffer (make in == out) */ static void dgnc_tty_flush_buffer(struct tty_struct *tty) @@ -3010,7 +3010,7 @@ static void dgnc_tty_flush_buffer(struct tty_struct *tty) un = tty->driver_data; if (!un || un->magic != DGNC_UNIT_MAGIC) return; - + ch = un->un_ch; if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) return; @@ -3048,7 +3048,7 @@ static void dgnc_tty_flush_buffer(struct tty_struct *tty) * The IOCTL function and all of its helpers * *****************************************************************************/ - + /* * dgnc_tty_ioctl() * @@ -3079,7 +3079,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, if (!bd || bd->magic != DGNC_BOARD_MAGIC) return (-ENODEV); - DPR_IOCTL(("dgnc_tty_ioctl start on port %d - cmd %s (%x), arg %lx\n", + DPR_IOCTL(("dgnc_tty_ioctl start on port %d - cmd %s (%x), arg %lx\n", ch->ch_portnum, dgnc_ioctl_name(cmd), cmd, arg)); DGNC_LOCK(ch->ch_lock, lock_flags); @@ -3096,7 +3096,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, case TCSBRK: /* - * TCSBRK is SVID version: non-zero arg --> no break + * TCSBRK is SVID version: non-zero arg --> no break * this behaviour is exploited by tcdrain(). * * According to POSIX.1 spec (7.2.2.1.2) breaks should be @@ -3124,7 +3124,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, DGNC_UNLOCK(ch->ch_lock, lock_flags); - DPR_IOCTL(("dgnc_tty_ioctl finish on port %d - cmd %s (%x), arg %lx\n", + DPR_IOCTL(("dgnc_tty_ioctl finish on port %d - cmd %s (%x), arg %lx\n", ch->ch_portnum, dgnc_ioctl_name(cmd), cmd, arg)); return(0); @@ -3154,7 +3154,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, DGNC_UNLOCK(ch->ch_lock, lock_flags); - DPR_IOCTL(("dgnc_tty_ioctl finish on port %d - cmd %s (%x), arg %lx\n", + DPR_IOCTL(("dgnc_tty_ioctl finish on port %d - cmd %s (%x), arg %lx\n", ch->ch_portnum, dgnc_ioctl_name(cmd), cmd, arg)); return(0); @@ -3178,7 +3178,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, DGNC_UNLOCK(ch->ch_lock, lock_flags); - DPR_IOCTL(("dgnc_tty_ioctl finish on port %d - cmd %s (%x), arg %lx\n", + DPR_IOCTL(("dgnc_tty_ioctl finish on port %d - cmd %s (%x), arg %lx\n", ch->ch_portnum, dgnc_ioctl_name(cmd), cmd, arg)); return(0); @@ -3208,7 +3208,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, DGNC_UNLOCK(ch->ch_lock, lock_flags); return(0); - + case TIOCMGET: DGNC_UNLOCK(ch->ch_lock, lock_flags); return(dgnc_get_modem_info(ch, uarg)); @@ -3222,8 +3222,8 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, /* * Here are any additional ioctl's that we want to implement */ - - case TCFLSH: + + case TCFLSH: /* * The linux tty driver doesn't have a flush * input routine for the driver, assuming all backed @@ -3232,7 +3232,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, * act on the ioctl, but then lie and say we didn't * so the line discipline will process the flush * also. - */ + */ rc = tty_check_change(tty); if (rc) { DGNC_UNLOCK(ch->ch_lock, lock_flags); @@ -3264,7 +3264,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, } } - /* pretend we didn't recognize this IOCTL */ + /* pretend we didn't recognize this IOCTL */ DGNC_UNLOCK(ch->ch_lock, lock_flags); return(-ENOIOCTLCMD); case TCSETSF: @@ -3295,7 +3295,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, return(-EINTR); } - DPR_IOCTL(("dgnc_tty_ioctl finish on port %d - cmd %s (%x), arg %lx\n", + DPR_IOCTL(("dgnc_tty_ioctl finish on port %d - cmd %s (%x), arg %lx\n", ch->ch_portnum, dgnc_ioctl_name(cmd), cmd, arg)); /* pretend we didn't recognize this */ @@ -3311,7 +3311,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, } /* pretend we didn't recognize this */ - return(-ENOIOCTLCMD); + return(-ENOIOCTLCMD); case TCXONC: DGNC_UNLOCK(ch->ch_lock, lock_flags); @@ -3345,7 +3345,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, case DIGI_SETA: DGNC_UNLOCK(ch->ch_lock, lock_flags); return(dgnc_tty_digiseta(tty, uarg)); - + case DIGI_LOOPBACK: { uint loopback = 0; @@ -3356,7 +3356,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, return(rc); DGNC_LOCK(ch->ch_lock, lock_flags); - /* Enable/disable internal loopback for this port */ + /* Enable/disable internal loopback for this port */ if (loopback) ch->ch_flags |= CH_LOOPBACK; else @@ -3530,7 +3530,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, DGNC_UNLOCK(ch->ch_lock, lock_flags); DPR_IOCTL(("dgnc_tty_ioctl - in default\n")); - DPR_IOCTL(("dgnc_tty_ioctl end - cmd %s (%x), arg %lx\n", + DPR_IOCTL(("dgnc_tty_ioctl end - cmd %s (%x), arg %lx\n", dgnc_ioctl_name(cmd), cmd, arg)); return(-ENOIOCTLCMD); @@ -3538,8 +3538,8 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, DGNC_UNLOCK(ch->ch_lock, lock_flags); - DPR_IOCTL(("dgnc_tty_ioctl end - cmd %s (%x), arg %lx\n", + DPR_IOCTL(("dgnc_tty_ioctl end - cmd %s (%x), arg %lx\n", dgnc_ioctl_name(cmd), cmd, arg)); - + return(0); } -- GitLab From b8f5472a69d114e5aee9036a7e57e4990866b1fb Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Wed, 21 Aug 2013 11:08:12 -0400 Subject: [PATCH 715/942] staging: dgnc: digi.h: removes trailing whitespace This patch removes trailing whitespace in the digi.h file. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/digi.h | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/staging/dgnc/digi.h b/drivers/staging/dgnc/digi.h index ab903823ab072..8027eab969004 100644 --- a/drivers/staging/dgnc/digi.h +++ b/drivers/staging/dgnc/digi.h @@ -43,7 +43,7 @@ #define TIOCMODG ('d'<<8) | 250 /* get modem ctrl state */ #define TIOCMODS ('d'<<8) | 251 /* set modem ctrl state */ -#ifndef TIOCM_LE +#ifndef TIOCM_LE #define TIOCM_LE 0x01 /* line enable */ #define TIOCM_DTR 0x02 /* data terminal ready */ #define TIOCM_RTS 0x04 /* request to send */ @@ -122,7 +122,7 @@ struct digiflow_t { #endif /************************************************************************ - * Values for digi_flags + * Values for digi_flags ************************************************************************/ #define DIGI_IXON 0x0001 /* Handle IXON in the FEP */ #define DIGI_FAST 0x0002 /* Fast baud rates */ @@ -193,8 +193,8 @@ struct rw_t { #define COMXI_TYPE 5 /* Board type at the designated port is a COM/Xi */ /* Non-Zero Result codes. */ -#define RESULT_NOBDFND 1 /* A Digi product at that port is not config installed */ -#define RESULT_NODESCT 2 /* A memory descriptor was not obtainable */ +#define RESULT_NOBDFND 1 /* A Digi product at that port is not config installed */ +#define RESULT_NODESCT 2 /* A memory descriptor was not obtainable */ #define RESULT_NOOSSIG 3 /* FEP/OS signature was not detected on the board */ #define RESULT_TOOSML 4 /* Too small an area to shrink. */ #define RESULT_NOCHAN 5 /* Channel structure for the board was not found */ @@ -205,7 +205,7 @@ struct shrink_buf_struct { unsigned int shrink_buf_bseg; /* Amount of board memory */ unsigned int shrink_buf_hseg; /* '186 Begining of Dual-Port */ - unsigned int shrink_buf_lseg; /* '186 Begining of freed memory */ + unsigned int shrink_buf_lseg; /* '186 Begining of freed memory */ unsigned int shrink_buf_mseg; /* Linear address from start of dual-port were freed memory begins, host viewpoint. */ @@ -220,18 +220,18 @@ struct shrink_buf_struct { unsigned char shrink_buf_result; /* Reason for call failing Zero is Good return */ - unsigned char shrink_buf_init; /* Non-Zero if it caused an + unsigned char shrink_buf_init; /* Non-Zero if it caused an xxinit call. */ unsigned char shrink_buf_anports; /* Number of async ports */ unsigned char shrink_buf_snports; /* Number of sync ports */ unsigned char shrink_buf_type; /* Board type 1 = PC/Xi, 2 = PC/Xm, - 3 = PC/Xe - 4 = MC/Xi + 3 = PC/Xe + 4 = MC/Xi 5 = COMX/i */ unsigned char shrink_buf_card; /* Card number */ - + }; /************************************************************************ @@ -244,7 +244,7 @@ struct digi_dinfo { }; #define DIGI_GETDD ('d'<<8) | 248 /* get driver info */ - + /************************************************************************ * Structure used with ioctl commands for per-board information * @@ -264,7 +264,7 @@ struct digi_info { }; #define DIGI_GETBD ('d'<<8) | 249 /* get board info */ - + struct digi_stat { unsigned int info_chan; /* Channel number (0 based) */ unsigned int info_brd; /* Board number (0 based) */ @@ -299,7 +299,7 @@ struct digi_ch { }; /* -* This structure is used with the DIGI_FEPCMD ioctl to +* This structure is used with the DIGI_FEPCMD ioctl to * tell the driver which port to send the command for. */ struct digi_cmd { @@ -398,16 +398,16 @@ struct digi_getcounter #define DIGI_REALPORT_GETEVENTS ('e'<<8 ) | 111 #define EV_OPU 0x0001 //! Date: Wed, 21 Aug 2013 11:08:13 -0400 Subject: [PATCH 716/942] staging: dgnc: dpacompat.h: removes trailing whitespace This patch removes trailing whitespace in the dpacompat.h file. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dpacompat.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/dgnc/dpacompat.h b/drivers/staging/dgnc/dpacompat.h index 44379eb22f425..f96963b9843cb 100644 --- a/drivers/staging/dgnc/dpacompat.h +++ b/drivers/staging/dgnc/dpacompat.h @@ -20,8 +20,8 @@ */ -/* - * This structure holds data needed for the intelligent <--> nonintelligent +/* + * This structure holds data needed for the intelligent <--> nonintelligent * DPA translation */ struct ni_info { -- GitLab From 6ec16a4cc099534dcd4dee423bf33fb486b9d30a Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Tue, 20 Aug 2013 12:15:04 +0900 Subject: [PATCH 717/942] staging: usbip: Fix typo in comments within usbip Correct spelling typo in comments Signed-off-by: Masanari Iida Signed-off-by: Greg Kroah-Hartman --- drivers/staging/usbip/userspace/libsrc/vhci_driver.c | 2 +- drivers/staging/usbip/userspace/src/usbip_attach.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c b/drivers/staging/usbip/userspace/libsrc/vhci_driver.c index 25e62e9f0a335..1091bb20de11b 100644 --- a/drivers/staging/usbip/userspace/libsrc/vhci_driver.c +++ b/drivers/staging/usbip/userspace/libsrc/vhci_driver.c @@ -230,7 +230,7 @@ static int refresh_class_device_list(void) sysfs_close_list(cname_list); - /* seach under /sys/block */ + /* search under /sys/block */ ret = search_class_for_usbip_device(SYSFS_BLOCK_NAME); if (ret < 0) return -1; diff --git a/drivers/staging/usbip/userspace/src/usbip_attach.c b/drivers/staging/usbip/userspace/src/usbip_attach.c index 0ec16e54fb02e..99a24747af0c9 100644 --- a/drivers/staging/usbip/userspace/src/usbip_attach.c +++ b/drivers/staging/usbip/userspace/src/usbip_attach.c @@ -144,7 +144,7 @@ static int query_import_device(int sockfd, char *busid) return -1; } - /* recieve a reply */ + /* receive a reply */ rc = usbip_net_recv_op_common(sockfd, &code); if (rc < 0) { err("recv op_common"); -- GitLab From d60019a948130bbdd10c7fa842d29006d68e6f62 Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Tue, 20 Aug 2013 12:05:39 +0900 Subject: [PATCH 718/942] staging: tidspbridge: Fix typos in comments Correct spelling typos in comments. Signed-off-by: Masanari Iida Signed-off-by: Greg Kroah-Hartman --- drivers/staging/tidspbridge/include/dspbridge/cmm.h | 2 +- drivers/staging/tidspbridge/include/dspbridge/proc.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/tidspbridge/include/dspbridge/cmm.h b/drivers/staging/tidspbridge/include/dspbridge/cmm.h index c66bcf7ea90cb..2adf9ecdf07ff 100644 --- a/drivers/staging/tidspbridge/include/dspbridge/cmm.h +++ b/drivers/staging/tidspbridge/include/dspbridge/cmm.h @@ -293,7 +293,7 @@ extern int cmm_xlator_free_buf(struct cmm_xlatorobject *xlator, * ======== cmm_xlator_info ======== * Purpose: * Set/Get process specific "translator" address info. - * This is used to perform fast virtaul address translation + * This is used to perform fast virtual address translation * for shared memory buffers between the GPP and DSP. * Parameters: * xlator: handle to translator. diff --git a/drivers/staging/tidspbridge/include/dspbridge/proc.h b/drivers/staging/tidspbridge/include/dspbridge/proc.h index 774a3f6ff2011..64c2457aae954 100644 --- a/drivers/staging/tidspbridge/include/dspbridge/proc.h +++ b/drivers/staging/tidspbridge/include/dspbridge/proc.h @@ -284,7 +284,7 @@ extern int proc_get_trace(void *hprocessor, u8 * pbuf, u32 max_size); * user_envp: An Array of Environment settings(Unicode Strings) * Returns: * 0: Success. - * -ENOENT: The DSP Execuetable was not found. + * -ENOENT: The DSP Executable was not found. * -EFAULT: Invalid processor handle. * -EPERM : Unable to Load the Processor * Requires: -- GitLab From 1a04eac93d4df94500d77b672a75a8c12ccae1c7 Mon Sep 17 00:00:00 2001 From: Jens Frederich Date: Tue, 20 Aug 2013 15:53:06 +0200 Subject: [PATCH 719/942] Staging: olpc_dcon: Removed more completed TODO entries 1. Console event notifier support: No one I've asked knows what this all about. 2. Audit code for unnecessary code: This is done. 3. Verify sane i2cAPI usage: This is also done. Signed-off-by: Jens Frederich Signed-off-by: Greg Kroah-Hartman --- drivers/staging/olpc_dcon/TODO | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/olpc_dcon/TODO b/drivers/staging/olpc_dcon/TODO index 885399196de21..61c2e65ac354a 100644 --- a/drivers/staging/olpc_dcon/TODO +++ b/drivers/staging/olpc_dcon/TODO @@ -2,10 +2,6 @@ TODO: - see if vx855 gpio API can be made similar enough to cs5535 so we can share more code - allow simultaneous XO-1 and XO-1.5 support - - console event notifier support - - audit code for unnecessary code; old unsupported prototype - workarounds, ancient variables (noaa?), etc - - verify sane i2c API usage, update to new stuff if necessary Please send patches to Greg Kroah-Hartman and copy: -- GitLab From 23ebe1e0c6a750a0a68c7322a4d4403a9b61d617 Mon Sep 17 00:00:00 2001 From: Mark Einon Date: Tue, 20 Aug 2013 22:42:43 +0100 Subject: [PATCH 720/942] staging: et131x: Remove frame error TODO item After prolonged testing for a few days of normal use with new et131x hardware, I've concluded that this was a hardware issue with the older hardware I had. Removing this item from the TODO. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/README | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/et131x/README b/drivers/staging/et131x/README index 05ad085016639..9272a24ae61c8 100644 --- a/drivers/staging/et131x/README +++ b/drivers/staging/et131x/README @@ -8,7 +8,6 @@ Note, the powermanagement options were removed from the vendor provided driver as they did not build properly at the time. TODO: - - some rx packets have CRC/code/frame errors - Look at reducing the number of spinlocks - Simplify code in nic_rx_pkts(), when determining multicast_pkts_rcvd - Implement NAPI support -- GitLab From c921cc8c1ab53cb9306fe5b1296926e9e46fb824 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Tue, 20 Aug 2013 20:47:49 +0100 Subject: [PATCH 721/942] staging: vt6656: rxtx.c dead code TYPE_ATIMDMA/TYPE_BEACONDMA Both TYPE_ATIMDMA/TYPE_BEACONDMA are not used in driver for the value of uDMAIdx. Remove dead code. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 41 ++++++----------------------------- 1 file changed, 7 insertions(+), 34 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index d7f920de25f79..06950c409730f 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -499,22 +499,6 @@ static u32 s_uFillDataHead(struct vnt_private *pDevice, } if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { - if ((uDMAIdx == TYPE_ATIMDMA) || (uDMAIdx == TYPE_BEACONDMA)) { - struct vnt_tx_datahead_ab *pBuf = - (struct vnt_tx_datahead_ab *)pTxDataHead; - //Get SignalField,ServiceField,Length - BBvCalculateParameter(pDevice, cbFrameLength, wCurrentRate, byPktType, - (u16 *)&(pBuf->wTransmitLength), (u8 *)&(pBuf->byServiceField), (u8 *)&(pBuf->bySignalField) - ); - //Get Duration and TimeStampOff - pBuf->wDuration = (u16)s_uGetDataDuration(pDevice, DATADUR_A, - byPktType, bNeedAck); - if(uDMAIdx!=TYPE_ATIMDMA) { - pBuf->wTimeStampOff = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]; - } - return (pBuf->wDuration); - } - else { // DATA & MANAGE Frame if (byFBOption == AUTO_FB_NONE) { struct vnt_tx_datahead_g *pBuf = (struct vnt_tx_datahead_g *)pTxDataHead; @@ -558,11 +542,9 @@ static u32 s_uFillDataHead(struct vnt_private *pDevice, pBuf->wTimeStampOff_b = wTimeStampOff[pDevice->byPreambleType%2][pDevice->byTopCCKBasicRate%MAX_RATE]; return (pBuf->wDuration_a); } //if (byFBOption == AUTO_FB_NONE) - } } else if (byPktType == PK_TYPE_11A) { - if ((byFBOption != AUTO_FB_NONE) && (uDMAIdx != TYPE_ATIMDMA) && (uDMAIdx != TYPE_BEACONDMA)) { - // Auto Fallback + if (byFBOption != AUTO_FB_NONE) { struct vnt_tx_datahead_a_fb *pBuf = (struct vnt_tx_datahead_a_fb *)pTxDataHead; //Get SignalField,ServiceField,Length @@ -576,9 +558,7 @@ static u32 s_uFillDataHead(struct vnt_private *pDevice, DATADUR_A_F0, byPktType, bNeedAck); pBuf->wDuration_f1 = (u16)s_uGetDataDuration(pDevice, DATADUR_A_F1, byPktType, bNeedAck); - if(uDMAIdx!=TYPE_ATIMDMA) { pBuf->wTimeStampOff = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]; - } return (pBuf->wDuration); } else { struct vnt_tx_datahead_ab *pBuf = @@ -590,10 +570,8 @@ static u32 s_uFillDataHead(struct vnt_private *pDevice, //Get Duration and TimeStampOff pBuf->wDuration = (u16)s_uGetDataDuration(pDevice, DATADUR_A, byPktType, bNeedAck); - - if(uDMAIdx!=TYPE_ATIMDMA) { pBuf->wTimeStampOff = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]; - } + return (pBuf->wDuration); } } @@ -607,9 +585,8 @@ static u32 s_uFillDataHead(struct vnt_private *pDevice, //Get Duration and TimeStampOff pBuf->wDuration = (u16)s_uGetDataDuration(pDevice, DATADUR_B, byPktType, bNeedAck); - if (uDMAIdx != TYPE_ATIMDMA) { pBuf->wTimeStampOff = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]; - } + return (pBuf->wDuration); } return 0; @@ -826,8 +803,8 @@ static void s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx, } if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { - if (byFBOption != AUTO_FB_NONE && uDMAIdx != TYPE_ATIMDMA && uDMAIdx != TYPE_BEACONDMA) { - // Auto Fall back + if (byFBOption != AUTO_FB_NONE) { + /* Auto Fall back */ struct vnt_cts_fb *pBuf = (struct vnt_cts_fb *)pvCTS; //Get SignalField,ServiceField,Length BBvCalculateParameter(pDevice, uCTSFrameLen, pDevice->byTopCCKBasicRate, PK_TYPE_11B, @@ -849,7 +826,7 @@ static void s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx, pBuf->data.duration = pBuf->wDuration_ba; pBuf->data.frame_control = TYPE_CTL_CTS; memcpy(pBuf->data.ra, pDevice->abyCurrentNetAddr, ETH_ALEN); - } else { //if (byFBOption != AUTO_FB_NONE && uDMAIdx != TYPE_ATIMDMA && uDMAIdx != TYPE_BEACONDMA) + } else { struct vnt_cts *pBuf = (struct vnt_cts *)pvCTS; //Get SignalField,ServiceField,Length BBvCalculateParameter(pDevice, uCTSFrameLen, pDevice->byTopCCKBasicRate, PK_TYPE_11B, @@ -1462,11 +1439,7 @@ static void s_vGenerateMACHeader(struct vnt_private *pDevice, { struct ieee80211_hdr *pMACHeader = (struct ieee80211_hdr *)pbyBufferAddr; - if (uDMAIdx == TYPE_ATIMDMA) { - pMACHeader->frame_control = TYPE_802_11_ATIM; - } else { - pMACHeader->frame_control = TYPE_802_11_DATA; - } + pMACHeader->frame_control = TYPE_802_11_DATA; if (pDevice->eOPMode == OP_MODE_AP) { memcpy(&(pMACHeader->addr1[0]), -- GitLab From 253d50ebda91154a03767b0a97ef99c293b175b2 Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Tue, 20 Aug 2013 21:00:53 +0900 Subject: [PATCH 722/942] staging: lustre: Fix typo in lustre/include Fix spelling typo in comments within lustre/include/linux. Signed-off-by: Masanari Iida Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/include/linux/libcfs/libcfs_crypto.h | 8 ++++---- drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h | 2 +- .../staging/lustre/include/linux/libcfs/libcfs_private.h | 2 +- .../lustre/include/linux/libcfs/linux/linux-lock.h | 2 +- drivers/staging/lustre/include/linux/lnet/lib-types.h | 4 ++-- drivers/staging/lustre/include/linux/lnet/lnetst.h | 2 +- drivers/staging/lustre/include/linux/lnet/ptllnd.h | 4 ++-- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h index 64ca62f0cc930..776e9c0e48c13 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h @@ -136,13 +136,13 @@ int cfs_crypto_hash_digest(unsigned char alg, /* cfs crypto hash descriptor */ struct cfs_crypto_hash_desc; -/** Allocate and initialize desriptor for hash algorithm. +/** Allocate and initialize descriptor for hash algorithm. * @param alg algorithm id * @param key initial value for algorithm, if it is NULL, * default initial value should be used. * @param key_len len of initial value * @returns pointer to descriptor of hash instance - * @retval ERR_PTR(error) when errors occured. + * @retval ERR_PTR(error) when errors occurred. */ struct cfs_crypto_hash_desc* cfs_crypto_hash_init(unsigned char alg, @@ -175,7 +175,7 @@ int cfs_crypto_hash_update(struct cfs_crypto_hash_desc *desc, const void *buf, * @param desc hash descriptor * @param hash buffer pointer to store hash digest * @param hash_len pointer to hash buffer size, if NULL - * destory hash descriptor + * destroy hash descriptor * @returns status of operation * @retval -ENOSPC if hash is NULL, or *hash_len less than * digest size @@ -195,7 +195,7 @@ int cfs_crypto_register(void); void cfs_crypto_unregister(void); /** Return hash speed in Mbytes per second for valid hash algorithm - * identifier. If test was unsuccessfull -1 would be return. + * identifier. If test was unsuccessful -1 would be returned. */ int cfs_crypto_hash_speed(unsigned char hash_alg); #endif diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h index f6361b3f0a0c1..98f5be243c8ec 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_hash.h @@ -720,7 +720,7 @@ __u64 cfs_hash_size_get(cfs_hash_t *hs); /* * Rehash - Theta is calculated to be the average chained - * hash depth assuming a perfectly uniform hash funcion. + * hash depth assuming a perfectly uniform hash function. */ void cfs_hash_rehash_cancel_locked(cfs_hash_t *hs); void cfs_hash_rehash_cancel(cfs_hash_t *hs); diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h index b033aa499deff..d0d942ced01a5 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h @@ -229,7 +229,7 @@ void libcfs_debug_set_level(unsigned int debug_level); */ void *cfs_percpt_alloc(struct cfs_cpt_table *cptab, unsigned int size); /* - * destory per-cpu-partition variable + * destroy per-cpu-partition variable */ void cfs_percpt_free(void *vars); int cfs_percpt_number(void *vars); diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-lock.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-lock.h index 6fbcbf3ab0d3d..d6e00f92e4a03 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-lock.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-lock.h @@ -52,7 +52,7 @@ * IMPORTANT !!!!!!!! * * All locks' declaration are not guaranteed to be initialized, - * Althought some of they are initialized in Linux. All locks + * although some of them are initialized in Linux. All locks * declared by CFS_DECL_* should be initialized explicitly. */ diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h index 86428d4b993ee..538e4ffa7a184 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h @@ -181,11 +181,11 @@ typedef struct lnet_msg { lnet_nid_t msg_from; __u32 msg_type; - /* commited for sending */ + /* committed for sending */ unsigned int msg_tx_committed:1; /* CPT # this message committed for sending */ unsigned int msg_tx_cpt:15; - /* commited for receiving */ + /* committed for receiving */ unsigned int msg_rx_committed:1; /* CPT # this message committed for receiving */ unsigned int msg_rx_cpt:15; diff --git a/drivers/staging/lustre/include/linux/lnet/lnetst.h b/drivers/staging/lustre/include/linux/lnet/lnetst.h index d90f94e946016..e060599314d58 100644 --- a/drivers/staging/lustre/include/linux/lnet/lnetst.h +++ b/drivers/staging/lustre/include/linux/lnet/lnetst.h @@ -59,7 +59,7 @@ #define LSTIO_SESSION_INFO 0xC03 /* query session */ #define LSTIO_GROUP_ADD 0xC10 /* add group */ #define LSTIO_GROUP_LIST 0xC11 /* list all groups in session */ -#define LSTIO_GROUP_INFO 0xC12 /* query defailt infomation of specified group */ +#define LSTIO_GROUP_INFO 0xC12 /* query default information of specified group */ #define LSTIO_GROUP_DEL 0xC13 /* delete group */ #define LSTIO_NODES_ADD 0xC14 /* add nodes to specified group */ #define LSTIO_GROUP_UPDATE 0xC15 /* update group */ diff --git a/drivers/staging/lustre/include/linux/lnet/ptllnd.h b/drivers/staging/lustre/include/linux/lnet/ptllnd.h index fc1ce8ed1f8b0..564f5d3a9b4d0 100644 --- a/drivers/staging/lustre/include/linux/lnet/ptllnd.h +++ b/drivers/staging/lustre/include/linux/lnet/ptllnd.h @@ -68,7 +68,7 @@ /* Can compare handles directly on Cray Portals */ #define PtlHandleIsEqual(a,b) ((a) == (b)) -/* Diffrent error types on Cray Portals*/ +/* Different error types on Cray Portals*/ #define ptl_err_t ptl_ni_fail_t /* @@ -76,7 +76,7 @@ * maximum is limited only by memory and size of the * int parameters (2^31-1). * Lustre only really require that the underyling - * implemenation to support at least LNET_MAX_IOV, + * implementation to support at least LNET_MAX_IOV, * so for Cray portals we can safely just use that * value here. * -- GitLab From ded82ef91e247692682d696462f5f7e1f528758c Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 20 Aug 2013 12:06:19 +0300 Subject: [PATCH 723/942] staging: comedi: usbdux: allocating too much data We only need to allocate enough space for a pointer. We allocate the space for the urbs themselves with the call to usb_alloc_urb() a few lines later. Signed-off-by: Dan Carpenter Acked-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 7e91f1506a39c..701ad1a693946 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -1558,9 +1558,9 @@ static int usbdux_alloc_usb_buffers(struct comedi_device *dev) devpriv->dux_commands = kzalloc(SIZEOFDUXBUFFER, GFP_KERNEL); devpriv->in_buf = kzalloc(SIZEINBUF, GFP_KERNEL); devpriv->insn_buf = kzalloc(SIZEINSNBUF, GFP_KERNEL); - devpriv->ai_urbs = kcalloc(devpriv->n_ai_urbs, sizeof(*urb), + devpriv->ai_urbs = kcalloc(devpriv->n_ai_urbs, sizeof(void *), GFP_KERNEL); - devpriv->ao_urbs = kcalloc(devpriv->n_ao_urbs, sizeof(*urb), + devpriv->ao_urbs = kcalloc(devpriv->n_ao_urbs, sizeof(void *), GFP_KERNEL); if (!devpriv->dux_commands || !devpriv->in_buf || !devpriv->insn_buf || !devpriv->ai_urbs || !devpriv->ao_urbs) -- GitLab From 2c4283ca7cdcc6605859c836fc536fcd83a4525f Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 20 Aug 2013 11:57:35 +0300 Subject: [PATCH 724/942] staging: comedi: dt282x: dt282x_ai_insn_read() always fails In dt282x_ai_insn_read() we call this macro like: wait_for(!mux_busy(), comedi_error(dev, "timeout\n"); return -ETIME;); Because the if statement doesn't have curly braces it means we always return -ETIME and the function never succeeds. Signed-off-by: Dan Carpenter Acked-by: Ian Abbott Cc: stable # 2.6.36+ Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt282x.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/dt282x.c b/drivers/staging/comedi/drivers/dt282x.c index 23cb033559b3c..4a25382e9b861 100644 --- a/drivers/staging/comedi/drivers/dt282x.c +++ b/drivers/staging/comedi/drivers/dt282x.c @@ -267,8 +267,9 @@ struct dt282x_private { } \ udelay(5); \ } \ - if (_i) \ + if (_i) { \ b \ + } \ } while (0) static int prep_ai_dma(struct comedi_device *dev, int chan, int size); -- GitLab From 35b7b91ab928c8f84ad49dc4f6d7d61f19d3ccb9 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 21 Aug 2013 11:28:04 +0300 Subject: [PATCH 725/942] staging: comedi: pcl812: missing break statement Smatch complains that there is a missing break statement here. Signed-off-by: Dan Carpenter Acked-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl812.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index 35251e71b7f8a..03a098900d34e 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -1404,6 +1404,7 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (it->options[3] > 0) /* we use external trigger */ devpriv->use_ext_trg = 1; + break; case boardA821: devpriv->max_812_ai_mode0_rangewait = 1; devpriv->mode_reg_int = (irq << 4) & 0xf0; -- GitLab From 234ad18249a46af8703246a3c417bb4382512d2f Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 21 Aug 2013 11:31:18 +0300 Subject: [PATCH 726/942] staging: gdm7240: fix error handling of probe() The error handling is messy and not in kernel style. On some paths it frees "mux_dev" twice. Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm724x/gdm_mux.c | 57 ++++++++++++++----------------- 1 file changed, 25 insertions(+), 32 deletions(-) diff --git a/drivers/staging/gdm724x/gdm_mux.c b/drivers/staging/gdm724x/gdm_mux.c index 9e217ff3b15b2..5b1ef4000d0fe 100644 --- a/drivers/staging/gdm724x/gdm_mux.c +++ b/drivers/staging/gdm724x/gdm_mux.c @@ -509,11 +509,11 @@ static int init_usb(struct mux_dev *mux_dev) static int gdm_mux_probe(struct usb_interface *intf, const struct usb_device_id *id) { - struct mux_dev *mux_dev = NULL; - struct tty_dev *tty_dev = NULL; + struct mux_dev *mux_dev; + struct tty_dev *tty_dev; u16 idVendor, idProduct; int bInterfaceNumber; - int ret = 0; + int ret; int i; struct usb_device *usbdev = interface_to_usbdev(intf); bInterfaceNumber = intf->cur_altsetting->desc.bInterfaceNumber; @@ -523,61 +523,54 @@ static int gdm_mux_probe(struct usb_interface *intf, const struct usb_device_id pr_info("mux vid = 0x%04x pid = 0x%04x\n", idVendor, idProduct); - if (bInterfaceNumber != 2) { - ret = -ENODEV; - goto out; - } + if (bInterfaceNumber != 2) + return -ENODEV; mux_dev = kzalloc(sizeof(struct mux_dev), GFP_KERNEL); - if (!mux_dev) { - ret = -ENOMEM; - goto out; - } + if (!mux_dev) + return -ENOMEM; tty_dev = kzalloc(sizeof(struct tty_dev), GFP_KERNEL); if (!tty_dev) { - kfree(mux_dev); ret = -ENOMEM; - goto out; + goto err_free_mux; } mux_dev->usbdev = usbdev; mux_dev->control_intf = intf; ret = init_usb(mux_dev); - if (ret < 0) - goto out; + if (ret) + goto err_free_tty; tty_dev->priv_dev = (void *)mux_dev; tty_dev->send_func = gdm_mux_send; tty_dev->recv_func = gdm_mux_recv; tty_dev->send_control = gdm_mux_send_control; - if (register_lte_tty_device(tty_dev, &intf->dev) < 0) { - unregister_lte_tty_device(tty_dev); - mux_dev = tty_dev->priv_dev; + ret = register_lte_tty_device(tty_dev, &intf->dev); + if (ret) + goto err_unregister_tty; - ret = -1; - goto out; - } for (i = 0; i < TTY_MAX_COUNT; i++) mux_dev->tty_dev = tty_dev; -out: - if (ret < 0) { - kfree(tty_dev); - if (mux_dev) { - release_usb(mux_dev); - kfree(mux_dev); - } - } else { - mux_dev->intf = intf; - mux_dev->usb_state = PM_NORMAL; - } + mux_dev->intf = intf; + mux_dev->usb_state = PM_NORMAL; usb_get_dev(usbdev); usb_set_intfdata(intf, tty_dev); + return 0; + +err_unregister_tty: + unregister_lte_tty_device(tty_dev); + release_usb(mux_dev); +err_free_tty: + kfree(tty_dev); +err_free_mux: + kfree(mux_dev); + return ret; } -- GitLab From df2da9a3fc4b4aeb5c6250006a297f143ca7fcc3 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 21 Aug 2013 11:30:08 +0300 Subject: [PATCH 727/942] staging: drm/imx: ipu-dc: signedness bug in ipu_dc_init_sync() "map" needs to be signed for the error handling to work. In the success case then it holds a small non-negative value. Signed-off-by: Dan Carpenter Acked-by: Sascha Hauer Acked-by: Marek Vasut Signed-off-by: Greg Kroah-Hartman --- drivers/staging/imx-drm/ipu-v3/ipu-dc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-dc.c b/drivers/staging/imx-drm/ipu-v3/ipu-dc.c index 59f03f9aefc3d..21bf1c8065288 100644 --- a/drivers/staging/imx-drm/ipu-v3/ipu-dc.c +++ b/drivers/staging/imx-drm/ipu-v3/ipu-dc.c @@ -161,14 +161,15 @@ int ipu_dc_init_sync(struct ipu_dc *dc, struct ipu_di *di, bool interlaced, u32 pixel_fmt, u32 width) { struct ipu_dc_priv *priv = dc->priv; - u32 reg = 0, map; + u32 reg = 0; + int map; dc->di = ipu_di_get_num(di); map = ipu_pixfmt_to_map(pixel_fmt); if (map < 0) { dev_dbg(priv->dev, "IPU_DISP: No MAP\n"); - return -EINVAL; + return map; } if (interlaced) { -- GitLab From 4ac306e0d41e8da01a59ac9e3a347877d56874a7 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Tue, 20 Aug 2013 22:49:26 +0100 Subject: [PATCH 728/942] staging: vt6656: baseband.c BBvCalculateParameter pwPhyLen return endian corrected. In rxtx.c many calls to BBvCaculateParameter are not endian corrected all calls here need to be endian corrected. Correct the endian in BBvCaculateParameter. In card.c: CARDvSetRSPINF pwPhyLen points to awLen and is manually applied to abyData. Because it is now endian corrected put_unaligned is needed to correct it. In rxtx.c remove were endian is corrected. This allows to merge BBvCalculateParameter *pwPhyLen,*pbyPhySrv and *pbyPhySgn to singles structure for tx buffers. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/baseband.c | 19 +++++++++---------- drivers/staging/vt6656/card.c | 12 ++++-------- drivers/staging/vt6656/rxtx.c | 9 --------- 3 files changed, 13 insertions(+), 27 deletions(-) diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c index a14a6a0c1cd28..7d344036dd5ee 100644 --- a/drivers/staging/vt6656/baseband.c +++ b/drivers/staging/vt6656/baseband.c @@ -870,16 +870,15 @@ void BBvCalculateParameter(struct vnt_private *pDevice, u32 cbFrameLength, break; } - if (byPacketType == PK_TYPE_11B) { - *pbyPhySrv = 0x00; - if (bExtBit) - *pbyPhySrv = *pbyPhySrv | 0x80; - *pwPhyLen = (u16) cbUsCount; - } - else { - *pbyPhySrv = 0x00; - *pwPhyLen = (u16)cbFrameLength; - } + if (byPacketType == PK_TYPE_11B) { + *pbyPhySrv = 0x00; + if (bExtBit) + *pbyPhySrv = *pbyPhySrv | 0x80; + *pwPhyLen = cpu_to_le16((u16)cbUsCount); + } else { + *pbyPhySrv = 0x00; + *pwPhyLen = cpu_to_le16((u16)cbFrameLength); + } } /* diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c index 24291aee58b55..c0815d8020bc1 100644 --- a/drivers/staging/vt6656/card.c +++ b/drivers/staging/vt6656/card.c @@ -421,23 +421,19 @@ void CARDvSetRSPINF(struct vnt_private *pDevice, u8 byBBType) &abyTxRate[8], &abyRsvTime[8]); - abyData[0] = (u8)(awLen[0]&0xFF); - abyData[1] = (u8)(awLen[0]>>8); + put_unaligned(awLen[0], (u16 *)&abyData[0]); abyData[2] = abySignal[0]; abyData[3] = abyServ[0]; - abyData[4] = (u8)(awLen[1]&0xFF); - abyData[5] = (u8)(awLen[1]>>8); + put_unaligned(awLen[1], (u16 *)&abyData[4]); abyData[6] = abySignal[1]; abyData[7] = abyServ[1]; - abyData[8] = (u8)(awLen[2]&0xFF); - abyData[9] = (u8)(awLen[2]>>8); + put_unaligned(awLen[2], (u16 *)&abyData[8]); abyData[10] = abySignal[2]; abyData[11] = abyServ[2]; - abyData[12] = (u8)(awLen[3]&0xFF); - abyData[13] = (u8)(awLen[3]>>8); + put_unaligned(awLen[3], (u16 *)&abyData[12]); abyData[14] = abySignal[3]; abyData[15] = abyServ[3]; diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 06950c409730f..8c427818696f0 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -617,11 +617,9 @@ static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, BBvCalculateParameter(pDevice, uRTSFrameLen, pDevice->byTopCCKBasicRate, PK_TYPE_11B, (u16 *)&(wLen), (u8 *)&(pBuf->byServiceField_b), (u8 *)&(pBuf->bySignalField_b) ); - pBuf->wTransmitLength_b = cpu_to_le16(wLen); BBvCalculateParameter(pDevice, uRTSFrameLen, pDevice->byTopOFDMBasicRate, byPktType, (u16 *)&(wLen), (u8 *)&(pBuf->byServiceField_a), (u8 *)&(pBuf->bySignalField_a) ); - pBuf->wTransmitLength_a = cpu_to_le16(wLen); //Get Duration pBuf->wDuration_bb = s_uGetRTSCTSDuration(pDevice, RTSDUR_BB, cbFrameLength, PK_TYPE_11B, @@ -653,11 +651,9 @@ static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, BBvCalculateParameter(pDevice, uRTSFrameLen, pDevice->byTopCCKBasicRate, PK_TYPE_11B, (u16 *)&(wLen), (u8 *)&(pBuf->byServiceField_b), (u8 *)&(pBuf->bySignalField_b) ); - pBuf->wTransmitLength_b = cpu_to_le16(wLen); BBvCalculateParameter(pDevice, uRTSFrameLen, pDevice->byTopOFDMBasicRate, byPktType, (u16 *)&(wLen), (u8 *)&(pBuf->byServiceField_a), (u8 *)&(pBuf->bySignalField_a) ); - pBuf->wTransmitLength_a = cpu_to_le16(wLen); //Get Duration pBuf->wDuration_bb = s_uGetRTSCTSDuration(pDevice, RTSDUR_BB, cbFrameLength, PK_TYPE_11B, @@ -703,7 +699,6 @@ static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, BBvCalculateParameter(pDevice, uRTSFrameLen, pDevice->byTopOFDMBasicRate, byPktType, (u16 *)&(wLen), (u8 *)&(pBuf->byServiceField), (u8 *)&(pBuf->bySignalField) ); - pBuf->wTransmitLength = cpu_to_le16(wLen); //Get Duration pBuf->wDuration = s_uGetRTSCTSDuration(pDevice, RTSDUR_AA, cbFrameLength, byPktType, wCurrentRate, @@ -729,7 +724,6 @@ static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, BBvCalculateParameter(pDevice, uRTSFrameLen, pDevice->byTopOFDMBasicRate, byPktType, (u16 *)&(wLen), (u8 *)&(pBuf->byServiceField), (u8 *)&(pBuf->bySignalField) ); - pBuf->wTransmitLength = cpu_to_le16(wLen); //Get Duration pBuf->wDuration = s_uGetRTSCTSDuration(pDevice, RTSDUR_AA, cbFrameLength, byPktType, wCurrentRate, @@ -762,7 +756,6 @@ static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, BBvCalculateParameter(pDevice, uRTSFrameLen, pDevice->byTopCCKBasicRate, PK_TYPE_11B, (u16 *)&(wLen), (u8 *)&(pBuf->byServiceField), (u8 *)&(pBuf->bySignalField) ); - pBuf->wTransmitLength = cpu_to_le16(wLen); //Get Duration pBuf->wDuration = s_uGetRTSCTSDuration(pDevice, RTSDUR_BB, cbFrameLength, byPktType, wCurrentRate, @@ -810,7 +803,6 @@ static void s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx, BBvCalculateParameter(pDevice, uCTSFrameLen, pDevice->byTopCCKBasicRate, PK_TYPE_11B, (u16 *)&(wLen), (u8 *)&(pBuf->byServiceField_b), (u8 *)&(pBuf->bySignalField_b) ); - pBuf->wTransmitLength_b = cpu_to_le16(wLen); pBuf->wDuration_ba = s_uGetRTSCTSDuration(pDevice, CTSDUR_BA, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption); @@ -832,7 +824,6 @@ static void s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx, BBvCalculateParameter(pDevice, uCTSFrameLen, pDevice->byTopCCKBasicRate, PK_TYPE_11B, (u16 *)&(wLen), (u8 *)&(pBuf->byServiceField_b), (u8 *)&(pBuf->bySignalField_b) ); - pBuf->wTransmitLength_b = cpu_to_le16(wLen); /* Get CTSDuration_ba */ pBuf->wDuration_ba = s_uGetRTSCTSDuration(pDevice, CTSDUR_BA, cbFrameLength, byPktType, -- GitLab From aed387c78d4ad3cb7b65670785ab396ce06d0b5d Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Tue, 20 Aug 2013 22:52:30 +0100 Subject: [PATCH 729/942] staging: vt6656: baseband.c BBvCalculateParameter create structure for pwPhyLen, pbyPhySrv and pbyPhySgn Create single packed structure vnt_phy_field for rxtx.h structures. In card.c CARDvSetRSPINF a vnt_phy_field replaces abyServ, abySignal, awLen variables. In rxtx.c point BBvCalculateParameter to relevant field. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/baseband.c | 70 +++++++++++----------- drivers/staging/vt6656/baseband.h | 10 +++- drivers/staging/vt6656/card.c | 68 +++++++--------------- drivers/staging/vt6656/rxtx.c | 97 ++++++++++++------------------- drivers/staging/vt6656/rxtx.h | 57 +++++------------- 5 files changed, 117 insertions(+), 185 deletions(-) diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c index 7d344036dd5ee..1e8b8412e67e4 100644 --- a/drivers/staging/vt6656/baseband.c +++ b/drivers/staging/vt6656/baseband.c @@ -723,16 +723,16 @@ BBuGetFrameTime( * cbFrameLength - Tx Frame Length * wRate - Tx Rate * Out: - * pwPhyLen - pointer to Phy Length field - * pbyPhySrv - pointer to Phy Service field - * pbyPhySgn - pointer to Phy Signal field + * struct vnt_phy_field *phy + * - pointer to Phy Length field + * - pointer to Phy Service field + * - pointer to Phy Signal field * * Return Value: none * */ void BBvCalculateParameter(struct vnt_private *pDevice, u32 cbFrameLength, - u16 wRate, u8 byPacketType, u16 *pwPhyLen, u8 *pbyPhySrv, - u8 *pbyPhySgn) + u16 wRate, u8 byPacketType, struct vnt_phy_field *phy) { u32 cbBitCount; u32 cbUsCount = 0; @@ -747,15 +747,15 @@ void BBvCalculateParameter(struct vnt_private *pDevice, u32 cbFrameLength, switch (wRate) { case RATE_1M : cbUsCount = cbBitCount; - *pbyPhySgn = 0x00; + phy->signal = 0x00; break; case RATE_2M : cbUsCount = cbBitCount / 2; if (byPreambleType == 1) - *pbyPhySgn = 0x09; + phy->signal = 0x09; else // long preamble - *pbyPhySgn = 0x01; + phy->signal = 0x01; break; case RATE_5M : @@ -766,9 +766,9 @@ void BBvCalculateParameter(struct vnt_private *pDevice, u32 cbFrameLength, if (cbTmp != cbBitCount) cbUsCount ++; if (byPreambleType == 1) - *pbyPhySgn = 0x0a; + phy->signal = 0x0a; else // long preamble - *pbyPhySgn = 0x02; + phy->signal = 0x02; break; case RATE_11M : @@ -783,101 +783,101 @@ void BBvCalculateParameter(struct vnt_private *pDevice, u32 cbFrameLength, bExtBit = true; } if (byPreambleType == 1) - *pbyPhySgn = 0x0b; + phy->signal = 0x0b; else // long preamble - *pbyPhySgn = 0x03; + phy->signal = 0x03; break; case RATE_6M : if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ - *pbyPhySgn = 0x9B; //1001 1011 + phy->signal = 0x9b; } else {//11g, 2.4GHZ - *pbyPhySgn = 0x8B; //1000 1011 + phy->signal = 0x8b; } break; case RATE_9M : if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ - *pbyPhySgn = 0x9F; //1001 1111 + phy->signal = 0x9f; } else {//11g, 2.4GHZ - *pbyPhySgn = 0x8F; //1000 1111 + phy->signal = 0x8f; } break; case RATE_12M : if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ - *pbyPhySgn = 0x9A; //1001 1010 + phy->signal = 0x9a; } else {//11g, 2.4GHZ - *pbyPhySgn = 0x8A; //1000 1010 + phy->signal = 0x8a; } break; case RATE_18M : if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ - *pbyPhySgn = 0x9E; //1001 1110 + phy->signal = 0x9e; } else {//11g, 2.4GHZ - *pbyPhySgn = 0x8E; //1000 1110 + phy->signal = 0x8e; } break; case RATE_24M : if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ - *pbyPhySgn = 0x99; //1001 1001 + phy->signal = 0x99; } else {//11g, 2.4GHZ - *pbyPhySgn = 0x89; //1000 1001 + phy->signal = 0x89; } break; case RATE_36M : if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ - *pbyPhySgn = 0x9D; //1001 1101 + phy->signal = 0x9d; } else {//11g, 2.4GHZ - *pbyPhySgn = 0x8D; //1000 1101 + phy->signal = 0x8d; } break; case RATE_48M : if(byPacketType == PK_TYPE_11A) {//11a, 5GHZ - *pbyPhySgn = 0x98; //1001 1000 + phy->signal = 0x98; } else {//11g, 2.4GHZ - *pbyPhySgn = 0x88; //1000 1000 + phy->signal = 0x88; } break; case RATE_54M : if (byPacketType == PK_TYPE_11A) {//11a, 5GHZ - *pbyPhySgn = 0x9C; //1001 1100 + phy->signal = 0x9c; } else {//11g, 2.4GHZ - *pbyPhySgn = 0x8C; //1000 1100 + phy->signal = 0x8c; } break; default : if (byPacketType == PK_TYPE_11A) {//11a, 5GHZ - *pbyPhySgn = 0x9C; //1001 1100 + phy->signal = 0x9c; } else {//11g, 2.4GHZ - *pbyPhySgn = 0x8C; //1000 1100 + phy->signal = 0x8c; } break; } if (byPacketType == PK_TYPE_11B) { - *pbyPhySrv = 0x00; + phy->service = 0x00; if (bExtBit) - *pbyPhySrv = *pbyPhySrv | 0x80; - *pwPhyLen = cpu_to_le16((u16)cbUsCount); + phy->service |= 0x80; + phy->len = cpu_to_le16((u16)cbUsCount); } else { - *pbyPhySrv = 0x00; - *pwPhyLen = cpu_to_le16((u16)cbFrameLength); + phy->service = 0x00; + phy->len = cpu_to_le16((u16)cbFrameLength); } } diff --git a/drivers/staging/vt6656/baseband.h b/drivers/staging/vt6656/baseband.h index 0a634adabf0ef..a8db17dc366e8 100644 --- a/drivers/staging/vt6656/baseband.h +++ b/drivers/staging/vt6656/baseband.h @@ -81,6 +81,13 @@ #define TOP_RATE_2M 0x00200000 #define TOP_RATE_1M 0x00100000 +/* Length, Service, and Signal fields of Phy for Tx */ +struct vnt_phy_field { + u8 signal; + u8 service; + u16 len; +} __packed; + unsigned int BBuGetFrameTime( u8 byPreambleType, @@ -90,8 +97,7 @@ BBuGetFrameTime( ); void BBvCalculateParameter(struct vnt_private *, u32 cbFrameLength, - u16 wRate, u8 byPacketType, u16 *pwPhyLen, u8 *pbyPhySrv, - u8 *pbyPhySgn); + u16 wRate, u8 byPacketType, struct vnt_phy_field *); /* timer for antenna diversity */ diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c index c0815d8020bc1..dbf11ecb794ec 100644 --- a/drivers/staging/vt6656/card.c +++ b/drivers/staging/vt6656/card.c @@ -319,53 +319,27 @@ CARDvCalculateOFDMRParameter ( */ void CARDvSetRSPINF(struct vnt_private *pDevice, u8 byBBType) { - u8 abyServ[4] = {0, 0, 0, 0}; /* For CCK */ - u8 abySignal[4] = {0, 0, 0, 0}; - u16 awLen[4] = {0, 0, 0, 0}; + struct vnt_phy_field phy[4]; u8 abyTxRate[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; /* For OFDM */ u8 abyRsvTime[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; u8 abyData[34]; int i; //RSPINF_b_1 - BBvCalculateParameter(pDevice, - 14, - swGetCCKControlRate(pDevice, RATE_1M), - PK_TYPE_11B, - &awLen[0], - &abyServ[0], - &abySignal[0] - ); + BBvCalculateParameter(pDevice, 14, + swGetCCKControlRate(pDevice, RATE_1M), PK_TYPE_11B, &phy[0]); ///RSPINF_b_2 - BBvCalculateParameter(pDevice, - 14, - swGetCCKControlRate(pDevice, RATE_2M), - PK_TYPE_11B, - &awLen[1], - &abyServ[1], - &abySignal[1] - ); + BBvCalculateParameter(pDevice, 14, + swGetCCKControlRate(pDevice, RATE_2M), PK_TYPE_11B, &phy[1]); //RSPINF_b_5 - BBvCalculateParameter(pDevice, - 14, - swGetCCKControlRate(pDevice, RATE_5M), - PK_TYPE_11B, - &awLen[2], - &abyServ[2], - &abySignal[2] - ); + BBvCalculateParameter(pDevice, 14, + swGetCCKControlRate(pDevice, RATE_5M), PK_TYPE_11B, &phy[2]); //RSPINF_b_11 - BBvCalculateParameter(pDevice, - 14, - swGetCCKControlRate(pDevice, RATE_11M), - PK_TYPE_11B, - &awLen[3], - &abyServ[3], - &abySignal[3] - ); + BBvCalculateParameter(pDevice, 14, + swGetCCKControlRate(pDevice, RATE_11M), PK_TYPE_11B, &phy[3]); //RSPINF_a_6 CARDvCalculateOFDMRParameter (RATE_6M, @@ -421,21 +395,21 @@ void CARDvSetRSPINF(struct vnt_private *pDevice, u8 byBBType) &abyTxRate[8], &abyRsvTime[8]); - put_unaligned(awLen[0], (u16 *)&abyData[0]); - abyData[2] = abySignal[0]; - abyData[3] = abyServ[0]; + put_unaligned(phy[0].len, (u16 *)&abyData[0]); + abyData[2] = phy[0].signal; + abyData[3] = phy[0].service; - put_unaligned(awLen[1], (u16 *)&abyData[4]); - abyData[6] = abySignal[1]; - abyData[7] = abyServ[1]; + put_unaligned(phy[1].len, (u16 *)&abyData[4]); + abyData[6] = phy[1].signal; + abyData[7] = phy[1].service; - put_unaligned(awLen[2], (u16 *)&abyData[8]); - abyData[10] = abySignal[2]; - abyData[11] = abyServ[2]; + put_unaligned(phy[2].len, (u16 *)&abyData[8]); + abyData[10] = phy[2].signal; + abyData[11] = phy[2].service; - put_unaligned(awLen[3], (u16 *)&abyData[12]); - abyData[14] = abySignal[3]; - abyData[15] = abyServ[3]; + put_unaligned(phy[3].len, (u16 *)&abyData[12]); + abyData[14] = phy[3].signal; + abyData[15] = phy[3].service; for (i = 0; i < 9; i++) { abyData[16+i*2] = abyTxRate[i]; diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 8c427818696f0..05e82ece1f302 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -52,7 +52,6 @@ #include "card.h" #include "bssdb.h" #include "mac.h" -#include "baseband.h" #include "michael.h" #include "tkip.h" #include "tcrc.h" @@ -503,12 +502,10 @@ static u32 s_uFillDataHead(struct vnt_private *pDevice, struct vnt_tx_datahead_g *pBuf = (struct vnt_tx_datahead_g *)pTxDataHead; //Get SignalField,ServiceField,Length - BBvCalculateParameter(pDevice, cbFrameLength, wCurrentRate, byPktType, - (u16 *)&(pBuf->wTransmitLength_a), (u8 *)&(pBuf->byServiceField_a), (u8 *)&(pBuf->bySignalField_a) - ); - BBvCalculateParameter(pDevice, cbFrameLength, pDevice->byTopCCKBasicRate, PK_TYPE_11B, - (u16 *)&(pBuf->wTransmitLength_b), (u8 *)&(pBuf->byServiceField_b), (u8 *)&(pBuf->bySignalField_b) - ); + BBvCalculateParameter(pDevice, cbFrameLength, wCurrentRate, + byPktType, &pBuf->a); + BBvCalculateParameter(pDevice, cbFrameLength, + pDevice->byTopCCKBasicRate, PK_TYPE_11B, &pBuf->b); //Get Duration and TimeStamp pBuf->wDuration_a = (u16)s_uGetDataDuration(pDevice, DATADUR_A, byPktType, bNeedAck); @@ -523,12 +520,10 @@ static u32 s_uFillDataHead(struct vnt_private *pDevice, struct vnt_tx_datahead_g_fb *pBuf = (struct vnt_tx_datahead_g_fb *)pTxDataHead; //Get SignalField,ServiceField,Length - BBvCalculateParameter(pDevice, cbFrameLength, wCurrentRate, byPktType, - (u16 *)&(pBuf->wTransmitLength_a), (u8 *)&(pBuf->byServiceField_a), (u8 *)&(pBuf->bySignalField_a) - ); - BBvCalculateParameter(pDevice, cbFrameLength, pDevice->byTopCCKBasicRate, PK_TYPE_11B, - (u16 *)&(pBuf->wTransmitLength_b), (u8 *)&(pBuf->byServiceField_b), (u8 *)&(pBuf->bySignalField_b) - ); + BBvCalculateParameter(pDevice, cbFrameLength, wCurrentRate, + byPktType, &pBuf->a); + BBvCalculateParameter(pDevice, cbFrameLength, + pDevice->byTopCCKBasicRate, PK_TYPE_11B, &pBuf->b); //Get Duration and TimeStamp pBuf->wDuration_a = (u16)s_uGetDataDuration(pDevice, DATADUR_A, byPktType, bNeedAck); @@ -548,9 +543,8 @@ static u32 s_uFillDataHead(struct vnt_private *pDevice, struct vnt_tx_datahead_a_fb *pBuf = (struct vnt_tx_datahead_a_fb *)pTxDataHead; //Get SignalField,ServiceField,Length - BBvCalculateParameter(pDevice, cbFrameLength, wCurrentRate, byPktType, - (u16 *)&(pBuf->wTransmitLength), (u8 *)&(pBuf->byServiceField), (u8 *)&(pBuf->bySignalField) - ); + BBvCalculateParameter(pDevice, cbFrameLength, wCurrentRate, + byPktType, &pBuf->a); //Get Duration and TimeStampOff pBuf->wDuration = (u16)s_uGetDataDuration(pDevice, DATADUR_A, byPktType, bNeedAck); @@ -564,9 +558,8 @@ static u32 s_uFillDataHead(struct vnt_private *pDevice, struct vnt_tx_datahead_ab *pBuf = (struct vnt_tx_datahead_ab *)pTxDataHead; //Get SignalField,ServiceField,Length - BBvCalculateParameter(pDevice, cbFrameLength, wCurrentRate, byPktType, - (u16 *)&(pBuf->wTransmitLength), (u8 *)&(pBuf->byServiceField), (u8 *)&(pBuf->bySignalField) - ); + BBvCalculateParameter(pDevice, cbFrameLength, wCurrentRate, + byPktType, &pBuf->ab); //Get Duration and TimeStampOff pBuf->wDuration = (u16)s_uGetDataDuration(pDevice, DATADUR_A, byPktType, bNeedAck); @@ -579,9 +572,8 @@ static u32 s_uFillDataHead(struct vnt_private *pDevice, struct vnt_tx_datahead_ab *pBuf = (struct vnt_tx_datahead_ab *)pTxDataHead; //Get SignalField,ServiceField,Length - BBvCalculateParameter(pDevice, cbFrameLength, wCurrentRate, byPktType, - (u16 *)&(pBuf->wTransmitLength), (u8 *)&(pBuf->byServiceField), (u8 *)&(pBuf->bySignalField) - ); + BBvCalculateParameter(pDevice, cbFrameLength, wCurrentRate, + byPktType, &pBuf->ab); //Get Duration and TimeStampOff pBuf->wDuration = (u16)s_uGetDataDuration(pDevice, DATADUR_B, byPktType, bNeedAck); @@ -597,7 +589,6 @@ static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, struct ethhdr *psEthHeader, u16 wCurrentRate, u8 byFBOption) { u32 uRTSFrameLen = 20; - u16 wLen = 0; if (pvRTS == NULL) return; @@ -614,12 +605,10 @@ static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, if (byFBOption == AUTO_FB_NONE) { struct vnt_rts_g *pBuf = (struct vnt_rts_g *)pvRTS; //Get SignalField,ServiceField,Length - BBvCalculateParameter(pDevice, uRTSFrameLen, pDevice->byTopCCKBasicRate, PK_TYPE_11B, - (u16 *)&(wLen), (u8 *)&(pBuf->byServiceField_b), (u8 *)&(pBuf->bySignalField_b) - ); - BBvCalculateParameter(pDevice, uRTSFrameLen, pDevice->byTopOFDMBasicRate, byPktType, - (u16 *)&(wLen), (u8 *)&(pBuf->byServiceField_a), (u8 *)&(pBuf->bySignalField_a) - ); + BBvCalculateParameter(pDevice, uRTSFrameLen, + pDevice->byTopCCKBasicRate, PK_TYPE_11B, &pBuf->b); + BBvCalculateParameter(pDevice, uRTSFrameLen, + pDevice->byTopOFDMBasicRate, byPktType, &pBuf->a); //Get Duration pBuf->wDuration_bb = s_uGetRTSCTSDuration(pDevice, RTSDUR_BB, cbFrameLength, PK_TYPE_11B, @@ -648,12 +637,10 @@ static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, else { struct vnt_rts_g_fb *pBuf = (struct vnt_rts_g_fb *)pvRTS; //Get SignalField,ServiceField,Length - BBvCalculateParameter(pDevice, uRTSFrameLen, pDevice->byTopCCKBasicRate, PK_TYPE_11B, - (u16 *)&(wLen), (u8 *)&(pBuf->byServiceField_b), (u8 *)&(pBuf->bySignalField_b) - ); - BBvCalculateParameter(pDevice, uRTSFrameLen, pDevice->byTopOFDMBasicRate, byPktType, - (u16 *)&(wLen), (u8 *)&(pBuf->byServiceField_a), (u8 *)&(pBuf->bySignalField_a) - ); + BBvCalculateParameter(pDevice, uRTSFrameLen, + pDevice->byTopCCKBasicRate, PK_TYPE_11B, &pBuf->b); + BBvCalculateParameter(pDevice, uRTSFrameLen, + pDevice->byTopOFDMBasicRate, byPktType, &pBuf->a); //Get Duration pBuf->wDuration_bb = s_uGetRTSCTSDuration(pDevice, RTSDUR_BB, cbFrameLength, PK_TYPE_11B, @@ -696,9 +683,8 @@ static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, if (byFBOption == AUTO_FB_NONE) { struct vnt_rts_ab *pBuf = (struct vnt_rts_ab *)pvRTS; //Get SignalField,ServiceField,Length - BBvCalculateParameter(pDevice, uRTSFrameLen, pDevice->byTopOFDMBasicRate, byPktType, - (u16 *)&(wLen), (u8 *)&(pBuf->byServiceField), (u8 *)&(pBuf->bySignalField) - ); + BBvCalculateParameter(pDevice, uRTSFrameLen, + pDevice->byTopOFDMBasicRate, byPktType, &pBuf->ab); //Get Duration pBuf->wDuration = s_uGetRTSCTSDuration(pDevice, RTSDUR_AA, cbFrameLength, byPktType, wCurrentRate, @@ -721,9 +707,8 @@ static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, else { struct vnt_rts_a_fb *pBuf = (struct vnt_rts_a_fb *)pvRTS; //Get SignalField,ServiceField,Length - BBvCalculateParameter(pDevice, uRTSFrameLen, pDevice->byTopOFDMBasicRate, byPktType, - (u16 *)&(wLen), (u8 *)&(pBuf->byServiceField), (u8 *)&(pBuf->bySignalField) - ); + BBvCalculateParameter(pDevice, uRTSFrameLen, + pDevice->byTopOFDMBasicRate, byPktType, &pBuf->a); //Get Duration pBuf->wDuration = s_uGetRTSCTSDuration(pDevice, RTSDUR_AA, cbFrameLength, byPktType, wCurrentRate, @@ -753,9 +738,8 @@ static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, else if (byPktType == PK_TYPE_11B) { struct vnt_rts_ab *pBuf = (struct vnt_rts_ab *)pvRTS; //Get SignalField,ServiceField,Length - BBvCalculateParameter(pDevice, uRTSFrameLen, pDevice->byTopCCKBasicRate, PK_TYPE_11B, - (u16 *)&(wLen), (u8 *)&(pBuf->byServiceField), (u8 *)&(pBuf->bySignalField) - ); + BBvCalculateParameter(pDevice, uRTSFrameLen, pDevice->byTopCCKBasicRate, + PK_TYPE_11B, &pBuf->ab); //Get Duration pBuf->wDuration = s_uGetRTSCTSDuration(pDevice, RTSDUR_BB, cbFrameLength, byPktType, wCurrentRate, @@ -783,7 +767,6 @@ static void s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx, int bDisCRC, u16 wCurrentRate, u8 byFBOption) { u32 uCTSFrameLen = 14; - u16 wLen = 0; if (pvCTS == NULL) { return; @@ -799,10 +782,9 @@ static void s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx, if (byFBOption != AUTO_FB_NONE) { /* Auto Fall back */ struct vnt_cts_fb *pBuf = (struct vnt_cts_fb *)pvCTS; - //Get SignalField,ServiceField,Length - BBvCalculateParameter(pDevice, uCTSFrameLen, pDevice->byTopCCKBasicRate, PK_TYPE_11B, - (u16 *)&(wLen), (u8 *)&(pBuf->byServiceField_b), (u8 *)&(pBuf->bySignalField_b) - ); + /* Get SignalField,ServiceField,Length */ + BBvCalculateParameter(pDevice, uCTSFrameLen, + pDevice->byTopCCKBasicRate, PK_TYPE_11B, &pBuf->b); pBuf->wDuration_ba = s_uGetRTSCTSDuration(pDevice, CTSDUR_BA, cbFrameLength, byPktType, wCurrentRate, bNeedAck, byFBOption); @@ -820,10 +802,9 @@ static void s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx, memcpy(pBuf->data.ra, pDevice->abyCurrentNetAddr, ETH_ALEN); } else { struct vnt_cts *pBuf = (struct vnt_cts *)pvCTS; - //Get SignalField,ServiceField,Length - BBvCalculateParameter(pDevice, uCTSFrameLen, pDevice->byTopCCKBasicRate, PK_TYPE_11B, - (u16 *)&(wLen), (u8 *)&(pBuf->byServiceField_b), (u8 *)&(pBuf->bySignalField_b) - ); + /* Get SignalField,ServiceField,Length */ + BBvCalculateParameter(pDevice, uCTSFrameLen, + pDevice->byTopCCKBasicRate, PK_TYPE_11B, &pBuf->b); /* Get CTSDuration_ba */ pBuf->wDuration_ba = s_uGetRTSCTSDuration(pDevice, CTSDUR_BA, cbFrameLength, byPktType, @@ -1821,9 +1802,8 @@ CMD_STATUS csBeacon_xmit(struct vnt_private *pDevice, pTxDataHead = (struct vnt_tx_datahead_ab *) (pbyTxBufferAddr + wTxBufSize); //Get SignalField,ServiceField,Length - BBvCalculateParameter(pDevice, cbFrameSize, wCurrentRate, PK_TYPE_11A, - (u16 *)&(pTxDataHead->wTransmitLength), (u8 *)&(pTxDataHead->byServiceField), (u8 *)&(pTxDataHead->bySignalField) - ); + BBvCalculateParameter(pDevice, cbFrameSize, wCurrentRate, PK_TYPE_11A, + &pTxDataHead->ab); //Get Duration and TimeStampOff pTxDataHead->wDuration = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A, PK_TYPE_11A, false)); @@ -1835,9 +1815,8 @@ CMD_STATUS csBeacon_xmit(struct vnt_private *pDevice, pTxDataHead = (struct vnt_tx_datahead_ab *) (pbyTxBufferAddr + wTxBufSize); //Get SignalField,ServiceField,Length - BBvCalculateParameter(pDevice, cbFrameSize, wCurrentRate, PK_TYPE_11B, - (u16 *)&(pTxDataHead->wTransmitLength), (u8 *)&(pTxDataHead->byServiceField), (u8 *)&(pTxDataHead->bySignalField) - ); + BBvCalculateParameter(pDevice, cbFrameSize, wCurrentRate, PK_TYPE_11B, + &pTxDataHead->ab); //Get Duration and TimeStampOff pTxDataHead->wDuration = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_B, PK_TYPE_11B, false)); diff --git a/drivers/staging/vt6656/rxtx.h b/drivers/staging/vt6656/rxtx.h index b1ef90eac4ea3..3484f2b16640b 100644 --- a/drivers/staging/vt6656/rxtx.h +++ b/drivers/staging/vt6656/rxtx.h @@ -31,6 +31,7 @@ #include "device.h" #include "wcmd.h" +#include "baseband.h" /* RsvTime buffer header */ struct vnt_rrv_time_rts { @@ -56,12 +57,8 @@ struct vnt_rrv_time_ab { /* TX data header */ struct vnt_tx_datahead_g { - u8 bySignalField_b; - u8 byServiceField_b; - u16 wTransmitLength_b; - u8 bySignalField_a; - u8 byServiceField_a; - u16 wTransmitLength_a; + struct vnt_phy_field b; + struct vnt_phy_field a; u16 wDuration_b; u16 wDuration_a; u16 wTimeStampOff_b; @@ -69,12 +66,8 @@ struct vnt_tx_datahead_g { } __packed; struct vnt_tx_datahead_g_fb { - u8 bySignalField_b; - u8 byServiceField_b; - u16 wTransmitLength_b; - u8 bySignalField_a; - u8 byServiceField_a; - u16 wTransmitLength_a; + struct vnt_phy_field b; + struct vnt_phy_field a; u16 wDuration_b; u16 wDuration_a; u16 wDuration_a_f0; @@ -84,17 +77,13 @@ struct vnt_tx_datahead_g_fb { } __packed; struct vnt_tx_datahead_ab { - u8 bySignalField; - u8 byServiceField; - u16 wTransmitLength; + struct vnt_phy_field ab; u16 wDuration; u16 wTimeStampOff; } __packed; struct vnt_tx_datahead_a_fb { - u8 bySignalField; - u8 byServiceField; - u16 wTransmitLength; + struct vnt_phy_field a; u16 wDuration; u16 wTimeStampOff; u16 wDuration_f0; @@ -103,12 +92,8 @@ struct vnt_tx_datahead_a_fb { /* RTS buffer header */ struct vnt_rts_g { - u8 bySignalField_b; - u8 byServiceField_b; - u16 wTransmitLength_b; - u8 bySignalField_a; - u8 byServiceField_a; - u16 wTransmitLength_a; + struct vnt_phy_field b; + struct vnt_phy_field a; u16 wDuration_ba; u16 wDuration_aa; u16 wDuration_bb; @@ -117,12 +102,8 @@ struct vnt_rts_g { } __packed; struct vnt_rts_g_fb { - u8 bySignalField_b; - u8 byServiceField_b; - u16 wTransmitLength_b; - u8 bySignalField_a; - u8 byServiceField_a; - u16 wTransmitLength_a; + struct vnt_phy_field b; + struct vnt_phy_field a; u16 wDuration_ba; u16 wDuration_aa; u16 wDuration_bb; @@ -135,18 +116,14 @@ struct vnt_rts_g_fb { } __packed; struct vnt_rts_ab { - u8 bySignalField; - u8 byServiceField; - u16 wTransmitLength; + struct vnt_phy_field ab; u16 wDuration; u16 wReserved; struct ieee80211_rts data; } __packed; struct vnt_rts_a_fb { - u8 bySignalField; - u8 byServiceField; - u16 wTransmitLength; + struct vnt_phy_field a; u16 wDuration; u16 wReserved; u16 wRTSDuration_f0; @@ -156,9 +133,7 @@ struct vnt_rts_a_fb { /* CTS buffer header */ struct vnt_cts { - u8 bySignalField_b; - u8 byServiceField_b; - u16 wTransmitLength_b; + struct vnt_phy_field b; u16 wDuration_ba; u16 wReserved; struct ieee80211_cts data; @@ -166,9 +141,7 @@ struct vnt_cts { } __packed; struct vnt_cts_fb { - u8 bySignalField_b; - u8 byServiceField_b; - u16 wTransmitLength_b; + struct vnt_phy_field b; u16 wDuration_ba; u16 wReserved; u16 wCTSDuration_ba_f0; -- GitLab From 4cfa73097f50c01057754112ef25f5edadf79c9d Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Wed, 21 Aug 2013 13:26:40 -0400 Subject: [PATCH 730/942] staging: dgnc: removes CVS code from files This patch removes the code supporting CVS from its files. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_cls.c | 2 -- drivers/staging/dgnc/dgnc_driver.c | 2 -- drivers/staging/dgnc/dgnc_mgmt.c | 1 - drivers/staging/dgnc/dgnc_neo.c | 2 -- drivers/staging/dgnc/dgnc_pci.h | 2 -- drivers/staging/dgnc/dgnc_sysfs.c | 3 --- drivers/staging/dgnc/dgnc_trace.c | 2 -- drivers/staging/dgnc/dgnc_trace.h | 1 - drivers/staging/dgnc/dgnc_tty.c | 1 - drivers/staging/dgnc/digi.h | 2 -- 10 files changed, 18 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_cls.c b/drivers/staging/dgnc/dgnc_cls.c index cf997bea4bc1c..92ecbfb62515e 100644 --- a/drivers/staging/dgnc/dgnc_cls.c +++ b/drivers/staging/dgnc/dgnc_cls.c @@ -27,8 +27,6 @@ * Send any bug fixes/changes to: Eng.Linux at digi dot com. * Thank you. * - * - * $Id: dgnc_cls.c,v 1.1.1.1 2009/05/20 12:19:19 markh Exp $ */ #include diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c index ad7a8f1353b89..4ed35efb6cbdd 100644 --- a/drivers/staging/dgnc/dgnc_driver.c +++ b/drivers/staging/dgnc/dgnc_driver.c @@ -27,8 +27,6 @@ * Send any bug fixes/changes to: Eng.Linux at digi dot com. * Thank you. * - * $Id: dgnc_driver.c,v 1.3 2011/06/23 12:47:35 markh Exp $ - * */ diff --git a/drivers/staging/dgnc/dgnc_mgmt.c b/drivers/staging/dgnc/dgnc_mgmt.c index c86303985c1d5..c4629d7c80b21 100644 --- a/drivers/staging/dgnc/dgnc_mgmt.c +++ b/drivers/staging/dgnc/dgnc_mgmt.c @@ -35,7 +35,6 @@ * Neo and ClassicBoard based product lines. * ************************************************************************ - * $Id: dgnc_mgmt.c,v 1.2 2010/12/14 20:08:29 markh Exp $ */ #include #include diff --git a/drivers/staging/dgnc/dgnc_neo.c b/drivers/staging/dgnc/dgnc_neo.c index 9ca143ec8dba2..7e027808f32f9 100644 --- a/drivers/staging/dgnc/dgnc_neo.c +++ b/drivers/staging/dgnc/dgnc_neo.c @@ -27,8 +27,6 @@ * Send any bug fixes/changes to: Eng.Linux at digi dot com. * Thank you. * - * - * $Id: dgnc_neo.c,v 1.1.1.1 2009/05/20 12:19:19 markh Exp $ */ diff --git a/drivers/staging/dgnc/dgnc_pci.h b/drivers/staging/dgnc/dgnc_pci.h index 5550707ba1fb3..5b6f76d98aa72 100644 --- a/drivers/staging/dgnc/dgnc_pci.h +++ b/drivers/staging/dgnc/dgnc_pci.h @@ -19,8 +19,6 @@ * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! */ -/* $Id: dgnc_pci.h,v 1.1.1.1 2009/05/20 12:19:19 markh Exp $ */ - #ifndef __DGNC_PCI_H #define __DGNC_PCI_H diff --git a/drivers/staging/dgnc/dgnc_sysfs.c b/drivers/staging/dgnc/dgnc_sysfs.c index 1ed456ec53498..75a23000cbf40 100644 --- a/drivers/staging/dgnc/dgnc_sysfs.c +++ b/drivers/staging/dgnc/dgnc_sysfs.c @@ -27,9 +27,6 @@ * Send any bug fixes/changes to: Eng.Linux at digi dot com. * Thank you. * - * - * - * $Id: dgnc_sysfs.c,v 1.1.1.1 2009/05/20 12:19:19 markh Exp $ */ diff --git a/drivers/staging/dgnc/dgnc_trace.c b/drivers/staging/dgnc/dgnc_trace.c index 0f00ddcdeeea1..a98b7d4255c85 100644 --- a/drivers/staging/dgnc/dgnc_trace.c +++ b/drivers/staging/dgnc/dgnc_trace.c @@ -29,8 +29,6 @@ * */ -/* $Id: dgnc_trace.c,v 1.1.1.1 2009/05/20 12:19:19 markh Exp $ */ - #include #include /* For jiffies, task states */ #include /* For tasklet and interrupt structs/defines */ diff --git a/drivers/staging/dgnc/dgnc_trace.h b/drivers/staging/dgnc/dgnc_trace.h index 1e8870bf8eeeb..efed88a627dca 100644 --- a/drivers/staging/dgnc/dgnc_trace.h +++ b/drivers/staging/dgnc/dgnc_trace.h @@ -21,7 +21,6 @@ ***************************************************************************** * Header file for dgnc_trace.c * - * $Id: dgnc_trace.h,v 1.1.1.1 2009/05/20 12:19:19 markh Exp $ */ #ifndef __DGNC_TRACE_H diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c index feb0124a84179..5938c4a672cf9 100644 --- a/drivers/staging/dgnc/dgnc_tty.c +++ b/drivers/staging/dgnc/dgnc_tty.c @@ -35,7 +35,6 @@ * ************************************************************************ * - * $Id: dgnc_tty.c,v 1.5 2013/04/30 19:18:30 markh Exp $ */ #include diff --git a/drivers/staging/dgnc/digi.h b/drivers/staging/dgnc/digi.h index 8027eab969004..a9700be2c2e2c 100644 --- a/drivers/staging/dgnc/digi.h +++ b/drivers/staging/dgnc/digi.h @@ -16,8 +16,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: digi.h,v 1.1.1.1 2009/05/20 12:19:19 markh Exp $ - * * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! */ -- GitLab From 58b905b39ffd7efbfd6d3ec3dbfd439b0b448af0 Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Wed, 21 Aug 2013 13:27:15 -0400 Subject: [PATCH 731/942] staging: dgnc: tty.c: fixes pointer syntax This patch fixes the error: "foo* bar" should be "foo *bar". Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_tty.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c index 5938c4a672cf9..da035a53d567b 100644 --- a/drivers/staging/dgnc/dgnc_tty.c +++ b/drivers/staging/dgnc/dgnc_tty.c @@ -114,9 +114,9 @@ static int dgnc_block_til_ready(struct tty_struct *tty, struct file *file, struc static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg); static int dgnc_tty_digigeta(struct tty_struct *tty, struct digi_t __user *retinfo); static int dgnc_tty_digiseta(struct tty_struct *tty, struct digi_t __user *new_info); -static int dgnc_tty_write_room(struct tty_struct* tty); +static int dgnc_tty_write_room(struct tty_struct *tty); static int dgnc_tty_put_char(struct tty_struct *tty, unsigned char c); -static int dgnc_tty_chars_in_buffer(struct tty_struct* tty); +static int dgnc_tty_chars_in_buffer(struct tty_struct *tty); static void dgnc_tty_start(struct tty_struct *tty); static void dgnc_tty_stop(struct tty_struct *tty); static void dgnc_tty_throttle(struct tty_struct *tty); -- GitLab From ba48f61b135ad1ace174f548507b2af386372fd5 Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Wed, 21 Aug 2013 13:27:26 -0400 Subject: [PATCH 732/942] staging: dgnc: fixes struct declaration This patch fixes the error: open brace '{' following struct go on the same line. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_driver.h | 3 +-- drivers/staging/dgnc/digi.h | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_driver.h b/drivers/staging/dgnc/dgnc_driver.h index 84727a7151360..fbbb9f9f3ff9a 100644 --- a/drivers/staging/dgnc/dgnc_driver.h +++ b/drivers/staging/dgnc/dgnc_driver.h @@ -282,8 +282,7 @@ struct board_ops { /* * Per-board information */ -struct board_t -{ +struct board_t { int magic; /* Board Magic number. */ int boardnum; /* Board number: 0-32 */ diff --git a/drivers/staging/dgnc/digi.h b/drivers/staging/dgnc/digi.h index a9700be2c2e2c..eb6e371257276 100644 --- a/drivers/staging/dgnc/digi.h +++ b/drivers/staging/dgnc/digi.h @@ -318,8 +318,7 @@ struct digi_getbuffer /* Struct for holding buffer use counts */ unsigned long txdone; }; -struct digi_getcounter -{ +struct digi_getcounter { unsigned long norun; /* number of UART overrun errors */ unsigned long noflow; /* number of buffer overflow errors */ unsigned long nframe; /* number of framing errors */ -- GitLab From eae9842a5f10ae62ce653a12c8b9a150f544379f Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Wed, 21 Aug 2013 13:30:07 -0400 Subject: [PATCH 733/942] staging: dgnc: driver.c: fixes code indent error This patch fixes the error "code indent should use tabs where possible" in dgnc_driver.c. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_driver.c | 70 +++++++++++++++--------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c index 4ed35efb6cbdd..fa4e91a0950fd 100644 --- a/drivers/staging/dgnc/dgnc_driver.c +++ b/drivers/staging/dgnc/dgnc_driver.c @@ -97,7 +97,7 @@ module_exit(dgnc_cleanup_module); static struct file_operations dgnc_BoardFops = { .owner = THIS_MODULE, - .unlocked_ioctl = dgnc_mgmt_ioctl, + .unlocked_ioctl = dgnc_mgmt_ioctl, .open = dgnc_mgmt_open, .release = dgnc_mgmt_close }; @@ -297,9 +297,9 @@ static int dgnc_start(void) MKDEV(dgnc_Major, 0), NULL, "dgnc_mgmt"); #else - device_create(dgnc_class, NULL, - MKDEV(dgnc_Major, 0), - NULL, "dgnc_mgmt"); + device_create(dgnc_class, NULL, + MKDEV(dgnc_Major, 0), + NULL, "dgnc_mgmt"); #endif dgnc_Major_Control_Registered = TRUE; @@ -355,7 +355,7 @@ static int dgnc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) rc = dgnc_probe1(pdev, ent->driver_data); if (rc == 0) { dgnc_NumBoards++; - DPR_INIT(("Incrementing numboards to %d\n", dgnc_NumBoards)); + DPR_INIT(("Incrementing numboards to %d\n", dgnc_NumBoards)); } } return rc; @@ -423,8 +423,8 @@ static void dgnc_cleanup_board(struct board_t *brd) { int i = 0; - if(!brd || brd->magic != DGNC_BOARD_MAGIC) - return; + if(!brd || brd->magic != DGNC_BOARD_MAGIC) + return; switch (brd->device) { case PCI_DEVICE_CLASSIC_4_DID: @@ -459,7 +459,7 @@ static void dgnc_cleanup_board(struct board_t *brd) kfree(brd->msgbuf_head); brd->msgbuf_head = NULL; DGNC_UNLOCK(dgnc_global_lock, flags); - } + } /* Free all allocated channels structs */ for (i = 0; i < MAXPORTS ; i++) { @@ -481,7 +481,7 @@ static void dgnc_cleanup_board(struct board_t *brd) dgnc_Board[brd->boardnum] = NULL; - kfree(brd); + kfree(brd); } @@ -492,28 +492,28 @@ static void dgnc_cleanup_board(struct board_t *brd) */ static int dgnc_found_board(struct pci_dev *pdev, int id) { - struct board_t *brd; + struct board_t *brd; unsigned int pci_irq; int i = 0; int rc = 0; unsigned long flags; - /* get the board structure and prep it */ - brd = dgnc_Board[dgnc_NumBoards] = - (struct board_t *) dgnc_driver_kzmalloc(sizeof(struct board_t), GFP_KERNEL); + /* get the board structure and prep it */ + brd = dgnc_Board[dgnc_NumBoards] = + (struct board_t *) dgnc_driver_kzmalloc(sizeof(struct board_t), GFP_KERNEL); if (!brd) { APR(("memory allocation for board structure failed\n")); return(-ENOMEM); } - /* make a temporary message buffer for the boot messages */ - brd->msgbuf = brd->msgbuf_head = - (char *) dgnc_driver_kzmalloc(sizeof(char) * 8192, GFP_KERNEL); - if (!brd->msgbuf) { + /* make a temporary message buffer for the boot messages */ + brd->msgbuf = brd->msgbuf_head = + (char *) dgnc_driver_kzmalloc(sizeof(char) * 8192, GFP_KERNEL); + if (!brd->msgbuf) { kfree(brd); APR(("memory allocation for board msgbuf failed\n")); return(-ENOMEM); - } + } /* store the info for the board we've found */ brd->magic = DGNC_BOARD_MAGIC; @@ -557,16 +557,16 @@ static int dgnc_found_board(struct pci_dev *pdev, int id) brd->dpatype = T_CLASSIC | T_PCIBUS; - DPR_INIT(("dgnc_found_board - Classic.\n")); + DPR_INIT(("dgnc_found_board - Classic.\n")); /* * For PCI ClassicBoards * PCI Local Address (i.e. "resource" number) space - * 0 PLX Memory Mapped Config - * 1 PLX I/O Mapped Config - * 2 I/O Mapped UARTs and Status - * 3 Memory Mapped VPD - * 4 Memory Mapped UARTs and Status + * 0 PLX Memory Mapped Config + * 1 PLX I/O Mapped Config + * 2 I/O Mapped UARTs and Status + * 3 Memory Mapped VPD + * 4 Memory Mapped UARTs and Status */ @@ -585,9 +585,9 @@ static int dgnc_found_board(struct pci_dev *pdev, int id) else brd->membase &= ~15; - brd->iobase = pci_resource_start(pdev, 1); + brd->iobase = pci_resource_start(pdev, 1); brd->iobase_end = pci_resource_end(pdev, 1); - brd->iobase = ((unsigned int) (brd->iobase)) & 0xFFFE; + brd->iobase = ((unsigned int) (brd->iobase)) & 0xFFFE; /* Assign the board_ops struct */ brd->bd_ops = &dgnc_cls_ops; @@ -633,7 +633,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id) else brd->dpatype = T_NEO | T_PCIBUS; - DPR_INIT(("dgnc_found_board - NEO.\n")); + DPR_INIT(("dgnc_found_board - NEO.\n")); /* get the PCI Base Address Registers */ brd->membase = pci_resource_start(pdev, 0); @@ -730,7 +730,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id) wake_up_interruptible(&brd->state_wait); - return(0); + return(0); failed: @@ -742,12 +742,12 @@ static int dgnc_found_board(struct pci_dev *pdev, int id) static int dgnc_finalize_board_init(struct board_t *brd) { int rc = 0; - DPR_INIT(("dgnc_finalize_board_init() - start\n")); + DPR_INIT(("dgnc_finalize_board_init() - start\n")); if (!brd || brd->magic != DGNC_BOARD_MAGIC) - return(-ENODEV); + return(-ENODEV); - DPR_INIT(("dgnc_finalize_board_init() - start #2\n")); + DPR_INIT(("dgnc_finalize_board_init() - start #2\n")); if (brd->irq) { rc = request_irq(brd->irq, brd->bd_ops->intr, IRQF_SHARED, "DGNC", brd); @@ -807,8 +807,8 @@ static void dgnc_do_remap(struct board_t *brd) static void dgnc_poll_handler(ulong dummy) { - struct board_t *brd; - unsigned long lock_flags; + struct board_t *brd; + unsigned long lock_flags; int i; unsigned long new_time; @@ -877,7 +877,7 @@ static void dgnc_init_globals(void) int i = 0; dgnc_rawreadok = rawreadok; - dgnc_trcbuf_size = trcbuf_size; + dgnc_trcbuf_size = trcbuf_size; dgnc_debug = debug; for (i = 0; i < MAXBOARDS; i++) { @@ -902,7 +902,7 @@ static void dgnc_init_globals(void) */ void *dgnc_driver_kzmalloc(size_t size, int priority) { - void *p = kmalloc(size, priority); + void *p = kmalloc(size, priority); if(p) memset(p, 0, size); return(p); -- GitLab From 5a62025d4bbd98040daec93ed52c1ffe7eee2ef1 Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Wed, 21 Aug 2013 13:30:08 -0400 Subject: [PATCH 734/942] staging: dgnc: driver.h: fixes code indent error This patch fixes the error "code indent should use tabs where possible" in dgnc_driver.h. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_driver.h | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_driver.h b/drivers/staging/dgnc/dgnc_driver.h index fbbb9f9f3ff9a..47bc781ac5742 100644 --- a/drivers/staging/dgnc/dgnc_driver.h +++ b/drivers/staging/dgnc/dgnc_driver.h @@ -28,7 +28,7 @@ #define __DGNC_DRIVER_H #include /* To pick up the varions Linux types */ -#include /* To pick up the various tty structs/defines */ +#include /* To pick up the various tty structs/defines */ #include /* For irqreturn_t type */ #include "dgnc_types.h" /* Additional types needed by the Digi header files */ @@ -250,7 +250,7 @@ struct board_t; struct channel_t; /************************************************************************ - * Per board operations structure * + * Per board operations structure * ************************************************************************/ struct board_ops { void (*tasklet) (unsigned long data); @@ -276,7 +276,7 @@ struct board_ops { /************************************************************************ * Device flag definitions for bd_flags. ************************************************************************/ -#define BD_IS_PCI_EXPRESS 0x0001 /* Is a PCI Express board */ +#define BD_IS_PCI_EXPRESS 0x0001 /* Is a PCI Express board */ /* @@ -354,8 +354,8 @@ struct board_t { /* * Mgmt data. */ - char *msgbuf_head; - char *msgbuf; + char *msgbuf_head; + char *msgbuf; uint bd_dividend; /* Board/UARTs specific dividend */ @@ -451,26 +451,26 @@ struct channel_t { int magic; /* Channel Magic Number */ struct board_t *ch_bd; /* Board structure pointer */ struct digi_t ch_digi; /* Transparent Print structure */ - struct un_t ch_tun; /* Terminal unit info */ - struct un_t ch_pun; /* Printer unit info */ + struct un_t ch_tun; /* Terminal unit info */ + struct un_t ch_pun; /* Printer unit info */ spinlock_t ch_lock; /* provide for serialization */ wait_queue_head_t ch_flags_wait; uint ch_portnum; /* Port number, 0 offset. */ uint ch_open_count; /* open count */ - uint ch_flags; /* Channel flags */ + uint ch_flags; /* Channel flags */ ulong ch_close_delay; /* How long we should drop RTS/DTR for */ ulong ch_cpstime; /* Time for CPS calculations */ - tcflag_t ch_c_iflag; /* channel iflags */ - tcflag_t ch_c_cflag; /* channel cflags */ - tcflag_t ch_c_oflag; /* channel oflags */ - tcflag_t ch_c_lflag; /* channel lflags */ - uchar ch_stopc; /* Stop character */ - uchar ch_startc; /* Start character */ + tcflag_t ch_c_iflag; /* channel iflags */ + tcflag_t ch_c_cflag; /* channel cflags */ + tcflag_t ch_c_oflag; /* channel oflags */ + tcflag_t ch_c_lflag; /* channel lflags */ + uchar ch_stopc; /* Stop character */ + uchar ch_startc; /* Start character */ uint ch_old_baud; /* Cache of the current baud */ uint ch_custom_speed;/* Custom baud, if set */ @@ -530,7 +530,7 @@ struct channel_t { uint ch_sniff_in; uint ch_sniff_out; char *ch_sniff_buf; /* Sniff buffer for proc */ - ulong ch_sniff_flags; /* Channel flags */ + ulong ch_sniff_flags; /* Channel flags */ wait_queue_head_t ch_sniff_wait; }; -- GitLab From 00804f773bad78dd15f9b5baae45d2808bc3f062 Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Wed, 21 Aug 2013 13:30:09 -0400 Subject: [PATCH 735/942] staging: dgnc: neo.c: fixes code indent error This patch fixes the error "code indent should use tabs where possible" in dgnc_neo.c. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_neo.c | 46 ++++++++++++++++----------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_neo.c b/drivers/staging/dgnc/dgnc_neo.c index 7e027808f32f9..22c8ce32f8cdd 100644 --- a/drivers/staging/dgnc/dgnc_neo.c +++ b/drivers/staging/dgnc/dgnc_neo.c @@ -260,7 +260,7 @@ static inline void neo_set_ixoff_flow_control(struct channel_t *ch) writeb((UART_17158_FCTR_TRGD | UART_17158_FCTR_RTS_8DELAY), &ch->ch_neo_uart->fctr); writeb(8, &ch->ch_neo_uart->tfifo); - ch->ch_t_tlevel = 8; + ch->ch_t_tlevel = 8; /* Tell UART what start/stop chars it should be looking for */ writeb(ch->ch_startc, &ch->ch_neo_uart->xonchar1); @@ -306,10 +306,10 @@ static inline void neo_set_no_input_flow_control(struct channel_t *ch) ch->ch_r_watermark = 0; writeb(16, &ch->ch_neo_uart->tfifo); - ch->ch_t_tlevel = 16; + ch->ch_t_tlevel = 16; writeb(16, &ch->ch_neo_uart->rfifo); - ch->ch_r_tlevel = 16; + ch->ch_r_tlevel = 16; writeb(ier, &ch->ch_neo_uart->ier); @@ -346,10 +346,10 @@ static inline void neo_set_no_output_flow_control(struct channel_t *ch) ch->ch_r_watermark = 0; writeb(16, &ch->ch_neo_uart->tfifo); - ch->ch_t_tlevel = 16; + ch->ch_t_tlevel = 16; writeb(16, &ch->ch_neo_uart->rfifo); - ch->ch_r_tlevel = 16; + ch->ch_r_tlevel = 16; writeb(ier, &ch->ch_neo_uart->ier); @@ -397,13 +397,13 @@ static inline void neo_clear_break(struct channel_t *ch, int force) if (ch->ch_flags & CH_BREAK_SENDING) { if ((jiffies >= ch->ch_stop_sending_break) || force) { uchar temp = readb(&ch->ch_neo_uart->lcr); - writeb((temp & ~UART_LCR_SBC), &ch->ch_neo_uart->lcr); + writeb((temp & ~UART_LCR_SBC), &ch->ch_neo_uart->lcr); neo_pci_posting_flush(ch->ch_bd); ch->ch_flags &= ~(CH_BREAK_SENDING); ch->ch_stop_sending_break = 0; DPR_IOCTL(("Finishing UART_LCR_SBC! finished: %lx\n", jiffies)); - } - } + } + } DGNC_UNLOCK(ch->ch_lock, lock_flags); } @@ -648,11 +648,11 @@ static void neo_param(struct tty_struct *tty) uchar uart_lcr = 0; uchar ier = 0; uchar uart_ier = 0; - uint baud = 9600; + uint baud = 9600; int quot = 0; - struct board_t *bd; + struct board_t *bd; struct channel_t *ch; - struct un_t *un; + struct un_t *un; if (!tty || tty->magic != TTY_MAGIC) { return; @@ -827,7 +827,7 @@ static void neo_param(struct tty_struct *tty) writeb((quot & 0xff), &ch->ch_neo_uart->txrx); writeb((quot >> 8), &ch->ch_neo_uart->ier); writeb(lcr, &ch->ch_neo_uart->lcr); - } + } if (uart_lcr != lcr) writeb(lcr, &ch->ch_neo_uart->lcr); @@ -911,7 +911,7 @@ static void neo_param(struct tty_struct *tty) */ static void neo_tasklet(unsigned long data) { - struct board_t *bd = (struct board_t *) data; + struct board_t *bd = (struct board_t *) data; struct channel_t *ch; ulong lock_flags; int i; @@ -1077,7 +1077,7 @@ static irqreturn_t neo_intr(int irq, void *voidbrd) case UART_17158_RXRDY_TIMEOUT: /* * RXRDY Time-out is cleared by reading data in the - * RX FIFO until it falls below the trigger level. + * RX FIFO until it falls below the trigger level. */ /* Verify the port is in range. */ @@ -1178,11 +1178,11 @@ static void neo_enable_receiver(struct channel_t *ch) static void neo_copy_data_from_uart_to_queue(struct channel_t *ch) { - int qleft = 0; + int qleft = 0; uchar linestatus = 0; uchar error_mask = 0; - int n = 0; - int total = 0; + int n = 0; + int total = 0; ushort head; ushort tail; ulong lock_flags; @@ -1400,7 +1400,7 @@ static int neo_drain(struct tty_struct *tty, uint seconds) { ulong lock_flags; struct channel_t *ch; - struct un_t *un; + struct un_t *un; int rc = 0; if (!tty || tty->magic != TTY_MAGIC) { @@ -1439,7 +1439,7 @@ static int neo_drain(struct tty_struct *tty, uint seconds) DPR_IOCTL(("%d Drain wait finished.\n", __LINE__)); } - return (rc); + return (rc); } @@ -1792,7 +1792,7 @@ static void neo_uart_init(struct channel_t *ch) writeb(UART_EFR_ECB, &ch->ch_neo_uart->efr); - /* Clear out UART and FIFO */ + /* Clear out UART and FIFO */ readb(&ch->ch_neo_uart->txrx); writeb((UART_FCR_ENABLE_FIFO|UART_FCR_CLEAR_RCVR|UART_FCR_CLEAR_XMIT), &ch->ch_neo_uart->isr_fcr); readb(&ch->ch_neo_uart->lsr); @@ -1831,7 +1831,7 @@ static uint neo_get_uart_bytes_left(struct channel_t *ch) /* Determine whether the Transmitter is empty or not */ if (!(lsr & UART_LSR_TEMT)) { if (ch->ch_flags & CH_TX_FIFO_EMPTY) { - tasklet_schedule(&ch->ch_bd->helper_tasklet); + tasklet_schedule(&ch->ch_bd->helper_tasklet); } left = 1; } else { @@ -1871,12 +1871,12 @@ static void neo_send_break(struct channel_t *ch, int msecs) /* Tell the UART to start sending the break */ if (!(ch->ch_flags & CH_BREAK_SENDING)) { uchar temp = readb(&ch->ch_neo_uart->lcr); - writeb((temp | UART_LCR_SBC), &ch->ch_neo_uart->lcr); + writeb((temp | UART_LCR_SBC), &ch->ch_neo_uart->lcr); neo_pci_posting_flush(ch->ch_bd); ch->ch_flags |= (CH_BREAK_SENDING); DPR_IOCTL(("Port %d. Starting UART_LCR_SBC! start: %lx should end: %lx\n", ch->ch_portnum, jiffies, ch->ch_stop_sending_break)); - } + } } -- GitLab From 0a60eb3313b4ac3bc173f21d828f893705b32245 Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Wed, 21 Aug 2013 13:30:10 -0400 Subject: [PATCH 736/942] staging: dgnc: sysfs.c: fixes code indent error This patch fixes the error "code indent should use tabs where possible" in dgnc_sysfs.c. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_sysfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_sysfs.c b/drivers/staging/dgnc/dgnc_sysfs.c index 75a23000cbf40..0ea6c80028050 100644 --- a/drivers/staging/dgnc/dgnc_sysfs.c +++ b/drivers/staging/dgnc/dgnc_sysfs.c @@ -728,8 +728,8 @@ static struct attribute *dgnc_sysfs_tty_entries[] = { static struct attribute_group dgnc_tty_attribute_group = { - .name = NULL, - .attrs = dgnc_sysfs_tty_entries, + .name = NULL, + .attrs = dgnc_sysfs_tty_entries, }; -- GitLab From 90d2a47152ae1fde6dc60f7bf9952035bb0e4924 Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Wed, 21 Aug 2013 13:30:11 -0400 Subject: [PATCH 737/942] staging: dgnc: tty.c: fixes code indent error This patch fixes the error "code indent should use tabs where possible" in dgnc_tty.c. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_tty.c | 156 ++++++++++++++++---------------- 1 file changed, 78 insertions(+), 78 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c index da035a53d567b..f0ecc65b86b77 100644 --- a/drivers/staging/dgnc/dgnc_tty.c +++ b/drivers/staging/dgnc/dgnc_tty.c @@ -47,7 +47,7 @@ #include #include #include -#include /* For udelay */ +#include /* For udelay */ #include /* For copy_from_user/copy_to_user */ #include @@ -61,9 +61,9 @@ #include "dgnc_sysfs.h" #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37) -#define init_MUTEX(sem) sema_init(sem, 1) +#define init_MUTEX(sem) sema_init(sem, 1) #define DECLARE_MUTEX(name) \ - struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) + struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) #endif /* @@ -208,7 +208,7 @@ int dgnc_tty_register(struct board_t *brd) DPR_INIT(("tty_register start\n")); - memset(&brd->SerialDriver, 0, sizeof(struct tty_driver)); + memset(&brd->SerialDriver, 0, sizeof(struct tty_driver)); memset(&brd->PrintDriver, 0, sizeof(struct tty_driver)); brd->SerialDriver.magic = TTY_DRIVER_MAGIC; @@ -235,9 +235,9 @@ int dgnc_tty_register(struct board_t *brd) return(-ENOMEM); #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28) - brd->SerialDriver.refcount = brd->TtyRefCnt; + brd->SerialDriver.refcount = brd->TtyRefCnt; #else - kref_init(&brd->SerialDriver.kref); + kref_init(&brd->SerialDriver.kref); #endif brd->SerialDriver.termios = dgnc_driver_kzmalloc(brd->maxports * sizeof(struct ktermios *), GFP_KERNEL); @@ -294,9 +294,9 @@ int dgnc_tty_register(struct board_t *brd) return(-ENOMEM); #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28) - brd->PrintDriver.refcount = brd->TtyRefCnt; + brd->PrintDriver.refcount = brd->TtyRefCnt; #else - kref_init(&brd->PrintDriver.kref); + kref_init(&brd->PrintDriver.kref); #endif brd->PrintDriver.termios = dgnc_driver_kzmalloc(brd->maxports * sizeof(struct ktermios *), GFP_KERNEL); @@ -317,7 +317,7 @@ int dgnc_tty_register(struct board_t *brd) if (!brd->dgnc_Major_TransparentPrint_Registered) { /* Register Transparent Print devices */ - rc = tty_register_driver(&brd->PrintDriver); + rc = tty_register_driver(&brd->PrintDriver); if (rc < 0) { APR(("Can't register Transparent Print device (%d)\n", rc)); return(rc); @@ -493,7 +493,7 @@ void dgnc_tty_uninit(struct board_t *brd) if (brd->PrintDriver.ttys) { kfree(brd->PrintDriver.ttys); brd->PrintDriver.ttys = NULL; - } + } } @@ -666,7 +666,7 @@ static void dgnc_wmove(struct channel_t *ch, char *buf, uint n) * * dgnc_input - Process received data. * - * ch - Pointer to channel structure. + * ch - Pointer to channel structure. * *=======================================================================*/ void dgnc_input(struct channel_t *ch) @@ -714,7 +714,7 @@ void dgnc_input(struct channel_t *ch) /* * If the device is not open, or CREAD is off, - * flush input data and return immediately. + * flush input data and return immediately. */ if (!tp || (tp->magic != TTY_MAGIC) || !(ch->ch_tun.un_flags & UN_ISOPEN) || !(tp->termios.c_cflag & CREAD) || (ch->ch_tun.un_flags & UN_CLOSING)) { @@ -869,8 +869,8 @@ void dgnc_carrier(struct channel_t *ch) { struct board_t *bd; - int virt_carrier = 0; - int phys_carrier = 0; + int virt_carrier = 0; + int phys_carrier = 0; DPR_CARR(("dgnc_carrier called...\n")); @@ -1006,7 +1006,7 @@ static void dgnc_set_custom_speed(struct channel_t *ch, uint newrate) newrate = ((ch->ch_bd->bd_dividend / 0xFFFF) + 1); if (newrate && newrate > ch->ch_bd->bd_dividend) - newrate = ch->ch_bd->bd_dividend; + newrate = ch->ch_bd->bd_dividend; while (newrate > 0) { testdiv = ch->ch_bd->bd_dividend / newrate; @@ -1037,7 +1037,7 @@ static void dgnc_set_custom_speed(struct channel_t *ch, uint newrate) if (deltahigh < deltalow) { newrate = testrate_high; - } else { + } else { newrate = testrate_low; } @@ -1150,7 +1150,7 @@ void dgnc_wakeup_writes(struct channel_t *ch) * If channel now has space, wake up anyone waiting on the condition. */ if ((qlen = ch->ch_w_head - ch->ch_w_tail) < 0) - qlen += WQUEUESIZE; + qlen += WQUEUESIZE; if (qlen >= (WQUEUESIZE - 256)) { DGNC_UNLOCK(ch->ch_lock, lock_flags); @@ -1159,13 +1159,13 @@ void dgnc_wakeup_writes(struct channel_t *ch) if (ch->ch_tun.un_flags & UN_ISOPEN) { #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30) - if ((ch->ch_tun.un_tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && - ch->ch_tun.un_tty->ldisc->ops->write_wakeup) - { - DGNC_UNLOCK(ch->ch_lock, lock_flags); - (ch->ch_tun.un_tty->ldisc->ops->write_wakeup)(ch->ch_tun.un_tty); - DGNC_LOCK(ch->ch_lock, lock_flags); - } + if ((ch->ch_tun.un_tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && + ch->ch_tun.un_tty->ldisc->ops->write_wakeup) + { + DGNC_UNLOCK(ch->ch_lock, lock_flags); + (ch->ch_tun.un_tty->ldisc->ops->write_wakeup)(ch->ch_tun.un_tty); + DGNC_LOCK(ch->ch_lock, lock_flags); + } #else if ((ch->ch_tun.un_tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && ch->ch_tun.un_tty->ldisc.ops->write_wakeup) @@ -1211,13 +1211,13 @@ void dgnc_wakeup_writes(struct channel_t *ch) if (ch->ch_pun.un_flags & UN_ISOPEN) { #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30) - if ((ch->ch_pun.un_tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && - ch->ch_pun.un_tty->ldisc->ops->write_wakeup) - { - DGNC_UNLOCK(ch->ch_lock, lock_flags); - (ch->ch_pun.un_tty->ldisc->ops->write_wakeup)(ch->ch_pun.un_tty); - DGNC_LOCK(ch->ch_lock, lock_flags); - } + if ((ch->ch_pun.un_tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && + ch->ch_pun.un_tty->ldisc->ops->write_wakeup) + { + DGNC_UNLOCK(ch->ch_lock, lock_flags); + (ch->ch_pun.un_tty->ldisc->ops->write_wakeup)(ch->ch_pun.un_tty); + DGNC_LOCK(ch->ch_lock, lock_flags); + } #else if ((ch->ch_pun.un_tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && ch->ch_pun.un_tty->ldisc.ops->write_wakeup) @@ -1722,8 +1722,8 @@ static void dgnc_tty_close(struct tty_struct *tty, struct file *file) ch->ch_open_count, un->un_open_count)); DGNC_UNLOCK(ch->ch_lock, lock_flags); - return; - } + return; + } /* OK, its the last close on the unit */ DPR_CLOSE(("dgnc_tty_close - last close on unit procedures\n")); @@ -1735,7 +1735,7 @@ static void dgnc_tty_close(struct tty_struct *tty, struct file *file) /* * Only officially close channel if count is 0 and - * DIGI_PRINTER bit is not set. + * DIGI_PRINTER bit is not set. */ if ((ch->ch_open_count == 0) && !(ch->ch_digi.digi_flags & DIGI_PRINTER)) { @@ -1820,7 +1820,7 @@ static void dgnc_tty_close(struct tty_struct *tty, struct file *file) DGNC_UNLOCK(ch->ch_lock, lock_flags); - DPR_BASIC(("dgnc_tty_close - complete\n")); + DPR_BASIC(("dgnc_tty_close - complete\n")); } @@ -1870,10 +1870,10 @@ static int dgnc_tty_chars_in_buffer(struct tty_struct *tty) chars = thead - ttail + WQUEUESIZE; } - DPR_WRITE(("dgnc_tty_chars_in_buffer. Port: %x - %d (head: %d tail: %d)\n", + DPR_WRITE(("dgnc_tty_chars_in_buffer. Port: %x - %d (head: %d tail: %d)\n", ch->ch_portnum, chars, thead, ttail)); - return(chars); + return(chars); } @@ -1916,7 +1916,7 @@ static int dgnc_maxcps_room(struct tty_struct *tty, int bytes_available) if (ch->ch_cpstime < current_time) { /* buffer is empty */ - ch->ch_cpstime = current_time; /* reset ch_cpstime */ + ch->ch_cpstime = current_time; /* reset ch_cpstime */ cps_limit = ch->ch_digi.digi_bufsize; } else if (ch->ch_cpstime < buffer_time) { @@ -1994,7 +1994,7 @@ static int dgnc_tty_write_room(struct tty_struct *tty) DPR_WRITE(("dgnc_tty_write_room - %d tail: %d head: %d\n", ret, tail, head)); - return(ret); + return(ret); } @@ -2209,7 +2209,7 @@ static int dgnc_tty_write(struct tty_struct *tty, /* Update printer buffer empty time. */ if ((un->un_type == DGNC_PRINT) && (ch->ch_digi.digi_maxcps > 0) && (ch->ch_digi.digi_bufsize > 0)) { - ch->ch_cpstime += (HZ * count) / ch->ch_digi.digi_maxcps; + ch->ch_cpstime += (HZ * count) / ch->ch_digi.digi_maxcps; } if (from_user) { @@ -2295,7 +2295,7 @@ static int dgnc_tty_tiocmget(struct tty_struct *tty, struct file *file) */ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39) static int dgnc_tty_tiocmset(struct tty_struct *tty, - unsigned int set, unsigned int clear) + unsigned int set, unsigned int clear) #else static int dgnc_tty_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear) @@ -2329,19 +2329,19 @@ static int dgnc_tty_tiocmset(struct tty_struct *tty, struct file *file, if (set & TIOCM_RTS) { ch->ch_mostat |= UART_MCR_RTS; - } + } if (set & TIOCM_DTR) { ch->ch_mostat |= UART_MCR_DTR; - } + } if (clear & TIOCM_RTS) { ch->ch_mostat &= ~(UART_MCR_RTS); - } + } if (clear & TIOCM_DTR) { ch->ch_mostat &= ~(UART_MCR_DTR); - } + } ch->ch_bd->bd_ops->assert_modem_signals(ch); @@ -2593,37 +2593,37 @@ static int dgnc_set_modem_info(struct tty_struct *tty, unsigned int command, uns case TIOCMBIS: if (arg & TIOCM_RTS) { ch->ch_mostat |= UART_MCR_RTS; - } + } if (arg & TIOCM_DTR) { ch->ch_mostat |= UART_MCR_DTR; - } + } break; case TIOCMBIC: if (arg & TIOCM_RTS) { ch->ch_mostat &= ~(UART_MCR_RTS); - } + } if (arg & TIOCM_DTR) { ch->ch_mostat &= ~(UART_MCR_DTR); - } + } break; - case TIOCMSET: + case TIOCMSET: if (arg & TIOCM_RTS) { ch->ch_mostat |= UART_MCR_RTS; - } + } else { ch->ch_mostat &= ~(UART_MCR_RTS); } if (arg & TIOCM_DTR) { ch->ch_mostat |= UART_MCR_DTR; - } + } else { ch->ch_mostat &= ~(UART_MCR_DTR); } @@ -2721,9 +2721,9 @@ static int dgnc_tty_digiseta(struct tty_struct *tty, struct digi_t __user *new_i if (!bd || bd->magic != DGNC_BOARD_MAGIC) return (-EFAULT); - if (copy_from_user(&new_digi, new_info, sizeof(struct digi_t))) { + if (copy_from_user(&new_digi, new_info, sizeof(struct digi_t))) { DPR_IOCTL(("DIGI_SETA failed copy_from_user\n")); - return(-EFAULT); + return(-EFAULT); } DGNC_LOCK(ch->ch_lock, lock_flags); @@ -2831,9 +2831,9 @@ static void dgnc_tty_throttle(struct tty_struct *tty) if (!un || un->magic != DGNC_UNIT_MAGIC) return; - ch = un->un_ch; - if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) - return; + ch = un->un_ch; + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return; DPR_IOCTL(("dgnc_tty_throttle start\n")); @@ -2860,9 +2860,9 @@ static void dgnc_tty_unthrottle(struct tty_struct *tty) if (!un || un->magic != DGNC_UNIT_MAGIC) return; - ch = un->un_ch; - if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) - return; + ch = un->un_ch; + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return; DPR_IOCTL(("dgnc_tty_unthrottle start\n")); @@ -2890,9 +2890,9 @@ static void dgnc_tty_start(struct tty_struct *tty) if (!un || un->magic != DGNC_UNIT_MAGIC) return; - ch = un->un_ch; - if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) - return; + ch = un->un_ch; + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return; bd = ch->ch_bd; if (!bd || bd->magic != DGNC_BOARD_MAGIC) @@ -2924,9 +2924,9 @@ static void dgnc_tty_stop(struct tty_struct *tty) if (!un || un->magic != DGNC_UNIT_MAGIC) return; - ch = un->un_ch; - if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) - return; + ch = un->un_ch; + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return; bd = ch->ch_bd; if (!bd || bd->magic != DGNC_BOARD_MAGIC) @@ -2971,9 +2971,9 @@ static void dgnc_tty_flush_chars(struct tty_struct *tty) if (!un || un->magic != DGNC_UNIT_MAGIC) return; - ch = un->un_ch; - if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) - return; + ch = un->un_ch; + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return; bd = ch->ch_bd; if (!bd || bd->magic != DGNC_BOARD_MAGIC) @@ -3010,9 +3010,9 @@ static void dgnc_tty_flush_buffer(struct tty_struct *tty) if (!un || un->magic != DGNC_UNIT_MAGIC) return; - ch = un->un_ch; - if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) - return; + ch = un->un_ch; + if (!ch || ch->magic != DGNC_CHANNEL_MAGIC) + return; DPR_IOCTL(("dgnc_tty_flush_buffer on port: %d start\n", ch->ch_portnum)); @@ -3130,7 +3130,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, case TCSBRKP: - /* support for POSIX tcsendbreak() + /* support for POSIX tcsendbreak() * According to POSIX.1 spec (7.2.2.1.2) breaks should be * between 0.25 and 0.5 seconds so we'll ask for something * in the middle: 0.375 seconds. @@ -3210,7 +3210,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, case TIOCMGET: DGNC_UNLOCK(ch->ch_lock, lock_flags); - return(dgnc_get_modem_info(ch, uarg)); + return(dgnc_get_modem_info(ch, uarg)); case TIOCMBIS: case TIOCMBIC: @@ -3364,7 +3364,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, ch->ch_bd->bd_ops->param(tty); DGNC_UNLOCK(ch->ch_lock, lock_flags); return(0); - } + } case DIGI_GETCUSTOMBAUD: DGNC_UNLOCK(ch->ch_lock, lock_flags); @@ -3384,7 +3384,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, ch->ch_bd->bd_ops->param(tty); DGNC_UNLOCK(ch->ch_lock, lock_flags); return(0); - } + } /* * This ioctl allows insertion of a character into the front @@ -3437,7 +3437,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, * * This ioctl is to satify the "Event Reporting" * call that the RealPort protocol spec requires. - */ + */ case DIGI_REALPORT_GETEVENTS: { unsigned int events = 0; @@ -3462,7 +3462,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd, * upon the values passed in by the RealPort Server. * It also passes back whether the UART Transmitter is * empty as well. - */ + */ case DIGI_REALPORT_GETBUFFERS: { struct digi_getbuffer buf; -- GitLab From 68a5a5f38c2d80f74c946972375983ff85d508bb Mon Sep 17 00:00:00 2001 From: Tushar Behera Date: Thu, 22 Aug 2013 18:54:23 +0530 Subject: [PATCH 738/942] staging: dgnc: driver.c: Need to include slab.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With 'allyesconfig', we get following error without this. drivers/staging/dgnc/dgnc_driver.c: In function ‘dgnc_cleanup_board’: drivers/staging/dgnc/dgnc_driver.c:459:3: error: implicit declaration of function ‘kfree’ [-Werror=implicit-function-declaration] kfree(brd->msgbuf_head); ^ drivers/staging/dgnc/dgnc_driver.c: In function ‘dgnc_driver_kzmalloc’: drivers/staging/dgnc/dgnc_driver.c:905:2: error: implicit declaration of function ‘kmalloc’ [-Werror=implicit-function-declaration] void *p = kmalloc(size, priority); Signed-off-by: Tushar Behera Cc: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_driver.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c index fa4e91a0950fd..80323686f3909 100644 --- a/drivers/staging/dgnc/dgnc_driver.c +++ b/drivers/staging/dgnc/dgnc_driver.c @@ -34,6 +34,7 @@ #include #include #include +#include #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39) #include -- GitLab From aac6b82e8946052cce24857c5a7528b284c544d0 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Thu, 22 Aug 2013 13:36:57 +0530 Subject: [PATCH 739/942] staging: xillybus: Remove duplicate inclusion of list.h list.h header file was included twice. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xillybus/xillybus.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/xillybus/xillybus.h b/drivers/staging/xillybus/xillybus.h index d3fc8aa896de7..e5e91d6128851 100644 --- a/drivers/staging/xillybus/xillybus.h +++ b/drivers/staging/xillybus/xillybus.h @@ -21,7 +21,6 @@ #include #include #include -#include #include struct xilly_endpoint_hardware; -- GitLab From b88e75bb6576d99e0ba4f6edc978293d1ff9c01b Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Tue, 20 Aug 2013 16:55:41 +0100 Subject: [PATCH 740/942] staging: comedi: pcmmio: remove unneeded checks on detach As pointed out by Dan carpenter for the similar pcmuio driver, there is no need to check the pointer passed to `kfree()`, so remove that check from `pcmmio_detach()`. Also, check the `devpriv` (`dev->private`) pointer once, outside the `for` loop. Signed-off-by: Ian Abbott Cc: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcmmio.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcmmio.c b/drivers/staging/comedi/drivers/pcmmio.c index aa3c0307483d0..574443df42dab 100644 --- a/drivers/staging/comedi/drivers/pcmmio.c +++ b/drivers/staging/comedi/drivers/pcmmio.c @@ -1156,12 +1156,13 @@ static void pcmmio_detach(struct comedi_device *dev) struct pcmmio_private *devpriv = dev->private; int i; - for (i = 0; i < MAX_ASICS; ++i) { - if (devpriv && devpriv->asics[i].irq) - free_irq(devpriv->asics[i].irq, dev); - } - if (devpriv && devpriv->sprivs) + if (devpriv) { + for (i = 0; i < MAX_ASICS; ++i) { + if (devpriv->asics[i].irq) + free_irq(devpriv->asics[i].irq, dev); + } kfree(devpriv->sprivs); + } comedi_legacy_detach(dev); } -- GitLab From 2fd2bdfccae61efe18f6b92b6a45fbf936d75b48 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Tue, 20 Aug 2013 11:50:19 +0100 Subject: [PATCH 741/942] staging: comedi: pcmuio: fix possible NULL deref on detach pcmuio_detach() is called by the comedi core even if pcmuio_attach() returned an error, so `dev->private` might be `NULL`. Check for that before dereferencing it. Also, as pointed out by Dan Carpenter, there is no need to check the pointer passed to `kfree()` is non-NULL, so remove that check. Signed-off-by: Ian Abbott Cc: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcmuio.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcmuio.c b/drivers/staging/comedi/drivers/pcmuio.c index f9424554539d7..67e2bb1d66f00 100644 --- a/drivers/staging/comedi/drivers/pcmuio.c +++ b/drivers/staging/comedi/drivers/pcmuio.c @@ -672,12 +672,13 @@ static void pcmuio_detach(struct comedi_device *dev) struct pcmuio_private *devpriv = dev->private; int i; - for (i = 0; i < PCMUIO_MAX_ASICS; ++i) { - if (devpriv->asics[i].irq) - free_irq(devpriv->asics[i].irq, dev); - } - if (devpriv && devpriv->sprivs) + if (devpriv) { + for (i = 0; i < PCMUIO_MAX_ASICS; ++i) { + if (devpriv->asics[i].irq) + free_irq(devpriv->asics[i].irq, dev); + } kfree(devpriv->sprivs); + } comedi_legacy_detach(dev); } -- GitLab From d5005955162944371c7108b5f67b90d7bced9525 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 21 Aug 2013 21:58:37 +0100 Subject: [PATCH 742/942] staging: vt6656: rxtx.c s_uGetDataDuration return endian corrected u16. The return always be u16 endian corrected. For the large part this is missing. Fix uGetDataDuration to return u16 endian corrected. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 36 +++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 05e82ece1f302..1d0611ee7e0a2 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -132,7 +132,7 @@ static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, void *pvRTS, u32 cbFrameLength, int bNeedAck, int bDisCRC, struct ethhdr *psEthHeader, u16 wCurrentRate, u8 byFBOption); -static u32 s_uGetDataDuration(struct vnt_private *pDevice, u8 byDurType, +static u16 s_uGetDataDuration(struct vnt_private *pDevice, u8 byDurType, u8 byPktType, int bNeedAck); static u16 s_uGetRTSCTSDuration(struct vnt_private *pDevice, @@ -383,7 +383,7 @@ static u32 s_uGetRTSCTSRsvTime(struct vnt_private *pDevice, } //byFreqType 0: 5GHz, 1:2.4Ghz -static u32 s_uGetDataDuration(struct vnt_private *pDevice, u8 byDurType, +static u16 s_uGetDataDuration(struct vnt_private *pDevice, u8 byDurType, u8 byPktType, int bNeedAck) { u32 uAckTime = 0; @@ -395,7 +395,7 @@ static u32 s_uGetDataDuration(struct vnt_private *pDevice, u8 byDurType, else uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopOFDMBasicRate); - return pDevice->uSIFS + uAckTime; + return cpu_to_le16((u16)(pDevice->uSIFS + uAckTime)); } return 0; @@ -507,9 +507,9 @@ static u32 s_uFillDataHead(struct vnt_private *pDevice, BBvCalculateParameter(pDevice, cbFrameLength, pDevice->byTopCCKBasicRate, PK_TYPE_11B, &pBuf->b); //Get Duration and TimeStamp - pBuf->wDuration_a = (u16)s_uGetDataDuration(pDevice, DATADUR_A, + pBuf->wDuration_a = s_uGetDataDuration(pDevice, DATADUR_A, byPktType, bNeedAck); - pBuf->wDuration_b = (u16)s_uGetDataDuration(pDevice, DATADUR_B, + pBuf->wDuration_b = s_uGetDataDuration(pDevice, DATADUR_B, PK_TYPE_11B, bNeedAck); pBuf->wTimeStampOff_a = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]; @@ -525,13 +525,13 @@ static u32 s_uFillDataHead(struct vnt_private *pDevice, BBvCalculateParameter(pDevice, cbFrameLength, pDevice->byTopCCKBasicRate, PK_TYPE_11B, &pBuf->b); //Get Duration and TimeStamp - pBuf->wDuration_a = (u16)s_uGetDataDuration(pDevice, DATADUR_A, + pBuf->wDuration_a = s_uGetDataDuration(pDevice, DATADUR_A, byPktType, bNeedAck); - pBuf->wDuration_b = (u16)s_uGetDataDuration(pDevice, DATADUR_B, + pBuf->wDuration_b = s_uGetDataDuration(pDevice, DATADUR_B, PK_TYPE_11B, bNeedAck); - pBuf->wDuration_a_f0 = (u16)s_uGetDataDuration(pDevice, + pBuf->wDuration_a_f0 = s_uGetDataDuration(pDevice, DATADUR_A_F0, byPktType, bNeedAck); - pBuf->wDuration_a_f1 = (u16)s_uGetDataDuration(pDevice, + pBuf->wDuration_a_f1 = s_uGetDataDuration(pDevice, DATADUR_A_F1, byPktType, bNeedAck); pBuf->wTimeStampOff_a = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]; pBuf->wTimeStampOff_b = wTimeStampOff[pDevice->byPreambleType%2][pDevice->byTopCCKBasicRate%MAX_RATE]; @@ -546,11 +546,11 @@ static u32 s_uFillDataHead(struct vnt_private *pDevice, BBvCalculateParameter(pDevice, cbFrameLength, wCurrentRate, byPktType, &pBuf->a); //Get Duration and TimeStampOff - pBuf->wDuration = (u16)s_uGetDataDuration(pDevice, DATADUR_A, + pBuf->wDuration = s_uGetDataDuration(pDevice, DATADUR_A, byPktType, bNeedAck); - pBuf->wDuration_f0 = (u16)s_uGetDataDuration(pDevice, + pBuf->wDuration_f0 = s_uGetDataDuration(pDevice, DATADUR_A_F0, byPktType, bNeedAck); - pBuf->wDuration_f1 = (u16)s_uGetDataDuration(pDevice, + pBuf->wDuration_f1 = s_uGetDataDuration(pDevice, DATADUR_A_F1, byPktType, bNeedAck); pBuf->wTimeStampOff = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]; return (pBuf->wDuration); @@ -561,7 +561,7 @@ static u32 s_uFillDataHead(struct vnt_private *pDevice, BBvCalculateParameter(pDevice, cbFrameLength, wCurrentRate, byPktType, &pBuf->ab); //Get Duration and TimeStampOff - pBuf->wDuration = (u16)s_uGetDataDuration(pDevice, DATADUR_A, + pBuf->wDuration = s_uGetDataDuration(pDevice, DATADUR_A, byPktType, bNeedAck); pBuf->wTimeStampOff = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]; @@ -575,7 +575,7 @@ static u32 s_uFillDataHead(struct vnt_private *pDevice, BBvCalculateParameter(pDevice, cbFrameLength, wCurrentRate, byPktType, &pBuf->ab); //Get Duration and TimeStampOff - pBuf->wDuration = (u16)s_uGetDataDuration(pDevice, DATADUR_B, + pBuf->wDuration = s_uGetDataDuration(pDevice, DATADUR_B, byPktType, bNeedAck); pBuf->wTimeStampOff = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]; @@ -1805,8 +1805,8 @@ CMD_STATUS csBeacon_xmit(struct vnt_private *pDevice, BBvCalculateParameter(pDevice, cbFrameSize, wCurrentRate, PK_TYPE_11A, &pTxDataHead->ab); //Get Duration and TimeStampOff - pTxDataHead->wDuration = cpu_to_le16((u16)s_uGetDataDuration(pDevice, - DATADUR_A, PK_TYPE_11A, false)); + pTxDataHead->wDuration = s_uGetDataDuration(pDevice, + DATADUR_A, PK_TYPE_11A, false); pTxDataHead->wTimeStampOff = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]; cbHeaderSize = wTxBufSize + sizeof(struct vnt_tx_datahead_ab); } else { @@ -1818,8 +1818,8 @@ CMD_STATUS csBeacon_xmit(struct vnt_private *pDevice, BBvCalculateParameter(pDevice, cbFrameSize, wCurrentRate, PK_TYPE_11B, &pTxDataHead->ab); //Get Duration and TimeStampOff - pTxDataHead->wDuration = cpu_to_le16((u16)s_uGetDataDuration(pDevice, - DATADUR_B, PK_TYPE_11B, false)); + pTxDataHead->wDuration = s_uGetDataDuration(pDevice, + DATADUR_B, PK_TYPE_11B, false); pTxDataHead->wTimeStampOff = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]; cbHeaderSize = wTxBufSize + sizeof(struct vnt_tx_datahead_ab); } -- GitLab From 6b5ad9d269b5fbc981e32ccfafbb406bd3714984 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 21 Aug 2013 22:16:04 +0100 Subject: [PATCH 743/942] staging: vt6656: rxtx.c: s_uGetDataDuration Drop argument byDurType. When byDurType == DATADUR_B then byPktType == PK_TYPE_11B Drop argument byDurType and filter on byPktType == PK_TYPE_11B. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 1d0611ee7e0a2..d4b9b60f02ccd 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -132,7 +132,7 @@ static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, void *pvRTS, u32 cbFrameLength, int bNeedAck, int bDisCRC, struct ethhdr *psEthHeader, u16 wCurrentRate, u8 byFBOption); -static u16 s_uGetDataDuration(struct vnt_private *pDevice, u8 byDurType, +static u16 s_uGetDataDuration(struct vnt_private *pDevice, u8 byPktType, int bNeedAck); static u16 s_uGetRTSCTSDuration(struct vnt_private *pDevice, @@ -383,13 +383,13 @@ static u32 s_uGetRTSCTSRsvTime(struct vnt_private *pDevice, } //byFreqType 0: 5GHz, 1:2.4Ghz -static u16 s_uGetDataDuration(struct vnt_private *pDevice, u8 byDurType, - u8 byPktType, int bNeedAck) +static u16 s_uGetDataDuration(struct vnt_private *pDevice, + u8 byPktType, int bNeedAck) { u32 uAckTime = 0; if (bNeedAck) { - if (byDurType == DATADUR_B) + if (byPktType == PK_TYPE_11B) uAckTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, 14, pDevice->byTopCCKBasicRate); else @@ -507,9 +507,9 @@ static u32 s_uFillDataHead(struct vnt_private *pDevice, BBvCalculateParameter(pDevice, cbFrameLength, pDevice->byTopCCKBasicRate, PK_TYPE_11B, &pBuf->b); //Get Duration and TimeStamp - pBuf->wDuration_a = s_uGetDataDuration(pDevice, DATADUR_A, + pBuf->wDuration_a = s_uGetDataDuration(pDevice, byPktType, bNeedAck); - pBuf->wDuration_b = s_uGetDataDuration(pDevice, DATADUR_B, + pBuf->wDuration_b = s_uGetDataDuration(pDevice, PK_TYPE_11B, bNeedAck); pBuf->wTimeStampOff_a = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]; @@ -525,14 +525,14 @@ static u32 s_uFillDataHead(struct vnt_private *pDevice, BBvCalculateParameter(pDevice, cbFrameLength, pDevice->byTopCCKBasicRate, PK_TYPE_11B, &pBuf->b); //Get Duration and TimeStamp - pBuf->wDuration_a = s_uGetDataDuration(pDevice, DATADUR_A, + pBuf->wDuration_a = s_uGetDataDuration(pDevice, byPktType, bNeedAck); - pBuf->wDuration_b = s_uGetDataDuration(pDevice, DATADUR_B, + pBuf->wDuration_b = s_uGetDataDuration(pDevice, PK_TYPE_11B, bNeedAck); pBuf->wDuration_a_f0 = s_uGetDataDuration(pDevice, - DATADUR_A_F0, byPktType, bNeedAck); + byPktType, bNeedAck); pBuf->wDuration_a_f1 = s_uGetDataDuration(pDevice, - DATADUR_A_F1, byPktType, bNeedAck); + byPktType, bNeedAck); pBuf->wTimeStampOff_a = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]; pBuf->wTimeStampOff_b = wTimeStampOff[pDevice->byPreambleType%2][pDevice->byTopCCKBasicRate%MAX_RATE]; return (pBuf->wDuration_a); @@ -546,12 +546,12 @@ static u32 s_uFillDataHead(struct vnt_private *pDevice, BBvCalculateParameter(pDevice, cbFrameLength, wCurrentRate, byPktType, &pBuf->a); //Get Duration and TimeStampOff - pBuf->wDuration = s_uGetDataDuration(pDevice, DATADUR_A, + pBuf->wDuration = s_uGetDataDuration(pDevice, byPktType, bNeedAck); pBuf->wDuration_f0 = s_uGetDataDuration(pDevice, - DATADUR_A_F0, byPktType, bNeedAck); + byPktType, bNeedAck); pBuf->wDuration_f1 = s_uGetDataDuration(pDevice, - DATADUR_A_F1, byPktType, bNeedAck); + byPktType, bNeedAck); pBuf->wTimeStampOff = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]; return (pBuf->wDuration); } else { @@ -561,7 +561,7 @@ static u32 s_uFillDataHead(struct vnt_private *pDevice, BBvCalculateParameter(pDevice, cbFrameLength, wCurrentRate, byPktType, &pBuf->ab); //Get Duration and TimeStampOff - pBuf->wDuration = s_uGetDataDuration(pDevice, DATADUR_A, + pBuf->wDuration = s_uGetDataDuration(pDevice, byPktType, bNeedAck); pBuf->wTimeStampOff = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]; @@ -575,7 +575,7 @@ static u32 s_uFillDataHead(struct vnt_private *pDevice, BBvCalculateParameter(pDevice, cbFrameLength, wCurrentRate, byPktType, &pBuf->ab); //Get Duration and TimeStampOff - pBuf->wDuration = s_uGetDataDuration(pDevice, DATADUR_B, + pBuf->wDuration = s_uGetDataDuration(pDevice, byPktType, bNeedAck); pBuf->wTimeStampOff = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]; @@ -1806,7 +1806,7 @@ CMD_STATUS csBeacon_xmit(struct vnt_private *pDevice, &pTxDataHead->ab); //Get Duration and TimeStampOff pTxDataHead->wDuration = s_uGetDataDuration(pDevice, - DATADUR_A, PK_TYPE_11A, false); + PK_TYPE_11A, false); pTxDataHead->wTimeStampOff = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]; cbHeaderSize = wTxBufSize + sizeof(struct vnt_tx_datahead_ab); } else { @@ -1819,7 +1819,7 @@ CMD_STATUS csBeacon_xmit(struct vnt_private *pDevice, &pTxDataHead->ab); //Get Duration and TimeStampOff pTxDataHead->wDuration = s_uGetDataDuration(pDevice, - DATADUR_B, PK_TYPE_11B, false); + PK_TYPE_11B, false); pTxDataHead->wTimeStampOff = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]; cbHeaderSize = wTxBufSize + sizeof(struct vnt_tx_datahead_ab); } -- GitLab From c84b8b503eaccf5c9e7b9f78553cbed8e97a9230 Mon Sep 17 00:00:00 2001 From: "Scott_Kilau@digi.com" Date: Wed, 21 Aug 2013 21:48:31 -0400 Subject: [PATCH 744/942] staging: dgap: adds dgap driver to staging This patch adds the dgap driver to staging. This is a TTY serial port driver for the EPCA PCI based product line by Digi International . Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/Kconfig | 6 + drivers/staging/dgap/Makefile | 9 + drivers/staging/dgap/dgap_conf.h | 290 +++ drivers/staging/dgap/dgap_downld.h | 69 + drivers/staging/dgap/dgap_driver.c | 1063 ++++++++ drivers/staging/dgap/dgap_driver.h | 626 +++++ drivers/staging/dgap/dgap_fep5.c | 1957 ++++++++++++++ drivers/staging/dgap/dgap_fep5.h | 253 ++ drivers/staging/dgap/dgap_kcompat.h | 93 + drivers/staging/dgap/dgap_mgmt.c | 768 ++++++ drivers/staging/dgap/dgap_mgmt.h | 38 + drivers/staging/dgap/dgap_parse.c | 1372 ++++++++++ drivers/staging/dgap/dgap_parse.h | 35 + drivers/staging/dgap/dgap_pci.h | 92 + drivers/staging/dgap/dgap_proc.c | 1924 ++++++++++++++ drivers/staging/dgap/dgap_proc.h | 151 ++ drivers/staging/dgap/dgap_sysfs.c | 796 ++++++ drivers/staging/dgap/dgap_sysfs.h | 48 + drivers/staging/dgap/dgap_trace.c | 186 ++ drivers/staging/dgap/dgap_trace.h | 36 + drivers/staging/dgap/dgap_tty.c | 3651 +++++++++++++++++++++++++++ drivers/staging/dgap/dgap_tty.h | 39 + drivers/staging/dgap/dgap_types.h | 36 + drivers/staging/dgap/digi.h | 376 +++ drivers/staging/dgap/downld.c | 798 ++++++ 25 files changed, 14712 insertions(+) create mode 100644 drivers/staging/dgap/Kconfig create mode 100644 drivers/staging/dgap/Makefile create mode 100644 drivers/staging/dgap/dgap_conf.h create mode 100644 drivers/staging/dgap/dgap_downld.h create mode 100644 drivers/staging/dgap/dgap_driver.c create mode 100644 drivers/staging/dgap/dgap_driver.h create mode 100644 drivers/staging/dgap/dgap_fep5.c create mode 100644 drivers/staging/dgap/dgap_fep5.h create mode 100644 drivers/staging/dgap/dgap_kcompat.h create mode 100644 drivers/staging/dgap/dgap_mgmt.c create mode 100644 drivers/staging/dgap/dgap_mgmt.h create mode 100644 drivers/staging/dgap/dgap_parse.c create mode 100644 drivers/staging/dgap/dgap_parse.h create mode 100644 drivers/staging/dgap/dgap_pci.h create mode 100644 drivers/staging/dgap/dgap_proc.c create mode 100644 drivers/staging/dgap/dgap_proc.h create mode 100644 drivers/staging/dgap/dgap_sysfs.c create mode 100644 drivers/staging/dgap/dgap_sysfs.h create mode 100644 drivers/staging/dgap/dgap_trace.c create mode 100644 drivers/staging/dgap/dgap_trace.h create mode 100644 drivers/staging/dgap/dgap_tty.c create mode 100644 drivers/staging/dgap/dgap_tty.h create mode 100644 drivers/staging/dgap/dgap_types.h create mode 100644 drivers/staging/dgap/digi.h create mode 100644 drivers/staging/dgap/downld.c diff --git a/drivers/staging/dgap/Kconfig b/drivers/staging/dgap/Kconfig new file mode 100644 index 0000000000000..31f1d7533eecb --- /dev/null +++ b/drivers/staging/dgap/Kconfig @@ -0,0 +1,6 @@ +config DGAP + tristate "Digi EPCA PCI products" + default n + depends on TTY + ---help--- + Driver for the Digi International EPCA PCI based product line diff --git a/drivers/staging/dgap/Makefile b/drivers/staging/dgap/Makefile new file mode 100644 index 0000000000000..0aa5cde2c8234 --- /dev/null +++ b/drivers/staging/dgap/Makefile @@ -0,0 +1,9 @@ +EXTRA_CFLAGS += -DDG_NAME=\"dgap-1.3-16\" -DDG_PART=\"40002347_C\" + +obj-$(CONFIG_DGAP) += dgap.o + + +dgap-objs := dgap_driver.o dgap_fep5.o dgap_mgmt.o \ + dgap_parse.o dgap_proc.o dgap_trace.o \ + dgap_tty.o dgap_sysfs.o + diff --git a/drivers/staging/dgap/dgap_conf.h b/drivers/staging/dgap/dgap_conf.h new file mode 100644 index 0000000000000..88097013ed048 --- /dev/null +++ b/drivers/staging/dgap/dgap_conf.h @@ -0,0 +1,290 @@ +/* + * Copyright 2003 Digi International (www.digi.com) + * Scott H Kilau + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + ***************************************************************************** + * + * dgap_conf.h - Header file for installations and parse files. + * + * $Id: dgap_conf.h,v 1.1 2009/10/23 14:01:57 markh Exp $ + * + * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! + */ + +#ifndef _DGAP_CONF_H +#define _DGAP_CONF_H + +#define NULLNODE 0 /* header node, not used */ +#define BNODE 1 /* Board node */ +#define LNODE 2 /* Line node */ +#define CNODE 3 /* Concentrator node */ +#define MNODE 4 /* EBI Module node */ +#define TNODE 5 /* tty name prefix node */ +#define CUNODE 6 /* cu name prefix (non-SCO) */ +#define PNODE 7 /* trans. print prefix node */ +#define JNODE 8 /* maJor number node */ +#define ANODE 9 /* altpin */ +#define TSNODE 10 /* tty structure size */ +#define CSNODE 11 /* channel structure size */ +#define BSNODE 12 /* board structure size */ +#define USNODE 13 /* unit schedule structure size */ +#define FSNODE 14 /* f2200 structure size */ +#define VSNODE 15 /* size of VPIX structures */ +#define INTRNODE 16 /* enable interrupt */ + +/* Enumeration of tokens */ +#define BEGIN 1 +#define END 2 +#define BOARD 10 + +#define EPCFS 11 /* start of EPC family definitions */ +#define ICX 11 +#define MCX 13 +#define PCX 14 +#define IEPC 15 +#define EEPC 16 +#define MEPC 17 +#define IPCM 18 +#define EPCM 19 +#define MPCM 20 +#define PEPC 21 +#define PPCM 22 +#ifdef CP +#define ICP 23 +#define ECP 24 +#define MCP 25 +#endif +#define EPCFE 25 /* end of EPC family definitions */ +#define PC2E 26 +#define PC4E 27 +#define PC4E8K 28 +#define PC8E 29 +#define PC8E8K 30 +#define PC16E 31 +#define MC2E8K 34 +#define MC4E8K 35 +#define MC8E8K 36 + +#define AVANFS 42 /* start of Avanstar family definitions */ +#define A8P 42 +#define A16P 43 +#define AVANFE 43 /* end of Avanstar family definitions */ + +#define DA2000FS 44 /* start of AccelePort 2000 family definitions */ +#define DA22 44 /* AccelePort 2002 */ +#define DA24 45 /* AccelePort 2004 */ +#define DA28 46 /* AccelePort 2008 */ +#define DA216 47 /* AccelePort 2016 */ +#define DAR4 48 /* AccelePort RAS 4 port */ +#define DAR8 49 /* AccelePort RAS 8 port */ +#define DDR24 50 /* DataFire RAS 24 port */ +#define DDR30 51 /* DataFire RAS 30 port */ +#define DDR48 52 /* DataFire RAS 48 port */ +#define DDR60 53 /* DataFire RAS 60 port */ +#define DA2000FE 53 /* end of AccelePort 2000/RAS family definitions */ + +#define PCXRFS 106 /* start of PCXR family definitions */ +#define APORT4 106 +#define APORT8 107 +#define PAPORT4 108 +#define PAPORT8 109 +#define APORT4_920I 110 +#define APORT8_920I 111 +#define APORT4_920P 112 +#define APORT8_920P 113 +#define APORT2_920P 114 +#define PCXRFE 117 /* end of PCXR family definitions */ + +#define LINE 82 +#ifdef T1 +#define T1M 83 +#define E1M 84 +#endif +#define CONC 64 +#define CX 65 +#define EPC 66 +#define MOD 67 +#define PORTS 68 +#define METHOD 69 +#define CUSTOM 70 +#define BASIC 71 +#define STATUS 72 +#define MODEM 73 +/* The following tokens can appear in multiple places */ +#define SPEED 74 +#define NPORTS 75 +#define ID 76 +#define CABLE 77 +#define CONNECT 78 +#define IO 79 +#define MEM 80 +#define DPSZ 81 + +#define TTYN 90 +#define CU 91 +#define PRINT 92 +#define XPRINT 93 +#define CMAJOR 94 +#define ALTPIN 95 +#define STARTO 96 +#define USEINTR 97 +#define PCIINFO 98 + +#define TTSIZ 100 +#define CHSIZ 101 +#define BSSIZ 102 +#define UNTSIZ 103 +#define F2SIZ 104 +#define VPSIZ 105 + +#define TOTAL_BOARD 2 +#define CURRENT_BRD 4 +#define BOARD_TYPE 6 +#define IO_ADDRESS 8 +#define MEM_ADDRESS 10 + +#define FIELDS_PER_PAGE 18 + +#define TB_FIELD 1 +#define CB_FIELD 3 +#define BT_FIELD 5 +#define IO_FIELD 7 +#define ID_FIELD 8 +#define ME_FIELD 9 +#define TTY_FIELD 11 +#define CU_FIELD 13 +#define PR_FIELD 15 +#define MPR_FIELD 17 + +#define MAX_FIELD 512 + +#define INIT 0 +#define NITEMS 128 +#define MAX_ITEM 512 + +#define DSCRINST 1 +#define DSCRNUM 3 +#define ALTPINQ 5 +#define SSAVE 7 + +#define DSCR "32" +#define ONETONINE "123456789" +#define ALL "1234567890" + + +struct cnode { + struct cnode *next; + int type; + int numbrd; + + union { + struct { + char type; /* Board Type */ + short port; /* I/O Address */ + char *portstr; /* I/O Address in string */ + long addr; /* Memory Address */ + char *addrstr; /* Memory Address in string */ + long pcibus; /* PCI BUS */ + char *pcibusstr; /* PCI BUS in string */ + long pcislot; /* PCI SLOT */ + char *pcislotstr; /* PCI SLOT in string */ + char nport; /* Number of Ports */ + char *id; /* tty id */ + int start; /* start of tty counting */ + char *method; /* Install method */ + char v_type; + char v_port; + char v_addr; + char v_pcibus; + char v_pcislot; + char v_nport; + char v_id; + char v_start; + char v_method; + char line1; + char line2; + char conc1; /* total concs in line1 */ + char conc2; /* total concs in line2 */ + char module1; /* total modules for line1 */ + char module2; /* total modules for line2 */ + char *status; /* config status */ + char *dimstatus; /* Y/N */ + int status_index; /* field pointer */ + } board; + + struct { + char *cable; + char v_cable; + char speed; + char v_speed; + } line; + + struct { + char type; + char *connect; + char speed; + char nport; + char *id; + char *idstr; + int start; + char v_type; + char v_connect; + char v_speed; + char v_nport; + char v_id; + char v_start; + } conc; + + struct { + char type; + char nport; + char *id; + char *idstr; + int start; + char v_type; + char v_nport; + char v_id; + char v_start; + } module; + + char *ttyname; + + char *cuname; + + char *printname; + + int majornumber; + + int altpin; + + int ttysize; + + int chsize; + + int bssize; + + int unsize; + + int f2size; + + int vpixsize; + + int useintr; + } u; +}; + +#endif diff --git a/drivers/staging/dgap/dgap_downld.h b/drivers/staging/dgap/dgap_downld.h new file mode 100644 index 0000000000000..f79e65cd1d515 --- /dev/null +++ b/drivers/staging/dgap/dgap_downld.h @@ -0,0 +1,69 @@ +/* + * Copyright 2003 Digi International (www.digi.com) + * Scott H Kilau + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id: dgap_downld.h,v 1.1 2009/10/23 14:01:57 markh Exp $ + * + * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! + * + */ + +/* +** downld.h +** - describes the interface between the user level download process +** and the concentrator download driver. +*/ + +#ifndef _DGAP_DOWNLD_H_ +#define _DGAP_DOWNLD_H_ + + +struct fepimg { + int type; /* board type */ + int len; /* length of image */ + char fepimage[1]; /* begining of image */ +}; + +struct downldio { + unsigned int req_type; /* FEP or concentrator */ + unsigned int bdid; /* opaque board identifier */ + union { + struct downld_t dl; /* download structure */ + struct fepimg fi; /* fep/bios image structure */ + } image; +}; + +#define DIGI_DLREQ_GET (('d'<<8) | 220) +#define DIGI_DLREQ_SET (('d'<<8) | 221) + +#define DIGI_DL_NUKE (('d'<<8) | 222) /* Not really a dl request, but + dangerous enuff to not put in + digi.h */ +/* Packed bits of intarg for DIGI_DL_NUKE */ +#define DIGI_NUKE_RESET_ALL (1 << 31) +#define DIGI_NUKE_INHIBIT_POLLER (1 << 30) +#define DIGI_NUKE_BRD_NUMB 0x0f + + + +#define DLREQ_BIOS 0 +#define DLREQ_FEP 1 +#define DLREQ_CONC 2 +#define DLREQ_CONFIG 3 +#define DLREQ_DEVCREATE 4 + +#endif diff --git a/drivers/staging/dgap/dgap_driver.c b/drivers/staging/dgap/dgap_driver.c new file mode 100644 index 0000000000000..b4f54ef8493de --- /dev/null +++ b/drivers/staging/dgap/dgap_driver.c @@ -0,0 +1,1063 @@ +/* + * Copyright 2003 Digi International (www.digi.com) + * Scott H Kilau + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * + * NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE! + * + * This is shared code between Digi's CVS archive and the + * Linux Kernel sources. + * Changing the source just for reformatting needlessly breaks + * our CVS diff history. + * + * Send any bug fixes/changes to: Eng.Linux at digi dot com. + * Thank you. + * + * $Id: dgap_driver.c,v 1.3 2011/06/21 10:35:16 markh Exp $ + */ + + +#include +#include +#include +#include +#include /* For udelay */ +#include /* For copy_from_user/copy_to_user */ + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39) +#include +#endif + +#include "dgap_driver.h" +#include "dgap_pci.h" +#include "dgap_proc.h" +#include "dgap_fep5.h" +#include "dgap_tty.h" +#include "dgap_conf.h" +#include "dgap_parse.h" +#include "dgap_mgmt.h" +#include "dgap_trace.h" +#include "dgap_sysfs.h" + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Digi International, http://www.digi.com"); +MODULE_DESCRIPTION("Driver for the Digi International EPCA PCI based product line"); +MODULE_SUPPORTED_DEVICE("dgap"); + +/* + * insmod command line overrideable parameters + * + * NOTE: we use a set of macros to create the variables, which allows + * us to specify the variable type, name, initial value, and description. + */ +PARM_INT(debug, 0x00, 0644, "Driver debugging level"); +PARM_INT(rawreadok, 1, 0644, "Bypass flip buffers on input"); +PARM_INT(trcbuf_size, 0x100000, 0644, "Debugging trace buffer size."); + + +/************************************************************************** + * + * protos for this file + * + */ + +static int dgap_start(void); +static void dgap_init_globals(void); +static int dgap_found_board(struct pci_dev *pdev, int id); +static void dgap_cleanup_board(struct board_t *brd); +static void dgap_poll_handler(ulong dummy); +static int dgap_init_pci(void); +static int dgap_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); +static void dgap_remove_one(struct pci_dev *dev); +static int dgap_probe1(struct pci_dev *pdev, int card_type); +static void dgap_mbuf(struct board_t *brd, const char *fmt, ...); +static int dgap_do_remap(struct board_t *brd); +static irqreturn_t dgap_intr(int irq, void *voidbrd); + +/* Driver load/unload functions */ +int dgap_init_module(void); +void dgap_cleanup_module(void); + +module_init(dgap_init_module); +module_exit(dgap_cleanup_module); + + +/* + * File operations permitted on Control/Management major. + */ +static struct file_operations DgapBoardFops = +{ + .owner = THIS_MODULE, +#ifdef HAVE_UNLOCKED_IOCTL + .unlocked_ioctl = dgap_mgmt_ioctl, +#else + .ioctl: = dgap_mgmt_ioctl, +#endif + .open = dgap_mgmt_open, + .release = dgap_mgmt_close +}; + + +/* + * Globals + */ +uint dgap_NumBoards; +struct board_t *dgap_Board[MAXBOARDS]; +DEFINE_SPINLOCK(dgap_global_lock); +ulong dgap_poll_counter; +char *dgap_config_buf; +int dgap_driver_state = DRIVER_INITIALIZED; +DEFINE_SPINLOCK(dgap_dl_lock); +wait_queue_head_t dgap_dl_wait; +int dgap_dl_action; +int dgap_poll_tick = 20; /* Poll interval - 20 ms */ + +/* + * Static vars. + */ +static int dgap_Major_Control_Registered = FALSE; +static uint dgap_driver_start = FALSE; + +static struct class * dgap_class; + +/* + * Poller stuff + */ +static DEFINE_SPINLOCK(dgap_poll_lock); /* Poll scheduling lock */ +static ulong dgap_poll_time; /* Time of next poll */ +static uint dgap_poll_stop; /* Used to tell poller to stop */ +static struct timer_list dgap_poll_timer; + + +static struct pci_device_id dgap_pci_tbl[] = { + { DIGI_VID, PCI_DEVICE_XEM_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, + { DIGI_VID, PCI_DEVICE_CX_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1 }, + { DIGI_VID, PCI_DEVICE_CX_IBM_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2 }, + { DIGI_VID, PCI_DEVICE_EPCJ_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 3 }, + { DIGI_VID, PCI_DEVICE_920_2_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4 }, + { DIGI_VID, PCI_DEVICE_920_4_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 5 }, + { DIGI_VID, PCI_DEVICE_920_8_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 6 }, + { DIGI_VID, PCI_DEVICE_XR_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 7 }, + { DIGI_VID, PCI_DEVICE_XRJ_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 8 }, + { DIGI_VID, PCI_DEVICE_XR_422_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 9 }, + { DIGI_VID, PCI_DEVICE_XR_IBM_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 10 }, + { DIGI_VID, PCI_DEVICE_XR_SAIP_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 11 }, + { DIGI_VID, PCI_DEVICE_XR_BULL_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 12 }, + { DIGI_VID, PCI_DEVICE_920_8_HP_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 13 }, + { DIGI_VID, PCI_DEVICE_XEM_HP_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 14 }, + {0,} /* 0 terminated list. */ +}; +MODULE_DEVICE_TABLE(pci, dgap_pci_tbl); + + +/* + * A generic list of Product names, PCI Vendor ID, and PCI Device ID. + */ +struct board_id { + uint config_type; + uchar *name; + uint maxports; + uint dpatype; +}; + +static struct board_id dgap_Ids[] = +{ + { PPCM, PCI_DEVICE_XEM_NAME, 64, (T_PCXM | T_PCLITE | T_PCIBUS) }, + { PCX, PCI_DEVICE_CX_NAME, 128, (T_CX | T_PCIBUS) }, + { PCX, PCI_DEVICE_CX_IBM_NAME, 128, (T_CX | T_PCIBUS) }, + { PEPC, PCI_DEVICE_EPCJ_NAME, 224, (T_EPC | T_PCIBUS) }, + { APORT2_920P, PCI_DEVICE_920_2_NAME, 2, (T_PCXR | T_PCLITE | T_PCIBUS) }, + { APORT4_920P, PCI_DEVICE_920_4_NAME, 4, (T_PCXR | T_PCLITE | T_PCIBUS) }, + { APORT8_920P, PCI_DEVICE_920_8_NAME, 8, (T_PCXR | T_PCLITE | T_PCIBUS) }, + { PAPORT8, PCI_DEVICE_XR_NAME, 8, (T_PCXR | T_PCLITE | T_PCIBUS) }, + { PAPORT8, PCI_DEVICE_XRJ_NAME, 8, (T_PCXR | T_PCLITE | T_PCIBUS) }, + { PAPORT8, PCI_DEVICE_XR_422_NAME, 8, (T_PCXR | T_PCLITE | T_PCIBUS) }, + { PAPORT8, PCI_DEVICE_XR_IBM_NAME, 8, (T_PCXR | T_PCLITE | T_PCIBUS) }, + { PAPORT8, PCI_DEVICE_XR_SAIP_NAME, 8, (T_PCXR | T_PCLITE | T_PCIBUS) }, + { PAPORT8, PCI_DEVICE_XR_BULL_NAME, 8, (T_PCXR | T_PCLITE | T_PCIBUS) }, + { APORT8_920P, PCI_DEVICE_920_8_HP_NAME, 8, (T_PCXR | T_PCLITE | T_PCIBUS) }, + { PPCM, PCI_DEVICE_XEM_HP_NAME, 64, (T_PCXM | T_PCLITE | T_PCIBUS) }, + {0,} /* 0 terminated list. */ +}; + +static struct pci_driver dgap_driver = { + .name = "dgap", + .probe = dgap_init_one, + .id_table = dgap_pci_tbl, + .remove = dgap_remove_one, +}; + + +char *dgap_state_text[] = { + "Board Failed", + "Configuration for board not found.\n\t\t\tRun mpi to configure board.", + "Board Found", + "Need Reset", + "Finished Reset", + "Need Config", + "Finished Config", + "Need Device Creation", + "Requested Device Creation", + "Finished Device Creation", + "Need BIOS Load", + "Requested BIOS", + "Doing BIOS Load", + "Finished BIOS Load", + "Need FEP Load", + "Requested FEP", + "Doing FEP Load", + "Finished FEP Load", + "Requested PROC creation", + "Finished PROC creation", + "Board READY", +}; + +char *dgap_driver_state_text[] = { + "Driver Initialized", + "Driver needs configuration load.", + "Driver requested configuration from download daemon.", + "Driver Ready." +}; + + + +/************************************************************************ + * + * Driver load/unload functions + * + ************************************************************************/ + +/* + * init_module() + * + * Module load. This is where it all starts. + */ +int dgap_init_module(void) +{ + int rc = 0; + + APR(("%s, Digi International Part Number %s\n", DG_NAME, DG_PART)); + + /* + * Initialize global stuff + */ + rc = dgap_start(); + + if (rc < 0) { + return(rc); + } + + /* + * Find and configure all the cards + */ + rc = dgap_init_pci(); + + /* + * If something went wrong in the scan, bail out of driver. + */ + if (rc < 0) { + /* Only unregister the pci driver if it was actually registered. */ + if (dgap_NumBoards) + pci_unregister_driver(&dgap_driver); + else + printk("WARNING: dgap driver load failed. No DGAP boards found.\n"); + + dgap_cleanup_module(); + } + else { + dgap_create_driver_sysfiles(&dgap_driver); + } + + DPR_INIT(("Finished init_module. Returning %d\n", rc)); + return (rc); +} + + +/* + * Start of driver. + */ +static int dgap_start(void) +{ + int rc = 0; + unsigned long flags; + + if (dgap_driver_start == FALSE) { + + dgap_driver_start = TRUE; + + /* make sure that the globals are init'd before we do anything else */ + dgap_init_globals(); + + dgap_NumBoards = 0; + + APR(("For the tools package or updated drivers please visit http://www.digi.com\n")); + + /* + * Register our base character device into the kernel. + * This allows the download daemon to connect to the downld device + * before any of the boards are init'ed. + */ + if (!dgap_Major_Control_Registered) { + /* + * Register management/dpa devices + */ + rc = register_chrdev(DIGI_DGAP_MAJOR, "dgap", &DgapBoardFops); + if (rc < 0) { + APR(("Can't register dgap driver device (%d)\n", rc)); + return (rc); + } + + dgap_class = class_create(THIS_MODULE, "dgap_mgmt"); + device_create(dgap_class, NULL, + MKDEV(DIGI_DGAP_MAJOR, 0), + NULL, "dgap_mgmt"); + device_create(dgap_class, NULL, + MKDEV(DIGI_DGAP_MAJOR, 1), + NULL, "dgap_downld"); + dgap_Major_Control_Registered = TRUE; + } + + /* + * Register our basic stuff in /proc/dgap + */ + dgap_proc_register_basic_prescan(); + + /* + * Init any global tty stuff. + */ + rc = dgap_tty_preinit(); + + if (rc < 0) { + APR(("tty preinit - not enough memory (%d)\n", rc)); + return(rc); + } + + /* Start the poller */ + DGAP_LOCK(dgap_poll_lock, flags); + init_timer(&dgap_poll_timer); + dgap_poll_timer.function = dgap_poll_handler; + dgap_poll_timer.data = 0; + dgap_poll_time = jiffies + dgap_jiffies_from_ms(dgap_poll_tick); + dgap_poll_timer.expires = dgap_poll_time; + DGAP_UNLOCK(dgap_poll_lock, flags); + + add_timer(&dgap_poll_timer); + + dgap_driver_state = DRIVER_NEED_CONFIG_LOAD; + } + + return (rc); +} + + +/* + * Register pci driver, and return how many boards we have. + */ +static int dgap_init_pci(void) +{ + return pci_register_driver(&dgap_driver); +} + + +/* returns count (>= 0), or negative on error */ +static int dgap_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) +{ + int rc; + + /* wake up and enable device */ + rc = pci_enable_device(pdev); + + if (rc < 0) { + rc = -EIO; + } else { + rc = dgap_probe1(pdev, ent->driver_data); + if (rc == 0) { + dgap_NumBoards++; + DPR_INIT(("Incrementing numboards to %d\n", dgap_NumBoards)); + } + } + return rc; +} + + +static int dgap_probe1(struct pci_dev *pdev, int card_type) +{ + return dgap_found_board(pdev, card_type); +} + + +static void dgap_remove_one(struct pci_dev *dev) +{ + /* Do Nothing */ +} + + +/* + * dgap_cleanup_module() + * + * Module unload. This is where it all ends. + */ +void dgap_cleanup_module(void) +{ + int i; + ulong lock_flags; + + DGAP_LOCK(dgap_poll_lock, lock_flags); + dgap_poll_stop = 1; + DGAP_UNLOCK(dgap_poll_lock, lock_flags); + + /* Turn off poller right away. */ + del_timer_sync( &dgap_poll_timer); + + dgap_proc_unregister_all(); + + dgap_remove_driver_sysfiles(&dgap_driver); + + + if (dgap_Major_Control_Registered) { + device_destroy(dgap_class, MKDEV(DIGI_DGAP_MAJOR, 0)); + device_destroy(dgap_class, MKDEV(DIGI_DGAP_MAJOR, 1)); + class_destroy(dgap_class); + unregister_chrdev(DIGI_DGAP_MAJOR, "dgap"); + } + + if (dgap_config_buf) + kfree(dgap_config_buf); + + for (i = 0; i < dgap_NumBoards; ++i) { + dgap_remove_ports_sysfiles(dgap_Board[i]); + dgap_tty_uninit(dgap_Board[i]); + dgap_cleanup_board(dgap_Board[i]); + } + + dgap_tty_post_uninit(); + +#if defined(DGAP_TRACER) + /* last thing, make sure we release the tracebuffer */ + dgap_tracer_free(); +#endif + if (dgap_NumBoards) + pci_unregister_driver(&dgap_driver); +} + + +/* + * dgap_cleanup_board() + * + * Free all the memory associated with a board + */ +static void dgap_cleanup_board(struct board_t *brd) +{ + int i = 0; + + if(!brd || brd->magic != DGAP_BOARD_MAGIC) + return; + + if (brd->intr_used && brd->irq) + free_irq(brd->irq, brd); + + tasklet_kill(&brd->helper_tasklet); + + if (brd->re_map_port) { + release_mem_region(brd->membase + 0x200000, 0x200000); + iounmap(brd->re_map_port); + brd->re_map_port = NULL; + } + + if (brd->re_map_membase) { + release_mem_region(brd->membase, 0x200000); + iounmap(brd->re_map_membase); + brd->re_map_membase = NULL; + } + + if (brd->msgbuf_head) { + unsigned long flags; + + DGAP_LOCK(dgap_global_lock, flags); + brd->msgbuf = NULL; + printk(brd->msgbuf_head); + kfree(brd->msgbuf_head); + brd->msgbuf_head = NULL; + DGAP_UNLOCK(dgap_global_lock, flags); + } + + /* Free all allocated channels structs */ + for (i = 0; i < MAXPORTS ; i++) { + if (brd->channels[i]) { + kfree(brd->channels[i]); + brd->channels[i] = NULL; + } + } + + if (brd->flipbuf) + kfree(brd->flipbuf); + if (brd->flipflagbuf) + kfree(brd->flipflagbuf); + + dgap_Board[brd->boardnum] = NULL; + + kfree(brd); +} + + +/* + * dgap_found_board() + * + * A board has been found, init it. + */ +static int dgap_found_board(struct pci_dev *pdev, int id) +{ + struct board_t *brd; + unsigned int pci_irq; + int i = 0; + unsigned long flags; + + /* get the board structure and prep it */ + brd = dgap_Board[dgap_NumBoards] = + (struct board_t *) dgap_driver_kzmalloc(sizeof(struct board_t), GFP_KERNEL); + if (!brd) { + APR(("memory allocation for board structure failed\n")); + return(-ENOMEM); + } + + /* make a temporary message buffer for the boot messages */ + brd->msgbuf = brd->msgbuf_head = + (char *) dgap_driver_kzmalloc(sizeof(char) * 8192, GFP_KERNEL); + if(!brd->msgbuf) { + kfree(brd); + APR(("memory allocation for board msgbuf failed\n")); + return(-ENOMEM); + } + + /* store the info for the board we've found */ + brd->magic = DGAP_BOARD_MAGIC; + brd->boardnum = dgap_NumBoards; + brd->firstminor = 0; + brd->vendor = dgap_pci_tbl[id].vendor; + brd->device = dgap_pci_tbl[id].device; + brd->pdev = pdev; + brd->pci_bus = pdev->bus->number; + brd->pci_slot = PCI_SLOT(pdev->devfn); + brd->name = dgap_Ids[id].name; + brd->maxports = dgap_Ids[id].maxports; + brd->type = dgap_Ids[id].config_type; + brd->dpatype = dgap_Ids[id].dpatype; + brd->dpastatus = BD_NOFEP; + init_waitqueue_head(&brd->state_wait); + + DGAP_SPINLOCK_INIT(brd->bd_lock); + + brd->state = BOARD_FOUND; + brd->runwait = 0; + brd->inhibit_poller = FALSE; + brd->wait_for_bios = 0; + brd->wait_for_fep = 0; + + for (i = 0; i < MAXPORTS; i++) { + brd->channels[i] = NULL; + } + + /* store which card & revision we have */ + pci_read_config_word(pdev, PCI_SUBSYSTEM_VENDOR_ID, &brd->subvendor); + pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, &brd->subdevice); + pci_read_config_byte(pdev, PCI_REVISION_ID, &brd->rev); + + pci_irq = pdev->irq; + brd->irq = pci_irq; + + /* get the PCI Base Address Registers */ + + /* Xr Jupiter and EPC use BAR 2 */ + if (brd->device == PCI_DEVICE_XRJ_DID || brd->device == PCI_DEVICE_EPCJ_DID) { + brd->membase = pci_resource_start(pdev, 2); + brd->membase_end = pci_resource_end(pdev, 2); + } + /* Everyone else uses BAR 0 */ + else { + brd->membase = pci_resource_start(pdev, 0); + brd->membase_end = pci_resource_end(pdev, 0); + } + + if (!brd->membase) { + APR(("card has no PCI IO resources, failing board.\n")); + return -ENODEV; + } + + if (brd->membase & 1) + brd->membase &= ~3; + else + brd->membase &= ~15; + + /* + * On the PCI boards, there is no IO space allocated + * The I/O registers will be in the first 3 bytes of the + * upper 2MB of the 4MB memory space. The board memory + * will be mapped into the low 2MB of the 4MB memory space + */ + brd->port = brd->membase + PCI_IO_OFFSET; + brd->port_end = brd->port + PCI_IO_SIZE; + + + /* + * Special initialization for non-PLX boards + */ + if (brd->device != PCI_DEVICE_XRJ_DID && brd->device != PCI_DEVICE_EPCJ_DID) { + unsigned short cmd; + + pci_write_config_byte(pdev, 0x40, 0); + pci_write_config_byte(pdev, 0x46, 0); + + /* Limit burst length to 2 doubleword transactions */ + pci_write_config_byte(pdev, 0x42, 1); + + /* + * Enable IO and mem if not already done. + * This was needed for support on Itanium. + */ + pci_read_config_word(pdev, PCI_COMMAND, &cmd); + cmd |= (PCI_COMMAND_IO | PCI_COMMAND_MEMORY); + pci_write_config_word(pdev, PCI_COMMAND, cmd); + } + + /* init our poll helper tasklet */ + tasklet_init(&brd->helper_tasklet, dgap_poll_tasklet, (unsigned long) brd); + + /* Log the information about the board */ + dgap_mbuf(brd, DRVSTR": board %d: %s (rev %d), irq %d\n", + dgap_NumBoards, brd->name, brd->rev, brd->irq); + + DPR_INIT(("dgap_scan(%d) - printing out the msgbuf\n", i)); + DGAP_LOCK(dgap_global_lock, flags); + brd->msgbuf = NULL; + printk(brd->msgbuf_head); + kfree(brd->msgbuf_head); + brd->msgbuf_head = NULL; + DGAP_UNLOCK(dgap_global_lock, flags); + + i = dgap_do_remap(brd); + if (i) + brd->state = BOARD_FAILED; + else + brd->state = NEED_RESET; + + return(0); +} + + +int dgap_finalize_board_init(struct board_t *brd) { + + int rc; + + DPR_INIT(("dgap_finalize_board_init() - start\n")); + + if (!brd || brd->magic != DGAP_BOARD_MAGIC) + return(-ENODEV); + + DPR_INIT(("dgap_finalize_board_init() - start #2\n")); + + brd->use_interrupts = dgap_config_get_useintr(brd); + + /* + * Set up our interrupt handler if we are set to do interrupts. + */ + if (brd->use_interrupts && brd->irq) { + + rc = request_irq(brd->irq, dgap_intr, IRQF_SHARED, "DGAP", brd); + + if (rc) { + dgap_mbuf(brd, DRVSTR": Failed to hook IRQ %d. Board will work in poll mode.\n", + brd->irq); + brd->intr_used = 0; + } + else + brd->intr_used = 1; + } else { + brd->intr_used = 0; + } + + return(0); +} + + +/* + * Remap PCI memory. + */ +static int dgap_do_remap(struct board_t *brd) +{ + if (!brd || brd->magic != DGAP_BOARD_MAGIC) + return -ENXIO; + + if (!request_mem_region(brd->membase, 0x200000, "dgap")) { + APR(("dgap: mem_region %lx already in use.\n", brd->membase)); + return -ENOMEM; + } + + if (!request_mem_region(brd->membase + PCI_IO_OFFSET, 0x200000, "dgap")) { + APR(("dgap: mem_region IO %lx already in use.\n", + brd->membase + PCI_IO_OFFSET)); + release_mem_region(brd->membase, 0x200000); + return -ENOMEM; + } + + brd->re_map_membase = ioremap(brd->membase, 0x200000); + if (!brd->re_map_membase) { + APR(("dgap: ioremap mem %lx cannot be mapped.\n", brd->membase)); + release_mem_region(brd->membase, 0x200000); + release_mem_region(brd->membase + PCI_IO_OFFSET, 0x200000); + return -ENOMEM; + } + + brd->re_map_port = ioremap((brd->membase + PCI_IO_OFFSET), 0x200000); + if (!brd->re_map_port) { + release_mem_region(brd->membase, 0x200000); + release_mem_region(brd->membase + PCI_IO_OFFSET, 0x200000); + iounmap(brd->re_map_membase); + APR(("dgap: ioremap IO mem %lx cannot be mapped.\n", + brd->membase + PCI_IO_OFFSET)); + return -ENOMEM; + } + + DPR_INIT(("remapped io: 0x%p remapped mem: 0x%p\n", + brd->re_map_port, brd->re_map_membase)); + return 0; +} + + +/***************************************************************************** +* +* Function: +* +* dgap_poll_handler +* +* Author: +* +* Scott H Kilau +* +* Parameters: +* +* dummy -- ignored +* +* Return Values: +* +* none +* +* Description: +* +* As each timer expires, it determines (a) whether the "transmit" +* waiter needs to be woken up, and (b) whether the poller needs to +* be rescheduled. +* +******************************************************************************/ + +static void dgap_poll_handler(ulong dummy) +{ + int i; + struct board_t *brd; + unsigned long lock_flags; + unsigned long lock_flags2; + ulong new_time; + + dgap_poll_counter++; + + + /* + * If driver needs the config file still, + * keep trying to wake up the downloader to + * send us the file. + */ + if (dgap_driver_state == DRIVER_NEED_CONFIG_LOAD) { + /* + * Signal downloader, its got some work to do. + */ + DGAP_LOCK(dgap_dl_lock, lock_flags2); + if (dgap_dl_action != 1) { + dgap_dl_action = 1; + wake_up_interruptible(&dgap_dl_wait); + } + DGAP_UNLOCK(dgap_dl_lock, lock_flags2); + goto schedule_poller; + } + /* + * Do not start the board state machine until + * driver tells us its up and running, and has + * everything it needs. + */ + else if (dgap_driver_state != DRIVER_READY) { + goto schedule_poller; + } + + /* + * If we have just 1 board, or the system is not SMP, + * then use the typical old style poller. + * Otherwise, use our new tasklet based poller, which should + * speed things up for multiple boards. + */ + if ( (dgap_NumBoards == 1) || (num_online_cpus() <= 1) ) { + for (i = 0; i < dgap_NumBoards; i++) { + + brd = dgap_Board[i]; + + if (brd->state == BOARD_FAILED) { + continue; + } + if (!brd->intr_running) { + /* Call the real board poller directly */ + dgap_poll_tasklet((unsigned long) brd); + } + } + } + else { + /* Go thru each board, kicking off a tasklet for each if needed */ + for (i = 0; i < dgap_NumBoards; i++) { + brd = dgap_Board[i]; + + /* + * Attempt to grab the board lock. + * + * If we can't get it, no big deal, the next poll will get it. + * Basically, I just really don't want to spin in here, because I want + * to kick off my tasklets as fast as I can, and then get out the poller. + */ + if (!spin_trylock(&brd->bd_lock)) { + continue; + } + + /* If board is in a failed state, don't bother scheduling a tasklet */ + if (brd->state == BOARD_FAILED) { + spin_unlock(&brd->bd_lock); + continue; + } + + /* Schedule a poll helper task */ + if (!brd->intr_running) { + tasklet_schedule(&brd->helper_tasklet); + } + + /* + * Can't do DGAP_UNLOCK here, as we don't have + * lock_flags because we did a trylock above. + */ + spin_unlock(&brd->bd_lock); + } + } + +schedule_poller: + + /* + * Schedule ourself back at the nominal wakeup interval. + */ + DGAP_LOCK(dgap_poll_lock, lock_flags ); + dgap_poll_time += dgap_jiffies_from_ms(dgap_poll_tick); + + new_time = dgap_poll_time - jiffies; + + if ((ulong) new_time >= 2 * dgap_poll_tick) { + dgap_poll_time = jiffies + dgap_jiffies_from_ms(dgap_poll_tick); + } + + dgap_poll_timer.function = dgap_poll_handler; + dgap_poll_timer.data = 0; + dgap_poll_timer.expires = dgap_poll_time; + DGAP_UNLOCK(dgap_poll_lock, lock_flags ); + + if (!dgap_poll_stop) + add_timer(&dgap_poll_timer); +} + + + + +/* + * dgap_intr() + * + * Driver interrupt handler. + */ +static irqreturn_t dgap_intr(int irq, void *voidbrd) +{ + struct board_t *brd = (struct board_t *) voidbrd; + + if (!brd) { + APR(("Received interrupt (%d) with null board associated\n", irq)); + return IRQ_NONE; + } + + /* + * Check to make sure its for us. + */ + if (brd->magic != DGAP_BOARD_MAGIC) { + APR(("Received interrupt (%d) with a board pointer that wasn't ours!\n", irq)); + return IRQ_NONE; + } + + brd->intr_count++; + + /* + * Schedule tasklet to run at a better time. + */ + tasklet_schedule(&brd->helper_tasklet); + return IRQ_HANDLED; +} + + +/* + * dgap_init_globals() + * + * This is where we initialize the globals from the static insmod + * configuration variables. These are declared near the head of + * this file. + */ +static void dgap_init_globals(void) +{ + int i = 0; + + dgap_rawreadok = rawreadok; + dgap_trcbuf_size = trcbuf_size; + dgap_debug = debug; + + for (i = 0; i < MAXBOARDS; i++) { + dgap_Board[i] = NULL; + } + + init_timer( &dgap_poll_timer ); + + init_waitqueue_head(&dgap_dl_wait); + dgap_dl_action = 0; +} + + +/************************************************************************ + * + * Utility functions + * + ************************************************************************/ + + +/* + * dgap_driver_kzmalloc() + * + * Malloc and clear memory, + */ +void *dgap_driver_kzmalloc(size_t size, int priority) +{ + void *p = kmalloc(size, priority); + if(p) + memset(p, 0, size); + return(p); +} + + +/* + * dgap_mbuf() + * + * Used to print to the message buffer during board init. + */ +static void dgap_mbuf(struct board_t *brd, const char *fmt, ...) { + va_list ap; + char buf[1024]; + int i; + unsigned long flags; + + DGAP_LOCK(dgap_global_lock, flags); + + /* Format buf using fmt and arguments contained in ap. */ + va_start(ap, fmt); + i = vsprintf(buf, fmt, ap); + va_end(ap); + + DPR((buf)); + + if (!brd || !brd->msgbuf) { + printk(buf); + DGAP_UNLOCK(dgap_global_lock, flags); + return; + } + + memcpy(brd->msgbuf, buf, strlen(buf)); + brd->msgbuf += strlen(buf); + *brd->msgbuf = 0; + + DGAP_UNLOCK(dgap_global_lock, flags); +} + + +/* + * dgap_ms_sleep() + * + * Put the driver to sleep for x ms's + * + * Returns 0 if timed out, !0 (showing signal) if interrupted by a signal. + */ +int dgap_ms_sleep(ulong ms) +{ + current->state = TASK_INTERRUPTIBLE; + schedule_timeout((ms * HZ) / 1000); + return (signal_pending(current)); +} + + + +/* + * dgap_ioctl_name() : Returns a text version of each ioctl value. + */ +char *dgap_ioctl_name(int cmd) +{ + switch(cmd) { + + case TCGETA: return("TCGETA"); + case TCGETS: return("TCGETS"); + case TCSETA: return("TCSETA"); + case TCSETS: return("TCSETS"); + case TCSETAW: return("TCSETAW"); + case TCSETSW: return("TCSETSW"); + case TCSETAF: return("TCSETAF"); + case TCSETSF: return("TCSETSF"); + case TCSBRK: return("TCSBRK"); + case TCXONC: return("TCXONC"); + case TCFLSH: return("TCFLSH"); + case TIOCGSID: return("TIOCGSID"); + + case TIOCGETD: return("TIOCGETD"); + case TIOCSETD: return("TIOCSETD"); + case TIOCGWINSZ: return("TIOCGWINSZ"); + case TIOCSWINSZ: return("TIOCSWINSZ"); + + case TIOCMGET: return("TIOCMGET"); + case TIOCMSET: return("TIOCMSET"); + case TIOCMBIS: return("TIOCMBIS"); + case TIOCMBIC: return("TIOCMBIC"); + + /* from digi.h */ + case DIGI_SETA: return("DIGI_SETA"); + case DIGI_SETAW: return("DIGI_SETAW"); + case DIGI_SETAF: return("DIGI_SETAF"); + case DIGI_SETFLOW: return("DIGI_SETFLOW"); + case DIGI_SETAFLOW: return("DIGI_SETAFLOW"); + case DIGI_GETFLOW: return("DIGI_GETFLOW"); + case DIGI_GETAFLOW: return("DIGI_GETAFLOW"); + case DIGI_GETA: return("DIGI_GETA"); + case DIGI_GEDELAY: return("DIGI_GEDELAY"); + case DIGI_SEDELAY: return("DIGI_SEDELAY"); + case DIGI_GETCUSTOMBAUD: return("DIGI_GETCUSTOMBAUD"); + case DIGI_SETCUSTOMBAUD: return("DIGI_SETCUSTOMBAUD"); + case TIOCMODG: return("TIOCMODG"); + case TIOCMODS: return("TIOCMODS"); + case TIOCSDTR: return("TIOCSDTR"); + case TIOCCDTR: return("TIOCCDTR"); + + default: return("unknown"); + } +} diff --git a/drivers/staging/dgap/dgap_driver.h b/drivers/staging/dgap/dgap_driver.h new file mode 100644 index 0000000000000..b76ec3c39ef0a --- /dev/null +++ b/drivers/staging/dgap/dgap_driver.h @@ -0,0 +1,626 @@ +/* + * Copyright 2003 Digi International (www.digi.com) + * Scott H Kilau + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! + * + ************************************************************************* + * + * Driver includes + * + *************************************************************************/ + +#ifndef __DGAP_DRIVER_H +#define __DGAP_DRIVER_H + +#include /* To get the current Linux version */ +#include /* To pick up the varions Linux types */ +#include /* To pick up the various tty structs/defines */ +#include /* For irqreturn_t type */ + +#include "dgap_types.h" /* Additional types needed by the Digi header files */ +#include "digi.h" /* Digi specific ioctl header */ +#include "dgap_kcompat.h" /* Kernel 2.4/2.6 compat includes */ +#include "dgap_sysfs.h" /* Support for SYSFS */ + +/************************************************************************* + * + * Driver defines + * + *************************************************************************/ + +/* + * Driver identification, error and debugging statments + * + * In theory, you can change all occurances of "digi" in the next + * three lines, and the driver printk's will all automagically change. + * + * APR((fmt, args, ...)); Always prints message + * DPR((fmt, args, ...)); Only prints if DGAP_TRACER is defined at + * compile time and dgap_debug!=0 + */ +#define PROCSTR "dgap" /* /proc entries */ +#define DEVSTR "/dev/dg/dgap" /* /dev entries */ +#define DRVSTR "dgap" /* Driver name string + * displayed by APR */ +#define APR(args) do { PRINTF_TO_KMEM(args); printk(DRVSTR": "); printk args; \ + } while (0) +#define RAPR(args) do { PRINTF_TO_KMEM(args); printk args; } while (0) + +#define TRC_TO_CONSOLE 1 + +/* + * Debugging levels can be set using debug insmod variable + * They can also be compiled out completely. + */ + +#define DBG_INIT (dgap_debug & 0x01) +#define DBG_BASIC (dgap_debug & 0x02) +#define DBG_CORE (dgap_debug & 0x04) + +#define DBG_OPEN (dgap_debug & 0x08) +#define DBG_CLOSE (dgap_debug & 0x10) +#define DBG_READ (dgap_debug & 0x20) +#define DBG_WRITE (dgap_debug & 0x40) + +#define DBG_IOCTL (dgap_debug & 0x80) + +#define DBG_PROC (dgap_debug & 0x100) +#define DBG_PARAM (dgap_debug & 0x200) +#define DBG_PSCAN (dgap_debug & 0x400) +#define DBG_EVENT (dgap_debug & 0x800) + +#define DBG_DRAIN (dgap_debug & 0x1000) +#define DBG_CARR (dgap_debug & 0x2000) + +#define DBG_MGMT (dgap_debug & 0x4000) + + +#if defined(DGAP_TRACER) + +# if defined(TRC_TO_KMEM) +/* Choose one: */ +# define TRC_ON_OVERFLOW_WRAP_AROUND +# undef TRC_ON_OVERFLOW_SHIFT_BUFFER +# endif //TRC_TO_KMEM + +# define TRC_MAXMSG 1024 +# define TRC_OVERFLOW "(OVERFLOW)" +# define TRC_DTRC "/usr/bin/dtrc" + +#if defined TRC_TO_CONSOLE +#define PRINTF_TO_CONSOLE(args) { printk(DRVSTR": "); printk args; } +#else //!defined TRACE_TO_CONSOLE +#define PRINTF_TO_CONSOLE(args) +#endif + +#if defined TRC_TO_KMEM +#define PRINTF_TO_KMEM(args) dgap_tracef args +#else //!defined TRC_TO_KMEM +#define PRINTF_TO_KMEM(args) +#endif + +#define TRC(args) { PRINTF_TO_KMEM(args); PRINTF_TO_CONSOLE(args) } + +# define DPR_INIT(ARGS) if (DBG_INIT) TRC(ARGS) +# define DPR_BASIC(ARGS) if (DBG_BASIC) TRC(ARGS) +# define DPR_CORE(ARGS) if (DBG_CORE) TRC(ARGS) +# define DPR_OPEN(ARGS) if (DBG_OPEN) TRC(ARGS) +# define DPR_CLOSE(ARGS) if (DBG_CLOSE) TRC(ARGS) +# define DPR_READ(ARGS) if (DBG_READ) TRC(ARGS) +# define DPR_WRITE(ARGS) if (DBG_WRITE) TRC(ARGS) +# define DPR_IOCTL(ARGS) if (DBG_IOCTL) TRC(ARGS) +# define DPR_PROC(ARGS) if (DBG_PROC) TRC(ARGS) +# define DPR_PARAM(ARGS) if (DBG_PARAM) TRC(ARGS) +# define DPR_PSCAN(ARGS) if (DBG_PSCAN) TRC(ARGS) +# define DPR_EVENT(ARGS) if (DBG_EVENT) TRC(ARGS) +# define DPR_DRAIN(ARGS) if (DBG_DRAIN) TRC(ARGS) +# define DPR_CARR(ARGS) if (DBG_CARR) TRC(ARGS) +# define DPR_MGMT(ARGS) if (DBG_MGMT) TRC(ARGS) + +# define DPR(ARGS) if (dgap_debug) TRC(ARGS) +# define P(X) dgap_tracef(#X "=%p\n", X) +# define X(X) dgap_tracef(#X "=%x\n", X) + +#else//!defined DGAP_TRACER + +#define PRINTF_TO_KMEM(args) +# define TRC(ARGS) +# define DPR_INIT(ARGS) +# define DPR_BASIC(ARGS) +# define DPR_CORE(ARGS) +# define DPR_OPEN(ARGS) +# define DPR_CLOSE(ARGS) +# define DPR_READ(ARGS) +# define DPR_WRITE(ARGS) +# define DPR_IOCTL(ARGS) +# define DPR_PROC(ARGS) +# define DPR_PARAM(ARGS) +# define DPR_PSCAN(ARGS) +# define DPR_EVENT(ARGS) +# define DPR_DRAIN(ARGS) +# define DPR_CARR(ARGS) +# define DPR_MGMT(ARGS) + +# define DPR(args) + +#endif//DGAP_TRACER + +/* Number of boards we support at once. */ +#define MAXBOARDS 32 +#define MAXPORTS 224 +#define MAXTTYNAMELEN 200 + +/* Our 3 magic numbers for our board, channel and unit structs */ +#define DGAP_BOARD_MAGIC 0x5c6df104 +#define DGAP_CHANNEL_MAGIC 0x6c6df104 +#define DGAP_UNIT_MAGIC 0x7c6df104 + +/* Serial port types */ +#define DGAP_SERIAL 0 +#define DGAP_PRINT 1 + +#define SERIAL_TYPE_NORMAL 1 + +/* 4 extra for alignment play space */ +#define WRITEBUFLEN ((4096) + 4) +#define MYFLIPLEN N_TTY_BUF_SIZE + +#define SBREAK_TIME 0x25 +#define U2BSIZE 0x400 + +#define dgap_jiffies_from_ms(a) (((a) * HZ) / 1000) + +/* + * Our major for the mgmt devices. + * + * We can use 22, because Digi was allocated 22 and 23 for the epca driver. + * 22 has now become obsolete now that the "cu" devices have + * been removed from 2.6. + * Also, this *IS* the epca driver, just PCI only now. + */ +#ifndef DIGI_DGAP_MAJOR +# define DIGI_DGAP_MAJOR 22 +#endif + +/* + * The parameters we use to define the periods of the moving averages. + */ +#define MA_PERIOD (HZ / 10) +#define SMA_DUR (1 * HZ) +#define EMA_DUR (1 * HZ) +#define SMA_NPERIODS (SMA_DUR / MA_PERIOD) +#define EMA_NPERIODS (EMA_DUR / MA_PERIOD) + +/* + * Define a local default termios struct. All ports will be created + * with this termios initially. This is the same structure that is defined + * as the default in tty_io.c with the same settings overriden as in serial.c + * + * In short, this should match the internal serial ports' defaults. + */ +#define DEFAULT_IFLAGS (ICRNL | IXON) +#define DEFAULT_OFLAGS (OPOST | ONLCR) +#define DEFAULT_CFLAGS (B9600 | CS8 | CREAD | HUPCL | CLOCAL) +#define DEFAULT_LFLAGS (ISIG | ICANON | ECHO | ECHOE | ECHOK | \ + ECHOCTL | ECHOKE | IEXTEN) + +#ifndef _POSIX_VDISABLE +#define _POSIX_VDISABLE '\0' +#endif + +#define SNIFF_MAX 65536 /* Sniff buffer size (2^n) */ +#define SNIFF_MASK (SNIFF_MAX - 1) /* Sniff wrap mask */ + +#define VPDSIZE (512) + +/* + * Lock function/defines. + * Makes spotting lock/unlock locations easier. + */ +# define DGAP_SPINLOCK_INIT(x) spin_lock_init(&(x)) +# define DGAP_LOCK(x,y) spin_lock_irqsave(&(x), y) +# define DGAP_UNLOCK(x,y) spin_unlock_irqrestore(&(x), y) +# define DGAP_TRYLOCK(x,y) spin_trylock(&(x)) + +/* + * All the possible states the driver can be while being loaded. + */ +enum { + DRIVER_INITIALIZED = 0, + DRIVER_NEED_CONFIG_LOAD, + DRIVER_REQUESTED_CONFIG, + DRIVER_READY +}; + +/* + * All the possible states the board can be while booting up. + */ +enum { + BOARD_FAILED = 0, + CONFIG_NOT_FOUND, + BOARD_FOUND, + NEED_RESET, + FINISHED_RESET, + NEED_CONFIG, + FINISHED_CONFIG, + NEED_DEVICE_CREATION, + REQUESTED_DEVICE_CREATION, + FINISHED_DEVICE_CREATION, + NEED_BIOS_LOAD, + REQUESTED_BIOS, + WAIT_BIOS_LOAD, + FINISHED_BIOS_LOAD, + NEED_FEP_LOAD, + REQUESTED_FEP, + WAIT_FEP_LOAD, + FINISHED_FEP_LOAD, + NEED_PROC_CREATION, + FINISHED_PROC_CREATION, + BOARD_READY +}; + +/* + * All the possible states that a requested concentrator image can be in. + */ +enum { + NO_PENDING_CONCENTRATOR_REQUESTS = 0, + NEED_CONCENTRATOR, + REQUESTED_CONCENTRATOR +}; + +extern char *dgap_state_text[]; +extern char *dgap_driver_state_text[]; + + +/* + * Modem line constants are defined as macros because DSR and + * DCD are swapable using the ditty altpin option. + */ +#define D_CD(ch) ch->ch_cd /* Carrier detect */ +#define D_DSR(ch) ch->ch_dsr /* Data set ready */ +#define D_RTS(ch) DM_RTS /* Request to send */ +#define D_CTS(ch) DM_CTS /* Clear to send */ +#define D_RI(ch) DM_RI /* Ring indicator */ +#define D_DTR(ch) DM_DTR /* Data terminal ready */ + + +/************************************************************************* + * + * Structures and closely related defines. + * + *************************************************************************/ + + +/* + * A structure to hold a statistics counter. We also + * compute moving averages for this counter. + */ +struct macounter +{ + u32 cnt; /* Total count */ + ulong accum; /* Acuumulator per period */ + ulong sma; /* Simple moving average */ + ulong ema; /* Exponential moving average */ +}; + + +/************************************************************************ + * Device flag definitions for bd_flags. + ************************************************************************/ +#define BD_FEP5PLUS 0x0001 /* Supports FEP5 Plus commands */ +#define BD_HAS_VPD 0x0002 /* Board has VPD info available */ + + +/* + * Per-board information + */ +struct board_t +{ + int magic; /* Board Magic number. */ + int boardnum; /* Board number: 0-3 */ + int firstminor; /* First minor, e.g. 0, 30, 60 */ + + int type; /* Type of board */ + char *name; /* Product Name */ + struct pci_dev *pdev; /* Pointer to the pci_dev struct */ + u16 vendor; /* PCI vendor ID */ + u16 device; /* PCI device ID */ + u16 subvendor; /* PCI subsystem vendor ID */ + u16 subdevice; /* PCI subsystem device ID */ + uchar rev; /* PCI revision ID */ + uint pci_bus; /* PCI bus value */ + uint pci_slot; /* PCI slot value */ + u16 maxports; /* MAX ports this board can handle */ + uchar vpd[VPDSIZE]; /* VPD of board, if found */ + u32 bd_flags; /* Board flags */ + + spinlock_t bd_lock; /* Used to protect board */ + + u32 state; /* State of card. */ + wait_queue_head_t state_wait; /* Place to sleep on for state change */ + + struct tasklet_struct helper_tasklet; /* Poll helper tasklet */ + + u32 wait_for_bios; + u32 wait_for_fep; + + struct cnode * bd_config; /* Config of board */ + + u16 nasync; /* Number of ports on card */ + + u32 use_interrupts; /* Should we be interrupt driven? */ + ulong irq; /* Interrupt request number */ + ulong intr_count; /* Count of interrupts */ + u32 intr_used; /* Non-zero if using interrupts */ + u32 intr_running; /* Non-zero if FEP knows its doing interrupts */ + + ulong port; /* Start of base io port of the card */ + ulong port_end; /* End of base io port of the card */ + ulong membase; /* Start of base memory of the card */ + ulong membase_end; /* End of base memory of the card */ + + uchar *re_map_port; /* Remapped io port of the card */ + uchar *re_map_membase;/* Remapped memory of the card */ + + uchar runwait; /* # Processes waiting for FEP */ + uchar inhibit_poller; /* Tells the poller to leave us alone */ + + struct channel_t *channels[MAXPORTS]; /* array of pointers to our channels. */ + + struct tty_driver *SerialDriver; + char SerialName[200]; + struct tty_driver *PrintDriver; + char PrintName[200]; + + u32 dgap_Major_Serial_Registered; + u32 dgap_Major_TransparentPrint_Registered; + + u32 dgap_Serial_Major; + u32 dgap_TransparentPrint_Major; + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28) + u32 TtyRefCnt; +#endif + + struct bs_t *bd_bs; /* Base structure pointer */ + + char *flipbuf; /* Our flip buffer, alloced if board is found */ + char *flipflagbuf; /* Our flip flag buffer, alloced if board is found */ + + u16 dpatype; /* The board "type", as defined by DPA */ + u16 dpastatus; /* The board "status", as defined by DPA */ + wait_queue_head_t kme_wait; /* Needed for DPA support */ + + u32 conc_dl_status; /* Status of any pending conc download */ + /* + * Mgmt data. + */ + char *msgbuf_head; + char *msgbuf; + + /* /proc/ entries */ + struct proc_dir_entry *proc_entry_pointer; + struct dgap_proc_entry *dgap_board_table; +}; + + + +/************************************************************************ + * Unit flag definitions for un_flags. + ************************************************************************/ +#define UN_ISOPEN 0x0001 /* Device is open */ +#define UN_CLOSING 0x0002 /* Line is being closed */ +#define UN_IMM 0x0004 /* Service immediately */ +#define UN_BUSY 0x0008 /* Some work this channel */ +#define UN_BREAKI 0x0010 /* Input break received */ +#define UN_PWAIT 0x0020 /* Printer waiting for terminal */ +#define UN_TIME 0x0040 /* Waiting on time */ +#define UN_EMPTY 0x0080 /* Waiting output queue empty */ +#define UN_LOW 0x0100 /* Waiting output low water mark*/ +#define UN_EXCL_OPEN 0x0200 /* Open for exclusive use */ +#define UN_WOPEN 0x0400 /* Device waiting for open */ +#define UN_WIOCTL 0x0800 /* Device waiting for open */ +#define UN_HANGUP 0x8000 /* Carrier lost */ + +struct device; + +/************************************************************************ + * Structure for terminal or printer unit. + ************************************************************************/ +struct un_t { + int magic; /* Unit Magic Number. */ + struct channel_t *un_ch; + u32 un_time; + u32 un_type; + u32 un_open_count; /* Counter of opens to port */ + struct tty_struct *un_tty;/* Pointer to unit tty structure */ + u32 un_flags; /* Unit flags */ + wait_queue_head_t un_flags_wait; /* Place to sleep to wait on unit */ + u32 un_dev; /* Minor device number */ + tcflag_t un_oflag; /* oflags being done on board */ + tcflag_t un_lflag; /* lflags being done on board */ + struct device *un_sysfs; +}; + + +/************************************************************************ + * Device flag definitions for ch_flags. + ************************************************************************/ +#define CH_PRON 0x0001 /* Printer on string */ +#define CH_OUT 0x0002 /* Dial-out device open */ +#define CH_STOP 0x0004 /* Output is stopped */ +#define CH_STOPI 0x0008 /* Input is stopped */ +#define CH_CD 0x0010 /* Carrier is present */ +#define CH_FCAR 0x0020 /* Carrier forced on */ + +#define CH_RXBLOCK 0x0080 /* Enable rx blocked flag */ +#define CH_WLOW 0x0100 /* Term waiting low event */ +#define CH_WEMPTY 0x0200 /* Term waiting empty event */ +#define CH_RENABLE 0x0400 /* Buffer just emptied */ +#define CH_RACTIVE 0x0800 /* Process active in xxread() */ +#define CH_RWAIT 0x1000 /* Process waiting in xxread() */ +#define CH_BAUD0 0x2000 /* Used for checking B0 transitions */ +#define CH_HANGUP 0x8000 /* Hangup received */ + +/* + * Definitions for ch_sniff_flags + */ +#define SNIFF_OPEN 0x1 +#define SNIFF_WAIT_DATA 0x2 +#define SNIFF_WAIT_SPACE 0x4 + + +/************************************************************************ + * Channel information structure. + ************************************************************************/ +struct channel_t { + int magic; /* Channel Magic Number */ + struct bs_t *ch_bs; /* Base structure pointer */ + struct cm_t *ch_cm; /* Command queue pointer */ + struct board_t *ch_bd; /* Board structure pointer */ + unsigned char *ch_vaddr; /* FEP memory origin */ + unsigned char *ch_taddr; /* Write buffer origin */ + unsigned char *ch_raddr; /* Read buffer origin */ + struct digi_t ch_digi; /* Transparent Print structure */ + struct un_t ch_tun; /* Terminal unit info */ + struct un_t ch_pun; /* Printer unit info */ + + spinlock_t ch_lock; /* provide for serialization */ + wait_queue_head_t ch_flags_wait; + + u32 pscan_state; + uchar pscan_savechar; + + u32 ch_portnum; /* Port number, 0 offset. */ + u32 ch_open_count; /* open count */ + u32 ch_flags; /* Channel flags */ + + + u32 ch_close_delay; /* How long we should drop RTS/DTR for */ + + u32 ch_cpstime; /* Time for CPS calculations */ + + tcflag_t ch_c_iflag; /* channel iflags */ + tcflag_t ch_c_cflag; /* channel cflags */ + tcflag_t ch_c_oflag; /* channel oflags */ + tcflag_t ch_c_lflag; /* channel lflags */ + + u16 ch_fepiflag; /* FEP tty iflags */ + u16 ch_fepcflag; /* FEP tty cflags */ + u16 ch_fepoflag; /* FEP tty oflags */ + u16 ch_wopen; /* Waiting for open process cnt */ + u16 ch_tstart; /* Transmit buffer start */ + u16 ch_tsize; /* Transmit buffer size */ + u16 ch_rstart; /* Receive buffer start */ + u16 ch_rsize; /* Receive buffer size */ + u16 ch_rdelay; /* Receive delay time */ + + u16 ch_tlw; /* Our currently set low water mark */ + + u16 ch_cook; /* Output character mask */ + + uchar ch_card; /* Card channel is on */ + uchar ch_stopc; /* Stop character */ + uchar ch_startc; /* Start character */ + + uchar ch_mostat; /* FEP output modem status */ + uchar ch_mistat; /* FEP input modem status */ + uchar ch_mforce; /* Modem values to be forced */ + uchar ch_mval; /* Force values */ + uchar ch_fepstopc; /* FEP stop character */ + uchar ch_fepstartc; /* FEP start character */ + + uchar ch_astopc; /* Auxiliary Stop character */ + uchar ch_astartc; /* Auxiliary Start character */ + uchar ch_fepastopc; /* Auxiliary FEP stop char */ + uchar ch_fepastartc; /* Auxiliary FEP start char */ + + uchar ch_hflow; /* FEP hardware handshake */ + uchar ch_dsr; /* stores real dsr value */ + uchar ch_cd; /* stores real cd value */ + uchar ch_tx_win; /* channel tx buffer window */ + uchar ch_rx_win; /* channel rx buffer window */ + uint ch_custom_speed; /* Custom baud, if set */ + uint ch_baud_info; /* Current baud info for /proc output */ + ulong ch_rxcount; /* total of data received so far */ + ulong ch_txcount; /* total of data transmitted so far */ + ulong ch_err_parity; /* Count of parity errors on channel */ + ulong ch_err_frame; /* Count of framing errors on channel */ + ulong ch_err_break; /* Count of breaks on channel */ + ulong ch_err_overrun; /* Count of overruns on channel */ + + /* /proc// entries */ + struct proc_dir_entry *proc_entry_pointer; + struct dgap_proc_entry *dgap_channel_table; + + uint ch_sniff_in; + uint ch_sniff_out; + char *ch_sniff_buf; /* Sniff buffer for proc */ + ulong ch_sniff_flags; /* Channel flags */ + wait_queue_head_t ch_sniff_wait; +}; + + +/************************************************************************* + * + * Prototypes for non-static functions used in more than one module + * + *************************************************************************/ + +extern int dgap_ms_sleep(ulong ms); +extern void *dgap_driver_kzmalloc(size_t size, int priority); +extern char *dgap_ioctl_name(int cmd); +extern void dgap_do_bios_load(struct board_t *brd, uchar __user *ubios, int len); +extern void dgap_do_fep_load(struct board_t *brd, uchar __user *ufep, int len); +extern void dgap_do_conc_load(struct board_t *brd, uchar *uaddr, int len); +extern void dgap_do_config_load(uchar __user *uaddr, int len); +extern int dgap_after_config_loaded(void); +extern int dgap_finalize_board_init(struct board_t *brd); + +/* + * Our Global Variables. + */ +extern int dgap_driver_state; /* The state of the driver */ +extern int dgap_debug; /* Debug variable */ +extern int dgap_rawreadok; /* Set if user wants rawreads */ +extern int dgap_poll_tick; /* Poll interval - 20 ms */ +extern spinlock_t dgap_global_lock; /* Driver global spinlock */ +extern uint dgap_NumBoards; /* Total number of boards */ +extern struct board_t *dgap_Board[MAXBOARDS]; /* Array of board structs */ +extern ulong dgap_poll_counter; /* Times the poller has run */ +extern char *dgap_config_buf; /* The config file buffer */ +extern spinlock_t dgap_dl_lock; /* Downloader spinlock */ +extern wait_queue_head_t dgap_dl_wait; /* Wait queue for downloader */ +extern int dgap_dl_action; /* Action flag for downloader */ +extern int dgap_registerttyswithsysfs; /* Should we register the */ + /* ttys with sysfs or not */ + +/* + * Global functions declared in dgap_fep5.c, but must be hidden from + * user space programs. + */ +extern void dgap_poll_tasklet(unsigned long data); +extern void dgap_cmdb(struct channel_t *ch, uchar cmd, uchar byte1, uchar byte2, uint ncmds); +extern void dgap_cmdw(struct channel_t *ch, uchar cmd, u16 word, uint ncmds); +extern void dgap_wmove(struct channel_t *ch, char *buf, uint cnt); +extern int dgap_param(struct tty_struct *tty); +extern void dgap_parity_scan(struct channel_t *ch, unsigned char *cbuf, unsigned char *fbuf, int *len); +extern uint dgap_get_custom_baud(struct channel_t *ch); +extern void dgap_firmware_reset_port(struct channel_t *ch); + +#endif diff --git a/drivers/staging/dgap/dgap_fep5.c b/drivers/staging/dgap/dgap_fep5.c new file mode 100644 index 0000000000000..ed3cb151d6dab --- /dev/null +++ b/drivers/staging/dgap/dgap_fep5.c @@ -0,0 +1,1957 @@ +/* + * Copyright 2003 Digi International (www.digi.com) + * Scott H Kilau + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * + * NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE! + * + * This is shared code between Digi's CVS archive and the + * Linux Kernel sources. + * Changing the source just for reformatting needlessly breaks + * our CVS diff history. + * + * Send any bug fixes/changes to: Eng.Linux at digi dot com. + * Thank you. + * + * $Id: dgap_fep5.c,v 1.2 2011/06/21 10:35:40 markh Exp $ + */ + + +#include +#include +#include +#include +#include /* For udelay */ +#include /* For copy_from_user/copy_to_user */ +#include +#include /* For tty_schedule_flip */ + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39) +#include +#endif + +#include "dgap_driver.h" +#include "dgap_pci.h" +#include "dgap_proc.h" +#include "dgap_fep5.h" +#include "dgap_tty.h" +#include "dgap_conf.h" +#include "dgap_parse.h" +#include "dgap_mgmt.h" +#include "dgap_trace.h" + +/* + * Our function prototypes + */ +static void dgap_cmdw_ext(struct channel_t *ch, u16 cmd, u16 word, uint ncmds); +static int dgap_event(struct board_t *bd); + +/* + * internal variables + */ +static uint dgap_count = 500; + + +/* + * Loads the dgap.conf config file from the user. + */ +void dgap_do_config_load(uchar __user *uaddr, int len) +{ + int orig_len = len; + char *to_addr; + uchar __user *from_addr = uaddr; + char buf[U2BSIZE]; + int n; + + to_addr = dgap_config_buf = dgap_driver_kzmalloc(len + 1, GFP_ATOMIC); + if (!dgap_config_buf) { + DPR_INIT(("dgap_do_config_load - unable to allocate memory for file\n")); + dgap_driver_state = DRIVER_NEED_CONFIG_LOAD; + return; + } + + n = U2BSIZE; + while (len) { + + if (n > len) + n = len; + + if (copy_from_user((char *) &buf, from_addr, n) == -1 ) + return; + + /* Copy data from buffer to kernel memory */ + memcpy(to_addr, buf, n); + + /* increment counts */ + len -= n; + to_addr += n; + from_addr += n; + n = U2BSIZE; + } + + dgap_config_buf[orig_len] = '\0'; + + to_addr = dgap_config_buf; + dgap_parsefile(&to_addr, TRUE); + + DPR_INIT(("dgap_config_load() finish\n")); + + return; +} + + +int dgap_after_config_loaded(void) +{ + int i = 0; + int rc = 0; + + /* + * Register our ttys, now that we have the config loaded. + */ + for (i = 0; i < dgap_NumBoards; ++i) { + + /* + * Initialize KME waitqueues... + */ + init_waitqueue_head(&(dgap_Board[i]->kme_wait)); + + /* + * allocate flip buffer for board. + */ + dgap_Board[i]->flipbuf = dgap_driver_kzmalloc(MYFLIPLEN, GFP_ATOMIC); + dgap_Board[i]->flipflagbuf = dgap_driver_kzmalloc(MYFLIPLEN, GFP_ATOMIC); + + dgap_proc_register_basic_postscan(i); + } + + return (rc); +} + + + +/*======================================================================= + * + * usertoboard - copy from user space to board space. + * + *=======================================================================*/ +static int dgap_usertoboard(struct board_t *brd, char *to_addr, char __user *from_addr, int len) +{ + char buf[U2BSIZE]; + int n = U2BSIZE; + + if (!brd || brd->magic != DGAP_BOARD_MAGIC) + return(-EFAULT); + + while (len) { + if (n > len) + n = len; + + if (copy_from_user((char *) &buf, from_addr, n) == -1 ) { + return(-EFAULT); + } + + /* Copy data from buffer to card memory */ + memcpy_toio(to_addr, buf, n); + + /* increment counts */ + len -= n; + to_addr += n; + from_addr += n; + n = U2BSIZE; + } + return(0); +} + + +/* + * Copies the BIOS code from the user to the board, + * and starts the BIOS running. + */ +void dgap_do_bios_load(struct board_t *brd, uchar __user *ubios, int len) +{ + uchar *addr; + uint offset; + int i; + + if (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase) + return; + + DPR_INIT(("dgap_do_bios_load() start\n")); + + addr = brd->re_map_membase; + + /* + * clear POST area + */ + for (i = 0; i < 16; i++) + writeb(0, addr + POSTAREA + i); + + /* + * Download bios + */ + offset = 0x1000; + if (dgap_usertoboard(brd, addr + offset, ubios, len) == -1 ) { + brd->state = BOARD_FAILED; + brd->dpastatus = BD_NOFEP; + return; + } + + writel(0x0bf00401, addr); + writel(0, (addr + 4)); + + /* Clear the reset, and change states. */ + writeb(FEPCLR, brd->re_map_port); + brd->state = WAIT_BIOS_LOAD; +} + + +/* + * Checks to see if the BIOS completed running on the card. + */ +static void dgap_do_wait_for_bios(struct board_t *brd) +{ + uchar *addr; + u16 word; + + if (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase) + return; + + addr = brd->re_map_membase; + word = readw(addr + POSTAREA); + + /* Check to see if BIOS thinks board is good. (GD). */ + if (word == *(u16 *) "GD") { + DPR_INIT(("GOT GD in memory, moving states.\n")); + brd->state = FINISHED_BIOS_LOAD; + return; + } + + /* Give up on board after too long of time taken */ + if (brd->wait_for_bios++ > 5000) { + u16 err1 = readw(addr + SEQUENCE); + u16 err2 = readw(addr + ERROR); + APR(("***WARNING*** %s failed diagnostics. Error #(%x,%x).\n", + brd->name, err1, err2)); + brd->state = BOARD_FAILED; + brd->dpastatus = BD_NOFEP; + } +} + + +/* + * Copies the FEP code from the user to the board, + * and starts the FEP running. + */ +void dgap_do_fep_load(struct board_t *brd, uchar __user *ufep, int len) +{ + uchar *addr; + uint offset; + + if (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase) + return; + + addr = brd->re_map_membase; + + DPR_INIT(("dgap_do_fep_load() for board %s : start\n", brd->name)); + + /* + * Download FEP + */ + offset = 0x1000; + if (dgap_usertoboard(brd, addr + offset, ufep, len) == -1 ) { + brd->state = BOARD_FAILED; + brd->dpastatus = BD_NOFEP; + return; + } + + /* + * If board is a concentrator product, we need to give + * it its config string describing how the concentrators look. + */ + if ((brd->type == PCX) || (brd->type == PEPC)) { + uchar string[100]; + uchar *config, *xconfig; + int i = 0; + + xconfig = dgap_create_config_string(brd, string); + + /* Write string to board memory */ + config = addr + CONFIG; + for (; i < CONFIGSIZE; i++, config++, xconfig++) { + writeb(*xconfig, config); + if ((*xconfig & 0xff) == 0xff) + break; + } + } + + writel(0xbfc01004, (addr + 0xc34)); + writel(0x3, (addr + 0xc30)); + + /* change states. */ + brd->state = WAIT_FEP_LOAD; + + DPR_INIT(("dgap_do_fep_load() for board %s : finish\n", brd->name)); + +} + + +/* + * Waits for the FEP to report thats its ready for us to use. + */ +static void dgap_do_wait_for_fep(struct board_t *brd) +{ + uchar *addr; + u16 word; + + if (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase) + return; + + addr = brd->re_map_membase; + + DPR_INIT(("dgap_do_wait_for_fep() for board %s : start. addr: %p\n", brd->name, addr)); + + word = readw(addr + FEPSTAT); + + /* Check to see if FEP is up and running now. */ + if (word == *(u16 *) "OS") { + DPR_INIT(("GOT OS in memory for board %s, moving states.\n", brd->name)); + brd->state = FINISHED_FEP_LOAD; + + /* + * Check to see if the board can support FEP5+ commands. + */ + word = readw(addr + FEP5_PLUS); + if (word == *(u16 *) "5A") { + DPR_INIT(("GOT 5A in memory for board %s, board supports extended FEP5 commands.\n", brd->name)); + brd->bd_flags |= BD_FEP5PLUS; + } + + return; + } + + /* Give up on board after too long of time taken */ + if (brd->wait_for_fep++ > 5000) { + u16 err1 = readw(addr + SEQUENCE); + u16 err2 = readw(addr + ERROR); + APR(("***WARNING*** FEPOS for %s not functioning. Error #(%x,%x).\n", + brd->name, err1, err2)); + brd->state = BOARD_FAILED; + brd->dpastatus = BD_NOFEP; + } + + DPR_INIT(("dgap_do_wait_for_fep() for board %s : finish\n", brd->name)); +} + + +/* + * Physically forces the FEP5 card to reset itself. + */ +static void dgap_do_reset_board(struct board_t *brd) +{ + uchar check; + u32 check1; + u32 check2; + int i = 0; + + if (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase || !brd->re_map_port) { + DPR_INIT(("dgap_do_reset_board() start. bad values. brd: %p mem: %p io: %p\n", + brd, brd ? brd->re_map_membase : 0, brd ? brd->re_map_port : 0)); + return; + } + + DPR_INIT(("dgap_do_reset_board() start. io: %p\n", brd->re_map_port)); + + /* FEPRST does not vary among supported boards */ + writeb(FEPRST, brd->re_map_port); + + for (i = 0; i <= 1000; i++) { + check = readb(brd->re_map_port) & 0xe; + if (check == FEPRST) + break; + udelay(10); + + } + if (i > 1000) { + APR(("*** WARNING *** Board not resetting... Failing board.\n")); + brd->state = BOARD_FAILED; + brd->dpastatus = BD_NOFEP; + goto failed; + } + + /* + * Make sure there really is memory out there. + */ + writel(0xa55a3cc3, (brd->re_map_membase + LOWMEM)); + writel(0x5aa5c33c, (brd->re_map_membase + HIGHMEM)); + check1 = readl(brd->re_map_membase + LOWMEM); + check2 = readl(brd->re_map_membase + HIGHMEM); + + if ((check1 != 0xa55a3cc3) || (check2 != 0x5aa5c33c)) { + APR(("*** Warning *** No memory at %p for board.\n", brd->re_map_membase)); + brd->state = BOARD_FAILED; + brd->dpastatus = BD_NOFEP; + goto failed; + } + + if (brd->state != BOARD_FAILED) + brd->state = FINISHED_RESET; + +failed: + DPR_INIT(("dgap_do_reset_board() finish\n")); +} + + +/* + * Sends a concentrator image into the FEP5 board. + */ +void dgap_do_conc_load(struct board_t *brd, uchar *uaddr, int len) +{ + char *vaddr; + u16 offset = 0; + struct downld_t *to_dp; + + if (!brd || (brd->magic != DGAP_BOARD_MAGIC) || !brd->re_map_membase) + return; + + vaddr = brd->re_map_membase; + + offset = readw((u16 *) (vaddr + DOWNREQ)); + to_dp = (struct downld_t *) (vaddr + (int) offset); + + /* + * The image was already read into kernel space, + * we do NOT need a user space read here + */ + memcpy_toio((char *) to_dp, uaddr, sizeof(struct downld_t)); + + /* Tell card we have data for it */ + writew(0, vaddr + (DOWNREQ)); + + brd->conc_dl_status = NO_PENDING_CONCENTRATOR_REQUESTS; +} + + +#define EXPANSION_ROM_SIZE (64 * 1024) +#define FEP5_ROM_MAGIC (0xFEFFFFFF) + +static void dgap_get_vpd(struct board_t *brd) +{ + u32 magic; + u32 base_offset; + u16 rom_offset; + u16 vpd_offset; + u16 image_length; + u16 i; + uchar byte1; + uchar byte2; + + /* + * Poke the magic number at the PCI Rom Address location. + * If VPD is supported, the value read from that address + * will be non-zero. + */ + magic = FEP5_ROM_MAGIC; + pci_write_config_dword(brd->pdev, PCI_ROM_ADDRESS, magic); + pci_read_config_dword(brd->pdev, PCI_ROM_ADDRESS, &magic); + + /* VPD not supported, bail */ + if (!magic) + return; + + /* + * To get to the OTPROM memory, we have to send the boards base + * address or'ed with 1 into the PCI Rom Address location. + */ + magic = brd->membase | 0x01; + pci_write_config_dword(brd->pdev, PCI_ROM_ADDRESS, magic); + pci_read_config_dword(brd->pdev, PCI_ROM_ADDRESS, &magic); + + byte1 = readb(brd->re_map_membase); + byte2 = readb(brd->re_map_membase + 1); + + /* + * If the board correctly swapped to the OTPROM memory, + * the first 2 bytes (header) should be 0x55, 0xAA + */ + if (byte1 == 0x55 && byte2 == 0xAA) { + + base_offset = 0; + + /* + * We have to run through all the OTPROM memory looking + * for the VPD offset. + */ + while (base_offset <= EXPANSION_ROM_SIZE) { + + /* + * Lots of magic numbers here. + * + * The VPD offset is located inside the ROM Data Structure. + * We also have to remember the length of each + * ROM Data Structure, so we can "hop" to the next + * entry if the VPD isn't in the current + * ROM Data Structure. + */ + rom_offset = readw(brd->re_map_membase + base_offset + 0x18); + image_length = readw(brd->re_map_membase + rom_offset + 0x10) * 512; + vpd_offset = readw(brd->re_map_membase + rom_offset + 0x08); + + /* Found the VPD entry */ + if (vpd_offset) + break; + + /* We didn't find a VPD entry, go to next ROM entry. */ + base_offset += image_length; + + byte1 = readb(brd->re_map_membase + base_offset); + byte2 = readb(brd->re_map_membase + base_offset + 1); + + /* + * If the new ROM offset doesn't have 0x55, 0xAA + * as its header, we have run out of ROM. + */ + if (byte1 != 0x55 || byte2 != 0xAA) + break; + } + + /* + * If we have a VPD offset, then mark the board + * as having a valid VPD, and copy VPDSIZE (512) bytes of + * that VPD to the buffer we have in our board structure. + */ + if (vpd_offset) { + brd->bd_flags |= BD_HAS_VPD; + for (i = 0; i < VPDSIZE; i++) + brd->vpd[i] = readb(brd->re_map_membase + vpd_offset + i); + } + } + + /* + * We MUST poke the magic number at the PCI Rom Address location again. + * This makes the card report the regular board memory back to us, + * rather than the OTPROM memory. + */ + magic = FEP5_ROM_MAGIC; + pci_write_config_dword(brd->pdev, PCI_ROM_ADDRESS, magic); +} + + +/* + * Our board poller function. + */ +void dgap_poll_tasklet(unsigned long data) +{ + struct board_t *bd = (struct board_t *) data; + ulong lock_flags; + ulong lock_flags2; + char *vaddr; + u16 head, tail; + u16 *chk_addr; + u16 check = 0; + + if (!bd || (bd->magic != DGAP_BOARD_MAGIC)) { + APR(("dgap_poll_tasklet() - NULL or bad bd.\n")); + return; + } + + if (bd->inhibit_poller) + return; + + DGAP_LOCK(bd->bd_lock, lock_flags); + + vaddr = bd->re_map_membase; + + /* + * If board is ready, parse deeper to see if there is anything to do. + */ + if (bd->state == BOARD_READY) { + + struct ev_t *eaddr = NULL; + + if (!bd->re_map_membase) { + DGAP_UNLOCK(bd->bd_lock, lock_flags); + return; + } + if (!bd->re_map_port) { + DGAP_UNLOCK(bd->bd_lock, lock_flags); + return; + } + + if (!bd->nasync) { + goto out; + } + + /* + * If this is a CX or EPCX, we need to see if the firmware + * is requesting a concentrator image from us. + */ + if ((bd->type == PCX) || (bd->type == PEPC)) { + chk_addr = (u16 *) (vaddr + DOWNREQ); + check = readw(chk_addr); + /* Nonzero if FEP is requesting concentrator image. */ + if (check) { + if (bd->conc_dl_status == NO_PENDING_CONCENTRATOR_REQUESTS) + bd->conc_dl_status = NEED_CONCENTRATOR; + /* + * Signal downloader, its got some work to do. + */ + DGAP_LOCK(dgap_dl_lock, lock_flags2); + if (dgap_dl_action != 1) { + dgap_dl_action = 1; + wake_up_interruptible(&dgap_dl_wait); + } + DGAP_UNLOCK(dgap_dl_lock, lock_flags2); + + } + } + + eaddr = (struct ev_t *) (vaddr + EVBUF); + + /* Get our head and tail */ + head = readw(&(eaddr->ev_head)); + tail = readw(&(eaddr->ev_tail)); + + /* + * If there is an event pending. Go service it. + */ + if (head != tail) { + DGAP_UNLOCK(bd->bd_lock, lock_flags); + dgap_event(bd); + DGAP_LOCK(bd->bd_lock, lock_flags); + } + +out: + /* + * If board is doing interrupts, ACK the interrupt. + */ + if (bd && bd->intr_running) { + readb(bd->re_map_port + 2); + } + + DGAP_UNLOCK(bd->bd_lock, lock_flags); + return; + } + + /* Our state machine to get the board up and running */ + + /* Reset board */ + if (bd->state == NEED_RESET) { + + /* Get VPD info */ + dgap_get_vpd(bd); + + dgap_do_reset_board(bd); + } + + /* Move to next state */ + if (bd->state == FINISHED_RESET) { + bd->state = NEED_CONFIG; + } + + if (bd->state == NEED_CONFIG) { + /* + * Match this board to a config the user created for us. + */ + bd->bd_config = dgap_find_config(bd->type, bd->pci_bus, bd->pci_slot); + + /* + * Because the 4 port Xr products share the same PCI ID + * as the 8 port Xr products, if we receive a NULL config + * back, and this is a PAPORT8 board, retry with a + * PAPORT4 attempt as well. + */ + if (bd->type == PAPORT8 && !bd->bd_config) { + bd->bd_config = dgap_find_config(PAPORT4, bd->pci_bus, bd->pci_slot); + } + + /* + * Register the ttys (if any) into the kernel. + */ + if (bd->bd_config) { + bd->state = FINISHED_CONFIG; + } + else { + bd->state = CONFIG_NOT_FOUND; + } + } + + /* Move to next state */ + if (bd->state == FINISHED_CONFIG) { + bd->state = NEED_DEVICE_CREATION; + } + + /* Move to next state */ + if (bd->state == NEED_DEVICE_CREATION) { + /* + * Signal downloader, its got some work to do. + */ + DGAP_LOCK(dgap_dl_lock, lock_flags2); + if (dgap_dl_action != 1) { + dgap_dl_action = 1; + wake_up_interruptible(&dgap_dl_wait); + } + DGAP_UNLOCK(dgap_dl_lock, lock_flags2); + } + + /* Move to next state */ + if (bd->state == FINISHED_DEVICE_CREATION) { + bd->state = NEED_BIOS_LOAD; + } + + /* Move to next state */ + if (bd->state == NEED_BIOS_LOAD) { + /* + * Signal downloader, its got some work to do. + */ + DGAP_LOCK(dgap_dl_lock, lock_flags2); + if (dgap_dl_action != 1) { + dgap_dl_action = 1; + wake_up_interruptible(&dgap_dl_wait); + } + DGAP_UNLOCK(dgap_dl_lock, lock_flags2); + } + + /* Wait for BIOS to test board... */ + if (bd->state == WAIT_BIOS_LOAD) { + dgap_do_wait_for_bios(bd); + } + + /* Move to next state */ + if (bd->state == FINISHED_BIOS_LOAD) { + bd->state = NEED_FEP_LOAD; + + /* + * Signal downloader, its got some work to do. + */ + DGAP_LOCK(dgap_dl_lock, lock_flags2); + if (dgap_dl_action != 1) { + dgap_dl_action = 1; + wake_up_interruptible(&dgap_dl_wait); + } + DGAP_UNLOCK(dgap_dl_lock, lock_flags2); + } + + /* Wait for FEP to load on board... */ + if (bd->state == WAIT_FEP_LOAD) { + dgap_do_wait_for_fep(bd); + } + + + /* Move to next state */ + if (bd->state == FINISHED_FEP_LOAD) { + + /* + * Do tty device initialization. + */ + int rc = dgap_tty_init(bd); + + if (rc < 0) { + dgap_tty_uninit(bd); + APR(("Can't init tty devices (%d)\n", rc)); + bd->state = BOARD_FAILED; + bd->dpastatus = BD_NOFEP; + } + else { + bd->state = NEED_PROC_CREATION; + + /* + * Signal downloader, its got some work to do. + */ + DGAP_LOCK(dgap_dl_lock, lock_flags2); + if (dgap_dl_action != 1) { + dgap_dl_action = 1; + wake_up_interruptible(&dgap_dl_wait); + } + DGAP_UNLOCK(dgap_dl_lock, lock_flags2); + } + } + + /* Move to next state */ + if (bd->state == FINISHED_PROC_CREATION) { + + bd->state = BOARD_READY; + bd->dpastatus = BD_RUNNING; + + /* + * If user requested the board to run in interrupt mode, + * go and set it up on the board. + */ + if (bd->intr_used) { + writew(1, (bd->re_map_membase + ENABLE_INTR)); + /* + * Tell the board to poll the UARTS as fast as possible. + */ + writew(FEPPOLL_MIN, (bd->re_map_membase + FEPPOLL)); + bd->intr_running = 1; + } + + /* Wake up anyone waiting for board state to change to ready */ + wake_up_interruptible(&bd->state_wait); + } + + DGAP_UNLOCK(bd->bd_lock, lock_flags); +} + + +/*======================================================================= + * + * dgap_cmdb - Sends a 2 byte command to the FEP. + * + * ch - Pointer to channel structure. + * cmd - Command to be sent. + * byte1 - Integer containing first byte to be sent. + * byte2 - Integer containing second byte to be sent. + * ncmds - Wait until ncmds or fewer cmds are left + * in the cmd buffer before returning. + * + *=======================================================================*/ +void dgap_cmdb(struct channel_t *ch, uchar cmd, uchar byte1, uchar byte2, uint ncmds) +{ + char *vaddr = NULL; + struct cm_t *cm_addr = NULL; + uint count; + uint n; + u16 head; + u16 tail; + + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return; + + /* + * Check if board is still alive. + */ + if (ch->ch_bd->state == BOARD_FAILED) { + DPR_CORE(("%s:%d board is in failed state.\n", __FILE__, __LINE__)); + return; + } + + /* + * Make sure the pointers are in range before + * writing to the FEP memory. + */ + vaddr = ch->ch_bd->re_map_membase; + + if (!vaddr) + return; + + cm_addr = (struct cm_t *) (vaddr + CMDBUF); + head = readw(&(cm_addr->cm_head)); + + /* + * Forget it if pointers out of range. + */ + if (head >= (CMDMAX - CMDSTART) || (head & 03)) { + DPR_CORE(("%s:%d pointers out of range, failing board!\n", __FILE__, __LINE__)); + ch->ch_bd->state = BOARD_FAILED; + return; + } + + /* + * Put the data in the circular command buffer. + */ + writeb(cmd, (char *) (vaddr + head + CMDSTART + 0)); + writeb((uchar) ch->ch_portnum, (char *) (vaddr + head + CMDSTART + 1)); + writeb(byte1, (char *) (vaddr + head + CMDSTART + 2)); + writeb(byte2, (char *) (vaddr + head + CMDSTART + 3)); + + head = (head + 4) & (CMDMAX - CMDSTART - 4); + + writew(head, &(cm_addr->cm_head)); + + /* + * Wait if necessary before updating the head + * pointer to limit the number of outstanding + * commands to the FEP. If the time spent waiting + * is outlandish, declare the FEP dead. + */ + for (count = dgap_count ;;) { + + head = readw(&(cm_addr->cm_head)); + tail = readw(&(cm_addr->cm_tail)); + + n = (head - tail) & (CMDMAX - CMDSTART - 4); + + if (n <= ncmds * sizeof(struct cm_t)) + break; + + if (--count == 0) { + DPR_CORE(("%s:%d failing board.\n",__FILE__, __LINE__)); + ch->ch_bd->state = BOARD_FAILED; + return; + } + udelay(10); + } +} + + +/*======================================================================= + * + * dgap_cmdw - Sends a 1 word command to the FEP. + * + * ch - Pointer to channel structure. + * cmd - Command to be sent. + * word - Integer containing word to be sent. + * ncmds - Wait until ncmds or fewer cmds are left + * in the cmd buffer before returning. + * + *=======================================================================*/ +void dgap_cmdw(struct channel_t *ch, uchar cmd, u16 word, uint ncmds) +{ + char *vaddr = NULL; + struct cm_t *cm_addr = NULL; + uint count; + uint n; + u16 head; + u16 tail; + + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return; + + /* + * Check if board is still alive. + */ + if (ch->ch_bd->state == BOARD_FAILED) { + DPR_CORE(("%s:%d board is failed!\n", __FILE__, __LINE__)); + return; + } + + /* + * Make sure the pointers are in range before + * writing to the FEP memory. + */ + vaddr = ch->ch_bd->re_map_membase; + if (!vaddr) + return; + + cm_addr = (struct cm_t *) (vaddr + CMDBUF); + head = readw(&(cm_addr->cm_head)); + + /* + * Forget it if pointers out of range. + */ + if (head >= (CMDMAX - CMDSTART) || (head & 03)) { + DPR_CORE(("%s:%d Pointers out of range. Failing board.\n",__FILE__, __LINE__)); + ch->ch_bd->state = BOARD_FAILED; + return; + } + + /* + * Put the data in the circular command buffer. + */ + writeb(cmd, (char *) (vaddr + head + CMDSTART + 0)); + writeb((uchar) ch->ch_portnum, (char *) (vaddr + head + CMDSTART + 1)); + writew((u16) word, (char *) (vaddr + head + CMDSTART + 2)); + + head = (head + 4) & (CMDMAX - CMDSTART - 4); + + writew(head, &(cm_addr->cm_head)); + + /* + * Wait if necessary before updating the head + * pointer to limit the number of outstanding + * commands to the FEP. If the time spent waiting + * is outlandish, declare the FEP dead. + */ + for (count = dgap_count ;;) { + + head = readw(&(cm_addr->cm_head)); + tail = readw(&(cm_addr->cm_tail)); + + n = (head - tail) & (CMDMAX - CMDSTART - 4); + + if (n <= ncmds * sizeof(struct cm_t)) + break; + + if (--count == 0) { + DPR_CORE(("%s:%d Failing board.\n",__FILE__, __LINE__)); + ch->ch_bd->state = BOARD_FAILED; + return; + } + udelay(10); + } +} + + + +/*======================================================================= + * + * dgap_cmdw_ext - Sends a extended word command to the FEP. + * + * ch - Pointer to channel structure. + * cmd - Command to be sent. + * word - Integer containing word to be sent. + * ncmds - Wait until ncmds or fewer cmds are left + * in the cmd buffer before returning. + * + *=======================================================================*/ +static void dgap_cmdw_ext(struct channel_t *ch, u16 cmd, u16 word, uint ncmds) +{ + char *vaddr = NULL; + struct cm_t *cm_addr = NULL; + uint count; + uint n; + u16 head; + u16 tail; + + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return; + + /* + * Check if board is still alive. + */ + if (ch->ch_bd->state == BOARD_FAILED) { + DPR_CORE(("%s:%d board is failed!\n", __FILE__, __LINE__)); + return; + } + + /* + * Make sure the pointers are in range before + * writing to the FEP memory. + */ + vaddr = ch->ch_bd->re_map_membase; + if (!vaddr) + return; + + cm_addr = (struct cm_t *) (vaddr + CMDBUF); + head = readw(&(cm_addr->cm_head)); + + /* + * Forget it if pointers out of range. + */ + if (head >= (CMDMAX - CMDSTART) || (head & 03)) { + DPR_CORE(("%s:%d Pointers out of range. Failing board.\n",__FILE__, __LINE__)); + ch->ch_bd->state = BOARD_FAILED; + return; + } + + /* + * Put the data in the circular command buffer. + */ + + /* Write an FF to tell the FEP that we want an extended command */ + writeb((uchar) 0xff, (char *) (vaddr + head + CMDSTART + 0)); + + writeb((uchar) ch->ch_portnum, (uchar *) (vaddr + head + CMDSTART + 1)); + writew((u16) cmd, (char *) (vaddr + head + CMDSTART + 2)); + + /* + * If the second part of the command won't fit, + * put it at the beginning of the circular buffer. + */ + if (((head + 4) >= ((CMDMAX - CMDSTART)) || (head & 03))) { + writew((u16) word, (char *) (vaddr + CMDSTART)); + } else { + writew((u16) word, (char *) (vaddr + head + CMDSTART + 4)); + } + + head = (head + 8) & (CMDMAX - CMDSTART - 4); + + writew(head, &(cm_addr->cm_head)); + + /* + * Wait if necessary before updating the head + * pointer to limit the number of outstanding + * commands to the FEP. If the time spent waiting + * is outlandish, declare the FEP dead. + */ + for (count = dgap_count ;;) { + + head = readw(&(cm_addr->cm_head)); + tail = readw(&(cm_addr->cm_tail)); + + n = (head - tail) & (CMDMAX - CMDSTART - 4); + + if (n <= ncmds * sizeof(struct cm_t)) + break; + + if (--count == 0) { + DPR_CORE(("%s:%d Failing board.\n",__FILE__, __LINE__)); + ch->ch_bd->state = BOARD_FAILED; + return; + } + udelay(10); + } +} + + +/*======================================================================= + * + * dgap_wmove - Write data to FEP buffer. + * + * ch - Pointer to channel structure. + * buf - Poiter to characters to be moved. + * cnt - Number of characters to move. + * + *=======================================================================*/ +void dgap_wmove(struct channel_t *ch, char *buf, uint cnt) +{ + int n; + char *taddr; + struct bs_t *bs; + u16 head; + + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return; + + /* + * Check parameters. + */ + bs = ch->ch_bs; + head = readw(&(bs->tx_head)); + + /* + * If pointers are out of range, just return. + */ + if ((cnt > ch->ch_tsize) || (unsigned)(head - ch->ch_tstart) >= ch->ch_tsize) { + DPR_CORE(("%s:%d pointer out of range", __FILE__, __LINE__)); + return; + } + + /* + * If the write wraps over the top of the circular buffer, + * move the portion up to the wrap point, and reset the + * pointers to the bottom. + */ + n = ch->ch_tstart + ch->ch_tsize - head; + + if (cnt >= n) { + cnt -= n; + taddr = ch->ch_taddr + head; + memcpy_toio(taddr, buf, n); + head = ch->ch_tstart; + buf += n; + } + + /* + * Move rest of data. + */ + taddr = ch->ch_taddr + head; + n = cnt; + memcpy_toio(taddr, buf, n); + head += cnt; + + writew(head, &(bs->tx_head)); +} + +/* + * Retrives the current custom baud rate from FEP memory, + * and returns it back to the user. + * Returns 0 on error. + */ +uint dgap_get_custom_baud(struct channel_t *ch) +{ + uchar *vaddr; + ulong offset = 0; + uint value = 0; + + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) { + return (0); + } + + if (!ch->ch_bd || ch->ch_bd->magic != DGAP_BOARD_MAGIC) { + return (0); + } + + if (!(ch->ch_bd->bd_flags & BD_FEP5PLUS)) + return (0); + + vaddr = ch->ch_bd->re_map_membase; + + if (!vaddr) + return (0); + + /* + * Go get from fep mem, what the fep + * believes the custom baud rate is. + */ + offset = ((((*(unsigned short *)(vaddr + ECS_SEG)) << 4) + + (ch->ch_portnum * 0x28) + LINE_SPEED)); + + value = readw(vaddr + offset); + return (value); +} + + +/* + * Calls the firmware to reset this channel. + */ +void dgap_firmware_reset_port(struct channel_t *ch) +{ + dgap_cmdb(ch, CHRESET, 0, 0, 0); + + /* + * Now that the channel is reset, we need to make sure + * all the current settings get reapplied to the port + * in the firmware. + * + * So we will set the driver's cache of firmware + * settings all to 0, and then call param. + */ + ch->ch_fepiflag = 0; + ch->ch_fepcflag = 0; + ch->ch_fepoflag = 0; + ch->ch_fepstartc = 0; + ch->ch_fepstopc = 0; + ch->ch_fepastartc = 0; + ch->ch_fepastopc = 0; + ch->ch_mostat = 0; + ch->ch_hflow = 0; +} + + +/*======================================================================= + * + * dgap_param - Set Digi parameters. + * + * struct tty_struct * - TTY for port. + * + *=======================================================================*/ +int dgap_param(struct tty_struct *tty) +{ + struct ktermios *ts; + struct board_t *bd; + struct channel_t *ch; + struct bs_t *bs; + struct un_t *un; + u16 head; + u16 cflag; + u16 iflag; + uchar mval; + uchar hflow; + + if (!tty || tty->magic != TTY_MAGIC) { + return (-ENXIO); + } + + un = (struct un_t *) tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) { + return (-ENXIO); + } + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) { + return (-ENXIO); + } + + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) { + return (-ENXIO); + } + + bs = ch->ch_bs; + if (bs == 0) { + return (-ENXIO); + } + + DPR_PARAM(("param start: tdev: %x cflags: %x oflags: %x iflags: %x\n", + ch->ch_tun.un_dev, ch->ch_c_cflag, ch->ch_c_oflag, ch->ch_c_iflag)); + + ts = tty->termios; + + /* + * If baud rate is zero, flush queues, and set mval to drop DTR. + */ + if ((ch->ch_c_cflag & (CBAUD)) == 0) { + + /* flush rx */ + head = readw(&(ch->ch_bs->rx_head)); + writew(head, &(ch->ch_bs->rx_tail)); + + /* flush tx */ + head = readw(&(ch->ch_bs->tx_head)); + writew(head, &(ch->ch_bs->tx_tail)); + + ch->ch_flags |= (CH_BAUD0); + + /* Drop RTS and DTR */ + ch->ch_mval &= ~(D_RTS(ch)|D_DTR(ch)); + mval = D_DTR(ch) | D_RTS(ch); + ch->ch_baud_info = 0; + + } else if (ch->ch_custom_speed && (bd->bd_flags & BD_FEP5PLUS)) { + /* + * Tell the fep to do the command + */ + + DPR_PARAM(("param: Want %d speed\n", ch->ch_custom_speed)); + + dgap_cmdw_ext(ch, 0xff01, ch->ch_custom_speed, 0); + + /* + * Now go get from fep mem, what the fep + * believes the custom baud rate is. + */ + ch->ch_baud_info = ch->ch_custom_speed = dgap_get_custom_baud(ch); + + DPR_PARAM(("param: Got %d speed\n", ch->ch_custom_speed)); + + /* Handle transition from B0 */ + if (ch->ch_flags & CH_BAUD0) { + ch->ch_flags &= ~(CH_BAUD0); + ch->ch_mval |= (D_RTS(ch)|D_DTR(ch)); + } + mval = D_DTR(ch) | D_RTS(ch); + + } else { + /* + * Set baud rate, character size, and parity. + */ + + + int iindex = 0; + int jindex = 0; + int baud = 0; + + ulong bauds[4][16] = { + { /* slowbaud */ + 0, 50, 75, 110, + 134, 150, 200, 300, + 600, 1200, 1800, 2400, + 4800, 9600, 19200, 38400 }, + { /* slowbaud & CBAUDEX */ + 0, 57600, 115200, 230400, + 460800, 150, 200, 921600, + 600, 1200, 1800, 2400, + 4800, 9600, 19200, 38400 }, + { /* fastbaud */ + 0, 57600, 76800, 115200, + 14400, 57600, 230400, 76800, + 115200, 230400, 28800, 460800, + 921600, 9600, 19200, 38400 }, + { /* fastbaud & CBAUDEX */ + 0, 57600, 115200, 230400, + 460800, 150, 200, 921600, + 600, 1200, 1800, 2400, + 4800, 9600, 19200, 38400 } + }; + + /* Only use the TXPrint baud rate if the terminal unit is NOT open */ + if (!(ch->ch_tun.un_flags & UN_ISOPEN) && (un->un_type == DGAP_PRINT)) + baud = C_BAUD(ch->ch_pun.un_tty) & 0xff; + else + baud = C_BAUD(ch->ch_tun.un_tty) & 0xff; + + if (ch->ch_c_cflag & CBAUDEX) + iindex = 1; + + if (ch->ch_digi.digi_flags & DIGI_FAST) + iindex += 2; + + jindex = baud; + + if ((iindex >= 0) && (iindex < 4) && (jindex >= 0) && (jindex < 16)) { + baud = bauds[iindex][jindex]; + } else { + DPR_IOCTL(("baud indices were out of range (%d)(%d)", + iindex, jindex)); + baud = 0; + } + + if (baud == 0) + baud = 9600; + + ch->ch_baud_info = baud; + + + /* + * CBAUD has bit position 0x1000 set these days to indicate Linux + * baud rate remap. + * We use a different bit assignment for high speed. Clear this + * bit out while grabbing the parts of "cflag" we want. + */ + cflag = ch->ch_c_cflag & ((CBAUD ^ CBAUDEX) | PARODD | PARENB | CSTOPB | CSIZE); + + /* + * HUPCL bit is used by FEP to indicate fast baud + * table is to be used. + */ + if ((ch->ch_digi.digi_flags & DIGI_FAST) || (ch->ch_c_cflag & CBAUDEX)) + cflag |= HUPCL; + + + if ((ch->ch_c_cflag & CBAUDEX) && !(ch->ch_digi.digi_flags & DIGI_FAST)) { + /* + * The below code is trying to guarantee that only baud rates + * 115200, 230400, 460800, 921600 are remapped. We use exclusive or + * because the various baud rates share common bit positions + * and therefore can't be tested for easily. + */ + tcflag_t tcflag = (ch->ch_c_cflag & CBAUD) | CBAUDEX; + int baudpart = 0; + + /* Map high speed requests to index into FEP's baud table */ + switch (tcflag) { + case B57600 : + baudpart = 1; + break; +#ifdef B76800 + case B76800 : + baudpart = 2; + break; +#endif + case B115200 : + baudpart = 3; + break; + case B230400 : + baudpart = 9; + break; + case B460800 : + baudpart = 11; + break; +#ifdef B921600 + case B921600 : + baudpart = 12; + break; +#endif + default: + baudpart = 0; + } + + if (baudpart) + cflag = (cflag & ~(CBAUD | CBAUDEX)) | baudpart; + } + + cflag &= 0xffff; + + if (cflag != ch->ch_fepcflag) { + ch->ch_fepcflag = (u16) (cflag & 0xffff); + + /* Okay to have channel and board locks held calling this */ + dgap_cmdw(ch, SCFLAG, (u16) cflag, 0); + } + + /* Handle transition from B0 */ + if (ch->ch_flags & CH_BAUD0) { + ch->ch_flags &= ~(CH_BAUD0); + ch->ch_mval |= (D_RTS(ch)|D_DTR(ch)); + } + mval = D_DTR(ch) | D_RTS(ch); + } + + /* + * Get input flags. + */ + iflag = ch->ch_c_iflag & (IGNBRK | BRKINT | IGNPAR | PARMRK | INPCK | ISTRIP | IXON | IXANY | IXOFF); + + if ((ch->ch_startc == _POSIX_VDISABLE) || (ch->ch_stopc == _POSIX_VDISABLE)) { + iflag &= ~(IXON | IXOFF); + ch->ch_c_iflag &= ~(IXON | IXOFF); + } + + /* + * Only the IBM Xr card can switch between + * 232 and 422 modes on the fly + */ + if (bd->device == PCI_DEVICE_XR_IBM_DID) { + if (ch->ch_digi.digi_flags & DIGI_422) + dgap_cmdb(ch, SCOMMODE, MODE_422, 0, 0); + else + dgap_cmdb(ch, SCOMMODE, MODE_232, 0, 0); + } + + if (ch->ch_digi.digi_flags & DIGI_ALTPIN) + iflag |= IALTPIN ; + + if (iflag != ch->ch_fepiflag) { + ch->ch_fepiflag = iflag; + + /* Okay to have channel and board locks held calling this */ + dgap_cmdw(ch, SIFLAG, (u16) ch->ch_fepiflag, 0); + } + + /* + * Select hardware handshaking. + */ + hflow = 0; + + if (ch->ch_c_cflag & CRTSCTS) { + hflow |= (D_RTS(ch) | D_CTS(ch)); + } + if (ch->ch_digi.digi_flags & RTSPACE) + hflow |= D_RTS(ch); + if (ch->ch_digi.digi_flags & DTRPACE) + hflow |= D_DTR(ch); + if (ch->ch_digi.digi_flags & CTSPACE) + hflow |= D_CTS(ch); + if (ch->ch_digi.digi_flags & DSRPACE) + hflow |= D_DSR(ch); + if (ch->ch_digi.digi_flags & DCDPACE) + hflow |= D_CD(ch); + + if (hflow != ch->ch_hflow) { + ch->ch_hflow = hflow; + + /* Okay to have channel and board locks held calling this */ + dgap_cmdb(ch, SHFLOW, (uchar) hflow, 0xff, 0); + } + + + /* + * Set RTS and/or DTR Toggle if needed, but only if product is FEP5+ based. + */ + if (bd->bd_flags & BD_FEP5PLUS) { + u16 hflow2 = 0; + if (ch->ch_digi.digi_flags & DIGI_RTS_TOGGLE) { + hflow2 |= (D_RTS(ch)); + } + if (ch->ch_digi.digi_flags & DIGI_DTR_TOGGLE) { + hflow2 |= (D_DTR(ch)); + } + + dgap_cmdw_ext(ch, 0xff03, hflow2, 0); + } + + /* + * Set modem control lines. + */ + + mval ^= ch->ch_mforce & (mval ^ ch->ch_mval); + + DPR_PARAM(("dgap_param: mval: %x ch_mforce: %x ch_mval: %x ch_mostat: %x\n", + mval, ch->ch_mforce, ch->ch_mval, ch->ch_mostat)); + + if (ch->ch_mostat ^ mval) { + ch->ch_mostat = mval; + + /* Okay to have channel and board locks held calling this */ + DPR_PARAM(("dgap_param: Sending SMODEM mval: %x\n", mval)); + dgap_cmdb(ch, SMODEM, (uchar) mval, D_RTS(ch)|D_DTR(ch), 0); + } + + /* + * Read modem signals, and then call carrier function. + */ + ch->ch_mistat = readb(&(bs->m_stat)); + dgap_carrier(ch); + + /* + * Set the start and stop characters. + */ + if (ch->ch_startc != ch->ch_fepstartc || ch->ch_stopc != ch->ch_fepstopc) { + ch->ch_fepstartc = ch->ch_startc; + ch->ch_fepstopc = ch->ch_stopc; + + /* Okay to have channel and board locks held calling this */ + dgap_cmdb(ch, SFLOWC, ch->ch_fepstartc, ch->ch_fepstopc, 0); + } + + /* + * Set the Auxiliary start and stop characters. + */ + if (ch->ch_astartc != ch->ch_fepastartc || ch->ch_astopc != ch->ch_fepastopc) { + ch->ch_fepastartc = ch->ch_astartc; + ch->ch_fepastopc = ch->ch_astopc; + + /* Okay to have channel and board locks held calling this */ + dgap_cmdb(ch, SAFLOWC, ch->ch_fepastartc, ch->ch_fepastopc, 0); + } + + DPR_PARAM(("param finish\n")); + + return (0); +} + + +/* + * dgap_parity_scan() + * + * Convert the FEP5 way of reporting parity errors and breaks into + * the Linux line discipline way. + */ +void dgap_parity_scan(struct channel_t *ch, unsigned char *cbuf, unsigned char *fbuf, int *len) +{ + int l = *len; + int count = 0; + unsigned char *in, *cout, *fout; + unsigned char c; + + in = cbuf; + cout = cbuf; + fout = fbuf; + + DPR_PSCAN(("dgap_parity_scan start\n")); + + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return; + + while (l--) { + c = *in++; + switch (ch->pscan_state) { + default: + /* reset to sanity and fall through */ + ch->pscan_state = 0; + + case 0: + /* No FF seen yet */ + if (c == (unsigned char) '\377') { + /* delete this character from stream */ + ch->pscan_state = 1; + } else { + *cout++ = c; + *fout++ = TTY_NORMAL; + count += 1; + } + break; + + case 1: + /* first FF seen */ + if (c == (unsigned char) '\377') { + /* doubled ff, transform to single ff */ + *cout++ = c; + *fout++ = TTY_NORMAL; + count += 1; + ch->pscan_state = 0; + } else { + /* save value examination in next state */ + ch->pscan_savechar = c; + ch->pscan_state = 2; + } + break; + + case 2: + /* third character of ff sequence */ + + *cout++ = c; + + if (ch->pscan_savechar == 0x0) { + + if (c == 0x0) { + DPR_PSCAN(("dgap_parity_scan in 3rd char of ff seq. c: %x setting break.\n", c)); + ch->ch_err_break++; + *fout++ = TTY_BREAK; + } + else { + DPR_PSCAN(("dgap_parity_scan in 3rd char of ff seq. c: %x setting parity.\n", c)); + ch->ch_err_parity++; + *fout++ = TTY_PARITY; + } + } + else { + DPR_PSCAN(("%s:%d Logic Error.\n", __FILE__, __LINE__)); + } + + count += 1; + ch->pscan_state = 0; + } + } + *len = count; + DPR_PSCAN(("dgap_parity_scan finish\n")); +} + + + + +/*======================================================================= + * + * dgap_event - FEP to host event processing routine. + * + * bd - Board of current event. + * + *=======================================================================*/ +static int dgap_event(struct board_t *bd) +{ + struct channel_t *ch; + ulong lock_flags; + ulong lock_flags2; + struct bs_t *bs; + uchar *event; + uchar *vaddr = NULL; + struct ev_t *eaddr = NULL; + uint head; + uint tail; + int port; + int reason; + int modem; + int b1; + + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return (-ENXIO); + + DGAP_LOCK(bd->bd_lock, lock_flags); + + vaddr = bd->re_map_membase; + + if (!vaddr) { + DGAP_UNLOCK(bd->bd_lock, lock_flags); + return (-ENXIO); + } + + eaddr = (struct ev_t *) (vaddr + EVBUF); + + /* Get our head and tail */ + head = readw(&(eaddr->ev_head)); + tail = readw(&(eaddr->ev_tail)); + + /* + * Forget it if pointers out of range. + */ + + if (head >= EVMAX - EVSTART || tail >= EVMAX - EVSTART || + (head | tail) & 03) { + DPR_EVENT(("should be calling xxfail %d\n", __LINE__)); + /* Let go of board lock */ + DGAP_UNLOCK(bd->bd_lock, lock_flags); + return (-ENXIO); + } + + /* + * Loop to process all the events in the buffer. + */ + while (tail != head) { + + /* + * Get interrupt information. + */ + + event = bd->re_map_membase + tail + EVSTART; + + port = event[0]; + reason = event[1]; + modem = event[2]; + b1 = event[3]; + + DPR_EVENT(("event: jiffies: %ld port: %d reason: %x modem: %x\n", + jiffies, port, reason, modem)); + + /* + * Make sure the interrupt is valid. + */ + if ( port >= bd->nasync) { + goto next; + } + + if (!(reason & (IFMODEM | IFBREAK | IFTLW | IFTEM | IFDATA))) { + goto next; + } + + ch = bd->channels[port]; + + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) { + goto next; + } + + /* + * If we have made it here, the event was valid. + * Lock down the channel. + */ + DGAP_LOCK(ch->ch_lock, lock_flags2); + + bs = ch->ch_bs; + + if (!bs) { + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + goto next; + } + + /* + * Process received data. + */ + if (reason & IFDATA) { + + /* + * ALL LOCKS *MUST* BE DROPPED BEFORE CALLING INPUT! + * input could send some data to ld, which in turn + * could do a callback to one of our other functions. + */ + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + dgap_input(ch); + + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + + if (ch->ch_flags & CH_RACTIVE) + ch->ch_flags |= CH_RENABLE; + else + writeb(1, &(bs->idata)); + + if (ch->ch_flags & CH_RWAIT) { + ch->ch_flags &= ~CH_RWAIT; + + wake_up_interruptible(&ch->ch_tun.un_flags_wait); + } + } + + /* + * Process Modem change signals. + */ + if (reason & IFMODEM) { + ch->ch_mistat = modem; + dgap_carrier(ch); + } + + /* + * Process break. + */ + if (reason & IFBREAK) { + + DPR_EVENT(("got IFBREAK\n")); + + if (ch->ch_tun.un_tty) { + /* A break has been indicated */ + ch->ch_err_break++; + tty_buffer_request_room(ch->ch_tun.un_tty, 1); + tty_insert_flip_char(ch->ch_tun.un_tty, 0, TTY_BREAK); + tty_flip_buffer_push(ch->ch_tun.un_tty); + } + } + + /* + * Process Transmit low. + */ + if (reason & IFTLW) { + + DPR_EVENT(("event: got low event\n")); + + if (ch->ch_tun.un_flags & UN_LOW) { + ch->ch_tun.un_flags &= ~UN_LOW; + + if (ch->ch_tun.un_flags & UN_ISOPEN) { + if ((ch->ch_tun.un_tty->flags & + (1 << TTY_DO_WRITE_WAKEUP)) && +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31) + ch->ch_tun.un_tty->ldisc->ops->write_wakeup) +#else + ch->ch_tun.un_tty->ldisc.ops->write_wakeup) +#endif + { + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31) + (ch->ch_tun.un_tty->ldisc->ops->write_wakeup)(ch->ch_tun.un_tty); +#else + (ch->ch_tun.un_tty->ldisc.ops->write_wakeup)(ch->ch_tun.un_tty); +#endif + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + } + wake_up_interruptible(&ch->ch_tun.un_tty->write_wait); + wake_up_interruptible(&ch->ch_tun.un_flags_wait); + + DPR_EVENT(("event: Got low event. jiffies: %lu\n", jiffies)); + } + } + + if (ch->ch_pun.un_flags & UN_LOW) { + ch->ch_pun.un_flags &= ~UN_LOW; + if (ch->ch_pun.un_flags & UN_ISOPEN) { + if ((ch->ch_pun.un_tty->flags & + (1 << TTY_DO_WRITE_WAKEUP)) && +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31) + ch->ch_pun.un_tty->ldisc->ops->write_wakeup) +#else + ch->ch_pun.un_tty->ldisc.ops->write_wakeup) +#endif + { + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31) + (ch->ch_pun.un_tty->ldisc->ops->write_wakeup)(ch->ch_pun.un_tty); +#else + (ch->ch_pun.un_tty->ldisc.ops->write_wakeup)(ch->ch_pun.un_tty); +#endif + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + } + wake_up_interruptible(&ch->ch_pun.un_tty->write_wait); + wake_up_interruptible(&ch->ch_pun.un_flags_wait); + } + } + + if (ch->ch_flags & CH_WLOW) { + ch->ch_flags &= ~CH_WLOW; + wake_up_interruptible(&ch->ch_flags_wait); + } + } + + /* + * Process Transmit empty. + */ + if (reason & IFTEM) { + DPR_EVENT(("event: got empty event\n")); + + if (ch->ch_tun.un_flags & UN_EMPTY) { + ch->ch_tun.un_flags &= ~UN_EMPTY; + if (ch->ch_tun.un_flags & UN_ISOPEN) { + if ((ch->ch_tun.un_tty->flags & + (1 << TTY_DO_WRITE_WAKEUP)) && +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31) + ch->ch_tun.un_tty->ldisc->ops->write_wakeup) +#else + ch->ch_tun.un_tty->ldisc.ops->write_wakeup) +#endif + { + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31) + (ch->ch_tun.un_tty->ldisc->ops->write_wakeup)(ch->ch_tun.un_tty); +#else + (ch->ch_tun.un_tty->ldisc.ops->write_wakeup)(ch->ch_tun.un_tty); +#endif + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + } + wake_up_interruptible(&ch->ch_tun.un_tty->write_wait); + wake_up_interruptible(&ch->ch_tun.un_flags_wait); + } + } + + if (ch->ch_pun.un_flags & UN_EMPTY) { + ch->ch_pun.un_flags &= ~UN_EMPTY; + if (ch->ch_pun.un_flags & UN_ISOPEN) { + if ((ch->ch_pun.un_tty->flags & + (1 << TTY_DO_WRITE_WAKEUP)) && +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31) + ch->ch_pun.un_tty->ldisc->ops->write_wakeup) +#else + ch->ch_pun.un_tty->ldisc.ops->write_wakeup) +#endif + { + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31) + (ch->ch_pun.un_tty->ldisc->ops->write_wakeup)(ch->ch_pun.un_tty); +#else + (ch->ch_pun.un_tty->ldisc.ops->write_wakeup)(ch->ch_pun.un_tty); +#endif + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + } + wake_up_interruptible(&ch->ch_pun.un_tty->write_wait); + wake_up_interruptible(&ch->ch_pun.un_flags_wait); + } + } + + + if (ch->ch_flags & CH_WEMPTY) { + ch->ch_flags &= ~CH_WEMPTY; + wake_up_interruptible(&ch->ch_flags_wait); + } + } + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + +next: + tail = (tail + 4) & (EVMAX - EVSTART - 4); + } + + writew(tail, &(eaddr->ev_tail)); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + return (0); +} diff --git a/drivers/staging/dgap/dgap_fep5.h b/drivers/staging/dgap/dgap_fep5.h new file mode 100644 index 0000000000000..3a12ba5e3c2ad --- /dev/null +++ b/drivers/staging/dgap/dgap_fep5.h @@ -0,0 +1,253 @@ +/* + * Copyright 2003 Digi International (www.digi.com) + * Scott H Kilau + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! + * + ************************************************************************ + *** FEP Version 5 dependent definitions + ************************************************************************/ + +#ifndef __DGAP_FEP5_H +#define __DGAP_FEP5_H + +/************************************************************************ + * FEP memory offsets + ************************************************************************/ +#define START 0x0004L /* Execution start address */ + +#define CMDBUF 0x0d10L /* Command (cm_t) structure offset */ +#define CMDSTART 0x0400L /* Start of command buffer */ +#define CMDMAX 0x0800L /* End of command buffer */ + +#define EVBUF 0x0d18L /* Event (ev_t) structure */ +#define EVSTART 0x0800L /* Start of event buffer */ +#define EVMAX 0x0c00L /* End of event buffer */ +#define FEP5_PLUS 0x0E40 /* ASCII '5' and ASCII 'A' is here */ +#define ECS_SEG 0x0E44 /* Segment of the extended channel structure */ +#define LINE_SPEED 0x10 /* Offset into ECS_SEG for line speed */ + /* if the fep has extended capabilities */ + +/* BIOS MAGIC SPOTS */ +#define ERROR 0x0C14L /* BIOS error code */ +#define SEQUENCE 0x0C12L /* BIOS sequence indicator */ +#define POSTAREA 0x0C00L /* POST complete message area */ + +/* FEP MAGIC SPOTS */ +#define FEPSTAT POSTAREA /* OS here when FEP comes up */ +#define NCHAN 0x0C02L /* number of ports FEP sees */ +#define PANIC 0x0C10L /* PANIC area for FEP */ +#define KMEMEM 0x0C30L /* Memory for KME use */ +#define CONFIG 0x0CD0L /* Concentrator configuration info */ +#define CONFIGSIZE 0x0030 /* configuration info size */ +#define DOWNREQ 0x0D00 /* Download request buffer pointer */ + +#define CHANBUF 0x1000L /* Async channel (bs_t) structs */ +#define FEPOSSIZE 0x1FFF /* 8K FEPOS */ + +#define XEMPORTS 0xC02 /* + * Offset in board memory where FEP5 stores + * how many ports it has detected. + * NOTE: FEP5 reports 64 ports when the user + * has the cable in EBI OUT instead of EBI IN. + */ + +#define FEPCLR 0x00 +#define FEPMEM 0x02 +#define FEPRST 0x04 +#define FEPINT 0x08 +#define FEPMASK 0x0e +#define FEPWIN 0x80 + +#define LOWMEM 0x0100 +#define HIGHMEM 0x7f00 + +#define FEPTIMEOUT 200000 + +#define ENABLE_INTR 0x0e04 /* Enable interrupts flag */ +#define FEPPOLL_MIN 1 /* minimum of 1 millisecond */ +#define FEPPOLL_MAX 20 /* maximum of 20 milliseconds */ +#define FEPPOLL 0x0c26 /* Fep event poll interval */ + +#define IALTPIN 0x0080 /* Input flag to swap DSR <-> DCD */ + +/************************************************************************ + * Command structure definition. + ************************************************************************/ +struct cm_t { + volatile unsigned short cm_head; /* Command buffer head offset */ + volatile unsigned short cm_tail; /* Command buffer tail offset */ + volatile unsigned short cm_start; /* start offset of buffer */ + volatile unsigned short cm_max; /* last offset of buffer */ +}; + +/************************************************************************ + * Event structure definition. + ************************************************************************/ +struct ev_t { + volatile unsigned short ev_head; /* Command buffer head offset */ + volatile unsigned short ev_tail; /* Command buffer tail offset */ + volatile unsigned short ev_start; /* start offset of buffer */ + volatile unsigned short ev_max; /* last offset of buffer */ +}; + +/************************************************************************ + * Download buffer structure. + ************************************************************************/ +struct downld_t { + uchar dl_type; /* Header */ + uchar dl_seq; /* Download sequence */ + ushort dl_srev; /* Software revision number */ + ushort dl_lrev; /* Low revision number */ + ushort dl_hrev; /* High revision number */ + ushort dl_seg; /* Start segment address */ + ushort dl_size; /* Number of bytes to download */ + uchar dl_data[1024]; /* Download data */ +}; + +/************************************************************************ + * Per channel buffer structure + ************************************************************************ + * Base Structure Entries Usage Meanings to Host * + * * + * W = read write R = read only * + * C = changed by commands only * + * U = unknown (may be changed w/o notice) * + ************************************************************************/ +struct bs_t { + volatile unsigned short tp_jmp; /* Transmit poll jump */ + volatile unsigned short tc_jmp; /* Cooked procedure jump */ + volatile unsigned short ri_jmp; /* Not currently used */ + volatile unsigned short rp_jmp; /* Receive poll jump */ + + volatile unsigned short tx_seg; /* W Tx segment */ + volatile unsigned short tx_head; /* W Tx buffer head offset */ + volatile unsigned short tx_tail; /* R Tx buffer tail offset */ + volatile unsigned short tx_max; /* W Tx buffer size - 1 */ + + volatile unsigned short rx_seg; /* W Rx segment */ + volatile unsigned short rx_head; /* W Rx buffer head offset */ + volatile unsigned short rx_tail; /* R Rx buffer tail offset */ + volatile unsigned short rx_max; /* W Rx buffer size - 1 */ + + volatile unsigned short tx_lw; /* W Tx buffer low water mark */ + volatile unsigned short rx_lw; /* W Rx buffer low water mark */ + volatile unsigned short rx_hw; /* W Rx buffer high water mark */ + volatile unsigned short incr; /* W Increment to next channel */ + + volatile unsigned short fepdev; /* U SCC device base address */ + volatile unsigned short edelay; /* W Exception delay */ + volatile unsigned short blen; /* W Break length */ + volatile unsigned short btime; /* U Break complete time */ + + volatile unsigned short iflag; /* C UNIX input flags */ + volatile unsigned short oflag; /* C UNIX output flags */ + volatile unsigned short cflag; /* C UNIX control flags */ + volatile unsigned short wfill[13]; /* U Reserved for expansion */ + + volatile unsigned char num; /* U Channel number */ + volatile unsigned char ract; /* U Receiver active counter */ + volatile unsigned char bstat; /* U Break status bits */ + volatile unsigned char tbusy; /* W Transmit busy */ + volatile unsigned char iempty; /* W Transmit empty event enable */ + volatile unsigned char ilow; /* W Transmit low-water event enable */ + volatile unsigned char idata; /* W Receive data interrupt enable */ + volatile unsigned char eflag; /* U Host event flags */ + + volatile unsigned char tflag; /* U Transmit flags */ + volatile unsigned char rflag; /* U Receive flags */ + volatile unsigned char xmask; /* U Transmit ready flags */ + volatile unsigned char xval; /* U Transmit ready value */ + volatile unsigned char m_stat; /* RC Modem status bits */ + volatile unsigned char m_change; /* U Modem bits which changed */ + volatile unsigned char m_int; /* W Modem interrupt enable bits */ + volatile unsigned char m_last; /* U Last modem status */ + + volatile unsigned char mtran; /* C Unreported modem trans */ + volatile unsigned char orun; /* C Buffer overrun occurred */ + volatile unsigned char astartc; /* W Auxiliary Xon char */ + volatile unsigned char astopc; /* W Auxiliary Xoff char */ + volatile unsigned char startc; /* W Xon character */ + volatile unsigned char stopc; /* W Xoff character */ + volatile unsigned char vnextc; /* W Vnext character */ + volatile unsigned char hflow; /* C Software flow control */ + + volatile unsigned char fillc; /* U Delay Fill character */ + volatile unsigned char ochar; /* U Saved output character */ + volatile unsigned char omask; /* U Output character mask */ + + volatile unsigned char bfill[13]; /* U Reserved for expansion */ + + volatile unsigned char scc[16]; /* U SCC registers */ +}; + + +/************************************************************************ + * FEP supported functions + ************************************************************************/ +#define SRLOW 0xe0 /* Set receive low water */ +#define SRHIGH 0xe1 /* Set receive high water */ +#define FLUSHTX 0xe2 /* Flush transmit buffer */ +#define PAUSETX 0xe3 /* Pause data transmission */ +#define RESUMETX 0xe4 /* Resume data transmission */ +#define SMINT 0xe5 /* Set Modem Interrupt */ +#define SAFLOWC 0xe6 /* Set Aux. flow control chars */ +#define SBREAK 0xe8 /* Send break */ +#define SMODEM 0xe9 /* Set 8530 modem control lines */ +#define SIFLAG 0xea /* Set UNIX iflags */ +#define SFLOWC 0xeb /* Set flow control characters */ +#define STLOW 0xec /* Set transmit low water mark */ +#define RPAUSE 0xee /* Pause recieve */ +#define RRESUME 0xef /* Resume receive */ +#define CHRESET 0xf0 /* Reset Channel */ +#define BUFSETALL 0xf2 /* Set Tx & Rx buffer size avail*/ +#define SOFLAG 0xf3 /* Set UNIX oflags */ +#define SHFLOW 0xf4 /* Set hardware handshake */ +#define SCFLAG 0xf5 /* Set UNIX cflags */ +#define SVNEXT 0xf6 /* Set VNEXT character */ +#define SPINTFC 0xfc /* Reserved */ +#define SCOMMODE 0xfd /* Set RS232/422 mode */ + + +/************************************************************************ + * Modes for SCOMMODE + ************************************************************************/ +#define MODE_232 0x00 +#define MODE_422 0x01 + + +/************************************************************************ + * Event flags. + ************************************************************************/ +#define IFBREAK 0x01 /* Break received */ +#define IFTLW 0x02 /* Transmit low water */ +#define IFTEM 0x04 /* Transmitter empty */ +#define IFDATA 0x08 /* Receive data present */ +#define IFMODEM 0x20 /* Modem status change */ + +/************************************************************************ + * Modem flags + ************************************************************************/ +# define DM_RTS 0x02 /* Request to send */ +# define DM_CD 0x80 /* Carrier detect */ +# define DM_DSR 0x20 /* Data set ready */ +# define DM_CTS 0x10 /* Clear to send */ +# define DM_RI 0x40 /* Ring indicator */ +# define DM_DTR 0x01 /* Data terminal ready */ + + +#endif diff --git a/drivers/staging/dgap/dgap_kcompat.h b/drivers/staging/dgap/dgap_kcompat.h new file mode 100644 index 0000000000000..8ebf4b7373b74 --- /dev/null +++ b/drivers/staging/dgap/dgap_kcompat.h @@ -0,0 +1,93 @@ +/* + * Copyright 2004 Digi International (www.digi.com) + * Scott H Kilau + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! + * + ************************************************************************* + * + * This file is intended to contain all the kernel "differences" between the + * various kernels that we support. + * + *************************************************************************/ + +#ifndef __DGAP_KCOMPAT_H +#define __DGAP_KCOMPAT_H + +# ifndef KERNEL_VERSION +# define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) +# endif + + +#if !defined(TTY_FLIPBUF_SIZE) +# define TTY_FLIPBUF_SIZE 512 +#endif + + +/* Sparse stuff */ +# ifndef __user +# define __user +# define __kernel +# define __safe +# define __force +# define __chk_user_ptr(x) (void)0 +# endif + + +# define PARM_STR(VAR, INIT, PERM, DESC) \ + static char *VAR = INIT; \ + char *dgap_##VAR; \ + module_param(VAR, charp, PERM); \ + MODULE_PARM_DESC(VAR, DESC); + +# define PARM_INT(VAR, INIT, PERM, DESC) \ + static int VAR = INIT; \ + int dgap_##VAR; \ + module_param(VAR, int, PERM); \ + MODULE_PARM_DESC(VAR, DESC); + +# define PARM_ULONG(VAR, INIT, PERM, DESC) \ + static ulong VAR = INIT; \ + ulong dgap_##VAR; \ + module_param(VAR, long, PERM); \ + MODULE_PARM_DESC(VAR, DESC); + + + + + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) + + + + +/* NOTHING YET */ + + + + +# else + + + +# error "this driver does not support anything below the 2.6.27 kernel series." + + + +# endif + +#endif /* ! __DGAP_KCOMPAT_H */ diff --git a/drivers/staging/dgap/dgap_mgmt.c b/drivers/staging/dgap/dgap_mgmt.c new file mode 100644 index 0000000000000..00624816d2526 --- /dev/null +++ b/drivers/staging/dgap/dgap_mgmt.c @@ -0,0 +1,768 @@ +/* + * Copyright 2003 Digi International (www.digi.com) + * Scott H Kilau + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * + * NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE! + * + * This is shared code between Digi's CVS archive and the + * Linux Kernel sources. + * Changing the source just for reformatting needlessly breaks + * our CVS diff history. + * + * Send any bug fixes/changes to: Eng.Linux at digi dot com. + * Thank you. + * + */ + +/************************************************************************ + * + * This file implements the mgmt functionality for the + * FEP5 based product lines. + * + ************************************************************************ + * $Id: dgap_mgmt.c,v 1.2 2010/12/13 19:38:04 markh Exp $ + */ + +#include +#include +#include +#include /* For jiffies, task states */ +#include /* For tasklet and interrupt structs/defines */ +#include +#include +#include +#include /* For copy_from_user/copy_to_user */ +#include /* For read[bwl]/write[bwl] */ + +#include "dgap_driver.h" +#include "dgap_kcompat.h" /* Kernel 2.4/2.6 compat includes */ +#include "dgap_fep5.h" +#include "dgap_parse.h" +#include "dgap_mgmt.h" +#include "dgap_downld.h" +#include "dgap_tty.h" +#include "dgap_proc.h" +#include "dgap_sysfs.h" + + +/* This holds the status of the KME buffer */ +static int dgap_kmebusy = 0; + +/* Our "in use" variables, to enforce 1 open only */ +static int dgap_mgmt_in_use = 0; +static int dgap_downld_in_use = 0; + + +/* + * dgap_mgmt_open() + * + * Open the mgmt/downld/dpa device + */ +int dgap_mgmt_open(struct inode *inode, struct file *file) +{ + unsigned long lock_flags; + unsigned int minor = iminor(inode); + + DPR_MGMT(("dgap_mgmt_open start.\n")); + + DGAP_LOCK(dgap_global_lock, lock_flags); + + /* mgmt device */ + if (minor == MGMT_MGMT) { + /* Only allow 1 open at a time on mgmt device */ + if (dgap_mgmt_in_use) { + DGAP_UNLOCK(dgap_global_lock, lock_flags); + return (-EBUSY); + } + dgap_mgmt_in_use++; + } + /* downld device */ + else if (minor == MGMT_DOWNLD) { + /* Only allow 1 open at a time on downld device */ + if (dgap_downld_in_use) { + DGAP_UNLOCK(dgap_global_lock, lock_flags); + return (-EBUSY); + } + dgap_downld_in_use++; + } + else { + DGAP_UNLOCK(dgap_global_lock, lock_flags); + return (-ENXIO); + } + + DGAP_UNLOCK(dgap_global_lock, lock_flags); + + DPR_MGMT(("dgap_mgmt_open finish.\n")); + + return 0; +} + +/* + * dgap_mgmt_close() + * + * Open the mgmt/dpa device + */ +int dgap_mgmt_close(struct inode *inode, struct file *file) +{ + unsigned long lock_flags; + unsigned int minor = iminor(inode); + + DPR_MGMT(("dgap_mgmt_close start.\n")); + + DGAP_LOCK(dgap_global_lock, lock_flags); + + /* mgmt device */ + if (minor == MGMT_MGMT) { + if (dgap_mgmt_in_use) { + dgap_mgmt_in_use = 0; + } + } + /* downld device */ + else if (minor == MGMT_DOWNLD) { + if (dgap_downld_in_use) { + dgap_downld_in_use = 0; + } + } + + DGAP_UNLOCK(dgap_global_lock, lock_flags); + + DPR_MGMT(("dgap_mgmt_close finish.\n")); + + return 0; +} + + +/* + * dgap_mgmt_ioctl() + * + * ioctl the mgmt/dpa device + */ +#ifdef HAVE_UNLOCKED_IOCTL +long dgap_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +{ + struct inode *inode = file->f_dentry->d_inode; +#else +int dgap_mgmt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) +{ +#endif + unsigned long lock_flags; + int error = 0; + int i = 0; + int j = 0; + struct board_t *brd; + struct channel_t *ch; + static struct downldio dlio; + void __user *uarg = (void __user *) arg; + + DPR_MGMT(("dgap_mgmt_ioctl start.\n")); + + switch (cmd) { + + /* HiJack the usage of SEDELAY to turn on/off debugging. */ + case DIGI_SEDELAY: + { + unsigned int value = 0; + + if (copy_from_user((unsigned int *) &value, uarg, sizeof(unsigned int))) { + return (-EFAULT); + } + + printk("Setting debug of value: %x\n", value); + dgap_debug = value; + return 0; + } + + case DIGI_DLREQ_GET: + { + +get_service: + + DGAP_LOCK(dgap_global_lock, lock_flags); + + if (dgap_driver_state == DRIVER_NEED_CONFIG_LOAD) { + + dgap_driver_state = DRIVER_REQUESTED_CONFIG; + + dlio.req_type = DLREQ_CONFIG; + dlio.bdid = 0; + dlio.image.fi.type = 0; + + DGAP_UNLOCK(dgap_global_lock, lock_flags); + + if (copy_to_user(uarg, &dlio, sizeof(struct downldio))) { + DGAP_LOCK(dgap_global_lock, lock_flags); + dgap_driver_state = DRIVER_NEED_CONFIG_LOAD; + DGAP_UNLOCK(dgap_global_lock, lock_flags); + return(-EFAULT); + } + + return(0); + } + + DGAP_UNLOCK(dgap_global_lock, lock_flags); + + /* + * Loop thru each board. + * Check state, force state machine to start running. + */ + for (i = 0; i < dgap_NumBoards; i++ ) { + + brd = dgap_Board[i]; + + DGAP_LOCK(brd->bd_lock, lock_flags); + + switch (brd->state) { + + case NEED_DEVICE_CREATION: + + /* + * Let go of lock, tty_register() (and us also) + * does a non-atomic malloc, so it would be + * possible to deadlock the system if the + * malloc went to sleep. + */ + DGAP_UNLOCK(brd->bd_lock, lock_flags); + dgap_tty_register(brd); + dgap_finalize_board_init(brd); + DGAP_LOCK(brd->bd_lock, lock_flags); + + brd->state = REQUESTED_DEVICE_CREATION; + + dlio.req_type = DLREQ_DEVCREATE; + dlio.bdid = i; + dlio.image.fi.type = brd->dpatype; + + DGAP_UNLOCK(brd->bd_lock, lock_flags); + + if (copy_to_user(uarg, &dlio, sizeof(struct downldio))) { + DGAP_LOCK(brd->bd_lock, lock_flags); + brd->state = NEED_DEVICE_CREATION; + DGAP_UNLOCK(brd->bd_lock, lock_flags); + return(-EFAULT); + } + + return(0); + + case NEED_BIOS_LOAD: + + brd->state = REQUESTED_BIOS; + + dlio.req_type = DLREQ_BIOS; + dlio.bdid = i; + dlio.image.fi.type = brd->dpatype; + + DGAP_UNLOCK(brd->bd_lock, lock_flags); + if (copy_to_user(uarg, &dlio, sizeof(struct downldio))) { + DGAP_LOCK(brd->bd_lock, lock_flags); + brd->state = NEED_BIOS_LOAD; + DGAP_UNLOCK(brd->bd_lock, lock_flags); + return(-EFAULT); + } + + return(0); + + case NEED_FEP_LOAD: + brd->state = REQUESTED_FEP; + + dlio.req_type = DLREQ_FEP; + dlio.bdid = i; + dlio.image.fi.type = brd->dpatype; + + DGAP_UNLOCK(brd->bd_lock, lock_flags); + + if (copy_to_user(uarg, &dlio, sizeof(struct downldio))) { + DGAP_LOCK(brd->bd_lock, lock_flags); + brd->state = NEED_FEP_LOAD; + DGAP_UNLOCK(brd->bd_lock, lock_flags); + return(-EFAULT); + } + return(0); + + case NEED_PROC_CREATION: + + DGAP_UNLOCK(brd->bd_lock, lock_flags); + dgap_proc_register_channel_postscan(brd->boardnum); + + ch = brd->channels[0]; + for (j = 0; j < brd->nasync; j++, ch = brd->channels[j]) { + struct device *classp; + classp = + tty_register_device(brd->SerialDriver, j, + &(ch->ch_bd->pdev->dev)); + ch->ch_tun.un_sysfs = classp; + dgap_create_tty_sysfs(&ch->ch_tun, classp); + + classp = + tty_register_device(brd->PrintDriver, j, + &(ch->ch_bd->pdev->dev)); + ch->ch_pun.un_sysfs = classp; + dgap_create_tty_sysfs(&ch->ch_pun, classp); + } + dgap_create_ports_sysfiles(brd); + + DGAP_LOCK(brd->bd_lock, lock_flags); + brd->state = FINISHED_PROC_CREATION; + DGAP_UNLOCK(brd->bd_lock, lock_flags); + break; + + default: + DGAP_UNLOCK(brd->bd_lock, lock_flags); + break; + + } + + DGAP_LOCK(brd->bd_lock, lock_flags); + + switch (brd->conc_dl_status) { + + case NEED_CONCENTRATOR: + { + u16 offset = 0; + char *vaddr; + struct downld_t *to_dp; + + vaddr = brd->re_map_membase; + if (!vaddr) { + brd->conc_dl_status = NO_PENDING_CONCENTRATOR_REQUESTS; + DGAP_UNLOCK(brd->bd_lock, lock_flags); + break; + } + + dlio.req_type = DLREQ_CONC; + dlio.bdid = i; + + offset = readw((u16 *) (vaddr + DOWNREQ)); + to_dp = (struct downld_t *) (vaddr + (int) offset); + + if (!to_dp) { + brd->conc_dl_status = NO_PENDING_CONCENTRATOR_REQUESTS; + DGAP_UNLOCK(brd->bd_lock, lock_flags); + break; + } + + memcpy(&dlio.image.dl, to_dp, sizeof(struct downld_t)); + + brd->conc_dl_status = REQUESTED_CONCENTRATOR; + + DGAP_UNLOCK(brd->bd_lock, lock_flags); + + if (copy_to_user(uarg, &dlio, sizeof(struct downldio))) { + DGAP_LOCK(brd->bd_lock, lock_flags); + brd->conc_dl_status = NEED_CONCENTRATOR; + DGAP_UNLOCK(brd->bd_lock, lock_flags); + return(-EFAULT); + } + + return(0); + } + + default: + DGAP_UNLOCK(brd->bd_lock, lock_flags); + break; + } + } + + /* + * Go to sleep waiting for the driver to signal an event to us. + */ + error = wait_event_interruptible(dgap_dl_wait, (dgap_dl_action)); + + DGAP_LOCK(dgap_dl_lock, lock_flags); + dgap_dl_action = 0; + DGAP_UNLOCK(dgap_dl_lock, lock_flags); + + /* Break out of ioctl if user cancelled us */ + if (error) + break; + + goto get_service; + + } + + case DIGI_DLREQ_SET: + { + uchar __user *uaddr = NULL; + uchar *uaddr2 = NULL; + + if (copy_from_user((char *) &dlio, uarg, sizeof(struct downldio))) { + return (-EFAULT); + } + + if (dlio.req_type == DLREQ_CONFIG) { + + uaddr = uarg + + (int) ( ((struct downldio *)0)->image.fi.fepimage); + + dgap_do_config_load(uaddr, dlio.image.fi.len); + dgap_after_config_loaded(); + + DGAP_LOCK(dgap_global_lock, lock_flags); + dgap_driver_state = DRIVER_READY; + DGAP_UNLOCK(dgap_global_lock, lock_flags); + + break; + + } + + if (dlio.bdid < 0 || dlio.bdid > dgap_NumBoards) { + return(-ENXIO); + } + + brd = dgap_Board[dlio.bdid]; + + switch(dlio.req_type) { + + case DLREQ_BIOS: + if (brd->state == BOARD_FAILED || brd->state == BOARD_READY) { + break; + } + + if (dlio.image.fi.type == -1) { + DGAP_LOCK(brd->bd_lock, lock_flags); + brd->state = BOARD_FAILED; + brd->dpastatus = BD_NOBIOS; + DGAP_UNLOCK(brd->bd_lock, lock_flags); + break; + } + + + uaddr = uarg + + (int) ( ((struct downldio *)0)->image.fi.fepimage); + + dgap_do_bios_load(brd, uaddr, dlio.image.fi.len); + + break; + case DLREQ_FEP: + if (brd->state == BOARD_FAILED || brd->state == BOARD_READY) { + break; + } + + if (dlio.image.fi.type == -1) { + DGAP_LOCK(brd->bd_lock, lock_flags); + brd->state = BOARD_FAILED; + brd->dpastatus = BD_NOBIOS; + DGAP_UNLOCK(brd->bd_lock, lock_flags); + break; + } + + uaddr = uarg + + (int) ( ((struct downldio *)0)->image.fi.fepimage); + + dgap_do_fep_load(brd, uaddr, dlio.image.fi.len); + + break; + + case DLREQ_CONC: + + if (brd->state == BOARD_FAILED) { + break; + } + + if (dlio.image.fi.type == -1) { + break; + } + + uaddr2 = (char *) &dlio.image.dl; + dgap_do_conc_load(brd, uaddr2, sizeof(struct downld_t)); + + break; + + case DLREQ_DEVCREATE: + if (brd->state == BOARD_FAILED || brd->state == BOARD_READY) { + break; + } + + DGAP_LOCK(brd->bd_lock, lock_flags); + brd->state = FINISHED_DEVICE_CREATION; + DGAP_UNLOCK(brd->bd_lock, lock_flags); + + break; + + } + + break; + } + + + case DIGI_GETDD: + { + /* + * This returns the total number of boards + * in the system, as well as driver version + * and has space for a reserved entry + */ + struct digi_dinfo ddi; + + DGAP_LOCK(dgap_global_lock, lock_flags); + + ddi.dinfo_nboards = dgap_NumBoards; + sprintf(ddi.dinfo_version, "%s", DG_PART); + + DGAP_UNLOCK(dgap_global_lock, lock_flags); + + DPR_MGMT(("DIGI_GETDD returning numboards: %lu version: %s\n", + ddi.dinfo_nboards, ddi.dinfo_version)); + + if (copy_to_user(uarg, &ddi, sizeof(ddi))) + return(-EFAULT); + + break; + } + + case DIGI_GETBD: + { + int brd2; + struct digi_info di; + + if (copy_from_user(&brd2, uarg, sizeof(int))) { + return(-EFAULT); + } + + DPR_MGMT(("DIGI_GETBD asking about board: %d\n", brd2)); + + if ((brd2 < 0) || (brd2 > dgap_NumBoards) || (dgap_NumBoards == 0)) + return (-ENODEV); + + memset(&di, 0, sizeof(di)); + + di.info_bdnum = brd2; + + DGAP_LOCK(dgap_Board[brd2]->bd_lock, lock_flags); + + di.info_bdtype = dgap_Board[brd2]->dpatype; + di.info_bdstate = dgap_Board[brd2]->dpastatus; + di.info_ioport = (ulong) dgap_Board[brd2]->port; + di.info_physaddr = (ulong) dgap_Board[brd2]->membase; + di.info_physsize = (ulong) dgap_Board[brd2]->membase - dgap_Board[brd2]->membase_end; + if (dgap_Board[brd2]->state != BOARD_FAILED) + di.info_nports = dgap_Board[brd2]->nasync; + else + di.info_nports = 0; + + DGAP_UNLOCK(dgap_Board[brd2]->bd_lock, lock_flags); + + DPR_MGMT(("DIGI_GETBD returning type: %x state: %x ports: %x size: %lx\n", + di.info_bdtype, di.info_bdstate, di.info_nports, di.info_physsize)); + + if (copy_to_user(uarg, &di, sizeof (di))) + return(-EFAULT); + + break; + } + + case DIGI_KME: + { + int itmp, jtmp; + unchar *memaddr = NULL; + struct rw_t kme; + struct rw_t *mp = NULL; + int brd2 = 0; + struct board_t *bd; + + /* This ioctl takes an argument of type 'rw_t' + * and uses it to interact with the KME struct + * located on the digiboard itself. + */ + if (copy_from_user(&kme, uarg, sizeof(kme))) + return(-EFAULT); + + if (kme.rw_size > 128) + kme.rw_size = 128; + + brd2 = kme.rw_board; + + DPR_MGMT(("dgap_mgmt: DIGI_KME: %s asked for board %d\n", current->comm, brd2)); + + /* Sanity Checking... */ + if ((brd2 < 0) || (brd2 > dgap_NumBoards) || (dgap_NumBoards == 0)) + return (-ENODEV); + + bd = dgap_Board[brd2]; + + DGAP_LOCK(dgap_Board[brd2]->bd_lock, lock_flags); + + if (bd->state != BOARD_READY) { + DGAP_UNLOCK(dgap_Board[brd2]->bd_lock, lock_flags); + return(-ENODEV); + } + + memaddr = bd->re_map_membase; + + DGAP_UNLOCK(dgap_Board[brd2]->bd_lock, lock_flags); + + /* If the concentrator number is 0... */ + if (kme.rw_conc == 0 && kme.rw_addr < 0x100000) { + int page = 0; + int addr = kme.rw_addr; + int size = kme.rw_size; + caddr_t data = (caddr_t) kme.rw_data; + + while ((itmp = size)) { + + switch (kme.rw_req) { + case RW_READ: + { + register caddr_t cp1 = (char *)memaddr + addr; + register caddr_t cp2 = kme.rw_data; + + DPR_MGMT(("RW_READ CARDMEM - page=%d rw_addr=0x%lx rw_size=%x\n", + page, kme.rw_addr, kme.rw_size)); + + for (jtmp = 0; jtmp < itmp; jtmp++) { + *cp2++ = readb(cp1++); + } + } + + break; + + case RW_WRITE: + { + register caddr_t cp1 = memaddr + addr; + register caddr_t cp2 = data; + + DPR_MGMT(("RW_WRITE CARDMEM - page=%d rw_addr=0x%lx rw_size=%d\n", + page, kme.rw_addr, kme.rw_size)); + + for (jtmp = 0; jtmp < itmp; jtmp++) { + writeb(*cp2++, cp1++); + } + } + break; + } + + addr += itmp; + data += itmp; + size -= itmp; + + } + + } + else { + + /* + * Read/Write memory in a REMOTE CONCENTRATOR.. + * There is only 1 buffer, so do mutual + * exclusion to make sure only one KME + * request is pending... + */ + + mp = (struct rw_t *) (memaddr + KMEMEM); + + while (dgap_kmebusy != 0) { + dgap_kmebusy = 2; + error = wait_event_interruptible(bd->kme_wait, (!dgap_kmebusy)); + if (error) + goto endkme; + } + + dgap_kmebusy = 1; + + /* Copy KME request to the board.. */ + + mp->rw_board = kme.rw_board; + mp->rw_conc = kme.rw_conc; + mp->rw_reserved = kme.rw_reserved; + memcpy(&mp->rw_addr, &kme.rw_addr, sizeof(int)); + memcpy(&mp->rw_size, &kme.rw_size, sizeof(short)); + + if(kme.rw_req == RW_WRITE) { + register caddr_t cp1 = (caddr_t) mp->rw_data; + register caddr_t cp2 = (caddr_t) kme.rw_data; + + DPR_MGMT(("RW_WRITE CONCMEM - rw_addr=0x%lx rw_size=%d\n", + kme.rw_addr, kme.rw_size)); + + for (jtmp = 0; jtmp < (int) kme.rw_size; jtmp++) { + writeb(*cp2++, cp1++); + } + } + + /* EXECUTE REQUEST */ + + mp->rw_req = kme.rw_req; + + /* + * Wait for the board to process the + * request, but limit the wait to 2 secs + */ + + for (itmp = jiffies + (2 * HZ); mp->rw_req;) { + if(jiffies >= itmp) { + error = ENXIO; + /* Set request back to 0.. */ + mp->rw_req = 0; + goto endkme; + } + + schedule_timeout(HZ / 10); + } + + /* + * Since this portion of code is looksee + * ported from the HPUX EMUX code, i'm + * leaving OUT a portion of that code where + * the HP/UX code actually puts the process + * to sleep for some reason + */ + if (mp->rw_size < kme.rw_size) + memcpy(&kme.rw_size, &mp->rw_size, sizeof(short)); + + /* Copy the READ data back to the source buffer... */ + if (kme.rw_req == RW_READ) { + register caddr_t cp1 = (caddr_t) mp->rw_data; + register caddr_t cp2 = (caddr_t) kme.rw_data; + + DPR_MGMT(("RW_READ CONCMEM - rw_addr=0x%lx rw_size=%d\n", + kme.rw_addr, kme.rw_size)); + + for (jtmp = 0; jtmp < (int) kme.rw_size; jtmp++) { + *cp2++ = readb(cp1++); + } + } + + /* + * Common exit point for code sharing the + * kme buffer. Before exiting, always wake + * another process waiting for the buffer + */ + + endkme: + + if (dgap_kmebusy != 1) + wake_up_interruptible(&bd->kme_wait); + dgap_kmebusy = 0; + if (error == ENXIO) + return(-EINVAL); + } + + /* Copy the whole (Possibly Modified) mess */ + /* back out to user space... */ + + if (!error) { + if (copy_to_user(uarg, &kme, sizeof(kme))) + return (-EFAULT); + + return(0); + } + } + } + + DPR_MGMT(("dgap_mgmt_ioctl finish.\n")); + + return 0; +} diff --git a/drivers/staging/dgap/dgap_mgmt.h b/drivers/staging/dgap/dgap_mgmt.h new file mode 100644 index 0000000000000..69e760314db75 --- /dev/null +++ b/drivers/staging/dgap/dgap_mgmt.h @@ -0,0 +1,38 @@ +/* + * Copyright 2003 Digi International (www.digi.com) + * Scott H Kilau + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! + */ + +#ifndef __DGAP_MGMT_H +#define __DGAP_MGMT_H + +#define MGMT_MGMT 0 +#define MGMT_DOWNLD 1 + +int dgap_mgmt_open(struct inode *inode, struct file *file); +int dgap_mgmt_close(struct inode *inode, struct file *file); + +#ifdef HAVE_UNLOCKED_IOCTL +long dgap_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg); +#else +int dgap_mgmt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg); +#endif + +#endif + diff --git a/drivers/staging/dgap/dgap_parse.c b/drivers/staging/dgap/dgap_parse.c new file mode 100644 index 0000000000000..d6d507bb05a4e --- /dev/null +++ b/drivers/staging/dgap/dgap_parse.c @@ -0,0 +1,1372 @@ +/* + * Copyright 2003 Digi International (www.digi.com) + * Scott H Kilau + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * + * NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE! + * + * This is shared code between Digi's CVS archive and the + * Linux Kernel sources. + * Changing the source just for reformatting needlessly breaks + * our CVS diff history. + * + * Send any bug fixes/changes to: Eng.Linux at digi dot com. + * Thank you. + * + * + ***************************************************************************** + * + * dgap_parse.c - Parses the configuration information from the input file. + * + * $Id: dgap_parse.c,v 1.1 2009/10/23 14:01:57 markh Exp $ + * + */ +#include +#include +#include +#include + +#include "dgap_types.h" +#include "dgap_fep5.h" +#include "dgap_driver.h" +#include "dgap_conf.h" + + +/* + * Function prototypes. + */ +static int dgap_gettok(char **in, struct cnode *p); +static char *dgap_getword(char **in); +static char *dgap_savestring(char *s); +static struct cnode *dgap_newnode(int t); +static int dgap_checknode(struct cnode *p); +static void dgap_err(char *s); + +/* + * Our needed internal static variables... + */ +static struct cnode dgap_head; +#define MAXCWORD 200 +static char dgap_cword[MAXCWORD]; + +struct toklist { + int token; + char *string; +}; + +static struct toklist dgap_tlist[] = { + { BEGIN, "config_begin" }, + { END, "config_end" }, + { BOARD, "board" }, + { PCX, "Digi_AccelePort_C/X_PCI" }, /* C/X_PCI */ + { PEPC, "Digi_AccelePort_EPC/X_PCI" }, /* EPC/X_PCI */ + { PPCM, "Digi_AccelePort_Xem_PCI" }, /* PCI/Xem */ + { APORT2_920P, "Digi_AccelePort_2r_920_PCI" }, + { APORT4_920P, "Digi_AccelePort_4r_920_PCI" }, + { APORT8_920P, "Digi_AccelePort_8r_920_PCI" }, + { PAPORT4, "Digi_AccelePort_4r_PCI(EIA-232/RS-422)" }, + { PAPORT8, "Digi_AccelePort_8r_PCI(EIA-232/RS-422)" }, + { IO, "io" }, + { PCIINFO, "pciinfo" }, + { LINE, "line" }, + { CONC, "conc" }, + { CONC, "concentrator" }, + { CX, "cx" }, + { CX, "ccon" }, + { EPC, "epccon" }, + { EPC, "epc" }, + { MOD, "module" }, + { ID, "id" }, + { STARTO, "start" }, + { SPEED, "speed" }, + { CABLE, "cable" }, + { CONNECT, "connect" }, + { METHOD, "method" }, + { STATUS, "status" }, + { CUSTOM, "Custom" }, + { BASIC, "Basic" }, + { MEM, "mem" }, + { MEM, "memory" }, + { PORTS, "ports" }, + { MODEM, "modem" }, + { NPORTS, "nports" }, + { TTYN, "ttyname" }, + { CU, "cuname" }, + { PRINT, "prname" }, + { CMAJOR, "major" }, + { ALTPIN, "altpin" }, + { USEINTR, "useintr" }, + { TTSIZ, "ttysize" }, + { CHSIZ, "chsize" }, + { BSSIZ, "boardsize" }, + { UNTSIZ, "schedsize" }, + { F2SIZ, "f2200size" }, + { VPSIZ, "vpixsize" }, + { 0, NULL } +}; + + +/* + * Parse a configuration file read into memory as a string. + */ +int dgap_parsefile(char **in, int Remove) +{ + struct cnode *p, *brd, *line, *conc; + int rc; + char *s = NULL, *s2 = NULL; + int linecnt = 0; + + p = &dgap_head; + brd = line = conc = NULL; + + /* perhaps we are adding to an existing list? */ + while (p->next != NULL) { + p = p->next; + } + + /* file must start with a BEGIN */ + while ( (rc = dgap_gettok(in,p)) != BEGIN ) { + if (rc == 0) { + dgap_err("unexpected EOF"); + return(-1); + } + } + + for (; ; ) { + rc = dgap_gettok(in,p); + if (rc == 0) { + dgap_err("unexpected EOF"); + return(-1); + } + + switch (rc) { + case 0: + dgap_err("unexpected end of file"); + return(-1); + + case BEGIN: /* should only be 1 begin */ + dgap_err("unexpected config_begin\n"); + return(-1); + + case END: + return(0); + + case BOARD: /* board info */ + if (dgap_checknode(p)) + return(-1); + if ( (p->next = dgap_newnode(BNODE)) == NULL ) { + dgap_err("out of memory"); + return(-1); + } + p = p->next; + + p->u.board.status = dgap_savestring("No"); + line = conc = NULL; + brd = p; + linecnt = -1; + break; + + case APORT2_920P: /* AccelePort_4 */ + if (p->type != BNODE) { + dgap_err("unexpected Digi_2r_920 string"); + return(-1); + } + p->u.board.type = APORT2_920P; + p->u.board.v_type = 1; + DPR_INIT(("Adding Digi_2r_920 PCI to config...\n")); + break; + + case APORT4_920P: /* AccelePort_4 */ + if (p->type != BNODE) { + dgap_err("unexpected Digi_4r_920 string"); + return(-1); + } + p->u.board.type = APORT4_920P; + p->u.board.v_type = 1; + DPR_INIT(("Adding Digi_4r_920 PCI to config...\n")); + break; + + case APORT8_920P: /* AccelePort_8 */ + if (p->type != BNODE) { + dgap_err("unexpected Digi_8r_920 string"); + return(-1); + } + p->u.board.type = APORT8_920P; + p->u.board.v_type = 1; + DPR_INIT(("Adding Digi_8r_920 PCI to config...\n")); + break; + + case PAPORT4: /* AccelePort_4 PCI */ + if (p->type != BNODE) { + dgap_err("unexpected Digi_4r(PCI) string"); + return(-1); + } + p->u.board.type = PAPORT4; + p->u.board.v_type = 1; + DPR_INIT(("Adding Digi_4r PCI to config...\n")); + break; + + case PAPORT8: /* AccelePort_8 PCI */ + if (p->type != BNODE) { + dgap_err("unexpected Digi_8r string"); + return(-1); + } + p->u.board.type = PAPORT8; + p->u.board.v_type = 1; + DPR_INIT(("Adding Digi_8r PCI to config...\n")); + break; + + case PCX: /* PCI C/X */ + if (p->type != BNODE) { + dgap_err("unexpected Digi_C/X_(PCI) string"); + return(-1); + } + p->u.board.type = PCX; + p->u.board.v_type = 1; + p->u.board.conc1 = 0; + p->u.board.conc2 = 0; + p->u.board.module1 = 0; + p->u.board.module2 = 0; + DPR_INIT(("Adding PCI C/X to config...\n")); + break; + + case PEPC: /* PCI EPC/X */ + if (p->type != BNODE) { + dgap_err("unexpected \"Digi_EPC/X_(PCI)\" string"); + return(-1); + } + p->u.board.type = PEPC; + p->u.board.v_type = 1; + p->u.board.conc1 = 0; + p->u.board.conc2 = 0; + p->u.board.module1 = 0; + p->u.board.module2 = 0; + DPR_INIT(("Adding PCI EPC/X to config...\n")); + break; + + case PPCM: /* PCI/Xem */ + if (p->type != BNODE) { + dgap_err("unexpected PCI/Xem string"); + return(-1); + } + p->u.board.type = PPCM; + p->u.board.v_type = 1; + p->u.board.conc1 = 0; + p->u.board.conc2 = 0; + DPR_INIT(("Adding PCI XEM to config...\n")); + break; + + case IO: /* i/o port */ + if (p->type != BNODE) { + dgap_err("IO port only vaild for boards"); + return(-1); + } + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.board.portstr = dgap_savestring(s); + p->u.board.port = (short)simple_strtol(s, &s2, 0); + if ((short)strlen(s) > (short)(s2 - s)) { + dgap_err("bad number for IO port"); + return(-1); + } + p->u.board.v_port = 1; + DPR_INIT(("Adding IO (%s) to config...\n", s)); + break; + + case MEM: /* memory address */ + if (p->type != BNODE) { + dgap_err("memory address only vaild for boards"); + return(-1); + } + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.board.addrstr = dgap_savestring(s); + p->u.board.addr = simple_strtoul(s, &s2, 0); + if ((int)strlen(s) > (int)(s2 - s)) { + dgap_err("bad number for memory address"); + return(-1); + } + p->u.board.v_addr = 1; + DPR_INIT(("Adding MEM (%s) to config...\n", s)); + break; + + case PCIINFO: /* pci information */ + if (p->type != BNODE) { + dgap_err("memory address only vaild for boards"); + return(-1); + } + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.board.pcibusstr = dgap_savestring(s); + p->u.board.pcibus = simple_strtoul(s, &s2, 0); + if ((int)strlen(s) > (int)(s2 - s)) { + dgap_err("bad number for pci bus"); + return(-1); + } + p->u.board.v_pcibus = 1; + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.board.pcislotstr = dgap_savestring(s); + p->u.board.pcislot = simple_strtoul(s, &s2, 0); + if ((int)strlen(s) > (int)(s2 - s)) { + dgap_err("bad number for pci slot"); + return(-1); + } + p->u.board.v_pcislot = 1; + + DPR_INIT(("Adding PCIINFO (%s %s) to config...\n", p->u.board.pcibusstr, + p->u.board.pcislotstr)); + break; + + case METHOD: + if (p->type != BNODE) { + dgap_err("install method only vaild for boards"); + return(-1); + } + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.board.method = dgap_savestring(s); + p->u.board.v_method = 1; + DPR_INIT(("Adding METHOD (%s) to config...\n", s)); + break; + + case STATUS: + if (p->type != BNODE) { + dgap_err("config status only vaild for boards"); + return(-1); + } + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.board.status = dgap_savestring(s); + DPR_INIT(("Adding STATUS (%s) to config...\n", s)); + break; + + case NPORTS: /* number of ports */ + if (p->type == BNODE) { + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.board.nport = (char)simple_strtol(s, &s2, 0); + if ((int)strlen(s) > (int)(s2 - s)) { + dgap_err("bad number for number of ports"); + return(-1); + } + p->u.board.v_nport = 1; + } else if (p->type == CNODE) { + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.conc.nport = (char)simple_strtol(s, &s2, 0); + if ((int)strlen(s) > (int)(s2 - s)) { + dgap_err("bad number for number of ports"); + return(-1); + } + p->u.conc.v_nport = 1; + } else if (p->type == MNODE) { + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.module.nport = (char)simple_strtol(s, &s2, 0); + if ((int)strlen(s) > (int)(s2 - s)) { + dgap_err("bad number for number of ports"); + return(-1); + } + p->u.module.v_nport = 1; + } else { + dgap_err("nports only valid for concentrators or modules"); + return(-1); + } + DPR_INIT(("Adding NPORTS (%s) to config...\n", s)); + break; + + case ID: /* letter ID used in tty name */ + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + + p->u.board.status = dgap_savestring(s); + + if (p->type == CNODE) { + p->u.conc.id = dgap_savestring(s); + p->u.conc.v_id = 1; + } else if (p->type == MNODE) { + p->u.module.id = dgap_savestring(s); + p->u.module.v_id = 1; + } else { + dgap_err("id only valid for concentrators or modules"); + return(-1); + } + DPR_INIT(("Adding ID (%s) to config...\n", s)); + break; + + case STARTO: /* start offset of ID */ + if (p->type == BNODE) { + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.board.start = simple_strtol(s, &s2, 0); + if ((int)strlen(s) > (int)(s2 - s)) { + dgap_err("bad number for start of tty count"); + return(-1); + } + p->u.board.v_start = 1; + } else if (p->type == CNODE) { + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.conc.start = simple_strtol(s, &s2, 0); + if ((int)strlen(s) > (int)(s2 - s)) { + dgap_err("bad number for start of tty count"); + return(-1); + } + p->u.conc.v_start = 1; + } else if (p->type == MNODE) { + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.module.start = simple_strtol(s, &s2, 0); + if ((int)strlen(s) > (int)(s2 - s)) { + dgap_err("bad number for start of tty count"); + return(-1); + } + p->u.module.v_start = 1; + } else { + dgap_err("start only valid for concentrators or modules"); + return(-1); + } + DPR_INIT(("Adding START (%s) to config...\n", s)); + break; + + case TTYN: /* tty name prefix */ + if (dgap_checknode(p)) + return(-1); + if ( (p->next = dgap_newnode(TNODE)) == NULL ) { + dgap_err("out of memory"); + return(-1); + } + p = p->next; + if ( (s = dgap_getword(in)) == NULL ) { + dgap_err("unexpeced end of file"); + return(-1); + } + if ( (p->u.ttyname = dgap_savestring(s)) == NULL ) { + dgap_err("out of memory"); + return(-1); + } + DPR_INIT(("Adding TTY (%s) to config...\n", s)); + break; + + case CU: /* cu name prefix */ + if (dgap_checknode(p)) + return(-1); + if ( (p->next = dgap_newnode(CUNODE)) == NULL ) { + dgap_err("out of memory"); + return(-1); + } + p = p->next; + if ( (s = dgap_getword(in)) == NULL ) { + dgap_err("unexpeced end of file"); + return(-1); + } + if ( (p->u.cuname = dgap_savestring(s)) == NULL ) { + dgap_err("out of memory"); + return(-1); + } + DPR_INIT(("Adding CU (%s) to config...\n", s)); + break; + + case LINE: /* line information */ + if (dgap_checknode(p)) + return(-1); + if (brd == NULL) { + dgap_err("must specify board before line info"); + return(-1); + } + switch (brd->u.board.type) { + case PPCM: + dgap_err("line not vaild for PC/em"); + return(-1); + } + if ( (p->next = dgap_newnode(LNODE)) == NULL ) { + dgap_err("out of memory"); + return(-1); + } + p = p->next; + conc = NULL; + line = p; + linecnt++; + DPR_INIT(("Adding LINE to config...\n")); + break; + + case CONC: /* concentrator information */ + if (dgap_checknode(p)) + return(-1); + if (line == NULL) { + dgap_err("must specify line info before concentrator"); + return(-1); + } + if ( (p->next = dgap_newnode(CNODE)) == NULL ) { + dgap_err("out of memory"); + return(-1); + } + p = p->next; + conc = p; + if (linecnt) + brd->u.board.conc2++; + else + brd->u.board.conc1++; + + DPR_INIT(("Adding CONC to config...\n")); + break; + + case CX: /* c/x type concentrator */ + if (p->type != CNODE) { + dgap_err("cx only valid for concentrators"); + return(-1); + } + p->u.conc.type = CX; + p->u.conc.v_type = 1; + DPR_INIT(("Adding CX to config...\n")); + break; + + case EPC: /* epc type concentrator */ + if (p->type != CNODE) { + dgap_err("cx only valid for concentrators"); + return(-1); + } + p->u.conc.type = EPC; + p->u.conc.v_type = 1; + DPR_INIT(("Adding EPC to config...\n")); + break; + + case MOD: /* EBI module */ + if (dgap_checknode(p)) + return(-1); + if (brd == NULL) { + dgap_err("must specify board info before EBI modules"); + return(-1); + } + switch (brd->u.board.type) { + case PPCM: + linecnt = 0; + break; + default: + if (conc == NULL) { + dgap_err("must specify concentrator info before EBI module"); + return(-1); + } + } + if ( (p->next = dgap_newnode(MNODE)) == NULL ) { + dgap_err("out of memory"); + return(-1); + } + p = p->next; + if (linecnt) + brd->u.board.module2++; + else + brd->u.board.module1++; + + DPR_INIT(("Adding MOD to config...\n")); + break; + + case PORTS: /* ports type EBI module */ + if (p->type != MNODE) { + dgap_err("ports only valid for EBI modules"); + return(-1); + } + p->u.module.type = PORTS; + p->u.module.v_type = 1; + DPR_INIT(("Adding PORTS to config...\n")); + break; + + case MODEM: /* ports type EBI module */ + if (p->type != MNODE) { + dgap_err("modem only valid for modem modules"); + return(-1); + } + p->u.module.type = MODEM; + p->u.module.v_type = 1; + DPR_INIT(("Adding MODEM to config...\n")); + break; + + case CABLE: + if (p->type == LNODE) { + if ((s = dgap_getword(in)) == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.line.cable = dgap_savestring(s); + p->u.line.v_cable = 1; + } + DPR_INIT(("Adding CABLE (%s) to config...\n", s)); + break; + + case SPEED: /* sync line speed indication */ + if (p->type == LNODE) { + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.line.speed = (char)simple_strtol(s, &s2, 0); + if ((short)strlen(s) > (short)(s2 - s)) { + dgap_err("bad number for line speed"); + return(-1); + } + p->u.line.v_speed = 1; + } else if (p->type == CNODE) { + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.conc.speed = (char)simple_strtol(s, &s2, 0); + if ((short)strlen(s) > (short)(s2 - s)) { + dgap_err("bad number for line speed"); + return(-1); + } + p->u.conc.v_speed = 1; + } else { + dgap_err("speed valid only for lines or concentrators."); + return(-1); + } + DPR_INIT(("Adding SPEED (%s) to config...\n", s)); + break; + + case CONNECT: + if (p->type == CNODE) { + if ((s = dgap_getword(in)) == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.conc.connect = dgap_savestring(s); + p->u.conc.v_connect = 1; + } + DPR_INIT(("Adding CONNECT (%s) to config...\n", s)); + break; + case PRINT: /* transparent print name prefix */ + if (dgap_checknode(p)) + return(-1); + if ( (p->next = dgap_newnode(PNODE)) == NULL ) { + dgap_err("out of memory"); + return(-1); + } + p = p->next; + if ( (s = dgap_getword(in)) == NULL ) { + dgap_err("unexpeced end of file"); + return(-1); + } + if ( (p->u.printname = dgap_savestring(s)) == NULL ) { + dgap_err("out of memory"); + return(-1); + } + DPR_INIT(("Adding PRINT (%s) to config...\n", s)); + break; + + case CMAJOR: /* major number */ + if (dgap_checknode(p)) + return(-1); + if ( (p->next = dgap_newnode(JNODE)) == NULL ) { + dgap_err("out of memory"); + return(-1); + } + p = p->next; + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.majornumber = simple_strtol(s, &s2, 0); + if ((int)strlen(s) > (int)(s2 - s)) { + dgap_err("bad number for major number"); + return(-1); + } + DPR_INIT(("Adding CMAJOR (%s) to config...\n", s)); + break; + + case ALTPIN: /* altpin setting */ + if (dgap_checknode(p)) + return(-1); + if ( (p->next = dgap_newnode(ANODE)) == NULL ) { + dgap_err("out of memory"); + return(-1); + } + p = p->next; + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.altpin = simple_strtol(s, &s2, 0); + if ((int)strlen(s) > (int)(s2 - s)) { + dgap_err("bad number for altpin"); + return(-1); + } + DPR_INIT(("Adding ALTPIN (%s) to config...\n", s)); + break; + + case USEINTR: /* enable interrupt setting */ + if (dgap_checknode(p)) + return(-1); + if ( (p->next = dgap_newnode(INTRNODE)) == NULL ) { + dgap_err("out of memory"); + return(-1); + } + p = p->next; + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.useintr = simple_strtol(s, &s2, 0); + if ((int)strlen(s) > (int)(s2 - s)) { + dgap_err("bad number for useintr"); + return(-1); + } + DPR_INIT(("Adding USEINTR (%s) to config...\n", s)); + break; + + case TTSIZ: /* size of tty structure */ + if (dgap_checknode(p)) + return(-1); + if ( (p->next = dgap_newnode(TSNODE)) == NULL ) { + dgap_err("out of memory"); + return(-1); + } + p = p->next; + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.ttysize = simple_strtol(s, &s2, 0); + if ((int)strlen(s) > (int)(s2 - s)) { + dgap_err("bad number for ttysize"); + return(-1); + } + DPR_INIT(("Adding TTSIZ (%s) to config...\n", s)); + break; + + case CHSIZ: /* channel structure size */ + if (dgap_checknode(p)) + return(-1); + if ( (p->next = dgap_newnode(CSNODE)) == NULL ) { + dgap_err("out of memory"); + return(-1); + } + p = p->next; + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.chsize = simple_strtol(s, &s2, 0); + if ((int)strlen(s) > (int)(s2 - s)) { + dgap_err("bad number for chsize"); + return(-1); + } + DPR_INIT(("Adding CHSIZE (%s) to config...\n", s)); + break; + + case BSSIZ: /* board structure size */ + if (dgap_checknode(p)) + return(-1); + if ( (p->next = dgap_newnode(BSNODE)) == NULL ) { + dgap_err("out of memory"); + return(-1); + } + p = p->next; + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.bssize = simple_strtol(s, &s2, 0); + if ((int)strlen(s) > (int)(s2 - s)) { + dgap_err("bad number for bssize"); + return(-1); + } + DPR_INIT(("Adding BSSIZ (%s) to config...\n", s)); + break; + + case UNTSIZ: /* sched structure size */ + if (dgap_checknode(p)) + return(-1); + if ( (p->next = dgap_newnode(USNODE)) == NULL ) { + dgap_err("out of memory"); + return(-1); + } + p = p->next; + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.unsize = simple_strtol(s, &s2, 0); + if ((int)strlen(s) > (int)(s2 - s)) { + dgap_err("bad number for schedsize"); + return(-1); + } + DPR_INIT(("Adding UNTSIZ (%s) to config...\n", s)); + break; + + case F2SIZ: /* f2200 structure size */ + if (dgap_checknode(p)) + return(-1); + if ( (p->next = dgap_newnode(FSNODE)) == NULL ) { + dgap_err("out of memory"); + return(-1); + } + p = p->next; + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.f2size = simple_strtol(s, &s2, 0); + if ((int)strlen(s) > (int)(s2 - s)) { + dgap_err("bad number for f2200size"); + return(-1); + } + DPR_INIT(("Adding F2SIZ (%s) to config...\n", s)); + break; + + case VPSIZ: /* vpix structure size */ + if (dgap_checknode(p)) + return(-1); + if ( (p->next = dgap_newnode(VSNODE)) == NULL ) { + dgap_err("out of memory"); + return(-1); + } + p = p->next; + s = dgap_getword(in); + if (s == NULL) { + dgap_err("unexpected end of file"); + return(-1); + } + p->u.vpixsize = simple_strtol(s, &s2, 0); + if ((int)strlen(s) > (int)(s2 - s)) { + dgap_err("bad number for vpixsize"); + return(-1); + } + DPR_INIT(("Adding VPSIZ (%s) to config...\n", s)); + break; + } + } +} + + +/* + * dgap_sindex: much like index(), but it looks for a match of any character in + * the group, and returns that position. If the first character is a ^, then + * this will match the first occurence not in that group. + */ +static char *dgap_sindex (char *string, char *group) +{ + char *ptr; + + if (!string || !group) + return (char *) NULL; + + if (*group == '^') { + group++; + for (; *string; string++) { + for (ptr = group; *ptr; ptr++) { + if (*ptr == *string) + break; + } + if (*ptr == '\0') + return string; + } + } + else { + for (; *string; string++) { + for (ptr = group; *ptr; ptr++) { + if (*ptr == *string) + return string; + } + } + } + + return (char *) NULL; +} + + +/* + * Get a token from the input file; return 0 if end of file is reached + */ +static int dgap_gettok(char **in, struct cnode *p) +{ + char *w; + struct toklist *t; + + if (strstr(dgap_cword, "boar")) { + w = dgap_getword(in); + snprintf(dgap_cword, MAXCWORD, "%s", w); + for (t = dgap_tlist; t->token != 0; t++) { + if ( !strcmp(w, t->string)) { + return(t->token); + } + } + dgap_err("board !!type not specified"); + return(1); + } + else { + while ( (w = dgap_getword(in)) != NULL ) { + snprintf(dgap_cword, MAXCWORD, "%s", w); + for (t = dgap_tlist; t->token != 0; t++) { + if ( !strcmp(w, t->string) ) + return(t->token); + } + } + return(0); + } +} + + +/* + * get a word from the input stream, also keep track of current line number. + * words are separated by whitespace. + */ +static char *dgap_getword(char **in) +{ + char *ret_ptr = *in; + + char *ptr = dgap_sindex(*in, " \t\n"); + + /* If no word found, return null */ + if (!ptr) + return NULL; + + /* Mark new location for our buffer */ + *ptr = '\0'; + *in = ptr + 1; + + /* Eat any extra spaces/tabs/newlines that might be present */ + while (*in && **in && ((**in == ' ') || (**in == '\t') || (**in == '\n'))) { + **in = '\0'; + *in = *in + 1; + } + + return ret_ptr; +} + + +/* + * print an error message, giving the line number in the file where + * the error occurred. + */ +static void dgap_err(char *s) +{ + printk("DGAP: parse: %s\n", s); +} + + +/* + * allocate a new configuration node of type t + */ +static struct cnode *dgap_newnode(int t) +{ + struct cnode *n; + if ( (n = (struct cnode *) kmalloc(sizeof(struct cnode ), GFP_ATOMIC) ) != NULL) { + memset( (char *)n, 0, sizeof(struct cnode ) ); + n->type = t; + } + return(n); +} + + +/* + * dgap_checknode: see if all the necessary info has been supplied for a node + * before creating the next node. + */ +static int dgap_checknode(struct cnode *p) +{ + switch (p->type) { + case BNODE: + if (p->u.board.v_type == 0) { + dgap_err("board type !not specified"); + return(1); + } + + return(0); + + case LNODE: + if (p->u.line.v_speed == 0) { + dgap_err("line speed not specified"); + return(1); + } + return(0); + + case CNODE: + if (p->u.conc.v_type == 0) { + dgap_err("concentrator type not specified"); + return(1); + } + if (p->u.conc.v_speed == 0) { + dgap_err("concentrator line speed not specified"); + return(1); + } + if (p->u.conc.v_nport == 0) { + dgap_err("number of ports on concentrator not specified"); + return(1); + } + if (p->u.conc.v_id == 0) { + dgap_err("concentrator id letter not specified"); + return(1); + } + return(0); + + case MNODE: + if (p->u.module.v_type == 0) { + dgap_err("EBI module type not specified"); + return(1); + } + if (p->u.module.v_nport == 0) { + dgap_err("number of ports on EBI module not specified"); + return(1); + } + if (p->u.module.v_id == 0) { + dgap_err("EBI module id letter not specified"); + return(1); + } + return(0); + } + return(0); +} + +/* + * save a string somewhere + */ +static char *dgap_savestring(char *s) +{ + char *p; + if ( (p = kmalloc(strlen(s) + 1, GFP_ATOMIC) ) != NULL) { + strcpy(p, s); + } + return(p); +} + + +/* + * Given a board pointer, returns whether we should use interrupts or not. + */ +uint dgap_config_get_useintr(struct board_t *bd) +{ + struct cnode *p = NULL; + + if (!bd) + return(0); + + for (p = bd->bd_config; p; p = p->next) { + switch (p->type) { + case INTRNODE: + /* + * check for pcxr types. + */ + return p->u.useintr; + default: + break; + } + } + + /* If not found, then don't turn on interrupts. */ + return 0; +} + + +/* + * Given a board pointer, returns whether we turn on altpin or not. + */ +uint dgap_config_get_altpin(struct board_t *bd) +{ + struct cnode *p = NULL; + + if (!bd) + return(0); + + for (p = bd->bd_config; p; p = p->next) { + switch (p->type) { + case ANODE: + /* + * check for pcxr types. + */ + return p->u.altpin; + default: + break; + } + } + + /* If not found, then don't turn on interrupts. */ + return 0; +} + + + +/* + * Given a specific type of board, if found, detached link and + * returns the first occurance in the list. + */ +struct cnode *dgap_find_config(int type, int bus, int slot) +{ + struct cnode *p, *prev = NULL, *prev2 = NULL, *found = NULL; + + p = &dgap_head; + + while (p->next != NULL) { + prev = p; + p = p->next; + + if (p->type == BNODE) { + + if (p->u.board.type == type) { + + if (p->u.board.v_pcibus && p->u.board.pcibus != bus) { + DPR(("Found matching board, but wrong bus position. System says bus %d, we want bus %ld\n", + bus, p->u.board.pcibus)); + continue; + } + if (p->u.board.v_pcislot && p->u.board.pcislot != slot) { + DPR_INIT(("Found matching board, but wrong slot position. System says slot %d, we want slot %ld\n", + slot, p->u.board.pcislot)); + continue; + } + + DPR_INIT(("Matched type in config file\n")); + + found = p; + /* + * Keep walking thru the list till we find the next board. + */ + while (p->next != NULL) { + prev2 = p; + p = p->next; + if (p->type == BNODE) { + + /* + * Mark the end of our 1 board chain of configs. + */ + prev2->next = NULL; + + /* + * Link the "next" board to the previous board, + * effectively "unlinking" our board from the main config. + */ + prev->next = p; + + return found; + } + } + /* + * It must be the last board in the list. + */ + prev->next = NULL; + return found; + } + } + } + return NULL; +} + +/* + * Given a board pointer, walks the config link, counting up + * all ports user specified should be on the board. + * (This does NOT mean they are all actually present right now tho) + */ +uint dgap_config_get_number_of_ports(struct board_t *bd) +{ + int count = 0; + struct cnode *p = NULL; + + if (!bd) + return(0); + + for (p = bd->bd_config; p; p = p->next) { + + switch (p->type) { + case BNODE: + /* + * check for pcxr types. + */ + if (p->u.board.type > EPCFE) + count += p->u.board.nport; + break; + case CNODE: + count += p->u.conc.nport; + break; + case MNODE: + count += p->u.module.nport; + break; + } + } + return (count); +} + +char *dgap_create_config_string(struct board_t *bd, char *string) +{ + char *ptr = string; + struct cnode *p = NULL; + struct cnode *q = NULL; + int speed; + + if (!bd) { + *ptr = 0xff; + return string; + } + + for (p = bd->bd_config; p; p = p->next) { + + switch (p->type) { + case LNODE: + *ptr = '\0'; + ptr++; + *ptr = p->u.line.speed; + ptr++; + break; + case CNODE: + /* + * Because the EPC/con concentrators can have EM modules + * hanging off of them, we have to walk ahead in the list + * and keep adding the number of ports on each EM to the config. + * UGH! + */ + speed = p->u.conc.speed; + q = p->next; + if ((q != NULL) && (q->type == MNODE) ) { + *ptr = (p->u.conc.nport + 0x80); + ptr++; + p = q; + while ((q->next != NULL) && (q->next->type) == MNODE) { + *ptr = (q->u.module.nport + 0x80); + ptr++; + p = q; + q = q->next; + } + *ptr = q->u.module.nport; + ptr++; + } else { + *ptr = p->u.conc.nport; + ptr++; + } + + *ptr = speed; + ptr++; + break; + } + } + + *ptr = 0xff; + return string; +} + + + +char *dgap_get_config_letters(struct board_t *bd, char *string) +{ + int found = FALSE; + char *ptr = string; + struct cnode *cptr = NULL; + int len = 0; + int left = MAXTTYNAMELEN; + + if (!bd) { + return ""; + } + + for (cptr = bd->bd_config; cptr; cptr = cptr->next) { + + if ((cptr->type == BNODE) && + ((cptr->u.board.type == APORT2_920P) || (cptr->u.board.type == APORT4_920P) || + (cptr->u.board.type == APORT8_920P) || (cptr->u.board.type == PAPORT4) || + (cptr->u.board.type == PAPORT8))) { + + found = TRUE; + } + + if (cptr->type == TNODE && found == TRUE) { + char *ptr1; + if (strstr(cptr->u.ttyname, "tty")) { + ptr1 = cptr->u.ttyname; + ptr1 += 3; + } + else { + ptr1 = cptr->u.ttyname; + } + if (ptr1) { + len = snprintf(ptr, left, "%s", ptr1); + left -= len; + ptr += len; + if (left <= 0) + break; + } + } + + if (cptr->type == CNODE) { + if (cptr->u.conc.id) { + len = snprintf(ptr, left, "%s", cptr->u.conc.id); + left -= len; + ptr += len; + if (left <= 0) + break; + } + } + + if (cptr->type == MNODE) { + if (cptr->u.module.id) { + len = snprintf(ptr, left, "%s", cptr->u.module.id); + left -= len; + ptr += len; + if (left <= 0) + break; + } + } + } + + return string; +} diff --git a/drivers/staging/dgap/dgap_parse.h b/drivers/staging/dgap/dgap_parse.h new file mode 100644 index 0000000000000..8128c47343cb2 --- /dev/null +++ b/drivers/staging/dgap/dgap_parse.h @@ -0,0 +1,35 @@ +/* + * Copyright 2003 Digi International (www.digi.com) + * Scott H Kilau + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! + */ + +#ifndef _DGAP_PARSE_H +#define _DGAP_PARSE_H + +#include "dgap_driver.h" + +extern int dgap_parsefile(char **in, int Remove); +extern struct cnode *dgap_find_config(int type, int bus, int slot); +extern uint dgap_config_get_number_of_ports(struct board_t *bd); +extern char *dgap_create_config_string(struct board_t *bd, char *string); +extern char *dgap_get_config_letters(struct board_t *bd, char *string); +extern uint dgap_config_get_useintr(struct board_t *bd); +extern uint dgap_config_get_altpin(struct board_t *bd); + +#endif diff --git a/drivers/staging/dgap/dgap_pci.h b/drivers/staging/dgap/dgap_pci.h new file mode 100644 index 0000000000000..05ed374f08e14 --- /dev/null +++ b/drivers/staging/dgap/dgap_pci.h @@ -0,0 +1,92 @@ +/* + * Copyright 2003 Digi International (www.digi.com) + * Scott H Kilau + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! + */ + +/* $Id: dgap_pci.h,v 1.1 2009/10/23 14:01:57 markh Exp $ */ + +#ifndef __DGAP_PCI_H +#define __DGAP_PCI_H + +#define PCIMAX 32 /* maximum number of PCI boards */ + +#define DIGI_VID 0x114F + +#define PCI_DEVICE_EPC_DID 0x0002 +#define PCI_DEVICE_XEM_DID 0x0004 +#define PCI_DEVICE_XR_DID 0x0005 +#define PCI_DEVICE_CX_DID 0x0006 +#define PCI_DEVICE_XRJ_DID 0x0009 /* PLX-based Xr adapter */ +#define PCI_DEVICE_XR_IBM_DID 0x0011 /* IBM 8-port Async Adapter */ +#define PCI_DEVICE_XR_BULL_DID 0x0013 /* BULL 8-port Async Adapter */ +#define PCI_DEVICE_XR_SAIP_DID 0x001c /* SAIP card - Xr adapter */ +#define PCI_DEVICE_XR_422_DID 0x0012 /* Xr-422 */ +#define PCI_DEVICE_920_2_DID 0x0034 /* XR-Plus 920 K, 2 port */ +#define PCI_DEVICE_920_4_DID 0x0026 /* XR-Plus 920 K, 4 port */ +#define PCI_DEVICE_920_8_DID 0x0027 /* XR-Plus 920 K, 8 port */ +#define PCI_DEVICE_EPCJ_DID 0x000a /* PLX 9060 chip for PCI */ +#define PCI_DEVICE_CX_IBM_DID 0x001b /* IBM 128-port Async Adapter */ +#define PCI_DEVICE_920_8_HP_DID 0x0058 /* HP XR-Plus 920 K, 8 port */ +#define PCI_DEVICE_XEM_HP_DID 0x0059 /* HP Xem PCI */ + +#define PCI_DEVICE_XEM_NAME "AccelePort XEM" +#define PCI_DEVICE_CX_NAME "AccelePort CX" +#define PCI_DEVICE_XR_NAME "AccelePort Xr" +#define PCI_DEVICE_XRJ_NAME "AccelePort Xr (PLX)" +#define PCI_DEVICE_XR_SAIP_NAME "AccelePort Xr (SAIP)" +#define PCI_DEVICE_920_2_NAME "AccelePort Xr920 2 port" +#define PCI_DEVICE_920_4_NAME "AccelePort Xr920 4 port" +#define PCI_DEVICE_920_8_NAME "AccelePort Xr920 8 port" +#define PCI_DEVICE_XR_422_NAME "AccelePort Xr 422" +#define PCI_DEVICE_EPCJ_NAME "AccelePort EPC (PLX)" +#define PCI_DEVICE_XR_BULL_NAME "AccelePort Xr (BULL)" +#define PCI_DEVICE_XR_IBM_NAME "AccelePort Xr (IBM)" +#define PCI_DEVICE_CX_IBM_NAME "AccelePort CX (IBM)" +#define PCI_DEVICE_920_8_HP_NAME "AccelePort Xr920 8 port (HP)" +#define PCI_DEVICE_XEM_HP_NAME "AccelePort XEM (HP)" + + +/* + * On the PCI boards, there is no IO space allocated + * The I/O registers will be in the first 3 bytes of the + * upper 2MB of the 4MB memory space. The board memory + * will be mapped into the low 2MB of the 4MB memory space + */ + +/* Potential location of PCI Bios from E0000 to FFFFF*/ +#define PCI_BIOS_SIZE 0x00020000 + +/* Size of Memory and I/O for PCI (4MB) */ +#define PCI_RAM_SIZE 0x00400000 + +/* Size of Memory (2MB) */ +#define PCI_MEM_SIZE 0x00200000 + +/* Max PCI Window Size (2MB) */ +#define PCI_WIN_SIZE 0x00200000 + +#define PCI_WIN_SHIFT 21 /* 21 bits max */ + +/* Offset of I/0 in Memory (2MB) */ +#define PCI_IO_OFFSET 0x00200000 + +/* Size of IO (2MB) */ +#define PCI_IO_SIZE 0x00200000 + +#endif diff --git a/drivers/staging/dgap/dgap_proc.c b/drivers/staging/dgap/dgap_proc.c new file mode 100644 index 0000000000000..6950a6c9b87db --- /dev/null +++ b/drivers/staging/dgap/dgap_proc.c @@ -0,0 +1,1924 @@ +/* + * Copyright 2003 Digi International (www.digi.com) + * Scott H Kilau + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * + * NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE! + * + * This is shared code between Digi's CVS archive and the + * Linux Kernel sources. + * Changing the source just for reformatting needlessly breaks + * our CVS diff history. + * + * Send any bug fixes/changes to: Eng.Linux at digi dot com. + * Thank you. + * + * + * $Id: dgap_proc.c,v 1.2 2010/12/22 21:22:39 markh Exp $ + */ + +#include +#include +#include /* For jiffies, task states */ +#include /* For tasklet and interrupt structs/defines */ +#include +#include +#include +#include +#include /* For in_egroup_p() */ +#include +#include /* For copy_from_user/copy_to_user */ +#include + +#include "dgap_driver.h" +#include "dgap_proc.h" +#include "dgap_mgmt.h" +#include "dgap_conf.h" +#include "dgap_parse.h" +#include "dgap_fep5.h" + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37) +#define init_MUTEX(sem) sema_init(sem, 1) +#endif + +/* The /proc/dgap directory */ +static struct proc_dir_entry *ProcDGAP; + + +/* File operation declarations */ +static int dgap_gen_proc_open(struct inode *, struct file *); +static int dgap_gen_proc_close(struct inode *, struct file *); +static ssize_t dgap_gen_proc_read(struct file *file, char __user *buf, size_t count, loff_t *ppos); +static ssize_t dgap_gen_proc_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos); + +static int dgap_proc_chk_perm(struct inode *, int); + +static const struct file_operations dgap_proc_file_ops = +{ + .owner = THIS_MODULE, + .read = dgap_gen_proc_read, /* read */ + .write = dgap_gen_proc_write, /* write */ + .open = dgap_gen_proc_open, /* open */ + .release = dgap_gen_proc_close, /* release */ +}; + + +static struct inode_operations dgap_proc_inode_ops = +{ + .permission = dgap_proc_chk_perm +}; + + +static void dgap_register_proc_table(struct dgap_proc_entry *, struct proc_dir_entry *); +static void dgap_unregister_proc_table(struct dgap_proc_entry *, struct proc_dir_entry *); +static void dgap_remove_proc_entry(struct proc_dir_entry *pde); + + +/* Stuff in /proc/ */ +static int dgap_read_info(struct dgap_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos); +static int dgap_write_info(struct dgap_proc_entry *table, int dir, struct file *filp, + const char __user *buffer, ssize_t *lenp, loff_t *ppos); + +static int dgap_read_mknod(struct dgap_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos); + +static struct dgap_proc_entry dgap_table[] = { + {DGAP_INFO, "info", 0600, NULL, NULL, NULL, &dgap_read_info, &dgap_write_info, + NULL, __SEMAPHORE_INITIALIZER(dgap_table[0].excl_sem, 1), 0, NULL }, + {DGAP_MKNOD, "mknod", 0600, NULL, NULL, NULL, &dgap_read_mknod, NULL, + NULL, __SEMAPHORE_INITIALIZER(dgap_table[1].excl_sem, 1), 0, NULL }, + + {0} +}; + + +/* Stuff in /proc// */ +static int dgap_read_board_info(struct dgap_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos); +static int dgap_read_board_vpd(struct dgap_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos); +static int dgap_read_board_vpddata(struct dgap_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos); +static int dgap_read_board_mknod(struct dgap_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos); +static int dgap_read_board_ttystats(struct dgap_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos); +static int dgap_read_board_ttyflags(struct dgap_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos); + +static struct dgap_proc_entry dgap_board_table[] = { + {DGAP_BOARD_INFO, "info", 0600, NULL, NULL, NULL, &dgap_read_board_info, NULL, + NULL, __SEMAPHORE_INITIALIZER(dgap_board_table[0].excl_sem, 1), 0, NULL }, + {DGAP_BOARD_VPD, "vpd", 0600, NULL, NULL, NULL, &dgap_read_board_vpd, NULL, + NULL, __SEMAPHORE_INITIALIZER(dgap_board_table[1].excl_sem, 1), 0, NULL }, + {DGAP_BOARD_VPDDATA, "vpddata", 0600, NULL, NULL, NULL, &dgap_read_board_vpddata, NULL, + NULL, __SEMAPHORE_INITIALIZER(dgap_board_table[2].excl_sem, 1), 0, NULL }, + {DGAP_BOARD_TTYSTATS, "stats", 0600, NULL, NULL, NULL, &dgap_read_board_ttystats, NULL, + NULL, __SEMAPHORE_INITIALIZER(dgap_board_table[3].excl_sem, 1), 0, NULL }, + {DGAP_BOARD_TTYFLAGS, "flags", 0600, NULL, NULL, NULL, &dgap_read_board_ttyflags, NULL, + NULL, __SEMAPHORE_INITIALIZER(dgap_board_table[4].excl_sem, 1), 0, NULL }, + {DGAP_BOARD_MKNOD, "mknod", 0600, NULL, NULL, NULL, &dgap_read_board_mknod, NULL, + NULL, __SEMAPHORE_INITIALIZER(dgap_board_table[5].excl_sem, 1), 0, NULL }, + {0} +}; + + +/* Stuff in /proc// */ +static int dgap_read_channel_info(struct dgap_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos); +static int dgap_open_channel_sniff(struct dgap_proc_entry *table, int dir, struct file *filp, + void *buffer, ssize_t *lenp, loff_t *ppos); +static int dgap_close_channel_sniff(struct dgap_proc_entry *table, int dir, struct file *filp, + void *buffer, ssize_t *lenp, loff_t *ppos); +static int dgap_read_channel_sniff(struct dgap_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos); +static int dgap_read_channel_custom_ttyname(struct dgap_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos); +static int dgap_read_channel_custom_prname(struct dgap_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos); +static int dgap_read_channel_fepstate(struct dgap_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos); + + +static struct dgap_proc_entry dgap_channel_table[] = { + {DGAP_PORT_INFO, "info", 0600, NULL, NULL, NULL, &dgap_read_channel_info, NULL, + NULL, __SEMAPHORE_INITIALIZER(dgap_channel_table[0].excl_sem, 1), 0, NULL }, + {DGAP_PORT_SNIFF, "sniff", 0600, NULL, &dgap_open_channel_sniff, &dgap_close_channel_sniff, &dgap_read_channel_sniff, NULL, + NULL, __SEMAPHORE_INITIALIZER(dgap_channel_table[1].excl_sem, 1), 0, NULL}, + {DGAP_PORT_CUSTOM_TTYNAME, "ttyname", 0600, NULL, NULL, NULL, &dgap_read_channel_custom_ttyname, NULL, + NULL, __SEMAPHORE_INITIALIZER(dgap_channel_table[2].excl_sem, 1), 0, NULL }, + {DGAP_PORT_CUSTOM_PRNAME, "prname", 0600, NULL, NULL, NULL, &dgap_read_channel_custom_prname, NULL, + NULL, __SEMAPHORE_INITIALIZER(dgap_channel_table[3].excl_sem, 1), 0, NULL }, + {DGAP_PORT_FEPSTATE, "fepstate", 0600, NULL, NULL, NULL, &dgap_read_channel_fepstate, NULL, + NULL, __SEMAPHORE_INITIALIZER(dgap_channel_table[4].excl_sem, 1), 0, NULL }, + {0} +}; + + +/* + * test_perm does NOT grant the superuser all rights automatically, because + * some entries are readonly even to root. + */ +static inline int test_perm(int mode, int op) +{ + if (!current_euid()) + mode >>= 6; + else if (in_egroup_p(0)) + mode >>= 3; + if ((mode & op & 0007) == op) + return 0; + if (capable(CAP_SYS_ADMIN)) + return 0; + return -EACCES; +} + + +/* + * /proc/sys support + */ +static inline int dgap_proc_match(int len, const char *name, struct proc_dir_entry *de) +{ + if (!de || !de->low_ino) + return 0; + if (de->namelen != len) + return 0; + return !memcmp(name, de->name, len); +} + + +/* + * Scan the entries in table and add them all to /proc at the position + * referred to by "root" + */ +static void dgap_register_proc_table(struct dgap_proc_entry *table, struct proc_dir_entry *root) +{ + struct proc_dir_entry *de; + int len; + mode_t mode; + + for (; table->magic; table++) { + /* Can't do anything without a proc name. */ + if (!table->name) { + DPR_PROC(("dgap_register_proc_table, no name...\n")); + continue; + } + + /* Maybe we can't do anything with it... */ + if (!table->read_handler && !table->write_handler && !table->child) { + DPR_PROC((KERN_WARNING "DGAP PROC: Can't register %s\n", table->name)); + continue; + } + + len = strlen(table->name); + mode = table->mode; + de = NULL; + + if (!table->child) { + mode |= S_IFREG; + } else { + mode |= S_IFDIR; + for (de = root->subdir; de; de = de->next) { + if (dgap_proc_match(len, table->name, de)) + break; + } + + /* If the subdir exists already, de is non-NULL */ + } + + if (!de) { + de = create_proc_entry(table->name, mode, root); + if (!de) + continue; + de->data = (void *) table; + if (!table->child) { + de->proc_iops = &dgap_proc_inode_ops; + de->proc_fops = &dgap_proc_file_ops; + } + } + + table->de = de; + + if (de->mode & S_IFDIR) + dgap_register_proc_table(table->child, de); + + } +} + + + +/* + * Unregister a /proc sysctl table and any subdirectories. + */ +static void dgap_unregister_proc_table(struct dgap_proc_entry *table, struct proc_dir_entry *root) +{ + struct proc_dir_entry *de; + + for (; table->magic; table++) { + if (!(de = table->de)) + continue; + + if (de->mode & S_IFDIR) { + if (!table->child) { + DPR_PROC((KERN_ALERT "Help - malformed sysctl tree on free\n")); + continue; + } + + /* recurse down into subdirectory... */ + DPR_PROC(("Recursing down a directory...\n")); + dgap_unregister_proc_table(table->child, de); + + /* Don't unregister directories which still have entries.. */ + if (de->subdir) + continue; + } + /* Don't unregister proc entries that are still being used.. */ + if ((atomic_read(&de->count)) != 1) { + DPR_PROC(("proc entry in use... Not removing...\n")); + continue; + } + dgap_remove_proc_entry(de); + table->de = NULL; + } +} + + + +static int dgap_gen_proc_open(struct inode *inode, struct file *file) +{ + struct proc_dir_entry *de; + struct dgap_proc_entry *entry; + int (*handler) (struct dgap_proc_entry *table, int dir, struct file *filp, + void *buffer, ssize_t *lenp, loff_t *ppos); + int ret = 0, error = 0; + + de = (struct proc_dir_entry *) PDE(file->f_dentry->d_inode); + if (!de || !de->data) { + ret = -ENXIO; + goto done; + } + + entry = (struct dgap_proc_entry *) de->data; + if (!entry) { + ret = -ENXIO; + goto done; + } + + down(&entry->excl_sem); + + if (entry->excl_cnt) { + ret = -EBUSY; + } else { + entry->excl_cnt++; + handler = entry->open_handler; + if (handler) { + error = (*handler) (entry, OUTBOUND, file, NULL, NULL, NULL); + if (error) { + entry->excl_cnt--; + ret = error; + } + } + } + + up(&entry->excl_sem); + +done: + + return ret; +} + + +static int dgap_gen_proc_close(struct inode *inode, struct file *file) +{ + struct proc_dir_entry *de; + int (*handler) (struct dgap_proc_entry *table, int dir, struct file *filp, + void *buffer, ssize_t *lenp, loff_t *ppos); + struct dgap_proc_entry *entry; + int error = 0; + + de = (struct proc_dir_entry *) PDE(file->f_dentry->d_inode); + if (!de || !de->data) + goto done; + + entry = (struct dgap_proc_entry *) de->data; + if (!entry) + goto done; + + down(&entry->excl_sem); + + if (entry->excl_cnt) + entry->excl_cnt = 0; + + + handler = entry->close_handler; + if (handler) { + error = (*handler) (entry, OUTBOUND, file, NULL, NULL, NULL); + } + + up(&entry->excl_sem); + +done: + return 0; +} + + +static ssize_t dgap_gen_proc_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) +{ + struct proc_dir_entry *de; + struct dgap_proc_entry *entry; + int (*handler) (struct dgap_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos2); + ssize_t res; + ssize_t error; + + de = (struct proc_dir_entry*) PDE(file->f_dentry->d_inode); + if (!de || !de->data) + return -ENXIO; + + entry = (struct dgap_proc_entry *) de->data; + if (!entry) + return -ENXIO; + + /* Test for read permission */ + if (test_perm(entry->mode, 4)) + return -EPERM; + + res = count; + + handler = entry->read_handler; + if (!handler) + return -ENXIO; + + error = (*handler) (entry, OUTBOUND, file, buf, &res, ppos); + if (error) + return error; + + return res; +} + + +static ssize_t dgap_gen_proc_write(struct file *file, const char __user *buf, + size_t count, loff_t *ppos) +{ + struct proc_dir_entry *de; + struct dgap_proc_entry *entry; + int (*handler) (struct dgap_proc_entry *table, int dir, struct file *filp, + const char __user *buffer, ssize_t *lenp, loff_t *ppos2); + ssize_t res; + ssize_t error; + + de = (struct proc_dir_entry *) PDE(file->f_dentry->d_inode); + if (!de || !de->data) + return -ENXIO; + + entry = (struct dgap_proc_entry *) de->data; + if (!entry) + return -ENXIO; + + /* Test for write permission */ + if (test_perm(entry->mode, 2)) + return -EPERM; + + res = count; + + handler = entry->write_handler; + if (!handler) + return -ENXIO; + + error = (*handler) (entry, INBOUND, file, buf, &res, ppos); + if (error) + return error; + + return res; +} + + +static int dgap_proc_chk_perm(struct inode *inode, int op) +{ + return test_perm(inode->i_mode, op); +} + + +/* + * Return what is (hopefully) useful information about the + * driver. + */ +static int dgap_read_info(struct dgap_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos) +{ + static int done = 0; + static char buf[4096]; + char *p = buf; + + DPR_PROC(("dgap_proc_info\n")); + + if (done) { + done = 0; + *lenp = 0; + return 0; + } + + p += sprintf(p, "Driver:\t\t%s\n", DG_NAME); + p += sprintf(p, "\n"); + p += sprintf(p, "Debug:\t\t0x%x\n", dgap_debug); + p += sprintf(p, "Rawreadok:\t0x%x\n", dgap_rawreadok); + p += sprintf(p, "Max Boards:\t%d\n", MAXBOARDS); + p += sprintf(p, "Total Boards:\t%d\n", dgap_NumBoards); + p += sprintf(p, "Poll rate:\t%dms\n", dgap_poll_tick); + p += sprintf(p, "Poll counter:\t%ld\n", dgap_poll_counter); + p += sprintf(p, "State:\t\t%s\n", dgap_driver_state_text[dgap_driver_state]); + + if (copy_to_user(buffer, buf, (p - (char *) buf))) + return -EFAULT; + + *lenp = p - (char *) buf; + *ppos += p - (char *) buf; + done = 1; + return 0; +} + + +/* + * When writing to the "info" entry point, I actually allow one + * to modify certain variables. This may be a sleazy overload + * of this /proc entry, but I don't want: + * + * a. to clutter /proc more than I have to + * b. to overload the "config" entry, which would be somewhat + * more natural + * c. necessarily advertise the fact this ability exists + * + * The continued support of this feature has not yet been + * guaranteed. + * + * Writing operates on a "state machine" principle. + * + * State 0: waiting for a symbol to start. Waiting for anything + * which isn't " ' = or whitespace. + * State 1: reading a symbol. If the character is a space, move + * to state 2. If =, move to state 3. If " or ', move + * to state 0. + * State 2: Waiting for =... suck whitespace. If anything other + * than whitespace, drop to state 0. + * State 3: Got =. Suck whitespace waiting for value to start. + * If " or ', go to state 4 (and remember which quote it + * was). Otherwise, go to state 5. + * State 4: Reading value, within quotes. Everything is added to + * value up until the matching quote. When you hit the + * matching quote, try to set the variable, then state 0. + * State 5: Reading value, outside quotes. Everything not " ' = + * or whitespace goes in value. Hitting one of the + * terminators tosses us back to state 0 after trying to + * set the variable. + */ +typedef enum { + INFO_NONE, INFO_INT, INFO_CHAR, INFO_SHORT, + INFO_LONG, INFO_PTR, INFO_STRING, INFO_END +} info_proc_var_val; + +static struct { + char *name; + info_proc_var_val type; + int rw; /* 0=readonly */ + void *val_ptr; +} dgap_info_vars[] = { + { "rawreadok", INFO_INT, 1, (void *) &dgap_rawreadok }, + { "pollrate", INFO_INT, 1, (void *) &dgap_poll_tick }, + { NULL, INFO_NONE, 0, NULL }, + { "debug", INFO_LONG, 1, (void *) &dgap_debug }, + { NULL, INFO_END, 0, NULL } +}; + +static void dgap_set_info_var(char *name, char *val) +{ + int i; + unsigned long newval; + unsigned char charval; + unsigned short shortval; + unsigned int intval; + + for (i = 0; dgap_info_vars[i].type != INFO_END; i++) { + if (dgap_info_vars[i].name) + if (!strcmp(name, dgap_info_vars[i].name)) + break; + } + + if (dgap_info_vars[i].type == INFO_END) + return; + if (dgap_info_vars[i].rw == 0) + return; + if (dgap_info_vars[i].val_ptr == NULL) + return; + + newval = simple_strtoul(val, NULL, 0 ); + + switch (dgap_info_vars[i].type) { + case INFO_CHAR: + charval = newval & 0xff; + APR(("Modifying %s (%lx) <= 0x%02x (%d)\n", + name, (long)(dgap_info_vars[i].val_ptr ), + charval, charval)); + *(uchar *)(dgap_info_vars[i].val_ptr) = charval; + break; + case INFO_SHORT: + shortval = newval & 0xffff; + APR(("Modifying %s (%lx) <= 0x%04x (%d)\n", + name, (long)(dgap_info_vars[i].val_ptr), + shortval, shortval)); + *(ushort *)(dgap_info_vars[i].val_ptr) = shortval; + break; + case INFO_INT: + intval = newval & 0xffffffff; + APR(("Modifying %s (%lx) <= 0x%08x (%d)\n", + name, (long)(dgap_info_vars[i].val_ptr), + intval, intval)); + *(uint *)(dgap_info_vars[i].val_ptr) = intval; + break; + case INFO_LONG: + APR(("Modifying %s (%lx) <= 0x%lx (%ld)\n", + name, (long)(dgap_info_vars[i].val_ptr), + newval, newval)); + *(ulong *)(dgap_info_vars[i].val_ptr) = newval; + break; + case INFO_PTR: + case INFO_STRING: + case INFO_END: + case INFO_NONE: + default: + break; + } +} + +static int dgap_write_info(struct dgap_proc_entry *table, int dir, struct file *filp, + const char __user *buffer, ssize_t *lenp, loff_t *ppos) +{ + static int state = 0; + #define MAXSYM 255 + static int sympos, valpos; + static char sym[MAXSYM + 1]; + static char val[MAXSYM + 1]; + static int quotchar = 0; + + int i; + + long len; + #define INBUFLEN 256 + char inbuf[INBUFLEN]; + + if (*ppos == 0) { + state = 0; + sympos = 0; sym[0] = 0; + valpos = 0; val[0] = 0; + quotchar = 0; + } + + if ((!*lenp) || (dir != INBOUND)) { + *lenp = 0; + return 0; + } + + len = *lenp; + + if (len > INBUFLEN - 1) + len = INBUFLEN - 1; + + if (copy_from_user(inbuf, buffer, len)) + return -EFAULT; + + inbuf[len] = 0; + + for (i = 0; i < len; i++) { + unsigned char c = inbuf[i]; + + switch (state) { + case 0: + quotchar = sympos = valpos = sym[0] = val[0] = 0; + if (!isspace(c) && (c != '\"') && + (c != '\'') && (c != '=')) { + sym[sympos++] = c; + state = 1; + break; + } + break; + case 1: + if (isspace(c)) { + sym[sympos] = 0; + state = 2; + break; + } + if (c == '=') { + sym[sympos] = 0; + state = 3; + break; + } + if ((c == '\"' ) || ( c == '\'' )) { + state = 0; + break; + } + if (sympos < MAXSYM) sym[sympos++] = c; + break; + case 2: + if (isspace(c)) break; + if (c == '=') { + state = 3; + break; + } + if ((c != '\"') && (c != '\'')) { + quotchar = sympos = valpos = sym[0] = val[0] = 0; + sym[sympos++] = c; + state = 1; + break; + } + state = 0; + break; + case 3: + if (isspace(c)) break; + if (c == '=') { + state = 0; + break; + } + if ((c == '\"') || (c == '\'')) { + state = 4; + quotchar = c; + break; + } + val[valpos++] = c; + state = 5; + break; + case 4: + if (c == quotchar) { + val[valpos] = 0; + dgap_set_info_var(sym, val); + state = 0; + break; + } + if (valpos < MAXSYM) val[valpos++] = c; + break; + case 5: + if (isspace(c) || (c == '\"') || + (c == '\'') || (c == '=')) { + val[valpos] = 0; + dgap_set_info_var(sym, val); + state = 0; + break; + } + if (valpos < MAXSYM) val[valpos++] = c; + break; + default: + break; + } + } + + *lenp = len; + *ppos += len; + + return len; +} + + +/* + * Return mknod information for the driver's devices. + */ +static int dgap_read_mknod(struct dgap_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos) +{ + static int done = 0; + static char buf[4096]; + char *p = buf; + + DPR_PROC(("dgap_proc_info\n")); + + if (done) { + done = 0; + *lenp = 0; + return 0; + } + + DPR_PROC(("dgap_proc_mknod\n")); + + p += sprintf(p, "#\tCreate the management device.\n"); + p += sprintf(p, "/dev/dg/dgap/mgmt\t%d\t%d\t%d\t%d\n", DIGI_DGAP_MAJOR, MGMT_MGMT, 1, 0); + p += sprintf(p, "/dev/dg/dgap/downld\t%d\t%d\t%d\t%d\n", DIGI_DGAP_MAJOR, MGMT_DOWNLD, 1, 0); + + if (copy_to_user(buffer, buf, (p - (char *) buf))) + return -EFAULT; + + *lenp = p - (char *) buf; + *ppos += p - (char *) buf; + done = 1; + return 0; +} + + + +/* + * Return what is (hopefully) useful information about the specific board. + */ +static int dgap_read_board_info(struct dgap_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos) +{ + struct board_t *brd; + static int done = 0; + static char buf[4096]; + char *p = buf; + char *name; + + DPR_PROC(("dgap_proc_brd_info\n")); + + brd = (struct board_t *) table->data; + + if (done || !brd || (brd->magic != DGAP_BOARD_MAGIC)) { + done = 0; + *lenp = 0; + return 0; + } + + name = brd->name; + + p += sprintf(p, "Board Name = %s\n", name); + p += sprintf(p, "Board Type = %d\n", brd->type); + p += sprintf(p, "Number of Ports = %d\n", brd->nasync); + + /* + * report some things about the PCI bus that are important + * to some applications + */ + p += sprintf(p, "Vendor ID = 0x%x\n", brd->vendor); + p += sprintf(p, "Device ID = 0x%x\n", brd->device); + p += sprintf(p, "Subvendor ID = 0x%x\n", brd->subvendor); + p += sprintf(p, "Subdevice ID = 0x%x\n", brd->subdevice); + p += sprintf(p, "Bus = %d\n", brd->pci_bus); + p += sprintf(p, "Slot = %d\n", brd->pci_slot); + + /* + * report the physical addresses assigned to us when we got + * registered + */ + p += sprintf(p, "Memory Base Address = 0x%lx\n", brd->membase); + p += sprintf(p, "Remapped Memory Base Address = 0x%p\n", brd->re_map_membase); + + p += sprintf(p, "Current state of board = %s\n", dgap_state_text[brd->state]); + + if (brd->bd_flags & BD_FEP5PLUS) + p += sprintf(p, "FEP5+ Support = Yes\n"); + else + p += sprintf(p, "FEP5+ Support = No\n"); + + p += sprintf(p, "Interrupt #: %ld. Times interrupted: %ld\n", + brd->irq, brd->intr_count); + p += sprintf(p, "Majors allocated to board = TTY: %d PR: %d\n", + brd->SerialDriver->major, brd->PrintDriver->major); + + + if (copy_to_user(buffer, buf, (p - (char *) buf))) + return -EFAULT; + + *lenp = p - (char *) buf; + *ppos += p - (char *) buf; + done = 1; + return 0; +} + + +static int dgap_read_board_vpddata(struct dgap_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos) +{ + struct board_t *brd; + static int done = 0; + static char buf[4096]; + int i = 0, j = 0; + char *p = buf; + + DPR_PROC(("dgap_proc_brd_info\n")); + + brd = (struct board_t *) table->data; + + if (done || !brd || (brd->magic != DGAP_BOARD_MAGIC)) { + done = 0; + *lenp = 0; + return 0; + } + + p += sprintf(p, "\n 0 1 2 3 4 5 6 7 8 9 A B C D E F\n"); + + /* Ending at 0xC0, because nothing but zeros exist after that offset */ + for (i = 0; i < 0xC0; i++) { + j = i; + if (!(i % 16)) { + if (j > 0) { + p += sprintf(p, " "); + for (j = i - 16; j < i; j++) { + if (0x20 <= brd->vpd[j] && brd->vpd[j] <= 0x7e) + p += sprintf(p, "%c", brd->vpd[j]); + else + p += sprintf(p, "."); + } + p += sprintf(p, "\n"); + } + p += sprintf(p, "%04X ", i); + } + p += sprintf(p, "%02X ", brd->vpd[i]); + } + if (!(i % 16)) { + p += sprintf(p, " "); + for (j = i - 16; j < i; j++) { + if (0x20 <= brd->vpd[j] && brd->vpd[j] <= 0x7e) + p += sprintf(p, "%c", brd->vpd[j]); + else + p += sprintf(p, "."); + } + p += sprintf(p, "\n"); + } + + p += sprintf(p, "\n"); + + if (copy_to_user(buffer, buf, (p - (char *) buf))) + return -EFAULT; + + *lenp = p - (char *) buf; + *ppos += p - (char *) buf; + done = 1; + return 0; +} + + +static int dgap_read_board_vpd(struct dgap_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos) +{ + struct board_t *brd; + static int done = 0; + static char buf[4096]; + char *p = buf; + long ptr; + u16 i, j; + uchar len; + + DPR_PROC(("dgap_proc_brd_info\n")); + + brd = (struct board_t *) table->data; + + if (done || !brd || (brd->magic != DGAP_BOARD_MAGIC) || !(brd->bd_flags & BD_HAS_VPD)) { + done = 0; + *lenp = 0; + return 0; + } + + ptr = 0; + + /* Description */ + if (brd->vpd[ptr] == 0x82) { + ptr++; + + p += sprintf(p, "*DS: "); + len = brd->vpd[ptr]; + ptr += 2; + for (i = len; i; i--) { + uchar a; + a = brd->vpd[ptr]; + ptr++; + p += sprintf(p, "%c", a); + } + p += sprintf(p, "\n"); + } + + /* VPD */ + if (brd->vpd[ptr] == 0x90) { + ptr += 3; + + i = brd->vpd[ptr]; + + while (i > 0) { + + uchar a, b; + uchar str1[16]; + + a = brd->vpd[ptr]; + ptr++; + b = brd->vpd[ptr]; + ptr++; + + if ((a == 'P') && (b == 'N')) { + strcpy (str1, "*PN"); + } + else if ((a == 'E') && (b == 'C')) { + strcpy (str1, "*EC"); + } + else if ((a == 'F') && (b == 'N')) { + strcpy (str1, "*FN"); + } + else if ((a == 'M') && (b == 'N')) { + strcpy (str1, "*MF"); + } + else if ((a == 'S') && (b == 'N')) { + strcpy (str1, "*SN"); + } + else if ((a == 'R') && (b == 'L')) { + strcpy (str1, "*RL"); + } + else if ((a == 'D') && (b == 'D')) { + strcpy (str1, "*DD"); + } + else if ((a == 'D') && (b == 'G')) { + strcpy (str1, "*DG"); + } + else if ((a == 'L') && (b == 'L')) { + strcpy (str1, "*LL"); + } + else { + break; + } + + len = brd->vpd[ptr]; + ptr++; + + p += sprintf(p, "%s: ", str1); + + for (j = len; j; j--) { + uchar aa; + aa = brd->vpd[ptr]; + ptr++; + p += sprintf(p, "%c", aa); + } + + p += sprintf(p, "\n"); + + i -= (3 + len); + } + } + + if (copy_to_user(buffer, buf, (p - (char *) buf))) + return -EFAULT; + + *lenp = p - (char *) buf; + *ppos += p - (char *) buf; + done = 1; + return 0; +} + + + +/* + * Return what is (hopefully) useful stats about the specific board's ttys + */ +static int dgap_read_board_ttystats(struct dgap_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos) +{ + struct board_t *brd; + static int done = 0; + static char buf[4096]; + char *p = buf; + int i = 0; + + DPR_PROC(("dgap_proc_brd_info\n")); + + brd = (struct board_t *) table->data; + + if (done || !brd || (brd->magic != DGAP_BOARD_MAGIC)) { + done = 0; + *lenp = 0; + return 0; + } + + /* Prepare the Header Labels */ + p += sprintf(p, "%2s %10s %23s %10s\n", + "Ch", "Chars Rx", " Rx Par--Brk--Frm--Ovr", "Chars Tx"); + + for (i = 0; i < brd->nasync; i++) { + + struct channel_t *ch = brd->channels[i]; + p += sprintf(p, "%2d ", i); + p += sprintf(p, "%10ld ", ch->ch_rxcount); + p += sprintf(p, " %4ld %4ld %4ld %4ld ", ch->ch_err_parity, + ch->ch_err_break, ch->ch_err_frame, ch->ch_err_overrun); + p += sprintf(p, "%10ld ", ch->ch_txcount); + p += sprintf(p, "\n"); + } + + if (copy_to_user(buffer, buf, (p - (char *) buf))) + return -EFAULT; + + *lenp = p - (char *) buf; + *ppos += p - (char *) buf; + done = 1; + return 0; +} + + +/* + * Return what is (hopefully) useful flags about the specific board's ttys + */ +static int dgap_read_board_ttyflags(struct dgap_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos) +{ + struct board_t *brd; + static int done = 0; + static char buf[4096]; + char *p = buf; + int i = 0; + + DPR_PROC(("dgap_proc_brd_info\n")); + + brd = (struct board_t *) table->data; + + if (done || !brd || (brd->magic != DGAP_BOARD_MAGIC)) { + done = 0; + *lenp = 0; + return 0; + } + + /* Prepare the Header Labels */ + p += sprintf(p, "%2s %5s %5s %5s %5s %5s %10s Line Status Flags\n", + "Ch", "CFlag", "IFlag", "OFlag", "LFlag", "DFlag", "Baud"); + + for (i = 0; i < brd->nasync; i++) { + + struct channel_t *ch = brd->channels[i]; + + p += sprintf(p, "%2d ", i); + p += sprintf(p, "%5x ", ch->ch_c_cflag); + p += sprintf(p, "%5x ", ch->ch_c_iflag); + p += sprintf(p, "%5x ", ch->ch_c_oflag); + p += sprintf(p, "%5x ", ch->ch_c_lflag); + p += sprintf(p, "%5x ", ch->ch_digi.digi_flags); + p += sprintf(p, "%10d ", ch->ch_baud_info); + + if (!ch->ch_open_count) { + p += sprintf(p, " -- -- -- -- -- -- --") ; + } else { + p += sprintf(p, " op %s %s %s %s %s %s", + (ch->ch_mostat & UART_MCR_RTS) ? "rs" : "--", + (ch->ch_mistat & UART_MSR_CTS) ? "cs" : "--", + (ch->ch_mostat & UART_MCR_DTR) ? "tr" : "--", + (ch->ch_mistat & UART_MSR_DSR) ? "mr" : "--", + (ch->ch_mistat & UART_MSR_DCD) ? "cd" : "--", + (ch->ch_mistat & UART_MSR_RI) ? "ri" : "--"); + } + + p += sprintf(p, "\n"); + } + if (copy_to_user(buffer, buf, (p - (char *) buf))) + return -EFAULT; + + *lenp = p - (char *) buf; + *ppos += p - (char *) buf; + done = 1; + return 0; +} + + +/* + * Return mknod information for the board's devices. + */ +static int dgap_read_board_mknod(struct dgap_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos) +{ + struct board_t *brd; + static int done = 0; + static char buf[4096]; + char *p = buf; + + int bn; + struct cnode *cptr = NULL; + int found = FALSE; + int ncount = 0; + int starto = 0; + + + DPR_PROC(("dgap_proc_brd_info\n")); + + brd = (struct board_t *) table->data; + + if (done || !brd || (brd->magic != DGAP_BOARD_MAGIC)) { + done = 0; + *lenp = 0; + return 0; + } + + bn = brd->boardnum; + + /* + * For each board, output the device information in + * a handy table format... + */ + p += sprintf(p, "# NAME\t\tMAJOR\tMINOR\tCOUNT\tSTART\n"); + + + for (cptr = brd->bd_config; cptr; cptr = cptr->next) { + + if ((cptr->type == BNODE) && + ((cptr->u.board.type == APORT2_920P) || (cptr->u.board.type == APORT4_920P) || + (cptr->u.board.type == APORT8_920P) || (cptr->u.board.type == PAPORT4) || + (cptr->u.board.type == PAPORT8))) { + + found = TRUE; + if (cptr->u.board.v_start) + starto = cptr->u.board.start; + else + starto = 1; + } + + if (cptr->type == TNODE && found == TRUE) { + char *ptr1; + if (strstr(cptr->u.ttyname, "tty")) { + ptr1 = cptr->u.ttyname; + ptr1 += 3; + } + else { + ptr1 = cptr->u.ttyname; + } + + /* TTY devices */ + p += sprintf(p, "tty%s\t\t%d\t%d\t%d\t%d\n", + ptr1, brd->SerialDriver->major, + 0, dgap_config_get_number_of_ports(brd), starto); + + /* PR devices */ + p += sprintf(p, "pr%s\t\t%d\t%d\t%d\t%d\n", + ptr1, brd->PrintDriver->major, + 0, dgap_config_get_number_of_ports(brd), starto); + } + + if (cptr->type == CNODE) { + + /* TTY devices */ + p += sprintf(p, "tty%s\t\t%d\t%d\t%d\t%d\n", + cptr->u.conc.id, brd->SerialDriver->major, + ncount, cptr->u.conc.nport, + cptr->u.conc.v_start ? cptr->u.conc.start : 1); + + /* PR devices */ + p += sprintf(p, "pr%s\t\t%d\t%d\t%d\t%d\n", + cptr->u.conc.id, brd->PrintDriver->major, + ncount, cptr->u.conc.nport, + cptr->u.conc.v_start ? cptr->u.conc.start : 1); + + ncount += cptr->u.conc.nport; + } + + if (cptr->type == MNODE) { + + /* TTY devices */ + p += sprintf(p, "tty%s\t\t%d\t%d\t%d\t%d\n", + cptr->u.module.id, brd->SerialDriver->major, + ncount, cptr->u.module.nport, + cptr->u.module.v_start ? cptr->u.module.start : 1); + + /* PR devices */ + p += sprintf(p, "pr%s\t\t%d\t%d\t%d\t%d\n", + cptr->u.module.id, brd->PrintDriver->major, + ncount, cptr->u.module.nport, + cptr->u.module.v_start ? cptr->u.module.start : 1); + + ncount += cptr->u.module.nport; + + } + } + + if (copy_to_user(buffer, buf, (p - (char *) buf))) + return -EFAULT; + + *lenp = p - (char *) buf; + *ppos += p - (char *) buf; + done = 1; + return 0; +} + + + + + +/* + * Return what is (hopefully) useful information about the specific channel. + */ +static int dgap_read_channel_info(struct dgap_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos) +{ + struct channel_t *ch; + static int done = 0; + static char buf[4096]; + char *p = buf; + + DPR_PROC(("dgap_proc_info\n")); + + ch = (struct channel_t *) table->data; + + if (done || !ch || (ch->magic != DGAP_CHANNEL_MAGIC)) { + done = 0; + *lenp = 0; + return 0; + } + + p += sprintf(p, "Port number:\t\t%d\n", ch->ch_portnum); + p += sprintf(p, "\n"); + + /* Prepare the Header Labels */ + p += sprintf(p, "%10s %23s %10s\n", + "Chars Rx", " Rx Par--Brk--Frm--Ovr", "Chars Tx"); + p += sprintf(p, "%10ld ", ch->ch_rxcount); + p += sprintf(p, " %4ld %4ld %4ld %4ld ", ch->ch_err_parity, + ch->ch_err_break, ch->ch_err_frame, ch->ch_err_overrun); + p += sprintf(p, "%10ld ", ch->ch_txcount); + p += sprintf(p, "\n\n"); + + /* Prepare the Header Labels */ + p += sprintf(p, "%5s %5s %5s %5s %5s %10s Line Status Flags\n", + "CFlag", "IFlag", "OFlag", "LFlag", "DFlag", "Baud"); + + p += sprintf(p, "%5x ", ch->ch_c_cflag); + p += sprintf(p, "%5x ", ch->ch_c_iflag); + p += sprintf(p, "%5x ", ch->ch_c_oflag); + p += sprintf(p, "%5x ", ch->ch_c_lflag); + p += sprintf(p, "%5x ", ch->ch_digi.digi_flags); + p += sprintf(p, "%10d ", ch->ch_baud_info); + if (!ch->ch_open_count) { + p += sprintf(p, " -- -- -- -- -- -- --") ; + } else { + p += sprintf(p, " op %s %s %s %s %s %s", + (ch->ch_mostat & UART_MCR_RTS) ? "rs" : "--", + (ch->ch_mistat & UART_MSR_CTS) ? "cs" : "--", + (ch->ch_mostat & UART_MCR_DTR) ? "tr" : "--", + (ch->ch_mistat & UART_MSR_DSR) ? "mr" : "--", + (ch->ch_mistat & UART_MSR_DCD) ? "cd" : "--", + (ch->ch_mistat & UART_MSR_RI) ? "ri" : "--"); + } + p += sprintf(p, "\n\n"); + + if (copy_to_user(buffer, buf, (p - (char *) buf))) + return -EFAULT; + + *lenp = p - (char *) buf; + *ppos += p - (char *) buf; + done = 1; + return 0; +} + + +/* + * Return mknod information for the board's devices. + */ +static int dgap_read_channel_custom_ttyname(struct dgap_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos) +{ + struct channel_t *ch; + struct board_t *brd; + static int done = 0; + static char buf[4096]; + char *p = buf; + + int cn; + int bn; + struct cnode *cptr = NULL; + int found = FALSE; + int ncount = 0; + int starto = 0; + int i = 0; + + DPR_PROC(("dgap_proc_brd_info\n")); + + ch = (struct channel_t *) table->data; + + if (done || !ch || (ch->magic != DGAP_CHANNEL_MAGIC)) { + done = 0; + *lenp = 0; + return 0; + } + + brd = ch->ch_bd; + + if (done || !brd || (brd->magic != DGAP_BOARD_MAGIC)) { + done = 0; + *lenp = 0; + return 0; + } + + bn = brd->boardnum; + cn = ch->ch_portnum; + + /* + * For each board, output the device information in + * a handy table format... + */ + + for (cptr = brd->bd_config; cptr; cptr = cptr->next) { + + if ((cptr->type == BNODE) && + ((cptr->u.board.type == APORT2_920P) || (cptr->u.board.type == APORT4_920P) || + (cptr->u.board.type == APORT8_920P) || (cptr->u.board.type == PAPORT4) || + (cptr->u.board.type == PAPORT8))) { + + found = TRUE; + if (cptr->u.board.v_start) + starto = cptr->u.board.start; + else + starto = 1; + } + + if (cptr->type == TNODE && found == TRUE) { + char *ptr1; + if (strstr(cptr->u.ttyname, "tty")) { + ptr1 = cptr->u.ttyname; + ptr1 += 3; + } + else { + ptr1 = cptr->u.ttyname; + } + + for (i = 0; i < dgap_config_get_number_of_ports(brd); i++) { + if (cn == i) { + p += sprintf(p, "tty%s%02d\n", + ptr1, i + starto); + } + } + } + + if (cptr->type == CNODE) { + + for (i = 0; i < cptr->u.conc.nport; i++) { + if (cn == (i + ncount)) { + p += sprintf(p, "tty%s%02d\n", cptr->u.conc.id, + i + (cptr->u.conc.v_start ? cptr->u.conc.start : 1)); + } + } + + ncount += cptr->u.conc.nport; + } + + if (cptr->type == MNODE) { + + for (i = 0; i < cptr->u.module.nport; i++) { + if (cn == (i + ncount)) { + p += sprintf(p, "tty%s%02d\n", cptr->u.module.id, + i + (cptr->u.module.v_start ? cptr->u.module.start : 1)); + } + } + + ncount += cptr->u.module.nport; + + } + } + + if (copy_to_user(buffer, buf, (p - (char *) buf))) + return -EFAULT; + + *lenp = p - (char *) buf; + *ppos += p - (char *) buf; + done = 1; + return 0; +} + + +/* + * Return mknod information for the board's devices. + */ +static int dgap_read_channel_custom_prname(struct dgap_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos) +{ + struct channel_t *ch; + struct board_t *brd; + static int done = 0; + static char buf[4096]; + char *p = buf; + + int cn; + int bn; + struct cnode *cptr = NULL; + int found = FALSE; + int ncount = 0; + int starto = 0; + int i = 0; + + DPR_PROC(("dgap_proc_brd_info\n")); + + ch = (struct channel_t *) table->data; + + if (done || !ch || (ch->magic != DGAP_CHANNEL_MAGIC)) { + done = 0; + *lenp = 0; + return 0; + } + + brd = ch->ch_bd; + + if (done || !brd || (brd->magic != DGAP_BOARD_MAGIC)) { + done = 0; + *lenp = 0; + return 0; + } + + bn = brd->boardnum; + cn = ch->ch_portnum; + + /* + * For each board, output the device information in + * a handy table format... + */ + + for (cptr = brd->bd_config; cptr; cptr = cptr->next) { + + if ((cptr->type == BNODE) && + ((cptr->u.board.type == APORT2_920P) || (cptr->u.board.type == APORT4_920P) || + (cptr->u.board.type == APORT8_920P) || (cptr->u.board.type == PAPORT4) || + (cptr->u.board.type == PAPORT8))) { + + found = TRUE; + if (cptr->u.board.v_start) + starto = cptr->u.board.start; + else + starto = 1; + } + + if (cptr->type == TNODE && found == TRUE) { + char *ptr1; + if (strstr(cptr->u.ttyname, "tty")) { + ptr1 = cptr->u.ttyname; + ptr1 += 3; + } + else { + ptr1 = cptr->u.ttyname; + } + + for (i = 0; i < dgap_config_get_number_of_ports(brd); i++) { + if (cn == i) { + p += sprintf(p, "pr%s%02d\n", + ptr1, i + starto); + } + } + } + + if (cptr->type == CNODE) { + + for (i = 0; i < cptr->u.conc.nport; i++) { + if (cn == (i + ncount)) { + p += sprintf(p, "pr%s%02d\n", cptr->u.conc.id, + i + (cptr->u.conc.v_start ? cptr->u.conc.start : 1)); + } + } + + ncount += cptr->u.conc.nport; + } + + if (cptr->type == MNODE) { + + for (i = 0; i < cptr->u.module.nport; i++) { + if (cn == (i + ncount)) { + p += sprintf(p, "pr%s%02d\n", cptr->u.module.id, + i + (cptr->u.module.v_start ? cptr->u.module.start : 1)); + } + } + + ncount += cptr->u.module.nport; + + } + } + + if (copy_to_user(buffer, buf, (p - (char *) buf))) + return -EFAULT; + + *lenp = p - (char *) buf; + *ppos += p - (char *) buf; + done = 1; + return 0; +} + + + + + +static int dgap_open_channel_sniff(struct dgap_proc_entry *table, int dir, struct file *filp, + void *buffer, ssize_t *lenp, loff_t *ppos) +{ + struct channel_t *ch; + ulong lock_flags; + + ch = (struct channel_t *) table->data; + + if (!ch || (ch->magic != DGAP_CHANNEL_MAGIC)) + return 0; + + ch->ch_sniff_buf = dgap_driver_kzmalloc(SNIFF_MAX, GFP_KERNEL); + + DGAP_LOCK(ch->ch_lock, lock_flags); + ch->ch_sniff_flags |= SNIFF_OPEN; + DGAP_UNLOCK(ch->ch_lock, lock_flags); + + return 0; +} + +static int dgap_close_channel_sniff(struct dgap_proc_entry *table, int dir, struct file *filp, + void *buffer, ssize_t *lenp, loff_t *ppos) +{ + struct channel_t *ch; + ulong lock_flags; + + ch = (struct channel_t *) table->data; + + if (!ch || (ch->magic != DGAP_CHANNEL_MAGIC)) + return 0; + + DGAP_LOCK(ch->ch_lock, lock_flags); + ch->ch_sniff_flags &= ~(SNIFF_OPEN); + kfree(ch->ch_sniff_buf); + DGAP_UNLOCK(ch->ch_lock, lock_flags); + + return 0; +} + + +/* + * Copy data from the monitoring buffer to the user, freeing space + * in the monitoring buffer for more messages + * + */ +static int dgap_read_channel_sniff(struct dgap_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos) +{ + struct channel_t *ch; + int n; + int r; + int offset = 0; + int res = 0; + ssize_t rtn = 0; + ulong lock_flags; + + ch = (struct channel_t *) table->data; + + if (!ch || (ch->magic != DGAP_CHANNEL_MAGIC)) { + rtn = -ENXIO; + goto done; + } + + /* + * Wait for some data to appear in the buffer. + */ + DGAP_LOCK(ch->ch_lock, lock_flags); + + for (;;) { + n = (ch->ch_sniff_in - ch->ch_sniff_out) & SNIFF_MASK; + + if (n != 0) + break; + + ch->ch_sniff_flags |= SNIFF_WAIT_DATA; + + DGAP_UNLOCK(ch->ch_lock, lock_flags); + + /* + * Go to sleep waiting until the condition becomes true. + */ + rtn = wait_event_interruptible(ch->ch_sniff_wait, + ((ch->ch_sniff_flags & SNIFF_WAIT_DATA) == 0)); + + if (rtn) + goto done; + + DGAP_LOCK(ch->ch_lock, lock_flags); + } + + /* + * Read whatever is there. + */ + + if (n > *lenp) + n = *lenp; + + res = n; + + r = SNIFF_MAX - ch->ch_sniff_out; + + if (r <= n) { + DGAP_UNLOCK(ch->ch_lock, lock_flags); + rtn = copy_to_user(buffer, ch->ch_sniff_buf + ch->ch_sniff_out, r); + if (rtn) { + rtn = -EFAULT; + goto done; + } + + DGAP_LOCK(ch->ch_lock, lock_flags); + + ch->ch_sniff_out = 0; + n -= r; + offset = r; + } + + DGAP_UNLOCK(ch->ch_lock, lock_flags); + rtn = copy_to_user(buffer + offset, ch->ch_sniff_buf + ch->ch_sniff_out, n); + if (rtn) { + rtn = -EFAULT; + goto done; + } + DGAP_LOCK(ch->ch_lock, lock_flags); + + ch->ch_sniff_out += n; + *ppos += res; + rtn = res; +// rtn = 0; + + /* + * Wakeup any thread waiting for buffer space. + */ + + if (ch->ch_sniff_flags & SNIFF_WAIT_SPACE) { + ch->ch_sniff_flags &= ~SNIFF_WAIT_SPACE; + wake_up_interruptible(&ch->ch_sniff_wait); + } + + DGAP_UNLOCK(ch->ch_lock, lock_flags); + +done: + return rtn; +} + + +static int dgap_read_channel_fepstate(struct dgap_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos) +{ + struct channel_t *ch; + static int done = 0; + static char buf[4096]; + char *p = buf; + + DPR_PROC(("dgap_proc_info\n")); + + ch = (struct channel_t *) table->data; + + if (done || !ch || (ch->magic != DGAP_CHANNEL_MAGIC) || (ch->ch_bd->state != BOARD_READY)) { + done = 0; + *lenp = 0; + return 0; + } + + p += sprintf(p, "Port number: %d\n", ch->ch_portnum); + p += sprintf(p, "\n"); + + p += sprintf(p, "\tTPJMP:\t%x\n", ch->ch_bs->tp_jmp); + p += sprintf(p, "\tTCJMP:\t%x\n", ch->ch_bs->tc_jmp); + p += sprintf(p, "\tTPJMP:\t%x\n", ch->ch_bs->ri_jmp); + p += sprintf(p, "\tRPJMP:\t%x\n", ch->ch_bs->rp_jmp); + + p += sprintf(p, "\tTSEG:\t%x\n", ch->ch_bs->tx_seg); + p += sprintf(p, "\tTIN:\t%x\n", ch->ch_bs->tx_head); + p += sprintf(p, "\tTOUT:\t%x\n", ch->ch_bs->tx_tail); + p += sprintf(p, "\tTMAX:\t%x\n", ch->ch_bs->tx_max); + + p += sprintf(p, "\tRSEG:\t%x\n", ch->ch_bs->rx_seg); + p += sprintf(p, "\tRIN:\t%x\n", ch->ch_bs->rx_head); + p += sprintf(p, "\tROUT:\t%x\n", ch->ch_bs->rx_tail); + p += sprintf(p, "\tRMAX:\t%x\n", ch->ch_bs->rx_max); + + p += sprintf(p, "\tTLOW:\t%x\n", ch->ch_bs->tx_lw); + p += sprintf(p, "\tRLOW:\t%x\n", ch->ch_bs->rx_lw); + p += sprintf(p, "\tRHIGH:\t%x\n", ch->ch_bs->rx_hw); + p += sprintf(p, "\tINCR:\t%x\n", ch->ch_bs->incr); + + p += sprintf(p, "\tDEV:\t%x\n", ch->ch_bs->fepdev); + p += sprintf(p, "\tEDELAY:\t%x\n", ch->ch_bs->edelay); + p += sprintf(p, "\tBLEN:\t%x\n", ch->ch_bs->blen); + p += sprintf(p, "\tBTIME:\t%x\n", ch->ch_bs->btime); + + p += sprintf(p, "\tIFLAG:\t%x\n", ch->ch_bs->iflag); + p += sprintf(p, "\tOFLAG:\t%x\n", ch->ch_bs->oflag); + p += sprintf(p, "\tCFLAG:\t%x\n", ch->ch_bs->cflag); + + p += sprintf(p, "\tNUM:\t%x\n", ch->ch_bs->num); + p += sprintf(p, "\tRACT:\t%x\n", ch->ch_bs->ract); + p += sprintf(p, "\tBSTAT:\t%x\n", ch->ch_bs->bstat); + p += sprintf(p, "\tTBUSY:\t%x\n", ch->ch_bs->tbusy); + p += sprintf(p, "\tIEMPTY:\t%x\n", ch->ch_bs->iempty); + p += sprintf(p, "\tILOW:\t%x\n", ch->ch_bs->ilow); + p += sprintf(p, "\tIDATA:\t%x\n", ch->ch_bs->idata); + p += sprintf(p, "\tEFLAG:\t%x\n", ch->ch_bs->eflag); + + p += sprintf(p, "\tTFLAG:\t%x\n", ch->ch_bs->tflag); + p += sprintf(p, "\tRFLAG:\t%x\n", ch->ch_bs->rflag); + p += sprintf(p, "\tXMASK:\t%x\n", ch->ch_bs->xmask); + p += sprintf(p, "\tXVAL:\t%x\n", ch->ch_bs->xval); + p += sprintf(p, "\tMSTAT:\t%x\n", ch->ch_bs->m_stat); + p += sprintf(p, "\tEFMASK:\t%x\n", ch->ch_bs->m_change); + p += sprintf(p, "\tMINT:\t%x\n", ch->ch_bs->m_int); + p += sprintf(p, "\tLSTAT:\t%x\n", ch->ch_bs->m_last); + + p += sprintf(p, "\tMTRAN:\t%x\n", ch->ch_bs->mtran); + p += sprintf(p, "\tORUN:\t%x\n", ch->ch_bs->orun); + p += sprintf(p, "\tSTARTCA:%x\n", ch->ch_bs->astartc); + p += sprintf(p, "\tSTOPCA:\t%x\n", ch->ch_bs->astopc); + p += sprintf(p, "\tSTARTC\t%x\n", ch->ch_bs->startc); + p += sprintf(p, "\tSTOPC:\t%x\n", ch->ch_bs->stopc); + p += sprintf(p, "\tVNEXT:\t%x\n", ch->ch_bs->vnextc); + p += sprintf(p, "\tHFLOW:\t%x\n", ch->ch_bs->hflow); + p += sprintf(p, "\tFILLC:\t%x\n", ch->ch_bs->fillc); + p += sprintf(p, "\tOCHAR:\t%x\n", ch->ch_bs->ochar); + p += sprintf(p, "\tOMASK:\t%x\n", ch->ch_bs->omask); + + if (copy_to_user(buffer, buf, (p - (char *) buf))) + return -EFAULT; + + *lenp = p - (char *) buf; + *ppos += p - (char *) buf; + done = 1; + return 0; +} + + +/* + * Register the basic /proc/dgap files that appear whenever + * the driver is loaded. + */ +void dgap_proc_register_basic_prescan(void) +{ + int i; + + /* Initialize semaphores in each table slot */ + for (i = 0; i < DGAP_MAX_PROC_ENTRIES; i++) { + if (!dgap_table[i].magic) { + break; + } + init_MUTEX(&(dgap_table[i].excl_sem)); + } + + /* + * Register /proc/dgap + */ + ProcDGAP = proc_create("dgap", (0700 | S_IFDIR), NULL, &dgap_proc_file_ops); + dgap_register_proc_table(dgap_table, ProcDGAP); +} + + +/* + * Register the basic /proc/dgap files that appear whenever + * the driver is loaded. + */ +void dgap_proc_register_basic_postscan(int board_num) +{ + int i; + char board[10]; + sprintf(board, "%d", board_num); + + /* Set proc board entry pointer */ + dgap_Board[board_num]->proc_entry_pointer = create_proc_entry(board, (0700 | S_IFDIR), ProcDGAP); + + /* Create a new copy of the board_table... */ + dgap_Board[board_num]->dgap_board_table = dgap_driver_kzmalloc(sizeof(dgap_board_table), + GFP_KERNEL); + + /* Now copy the default table into that memory */ + memcpy(dgap_Board[board_num]->dgap_board_table, dgap_board_table, sizeof(dgap_board_table)); + + /* Initialize semaphores in each table slot */ + for (i = 0; i < DGAP_MAX_PROC_ENTRIES; i++) { + if (!dgap_Board[board_num]->dgap_board_table[i].magic) { + break; + } + + init_MUTEX(&(dgap_Board[board_num]->dgap_board_table[i].excl_sem)); + dgap_Board[board_num]->dgap_board_table[i].data = dgap_Board[board_num]; + + } + + /* Register board table into proc */ + dgap_register_proc_table(dgap_Board[board_num]->dgap_board_table, + dgap_Board[board_num]->proc_entry_pointer); +} + + +/* + * Register the channel /proc/dgap files that appear whenever + * the driver is loaded. + */ +void dgap_proc_register_channel_postscan(int board_num) +{ + int i, j; + + /* + * Add new entries for each port. + */ + for (i = 0; i < dgap_Board[board_num]->nasync; i++) { + + char channel[10]; + sprintf(channel, "%d", i); + + /* Set proc channel entry pointer */ + dgap_Board[board_num]->channels[i]->proc_entry_pointer = + create_proc_entry(channel, (0700 | S_IFDIR), + dgap_Board[board_num]->proc_entry_pointer); + + /* Create a new copy of the channel_table... */ + dgap_Board[board_num]->channels[i]->dgap_channel_table = + dgap_driver_kzmalloc(sizeof(dgap_channel_table), GFP_KERNEL); + + /* Now copy the default table into that memory */ + memcpy(dgap_Board[board_num]->channels[i]->dgap_channel_table, + dgap_channel_table, sizeof(dgap_channel_table)); + + /* Initialize semaphores in each table slot */ + for (j = 0; j < DGAP_MAX_PROC_ENTRIES; j++) { + if (!dgap_Board[board_num]->channels[i]->dgap_channel_table[j].magic) { + break; + } + + init_MUTEX(&(dgap_Board[board_num]->channels[i]->dgap_channel_table[j].excl_sem)); + dgap_Board[board_num]->channels[i]->dgap_channel_table[j].data = + dgap_Board[board_num]->channels[i]; + } + + /* Register channel table into proc */ + dgap_register_proc_table(dgap_Board[board_num]->channels[i]->dgap_channel_table, + dgap_Board[board_num]->channels[i]->proc_entry_pointer); + } +} + + +static void dgap_remove_proc_entry(struct proc_dir_entry *pde) +{ + if (!pde) { + DPR_PROC(("dgap_remove_proc_entry... NULL entry... not removing...\n")); + return; + } + + remove_proc_entry(pde->name, pde->parent); +} + + +void dgap_proc_unregister_all(void) +{ + int i = 0, j = 0; + + /* Walk each board, blowing away their proc entries... */ + for (i = 0; i < dgap_NumBoards; i++) { + + /* Walk each channel, blowing away their proc entries... */ + for (j = 0; j < dgap_Board[i]->nasync; j++) { + + if (dgap_Board[i]->channels[j]->dgap_channel_table) { + dgap_unregister_proc_table(dgap_Board[i]->channels[j]->dgap_channel_table, + dgap_Board[i]->channels[j]->proc_entry_pointer); + dgap_remove_proc_entry(dgap_Board[i]->channels[j]->proc_entry_pointer); + kfree(dgap_Board[i]->channels[j]->dgap_channel_table); + } + } + + if (dgap_Board[i]->dgap_board_table) { + dgap_unregister_proc_table(dgap_Board[i]->dgap_board_table, + dgap_Board[i]->proc_entry_pointer); + dgap_remove_proc_entry(dgap_Board[i]->proc_entry_pointer); + kfree(dgap_Board[i]->dgap_board_table); + } + } + + /* Blow away the top proc entry */ + dgap_unregister_proc_table(dgap_table, ProcDGAP); + dgap_remove_proc_entry(ProcDGAP); +} diff --git a/drivers/staging/dgap/dgap_proc.h b/drivers/staging/dgap/dgap_proc.h new file mode 100644 index 0000000000000..9970d28816eec --- /dev/null +++ b/drivers/staging/dgap/dgap_proc.h @@ -0,0 +1,151 @@ +/* + * Copyright 2003 Digi International (www.digi.com) + * Scott H Kilau + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! + * + * + * $Id: dgap_proc.h,v 1.1 2009/10/23 14:01:57 markh Exp $ + * + * Description: + * + * Describes the private structures used to manipulate the "special" + * proc constructs (not read-only) used by the Digi Neo software. + * The concept is borrowed heavily from the "sysctl" interface of + * the kernel. I decided not to use the structures and functions + * provided by the kernel for two reasons: + * + * 1. Due to the planned use of "/proc" in the Neo driver, many + * of the functions of the "sysctl" interface would go unused. + * A simpler interface will be easier to maintain. + * + * 2. I'd rather divorce our "added package" from the kernel internals. + * If the "sysctl" structures should change, I will be insulated + * from those changes. These "/proc" entries won't be under the + * "sys" tree anyway, so there is no need to maintain a strict + * dependence relationship. + * + * Author: + * + * Scott H Kilau + * + */ + +#ifndef _DGAP_RW_PROC_H +#define _DGAP_RW_PROC_H + +/* + * The list of DGAP entries with r/w capabilities. + * These magic numbers are used for identification purposes. + */ +enum { + DGAP_INFO = 1, /* Get info about the running module */ + DGAP_MKNOD = 2, /* Get info about driver devices */ + DGAP_BOARD_INFO = 3, /* Get info about the specific board */ + DGAP_BOARD_VPD = 4, /* Get info about the board's VPD */ + DGAP_BOARD_VPDDATA = 5, /* Get info about the board's VPD */ + DGAP_BOARD_TTYSTATS = 6, /* Get info about the board's tty stats */ + DGAP_BOARD_TTYFLAGS = 7, /* Get info about the board's tty flags */ + DGAP_BOARD_MKNOD = 8, /* Get info about board devices */ + DGAP_PORT_INFO = 9, /* Get info about the specific port */ + DGAP_PORT_SNIFF = 10, /* Sniff data in/out of specific port */ + DGAP_PORT_CUSTOM_TTYNAME = 11, /* Get info about UDEV tty name */ + DGAP_PORT_CUSTOM_PRNAME = 12, /* Get info about UDEV pr name */ + DGAP_PORT_FEPSTATE = 13, /* Get info about Ports FEP state */ +}; + +#define DGAP_MAX_PROC_ENTRIES 999 + +/* + * Directions for proc handlers + */ +enum { + INBOUND = 1, /* Data being written to kernel */ + OUTBOUND = 2, /* Data being read from the kernel */ +}; + +/* + * Each entry in a DGAP proc directory is described with a + * "dgap_proc_entry" structure. A collection of these + * entries (in an array) represents the members associated + * with a particular "/proc" directory, and is referred to + * as a table. All "tables" are terminated by an entry with + * zeros for every member. + * + * The structure members are as follows: + * + * int magic -- ID number associated with this particular + * entry. Should be unique across all of + * DGAP. + * + * const char *name -- ASCII name associated with the /proc entry. + * + * mode_t mode -- File access permisssions for the /proc entry. + * + * dgap_proc_entry *child -- When set, this entry refers to a directory, + * and points to the table which describes the + * entries in the subdirectory + * + * dgap_proc_handler *open_handler -- When set, points to the fxn which + * does any "extra" open stuff. + * + * dgap_proc_handler *close_handler -- When set, points to the fxn which + * does any "extra" close stuff. + * + * dgap_proc_handler *read_handler -- When set, points to the fxn which + * handle outbound data flow + * + * dgap_proc_handler *write_handler -- When set, points to the fxn which + * handles inbound data flow + * + * struct proc_dir_entry *de -- Pointer to the directory entry for this + * object once registered. Used to grab + * the handle of the object for + * unregistration + * + * void *data; When set, points to the parent structure + * + */ + +struct dgap_proc_entry { + int magic; /* Integer identifier */ + const char *name; /* ASCII identifier */ + mode_t mode; /* File access permissions */ + struct dgap_proc_entry *child; /* Child pointer */ + + int (*open_handler) (struct dgap_proc_entry *table, int dir, struct file *filp, + void *buffer, ssize_t *lenp, loff_t *ppos); + int (*close_handler) (struct dgap_proc_entry *table, int dir, struct file *filp, + void *buffer, ssize_t *lenp, loff_t *ppos); + int (*read_handler) (struct dgap_proc_entry *table, int dir, struct file *filp, + char __user *buffer, ssize_t *lenp, loff_t *ppos); + int (*write_handler) (struct dgap_proc_entry *table, int dir, struct file *filp, + const char __user *buffer, ssize_t *lenp, loff_t *ppos); + + struct proc_dir_entry *de; /* proc entry pointer */ + struct semaphore excl_sem; /* Protects exclusive access var */ + int excl_cnt; /* Counts number of curr accesses */ + void *data; /* Allows storing a pointer to parent */ +}; + + +void dgap_proc_register_basic_prescan(void); +void dgap_proc_unregister_all(void); +void dgap_proc_register_basic_postscan(int board_num); +void dgap_proc_register_channel_postscan(int board_num); + +#endif /* _DGAP_RW_PROC_H */ diff --git a/drivers/staging/dgap/dgap_sysfs.c b/drivers/staging/dgap/dgap_sysfs.c new file mode 100644 index 0000000000000..6f98ac6248305 --- /dev/null +++ b/drivers/staging/dgap/dgap_sysfs.c @@ -0,0 +1,796 @@ +/* + * Copyright 2004 Digi International (www.digi.com) + * Scott H Kilau + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * + * NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE! + * + * This is shared code between Digi's CVS archive and the + * Linux Kernel sources. + * Changing the source just for reformatting needlessly breaks + * our CVS diff history. + * + * Send any bug fixes/changes to: Eng.Linux at digi dot com. + * Thank you. + * + * + * + * $Id: dgap_sysfs.c,v 1.1 2009/10/23 14:01:57 markh Exp $ + */ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "dgap_driver.h" +#include "dgap_proc.h" +#include "dgap_mgmt.h" +#include "dgap_conf.h" +#include "dgap_parse.h" + + +static ssize_t dgap_driver_version_show(struct device_driver *ddp, char *buf) +{ + return snprintf(buf, PAGE_SIZE, "%s\n", DG_PART); +} +static DRIVER_ATTR(version, S_IRUSR, dgap_driver_version_show, NULL); + + +static ssize_t dgap_driver_boards_show(struct device_driver *ddp, char *buf) +{ + return snprintf(buf, PAGE_SIZE, "%d\n", dgap_NumBoards); +} +static DRIVER_ATTR(boards, S_IRUSR, dgap_driver_boards_show, NULL); + + +static ssize_t dgap_driver_maxboards_show(struct device_driver *ddp, char *buf) +{ + return snprintf(buf, PAGE_SIZE, "%d\n", MAXBOARDS); +} +static DRIVER_ATTR(maxboards, S_IRUSR, dgap_driver_maxboards_show, NULL); + + +static ssize_t dgap_driver_pollcounter_show(struct device_driver *ddp, char *buf) +{ + return snprintf(buf, PAGE_SIZE, "%ld\n", dgap_poll_counter); +} +static DRIVER_ATTR(pollcounter, S_IRUSR, dgap_driver_pollcounter_show, NULL); + + +static ssize_t dgap_driver_state_show(struct device_driver *ddp, char *buf) +{ + return snprintf(buf, PAGE_SIZE, "%s\n", dgap_driver_state_text[dgap_driver_state]); +} +static DRIVER_ATTR(state, S_IRUSR, dgap_driver_state_show, NULL); + + +static ssize_t dgap_driver_debug_show(struct device_driver *ddp, char *buf) +{ + return snprintf(buf, PAGE_SIZE, "0x%x\n", dgap_debug); +} + +static ssize_t dgap_driver_debug_store(struct device_driver *ddp, const char *buf, size_t count) +{ + sscanf(buf, "0x%x\n", &dgap_debug); + return count; +} +static DRIVER_ATTR(debug, (S_IRUSR | S_IWUSR), dgap_driver_debug_show, dgap_driver_debug_store); + + +static ssize_t dgap_driver_rawreadok_show(struct device_driver *ddp, char *buf) +{ + return snprintf(buf, PAGE_SIZE, "0x%x\n", dgap_rawreadok); +} + +static ssize_t dgap_driver_rawreadok_store(struct device_driver *ddp, const char *buf, size_t count) +{ + sscanf(buf, "0x%x\n", &dgap_rawreadok); + return count; +} +static DRIVER_ATTR(rawreadok, (S_IRUSR | S_IWUSR), dgap_driver_rawreadok_show, dgap_driver_rawreadok_store); + + +static ssize_t dgap_driver_pollrate_show(struct device_driver *ddp, char *buf) +{ + return snprintf(buf, PAGE_SIZE, "%dms\n", dgap_poll_tick); +} + +static ssize_t dgap_driver_pollrate_store(struct device_driver *ddp, const char *buf, size_t count) +{ + sscanf(buf, "%d\n", &dgap_poll_tick); + return count; +} +static DRIVER_ATTR(pollrate, (S_IRUSR | S_IWUSR), dgap_driver_pollrate_show, dgap_driver_pollrate_store); + + +void dgap_create_driver_sysfiles(struct pci_driver *dgap_driver) +{ + int rc = 0; + struct device_driver *driverfs = &dgap_driver->driver; + + rc |= driver_create_file(driverfs, &driver_attr_version); + rc |= driver_create_file(driverfs, &driver_attr_boards); + rc |= driver_create_file(driverfs, &driver_attr_maxboards); + rc |= driver_create_file(driverfs, &driver_attr_debug); + rc |= driver_create_file(driverfs, &driver_attr_rawreadok); + rc |= driver_create_file(driverfs, &driver_attr_pollrate); + rc |= driver_create_file(driverfs, &driver_attr_pollcounter); + rc |= driver_create_file(driverfs, &driver_attr_state); + if (rc) { + printk(KERN_ERR "DGAP: sysfs driver_create_file failed!\n"); + } +} + + +void dgap_remove_driver_sysfiles(struct pci_driver *dgap_driver) +{ + struct device_driver *driverfs = &dgap_driver->driver; + driver_remove_file(driverfs, &driver_attr_version); + driver_remove_file(driverfs, &driver_attr_boards); + driver_remove_file(driverfs, &driver_attr_maxboards); + driver_remove_file(driverfs, &driver_attr_debug); + driver_remove_file(driverfs, &driver_attr_rawreadok); + driver_remove_file(driverfs, &driver_attr_pollrate); + driver_remove_file(driverfs, &driver_attr_pollcounter); + driver_remove_file(driverfs, &driver_attr_state); +} + + +#define DGAP_VERIFY_BOARD(p, bd) \ + if (!p) \ + return (0); \ + \ + bd = dev_get_drvdata(p); \ + if (!bd || bd->magic != DGAP_BOARD_MAGIC) \ + return (0); \ + if (bd->state != BOARD_READY) \ + return (0); \ + + +static ssize_t dgap_ports_state_show(struct device *p, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + int count = 0; + int i = 0; + + DGAP_VERIFY_BOARD(p, bd); + + for (i = 0; i < bd->nasync; i++) { + count += snprintf(buf + count, PAGE_SIZE - count, + "%d %s\n", bd->channels[i]->ch_portnum, + bd->channels[i]->ch_open_count ? "Open" : "Closed"); + } + return count; +} +static DEVICE_ATTR(ports_state, S_IRUSR, dgap_ports_state_show, NULL); + + +static ssize_t dgap_ports_baud_show(struct device *p, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + int count = 0; + int i = 0; + + DGAP_VERIFY_BOARD(p, bd); + + for (i = 0; i < bd->nasync; i++) { + count += snprintf(buf + count, PAGE_SIZE - count, + "%d %d\n", bd->channels[i]->ch_portnum, bd->channels[i]->ch_baud_info); + } + return count; +} +static DEVICE_ATTR(ports_baud, S_IRUSR, dgap_ports_baud_show, NULL); + + +static ssize_t dgap_ports_msignals_show(struct device *p, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + int count = 0; + int i = 0; + + DGAP_VERIFY_BOARD(p, bd); + + for (i = 0; i < bd->nasync; i++) { + if (bd->channels[i]->ch_open_count) { + count += snprintf(buf + count, PAGE_SIZE - count, + "%d %s %s %s %s %s %s\n", bd->channels[i]->ch_portnum, + (bd->channels[i]->ch_mostat & UART_MCR_RTS) ? "RTS" : "", + (bd->channels[i]->ch_mistat & UART_MSR_CTS) ? "CTS" : "", + (bd->channels[i]->ch_mostat & UART_MCR_DTR) ? "DTR" : "", + (bd->channels[i]->ch_mistat & UART_MSR_DSR) ? "DSR" : "", + (bd->channels[i]->ch_mistat & UART_MSR_DCD) ? "DCD" : "", + (bd->channels[i]->ch_mistat & UART_MSR_RI) ? "RI" : ""); + } else { + count += snprintf(buf + count, PAGE_SIZE - count, + "%d\n", bd->channels[i]->ch_portnum); + } + } + return count; +} +static DEVICE_ATTR(ports_msignals, S_IRUSR, dgap_ports_msignals_show, NULL); + + +static ssize_t dgap_ports_iflag_show(struct device *p, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + int count = 0; + int i = 0; + + DGAP_VERIFY_BOARD(p, bd); + + for (i = 0; i < bd->nasync; i++) { + count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n", + bd->channels[i]->ch_portnum, bd->channels[i]->ch_c_iflag); + } + return count; +} +static DEVICE_ATTR(ports_iflag, S_IRUSR, dgap_ports_iflag_show, NULL); + + +static ssize_t dgap_ports_cflag_show(struct device *p, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + int count = 0; + int i = 0; + + DGAP_VERIFY_BOARD(p, bd); + + for (i = 0; i < bd->nasync; i++) { + count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n", + bd->channels[i]->ch_portnum, bd->channels[i]->ch_c_cflag); + } + return count; +} +static DEVICE_ATTR(ports_cflag, S_IRUSR, dgap_ports_cflag_show, NULL); + + +static ssize_t dgap_ports_oflag_show(struct device *p, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + int count = 0; + int i = 0; + + DGAP_VERIFY_BOARD(p, bd); + + for (i = 0; i < bd->nasync; i++) { + count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n", + bd->channels[i]->ch_portnum, bd->channels[i]->ch_c_oflag); + } + return count; +} +static DEVICE_ATTR(ports_oflag, S_IRUSR, dgap_ports_oflag_show, NULL); + + +static ssize_t dgap_ports_lflag_show(struct device *p, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + int count = 0; + int i = 0; + + DGAP_VERIFY_BOARD(p, bd); + + for (i = 0; i < bd->nasync; i++) { + count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n", + bd->channels[i]->ch_portnum, bd->channels[i]->ch_c_lflag); + } + return count; +} +static DEVICE_ATTR(ports_lflag, S_IRUSR, dgap_ports_lflag_show, NULL); + + +static ssize_t dgap_ports_digi_flag_show(struct device *p, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + int count = 0; + int i = 0; + + DGAP_VERIFY_BOARD(p, bd); + + for (i = 0; i < bd->nasync; i++) { + count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n", + bd->channels[i]->ch_portnum, bd->channels[i]->ch_digi.digi_flags); + } + return count; +} +static DEVICE_ATTR(ports_digi_flag, S_IRUSR, dgap_ports_digi_flag_show, NULL); + + +static ssize_t dgap_ports_rxcount_show(struct device *p, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + int count = 0; + int i = 0; + + DGAP_VERIFY_BOARD(p, bd); + + for (i = 0; i < bd->nasync; i++) { + count += snprintf(buf + count, PAGE_SIZE - count, "%d %ld\n", + bd->channels[i]->ch_portnum, bd->channels[i]->ch_rxcount); + } + return count; +} +static DEVICE_ATTR(ports_rxcount, S_IRUSR, dgap_ports_rxcount_show, NULL); + + +static ssize_t dgap_ports_txcount_show(struct device *p, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + int count = 0; + int i = 0; + + DGAP_VERIFY_BOARD(p, bd); + + for (i = 0; i < bd->nasync; i++) { + count += snprintf(buf + count, PAGE_SIZE - count, "%d %ld\n", + bd->channels[i]->ch_portnum, bd->channels[i]->ch_txcount); + } + return count; +} +static DEVICE_ATTR(ports_txcount, S_IRUSR, dgap_ports_txcount_show, NULL); + + +/* this function creates the sys files that will export each signal status + * to sysfs each value will be put in a separate filename + */ +void dgap_create_ports_sysfiles(struct board_t *bd) +{ + int rc = 0; + + dev_set_drvdata(&bd->pdev->dev, bd); + rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_state); + rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_baud); + rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_msignals); + rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_iflag); + rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_cflag); + rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_oflag); + rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_lflag); + rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_digi_flag); + rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_rxcount); + rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_txcount); + if (rc) { + printk(KERN_ERR "DGAP: sysfs device_create_file failed!\n"); + } +} + + +/* removes all the sys files created for that port */ +void dgap_remove_ports_sysfiles(struct board_t *bd) +{ + device_remove_file(&(bd->pdev->dev), &dev_attr_ports_state); + device_remove_file(&(bd->pdev->dev), &dev_attr_ports_baud); + device_remove_file(&(bd->pdev->dev), &dev_attr_ports_msignals); + device_remove_file(&(bd->pdev->dev), &dev_attr_ports_iflag); + device_remove_file(&(bd->pdev->dev), &dev_attr_ports_cflag); + device_remove_file(&(bd->pdev->dev), &dev_attr_ports_oflag); + device_remove_file(&(bd->pdev->dev), &dev_attr_ports_lflag); + device_remove_file(&(bd->pdev->dev), &dev_attr_ports_digi_flag); + device_remove_file(&(bd->pdev->dev), &dev_attr_ports_rxcount); + device_remove_file(&(bd->pdev->dev), &dev_attr_ports_txcount); +} + + +static ssize_t dgap_tty_state_show(struct device *d, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + + if (!d) + return (0); + un = (struct un_t *) dev_get_drvdata(d); + if (!un || un->magic != DGAP_UNIT_MAGIC) + return (0); + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return (0); + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return (0); + if (bd->state != BOARD_READY) + return (0); + + return snprintf(buf, PAGE_SIZE, "%s", un->un_open_count ? "Open" : "Closed"); +} +static DEVICE_ATTR(state, S_IRUSR, dgap_tty_state_show, NULL); + + +static ssize_t dgap_tty_baud_show(struct device *d, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + + if (!d) + return (0); + un = (struct un_t *) dev_get_drvdata(d); + if (!un || un->magic != DGAP_UNIT_MAGIC) + return (0); + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return (0); + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return (0); + if (bd->state != BOARD_READY) + return (0); + + return snprintf(buf, PAGE_SIZE, "%d\n", ch->ch_baud_info); +} +static DEVICE_ATTR(baud, S_IRUSR, dgap_tty_baud_show, NULL); + + +static ssize_t dgap_tty_msignals_show(struct device *d, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + + if (!d) + return (0); + un = (struct un_t *) dev_get_drvdata(d); + if (!un || un->magic != DGAP_UNIT_MAGIC) + return (0); + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return (0); + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return (0); + if (bd->state != BOARD_READY) + return (0); + + if (ch->ch_open_count) { + return snprintf(buf, PAGE_SIZE, "%s %s %s %s %s %s\n", + (ch->ch_mostat & UART_MCR_RTS) ? "RTS" : "", + (ch->ch_mistat & UART_MSR_CTS) ? "CTS" : "", + (ch->ch_mostat & UART_MCR_DTR) ? "DTR" : "", + (ch->ch_mistat & UART_MSR_DSR) ? "DSR" : "", + (ch->ch_mistat & UART_MSR_DCD) ? "DCD" : "", + (ch->ch_mistat & UART_MSR_RI) ? "RI" : ""); + } + return 0; +} +static DEVICE_ATTR(msignals, S_IRUSR, dgap_tty_msignals_show, NULL); + + +static ssize_t dgap_tty_iflag_show(struct device *d, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + + if (!d) + return (0); + un = (struct un_t *) dev_get_drvdata(d); + if (!un || un->magic != DGAP_UNIT_MAGIC) + return (0); + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return (0); + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return (0); + if (bd->state != BOARD_READY) + return (0); + + return snprintf(buf, PAGE_SIZE, "%x\n", ch->ch_c_iflag); +} +static DEVICE_ATTR(iflag, S_IRUSR, dgap_tty_iflag_show, NULL); + + +static ssize_t dgap_tty_cflag_show(struct device *d, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + + if (!d) + return (0); + un = (struct un_t *) dev_get_drvdata(d); + if (!un || un->magic != DGAP_UNIT_MAGIC) + return (0); + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return (0); + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return (0); + if (bd->state != BOARD_READY) + return (0); + + return snprintf(buf, PAGE_SIZE, "%x\n", ch->ch_c_cflag); +} +static DEVICE_ATTR(cflag, S_IRUSR, dgap_tty_cflag_show, NULL); + + +static ssize_t dgap_tty_oflag_show(struct device *d, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + + if (!d) + return (0); + un = (struct un_t *) dev_get_drvdata(d); + if (!un || un->magic != DGAP_UNIT_MAGIC) + return (0); + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return (0); + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return (0); + if (bd->state != BOARD_READY) + return (0); + + return snprintf(buf, PAGE_SIZE, "%x\n", ch->ch_c_oflag); +} +static DEVICE_ATTR(oflag, S_IRUSR, dgap_tty_oflag_show, NULL); + + +static ssize_t dgap_tty_lflag_show(struct device *d, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + + if (!d) + return (0); + un = (struct un_t *) dev_get_drvdata(d); + if (!un || un->magic != DGAP_UNIT_MAGIC) + return (0); + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return (0); + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return (0); + if (bd->state != BOARD_READY) + return (0); + + return snprintf(buf, PAGE_SIZE, "%x\n", ch->ch_c_lflag); +} +static DEVICE_ATTR(lflag, S_IRUSR, dgap_tty_lflag_show, NULL); + + +static ssize_t dgap_tty_digi_flag_show(struct device *d, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + + if (!d) + return (0); + un = (struct un_t *) dev_get_drvdata(d); + if (!un || un->magic != DGAP_UNIT_MAGIC) + return (0); + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return (0); + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return (0); + if (bd->state != BOARD_READY) + return (0); + + return snprintf(buf, PAGE_SIZE, "%x\n", ch->ch_digi.digi_flags); +} +static DEVICE_ATTR(digi_flag, S_IRUSR, dgap_tty_digi_flag_show, NULL); + + +static ssize_t dgap_tty_rxcount_show(struct device *d, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + + if (!d) + return (0); + un = (struct un_t *) dev_get_drvdata(d); + if (!un || un->magic != DGAP_UNIT_MAGIC) + return (0); + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return (0); + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return (0); + if (bd->state != BOARD_READY) + return (0); + + return snprintf(buf, PAGE_SIZE, "%ld\n", ch->ch_rxcount); +} +static DEVICE_ATTR(rxcount, S_IRUSR, dgap_tty_rxcount_show, NULL); + + +static ssize_t dgap_tty_txcount_show(struct device *d, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + + if (!d) + return (0); + un = (struct un_t *) dev_get_drvdata(d); + if (!un || un->magic != DGAP_UNIT_MAGIC) + return (0); + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return (0); + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return (0); + if (bd->state != BOARD_READY) + return (0); + + return snprintf(buf, PAGE_SIZE, "%ld\n", ch->ch_txcount); +} +static DEVICE_ATTR(txcount, S_IRUSR, dgap_tty_txcount_show, NULL); + + +static ssize_t dgap_tty_name_show(struct device *d, struct device_attribute *attr, char *buf) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + int cn; + int bn; + struct cnode *cptr = NULL; + int found = FALSE; + int ncount = 0; + int starto = 0; + int i = 0; + + if (!d) + return (0); + un = (struct un_t *) dev_get_drvdata(d); + if (!un || un->magic != DGAP_UNIT_MAGIC) + return (0); + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return (0); + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return (0); + if (bd->state != BOARD_READY) + return (0); + + bn = bd->boardnum; + cn = ch->ch_portnum; + + for (cptr = bd->bd_config; cptr; cptr = cptr->next) { + + if ((cptr->type == BNODE) && + ((cptr->u.board.type == APORT2_920P) || (cptr->u.board.type == APORT4_920P) || + (cptr->u.board.type == APORT8_920P) || (cptr->u.board.type == PAPORT4) || + (cptr->u.board.type == PAPORT8))) { + + found = TRUE; + if (cptr->u.board.v_start) + starto = cptr->u.board.start; + else + starto = 1; + } + + if (cptr->type == TNODE && found == TRUE) { + char *ptr1; + if (strstr(cptr->u.ttyname, "tty")) { + ptr1 = cptr->u.ttyname; + ptr1 += 3; + } + else { + ptr1 = cptr->u.ttyname; + } + + for (i = 0; i < dgap_config_get_number_of_ports(bd); i++) { + if (cn == i) { + return snprintf(buf, PAGE_SIZE, "%s%s%02d\n", + (un->un_type == DGAP_PRINT) ? "pr" : "tty", + ptr1, i + starto); + } + } + } + + if (cptr->type == CNODE) { + + for (i = 0; i < cptr->u.conc.nport; i++) { + if (cn == (i + ncount)) { + + return snprintf(buf, PAGE_SIZE, "%s%s%02d\n", + (un->un_type == DGAP_PRINT) ? "pr" : "tty", + cptr->u.conc.id, + i + (cptr->u.conc.v_start ? cptr->u.conc.start : 1)); + } + } + + ncount += cptr->u.conc.nport; + } + + if (cptr->type == MNODE) { + + for (i = 0; i < cptr->u.module.nport; i++) { + if (cn == (i + ncount)) { + return snprintf(buf, PAGE_SIZE, "%s%s%02d\n", + (un->un_type == DGAP_PRINT) ? "pr" : "tty", + cptr->u.module.id, + i + (cptr->u.module.v_start ? cptr->u.module.start : 1)); + } + } + + ncount += cptr->u.module.nport; + + } + } + + return snprintf(buf, PAGE_SIZE, "%s_dgap_%d_%d\n", + (un->un_type == DGAP_PRINT) ? "pr" : "tty", bn, cn); + +} +static DEVICE_ATTR(custom_name, S_IRUSR, dgap_tty_name_show, NULL); + + +static struct attribute *dgap_sysfs_tty_entries[] = { + &dev_attr_state.attr, + &dev_attr_baud.attr, + &dev_attr_msignals.attr, + &dev_attr_iflag.attr, + &dev_attr_cflag.attr, + &dev_attr_oflag.attr, + &dev_attr_lflag.attr, + &dev_attr_digi_flag.attr, + &dev_attr_rxcount.attr, + &dev_attr_txcount.attr, + &dev_attr_custom_name.attr, + NULL +}; + + +static struct attribute_group dgap_tty_attribute_group = { + .name = NULL, + .attrs = dgap_sysfs_tty_entries, +}; + + + + +void dgap_create_tty_sysfs(struct un_t *un, struct device *c) +{ + int ret; + + ret = sysfs_create_group(&c->kobj, &dgap_tty_attribute_group); + if (ret) { + printk(KERN_ERR "dgap: failed to create sysfs tty device attributes.\n"); + sysfs_remove_group(&c->kobj, &dgap_tty_attribute_group); + return; + } + + dev_set_drvdata(c, un); + +} + + +void dgap_remove_tty_sysfs(struct device *c) +{ + sysfs_remove_group(&c->kobj, &dgap_tty_attribute_group); +} diff --git a/drivers/staging/dgap/dgap_sysfs.h b/drivers/staging/dgap/dgap_sysfs.h new file mode 100644 index 0000000000000..dde690eec5cf6 --- /dev/null +++ b/drivers/staging/dgap/dgap_sysfs.h @@ -0,0 +1,48 @@ +/* + * Copyright 2003 Digi International (www.digi.com) + * Scott H Kilau + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! + */ + +#ifndef __DGAP_SYSFS_H +#define __DGAP_SYSFS_H + +#include "dgap_driver.h" + +#include + +struct board_t; +struct channel_t; +struct un_t; +struct pci_driver; +struct class_device; + +extern void dgap_create_ports_sysfiles(struct board_t *bd); +extern void dgap_remove_ports_sysfiles(struct board_t *bd); + +extern void dgap_create_driver_sysfiles(struct pci_driver *); +extern void dgap_remove_driver_sysfiles(struct pci_driver *); + +extern int dgap_tty_class_init(void); +extern int dgap_tty_class_destroy(void); + +extern void dgap_create_tty_sysfs(struct un_t *un, struct device *c); +extern void dgap_remove_tty_sysfs(struct device *c); + + +#endif diff --git a/drivers/staging/dgap/dgap_trace.c b/drivers/staging/dgap/dgap_trace.c new file mode 100644 index 0000000000000..17610025b8f45 --- /dev/null +++ b/drivers/staging/dgap/dgap_trace.c @@ -0,0 +1,186 @@ +/* + * Copyright 2003 Digi International (www.digi.com) + * Scott H Kilau + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * + * NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE! + * + * This is shared code between Digi's CVS archive and the + * Linux Kernel sources. + * Changing the source just for reformatting needlessly breaks + * our CVS diff history. + * + * Send any bug fixes/changes to: Eng.Linux at digi dot com. + * Thank you. + * + */ + +/* $Id: dgap_trace.c,v 1.1 2009/10/23 14:01:57 markh Exp $ */ + +#include +#include +#include /* For jiffies, task states */ +#include /* For tasklet and interrupt structs/defines */ +#include + +#include "dgap_driver.h" + +#define TRC_TO_CONSOLE 1 + +/* file level globals */ +static char *dgap_trcbuf; /* the ringbuffer */ + +#if defined(TRC_TO_KMEM) +static int dgap_trcbufi = 0; /* index of the tilde at the end of */ +#endif + +extern int dgap_trcbuf_size; /* size of the ringbuffer */ + +#if defined(TRC_TO_KMEM) +static DEFINE_SPINLOCK(dgap_tracef_lock); +#endif + +#if 0 + +#if !defined(TRC_TO_KMEM) && !defined(TRC_TO_CONSOLE) +void dgap_tracef(const char *fmt, ...) +{ + return; +} + +#else /* !defined(TRC_TO_KMEM) && !defined(TRC_TO_CONSOLE) */ + +void dgap_tracef(const char *fmt, ...) +{ + va_list ap; + char buf[TRC_MAXMSG+1]; + size_t lenbuf; + int i; + static int failed = FALSE; +# if defined(TRC_TO_KMEM) + unsigned long flags; +#endif + + if(failed) + return; +# if defined(TRC_TO_KMEM) + DGAP_LOCK(dgap_tracef_lock, flags); +#endif + + /* Format buf using fmt and arguments contained in ap. */ + va_start(ap, fmt); + i = vsprintf(buf, fmt, ap); + va_end(ap); + lenbuf = strlen(buf); + +# if defined(TRC_TO_KMEM) + { + static int initd=0; + + /* + * Now, in addition to (or instead of) printing this stuff out + * (which is a buffered operation), also tuck it away into a + * corner of memory which can be examined post-crash in kdb. + */ + if (!initd) { + dgap_trcbuf = (char *) vmalloc(dgap_trcbuf_size); + if(!dgap_trcbuf) { + failed = TRUE; + printk("dgap: tracing init failed!\n"); + return; + } + + memset(dgap_trcbuf, '\0', dgap_trcbuf_size); + dgap_trcbufi = 0; + initd++; + + printk("dgap: tracing enabled - " TRC_DTRC + " 0x%lx 0x%x\n", + (unsigned long)dgap_trcbuf, + dgap_trcbuf_size); + } + +# if defined(TRC_ON_OVERFLOW_WRAP_AROUND) + /* + * This is the less CPU-intensive way to do things. We simply + * wrap around before we fall off the end of the buffer. A + * tilde (~) demarcates the current end of the trace. + * + * This method should be used if you are concerned about race + * conditions as it is less likely to affect the timing of + * things. + */ + + if (dgap_trcbufi + lenbuf >= dgap_trcbuf_size) { + /* We are wrapping, so wipe out the last tilde. */ + dgap_trcbuf[dgap_trcbufi] = '\0'; + /* put the new string at the beginning of the buffer */ + dgap_trcbufi = 0; + } + + strcpy(&dgap_trcbuf[dgap_trcbufi], buf); + dgap_trcbufi += lenbuf; + dgap_trcbuf[dgap_trcbufi] = '~'; + +# elif defined(TRC_ON_OVERFLOW_SHIFT_BUFFER) + /* + * This is the more CPU-intensive way to do things. If we + * venture into the last 1/8 of the buffer, we shift the + * last 7/8 of the buffer forward, wiping out the first 1/8. + * Advantage: No wrap-around, only truncation from the + * beginning. + * + * This method should not be used if you are concerned about + * timing changes affecting the behaviour of the driver (ie, + * race conditions). + */ + strcpy(&dgap_trcbuf[dgap_trcbufi], buf); + dgap_trcbufi += lenbuf; + dgap_trcbuf[dgap_trcbufi] = '~'; + dgap_trcbuf[dgap_trcbufi+1] = '\0'; + + /* If we're near the end of the trace buffer... */ + if (dgap_trcbufi > (dgap_trcbuf_size/8)*7) { + /* Wipe out the first eighth to make some more room. */ + strcpy(dgap_trcbuf, &dgap_trcbuf[dgap_trcbuf_size/8]); + dgap_trcbufi = strlen(dgap_trcbuf)-1; + /* Plop overflow message at the top of the buffer. */ + bcopy(TRC_OVERFLOW, dgap_trcbuf, strlen(TRC_OVERFLOW)); + } +# else +# error "TRC_ON_OVERFLOW_WRAP_AROUND or TRC_ON_OVERFLOW_SHIFT_BUFFER?" +# endif + } + DGAP_UNLOCK(dgap_tracef_lock, flags); + +# endif /* defined(TRC_TO_KMEM) */ +} + +#endif /* !defined(TRC_TO_KMEM) && !defined(TRC_TO_CONSOLE) */ + +#endif + +/* + * dgap_tracer_free() + * + * + */ +void dgap_tracer_free(void) +{ + if(dgap_trcbuf) + vfree(dgap_trcbuf); +} diff --git a/drivers/staging/dgap/dgap_trace.h b/drivers/staging/dgap/dgap_trace.h new file mode 100644 index 0000000000000..b21f46198e71c --- /dev/null +++ b/drivers/staging/dgap/dgap_trace.h @@ -0,0 +1,36 @@ +/* + * Copyright 2003 Digi International (www.digi.com) + * Scott H Kilau + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! + * + ***************************************************************************** + * Header file for dgap_trace.c + * + * $Id: dgap_trace.h,v 1.1 2009/10/23 14:01:57 markh Exp $ + */ + +#ifndef __DGAP_TRACE_H +#define __DGAP_TRACE_H + +#include "dgap_driver.h" + +void dgap_tracef(const char *fmt, ...); +void dgap_tracer_free(void); + +#endif + diff --git a/drivers/staging/dgap/dgap_tty.c b/drivers/staging/dgap/dgap_tty.c new file mode 100644 index 0000000000000..e7aea5ef51c56 --- /dev/null +++ b/drivers/staging/dgap/dgap_tty.c @@ -0,0 +1,3651 @@ +/* + * Copyright 2003 Digi International (www.digi.com) + * Scott H Kilau + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * + * NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE! + * + * This is shared code between Digi's CVS archive and the + * Linux Kernel sources. + * Changing the source just for reformatting needlessly breaks + * our CVS diff history. + * + * Send any bug fixes/changes to: Eng.Linux at digi dot com. + * Thank you. + */ + +/************************************************************************ + * + * This file implements the tty driver functionality for the + * FEP5 based product lines. + * + ************************************************************************ + * + * $Id: dgap_tty.c,v 1.3 2011/06/23 12:11:31 markh Exp $ + */ + +#include +#include +#include /* For jiffies, task states */ +#include /* For tasklet and interrupt structs/defines */ +#include +#include +#include +#include +#include +#include +#include /* For udelay */ +#include /* For copy_from_user/copy_to_user */ +#include /* For read[bwl]/write[bwl] */ +#include + +#include "dgap_driver.h" +#include "dgap_tty.h" +#include "dgap_types.h" +#include "dgap_fep5.h" +#include "dgap_parse.h" +#include "dgap_conf.h" +#include "dgap_sysfs.h" + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37) +#define init_MUTEX(sem) sema_init(sem, 1) +#define DECLARE_MUTEX(name) \ + struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) +#endif + +/* + * internal variables + */ +static struct board_t *dgap_BoardsByMajor[256]; +static uchar *dgap_TmpWriteBuf = NULL; +static DECLARE_MUTEX(dgap_TmpWriteSem); + +/* + * Default transparent print information. + */ +static struct digi_t dgap_digi_init = { + .digi_flags = DIGI_COOK, /* Flags */ + .digi_maxcps = 100, /* Max CPS */ + .digi_maxchar = 50, /* Max chars in print queue */ + .digi_bufsize = 100, /* Printer buffer size */ + .digi_onlen = 4, /* size of printer on string */ + .digi_offlen = 4, /* size of printer off string */ + .digi_onstr = "\033[5i", /* ANSI printer on string ] */ + .digi_offstr = "\033[4i", /* ANSI printer off string ] */ + .digi_term = "ansi" /* default terminal type */ +}; + + +/* + * Define a local default termios struct. All ports will be created + * with this termios initially. + * + * This defines a raw port at 9600 baud, 8 data bits, no parity, + * 1 stop bit. + */ + +static struct ktermios DgapDefaultTermios = +{ + .c_iflag = (DEFAULT_IFLAGS), /* iflags */ + .c_oflag = (DEFAULT_OFLAGS), /* oflags */ + .c_cflag = (DEFAULT_CFLAGS), /* cflags */ + .c_lflag = (DEFAULT_LFLAGS), /* lflags */ + .c_cc = INIT_C_CC, + .c_line = 0, +}; + +/* Our function prototypes */ +static int dgap_tty_open(struct tty_struct *tty, struct file *file); +static void dgap_tty_close(struct tty_struct *tty, struct file *file); +static int dgap_block_til_ready(struct tty_struct *tty, struct file *file, struct channel_t *ch); +static int dgap_tty_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg); +static int dgap_tty_digigeta(struct tty_struct *tty, struct digi_t __user *retinfo); +static int dgap_tty_digiseta(struct tty_struct *tty, struct digi_t __user *new_info); +static int dgap_tty_digigetedelay(struct tty_struct *tty, int __user *retinfo); +static int dgap_tty_digisetedelay(struct tty_struct *tty, int __user *new_info); +static int dgap_tty_write_room(struct tty_struct* tty); +static int dgap_tty_chars_in_buffer(struct tty_struct* tty); +static void dgap_tty_start(struct tty_struct *tty); +static void dgap_tty_stop(struct tty_struct *tty); +static void dgap_tty_throttle(struct tty_struct *tty); +static void dgap_tty_unthrottle(struct tty_struct *tty); +static void dgap_tty_flush_chars(struct tty_struct *tty); +static void dgap_tty_flush_buffer(struct tty_struct *tty); +static void dgap_tty_hangup(struct tty_struct *tty); +static int dgap_wait_for_drain(struct tty_struct *tty); +static int dgap_set_modem_info(struct tty_struct *tty, unsigned int command, unsigned int __user *value); +static int dgap_get_modem_info(struct channel_t *ch, unsigned int __user *value); +static int dgap_tty_digisetcustombaud(struct tty_struct *tty, int __user *new_info); +static int dgap_tty_digigetcustombaud(struct tty_struct *tty, int __user *retinfo); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39) +static int dgap_tty_tiocmget(struct tty_struct *tty); +static int dgap_tty_tiocmset(struct tty_struct *tty, unsigned int set, unsigned int clear); +#else +static int dgap_tty_tiocmget(struct tty_struct *tty, struct file *file); +static int dgap_tty_tiocmset(struct tty_struct *tty, struct file *file, unsigned int set, unsigned int clear); +#endif +static int dgap_tty_send_break(struct tty_struct *tty, int msec); +static void dgap_tty_wait_until_sent(struct tty_struct *tty, int timeout); +static int dgap_tty_write(struct tty_struct *tty, const unsigned char *buf, int count); +static void dgap_tty_set_termios(struct tty_struct *tty, struct ktermios *old_termios); +static int dgap_tty_put_char(struct tty_struct *tty, unsigned char c); +static void dgap_tty_send_xchar(struct tty_struct *tty, char ch); + +static const struct tty_operations dgap_tty_ops = { + .open = dgap_tty_open, + .close = dgap_tty_close, + .write = dgap_tty_write, + .write_room = dgap_tty_write_room, + .flush_buffer = dgap_tty_flush_buffer, + .chars_in_buffer = dgap_tty_chars_in_buffer, + .flush_chars = dgap_tty_flush_chars, + .ioctl = dgap_tty_ioctl, + .set_termios = dgap_tty_set_termios, + .stop = dgap_tty_stop, + .start = dgap_tty_start, + .throttle = dgap_tty_throttle, + .unthrottle = dgap_tty_unthrottle, + .hangup = dgap_tty_hangup, + .put_char = dgap_tty_put_char, + .tiocmget = dgap_tty_tiocmget, + .tiocmset = dgap_tty_tiocmset, + .break_ctl = dgap_tty_send_break, + .wait_until_sent = dgap_tty_wait_until_sent, + .send_xchar = dgap_tty_send_xchar +}; + + + + + +/************************************************************************ + * + * TTY Initialization/Cleanup Functions + * + ************************************************************************/ + +/* + * dgap_tty_preinit() + * + * Initialize any global tty related data before we download any boards. + */ +int dgap_tty_preinit(void) +{ + unsigned long flags; + + DGAP_LOCK(dgap_global_lock, flags); + + /* + * Allocate a buffer for doing the copy from user space to + * kernel space in dgap_input(). We only use one buffer and + * control access to it with a semaphore. If we are paging, we + * are already in trouble so one buffer won't hurt much anyway. + */ + dgap_TmpWriteBuf = kmalloc(WRITEBUFLEN, GFP_ATOMIC); + + if (!dgap_TmpWriteBuf) { + DGAP_UNLOCK(dgap_global_lock, flags); + DPR_INIT(("unable to allocate tmp write buf")); + return (-ENOMEM); + } + + DGAP_UNLOCK(dgap_global_lock, flags); + return(0); +} + + +/* + * dgap_tty_register() + * + * Init the tty subsystem for this board. + */ +int dgap_tty_register(struct board_t *brd) +{ + int rc = 0; + + DPR_INIT(("tty_register start")); + + brd->SerialDriver = alloc_tty_driver(MAXPORTS); + + snprintf(brd->SerialName, MAXTTYNAMELEN, "tty_dgap_%d_", brd->boardnum); + brd->SerialDriver->name = brd->SerialName; + brd->SerialDriver->name_base = 0; + brd->SerialDriver->major = 0; + brd->SerialDriver->minor_start = 0; + brd->SerialDriver->type = TTY_DRIVER_TYPE_SERIAL; + brd->SerialDriver->subtype = SERIAL_TYPE_NORMAL; + brd->SerialDriver->init_termios = DgapDefaultTermios; + brd->SerialDriver->driver_name = DRVSTR; + brd->SerialDriver->flags = (TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_HARDWARE_BREAK); + + /* The kernel wants space to store pointers to tty_structs */ + brd->SerialDriver->ttys = dgap_driver_kzmalloc(MAXPORTS * sizeof(struct tty_struct *), GFP_KERNEL); + if (!brd->SerialDriver->ttys) + return(-ENOMEM); + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28) + brd->SerialDriver->refcount = brd->TtyRefCnt; +#endif + + /* + * Entry points for driver. Called by the kernel from + * tty_io.c and n_tty.c. + */ + tty_set_operations(brd->SerialDriver, &dgap_tty_ops); + + /* + * If we're doing transparent print, we have to do all of the above + * again, seperately so we don't get the LD confused about what major + * we are when we get into the dgap_tty_open() routine. + */ + brd->PrintDriver = alloc_tty_driver(MAXPORTS); + + snprintf(brd->PrintName, MAXTTYNAMELEN, "pr_dgap_%d_", brd->boardnum); + brd->PrintDriver->name = brd->PrintName; + brd->PrintDriver->name_base = 0; + brd->PrintDriver->major = 0; + brd->PrintDriver->minor_start = 0; + brd->PrintDriver->type = TTY_DRIVER_TYPE_SERIAL; + brd->PrintDriver->subtype = SERIAL_TYPE_NORMAL; + brd->PrintDriver->init_termios = DgapDefaultTermios; + brd->PrintDriver->driver_name = DRVSTR; + brd->PrintDriver->flags = (TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_HARDWARE_BREAK); + + /* The kernel wants space to store pointers to tty_structs */ + brd->PrintDriver->ttys = dgap_driver_kzmalloc(MAXPORTS * sizeof(struct tty_struct *), GFP_KERNEL); + if (!brd->PrintDriver->ttys) + return(-ENOMEM); + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28) + brd->PrintDriver->refcount = brd->TtyRefCnt; +#endif + + /* + * Entry points for driver. Called by the kernel from + * tty_io.c and n_tty.c. + */ + tty_set_operations(brd->PrintDriver, &dgap_tty_ops); + + if (!brd->dgap_Major_Serial_Registered) { + /* Register tty devices */ + rc = tty_register_driver(brd->SerialDriver); + if (rc < 0) { + APR(("Can't register tty device (%d)\n", rc)); + return(rc); + } + brd->dgap_Major_Serial_Registered = TRUE; + dgap_BoardsByMajor[brd->SerialDriver->major] = brd; + brd->dgap_Serial_Major = brd->SerialDriver->major; + } + + if (!brd->dgap_Major_TransparentPrint_Registered) { + /* Register Transparent Print devices */ + rc = tty_register_driver(brd->PrintDriver); + if (rc < 0) { + APR(("Can't register Transparent Print device (%d)\n", rc)); + return(rc); + } + brd->dgap_Major_TransparentPrint_Registered = TRUE; + dgap_BoardsByMajor[brd->PrintDriver->major] = brd; + brd->dgap_TransparentPrint_Major = brd->PrintDriver->major; + } + + DPR_INIT(("DGAP REGISTER TTY: MAJORS: %d %d\n", brd->SerialDriver->major, + brd->PrintDriver->major)); + + return (rc); +} + + +/* + * dgap_tty_init() + * + * Init the tty subsystem. Called once per board after board has been + * downloaded and init'ed. + */ +int dgap_tty_init(struct board_t *brd) +{ + int i; + int tlw; + uint true_count = 0; + uchar *vaddr; + uchar modem = 0; + struct channel_t *ch; + struct bs_t *bs; + struct cm_t *cm; + + if (!brd) + return (-ENXIO); + + DPR_INIT(("dgap_tty_init start\n")); + + /* + * Initialize board structure elements. + */ + + vaddr = brd->re_map_membase; + true_count = readw((vaddr + NCHAN)); + + brd->nasync = dgap_config_get_number_of_ports(brd); + + if (!brd->nasync) { + brd->nasync = brd->maxports; + } + + if (brd->nasync > brd->maxports) { + brd->nasync = brd->maxports; + } + + if (true_count != brd->nasync) { + if ((brd->type == PPCM) && (true_count == 64)) { + APR(("***WARNING**** %s configured for %d ports, has %d ports.\nPlease make SURE the EBI cable running from the card\nto each EM module is plugged into EBI IN!\n", + brd->name, brd->nasync, true_count)); + } + else if ((brd->type == PPCM) && (true_count == 0)) { + APR(("***WARNING**** %s configured for %d ports, has %d ports.\nPlease make SURE the EBI cable running from the card\nto each EM module is plugged into EBI IN!\n", + brd->name, brd->nasync, true_count)); + } + else { + APR(("***WARNING**** %s configured for %d ports, has %d ports.\n", + brd->name, brd->nasync, true_count)); + } + + brd->nasync = true_count; + + /* If no ports, don't bother going any further */ + if (!brd->nasync) { + brd->state = BOARD_FAILED; + brd->dpastatus = BD_NOFEP; + return(-ENXIO); + } + } + + /* + * Allocate channel memory that might not have been allocated + * when the driver was first loaded. + */ + for (i = 0; i < brd->nasync; i++) { + if (!brd->channels[i]) { + brd->channels[i] = dgap_driver_kzmalloc(sizeof(struct channel_t), GFP_ATOMIC); + if (!brd->channels[i]) { + DPR_CORE(("%s:%d Unable to allocate memory for channel struct\n", + __FILE__, __LINE__)); + } + } + } + + ch = brd->channels[0]; + vaddr = brd->re_map_membase; + + bs = (struct bs_t *) ((ulong) vaddr + CHANBUF); + cm = (struct cm_t *) ((ulong) vaddr + CMDBUF); + + brd->bd_bs = bs; + + /* Set up channel variables */ + for (i = 0; i < brd->nasync; i++, ch = brd->channels[i], bs++) { + + if (!brd->channels[i]) + continue; + + DGAP_SPINLOCK_INIT(ch->ch_lock); + + /* Store all our magic numbers */ + ch->magic = DGAP_CHANNEL_MAGIC; + ch->ch_tun.magic = DGAP_UNIT_MAGIC; + ch->ch_tun.un_type = DGAP_SERIAL; + ch->ch_tun.un_ch = ch; + ch->ch_tun.un_dev = i; + + ch->ch_pun.magic = DGAP_UNIT_MAGIC; + ch->ch_pun.un_type = DGAP_PRINT; + ch->ch_pun.un_ch = ch; + ch->ch_pun.un_dev = i; + + ch->ch_vaddr = vaddr; + ch->ch_bs = bs; + ch->ch_cm = cm; + ch->ch_bd = brd; + ch->ch_portnum = i; + ch->ch_digi = dgap_digi_init; + + /* + * Set up digi dsr and dcd bits based on altpin flag. + */ + if (dgap_config_get_altpin(brd)) { + ch->ch_dsr = DM_CD; + ch->ch_cd = DM_DSR; + ch->ch_digi.digi_flags |= DIGI_ALTPIN; + } + else { + ch->ch_cd = DM_CD; + ch->ch_dsr = DM_DSR; + } + + ch->ch_taddr = vaddr + ((ch->ch_bs->tx_seg) << 4); + ch->ch_raddr = vaddr + ((ch->ch_bs->rx_seg) << 4); + ch->ch_tx_win = 0; + ch->ch_rx_win = 0; + ch->ch_tsize = readw(&(ch->ch_bs->tx_max)) + 1; + ch->ch_rsize = readw(&(ch->ch_bs->rx_max)) + 1; + ch->ch_tstart = 0; + ch->ch_rstart = 0; + + /* .25 second delay */ + ch->ch_close_delay = 250; + + /* + * Set queue water marks, interrupt mask, + * and general tty parameters. + */ + ch->ch_tlw = tlw = ch->ch_tsize >= 2000 ? ((ch->ch_tsize * 5) / 8) : ch->ch_tsize / 2; + + dgap_cmdw(ch, STLOW, tlw, 0); + + dgap_cmdw(ch, SRLOW, ch->ch_rsize / 2, 0); + + dgap_cmdw(ch, SRHIGH, 7 * ch->ch_rsize / 8, 0); + + ch->ch_mistat = readb(&(ch->ch_bs->m_stat)); + + init_waitqueue_head(&ch->ch_flags_wait); + init_waitqueue_head(&ch->ch_tun.un_flags_wait); + init_waitqueue_head(&ch->ch_pun.un_flags_wait); + init_waitqueue_head(&ch->ch_sniff_wait); + + /* Turn on all modem interrupts for now */ + modem = (DM_CD | DM_DSR | DM_CTS | DM_RI); + writeb(modem, &(ch->ch_bs->m_int)); + + /* + * Set edelay to 0 if interrupts are turned on, + * otherwise set edelay to the usual 100. + */ + if (brd->intr_used) + writew(0, &(ch->ch_bs->edelay)); + else + writew(100, &(ch->ch_bs->edelay)); + + writeb(1, &(ch->ch_bs->idata)); + } + + + DPR_INIT(("dgap_tty_init finish\n")); + + return (0); +} + + +/* + * dgap_tty_post_uninit() + * + * UnInitialize any global tty related data. + */ +void dgap_tty_post_uninit(void) +{ + if (dgap_TmpWriteBuf) { + kfree(dgap_TmpWriteBuf); + dgap_TmpWriteBuf = NULL; + } +} + + +/* + * dgap_tty_uninit() + * + * Uninitialize the TTY portion of this driver. Free all memory and + * resources. + */ +void dgap_tty_uninit(struct board_t *brd) +{ + int i = 0; + + if (brd->dgap_Major_Serial_Registered) { + dgap_BoardsByMajor[brd->SerialDriver->major] = NULL; + brd->dgap_Serial_Major = 0; + for (i = 0; i < brd->nasync; i++) { + dgap_remove_tty_sysfs(brd->channels[i]->ch_tun.un_sysfs); + tty_unregister_device(brd->SerialDriver, i); + } + tty_unregister_driver(brd->SerialDriver); + if (brd->SerialDriver->ttys) { + kfree(brd->SerialDriver->ttys); + brd->SerialDriver->ttys = NULL; + } + put_tty_driver(brd->SerialDriver); + brd->dgap_Major_Serial_Registered = FALSE; + } + + if (brd->dgap_Major_TransparentPrint_Registered) { + dgap_BoardsByMajor[brd->PrintDriver->major] = NULL; + brd->dgap_TransparentPrint_Major = 0; + for (i = 0; i < brd->nasync; i++) { + dgap_remove_tty_sysfs(brd->channels[i]->ch_pun.un_sysfs); + tty_unregister_device(brd->PrintDriver, i); + } + tty_unregister_driver(brd->PrintDriver); + if (brd->PrintDriver->ttys) { + kfree(brd->PrintDriver->ttys); + brd->PrintDriver->ttys = NULL; + } + put_tty_driver(brd->PrintDriver); + brd->dgap_Major_TransparentPrint_Registered = FALSE; + } +} + + +#define TMPBUFLEN (1024) + +/* + * dgap_sniff - Dump data out to the "sniff" buffer if the + * proc sniff file is opened... + */ +static void dgap_sniff_nowait_nolock(struct channel_t *ch, uchar *text, uchar *buf, int len) +{ + struct timeval tv; + int n; + int r; + int nbuf; + int i; + int tmpbuflen; + char tmpbuf[TMPBUFLEN]; + char *p = tmpbuf; + int too_much_data; + + /* Leave if sniff not open */ + if (!(ch->ch_sniff_flags & SNIFF_OPEN)) + return; + + do_gettimeofday(&tv); + + /* Create our header for data dump */ + p += sprintf(p, "<%ld %ld><%s><", tv.tv_sec, tv.tv_usec, text); + tmpbuflen = p - tmpbuf; + + do { + too_much_data = 0; + + for (i = 0; i < len && tmpbuflen < (TMPBUFLEN - 4); i++) { + p += sprintf(p, "%02x ", *buf); + buf++; + tmpbuflen = p - tmpbuf; + } + + if (tmpbuflen < (TMPBUFLEN - 4)) { + if (i > 0) + p += sprintf(p - 1, "%s\n", ">"); + else + p += sprintf(p, "%s\n", ">"); + } else { + too_much_data = 1; + len -= i; + } + + nbuf = strlen(tmpbuf); + p = tmpbuf; + + /* + * Loop while data remains. + */ + while (nbuf > 0 && ch->ch_sniff_buf != 0) { + /* + * Determine the amount of available space left in the + * buffer. If there's none, wait until some appears. + */ + n = (ch->ch_sniff_out - ch->ch_sniff_in - 1) & SNIFF_MASK; + + /* + * If there is no space left to write to in our sniff buffer, + * we have no choice but to drop the data. + * We *cannot* sleep here waiting for space, because this + * function was probably called by the interrupt/timer routines! + */ + if (n == 0) { + return; + } + + /* + * Copy as much data as will fit. + */ + + if (n > nbuf) + n = nbuf; + + r = SNIFF_MAX - ch->ch_sniff_in; + + if (r <= n) { + memcpy(ch->ch_sniff_buf + ch->ch_sniff_in, p, r); + + n -= r; + ch->ch_sniff_in = 0; + p += r; + nbuf -= r; + } + + memcpy(ch->ch_sniff_buf + ch->ch_sniff_in, p, n); + + ch->ch_sniff_in += n; + p += n; + nbuf -= n; + + /* + * Wakeup any thread waiting for data + */ + if (ch->ch_sniff_flags & SNIFF_WAIT_DATA) { + ch->ch_sniff_flags &= ~SNIFF_WAIT_DATA; + wake_up_interruptible(&ch->ch_sniff_wait); + } + } + + /* + * If the user sent us too much data to push into our tmpbuf, + * we need to keep looping around on all the data. + */ + if (too_much_data) { + p = tmpbuf; + tmpbuflen = 0; + } + + } while (too_much_data); +} + + +/*======================================================================= + * + * dgap_input - Process received data. + * + * ch - Pointer to channel structure. + * + *=======================================================================*/ + +void dgap_input(struct channel_t *ch) +{ + struct board_t *bd; + struct bs_t *bs; + struct tty_struct *tp; + struct tty_ldisc *ld; + uint rmask; + uint head; + uint tail; + int data_len; + ulong lock_flags; + ulong lock_flags2; + int flip_len; + int len = 0; + int n = 0; + uchar *buf; + uchar tmpchar; + int s = 0; + + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return; + + tp = ch->ch_tun.un_tty; + + bs = ch->ch_bs; + if (!bs) { + return; + } + + bd = ch->ch_bd; + if(!bd || bd->magic != DGAP_BOARD_MAGIC) + return; + + DPR_READ(("dgap_input start\n")); + + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + + /* + * Figure the number of characters in the buffer. + * Exit immediately if none. + */ + + rmask = ch->ch_rsize - 1; + + head = readw(&(bs->rx_head)); + head &= rmask; + tail = readw(&(bs->rx_tail)); + tail &= rmask; + + data_len = (head - tail) & rmask; + + if (data_len == 0) { + writeb(1, &(bs->idata)); + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + DPR_READ(("No data on port %d\n", ch->ch_portnum)); + return; + } + + /* + * If the device is not open, or CREAD is off, flush + * input data and return immediately. + */ + if ((bd->state != BOARD_READY) || !tp || (tp->magic != TTY_MAGIC) || + !(ch->ch_tun.un_flags & UN_ISOPEN) || !(tp->termios->c_cflag & CREAD) || + (ch->ch_tun.un_flags & UN_CLOSING)) { + + DPR_READ(("input. dropping %d bytes on port %d...\n", data_len, ch->ch_portnum)); + DPR_READ(("input. tp: %p tp->magic: %x MAGIC:%x ch flags: %x\n", + tp, tp ? tp->magic : 0, TTY_MAGIC, ch->ch_tun.un_flags)); + writew(head, &(bs->rx_tail)); + writeb(1, &(bs->idata)); + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + return; + } + + /* + * If we are throttled, simply don't read any data. + */ + if (ch->ch_flags & CH_RXBLOCK) { + writeb(1, &(bs->idata)); + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + DPR_READ(("Port %d throttled, not reading any data. head: %x tail: %x\n", + ch->ch_portnum, head, tail)); + return; + } + + /* + * Ignore oruns. + */ + tmpchar = readb(&(bs->orun)); + if (tmpchar) { + ch->ch_err_overrun++; + writeb(0, &(bs->orun)); + } + + DPR_READ(("dgap_input start 2\n")); + + /* Decide how much data we can send into the tty layer */ + if (dgap_rawreadok && tp->real_raw) + flip_len = MYFLIPLEN; + else + flip_len = TTY_FLIPBUF_SIZE; + + /* Chop down the length, if needed */ + len = min(data_len, flip_len); + len = min(len, (N_TTY_BUF_SIZE - 1) - tp->read_cnt); + + ld = tty_ldisc_ref(tp); + +#ifdef TTY_DONT_FLIP + /* + * If the DONT_FLIP flag is on, don't flush our buffer, and act + * like the ld doesn't have any space to put the data right now. + */ + if (test_bit(TTY_DONT_FLIP, &tp->flags)) + len = 0; +#endif + + /* + * If we were unable to get a reference to the ld, + * don't flush our buffer, and act like the ld doesn't + * have any space to put the data right now. + */ + if (!ld) { + len = 0; + } else { + /* + * If ld doesn't have a pointer to a receive_buf function, + * flush the data, then act like the ld doesn't have any + * space to put the data right now. + */ + if (!ld->ops->receive_buf) { + writew(head, &(bs->rx_tail)); + len = 0; + } + } + + if (len <= 0) { + writeb(1, &(bs->idata)); + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + DPR_READ(("dgap_input 1 - finish\n")); + if (ld) + tty_ldisc_deref(ld); + return; + } + + buf = ch->ch_bd->flipbuf; + n = len; + + /* + * n now contains the most amount of data we can copy, + * bounded either by our buffer size or the amount + * of data the card actually has pending... + */ + while (n) { + + s = ((head >= tail) ? head : ch->ch_rsize) - tail; + s = min(s, n); + + if (s <= 0) + break; + + memcpy_fromio(buf, (char *) ch->ch_raddr + tail, s); + dgap_sniff_nowait_nolock(ch, "USER READ", buf, s); + + tail += s; + buf += s; + + n -= s; + /* Flip queue if needed */ + tail &= rmask; + } + + writew(tail, &(bs->rx_tail)); + writeb(1, &(bs->idata)); + ch->ch_rxcount += len; + + /* + * If we are completely raw, we don't need to go through a lot + * of the tty layers that exist. + * In this case, we take the shortest and fastest route we + * can to relay the data to the user. + * + * On the other hand, if we are not raw, we need to go through + * the tty layer, which has its API more well defined. + */ + if (dgap_rawreadok && tp->real_raw) { + + /* !!! WE *MUST* LET GO OF ALL LOCKS BEFORE CALLING RECEIVE BUF !!! */ + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + DPR_READ(("dgap_input. %d real_raw len:%d calling receive_buf for buffer for board %d\n", + __LINE__, len, ch->ch_bd->boardnum)); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31) + tp->ldisc->ops->receive_buf(tp, ch->ch_bd->flipbuf, NULL, len); +#else + tp->ldisc.ops->receive_buf(tp, ch->ch_bd->flipbuf, NULL, len); +#endif + } + else { + if (I_PARMRK(tp) || I_BRKINT(tp) || I_INPCK(tp)) { + dgap_parity_scan(ch, ch->ch_bd->flipbuf, ch->ch_bd->flipflagbuf, &len); + + len = tty_buffer_request_room(tp, len); + tty_insert_flip_string_flags(tp, ch->ch_bd->flipbuf, + ch->ch_bd->flipflagbuf, len); + } + else { + len = tty_buffer_request_room(tp, len); + tty_insert_flip_string(tp, ch->ch_bd->flipbuf, len); + } + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + /* Tell the tty layer its okay to "eat" the data now */ + tty_flip_buffer_push(tp); + } + + if (ld) + tty_ldisc_deref(ld); + + DPR_READ(("dgap_input - finish\n")); +} + + +/************************************************************************ + * Determines when CARRIER changes state and takes appropriate + * action. + ************************************************************************/ +void dgap_carrier(struct channel_t *ch) +{ + struct board_t *bd; + + int virt_carrier = 0; + int phys_carrier = 0; + + DPR_CARR(("dgap_carrier called...\n")); + + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return; + + bd = ch->ch_bd; + + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return; + + /* Make sure altpin is always set correctly */ + if (ch->ch_digi.digi_flags & DIGI_ALTPIN) { + ch->ch_dsr = DM_CD; + ch->ch_cd = DM_DSR; + } + else { + ch->ch_dsr = DM_DSR; + ch->ch_cd = DM_CD; + } + + if (ch->ch_mistat & D_CD(ch)) { + DPR_CARR(("mistat: %x D_CD: %x\n", ch->ch_mistat, D_CD(ch))); + phys_carrier = 1; + } + + if (ch->ch_digi.digi_flags & DIGI_FORCEDCD) { + virt_carrier = 1; + } + + if (ch->ch_c_cflag & CLOCAL) { + virt_carrier = 1; + } + + + DPR_CARR(("DCD: physical: %d virt: %d\n", phys_carrier, virt_carrier)); + + /* + * Test for a VIRTUAL carrier transition to HIGH. + */ + if (((ch->ch_flags & CH_FCAR) == 0) && (virt_carrier == 1)) { + + /* + * When carrier rises, wake any threads waiting + * for carrier in the open routine. + */ + + DPR_CARR(("carrier: virt DCD rose\n")); + + if (waitqueue_active(&(ch->ch_flags_wait))) + wake_up_interruptible(&ch->ch_flags_wait); + } + + /* + * Test for a PHYSICAL carrier transition to HIGH. + */ + if (((ch->ch_flags & CH_CD) == 0) && (phys_carrier == 1)) { + + /* + * When carrier rises, wake any threads waiting + * for carrier in the open routine. + */ + + DPR_CARR(("carrier: physical DCD rose\n")); + + if (waitqueue_active(&(ch->ch_flags_wait))) + wake_up_interruptible(&ch->ch_flags_wait); + } + + /* + * Test for a PHYSICAL transition to low, so long as we aren't + * currently ignoring physical transitions (which is what "virtual + * carrier" indicates). + * + * The transition of the virtual carrier to low really doesn't + * matter... it really only means "ignore carrier state", not + * "make pretend that carrier is there". + */ + if ((virt_carrier == 0) && ((ch->ch_flags & CH_CD) != 0) && + (phys_carrier == 0)) + { + + /* + * When carrier drops: + * + * Drop carrier on all open units. + * + * Flush queues, waking up any task waiting in the + * line discipline. + * + * Send a hangup to the control terminal. + * + * Enable all select calls. + */ + if (waitqueue_active(&(ch->ch_flags_wait))) + wake_up_interruptible(&ch->ch_flags_wait); + + if (ch->ch_tun.un_open_count > 0) { + DPR_CARR(("Sending tty hangup\n")); + tty_hangup(ch->ch_tun.un_tty); + } + + if (ch->ch_pun.un_open_count > 0) { + DPR_CARR(("Sending pr hangup\n")); + tty_hangup(ch->ch_pun.un_tty); + } + } + + /* + * Make sure that our cached values reflect the current reality. + */ + if (virt_carrier == 1) + ch->ch_flags |= CH_FCAR; + else + ch->ch_flags &= ~CH_FCAR; + + if (phys_carrier == 1) + ch->ch_flags |= CH_CD; + else + ch->ch_flags &= ~CH_CD; +} + + +/************************************************************************ + * + * TTY Entry points and helper functions + * + ************************************************************************/ + +/* + * dgap_tty_open() + * + */ +static int dgap_tty_open(struct tty_struct *tty, struct file *file) +{ + struct board_t *brd; + struct channel_t *ch; + struct un_t *un; + struct bs_t *bs; + uint major = 0; + uint minor = 0; + int rc = 0; + ulong lock_flags; + ulong lock_flags2; + u16 head; + + rc = 0; + + major = MAJOR(tty_devnum(tty)); + minor = MINOR(tty_devnum(tty)); + + if (major > 255) { + return -ENXIO; + } + + /* Get board pointer from our array of majors we have allocated */ + brd = dgap_BoardsByMajor[major]; + if (!brd) { + return -ENXIO; + } + + /* + * If board is not yet up to a state of READY, go to + * sleep waiting for it to happen or they cancel the open. + */ + rc = wait_event_interruptible(brd->state_wait, + (brd->state & BOARD_READY)); + + if (rc) { + return rc; + } + + DGAP_LOCK(brd->bd_lock, lock_flags); + + /* The wait above should guarentee this cannot happen */ + if (brd->state != BOARD_READY) { + DGAP_UNLOCK(brd->bd_lock, lock_flags); + return -ENXIO; + } + + /* If opened device is greater than our number of ports, bail. */ + if (MINOR(tty_devnum(tty)) > brd->nasync) { + DGAP_UNLOCK(brd->bd_lock, lock_flags); + return -ENXIO; + } + + ch = brd->channels[minor]; + if (!ch) { + DGAP_UNLOCK(brd->bd_lock, lock_flags); + return -ENXIO; + } + + /* Grab channel lock */ + DGAP_LOCK(ch->ch_lock, lock_flags2); + + /* Figure out our type */ + if (major == brd->dgap_Serial_Major) { + un = &brd->channels[minor]->ch_tun; + un->un_type = DGAP_SERIAL; + } + else if (major == brd->dgap_TransparentPrint_Major) { + un = &brd->channels[minor]->ch_pun; + un->un_type = DGAP_PRINT; + } + else { + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(brd->bd_lock, lock_flags); + DPR_OPEN(("%d Unknown TYPE!\n", __LINE__)); + return -ENXIO; + } + + /* Store our unit into driver_data, so we always have it available. */ + tty->driver_data = un; + + DPR_OPEN(("Open called. MAJOR: %d MINOR:%d unit: %p NAME: %s\n", + MAJOR(tty_devnum(tty)), MINOR(tty_devnum(tty)), un, brd->name)); + + /* + * Error if channel info pointer is 0. + */ + if ((bs = ch->ch_bs) == 0) { + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(brd->bd_lock, lock_flags); + DPR_OPEN(("%d BS is 0!\n", __LINE__)); + return -ENXIO; + } + + DPR_OPEN(("%d: tflag=%x pflag=%x\n", __LINE__, ch->ch_tun.un_flags, ch->ch_pun.un_flags)); + + /* + * Initialize tty's + */ + if (!(un->un_flags & UN_ISOPEN)) { + /* Store important variables. */ + un->un_tty = tty; + + /* Maybe do something here to the TTY struct as well? */ + } + + /* + * Initialize if neither terminal or printer is open. + */ + if (!((ch->ch_tun.un_flags | ch->ch_pun.un_flags) & UN_ISOPEN)) { + + DPR_OPEN(("dgap_open: initializing channel in open...\n")); + + ch->ch_mforce = 0; + ch->ch_mval = 0; + + /* + * Flush input queue. + */ + head = readw(&(bs->rx_head)); + writew(head, &(bs->rx_tail)); + + ch->ch_flags = 0; + ch->pscan_state = 0; + ch->pscan_savechar = 0; + + ch->ch_c_cflag = tty->termios->c_cflag; + ch->ch_c_iflag = tty->termios->c_iflag; + ch->ch_c_oflag = tty->termios->c_oflag; + ch->ch_c_lflag = tty->termios->c_lflag; + ch->ch_startc = tty->termios->c_cc[VSTART]; + ch->ch_stopc = tty->termios->c_cc[VSTOP]; + + /* TODO: flush our TTY struct here? */ + } + + dgap_carrier(ch); + /* + * Run param in case we changed anything + */ + dgap_param(tty); + + /* + * follow protocol for opening port + */ + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(brd->bd_lock, lock_flags); + + rc = dgap_block_til_ready(tty, file, ch); + + if (!un->un_tty) { + return -ENODEV; + } + + if (rc) { + DPR_OPEN(("dgap_tty_open returning after dgap_block_til_ready " + "with %d\n", rc)); + } + + /* No going back now, increment our unit and channel counters */ + DGAP_LOCK(ch->ch_lock, lock_flags); + ch->ch_open_count++; + un->un_open_count++; + un->un_flags |= (UN_ISOPEN); + DGAP_UNLOCK(ch->ch_lock, lock_flags); + + DPR_OPEN(("dgap_tty_open finished\n")); + return (rc); +} + + +/* + * dgap_block_til_ready() + * + * Wait for DCD, if needed. + */ +static int dgap_block_til_ready(struct tty_struct *tty, struct file *file, struct channel_t *ch) +{ + int retval = 0; + struct un_t *un = NULL; + ulong lock_flags; + uint old_flags = 0; + int sleep_on_un_flags = 0; + + if (!tty || tty->magic != TTY_MAGIC || !file || !ch || ch->magic != DGAP_CHANNEL_MAGIC) { + return (-ENXIO); + } + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) { + return (-ENXIO); + } + + DPR_OPEN(("dgap_block_til_ready - before block.\n")); + + DGAP_LOCK(ch->ch_lock, lock_flags); + + ch->ch_wopen++; + + /* Loop forever */ + while (1) { + + sleep_on_un_flags = 0; + + /* + * If board has failed somehow during our sleep, bail with error. + */ + if (ch->ch_bd->state == BOARD_FAILED) { + retval = -ENXIO; + break; + } + + /* If tty was hung up, break out of loop and set error. */ + if (tty_hung_up_p(file)) { + retval = -EAGAIN; + break; + } + + /* + * If either unit is in the middle of the fragile part of close, + * we just cannot touch the channel safely. + * Go back to sleep, knowing that when the channel can be + * touched safely, the close routine will signal the + * ch_wait_flags to wake us back up. + */ + if (!((ch->ch_tun.un_flags | ch->ch_pun.un_flags) & UN_CLOSING)) { + + /* + * Our conditions to leave cleanly and happily: + * 1) NONBLOCKING on the tty is set. + * 2) CLOCAL is set. + * 3) DCD (fake or real) is active. + */ + + if (file->f_flags & O_NONBLOCK) { + break; + } + + if (tty->flags & (1 << TTY_IO_ERROR)) { + break; + } + + if (ch->ch_flags & CH_CD) { + DPR_OPEN(("%d: ch_flags: %x\n", __LINE__, ch->ch_flags)); + break; + } + + if (ch->ch_flags & CH_FCAR) { + DPR_OPEN(("%d: ch_flags: %x\n", __LINE__, ch->ch_flags)); + break; + } + } + else { + sleep_on_un_flags = 1; + } + + /* + * If there is a signal pending, the user probably + * interrupted (ctrl-c) us. + * Leave loop with error set. + */ + if (signal_pending(current)) { + DPR_OPEN(("%d: signal pending...\n", __LINE__)); + retval = -ERESTARTSYS; + break; + } + + DPR_OPEN(("dgap_block_til_ready - blocking.\n")); + + /* + * Store the flags before we let go of channel lock + */ + if (sleep_on_un_flags) + old_flags = ch->ch_tun.un_flags | ch->ch_pun.un_flags; + else + old_flags = ch->ch_flags; + + /* + * Let go of channel lock before calling schedule. + * Our poller will get any FEP events and wake us up when DCD + * eventually goes active. + */ + + DGAP_UNLOCK(ch->ch_lock, lock_flags); + + DPR_OPEN(("Going to sleep on %s flags...\n", + (sleep_on_un_flags ? "un" : "ch"))); + + /* + * Wait for something in the flags to change from the current value. + */ + if (sleep_on_un_flags) { + retval = wait_event_interruptible(un->un_flags_wait, + (old_flags != (ch->ch_tun.un_flags | ch->ch_pun.un_flags))); + } + else { + retval = wait_event_interruptible(ch->ch_flags_wait, + (old_flags != ch->ch_flags)); + } + + DPR_OPEN(("After sleep... retval: %x\n", retval)); + + /* + * We got woken up for some reason. + * Before looping around, grab our channel lock. + */ + DGAP_LOCK(ch->ch_lock, lock_flags); + } + + ch->ch_wopen--; + + DGAP_UNLOCK(ch->ch_lock, lock_flags); + + DPR_OPEN(("dgap_block_til_ready - after blocking.\n")); + + if (retval) { + DPR_OPEN(("dgap_block_til_ready - done. error. retval: %x\n", retval)); + return(retval); + } + + DPR_OPEN(("dgap_block_til_ready - done no error. jiffies: %lu\n", jiffies)); + + return(0); +} + + +/* + * dgap_tty_hangup() + * + * Hangup the port. Like a close, but don't wait for output to drain. + */ +static void dgap_tty_hangup(struct tty_struct *tty) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + + if (!tty || tty->magic != TTY_MAGIC) + return; + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return; + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return; + + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return; + + DPR_CLOSE(("dgap_hangup called. ch->ch_open_count: %d un->un_open_count: %d\n", + ch->ch_open_count, un->un_open_count)); + + /* flush the transmit queues */ + dgap_tty_flush_buffer(tty); + + DPR_CLOSE(("dgap_hangup finished. ch->ch_open_count: %d un->un_open_count: %d\n", + ch->ch_open_count, un->un_open_count)); +} + + + +/* + * dgap_tty_close() + * + */ +static void dgap_tty_close(struct tty_struct *tty, struct file *file) +{ + struct ktermios *ts; + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + ulong lock_flags; + int rc = 0; + + if (!tty || tty->magic != TTY_MAGIC) + return; + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return; + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return; + + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return; + + ts = tty->termios; + + DPR_CLOSE(("Close called\n")); + + DGAP_LOCK(ch->ch_lock, lock_flags); + + /* + * Determine if this is the last close or not - and if we agree about + * which type of close it is with the Line Discipline + */ + if ((tty->count == 1) && (un->un_open_count != 1)) { + /* + * Uh, oh. tty->count is 1, which means that the tty + * structure will be freed. un_open_count should always + * be one in these conditions. If it's greater than + * one, we've got real problems, since it means the + * serial port won't be shutdown. + */ + APR(("tty->count is 1, un open count is %d\n", un->un_open_count)); + un->un_open_count = 1; + } + + if (--un->un_open_count < 0) { + APR(("bad serial port open count of %d\n", un->un_open_count)); + un->un_open_count = 0; + } + + ch->ch_open_count--; + + if (ch->ch_open_count && un->un_open_count) { + DPR_CLOSE(("dgap_tty_close: not last close ch: %d un:%d\n", + ch->ch_open_count, un->un_open_count)); + + DGAP_UNLOCK(ch->ch_lock, lock_flags); + return; + } + + /* OK, its the last close on the unit */ + DPR_CLOSE(("dgap_tty_close - last close on unit procedures\n")); + + un->un_flags |= UN_CLOSING; + + tty->closing = 1; + + /* + * Only officially close channel if count is 0 and + * DIGI_PRINTER bit is not set. + */ + if ((ch->ch_open_count == 0) && !(ch->ch_digi.digi_flags & DIGI_PRINTER)) { + + ch->ch_flags &= ~(CH_RXBLOCK); + + DGAP_UNLOCK(ch->ch_lock, lock_flags); + + /* wait for output to drain */ + /* This will also return if we take an interrupt */ + + DPR_CLOSE(("Calling wait_for_drain\n")); + rc = dgap_wait_for_drain(tty); + DPR_CLOSE(("After calling wait_for_drain\n")); + + if (rc) { + DPR_BASIC(("dgap_tty_close - bad return: %d ", rc)); + } + + dgap_tty_flush_buffer(tty); + tty_ldisc_flush(tty); + + DGAP_LOCK(ch->ch_lock, lock_flags); + + tty->closing = 0; + + /* + * If we have HUPCL set, lower DTR and RTS + */ + if (ch->ch_c_cflag & HUPCL ) { + DPR_CLOSE(("Close. HUPCL set, dropping DTR/RTS\n")); + ch->ch_mostat &= ~(D_RTS(ch)|D_DTR(ch)); + dgap_cmdb( ch, SMODEM, 0, D_DTR(ch)|D_RTS(ch), 0 ); + + /* + * Go to sleep to ensure RTS/DTR + * have been dropped for modems to see it. + */ + if (ch->ch_close_delay) { + DPR_CLOSE(("Close. Sleeping for RTS/DTR drop\n")); + + DGAP_UNLOCK(ch->ch_lock, lock_flags); + dgap_ms_sleep(ch->ch_close_delay); + DGAP_LOCK(ch->ch_lock, lock_flags); + + DPR_CLOSE(("Close. After sleeping for RTS/DTR drop\n")); + } + } + + ch->pscan_state = 0; + ch->pscan_savechar = 0; + ch->ch_baud_info = 0; + + } + + /* + * turn off print device when closing print device. + */ + if ((un->un_type == DGAP_PRINT) && (ch->ch_flags & CH_PRON) ) { + dgap_wmove(ch, ch->ch_digi.digi_offstr, + (int) ch->ch_digi.digi_offlen); + ch->ch_flags &= ~CH_PRON; + } + + un->un_tty = NULL; + un->un_flags &= ~(UN_ISOPEN | UN_CLOSING); + tty->driver_data = NULL; + + DPR_CLOSE(("Close. Doing wakeups\n")); + wake_up_interruptible(&ch->ch_flags_wait); + wake_up_interruptible(&un->un_flags_wait); + + DGAP_UNLOCK(ch->ch_lock, lock_flags); + + DPR_BASIC(("dgap_tty_close - complete\n")); +} + + +/* + * dgap_tty_chars_in_buffer() + * + * Return number of characters that have not been transmitted yet. + * + * This routine is used by the line discipline to determine if there + * is data waiting to be transmitted/drained/flushed or not. + */ +static int dgap_tty_chars_in_buffer(struct tty_struct *tty) +{ + struct board_t *bd = NULL; + struct channel_t *ch = NULL; + struct un_t *un = NULL; + struct bs_t *bs = NULL; + uchar tbusy; + uint chars = 0; + u16 thead, ttail, tmask, chead, ctail; + ulong lock_flags = 0; + ulong lock_flags2 = 0; + + if (tty == NULL) + return(0); + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return (0); + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return (0); + + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return (0); + + bs = ch->ch_bs; + if (!bs) + return (0); + + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + + tmask = (ch->ch_tsize - 1); + + /* Get Transmit queue pointers */ + thead = readw(&(bs->tx_head)) & tmask; + ttail = readw(&(bs->tx_tail)) & tmask; + + /* Get tbusy flag */ + tbusy = readb(&(bs->tbusy)); + + /* Get Command queue pointers */ + chead = readw(&(ch->ch_cm->cm_head)); + ctail = readw(&(ch->ch_cm->cm_tail)); + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + /* + * The only way we know for sure if there is no pending + * data left to be transferred, is if: + * 1) Transmit head and tail are equal (empty). + * 2) Command queue head and tail are equal (empty). + * 3) The "TBUSY" flag is 0. (Transmitter not busy). + */ + + if ((ttail == thead) && (tbusy == 0) && (chead == ctail)) { + chars = 0; + } + else { + if (thead >= ttail) + chars = thead - ttail; + else + chars = thead - ttail + ch->ch_tsize; + /* + * Fudge factor here. + * If chars is zero, we know that the command queue had + * something in it or tbusy was set. Because we cannot + * be sure if there is still some data to be transmitted, + * lets lie, and tell ld we have 1 byte left. + */ + if (chars == 0) { + /* + * If TBUSY is still set, and our tx buffers are empty, + * force the firmware to send me another wakeup after + * TBUSY has been cleared. + */ + if (tbusy != 0) { + DGAP_LOCK(ch->ch_lock, lock_flags); + un->un_flags |= UN_EMPTY; + writeb(1, &(bs->iempty)); + DGAP_UNLOCK(ch->ch_lock, lock_flags); + } + chars = 1; + } + } + + DPR_WRITE(("dgap_tty_chars_in_buffer. Port: %x - %d (head: %d tail: %d tsize: %d)\n", + ch->ch_portnum, chars, thead, ttail, ch->ch_tsize)); + return(chars); +} + + +static int dgap_wait_for_drain(struct tty_struct *tty) +{ + struct channel_t *ch; + struct un_t *un; + struct bs_t *bs; + int ret = -EIO; + uint count = 1; + ulong lock_flags = 0; + + if (!tty || tty->magic != TTY_MAGIC) + return ret; + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return ret; + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return ret; + + bs = ch->ch_bs; + if (!bs) + return ret; + + ret = 0; + + DPR_DRAIN(("dgap_wait_for_drain start\n")); + + /* Loop until data is drained */ + while (count != 0) { + + count = dgap_tty_chars_in_buffer(tty); + + if (count == 0) + break; + + /* Set flag waiting for drain */ + DGAP_LOCK(ch->ch_lock, lock_flags); + un->un_flags |= UN_EMPTY; + writeb(1, &(bs->iempty)); + DGAP_UNLOCK(ch->ch_lock, lock_flags); + + /* Go to sleep till we get woken up */ + ret = wait_event_interruptible(un->un_flags_wait, ((un->un_flags & UN_EMPTY) == 0)); + /* If ret is non-zero, user ctrl-c'ed us */ + if (ret) { + break; + } + } + + DGAP_LOCK(ch->ch_lock, lock_flags); + un->un_flags &= ~(UN_EMPTY); + DGAP_UNLOCK(ch->ch_lock, lock_flags); + + DPR_DRAIN(("dgap_wait_for_drain finish\n")); + return (ret); +} + + +/* + * dgap_maxcps_room + * + * Reduces bytes_available to the max number of characters + * that can be sent currently given the maxcps value, and + * returns the new bytes_available. This only affects printer + * output. + */ +static int dgap_maxcps_room(struct tty_struct *tty, int bytes_available) +{ + struct channel_t *ch = NULL; + struct un_t *un = NULL; + + if (tty == NULL) + return (bytes_available); + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return (bytes_available); + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return (bytes_available); + + /* + * If its not the Transparent print device, return + * the full data amount. + */ + if (un->un_type != DGAP_PRINT) + return (bytes_available); + + if (ch->ch_digi.digi_maxcps > 0 && ch->ch_digi.digi_bufsize > 0 ) { + int cps_limit = 0; + unsigned long current_time = jiffies; + unsigned long buffer_time = current_time + + (HZ * ch->ch_digi.digi_bufsize) / ch->ch_digi.digi_maxcps; + + if (ch->ch_cpstime < current_time) { + /* buffer is empty */ + ch->ch_cpstime = current_time; /* reset ch_cpstime */ + cps_limit = ch->ch_digi.digi_bufsize; + } + else if (ch->ch_cpstime < buffer_time) { + /* still room in the buffer */ + cps_limit = ((buffer_time - ch->ch_cpstime) * ch->ch_digi.digi_maxcps) / HZ; + } + else { + /* no room in the buffer */ + cps_limit = 0; + } + + bytes_available = min(cps_limit, bytes_available); + } + + return (bytes_available); +} + + +static inline void dgap_set_firmware_event(struct un_t *un, unsigned int event) +{ + struct channel_t *ch = NULL; + struct bs_t *bs = NULL; + + if (!un || un->magic != DGAP_UNIT_MAGIC) + return; + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return; + bs = ch->ch_bs; + if (!bs) + return; + + if ((event & UN_LOW) != 0) { + if ((un->un_flags & UN_LOW) == 0) { + un->un_flags |= UN_LOW; + writeb(1, &(bs->ilow)); + } + } + if ((event & UN_LOW) != 0) { + if ((un->un_flags & UN_EMPTY) == 0) { + un->un_flags |= UN_EMPTY; + writeb(1, &(bs->iempty)); + } + } +} + + +/* + * dgap_tty_write_room() + * + * Return space available in Tx buffer + */ +static int dgap_tty_write_room(struct tty_struct *tty) +{ + struct channel_t *ch = NULL; + struct un_t *un = NULL; + struct bs_t *bs = NULL; + u16 head, tail, tmask; + int ret = 0; + ulong lock_flags = 0; + + if (tty == NULL || dgap_TmpWriteBuf == NULL) + return(0); + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return (0); + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return (0); + + bs = ch->ch_bs; + if (!bs) + return (0); + + DGAP_LOCK(ch->ch_lock, lock_flags); + + tmask = ch->ch_tsize - 1; + head = readw(&(bs->tx_head)) & tmask; + tail = readw(&(bs->tx_tail)) & tmask; + + if ((ret = tail - head - 1) < 0) + ret += ch->ch_tsize; + + /* Limit printer to maxcps */ + ret = dgap_maxcps_room(tty, ret); + + /* + * If we are printer device, leave space for + * possibly both the on and off strings. + */ + if (un->un_type == DGAP_PRINT) { + if (!(ch->ch_flags & CH_PRON)) + ret -= ch->ch_digi.digi_onlen; + ret -= ch->ch_digi.digi_offlen; + } + else { + if (ch->ch_flags & CH_PRON) + ret -= ch->ch_digi.digi_offlen; + } + + if (ret < 0) + ret = 0; + + /* + * Schedule FEP to wake us up if needed. + * + * TODO: This might be overkill... + * Do we really need to schedule callbacks from the FEP + * in every case? Can we get smarter based on ret? + */ + dgap_set_firmware_event(un, UN_LOW | UN_EMPTY); + DGAP_UNLOCK(ch->ch_lock, lock_flags); + + DPR_WRITE(("dgap_tty_write_room - %d tail: %d head: %d\n", ret, tail, head)); + + return(ret); +} + + +/* + * dgap_tty_put_char() + * + * Put a character into ch->ch_buf + * + * - used by the line discipline for OPOST processing + */ +static int dgap_tty_put_char(struct tty_struct *tty, unsigned char c) +{ + /* + * Simply call tty_write. + */ + DPR_WRITE(("dgap_tty_put_char called\n")); + dgap_tty_write(tty, &c, 1); + return 1; +} + + +/* + * dgap_tty_write() + * + * Take data from the user or kernel and send it out to the FEP. + * In here exists all the Transparent Print magic as well. + */ +static int dgap_tty_write(struct tty_struct *tty, const unsigned char *buf, int count) +{ + struct channel_t *ch = NULL; + struct un_t *un = NULL; + struct bs_t *bs = NULL; + char *vaddr = NULL; + u16 head, tail, tmask, remain; + int bufcount = 0, n = 0; + int orig_count = 0; + ulong lock_flags; + int from_user = 0; + + if (tty == NULL || dgap_TmpWriteBuf == NULL) + return(0); + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return (0); + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return(0); + + bs = ch->ch_bs; + if (!bs) + return(0); + + if (!count) + return(0); + + DPR_WRITE(("dgap_tty_write: Port: %x tty=%p user=%d len=%d\n", + ch->ch_portnum, tty, from_user, count)); + + /* + * Store original amount of characters passed in. + * This helps to figure out if we should ask the FEP + * to send us an event when it has more space available. + */ + orig_count = count; + + DGAP_LOCK(ch->ch_lock, lock_flags); + + /* Get our space available for the channel from the board */ + tmask = ch->ch_tsize - 1; + head = readw(&(bs->tx_head)) & tmask; + tail = readw(&(bs->tx_tail)) & tmask; + + if ((bufcount = tail - head - 1) < 0) + bufcount += ch->ch_tsize; + + DPR_WRITE(("%d: bufcount: %x count: %x tail: %x head: %x tmask: %x\n", + __LINE__, bufcount, count, tail, head, tmask)); + + /* + * Limit printer output to maxcps overall, with bursts allowed + * up to bufsize characters. + */ + bufcount = dgap_maxcps_room(tty, bufcount); + + /* + * Take minimum of what the user wants to send, and the + * space available in the FEP buffer. + */ + count = min(count, bufcount); + + /* + * Bail if no space left. + */ + if (count <= 0) { + dgap_set_firmware_event(un, UN_LOW | UN_EMPTY); + DGAP_UNLOCK(ch->ch_lock, lock_flags); + return(0); + } + + /* + * Output the printer ON string, if we are in terminal mode, but + * need to be in printer mode. + */ + if ((un->un_type == DGAP_PRINT) && !(ch->ch_flags & CH_PRON)) { + dgap_wmove(ch, ch->ch_digi.digi_onstr, + (int) ch->ch_digi.digi_onlen); + head = readw(&(bs->tx_head)) & tmask; + ch->ch_flags |= CH_PRON; + } + + /* + * On the other hand, output the printer OFF string, if we are + * currently in printer mode, but need to output to the terminal. + */ + if ((un->un_type != DGAP_PRINT) && (ch->ch_flags & CH_PRON)) { + dgap_wmove(ch, ch->ch_digi.digi_offstr, + (int) ch->ch_digi.digi_offlen); + head = readw(&(bs->tx_head)) & tmask; + ch->ch_flags &= ~CH_PRON; + } + + /* + * If there is nothing left to copy, or I can't handle any more data, leave. + */ + if (count <= 0) { + dgap_set_firmware_event(un, UN_LOW | UN_EMPTY); + DGAP_UNLOCK(ch->ch_lock, lock_flags); + return(0); + } + + if (from_user) { + + count = min(count, WRITEBUFLEN); + + DGAP_UNLOCK(ch->ch_lock, lock_flags); + + /* + * If data is coming from user space, copy it into a temporary + * buffer so we don't get swapped out while doing the copy to + * the board. + */ + /* we're allowed to block if it's from_user */ + if (down_interruptible(&dgap_TmpWriteSem)) { + return (-EINTR); + } + + if (copy_from_user(dgap_TmpWriteBuf, (const uchar __user *) buf, count)) { + up(&dgap_TmpWriteSem); + printk("Write: Copy from user failed!\n"); + return -EFAULT; + } + + DGAP_LOCK(ch->ch_lock, lock_flags); + + buf = dgap_TmpWriteBuf; + } + + n = count; + + /* + * If the write wraps over the top of the circular buffer, + * move the portion up to the wrap point, and reset the + * pointers to the bottom. + */ + remain = ch->ch_tstart + ch->ch_tsize - head; + + if (n >= remain) { + n -= remain; + vaddr = ch->ch_taddr + head; + + memcpy_toio(vaddr, (uchar *) buf, remain); + dgap_sniff_nowait_nolock(ch, "USER WRITE", (uchar *) buf, remain); + + head = ch->ch_tstart; + buf += remain; + } + + if (n > 0) { + + /* + * Move rest of data. + */ + vaddr = ch->ch_taddr + head; + remain = n; + + memcpy_toio(vaddr, (uchar *) buf, remain); + dgap_sniff_nowait_nolock(ch, "USER WRITE", (uchar *) buf, remain); + + head += remain; + + } + + if (count) { + ch->ch_txcount += count; + head &= tmask; + writew(head, &(bs->tx_head)); + } + + + dgap_set_firmware_event(un, UN_LOW | UN_EMPTY); + + /* + * If this is the print device, and the + * printer is still on, we need to turn it + * off before going idle. If the buffer is + * non-empty, wait until it goes empty. + * Otherwise turn it off right now. + */ + if ((un->un_type == DGAP_PRINT) && (ch->ch_flags & CH_PRON)) { + tail = readw(&(bs->tx_tail)) & tmask; + + if (tail != head) { + un->un_flags |= UN_EMPTY; + writeb(1, &(bs->iempty)); + } + else { + dgap_wmove(ch, ch->ch_digi.digi_offstr, + (int) ch->ch_digi.digi_offlen); + head = readw(&(bs->tx_head)) & tmask; + ch->ch_flags &= ~CH_PRON; + } + } + + /* Update printer buffer empty time. */ + if ((un->un_type == DGAP_PRINT) && (ch->ch_digi.digi_maxcps > 0) + && (ch->ch_digi.digi_bufsize > 0)) { + ch->ch_cpstime += (HZ * count) / ch->ch_digi.digi_maxcps; + } + + if (from_user) { + DGAP_UNLOCK(ch->ch_lock, lock_flags); + up(&dgap_TmpWriteSem); + } + else { + DGAP_UNLOCK(ch->ch_lock, lock_flags); + } + + DPR_WRITE(("Write finished - Write %d bytes of %d.\n", count, orig_count)); + + return (count); +} + + + +/* + * Return modem signals to ld. + */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39) +static int dgap_tty_tiocmget(struct tty_struct *tty) +#else +static int dgap_tty_tiocmget(struct tty_struct *tty, struct file *file) +#endif +{ + struct channel_t *ch; + struct un_t *un; + int result = -EIO; + uchar mstat = 0; + ulong lock_flags; + + if (!tty || tty->magic != TTY_MAGIC) + return result; + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return result; + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return result; + + DPR_IOCTL(("dgap_tty_tiocmget start\n")); + + DGAP_LOCK(ch->ch_lock, lock_flags); + + mstat = readb(&(ch->ch_bs->m_stat)); + /* Append any outbound signals that might be pending... */ + mstat |= ch->ch_mostat; + + DGAP_UNLOCK(ch->ch_lock, lock_flags); + + result = 0; + + if (mstat & D_DTR(ch)) + result |= TIOCM_DTR; + if (mstat & D_RTS(ch)) + result |= TIOCM_RTS; + if (mstat & D_CTS(ch)) + result |= TIOCM_CTS; + if (mstat & D_DSR(ch)) + result |= TIOCM_DSR; + if (mstat & D_RI(ch)) + result |= TIOCM_RI; + if (mstat & D_CD(ch)) + result |= TIOCM_CD; + + DPR_IOCTL(("dgap_tty_tiocmget finish\n")); + + return result; +} + + +/* + * dgap_tty_tiocmset() + * + * Set modem signals, called by ld. + */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39) +static int dgap_tty_tiocmset(struct tty_struct *tty, + unsigned int set, unsigned int clear) +#else +static int dgap_tty_tiocmset(struct tty_struct *tty, struct file *file, + unsigned int set, unsigned int clear) +#endif +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + int ret = -EIO; + ulong lock_flags; + ulong lock_flags2; + + if (!tty || tty->magic != TTY_MAGIC) + return ret; + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return ret; + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return ret; + + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return ret; + + DPR_IOCTL(("dgap_tty_tiocmset start\n")); + + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + + if (set & TIOCM_RTS) { + ch->ch_mforce |= D_RTS(ch); + ch->ch_mval |= D_RTS(ch); + } + + if (set & TIOCM_DTR) { + ch->ch_mforce |= D_DTR(ch); + ch->ch_mval |= D_DTR(ch); + } + + if (clear & TIOCM_RTS) { + ch->ch_mforce |= D_RTS(ch); + ch->ch_mval &= ~(D_RTS(ch)); + } + + if (clear & TIOCM_DTR) { + ch->ch_mforce |= D_DTR(ch); + ch->ch_mval &= ~(D_DTR(ch)); + } + + dgap_param(tty); + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + DPR_IOCTL(("dgap_tty_tiocmset finish\n")); + + return (0); +} + + + +/* + * dgap_tty_send_break() + * + * Send a Break, called by ld. + */ +static int dgap_tty_send_break(struct tty_struct *tty, int msec) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + int ret = -EIO; + ulong lock_flags; + ulong lock_flags2; + + if (!tty || tty->magic != TTY_MAGIC) + return ret; + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return ret; + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return ret; + + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return ret; + + switch (msec) { + case -1: + msec = 0xFFFF; + break; + case 0: + msec = 1; + break; + default: + msec /= 10; + break; + } + + DPR_IOCTL(("dgap_tty_send_break start 1. %lx\n", jiffies)); + + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); +#if 0 + dgap_cmdw(ch, SBREAK, (u16) SBREAK_TIME, 0); +#endif + dgap_cmdw(ch, SBREAK, (u16) msec, 0); + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + DPR_IOCTL(("dgap_tty_send_break finish\n")); + + return (0); +} + + + + +/* + * dgap_tty_wait_until_sent() + * + * wait until data has been transmitted, called by ld. + */ +static void dgap_tty_wait_until_sent(struct tty_struct *tty, int timeout) +{ + int rc; + rc = dgap_wait_for_drain(tty); + if (rc) { + DPR_IOCTL(("dgap_tty_ioctl - bad return: %d ", rc)); + return; + } + return; +} + + + +/* + * dgap_send_xchar() + * + * send a high priority character, called by ld. + */ +static void dgap_tty_send_xchar(struct tty_struct *tty, char c) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + ulong lock_flags; + ulong lock_flags2; + + if (!tty || tty->magic != TTY_MAGIC) + return; + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return; + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return; + + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return; + + DPR_IOCTL(("dgap_tty_send_xchar start 1. %lx\n", jiffies)); + + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + + /* + * This is technically what we should do. + * However, the NIST tests specifically want + * to see each XON or XOFF character that it + * sends, so lets just send each character + * by hand... + */ +#if 0 + if (c == STOP_CHAR(tty)) { + dgap_cmdw(ch, RPAUSE, 0, 0); + } + else if (c == START_CHAR(tty)) { + dgap_cmdw(ch, RRESUME, 0, 0); + } + else { + dgap_wmove(ch, &c, 1); + } +#else + dgap_wmove(ch, &c, 1); +#endif + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + DPR_IOCTL(("dgap_tty_send_xchar finish\n")); + + return; +} + + + + +/* + * Return modem signals to ld. + */ +static int dgap_get_modem_info(struct channel_t *ch, unsigned int __user *value) +{ + int result = 0; + uchar mstat = 0; + ulong lock_flags; + int rc = 0; + + DPR_IOCTL(("dgap_get_modem_info start\n")); + + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return(-ENXIO); + + DGAP_LOCK(ch->ch_lock, lock_flags); + + mstat = readb(&(ch->ch_bs->m_stat)); + /* Append any outbound signals that might be pending... */ + mstat |= ch->ch_mostat; + + DGAP_UNLOCK(ch->ch_lock, lock_flags); + + result = 0; + + if (mstat & D_DTR(ch)) + result |= TIOCM_DTR; + if (mstat & D_RTS(ch)) + result |= TIOCM_RTS; + if (mstat & D_CTS(ch)) + result |= TIOCM_CTS; + if (mstat & D_DSR(ch)) + result |= TIOCM_DSR; + if (mstat & D_RI(ch)) + result |= TIOCM_RI; + if (mstat & D_CD(ch)) + result |= TIOCM_CD; + + rc = put_user(result, value); + + DPR_IOCTL(("dgap_get_modem_info finish\n")); + return(rc); +} + + +/* + * dgap_set_modem_info() + * + * Set modem signals, called by ld. + */ +static int dgap_set_modem_info(struct tty_struct *tty, unsigned int command, unsigned int __user *value) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + int ret = -ENXIO; + unsigned int arg = 0; + ulong lock_flags; + ulong lock_flags2; + + if (!tty || tty->magic != TTY_MAGIC) + return ret; + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return ret; + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return ret; + + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return ret; + + DPR_IOCTL(("dgap_set_modem_info() start\n")); + + ret = get_user(arg, value); + if (ret) { + DPR_IOCTL(("dgap_set_modem_info %d ret: %x. finished.\n", __LINE__, ret)); + return(ret); + } + + DPR_IOCTL(("dgap_set_modem_info: command: %x arg: %x\n", command, arg)); + + switch (command) { + case TIOCMBIS: + if (arg & TIOCM_RTS) { + ch->ch_mforce |= D_RTS(ch); + ch->ch_mval |= D_RTS(ch); + } + + if (arg & TIOCM_DTR) { + ch->ch_mforce |= D_DTR(ch); + ch->ch_mval |= D_DTR(ch); + } + + break; + + case TIOCMBIC: + if (arg & TIOCM_RTS) { + ch->ch_mforce |= D_RTS(ch); + ch->ch_mval &= ~(D_RTS(ch)); + } + + if (arg & TIOCM_DTR) { + ch->ch_mforce |= D_DTR(ch); + ch->ch_mval &= ~(D_DTR(ch)); + } + + break; + + case TIOCMSET: + ch->ch_mforce = D_DTR(ch)|D_RTS(ch); + + if (arg & TIOCM_RTS) { + ch->ch_mval |= D_RTS(ch); + } + else { + ch->ch_mval &= ~(D_RTS(ch)); + } + + if (arg & TIOCM_DTR) { + ch->ch_mval |= (D_DTR(ch)); + } + else { + ch->ch_mval &= ~(D_DTR(ch)); + } + + break; + + default: + return(-EINVAL); + } + + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + + dgap_param(tty); + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + DPR_IOCTL(("dgap_set_modem_info finish\n")); + + return (0); +} + + +/* + * dgap_tty_digigeta() + * + * Ioctl to get the information for ditty. + * + * + * + */ +static int dgap_tty_digigeta(struct tty_struct *tty, struct digi_t __user *retinfo) +{ + struct channel_t *ch; + struct un_t *un; + struct digi_t tmp; + ulong lock_flags; + + if (!retinfo) + return (-EFAULT); + + if (!tty || tty->magic != TTY_MAGIC) + return (-EFAULT); + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return (-EFAULT); + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return (-EFAULT); + + memset(&tmp, 0, sizeof(tmp)); + + DGAP_LOCK(ch->ch_lock, lock_flags); + memcpy(&tmp, &ch->ch_digi, sizeof(tmp)); + DGAP_UNLOCK(ch->ch_lock, lock_flags); + + if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) + return (-EFAULT); + + return (0); +} + + +/* + * dgap_tty_digiseta() + * + * Ioctl to set the information for ditty. + * + * + * + */ +static int dgap_tty_digiseta(struct tty_struct *tty, struct digi_t __user *new_info) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + struct digi_t new_digi; + ulong lock_flags = 0; + unsigned long lock_flags2; + + DPR_IOCTL(("DIGI_SETA start\n")); + + if (!tty || tty->magic != TTY_MAGIC) + return (-EFAULT); + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return (-EFAULT); + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return (-EFAULT); + + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return (-EFAULT); + + if (copy_from_user(&new_digi, new_info, sizeof(struct digi_t))) { + DPR_IOCTL(("DIGI_SETA failed copy_from_user\n")); + return(-EFAULT); + } + + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + + memcpy(&ch->ch_digi, &new_digi, sizeof(struct digi_t)); + + if (ch->ch_digi.digi_maxcps < 1) + ch->ch_digi.digi_maxcps = 1; + + if (ch->ch_digi.digi_maxcps > 10000) + ch->ch_digi.digi_maxcps = 10000; + + if (ch->ch_digi.digi_bufsize < 10) + ch->ch_digi.digi_bufsize = 10; + + if (ch->ch_digi.digi_maxchar < 1) + ch->ch_digi.digi_maxchar = 1; + + if (ch->ch_digi.digi_maxchar > ch->ch_digi.digi_bufsize) + ch->ch_digi.digi_maxchar = ch->ch_digi.digi_bufsize; + + if (ch->ch_digi.digi_onlen > DIGI_PLEN) + ch->ch_digi.digi_onlen = DIGI_PLEN; + + if (ch->ch_digi.digi_offlen > DIGI_PLEN) + ch->ch_digi.digi_offlen = DIGI_PLEN; + + dgap_param(tty); + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + DPR_IOCTL(("DIGI_SETA finish\n")); + + return(0); +} + + +/* + * dgap_tty_digigetedelay() + * + * Ioctl to get the current edelay setting. + * + * + * + */ +static int dgap_tty_digigetedelay(struct tty_struct *tty, int __user *retinfo) +{ + struct channel_t *ch; + struct un_t *un; + int tmp; + ulong lock_flags; + + if (!retinfo) + return (-EFAULT); + + if (!tty || tty->magic != TTY_MAGIC) + return (-EFAULT); + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return (-EFAULT); + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return (-EFAULT); + + memset(&tmp, 0, sizeof(tmp)); + + DGAP_LOCK(ch->ch_lock, lock_flags); + tmp = readw(&(ch->ch_bs->edelay)); + DGAP_UNLOCK(ch->ch_lock, lock_flags); + + if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) + return (-EFAULT); + + return (0); +} + + +/* + * dgap_tty_digisetedelay() + * + * Ioctl to set the EDELAY setting + * + */ +static int dgap_tty_digisetedelay(struct tty_struct *tty, int __user *new_info) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + int new_digi; + ulong lock_flags; + ulong lock_flags2; + + DPR_IOCTL(("DIGI_SETA start\n")); + + if (!tty || tty->magic != TTY_MAGIC) + return (-EFAULT); + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return (-EFAULT); + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return (-EFAULT); + + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return (-EFAULT); + + if (copy_from_user(&new_digi, new_info, sizeof(int))) { + DPR_IOCTL(("DIGI_SETEDELAY failed copy_from_user\n")); + return(-EFAULT); + } + + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + + writew((u16) new_digi, &(ch->ch_bs->edelay)); + + dgap_param(tty); + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + DPR_IOCTL(("DIGI_SETA finish\n")); + + return(0); +} + + +/* + * dgap_tty_digigetcustombaud() + * + * Ioctl to get the current custom baud rate setting. + */ +static int dgap_tty_digigetcustombaud(struct tty_struct *tty, int __user *retinfo) +{ + struct channel_t *ch; + struct un_t *un; + int tmp; + ulong lock_flags; + + if (!retinfo) + return (-EFAULT); + + if (!tty || tty->magic != TTY_MAGIC) + return (-EFAULT); + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return (-EFAULT); + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return (-EFAULT); + + memset(&tmp, 0, sizeof(tmp)); + + DGAP_LOCK(ch->ch_lock, lock_flags); + tmp = dgap_get_custom_baud(ch); + DGAP_UNLOCK(ch->ch_lock, lock_flags); + + DPR_IOCTL(("DIGI_GETCUSTOMBAUD. Returning %d\n", tmp)); + + if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) + return (-EFAULT); + + return (0); +} + + +/* + * dgap_tty_digisetcustombaud() + * + * Ioctl to set the custom baud rate setting + */ +static int dgap_tty_digisetcustombaud(struct tty_struct *tty, int __user *new_info) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + uint new_rate; + ulong lock_flags; + ulong lock_flags2; + + DPR_IOCTL(("DIGI_SETCUSTOMBAUD start\n")); + + if (!tty || tty->magic != TTY_MAGIC) + return (-EFAULT); + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return (-EFAULT); + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return (-EFAULT); + + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return (-EFAULT); + + + if (copy_from_user(&new_rate, new_info, sizeof(unsigned int))) { + DPR_IOCTL(("DIGI_SETCUSTOMBAUD failed copy_from_user\n")); + return(-EFAULT); + } + + if (bd->bd_flags & BD_FEP5PLUS) { + + DPR_IOCTL(("DIGI_SETCUSTOMBAUD. Setting %d\n", new_rate)); + + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + + ch->ch_custom_speed = new_rate; + + dgap_param(tty); + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + } + + DPR_IOCTL(("DIGI_SETCUSTOMBAUD finish\n")); + + return(0); +} + + +/* + * dgap_set_termios() + */ +static void dgap_tty_set_termios(struct tty_struct *tty, struct ktermios *old_termios) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + unsigned long lock_flags; + unsigned long lock_flags2; + + if (!tty || tty->magic != TTY_MAGIC) + return; + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return; + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return; + + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return; + + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + + ch->ch_c_cflag = tty->termios->c_cflag; + ch->ch_c_iflag = tty->termios->c_iflag; + ch->ch_c_oflag = tty->termios->c_oflag; + ch->ch_c_lflag = tty->termios->c_lflag; + ch->ch_startc = tty->termios->c_cc[VSTART]; + ch->ch_stopc = tty->termios->c_cc[VSTOP]; + + dgap_carrier(ch); + dgap_param(tty); + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); +} + + +static void dgap_tty_throttle(struct tty_struct *tty) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + ulong lock_flags; + ulong lock_flags2; + + if (!tty || tty->magic != TTY_MAGIC) + return; + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return; + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return; + + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return; + + DPR_IOCTL(("dgap_tty_throttle start\n")); + + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + + ch->ch_flags |= (CH_RXBLOCK); +#if 1 + dgap_cmdw(ch, RPAUSE, 0, 0); +#endif + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + DPR_IOCTL(("dgap_tty_throttle finish\n")); +} + + +static void dgap_tty_unthrottle(struct tty_struct *tty) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + ulong lock_flags; + ulong lock_flags2; + + if (!tty || tty->magic != TTY_MAGIC) + return; + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return; + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return; + + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return; + + DPR_IOCTL(("dgap_tty_unthrottle start\n")); + + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + + ch->ch_flags &= ~(CH_RXBLOCK); + +#if 1 + dgap_cmdw(ch, RRESUME, 0, 0); +#endif + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + DPR_IOCTL(("dgap_tty_unthrottle finish\n")); +} + + +static void dgap_tty_start(struct tty_struct *tty) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + ulong lock_flags; + ulong lock_flags2; + + if (!tty || tty->magic != TTY_MAGIC) + return; + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return; + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return; + + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return; + + DPR_IOCTL(("dgap_tty_start start\n")); + + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + + dgap_cmdw(ch, RESUMETX, 0, 0); + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + DPR_IOCTL(("dgap_tty_start finish\n")); +} + + +static void dgap_tty_stop(struct tty_struct *tty) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + ulong lock_flags; + ulong lock_flags2; + + if (!tty || tty->magic != TTY_MAGIC) + return; + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return; + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return; + + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return; + + DPR_IOCTL(("dgap_tty_stop start\n")); + + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + + dgap_cmdw(ch, PAUSETX, 0, 0); + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + DPR_IOCTL(("dgap_tty_stop finish\n")); +} + + +/* + * dgap_tty_flush_chars() + * + * Flush the cook buffer + * + * Note to self, and any other poor souls who venture here: + * + * flush in this case DOES NOT mean dispose of the data. + * instead, it means "stop buffering and send it if you + * haven't already." Just guess how I figured that out... SRW 2-Jun-98 + * + * It is also always called in interrupt context - JAR 8-Sept-99 + */ +static void dgap_tty_flush_chars(struct tty_struct *tty) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + ulong lock_flags; + ulong lock_flags2; + + if (!tty || tty->magic != TTY_MAGIC) + return; + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return; + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return; + + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return; + + DPR_IOCTL(("dgap_tty_flush_chars start\n")); + + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + + /* TODO: Do something here */ + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + DPR_IOCTL(("dgap_tty_flush_chars finish\n")); +} + + + +/* + * dgap_tty_flush_buffer() + * + * Flush Tx buffer (make in == out) + */ +static void dgap_tty_flush_buffer(struct tty_struct *tty) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + ulong lock_flags; + ulong lock_flags2; + u16 head = 0; + + if (!tty || tty->magic != TTY_MAGIC) + return; + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return; + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return; + + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return; + + DPR_IOCTL(("dgap_tty_flush_buffer on port: %d start\n", ch->ch_portnum)); + + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + + ch->ch_flags &= ~CH_STOP; + head = readw(&(ch->ch_bs->tx_head)); + dgap_cmdw(ch, FLUSHTX, (u16) head, 0); + dgap_cmdw(ch, RESUMETX, 0, 0); + if (ch->ch_tun.un_flags & (UN_LOW|UN_EMPTY)) { + ch->ch_tun.un_flags &= ~(UN_LOW|UN_EMPTY); + wake_up_interruptible(&ch->ch_tun.un_flags_wait); + } + if (ch->ch_pun.un_flags & (UN_LOW|UN_EMPTY)) { + ch->ch_pun.un_flags &= ~(UN_LOW|UN_EMPTY); + wake_up_interruptible(&ch->ch_pun.un_flags_wait); + } + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + if (waitqueue_active(&tty->write_wait)) + wake_up_interruptible(&tty->write_wait); + tty_wakeup(tty); + + DPR_IOCTL(("dgap_tty_flush_buffer finish\n")); +} + + + +/***************************************************************************** + * + * The IOCTL function and all of its helpers + * + *****************************************************************************/ + +/* + * dgap_tty_ioctl() + * + * The usual assortment of ioctl's + */ +static int dgap_tty_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, + unsigned long arg) +{ + struct board_t *bd; + struct channel_t *ch; + struct un_t *un; + int rc; + u16 head = 0; + ulong lock_flags = 0; + ulong lock_flags2 = 0; + void __user *uarg = (void __user *) arg; + + if (!tty || tty->magic != TTY_MAGIC) + return (-ENODEV); + + un = tty->driver_data; + if (!un || un->magic != DGAP_UNIT_MAGIC) + return (-ENODEV); + + ch = un->un_ch; + if (!ch || ch->magic != DGAP_CHANNEL_MAGIC) + return (-ENODEV); + + bd = ch->ch_bd; + if (!bd || bd->magic != DGAP_BOARD_MAGIC) + return (-ENODEV); + + DPR_IOCTL(("dgap_tty_ioctl start on port %d - cmd %s (%x), arg %lx\n", + ch->ch_portnum, dgap_ioctl_name(cmd), cmd, arg)); + + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + + if (un->un_open_count <= 0) { + DPR_BASIC(("dgap_tty_ioctl - unit not open.\n")); + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + return(-EIO); + } + + switch (cmd) { + + /* Here are all the standard ioctl's that we MUST implement */ + + case TCSBRK: + /* + * TCSBRK is SVID version: non-zero arg --> no break + * this behaviour is exploited by tcdrain(). + * + * According to POSIX.1 spec (7.2.2.1.2) breaks should be + * between 0.25 and 0.5 seconds so we'll ask for something + * in the middle: 0.375 seconds. + */ + rc = tty_check_change(tty); + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + if (rc) { + return(rc); + } + + rc = dgap_wait_for_drain(tty); + + if (rc) { + DPR_IOCTL(("dgap_tty_ioctl - bad return: %d ", rc)); + return(-EINTR); + } + + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + + if(((cmd == TCSBRK) && (!arg)) || (cmd == TCSBRKP)) { + dgap_cmdw(ch, SBREAK, (u16) SBREAK_TIME, 0); + } + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + DPR_IOCTL(("dgap_tty_ioctl finish on port %d - cmd %s (%x), arg %lx\n", + ch->ch_portnum, dgap_ioctl_name(cmd), cmd, arg)); + + return(0); + + + case TCSBRKP: + /* support for POSIX tcsendbreak() + + * According to POSIX.1 spec (7.2.2.1.2) breaks should be + * between 0.25 and 0.5 seconds so we'll ask for something + * in the middle: 0.375 seconds. + */ + rc = tty_check_change(tty); + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + if (rc) { + return(rc); + } + + rc = dgap_wait_for_drain(tty); + if (rc) { + DPR_IOCTL(("dgap_tty_ioctl - bad return: %d ", rc)); + return(-EINTR); + } + + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + + dgap_cmdw(ch, SBREAK, (u16) SBREAK_TIME, 0); + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + DPR_IOCTL(("dgap_tty_ioctl finish on port %d - cmd %s (%x), arg %lx\n", + ch->ch_portnum, dgap_ioctl_name(cmd), cmd, arg)); + + return(0); + + case TIOCSBRK: + /* + * FEP5 doesn't support turning on a break unconditionally. + * The FEP5 device will stop sending a break automatically + * after the specified time value that was sent when turning on + * the break. + */ + rc = tty_check_change(tty); + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + if (rc) { + return(rc); + } + + rc = dgap_wait_for_drain(tty); + if (rc) { + DPR_IOCTL(("dgap_tty_ioctl - bad return: %d ", rc)); + return(-EINTR); + } + + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + + dgap_cmdw(ch, SBREAK, (u16) SBREAK_TIME, 0); + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + DPR_IOCTL(("dgap_tty_ioctl finish on port %d - cmd %s (%x), arg %lx\n", + ch->ch_portnum, dgap_ioctl_name(cmd), cmd, arg)); + + return 0; + + case TIOCCBRK: + /* + * FEP5 doesn't support turning off a break unconditionally. + * The FEP5 device will stop sending a break automatically + * after the specified time value that was sent when turning on + * the break. + */ + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + return 0; + + case TIOCGSOFTCAR: + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + rc = put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long __user *) arg); + return(rc); + + case TIOCSSOFTCAR: + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + rc = get_user(arg, (unsigned long __user *) arg); + if (rc) + return(rc); + + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + tty->termios->c_cflag = ((tty->termios->c_cflag & ~CLOCAL) | (arg ? CLOCAL : 0)); + dgap_param(tty); + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + return(0); + + case TIOCMGET: + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + return(dgap_get_modem_info(ch, uarg)); + + case TIOCMBIS: + case TIOCMBIC: + case TIOCMSET: + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + return(dgap_set_modem_info(tty, cmd, uarg)); + + /* + * Here are any additional ioctl's that we want to implement + */ + + case TCFLSH: + /* + * The linux tty driver doesn't have a flush + * input routine for the driver, assuming all backed + * up data is in the line disc. buffers. However, + * we all know that's not the case. Here, we + * act on the ioctl, but then lie and say we didn't + * so the line discipline will process the flush + * also. + */ + rc = tty_check_change(tty); + if (rc) { + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + return(rc); + } + + if ((arg == TCIFLUSH) || (arg == TCIOFLUSH)) { + if (!(un->un_type == DGAP_PRINT)) { + head = readw(&(ch->ch_bs->rx_head)); + writew(head, &(ch->ch_bs->rx_tail)); + writeb(0, &(ch->ch_bs->orun)); + } + } + + if ((arg == TCOFLUSH) || (arg == TCIOFLUSH)) { + ch->ch_flags &= ~CH_STOP; + head = readw(&(ch->ch_bs->tx_head)); + dgap_cmdw(ch, FLUSHTX, (u16) head, 0 ); + dgap_cmdw(ch, RESUMETX, 0, 0); + if (ch->ch_tun.un_flags & (UN_LOW|UN_EMPTY)) { + ch->ch_tun.un_flags &= ~(UN_LOW|UN_EMPTY); + wake_up_interruptible(&ch->ch_tun.un_flags_wait); + } + if (ch->ch_pun.un_flags & (UN_LOW|UN_EMPTY)) { + ch->ch_pun.un_flags &= ~(UN_LOW|UN_EMPTY); + wake_up_interruptible(&ch->ch_pun.un_flags_wait); + } + if (waitqueue_active(&tty->write_wait)) + wake_up_interruptible(&tty->write_wait); + + /* Can't hold any locks when calling tty_wakeup! */ + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + tty_wakeup(tty); + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + } + + /* pretend we didn't recognize this IOCTL */ + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + DPR_IOCTL(("dgap_tty_ioctl (LINE:%d) finish on port %d - cmd %s (%x), arg %lx\n", + __LINE__, ch->ch_portnum, dgap_ioctl_name(cmd), cmd, arg)); + + return(-ENOIOCTLCMD); + +#ifdef TIOCGETP + case TIOCGETP: +#endif + case TCGETS: + case TCGETA: +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31) + if (tty->ldisc->ops->ioctl) { +#else + if (tty->ldisc.ops->ioctl) { +#endif + int retval = (-ENXIO); + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + if (tty->termios) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31) + retval = ((tty->ldisc->ops->ioctl) (tty, file, cmd, arg)); +#else + retval = ((tty->ldisc.ops->ioctl) (tty, file, cmd, arg)); +#endif + } + + DPR_IOCTL(("dgap_tty_ioctl (LINE:%d) finish on port %d - cmd %s (%x), arg %lx\n", + __LINE__, ch->ch_portnum, dgap_ioctl_name(cmd), cmd, arg)); + return(retval); + } + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + DPR_IOCTL(("dgap_tty_ioctl (LINE:%d) finish on port %d - cmd %s (%x), arg %lx\n", + __LINE__, ch->ch_portnum, dgap_ioctl_name(cmd), cmd, arg)); + + return(-ENOIOCTLCMD); + + case TCSETSF: + case TCSETSW: + /* + * The linux tty driver doesn't have a flush + * input routine for the driver, assuming all backed + * up data is in the line disc. buffers. However, + * we all know that's not the case. Here, we + * act on the ioctl, but then lie and say we didn't + * so the line discipline will process the flush + * also. + */ + if (cmd == TCSETSF) { + /* flush rx */ + ch->ch_flags &= ~CH_STOP; + head = readw(&(ch->ch_bs->rx_head)); + writew(head, &(ch->ch_bs->rx_tail)); + } + + /* now wait for all the output to drain */ + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + rc = dgap_wait_for_drain(tty); + if (rc) { + DPR_IOCTL(("dgap_tty_ioctl - bad return: %d ", rc)); + return(-EINTR); + } + + DPR_IOCTL(("dgap_tty_ioctl finish on port %d - cmd %s (%x), arg %lx\n", + ch->ch_portnum, dgap_ioctl_name(cmd), cmd, arg)); + + /* pretend we didn't recognize this */ + return(-ENOIOCTLCMD); + + case TCSETAW: + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + rc = dgap_wait_for_drain(tty); + if (rc) { + DPR_IOCTL(("dgap_tty_ioctl - bad return: %d ", rc)); + return(-EINTR); + } + + /* pretend we didn't recognize this */ + return(-ENOIOCTLCMD); + + case TCXONC: + /* + * The Linux Line Discipline (LD) would do this for us if we + * let it, but we have the special firmware options to do this + * the "right way" regardless of hardware or software flow + * control so we'll do it outselves instead of letting the LD + * do it. + */ + rc = tty_check_change(tty); + if (rc) { + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + return(rc); + } + + DPR_IOCTL(("dgap_ioctl - in TCXONC - %d\n", cmd)); + switch (arg) { + + case TCOON: + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + dgap_tty_start(tty); + return(0); + case TCOOFF: + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + dgap_tty_stop(tty); + return(0); + case TCION: + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + /* Make the ld do it */ + return(-ENOIOCTLCMD); + case TCIOFF: + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + /* Make the ld do it */ + return(-ENOIOCTLCMD); + default: + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + return(-EINVAL); + } + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + return(-ENOIOCTLCMD); + + case DIGI_GETA: + /* get information for ditty */ + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + return(dgap_tty_digigeta(tty, uarg)); + + case DIGI_SETAW: + case DIGI_SETAF: + + /* set information for ditty */ + if (cmd == (DIGI_SETAW)) { + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + rc = dgap_wait_for_drain(tty); + if (rc) { + DPR_IOCTL(("dgap_tty_ioctl - bad return: %d ", rc)); + return(-EINTR); + } + DGAP_LOCK(bd->bd_lock, lock_flags); + DGAP_LOCK(ch->ch_lock, lock_flags2); + } + else { + tty_ldisc_flush(tty); + } + /* fall thru */ + + case DIGI_SETA: + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + return(dgap_tty_digiseta(tty, uarg)); + + case DIGI_GEDELAY: + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + return(dgap_tty_digigetedelay(tty, uarg)); + + case DIGI_SEDELAY: + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + return(dgap_tty_digisetedelay(tty, uarg)); + + case DIGI_GETCUSTOMBAUD: + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + return(dgap_tty_digigetcustombaud(tty, uarg)); + + case DIGI_SETCUSTOMBAUD: + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + return(dgap_tty_digisetcustombaud(tty, uarg)); + + case DIGI_RESET_PORT: + dgap_firmware_reset_port(ch); + dgap_param(tty); + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + return 0; + + default: + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + DPR_IOCTL(("dgap_tty_ioctl - in default\n")); + DPR_IOCTL(("dgap_tty_ioctl end - cmd %s (%x), arg %lx\n", + dgap_ioctl_name(cmd), cmd, arg)); + + return(-ENOIOCTLCMD); + } + + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); + + DPR_IOCTL(("dgap_tty_ioctl end - cmd %s (%x), arg %lx\n", + dgap_ioctl_name(cmd), cmd, arg)); + + return(0); +} diff --git a/drivers/staging/dgap/dgap_tty.h b/drivers/staging/dgap/dgap_tty.h new file mode 100644 index 0000000000000..464a460b6be87 --- /dev/null +++ b/drivers/staging/dgap/dgap_tty.h @@ -0,0 +1,39 @@ +/* + * Copyright 2003 Digi International (www.digi.com) + * Scott H Kilau + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! + */ + +#ifndef __DGAP_TTY_H +#define __DGAP_TTY_H + +#include "dgap_driver.h" + +int dgap_tty_register(struct board_t *brd); + +int dgap_tty_preinit(void); +int dgap_tty_init(struct board_t *); + +void dgap_tty_post_uninit(void); +void dgap_tty_uninit(struct board_t *); + +void dgap_carrier(struct channel_t *ch); +void dgap_input(struct channel_t *ch); + + +#endif diff --git a/drivers/staging/dgap/dgap_types.h b/drivers/staging/dgap/dgap_types.h new file mode 100644 index 0000000000000..eca38c7f359d1 --- /dev/null +++ b/drivers/staging/dgap/dgap_types.h @@ -0,0 +1,36 @@ +/* + * Copyright 2003 Digi International (www.digi.com) + * Scott H Kilau + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! + */ + +#ifndef __DGAP_TYPES_H +#define __DGAP_TYPES_H + +#ifndef TRUE +# define TRUE 1 +#endif + +#ifndef FALSE +# define FALSE 0 +#endif + +/* Required for our shared headers! */ +typedef unsigned char uchar; + +#endif diff --git a/drivers/staging/dgap/digi.h b/drivers/staging/dgap/digi.h new file mode 100644 index 0000000000000..651e2e5e93c77 --- /dev/null +++ b/drivers/staging/dgap/digi.h @@ -0,0 +1,376 @@ +/* + * Copyright 2003 Digi International (www.digi.com) + * Scott H Kilau + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id: digi.h,v 1.1 2009/10/23 14:01:57 markh Exp $ + * + * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! + */ + +#ifndef __DIGI_H +#define __DIGI_H + +/************************************************************************ + *** Definitions for Digi ditty(1) command. + ************************************************************************/ + + +/* + * Copyright (c) 1988-96 Digi International Inc., All Rights Reserved. + */ + +/************************************************************************ + * This module provides application access to special Digi + * serial line enhancements which are not standard UNIX(tm) features. + ************************************************************************/ + +#if !defined(TIOCMODG) + +#define TIOCMODG ('d'<<8) | 250 /* get modem ctrl state */ +#define TIOCMODS ('d'<<8) | 251 /* set modem ctrl state */ + +#ifndef TIOCM_LE +#define TIOCM_LE 0x01 /* line enable */ +#define TIOCM_DTR 0x02 /* data terminal ready */ +#define TIOCM_RTS 0x04 /* request to send */ +#define TIOCM_ST 0x08 /* secondary transmit */ +#define TIOCM_SR 0x10 /* secondary receive */ +#define TIOCM_CTS 0x20 /* clear to send */ +#define TIOCM_CAR 0x40 /* carrier detect */ +#define TIOCM_RNG 0x80 /* ring indicator */ +#define TIOCM_DSR 0x100 /* data set ready */ +#define TIOCM_RI TIOCM_RNG /* ring (alternate) */ +#define TIOCM_CD TIOCM_CAR /* carrier detect (alt) */ +#endif + +#endif + +#if !defined(TIOCMSET) +#define TIOCMSET ('d'<<8) | 252 /* set modem ctrl state */ +#define TIOCMGET ('d'<<8) | 253 /* set modem ctrl state */ +#endif + +#if !defined(TIOCMBIC) +#define TIOCMBIC ('d'<<8) | 254 /* set modem ctrl state */ +#define TIOCMBIS ('d'<<8) | 255 /* set modem ctrl state */ +#endif + + +#if !defined(TIOCSDTR) +#define TIOCSDTR ('e'<<8) | 0 /* set DTR */ +#define TIOCCDTR ('e'<<8) | 1 /* clear DTR */ +#endif + +/************************************************************************ + * Ioctl command arguments for DIGI parameters. + ************************************************************************/ +#define DIGI_GETA ('e'<<8) | 94 /* Read params */ + +#define DIGI_SETA ('e'<<8) | 95 /* Set params */ +#define DIGI_SETAW ('e'<<8) | 96 /* Drain & set params */ +#define DIGI_SETAF ('e'<<8) | 97 /* Drain, flush & set params */ + +#define DIGI_KME ('e'<<8) | 98 /* Read/Write Host */ + /* Adapter Memory */ + +#define DIGI_GETFLOW ('e'<<8) | 99 /* Get startc/stopc flow */ + /* control characters */ +#define DIGI_SETFLOW ('e'<<8) | 100 /* Set startc/stopc flow */ + /* control characters */ +#define DIGI_GETAFLOW ('e'<<8) | 101 /* Get Aux. startc/stopc */ + /* flow control chars */ +#define DIGI_SETAFLOW ('e'<<8) | 102 /* Set Aux. startc/stopc */ + /* flow control chars */ + +#define DIGI_GEDELAY ('d'<<8) | 246 /* Get edelay */ +#define DIGI_SEDELAY ('d'<<8) | 247 /* Set edelay */ + +struct digiflow_t { + unsigned char startc; /* flow cntl start char */ + unsigned char stopc; /* flow cntl stop char */ +}; + + +#ifdef FLOW_2200 +#define F2200_GETA ('e'<<8) | 104 /* Get 2x36 flow cntl flags */ +#define F2200_SETAW ('e'<<8) | 105 /* Set 2x36 flow cntl flags */ +#define F2200_MASK 0x03 /* 2200 flow cntl bit mask */ +#define FCNTL_2200 0x01 /* 2x36 terminal flow cntl */ +#define PCNTL_2200 0x02 /* 2x36 printer flow cntl */ +#define F2200_XON 0xf8 +#define P2200_XON 0xf9 +#define F2200_XOFF 0xfa +#define P2200_XOFF 0xfb + +#define FXOFF_MASK 0x03 /* 2200 flow status mask */ +#define RCVD_FXOFF 0x01 /* 2x36 Terminal XOFF rcvd */ +#define RCVD_PXOFF 0x02 /* 2x36 Printer XOFF rcvd */ +#endif + +/************************************************************************ + * Values for digi_flags + ************************************************************************/ +#define DIGI_IXON 0x0001 /* Handle IXON in the FEP */ +#define DIGI_FAST 0x0002 /* Fast baud rates */ +#define RTSPACE 0x0004 /* RTS input flow control */ +#define CTSPACE 0x0008 /* CTS output flow control */ +#define DSRPACE 0x0010 /* DSR output flow control */ +#define DCDPACE 0x0020 /* DCD output flow control */ +#define DTRPACE 0x0040 /* DTR input flow control */ +#define DIGI_COOK 0x0080 /* Cooked processing done in FEP */ +#define DIGI_FORCEDCD 0x0100 /* Force carrier */ +#define DIGI_ALTPIN 0x0200 /* Alternate RJ-45 pin config */ +#define DIGI_AIXON 0x0400 /* Aux flow control in fep */ +#define DIGI_PRINTER 0x0800 /* Hold port open for flow cntrl*/ +#define DIGI_PP_INPUT 0x1000 /* Change parallel port to input*/ +#define DIGI_DTR_TOGGLE 0x2000 /* Support DTR Toggle */ +#define DIGI_422 0x4000 /* for 422/232 selectable panel */ +#define DIGI_RTS_TOGGLE 0x8000 /* Support RTS Toggle */ + +/************************************************************************ + * These options are not supported on the comxi. + ************************************************************************/ +#define DIGI_COMXI (DIGI_FAST|DIGI_COOK|DSRPACE|DCDPACE|DTRPACE) + +#define DIGI_PLEN 28 /* String length */ +#define DIGI_TSIZ 10 /* Terminal string len */ + +/************************************************************************ + * Structure used with ioctl commands for DIGI parameters. + ************************************************************************/ +struct digi_t { + unsigned short digi_flags; /* Flags (see above) */ + unsigned short digi_maxcps; /* Max printer CPS */ + unsigned short digi_maxchar; /* Max chars in print queue */ + unsigned short digi_bufsize; /* Buffer size */ + unsigned char digi_onlen; /* Length of ON string */ + unsigned char digi_offlen; /* Length of OFF string */ + char digi_onstr[DIGI_PLEN]; /* Printer on string */ + char digi_offstr[DIGI_PLEN]; /* Printer off string */ + char digi_term[DIGI_TSIZ]; /* terminal string */ +}; + +/************************************************************************ + * KME definitions and structures. + ************************************************************************/ +#define RW_IDLE 0 /* Operation complete */ +#define RW_READ 1 /* Read Concentrator Memory */ +#define RW_WRITE 2 /* Write Concentrator Memory */ + +struct rw_t { + unsigned char rw_req; /* Request type */ + unsigned char rw_board; /* Host Adapter board number */ + unsigned char rw_conc; /* Concentrator number */ + unsigned char rw_reserved; /* Reserved for expansion */ + unsigned long rw_addr; /* Address in concentrator */ + unsigned short rw_size; /* Read/write request length */ + unsigned char rw_data[128]; /* Data to read/write */ +}; + +/*********************************************************************** + * Shrink Buffer and Board Information definitions and structures. + + ************************************************************************/ + /* Board type return codes */ +#define PCXI_TYPE 1 /* Board type at the designated port is a PC/Xi */ +#define PCXM_TYPE 2 /* Board type at the designated port is a PC/Xm */ +#define PCXE_TYPE 3 /* Board type at the designated port is a PC/Xe */ +#define MCXI_TYPE 4 /* Board type at the designated port is a MC/Xi */ +#define COMXI_TYPE 5 /* Board type at the designated port is a COM/Xi */ + + /* Non-Zero Result codes. */ +#define RESULT_NOBDFND 1 /* A Digi product at that port is not config installed */ +#define RESULT_NODESCT 2 /* A memory descriptor was not obtainable */ +#define RESULT_NOOSSIG 3 /* FEP/OS signature was not detected on the board */ +#define RESULT_TOOSML 4 /* Too small an area to shrink. */ +#define RESULT_NOCHAN 5 /* Channel structure for the board was not found */ + +struct shrink_buf_struct { + unsigned long shrink_buf_vaddr; /* Virtual address of board */ + unsigned long shrink_buf_phys; /* Physical address of board */ + unsigned long shrink_buf_bseg; /* Amount of board memory */ + unsigned long shrink_buf_hseg; /* '186 Begining of Dual-Port */ + + unsigned long shrink_buf_lseg; /* '186 Begining of freed memory */ + unsigned long shrink_buf_mseg; /* Linear address from start of + dual-port were freed memory + begins, host viewpoint. */ + + unsigned long shrink_buf_bdparam; /* Parameter for xxmemon and + xxmemoff */ + + unsigned long shrink_buf_reserva; /* Reserved */ + unsigned long shrink_buf_reservb; /* Reserved */ + unsigned long shrink_buf_reservc; /* Reserved */ + unsigned long shrink_buf_reservd; /* Reserved */ + + unsigned char shrink_buf_result; /* Reason for call failing + Zero is Good return */ + unsigned char shrink_buf_init; /* Non-Zero if it caused an + xxinit call. */ + + unsigned char shrink_buf_anports; /* Number of async ports */ + unsigned char shrink_buf_snports; /* Number of sync ports */ + unsigned char shrink_buf_type; /* Board type 1 = PC/Xi, + 2 = PC/Xm, + 3 = PC/Xe + 4 = MC/Xi + 5 = COMX/i */ + unsigned char shrink_buf_card; /* Card number */ + +}; + +/************************************************************************ + * Structure to get driver status information + ************************************************************************/ +struct digi_dinfo { + unsigned long dinfo_nboards; /* # boards configured */ + char dinfo_reserved[12]; /* for future expansion */ + char dinfo_version[16]; /* driver version */ +}; + +#define DIGI_GETDD ('d'<<8) | 248 /* get driver info */ + +/************************************************************************ + * Structure used with ioctl commands for per-board information + * + * physsize and memsize differ when board has "windowed" memory + ************************************************************************/ +struct digi_info { + unsigned long info_bdnum; /* Board number (0 based) */ + unsigned long info_ioport; /* io port address */ + unsigned long info_physaddr; /* memory address */ + unsigned long info_physsize; /* Size of host mem window */ + unsigned long info_memsize; /* Amount of dual-port mem */ + /* on board */ + unsigned short info_bdtype; /* Board type */ + unsigned short info_nports; /* number of ports */ + char info_bdstate; /* board state */ + char info_reserved[7]; /* for future expansion */ +}; + +#define DIGI_GETBD ('d'<<8) | 249 /* get board info */ + +struct digi_stat { + unsigned int info_chan; /* Channel number (0 based) */ + unsigned int info_brd; /* Board number (0 based) */ + unsigned long info_cflag; /* cflag for channel */ + unsigned long info_iflag; /* iflag for channel */ + unsigned long info_oflag; /* oflag for channel */ + unsigned long info_mstat; /* mstat for channel */ + unsigned long info_tx_data; /* tx_data for channel */ + unsigned long info_rx_data; /* rx_data for channel */ + unsigned long info_hflow; /* hflow for channel */ + unsigned long info_reserved[8]; /* for future expansion */ +}; + +#define DIGI_GETSTAT ('d'<<8) | 244 /* get board info */ +/************************************************************************ + * + * Structure used with ioctl commands for per-channel information + * + ************************************************************************/ +struct digi_ch { + unsigned long info_bdnum; /* Board number (0 based) */ + unsigned long info_channel; /* Channel index number */ + unsigned long info_ch_cflag; /* Channel cflag */ + unsigned long info_ch_iflag; /* Channel iflag */ + unsigned long info_ch_oflag; /* Channel oflag */ + unsigned long info_chsize; /* Channel structure size */ + unsigned long info_sleep_stat; /* sleep status */ + dev_t info_dev; /* device number */ + unsigned char info_initstate; /* Channel init state */ + unsigned char info_running; /* Channel running state */ + long reserved[8]; /* reserved for future use */ +}; + +/* +* This structure is used with the DIGI_FEPCMD ioctl to +* tell the driver which port to send the command for. +*/ +struct digi_cmd { + int cmd; + int word; + int ncmds; + int chan; /* channel index (zero based) */ + int bdid; /* board index (zero based) */ +}; + +/* +* info_sleep_stat defines +*/ +#define INFO_RUNWAIT 0x0001 +#define INFO_WOPEN 0x0002 +#define INFO_TTIOW 0x0004 +#define INFO_CH_RWAIT 0x0008 +#define INFO_CH_WEMPTY 0x0010 +#define INFO_CH_WLOW 0x0020 +#define INFO_XXBUF_BUSY 0x0040 + +#define DIGI_GETCH ('d'<<8) | 245 /* get board info */ + +/* Board type definitions */ + +#define SUBTYPE 0007 +#define T_PCXI 0000 +#define T_PCXM 0001 +#define T_PCXE 0002 +#define T_PCXR 0003 +#define T_SP 0004 +#define T_SP_PLUS 0005 +# define T_HERC 0000 +# define T_HOU 0001 +# define T_LON 0002 +# define T_CHA 0003 +#define FAMILY 0070 +#define T_COMXI 0000 +#define T_PCXX 0010 +#define T_CX 0020 +#define T_EPC 0030 +#define T_PCLITE 0040 +#define T_SPXX 0050 +#define T_AVXX 0060 +#define T_DXB 0070 +#define T_A2K_4_8 0070 +#define BUSTYPE 0700 +#define T_ISABUS 0000 +#define T_MCBUS 0100 +#define T_EISABUS 0200 +#define T_PCIBUS 0400 + +/* Board State Definitions */ + +#define BD_RUNNING 0x0 +#define BD_REASON 0x7f +#define BD_NOTFOUND 0x1 +#define BD_NOIOPORT 0x2 +#define BD_NOMEM 0x3 +#define BD_NOBIOS 0x4 +#define BD_NOFEP 0x5 +#define BD_FAILED 0x6 +#define BD_ALLOCATED 0x7 +#define BD_TRIBOOT 0x8 +#define BD_BADKME 0x80 + +#define DIGI_LOOPBACK ('d'<<8) | 252 /* Enable/disable UART internal loopback */ +#define DIGI_SPOLL ('d'<<8) | 254 /* change poller rate */ + +#define DIGI_SETCUSTOMBAUD _IOW('e', 106, int) /* Set integer baud rate */ +#define DIGI_GETCUSTOMBAUD _IOR('e', 107, int) /* Get integer baud rate */ +#define DIGI_RESET_PORT ('e'<<8) | 93 /* Reset port */ + +#endif /* DIGI_H */ diff --git a/drivers/staging/dgap/downld.c b/drivers/staging/dgap/downld.c new file mode 100644 index 0000000000000..57dfd6bafcf69 --- /dev/null +++ b/drivers/staging/dgap/downld.c @@ -0,0 +1,798 @@ +/* + * Copyright 2003 Digi International (www.digi.com) + * Scott H Kilau + * + * 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, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id: downld.c,v 1.6 2009/01/14 14:10:54 markh Exp $ + */ + +/* +** downld.c +** +** This is the daemon that sends the fep, bios, and concentrator images +** from user space to the driver. +** BUGS: +** If the file changes in the middle of the download, you probably +** will get what you deserve. +** +*/ + +#include +#include +#include +#include +#include +#include + +#include "dgap_types.h" +#include "digi.h" +#include "dgap_fep5.h" + +#include "dgap_downld.h" + +#include +#include +#include +#include + +char *pgm; +void myperror(); + +/* +** This structure is used to keep track of the diferent images available +** to give to the driver. It is arranged so that the things that are +** constants or that have defaults are first inthe strucutre to simplify +** the table of initializers. +*/ +struct image_info { + short type; /* bios, fep, conc */ + short family; /* boards this applies to */ + short subtype; /* subtype */ + int len; /* size of image */ + char *image; /* ioctl struct + image */ + char *name; + char *fname; /* filename of binary (i.e. "asfep.bin") */ + char *pathname; /* pathname to this binary ("/etc/dgap/xrfep.bin"); */ + time_t mtime; /* Last modification time */ +}; + +#define IBIOS 0 +#define IFEP 1 +#define ICONC 2 +#define ICONFIG 3 +#define IBAD 4 + +#define DEFAULT_LOC "/lib/firmware/dgap/" + +struct image_info *image_list; +int nimages, count; + +struct image_info images[] = { +{IBIOS, T_EPC, SUBTYPE, 0, NULL, "EPC/X", "fxbios.bin", DEFAULT_LOC "fxbios.bin", 0 }, +{IFEP, T_EPC, SUBTYPE, 0, NULL, "EPC/X", "fxfep.bin", DEFAULT_LOC "fxfep.bin", 0 }, +{ICONC, T_EPC, SUBTYPE, 0, NULL, "EPC/X", "fxcon.bin", DEFAULT_LOC "fxcon.bin", 0 }, + +{IBIOS, T_CX, SUBTYPE, 0, NULL, "C/X", "cxbios.bin", DEFAULT_LOC "cxbios.bin", 0 }, +{IFEP, T_CX, SUBTYPE, 0, NULL, "C/X", "cxhost.bin", DEFAULT_LOC "cxhost.bin", 0 }, + +{IBIOS, T_CX, T_PCIBUS, 0, NULL, "C/X PCI", "cxpbios.bin", DEFAULT_LOC "cxpbios.bin", 0 }, +{IFEP, T_CX, T_PCIBUS, 0, NULL, "C/X PCI", "cxpfep.bin", DEFAULT_LOC "cxpfep.bin", 0 }, + +{ICONC, T_CX, SUBTYPE, 0, NULL, "C/X", "cxcon.bin", DEFAULT_LOC "cxcon.bin", 0 }, +{ICONC, T_CX, SUBTYPE, 0, NULL, "C/X", "ibmcxcon.bin", DEFAULT_LOC "ibmcxcon.bin", 0 }, +{ICONC, T_CX, SUBTYPE, 0, NULL, "C/X", "ibmencon.bin", DEFAULT_LOC "ibmencon.bin", 0 }, + +{IBIOS, FAMILY, T_PCXR, 0, NULL, "PCXR", "xrbios.bin", DEFAULT_LOC "xrbios.bin", 0 }, +{IFEP, FAMILY, T_PCXR, 0, NULL, "PCXR", "xrfep.bin", DEFAULT_LOC "xrfep.bin", 0 }, + +{IBIOS, T_PCLITE, SUBTYPE, 0, NULL, "X/em", "sxbios.bin", DEFAULT_LOC "sxbios.bin", 0 }, +{IFEP, T_PCLITE, SUBTYPE, 0, NULL, "X/em", "sxfep.bin", DEFAULT_LOC "sxfep.bin", 0 }, + +{IBIOS, T_EPC, T_PCIBUS, 0, NULL, "PCI", "pcibios.bin", DEFAULT_LOC "pcibios.bin", 0 }, +{IFEP, T_EPC, T_PCIBUS, 0, NULL, "PCI", "pcifep.bin", DEFAULT_LOC "pcifep.bin", 0 }, +{ICONFIG, 0, 0, 0, NULL, NULL, "dgap.conf", "/etc/dgap.conf", 0 }, + +/* IBAD/NULL entry indicating end-of-table */ + +{IBAD, 0, 0, 0, NULL, NULL, NULL, NULL, 0 } + +} ; + +int errorprint = 1; +int nodldprint = 1; +int debugflag; +int fd; + +struct downld_t *ip; /* Image pointer in current image */ +struct downld_t *dp; /* conc. download */ + + +/* + * The same for either the FEP or the BIOS. + * Append the downldio header, issue the ioctl, then free + * the buffer. Not horribly CPU efficient, but quite RAM efficient. + */ + +void squirt(int req_type, int bdid, struct image_info *ii) +{ + struct downldio *dliop; + int size_buf; + int sfd; + struct stat sb; + + /* + * If this binary comes from a file, stat it to see how + * large it is. Yes, we intentionally do this each + * time for the binary may change between loads. + */ + + if (ii->pathname) { + sfd = open(ii->pathname, O_RDONLY); + + if (sfd < 0 ) { + myperror(ii->pathname); + goto squirt_end; + } + + if (fstat(sfd, &sb) == -1 ) { + myperror(ii->pathname); + goto squirt_end; + } + + ii->len = sb.st_size ; + } + + size_buf = ii->len + sizeof(struct downldio); + + /* + * This buffer will be freed at the end of this function. It is + * not resilient and should be around only long enough for the d/l + * to happen. + */ + dliop = (struct downldio *) malloc(size_buf); + + if (dliop == NULL) { + fprintf(stderr,"%s: can't get %d bytes of memory; aborting\n", + pgm, size_buf); + exit (1); + } + + /* Now, stick the image in fepimage. This can come from either + * the compiled-in image or from the filesystem. + */ + if (ii->pathname) + read(sfd, dliop->image.fi.fepimage, ii->len); + else + memcpy(dliop ->image.fi.fepimage, ii->image, ii->len); + + dliop->req_type = req_type; + dliop->bdid = bdid; + + dliop->image.fi.len = ii->len; + + if (debugflag) + printf("sending %d bytes of %s %s from %s\n", + ii->len, + (ii->type == IFEP) ? "FEP" : (ii->type == IBIOS) ? "BIOS" : "CONFIG", + ii->name ? ii->name : "", + (ii->pathname) ? ii->pathname : "internal image" ); + + if (ioctl(fd, DIGI_DLREQ_SET, (char *) dliop) == -1) { + if(errorprint) { + fprintf(stderr, + "%s: warning - download ioctl failed\n",pgm); + errorprint = 0; + } + sleep(2); + } + +squirt_end: + + if (ii->pathname) { + close(sfd); + } + free(dliop); +} + + +/* + * See if we need to reload the download image in core + * + */ +void consider_file_rescan(struct image_info *ii) +{ + int sfd ; + int len ; + struct stat sb; + + /* This operation only makes sense when we're working from a file */ + + if (ii->pathname) { + + sfd = open (ii->pathname, O_RDONLY) ; + if (sfd < 0 ) { + myperror(ii->pathname); + exit(1) ; + } + + if( fstat(sfd,&sb) == -1 ) { + myperror(ii->pathname); + exit(1); + } + + /* If the file hasn't changed since we last did this, + * and we have not done a free() on the image, bail + */ + if (ii->image && (sb.st_mtime == ii->mtime)) + goto end_rescan; + + ii->len = len = sb.st_size ; + + /* Record the timestamp of the file */ + ii->mtime = sb.st_mtime; + + /* image should be NULL unless there is an image malloced + * in already. Before we malloc again, make sure we don't + * have a memory leak. + */ + if ( ii->image ) { + free( ii->image ); + /* ii->image = NULL; */ /* not necessary */ + } + + /* This image will be kept only long enough for the + * download to happen. After sending the last block, + * it will be freed + */ + ii->image = malloc(len) ; + + if (ii->image == NULL) { + fprintf(stderr, + "%s: can't get %d bytes of memory; aborting\n", + pgm, len); + exit (1); + } + + if (read(sfd, ii->image, len) < len) { + fprintf(stderr,"%s: read error on %s; aborting\n", + pgm, ii->pathname); + exit (1); + } + +end_rescan: + close(sfd); + + } +} + +/* + * Scan for images to match the driver requests + */ + +struct image_info * find_conc_image() +{ + int x ; + struct image_info *i = NULL ; + + for ( x = 0; x < nimages; x++ ) { + i=&image_list[x]; + + if(i->type != ICONC) + continue; + + consider_file_rescan(i) ; + + ip = (struct downld_t *) image_list[x].image; + if (ip == NULL) continue; + + /* + * When I removed Clusterport, I kept only the code that I + * was SURE wasn't ClusterPort. We may not need the next two + * lines of code. + */ + if ((dp->dl_type != 'P' ) && ( ip->dl_srev == dp->dl_srev )) + return i; + } + return NULL ; +} + + +int main(int argc, char **argv) +{ + struct downldio dlio; + int offset, bsize; + int x; + char *down, *image, *fname; + struct image_info *ii; + + pgm = argv[0]; + dp = &dlio.image.dl; /* conc. download */ + + while((argc > 2) && !strcmp(argv[1],"-d")) { + debugflag++ ; + argc-- ; + argv++ ; + } + + if(argc < 2) { + fprintf(stderr, + "usage: %s download-device [image-file] ...\n", + pgm); + exit(1); + } + + + + /* + * Daemonize, unless debugging is turned on. + */ + if (debugflag == 0) { + switch (fork()) + { + case 0: + break; + + case -1: + return 1; + + default: + return 0; + } + + setsid(); + + /* + * The child no longer needs "stdin", "stdout", or "stderr", + * and should not block processes waiting for them to close. + */ + fclose(stdin); + fclose(stdout); + fclose(stderr); + + } + + while (1) { + if( (fd = open(argv[1], O_RDWR)) == -1 ) { + sleep(1); + } + else + break; + } + + /* + ** create a list of images to search through when trying to match + ** requests from the driver. Put images from the command line in + ** the list before built in images so that the command line images + ** can override the built in ones. + */ + + /* allocate space for the list */ + + nimages = argc - 2; + + /* count the number of default list entries */ + + for (count = 0; images[count].type != IBAD; ++count) ; + + nimages += count; + + /* Really should just remove the variable "image_list".... robertl */ + image_list = images ; + + /* get the images from the command line */ + for(x = 2; x < argc; x++) { + int xx; + + /* + * strip off any leading path information for + * determining file type + */ + if( (fname = strrchr(argv[x],'/')) == NULL) + fname = argv[x]; + else + fname++; /* skip the slash */ + + for (xx = 0; xx < count; xx++) { + if (strcmp(fname, images[xx].fname) == 0 ) { + images[xx].pathname = argv[x]; + + /* image should be NULL until */ + /* space is malloced */ + images[xx].image = NULL ; + } + } + } + + sleep(3); + + /* + ** Endless loop: get a request from the fep, and service that request. + */ + for(;;) { + /* get the request */ + if (debugflag) + printf("b4 get ioctl..."); + + if (ioctl(fd,DIGI_DLREQ_GET, &dlio) == -1 ) { + if (errorprint) { + fprintf(stderr, + "%s: warning - download ioctl failed\n", + pgm); + errorprint = 0; + } + sleep(2); + } else { + if (debugflag) + printf("dlio.req_type is %d bd %d\n", + dlio.req_type,dlio.bdid); + + switch(dlio.req_type) { + case DLREQ_BIOS: + /* + ** find the bios image for this type + */ + for ( x = 0; x < nimages; x++ ) { + if(image_list[x].type != IBIOS) + continue; + + if ((dlio.image.fi.type & FAMILY) == + image_list[x].family) { + + if ( image_list[x].family == T_CX ) { + if ((dlio.image.fi.type & BUSTYPE) + == T_PCIBUS ) { + if ( image_list[x].subtype + == T_PCIBUS ) + break; + } + else { + break; + } + } + else if ( image_list[x].family == T_EPC ) { + /* If subtype of image is T_PCIBUS, it is */ + /* a PCI EPC image, so the board must */ + /* have bus type T_PCIBUS to match */ + if ((dlio.image.fi.type & BUSTYPE) + == T_PCIBUS ) { + if ( image_list[x].subtype + == T_PCIBUS ) + break; + } + else { + /* NON PCI EPC doesn't use PCI image */ + if ( image_list[x].subtype + != T_PCIBUS ) + break; + } + } + else + break; + } + else if ((dlio.image.fi.type & SUBTYPE) == image_list[x].subtype) { + /* PCXR board will break out of the loop here */ + if ( image_list[x].subtype == T_PCXR ) { + break; + } + } + } + + if ( x >= nimages) { + /* + ** no valid images exist + */ + if(nodldprint) { + fprintf(stderr, + "%s: cannot find correct BIOS image\n", + pgm); + nodldprint = 0; + } + dlio.image.fi.type = -1; + if (ioctl(fd, DIGI_DLREQ_SET, &dlio) == -1) { + if (errorprint) { + fprintf(stderr, + "%s: warning - download ioctl failed\n", + pgm); + errorprint = 0; + } + sleep(2); + } + break; + } + squirt(dlio.req_type, dlio.bdid, &image_list[x]); + break ; + + case DLREQ_FEP: + /* + ** find the fep image for this type + */ + for ( x = 0; x < nimages; x++ ) { + if(image_list[x].type != IFEP) + continue; + if( (dlio.image.fi.type & FAMILY) == + image_list[x].family ) { + if ( image_list[x].family == T_CX ) { + /* C/X PCI board */ + if ((dlio.image.fi.type & BUSTYPE) + == T_PCIBUS ) { + if ( image_list[x].subtype + == T_PCIBUS ) + break; + } + else { + /* Regular CX */ + break; + } + } + else if ( image_list[x].family == T_EPC ) { + /* If subtype of image is T_PCIBUS, it is */ + /* a PCI EPC image, so the board must */ + /* have bus type T_PCIBUS to match */ + if ((dlio.image.fi.type & BUSTYPE) + == T_PCIBUS ) { + if ( image_list[x].subtype + == T_PCIBUS ) + break; + } + else { + /* NON PCI EPC doesn't use PCI image */ + if ( image_list[x].subtype + != T_PCIBUS ) + break; + } + } + else + break; + } + else if ((dlio.image.fi.type & SUBTYPE) == image_list[x].subtype) { + /* PCXR board will break out of the loop here */ + if ( image_list[x].subtype == T_PCXR ) { + break; + } + } + } + + if ( x >= nimages) { + /* + ** no valid images exist + */ + if(nodldprint) { + fprintf(stderr, + "%s: cannot find correct FEP image\n", + pgm); + nodldprint = 0; + } + dlio.image.fi.type=-1; + if( ioctl(fd,DIGI_DLREQ_SET,&dlio) == -1 ) { + if(errorprint) { + fprintf(stderr, + "%s: warning - download ioctl failed\n", + pgm); + errorprint=0; + } + sleep(2); + } + break; + } + squirt(dlio.req_type, dlio.bdid, &image_list[x]); + break; + + case DLREQ_DEVCREATE: + { + char string[1024]; +#if 0 + sprintf(string, "%s /proc/dgap/%d/mknod", DEFSHELL, dlio.bdid); +#endif + sprintf(string, "%s /usr/sbin/dgap_updatedevs %d", DEFSHELL, dlio.bdid); + system(string); + + if (debugflag) + printf("Created Devices.\n"); + if (ioctl(fd, DIGI_DLREQ_SET, &dlio) == -1 ) { + if(errorprint) { + fprintf(stderr, "%s: warning - DEVCREATE ioctl failed\n",pgm); + errorprint = 0; + } + sleep(2); + } + if (debugflag) + printf("After ioctl set - Created Device.\n"); + } + + break; + + case DLREQ_CONFIG: + for ( x = 0; x < nimages; x++ ) { + if(image_list[x].type != ICONFIG) + continue; + else + break; + } + + if ( x >= nimages) { + /* + ** no valid images exist + */ + if(nodldprint) { + fprintf(stderr, + "%s: cannot find correct CONFIG image\n", + pgm); + nodldprint = 0; + } + dlio.image.fi.type=-1; + if (ioctl(fd, DIGI_DLREQ_SET, &dlio) == -1 ) { + if(errorprint) { + fprintf(stderr, + "%s: warning - download ioctl failed\n", + pgm); + errorprint=0; + } + sleep(2); + } + break; + } + + squirt(dlio.req_type, dlio.bdid, &image_list[x]); + break; + + case DLREQ_CONC: + /* + ** find the image needed for this download + */ + if ( dp->dl_seq == 0 ) { + /* + ** find image for hardware rev range + */ + for ( x = 0; x < nimages; x++ ) { + ii=&image_list[x]; + + if(image_list[x].type != ICONC) + continue; + + consider_file_rescan(ii) ; + + ip = (struct downld_t *) image_list[x].image; + if (ip == NULL) continue; + + /* + * When I removed Clusterport, I kept only the + * code that I was SURE wasn't ClusterPort. + * We may not need the next four lines of code. + */ + + if ((dp->dl_type != 'P' ) && + (ip->dl_lrev <= dp->dl_lrev ) && + ( dp->dl_lrev <= ip->dl_hrev)) + break; + } + + if ( x >= nimages ) { + /* + ** No valid images exist + */ + if(nodldprint) { + fprintf(stderr, + "%s: cannot find correct download image %d\n", + pgm, dp->dl_lrev); + nodldprint=0; + } + continue; + } + + } else { + /* + ** find image version required + */ + if ((ii = find_conc_image()) == NULL ) { + /* + ** No valid images exist + */ + fprintf(stderr, + "%s: can't find rest of download image??\n", + pgm); + continue; + } + } + + /* + ** download block of image + */ + + offset = 1024 * dp->dl_seq; + + /* + ** test if block requested within image + */ + if ( offset < ii->len ) { + + /* + ** if it is, determine block size, set segment, + ** set size, set pointers, and copy block + */ + if (( bsize = ii->len - offset ) > 1024 ) + bsize = 1024; + + /* + ** copy image version info to download area + */ + dp->dl_srev = ip->dl_srev; + dp->dl_lrev = ip->dl_lrev; + dp->dl_hrev = ip->dl_hrev; + + dp->dl_seg = (64 * dp->dl_seq) + ip->dl_seg; + dp->dl_size = bsize; + + down = (char *)&dp->dl_data[0]; + image = (char *)((char *)ip + offset); + + memcpy(down, image, bsize); + } + else { + /* + ** Image has been downloaded, set segment and + ** size to indicate no more blocks + */ + dp->dl_seg = ip->dl_seg; + dp->dl_size = 0; + + /* Now, we can release the concentrator */ + /* image from memory if we're running */ + /* from filesystem images */ + + if (ii->pathname) + if (ii->image) { + free(ii->image); + ii->image = NULL ; + } + } + + if (debugflag) + printf( + "sending conc dl section %d to %s from %s\n", + dp->dl_seq, ii->name, + ii->pathname ? ii->pathname : "Internal Image"); + + if (ioctl(fd, DIGI_DLREQ_SET, &dlio) == -1 ) { + if (errorprint) { + fprintf(stderr, + "%s: warning - download ioctl failed\n", + pgm); + errorprint=0; + } + sleep(2); + } + break; + } /* switch */ + } + if (debugflag > 1) { + printf("pausing: "); fflush(stdout); + fflush(stdin); + while(getchar() != '\n'); + printf("continuing\n"); + } + } +} + +/* +** myperror() +** +** Same as normal perror(), but places the program name at the begining +** of the message. +*/ +void myperror(char *s) +{ + fprintf(stderr,"%s: %s: %s.\n",pgm, s, strerror(errno)); +} -- GitLab From fc5a89904c8a6ef9bc47cecd1e068b8ba285dc22 Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Wed, 21 Aug 2013 21:48:32 -0400 Subject: [PATCH 745/942] staging: dgap: fixes incompatible type error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch fixes the error: incompatible types when assigning to type ‘struct ktermios *’ from type ‘struct ktermios’ Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap_fep5.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/dgap/dgap_fep5.c b/drivers/staging/dgap/dgap_fep5.c index ed3cb151d6dab..ce87752b91724 100644 --- a/drivers/staging/dgap/dgap_fep5.c +++ b/drivers/staging/dgap/dgap_fep5.c @@ -1260,7 +1260,7 @@ int dgap_param(struct tty_struct *tty) DPR_PARAM(("param start: tdev: %x cflags: %x oflags: %x iflags: %x\n", ch->ch_tun.un_dev, ch->ch_c_cflag, ch->ch_c_oflag, ch->ch_c_iflag)); - ts = tty->termios; + ts = &tty->termios; /* * If baud rate is zero, flush queues, and set mval to drop DTR. -- GitLab From 1c2aa15ae4e33d6bfb4b068967bb451618db6bec Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Wed, 21 Aug 2013 21:48:33 -0400 Subject: [PATCH 746/942] staging: dgap: removes references to proc code This patch removes references to proc code in this driver. It still has proc.c, proc.h and a board state called NEEDS_PROC_CREATION. All three of these will be removed in another patch. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/Makefile | 2 +- drivers/staging/dgap/dgap_driver.c | 7 ------- drivers/staging/dgap/dgap_fep5.c | 2 +- drivers/staging/dgap/dgap_mgmt.c | 2 +- 4 files changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/staging/dgap/Makefile b/drivers/staging/dgap/Makefile index 0aa5cde2c8234..15b7704cd5b70 100644 --- a/drivers/staging/dgap/Makefile +++ b/drivers/staging/dgap/Makefile @@ -4,6 +4,6 @@ obj-$(CONFIG_DGAP) += dgap.o dgap-objs := dgap_driver.o dgap_fep5.o dgap_mgmt.o \ - dgap_parse.o dgap_proc.o dgap_trace.o \ + dgap_parse.o dgap_trace.o \ dgap_tty.o dgap_sysfs.o diff --git a/drivers/staging/dgap/dgap_driver.c b/drivers/staging/dgap/dgap_driver.c index b4f54ef8493de..987ce21f19ef7 100644 --- a/drivers/staging/dgap/dgap_driver.c +++ b/drivers/staging/dgap/dgap_driver.c @@ -331,11 +331,6 @@ static int dgap_start(void) dgap_Major_Control_Registered = TRUE; } - /* - * Register our basic stuff in /proc/dgap - */ - dgap_proc_register_basic_prescan(); - /* * Init any global tty stuff. */ @@ -423,8 +418,6 @@ void dgap_cleanup_module(void) /* Turn off poller right away. */ del_timer_sync( &dgap_poll_timer); - dgap_proc_unregister_all(); - dgap_remove_driver_sysfiles(&dgap_driver); diff --git a/drivers/staging/dgap/dgap_fep5.c b/drivers/staging/dgap/dgap_fep5.c index ce87752b91724..604eae1f785d7 100644 --- a/drivers/staging/dgap/dgap_fep5.c +++ b/drivers/staging/dgap/dgap_fep5.c @@ -135,7 +135,7 @@ int dgap_after_config_loaded(void) dgap_Board[i]->flipbuf = dgap_driver_kzmalloc(MYFLIPLEN, GFP_ATOMIC); dgap_Board[i]->flipflagbuf = dgap_driver_kzmalloc(MYFLIPLEN, GFP_ATOMIC); - dgap_proc_register_basic_postscan(i); + //dgap_proc_register_basic_postscan(i); } return (rc); diff --git a/drivers/staging/dgap/dgap_mgmt.c b/drivers/staging/dgap/dgap_mgmt.c index 00624816d2526..1147f1d425fb6 100644 --- a/drivers/staging/dgap/dgap_mgmt.c +++ b/drivers/staging/dgap/dgap_mgmt.c @@ -296,7 +296,7 @@ int dgap_mgmt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un case NEED_PROC_CREATION: DGAP_UNLOCK(brd->bd_lock, lock_flags); - dgap_proc_register_channel_postscan(brd->boardnum); + //dgap_proc_register_channel_postscan(brd->boardnum); ch = brd->channels[0]; for (j = 0; j < brd->nasync; j++, ch = brd->channels[j]) { -- GitLab From bb9ebe70739c62322c26f22fac3c60998cfe56ec Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Wed, 21 Aug 2013 21:48:34 -0400 Subject: [PATCH 747/942] staging: dgap: fep5.c: fixes errors with tty function calls This patch fixes errors with the tty function calls tty_buffer_request_room, tty_insert_flip_char and tty_flip_buffer_push. They now take struct tty_port as a parameter instead of tty_struct. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap_fep5.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/dgap/dgap_fep5.c b/drivers/staging/dgap/dgap_fep5.c index 604eae1f785d7..2bbbcd3c398ef 100644 --- a/drivers/staging/dgap/dgap_fep5.c +++ b/drivers/staging/dgap/dgap_fep5.c @@ -1805,9 +1805,9 @@ static int dgap_event(struct board_t *bd) if (ch->ch_tun.un_tty) { /* A break has been indicated */ ch->ch_err_break++; - tty_buffer_request_room(ch->ch_tun.un_tty, 1); - tty_insert_flip_char(ch->ch_tun.un_tty, 0, TTY_BREAK); - tty_flip_buffer_push(ch->ch_tun.un_tty); + tty_buffer_request_room(ch->ch_tun.un_tty->port, 1); + tty_insert_flip_char(ch->ch_tun.un_tty->port, 0, TTY_BREAK); + tty_flip_buffer_push(ch->ch_tun.un_tty->port); } } -- GitLab From 17c82bce16e33b177c04ee38c85c09087a09bc80 Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Wed, 21 Aug 2013 21:48:35 -0400 Subject: [PATCH 748/942] staging: dgap: tty.c: fixes errors with tty function calls This patch fixes errors with the tty function calls tty_buffer_request_room, tty_insert_flip_string_flags, tty_insert_flip_string and tty_flip_buffer_push. They now take struct tty_port as a parameter instead of tty_struct. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap_tty.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/dgap/dgap_tty.c b/drivers/staging/dgap/dgap_tty.c index e7aea5ef51c56..4c3cc9460c755 100644 --- a/drivers/staging/dgap/dgap_tty.c +++ b/drivers/staging/dgap/dgap_tty.c @@ -881,20 +881,20 @@ void dgap_input(struct channel_t *ch) if (I_PARMRK(tp) || I_BRKINT(tp) || I_INPCK(tp)) { dgap_parity_scan(ch, ch->ch_bd->flipbuf, ch->ch_bd->flipflagbuf, &len); - len = tty_buffer_request_room(tp, len); - tty_insert_flip_string_flags(tp, ch->ch_bd->flipbuf, + len = tty_buffer_request_room(tp->port, len); + tty_insert_flip_string_flags(tp->port, ch->ch_bd->flipbuf, ch->ch_bd->flipflagbuf, len); } else { - len = tty_buffer_request_room(tp, len); - tty_insert_flip_string(tp, ch->ch_bd->flipbuf, len); + len = tty_buffer_request_room(tp->port, len); + tty_insert_flip_string(tp->port, ch->ch_bd->flipbuf, len); } DGAP_UNLOCK(ch->ch_lock, lock_flags2); DGAP_UNLOCK(bd->bd_lock, lock_flags); /* Tell the tty layer its okay to "eat" the data now */ - tty_flip_buffer_push(tp); + tty_flip_buffer_push(tp->port); } if (ld) -- GitLab From c3dc9dc57d7452fe263459774400413b5d96a79c Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Wed, 21 Aug 2013 21:48:36 -0400 Subject: [PATCH 749/942] staging: dgap: tty.c: fixes termios error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch fixes this error: invalid type argument of ‘->’ (have ‘struct ktermios’). Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap_tty.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/staging/dgap/dgap_tty.c b/drivers/staging/dgap/dgap_tty.c index 4c3cc9460c755..c077e0d464939 100644 --- a/drivers/staging/dgap/dgap_tty.c +++ b/drivers/staging/dgap/dgap_tty.c @@ -737,7 +737,7 @@ void dgap_input(struct channel_t *ch) * input data and return immediately. */ if ((bd->state != BOARD_READY) || !tp || (tp->magic != TTY_MAGIC) || - !(ch->ch_tun.un_flags & UN_ISOPEN) || !(tp->termios->c_cflag & CREAD) || + !(ch->ch_tun.un_flags & UN_ISOPEN) || !(tp->termios.c_cflag & CREAD) || (ch->ch_tun.un_flags & UN_CLOSING)) { DPR_READ(("input. dropping %d bytes on port %d...\n", data_len, ch->ch_portnum)); @@ -1173,12 +1173,12 @@ static int dgap_tty_open(struct tty_struct *tty, struct file *file) ch->pscan_state = 0; ch->pscan_savechar = 0; - ch->ch_c_cflag = tty->termios->c_cflag; - ch->ch_c_iflag = tty->termios->c_iflag; - ch->ch_c_oflag = tty->termios->c_oflag; - ch->ch_c_lflag = tty->termios->c_lflag; - ch->ch_startc = tty->termios->c_cc[VSTART]; - ch->ch_stopc = tty->termios->c_cc[VSTOP]; + ch->ch_c_cflag = tty->termios.c_cflag; + ch->ch_c_iflag = tty->termios.c_iflag; + ch->ch_c_oflag = tty->termios.c_oflag; + ch->ch_c_lflag = tty->termios.c_lflag; + ch->ch_startc = tty->termios.c_cc[VSTART]; + ch->ch_stopc = tty->termios.c_cc[VSTOP]; /* TODO: flush our TTY struct here? */ } @@ -2893,12 +2893,12 @@ static void dgap_tty_set_termios(struct tty_struct *tty, struct ktermios *old_te DGAP_LOCK(bd->bd_lock, lock_flags); DGAP_LOCK(ch->ch_lock, lock_flags2); - ch->ch_c_cflag = tty->termios->c_cflag; - ch->ch_c_iflag = tty->termios->c_iflag; - ch->ch_c_oflag = tty->termios->c_oflag; - ch->ch_c_lflag = tty->termios->c_lflag; - ch->ch_startc = tty->termios->c_cc[VSTART]; - ch->ch_stopc = tty->termios->c_cc[VSTOP]; + ch->ch_c_cflag = tty->termios.c_cflag; + ch->ch_c_iflag = tty->termios.c_iflag; + ch->ch_c_oflag = tty->termios.c_oflag; + ch->ch_c_lflag = tty->termios.c_lflag; + ch->ch_startc = tty->termios.c_cc[VSTART]; + ch->ch_stopc = tty->termios.c_cc[VSTOP]; dgap_carrier(ch); dgap_param(tty); @@ -3361,7 +3361,7 @@ static int dgap_tty_ioctl(struct tty_struct *tty, struct file *file, unsigned in DGAP_LOCK(bd->bd_lock, lock_flags); DGAP_LOCK(ch->ch_lock, lock_flags2); - tty->termios->c_cflag = ((tty->termios->c_cflag & ~CLOCAL) | (arg ? CLOCAL : 0)); + tty->termios.c_cflag = ((tty->termios.c_cflag & ~CLOCAL) | (arg ? CLOCAL : 0)); dgap_param(tty); DGAP_UNLOCK(ch->ch_lock, lock_flags2); DGAP_UNLOCK(bd->bd_lock, lock_flags); -- GitLab From fd2ada8db84435ddfd7374d3a0935bb927c11954 Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Wed, 21 Aug 2013 21:48:37 -0400 Subject: [PATCH 750/942] staging: dgap: tty.c: removes read_cnt, real_raw and rawreadok This patch removes the use of read_cnt, real_raw and rawreadok. These variables don't exist in the new API. Reading the data raw is no longer supported by the tty layer. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap_tty.c | 47 ++++++++++----------------------- 1 file changed, 14 insertions(+), 33 deletions(-) diff --git a/drivers/staging/dgap/dgap_tty.c b/drivers/staging/dgap/dgap_tty.c index c077e0d464939..3fc6c5aeafe14 100644 --- a/drivers/staging/dgap/dgap_tty.c +++ b/drivers/staging/dgap/dgap_tty.c @@ -774,14 +774,11 @@ void dgap_input(struct channel_t *ch) DPR_READ(("dgap_input start 2\n")); /* Decide how much data we can send into the tty layer */ - if (dgap_rawreadok && tp->real_raw) - flip_len = MYFLIPLEN; - else - flip_len = TTY_FLIPBUF_SIZE; + flip_len = TTY_FLIPBUF_SIZE; /* Chop down the length, if needed */ len = min(data_len, flip_len); - len = min(len, (N_TTY_BUF_SIZE - 1) - tp->read_cnt); + len = min(len, (N_TTY_BUF_SIZE - 1)); ld = tty_ldisc_ref(tp); @@ -863,39 +860,23 @@ void dgap_input(struct channel_t *ch) * On the other hand, if we are not raw, we need to go through * the tty layer, which has its API more well defined. */ - if (dgap_rawreadok && tp->real_raw) { + if (I_PARMRK(tp) || I_BRKINT(tp) || I_INPCK(tp)) { + dgap_parity_scan(ch, ch->ch_bd->flipbuf, ch->ch_bd->flipflagbuf, &len); - /* !!! WE *MUST* LET GO OF ALL LOCKS BEFORE CALLING RECEIVE BUF !!! */ - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - - DPR_READ(("dgap_input. %d real_raw len:%d calling receive_buf for buffer for board %d\n", - __LINE__, len, ch->ch_bd->boardnum)); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31) - tp->ldisc->ops->receive_buf(tp, ch->ch_bd->flipbuf, NULL, len); -#else - tp->ldisc.ops->receive_buf(tp, ch->ch_bd->flipbuf, NULL, len); -#endif + len = tty_buffer_request_room(tp->port, len); + tty_insert_flip_string_flags(tp->port, ch->ch_bd->flipbuf, + ch->ch_bd->flipflagbuf, len); } else { - if (I_PARMRK(tp) || I_BRKINT(tp) || I_INPCK(tp)) { - dgap_parity_scan(ch, ch->ch_bd->flipbuf, ch->ch_bd->flipflagbuf, &len); - - len = tty_buffer_request_room(tp->port, len); - tty_insert_flip_string_flags(tp->port, ch->ch_bd->flipbuf, - ch->ch_bd->flipflagbuf, len); - } - else { - len = tty_buffer_request_room(tp->port, len); - tty_insert_flip_string(tp->port, ch->ch_bd->flipbuf, len); - } + len = tty_buffer_request_room(tp->port, len); + tty_insert_flip_string(tp->port, ch->ch_bd->flipbuf, len); + } - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); + DGAP_UNLOCK(ch->ch_lock, lock_flags2); + DGAP_UNLOCK(bd->bd_lock, lock_flags); - /* Tell the tty layer its okay to "eat" the data now */ - tty_flip_buffer_push(tp->port); - } + /* Tell the tty layer its okay to "eat" the data now */ + tty_flip_buffer_push(tp->port); if (ld) tty_ldisc_deref(ld); -- GitLab From acccb45473935fbe33742ee2c2f7d55dbaec4dda Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Wed, 21 Aug 2013 21:48:38 -0400 Subject: [PATCH 751/942] staging: dgap: tty.c: fixes ioctl param list The declaration for the ioctl function has changed. The previous version of this declaration took struct file *file as a parameter and the new one does not. This patch removes that parameter. It also removes cases for the commands TIOCGETP TCGETS and TCGETA. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap_tty.c | 39 ++------------------------------- 1 file changed, 2 insertions(+), 37 deletions(-) diff --git a/drivers/staging/dgap/dgap_tty.c b/drivers/staging/dgap/dgap_tty.c index 3fc6c5aeafe14..0ca141691d2cd 100644 --- a/drivers/staging/dgap/dgap_tty.c +++ b/drivers/staging/dgap/dgap_tty.c @@ -112,7 +112,7 @@ static struct ktermios DgapDefaultTermios = static int dgap_tty_open(struct tty_struct *tty, struct file *file); static void dgap_tty_close(struct tty_struct *tty, struct file *file); static int dgap_block_til_ready(struct tty_struct *tty, struct file *file, struct channel_t *ch); -static int dgap_tty_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg); +static int dgap_tty_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg); static int dgap_tty_digigeta(struct tty_struct *tty, struct digi_t __user *retinfo); static int dgap_tty_digiseta(struct tty_struct *tty, struct digi_t __user *new_info); static int dgap_tty_digigetedelay(struct tty_struct *tty, int __user *retinfo); @@ -3164,7 +3164,7 @@ static void dgap_tty_flush_buffer(struct tty_struct *tty) * * The usual assortment of ioctl's */ -static int dgap_tty_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, +static int dgap_tty_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg) { struct board_t *bd; @@ -3423,41 +3423,6 @@ static int dgap_tty_ioctl(struct tty_struct *tty, struct file *file, unsigned in return(-ENOIOCTLCMD); -#ifdef TIOCGETP - case TIOCGETP: -#endif - case TCGETS: - case TCGETA: -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31) - if (tty->ldisc->ops->ioctl) { -#else - if (tty->ldisc.ops->ioctl) { -#endif - int retval = (-ENXIO); - - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - - if (tty->termios) { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31) - retval = ((tty->ldisc->ops->ioctl) (tty, file, cmd, arg)); -#else - retval = ((tty->ldisc.ops->ioctl) (tty, file, cmd, arg)); -#endif - } - - DPR_IOCTL(("dgap_tty_ioctl (LINE:%d) finish on port %d - cmd %s (%x), arg %lx\n", - __LINE__, ch->ch_portnum, dgap_ioctl_name(cmd), cmd, arg)); - return(retval); - } - - DGAP_UNLOCK(ch->ch_lock, lock_flags2); - DGAP_UNLOCK(bd->bd_lock, lock_flags); - DPR_IOCTL(("dgap_tty_ioctl (LINE:%d) finish on port %d - cmd %s (%x), arg %lx\n", - __LINE__, ch->ch_portnum, dgap_ioctl_name(cmd), cmd, arg)); - - return(-ENOIOCTLCMD); - case TCSETSF: case TCSETSW: /* -- GitLab From 038bc7ac702f4a5bee4bbc8c16c2b5f5aa91cc93 Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Wed, 21 Aug 2013 21:48:39 -0400 Subject: [PATCH 752/942] staging: dgap: tty.c: fixes incompatible type error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch fixes the error: incompatible types when assigning to type ‘struct ktermios *’ from type ‘struct ktermios’ Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap_tty.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/dgap/dgap_tty.c b/drivers/staging/dgap/dgap_tty.c index 0ca141691d2cd..b906db30b6176 100644 --- a/drivers/staging/dgap/dgap_tty.c +++ b/drivers/staging/dgap/dgap_tty.c @@ -1421,7 +1421,7 @@ static void dgap_tty_close(struct tty_struct *tty, struct file *file) if (!bd || bd->magic != DGAP_BOARD_MAGIC) return; - ts = tty->termios; + ts = &tty->termios; DPR_CLOSE(("Close called\n")); -- GitLab From 6c2f9ab53ca189aa1829b267dfca1dc3d95252c1 Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Wed, 21 Aug 2013 21:48:40 -0400 Subject: [PATCH 753/942] staging: dgap: mgmt.c: removes unused variable This patch removes the unused variable page in mgmt.c. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap_mgmt.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/dgap/dgap_mgmt.c b/drivers/staging/dgap/dgap_mgmt.c index 1147f1d425fb6..dce33d4ae6042 100644 --- a/drivers/staging/dgap/dgap_mgmt.c +++ b/drivers/staging/dgap/dgap_mgmt.c @@ -607,7 +607,6 @@ int dgap_mgmt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, un /* If the concentrator number is 0... */ if (kme.rw_conc == 0 && kme.rw_addr < 0x100000) { - int page = 0; int addr = kme.rw_addr; int size = kme.rw_size; caddr_t data = (caddr_t) kme.rw_data; -- GitLab From acb8d4056a5351748015464b1c551fcd310014ba Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Wed, 21 Aug 2013 21:48:41 -0400 Subject: [PATCH 754/942] staging: dgap: ifdef HAVE_UNLOCKED_IOCTL conditionals This patch removes the HAVE_UNLOCKED_IOCTL conditional statements from driver.c, mgmt.c and mgmt.h. This was used to support older kernels. It isn't needed now. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap_driver.c | 4 ---- drivers/staging/dgap/dgap_mgmt.c | 6 ------ drivers/staging/dgap/dgap_mgmt.h | 5 ----- 3 files changed, 15 deletions(-) diff --git a/drivers/staging/dgap/dgap_driver.c b/drivers/staging/dgap/dgap_driver.c index 987ce21f19ef7..0e09ce3c6f368 100644 --- a/drivers/staging/dgap/dgap_driver.c +++ b/drivers/staging/dgap/dgap_driver.c @@ -102,11 +102,7 @@ module_exit(dgap_cleanup_module); static struct file_operations DgapBoardFops = { .owner = THIS_MODULE, -#ifdef HAVE_UNLOCKED_IOCTL .unlocked_ioctl = dgap_mgmt_ioctl, -#else - .ioctl: = dgap_mgmt_ioctl, -#endif .open = dgap_mgmt_open, .release = dgap_mgmt_close }; diff --git a/drivers/staging/dgap/dgap_mgmt.c b/drivers/staging/dgap/dgap_mgmt.c index dce33d4ae6042..1ed737542507e 100644 --- a/drivers/staging/dgap/dgap_mgmt.c +++ b/drivers/staging/dgap/dgap_mgmt.c @@ -152,14 +152,8 @@ int dgap_mgmt_close(struct inode *inode, struct file *file) * * ioctl the mgmt/dpa device */ -#ifdef HAVE_UNLOCKED_IOCTL long dgap_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { - struct inode *inode = file->f_dentry->d_inode; -#else -int dgap_mgmt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) -{ -#endif unsigned long lock_flags; int error = 0; int i = 0; diff --git a/drivers/staging/dgap/dgap_mgmt.h b/drivers/staging/dgap/dgap_mgmt.h index 69e760314db75..4b153f2dd7f22 100644 --- a/drivers/staging/dgap/dgap_mgmt.h +++ b/drivers/staging/dgap/dgap_mgmt.h @@ -27,12 +27,7 @@ int dgap_mgmt_open(struct inode *inode, struct file *file); int dgap_mgmt_close(struct inode *inode, struct file *file); - -#ifdef HAVE_UNLOCKED_IOCTL long dgap_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg); -#else -int dgap_mgmt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg); -#endif #endif -- GitLab From 0a7bfbffbd9a94a31a4bac7e9ec29d18adc8e198 Mon Sep 17 00:00:00 2001 From: Rupesh Gujare Date: Thu, 22 Aug 2013 17:38:48 +0100 Subject: [PATCH 755/942] staging: ozwpan: Fix crash for race condition. Do not allocate a port to new device or process URB when its status is yet to be read. This avoids race condition when USB core read hub status a bit late, while new device tries to acquire port. Signed-off-by: Rupesh Gujare Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozhcd.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c index 2b67107db6b24..4682d782abe75 100644 --- a/drivers/staging/ozwpan/ozhcd.c +++ b/drivers/staging/ozwpan/ozhcd.c @@ -685,7 +685,7 @@ struct oz_port *oz_hcd_pd_arrived(void *hpd) struct oz_port *port = &ozhcd->ports[i]; spin_lock(&port->port_lock); - if (!(port->flags & OZ_PORT_F_PRESENT)) { + if (!(port->flags & (OZ_PORT_F_PRESENT | OZ_PORT_F_CHANGED))) { oz_acquire_port(port, hpd); spin_unlock(&port->port_lock); break; @@ -1818,7 +1818,8 @@ static int oz_hcd_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, port = &ozhcd->ports[port_ix]; if (port == NULL) return -EPIPE; - if ((port->flags & OZ_PORT_F_PRESENT) == 0) { + if (!(port->flags & OZ_PORT_F_PRESENT) || + (port->flags & OZ_PORT_F_CHANGED)) { oz_dbg(ON, "Refusing URB port_ix = %d devnum = %d\n", port_ix, urb->dev->devnum); return -EPIPE; -- GitLab From d236dc11a17e8fa29c1b4e0ecc8cf5b9bcc7fcf5 Mon Sep 17 00:00:00 2001 From: Rupesh Gujare Date: Thu, 22 Aug 2013 17:38:49 +0100 Subject: [PATCH 756/942] staging: ozwpan: Check error condition before creating endpoint. Check if interface number is correct before creating an end point. Signed-off-by: Rupesh Gujare Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozhcd.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c index 4682d782abe75..d5a3900d41817 100644 --- a/drivers/staging/ozwpan/ozhcd.c +++ b/drivers/staging/ozwpan/ozhcd.c @@ -1247,6 +1247,8 @@ static int oz_build_endpoints_for_interface(struct usb_hcd *hcd, int request_heartbeat = 0; oz_dbg(ON, "interface[%d] = %p\n", if_ix, intf); + if (if_ix >= port->num_iface || port->iface == NULL) + return -ENOMEM; for (i = 0; i < intf->desc.bNumEndpoints; i++) { struct usb_host_endpoint *hep = &intf->endpoint[i]; u8 ep_addr = hep->desc.bEndpointAddress; -- GitLab From b75d7d45f25c8361555f368665af6636bfd10102 Mon Sep 17 00:00:00 2001 From: Rupesh Gujare Date: Thu, 22 Aug 2013 17:38:50 +0100 Subject: [PATCH 757/942] staging: ozwpan: Increment reference counter. Increment PD reference counter, on every timer event so that we do not loose PD object by mistake. Signed-off-by: Rupesh Gujare Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozproto.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/staging/ozwpan/ozproto.c b/drivers/staging/ozwpan/ozproto.c index 8c2200b90d596..d8ac823f1c977 100644 --- a/drivers/staging/ozwpan/ozproto.c +++ b/drivers/staging/ozwpan/ozproto.c @@ -497,7 +497,7 @@ void oz_pd_heartbeat_handler(unsigned long data) spin_unlock_bh(&g_polling_lock); if (apps) oz_pd_heartbeat(pd, apps); - + oz_pd_put(pd); } /*------------------------------------------------------------------------------ @@ -519,6 +519,7 @@ void oz_pd_timeout_handler(unsigned long data) oz_pd_stop(pd); break; } + oz_pd_put(pd); } /*------------------------------------------------------------------------------ @@ -531,6 +532,7 @@ enum hrtimer_restart oz_pd_heartbeat_event(struct hrtimer *timer) pd = container_of(timer, struct oz_pd, heartbeat); hrtimer_forward_now(timer, ktime_set(pd->pulse_period / MSEC_PER_SEC, (pd->pulse_period % MSEC_PER_SEC) * NSEC_PER_MSEC)); + oz_pd_get(pd); tasklet_schedule(&pd->heartbeat_tasklet); return HRTIMER_RESTART; } @@ -543,6 +545,7 @@ enum hrtimer_restart oz_pd_timeout_event(struct hrtimer *timer) struct oz_pd *pd; pd = container_of(timer, struct oz_pd, timeout); + oz_pd_get(pd); tasklet_schedule(&pd->timeout_tasklet); return HRTIMER_NORESTART; } -- GitLab From 6af47622398d65e4cb3a52af5de52c6b447270d5 Mon Sep 17 00:00:00 2001 From: Rupesh Gujare Date: Thu, 22 Aug 2013 17:38:51 +0100 Subject: [PATCH 758/942] staging: ozwpan: Create deferred work to destroy PD object. Currently we call oz_pd_destroy() from softirq context, where we try to destroy relevant data structures, as well we kill a tasklet which always result in following kernel warning. [12279.262194] Attempt to kill tasklet from interrupt [12279.262202] Attempt to kill tasklet from interrupt This patch defers deallocation of data structures to work queue. Signed-off-by: Rupesh Gujare Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozpd.c | 28 +++++++++++++++++++++++----- drivers/staging/ozwpan/ozpd.h | 1 + 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/drivers/staging/ozwpan/ozpd.c b/drivers/staging/ozwpan/ozpd.c index 2514d79a8ff41..06004c8b85feb 100644 --- a/drivers/staging/ozwpan/ozpd.c +++ b/drivers/staging/ozwpan/ozpd.c @@ -204,18 +204,16 @@ struct oz_pd *oz_pd_alloc(const u8 *mac_addr) /*------------------------------------------------------------------------------ * Context: softirq or process */ -void oz_pd_destroy(struct oz_pd *pd) +void oz_pd_free(struct work_struct *work) { struct list_head *e; struct oz_tx_frame *f; struct oz_isoc_stream *st; struct oz_farewell *fwell; + struct oz_pd *pd; oz_pd_dbg(pd, ON, "Destroying PD\n"); - if (hrtimer_active(&pd->timeout)) - hrtimer_cancel(&pd->timeout); - if (hrtimer_active(&pd->heartbeat)) - hrtimer_cancel(&pd->heartbeat); + pd = container_of(work, struct oz_pd, workitem); /*Disable timer tasklets*/ tasklet_kill(&pd->heartbeat_tasklet); tasklet_kill(&pd->timeout_tasklet); @@ -258,6 +256,26 @@ void oz_pd_destroy(struct oz_pd *pd) kfree(pd); } +/*------------------------------------------------------------------------------ + * Context: softirq or Process + */ +void oz_pd_destroy(struct oz_pd *pd) +{ + int ret; + + if (hrtimer_active(&pd->timeout)) + hrtimer_cancel(&pd->timeout); + if (hrtimer_active(&pd->heartbeat)) + hrtimer_cancel(&pd->heartbeat); + + memset(&pd->workitem, 0, sizeof(pd->workitem)); + INIT_WORK(&pd->workitem, oz_pd_free); + ret = schedule_work(&pd->workitem); + + if (ret) + oz_pd_dbg(pd, ON, "failed to schedule workitem\n"); +} + /*------------------------------------------------------------------------------ * Context: softirq-serialized */ diff --git a/drivers/staging/ozwpan/ozpd.h b/drivers/staging/ozwpan/ozpd.h index 996ef65ed3156..12c712956888e 100644 --- a/drivers/staging/ozwpan/ozpd.h +++ b/drivers/staging/ozwpan/ozpd.h @@ -99,6 +99,7 @@ struct oz_pd { u8 timeout_type; struct tasklet_struct heartbeat_tasklet; struct tasklet_struct timeout_tasklet; + struct work_struct workitem; }; #define OZ_MAX_QUEUED_FRAMES 4 -- GitLab From 9a7fe54ddc3a70a25a773cb1e275cb7f7d2c6526 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 21 Aug 2013 22:33:43 -0500 Subject: [PATCH 759/942] staging: r8188eu: Add source files for new driver - part 1 This commit adds core/rtw_ap.c, core/rtw_br_ext.c, and core/rtw_cmd.c Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ap.c | 1988 ++++++++++++++++ drivers/staging/rtl8188eu/core/rtw_br_ext.c | 1199 ++++++++++ drivers/staging/rtl8188eu/core/rtw_cmd.c | 2364 +++++++++++++++++++ 3 files changed, 5551 insertions(+) create mode 100644 drivers/staging/rtl8188eu/core/rtw_ap.c create mode 100644 drivers/staging/rtl8188eu/core/rtw_br_ext.c create mode 100644 drivers/staging/rtl8188eu/core/rtw_cmd.c diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c b/drivers/staging/rtl8188eu/core/rtw_ap.c new file mode 100644 index 0000000000000..2c73823d2245b --- /dev/null +++ b/drivers/staging/rtl8188eu/core/rtw_ap.c @@ -0,0 +1,1988 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTW_AP_C_ + +#include +#include +#include +#include + +#ifdef CONFIG_88EU_AP_MODE + +void init_mlme_ap_info(struct adapter *padapter) +{ + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct sta_priv *pstapriv = &padapter->stapriv; + struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; + + + _rtw_spinlock_init(&pmlmepriv->bcn_update_lock); + + /* for ACL */ + _rtw_init_queue(&pacl_list->acl_node_q); + + start_ap_mode(padapter); +} + +void free_mlme_ap_info(struct adapter *padapter) +{ + unsigned long irqL; + struct sta_info *psta = NULL; + struct sta_priv *pstapriv = &padapter->stapriv; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + pmlmepriv->update_bcn = false; + pmlmeext->bstart_bss = false; + + rtw_sta_flush(padapter); + + pmlmeinfo->state = _HW_STATE_NOLINK_; + + /* free_assoc_sta_resources */ + rtw_free_all_stainfo(padapter); + + /* free bc/mc sta_info */ + psta = rtw_get_bcmc_stainfo(padapter); + _enter_critical_bh(&(pstapriv->sta_hash_lock), &irqL); + rtw_free_stainfo(padapter, psta); + _exit_critical_bh(&(pstapriv->sta_hash_lock), &irqL); + + _rtw_spinlock_free(&pmlmepriv->bcn_update_lock); +} + +static void update_BCNTIM(struct adapter *padapter) +{ + struct sta_priv *pstapriv = &padapter->stapriv; + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *pnetwork_mlmeext = &(pmlmeinfo->network); + unsigned char *pie = pnetwork_mlmeext->IEs; + + /* update TIM IE */ + if (true) { + u8 *p, *dst_ie, *premainder_ie = NULL; + u8 *pbackup_remainder_ie = NULL; + __le16 tim_bitmap_le; + uint offset, tmp_len, tim_ielen, tim_ie_offset, remainder_ielen; + + tim_bitmap_le = cpu_to_le16(pstapriv->tim_bitmap); + + p = rtw_get_ie(pie + _FIXED_IE_LENGTH_, _TIM_IE_, &tim_ielen, pnetwork_mlmeext->IELength - _FIXED_IE_LENGTH_); + if (p != NULL && tim_ielen > 0) { + tim_ielen += 2; + premainder_ie = p+tim_ielen; + tim_ie_offset = (int)(p - pie); + remainder_ielen = pnetwork_mlmeext->IELength - tim_ie_offset - tim_ielen; + /* append TIM IE from dst_ie offset */ + dst_ie = p; + } else { + tim_ielen = 0; + + /* calucate head_len */ + offset = _FIXED_IE_LENGTH_; + offset += pnetwork_mlmeext->Ssid.SsidLength + 2; + + /* get supported rates len */ + p = rtw_get_ie(pie + _BEACON_IE_OFFSET_, _SUPPORTEDRATES_IE_, &tmp_len, (pnetwork_mlmeext->IELength - _BEACON_IE_OFFSET_)); + if (p != NULL) + offset += tmp_len+2; + + /* DS Parameter Set IE, len = 3 */ + offset += 3; + + premainder_ie = pie + offset; + + remainder_ielen = pnetwork_mlmeext->IELength - offset - tim_ielen; + + /* append TIM IE from offset */ + dst_ie = pie + offset; + } + + if (remainder_ielen > 0) { + pbackup_remainder_ie = rtw_malloc(remainder_ielen); + if (pbackup_remainder_ie && premainder_ie) + memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen); + } + *dst_ie++ = _TIM_IE_; + + if ((pstapriv->tim_bitmap&0xff00) && (pstapriv->tim_bitmap&0x00fc)) + tim_ielen = 5; + else + tim_ielen = 4; + + *dst_ie++ = tim_ielen; + + *dst_ie++ = 0;/* DTIM count */ + *dst_ie++ = 1;/* DTIM peroid */ + + if (pstapriv->tim_bitmap&BIT(0))/* for bc/mc frames */ + *dst_ie++ = BIT(0);/* bitmap ctrl */ + else + *dst_ie++ = 0; + + if (tim_ielen == 4) { + *dst_ie++ = *(u8 *)&tim_bitmap_le; + } else if (tim_ielen == 5) { + memcpy(dst_ie, &tim_bitmap_le, 2); + dst_ie += 2; + } + + /* copy remainder IE */ + if (pbackup_remainder_ie) { + memcpy(dst_ie, pbackup_remainder_ie, remainder_ielen); + + kfree(pbackup_remainder_ie); + } + offset = (uint)(dst_ie - pie); + pnetwork_mlmeext->IELength = offset + remainder_ielen; + } + + set_tx_beacon_cmd(padapter); +} + +void rtw_add_bcn_ie(struct adapter *padapter, struct wlan_bssid_ex *pnetwork, u8 index, u8 *data, u8 len) +{ + struct ndis_802_11_var_ie *pIE; + u8 bmatch = false; + u8 *pie = pnetwork->IEs; + u8 *p = NULL, *dst_ie = NULL, *premainder_ie = NULL; + u8 *pbackup_remainder_ie = NULL; + u32 i, offset, ielen = 0, ie_offset, remainder_ielen = 0; + + for (i = sizeof(struct ndis_802_11_fixed_ie); i < pnetwork->IELength;) { + pIE = (struct ndis_802_11_var_ie *)(pnetwork->IEs + i); + + if (pIE->ElementID > index) { + break; + } else if (pIE->ElementID == index) { /* already exist the same IE */ + p = (u8 *)pIE; + ielen = pIE->Length; + bmatch = true; + break; + } + p = (u8 *)pIE; + ielen = pIE->Length; + i += (pIE->Length + 2); + } + + if (p != NULL && ielen > 0) { + ielen += 2; + + premainder_ie = p+ielen; + + ie_offset = (int)(p - pie); + + remainder_ielen = pnetwork->IELength - ie_offset - ielen; + + if (bmatch) + dst_ie = p; + else + dst_ie = (p+ielen); + } + + if (remainder_ielen > 0) { + pbackup_remainder_ie = rtw_malloc(remainder_ielen); + if (pbackup_remainder_ie && premainder_ie) + memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen); + } + + *dst_ie++ = index; + *dst_ie++ = len; + + memcpy(dst_ie, data, len); + dst_ie += len; + + /* copy remainder IE */ + if (pbackup_remainder_ie) { + memcpy(dst_ie, pbackup_remainder_ie, remainder_ielen); + + kfree(pbackup_remainder_ie); + } + + offset = (uint)(dst_ie - pie); + pnetwork->IELength = offset + remainder_ielen; +} + +void rtw_remove_bcn_ie(struct adapter *padapter, struct wlan_bssid_ex *pnetwork, u8 index) +{ + u8 *p, *dst_ie = NULL, *premainder_ie = NULL; + u8 *pbackup_remainder_ie = NULL; + uint offset, ielen, ie_offset, remainder_ielen = 0; + u8 *pie = pnetwork->IEs; + + p = rtw_get_ie(pie + _FIXED_IE_LENGTH_, index, &ielen, + pnetwork->IELength - _FIXED_IE_LENGTH_); + if (p != NULL && ielen > 0) { + ielen += 2; + + premainder_ie = p+ielen; + + ie_offset = (int)(p - pie); + + remainder_ielen = pnetwork->IELength - ie_offset - ielen; + + dst_ie = p; + } + + if (remainder_ielen > 0) { + pbackup_remainder_ie = rtw_malloc(remainder_ielen); + if (pbackup_remainder_ie && premainder_ie) + memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen); + } + + /* copy remainder IE */ + if (pbackup_remainder_ie) { + memcpy(dst_ie, pbackup_remainder_ie, remainder_ielen); + + kfree(pbackup_remainder_ie); + } + + offset = (uint)(dst_ie - pie); + pnetwork->IELength = offset + remainder_ielen; +} + +static u8 chk_sta_is_alive(struct sta_info *psta) +{ + u8 ret = false; + + if ((psta->sta_stats.last_rx_data_pkts + psta->sta_stats.last_rx_ctrl_pkts) == + (psta->sta_stats.rx_data_pkts + psta->sta_stats.rx_ctrl_pkts)) + ; + else + ret = true; + + sta_update_last_rx_pkts(psta); + + return ret; +} + +void expire_timeout_chk(struct adapter *padapter) +{ + unsigned long irqL; + struct list_head *phead, *plist; + u8 updated = 0; + struct sta_info *psta = NULL; + struct sta_priv *pstapriv = &padapter->stapriv; + u8 chk_alive_num = 0; + char chk_alive_list[NUM_STA]; + int i; + + _enter_critical_bh(&pstapriv->auth_list_lock, &irqL); + + phead = &pstapriv->auth_list; + plist = get_next(phead); + + /* check auth_queue */ + while ((rtw_end_of_queue_search(phead, plist)) == false) { + psta = LIST_CONTAINOR(plist, struct sta_info, auth_list); + plist = get_next(plist); + + if (psta->expire_to > 0) { + psta->expire_to--; + if (psta->expire_to == 0) { + rtw_list_delete(&psta->auth_list); + pstapriv->auth_list_cnt--; + + DBG_88E("auth expire %6ph\n", + psta->hwaddr); + + _exit_critical_bh(&pstapriv->auth_list_lock, &irqL); + + _enter_critical_bh(&(pstapriv->sta_hash_lock), &irqL); + rtw_free_stainfo(padapter, psta); + _exit_critical_bh(&(pstapriv->sta_hash_lock), &irqL); + + _enter_critical_bh(&pstapriv->auth_list_lock, &irqL); + } + } + + } + _exit_critical_bh(&pstapriv->auth_list_lock, &irqL); + + psta = NULL; + + _enter_critical_bh(&pstapriv->asoc_list_lock, &irqL); + + phead = &pstapriv->asoc_list; + plist = get_next(phead); + + /* check asoc_queue */ + while ((rtw_end_of_queue_search(phead, plist)) == false) { + psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); + plist = get_next(plist); + + if (chk_sta_is_alive(psta) || !psta->expire_to) { + psta->expire_to = pstapriv->expire_to; + psta->keep_alive_trycnt = 0; + psta->under_exist_checking = 0; + } else { + psta->expire_to--; + } + + if (psta->expire_to <= 0) { + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + + if (padapter->registrypriv.wifi_spec == 1) { + psta->expire_to = pstapriv->expire_to; + continue; + } + + if (psta->state & WIFI_SLEEP_STATE) { + if (!(psta->state & WIFI_STA_ALIVE_CHK_STATE)) { + /* to check if alive by another methods if staion is at ps mode. */ + psta->expire_to = pstapriv->expire_to; + psta->state |= WIFI_STA_ALIVE_CHK_STATE; + + /* to update bcn with tim_bitmap for this station */ + pstapriv->tim_bitmap |= BIT(psta->aid); + update_beacon(padapter, _TIM_IE_, NULL, false); + + if (!pmlmeext->active_keep_alive_check) + continue; + } + } + if (pmlmeext->active_keep_alive_check) { + int stainfo_offset; + + stainfo_offset = rtw_stainfo_offset(pstapriv, psta); + if (stainfo_offset_valid(stainfo_offset)) + chk_alive_list[chk_alive_num++] = stainfo_offset; + continue; + } + + rtw_list_delete(&psta->asoc_list); + pstapriv->asoc_list_cnt--; + + DBG_88E("asoc expire %pM, state = 0x%x\n", (psta->hwaddr), psta->state); + updated = ap_free_sta(padapter, psta, true, WLAN_REASON_DEAUTH_LEAVING); + } else { + /* TODO: Aging mechanism to digest frames in sleep_q to avoid running out of xmitframe */ + if (psta->sleepq_len > (NR_XMITFRAME/pstapriv->asoc_list_cnt) && + padapter->xmitpriv.free_xmitframe_cnt < (NR_XMITFRAME/pstapriv->asoc_list_cnt/2)) { + DBG_88E("%s sta:%pM, sleepq_len:%u, free_xmitframe_cnt:%u, asoc_list_cnt:%u, clear sleep_q\n", __func__, + (psta->hwaddr), psta->sleepq_len, + padapter->xmitpriv.free_xmitframe_cnt, + pstapriv->asoc_list_cnt); + wakeup_sta_to_xmit(padapter, psta); + } + } + } + + _exit_critical_bh(&pstapriv->asoc_list_lock, &irqL); + + if (chk_alive_num) { + u8 backup_oper_channel = 0; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + /* switch to correct channel of current network before issue keep-alive frames */ + if (rtw_get_oper_ch(padapter) != pmlmeext->cur_channel) { + backup_oper_channel = rtw_get_oper_ch(padapter); + SelectChannel(padapter, pmlmeext->cur_channel); + } + + /* issue null data to check sta alive*/ + for (i = 0; i < chk_alive_num; i++) { + int ret = _FAIL; + + psta = rtw_get_stainfo_by_offset(pstapriv, chk_alive_list[i]); + + if (psta->state & WIFI_SLEEP_STATE) + ret = issue_nulldata(padapter, psta->hwaddr, 0, 1, 50); + else + ret = issue_nulldata(padapter, psta->hwaddr, 0, 3, 50); + + psta->keep_alive_trycnt++; + if (ret == _SUCCESS) { + DBG_88E("asoc check, sta(%pM) is alive\n", (psta->hwaddr)); + psta->expire_to = pstapriv->expire_to; + psta->keep_alive_trycnt = 0; + continue; + } else if (psta->keep_alive_trycnt <= 3) { + DBG_88E("ack check for asoc expire, keep_alive_trycnt =%d\n", psta->keep_alive_trycnt); + psta->expire_to = 1; + continue; + } + + psta->keep_alive_trycnt = 0; + + DBG_88E("asoc expire %pM, state = 0x%x\n", (psta->hwaddr), psta->state); + _enter_critical_bh(&pstapriv->asoc_list_lock, &irqL); + rtw_list_delete(&psta->asoc_list); + pstapriv->asoc_list_cnt--; + updated = ap_free_sta(padapter, psta, true, WLAN_REASON_DEAUTH_LEAVING); + _exit_critical_bh(&pstapriv->asoc_list_lock, &irqL); + } + + if (backup_oper_channel > 0) /* back to the original operation channel */ + SelectChannel(padapter, backup_oper_channel); + } + + associated_clients_update(padapter, updated); +} + +void add_RATid(struct adapter *padapter, struct sta_info *psta, u8 rssi_level) +{ + int i; + u8 rf_type; + u32 init_rate = 0; + unsigned char sta_band = 0, raid, shortGIrate = false; + unsigned char limit; + unsigned int tx_ra_bitmap = 0; + struct ht_priv *psta_ht = NULL; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct wlan_bssid_ex *pcur_network = (struct wlan_bssid_ex *)&pmlmepriv->cur_network.network; + + if (psta) + psta_ht = &psta->htpriv; + else + return; + + if (!(psta->state & _FW_LINKED)) + return; + + /* b/g mode ra_bitmap */ + for (i = 0; i < sizeof(psta->bssrateset); i++) { + if (psta->bssrateset[i]) + tx_ra_bitmap |= rtw_get_bit_value_from_ieee_value(psta->bssrateset[i]&0x7f); + } + /* n mode ra_bitmap */ + if (psta_ht->ht_option) { + rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); + if (rf_type == RF_2T2R) + limit = 16;/* 2R */ + else + limit = 8;/* 1R */ + + for (i = 0; i < limit; i++) { + if (psta_ht->ht_cap.supp_mcs_set[i/8] & BIT(i%8)) + tx_ra_bitmap |= BIT(i+12); + } + + /* max short GI rate */ + shortGIrate = psta_ht->sgi; + } + + if (pcur_network->Configuration.DSConfig > 14) { + /* 5G band */ + if (tx_ra_bitmap & 0xffff000) + sta_band |= WIRELESS_11_5N | WIRELESS_11A; + else + sta_band |= WIRELESS_11A; + } else { + if (tx_ra_bitmap & 0xffff000) + sta_band |= WIRELESS_11_24N | WIRELESS_11G | WIRELESS_11B; + else if (tx_ra_bitmap & 0xff0) + sta_band |= WIRELESS_11G | WIRELESS_11B; + else + sta_band |= WIRELESS_11B; + } + + psta->wireless_mode = sta_band; + + raid = networktype_to_raid(sta_band); + init_rate = get_highest_rate_idx(tx_ra_bitmap&0x0fffffff)&0x3f; + + if (psta->aid < NUM_STA) { + u8 arg = 0; + + arg = psta->mac_id&0x1f; + + arg |= BIT(7);/* support entry 2~31 */ + + if (shortGIrate) + arg |= BIT(5); + + tx_ra_bitmap |= ((raid<<28)&0xf0000000); + + DBG_88E("%s => mac_id:%d , raid:%d , bitmap = 0x%x, arg = 0x%x\n", + __func__ , psta->mac_id, raid , tx_ra_bitmap, arg); + + /* bitmap[0:27] = tx_rate_bitmap */ + /* bitmap[28:31]= Rate Adaptive id */ + /* arg[0:4] = macid */ + /* arg[5] = Short GI */ + rtw_hal_add_ra_tid(padapter, tx_ra_bitmap, arg, rssi_level); + + if (shortGIrate) + init_rate |= BIT(6); + + /* set ra_id, init_rate */ + psta->raid = raid; + psta->init_rate = init_rate; + + } else { + DBG_88E("station aid %d exceed the max number\n", psta->aid); + } +} + +static void update_bmc_sta(struct adapter *padapter) +{ + unsigned long irqL; + u32 init_rate = 0; + unsigned char network_type, raid; + int i, supportRateNum = 0; + unsigned int tx_ra_bitmap = 0; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct wlan_bssid_ex *pcur_network = (struct wlan_bssid_ex *)&pmlmepriv->cur_network.network; + struct sta_info *psta = rtw_get_bcmc_stainfo(padapter); + + if (psta) { + psta->aid = 0;/* default set to 0 */ + psta->mac_id = psta->aid + 1; + + psta->qos_option = 0; + psta->htpriv.ht_option = false; + + psta->ieee8021x_blocked = 0; + + _rtw_memset((void *)&psta->sta_stats, 0, sizeof(struct stainfo_stats)); + + /* prepare for add_RATid */ + supportRateNum = rtw_get_rateset_len((u8 *)&pcur_network->SupportedRates); + network_type = rtw_check_network_type((u8 *)&pcur_network->SupportedRates, supportRateNum, 1); + + memcpy(psta->bssrateset, &pcur_network->SupportedRates, supportRateNum); + psta->bssratelen = supportRateNum; + + /* b/g mode ra_bitmap */ + for (i = 0; i < supportRateNum; i++) { + if (psta->bssrateset[i]) + tx_ra_bitmap |= rtw_get_bit_value_from_ieee_value(psta->bssrateset[i]&0x7f); + } + + if (pcur_network->Configuration.DSConfig > 14) { + /* force to A mode. 5G doesn't support CCK rates */ + network_type = WIRELESS_11A; + tx_ra_bitmap = 0x150; /* 6, 12, 24 Mbps */ + } else { + /* force to b mode */ + network_type = WIRELESS_11B; + tx_ra_bitmap = 0xf; + } + + raid = networktype_to_raid(network_type); + init_rate = get_highest_rate_idx(tx_ra_bitmap&0x0fffffff)&0x3f; + + /* ap mode */ + rtw_hal_set_odm_var(padapter, HAL_ODM_STA_INFO, psta, true); + + { + u8 arg = 0; + + arg = psta->mac_id&0x1f; + arg |= BIT(7); + tx_ra_bitmap |= ((raid<<28)&0xf0000000); + DBG_88E("update_bmc_sta, mask = 0x%x, arg = 0x%x\n", tx_ra_bitmap, arg); + + /* bitmap[0:27] = tx_rate_bitmap */ + /* bitmap[28:31]= Rate Adaptive id */ + /* arg[0:4] = macid */ + /* arg[5] = Short GI */ + rtw_hal_add_ra_tid(padapter, tx_ra_bitmap, arg, 0); + } + /* set ra_id, init_rate */ + psta->raid = raid; + psta->init_rate = init_rate; + + rtw_stassoc_hw_rpt(padapter, psta); + + _enter_critical_bh(&psta->lock, &irqL); + psta->state = _FW_LINKED; + _exit_critical_bh(&psta->lock, &irqL); + + } else { + DBG_88E("add_RATid_bmc_sta error!\n"); + } +} + +/* notes: */ +/* AID: 1~MAX for sta and 0 for bc/mc in ap/adhoc mode */ +/* MAC_ID = AID+1 for sta in ap/adhoc mode */ +/* MAC_ID = 1 for bc/mc for sta/ap/adhoc */ +/* MAC_ID = 0 for bssid for sta/ap/adhoc */ +/* CAM_ID = 0~3 for default key, cmd_id = macid + 3, macid = aid+1; */ + +void update_sta_info_apmode(struct adapter *padapter, struct sta_info *psta) +{ + unsigned long irqL; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct security_priv *psecuritypriv = &padapter->securitypriv; + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct ht_priv *phtpriv_ap = &pmlmepriv->htpriv; + struct ht_priv *phtpriv_sta = &psta->htpriv; + + psta->mac_id = psta->aid+1; + DBG_88E("%s\n", __func__); + + /* ap mode */ + rtw_hal_set_odm_var(padapter, HAL_ODM_STA_INFO, psta, true); + + if (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) + psta->ieee8021x_blocked = true; + else + psta->ieee8021x_blocked = false; + + + /* update sta's cap */ + + /* ERP */ + VCS_update(padapter, psta); + /* HT related cap */ + if (phtpriv_sta->ht_option) { + /* check if sta supports rx ampdu */ + phtpriv_sta->ampdu_enable = phtpriv_ap->ampdu_enable; + + /* check if sta support s Short GI */ + if ((phtpriv_sta->ht_cap.cap_info & phtpriv_ap->ht_cap.cap_info) & (IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40)) + phtpriv_sta->sgi = true; + + /* bwmode */ + if ((phtpriv_sta->ht_cap.cap_info & phtpriv_ap->ht_cap.cap_info) & IEEE80211_HT_CAP_SUP_WIDTH) { + phtpriv_sta->bwmode = pmlmeext->cur_bwmode; + phtpriv_sta->ch_offset = pmlmeext->cur_ch_offset; + } + psta->qos_option = true; + } else { + phtpriv_sta->ampdu_enable = false; + phtpriv_sta->sgi = false; + phtpriv_sta->bwmode = HT_CHANNEL_WIDTH_20; + phtpriv_sta->ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; + } + + /* Rx AMPDU */ + send_delba(padapter, 0, psta->hwaddr);/* recipient */ + + /* TX AMPDU */ + send_delba(padapter, 1, psta->hwaddr);/* originator */ + phtpriv_sta->agg_enable_bitmap = 0x0;/* reset */ + phtpriv_sta->candidate_tid_bitmap = 0x0;/* reset */ + + /* todo: init other variables */ + + _rtw_memset((void *)&psta->sta_stats, 0, sizeof(struct stainfo_stats)); + + _enter_critical_bh(&psta->lock, &irqL); + psta->state |= _FW_LINKED; + _exit_critical_bh(&psta->lock, &irqL); +} + +static void update_hw_ht_param(struct adapter *padapter) +{ + unsigned char max_AMPDU_len; + unsigned char min_MPDU_spacing; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + DBG_88E("%s\n", __func__); + + /* handle A-MPDU parameter field */ + /* + AMPDU_para [1:0]:Max AMPDU Len => 0:8k , 1:16k, 2:32k, 3:64k + AMPDU_para [4:2]:Min MPDU Start Spacing + */ + max_AMPDU_len = pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x03; + + min_MPDU_spacing = (pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c) >> 2; + + rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_MIN_SPACE, (u8 *)(&min_MPDU_spacing)); + + rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_FACTOR, (u8 *)(&max_AMPDU_len)); + + /* */ + /* Config SM Power Save setting */ + /* */ + pmlmeinfo->SM_PS = (le16_to_cpu(pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info) & 0x0C) >> 2; + if (pmlmeinfo->SM_PS == WLAN_HT_CAP_SM_PS_STATIC) + DBG_88E("%s(): WLAN_HT_CAP_SM_PS_STATIC\n", __func__); +} + +static void start_bss_network(struct adapter *padapter, u8 *pbuf) +{ + u8 *p; + u8 val8, cur_channel, cur_bwmode, cur_ch_offset; + u16 bcn_interval; + u32 acparm; + int ie_len; + struct registry_priv *pregpriv = &padapter->registrypriv; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct security_priv *psecuritypriv = &(padapter->securitypriv); + struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)&pmlmepriv->cur_network.network; + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *pnetwork_mlmeext = &(pmlmeinfo->network); + struct HT_info_element *pht_info = NULL; +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); +#endif /* CONFIG_88EU_P2P */ + + bcn_interval = (u16)pnetwork->Configuration.BeaconPeriod; + cur_channel = pnetwork->Configuration.DSConfig; + cur_bwmode = HT_CHANNEL_WIDTH_20; + cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; + + + /* check if there is wps ie, */ + /* if there is wpsie in beacon, the hostapd will update beacon twice when stating hostapd, */ + /* and at first time the security ie (RSN/WPA IE) will not include in beacon. */ + if (!rtw_get_wps_ie(pnetwork->IEs+_FIXED_IE_LENGTH_, pnetwork->IELength-_FIXED_IE_LENGTH_, NULL, NULL)) + pmlmeext->bstart_bss = true; + + /* todo: update wmm, ht cap */ + if (pmlmepriv->qospriv.qos_option) + pmlmeinfo->WMM_enable = true; + if (pmlmepriv->htpriv.ht_option) { + pmlmeinfo->WMM_enable = true; + pmlmeinfo->HT_enable = true; + + update_hw_ht_param(padapter); + } + + if (pmlmepriv->cur_network.join_res != true) { /* setting only at first time */ + /* WEP Key will be set before this function, do not clear CAM. */ + if ((psecuritypriv->dot11PrivacyAlgrthm != _WEP40_) && + (psecuritypriv->dot11PrivacyAlgrthm != _WEP104_)) + flush_all_cam_entry(padapter); /* clear CAM */ + } + + /* set MSR to AP_Mode */ + Set_MSR(padapter, _HW_STATE_AP_); + + /* Set BSSID REG */ + rtw_hal_set_hwreg(padapter, HW_VAR_BSSID, pnetwork->MacAddress); + + /* Set EDCA param reg */ + acparm = 0x002F3217; /* VO */ + rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_VO, (u8 *)(&acparm)); + acparm = 0x005E4317; /* VI */ + rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_VI, (u8 *)(&acparm)); + acparm = 0x005ea42b; + rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_BE, (u8 *)(&acparm)); + acparm = 0x0000A444; /* BK */ + rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_BK, (u8 *)(&acparm)); + + /* Set Security */ + val8 = (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) ? 0xcc : 0xcf; + rtw_hal_set_hwreg(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8)); + + /* Beacon Control related register */ + rtw_hal_set_hwreg(padapter, HW_VAR_BEACON_INTERVAL, (u8 *)(&bcn_interval)); + + UpdateBrateTbl(padapter, pnetwork->SupportedRates); + rtw_hal_set_hwreg(padapter, HW_VAR_BASIC_RATE, pnetwork->SupportedRates); + + if (!pmlmepriv->cur_network.join_res) { /* setting only at first time */ + /* turn on all dynamic functions */ + Switch_DM_Func(padapter, DYNAMIC_ALL_FUNC_ENABLE, true); + } + /* set channel, bwmode */ + p = rtw_get_ie((pnetwork->IEs + sizeof(struct ndis_802_11_fixed_ie)), _HT_ADD_INFO_IE_, &ie_len, (pnetwork->IELength - sizeof(struct ndis_802_11_fixed_ie))); + if (p && ie_len) { + pht_info = (struct HT_info_element *)(p+2); + + if ((pregpriv->cbw40_enable) && (pht_info->infos[0] & BIT(2))) { + /* switch to the 40M Hz mode */ + cur_bwmode = HT_CHANNEL_WIDTH_40; + switch (pht_info->infos[0] & 0x3) { + case 1: + cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER; + break; + case 3: + cur_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER; + break; + default: + cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; + break; + } + } + } + /* TODO: need to judge the phy parameters on concurrent mode for single phy */ + set_channel_bwmode(padapter, cur_channel, cur_ch_offset, cur_bwmode); + + DBG_88E("CH =%d, BW =%d, offset =%d\n", cur_channel, cur_bwmode, cur_ch_offset); + + /* */ + pmlmeext->cur_channel = cur_channel; + pmlmeext->cur_bwmode = cur_bwmode; + pmlmeext->cur_ch_offset = cur_ch_offset; + pmlmeext->cur_wireless_mode = pmlmepriv->cur_network.network_type; + + /* update cur_wireless_mode */ + update_wireless_mode(padapter); + + /* udpate capability after cur_wireless_mode updated */ + update_capinfo(padapter, rtw_get_capability((struct wlan_bssid_ex *)pnetwork)); + + /* let pnetwork_mlmeext == pnetwork_mlme. */ + memcpy(pnetwork_mlmeext, pnetwork, pnetwork->Length); + +#ifdef CONFIG_88EU_P2P + memcpy(pwdinfo->p2p_group_ssid, pnetwork->Ssid.Ssid, pnetwork->Ssid.SsidLength); + pwdinfo->p2p_group_ssid_len = pnetwork->Ssid.SsidLength; +#endif /* CONFIG_88EU_P2P */ + + if (pmlmeext->bstart_bss) { + update_beacon(padapter, _TIM_IE_, NULL, false); + + /* issue beacon frame */ + if (send_beacon(padapter) == _FAIL) + DBG_88E("issue_beacon, fail!\n"); + } + + /* update bc/mc sta_info */ + update_bmc_sta(padapter); +} + +int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) +{ + int ret = _SUCCESS; + u8 *p; + u8 *pHT_caps_ie = NULL; + u8 *pHT_info_ie = NULL; + struct sta_info *psta = NULL; + u16 cap, ht_cap = false; + uint ie_len = 0; + int group_cipher, pairwise_cipher; + u8 channel, network_type, supportRate[NDIS_802_11_LENGTH_RATES_EX]; + int supportRateNum = 0; + u8 OUI1[] = {0x00, 0x50, 0xf2, 0x01}; + u8 WMM_PARA_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x01, 0x01}; + struct registry_priv *pregistrypriv = &padapter->registrypriv; + struct security_priv *psecuritypriv = &padapter->securitypriv; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct wlan_bssid_ex *pbss_network = (struct wlan_bssid_ex *)&pmlmepriv->cur_network.network; + u8 *ie = pbss_network->IEs; + + /* SSID */ + /* Supported rates */ + /* DS Params */ + /* WLAN_EID_COUNTRY */ + /* ERP Information element */ + /* Extended supported rates */ + /* WPA/WPA2 */ + /* Wi-Fi Wireless Multimedia Extensions */ + /* ht_capab, ht_oper */ + /* WPS IE */ + + DBG_88E("%s, len =%d\n", __func__, len); + + if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) + return _FAIL; + + + if (len > MAX_IE_SZ) + return _FAIL; + + pbss_network->IELength = len; + + _rtw_memset(ie, 0, MAX_IE_SZ); + + memcpy(ie, pbuf, pbss_network->IELength); + + + if (pbss_network->InfrastructureMode != Ndis802_11APMode) + return _FAIL; + + pbss_network->Rssi = 0; + + memcpy(pbss_network->MacAddress, myid(&(padapter->eeprompriv)), ETH_ALEN); + + /* beacon interval */ + p = rtw_get_beacon_interval_from_ie(ie);/* 8: TimeStamp, 2: Beacon Interval 2:Capability */ + pbss_network->Configuration.BeaconPeriod = RTW_GET_LE16(p); + + /* capability */ + cap = RTW_GET_LE16(ie); + + /* SSID */ + p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _SSID_IE_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_)); + if (p && ie_len > 0) { + _rtw_memset(&pbss_network->Ssid, 0, sizeof(struct ndis_802_11_ssid)); + memcpy(pbss_network->Ssid.Ssid, (p + 2), ie_len); + pbss_network->Ssid.SsidLength = ie_len; + } + + /* channel */ + channel = 0; + pbss_network->Configuration.Length = 0; + p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _DSSET_IE_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_)); + if (p && ie_len > 0) + channel = *(p + 2); + + pbss_network->Configuration.DSConfig = channel; + + _rtw_memset(supportRate, 0, NDIS_802_11_LENGTH_RATES_EX); + /* get supported rates */ + p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _SUPPORTEDRATES_IE_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_)); + if (p != NULL) { + memcpy(supportRate, p+2, ie_len); + supportRateNum = ie_len; + } + + /* get ext_supported rates */ + p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _EXT_SUPPORTEDRATES_IE_, &ie_len, pbss_network->IELength - _BEACON_IE_OFFSET_); + if (p != NULL) { + memcpy(supportRate+supportRateNum, p+2, ie_len); + supportRateNum += ie_len; + } + + network_type = rtw_check_network_type(supportRate, supportRateNum, channel); + + rtw_set_supported_rate(pbss_network->SupportedRates, network_type); + + /* parsing ERP_IE */ + p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _ERPINFO_IE_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_)); + if (p && ie_len > 0) + ERP_IE_handler(padapter, (struct ndis_802_11_var_ie *)p); + + /* update privacy/security */ + if (cap & BIT(4)) + pbss_network->Privacy = 1; + else + pbss_network->Privacy = 0; + + psecuritypriv->wpa_psk = 0; + + /* wpa2 */ + group_cipher = 0; + pairwise_cipher = 0; + psecuritypriv->wpa2_group_cipher = _NO_PRIVACY_; + psecuritypriv->wpa2_pairwise_cipher = _NO_PRIVACY_; + p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _RSN_IE_2_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_)); + if (p && ie_len > 0) { + if (rtw_parse_wpa2_ie(p, ie_len+2, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) { + psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; + + psecuritypriv->dot8021xalg = 1;/* psk, todo:802.1x */ + psecuritypriv->wpa_psk |= BIT(1); + + psecuritypriv->wpa2_group_cipher = group_cipher; + psecuritypriv->wpa2_pairwise_cipher = pairwise_cipher; + } + } + /* wpa */ + ie_len = 0; + group_cipher = 0; + pairwise_cipher = 0; + psecuritypriv->wpa_group_cipher = _NO_PRIVACY_; + psecuritypriv->wpa_pairwise_cipher = _NO_PRIVACY_; + for (p = ie + _BEACON_IE_OFFSET_;; p += (ie_len + 2)) { + p = rtw_get_ie(p, _SSN_IE_1_, &ie_len, + (pbss_network->IELength - _BEACON_IE_OFFSET_ - (ie_len + 2))); + if ((p) && (_rtw_memcmp(p+2, OUI1, 4))) { + if (rtw_parse_wpa_ie(p, ie_len+2, &group_cipher, + &pairwise_cipher, NULL) == _SUCCESS) { + psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; + + psecuritypriv->dot8021xalg = 1;/* psk, todo:802.1x */ + + psecuritypriv->wpa_psk |= BIT(0); + + psecuritypriv->wpa_group_cipher = group_cipher; + psecuritypriv->wpa_pairwise_cipher = pairwise_cipher; + } + break; + } + if ((p == NULL) || (ie_len == 0)) + break; + } + + /* wmm */ + ie_len = 0; + pmlmepriv->qospriv.qos_option = 0; + if (pregistrypriv->wmm_enable) { + for (p = ie + _BEACON_IE_OFFSET_;; p += (ie_len + 2)) { + p = rtw_get_ie(p, _VENDOR_SPECIFIC_IE_, &ie_len, + (pbss_network->IELength - _BEACON_IE_OFFSET_ - (ie_len + 2))); + if ((p) && _rtw_memcmp(p+2, WMM_PARA_IE, 6)) { + pmlmepriv->qospriv.qos_option = 1; + + *(p+8) |= BIT(7);/* QoS Info, support U-APSD */ + + /* disable all ACM bits since the WMM admission control is not supported */ + *(p + 10) &= ~BIT(4); /* BE */ + *(p + 14) &= ~BIT(4); /* BK */ + *(p + 18) &= ~BIT(4); /* VI */ + *(p + 22) &= ~BIT(4); /* VO */ + break; + } + + if ((p == NULL) || (ie_len == 0)) + break; + } + } + /* parsing HT_CAP_IE */ + p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _HT_CAPABILITY_IE_, &ie_len, + (pbss_network->IELength - _BEACON_IE_OFFSET_)); + if (p && ie_len > 0) { + u8 rf_type; + struct rtw_ieee80211_ht_cap *pht_cap = (struct rtw_ieee80211_ht_cap *)(p+2); + + pHT_caps_ie = p; + ht_cap = true; + network_type |= WIRELESS_11_24N; + + rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); + + if ((psecuritypriv->wpa_pairwise_cipher & WPA_CIPHER_CCMP) || + (psecuritypriv->wpa2_pairwise_cipher & WPA_CIPHER_CCMP)) + pht_cap->ampdu_params_info |= (IEEE80211_HT_CAP_AMPDU_DENSITY&(0x07<<2)); + else + pht_cap->ampdu_params_info |= (IEEE80211_HT_CAP_AMPDU_DENSITY&0x00); + + /* set Max Rx AMPDU size to 64K */ + pht_cap->ampdu_params_info |= (IEEE80211_HT_CAP_AMPDU_FACTOR & 0x03); + + if (rf_type == RF_1T1R) { + pht_cap->supp_mcs_set[0] = 0xff; + pht_cap->supp_mcs_set[1] = 0x0; + } + memcpy(&pmlmepriv->htpriv.ht_cap, p+2, ie_len); + } + + /* parsing HT_INFO_IE */ + p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _HT_ADD_INFO_IE_, &ie_len, + (pbss_network->IELength - _BEACON_IE_OFFSET_)); + if (p && ie_len > 0) + pHT_info_ie = p; + switch (network_type) { + case WIRELESS_11B: + pbss_network->NetworkTypeInUse = Ndis802_11DS; + break; + case WIRELESS_11G: + case WIRELESS_11BG: + case WIRELESS_11G_24N: + case WIRELESS_11BG_24N: + pbss_network->NetworkTypeInUse = Ndis802_11OFDM24; + break; + case WIRELESS_11A: + pbss_network->NetworkTypeInUse = Ndis802_11OFDM5; + break; + default: + pbss_network->NetworkTypeInUse = Ndis802_11OFDM24; + break; + } + + pmlmepriv->cur_network.network_type = network_type; + + pmlmepriv->htpriv.ht_option = false; + + if ((psecuritypriv->wpa2_pairwise_cipher & WPA_CIPHER_TKIP) || + (psecuritypriv->wpa_pairwise_cipher & WPA_CIPHER_TKIP)) { + /* todo: */ + /* ht_cap = false; */ + } + + /* ht_cap */ + if (pregistrypriv->ht_enable && ht_cap) { + pmlmepriv->htpriv.ht_option = true; + pmlmepriv->qospriv.qos_option = 1; + + if (pregistrypriv->ampdu_enable == 1) + pmlmepriv->htpriv.ampdu_enable = true; + HT_caps_handler(padapter, (struct ndis_802_11_var_ie *)pHT_caps_ie); + + HT_info_handler(padapter, (struct ndis_802_11_var_ie *)pHT_info_ie); + } + + pbss_network->Length = get_wlan_bssid_ex_sz((struct wlan_bssid_ex *)pbss_network); + + /* issue beacon to start bss network */ + start_bss_network(padapter, (u8 *)pbss_network); + + /* alloc sta_info for ap itself */ + psta = rtw_get_stainfo(&padapter->stapriv, pbss_network->MacAddress); + if (!psta) { + psta = rtw_alloc_stainfo(&padapter->stapriv, pbss_network->MacAddress); + if (psta == NULL) + return _FAIL; + } + + pmlmepriv->cur_network.join_res = true;/* for check if already set beacon */ + return ret; +} + +void rtw_set_macaddr_acl(struct adapter *padapter, int mode) +{ + struct sta_priv *pstapriv = &padapter->stapriv; + struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; + + DBG_88E("%s, mode =%d\n", __func__, mode); + + pacl_list->mode = mode; +} + +int rtw_acl_add_sta(struct adapter *padapter, u8 *addr) +{ + unsigned long irqL; + struct list_head *plist, *phead; + u8 added = false; + int i, ret = 0; + struct rtw_wlan_acl_node *paclnode; + struct sta_priv *pstapriv = &padapter->stapriv; + struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; + struct __queue *pacl_node_q = &pacl_list->acl_node_q; + + DBG_88E("%s(acl_num =%d) =%pM\n", __func__, pacl_list->num, (addr)); + + if ((NUM_ACL-1) < pacl_list->num) + return -1; + + _enter_critical_bh(&(pacl_node_q->lock), &irqL); + + phead = get_list_head(pacl_node_q); + plist = get_next(phead); + + while (!rtw_end_of_queue_search(phead, plist)) { + paclnode = LIST_CONTAINOR(plist, struct rtw_wlan_acl_node, list); + plist = get_next(plist); + + if (_rtw_memcmp(paclnode->addr, addr, ETH_ALEN)) { + if (paclnode->valid) { + added = true; + DBG_88E("%s, sta has been added\n", __func__); + break; + } + } + } + + _exit_critical_bh(&(pacl_node_q->lock), &irqL); + + if (added) + return ret; + + _enter_critical_bh(&(pacl_node_q->lock), &irqL); + + for (i = 0; i < NUM_ACL; i++) { + paclnode = &pacl_list->aclnode[i]; + + if (!paclnode->valid) { + _rtw_init_listhead(&paclnode->list); + + memcpy(paclnode->addr, addr, ETH_ALEN); + + paclnode->valid = true; + + rtw_list_insert_tail(&paclnode->list, get_list_head(pacl_node_q)); + + pacl_list->num++; + + break; + } + } + + DBG_88E("%s, acl_num =%d\n", __func__, pacl_list->num); + + _exit_critical_bh(&(pacl_node_q->lock), &irqL); + + return ret; +} + +int rtw_acl_remove_sta(struct adapter *padapter, u8 *addr) +{ + unsigned long irqL; + struct list_head *plist, *phead; + int ret = 0; + struct rtw_wlan_acl_node *paclnode; + struct sta_priv *pstapriv = &padapter->stapriv; + struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; + struct __queue *pacl_node_q = &pacl_list->acl_node_q; + + DBG_88E("%s(acl_num =%d) =%pM\n", __func__, pacl_list->num, (addr)); + + _enter_critical_bh(&(pacl_node_q->lock), &irqL); + + phead = get_list_head(pacl_node_q); + plist = get_next(phead); + + while (!rtw_end_of_queue_search(phead, plist)) { + paclnode = LIST_CONTAINOR(plist, struct rtw_wlan_acl_node, list); + plist = get_next(plist); + + if (_rtw_memcmp(paclnode->addr, addr, ETH_ALEN)) { + if (paclnode->valid) { + paclnode->valid = false; + + rtw_list_delete(&paclnode->list); + + pacl_list->num--; + } + } + } + + _exit_critical_bh(&(pacl_node_q->lock), &irqL); + + DBG_88E("%s, acl_num =%d\n", __func__, pacl_list->num); + return ret; +} + +static void update_bcn_fixed_ie(struct adapter *padapter) +{ + DBG_88E("%s\n", __func__); +} + +static void update_bcn_erpinfo_ie(struct adapter *padapter) +{ + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); + unsigned char *p, *ie = pnetwork->IEs; + u32 len = 0; + + DBG_88E("%s, ERP_enable =%d\n", __func__, pmlmeinfo->ERP_enable); + + if (!pmlmeinfo->ERP_enable) + return; + + /* parsing ERP_IE */ + p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _ERPINFO_IE_, &len, + (pnetwork->IELength - _BEACON_IE_OFFSET_)); + if (p && len > 0) { + struct ndis_802_11_var_ie *pIE = (struct ndis_802_11_var_ie *)p; + + if (pmlmepriv->num_sta_non_erp == 1) + pIE->data[0] |= RTW_ERP_INFO_NON_ERP_PRESENT|RTW_ERP_INFO_USE_PROTECTION; + else + pIE->data[0] &= ~(RTW_ERP_INFO_NON_ERP_PRESENT|RTW_ERP_INFO_USE_PROTECTION); + + if (pmlmepriv->num_sta_no_short_preamble > 0) + pIE->data[0] |= RTW_ERP_INFO_BARKER_PREAMBLE_MODE; + else + pIE->data[0] &= ~(RTW_ERP_INFO_BARKER_PREAMBLE_MODE); + + ERP_IE_handler(padapter, pIE); + } +} + +static void update_bcn_htcap_ie(struct adapter *padapter) +{ + DBG_88E("%s\n", __func__); +} + +static void update_bcn_htinfo_ie(struct adapter *padapter) +{ + DBG_88E("%s\n", __func__); +} + +static void update_bcn_rsn_ie(struct adapter *padapter) +{ + DBG_88E("%s\n", __func__); +} + +static void update_bcn_wpa_ie(struct adapter *padapter) +{ + DBG_88E("%s\n", __func__); +} + +static void update_bcn_wmm_ie(struct adapter *padapter) +{ + DBG_88E("%s\n", __func__); +} + +static void update_bcn_wps_ie(struct adapter *padapter) +{ + u8 *pwps_ie = NULL, *pwps_ie_src; + u8 *premainder_ie, *pbackup_remainder_ie = NULL; + uint wps_ielen = 0, wps_offset, remainder_ielen; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); + unsigned char *ie = pnetwork->IEs; + u32 ielen = pnetwork->IELength; + + DBG_88E("%s\n", __func__); + + pwps_ie = rtw_get_wps_ie(ie+_FIXED_IE_LENGTH_, ielen-_FIXED_IE_LENGTH_, NULL, &wps_ielen); + + if (pwps_ie == NULL || wps_ielen == 0) + return; + + wps_offset = (uint)(pwps_ie-ie); + + premainder_ie = pwps_ie + wps_ielen; + + remainder_ielen = ielen - wps_offset - wps_ielen; + + if (remainder_ielen > 0) { + pbackup_remainder_ie = rtw_malloc(remainder_ielen); + if (pbackup_remainder_ie) + memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen); + } + + pwps_ie_src = pmlmepriv->wps_beacon_ie; + if (pwps_ie_src == NULL) + return; + + wps_ielen = (uint)pwps_ie_src[1];/* to get ie data len */ + if ((wps_offset+wps_ielen+2+remainder_ielen) <= MAX_IE_SZ) { + memcpy(pwps_ie, pwps_ie_src, wps_ielen+2); + pwps_ie += (wps_ielen+2); + + if (pbackup_remainder_ie) + memcpy(pwps_ie, pbackup_remainder_ie, remainder_ielen); + + /* update IELength */ + pnetwork->IELength = wps_offset + (wps_ielen+2) + remainder_ielen; + } + + if (pbackup_remainder_ie) + kfree(pbackup_remainder_ie); +} + +static void update_bcn_p2p_ie(struct adapter *padapter) +{ +} + +static void update_bcn_vendor_spec_ie(struct adapter *padapter, u8 *oui) +{ + DBG_88E("%s\n", __func__); + + if (_rtw_memcmp(RTW_WPA_OUI, oui, 4)) + update_bcn_wpa_ie(padapter); + else if (_rtw_memcmp(WMM_OUI, oui, 4)) + update_bcn_wmm_ie(padapter); + else if (_rtw_memcmp(WPS_OUI, oui, 4)) + update_bcn_wps_ie(padapter); + else if (_rtw_memcmp(P2P_OUI, oui, 4)) + update_bcn_p2p_ie(padapter); + else + DBG_88E("unknown OUI type!\n"); +} + +void update_beacon(struct adapter *padapter, u8 ie_id, u8 *oui, u8 tx) +{ + unsigned long irqL; + struct mlme_priv *pmlmepriv; + struct mlme_ext_priv *pmlmeext; + + if (!padapter) + return; + + pmlmepriv = &(padapter->mlmepriv); + pmlmeext = &(padapter->mlmeextpriv); + + if (!pmlmeext->bstart_bss) + return; + + _enter_critical_bh(&pmlmepriv->bcn_update_lock, &irqL); + + switch (ie_id) { + case 0xFF: + update_bcn_fixed_ie(padapter);/* 8: TimeStamp, 2: Beacon Interval 2:Capability */ + break; + case _TIM_IE_: + update_BCNTIM(padapter); + break; + case _ERPINFO_IE_: + update_bcn_erpinfo_ie(padapter); + break; + case _HT_CAPABILITY_IE_: + update_bcn_htcap_ie(padapter); + break; + case _RSN_IE_2_: + update_bcn_rsn_ie(padapter); + break; + case _HT_ADD_INFO_IE_: + update_bcn_htinfo_ie(padapter); + break; + case _VENDOR_SPECIFIC_IE_: + update_bcn_vendor_spec_ie(padapter, oui); + break; + default: + break; + } + + pmlmepriv->update_bcn = true; + + _exit_critical_bh(&pmlmepriv->bcn_update_lock, &irqL); + + if (tx) + set_tx_beacon_cmd(padapter); +} + +/* +op_mode +Set to 0 (HT pure) under the followign conditions + - all STAs in the BSS are 20/40 MHz HT in 20/40 MHz BSS or + - all STAs in the BSS are 20 MHz HT in 20 MHz BSS +Set to 1 (HT non-member protection) if there may be non-HT STAs + in both the primary and the secondary channel +Set to 2 if only HT STAs are associated in BSS, + however and at least one 20 MHz HT STA is associated +Set to 3 (HT mixed mode) when one or more non-HT STAs are associated + (currently non-GF HT station is considered as non-HT STA also) +*/ +static int rtw_ht_operation_update(struct adapter *padapter) +{ + u16 cur_op_mode, new_op_mode; + int op_mode_changes = 0; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct ht_priv *phtpriv_ap = &pmlmepriv->htpriv; + + if (pmlmepriv->htpriv.ht_option) + return 0; + + DBG_88E("%s current operation mode = 0x%X\n", + __func__, pmlmepriv->ht_op_mode); + + if (!(pmlmepriv->ht_op_mode & HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT) && + pmlmepriv->num_sta_ht_no_gf) { + pmlmepriv->ht_op_mode |= + HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT; + op_mode_changes++; + } else if ((pmlmepriv->ht_op_mode & + HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT) && + pmlmepriv->num_sta_ht_no_gf == 0) { + pmlmepriv->ht_op_mode &= + ~HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT; + op_mode_changes++; + } + + if (!(pmlmepriv->ht_op_mode & HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT) && + (pmlmepriv->num_sta_no_ht || pmlmepriv->olbc_ht)) { + pmlmepriv->ht_op_mode |= HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT; + op_mode_changes++; + } else if ((pmlmepriv->ht_op_mode & + HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT) && + (pmlmepriv->num_sta_no_ht == 0 && !pmlmepriv->olbc_ht)) { + pmlmepriv->ht_op_mode &= + ~HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT; + op_mode_changes++; + } + + /* Note: currently we switch to the MIXED op mode if HT non-greenfield + * station is associated. Probably it's a theoretical case, since + * it looks like all known HT STAs support greenfield. + */ + new_op_mode = 0; + if (pmlmepriv->num_sta_no_ht || + (pmlmepriv->ht_op_mode & HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT)) + new_op_mode = OP_MODE_MIXED; + else if ((phtpriv_ap->ht_cap.cap_info & IEEE80211_HT_CAP_SUP_WIDTH) && + pmlmepriv->num_sta_ht_20mhz) + new_op_mode = OP_MODE_20MHZ_HT_STA_ASSOCED; + else if (pmlmepriv->olbc_ht) + new_op_mode = OP_MODE_MAY_BE_LEGACY_STAS; + else + new_op_mode = OP_MODE_PURE; + + cur_op_mode = pmlmepriv->ht_op_mode & HT_INFO_OPERATION_MODE_OP_MODE_MASK; + if (cur_op_mode != new_op_mode) { + pmlmepriv->ht_op_mode &= ~HT_INFO_OPERATION_MODE_OP_MODE_MASK; + pmlmepriv->ht_op_mode |= new_op_mode; + op_mode_changes++; + } + + DBG_88E("%s new operation mode = 0x%X changes =%d\n", + __func__, pmlmepriv->ht_op_mode, op_mode_changes); + + return op_mode_changes; +} + +void associated_clients_update(struct adapter *padapter, u8 updated) +{ + /* update associcated stations cap. */ + if (updated) { + unsigned long irqL; + struct list_head *phead, *plist; + struct sta_info *psta = NULL; + struct sta_priv *pstapriv = &padapter->stapriv; + + _enter_critical_bh(&pstapriv->asoc_list_lock, &irqL); + + phead = &pstapriv->asoc_list; + plist = get_next(phead); + + /* check asoc_queue */ + while ((rtw_end_of_queue_search(phead, plist)) == false) { + psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); + + plist = get_next(plist); + + VCS_update(padapter, psta); + } + _exit_critical_bh(&pstapriv->asoc_list_lock, &irqL); + } +} + +/* called > TSR LEVEL for USB or SDIO Interface*/ +void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta) +{ + u8 beacon_updated = false; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + + if (!(psta->flags & WLAN_STA_SHORT_PREAMBLE)) { + if (!psta->no_short_preamble_set) { + psta->no_short_preamble_set = 1; + + pmlmepriv->num_sta_no_short_preamble++; + + if ((pmlmeext->cur_wireless_mode > WIRELESS_11B) && + (pmlmepriv->num_sta_no_short_preamble == 1)) { + beacon_updated = true; + update_beacon(padapter, 0xFF, NULL, true); + } + } + } else { + if (psta->no_short_preamble_set) { + psta->no_short_preamble_set = 0; + + pmlmepriv->num_sta_no_short_preamble--; + + if ((pmlmeext->cur_wireless_mode > WIRELESS_11B) && + (pmlmepriv->num_sta_no_short_preamble == 0)) { + beacon_updated = true; + update_beacon(padapter, 0xFF, NULL, true); + } + } + } + + if (psta->flags & WLAN_STA_NONERP) { + if (!psta->nonerp_set) { + psta->nonerp_set = 1; + + pmlmepriv->num_sta_non_erp++; + + if (pmlmepriv->num_sta_non_erp == 1) { + beacon_updated = true; + update_beacon(padapter, _ERPINFO_IE_, NULL, true); + } + } + } else { + if (psta->nonerp_set) { + psta->nonerp_set = 0; + + pmlmepriv->num_sta_non_erp--; + + if (pmlmepriv->num_sta_non_erp == 0) { + beacon_updated = true; + update_beacon(padapter, _ERPINFO_IE_, NULL, true); + } + } + } + + if (!(psta->capability & WLAN_CAPABILITY_SHORT_SLOT)) { + if (!psta->no_short_slot_time_set) { + psta->no_short_slot_time_set = 1; + + pmlmepriv->num_sta_no_short_slot_time++; + + if ((pmlmeext->cur_wireless_mode > WIRELESS_11B) && + (pmlmepriv->num_sta_no_short_slot_time == 1)) { + beacon_updated = true; + update_beacon(padapter, 0xFF, NULL, true); + } + } + } else { + if (psta->no_short_slot_time_set) { + psta->no_short_slot_time_set = 0; + + pmlmepriv->num_sta_no_short_slot_time--; + + if ((pmlmeext->cur_wireless_mode > WIRELESS_11B) && + (pmlmepriv->num_sta_no_short_slot_time == 0)) { + beacon_updated = true; + update_beacon(padapter, 0xFF, NULL, true); + } + } + } + + if (psta->flags & WLAN_STA_HT) { + u16 ht_capab = psta->htpriv.ht_cap.cap_info; + + DBG_88E("HT: STA %pM HT Capabilities Info: 0x%04x\n", + (psta->hwaddr), ht_capab); + + if (psta->no_ht_set) { + psta->no_ht_set = 0; + pmlmepriv->num_sta_no_ht--; + } + + if ((ht_capab & IEEE80211_HT_CAP_GRN_FLD) == 0) { + if (!psta->no_ht_gf_set) { + psta->no_ht_gf_set = 1; + pmlmepriv->num_sta_ht_no_gf++; + } + DBG_88E("%s STA %pM - no greenfield, num of non-gf stations %d\n", + __func__, (psta->hwaddr), + pmlmepriv->num_sta_ht_no_gf); + } + + if ((ht_capab & IEEE80211_HT_CAP_SUP_WIDTH) == 0) { + if (!psta->ht_20mhz_set) { + psta->ht_20mhz_set = 1; + pmlmepriv->num_sta_ht_20mhz++; + } + DBG_88E("%s STA %pM - 20 MHz HT, num of 20MHz HT STAs %d\n", + __func__, (psta->hwaddr), + pmlmepriv->num_sta_ht_20mhz); + } + } else { + if (!psta->no_ht_set) { + psta->no_ht_set = 1; + pmlmepriv->num_sta_no_ht++; + } + if (pmlmepriv->htpriv.ht_option) { + DBG_88E("%s STA %pM - no HT, num of non-HT stations %d\n", + __func__, (psta->hwaddr), + pmlmepriv->num_sta_no_ht); + } + } + + if (rtw_ht_operation_update(padapter) > 0) { + update_beacon(padapter, _HT_CAPABILITY_IE_, NULL, false); + update_beacon(padapter, _HT_ADD_INFO_IE_, NULL, true); + } + + /* update associcated stations cap. */ + associated_clients_update(padapter, beacon_updated); + + DBG_88E("%s, updated =%d\n", __func__, beacon_updated); +} + +u8 bss_cap_update_on_sta_leave(struct adapter *padapter, struct sta_info *psta) +{ + u8 beacon_updated = false; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + + if (!psta) + return beacon_updated; + + if (psta->no_short_preamble_set) { + psta->no_short_preamble_set = 0; + pmlmepriv->num_sta_no_short_preamble--; + if (pmlmeext->cur_wireless_mode > WIRELESS_11B && + pmlmepriv->num_sta_no_short_preamble == 0) { + beacon_updated = true; + update_beacon(padapter, 0xFF, NULL, true); + } + } + + if (psta->nonerp_set) { + psta->nonerp_set = 0; + pmlmepriv->num_sta_non_erp--; + if (pmlmepriv->num_sta_non_erp == 0) { + beacon_updated = true; + update_beacon(padapter, _ERPINFO_IE_, NULL, true); + } + } + + if (psta->no_short_slot_time_set) { + psta->no_short_slot_time_set = 0; + pmlmepriv->num_sta_no_short_slot_time--; + if (pmlmeext->cur_wireless_mode > WIRELESS_11B && + pmlmepriv->num_sta_no_short_slot_time == 0) { + beacon_updated = true; + update_beacon(padapter, 0xFF, NULL, true); + } + } + + if (psta->no_ht_gf_set) { + psta->no_ht_gf_set = 0; + pmlmepriv->num_sta_ht_no_gf--; + } + + if (psta->no_ht_set) { + psta->no_ht_set = 0; + pmlmepriv->num_sta_no_ht--; + } + + if (psta->ht_20mhz_set) { + psta->ht_20mhz_set = 0; + pmlmepriv->num_sta_ht_20mhz--; + } + + if (rtw_ht_operation_update(padapter) > 0) { + update_beacon(padapter, _HT_CAPABILITY_IE_, NULL, false); + update_beacon(padapter, _HT_ADD_INFO_IE_, NULL, true); + } + + /* update associcated stations cap. */ + + DBG_88E("%s, updated =%d\n", __func__, beacon_updated); + + return beacon_updated; +} + +u8 ap_free_sta(struct adapter *padapter, struct sta_info *psta, + bool active, u16 reason) +{ + unsigned long irqL; + u8 beacon_updated = false; + struct sta_priv *pstapriv = &padapter->stapriv; + + if (!psta) + return beacon_updated; + + /* tear down Rx AMPDU */ + send_delba(padapter, 0, psta->hwaddr);/* recipient */ + + /* tear down TX AMPDU */ + send_delba(padapter, 1, psta->hwaddr);/* originator */ + psta->htpriv.agg_enable_bitmap = 0x0;/* reset */ + psta->htpriv.candidate_tid_bitmap = 0x0;/* reset */ + + if (active) + issue_deauth(padapter, psta->hwaddr, reason); + + /* clear cam entry / key */ + rtw_clearstakey_cmd(padapter, (u8 *)psta, (u8)(psta->mac_id + 3), true); + + + _enter_critical_bh(&psta->lock, &irqL); + psta->state &= ~_FW_LINKED; + _exit_critical_bh(&psta->lock, &irqL); + + rtw_indicate_sta_disassoc_event(padapter, psta); + + report_del_sta_event(padapter, psta->hwaddr, reason); + + beacon_updated = bss_cap_update_on_sta_leave(padapter, psta); + + _enter_critical_bh(&(pstapriv->sta_hash_lock), &irqL); + rtw_free_stainfo(padapter, psta); + _exit_critical_bh(&(pstapriv->sta_hash_lock), &irqL); + + return beacon_updated; +} + +int rtw_ap_inform_ch_switch(struct adapter *padapter, u8 new_ch, u8 ch_offset) +{ + unsigned long irqL; + struct list_head *phead, *plist; + int ret = 0; + struct sta_info *psta = NULL; + struct sta_priv *pstapriv = &padapter->stapriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + + if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) + return ret; + + DBG_88E(FUNC_NDEV_FMT" with ch:%u, offset:%u\n", + FUNC_NDEV_ARG(padapter->pnetdev), new_ch, ch_offset); + + _enter_critical_bh(&pstapriv->asoc_list_lock, &irqL); + phead = &pstapriv->asoc_list; + plist = get_next(phead); + + /* for each sta in asoc_queue */ + while (!rtw_end_of_queue_search(phead, plist)) { + psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); + plist = get_next(plist); + + issue_action_spct_ch_switch(padapter, psta->hwaddr, new_ch, ch_offset); + psta->expire_to = ((pstapriv->expire_to * 2) > 5) ? 5 : (pstapriv->expire_to * 2); + } + _exit_critical_bh(&pstapriv->asoc_list_lock, &irqL); + + issue_action_spct_ch_switch(padapter, bc_addr, new_ch, ch_offset); + + return ret; +} + +int rtw_sta_flush(struct adapter *padapter) +{ + unsigned long irqL; + struct list_head *phead, *plist; + int ret = 0; + struct sta_info *psta = NULL; + struct sta_priv *pstapriv = &padapter->stapriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + + DBG_88E(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(padapter->pnetdev)); + + if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) + return ret; + + _enter_critical_bh(&pstapriv->asoc_list_lock, &irqL); + phead = &pstapriv->asoc_list; + plist = get_next(phead); + + /* free sta asoc_queue */ + while ((rtw_end_of_queue_search(phead, plist)) == false) { + psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); + + plist = get_next(plist); + + rtw_list_delete(&psta->asoc_list); + pstapriv->asoc_list_cnt--; + + ap_free_sta(padapter, psta, true, WLAN_REASON_DEAUTH_LEAVING); + } + _exit_critical_bh(&pstapriv->asoc_list_lock, &irqL); + + + issue_deauth(padapter, bc_addr, WLAN_REASON_DEAUTH_LEAVING); + + associated_clients_update(padapter, true); + + return ret; +} + +/* called > TSR LEVEL for USB or SDIO Interface*/ +void sta_info_update(struct adapter *padapter, struct sta_info *psta) +{ + int flags = psta->flags; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + + /* update wmm cap. */ + if (WLAN_STA_WME&flags) + psta->qos_option = 1; + else + psta->qos_option = 0; + + if (pmlmepriv->qospriv.qos_option == 0) + psta->qos_option = 0; + + /* update 802.11n ht cap. */ + if (WLAN_STA_HT&flags) { + psta->htpriv.ht_option = true; + psta->qos_option = 1; + } else { + psta->htpriv.ht_option = false; + } + + if (!pmlmepriv->htpriv.ht_option) + psta->htpriv.ht_option = false; + + update_sta_info_apmode(padapter, psta); +} + +/* called >= TSR LEVEL for USB or SDIO Interface*/ +void ap_sta_info_defer_update(struct adapter *padapter, struct sta_info *psta) +{ + if (psta->state & _FW_LINKED) { + /* add ratid */ + add_RATid(padapter, psta, 0);/* DM_RATR_STA_INIT */ + } +} + +void start_ap_mode(struct adapter *padapter) +{ + int i; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct sta_priv *pstapriv = &padapter->stapriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; + + pmlmepriv->update_bcn = false; + + pmlmeext->bstart_bss = false; + + pmlmepriv->num_sta_non_erp = 0; + + pmlmepriv->num_sta_no_short_slot_time = 0; + + pmlmepriv->num_sta_no_short_preamble = 0; + + pmlmepriv->num_sta_ht_no_gf = 0; + pmlmepriv->num_sta_no_ht = 0; + pmlmepriv->num_sta_ht_20mhz = 0; + + pmlmepriv->olbc = false; + + pmlmepriv->olbc_ht = false; + + pmlmepriv->ht_op_mode = 0; + + for (i = 0; i < NUM_STA; i++) + pstapriv->sta_aid[i] = NULL; + + pmlmepriv->wps_beacon_ie = NULL; + pmlmepriv->wps_probe_resp_ie = NULL; + pmlmepriv->wps_assoc_resp_ie = NULL; + + pmlmepriv->p2p_beacon_ie = NULL; + pmlmepriv->p2p_probe_resp_ie = NULL; + + /* for ACL */ + _rtw_init_listhead(&(pacl_list->acl_node_q.queue)); + pacl_list->num = 0; + pacl_list->mode = 0; + for (i = 0; i < NUM_ACL; i++) { + _rtw_init_listhead(&pacl_list->aclnode[i].list); + pacl_list->aclnode[i].valid = false; + } +} + +void stop_ap_mode(struct adapter *padapter) +{ + unsigned long irqL; + struct list_head *phead, *plist; + struct rtw_wlan_acl_node *paclnode; + struct sta_info *psta = NULL; + struct sta_priv *pstapriv = &padapter->stapriv; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; + struct __queue *pacl_node_q = &pacl_list->acl_node_q; + + pmlmepriv->update_bcn = false; + pmlmeext->bstart_bss = false; + + /* reset and init security priv , this can refine with rtw_reset_securitypriv */ + _rtw_memset((unsigned char *)&padapter->securitypriv, 0, sizeof(struct security_priv)); + padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen; + padapter->securitypriv.ndisencryptstatus = Ndis802_11WEPDisabled; + + /* for ACL */ + _enter_critical_bh(&(pacl_node_q->lock), &irqL); + phead = get_list_head(pacl_node_q); + plist = get_next(phead); + while ((rtw_end_of_queue_search(phead, plist)) == false) { + paclnode = LIST_CONTAINOR(plist, struct rtw_wlan_acl_node, list); + plist = get_next(plist); + + if (paclnode->valid) { + paclnode->valid = false; + + rtw_list_delete(&paclnode->list); + + pacl_list->num--; + } + } + _exit_critical_bh(&(pacl_node_q->lock), &irqL); + + DBG_88E("%s, free acl_node_queue, num =%d\n", __func__, pacl_list->num); + + rtw_sta_flush(padapter); + + /* free_assoc_sta_resources */ + rtw_free_all_stainfo(padapter); + + psta = rtw_get_bcmc_stainfo(padapter); + _enter_critical_bh(&(pstapriv->sta_hash_lock), &irqL); + rtw_free_stainfo(padapter, psta); + _exit_critical_bh(&(pstapriv->sta_hash_lock), &irqL); + + rtw_init_bcmc_stainfo(padapter); + + rtw_free_mlme_priv_ie_data(pmlmepriv); +} + +#endif /* CONFIG_88EU_AP_MODE */ diff --git a/drivers/staging/rtl8188eu/core/rtw_br_ext.c b/drivers/staging/rtl8188eu/core/rtw_br_ext.c new file mode 100644 index 0000000000000..fbca394cf4fcd --- /dev/null +++ b/drivers/staging/rtl8188eu/core/rtw_br_ext.c @@ -0,0 +1,1199 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTW_BR_EXT_C_ + +#include +#include +#include +#include +#include +#include + +#include +#include "rtw_br_ext.h" +#include +#include + +#ifndef csum_ipv6_magic +#include +#endif + +#include +#include +#include +#include + +#define NAT25_IPV4 01 +#define NAT25_IPV6 02 +#define NAT25_IPX 03 +#define NAT25_APPLE 04 +#define NAT25_PPPOE 05 + +#define RTL_RELAY_TAG_LEN (ETH_ALEN) +#define TAG_HDR_LEN 4 + +#define MAGIC_CODE 0x8186 +#define MAGIC_CODE_LEN 2 +#define WAIT_TIME_PPPOE 5 /* waiting time for pppoe server in sec */ + +/*----------------------------------------------------------------- + How database records network address: + 0 1 2 3 4 5 6 7 8 9 10 + |----|----|----|----|----|----|----|----|----|----|----| + IPv4 |type| | IP addr | + IPX |type| Net addr | Node addr | + IPX |type| Net addr |Sckt addr| + Apple |type| Network |node| + PPPoE |type| SID | AC MAC | +-----------------------------------------------------------------*/ + + +/* Find a tag in pppoe frame and return the pointer */ +static inline unsigned char *__nat25_find_pppoe_tag(struct pppoe_hdr *ph, unsigned short type) +{ + unsigned char *cur_ptr, *start_ptr; + unsigned short tagLen, tagType; + + start_ptr = cur_ptr = (unsigned char *)ph->tag; + while ((cur_ptr - start_ptr) < ntohs(ph->length)) { + /* prevent un-alignment access */ + tagType = (unsigned short)((cur_ptr[0] << 8) + cur_ptr[1]); + tagLen = (unsigned short)((cur_ptr[2] << 8) + cur_ptr[3]); + if (tagType == type) + return cur_ptr; + cur_ptr = cur_ptr + TAG_HDR_LEN + tagLen; + } + return NULL; +} + + +static inline int __nat25_add_pppoe_tag(struct sk_buff *skb, struct pppoe_tag *tag) +{ + struct pppoe_hdr *ph = (struct pppoe_hdr *)(skb->data + ETH_HLEN); + int data_len; + + data_len = tag->tag_len + TAG_HDR_LEN; + if (skb_tailroom(skb) < data_len) { + _DEBUG_ERR("skb_tailroom() failed in add SID tag!\n"); + return -1; + } + + skb_put(skb, data_len); + /* have a room for new tag */ + memmove(((unsigned char *)ph->tag + data_len), (unsigned char *)ph->tag, ntohs(ph->length)); + ph->length = htons(ntohs(ph->length) + data_len); + memcpy((unsigned char *)ph->tag, tag, data_len); + return data_len; +} + +static int skb_pull_and_merge(struct sk_buff *skb, unsigned char *src, int len) +{ + int tail_len; + unsigned long end, tail; + + if ((src+len) > skb_tail_pointer(skb) || skb->len < len) + return -1; + + tail = (unsigned long)skb_tail_pointer(skb); + end = (unsigned long)src+len; + if (tail < end) + return -1; + + tail_len = (int)(tail-end); + if (tail_len > 0) + memmove(src, src+len, tail_len); + + skb_trim(skb, skb->len-len); + return 0; +} + +static inline unsigned long __nat25_timeout(struct adapter *priv) +{ + unsigned long timeout; + + timeout = jiffies - NAT25_AGEING_TIME*HZ; + + return timeout; +} + + +static inline int __nat25_has_expired(struct adapter *priv, + struct nat25_network_db_entry *fdb) +{ + if (time_before_eq(fdb->ageing_timer, __nat25_timeout(priv))) + return 1; + + return 0; +} + + +static inline void __nat25_generate_ipv4_network_addr(unsigned char *networkAddr, + unsigned int *ipAddr) +{ + memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); + + networkAddr[0] = NAT25_IPV4; + memcpy(networkAddr+7, (unsigned char *)ipAddr, 4); +} + + +static inline void __nat25_generate_ipx_network_addr_with_node(unsigned char *networkAddr, + unsigned int *ipxNetAddr, unsigned char *ipxNodeAddr) +{ + memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); + + networkAddr[0] = NAT25_IPX; + memcpy(networkAddr+1, (unsigned char *)ipxNetAddr, 4); + memcpy(networkAddr+5, ipxNodeAddr, 6); +} + + +static inline void __nat25_generate_ipx_network_addr_with_socket(unsigned char *networkAddr, + unsigned int *ipxNetAddr, unsigned short *ipxSocketAddr) +{ + memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); + + networkAddr[0] = NAT25_IPX; + memcpy(networkAddr+1, (unsigned char *)ipxNetAddr, 4); + memcpy(networkAddr+5, (unsigned char *)ipxSocketAddr, 2); +} + + +static inline void __nat25_generate_apple_network_addr(unsigned char *networkAddr, + unsigned short *network, unsigned char *node) +{ + memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); + + networkAddr[0] = NAT25_APPLE; + memcpy(networkAddr+1, (unsigned char *)network, 2); + networkAddr[3] = *node; +} + +static inline void __nat25_generate_pppoe_network_addr(unsigned char *networkAddr, + unsigned char *ac_mac, unsigned short *sid) +{ + memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); + + networkAddr[0] = NAT25_PPPOE; + memcpy(networkAddr+1, (unsigned char *)sid, 2); + memcpy(networkAddr+3, (unsigned char *)ac_mac, 6); +} + +static void __nat25_generate_ipv6_network_addr(unsigned char *networkAddr, + unsigned int *ipAddr) +{ + memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); + + networkAddr[0] = NAT25_IPV6; + memcpy(networkAddr+1, (unsigned char *)ipAddr, 16); +} + +static unsigned char *scan_tlv(unsigned char *data, int len, unsigned char tag, unsigned char len8b) +{ + while (len > 0) { + if (*data == tag && *(data+1) == len8b && len >= len8b*8) + return data+2; + + len -= (*(data+1))*8; + data += (*(data+1))*8; + } + return NULL; +} + +static int update_nd_link_layer_addr(unsigned char *data, int len, unsigned char *replace_mac) +{ + struct icmp6hdr *icmphdr = (struct icmp6hdr *)data; + unsigned char *mac; + + if (icmphdr->icmp6_type == NDISC_ROUTER_SOLICITATION) { + if (len >= 8) { + mac = scan_tlv(&data[8], len-8, 1, 1); + if (mac) { + _DEBUG_INFO("Router Solicitation, replace MAC From: %02x:%02x:%02x:%02x:%02x:%02x, To: %02x:%02x:%02x:%02x:%02x:%02x\n", + mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], + replace_mac[0], replace_mac[1], replace_mac[2], replace_mac[3], replace_mac[4], replace_mac[5]); + memcpy(mac, replace_mac, 6); + return 1; + } + } + } else if (icmphdr->icmp6_type == NDISC_ROUTER_ADVERTISEMENT) { + if (len >= 16) { + mac = scan_tlv(&data[16], len-16, 1, 1); + if (mac) { + _DEBUG_INFO("Router Advertisement, replace MAC From: %02x:%02x:%02x:%02x:%02x:%02x, To: %02x:%02x:%02x:%02x:%02x:%02x\n", + mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], + replace_mac[0], replace_mac[1], replace_mac[2], replace_mac[3], replace_mac[4], replace_mac[5]); + memcpy(mac, replace_mac, 6); + return 1; + } + } + } else if (icmphdr->icmp6_type == NDISC_NEIGHBOUR_SOLICITATION) { + if (len >= 24) { + mac = scan_tlv(&data[24], len-24, 1, 1); + if (mac) { + _DEBUG_INFO("Neighbor Solicitation, replace MAC From: %02x:%02x:%02x:%02x:%02x:%02x, To: %02x:%02x:%02x:%02x:%02x:%02x\n", + mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], + replace_mac[0], replace_mac[1], replace_mac[2], replace_mac[3], replace_mac[4], replace_mac[5]); + memcpy(mac, replace_mac, 6); + return 1; + } + } + } else if (icmphdr->icmp6_type == NDISC_NEIGHBOUR_ADVERTISEMENT) { + if (len >= 24) { + mac = scan_tlv(&data[24], len-24, 2, 1); + if (mac) { + _DEBUG_INFO("Neighbor Advertisement, replace MAC From: %02x:%02x:%02x:%02x:%02x:%02x, To: %02x:%02x:%02x:%02x:%02x:%02x\n", + mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], + replace_mac[0], replace_mac[1], replace_mac[2], replace_mac[3], replace_mac[4], replace_mac[5]); + memcpy(mac, replace_mac, 6); + return 1; + } + } + } else if (icmphdr->icmp6_type == NDISC_REDIRECT) { + if (len >= 40) { + mac = scan_tlv(&data[40], len-40, 2, 1); + if (mac) { + _DEBUG_INFO("Redirect, replace MAC From: %02x:%02x:%02x:%02x:%02x:%02x, To: %02x:%02x:%02x:%02x:%02x:%02x\n", + mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], + replace_mac[0], replace_mac[1], replace_mac[2], replace_mac[3], replace_mac[4], replace_mac[5]); + memcpy(mac, replace_mac, 6); + return 1; + } + } + } + return 0; +} + +static inline int __nat25_network_hash(unsigned char *networkAddr) +{ + if (networkAddr[0] == NAT25_IPV4) { + unsigned long x; + + x = networkAddr[7] ^ networkAddr[8] ^ networkAddr[9] ^ networkAddr[10]; + + return x & (NAT25_HASH_SIZE - 1); + } else if (networkAddr[0] == NAT25_IPX) { + unsigned long x; + + x = networkAddr[1] ^ networkAddr[2] ^ networkAddr[3] ^ networkAddr[4] ^ networkAddr[5] ^ + networkAddr[6] ^ networkAddr[7] ^ networkAddr[8] ^ networkAddr[9] ^ networkAddr[10]; + + return x & (NAT25_HASH_SIZE - 1); + } else if (networkAddr[0] == NAT25_APPLE) { + unsigned long x; + + x = networkAddr[1] ^ networkAddr[2] ^ networkAddr[3]; + + return x & (NAT25_HASH_SIZE - 1); + } else if (networkAddr[0] == NAT25_PPPOE) { + unsigned long x; + + x = networkAddr[0] ^ networkAddr[1] ^ networkAddr[2] ^ networkAddr[3] ^ networkAddr[4] ^ networkAddr[5] ^ networkAddr[6] ^ networkAddr[7] ^ networkAddr[8]; + + return x & (NAT25_HASH_SIZE - 1); + } else if (networkAddr[0] == NAT25_IPV6) { + unsigned long x; + + x = networkAddr[1] ^ networkAddr[2] ^ networkAddr[3] ^ networkAddr[4] ^ networkAddr[5] ^ + networkAddr[6] ^ networkAddr[7] ^ networkAddr[8] ^ networkAddr[9] ^ networkAddr[10] ^ + networkAddr[11] ^ networkAddr[12] ^ networkAddr[13] ^ networkAddr[14] ^ networkAddr[15] ^ + networkAddr[16]; + + return x & (NAT25_HASH_SIZE - 1); + } else { + unsigned long x = 0; + int i; + + for (i = 0; i < MAX_NETWORK_ADDR_LEN; i++) + x ^= networkAddr[i]; + + return x & (NAT25_HASH_SIZE - 1); + } +} + +static inline void __network_hash_link(struct adapter *priv, + struct nat25_network_db_entry *ent, int hash) +{ + /* Caller must _enter_critical_bh already! */ + ent->next_hash = priv->nethash[hash]; + if (ent->next_hash != NULL) + ent->next_hash->pprev_hash = &ent->next_hash; + priv->nethash[hash] = ent; + ent->pprev_hash = &priv->nethash[hash]; +} + +static inline void __network_hash_unlink(struct nat25_network_db_entry *ent) +{ + /* Caller must _enter_critical_bh already! */ + *(ent->pprev_hash) = ent->next_hash; + if (ent->next_hash != NULL) + ent->next_hash->pprev_hash = ent->pprev_hash; + ent->next_hash = NULL; + ent->pprev_hash = NULL; +} + +static int __nat25_db_network_lookup_and_replace(struct adapter *priv, + struct sk_buff *skb, unsigned char *networkAddr) +{ + struct nat25_network_db_entry *db; + unsigned long irqL; + _enter_critical_bh(&priv->br_ext_lock, &irqL); + + db = priv->nethash[__nat25_network_hash(networkAddr)]; + while (db != NULL) { + if (!memcmp(db->networkAddr, networkAddr, MAX_NETWORK_ADDR_LEN)) { + if (!__nat25_has_expired(priv, db)) { + /* replace the destination mac address */ + memcpy(skb->data, db->macAddr, ETH_ALEN); + atomic_inc(&db->use_count); + + DEBUG_INFO("NAT25: Lookup M:%02x%02x%02x%02x%02x%02x N:%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x" + "%02x%02x%02x%02x%02x%02x\n", + db->macAddr[0], + db->macAddr[1], + db->macAddr[2], + db->macAddr[3], + db->macAddr[4], + db->macAddr[5], + db->networkAddr[0], + db->networkAddr[1], + db->networkAddr[2], + db->networkAddr[3], + db->networkAddr[4], + db->networkAddr[5], + db->networkAddr[6], + db->networkAddr[7], + db->networkAddr[8], + db->networkAddr[9], + db->networkAddr[10], + db->networkAddr[11], + db->networkAddr[12], + db->networkAddr[13], + db->networkAddr[14], + db->networkAddr[15], + db->networkAddr[16]); + } + _exit_critical_bh(&priv->br_ext_lock, &irqL); + return 1; + } + db = db->next_hash; + } + _exit_critical_bh(&priv->br_ext_lock, &irqL); + return 0; +} + +static void __nat25_db_network_insert(struct adapter *priv, + unsigned char *macAddr, unsigned char *networkAddr) +{ + struct nat25_network_db_entry *db; + int hash; + unsigned long irqL; + + _enter_critical_bh(&priv->br_ext_lock, &irqL); + hash = __nat25_network_hash(networkAddr); + db = priv->nethash[hash]; + while (db != NULL) { + if (!memcmp(db->networkAddr, networkAddr, MAX_NETWORK_ADDR_LEN)) { + memcpy(db->macAddr, macAddr, ETH_ALEN); + db->ageing_timer = jiffies; + _exit_critical_bh(&priv->br_ext_lock, &irqL); + return; + } + db = db->next_hash; + } + db = (struct nat25_network_db_entry *) rtw_malloc(sizeof(*db)); + if (db == NULL) { + _exit_critical_bh(&priv->br_ext_lock, &irqL); + return; + } + memcpy(db->networkAddr, networkAddr, MAX_NETWORK_ADDR_LEN); + memcpy(db->macAddr, macAddr, ETH_ALEN); + atomic_set(&db->use_count, 1); + db->ageing_timer = jiffies; + + __network_hash_link(priv, db, hash); + + _exit_critical_bh(&priv->br_ext_lock, &irqL); +} + +static void __nat25_db_print(struct adapter *priv) +{ +} + +/* + * NAT2.5 interface + */ + +void nat25_db_cleanup(struct adapter *priv) +{ + int i; + unsigned long irqL; + _enter_critical_bh(&priv->br_ext_lock, &irqL); + + for (i = 0; i < NAT25_HASH_SIZE; i++) { + struct nat25_network_db_entry *f; + f = priv->nethash[i]; + while (f != NULL) { + struct nat25_network_db_entry *g; + + g = f->next_hash; + if (priv->scdb_entry == f) { + memset(priv->scdb_mac, 0, ETH_ALEN); + memset(priv->scdb_ip, 0, 4); + priv->scdb_entry = NULL; + } + __network_hash_unlink(f); + kfree(f); + f = g; + } + } + _exit_critical_bh(&priv->br_ext_lock, &irqL); +} + +void nat25_db_expire(struct adapter *priv) +{ + int i; + unsigned long irqL; + _enter_critical_bh(&priv->br_ext_lock, &irqL); + + for (i = 0; i < NAT25_HASH_SIZE; i++) { + struct nat25_network_db_entry *f; + f = priv->nethash[i]; + + while (f != NULL) { + struct nat25_network_db_entry *g; + g = f->next_hash; + + if (__nat25_has_expired(priv, f)) { + if (atomic_dec_and_test(&f->use_count)) { + if (priv->scdb_entry == f) { + memset(priv->scdb_mac, 0, ETH_ALEN); + memset(priv->scdb_ip, 0, 4); + priv->scdb_entry = NULL; + } + __network_hash_unlink(f); + kfree(f); + } + } + f = g; + } + } + _exit_critical_bh(&priv->br_ext_lock, &irqL); +} + +int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method) +{ + unsigned short protocol; + unsigned char networkAddr[MAX_NETWORK_ADDR_LEN]; + unsigned int tmp; + + if (skb == NULL) + return -1; + + if ((method <= NAT25_MIN) || (method >= NAT25_MAX)) + return -1; + + protocol = be16_to_cpu(*((__be16 *)(skb->data + 2 * ETH_ALEN))); + + /*---------------------------------------------------*/ + /* Handle IP frame */ + /*---------------------------------------------------*/ + if (protocol == ETH_P_IP) { + struct iphdr *iph = (struct iphdr *)(skb->data + ETH_HLEN); + + if (((unsigned char *)(iph) + (iph->ihl<<2)) >= (skb->data + ETH_HLEN + skb->len)) { + DEBUG_WARN("NAT25: malformed IP packet !\n"); + return -1; + } + + switch (method) { + case NAT25_CHECK: + return -1; + case NAT25_INSERT: + /* some muticast with source IP is all zero, maybe other case is illegal */ + /* in class A, B, C, host address is all zero or all one is illegal */ + if (iph->saddr == 0) + return 0; + tmp = be32_to_cpu(iph->saddr); + DEBUG_INFO("NAT25: Insert IP, SA =%08x, DA =%08x\n", tmp, iph->daddr); + __nat25_generate_ipv4_network_addr(networkAddr, &tmp); + /* record source IP address and , source mac address into db */ + __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr); + + __nat25_db_print(priv); + return 0; + case NAT25_LOOKUP: + DEBUG_INFO("NAT25: Lookup IP, SA =%08x, DA =%08x\n", iph->saddr, iph->daddr); + tmp = be32_to_cpu(iph->daddr); + __nat25_generate_ipv4_network_addr(networkAddr, &tmp); + + if (!__nat25_db_network_lookup_and_replace(priv, skb, networkAddr)) { + if (*((unsigned char *)&iph->daddr + 3) == 0xff) { + /* L2 is unicast but L3 is broadcast, make L2 bacome broadcast */ + DEBUG_INFO("NAT25: Set DA as boardcast\n"); + memset(skb->data, 0xff, ETH_ALEN); + } else { + /* forward unknow IP packet to upper TCP/IP */ + DEBUG_INFO("NAT25: Replace DA with BR's MAC\n"); + if ((*(u32 *)priv->br_mac) == 0 && (*(u16 *)(priv->br_mac+4)) == 0) { + printk("Re-init netdev_br_init() due to br_mac == 0!\n"); + netdev_br_init(priv->pnetdev); + } + memcpy(skb->data, priv->br_mac, ETH_ALEN); + } + } + return 0; + default: + return -1; + } + } else if (protocol == ETH_P_ARP) { + /*---------------------------------------------------*/ + /* Handle ARP frame */ + /*---------------------------------------------------*/ + struct arphdr *arp = (struct arphdr *)(skb->data + ETH_HLEN); + unsigned char *arp_ptr = (unsigned char *)(arp + 1); + unsigned int *sender, *target; + + if (arp->ar_pro != __constant_htons(ETH_P_IP)) { + DEBUG_WARN("NAT25: arp protocol unknown (%4x)!\n", be16_to_cpu(arp->ar_pro)); + return -1; + } + + switch (method) { + case NAT25_CHECK: + return 0; /* skb_copy for all ARP frame */ + case NAT25_INSERT: + DEBUG_INFO("NAT25: Insert ARP, MAC =%02x%02x%02x%02x%02x%02x\n", arp_ptr[0], + arp_ptr[1], arp_ptr[2], arp_ptr[3], arp_ptr[4], arp_ptr[5]); + + /* change to ARP sender mac address to wlan STA address */ + memcpy(arp_ptr, GET_MY_HWADDR(priv), ETH_ALEN); + arp_ptr += arp->ar_hln; + sender = (unsigned int *)arp_ptr; + __nat25_generate_ipv4_network_addr(networkAddr, sender); + __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr); + __nat25_db_print(priv); + return 0; + case NAT25_LOOKUP: + DEBUG_INFO("NAT25: Lookup ARP\n"); + + arp_ptr += arp->ar_hln; + sender = (unsigned int *)arp_ptr; + arp_ptr += (arp->ar_hln + arp->ar_pln); + target = (unsigned int *)arp_ptr; + __nat25_generate_ipv4_network_addr(networkAddr, target); + __nat25_db_network_lookup_and_replace(priv, skb, networkAddr); + /* change to ARP target mac address to Lookup result */ + arp_ptr = (unsigned char *)(arp + 1); + arp_ptr += (arp->ar_hln + arp->ar_pln); + memcpy(arp_ptr, skb->data, ETH_ALEN); + return 0; + default: + return -1; + } + } else if ((protocol == ETH_P_IPX) || + (protocol <= ETH_FRAME_LEN)) { + /*---------------------------------------------------*/ + /* Handle IPX and Apple Talk frame */ + /*---------------------------------------------------*/ + unsigned char ipx_header[2] = {0xFF, 0xFF}; + struct ipxhdr *ipx = NULL; + struct elapaarp *ea = NULL; + struct ddpehdr *ddp = NULL; + unsigned char *framePtr = skb->data + ETH_HLEN; + + if (protocol == ETH_P_IPX) { + DEBUG_INFO("NAT25: Protocol = IPX (Ethernet II)\n"); + ipx = (struct ipxhdr *)framePtr; + } else if (protocol <= ETH_FRAME_LEN) { + if (!memcmp(ipx_header, framePtr, 2)) { + DEBUG_INFO("NAT25: Protocol = IPX (Ethernet 802.3)\n"); + ipx = (struct ipxhdr *)framePtr; + } else { + unsigned char ipx_8022_type = 0xE0; + unsigned char snap_8022_type = 0xAA; + + if (*framePtr == snap_8022_type) { + unsigned char ipx_snap_id[5] = {0x0, 0x0, 0x0, 0x81, 0x37}; /* IPX SNAP ID */ + unsigned char aarp_snap_id[5] = {0x00, 0x00, 0x00, 0x80, 0xF3}; /* Apple Talk AARP SNAP ID */ + unsigned char ddp_snap_id[5] = {0x08, 0x00, 0x07, 0x80, 0x9B}; /* Apple Talk DDP SNAP ID */ + + framePtr += 3; /* eliminate the 802.2 header */ + + if (!memcmp(ipx_snap_id, framePtr, 5)) { + framePtr += 5; /* eliminate the SNAP header */ + + DEBUG_INFO("NAT25: Protocol = IPX (Ethernet SNAP)\n"); + ipx = (struct ipxhdr *)framePtr; + } else if (!memcmp(aarp_snap_id, framePtr, 5)) { + framePtr += 5; /* eliminate the SNAP header */ + + ea = (struct elapaarp *)framePtr; + } else if (!memcmp(ddp_snap_id, framePtr, 5)) { + framePtr += 5; /* eliminate the SNAP header */ + + ddp = (struct ddpehdr *)framePtr; + } else { + DEBUG_WARN("NAT25: Protocol = Ethernet SNAP %02x%02x%02x%02x%02x\n", framePtr[0], + framePtr[1], framePtr[2], framePtr[3], framePtr[4]); + return -1; + } + } else if (*framePtr == ipx_8022_type) { + framePtr += 3; /* eliminate the 802.2 header */ + + if (!memcmp(ipx_header, framePtr, 2)) { + DEBUG_INFO("NAT25: Protocol = IPX (Ethernet 802.2)\n"); + ipx = (struct ipxhdr *)framePtr; + } else { + return -1; + } + } else { + return -1; + } + } + } else { + return -1; + } + + /* IPX */ + if (ipx != NULL) { + switch (method) { + case NAT25_CHECK: + if (!memcmp(skb->data+ETH_ALEN, ipx->ipx_source.node, ETH_ALEN)) + DEBUG_INFO("NAT25: Check IPX skb_copy\n"); + return 0; + return -1; + case NAT25_INSERT: + DEBUG_INFO("NAT25: Insert IPX, Dest =%08x,%02x%02x%02x%02x%02x%02x,%04x Source =%08x,%02x%02x%02x%02x%02x%02x,%04x\n", + ipx->ipx_dest.net, + ipx->ipx_dest.node[0], + ipx->ipx_dest.node[1], + ipx->ipx_dest.node[2], + ipx->ipx_dest.node[3], + ipx->ipx_dest.node[4], + ipx->ipx_dest.node[5], + ipx->ipx_dest.sock, + ipx->ipx_source.net, + ipx->ipx_source.node[0], + ipx->ipx_source.node[1], + ipx->ipx_source.node[2], + ipx->ipx_source.node[3], + ipx->ipx_source.node[4], + ipx->ipx_source.node[5], + ipx->ipx_source.sock); + + if (!memcmp(skb->data+ETH_ALEN, ipx->ipx_source.node, ETH_ALEN)) { + DEBUG_INFO("NAT25: Use IPX Net, and Socket as network addr\n"); + + __nat25_generate_ipx_network_addr_with_socket(networkAddr, &ipx->ipx_source.net, &ipx->ipx_source.sock); + + /* change IPX source node addr to wlan STA address */ + memcpy(ipx->ipx_source.node, GET_MY_HWADDR(priv), ETH_ALEN); + } else { + __nat25_generate_ipx_network_addr_with_node(networkAddr, &ipx->ipx_source.net, ipx->ipx_source.node); + } + __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr); + __nat25_db_print(priv); + return 0; + case NAT25_LOOKUP: + if (!memcmp(GET_MY_HWADDR(priv), ipx->ipx_dest.node, ETH_ALEN)) { + DEBUG_INFO("NAT25: Lookup IPX, Modify Destination IPX Node addr\n"); + + __nat25_generate_ipx_network_addr_with_socket(networkAddr, &ipx->ipx_dest.net, &ipx->ipx_dest.sock); + + __nat25_db_network_lookup_and_replace(priv, skb, networkAddr); + + /* replace IPX destination node addr with Lookup destination MAC addr */ + memcpy(ipx->ipx_dest.node, skb->data, ETH_ALEN); + } else { + __nat25_generate_ipx_network_addr_with_node(networkAddr, &ipx->ipx_dest.net, ipx->ipx_dest.node); + + __nat25_db_network_lookup_and_replace(priv, skb, networkAddr); + } + return 0; + default: + return -1; + } + } else if (ea != NULL) { + /* Sanity check fields. */ + if (ea->hw_len != ETH_ALEN || ea->pa_len != AARP_PA_ALEN) { + DEBUG_WARN("NAT25: Appletalk AARP Sanity check fail!\n"); + return -1; + } + + switch (method) { + case NAT25_CHECK: + return 0; + case NAT25_INSERT: + /* change to AARP source mac address to wlan STA address */ + memcpy(ea->hw_src, GET_MY_HWADDR(priv), ETH_ALEN); + + DEBUG_INFO("NAT25: Insert AARP, Source =%d,%d Destination =%d,%d\n", + ea->pa_src_net, + ea->pa_src_node, + ea->pa_dst_net, + ea->pa_dst_node); + + __nat25_generate_apple_network_addr(networkAddr, &ea->pa_src_net, &ea->pa_src_node); + + __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr); + + __nat25_db_print(priv); + return 0; + case NAT25_LOOKUP: + DEBUG_INFO("NAT25: Lookup AARP, Source =%d,%d Destination =%d,%d\n", + ea->pa_src_net, + ea->pa_src_node, + ea->pa_dst_net, + ea->pa_dst_node); + + __nat25_generate_apple_network_addr(networkAddr, &ea->pa_dst_net, &ea->pa_dst_node); + + __nat25_db_network_lookup_and_replace(priv, skb, networkAddr); + + /* change to AARP destination mac address to Lookup result */ + memcpy(ea->hw_dst, skb->data, ETH_ALEN); + return 0; + default: + return -1; + } + } else if (ddp != NULL) { + switch (method) { + case NAT25_CHECK: + return -1; + case NAT25_INSERT: + DEBUG_INFO("NAT25: Insert DDP, Source =%d,%d Destination =%d,%d\n", + ddp->deh_snet, + ddp->deh_snode, + ddp->deh_dnet, + ddp->deh_dnode); + + __nat25_generate_apple_network_addr(networkAddr, &ddp->deh_snet, &ddp->deh_snode); + + __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr); + + __nat25_db_print(priv); + return 0; + case NAT25_LOOKUP: + DEBUG_INFO("NAT25: Lookup DDP, Source =%d,%d Destination =%d,%d\n", + ddp->deh_snet, + ddp->deh_snode, + ddp->deh_dnet, + ddp->deh_dnode); + __nat25_generate_apple_network_addr(networkAddr, &ddp->deh_dnet, &ddp->deh_dnode); + __nat25_db_network_lookup_and_replace(priv, skb, networkAddr); + return 0; + default: + return -1; + } + } + + return -1; + } else if ((protocol == ETH_P_PPP_DISC) || + (protocol == ETH_P_PPP_SES)) { + /*---------------------------------------------------*/ + /* Handle PPPoE frame */ + /*---------------------------------------------------*/ + struct pppoe_hdr *ph = (struct pppoe_hdr *)(skb->data + ETH_HLEN); + unsigned short *pMagic; + + switch (method) { + case NAT25_CHECK: + if (ph->sid == 0) + return 0; + return 1; + case NAT25_INSERT: + if (ph->sid == 0) { /* Discovery phase according to tag */ + if (ph->code == PADI_CODE || ph->code == PADR_CODE) { + if (priv->ethBrExtInfo.addPPPoETag) { + struct pppoe_tag *tag, *pOldTag; + unsigned char tag_buf[40]; + int old_tag_len = 0; + + tag = (struct pppoe_tag *)tag_buf; + pOldTag = (struct pppoe_tag *)__nat25_find_pppoe_tag(ph, ntohs(PTT_RELAY_SID)); + if (pOldTag) { /* if SID existed, copy old value and delete it */ + old_tag_len = ntohs(pOldTag->tag_len); + if (old_tag_len+TAG_HDR_LEN+MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN > sizeof(tag_buf)) { + DEBUG_ERR("SID tag length too long!\n"); + return -1; + } + + memcpy(tag->tag_data+MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN, + pOldTag->tag_data, old_tag_len); + + if (skb_pull_and_merge(skb, (unsigned char *)pOldTag, TAG_HDR_LEN+old_tag_len) < 0) { + DEBUG_ERR("call skb_pull_and_merge() failed in PADI/R packet!\n"); + return -1; + } + ph->length = htons(ntohs(ph->length)-TAG_HDR_LEN-old_tag_len); + } + + tag->tag_type = PTT_RELAY_SID; + tag->tag_len = htons(MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN+old_tag_len); + + /* insert the magic_code+client mac in relay tag */ + pMagic = (unsigned short *)tag->tag_data; + *pMagic = htons(MAGIC_CODE); + memcpy(tag->tag_data+MAGIC_CODE_LEN, skb->data+ETH_ALEN, ETH_ALEN); + + /* Add relay tag */ + if (__nat25_add_pppoe_tag(skb, tag) < 0) + return -1; + + DEBUG_INFO("NAT25: Insert PPPoE, forward %s packet\n", + (ph->code == PADI_CODE ? "PADI" : "PADR")); + } else { /* not add relay tag */ + if (priv->pppoe_connection_in_progress && + memcmp(skb->data+ETH_ALEN, priv->pppoe_addr, ETH_ALEN)) { + DEBUG_ERR("Discard PPPoE packet due to another PPPoE connection is in progress!\n"); + return -2; + } + + if (priv->pppoe_connection_in_progress == 0) + memcpy(priv->pppoe_addr, skb->data+ETH_ALEN, ETH_ALEN); + + priv->pppoe_connection_in_progress = WAIT_TIME_PPPOE; + } + } else { + return -1; + } + } else { /* session phase */ + DEBUG_INFO("NAT25: Insert PPPoE, insert session packet to %s\n", skb->dev->name); + + __nat25_generate_pppoe_network_addr(networkAddr, skb->data, &(ph->sid)); + + __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr); + + __nat25_db_print(priv); + + if (!priv->ethBrExtInfo.addPPPoETag && + priv->pppoe_connection_in_progress && + !memcmp(skb->data+ETH_ALEN, priv->pppoe_addr, ETH_ALEN)) + priv->pppoe_connection_in_progress = 0; + } + return 0; + case NAT25_LOOKUP: + if (ph->code == PADO_CODE || ph->code == PADS_CODE) { + if (priv->ethBrExtInfo.addPPPoETag) { + struct pppoe_tag *tag; + unsigned char *ptr; + unsigned short tagType, tagLen; + int offset = 0; + + ptr = __nat25_find_pppoe_tag(ph, ntohs(PTT_RELAY_SID)); + if (ptr == NULL) { + DEBUG_ERR("Fail to find PTT_RELAY_SID in FADO!\n"); + return -1; + } + + tag = (struct pppoe_tag *)ptr; + tagType = (unsigned short)((ptr[0] << 8) + ptr[1]); + tagLen = (unsigned short)((ptr[2] << 8) + ptr[3]); + + if ((tagType != ntohs(PTT_RELAY_SID)) || (tagLen < (MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN))) { + DEBUG_ERR("Invalid PTT_RELAY_SID tag length [%d]!\n", tagLen); + return -1; + } + + pMagic = (unsigned short *)tag->tag_data; + if (ntohs(*pMagic) != MAGIC_CODE) { + DEBUG_ERR("Can't find MAGIC_CODE in %s packet!\n", + (ph->code == PADO_CODE ? "PADO" : "PADS")); + return -1; + } + + memcpy(skb->data, tag->tag_data+MAGIC_CODE_LEN, ETH_ALEN); + + if (tagLen > MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN) + offset = TAG_HDR_LEN; + + if (skb_pull_and_merge(skb, ptr+offset, TAG_HDR_LEN+MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN-offset) < 0) { + DEBUG_ERR("call skb_pull_and_merge() failed in PADO packet!\n"); + return -1; + } + ph->length = htons(ntohs(ph->length)-(TAG_HDR_LEN+MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN-offset)); + if (offset > 0) + tag->tag_len = htons(tagLen-MAGIC_CODE_LEN-RTL_RELAY_TAG_LEN); + + DEBUG_INFO("NAT25: Lookup PPPoE, forward %s Packet from %s\n", + (ph->code == PADO_CODE ? "PADO" : "PADS"), skb->dev->name); + } else { /* not add relay tag */ + if (!priv->pppoe_connection_in_progress) { + DEBUG_ERR("Discard PPPoE packet due to no connection in progresss!\n"); + return -1; + } + memcpy(skb->data, priv->pppoe_addr, ETH_ALEN); + priv->pppoe_connection_in_progress = WAIT_TIME_PPPOE; + } + } else { + if (ph->sid != 0) { + DEBUG_INFO("NAT25: Lookup PPPoE, lookup session packet from %s\n", skb->dev->name); + __nat25_generate_pppoe_network_addr(networkAddr, skb->data+ETH_ALEN, &(ph->sid)); + __nat25_db_network_lookup_and_replace(priv, skb, networkAddr); + __nat25_db_print(priv); + } else { + return -1; + } + } + return 0; + default: + return -1; + } + } else if (protocol == 0x888e) { + /*---------------------------------------------------*/ + /* Handle EAP frame */ + /*---------------------------------------------------*/ + switch (method) { + case NAT25_CHECK: + return -1; + case NAT25_INSERT: + return 0; + case NAT25_LOOKUP: + return 0; + default: + return -1; + } + } else if ((protocol == 0xe2ae) || (protocol == 0xe2af)) { + /*---------------------------------------------------*/ + /* Handle C-Media proprietary frame */ + /*---------------------------------------------------*/ + switch (method) { + case NAT25_CHECK: + return -1; + case NAT25_INSERT: + return 0; + case NAT25_LOOKUP: + return 0; + default: + return -1; + } + } else if (protocol == ETH_P_IPV6) { + /*------------------------------------------------*/ + /* Handle IPV6 frame */ + /*------------------------------------------------*/ + struct ipv6hdr *iph = (struct ipv6hdr *)(skb->data + ETH_HLEN); + + if (sizeof(*iph) >= (skb->len - ETH_HLEN)) { + DEBUG_WARN("NAT25: malformed IPv6 packet !\n"); + return -1; + } + + switch (method) { + case NAT25_CHECK: + if (skb->data[0] & 1) + return 0; + return -1; + case NAT25_INSERT: + DEBUG_INFO("NAT25: Insert IP, SA =%4x:%4x:%4x:%4x:%4x:%4x:%4x:%4x," + " DA =%4x:%4x:%4x:%4x:%4x:%4x:%4x:%4x\n", + iph->saddr.s6_addr16[0], iph->saddr.s6_addr16[1], iph->saddr.s6_addr16[2], iph->saddr.s6_addr16[3], + iph->saddr.s6_addr16[4], iph->saddr.s6_addr16[5], iph->saddr.s6_addr16[6], iph->saddr.s6_addr16[7], + iph->daddr.s6_addr16[0], iph->daddr.s6_addr16[1], iph->daddr.s6_addr16[2], iph->daddr.s6_addr16[3], + iph->daddr.s6_addr16[4], iph->daddr.s6_addr16[5], iph->daddr.s6_addr16[6], iph->daddr.s6_addr16[7]); + + if (memcmp(&iph->saddr, "\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0", 16)) { + __nat25_generate_ipv6_network_addr(networkAddr, (unsigned int *)&iph->saddr); + __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr); + __nat25_db_print(priv); + + if (iph->nexthdr == IPPROTO_ICMPV6 && + skb->len > (ETH_HLEN + sizeof(*iph) + 4)) { + if (update_nd_link_layer_addr(skb->data + ETH_HLEN + sizeof(*iph), + skb->len - ETH_HLEN - sizeof(*iph), GET_MY_HWADDR(priv))) { + struct icmp6hdr *hdr = (struct icmp6hdr *)(skb->data + ETH_HLEN + sizeof(*iph)); + hdr->icmp6_cksum = 0; + hdr->icmp6_cksum = csum_ipv6_magic(&iph->saddr, &iph->daddr, + iph->payload_len, + IPPROTO_ICMPV6, + csum_partial((__u8 *)hdr, iph->payload_len, 0)); + } + } + } + return 0; + case NAT25_LOOKUP: + DEBUG_INFO("NAT25: Lookup IP, SA =%4x:%4x:%4x:%4x:%4x:%4x:%4x:%4x, DA =%4x:%4x:%4x:%4x:%4x:%4x:%4x:%4x\n", + iph->saddr.s6_addr16[0], iph->saddr.s6_addr16[1], iph->saddr.s6_addr16[2], iph->saddr.s6_addr16[3], + iph->saddr.s6_addr16[4], iph->saddr.s6_addr16[5], iph->saddr.s6_addr16[6], iph->saddr.s6_addr16[7], + iph->daddr.s6_addr16[0], iph->daddr.s6_addr16[1], iph->daddr.s6_addr16[2], iph->daddr.s6_addr16[3], + iph->daddr.s6_addr16[4], iph->daddr.s6_addr16[5], iph->daddr.s6_addr16[6], iph->daddr.s6_addr16[7]); + __nat25_generate_ipv6_network_addr(networkAddr, (unsigned int *)&iph->daddr); + __nat25_db_network_lookup_and_replace(priv, skb, networkAddr); + return 0; + default: + return -1; + } + } + return -1; +} + +int nat25_handle_frame(struct adapter *priv, struct sk_buff *skb) +{ + if (!(skb->data[0] & 1)) { + int is_vlan_tag = 0, i, retval = 0; + unsigned short vlan_hdr = 0; + unsigned short protocol; + + protocol = be16_to_cpu(*((__be16 *)(skb->data + 2 * ETH_ALEN))); + if (protocol == ETH_P_8021Q) { + is_vlan_tag = 1; + vlan_hdr = *((unsigned short *)(skb->data+ETH_ALEN*2+2)); + for (i = 0; i < 6; i++) + *((unsigned short *)(skb->data+ETH_ALEN*2+2-i*2)) = *((unsigned short *)(skb->data+ETH_ALEN*2-2-i*2)); + skb_pull(skb, 4); + } + + if (!priv->ethBrExtInfo.nat25_disable) { + unsigned long irqL; + _enter_critical_bh(&priv->br_ext_lock, &irqL); + /* + * This function look up the destination network address from + * the NAT2.5 database. Return value = -1 means that the + * corresponding network protocol is NOT support. + */ + if (!priv->ethBrExtInfo.nat25sc_disable && + (be16_to_cpu(*((__be16 *)(skb->data+ETH_ALEN*2))) == ETH_P_IP) && + !memcmp(priv->scdb_ip, skb->data+ETH_HLEN+16, 4)) { + memcpy(skb->data, priv->scdb_mac, ETH_ALEN); + + _exit_critical_bh(&priv->br_ext_lock, &irqL); + } else { + _exit_critical_bh(&priv->br_ext_lock, &irqL); + + retval = nat25_db_handle(priv, skb, NAT25_LOOKUP); + } + } else { + if (((be16_to_cpu(*((__be16 *)(skb->data+ETH_ALEN*2))) == ETH_P_IP) && + !memcmp(priv->br_ip, skb->data+ETH_HLEN+16, 4)) || + ((be16_to_cpu(*((__be16 *)(skb->data+ETH_ALEN*2))) == ETH_P_ARP) && + !memcmp(priv->br_ip, skb->data+ETH_HLEN+24, 4))) { + /* for traffic to upper TCP/IP */ + retval = nat25_db_handle(priv, skb, NAT25_LOOKUP); + } + } + + if (is_vlan_tag) { + skb_push(skb, 4); + for (i = 0; i < 6; i++) + *((unsigned short *)(skb->data+i*2)) = *((unsigned short *)(skb->data+4+i*2)); + *((__be16 *)(skb->data+ETH_ALEN*2)) = __constant_htons(ETH_P_8021Q); + *((unsigned short *)(skb->data+ETH_ALEN*2+2)) = vlan_hdr; + } + + if (retval == -1) { + /* DEBUG_ERR("NAT25: Lookup fail!\n"); */ + return -1; + } + } + + return 0; +} + +#define SERVER_PORT 67 +#define CLIENT_PORT 68 +#define DHCP_MAGIC 0x63825363 +#define BROADCAST_FLAG 0x8000 + +struct dhcpMessage { + u_int8_t op; + u_int8_t htype; + u_int8_t hlen; + u_int8_t hops; + u_int32_t xid; + u_int16_t secs; + u_int16_t flags; + u_int32_t ciaddr; + u_int32_t yiaddr; + u_int32_t siaddr; + u_int32_t giaddr; + u_int8_t chaddr[16]; + u_int8_t sname[64]; + u_int8_t file[128]; + u_int32_t cookie; + u_int8_t options[308]; /* 312 - cookie */ +}; + +void dhcp_flag_bcast(struct adapter *priv, struct sk_buff *skb) +{ + if (skb == NULL) + return; + + if (!priv->ethBrExtInfo.dhcp_bcst_disable) { + __be16 protocol = *((__be16 *)(skb->data + 2 * ETH_ALEN)); + + if (protocol == __constant_htons(ETH_P_IP)) { /* IP */ + struct iphdr *iph = (struct iphdr *)(skb->data + ETH_HLEN); + + if (iph->protocol == IPPROTO_UDP) { /* UDP */ + struct udphdr *udph = (struct udphdr *)((size_t)iph + (iph->ihl << 2)); + + if ((udph->source == __constant_htons(CLIENT_PORT)) && + (udph->dest == __constant_htons(SERVER_PORT))) { /* DHCP request */ + struct dhcpMessage *dhcph = + (struct dhcpMessage *)((size_t)udph + sizeof(struct udphdr)); + u32 cookie = be32_to_cpu((__be32)dhcph->cookie); + + if (cookie == DHCP_MAGIC) { /* match magic word */ + if (!(dhcph->flags & htons(BROADCAST_FLAG))) { + /* if not broadcast */ + register int sum = 0; + + DEBUG_INFO("DHCP: change flag of DHCP request to broadcast.\n"); + /* or BROADCAST flag */ + dhcph->flags |= htons(BROADCAST_FLAG); + /* recalculate checksum */ + sum = ~(udph->check) & 0xffff; + sum += be16_to_cpu(dhcph->flags); + while (sum >> 16) + sum = (sum & 0xffff) + (sum >> 16); + udph->check = ~sum; + } + } + } + } + } + } +} + + +void *scdb_findEntry(struct adapter *priv, unsigned char *macAddr, + unsigned char *ipAddr) +{ + unsigned char networkAddr[MAX_NETWORK_ADDR_LEN]; + struct nat25_network_db_entry *db; + int hash; + /* unsigned long irqL; */ + /* _enter_critical_bh(&priv->br_ext_lock, &irqL); */ + + __nat25_generate_ipv4_network_addr(networkAddr, (unsigned int *)ipAddr); + hash = __nat25_network_hash(networkAddr); + db = priv->nethash[hash]; + while (db != NULL) { + if (!memcmp(db->networkAddr, networkAddr, MAX_NETWORK_ADDR_LEN)) { + /* _exit_critical_bh(&priv->br_ext_lock, &irqL); */ + return (void *)db; + } + + db = db->next_hash; + } + + /* _exit_critical_bh(&priv->br_ext_lock, &irqL); */ + return NULL; +} diff --git a/drivers/staging/rtl8188eu/core/rtw_cmd.c b/drivers/staging/rtl8188eu/core/rtw_cmd.c new file mode 100644 index 0000000000000..859fc1919ad64 --- /dev/null +++ b/drivers/staging/rtl8188eu/core/rtw_cmd.c @@ -0,0 +1,2364 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTW_CMD_C_ + +#include +#include +#include +#include +#include +#include +#include + +/* +Caller and the rtw_cmd_thread can protect cmd_q by spin_lock. +No irqsave is necessary. +*/ + +int _rtw_init_cmd_priv (struct cmd_priv *pcmdpriv) +{ + int res = _SUCCESS; + +_func_enter_; + + _rtw_init_sema(&(pcmdpriv->cmd_queue_sema), 0); + /* _rtw_init_sema(&(pcmdpriv->cmd_done_sema), 0); */ + _rtw_init_sema(&(pcmdpriv->terminate_cmdthread_sema), 0); + + + _rtw_init_queue(&(pcmdpriv->cmd_queue)); + + /* allocate DMA-able/Non-Page memory for cmd_buf and rsp_buf */ + + pcmdpriv->cmd_seq = 1; + + pcmdpriv->cmd_allocated_buf = rtw_zmalloc(MAX_CMDSZ + CMDBUFF_ALIGN_SZ); + + if (pcmdpriv->cmd_allocated_buf == NULL) { + res = _FAIL; + goto exit; + } + + pcmdpriv->cmd_buf = pcmdpriv->cmd_allocated_buf + CMDBUFF_ALIGN_SZ - ((size_t)(pcmdpriv->cmd_allocated_buf) & (CMDBUFF_ALIGN_SZ-1)); + + pcmdpriv->rsp_allocated_buf = rtw_zmalloc(MAX_RSPSZ + 4); + + if (pcmdpriv->rsp_allocated_buf == NULL) { + res = _FAIL; + goto exit; + } + + pcmdpriv->rsp_buf = pcmdpriv->rsp_allocated_buf + 4 - ((size_t)(pcmdpriv->rsp_allocated_buf) & 3); + + pcmdpriv->cmd_issued_cnt = 0; + pcmdpriv->cmd_done_cnt = 0; + pcmdpriv->rsp_cnt = 0; +exit: +_func_exit_; + return res; +} + +static void c2h_wk_callback(struct work_struct *work); + +int _rtw_init_evt_priv(struct evt_priv *pevtpriv) +{ + int res = _SUCCESS; + +_func_enter_; + + /* allocate DMA-able/Non-Page memory for cmd_buf and rsp_buf */ + ATOMIC_SET(&pevtpriv->event_seq, 0); + pevtpriv->evt_done_cnt = 0; + + _init_workitem(&pevtpriv->c2h_wk, c2h_wk_callback, NULL); + pevtpriv->c2h_wk_alive = false; + pevtpriv->c2h_queue = rtw_cbuf_alloc(C2H_QUEUE_MAX_LEN+1); + +_func_exit_; + + return res; +} + +void rtw_free_evt_priv(struct evt_priv *pevtpriv) +{ +_func_enter_; + + RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("+rtw_free_evt_priv\n")); + + _cancel_workitem_sync(&pevtpriv->c2h_wk); + while (pevtpriv->c2h_wk_alive) + rtw_msleep_os(10); + + while (!rtw_cbuf_empty(pevtpriv->c2h_queue)) { + void *c2h = rtw_cbuf_pop(pevtpriv->c2h_queue); + if (c2h != NULL && c2h != (void *)pevtpriv) + kfree(c2h); + } + RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("-rtw_free_evt_priv\n")); + +_func_exit_; +} + +void _rtw_free_cmd_priv (struct cmd_priv *pcmdpriv) +{ +_func_enter_; + + if (pcmdpriv) { + _rtw_spinlock_free(&(pcmdpriv->cmd_queue.lock)); + _rtw_free_sema(&(pcmdpriv->cmd_queue_sema)); + _rtw_free_sema(&(pcmdpriv->terminate_cmdthread_sema)); + + if (pcmdpriv->cmd_allocated_buf) + kfree(pcmdpriv->cmd_allocated_buf); + + if (pcmdpriv->rsp_allocated_buf) + kfree(pcmdpriv->rsp_allocated_buf); + } +_func_exit_; +} + +/* +Calling Context: + +rtw_enqueue_cmd can only be called between kernel thread, +since only spin_lock is used. + +ISR/Call-Back functions can't call this sub-function. + +*/ + +int _rtw_enqueue_cmd(struct __queue *queue, struct cmd_obj *obj) +{ + unsigned long irqL; + +_func_enter_; + + if (obj == NULL) + goto exit; + + /* _enter_critical_bh(&queue->lock, &irqL); */ + _enter_critical(&queue->lock, &irqL); + + rtw_list_insert_tail(&obj->list, &queue->queue); + + /* _exit_critical_bh(&queue->lock, &irqL); */ + _exit_critical(&queue->lock, &irqL); + +exit: + +_func_exit_; + + return _SUCCESS; +} + +struct cmd_obj *_rtw_dequeue_cmd(struct __queue *queue) +{ + unsigned long irqL; + struct cmd_obj *obj; + +_func_enter_; + + /* _enter_critical_bh(&(queue->lock), &irqL); */ + _enter_critical(&queue->lock, &irqL); + if (rtw_is_list_empty(&(queue->queue))) { + obj = NULL; + } else { + obj = LIST_CONTAINOR(get_next(&(queue->queue)), struct cmd_obj, list); + rtw_list_delete(&obj->list); + } + + /* _exit_critical_bh(&(queue->lock), &irqL); */ + _exit_critical(&queue->lock, &irqL); + +_func_exit_; + + return obj; +} + +u32 rtw_init_cmd_priv(struct cmd_priv *pcmdpriv) +{ + u32 res; +_func_enter_; + res = _rtw_init_cmd_priv (pcmdpriv); +_func_exit_; + return res; +} + +u32 rtw_init_evt_priv (struct evt_priv *pevtpriv) +{ + int res; +_func_enter_; + res = _rtw_init_evt_priv(pevtpriv); +_func_exit_; + return res; +} + +void rtw_free_cmd_priv(struct cmd_priv *pcmdpriv) +{ +_func_enter_; + RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("rtw_free_cmd_priv\n")); + _rtw_free_cmd_priv(pcmdpriv); +_func_exit_; +} + +int rtw_cmd_filter(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj) +{ + u8 bAllow = false; /* set to true to allow enqueuing cmd when hw_init_completed is false */ + + /* To decide allow or not */ + if ((pcmdpriv->padapter->pwrctrlpriv.bHWPwrPindetect) && + (!pcmdpriv->padapter->registrypriv.usbss_enable)) { + if (cmd_obj->cmdcode == GEN_CMD_CODE(_Set_Drv_Extra)) { + struct drvextra_cmd_parm *pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)cmd_obj->parmbuf; + if (pdrvextra_cmd_parm->ec_id == POWER_SAVING_CTRL_WK_CID) + bAllow = true; + } + } + + if (cmd_obj->cmdcode == GEN_CMD_CODE(_SetChannelPlan)) + bAllow = true; + + if ((!pcmdpriv->padapter->hw_init_completed && !bAllow) || + !pcmdpriv->cmdthd_running) /* com_thread not running */ + return _FAIL; + return _SUCCESS; +} + +u32 rtw_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj) +{ + int res = _FAIL; + struct adapter *padapter = pcmdpriv->padapter; + +_func_enter_; + + if (cmd_obj == NULL) + goto exit; + + cmd_obj->padapter = padapter; + + res = rtw_cmd_filter(pcmdpriv, cmd_obj); + if (_FAIL == res) { + rtw_free_cmd_obj(cmd_obj); + goto exit; + } + + res = _rtw_enqueue_cmd(&pcmdpriv->cmd_queue, cmd_obj); + + if (res == _SUCCESS) + _rtw_up_sema(&pcmdpriv->cmd_queue_sema); + +exit: + +_func_exit_; + + return res; +} + +struct cmd_obj *rtw_dequeue_cmd(struct cmd_priv *pcmdpriv) +{ + struct cmd_obj *cmd_obj; + +_func_enter_; + + cmd_obj = _rtw_dequeue_cmd(&pcmdpriv->cmd_queue); + +_func_exit_; + return cmd_obj; +} + +void rtw_cmd_clr_isr(struct cmd_priv *pcmdpriv) +{ +_func_enter_; + pcmdpriv->cmd_done_cnt++; + /* _rtw_up_sema(&(pcmdpriv->cmd_done_sema)); */ +_func_exit_; +} + +void rtw_free_cmd_obj(struct cmd_obj *pcmd) +{ +_func_enter_; + + if ((pcmd->cmdcode != _JoinBss_CMD_) && (pcmd->cmdcode != _CreateBss_CMD_)) { + /* free parmbuf in cmd_obj */ + kfree(pcmd->parmbuf); + } + + if (pcmd->rsp != NULL) { + if (pcmd->rspsz != 0) { + /* free rsp in cmd_obj */ + kfree(pcmd->rsp); + } + } + + /* free cmd_obj */ + kfree(pcmd); + +_func_exit_; +} + +int rtw_cmd_thread(void *context) +{ + u8 ret; + struct cmd_obj *pcmd; + u8 *pcmdbuf; + u8 (*cmd_hdl)(struct adapter *padapter, u8 *pbuf); + void (*pcmd_callback)(struct adapter *dev, struct cmd_obj *pcmd); + struct adapter *padapter = (struct adapter *)context; + struct cmd_priv *pcmdpriv = &(padapter->cmdpriv); + +_func_enter_; + + thread_enter("RTW_CMD_THREAD"); + + pcmdbuf = pcmdpriv->cmd_buf; + + pcmdpriv->cmdthd_running = true; + _rtw_up_sema(&pcmdpriv->terminate_cmdthread_sema); + + RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("start r871x rtw_cmd_thread !!!!\n")); + + while (1) { + if (_rtw_down_sema(&pcmdpriv->cmd_queue_sema) == _FAIL) + break; + + if (padapter->bDriverStopped || + padapter->bSurpriseRemoved) { + DBG_88E("%s: DriverStopped(%d) SurpriseRemoved(%d) break at line %d\n", + __func__, padapter->bDriverStopped, padapter->bSurpriseRemoved, __LINE__); + break; + } +_next: + if (padapter->bDriverStopped || + padapter->bSurpriseRemoved) { + DBG_88E("%s: DriverStopped(%d) SurpriseRemoved(%d) break at line %d\n", + __func__, padapter->bDriverStopped, padapter->bSurpriseRemoved, __LINE__); + break; + } + + pcmd = rtw_dequeue_cmd(pcmdpriv); + if (!pcmd) + continue; + + if (_FAIL == rtw_cmd_filter(pcmdpriv, pcmd)) { + pcmd->res = H2C_DROPPED; + goto post_process; + } + + pcmdpriv->cmd_issued_cnt++; + + pcmd->cmdsz = _RND4((pcmd->cmdsz));/* _RND4 */ + + memcpy(pcmdbuf, pcmd->parmbuf, pcmd->cmdsz); + + if (pcmd->cmdcode <= (sizeof(wlancmds) / sizeof(struct cmd_hdl))) { + cmd_hdl = wlancmds[pcmd->cmdcode].h2cfuns; + + if (cmd_hdl) { + ret = cmd_hdl(pcmd->padapter, pcmdbuf); + pcmd->res = ret; + } + + pcmdpriv->cmd_seq++; + } else { + pcmd->res = H2C_PARAMETERS_ERROR; + } + + cmd_hdl = NULL; + +post_process: + + /* call callback function for post-processed */ + if (pcmd->cmdcode <= (sizeof(rtw_cmd_callback) / sizeof(struct _cmd_callback))) { + pcmd_callback = rtw_cmd_callback[pcmd->cmdcode].callback; + if (pcmd_callback == NULL) { + RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("mlme_cmd_hdl(): pcmd_callback = 0x%p, cmdcode = 0x%x\n", pcmd_callback, pcmd->cmdcode)); + rtw_free_cmd_obj(pcmd); + } else { + /* todo: !!! fill rsp_buf to pcmd->rsp if (pcmd->rsp!= NULL) */ + pcmd_callback(pcmd->padapter, pcmd);/* need conider that free cmd_obj in rtw_cmd_callback */ + } + } else { + RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("%s: cmdcode = 0x%x callback not defined!\n", __func__, pcmd->cmdcode)); + rtw_free_cmd_obj(pcmd); + } + + flush_signals_thread(); + + goto _next; + } + pcmdpriv->cmdthd_running = false; + + /* free all cmd_obj resources */ + do { + pcmd = rtw_dequeue_cmd(pcmdpriv); + if (pcmd == NULL) + break; + + /* DBG_88E("%s: leaving... drop cmdcode:%u\n", __func__, pcmd->cmdcode); */ + + rtw_free_cmd_obj(pcmd); + } while (1); + + _rtw_up_sema(&pcmdpriv->terminate_cmdthread_sema); + +_func_exit_; + + thread_exit(); +} + +u8 rtw_setstandby_cmd(struct adapter *padapter, uint action) +{ + struct cmd_obj *ph2c; + struct usb_suspend_parm *psetusbsuspend; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + + u8 ret = _SUCCESS; + +_func_enter_; + + ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) { + ret = _FAIL; + goto exit; + } + + psetusbsuspend = (struct usb_suspend_parm *)rtw_zmalloc(sizeof(struct usb_suspend_parm)); + if (psetusbsuspend == NULL) { + kfree(ph2c); + ret = _FAIL; + goto exit; + } + + psetusbsuspend->action = action; + + init_h2fwcmd_w_parm_no_rsp(ph2c, psetusbsuspend, GEN_CMD_CODE(_SetUsbSuspend)); + + ret = rtw_enqueue_cmd(pcmdpriv, ph2c); + +exit: + +_func_exit_; + + return ret; +} + +/* +rtw_sitesurvey_cmd(~) + ### NOTE:#### (!!!!) + MUST TAKE CARE THAT BEFORE CALLING THIS FUNC, YOU SHOULD HAVE LOCKED pmlmepriv->lock +*/ +u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid, int ssid_num, + struct rtw_ieee80211_channel *ch, int ch_num) +{ + u8 res = _FAIL; + struct cmd_obj *ph2c; + struct sitesurvey_parm *psurveyPara; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + +_func_enter_; + if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_SCAN, 1); + } + + if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + p2p_ps_wk_cmd(padapter, P2P_PS_SCAN, 1); + } + + ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) + return _FAIL; + + psurveyPara = (struct sitesurvey_parm *)rtw_zmalloc(sizeof(struct sitesurvey_parm)); + if (psurveyPara == NULL) { + kfree(ph2c); + return _FAIL; + } + + rtw_free_network_queue(padapter, false); + + RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("%s: flush network queue\n", __func__)); + + init_h2fwcmd_w_parm_no_rsp(ph2c, psurveyPara, GEN_CMD_CODE(_SiteSurvey)); + + /* psurveyPara->bsslimit = 48; */ + psurveyPara->scan_mode = pmlmepriv->scan_mode; + + /* prepare ssid list */ + if (ssid) { + int i; + for (i = 0; i < ssid_num && i < RTW_SSID_SCAN_AMOUNT; i++) { + if (ssid[i].SsidLength) { + memcpy(&psurveyPara->ssid[i], &ssid[i], sizeof(struct ndis_802_11_ssid)); + psurveyPara->ssid_num++; + if (0) + DBG_88E(FUNC_ADPT_FMT" ssid:(%s, %d)\n", FUNC_ADPT_ARG(padapter), + psurveyPara->ssid[i].Ssid, psurveyPara->ssid[i].SsidLength); + } + } + } + + /* prepare channel list */ + if (ch) { + int i; + for (i = 0; i < ch_num && i < RTW_CHANNEL_SCAN_AMOUNT; i++) { + if (ch[i].hw_value && !(ch[i].flags & RTW_IEEE80211_CHAN_DISABLED)) { + memcpy(&psurveyPara->ch[i], &ch[i], sizeof(struct rtw_ieee80211_channel)); + psurveyPara->ch_num++; + if (0) + DBG_88E(FUNC_ADPT_FMT" ch:%u\n", FUNC_ADPT_ARG(padapter), + psurveyPara->ch[i].hw_value); + } + } + } + + set_fwstate(pmlmepriv, _FW_UNDER_SURVEY); + + res = rtw_enqueue_cmd(pcmdpriv, ph2c); + + if (res == _SUCCESS) { + pmlmepriv->scan_start_time = rtw_get_current_time(); + + _set_timer(&pmlmepriv->scan_to_timer, SCANNING_TIMEOUT); + + rtw_led_control(padapter, LED_CTL_SITE_SURVEY); + + pmlmepriv->scan_interval = SCAN_INTERVAL;/* 30*2 sec = 60sec */ + } else { + _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY); + } + +_func_exit_; + + return res; +} + +u8 rtw_setdatarate_cmd(struct adapter *padapter, u8 *rateset) +{ + struct cmd_obj *ph2c; + struct setdatarate_parm *pbsetdataratepara; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; + +_func_enter_; + + ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + + pbsetdataratepara = (struct setdatarate_parm *)rtw_zmalloc(sizeof(struct setdatarate_parm)); + if (pbsetdataratepara == NULL) { + kfree(ph2c); + res = _FAIL; + goto exit; + } + + init_h2fwcmd_w_parm_no_rsp(ph2c, pbsetdataratepara, GEN_CMD_CODE(_SetDataRate)); + pbsetdataratepara->mac_id = 5; + memcpy(pbsetdataratepara->datarates, rateset, NumRates); + res = rtw_enqueue_cmd(pcmdpriv, ph2c); +exit: + +_func_exit_; + + return res; +} + +u8 rtw_setbasicrate_cmd(struct adapter *padapter, u8 *rateset) +{ + struct cmd_obj *ph2c; + struct setbasicrate_parm *pssetbasicratepara; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; + +_func_enter_; + + ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + pssetbasicratepara = (struct setbasicrate_parm *)rtw_zmalloc(sizeof(struct setbasicrate_parm)); + + if (pssetbasicratepara == NULL) { + kfree(ph2c); + res = _FAIL; + goto exit; + } + + init_h2fwcmd_w_parm_no_rsp(ph2c, pssetbasicratepara, _SetBasicRate_CMD_); + + memcpy(pssetbasicratepara->basicrates, rateset, NumRates); + + res = rtw_enqueue_cmd(pcmdpriv, ph2c); +exit: + +_func_exit_; + + return res; +} + + +/* +unsigned char rtw_setphy_cmd(unsigned char *adapter) + +1. be called only after rtw_update_registrypriv_dev_network(~) or mp testing program +2. for AdHoc/Ap mode or mp mode? + +*/ +u8 rtw_setphy_cmd(struct adapter *padapter, u8 modem, u8 ch) +{ + struct cmd_obj *ph2c; + struct setphy_parm *psetphypara; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; + +_func_enter_; + + ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + psetphypara = (struct setphy_parm *)rtw_zmalloc(sizeof(struct setphy_parm)); + + if (psetphypara == NULL) { + kfree(ph2c); + res = _FAIL; + goto exit; + } + + init_h2fwcmd_w_parm_no_rsp(ph2c, psetphypara, _SetPhy_CMD_); + + RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("CH =%d, modem =%d", ch, modem)); + + psetphypara->modem = modem; + psetphypara->rfchannel = ch; + + res = rtw_enqueue_cmd(pcmdpriv, ph2c); +exit: +_func_exit_; + return res; +} + +u8 rtw_setbbreg_cmd(struct adapter *padapter, u8 offset, u8 val) +{ + struct cmd_obj *ph2c; + struct writeBB_parm *pwritebbparm; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; + +_func_enter_; + ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + pwritebbparm = (struct writeBB_parm *)rtw_zmalloc(sizeof(struct writeBB_parm)); + + if (pwritebbparm == NULL) { + kfree(ph2c); + res = _FAIL; + goto exit; + } + + init_h2fwcmd_w_parm_no_rsp(ph2c, pwritebbparm, GEN_CMD_CODE(_SetBBReg)); + + pwritebbparm->offset = offset; + pwritebbparm->value = val; + + res = rtw_enqueue_cmd(pcmdpriv, ph2c); +exit: +_func_exit_; + return res; +} + +u8 rtw_getbbreg_cmd(struct adapter *padapter, u8 offset, u8 *pval) +{ + struct cmd_obj *ph2c; + struct readBB_parm *prdbbparm; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; + +_func_enter_; + ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + prdbbparm = (struct readBB_parm *)rtw_zmalloc(sizeof(struct readBB_parm)); + + if (prdbbparm == NULL) { + kfree(ph2c); + return _FAIL; + } + + _rtw_init_listhead(&ph2c->list); + ph2c->cmdcode = GEN_CMD_CODE(_GetBBReg); + ph2c->parmbuf = (unsigned char *)prdbbparm; + ph2c->cmdsz = sizeof(struct readBB_parm); + ph2c->rsp = pval; + ph2c->rspsz = sizeof(struct readBB_rsp); + + prdbbparm->offset = offset; + + res = rtw_enqueue_cmd(pcmdpriv, ph2c); +exit: +_func_exit_; + return res; +} + +u8 rtw_setrfreg_cmd(struct adapter *padapter, u8 offset, u32 val) +{ + struct cmd_obj *ph2c; + struct writeRF_parm *pwriterfparm; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; +_func_enter_; + ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + pwriterfparm = (struct writeRF_parm *)rtw_zmalloc(sizeof(struct writeRF_parm)); + + if (pwriterfparm == NULL) { + kfree(ph2c); + res = _FAIL; + goto exit; + } + + init_h2fwcmd_w_parm_no_rsp(ph2c, pwriterfparm, GEN_CMD_CODE(_SetRFReg)); + + pwriterfparm->offset = offset; + pwriterfparm->value = val; + + res = rtw_enqueue_cmd(pcmdpriv, ph2c); +exit: +_func_exit_; + return res; +} + +u8 rtw_getrfreg_cmd(struct adapter *padapter, u8 offset, u8 *pval) +{ + struct cmd_obj *ph2c; + struct readRF_parm *prdrfparm; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; + +_func_enter_; + + ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + + prdrfparm = (struct readRF_parm *)rtw_zmalloc(sizeof(struct readRF_parm)); + if (prdrfparm == NULL) { + kfree(ph2c); + res = _FAIL; + goto exit; + } + + _rtw_init_listhead(&ph2c->list); + ph2c->cmdcode = GEN_CMD_CODE(_GetRFReg); + ph2c->parmbuf = (unsigned char *)prdrfparm; + ph2c->cmdsz = sizeof(struct readRF_parm); + ph2c->rsp = pval; + ph2c->rspsz = sizeof(struct readRF_rsp); + + prdrfparm->offset = offset; + + res = rtw_enqueue_cmd(pcmdpriv, ph2c); + +exit: + +_func_exit_; + + return res; +} + +void rtw_getbbrfreg_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pcmd) +{ + _func_enter_; + + kfree(pcmd->parmbuf); + kfree(pcmd); + + if (padapter->registrypriv.mp_mode == 1) + padapter->mppriv.workparam.bcompleted = true; +_func_exit_; +} + +void rtw_readtssi_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pcmd) +{ + _func_enter_; + + kfree(pcmd->parmbuf); + kfree(pcmd); + + if (padapter->registrypriv.mp_mode == 1) + padapter->mppriv.workparam.bcompleted = true; +_func_exit_; +} + +u8 rtw_createbss_cmd(struct adapter *padapter) +{ + struct cmd_obj *pcmd; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct wlan_bssid_ex *pdev_network = &padapter->registrypriv.dev_network; + u8 res = _SUCCESS; + +_func_enter_; + + rtw_led_control(padapter, LED_CTL_START_TO_LINK); + + if (pmlmepriv->assoc_ssid.SsidLength == 0) + RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, (" createbss for Any SSid:%s\n", pmlmepriv->assoc_ssid.Ssid)); + else + RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, (" createbss for SSid:%s\n", pmlmepriv->assoc_ssid.Ssid)); + + pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (pcmd == NULL) { + res = _FAIL; + goto exit; + } + + _rtw_init_listhead(&pcmd->list); + pcmd->cmdcode = _CreateBss_CMD_; + pcmd->parmbuf = (unsigned char *)pdev_network; + pcmd->cmdsz = get_wlan_bssid_ex_sz((struct wlan_bssid_ex *)pdev_network); + pcmd->rsp = NULL; + pcmd->rspsz = 0; + pdev_network->Length = pcmd->cmdsz; + res = rtw_enqueue_cmd(pcmdpriv, pcmd); +exit: + +_func_exit_; + + return res; +} + +u8 rtw_createbss_cmd_ex(struct adapter *padapter, unsigned char *pbss, unsigned int sz) +{ + struct cmd_obj *pcmd; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; + +_func_enter_; + + pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (pcmd == NULL) { + res = _FAIL; + goto exit; + } + + _rtw_init_listhead(&pcmd->list); + pcmd->cmdcode = GEN_CMD_CODE(_CreateBss); + pcmd->parmbuf = pbss; + pcmd->cmdsz = sz; + pcmd->rsp = NULL; + pcmd->rspsz = 0; + + res = rtw_enqueue_cmd(pcmdpriv, pcmd); + +exit: + +_func_exit_; + + return res; +} + +u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork) +{ + u8 res = _SUCCESS; + uint t_len = 0; + struct wlan_bssid_ex *psecnetwork; + struct cmd_obj *pcmd; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct qos_priv *pqospriv = &pmlmepriv->qospriv; + struct security_priv *psecuritypriv = &padapter->securitypriv; + struct registry_priv *pregistrypriv = &padapter->registrypriv; + struct ht_priv *phtpriv = &pmlmepriv->htpriv; + enum ndis_802_11_network_infra ndis_network_mode = pnetwork->network.InfrastructureMode; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + +_func_enter_; + + rtw_led_control(padapter, LED_CTL_START_TO_LINK); + + if (pmlmepriv->assoc_ssid.SsidLength == 0) { + RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("+Join cmd: Any SSid\n")); + } else { + RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+Join cmd: SSid =[%s]\n", pmlmepriv->assoc_ssid.Ssid)); + } + + pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (pcmd == NULL) { + res = _FAIL; + RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("rtw_joinbss_cmd: memory allocate for cmd_obj fail!!!\n")); + goto exit; + } + /* for IEs is fix buf size */ + t_len = sizeof(struct wlan_bssid_ex); + + + /* for hidden ap to set fw_state here */ + if (!check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_ADHOC_STATE)) { + switch (ndis_network_mode) { + case Ndis802_11IBSS: + set_fwstate(pmlmepriv, WIFI_ADHOC_STATE); + break; + case Ndis802_11Infrastructure: + set_fwstate(pmlmepriv, WIFI_STATION_STATE); + break; + case Ndis802_11APMode: + case Ndis802_11AutoUnknown: + case Ndis802_11InfrastructureMax: + break; + } + } + + psecnetwork = (struct wlan_bssid_ex *)&psecuritypriv->sec_bss; + if (psecnetwork == NULL) { + if (pcmd != NULL) + kfree(pcmd); + + res = _FAIL; + + RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("rtw_joinbss_cmd :psecnetwork == NULL!!!\n")); + + goto exit; + } + + _rtw_memset(psecnetwork, 0, t_len); + + memcpy(psecnetwork, &pnetwork->network, get_wlan_bssid_ex_sz(&pnetwork->network)); + + psecuritypriv->authenticator_ie[0] = (unsigned char)psecnetwork->IELength; + + if ((psecnetwork->IELength-12) < (256-1)) { + memcpy(&psecuritypriv->authenticator_ie[1], &psecnetwork->IEs[12], psecnetwork->IELength-12); + } else { + memcpy(&psecuritypriv->authenticator_ie[1], &psecnetwork->IEs[12], (256-1)); + } + + psecnetwork->IELength = 0; + /* Added by Albert 2009/02/18 */ + /* If the the driver wants to use the bssid to create the connection. */ + /* If not, we have to copy the connecting AP's MAC address to it so that */ + /* the driver just has the bssid information for PMKIDList searching. */ + + if (!pmlmepriv->assoc_by_bssid) + memcpy(&pmlmepriv->assoc_bssid[0], &pnetwork->network.MacAddress[0], ETH_ALEN); + + psecnetwork->IELength = rtw_restruct_sec_ie(padapter, &pnetwork->network.IEs[0], &psecnetwork->IEs[0], pnetwork->network.IELength); + + + pqospriv->qos_option = 0; + + if (pregistrypriv->wmm_enable) { + u32 tmp_len; + + tmp_len = rtw_restruct_wmm_ie(padapter, &pnetwork->network.IEs[0], &psecnetwork->IEs[0], pnetwork->network.IELength, psecnetwork->IELength); + + if (psecnetwork->IELength != tmp_len) { + psecnetwork->IELength = tmp_len; + pqospriv->qos_option = 1; /* There is WMM IE in this corresp. beacon */ + } else { + pqospriv->qos_option = 0;/* There is no WMM IE in this corresp. beacon */ + } + } + + phtpriv->ht_option = false; + if (pregistrypriv->ht_enable) { + /* Added by Albert 2010/06/23 */ + /* For the WEP mode, we will use the bg mode to do the connection to avoid some IOT issue. */ + /* Especially for Realtek 8192u SoftAP. */ + if ((padapter->securitypriv.dot11PrivacyAlgrthm != _WEP40_) && + (padapter->securitypriv.dot11PrivacyAlgrthm != _WEP104_) && + (padapter->securitypriv.dot11PrivacyAlgrthm != _TKIP_)) { + /* rtw_restructure_ht_ie */ + rtw_restructure_ht_ie(padapter, &pnetwork->network.IEs[0], &psecnetwork->IEs[0], + pnetwork->network.IELength, &psecnetwork->IELength); + } + } + + pmlmeinfo->assoc_AP_vendor = check_assoc_AP(pnetwork->network.IEs, pnetwork->network.IELength); + + if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_TENDA) + padapter->pwrctrlpriv.smart_ps = 0; + else + padapter->pwrctrlpriv.smart_ps = padapter->registrypriv.smart_ps; + + DBG_88E("%s: smart_ps =%d\n", __func__, padapter->pwrctrlpriv.smart_ps); + + pcmd->cmdsz = get_wlan_bssid_ex_sz(psecnetwork);/* get cmdsz before endian conversion */ + + _rtw_init_listhead(&pcmd->list); + pcmd->cmdcode = _JoinBss_CMD_;/* GEN_CMD_CODE(_JoinBss) */ + pcmd->parmbuf = (unsigned char *)psecnetwork; + pcmd->rsp = NULL; + pcmd->rspsz = 0; + + res = rtw_enqueue_cmd(pcmdpriv, pcmd); + +exit: + +_func_exit_; + + return res; +} + +u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueue) /* for sta_mode */ +{ + struct cmd_obj *cmdobj = NULL; + struct disconnect_parm *param = NULL; + struct cmd_priv *cmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; + +_func_enter_; + + RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+rtw_disassoc_cmd\n")); + + /* prepare cmd parameter */ + param = (struct disconnect_parm *)rtw_zmalloc(sizeof(*param)); + if (param == NULL) { + res = _FAIL; + goto exit; + } + param->deauth_timeout_ms = deauth_timeout_ms; + + if (enqueue) { + /* need enqueue, prepare cmd_obj and enqueue */ + cmdobj = (struct cmd_obj *)rtw_zmalloc(sizeof(*cmdobj)); + if (cmdobj == NULL) { + res = _FAIL; + kfree(param); + goto exit; + } + init_h2fwcmd_w_parm_no_rsp(cmdobj, param, _DisConnect_CMD_); + res = rtw_enqueue_cmd(cmdpriv, cmdobj); + } else { + /* no need to enqueue, do the cmd hdl directly and free cmd parameter */ + if (H2C_SUCCESS != disconnect_hdl(padapter, (u8 *)param)) + res = _FAIL; + kfree(param); + } + +exit: + +_func_exit_; + + return res; +} + +u8 rtw_setopmode_cmd(struct adapter *padapter, enum ndis_802_11_network_infra networktype) +{ + struct cmd_obj *ph2c; + struct setopmode_parm *psetop; + + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; + +_func_enter_; + + ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) { + res = false; + goto exit; + } + psetop = (struct setopmode_parm *)rtw_zmalloc(sizeof(struct setopmode_parm)); + + if (psetop == NULL) { + kfree(ph2c); + res = false; + goto exit; + } + + init_h2fwcmd_w_parm_no_rsp(ph2c, psetop, _SetOpMode_CMD_); + psetop->mode = (u8)networktype; + + res = rtw_enqueue_cmd(pcmdpriv, ph2c); + +exit: + +_func_exit_; + + return res; +} + +u8 rtw_setstakey_cmd(struct adapter *padapter, u8 *psta, u8 unicast_key) +{ + struct cmd_obj *ph2c; + struct set_stakey_parm *psetstakey_para; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + struct set_stakey_rsp *psetstakey_rsp = NULL; + + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct security_priv *psecuritypriv = &padapter->securitypriv; + struct sta_info *sta = (struct sta_info *)psta; + u8 res = _SUCCESS; + +_func_enter_; + + ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + + psetstakey_para = (struct set_stakey_parm *)rtw_zmalloc(sizeof(struct set_stakey_parm)); + if (psetstakey_para == NULL) { + kfree(ph2c); + res = _FAIL; + goto exit; + } + + psetstakey_rsp = (struct set_stakey_rsp *)rtw_zmalloc(sizeof(struct set_stakey_rsp)); + if (psetstakey_rsp == NULL) { + kfree(ph2c); + kfree(psetstakey_para); + res = _FAIL; + goto exit; + } + + init_h2fwcmd_w_parm_no_rsp(ph2c, psetstakey_para, _SetStaKey_CMD_); + ph2c->rsp = (u8 *)psetstakey_rsp; + ph2c->rspsz = sizeof(struct set_stakey_rsp); + + memcpy(psetstakey_para->addr, sta->hwaddr, ETH_ALEN); + + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) + psetstakey_para->algorithm = (unsigned char) psecuritypriv->dot11PrivacyAlgrthm; + else + GET_ENCRY_ALGO(psecuritypriv, sta, psetstakey_para->algorithm, false); + + if (unicast_key) + memcpy(&psetstakey_para->key, &sta->dot118021x_UncstKey, 16); + else + memcpy(&psetstakey_para->key, &psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey, 16); + + /* jeff: set this becasue at least sw key is ready */ + padapter->securitypriv.busetkipkey = true; + + res = rtw_enqueue_cmd(pcmdpriv, ph2c); + +exit: + +_func_exit_; + + return res; +} + +u8 rtw_clearstakey_cmd(struct adapter *padapter, u8 *psta, u8 entry, u8 enqueue) +{ + struct cmd_obj *ph2c; + struct set_stakey_parm *psetstakey_para; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + struct set_stakey_rsp *psetstakey_rsp = NULL; + struct sta_info *sta = (struct sta_info *)psta; + u8 res = _SUCCESS; + +_func_enter_; + + if (!enqueue) { + clear_cam_entry(padapter, entry); + } else { + ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + + psetstakey_para = (struct set_stakey_parm *)rtw_zmalloc(sizeof(struct set_stakey_parm)); + if (psetstakey_para == NULL) { + kfree(ph2c); + res = _FAIL; + goto exit; + } + + psetstakey_rsp = (struct set_stakey_rsp *)rtw_zmalloc(sizeof(struct set_stakey_rsp)); + if (psetstakey_rsp == NULL) { + kfree(ph2c); + kfree(psetstakey_para); + res = _FAIL; + goto exit; + } + + init_h2fwcmd_w_parm_no_rsp(ph2c, psetstakey_para, _SetStaKey_CMD_); + ph2c->rsp = (u8 *)psetstakey_rsp; + ph2c->rspsz = sizeof(struct set_stakey_rsp); + + memcpy(psetstakey_para->addr, sta->hwaddr, ETH_ALEN); + + psetstakey_para->algorithm = _NO_PRIVACY_; + + psetstakey_para->id = entry; + + res = rtw_enqueue_cmd(pcmdpriv, ph2c); + } +exit: + +_func_exit_; + + return res; +} + +u8 rtw_setrttbl_cmd(struct adapter *padapter, struct setratable_parm *prate_table) +{ + struct cmd_obj *ph2c; + struct setratable_parm *psetrttblparm; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; +_func_enter_; + + ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + psetrttblparm = (struct setratable_parm *)rtw_zmalloc(sizeof(struct setratable_parm)); + + if (psetrttblparm == NULL) { + kfree(ph2c); + res = _FAIL; + goto exit; + } + + init_h2fwcmd_w_parm_no_rsp(ph2c, psetrttblparm, GEN_CMD_CODE(_SetRaTable)); + + memcpy(psetrttblparm, prate_table, sizeof(struct setratable_parm)); + + res = rtw_enqueue_cmd(pcmdpriv, ph2c); +exit: +_func_exit_; + return res; +} + +u8 rtw_getrttbl_cmd(struct adapter *padapter, struct getratable_rsp *pval) +{ + struct cmd_obj *ph2c; + struct getratable_parm *pgetrttblparm; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; +_func_enter_; + + ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + pgetrttblparm = (struct getratable_parm *)rtw_zmalloc(sizeof(struct getratable_parm)); + + if (pgetrttblparm == NULL) { + kfree(ph2c); + res = _FAIL; + goto exit; + } + +/* init_h2fwcmd_w_parm_no_rsp(ph2c, psetrttblparm, GEN_CMD_CODE(_SetRaTable)); */ + + _rtw_init_listhead(&ph2c->list); + ph2c->cmdcode = GEN_CMD_CODE(_GetRaTable); + ph2c->parmbuf = (unsigned char *)pgetrttblparm; + ph2c->cmdsz = sizeof(struct getratable_parm); + ph2c->rsp = (u8 *)pval; + ph2c->rspsz = sizeof(struct getratable_rsp); + + pgetrttblparm->rsvd = 0x0; + + res = rtw_enqueue_cmd(pcmdpriv, ph2c); +exit: +_func_exit_; + return res; +} + +u8 rtw_setassocsta_cmd(struct adapter *padapter, u8 *mac_addr) +{ + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + struct cmd_obj *ph2c; + struct set_assocsta_parm *psetassocsta_para; + struct set_stakey_rsp *psetassocsta_rsp = NULL; + + u8 res = _SUCCESS; + +_func_enter_; + + ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + + psetassocsta_para = (struct set_assocsta_parm *)rtw_zmalloc(sizeof(struct set_assocsta_parm)); + if (psetassocsta_para == NULL) { + kfree(ph2c); + res = _FAIL; + goto exit; + } + + psetassocsta_rsp = (struct set_stakey_rsp *)rtw_zmalloc(sizeof(struct set_assocsta_rsp)); + if (psetassocsta_rsp == NULL) { + kfree(ph2c); + kfree(psetassocsta_para); + return _FAIL; + } + + init_h2fwcmd_w_parm_no_rsp(ph2c, psetassocsta_para, _SetAssocSta_CMD_); + ph2c->rsp = (u8 *)psetassocsta_rsp; + ph2c->rspsz = sizeof(struct set_assocsta_rsp); + + memcpy(psetassocsta_para->addr, mac_addr, ETH_ALEN); + + res = rtw_enqueue_cmd(pcmdpriv, ph2c); + +exit: + +_func_exit_; + + return res; + } + +u8 rtw_addbareq_cmd(struct adapter *padapter, u8 tid, u8 *addr) +{ + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + struct cmd_obj *ph2c; + struct addBaReq_parm *paddbareq_parm; + u8 res = _SUCCESS; + +_func_enter_; + + ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + + paddbareq_parm = (struct addBaReq_parm *)rtw_zmalloc(sizeof(struct addBaReq_parm)); + if (paddbareq_parm == NULL) { + kfree(ph2c); + res = _FAIL; + goto exit; + } + + paddbareq_parm->tid = tid; + memcpy(paddbareq_parm->addr, addr, ETH_ALEN); + + init_h2fwcmd_w_parm_no_rsp(ph2c, paddbareq_parm, GEN_CMD_CODE(_AddBAReq)); + + /* DBG_88E("rtw_addbareq_cmd, tid =%d\n", tid); */ + + /* rtw_enqueue_cmd(pcmdpriv, ph2c); */ + res = rtw_enqueue_cmd(pcmdpriv, ph2c); + +exit: + +_func_exit_; + + return res; +} + +u8 rtw_dynamic_chk_wk_cmd(struct adapter *padapter) +{ + struct cmd_obj *ph2c; + struct drvextra_cmd_parm *pdrvextra_cmd_parm; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; + +_func_enter_; + + ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + + pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); + if (pdrvextra_cmd_parm == NULL) { + kfree(ph2c); + res = _FAIL; + goto exit; + } + + pdrvextra_cmd_parm->ec_id = DYNAMIC_CHK_WK_CID; + pdrvextra_cmd_parm->type_size = 0; + pdrvextra_cmd_parm->pbuf = (u8 *)padapter; + + init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra)); + + + /* rtw_enqueue_cmd(pcmdpriv, ph2c); */ + res = rtw_enqueue_cmd(pcmdpriv, ph2c); +exit: +_func_exit_; + return res; +} + +u8 rtw_set_ch_cmd(struct adapter *padapter, u8 ch, u8 bw, u8 ch_offset, u8 enqueue) +{ + struct cmd_obj *pcmdobj; + struct set_ch_parm *set_ch_parm; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + + u8 res = _SUCCESS; + +_func_enter_; + + DBG_88E(FUNC_NDEV_FMT" ch:%u, bw:%u, ch_offset:%u\n", + FUNC_NDEV_ARG(padapter->pnetdev), ch, bw, ch_offset); + + /* check input parameter */ + + /* prepare cmd parameter */ + set_ch_parm = (struct set_ch_parm *)rtw_zmalloc(sizeof(*set_ch_parm)); + if (set_ch_parm == NULL) { + res = _FAIL; + goto exit; + } + set_ch_parm->ch = ch; + set_ch_parm->bw = bw; + set_ch_parm->ch_offset = ch_offset; + + if (enqueue) { + /* need enqueue, prepare cmd_obj and enqueue */ + pcmdobj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (pcmdobj == NULL) { + kfree(set_ch_parm); + res = _FAIL; + goto exit; + } + + init_h2fwcmd_w_parm_no_rsp(pcmdobj, set_ch_parm, GEN_CMD_CODE(_SetChannel)); + res = rtw_enqueue_cmd(pcmdpriv, pcmdobj); + } else { + /* no need to enqueue, do the cmd hdl directly and free cmd parameter */ + if (H2C_SUCCESS != set_ch_hdl(padapter, (u8 *)set_ch_parm)) + res = _FAIL; + + kfree(set_ch_parm); + } + + /* do something based on res... */ + +exit: + + DBG_88E(FUNC_NDEV_FMT" res:%u\n", FUNC_NDEV_ARG(padapter->pnetdev), res); + +_func_exit_; + + return res; +} + +u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue) +{ + struct cmd_obj *pcmdobj; + struct SetChannelPlan_param *setChannelPlan_param; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + + u8 res = _SUCCESS; + +_func_enter_; + + RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+rtw_set_chplan_cmd\n")); + + /* check input parameter */ + if (!rtw_is_channel_plan_valid(chplan)) { + res = _FAIL; + goto exit; + } + + /* prepare cmd parameter */ + setChannelPlan_param = (struct SetChannelPlan_param *)rtw_zmalloc(sizeof(struct SetChannelPlan_param)); + if (setChannelPlan_param == NULL) { + res = _FAIL; + goto exit; + } + setChannelPlan_param->channel_plan = chplan; + + if (enqueue) { + /* need enqueue, prepare cmd_obj and enqueue */ + pcmdobj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (pcmdobj == NULL) { + kfree(setChannelPlan_param); + res = _FAIL; + goto exit; + } + + init_h2fwcmd_w_parm_no_rsp(pcmdobj, setChannelPlan_param, GEN_CMD_CODE(_SetChannelPlan)); + res = rtw_enqueue_cmd(pcmdpriv, pcmdobj); + } else { + /* no need to enqueue, do the cmd hdl directly and free cmd parameter */ + if (H2C_SUCCESS != set_chplan_hdl(padapter, (unsigned char *)setChannelPlan_param)) + res = _FAIL; + + kfree(setChannelPlan_param); + } + + /* do something based on res... */ + if (res == _SUCCESS) + padapter->mlmepriv.ChannelPlan = chplan; + +exit: + +_func_exit_; + + return res; +} + +u8 rtw_led_blink_cmd(struct adapter *padapter, struct LED_871x *pLed) +{ + struct cmd_obj *pcmdobj; + struct LedBlink_param *ledBlink_param; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + + u8 res = _SUCCESS; + +_func_enter_; + + RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+rtw_led_blink_cmd\n")); + + pcmdobj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (pcmdobj == NULL) { + res = _FAIL; + goto exit; + } + + ledBlink_param = (struct LedBlink_param *)rtw_zmalloc(sizeof(struct LedBlink_param)); + if (ledBlink_param == NULL) { + kfree(pcmdobj); + res = _FAIL; + goto exit; + } + + ledBlink_param->pLed = pLed; + + init_h2fwcmd_w_parm_no_rsp(pcmdobj, ledBlink_param, GEN_CMD_CODE(_LedBlink)); + res = rtw_enqueue_cmd(pcmdpriv, pcmdobj); + +exit: + +_func_exit_; + + return res; +} + +u8 rtw_set_csa_cmd(struct adapter *padapter, u8 new_ch_no) +{ + struct cmd_obj *pcmdobj; + struct SetChannelSwitch_param *setChannelSwitch_param; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + + u8 res = _SUCCESS; + +_func_enter_; + + RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+rtw_set_csa_cmd\n")); + + pcmdobj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (pcmdobj == NULL) { + res = _FAIL; + goto exit; + } + + setChannelSwitch_param = (struct SetChannelSwitch_param *)rtw_zmalloc(sizeof(struct SetChannelSwitch_param)); + if (setChannelSwitch_param == NULL) { + kfree(pcmdobj); + res = _FAIL; + goto exit; + } + + setChannelSwitch_param->new_ch_no = new_ch_no; + + init_h2fwcmd_w_parm_no_rsp(pcmdobj, setChannelSwitch_param, GEN_CMD_CODE(_SetChannelSwitch)); + res = rtw_enqueue_cmd(pcmdpriv, pcmdobj); + +exit: + +_func_exit_; + + return res; +} + +u8 rtw_tdls_cmd(struct adapter *padapter, u8 *addr, u8 option) +{ + return _SUCCESS; +} + +static void traffic_status_watchdog(struct adapter *padapter) +{ + u8 bEnterPS; + u8 bBusyTraffic = false, bTxBusyTraffic = false, bRxBusyTraffic = false; + u8 bHigherBusyTraffic = false, bHigherBusyRxTraffic = false, bHigherBusyTxTraffic = false; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + + /* */ + /* Determine if our traffic is busy now */ + /* */ + if (check_fwstate(pmlmepriv, _FW_LINKED)) { + if (pmlmepriv->LinkDetectInfo.NumRxOkInPeriod > 100 || + pmlmepriv->LinkDetectInfo.NumTxOkInPeriod > 100) { + bBusyTraffic = true; + + if (pmlmepriv->LinkDetectInfo.NumRxOkInPeriod > pmlmepriv->LinkDetectInfo.NumTxOkInPeriod) + bRxBusyTraffic = true; + else + bTxBusyTraffic = true; + } + + /* Higher Tx/Rx data. */ + if (pmlmepriv->LinkDetectInfo.NumRxOkInPeriod > 4000 || + pmlmepriv->LinkDetectInfo.NumTxOkInPeriod > 4000) { + bHigherBusyTraffic = true; + + if (pmlmepriv->LinkDetectInfo.NumRxOkInPeriod > pmlmepriv->LinkDetectInfo.NumTxOkInPeriod) + bHigherBusyRxTraffic = true; + else + bHigherBusyTxTraffic = true; + } + + /* check traffic for powersaving. */ + if (((pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod + pmlmepriv->LinkDetectInfo.NumTxOkInPeriod) > 8) || + (pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod > 2)) + bEnterPS = false; + else + bEnterPS = true; + + /* LeisurePS only work in infra mode. */ + if (bEnterPS) + LPS_Enter(padapter); + else + LPS_Leave(padapter); + } else { + LPS_Leave(padapter); + } + + pmlmepriv->LinkDetectInfo.NumRxOkInPeriod = 0; + pmlmepriv->LinkDetectInfo.NumTxOkInPeriod = 0; + pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod = 0; + pmlmepriv->LinkDetectInfo.bBusyTraffic = bBusyTraffic; + pmlmepriv->LinkDetectInfo.bTxBusyTraffic = bTxBusyTraffic; + pmlmepriv->LinkDetectInfo.bRxBusyTraffic = bRxBusyTraffic; + pmlmepriv->LinkDetectInfo.bHigherBusyTraffic = bHigherBusyTraffic; + pmlmepriv->LinkDetectInfo.bHigherBusyRxTraffic = bHigherBusyRxTraffic; + pmlmepriv->LinkDetectInfo.bHigherBusyTxTraffic = bHigherBusyTxTraffic; +} + +void dynamic_chk_wk_hdl(struct adapter *padapter, u8 *pbuf, int sz) +{ + struct mlme_priv *pmlmepriv; + + padapter = (struct adapter *)pbuf; + pmlmepriv = &(padapter->mlmepriv); + +#ifdef CONFIG_88EU_AP_MODE + if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) + expire_timeout_chk(padapter); +#endif + + rtw_hal_sreset_xmit_status_check(padapter); + + linked_status_chk(padapter); + traffic_status_watchdog(padapter); + + rtw_hal_dm_watchdog(padapter); +} + +static void lps_ctrl_wk_hdl(struct adapter *padapter, u8 lps_ctrl_type) +{ + struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + u8 mstatus; + +_func_enter_; + + if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) || + (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) + return; + + switch (lps_ctrl_type) { + case LPS_CTRL_SCAN: + if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + /* connect */ + LPS_Leave(padapter); + } + break; + case LPS_CTRL_JOINBSS: + LPS_Leave(padapter); + break; + case LPS_CTRL_CONNECT: + mstatus = 1;/* connect */ + /* Reset LPS Setting */ + padapter->pwrctrlpriv.LpsIdleCount = 0; + rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_JOINBSSRPT, (u8 *)(&mstatus)); + break; + case LPS_CTRL_DISCONNECT: + mstatus = 0;/* disconnect */ + LPS_Leave(padapter); + rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_JOINBSSRPT, (u8 *)(&mstatus)); + break; + case LPS_CTRL_SPECIAL_PACKET: + /* DBG_88E("LPS_CTRL_SPECIAL_PACKET\n"); */ + pwrpriv->DelayLPSLastTimeStamp = rtw_get_current_time(); + LPS_Leave(padapter); + break; + case LPS_CTRL_LEAVE: + LPS_Leave(padapter); + break; + default: + break; + } + +_func_exit_; +} + +u8 rtw_lps_ctrl_wk_cmd(struct adapter *padapter, u8 lps_ctrl_type, u8 enqueue) +{ + struct cmd_obj *ph2c; + struct drvextra_cmd_parm *pdrvextra_cmd_parm; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + /* struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv; */ + u8 res = _SUCCESS; + +_func_enter_; + + /* if (!pwrctrlpriv->bLeisurePs) */ + /* return res; */ + + if (enqueue) { + ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + + pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); + if (pdrvextra_cmd_parm == NULL) { + kfree(ph2c); + res = _FAIL; + goto exit; + } + + pdrvextra_cmd_parm->ec_id = LPS_CTRL_WK_CID; + pdrvextra_cmd_parm->type_size = lps_ctrl_type; + pdrvextra_cmd_parm->pbuf = NULL; + + init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra)); + + res = rtw_enqueue_cmd(pcmdpriv, ph2c); + } else { + lps_ctrl_wk_hdl(padapter, lps_ctrl_type); + } + +exit: + +_func_exit_; + + return res; +} + +static void rpt_timer_setting_wk_hdl(struct adapter *padapter, u16 min_time) +{ + rtw_hal_set_hwreg(padapter, HW_VAR_RPT_TIMER_SETTING, (u8 *)(&min_time)); +} + +u8 rtw_rpt_timer_cfg_cmd(struct adapter *padapter, u16 min_time) +{ + struct cmd_obj *ph2c; + struct drvextra_cmd_parm *pdrvextra_cmd_parm; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + + u8 res = _SUCCESS; + +_func_enter_; + ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + + pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); + if (pdrvextra_cmd_parm == NULL) { + kfree(ph2c); + res = _FAIL; + goto exit; + } + + pdrvextra_cmd_parm->ec_id = RTP_TIMER_CFG_WK_CID; + pdrvextra_cmd_parm->type_size = min_time; + pdrvextra_cmd_parm->pbuf = NULL; + init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra)); + res = rtw_enqueue_cmd(pcmdpriv, ph2c); +exit: + +_func_exit_; + + return res; +} + +static void antenna_select_wk_hdl(struct adapter *padapter, u8 antenna) +{ + rtw_hal_set_hwreg(padapter, HW_VAR_ANTENNA_DIVERSITY_SELECT, (u8 *)(&antenna)); +} + +u8 rtw_antenna_select_cmd(struct adapter *padapter, u8 antenna, u8 enqueue) +{ + struct cmd_obj *ph2c; + struct drvextra_cmd_parm *pdrvextra_cmd_parm; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 support_ant_div; + u8 res = _SUCCESS; + +_func_enter_; + rtw_hal_get_def_var(padapter, HAL_DEF_IS_SUPPORT_ANT_DIV, &support_ant_div); + if (!support_ant_div) + return res; + + if (enqueue) { + ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + + pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); + if (pdrvextra_cmd_parm == NULL) { + kfree(ph2c); + res = _FAIL; + goto exit; + } + + pdrvextra_cmd_parm->ec_id = ANT_SELECT_WK_CID; + pdrvextra_cmd_parm->type_size = antenna; + pdrvextra_cmd_parm->pbuf = NULL; + init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra)); + + res = rtw_enqueue_cmd(pcmdpriv, ph2c); + } else { + antenna_select_wk_hdl(padapter, antenna); + } +exit: + +_func_exit_; + + return res; +} + +static void power_saving_wk_hdl(struct adapter *padapter, u8 *pbuf, int sz) +{ + rtw_ps_processor(padapter); +} + +#ifdef CONFIG_88EU_P2P +u8 p2p_protocol_wk_cmd(struct adapter *padapter, int intCmdType) +{ + struct cmd_obj *ph2c; + struct drvextra_cmd_parm *pdrvextra_cmd_parm; + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; + +_func_enter_; + + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) + return res; + + ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + + pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); + if (pdrvextra_cmd_parm == NULL) { + kfree(ph2c); + res = _FAIL; + goto exit; + } + + pdrvextra_cmd_parm->ec_id = P2P_PROTO_WK_CID; + pdrvextra_cmd_parm->type_size = intCmdType; /* As the command tppe. */ + pdrvextra_cmd_parm->pbuf = NULL; /* Must be NULL here */ + + init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra)); + + res = rtw_enqueue_cmd(pcmdpriv, ph2c); + +exit: + +_func_exit_; + + return res; +} +#endif /* CONFIG_88EU_P2P */ + +u8 rtw_ps_cmd(struct adapter *padapter) +{ + struct cmd_obj *ppscmd; + struct drvextra_cmd_parm *pdrvextra_cmd_parm; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + + u8 res = _SUCCESS; +_func_enter_; + + ppscmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ppscmd == NULL) { + res = _FAIL; + goto exit; + } + + pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); + if (pdrvextra_cmd_parm == NULL) { + kfree(ppscmd); + res = _FAIL; + goto exit; + } + + pdrvextra_cmd_parm->ec_id = POWER_SAVING_CTRL_WK_CID; + pdrvextra_cmd_parm->pbuf = NULL; + init_h2fwcmd_w_parm_no_rsp(ppscmd, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra)); + + res = rtw_enqueue_cmd(pcmdpriv, ppscmd); + +exit: + +_func_exit_; + + return res; +} + +#ifdef CONFIG_88EU_AP_MODE + +static void rtw_chk_hi_queue_hdl(struct adapter *padapter) +{ + int cnt = 0; + struct sta_info *psta_bmc; + struct sta_priv *pstapriv = &padapter->stapriv; + + psta_bmc = rtw_get_bcmc_stainfo(padapter); + if (!psta_bmc) + return; + + if (psta_bmc->sleepq_len == 0) { + u8 val = 0; + + /* while ((rtw_read32(padapter, 0x414)&0x00ffff00)!= 0) */ + /* while ((rtw_read32(padapter, 0x414)&0x0000ff00)!= 0) */ + + rtw_hal_get_hwreg(padapter, HW_VAR_CHK_HI_QUEUE_EMPTY, &val); + + while (!val) { + rtw_msleep_os(100); + + cnt++; + + if (cnt > 10) + break; + + rtw_hal_get_hwreg(padapter, HW_VAR_CHK_HI_QUEUE_EMPTY, &val); + } + + if (cnt <= 10) { + pstapriv->tim_bitmap &= ~BIT(0); + pstapriv->sta_dz_bitmap &= ~BIT(0); + + update_beacon(padapter, _TIM_IE_, NULL, false); + } else { /* re check again */ + rtw_chk_hi_queue_cmd(padapter); + } + } +} + +u8 rtw_chk_hi_queue_cmd(struct adapter *padapter) +{ + struct cmd_obj *ph2c; + struct drvextra_cmd_parm *pdrvextra_cmd_parm; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; + + ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + + pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); + if (pdrvextra_cmd_parm == NULL) { + kfree(ph2c); + res = _FAIL; + goto exit; + } + + pdrvextra_cmd_parm->ec_id = CHECK_HIQ_WK_CID; + pdrvextra_cmd_parm->type_size = 0; + pdrvextra_cmd_parm->pbuf = NULL; + + init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra)); + + res = rtw_enqueue_cmd(pcmdpriv, ph2c); +exit: + return res; +} +#endif + +u8 rtw_c2h_wk_cmd(struct adapter *padapter, u8 *c2h_evt) +{ + struct cmd_obj *ph2c; + struct drvextra_cmd_parm *pdrvextra_cmd_parm; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; + + ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + + pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); + if (pdrvextra_cmd_parm == NULL) { + kfree(ph2c); + res = _FAIL; + goto exit; + } + + pdrvextra_cmd_parm->ec_id = C2H_WK_CID; + pdrvextra_cmd_parm->type_size = c2h_evt ? 16 : 0; + pdrvextra_cmd_parm->pbuf = c2h_evt; + + init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra)); + + res = rtw_enqueue_cmd(pcmdpriv, ph2c); + +exit: + + return res; +} + +static s32 c2h_evt_hdl(struct adapter *adapter, struct c2h_evt_hdr *c2h_evt, c2h_id_filter filter) +{ + s32 ret = _FAIL; + u8 buf[16]; + + if (!c2h_evt) { + /* No c2h event in cmd_obj, read c2h event before handling*/ + if (c2h_evt_read(adapter, buf) == _SUCCESS) { + c2h_evt = (struct c2h_evt_hdr *)buf; + + if (filter && filter(c2h_evt->id) == false) + goto exit; + + ret = rtw_hal_c2h_handler(adapter, c2h_evt); + } + } else { + if (filter && filter(c2h_evt->id) == false) + goto exit; + + ret = rtw_hal_c2h_handler(adapter, c2h_evt); + } +exit: + return ret; +} + +static void c2h_wk_callback(struct work_struct *work) +{ + struct evt_priv *evtpriv = container_of(work, struct evt_priv, c2h_wk); + struct adapter *adapter = container_of(evtpriv, struct adapter, evtpriv); + struct c2h_evt_hdr *c2h_evt; + c2h_id_filter ccx_id_filter = rtw_hal_c2h_id_filter_ccx(adapter); + + evtpriv->c2h_wk_alive = true; + + while (!rtw_cbuf_empty(evtpriv->c2h_queue)) { + if ((c2h_evt = (struct c2h_evt_hdr *)rtw_cbuf_pop(evtpriv->c2h_queue)) != NULL) { + /* This C2H event is read, clear it */ + c2h_evt_clear(adapter); + } else if ((c2h_evt = (struct c2h_evt_hdr *)rtw_malloc(16)) != NULL) { + /* This C2H event is not read, read & clear now */ + if (c2h_evt_read(adapter, (u8 *)c2h_evt) != _SUCCESS) + continue; + } + + /* Special pointer to trigger c2h_evt_clear only */ + if ((void *)c2h_evt == (void *)evtpriv) + continue; + + if (!c2h_evt_exist(c2h_evt)) { + kfree(c2h_evt); + continue; + } + + if (ccx_id_filter(c2h_evt->id) == true) { + /* Handle CCX report here */ + rtw_hal_c2h_handler(adapter, c2h_evt); + kfree(c2h_evt); + } else { +#ifdef CONFIG_88EU_P2P + /* Enqueue into cmd_thread for others */ + rtw_c2h_wk_cmd(adapter, (u8 *)c2h_evt); +#endif + } + } + + evtpriv->c2h_wk_alive = false; +} + +u8 rtw_drvextra_cmd_hdl(struct adapter *padapter, unsigned char *pbuf) +{ + struct drvextra_cmd_parm *pdrvextra_cmd; + + if (!pbuf) + return H2C_PARAMETERS_ERROR; + + pdrvextra_cmd = (struct drvextra_cmd_parm *)pbuf; + + switch (pdrvextra_cmd->ec_id) { + case DYNAMIC_CHK_WK_CID: + dynamic_chk_wk_hdl(padapter, pdrvextra_cmd->pbuf, pdrvextra_cmd->type_size); + break; + case POWER_SAVING_CTRL_WK_CID: + power_saving_wk_hdl(padapter, pdrvextra_cmd->pbuf, pdrvextra_cmd->type_size); + break; + case LPS_CTRL_WK_CID: + lps_ctrl_wk_hdl(padapter, (u8)pdrvextra_cmd->type_size); + break; + case RTP_TIMER_CFG_WK_CID: + rpt_timer_setting_wk_hdl(padapter, pdrvextra_cmd->type_size); + break; + case ANT_SELECT_WK_CID: + antenna_select_wk_hdl(padapter, pdrvextra_cmd->type_size); + break; +#ifdef CONFIG_88EU_P2P + case P2P_PS_WK_CID: + p2p_ps_wk_hdl(padapter, pdrvextra_cmd->type_size); + break; + case P2P_PROTO_WK_CID: + /* Commented by Albert 2011/07/01 */ + /* I used the type_size as the type command */ + p2p_protocol_wk_hdl(padapter, pdrvextra_cmd->type_size); + break; +#endif +#ifdef CONFIG_88EU_AP_MODE + case CHECK_HIQ_WK_CID: + rtw_chk_hi_queue_hdl(padapter); + break; +#endif /* CONFIG_88EU_AP_MODE */ + case C2H_WK_CID: + c2h_evt_hdl(padapter, (struct c2h_evt_hdr *)pdrvextra_cmd->pbuf, NULL); + break; + default: + break; + } + + if (pdrvextra_cmd->pbuf && pdrvextra_cmd->type_size > 0) + kfree(pdrvextra_cmd->pbuf); + + return H2C_SUCCESS; +} + +void rtw_survey_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd) +{ + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + +_func_enter_; + + if (pcmd->res == H2C_DROPPED) { + /* TODO: cancel timer and do timeout handler directly... */ + /* need to make timeout handlerOS independent */ + _set_timer(&pmlmepriv->scan_to_timer, 1); + } else if (pcmd->res != H2C_SUCCESS) { + _set_timer(&pmlmepriv->scan_to_timer, 1); + RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\n ********Error: MgntActrtw_set_802_11_bssid_LIST_SCAN Fail ************\n\n.")); + } + + /* free cmd */ + rtw_free_cmd_obj(pcmd); + +_func_exit_; +} +void rtw_disassoc_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd) +{ + unsigned long irqL; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + +_func_enter_; + + if (pcmd->res != H2C_SUCCESS) { + _enter_critical_bh(&pmlmepriv->lock, &irqL); + set_fwstate(pmlmepriv, _FW_LINKED); + _exit_critical_bh(&pmlmepriv->lock, &irqL); + + RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\n ***Error: disconnect_cmd_callback Fail ***\n.")); + + goto exit; + } else /* clear bridge database */ + nat25_db_cleanup(padapter); + + /* free cmd */ + rtw_free_cmd_obj(pcmd); + +exit: + +_func_exit_; +} + +void rtw_joinbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd) +{ + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + +_func_enter_; + + if (pcmd->res == H2C_DROPPED) { + /* TODO: cancel timer and do timeout handler directly... */ + /* need to make timeout handlerOS independent */ + _set_timer(&pmlmepriv->assoc_timer, 1); + } else if (pcmd->res != H2C_SUCCESS) { + RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("********Error:rtw_select_and_join_from_scanned_queue Wait Sema Fail ************\n")); + _set_timer(&pmlmepriv->assoc_timer, 1); + } + + rtw_free_cmd_obj(pcmd); + +_func_exit_; +} + +void rtw_createbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd) +{ + unsigned long irqL; + u8 timer_cancelled; + struct sta_info *psta = NULL; + struct wlan_network *pwlan = NULL; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)pcmd->parmbuf; + struct wlan_network *tgt_network = &(pmlmepriv->cur_network); + +_func_enter_; + + if ((pcmd->res != H2C_SUCCESS)) { + RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\n ********Error: rtw_createbss_cmd_callback Fail ************\n\n.")); + _set_timer(&pmlmepriv->assoc_timer, 1); + } + + _cancel_timer(&pmlmepriv->assoc_timer, &timer_cancelled); + + _enter_critical_bh(&pmlmepriv->lock, &irqL); + + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { + psta = rtw_get_stainfo(&padapter->stapriv, pnetwork->MacAddress); + if (!psta) { + psta = rtw_alloc_stainfo(&padapter->stapriv, pnetwork->MacAddress); + if (psta == NULL) { + RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\nCan't alloc sta_info when createbss_cmd_callback\n")); + goto createbss_cmd_fail ; + } + } + + rtw_indicate_connect(padapter); + } else { + unsigned long irqL; + + pwlan = _rtw_alloc_network(pmlmepriv); + _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); + if (pwlan == NULL) { + pwlan = rtw_get_oldest_wlan_network(&pmlmepriv->scanned_queue); + if (pwlan == NULL) { + RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\n Error: can't get pwlan in rtw_joinbss_event_callback\n")); + _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); + goto createbss_cmd_fail; + } + pwlan->last_scanned = rtw_get_current_time(); + } else { + rtw_list_insert_tail(&(pwlan->list), &pmlmepriv->scanned_queue.queue); + } + + pnetwork->Length = get_wlan_bssid_ex_sz(pnetwork); + memcpy(&(pwlan->network), pnetwork, pnetwork->Length); + + memcpy(&tgt_network->network, pnetwork, (get_wlan_bssid_ex_sz(pnetwork))); + + _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); + + _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); + /* we will set _FW_LINKED when there is one more sat to join us (rtw_stassoc_event_callback) */ + } + +createbss_cmd_fail: + + _exit_critical_bh(&pmlmepriv->lock, &irqL); + + rtw_free_cmd_obj(pcmd); + +_func_exit_; +} + +void rtw_setstaKey_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pcmd) +{ + struct sta_priv *pstapriv = &padapter->stapriv; + struct set_stakey_rsp *psetstakey_rsp = (struct set_stakey_rsp *)(pcmd->rsp); + struct sta_info *psta = rtw_get_stainfo(pstapriv, psetstakey_rsp->addr); + +_func_enter_; + + if (psta == NULL) { + RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\nERROR: rtw_setstaKey_cmdrsp_callback => can't get sta_info\n\n")); + goto exit; + } +exit: + rtw_free_cmd_obj(pcmd); +_func_exit_; +} + +void rtw_setassocsta_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pcmd) +{ + unsigned long irqL; + struct sta_priv *pstapriv = &padapter->stapriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct set_assocsta_parm *passocsta_parm = (struct set_assocsta_parm *)(pcmd->parmbuf); + struct set_assocsta_rsp *passocsta_rsp = (struct set_assocsta_rsp *)(pcmd->rsp); + struct sta_info *psta = rtw_get_stainfo(pstapriv, passocsta_parm->addr); + +_func_enter_; + + if (psta == NULL) { + RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\nERROR: setassocsta_cmdrsp_callbac => can't get sta_info\n\n")); + goto exit; + } + + psta->aid = passocsta_rsp->cam_id; + psta->mac_id = passocsta_rsp->cam_id; + + _enter_critical_bh(&pmlmepriv->lock, &irqL); + + if ((check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) && (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true)) + _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); + + set_fwstate(pmlmepriv, _FW_LINKED); + _exit_critical_bh(&pmlmepriv->lock, &irqL); + +exit: + rtw_free_cmd_obj(pcmd); + +_func_exit_; +} -- GitLab From 06a0588468873d3086d199268dfb78658cf223af Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 21 Aug 2013 22:33:44 -0500 Subject: [PATCH 760/942] staging: r8188eu: Add files for new driver - part 2 This commit adds core/rtw_debug.c, core/rtw_efuse.c, and core/rtw_ieee80211.c Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_debug.c | 948 ++++++++++ drivers/staging/rtl8188eu/core/rtw_efuse.c | 875 +++++++++ .../staging/rtl8188eu/core/rtw_ieee80211.c | 1640 +++++++++++++++++ 3 files changed, 3463 insertions(+) create mode 100644 drivers/staging/rtl8188eu/core/rtw_debug.c create mode 100644 drivers/staging/rtl8188eu/core/rtw_efuse.c create mode 100644 drivers/staging/rtl8188eu/core/rtw_ieee80211.c diff --git a/drivers/staging/rtl8188eu/core/rtw_debug.c b/drivers/staging/rtl8188eu/core/rtw_debug.c new file mode 100644 index 0000000000000..0fe5f5de54a91 --- /dev/null +++ b/drivers/staging/rtl8188eu/core/rtw_debug.c @@ -0,0 +1,948 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTW_DEBUG_C_ + +#include +#include + +int proc_get_drv_version(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + int len = 0; + + len += snprintf(page + len, count - len, "%s\n", DRIVERVERSION); + + *eof = 1; + return len; +} + +int proc_get_write_reg(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + *eof = 1; + return 0; +} + +int proc_set_write_reg(struct file *file, const char __user *buffer, + unsigned long count, void *data) +{ + struct net_device *dev = (struct net_device *)data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + char tmp[32]; + u32 addr, val, len; + + if (count < 3) { + DBG_88E("argument size is less than 3\n"); + return -EFAULT; + } + + if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) { + int num = sscanf(tmp, "%x %x %x", &addr, &val, &len); + + if (num != 3) { + DBG_88E("invalid write_reg parameter!\n"); + return count; + } + switch (len) { + case 1: + rtw_write8(padapter, addr, (u8)val); + break; + case 2: + rtw_write16(padapter, addr, (u16)val); + break; + case 4: + rtw_write32(padapter, addr, val); + break; + default: + DBG_88E("error write length =%d", len); + break; + } + } + return count; +} + +static u32 proc_get_read_addr = 0xeeeeeeee; +static u32 proc_get_read_len = 0x4; + +int proc_get_read_reg(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + + int len = 0; + + if (proc_get_read_addr == 0xeeeeeeee) { + *eof = 1; + return len; + } + + switch (proc_get_read_len) { + case 1: + len += snprintf(page + len, count - len, "rtw_read8(0x%x)=0x%x\n", proc_get_read_addr, rtw_read8(padapter, proc_get_read_addr)); + break; + case 2: + len += snprintf(page + len, count - len, "rtw_read16(0x%x)=0x%x\n", proc_get_read_addr, rtw_read16(padapter, proc_get_read_addr)); + break; + case 4: + len += snprintf(page + len, count - len, "rtw_read32(0x%x)=0x%x\n", proc_get_read_addr, rtw_read32(padapter, proc_get_read_addr)); + break; + default: + len += snprintf(page + len, count - len, "error read length=%d\n", proc_get_read_len); + break; + } + + *eof = 1; + return len; +} + +int proc_set_read_reg(struct file *file, const char __user *buffer, + unsigned long count, void *data) +{ + char tmp[16]; + u32 addr, len; + + if (count < 2) { + DBG_88E("argument size is less than 2\n"); + return -EFAULT; + } + + if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) { + int num = sscanf(tmp, "%x %x", &addr, &len); + + if (num != 2) { + DBG_88E("invalid read_reg parameter!\n"); + return count; + } + + proc_get_read_addr = addr; + + proc_get_read_len = len; + } + + return count; +} + +int proc_get_fwstate(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + + int len = 0; + + len += snprintf(page + len, count - len, "fwstate=0x%x\n", get_fwstate(pmlmepriv)); + + *eof = 1; + return len; +} + +int proc_get_sec_info(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct security_priv *psecuritypriv = &padapter->securitypriv; + + int len = 0; + + len += snprintf(page + len, count - len, "auth_alg=0x%x, enc_alg=0x%x, auth_type=0x%x, enc_type=0x%x\n", + psecuritypriv->dot11AuthAlgrthm, psecuritypriv->dot11PrivacyAlgrthm, + psecuritypriv->ndisauthtype, psecuritypriv->ndisencryptstatus); + + *eof = 1; + return len; +} + +int proc_get_mlmext_state(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + int len = 0; + + len += snprintf(page + len, count - len, "pmlmeinfo->state=0x%x\n", pmlmeinfo->state); + + *eof = 1; + return len; +} + +int proc_get_qos_option(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + + int len = 0; + + len += snprintf(page + len, count - len, "qos_option=%d\n", pmlmepriv->qospriv.qos_option); + + *eof = 1; + return len; +} + +int proc_get_ht_option(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + + int len = 0; + len += snprintf(page + len, count - len, "ht_option=%d\n", pmlmepriv->htpriv.ht_option); + *eof = 1; + return len; +} + +int proc_get_rf_info(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + int len = 0; + + len += snprintf(page + len, count - len, "cur_ch=%d, cur_bw=%d, cur_ch_offet=%d\n", + pmlmeext->cur_channel, pmlmeext->cur_bwmode, pmlmeext->cur_ch_offset); + *eof = 1; + return len; +} + +int proc_get_ap_info(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct sta_info *psta; + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct wlan_network *cur_network = &(pmlmepriv->cur_network); + struct sta_priv *pstapriv = &padapter->stapriv; + int len = 0; + + psta = rtw_get_stainfo(pstapriv, cur_network->network.MacAddress); + if (psta) { + int i; + struct recv_reorder_ctrl *preorder_ctrl; + + len += snprintf(page + len, count - len, "SSID=%s\n", cur_network->network.Ssid.Ssid); + len += snprintf(page + len, count - len, "sta's macaddr:%pM\n", psta->hwaddr); + len += snprintf(page + len, count - len, "cur_channel=%d, cur_bwmode=%d, cur_ch_offset=%d\n", pmlmeext->cur_channel, pmlmeext->cur_bwmode, pmlmeext->cur_ch_offset); + len += snprintf(page + len, count - len, "rtsen=%d, cts2slef=%d\n", psta->rtsen, psta->cts2self); + len += snprintf(page + len, count - len, "state=0x%x, aid=%d, macid=%d, raid=%d\n", psta->state, psta->aid, psta->mac_id, psta->raid); + len += snprintf(page + len, count - len, "qos_en=%d, ht_en=%d, init_rate=%d\n", psta->qos_option, psta->htpriv.ht_option, psta->init_rate); + len += snprintf(page + len, count - len, "bwmode=%d, ch_offset=%d, sgi=%d\n", psta->htpriv.bwmode, psta->htpriv.ch_offset, psta->htpriv.sgi); + len += snprintf(page + len, count - len, "ampdu_enable = %d\n", psta->htpriv.ampdu_enable); + len += snprintf(page + len, count - len, "agg_enable_bitmap=%x, candidate_tid_bitmap=%x\n", psta->htpriv.agg_enable_bitmap, psta->htpriv.candidate_tid_bitmap); + + for (i = 0; i < 16; i++) { + preorder_ctrl = &psta->recvreorder_ctrl[i]; + if (preorder_ctrl->enable) + len += snprintf(page + len, count - len, "tid=%d, indicate_seq=%d\n", i, preorder_ctrl->indicate_seq); + } + } else { + len += snprintf(page + len, count - len, "can't get sta's macaddr, cur_network's macaddr: %pM\n", cur_network->network.MacAddress); + } + + *eof = 1; + return len; +} + +int proc_get_adapter_state(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + int len = 0; + + len += snprintf(page + len, count - len, "bSurpriseRemoved=%d, bDriverStopped=%d\n", + padapter->bSurpriseRemoved, padapter->bDriverStopped); + + *eof = 1; + return len; +} + +int proc_get_trx_info(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct recv_priv *precvpriv = &padapter->recvpriv; + int len = 0; + + len += snprintf(page + len, count - len, "free_xmitbuf_cnt=%d, free_xmitframe_cnt=%d, free_ext_xmitbuf_cnt=%d, free_recvframe_cnt=%d\n", + pxmitpriv->free_xmitbuf_cnt, pxmitpriv->free_xmitframe_cnt, pxmitpriv->free_xmit_extbuf_cnt, precvpriv->free_recvframe_cnt); + len += snprintf(page + len, count - len, "rx_urb_pending_cn=%d\n", precvpriv->rx_pending_cnt); + + *eof = 1; + return len; +} + +int proc_get_mac_reg_dump1(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + int len = 0; + int i, j = 1; + + len += snprintf(page + len, count - len, "\n======= MAC REG =======\n"); + + for (i = 0x0; i < 0x300; i += 4) { + if (j%4 == 1) + len += snprintf(page + len, count - len, "0x%02x", i); + len += snprintf(page + len, count - len, " 0x%08x ", rtw_read32(padapter, i)); + if ((j++)%4 == 0) + len += snprintf(page + len, count - len, "\n"); + } + + *eof = 1; + return len; +} + +int proc_get_mac_reg_dump2(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + int len = 0; + int i, j = 1; + + len += snprintf(page + len, count - len, "\n======= MAC REG =======\n"); + memset(page, 0, count); + for (i = 0x300; i < 0x600; i += 4) { + if (j%4 == 1) + len += snprintf(page + len, count - len, "0x%02x", i); + len += snprintf(page + len, count - len, " 0x%08x ", rtw_read32(padapter, i)); + if ((j++)%4 == 0) + len += snprintf(page + len, count - len, "\n"); + } + + *eof = 1; + return len; +} + +int proc_get_mac_reg_dump3(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + int len = 0; + int i, j = 1; + + len += snprintf(page + len, count - len, "\n======= MAC REG =======\n"); + + for (i = 0x600; i < 0x800; i += 4) { + if (j%4 == 1) + len += snprintf(page + len, count - len, "0x%02x", i); + len += snprintf(page + len, count - len, " 0x%08x ", rtw_read32(padapter, i)); + if ((j++)%4 == 0) + len += snprintf(page + len, count - len, "\n"); + } + + *eof = 1; + return len; +} + +int proc_get_bb_reg_dump1(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + int len = 0; + int i, j = 1; + + len += snprintf(page + len, count - len, "\n======= BB REG =======\n"); + for (i = 0x800; i < 0xB00; i += 4) { + if (j%4 == 1) + len += snprintf(page + len, count - len, "0x%02x", i); + len += snprintf(page + len, count - len, " 0x%08x ", rtw_read32(padapter, i)); + if ((j++)%4 == 0) + len += snprintf(page + len, count - len, "\n"); + } + *eof = 1; + return len; +} + +int proc_get_bb_reg_dump2(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + int len = 0; + int i, j = 1; + + len += snprintf(page + len, count - len, "\n======= BB REG =======\n"); + for (i = 0xB00; i < 0xE00; i += 4) { + if (j%4 == 1) + len += snprintf(page + len, count - len, "0x%02x", i); + len += snprintf(page + len, count - len, " 0x%08x ", rtw_read32(padapter, i)); + if ((j++)%4 == 0) + len += snprintf(page + len, count - len, "\n"); + } + *eof = 1; + return len; +} + +int proc_get_bb_reg_dump3(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + int len = 0; + int i, j = 1; + + len += snprintf(page + len, count - len, "\n======= BB REG =======\n"); + for (i = 0xE00; i < 0x1000; i += 4) { + if (j%4 == 1) + len += snprintf(page + len, count - len, "0x%02x", i); + len += snprintf(page + len, count - len, " 0x%08x ", rtw_read32(padapter, i)); + if ((j++)%4 == 0) + len += snprintf(page + len, count - len, "\n"); + } + *eof = 1; + return len; +} + +int proc_get_rf_reg_dump1(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + int len = 0; + int i, j = 1, path; + u32 value; + + len += snprintf(page + len, count - len, "\n======= RF REG =======\n"); + path = 1; + len += snprintf(page + len, count - len, "\nRF_Path(%x)\n", path); + for (i = 0; i < 0xC0; i++) { + value = rtw_hal_read_rfreg(padapter, path, i, 0xffffffff); + if (j%4 == 1) + len += snprintf(page + len, count - len, "0x%02x ", i); + len += snprintf(page + len, count - len, " 0x%08x ", value); + if ((j++)%4 == 0) + len += snprintf(page + len, count - len, "\n"); + } + *eof = 1; + return len; +} + +int proc_get_rf_reg_dump2(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + int len = 0; + int i, j = 1, path; + u32 value; + + len += snprintf(page + len, count - len, "\n======= RF REG =======\n"); + path = 1; + len += snprintf(page + len, count - len, "\nRF_Path(%x)\n", path); + for (i = 0xC0; i < 0x100; i++) { + value = rtw_hal_read_rfreg(padapter, path, i, 0xffffffff); + if (j%4 == 1) + len += snprintf(page + len, count - len, "0x%02x ", i); + len += snprintf(page + len, count - len, " 0x%08x ", value); + if ((j++)%4 == 0) + len += snprintf(page + len, count - len, "\n"); + } + *eof = 1; + return len; +} + +int proc_get_rf_reg_dump3(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + int len = 0; + int i, j = 1, path; + u32 value; + + len += snprintf(page + len, count - len, "\n======= RF REG =======\n"); + path = 2; + len += snprintf(page + len, count - len, "\nRF_Path(%x)\n", path); + for (i = 0; i < 0xC0; i++) { + value = rtw_hal_read_rfreg(padapter, path, i, 0xffffffff); + if (j%4 == 1) + len += snprintf(page + len, count - len, "0x%02x ", i); + len += snprintf(page + len, count - len, " 0x%08x ", value); + if ((j++)%4 == 0) + len += snprintf(page + len, count - len, "\n"); + } + + *eof = 1; + return len; +} + + +int proc_get_rf_reg_dump4(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + int len = 0; + int i, j = 1, path; + u32 value; + + len += snprintf(page + len, count - len, "\n======= RF REG =======\n"); + path = 2; + len += snprintf(page + len, count - len, "\nRF_Path(%x)\n", path); + for (i = 0xC0; i < 0x100; i++) { + value = rtw_hal_read_rfreg(padapter, path, i, 0xffffffff); + if (j%4 == 1) + len += snprintf(page + len, count - len, "0x%02x ", i); + len += snprintf(page + len, count - len, " 0x%08x ", value); + if ((j++)%4 == 0) + len += snprintf(page + len, count - len, "\n"); + } + *eof = 1; + return len; +} + + + +int proc_get_rx_signal(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + int len = 0; + + len = snprintf(page + len, count, + "rssi:%d\n" + "rxpwdb:%d\n" + "signal_strength:%u\n" + "signal_qual:%u\n" + "noise:%u\n", + padapter->recvpriv.rssi, + padapter->recvpriv.rxpwdb, + padapter->recvpriv.signal_strength, + padapter->recvpriv.signal_qual, + padapter->recvpriv.noise + ); + + *eof = 1; + return len; +} + +int proc_set_rx_signal(struct file *file, const char __user *buffer, + unsigned long count, void *data) +{ + struct net_device *dev = (struct net_device *)data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + char tmp[32]; + u32 is_signal_dbg; + s32 signal_strength; + + if (count < 1) + return -EFAULT; + + if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) { + int num = sscanf(tmp, "%u %u", &is_signal_dbg, &signal_strength); + is_signal_dbg = is_signal_dbg == 0 ? 0 : 1; + if (is_signal_dbg && num != 2) + return count; + + signal_strength = signal_strength > 100 ? 100 : signal_strength; + signal_strength = signal_strength < 0 ? 0 : signal_strength; + + padapter->recvpriv.is_signal_dbg = is_signal_dbg; + padapter->recvpriv.signal_strength_dbg = signal_strength; + + if (is_signal_dbg) + DBG_88E("set %s %u\n", "DBG_SIGNAL_STRENGTH", signal_strength); + else + DBG_88E("set %s\n", "HW_SIGNAL_STRENGTH"); + } + return count; +} + +int proc_get_ht_enable(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct registry_priv *pregpriv = &padapter->registrypriv; + int len = 0; + + if (pregpriv) + len += snprintf(page + len, count - len, + "%d\n", + pregpriv->ht_enable + ); + *eof = 1; + return len; +} + +int proc_set_ht_enable(struct file *file, const char __user *buffer, + unsigned long count, void *data) +{ + struct net_device *dev = (struct net_device *)data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct registry_priv *pregpriv = &padapter->registrypriv; + char tmp[32]; + s32 mode = 0; + + if (count < 1) + return -EFAULT; + + if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) { + if (pregpriv) { + pregpriv->ht_enable = mode; + pr_info("ht_enable=%d\n", pregpriv->ht_enable); + } + } + + return count; +} + +int proc_get_cbw40_enable(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct registry_priv *pregpriv = &padapter->registrypriv; + + int len = 0; + + if (pregpriv) + len += snprintf(page + len, count - len, + "%d\n", + pregpriv->cbw40_enable + ); + + *eof = 1; + return len; +} + +int proc_set_cbw40_enable(struct file *file, const char __user *buffer, + unsigned long count, void *data) +{ + struct net_device *dev = (struct net_device *)data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct registry_priv *pregpriv = &padapter->registrypriv; + char tmp[32]; + s32 mode = 0; + + if (count < 1) + return -EFAULT; + + if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) { + if (pregpriv) { + pregpriv->cbw40_enable = mode; + pr_info("cbw40_enable=%d\n", mode); + } + } + return count; +} + +int proc_get_ampdu_enable(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct registry_priv *pregpriv = &padapter->registrypriv; + + int len = 0; + + if (pregpriv) + len += snprintf(page + len, count - len, + "%d\n", + pregpriv->ampdu_enable + ); + + *eof = 1; + return len; +} + +int proc_set_ampdu_enable(struct file *file, const char __user *buffer, + unsigned long count, void *data) +{ + struct net_device *dev = (struct net_device *)data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct registry_priv *pregpriv = &padapter->registrypriv; + char tmp[32]; + s32 mode = 0; + + if (count < 1) + return -EFAULT; + + if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) { + if (pregpriv) { + pregpriv->ampdu_enable = mode; + pr_info("ampdu_enable=%d\n", mode); + } + } + return count; +} + +int proc_get_two_path_rssi(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + + int len = 0; + + if (padapter) + len += snprintf(page + len, count - len, + "%d %d\n", + padapter->recvpriv.RxRssi[0], + padapter->recvpriv.RxRssi[1] + ); + + *eof = 1; + return len; +} + +int proc_get_rx_stbc(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct registry_priv *pregpriv = &padapter->registrypriv; + + int len = 0; + + if (pregpriv) + len += snprintf(page + len, count - len, + "%d\n", + pregpriv->rx_stbc + ); + + *eof = 1; + return len; +} + +int proc_set_rx_stbc(struct file *file, const char __user *buffer, + unsigned long count, void *data) +{ + struct net_device *dev = (struct net_device *)data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct registry_priv *pregpriv = &padapter->registrypriv; + char tmp[32]; + u32 mode = 0; + + if (count < 1) + return -EFAULT; + + if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) { + if (pregpriv) { + pregpriv->rx_stbc = mode; + printk("rx_stbc=%d\n", mode); + } + } + return count; +} + +int proc_get_rssi_disp(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + *eof = 1; + return 0; +} + +int proc_set_rssi_disp(struct file *file, const char __user *buffer, + unsigned long count, void *data) +{ + struct net_device *dev = (struct net_device *)data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + char tmp[32]; + u32 enable = 0; + + if (count < 1) { + DBG_88E("argument size is less than 1\n"); + return -EFAULT; + } + + if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) { + int num = sscanf(tmp, "%x", &enable); + + if (num != 1) { + DBG_88E("invalid set_rssi_disp parameter!\n"); + return count; + } + + if (enable) { + DBG_88E("Turn On Rx RSSI Display Function\n"); + padapter->bRxRSSIDisplay = enable ; + } else { + DBG_88E("Turn Off Rx RSSI Display Function\n"); + padapter->bRxRSSIDisplay = 0; + } + } + return count; +} + +#ifdef CONFIG_88EU_AP_MODE + +int proc_get_all_sta_info(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + unsigned long irqL; + struct sta_info *psta; + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct sta_priv *pstapriv = &padapter->stapriv; + int i, j; + struct list_head *plist, *phead; + struct recv_reorder_ctrl *preorder_ctrl; + int len = 0; + + + len += snprintf(page + len, count - len, "sta_dz_bitmap=0x%x, tim_bitmap=0x%x\n", pstapriv->sta_dz_bitmap, pstapriv->tim_bitmap); + + _enter_critical_bh(&pstapriv->sta_hash_lock, &irqL); + + for (i = 0; i < NUM_STA; i++) { + phead = &(pstapriv->sta_hash[i]); + plist = get_next(phead); + + while ((rtw_end_of_queue_search(phead, plist)) == false) { + psta = LIST_CONTAINOR(plist, struct sta_info, hash_list); + + plist = get_next(plist); + + len += snprintf(page + len, count - len, "sta's macaddr: %pM\n", psta->hwaddr); + len += snprintf(page + len, count - len, "rtsen=%d, cts2slef=%d\n", psta->rtsen, psta->cts2self); + len += snprintf(page + len, count - len, "state=0x%x, aid=%d, macid=%d, raid=%d\n", psta->state, psta->aid, psta->mac_id, psta->raid); + len += snprintf(page + len, count - len, "qos_en=%d, ht_en=%d, init_rate=%d\n", psta->qos_option, psta->htpriv.ht_option, psta->init_rate); + len += snprintf(page + len, count - len, "bwmode=%d, ch_offset=%d, sgi=%d\n", psta->htpriv.bwmode, psta->htpriv.ch_offset, psta->htpriv.sgi); + len += snprintf(page + len, count - len, "ampdu_enable = %d\n", psta->htpriv.ampdu_enable); + len += snprintf(page + len, count - len, "agg_enable_bitmap=%x, candidate_tid_bitmap=%x\n", psta->htpriv.agg_enable_bitmap, psta->htpriv.candidate_tid_bitmap); + len += snprintf(page + len, count - len, "sleepq_len=%d\n", psta->sleepq_len); + len += snprintf(page + len, count - len, "capability=0x%x\n", psta->capability); + len += snprintf(page + len, count - len, "flags=0x%x\n", psta->flags); + len += snprintf(page + len, count - len, "wpa_psk=0x%x\n", psta->wpa_psk); + len += snprintf(page + len, count - len, "wpa2_group_cipher=0x%x\n", psta->wpa2_group_cipher); + len += snprintf(page + len, count - len, "wpa2_pairwise_cipher=0x%x\n", psta->wpa2_pairwise_cipher); + len += snprintf(page + len, count - len, "qos_info=0x%x\n", psta->qos_info); + len += snprintf(page + len, count - len, "dot118021XPrivacy=0x%x\n", psta->dot118021XPrivacy); + + for (j = 0; j < 16; j++) { + preorder_ctrl = &psta->recvreorder_ctrl[j]; + if (preorder_ctrl->enable) + len += snprintf(page + len, count - len, "tid=%d, indicate_seq=%d\n", j, preorder_ctrl->indicate_seq); + } + } + } + _exit_critical_bh(&pstapriv->sta_hash_lock, &irqL); + + *eof = 1; + return len; +} +#endif + +int proc_get_best_channel(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + int len = 0; + u32 i, best_channel_24G = 1, best_channel_5G = 36, index_24G = 0, index_5G = 0; + + for (i = 0; pmlmeext->channel_set[i].ChannelNum != 0; i++) { + if (pmlmeext->channel_set[i].ChannelNum == 1) + index_24G = i; + if (pmlmeext->channel_set[i].ChannelNum == 36) + index_5G = i; + } + + for (i = 0; pmlmeext->channel_set[i].ChannelNum != 0; i++) { + /* 2.4G */ + if (pmlmeext->channel_set[i].ChannelNum == 6) { + if (pmlmeext->channel_set[i].rx_count < pmlmeext->channel_set[index_24G].rx_count) { + index_24G = i; + best_channel_24G = pmlmeext->channel_set[i].ChannelNum; + } + } + + /* 5G */ + if (pmlmeext->channel_set[i].ChannelNum >= 36 && + pmlmeext->channel_set[i].ChannelNum < 140) { + /* Find primary channel */ + if (((pmlmeext->channel_set[i].ChannelNum - 36) % 8 == 0) && + (pmlmeext->channel_set[i].rx_count < pmlmeext->channel_set[index_5G].rx_count)) { + index_5G = i; + best_channel_5G = pmlmeext->channel_set[i].ChannelNum; + } + } + + if (pmlmeext->channel_set[i].ChannelNum >= 149 && + pmlmeext->channel_set[i].ChannelNum < 165) { + /* find primary channel */ + if (((pmlmeext->channel_set[i].ChannelNum - 149) % 8 == 0) && + (pmlmeext->channel_set[i].rx_count < pmlmeext->channel_set[index_5G].rx_count)) { + index_5G = i; + best_channel_5G = pmlmeext->channel_set[i].ChannelNum; + } + } + /* debug */ + len += snprintf(page + len, count - len, "The rx cnt of channel %3d = %d\n", + pmlmeext->channel_set[i].ChannelNum, pmlmeext->channel_set[i].rx_count); + } + + len += snprintf(page + len, count - len, "best_channel_5G = %d\n", best_channel_5G); + len += snprintf(page + len, count - len, "best_channel_24G = %d\n", best_channel_24G); + + *eof = 1; + return len; +} diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c b/drivers/staging/rtl8188eu/core/rtw_efuse.c new file mode 100644 index 0000000000000..869434c4cf692 --- /dev/null +++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c @@ -0,0 +1,875 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTW_EFUSE_C_ + +#include +#include +#include + + + +/*------------------------Define local variable------------------------------*/ +u8 fakeEfuseBank; +u32 fakeEfuseUsedBytes; +u8 fakeEfuseContent[EFUSE_MAX_HW_SIZE] = {0}; +u8 fakeEfuseInitMap[EFUSE_MAX_MAP_LEN] = {0}; +u8 fakeEfuseModifiedMap[EFUSE_MAX_MAP_LEN] = {0}; + +u32 BTEfuseUsedBytes; +u8 BTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE]; +u8 BTEfuseInitMap[EFUSE_BT_MAX_MAP_LEN] = {0}; +u8 BTEfuseModifiedMap[EFUSE_BT_MAX_MAP_LEN] = {0}; + +u32 fakeBTEfuseUsedBytes; +u8 fakeBTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE]; +u8 fakeBTEfuseInitMap[EFUSE_BT_MAX_MAP_LEN] = {0}; +u8 fakeBTEfuseModifiedMap[EFUSE_BT_MAX_MAP_LEN] = {0}; +/*------------------------Define local variable------------------------------*/ + +/* */ +#define REG_EFUSE_CTRL 0x0030 +#define EFUSE_CTRL REG_EFUSE_CTRL /* E-Fuse Control. */ +/* */ + +bool +Efuse_Read1ByteFromFakeContent( + struct adapter *pAdapter, + u16 Offset, + u8 *Value); +bool +Efuse_Read1ByteFromFakeContent( + struct adapter *pAdapter, + u16 Offset, + u8 *Value) +{ + if (Offset >= EFUSE_MAX_HW_SIZE) + return false; + if (fakeEfuseBank == 0) + *Value = fakeEfuseContent[Offset]; + else + *Value = fakeBTEfuseContent[fakeEfuseBank-1][Offset]; + return true; +} + +static bool +Efuse_Write1ByteToFakeContent( + struct adapter *pAdapter, + u16 Offset, + u8 Value) +{ + if (Offset >= EFUSE_MAX_HW_SIZE) + return false; + if (fakeEfuseBank == 0) { + fakeEfuseContent[Offset] = Value; + } else { + fakeBTEfuseContent[fakeEfuseBank-1][Offset] = Value; + } + return true; +} + +/*----------------------------------------------------------------------------- + * Function: Efuse_PowerSwitch + * + * Overview: When we want to enable write operation, we should change to + * pwr on state. When we stop write, we should switch to 500k mode + * and disable LDO 2.5V. + * + * Input: NONE + * + * Output: NONE + * + * Return: NONE + * + * Revised History: + * When Who Remark + * 11/17/2008 MHC Create Version 0. + * + *---------------------------------------------------------------------------*/ +void +Efuse_PowerSwitch( + struct adapter *pAdapter, + u8 write, + u8 PwrState) +{ + pAdapter->HalFunc.EfusePowerSwitch(pAdapter, write, PwrState); +} + +/*----------------------------------------------------------------------------- + * Function: efuse_GetCurrentSize + * + * Overview: Get current efuse size!!! + * + * Input: NONE + * + * Output: NONE + * + * Return: NONE + * + * Revised History: + * When Who Remark + * 11/16/2008 MHC Create Version 0. + * + *---------------------------------------------------------------------------*/ +u16 +Efuse_GetCurrentSize( + struct adapter *pAdapter, + u8 efuseType, + bool pseudo) +{ + u16 ret = 0; + + ret = pAdapter->HalFunc.EfuseGetCurrentSize(pAdapter, efuseType, pseudo); + + return ret; +} + +/* 11/16/2008 MH Add description. Get current efuse area enabled word!!. */ +u8 +Efuse_CalculateWordCnts(u8 word_en) +{ + u8 word_cnts = 0; + if (!(word_en & BIT(0))) + word_cnts++; /* 0 : write enable */ + if (!(word_en & BIT(1))) + word_cnts++; + if (!(word_en & BIT(2))) + word_cnts++; + if (!(word_en & BIT(3))) + word_cnts++; + return word_cnts; +} + +/* */ +/* Description: */ +/* Execute E-Fuse read byte operation. */ +/* Refered from SD1 Richard. */ +/* */ +/* Assumption: */ +/* 1. Boot from E-Fuse and successfully auto-load. */ +/* 2. PASSIVE_LEVEL (USB interface) */ +/* */ +/* Created by Roger, 2008.10.21. */ +/* */ +void +ReadEFuseByte( + struct adapter *Adapter, + u16 _offset, + u8 *pbuf, + bool pseudo) +{ + u32 value32; + u8 readbyte; + u16 retry; + + if (pseudo) { + Efuse_Read1ByteFromFakeContent(Adapter, _offset, pbuf); + return; + } + + /* Write Address */ + rtw_write8(Adapter, EFUSE_CTRL+1, (_offset & 0xff)); + readbyte = rtw_read8(Adapter, EFUSE_CTRL+2); + rtw_write8(Adapter, EFUSE_CTRL+2, ((_offset >> 8) & 0x03) | (readbyte & 0xfc)); + + /* Write bit 32 0 */ + readbyte = rtw_read8(Adapter, EFUSE_CTRL+3); + rtw_write8(Adapter, EFUSE_CTRL+3, (readbyte & 0x7f)); + + /* Check bit 32 read-ready */ + retry = 0; + value32 = rtw_read32(Adapter, EFUSE_CTRL); + while (!(((value32 >> 24) & 0xff) & 0x80) && (retry < 10000)) { + value32 = rtw_read32(Adapter, EFUSE_CTRL); + retry++; + } + + /* 20100205 Joseph: Add delay suggested by SD1 Victor. */ + /* This fix the problem that Efuse read error in high temperature condition. */ + /* Designer says that there shall be some delay after ready bit is set, or the */ + /* result will always stay on last data we read. */ + rtw_udelay_os(50); + value32 = rtw_read32(Adapter, EFUSE_CTRL); + + *pbuf = (u8)(value32 & 0xff); +} + +/* */ +/* Description: */ +/* 1. Execute E-Fuse read byte operation according as map offset and */ +/* save to E-Fuse table. */ +/* 2. Refered from SD1 Richard. */ +/* */ +/* Assumption: */ +/* 1. Boot from E-Fuse and successfully auto-load. */ +/* 2. PASSIVE_LEVEL (USB interface) */ +/* */ +/* Created by Roger, 2008.10.21. */ +/* */ +/* 2008/12/12 MH 1. Reorganize code flow and reserve bytes. and add description. */ +/* 2. Add efuse utilization collect. */ +/* 2008/12/22 MH Read Efuse must check if we write section 1 data again!!! Sec1 */ +/* write addr must be after sec5. */ +/* */ + +static void efuse_ReadEFuse(struct adapter *Adapter, u8 efuseType, u16 _offset, u16 _size_byte, u8 *pbuf, bool pseudo) +{ + Adapter->HalFunc.ReadEFuse(Adapter, efuseType, _offset, _size_byte, pbuf, pseudo); +} + +void EFUSE_GetEfuseDefinition(struct adapter *pAdapter, u8 efuseType, u8 type, void *pOut, bool pseudo + ) +{ + pAdapter->HalFunc.EFUSEGetEfuseDefinition(pAdapter, efuseType, type, pOut, pseudo); +} + +/*----------------------------------------------------------------------------- + * Function: EFUSE_Read1Byte + * + * Overview: Copy from WMAC fot EFUSE read 1 byte. + * + * Input: NONE + * + * Output: NONE + * + * Return: NONE + * + * Revised History: + * When Who Remark + * 09/23/2008 MHC Copy from WMAC. + * + *---------------------------------------------------------------------------*/ +u8 EFUSE_Read1Byte(struct adapter *Adapter, u16 Address) +{ + u8 data; + u8 Bytetemp = {0x00}; + u8 temp = {0x00}; + u32 k = 0; + u16 contentLen = 0; + + EFUSE_GetEfuseDefinition(Adapter, EFUSE_WIFI , TYPE_EFUSE_REAL_CONTENT_LEN, (void *)&contentLen, false); + + if (Address < contentLen) { /* E-fuse 512Byte */ + /* Write E-fuse Register address bit0~7 */ + temp = Address & 0xFF; + rtw_write8(Adapter, EFUSE_CTRL+1, temp); + Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+2); + /* Write E-fuse Register address bit8~9 */ + temp = ((Address >> 8) & 0x03) | (Bytetemp & 0xFC); + rtw_write8(Adapter, EFUSE_CTRL+2, temp); + + /* Write 0x30[31]= 0 */ + Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+3); + temp = Bytetemp & 0x7F; + rtw_write8(Adapter, EFUSE_CTRL+3, temp); + + /* Wait Write-ready (0x30[31]= 1) */ + Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+3); + while (!(Bytetemp & 0x80)) { + Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+3); + k++; + if (k == 1000) { + k = 0; + break; + } + } + data = rtw_read8(Adapter, EFUSE_CTRL); + return data; + } else { + return 0xFF; + } + +} /* EFUSE_Read1Byte */ + +/* 11/16/2008 MH Read one byte from real Efuse. */ +u8 efuse_OneByteRead(struct adapter *pAdapter, u16 addr, u8 *data, bool pseudo) +{ + u8 tmpidx = 0; + u8 result; + + if (pseudo) { + result = Efuse_Read1ByteFromFakeContent(pAdapter, addr, data); + return result; + } + /* -----------------e-fuse reg ctrl --------------------------------- */ + /* address */ + rtw_write8(pAdapter, EFUSE_CTRL+1, (u8)(addr & 0xff)); + rtw_write8(pAdapter, EFUSE_CTRL+2, ((u8)((addr>>8) & 0x03)) | + (rtw_read8(pAdapter, EFUSE_CTRL+2) & 0xFC)); + + rtw_write8(pAdapter, EFUSE_CTRL+3, 0x72);/* read cmd */ + + while (!(0x80 & rtw_read8(pAdapter, EFUSE_CTRL+3)) && (tmpidx < 100)) + tmpidx++; + if (tmpidx < 100) { + *data = rtw_read8(pAdapter, EFUSE_CTRL); + result = true; + } else { + *data = 0xff; + result = false; + } + return result; +} + +/* 11/16/2008 MH Write one byte to reald Efuse. */ +u8 efuse_OneByteWrite(struct adapter *pAdapter, u16 addr, u8 data, bool pseudo) +{ + u8 tmpidx = 0; + u8 result; + + if (pseudo) { + result = Efuse_Write1ByteToFakeContent(pAdapter, addr, data); + return result; + } + + /* -----------------e-fuse reg ctrl --------------------------------- */ + /* address */ + rtw_write8(pAdapter, EFUSE_CTRL+1, (u8)(addr&0xff)); + rtw_write8(pAdapter, EFUSE_CTRL+2, + (rtw_read8(pAdapter, EFUSE_CTRL+2) & 0xFC) | + (u8)((addr>>8) & 0x03)); + rtw_write8(pAdapter, EFUSE_CTRL, data);/* data */ + + rtw_write8(pAdapter, EFUSE_CTRL+3, 0xF2);/* write cmd */ + + while ((0x80 & rtw_read8(pAdapter, EFUSE_CTRL+3)) && (tmpidx < 100)) + tmpidx++; + + if (tmpidx < 100) + result = true; + else + result = false; + + return result; +} + +int Efuse_PgPacketRead(struct adapter *pAdapter, u8 offset, u8 *data, bool pseudo) +{ + int ret = 0; + + ret = pAdapter->HalFunc.Efuse_PgPacketRead(pAdapter, offset, data, pseudo); + + return ret; +} + +int Efuse_PgPacketWrite(struct adapter *pAdapter, u8 offset, u8 word_en, u8 *data, bool pseudo) +{ + int ret; + + ret = pAdapter->HalFunc.Efuse_PgPacketWrite(pAdapter, offset, word_en, data, pseudo); + + return ret; +} + + +static int Efuse_PgPacketWrite_BT(struct adapter *pAdapter, u8 offset, u8 word_en, u8 *data, bool pseudo) +{ + int ret; + + ret = pAdapter->HalFunc.Efuse_PgPacketWrite_BT(pAdapter, offset, word_en, data, pseudo); + + return ret; +} + +/*----------------------------------------------------------------------------- + * Function: efuse_WordEnableDataRead + * + * Overview: Read allowed word in current efuse section data. + * + * Input: NONE + * + * Output: NONE + * + * Return: NONE + * + * Revised History: + * When Who Remark + * 11/16/2008 MHC Create Version 0. + * 11/21/2008 MHC Fix Write bug when we only enable late word. + * + *---------------------------------------------------------------------------*/ +void efuse_WordEnableDataRead(u8 word_en, u8 *sourdata, u8 *targetdata) +{ + if (!(word_en&BIT(0))) { + targetdata[0] = sourdata[0]; + targetdata[1] = sourdata[1]; + } + if (!(word_en&BIT(1))) { + targetdata[2] = sourdata[2]; + targetdata[3] = sourdata[3]; + } + if (!(word_en&BIT(2))) { + targetdata[4] = sourdata[4]; + targetdata[5] = sourdata[5]; + } + if (!(word_en&BIT(3))) { + targetdata[6] = sourdata[6]; + targetdata[7] = sourdata[7]; + } +} + +u8 Efuse_WordEnableDataWrite(struct adapter *pAdapter, u16 efuse_addr, u8 word_en, u8 *data, bool pseudo) +{ + u8 ret = 0; + + ret = pAdapter->HalFunc.Efuse_WordEnableDataWrite(pAdapter, efuse_addr, word_en, data, pseudo); + + return ret; +} + +static u8 efuse_read8(struct adapter *padapter, u16 address, u8 *value) +{ + return efuse_OneByteRead(padapter, address, value, false); +} + +static u8 efuse_write8(struct adapter *padapter, u16 address, u8 *value) +{ + return efuse_OneByteWrite(padapter, address, *value, false); +} + +/* + * read/wirte raw efuse data + */ +u8 rtw_efuse_access(struct adapter *padapter, u8 write, u16 start_addr, u16 cnts, u8 *data) +{ + int i = 0; + u16 real_content_len = 0, max_available_size = 0; + u8 res = _FAIL ; + u8 (*rw8)(struct adapter *, u16, u8*); + + EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_EFUSE_REAL_CONTENT_LEN, (void *)&real_content_len, false); + EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); + + if (start_addr > real_content_len) + return _FAIL; + + if (write) { + if ((start_addr + cnts) > max_available_size) + return _FAIL; + rw8 = &efuse_write8; + } else { + rw8 = &efuse_read8; + } + + Efuse_PowerSwitch(padapter, write, true); + + /* e-fuse one byte read / write */ + for (i = 0; i < cnts; i++) { + if (start_addr >= real_content_len) { + res = _FAIL; + break; + } + + res = rw8(padapter, start_addr++, data++); + if (_FAIL == res) + break; + } + + Efuse_PowerSwitch(padapter, write, false); + + return res; +} +/* */ +u16 efuse_GetMaxSize(struct adapter *padapter) +{ + u16 max_size; + EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI , TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_size, false); + return max_size; +} +/* */ +u8 efuse_GetCurrentSize(struct adapter *padapter, u16 *size) +{ + Efuse_PowerSwitch(padapter, false, true); + *size = Efuse_GetCurrentSize(padapter, EFUSE_WIFI, false); + Efuse_PowerSwitch(padapter, false, false); + + return _SUCCESS; +} +/* */ +u8 rtw_efuse_map_read(struct adapter *padapter, u16 addr, u16 cnts, u8 *data) +{ + u16 mapLen = 0; + + EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_EFUSE_MAP_LEN, (void *)&mapLen, false); + + if ((addr + cnts) > mapLen) + return _FAIL; + + Efuse_PowerSwitch(padapter, false, true); + + efuse_ReadEFuse(padapter, EFUSE_WIFI, addr, cnts, data, false); + + Efuse_PowerSwitch(padapter, false, false); + + return _SUCCESS; +} + +u8 rtw_BT_efuse_map_read(struct adapter *padapter, u16 addr, u16 cnts, u8 *data) +{ + u16 mapLen = 0; + + EFUSE_GetEfuseDefinition(padapter, EFUSE_BT, TYPE_EFUSE_MAP_LEN, (void *)&mapLen, false); + + if ((addr + cnts) > mapLen) + return _FAIL; + + Efuse_PowerSwitch(padapter, false, true); + + efuse_ReadEFuse(padapter, EFUSE_BT, addr, cnts, data, false); + + Efuse_PowerSwitch(padapter, false, false); + + return _SUCCESS; +} +/* */ +u8 rtw_efuse_map_write(struct adapter *padapter, u16 addr, u16 cnts, u8 *data) +{ + u8 offset, word_en; + u8 *map; + u8 newdata[PGPKT_DATA_SIZE]; + s32 i, idx; + u8 ret = _SUCCESS; + u16 mapLen = 0; + + EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_EFUSE_MAP_LEN, (void *)&mapLen, false); + + if ((addr + cnts) > mapLen) + return _FAIL; + + map = rtw_zmalloc(mapLen); + if (map == NULL) + return _FAIL; + + ret = rtw_efuse_map_read(padapter, 0, mapLen, map); + if (ret == _FAIL) + goto exit; + + Efuse_PowerSwitch(padapter, true, true); + + offset = (addr >> 3); + word_en = 0xF; + _rtw_memset(newdata, 0xFF, PGPKT_DATA_SIZE); + i = addr & 0x7; /* index of one package */ + idx = 0; /* data index */ + + if (i & 0x1) { + /* odd start */ + if (data[idx] != map[addr+idx]) { + word_en &= ~BIT(i >> 1); + newdata[i-1] = map[addr+idx-1]; + newdata[i] = data[idx]; + } + i++; + idx++; + } + do { + for (; i < PGPKT_DATA_SIZE; i += 2) { + if (cnts == idx) + break; + if ((cnts - idx) == 1) { + if (data[idx] != map[addr+idx]) { + word_en &= ~BIT(i >> 1); + newdata[i] = data[idx]; + newdata[i+1] = map[addr+idx+1]; + } + idx++; + break; + } else { + if ((data[idx] != map[addr+idx]) || + (data[idx+1] != map[addr+idx+1])) { + word_en &= ~BIT(i >> 1); + newdata[i] = data[idx]; + newdata[i+1] = data[idx + 1]; + } + idx += 2; + } + if (idx == cnts) + break; + } + + if (word_en != 0xF) { + ret = Efuse_PgPacketWrite(padapter, offset, word_en, newdata, false); + DBG_88E("offset=%x\n", offset); + DBG_88E("word_en=%x\n", word_en); + + for (i = 0; i < PGPKT_DATA_SIZE; i++) + DBG_88E("data=%x \t", newdata[i]); + if (ret == _FAIL) + break; + } + + if (idx == cnts) + break; + + offset++; + i = 0; + word_en = 0xF; + _rtw_memset(newdata, 0xFF, PGPKT_DATA_SIZE); + } while (1); + + Efuse_PowerSwitch(padapter, true, false); +exit: + kfree(map); + return ret; +} + +/* */ +u8 rtw_BT_efuse_map_write(struct adapter *padapter, u16 addr, u16 cnts, u8 *data) +{ + u8 offset, word_en; + u8 *map; + u8 newdata[PGPKT_DATA_SIZE]; + s32 i, idx; + u8 ret = _SUCCESS; + u16 mapLen = 0; + + EFUSE_GetEfuseDefinition(padapter, EFUSE_BT, TYPE_EFUSE_MAP_LEN, (void *)&mapLen, false); + + if ((addr + cnts) > mapLen) + return _FAIL; + + map = rtw_zmalloc(mapLen); + if (map == NULL) + return _FAIL; + + ret = rtw_BT_efuse_map_read(padapter, 0, mapLen, map); + if (ret == _FAIL) + goto exit; + + Efuse_PowerSwitch(padapter, true, true); + + offset = (addr >> 3); + word_en = 0xF; + _rtw_memset(newdata, 0xFF, PGPKT_DATA_SIZE); + i = addr & 0x7; /* index of one package */ + idx = 0; /* data index */ + + if (i & 0x1) { + /* odd start */ + if (data[idx] != map[addr+idx]) { + word_en &= ~BIT(i >> 1); + newdata[i-1] = map[addr+idx-1]; + newdata[i] = data[idx]; + } + i++; + idx++; + } + do { + for (; i < PGPKT_DATA_SIZE; i += 2) { + if (cnts == idx) + break; + if ((cnts - idx) == 1) { + if (data[idx] != map[addr+idx]) { + word_en &= ~BIT(i >> 1); + newdata[i] = data[idx]; + newdata[i+1] = map[addr+idx+1]; + } + idx++; + break; + } else { + if ((data[idx] != map[addr+idx]) || + (data[idx+1] != map[addr+idx+1])) { + word_en &= ~BIT(i >> 1); + newdata[i] = data[idx]; + newdata[i+1] = data[idx + 1]; + } + idx += 2; + } + if (idx == cnts) + break; + } + + if (word_en != 0xF) { + DBG_88E("%s: offset=%#X\n", __func__, offset); + DBG_88E("%s: word_en=%#X\n", __func__, word_en); + DBG_88E("%s: data=", __func__); + for (i = 0; i < PGPKT_DATA_SIZE; i++) + DBG_88E("0x%02X ", newdata[i]); + DBG_88E("\n"); + + ret = Efuse_PgPacketWrite_BT(padapter, offset, word_en, newdata, false); + if (ret == _FAIL) + break; + } + + if (idx == cnts) + break; + + offset++; + i = 0; + word_en = 0xF; + _rtw_memset(newdata, 0xFF, PGPKT_DATA_SIZE); + } while (1); + + Efuse_PowerSwitch(padapter, true, false); + +exit: + + kfree(map); + + return ret; +} + +/*----------------------------------------------------------------------------- + * Function: efuse_ShadowRead1Byte + * efuse_ShadowRead2Byte + * efuse_ShadowRead4Byte + * + * Overview: Read from efuse init map by one/two/four bytes !!!!! + * + * Input: NONE + * + * Output: NONE + * + * Return: NONE + * + * Revised History: + * When Who Remark + * 11/12/2008 MHC Create Version 0. + * + *---------------------------------------------------------------------------*/ +static void +efuse_ShadowRead1Byte( + struct adapter *pAdapter, + u16 Offset, + u8 *Value) +{ + struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(pAdapter); + + *Value = pEEPROM->efuse_eeprom_data[Offset]; + +} /* EFUSE_ShadowRead1Byte */ + +/* Read Two Bytes */ +static void +efuse_ShadowRead2Byte( + struct adapter *pAdapter, + u16 Offset, + u16 *Value) +{ + struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(pAdapter); + + *Value = pEEPROM->efuse_eeprom_data[Offset]; + *Value |= pEEPROM->efuse_eeprom_data[Offset+1]<<8; + +} /* EFUSE_ShadowRead2Byte */ + +/* Read Four Bytes */ +static void +efuse_ShadowRead4Byte( + struct adapter *pAdapter, + u16 Offset, + u32 *Value) +{ + struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(pAdapter); + + *Value = pEEPROM->efuse_eeprom_data[Offset]; + *Value |= pEEPROM->efuse_eeprom_data[Offset+1]<<8; + *Value |= pEEPROM->efuse_eeprom_data[Offset+2]<<16; + *Value |= pEEPROM->efuse_eeprom_data[Offset+3]<<24; + +} /* efuse_ShadowRead4Byte */ + +/*----------------------------------------------------------------------------- + * Function: Efuse_ReadAllMap + * + * Overview: Read All Efuse content + * + * Input: NONE + * + * Output: NONE + * + * Return: NONE + * + * Revised History: + * When Who Remark + * 11/11/2008 MHC Create Version 0. + * + *---------------------------------------------------------------------------*/ +static void Efuse_ReadAllMap(struct adapter *pAdapter, u8 efuseType, u8 *Efuse, bool pseudo) +{ + u16 mapLen = 0; + + Efuse_PowerSwitch(pAdapter, false, true); + + EFUSE_GetEfuseDefinition(pAdapter, efuseType, TYPE_EFUSE_MAP_LEN, (void *)&mapLen, pseudo); + + efuse_ReadEFuse(pAdapter, efuseType, 0, mapLen, Efuse, pseudo); + + Efuse_PowerSwitch(pAdapter, false, false); +} + +/*----------------------------------------------------------------------------- + * Function: EFUSE_ShadowMapUpdate + * + * Overview: Transfer current EFUSE content to shadow init and modify map. + * + * Input: NONE + * + * Output: NONE + * + * Return: NONE + * + * Revised History: + * When Who Remark + * 11/13/2008 MHC Create Version 0. + * + *---------------------------------------------------------------------------*/ +void EFUSE_ShadowMapUpdate( + struct adapter *pAdapter, + u8 efuseType, + bool pseudo) +{ + struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(pAdapter); + u16 mapLen = 0; + + EFUSE_GetEfuseDefinition(pAdapter, efuseType, TYPE_EFUSE_MAP_LEN, (void *)&mapLen, pseudo); + + if (pEEPROM->bautoload_fail_flag) + _rtw_memset(pEEPROM->efuse_eeprom_data, 0xFF, mapLen); + else + Efuse_ReadAllMap(pAdapter, efuseType, pEEPROM->efuse_eeprom_data, pseudo); +} /* EFUSE_ShadowMapUpdate */ + +/*----------------------------------------------------------------------------- + * Function: EFUSE_ShadowRead + * + * Overview: Read from efuse init map !!!!! + * + * Input: NONE + * + * Output: NONE + * + * Return: NONE + * + * Revised History: + * When Who Remark + * 11/12/2008 MHC Create Version 0. + * + *---------------------------------------------------------------------------*/ +void EFUSE_ShadowRead(struct adapter *pAdapter, u8 Type, u16 Offset, u32 *Value) +{ + if (Type == 1) + efuse_ShadowRead1Byte(pAdapter, Offset, (u8 *)Value); + else if (Type == 2) + efuse_ShadowRead2Byte(pAdapter, Offset, (u16 *)Value); + else if (Type == 4) + efuse_ShadowRead4Byte(pAdapter, Offset, (u32 *)Value); + +} /* EFUSE_ShadowRead */ diff --git a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c new file mode 100644 index 0000000000000..3605c5da822d9 --- /dev/null +++ b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c @@ -0,0 +1,1640 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _IEEE80211_C + +#include +#include +#include +#include +#include +#include + +u8 RTW_WPA_OUI_TYPE[] = { 0x00, 0x50, 0xf2, 1 }; +u16 RTW_WPA_VERSION = 1; +u8 WPA_AUTH_KEY_MGMT_NONE[] = { 0x00, 0x50, 0xf2, 0 }; +u8 WPA_AUTH_KEY_MGMT_UNSPEC_802_1X[] = { 0x00, 0x50, 0xf2, 1 }; +u8 WPA_AUTH_KEY_MGMT_PSK_OVER_802_1X[] = { 0x00, 0x50, 0xf2, 2 }; +u8 WPA_CIPHER_SUITE_NONE[] = { 0x00, 0x50, 0xf2, 0 }; +u8 WPA_CIPHER_SUITE_WEP40[] = { 0x00, 0x50, 0xf2, 1 }; +u8 WPA_CIPHER_SUITE_TKIP[] = { 0x00, 0x50, 0xf2, 2 }; +u8 WPA_CIPHER_SUITE_WRAP[] = { 0x00, 0x50, 0xf2, 3 }; +u8 WPA_CIPHER_SUITE_CCMP[] = { 0x00, 0x50, 0xf2, 4 }; +u8 WPA_CIPHER_SUITE_WEP104[] = { 0x00, 0x50, 0xf2, 5 }; + +u16 RSN_VERSION_BSD = 1; +u8 RSN_AUTH_KEY_MGMT_UNSPEC_802_1X[] = { 0x00, 0x0f, 0xac, 1 }; +u8 RSN_AUTH_KEY_MGMT_PSK_OVER_802_1X[] = { 0x00, 0x0f, 0xac, 2 }; +u8 RSN_CIPHER_SUITE_NONE[] = { 0x00, 0x0f, 0xac, 0 }; +u8 RSN_CIPHER_SUITE_WEP40[] = { 0x00, 0x0f, 0xac, 1 }; +u8 RSN_CIPHER_SUITE_TKIP[] = { 0x00, 0x0f, 0xac, 2 }; +u8 RSN_CIPHER_SUITE_WRAP[] = { 0x00, 0x0f, 0xac, 3 }; +u8 RSN_CIPHER_SUITE_CCMP[] = { 0x00, 0x0f, 0xac, 4 }; +u8 RSN_CIPHER_SUITE_WEP104[] = { 0x00, 0x0f, 0xac, 5 }; +/* */ +/* for adhoc-master to generate ie and provide supported-rate to fw */ +/* */ + +static u8 WIFI_CCKRATES[] = { + (IEEE80211_CCK_RATE_1MB | IEEE80211_BASIC_RATE_MASK), + (IEEE80211_CCK_RATE_2MB | IEEE80211_BASIC_RATE_MASK), + (IEEE80211_CCK_RATE_5MB | IEEE80211_BASIC_RATE_MASK), + (IEEE80211_CCK_RATE_11MB | IEEE80211_BASIC_RATE_MASK) + }; + +static u8 WIFI_OFDMRATES[] = { + (IEEE80211_OFDM_RATE_6MB), + (IEEE80211_OFDM_RATE_9MB), + (IEEE80211_OFDM_RATE_12MB), + (IEEE80211_OFDM_RATE_18MB), + (IEEE80211_OFDM_RATE_24MB), + IEEE80211_OFDM_RATE_36MB, + IEEE80211_OFDM_RATE_48MB, + IEEE80211_OFDM_RATE_54MB + }; + + +int rtw_get_bit_value_from_ieee_value(u8 val) +{ + unsigned char dot11_rate_table[] = { + 2, 4, 11, 22, 12, 18, 24, 36, 48, + 72, 96, 108, 0}; /* last element must be zero!! */ + + int i = 0; + while (dot11_rate_table[i] != 0) { + if (dot11_rate_table[i] == val) + return BIT(i); + i++; + } + return 0; +} + +uint rtw_is_cckrates_included(u8 *rate) +{ + u32 i = 0; + + while (rate[i] != 0) { + if ((((rate[i]) & 0x7f) == 2) || (((rate[i]) & 0x7f) == 4) || + (((rate[i]) & 0x7f) == 11) || (((rate[i]) & 0x7f) == 22)) + return true; + i++; + } + return false; +} + +uint rtw_is_cckratesonly_included(u8 *rate) +{ + u32 i = 0; + + while (rate[i] != 0) { + if ((((rate[i]) & 0x7f) != 2) && (((rate[i]) & 0x7f) != 4) && + (((rate[i]) & 0x7f) != 11) && (((rate[i]) & 0x7f) != 22)) + return false; + i++; + } + + return true; +} + +int rtw_check_network_type(unsigned char *rate, int ratelen, int channel) +{ + if (channel > 14) { + if ((rtw_is_cckrates_included(rate)) == true) + return WIRELESS_INVALID; + else + return WIRELESS_11A; + } else { /* could be pure B, pure G, or B/G */ + if ((rtw_is_cckratesonly_included(rate)) == true) + return WIRELESS_11B; + else if ((rtw_is_cckrates_included(rate)) == true) + return WIRELESS_11BG; + else + return WIRELESS_11G; + } +} + +u8 *rtw_set_fixed_ie(unsigned char *pbuf, unsigned int len, unsigned char *source, + unsigned int *frlen) +{ + memcpy((void *)pbuf, (void *)source, len); + *frlen = *frlen + len; + return pbuf + len; +} + +/* rtw_set_ie will update frame length */ +u8 *rtw_set_ie +( + u8 *pbuf, + int index, + uint len, + u8 *source, + uint *frlen /* frame length */ +) +{ +_func_enter_; + *pbuf = (u8)index; + + *(pbuf + 1) = (u8)len; + + if (len > 0) + memcpy((void *)(pbuf + 2), (void *)source, len); + + *frlen = *frlen + (len + 2); + + return pbuf + len + 2; +_func_exit_; +} + +inline u8 *rtw_set_ie_ch_switch (u8 *buf, u32 *buf_len, u8 ch_switch_mode, + u8 new_ch, u8 ch_switch_cnt) +{ + u8 ie_data[3]; + + ie_data[0] = ch_switch_mode; + ie_data[1] = new_ch; + ie_data[2] = ch_switch_cnt; + return rtw_set_ie(buf, WLAN_EID_CHANNEL_SWITCH, 3, ie_data, buf_len); +} + +inline u8 secondary_ch_offset_to_hal_ch_offset(u8 ch_offset) +{ + if (ch_offset == SCN) + return HAL_PRIME_CHNL_OFFSET_DONT_CARE; + else if (ch_offset == SCA) + return HAL_PRIME_CHNL_OFFSET_UPPER; + else if (ch_offset == SCB) + return HAL_PRIME_CHNL_OFFSET_LOWER; + + return HAL_PRIME_CHNL_OFFSET_DONT_CARE; +} + +inline u8 hal_ch_offset_to_secondary_ch_offset(u8 ch_offset) +{ + if (ch_offset == HAL_PRIME_CHNL_OFFSET_DONT_CARE) + return SCN; + else if (ch_offset == HAL_PRIME_CHNL_OFFSET_LOWER) + return SCB; + else if (ch_offset == HAL_PRIME_CHNL_OFFSET_UPPER) + return SCA; + + return SCN; +} + +inline u8 *rtw_set_ie_secondary_ch_offset(u8 *buf, u32 *buf_len, u8 secondary_ch_offset) +{ + return rtw_set_ie(buf, WLAN_EID_SECONDARY_CHANNEL_OFFSET, 1, &secondary_ch_offset, buf_len); +} + +inline u8 *rtw_set_ie_mesh_ch_switch_parm(u8 *buf, u32 *buf_len, u8 ttl, + u8 flags, u16 reason, u16 precedence) +{ + u8 ie_data[6]; + + ie_data[0] = ttl; + ie_data[1] = flags; + RTW_PUT_LE16((u8 *)&ie_data[2], reason); + RTW_PUT_LE16((u8 *)&ie_data[4], precedence); + + return rtw_set_ie(buf, 0x118, 6, ie_data, buf_len); +} + +/*---------------------------------------------------------------------------- +index: the information element id index, limit is the limit for search +-----------------------------------------------------------------------------*/ +u8 *rtw_get_ie(u8 *pbuf, int index, int *len, int limit) +{ + int tmp, i; + u8 *p; +_func_enter_; + if (limit < 1) { + _func_exit_; + return NULL; + } + + p = pbuf; + i = 0; + *len = 0; + while (1) { + if (*p == index) { + *len = *(p + 1); + return p; + } else { + tmp = *(p + 1); + p += (tmp + 2); + i += (tmp + 2); + } + if (i >= limit) + break; + } +_func_exit_; + return NULL; +} + +/** + * rtw_get_ie_ex - Search specific IE from a series of IEs + * @in_ie: Address of IEs to search + * @in_len: Length limit from in_ie + * @eid: Element ID to match + * @oui: OUI to match + * @oui_len: OUI length + * @ie: If not NULL and the specific IE is found, the IE will be copied to the buf starting from the specific IE + * @ielen: If not NULL and the specific IE is found, will set to the length of the entire IE + * + * Returns: The address of the specific IE found, or NULL + */ +u8 *rtw_get_ie_ex(u8 *in_ie, uint in_len, u8 eid, u8 *oui, u8 oui_len, u8 *ie, uint *ielen) +{ + uint cnt; + u8 *target_ie = NULL; + + + if (ielen) + *ielen = 0; + + if (!in_ie || in_len <= 0) + return target_ie; + + cnt = 0; + + while (cnt < in_len) { + if (eid == in_ie[cnt] && (!oui || _rtw_memcmp(&in_ie[cnt+2], oui, oui_len))) { + target_ie = &in_ie[cnt]; + + if (ie) + memcpy(ie, &in_ie[cnt], in_ie[cnt+1]+2); + + if (ielen) + *ielen = in_ie[cnt+1]+2; + + break; + } else { + cnt += in_ie[cnt+1]+2; /* goto next */ + } + } + return target_ie; +} + +/** + * rtw_ies_remove_ie - Find matching IEs and remove + * @ies: Address of IEs to search + * @ies_len: Pointer of length of ies, will update to new length + * @offset: The offset to start scarch + * @eid: Element ID to match + * @oui: OUI to match + * @oui_len: OUI length + * + * Returns: _SUCCESS: ies is updated, _FAIL: not updated + */ +int rtw_ies_remove_ie(u8 *ies, uint *ies_len, uint offset, u8 eid, u8 *oui, u8 oui_len) +{ + int ret = _FAIL; + u8 *target_ie; + u32 target_ielen; + u8 *start; + uint search_len; + + if (!ies || !ies_len || *ies_len <= offset) + goto exit; + + start = ies + offset; + search_len = *ies_len - offset; + + while (1) { + target_ie = rtw_get_ie_ex(start, search_len, eid, oui, oui_len, NULL, &target_ielen); + if (target_ie && target_ielen) { + u8 buf[MAX_IE_SZ] = {0}; + u8 *remain_ies = target_ie + target_ielen; + uint remain_len = search_len - (remain_ies - start); + + memcpy(buf, remain_ies, remain_len); + memcpy(target_ie, buf, remain_len); + *ies_len = *ies_len - target_ielen; + ret = _SUCCESS; + + start = target_ie; + search_len = remain_len; + } else { + break; + } + } +exit: + return ret; +} + +void rtw_set_supported_rate(u8 *SupportedRates, uint mode) +{ +_func_enter_; + + _rtw_memset(SupportedRates, 0, NDIS_802_11_LENGTH_RATES_EX); + + switch (mode) { + case WIRELESS_11B: + memcpy(SupportedRates, WIFI_CCKRATES, IEEE80211_CCK_RATE_LEN); + break; + case WIRELESS_11G: + case WIRELESS_11A: + case WIRELESS_11_5N: + case WIRELESS_11A_5N:/* Todo: no basic rate for ofdm ? */ + memcpy(SupportedRates, WIFI_OFDMRATES, IEEE80211_NUM_OFDM_RATESLEN); + break; + case WIRELESS_11BG: + case WIRELESS_11G_24N: + case WIRELESS_11_24N: + case WIRELESS_11BG_24N: + memcpy(SupportedRates, WIFI_CCKRATES, IEEE80211_CCK_RATE_LEN); + memcpy(SupportedRates + IEEE80211_CCK_RATE_LEN, WIFI_OFDMRATES, IEEE80211_NUM_OFDM_RATESLEN); + break; + } +_func_exit_; +} + +uint rtw_get_rateset_len(u8 *rateset) +{ + uint i = 0; +_func_enter_; + while (1) { + if ((rateset[i]) == 0) + break; + if (i > 12) + break; + i++; + } +_func_exit_; + return i; +} + +int rtw_generate_ie(struct registry_priv *pregistrypriv) +{ + u8 wireless_mode; + int sz = 0, rateLen; + struct wlan_bssid_ex *pdev_network = &pregistrypriv->dev_network; + u8 *ie = pdev_network->IEs; + +_func_enter_; + + /* timestamp will be inserted by hardware */ + sz += 8; + ie += sz; + + /* beacon interval : 2bytes */ + *(__le16 *)ie = cpu_to_le16((u16)pdev_network->Configuration.BeaconPeriod);/* BCN_INTERVAL; */ + sz += 2; + ie += 2; + + /* capability info */ + *(u16 *)ie = 0; + + *(__le16 *)ie |= cpu_to_le16(cap_IBSS); + + if (pregistrypriv->preamble == PREAMBLE_SHORT) + *(__le16 *)ie |= cpu_to_le16(cap_ShortPremble); + + if (pdev_network->Privacy) + *(__le16 *)ie |= cpu_to_le16(cap_Privacy); + + sz += 2; + ie += 2; + + /* SSID */ + ie = rtw_set_ie(ie, _SSID_IE_, pdev_network->Ssid.SsidLength, pdev_network->Ssid.Ssid, &sz); + + /* supported rates */ + if (pregistrypriv->wireless_mode == WIRELESS_11ABGN) { + if (pdev_network->Configuration.DSConfig > 14) + wireless_mode = WIRELESS_11A_5N; + else + wireless_mode = WIRELESS_11BG_24N; + } else { + wireless_mode = pregistrypriv->wireless_mode; + } + + rtw_set_supported_rate(pdev_network->SupportedRates, wireless_mode); + + rateLen = rtw_get_rateset_len(pdev_network->SupportedRates); + + if (rateLen > 8) { + ie = rtw_set_ie(ie, _SUPPORTEDRATES_IE_, 8, pdev_network->SupportedRates, &sz); + /* ie = rtw_set_ie(ie, _EXT_SUPPORTEDRATES_IE_, (rateLen - 8), (pdev_network->SupportedRates + 8), &sz); */ + } else { + ie = rtw_set_ie(ie, _SUPPORTEDRATES_IE_, rateLen, pdev_network->SupportedRates, &sz); + } + + /* DS parameter set */ + ie = rtw_set_ie(ie, _DSSET_IE_, 1, (u8 *)&(pdev_network->Configuration.DSConfig), &sz); + + /* IBSS Parameter Set */ + + ie = rtw_set_ie(ie, _IBSS_PARA_IE_, 2, (u8 *)&(pdev_network->Configuration.ATIMWindow), &sz); + + if (rateLen > 8) + ie = rtw_set_ie(ie, _EXT_SUPPORTEDRATES_IE_, (rateLen - 8), (pdev_network->SupportedRates + 8), &sz); +_func_exit_; + + return sz; +} + +unsigned char *rtw_get_wpa_ie(unsigned char *pie, int *wpa_ie_len, int limit) +{ + int len; + u16 val16; + __le16 le_tmp; + unsigned char wpa_oui_type[] = {0x00, 0x50, 0xf2, 0x01}; + u8 *pbuf = pie; + int limit_new = limit; + + while (1) { + pbuf = rtw_get_ie(pbuf, _WPA_IE_ID_, &len, limit_new); + + if (pbuf) { + /* check if oui matches... */ + if (_rtw_memcmp((pbuf + 2), wpa_oui_type, sizeof (wpa_oui_type)) == false) + goto check_next_ie; + + /* check version... */ + memcpy((u8 *)&le_tmp, (pbuf + 6), sizeof(val16)); + + val16 = le16_to_cpu(le_tmp); + if (val16 != 0x0001) + goto check_next_ie; + *wpa_ie_len = *(pbuf + 1); + return pbuf; + } else { + *wpa_ie_len = 0; + return NULL; + } + +check_next_ie: + limit_new = limit - (pbuf - pie) - 2 - len; + if (limit_new <= 0) + break; + pbuf += (2 + len); + } + *wpa_ie_len = 0; + return NULL; +} + +unsigned char *rtw_get_wpa2_ie(unsigned char *pie, int *rsn_ie_len, int limit) +{ + + return rtw_get_ie(pie, _WPA2_IE_ID_, rsn_ie_len, limit); +} + +int rtw_get_wpa_cipher_suite(u8 *s) +{ + if (_rtw_memcmp(s, WPA_CIPHER_SUITE_NONE, WPA_SELECTOR_LEN) == true) + return WPA_CIPHER_NONE; + if (_rtw_memcmp(s, WPA_CIPHER_SUITE_WEP40, WPA_SELECTOR_LEN) == true) + return WPA_CIPHER_WEP40; + if (_rtw_memcmp(s, WPA_CIPHER_SUITE_TKIP, WPA_SELECTOR_LEN) == true) + return WPA_CIPHER_TKIP; + if (_rtw_memcmp(s, WPA_CIPHER_SUITE_CCMP, WPA_SELECTOR_LEN) == true) + return WPA_CIPHER_CCMP; + if (_rtw_memcmp(s, WPA_CIPHER_SUITE_WEP104, WPA_SELECTOR_LEN) == true) + return WPA_CIPHER_WEP104; + + return 0; +} + +int rtw_get_wpa2_cipher_suite(u8 *s) +{ + if (_rtw_memcmp(s, RSN_CIPHER_SUITE_NONE, RSN_SELECTOR_LEN) == true) + return WPA_CIPHER_NONE; + if (_rtw_memcmp(s, RSN_CIPHER_SUITE_WEP40, RSN_SELECTOR_LEN) == true) + return WPA_CIPHER_WEP40; + if (_rtw_memcmp(s, RSN_CIPHER_SUITE_TKIP, RSN_SELECTOR_LEN) == true) + return WPA_CIPHER_TKIP; + if (_rtw_memcmp(s, RSN_CIPHER_SUITE_CCMP, RSN_SELECTOR_LEN) == true) + return WPA_CIPHER_CCMP; + if (_rtw_memcmp(s, RSN_CIPHER_SUITE_WEP104, RSN_SELECTOR_LEN) == true) + return WPA_CIPHER_WEP104; + + return 0; +} + + +int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x) +{ + int i, ret = _SUCCESS; + int left, count; + u8 *pos; + u8 SUITE_1X[4] = {0x00, 0x50, 0xf2, 1}; + + if (wpa_ie_len <= 0) { + /* No WPA IE - fail silently */ + return _FAIL; + } + + + if ((*wpa_ie != _WPA_IE_ID_) || (*(wpa_ie+1) != (u8)(wpa_ie_len - 2)) || + (_rtw_memcmp(wpa_ie+2, RTW_WPA_OUI_TYPE, WPA_SELECTOR_LEN) != true)) + return _FAIL; + + pos = wpa_ie; + + pos += 8; + left = wpa_ie_len - 8; + + + /* group_cipher */ + if (left >= WPA_SELECTOR_LEN) { + *group_cipher = rtw_get_wpa_cipher_suite(pos); + pos += WPA_SELECTOR_LEN; + left -= WPA_SELECTOR_LEN; + } else if (left > 0) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s: ie length mismatch, %u too much", __func__, left)); + return _FAIL; + } + + /* pairwise_cipher */ + if (left >= 2) { + count = RTW_GET_LE16(pos); + pos += 2; + left -= 2; + + if (count == 0 || left < count * WPA_SELECTOR_LEN) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s: ie count botch (pairwise), " + "count %u left %u", __func__, count, left)); + return _FAIL; + } + + for (i = 0; i < count; i++) { + *pairwise_cipher |= rtw_get_wpa_cipher_suite(pos); + + pos += WPA_SELECTOR_LEN; + left -= WPA_SELECTOR_LEN; + } + } else if (left == 1) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s: ie too short (for key mgmt)", __func__)); + return _FAIL; + } + + if (is_8021x) { + if (left >= 6) { + pos += 2; + if (_rtw_memcmp(pos, SUITE_1X, 4) == 1) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s : there has 802.1x auth\n", __func__)); + *is_8021x = 1; + } + } + } + + return ret; +} + +int rtw_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x) +{ + int i, ret = _SUCCESS; + int left, count; + u8 *pos; + u8 SUITE_1X[4] = {0x00, 0x0f, 0xac, 0x01}; + + if (rsn_ie_len <= 0) { + /* No RSN IE - fail silently */ + return _FAIL; + } + + + if ((*rsn_ie != _WPA2_IE_ID_) || (*(rsn_ie+1) != (u8)(rsn_ie_len - 2))) + return _FAIL; + + pos = rsn_ie; + pos += 4; + left = rsn_ie_len - 4; + + /* group_cipher */ + if (left >= RSN_SELECTOR_LEN) { + *group_cipher = rtw_get_wpa2_cipher_suite(pos); + + pos += RSN_SELECTOR_LEN; + left -= RSN_SELECTOR_LEN; + + } else if (left > 0) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s: ie length mismatch, %u too much", __func__, left)); + return _FAIL; + } + + /* pairwise_cipher */ + if (left >= 2) { + count = RTW_GET_LE16(pos); + pos += 2; + left -= 2; + + if (count == 0 || left < count * RSN_SELECTOR_LEN) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s: ie count botch (pairwise), " + "count %u left %u", __func__, count, left)); + return _FAIL; + } + + for (i = 0; i < count; i++) { + *pairwise_cipher |= rtw_get_wpa2_cipher_suite(pos); + + pos += RSN_SELECTOR_LEN; + left -= RSN_SELECTOR_LEN; + } + + } else if (left == 1) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s: ie too short (for key mgmt)", __func__)); + + return _FAIL; + } + + if (is_8021x) { + if (left >= 6) { + pos += 2; + if (_rtw_memcmp(pos, SUITE_1X, 4) == 1) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s (): there has 802.1x auth\n", __func__)); + *is_8021x = 1; + } + } + } + return ret; +} + +int rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie, u16 *wpa_len) +{ + u8 authmode, sec_idx, i; + u8 wpa_oui[4] = {0x0, 0x50, 0xf2, 0x01}; + uint cnt; + +_func_enter_; + + /* Search required WPA or WPA2 IE and copy to sec_ie[] */ + + cnt = (_TIMESTAMP_ + _BEACON_ITERVAL_ + _CAPABILITY_); + + sec_idx = 0; + + while (cnt < in_len) { + authmode = in_ie[cnt]; + + if ((authmode == _WPA_IE_ID_) && (_rtw_memcmp(&in_ie[cnt+2], &wpa_oui[0], 4))) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, + ("\n rtw_get_wpa_ie: sec_idx =%d in_ie[cnt+1]+2 =%d\n", + sec_idx, in_ie[cnt+1]+2)); + + if (wpa_ie) { + memcpy(wpa_ie, &in_ie[cnt], in_ie[cnt+1]+2); + + for (i = 0; i < (in_ie[cnt+1]+2); i += 8) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, + ("\n %2x,%2x,%2x,%2x,%2x,%2x,%2x,%2x\n", + wpa_ie[i], wpa_ie[i+1], wpa_ie[i+2], wpa_ie[i+3], wpa_ie[i+4], + wpa_ie[i+5], wpa_ie[i+6], wpa_ie[i+7])); + } + } + + *wpa_len = in_ie[cnt+1]+2; + cnt += in_ie[cnt+1]+2; /* get next */ + } else { + if (authmode == _WPA2_IE_ID_) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, + ("\n get_rsn_ie: sec_idx =%d in_ie[cnt+1]+2 =%d\n", + sec_idx, in_ie[cnt+1]+2)); + + if (rsn_ie) { + memcpy(rsn_ie, &in_ie[cnt], in_ie[cnt+1]+2); + + for (i = 0; i < (in_ie[cnt+1]+2); i += 8) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, + ("\n %2x,%2x,%2x,%2x,%2x,%2x,%2x,%2x\n", + rsn_ie[i], rsn_ie[i+1], rsn_ie[i+2], rsn_ie[i+3], rsn_ie[i+4], + rsn_ie[i+5], rsn_ie[i+6], rsn_ie[i+7])); + } + } + + *rsn_len = in_ie[cnt+1]+2; + cnt += in_ie[cnt+1]+2; /* get next */ + } else { + cnt += in_ie[cnt+1]+2; /* get next */ + } + } + } + +_func_exit_; + + return *rsn_len + *wpa_len; +} + +u8 rtw_is_wps_ie(u8 *ie_ptr, uint *wps_ielen) +{ + u8 match = false; + u8 eid, wps_oui[4] = {0x0, 0x50, 0xf2, 0x04}; + + if (ie_ptr == NULL) + return match; + + eid = ie_ptr[0]; + + if ((eid == _WPA_IE_ID_) && (_rtw_memcmp(&ie_ptr[2], wps_oui, 4))) { + *wps_ielen = ie_ptr[1]+2; + match = true; + } + return match; +} + +/** + * rtw_get_wps_ie - Search WPS IE from a series of IEs + * @in_ie: Address of IEs to search + * @in_len: Length limit from in_ie + * @wps_ie: If not NULL and WPS IE is found, WPS IE will be copied to the buf starting from wps_ie + * @wps_ielen: If not NULL and WPS IE is found, will set to the length of the entire WPS IE + * + * Returns: The address of the WPS IE found, or NULL + */ +u8 *rtw_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen) +{ + uint cnt; + u8 *wpsie_ptr = NULL; + u8 eid, wps_oui[4] = {0x0, 0x50, 0xf2, 0x04}; + + if (wps_ielen) + *wps_ielen = 0; + + if (!in_ie || in_len <= 0) + return wpsie_ptr; + + cnt = 0; + + while (cnt < in_len) { + eid = in_ie[cnt]; + + if ((eid == _WPA_IE_ID_) && (_rtw_memcmp(&in_ie[cnt+2], wps_oui, 4))) { + wpsie_ptr = &in_ie[cnt]; + + if (wps_ie) + memcpy(wps_ie, &in_ie[cnt], in_ie[cnt+1]+2); + + if (wps_ielen) + *wps_ielen = in_ie[cnt+1]+2; + + cnt += in_ie[cnt+1]+2; + + break; + } else { + cnt += in_ie[cnt+1]+2; /* goto next */ + } + } + return wpsie_ptr; +} + +/** + * rtw_get_wps_attr - Search a specific WPS attribute from a given WPS IE + * @wps_ie: Address of WPS IE to search + * @wps_ielen: Length limit from wps_ie + * @target_attr_id: The attribute ID of WPS attribute to search + * @buf_attr: If not NULL and the WPS attribute is found, WPS attribute will be copied to the buf starting from buf_attr + * @len_attr: If not NULL and the WPS attribute is found, will set to the length of the entire WPS attribute + * + * Returns: the address of the specific WPS attribute found, or NULL + */ +u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id , u8 *buf_attr, u32 *len_attr) +{ + u8 *attr_ptr = NULL; + u8 *target_attr_ptr = NULL; + u8 wps_oui[4] = {0x00, 0x50, 0xF2, 0x04}; + + if (len_attr) + *len_attr = 0; + + if ((wps_ie[0] != _VENDOR_SPECIFIC_IE_) || + (_rtw_memcmp(wps_ie + 2, wps_oui , 4) != true)) + return attr_ptr; + + /* 6 = 1(Element ID) + 1(Length) + 4(WPS OUI) */ + attr_ptr = wps_ie + 6; /* goto first attr */ + + while (attr_ptr - wps_ie < wps_ielen) { + /* 4 = 2(Attribute ID) + 2(Length) */ + u16 attr_id = RTW_GET_BE16(attr_ptr); + u16 attr_data_len = RTW_GET_BE16(attr_ptr + 2); + u16 attr_len = attr_data_len + 4; + + if (attr_id == target_attr_id) { + target_attr_ptr = attr_ptr; + if (buf_attr) + memcpy(buf_attr, attr_ptr, attr_len); + if (len_attr) + *len_attr = attr_len; + break; + } else { + attr_ptr += attr_len; /* goto next */ + } + } + return target_attr_ptr; +} + +/** + * rtw_get_wps_attr_content - Search a specific WPS attribute content from a given WPS IE + * @wps_ie: Address of WPS IE to search + * @wps_ielen: Length limit from wps_ie + * @target_attr_id: The attribute ID of WPS attribute to search + * @buf_content: If not NULL and the WPS attribute is found, WPS attribute content will be copied to the buf starting from buf_content + * @len_content: If not NULL and the WPS attribute is found, will set to the length of the WPS attribute content + * + * Returns: the address of the specific WPS attribute content found, or NULL + */ +u8 *rtw_get_wps_attr_content(u8 *wps_ie, uint wps_ielen, u16 target_attr_id , u8 *buf_content, uint *len_content) +{ + u8 *attr_ptr; + u32 attr_len; + + if (len_content) + *len_content = 0; + + attr_ptr = rtw_get_wps_attr(wps_ie, wps_ielen, target_attr_id, NULL, &attr_len); + + if (attr_ptr && attr_len) { + if (buf_content) + memcpy(buf_content, attr_ptr+4, attr_len-4); + + if (len_content) + *len_content = attr_len-4; + + return attr_ptr+4; + } + + return NULL; +} + +static int rtw_ieee802_11_parse_vendor_specific(u8 *pos, uint elen, + struct rtw_ieee802_11_elems *elems, + int show_errors) +{ + unsigned int oui; + + /* first 3 bytes in vendor specific information element are the IEEE + * OUI of the vendor. The following byte is used a vendor specific + * sub-type. */ + if (elen < 4) { + if (show_errors) { + DBG_88E("short vendor specific information element ignored (len=%lu)\n", + (unsigned long) elen); + } + return -1; + } + + oui = RTW_GET_BE24(pos); + switch (oui) { + case OUI_MICROSOFT: + /* Microsoft/Wi-Fi information elements are further typed and + * subtyped */ + switch (pos[3]) { + case 1: + /* Microsoft OUI (00:50:F2) with OUI Type 1: + * real WPA information element */ + elems->wpa_ie = pos; + elems->wpa_ie_len = elen; + break; + case WME_OUI_TYPE: /* this is a Wi-Fi WME info. element */ + if (elen < 5) { + DBG_88E("short WME information element ignored (len=%lu)\n", + (unsigned long) elen); + return -1; + } + switch (pos[4]) { + case WME_OUI_SUBTYPE_INFORMATION_ELEMENT: + case WME_OUI_SUBTYPE_PARAMETER_ELEMENT: + elems->wme = pos; + elems->wme_len = elen; + break; + case WME_OUI_SUBTYPE_TSPEC_ELEMENT: + elems->wme_tspec = pos; + elems->wme_tspec_len = elen; + break; + default: + DBG_88E("unknown WME information element ignored (subtype=%d len=%lu)\n", + pos[4], (unsigned long) elen); + return -1; + } + break; + case 4: + /* Wi-Fi Protected Setup (WPS) IE */ + elems->wps_ie = pos; + elems->wps_ie_len = elen; + break; + default: + DBG_88E("Unknown Microsoft information element ignored (type=%d len=%lu)\n", + pos[3], (unsigned long) elen); + return -1; + } + break; + + case OUI_BROADCOM: + switch (pos[3]) { + case VENDOR_HT_CAPAB_OUI_TYPE: + elems->vendor_ht_cap = pos; + elems->vendor_ht_cap_len = elen; + break; + default: + DBG_88E("Unknown Broadcom information element ignored (type=%d len=%lu)\n", + pos[3], (unsigned long) elen); + return -1; + } + break; + default: + DBG_88E("unknown vendor specific information element ignored (vendor OUI %02x:%02x:%02x len=%lu)\n", + pos[0], pos[1], pos[2], (unsigned long) elen); + return -1; + } + return 0; +} + +/** + * ieee802_11_parse_elems - Parse information elements in management frames + * @start: Pointer to the start of IEs + * @len: Length of IE buffer in octets + * @elems: Data structure for parsed elements + * @show_errors: Whether to show parsing errors in debug log + * Returns: Parsing result + */ +enum parse_res rtw_ieee802_11_parse_elems(u8 *start, uint len, + struct rtw_ieee802_11_elems *elems, + int show_errors) +{ + uint left = len; + u8 *pos = start; + int unknown = 0; + + _rtw_memset(elems, 0, sizeof(*elems)); + + while (left >= 2) { + u8 id, elen; + + id = *pos++; + elen = *pos++; + left -= 2; + + if (elen > left) { + if (show_errors) { + DBG_88E("IEEE 802.11 element parse failed (id=%d elen=%d left=%lu)\n", + id, elen, (unsigned long) left); + } + return ParseFailed; + } + + switch (id) { + case WLAN_EID_SSID: + elems->ssid = pos; + elems->ssid_len = elen; + break; + case WLAN_EID_SUPP_RATES: + elems->supp_rates = pos; + elems->supp_rates_len = elen; + break; + case WLAN_EID_FH_PARAMS: + elems->fh_params = pos; + elems->fh_params_len = elen; + break; + case WLAN_EID_DS_PARAMS: + elems->ds_params = pos; + elems->ds_params_len = elen; + break; + case WLAN_EID_CF_PARAMS: + elems->cf_params = pos; + elems->cf_params_len = elen; + break; + case WLAN_EID_TIM: + elems->tim = pos; + elems->tim_len = elen; + break; + case WLAN_EID_IBSS_PARAMS: + elems->ibss_params = pos; + elems->ibss_params_len = elen; + break; + case WLAN_EID_CHALLENGE: + elems->challenge = pos; + elems->challenge_len = elen; + break; + case WLAN_EID_ERP_INFO: + elems->erp_info = pos; + elems->erp_info_len = elen; + break; + case WLAN_EID_EXT_SUPP_RATES: + elems->ext_supp_rates = pos; + elems->ext_supp_rates_len = elen; + break; + case WLAN_EID_VENDOR_SPECIFIC: + if (rtw_ieee802_11_parse_vendor_specific(pos, elen, elems, show_errors)) + unknown++; + break; + case WLAN_EID_RSN: + elems->rsn_ie = pos; + elems->rsn_ie_len = elen; + break; + case WLAN_EID_PWR_CAPABILITY: + elems->power_cap = pos; + elems->power_cap_len = elen; + break; + case WLAN_EID_SUPPORTED_CHANNELS: + elems->supp_channels = pos; + elems->supp_channels_len = elen; + break; + case WLAN_EID_MOBILITY_DOMAIN: + elems->mdie = pos; + elems->mdie_len = elen; + break; + case WLAN_EID_FAST_BSS_TRANSITION: + elems->ftie = pos; + elems->ftie_len = elen; + break; + case WLAN_EID_TIMEOUT_INTERVAL: + elems->timeout_int = pos; + elems->timeout_int_len = elen; + break; + case WLAN_EID_HT_CAP: + elems->ht_capabilities = pos; + elems->ht_capabilities_len = elen; + break; + case WLAN_EID_HT_OPERATION: + elems->ht_operation = pos; + elems->ht_operation_len = elen; + break; + default: + unknown++; + if (!show_errors) + break; + DBG_88E("IEEE 802.11 element parse ignored unknown element (id=%d elen=%d)\n", + id, elen); + break; + } + left -= elen; + pos += elen; + } + if (left) + return ParseFailed; + return unknown ? ParseUnknown : ParseOK; +} + +u8 key_char2num(u8 ch) +{ + if ((ch >= '0') && (ch <= '9')) + return ch - '0'; + else if ((ch >= 'a') && (ch <= 'f')) + return ch - 'a' + 10; + else if ((ch >= 'A') && (ch <= 'F')) + return ch - 'A' + 10; + else + return 0xff; +} + +u8 str_2char2num(u8 hch, u8 lch) +{ + return (key_char2num(hch) * 10) + key_char2num(lch); +} + +u8 key_2char2num(u8 hch, u8 lch) +{ + return (key_char2num(hch) << 4) | key_char2num(lch); +} + +void rtw_macaddr_cfg(u8 *mac_addr) +{ + u8 mac[ETH_ALEN]; + if (mac_addr == NULL) + return; + + if (rtw_initmac) { /* Users specify the mac address */ + int jj, kk; + + for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) + mac[jj] = key_2char2num(rtw_initmac[kk], rtw_initmac[kk + 1]); + memcpy(mac_addr, mac, ETH_ALEN); + } else { /* Use the mac address stored in the Efuse */ + memcpy(mac, mac_addr, ETH_ALEN); + } + + if (((mac[0] == 0xff) && (mac[1] == 0xff) && (mac[2] == 0xff) && + (mac[3] == 0xff) && (mac[4] == 0xff) && (mac[5] == 0xff)) || + ((mac[0] == 0x0) && (mac[1] == 0x0) && (mac[2] == 0x0) && + (mac[3] == 0x0) && (mac[4] == 0x0) && (mac[5] == 0x0))) { + mac[0] = 0x00; + mac[1] = 0xe0; + mac[2] = 0x4c; + mac[3] = 0x87; + mac[4] = 0x00; + mac[5] = 0x00; + /* use default mac addresss */ + memcpy(mac_addr, mac, ETH_ALEN); + DBG_88E("MAC Address from efuse error, assign default one !!!\n"); + } + + DBG_88E("rtw_macaddr_cfg MAC Address = %pM\n", (mac_addr)); +} + +void dump_ies(u8 *buf, u32 buf_len) +{ + u8 *pos = (u8 *)buf; + u8 id, len; + + while (pos-buf <= buf_len) { + id = *pos; + len = *(pos+1); + + DBG_88E("%s ID:%u, LEN:%u\n", __func__, id, len); + #ifdef CONFIG_88EU_P2P + dump_p2p_ie(pos, len); + #endif + dump_wps_ie(pos, len); + + pos += (2 + len); + } +} + +void dump_wps_ie(u8 *ie, u32 ie_len) +{ + u8 *pos = (u8 *)ie; + u16 id; + u16 len; + u8 *wps_ie; + uint wps_ielen; + + wps_ie = rtw_get_wps_ie(ie, ie_len, NULL, &wps_ielen); + if (wps_ie != ie || wps_ielen == 0) + return; + + pos += 6; + while (pos-ie < ie_len) { + id = RTW_GET_BE16(pos); + len = RTW_GET_BE16(pos + 2); + DBG_88E("%s ID:0x%04x, LEN:%u\n", __func__, id, len); + pos += (4+len); + } +} + +#ifdef CONFIG_88EU_P2P +void dump_p2p_ie(u8 *ie, u32 ie_len) +{ + u8 *pos = (u8 *)ie; + u8 id; + u16 len; + u8 *p2p_ie; + uint p2p_ielen; + + p2p_ie = rtw_get_p2p_ie(ie, ie_len, NULL, &p2p_ielen); + if (p2p_ie != ie || p2p_ielen == 0) + return; + + pos += 6; + while (pos-ie < ie_len) { + id = *pos; + len = RTW_GET_LE16(pos+1); + DBG_88E("%s ID:%u, LEN:%u\n", __func__, id, len); + pos += (3+len); + } +} + +/** + * rtw_get_p2p_ie - Search P2P IE from a series of IEs + * @in_ie: Address of IEs to search + * @in_len: Length limit from in_ie + * @p2p_ie: If not NULL and P2P IE is found, P2P IE will be copied to the buf starting from p2p_ie + * @p2p_ielen: If not NULL and P2P IE is found, will set to the length of the entire P2P IE + * + * Returns: The address of the P2P IE found, or NULL + */ +u8 *rtw_get_p2p_ie(u8 *in_ie, int in_len, u8 *p2p_ie, uint *p2p_ielen) +{ + uint cnt = 0; + u8 *p2p_ie_ptr; + u8 eid, p2p_oui[4] = {0x50, 0x6F, 0x9A, 0x09}; + + if (p2p_ielen != NULL) + *p2p_ielen = 0; + + while (cnt < in_len) { + eid = in_ie[cnt]; + if ((in_len < 0) || (cnt > MAX_IE_SZ)) { + dump_stack(); + return NULL; + } + if ((eid == _VENDOR_SPECIFIC_IE_) && (_rtw_memcmp(&in_ie[cnt+2], p2p_oui, 4) == true)) { + p2p_ie_ptr = in_ie + cnt; + + if (p2p_ie != NULL) + memcpy(p2p_ie, &in_ie[cnt], in_ie[cnt + 1] + 2); + if (p2p_ielen != NULL) + *p2p_ielen = in_ie[cnt + 1] + 2; + return p2p_ie_ptr; + } else { + cnt += in_ie[cnt + 1] + 2; /* goto next */ + } + } + return NULL; +} + +/** + * rtw_get_p2p_attr - Search a specific P2P attribute from a given P2P IE + * @p2p_ie: Address of P2P IE to search + * @p2p_ielen: Length limit from p2p_ie + * @target_attr_id: The attribute ID of P2P attribute to search + * @buf_attr: If not NULL and the P2P attribute is found, P2P attribute will be copied to the buf starting from buf_attr + * @len_attr: If not NULL and the P2P attribute is found, will set to the length of the entire P2P attribute + * + * Returns: the address of the specific WPS attribute found, or NULL + */ +u8 *rtw_get_p2p_attr(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id , u8 *buf_attr, u32 *len_attr) +{ + u8 *attr_ptr = NULL; + u8 *target_attr_ptr = NULL; + u8 p2p_oui[4] = {0x50, 0x6F, 0x9A, 0x09}; + + if (len_attr) + *len_attr = 0; + + if (!p2p_ie || (p2p_ie[0] != _VENDOR_SPECIFIC_IE_) || + (_rtw_memcmp(p2p_ie + 2, p2p_oui , 4) != true)) + return attr_ptr; + + /* 6 = 1(Element ID) + 1(Length) + 3 (OUI) + 1(OUI Type) */ + attr_ptr = p2p_ie + 6; /* goto first attr */ + + while (attr_ptr - p2p_ie < p2p_ielen) { + /* 3 = 1(Attribute ID) + 2(Length) */ + u8 attr_id = *attr_ptr; + u16 attr_data_len = RTW_GET_LE16(attr_ptr + 1); + u16 attr_len = attr_data_len + 3; + + if (attr_id == target_attr_id) { + target_attr_ptr = attr_ptr; + + if (buf_attr) + memcpy(buf_attr, attr_ptr, attr_len); + if (len_attr) + *len_attr = attr_len; + break; + } else { + attr_ptr += attr_len; /* goto next */ + } + } + return target_attr_ptr; +} + +/** + * rtw_get_p2p_attr_content - Search a specific P2P attribute content from a given P2P IE + * @p2p_ie: Address of P2P IE to search + * @p2p_ielen: Length limit from p2p_ie + * @target_attr_id: The attribute ID of P2P attribute to search + * @buf_content: If not NULL and the P2P attribute is found, P2P attribute content will be copied to the buf starting from buf_content + * @len_content: If not NULL and the P2P attribute is found, will set to the length of the P2P attribute content + * + * Returns: the address of the specific P2P attribute content found, or NULL + */ +u8 *rtw_get_p2p_attr_content(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id , u8 *buf_content, uint *len_content) +{ + u8 *attr_ptr; + u32 attr_len; + + if (len_content) + *len_content = 0; + + attr_ptr = rtw_get_p2p_attr(p2p_ie, p2p_ielen, target_attr_id, NULL, &attr_len); + + if (attr_ptr && attr_len) { + if (buf_content) + memcpy(buf_content, attr_ptr+3, attr_len-3); + + if (len_content) + *len_content = attr_len-3; + + return attr_ptr+3; + } + + return NULL; +} + +u32 rtw_set_p2p_attr_content(u8 *pbuf, u8 attr_id, u16 attr_len, u8 *pdata_attr) +{ + u32 a_len; + + *pbuf = attr_id; + + /* u16*)(pbuf + 1) = cpu_to_le16(attr_len); */ + RTW_PUT_LE16(pbuf + 1, attr_len); + + if (pdata_attr) + memcpy(pbuf + 3, pdata_attr, attr_len); + + a_len = attr_len + 3; + + return a_len; +} + +static uint rtw_p2p_attr_remove(u8 *ie, uint ielen_ori, u8 attr_id) +{ + u8 *target_attr; + u32 target_attr_len; + uint ielen = ielen_ori; + + while (1) { + target_attr = rtw_get_p2p_attr(ie, ielen, attr_id, NULL, &target_attr_len); + if (target_attr && target_attr_len) { + u8 *next_attr = target_attr+target_attr_len; + uint remain_len = ielen-(next_attr-ie); + + _rtw_memset(target_attr, 0, target_attr_len); + memcpy(target_attr, next_attr, remain_len); + _rtw_memset(target_attr+remain_len, 0, target_attr_len); + *(ie+1) -= target_attr_len; + ielen -= target_attr_len; + } else { + break; + } + } + return ielen; +} + +void rtw_wlan_bssid_ex_remove_p2p_attr(struct wlan_bssid_ex *bss_ex, u8 attr_id) +{ + u8 *p2p_ie; + uint p2p_ielen, p2p_ielen_ori; + + p2p_ie = rtw_get_p2p_ie(bss_ex->IEs+_FIXED_IE_LENGTH_, bss_ex->IELength-_FIXED_IE_LENGTH_, NULL, &p2p_ielen_ori); + if (p2p_ie) { + p2p_ielen = rtw_p2p_attr_remove(p2p_ie, p2p_ielen_ori, attr_id); + if (p2p_ielen != p2p_ielen_ori) { + u8 *next_ie_ori = p2p_ie+p2p_ielen_ori; + u8 *next_ie = p2p_ie+p2p_ielen; + uint remain_len = bss_ex->IELength-(next_ie_ori-bss_ex->IEs); + + memcpy(next_ie, next_ie_ori, remain_len); + _rtw_memset(next_ie+remain_len, 0, p2p_ielen_ori-p2p_ielen); + bss_ex->IELength -= p2p_ielen_ori-p2p_ielen; + } + } +} + +#endif /* CONFIG_88EU_P2P */ + +/* Baron adds to avoid FreeBSD warning */ +int ieee80211_is_empty_essid(const char *essid, int essid_len) +{ + /* Single white space is for Linksys APs */ + if (essid_len == 1 && essid[0] == ' ') + return 1; + + /* Otherwise, if the entire essid is 0, we assume it is hidden */ + while (essid_len) { + essid_len--; + if (essid[essid_len] != '\0') + return 0; + } + + return 1; +} + +int ieee80211_get_hdrlen(u16 fc) +{ + int hdrlen = 24; + + switch (WLAN_FC_GET_TYPE(fc)) { + case RTW_IEEE80211_FTYPE_DATA: + if (fc & RTW_IEEE80211_STYPE_QOS_DATA) + hdrlen += 2; + if ((fc & RTW_IEEE80211_FCTL_FROMDS) && (fc & RTW_IEEE80211_FCTL_TODS)) + hdrlen += 6; /* Addr4 */ + break; + case RTW_IEEE80211_FTYPE_CTL: + switch (WLAN_FC_GET_STYPE(fc)) { + case RTW_IEEE80211_STYPE_CTS: + case RTW_IEEE80211_STYPE_ACK: + hdrlen = 10; + break; + default: + hdrlen = 16; + break; + } + break; + } + + return hdrlen; +} + +static int rtw_get_cipher_info(struct wlan_network *pnetwork) +{ + u32 wpa_ielen; + unsigned char *pbuf; + int group_cipher = 0, pairwise_cipher = 0, is8021x = 0; + int ret = _FAIL; + pbuf = rtw_get_wpa_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength-12); + + if (pbuf && (wpa_ielen > 0)) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_get_cipher_info: wpa_ielen: %d", wpa_ielen)); + if (_SUCCESS == rtw_parse_wpa_ie(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is8021x)) { + pnetwork->BcnInfo.pairwise_cipher = pairwise_cipher; + pnetwork->BcnInfo.group_cipher = group_cipher; + pnetwork->BcnInfo.is_8021x = is8021x; + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s: pnetwork->pairwise_cipher: %d, is_8021x is %d", + __func__, pnetwork->BcnInfo.pairwise_cipher, pnetwork->BcnInfo.is_8021x)); + ret = _SUCCESS; + } + } else { + pbuf = rtw_get_wpa2_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength-12); + + if (pbuf && (wpa_ielen > 0)) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("get RSN IE\n")); + if (_SUCCESS == rtw_parse_wpa2_ie(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is8021x)) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("get RSN IE OK!!!\n")); + pnetwork->BcnInfo.pairwise_cipher = pairwise_cipher; + pnetwork->BcnInfo.group_cipher = group_cipher; + pnetwork->BcnInfo.is_8021x = is8021x; + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s: pnetwork->pairwise_cipher: %d," + "pnetwork->group_cipher is %d, is_8021x is %d", __func__, pnetwork->BcnInfo.pairwise_cipher, + pnetwork->BcnInfo.group_cipher, pnetwork->BcnInfo.is_8021x)); + ret = _SUCCESS; + } + } + } + + return ret; +} + +void rtw_get_bcn_info(struct wlan_network *pnetwork) +{ + unsigned short cap = 0; + u8 bencrypt = 0; + __le16 le_tmp; + u16 wpa_len = 0, rsn_len = 0; + struct HT_info_element *pht_info = NULL; + struct rtw_ieee80211_ht_cap *pht_cap = NULL; + unsigned int len; + unsigned char *p; + + memcpy(&le_tmp, rtw_get_capability_from_ie(pnetwork->network.IEs), 2); + cap = le16_to_cpu(le_tmp); + if (cap & WLAN_CAPABILITY_PRIVACY) { + bencrypt = 1; + pnetwork->network.Privacy = 1; + } else { + pnetwork->BcnInfo.encryp_protocol = ENCRYP_PROTOCOL_OPENSYS; + } + rtw_get_sec_ie(pnetwork->network.IEs , pnetwork->network.IELength, NULL, &rsn_len, NULL, &wpa_len); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_get_bcn_info: ssid =%s\n", pnetwork->network.Ssid.Ssid)); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_get_bcn_info: wpa_len =%d rsn_len =%d\n", wpa_len, rsn_len)); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_get_bcn_info: ssid =%s\n", pnetwork->network.Ssid.Ssid)); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_get_bcn_info: wpa_len =%d rsn_len =%d\n", wpa_len, rsn_len)); + + if (rsn_len > 0) { + pnetwork->BcnInfo.encryp_protocol = ENCRYP_PROTOCOL_WPA2; + } else if (wpa_len > 0) { + pnetwork->BcnInfo.encryp_protocol = ENCRYP_PROTOCOL_WPA; + } else { + if (bencrypt) + pnetwork->BcnInfo.encryp_protocol = ENCRYP_PROTOCOL_WEP; + } + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_get_bcn_info: pnetwork->encryp_protocol is %x\n", + pnetwork->BcnInfo.encryp_protocol)); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_get_bcn_info: pnetwork->encryp_protocol is %x\n", + pnetwork->BcnInfo.encryp_protocol)); + rtw_get_cipher_info(pnetwork); + + /* get bwmode and ch_offset */ + /* parsing HT_CAP_IE */ + p = rtw_get_ie(pnetwork->network.IEs + _FIXED_IE_LENGTH_, _HT_CAPABILITY_IE_, &len, pnetwork->network.IELength - _FIXED_IE_LENGTH_); + if (p && len > 0) { + pht_cap = (struct rtw_ieee80211_ht_cap *)(p + 2); + pnetwork->BcnInfo.ht_cap_info = pht_cap->cap_info; + } else { + pnetwork->BcnInfo.ht_cap_info = 0; + } + /* parsing HT_INFO_IE */ + p = rtw_get_ie(pnetwork->network.IEs + _FIXED_IE_LENGTH_, _HT_ADD_INFO_IE_, &len, pnetwork->network.IELength - _FIXED_IE_LENGTH_); + if (p && len > 0) { + pht_info = (struct HT_info_element *)(p + 2); + pnetwork->BcnInfo.ht_info_infos_0 = pht_info->infos[0]; + } else { + pnetwork->BcnInfo.ht_info_infos_0 = 0; + } +} + +/* show MCS rate, unit: 100Kbps */ +u16 rtw_mcs_rate(u8 rf_type, u8 bw_40MHz, u8 short_GI_20, u8 short_GI_40, unsigned char *MCS_rate) +{ + u16 max_rate = 0; + + if (rf_type == RF_1T1R) { + if (MCS_rate[0] & BIT(7)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 1500 : 1350) : ((short_GI_20) ? 722 : 650); + else if (MCS_rate[0] & BIT(6)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 1350 : 1215) : ((short_GI_20) ? 650 : 585); + else if (MCS_rate[0] & BIT(5)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 1200 : 1080) : ((short_GI_20) ? 578 : 520); + else if (MCS_rate[0] & BIT(4)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 900 : 810) : ((short_GI_20) ? 433 : 390); + else if (MCS_rate[0] & BIT(3)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 600 : 540) : ((short_GI_20) ? 289 : 260); + else if (MCS_rate[0] & BIT(2)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 450 : 405) : ((short_GI_20) ? 217 : 195); + else if (MCS_rate[0] & BIT(1)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 300 : 270) : ((short_GI_20) ? 144 : 130); + else if (MCS_rate[0] & BIT(0)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 150 : 135) : ((short_GI_20) ? 72 : 65); + } else { + if (MCS_rate[1]) { + if (MCS_rate[1] & BIT(7)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 3000 : 2700) : ((short_GI_20) ? 1444 : 1300); + else if (MCS_rate[1] & BIT(6)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 2700 : 2430) : ((short_GI_20) ? 1300 : 1170); + else if (MCS_rate[1] & BIT(5)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 2400 : 2160) : ((short_GI_20) ? 1156 : 1040); + else if (MCS_rate[1] & BIT(4)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 1800 : 1620) : ((short_GI_20) ? 867 : 780); + else if (MCS_rate[1] & BIT(3)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 1200 : 1080) : ((short_GI_20) ? 578 : 520); + else if (MCS_rate[1] & BIT(2)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 900 : 810) : ((short_GI_20) ? 433 : 390); + else if (MCS_rate[1] & BIT(1)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 600 : 540) : ((short_GI_20) ? 289 : 260); + else if (MCS_rate[1] & BIT(0)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 300 : 270) : ((short_GI_20) ? 144 : 130); + } else { + if (MCS_rate[0] & BIT(7)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 1500 : 1350) : ((short_GI_20) ? 722 : 650); + else if (MCS_rate[0] & BIT(6)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 1350 : 1215) : ((short_GI_20) ? 650 : 585); + else if (MCS_rate[0] & BIT(5)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 1200 : 1080) : ((short_GI_20) ? 578 : 520); + else if (MCS_rate[0] & BIT(4)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 900 : 810) : ((short_GI_20) ? 433 : 390); + else if (MCS_rate[0] & BIT(3)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 600 : 540) : ((short_GI_20) ? 289 : 260); + else if (MCS_rate[0] & BIT(2)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 450 : 405) : ((short_GI_20) ? 217 : 195); + else if (MCS_rate[0] & BIT(1)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 300 : 270) : ((short_GI_20) ? 144 : 130); + else if (MCS_rate[0] & BIT(0)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 150 : 135) : ((short_GI_20) ? 72 : 65); + } + } + return max_rate; +} + +int rtw_action_frame_parse(const u8 *frame, u32 frame_len, u8 *category, u8 *action) +{ + const u8 *frame_body = frame + sizeof(struct rtw_ieee80211_hdr_3addr); + u16 fc; + u8 c, a = 0; + + fc = le16_to_cpu(((struct rtw_ieee80211_hdr_3addr *)frame)->frame_ctl); + + if ((fc & (RTW_IEEE80211_FCTL_FTYPE|RTW_IEEE80211_FCTL_STYPE)) != + (RTW_IEEE80211_FTYPE_MGMT|RTW_IEEE80211_STYPE_ACTION)) + return false; + + c = frame_body[0]; + + switch (c) { + case RTW_WLAN_CATEGORY_P2P: /* vendor-specific */ + break; + default: + a = frame_body[1]; + } + + if (category) + *category = c; + if (action) + *action = a; + + return true; +} + +static const char *_action_public_str[] = { + "ACT_PUB_BSSCOEXIST", + "ACT_PUB_DSE_ENABLE", + "ACT_PUB_DSE_DEENABLE", + "ACT_PUB_DSE_REG_LOCATION", + "ACT_PUB_EXT_CHL_SWITCH", + "ACT_PUB_DSE_MSR_REQ", + "ACT_PUB_DSE_MSR_RPRT", + "ACT_PUB_MP", + "ACT_PUB_DSE_PWR_CONSTRAINT", + "ACT_PUB_VENDOR", + "ACT_PUB_GAS_INITIAL_REQ", + "ACT_PUB_GAS_INITIAL_RSP", + "ACT_PUB_GAS_COMEBACK_REQ", + "ACT_PUB_GAS_COMEBACK_RSP", + "ACT_PUB_TDLS_DISCOVERY_RSP", + "ACT_PUB_LOCATION_TRACK", + "ACT_PUB_RSVD", +}; + +const char *action_public_str(u8 action) +{ + action = (action >= ACT_PUBLIC_MAX) ? ACT_PUBLIC_MAX : action; + return _action_public_str[action]; +} -- GitLab From 105981e60135c02ae656ebb9a2baa8eff21a420b Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 21 Aug 2013 22:33:45 -0500 Subject: [PATCH 761/942] staging: r8188eu: Add files for new driver - part 3 This commit adds core/rtw_io.c, core/rtw_ioctl_set.c, and core/rtw_iol.c Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_io.c | 329 +++++ .../staging/rtl8188eu/core/rtw_ioctl_set.c | 1169 +++++++++++++++++ drivers/staging/rtl8188eu/core/rtw_iol.c | 209 +++ 3 files changed, 1707 insertions(+) create mode 100644 drivers/staging/rtl8188eu/core/rtw_io.c create mode 100644 drivers/staging/rtl8188eu/core/rtw_ioctl_set.c create mode 100644 drivers/staging/rtl8188eu/core/rtw_iol.c diff --git a/drivers/staging/rtl8188eu/core/rtw_io.c b/drivers/staging/rtl8188eu/core/rtw_io.c new file mode 100644 index 0000000000000..10c9c6560b202 --- /dev/null +++ b/drivers/staging/rtl8188eu/core/rtw_io.c @@ -0,0 +1,329 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +/* + +The purpose of rtw_io.c + +a. provides the API + +b. provides the protocol engine + +c. provides the software interface between caller and the hardware interface + + +Compiler Flag Option: + +USB: + a. USE_ASYNC_IRP: Both sync/async operations are provided. + +Only sync read/rtw_write_mem operations are provided. + +jackson@realtek.com.tw + +*/ + +#define _RTW_IO_C_ +#include +#include +#include +#include +#include + +#define rtw_le16_to_cpu(val) le16_to_cpu(val) +#define rtw_le32_to_cpu(val) le32_to_cpu(val) +#define rtw_cpu_to_le16(val) cpu_to_le16(val) +#define rtw_cpu_to_le32(val) cpu_to_le32(val) + + +u8 _rtw_read8(struct adapter *adapter, u32 addr) +{ + u8 r_val; + struct io_priv *pio_priv = &adapter->iopriv; + struct intf_hdl *pintfhdl = &(pio_priv->intf); + u8 (*_read8)(struct intf_hdl *pintfhdl, u32 addr); + + _func_enter_; + _read8 = pintfhdl->io_ops._read8; + r_val = _read8(pintfhdl, addr); + _func_exit_; + return r_val; +} + +u16 _rtw_read16(struct adapter *adapter, u32 addr) +{ + u16 r_val; + struct io_priv *pio_priv = &adapter->iopriv; + struct intf_hdl *pintfhdl = &(pio_priv->intf); + u16 (*_read16)(struct intf_hdl *pintfhdl, u32 addr); +_func_enter_; + _read16 = pintfhdl->io_ops._read16; + + r_val = _read16(pintfhdl, addr); +_func_exit_; + return r_val; +} + +u32 _rtw_read32(struct adapter *adapter, u32 addr) +{ + u32 r_val; + struct io_priv *pio_priv = &adapter->iopriv; + struct intf_hdl *pintfhdl = &(pio_priv->intf); + u32 (*_read32)(struct intf_hdl *pintfhdl, u32 addr); +_func_enter_; + _read32 = pintfhdl->io_ops._read32; + + r_val = _read32(pintfhdl, addr); +_func_exit_; + return r_val; +} + +int _rtw_write8(struct adapter *adapter, u32 addr, u8 val) +{ + struct io_priv *pio_priv = &adapter->iopriv; + struct intf_hdl *pintfhdl = &(pio_priv->intf); + int (*_write8)(struct intf_hdl *pintfhdl, u32 addr, u8 val); + int ret; + _func_enter_; + _write8 = pintfhdl->io_ops._write8; + + ret = _write8(pintfhdl, addr, val); + _func_exit_; + + return RTW_STATUS_CODE(ret); +} + +int _rtw_write16(struct adapter *adapter, u32 addr, u16 val) +{ + struct io_priv *pio_priv = &adapter->iopriv; + struct intf_hdl *pintfhdl = &(pio_priv->intf); + int (*_write16)(struct intf_hdl *pintfhdl, u32 addr, u16 val); + int ret; + _func_enter_; + _write16 = pintfhdl->io_ops._write16; + + ret = _write16(pintfhdl, addr, val); + _func_exit_; + + return RTW_STATUS_CODE(ret); +} +int _rtw_write32(struct adapter *adapter, u32 addr, u32 val) +{ + struct io_priv *pio_priv = &adapter->iopriv; + struct intf_hdl *pintfhdl = &(pio_priv->intf); + int (*_write32)(struct intf_hdl *pintfhdl, u32 addr, u32 val); + int ret; + _func_enter_; + _write32 = pintfhdl->io_ops._write32; + + ret = _write32(pintfhdl, addr, val); + _func_exit_; + + return RTW_STATUS_CODE(ret); +} + +int _rtw_writeN(struct adapter *adapter, u32 addr , u32 length , u8 *pdata) +{ + struct io_priv *pio_priv = &adapter->iopriv; + struct intf_hdl *pintfhdl = (struct intf_hdl *)(&(pio_priv->intf)); + int (*_writeN)(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata); + int ret; + _func_enter_; + _writeN = pintfhdl->io_ops._writeN; + + ret = _writeN(pintfhdl, addr, length, pdata); + _func_exit_; + + return RTW_STATUS_CODE(ret); +} +int _rtw_write8_async(struct adapter *adapter, u32 addr, u8 val) +{ + struct io_priv *pio_priv = &adapter->iopriv; + struct intf_hdl *pintfhdl = &(pio_priv->intf); + int (*_write8_async)(struct intf_hdl *pintfhdl, u32 addr, u8 val); + int ret; + _func_enter_; + _write8_async = pintfhdl->io_ops._write8_async; + + ret = _write8_async(pintfhdl, addr, val); + _func_exit_; + + return RTW_STATUS_CODE(ret); +} + +int _rtw_write16_async(struct adapter *adapter, u32 addr, u16 val) +{ + struct io_priv *pio_priv = &adapter->iopriv; + struct intf_hdl *pintfhdl = &(pio_priv->intf); + int (*_write16_async)(struct intf_hdl *pintfhdl, u32 addr, u16 val); + int ret; + +_func_enter_; + _write16_async = pintfhdl->io_ops._write16_async; + ret = _write16_async(pintfhdl, addr, val); +_func_exit_; + + return RTW_STATUS_CODE(ret); +} + +int _rtw_write32_async(struct adapter *adapter, u32 addr, u32 val) +{ + struct io_priv *pio_priv = &adapter->iopriv; + struct intf_hdl *pintfhdl = &(pio_priv->intf); + int (*_write32_async)(struct intf_hdl *pintfhdl, u32 addr, u32 val); + int ret; + +_func_enter_; + _write32_async = pintfhdl->io_ops._write32_async; + ret = _write32_async(pintfhdl, addr, val); +_func_exit_; + + return RTW_STATUS_CODE(ret); +} + +void _rtw_read_mem(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem) +{ + void (*_read_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); + struct io_priv *pio_priv = &adapter->iopriv; + struct intf_hdl *pintfhdl = &(pio_priv->intf); + + _func_enter_; + if (adapter->bDriverStopped || adapter->bSurpriseRemoved) { + RT_TRACE(_module_rtl871x_io_c_, _drv_info_, + ("rtw_read_mem:bDriverStopped(%d) OR bSurpriseRemoved(%d)", + adapter->bDriverStopped, adapter->bSurpriseRemoved)); + return; + } + _read_mem = pintfhdl->io_ops._read_mem; + _read_mem(pintfhdl, addr, cnt, pmem); + _func_exit_; +} + +void _rtw_write_mem(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem) +{ + void (*_write_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); + struct io_priv *pio_priv = &adapter->iopriv; + struct intf_hdl *pintfhdl = &(pio_priv->intf); + + _func_enter_; + + _write_mem = pintfhdl->io_ops._write_mem; + + _write_mem(pintfhdl, addr, cnt, pmem); + + _func_exit_; +} + +void _rtw_read_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem) +{ + u32 (*_read_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); + struct io_priv *pio_priv = &adapter->iopriv; + struct intf_hdl *pintfhdl = &(pio_priv->intf); + + _func_enter_; + + if (adapter->bDriverStopped || adapter->bSurpriseRemoved) { + RT_TRACE(_module_rtl871x_io_c_, _drv_info_, + ("rtw_read_port:bDriverStopped(%d) OR bSurpriseRemoved(%d)", + adapter->bDriverStopped, adapter->bSurpriseRemoved)); + return; + } + + _read_port = pintfhdl->io_ops._read_port; + + _read_port(pintfhdl, addr, cnt, pmem); + + _func_exit_; +} + +void _rtw_read_port_cancel(struct adapter *adapter) +{ + void (*_read_port_cancel)(struct intf_hdl *pintfhdl); + struct io_priv *pio_priv = &adapter->iopriv; + struct intf_hdl *pintfhdl = &(pio_priv->intf); + + _read_port_cancel = pintfhdl->io_ops._read_port_cancel; + + if (_read_port_cancel) + _read_port_cancel(pintfhdl); +} + +u32 _rtw_write_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem) +{ + u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); + struct io_priv *pio_priv = &adapter->iopriv; + struct intf_hdl *pintfhdl = &(pio_priv->intf); + u32 ret = _SUCCESS; + + _func_enter_; + + _write_port = pintfhdl->io_ops._write_port; + + ret = _write_port(pintfhdl, addr, cnt, pmem); + + _func_exit_; + + return ret; +} + +u32 _rtw_write_port_and_wait(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem, int timeout_ms) +{ + int ret = _SUCCESS; + struct xmit_buf *pxmitbuf = (struct xmit_buf *)pmem; + struct submit_ctx sctx; + + rtw_sctx_init(&sctx, timeout_ms); + pxmitbuf->sctx = &sctx; + + ret = _rtw_write_port(adapter, addr, cnt, pmem); + + if (ret == _SUCCESS) + ret = rtw_sctx_wait(&sctx); + + return ret; +} + +void _rtw_write_port_cancel(struct adapter *adapter) +{ + void (*_write_port_cancel)(struct intf_hdl *pintfhdl); + struct io_priv *pio_priv = &adapter->iopriv; + struct intf_hdl *pintfhdl = &(pio_priv->intf); + + _write_port_cancel = pintfhdl->io_ops._write_port_cancel; + + if (_write_port_cancel) + _write_port_cancel(pintfhdl); +} + +int rtw_init_io_priv(struct adapter *padapter, void (*set_intf_ops)(struct _io_ops *pops)) +{ + struct io_priv *piopriv = &padapter->iopriv; + struct intf_hdl *pintf = &piopriv->intf; + + if (set_intf_ops == NULL) + return _FAIL; + + piopriv->padapter = padapter; + pintf->padapter = padapter; + pintf->pintf_dev = adapter_to_dvobj(padapter); + + set_intf_ops(&pintf->io_ops); + + return _SUCCESS; +} diff --git a/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c b/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c new file mode 100644 index 0000000000000..9e127746416fd --- /dev/null +++ b/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c @@ -0,0 +1,1169 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTW_IOCTL_SET_C_ + + +#include +#include +#include +#include + +#include +#include + +extern void indicate_wx_scan_complete_event(struct adapter *padapter); + +#define IS_MAC_ADDRESS_BROADCAST(addr) \ +(\ + ((addr[0] == 0xff) && (addr[1] == 0xff) && \ + (addr[2] == 0xff) && (addr[3] == 0xff) && \ + (addr[4] == 0xff) && (addr[5] == 0xff)) ? true : false \ +) + +u8 rtw_validate_ssid(struct ndis_802_11_ssid *ssid) +{ + u8 i; + u8 ret = true; + +_func_enter_; + + if (ssid->SsidLength > 32) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("ssid length >32\n")); + ret = false; + goto exit; + } + + for (i = 0; i < ssid->SsidLength; i++) { + /* wifi, printable ascii code must be supported */ + if (!((ssid->Ssid[i] >= 0x20) && (ssid->Ssid[i] <= 0x7e))) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("ssid has nonprintabl ascii\n")); + ret = false; + break; + } + } + +exit: + +_func_exit_; + + return ret; +} + +u8 rtw_do_join(struct adapter *padapter) +{ + unsigned long irqL; + struct list_head *plist, *phead; + u8 *pibss = NULL; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct __queue *queue = &(pmlmepriv->scanned_queue); + u8 ret = _SUCCESS; + +_func_enter_; + + _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); + phead = get_list_head(queue); + plist = get_next(phead); + + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("\n rtw_do_join: phead = %p; plist = %p\n\n\n", phead, plist)); + + pmlmepriv->cur_network.join_res = -2; + + set_fwstate(pmlmepriv, _FW_UNDER_LINKING); + + pmlmepriv->pscanned = plist; + + pmlmepriv->to_join = true; + + if (_rtw_queue_empty(queue)) { + _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); + _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); + + /* when set_ssid/set_bssid for rtw_do_join(), but scanning queue is empty */ + /* we try to issue sitesurvey firstly */ + + if (!pmlmepriv->LinkDetectInfo.bBusyTraffic || + pmlmepriv->to_roaming > 0) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("rtw_do_join(): site survey if scanned_queue is empty\n.")); + /* submit site_survey_cmd */ + ret = rtw_sitesurvey_cmd(padapter, &pmlmepriv->assoc_ssid, 1, NULL, 0); + if (_SUCCESS != ret) { + pmlmepriv->to_join = false; + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("rtw_do_join(): site survey return error\n.")); + } + } else { + pmlmepriv->to_join = false; + ret = _FAIL; + } + + goto exit; + } else { + int select_ret; + + _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); + select_ret = rtw_select_and_join_from_scanned_queue(pmlmepriv); + if (select_ret == _SUCCESS) { + pmlmepriv->to_join = false; + _set_timer(&pmlmepriv->assoc_timer, MAX_JOIN_TIMEOUT); + } else { + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) { + /* submit createbss_cmd to change to a ADHOC_MASTER */ + + /* pmlmepriv->lock has been acquired by caller... */ + struct wlan_bssid_ex *pdev_network = &(padapter->registrypriv.dev_network); + + pmlmepriv->fw_state = WIFI_ADHOC_MASTER_STATE; + + pibss = padapter->registrypriv.dev_network.MacAddress; + + _rtw_memset(&pdev_network->Ssid, 0, sizeof(struct ndis_802_11_ssid)); + memcpy(&pdev_network->Ssid, &pmlmepriv->assoc_ssid, sizeof(struct ndis_802_11_ssid)); + + rtw_update_registrypriv_dev_network(padapter); + + rtw_generate_random_ibss(pibss); + + if (rtw_createbss_cmd(padapter) != _SUCCESS) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("***Error =>do_goin: rtw_createbss_cmd status FAIL***\n ")); + ret = false; + goto exit; + } + pmlmepriv->to_join = false; + + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, + ("***Error => rtw_select_and_join_from_scanned_queue FAIL under STA_Mode***\n ")); + } else { + /* can't associate ; reset under-linking */ + _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); + + /* when set_ssid/set_bssid for rtw_do_join(), but there are no desired bss in scanning queue */ + /* we try to issue sitesurvey firstly */ + if (!pmlmepriv->LinkDetectInfo.bBusyTraffic || + pmlmepriv->to_roaming > 0) { + ret = rtw_sitesurvey_cmd(padapter, &pmlmepriv->assoc_ssid, 1, NULL, 0); + if (_SUCCESS != ret) { + pmlmepriv->to_join = false; + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("do_join(): site survey return error\n.")); + } + } else { + ret = _FAIL; + pmlmepriv->to_join = false; + } + } + } + } + +exit: + +_func_exit_; + + return ret; +} + +u8 rtw_set_802_11_bssid(struct adapter *padapter, u8 *bssid) +{ + unsigned long irqL; + u8 status = _SUCCESS; + u32 cur_time = 0; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + +_func_enter_; + + DBG_88E_LEVEL(_drv_info_, "set bssid:%pM\n", bssid); + + if ((bssid[0] == 0x00 && bssid[1] == 0x00 && bssid[2] == 0x00 && + bssid[3] == 0x00 && bssid[4] == 0x00 && bssid[5] == 0x00) || + (bssid[0] == 0xFF && bssid[1] == 0xFF && bssid[2] == 0xFF && + bssid[3] == 0xFF && bssid[4] == 0xFF && bssid[5] == 0xFF)) { + status = _FAIL; + goto exit; + } + + _enter_critical_bh(&pmlmepriv->lock, &irqL); + + + DBG_88E("Set BSSID under fw_state = 0x%08x\n", get_fwstate(pmlmepriv)); + if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) + goto handle_tkip_countermeasure; + else if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) + goto release_mlme_lock; + + if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE)) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("set_bssid: _FW_LINKED||WIFI_ADHOC_MASTER_STATE\n")); + + if (_rtw_memcmp(&pmlmepriv->cur_network.network.MacAddress, bssid, ETH_ALEN)) { + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == false) + goto release_mlme_lock;/* it means driver is in WIFI_ADHOC_MASTER_STATE, we needn't create bss again. */ + } else { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("Set BSSID not the same bssid\n")); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("set_bssid =%pM\n", (bssid))); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("cur_bssid =%pM\n", (pmlmepriv->cur_network.network.MacAddress))); + + rtw_disassoc_cmd(padapter, 0, true); + + if (check_fwstate(pmlmepriv, _FW_LINKED) == true) + rtw_indicate_disconnect(padapter); + + rtw_free_assoc_resources(padapter, 1); + + if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) { + _clr_fwstate_(pmlmepriv, WIFI_ADHOC_MASTER_STATE); + set_fwstate(pmlmepriv, WIFI_ADHOC_STATE); + } + } + } + +handle_tkip_countermeasure: + /* should we add something here...? */ + + if (padapter->securitypriv.btkip_countermeasure) { + cur_time = rtw_get_current_time(); + + if ((cur_time - padapter->securitypriv.btkip_countermeasure_time) > 60 * HZ) { + padapter->securitypriv.btkip_countermeasure = false; + padapter->securitypriv.btkip_countermeasure_time = 0; + } else { + status = _FAIL; + goto release_mlme_lock; + } + } + + memcpy(&pmlmepriv->assoc_bssid, bssid, ETH_ALEN); + pmlmepriv->assoc_by_bssid = true; + + if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) + pmlmepriv->to_join = true; + else + status = rtw_do_join(padapter); + +release_mlme_lock: + _exit_critical_bh(&pmlmepriv->lock, &irqL); + +exit: + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + ("rtw_set_802_11_bssid: status=%d\n", status)); + +_func_exit_; + + return status; +} + +u8 rtw_set_802_11_ssid(struct adapter *padapter, struct ndis_802_11_ssid *ssid) +{ + unsigned long irqL; + u8 status = _SUCCESS; + u32 cur_time = 0; + + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct wlan_network *pnetwork = &pmlmepriv->cur_network; + +_func_enter_; + + DBG_88E_LEVEL(_drv_info_, "set ssid [%s] fw_state=0x%08x\n", + ssid->Ssid, get_fwstate(pmlmepriv)); + + if (!padapter->hw_init_completed) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + ("set_ssid: hw_init_completed == false =>exit!!!\n")); + status = _FAIL; + goto exit; + } + + _enter_critical_bh(&pmlmepriv->lock, &irqL); + + DBG_88E("Set SSID under fw_state = 0x%08x\n", get_fwstate(pmlmepriv)); + if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) { + goto handle_tkip_countermeasure; + } else if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true) { + goto release_mlme_lock; + } + + if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE)) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, + ("set_ssid: _FW_LINKED||WIFI_ADHOC_MASTER_STATE\n")); + + if ((pmlmepriv->assoc_ssid.SsidLength == ssid->SsidLength) && + (_rtw_memcmp(&pmlmepriv->assoc_ssid.Ssid, ssid->Ssid, ssid->SsidLength))) { + if ((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == false)) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + ("Set SSID is the same ssid, fw_state = 0x%08x\n", + get_fwstate(pmlmepriv))); + + if (!rtw_is_same_ibss(padapter, pnetwork)) { + /* if in WIFI_ADHOC_MASTER_STATE | WIFI_ADHOC_STATE, create bss or rejoin again */ + rtw_disassoc_cmd(padapter, 0, true); + + if (check_fwstate(pmlmepriv, _FW_LINKED) == true) + rtw_indicate_disconnect(padapter); + + rtw_free_assoc_resources(padapter, 1); + + if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) { + _clr_fwstate_(pmlmepriv, WIFI_ADHOC_MASTER_STATE); + set_fwstate(pmlmepriv, WIFI_ADHOC_STATE); + } + } else { + goto release_mlme_lock;/* it means driver is in WIFI_ADHOC_MASTER_STATE, we needn't create bss again. */ + } + } else { + rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_JOINBSS, 1); + } + } else { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("Set SSID not the same ssid\n")); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("set_ssid =[%s] len = 0x%x\n", ssid->Ssid, (unsigned int)ssid->SsidLength)); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("assoc_ssid =[%s] len = 0x%x\n", pmlmepriv->assoc_ssid.Ssid, (unsigned int)pmlmepriv->assoc_ssid.SsidLength)); + + rtw_disassoc_cmd(padapter, 0, true); + + if (check_fwstate(pmlmepriv, _FW_LINKED) == true) + rtw_indicate_disconnect(padapter); + + rtw_free_assoc_resources(padapter, 1); + + if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) { + _clr_fwstate_(pmlmepriv, WIFI_ADHOC_MASTER_STATE); + set_fwstate(pmlmepriv, WIFI_ADHOC_STATE); + } + } + } + +handle_tkip_countermeasure: + + if (padapter->securitypriv.btkip_countermeasure) { + cur_time = rtw_get_current_time(); + + if ((cur_time - padapter->securitypriv.btkip_countermeasure_time) > 60 * HZ) { + padapter->securitypriv.btkip_countermeasure = false; + padapter->securitypriv.btkip_countermeasure_time = 0; + } else { + status = _FAIL; + goto release_mlme_lock; + } + } + + memcpy(&pmlmepriv->assoc_ssid, ssid, sizeof(struct ndis_802_11_ssid)); + pmlmepriv->assoc_by_bssid = false; + + if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) { + pmlmepriv->to_join = true; + } else { + status = rtw_do_join(padapter); + } + +release_mlme_lock: + _exit_critical_bh(&pmlmepriv->lock, &irqL); + +exit: + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + ("-rtw_set_802_11_ssid: status =%d\n", status)); +_func_exit_; + return status; +} + +u8 rtw_set_802_11_infrastructure_mode(struct adapter *padapter, + enum ndis_802_11_network_infra networktype) +{ + unsigned long irqL; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct wlan_network *cur_network = &pmlmepriv->cur_network; + enum ndis_802_11_network_infra *pold_state = &(cur_network->network.InfrastructureMode); + +_func_enter_; + + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_notice_, + ("+rtw_set_802_11_infrastructure_mode: old =%d new =%d fw_state = 0x%08x\n", + *pold_state, networktype, get_fwstate(pmlmepriv))); + + if (*pold_state != networktype) { + _enter_critical_bh(&pmlmepriv->lock, &irqL); + + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, (" change mode!")); + /* DBG_88E("change mode, old_mode =%d, new_mode =%d, fw_state = 0x%x\n", *pold_state, networktype, get_fwstate(pmlmepriv)); */ + + if (*pold_state == Ndis802_11APMode) { + /* change to other mode from Ndis802_11APMode */ + cur_network->join_res = -1; + +#ifdef CONFIG_88EU_AP_MODE + stop_ap_mode(padapter); +#endif + } + + if ((check_fwstate(pmlmepriv, _FW_LINKED)) || + (*pold_state == Ndis802_11IBSS)) + rtw_disassoc_cmd(padapter, 0, true); + + if ((check_fwstate(pmlmepriv, _FW_LINKED)) || + (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE))) + rtw_free_assoc_resources(padapter, 1); + + if ((*pold_state == Ndis802_11Infrastructure) || (*pold_state == Ndis802_11IBSS)) { + if (check_fwstate(pmlmepriv, _FW_LINKED) == true) + rtw_indicate_disconnect(padapter); /* will clr Linked_state; before this function, we must have chked whether issue dis-assoc_cmd or not */ + } + + *pold_state = networktype; + + _clr_fwstate_(pmlmepriv, ~WIFI_NULL_STATE); + + switch (networktype) { + case Ndis802_11IBSS: + set_fwstate(pmlmepriv, WIFI_ADHOC_STATE); + break; + case Ndis802_11Infrastructure: + set_fwstate(pmlmepriv, WIFI_STATION_STATE); + break; + case Ndis802_11APMode: + set_fwstate(pmlmepriv, WIFI_AP_STATE); +#ifdef CONFIG_88EU_AP_MODE + start_ap_mode(padapter); +#endif + break; + case Ndis802_11AutoUnknown: + case Ndis802_11InfrastructureMax: + break; + } + _exit_critical_bh(&pmlmepriv->lock, &irqL); + } + +_func_exit_; + + return true; +} + + +u8 rtw_set_802_11_disassociate(struct adapter *padapter) +{ + unsigned long irqL; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + +_func_enter_; + + _enter_critical_bh(&pmlmepriv->lock, &irqL); + + if (check_fwstate(pmlmepriv, _FW_LINKED)) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, + ("MgntActrtw_set_802_11_disassociate: rtw_indicate_disconnect\n")); + + rtw_disassoc_cmd(padapter, 0, true); + rtw_indicate_disconnect(padapter); + rtw_free_assoc_resources(padapter, 1); + rtw_pwr_wakeup(padapter); + } + + _exit_critical_bh(&pmlmepriv->lock, &irqL); + +_func_exit_; + + return true; +} + +u8 rtw_set_802_11_bssid_list_scan(struct adapter *padapter, struct ndis_802_11_ssid *pssid, int ssid_max_num) +{ + unsigned long irqL; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + u8 res = true; + +_func_enter_; + + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("+rtw_set_802_11_bssid_list_scan(), fw_state =%x\n", get_fwstate(pmlmepriv))); + + if (padapter == NULL) { + res = false; + goto exit; + } + if (!padapter->hw_init_completed) { + res = false; + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("\n === rtw_set_802_11_bssid_list_scan:hw_init_completed == false ===\n")); + goto exit; + } + + if ((check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING)) || + (pmlmepriv->LinkDetectInfo.bBusyTraffic)) { + /* Scan or linking is in progress, do nothing. */ + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("rtw_set_802_11_bssid_list_scan fail since fw_state = %x\n", get_fwstate(pmlmepriv))); + res = true; + + if (check_fwstate(pmlmepriv, (_FW_UNDER_SURVEY|_FW_UNDER_LINKING)) == true) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("\n###_FW_UNDER_SURVEY|_FW_UNDER_LINKING\n\n")); + } else { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("\n###pmlmepriv->sitesurveyctrl.traffic_busy == true\n\n")); + } + } else { + if (rtw_is_scan_deny(padapter)) { + DBG_88E(FUNC_ADPT_FMT": scan deny\n", FUNC_ADPT_ARG(padapter)); + indicate_wx_scan_complete_event(padapter); + return _SUCCESS; + } + + _enter_critical_bh(&pmlmepriv->lock, &irqL); + + res = rtw_sitesurvey_cmd(padapter, pssid, ssid_max_num, NULL, 0); + + _exit_critical_bh(&pmlmepriv->lock, &irqL); + } +exit: + +_func_exit_; + + return res; +} + +u8 rtw_set_802_11_authentication_mode(struct adapter *padapter, enum ndis_802_11_auth_mode authmode) +{ + struct security_priv *psecuritypriv = &padapter->securitypriv; + int res; + u8 ret; + +_func_enter_; + + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("set_802_11_auth.mode(): mode =%x\n", authmode)); + + psecuritypriv->ndisauthtype = authmode; + + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, + ("rtw_set_802_11_authentication_mode:psecuritypriv->ndisauthtype=%d", + psecuritypriv->ndisauthtype)); + + if (psecuritypriv->ndisauthtype > 3) + psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; + + res = rtw_set_auth(padapter, psecuritypriv); + + if (res == _SUCCESS) + ret = true; + else + ret = false; + +_func_exit_; + + return ret; +} + +u8 rtw_set_802_11_add_wep(struct adapter *padapter, struct ndis_802_11_wep *wep) +{ + int keyid, res; + struct security_priv *psecuritypriv = &(padapter->securitypriv); + u8 ret = _SUCCESS; + +_func_enter_; + + keyid = wep->KeyIndex & 0x3fffffff; + + if (keyid > 4) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("MgntActrtw_set_802_11_add_wep:keyid>4 =>fail\n")); + ret = false; + goto exit; + } + + switch (wep->KeyLength) { + case 5: + psecuritypriv->dot11PrivacyAlgrthm = _WEP40_; + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("MgntActrtw_set_802_11_add_wep:wep->KeyLength = 5\n")); + break; + case 13: + psecuritypriv->dot11PrivacyAlgrthm = _WEP104_; + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("MgntActrtw_set_802_11_add_wep:wep->KeyLength = 13\n")); + break; + default: + psecuritypriv->dot11PrivacyAlgrthm = _NO_PRIVACY_; + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("MgntActrtw_set_802_11_add_wep:wep->KeyLength!= 5 or 13\n")); + break; + } + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, + ("rtw_set_802_11_add_wep:befor memcpy, wep->KeyLength = 0x%x wep->KeyIndex = 0x%x keyid =%x\n", + wep->KeyLength, wep->KeyIndex, keyid)); + + memcpy(&(psecuritypriv->dot11DefKey[keyid].skey[0]), &(wep->KeyMaterial), wep->KeyLength); + + psecuritypriv->dot11DefKeylen[keyid] = wep->KeyLength; + + psecuritypriv->dot11PrivacyKeyIndex = keyid; + + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, + ("rtw_set_802_11_add_wep:security key material : %x %x %x %x %x %x %x %x %x %x %x %x %x\n", + psecuritypriv->dot11DefKey[keyid].skey[0], + psecuritypriv->dot11DefKey[keyid].skey[1], + psecuritypriv->dot11DefKey[keyid].skey[2], + psecuritypriv->dot11DefKey[keyid].skey[3], + psecuritypriv->dot11DefKey[keyid].skey[4], + psecuritypriv->dot11DefKey[keyid].skey[5], + psecuritypriv->dot11DefKey[keyid].skey[6], + psecuritypriv->dot11DefKey[keyid].skey[7], + psecuritypriv->dot11DefKey[keyid].skey[8], + psecuritypriv->dot11DefKey[keyid].skey[9], + psecuritypriv->dot11DefKey[keyid].skey[10], + psecuritypriv->dot11DefKey[keyid].skey[11], + psecuritypriv->dot11DefKey[keyid].skey[12])); + + res = rtw_set_key(padapter, psecuritypriv, keyid, 1); + + if (res == _FAIL) + ret = false; +exit: +_func_exit_; + return ret; +} + +u8 rtw_set_802_11_remove_wep(struct adapter *padapter, u32 keyindex) +{ + u8 ret = _SUCCESS; + +_func_enter_; + if (keyindex >= 0x80000000 || padapter == NULL) { + ret = false; + goto exit; + } else { + int res; + struct security_priv *psecuritypriv = &(padapter->securitypriv); + if (keyindex < 4) { + _rtw_memset(&psecuritypriv->dot11DefKey[keyindex], 0, 16); + res = rtw_set_key(padapter, psecuritypriv, keyindex, 0); + psecuritypriv->dot11DefKeylen[keyindex] = 0; + if (res == _FAIL) + ret = _FAIL; + } else { + ret = _FAIL; + } + } +exit: + +_func_exit_; + return ret; +} + +u8 rtw_set_802_11_add_key(struct adapter *padapter, struct ndis_802_11_key *key) +{ + uint encryptionalgo; + u8 *pbssid; + struct sta_info *stainfo; + u8 bgroup = false; + u8 bgrouptkey = false;/* can be removed later */ + u8 ret = _SUCCESS; + +_func_enter_; + + if (((key->KeyIndex & 0x80000000) == 0) && ((key->KeyIndex & 0x40000000) > 0)) { + /* It is invalid to clear bit 31 and set bit 30. If the miniport driver encounters this combination, */ + /* it must fail the request and return NDIS_STATUS_INVALID_DATA. */ + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, + ("rtw_set_802_11_add_key: ((key->KeyIndex & 0x80000000)==0)[=%d]", + (int)(key->KeyIndex & 0x80000000) == 0)); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, + ("rtw_set_802_11_add_key:((key->KeyIndex & 0x40000000)>0)[=%d]", + (int)(key->KeyIndex & 0x40000000) > 0)); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, + ("rtw_set_802_11_add_key: key->KeyIndex=%d\n", + (int)key->KeyIndex)); + ret = _FAIL; + goto exit; + } + + if (key->KeyIndex & 0x40000000) { + /* Pairwise key */ + + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("OID_802_11_ADD_KEY: +++++ Pairwise key +++++\n")); + + pbssid = get_bssid(&padapter->mlmepriv); + stainfo = rtw_get_stainfo(&padapter->stapriv, pbssid); + + if ((stainfo != NULL) && (padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X)) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + ("OID_802_11_ADD_KEY:(stainfo!=NULL)&&(Adapter->securitypriv.dot11AuthAlgrthm==dot11AuthAlgrthm_8021X)\n")); + encryptionalgo = stainfo->dot118021XPrivacy; + } else { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("OID_802_11_ADD_KEY: stainfo == NULL)||(Adapter->securitypriv.dot11AuthAlgrthm!= dot11AuthAlgrthm_8021X)\n")); + encryptionalgo = padapter->securitypriv.dot11PrivacyAlgrthm; + } + + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + ("rtw_set_802_11_add_key: (encryptionalgo==%d)!\n", + encryptionalgo)); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + ("rtw_set_802_11_add_key: (Adapter->securitypriv.dot11PrivacyAlgrthm==%d)!\n", + padapter->securitypriv.dot11PrivacyAlgrthm)); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + ("rtw_set_802_11_add_key: (Adapter->securitypriv.dot11AuthAlgrthm==%d)!\n", + padapter->securitypriv.dot11AuthAlgrthm)); + + if ((stainfo != NULL)) + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + ("rtw_set_802_11_add_key: (stainfo->dot118021XPrivacy==%d)!\n", + stainfo->dot118021XPrivacy)); + + if (key->KeyIndex & 0x000000FF) { + /* The key index is specified in the lower 8 bits by values of zero to 255. */ + /* The key index should be set to zero for a Pairwise key, and the driver should fail with */ + /* NDIS_STATUS_INVALID_DATA if the lower 8 bits is not zero */ + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, (" key->KeyIndex & 0x000000FF.\n")); + ret = _FAIL; + goto exit; + } + + /* check BSSID */ + if (IS_MAC_ADDRESS_BROADCAST(key->BSSID) == true) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("MacAddr_isBcst(key->BSSID)\n")); + ret = false; + goto exit; + } + + /* Check key length for TKIP. */ + if ((encryptionalgo == _TKIP_) && (key->KeyLength != 32)) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("TKIP KeyLength:0x%x != 32\n", key->KeyLength)); + ret = _FAIL; + goto exit; + } + + /* Check key length for AES. */ + if ((encryptionalgo == _AES_) && (key->KeyLength != 16)) { + /* For our supplicant, EAPPkt9x.vxd, cannot differentiate TKIP and AES case. */ + if (key->KeyLength == 32) { + key->KeyLength = 16; + } else { + ret = _FAIL; + goto exit; + } + } + + /* Check key length for WEP. For NDTEST, 2005.01.27, by rcnjko. */ + if ((encryptionalgo == _WEP40_ || encryptionalgo == _WEP104_) && + (key->KeyLength != 5 || key->KeyLength != 13)) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("WEP KeyLength:0x%x != 5 or 13\n", key->KeyLength)); + ret = _FAIL; + goto exit; + } + + bgroup = false; + + /* Check the pairwise key. Added by Annie, 2005-07-06. */ + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("------------------------------------------\n")); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("[Pairwise Key set]\n")); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("------------------------------------------\n")); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("key index: 0x%8x(0x%8x)\n", key->KeyIndex, (key->KeyIndex&0x3))); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("key Length: %d\n", key->KeyLength)); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("------------------------------------------\n")); + + } else { + /* Group key - KeyIndex(BIT30 == 0) */ + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("OID_802_11_ADD_KEY: +++++ Group key +++++\n")); + + + /* when add wep key through add key and didn't assigned encryption type before */ + if ((padapter->securitypriv.ndisauthtype <= 3) && + (padapter->securitypriv.dot118021XGrpPrivacy == 0)) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + ("keylen =%d(Adapter->securitypriv.dot11PrivacyAlgrthm=%x )padapter->securitypriv.dot118021XGrpPrivacy(%x)\n", + key->KeyLength, padapter->securitypriv.dot11PrivacyAlgrthm, + padapter->securitypriv.dot118021XGrpPrivacy)); + switch (key->KeyLength) { + case 5: + padapter->securitypriv.dot11PrivacyAlgrthm = _WEP40_; + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + ("Adapter->securitypriv.dot11PrivacyAlgrthm=%x key->KeyLength=%u\n", + padapter->securitypriv.dot11PrivacyAlgrthm, key->KeyLength)); + break; + case 13: + padapter->securitypriv.dot11PrivacyAlgrthm = _WEP104_; + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + ("Adapter->securitypriv.dot11PrivacyAlgrthm=%x key->KeyLength=%u\n", + padapter->securitypriv.dot11PrivacyAlgrthm, key->KeyLength)); + break; + default: + padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + ("Adapter->securitypriv.dot11PrivacyAlgrthm=%x key->KeyLength=%u\n", + padapter->securitypriv.dot11PrivacyAlgrthm, key->KeyLength)); + break; + } + + encryptionalgo = padapter->securitypriv.dot11PrivacyAlgrthm; + + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + (" Adapter->securitypriv.dot11PrivacyAlgrthm=%x\n", + padapter->securitypriv.dot11PrivacyAlgrthm)); + + } else { + encryptionalgo = padapter->securitypriv.dot118021XGrpPrivacy; + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + ("(Adapter->securitypriv.dot11PrivacyAlgrthm=%x)encryptionalgo(%x)=padapter->securitypriv.dot118021XGrpPrivacy(%x)keylen=%d\n", + padapter->securitypriv.dot11PrivacyAlgrthm, encryptionalgo, + padapter->securitypriv.dot118021XGrpPrivacy, key->KeyLength)); + } + + if ((check_fwstate(&padapter->mlmepriv, WIFI_ADHOC_STATE) == true) && (IS_MAC_ADDRESS_BROADCAST(key->BSSID) == false)) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + (" IBSS but BSSID is not Broadcast Address.\n")); + ret = _FAIL; + goto exit; + } + + /* Check key length for TKIP */ + if ((encryptionalgo == _TKIP_) && (key->KeyLength != 32)) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + (" TKIP GTK KeyLength:%u != 32\n", key->KeyLength)); + ret = _FAIL; + goto exit; + } else if (encryptionalgo == _AES_ && (key->KeyLength != 16 && key->KeyLength != 32)) { + /* Check key length for AES */ + /* For NDTEST, we allow keylen = 32 in this case. 2005.01.27, by rcnjko. */ + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + ("<=== SetInfo, OID_802_11_ADD_KEY: AES GTK KeyLength:%u != 16 or 32\n", + key->KeyLength)); + ret = _FAIL; + goto exit; + } + + /* Change the key length for EAPPkt9x.vxd. Added by Annie, 2005-11-03. */ + if ((encryptionalgo == _AES_) && (key->KeyLength == 32)) { + key->KeyLength = 16; + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("AES key length changed: %u\n", key->KeyLength)); + } + + if (key->KeyIndex & 0x8000000) {/* error ??? 0x8000_0000 */ + bgrouptkey = true; + } + + if ((check_fwstate(&padapter->mlmepriv, WIFI_ADHOC_STATE)) && + (check_fwstate(&padapter->mlmepriv, _FW_LINKED))) + bgrouptkey = true; + bgroup = true; + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("------------------------------------------\n")); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("[Group Key set]\n")); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("------------------------------------------\n")) ; + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("key index: 0x%8x(0x%8x)\n", key->KeyIndex, (key->KeyIndex&0x3))); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("key Length: %d\n", key->KeyLength)) ; + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("------------------------------------------\n")); + } + + /* If WEP encryption algorithm, just call rtw_set_802_11_add_wep(). */ + if ((padapter->securitypriv.dot11AuthAlgrthm != dot11AuthAlgrthm_8021X) && + (encryptionalgo == _WEP40_ || encryptionalgo == _WEP104_)) { + u32 keyindex; + u32 len = FIELD_OFFSET(struct ndis_802_11_key, KeyMaterial) + key->KeyLength; + struct ndis_802_11_wep *wep = &padapter->securitypriv.ndiswep; + + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("OID_802_11_ADD_KEY: +++++ WEP key +++++\n")); + + wep->Length = len; + keyindex = key->KeyIndex&0x7fffffff; + wep->KeyIndex = keyindex ; + wep->KeyLength = key->KeyLength; + + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("OID_802_11_ADD_KEY:Before memcpy\n")); + + memcpy(wep->KeyMaterial, key->KeyMaterial, key->KeyLength); + memcpy(&(padapter->securitypriv.dot11DefKey[keyindex].skey[0]), key->KeyMaterial, key->KeyLength); + + padapter->securitypriv.dot11DefKeylen[keyindex] = key->KeyLength; + padapter->securitypriv.dot11PrivacyKeyIndex = keyindex; + + ret = rtw_set_802_11_add_wep(padapter, wep); + goto exit; + } + if (key->KeyIndex & 0x20000000) { + /* SetRSC */ + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("OID_802_11_ADD_KEY: +++++ SetRSC+++++\n")); + if (bgroup) { + unsigned long long keysrc = key->KeyRSC & 0x00FFFFFFFFFFFFULL; + memcpy(&padapter->securitypriv.dot11Grprxpn, &keysrc, 8); + } else { + unsigned long long keysrc = key->KeyRSC & 0x00FFFFFFFFFFFFULL; + memcpy(&padapter->securitypriv.dot11Grptxpn, &keysrc, 8); + } + } + + /* Indicate this key idx is used for TX */ + /* Save the key in KeyMaterial */ + if (bgroup) { /* Group transmit key */ + int res; + + if (bgrouptkey) + padapter->securitypriv.dot118021XGrpKeyid = (u8)key->KeyIndex; + if ((key->KeyIndex&0x3) == 0) { + ret = _FAIL; + goto exit; + } + _rtw_memset(&padapter->securitypriv.dot118021XGrpKey[(u8)((key->KeyIndex) & 0x03)], 0, 16); + _rtw_memset(&padapter->securitypriv.dot118021XGrptxmickey[(u8)((key->KeyIndex) & 0x03)], 0, 16); + _rtw_memset(&padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex) & 0x03)], 0, 16); + + if ((key->KeyIndex & 0x10000000)) { + memcpy(&padapter->securitypriv.dot118021XGrptxmickey[(u8)((key->KeyIndex) & 0x03)], key->KeyMaterial + 16, 8); + memcpy(&padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex) & 0x03)], key->KeyMaterial + 24, 8); + + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + ("\n rtw_set_802_11_add_key:rx mic :0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x\n", + padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex) & 0x03)].skey[0], + padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex-1) & 0x03)].skey[1], + padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex) & 0x03)].skey[2], + padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex-1) & 0x03)].skey[3], + padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex) & 0x03)].skey[4], + padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex-1) & 0x03)].skey[5], + padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex) & 0x03)].skey[6], + padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex-1) & 0x03)].skey[7])); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("\n rtw_set_802_11_add_key:set Group mic key!!!!!!!!\n")); + } else { + memcpy(&padapter->securitypriv.dot118021XGrptxmickey[(u8)((key->KeyIndex) & 0x03)], key->KeyMaterial + 24, 8); + memcpy(&padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex) & 0x03)], key->KeyMaterial + 16, 8); + + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + ("\n rtw_set_802_11_add_key:rx mic :0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x\n", + padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex) & 0x03)].skey[0], + padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex-1) & 0x03)].skey[1], + padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex) & 0x03)].skey[2], + padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex-1) & 0x03)].skey[3], + padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex) & 0x03)].skey[4], + padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex-1) & 0x03)].skey[5], + padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex) & 0x03)].skey[6], + padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex-1) & 0x03)].skey[7])); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + ("\n rtw_set_802_11_add_key:set Group mic key!!!!!!!!\n")); + } + + /* set group key by index */ + memcpy(&padapter->securitypriv.dot118021XGrpKey[(u8)((key->KeyIndex) & 0x03)], key->KeyMaterial, key->KeyLength); + + key->KeyIndex = key->KeyIndex & 0x03; + + padapter->securitypriv.binstallGrpkey = true; + + padapter->securitypriv.bcheck_grpkey = false; + + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("reset group key")); + + res = rtw_set_key(padapter, &padapter->securitypriv, key->KeyIndex, 1); + + if (res == _FAIL) + ret = _FAIL; + + goto exit; + + } else { /* Pairwise Key */ + u8 res; + + pbssid = get_bssid(&padapter->mlmepriv); + stainfo = rtw_get_stainfo(&padapter->stapriv, pbssid); + + if (stainfo != NULL) { + _rtw_memset(&stainfo->dot118021x_UncstKey, 0, 16);/* clear keybuffer */ + + memcpy(&stainfo->dot118021x_UncstKey, key->KeyMaterial, 16); + + if (encryptionalgo == _TKIP_) { + padapter->securitypriv.busetkipkey = false; + + /* _set_timer(&padapter->securitypriv.tkip_timer, 50); */ + + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("\n========== _set_timer\n")); + + /* if TKIP, save the Receive/Transmit MIC key in KeyMaterial[128-255] */ + if ((key->KeyIndex & 0x10000000)) { + memcpy(&stainfo->dot11tkiptxmickey, key->KeyMaterial + 16, 8); + memcpy(&stainfo->dot11tkiprxmickey, key->KeyMaterial + 24, 8); + + } else { + memcpy(&stainfo->dot11tkiptxmickey, key->KeyMaterial + 24, 8); + memcpy(&stainfo->dot11tkiprxmickey, key->KeyMaterial + 16, 8); + } + } + + + /* Set key to CAM through H2C command */ + if (bgrouptkey) { /* never go to here */ + res = rtw_setstakey_cmd(padapter, (unsigned char *)stainfo, false); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("\n rtw_set_802_11_add_key:rtw_setstakey_cmd(group)\n")); + } else { + res = rtw_setstakey_cmd(padapter, (unsigned char *)stainfo, true); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("\n rtw_set_802_11_add_key:rtw_setstakey_cmd(unicast)\n")); + } + if (!res) + ret = _FAIL; + } + } +exit: + +_func_exit_; + return ret; +} + +u8 rtw_set_802_11_remove_key(struct adapter *padapter, struct ndis_802_11_remove_key *key) +{ + u8 *pbssid; + struct sta_info *stainfo; + u8 bgroup = (key->KeyIndex & 0x4000000) > 0 ? false : true; + u8 keyIndex = (u8)key->KeyIndex & 0x03; + u8 ret = _SUCCESS; + +_func_enter_; + + if ((key->KeyIndex & 0xbffffffc) > 0) { + ret = _FAIL; + goto exit; + } + + if (bgroup) { + /* clear group key by index */ + + _rtw_memset(&padapter->securitypriv.dot118021XGrpKey[keyIndex], 0, 16); + + /* \todo Send a H2C Command to Firmware for removing this Key in CAM Entry. */ + } else { + pbssid = get_bssid(&padapter->mlmepriv); + stainfo = rtw_get_stainfo(&padapter->stapriv, pbssid); + if (stainfo) { + /* clear key by BSSID */ + _rtw_memset(&stainfo->dot118021x_UncstKey, 0, 16); + + /* \todo Send a H2C Command to Firmware for disable this Key in CAM Entry. */ + } else { + ret = _FAIL; + goto exit; + } + } +exit: + +_func_exit_; + return ret; +} + +/* +* rtw_get_cur_max_rate - +* @adapter: pointer to struct adapter structure +* +* Return 0 or 100Kbps +*/ +u16 rtw_get_cur_max_rate(struct adapter *adapter) +{ + int i = 0; + u8 *p; + u16 rate = 0, max_rate = 0; + struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct registry_priv *pregistrypriv = &adapter->registrypriv; + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; + struct rtw_ieee80211_ht_cap *pht_capie; + u8 rf_type = 0; + u8 bw_40MHz = 0, short_GI_20 = 0, short_GI_40 = 0; + u16 mcs_rate = 0; + u32 ht_ielen = 0; + + if (adapter->registrypriv.mp_mode == 1) { + if (check_fwstate(pmlmepriv, WIFI_MP_STATE)) + return 0; + } + + if ((!check_fwstate(pmlmepriv, _FW_LINKED)) && + (!check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE))) + return 0; + + if (pmlmeext->cur_wireless_mode & (WIRELESS_11_24N|WIRELESS_11_5N)) { + p = rtw_get_ie(&pcur_bss->IEs[12], _HT_CAPABILITY_IE_, &ht_ielen, pcur_bss->IELength-12); + if (p && ht_ielen > 0) { + pht_capie = (struct rtw_ieee80211_ht_cap *)(p+2); + + memcpy(&mcs_rate, pht_capie->supp_mcs_set, 2); + + /* cur_bwmod is updated by beacon, pmlmeinfo is updated by association response */ + bw_40MHz = (pmlmeext->cur_bwmode && (HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH & pmlmeinfo->HT_info.infos[0])) ? 1 : 0; + + short_GI_20 = (le16_to_cpu(pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info) & IEEE80211_HT_CAP_SGI_20) ? 1 : 0; + short_GI_40 = (le16_to_cpu(pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info) & IEEE80211_HT_CAP_SGI_40) ? 1 : 0; + + rtw_hal_get_hwreg(adapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); + max_rate = rtw_mcs_rate( + rf_type, + bw_40MHz & (pregistrypriv->cbw40_enable), + short_GI_20, + short_GI_40, + pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate + ); + } + } else { + while ((pcur_bss->SupportedRates[i] != 0) && (pcur_bss->SupportedRates[i] != 0xFF)) { + rate = pcur_bss->SupportedRates[i]&0x7F; + if (rate > max_rate) + max_rate = rate; + i++; + } + + max_rate = max_rate*10/2; + } + + return max_rate; +} + +/* +* rtw_set_scan_mode - +* @adapter: pointer to struct adapter structure +* @scan_mode: +* +* Return _SUCCESS or _FAIL +*/ +int rtw_set_scan_mode(struct adapter *adapter, enum rt_scan_type scan_mode) +{ + if (scan_mode != SCAN_ACTIVE && scan_mode != SCAN_PASSIVE) + return _FAIL; + + adapter->mlmepriv.scan_mode = scan_mode; + + return _SUCCESS; +} + +/* +* rtw_set_channel_plan - +* @adapter: pointer to struct adapter structure +* @channel_plan: +* +* Return _SUCCESS or _FAIL +*/ +int rtw_set_channel_plan(struct adapter *adapter, u8 channel_plan) +{ + /* handle by cmd_thread to sync with scan operation */ + return rtw_set_chplan_cmd(adapter, channel_plan, 1); +} + +/* +* rtw_set_country - +* @adapter: pointer to struct adapter structure +* @country_code: string of country code +* +* Return _SUCCESS or _FAIL +*/ +int rtw_set_country(struct adapter *adapter, const char *country_code) +{ + int channel_plan = RT_CHANNEL_DOMAIN_WORLD_WIDE_5G; + + DBG_88E("%s country_code:%s\n", __func__, country_code); + + /* TODO: should have a table to match country code and RT_CHANNEL_DOMAIN */ + /* TODO: should consider 2-character and 3-character country code */ + if (0 == strcmp(country_code, "US")) + channel_plan = RT_CHANNEL_DOMAIN_FCC; + else if (0 == strcmp(country_code, "EU")) + channel_plan = RT_CHANNEL_DOMAIN_ETSI; + else if (0 == strcmp(country_code, "JP")) + channel_plan = RT_CHANNEL_DOMAIN_MKK; + else if (0 == strcmp(country_code, "CN")) + channel_plan = RT_CHANNEL_DOMAIN_CHINA; + else + DBG_88E("%s unknown country_code:%s\n", __func__, country_code); + + return rtw_set_channel_plan(adapter, channel_plan); +} diff --git a/drivers/staging/rtl8188eu/core/rtw_iol.c b/drivers/staging/rtl8188eu/core/rtw_iol.c new file mode 100644 index 0000000000000..e6fdd32f9a3f4 --- /dev/null +++ b/drivers/staging/rtl8188eu/core/rtw_iol.c @@ -0,0 +1,209 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#include + +struct xmit_frame *rtw_IOL_accquire_xmit_frame(struct adapter *adapter) +{ + struct xmit_frame *xmit_frame; + struct xmit_buf *xmitbuf; + struct pkt_attrib *pattrib; + struct xmit_priv *pxmitpriv = &(adapter->xmitpriv); + + xmit_frame = rtw_alloc_xmitframe(pxmitpriv); + if (xmit_frame == NULL) { + DBG_88E("%s rtw_alloc_xmitframe return null\n", __func__); + goto exit; + } + + xmitbuf = rtw_alloc_xmitbuf(pxmitpriv); + if (xmitbuf == NULL) { + DBG_88E("%s rtw_alloc_xmitbuf return null\n", __func__); + rtw_free_xmitframe(pxmitpriv, xmit_frame); + xmit_frame = NULL; + goto exit; + } + + xmit_frame->frame_tag = MGNT_FRAMETAG; + xmit_frame->pxmitbuf = xmitbuf; + xmit_frame->buf_addr = xmitbuf->pbuf; + xmitbuf->priv_data = xmit_frame; + + pattrib = &xmit_frame->attrib; + update_mgntframe_attrib(adapter, pattrib); + pattrib->qsel = 0x10;/* Beacon */ + pattrib->subtype = WIFI_BEACON; + pattrib->pktlen = 0; + pattrib->last_txcmdsz = 0; +exit: + return xmit_frame; +} + +int rtw_IOL_append_cmds(struct xmit_frame *xmit_frame, u8 *IOL_cmds, u32 cmd_len) +{ + struct pkt_attrib *pattrib = &xmit_frame->attrib; + u16 buf_offset; + u32 ori_len; + + buf_offset = TXDESC_OFFSET; + ori_len = buf_offset+pattrib->pktlen; + + /* check if the io_buf can accommodate new cmds */ + if (ori_len + cmd_len + 8 > MAX_XMITBUF_SZ) { + DBG_88E("%s %u is large than MAX_XMITBUF_SZ:%u, can't accommodate new cmds\n", + __func__ , ori_len + cmd_len + 8, MAX_XMITBUF_SZ); + return _FAIL; + } + + memcpy(xmit_frame->buf_addr + buf_offset + pattrib->pktlen, IOL_cmds, cmd_len); + pattrib->pktlen += cmd_len; + pattrib->last_txcmdsz += cmd_len; + + return _SUCCESS; +} + +bool rtw_IOL_applied(struct adapter *adapter) +{ + if (1 == adapter->registrypriv.fw_iol) + return true; + + if ((2 == adapter->registrypriv.fw_iol) && (!adapter_to_dvobj(adapter)->ishighspeed)) + return true; + return false; +} + +int rtw_IOL_exec_cmds_sync(struct adapter *adapter, struct xmit_frame *xmit_frame, u32 max_wating_ms, u32 bndy_cnt) +{ + return rtw_hal_iol_cmd(adapter, xmit_frame, max_wating_ms, bndy_cnt); +} + +int rtw_IOL_append_LLT_cmd(struct xmit_frame *xmit_frame, u8 page_boundary) +{ + return _SUCCESS; +} + +int _rtw_IOL_append_WB_cmd(struct xmit_frame *xmit_frame, u16 addr, u8 value, u8 mask) +{ + struct ioreg_cfg cmd = {8, IOREG_CMD_WB_REG, 0x0, 0x0, 0x0}; + + cmd.address = cpu_to_le16(addr); + cmd.data = cpu_to_le32(value); + + if (mask != 0xFF) { + cmd.length = 12; + cmd.mask = cpu_to_le32(mask); + } + return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, cmd.length); +} + +int _rtw_IOL_append_WW_cmd(struct xmit_frame *xmit_frame, u16 addr, u16 value, u16 mask) +{ + struct ioreg_cfg cmd = {8, IOREG_CMD_WW_REG, 0x0, 0x0, 0x0}; + + cmd.address = cpu_to_le16(addr); + cmd.data = cpu_to_le32(value); + + if (mask != 0xFFFF) { + cmd.length = 12; + cmd.mask = cpu_to_le32(mask); + } + return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, cmd.length); +} + +int _rtw_IOL_append_WD_cmd(struct xmit_frame *xmit_frame, u16 addr, u32 value, u32 mask) +{ + struct ioreg_cfg cmd = {8, IOREG_CMD_WD_REG, 0x0, 0x0, 0x0}; + + cmd.address = cpu_to_le16(addr); + cmd.data = cpu_to_le32(value); + + if (mask != 0xFFFFFFFF) { + cmd.length = 12; + cmd.mask = cpu_to_le32(mask); + } + return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, cmd.length); +} + +int _rtw_IOL_append_WRF_cmd(struct xmit_frame *xmit_frame, u8 rf_path, u16 addr, u32 value, u32 mask) +{ + struct ioreg_cfg cmd = {8, IOREG_CMD_W_RF, 0x0, 0x0, 0x0}; + + cmd.address = cpu_to_le16((rf_path<<8) | ((addr) & 0xFF)); + cmd.data = cpu_to_le32(value); + + if (mask != 0x000FFFFF) { + cmd.length = 12; + cmd.mask = cpu_to_le32(mask); + } + return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, cmd.length); +} + +int rtw_IOL_append_DELAY_US_cmd(struct xmit_frame *xmit_frame, u16 us) +{ + struct ioreg_cfg cmd = {4, IOREG_CMD_DELAY_US, 0x0, 0x0, 0x0}; + cmd.address = cpu_to_le16(us); + + return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, 4); +} + +int rtw_IOL_append_DELAY_MS_cmd(struct xmit_frame *xmit_frame, u16 ms) +{ + struct ioreg_cfg cmd = {4, IOREG_CMD_DELAY_US, 0x0, 0x0, 0x0}; + + cmd.address = cpu_to_le16(ms); + return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, 4); +} + +int rtw_IOL_append_END_cmd(struct xmit_frame *xmit_frame) +{ + struct ioreg_cfg cmd = {4, IOREG_CMD_END, cpu_to_le16(0xFFFF), cpu_to_le32(0xFF), 0x0}; + + return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, 4); +} + +u8 rtw_IOL_cmd_boundary_handle(struct xmit_frame *pxmit_frame) +{ + u8 is_cmd_bndy = false; + if (((pxmit_frame->attrib.pktlen+32)%256) + 8 >= 256) { + rtw_IOL_append_END_cmd(pxmit_frame); + pxmit_frame->attrib.pktlen = ((((pxmit_frame->attrib.pktlen+32)/256)+1)*256); + + pxmit_frame->attrib.last_txcmdsz = pxmit_frame->attrib.pktlen; + is_cmd_bndy = true; + } + return is_cmd_bndy; +} + +void rtw_IOL_cmd_buf_dump(struct adapter *Adapter, int buf_len, u8 *pbuf) +{ + int i; + int j = 1; + + pr_info("###### %s ######\n", __func__); + for (i = 0; i < buf_len; i++) { + printk("%02x-", *(pbuf+i)); + + if (j%32 == 0) + printk("\n"); + j++; + } + printk("\n"); + pr_info("=============ioreg_cmd len=%d===============\n", buf_len); +} -- GitLab From 7b464c9fa5cc2723508d394e389f72f0def24705 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 21 Aug 2013 22:33:46 -0500 Subject: [PATCH 762/942] staging: r8188eu: Add files for new driver - part 4 This commit adds files core/rtw_led.c, core/rtw_mlme.c, core/rtw_mlme_ext.c, core/rtw_mp.c, core/rtw_mp_ioctl.c, and core/rtw_p2p.c Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_led.c | 1692 ++++ drivers/staging/rtl8188eu/core/rtw_mlme.c | 2442 +++++ drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 8481 +++++++++++++++++ drivers/staging/rtl8188eu/core/rtw_mp.c | 997 ++ drivers/staging/rtl8188eu/core/rtw_mp_ioctl.c | 1508 +++ drivers/staging/rtl8188eu/core/rtw_p2p.c | 2064 ++++ 6 files changed, 17184 insertions(+) create mode 100644 drivers/staging/rtl8188eu/core/rtw_led.c create mode 100644 drivers/staging/rtl8188eu/core/rtw_mlme.c create mode 100644 drivers/staging/rtl8188eu/core/rtw_mlme_ext.c create mode 100644 drivers/staging/rtl8188eu/core/rtw_mp.c create mode 100644 drivers/staging/rtl8188eu/core/rtw_mp_ioctl.c create mode 100644 drivers/staging/rtl8188eu/core/rtw_p2p.c diff --git a/drivers/staging/rtl8188eu/core/rtw_led.c b/drivers/staging/rtl8188eu/core/rtw_led.c new file mode 100644 index 0000000000000..2db23806a9ba8 --- /dev/null +++ b/drivers/staging/rtl8188eu/core/rtw_led.c @@ -0,0 +1,1692 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#include +#include "rtw_led.h" + +/* */ +/* Description: */ +/* Callback function of LED BlinkTimer, */ +/* it just schedules to corresponding BlinkWorkItem/led_blink_hdl */ +/* */ +void BlinkTimerCallback(void *data) +{ + struct LED_871x *pLed = (struct LED_871x *)data; + struct adapter *padapter = pLed->padapter; + + if ((padapter->bSurpriseRemoved) || (padapter->bDriverStopped)) + return; + + _set_workitem(&(pLed->BlinkWorkItem)); +} + +/* */ +/* Description: */ +/* Callback function of LED BlinkWorkItem. */ +/* We dispatch acture LED blink action according to LedStrategy. */ +/* */ +void BlinkWorkItemCallback(struct work_struct *work) +{ + struct LED_871x *pLed = container_of(work, struct LED_871x, BlinkWorkItem); + BlinkHandler(pLed); +} + +/* */ +/* Description: */ +/* Reset status of LED_871x object. */ +/* */ +void ResetLedStatus(struct LED_871x *pLed) +{ + pLed->CurrLedState = RTW_LED_OFF; /* Current LED state. */ + pLed->bLedOn = false; /* true if LED is ON, false if LED is OFF. */ + + pLed->bLedBlinkInProgress = false; /* true if it is blinking, false o.w.. */ + pLed->bLedWPSBlinkInProgress = false; + + pLed->BlinkTimes = 0; /* Number of times to toggle led state for blinking. */ + pLed->BlinkingLedState = LED_UNKNOWN; /* Next state for blinking, either RTW_LED_ON or RTW_LED_OFF are. */ + + pLed->bLedNoLinkBlinkInProgress = false; + pLed->bLedLinkBlinkInProgress = false; + pLed->bLedStartToLinkBlinkInProgress = false; + pLed->bLedScanBlinkInProgress = false; +} + +/*Description: */ +/* Initialize an LED_871x object. */ +void InitLed871x(struct adapter *padapter, struct LED_871x *pLed, enum LED_PIN_871x LedPin) +{ + pLed->padapter = padapter; + pLed->LedPin = LedPin; + + ResetLedStatus(pLed); + + _init_timer(&(pLed->BlinkTimer), padapter->pnetdev, BlinkTimerCallback, pLed); + + _init_workitem(&(pLed->BlinkWorkItem), BlinkWorkItemCallback, pLed); +} + + +/* */ +/* Description: */ +/* DeInitialize an LED_871x object. */ +/* */ +void DeInitLed871x(struct LED_871x *pLed) +{ + _cancel_workitem_sync(&(pLed->BlinkWorkItem)); + _cancel_timer_ex(&(pLed->BlinkTimer)); + ResetLedStatus(pLed); +} + +/* */ +/* Description: */ +/* Implementation of LED blinking behavior. */ +/* It toggle off LED and schedule corresponding timer if necessary. */ +/* */ + +static void SwLedBlink(struct LED_871x *pLed) +{ + struct adapter *padapter = pLed->padapter; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + u8 bStopBlinking = false; + + /* Change LED according to BlinkingLedState specified. */ + if (pLed->BlinkingLedState == RTW_LED_ON) { + SwLedOn(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); + } else { + SwLedOff(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); + } + + /* Determine if we shall change LED state again. */ + pLed->BlinkTimes--; + switch (pLed->CurrLedState) { + case LED_BLINK_NORMAL: + if (pLed->BlinkTimes == 0) + bStopBlinking = true; + break; + case LED_BLINK_StartToBlink: + if (check_fwstate(pmlmepriv, _FW_LINKED) && check_fwstate(pmlmepriv, WIFI_STATION_STATE)) + bStopBlinking = true; + if (check_fwstate(pmlmepriv, _FW_LINKED) && + (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) || + check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE))) + bStopBlinking = true; + else if (pLed->BlinkTimes == 0) + bStopBlinking = true; + break; + case LED_BLINK_WPS: + if (pLed->BlinkTimes == 0) + bStopBlinking = true; + break; + default: + bStopBlinking = true; + break; + } + + if (bStopBlinking) { + /* if (padapter->pwrctrlpriv.cpwm >= PS_STATE_S2) */ + if (0) { + SwLedOff(padapter, pLed); + } else if ((check_fwstate(pmlmepriv, _FW_LINKED)) && (!pLed->bLedOn)) { + SwLedOn(padapter, pLed); + } else if ((check_fwstate(pmlmepriv, _FW_LINKED)) && pLed->bLedOn) { + SwLedOff(padapter, pLed); + } + pLed->BlinkTimes = 0; + pLed->bLedBlinkInProgress = false; + } else { + /* Assign LED state to toggle. */ + if (pLed->BlinkingLedState == RTW_LED_ON) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + + /* Schedule a timer to toggle LED state. */ + switch (pLed->CurrLedState) { + case LED_BLINK_NORMAL: + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); + break; + case LED_BLINK_SLOWLY: + case LED_BLINK_StartToBlink: + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL); + break; + case LED_BLINK_WPS: + if (pLed->BlinkingLedState == RTW_LED_ON) + _set_timer(&(pLed->BlinkTimer), LED_BLINK_LONG_INTERVAL); + else + _set_timer(&(pLed->BlinkTimer), LED_BLINK_LONG_INTERVAL); + break; + default: + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL); + break; + } + } +} + +static void SwLedBlink1(struct LED_871x *pLed) +{ + struct adapter *padapter = pLed->padapter; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + u8 bStopBlinking = false; + + /* Change LED according to BlinkingLedState specified. */ + if (pLed->BlinkingLedState == RTW_LED_ON) { + SwLedOn(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); + } else { + SwLedOff(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); + } + + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { + SwLedOff(padapter, pLed); + ResetLedStatus(pLed); + return; + } + + switch (pLed->CurrLedState) { + case LED_BLINK_SLOWLY: + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + break; + case LED_BLINK_NORMAL: + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA); + break; + case LED_BLINK_SCAN: + pLed->BlinkTimes--; + if (pLed->BlinkTimes == 0) + bStopBlinking = true; + if (bStopBlinking) { + if (check_fwstate(pmlmepriv, _FW_LINKED)) { + pLed->bLedLinkBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_NORMAL; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); + } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) { + pLed->bLedNoLinkBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_SLOWLY; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); + } + pLed->bLedScanBlinkInProgress = false; + } else { + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + } + break; + case LED_BLINK_TXRX: + pLed->BlinkTimes--; + if (pLed->BlinkTimes == 0) + bStopBlinking = true; + if (bStopBlinking) { + if (check_fwstate(pmlmepriv, _FW_LINKED)) { + pLed->bLedLinkBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_NORMAL; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); + } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) { + pLed->bLedNoLinkBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_SLOWLY; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); + } + pLed->BlinkTimes = 0; + pLed->bLedBlinkInProgress = false; + } else { + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); + } + break; + case LED_BLINK_WPS: + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + break; + case LED_BLINK_WPS_STOP: /* WPS success */ + if (pLed->BlinkingLedState == RTW_LED_ON) + bStopBlinking = false; + else + bStopBlinking = true; + + if (bStopBlinking) { + pLed->bLedLinkBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_NORMAL; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); + + pLed->bLedWPSBlinkInProgress = false; + } else { + pLed->BlinkingLedState = RTW_LED_OFF; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA); + } + break; + default: + break; + } +} + +static void SwLedBlink2(struct LED_871x *pLed) +{ + struct adapter *padapter = pLed->padapter; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + u8 bStopBlinking = false; + + /* Change LED according to BlinkingLedState specified. */ + if (pLed->BlinkingLedState == RTW_LED_ON) { + SwLedOn(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); + } else { + SwLedOff(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); + } + + switch (pLed->CurrLedState) { + case LED_BLINK_SCAN: + pLed->BlinkTimes--; + if (pLed->BlinkTimes == 0) + bStopBlinking = true; + if (bStopBlinking) { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { + SwLedOff(padapter, pLed); + } else if (check_fwstate(pmlmepriv, _FW_LINKED)) { + pLed->CurrLedState = RTW_LED_ON; + pLed->BlinkingLedState = RTW_LED_ON; + SwLedOn(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("stop scan blink CurrLedState %d\n", pLed->CurrLedState)); + + } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) { + pLed->CurrLedState = RTW_LED_OFF; + pLed->BlinkingLedState = RTW_LED_OFF; + SwLedOff(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("stop scan blink CurrLedState %d\n", pLed->CurrLedState)); + } + pLed->bLedScanBlinkInProgress = false; + } else { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { + SwLedOff(padapter, pLed); + } else { + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + } + } + break; + case LED_BLINK_TXRX: + pLed->BlinkTimes--; + if (pLed->BlinkTimes == 0) + bStopBlinking = true; + if (bStopBlinking) { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { + SwLedOff(padapter, pLed); + } else if (check_fwstate(pmlmepriv, _FW_LINKED)) { + pLed->CurrLedState = RTW_LED_ON; + pLed->BlinkingLedState = RTW_LED_ON; + SwLedOn(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("stop CurrLedState %d\n", pLed->CurrLedState)); + } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) { + pLed->CurrLedState = RTW_LED_OFF; + pLed->BlinkingLedState = RTW_LED_OFF; + SwLedOff(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("stop CurrLedState %d\n", pLed->CurrLedState)); + } + pLed->bLedBlinkInProgress = false; + } else { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { + SwLedOff(padapter, pLed); + } else { + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); + } + } + break; + default: + break; + } +} + +static void SwLedBlink3(struct LED_871x *pLed) +{ + struct adapter *padapter = pLed->padapter; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + u8 bStopBlinking = false; + + /* Change LED according to BlinkingLedState specified. */ + if (pLed->BlinkingLedState == RTW_LED_ON) { + SwLedOn(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); + } else { + if (pLed->CurrLedState != LED_BLINK_WPS_STOP) + SwLedOff(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); + } + + switch (pLed->CurrLedState) { + case LED_BLINK_SCAN: + pLed->BlinkTimes--; + if (pLed->BlinkTimes == 0) + bStopBlinking = true; + if (bStopBlinking) { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { + SwLedOff(padapter, pLed); + } else if (check_fwstate(pmlmepriv, _FW_LINKED)) { + pLed->CurrLedState = RTW_LED_ON; + pLed->BlinkingLedState = RTW_LED_ON; + if (!pLed->bLedOn) + SwLedOn(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); + } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) { + pLed->CurrLedState = RTW_LED_OFF; + pLed->BlinkingLedState = RTW_LED_OFF; + if (pLed->bLedOn) + SwLedOff(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); + } + pLed->bLedScanBlinkInProgress = false; + } else { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { + SwLedOff(padapter, pLed); + } else { + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + } + } + break; + case LED_BLINK_TXRX: + pLed->BlinkTimes--; + if (pLed->BlinkTimes == 0) + bStopBlinking = true; + if (bStopBlinking) { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { + SwLedOff(padapter, pLed); + } else if (check_fwstate(pmlmepriv, _FW_LINKED)) { + pLed->CurrLedState = RTW_LED_ON; + pLed->BlinkingLedState = RTW_LED_ON; + if (!pLed->bLedOn) + SwLedOn(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); + } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) { + pLed->CurrLedState = RTW_LED_OFF; + pLed->BlinkingLedState = RTW_LED_OFF; + + if (pLed->bLedOn) + SwLedOff(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); + } + pLed->bLedBlinkInProgress = false; + } else { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { + SwLedOff(padapter, pLed); + } else { + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); + } + } + break; + case LED_BLINK_WPS: + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + break; + case LED_BLINK_WPS_STOP: /* WPS success */ + if (pLed->BlinkingLedState == RTW_LED_ON) { + pLed->BlinkingLedState = RTW_LED_OFF; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA); + bStopBlinking = false; + } else { + bStopBlinking = true; + } + if (bStopBlinking) { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { + SwLedOff(padapter, pLed); + } else { + pLed->CurrLedState = RTW_LED_ON; + pLed->BlinkingLedState = RTW_LED_ON; + SwLedOn(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); + } + pLed->bLedWPSBlinkInProgress = false; + } + break; + default: + break; + } +} + +static void SwLedBlink4(struct LED_871x *pLed) +{ + struct adapter *padapter = pLed->padapter; + struct led_priv *ledpriv = &(padapter->ledpriv); + struct LED_871x *pLed1 = &(ledpriv->SwLed1); + u8 bStopBlinking = false; + + /* Change LED according to BlinkingLedState specified. */ + if (pLed->BlinkingLedState == RTW_LED_ON) { + SwLedOn(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); + } else { + SwLedOff(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); + } + + if (!pLed1->bLedWPSBlinkInProgress && pLed1->BlinkingLedState == LED_UNKNOWN) { + pLed1->BlinkingLedState = RTW_LED_OFF; + pLed1->CurrLedState = RTW_LED_OFF; + SwLedOff(padapter, pLed1); + } + + switch (pLed->CurrLedState) { + case LED_BLINK_SLOWLY: + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + break; + case LED_BLINK_StartToBlink: + if (pLed->bLedOn) { + pLed->BlinkingLedState = RTW_LED_OFF; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL); + } else { + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); + } + break; + case LED_BLINK_SCAN: + pLed->BlinkTimes--; + if (pLed->BlinkTimes == 0) + bStopBlinking = false; + if (bStopBlinking) { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { + SwLedOff(padapter, pLed); + } else { + pLed->bLedNoLinkBlinkInProgress = false; + pLed->CurrLedState = LED_BLINK_SLOWLY; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + } + pLed->bLedScanBlinkInProgress = false; + } else { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { + SwLedOff(padapter, pLed); + } else { + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + } + } + break; + case LED_BLINK_TXRX: + pLed->BlinkTimes--; + if (pLed->BlinkTimes == 0) + bStopBlinking = true; + if (bStopBlinking) { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { + SwLedOff(padapter, pLed); + } else { + pLed->bLedNoLinkBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_SLOWLY; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + } + pLed->bLedBlinkInProgress = false; + } else { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { + SwLedOff(padapter, pLed); + } else { + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); + } + } + break; + case LED_BLINK_WPS: + if (pLed->bLedOn) { + pLed->BlinkingLedState = RTW_LED_OFF; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL); + } else { + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); + } + break; + case LED_BLINK_WPS_STOP: /* WPS authentication fail */ + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); + break; + case LED_BLINK_WPS_STOP_OVERLAP: /* WPS session overlap */ + pLed->BlinkTimes--; + if (pLed->BlinkTimes == 0) { + if (pLed->bLedOn) + pLed->BlinkTimes = 1; + else + bStopBlinking = true; + } + + if (bStopBlinking) { + pLed->BlinkTimes = 10; + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA); + } else { + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); + } + break; + default: + break; + } + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("SwLedBlink4 CurrLedState %d\n", pLed->CurrLedState)); +} + +static void SwLedBlink5(struct LED_871x *pLed) +{ + struct adapter *padapter = pLed->padapter; + u8 bStopBlinking = false; + + /* Change LED according to BlinkingLedState specified. */ + if (pLed->BlinkingLedState == RTW_LED_ON) { + SwLedOn(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); + } else { + SwLedOff(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); + } + + switch (pLed->CurrLedState) { + case LED_BLINK_SCAN: + pLed->BlinkTimes--; + if (pLed->BlinkTimes == 0) + bStopBlinking = true; + + if (bStopBlinking) { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { + pLed->CurrLedState = RTW_LED_OFF; + pLed->BlinkingLedState = RTW_LED_OFF; + if (pLed->bLedOn) + SwLedOff(padapter, pLed); + } else { + pLed->CurrLedState = RTW_LED_ON; + pLed->BlinkingLedState = RTW_LED_ON; + if (!pLed->bLedOn) + _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); + } + + pLed->bLedScanBlinkInProgress = false; + } else { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { + SwLedOff(padapter, pLed); + } else { + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + } + } + break; + case LED_BLINK_TXRX: + pLed->BlinkTimes--; + if (pLed->BlinkTimes == 0) + bStopBlinking = true; + + if (bStopBlinking) { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { + pLed->CurrLedState = RTW_LED_OFF; + pLed->BlinkingLedState = RTW_LED_OFF; + if (pLed->bLedOn) + SwLedOff(padapter, pLed); + } else { + pLed->CurrLedState = RTW_LED_ON; + pLed->BlinkingLedState = RTW_LED_ON; + if (!pLed->bLedOn) + _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); + } + + pLed->bLedBlinkInProgress = false; + } else { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { + SwLedOff(padapter, pLed); + } else { + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); + } + } + break; + + default: + break; + } + + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("SwLedBlink5 CurrLedState %d\n", pLed->CurrLedState)); +} + +static void SwLedBlink6(struct LED_871x *pLed) +{ + struct adapter *padapter = pLed->padapter; + + /* Change LED according to BlinkingLedState specified. */ + if (pLed->BlinkingLedState == RTW_LED_ON) { + SwLedOn(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); + } else { + SwLedOff(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); + } + + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("<==== blink6\n")); +} + + /* ALPHA, added by chiyoko, 20090106 */ +static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAction) +{ + struct led_priv *ledpriv = &(padapter->ledpriv); + struct LED_871x *pLed = &(ledpriv->SwLed0); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + + switch (LedAction) { + case LED_CTL_POWER_ON: + case LED_CTL_START_TO_LINK: + case LED_CTL_NO_LINK: + if (!pLed->bLedNoLinkBlinkInProgress) { + if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) + return; + if (pLed->bLedLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedLinkBlinkInProgress = false; + } + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + + pLed->bLedNoLinkBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_SLOWLY; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + } + break; + case LED_CTL_LINK: + if (!pLed->bLedLinkBlinkInProgress) { + if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) + return; + if (pLed->bLedNoLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedNoLinkBlinkInProgress = false; + } + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + pLed->bLedLinkBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_NORMAL; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA); + } + break; + case LED_CTL_SITE_SURVEY: + if ((pmlmepriv->LinkDetectInfo.bBusyTraffic) && (check_fwstate(pmlmepriv, _FW_LINKED))) { + ; + } else if (!pLed->bLedScanBlinkInProgress) { + if (IS_LED_WPS_BLINKING(pLed)) + return; + if (pLed->bLedNoLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedNoLinkBlinkInProgress = false; + } + if (pLed->bLedLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedLinkBlinkInProgress = false; + } + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + pLed->bLedScanBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_SCAN; + pLed->BlinkTimes = 24; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + } + break; + case LED_CTL_TX: + case LED_CTL_RX: + if (!pLed->bLedBlinkInProgress) { + if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) + return; + if (pLed->bLedNoLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedNoLinkBlinkInProgress = false; + } + if (pLed->bLedLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedLinkBlinkInProgress = false; + } + pLed->bLedBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_TXRX; + pLed->BlinkTimes = 2; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); + } + break; + case LED_CTL_START_WPS: /* wait until xinpin finish */ + case LED_CTL_START_WPS_BOTTON: + if (!pLed->bLedWPSBlinkInProgress) { + if (pLed->bLedNoLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedNoLinkBlinkInProgress = false; + } + if (pLed->bLedLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedLinkBlinkInProgress = false; + } + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + if (pLed->bLedScanBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedScanBlinkInProgress = false; + } + pLed->bLedWPSBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_WPS; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + } + break; + case LED_CTL_STOP_WPS: + if (pLed->bLedNoLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedNoLinkBlinkInProgress = false; + } + if (pLed->bLedLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedLinkBlinkInProgress = false; + } + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + if (pLed->bLedScanBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedScanBlinkInProgress = false; + } + if (pLed->bLedWPSBlinkInProgress) + _cancel_timer_ex(&(pLed->BlinkTimer)); + else + pLed->bLedWPSBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_WPS_STOP; + if (pLed->bLedOn) { + pLed->BlinkingLedState = RTW_LED_OFF; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA); + } else { + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), 0); + } + break; + case LED_CTL_STOP_WPS_FAIL: + if (pLed->bLedWPSBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedWPSBlinkInProgress = false; + } + pLed->bLedNoLinkBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_SLOWLY; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + break; + case LED_CTL_POWER_OFF: + pLed->CurrLedState = RTW_LED_OFF; + pLed->BlinkingLedState = RTW_LED_OFF; + if (pLed->bLedNoLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedNoLinkBlinkInProgress = false; + } + if (pLed->bLedLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedLinkBlinkInProgress = false; + } + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + if (pLed->bLedWPSBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedWPSBlinkInProgress = false; + } + if (pLed->bLedScanBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedScanBlinkInProgress = false; + } + SwLedOff(padapter, pLed); + break; + default: + break; + } + + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Led %d\n", pLed->CurrLedState)); +} + + /* Arcadyan/Sitecom , added by chiyoko, 20090216 */ +static void SwLedControlMode2(struct adapter *padapter, enum LED_CTL_MODE LedAction) +{ + struct led_priv *ledpriv = &(padapter->ledpriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct LED_871x *pLed = &(ledpriv->SwLed0); + + switch (LedAction) { + case LED_CTL_SITE_SURVEY: + if (pmlmepriv->LinkDetectInfo.bBusyTraffic) { + } else if (!pLed->bLedScanBlinkInProgress) { + if (IS_LED_WPS_BLINKING(pLed)) + return; + + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + pLed->bLedScanBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_SCAN; + pLed->BlinkTimes = 24; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + } + break; + case LED_CTL_TX: + case LED_CTL_RX: + if ((!pLed->bLedBlinkInProgress) && (check_fwstate(pmlmepriv, _FW_LINKED))) { + if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) + return; + pLed->bLedBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_TXRX; + pLed->BlinkTimes = 2; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); + } + break; + case LED_CTL_LINK: + pLed->CurrLedState = RTW_LED_ON; + pLed->BlinkingLedState = RTW_LED_ON; + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + if (pLed->bLedScanBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedScanBlinkInProgress = false; + } + _set_timer(&(pLed->BlinkTimer), 0); + break; + case LED_CTL_START_WPS: /* wait until xinpin finish */ + case LED_CTL_START_WPS_BOTTON: + if (!pLed->bLedWPSBlinkInProgress) { + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + if (pLed->bLedScanBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedScanBlinkInProgress = false; + } + pLed->bLedWPSBlinkInProgress = true; + pLed->CurrLedState = RTW_LED_ON; + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), 0); + } + break; + case LED_CTL_STOP_WPS: + pLed->bLedWPSBlinkInProgress = false; + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { + SwLedOff(padapter, pLed); + } else { + pLed->CurrLedState = RTW_LED_ON; + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), 0); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); + } + break; + case LED_CTL_STOP_WPS_FAIL: + pLed->bLedWPSBlinkInProgress = false; + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { + SwLedOff(padapter, pLed); + } else { + pLed->CurrLedState = RTW_LED_OFF; + pLed->BlinkingLedState = RTW_LED_OFF; + _set_timer(&(pLed->BlinkTimer), 0); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); + } + break; + case LED_CTL_START_TO_LINK: + case LED_CTL_NO_LINK: + if (!IS_LED_BLINKING(pLed)) { + pLed->CurrLedState = RTW_LED_OFF; + pLed->BlinkingLedState = RTW_LED_OFF; + _set_timer(&(pLed->BlinkTimer), 0); + } + break; + case LED_CTL_POWER_OFF: + pLed->CurrLedState = RTW_LED_OFF; + pLed->BlinkingLedState = RTW_LED_OFF; + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + if (pLed->bLedScanBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedScanBlinkInProgress = false; + } + if (pLed->bLedWPSBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedWPSBlinkInProgress = false; + } + + _set_timer(&(pLed->BlinkTimer), 0); + break; + default: + break; + } + + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); +} + + /* COREGA, added by chiyoko, 20090316 */ + static void SwLedControlMode3(struct adapter *padapter, enum LED_CTL_MODE LedAction) +{ + struct led_priv *ledpriv = &(padapter->ledpriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct LED_871x *pLed = &(ledpriv->SwLed0); + + switch (LedAction) { + case LED_CTL_SITE_SURVEY: + if (pmlmepriv->LinkDetectInfo.bBusyTraffic) { + } else if (!pLed->bLedScanBlinkInProgress) { + if (IS_LED_WPS_BLINKING(pLed)) + return; + + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + pLed->bLedScanBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_SCAN; + pLed->BlinkTimes = 24; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + } + break; + case LED_CTL_TX: + case LED_CTL_RX: + if ((!pLed->bLedBlinkInProgress) && (check_fwstate(pmlmepriv, _FW_LINKED))) { + if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) + return; + pLed->bLedBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_TXRX; + pLed->BlinkTimes = 2; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); + } + break; + case LED_CTL_LINK: + if (IS_LED_WPS_BLINKING(pLed)) + return; + pLed->CurrLedState = RTW_LED_ON; + pLed->BlinkingLedState = RTW_LED_ON; + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + if (pLed->bLedScanBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedScanBlinkInProgress = false; + } + + _set_timer(&(pLed->BlinkTimer), 0); + break; + case LED_CTL_START_WPS: /* wait until xinpin finish */ + case LED_CTL_START_WPS_BOTTON: + if (!pLed->bLedWPSBlinkInProgress) { + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + if (pLed->bLedScanBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedScanBlinkInProgress = false; + } + pLed->bLedWPSBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_WPS; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + } + break; + case LED_CTL_STOP_WPS: + if (pLed->bLedWPSBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedWPSBlinkInProgress = false; + } else { + pLed->bLedWPSBlinkInProgress = true; + } + + pLed->CurrLedState = LED_BLINK_WPS_STOP; + if (pLed->bLedOn) { + pLed->BlinkingLedState = RTW_LED_OFF; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA); + } else { + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), 0); + } + break; + case LED_CTL_STOP_WPS_FAIL: + if (pLed->bLedWPSBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedWPSBlinkInProgress = false; + } + pLed->CurrLedState = RTW_LED_OFF; + pLed->BlinkingLedState = RTW_LED_OFF; + _set_timer(&(pLed->BlinkTimer), 0); + break; + case LED_CTL_START_TO_LINK: + case LED_CTL_NO_LINK: + if (!IS_LED_BLINKING(pLed)) { + pLed->CurrLedState = RTW_LED_OFF; + pLed->BlinkingLedState = RTW_LED_OFF; + _set_timer(&(pLed->BlinkTimer), 0); + } + break; + case LED_CTL_POWER_OFF: + pLed->CurrLedState = RTW_LED_OFF; + pLed->BlinkingLedState = RTW_LED_OFF; + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + if (pLed->bLedScanBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedScanBlinkInProgress = false; + } + if (pLed->bLedWPSBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedWPSBlinkInProgress = false; + } + + _set_timer(&(pLed->BlinkTimer), 0); + break; + default: + break; + } + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, + ("CurrLedState %d\n", pLed->CurrLedState)); +} + + /* Edimax-Belkin, added by chiyoko, 20090413 */ +static void SwLedControlMode4(struct adapter *padapter, enum LED_CTL_MODE LedAction) +{ + struct led_priv *ledpriv = &(padapter->ledpriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct LED_871x *pLed = &(ledpriv->SwLed0); + struct LED_871x *pLed1 = &(ledpriv->SwLed1); + + switch (LedAction) { + case LED_CTL_START_TO_LINK: + if (pLed1->bLedWPSBlinkInProgress) { + pLed1->bLedWPSBlinkInProgress = false; + _cancel_timer_ex(&(pLed1->BlinkTimer)); + + pLed1->BlinkingLedState = RTW_LED_OFF; + pLed1->CurrLedState = RTW_LED_OFF; + + if (pLed1->bLedOn) + _set_timer(&(pLed->BlinkTimer), 0); + } + + if (!pLed->bLedStartToLinkBlinkInProgress) { + if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) + return; + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + if (pLed->bLedNoLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedNoLinkBlinkInProgress = false; + } + + pLed->bLedStartToLinkBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_StartToBlink; + if (pLed->bLedOn) { + pLed->BlinkingLedState = RTW_LED_OFF; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL); + } else { + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); + } + } + break; + case LED_CTL_LINK: + case LED_CTL_NO_LINK: + /* LED1 settings */ + if (LedAction == LED_CTL_LINK) { + if (pLed1->bLedWPSBlinkInProgress) { + pLed1->bLedWPSBlinkInProgress = false; + _cancel_timer_ex(&(pLed1->BlinkTimer)); + + pLed1->BlinkingLedState = RTW_LED_OFF; + pLed1->CurrLedState = RTW_LED_OFF; + + if (pLed1->bLedOn) + _set_timer(&(pLed->BlinkTimer), 0); + } + } + + if (!pLed->bLedNoLinkBlinkInProgress) { + if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) + return; + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + + pLed->bLedNoLinkBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_SLOWLY; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + } + break; + case LED_CTL_SITE_SURVEY: + if ((pmlmepriv->LinkDetectInfo.bBusyTraffic) && (check_fwstate(pmlmepriv, _FW_LINKED))) { + } else if (!pLed->bLedScanBlinkInProgress) { + if (IS_LED_WPS_BLINKING(pLed)) + return; + + if (pLed->bLedNoLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedNoLinkBlinkInProgress = false; + } + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + pLed->bLedScanBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_SCAN; + pLed->BlinkTimes = 24; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + } + break; + case LED_CTL_TX: + case LED_CTL_RX: + if (!pLed->bLedBlinkInProgress) { + if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) + return; + if (pLed->bLedNoLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedNoLinkBlinkInProgress = false; + } + pLed->bLedBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_TXRX; + pLed->BlinkTimes = 2; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); + } + break; + case LED_CTL_START_WPS: /* wait until xinpin finish */ + case LED_CTL_START_WPS_BOTTON: + if (pLed1->bLedWPSBlinkInProgress) { + pLed1->bLedWPSBlinkInProgress = false; + _cancel_timer_ex(&(pLed1->BlinkTimer)); + + pLed1->BlinkingLedState = RTW_LED_OFF; + pLed1->CurrLedState = RTW_LED_OFF; + + if (pLed1->bLedOn) + _set_timer(&(pLed->BlinkTimer), 0); + } + + if (!pLed->bLedWPSBlinkInProgress) { + if (pLed->bLedNoLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedNoLinkBlinkInProgress = false; + } + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + if (pLed->bLedScanBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedScanBlinkInProgress = false; + } + pLed->bLedWPSBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_WPS; + if (pLed->bLedOn) { + pLed->BlinkingLedState = RTW_LED_OFF; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL); + } else { + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); + } + } + break; + case LED_CTL_STOP_WPS: /* WPS connect success */ + if (pLed->bLedWPSBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedWPSBlinkInProgress = false; + } + + pLed->bLedNoLinkBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_SLOWLY; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + + break; + case LED_CTL_STOP_WPS_FAIL: /* WPS authentication fail */ + if (pLed->bLedWPSBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedWPSBlinkInProgress = false; + } + pLed->bLedNoLinkBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_SLOWLY; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + + /* LED1 settings */ + if (pLed1->bLedWPSBlinkInProgress) + _cancel_timer_ex(&(pLed1->BlinkTimer)); + else + pLed1->bLedWPSBlinkInProgress = true; + pLed1->CurrLedState = LED_BLINK_WPS_STOP; + if (pLed1->bLedOn) + pLed1->BlinkingLedState = RTW_LED_OFF; + else + pLed1->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); + break; + case LED_CTL_STOP_WPS_FAIL_OVERLAP: /* WPS session overlap */ + if (pLed->bLedWPSBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedWPSBlinkInProgress = false; + } + pLed->bLedNoLinkBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_SLOWLY; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + + /* LED1 settings */ + if (pLed1->bLedWPSBlinkInProgress) + _cancel_timer_ex(&(pLed1->BlinkTimer)); + else + pLed1->bLedWPSBlinkInProgress = true; + pLed1->CurrLedState = LED_BLINK_WPS_STOP_OVERLAP; + pLed1->BlinkTimes = 10; + if (pLed1->bLedOn) + pLed1->BlinkingLedState = RTW_LED_OFF; + else + pLed1->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); + break; + case LED_CTL_POWER_OFF: + pLed->CurrLedState = RTW_LED_OFF; + pLed->BlinkingLedState = RTW_LED_OFF; + + if (pLed->bLedNoLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedNoLinkBlinkInProgress = false; + } + if (pLed->bLedLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedLinkBlinkInProgress = false; + } + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + if (pLed->bLedWPSBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedWPSBlinkInProgress = false; + } + if (pLed->bLedScanBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedScanBlinkInProgress = false; + } + if (pLed->bLedStartToLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedStartToLinkBlinkInProgress = false; + } + if (pLed1->bLedWPSBlinkInProgress) { + _cancel_timer_ex(&(pLed1->BlinkTimer)); + pLed1->bLedWPSBlinkInProgress = false; + } + pLed1->BlinkingLedState = LED_UNKNOWN; + SwLedOff(padapter, pLed); + SwLedOff(padapter, pLed1); + break; + default: + break; + } + + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Led %d\n", pLed->CurrLedState)); +} + + + + /* Sercomm-Belkin, added by chiyoko, 20090415 */ +static void +SwLedControlMode5( + struct adapter *padapter, + enum LED_CTL_MODE LedAction +) +{ + struct led_priv *ledpriv = &(padapter->ledpriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct LED_871x *pLed = &(ledpriv->SwLed0); + + switch (LedAction) { + case LED_CTL_POWER_ON: + case LED_CTL_NO_LINK: + case LED_CTL_LINK: /* solid blue */ + pLed->CurrLedState = RTW_LED_ON; + pLed->BlinkingLedState = RTW_LED_ON; + + _set_timer(&(pLed->BlinkTimer), 0); + break; + case LED_CTL_SITE_SURVEY: + if ((pmlmepriv->LinkDetectInfo.bBusyTraffic) && (check_fwstate(pmlmepriv, _FW_LINKED))) { + } else if (!pLed->bLedScanBlinkInProgress) { + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + pLed->bLedScanBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_SCAN; + pLed->BlinkTimes = 24; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + } + break; + case LED_CTL_TX: + case LED_CTL_RX: + if (!pLed->bLedBlinkInProgress) { + if (pLed->CurrLedState == LED_BLINK_SCAN) + return; + pLed->bLedBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_TXRX; + pLed->BlinkTimes = 2; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); + } + break; + case LED_CTL_POWER_OFF: + pLed->CurrLedState = RTW_LED_OFF; + pLed->BlinkingLedState = RTW_LED_OFF; + + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + SwLedOff(padapter, pLed); + break; + default: + break; + } + + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Led %d\n", pLed->CurrLedState)); +} + + /* WNC-Corega, added by chiyoko, 20090902 */ +static void +SwLedControlMode6( + struct adapter *padapter, + enum LED_CTL_MODE LedAction +) +{ + struct led_priv *ledpriv = &(padapter->ledpriv); + struct LED_871x *pLed0 = &(ledpriv->SwLed0); + + switch (LedAction) { + case LED_CTL_POWER_ON: + case LED_CTL_LINK: + case LED_CTL_NO_LINK: + _cancel_timer_ex(&(pLed0->BlinkTimer)); + pLed0->CurrLedState = RTW_LED_ON; + pLed0->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed0->BlinkTimer), 0); + break; + case LED_CTL_POWER_OFF: + SwLedOff(padapter, pLed0); + break; + default: + break; + } + + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("ledcontrol 6 Led %d\n", pLed0->CurrLedState)); +} + +/* */ +/* Description: */ +/* Handler function of LED Blinking. */ +/* We dispatch acture LED blink action according to LedStrategy. */ +/* */ +void BlinkHandler(struct LED_871x *pLed) +{ + struct adapter *padapter = pLed->padapter; + struct led_priv *ledpriv = &(padapter->ledpriv); + + if ((padapter->bSurpriseRemoved) || (padapter->bDriverStopped)) + return; + + switch (ledpriv->LedStrategy) { + case SW_LED_MODE0: + SwLedBlink(pLed); + break; + case SW_LED_MODE1: + SwLedBlink1(pLed); + break; + case SW_LED_MODE2: + SwLedBlink2(pLed); + break; + case SW_LED_MODE3: + SwLedBlink3(pLed); + break; + case SW_LED_MODE4: + SwLedBlink4(pLed); + break; + case SW_LED_MODE5: + SwLedBlink5(pLed); + break; + case SW_LED_MODE6: + SwLedBlink6(pLed); + break; + default: + break; + } +} + +void LedControl871x(struct adapter *padapter, enum LED_CTL_MODE LedAction) +{ + struct led_priv *ledpriv = &(padapter->ledpriv); + + if ((padapter->bSurpriseRemoved) || (padapter->bDriverStopped) || + (!padapter->hw_init_completed)) + return; + + if (!ledpriv->bRegUseLed) + return; + + if ((padapter->pwrctrlpriv.rf_pwrstate != rf_on && + padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) && + (LedAction == LED_CTL_TX || LedAction == LED_CTL_RX || + LedAction == LED_CTL_SITE_SURVEY || + LedAction == LED_CTL_LINK || + LedAction == LED_CTL_NO_LINK || + LedAction == LED_CTL_POWER_ON)) + return; + + switch (ledpriv->LedStrategy) { + case SW_LED_MODE0: + break; + case SW_LED_MODE1: + SwLedControlMode1(padapter, LedAction); + break; + case SW_LED_MODE2: + SwLedControlMode2(padapter, LedAction); + break; + case SW_LED_MODE3: + SwLedControlMode3(padapter, LedAction); + break; + case SW_LED_MODE4: + SwLedControlMode4(padapter, LedAction); + break; + case SW_LED_MODE5: + SwLedControlMode5(padapter, LedAction); + break; + case SW_LED_MODE6: + SwLedControlMode6(padapter, LedAction); + break; + default: + break; + } + + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, + ("LedStrategy:%d, LedAction %d\n", + ledpriv->LedStrategy, LedAction)); +} diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c new file mode 100644 index 0000000000000..ea6607196d84b --- /dev/null +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -0,0 +1,2442 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTW_MLME_C_ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern unsigned char MCS_rate_2R[16]; +extern unsigned char MCS_rate_1R[16]; + +int _rtw_init_mlme_priv (struct adapter *padapter) +{ + int i; + u8 *pbuf; + struct wlan_network *pnetwork; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + int res = _SUCCESS; + +_func_enter_; + + /* We don't need to memset padapter->XXX to zero, because adapter is allocated by rtw_zvmalloc(). */ + + pmlmepriv->nic_hdl = (u8 *)padapter; + + pmlmepriv->pscanned = NULL; + pmlmepriv->fw_state = 0; + pmlmepriv->cur_network.network.InfrastructureMode = Ndis802_11AutoUnknown; + pmlmepriv->scan_mode = SCAN_ACTIVE;/* 1: active, 0: pasive. Maybe someday we should rename this varable to "active_mode" (Jeff) */ + + _rtw_spinlock_init(&(pmlmepriv->lock)); + _rtw_init_queue(&(pmlmepriv->free_bss_pool)); + _rtw_init_queue(&(pmlmepriv->scanned_queue)); + + set_scanned_network_val(pmlmepriv, 0); + + _rtw_memset(&pmlmepriv->assoc_ssid, 0, sizeof(struct ndis_802_11_ssid)); + + pbuf = rtw_zvmalloc(MAX_BSS_CNT * (sizeof(struct wlan_network))); + + if (pbuf == NULL) { + res = _FAIL; + goto exit; + } + pmlmepriv->free_bss_buf = pbuf; + + pnetwork = (struct wlan_network *)pbuf; + + for (i = 0; i < MAX_BSS_CNT; i++) { + _rtw_init_listhead(&(pnetwork->list)); + + rtw_list_insert_tail(&(pnetwork->list), &(pmlmepriv->free_bss_pool.queue)); + + pnetwork++; + } + + /* allocate DMA-able/Non-Page memory for cmd_buf and rsp_buf */ + + rtw_clear_scan_deny(padapter); + + rtw_init_mlme_timer(padapter); + +exit: + +_func_exit_; + + return res; +} + +static void rtw_mfree_mlme_priv_lock (struct mlme_priv *pmlmepriv) +{ + _rtw_spinlock_free(&pmlmepriv->lock); + _rtw_spinlock_free(&(pmlmepriv->free_bss_pool.lock)); + _rtw_spinlock_free(&(pmlmepriv->scanned_queue.lock)); +} + +#if defined (CONFIG_88EU_AP_MODE) +static void rtw_free_mlme_ie_data(u8 **ppie, u32 *plen) +{ + kfree(*ppie); + *plen = 0; + *ppie = NULL; +} + +void rtw_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv) +{ + rtw_buf_free(&pmlmepriv->assoc_req, &pmlmepriv->assoc_req_len); + rtw_buf_free(&pmlmepriv->assoc_rsp, &pmlmepriv->assoc_rsp_len); + rtw_free_mlme_ie_data(&pmlmepriv->wps_beacon_ie, &pmlmepriv->wps_beacon_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->wps_probe_req_ie, &pmlmepriv->wps_probe_req_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->wps_probe_resp_ie, &pmlmepriv->wps_probe_resp_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->wps_assoc_resp_ie, &pmlmepriv->wps_assoc_resp_ie_len); + + rtw_free_mlme_ie_data(&pmlmepriv->p2p_beacon_ie, &pmlmepriv->p2p_beacon_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->p2p_probe_req_ie, &pmlmepriv->p2p_probe_req_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->p2p_probe_resp_ie, &pmlmepriv->p2p_probe_resp_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->p2p_go_probe_resp_ie, &pmlmepriv->p2p_go_probe_resp_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->p2p_assoc_req_ie, &pmlmepriv->p2p_assoc_req_ie_len); +} +#else +void rtw_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv) +{ +} +#endif + +void _rtw_free_mlme_priv (struct mlme_priv *pmlmepriv) +{ +_func_enter_; + + rtw_free_mlme_priv_ie_data(pmlmepriv); + + if (pmlmepriv) { + rtw_mfree_mlme_priv_lock (pmlmepriv); + + if (pmlmepriv->free_bss_buf) { + rtw_vmfree(pmlmepriv->free_bss_buf, MAX_BSS_CNT * sizeof(struct wlan_network)); + } + } +_func_exit_; +} + +int _rtw_enqueue_network(struct __queue *queue, struct wlan_network *pnetwork) +{ + unsigned long irql; + +_func_enter_; + + if (pnetwork == NULL) + goto exit; + + _enter_critical_bh(&queue->lock, &irql); + + rtw_list_insert_tail(&pnetwork->list, &queue->queue); + + _exit_critical_bh(&queue->lock, &irql); + +exit: + +_func_exit_; + + return _SUCCESS; +} + +struct wlan_network *_rtw_dequeue_network(struct __queue *queue) +{ + unsigned long irql; + + struct wlan_network *pnetwork; + +_func_enter_; + + _enter_critical_bh(&queue->lock, &irql); + + if (_rtw_queue_empty(queue)) { + pnetwork = NULL; + } else { + pnetwork = LIST_CONTAINOR(get_next(&queue->queue), struct wlan_network, list); + + rtw_list_delete(&(pnetwork->list)); + } + + _exit_critical_bh(&queue->lock, &irql); + +_func_exit_; + + return pnetwork; +} + +struct wlan_network *_rtw_alloc_network(struct mlme_priv *pmlmepriv)/* _queue *free_queue) */ +{ + unsigned long irql; + struct wlan_network *pnetwork; + struct __queue *free_queue = &pmlmepriv->free_bss_pool; + struct list_head *plist = NULL; + +_func_enter_; + + _enter_critical_bh(&free_queue->lock, &irql); + + if (_rtw_queue_empty(free_queue) == true) { + pnetwork = NULL; + goto exit; + } + plist = get_next(&(free_queue->queue)); + + pnetwork = LIST_CONTAINOR(plist , struct wlan_network, list); + + rtw_list_delete(&pnetwork->list); + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("_rtw_alloc_network: ptr=%p\n", plist)); + pnetwork->network_type = 0; + pnetwork->fixed = false; + pnetwork->last_scanned = rtw_get_current_time(); + pnetwork->aid = 0; + pnetwork->join_res = 0; + + pmlmepriv->num_of_scanned++; + +exit: + _exit_critical_bh(&free_queue->lock, &irql); + +_func_exit_; + + return pnetwork; +} + +void _rtw_free_network(struct mlme_priv *pmlmepriv , struct wlan_network *pnetwork, u8 isfreeall) +{ + u32 curr_time, delta_time; + u32 lifetime = SCANQUEUE_LIFETIME; + unsigned long irql; + struct __queue *free_queue = &(pmlmepriv->free_bss_pool); + +_func_enter_; + + if (pnetwork == NULL) + goto exit; + + if (pnetwork->fixed) + goto exit; + curr_time = rtw_get_current_time(); + if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) || + (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE))) + lifetime = 1; + if (!isfreeall) { + delta_time = (curr_time - pnetwork->last_scanned)/HZ; + if (delta_time < lifetime)/* unit:sec */ + goto exit; + } + _enter_critical_bh(&free_queue->lock, &irql); + rtw_list_delete(&(pnetwork->list)); + rtw_list_insert_tail(&(pnetwork->list), &(free_queue->queue)); + pmlmepriv->num_of_scanned--; + _exit_critical_bh(&free_queue->lock, &irql); + +exit: +_func_exit_; +} + +void _rtw_free_network_nolock(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork) +{ + struct __queue *free_queue = &(pmlmepriv->free_bss_pool); + +_func_enter_; + if (pnetwork == NULL) + goto exit; + if (pnetwork->fixed) + goto exit; + rtw_list_delete(&(pnetwork->list)); + rtw_list_insert_tail(&(pnetwork->list), get_list_head(free_queue)); + pmlmepriv->num_of_scanned--; +exit: + +_func_exit_; +} + +/* + return the wlan_network with the matching addr + + Shall be calle under atomic context... to avoid possible racing condition... +*/ +struct wlan_network *_rtw_find_network(struct __queue *scanned_queue, u8 *addr) +{ + struct list_head *phead, *plist; + struct wlan_network *pnetwork = NULL; + u8 zero_addr[ETH_ALEN] = {0, 0, 0, 0, 0, 0}; + +_func_enter_; + if (_rtw_memcmp(zero_addr, addr, ETH_ALEN)) { + pnetwork = NULL; + goto exit; + } + phead = get_list_head(scanned_queue); + plist = get_next(phead); + + while (plist != phead) { + pnetwork = LIST_CONTAINOR(plist, struct wlan_network , list); + if (_rtw_memcmp(addr, pnetwork->network.MacAddress, ETH_ALEN) == true) + break; + plist = get_next(plist); + } + if (plist == phead) + pnetwork = NULL; +exit: +_func_exit_; + return pnetwork; +} + + +void _rtw_free_network_queue(struct adapter *padapter, u8 isfreeall) +{ + unsigned long irql; + struct list_head *phead, *plist; + struct wlan_network *pnetwork; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct __queue *scanned_queue = &pmlmepriv->scanned_queue; + +_func_enter_; + + + _enter_critical_bh(&scanned_queue->lock, &irql); + + phead = get_list_head(scanned_queue); + plist = get_next(phead); + + while (rtw_end_of_queue_search(phead, plist) == false) { + pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); + + plist = get_next(plist); + + _rtw_free_network(pmlmepriv, pnetwork, isfreeall); + } + _exit_critical_bh(&scanned_queue->lock, &irql); +_func_exit_; +} + +int rtw_if_up(struct adapter *padapter) +{ + int res; +_func_enter_; + + if (padapter->bDriverStopped || padapter->bSurpriseRemoved || + (check_fwstate(&padapter->mlmepriv, _FW_LINKED) == false)) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, + ("rtw_if_up:bDriverStopped(%d) OR bSurpriseRemoved(%d)", + padapter->bDriverStopped, padapter->bSurpriseRemoved)); + res = false; + } else { + res = true; + } + +_func_exit_; + return res; +} + +void rtw_generate_random_ibss(u8 *pibss) +{ + u32 curtime = rtw_get_current_time(); + +_func_enter_; + pibss[0] = 0x02; /* in ad-hoc mode bit1 must set to 1 */ + pibss[1] = 0x11; + pibss[2] = 0x87; + pibss[3] = (u8)(curtime & 0xff);/* p[0]; */ + pibss[4] = (u8)((curtime>>8) & 0xff);/* p[1]; */ + pibss[5] = (u8)((curtime>>16) & 0xff);/* p[2]; */ +_func_exit_; + return; +} + +u8 *rtw_get_capability_from_ie(u8 *ie) +{ + return ie + 8 + 2; +} + + +u16 rtw_get_capability(struct wlan_bssid_ex *bss) +{ + __le16 val; +_func_enter_; + + memcpy((u8 *)&val, rtw_get_capability_from_ie(bss->IEs), 2); + +_func_exit_; + return le16_to_cpu(val); +} + +u8 *rtw_get_timestampe_from_ie(u8 *ie) +{ + return ie + 0; +} + +u8 *rtw_get_beacon_interval_from_ie(u8 *ie) +{ + return ie + 8; +} + +int rtw_init_mlme_priv (struct adapter *padapter)/* struct mlme_priv *pmlmepriv) */ +{ + int res; +_func_enter_; + res = _rtw_init_mlme_priv(padapter);/* (pmlmepriv); */ +_func_exit_; + return res; +} + +void rtw_free_mlme_priv (struct mlme_priv *pmlmepriv) +{ +_func_enter_; + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("rtw_free_mlme_priv\n")); + _rtw_free_mlme_priv (pmlmepriv); +_func_exit_; +} + +static struct wlan_network *rtw_alloc_network(struct mlme_priv *pmlmepriv) +{ + struct wlan_network *pnetwork; +_func_enter_; + pnetwork = _rtw_alloc_network(pmlmepriv); +_func_exit_; + return pnetwork; +} + +static void rtw_free_network_nolock(struct mlme_priv *pmlmepriv, + struct wlan_network *pnetwork) +{ +_func_enter_; + _rtw_free_network_nolock(pmlmepriv, pnetwork); +_func_exit_; +} + + +void rtw_free_network_queue(struct adapter *dev, u8 isfreeall) +{ +_func_enter_; + _rtw_free_network_queue(dev, isfreeall); +_func_exit_; +} + +/* + return the wlan_network with the matching addr + + Shall be calle under atomic context... to avoid possible racing condition... +*/ +struct wlan_network *rtw_find_network(struct __queue *scanned_queue, u8 *addr) +{ + struct wlan_network *pnetwork = _rtw_find_network(scanned_queue, addr); + + return pnetwork; +} + +int rtw_is_same_ibss(struct adapter *adapter, struct wlan_network *pnetwork) +{ + int ret = true; + struct security_priv *psecuritypriv = &adapter->securitypriv; + + if ((psecuritypriv->dot11PrivacyAlgrthm != _NO_PRIVACY_) && + (pnetwork->network.Privacy == 0)) + ret = false; + else if ((psecuritypriv->dot11PrivacyAlgrthm == _NO_PRIVACY_) && + (pnetwork->network.Privacy == 1)) + ret = false; + else + ret = true; + return ret; +} + +static int is_same_ess(struct wlan_bssid_ex *a, struct wlan_bssid_ex *b) +{ + return (a->Ssid.SsidLength == b->Ssid.SsidLength) && + _rtw_memcmp(a->Ssid.Ssid, b->Ssid.Ssid, a->Ssid.SsidLength); +} + +int is_same_network(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst) +{ + u16 s_cap, d_cap; + __le16 le_scap, le_dcap; + +_func_enter_; + memcpy((u8 *)&le_scap, rtw_get_capability_from_ie(src->IEs), 2); + memcpy((u8 *)&le_dcap, rtw_get_capability_from_ie(dst->IEs), 2); + + + s_cap = le16_to_cpu(le_scap); + d_cap = le16_to_cpu(le_dcap); + +_func_exit_; + + return ((src->Ssid.SsidLength == dst->Ssid.SsidLength) && + ((_rtw_memcmp(src->MacAddress, dst->MacAddress, ETH_ALEN)) == true) && + ((_rtw_memcmp(src->Ssid.Ssid, dst->Ssid.Ssid, src->Ssid.SsidLength)) == true) && + ((s_cap & WLAN_CAPABILITY_IBSS) == + (d_cap & WLAN_CAPABILITY_IBSS)) && + ((s_cap & WLAN_CAPABILITY_BSS) == + (d_cap & WLAN_CAPABILITY_BSS))); +} + +struct wlan_network *rtw_get_oldest_wlan_network(struct __queue *scanned_queue) +{ + struct list_head *plist, *phead; + struct wlan_network *pwlan = NULL; + struct wlan_network *oldest = NULL; + +_func_enter_; + phead = get_list_head(scanned_queue); + + plist = get_next(phead); + + while (1) { + if (rtw_end_of_queue_search(phead, plist) == true) + break; + + pwlan = LIST_CONTAINOR(plist, struct wlan_network, list); + + if (!pwlan->fixed) { + if (oldest == NULL || time_after(oldest->last_scanned, pwlan->last_scanned)) + oldest = pwlan; + } + + plist = get_next(plist); + } +_func_exit_; + return oldest; +} + +void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, + struct adapter *padapter, bool update_ie) +{ + long rssi_ori = dst->Rssi; + u8 sq_smp = src->PhyInfo.SignalQuality; + u8 ss_final; + u8 sq_final; + long rssi_final; + +_func_enter_; + rtw_hal_antdiv_rssi_compared(padapter, dst, src); /* this will update src.Rssi, need consider again */ + + /* The rule below is 1/5 for sample value, 4/5 for history value */ + if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) && is_same_network(&(padapter->mlmepriv.cur_network.network), src)) { + /* Take the recvpriv's value for the connected AP*/ + ss_final = padapter->recvpriv.signal_strength; + sq_final = padapter->recvpriv.signal_qual; + /* the rssi value here is undecorated, and will be used for antenna diversity */ + if (sq_smp != 101) /* from the right channel */ + rssi_final = (src->Rssi+dst->Rssi*4)/5; + else + rssi_final = rssi_ori; + } else { + if (sq_smp != 101) { /* from the right channel */ + ss_final = ((u32)(src->PhyInfo.SignalStrength)+(u32)(dst->PhyInfo.SignalStrength)*4)/5; + sq_final = ((u32)(src->PhyInfo.SignalQuality)+(u32)(dst->PhyInfo.SignalQuality)*4)/5; + rssi_final = (src->Rssi+dst->Rssi*4)/5; + } else { + /* bss info not receving from the right channel, use the original RX signal infos */ + ss_final = dst->PhyInfo.SignalStrength; + sq_final = dst->PhyInfo.SignalQuality; + rssi_final = dst->Rssi; + } + } + if (update_ie) + memcpy((u8 *)dst, (u8 *)src, get_wlan_bssid_ex_sz(src)); + dst->PhyInfo.SignalStrength = ss_final; + dst->PhyInfo.SignalQuality = sq_final; + dst->Rssi = rssi_final; + +_func_exit_; +} + +static void update_current_network(struct adapter *adapter, struct wlan_bssid_ex *pnetwork) +{ + struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); + +_func_enter_; + + if ((check_fwstate(pmlmepriv, _FW_LINKED) == true) && + (is_same_network(&(pmlmepriv->cur_network.network), pnetwork))) { + update_network(&(pmlmepriv->cur_network.network), pnetwork, adapter, true); + rtw_update_protection(adapter, (pmlmepriv->cur_network.network.IEs) + sizeof(struct ndis_802_11_fixed_ie), + pmlmepriv->cur_network.network.IELength); + } +_func_exit_; +} + +/* +Caller must hold pmlmepriv->lock first. +*/ +void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *target) +{ + unsigned long irql; + struct list_head *plist, *phead; + u32 bssid_ex_sz; + struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); + struct __queue *queue = &(pmlmepriv->scanned_queue); + struct wlan_network *pnetwork = NULL; + struct wlan_network *oldest = NULL; + +_func_enter_; + + _enter_critical_bh(&queue->lock, &irql); + phead = get_list_head(queue); + plist = get_next(phead); + + while (1) { + if (rtw_end_of_queue_search(phead, plist) == true) + break; + + pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); + + if (is_same_network(&(pnetwork->network), target)) + break; + if ((oldest == ((struct wlan_network *)0)) || + time_after(oldest->last_scanned, pnetwork->last_scanned)) + oldest = pnetwork; + plist = get_next(plist); + } + /* If we didn't find a match, then get a new network slot to initialize + * with this beacon's information */ + if (rtw_end_of_queue_search(phead, plist) == true) { + if (_rtw_queue_empty(&(pmlmepriv->free_bss_pool)) == true) { + /* If there are no more slots, expire the oldest */ + pnetwork = oldest; + + rtw_hal_get_def_var(adapter, HAL_DEF_CURRENT_ANTENNA, &(target->PhyInfo.Optimum_antenna)); + memcpy(&(pnetwork->network), target, get_wlan_bssid_ex_sz(target)); + /* variable initialize */ + pnetwork->fixed = false; + pnetwork->last_scanned = rtw_get_current_time(); + + pnetwork->network_type = 0; + pnetwork->aid = 0; + pnetwork->join_res = 0; + + /* bss info not receving from the right channel */ + if (pnetwork->network.PhyInfo.SignalQuality == 101) + pnetwork->network.PhyInfo.SignalQuality = 0; + } else { + /* Otherwise just pull from the free list */ + + pnetwork = rtw_alloc_network(pmlmepriv); /* will update scan_time */ + + if (pnetwork == NULL) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("\n\n\nsomething wrong here\n\n\n")); + goto exit; + } + + bssid_ex_sz = get_wlan_bssid_ex_sz(target); + target->Length = bssid_ex_sz; + rtw_hal_get_def_var(adapter, HAL_DEF_CURRENT_ANTENNA, &(target->PhyInfo.Optimum_antenna)); + memcpy(&(pnetwork->network), target, bssid_ex_sz); + + pnetwork->last_scanned = rtw_get_current_time(); + + /* bss info not receving from the right channel */ + if (pnetwork->network.PhyInfo.SignalQuality == 101) + pnetwork->network.PhyInfo.SignalQuality = 0; + rtw_list_insert_tail(&(pnetwork->list), &(queue->queue)); + } + } else { + /* we have an entry and we are going to update it. But this entry may + * be already expired. In this case we do the same as we found a new + * net and call the new_net handler + */ + bool update_ie = true; + + pnetwork->last_scanned = rtw_get_current_time(); + + /* target.Reserved[0]== 1, means that scaned network is a bcn frame. */ + if ((pnetwork->network.IELength > target->IELength) && (target->Reserved[0] == 1)) + update_ie = false; + + update_network(&(pnetwork->network), target, adapter, update_ie); + } + +exit: + _exit_critical_bh(&queue->lock, &irql); + +_func_exit_; +} + +static void rtw_add_network(struct adapter *adapter, + struct wlan_bssid_ex *pnetwork) +{ +_func_enter_; +#if defined(CONFIG_88EU_P2P) + rtw_wlan_bssid_ex_remove_p2p_attr(pnetwork, P2P_ATTR_GROUP_INFO); +#endif + update_current_network(adapter, pnetwork); + rtw_update_scanned_network(adapter, pnetwork); +_func_exit_; +} + +/* select the desired network based on the capability of the (i)bss. */ +/* check items: (1) security */ +/* (2) network_type */ +/* (3) WMM */ +/* (4) HT */ +/* (5) others */ +static int rtw_is_desired_network(struct adapter *adapter, struct wlan_network *pnetwork) +{ + struct security_priv *psecuritypriv = &adapter->securitypriv; + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + u32 desired_encmode; + u32 privacy; + + /* u8 wps_ie[512]; */ + uint wps_ielen; + + int bselected = true; + + desired_encmode = psecuritypriv->ndisencryptstatus; + privacy = pnetwork->network.Privacy; + + if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) { + if (rtw_get_wps_ie(pnetwork->network.IEs+_FIXED_IE_LENGTH_, pnetwork->network.IELength-_FIXED_IE_LENGTH_, NULL, &wps_ielen) != NULL) + return true; + else + return false; + } + if (adapter->registrypriv.wifi_spec == 1) { /* for correct flow of 8021X to do.... */ + if ((desired_encmode == Ndis802_11EncryptionDisabled) && (privacy != 0)) + bselected = false; + } + + + if ((desired_encmode != Ndis802_11EncryptionDisabled) && (privacy == 0)) { + DBG_88E("desired_encmode: %d, privacy: %d\n", desired_encmode, privacy); + bselected = false; + } + + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) { + if (pnetwork->network.InfrastructureMode != pmlmepriv->cur_network.network.InfrastructureMode) + bselected = false; + } + + + return bselected; +} + +/* TODO: Perry: For Power Management */ +void rtw_atimdone_event_callback(struct adapter *adapter , u8 *pbuf) +{ +_func_enter_; + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("receive atimdone_evet\n")); +_func_exit_; + return; +} + + +void rtw_survey_event_callback(struct adapter *adapter, u8 *pbuf) +{ + unsigned long irql; + u32 len; + struct wlan_bssid_ex *pnetwork; + struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); + +_func_enter_; + + pnetwork = (struct wlan_bssid_ex *)pbuf; + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_survey_event_callback, ssid=%s\n", pnetwork->Ssid.Ssid)); + + len = get_wlan_bssid_ex_sz(pnetwork); + if (len > (sizeof(struct wlan_bssid_ex))) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("\n****rtw_survey_event_callback: return a wrong bss ***\n")); + return; + } + _enter_critical_bh(&pmlmepriv->lock, &irql); + + /* update IBSS_network 's timestamp */ + if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) == true) { + if (_rtw_memcmp(&(pmlmepriv->cur_network.network.MacAddress), pnetwork->MacAddress, ETH_ALEN)) { + struct wlan_network *ibss_wlan = NULL; + unsigned long irql; + + memcpy(pmlmepriv->cur_network.network.IEs, pnetwork->IEs, 8); + _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irql); + ibss_wlan = rtw_find_network(&pmlmepriv->scanned_queue, pnetwork->MacAddress); + if (ibss_wlan) { + memcpy(ibss_wlan->network.IEs , pnetwork->IEs, 8); + _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irql); + goto exit; + } + _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irql); + } + } + + /* lock pmlmepriv->lock when you accessing network_q */ + if ((check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) == false) { + if (pnetwork->Ssid.Ssid[0] == 0) + pnetwork->Ssid.SsidLength = 0; + rtw_add_network(adapter, pnetwork); + } + +exit: + + _exit_critical_bh(&pmlmepriv->lock, &irql); + +_func_exit_; + + return; +} + + + +void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf) +{ + unsigned long irql; + struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); + struct mlme_ext_priv *pmlmeext; + +_func_enter_; + _enter_critical_bh(&pmlmepriv->lock, &irql); + + if (pmlmepriv->wps_probe_req_ie) { + pmlmepriv->wps_probe_req_ie_len = 0; + kfree(pmlmepriv->wps_probe_req_ie); + pmlmepriv->wps_probe_req_ie = NULL; + } + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_surveydone_event_callback: fw_state:%x\n\n", get_fwstate(pmlmepriv))); + + if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) { + u8 timer_cancelled; + + _cancel_timer(&pmlmepriv->scan_to_timer, &timer_cancelled); + + _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY); + } else { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("nic status=%x, survey done event comes too late!\n", get_fwstate(pmlmepriv))); + } + + rtw_set_signal_stat_timer(&adapter->recvpriv); + + if (pmlmepriv->to_join) { + if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) { + if (check_fwstate(pmlmepriv, _FW_LINKED) == false) { + set_fwstate(pmlmepriv, _FW_UNDER_LINKING); + + if (rtw_select_and_join_from_scanned_queue(pmlmepriv) == _SUCCESS) { + _set_timer(&pmlmepriv->assoc_timer, MAX_JOIN_TIMEOUT); + } else { + struct wlan_bssid_ex *pdev_network = &(adapter->registrypriv.dev_network); + u8 *pibss = adapter->registrypriv.dev_network.MacAddress; + + _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY); + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("switching to adhoc master\n")); + + _rtw_memset(&pdev_network->Ssid, 0, sizeof(struct ndis_802_11_ssid)); + memcpy(&pdev_network->Ssid, &pmlmepriv->assoc_ssid, sizeof(struct ndis_802_11_ssid)); + + rtw_update_registrypriv_dev_network(adapter); + rtw_generate_random_ibss(pibss); + + pmlmepriv->fw_state = WIFI_ADHOC_MASTER_STATE; + + if (rtw_createbss_cmd(adapter) != _SUCCESS) + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Error=>rtw_createbss_cmd status FAIL\n")); + pmlmepriv->to_join = false; + } + } + } else { + int s_ret; + set_fwstate(pmlmepriv, _FW_UNDER_LINKING); + pmlmepriv->to_join = false; + s_ret = rtw_select_and_join_from_scanned_queue(pmlmepriv); + if (_SUCCESS == s_ret) { + _set_timer(&pmlmepriv->assoc_timer, MAX_JOIN_TIMEOUT); + } else if (s_ret == 2) { /* there is no need to wait for join */ + _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); + rtw_indicate_connect(adapter); + } else { + DBG_88E("try_to_join, but select scanning queue fail, to_roaming:%d\n", pmlmepriv->to_roaming); + if (pmlmepriv->to_roaming != 0) { + if (--pmlmepriv->to_roaming == 0 || + _SUCCESS != rtw_sitesurvey_cmd(adapter, &pmlmepriv->assoc_ssid, 1, NULL, 0)) { + pmlmepriv->to_roaming = 0; + rtw_free_assoc_resources(adapter, 1); + rtw_indicate_disconnect(adapter); + } else { + pmlmepriv->to_join = true; + } + } + _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); + } + } + } + + indicate_wx_scan_complete_event(adapter); + + _exit_critical_bh(&pmlmepriv->lock, &irql); + + if (check_fwstate(pmlmepriv, _FW_LINKED) == true) + p2p_ps_wk_cmd(adapter, P2P_PS_SCAN_DONE, 0); + + rtw_os_xmit_schedule(adapter); + + pmlmeext = &adapter->mlmeextpriv; + if (pmlmeext->sitesurvey_res.bss_cnt == 0) + rtw_hal_sreset_reset(adapter); +_func_exit_; +} + +void rtw_dummy_event_callback(struct adapter *adapter , u8 *pbuf) +{ +} + +void rtw_fwdbg_event_callback(struct adapter *adapter , u8 *pbuf) +{ +} + +static void free_scanqueue(struct mlme_priv *pmlmepriv) +{ + unsigned long irql, irql0; + struct __queue *free_queue = &pmlmepriv->free_bss_pool; + struct __queue *scan_queue = &pmlmepriv->scanned_queue; + struct list_head *plist, *phead, *ptemp; + +_func_enter_; + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, ("+free_scanqueue\n")); + _enter_critical_bh(&scan_queue->lock, &irql0); + _enter_critical_bh(&free_queue->lock, &irql); + + phead = get_list_head(scan_queue); + plist = get_next(phead); + + while (plist != phead) { + ptemp = get_next(plist); + rtw_list_delete(plist); + rtw_list_insert_tail(plist, &free_queue->queue); + plist = ptemp; + pmlmepriv->num_of_scanned--; + } + + _exit_critical_bh(&free_queue->lock, &irql); + _exit_critical_bh(&scan_queue->lock, &irql0); + +_func_exit_; +} + +/* +*rtw_free_assoc_resources: the caller has to lock pmlmepriv->lock +*/ +void rtw_free_assoc_resources(struct adapter *adapter, int lock_scanned_queue) +{ + unsigned long irql; + struct wlan_network *pwlan = NULL; + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + struct sta_priv *pstapriv = &adapter->stapriv; + struct wlan_network *tgt_network = &pmlmepriv->cur_network; + +_func_enter_; + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, ("+rtw_free_assoc_resources\n")); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, + ("tgt_network->network.MacAddress=%pM ssid=%s\n", + tgt_network->network.MacAddress, tgt_network->network.Ssid.Ssid)); + + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE | WIFI_AP_STATE)) { + struct sta_info *psta; + + psta = rtw_get_stainfo(&adapter->stapriv, tgt_network->network.MacAddress); + + _enter_critical_bh(&(pstapriv->sta_hash_lock), &irql); + rtw_free_stainfo(adapter, psta); + _exit_critical_bh(&(pstapriv->sta_hash_lock), &irql); + } + + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE | WIFI_ADHOC_MASTER_STATE | WIFI_AP_STATE)) { + struct sta_info *psta; + + rtw_free_all_stainfo(adapter); + + psta = rtw_get_bcmc_stainfo(adapter); + _enter_critical_bh(&(pstapriv->sta_hash_lock), &irql); + rtw_free_stainfo(adapter, psta); + _exit_critical_bh(&(pstapriv->sta_hash_lock), &irql); + + rtw_init_bcmc_stainfo(adapter); + } + + if (lock_scanned_queue) + _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irql); + + pwlan = rtw_find_network(&pmlmepriv->scanned_queue, tgt_network->network.MacAddress); + if (pwlan) + pwlan->fixed = false; + else + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("rtw_free_assoc_resources:pwlan==NULL\n\n")); + + if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) && (adapter->stapriv.asoc_sta_count == 1))) + rtw_free_network_nolock(pmlmepriv, pwlan); + + if (lock_scanned_queue) + _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irql); + pmlmepriv->key_mask = 0; +_func_exit_; +} + +/* +*rtw_indicate_connect: the caller has to lock pmlmepriv->lock +*/ +void rtw_indicate_connect(struct adapter *padapter) +{ + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + +_func_enter_; + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("+rtw_indicate_connect\n")); + + pmlmepriv->to_join = false; + + if (!check_fwstate(&padapter->mlmepriv, _FW_LINKED)) { + set_fwstate(pmlmepriv, _FW_LINKED); + + rtw_led_control(padapter, LED_CTL_LINK); + + rtw_os_indicate_connect(padapter); + } + + pmlmepriv->to_roaming = 0; + + rtw_set_scan_deny(padapter, 3000); + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("-rtw_indicate_connect: fw_state=0x%08x\n", get_fwstate(pmlmepriv))); +_func_exit_; +} + +/* +*rtw_indicate_disconnect: the caller has to lock pmlmepriv->lock +*/ +void rtw_indicate_disconnect(struct adapter *padapter) +{ + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + +_func_enter_; + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("+rtw_indicate_disconnect\n")); + + _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING | WIFI_UNDER_WPS); + + + if (pmlmepriv->to_roaming > 0) + _clr_fwstate_(pmlmepriv, _FW_LINKED); + + if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) || + (pmlmepriv->to_roaming <= 0)) { + rtw_os_indicate_disconnect(padapter); + + _clr_fwstate_(pmlmepriv, _FW_LINKED); + rtw_led_control(padapter, LED_CTL_NO_LINK); + rtw_clear_scan_deny(padapter); + } + p2p_ps_wk_cmd(padapter, P2P_PS_DISABLE, 1); + + rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_DISCONNECT, 1); + +_func_exit_; +} + +inline void rtw_indicate_scan_done(struct adapter *padapter, bool aborted) +{ + rtw_os_indicate_scan_done(padapter, aborted); +} + +void rtw_scan_abort(struct adapter *adapter) +{ + u32 start; + struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &(adapter->mlmeextpriv); + + start = rtw_get_current_time(); + pmlmeext->scan_abort = true; + while (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) && + rtw_get_passing_time_ms(start) <= 200) { + if (adapter->bDriverStopped || adapter->bSurpriseRemoved) + break; + DBG_88E(FUNC_NDEV_FMT"fw_state=_FW_UNDER_SURVEY!\n", FUNC_NDEV_ARG(adapter->pnetdev)); + rtw_msleep_os(20); + } + if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) { + if (!adapter->bDriverStopped && !adapter->bSurpriseRemoved) + DBG_88E(FUNC_NDEV_FMT"waiting for scan_abort time out!\n", FUNC_NDEV_ARG(adapter->pnetdev)); + rtw_indicate_scan_done(adapter, true); + } + pmlmeext->scan_abort = false; +} + +static struct sta_info *rtw_joinbss_update_stainfo(struct adapter *padapter, struct wlan_network *pnetwork) +{ + int i; + struct sta_info *bmc_sta, *psta = NULL; + struct recv_reorder_ctrl *preorder_ctrl; + struct sta_priv *pstapriv = &padapter->stapriv; + + psta = rtw_get_stainfo(pstapriv, pnetwork->network.MacAddress); + if (psta == NULL) + psta = rtw_alloc_stainfo(pstapriv, pnetwork->network.MacAddress); + + if (psta) { /* update ptarget_sta */ + DBG_88E("%s\n", __func__); + psta->aid = pnetwork->join_res; + psta->mac_id = 0; + /* sta mode */ + rtw_hal_set_odm_var(padapter, HAL_ODM_STA_INFO, psta, true); + /* security related */ + if (padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) { + padapter->securitypriv.binstallGrpkey = false; + padapter->securitypriv.busetkipkey = false; + padapter->securitypriv.bgrpkey_handshake = false; + psta->ieee8021x_blocked = true; + psta->dot118021XPrivacy = padapter->securitypriv.dot11PrivacyAlgrthm; + _rtw_memset((u8 *)&psta->dot118021x_UncstKey, 0, sizeof(union Keytype)); + _rtw_memset((u8 *)&psta->dot11tkiprxmickey, 0, sizeof(union Keytype)); + _rtw_memset((u8 *)&psta->dot11tkiptxmickey, 0, sizeof(union Keytype)); + _rtw_memset((u8 *)&psta->dot11txpn, 0, sizeof(union pn48)); + _rtw_memset((u8 *)&psta->dot11rxpn, 0, sizeof(union pn48)); + } + /* Commented by Albert 2012/07/21 */ + /* When doing the WPS, the wps_ie_len won't equal to 0 */ + /* And the Wi-Fi driver shouldn't allow the data packet to be tramsmitted. */ + if (padapter->securitypriv.wps_ie_len != 0) { + psta->ieee8021x_blocked = true; + padapter->securitypriv.wps_ie_len = 0; + } + /* for A-MPDU Rx reordering buffer control for bmc_sta & sta_info */ + /* if A-MPDU Rx is enabled, reseting rx_ordering_ctrl wstart_b(indicate_seq) to default value = 0xffff */ + /* todo: check if AP can send A-MPDU packets */ + for (i = 0; i < 16; i++) { + /* preorder_ctrl = &precvpriv->recvreorder_ctrl[i]; */ + preorder_ctrl = &psta->recvreorder_ctrl[i]; + preorder_ctrl->enable = false; + preorder_ctrl->indicate_seq = 0xffff; + preorder_ctrl->wend_b = 0xffff; + preorder_ctrl->wsize_b = 64;/* max_ampdu_sz; ex. 32(kbytes) -> wsize_b = 32 */ + } + bmc_sta = rtw_get_bcmc_stainfo(padapter); + if (bmc_sta) { + for (i = 0; i < 16; i++) { + /* preorder_ctrl = &precvpriv->recvreorder_ctrl[i]; */ + preorder_ctrl = &bmc_sta->recvreorder_ctrl[i]; + preorder_ctrl->enable = false; + preorder_ctrl->indicate_seq = 0xffff; + preorder_ctrl->wend_b = 0xffff; + preorder_ctrl->wsize_b = 64;/* max_ampdu_sz; ex. 32(kbytes) -> wsize_b = 32 */ + } + } + /* misc. */ + update_sta_info(padapter, psta); + } + return psta; +} + +/* pnetwork: returns from rtw_joinbss_event_callback */ +/* ptarget_wlan: found from scanned_queue */ +static void rtw_joinbss_update_network(struct adapter *padapter, struct wlan_network *ptarget_wlan, struct wlan_network *pnetwork) +{ + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct wlan_network *cur_network = &(pmlmepriv->cur_network); + + DBG_88E("%s\n", __func__); + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, + ("\nfw_state:%x, BSSID:%pM\n", + get_fwstate(pmlmepriv), pnetwork->network.MacAddress)); + + + /* why not use ptarget_wlan?? */ + memcpy(&cur_network->network, &pnetwork->network, pnetwork->network.Length); + /* some IEs in pnetwork is wrong, so we should use ptarget_wlan IEs */ + cur_network->network.IELength = ptarget_wlan->network.IELength; + memcpy(&cur_network->network.IEs[0], &ptarget_wlan->network.IEs[0], MAX_IE_SZ); + + cur_network->aid = pnetwork->join_res; + + + rtw_set_signal_stat_timer(&padapter->recvpriv); + padapter->recvpriv.signal_strength = ptarget_wlan->network.PhyInfo.SignalStrength; + padapter->recvpriv.signal_qual = ptarget_wlan->network.PhyInfo.SignalQuality; + /* the ptarget_wlan->network.Rssi is raw data, we use ptarget_wlan->network.PhyInfo.SignalStrength instead (has scaled) */ + padapter->recvpriv.rssi = translate_percentage_to_dbm(ptarget_wlan->network.PhyInfo.SignalStrength); + rtw_set_signal_stat_timer(&padapter->recvpriv); + + /* update fw_state will clr _FW_UNDER_LINKING here indirectly */ + switch (pnetwork->network.InfrastructureMode) { + case Ndis802_11Infrastructure: + if (pmlmepriv->fw_state&WIFI_UNDER_WPS) + pmlmepriv->fw_state = WIFI_STATION_STATE|WIFI_UNDER_WPS; + else + pmlmepriv->fw_state = WIFI_STATION_STATE; + break; + case Ndis802_11IBSS: + pmlmepriv->fw_state = WIFI_ADHOC_STATE; + break; + default: + pmlmepriv->fw_state = WIFI_NULL_STATE; + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Invalid network_mode\n")); + break; + } + + rtw_update_protection(padapter, (cur_network->network.IEs) + + sizeof(struct ndis_802_11_fixed_ie), + (cur_network->network.IELength)); + rtw_update_ht_cap(padapter, cur_network->network.IEs, cur_network->network.IELength); +} + +/* Notes: the fucntion could be > passive_level (the same context as Rx tasklet) */ +/* pnetwork: returns from rtw_joinbss_event_callback */ +/* ptarget_wlan: found from scanned_queue */ +/* if join_res > 0, for (fw_state == WIFI_STATION_STATE), we check if "ptarget_sta" & "ptarget_wlan" exist. */ +/* if join_res > 0, for (fw_state == WIFI_ADHOC_STATE), we only check if "ptarget_wlan" exist. */ +/* if join_res > 0, update "cur_network->network" from "pnetwork->network" if (ptarget_wlan != NULL). */ + +void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) +{ + unsigned long irql, irql2; + u8 timer_cancelled; + struct sta_info *ptarget_sta = NULL, *pcur_sta = NULL; + struct sta_priv *pstapriv = &adapter->stapriv; + struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); + struct wlan_network *pnetwork = (struct wlan_network *)pbuf; + struct wlan_network *cur_network = &(pmlmepriv->cur_network); + struct wlan_network *pcur_wlan = NULL, *ptarget_wlan = NULL; + unsigned int the_same_macaddr = false; + +_func_enter_; + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("joinbss event call back received with res=%d\n", pnetwork->join_res)); + + rtw_get_encrypt_decrypt_from_registrypriv(adapter); + + + if (pmlmepriv->assoc_ssid.SsidLength == 0) + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("@@@@@ joinbss event call back for Any SSid\n")); + else + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("@@@@@ rtw_joinbss_event_callback for SSid:%s\n", pmlmepriv->assoc_ssid.Ssid)); + + the_same_macaddr = _rtw_memcmp(pnetwork->network.MacAddress, cur_network->network.MacAddress, ETH_ALEN); + + pnetwork->network.Length = get_wlan_bssid_ex_sz(&pnetwork->network); + if (pnetwork->network.Length > sizeof(struct wlan_bssid_ex)) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("\n\n ***joinbss_evt_callback return a wrong bss ***\n\n")); + goto ignore_nolock; + } + + _enter_critical_bh(&pmlmepriv->lock, &irql); + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("\nrtw_joinbss_event_callback!! _enter_critical\n")); + + if (pnetwork->join_res > 0) { + _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irql); + if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) { + /* s1. find ptarget_wlan */ + if (check_fwstate(pmlmepriv, _FW_LINKED)) { + if (the_same_macaddr) { + ptarget_wlan = rtw_find_network(&pmlmepriv->scanned_queue, cur_network->network.MacAddress); + } else { + pcur_wlan = rtw_find_network(&pmlmepriv->scanned_queue, cur_network->network.MacAddress); + if (pcur_wlan) + pcur_wlan->fixed = false; + + pcur_sta = rtw_get_stainfo(pstapriv, cur_network->network.MacAddress); + if (pcur_sta) { + _enter_critical_bh(&(pstapriv->sta_hash_lock), &irql2); + rtw_free_stainfo(adapter, pcur_sta); + _exit_critical_bh(&(pstapriv->sta_hash_lock), &irql2); + } + + ptarget_wlan = rtw_find_network(&pmlmepriv->scanned_queue, pnetwork->network.MacAddress); + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { + if (ptarget_wlan) + ptarget_wlan->fixed = true; + } + } + } else { + ptarget_wlan = rtw_find_network(&pmlmepriv->scanned_queue, pnetwork->network.MacAddress); + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { + if (ptarget_wlan) + ptarget_wlan->fixed = true; + } + } + + /* s2. update cur_network */ + if (ptarget_wlan) { + rtw_joinbss_update_network(adapter, ptarget_wlan, pnetwork); + } else { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Can't find ptarget_wlan when joinbss_event callback\n")); + _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irql); + goto ignore_joinbss_callback; + } + + + /* s3. find ptarget_sta & update ptarget_sta after update cur_network only for station mode */ + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { + ptarget_sta = rtw_joinbss_update_stainfo(adapter, pnetwork); + if (ptarget_sta == NULL) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Can't update stainfo when joinbss_event callback\n")); + _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irql); + goto ignore_joinbss_callback; + } + } + + /* s4. indicate connect */ + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { + rtw_indicate_connect(adapter); + } else { + /* adhoc mode will rtw_indicate_connect when rtw_stassoc_event_callback */ + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("adhoc mode, fw_state:%x", get_fwstate(pmlmepriv))); + } + + /* s5. Cancle assoc_timer */ + _cancel_timer(&pmlmepriv->assoc_timer, &timer_cancelled); + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("Cancle assoc_timer\n")); + + } else { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("rtw_joinbss_event_callback err: fw_state:%x", get_fwstate(pmlmepriv))); + _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irql); + goto ignore_joinbss_callback; + } + + _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irql); + + } else if (pnetwork->join_res == -4) { + rtw_reset_securitypriv(adapter); + _set_timer(&pmlmepriv->assoc_timer, 1); + + if ((check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) == true) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("fail! clear _FW_UNDER_LINKING ^^^fw_state=%x\n", get_fwstate(pmlmepriv))); + _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); + } + } else { /* if join_res < 0 (join fails), then try again */ + _set_timer(&pmlmepriv->assoc_timer, 1); + _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); + } + +ignore_joinbss_callback: + _exit_critical_bh(&pmlmepriv->lock, &irql); +ignore_nolock: +_func_exit_; +} + +void rtw_joinbss_event_callback(struct adapter *adapter, u8 *pbuf) +{ + struct wlan_network *pnetwork = (struct wlan_network *)pbuf; + +_func_enter_; + + mlmeext_joinbss_event_callback(adapter, pnetwork->join_res); + + rtw_os_xmit_schedule(adapter); + +_func_exit_; +} + +static u8 search_max_mac_id(struct adapter *padapter) +{ + u8 mac_id; +#if defined (CONFIG_88EU_AP_MODE) + u8 aid; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct sta_priv *pstapriv = &padapter->stapriv; +#endif + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + +#if defined (CONFIG_88EU_AP_MODE) + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { + for (aid = (pstapriv->max_num_sta); aid > 0; aid--) { + if (pstapriv->sta_aid[aid-1] != NULL) + break; + } + mac_id = aid + 1; + } else +#endif + {/* adhoc id = 31~2 */ + for (mac_id = (NUM_STA-1); mac_id >= IBSS_START_MAC_ID; mac_id--) { + if (pmlmeinfo->FW_sta_info[mac_id].status == 1) + break; + } + } + return mac_id; +} + +/* FOR AP , AD-HOC mode */ +void rtw_stassoc_hw_rpt(struct adapter *adapter, struct sta_info *psta) +{ + u16 media_status; + u8 macid; + + if (psta == NULL) + return; + + macid = search_max_mac_id(adapter); + rtw_hal_set_hwreg(adapter, HW_VAR_TX_RPT_MAX_MACID, (u8 *)&macid); + media_status = (psta->mac_id<<8)|1; /* MACID|OPMODE:1 connect */ + rtw_hal_set_hwreg(adapter, HW_VAR_H2C_MEDIA_STATUS_RPT, (u8 *)&media_status); +} + +void rtw_stassoc_event_callback(struct adapter *adapter, u8 *pbuf) +{ + unsigned long irql; + struct sta_info *psta; + struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); + struct stassoc_event *pstassoc = (struct stassoc_event *)pbuf; + struct wlan_network *cur_network = &(pmlmepriv->cur_network); + struct wlan_network *ptarget_wlan = NULL; + +_func_enter_; + + if (rtw_access_ctrl(adapter, pstassoc->macaddr) == false) + return; + +#if defined (CONFIG_88EU_AP_MODE) + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { + psta = rtw_get_stainfo(&adapter->stapriv, pstassoc->macaddr); + if (psta) { + ap_sta_info_defer_update(adapter, psta); + rtw_stassoc_hw_rpt(adapter, psta); + } + goto exit; + } +#endif + /* for AD-HOC mode */ + psta = rtw_get_stainfo(&adapter->stapriv, pstassoc->macaddr); + if (psta != NULL) { + /* the sta have been in sta_info_queue => do nothing */ + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Error: rtw_stassoc_event_callback: sta has been in sta_hash_queue\n")); + goto exit; /* between drv has received this event before and fw have not yet to set key to CAM_ENTRY) */ + } + psta = rtw_alloc_stainfo(&adapter->stapriv, pstassoc->macaddr); + if (psta == NULL) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Can't alloc sta_info when rtw_stassoc_event_callback\n")); + goto exit; + } + /* to do: init sta_info variable */ + psta->qos_option = 0; + psta->mac_id = (uint)pstassoc->cam_id; + DBG_88E("%s\n", __func__); + /* for ad-hoc mode */ + rtw_hal_set_odm_var(adapter, HAL_ODM_STA_INFO, psta, true); + rtw_stassoc_hw_rpt(adapter, psta); + if (adapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) + psta->dot118021XPrivacy = adapter->securitypriv.dot11PrivacyAlgrthm; + psta->ieee8021x_blocked = false; + _enter_critical_bh(&pmlmepriv->lock, &irql); + if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) || + (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE))) { + if (adapter->stapriv.asoc_sta_count == 2) { + _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irql); + ptarget_wlan = rtw_find_network(&pmlmepriv->scanned_queue, cur_network->network.MacAddress); + if (ptarget_wlan) + ptarget_wlan->fixed = true; + _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irql); + /* a sta + bc/mc_stainfo (not Ibss_stainfo) */ + rtw_indicate_connect(adapter); + } + } + _exit_critical_bh(&pmlmepriv->lock, &irql); + mlmeext_sta_add_event_callback(adapter, psta); +exit: +_func_exit_; +} + +void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf) +{ + unsigned long irql, irql2; + int mac_id = -1; + struct sta_info *psta; + struct wlan_network *pwlan = NULL; + struct wlan_bssid_ex *pdev_network = NULL; + u8 *pibss = NULL; + struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); + struct stadel_event *pstadel = (struct stadel_event *)pbuf; + struct sta_priv *pstapriv = &adapter->stapriv; + struct wlan_network *tgt_network = &(pmlmepriv->cur_network); + +_func_enter_; + + psta = rtw_get_stainfo(&adapter->stapriv, pstadel->macaddr); + if (psta) + mac_id = psta->mac_id; + else + mac_id = pstadel->mac_id; + + DBG_88E("%s(mac_id=%d)=%pM\n", __func__, mac_id, pstadel->macaddr); + + if (mac_id >= 0) { + u16 media_status; + media_status = (mac_id<<8)|0; /* MACID|OPMODE:0 means disconnect */ + /* for STA, AP, ADHOC mode, report disconnect stauts to FW */ + rtw_hal_set_hwreg(adapter, HW_VAR_H2C_MEDIA_STATUS_RPT, (u8 *)&media_status); + } + + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) + return; + + mlmeext_sta_del_event_callback(adapter); + + _enter_critical_bh(&pmlmepriv->lock, &irql2); + + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { + if (pmlmepriv->to_roaming > 0) + pmlmepriv->to_roaming--; /* this stadel_event is caused by roaming, decrease to_roaming */ + else if (pmlmepriv->to_roaming == 0) + pmlmepriv->to_roaming = adapter->registrypriv.max_roaming_times; + + if (*((unsigned short *)(pstadel->rsvd)) != WLAN_REASON_EXPIRATION_CHK) + pmlmepriv->to_roaming = 0; /* don't roam */ + + rtw_free_uc_swdec_pending_queue(adapter); + + rtw_free_assoc_resources(adapter, 1); + rtw_indicate_disconnect(adapter); + _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irql); + /* remove the network entry in scanned_queue */ + pwlan = rtw_find_network(&pmlmepriv->scanned_queue, tgt_network->network.MacAddress); + if (pwlan) { + pwlan->fixed = false; + rtw_free_network_nolock(pmlmepriv, pwlan); + } + _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irql); + _rtw_roaming(adapter, tgt_network); + } + if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) || + check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { + _enter_critical_bh(&(pstapriv->sta_hash_lock), &irql); + rtw_free_stainfo(adapter, psta); + _exit_critical_bh(&(pstapriv->sta_hash_lock), &irql); + + if (adapter->stapriv.asoc_sta_count == 1) { /* a sta + bc/mc_stainfo (not Ibss_stainfo) */ + _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irql); + /* free old ibss network */ + pwlan = rtw_find_network(&pmlmepriv->scanned_queue, tgt_network->network.MacAddress); + if (pwlan) { + pwlan->fixed = false; + rtw_free_network_nolock(pmlmepriv, pwlan); + } + _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irql); + /* re-create ibss */ + pdev_network = &(adapter->registrypriv.dev_network); + pibss = adapter->registrypriv.dev_network.MacAddress; + + memcpy(pdev_network, &tgt_network->network, get_wlan_bssid_ex_sz(&tgt_network->network)); + + _rtw_memset(&pdev_network->Ssid, 0, sizeof(struct ndis_802_11_ssid)); + memcpy(&pdev_network->Ssid, &pmlmepriv->assoc_ssid, sizeof(struct ndis_802_11_ssid)); + + rtw_update_registrypriv_dev_network(adapter); + + rtw_generate_random_ibss(pibss); + + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { + set_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE); + _clr_fwstate_(pmlmepriv, WIFI_ADHOC_STATE); + } + + if (rtw_createbss_cmd(adapter) != _SUCCESS) + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("***Error=>stadel_event_callback: rtw_createbss_cmd status FAIL***\n ")); + } + } + _exit_critical_bh(&pmlmepriv->lock, &irql2); +_func_exit_; +} + +void rtw_cpwm_event_callback(struct adapter *padapter, u8 *pbuf) +{ +_func_enter_; + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("+rtw_cpwm_event_callback !!!\n")); +_func_exit_; +} + +/* +* _rtw_join_timeout_handler - Timeout/faliure handler for CMD JoinBss +* @adapter: pointer to struct adapter structure +*/ +void _rtw_join_timeout_handler (struct adapter *adapter) +{ + unsigned long irql; + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + int do_join_r; + +_func_enter_; + + DBG_88E("%s, fw_state=%x\n", __func__, get_fwstate(pmlmepriv)); + + if (adapter->bDriverStopped || adapter->bSurpriseRemoved) + return; + + + _enter_critical_bh(&pmlmepriv->lock, &irql); + + if (pmlmepriv->to_roaming > 0) { /* join timeout caused by roaming */ + while (1) { + pmlmepriv->to_roaming--; + if (pmlmepriv->to_roaming != 0) { /* try another , */ + DBG_88E("%s try another roaming\n", __func__); + do_join_r = rtw_do_join(adapter); + if (_SUCCESS != do_join_r) { + DBG_88E("%s roaming do_join return %d\n", __func__ , do_join_r); + continue; + } + break; + } else { + DBG_88E("%s We've try roaming but fail\n", __func__); + rtw_indicate_disconnect(adapter); + break; + } + } + } else { + rtw_indicate_disconnect(adapter); + free_scanqueue(pmlmepriv);/* */ + } + _exit_critical_bh(&pmlmepriv->lock, &irql); +_func_exit_; +} + +/* +* rtw_scan_timeout_handler - Timeout/Faliure handler for CMD SiteSurvey +* @adapter: pointer to struct adapter structure +*/ +void rtw_scan_timeout_handler (struct adapter *adapter) +{ + unsigned long irql; + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + + DBG_88E(FUNC_ADPT_FMT" fw_state=%x\n", FUNC_ADPT_ARG(adapter), get_fwstate(pmlmepriv)); + _enter_critical_bh(&pmlmepriv->lock, &irql); + _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY); + _exit_critical_bh(&pmlmepriv->lock, &irql); + rtw_indicate_scan_done(adapter, true); +} + +static void rtw_auto_scan_handler(struct adapter *padapter) +{ + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + + /* auto site survey per 60sec */ + if (pmlmepriv->scan_interval > 0) { + pmlmepriv->scan_interval--; + if (pmlmepriv->scan_interval == 0) { + DBG_88E("%s\n", __func__); + rtw_set_802_11_bssid_list_scan(padapter, NULL, 0); + pmlmepriv->scan_interval = SCAN_INTERVAL;/* 30*2 sec = 60sec */ + } + } +} + +void rtw_dynamic_check_timer_handlder(struct adapter *adapter) +{ + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + struct registry_priv *pregistrypriv = &adapter->registrypriv; + + if (!adapter) + return; + if (!adapter->hw_init_completed) + return; + if ((adapter->bDriverStopped) || (adapter->bSurpriseRemoved)) + return; + if (adapter->net_closed) + return; + rtw_dynamic_chk_wk_cmd(adapter); + + if (pregistrypriv->wifi_spec == 1) { +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &adapter->wdinfo; + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) +#endif + { + /* auto site survey */ + rtw_auto_scan_handler(adapter); + } + } + + rcu_read_lock(); + + if (rcu_dereference(adapter->pnetdev->rx_handler_data) && + (check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_ADHOC_STATE) == true)) { + /* expire NAT2.5 entry */ + nat25_db_expire(adapter); + + if (adapter->pppoe_connection_in_progress > 0) { + adapter->pppoe_connection_in_progress--; + } + + /* due to rtw_dynamic_check_timer_handlder() is called every 2 seconds */ + if (adapter->pppoe_connection_in_progress > 0) { + adapter->pppoe_connection_in_progress--; + } + } + + rcu_read_unlock(); +} + +#define RTW_SCAN_RESULT_EXPIRE 2000 + +/* +* Select a new join candidate from the original @param candidate and @param competitor +* @return true: candidate is updated +* @return false: candidate is not updated +*/ +static int rtw_check_join_candidate(struct mlme_priv *pmlmepriv + , struct wlan_network **candidate, struct wlan_network *competitor) +{ + int updated = false; + struct adapter *adapter = container_of(pmlmepriv, struct adapter, mlmepriv); + + + /* check bssid, if needed */ + if (pmlmepriv->assoc_by_bssid) { + if (!_rtw_memcmp(competitor->network.MacAddress, pmlmepriv->assoc_bssid, ETH_ALEN)) + goto exit; + } + + /* check ssid, if needed */ + if (pmlmepriv->assoc_ssid.Ssid && pmlmepriv->assoc_ssid.SsidLength) { + if (competitor->network.Ssid.SsidLength != pmlmepriv->assoc_ssid.SsidLength || + _rtw_memcmp(competitor->network.Ssid.Ssid, pmlmepriv->assoc_ssid.Ssid, pmlmepriv->assoc_ssid.SsidLength) == false) + goto exit; + } + + if (rtw_is_desired_network(adapter, competitor) == false) + goto exit; + + if (pmlmepriv->to_roaming) { + if (rtw_get_passing_time_ms((u32)competitor->last_scanned) >= RTW_SCAN_RESULT_EXPIRE || + is_same_ess(&competitor->network, &pmlmepriv->cur_network.network) == false) + goto exit; + } + + if (*candidate == NULL || (*candidate)->network.Rssi < competitor->network.Rssi) { + *candidate = competitor; + updated = true; + } + if (updated) { + DBG_88E("[by_bssid:%u][assoc_ssid:%s]new candidate: %s(%pM rssi:%d\n", + pmlmepriv->assoc_by_bssid, + pmlmepriv->assoc_ssid.Ssid, + (*candidate)->network.Ssid.Ssid, + (*candidate)->network.MacAddress, + (int)(*candidate)->network.Rssi); + DBG_88E("[to_roaming:%u]\n", pmlmepriv->to_roaming); + } + +exit: + return updated; +} + +/* +Calling context: +The caller of the sub-routine will be in critical section... +The caller must hold the following spinlock +pmlmepriv->lock +*/ + +int rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv) +{ + unsigned long irql; + int ret; + struct list_head *phead; + struct adapter *adapter; + struct __queue *queue = &(pmlmepriv->scanned_queue); + struct wlan_network *pnetwork = NULL; + struct wlan_network *candidate = NULL; + u8 supp_ant_div = false; + +_func_enter_; + + _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irql); + phead = get_list_head(queue); + adapter = (struct adapter *)pmlmepriv->nic_hdl; + pmlmepriv->pscanned = get_next(phead); + while (!rtw_end_of_queue_search(phead, pmlmepriv->pscanned)) { + pnetwork = LIST_CONTAINOR(pmlmepriv->pscanned, struct wlan_network, list); + if (pnetwork == NULL) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s return _FAIL:(pnetwork==NULL)\n", __func__)); + ret = _FAIL; + goto exit; + } + pmlmepriv->pscanned = get_next(pmlmepriv->pscanned); + rtw_check_join_candidate(pmlmepriv, &candidate, pnetwork); + } + if (candidate == NULL) { + DBG_88E("%s: return _FAIL(candidate==NULL)\n", __func__); + ret = _FAIL; + goto exit; + } else { + DBG_88E("%s: candidate: %s(%pM ch:%u)\n", __func__, + candidate->network.Ssid.Ssid, candidate->network.MacAddress, + candidate->network.Configuration.DSConfig); + } + + + /* check for situation of _FW_LINKED */ + if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + DBG_88E("%s: _FW_LINKED while ask_for_joinbss!!!\n", __func__); + + rtw_disassoc_cmd(adapter, 0, true); + rtw_indicate_disconnect(adapter); + rtw_free_assoc_resources(adapter, 0); + } + + rtw_hal_get_def_var(adapter, HAL_DEF_IS_SUPPORT_ANT_DIV, &(supp_ant_div)); + if (supp_ant_div) { + u8 cur_ant; + rtw_hal_get_def_var(adapter, HAL_DEF_CURRENT_ANTENNA, &(cur_ant)); + DBG_88E("#### Opt_Ant_(%s), cur_Ant(%s)\n", + (2 == candidate->network.PhyInfo.Optimum_antenna) ? "A" : "B", + (2 == cur_ant) ? "A" : "B" + ); + } + + ret = rtw_joinbss_cmd(adapter, candidate); + +exit: + _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irql); + +_func_exit_; + + return ret; +} + +int rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv) +{ + struct cmd_obj *pcmd; + struct setauth_parm *psetauthparm; + struct cmd_priv *pcmdpriv = &(adapter->cmdpriv); + int res = _SUCCESS; + +_func_enter_; + + pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (pcmd == NULL) { + res = _FAIL; /* try again */ + goto exit; + } + + psetauthparm = (struct setauth_parm *)rtw_zmalloc(sizeof(struct setauth_parm)); + if (psetauthparm == NULL) { + kfree(pcmd); + res = _FAIL; + goto exit; + } + _rtw_memset(psetauthparm, 0, sizeof(struct setauth_parm)); + psetauthparm->mode = (unsigned char)psecuritypriv->dot11AuthAlgrthm; + pcmd->cmdcode = _SetAuth_CMD_; + pcmd->parmbuf = (unsigned char *)psetauthparm; + pcmd->cmdsz = (sizeof(struct setauth_parm)); + pcmd->rsp = NULL; + pcmd->rspsz = 0; + _rtw_init_listhead(&pcmd->list); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, + ("after enqueue set_auth_cmd, auth_mode=%x\n", + psecuritypriv->dot11AuthAlgrthm)); + res = rtw_enqueue_cmd(pcmdpriv, pcmd); +exit: +_func_exit_; + return res; +} + +int rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, int keyid, u8 set_tx) +{ + u8 keylen; + struct cmd_obj *pcmd; + struct setkey_parm *psetkeyparm; + struct cmd_priv *pcmdpriv = &(adapter->cmdpriv); + struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); + int res = _SUCCESS; + +_func_enter_; + pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (pcmd == NULL) { + res = _FAIL; /* try again */ + goto exit; + } + psetkeyparm = (struct setkey_parm *)rtw_zmalloc(sizeof(struct setkey_parm)); + if (psetkeyparm == NULL) { + kfree(pcmd); + res = _FAIL; + goto exit; + } + + _rtw_memset(psetkeyparm, 0, sizeof(struct setkey_parm)); + + if (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) { + psetkeyparm->algorithm = (unsigned char)psecuritypriv->dot118021XGrpPrivacy; + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, + ("\n rtw_set_key: psetkeyparm->algorithm=(unsigned char)psecuritypriv->dot118021XGrpPrivacy=%d\n", + psetkeyparm->algorithm)); + } else { + psetkeyparm->algorithm = (u8)psecuritypriv->dot11PrivacyAlgrthm; + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, + ("\n rtw_set_key: psetkeyparm->algorithm=(u8)psecuritypriv->dot11PrivacyAlgrthm=%d\n", + psetkeyparm->algorithm)); + } + psetkeyparm->keyid = (u8)keyid;/* 0~3 */ + psetkeyparm->set_tx = set_tx; + pmlmepriv->key_mask |= BIT(psetkeyparm->keyid); + DBG_88E("==> rtw_set_key algorithm(%x), keyid(%x), key_mask(%x)\n", + psetkeyparm->algorithm, psetkeyparm->keyid, pmlmepriv->key_mask); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, + ("\n rtw_set_key: psetkeyparm->algorithm=%d psetkeyparm->keyid=(u8)keyid=%d\n", + psetkeyparm->algorithm, keyid)); + + switch (psetkeyparm->algorithm) { + case _WEP40_: + keylen = 5; + memcpy(&(psetkeyparm->key[0]), &(psecuritypriv->dot11DefKey[keyid].skey[0]), keylen); + break; + case _WEP104_: + keylen = 13; + memcpy(&(psetkeyparm->key[0]), &(psecuritypriv->dot11DefKey[keyid].skey[0]), keylen); + break; + case _TKIP_: + keylen = 16; + memcpy(&psetkeyparm->key, &psecuritypriv->dot118021XGrpKey[keyid], keylen); + psetkeyparm->grpkey = 1; + break; + case _AES_: + keylen = 16; + memcpy(&psetkeyparm->key, &psecuritypriv->dot118021XGrpKey[keyid], keylen); + psetkeyparm->grpkey = 1; + break; + default: + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, + ("\n rtw_set_key:psecuritypriv->dot11PrivacyAlgrthm=%x (must be 1 or 2 or 4 or 5)\n", + psecuritypriv->dot11PrivacyAlgrthm)); + res = _FAIL; + goto exit; + } + pcmd->cmdcode = _SetKey_CMD_; + pcmd->parmbuf = (u8 *)psetkeyparm; + pcmd->cmdsz = (sizeof(struct setkey_parm)); + pcmd->rsp = NULL; + pcmd->rspsz = 0; + _rtw_init_listhead(&pcmd->list); + res = rtw_enqueue_cmd(pcmdpriv, pcmd); +exit: +_func_exit_; + return res; +} + +/* adjust IEs for rtw_joinbss_cmd in WMM */ +int rtw_restruct_wmm_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_len, uint initial_out_len) +{ + unsigned int ielength = 0; + unsigned int i, j; + + i = 12; /* after the fixed IE */ + while (i < in_len) { + ielength = initial_out_len; + + if (in_ie[i] == 0xDD && in_ie[i+2] == 0x00 && in_ie[i+3] == 0x50 && in_ie[i+4] == 0xF2 && in_ie[i+5] == 0x02 && i+5 < in_len) { + /* WMM element ID and OUI */ + /* Append WMM IE to the last index of out_ie */ + + for (j = i; j < i + 9; j++) { + out_ie[ielength] = in_ie[j]; + ielength++; + } + out_ie[initial_out_len + 1] = 0x07; + out_ie[initial_out_len + 6] = 0x00; + out_ie[initial_out_len + 8] = 0x00; + break; + } + i += (in_ie[i+1]+2); /* to the next IE element */ + } + return ielength; +} + +/* */ +/* Ported from 8185: IsInPreAuthKeyList(). (Renamed from SecIsInPreAuthKeyList(), 2006-10-13.) */ +/* Added by Annie, 2006-05-07. */ +/* */ +/* Search by BSSID, */ +/* Return Value: */ +/* -1 :if there is no pre-auth key in the table */ +/* >= 0 :if there is pre-auth key, and return the entry id */ +/* */ +/* */ + +static int SecIsInPMKIDList(struct adapter *Adapter, u8 *bssid) +{ + struct security_priv *psecuritypriv = &Adapter->securitypriv; + int i = 0; + + do { + if ((psecuritypriv->PMKIDList[i].bUsed) && + (_rtw_memcmp(psecuritypriv->PMKIDList[i].Bssid, bssid, ETH_ALEN) == true)) { + break; + } else { + i++; + /* continue; */ + } + + } while (i < NUM_PMKID_CACHE); + + if (i == NUM_PMKID_CACHE) { + i = -1;/* Could not find. */ + } else { + /* There is one Pre-Authentication Key for the specific BSSID. */ + } + return i; +} + +/* */ +/* Check the RSN IE length */ +/* If the RSN IE length <= 20, the RSN IE didn't include the PMKID information */ +/* 0-11th element in the array are the fixed IE */ +/* 12th element in the array is the IE */ +/* 13th element in the array is the IE length */ +/* */ + +static int rtw_append_pmkid(struct adapter *Adapter, int iEntry, u8 *ie, uint ie_len) +{ + struct security_priv *psecuritypriv = &Adapter->securitypriv; + + if (ie[13] <= 20) { + /* The RSN IE didn't include the PMK ID, append the PMK information */ + ie[ie_len] = 1; + ie_len++; + ie[ie_len] = 0; /* PMKID count = 0x0100 */ + ie_len++; + memcpy(&ie[ie_len], &psecuritypriv->PMKIDList[iEntry].PMKID, 16); + + ie_len += 16; + ie[13] += 18;/* PMKID length = 2+16 */ + } + return ie_len; +} + +int rtw_restruct_sec_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_len) +{ + u8 authmode; + uint ielength; + int iEntry; + + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + struct security_priv *psecuritypriv = &adapter->securitypriv; + uint ndisauthmode = psecuritypriv->ndisauthtype; + uint ndissecuritytype = psecuritypriv->ndisencryptstatus; + +_func_enter_; + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, + ("+rtw_restruct_sec_ie: ndisauthmode=%d ndissecuritytype=%d\n", + ndisauthmode, ndissecuritytype)); + + /* copy fixed ie only */ + memcpy(out_ie, in_ie, 12); + ielength = 12; + if ((ndisauthmode == Ndis802_11AuthModeWPA) || + (ndisauthmode == Ndis802_11AuthModeWPAPSK)) + authmode = _WPA_IE_ID_; + if ((ndisauthmode == Ndis802_11AuthModeWPA2) || + (ndisauthmode == Ndis802_11AuthModeWPA2PSK)) + authmode = _WPA2_IE_ID_; + + if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) { + memcpy(out_ie+ielength, psecuritypriv->wps_ie, psecuritypriv->wps_ie_len); + + ielength += psecuritypriv->wps_ie_len; + } else if ((authmode == _WPA_IE_ID_) || (authmode == _WPA2_IE_ID_)) { + /* copy RSN or SSN */ + memcpy(&out_ie[ielength], &psecuritypriv->supplicant_ie[0], psecuritypriv->supplicant_ie[1]+2); + ielength += psecuritypriv->supplicant_ie[1]+2; + rtw_report_sec_ie(adapter, authmode, psecuritypriv->supplicant_ie); + } + + iEntry = SecIsInPMKIDList(adapter, pmlmepriv->assoc_bssid); + if (iEntry < 0) { + return ielength; + } else { + if (authmode == _WPA2_IE_ID_) + ielength = rtw_append_pmkid(adapter, iEntry, out_ie, ielength); + } + +_func_exit_; + + return ielength; +} + +void rtw_init_registrypriv_dev_network(struct adapter *adapter) +{ + struct registry_priv *pregistrypriv = &adapter->registrypriv; + struct eeprom_priv *peepriv = &adapter->eeprompriv; + struct wlan_bssid_ex *pdev_network = &pregistrypriv->dev_network; + u8 *myhwaddr = myid(peepriv); + +_func_enter_; + + memcpy(pdev_network->MacAddress, myhwaddr, ETH_ALEN); + + memcpy(&pdev_network->Ssid, &pregistrypriv->ssid, sizeof(struct ndis_802_11_ssid)); + + pdev_network->Configuration.Length = sizeof(struct ndis_802_11_config); + pdev_network->Configuration.BeaconPeriod = 100; + pdev_network->Configuration.FHConfig.Length = 0; + pdev_network->Configuration.FHConfig.HopPattern = 0; + pdev_network->Configuration.FHConfig.HopSet = 0; + pdev_network->Configuration.FHConfig.DwellTime = 0; + +_func_exit_; +} + +void rtw_update_registrypriv_dev_network(struct adapter *adapter) +{ + int sz = 0; + struct registry_priv *pregistrypriv = &adapter->registrypriv; + struct wlan_bssid_ex *pdev_network = &pregistrypriv->dev_network; + struct security_priv *psecuritypriv = &adapter->securitypriv; + struct wlan_network *cur_network = &adapter->mlmepriv.cur_network; + +_func_enter_; + + pdev_network->Privacy = (psecuritypriv->dot11PrivacyAlgrthm > 0 ? 1 : 0); /* adhoc no 802.1x */ + + pdev_network->Rssi = 0; + + switch (pregistrypriv->wireless_mode) { + case WIRELESS_11B: + pdev_network->NetworkTypeInUse = (Ndis802_11DS); + break; + case WIRELESS_11G: + case WIRELESS_11BG: + case WIRELESS_11_24N: + case WIRELESS_11G_24N: + case WIRELESS_11BG_24N: + pdev_network->NetworkTypeInUse = (Ndis802_11OFDM24); + break; + case WIRELESS_11A: + case WIRELESS_11A_5N: + pdev_network->NetworkTypeInUse = (Ndis802_11OFDM5); + break; + case WIRELESS_11ABGN: + if (pregistrypriv->channel > 14) + pdev_network->NetworkTypeInUse = (Ndis802_11OFDM5); + else + pdev_network->NetworkTypeInUse = (Ndis802_11OFDM24); + break; + default: + /* TODO */ + break; + } + + pdev_network->Configuration.DSConfig = (pregistrypriv->channel); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, + ("pregistrypriv->channel=%d, pdev_network->Configuration.DSConfig=0x%x\n", + pregistrypriv->channel, pdev_network->Configuration.DSConfig)); + + if (cur_network->network.InfrastructureMode == Ndis802_11IBSS) + pdev_network->Configuration.ATIMWindow = (0); + + pdev_network->InfrastructureMode = (cur_network->network.InfrastructureMode); + + /* 1. Supported rates */ + /* 2. IE */ + + sz = rtw_generate_ie(pregistrypriv); + pdev_network->IELength = sz; + pdev_network->Length = get_wlan_bssid_ex_sz((struct wlan_bssid_ex *)pdev_network); + + /* notes: translate IELength & Length after assign the Length to cmdsz in createbss_cmd(); */ + /* pdev_network->IELength = cpu_to_le32(sz); */ +_func_exit_; +} + +void rtw_get_encrypt_decrypt_from_registrypriv(struct adapter *adapter) +{ +_func_enter_; +_func_exit_; +} + +/* the fucntion is at passive_level */ +void rtw_joinbss_reset(struct adapter *padapter) +{ + u8 threshold; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct ht_priv *phtpriv = &pmlmepriv->htpriv; + + /* todo: if you want to do something io/reg/hw setting before join_bss, please add code here */ + pmlmepriv->num_FortyMHzIntolerant = 0; + + pmlmepriv->num_sta_no_ht = 0; + + phtpriv->ampdu_enable = false;/* reset to disabled */ + + /* TH = 1 => means that invalidate usb rx aggregation */ + /* TH = 0 => means that validate usb rx aggregation, use init value. */ + if (phtpriv->ht_option) { + if (padapter->registrypriv.wifi_spec == 1) + threshold = 1; + else + threshold = 0; + rtw_hal_set_hwreg(padapter, HW_VAR_RXDMA_AGG_PG_TH, (u8 *)(&threshold)); + } else { + threshold = 1; + rtw_hal_set_hwreg(padapter, HW_VAR_RXDMA_AGG_PG_TH, (u8 *)(&threshold)); + } +} + +/* the fucntion is >= passive_level */ +unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_ie, uint in_len, uint *pout_len) +{ + u32 ielen, out_len; + enum ht_cap_ampdu_factor max_rx_ampdu_factor; + unsigned char *p; + struct rtw_ieee80211_ht_cap ht_capie; + unsigned char WMM_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01, 0x00}; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct qos_priv *pqospriv = &pmlmepriv->qospriv; + struct ht_priv *phtpriv = &pmlmepriv->htpriv; + u32 rx_packet_offset, max_recvbuf_sz; + + + phtpriv->ht_option = false; + + p = rtw_get_ie(in_ie+12, _HT_CAPABILITY_IE_, &ielen, in_len-12); + + if (p && ielen > 0) { + if (pqospriv->qos_option == 0) { + out_len = *pout_len; + rtw_set_ie(out_ie+out_len, _VENDOR_SPECIFIC_IE_, + _WMM_IE_Length_, WMM_IE, pout_len); + + pqospriv->qos_option = 1; + } + + out_len = *pout_len; + + _rtw_memset(&ht_capie, 0, sizeof(struct rtw_ieee80211_ht_cap)); + + ht_capie.cap_info = IEEE80211_HT_CAP_SUP_WIDTH | + IEEE80211_HT_CAP_SGI_20 | + IEEE80211_HT_CAP_SGI_40 | + IEEE80211_HT_CAP_TX_STBC | + IEEE80211_HT_CAP_DSSSCCK40; + + rtw_hal_get_def_var(padapter, HAL_DEF_RX_PACKET_OFFSET, &rx_packet_offset); + rtw_hal_get_def_var(padapter, HAL_DEF_MAX_RECVBUF_SZ, &max_recvbuf_sz); + + /* + AMPDU_para [1:0]:Max AMPDU Len => 0:8k , 1:16k, 2:32k, 3:64k + AMPDU_para [4:2]:Min MPDU Start Spacing + */ + + rtw_hal_get_def_var(padapter, HW_VAR_MAX_RX_AMPDU_FACTOR, &max_rx_ampdu_factor); + ht_capie.ampdu_params_info = (max_rx_ampdu_factor&0x03); + + if (padapter->securitypriv.dot11PrivacyAlgrthm == _AES_) + ht_capie.ampdu_params_info |= (IEEE80211_HT_CAP_AMPDU_DENSITY&(0x07<<2)); + else + ht_capie.ampdu_params_info |= (IEEE80211_HT_CAP_AMPDU_DENSITY&0x00); + + + rtw_set_ie(out_ie+out_len, _HT_CAPABILITY_IE_, + sizeof(struct rtw_ieee80211_ht_cap), (unsigned char *)&ht_capie, pout_len); + + phtpriv->ht_option = true; + + p = rtw_get_ie(in_ie+12, _HT_ADD_INFO_IE_, &ielen, in_len-12); + if (p && (ielen == sizeof(struct ieee80211_ht_addt_info))) { + out_len = *pout_len; + rtw_set_ie(out_ie+out_len, _HT_ADD_INFO_IE_, ielen, p+2 , pout_len); + } + } + return phtpriv->ht_option; +} + +/* the fucntion is > passive_level (in critical_section) */ +void rtw_update_ht_cap(struct adapter *padapter, u8 *pie, uint ie_len) +{ + u8 *p, max_ampdu_sz; + int len; + struct rtw_ieee80211_ht_cap *pht_capie; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct ht_priv *phtpriv = &pmlmepriv->htpriv; + struct registry_priv *pregistrypriv = &padapter->registrypriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + if (!phtpriv->ht_option) + return; + + if ((!pmlmeinfo->HT_info_enable) || (!pmlmeinfo->HT_caps_enable)) + return; + + DBG_88E("+rtw_update_ht_cap()\n"); + + /* maybe needs check if ap supports rx ampdu. */ + if ((!phtpriv->ampdu_enable) && (pregistrypriv->ampdu_enable == 1)) { + if (pregistrypriv->wifi_spec == 1) + phtpriv->ampdu_enable = false; + else + phtpriv->ampdu_enable = true; + } else if (pregistrypriv->ampdu_enable == 2) { + phtpriv->ampdu_enable = true; + } + + + /* check Max Rx A-MPDU Size */ + len = 0; + p = rtw_get_ie(pie+sizeof(struct ndis_802_11_fixed_ie), _HT_CAPABILITY_IE_, &len, ie_len-sizeof(struct ndis_802_11_fixed_ie)); + if (p && len > 0) { + pht_capie = (struct rtw_ieee80211_ht_cap *)(p+2); + max_ampdu_sz = (pht_capie->ampdu_params_info & IEEE80211_HT_CAP_AMPDU_FACTOR); + max_ampdu_sz = 1 << (max_ampdu_sz+3); /* max_ampdu_sz (kbytes); */ + phtpriv->rx_ampdu_maxlen = max_ampdu_sz; + } + len = 0; + p = rtw_get_ie(pie+sizeof(struct ndis_802_11_fixed_ie), _HT_ADD_INFO_IE_, &len, ie_len-sizeof(struct ndis_802_11_fixed_ie)); + + /* update cur_bwmode & cur_ch_offset */ + if ((pregistrypriv->cbw40_enable) && + (le16_to_cpu(pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info) & BIT(1)) && + (pmlmeinfo->HT_info.infos[0] & BIT(2))) { + int i; + u8 rf_type; + + padapter->HalFunc.GetHwRegHandler(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); + + /* update the MCS rates */ + for (i = 0; i < 16; i++) { + if ((rf_type == RF_1T1R) || (rf_type == RF_1T2R)) + pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate[i] &= MCS_rate_1R[i]; + else + pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate[i] &= MCS_rate_2R[i]; + } + /* switch to the 40M Hz mode accoring to the AP */ + pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_40; + switch ((pmlmeinfo->HT_info.infos[0] & 0x3)) { + case HT_EXTCHNL_OFFSET_UPPER: + pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER; + break; + case HT_EXTCHNL_OFFSET_LOWER: + pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER; + break; + default: + pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; + break; + } + } + + /* Config SM Power Save setting */ + pmlmeinfo->SM_PS = (le16_to_cpu(pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info) & 0x0C) >> 2; + if (pmlmeinfo->SM_PS == WLAN_HT_CAP_SM_PS_STATIC) + DBG_88E("%s(): WLAN_HT_CAP_SM_PS_STATIC\n", __func__); + + /* Config current HT Protection mode. */ + pmlmeinfo->HT_protection = pmlmeinfo->HT_info.infos[1] & 0x3; +} + +void rtw_issue_addbareq_cmd(struct adapter *padapter, struct xmit_frame *pxmitframe) +{ + u8 issued; + int priority; + struct sta_info *psta = NULL; + struct ht_priv *phtpriv; + struct pkt_attrib *pattrib = &pxmitframe->attrib; + s32 bmcst = IS_MCAST(pattrib->ra); + + if (bmcst || (padapter->mlmepriv.LinkDetectInfo.NumTxOkInPeriod < 100)) + return; + + priority = pattrib->priority; + + if (pattrib->psta) + psta = pattrib->psta; + else + psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra); + + if (psta == NULL) + return; + + phtpriv = &psta->htpriv; + + if ((phtpriv->ht_option) && (phtpriv->ampdu_enable)) { + issued = (phtpriv->agg_enable_bitmap>>priority)&0x1; + issued |= (phtpriv->candidate_tid_bitmap>>priority)&0x1; + + if (0 == issued) { + DBG_88E("rtw_issue_addbareq_cmd, p=%d\n", priority); + psta->htpriv.candidate_tid_bitmap |= BIT((u8)priority); + rtw_addbareq_cmd(padapter, (u8) priority, pattrib->ra); + } + } +} + +void rtw_roaming(struct adapter *padapter, struct wlan_network *tgt_network) +{ + unsigned long irql; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + + _enter_critical_bh(&pmlmepriv->lock, &irql); + _rtw_roaming(padapter, tgt_network); + _exit_critical_bh(&pmlmepriv->lock, &irql); +} +void _rtw_roaming(struct adapter *padapter, struct wlan_network *tgt_network) +{ + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + int do_join_r; + + struct wlan_network *pnetwork; + + if (tgt_network != NULL) + pnetwork = tgt_network; + else + pnetwork = &pmlmepriv->cur_network; + + if (0 < pmlmepriv->to_roaming) { + DBG_88E("roaming from %s(%pM length:%d\n", + pnetwork->network.Ssid.Ssid, pnetwork->network.MacAddress, + pnetwork->network.Ssid.SsidLength); + memcpy(&pmlmepriv->assoc_ssid, &pnetwork->network.Ssid, sizeof(struct ndis_802_11_ssid)); + + pmlmepriv->assoc_by_bssid = false; + + while (1) { + do_join_r = rtw_do_join(padapter); + if (_SUCCESS == do_join_r) { + break; + } else { + DBG_88E("roaming do_join return %d\n", do_join_r); + pmlmepriv->to_roaming--; + + if (0 < pmlmepriv->to_roaming) { + continue; + } else { + DBG_88E("%s(%d) -to roaming fail, indicate_disconnect\n", __func__, __LINE__); + rtw_indicate_disconnect(padapter); + break; + } + } + } + } +} diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c new file mode 100644 index 0000000000000..8b2ba26ba38d9 --- /dev/null +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -0,0 +1,8481 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTW_MLME_EXT_C_ + +#include +#include +#include +#include +#include +#include +#include + +static struct mlme_handler mlme_sta_tbl[] = { + {WIFI_ASSOCREQ, "OnAssocReq", &OnAssocReq}, + {WIFI_ASSOCRSP, "OnAssocRsp", &OnAssocRsp}, + {WIFI_REASSOCREQ, "OnReAssocReq", &OnAssocReq}, + {WIFI_REASSOCRSP, "OnReAssocRsp", &OnAssocRsp}, + {WIFI_PROBEREQ, "OnProbeReq", &OnProbeReq}, + {WIFI_PROBERSP, "OnProbeRsp", &OnProbeRsp}, + + /*---------------------------------------------------------- + below 2 are reserved + -----------------------------------------------------------*/ + {0, "DoReserved", &DoReserved}, + {0, "DoReserved", &DoReserved}, + {WIFI_BEACON, "OnBeacon", &OnBeacon}, + {WIFI_ATIM, "OnATIM", &OnAtim}, + {WIFI_DISASSOC, "OnDisassoc", &OnDisassoc}, + {WIFI_AUTH, "OnAuth", &OnAuthClient}, + {WIFI_DEAUTH, "OnDeAuth", &OnDeAuth}, + {WIFI_ACTION, "OnAction", &OnAction}, +}; + +static struct action_handler OnAction_tbl[] = { + {RTW_WLAN_CATEGORY_SPECTRUM_MGMT, "ACTION_SPECTRUM_MGMT", on_action_spct}, + {RTW_WLAN_CATEGORY_QOS, "ACTION_QOS", &OnAction_qos}, + {RTW_WLAN_CATEGORY_DLS, "ACTION_DLS", &OnAction_dls}, + {RTW_WLAN_CATEGORY_BACK, "ACTION_BACK", &OnAction_back}, + {RTW_WLAN_CATEGORY_PUBLIC, "ACTION_PUBLIC", on_action_public}, + {RTW_WLAN_CATEGORY_RADIO_MEASUREMENT, "ACTION_RADIO_MEASUREMENT", &DoReserved}, + {RTW_WLAN_CATEGORY_FT, "ACTION_FT", &DoReserved}, + {RTW_WLAN_CATEGORY_HT, "ACTION_HT", &OnAction_ht}, + {RTW_WLAN_CATEGORY_SA_QUERY, "ACTION_SA_QUERY", &DoReserved}, + {RTW_WLAN_CATEGORY_WMM, "ACTION_WMM", &OnAction_wmm}, + {RTW_WLAN_CATEGORY_P2P, "ACTION_P2P", &OnAction_p2p}, +}; + + +static u8 null_addr[ETH_ALEN] = {0, 0, 0, 0, 0, 0}; + +/************************************************** +OUI definitions for the vendor specific IE +***************************************************/ +unsigned char RTW_WPA_OUI[] = {0x00, 0x50, 0xf2, 0x01}; +unsigned char WMM_OUI[] = {0x00, 0x50, 0xf2, 0x02}; +unsigned char WPS_OUI[] = {0x00, 0x50, 0xf2, 0x04}; +unsigned char P2P_OUI[] = {0x50, 0x6F, 0x9A, 0x09}; +unsigned char WFD_OUI[] = {0x50, 0x6F, 0x9A, 0x0A}; + +unsigned char WMM_INFO_OUI[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01}; +unsigned char WMM_PARA_OUI[] = {0x00, 0x50, 0xf2, 0x02, 0x01, 0x01}; + +unsigned char WPA_TKIP_CIPHER[4] = {0x00, 0x50, 0xf2, 0x02}; +unsigned char RSN_TKIP_CIPHER[4] = {0x00, 0x0f, 0xac, 0x02}; + +extern unsigned char REALTEK_96B_IE[]; + +/******************************************************** +MCS rate definitions +*********************************************************/ +unsigned char MCS_rate_2R[16] = {0xff, 0xff, 0x0, 0x0, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; +unsigned char MCS_rate_1R[16] = {0xff, 0x00, 0x0, 0x0, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; + +/******************************************************** +ChannelPlan definitions +*********************************************************/ +static struct rt_channel_plan_2g RTW_ChannelPlan2G[RT_CHANNEL_DOMAIN_2G_MAX] = { + {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13}, /* 0x00, RT_CHANNEL_DOMAIN_2G_WORLD , Passive scan CH 12, 13 */ + {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13}, /* 0x01, RT_CHANNEL_DOMAIN_2G_ETSI1 */ + {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}, 11}, /* 0x02, RT_CHANNEL_DOMAIN_2G_FCC1 */ + {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}, 14}, /* 0x03, RT_CHANNEL_DOMAIN_2G_MIKK1 */ + {{10, 11, 12, 13}, 4}, /* 0x04, RT_CHANNEL_DOMAIN_2G_ETSI2 */ + {{}, 0}, /* 0x05, RT_CHANNEL_DOMAIN_2G_NULL */ +}; + +static struct rt_channel_plan_map RTW_ChannelPlanMap[RT_CHANNEL_DOMAIN_MAX] = { + /* 0x00 ~ 0x1F , Old Define ===== */ + {0x02}, /* 0x00, RT_CHANNEL_DOMAIN_FCC */ + {0x02}, /* 0x01, RT_CHANNEL_DOMAIN_IC */ + {0x01}, /* 0x02, RT_CHANNEL_DOMAIN_ETSI */ + {0x01}, /* 0x03, RT_CHANNEL_DOMAIN_SPAIN */ + {0x01}, /* 0x04, RT_CHANNEL_DOMAIN_FRANCE */ + {0x03}, /* 0x05, RT_CHANNEL_DOMAIN_MKK */ + {0x03}, /* 0x06, RT_CHANNEL_DOMAIN_MKK1 */ + {0x01}, /* 0x07, RT_CHANNEL_DOMAIN_ISRAEL */ + {0x03}, /* 0x08, RT_CHANNEL_DOMAIN_TELEC */ + {0x03}, /* 0x09, RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN */ + {0x00}, /* 0x0A, RT_CHANNEL_DOMAIN_WORLD_WIDE_13 */ + {0x02}, /* 0x0B, RT_CHANNEL_DOMAIN_TAIWAN */ + {0x01}, /* 0x0C, RT_CHANNEL_DOMAIN_CHINA */ + {0x02}, /* 0x0D, RT_CHANNEL_DOMAIN_SINGAPORE_INDIA_MEXICO */ + {0x02}, /* 0x0E, RT_CHANNEL_DOMAIN_KOREA */ + {0x02}, /* 0x0F, RT_CHANNEL_DOMAIN_TURKEY */ + {0x01}, /* 0x10, RT_CHANNEL_DOMAIN_JAPAN */ + {0x02}, /* 0x11, RT_CHANNEL_DOMAIN_FCC_NO_DFS */ + {0x01}, /* 0x12, RT_CHANNEL_DOMAIN_JAPAN_NO_DFS */ + {0x00}, /* 0x13, RT_CHANNEL_DOMAIN_WORLD_WIDE_5G */ + {0x02}, /* 0x14, RT_CHANNEL_DOMAIN_TAIWAN_NO_DFS */ + {0x00}, /* 0x15, RT_CHANNEL_DOMAIN_ETSI_NO_DFS */ + {0x00}, /* 0x16, RT_CHANNEL_DOMAIN_KOREA_NO_DFS */ + {0x03}, /* 0x17, RT_CHANNEL_DOMAIN_JAPAN_NO_DFS */ + {0x05}, /* 0x18, RT_CHANNEL_DOMAIN_PAKISTAN_NO_DFS */ + {0x02}, /* 0x19, RT_CHANNEL_DOMAIN_TAIWAN2_NO_DFS */ + {0x00}, /* 0x1A, */ + {0x00}, /* 0x1B, */ + {0x00}, /* 0x1C, */ + {0x00}, /* 0x1D, */ + {0x00}, /* 0x1E, */ + {0x05}, /* 0x1F, RT_CHANNEL_DOMAIN_WORLD_WIDE_ONLY_5G */ + /* 0x20 ~ 0x7F , New Define ===== */ + {0x00}, /* 0x20, RT_CHANNEL_DOMAIN_WORLD_NULL */ + {0x01}, /* 0x21, RT_CHANNEL_DOMAIN_ETSI1_NULL */ + {0x02}, /* 0x22, RT_CHANNEL_DOMAIN_FCC1_NULL */ + {0x03}, /* 0x23, RT_CHANNEL_DOMAIN_MKK1_NULL */ + {0x04}, /* 0x24, RT_CHANNEL_DOMAIN_ETSI2_NULL */ + {0x02}, /* 0x25, RT_CHANNEL_DOMAIN_FCC1_FCC1 */ + {0x00}, /* 0x26, RT_CHANNEL_DOMAIN_WORLD_ETSI1 */ + {0x03}, /* 0x27, RT_CHANNEL_DOMAIN_MKK1_MKK1 */ + {0x00}, /* 0x28, RT_CHANNEL_DOMAIN_WORLD_KCC1 */ + {0x00}, /* 0x29, RT_CHANNEL_DOMAIN_WORLD_FCC2 */ + {0x00}, /* 0x2A, */ + {0x00}, /* 0x2B, */ + {0x00}, /* 0x2C, */ + {0x00}, /* 0x2D, */ + {0x00}, /* 0x2E, */ + {0x00}, /* 0x2F, */ + {0x00}, /* 0x30, RT_CHANNEL_DOMAIN_WORLD_FCC3 */ + {0x00}, /* 0x31, RT_CHANNEL_DOMAIN_WORLD_FCC4 */ + {0x00}, /* 0x32, RT_CHANNEL_DOMAIN_WORLD_FCC5 */ + {0x00}, /* 0x33, RT_CHANNEL_DOMAIN_WORLD_FCC6 */ + {0x02}, /* 0x34, RT_CHANNEL_DOMAIN_FCC1_FCC7 */ + {0x00}, /* 0x35, RT_CHANNEL_DOMAIN_WORLD_ETSI2 */ + {0x00}, /* 0x36, RT_CHANNEL_DOMAIN_WORLD_ETSI3 */ + {0x03}, /* 0x37, RT_CHANNEL_DOMAIN_MKK1_MKK2 */ + {0x03}, /* 0x38, RT_CHANNEL_DOMAIN_MKK1_MKK3 */ + {0x02}, /* 0x39, RT_CHANNEL_DOMAIN_FCC1_NCC1 */ + {0x00}, /* 0x3A, */ + {0x00}, /* 0x3B, */ + {0x00}, /* 0x3C, */ + {0x00}, /* 0x3D, */ + {0x00}, /* 0x3E, */ + {0x00}, /* 0x3F, */ + {0x02}, /* 0x40, RT_CHANNEL_DOMAIN_FCC1_NCC2 */ + {0x03}, /* 0x41, RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN_2G */ +}; + +static struct rt_channel_plan_map RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE = {0x03}; /* use the conbination for max channel numbers */ + +/* + * Search the @param channel_num in given @param channel_set + * @ch_set: the given channel set + * @ch: the given channel number + * + * return the index of channel_num in channel_set, -1 if not found + */ +int rtw_ch_set_search_ch(struct rt_channel_info *ch_set, const u32 ch) +{ + int i; + for (i = 0; ch_set[i].ChannelNum != 0; i++) { + if (ch == ch_set[i].ChannelNum) + break; + } + + if (i >= ch_set[i].ChannelNum) + return -1; + return i; +} + +/**************************************************************************** + +Following are the initialization functions for WiFi MLME + +*****************************************************************************/ + +int init_hw_mlme_ext(struct adapter *padapter) +{ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + + set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); + return _SUCCESS; +} + +static void init_mlme_ext_priv_value(struct adapter *padapter) +{ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + unsigned char mixed_datarate[NumRates] = { + _1M_RATE_, _2M_RATE_, _5M_RATE_, _11M_RATE_, _6M_RATE_, + _9M_RATE_, _12M_RATE_, _18M_RATE_, _24M_RATE_, _36M_RATE_, + _48M_RATE_, _54M_RATE_, 0xff + }; + unsigned char mixed_basicrate[NumRates] = { + _1M_RATE_, _2M_RATE_, _5M_RATE_, _11M_RATE_, _6M_RATE_, + _12M_RATE_, _24M_RATE_, 0xff, + }; + + ATOMIC_SET(&pmlmeext->event_seq, 0); + pmlmeext->mgnt_seq = 0;/* reset to zero when disconnect at client mode */ + + pmlmeext->cur_channel = padapter->registrypriv.channel; + pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_20; + pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; + pmlmeext->oper_channel = pmlmeext->cur_channel ; + pmlmeext->oper_bwmode = pmlmeext->cur_bwmode; + pmlmeext->oper_ch_offset = pmlmeext->cur_ch_offset; + pmlmeext->retry = 0; + + pmlmeext->cur_wireless_mode = padapter->registrypriv.wireless_mode; + + memcpy(pmlmeext->datarate, mixed_datarate, NumRates); + memcpy(pmlmeext->basicrate, mixed_basicrate, NumRates); + + pmlmeext->tx_rate = IEEE80211_CCK_RATE_1MB; + + pmlmeext->sitesurvey_res.state = SCAN_DISABLE; + pmlmeext->sitesurvey_res.channel_idx = 0; + pmlmeext->sitesurvey_res.bss_cnt = 0; + pmlmeext->scan_abort = false; + + pmlmeinfo->state = WIFI_FW_NULL_STATE; + pmlmeinfo->reauth_count = 0; + pmlmeinfo->reassoc_count = 0; + pmlmeinfo->link_count = 0; + pmlmeinfo->auth_seq = 0; + pmlmeinfo->auth_algo = dot11AuthAlgrthm_Open; + pmlmeinfo->key_index = 0; + pmlmeinfo->iv = 0; + + pmlmeinfo->enc_algo = _NO_PRIVACY_; + pmlmeinfo->authModeToggle = 0; + + _rtw_memset(pmlmeinfo->chg_txt, 0, 128); + + pmlmeinfo->slotTime = SHORT_SLOT_TIME; + pmlmeinfo->preamble_mode = PREAMBLE_AUTO; + + pmlmeinfo->dialogToken = 0; + + pmlmeext->action_public_rxseq = 0xffff; + pmlmeext->action_public_dialog_token = 0xff; +} + +static int has_channel(struct rt_channel_info *channel_set, + u8 chanset_size, + u8 chan) { + int i; + + for (i = 0; i < chanset_size; i++) { + if (channel_set[i].ChannelNum == chan) + return 1; + } + return 0; +} + +static void init_channel_list(struct adapter *padapter, struct rt_channel_info *channel_set, + u8 chanset_size, + struct p2p_channels *channel_list) { + struct p2p_oper_class_map op_class[] = { + { IEEE80211G, 81, 1, 13, 1, BW20 }, + { IEEE80211G, 82, 14, 14, 1, BW20 }, + { -1, 0, 0, 0, 0, BW20 } + }; + + int cla, op; + + cla = 0; + + for (op = 0; op_class[op].op_class; op++) { + u8 ch; + struct p2p_oper_class_map *o = &op_class[op]; + struct p2p_reg_class *reg = NULL; + + for (ch = o->min_chan; ch <= o->max_chan; ch += o->inc) { + if (!has_channel(channel_set, chanset_size, ch)) { + continue; + } + + if ((0 == padapter->registrypriv.ht_enable) && (8 == o->inc)) + continue; + + if ((0 == (padapter->registrypriv.cbw40_enable & BIT(1))) && + ((BW40MINUS == o->bw) || (BW40PLUS == o->bw))) + continue; + + if (reg == NULL) { + reg = &channel_list->reg_class[cla]; + cla++; + reg->reg_class = o->op_class; + reg->channels = 0; + } + reg->channel[reg->channels] = ch; + reg->channels++; + } + } + channel_list->reg_classes = cla; +} + +static u8 init_channel_set(struct adapter *padapter, u8 ChannelPlan, struct rt_channel_info *channel_set) +{ + u8 index, chanset_size = 0; + u8 b2_4GBand = false; + u8 Index2G = 0; + + _rtw_memset(channel_set, 0, sizeof(struct rt_channel_info) * MAX_CHANNEL_NUM); + + if (ChannelPlan >= RT_CHANNEL_DOMAIN_MAX && ChannelPlan != RT_CHANNEL_DOMAIN_REALTEK_DEFINE) { + DBG_88E("ChannelPlan ID %x error !!!!!\n", ChannelPlan); + return chanset_size; + } + + if (padapter->registrypriv.wireless_mode & WIRELESS_11G) { + b2_4GBand = true; + if (RT_CHANNEL_DOMAIN_REALTEK_DEFINE == ChannelPlan) + Index2G = RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE.Index2G; + else + Index2G = RTW_ChannelPlanMap[ChannelPlan].Index2G; + } + + if (b2_4GBand) { + for (index = 0; index < RTW_ChannelPlan2G[Index2G].Len; index++) { + channel_set[chanset_size].ChannelNum = RTW_ChannelPlan2G[Index2G].Channel[index]; + + if ((RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN == ChannelPlan) ||/* Channel 1~11 is active, and 12~14 is passive */ + (RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN_2G == ChannelPlan)) { + if (channel_set[chanset_size].ChannelNum >= 1 && channel_set[chanset_size].ChannelNum <= 11) + channel_set[chanset_size].ScanType = SCAN_ACTIVE; + else if ((channel_set[chanset_size].ChannelNum >= 12 && channel_set[chanset_size].ChannelNum <= 14)) + channel_set[chanset_size].ScanType = SCAN_PASSIVE; + } else if (RT_CHANNEL_DOMAIN_WORLD_WIDE_13 == ChannelPlan || + RT_CHANNEL_DOMAIN_2G_WORLD == Index2G) {/* channel 12~13, passive scan */ + if (channel_set[chanset_size].ChannelNum <= 11) + channel_set[chanset_size].ScanType = SCAN_ACTIVE; + else + channel_set[chanset_size].ScanType = SCAN_PASSIVE; + } else { + channel_set[chanset_size].ScanType = SCAN_ACTIVE; + } + + chanset_size++; + } + } + return chanset_size; +} + +int init_mlme_ext_priv(struct adapter *padapter) +{ + int res = _SUCCESS; + struct registry_priv *pregistrypriv = &padapter->registrypriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + pmlmeext->padapter = padapter; + + init_mlme_ext_priv_value(padapter); + pmlmeinfo->bAcceptAddbaReq = pregistrypriv->bAcceptAddbaReq; + + init_mlme_ext_timer(padapter); + +#ifdef CONFIG_88EU_AP_MODE + init_mlme_ap_info(padapter); +#endif + + pmlmeext->max_chan_nums = init_channel_set(padapter, pmlmepriv->ChannelPlan, pmlmeext->channel_set); + init_channel_list(padapter, pmlmeext->channel_set, pmlmeext->max_chan_nums, &pmlmeext->channel_list); + + pmlmeext->chan_scan_time = SURVEY_TO; + pmlmeext->mlmeext_init = true; + + + pmlmeext->active_keep_alive_check = true; + + return res; +} + +void free_mlme_ext_priv(struct mlme_ext_priv *pmlmeext) +{ + struct adapter *padapter = pmlmeext->padapter; + + if (!padapter) + return; + + if (padapter->bDriverStopped) { + _cancel_timer_ex(&pmlmeext->survey_timer); + _cancel_timer_ex(&pmlmeext->link_timer); + /* _cancel_timer_ex(&pmlmeext->ADDBA_timer); */ + } +} + +static void _mgt_dispatcher(struct adapter *padapter, struct mlme_handler *ptable, union recv_frame *precv_frame) +{ + u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + u8 *pframe = precv_frame->u.hdr.rx_data; + + if (ptable->func) { + /* receive the frames that ra(a1) is my address or ra(a1) is bc address. */ + if (!_rtw_memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN) && + !_rtw_memcmp(GetAddr1Ptr(pframe), bc_addr, ETH_ALEN)) + return; + ptable->func(padapter, precv_frame); + } +} + +void mgt_dispatcher(struct adapter *padapter, union recv_frame *precv_frame) +{ + int index; + struct mlme_handler *ptable; +#ifdef CONFIG_88EU_AP_MODE + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; +#endif /* CONFIG_88EU_AP_MODE */ + u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + u8 *pframe = precv_frame->u.hdr.rx_data; + struct sta_info *psta = rtw_get_stainfo(&padapter->stapriv, GetAddr2Ptr(pframe)); + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, + ("+mgt_dispatcher: type(0x%x) subtype(0x%x)\n", + GetFrameType(pframe), GetFrameSubType(pframe))); + + if (GetFrameType(pframe) != WIFI_MGT_TYPE) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("mgt_dispatcher: type(0x%x) error!\n", GetFrameType(pframe))); + return; + } + + /* receive the frames that ra(a1) is my address or ra(a1) is bc address. */ + if (!_rtw_memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN) && + !_rtw_memcmp(GetAddr1Ptr(pframe), bc_addr, ETH_ALEN)) + return; + + ptable = mlme_sta_tbl; + + index = GetFrameSubType(pframe) >> 4; + + if (index > 13) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Currently we do not support reserved sub-fr-type=%d\n", index)); + return; + } + ptable += index; + + if (psta != NULL) { + if (GetRetry(pframe)) { + if (precv_frame->u.hdr.attrib.seq_num == psta->RxMgmtFrameSeqNum) { + /* drop the duplicate management frame */ + DBG_88E("Drop duplicate management frame with seq_num=%d.\n", precv_frame->u.hdr.attrib.seq_num); + return; + } + } + psta->RxMgmtFrameSeqNum = precv_frame->u.hdr.attrib.seq_num; + } + +#ifdef CONFIG_88EU_AP_MODE + switch (GetFrameSubType(pframe)) { + case WIFI_AUTH: + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) + ptable->func = &OnAuth; + else + ptable->func = &OnAuthClient; + /* fall through */ + case WIFI_ASSOCREQ: + case WIFI_REASSOCREQ: + _mgt_dispatcher(padapter, ptable, precv_frame); + break; + case WIFI_PROBEREQ: + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) + _mgt_dispatcher(padapter, ptable, precv_frame); + else + _mgt_dispatcher(padapter, ptable, precv_frame); + break; + case WIFI_BEACON: + _mgt_dispatcher(padapter, ptable, precv_frame); + break; + case WIFI_ACTION: + _mgt_dispatcher(padapter, ptable, precv_frame); + break; + default: + _mgt_dispatcher(padapter, ptable, precv_frame); + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) + rtw_hostapd_mlme_rx(padapter, precv_frame); + break; + } +#else + _mgt_dispatcher(padapter, ptable, precv_frame); +#endif +} + +#ifdef CONFIG_88EU_P2P +static u32 p2p_listen_state_process(struct adapter *padapter, unsigned char *da) +{ + bool response = true; + + /* do nothing if the device name is empty */ + if (!padapter->wdinfo.device_name_len) + response = false; + + if (response) + issue_probersp_p2p(padapter, da); + + return _SUCCESS; +} +#endif /* CONFIG_88EU_P2P */ + + +/**************************************************************************** + +Following are the callback functions for each subtype of the management frames + +*****************************************************************************/ + +unsigned int OnProbeReq(struct adapter *padapter, union recv_frame *precv_frame) +{ + unsigned int ielen; + unsigned char *p; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *cur = &(pmlmeinfo->network); + u8 *pframe = precv_frame->u.hdr.rx_data; + uint len = precv_frame->u.hdr.len; + u8 is_valid_p2p_probereq = false; + +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + u8 wifi_test_chk_rate = 1; + + if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE) && + !rtw_p2p_chk_state(pwdinfo, P2P_STATE_IDLE) && + !rtw_p2p_chk_role(pwdinfo, P2P_ROLE_CLIENT) && + !rtw_p2p_chk_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH) && + !rtw_p2p_chk_state(pwdinfo, P2P_STATE_SCAN)) { + /* mcs_rate = 0 -> CCK 1M rate */ + /* mcs_rate = 1 -> CCK 2M rate */ + /* mcs_rate = 2 -> CCK 5.5M rate */ + /* mcs_rate = 3 -> CCK 11M rate */ + /* In the P2P mode, the driver should not support the CCK rate */ + + /* Commented by Kurt 2012/10/16 */ + /* IOT issue: Google Nexus7 use 1M rate to send p2p_probe_req after GO nego completed and Nexus7 is client */ + if (wifi_test_chk_rate == 1) { + is_valid_p2p_probereq = process_probe_req_p2p_ie(pwdinfo, pframe, len); + if (is_valid_p2p_probereq) { + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE)) { + /* FIXME */ + report_survey_event(padapter, precv_frame); + p2p_listen_state_process(padapter, get_sa(pframe)); + + return _SUCCESS; + } + + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) + goto _continue; + } + } + } + +_continue: +#endif /* CONFIG_88EU_P2P */ + + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) + return _SUCCESS; + + if (!check_fwstate(pmlmepriv, _FW_LINKED) && + !check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE|WIFI_AP_STATE)) + return _SUCCESS; + + p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + _PROBEREQ_IE_OFFSET_, _SSID_IE_, (int *)&ielen, + len - WLAN_HDR_A3_LEN - _PROBEREQ_IE_OFFSET_); + + /* check (wildcard) SSID */ + if (p != NULL) { + if (is_valid_p2p_probereq) + goto _issue_probersp; + + if ((ielen != 0 && !_rtw_memcmp((void *)(p+2), (void *)cur->Ssid.Ssid, cur->Ssid.SsidLength)) || + (ielen == 0 && pmlmeinfo->hidden_ssid_mode)) + return _SUCCESS; + +_issue_probersp: + + if (check_fwstate(pmlmepriv, _FW_LINKED) && + pmlmepriv->cur_network.join_res) + issue_probersp(padapter, get_sa(pframe), is_valid_p2p_probereq); + } + return _SUCCESS; +} + +unsigned int OnProbeRsp(struct adapter *padapter, union recv_frame *precv_frame) +{ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &padapter->wdinfo; + u8 *pframe = precv_frame->u.hdr.rx_data; +#endif + +#ifdef CONFIG_88EU_P2P + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_TX_PROVISION_DIS_REQ)) { + if (pwdinfo->tx_prov_disc_info.benable) { + if (_rtw_memcmp(pwdinfo->tx_prov_disc_info.peerIFAddr, GetAddr2Ptr(pframe), ETH_ALEN)) { + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_CLIENT)) { + pwdinfo->tx_prov_disc_info.benable = false; + issue_p2p_provision_request(padapter, + pwdinfo->tx_prov_disc_info.ssid.Ssid, + pwdinfo->tx_prov_disc_info.ssid.SsidLength, + pwdinfo->tx_prov_disc_info.peerDevAddr); + } else if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE) || rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { + pwdinfo->tx_prov_disc_info.benable = false; + issue_p2p_provision_request(padapter, NULL, 0, + pwdinfo->tx_prov_disc_info.peerDevAddr); + } + } + } + return _SUCCESS; + } else if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_ING)) { + if (pwdinfo->nego_req_info.benable) { + DBG_88E("[%s] P2P State is GONEGO ING!\n", __func__); + if (_rtw_memcmp(pwdinfo->nego_req_info.peerDevAddr, GetAddr2Ptr(pframe), ETH_ALEN)) { + pwdinfo->nego_req_info.benable = false; + issue_p2p_GO_request(padapter, pwdinfo->nego_req_info.peerDevAddr); + } + } + } else if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_TX_INVITE_REQ)) { + if (pwdinfo->invitereq_info.benable) { + DBG_88E("[%s] P2P_STATE_TX_INVITE_REQ!\n", __func__); + if (_rtw_memcmp(pwdinfo->invitereq_info.peer_macaddr, GetAddr2Ptr(pframe), ETH_ALEN)) { + pwdinfo->invitereq_info.benable = false; + issue_p2p_invitation_request(padapter, pwdinfo->invitereq_info.peer_macaddr); + } + } + } +#endif + + + if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) { + report_survey_event(padapter, precv_frame); + return _SUCCESS; + } + + return _SUCCESS; +} + +unsigned int OnBeacon(struct adapter *padapter, union recv_frame *precv_frame) +{ + int cam_idx; + struct sta_info *psta; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct sta_priv *pstapriv = &padapter->stapriv; + u8 *pframe = precv_frame->u.hdr.rx_data; + uint len = precv_frame->u.hdr.len; + struct wlan_bssid_ex *pbss; + int ret = _SUCCESS; + + if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) { + report_survey_event(padapter, precv_frame); + return _SUCCESS; + } + + if (_rtw_memcmp(GetAddr3Ptr(pframe), get_my_bssid(&pmlmeinfo->network), ETH_ALEN)) { + if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) { + /* we should update current network before auth, or some IE is wrong */ + pbss = (struct wlan_bssid_ex *)rtw_malloc(sizeof(struct wlan_bssid_ex)); + if (pbss) { + if (collect_bss_info(padapter, precv_frame, pbss) == _SUCCESS) { + update_network(&(pmlmepriv->cur_network.network), pbss, padapter, true); + rtw_get_bcn_info(&(pmlmepriv->cur_network)); + } + kfree(pbss); + } + + /* check the vendor of the assoc AP */ + pmlmeinfo->assoc_AP_vendor = check_assoc_AP(pframe+sizeof(struct rtw_ieee80211_hdr_3addr), len-sizeof(struct rtw_ieee80211_hdr_3addr)); + + /* update TSF Value */ + update_TSF(pmlmeext, pframe, len); + + /* start auth */ + start_clnt_auth(padapter); + + return _SUCCESS; + } + + if (((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) && (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) { + psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); + if (psta != NULL) { + ret = rtw_check_bcn_info(padapter, pframe, len); + if (!ret) { + DBG_88E_LEVEL(_drv_info_, "ap has changed, disconnect now\n "); + receive_disconnect(padapter, pmlmeinfo->network.MacAddress , 65535); + return _SUCCESS; + } + /* update WMM, ERP in the beacon */ + /* todo: the timer is used instead of the number of the beacon received */ + if ((sta_rx_pkts(psta) & 0xf) == 0) + update_beacon_info(padapter, pframe, len, psta); + process_p2p_ps_ie(padapter, (pframe + WLAN_HDR_A3_LEN), (len - WLAN_HDR_A3_LEN)); + } + } else if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { + psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); + if (psta != NULL) { + /* update WMM, ERP in the beacon */ + /* todo: the timer is used instead of the number of the beacon received */ + if ((sta_rx_pkts(psta) & 0xf) == 0) + update_beacon_info(padapter, pframe, len, psta); + } else { + /* allocate a new CAM entry for IBSS station */ + cam_idx = allocate_fw_sta_entry(padapter); + if (cam_idx == NUM_STA) + goto _END_ONBEACON_; + + /* get supported rate */ + if (update_sta_support_rate(padapter, (pframe + WLAN_HDR_A3_LEN + _BEACON_IE_OFFSET_), (len - WLAN_HDR_A3_LEN - _BEACON_IE_OFFSET_), cam_idx) == _FAIL) { + pmlmeinfo->FW_sta_info[cam_idx].status = 0; + goto _END_ONBEACON_; + } + + /* update TSF Value */ + update_TSF(pmlmeext, pframe, len); + + /* report sta add event */ + report_add_sta_event(padapter, GetAddr2Ptr(pframe), cam_idx); + } + } + } + +_END_ONBEACON_: + + return _SUCCESS; +} + +unsigned int OnAuth(struct adapter *padapter, union recv_frame *precv_frame) +{ +#ifdef CONFIG_88EU_AP_MODE + unsigned long irqL; + unsigned int auth_mode, ie_len; + u16 seq; + unsigned char *sa, *p; + u16 algorithm; + int status; + static struct sta_info stat; + struct sta_info *pstat = NULL; + struct sta_priv *pstapriv = &padapter->stapriv; + struct security_priv *psecuritypriv = &padapter->securitypriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + u8 *pframe = precv_frame->u.hdr.rx_data; + uint len = precv_frame->u.hdr.len; + + if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) + return _FAIL; + + DBG_88E("+OnAuth\n"); + + sa = GetAddr2Ptr(pframe); + + auth_mode = psecuritypriv->dot11AuthAlgrthm; + seq = le16_to_cpu(*(__le16 *)((size_t)pframe + WLAN_HDR_A3_LEN + 2)); + algorithm = le16_to_cpu(*(__le16 *)((size_t)pframe + WLAN_HDR_A3_LEN)); + + DBG_88E("auth alg=%x, seq=%X\n", algorithm, seq); + + if (auth_mode == 2 && psecuritypriv->dot11PrivacyAlgrthm != _WEP40_ && + psecuritypriv->dot11PrivacyAlgrthm != _WEP104_) + auth_mode = 0; + + if ((algorithm > 0 && auth_mode == 0) || /* rx a shared-key auth but shared not enabled */ + (algorithm == 0 && auth_mode == 1)) { /* rx a open-system auth but shared-key is enabled */ + DBG_88E("auth rejected due to bad alg [alg=%d, auth_mib=%d] %02X%02X%02X%02X%02X%02X\n", + algorithm, auth_mode, sa[0], sa[1], sa[2], sa[3], sa[4], sa[5]); + + status = _STATS_NO_SUPP_ALG_; + + goto auth_fail; + } + + if (!rtw_access_ctrl(padapter, sa)) { + status = _STATS_UNABLE_HANDLE_STA_; + goto auth_fail; + } + + pstat = rtw_get_stainfo(pstapriv, sa); + if (pstat == NULL) { + /* allocate a new one */ + DBG_88E("going to alloc stainfo for sa=%pM\n", sa); + pstat = rtw_alloc_stainfo(pstapriv, sa); + if (pstat == NULL) { + DBG_88E(" Exceed the upper limit of supported clients...\n"); + status = _STATS_UNABLE_HANDLE_STA_; + goto auth_fail; + } + + pstat->state = WIFI_FW_AUTH_NULL; + pstat->auth_seq = 0; + } else { + _enter_critical_bh(&pstapriv->asoc_list_lock, &irqL); + if (!rtw_is_list_empty(&pstat->asoc_list)) { + rtw_list_delete(&pstat->asoc_list); + pstapriv->asoc_list_cnt--; + } + _exit_critical_bh(&pstapriv->asoc_list_lock, &irqL); + + if (seq == 1) { + /* TODO: STA re_auth and auth timeout */ + } + } + + _enter_critical_bh(&pstapriv->auth_list_lock, &irqL); + if (rtw_is_list_empty(&pstat->auth_list)) { + rtw_list_insert_tail(&pstat->auth_list, &pstapriv->auth_list); + pstapriv->auth_list_cnt++; + } + _exit_critical_bh(&pstapriv->auth_list_lock, &irqL); + + if (pstat->auth_seq == 0) + pstat->expire_to = pstapriv->auth_to; + + if ((pstat->auth_seq + 1) != seq) { + DBG_88E("(1)auth rejected because out of seq [rx_seq=%d, exp_seq=%d]!\n", + seq, pstat->auth_seq+1); + status = _STATS_OUT_OF_AUTH_SEQ_; + goto auth_fail; + } + + if (algorithm == 0 && (auth_mode == 0 || auth_mode == 2)) { + if (seq == 1) { + pstat->state &= ~WIFI_FW_AUTH_NULL; + pstat->state |= WIFI_FW_AUTH_SUCCESS; + pstat->expire_to = pstapriv->assoc_to; + pstat->authalg = algorithm; + } else { + DBG_88E("(2)auth rejected because out of seq [rx_seq=%d, exp_seq=%d]!\n", + seq, pstat->auth_seq+1); + status = _STATS_OUT_OF_AUTH_SEQ_; + goto auth_fail; + } + } else { /* shared system or auto authentication */ + if (seq == 1) { + /* prepare for the challenging txt... */ + + pstat->state &= ~WIFI_FW_AUTH_NULL; + pstat->state |= WIFI_FW_AUTH_STATE; + pstat->authalg = algorithm; + pstat->auth_seq = 2; + } else if (seq == 3) { + /* checking for challenging txt... */ + DBG_88E("checking for challenging txt...\n"); + + p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + 4 + _AUTH_IE_OFFSET_ , _CHLGETXT_IE_, (int *)&ie_len, + len - WLAN_HDR_A3_LEN - _AUTH_IE_OFFSET_ - 4); + + if ((p == NULL) || (ie_len <= 0)) { + DBG_88E("auth rejected because challenge failure!(1)\n"); + status = _STATS_CHALLENGE_FAIL_; + goto auth_fail; + } + + if (_rtw_memcmp((void *)(p + 2), pstat->chg_txt, 128)) { + pstat->state &= (~WIFI_FW_AUTH_STATE); + pstat->state |= WIFI_FW_AUTH_SUCCESS; + /* challenging txt is correct... */ + pstat->expire_to = pstapriv->assoc_to; + } else { + DBG_88E("auth rejected because challenge failure!\n"); + status = _STATS_CHALLENGE_FAIL_; + goto auth_fail; + } + } else { + DBG_88E("(3)auth rejected because out of seq [rx_seq=%d, exp_seq=%d]!\n", + seq, pstat->auth_seq+1); + status = _STATS_OUT_OF_AUTH_SEQ_; + goto auth_fail; + } + } + + /* Now, we are going to issue_auth... */ + pstat->auth_seq = seq + 1; + +#ifdef CONFIG_88EU_AP_MODE + issue_auth(padapter, pstat, (unsigned short)(_STATS_SUCCESSFUL_)); +#endif + + if (pstat->state & WIFI_FW_AUTH_SUCCESS) + pstat->auth_seq = 0; + + return _SUCCESS; + +auth_fail: + + if (pstat) + rtw_free_stainfo(padapter , pstat); + + pstat = &stat; + _rtw_memset((char *)pstat, '\0', sizeof(stat)); + pstat->auth_seq = 2; + memcpy(pstat->hwaddr, sa, 6); + +#ifdef CONFIG_88EU_AP_MODE + issue_auth(padapter, pstat, (unsigned short)status); +#endif + +#endif + return _FAIL; +} + +unsigned int OnAuthClient(struct adapter *padapter, union recv_frame *precv_frame) +{ + unsigned int seq, len, status, offset; + unsigned char *p; + unsigned int go2asoc = 0; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + u8 *pframe = precv_frame->u.hdr.rx_data; + uint pkt_len = precv_frame->u.hdr.len; + + DBG_88E("%s\n", __func__); + + /* check A1 matches or not */ + if (!_rtw_memcmp(myid(&(padapter->eeprompriv)), get_da(pframe), ETH_ALEN)) + return _SUCCESS; + + if (!(pmlmeinfo->state & WIFI_FW_AUTH_STATE)) + return _SUCCESS; + + offset = (GetPrivacy(pframe)) ? 4 : 0; + + seq = le16_to_cpu(*(__le16 *)((size_t)pframe + WLAN_HDR_A3_LEN + offset + 2)); + status = le16_to_cpu(*(__le16 *)((size_t)pframe + WLAN_HDR_A3_LEN + offset + 4)); + + if (status != 0) { + DBG_88E("clnt auth fail, status: %d\n", status); + if (status == 13) { /* pmlmeinfo->auth_algo == dot11AuthAlgrthm_Auto) */ + if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) + pmlmeinfo->auth_algo = dot11AuthAlgrthm_Open; + else + pmlmeinfo->auth_algo = dot11AuthAlgrthm_Shared; + } + + set_link_timer(pmlmeext, 1); + goto authclnt_fail; + } + + if (seq == 2) { + if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) { + /* legendary shared system */ + p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + _AUTH_IE_OFFSET_, _CHLGETXT_IE_, (int *)&len, + pkt_len - WLAN_HDR_A3_LEN - _AUTH_IE_OFFSET_); + + if (p == NULL) + goto authclnt_fail; + + memcpy((void *)(pmlmeinfo->chg_txt), (void *)(p + 2), len); + pmlmeinfo->auth_seq = 3; + issue_auth(padapter, NULL, 0); + set_link_timer(pmlmeext, REAUTH_TO); + + return _SUCCESS; + } else { + /* open system */ + go2asoc = 1; + } + } else if (seq == 4) { + if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) + go2asoc = 1; + else + goto authclnt_fail; + } else { + /* this is also illegal */ + goto authclnt_fail; + } + + if (go2asoc) { + DBG_88E_LEVEL(_drv_info_, "auth success, start assoc\n"); + start_clnt_assoc(padapter); + return _SUCCESS; + } +authclnt_fail: + return _FAIL; +} + +unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) +{ +#ifdef CONFIG_88EU_AP_MODE + unsigned long irqL; + u16 capab_info; + struct rtw_ieee802_11_elems elems; + struct sta_info *pstat; + unsigned char reassoc, *p, *pos, *wpa_ie; + unsigned char WMM_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01}; + int i, ie_len, wpa_ie_len, left; + unsigned char supportRate[16]; + int supportRateNum; + unsigned short status = _STATS_SUCCESSFUL_; + unsigned short frame_type, ie_offset = 0; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct security_priv *psecuritypriv = &padapter->securitypriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *cur = &(pmlmeinfo->network); + struct sta_priv *pstapriv = &padapter->stapriv; + u8 *pframe = precv_frame->u.hdr.rx_data; + uint pkt_len = precv_frame->u.hdr.len; +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + u8 p2p_status_code = P2P_STATUS_SUCCESS; + u8 *p2pie; + u32 p2pielen = 0; +#endif /* CONFIG_88EU_P2P */ + + if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) + return _FAIL; + + frame_type = GetFrameSubType(pframe); + if (frame_type == WIFI_ASSOCREQ) { + reassoc = 0; + ie_offset = _ASOCREQ_IE_OFFSET_; + } else { /* WIFI_REASSOCREQ */ + reassoc = 1; + ie_offset = _REASOCREQ_IE_OFFSET_; + } + + + if (pkt_len < IEEE80211_3ADDR_LEN + ie_offset) { + DBG_88E("handle_assoc(reassoc=%d) - too short payload (len=%lu)" + "\n", reassoc, (unsigned long)pkt_len); + return _FAIL; + } + + pstat = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); + if (pstat == (struct sta_info *)NULL) { + status = _RSON_CLS2_; + goto asoc_class2_error; + } + + capab_info = RTW_GET_LE16(pframe + WLAN_HDR_A3_LEN); + + left = pkt_len - (IEEE80211_3ADDR_LEN + ie_offset); + pos = pframe + (IEEE80211_3ADDR_LEN + ie_offset); + + + DBG_88E("%s\n", __func__); + + /* check if this stat has been successfully authenticated/assocated */ + if (!((pstat->state) & WIFI_FW_AUTH_SUCCESS)) { + if (!((pstat->state) & WIFI_FW_ASSOC_SUCCESS)) { + status = _RSON_CLS2_; + goto asoc_class2_error; + } else { + pstat->state &= (~WIFI_FW_ASSOC_SUCCESS); + pstat->state |= WIFI_FW_ASSOC_STATE; + } + } else { + pstat->state &= (~WIFI_FW_AUTH_SUCCESS); + pstat->state |= WIFI_FW_ASSOC_STATE; + } + pstat->capability = capab_info; + /* now parse all ieee802_11 ie to point to elems */ + if (rtw_ieee802_11_parse_elems(pos, left, &elems, 1) == ParseFailed || + !elems.ssid) { + DBG_88E("STA %pM sent invalid association request\n", + pstat->hwaddr); + status = _STATS_FAILURE_; + goto OnAssocReqFail; + } + + + /* now we should check all the fields... */ + /* checking SSID */ + p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, _SSID_IE_, &ie_len, + pkt_len - WLAN_HDR_A3_LEN - ie_offset); + if (p == NULL) + status = _STATS_FAILURE_; + + if (ie_len == 0) { /* broadcast ssid, however it is not allowed in assocreq */ + status = _STATS_FAILURE_; + } else { + /* check if ssid match */ + if (!_rtw_memcmp((void *)(p+2), cur->Ssid.Ssid, cur->Ssid.SsidLength)) + status = _STATS_FAILURE_; + + if (ie_len != cur->Ssid.SsidLength) + status = _STATS_FAILURE_; + } + + if (_STATS_SUCCESSFUL_ != status) + goto OnAssocReqFail; + + /* check if the supported rate is ok */ + p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, _SUPPORTEDRATES_IE_, &ie_len, pkt_len - WLAN_HDR_A3_LEN - ie_offset); + if (p == NULL) { + DBG_88E("Rx a sta assoc-req which supported rate is empty!\n"); + /* use our own rate set as statoin used */ + /* memcpy(supportRate, AP_BSSRATE, AP_BSSRATE_LEN); */ + /* supportRateNum = AP_BSSRATE_LEN; */ + + status = _STATS_FAILURE_; + goto OnAssocReqFail; + } else { + memcpy(supportRate, p+2, ie_len); + supportRateNum = ie_len; + + p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, _EXT_SUPPORTEDRATES_IE_ , &ie_len, + pkt_len - WLAN_HDR_A3_LEN - ie_offset); + if (p != NULL) { + if (supportRateNum <= sizeof(supportRate)) { + memcpy(supportRate+supportRateNum, p+2, ie_len); + supportRateNum += ie_len; + } + } + } + + /* todo: mask supportRate between AP & STA -> move to update raid */ + /* get_matched_rate(pmlmeext, supportRate, &supportRateNum, 0); */ + + /* update station supportRate */ + pstat->bssratelen = supportRateNum; + memcpy(pstat->bssrateset, supportRate, supportRateNum); + UpdateBrateTblForSoftAP(pstat->bssrateset, pstat->bssratelen); + + /* check RSN/WPA/WPS */ + pstat->dot8021xalg = 0; + pstat->wpa_psk = 0; + pstat->wpa_group_cipher = 0; + pstat->wpa2_group_cipher = 0; + pstat->wpa_pairwise_cipher = 0; + pstat->wpa2_pairwise_cipher = 0; + _rtw_memset(pstat->wpa_ie, 0, sizeof(pstat->wpa_ie)); + if ((psecuritypriv->wpa_psk & BIT(1)) && elems.rsn_ie) { + int group_cipher = 0, pairwise_cipher = 0; + + wpa_ie = elems.rsn_ie; + wpa_ie_len = elems.rsn_ie_len; + + if (rtw_parse_wpa2_ie(wpa_ie-2, wpa_ie_len+2, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) { + pstat->dot8021xalg = 1;/* psk, todo:802.1x */ + pstat->wpa_psk |= BIT(1); + + pstat->wpa2_group_cipher = group_cipher&psecuritypriv->wpa2_group_cipher; + pstat->wpa2_pairwise_cipher = pairwise_cipher&psecuritypriv->wpa2_pairwise_cipher; + + if (!pstat->wpa2_group_cipher) + status = WLAN_STATUS_GROUP_CIPHER_NOT_VALID; + + if (!pstat->wpa2_pairwise_cipher) + status = WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID; + } else { + status = WLAN_STATUS_INVALID_IE; + } + } else if ((psecuritypriv->wpa_psk & BIT(0)) && elems.wpa_ie) { + int group_cipher = 0, pairwise_cipher = 0; + + wpa_ie = elems.wpa_ie; + wpa_ie_len = elems.wpa_ie_len; + + if (rtw_parse_wpa_ie(wpa_ie-2, wpa_ie_len+2, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) { + pstat->dot8021xalg = 1;/* psk, todo:802.1x */ + pstat->wpa_psk |= BIT(0); + + pstat->wpa_group_cipher = group_cipher&psecuritypriv->wpa_group_cipher; + pstat->wpa_pairwise_cipher = pairwise_cipher&psecuritypriv->wpa_pairwise_cipher; + + if (!pstat->wpa_group_cipher) + status = WLAN_STATUS_GROUP_CIPHER_NOT_VALID; + + if (!pstat->wpa_pairwise_cipher) + status = WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID; + } else { + status = WLAN_STATUS_INVALID_IE; + } + } else { + wpa_ie = NULL; + wpa_ie_len = 0; + } + + if (_STATS_SUCCESSFUL_ != status) + goto OnAssocReqFail; + + pstat->flags &= ~(WLAN_STA_WPS | WLAN_STA_MAYBE_WPS); + if (wpa_ie == NULL) { + if (elems.wps_ie) { + DBG_88E("STA included WPS IE in " + "(Re)Association Request - assume WPS is " + "used\n"); + pstat->flags |= WLAN_STA_WPS; + /* wpabuf_free(sta->wps_ie); */ + /* sta->wps_ie = wpabuf_alloc_copy(elems.wps_ie + 4, */ + /* elems.wps_ie_len - 4); */ + } else { + DBG_88E("STA did not include WPA/RSN IE " + "in (Re)Association Request - possible WPS " + "use\n"); + pstat->flags |= WLAN_STA_MAYBE_WPS; + } + + + /* AP support WPA/RSN, and sta is going to do WPS, but AP is not ready */ + /* that the selected registrar of AP is _FLASE */ + if ((psecuritypriv->wpa_psk > 0) && (pstat->flags & (WLAN_STA_WPS|WLAN_STA_MAYBE_WPS))) { + if (pmlmepriv->wps_beacon_ie) { + u8 selected_registrar = 0; + + rtw_get_wps_attr_content(pmlmepriv->wps_beacon_ie, pmlmepriv->wps_beacon_ie_len, WPS_ATTR_SELECTED_REGISTRAR , &selected_registrar, NULL); + + if (!selected_registrar) { + DBG_88E("selected_registrar is false , or AP is not ready to do WPS\n"); + + status = _STATS_UNABLE_HANDLE_STA_; + + goto OnAssocReqFail; + } + } + } + } else { + int copy_len; + + if (psecuritypriv->wpa_psk == 0) { + DBG_88E("STA %pM: WPA/RSN IE in association " + "request, but AP don't support WPA/RSN\n", pstat->hwaddr); + + status = WLAN_STATUS_INVALID_IE; + + goto OnAssocReqFail; + } + + if (elems.wps_ie) { + DBG_88E("STA included WPS IE in " + "(Re)Association Request - WPS is " + "used\n"); + pstat->flags |= WLAN_STA_WPS; + copy_len = 0; + } else { + copy_len = ((wpa_ie_len+2) > sizeof(pstat->wpa_ie)) ? (sizeof(pstat->wpa_ie)) : (wpa_ie_len+2); + } + if (copy_len > 0) + memcpy(pstat->wpa_ie, wpa_ie-2, copy_len); + } + /* check if there is WMM IE & support WWM-PS */ + pstat->flags &= ~WLAN_STA_WME; + pstat->qos_option = 0; + pstat->qos_info = 0; + pstat->has_legacy_ac = true; + pstat->uapsd_vo = 0; + pstat->uapsd_vi = 0; + pstat->uapsd_be = 0; + pstat->uapsd_bk = 0; + if (pmlmepriv->qospriv.qos_option) { + p = pframe + WLAN_HDR_A3_LEN + ie_offset; ie_len = 0; + for (;;) { + p = rtw_get_ie(p, _VENDOR_SPECIFIC_IE_, &ie_len, pkt_len - WLAN_HDR_A3_LEN - ie_offset); + if (p != NULL) { + if (_rtw_memcmp(p+2, WMM_IE, 6)) { + pstat->flags |= WLAN_STA_WME; + + pstat->qos_option = 1; + pstat->qos_info = *(p+8); + + pstat->max_sp_len = (pstat->qos_info>>5)&0x3; + + if ((pstat->qos_info&0xf) != 0xf) + pstat->has_legacy_ac = true; + else + pstat->has_legacy_ac = false; + + if (pstat->qos_info&0xf) { + if (pstat->qos_info&BIT(0)) + pstat->uapsd_vo = BIT(0)|BIT(1); + else + pstat->uapsd_vo = 0; + + if (pstat->qos_info&BIT(1)) + pstat->uapsd_vi = BIT(0)|BIT(1); + else + pstat->uapsd_vi = 0; + + if (pstat->qos_info&BIT(2)) + pstat->uapsd_bk = BIT(0)|BIT(1); + else + pstat->uapsd_bk = 0; + + if (pstat->qos_info&BIT(3)) + pstat->uapsd_be = BIT(0)|BIT(1); + else + pstat->uapsd_be = 0; + } + break; + } + } else { + break; + } + p = p + ie_len + 2; + } + } + + /* save HT capabilities in the sta object */ + _rtw_memset(&pstat->htpriv.ht_cap, 0, sizeof(struct rtw_ieee80211_ht_cap)); + if (elems.ht_capabilities && elems.ht_capabilities_len >= sizeof(struct rtw_ieee80211_ht_cap)) { + pstat->flags |= WLAN_STA_HT; + + pstat->flags |= WLAN_STA_WME; + + memcpy(&pstat->htpriv.ht_cap, elems.ht_capabilities, sizeof(struct rtw_ieee80211_ht_cap)); + } else { + pstat->flags &= ~WLAN_STA_HT; + } + if ((!pmlmepriv->htpriv.ht_option) && (pstat->flags&WLAN_STA_HT)) { + status = _STATS_FAILURE_; + goto OnAssocReqFail; + } + + if ((pstat->flags & WLAN_STA_HT) && + ((pstat->wpa2_pairwise_cipher&WPA_CIPHER_TKIP) || + (pstat->wpa_pairwise_cipher&WPA_CIPHER_TKIP))) { + DBG_88E("HT: %pM tried to " + "use TKIP with HT association\n", pstat->hwaddr); + + /* status = WLAN_STATUS_CIPHER_REJECTED_PER_POLICY; */ + /* goto OnAssocReqFail; */ + } + + pstat->flags |= WLAN_STA_NONERP; + for (i = 0; i < pstat->bssratelen; i++) { + if ((pstat->bssrateset[i] & 0x7f) > 22) { + pstat->flags &= ~WLAN_STA_NONERP; + break; + } + } + + if (pstat->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) + pstat->flags |= WLAN_STA_SHORT_PREAMBLE; + else + pstat->flags &= ~WLAN_STA_SHORT_PREAMBLE; + + + + if (status != _STATS_SUCCESSFUL_) + goto OnAssocReqFail; + +#ifdef CONFIG_88EU_P2P + pstat->is_p2p_device = false; + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { + p2pie = rtw_get_p2p_ie(pframe + WLAN_HDR_A3_LEN + ie_offset , pkt_len - WLAN_HDR_A3_LEN - ie_offset , NULL, &p2pielen); + if (p2pie) { + pstat->is_p2p_device = true; + p2p_status_code = (u8)process_assoc_req_p2p_ie(pwdinfo, pframe, pkt_len, pstat); + if (p2p_status_code > 0) { + pstat->p2p_status_code = p2p_status_code; + status = _STATS_CAP_FAIL_; + goto OnAssocReqFail; + } + } + } + pstat->p2p_status_code = p2p_status_code; +#endif /* CONFIG_88EU_P2P */ + + /* TODO: identify_proprietary_vendor_ie(); */ + /* Realtek proprietary IE */ + /* identify if this is Broadcom sta */ + /* identify if this is ralink sta */ + /* Customer proprietary IE */ + + /* get a unique AID */ + if (pstat->aid > 0) { + DBG_88E(" old AID %d\n", pstat->aid); + } else { + for (pstat->aid = 1; pstat->aid <= NUM_STA; pstat->aid++) + if (pstapriv->sta_aid[pstat->aid - 1] == NULL) + break; + + /* if (pstat->aid > NUM_STA) { */ + if (pstat->aid > pstapriv->max_num_sta) { + pstat->aid = 0; + + DBG_88E(" no room for more AIDs\n"); + + status = WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA; + + goto OnAssocReqFail; + } else { + pstapriv->sta_aid[pstat->aid - 1] = pstat; + DBG_88E("allocate new AID=(%d)\n", pstat->aid); + } + } + + pstat->state &= (~WIFI_FW_ASSOC_STATE); + pstat->state |= WIFI_FW_ASSOC_SUCCESS; + + _enter_critical_bh(&pstapriv->auth_list_lock, &irqL); + if (!rtw_is_list_empty(&pstat->auth_list)) { + rtw_list_delete(&pstat->auth_list); + pstapriv->auth_list_cnt--; + } + _exit_critical_bh(&pstapriv->auth_list_lock, &irqL); + + _enter_critical_bh(&pstapriv->asoc_list_lock, &irqL); + if (rtw_is_list_empty(&pstat->asoc_list)) { + pstat->expire_to = pstapriv->expire_to; + rtw_list_insert_tail(&pstat->asoc_list, &pstapriv->asoc_list); + pstapriv->asoc_list_cnt++; + } + _exit_critical_bh(&pstapriv->asoc_list_lock, &irqL); + + /* now the station is qualified to join our BSS... */ + if (pstat && (pstat->state & WIFI_FW_ASSOC_SUCCESS) && (_STATS_SUCCESSFUL_ == status)) { +#ifdef CONFIG_88EU_AP_MODE + /* 1 bss_cap_update & sta_info_update */ + bss_cap_update_on_sta_join(padapter, pstat); + sta_info_update(padapter, pstat); + + /* issue assoc rsp before notify station join event. */ + if (frame_type == WIFI_ASSOCREQ) + issue_asocrsp(padapter, status, pstat, WIFI_ASSOCRSP); + else + issue_asocrsp(padapter, status, pstat, WIFI_REASSOCRSP); + + /* 2 - report to upper layer */ + DBG_88E("indicate_sta_join_event to upper layer - hostapd\n"); + rtw_indicate_sta_assoc_event(padapter, pstat); + + /* 3-(1) report sta add event */ + report_add_sta_event(padapter, pstat->hwaddr, pstat->aid); +#endif + } + + return _SUCCESS; + +asoc_class2_error: + +#ifdef CONFIG_88EU_AP_MODE + issue_deauth(padapter, (void *)GetAddr2Ptr(pframe), status); +#endif + + return _FAIL; + +OnAssocReqFail: + + +#ifdef CONFIG_88EU_AP_MODE + pstat->aid = 0; + if (frame_type == WIFI_ASSOCREQ) + issue_asocrsp(padapter, status, pstat, WIFI_ASSOCRSP); + else + issue_asocrsp(padapter, status, pstat, WIFI_REASSOCRSP); +#endif + + +#endif /* CONFIG_88EU_AP_MODE */ + + return _FAIL; +} + +unsigned int OnAssocRsp(struct adapter *padapter, union recv_frame *precv_frame) +{ + uint i; + int res; + unsigned short status; + struct ndis_802_11_var_ie *pIE; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + /* struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); */ + u8 *pframe = precv_frame->u.hdr.rx_data; + uint pkt_len = precv_frame->u.hdr.len; + + DBG_88E("%s\n", __func__); + + /* check A1 matches or not */ + if (!_rtw_memcmp(myid(&(padapter->eeprompriv)), get_da(pframe), ETH_ALEN)) + return _SUCCESS; + + if (!(pmlmeinfo->state & (WIFI_FW_AUTH_SUCCESS | WIFI_FW_ASSOC_STATE))) + return _SUCCESS; + + if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) + return _SUCCESS; + + _cancel_timer_ex(&pmlmeext->link_timer); + + /* status */ + status = le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN + 2)); + if (status > 0) { + DBG_88E("assoc reject, status code: %d\n", status); + pmlmeinfo->state = WIFI_FW_NULL_STATE; + res = -4; + goto report_assoc_result; + } + + /* get capabilities */ + pmlmeinfo->capability = le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN)); + + /* set slot time */ + pmlmeinfo->slotTime = (pmlmeinfo->capability & BIT(10)) ? 9 : 20; + + /* AID */ + pmlmeinfo->aid = (int)(le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN + 4))&0x3fff); + res = pmlmeinfo->aid; + + /* following are moved to join event callback function */ + /* to handle HT, WMM, rate adaptive, update MAC reg */ + /* for not to handle the synchronous IO in the tasklet */ + for (i = (6 + WLAN_HDR_A3_LEN); i < pkt_len;) { + pIE = (struct ndis_802_11_var_ie *)(pframe + i); + + switch (pIE->ElementID) { + case _VENDOR_SPECIFIC_IE_: + if (_rtw_memcmp(pIE->data, WMM_PARA_OUI, 6)) /* WMM */ + WMM_param_handler(padapter, pIE); + break; + case _HT_CAPABILITY_IE_: /* HT caps */ + HT_caps_handler(padapter, pIE); + break; + case _HT_EXTRA_INFO_IE_: /* HT info */ + HT_info_handler(padapter, pIE); + break; + case _ERPINFO_IE_: + ERP_IE_handler(padapter, pIE); + default: + break; + } + + i += (pIE->Length + 2); + } + + pmlmeinfo->state &= (~WIFI_FW_ASSOC_STATE); + pmlmeinfo->state |= WIFI_FW_ASSOC_SUCCESS; + + /* Update Basic Rate Table for spec, 2010-12-28 , by thomas */ + UpdateBrateTbl(padapter, pmlmeinfo->network.SupportedRates); + +report_assoc_result: + if (res > 0) { + rtw_buf_update(&pmlmepriv->assoc_rsp, &pmlmepriv->assoc_rsp_len, pframe, pkt_len); + } else { + rtw_buf_free(&pmlmepriv->assoc_rsp, &pmlmepriv->assoc_rsp_len); + } + + report_join_res(padapter, res); + + return _SUCCESS; +} + +unsigned int OnDeAuth(struct adapter *padapter, union recv_frame *precv_frame) +{ + unsigned short reason; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + u8 *pframe = precv_frame->u.hdr.rx_data; +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); +#endif /* CONFIG_88EU_P2P */ + + /* check A3 */ + if (!(_rtw_memcmp(GetAddr3Ptr(pframe), get_my_bssid(&pmlmeinfo->network), ETH_ALEN))) + return _SUCCESS; + +#ifdef CONFIG_88EU_P2P + if (pwdinfo->rx_invitereq_info.scan_op_ch_only) { + _cancel_timer_ex(&pwdinfo->reset_ch_sitesurvey); + _set_timer(&pwdinfo->reset_ch_sitesurvey, 10); + } +#endif /* CONFIG_88EU_P2P */ + + reason = le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN)); + + DBG_88E("%s Reason code(%d)\n", __func__, reason); + +#ifdef CONFIG_88EU_AP_MODE + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { + unsigned long irqL; + struct sta_info *psta; + struct sta_priv *pstapriv = &padapter->stapriv; + + DBG_88E_LEVEL(_drv_always_, "ap recv deauth reason code(%d) sta:%pM\n", + reason, GetAddr2Ptr(pframe)); + + psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); + if (psta) { + u8 updated = 0; + + _enter_critical_bh(&pstapriv->asoc_list_lock, &irqL); + if (!rtw_is_list_empty(&psta->asoc_list)) { + rtw_list_delete(&psta->asoc_list); + pstapriv->asoc_list_cnt--; + updated = ap_free_sta(padapter, psta, false, reason); + } + _exit_critical_bh(&pstapriv->asoc_list_lock, &irqL); + + associated_clients_update(padapter, updated); + } + + + return _SUCCESS; + } else +#endif + { + DBG_88E_LEVEL(_drv_always_, "sta recv deauth reason code(%d) sta:%pM\n", + reason, GetAddr3Ptr(pframe)); + + receive_disconnect(padapter, GetAddr3Ptr(pframe) , reason); + } + pmlmepriv->LinkDetectInfo.bBusyTraffic = false; + return _SUCCESS; +} + +unsigned int OnDisassoc(struct adapter *padapter, union recv_frame *precv_frame) +{ + u16 reason; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + u8 *pframe = precv_frame->u.hdr.rx_data; +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); +#endif /* CONFIG_88EU_P2P */ + + /* check A3 */ + if (!(_rtw_memcmp(GetAddr3Ptr(pframe), get_my_bssid(&pmlmeinfo->network), ETH_ALEN))) + return _SUCCESS; + +#ifdef CONFIG_88EU_P2P + if (pwdinfo->rx_invitereq_info.scan_op_ch_only) { + _cancel_timer_ex(&pwdinfo->reset_ch_sitesurvey); + _set_timer(&pwdinfo->reset_ch_sitesurvey, 10); + } +#endif /* CONFIG_88EU_P2P */ + + reason = le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN)); + + DBG_88E("%s Reason code(%d)\n", __func__, reason); + +#ifdef CONFIG_88EU_AP_MODE + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { + unsigned long irqL; + struct sta_info *psta; + struct sta_priv *pstapriv = &padapter->stapriv; + + /* _enter_critical_bh(&(pstapriv->sta_hash_lock), &irqL); */ + /* rtw_free_stainfo(padapter, psta); */ + /* _exit_critical_bh(&(pstapriv->sta_hash_lock), &irqL); */ + + DBG_88E_LEVEL(_drv_always_, "ap recv disassoc reason code(%d) sta:%pM\n", + reason, GetAddr2Ptr(pframe)); + + psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); + if (psta) { + u8 updated = 0; + + _enter_critical_bh(&pstapriv->asoc_list_lock, &irqL); + if (!rtw_is_list_empty(&psta->asoc_list)) { + rtw_list_delete(&psta->asoc_list); + pstapriv->asoc_list_cnt--; + updated = ap_free_sta(padapter, psta, false, reason); + } + _exit_critical_bh(&pstapriv->asoc_list_lock, &irqL); + + associated_clients_update(padapter, updated); + } + + return _SUCCESS; + } else +#endif + { + DBG_88E_LEVEL(_drv_always_, "ap recv disassoc reason code(%d) sta:%pM\n", + reason, GetAddr3Ptr(pframe)); + + receive_disconnect(padapter, GetAddr3Ptr(pframe), reason); + } + pmlmepriv->LinkDetectInfo.bBusyTraffic = false; + return _SUCCESS; +} + +unsigned int OnAtim(struct adapter *padapter, union recv_frame *precv_frame) +{ + DBG_88E("%s\n", __func__); + return _SUCCESS; +} + +unsigned int on_action_spct(struct adapter *padapter, union recv_frame *precv_frame) +{ + unsigned int ret = _FAIL; + struct sta_info *psta = NULL; + struct sta_priv *pstapriv = &padapter->stapriv; + u8 *pframe = precv_frame->u.hdr.rx_data; + u8 *frame_body = (u8 *)(pframe + sizeof(struct rtw_ieee80211_hdr_3addr)); + u8 category; + u8 action; + + DBG_88E(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(padapter->pnetdev)); + + psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); + + if (!psta) + goto exit; + + category = frame_body[0]; + if (category != RTW_WLAN_CATEGORY_SPECTRUM_MGMT) + goto exit; + + action = frame_body[1]; + switch (action) { + case RTW_WLAN_ACTION_SPCT_MSR_REQ: + case RTW_WLAN_ACTION_SPCT_MSR_RPRT: + case RTW_WLAN_ACTION_SPCT_TPC_REQ: + case RTW_WLAN_ACTION_SPCT_TPC_RPRT: + break; + case RTW_WLAN_ACTION_SPCT_CHL_SWITCH: + break; + default: + break; + } + +exit: + return ret; +} + +unsigned int OnAction_qos(struct adapter *padapter, union recv_frame *precv_frame) +{ + return _SUCCESS; +} + +unsigned int OnAction_dls(struct adapter *padapter, union recv_frame *precv_frame) +{ + return _SUCCESS; +} + +unsigned int OnAction_back(struct adapter *padapter, union recv_frame *precv_frame) +{ + u8 *addr; + struct sta_info *psta = NULL; + struct recv_reorder_ctrl *preorder_ctrl; + unsigned char *frame_body; + unsigned char category, action; + unsigned short tid, status, reason_code = 0; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + u8 *pframe = precv_frame->u.hdr.rx_data; + struct sta_priv *pstapriv = &padapter->stapriv; + /* check RA matches or not */ + if (!_rtw_memcmp(myid(&(padapter->eeprompriv)), GetAddr1Ptr(pframe), ETH_ALEN))/* for if1, sta/ap mode */ + return _SUCCESS; + + DBG_88E("%s\n", __func__); + + if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) + if (!(pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) + return _SUCCESS; + + addr = GetAddr2Ptr(pframe); + psta = rtw_get_stainfo(pstapriv, addr); + + if (psta == NULL) + return _SUCCESS; + + frame_body = (unsigned char *)(pframe + sizeof(struct rtw_ieee80211_hdr_3addr)); + + category = frame_body[0]; + if (category == RTW_WLAN_CATEGORY_BACK) { /* representing Block Ack */ + if (!pmlmeinfo->HT_enable) + return _SUCCESS; + action = frame_body[1]; + DBG_88E("%s, action=%d\n", __func__, action); + switch (action) { + case RTW_WLAN_ACTION_ADDBA_REQ: /* ADDBA request */ + memcpy(&(pmlmeinfo->ADDBA_req), &(frame_body[2]), sizeof(struct ADDBA_request)); + process_addba_req(padapter, (u8 *)&(pmlmeinfo->ADDBA_req), addr); + + if (pmlmeinfo->bAcceptAddbaReq) + issue_action_BA(padapter, addr, RTW_WLAN_ACTION_ADDBA_RESP, 0); + else + issue_action_BA(padapter, addr, RTW_WLAN_ACTION_ADDBA_RESP, 37);/* reject ADDBA Req */ + break; + case RTW_WLAN_ACTION_ADDBA_RESP: /* ADDBA response */ + status = RTW_GET_LE16(&frame_body[3]); + tid = ((frame_body[5] >> 2) & 0x7); + if (status == 0) { /* successful */ + DBG_88E("agg_enable for TID=%d\n", tid); + psta->htpriv.agg_enable_bitmap |= 1 << tid; + psta->htpriv.candidate_tid_bitmap &= ~BIT(tid); + } else { + psta->htpriv.agg_enable_bitmap &= ~BIT(tid); + } + break; + case RTW_WLAN_ACTION_DELBA: /* DELBA */ + if ((frame_body[3] & BIT(3)) == 0) { + psta->htpriv.agg_enable_bitmap &= ~(1 << ((frame_body[3] >> 4) & 0xf)); + psta->htpriv.candidate_tid_bitmap &= ~(1 << ((frame_body[3] >> 4) & 0xf)); + reason_code = RTW_GET_LE16(&frame_body[4]); + } else if ((frame_body[3] & BIT(3)) == BIT(3)) { + tid = (frame_body[3] >> 4) & 0x0F; + preorder_ctrl = &psta->recvreorder_ctrl[tid]; + preorder_ctrl->enable = false; + preorder_ctrl->indicate_seq = 0xffff; + } + DBG_88E("%s(): DELBA: %x(%x)\n", __func__, pmlmeinfo->agg_enable_bitmap, reason_code); + /* todo: how to notify the host while receiving DELETE BA */ + break; + default: + break; + } + } + return _SUCCESS; +} + +#ifdef CONFIG_88EU_P2P + +static int get_reg_classes_full_count(struct p2p_channels channel_list) +{ + int cnt = 0; + int i; + + for (i = 0; i < channel_list.reg_classes; i++) { + cnt += channel_list.reg_class[i].channels; + } + + return cnt; +} + +void issue_p2p_GO_request(struct adapter *padapter, u8 *raddr) +{ + unsigned char category = RTW_WLAN_CATEGORY_PUBLIC; + u8 action = P2P_PUB_ACTION_ACTION; + __be32 p2poui = cpu_to_be32(P2POUI); + u8 oui_subtype = P2P_GO_NEGO_REQ; + u8 wpsie[255] = { 0x00 }, p2pie[255] = { 0x00 }; + u8 wpsielen = 0, p2pielen = 0; + u16 len_channellist_attr = 0; + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; + struct rtw_ieee80211_hdr *pwlanhdr; + unsigned short *fctrl; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + return; + + DBG_88E("[%s] In\n", __func__); + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + + _rtw_memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + + memcpy(pwlanhdr->addr1, raddr, ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr3, myid(&(padapter->eeprompriv)), ETH_ALEN); + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + SetFrameSubType(pframe, WIFI_ACTION); + + pframe += sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); + + pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(action), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&(p2poui), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(oui_subtype), &(pattrib->pktlen)); + pwdinfo->negotiation_dialog_token = 1; /* Initialize the dialog value */ + pframe = rtw_set_fixed_ie(pframe, 1, &pwdinfo->negotiation_dialog_token, &(pattrib->pktlen)); + + + + /* WPS Section */ + wpsielen = 0; + /* WPS OUI */ + *(__be32 *)(wpsie) = cpu_to_be32(WPSOUI); + wpsielen += 4; + + /* WPS version */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_VER1); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0001); + wpsielen += 2; + + /* Value: */ + wpsie[wpsielen++] = WPS_VERSION_1; /* Version 1.0 */ + + /* Device Password ID */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_DEVICE_PWID); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0002); + wpsielen += 2; + + /* Value: */ + + if (pwdinfo->ui_got_wps_info == P2P_GOT_WPSINFO_PEER_DISPLAY_PIN) + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_DPID_USER_SPEC); + else if (pwdinfo->ui_got_wps_info == P2P_GOT_WPSINFO_SELF_DISPLAY_PIN) + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_DPID_REGISTRAR_SPEC); + else if (pwdinfo->ui_got_wps_info == P2P_GOT_WPSINFO_PBC) + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_DPID_PBC); + + wpsielen += 2; + + pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, wpsielen, (unsigned char *)wpsie, &pattrib->pktlen); + + + /* P2P IE Section. */ + + /* P2P OUI */ + p2pielen = 0; + p2pie[p2pielen++] = 0x50; + p2pie[p2pielen++] = 0x6F; + p2pie[p2pielen++] = 0x9A; + p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ + + /* Commented by Albert 20110306 */ + /* According to the P2P Specification, the group negoitation request frame should contain 9 P2P attributes */ + /* 1. P2P Capability */ + /* 2. Group Owner Intent */ + /* 3. Configuration Timeout */ + /* 4. Listen Channel */ + /* 5. Extended Listen Timing */ + /* 6. Intended P2P Interface Address */ + /* 7. Channel List */ + /* 8. P2P Device Info */ + /* 9. Operating Channel */ + + + /* P2P Capability */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_CAPABILITY; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0002); + p2pielen += 2; + + /* Value: */ + /* Device Capability Bitmap, 1 byte */ + p2pie[p2pielen++] = DMP_P2P_DEVCAP_SUPPORT; + + /* Group Capability Bitmap, 1 byte */ + if (pwdinfo->persistent_supported) + p2pie[p2pielen++] = P2P_GRPCAP_CROSS_CONN | P2P_GRPCAP_PERSISTENT_GROUP; + else + p2pie[p2pielen++] = P2P_GRPCAP_CROSS_CONN; + + /* Group Owner Intent */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_GO_INTENT; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0001); + p2pielen += 2; + + /* Value: */ + /* Todo the tie breaker bit. */ + p2pie[p2pielen++] = ((pwdinfo->intent << 1) | BIT(0)); + + /* Configuration Timeout */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_CONF_TIMEOUT; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0002); + p2pielen += 2; + + /* Value: */ + p2pie[p2pielen++] = 200; /* 2 seconds needed to be the P2P GO */ + p2pie[p2pielen++] = 200; /* 2 seconds needed to be the P2P Client */ + + + /* Listen Channel */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_LISTEN_CH; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0005); + p2pielen += 2; + + /* Value: */ + /* Country String */ + p2pie[p2pielen++] = 'X'; + p2pie[p2pielen++] = 'X'; + + /* The third byte should be set to 0x04. */ + /* Described in the "Operating Channel Attribute" section. */ + p2pie[p2pielen++] = 0x04; + + /* Operating Class */ + p2pie[p2pielen++] = 0x51; /* Copy from SD7 */ + + /* Channel Number */ + p2pie[p2pielen++] = pwdinfo->listen_channel; /* listening channel number */ + + + /* Extended Listen Timing ATTR */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_EX_LISTEN_TIMING; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0004); + p2pielen += 2; + + /* Value: */ + /* Availability Period */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0xFFFF); + p2pielen += 2; + + /* Availability Interval */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0xFFFF); + p2pielen += 2; + + + /* Intended P2P Interface Address */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_INTENTED_IF_ADDR; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(ETH_ALEN); + p2pielen += 2; + + /* Value: */ + memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv), ETH_ALEN); + p2pielen += ETH_ALEN; + + + /* Channel List */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_CH_LIST; + + /* Length: */ + /* Country String(3) */ + /* + (Operating Class (1) + Number of Channels(1)) * Operation Classes (?) */ + /* + number of channels in all classes */ + len_channellist_attr = 3 + + (1 + 1) * (u16)(pmlmeext->channel_list.reg_classes) + + get_reg_classes_full_count(pmlmeext->channel_list); + + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(len_channellist_attr); + p2pielen += 2; + + /* Value: */ + /* Country String */ + p2pie[p2pielen++] = 'X'; + p2pie[p2pielen++] = 'X'; + + /* The third byte should be set to 0x04. */ + /* Described in the "Operating Channel Attribute" section. */ + p2pie[p2pielen++] = 0x04; + + /* Channel Entry List */ + + { + int i, j; + for (j = 0; j < pmlmeext->channel_list.reg_classes; j++) { + /* Operating Class */ + p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].reg_class; + + /* Number of Channels */ + p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].channels; + + /* Channel List */ + for (i = 0; i < pmlmeext->channel_list.reg_class[j].channels; i++) { + p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].channel[i]; + } + } + } + + /* Device Info */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_DEVICE_INFO; + + /* Length: */ + /* 21 -> P2P Device Address (6bytes) + Config Methods (2bytes) + Primary Device Type (8bytes) */ + /* + NumofSecondDevType (1byte) + WPS Device Name ID field (2bytes) + WPS Device Name Len field (2bytes) */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(21 + pwdinfo->device_name_len); + p2pielen += 2; + + /* Value: */ + /* P2P Device Address */ + memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv), ETH_ALEN); + p2pielen += ETH_ALEN; + + /* Config Method */ + /* This field should be big endian. Noted by P2P specification. */ + + *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(pwdinfo->supported_wps_cm); + + p2pielen += 2; + + /* Primary Device Type */ + /* Category ID */ + *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); + p2pielen += 2; + + /* OUI */ + *(__be32 *)(p2pie + p2pielen) = cpu_to_be32(WPSOUI); + p2pielen += 4; + + /* Sub Category ID */ + *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); + p2pielen += 2; + + /* Number of Secondary Device Types */ + p2pie[p2pielen++] = 0x00; /* No Secondary Device Type List */ + + /* Device Name */ + /* Type: */ + *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); + p2pielen += 2; + + /* Length: */ + *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(pwdinfo->device_name_len); + p2pielen += 2; + + /* Value: */ + memcpy(p2pie + p2pielen, pwdinfo->device_name , pwdinfo->device_name_len); + p2pielen += pwdinfo->device_name_len; + + + /* Operating Channel */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_OPERATING_CH; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0005); + p2pielen += 2; + + /* Value: */ + /* Country String */ + p2pie[p2pielen++] = 'X'; + p2pie[p2pielen++] = 'X'; + + /* The third byte should be set to 0x04. */ + /* Described in the "Operating Channel Attribute" section. */ + p2pie[p2pielen++] = 0x04; + + /* Operating Class */ + p2pie[p2pielen++] = 0x51; + + /* Channel Number */ + p2pie[p2pielen++] = pwdinfo->operating_channel; /* operating channel number */ + + pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &pattrib->pktlen); + + pattrib->last_txcmdsz = pattrib->pktlen; + + dump_mgntframe(padapter, pmgntframe); + + return; +} + +static void issue_p2p_GO_response(struct adapter *padapter, u8 *raddr, u8 *frame_body, uint len, u8 result) +{ + unsigned char category = RTW_WLAN_CATEGORY_PUBLIC; + u8 action = P2P_PUB_ACTION_ACTION; + __be32 p2poui = cpu_to_be32(P2POUI); + u8 oui_subtype = P2P_GO_NEGO_RESP; + u8 wpsie[255] = { 0x00 }, p2pie[255] = { 0x00 }; + u8 p2pielen = 0; + uint wpsielen = 0; + u16 wps_devicepassword_id = 0x0000; + __be16 be_tmp; + uint wps_devicepassword_id_len = 0; + u16 len_channellist_attr = 0; + + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; + struct rtw_ieee80211_hdr *pwlanhdr; + unsigned short *fctrl; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + return; + + DBG_88E("[%s] In, result=%d\n", __func__, result); + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + + _rtw_memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + + memcpy(pwlanhdr->addr1, raddr, ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr3, myid(&(padapter->eeprompriv)), ETH_ALEN); + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + SetFrameSubType(pframe, WIFI_ACTION); + + pframe += sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); + + pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(action), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&(p2poui), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(oui_subtype), &(pattrib->pktlen)); + pwdinfo->negotiation_dialog_token = frame_body[7]; /* The Dialog Token of provisioning discovery request frame. */ + pframe = rtw_set_fixed_ie(pframe, 1, &(pwdinfo->negotiation_dialog_token), &(pattrib->pktlen)); + + /* Commented by Albert 20110328 */ + /* Try to get the device password ID from the WPS IE of group negotiation request frame */ + /* WiFi Direct test plan 5.1.15 */ + rtw_get_wps_ie(frame_body + _PUBLIC_ACTION_IE_OFFSET_, len - _PUBLIC_ACTION_IE_OFFSET_, wpsie, &wpsielen); + rtw_get_wps_attr_content(wpsie, wpsielen, WPS_ATTR_DEVICE_PWID, (u8 *)&be_tmp, &wps_devicepassword_id_len); + wps_devicepassword_id = be16_to_cpu(be_tmp); + + _rtw_memset(wpsie, 0x00, 255); + wpsielen = 0; + + /* WPS Section */ + wpsielen = 0; + /* WPS OUI */ + *(__be32 *)(wpsie) = cpu_to_be32(WPSOUI); + wpsielen += 4; + + /* WPS version */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_VER1); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0001); + wpsielen += 2; + + /* Value: */ + wpsie[wpsielen++] = WPS_VERSION_1; /* Version 1.0 */ + + /* Device Password ID */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_DEVICE_PWID); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0002); + wpsielen += 2; + + /* Value: */ + if (wps_devicepassword_id == WPS_DPID_USER_SPEC) + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_DPID_REGISTRAR_SPEC); + else if (wps_devicepassword_id == WPS_DPID_REGISTRAR_SPEC) + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_DPID_USER_SPEC); + else + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_DPID_PBC); + wpsielen += 2; + + /* Commented by Kurt 20120113 */ + /* If some device wants to do p2p handshake without sending prov_disc_req */ + /* We have to get peer_req_cm from here. */ + if (_rtw_memcmp(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "000", 3)) { + if (wps_devicepassword_id == WPS_DPID_USER_SPEC) + memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "dis", 3); + else if (wps_devicepassword_id == WPS_DPID_REGISTRAR_SPEC) + memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "pad", 3); + else + memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "pbc", 3); + } + + pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, wpsielen, (unsigned char *)wpsie, &pattrib->pktlen); + + + /* P2P IE Section. */ + + /* P2P OUI */ + p2pielen = 0; + p2pie[p2pielen++] = 0x50; + p2pie[p2pielen++] = 0x6F; + p2pie[p2pielen++] = 0x9A; + p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ + + /* Commented by Albert 20100908 */ + /* According to the P2P Specification, the group negoitation response frame should contain 9 P2P attributes */ + /* 1. Status */ + /* 2. P2P Capability */ + /* 3. Group Owner Intent */ + /* 4. Configuration Timeout */ + /* 5. Operating Channel */ + /* 6. Intended P2P Interface Address */ + /* 7. Channel List */ + /* 8. Device Info */ + /* 9. Group ID (Only GO) */ + + + /* ToDo: */ + + /* P2P Status */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_STATUS; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0001); + p2pielen += 2; + + /* Value: */ + p2pie[p2pielen++] = result; + + /* P2P Capability */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_CAPABILITY; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0002); + p2pielen += 2; + + /* Value: */ + /* Device Capability Bitmap, 1 byte */ + + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_CLIENT)) { + /* Commented by Albert 2011/03/08 */ + /* According to the P2P specification */ + /* if the sending device will be client, the P2P Capability should be reserved of group negotation response frame */ + p2pie[p2pielen++] = 0; + } else { + /* Be group owner or meet the error case */ + p2pie[p2pielen++] = DMP_P2P_DEVCAP_SUPPORT; + } + + /* Group Capability Bitmap, 1 byte */ + if (pwdinfo->persistent_supported) { + p2pie[p2pielen++] = P2P_GRPCAP_CROSS_CONN | P2P_GRPCAP_PERSISTENT_GROUP; + } else { + p2pie[p2pielen++] = P2P_GRPCAP_CROSS_CONN; + } + + /* Group Owner Intent */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_GO_INTENT; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0001); + p2pielen += 2; + + /* Value: */ + if (pwdinfo->peer_intent & 0x01) { + /* Peer's tie breaker bit is 1, our tie breaker bit should be 0 */ + p2pie[p2pielen++] = (pwdinfo->intent << 1); + } else { + /* Peer's tie breaker bit is 0, our tie breaker bit should be 1 */ + p2pie[p2pielen++] = ((pwdinfo->intent << 1) | BIT(0)); + } + + + /* Configuration Timeout */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_CONF_TIMEOUT; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0002); + p2pielen += 2; + + /* Value: */ + p2pie[p2pielen++] = 200; /* 2 seconds needed to be the P2P GO */ + p2pie[p2pielen++] = 200; /* 2 seconds needed to be the P2P Client */ + + /* Operating Channel */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_OPERATING_CH; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0005); + p2pielen += 2; + + /* Value: */ + /* Country String */ + p2pie[p2pielen++] = 'X'; + p2pie[p2pielen++] = 'X'; + + /* The third byte should be set to 0x04. */ + /* Described in the "Operating Channel Attribute" section. */ + p2pie[p2pielen++] = 0x04; + + /* Operating Class */ + p2pie[p2pielen++] = 0x51; + + /* Channel Number */ + p2pie[p2pielen++] = pwdinfo->operating_channel; /* operating channel number */ + + /* Intended P2P Interface Address */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_INTENTED_IF_ADDR; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(ETH_ALEN); + p2pielen += 2; + + /* Value: */ + memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv), ETH_ALEN); + p2pielen += ETH_ALEN; + + /* Channel List */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_CH_LIST; + + /* Country String(3) */ + /* + (Operating Class (1) + Number of Channels(1)) * Operation Classes (?) */ + /* + number of channels in all classes */ + len_channellist_attr = 3 + + (1 + 1) * (u16)pmlmeext->channel_list.reg_classes + + get_reg_classes_full_count(pmlmeext->channel_list); + + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(len_channellist_attr); + + p2pielen += 2; + + /* Value: */ + /* Country String */ + p2pie[p2pielen++] = 'X'; + p2pie[p2pielen++] = 'X'; + + /* The third byte should be set to 0x04. */ + /* Described in the "Operating Channel Attribute" section. */ + p2pie[p2pielen++] = 0x04; + + /* Channel Entry List */ + + { + int i, j; + for (j = 0; j < pmlmeext->channel_list.reg_classes; j++) { + /* Operating Class */ + p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].reg_class; + + /* Number of Channels */ + p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].channels; + + /* Channel List */ + for (i = 0; i < pmlmeext->channel_list.reg_class[j].channels; i++) { + p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].channel[i]; + } + } + } + + /* Device Info */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_DEVICE_INFO; + + /* Length: */ + /* 21 -> P2P Device Address (6bytes) + Config Methods (2bytes) + Primary Device Type (8bytes) */ + /* + NumofSecondDevType (1byte) + WPS Device Name ID field (2bytes) + WPS Device Name Len field (2bytes) */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(21 + pwdinfo->device_name_len); + p2pielen += 2; + + /* Value: */ + /* P2P Device Address */ + memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv), ETH_ALEN); + p2pielen += ETH_ALEN; + + /* Config Method */ + /* This field should be big endian. Noted by P2P specification. */ + + *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(pwdinfo->supported_wps_cm); + + p2pielen += 2; + + /* Primary Device Type */ + /* Category ID */ + *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); + p2pielen += 2; + + /* OUI */ + *(__be32 *)(p2pie + p2pielen) = cpu_to_be32(WPSOUI); + p2pielen += 4; + + /* Sub Category ID */ + *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); + p2pielen += 2; + + /* Number of Secondary Device Types */ + p2pie[p2pielen++] = 0x00; /* No Secondary Device Type List */ + + /* Device Name */ + /* Type: */ + *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); + p2pielen += 2; + + /* Length: */ + *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(pwdinfo->device_name_len); + p2pielen += 2; + + /* Value: */ + memcpy(p2pie + p2pielen, pwdinfo->device_name , pwdinfo->device_name_len); + p2pielen += pwdinfo->device_name_len; + + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { + /* Group ID Attribute */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_GROUP_ID; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(ETH_ALEN + pwdinfo->nego_ssidlen); + p2pielen += 2; + + /* Value: */ + /* p2P Device Address */ + memcpy(p2pie + p2pielen , pwdinfo->device_addr, ETH_ALEN); + p2pielen += ETH_ALEN; + + /* SSID */ + memcpy(p2pie + p2pielen, pwdinfo->nego_ssid, pwdinfo->nego_ssidlen); + p2pielen += pwdinfo->nego_ssidlen; + } + + pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &pattrib->pktlen); + + pattrib->last_txcmdsz = pattrib->pktlen; + + dump_mgntframe(padapter, pmgntframe); + return; +} + +static void issue_p2p_GO_confirm(struct adapter *padapter, u8 *raddr, u8 result) +{ + unsigned char category = RTW_WLAN_CATEGORY_PUBLIC; + u8 action = P2P_PUB_ACTION_ACTION; + __be32 p2poui = cpu_to_be32(P2POUI); + u8 oui_subtype = P2P_GO_NEGO_CONF; + u8 p2pie[255] = { 0x00 }; + u8 p2pielen = 0; + + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; + struct rtw_ieee80211_hdr *pwlanhdr; + unsigned short *fctrl; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + return; + + DBG_88E("[%s] In\n", __func__); + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + + _rtw_memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + + memcpy(pwlanhdr->addr1, raddr, ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr3, myid(&(padapter->eeprompriv)), ETH_ALEN); + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + SetFrameSubType(pframe, WIFI_ACTION); + + pframe += sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); + + pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(action), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&(p2poui), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(oui_subtype), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(pwdinfo->negotiation_dialog_token), &(pattrib->pktlen)); + + + + /* P2P IE Section. */ + + /* P2P OUI */ + p2pielen = 0; + p2pie[p2pielen++] = 0x50; + p2pie[p2pielen++] = 0x6F; + p2pie[p2pielen++] = 0x9A; + p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ + + /* Commented by Albert 20110306 */ + /* According to the P2P Specification, the group negoitation request frame should contain 5 P2P attributes */ + /* 1. Status */ + /* 2. P2P Capability */ + /* 3. Operating Channel */ + /* 4. Channel List */ + /* 5. Group ID (if this WiFi is GO) */ + + /* P2P Status */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_STATUS; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0001); + p2pielen += 2; + + /* Value: */ + p2pie[p2pielen++] = result; + + /* P2P Capability */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_CAPABILITY; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0002); + p2pielen += 2; + + /* Value: */ + /* Device Capability Bitmap, 1 byte */ + p2pie[p2pielen++] = DMP_P2P_DEVCAP_SUPPORT; + + /* Group Capability Bitmap, 1 byte */ + if (pwdinfo->persistent_supported) + p2pie[p2pielen++] = P2P_GRPCAP_CROSS_CONN | P2P_GRPCAP_PERSISTENT_GROUP; + else + p2pie[p2pielen++] = P2P_GRPCAP_CROSS_CONN; + + /* Operating Channel */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_OPERATING_CH; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0005); + p2pielen += 2; + + /* Value: */ + /* Country String */ + p2pie[p2pielen++] = 'X'; + p2pie[p2pielen++] = 'X'; + + /* The third byte should be set to 0x04. */ + /* Described in the "Operating Channel Attribute" section. */ + p2pie[p2pielen++] = 0x04; + + + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_CLIENT)) { + /* Operating Class */ + p2pie[p2pielen++] = 0x51; + p2pie[p2pielen++] = pwdinfo->peer_operating_ch; + } else { + /* Operating Class */ + p2pie[p2pielen++] = 0x51; + + /* Channel Number */ + p2pie[p2pielen++] = pwdinfo->operating_channel; /* Use the listen channel as the operating channel */ + } + + + /* Channel List */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_CH_LIST; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(pwdinfo->channel_list_attr_len); + p2pielen += 2; + + /* Value: */ + memcpy(p2pie + p2pielen, pwdinfo->channel_list_attr, pwdinfo->channel_list_attr_len); + p2pielen += pwdinfo->channel_list_attr_len; + + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { + /* Group ID Attribute */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_GROUP_ID; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(ETH_ALEN + pwdinfo->nego_ssidlen); + p2pielen += 2; + + /* Value: */ + /* p2P Device Address */ + memcpy(p2pie + p2pielen , pwdinfo->device_addr, ETH_ALEN); + p2pielen += ETH_ALEN; + + /* SSID */ + memcpy(p2pie + p2pielen, pwdinfo->nego_ssid, pwdinfo->nego_ssidlen); + p2pielen += pwdinfo->nego_ssidlen; + } + pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &pattrib->pktlen); + pattrib->last_txcmdsz = pattrib->pktlen; + dump_mgntframe(padapter, pmgntframe); + return; +} + +void issue_p2p_invitation_request(struct adapter *padapter, u8 *raddr) +{ + unsigned char category = RTW_WLAN_CATEGORY_PUBLIC; + u8 action = P2P_PUB_ACTION_ACTION; + __be32 p2poui = cpu_to_be32(P2POUI); + u8 oui_subtype = P2P_INVIT_REQ; + u8 p2pie[255] = { 0x00 }; + u8 p2pielen = 0; + u8 dialogToken = 3; + u16 len_channellist_attr = 0; + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; + struct rtw_ieee80211_hdr *pwlanhdr; + unsigned short *fctrl; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + return; + + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + + _rtw_memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + + memcpy(pwlanhdr->addr1, raddr, ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr3, raddr, ETH_ALEN); + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + SetFrameSubType(pframe, WIFI_ACTION); + + pframe += sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); + + pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(action), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&(p2poui), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(oui_subtype), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(dialogToken), &(pattrib->pktlen)); + + /* P2P IE Section. */ + + /* P2P OUI */ + p2pielen = 0; + p2pie[p2pielen++] = 0x50; + p2pie[p2pielen++] = 0x6F; + p2pie[p2pielen++] = 0x9A; + p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ + + /* Commented by Albert 20101011 */ + /* According to the P2P Specification, the P2P Invitation request frame should contain 7 P2P attributes */ + /* 1. Configuration Timeout */ + /* 2. Invitation Flags */ + /* 3. Operating Channel (Only GO) */ + /* 4. P2P Group BSSID (Should be included if I am the GO) */ + /* 5. Channel List */ + /* 6. P2P Group ID */ + /* 7. P2P Device Info */ + + /* Configuration Timeout */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_CONF_TIMEOUT; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0002); + p2pielen += 2; + + /* Value: */ + p2pie[p2pielen++] = 200; /* 2 seconds needed to be the P2P GO */ + p2pie[p2pielen++] = 200; /* 2 seconds needed to be the P2P Client */ + + /* Invitation Flags */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_INVITATION_FLAGS; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0001); + p2pielen += 2; + + /* Value: */ + p2pie[p2pielen++] = P2P_INVITATION_FLAGS_PERSISTENT; + + + /* Operating Channel */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_OPERATING_CH; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0005); + p2pielen += 2; + + /* Value: */ + /* Country String */ + p2pie[p2pielen++] = 'X'; + p2pie[p2pielen++] = 'X'; + + /* The third byte should be set to 0x04. */ + /* Described in the "Operating Channel Attribute" section. */ + p2pie[p2pielen++] = 0x04; + + /* Operating Class */ + p2pie[p2pielen++] = 0x51; + + /* Channel Number */ + p2pie[p2pielen++] = pwdinfo->invitereq_info.operating_ch; /* operating channel number */ + + if (_rtw_memcmp(myid(&padapter->eeprompriv), pwdinfo->invitereq_info.go_bssid, ETH_ALEN)) { + /* P2P Group BSSID */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_GROUP_BSSID; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(ETH_ALEN); + p2pielen += 2; + + /* Value: */ + /* P2P Device Address for GO */ + memcpy(p2pie + p2pielen, pwdinfo->invitereq_info.go_bssid, ETH_ALEN); + p2pielen += ETH_ALEN; + } + + /* Channel List */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_CH_LIST; + + + /* Length: */ + /* Country String(3) */ + /* + (Operating Class (1) + Number of Channels(1)) * Operation Classes (?) */ + /* + number of channels in all classes */ + len_channellist_attr = 3 + + (1 + 1) * (u16)pmlmeext->channel_list.reg_classes + + get_reg_classes_full_count(pmlmeext->channel_list); + + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(len_channellist_attr); + + p2pielen += 2; + + /* Value: */ + /* Country String */ + p2pie[p2pielen++] = 'X'; + p2pie[p2pielen++] = 'X'; + + /* The third byte should be set to 0x04. */ + /* Described in the "Operating Channel Attribute" section. */ + p2pie[p2pielen++] = 0x04; + + /* Channel Entry List */ + { + int i, j; + for (j = 0; j < pmlmeext->channel_list.reg_classes; j++) { + /* Operating Class */ + p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].reg_class; + + /* Number of Channels */ + p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].channels; + + /* Channel List */ + for (i = 0; i < pmlmeext->channel_list.reg_class[j].channels; i++) { + p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].channel[i]; + } + } + } + + + /* P2P Group ID */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_GROUP_ID; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(6 + pwdinfo->invitereq_info.ssidlen); + p2pielen += 2; + + /* Value: */ + /* P2P Device Address for GO */ + memcpy(p2pie + p2pielen, pwdinfo->invitereq_info.go_bssid, ETH_ALEN); + p2pielen += ETH_ALEN; + + /* SSID */ + memcpy(p2pie + p2pielen, pwdinfo->invitereq_info.go_ssid, pwdinfo->invitereq_info.ssidlen); + p2pielen += pwdinfo->invitereq_info.ssidlen; + + + /* Device Info */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_DEVICE_INFO; + + /* Length: */ + /* 21 -> P2P Device Address (6bytes) + Config Methods (2bytes) + Primary Device Type (8bytes) */ + /* + NumofSecondDevType (1byte) + WPS Device Name ID field (2bytes) + WPS Device Name Len field (2bytes) */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(21 + pwdinfo->device_name_len); + p2pielen += 2; + + /* Value: */ + /* P2P Device Address */ + memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv), ETH_ALEN); + p2pielen += ETH_ALEN; + + /* Config Method */ + /* This field should be big endian. Noted by P2P specification. */ + *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_CONFIG_METHOD_DISPLAY); + p2pielen += 2; + + /* Primary Device Type */ + /* Category ID */ + *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); + p2pielen += 2; + + /* OUI */ + *(__be32 *)(p2pie + p2pielen) = cpu_to_be32(WPSOUI); + p2pielen += 4; + + /* Sub Category ID */ + *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); + p2pielen += 2; + + /* Number of Secondary Device Types */ + p2pie[p2pielen++] = 0x00; /* No Secondary Device Type List */ + + /* Device Name */ + /* Type: */ + *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); + p2pielen += 2; + + /* Length: */ + *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(pwdinfo->device_name_len); + p2pielen += 2; + + /* Value: */ + memcpy(p2pie + p2pielen, pwdinfo->device_name, pwdinfo->device_name_len); + p2pielen += pwdinfo->device_name_len; + + pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &pattrib->pktlen); + + pattrib->last_txcmdsz = pattrib->pktlen; + + dump_mgntframe(padapter, pmgntframe); + + return; +} + +void issue_p2p_invitation_response(struct adapter *padapter, u8 *raddr, u8 dialogToken, u8 status_code) +{ + unsigned char category = RTW_WLAN_CATEGORY_PUBLIC; + u8 action = P2P_PUB_ACTION_ACTION; + __be32 p2poui = cpu_to_be32(P2POUI); + u8 oui_subtype = P2P_INVIT_RESP; + u8 p2pie[255] = { 0x00 }; + u8 p2pielen = 0; + u16 len_channellist_attr = 0; + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; + struct rtw_ieee80211_hdr *pwlanhdr; + unsigned short *fctrl; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + return; + + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + + _rtw_memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + + memcpy(pwlanhdr->addr1, raddr, ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr3, raddr, ETH_ALEN); + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + SetFrameSubType(pframe, WIFI_ACTION); + + pframe += sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); + + pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(action), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&(p2poui), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(oui_subtype), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(dialogToken), &(pattrib->pktlen)); + + /* P2P IE Section. */ + + /* P2P OUI */ + p2pielen = 0; + p2pie[p2pielen++] = 0x50; + p2pie[p2pielen++] = 0x6F; + p2pie[p2pielen++] = 0x9A; + p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ + + /* Commented by Albert 20101005 */ + /* According to the P2P Specification, the P2P Invitation response frame should contain 5 P2P attributes */ + /* 1. Status */ + /* 2. Configuration Timeout */ + /* 3. Operating Channel (Only GO) */ + /* 4. P2P Group BSSID (Only GO) */ + /* 5. Channel List */ + + /* P2P Status */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_STATUS; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0001); + p2pielen += 2; + + /* Value: */ + /* When status code is P2P_STATUS_FAIL_INFO_UNAVAILABLE. */ + /* Sent the event receiving the P2P Invitation Req frame to DMP UI. */ + /* DMP had to compare the MAC address to find out the profile. */ + /* So, the WiFi driver will send the P2P_STATUS_FAIL_INFO_UNAVAILABLE to NB. */ + /* If the UI found the corresponding profile, the WiFi driver sends the P2P Invitation Req */ + /* to NB to rebuild the persistent group. */ + p2pie[p2pielen++] = status_code; + + /* Configuration Timeout */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_CONF_TIMEOUT; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0002); + p2pielen += 2; + + /* Value: */ + p2pie[p2pielen++] = 200; /* 2 seconds needed to be the P2P GO */ + p2pie[p2pielen++] = 200; /* 2 seconds needed to be the P2P Client */ + + if (status_code == P2P_STATUS_SUCCESS) { + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { + /* The P2P Invitation request frame asks this Wi-Fi device to be the P2P GO */ + /* In this case, the P2P Invitation response frame should carry the two more P2P attributes. */ + /* First one is operating channel attribute. */ + /* Second one is P2P Group BSSID attribute. */ + + /* Operating Channel */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_OPERATING_CH; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0005); + p2pielen += 2; + + /* Value: */ + /* Country String */ + p2pie[p2pielen++] = 'X'; + p2pie[p2pielen++] = 'X'; + + /* The third byte should be set to 0x04. */ + /* Described in the "Operating Channel Attribute" section. */ + p2pie[p2pielen++] = 0x04; + + /* Operating Class */ + p2pie[p2pielen++] = 0x51; /* Copy from SD7 */ + + /* Channel Number */ + p2pie[p2pielen++] = pwdinfo->operating_channel; /* operating channel number */ + + + /* P2P Group BSSID */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_GROUP_BSSID; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(ETH_ALEN); + p2pielen += 2; + + /* Value: */ + /* P2P Device Address for GO */ + memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv), ETH_ALEN); + p2pielen += ETH_ALEN; + } + + /* Channel List */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_CH_LIST; + + /* Length: */ + /* Country String(3) */ + /* + (Operating Class (1) + Number of Channels(1)) * Operation Classes (?) */ + /* + number of channels in all classes */ + len_channellist_attr = 3 + + (1 + 1) * (u16)pmlmeext->channel_list.reg_classes + + get_reg_classes_full_count(pmlmeext->channel_list); + + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(len_channellist_attr); + p2pielen += 2; + + /* Value: */ + /* Country String */ + p2pie[p2pielen++] = 'X'; + p2pie[p2pielen++] = 'X'; + + /* The third byte should be set to 0x04. */ + /* Described in the "Operating Channel Attribute" section. */ + p2pie[p2pielen++] = 0x04; + + /* Channel Entry List */ + { + int i, j; + for (j = 0; j < pmlmeext->channel_list.reg_classes; j++) { + /* Operating Class */ + p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].reg_class; + + /* Number of Channels */ + p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].channels; + + /* Channel List */ + for (i = 0; i < pmlmeext->channel_list.reg_class[j].channels; i++) { + p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].channel[i]; + } + } + } + } + + pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &pattrib->pktlen); + + pattrib->last_txcmdsz = pattrib->pktlen; + + dump_mgntframe(padapter, pmgntframe); + + return; +} + +void issue_p2p_provision_request(struct adapter *padapter, u8 *pssid, u8 ussidlen, u8 *pdev_raddr) +{ + unsigned char category = RTW_WLAN_CATEGORY_PUBLIC; + u8 action = P2P_PUB_ACTION_ACTION; + u8 dialogToken = 1; + u8 oui_subtype = P2P_PROVISION_DISC_REQ; + u8 wpsie[100] = { 0x00 }; + u8 wpsielen = 0; + __be32 p2poui = cpu_to_be32(P2POUI); + u32 p2pielen = 0; + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; + struct rtw_ieee80211_hdr *pwlanhdr; + unsigned short *fctrl; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + return; + + DBG_88E("[%s] In\n", __func__); + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + + _rtw_memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + + memcpy(pwlanhdr->addr1, pdev_raddr, ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr3, pdev_raddr, ETH_ALEN); + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + SetFrameSubType(pframe, WIFI_ACTION); + + pframe += sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); + + pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(action), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&(p2poui), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(oui_subtype), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(dialogToken), &(pattrib->pktlen)); + + p2pielen = build_prov_disc_request_p2p_ie(pwdinfo, pframe, pssid, ussidlen, pdev_raddr); + + pframe += p2pielen; + pattrib->pktlen += p2pielen; + + wpsielen = 0; + /* WPS OUI */ + *(__be32 *)(wpsie) = cpu_to_be32(WPSOUI); + wpsielen += 4; + + /* WPS version */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_VER1); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0001); + wpsielen += 2; + + /* Value: */ + wpsie[wpsielen++] = WPS_VERSION_1; /* Version 1.0 */ + + /* Config Method */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_CONF_METHOD); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0002); + wpsielen += 2; + + /* Value: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(pwdinfo->tx_prov_disc_info.wps_config_method_request); + wpsielen += 2; + + pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, wpsielen, (unsigned char *)wpsie, &pattrib->pktlen); + + pattrib->last_txcmdsz = pattrib->pktlen; + + dump_mgntframe(padapter, pmgntframe); + + return; +} + +static u8 is_matched_in_profilelist(u8 *peermacaddr, struct profile_info *profileinfo) +{ + u8 i, match_result = 0; + + DBG_88E("[%s] peermac=%.2X %.2X %.2X %.2X %.2X %.2X\n", __func__, + peermacaddr[0], peermacaddr[1], peermacaddr[2], peermacaddr[3], peermacaddr[4], peermacaddr[5]); + + for (i = 0; i < P2P_MAX_PERSISTENT_GROUP_NUM; i++, profileinfo++) { + DBG_88E("[%s] profileinfo_mac=%.2X %.2X %.2X %.2X %.2X %.2X\n", __func__, + profileinfo->peermac[0], profileinfo->peermac[1], profileinfo->peermac[2], profileinfo->peermac[3], profileinfo->peermac[4], profileinfo->peermac[5]); + if (_rtw_memcmp(peermacaddr, profileinfo->peermac, ETH_ALEN)) { + match_result = 1; + DBG_88E("[%s] Match!\n", __func__); + break; + } + } + return match_result; +} + +void issue_probersp_p2p(struct adapter *padapter, unsigned char *da) +{ + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; + struct rtw_ieee80211_hdr *pwlanhdr; + unsigned short *fctrl; + unsigned char *mac; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + u16 beacon_interval = 100; + u16 capInfo = 0; + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + u8 wpsie[255] = { 0x00 }; + u32 wpsielen = 0, p2pielen = 0; + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + return; + + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + + _rtw_memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + mac = myid(&(padapter->eeprompriv)); + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + memcpy(pwlanhdr->addr1, da, ETH_ALEN); + memcpy(pwlanhdr->addr2, mac, ETH_ALEN); + + /* Use the device address for BSSID field. */ + memcpy(pwlanhdr->addr3, mac, ETH_ALEN); + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + SetFrameSubType(fctrl, WIFI_PROBERSP); + + pattrib->hdrlen = sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = pattrib->hdrlen; + pframe += pattrib->hdrlen; + + /* timestamp will be inserted by hardware */ + pframe += 8; + pattrib->pktlen += 8; + + /* beacon interval: 2 bytes */ + memcpy(pframe, (unsigned char *)&beacon_interval, 2); + pframe += 2; + pattrib->pktlen += 2; + + /* capability info: 2 bytes */ + /* ESS and IBSS bits must be 0 (defined in the 3.1.2.1.1 of WiFi Direct Spec) */ + capInfo |= cap_ShortPremble; + capInfo |= cap_ShortSlot; + + memcpy(pframe, (unsigned char *)&capInfo, 2); + pframe += 2; + pattrib->pktlen += 2; + + + /* SSID */ + pframe = rtw_set_ie(pframe, _SSID_IE_, 7, pwdinfo->p2p_wildcard_ssid, &pattrib->pktlen); + + /* supported rates... */ + /* Use the OFDM rate in the P2P probe response frame. (6(B), 9(B), 12, 18, 24, 36, 48, 54) */ + pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, 8, pwdinfo->support_rate, &pattrib->pktlen); + + /* DS parameter set */ + pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&pwdinfo->listen_channel, &pattrib->pktlen); + + /* Todo: WPS IE */ + /* Noted by Albert 20100907 */ + /* According to the WPS specification, all the WPS attribute is presented by Big Endian. */ + + wpsielen = 0; + /* WPS OUI */ + *(__be32 *)(wpsie) = cpu_to_be32(WPSOUI); + wpsielen += 4; + + /* WPS version */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_VER1); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0001); + wpsielen += 2; + + /* Value: */ + wpsie[wpsielen++] = WPS_VERSION_1; /* Version 1.0 */ + + /* WiFi Simple Config State */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_SIMPLE_CONF_STATE); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0001); + wpsielen += 2; + + /* Value: */ + wpsie[wpsielen++] = WPS_WSC_STATE_NOT_CONFIG; /* Not Configured. */ + + /* Response Type */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_RESP_TYPE); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0001); + wpsielen += 2; + + /* Value: */ + wpsie[wpsielen++] = WPS_RESPONSE_TYPE_8021X; + + /* UUID-E */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_UUID_E); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0010); + wpsielen += 2; + + /* Value: */ + memcpy(wpsie + wpsielen, myid(&padapter->eeprompriv), ETH_ALEN); + wpsielen += 0x10; + + /* Manufacturer */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_MANUFACTURER); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0007); + wpsielen += 2; + + /* Value: */ + memcpy(wpsie + wpsielen, "Realtek", 7); + wpsielen += 7; + + /* Model Name */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_MODEL_NAME); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0006); + wpsielen += 2; + + /* Value: */ + memcpy(wpsie + wpsielen, "8188EU", 6); + wpsielen += 6; + + /* Model Number */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_MODEL_NUMBER); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0001); + wpsielen += 2; + + /* Value: */ + wpsie[wpsielen++] = 0x31; /* character 1 */ + + /* Serial Number */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_SERIAL_NUMBER); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(ETH_ALEN); + wpsielen += 2; + + /* Value: */ + memcpy(wpsie + wpsielen, "123456" , ETH_ALEN); + wpsielen += ETH_ALEN; + + /* Primary Device Type */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_PRIMARY_DEV_TYPE); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0008); + wpsielen += 2; + + /* Value: */ + /* Category ID */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); + wpsielen += 2; + + /* OUI */ + *(__be32 *)(wpsie + wpsielen) = cpu_to_be32(WPSOUI); + wpsielen += 4; + + /* Sub Category ID */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); + wpsielen += 2; + + /* Device Name */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(pwdinfo->device_name_len); + wpsielen += 2; + + /* Value: */ + if (pwdinfo->device_name_len) { + memcpy(wpsie + wpsielen, pwdinfo->device_name, pwdinfo->device_name_len); + wpsielen += pwdinfo->device_name_len; + } + + /* Config Method */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_CONF_METHOD); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0002); + wpsielen += 2; + + /* Value: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(pwdinfo->supported_wps_cm); + wpsielen += 2; + + + pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, wpsielen, (unsigned char *)wpsie, &pattrib->pktlen); + + + p2pielen = build_probe_resp_p2p_ie(pwdinfo, pframe); + pframe += p2pielen; + pattrib->pktlen += p2pielen; + + pattrib->last_txcmdsz = pattrib->pktlen; + + dump_mgntframe(padapter, pmgntframe); + + return; +} + +static int _issue_probereq_p2p(struct adapter *padapter, u8 *da, int wait_ack) +{ + int ret = _FAIL; + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; + struct rtw_ieee80211_hdr *pwlanhdr; + unsigned short *fctrl; + unsigned char *mac; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + u8 wpsie[255] = { 0x00 }, p2pie[255] = { 0x00 }; + u16 wpsielen = 0, p2pielen = 0; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + goto exit; + + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + + + _rtw_memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + mac = myid(&(padapter->eeprompriv)); + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + + if (da) { + memcpy(pwlanhdr->addr1, da, ETH_ALEN); + memcpy(pwlanhdr->addr3, da, ETH_ALEN); + } else { + if ((pwdinfo->p2p_info.scan_op_ch_only) || (pwdinfo->rx_invitereq_info.scan_op_ch_only)) { + /* This two flags will be set when this is only the P2P client mode. */ + memcpy(pwlanhdr->addr1, pwdinfo->p2p_peer_interface_addr, ETH_ALEN); + memcpy(pwlanhdr->addr3, pwdinfo->p2p_peer_interface_addr, ETH_ALEN); + } else { + /* broadcast probe request frame */ + memcpy(pwlanhdr->addr1, bc_addr, ETH_ALEN); + memcpy(pwlanhdr->addr3, bc_addr, ETH_ALEN); + } + } + memcpy(pwlanhdr->addr2, mac, ETH_ALEN); + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + SetFrameSubType(pframe, WIFI_PROBEREQ); + + pframe += sizeof (struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof (struct rtw_ieee80211_hdr_3addr); + + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_TX_PROVISION_DIS_REQ)) + pframe = rtw_set_ie(pframe, _SSID_IE_, pwdinfo->tx_prov_disc_info.ssid.SsidLength, pwdinfo->tx_prov_disc_info.ssid.Ssid, &(pattrib->pktlen)); + else + pframe = rtw_set_ie(pframe, _SSID_IE_, P2P_WILDCARD_SSID_LEN, pwdinfo->p2p_wildcard_ssid, &(pattrib->pktlen)); + + /* Use the OFDM rate in the P2P probe request frame. (6(B), 9(B), 12(B), 24(B), 36, 48, 54) */ + pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, 8, pwdinfo->support_rate, &pattrib->pktlen); + + + /* WPS IE */ + /* Noted by Albert 20110221 */ + /* According to the WPS specification, all the WPS attribute is presented by Big Endian. */ + + wpsielen = 0; + /* WPS OUI */ + *(__be32 *)(wpsie) = cpu_to_be32(WPSOUI); + wpsielen += 4; + + /* WPS version */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_VER1); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0001); + wpsielen += 2; + + /* Value: */ + wpsie[wpsielen++] = WPS_VERSION_1; /* Version 1.0 */ + + if (pmlmepriv->wps_probe_req_ie == NULL) { + /* UUID-E */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_UUID_E); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0010); + wpsielen += 2; + + /* Value: */ + memcpy(wpsie + wpsielen, myid(&padapter->eeprompriv), ETH_ALEN); + wpsielen += 0x10; + + /* Config Method */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_CONF_METHOD); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0002); + wpsielen += 2; + + /* Value: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(pwdinfo->supported_wps_cm); + wpsielen += 2; + } + + /* Device Name */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(pwdinfo->device_name_len); + wpsielen += 2; + + /* Value: */ + memcpy(wpsie + wpsielen, pwdinfo->device_name, pwdinfo->device_name_len); + wpsielen += pwdinfo->device_name_len; + + /* Primary Device Type */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_PRIMARY_DEV_TYPE); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0008); + wpsielen += 2; + + /* Value: */ + /* Category ID */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_PDT_CID_RTK_WIDI); + wpsielen += 2; + + /* OUI */ + *(__be32 *)(wpsie + wpsielen) = cpu_to_be32(WPSOUI); + wpsielen += 4; + + /* Sub Category ID */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_PDT_SCID_RTK_DMP); + wpsielen += 2; + + /* Device Password ID */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_DEVICE_PWID); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0002); + wpsielen += 2; + + /* Value: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_DPID_REGISTRAR_SPEC); /* Registrar-specified */ + wpsielen += 2; + + pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, wpsielen, (unsigned char *)wpsie, &pattrib->pktlen); + + /* P2P OUI */ + p2pielen = 0; + p2pie[p2pielen++] = 0x50; + p2pie[p2pielen++] = 0x6F; + p2pie[p2pielen++] = 0x9A; + p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ + + /* Commented by Albert 20110221 */ + /* According to the P2P Specification, the probe request frame should contain 5 P2P attributes */ + /* 1. P2P Capability */ + /* 2. P2P Device ID if this probe request wants to find the specific P2P device */ + /* 3. Listen Channel */ + /* 4. Extended Listen Timing */ + /* 5. Operating Channel if this WiFi is working as the group owner now */ + + /* P2P Capability */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_CAPABILITY; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0002); + p2pielen += 2; + + /* Value: */ + /* Device Capability Bitmap, 1 byte */ + p2pie[p2pielen++] = DMP_P2P_DEVCAP_SUPPORT; + + /* Group Capability Bitmap, 1 byte */ + if (pwdinfo->persistent_supported) + p2pie[p2pielen++] = P2P_GRPCAP_PERSISTENT_GROUP | DMP_P2P_GRPCAP_SUPPORT; + else + p2pie[p2pielen++] = DMP_P2P_GRPCAP_SUPPORT; + + /* Listen Channel */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_LISTEN_CH; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0005); + p2pielen += 2; + + /* Value: */ + /* Country String */ + p2pie[p2pielen++] = 'X'; + p2pie[p2pielen++] = 'X'; + + /* The third byte should be set to 0x04. */ + /* Described in the "Operating Channel Attribute" section. */ + p2pie[p2pielen++] = 0x04; + + /* Operating Class */ + p2pie[p2pielen++] = 0x51; /* Copy from SD7 */ + + /* Channel Number */ + p2pie[p2pielen++] = pwdinfo->listen_channel; /* listen channel */ + + + /* Extended Listen Timing */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_EX_LISTEN_TIMING; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0004); + p2pielen += 2; + + /* Value: */ + /* Availability Period */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0xFFFF); + p2pielen += 2; + + /* Availability Interval */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0xFFFF); + p2pielen += 2; + + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { + /* Operating Channel (if this WiFi is working as the group owner now) */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_OPERATING_CH; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0005); + p2pielen += 2; + + /* Value: */ + /* Country String */ + p2pie[p2pielen++] = 'X'; + p2pie[p2pielen++] = 'X'; + + /* The third byte should be set to 0x04. */ + /* Described in the "Operating Channel Attribute" section. */ + p2pie[p2pielen++] = 0x04; + + /* Operating Class */ + p2pie[p2pielen++] = 0x51; /* Copy from SD7 */ + + /* Channel Number */ + p2pie[p2pielen++] = pwdinfo->operating_channel; /* operating channel number */ + } + + pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &pattrib->pktlen); + + if (pmlmepriv->wps_probe_req_ie != NULL) { + /* WPS IE */ + memcpy(pframe, pmlmepriv->wps_probe_req_ie, pmlmepriv->wps_probe_req_ie_len); + pattrib->pktlen += pmlmepriv->wps_probe_req_ie_len; + pframe += pmlmepriv->wps_probe_req_ie_len; + } + + pattrib->last_txcmdsz = pattrib->pktlen; + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("issuing probe_req, tx_len=%d\n", pattrib->last_txcmdsz)); + + if (wait_ack) { + ret = dump_mgntframe_and_wait_ack(padapter, pmgntframe); + } else { + dump_mgntframe(padapter, pmgntframe); + ret = _SUCCESS; + } + +exit: + return ret; +} + +inline void issue_probereq_p2p(struct adapter *adapter, u8 *da) +{ + _issue_probereq_p2p(adapter, da, false); +} + +int issue_probereq_p2p_ex(struct adapter *adapter, u8 *da, int try_cnt, int wait_ms) +{ + int ret; + int i = 0; + u32 start = rtw_get_current_time(); + + do { + ret = _issue_probereq_p2p(adapter, da, wait_ms > 0 ? true : false); + + i++; + + if (adapter->bDriverStopped || adapter->bSurpriseRemoved) + break; + + if (i < try_cnt && wait_ms > 0 && ret == _FAIL) + rtw_msleep_os(wait_ms); + } while ((i < try_cnt) && ((ret == _FAIL) || (wait_ms == 0))); + + if (ret != _FAIL) { + ret = _SUCCESS; + goto exit; + } + + if (try_cnt && wait_ms) { + if (da) + DBG_88E(FUNC_ADPT_FMT" to %pM, ch:%u%s, %d/%d in %u ms\n", + FUNC_ADPT_ARG(adapter), da, rtw_get_oper_ch(adapter), + ret == _SUCCESS ? ", acked" : "", i, try_cnt, rtw_get_passing_time_ms(start)); + else + DBG_88E(FUNC_ADPT_FMT", ch:%u%s, %d/%d in %u ms\n", + FUNC_ADPT_ARG(adapter), rtw_get_oper_ch(adapter), + ret == _SUCCESS ? ", acked" : "", i, try_cnt, rtw_get_passing_time_ms(start)); + } +exit: + return ret; +} + +#endif /* CONFIG_88EU_P2P */ + +static s32 rtw_action_public_decache(union recv_frame *recv_frame, s32 token) +{ + struct adapter *adapter = recv_frame->u.hdr.adapter; + struct mlme_ext_priv *mlmeext = &(adapter->mlmeextpriv); + u8 *frame = recv_frame->u.hdr.rx_data; + u16 seq_ctrl = ((recv_frame->u.hdr.attrib.seq_num&0xffff) << 4) | + (recv_frame->u.hdr.attrib.frag_num & 0xf); + + if (GetRetry(frame)) { + if (token >= 0) { + if ((seq_ctrl == mlmeext->action_public_rxseq) && (token == mlmeext->action_public_dialog_token)) { + DBG_88E(FUNC_ADPT_FMT" seq_ctrl = 0x%x, rxseq = 0x%x, token:%d\n", + FUNC_ADPT_ARG(adapter), seq_ctrl, mlmeext->action_public_rxseq, token); + return _FAIL; + } + } else { + if (seq_ctrl == mlmeext->action_public_rxseq) { + DBG_88E(FUNC_ADPT_FMT" seq_ctrl = 0x%x, rxseq = 0x%x\n", + FUNC_ADPT_ARG(adapter), seq_ctrl, mlmeext->action_public_rxseq); + return _FAIL; + } + } + } + + mlmeext->action_public_rxseq = seq_ctrl; + + if (token >= 0) + mlmeext->action_public_dialog_token = token; + + return _SUCCESS; +} + +static unsigned int on_action_public_p2p(union recv_frame *precv_frame) +{ + u8 *pframe = precv_frame->u.hdr.rx_data; + u8 *frame_body; + u8 dialogToken = 0; +#ifdef CONFIG_88EU_P2P + struct adapter *padapter = precv_frame->u.hdr.adapter; + uint len = precv_frame->u.hdr.len; + u8 *p2p_ie; + u32 p2p_ielen; + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + u8 result = P2P_STATUS_SUCCESS; + u8 empty_addr[ETH_ALEN] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +#endif /* CONFIG_88EU_P2P */ + + frame_body = (unsigned char *)(pframe + sizeof(struct rtw_ieee80211_hdr_3addr)); + + dialogToken = frame_body[7]; + + if (rtw_action_public_decache(precv_frame, dialogToken) == _FAIL) + return _FAIL; + +#ifdef CONFIG_88EU_P2P + _cancel_timer_ex(&pwdinfo->reset_ch_sitesurvey); + /* Do nothing if the driver doesn't enable the P2P function. */ + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE) || rtw_p2p_chk_state(pwdinfo, P2P_STATE_IDLE)) + return _SUCCESS; + + len -= sizeof(struct rtw_ieee80211_hdr_3addr); + + switch (frame_body[6]) { /* OUI Subtype */ + case P2P_GO_NEGO_REQ: + DBG_88E("[%s] Got GO Nego Req Frame\n", __func__); + _rtw_memset(&pwdinfo->groupid_info, 0x00, sizeof(struct group_id_info)); + + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_RX_PROVISION_DIS_REQ)) + rtw_p2p_set_state(pwdinfo, rtw_p2p_pre_state(pwdinfo)); + + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_FAIL)) { + /* Commented by Albert 20110526 */ + /* In this case, this means the previous nego fail doesn't be reset yet. */ + _cancel_timer_ex(&pwdinfo->restore_p2p_state_timer); + /* Restore the previous p2p state */ + rtw_p2p_set_state(pwdinfo, rtw_p2p_pre_state(pwdinfo)); + DBG_88E("[%s] Restore the previous p2p state to %d\n", __func__, rtw_p2p_state(pwdinfo)); + } + + /* Commented by Kurt 20110902 */ + /* Add if statement to avoid receiving duplicate prov disc req. such that pre_p2p_state would be covered. */ + if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_ING)) + rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo)); + + /* Commented by Kurt 20120113 */ + /* Get peer_dev_addr here if peer doesn't issue prov_disc frame. */ + if (_rtw_memcmp(pwdinfo->rx_prov_disc_info.peerDevAddr, empty_addr, ETH_ALEN)) + memcpy(pwdinfo->rx_prov_disc_info.peerDevAddr, GetAddr2Ptr(pframe), ETH_ALEN); + + result = process_p2p_group_negotation_req(pwdinfo, frame_body, len); + issue_p2p_GO_response(padapter, GetAddr2Ptr(pframe), frame_body, len, result); + + /* Commented by Albert 20110718 */ + /* No matter negotiating or negotiation failure, the driver should set up the restore P2P state timer. */ + _set_timer(&pwdinfo->restore_p2p_state_timer, 5000); + break; + case P2P_GO_NEGO_RESP: + DBG_88E("[%s] Got GO Nego Resp Frame\n", __func__); + + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_ING)) { + /* Commented by Albert 20110425 */ + /* The restore timer is enabled when issuing the nego request frame of rtw_p2p_connect function. */ + _cancel_timer_ex(&pwdinfo->restore_p2p_state_timer); + pwdinfo->nego_req_info.benable = false; + result = process_p2p_group_negotation_resp(pwdinfo, frame_body, len); + issue_p2p_GO_confirm(pwdinfo->padapter, GetAddr2Ptr(pframe), result); + if (P2P_STATUS_SUCCESS == result) { + if (rtw_p2p_role(pwdinfo) == P2P_ROLE_CLIENT) { + pwdinfo->p2p_info.operation_ch[0] = pwdinfo->peer_operating_ch; + pwdinfo->p2p_info.scan_op_ch_only = 1; + _set_timer(&pwdinfo->reset_ch_sitesurvey2, P2P_RESET_SCAN_CH); + } + } + /* Reset the dialog token for group negotiation frames. */ + pwdinfo->negotiation_dialog_token = 1; + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_FAIL)) + _set_timer(&pwdinfo->restore_p2p_state_timer, 5000); + } else { + DBG_88E("[%s] Skipped GO Nego Resp Frame (p2p_state != P2P_STATE_GONEGO_ING)\n", __func__); + } + break; + case P2P_GO_NEGO_CONF: + DBG_88E("[%s] Got GO Nego Confirm Frame\n", __func__); + result = process_p2p_group_negotation_confirm(pwdinfo, frame_body, len); + if (P2P_STATUS_SUCCESS == result) { + if (rtw_p2p_role(pwdinfo) == P2P_ROLE_CLIENT) { + pwdinfo->p2p_info.operation_ch[0] = pwdinfo->peer_operating_ch; + pwdinfo->p2p_info.scan_op_ch_only = 1; + _set_timer(&pwdinfo->reset_ch_sitesurvey2, P2P_RESET_SCAN_CH); + } + } + break; + case P2P_INVIT_REQ: + /* Added by Albert 2010/10/05 */ + /* Received the P2P Invite Request frame. */ + + DBG_88E("[%s] Got invite request frame!\n", __func__); + p2p_ie = rtw_get_p2p_ie(frame_body + _PUBLIC_ACTION_IE_OFFSET_, len - _PUBLIC_ACTION_IE_OFFSET_, NULL, &p2p_ielen); + if (p2p_ie) { + /* Parse the necessary information from the P2P Invitation Request frame. */ + /* For example: The MAC address of sending this P2P Invitation Request frame. */ + u32 attr_contentlen = 0; + u8 status_code = P2P_STATUS_FAIL_INFO_UNAVAILABLE; + struct group_id_info group_id; + u8 invitation_flag = 0; + + rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_INVITATION_FLAGS, &invitation_flag, &attr_contentlen); + if (attr_contentlen) { + rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_BSSID, pwdinfo->p2p_peer_interface_addr, &attr_contentlen); + /* Commented by Albert 20120510 */ + /* Copy to the pwdinfo->p2p_peer_interface_addr. */ + /* So that the WFD UI (or Sigma) can get the peer interface address by using the following command. */ + /* #> iwpriv wlan0 p2p_get peer_ifa */ + /* After having the peer interface address, the sigma can find the correct conf file for wpa_supplicant. */ + + if (attr_contentlen) { + DBG_88E("[%s] GO's BSSID = %.2X %.2X %.2X %.2X %.2X %.2X\n", __func__, + pwdinfo->p2p_peer_interface_addr[0], pwdinfo->p2p_peer_interface_addr[1], + pwdinfo->p2p_peer_interface_addr[2], pwdinfo->p2p_peer_interface_addr[3], + pwdinfo->p2p_peer_interface_addr[4], pwdinfo->p2p_peer_interface_addr[5]); + } + + if (invitation_flag & P2P_INVITATION_FLAGS_PERSISTENT) { + /* Re-invoke the persistent group. */ + + _rtw_memset(&group_id, 0x00, sizeof(struct group_id_info)); + rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_ID, (u8 *)&group_id, &attr_contentlen); + if (attr_contentlen) { + if (_rtw_memcmp(group_id.go_device_addr, myid(&padapter->eeprompriv), ETH_ALEN)) { + /* The p2p device sending this p2p invitation request wants this Wi-Fi device to be the persistent GO. */ + rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_GO); + rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); + status_code = P2P_STATUS_SUCCESS; + } else { + /* The p2p device sending this p2p invitation request wants to be the persistent GO. */ + if (is_matched_in_profilelist(pwdinfo->p2p_peer_interface_addr, &pwdinfo->profileinfo[0])) { + u8 operatingch_info[5] = { 0x00 }; + if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_OPERATING_CH, operatingch_info, &attr_contentlen)) { + if (rtw_ch_set_search_ch(padapter->mlmeextpriv.channel_set, (u32)operatingch_info[4])) { + /* The operating channel is acceptable for this device. */ + pwdinfo->rx_invitereq_info.operation_ch[0] = operatingch_info[4]; + pwdinfo->rx_invitereq_info.scan_op_ch_only = 1; + _set_timer(&pwdinfo->reset_ch_sitesurvey, P2P_RESET_SCAN_CH); + rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_MATCH); + rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); + status_code = P2P_STATUS_SUCCESS; + } else { + /* The operating channel isn't supported by this device. */ + rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_DISMATCH); + rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); + status_code = P2P_STATUS_FAIL_NO_COMMON_CH; + _set_timer(&pwdinfo->restore_p2p_state_timer, 3000); + } + } else { + /* Commented by Albert 20121130 */ + /* Intel will use the different P2P IE to store the operating channel information */ + /* Workaround for Intel WiDi 3.5 */ + rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_MATCH); + rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); + status_code = P2P_STATUS_SUCCESS; + } + } else { + rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_DISMATCH); + status_code = P2P_STATUS_FAIL_UNKNOWN_P2PGROUP; + } + } + } else { + DBG_88E("[%s] P2P Group ID Attribute NOT FOUND!\n", __func__); + status_code = P2P_STATUS_FAIL_INFO_UNAVAILABLE; + } + } else { + /* Received the invitation to join a P2P group. */ + + _rtw_memset(&group_id, 0x00, sizeof(struct group_id_info)); + rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_ID, (u8 *)&group_id, &attr_contentlen); + if (attr_contentlen) { + if (_rtw_memcmp(group_id.go_device_addr, myid(&padapter->eeprompriv), ETH_ALEN)) { + /* In this case, the GO can't be myself. */ + rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_DISMATCH); + status_code = P2P_STATUS_FAIL_INFO_UNAVAILABLE; + } else { + /* The p2p device sending this p2p invitation request wants to join an existing P2P group */ + /* Commented by Albert 2012/06/28 */ + /* In this case, this Wi-Fi device should use the iwpriv command to get the peer device address. */ + /* The peer device address should be the destination address for the provisioning discovery request. */ + /* Then, this Wi-Fi device should use the iwpriv command to get the peer interface address. */ + /* The peer interface address should be the address for WPS mac address */ + memcpy(pwdinfo->p2p_peer_device_addr, group_id.go_device_addr , ETH_ALEN); + rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); + rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_JOIN); + status_code = P2P_STATUS_SUCCESS; + } + } else { + DBG_88E("[%s] P2P Group ID Attribute NOT FOUND!\n", __func__); + status_code = P2P_STATUS_FAIL_INFO_UNAVAILABLE; + } + } + } else { + DBG_88E("[%s] P2P Invitation Flags Attribute NOT FOUND!\n", __func__); + status_code = P2P_STATUS_FAIL_INFO_UNAVAILABLE; + } + + DBG_88E("[%s] status_code = %d\n", __func__, status_code); + + pwdinfo->inviteresp_info.token = frame_body[7]; + issue_p2p_invitation_response(padapter, GetAddr2Ptr(pframe), pwdinfo->inviteresp_info.token, status_code); + } + break; + case P2P_INVIT_RESP: { + u8 attr_content = 0x00; + u32 attr_contentlen = 0; + + DBG_88E("[%s] Got invite response frame!\n", __func__); + _cancel_timer_ex(&pwdinfo->restore_p2p_state_timer); + p2p_ie = rtw_get_p2p_ie(frame_body + _PUBLIC_ACTION_IE_OFFSET_, len - _PUBLIC_ACTION_IE_OFFSET_, NULL, &p2p_ielen); + if (p2p_ie) { + rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_STATUS, &attr_content, &attr_contentlen); + + if (attr_contentlen == 1) { + DBG_88E("[%s] Status = %d\n", __func__, attr_content); + pwdinfo->invitereq_info.benable = false; + + if (attr_content == P2P_STATUS_SUCCESS) { + if (_rtw_memcmp(pwdinfo->invitereq_info.go_bssid, myid(&padapter->eeprompriv), ETH_ALEN)) { + rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); + } else { + rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); + } + rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_INVITE_RESP_OK); + } else { + rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); + rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_INVITE_RESP_FAIL); + } + } else { + rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); + rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_INVITE_RESP_FAIL); + } + } else { + rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); + rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_INVITE_RESP_FAIL); + } + + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_RX_INVITE_RESP_FAIL)) + _set_timer(&pwdinfo->restore_p2p_state_timer, 5000); + break; + } + case P2P_DEVDISC_REQ: + process_p2p_devdisc_req(pwdinfo, pframe, len); + break; + case P2P_DEVDISC_RESP: + process_p2p_devdisc_resp(pwdinfo, pframe, len); + break; + case P2P_PROVISION_DISC_REQ: + DBG_88E("[%s] Got Provisioning Discovery Request Frame\n", __func__); + process_p2p_provdisc_req(pwdinfo, pframe, len); + memcpy(pwdinfo->rx_prov_disc_info.peerDevAddr, GetAddr2Ptr(pframe), ETH_ALEN); + + /* 20110902 Kurt */ + /* Add the following statement to avoid receiving duplicate prov disc req. such that pre_p2p_state would be covered. */ + if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_RX_PROVISION_DIS_REQ)) + rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo)); + + rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_PROVISION_DIS_REQ); + _set_timer(&pwdinfo->restore_p2p_state_timer, P2P_PROVISION_TIMEOUT); + break; + case P2P_PROVISION_DISC_RESP: + /* Commented by Albert 20110707 */ + /* Should we check the pwdinfo->tx_prov_disc_info.bsent flag here?? */ + DBG_88E("[%s] Got Provisioning Discovery Response Frame\n", __func__); + /* Commented by Albert 20110426 */ + /* The restore timer is enabled when issuing the provisioing request frame in rtw_p2p_prov_disc function. */ + _cancel_timer_ex(&pwdinfo->restore_p2p_state_timer); + rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_PROVISION_DIS_RSP); + process_p2p_provdisc_resp(pwdinfo, pframe); + _set_timer(&pwdinfo->restore_p2p_state_timer, P2P_PROVISION_TIMEOUT); + break; + } +#endif /* CONFIG_88EU_P2P */ + + return _SUCCESS; +} + +static unsigned int on_action_public_vendor(union recv_frame *precv_frame) +{ + unsigned int ret = _FAIL; + u8 *pframe = precv_frame->u.hdr.rx_data; + u8 *frame_body = pframe + sizeof(struct rtw_ieee80211_hdr_3addr); + + if (_rtw_memcmp(frame_body + 2, P2P_OUI, 4) == true) { + ret = on_action_public_p2p(precv_frame); + } + + return ret; +} + +static unsigned int on_action_public_default(union recv_frame *precv_frame, u8 action) +{ + unsigned int ret = _FAIL; + u8 *pframe = precv_frame->u.hdr.rx_data; + u8 *frame_body = pframe + sizeof(struct rtw_ieee80211_hdr_3addr); + u8 token; + + token = frame_body[2]; + + if (rtw_action_public_decache(precv_frame, token) == _FAIL) + goto exit; + + ret = _SUCCESS; + +exit: + return ret; +} + +unsigned int on_action_public(struct adapter *padapter, union recv_frame *precv_frame) +{ + unsigned int ret = _FAIL; + u8 *pframe = precv_frame->u.hdr.rx_data; + u8 *frame_body = pframe + sizeof(struct rtw_ieee80211_hdr_3addr); + u8 category, action; + + /* check RA matches or not */ + if (!_rtw_memcmp(myid(&(padapter->eeprompriv)), GetAddr1Ptr(pframe), ETH_ALEN)) + goto exit; + + category = frame_body[0]; + if (category != RTW_WLAN_CATEGORY_PUBLIC) + goto exit; + + action = frame_body[1]; + switch (action) { + case ACT_PUBLIC_VENDOR: + ret = on_action_public_vendor(precv_frame); + break; + default: + ret = on_action_public_default(precv_frame, action); + break; + } + +exit: + return ret; +} + +unsigned int OnAction_ht(struct adapter *padapter, union recv_frame *precv_frame) +{ + return _SUCCESS; +} + +unsigned int OnAction_wmm(struct adapter *padapter, union recv_frame *precv_frame) +{ + return _SUCCESS; +} + +unsigned int OnAction_p2p(struct adapter *padapter, union recv_frame *precv_frame) +{ +#ifdef CONFIG_88EU_P2P + u8 *frame_body; + u8 category, OUI_Subtype; + u8 *pframe = precv_frame->u.hdr.rx_data; + uint len = precv_frame->u.hdr.len; + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + + + DBG_88E("%s\n", __func__); + + /* check RA matches or not */ + if (!_rtw_memcmp(myid(&(padapter->eeprompriv)), GetAddr1Ptr(pframe), ETH_ALEN))/* for if1, sta/ap mode */ + return _SUCCESS; + + frame_body = (unsigned char *)(pframe + sizeof(struct rtw_ieee80211_hdr_3addr)); + + category = frame_body[0]; + if (category != RTW_WLAN_CATEGORY_P2P) + return _SUCCESS; + + if (be32_to_cpu(*((__be32 *)(frame_body + 1))) != P2POUI) + return _SUCCESS; + + len -= sizeof(struct rtw_ieee80211_hdr_3addr); + OUI_Subtype = frame_body[5]; + + switch (OUI_Subtype) { + case P2P_NOTICE_OF_ABSENCE: + break; + case P2P_PRESENCE_REQUEST: + process_p2p_presence_req(pwdinfo, pframe, len); + break; + case P2P_PRESENCE_RESPONSE: + break; + case P2P_GO_DISC_REQUEST: + break; + default: + break; + } +#endif /* CONFIG_88EU_P2P */ + return _SUCCESS; +} + +unsigned int OnAction(struct adapter *padapter, union recv_frame *precv_frame) +{ + int i; + unsigned char category; + struct action_handler *ptable; + unsigned char *frame_body; + u8 *pframe = precv_frame->u.hdr.rx_data; + + frame_body = (unsigned char *)(pframe + sizeof(struct rtw_ieee80211_hdr_3addr)); + + category = frame_body[0]; + + for (i = 0; i < sizeof(OnAction_tbl)/sizeof(struct action_handler); i++) { + ptable = &OnAction_tbl[i]; + if (category == ptable->num) + ptable->func(padapter, precv_frame); + } + return _SUCCESS; +} + +unsigned int DoReserved(struct adapter *padapter, union recv_frame *precv_frame) +{ + return _SUCCESS; +} + +struct xmit_frame *alloc_mgtxmitframe(struct xmit_priv *pxmitpriv) +{ + struct xmit_frame *pmgntframe; + struct xmit_buf *pxmitbuf; + + pmgntframe = rtw_alloc_xmitframe(pxmitpriv); + if (pmgntframe == NULL) { + DBG_88E("%s, alloc xmitframe fail\n", __func__); + return NULL; + } + + pxmitbuf = rtw_alloc_xmitbuf_ext(pxmitpriv); + if (pxmitbuf == NULL) { + DBG_88E("%s, alloc xmitbuf fail\n", __func__); + rtw_free_xmitframe(pxmitpriv, pmgntframe); + return NULL; + } + pmgntframe->frame_tag = MGNT_FRAMETAG; + pmgntframe->pxmitbuf = pxmitbuf; + pmgntframe->buf_addr = pxmitbuf->pbuf; + pxmitbuf->priv_data = pmgntframe; + return pmgntframe; +} + +/**************************************************************************** + +Following are some TX fuctions for WiFi MLME + +*****************************************************************************/ + +void update_mgnt_tx_rate(struct adapter *padapter, u8 rate) +{ + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + + pmlmeext->tx_rate = rate; + DBG_88E("%s(): rate = %x\n", __func__, rate); +} + +void update_mgntframe_attrib(struct adapter *padapter, struct pkt_attrib *pattrib) +{ + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + + _rtw_memset((u8 *)(pattrib), 0, sizeof(struct pkt_attrib)); + + pattrib->hdrlen = 24; + pattrib->nr_frags = 1; + pattrib->priority = 7; + pattrib->mac_id = 0; + pattrib->qsel = 0x12; + + pattrib->pktlen = 0; + + if (pmlmeext->cur_wireless_mode & WIRELESS_11B) + pattrib->raid = 6;/* b mode */ + else + pattrib->raid = 5;/* a/g mode */ + + pattrib->encrypt = _NO_PRIVACY_; + pattrib->bswenc = false; + + pattrib->qos_en = false; + pattrib->ht_en = false; + pattrib->bwmode = HT_CHANNEL_WIDTH_20; + pattrib->ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; + pattrib->sgi = false; + + pattrib->seqnum = pmlmeext->mgnt_seq; + + pattrib->retry_ctrl = true; +} + +void dump_mgntframe(struct adapter *padapter, struct xmit_frame *pmgntframe) +{ + if (padapter->bSurpriseRemoved || padapter->bDriverStopped) + return; + + rtw_hal_mgnt_xmit(padapter, pmgntframe); +} + +s32 dump_mgntframe_and_wait(struct adapter *padapter, struct xmit_frame *pmgntframe, int timeout_ms) +{ + s32 ret = _FAIL; + struct xmit_buf *pxmitbuf = pmgntframe->pxmitbuf; + struct submit_ctx sctx; + + if (padapter->bSurpriseRemoved || padapter->bDriverStopped) + return ret; + + rtw_sctx_init(&sctx, timeout_ms); + pxmitbuf->sctx = &sctx; + + ret = rtw_hal_mgnt_xmit(padapter, pmgntframe); + + if (ret == _SUCCESS) + ret = rtw_sctx_wait(&sctx); + + return ret; +} + +s32 dump_mgntframe_and_wait_ack(struct adapter *padapter, struct xmit_frame *pmgntframe) +{ + s32 ret = _FAIL; + u32 timeout_ms = 500;/* 500ms */ + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + + if (padapter->bSurpriseRemoved || padapter->bDriverStopped) + return -1; + + _enter_critical_mutex(&pxmitpriv->ack_tx_mutex, NULL); + pxmitpriv->ack_tx = true; + + pmgntframe->ack_report = 1; + if (rtw_hal_mgnt_xmit(padapter, pmgntframe) == _SUCCESS) { + ret = rtw_ack_tx_wait(pxmitpriv, timeout_ms); + } + + pxmitpriv->ack_tx = false; + _exit_critical_mutex(&pxmitpriv->ack_tx_mutex, NULL); + + return ret; +} + +static int update_hidden_ssid(u8 *ies, u32 ies_len, u8 hidden_ssid_mode) +{ + u8 *ssid_ie; + int ssid_len_ori; + int len_diff = 0; + + ssid_ie = rtw_get_ie(ies, WLAN_EID_SSID, &ssid_len_ori, ies_len); + + if (ssid_ie && ssid_len_ori > 0) { + switch (hidden_ssid_mode) { + case 1: { + u8 *next_ie = ssid_ie + 2 + ssid_len_ori; + u32 remain_len = 0; + + remain_len = ies_len - (next_ie - ies); + + ssid_ie[1] = 0; + memcpy(ssid_ie+2, next_ie, remain_len); + len_diff -= ssid_len_ori; + + break; + } + case 2: + _rtw_memset(&ssid_ie[2], 0, ssid_len_ori); + break; + default: + break; + } + } + + return len_diff; +} + +void issue_beacon(struct adapter *padapter, int timeout_ms) +{ + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; + struct rtw_ieee80211_hdr *pwlanhdr; + unsigned short *fctrl; + unsigned int rate_len; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); +#if defined(CONFIG_88EU_AP_MODE) + unsigned long irqL; +#endif /* if defined (CONFIG_88EU_AP_MODE) */ + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); + u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); +#endif /* CONFIG_88EU_P2P */ + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) { + DBG_88E("%s, alloc mgnt frame fail\n", __func__); + return; + } +#if defined (CONFIG_88EU_AP_MODE) + _enter_critical_bh(&pmlmepriv->bcn_update_lock, &irqL); +#endif /* if defined (CONFIG_88EU_AP_MODE) */ + + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + pattrib->qsel = 0x10; + + _rtw_memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + + memcpy(pwlanhdr->addr1, bc_addr, ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr3, get_my_bssid(cur_network), ETH_ALEN); + + SetSeqNum(pwlanhdr, 0/*pmlmeext->mgnt_seq*/); + /* pmlmeext->mgnt_seq++; */ + SetFrameSubType(pframe, WIFI_BEACON); + + pframe += sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof (struct rtw_ieee80211_hdr_3addr); + + if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) { +#ifdef CONFIG_88EU_P2P + /* for P2P : Primary Device Type & Device Name */ + u32 wpsielen = 0, insert_len = 0; + u8 *wpsie = NULL; + wpsie = rtw_get_wps_ie(cur_network->IEs+_FIXED_IE_LENGTH_, cur_network->IELength-_FIXED_IE_LENGTH_, NULL, &wpsielen); + + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO) && wpsie && wpsielen > 0) { + uint wps_offset, remainder_ielen; + u8 *premainder_ie, *pframe_wscie; + + wps_offset = (uint)(wpsie - cur_network->IEs); + premainder_ie = wpsie + wpsielen; + remainder_ielen = cur_network->IELength - wps_offset - wpsielen; + pframe_wscie = pframe + wps_offset; + memcpy(pframe, cur_network->IEs, wps_offset+wpsielen); + pframe += (wps_offset + wpsielen); + pattrib->pktlen += (wps_offset + wpsielen); + + /* now pframe is end of wsc ie, insert Primary Device Type & Device Name */ + /* Primary Device Type */ + /* Type: */ + *(__be16 *)(pframe + insert_len) = cpu_to_be16(WPS_ATTR_PRIMARY_DEV_TYPE); + insert_len += 2; + + /* Length: */ + *(__be16 *)(pframe + insert_len) = cpu_to_be16(0x0008); + insert_len += 2; + + /* Value: */ + /* Category ID */ + *(__be16 *)(pframe + insert_len) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); + insert_len += 2; + + /* OUI */ + *(__be32 *)(pframe + insert_len) = cpu_to_be32(WPSOUI); + insert_len += 4; + + /* Sub Category ID */ + *(__be16 *)(pframe + insert_len) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); + insert_len += 2; + + /* Device Name */ + /* Type: */ + *(__be16 *)(pframe + insert_len) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); + insert_len += 2; + + /* Length: */ + *(__be16 *)(pframe + insert_len) = cpu_to_be16(pwdinfo->device_name_len); + insert_len += 2; + + /* Value: */ + memcpy(pframe + insert_len, pwdinfo->device_name, pwdinfo->device_name_len); + insert_len += pwdinfo->device_name_len; + + /* update wsc ie length */ + *(pframe_wscie+1) = (wpsielen-2) + insert_len; + + /* pframe move to end */ + pframe += insert_len; + pattrib->pktlen += insert_len; + + /* copy remainder_ie to pframe */ + memcpy(pframe, premainder_ie, remainder_ielen); + pframe += remainder_ielen; + pattrib->pktlen += remainder_ielen; + } else +#endif /* CONFIG_88EU_P2P */ + { + int len_diff; + memcpy(pframe, cur_network->IEs, cur_network->IELength); + len_diff = update_hidden_ssid( + pframe+_BEACON_IE_OFFSET_ + , cur_network->IELength-_BEACON_IE_OFFSET_ + , pmlmeinfo->hidden_ssid_mode + ); + pframe += (cur_network->IELength+len_diff); + pattrib->pktlen += (cur_network->IELength+len_diff); + } + + { + u8 *wps_ie; + uint wps_ielen; + u8 sr = 0; + wps_ie = rtw_get_wps_ie(pmgntframe->buf_addr+TXDESC_OFFSET+sizeof (struct rtw_ieee80211_hdr_3addr)+_BEACON_IE_OFFSET_, + pattrib->pktlen-sizeof (struct rtw_ieee80211_hdr_3addr)-_BEACON_IE_OFFSET_, NULL, &wps_ielen); + if (wps_ie && wps_ielen > 0) + rtw_get_wps_attr_content(wps_ie, wps_ielen, WPS_ATTR_SELECTED_REGISTRAR, (u8 *)(&sr), NULL); + if (sr != 0) + set_fwstate(pmlmepriv, WIFI_UNDER_WPS); + else + _clr_fwstate_(pmlmepriv, WIFI_UNDER_WPS); + } + +#ifdef CONFIG_88EU_P2P + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { + u32 len; + len = build_beacon_p2p_ie(pwdinfo, pframe); + + pframe += len; + pattrib->pktlen += len; + } +#endif /* CONFIG_88EU_P2P */ + + goto _issue_bcn; + } + + /* below for ad-hoc mode */ + + /* timestamp will be inserted by hardware */ + pframe += 8; + pattrib->pktlen += 8; + + /* beacon interval: 2 bytes */ + + memcpy(pframe, (unsigned char *)(rtw_get_beacon_interval_from_ie(cur_network->IEs)), 2); + + pframe += 2; + pattrib->pktlen += 2; + + /* capability info: 2 bytes */ + + memcpy(pframe, (unsigned char *)(rtw_get_capability_from_ie(cur_network->IEs)), 2); + + pframe += 2; + pattrib->pktlen += 2; + + /* SSID */ + pframe = rtw_set_ie(pframe, _SSID_IE_, cur_network->Ssid.SsidLength, cur_network->Ssid.Ssid, &pattrib->pktlen); + + /* supported rates... */ + rate_len = rtw_get_rateset_len(cur_network->SupportedRates); + pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, ((rate_len > 8) ? 8 : rate_len), cur_network->SupportedRates, &pattrib->pktlen); + + /* DS parameter set */ + pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&(cur_network->Configuration.DSConfig), &pattrib->pktlen); + + { + u8 erpinfo = 0; + u32 ATIMWindow; + /* IBSS Parameter Set... */ + ATIMWindow = 0; + pframe = rtw_set_ie(pframe, _IBSS_PARA_IE_, 2, (unsigned char *)(&ATIMWindow), &pattrib->pktlen); + + /* ERP IE */ + pframe = rtw_set_ie(pframe, _ERPINFO_IE_, 1, &erpinfo, &pattrib->pktlen); + } + + /* EXTERNDED SUPPORTED RATE */ + if (rate_len > 8) + pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (rate_len - 8), (cur_network->SupportedRates + 8), &pattrib->pktlen); + /* todo:HT for adhoc */ +_issue_bcn: + +#if defined (CONFIG_88EU_AP_MODE) + pmlmepriv->update_bcn = false; + + _exit_critical_bh(&pmlmepriv->bcn_update_lock, &irqL); +#endif /* if defined (CONFIG_88EU_AP_MODE) */ + + if ((pattrib->pktlen + TXDESC_SIZE) > 512) { + DBG_88E("beacon frame too large\n"); + return; + } + + pattrib->last_txcmdsz = pattrib->pktlen; + + /* DBG_88E("issue bcn_sz=%d\n", pattrib->last_txcmdsz); */ + if (timeout_ms > 0) + dump_mgntframe_and_wait(padapter, pmgntframe, timeout_ms); + else + dump_mgntframe(padapter, pmgntframe); +} + +void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p_probereq) +{ + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; + struct rtw_ieee80211_hdr *pwlanhdr; + unsigned short *fctrl; + unsigned char *mac, *bssid; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); +#if defined (CONFIG_88EU_AP_MODE) + u8 *pwps_ie; + uint wps_ielen; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; +#endif /* if defined (CONFIG_88EU_AP_MODE) */ + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); + unsigned int rate_len; +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); +#endif /* CONFIG_88EU_P2P */ + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) { + DBG_88E("%s, alloc mgnt frame fail\n", __func__); + return; + } + + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + + _rtw_memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + mac = myid(&(padapter->eeprompriv)); + bssid = cur_network->MacAddress; + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + memcpy(pwlanhdr->addr1, da, ETH_ALEN); + memcpy(pwlanhdr->addr2, mac, ETH_ALEN); + memcpy(pwlanhdr->addr3, bssid, ETH_ALEN); + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + SetFrameSubType(fctrl, WIFI_PROBERSP); + + pattrib->hdrlen = sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = pattrib->hdrlen; + pframe += pattrib->hdrlen; + + if (cur_network->IELength > MAX_IE_SZ) + return; + +#if defined(CONFIG_88EU_AP_MODE) + if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) { + pwps_ie = rtw_get_wps_ie(cur_network->IEs+_FIXED_IE_LENGTH_, cur_network->IELength-_FIXED_IE_LENGTH_, NULL, &wps_ielen); + + /* inerset & update wps_probe_resp_ie */ + if ((pmlmepriv->wps_probe_resp_ie != NULL) && pwps_ie && (wps_ielen > 0)) { + uint wps_offset, remainder_ielen; + u8 *premainder_ie; + + wps_offset = (uint)(pwps_ie - cur_network->IEs); + + premainder_ie = pwps_ie + wps_ielen; + + remainder_ielen = cur_network->IELength - wps_offset - wps_ielen; + + memcpy(pframe, cur_network->IEs, wps_offset); + pframe += wps_offset; + pattrib->pktlen += wps_offset; + + wps_ielen = (uint)pmlmepriv->wps_probe_resp_ie[1];/* to get ie data len */ + if ((wps_offset+wps_ielen+2) <= MAX_IE_SZ) { + memcpy(pframe, pmlmepriv->wps_probe_resp_ie, wps_ielen+2); + pframe += wps_ielen+2; + pattrib->pktlen += wps_ielen+2; + } + + if ((wps_offset+wps_ielen+2+remainder_ielen) <= MAX_IE_SZ) { + memcpy(pframe, premainder_ie, remainder_ielen); + pframe += remainder_ielen; + pattrib->pktlen += remainder_ielen; + } + } else { + memcpy(pframe, cur_network->IEs, cur_network->IELength); + pframe += cur_network->IELength; + pattrib->pktlen += cur_network->IELength; + } + } else +#endif + { + /* timestamp will be inserted by hardware */ + pframe += 8; + pattrib->pktlen += 8; + + /* beacon interval: 2 bytes */ + + memcpy(pframe, (unsigned char *)(rtw_get_beacon_interval_from_ie(cur_network->IEs)), 2); + + pframe += 2; + pattrib->pktlen += 2; + + /* capability info: 2 bytes */ + + memcpy(pframe, (unsigned char *)(rtw_get_capability_from_ie(cur_network->IEs)), 2); + + pframe += 2; + pattrib->pktlen += 2; + + /* below for ad-hoc mode */ + + /* SSID */ + pframe = rtw_set_ie(pframe, _SSID_IE_, cur_network->Ssid.SsidLength, cur_network->Ssid.Ssid, &pattrib->pktlen); + + /* supported rates... */ + rate_len = rtw_get_rateset_len(cur_network->SupportedRates); + pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, ((rate_len > 8) ? 8 : rate_len), cur_network->SupportedRates, &pattrib->pktlen); + + /* DS parameter set */ + pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&(cur_network->Configuration.DSConfig), &pattrib->pktlen); + + if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { + u8 erpinfo = 0; + u32 ATIMWindow; + /* IBSS Parameter Set... */ + /* ATIMWindow = cur->Configuration.ATIMWindow; */ + ATIMWindow = 0; + pframe = rtw_set_ie(pframe, _IBSS_PARA_IE_, 2, (unsigned char *)(&ATIMWindow), &pattrib->pktlen); + + /* ERP IE */ + pframe = rtw_set_ie(pframe, _ERPINFO_IE_, 1, &erpinfo, &pattrib->pktlen); + } + + + /* EXTERNDED SUPPORTED RATE */ + if (rate_len > 8) + pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (rate_len - 8), (cur_network->SupportedRates + 8), &pattrib->pktlen); + /* todo:HT for adhoc */ + } + +#ifdef CONFIG_88EU_P2P + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO) && is_valid_p2p_probereq) { + u32 len; + len = build_probe_resp_p2p_ie(pwdinfo, pframe); + + pframe += len; + pattrib->pktlen += len; + } +#endif /* CONFIG_88EU_P2P */ + + pattrib->last_txcmdsz = pattrib->pktlen; + + dump_mgntframe(padapter, pmgntframe); + + return; +} + +static int _issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da, int wait_ack) +{ + int ret = _FAIL; + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; + struct rtw_ieee80211_hdr *pwlanhdr; + unsigned short *fctrl; + unsigned char *mac; + unsigned char bssrate[NumRates]; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + int bssrate_len = 0; + u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, ("+issue_probereq\n")); + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + goto exit; + + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + + + _rtw_memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + mac = myid(&(padapter->eeprompriv)); + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + + if (da) { + /* unicast probe request frame */ + memcpy(pwlanhdr->addr1, da, ETH_ALEN); + memcpy(pwlanhdr->addr3, da, ETH_ALEN); + } else { + /* broadcast probe request frame */ + memcpy(pwlanhdr->addr1, bc_addr, ETH_ALEN); + memcpy(pwlanhdr->addr3, bc_addr, ETH_ALEN); + } + + memcpy(pwlanhdr->addr2, mac, ETH_ALEN); + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + SetFrameSubType(pframe, WIFI_PROBEREQ); + + pframe += sizeof (struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof (struct rtw_ieee80211_hdr_3addr); + + if (pssid) + pframe = rtw_set_ie(pframe, _SSID_IE_, pssid->SsidLength, pssid->Ssid, &(pattrib->pktlen)); + else + pframe = rtw_set_ie(pframe, _SSID_IE_, 0, NULL, &(pattrib->pktlen)); + + get_rate_set(padapter, bssrate, &bssrate_len); + + if (bssrate_len > 8) { + pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_ , 8, bssrate, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_ , (bssrate_len - 8), (bssrate + 8), &(pattrib->pktlen)); + } else { + pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_ , bssrate_len , bssrate, &(pattrib->pktlen)); + } + + /* add wps_ie for wps2.0 */ + if (pmlmepriv->wps_probe_req_ie_len > 0 && pmlmepriv->wps_probe_req_ie) { + memcpy(pframe, pmlmepriv->wps_probe_req_ie, pmlmepriv->wps_probe_req_ie_len); + pframe += pmlmepriv->wps_probe_req_ie_len; + pattrib->pktlen += pmlmepriv->wps_probe_req_ie_len; + } + + pattrib->last_txcmdsz = pattrib->pktlen; + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, + ("issuing probe_req, tx_len=%d\n", pattrib->last_txcmdsz)); + + if (wait_ack) { + ret = dump_mgntframe_and_wait_ack(padapter, pmgntframe); + } else { + dump_mgntframe(padapter, pmgntframe); + ret = _SUCCESS; + } + +exit: + return ret; +} + +inline void issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da) +{ + _issue_probereq(padapter, pssid, da, false); +} + +int issue_probereq_ex(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da, + int try_cnt, int wait_ms) +{ + int ret; + int i = 0; + u32 start = rtw_get_current_time(); + + do { + ret = _issue_probereq(padapter, pssid, da, wait_ms > 0 ? true : false); + + i++; + + if (padapter->bDriverStopped || padapter->bSurpriseRemoved) + break; + + if (i < try_cnt && wait_ms > 0 && ret == _FAIL) + rtw_msleep_os(wait_ms); + + } while ((i < try_cnt) && ((ret == _FAIL) || (wait_ms == 0))); + + if (ret != _FAIL) { + ret = _SUCCESS; + goto exit; + } + + if (try_cnt && wait_ms) { + if (da) + DBG_88E(FUNC_ADPT_FMT" to %pM, ch:%u%s, %d/%d in %u ms\n", + FUNC_ADPT_ARG(padapter), da, rtw_get_oper_ch(padapter), + ret == _SUCCESS ? ", acked" : "", i, try_cnt, rtw_get_passing_time_ms(start)); + else + DBG_88E(FUNC_ADPT_FMT", ch:%u%s, %d/%d in %u ms\n", + FUNC_ADPT_ARG(padapter), rtw_get_oper_ch(padapter), + ret == _SUCCESS ? ", acked" : "", i, try_cnt, rtw_get_passing_time_ms(start)); + } +exit: + return ret; +} + +/* if psta == NULL, indiate we are station(client) now... */ +void issue_auth(struct adapter *padapter, struct sta_info *psta, unsigned short status) +{ + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; + struct rtw_ieee80211_hdr *pwlanhdr; + unsigned short *fctrl; + unsigned int val32; + u16 val16; +#ifdef CONFIG_88EU_AP_MODE + __le16 le_val16; +#endif + int use_shared_key = 0; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + return; + + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + + _rtw_memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + SetFrameSubType(pframe, WIFI_AUTH); + + pframe += sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); + + + if (psta) {/* for AP mode */ +#ifdef CONFIG_88EU_AP_MODE + + memcpy(pwlanhdr->addr1, psta->hwaddr, ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr3, myid(&(padapter->eeprompriv)), ETH_ALEN); + + + /* setting auth algo number */ + val16 = (u16)psta->authalg; + + if (status != _STATS_SUCCESSFUL_) + val16 = 0; + + if (val16) { + le_val16 = cpu_to_le16(val16); + use_shared_key = 1; + } else { + le_val16 = 0; + } + + pframe = rtw_set_fixed_ie(pframe, _AUTH_ALGM_NUM_, (unsigned char *)&le_val16, &(pattrib->pktlen)); + + /* setting auth seq number */ + val16 = (u16)psta->auth_seq; + le_val16 = cpu_to_le16(val16); + pframe = rtw_set_fixed_ie(pframe, _AUTH_SEQ_NUM_, (unsigned char *)&le_val16, &(pattrib->pktlen)); + + /* setting status code... */ + val16 = status; + le_val16 = cpu_to_le16(val16); + pframe = rtw_set_fixed_ie(pframe, _STATUS_CODE_, (unsigned char *)&le_val16, &(pattrib->pktlen)); + + /* added challenging text... */ + if ((psta->auth_seq == 2) && (psta->state & WIFI_FW_AUTH_STATE) && (use_shared_key == 1)) + pframe = rtw_set_ie(pframe, _CHLGETXT_IE_, 128, psta->chg_txt, &(pattrib->pktlen)); +#endif + } else { + __le32 le_tmp32; + __le16 le_tmp16; + memcpy(pwlanhdr->addr1, get_my_bssid(&pmlmeinfo->network), ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN); + memcpy(pwlanhdr->addr3, get_my_bssid(&pmlmeinfo->network), ETH_ALEN); + + /* setting auth algo number */ + val16 = (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) ? 1 : 0;/* 0:OPEN System, 1:Shared key */ + if (val16) + use_shared_key = 1; + + /* setting IV for auth seq #3 */ + if ((pmlmeinfo->auth_seq == 3) && (pmlmeinfo->state & WIFI_FW_AUTH_STATE) && (use_shared_key == 1)) { + val32 = ((pmlmeinfo->iv++) | (pmlmeinfo->key_index << 30)); + le_tmp32 = cpu_to_le32(val32); + pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&le_tmp32, &(pattrib->pktlen)); + + pattrib->iv_len = 4; + } + + le_tmp16 = cpu_to_le16(val16); + pframe = rtw_set_fixed_ie(pframe, _AUTH_ALGM_NUM_, (unsigned char *)&le_tmp16, &(pattrib->pktlen)); + + /* setting auth seq number */ + val16 = pmlmeinfo->auth_seq; + le_tmp16 = cpu_to_le16(val16); + pframe = rtw_set_fixed_ie(pframe, _AUTH_SEQ_NUM_, (unsigned char *)&le_tmp16, &(pattrib->pktlen)); + + + /* setting status code... */ + le_tmp16 = cpu_to_le16(status); + pframe = rtw_set_fixed_ie(pframe, _STATUS_CODE_, (unsigned char *)&le_tmp16, &(pattrib->pktlen)); + + /* then checking to see if sending challenging text... */ + if ((pmlmeinfo->auth_seq == 3) && (pmlmeinfo->state & WIFI_FW_AUTH_STATE) && (use_shared_key == 1)) { + pframe = rtw_set_ie(pframe, _CHLGETXT_IE_, 128, pmlmeinfo->chg_txt, &(pattrib->pktlen)); + + SetPrivacy(fctrl); + + pattrib->hdrlen = sizeof(struct rtw_ieee80211_hdr_3addr); + + pattrib->encrypt = _WEP40_; + + pattrib->icv_len = 4; + + pattrib->pktlen += pattrib->icv_len; + } + } + + pattrib->last_txcmdsz = pattrib->pktlen; + + rtw_wep_encrypt(padapter, (u8 *)pmgntframe); + DBG_88E("%s\n", __func__); + dump_mgntframe(padapter, pmgntframe); + + return; +} + + +void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_info *pstat, int pkt_type) +{ +#ifdef CONFIG_88EU_AP_MODE + struct xmit_frame *pmgntframe; + struct rtw_ieee80211_hdr *pwlanhdr; + struct pkt_attrib *pattrib; + unsigned char *pbuf, *pframe; + unsigned short val; + unsigned short *fctrl; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); + u8 *ie = pnetwork->IEs; + __le16 lestatus, leval; +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); +#endif /* CONFIG_88EU_P2P */ + + DBG_88E("%s\n", __func__); + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + return; + + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + + + _rtw_memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + + memcpy((void *)GetAddr1Ptr(pwlanhdr), pstat->hwaddr, ETH_ALEN); + memcpy((void *)GetAddr2Ptr(pwlanhdr), myid(&(padapter->eeprompriv)), ETH_ALEN); + memcpy((void *)GetAddr3Ptr(pwlanhdr), get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); + + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + if ((pkt_type == WIFI_ASSOCRSP) || (pkt_type == WIFI_REASSOCRSP)) + SetFrameSubType(pwlanhdr, pkt_type); + else + return; + + pattrib->hdrlen = sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen += pattrib->hdrlen; + pframe += pattrib->hdrlen; + + /* capability */ + val = *(unsigned short *)rtw_get_capability_from_ie(ie); + + pframe = rtw_set_fixed_ie(pframe, _CAPABILITY_ , (unsigned char *)&val, &(pattrib->pktlen)); + + lestatus = cpu_to_le16(status); + pframe = rtw_set_fixed_ie(pframe , _STATUS_CODE_ , (unsigned char *)&lestatus, &(pattrib->pktlen)); + + leval = cpu_to_le16(pstat->aid | BIT(14) | BIT(15)); + pframe = rtw_set_fixed_ie(pframe, _ASOC_ID_ , (unsigned char *)&leval, &(pattrib->pktlen)); + + if (pstat->bssratelen <= 8) { + pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, pstat->bssratelen, pstat->bssrateset, &(pattrib->pktlen)); + } else { + pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, 8, pstat->bssrateset, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (pstat->bssratelen-8), pstat->bssrateset+8, &(pattrib->pktlen)); + } + + if ((pstat->flags & WLAN_STA_HT) && (pmlmepriv->htpriv.ht_option)) { + uint ie_len = 0; + + /* FILL HT CAP INFO IE */ + pbuf = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _HT_CAPABILITY_IE_, &ie_len, (pnetwork->IELength - _BEACON_IE_OFFSET_)); + if (pbuf && ie_len > 0) { + memcpy(pframe, pbuf, ie_len+2); + pframe += (ie_len+2); + pattrib->pktlen += (ie_len+2); + } + + /* FILL HT ADD INFO IE */ + pbuf = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _HT_ADD_INFO_IE_, &ie_len, (pnetwork->IELength - _BEACON_IE_OFFSET_)); + if (pbuf && ie_len > 0) { + memcpy(pframe, pbuf, ie_len+2); + pframe += (ie_len+2); + pattrib->pktlen += (ie_len+2); + } + } + + /* FILL WMM IE */ + if ((pstat->flags & WLAN_STA_WME) && (pmlmepriv->qospriv.qos_option)) { + uint ie_len = 0; + unsigned char WMM_PARA_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x01, 0x01}; + + for (pbuf = ie + _BEACON_IE_OFFSET_;; pbuf += (ie_len + 2)) { + pbuf = rtw_get_ie(pbuf, _VENDOR_SPECIFIC_IE_, &ie_len, (pnetwork->IELength - _BEACON_IE_OFFSET_ - (ie_len + 2))); + if (pbuf && _rtw_memcmp(pbuf+2, WMM_PARA_IE, 6)) { + memcpy(pframe, pbuf, ie_len+2); + pframe += (ie_len+2); + pattrib->pktlen += (ie_len+2); + break; + } + + if ((pbuf == NULL) || (ie_len == 0)) + break; + } + } + + if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_REALTEK) + pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, 6 , REALTEK_96B_IE, &(pattrib->pktlen)); + + /* add WPS IE ie for wps 2.0 */ + if (pmlmepriv->wps_assoc_resp_ie && pmlmepriv->wps_assoc_resp_ie_len > 0) { + memcpy(pframe, pmlmepriv->wps_assoc_resp_ie, pmlmepriv->wps_assoc_resp_ie_len); + + pframe += pmlmepriv->wps_assoc_resp_ie_len; + pattrib->pktlen += pmlmepriv->wps_assoc_resp_ie_len; + } + +#ifdef CONFIG_88EU_P2P + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO) && (pstat->is_p2p_device)) { + u32 len; + + len = build_assoc_resp_p2p_ie(pwdinfo, pframe, pstat->p2p_status_code); + + pframe += len; + pattrib->pktlen += len; + } +#endif /* CONFIG_88EU_P2P */ + pattrib->last_txcmdsz = pattrib->pktlen; + dump_mgntframe(padapter, pmgntframe); +#endif +} + +void issue_assocreq(struct adapter *padapter) +{ + int ret = _FAIL; + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe, *p; + struct rtw_ieee80211_hdr *pwlanhdr; + unsigned short *fctrl; + __le16 le_tmp; + unsigned int i, j, ie_len, index = 0; + unsigned char rf_type, bssrate[NumRates], sta_bssrate[NumRates]; + struct ndis_802_11_var_ie *pIE; + struct registry_priv *pregpriv = &padapter->registrypriv; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + int bssrate_len = 0, sta_bssrate_len = 0; +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + u8 p2pie[255] = { 0x00 }; + u16 p2pielen = 0; +#endif /* CONFIG_88EU_P2P */ + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + goto exit; + + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + + _rtw_memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + memcpy(pwlanhdr->addr1, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr3, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + SetFrameSubType(pframe, WIFI_ASSOCREQ); + + pframe += sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); + + /* caps */ + + memcpy(pframe, rtw_get_capability_from_ie(pmlmeinfo->network.IEs), 2); + + pframe += 2; + pattrib->pktlen += 2; + + /* listen interval */ + /* todo: listen interval for power saving */ + le_tmp = cpu_to_le16(3); + memcpy(pframe , (unsigned char *)&le_tmp, 2); + pframe += 2; + pattrib->pktlen += 2; + + /* SSID */ + pframe = rtw_set_ie(pframe, _SSID_IE_, pmlmeinfo->network.Ssid.SsidLength, pmlmeinfo->network.Ssid.Ssid, &(pattrib->pktlen)); + + /* supported rate & extended supported rate */ + + /* Check if the AP's supported rates are also supported by STA. */ + get_rate_set(padapter, sta_bssrate, &sta_bssrate_len); + + if (pmlmeext->cur_channel == 14)/* for JAPAN, channel 14 can only uses B Mode(CCK) */ + sta_bssrate_len = 4; + + for (i = 0; i < NDIS_802_11_LENGTH_RATES_EX; i++) { + if (pmlmeinfo->network.SupportedRates[i] == 0) + break; + DBG_88E("network.SupportedRates[%d]=%02X\n", i, pmlmeinfo->network.SupportedRates[i]); + } + + for (i = 0; i < NDIS_802_11_LENGTH_RATES_EX; i++) { + if (pmlmeinfo->network.SupportedRates[i] == 0) + break; + + /* Check if the AP's supported rates are also supported by STA. */ + for (j = 0; j < sta_bssrate_len; j++) { + /* Avoid the proprietary data rate (22Mbps) of Handlink WSG-4000 AP */ + if ((pmlmeinfo->network.SupportedRates[i]|IEEE80211_BASIC_RATE_MASK) + == (sta_bssrate[j]|IEEE80211_BASIC_RATE_MASK)) + break; + } + + if (j == sta_bssrate_len) { + /* the rate is not supported by STA */ + DBG_88E("%s(): the rate[%d]=%02X is not supported by STA!\n", __func__, i, pmlmeinfo->network.SupportedRates[i]); + } else { + /* the rate is supported by STA */ + bssrate[index++] = pmlmeinfo->network.SupportedRates[i]; + } + } + + bssrate_len = index; + DBG_88E("bssrate_len=%d\n", bssrate_len); + + if (bssrate_len == 0) { + rtw_free_xmitbuf(pxmitpriv, pmgntframe->pxmitbuf); + rtw_free_xmitframe(pxmitpriv, pmgntframe); + goto exit; /* don't connect to AP if no joint supported rate */ + } + + + if (bssrate_len > 8) { + pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_ , 8, bssrate, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_ , (bssrate_len - 8), (bssrate + 8), &(pattrib->pktlen)); + } else { + pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_ , bssrate_len , bssrate, &(pattrib->pktlen)); + } + + /* RSN */ + p = rtw_get_ie((pmlmeinfo->network.IEs + sizeof(struct ndis_802_11_fixed_ie)), _RSN_IE_2_, &ie_len, (pmlmeinfo->network.IELength - sizeof(struct ndis_802_11_fixed_ie))); + if (p != NULL) + pframe = rtw_set_ie(pframe, _RSN_IE_2_, ie_len, (p + 2), &(pattrib->pktlen)); + + /* HT caps */ + if (padapter->mlmepriv.htpriv.ht_option) { + p = rtw_get_ie((pmlmeinfo->network.IEs + sizeof(struct ndis_802_11_fixed_ie)), _HT_CAPABILITY_IE_, &ie_len, (pmlmeinfo->network.IELength - sizeof(struct ndis_802_11_fixed_ie))); + if ((p != NULL) && (!(is_ap_in_tkip(padapter)))) { + memcpy(&(pmlmeinfo->HT_caps), (p + 2), sizeof(struct HT_caps_element)); + + /* to disable 40M Hz support while gd_bw_40MHz_en = 0 */ + if (pregpriv->cbw40_enable == 0) + pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info &= cpu_to_le16(~(BIT(6) | BIT(1))); + else + pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info |= cpu_to_le16(BIT(1)); + + /* todo: disable SM power save mode */ + pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info |= cpu_to_le16(0x000c); + + rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); + switch (rf_type) { + case RF_1T1R: + if (pregpriv->rx_stbc) + pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info |= cpu_to_le16(0x0100);/* RX STBC One spatial stream */ + memcpy(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_rate_1R, 16); + break; + case RF_2T2R: + case RF_1T2R: + default: + if ((pregpriv->rx_stbc == 0x3) ||/* enable for 2.4/5 GHz */ + ((pmlmeext->cur_wireless_mode & WIRELESS_11_24N) && (pregpriv->rx_stbc == 0x1)) || /* enable for 2.4GHz */ + (pregpriv->wifi_spec == 1)) { + DBG_88E("declare supporting RX STBC\n"); + pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info |= cpu_to_le16(0x0200);/* RX STBC two spatial stream */ + } + memcpy(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_rate_2R, 16); + break; + } + pframe = rtw_set_ie(pframe, _HT_CAPABILITY_IE_, ie_len , (u8 *)(&(pmlmeinfo->HT_caps)), &(pattrib->pktlen)); + } + } + + /* vendor specific IE, such as WPA, WMM, WPS */ + for (i = sizeof(struct ndis_802_11_fixed_ie); i < pmlmeinfo->network.IELength;) { + pIE = (struct ndis_802_11_var_ie *)(pmlmeinfo->network.IEs + i); + + switch (pIE->ElementID) { + case _VENDOR_SPECIFIC_IE_: + if ((_rtw_memcmp(pIE->data, RTW_WPA_OUI, 4)) || + (_rtw_memcmp(pIE->data, WMM_OUI, 4)) || + (_rtw_memcmp(pIE->data, WPS_OUI, 4))) { + if (!padapter->registrypriv.wifi_spec) { + /* Commented by Kurt 20110629 */ + /* In some older APs, WPS handshake */ + /* would be fail if we append vender extensions informations to AP */ + if (_rtw_memcmp(pIE->data, WPS_OUI, 4)) + pIE->Length = 14; + } + pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, pIE->Length, pIE->data, &(pattrib->pktlen)); + } + break; + default: + break; + } + i += (pIE->Length + 2); + } + + if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_REALTEK) + pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, 6 , REALTEK_96B_IE, &(pattrib->pktlen)); + +#ifdef CONFIG_88EU_P2P + + if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE) && !rtw_p2p_chk_state(pwdinfo, P2P_STATE_IDLE)) { + /* Should add the P2P IE in the association request frame. */ + /* P2P OUI */ + + p2pielen = 0; + p2pie[p2pielen++] = 0x50; + p2pie[p2pielen++] = 0x6F; + p2pie[p2pielen++] = 0x9A; + p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ + + /* Commented by Albert 20101109 */ + /* According to the P2P Specification, the association request frame should contain 3 P2P attributes */ + /* 1. P2P Capability */ + /* 2. Extended Listen Timing */ + /* 3. Device Info */ + /* Commented by Albert 20110516 */ + /* 4. P2P Interface */ + + /* P2P Capability */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_CAPABILITY; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0002); + p2pielen += 2; + + /* Value: */ + /* Device Capability Bitmap, 1 byte */ + p2pie[p2pielen++] = DMP_P2P_DEVCAP_SUPPORT; + + /* Group Capability Bitmap, 1 byte */ + if (pwdinfo->persistent_supported) + p2pie[p2pielen++] = P2P_GRPCAP_PERSISTENT_GROUP | DMP_P2P_GRPCAP_SUPPORT; + else + p2pie[p2pielen++] = DMP_P2P_GRPCAP_SUPPORT; + + /* Extended Listen Timing */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_EX_LISTEN_TIMING; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0004); + p2pielen += 2; + + /* Value: */ + /* Availability Period */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0xFFFF); + p2pielen += 2; + + /* Availability Interval */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0xFFFF); + p2pielen += 2; + + /* Device Info */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_DEVICE_INFO; + + /* Length: */ + /* 21 -> P2P Device Address (6bytes) + Config Methods (2bytes) + Primary Device Type (8bytes) */ + /* + NumofSecondDevType (1byte) + WPS Device Name ID field (2bytes) + WPS Device Name Len field (2bytes) */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(21 + pwdinfo->device_name_len); + p2pielen += 2; + + /* Value: */ + /* P2P Device Address */ + memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv), ETH_ALEN); + p2pielen += ETH_ALEN; + + /* Config Method */ + /* This field should be big endian. Noted by P2P specification. */ + if ((pwdinfo->ui_got_wps_info == P2P_GOT_WPSINFO_PEER_DISPLAY_PIN) || + (pwdinfo->ui_got_wps_info == P2P_GOT_WPSINFO_SELF_DISPLAY_PIN)) + *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_CONFIG_METHOD_DISPLAY); + else + *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_CONFIG_METHOD_PBC); + + p2pielen += 2; + + /* Primary Device Type */ + /* Category ID */ + *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); + p2pielen += 2; + + /* OUI */ + *(__be32 *)(p2pie + p2pielen) = cpu_to_be32(WPSOUI); + p2pielen += 4; + + /* Sub Category ID */ + *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); + p2pielen += 2; + + /* Number of Secondary Device Types */ + p2pie[p2pielen++] = 0x00; /* No Secondary Device Type List */ + + /* Device Name */ + /* Type: */ + *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); + p2pielen += 2; + + /* Length: */ + *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(pwdinfo->device_name_len); + p2pielen += 2; + + /* Value: */ + memcpy(p2pie + p2pielen, pwdinfo->device_name, pwdinfo->device_name_len); + p2pielen += pwdinfo->device_name_len; + + /* P2P Interface */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_INTERFACE; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x000D); + p2pielen += 2; + + /* Value: */ + memcpy(p2pie + p2pielen, pwdinfo->device_addr, ETH_ALEN); /* P2P Device Address */ + p2pielen += ETH_ALEN; + + p2pie[p2pielen++] = 1; /* P2P Interface Address Count */ + + memcpy(p2pie + p2pielen, pwdinfo->device_addr, ETH_ALEN); /* P2P Interface Address List */ + p2pielen += ETH_ALEN; + + pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &pattrib->pktlen); + } + +#endif /* CONFIG_88EU_P2P */ + + pattrib->last_txcmdsz = pattrib->pktlen; + dump_mgntframe(padapter, pmgntframe); + + ret = _SUCCESS; + +exit: + if (ret == _SUCCESS) + rtw_buf_update(&pmlmepriv->assoc_req, &pmlmepriv->assoc_req_len, (u8 *)pwlanhdr, pattrib->pktlen); + else + rtw_buf_free(&pmlmepriv->assoc_req, &pmlmepriv->assoc_req_len); + + return; +} + +/* when wait_ack is ture, this function shoule be called at process context */ +static int _issue_nulldata(struct adapter *padapter, unsigned char *da, unsigned int power_mode, int wait_ack) +{ + int ret = _FAIL; + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; + struct rtw_ieee80211_hdr *pwlanhdr; + unsigned short *fctrl; + struct xmit_priv *pxmitpriv; + struct mlme_ext_priv *pmlmeext; + struct mlme_ext_info *pmlmeinfo; + + if (!padapter) + goto exit; + + pxmitpriv = &(padapter->xmitpriv); + pmlmeext = &(padapter->mlmeextpriv); + pmlmeinfo = &(pmlmeext->mlmext_info); + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + goto exit; + + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + pattrib->retry_ctrl = false; + + _rtw_memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + + if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) + SetFrDs(fctrl); + else if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) + SetToDs(fctrl); + + if (power_mode) + SetPwrMgt(fctrl); + + memcpy(pwlanhdr->addr1, da, ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr3, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + SetFrameSubType(pframe, WIFI_DATA_NULL); + + pframe += sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); + + pattrib->last_txcmdsz = pattrib->pktlen; + + if (wait_ack) { + ret = dump_mgntframe_and_wait_ack(padapter, pmgntframe); + } else { + dump_mgntframe(padapter, pmgntframe); + ret = _SUCCESS; + } + +exit: + return ret; +} + + +/* when wait_ms > 0 , this function shoule be called at process context */ +/* da == NULL for station mode */ +int issue_nulldata(struct adapter *padapter, unsigned char *da, unsigned int power_mode, int try_cnt, int wait_ms) +{ + int ret; + int i = 0; + u32 start = rtw_get_current_time(); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + /* da == NULL, assum it's null data for sta to ap*/ + if (da == NULL) + da = get_my_bssid(&(pmlmeinfo->network)); + + do { + ret = _issue_nulldata(padapter, da, power_mode, wait_ms > 0 ? true : false); + + i++; + + if (padapter->bDriverStopped || padapter->bSurpriseRemoved) + break; + + if (i < try_cnt && wait_ms > 0 && ret == _FAIL) + rtw_msleep_os(wait_ms); + } while ((i < try_cnt) && ((ret == _FAIL) || (wait_ms == 0))); + + if (ret != _FAIL) { + ret = _SUCCESS; + goto exit; + } + + if (try_cnt && wait_ms) { + if (da) + DBG_88E(FUNC_ADPT_FMT" to %pM, ch:%u%s, %d/%d in %u ms\n", + FUNC_ADPT_ARG(padapter), da, rtw_get_oper_ch(padapter), + ret == _SUCCESS ? ", acked" : "", i, try_cnt, rtw_get_passing_time_ms(start)); + else + DBG_88E(FUNC_ADPT_FMT", ch:%u%s, %d/%d in %u ms\n", + FUNC_ADPT_ARG(padapter), rtw_get_oper_ch(padapter), + ret == _SUCCESS ? ", acked" : "", i, try_cnt, rtw_get_passing_time_ms(start)); + } +exit: + return ret; +} + +/* when wait_ack is ture, this function shoule be called at process context */ +static int _issue_qos_nulldata(struct adapter *padapter, unsigned char *da, u16 tid, int wait_ack) +{ + int ret = _FAIL; + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; + struct rtw_ieee80211_hdr *pwlanhdr; + unsigned short *fctrl, *qc; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + DBG_88E("%s\n", __func__); + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + goto exit; + + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + + pattrib->hdrlen += 2; + pattrib->qos_en = true; + pattrib->eosp = 1; + pattrib->ack_policy = 0; + pattrib->mdata = 0; + + _rtw_memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + + if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) + SetFrDs(fctrl); + else if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) + SetToDs(fctrl); + + if (pattrib->mdata) + SetMData(fctrl); + + qc = (unsigned short *)(pframe + pattrib->hdrlen - 2); + + SetPriority(qc, tid); + + SetEOSP(qc, pattrib->eosp); + + SetAckpolicy(qc, pattrib->ack_policy); + + memcpy(pwlanhdr->addr1, da, ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr3, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + SetFrameSubType(pframe, WIFI_QOS_DATA_NULL); + + pframe += sizeof(struct rtw_ieee80211_hdr_3addr_qos); + pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr_qos); + + pattrib->last_txcmdsz = pattrib->pktlen; + + if (wait_ack) { + ret = dump_mgntframe_and_wait_ack(padapter, pmgntframe); + } else { + dump_mgntframe(padapter, pmgntframe); + ret = _SUCCESS; + } + +exit: + return ret; +} + +/* when wait_ms > 0 , this function shoule be called at process context */ +/* da == NULL for station mode */ +int issue_qos_nulldata(struct adapter *padapter, unsigned char *da, u16 tid, int try_cnt, int wait_ms) +{ + int ret; + int i = 0; + u32 start = rtw_get_current_time(); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + /* da == NULL, assum it's null data for sta to ap*/ + if (da == NULL) + da = get_my_bssid(&(pmlmeinfo->network)); + + do { + ret = _issue_qos_nulldata(padapter, da, tid, wait_ms > 0 ? true : false); + + i++; + + if (padapter->bDriverStopped || padapter->bSurpriseRemoved) + break; + + if (i < try_cnt && wait_ms > 0 && ret == _FAIL) + rtw_msleep_os(wait_ms); + } while ((i < try_cnt) && ((ret == _FAIL) || (wait_ms == 0))); + + if (ret != _FAIL) { + ret = _SUCCESS; + goto exit; + } + + if (try_cnt && wait_ms) { + if (da) + DBG_88E(FUNC_ADPT_FMT" to %pM, ch:%u%s, %d/%d in %u ms\n", + FUNC_ADPT_ARG(padapter), da, rtw_get_oper_ch(padapter), + ret == _SUCCESS ? ", acked" : "", i, try_cnt, rtw_get_passing_time_ms(start)); + else + DBG_88E(FUNC_ADPT_FMT", ch:%u%s, %d/%d in %u ms\n", + FUNC_ADPT_ARG(padapter), rtw_get_oper_ch(padapter), + ret == _SUCCESS ? ", acked" : "", i, try_cnt, rtw_get_passing_time_ms(start)); + } +exit: + return ret; +} + +static int _issue_deauth(struct adapter *padapter, unsigned char *da, unsigned short reason, u8 wait_ack) +{ + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; + struct rtw_ieee80211_hdr *pwlanhdr; + unsigned short *fctrl; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + int ret = _FAIL; + __le16 le_tmp; +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); +#endif /* CONFIG_88EU_P2P */ + +#ifdef CONFIG_88EU_P2P + if (!(rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) && (pwdinfo->rx_invitereq_info.scan_op_ch_only)) { + _cancel_timer_ex(&pwdinfo->reset_ch_sitesurvey); + _set_timer(&pwdinfo->reset_ch_sitesurvey, 10); + } +#endif /* CONFIG_88EU_P2P */ + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + goto exit; + + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + pattrib->retry_ctrl = false; + + _rtw_memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + + memcpy(pwlanhdr->addr1, da, ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr3, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + SetFrameSubType(pframe, WIFI_DEAUTH); + + pframe += sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); + + le_tmp = cpu_to_le16(reason); + pframe = rtw_set_fixed_ie(pframe, _RSON_CODE_ , (unsigned char *)&le_tmp, &(pattrib->pktlen)); + + pattrib->last_txcmdsz = pattrib->pktlen; + + + if (wait_ack) { + ret = dump_mgntframe_and_wait_ack(padapter, pmgntframe); + } else { + dump_mgntframe(padapter, pmgntframe); + ret = _SUCCESS; + } + +exit: + return ret; +} + +int issue_deauth(struct adapter *padapter, unsigned char *da, unsigned short reason) +{ + DBG_88E("%s to %pM\n", __func__, da); + return _issue_deauth(padapter, da, reason, false); +} + +int issue_deauth_ex(struct adapter *padapter, u8 *da, unsigned short reason, int try_cnt, + int wait_ms) +{ + int ret; + int i = 0; + u32 start = rtw_get_current_time(); + + do { + ret = _issue_deauth(padapter, da, reason, wait_ms > 0 ? true : false); + + i++; + + if (padapter->bDriverStopped || padapter->bSurpriseRemoved) + break; + + if (i < try_cnt && wait_ms > 0 && ret == _FAIL) + rtw_msleep_os(wait_ms); + } while ((i < try_cnt) && ((ret == _FAIL) || (wait_ms == 0))); + + if (ret != _FAIL) { + ret = _SUCCESS; + goto exit; + } + + if (try_cnt && wait_ms) { + if (da) + DBG_88E(FUNC_ADPT_FMT" to %pM, ch:%u%s, %d/%d in %u ms\n", + FUNC_ADPT_ARG(padapter), da, rtw_get_oper_ch(padapter), + ret == _SUCCESS ? ", acked" : "", i, try_cnt, rtw_get_passing_time_ms(start)); + else + DBG_88E(FUNC_ADPT_FMT", ch:%u%s, %d/%d in %u ms\n", + FUNC_ADPT_ARG(padapter), rtw_get_oper_ch(padapter), + ret == _SUCCESS ? ", acked" : "", i, try_cnt, rtw_get_passing_time_ms(start)); + } +exit: + return ret; +} + +void issue_action_spct_ch_switch (struct adapter *padapter, u8 *ra, u8 new_ch, u8 ch_offset) +{ + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; + struct rtw_ieee80211_hdr *pwlanhdr; + unsigned short *fctrl; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + + + DBG_88E(FUNC_NDEV_FMT" ra =%pM, ch:%u, offset:%u\n", + FUNC_NDEV_ARG(padapter->pnetdev), ra, new_ch, ch_offset); + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + return; + + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + + _rtw_memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + + memcpy(pwlanhdr->addr1, ra, ETH_ALEN); /* RA */ + memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); /* TA */ + memcpy(pwlanhdr->addr3, ra, ETH_ALEN); /* DA = RA */ + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + SetFrameSubType(pframe, WIFI_ACTION); + + pframe += sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); + + /* category, action */ + { + u8 category, action; + category = RTW_WLAN_CATEGORY_SPECTRUM_MGMT; + action = RTW_WLAN_ACTION_SPCT_CHL_SWITCH; + + pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(action), &(pattrib->pktlen)); + } + + pframe = rtw_set_ie_ch_switch (pframe, &(pattrib->pktlen), 0, new_ch, 0); + pframe = rtw_set_ie_secondary_ch_offset(pframe, &(pattrib->pktlen), + hal_ch_offset_to_secondary_ch_offset(ch_offset)); + + pattrib->last_txcmdsz = pattrib->pktlen; + + dump_mgntframe(padapter, pmgntframe); +} + +void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned char action, unsigned short status) +{ + u8 category = RTW_WLAN_CATEGORY_BACK; + u16 start_seq; + u16 BA_para_set; + u16 reason_code; + u16 BA_timeout_value; + __le16 le_tmp; + u16 BA_starting_seqctrl = 0; + enum ht_cap_ampdu_factor max_rx_ampdu_factor; + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + u8 *pframe; + struct rtw_ieee80211_hdr *pwlanhdr; + u16 *fctrl; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct sta_info *psta; + struct sta_priv *pstapriv = &padapter->stapriv; + struct registry_priv *pregpriv = &padapter->registrypriv; + + DBG_88E("%s, category=%d, action=%d, status=%d\n", __func__, category, action, status); + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + return; + + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + + _rtw_memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + + /* memcpy(pwlanhdr->addr1, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); */ + memcpy(pwlanhdr->addr1, raddr, ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr3, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + SetFrameSubType(pframe, WIFI_ACTION); + + pframe += sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); + + pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(action), &(pattrib->pktlen)); + + if (category == 3) { + switch (action) { + case 0: /* ADDBA req */ + do { + pmlmeinfo->dialogToken++; + } while (pmlmeinfo->dialogToken == 0); + pframe = rtw_set_fixed_ie(pframe, 1, &(pmlmeinfo->dialogToken), &(pattrib->pktlen)); + + BA_para_set = (0x1002 | ((status & 0xf) << 2)); /* immediate ack & 64 buffer size */ + le_tmp = cpu_to_le16(BA_para_set); + pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)(&(le_tmp)), &(pattrib->pktlen)); + + BA_timeout_value = 5000;/* 5ms */ + le_tmp = cpu_to_le16(BA_timeout_value); + pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)(&(le_tmp)), &(pattrib->pktlen)); + + psta = rtw_get_stainfo(pstapriv, raddr); + if (psta != NULL) { + start_seq = (psta->sta_xmitpriv.txseq_tid[status & 0x07]&0xfff) + 1; + + DBG_88E("BA_starting_seqctrl=%d for TID=%d\n", start_seq, status & 0x07); + + psta->BA_starting_seqctrl[status & 0x07] = start_seq; + + BA_starting_seqctrl = start_seq << 4; + } + le_tmp = cpu_to_le16(BA_starting_seqctrl); + pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)(&(le_tmp)), &(pattrib->pktlen)); + break; + case 1: /* ADDBA rsp */ + pframe = rtw_set_fixed_ie(pframe, 1, &(pmlmeinfo->ADDBA_req.dialog_token), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)(&status), &(pattrib->pktlen)); + rtw_hal_get_def_var(padapter, HW_VAR_MAX_RX_AMPDU_FACTOR, &max_rx_ampdu_factor); + if (MAX_AMPDU_FACTOR_64K == max_rx_ampdu_factor) + BA_para_set = (((pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f) | 0x1000); /* 64 buffer size */ + else if (MAX_AMPDU_FACTOR_32K == max_rx_ampdu_factor) + BA_para_set = (((pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f) | 0x0800); /* 32 buffer size */ + else if (MAX_AMPDU_FACTOR_16K == max_rx_ampdu_factor) + BA_para_set = (((pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f) | 0x0400); /* 16 buffer size */ + else if (MAX_AMPDU_FACTOR_8K == max_rx_ampdu_factor) + BA_para_set = (((pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f) | 0x0200); /* 8 buffer size */ + else + BA_para_set = (((pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f) | 0x1000); /* 64 buffer size */ + + if (pregpriv->ampdu_amsdu == 0)/* disabled */ + BA_para_set = BA_para_set & ~BIT(0); + else if (pregpriv->ampdu_amsdu == 1)/* enabled */ + BA_para_set = BA_para_set | BIT(0); + le_tmp = cpu_to_le16(BA_para_set); + + pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)(&(le_tmp)), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)(&(pmlmeinfo->ADDBA_req.BA_timeout_value)), &(pattrib->pktlen)); + break; + case 2:/* DELBA */ + BA_para_set = (status & 0x1F) << 3; + le_tmp = cpu_to_le16(BA_para_set); + pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)(&(le_tmp)), &(pattrib->pktlen)); + + reason_code = 37;/* Requested from peer STA as it does not want to use the mechanism */ + le_tmp = cpu_to_le16(reason_code); + pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)(&(le_tmp)), &(pattrib->pktlen)); + break; + default: + break; + } + } + + pattrib->last_txcmdsz = pattrib->pktlen; + + dump_mgntframe(padapter, pmgntframe); +} + +static void issue_action_BSSCoexistPacket(struct adapter *padapter) +{ + unsigned long irqL; + struct list_head *plist, *phead; + unsigned char category, action; + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; + struct rtw_ieee80211_hdr *pwlanhdr; + unsigned short *fctrl; + struct wlan_network *pnetwork = NULL; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct __queue *queue = &(pmlmepriv->scanned_queue); + u8 InfoContent[16] = {0}; + u8 ICS[8][15]; + if ((pmlmepriv->num_FortyMHzIntolerant == 0) || (pmlmepriv->num_sta_no_ht == 0)) + return; + + if (pmlmeinfo->bwmode_updated) + return; + + + DBG_88E("%s\n", __func__); + + + category = RTW_WLAN_CATEGORY_PUBLIC; + action = ACT_PUBLIC_BSSCOEXIST; + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + return; + + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + + _rtw_memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + + memcpy(pwlanhdr->addr1, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr3, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + SetFrameSubType(pframe, WIFI_ACTION); + + pframe += sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); + + pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(action), &(pattrib->pktlen)); + + + /* */ + if (pmlmepriv->num_FortyMHzIntolerant > 0) { + u8 iedata = 0; + + iedata |= BIT(2);/* 20 MHz BSS Width Request */ + + pframe = rtw_set_ie(pframe, EID_BSSCoexistence, 1, &iedata, &(pattrib->pktlen)); + } + + + /* */ + _rtw_memset(ICS, 0, sizeof(ICS)); + if (pmlmepriv->num_sta_no_ht > 0) { + int i; + + _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); + + phead = get_list_head(queue); + plist = get_next(phead); + + while (1) { + int len; + u8 *p; + struct wlan_bssid_ex *pbss_network; + + if (rtw_end_of_queue_search(phead, plist)) + break; + + pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); + + plist = get_next(plist); + + pbss_network = (struct wlan_bssid_ex *)&pnetwork->network; + + p = rtw_get_ie(pbss_network->IEs + _FIXED_IE_LENGTH_, _HT_CAPABILITY_IE_, &len, pbss_network->IELength - _FIXED_IE_LENGTH_); + if ((p == NULL) || (len == 0)) { /* non-HT */ + if ((pbss_network->Configuration.DSConfig <= 0) || (pbss_network->Configuration.DSConfig > 14)) + continue; + + ICS[0][pbss_network->Configuration.DSConfig] = 1; + + if (ICS[0][0] == 0) + ICS[0][0] = 1; + } + } + _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); + + for (i = 0; i < 8; i++) { + if (ICS[i][0] == 1) { + int j, k = 0; + + InfoContent[k] = i; + /* SET_BSS_INTOLERANT_ELE_REG_CLASS(InfoContent, i); */ + k++; + + for (j = 1; j <= 14; j++) { + if (ICS[i][j] == 1) { + if (k < 16) { + InfoContent[k] = j; /* channel number */ + /* SET_BSS_INTOLERANT_ELE_CHANNEL(InfoContent+k, j); */ + k++; + } + } + } + + pframe = rtw_set_ie(pframe, EID_BSSIntolerantChlReport, k, InfoContent, &(pattrib->pktlen)); + } + } + } + + + pattrib->last_txcmdsz = pattrib->pktlen; + + dump_mgntframe(padapter, pmgntframe); +} + +unsigned int send_delba(struct adapter *padapter, u8 initiator, u8 *addr) +{ + struct sta_priv *pstapriv = &padapter->stapriv; + struct sta_info *psta = NULL; + /* struct recv_reorder_ctrl *preorder_ctrl; */ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + u16 tid; + + if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) + if (!(pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) + return _SUCCESS; + + psta = rtw_get_stainfo(pstapriv, addr); + if (psta == NULL) + return _SUCCESS; + + if (initiator == 0) { /* recipient */ + for (tid = 0; tid < MAXTID; tid++) { + if (psta->recvreorder_ctrl[tid].enable) { + DBG_88E("rx agg disable tid(%d)\n", tid); + issue_action_BA(padapter, addr, RTW_WLAN_ACTION_DELBA, (((tid << 1) | initiator)&0x1F)); + psta->recvreorder_ctrl[tid].enable = false; + psta->recvreorder_ctrl[tid].indicate_seq = 0xffff; + } + } + } else if (initiator == 1) { /* originator */ + for (tid = 0; tid < MAXTID; tid++) { + if (psta->htpriv.agg_enable_bitmap & BIT(tid)) { + DBG_88E("tx agg disable tid(%d)\n", tid); + issue_action_BA(padapter, addr, RTW_WLAN_ACTION_DELBA, (((tid << 1) | initiator)&0x1F)); + psta->htpriv.agg_enable_bitmap &= ~BIT(tid); + psta->htpriv.candidate_tid_bitmap &= ~BIT(tid); + } + } + } + + return _SUCCESS; +} + +unsigned int send_beacon(struct adapter *padapter) +{ + u8 bxmitok = false; + int issue = 0; + int poll = 0; + + u32 start = rtw_get_current_time(); + + rtw_hal_set_hwreg(padapter, HW_VAR_BCN_VALID, NULL); + do { + issue_beacon(padapter, 100); + issue++; + do { + rtw_yield_os(); + rtw_hal_get_hwreg(padapter, HW_VAR_BCN_VALID, (u8 *)(&bxmitok)); + poll++; + } while ((poll%10) != 0 && !bxmitok && !padapter->bSurpriseRemoved && !padapter->bDriverStopped); + } while (!bxmitok && issue < 100 && !padapter->bSurpriseRemoved && !padapter->bDriverStopped); + + if (padapter->bSurpriseRemoved || padapter->bDriverStopped) + return _FAIL; + if (!bxmitok) { + DBG_88E("%s fail! %u ms\n", __func__, rtw_get_passing_time_ms(start)); + return _FAIL; + } else { + u32 passing_time = rtw_get_passing_time_ms(start); + + if (passing_time > 100 || issue > 3) + DBG_88E("%s success, issue:%d, poll:%d, %u ms\n", __func__, issue, poll, rtw_get_passing_time_ms(start)); + return _SUCCESS; + } +} + +/**************************************************************************** + +Following are some utitity fuctions for WiFi MLME + +*****************************************************************************/ + +void site_survey(struct adapter *padapter) +{ + unsigned char survey_channel = 0, val8; + enum rt_scan_type ScanType = SCAN_PASSIVE; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + u32 initialgain = 0; + +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + + if ((pwdinfo->rx_invitereq_info.scan_op_ch_only) || (pwdinfo->p2p_info.scan_op_ch_only)) { + if (pwdinfo->rx_invitereq_info.scan_op_ch_only) { + survey_channel = pwdinfo->rx_invitereq_info.operation_ch[pmlmeext->sitesurvey_res.channel_idx]; + } else { + survey_channel = pwdinfo->p2p_info.operation_ch[pmlmeext->sitesurvey_res.channel_idx]; + } + ScanType = SCAN_ACTIVE; + } else if (rtw_p2p_findphase_ex_is_social(pwdinfo)) { + /* Commented by Albert 2011/06/03 */ + /* The driver is in the find phase, it should go through the social channel. */ + int ch_set_idx; + survey_channel = pwdinfo->social_chan[pmlmeext->sitesurvey_res.channel_idx]; + ch_set_idx = rtw_ch_set_search_ch(pmlmeext->channel_set, survey_channel); + if (ch_set_idx >= 0) + ScanType = pmlmeext->channel_set[ch_set_idx].ScanType; + else + ScanType = SCAN_ACTIVE; + } else +#endif /* CONFIG_88EU_P2P */ + { + struct rtw_ieee80211_channel *ch; + if (pmlmeext->sitesurvey_res.channel_idx < pmlmeext->sitesurvey_res.ch_num) { + ch = &pmlmeext->sitesurvey_res.ch[pmlmeext->sitesurvey_res.channel_idx]; + survey_channel = ch->hw_value; + ScanType = (ch->flags & RTW_IEEE80211_CHAN_PASSIVE_SCAN) ? SCAN_PASSIVE : SCAN_ACTIVE; + } + } + + if (survey_channel != 0) { + /* PAUSE 4-AC Queue when site_survey */ + /* rtw_hal_get_hwreg(padapter, HW_VAR_TXPAUSE, (u8 *)(&val8)); */ + /* val8 |= 0x0f; */ + /* rtw_hal_set_hwreg(padapter, HW_VAR_TXPAUSE, (u8 *)(&val8)); */ + if (pmlmeext->sitesurvey_res.channel_idx == 0) + set_channel_bwmode(padapter, survey_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); + else + SelectChannel(padapter, survey_channel); + + if (ScanType == SCAN_ACTIVE) { /* obey the channel plan setting... */ + #ifdef CONFIG_88EU_P2P + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_SCAN) || + rtw_p2p_chk_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH)) { + issue_probereq_p2p(padapter, NULL); + issue_probereq_p2p(padapter, NULL); + issue_probereq_p2p(padapter, NULL); + } else + #endif /* CONFIG_88EU_P2P */ + { + int i; + for (i = 0; i < RTW_SSID_SCAN_AMOUNT; i++) { + if (pmlmeext->sitesurvey_res.ssid[i].SsidLength) { + /* todo: to issue two probe req??? */ + issue_probereq(padapter, &(pmlmeext->sitesurvey_res.ssid[i]), NULL); + /* rtw_msleep_os(SURVEY_TO>>1); */ + issue_probereq(padapter, &(pmlmeext->sitesurvey_res.ssid[i]), NULL); + } + } + + if (pmlmeext->sitesurvey_res.scan_mode == SCAN_ACTIVE) { + /* todo: to issue two probe req??? */ + issue_probereq(padapter, NULL, NULL); + /* rtw_msleep_os(SURVEY_TO>>1); */ + issue_probereq(padapter, NULL, NULL); + } + } + } + + set_survey_timer(pmlmeext, pmlmeext->chan_scan_time); + } else { + /* channel number is 0 or this channel is not valid. */ + +#ifdef CONFIG_88EU_P2P + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_SCAN) || rtw_p2p_chk_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH)) { + if ((pwdinfo->rx_invitereq_info.scan_op_ch_only) || (pwdinfo->p2p_info.scan_op_ch_only)) { + /* Set the find_phase_state_exchange_cnt to P2P_FINDPHASE_EX_CNT. */ + /* This will let the following flow to run the scanning end. */ + rtw_p2p_findphase_ex_set(pwdinfo, P2P_FINDPHASE_EX_MAX); + } + } + + if (rtw_p2p_findphase_ex_is_needed(pwdinfo)) { + /* Set the P2P State to the listen state of find phase and set the current channel to the listen channel */ + set_channel_bwmode(padapter, pwdinfo->listen_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); + rtw_p2p_set_state(pwdinfo, P2P_STATE_FIND_PHASE_LISTEN); + pmlmeext->sitesurvey_res.state = SCAN_DISABLE; + + initialgain = 0xff; /* restore RX GAIN */ + rtw_hal_set_hwreg(padapter, HW_VAR_INITIAL_GAIN, (u8 *)(&initialgain)); + /* turn on dynamic functions */ + Restore_DM_Func_Flag(padapter); + /* Switch_DM_Func(padapter, DYNAMIC_FUNC_DIG|DYNAMIC_FUNC_HP|DYNAMIC_FUNC_SS, true); */ + + _set_timer(&pwdinfo->find_phase_timer, (u32)((u32)(pwdinfo->listen_dwell) * 100)); + } else +#endif /* CONFIG_88EU_P2P */ + { + /* 20100721:Interrupt scan operation here. */ + /* For SW antenna diversity before link, it needs to switch to another antenna and scan again. */ + /* It compares the scan result and select beter one to do connection. */ + if (rtw_hal_antdiv_before_linked(padapter)) { + pmlmeext->sitesurvey_res.bss_cnt = 0; + pmlmeext->sitesurvey_res.channel_idx = -1; + pmlmeext->chan_scan_time = SURVEY_TO / 2; + set_survey_timer(pmlmeext, pmlmeext->chan_scan_time); + return; + } +#ifdef CONFIG_88EU_P2P + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_SCAN) || rtw_p2p_chk_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH)) + rtw_p2p_set_state(pwdinfo, rtw_p2p_pre_state(pwdinfo)); + rtw_p2p_findphase_ex_set(pwdinfo, P2P_FINDPHASE_EX_NONE); +#endif /* CONFIG_88EU_P2P */ + + pmlmeext->sitesurvey_res.state = SCAN_COMPLETE; + + /* switch back to the original channel */ + +#ifdef CONFIG_88EU_P2P + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_LISTEN)) + set_channel_bwmode(padapter, pwdinfo->listen_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); + else + set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); +#endif /* CONFIG_88EU_P2P */ + + /* flush 4-AC Queue after site_survey */ + /* val8 = 0; */ + /* rtw_hal_set_hwreg(padapter, HW_VAR_TXPAUSE, (u8 *)(&val8)); */ + + /* config MSR */ + Set_MSR(padapter, (pmlmeinfo->state & 0x3)); + + initialgain = 0xff; /* restore RX GAIN */ + rtw_hal_set_hwreg(padapter, HW_VAR_INITIAL_GAIN, (u8 *)(&initialgain)); + /* turn on dynamic functions */ + Restore_DM_Func_Flag(padapter); + /* Switch_DM_Func(padapter, DYNAMIC_ALL_FUNC_ENABLE, true); */ + + if (is_client_associated_to_ap(padapter)) + issue_nulldata(padapter, NULL, 0, 3, 500); + + val8 = 0; /* survey done */ + rtw_hal_set_hwreg(padapter, HW_VAR_MLME_SITESURVEY, (u8 *)(&val8)); + + report_surveydone_event(padapter); + + pmlmeext->chan_scan_time = SURVEY_TO; + pmlmeext->sitesurvey_res.state = SCAN_DISABLE; + + issue_action_BSSCoexistPacket(padapter); + issue_action_BSSCoexistPacket(padapter); + issue_action_BSSCoexistPacket(padapter); + } + } + return; +} + +/* collect bss info from Beacon and Probe request/response frames. */ +u8 collect_bss_info(struct adapter *padapter, union recv_frame *precv_frame, struct wlan_bssid_ex *bssid) +{ + int i; + u32 len; + u8 *p; + u16 val16, subtype; + u8 *pframe = precv_frame->u.hdr.rx_data; + u32 packet_len = precv_frame->u.hdr.len; + u8 ie_offset; + struct registry_priv *pregistrypriv = &padapter->registrypriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + __le32 le32_tmp; + + len = packet_len - sizeof(struct rtw_ieee80211_hdr_3addr); + + if (len > MAX_IE_SZ) + return _FAIL; + + _rtw_memset(bssid, 0, sizeof(struct wlan_bssid_ex)); + + subtype = GetFrameSubType(pframe); + + if (subtype == WIFI_BEACON) { + bssid->Reserved[0] = 1; + ie_offset = _BEACON_IE_OFFSET_; + } else { + /* FIXME : more type */ + if (subtype == WIFI_PROBEREQ) { + ie_offset = _PROBEREQ_IE_OFFSET_; + bssid->Reserved[0] = 2; + } else if (subtype == WIFI_PROBERSP) { + ie_offset = _PROBERSP_IE_OFFSET_; + bssid->Reserved[0] = 3; + } else { + bssid->Reserved[0] = 0; + ie_offset = _FIXED_IE_LENGTH_; + } + } + + bssid->Length = sizeof(struct wlan_bssid_ex) - MAX_IE_SZ + len; + + /* below is to copy the information element */ + bssid->IELength = len; + memcpy(bssid->IEs, (pframe + sizeof(struct rtw_ieee80211_hdr_3addr)), bssid->IELength); + + /* get the signal strength */ + bssid->Rssi = precv_frame->u.hdr.attrib.phy_info.recvpower; /* in dBM.raw data */ + bssid->PhyInfo.SignalQuality = precv_frame->u.hdr.attrib.phy_info.SignalQuality;/* in percentage */ + bssid->PhyInfo.SignalStrength = precv_frame->u.hdr.attrib.phy_info.SignalStrength;/* in percentage */ + rtw_hal_get_def_var(padapter, HAL_DEF_CURRENT_ANTENNA, &bssid->PhyInfo.Optimum_antenna); + + /* checking SSID */ + p = rtw_get_ie(bssid->IEs + ie_offset, _SSID_IE_, &len, bssid->IELength - ie_offset); + if (p == NULL) { + DBG_88E("marc: cannot find SSID for survey event\n"); + return _FAIL; + } + + if (*(p + 1)) { + if (len > NDIS_802_11_LENGTH_SSID) { + DBG_88E("%s()-%d: IE too long (%d) for survey event\n", __func__, __LINE__, len); + return _FAIL; + } + memcpy(bssid->Ssid.Ssid, (p + 2), *(p + 1)); + bssid->Ssid.SsidLength = *(p + 1); + } else { + bssid->Ssid.SsidLength = 0; + } + + _rtw_memset(bssid->SupportedRates, 0, NDIS_802_11_LENGTH_RATES_EX); + + /* checking rate info... */ + i = 0; + p = rtw_get_ie(bssid->IEs + ie_offset, _SUPPORTEDRATES_IE_, &len, bssid->IELength - ie_offset); + if (p != NULL) { + if (len > NDIS_802_11_LENGTH_RATES_EX) { + DBG_88E("%s()-%d: IE too long (%d) for survey event\n", __func__, __LINE__, len); + return _FAIL; + } + memcpy(bssid->SupportedRates, (p + 2), len); + i = len; + } + + p = rtw_get_ie(bssid->IEs + ie_offset, _EXT_SUPPORTEDRATES_IE_, &len, bssid->IELength - ie_offset); + if (p != NULL) { + if (len > (NDIS_802_11_LENGTH_RATES_EX-i)) { + DBG_88E("%s()-%d: IE too long (%d) for survey event\n", __func__, __LINE__, len); + return _FAIL; + } + memcpy(bssid->SupportedRates + i, (p + 2), len); + } + + /* todo: */ + bssid->NetworkTypeInUse = Ndis802_11OFDM24; + + if (bssid->IELength < 12) + return _FAIL; + + /* Checking for DSConfig */ + p = rtw_get_ie(bssid->IEs + ie_offset, _DSSET_IE_, &len, bssid->IELength - ie_offset); + + bssid->Configuration.DSConfig = 0; + bssid->Configuration.Length = 0; + + if (p) { + bssid->Configuration.DSConfig = *(p + 2); + } else {/* In 5G, some ap do not have DSSET IE */ + /* checking HT info for channel */ + p = rtw_get_ie(bssid->IEs + ie_offset, _HT_ADD_INFO_IE_, &len, bssid->IELength - ie_offset); + if (p) { + struct HT_info_element *HT_info = (struct HT_info_element *)(p + 2); + bssid->Configuration.DSConfig = HT_info->primary_channel; + } else { /* use current channel */ + bssid->Configuration.DSConfig = rtw_get_oper_ch(padapter); + } + } + + if (subtype == WIFI_PROBEREQ) { + /* FIXME */ + bssid->InfrastructureMode = Ndis802_11Infrastructure; + memcpy(bssid->MacAddress, GetAddr2Ptr(pframe), ETH_ALEN); + bssid->Privacy = 1; + return _SUCCESS; + } + + memcpy(&le32_tmp, rtw_get_beacon_interval_from_ie(bssid->IEs), 2); + bssid->Configuration.BeaconPeriod = le32_to_cpu(le32_tmp); + + val16 = rtw_get_capability((struct wlan_bssid_ex *)bssid); + + if (val16 & BIT(0)) { + bssid->InfrastructureMode = Ndis802_11Infrastructure; + memcpy(bssid->MacAddress, GetAddr2Ptr(pframe), ETH_ALEN); + } else { + bssid->InfrastructureMode = Ndis802_11IBSS; + memcpy(bssid->MacAddress, GetAddr3Ptr(pframe), ETH_ALEN); + } + + if (val16 & BIT(4)) + bssid->Privacy = 1; + else + bssid->Privacy = 0; + + bssid->Configuration.ATIMWindow = 0; + + /* 20/40 BSS Coexistence check */ + if ((pregistrypriv->wifi_spec == 1) && (!pmlmeinfo->bwmode_updated)) { + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + p = rtw_get_ie(bssid->IEs + ie_offset, _HT_CAPABILITY_IE_, &len, bssid->IELength - ie_offset); + if (p && len > 0) { + struct HT_caps_element *pHT_caps; + pHT_caps = (struct HT_caps_element *)(p + 2); + + if (le16_to_cpu(pHT_caps->u.HT_cap_element.HT_caps_info)&BIT(14)) + pmlmepriv->num_FortyMHzIntolerant++; + } else { + pmlmepriv->num_sta_no_ht++; + } + } + + /* mark bss info receving from nearby channel as SignalQuality 101 */ + if (bssid->Configuration.DSConfig != rtw_get_oper_ch(padapter)) + bssid->PhyInfo.SignalQuality = 101; + return _SUCCESS; +} + +void start_create_ibss(struct adapter *padapter) +{ + unsigned short caps; + u8 val8; + u8 join_type; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&(pmlmeinfo->network)); + pmlmeext->cur_channel = (u8)pnetwork->Configuration.DSConfig; + pmlmeinfo->bcn_interval = get_beacon_interval(pnetwork); + + /* update wireless mode */ + update_wireless_mode(padapter); + + /* udpate capability */ + caps = rtw_get_capability((struct wlan_bssid_ex *)pnetwork); + update_capinfo(padapter, caps); + if (caps&cap_IBSS) {/* adhoc master */ + val8 = 0xcf; + rtw_hal_set_hwreg(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8)); + + /* switch channel */ + /* SelectChannel(padapter, pmlmeext->cur_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE); */ + set_channel_bwmode(padapter, pmlmeext->cur_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); + + beacon_timing_control(padapter); + + /* set msr to WIFI_FW_ADHOC_STATE */ + pmlmeinfo->state = WIFI_FW_ADHOC_STATE; + Set_MSR(padapter, (pmlmeinfo->state & 0x3)); + + /* issue beacon */ + if (send_beacon(padapter) == _FAIL) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("issuing beacon frame fail....\n")); + + report_join_res(padapter, -1); + pmlmeinfo->state = WIFI_FW_NULL_STATE; + } else { + rtw_hal_set_hwreg(padapter, HW_VAR_BSSID, padapter->registrypriv.dev_network.MacAddress); + join_type = 0; + rtw_hal_set_hwreg(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); + + report_join_res(padapter, 1); + pmlmeinfo->state |= WIFI_FW_ASSOC_SUCCESS; + } + } else { + DBG_88E("start_create_ibss, invalid cap:%x\n", caps); + return; + } +} + +void start_clnt_join(struct adapter *padapter) +{ + unsigned short caps; + u8 val8; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&(pmlmeinfo->network)); + int beacon_timeout; + + pmlmeext->cur_channel = (u8)pnetwork->Configuration.DSConfig; + pmlmeinfo->bcn_interval = get_beacon_interval(pnetwork); + + /* update wireless mode */ + update_wireless_mode(padapter); + + /* udpate capability */ + caps = rtw_get_capability((struct wlan_bssid_ex *)pnetwork); + update_capinfo(padapter, caps); + if (caps&cap_ESS) { + Set_MSR(padapter, WIFI_FW_STATION_STATE); + + val8 = (pmlmeinfo->auth_algo == dot11AuthAlgrthm_8021X) ? 0xcc : 0xcf; + + rtw_hal_set_hwreg(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8)); + + /* switch channel */ + set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); + + /* here wait for receiving the beacon to start auth */ + /* and enable a timer */ + beacon_timeout = decide_wait_for_beacon_timeout(pmlmeinfo->bcn_interval); + set_link_timer(pmlmeext, beacon_timeout); + _set_timer(&padapter->mlmepriv.assoc_timer, + (REAUTH_TO * REAUTH_LIMIT) + (REASSOC_TO*REASSOC_LIMIT) + beacon_timeout); + + pmlmeinfo->state = WIFI_FW_AUTH_NULL | WIFI_FW_STATION_STATE; + } else if (caps&cap_IBSS) { /* adhoc client */ + Set_MSR(padapter, WIFI_FW_ADHOC_STATE); + + val8 = 0xcf; + rtw_hal_set_hwreg(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8)); + + /* switch channel */ + set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); + + beacon_timing_control(padapter); + + pmlmeinfo->state = WIFI_FW_ADHOC_STATE; + + report_join_res(padapter, 1); + } else { + return; + } +} + +void start_clnt_auth(struct adapter *padapter) +{ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + _cancel_timer_ex(&pmlmeext->link_timer); + + pmlmeinfo->state &= (~WIFI_FW_AUTH_NULL); + pmlmeinfo->state |= WIFI_FW_AUTH_STATE; + + pmlmeinfo->auth_seq = 1; + pmlmeinfo->reauth_count = 0; + pmlmeinfo->reassoc_count = 0; + pmlmeinfo->link_count = 0; + pmlmeext->retry = 0; + + + /* Because of AP's not receiving deauth before */ + /* AP may: 1)not response auth or 2)deauth us after link is complete */ + /* issue deauth before issuing auth to deal with the situation */ + /* Commented by Albert 2012/07/21 */ + /* For the Win8 P2P connection, it will be hard to have a successful connection if this Wi-Fi doesn't connect to it. */ + issue_deauth(padapter, (&(pmlmeinfo->network))->MacAddress, WLAN_REASON_DEAUTH_LEAVING); + + DBG_88E_LEVEL(_drv_info_, "start auth\n"); + issue_auth(padapter, NULL, 0); + + set_link_timer(pmlmeext, REAUTH_TO); +} + + +void start_clnt_assoc(struct adapter *padapter) +{ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + _cancel_timer_ex(&pmlmeext->link_timer); + + pmlmeinfo->state &= (~(WIFI_FW_AUTH_NULL | WIFI_FW_AUTH_STATE)); + pmlmeinfo->state |= (WIFI_FW_AUTH_SUCCESS | WIFI_FW_ASSOC_STATE); + + issue_assocreq(padapter); + + set_link_timer(pmlmeext, REASSOC_TO); +} + +unsigned int receive_disconnect(struct adapter *padapter, unsigned char *MacAddr, unsigned short reason) +{ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + /* check A3 */ + if (!(_rtw_memcmp(MacAddr, get_my_bssid(&pmlmeinfo->network), ETH_ALEN))) + return _SUCCESS; + + DBG_88E("%s\n", __func__); + + if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) { + if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) { + pmlmeinfo->state = WIFI_FW_NULL_STATE; + report_del_sta_event(padapter, MacAddr, reason); + } else if (pmlmeinfo->state & WIFI_FW_LINKING_STATE) { + pmlmeinfo->state = WIFI_FW_NULL_STATE; + report_join_res(padapter, -2); + } + } + return _SUCCESS; +} + +static void process_80211d(struct adapter *padapter, struct wlan_bssid_ex *bssid) +{ + struct registry_priv *pregistrypriv; + struct mlme_ext_priv *pmlmeext; + struct rt_channel_info *chplan_new; + u8 channel; + u8 i; + + pregistrypriv = &padapter->registrypriv; + pmlmeext = &padapter->mlmeextpriv; + + /* Adjust channel plan by AP Country IE */ + if (pregistrypriv->enable80211d && + (!pmlmeext->update_channel_plan_by_ap_done)) { + u8 *ie, *p; + u32 len; + struct rt_channel_plan chplan_ap; + struct rt_channel_info chplan_sta[MAX_CHANNEL_NUM]; + u8 country[4]; + u8 fcn; /* first channel number */ + u8 noc; /* number of channel */ + u8 j, k; + + ie = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _COUNTRY_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_); + if (!ie) + return; + if (len < 6) + return; + ie += 2; + p = ie; + ie += len; + + _rtw_memset(country, 0, 4); + memcpy(country, p, 3); + p += 3; + RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, + ("%s: 802.11d country =%s\n", __func__, country)); + + i = 0; + while ((ie - p) >= 3) { + fcn = *(p++); + noc = *(p++); + p++; + + for (j = 0; j < noc; j++) { + if (fcn <= 14) + channel = fcn + j; /* 2.4 GHz */ + else + channel = fcn + j*4; /* 5 GHz */ + + chplan_ap.Channel[i++] = channel; + } + } + chplan_ap.Len = i; + + memcpy(chplan_sta, pmlmeext->channel_set, sizeof(chplan_sta)); + + _rtw_memset(pmlmeext->channel_set, 0, sizeof(pmlmeext->channel_set)); + chplan_new = pmlmeext->channel_set; + + i = 0; + j = 0; + k = 0; + if (pregistrypriv->wireless_mode & WIRELESS_11G) { + do { + if ((i == MAX_CHANNEL_NUM) || + (chplan_sta[i].ChannelNum == 0) || + (chplan_sta[i].ChannelNum > 14)) + break; + + if ((j == chplan_ap.Len) || (chplan_ap.Channel[j] > 14)) + break; + + if (chplan_sta[i].ChannelNum == chplan_ap.Channel[j]) { + chplan_new[k].ChannelNum = chplan_ap.Channel[j]; + chplan_new[k].ScanType = SCAN_ACTIVE; + i++; + j++; + k++; + } else if (chplan_sta[i].ChannelNum < chplan_ap.Channel[j]) { + chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum; + chplan_new[k].ScanType = SCAN_PASSIVE; + i++; + k++; + } else if (chplan_sta[i].ChannelNum > chplan_ap.Channel[j]) { + chplan_new[k].ChannelNum = chplan_ap.Channel[j]; + chplan_new[k].ScanType = SCAN_ACTIVE; + j++; + k++; + } + } while (1); + + /* change AP not support channel to Passive scan */ + while ((i < MAX_CHANNEL_NUM) && + (chplan_sta[i].ChannelNum != 0) && + (chplan_sta[i].ChannelNum <= 14)) { + chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum; + chplan_new[k].ScanType = SCAN_PASSIVE; + i++; + k++; + } + + /* add channel AP supported */ + while ((j < chplan_ap.Len) && (chplan_ap.Channel[j] <= 14)) { + chplan_new[k].ChannelNum = chplan_ap.Channel[j]; + chplan_new[k].ScanType = SCAN_ACTIVE; + j++; + k++; + } + } else { + /* keep original STA 2.4G channel plan */ + while ((i < MAX_CHANNEL_NUM) && + (chplan_sta[i].ChannelNum != 0) && + (chplan_sta[i].ChannelNum <= 14)) { + chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum; + chplan_new[k].ScanType = chplan_sta[i].ScanType; + i++; + k++; + } + + /* skip AP 2.4G channel plan */ + while ((j < chplan_ap.Len) && (chplan_ap.Channel[j] <= 14)) + j++; + } + + /* keep original STA 5G channel plan */ + while ((i < MAX_CHANNEL_NUM) && (chplan_sta[i].ChannelNum != 0)) { + chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum; + chplan_new[k].ScanType = chplan_sta[i].ScanType; + i++; + k++; + } + + pmlmeext->update_channel_plan_by_ap_done = 1; + } + + /* If channel is used by AP, set channel scan type to active */ + channel = bssid->Configuration.DSConfig; + chplan_new = pmlmeext->channel_set; + i = 0; + while ((i < MAX_CHANNEL_NUM) && (chplan_new[i].ChannelNum != 0)) { + if (chplan_new[i].ChannelNum == channel) { + if (chplan_new[i].ScanType == SCAN_PASSIVE) { + chplan_new[i].ScanType = SCAN_ACTIVE; + RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, + ("%s: change channel %d scan type from passive to active\n", + __func__, channel)); + } + break; + } + i++; + } +} + +/**************************************************************************** + +Following are the functions to report events + +*****************************************************************************/ + +void report_survey_event(struct adapter *padapter, union recv_frame *precv_frame) +{ + struct cmd_obj *pcmd_obj; + u8 *pevtcmd; + u32 cmdsz; + struct survey_event *psurvey_evt; + struct C2HEvent_Header *pc2h_evt_hdr; + struct mlme_ext_priv *pmlmeext; + struct cmd_priv *pcmdpriv; + /* u8 *pframe = precv_frame->u.hdr.rx_data; */ + /* uint len = precv_frame->u.hdr.len; */ + + if (!padapter) + return; + + pmlmeext = &padapter->mlmeextpriv; + pcmdpriv = &padapter->cmdpriv; + + + pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (pcmd_obj == NULL) + return; + + cmdsz = (sizeof(struct survey_event) + sizeof(struct C2HEvent_Header)); + pevtcmd = (u8 *)rtw_zmalloc(cmdsz); + if (pevtcmd == NULL) { + kfree(pcmd_obj); + return; + } + + _rtw_init_listhead(&pcmd_obj->list); + + pcmd_obj->cmdcode = GEN_CMD_CODE(_Set_MLME_EVT); + pcmd_obj->cmdsz = cmdsz; + pcmd_obj->parmbuf = pevtcmd; + + pcmd_obj->rsp = NULL; + pcmd_obj->rspsz = 0; + + pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); + pc2h_evt_hdr->len = sizeof(struct survey_event); + pc2h_evt_hdr->ID = GEN_EVT_CODE(_Survey); + pc2h_evt_hdr->seq = ATOMIC_INC_RETURN(&pmlmeext->event_seq); + + psurvey_evt = (struct survey_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); + + if (collect_bss_info(padapter, precv_frame, (struct wlan_bssid_ex *)&psurvey_evt->bss) == _FAIL) { + kfree(pcmd_obj); + kfree(pevtcmd); + return; + } + + process_80211d(padapter, &psurvey_evt->bss); + + rtw_enqueue_cmd(pcmdpriv, pcmd_obj); + + pmlmeext->sitesurvey_res.bss_cnt++; + + return; +} + +void report_surveydone_event(struct adapter *padapter) +{ + struct cmd_obj *pcmd_obj; + u8 *pevtcmd; + u32 cmdsz; + struct surveydone_event *psurveydone_evt; + struct C2HEvent_Header *pc2h_evt_hdr; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + + pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (pcmd_obj == NULL) + return; + + cmdsz = (sizeof(struct surveydone_event) + sizeof(struct C2HEvent_Header)); + pevtcmd = (u8 *)rtw_zmalloc(cmdsz); + if (pevtcmd == NULL) { + kfree(pcmd_obj); + return; + } + + _rtw_init_listhead(&pcmd_obj->list); + + pcmd_obj->cmdcode = GEN_CMD_CODE(_Set_MLME_EVT); + pcmd_obj->cmdsz = cmdsz; + pcmd_obj->parmbuf = pevtcmd; + + pcmd_obj->rsp = NULL; + pcmd_obj->rspsz = 0; + + pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); + pc2h_evt_hdr->len = sizeof(struct surveydone_event); + pc2h_evt_hdr->ID = GEN_EVT_CODE(_SurveyDone); + pc2h_evt_hdr->seq = ATOMIC_INC_RETURN(&pmlmeext->event_seq); + + psurveydone_evt = (struct surveydone_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); + psurveydone_evt->bss_cnt = pmlmeext->sitesurvey_res.bss_cnt; + + DBG_88E("survey done event(%x)\n", psurveydone_evt->bss_cnt); + + rtw_enqueue_cmd(pcmdpriv, pcmd_obj); + + return; +} + +void report_join_res(struct adapter *padapter, int res) +{ + struct cmd_obj *pcmd_obj; + u8 *pevtcmd; + u32 cmdsz; + struct joinbss_event *pjoinbss_evt; + struct C2HEvent_Header *pc2h_evt_hdr; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + + pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (pcmd_obj == NULL) + return; + + cmdsz = (sizeof(struct joinbss_event) + sizeof(struct C2HEvent_Header)); + pevtcmd = (u8 *)rtw_zmalloc(cmdsz); + if (pevtcmd == NULL) { + kfree(pcmd_obj); + return; + } + + _rtw_init_listhead(&pcmd_obj->list); + + pcmd_obj->cmdcode = GEN_CMD_CODE(_Set_MLME_EVT); + pcmd_obj->cmdsz = cmdsz; + pcmd_obj->parmbuf = pevtcmd; + + pcmd_obj->rsp = NULL; + pcmd_obj->rspsz = 0; + + pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); + pc2h_evt_hdr->len = sizeof(struct joinbss_event); + pc2h_evt_hdr->ID = GEN_EVT_CODE(_JoinBss); + pc2h_evt_hdr->seq = ATOMIC_INC_RETURN(&pmlmeext->event_seq); + + pjoinbss_evt = (struct joinbss_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); + memcpy((unsigned char *)(&(pjoinbss_evt->network.network)), &(pmlmeinfo->network), sizeof(struct wlan_bssid_ex)); + pjoinbss_evt->network.join_res = res; + pjoinbss_evt->network.aid = res; + + DBG_88E("report_join_res(%d)\n", res); + + + rtw_joinbss_event_prehandle(padapter, (u8 *)&pjoinbss_evt->network); + + + rtw_enqueue_cmd(pcmdpriv, pcmd_obj); + + return; +} + +void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, unsigned short reason) +{ + struct cmd_obj *pcmd_obj; + u8 *pevtcmd; + u32 cmdsz; + struct sta_info *psta; + int mac_id; + struct stadel_event *pdel_sta_evt; + struct C2HEvent_Header *pc2h_evt_hdr; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + + pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (pcmd_obj == NULL) + return; + + cmdsz = (sizeof(struct stadel_event) + sizeof(struct C2HEvent_Header)); + pevtcmd = (u8 *)rtw_zmalloc(cmdsz); + if (pevtcmd == NULL) { + kfree(pcmd_obj); + return; + } + + _rtw_init_listhead(&pcmd_obj->list); + + pcmd_obj->cmdcode = GEN_CMD_CODE(_Set_MLME_EVT); + pcmd_obj->cmdsz = cmdsz; + pcmd_obj->parmbuf = pevtcmd; + + pcmd_obj->rsp = NULL; + pcmd_obj->rspsz = 0; + + pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); + pc2h_evt_hdr->len = sizeof(struct stadel_event); + pc2h_evt_hdr->ID = GEN_EVT_CODE(_DelSTA); + pc2h_evt_hdr->seq = ATOMIC_INC_RETURN(&pmlmeext->event_seq); + + pdel_sta_evt = (struct stadel_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); + memcpy((unsigned char *)(&(pdel_sta_evt->macaddr)), MacAddr, ETH_ALEN); + memcpy((unsigned char *)(pdel_sta_evt->rsvd), (unsigned char *)(&reason), 2); + + + psta = rtw_get_stainfo(&padapter->stapriv, MacAddr); + if (psta) + mac_id = (int)psta->mac_id; + else + mac_id = (-1); + + pdel_sta_evt->mac_id = mac_id; + + DBG_88E("report_del_sta_event: delete STA, mac_id =%d\n", mac_id); + + rtw_enqueue_cmd(pcmdpriv, pcmd_obj); + + return; +} + +void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr, int cam_idx) +{ + struct cmd_obj *pcmd_obj; + u8 *pevtcmd; + u32 cmdsz; + struct stassoc_event *padd_sta_evt; + struct C2HEvent_Header *pc2h_evt_hdr; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + + pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (pcmd_obj == NULL) + return; + + cmdsz = (sizeof(struct stassoc_event) + sizeof(struct C2HEvent_Header)); + pevtcmd = (u8 *)rtw_zmalloc(cmdsz); + if (pevtcmd == NULL) { + kfree(pcmd_obj); + return; + } + + _rtw_init_listhead(&pcmd_obj->list); + + pcmd_obj->cmdcode = GEN_CMD_CODE(_Set_MLME_EVT); + pcmd_obj->cmdsz = cmdsz; + pcmd_obj->parmbuf = pevtcmd; + + pcmd_obj->rsp = NULL; + pcmd_obj->rspsz = 0; + + pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); + pc2h_evt_hdr->len = sizeof(struct stassoc_event); + pc2h_evt_hdr->ID = GEN_EVT_CODE(_AddSTA); + pc2h_evt_hdr->seq = ATOMIC_INC_RETURN(&pmlmeext->event_seq); + + padd_sta_evt = (struct stassoc_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); + memcpy((unsigned char *)(&(padd_sta_evt->macaddr)), MacAddr, ETH_ALEN); + padd_sta_evt->cam_id = cam_idx; + + DBG_88E("report_add_sta_event: add STA\n"); + + rtw_enqueue_cmd(pcmdpriv, pcmd_obj); + + return; +} + + +/**************************************************************************** + +Following are the event callback functions + +*****************************************************************************/ + +/* for sta/adhoc mode */ +void update_sta_info(struct adapter *padapter, struct sta_info *psta) +{ + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + /* ERP */ + VCS_update(padapter, psta); + + /* HT */ + if (pmlmepriv->htpriv.ht_option) { + psta->htpriv.ht_option = true; + + psta->htpriv.ampdu_enable = pmlmepriv->htpriv.ampdu_enable; + + if (support_short_GI(padapter, &(pmlmeinfo->HT_caps))) + psta->htpriv.sgi = true; + + psta->qos_option = true; + } else { + psta->htpriv.ht_option = false; + + psta->htpriv.ampdu_enable = false; + + psta->htpriv.sgi = false; + psta->qos_option = false; + } + psta->htpriv.bwmode = pmlmeext->cur_bwmode; + psta->htpriv.ch_offset = pmlmeext->cur_ch_offset; + + psta->htpriv.agg_enable_bitmap = 0x0;/* reset */ + psta->htpriv.candidate_tid_bitmap = 0x0;/* reset */ + + /* QoS */ + if (pmlmepriv->qospriv.qos_option) + psta->qos_option = true; + + + psta->state = _FW_LINKED; +} + +void mlmeext_joinbss_event_callback(struct adapter *padapter, int join_res) +{ + struct sta_info *psta, *psta_bmc; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); + struct sta_priv *pstapriv = &padapter->stapriv; + u8 join_type; + u16 media_status; + + if (join_res < 0) { + join_type = 1; + rtw_hal_set_hwreg(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); + rtw_hal_set_hwreg(padapter, HW_VAR_BSSID, null_addr); + + /* restore to initial setting. */ + update_tx_basic_rate(padapter, padapter->registrypriv.wireless_mode); + + goto exit_mlmeext_joinbss_event_callback; + } + + if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { + /* for bc/mc */ + psta_bmc = rtw_get_bcmc_stainfo(padapter); + if (psta_bmc) { + pmlmeinfo->FW_sta_info[psta_bmc->mac_id].psta = psta_bmc; + update_bmc_sta_support_rate(padapter, psta_bmc->mac_id); + Update_RA_Entry(padapter, psta_bmc->mac_id); + } + } + + + /* turn on dynamic functions */ + Switch_DM_Func(padapter, DYNAMIC_ALL_FUNC_ENABLE, true); + + /* update IOT-releated issue */ + update_IOT_info(padapter); + + rtw_hal_set_hwreg(padapter, HW_VAR_BASIC_RATE, cur_network->SupportedRates); + + /* BCN interval */ + rtw_hal_set_hwreg(padapter, HW_VAR_BEACON_INTERVAL, (u8 *)(&pmlmeinfo->bcn_interval)); + + /* udpate capability */ + update_capinfo(padapter, pmlmeinfo->capability); + + /* WMM, Update EDCA param */ + WMMOnAssocRsp(padapter); + + /* HT */ + HTOnAssocRsp(padapter); + + set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); + + psta = rtw_get_stainfo(pstapriv, cur_network->MacAddress); + if (psta) { /* only for infra. mode */ + pmlmeinfo->FW_sta_info[psta->mac_id].psta = psta; + + psta->wireless_mode = pmlmeext->cur_wireless_mode; + + /* set per sta rate after updating HT cap. */ + set_sta_rate(padapter, psta); + rtw_hal_set_hwreg(padapter, HW_VAR_TX_RPT_MAX_MACID, (u8 *)&psta->mac_id); + media_status = (psta->mac_id<<8)|1; /* MACID|OPMODE: 1 means connect */ + rtw_hal_set_hwreg(padapter, HW_VAR_H2C_MEDIA_STATUS_RPT, (u8 *)&media_status); + } + + join_type = 2; + rtw_hal_set_hwreg(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); + + if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) { + /* correcting TSF */ + correct_TSF(padapter, pmlmeext); + } + rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_CONNECT, 0); + +exit_mlmeext_joinbss_event_callback: + + DBG_88E("=>%s\n", __func__); +} + +void mlmeext_sta_add_event_callback(struct adapter *padapter, struct sta_info *psta) +{ + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + u8 join_type; + + DBG_88E("%s\n", __func__); + + if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { + if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) {/* adhoc master or sta_count>1 */ + /* nothing to do */ + } else { /* adhoc client */ + /* correcting TSF */ + correct_TSF(padapter, pmlmeext); + + /* start beacon */ + if (send_beacon(padapter) == _FAIL) { + pmlmeinfo->FW_sta_info[psta->mac_id].status = 0; + pmlmeinfo->state ^= WIFI_FW_ADHOC_STATE; + return; + } + pmlmeinfo->state |= WIFI_FW_ASSOC_SUCCESS; + } + + join_type = 2; + rtw_hal_set_hwreg(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); + } + + pmlmeinfo->FW_sta_info[psta->mac_id].psta = psta; + + /* rate radaptive */ + Update_RA_Entry(padapter, psta->mac_id); + + /* update adhoc sta_info */ + update_sta_info(padapter, psta); +} + +void mlmeext_sta_del_event_callback(struct adapter *padapter) +{ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + if (is_client_associated_to_ap(padapter) || is_IBSS_empty(padapter)) { + rtw_hal_set_hwreg(padapter, HW_VAR_MLME_DISCONNECT, NULL); + rtw_hal_set_hwreg(padapter, HW_VAR_BSSID, null_addr); + + /* restore to initial setting. */ + update_tx_basic_rate(padapter, padapter->registrypriv.wireless_mode); + + /* switch to the 20M Hz mode after disconnect */ + pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_20; + pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; + + /* SelectChannel(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset); */ + set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); + + + flush_all_cam_entry(padapter); + + pmlmeinfo->state = WIFI_FW_NULL_STATE; + + /* set MSR to no link state -> infra. mode */ + Set_MSR(padapter, _HW_STATE_STATION_); + + _cancel_timer_ex(&pmlmeext->link_timer); + } +} + +/**************************************************************************** + +Following are the functions for the timer handlers + +*****************************************************************************/ +void _linked_rx_signal_strehgth_display(struct adapter *padapter); +void _linked_rx_signal_strehgth_display(struct adapter *padapter) +{ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + u8 mac_id; + int UndecoratedSmoothedPWDB; + if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) + mac_id = 0; + else if ((pmlmeinfo->state&0x03) == _HW_STATE_AP_) + mac_id = 2; + + rtw_hal_get_def_var(padapter, HW_DEF_RA_INFO_DUMP, &mac_id); + + rtw_hal_get_def_var(padapter, HAL_DEF_UNDERCORATEDSMOOTHEDPWDB, &UndecoratedSmoothedPWDB); + DBG_88E("UndecoratedSmoothedPWDB:%d\n", UndecoratedSmoothedPWDB); +} + +static u8 chk_ap_is_alive(struct adapter *padapter, struct sta_info *psta) +{ + u8 ret = false; + + if ((sta_rx_data_pkts(psta) == sta_last_rx_data_pkts(psta)) && + sta_rx_beacon_pkts(psta) == sta_last_rx_beacon_pkts(psta) && + sta_rx_probersp_pkts(psta) == sta_last_rx_probersp_pkts(psta)) + ret = false; + else + ret = true; + + sta_update_last_rx_pkts(psta); + + return ret; +} + +void linked_status_chk(struct adapter *padapter) +{ + u32 i; + struct sta_info *psta; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct sta_priv *pstapriv = &padapter->stapriv; + + if (padapter->bRxRSSIDisplay) + _linked_rx_signal_strehgth_display(padapter); + + rtw_hal_sreset_linked_status_check(padapter); + + if (is_client_associated_to_ap(padapter)) { + /* linked infrastructure client mode */ + + int tx_chk = _SUCCESS, rx_chk = _SUCCESS; + int rx_chk_limit; + + rx_chk_limit = 4; + psta = rtw_get_stainfo(pstapriv, pmlmeinfo->network.MacAddress); + if (psta != NULL) { + bool is_p2p_enable = false; + #ifdef CONFIG_88EU_P2P + is_p2p_enable = !rtw_p2p_chk_state(&padapter->wdinfo, P2P_STATE_NONE); + #endif + + if (!chk_ap_is_alive(padapter, psta)) + rx_chk = _FAIL; + + if (pxmitpriv->last_tx_pkts == pxmitpriv->tx_pkts) + tx_chk = _FAIL; + + if (pmlmeext->active_keep_alive_check && (rx_chk == _FAIL || tx_chk == _FAIL)) { + u8 backup_oper_channel = 0; + + /* switch to correct channel of current network before issue keep-alive frames */ + if (rtw_get_oper_ch(padapter) != pmlmeext->cur_channel) { + backup_oper_channel = rtw_get_oper_ch(padapter); + SelectChannel(padapter, pmlmeext->cur_channel); + } + + if (rx_chk != _SUCCESS) + issue_probereq_ex(padapter, &pmlmeinfo->network.Ssid, psta->hwaddr, 3, 1); + + if ((tx_chk != _SUCCESS && pmlmeinfo->link_count++ == 0xf) || rx_chk != _SUCCESS) { + tx_chk = issue_nulldata(padapter, psta->hwaddr, 0, 3, 1); + /* if tx acked and p2p disabled, set rx_chk _SUCCESS to reset retry count */ + if (tx_chk == _SUCCESS && !is_p2p_enable) + rx_chk = _SUCCESS; + } + + /* back to the original operation channel */ + if (backup_oper_channel > 0) + SelectChannel(padapter, backup_oper_channel); + } else { + if (rx_chk != _SUCCESS) { + if (pmlmeext->retry == 0) { + issue_probereq(padapter, &pmlmeinfo->network.Ssid, pmlmeinfo->network.MacAddress); + issue_probereq(padapter, &pmlmeinfo->network.Ssid, pmlmeinfo->network.MacAddress); + issue_probereq(padapter, &pmlmeinfo->network.Ssid, pmlmeinfo->network.MacAddress); + } + } + + if (tx_chk != _SUCCESS && pmlmeinfo->link_count++ == 0xf) { + tx_chk = issue_nulldata(padapter, NULL, 0, 1, 0); + } + } + + if (rx_chk == _FAIL) { + pmlmeext->retry++; + if (pmlmeext->retry > rx_chk_limit) { + DBG_88E_LEVEL(_drv_always_, FUNC_ADPT_FMT" disconnect or roaming\n", + FUNC_ADPT_ARG(padapter)); + receive_disconnect(padapter, pmlmeinfo->network.MacAddress, + WLAN_REASON_EXPIRATION_CHK); + return; + } + } else { + pmlmeext->retry = 0; + } + + if (tx_chk == _FAIL) { + pmlmeinfo->link_count &= 0xf; + } else { + pxmitpriv->last_tx_pkts = pxmitpriv->tx_pkts; + pmlmeinfo->link_count = 0; + } + } /* end of if ((psta = rtw_get_stainfo(pstapriv, passoc_res->network.MacAddress)) != NULL) */ + } else if (is_client_associated_to_ibss(padapter)) { + /* linked IBSS mode */ + /* for each assoc list entry to check the rx pkt counter */ + for (i = IBSS_START_MAC_ID; i < NUM_STA; i++) { + if (pmlmeinfo->FW_sta_info[i].status == 1) { + psta = pmlmeinfo->FW_sta_info[i].psta; + + if (NULL == psta) + continue; + if (pmlmeinfo->FW_sta_info[i].rx_pkt == sta_rx_pkts(psta)) { + if (pmlmeinfo->FW_sta_info[i].retry < 3) { + pmlmeinfo->FW_sta_info[i].retry++; + } else { + pmlmeinfo->FW_sta_info[i].retry = 0; + pmlmeinfo->FW_sta_info[i].status = 0; + report_del_sta_event(padapter, psta->hwaddr + , 65535/* indicate disconnect caused by no rx */ + ); + } + } else { + pmlmeinfo->FW_sta_info[i].retry = 0; + pmlmeinfo->FW_sta_info[i].rx_pkt = (u32)sta_rx_pkts(psta); + } + } + } + } +} + +void survey_timer_hdl(struct adapter *padapter) +{ + struct cmd_obj *ph2c; + struct sitesurvey_parm *psurveyPara; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); +#endif + + /* issue rtw_sitesurvey_cmd */ + if (pmlmeext->sitesurvey_res.state > SCAN_START) { + if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) + pmlmeext->sitesurvey_res.channel_idx++; + + if (pmlmeext->scan_abort) { + #ifdef CONFIG_88EU_P2P + if (!rtw_p2p_chk_state(&padapter->wdinfo, P2P_STATE_NONE)) { + rtw_p2p_findphase_ex_set(pwdinfo, P2P_FINDPHASE_EX_MAX); + pmlmeext->sitesurvey_res.channel_idx = 3; + DBG_88E("%s idx:%d, cnt:%u\n", __func__ + , pmlmeext->sitesurvey_res.channel_idx + , pwdinfo->find_phase_state_exchange_cnt + ); + } else + #endif + { + pmlmeext->sitesurvey_res.channel_idx = pmlmeext->sitesurvey_res.ch_num; + DBG_88E("%s idx:%d\n", __func__ + , pmlmeext->sitesurvey_res.channel_idx + ); + } + + pmlmeext->scan_abort = false;/* reset */ + } + + ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) + goto exit_survey_timer_hdl; + + psurveyPara = (struct sitesurvey_parm *)rtw_zmalloc(sizeof(struct sitesurvey_parm)); + if (psurveyPara == NULL) { + kfree(ph2c); + goto exit_survey_timer_hdl; + } + + init_h2fwcmd_w_parm_no_rsp(ph2c, psurveyPara, GEN_CMD_CODE(_SiteSurvey)); + rtw_enqueue_cmd(pcmdpriv, ph2c); + } + + +exit_survey_timer_hdl: + return; +} + +void link_timer_hdl(struct adapter *padapter) +{ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) { + DBG_88E("link_timer_hdl:no beacon while connecting\n"); + pmlmeinfo->state = WIFI_FW_NULL_STATE; + report_join_res(padapter, -3); + } else if (pmlmeinfo->state & WIFI_FW_AUTH_STATE) { + /* re-auth timer */ + if (++pmlmeinfo->reauth_count > REAUTH_LIMIT) { + pmlmeinfo->state = 0; + report_join_res(padapter, -1); + return; + } + + DBG_88E("link_timer_hdl: auth timeout and try again\n"); + pmlmeinfo->auth_seq = 1; + issue_auth(padapter, NULL, 0); + set_link_timer(pmlmeext, REAUTH_TO); + } else if (pmlmeinfo->state & WIFI_FW_ASSOC_STATE) { + /* re-assoc timer */ + if (++pmlmeinfo->reassoc_count > REASSOC_LIMIT) { + pmlmeinfo->state = WIFI_FW_NULL_STATE; + report_join_res(padapter, -2); + return; + } + + DBG_88E("link_timer_hdl: assoc timeout and try again\n"); + issue_assocreq(padapter); + set_link_timer(pmlmeext, REASSOC_TO); + } + return; +} + +void addba_timer_hdl(struct sta_info *psta) +{ + struct ht_priv *phtpriv; + + if (!psta) + return; + + phtpriv = &psta->htpriv; + + if ((phtpriv->ht_option) && (phtpriv->ampdu_enable)) { + if (phtpriv->candidate_tid_bitmap) + phtpriv->candidate_tid_bitmap = 0x0; + } +} + +u8 NULL_hdl(struct adapter *padapter, u8 *pbuf) +{ + return H2C_SUCCESS; +} + +u8 setopmode_hdl(struct adapter *padapter, u8 *pbuf) +{ + u8 type; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct setopmode_parm *psetop = (struct setopmode_parm *)pbuf; + + if (psetop->mode == Ndis802_11APMode) { + pmlmeinfo->state = WIFI_FW_AP_STATE; + type = _HW_STATE_AP_; + } else if (psetop->mode == Ndis802_11Infrastructure) { + pmlmeinfo->state &= ~(BIT(0)|BIT(1));/* clear state */ + pmlmeinfo->state |= WIFI_FW_STATION_STATE;/* set to STATION_STATE */ + type = _HW_STATE_STATION_; + } else if (psetop->mode == Ndis802_11IBSS) { + type = _HW_STATE_ADHOC_; + } else { + type = _HW_STATE_NOLINK_; + } + + rtw_hal_set_hwreg(padapter, HW_VAR_SET_OPMODE, (u8 *)(&type)); + /* Set_NETYPE0_MSR(padapter, type); */ + + return H2C_SUCCESS; +} + +u8 createbss_hdl(struct adapter *padapter, u8 *pbuf) +{ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&(pmlmeinfo->network)); + struct joinbss_parm *pparm = (struct joinbss_parm *)pbuf; + /* u32 initialgain; */ + + + if (pparm->network.InfrastructureMode == Ndis802_11APMode) { +#ifdef CONFIG_88EU_AP_MODE + + if (pmlmeinfo->state == WIFI_FW_AP_STATE) { + /* todo: */ + return H2C_SUCCESS; + } +#endif + } + + /* below is for ad-hoc master */ + if (pparm->network.InfrastructureMode == Ndis802_11IBSS) { + rtw_joinbss_reset(padapter); + + pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_20; + pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; + pmlmeinfo->ERP_enable = 0; + pmlmeinfo->WMM_enable = 0; + pmlmeinfo->HT_enable = 0; + pmlmeinfo->HT_caps_enable = 0; + pmlmeinfo->HT_info_enable = 0; + pmlmeinfo->agg_enable_bitmap = 0; + pmlmeinfo->candidate_tid_bitmap = 0; + + /* disable dynamic functions, such as high power, DIG */ + Save_DM_Func_Flag(padapter); + Switch_DM_Func(padapter, DYNAMIC_FUNC_DISABLE, false); + + /* config the initial gain under linking, need to write the BB registers */ + /* initialgain = 0x1E; */ + /* rtw_hal_set_hwreg(padapter, HW_VAR_INITIAL_GAIN, (u8 *)(&initialgain)); */ + + /* cancel link timer */ + _cancel_timer_ex(&pmlmeext->link_timer); + + /* clear CAM */ + flush_all_cam_entry(padapter); + + memcpy(pnetwork, pbuf, FIELD_OFFSET(struct wlan_bssid_ex, IELength)); + pnetwork->IELength = ((struct wlan_bssid_ex *)pbuf)->IELength; + + if (pnetwork->IELength > MAX_IE_SZ)/* Check pbuf->IELength */ + return H2C_PARAMETERS_ERROR; + + memcpy(pnetwork->IEs, ((struct wlan_bssid_ex *)pbuf)->IEs, pnetwork->IELength); + + start_create_ibss(padapter); + } + + return H2C_SUCCESS; +} + +u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf) +{ + u8 join_type; + struct ndis_802_11_var_ie *pIE; + struct registry_priv *pregpriv = &padapter->registrypriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&(pmlmeinfo->network)); + struct joinbss_parm *pparm = (struct joinbss_parm *)pbuf; + u32 i; + + /* check already connecting to AP or not */ + if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) { + if (pmlmeinfo->state & WIFI_FW_STATION_STATE) + issue_deauth_ex(padapter, pnetwork->MacAddress, WLAN_REASON_DEAUTH_LEAVING, 5, 100); + + pmlmeinfo->state = WIFI_FW_NULL_STATE; + + /* clear CAM */ + flush_all_cam_entry(padapter); + + _cancel_timer_ex(&pmlmeext->link_timer); + + /* set MSR to nolink -> infra. mode */ + Set_MSR(padapter, _HW_STATE_STATION_); + + + rtw_hal_set_hwreg(padapter, HW_VAR_MLME_DISCONNECT, NULL); + } + + rtw_antenna_select_cmd(padapter, pparm->network.PhyInfo.Optimum_antenna, false); + + rtw_joinbss_reset(padapter); + + pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_20; + pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; + pmlmeinfo->ERP_enable = 0; + pmlmeinfo->WMM_enable = 0; + pmlmeinfo->HT_enable = 0; + pmlmeinfo->HT_caps_enable = 0; + pmlmeinfo->HT_info_enable = 0; + pmlmeinfo->agg_enable_bitmap = 0; + pmlmeinfo->candidate_tid_bitmap = 0; + pmlmeinfo->bwmode_updated = false; + + memcpy(pnetwork, pbuf, FIELD_OFFSET(struct wlan_bssid_ex, IELength)); + pnetwork->IELength = ((struct wlan_bssid_ex *)pbuf)->IELength; + + if (pnetwork->IELength > MAX_IE_SZ)/* Check pbuf->IELength */ + return H2C_PARAMETERS_ERROR; + + memcpy(pnetwork->IEs, ((struct wlan_bssid_ex *)pbuf)->IEs, pnetwork->IELength); + + /* Check AP vendor to move rtw_joinbss_cmd() */ + + for (i = sizeof(struct ndis_802_11_fixed_ie); i < pnetwork->IELength;) { + pIE = (struct ndis_802_11_var_ie *)(pnetwork->IEs + i); + + switch (pIE->ElementID) { + case _VENDOR_SPECIFIC_IE_:/* Get WMM IE. */ + if (_rtw_memcmp(pIE->data, WMM_OUI, 4)) + pmlmeinfo->WMM_enable = 1; + break; + case _HT_CAPABILITY_IE_: /* Get HT Cap IE. */ + pmlmeinfo->HT_caps_enable = 1; + break; + case _HT_EXTRA_INFO_IE_: /* Get HT Info IE. */ + pmlmeinfo->HT_info_enable = 1; + + /* spec case only for cisco's ap because cisco's ap issue assoc rsp using mcs rate @40MHz or @20MHz */ + { + struct HT_info_element *pht_info = (struct HT_info_element *)(pIE->data); + + if ((pregpriv->cbw40_enable) && (pht_info->infos[0] & BIT(2))) { + /* switch to the 40M Hz mode according to the AP */ + pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_40; + switch (pht_info->infos[0] & 0x3) { + case 1: + pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER; + break; + case 3: + pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER; + break; + default: + pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; + break; + } + + DBG_88E("set ch/bw before connected\n"); + } + } + break; + default: + break; + } + + i += (pIE->Length + 2); + } + /* disable dynamic functions, such as high power, DIG */ + + /* config the initial gain under linking, need to write the BB registers */ + + rtw_hal_set_hwreg(padapter, HW_VAR_BSSID, pmlmeinfo->network.MacAddress); + join_type = 0; + rtw_hal_set_hwreg(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); + + /* cancel link timer */ + _cancel_timer_ex(&pmlmeext->link_timer); + + start_clnt_join(padapter); + + return H2C_SUCCESS; +} + +u8 disconnect_hdl(struct adapter *padapter, unsigned char *pbuf) +{ + struct disconnect_parm *param = (struct disconnect_parm *)pbuf; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&(pmlmeinfo->network)); + u8 val8; + + if (is_client_associated_to_ap(padapter)) + issue_deauth_ex(padapter, pnetwork->MacAddress, WLAN_REASON_DEAUTH_LEAVING, param->deauth_timeout_ms/100, 100); + + rtw_hal_set_hwreg(padapter, HW_VAR_MLME_DISCONNECT, NULL); + rtw_hal_set_hwreg(padapter, HW_VAR_BSSID, null_addr); + + /* restore to initial setting. */ + update_tx_basic_rate(padapter, padapter->registrypriv.wireless_mode); + + if (((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE)) { + /* Stop BCN */ + val8 = 0; + rtw_hal_set_hwreg(padapter, HW_VAR_BCN_FUNC, (u8 *)(&val8)); + } + + + /* set MSR to no link state -> infra. mode */ + Set_MSR(padapter, _HW_STATE_STATION_); + + pmlmeinfo->state = WIFI_FW_NULL_STATE; + + /* switch to the 20M Hz mode after disconnect */ + pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_20; + pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; + + set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); + + flush_all_cam_entry(padapter); + + _cancel_timer_ex(&pmlmeext->link_timer); + + rtw_free_uc_swdec_pending_queue(padapter); + + return H2C_SUCCESS; +} + +static int rtw_scan_ch_decision(struct adapter *padapter, struct rtw_ieee80211_channel *out, + u32 out_num, struct rtw_ieee80211_channel *in, u32 in_num) +{ + int i, j; + int set_idx; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + + /* clear out first */ + _rtw_memset(out, 0, sizeof(struct rtw_ieee80211_channel)*out_num); + + /* acquire channels from in */ + j = 0; + for (i = 0; i < in_num; i++) { + set_idx = rtw_ch_set_search_ch(pmlmeext->channel_set, in[i].hw_value); + if (in[i].hw_value && !(in[i].flags & RTW_IEEE80211_CHAN_DISABLED) && + set_idx >= 0) { + memcpy(&out[j], &in[i], sizeof(struct rtw_ieee80211_channel)); + + if (pmlmeext->channel_set[set_idx].ScanType == SCAN_PASSIVE) + out[j].flags &= RTW_IEEE80211_CHAN_PASSIVE_SCAN; + + j++; + } + if (j >= out_num) + break; + } + + /* if out is empty, use channel_set as default */ + if (j == 0) { + for (i = 0; i < pmlmeext->max_chan_nums; i++) { + out[i].hw_value = pmlmeext->channel_set[i].ChannelNum; + + if (pmlmeext->channel_set[i].ScanType == SCAN_PASSIVE) + out[i].flags &= RTW_IEEE80211_CHAN_PASSIVE_SCAN; + + j++; + } + } + + return j; +} + +u8 sitesurvey_cmd_hdl(struct adapter *padapter, u8 *pbuf) +{ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct sitesurvey_parm *pparm = (struct sitesurvey_parm *)pbuf; + u8 bdelayscan = false; + u8 val8; + u32 initialgain; + u32 i; + +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &padapter->wdinfo; +#endif + + if (pmlmeext->sitesurvey_res.state == SCAN_DISABLE) { + /* for first time sitesurvey_cmd */ + rtw_hal_set_hwreg(padapter, HW_VAR_CHECK_TXBUF, NULL); + + pmlmeext->sitesurvey_res.state = SCAN_START; + pmlmeext->sitesurvey_res.bss_cnt = 0; + pmlmeext->sitesurvey_res.channel_idx = 0; + + for (i = 0; i < RTW_SSID_SCAN_AMOUNT; i++) { + if (pparm->ssid[i].SsidLength) { + memcpy(pmlmeext->sitesurvey_res.ssid[i].Ssid, pparm->ssid[i].Ssid, IW_ESSID_MAX_SIZE); + pmlmeext->sitesurvey_res.ssid[i].SsidLength = pparm->ssid[i].SsidLength; + } else { + pmlmeext->sitesurvey_res.ssid[i].SsidLength = 0; + } + } + + pmlmeext->sitesurvey_res.ch_num = rtw_scan_ch_decision(padapter + , pmlmeext->sitesurvey_res.ch, RTW_CHANNEL_SCAN_AMOUNT + , pparm->ch, pparm->ch_num + ); + + pmlmeext->sitesurvey_res.scan_mode = pparm->scan_mode; + + /* issue null data if associating to the AP */ + if (is_client_associated_to_ap(padapter)) { + pmlmeext->sitesurvey_res.state = SCAN_TXNULL; + + issue_nulldata(padapter, NULL, 1, 3, 500); + + bdelayscan = true; + } + if (bdelayscan) { + /* delay 50ms to protect nulldata(1). */ + set_survey_timer(pmlmeext, 50); + return H2C_SUCCESS; + } + } + + if ((pmlmeext->sitesurvey_res.state == SCAN_START) || (pmlmeext->sitesurvey_res.state == SCAN_TXNULL)) { + /* disable dynamic functions, such as high power, DIG */ + Save_DM_Func_Flag(padapter); + Switch_DM_Func(padapter, DYNAMIC_FUNC_DISABLE, false); + + /* config the initial gain under scaning, need to write the BB registers */ +#ifdef CONFIG_88EU_P2P + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) + initialgain = 0x1E; + else + initialgain = 0x28; +#else /* CONFIG_88EU_P2P */ + initialgain = 0x1E; +#endif /* CONFIG_88EU_P2P */ + + rtw_hal_set_hwreg(padapter, HW_VAR_INITIAL_GAIN, (u8 *)(&initialgain)); + + /* set MSR to no link state */ + Set_MSR(padapter, _HW_STATE_NOLINK_); + + val8 = 1; /* under site survey */ + rtw_hal_set_hwreg(padapter, HW_VAR_MLME_SITESURVEY, (u8 *)(&val8)); + + pmlmeext->sitesurvey_res.state = SCAN_PROCESS; + } + + site_survey(padapter); + + return H2C_SUCCESS; +} + +u8 setauth_hdl(struct adapter *padapter, unsigned char *pbuf) +{ + struct setauth_parm *pparm = (struct setauth_parm *)pbuf; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + if (pparm->mode < 4) + pmlmeinfo->auth_algo = pparm->mode; + return H2C_SUCCESS; +} + +u8 setkey_hdl(struct adapter *padapter, u8 *pbuf) +{ + unsigned short ctrl; + struct setkey_parm *pparm = (struct setkey_parm *)pbuf; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + unsigned char null_sta[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + + /* main tx key for wep. */ + if (pparm->set_tx) + pmlmeinfo->key_index = pparm->keyid; + + /* write cam */ + ctrl = BIT(15) | ((pparm->algorithm) << 2) | pparm->keyid; + + DBG_88E_LEVEL(_drv_info_, "set group key to hw: alg:%d(WEP40-1 WEP104-5 TKIP-2 AES-4) " + "keyid:%d\n", pparm->algorithm, pparm->keyid); + write_cam(padapter, pparm->keyid, ctrl, null_sta, pparm->key); + + return H2C_SUCCESS; +} + +u8 set_stakey_hdl(struct adapter *padapter, u8 *pbuf) +{ + u16 ctrl = 0; + u8 cam_id;/* cam_entry */ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct set_stakey_parm *pparm = (struct set_stakey_parm *)pbuf; + + /* cam_entry: */ + /* 0~3 for default key */ + + /* for concurrent mode (ap+sta): */ + /* default key is disable, using sw encrypt/decrypt */ + /* cam_entry = 4 for sta mode (macid = 0) */ + /* cam_entry(macid+3) = 5 ~ N for ap mode (aid = 1~N, macid = 2 ~N) */ + + /* for concurrent mode (sta+sta): */ + /* default key is disable, using sw encrypt/decrypt */ + /* cam_entry = 4 mapping to macid = 0 */ + /* cam_entry = 5 mapping to macid = 2 */ + + cam_id = 4; + + DBG_88E_LEVEL(_drv_info_, "set pairwise key to hw: alg:%d(WEP40-1 WEP104-5 TKIP-2 AES-4) camid:%d\n", + pparm->algorithm, cam_id); + if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) { + struct sta_info *psta; + struct sta_priv *pstapriv = &padapter->stapriv; + + if (pparm->algorithm == _NO_PRIVACY_) /* clear cam entry */ { + clear_cam_entry(padapter, pparm->id); + return H2C_SUCCESS_RSP; + } + + psta = rtw_get_stainfo(pstapriv, pparm->addr); + if (psta) { + ctrl = (BIT(15) | ((pparm->algorithm) << 2)); + + DBG_88E("r871x_set_stakey_hdl(): enc_algorithm=%d\n", pparm->algorithm); + + if ((psta->mac_id < 1) || (psta->mac_id > (NUM_STA-4))) { + DBG_88E("r871x_set_stakey_hdl():set_stakey failed, mac_id(aid)=%d\n", psta->mac_id); + return H2C_REJECTED; + } + + cam_id = (psta->mac_id + 3);/* 0~3 for default key, cmd_id = macid + 3, macid = aid+1; */ + + DBG_88E("Write CAM, mac_addr =%x:%x:%x:%x:%x:%x, cam_entry=%d\n", pparm->addr[0], + pparm->addr[1], pparm->addr[2], pparm->addr[3], pparm->addr[4], + pparm->addr[5], cam_id); + + write_cam(padapter, cam_id, ctrl, pparm->addr, pparm->key); + + return H2C_SUCCESS_RSP; + } else { + DBG_88E("r871x_set_stakey_hdl(): sta has been free\n"); + return H2C_REJECTED; + } + } + + /* below for sta mode */ + + if (pparm->algorithm == _NO_PRIVACY_) { /* clear cam entry */ + clear_cam_entry(padapter, pparm->id); + return H2C_SUCCESS; + } + ctrl = BIT(15) | ((pparm->algorithm) << 2); + write_cam(padapter, cam_id, ctrl, pparm->addr, pparm->key); + pmlmeinfo->enc_algo = pparm->algorithm; + return H2C_SUCCESS; +} + +u8 add_ba_hdl(struct adapter *padapter, unsigned char *pbuf) +{ + struct addBaReq_parm *pparm = (struct addBaReq_parm *)pbuf; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + struct sta_info *psta = rtw_get_stainfo(&padapter->stapriv, pparm->addr); + + if (!psta) + return H2C_SUCCESS; + + if (((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && (pmlmeinfo->HT_enable)) || + ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE)) { + issue_action_BA(padapter, pparm->addr, RTW_WLAN_ACTION_ADDBA_REQ, (u16)pparm->tid); + _set_timer(&psta->addba_retry_timer, ADDBA_TO); + } else { + psta->htpriv.candidate_tid_bitmap &= ~BIT(pparm->tid); + } + return H2C_SUCCESS; +} + +u8 set_tx_beacon_cmd(struct adapter *padapter) +{ + struct cmd_obj *ph2c; + struct Tx_Beacon_param *ptxBeacon_parm; + struct cmd_priv *pcmdpriv = &(padapter->cmdpriv); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + u8 res = _SUCCESS; + int len_diff = 0; + +_func_enter_; + + ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + + ptxBeacon_parm = (struct Tx_Beacon_param *)rtw_zmalloc(sizeof(struct Tx_Beacon_param)); + if (ptxBeacon_parm == NULL) { + kfree(ph2c); + res = _FAIL; + goto exit; + } + + memcpy(&(ptxBeacon_parm->network), &(pmlmeinfo->network), sizeof(struct wlan_bssid_ex)); + + len_diff = update_hidden_ssid(ptxBeacon_parm->network.IEs+_BEACON_IE_OFFSET_, + ptxBeacon_parm->network.IELength-_BEACON_IE_OFFSET_, + pmlmeinfo->hidden_ssid_mode); + ptxBeacon_parm->network.IELength += len_diff; + + init_h2fwcmd_w_parm_no_rsp(ph2c, ptxBeacon_parm, GEN_CMD_CODE(_TX_Beacon)); + + res = rtw_enqueue_cmd(pcmdpriv, ph2c); + + +exit: + +_func_exit_; + + return res; +} + +u8 mlme_evt_hdl(struct adapter *padapter, unsigned char *pbuf) +{ + u8 evt_code; + u16 evt_sz; + uint *peventbuf; + void (*event_callback)(struct adapter *dev, u8 *pbuf); + struct evt_priv *pevt_priv = &(padapter->evtpriv); + + peventbuf = (uint *)pbuf; + evt_sz = (u16)(*peventbuf&0xffff); + evt_code = (u8)((*peventbuf>>16)&0xff); + + /* checking if event code is valid */ + if (evt_code >= MAX_C2HEVT) { + RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\nEvent Code(%d) mismatch!\n", evt_code)); + goto _abort_event_; + } + + /* checking if event size match the event parm size */ + if ((wlanevents[evt_code].parmsize != 0) && + (wlanevents[evt_code].parmsize != evt_sz)) { + RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, + ("\nEvent(%d) Parm Size mismatch (%d vs %d)!\n", + evt_code, wlanevents[evt_code].parmsize, evt_sz)); + goto _abort_event_; + } + + ATOMIC_INC(&pevt_priv->event_seq); + + peventbuf += 2; + + if (peventbuf) { + event_callback = wlanevents[evt_code].event_callback; + event_callback(padapter, (u8 *)peventbuf); + + pevt_priv->evt_done_cnt++; + } + +_abort_event_: + return H2C_SUCCESS; +} + +u8 h2c_msg_hdl(struct adapter *padapter, unsigned char *pbuf) +{ + if (!pbuf) + return H2C_PARAMETERS_ERROR; + + return H2C_SUCCESS; +} + +u8 tx_beacon_hdl(struct adapter *padapter, unsigned char *pbuf) +{ + if (send_beacon(padapter) == _FAIL) { + DBG_88E("issue_beacon, fail!\n"); + return H2C_PARAMETERS_ERROR; + } +#ifdef CONFIG_88EU_AP_MODE + else { /* tx bc/mc frames after update TIM */ + unsigned long irqL; + struct sta_info *psta_bmc; + struct list_head *xmitframe_plist, *xmitframe_phead; + struct xmit_frame *pxmitframe = NULL; + struct sta_priv *pstapriv = &padapter->stapriv; + + /* for BC/MC Frames */ + psta_bmc = rtw_get_bcmc_stainfo(padapter); + if (!psta_bmc) + return H2C_SUCCESS; + + if ((pstapriv->tim_bitmap&BIT(0)) && (psta_bmc->sleepq_len > 0)) { + rtw_msleep_os(10);/* 10ms, ATIM(HIQ) Windows */ + _enter_critical_bh(&psta_bmc->sleep_q.lock, &irqL); + + xmitframe_phead = get_list_head(&psta_bmc->sleep_q); + xmitframe_plist = get_next(xmitframe_phead); + + while (!rtw_end_of_queue_search(xmitframe_phead, xmitframe_plist)) { + pxmitframe = LIST_CONTAINOR(xmitframe_plist, struct xmit_frame, list); + + xmitframe_plist = get_next(xmitframe_plist); + + rtw_list_delete(&pxmitframe->list); + + psta_bmc->sleepq_len--; + if (psta_bmc->sleepq_len > 0) + pxmitframe->attrib.mdata = 1; + else + pxmitframe->attrib.mdata = 0; + + pxmitframe->attrib.triggered = 1; + + pxmitframe->attrib.qsel = 0x11;/* HIQ */ + + _exit_critical_bh(&psta_bmc->sleep_q.lock, &irqL); + if (rtw_hal_xmit(padapter, pxmitframe)) + rtw_os_xmit_complete(padapter, pxmitframe); + _enter_critical_bh(&psta_bmc->sleep_q.lock, &irqL); + } + _exit_critical_bh(&psta_bmc->sleep_q.lock, &irqL); + } + } +#endif + return H2C_SUCCESS; +} + +u8 set_ch_hdl(struct adapter *padapter, u8 *pbuf) +{ + struct set_ch_parm *set_ch_parm; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + + if (!pbuf) + return H2C_PARAMETERS_ERROR; + + set_ch_parm = (struct set_ch_parm *)pbuf; + + DBG_88E(FUNC_NDEV_FMT" ch:%u, bw:%u, ch_offset:%u\n", + FUNC_NDEV_ARG(padapter->pnetdev), + set_ch_parm->ch, set_ch_parm->bw, set_ch_parm->ch_offset); + + pmlmeext->cur_channel = set_ch_parm->ch; + pmlmeext->cur_ch_offset = set_ch_parm->ch_offset; + pmlmeext->cur_bwmode = set_ch_parm->bw; + + set_channel_bwmode(padapter, set_ch_parm->ch, set_ch_parm->ch_offset, set_ch_parm->bw); + + return H2C_SUCCESS; +} + +u8 set_chplan_hdl(struct adapter *padapter, unsigned char *pbuf) +{ + struct SetChannelPlan_param *setChannelPlan_param; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + + if (!pbuf) + return H2C_PARAMETERS_ERROR; + + setChannelPlan_param = (struct SetChannelPlan_param *)pbuf; + + pmlmeext->max_chan_nums = init_channel_set(padapter, setChannelPlan_param->channel_plan, pmlmeext->channel_set); + init_channel_list(padapter, pmlmeext->channel_set, pmlmeext->max_chan_nums, &pmlmeext->channel_list); + + return H2C_SUCCESS; +} + +u8 led_blink_hdl(struct adapter *padapter, unsigned char *pbuf) +{ + if (!pbuf) + return H2C_PARAMETERS_ERROR; + return H2C_SUCCESS; +} + +u8 set_csa_hdl(struct adapter *padapter, unsigned char *pbuf) +{ + return H2C_REJECTED; +} + +/* TDLS_WRCR : write RCR DATA BIT */ +/* TDLS_SD_PTI : issue peer traffic indication */ +/* TDLS_CS_OFF : go back to the channel linked with AP, terminating channel switch procedure */ +/* TDLS_INIT_CH_SEN : init channel sensing, receive all data and mgnt frame */ +/* TDLS_DONE_CH_SEN: channel sensing and report candidate channel */ +/* TDLS_OFF_CH : first time set channel to off channel */ +/* TDLS_BASE_CH : go back tp the channel linked with AP when set base channel as target channel */ +/* TDLS_P_OFF_CH : periodically go to off channel */ +/* TDLS_P_BASE_CH : periodically go back to base channel */ +/* TDLS_RS_RCR : restore RCR */ +/* TDLS_CKALV_PH1 : check alive timer phase1 */ +/* TDLS_CKALV_PH2 : check alive timer phase2 */ +/* TDLS_FREE_STA : free tdls sta */ +u8 tdls_hdl(struct adapter *padapter, unsigned char *pbuf) +{ + return H2C_REJECTED; +} diff --git a/drivers/staging/rtl8188eu/core/rtw_mp.c b/drivers/staging/rtl8188eu/core/rtw_mp.c new file mode 100644 index 0000000000000..c7ff2e4d1f23f --- /dev/null +++ b/drivers/staging/rtl8188eu/core/rtw_mp.c @@ -0,0 +1,997 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + *published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTW_MP_C_ + +#include + +#include "odm_precomp.h" +#include "rtl8188e_hal.h" + +u32 read_macreg(struct adapter *padapter, u32 addr, u32 sz) +{ + u32 val = 0; + + switch (sz) { + case 1: + val = rtw_read8(padapter, addr); + break; + case 2: + val = rtw_read16(padapter, addr); + break; + case 4: + val = rtw_read32(padapter, addr); + break; + default: + val = 0xffffffff; + break; + } + + return val; +} + +void write_macreg(struct adapter *padapter, u32 addr, u32 val, u32 sz) +{ + switch (sz) { + case 1: + rtw_write8(padapter, addr, (u8)val); + break; + case 2: + rtw_write16(padapter, addr, (u16)val); + break; + case 4: + rtw_write32(padapter, addr, val); + break; + default: + break; + } +} + +u32 read_bbreg(struct adapter *padapter, u32 addr, u32 bitmask) +{ + return rtw_hal_read_bbreg(padapter, addr, bitmask); +} + +void write_bbreg(struct adapter *padapter, u32 addr, u32 bitmask, u32 val) +{ + rtw_hal_write_bbreg(padapter, addr, bitmask, val); +} + +u32 _read_rfreg(struct adapter *padapter, u8 rfpath, u32 addr, u32 bitmask) +{ + return rtw_hal_read_rfreg(padapter, (enum rf_radio_path)rfpath, addr, bitmask); +} + +void _write_rfreg(struct adapter *padapter, u8 rfpath, u32 addr, u32 bitmask, u32 val) +{ + rtw_hal_write_rfreg(padapter, (enum rf_radio_path)rfpath, addr, bitmask, val); +} + +u32 read_rfreg(struct adapter *padapter, u8 rfpath, u32 addr) +{ + return _read_rfreg(padapter, (enum rf_radio_path)rfpath, addr, bRFRegOffsetMask); +} + +void write_rfreg(struct adapter *padapter, u8 rfpath, u32 addr, u32 val) +{ + _write_rfreg(padapter, (enum rf_radio_path)rfpath, addr, bRFRegOffsetMask, val); +} + +static void _init_mp_priv_(struct mp_priv *pmp_priv) +{ + struct wlan_bssid_ex *pnetwork; + + _rtw_memset(pmp_priv, 0, sizeof(struct mp_priv)); + + pmp_priv->mode = MP_OFF; + + pmp_priv->channel = 1; + pmp_priv->bandwidth = HT_CHANNEL_WIDTH_20; + pmp_priv->prime_channel_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; + pmp_priv->rateidx = MPT_RATE_1M; + pmp_priv->txpoweridx = 0x2A; + + pmp_priv->antenna_tx = ANTENNA_A; + pmp_priv->antenna_rx = ANTENNA_AB; + + pmp_priv->check_mp_pkt = 0; + + pmp_priv->tx_pktcount = 0; + + pmp_priv->rx_pktcount = 0; + pmp_priv->rx_crcerrpktcount = 0; + + pmp_priv->network_macaddr[0] = 0x00; + pmp_priv->network_macaddr[1] = 0xE0; + pmp_priv->network_macaddr[2] = 0x4C; + pmp_priv->network_macaddr[3] = 0x87; + pmp_priv->network_macaddr[4] = 0x66; + pmp_priv->network_macaddr[5] = 0x55; + + pnetwork = &pmp_priv->mp_network.network; + memcpy(pnetwork->MacAddress, pmp_priv->network_macaddr, ETH_ALEN); + + pnetwork->Ssid.SsidLength = 8; + memcpy(pnetwork->Ssid.Ssid, "mp_871x", pnetwork->Ssid.SsidLength); +} + +static void mp_init_xmit_attrib(struct mp_tx *pmptx, struct adapter *padapter) +{ + struct pkt_attrib *pattrib; + struct tx_desc *desc; + + /* init xmitframe attribute */ + pattrib = &pmptx->attrib; + _rtw_memset(pattrib, 0, sizeof(struct pkt_attrib)); + desc = &pmptx->desc; + _rtw_memset(desc, 0, TXDESC_SIZE); + + pattrib->ether_type = 0x8712; + _rtw_memset(pattrib->dst, 0xFF, ETH_ALEN); + pattrib->ack_policy = 0; + pattrib->hdrlen = WLAN_HDR_A3_LEN; + pattrib->subtype = WIFI_DATA; + pattrib->priority = 0; + pattrib->qsel = pattrib->priority; + pattrib->nr_frags = 1; + pattrib->encrypt = 0; + pattrib->bswenc = false; + pattrib->qos_en = false; +} + +s32 init_mp_priv(struct adapter *padapter) +{ + struct mp_priv *pmppriv = &padapter->mppriv; + + _init_mp_priv_(pmppriv); + pmppriv->papdater = padapter; + + pmppriv->tx.stop = 1; + mp_init_xmit_attrib(&pmppriv->tx, padapter); + + switch (padapter->registrypriv.rf_config) { + case RF_1T1R: + pmppriv->antenna_tx = ANTENNA_A; + pmppriv->antenna_rx = ANTENNA_A; + break; + case RF_1T2R: + default: + pmppriv->antenna_tx = ANTENNA_A; + pmppriv->antenna_rx = ANTENNA_AB; + break; + case RF_2T2R: + case RF_2T2R_GREEN: + pmppriv->antenna_tx = ANTENNA_AB; + pmppriv->antenna_rx = ANTENNA_AB; + break; + case RF_2T4R: + pmppriv->antenna_tx = ANTENNA_AB; + pmppriv->antenna_rx = ANTENNA_ABCD; + break; + } + + return _SUCCESS; +} + +void free_mp_priv(struct mp_priv *pmp_priv) +{ + kfree(pmp_priv->pallocated_mp_xmitframe_buf); + pmp_priv->pallocated_mp_xmitframe_buf = NULL; + pmp_priv->pmp_xmtframe_buf = NULL; +} + +#define PHY_IQCalibrate(a, b) PHY_IQCalibrate_8188E(a, b) +#define PHY_LCCalibrate(a) PHY_LCCalibrate_8188E(a) +#define PHY_SetRFPathSwitch(a, b) PHY_SetRFPathSwitch_8188E(a, b) + +s32 MPT_InitializeAdapter(struct adapter *pAdapter, u8 Channel) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); + s32 rtStatus = _SUCCESS; + struct mpt_context *pMptCtx = &pAdapter->mppriv.MptCtx; + struct mlme_priv *pmlmepriv = &pAdapter->mlmepriv; + + /* HW Initialization for 8190 MPT. */ + /* SW Initialization for 8190 MP. */ + pMptCtx->bMptDrvUnload = false; + pMptCtx->bMassProdTest = false; + pMptCtx->bMptIndexEven = true; /* default gain index is -6.0db */ + pMptCtx->h2cReqNum = 0x0; + /* Init mpt event. */ + /* init for BT MP */ + + pMptCtx->bMptWorkItemInProgress = false; + pMptCtx->CurrMptAct = NULL; + /* */ + + /* Don't accept any packets */ + rtw_write32(pAdapter, REG_RCR, 0); + + PHY_IQCalibrate(pAdapter, false); + dm_CheckTXPowerTracking(&pHalData->odmpriv); /* trigger thermal meter */ + PHY_LCCalibrate(pAdapter); + + pMptCtx->backup0xc50 = (u8)PHY_QueryBBReg(pAdapter, rOFDM0_XAAGCCore1, bMaskByte0); + pMptCtx->backup0xc58 = (u8)PHY_QueryBBReg(pAdapter, rOFDM0_XBAGCCore1, bMaskByte0); + pMptCtx->backup0xc30 = (u8)PHY_QueryBBReg(pAdapter, rOFDM0_RxDetector1, bMaskByte0); + pMptCtx->backup0x52_RF_A = (u8)PHY_QueryRFReg(pAdapter, RF_PATH_A, RF_0x52, 0x000F0); + pMptCtx->backup0x52_RF_B = (u8)PHY_QueryRFReg(pAdapter, RF_PATH_A, RF_0x52, 0x000F0); + + /* set ant to wifi side in mp mode */ + rtw_write16(pAdapter, 0x870, 0x300); + rtw_write16(pAdapter, 0x860, 0x110); + + if (pAdapter->registrypriv.mp_mode == 1) + pmlmepriv->fw_state = WIFI_MP_STATE; + + return rtStatus; +} + +/*----------------------------------------------------------------------------- + * Function: MPT_DeInitAdapter() + * + * Overview: Extra DeInitialization for Mass Production Test. + * + * Input: struct adapter * pAdapter + * + * Output: NONE + * + * Return: NONE + * + * Revised History: + * When Who Remark + * 05/08/2007 MHC Create Version 0. + * 05/18/2007 MHC Add normal driver MPHalt code. + * + *---------------------------------------------------------------------------*/ +void MPT_DeInitAdapter(struct adapter *pAdapter) +{ + struct mpt_context *pMptCtx = &pAdapter->mppriv.MptCtx; + + pMptCtx->bMptDrvUnload = true; +} + +static u8 mpt_ProStartTest(struct adapter *padapter) +{ + struct mpt_context *pMptCtx = &padapter->mppriv.MptCtx; + + pMptCtx->bMassProdTest = true; + pMptCtx->bStartContTx = false; + pMptCtx->bCckContTx = false; + pMptCtx->bOfdmContTx = false; + pMptCtx->bSingleCarrier = false; + pMptCtx->bCarrierSuppression = false; + pMptCtx->bSingleTone = false; + + return _SUCCESS; +} + +/* + * General use + */ +s32 SetPowerTracking(struct adapter *padapter, u8 enable) +{ + Hal_SetPowerTracking(padapter, enable); + return 0; +} + +void GetPowerTracking(struct adapter *padapter, u8 *enable) +{ + Hal_GetPowerTracking(padapter, enable); +} + +static void disable_dm(struct adapter *padapter) +{ + u8 v8; + + /* 3 1. disable firmware dynamic mechanism */ + /* disable Power Training, Rate Adaptive */ + v8 = rtw_read8(padapter, REG_BCN_CTRL); + v8 &= ~EN_BCN_FUNCTION; + rtw_write8(padapter, REG_BCN_CTRL, v8); + + /* 3 2. disable driver dynamic mechanism */ + /* disable Dynamic Initial Gain */ + /* disable High Power */ + /* disable Power Tracking */ + Switch_DM_Func(padapter, DYNAMIC_FUNC_DISABLE, false); + + /* enable APK, LCK and IQK but disable power tracking */ + Switch_DM_Func(padapter, DYNAMIC_RF_CALIBRATION, true); +} + +/* This function initializes the DUT to the MP test mode */ +s32 mp_start_test(struct adapter *padapter) +{ + struct wlan_bssid_ex bssid; + struct sta_info *psta; + u32 length; + u8 val8; + + unsigned long irqL; + s32 res = _SUCCESS; + + struct mp_priv *pmppriv = &padapter->mppriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct wlan_network *tgt_network = &pmlmepriv->cur_network; + + padapter->registrypriv.mp_mode = 1; + pmppriv->bSetTxPower = 0; /* for manually set tx power */ + + /* 3 disable dynamic mechanism */ + disable_dm(padapter); + + /* 3 0. update mp_priv */ + + if (padapter->registrypriv.rf_config == RF_819X_MAX_TYPE) { + switch (GET_RF_TYPE(padapter)) { + case RF_1T1R: + pmppriv->antenna_tx = ANTENNA_A; + pmppriv->antenna_rx = ANTENNA_A; + break; + case RF_1T2R: + default: + pmppriv->antenna_tx = ANTENNA_A; + pmppriv->antenna_rx = ANTENNA_AB; + break; + case RF_2T2R: + case RF_2T2R_GREEN: + pmppriv->antenna_tx = ANTENNA_AB; + pmppriv->antenna_rx = ANTENNA_AB; + break; + case RF_2T4R: + pmppriv->antenna_tx = ANTENNA_AB; + pmppriv->antenna_rx = ANTENNA_ABCD; + break; + } + } + + mpt_ProStartTest(padapter); + + /* 3 1. initialize a new struct wlan_bssid_ex */ +/* _rtw_memset(&bssid, 0, sizeof(struct wlan_bssid_ex)); */ + memcpy(bssid.MacAddress, pmppriv->network_macaddr, ETH_ALEN); + bssid.Ssid.SsidLength = strlen("mp_pseudo_adhoc"); + memcpy(bssid.Ssid.Ssid, (u8 *)"mp_pseudo_adhoc", bssid.Ssid.SsidLength); + bssid.InfrastructureMode = Ndis802_11IBSS; + bssid.NetworkTypeInUse = Ndis802_11DS; + bssid.IELength = 0; + + length = get_wlan_bssid_ex_sz(&bssid); + if (length % 4) + bssid.Length = ((length >> 2) + 1) << 2; /* round up to multiple of 4 bytes. */ + else + bssid.Length = length; + + _enter_critical_bh(&pmlmepriv->lock, &irqL); + + if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) + goto end_of_mp_start_test; + + /* init mp_start_test status */ + if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + rtw_disassoc_cmd(padapter, 500, true); + rtw_indicate_disconnect(padapter); + rtw_free_assoc_resources(padapter, 1); + } + pmppriv->prev_fw_state = get_fwstate(pmlmepriv); + if (padapter->registrypriv.mp_mode == 1) + pmlmepriv->fw_state = WIFI_MP_STATE; + set_fwstate(pmlmepriv, _FW_UNDER_LINKING); + + /* 3 2. create a new psta for mp driver */ + /* clear psta in the cur_network, if any */ + psta = rtw_get_stainfo(&padapter->stapriv, tgt_network->network.MacAddress); + if (psta) + rtw_free_stainfo(padapter, psta); + + psta = rtw_alloc_stainfo(&padapter->stapriv, bssid.MacAddress); + if (psta == NULL) { + RT_TRACE(_module_mp_, _drv_err_, ("mp_start_test: Can't alloc sta_info!\n")); + pmlmepriv->fw_state = pmppriv->prev_fw_state; + res = _FAIL; + goto end_of_mp_start_test; + } + + /* 3 3. join psudo AdHoc */ + tgt_network->join_res = 1; + tgt_network->aid = 1; + psta->aid = 1; + memcpy(&tgt_network->network, &bssid, length); + + rtw_indicate_connect(padapter); + _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); + +end_of_mp_start_test: + + _exit_critical_bh(&pmlmepriv->lock, &irqL); + + if (res == _SUCCESS) { + /* set MSR to WIFI_FW_ADHOC_STATE */ + val8 = rtw_read8(padapter, MSR) & 0xFC; /* 0x0102 */ + val8 |= WIFI_FW_ADHOC_STATE; + rtw_write8(padapter, MSR, val8); /* Link in ad hoc network */ + } + return res; +} +/* */ +/* This function change the DUT from the MP test mode into normal mode */ +void mp_stop_test(struct adapter *padapter) +{ + struct mp_priv *pmppriv = &padapter->mppriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct wlan_network *tgt_network = &pmlmepriv->cur_network; + struct sta_info *psta; + + unsigned long irqL; + + if (pmppriv->mode == MP_ON) { + pmppriv->bSetTxPower = 0; + _enter_critical_bh(&pmlmepriv->lock, &irqL); + if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == false) + goto end_of_mp_stop_test; + + /* 3 1. disconnect psudo AdHoc */ + rtw_indicate_disconnect(padapter); + + /* 3 2. clear psta used in mp test mode. */ + psta = rtw_get_stainfo(&padapter->stapriv, tgt_network->network.MacAddress); + if (psta) + rtw_free_stainfo(padapter, psta); + + /* 3 3. return to normal state (default:station mode) */ + pmlmepriv->fw_state = pmppriv->prev_fw_state; /* WIFI_STATION_STATE; */ + + /* flush the cur_network */ + _rtw_memset(tgt_network, 0, sizeof(struct wlan_network)); + + _clr_fwstate_(pmlmepriv, WIFI_MP_STATE); + +end_of_mp_stop_test: + + _exit_critical_bh(&pmlmepriv->lock, &irqL); + } +} + +/*---------------------------hal\rtl8192c\MPT_HelperFunc.c---------------------------*/ +/* + * SetChannel + * Description + * Use H2C command to change channel, + * not only modify rf register, but also other setting need to be done. + */ +void SetChannel(struct adapter *pAdapter) +{ + Hal_SetChannel(pAdapter); +} + +/* + * Notice + * Switch bandwitdth may change center frequency(channel) + */ +void SetBandwidth(struct adapter *pAdapter) +{ + Hal_SetBandwidth(pAdapter); +} + +void SetAntenna(struct adapter *pAdapter) +{ + Hal_SetAntenna(pAdapter); +} + +void SetAntennaPathPower(struct adapter *pAdapter) +{ + Hal_SetAntennaPathPower(pAdapter); +} + +void SetTxPower(struct adapter *pAdapter) +{ + Hal_SetTxPower(pAdapter); + } + +void SetDataRate(struct adapter *pAdapter) +{ + Hal_SetDataRate(pAdapter); +} + +void MP_PHY_SetRFPathSwitch(struct adapter *pAdapter , bool bMain) +{ + PHY_SetRFPathSwitch(pAdapter, bMain); +} + +s32 SetThermalMeter(struct adapter *pAdapter, u8 target_ther) +{ + return Hal_SetThermalMeter(pAdapter, target_ther); +} + +void GetThermalMeter(struct adapter *pAdapter, u8 *value) +{ + Hal_GetThermalMeter(pAdapter, value); +} + +void SetSingleCarrierTx(struct adapter *pAdapter, u8 bStart) +{ + PhySetTxPowerLevel(pAdapter); + Hal_SetSingleCarrierTx(pAdapter, bStart); +} + +void SetSingleToneTx(struct adapter *pAdapter, u8 bStart) +{ + PhySetTxPowerLevel(pAdapter); + Hal_SetSingleToneTx(pAdapter, bStart); +} + +void SetCarrierSuppressionTx(struct adapter *pAdapter, u8 bStart) +{ + PhySetTxPowerLevel(pAdapter); + Hal_SetCarrierSuppressionTx(pAdapter, bStart); +} + +void SetContinuousTx(struct adapter *pAdapter, u8 bStart) +{ + PhySetTxPowerLevel(pAdapter); + Hal_SetContinuousTx(pAdapter, bStart); +} + + +void PhySetTxPowerLevel(struct adapter *pAdapter) +{ + struct mp_priv *pmp_priv = &pAdapter->mppriv; + + if (pmp_priv->bSetTxPower == 0) /* for NO manually set power index */ + PHY_SetTxPowerLevel8188E(pAdapter, pmp_priv->channel); +} + +/* */ +static void dump_mpframe(struct adapter *padapter, struct xmit_frame *pmpframe) +{ + rtw_hal_mgnt_xmit(padapter, pmpframe); +} + +static struct xmit_frame *alloc_mp_xmitframe(struct xmit_priv *pxmitpriv) +{ + struct xmit_frame *pmpframe; + struct xmit_buf *pxmitbuf; + + pmpframe = rtw_alloc_xmitframe(pxmitpriv); + if (pmpframe == NULL) + return NULL; + + pxmitbuf = rtw_alloc_xmitbuf(pxmitpriv); + if (pxmitbuf == NULL) { + rtw_free_xmitframe(pxmitpriv, pmpframe); + return NULL; + } + + pmpframe->frame_tag = MP_FRAMETAG; + + pmpframe->pxmitbuf = pxmitbuf; + + pmpframe->buf_addr = pxmitbuf->pbuf; + + pxmitbuf->priv_data = pmpframe; + + return pmpframe; +} + +static int mp_xmit_packet_thread(void *context) +{ + struct xmit_frame *pxmitframe; + struct mp_tx *pmptx; + struct mp_priv *pmp_priv; + struct xmit_priv *pxmitpriv; + struct adapter *padapter; + + pmp_priv = (struct mp_priv *)context; + pmptx = &pmp_priv->tx; + padapter = pmp_priv->papdater; + pxmitpriv = &(padapter->xmitpriv); + + thread_enter("RTW_MP_THREAD"); + + /* DBG_88E("%s:pkTx Start\n", __func__); */ + while (1) { + pxmitframe = alloc_mp_xmitframe(pxmitpriv); + if (pxmitframe == NULL) { + if (pmptx->stop || + padapter->bSurpriseRemoved || + padapter->bDriverStopped) { + goto exit; + } else { + rtw_msleep_os(1); + continue; + } + } + + memcpy((u8 *)(pxmitframe->buf_addr+TXDESC_OFFSET), pmptx->buf, pmptx->write_size); + memcpy(&(pxmitframe->attrib), &(pmptx->attrib), sizeof(struct pkt_attrib)); + + dump_mpframe(padapter, pxmitframe); + + pmptx->sended++; + pmp_priv->tx_pktcount++; + + if (pmptx->stop || + padapter->bSurpriseRemoved || + padapter->bDriverStopped) + goto exit; + if ((pmptx->count != 0) && + (pmptx->count == pmptx->sended)) + goto exit; + + flush_signals_thread(); + } + +exit: + kfree(pmptx->pallocated_buf); + pmptx->pallocated_buf = NULL; + pmptx->stop = 1; + + thread_exit(); +} + +void fill_txdesc_for_mp(struct adapter *padapter, struct tx_desc *ptxdesc) +{ + struct mp_priv *pmp_priv = &padapter->mppriv; + memcpy(ptxdesc, &(pmp_priv->tx.desc), TXDESC_SIZE); +} + +void SetPacketTx(struct adapter *padapter) +{ + u8 *ptr, *pkt_start, *pkt_end; + u32 pkt_size; + struct tx_desc *desc; + struct rtw_ieee80211_hdr *hdr; + u8 payload; + s32 bmcast; + struct pkt_attrib *pattrib; + struct mp_priv *pmp_priv; + + + pmp_priv = &padapter->mppriv; + if (pmp_priv->tx.stop) + return; + pmp_priv->tx.sended = 0; + pmp_priv->tx.stop = 0; + pmp_priv->tx_pktcount = 0; + + /* 3 1. update_attrib() */ + pattrib = &pmp_priv->tx.attrib; + memcpy(pattrib->src, padapter->eeprompriv.mac_addr, ETH_ALEN); + memcpy(pattrib->ta, pattrib->src, ETH_ALEN); + memcpy(pattrib->ra, pattrib->dst, ETH_ALEN); + bmcast = IS_MCAST(pattrib->ra); + if (bmcast) { + pattrib->mac_id = 1; + pattrib->psta = rtw_get_bcmc_stainfo(padapter); + } else { + pattrib->mac_id = 0; + pattrib->psta = rtw_get_stainfo(&padapter->stapriv, get_bssid(&padapter->mlmepriv)); + } + + pattrib->last_txcmdsz = pattrib->hdrlen + pattrib->pktlen; + + /* 3 2. allocate xmit buffer */ + pkt_size = pattrib->last_txcmdsz; + + kfree(pmp_priv->tx.pallocated_buf); + pmp_priv->tx.write_size = pkt_size; + pmp_priv->tx.buf_size = pkt_size + XMITBUF_ALIGN_SZ; + pmp_priv->tx.pallocated_buf = rtw_zmalloc(pmp_priv->tx.buf_size); + if (pmp_priv->tx.pallocated_buf == NULL) { + DBG_88E("%s: malloc(%d) fail!!\n", __func__, pmp_priv->tx.buf_size); + return; + } + pmp_priv->tx.buf = (u8 *)N_BYTE_ALIGMENT((size_t)(pmp_priv->tx.pallocated_buf), XMITBUF_ALIGN_SZ); + ptr = pmp_priv->tx.buf; + + desc = &(pmp_priv->tx.desc); + _rtw_memset(desc, 0, TXDESC_SIZE); + pkt_start = ptr; + pkt_end = pkt_start + pkt_size; + + /* 3 3. init TX descriptor */ + /* offset 0 */ + desc->txdw0 |= cpu_to_le32(OWN | FSG | LSG); + desc->txdw0 |= cpu_to_le32(pkt_size & 0x0000FFFF); /* packet size */ + desc->txdw0 |= cpu_to_le32(((TXDESC_SIZE + OFFSET_SZ) << OFFSET_SHT) & 0x00FF0000); /* 32 bytes for TX Desc */ + if (bmcast) + desc->txdw0 |= cpu_to_le32(BMC); /* broadcast packet */ + + desc->txdw1 |= cpu_to_le32((0x01 << 26) & 0xff000000); + /* offset 4 */ + desc->txdw1 |= cpu_to_le32((pattrib->mac_id) & 0x3F); /* CAM_ID(MAC_ID) */ + desc->txdw1 |= cpu_to_le32((pattrib->qsel << QSEL_SHT) & 0x00001F00); /* Queue Select, TID */ + + desc->txdw1 |= cpu_to_le32((pattrib->raid << RATE_ID_SHT) & 0x000F0000); /* Rate Adaptive ID */ + /* offset 8 */ + /* offset 12 */ + + desc->txdw3 |= cpu_to_le32((pattrib->seqnum<<16)&0x0fff0000); + + /* offset 16 */ + desc->txdw4 |= cpu_to_le32(HW_SSN); + desc->txdw4 |= cpu_to_le32(USERATE); + desc->txdw4 |= cpu_to_le32(DISDATAFB); + + if (pmp_priv->preamble) { + if (pmp_priv->rateidx <= MPT_RATE_54M) + desc->txdw4 |= cpu_to_le32(DATA_SHORT); /* CCK Short Preamble */ + } + if (pmp_priv->bandwidth == HT_CHANNEL_WIDTH_40) + desc->txdw4 |= cpu_to_le32(DATA_BW); + + /* offset 20 */ + desc->txdw5 |= cpu_to_le32(pmp_priv->rateidx & 0x0000001F); + + if (pmp_priv->preamble) { + if (pmp_priv->rateidx > MPT_RATE_54M) + desc->txdw5 |= cpu_to_le32(SGI); /* MCS Short Guard Interval */ + } + desc->txdw5 |= cpu_to_le32(RTY_LMT_EN); /* retry limit enable */ + desc->txdw5 |= cpu_to_le32(0x00180000); /* DATA/RTS Rate Fallback Limit */ + + /* 3 4. make wlan header, make_wlanhdr() */ + hdr = (struct rtw_ieee80211_hdr *)pkt_start; + SetFrameSubType(&hdr->frame_ctl, pattrib->subtype); + memcpy(hdr->addr1, pattrib->dst, ETH_ALEN); /* DA */ + memcpy(hdr->addr2, pattrib->src, ETH_ALEN); /* SA */ + memcpy(hdr->addr3, get_bssid(&padapter->mlmepriv), ETH_ALEN); /* RA, BSSID */ + + /* 3 5. make payload */ + ptr = pkt_start + pattrib->hdrlen; + + switch (pmp_priv->tx.payload) { + case 0: + payload = 0x00; + break; + case 1: + payload = 0x5a; + break; + case 2: + payload = 0xa5; + break; + case 3: + payload = 0xff; + break; + default: + payload = 0x00; + break; + } + + _rtw_memset(ptr, payload, pkt_end - ptr); + + /* 3 6. start thread */ + pmp_priv->tx.PktTxThread = kthread_run(mp_xmit_packet_thread, pmp_priv, "RTW_MP_THREAD"); + if (IS_ERR(pmp_priv->tx.PktTxThread)) + DBG_88E("Create PktTx Thread Fail !!!!!\n"); +} + +void SetPacketRx(struct adapter *pAdapter, u8 bStartRx) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); + + if (bStartRx) { + /* Accept CRC error and destination address */ + pHalData->ReceiveConfig = AAP | APM | AM | AB | APP_ICV | ADF | AMF | HTC_LOC_CTRL | APP_MIC | APP_PHYSTS; + + pHalData->ReceiveConfig |= ACRC32; + + rtw_write32(pAdapter, REG_RCR, pHalData->ReceiveConfig); + + /* Accept all data frames */ + rtw_write16(pAdapter, REG_RXFLTMAP2, 0xFFFF); + } else { + rtw_write32(pAdapter, REG_RCR, 0); + } +} + +void ResetPhyRxPktCount(struct adapter *pAdapter) +{ + u32 i, phyrx_set = 0; + + for (i = 0; i <= 0xF; i++) { + phyrx_set = 0; + phyrx_set |= _RXERR_RPT_SEL(i); /* select */ + phyrx_set |= RXERR_RPT_RST; /* set counter to zero */ + rtw_write32(pAdapter, REG_RXERR_RPT, phyrx_set); + } +} + +static u32 GetPhyRxPktCounts(struct adapter *pAdapter, u32 selbit) +{ + /* selection */ + u32 phyrx_set = 0, count = 0; + + phyrx_set = _RXERR_RPT_SEL(selbit & 0xF); + rtw_write32(pAdapter, REG_RXERR_RPT, phyrx_set); + + /* Read packet count */ + count = rtw_read32(pAdapter, REG_RXERR_RPT) & RXERR_COUNTER_MASK; + + return count; +} + +u32 GetPhyRxPktReceived(struct adapter *pAdapter) +{ + u32 OFDM_cnt = 0, CCK_cnt = 0, HT_cnt = 0; + + OFDM_cnt = GetPhyRxPktCounts(pAdapter, RXERR_TYPE_OFDM_MPDU_OK); + CCK_cnt = GetPhyRxPktCounts(pAdapter, RXERR_TYPE_CCK_MPDU_OK); + HT_cnt = GetPhyRxPktCounts(pAdapter, RXERR_TYPE_HT_MPDU_OK); + + return OFDM_cnt + CCK_cnt + HT_cnt; +} + +u32 GetPhyRxPktCRC32Error(struct adapter *pAdapter) +{ + u32 OFDM_cnt = 0, CCK_cnt = 0, HT_cnt = 0; + + OFDM_cnt = GetPhyRxPktCounts(pAdapter, RXERR_TYPE_OFDM_MPDU_FAIL); + CCK_cnt = GetPhyRxPktCounts(pAdapter, RXERR_TYPE_CCK_MPDU_FAIL); + HT_cnt = GetPhyRxPktCounts(pAdapter, RXERR_TYPE_HT_MPDU_FAIL); + + return OFDM_cnt + CCK_cnt + HT_cnt; +} + +/* reg 0x808[9:0]: FFT data x */ +/* reg 0x808[22]: 0 --> 1 to get 1 FFT data y */ +/* reg 0x8B4[15:0]: FFT data y report */ +static u32 rtw_GetPSDData(struct adapter *pAdapter, u32 point) +{ + int psd_val; + + + psd_val = rtw_read32(pAdapter, 0x808); + psd_val &= 0xFFBFFC00; + psd_val |= point; + + rtw_write32(pAdapter, 0x808, psd_val); + rtw_mdelay_os(1); + psd_val |= 0x00400000; + + rtw_write32(pAdapter, 0x808, psd_val); + rtw_mdelay_os(1); + psd_val = rtw_read32(pAdapter, 0x8B4); + + psd_val &= 0x0000FFFF; + + return psd_val; +} + +/* + *pts start_point_min stop_point_max + * 128 64 64 + 128 = 192 + * 256 128 128 + 256 = 384 + * 512 256 256 + 512 = 768 + * 1024 512 512 + 1024 = 1536 + * + */ +u32 mp_query_psd(struct adapter *pAdapter, u8 *data) +{ + u32 i, psd_pts = 0, psd_start = 0, psd_stop = 0; + u32 psd_data = 0; + + + if (!netif_running(pAdapter->pnetdev)) { + RT_TRACE(_module_mp_, _drv_warning_, ("mp_query_psd: Fail! interface not opened!\n")); + return 0; + } + + if (check_fwstate(&pAdapter->mlmepriv, WIFI_MP_STATE) == false) { + RT_TRACE(_module_mp_, _drv_warning_, ("mp_query_psd: Fail! not in MP mode!\n")); + return 0; + } + + if (strlen(data) == 0) { /* default value */ + psd_pts = 128; + psd_start = 64; + psd_stop = 128; + } else { + sscanf(data, "pts =%d, start =%d, stop =%d", &psd_pts, &psd_start, &psd_stop); + } + + _rtw_memset(data, '\0', sizeof(data)); + + i = psd_start; + while (i < psd_stop) { + if (i >= psd_pts) { + psd_data = rtw_GetPSDData(pAdapter, i-psd_pts); + } else { + psd_data = rtw_GetPSDData(pAdapter, i); + } + sprintf(data, "%s%x ", data, psd_data); + i++; + } + + rtw_msleep_os(100); + return strlen(data)+1; +} + +void _rtw_mp_xmit_priv(struct xmit_priv *pxmitpriv) +{ + int i, res; + struct adapter *padapter = pxmitpriv->adapter; + struct xmit_buf *pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmitbuf; + + u32 max_xmit_extbuf_size = MAX_XMIT_EXTBUF_SZ; + u32 num_xmit_extbuf = NR_XMIT_EXTBUFF; + if (padapter->registrypriv.mp_mode == 0) { + max_xmit_extbuf_size = MAX_XMIT_EXTBUF_SZ; + num_xmit_extbuf = NR_XMIT_EXTBUFF; + } else { + max_xmit_extbuf_size = 20000; + num_xmit_extbuf = 1; + } + + pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmit_extbuf; + for (i = 0; i < num_xmit_extbuf; i++) { + rtw_os_xmit_resource_free(padapter, pxmitbuf, (max_xmit_extbuf_size + XMITBUF_ALIGN_SZ)); + + pxmitbuf++; + } + + if (pxmitpriv->pallocated_xmit_extbuf) + rtw_vmfree(pxmitpriv->pallocated_xmit_extbuf, num_xmit_extbuf * sizeof(struct xmit_buf) + 4); + + if (padapter->registrypriv.mp_mode == 0) { + max_xmit_extbuf_size = 20000; + num_xmit_extbuf = 1; + } else { + max_xmit_extbuf_size = MAX_XMIT_EXTBUF_SZ; + num_xmit_extbuf = NR_XMIT_EXTBUFF; + } + + /* Init xmit extension buff */ + _rtw_init_queue(&pxmitpriv->free_xmit_extbuf_queue); + + pxmitpriv->pallocated_xmit_extbuf = rtw_zvmalloc(num_xmit_extbuf * sizeof(struct xmit_buf) + 4); + + if (pxmitpriv->pallocated_xmit_extbuf == NULL) { + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("alloc xmit_extbuf fail!\n")); + res = _FAIL; + goto exit; + } + + pxmitpriv->pxmit_extbuf = (u8 *)N_BYTE_ALIGMENT((size_t)(pxmitpriv->pallocated_xmit_extbuf), 4); + + pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmit_extbuf; + + for (i = 0; i < num_xmit_extbuf; i++) { + _rtw_init_listhead(&pxmitbuf->list); + + pxmitbuf->priv_data = NULL; + pxmitbuf->padapter = padapter; + pxmitbuf->ext_tag = true; + + res = rtw_os_xmit_resource_alloc(padapter, pxmitbuf, max_xmit_extbuf_size + XMITBUF_ALIGN_SZ); + if (res == _FAIL) { + res = _FAIL; + goto exit; + } + + rtw_list_insert_tail(&pxmitbuf->list, &(pxmitpriv->free_xmit_extbuf_queue.queue)); + pxmitbuf++; + } + + pxmitpriv->free_xmit_extbuf_cnt = num_xmit_extbuf; + +exit: + ; +} diff --git a/drivers/staging/rtl8188eu/core/rtw_mp_ioctl.c b/drivers/staging/rtl8188eu/core/rtw_mp_ioctl.c new file mode 100644 index 0000000000000..12fecdec40168 --- /dev/null +++ b/drivers/staging/rtl8188eu/core/rtw_mp_ioctl.c @@ -0,0 +1,1508 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTW_MP_IOCTL_C_ + +#include +#include +#include + +/* include */ +#include + + +/* oid_rtl_seg_81_85 section start **************** */ +int oid_rt_wireless_mode_hdl(struct oid_par_priv *poid_par_priv) +{ + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + +_func_enter_; + + if (poid_par_priv->information_buf_len < sizeof(u8)) + return NDIS_STATUS_INVALID_LENGTH; + + if (poid_par_priv->type_of_oid == SET_OID) { + Adapter->registrypriv.wireless_mode = *(u8 *)poid_par_priv->information_buf; + } else if (poid_par_priv->type_of_oid == QUERY_OID) { + *(u8 *)poid_par_priv->information_buf = Adapter->registrypriv.wireless_mode; + *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; + RT_TRACE(_module_mp_, _drv_info_, ("-query Wireless Mode=%d\n", Adapter->registrypriv.wireless_mode)); + } else { + status = NDIS_STATUS_NOT_ACCEPTED; + } + +_func_exit_; + + return status; +} +/* oid_rtl_seg_81_87_80 section start **************** */ +int oid_rt_pro_write_bb_reg_hdl(struct oid_par_priv *poid_par_priv) +{ + struct bb_reg_param *pbbreg; + u16 offset; + u32 value; + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + +_func_enter_; + + RT_TRACE(_module_mp_, _drv_notice_, ("+oid_rt_pro_write_bb_reg_hdl\n")); + + if (poid_par_priv->type_of_oid != SET_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + if (poid_par_priv->information_buf_len < sizeof(struct bb_reg_param)) + return NDIS_STATUS_INVALID_LENGTH; + + pbbreg = (struct bb_reg_param *)(poid_par_priv->information_buf); + + offset = (u16)(pbbreg->offset) & 0xFFF; /* 0ffset :0x800~0xfff */ + if (offset < BB_REG_BASE_ADDR) + offset |= BB_REG_BASE_ADDR; + + value = pbbreg->value; + + RT_TRACE(_module_mp_, _drv_notice_, + ("oid_rt_pro_write_bb_reg_hdl: offset=0x%03X value=0x%08X\n", + offset, value)); + + _irqlevel_changed_(&oldirql, LOWER); + write_bbreg(Adapter, offset, 0xFFFFFFFF, value); + _irqlevel_changed_(&oldirql, RAISE); + +_func_exit_; + + return status; +} +/* */ +int oid_rt_pro_read_bb_reg_hdl(struct oid_par_priv *poid_par_priv) +{ + struct bb_reg_param *pbbreg; + u16 offset; + u32 value; + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + +_func_enter_; + + RT_TRACE(_module_mp_, _drv_notice_, ("+oid_rt_pro_read_bb_reg_hdl\n")); + + if (poid_par_priv->type_of_oid != QUERY_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + if (poid_par_priv->information_buf_len < sizeof(struct bb_reg_param)) + return NDIS_STATUS_INVALID_LENGTH; + + pbbreg = (struct bb_reg_param *)(poid_par_priv->information_buf); + + offset = (u16)(pbbreg->offset) & 0xFFF; /* 0ffset :0x800~0xfff */ + if (offset < BB_REG_BASE_ADDR) + offset |= BB_REG_BASE_ADDR; + + _irqlevel_changed_(&oldirql, LOWER); + value = read_bbreg(Adapter, offset, 0xFFFFFFFF); + _irqlevel_changed_(&oldirql, RAISE); + + pbbreg->value = value; + *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; + + RT_TRACE(_module_mp_, _drv_notice_, + ("-oid_rt_pro_read_bb_reg_hdl: offset=0x%03X value:0x%08X\n", + offset, value)); +_func_exit_; + + return status; +} +/* */ +int oid_rt_pro_write_rf_reg_hdl(struct oid_par_priv *poid_par_priv) +{ + struct rf_reg_param *pbbreg; + u8 path; + u8 offset; + u32 value; + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + +_func_enter_; + + RT_TRACE(_module_mp_, _drv_notice_, ("+oid_rt_pro_write_rf_reg_hdl\n")); + + if (poid_par_priv->type_of_oid != SET_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + if (poid_par_priv->information_buf_len < sizeof(struct rf_reg_param)) + return NDIS_STATUS_INVALID_LENGTH; + + pbbreg = (struct rf_reg_param *)(poid_par_priv->information_buf); + + if (pbbreg->path >= MAX_RF_PATH_NUMS) + return NDIS_STATUS_NOT_ACCEPTED; + if (pbbreg->offset > 0xFF) + return NDIS_STATUS_NOT_ACCEPTED; + if (pbbreg->value > 0xFFFFF) + return NDIS_STATUS_NOT_ACCEPTED; + + path = (u8)pbbreg->path; + offset = (u8)pbbreg->offset; + value = pbbreg->value; + + RT_TRACE(_module_mp_, _drv_notice_, + ("oid_rt_pro_write_rf_reg_hdl: path=%d offset=0x%02X value=0x%05X\n", + path, offset, value)); + + _irqlevel_changed_(&oldirql, LOWER); + write_rfreg(Adapter, path, offset, value); + _irqlevel_changed_(&oldirql, RAISE); + +_func_exit_; + + return status; +} +/* */ +int oid_rt_pro_read_rf_reg_hdl(struct oid_par_priv *poid_par_priv) +{ + struct rf_reg_param *pbbreg; + u8 path; + u8 offset; + u32 value; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + int status = NDIS_STATUS_SUCCESS; + +_func_enter_; + + RT_TRACE(_module_mp_, _drv_notice_, ("+oid_rt_pro_read_rf_reg_hdl\n")); + + if (poid_par_priv->type_of_oid != QUERY_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + if (poid_par_priv->information_buf_len < sizeof(struct rf_reg_param)) + return NDIS_STATUS_INVALID_LENGTH; + + pbbreg = (struct rf_reg_param *)(poid_par_priv->information_buf); + + if (pbbreg->path >= MAX_RF_PATH_NUMS) + return NDIS_STATUS_NOT_ACCEPTED; + if (pbbreg->offset > 0xFF) + return NDIS_STATUS_NOT_ACCEPTED; + + path = (u8)pbbreg->path; + offset = (u8)pbbreg->offset; + + _irqlevel_changed_(&oldirql, LOWER); + value = read_rfreg(Adapter, path, offset); + _irqlevel_changed_(&oldirql, RAISE); + + pbbreg->value = value; + + *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; + + RT_TRACE(_module_mp_, _drv_notice_, + ("-oid_rt_pro_read_rf_reg_hdl: path=%d offset=0x%02X value=0x%05X\n", + path, offset, value)); + +_func_exit_; + + return status; +} +/* oid_rtl_seg_81_87_00 section end**************** */ +/* */ + +/* oid_rtl_seg_81_80_00 section start **************** */ +/* */ +int oid_rt_pro_set_data_rate_hdl(struct oid_par_priv *poid_par_priv) +{ + u32 ratevalue;/* 4 */ + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + +_func_enter_; + + RT_TRACE(_module_mp_, _drv_notice_, + ("+oid_rt_pro_set_data_rate_hdl\n")); + + if (poid_par_priv->type_of_oid != SET_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + if (poid_par_priv->information_buf_len != sizeof(u32)) + return NDIS_STATUS_INVALID_LENGTH; + + ratevalue = *((u32 *)poid_par_priv->information_buf);/* 4 */ + RT_TRACE(_module_mp_, _drv_notice_, + ("oid_rt_pro_set_data_rate_hdl: data rate idx=%d\n", ratevalue)); + if (ratevalue >= MPT_RATE_LAST) + return NDIS_STATUS_INVALID_DATA; + + Adapter->mppriv.rateidx = ratevalue; + + _irqlevel_changed_(&oldirql, LOWER); + SetDataRate(Adapter); + _irqlevel_changed_(&oldirql, RAISE); + +_func_exit_; + + return status; +} +/* */ +int oid_rt_pro_start_test_hdl(struct oid_par_priv *poid_par_priv) +{ + u32 mode; + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + +_func_enter_; + + RT_TRACE(_module_mp_, _drv_notice_, ("+oid_rt_pro_start_test_hdl\n")); + + if (Adapter->registrypriv.mp_mode == 0) + return NDIS_STATUS_NOT_ACCEPTED; + + if (poid_par_priv->type_of_oid != SET_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + _irqlevel_changed_(&oldirql, LOWER); + + /* IQCalibrateBcut(Adapter); */ + + mode = *((u32 *)poid_par_priv->information_buf); + Adapter->mppriv.mode = mode;/* 1 for loopback */ + + if (mp_start_test(Adapter) == _FAIL) { + status = NDIS_STATUS_NOT_ACCEPTED; + goto exit; + } + +exit: + _irqlevel_changed_(&oldirql, RAISE); + + RT_TRACE(_module_mp_, _drv_notice_, ("-oid_rt_pro_start_test_hdl: mp_mode=%d\n", Adapter->mppriv.mode)); + +_func_exit_; + + return status; +} +/* */ +int oid_rt_pro_stop_test_hdl(struct oid_par_priv *poid_par_priv) +{ + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + +_func_enter_; + + RT_TRACE(_module_mp_, _drv_notice_, ("+Set OID_RT_PRO_STOP_TEST\n")); + + if (poid_par_priv->type_of_oid != SET_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + _irqlevel_changed_(&oldirql, LOWER); + mp_stop_test(Adapter); + _irqlevel_changed_(&oldirql, RAISE); + + RT_TRACE(_module_mp_, _drv_notice_, ("-Set OID_RT_PRO_STOP_TEST\n")); + +_func_exit_; + + return status; +} +/* */ +int oid_rt_pro_set_channel_direct_call_hdl(struct oid_par_priv *poid_par_priv) +{ + u32 Channel; + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + +_func_enter_; + + RT_TRACE(_module_mp_, _drv_notice_, ("+oid_rt_pro_set_channel_direct_call_hdl\n")); + + if (poid_par_priv->information_buf_len != sizeof(u32)) + return NDIS_STATUS_INVALID_LENGTH; + + if (poid_par_priv->type_of_oid == QUERY_OID) { + *((u32 *)poid_par_priv->information_buf) = Adapter->mppriv.channel; + return NDIS_STATUS_SUCCESS; + } + + if (poid_par_priv->type_of_oid != SET_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + Channel = *((u32 *)poid_par_priv->information_buf); + RT_TRACE(_module_mp_, _drv_notice_, ("oid_rt_pro_set_channel_direct_call_hdl: Channel=%d\n", Channel)); + if (Channel > 14) + return NDIS_STATUS_NOT_ACCEPTED; + Adapter->mppriv.channel = Channel; + + _irqlevel_changed_(&oldirql, LOWER); + SetChannel(Adapter); + _irqlevel_changed_(&oldirql, RAISE); + +_func_exit_; + + return status; +} +/* */ +int oid_rt_set_bandwidth_hdl(struct oid_par_priv *poid_par_priv) +{ + u16 bandwidth; + u16 channel_offset; + int status = NDIS_STATUS_SUCCESS; + struct adapter *padapter = (struct adapter *)(poid_par_priv->adapter_context); + +_func_enter_; + + RT_TRACE(_module_mp_, _drv_info_, + ("+oid_rt_set_bandwidth_hdl\n")); + + if (poid_par_priv->type_of_oid != SET_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + if (poid_par_priv->information_buf_len < sizeof(u32)) + return NDIS_STATUS_INVALID_LENGTH; + + bandwidth = *((u32 *)poid_par_priv->information_buf);/* 4 */ + channel_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; + + if (bandwidth != HT_CHANNEL_WIDTH_40) + bandwidth = HT_CHANNEL_WIDTH_20; + padapter->mppriv.bandwidth = (u8)bandwidth; + padapter->mppriv.prime_channel_offset = (u8)channel_offset; + + _irqlevel_changed_(&oldirql, LOWER); + SetBandwidth(padapter); + _irqlevel_changed_(&oldirql, RAISE); + + RT_TRACE(_module_mp_, _drv_notice_, + ("-oid_rt_set_bandwidth_hdl: bandwidth=%d channel_offset=%d\n", + bandwidth, channel_offset)); + +_func_exit_; + + return status; +} +/* */ +int oid_rt_pro_set_antenna_bb_hdl(struct oid_par_priv *poid_par_priv) +{ + u32 antenna; + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + +_func_enter_; + + RT_TRACE(_module_mp_, _drv_notice_, ("+oid_rt_pro_set_antenna_bb_hdl\n")); + + if (poid_par_priv->information_buf_len != sizeof(u32)) + return NDIS_STATUS_INVALID_LENGTH; + + if (poid_par_priv->type_of_oid == SET_OID) { + antenna = *(u32 *)poid_par_priv->information_buf; + + Adapter->mppriv.antenna_tx = (u16)((antenna & 0xFFFF0000) >> 16); + Adapter->mppriv.antenna_rx = (u16)(antenna & 0x0000FFFF); + RT_TRACE(_module_mp_, _drv_notice_, + ("oid_rt_pro_set_antenna_bb_hdl: tx_ant=0x%04x rx_ant=0x%04x\n", + Adapter->mppriv.antenna_tx, Adapter->mppriv.antenna_rx)); + + _irqlevel_changed_(&oldirql, LOWER); + SetAntenna(Adapter); + _irqlevel_changed_(&oldirql, RAISE); + } else { + antenna = (Adapter->mppriv.antenna_tx << 16)|Adapter->mppriv.antenna_rx; + *(u32 *)poid_par_priv->information_buf = antenna; + } + +_func_exit_; + + return status; +} + +int oid_rt_pro_set_tx_power_control_hdl(struct oid_par_priv *poid_par_priv) +{ + u32 tx_pwr_idx; + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + +_func_enter_; + + RT_TRACE(_module_mp_, _drv_info_, ("+oid_rt_pro_set_tx_power_control_hdl\n")); + + if (poid_par_priv->type_of_oid != SET_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + if (poid_par_priv->information_buf_len != sizeof(u32)) + return NDIS_STATUS_INVALID_LENGTH; + + tx_pwr_idx = *((u32 *)poid_par_priv->information_buf); + if (tx_pwr_idx > MAX_TX_PWR_INDEX_N_MODE) + return NDIS_STATUS_NOT_ACCEPTED; + + Adapter->mppriv.txpoweridx = (u8)tx_pwr_idx; + + RT_TRACE(_module_mp_, _drv_notice_, + ("oid_rt_pro_set_tx_power_control_hdl: idx=0x%2x\n", + Adapter->mppriv.txpoweridx)); + + _irqlevel_changed_(&oldirql, LOWER); + SetTxPower(Adapter); + _irqlevel_changed_(&oldirql, RAISE); + +_func_exit_; + + return status; +} + +/* */ +/* oid_rtl_seg_81_80_20 section start **************** */ +/* */ +int oid_rt_pro_query_tx_packet_sent_hdl(struct oid_par_priv *poid_par_priv) +{ + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + +_func_enter_; + + if (poid_par_priv->type_of_oid != QUERY_OID) { + status = NDIS_STATUS_NOT_ACCEPTED; + return status; + } + + if (poid_par_priv->information_buf_len == sizeof(u32)) { + *(u32 *)poid_par_priv->information_buf = Adapter->mppriv.tx_pktcount; + *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; + } else { + status = NDIS_STATUS_INVALID_LENGTH; + } + +_func_exit_; + + return status; +} +/* */ +int oid_rt_pro_query_rx_packet_received_hdl(struct oid_par_priv *poid_par_priv) +{ + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + +_func_enter_; + + if (poid_par_priv->type_of_oid != QUERY_OID) { + status = NDIS_STATUS_NOT_ACCEPTED; + return status; + } + RT_TRACE(_module_mp_, _drv_alert_, ("===> oid_rt_pro_query_rx_packet_received_hdl.\n")); + if (poid_par_priv->information_buf_len == sizeof(u32)) { + *(u32 *)poid_par_priv->information_buf = Adapter->mppriv.rx_pktcount; + *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; + RT_TRACE(_module_mp_, _drv_alert_, ("recv_ok:%d\n", Adapter->mppriv.rx_pktcount)); + } else { + status = NDIS_STATUS_INVALID_LENGTH; + } + +_func_exit_; + + return status; +} +/* */ +int oid_rt_pro_query_rx_packet_crc32_error_hdl(struct oid_par_priv *poid_par_priv) +{ + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + +_func_enter_; + + if (poid_par_priv->type_of_oid != QUERY_OID) { + status = NDIS_STATUS_NOT_ACCEPTED; + return status; + } + RT_TRACE(_module_mp_, _drv_alert_, ("===> oid_rt_pro_query_rx_packet_crc32_error_hdl.\n")); + if (poid_par_priv->information_buf_len == sizeof(u32)) { + *(u32 *)poid_par_priv->information_buf = Adapter->mppriv.rx_crcerrpktcount; + *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; + RT_TRACE(_module_mp_, _drv_alert_, ("recv_err:%d\n", Adapter->mppriv.rx_crcerrpktcount)); + } else { + status = NDIS_STATUS_INVALID_LENGTH; + } + +_func_exit_; + + return status; +} +/* */ + +int oid_rt_pro_reset_tx_packet_sent_hdl(struct oid_par_priv *poid_par_priv) +{ + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + +_func_enter_; + + if (poid_par_priv->type_of_oid != SET_OID) { + status = NDIS_STATUS_NOT_ACCEPTED; + return status; + } + + RT_TRACE(_module_mp_, _drv_alert_, ("===> oid_rt_pro_reset_tx_packet_sent_hdl.\n")); + Adapter->mppriv.tx_pktcount = 0; + +_func_exit_; + + return status; +} +/* */ +int oid_rt_pro_reset_rx_packet_received_hdl(struct oid_par_priv *poid_par_priv) +{ + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + +_func_enter_; + + if (poid_par_priv->type_of_oid != SET_OID) { + status = NDIS_STATUS_NOT_ACCEPTED; + return status; + } + + if (poid_par_priv->information_buf_len == sizeof(u32)) { + Adapter->mppriv.rx_pktcount = 0; + Adapter->mppriv.rx_crcerrpktcount = 0; + } else { + status = NDIS_STATUS_INVALID_LENGTH; + } + +_func_exit_; + + return status; +} +/* */ +int oid_rt_reset_phy_rx_packet_count_hdl(struct oid_par_priv *poid_par_priv) +{ + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + +_func_enter_; + + if (poid_par_priv->type_of_oid != SET_OID) { + status = NDIS_STATUS_NOT_ACCEPTED; + return status; + } + + _irqlevel_changed_(&oldirql, LOWER); + ResetPhyRxPktCount(Adapter); + _irqlevel_changed_(&oldirql, RAISE); + +_func_exit_; + + return status; +} +/* */ +int oid_rt_get_phy_rx_packet_received_hdl(struct oid_par_priv *poid_par_priv) +{ + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + +_func_enter_; + + RT_TRACE(_module_mp_, _drv_info_, ("+oid_rt_get_phy_rx_packet_received_hdl\n")); + + if (poid_par_priv->type_of_oid != QUERY_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + if (poid_par_priv->information_buf_len != sizeof(u32)) + return NDIS_STATUS_INVALID_LENGTH; + + _irqlevel_changed_(&oldirql, LOWER); + *(u32 *)poid_par_priv->information_buf = GetPhyRxPktReceived(Adapter); + _irqlevel_changed_(&oldirql, RAISE); + + *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; + + RT_TRACE(_module_mp_, _drv_notice_, ("-oid_rt_get_phy_rx_packet_received_hdl: recv_ok=%d\n", *(u32 *)poid_par_priv->information_buf)); + +_func_exit_; + + return status; +} +/* */ +int oid_rt_get_phy_rx_packet_crc32_error_hdl(struct oid_par_priv *poid_par_priv) +{ + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + +_func_enter_; + + RT_TRACE(_module_mp_, _drv_info_, ("+oid_rt_get_phy_rx_packet_crc32_error_hdl\n")); + + if (poid_par_priv->type_of_oid != QUERY_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + + if (poid_par_priv->information_buf_len != sizeof(u32)) + return NDIS_STATUS_INVALID_LENGTH; + + _irqlevel_changed_(&oldirql, LOWER); + *(u32 *)poid_par_priv->information_buf = GetPhyRxPktCRC32Error(Adapter); + _irqlevel_changed_(&oldirql, RAISE); + + *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; + + RT_TRACE(_module_mp_, _drv_info_, + ("-oid_rt_get_phy_rx_packet_crc32_error_hdl: recv_err =%d\n", + *(u32 *)poid_par_priv->information_buf)); + +_func_exit_; + + return status; +} +/* oid_rtl_seg_81_80_20 section end **************** */ +int oid_rt_pro_set_continuous_tx_hdl(struct oid_par_priv *poid_par_priv) +{ + u32 bStartTest; + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + +_func_enter_; + + RT_TRACE(_module_mp_, _drv_notice_, ("+oid_rt_pro_set_continuous_tx_hdl\n")); + + if (poid_par_priv->type_of_oid != SET_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + bStartTest = *((u32 *)poid_par_priv->information_buf); + + _irqlevel_changed_(&oldirql, LOWER); + SetContinuousTx(Adapter, (u8)bStartTest); + if (bStartTest) { + struct mp_priv *pmp_priv = &Adapter->mppriv; + if (pmp_priv->tx.stop == 0) { + pmp_priv->tx.stop = 1; + DBG_88E("%s: pkt tx is running...\n", __func__); + rtw_msleep_os(5); + } + pmp_priv->tx.stop = 0; + pmp_priv->tx.count = 1; + SetPacketTx(Adapter); + } + _irqlevel_changed_(&oldirql, RAISE); + +_func_exit_; + + return status; +} + +int oid_rt_pro_set_single_carrier_tx_hdl(struct oid_par_priv *poid_par_priv) +{ + u32 bStartTest; + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + +_func_enter_; + + RT_TRACE(_module_mp_, _drv_alert_, ("+oid_rt_pro_set_single_carrier_tx_hdl\n")); + + if (poid_par_priv->type_of_oid != SET_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + bStartTest = *((u32 *)poid_par_priv->information_buf); + + _irqlevel_changed_(&oldirql, LOWER); + SetSingleCarrierTx(Adapter, (u8)bStartTest); + if (bStartTest) { + struct mp_priv *pmp_priv = &Adapter->mppriv; + if (pmp_priv->tx.stop == 0) { + pmp_priv->tx.stop = 1; + DBG_88E("%s: pkt tx is running...\n", __func__); + rtw_msleep_os(5); + } + pmp_priv->tx.stop = 0; + pmp_priv->tx.count = 1; + SetPacketTx(Adapter); + } + _irqlevel_changed_(&oldirql, RAISE); + +_func_exit_; + + return status; +} + +int oid_rt_pro_set_carrier_suppression_tx_hdl(struct oid_par_priv *poid_par_priv) +{ + u32 bStartTest; + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + +_func_enter_; + + RT_TRACE(_module_mp_, _drv_notice_, ("+oid_rt_pro_set_carrier_suppression_tx_hdl\n")); + + if (poid_par_priv->type_of_oid != SET_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + bStartTest = *((u32 *)poid_par_priv->information_buf); + + _irqlevel_changed_(&oldirql, LOWER); + SetCarrierSuppressionTx(Adapter, (u8)bStartTest); + if (bStartTest) { + struct mp_priv *pmp_priv = &Adapter->mppriv; + if (pmp_priv->tx.stop == 0) { + pmp_priv->tx.stop = 1; + DBG_88E("%s: pkt tx is running...\n", __func__); + rtw_msleep_os(5); + } + pmp_priv->tx.stop = 0; + pmp_priv->tx.count = 1; + SetPacketTx(Adapter); + } + _irqlevel_changed_(&oldirql, RAISE); + +_func_exit_; + + return status; +} + +int oid_rt_pro_set_single_tone_tx_hdl(struct oid_par_priv *poid_par_priv) +{ + u32 bStartTest; + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + +_func_enter_; + + RT_TRACE(_module_mp_, _drv_alert_, ("+oid_rt_pro_set_single_tone_tx_hdl\n")); + + if (poid_par_priv->type_of_oid != SET_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + bStartTest = *((u32 *)poid_par_priv->information_buf); + + _irqlevel_changed_(&oldirql, LOWER); + SetSingleToneTx(Adapter, (u8)bStartTest); + _irqlevel_changed_(&oldirql, RAISE); + +_func_exit_; + + return status; +} + +int oid_rt_pro_set_modulation_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} + +int oid_rt_pro_trigger_gpio_hdl(struct oid_par_priv *poid_par_priv) +{ + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + int status = NDIS_STATUS_SUCCESS; +_func_enter_; + + if (poid_par_priv->type_of_oid != SET_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + _irqlevel_changed_(&oldirql, LOWER); + rtw_hal_set_hwreg(Adapter, HW_VAR_TRIGGER_GPIO_0, NULL); + _irqlevel_changed_(&oldirql, RAISE); + +_func_exit_; + + return status; +} +/* oid_rtl_seg_81_80_00 section end **************** */ +/* */ +int oid_rt_pro8711_join_bss_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} +/* */ +int oid_rt_pro_read_register_hdl(struct oid_par_priv *poid_par_priv) +{ + struct mp_rw_reg *RegRWStruct; + u32 offset, width; + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + +_func_enter_; + + RT_TRACE(_module_mp_, _drv_info_, + ("+oid_rt_pro_read_register_hdl\n")); + + if (poid_par_priv->type_of_oid != QUERY_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + RegRWStruct = (struct mp_rw_reg *)poid_par_priv->information_buf; + offset = RegRWStruct->offset; + width = RegRWStruct->width; + + if (offset > 0xFFF) + return NDIS_STATUS_NOT_ACCEPTED; + + _irqlevel_changed_(&oldirql, LOWER); + + switch (width) { + case 1: + RegRWStruct->value = rtw_read8(Adapter, offset); + break; + case 2: + RegRWStruct->value = rtw_read16(Adapter, offset); + break; + default: + width = 4; + RegRWStruct->value = rtw_read32(Adapter, offset); + break; + } + RT_TRACE(_module_mp_, _drv_notice_, + ("oid_rt_pro_read_register_hdl: offset:0x%04X value:0x%X\n", + offset, RegRWStruct->value)); + + _irqlevel_changed_(&oldirql, RAISE); + + *poid_par_priv->bytes_rw = width; + +_func_exit_; + + return status; +} +/* */ +int oid_rt_pro_write_register_hdl(struct oid_par_priv *poid_par_priv) +{ + struct mp_rw_reg *RegRWStruct; + u32 offset, width, value; + int status = NDIS_STATUS_SUCCESS; + struct adapter *padapter = (struct adapter *)(poid_par_priv->adapter_context); + +_func_enter_; + + RT_TRACE(_module_mp_, _drv_info_, + ("+oid_rt_pro_write_register_hdl\n")); + + if (poid_par_priv->type_of_oid != SET_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + RegRWStruct = (struct mp_rw_reg *)poid_par_priv->information_buf; + offset = RegRWStruct->offset; + width = RegRWStruct->width; + value = RegRWStruct->value; + + if (offset > 0xFFF) + return NDIS_STATUS_NOT_ACCEPTED; + + _irqlevel_changed_(&oldirql, LOWER); + + switch (RegRWStruct->width) { + case 1: + if (value > 0xFF) { + status = NDIS_STATUS_NOT_ACCEPTED; + break; + } + rtw_write8(padapter, offset, (u8)value); + break; + case 2: + if (value > 0xFFFF) { + status = NDIS_STATUS_NOT_ACCEPTED; + break; + } + rtw_write16(padapter, offset, (u16)value); + break; + case 4: + rtw_write32(padapter, offset, value); + break; + default: + status = NDIS_STATUS_NOT_ACCEPTED; + break; + } + + _irqlevel_changed_(&oldirql, RAISE); + + RT_TRACE(_module_mp_, _drv_info_, + ("-oid_rt_pro_write_register_hdl: offset=0x%08X width=%d value=0x%X\n", + offset, width, value)); + +_func_exit_; + + return status; +} +/* */ +int oid_rt_pro_burst_read_register_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} +/* */ +int oid_rt_pro_burst_write_register_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} +/* */ +int oid_rt_pro_write_txcmd_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} + +/* */ +int oid_rt_pro_read16_eeprom_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} + +/* */ +int oid_rt_pro_write16_eeprom_hdl (struct oid_par_priv *poid_par_priv) +{ + return 0; +} +/* */ +int oid_rt_pro8711_wi_poll_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} +/* */ +int oid_rt_pro8711_pkt_loss_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} +/* */ +int oid_rt_rd_attrib_mem_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} +/* */ +int oid_rt_wr_attrib_mem_hdl (struct oid_par_priv *poid_par_priv) +{ + return 0; +} +/* */ +int oid_rt_pro_set_rf_intfs_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} +/* */ +int oid_rt_poll_rx_status_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} +/* */ +int oid_rt_pro_cfg_debug_message_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} +/* */ +int oid_rt_pro_set_data_rate_ex_hdl(struct oid_par_priv *poid_par_priv) +{ + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + + int status = NDIS_STATUS_SUCCESS; + +_func_enter_; + + RT_TRACE(_module_mp_, _drv_notice_, ("+OID_RT_PRO_SET_DATA_RATE_EX\n")); + + if (poid_par_priv->type_of_oid != SET_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + _irqlevel_changed_(&oldirql, LOWER); + + if (rtw_setdatarate_cmd(Adapter, poid_par_priv->information_buf) != _SUCCESS) + status = NDIS_STATUS_NOT_ACCEPTED; + + _irqlevel_changed_(&oldirql, RAISE); + +_func_exit_; + + return status; +} +/* */ +int oid_rt_get_thermal_meter_hdl(struct oid_par_priv *poid_par_priv) +{ + int status = NDIS_STATUS_SUCCESS; + u8 thermal = 0; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + +_func_enter_; + + RT_TRACE(_module_mp_, _drv_notice_, ("+oid_rt_get_thermal_meter_hdl\n")); + + if (poid_par_priv->type_of_oid != QUERY_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + if (poid_par_priv->information_buf_len < sizeof(u32)) + return NDIS_STATUS_INVALID_LENGTH; + + _irqlevel_changed_(&oldirql, LOWER); + GetThermalMeter(Adapter, &thermal); + _irqlevel_changed_(&oldirql, RAISE); + + *(u32 *)poid_par_priv->information_buf = (u32)thermal; + *poid_par_priv->bytes_rw = sizeof(u32); + +_func_exit_; + + return status; +} +/* */ +int oid_rt_pro_read_tssi_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} +/* */ +int oid_rt_pro_set_power_tracking_hdl(struct oid_par_priv *poid_par_priv) +{ + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + + +_func_enter_; + + if (poid_par_priv->information_buf_len < sizeof(u8)) + return NDIS_STATUS_INVALID_LENGTH; + + _irqlevel_changed_(&oldirql, LOWER); + if (poid_par_priv->type_of_oid == SET_OID) { + u8 enable; + + enable = *(u8 *)poid_par_priv->information_buf; + RT_TRACE(_module_mp_, _drv_notice_, + ("+oid_rt_pro_set_power_tracking_hdl: enable =%d\n", enable)); + + SetPowerTracking(Adapter, enable); + } else { + GetPowerTracking(Adapter, (u8 *)poid_par_priv->information_buf); + } + _irqlevel_changed_(&oldirql, RAISE); + +_func_exit_; + + return status; +} +/* */ +int oid_rt_pro_set_basic_rate_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} +/* */ +int oid_rt_pro_qry_pwrstate_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} +/* */ +int oid_rt_pro_set_pwrstate_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} +/* */ +int oid_rt_pro_h2c_set_rate_table_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} +/* */ +int oid_rt_pro_h2c_get_rate_table_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} + +/* oid_rtl_seg_87_12_00 section start **************** */ +int oid_rt_pro_encryption_ctrl_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} + +int oid_rt_pro_add_sta_info_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} + +int oid_rt_pro_dele_sta_info_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} + +int oid_rt_pro_query_dr_variable_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} + +int oid_rt_pro_rx_packet_type_hdl(struct oid_par_priv *poid_par_priv) +{ + return NDIS_STATUS_SUCCESS; +} +/* */ +int oid_rt_pro_read_efuse_hdl(struct oid_par_priv *poid_par_priv) +{ + struct efuse_access_struct *pefuse; + u8 *data; + u16 addr = 0, cnts = 0, max_available_size = 0; + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + +_func_enter_; + + if (poid_par_priv->type_of_oid != QUERY_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + if (poid_par_priv->information_buf_len < sizeof(struct efuse_access_struct)) + return NDIS_STATUS_INVALID_LENGTH; + + pefuse = (struct efuse_access_struct *)poid_par_priv->information_buf; + addr = pefuse->start_addr; + cnts = pefuse->cnts; + data = pefuse->data; + + RT_TRACE(_module_mp_, _drv_notice_, + ("+oid_rt_pro_read_efuse_hd: buf_len=%d addr=%d cnts=%d\n", + poid_par_priv->information_buf_len, addr, cnts)); + + EFUSE_GetEfuseDefinition(Adapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); + + if ((addr + cnts) > max_available_size) { + RT_TRACE(_module_mp_, _drv_err_, ("!oid_rt_pro_read_efuse_hdl: parameter error!\n")); + return NDIS_STATUS_NOT_ACCEPTED; + } + + _irqlevel_changed_(&oldirql, LOWER); + if (rtw_efuse_access(Adapter, false, addr, cnts, data) == _FAIL) { + RT_TRACE(_module_mp_, _drv_err_, ("!oid_rt_pro_read_efuse_hdl: rtw_efuse_access FAIL!\n")); + status = NDIS_STATUS_FAILURE; + } else { + *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; + } + _irqlevel_changed_(&oldirql, RAISE); + +_func_exit_; + + return status; +} +/* */ +int oid_rt_pro_write_efuse_hdl(struct oid_par_priv *poid_par_priv) +{ + struct efuse_access_struct *pefuse; + u8 *data; + u16 addr = 0, cnts = 0, max_available_size = 0; + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + + +_func_enter_; + + if (poid_par_priv->type_of_oid != SET_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + pefuse = (struct efuse_access_struct *)poid_par_priv->information_buf; + addr = pefuse->start_addr; + cnts = pefuse->cnts; + data = pefuse->data; + + RT_TRACE(_module_mp_, _drv_notice_, + ("+oid_rt_pro_write_efuse_hdl: buf_len=%d addr=0x%04x cnts=%d\n", + poid_par_priv->information_buf_len, addr, cnts)); + + EFUSE_GetEfuseDefinition(Adapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); + + if ((addr + cnts) > max_available_size) { + RT_TRACE(_module_mp_, _drv_err_, ("!oid_rt_pro_write_efuse_hdl: parameter error")); + return NDIS_STATUS_NOT_ACCEPTED; + } + + _irqlevel_changed_(&oldirql, LOWER); + if (rtw_efuse_access(Adapter, true, addr, cnts, data) == _FAIL) + status = NDIS_STATUS_FAILURE; + _irqlevel_changed_(&oldirql, RAISE); + +_func_exit_; + + return status; +} +/* */ +int oid_rt_pro_rw_efuse_pgpkt_hdl(struct oid_par_priv *poid_par_priv) +{ + struct pgpkt *ppgpkt; + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + +_func_enter_; + + *poid_par_priv->bytes_rw = 0; + + if (poid_par_priv->information_buf_len < sizeof(struct pgpkt *)) + return NDIS_STATUS_INVALID_LENGTH; + + ppgpkt = (struct pgpkt *)poid_par_priv->information_buf; + + _irqlevel_changed_(&oldirql, LOWER); + + if (poid_par_priv->type_of_oid == QUERY_OID) { + RT_TRACE(_module_mp_, _drv_notice_, + ("oid_rt_pro_rw_efuse_pgpkt_hdl: Read offset=0x%x\n",\ + ppgpkt->offset)); + + Efuse_PowerSwitch(Adapter, false, true); + if (Efuse_PgPacketRead(Adapter, ppgpkt->offset, ppgpkt->data, false) == true) + *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; + else + status = NDIS_STATUS_FAILURE; + Efuse_PowerSwitch(Adapter, false, false); + } else { + RT_TRACE(_module_mp_, _drv_notice_, + ("oid_rt_pro_rw_efuse_pgpkt_hdl: Write offset=0x%x word_en=0x%x\n",\ + ppgpkt->offset, ppgpkt->word_en)); + + Efuse_PowerSwitch(Adapter, true, true); + if (Efuse_PgPacketWrite(Adapter, ppgpkt->offset, ppgpkt->word_en, ppgpkt->data, false) == true) + *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; + else + status = NDIS_STATUS_FAILURE; + Efuse_PowerSwitch(Adapter, true, false); + } + + _irqlevel_changed_(&oldirql, RAISE); + + RT_TRACE(_module_mp_, _drv_info_, + ("-oid_rt_pro_rw_efuse_pgpkt_hdl: status=0x%08X\n", status)); + +_func_exit_; + + return status; +} +/* */ +int oid_rt_get_efuse_current_size_hdl(struct oid_par_priv *poid_par_priv) +{ + u16 size; + u8 ret; + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + +_func_enter_; + + if (poid_par_priv->type_of_oid != QUERY_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + if (poid_par_priv->information_buf_len < sizeof(u32)) + return NDIS_STATUS_INVALID_LENGTH; + + _irqlevel_changed_(&oldirql, LOWER); + ret = efuse_GetCurrentSize(Adapter, &size); + _irqlevel_changed_(&oldirql, RAISE); + if (ret == _SUCCESS) { + *(u32 *)poid_par_priv->information_buf = size; + *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; + } else { + status = NDIS_STATUS_FAILURE; + } +_func_exit_; + + return status; +} +/* */ +int oid_rt_get_efuse_max_size_hdl(struct oid_par_priv *poid_par_priv) +{ + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + +_func_enter_; + + if (poid_par_priv->type_of_oid != QUERY_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + if (poid_par_priv->information_buf_len < sizeof(u32)) + return NDIS_STATUS_INVALID_LENGTH; + + *(u32 *)poid_par_priv->information_buf = efuse_GetMaxSize(Adapter); + *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; + + RT_TRACE(_module_mp_, _drv_info_, + ("-oid_rt_get_efuse_max_size_hdl: size=%d status=0x%08X\n", + *(int *)poid_par_priv->information_buf, status)); + +_func_exit_; + + return status; +} +/* */ +int oid_rt_pro_efuse_hdl(struct oid_par_priv *poid_par_priv) +{ + int status; + +_func_enter_; + + RT_TRACE(_module_mp_, _drv_info_, ("+oid_rt_pro_efuse_hdl\n")); + + if (poid_par_priv->type_of_oid == QUERY_OID) + status = oid_rt_pro_read_efuse_hdl(poid_par_priv); + else + status = oid_rt_pro_write_efuse_hdl(poid_par_priv); + + RT_TRACE(_module_mp_, _drv_info_, ("-oid_rt_pro_efuse_hdl: status=0x%08X\n", status)); + +_func_exit_; + + return status; +} +/* */ +int oid_rt_pro_efuse_map_hdl(struct oid_par_priv *poid_par_priv) +{ + u8 *data; + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + u16 maplen = 0; + +_func_enter_; + + RT_TRACE(_module_mp_, _drv_notice_, ("+oid_rt_pro_efuse_map_hdl\n")); + + EFUSE_GetEfuseDefinition(Adapter, EFUSE_WIFI, TYPE_EFUSE_MAP_LEN, (void *)&maplen, false); + + *poid_par_priv->bytes_rw = 0; + + if (poid_par_priv->information_buf_len < maplen) + return NDIS_STATUS_INVALID_LENGTH; + + data = (u8 *)poid_par_priv->information_buf; + + _irqlevel_changed_(&oldirql, LOWER); + + if (poid_par_priv->type_of_oid == QUERY_OID) { + RT_TRACE(_module_mp_, _drv_info_, + ("oid_rt_pro_efuse_map_hdl: READ\n")); + + if (rtw_efuse_map_read(Adapter, 0, maplen, data) == _SUCCESS) { + *poid_par_priv->bytes_rw = maplen; + } else { + RT_TRACE(_module_mp_, _drv_err_, + ("oid_rt_pro_efuse_map_hdl: READ fail\n")); + status = NDIS_STATUS_FAILURE; + } + } else { + /* SET_OID */ + RT_TRACE(_module_mp_, _drv_info_, + ("oid_rt_pro_efuse_map_hdl: WRITE\n")); + + if (rtw_efuse_map_write(Adapter, 0, maplen, data) == _SUCCESS) { + *poid_par_priv->bytes_rw = maplen; + } else { + RT_TRACE(_module_mp_, _drv_err_, + ("oid_rt_pro_efuse_map_hdl: WRITE fail\n")); + status = NDIS_STATUS_FAILURE; + } + } + + _irqlevel_changed_(&oldirql, RAISE); + + RT_TRACE(_module_mp_, _drv_info_, + ("-oid_rt_pro_efuse_map_hdl: status=0x%08X\n", status)); + +_func_exit_; + + return status; +} + +int oid_rt_set_crystal_cap_hdl(struct oid_par_priv *poid_par_priv) +{ + int status = NDIS_STATUS_SUCCESS; + return status; +} + +int oid_rt_set_rx_packet_type_hdl(struct oid_par_priv *poid_par_priv) +{ + u8 rx_pkt_type; + int status = NDIS_STATUS_SUCCESS; + +_func_enter_; + + RT_TRACE(_module_mp_, _drv_notice_, ("+oid_rt_set_rx_packet_type_hdl\n")); + + if (poid_par_priv->type_of_oid != SET_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + if (poid_par_priv->information_buf_len < sizeof(u8)) + return NDIS_STATUS_INVALID_LENGTH; + + rx_pkt_type = *((u8 *)poid_par_priv->information_buf);/* 4 */ + + RT_TRACE(_module_mp_, _drv_info_, ("rx_pkt_type: %x\n", rx_pkt_type)); +_func_exit_; + + return status; +} + +int oid_rt_pro_set_tx_agc_offset_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} + +int oid_rt_pro_set_pkt_test_mode_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} + +int mp_ioctl_xmit_packet_hdl(struct oid_par_priv *poid_par_priv) +{ + struct mp_xmit_parm *pparm; + struct adapter *padapter; + struct mp_priv *pmp_priv; + struct pkt_attrib *pattrib; + + RT_TRACE(_module_mp_, _drv_notice_, ("+%s\n", __func__)); + + pparm = (struct mp_xmit_parm *)poid_par_priv->information_buf; + padapter = (struct adapter *)poid_par_priv->adapter_context; + pmp_priv = &padapter->mppriv; + + if (poid_par_priv->type_of_oid == QUERY_OID) { + pparm->enable = !pmp_priv->tx.stop; + pparm->count = pmp_priv->tx.sended; + } else { + if (pparm->enable == 0) { + pmp_priv->tx.stop = 1; + } else if (pmp_priv->tx.stop == 1) { + pmp_priv->tx.stop = 0; + pmp_priv->tx.count = pparm->count; + pmp_priv->tx.payload = pparm->payload_type; + pattrib = &pmp_priv->tx.attrib; + pattrib->pktlen = pparm->length; + memcpy(pattrib->dst, pparm->da, ETH_ALEN); + SetPacketTx(padapter); + } else { + return NDIS_STATUS_FAILURE; + } + } + + return NDIS_STATUS_SUCCESS; +} + +/* */ +int oid_rt_set_power_down_hdl(struct oid_par_priv *poid_par_priv) +{ + int status = NDIS_STATUS_SUCCESS; + +_func_enter_; + + if (poid_par_priv->type_of_oid != SET_OID) { + status = NDIS_STATUS_NOT_ACCEPTED; + return status; + } + + RT_TRACE(_module_mp_, _drv_info_, + ("\n ===> Setoid_rt_set_power_down_hdl.\n")); + + _irqlevel_changed_(&oldirql, LOWER); + + /* CALL the power_down function */ + _irqlevel_changed_(&oldirql, RAISE); + +_func_exit_; + + return status; +} +/* */ +int oid_rt_get_power_mode_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} diff --git a/drivers/staging/rtl8188eu/core/rtw_p2p.c b/drivers/staging/rtl8188eu/core/rtw_p2p.c new file mode 100644 index 0000000000000..8cf915f4cf982 --- /dev/null +++ b/drivers/staging/rtl8188eu/core/rtw_p2p.c @@ -0,0 +1,2064 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTW_P2P_C_ + +#include +#include +#include + +#ifdef CONFIG_88EU_P2P + +static int rtw_p2p_is_channel_list_ok(u8 desired_ch, u8 *ch_list, u8 ch_cnt) +{ + int found = 0, i = 0; + + for (i = 0; i < ch_cnt; i++) { + if (ch_list[i] == desired_ch) { + found = 1; + break; + } + } + return found; +} + +static u32 go_add_group_info_attr(struct wifidirect_info *pwdinfo, u8 *pbuf) +{ + unsigned long irqL; + struct list_head *phead, *plist; + u32 len = 0; + u16 attr_len = 0; + u8 tmplen, *pdata_attr, *pstart, *pcur; + struct sta_info *psta = NULL; + struct adapter *padapter = pwdinfo->padapter; + struct sta_priv *pstapriv = &padapter->stapriv; + + DBG_88E("%s\n", __func__); + + pdata_attr = rtw_zmalloc(MAX_P2P_IE_LEN); + + pstart = pdata_attr; + pcur = pdata_attr; + + _enter_critical_bh(&pstapriv->asoc_list_lock, &irqL); + phead = &pstapriv->asoc_list; + plist = get_next(phead); + + /* look up sta asoc_queue */ + while ((rtw_end_of_queue_search(phead, plist)) == false) { + psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); + + plist = get_next(plist); + + + if (psta->is_p2p_device) { + tmplen = 0; + + pcur++; + + /* P2P device address */ + memcpy(pcur, psta->dev_addr, ETH_ALEN); + pcur += ETH_ALEN; + + /* P2P interface address */ + memcpy(pcur, psta->hwaddr, ETH_ALEN); + pcur += ETH_ALEN; + + *pcur = psta->dev_cap; + pcur++; + + /* u16*)(pcur) = cpu_to_be16(psta->config_methods); */ + RTW_PUT_BE16(pcur, psta->config_methods); + pcur += 2; + + memcpy(pcur, psta->primary_dev_type, 8); + pcur += 8; + + *pcur = psta->num_of_secdev_type; + pcur++; + + memcpy(pcur, psta->secdev_types_list, psta->num_of_secdev_type*8); + pcur += psta->num_of_secdev_type*8; + + if (psta->dev_name_len > 0) { + /* u16*)(pcur) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); */ + RTW_PUT_BE16(pcur, WPS_ATTR_DEVICE_NAME); + pcur += 2; + + /* u16*)(pcur) = cpu_to_be16(psta->dev_name_len); */ + RTW_PUT_BE16(pcur, psta->dev_name_len); + pcur += 2; + + memcpy(pcur, psta->dev_name, psta->dev_name_len); + pcur += psta->dev_name_len; + } + + + tmplen = (u8)(pcur-pstart); + + *pstart = (tmplen-1); + + attr_len += tmplen; + + /* pstart += tmplen; */ + pstart = pcur; + } + } + _exit_critical_bh(&pstapriv->asoc_list_lock, &irqL); + + if (attr_len > 0) + len = rtw_set_p2p_attr_content(pbuf, P2P_ATTR_GROUP_INFO, attr_len, pdata_attr); + + kfree(pdata_attr); + return len; +} + +static void issue_group_disc_req(struct wifidirect_info *pwdinfo, u8 *da) +{ + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; + struct rtw_ieee80211_hdr *pwlanhdr; + unsigned short *fctrl; + struct adapter *padapter = pwdinfo->padapter; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + unsigned char category = RTW_WLAN_CATEGORY_P2P;/* P2P action frame */ + __be32 p2poui = cpu_to_be32(P2POUI); + u8 oui_subtype = P2P_GO_DISC_REQUEST; + u8 dialogToken = 0; + + DBG_88E("[%s]\n", __func__); + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + return; + + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + + _rtw_memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + + memcpy(pwlanhdr->addr1, da, ETH_ALEN); + memcpy(pwlanhdr->addr2, pwdinfo->interface_addr, ETH_ALEN); + memcpy(pwlanhdr->addr3, pwdinfo->interface_addr, ETH_ALEN); + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + SetFrameSubType(pframe, WIFI_ACTION); + + pframe += sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); + + /* Build P2P action frame header */ + pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&(p2poui), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(oui_subtype), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(dialogToken), &(pattrib->pktlen)); + + /* there is no IE in this P2P action frame */ + + pattrib->last_txcmdsz = pattrib->pktlen; + + dump_mgntframe(padapter, pmgntframe); +} + +static void issue_p2p_devdisc_resp(struct wifidirect_info *pwdinfo, u8 *da, u8 status, u8 dialogToken) +{ + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; + struct rtw_ieee80211_hdr *pwlanhdr; + unsigned short *fctrl; + struct adapter *padapter = pwdinfo->padapter; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + unsigned char category = RTW_WLAN_CATEGORY_PUBLIC; + u8 action = P2P_PUB_ACTION_ACTION; + __be32 p2poui = cpu_to_be32(P2POUI); + u8 oui_subtype = P2P_DEVDISC_RESP; + u8 p2pie[8] = { 0x00 }; + u32 p2pielen = 0; + + DBG_88E("[%s]\n", __func__); + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + return; + + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + + _rtw_memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + + memcpy(pwlanhdr->addr1, da, ETH_ALEN); + memcpy(pwlanhdr->addr2, pwdinfo->device_addr, ETH_ALEN); + memcpy(pwlanhdr->addr3, pwdinfo->device_addr, ETH_ALEN); + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + SetFrameSubType(pframe, WIFI_ACTION); + + pframe += sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); + + /* Build P2P public action frame header */ + pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(action), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&(p2poui), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(oui_subtype), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(dialogToken), &(pattrib->pktlen)); + + + /* Build P2P IE */ + /* P2P OUI */ + p2pielen = 0; + p2pie[p2pielen++] = 0x50; + p2pie[p2pielen++] = 0x6F; + p2pie[p2pielen++] = 0x9A; + p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ + + /* P2P_ATTR_STATUS */ + p2pielen += rtw_set_p2p_attr_content(&p2pie[p2pielen], P2P_ATTR_STATUS, 1, &status); + + pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, p2pie, &pattrib->pktlen); + + pattrib->last_txcmdsz = pattrib->pktlen; + + dump_mgntframe(padapter, pmgntframe); +} + +static void issue_p2p_provision_resp(struct wifidirect_info *pwdinfo, u8 *raddr, u8 *frame_body, u16 config_method) +{ + struct adapter *padapter = pwdinfo->padapter; + unsigned char category = RTW_WLAN_CATEGORY_PUBLIC; + u8 action = P2P_PUB_ACTION_ACTION; + u8 dialogToken = frame_body[7]; /* The Dialog Token of provisioning discovery request frame. */ + __be32 p2poui = cpu_to_be32(P2POUI); + u8 oui_subtype = P2P_PROVISION_DISC_RESP; + u8 wpsie[100] = { 0x00 }; + u8 wpsielen = 0; + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; + struct rtw_ieee80211_hdr *pwlanhdr; + unsigned short *fctrl; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + return; + + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + + _rtw_memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + + memcpy(pwlanhdr->addr1, raddr, ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr3, myid(&(padapter->eeprompriv)), ETH_ALEN); + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + SetFrameSubType(pframe, WIFI_ACTION); + + pframe += sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); + + pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(action), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&(p2poui), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(oui_subtype), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(dialogToken), &(pattrib->pktlen)); + + wpsielen = 0; + /* WPS OUI */ + RTW_PUT_BE32(wpsie, WPSOUI); + wpsielen += 4; + + /* Config Method */ + /* Type: */ + RTW_PUT_BE16(wpsie + wpsielen, WPS_ATTR_CONF_METHOD); + wpsielen += 2; + + /* Length: */ + RTW_PUT_BE16(wpsie + wpsielen, 0x0002); + wpsielen += 2; + + /* Value: */ + RTW_PUT_BE16(wpsie + wpsielen, config_method); + wpsielen += 2; + + pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, wpsielen, (unsigned char *)wpsie, &pattrib->pktlen); + + pattrib->last_txcmdsz = pattrib->pktlen; + + dump_mgntframe(padapter, pmgntframe); + + return; +} + +static void issue_p2p_presence_resp(struct wifidirect_info *pwdinfo, u8 *da, u8 status, u8 dialogToken) +{ + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; + struct rtw_ieee80211_hdr *pwlanhdr; + unsigned short *fctrl; + struct adapter *padapter = pwdinfo->padapter; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + unsigned char category = RTW_WLAN_CATEGORY_P2P;/* P2P action frame */ + __be32 p2poui = cpu_to_be32(P2POUI); + u8 oui_subtype = P2P_PRESENCE_RESPONSE; + u8 p2pie[MAX_P2P_IE_LEN] = { 0x00 }; + u8 noa_attr_content[32] = { 0x00 }; + u32 p2pielen = 0; + + DBG_88E("[%s]\n", __func__); + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + return; + + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + + _rtw_memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + + memcpy(pwlanhdr->addr1, da, ETH_ALEN); + memcpy(pwlanhdr->addr2, pwdinfo->interface_addr, ETH_ALEN); + memcpy(pwlanhdr->addr3, pwdinfo->interface_addr, ETH_ALEN); + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + SetFrameSubType(pframe, WIFI_ACTION); + + pframe += sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); + + /* Build P2P action frame header */ + pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&(p2poui), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(oui_subtype), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(dialogToken), &(pattrib->pktlen)); + + + /* Add P2P IE header */ + /* P2P OUI */ + p2pielen = 0; + p2pie[p2pielen++] = 0x50; + p2pie[p2pielen++] = 0x6F; + p2pie[p2pielen++] = 0x9A; + p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ + + /* Add Status attribute in P2P IE */ + p2pielen += rtw_set_p2p_attr_content(&p2pie[p2pielen], P2P_ATTR_STATUS, 1, &status); + + /* Add NoA attribute in P2P IE */ + noa_attr_content[0] = 0x1;/* index */ + noa_attr_content[1] = 0x0;/* CTWindow and OppPS Parameters */ + + /* todo: Notice of Absence Descriptor(s) */ + + p2pielen += rtw_set_p2p_attr_content(&p2pie[p2pielen], P2P_ATTR_NOA, 2, noa_attr_content); + + + + pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, p2pie, &(pattrib->pktlen)); + + + pattrib->last_txcmdsz = pattrib->pktlen; + + dump_mgntframe(padapter, pmgntframe); +} + +u32 build_beacon_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) +{ + u8 p2pie[MAX_P2P_IE_LEN] = { 0x00 }; + u16 capability = 0; + u32 len = 0, p2pielen = 0; + __le16 le_tmp; + + /* P2P OUI */ + p2pielen = 0; + p2pie[p2pielen++] = 0x50; + p2pie[p2pielen++] = 0x6F; + p2pie[p2pielen++] = 0x9A; + p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ + + + /* According to the P2P Specification, the beacon frame should contain 3 P2P attributes */ + /* 1. P2P Capability */ + /* 2. P2P Device ID */ + /* 3. Notice of Absence (NOA) */ + + /* P2P Capability ATTR */ + /* Type: */ + /* Length: */ + /* Value: */ + /* Device Capability Bitmap, 1 byte */ + /* Be able to participate in additional P2P Groups and */ + /* support the P2P Invitation Procedure */ + /* Group Capability Bitmap, 1 byte */ + capability = P2P_DEVCAP_INVITATION_PROC|P2P_DEVCAP_CLIENT_DISCOVERABILITY; + capability |= ((P2P_GRPCAP_GO | P2P_GRPCAP_INTRABSS) << 8); + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_PROVISIONING_ING)) + capability |= (P2P_GRPCAP_GROUP_FORMATION<<8); + + le_tmp = cpu_to_le16(capability); + p2pielen += rtw_set_p2p_attr_content(&p2pie[p2pielen], P2P_ATTR_CAPABILITY, 2, (u8 *)&le_tmp); + + /* P2P Device ID ATTR */ + p2pielen += rtw_set_p2p_attr_content(&p2pie[p2pielen], P2P_ATTR_DEVICE_ID, ETH_ALEN, pwdinfo->device_addr); + + /* Notice of Absence ATTR */ + /* Type: */ + /* Length: */ + /* Value: */ + + pbuf = rtw_set_ie(pbuf, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &len); + return len; +} + +u32 build_probe_resp_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) +{ + u8 p2pie[MAX_P2P_IE_LEN] = { 0x00 }; + u32 len = 0, p2pielen = 0; + + /* P2P OUI */ + p2pielen = 0; + p2pie[p2pielen++] = 0x50; + p2pie[p2pielen++] = 0x6F; + p2pie[p2pielen++] = 0x9A; + p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ + + /* Commented by Albert 20100907 */ + /* According to the P2P Specification, the probe response frame should contain 5 P2P attributes */ + /* 1. P2P Capability */ + /* 2. Extended Listen Timing */ + /* 3. Notice of Absence (NOA) (Only GO needs this) */ + /* 4. Device Info */ + /* 5. Group Info (Only GO need this) */ + + /* P2P Capability ATTR */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_CAPABILITY; + + /* Length: */ + /* u16*) (p2pie + p2pielen) = cpu_to_le16(0x0002); */ + RTW_PUT_LE16(p2pie + p2pielen, 0x0002); + p2pielen += 2; + + /* Value: */ + /* Device Capability Bitmap, 1 byte */ + p2pie[p2pielen++] = DMP_P2P_DEVCAP_SUPPORT; + + /* Group Capability Bitmap, 1 byte */ + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { + p2pie[p2pielen] = (P2P_GRPCAP_GO | P2P_GRPCAP_INTRABSS); + + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_PROVISIONING_ING)) + p2pie[p2pielen] |= P2P_GRPCAP_GROUP_FORMATION; + + p2pielen++; + } else if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE)) { + /* Group Capability Bitmap, 1 byte */ + if (pwdinfo->persistent_supported) + p2pie[p2pielen++] = P2P_GRPCAP_PERSISTENT_GROUP | DMP_P2P_GRPCAP_SUPPORT; + else + p2pie[p2pielen++] = DMP_P2P_GRPCAP_SUPPORT; + } + + /* Extended Listen Timing ATTR */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_EX_LISTEN_TIMING; + + /* Length: */ + /* u16*) (p2pie + p2pielen) = cpu_to_le16(0x0004); */ + RTW_PUT_LE16(p2pie + p2pielen, 0x0004); + p2pielen += 2; + + /* Value: */ + /* Availability Period */ + /* u16*) (p2pie + p2pielen) = cpu_to_le16(0xFFFF); */ + RTW_PUT_LE16(p2pie + p2pielen, 0xFFFF); + p2pielen += 2; + + /* Availability Interval */ + /* u16*) (p2pie + p2pielen) = cpu_to_le16(0xFFFF); */ + RTW_PUT_LE16(p2pie + p2pielen, 0xFFFF); + p2pielen += 2; + + + /* Notice of Absence ATTR */ + /* Type: */ + /* Length: */ + /* Value: */ + + /* Device Info ATTR */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_DEVICE_INFO; + + /* Length: */ + /* 21 -> P2P Device Address (6bytes) + Config Methods (2bytes) + Primary Device Type (8bytes) */ + /* + NumofSecondDevType (1byte) + WPS Device Name ID field (2bytes) + WPS Device Name Len field (2bytes) */ + /* u16*) (p2pie + p2pielen) = cpu_to_le16(21 + pwdinfo->device_name_len); */ + RTW_PUT_LE16(p2pie + p2pielen, 21 + pwdinfo->device_name_len); + p2pielen += 2; + + /* Value: */ + /* P2P Device Address */ + memcpy(p2pie + p2pielen, pwdinfo->device_addr, ETH_ALEN); + p2pielen += ETH_ALEN; + + /* Config Method */ + /* This field should be big endian. Noted by P2P specification. */ + /* u16*) (p2pie + p2pielen) = cpu_to_be16(pwdinfo->supported_wps_cm); */ + RTW_PUT_BE16(p2pie + p2pielen, pwdinfo->supported_wps_cm); + p2pielen += 2; + + /* Primary Device Type */ + /* Category ID */ + /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); */ + RTW_PUT_BE16(p2pie + p2pielen, WPS_PDT_CID_MULIT_MEDIA); + p2pielen += 2; + + /* OUI */ + /* u32*) (p2pie + p2pielen) = cpu_to_be32(WPSOUI); */ + RTW_PUT_BE32(p2pie + p2pielen, WPSOUI); + p2pielen += 4; + + /* Sub Category ID */ + /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); */ + RTW_PUT_BE16(p2pie + p2pielen, WPS_PDT_SCID_MEDIA_SERVER); + p2pielen += 2; + + /* Number of Secondary Device Types */ + p2pie[p2pielen++] = 0x00; /* No Secondary Device Type List */ + + /* Device Name */ + /* Type: */ + /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); */ + RTW_PUT_BE16(p2pie + p2pielen, WPS_ATTR_DEVICE_NAME); + p2pielen += 2; + + /* Length: */ + /* u16*) (p2pie + p2pielen) = cpu_to_be16(pwdinfo->device_name_len); */ + RTW_PUT_BE16(p2pie + p2pielen, pwdinfo->device_name_len); + p2pielen += 2; + + /* Value: */ + memcpy(p2pie + p2pielen, pwdinfo->device_name, pwdinfo->device_name_len); + p2pielen += pwdinfo->device_name_len; + + /* Group Info ATTR */ + /* Type: */ + /* Length: */ + /* Value: */ + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) + p2pielen += go_add_group_info_attr(pwdinfo, p2pie + p2pielen); + + + pbuf = rtw_set_ie(pbuf, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &len); + + + return len; +} + +u32 build_prov_disc_request_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf, u8 *pssid, u8 ussidlen, u8 *pdev_raddr) +{ + u8 p2pie[MAX_P2P_IE_LEN] = { 0x00 }; + u32 len = 0, p2pielen = 0; + + /* P2P OUI */ + p2pielen = 0; + p2pie[p2pielen++] = 0x50; + p2pie[p2pielen++] = 0x6F; + p2pie[p2pielen++] = 0x9A; + p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ + + /* Commented by Albert 20110301 */ + /* According to the P2P Specification, the provision discovery request frame should contain 3 P2P attributes */ + /* 1. P2P Capability */ + /* 2. Device Info */ + /* 3. Group ID (When joining an operating P2P Group) */ + + /* P2P Capability ATTR */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_CAPABILITY; + + /* Length: */ + /* u16*) (p2pie + p2pielen) = cpu_to_le16(0x0002); */ + RTW_PUT_LE16(p2pie + p2pielen, 0x0002); + p2pielen += 2; + + /* Value: */ + /* Device Capability Bitmap, 1 byte */ + p2pie[p2pielen++] = DMP_P2P_DEVCAP_SUPPORT; + + /* Group Capability Bitmap, 1 byte */ + if (pwdinfo->persistent_supported) + p2pie[p2pielen++] = P2P_GRPCAP_PERSISTENT_GROUP | DMP_P2P_GRPCAP_SUPPORT; + else + p2pie[p2pielen++] = DMP_P2P_GRPCAP_SUPPORT; + + + /* Device Info ATTR */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_DEVICE_INFO; + + /* Length: */ + /* 21 -> P2P Device Address (6bytes) + Config Methods (2bytes) + Primary Device Type (8bytes) */ + /* + NumofSecondDevType (1byte) + WPS Device Name ID field (2bytes) + WPS Device Name Len field (2bytes) */ + /* u16*) (p2pie + p2pielen) = cpu_to_le16(21 + pwdinfo->device_name_len); */ + RTW_PUT_LE16(p2pie + p2pielen, 21 + pwdinfo->device_name_len); + p2pielen += 2; + + /* Value: */ + /* P2P Device Address */ + memcpy(p2pie + p2pielen, pwdinfo->device_addr, ETH_ALEN); + p2pielen += ETH_ALEN; + + /* Config Method */ + /* This field should be big endian. Noted by P2P specification. */ + if (pwdinfo->ui_got_wps_info == P2P_GOT_WPSINFO_PBC) { + /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_CONFIG_METHOD_PBC); */ + RTW_PUT_BE16(p2pie + p2pielen, WPS_CONFIG_METHOD_PBC); + } else { + /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_CONFIG_METHOD_DISPLAY); */ + RTW_PUT_BE16(p2pie + p2pielen, WPS_CONFIG_METHOD_DISPLAY); + } + + p2pielen += 2; + + /* Primary Device Type */ + /* Category ID */ + /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); */ + RTW_PUT_BE16(p2pie + p2pielen, WPS_PDT_CID_MULIT_MEDIA); + p2pielen += 2; + + /* OUI */ + /* u32*) (p2pie + p2pielen) = cpu_to_be32(WPSOUI); */ + RTW_PUT_BE32(p2pie + p2pielen, WPSOUI); + p2pielen += 4; + + /* Sub Category ID */ + /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); */ + RTW_PUT_BE16(p2pie + p2pielen, WPS_PDT_SCID_MEDIA_SERVER); + p2pielen += 2; + + /* Number of Secondary Device Types */ + p2pie[p2pielen++] = 0x00; /* No Secondary Device Type List */ + + /* Device Name */ + /* Type: */ + /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); */ + RTW_PUT_BE16(p2pie + p2pielen, WPS_ATTR_DEVICE_NAME); + p2pielen += 2; + + /* Length: */ + /* u16*) (p2pie + p2pielen) = cpu_to_be16(pwdinfo->device_name_len); */ + RTW_PUT_BE16(p2pie + p2pielen, pwdinfo->device_name_len); + p2pielen += 2; + + /* Value: */ + memcpy(p2pie + p2pielen, pwdinfo->device_name, pwdinfo->device_name_len); + p2pielen += pwdinfo->device_name_len; + + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_CLIENT)) { + /* Added by Albert 2011/05/19 */ + /* In this case, the pdev_raddr is the device address of the group owner. */ + + /* P2P Group ID ATTR */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_GROUP_ID; + + /* Length: */ + /* u16*) (p2pie + p2pielen) = cpu_to_le16(ETH_ALEN + ussidlen); */ + RTW_PUT_LE16(p2pie + p2pielen, ETH_ALEN + ussidlen); + p2pielen += 2; + + /* Value: */ + memcpy(p2pie + p2pielen, pdev_raddr, ETH_ALEN); + p2pielen += ETH_ALEN; + + memcpy(p2pie + p2pielen, pssid, ussidlen); + p2pielen += ussidlen; + } + + pbuf = rtw_set_ie(pbuf, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &len); + + + return len; +} + + +u32 build_assoc_resp_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf, u8 status_code) +{ + u8 p2pie[MAX_P2P_IE_LEN] = { 0x00 }; + u32 len = 0, p2pielen = 0; + + /* P2P OUI */ + p2pielen = 0; + p2pie[p2pielen++] = 0x50; + p2pie[p2pielen++] = 0x6F; + p2pie[p2pielen++] = 0x9A; + p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ + + /* According to the P2P Specification, the Association response frame should contain 2 P2P attributes */ + /* 1. Status */ + /* 2. Extended Listen Timing (optional) */ + + + /* Status ATTR */ + p2pielen += rtw_set_p2p_attr_content(&p2pie[p2pielen], P2P_ATTR_STATUS, 1, &status_code); + + + /* Extended Listen Timing ATTR */ + /* Type: */ + /* Length: */ + /* Value: */ + + pbuf = rtw_set_ie(pbuf, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &len); + + return len; +} + +u32 build_deauth_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) +{ + u32 len = 0; + + return len; +} + +u32 process_probe_req_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pframe, uint len) +{ + u8 *p; + u32 ret = false; + u8 *p2pie; + u32 p2pielen = 0; + int ssid_len = 0, rate_cnt = 0; + + p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + _PROBEREQ_IE_OFFSET_, _SUPPORTEDRATES_IE_, (int *)&rate_cnt, + len - WLAN_HDR_A3_LEN - _PROBEREQ_IE_OFFSET_); + + if (rate_cnt <= 4) { + int i, g_rate = 0; + + for (i = 0; i < rate_cnt; i++) { + if (((*(p + 2 + i) & 0xff) != 0x02) && + ((*(p + 2 + i) & 0xff) != 0x04) && + ((*(p + 2 + i) & 0xff) != 0x0B) && + ((*(p + 2 + i) & 0xff) != 0x16)) + g_rate = 1; + } + + if (g_rate == 0) { + /* There is no OFDM rate included in SupportedRates IE of this probe request frame */ + /* The driver should response this probe request. */ + return ret; + } + } else { + /* rate_cnt > 4 means the SupportRates IE contains the OFDM rate because the count of CCK rates are 4. */ + /* We should proceed the following check for this probe request. */ + } + + /* Added comments by Albert 20100906 */ + /* There are several items we should check here. */ + /* 1. This probe request frame must contain the P2P IE. (Done) */ + /* 2. This probe request frame must contain the wildcard SSID. (Done) */ + /* 3. Wildcard BSSID. (Todo) */ + /* 4. Destination Address. (Done in mgt_dispatcher function) */ + /* 5. Requested Device Type in WSC IE. (Todo) */ + /* 6. Device ID attribute in P2P IE. (Todo) */ + + p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + _PROBEREQ_IE_OFFSET_, _SSID_IE_, (int *)&ssid_len, + len - WLAN_HDR_A3_LEN - _PROBEREQ_IE_OFFSET_); + + ssid_len &= 0xff; /* Just last 1 byte is valid for ssid len of the probe request */ + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE) || rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { + p2pie = rtw_get_p2p_ie(pframe + WLAN_HDR_A3_LEN + _PROBEREQ_IE_OFFSET_ , len - WLAN_HDR_A3_LEN - _PROBEREQ_IE_OFFSET_ , NULL, &p2pielen); + if (p2pie) { + if ((p != NULL) && _rtw_memcmp((void *)(p+2), (void *)pwdinfo->p2p_wildcard_ssid , 7)) { + /* todo: */ + /* Check Requested Device Type attributes in WSC IE. */ + /* Check Device ID attribute in P2P IE */ + + ret = true; + } else if ((p != NULL) && (ssid_len == 0)) { + ret = true; + } + } else { + /* non -p2p device */ + } + } + + + return ret; +} + +u32 process_assoc_req_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pframe, uint len, struct sta_info *psta) +{ + u8 status_code = P2P_STATUS_SUCCESS; + u8 *pbuf, *pattr_content = NULL; + u32 attr_contentlen = 0; + u16 cap_attr = 0; + unsigned short frame_type, ie_offset = 0; + u8 *ies; + u32 ies_len; + u8 *p2p_ie; + u32 p2p_ielen = 0; + __be16 be_tmp; + __le16 le_tmp; + + if (!rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) + return P2P_STATUS_FAIL_REQUEST_UNABLE; + + frame_type = GetFrameSubType(pframe); + if (frame_type == WIFI_ASSOCREQ) + ie_offset = _ASOCREQ_IE_OFFSET_; + else /* WIFI_REASSOCREQ */ + ie_offset = _REASOCREQ_IE_OFFSET_; + + ies = pframe + WLAN_HDR_A3_LEN + ie_offset; + ies_len = len - WLAN_HDR_A3_LEN - ie_offset; + + p2p_ie = rtw_get_p2p_ie(ies , ies_len , NULL, &p2p_ielen); + + if (!p2p_ie) { + DBG_88E("[%s] P2P IE not Found!!\n", __func__); + status_code = P2P_STATUS_FAIL_INVALID_PARAM; + } else { + DBG_88E("[%s] P2P IE Found!!\n", __func__); + } + + while (p2p_ie) { + /* Check P2P Capability ATTR */ + if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_CAPABILITY, (u8 *)&le_tmp, (uint *)&attr_contentlen)) { + DBG_88E("[%s] Got P2P Capability Attr!!\n", __func__); + cap_attr = le16_to_cpu(le_tmp); + psta->dev_cap = cap_attr&0xff; + } + + /* Check Extended Listen Timing ATTR */ + + + /* Check P2P Device Info ATTR */ + if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_DEVICE_INFO, NULL, (uint *)&attr_contentlen)) { + DBG_88E("[%s] Got P2P DEVICE INFO Attr!!\n", __func__); + pattr_content = rtw_zmalloc(attr_contentlen); + pbuf = pattr_content; + if (pattr_content) { + u8 num_of_secdev_type; + u16 dev_name_len; + + rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_DEVICE_INFO , pattr_content, (uint *)&attr_contentlen); + + memcpy(psta->dev_addr, pattr_content, ETH_ALEN);/* P2P Device Address */ + + pattr_content += ETH_ALEN; + + memcpy(&be_tmp, pattr_content, 2);/* Config Methods */ + psta->config_methods = be16_to_cpu(be_tmp); + + pattr_content += 2; + + memcpy(psta->primary_dev_type, pattr_content, 8); + + pattr_content += 8; + + num_of_secdev_type = *pattr_content; + pattr_content += 1; + + if (num_of_secdev_type == 0) { + psta->num_of_secdev_type = 0; + } else { + u32 len; + + psta->num_of_secdev_type = num_of_secdev_type; + + len = (sizeof(psta->secdev_types_list) < (num_of_secdev_type*8)) ? + (sizeof(psta->secdev_types_list)) : (num_of_secdev_type*8); + + memcpy(psta->secdev_types_list, pattr_content, len); + + pattr_content += (num_of_secdev_type*8); + } + + + psta->dev_name_len = 0; + if (WPS_ATTR_DEVICE_NAME == be16_to_cpu(*(__be16 *)pattr_content)) { + dev_name_len = be16_to_cpu(*(__be16 *)(pattr_content+2)); + + psta->dev_name_len = (sizeof(psta->dev_name) < dev_name_len) ? sizeof(psta->dev_name) : dev_name_len; + + memcpy(psta->dev_name, pattr_content+4, psta->dev_name_len); + } + kfree(pbuf); + } + } + + /* Get the next P2P IE */ + p2p_ie = rtw_get_p2p_ie(p2p_ie+p2p_ielen, ies_len - (p2p_ie - ies + p2p_ielen), NULL, &p2p_ielen); + } + + return status_code; +} + +u32 process_p2p_devdisc_req(struct wifidirect_info *pwdinfo, u8 *pframe, uint len) +{ + u8 *frame_body; + u8 status, dialogToken; + struct sta_info *psta = NULL; + struct adapter *padapter = pwdinfo->padapter; + struct sta_priv *pstapriv = &padapter->stapriv; + u8 *p2p_ie; + u32 p2p_ielen = 0; + + frame_body = (unsigned char *)(pframe + sizeof(struct rtw_ieee80211_hdr_3addr)); + + dialogToken = frame_body[7]; + status = P2P_STATUS_FAIL_UNKNOWN_P2PGROUP; + + p2p_ie = rtw_get_p2p_ie(frame_body + _PUBLIC_ACTION_IE_OFFSET_, len - _PUBLIC_ACTION_IE_OFFSET_, NULL, &p2p_ielen); + if (p2p_ie) { + u8 groupid[38] = { 0x00 }; + u8 dev_addr[ETH_ALEN] = { 0x00 }; + u32 attr_contentlen = 0; + + if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_ID, groupid, &attr_contentlen)) { + if (_rtw_memcmp(pwdinfo->device_addr, groupid, ETH_ALEN) && + _rtw_memcmp(pwdinfo->p2p_group_ssid, groupid+ETH_ALEN, pwdinfo->p2p_group_ssid_len)) { + attr_contentlen = 0; + if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_DEVICE_ID, dev_addr, &attr_contentlen)) { + unsigned long irqL; + struct list_head *phead, *plist; + + _enter_critical_bh(&pstapriv->asoc_list_lock, &irqL); + phead = &pstapriv->asoc_list; + plist = get_next(phead); + + /* look up sta asoc_queue */ + while ((rtw_end_of_queue_search(phead, plist)) == false) { + psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); + + plist = get_next(plist); + + if (psta->is_p2p_device && (psta->dev_cap&P2P_DEVCAP_CLIENT_DISCOVERABILITY) && + _rtw_memcmp(psta->dev_addr, dev_addr, ETH_ALEN)) { + /* issue GO Discoverability Request */ + issue_group_disc_req(pwdinfo, psta->hwaddr); + status = P2P_STATUS_SUCCESS; + break; + } else { + status = P2P_STATUS_FAIL_INFO_UNAVAILABLE; + } + } + _exit_critical_bh(&pstapriv->asoc_list_lock, &irqL); + } else { + status = P2P_STATUS_FAIL_INVALID_PARAM; + } + } else { + status = P2P_STATUS_FAIL_INVALID_PARAM; + } + } + } + + + /* issue Device Discoverability Response */ + issue_p2p_devdisc_resp(pwdinfo, GetAddr2Ptr(pframe), status, dialogToken); + + return (status == P2P_STATUS_SUCCESS) ? true : false; +} + +u32 process_p2p_devdisc_resp(struct wifidirect_info *pwdinfo, u8 *pframe, uint len) +{ + return true; +} + +u8 process_p2p_provdisc_req(struct wifidirect_info *pwdinfo, u8 *pframe, uint len) +{ + u8 *frame_body; + u8 *wpsie; + uint wps_ielen = 0, attr_contentlen = 0; + u16 uconfig_method = 0; + __be16 be_tmp; + + frame_body = (pframe + sizeof(struct rtw_ieee80211_hdr_3addr)); + + wpsie = rtw_get_wps_ie(frame_body + _PUBLIC_ACTION_IE_OFFSET_, len - _PUBLIC_ACTION_IE_OFFSET_, NULL, &wps_ielen); + if (wpsie) { + if (rtw_get_wps_attr_content(wpsie, wps_ielen, WPS_ATTR_CONF_METHOD, (u8 *)&be_tmp, &attr_contentlen)) { + uconfig_method = be16_to_cpu(be_tmp); + switch (uconfig_method) { + case WPS_CM_DISPLYA: + memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "dis", 3); + break; + case WPS_CM_LABEL: + memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "lab", 3); + break; + case WPS_CM_PUSH_BUTTON: + memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "pbc", 3); + break; + case WPS_CM_KEYPAD: + memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "pad", 3); + break; + } + issue_p2p_provision_resp(pwdinfo, GetAddr2Ptr(pframe), frame_body, uconfig_method); + } + } + DBG_88E("[%s] config method = %s\n", __func__, pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req); + return true; +} + +u8 process_p2p_provdisc_resp(struct wifidirect_info *pwdinfo, u8 *pframe) +{ + return true; +} + +static u8 rtw_p2p_get_peer_ch_list(struct wifidirect_info *pwdinfo, u8 *ch_content, u8 ch_cnt, u8 *peer_ch_list) +{ + u8 i = 0, j = 0; + u8 temp = 0; + u8 ch_no = 0; + ch_content += 3; + ch_cnt -= 3; + + while (ch_cnt > 0) { + ch_content += 1; + ch_cnt -= 1; + temp = *ch_content; + for (i = 0 ; i < temp ; i++, j++) + peer_ch_list[j] = *(ch_content + 1 + i); + ch_content += (temp + 1); + ch_cnt -= (temp + 1); + ch_no += temp ; + } + + return ch_no; +} + +static u8 rtw_p2p_ch_inclusion(struct mlme_ext_priv *pmlmeext, u8 *peer_ch_list, u8 peer_ch_num, u8 *ch_list_inclusioned) +{ + int i = 0, j = 0, temp = 0; + u8 ch_no = 0; + + for (i = 0; i < peer_ch_num; i++) { + for (j = temp; j < pmlmeext->max_chan_nums; j++) { + if (*(peer_ch_list + i) == pmlmeext->channel_set[j].ChannelNum) { + ch_list_inclusioned[ch_no++] = *(peer_ch_list + i); + temp = j; + break; + } + } + } + + return ch_no; +} + +u8 process_p2p_group_negotation_req(struct wifidirect_info *pwdinfo, u8 *pframe, uint len) +{ + struct adapter *padapter = pwdinfo->padapter; + u8 result = P2P_STATUS_SUCCESS; + u32 p2p_ielen = 0, wps_ielen = 0; + u8 *ies; + u32 ies_len; + u8 *p2p_ie; + u8 *wpsie; + u16 wps_devicepassword_id = 0x0000; + uint wps_devicepassword_id_len = 0; + __be16 be_tmp; + + wpsie = rtw_get_wps_ie(pframe + _PUBLIC_ACTION_IE_OFFSET_, len - _PUBLIC_ACTION_IE_OFFSET_, NULL, &wps_ielen); + if (wpsie) { + /* Commented by Kurt 20120113 */ + /* If some device wants to do p2p handshake without sending prov_disc_req */ + /* We have to get peer_req_cm from here. */ + if (_rtw_memcmp(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "000", 3)) { + rtw_get_wps_attr_content(wpsie, wps_ielen, WPS_ATTR_DEVICE_PWID, (u8 *)&be_tmp, &wps_devicepassword_id_len); + wps_devicepassword_id = be16_to_cpu(be_tmp); + + if (wps_devicepassword_id == WPS_DPID_USER_SPEC) + memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "dis", 3); + else if (wps_devicepassword_id == WPS_DPID_REGISTRAR_SPEC) + memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "pad", 3); + else + memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "pbc", 3); + } + } else { + DBG_88E("[%s] WPS IE not Found!!\n", __func__); + result = P2P_STATUS_FAIL_INCOMPATIBLE_PARAM; + rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL); + return result; + } + + if (pwdinfo->ui_got_wps_info == P2P_NO_WPSINFO) { + result = P2P_STATUS_FAIL_INFO_UNAVAILABLE; + rtw_p2p_set_state(pwdinfo, P2P_STATE_TX_INFOR_NOREADY); + return result; + } + + ies = pframe + _PUBLIC_ACTION_IE_OFFSET_; + ies_len = len - _PUBLIC_ACTION_IE_OFFSET_; + + p2p_ie = rtw_get_p2p_ie(ies, ies_len, NULL, &p2p_ielen); + + if (!p2p_ie) { + DBG_88E("[%s] P2P IE not Found!!\n", __func__); + result = P2P_STATUS_FAIL_INCOMPATIBLE_PARAM; + rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL); + } + + while (p2p_ie) { + u8 attr_content = 0x00; + u32 attr_contentlen = 0; + u8 ch_content[50] = { 0x00 }; + uint ch_cnt = 0; + u8 peer_ch_list[50] = { 0x00 }; + u8 peer_ch_num = 0; + u8 ch_list_inclusioned[50] = { 0x00 }; + u8 ch_num_inclusioned = 0; + + rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_ING); + + if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_GO_INTENT , &attr_content, &attr_contentlen)) { + DBG_88E("[%s] GO Intent = %d, tie = %d\n", __func__, attr_content >> 1, attr_content & 0x01); + pwdinfo->peer_intent = attr_content; /* include both intent and tie breaker values. */ + + if (pwdinfo->intent == (pwdinfo->peer_intent >> 1)) { + /* Try to match the tie breaker value */ + if (pwdinfo->intent == P2P_MAX_INTENT) { + rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); + result = P2P_STATUS_FAIL_BOTH_GOINTENT_15; + } else { + if (attr_content & 0x01) + rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); + else + rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); + } + } else if (pwdinfo->intent > (pwdinfo->peer_intent >> 1)) { + rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); + } else { + rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); + } + + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { + /* Store the group id information. */ + memcpy(pwdinfo->groupid_info.go_device_addr, pwdinfo->device_addr, ETH_ALEN); + memcpy(pwdinfo->groupid_info.ssid, pwdinfo->nego_ssid, pwdinfo->nego_ssidlen); + } + } + + + attr_contentlen = 0; + if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_INTENTED_IF_ADDR, pwdinfo->p2p_peer_interface_addr, &attr_contentlen)) { + if (attr_contentlen != ETH_ALEN) + _rtw_memset(pwdinfo->p2p_peer_interface_addr, 0x00, ETH_ALEN); + } + + if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_CH_LIST, ch_content, &ch_cnt)) { + peer_ch_num = rtw_p2p_get_peer_ch_list(pwdinfo, ch_content, ch_cnt, peer_ch_list); + ch_num_inclusioned = rtw_p2p_ch_inclusion(&padapter->mlmeextpriv, peer_ch_list, peer_ch_num, ch_list_inclusioned); + + if (ch_num_inclusioned == 0) { + DBG_88E("[%s] No common channel in channel list!\n", __func__); + result = P2P_STATUS_FAIL_NO_COMMON_CH; + rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL); + break; + } + + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { + if (!rtw_p2p_is_channel_list_ok(pwdinfo->operating_channel, + ch_list_inclusioned, ch_num_inclusioned)) { + u8 operatingch_info[5] = { 0x00 }, peer_operating_ch = 0; + attr_contentlen = 0; + + if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_OPERATING_CH, operatingch_info, &attr_contentlen)) + peer_operating_ch = operatingch_info[4]; + + if (rtw_p2p_is_channel_list_ok(peer_operating_ch, + ch_list_inclusioned, ch_num_inclusioned)) { + /** + * Change our operating channel as peer's for compatibility. + */ + pwdinfo->operating_channel = peer_operating_ch; + DBG_88E("[%s] Change op ch to %02x as peer's\n", __func__, pwdinfo->operating_channel); + } else { + /* Take first channel of ch_list_inclusioned as operating channel */ + pwdinfo->operating_channel = ch_list_inclusioned[0]; + DBG_88E("[%s] Change op ch to %02x\n", __func__, pwdinfo->operating_channel); + } + } + } + } + + /* Get the next P2P IE */ + p2p_ie = rtw_get_p2p_ie(p2p_ie+p2p_ielen, ies_len - (p2p_ie - ies + p2p_ielen), NULL, &p2p_ielen); + } + return result; +} + +u8 process_p2p_group_negotation_resp(struct wifidirect_info *pwdinfo, u8 *pframe, uint len) +{ + struct adapter *padapter = pwdinfo->padapter; + u8 result = P2P_STATUS_SUCCESS; + u32 p2p_ielen, wps_ielen; + u8 *ies; + u32 ies_len; + u8 *p2p_ie; + + ies = pframe + _PUBLIC_ACTION_IE_OFFSET_; + ies_len = len - _PUBLIC_ACTION_IE_OFFSET_; + + /* Be able to know which one is the P2P GO and which one is P2P client. */ + + if (rtw_get_wps_ie(ies, ies_len, NULL, &wps_ielen)) { + } else { + DBG_88E("[%s] WPS IE not Found!!\n", __func__); + result = P2P_STATUS_FAIL_INCOMPATIBLE_PARAM; + rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL); + } + + p2p_ie = rtw_get_p2p_ie(ies, ies_len, NULL, &p2p_ielen); + if (!p2p_ie) { + rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); + rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL); + result = P2P_STATUS_FAIL_INCOMPATIBLE_PARAM; + } else { + u8 attr_content = 0x00; + u32 attr_contentlen = 0; + u8 operatingch_info[5] = { 0x00 }; + u8 groupid[38]; + u8 peer_ch_list[50] = { 0x00 }; + u8 peer_ch_num = 0; + u8 ch_list_inclusioned[50] = { 0x00 }; + u8 ch_num_inclusioned = 0; + + while (p2p_ie) { /* Found the P2P IE. */ + rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_STATUS, &attr_content, &attr_contentlen); + if (attr_contentlen == 1) { + DBG_88E("[%s] Status = %d\n", __func__, attr_content); + if (attr_content == P2P_STATUS_SUCCESS) { + /* Do nothing. */ + } else { + if (P2P_STATUS_FAIL_INFO_UNAVAILABLE == attr_content) { + rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_INFOR_NOREADY); + } else { + rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL); + } + rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); + result = attr_content; + break; + } + } + + /* Try to get the peer's interface address */ + attr_contentlen = 0; + if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_INTENTED_IF_ADDR, pwdinfo->p2p_peer_interface_addr, &attr_contentlen)) { + if (attr_contentlen != ETH_ALEN) + _rtw_memset(pwdinfo->p2p_peer_interface_addr, 0x00, ETH_ALEN); + } + + /* Try to get the peer's intent and tie breaker value. */ + attr_content = 0x00; + attr_contentlen = 0; + if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_GO_INTENT , &attr_content, &attr_contentlen)) { + DBG_88E("[%s] GO Intent = %d, tie = %d\n", __func__, attr_content >> 1, attr_content & 0x01); + pwdinfo->peer_intent = attr_content; /* include both intent and tie breaker values. */ + + if (pwdinfo->intent == (pwdinfo->peer_intent >> 1)) { + /* Try to match the tie breaker value */ + if (pwdinfo->intent == P2P_MAX_INTENT) { + rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); + result = P2P_STATUS_FAIL_BOTH_GOINTENT_15; + rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL); + } else { + rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK); + rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_GONEGO_OK); + if (attr_content & 0x01) + rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); + else + rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); + } + } else if (pwdinfo->intent > (pwdinfo->peer_intent >> 1)) { + rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK); + rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_GONEGO_OK); + rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); + } else { + rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK); + rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_GONEGO_OK); + rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); + } + + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { + /* Store the group id information. */ + memcpy(pwdinfo->groupid_info.go_device_addr, pwdinfo->device_addr, ETH_ALEN); + memcpy(pwdinfo->groupid_info.ssid, pwdinfo->nego_ssid, pwdinfo->nego_ssidlen); + } + } + + /* Try to get the operation channel information */ + + attr_contentlen = 0; + if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_OPERATING_CH, operatingch_info, &attr_contentlen)) { + DBG_88E("[%s] Peer's operating channel = %d\n", __func__, operatingch_info[4]); + pwdinfo->peer_operating_ch = operatingch_info[4]; + } + + /* Try to get the channel list information */ + if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_CH_LIST, pwdinfo->channel_list_attr, &pwdinfo->channel_list_attr_len)) { + DBG_88E("[%s] channel list attribute found, len = %d\n", __func__, pwdinfo->channel_list_attr_len); + + peer_ch_num = rtw_p2p_get_peer_ch_list(pwdinfo, pwdinfo->channel_list_attr, pwdinfo->channel_list_attr_len, peer_ch_list); + ch_num_inclusioned = rtw_p2p_ch_inclusion(&padapter->mlmeextpriv, peer_ch_list, peer_ch_num, ch_list_inclusioned); + + if (ch_num_inclusioned == 0) { + DBG_88E("[%s] No common channel in channel list!\n", __func__); + result = P2P_STATUS_FAIL_NO_COMMON_CH; + rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL); + break; + } + + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { + if (!rtw_p2p_is_channel_list_ok(pwdinfo->operating_channel, + ch_list_inclusioned, ch_num_inclusioned)) { + u8 operatingch_info[5] = { 0x00 }, peer_operating_ch = 0; + attr_contentlen = 0; + + if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_OPERATING_CH, operatingch_info, &attr_contentlen)) + peer_operating_ch = operatingch_info[4]; + + if (rtw_p2p_is_channel_list_ok(peer_operating_ch, + ch_list_inclusioned, ch_num_inclusioned)) { + /** + * Change our operating channel as peer's for compatibility. + */ + pwdinfo->operating_channel = peer_operating_ch; + DBG_88E("[%s] Change op ch to %02x as peer's\n", __func__, pwdinfo->operating_channel); + } else { + /* Take first channel of ch_list_inclusioned as operating channel */ + pwdinfo->operating_channel = ch_list_inclusioned[0]; + DBG_88E("[%s] Change op ch to %02x\n", __func__, pwdinfo->operating_channel); + } + } + } + } else { + DBG_88E("[%s] channel list attribute not found!\n", __func__); + } + + /* Try to get the group id information if peer is GO */ + attr_contentlen = 0; + _rtw_memset(groupid, 0x00, 38); + if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_ID, groupid, &attr_contentlen)) { + memcpy(pwdinfo->groupid_info.go_device_addr, &groupid[0], ETH_ALEN); + memcpy(pwdinfo->groupid_info.ssid, &groupid[6], attr_contentlen - ETH_ALEN); + } + + /* Get the next P2P IE */ + p2p_ie = rtw_get_p2p_ie(p2p_ie+p2p_ielen, ies_len - (p2p_ie - ies + p2p_ielen), NULL, &p2p_ielen); + } + } + return result; +} + +u8 process_p2p_group_negotation_confirm(struct wifidirect_info *pwdinfo, u8 *pframe, uint len) +{ + u8 *ies; + u32 ies_len; + u8 *p2p_ie; + u32 p2p_ielen = 0; + u8 result = P2P_STATUS_SUCCESS; + ies = pframe + _PUBLIC_ACTION_IE_OFFSET_; + ies_len = len - _PUBLIC_ACTION_IE_OFFSET_; + + p2p_ie = rtw_get_p2p_ie(ies, ies_len, NULL, &p2p_ielen); + while (p2p_ie) { /* Found the P2P IE. */ + u8 attr_content = 0x00, operatingch_info[5] = { 0x00 }; + u8 groupid[38] = { 0x00 }; + u32 attr_contentlen = 0; + + pwdinfo->negotiation_dialog_token = 1; + rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_STATUS, &attr_content, &attr_contentlen); + if (attr_contentlen == 1) { + DBG_88E("[%s] Status = %d\n", __func__, attr_content); + result = attr_content; + + if (attr_content == P2P_STATUS_SUCCESS) { + u8 bcancelled = 0; + + _cancel_timer(&pwdinfo->restore_p2p_state_timer, &bcancelled); + + /* Commented by Albert 20100911 */ + /* Todo: Need to handle the case which both Intents are the same. */ + rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK); + rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_GONEGO_OK); + if ((pwdinfo->intent) > (pwdinfo->peer_intent >> 1)) { + rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); + } else if ((pwdinfo->intent) < (pwdinfo->peer_intent >> 1)) { + rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); + } else { + /* Have to compare the Tie Breaker */ + if (pwdinfo->peer_intent & 0x01) + rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); + else + rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); + } + } else { + rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); + rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL); + break; + } + } + + /* Try to get the group id information */ + attr_contentlen = 0; + _rtw_memset(groupid, 0x00, 38); + if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_ID, groupid, &attr_contentlen)) { + DBG_88E("[%s] Ssid = %s, ssidlen = %zu\n", __func__, &groupid[ETH_ALEN], strlen(&groupid[ETH_ALEN])); + memcpy(pwdinfo->groupid_info.go_device_addr, &groupid[0], ETH_ALEN); + memcpy(pwdinfo->groupid_info.ssid, &groupid[6], attr_contentlen - ETH_ALEN); + } + + attr_contentlen = 0; + if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_OPERATING_CH, operatingch_info, &attr_contentlen)) { + DBG_88E("[%s] Peer's operating channel = %d\n", __func__, operatingch_info[4]); + pwdinfo->peer_operating_ch = operatingch_info[4]; + } + + /* Get the next P2P IE */ + p2p_ie = rtw_get_p2p_ie(p2p_ie+p2p_ielen, ies_len - (p2p_ie - ies + p2p_ielen), NULL, &p2p_ielen); + } + return result; +} + +u8 process_p2p_presence_req(struct wifidirect_info *pwdinfo, u8 *pframe, uint len) +{ + u8 *frame_body; + u8 dialogToken = 0; + u8 status = P2P_STATUS_SUCCESS; + + frame_body = (unsigned char *)(pframe + sizeof(struct rtw_ieee80211_hdr_3addr)); + + dialogToken = frame_body[6]; + + /* todo: check NoA attribute */ + + issue_p2p_presence_resp(pwdinfo, GetAddr2Ptr(pframe), status, dialogToken); + + return true; +} + +static void find_phase_handler(struct adapter *padapter) +{ + struct wifidirect_info *pwdinfo = &padapter->wdinfo; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct ndis_802_11_ssid ssid; + unsigned long irqL; + +_func_enter_; + + _rtw_memset((unsigned char *)&ssid, 0, sizeof(struct ndis_802_11_ssid)); + memcpy(ssid.Ssid, pwdinfo->p2p_wildcard_ssid, P2P_WILDCARD_SSID_LEN); + ssid.SsidLength = P2P_WILDCARD_SSID_LEN; + + rtw_p2p_set_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH); + + _enter_critical_bh(&pmlmepriv->lock, &irqL); + _exit_critical_bh(&pmlmepriv->lock, &irqL); + + +_func_exit_; +} + +void p2p_concurrent_handler(struct adapter *padapter); + +static void restore_p2p_state_handler(struct adapter *padapter) +{ + struct wifidirect_info *pwdinfo = &padapter->wdinfo; + +_func_enter_; + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_ING) || rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_FAIL)) + rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); + rtw_p2p_set_state(pwdinfo, rtw_p2p_pre_state(pwdinfo)); + + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE)) { + /* In the P2P client mode, the driver should not switch back to its listen channel */ + /* because this P2P client should stay at the operating channel of P2P GO. */ + set_channel_bwmode(padapter, pwdinfo->listen_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); + } +_func_exit_; +} + +static void pre_tx_invitereq_handler(struct adapter *padapter) +{ + struct wifidirect_info *pwdinfo = &padapter->wdinfo; + u8 val8 = 1; +_func_enter_; + + set_channel_bwmode(padapter, pwdinfo->invitereq_info.peer_ch, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); + padapter->HalFunc.SetHwRegHandler(padapter, HW_VAR_MLME_SITESURVEY, (u8 *)(&val8)); + issue_probereq_p2p(padapter, NULL); + _set_timer(&pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT); + +_func_exit_; +} + +static void pre_tx_provdisc_handler(struct adapter *padapter) +{ + struct wifidirect_info *pwdinfo = &padapter->wdinfo; + u8 val8 = 1; +_func_enter_; + + set_channel_bwmode(padapter, pwdinfo->tx_prov_disc_info.peer_channel_num[0], HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); + rtw_hal_set_hwreg(padapter, HW_VAR_MLME_SITESURVEY, (u8 *)(&val8)); + issue_probereq_p2p(padapter, NULL); + _set_timer(&pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT); + +_func_exit_; +} + +static void pre_tx_negoreq_handler(struct adapter *padapter) +{ + struct wifidirect_info *pwdinfo = &padapter->wdinfo; + u8 val8 = 1; +_func_enter_; + + set_channel_bwmode(padapter, pwdinfo->nego_req_info.peer_channel_num[0], HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); + rtw_hal_set_hwreg(padapter, HW_VAR_MLME_SITESURVEY, (u8 *)(&val8)); + issue_probereq_p2p(padapter, NULL); + _set_timer(&pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT); + +_func_exit_; +} + +void p2p_protocol_wk_hdl(struct adapter *padapter, int intCmdType) +{ +_func_enter_; + switch (intCmdType) { + case P2P_FIND_PHASE_WK: + find_phase_handler(padapter); + break; + case P2P_RESTORE_STATE_WK: + restore_p2p_state_handler(padapter); + break; + case P2P_PRE_TX_PROVDISC_PROCESS_WK: + pre_tx_provdisc_handler(padapter); + break; + case P2P_PRE_TX_INVITEREQ_PROCESS_WK: + pre_tx_invitereq_handler(padapter); + break; + case P2P_PRE_TX_NEGOREQ_PROCESS_WK: + pre_tx_negoreq_handler(padapter); + break; + } + +_func_exit_; +} + +void process_p2p_ps_ie(struct adapter *padapter, u8 *IEs, u32 IELength) +{ + u8 *ies; + u32 ies_len; + u8 *p2p_ie; + u32 p2p_ielen = 0; + u8 noa_attr[MAX_P2P_IE_LEN] = { 0x00 };/* NoA length should be n*(13) + 2 */ + u32 attr_contentlen = 0; + + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + u8 find_p2p = false, find_p2p_ps = false; + u8 noa_offset, noa_num, noa_index; + +_func_enter_; + + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) + return; + if (IELength <= _BEACON_IE_OFFSET_) + return; + + ies = IEs + _BEACON_IE_OFFSET_; + ies_len = IELength - _BEACON_IE_OFFSET_; + + p2p_ie = rtw_get_p2p_ie(ies, ies_len, NULL, &p2p_ielen); + + while (p2p_ie) { + find_p2p = true; + /* Get Notice of Absence IE. */ + if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_NOA, noa_attr, &attr_contentlen)) { + find_p2p_ps = true; + noa_index = noa_attr[0]; + + if ((pwdinfo->p2p_ps_mode == P2P_PS_NONE) || + (noa_index != pwdinfo->noa_index)) { /* if index change, driver should reconfigure related setting. */ + pwdinfo->noa_index = noa_index; + pwdinfo->opp_ps = noa_attr[1] >> 7; + pwdinfo->ctwindow = noa_attr[1] & 0x7F; + + noa_offset = 2; + noa_num = 0; + /* NoA length should be n*(13) + 2 */ + if (attr_contentlen > 2) { + while (noa_offset < attr_contentlen) { + /* memcpy(&wifidirect_info->noa_count[noa_num], &noa_attr[noa_offset], 1); */ + pwdinfo->noa_count[noa_num] = noa_attr[noa_offset]; + noa_offset += 1; + + memcpy(&pwdinfo->noa_duration[noa_num], &noa_attr[noa_offset], 4); + noa_offset += 4; + + memcpy(&pwdinfo->noa_interval[noa_num], &noa_attr[noa_offset], 4); + noa_offset += 4; + + memcpy(&pwdinfo->noa_start_time[noa_num], &noa_attr[noa_offset], 4); + noa_offset += 4; + + noa_num++; + } + } + pwdinfo->noa_num = noa_num; + + if (pwdinfo->opp_ps == 1) { + pwdinfo->p2p_ps_mode = P2P_PS_CTWINDOW; + /* driver should wait LPS for entering CTWindow */ + if (padapter->pwrctrlpriv.bFwCurrentInPSMode) + p2p_ps_wk_cmd(padapter, P2P_PS_ENABLE, 1); + } else if (pwdinfo->noa_num > 0) { + pwdinfo->p2p_ps_mode = P2P_PS_NOA; + p2p_ps_wk_cmd(padapter, P2P_PS_ENABLE, 1); + } else if (pwdinfo->p2p_ps_mode > P2P_PS_NONE) { + p2p_ps_wk_cmd(padapter, P2P_PS_DISABLE, 1); + } + } + + break; /* find target, just break. */ + } + + /* Get the next P2P IE */ + p2p_ie = rtw_get_p2p_ie(p2p_ie+p2p_ielen, ies_len - (p2p_ie - ies + p2p_ielen), NULL, &p2p_ielen); + } + + if (find_p2p) { + if ((pwdinfo->p2p_ps_mode > P2P_PS_NONE) && !find_p2p_ps) + p2p_ps_wk_cmd(padapter, P2P_PS_DISABLE, 1); + } + +_func_exit_; +} + +void p2p_ps_wk_hdl(struct adapter *padapter, u8 p2p_ps_state) +{ + struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + +_func_enter_; + + /* Pre action for p2p state */ + switch (p2p_ps_state) { + case P2P_PS_DISABLE: + pwdinfo->p2p_ps_state = p2p_ps_state; + + rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_P2P_PS_OFFLOAD, (u8 *)(&p2p_ps_state)); + + pwdinfo->noa_index = 0; + pwdinfo->ctwindow = 0; + pwdinfo->opp_ps = 0; + pwdinfo->noa_num = 0; + pwdinfo->p2p_ps_mode = P2P_PS_NONE; + if (padapter->pwrctrlpriv.bFwCurrentInPSMode) { + if (pwrpriv->smart_ps == 0) { + pwrpriv->smart_ps = 2; + rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 *)(&(padapter->pwrctrlpriv.pwr_mode))); + } + } + break; + case P2P_PS_ENABLE: + if (pwdinfo->p2p_ps_mode > P2P_PS_NONE) { + pwdinfo->p2p_ps_state = p2p_ps_state; + + if (pwdinfo->ctwindow > 0) { + if (pwrpriv->smart_ps != 0) { + pwrpriv->smart_ps = 0; + DBG_88E("%s(): Enter CTW, change SmartPS\n", __func__); + rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 *)(&(padapter->pwrctrlpriv.pwr_mode))); + } + } + rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_P2P_PS_OFFLOAD, (u8 *)(&p2p_ps_state)); + } + break; + case P2P_PS_SCAN: + case P2P_PS_SCAN_DONE: + case P2P_PS_ALLSTASLEEP: + if (pwdinfo->p2p_ps_mode > P2P_PS_NONE) { + pwdinfo->p2p_ps_state = p2p_ps_state; + rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_P2P_PS_OFFLOAD, (u8 *)(&p2p_ps_state)); + } + break; + default: + break; + } + +_func_exit_; +} + +u8 p2p_ps_wk_cmd(struct adapter *padapter, u8 p2p_ps_state, u8 enqueue) +{ + struct cmd_obj *ph2c; + struct drvextra_cmd_parm *pdrvextra_cmd_parm; + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; + +_func_enter_; + + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) + return res; + + if (enqueue) { + ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + + pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); + if (pdrvextra_cmd_parm == NULL) { + kfree(ph2c); + res = _FAIL; + goto exit; + } + + pdrvextra_cmd_parm->ec_id = P2P_PS_WK_CID; + pdrvextra_cmd_parm->type_size = p2p_ps_state; + pdrvextra_cmd_parm->pbuf = NULL; + + init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra)); + + res = rtw_enqueue_cmd(pcmdpriv, ph2c); + } else { + p2p_ps_wk_hdl(padapter, p2p_ps_state); + } + +exit: + +_func_exit_; + + return res; +} + +static void reset_ch_sitesurvey_timer_process (void *FunctionContext) +{ + struct adapter *adapter = (struct adapter *)FunctionContext; + struct wifidirect_info *pwdinfo = &adapter->wdinfo; + + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) + return; + + DBG_88E("[%s] In\n", __func__); + /* Reset the operation channel information */ + pwdinfo->rx_invitereq_info.operation_ch[0] = 0; + pwdinfo->rx_invitereq_info.scan_op_ch_only = 0; +} + +static void reset_ch_sitesurvey_timer_process2 (void *FunctionContext) +{ + struct adapter *adapter = (struct adapter *)FunctionContext; + struct wifidirect_info *pwdinfo = &adapter->wdinfo; + + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) + return; + + DBG_88E("[%s] In\n", __func__); + /* Reset the operation channel information */ + pwdinfo->p2p_info.operation_ch[0] = 0; + pwdinfo->p2p_info.scan_op_ch_only = 0; +} + +static void restore_p2p_state_timer_process (void *FunctionContext) +{ + struct adapter *adapter = (struct adapter *)FunctionContext; + struct wifidirect_info *pwdinfo = &adapter->wdinfo; + + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) + return; + + p2p_protocol_wk_cmd(adapter, P2P_RESTORE_STATE_WK); +} + +static void pre_tx_scan_timer_process(void *FunctionContext) +{ + struct adapter *adapter = (struct adapter *)FunctionContext; + struct wifidirect_info *pwdinfo = &adapter->wdinfo; + unsigned long irqL; + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) + return; + + _enter_critical_bh(&pmlmepriv->lock, &irqL); + + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_TX_PROVISION_DIS_REQ)) { + if (pwdinfo->tx_prov_disc_info.benable) { /* the provision discovery request frame is trigger to send or not */ + p2p_protocol_wk_cmd(adapter, P2P_PRE_TX_PROVDISC_PROCESS_WK); + /* issue_probereq_p2p(adapter, NULL); */ + /* _set_timer(&pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT); */ + } + } else if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_ING)) { + if (pwdinfo->nego_req_info.benable) + p2p_protocol_wk_cmd(adapter, P2P_PRE_TX_NEGOREQ_PROCESS_WK); + } else if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_TX_INVITE_REQ)) { + if (pwdinfo->invitereq_info.benable) + p2p_protocol_wk_cmd(adapter, P2P_PRE_TX_INVITEREQ_PROCESS_WK); + } else { + DBG_88E("[%s] p2p_state is %d, ignore!!\n", __func__, rtw_p2p_state(pwdinfo)); + } + + _exit_critical_bh(&pmlmepriv->lock, &irqL); +} + +static void find_phase_timer_process(void *FunctionContext) +{ + struct adapter *adapter = (struct adapter *)FunctionContext; + struct wifidirect_info *pwdinfo = &adapter->wdinfo; + + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) + return; + + adapter->wdinfo.find_phase_state_exchange_cnt++; + + p2p_protocol_wk_cmd(adapter, P2P_FIND_PHASE_WK); +} + +void reset_global_wifidirect_info(struct adapter *padapter) +{ + struct wifidirect_info *pwdinfo; + + pwdinfo = &padapter->wdinfo; + pwdinfo->persistent_supported = 0; + pwdinfo->session_available = true; + pwdinfo->wfd_tdls_enable = 0; + pwdinfo->wfd_tdls_weaksec = 0; +} + +void rtw_init_wifidirect_timers(struct adapter *padapter) +{ + struct wifidirect_info *pwdinfo = &padapter->wdinfo; + + _init_timer(&pwdinfo->find_phase_timer, padapter->pnetdev, find_phase_timer_process, padapter); + _init_timer(&pwdinfo->restore_p2p_state_timer, padapter->pnetdev, restore_p2p_state_timer_process, padapter); + _init_timer(&pwdinfo->pre_tx_scan_timer, padapter->pnetdev, pre_tx_scan_timer_process, padapter); + _init_timer(&pwdinfo->reset_ch_sitesurvey, padapter->pnetdev, reset_ch_sitesurvey_timer_process, padapter); + _init_timer(&pwdinfo->reset_ch_sitesurvey2, padapter->pnetdev, reset_ch_sitesurvey_timer_process2, padapter); +} + +void rtw_init_wifidirect_addrs(struct adapter *padapter, u8 *dev_addr, u8 *iface_addr) +{ +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &padapter->wdinfo; + + /*init device&interface address */ + if (dev_addr) + memcpy(pwdinfo->device_addr, dev_addr, ETH_ALEN); + if (iface_addr) + memcpy(pwdinfo->interface_addr, iface_addr, ETH_ALEN); +#endif +} + +void init_wifidirect_info(struct adapter *padapter, enum P2P_ROLE role) +{ + struct wifidirect_info *pwdinfo; + + pwdinfo = &padapter->wdinfo; + pwdinfo->padapter = padapter; + + /* 1, 6, 11 are the social channel defined in the WiFi Direct specification. */ + pwdinfo->social_chan[0] = 1; + pwdinfo->social_chan[1] = 6; + pwdinfo->social_chan[2] = 11; + pwdinfo->social_chan[3] = 0; /* channel 0 for scanning ending in site survey function. */ + + /* Use the channel 11 as the listen channel */ + pwdinfo->listen_channel = 11; + + if (role == P2P_ROLE_DEVICE) { + rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); + rtw_p2p_set_state(pwdinfo, P2P_STATE_LISTEN); + pwdinfo->intent = 1; + rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_LISTEN); + } else if (role == P2P_ROLE_CLIENT) { + rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); + rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK); + pwdinfo->intent = 1; + rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_GONEGO_OK); + } else if (role == P2P_ROLE_GO) { + rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); + rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK); + pwdinfo->intent = 15; + rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_GONEGO_OK); + } + +/* Use the OFDM rate in the P2P probe response frame. (6(B), 9(B), 12, 18, 24, 36, 48, 54) */ + pwdinfo->support_rate[0] = 0x8c; /* 6(B) */ + pwdinfo->support_rate[1] = 0x92; /* 9(B) */ + pwdinfo->support_rate[2] = 0x18; /* 12 */ + pwdinfo->support_rate[3] = 0x24; /* 18 */ + pwdinfo->support_rate[4] = 0x30; /* 24 */ + pwdinfo->support_rate[5] = 0x48; /* 36 */ + pwdinfo->support_rate[6] = 0x60; /* 48 */ + pwdinfo->support_rate[7] = 0x6c; /* 54 */ + + memcpy(pwdinfo->p2p_wildcard_ssid, "DIRECT-", 7); + + _rtw_memset(pwdinfo->device_name, 0x00, WPS_MAX_DEVICE_NAME_LEN); + pwdinfo->device_name_len = 0; + + _rtw_memset(&pwdinfo->invitereq_info, 0x00, sizeof(struct tx_invite_req_info)); + pwdinfo->invitereq_info.token = 3; /* Token used for P2P invitation request frame. */ + + _rtw_memset(&pwdinfo->inviteresp_info, 0x00, sizeof(struct tx_invite_resp_info)); + pwdinfo->inviteresp_info.token = 0; + + pwdinfo->profileindex = 0; + _rtw_memset(&pwdinfo->profileinfo[0], 0x00, sizeof(struct profile_info) * P2P_MAX_PERSISTENT_GROUP_NUM); + + rtw_p2p_findphase_ex_set(pwdinfo, P2P_FINDPHASE_EX_NONE); + + pwdinfo->listen_dwell = (u8) ((rtw_get_current_time() % 3) + 1); + + _rtw_memset(&pwdinfo->tx_prov_disc_info, 0x00, sizeof(struct tx_provdisc_req_info)); + pwdinfo->tx_prov_disc_info.wps_config_method_request = WPS_CM_NONE; + + _rtw_memset(&pwdinfo->nego_req_info, 0x00, sizeof(struct tx_nego_req_info)); + + pwdinfo->device_password_id_for_nego = WPS_DPID_PBC; + pwdinfo->negotiation_dialog_token = 1; + + _rtw_memset(pwdinfo->nego_ssid, 0x00, WLAN_SSID_MAXLEN); + pwdinfo->nego_ssidlen = 0; + + pwdinfo->ui_got_wps_info = P2P_NO_WPSINFO; + pwdinfo->supported_wps_cm = WPS_CONFIG_METHOD_DISPLAY | WPS_CONFIG_METHOD_PBC | WPS_CONFIG_METHOD_KEYPAD; + pwdinfo->channel_list_attr_len = 0; + _rtw_memset(pwdinfo->channel_list_attr, 0x00, 100); + + _rtw_memset(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, 0x00, 4); + _rtw_memset(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, '0', 3); + _rtw_memset(&pwdinfo->groupid_info, 0x00, sizeof(struct group_id_info)); + pwdinfo->wfd_tdls_enable = 0; + _rtw_memset(pwdinfo->p2p_peer_interface_addr, 0x00, ETH_ALEN); + _rtw_memset(pwdinfo->p2p_peer_device_addr, 0x00, ETH_ALEN); + + pwdinfo->rx_invitereq_info.operation_ch[0] = 0; + pwdinfo->rx_invitereq_info.operation_ch[1] = 0; /* Used to indicate the scan end in site survey function */ + pwdinfo->rx_invitereq_info.scan_op_ch_only = 0; + pwdinfo->p2p_info.operation_ch[0] = 0; + pwdinfo->p2p_info.operation_ch[1] = 0; /* Used to indicate the scan end in site survey function */ + pwdinfo->p2p_info.scan_op_ch_only = 0; +} + +int rtw_p2p_enable(struct adapter *padapter, enum P2P_ROLE role) +{ + int ret = _SUCCESS; + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + + if (role == P2P_ROLE_DEVICE || role == P2P_ROLE_CLIENT || role == P2P_ROLE_GO) { + /* leave IPS/Autosuspend */ + if (_FAIL == rtw_pwr_wakeup(padapter)) { + ret = _FAIL; + goto exit; + } + + /* Added by Albert 2011/03/22 */ + /* In the P2P mode, the driver should not support the b mode. */ + /* So, the Tx packet shouldn't use the CCK rate */ + update_tx_basic_rate(padapter, WIRELESS_11AGN); + + /* Enable P2P function */ + init_wifidirect_info(padapter, role); + + rtw_hal_set_odm_var(padapter, HAL_ODM_P2P_STATE, NULL, true); + } else if (role == P2P_ROLE_DISABLE) { + if (_FAIL == rtw_pwr_wakeup(padapter)) { + ret = _FAIL; + goto exit; + } + + /* Disable P2P function */ + if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { + _cancel_timer_ex(&pwdinfo->find_phase_timer); + _cancel_timer_ex(&pwdinfo->restore_p2p_state_timer); + _cancel_timer_ex(&pwdinfo->pre_tx_scan_timer); + _cancel_timer_ex(&pwdinfo->reset_ch_sitesurvey); + _cancel_timer_ex(&pwdinfo->reset_ch_sitesurvey2); + reset_ch_sitesurvey_timer_process(padapter); + reset_ch_sitesurvey_timer_process2(padapter); + rtw_p2p_set_state(pwdinfo, P2P_STATE_NONE); + rtw_p2p_set_role(pwdinfo, P2P_ROLE_DISABLE); + _rtw_memset(&pwdinfo->rx_prov_disc_info, 0x00, sizeof(struct rx_provdisc_req_info)); + } + + rtw_hal_set_odm_var(padapter, HAL_ODM_P2P_STATE, NULL, false); + + /* Restore to initial setting. */ + update_tx_basic_rate(padapter, padapter->registrypriv.wireless_mode); + } + +exit: + return ret; +} + +#else +u8 p2p_ps_wk_cmd(struct adapter *padapter, u8 p2p_ps_state, u8 enqueue) +{ + return _FAIL; +} + +void process_p2p_ps_ie(struct adapter *padapter, u8 *IEs, u32 IELength) +{ +} + +#endif /* CONFIG_88EU_P2P */ -- GitLab From 1cc18a22b96b33119f457cac3ce5fcbbcbab1bad Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 21 Aug 2013 22:33:47 -0500 Subject: [PATCH 763/942] staging: r8188eu: Add files for new driver - part 5 This commit adds core/rtw_pwrctrl.c, core/rtw_recv.c, and core/rtw_rf.c Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_pwrctrl.c | 662 +++++ drivers/staging/rtl8188eu/core/rtw_recv.c | 2299 ++++++++++++++++++ drivers/staging/rtl8188eu/core/rtw_rf.c | 89 + 3 files changed, 3050 insertions(+) create mode 100644 drivers/staging/rtl8188eu/core/rtw_pwrctrl.c create mode 100644 drivers/staging/rtl8188eu/core/rtw_recv.c create mode 100644 drivers/staging/rtl8188eu/core/rtw_rf.c diff --git a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c new file mode 100644 index 0000000000000..58a1661f5a847 --- /dev/null +++ b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c @@ -0,0 +1,662 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTW_PWRCTRL_C_ + +#include +#include +#include +#include + +void ips_enter(struct adapter *padapter) +{ + struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; + struct xmit_priv *pxmit_priv = &padapter->xmitpriv; + + if (padapter->registrypriv.mp_mode == 1) + return; + + if (pxmit_priv->free_xmitbuf_cnt != NR_XMITBUFF || + pxmit_priv->free_xmit_extbuf_cnt != NR_XMIT_EXTBUFF) { + DBG_88E_LEVEL(_drv_info_, "There are some pkts to transmit\n"); + DBG_88E_LEVEL(_drv_info_, "free_xmitbuf_cnt: %d, free_xmit_extbuf_cnt: %d\n", + pxmit_priv->free_xmitbuf_cnt, pxmit_priv->free_xmit_extbuf_cnt); + return; + } + + _enter_pwrlock(&pwrpriv->lock); + + pwrpriv->bips_processing = true; + + /* syn ips_mode with request */ + pwrpriv->ips_mode = pwrpriv->ips_mode_req; + + pwrpriv->ips_enter_cnts++; + DBG_88E("==>ips_enter cnts:%d\n", pwrpriv->ips_enter_cnts); + if (rf_off == pwrpriv->change_rfpwrstate) { + pwrpriv->bpower_saving = true; + DBG_88E_LEVEL(_drv_info_, "nolinked power save enter\n"); + + if (pwrpriv->ips_mode == IPS_LEVEL_2) + pwrpriv->bkeepfwalive = true; + + rtw_ips_pwr_down(padapter); + pwrpriv->rf_pwrstate = rf_off; + } + pwrpriv->bips_processing = false; + + _exit_pwrlock(&pwrpriv->lock); +} + +int ips_leave(struct adapter *padapter) +{ + struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; + struct security_priv *psecuritypriv = &(padapter->securitypriv); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + int result = _SUCCESS; + int keyid; + + + _enter_pwrlock(&pwrpriv->lock); + + if ((pwrpriv->rf_pwrstate == rf_off) && (!pwrpriv->bips_processing)) { + pwrpriv->bips_processing = true; + pwrpriv->change_rfpwrstate = rf_on; + pwrpriv->ips_leave_cnts++; + DBG_88E("==>ips_leave cnts:%d\n", pwrpriv->ips_leave_cnts); + + result = rtw_ips_pwr_up(padapter); + if (result == _SUCCESS) { + pwrpriv->rf_pwrstate = rf_on; + } + DBG_88E_LEVEL(_drv_info_, "nolinked power save leave\n"); + + if ((_WEP40_ == psecuritypriv->dot11PrivacyAlgrthm) || (_WEP104_ == psecuritypriv->dot11PrivacyAlgrthm)) { + DBG_88E("==>%s, channel(%d), processing(%x)\n", __func__, padapter->mlmeextpriv.cur_channel, pwrpriv->bips_processing); + set_channel_bwmode(padapter, padapter->mlmeextpriv.cur_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); + for (keyid = 0; keyid < 4; keyid++) { + if (pmlmepriv->key_mask & BIT(keyid)) { + if (keyid == psecuritypriv->dot11PrivacyKeyIndex) + result = rtw_set_key(padapter, psecuritypriv, keyid, 1); + else + result = rtw_set_key(padapter, psecuritypriv, keyid, 0); + } + } + } + + DBG_88E("==> ips_leave.....LED(0x%08x)...\n", rtw_read32(padapter, 0x4c)); + pwrpriv->bips_processing = false; + + pwrpriv->bkeepfwalive = false; + pwrpriv->bpower_saving = false; + } + + _exit_pwrlock(&pwrpriv->lock); + + return result; +} + +static bool rtw_pwr_unassociated_idle(struct adapter *adapter) +{ + struct adapter *buddy = adapter->pbuddy_adapter; + struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &(adapter->wdinfo); +#endif + + bool ret = false; + + if (adapter->pwrctrlpriv.ips_deny_time >= rtw_get_current_time()) + goto exit; + + if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE|WIFI_SITE_MONITOR) || + check_fwstate(pmlmepriv, WIFI_UNDER_LINKING|WIFI_UNDER_WPS) || + check_fwstate(pmlmepriv, WIFI_AP_STATE) || + check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE|WIFI_ADHOC_STATE) || +#if defined(CONFIG_88EU_P2P) + !rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) +#else + 0) +#endif + goto exit; + + /* consider buddy, if exist */ + if (buddy) { + struct mlme_priv *b_pmlmepriv = &(buddy->mlmepriv); + #ifdef CONFIG_88EU_P2P + struct wifidirect_info *b_pwdinfo = &(buddy->wdinfo); + #endif + + if (check_fwstate(b_pmlmepriv, WIFI_ASOC_STATE|WIFI_SITE_MONITOR) || + check_fwstate(b_pmlmepriv, WIFI_UNDER_LINKING|WIFI_UNDER_WPS) || + check_fwstate(b_pmlmepriv, WIFI_AP_STATE) || + check_fwstate(b_pmlmepriv, WIFI_ADHOC_MASTER_STATE|WIFI_ADHOC_STATE) || +#if defined(CONFIG_88EU_P2P) + !rtw_p2p_chk_state(b_pwdinfo, P2P_STATE_NONE)) +#else + 0) +#endif + goto exit; + } + ret = true; + +exit: + return ret; +} + +void rtw_ps_processor(struct adapter *padapter) +{ + struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + enum rt_rf_power_state rfpwrstate; + + pwrpriv->ps_processing = true; + + if (pwrpriv->bips_processing) + goto exit; + + if (padapter->pwrctrlpriv.bHWPwrPindetect) { + rfpwrstate = RfOnOffDetect(padapter); + DBG_88E("@@@@- #2 %s==> rfstate:%s\n", __func__, (rfpwrstate == rf_on) ? "rf_on" : "rf_off"); + + if (rfpwrstate != pwrpriv->rf_pwrstate) { + if (rfpwrstate == rf_off) { + pwrpriv->change_rfpwrstate = rf_off; + pwrpriv->brfoffbyhw = true; + padapter->bCardDisableWOHSM = true; + rtw_hw_suspend(padapter); + } else { + pwrpriv->change_rfpwrstate = rf_on; + rtw_hw_resume(padapter); + } + DBG_88E("current rf_pwrstate(%s)\n", (pwrpriv->rf_pwrstate == rf_off) ? "rf_off" : "rf_on"); + } + pwrpriv->pwr_state_check_cnts++; + } + + if (pwrpriv->ips_mode_req == IPS_NONE) + goto exit; + + if (rtw_pwr_unassociated_idle(padapter) == false) + goto exit; + + if ((pwrpriv->rf_pwrstate == rf_on) && ((pwrpriv->pwr_state_check_cnts%4) == 0)) { + DBG_88E("==>%s .fw_state(%x)\n", __func__, get_fwstate(pmlmepriv)); + pwrpriv->change_rfpwrstate = rf_off; + + ips_enter(padapter); + } +exit: + rtw_set_pwr_state_check_timer(&padapter->pwrctrlpriv); + pwrpriv->ps_processing = false; + return; +} + +static void pwr_state_check_handler(void *FunctionContext) +{ + struct adapter *padapter = (struct adapter *)FunctionContext; + rtw_ps_cmd(padapter); +} + +/* + * + * Parameters + * padapter + * pslv power state level, only could be PS_STATE_S0 ~ PS_STATE_S4 + * + */ +void rtw_set_rpwm(struct adapter *padapter, u8 pslv) +{ + u8 rpwm; + struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; + +_func_enter_; + + pslv = PS_STATE(pslv); + + + if (pwrpriv->btcoex_rfon) { + if (pslv < PS_STATE_S4) + pslv = PS_STATE_S3; + } + + if ((pwrpriv->rpwm == pslv)) { + RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_err_, + ("%s: Already set rpwm[0x%02X], new=0x%02X!\n", __func__, pwrpriv->rpwm, pslv)); + return; + } + + if ((padapter->bSurpriseRemoved) || + (!padapter->hw_init_completed)) { + RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_err_, + ("%s: SurpriseRemoved(%d) hw_init_completed(%d)\n", + __func__, padapter->bSurpriseRemoved, padapter->hw_init_completed)); + + pwrpriv->cpwm = PS_STATE_S4; + + return; + } + + if (padapter->bDriverStopped) { + RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_err_, + ("%s: change power state(0x%02X) when DriverStopped\n", __func__, pslv)); + + if (pslv < PS_STATE_S2) { + RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_err_, + ("%s: Reject to enter PS_STATE(0x%02X) lower than S2 when DriverStopped!!\n", __func__, pslv)); + return; + } + } + + rpwm = pslv | pwrpriv->tog; + RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_, + ("rtw_set_rpwm: rpwm=0x%02x cpwm=0x%02x\n", rpwm, pwrpriv->cpwm)); + + pwrpriv->rpwm = pslv; + + rtw_hal_set_hwreg(padapter, HW_VAR_SET_RPWM, (u8 *)(&rpwm)); + + pwrpriv->tog += 0x80; + pwrpriv->cpwm = pslv; + +_func_exit_; +} + +static u8 PS_RDY_CHECK(struct adapter *padapter) +{ + u32 curr_time, delta_time; + struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + + + curr_time = rtw_get_current_time(); + delta_time = curr_time - pwrpriv->DelayLPSLastTimeStamp; + + if (delta_time < LPS_DELAY_TIME) + return false; + + if ((check_fwstate(pmlmepriv, _FW_LINKED) == false) || + (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) || + (check_fwstate(pmlmepriv, WIFI_AP_STATE)) || + (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) || + (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE))) + return false; + if (pwrpriv->bInSuspend) + return false; + if ((padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) && (padapter->securitypriv.binstallGrpkey == false)) { + DBG_88E("Group handshake still in progress !!!\n"); + return false; + } + return true; +} + +void rtw_set_ps_mode(struct adapter *padapter, u8 ps_mode, u8 smart_ps, u8 bcn_ant_mode) +{ + struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); +#endif /* CONFIG_88EU_P2P */ + +_func_enter_; + + RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_, + ("%s: PowerMode=%d Smart_PS=%d\n", + __func__, ps_mode, smart_ps)); + + if (ps_mode > PM_Card_Disable) { + RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_err_, ("ps_mode:%d error\n", ps_mode)); + return; + } + + if (pwrpriv->pwr_mode == ps_mode) { + if (PS_MODE_ACTIVE == ps_mode) + return; + + if ((pwrpriv->smart_ps == smart_ps) && + (pwrpriv->bcn_ant_mode == bcn_ant_mode)) + return; + } + + /* if (pwrpriv->pwr_mode == PS_MODE_ACTIVE) */ + if (ps_mode == PS_MODE_ACTIVE) { +#ifdef CONFIG_88EU_P2P + if (pwdinfo->opp_ps == 0) { + DBG_88E("rtw_set_ps_mode: Leave 802.11 power save\n"); + pwrpriv->pwr_mode = ps_mode; + rtw_set_rpwm(padapter, PS_STATE_S4); + rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 *)(&ps_mode)); + pwrpriv->bFwCurrentInPSMode = false; + } + } else { +#endif /* CONFIG_88EU_P2P */ + if (PS_RDY_CHECK(padapter)) { + DBG_88E("%s: Enter 802.11 power save\n", __func__); + pwrpriv->bFwCurrentInPSMode = true; + pwrpriv->pwr_mode = ps_mode; + pwrpriv->smart_ps = smart_ps; + pwrpriv->bcn_ant_mode = bcn_ant_mode; + rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 *)(&ps_mode)); + +#ifdef CONFIG_88EU_P2P + /* Set CTWindow after LPS */ + if (pwdinfo->opp_ps == 1) + p2p_ps_wk_cmd(padapter, P2P_PS_ENABLE, 0); +#endif /* CONFIG_88EU_P2P */ + + rtw_set_rpwm(padapter, PS_STATE_S2); + } + } + +_func_exit_; +} + +/* + * Return: + * 0: Leave OK + * -1: Timeout + * -2: Other error + */ +s32 LPS_RF_ON_check(struct adapter *padapter, u32 delay_ms) +{ + u32 start_time; + u8 bAwake = false; + s32 err = 0; + + + start_time = rtw_get_current_time(); + while (1) { + rtw_hal_get_hwreg(padapter, HW_VAR_FWLPS_RF_ON, &bAwake); + if (bAwake) + break; + + if (padapter->bSurpriseRemoved) { + err = -2; + DBG_88E("%s: device surprise removed!!\n", __func__); + break; + } + + if (rtw_get_passing_time_ms(start_time) > delay_ms) { + err = -1; + DBG_88E("%s: Wait for FW LPS leave more than %u ms!!!\n", __func__, delay_ms); + break; + } + rtw_usleep_os(100); + } + + return err; +} + +/* */ +/* Description: */ +/* Enter the leisure power save mode. */ +/* */ +void LPS_Enter(struct adapter *padapter) +{ + struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; + +_func_enter_; + + if (PS_RDY_CHECK(padapter) == false) + return; + + if (pwrpriv->bLeisurePs) { + /* Idle for a while if we connect to AP a while ago. */ + if (pwrpriv->LpsIdleCount >= 2) { /* 4 Sec */ + if (pwrpriv->pwr_mode == PS_MODE_ACTIVE) { + pwrpriv->bpower_saving = true; + DBG_88E("%s smart_ps:%d\n", __func__, pwrpriv->smart_ps); + /* For Tenda W311R IOT issue */ + rtw_set_ps_mode(padapter, pwrpriv->power_mgnt, pwrpriv->smart_ps, 0); + } + } else { + pwrpriv->LpsIdleCount++; + } + } + +_func_exit_; +} + +#define LPS_LEAVE_TIMEOUT_MS 100 + +/* Description: */ +/* Leave the leisure power save mode. */ +void LPS_Leave(struct adapter *padapter) +{ + struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; + +_func_enter_; + + if (pwrpriv->bLeisurePs) { + if (pwrpriv->pwr_mode != PS_MODE_ACTIVE) { + rtw_set_ps_mode(padapter, PS_MODE_ACTIVE, 0, 0); + + if (pwrpriv->pwr_mode == PS_MODE_ACTIVE) + LPS_RF_ON_check(padapter, LPS_LEAVE_TIMEOUT_MS); + } + } + + pwrpriv->bpower_saving = false; + +_func_exit_; +} + +/* */ +/* Description: Leave all power save mode: LPS, FwLPS, IPS if needed. */ +/* Move code to function by tynli. 2010.03.26. */ +/* */ +void LeaveAllPowerSaveMode(struct adapter *Adapter) +{ + struct mlme_priv *pmlmepriv = &(Adapter->mlmepriv); + u8 enqueue = 0; + +_func_enter_; + + if (check_fwstate(pmlmepriv, _FW_LINKED)) { /* connect */ + p2p_ps_wk_cmd(Adapter, P2P_PS_DISABLE, enqueue); + + rtw_lps_ctrl_wk_cmd(Adapter, LPS_CTRL_LEAVE, enqueue); + } + +_func_exit_; +} + +void rtw_init_pwrctrl_priv(struct adapter *padapter) +{ + struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv; + +_func_enter_; + + _init_pwrlock(&pwrctrlpriv->lock); + pwrctrlpriv->rf_pwrstate = rf_on; + pwrctrlpriv->ips_enter_cnts = 0; + pwrctrlpriv->ips_leave_cnts = 0; + pwrctrlpriv->bips_processing = false; + + pwrctrlpriv->ips_mode = padapter->registrypriv.ips_mode; + pwrctrlpriv->ips_mode_req = padapter->registrypriv.ips_mode; + + pwrctrlpriv->pwr_state_check_interval = RTW_PWR_STATE_CHK_INTERVAL; + pwrctrlpriv->pwr_state_check_cnts = 0; + pwrctrlpriv->bInternalAutoSuspend = false; + pwrctrlpriv->bInSuspend = false; + pwrctrlpriv->bkeepfwalive = false; + + pwrctrlpriv->LpsIdleCount = 0; + if (padapter->registrypriv.mp_mode == 1) + pwrctrlpriv->power_mgnt = PS_MODE_ACTIVE ; + else + pwrctrlpriv->power_mgnt = padapter->registrypriv.power_mgnt;/* PS_MODE_MIN; */ + pwrctrlpriv->bLeisurePs = (PS_MODE_ACTIVE != pwrctrlpriv->power_mgnt) ? true : false; + + pwrctrlpriv->bFwCurrentInPSMode = false; + + pwrctrlpriv->rpwm = 0; + pwrctrlpriv->cpwm = PS_STATE_S4; + + pwrctrlpriv->pwr_mode = PS_MODE_ACTIVE; + pwrctrlpriv->smart_ps = padapter->registrypriv.smart_ps; + pwrctrlpriv->bcn_ant_mode = 0; + + pwrctrlpriv->tog = 0x80; + + pwrctrlpriv->btcoex_rfon = false; + + _init_timer(&(pwrctrlpriv->pwr_state_check_timer), padapter->pnetdev, pwr_state_check_handler, (u8 *)padapter); + +_func_exit_; +} + +void rtw_free_pwrctrl_priv(struct adapter *adapter) +{ + struct pwrctrl_priv *pwrctrlpriv = &adapter->pwrctrlpriv; + +_func_enter_; + + _free_pwrlock(&pwrctrlpriv->lock); + +_func_exit_; +} + +u8 rtw_interface_ps_func(struct adapter *padapter, enum hal_intf_ps_func efunc_id, u8 *val) +{ + u8 bResult = true; + rtw_hal_intf_ps_func(padapter, efunc_id, val); + + return bResult; +} + + +inline void rtw_set_ips_deny(struct adapter *padapter, u32 ms) +{ + struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; + pwrpriv->ips_deny_time = rtw_get_current_time() + rtw_ms_to_systime(ms); +} + +/* +* rtw_pwr_wakeup - Wake the NIC up from: 1)IPS. 2)USB autosuspend +* @adapter: pointer to struct adapter structure +* @ips_deffer_ms: the ms wiil prevent from falling into IPS after wakeup +* Return _SUCCESS or _FAIL +*/ + +int _rtw_pwr_wakeup(struct adapter *padapter, u32 ips_deffer_ms, const char *caller) +{ + struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + int ret = _SUCCESS; + + if (pwrpriv->ips_deny_time < rtw_get_current_time() + rtw_ms_to_systime(ips_deffer_ms)) + pwrpriv->ips_deny_time = rtw_get_current_time() + rtw_ms_to_systime(ips_deffer_ms); + +{ + u32 start = rtw_get_current_time(); + if (pwrpriv->ps_processing) { + DBG_88E("%s wait ps_processing...\n", __func__); + while (pwrpriv->ps_processing && rtw_get_passing_time_ms(start) <= 3000) + rtw_msleep_os(10); + if (pwrpriv->ps_processing) + DBG_88E("%s wait ps_processing timeout\n", __func__); + else + DBG_88E("%s wait ps_processing done\n", __func__); + } +} + + /* System suspend is not allowed to wakeup */ + if ((!pwrpriv->bInternalAutoSuspend) && (pwrpriv->bInSuspend)) { + ret = _FAIL; + goto exit; + } + + /* block??? */ + if ((pwrpriv->bInternalAutoSuspend) && (padapter->net_closed)) { + ret = _FAIL; + goto exit; + } + + /* I think this should be check in IPS, LPS, autosuspend functions... */ + if (check_fwstate(pmlmepriv, _FW_LINKED)) { + ret = _SUCCESS; + goto exit; + } + if (rf_off == pwrpriv->rf_pwrstate) { + DBG_88E("%s call ips_leave....\n", __func__); + if (_FAIL == ips_leave(padapter)) { + DBG_88E("======> ips_leave fail.............\n"); + ret = _FAIL; + goto exit; + } + } + + /* TODO: the following checking need to be merged... */ + if (padapter->bDriverStopped || !padapter->bup || + !padapter->hw_init_completed) { + DBG_88E("%s: bDriverStopped=%d, bup=%d, hw_init_completed =%u\n" + , caller + , padapter->bDriverStopped + , padapter->bup + , padapter->hw_init_completed); + ret = false; + goto exit; + } + +exit: + if (pwrpriv->ips_deny_time < rtw_get_current_time() + rtw_ms_to_systime(ips_deffer_ms)) + pwrpriv->ips_deny_time = rtw_get_current_time() + rtw_ms_to_systime(ips_deffer_ms); + return ret; +} + +int rtw_pm_set_lps(struct adapter *padapter, u8 mode) +{ + int ret = 0; + struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv; + + if (mode < PS_MODE_NUM) { + if (pwrctrlpriv->power_mgnt != mode) { + if (PS_MODE_ACTIVE == mode) + LeaveAllPowerSaveMode(padapter); + else + pwrctrlpriv->LpsIdleCount = 2; + pwrctrlpriv->power_mgnt = mode; + pwrctrlpriv->bLeisurePs = (PS_MODE_ACTIVE != pwrctrlpriv->power_mgnt) ? true : false; + } + } else { + ret = -EINVAL; + } + + return ret; +} + +int rtw_pm_set_ips(struct adapter *padapter, u8 mode) +{ + struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv; + + if (mode == IPS_NORMAL || mode == IPS_LEVEL_2) { + rtw_ips_mode_req(pwrctrlpriv, mode); + DBG_88E("%s %s\n", __func__, mode == IPS_NORMAL ? "IPS_NORMAL" : "IPS_LEVEL_2"); + return 0; + } else if (mode == IPS_NONE) { + rtw_ips_mode_req(pwrctrlpriv, mode); + DBG_88E("%s %s\n", __func__, "IPS_NONE"); + if ((padapter->bSurpriseRemoved == 0) && (_FAIL == rtw_pwr_wakeup(padapter))) + return -EFAULT; + } else { + return -EINVAL; + } + return 0; +} diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c new file mode 100644 index 0000000000000..201165787362b --- /dev/null +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -0,0 +1,2299 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTW_RECV_C_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static u8 SNAP_ETH_TYPE_IPX[2] = {0x81, 0x37}; +static u8 SNAP_ETH_TYPE_APPLETALK_AARP[2] = {0x80, 0xf3}; + +/* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */ +static u8 rtw_bridge_tunnel_header[] = { + 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 +}; + +static u8 rtw_rfc1042_header[] = { + 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 +}; + +void rtw_signal_stat_timer_hdl(RTW_TIMER_HDL_ARGS); + +void _rtw_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv) +{ +_func_enter_; + + _rtw_memset((u8 *)psta_recvpriv, 0, sizeof (struct sta_recv_priv)); + + _rtw_spinlock_init(&psta_recvpriv->lock); + + _rtw_init_queue(&psta_recvpriv->defrag_q); + +_func_exit_; +} + +int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter) +{ + int i; + + union recv_frame *precvframe; + + int res = _SUCCESS; + +_func_enter_; + _rtw_spinlock_init(&precvpriv->lock); + + _rtw_init_queue(&precvpriv->free_recv_queue); + _rtw_init_queue(&precvpriv->recv_pending_queue); + _rtw_init_queue(&precvpriv->uc_swdec_pending_queue); + + precvpriv->adapter = padapter; + + precvpriv->free_recvframe_cnt = NR_RECVFRAME; + + rtw_os_recv_resource_init(precvpriv, padapter); + + precvpriv->pallocated_frame_buf = rtw_zvmalloc(NR_RECVFRAME * sizeof(union recv_frame) + RXFRAME_ALIGN_SZ); + + if (precvpriv->pallocated_frame_buf == NULL) { + res = _FAIL; + goto exit; + } + + precvpriv->precv_frame_buf = (u8 *)N_BYTE_ALIGMENT((size_t)(precvpriv->pallocated_frame_buf), RXFRAME_ALIGN_SZ); + + precvframe = (union recv_frame *)precvpriv->precv_frame_buf; + + for (i = 0; i < NR_RECVFRAME; i++) { + _rtw_init_listhead(&(precvframe->u.list)); + + rtw_list_insert_tail(&(precvframe->u.list), &(precvpriv->free_recv_queue.queue)); + + res = rtw_os_recv_resource_alloc(padapter, precvframe); + + precvframe->u.hdr.len = 0; + + precvframe->u.hdr.adapter = padapter; + precvframe++; + } + precvpriv->rx_pending_cnt = 1; + + _rtw_init_sema(&precvpriv->allrxreturnevt, 0); + + res = rtw_hal_init_recv_priv(padapter); + + _init_timer(&precvpriv->signal_stat_timer, padapter->pnetdev, RTW_TIMER_HDL_NAME(signal_stat), padapter); + + precvpriv->signal_stat_sampling_interval = 1000; /* ms */ + + rtw_set_signal_stat_timer(precvpriv); +exit: + +_func_exit_; + + return res; +} + +static void rtw_mfree_recv_priv_lock(struct recv_priv *precvpriv) +{ + _rtw_spinlock_free(&precvpriv->lock); + _rtw_spinlock_free(&precvpriv->free_recv_queue.lock); + _rtw_spinlock_free(&precvpriv->recv_pending_queue.lock); + + _rtw_spinlock_free(&precvpriv->free_recv_buf_queue.lock); +} + +void _rtw_free_recv_priv (struct recv_priv *precvpriv) +{ + struct adapter *padapter = precvpriv->adapter; + +_func_enter_; + + rtw_free_uc_swdec_pending_queue(padapter); + + rtw_mfree_recv_priv_lock(precvpriv); + + rtw_os_recv_resource_free(precvpriv); + + if (precvpriv->pallocated_frame_buf) { + rtw_vmfree(precvpriv->pallocated_frame_buf, NR_RECVFRAME * sizeof(union recv_frame) + RXFRAME_ALIGN_SZ); + } + + rtw_hal_free_recv_priv(padapter); + +_func_exit_; +} + +union recv_frame *_rtw_alloc_recvframe (struct __queue *pfree_recv_queue) +{ + union recv_frame *precvframe; + struct list_head *plist, *phead; + struct adapter *padapter; + struct recv_priv *precvpriv; +_func_enter_; + + if (_rtw_queue_empty(pfree_recv_queue)) { + precvframe = NULL; + } else { + phead = get_list_head(pfree_recv_queue); + + plist = get_next(phead); + + precvframe = LIST_CONTAINOR(plist, union recv_frame, u); + + rtw_list_delete(&precvframe->u.hdr.list); + padapter = precvframe->u.hdr.adapter; + if (padapter != NULL) { + precvpriv = &padapter->recvpriv; + if (pfree_recv_queue == &precvpriv->free_recv_queue) + precvpriv->free_recvframe_cnt--; + } + } + +_func_exit_; + + return precvframe; +} + +union recv_frame *rtw_alloc_recvframe (struct __queue *pfree_recv_queue) +{ + unsigned long irqL; + union recv_frame *precvframe; + + _enter_critical_bh(&pfree_recv_queue->lock, &irqL); + + precvframe = _rtw_alloc_recvframe(pfree_recv_queue); + + _exit_critical_bh(&pfree_recv_queue->lock, &irqL); + + return precvframe; +} + +void rtw_init_recvframe(union recv_frame *precvframe, struct recv_priv *precvpriv) +{ + /* Perry: This can be removed */ + _rtw_init_listhead(&precvframe->u.hdr.list); + + precvframe->u.hdr.len = 0; +} + +int rtw_free_recvframe(union recv_frame *precvframe, struct __queue *pfree_recv_queue) +{ + unsigned long irqL; + struct adapter *padapter = precvframe->u.hdr.adapter; + struct recv_priv *precvpriv = &padapter->recvpriv; + +_func_enter_; + + if (precvframe->u.hdr.pkt) { + dev_kfree_skb_any(precvframe->u.hdr.pkt);/* free skb by driver */ + precvframe->u.hdr.pkt = NULL; + } + + _enter_critical_bh(&pfree_recv_queue->lock, &irqL); + + rtw_list_delete(&(precvframe->u.hdr.list)); + + precvframe->u.hdr.len = 0; + + rtw_list_insert_tail(&(precvframe->u.hdr.list), get_list_head(pfree_recv_queue)); + + if (padapter != NULL) { + if (pfree_recv_queue == &precvpriv->free_recv_queue) + precvpriv->free_recvframe_cnt++; + } + + _exit_critical_bh(&pfree_recv_queue->lock, &irqL); + +_func_exit_; + + return _SUCCESS; +} + +int _rtw_enqueue_recvframe(union recv_frame *precvframe, struct __queue *queue) +{ + struct adapter *padapter = precvframe->u.hdr.adapter; + struct recv_priv *precvpriv = &padapter->recvpriv; + +_func_enter_; + + rtw_list_delete(&(precvframe->u.hdr.list)); + rtw_list_insert_tail(&(precvframe->u.hdr.list), get_list_head(queue)); + + if (padapter != NULL) { + if (queue == &precvpriv->free_recv_queue) + precvpriv->free_recvframe_cnt++; + } + +_func_exit_; + + return _SUCCESS; +} + +int rtw_enqueue_recvframe(union recv_frame *precvframe, struct __queue *queue) +{ + int ret; + unsigned long irqL; + + _enter_critical_bh(&queue->lock, &irqL); + ret = _rtw_enqueue_recvframe(precvframe, queue); + _exit_critical_bh(&queue->lock, &irqL); + + return ret; +} + +/* +caller : defrag ; recvframe_chk_defrag in recv_thread (passive) +pframequeue: defrag_queue : will be accessed in recv_thread (passive) + +using spinlock to protect + +*/ + +void rtw_free_recvframe_queue(struct __queue *pframequeue, struct __queue *pfree_recv_queue) +{ + union recv_frame *precvframe; + struct list_head *plist, *phead; + +_func_enter_; + spin_lock(&pframequeue->lock); + + phead = get_list_head(pframequeue); + plist = get_next(phead); + + while (rtw_end_of_queue_search(phead, plist) == false) { + precvframe = LIST_CONTAINOR(plist, union recv_frame, u); + + plist = get_next(plist); + + rtw_free_recvframe(precvframe, pfree_recv_queue); + } + + spin_unlock(&pframequeue->lock); + +_func_exit_; +} + +u32 rtw_free_uc_swdec_pending_queue(struct adapter *adapter) +{ + u32 cnt = 0; + union recv_frame *pending_frame; + while ((pending_frame = rtw_alloc_recvframe(&adapter->recvpriv.uc_swdec_pending_queue))) { + rtw_free_recvframe(pending_frame, &adapter->recvpriv.free_recv_queue); + DBG_88E("%s: dequeue uc_swdec_pending_queue\n", __func__); + cnt++; + } + + return cnt; +} + +int rtw_enqueue_recvbuf_to_head(struct recv_buf *precvbuf, struct __queue *queue) +{ + unsigned long irqL; + + _enter_critical_bh(&queue->lock, &irqL); + + rtw_list_delete(&precvbuf->list); + rtw_list_insert_head(&precvbuf->list, get_list_head(queue)); + + _exit_critical_bh(&queue->lock, &irqL); + + return _SUCCESS; +} + +int rtw_enqueue_recvbuf(struct recv_buf *precvbuf, struct __queue *queue) +{ + unsigned long irqL; + _enter_critical_ex(&queue->lock, &irqL); + + rtw_list_delete(&precvbuf->list); + + rtw_list_insert_tail(&precvbuf->list, get_list_head(queue)); + _exit_critical_ex(&queue->lock, &irqL); + return _SUCCESS; +} + +struct recv_buf *rtw_dequeue_recvbuf (struct __queue *queue) +{ + unsigned long irqL; + struct recv_buf *precvbuf; + struct list_head *plist, *phead; + + _enter_critical_ex(&queue->lock, &irqL); + + if (_rtw_queue_empty(queue)) { + precvbuf = NULL; + } else { + phead = get_list_head(queue); + + plist = get_next(phead); + + precvbuf = LIST_CONTAINOR(plist, struct recv_buf, list); + + rtw_list_delete(&precvbuf->list); + } + + _exit_critical_ex(&queue->lock, &irqL); + + return precvbuf; +} + +static int recvframe_chkmic(struct adapter *adapter, union recv_frame *precvframe) +{ + int i, res = _SUCCESS; + u32 datalen; + u8 miccode[8]; + u8 bmic_err = false, brpt_micerror = true; + u8 *pframe, *payload, *pframemic; + u8 *mickey; + struct sta_info *stainfo; + struct rx_pkt_attrib *prxattrib = &precvframe->u.hdr.attrib; + struct security_priv *psecuritypriv = &adapter->securitypriv; + + struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); +_func_enter_; + + stainfo = rtw_get_stainfo(&adapter->stapriv, &prxattrib->ta[0]); + + if (prxattrib->encrypt == _TKIP_) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n recvframe_chkmic:prxattrib->encrypt==_TKIP_\n")); + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n recvframe_chkmic:da=0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x\n", + prxattrib->ra[0], prxattrib->ra[1], prxattrib->ra[2], prxattrib->ra[3], prxattrib->ra[4], prxattrib->ra[5])); + + /* calculate mic code */ + if (stainfo != NULL) { + if (IS_MCAST(prxattrib->ra)) { + mickey = &psecuritypriv->dot118021XGrprxmickey[prxattrib->key_index].skey[0]; + + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n recvframe_chkmic: bcmc key\n")); + + if (!psecuritypriv) { + res = _FAIL; + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n recvframe_chkmic:didn't install group key!!!!!!!!!!\n")); + DBG_88E("\n recvframe_chkmic:didn't install group key!!!!!!!!!!\n"); + goto exit; + } + } else { + mickey = &stainfo->dot11tkiprxmickey.skey[0]; + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n recvframe_chkmic: unicast key\n")); + } + + datalen = precvframe->u.hdr.len-prxattrib->hdrlen-prxattrib->iv_len-prxattrib->icv_len-8;/* icv_len included the mic code */ + pframe = precvframe->u.hdr.rx_data; + payload = pframe+prxattrib->hdrlen+prxattrib->iv_len; + + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n prxattrib->iv_len=%d prxattrib->icv_len=%d\n", prxattrib->iv_len, prxattrib->icv_len)); + rtw_seccalctkipmic(mickey, pframe, payload, datalen, &miccode[0], + (unsigned char)prxattrib->priority); /* care the length of the data */ + + pframemic = payload+datalen; + + bmic_err = false; + + for (i = 0; i < 8; i++) { + if (miccode[i] != *(pframemic+i)) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, + ("recvframe_chkmic:miccode[%d](%02x)!=*(pframemic+%d)(%02x) ", + i, miccode[i], i, *(pframemic+i))); + bmic_err = true; + } + } + + if (bmic_err) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, + ("\n *(pframemic-8)-*(pframemic-1)=0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x\n", + *(pframemic-8), *(pframemic-7), *(pframemic-6), + *(pframemic-5), *(pframemic-4), *(pframemic-3), + *(pframemic-2), *(pframemic-1))); + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, + ("\n *(pframemic-16)-*(pframemic-9)=0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x\n", + *(pframemic-16), *(pframemic-15), *(pframemic-14), + *(pframemic-13), *(pframemic-12), *(pframemic-11), + *(pframemic-10), *(pframemic-9))); + { + uint i; + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n ======demp packet (len=%d)======\n", precvframe->u.hdr.len)); + for (i = 0; i < precvframe->u.hdr.len; i = i+8) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x", + *(precvframe->u.hdr.rx_data+i), *(precvframe->u.hdr.rx_data+i+1), + *(precvframe->u.hdr.rx_data+i+2), *(precvframe->u.hdr.rx_data+i+3), + *(precvframe->u.hdr.rx_data+i+4), *(precvframe->u.hdr.rx_data+i+5), + *(precvframe->u.hdr.rx_data+i+6), *(precvframe->u.hdr.rx_data+i+7))); + } + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n ====== demp packet end [len=%d]======\n", precvframe->u.hdr.len)); + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n hrdlen=%d,\n", prxattrib->hdrlen)); + } + + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, + ("ra=0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x psecuritypriv->binstallGrpkey=%d ", + prxattrib->ra[0], prxattrib->ra[1], prxattrib->ra[2], + prxattrib->ra[3], prxattrib->ra[4], prxattrib->ra[5], psecuritypriv->binstallGrpkey)); + + /* double check key_index for some timing issue , */ + /* cannot compare with psecuritypriv->dot118021XGrpKeyid also cause timing issue */ + if ((IS_MCAST(prxattrib->ra) == true) && (prxattrib->key_index != pmlmeinfo->key_index)) + brpt_micerror = false; + + if ((prxattrib->bdecrypted) && (brpt_micerror)) { + rtw_handle_tkip_mic_err(adapter, (u8)IS_MCAST(prxattrib->ra)); + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, (" mic error :prxattrib->bdecrypted=%d ", prxattrib->bdecrypted)); + DBG_88E(" mic error :prxattrib->bdecrypted=%d\n", prxattrib->bdecrypted); + } else { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, (" mic error :prxattrib->bdecrypted=%d ", prxattrib->bdecrypted)); + DBG_88E(" mic error :prxattrib->bdecrypted=%d\n", prxattrib->bdecrypted); + } + res = _FAIL; + } else { + /* mic checked ok */ + if ((!psecuritypriv->bcheck_grpkey) && (IS_MCAST(prxattrib->ra))) { + psecuritypriv->bcheck_grpkey = true; + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("psecuritypriv->bcheck_grpkey = true")); + } + } + } else { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("recvframe_chkmic: rtw_get_stainfo==NULL!!!\n")); + } + + recvframe_pull_tail(precvframe, 8); + } + +exit: + +_func_exit_; + + return res; +} + +/* decrypt and set the ivlen, icvlen of the recv_frame */ +static union recv_frame *decryptor(struct adapter *padapter, union recv_frame *precv_frame) +{ + struct rx_pkt_attrib *prxattrib = &precv_frame->u.hdr.attrib; + struct security_priv *psecuritypriv = &padapter->securitypriv; + union recv_frame *return_packet = precv_frame; + u32 res = _SUCCESS; +_func_enter_; + + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("prxstat->decrypted=%x prxattrib->encrypt=0x%03x\n", prxattrib->bdecrypted, prxattrib->encrypt)); + + if (prxattrib->encrypt > 0) { + u8 *iv = precv_frame->u.hdr.rx_data+prxattrib->hdrlen; + prxattrib->key_index = (((iv[3])>>6)&0x3); + + if (prxattrib->key_index > WEP_KEYS) { + DBG_88E("prxattrib->key_index(%d)>WEP_KEYS\n", prxattrib->key_index); + + switch (prxattrib->encrypt) { + case _WEP40_: + case _WEP104_: + prxattrib->key_index = psecuritypriv->dot11PrivacyKeyIndex; + break; + case _TKIP_: + case _AES_: + default: + prxattrib->key_index = psecuritypriv->dot118021XGrpKeyid; + break; + } + } + } + + if ((prxattrib->encrypt > 0) && ((prxattrib->bdecrypted == 0) || (psecuritypriv->sw_decrypt))) { + psecuritypriv->hw_decrypted = false; + + switch (prxattrib->encrypt) { + case _WEP40_: + case _WEP104_: + rtw_wep_decrypt(padapter, (u8 *)precv_frame); + break; + case _TKIP_: + res = rtw_tkip_decrypt(padapter, (u8 *)precv_frame); + break; + case _AES_: + res = rtw_aes_decrypt(padapter, (u8 *)precv_frame); + break; + default: + break; + } + } else if (prxattrib->bdecrypted == 1 && prxattrib->encrypt > 0 && + (psecuritypriv->busetkipkey == 1 || prxattrib->encrypt != _TKIP_)) + psecuritypriv->hw_decrypted = true; + + if (res == _FAIL) { + rtw_free_recvframe(return_packet, &padapter->recvpriv.free_recv_queue); + return_packet = NULL; + } + +_func_exit_; + + return return_packet; +} + +/* set the security information in the recv_frame */ +static union recv_frame *portctrl(struct adapter *adapter, union recv_frame *precv_frame) +{ + u8 *psta_addr = NULL, *ptr; + uint auth_alg; + struct recv_frame_hdr *pfhdr; + struct sta_info *psta; + struct sta_priv *pstapriv; + union recv_frame *prtnframe; + u16 ether_type = 0; + u16 eapol_type = 0x888e;/* for Funia BD's WPA issue */ + struct rx_pkt_attrib *pattrib; + __be16 be_tmp; + +_func_enter_; + + pstapriv = &adapter->stapriv; + psta = rtw_get_stainfo(pstapriv, psta_addr); + + auth_alg = adapter->securitypriv.dot11AuthAlgrthm; + + ptr = get_recvframe_data(precv_frame); + pfhdr = &precv_frame->u.hdr; + pattrib = &pfhdr->attrib; + psta_addr = pattrib->ta; + + prtnframe = NULL; + + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("########portctrl:adapter->securitypriv.dot11AuthAlgrthm=%d\n", adapter->securitypriv.dot11AuthAlgrthm)); + + if (auth_alg == 2) { + if ((psta != NULL) && (psta->ieee8021x_blocked)) { + /* blocked */ + /* only accept EAPOL frame */ + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("########portctrl:psta->ieee8021x_blocked==1\n")); + + prtnframe = precv_frame; + + /* get ether_type */ + ptr = ptr+pfhdr->attrib.hdrlen+pfhdr->attrib.iv_len+LLC_HEADER_SIZE; + memcpy(&be_tmp, ptr, 2); + ether_type = ntohs(be_tmp); + + if (ether_type == eapol_type) { + prtnframe = precv_frame; + } else { + /* free this frame */ + rtw_free_recvframe(precv_frame, &adapter->recvpriv.free_recv_queue); + prtnframe = NULL; + } + } else { + /* allowed */ + /* check decryption status, and decrypt the frame if needed */ + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("########portctrl:psta->ieee8021x_blocked==0\n")); + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("portctrl:precv_frame->hdr.attrib.privacy=%x\n", precv_frame->u.hdr.attrib.privacy)); + + if (pattrib->bdecrypted == 0) + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("portctrl:prxstat->decrypted=%x\n", pattrib->bdecrypted)); + + prtnframe = precv_frame; + /* check is the EAPOL frame or not (Rekey) */ + if (ether_type == eapol_type) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("########portctrl:ether_type==0x888e\n")); + /* check Rekey */ + + prtnframe = precv_frame; + } else { + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("########portctrl:ether_type=0x%04x\n", ether_type)); + } + } + } else { + prtnframe = precv_frame; + } + +_func_exit_; + + return prtnframe; +} + +static int recv_decache(union recv_frame *precv_frame, u8 bretry, struct stainfo_rxcache *prxcache) +{ + int tid = precv_frame->u.hdr.attrib.priority; + + u16 seq_ctrl = ((precv_frame->u.hdr.attrib.seq_num&0xffff) << 4) | + (precv_frame->u.hdr.attrib.frag_num & 0xf); + +_func_enter_; + + if (tid > 15) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("recv_decache, (tid>15)! seq_ctrl=0x%x, tid=0x%x\n", seq_ctrl, tid)); + + return _FAIL; + } + + if (1) {/* if (bretry) */ + if (seq_ctrl == prxcache->tid_rxseq[tid]) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("recv_decache, seq_ctrl=0x%x, tid=0x%x, tid_rxseq=0x%x\n", seq_ctrl, tid, prxcache->tid_rxseq[tid])); + + return _FAIL; + } + } + + prxcache->tid_rxseq[tid] = seq_ctrl; + +_func_exit_; + + return _SUCCESS; +} + +void process_pwrbit_data(struct adapter *padapter, union recv_frame *precv_frame); +void process_pwrbit_data(struct adapter *padapter, union recv_frame *precv_frame) +{ +#ifdef CONFIG_88EU_AP_MODE + unsigned char pwrbit; + u8 *ptr = precv_frame->u.hdr.rx_data; + struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib; + struct sta_priv *pstapriv = &padapter->stapriv; + struct sta_info *psta = NULL; + + psta = rtw_get_stainfo(pstapriv, pattrib->src); + + pwrbit = GetPwrMgt(ptr); + + if (psta) { + if (pwrbit) { + if (!(psta->state & WIFI_SLEEP_STATE)) + stop_sta_xmit(padapter, psta); + } else { + if (psta->state & WIFI_SLEEP_STATE) + wakeup_sta_to_xmit(padapter, psta); + } + } + +#endif +} + +static void process_wmmps_data(struct adapter *padapter, union recv_frame *precv_frame) +{ +#ifdef CONFIG_88EU_AP_MODE + struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib; + struct sta_priv *pstapriv = &padapter->stapriv; + struct sta_info *psta = NULL; + + psta = rtw_get_stainfo(pstapriv, pattrib->src); + + if (!psta) + return; + + if (!psta->qos_option) + return; + + if (!(psta->qos_info&0xf)) + return; + + if (psta->state&WIFI_SLEEP_STATE) { + u8 wmmps_ac = 0; + + switch (pattrib->priority) { + case 1: + case 2: + wmmps_ac = psta->uapsd_bk&BIT(1); + break; + case 4: + case 5: + wmmps_ac = psta->uapsd_vi&BIT(1); + break; + case 6: + case 7: + wmmps_ac = psta->uapsd_vo&BIT(1); + break; + case 0: + case 3: + default: + wmmps_ac = psta->uapsd_be&BIT(1); + break; + } + + if (wmmps_ac) { + if (psta->sleepq_ac_len > 0) { + /* process received triggered frame */ + xmit_delivery_enabled_frames(padapter, psta); + } else { + /* issue one qos null frame with More data bit = 0 and the EOSP bit set (= 1) */ + issue_qos_nulldata(padapter, psta->hwaddr, (u16)pattrib->priority, 0, 0); + } + } + } + +#endif +} + +static void count_rx_stats(struct adapter *padapter, union recv_frame *prframe, struct sta_info *sta) +{ + int sz; + struct sta_info *psta = NULL; + struct stainfo_stats *pstats = NULL; + struct rx_pkt_attrib *pattrib = &prframe->u.hdr.attrib; + struct recv_priv *precvpriv = &padapter->recvpriv; + + sz = get_recvframe_len(prframe); + precvpriv->rx_bytes += sz; + + padapter->mlmepriv.LinkDetectInfo.NumRxOkInPeriod++; + + if ((!MacAddr_isBcst(pattrib->dst)) && (!IS_MCAST(pattrib->dst))) + padapter->mlmepriv.LinkDetectInfo.NumRxUnicastOkInPeriod++; + + if (sta) + psta = sta; + else + psta = prframe->u.hdr.psta; + + if (psta) { + pstats = &psta->sta_stats; + + pstats->rx_data_pkts++; + pstats->rx_bytes += sz; + } +} + +int sta2sta_data_frame( + struct adapter *adapter, + union recv_frame *precv_frame, + struct sta_info **psta +); + +int sta2sta_data_frame(struct adapter *adapter, union recv_frame *precv_frame, struct sta_info **psta) +{ + u8 *ptr = precv_frame->u.hdr.rx_data; + int ret = _SUCCESS; + struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib; + struct sta_priv *pstapriv = &adapter->stapriv; + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + u8 *mybssid = get_bssid(pmlmepriv); + u8 *myhwaddr = myid(&adapter->eeprompriv); + u8 *sta_addr = NULL; + int bmcast = IS_MCAST(pattrib->dst); + +_func_enter_; + + if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) || + (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) { + /* filter packets that SA is myself or multicast or broadcast */ + if (_rtw_memcmp(myhwaddr, pattrib->src, ETH_ALEN)) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, (" SA==myself\n")); + ret = _FAIL; + goto exit; + } + + if ((!_rtw_memcmp(myhwaddr, pattrib->dst, ETH_ALEN)) && (!bmcast)) { + ret = _FAIL; + goto exit; + } + + if (_rtw_memcmp(pattrib->bssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) || + _rtw_memcmp(mybssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) || + !_rtw_memcmp(pattrib->bssid, mybssid, ETH_ALEN)) { + ret = _FAIL; + goto exit; + } + + sta_addr = pattrib->src; + } else if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { + /* For Station mode, sa and bssid should always be BSSID, and DA is my mac-address */ + if (!_rtw_memcmp(pattrib->bssid, pattrib->src, ETH_ALEN)) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("bssid!=TA under STATION_MODE; drop pkt\n")); + ret = _FAIL; + goto exit; + } + sta_addr = pattrib->bssid; + } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { + if (bmcast) { + /* For AP mode, if DA == MCAST, then BSSID should be also MCAST */ + if (!IS_MCAST(pattrib->bssid)) { + ret = _FAIL; + goto exit; + } + } else { /* not mc-frame */ + /* For AP mode, if DA is non-MCAST, then it must be BSSID, and bssid == BSSID */ + if (!_rtw_memcmp(pattrib->bssid, pattrib->dst, ETH_ALEN)) { + ret = _FAIL; + goto exit; + } + + sta_addr = pattrib->src; + } + } else if (check_fwstate(pmlmepriv, WIFI_MP_STATE)) { + memcpy(pattrib->dst, GetAddr1Ptr(ptr), ETH_ALEN); + memcpy(pattrib->src, GetAddr2Ptr(ptr), ETH_ALEN); + memcpy(pattrib->bssid, GetAddr3Ptr(ptr), ETH_ALEN); + memcpy(pattrib->ra, pattrib->dst, ETH_ALEN); + memcpy(pattrib->ta, pattrib->src, ETH_ALEN); + + sta_addr = mybssid; + } else { + ret = _FAIL; + } + + if (bmcast) + *psta = rtw_get_bcmc_stainfo(adapter); + else + *psta = rtw_get_stainfo(pstapriv, sta_addr); /* get ap_info */ + + if (*psta == NULL) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("can't get psta under sta2sta_data_frame ; drop pkt\n")); + if (adapter->registrypriv.mp_mode == 1) { + if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) + adapter->mppriv.rx_pktloss++; + } + ret = _FAIL; + goto exit; + } + +exit: +_func_exit_; + return ret; +} + +static int ap2sta_data_frame ( + struct adapter *adapter, + union recv_frame *precv_frame, + struct sta_info **psta) +{ + u8 *ptr = precv_frame->u.hdr.rx_data; + struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib; + int ret = _SUCCESS; + struct sta_priv *pstapriv = &adapter->stapriv; + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + u8 *mybssid = get_bssid(pmlmepriv); + u8 *myhwaddr = myid(&adapter->eeprompriv); + int bmcast = IS_MCAST(pattrib->dst); + +_func_enter_; + + if ((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) && + (check_fwstate(pmlmepriv, _FW_LINKED) == true || + check_fwstate(pmlmepriv, _FW_UNDER_LINKING))) { + /* filter packets that SA is myself or multicast or broadcast */ + if (_rtw_memcmp(myhwaddr, pattrib->src, ETH_ALEN)) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, (" SA==myself\n")); + ret = _FAIL; + goto exit; + } + + /* da should be for me */ + if ((!_rtw_memcmp(myhwaddr, pattrib->dst, ETH_ALEN)) && (!bmcast)) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, + (" ap2sta_data_frame: compare DA fail; DA=%pM\n", (pattrib->dst))); + ret = _FAIL; + goto exit; + } + + /* check BSSID */ + if (_rtw_memcmp(pattrib->bssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) || + _rtw_memcmp(mybssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) || + (!_rtw_memcmp(pattrib->bssid, mybssid, ETH_ALEN))) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, + (" ap2sta_data_frame: compare BSSID fail ; BSSID=%pM\n", (pattrib->bssid))); + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("mybssid=%pM\n", (mybssid))); + + if (!bmcast) { + DBG_88E("issue_deauth to the nonassociated ap=%pM for the reason(7)\n", (pattrib->bssid)); + issue_deauth(adapter, pattrib->bssid, WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA); + } + + ret = _FAIL; + goto exit; + } + + if (bmcast) + *psta = rtw_get_bcmc_stainfo(adapter); + else + *psta = rtw_get_stainfo(pstapriv, pattrib->bssid); /* get ap_info */ + + if (*psta == NULL) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("ap2sta: can't get psta under STATION_MODE ; drop pkt\n")); + ret = _FAIL; + goto exit; + } + + /* if ((GetFrameSubType(ptr) & WIFI_QOS_DATA_TYPE) == WIFI_QOS_DATA_TYPE) { */ + /* */ + + if (GetFrameSubType(ptr) & BIT(6)) { + /* No data, will not indicate to upper layer, temporily count it here */ + count_rx_stats(adapter, precv_frame, *psta); + ret = RTW_RX_HANDLED; + goto exit; + } + } else if ((check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) && + (check_fwstate(pmlmepriv, _FW_LINKED) == true)) { + memcpy(pattrib->dst, GetAddr1Ptr(ptr), ETH_ALEN); + memcpy(pattrib->src, GetAddr2Ptr(ptr), ETH_ALEN); + memcpy(pattrib->bssid, GetAddr3Ptr(ptr), ETH_ALEN); + memcpy(pattrib->ra, pattrib->dst, ETH_ALEN); + memcpy(pattrib->ta, pattrib->src, ETH_ALEN); + + /* */ + memcpy(pattrib->bssid, mybssid, ETH_ALEN); + + *psta = rtw_get_stainfo(pstapriv, pattrib->bssid); /* get sta_info */ + if (*psta == NULL) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("can't get psta under MP_MODE ; drop pkt\n")); + ret = _FAIL; + goto exit; + } + } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { + /* Special case */ + ret = RTW_RX_HANDLED; + goto exit; + } else { + if (_rtw_memcmp(myhwaddr, pattrib->dst, ETH_ALEN) && (!bmcast)) { + *psta = rtw_get_stainfo(pstapriv, pattrib->bssid); /* get sta_info */ + if (*psta == NULL) { + DBG_88E("issue_deauth to the ap =%pM for the reason(7)\n", (pattrib->bssid)); + + issue_deauth(adapter, pattrib->bssid, WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA); + } + } + + ret = _FAIL; + } + +exit: + +_func_exit_; + + return ret; +} + +static int sta2ap_data_frame(struct adapter *adapter, + union recv_frame *precv_frame, + struct sta_info **psta) +{ + struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib; + struct sta_priv *pstapriv = &adapter->stapriv; + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + u8 *ptr = precv_frame->u.hdr.rx_data; + unsigned char *mybssid = get_bssid(pmlmepriv); + int ret = _SUCCESS; + +_func_enter_; + + if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) { + /* For AP mode, RA = BSSID, TX = STA(SRC_ADDR), A3 = DST_ADDR */ + if (!_rtw_memcmp(pattrib->bssid, mybssid, ETH_ALEN)) { + ret = _FAIL; + goto exit; + } + + *psta = rtw_get_stainfo(pstapriv, pattrib->src); + if (*psta == NULL) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("can't get psta under AP_MODE; drop pkt\n")); + DBG_88E("issue_deauth to sta=%pM for the reason(7)\n", (pattrib->src)); + + issue_deauth(adapter, pattrib->src, WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA); + + ret = RTW_RX_HANDLED; + goto exit; + } + + process_pwrbit_data(adapter, precv_frame); + + if ((GetFrameSubType(ptr) & WIFI_QOS_DATA_TYPE) == WIFI_QOS_DATA_TYPE) { + process_wmmps_data(adapter, precv_frame); + } + + if (GetFrameSubType(ptr) & BIT(6)) { + /* No data, will not indicate to upper layer, temporily count it here */ + count_rx_stats(adapter, precv_frame, *psta); + ret = RTW_RX_HANDLED; + goto exit; + } + } else { + u8 *myhwaddr = myid(&adapter->eeprompriv); + if (!_rtw_memcmp(pattrib->ra, myhwaddr, ETH_ALEN)) { + ret = RTW_RX_HANDLED; + goto exit; + } + DBG_88E("issue_deauth to sta=%pM for the reason(7)\n", (pattrib->src)); + issue_deauth(adapter, pattrib->src, WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA); + ret = RTW_RX_HANDLED; + goto exit; + } + +exit: + +_func_exit_; + + return ret; +} + +static int validate_recv_ctrl_frame(struct adapter *padapter, + union recv_frame *precv_frame) +{ +#ifdef CONFIG_88EU_AP_MODE + struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib; + struct sta_priv *pstapriv = &padapter->stapriv; + u8 *pframe = precv_frame->u.hdr.rx_data; + /* uint len = precv_frame->u.hdr.len; */ + + if (GetFrameType(pframe) != WIFI_CTRL_TYPE) + return _FAIL; + + /* receive the frames that ra(a1) is my address */ + if (!_rtw_memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN)) + return _FAIL; + + /* only handle ps-poll */ + if (GetFrameSubType(pframe) == WIFI_PSPOLL) { + u16 aid; + u8 wmmps_ac = 0; + struct sta_info *psta = NULL; + + aid = GetAid(pframe); + psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); + + if ((psta == NULL) || (psta->aid != aid)) + return _FAIL; + + /* for rx pkt statistics */ + psta->sta_stats.rx_ctrl_pkts++; + + switch (pattrib->priority) { + case 1: + case 2: + wmmps_ac = psta->uapsd_bk&BIT(0); + break; + case 4: + case 5: + wmmps_ac = psta->uapsd_vi&BIT(0); + break; + case 6: + case 7: + wmmps_ac = psta->uapsd_vo&BIT(0); + break; + case 0: + case 3: + default: + wmmps_ac = psta->uapsd_be&BIT(0); + break; + } + + if (wmmps_ac) + return _FAIL; + + if (psta->state & WIFI_STA_ALIVE_CHK_STATE) { + DBG_88E("%s alive check-rx ps-poll\n", __func__); + psta->expire_to = pstapriv->expire_to; + psta->state ^= WIFI_STA_ALIVE_CHK_STATE; + } + + if ((psta->state&WIFI_SLEEP_STATE) && (pstapriv->sta_dz_bitmap&BIT(psta->aid))) { + unsigned long irqL; + struct list_head *xmitframe_plist, *xmitframe_phead; + struct xmit_frame *pxmitframe = NULL; + + _enter_critical_bh(&psta->sleep_q.lock, &irqL); + + xmitframe_phead = get_list_head(&psta->sleep_q); + xmitframe_plist = get_next(xmitframe_phead); + + if ((rtw_end_of_queue_search(xmitframe_phead, xmitframe_plist)) == false) { + pxmitframe = LIST_CONTAINOR(xmitframe_plist, struct xmit_frame, list); + + xmitframe_plist = get_next(xmitframe_plist); + + rtw_list_delete(&pxmitframe->list); + + psta->sleepq_len--; + + if (psta->sleepq_len > 0) + pxmitframe->attrib.mdata = 1; + else + pxmitframe->attrib.mdata = 0; + + pxmitframe->attrib.triggered = 1; + + _exit_critical_bh(&psta->sleep_q.lock, &irqL); + if (rtw_hal_xmit(padapter, pxmitframe) == true) + rtw_os_xmit_complete(padapter, pxmitframe); + _enter_critical_bh(&psta->sleep_q.lock, &irqL); + + if (psta->sleepq_len == 0) { + pstapriv->tim_bitmap &= ~BIT(psta->aid); + + /* upate BCN for TIM IE */ + /* update_BCNTIM(padapter); */ + update_beacon(padapter, _TIM_IE_, NULL, false); + } + } else { + if (pstapriv->tim_bitmap&BIT(psta->aid)) { + if (psta->sleepq_len == 0) { + DBG_88E("no buffered packets to xmit\n"); + + /* issue nulldata with More data bit = 0 to indicate we have no buffered packets */ + issue_nulldata(padapter, psta->hwaddr, 0, 0, 0); + } else { + DBG_88E("error!psta->sleepq_len=%d\n", psta->sleepq_len); + psta->sleepq_len = 0; + } + + pstapriv->tim_bitmap &= ~BIT(psta->aid); + + /* upate BCN for TIM IE */ + /* update_BCNTIM(padapter); */ + update_beacon(padapter, _TIM_IE_, NULL, false); + } + } + + _exit_critical_bh(&psta->sleep_q.lock, &irqL); + } + } + +#endif + + return _FAIL; +} + +union recv_frame *recvframe_chk_defrag(struct adapter *padapter, union recv_frame *precv_frame); + +static int validate_recv_mgnt_frame(struct adapter *padapter, + union recv_frame *precv_frame) +{ + struct sta_info *psta; + + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("+validate_recv_mgnt_frame\n")); + + precv_frame = recvframe_chk_defrag(padapter, precv_frame); + if (precv_frame == NULL) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("%s: fragment packet\n", __func__)); + return _SUCCESS; + } + + /* for rx pkt statistics */ + psta = rtw_get_stainfo(&padapter->stapriv, GetAddr2Ptr(precv_frame->u.hdr.rx_data)); + if (psta) { + psta->sta_stats.rx_mgnt_pkts++; + if (GetFrameSubType(precv_frame->u.hdr.rx_data) == WIFI_BEACON) { + psta->sta_stats.rx_beacon_pkts++; + } else if (GetFrameSubType(precv_frame->u.hdr.rx_data) == WIFI_PROBEREQ) { + psta->sta_stats.rx_probereq_pkts++; + } else if (GetFrameSubType(precv_frame->u.hdr.rx_data) == WIFI_PROBERSP) { + if (_rtw_memcmp(padapter->eeprompriv.mac_addr, GetAddr1Ptr(precv_frame->u.hdr.rx_data), ETH_ALEN) == true) + psta->sta_stats.rx_probersp_pkts++; + else if (is_broadcast_mac_addr(GetAddr1Ptr(precv_frame->u.hdr.rx_data)) || + is_multicast_mac_addr(GetAddr1Ptr(precv_frame->u.hdr.rx_data))) + psta->sta_stats.rx_probersp_bm_pkts++; + else + psta->sta_stats.rx_probersp_uo_pkts++; + } + } + + mgt_dispatcher(padapter, precv_frame); + + return _SUCCESS; +} + +static int validate_recv_data_frame(struct adapter *adapter, + union recv_frame *precv_frame) +{ + u8 bretry; + u8 *psa, *pda, *pbssid; + struct sta_info *psta = NULL; + u8 *ptr = precv_frame->u.hdr.rx_data; + struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib; + struct security_priv *psecuritypriv = &adapter->securitypriv; + int ret = _SUCCESS; + +_func_enter_; + + bretry = GetRetry(ptr); + pda = get_da(ptr); + psa = get_sa(ptr); + pbssid = get_hdr_bssid(ptr); + + if (pbssid == NULL) { + ret = _FAIL; + goto exit; + } + + memcpy(pattrib->dst, pda, ETH_ALEN); + memcpy(pattrib->src, psa, ETH_ALEN); + + memcpy(pattrib->bssid, pbssid, ETH_ALEN); + + switch (pattrib->to_fr_ds) { + case 0: + memcpy(pattrib->ra, pda, ETH_ALEN); + memcpy(pattrib->ta, psa, ETH_ALEN); + ret = sta2sta_data_frame(adapter, precv_frame, &psta); + break; + case 1: + memcpy(pattrib->ra, pda, ETH_ALEN); + memcpy(pattrib->ta, pbssid, ETH_ALEN); + ret = ap2sta_data_frame(adapter, precv_frame, &psta); + break; + case 2: + memcpy(pattrib->ra, pbssid, ETH_ALEN); + memcpy(pattrib->ta, psa, ETH_ALEN); + ret = sta2ap_data_frame(adapter, precv_frame, &psta); + break; + case 3: + memcpy(pattrib->ra, GetAddr1Ptr(ptr), ETH_ALEN); + memcpy(pattrib->ta, GetAddr2Ptr(ptr), ETH_ALEN); + ret = _FAIL; + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, (" case 3\n")); + break; + default: + ret = _FAIL; + break; + } + + if (ret == _FAIL) { + goto exit; + } else if (ret == RTW_RX_HANDLED) { + goto exit; + } + + if (psta == NULL) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, (" after to_fr_ds_chk; psta==NULL\n")); + ret = _FAIL; + goto exit; + } + + /* psta->rssi = prxcmd->rssi; */ + /* psta->signal_quality = prxcmd->sq; */ + precv_frame->u.hdr.psta = psta; + + pattrib->amsdu = 0; + pattrib->ack_policy = 0; + /* parsing QC field */ + if (pattrib->qos == 1) { + pattrib->priority = GetPriority((ptr + 24)); + pattrib->ack_policy = GetAckpolicy((ptr + 24)); + pattrib->amsdu = GetAMsdu((ptr + 24)); + pattrib->hdrlen = pattrib->to_fr_ds == 3 ? 32 : 26; + + if (pattrib->priority != 0 && pattrib->priority != 3) + adapter->recvpriv.bIsAnyNonBEPkts = true; + } else { + pattrib->priority = 0; + pattrib->hdrlen = pattrib->to_fr_ds == 3 ? 30 : 24; + } + + if (pattrib->order)/* HT-CTRL 11n */ + pattrib->hdrlen += 4; + + precv_frame->u.hdr.preorder_ctrl = &psta->recvreorder_ctrl[pattrib->priority]; + + /* decache, drop duplicate recv packets */ + if (recv_decache(precv_frame, bretry, &psta->sta_recvpriv.rxcache) == _FAIL) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("decache : drop pkt\n")); + ret = _FAIL; + goto exit; + } + + if (pattrib->privacy) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("validate_recv_data_frame:pattrib->privacy=%x\n", pattrib->privacy)); + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n ^^^^^^^^^^^IS_MCAST(pattrib->ra(0x%02x))=%d^^^^^^^^^^^^^^^6\n", pattrib->ra[0], IS_MCAST(pattrib->ra))); + + GET_ENCRY_ALGO(psecuritypriv, psta, pattrib->encrypt, IS_MCAST(pattrib->ra)); + + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n pattrib->encrypt=%d\n", pattrib->encrypt)); + + SET_ICE_IV_LEN(pattrib->iv_len, pattrib->icv_len, pattrib->encrypt); + } else { + pattrib->encrypt = 0; + pattrib->iv_len = 0; + pattrib->icv_len = 0; + } + +exit: + +_func_exit_; + + return ret; +} + +static int validate_recv_frame(struct adapter *adapter, union recv_frame *precv_frame) +{ + /* shall check frame subtype, to / from ds, da, bssid */ + + /* then call check if rx seq/frag. duplicated. */ + + u8 type; + u8 subtype; + int retval = _SUCCESS; + u8 bDumpRxPkt; + struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib; + u8 *ptr = precv_frame->u.hdr.rx_data; + u8 ver = (unsigned char) (*ptr)&0x3; + struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv; + +_func_enter_; + + if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) { + int ch_set_idx = rtw_ch_set_search_ch(pmlmeext->channel_set, rtw_get_oper_ch(adapter)); + if (ch_set_idx >= 0) + pmlmeext->channel_set[ch_set_idx].rx_count++; + } + + /* add version chk */ + if (ver != 0) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("validate_recv_data_frame fail! (ver!=0)\n")); + retval = _FAIL; + goto exit; + } + + type = GetFrameType(ptr); + subtype = GetFrameSubType(ptr); /* bit(7)~bit(2) */ + + pattrib->to_fr_ds = get_tofr_ds(ptr); + + pattrib->frag_num = GetFragNum(ptr); + pattrib->seq_num = GetSequence(ptr); + + pattrib->pw_save = GetPwrMgt(ptr); + pattrib->mfrag = GetMFrag(ptr); + pattrib->mdata = GetMData(ptr); + pattrib->privacy = GetPrivacy(ptr); + pattrib->order = GetOrder(ptr); + + /* Dump rx packets */ + rtw_hal_get_def_var(adapter, HAL_DEF_DBG_DUMP_RXPKT, &(bDumpRxPkt)); + if (bDumpRxPkt == 1) {/* dump all rx packets */ + int i; + DBG_88E("#############################\n"); + + for (i = 0; i < 64; i = i+8) + DBG_88E("%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:\n", *(ptr+i), + *(ptr+i+1), *(ptr+i+2), *(ptr+i+3), *(ptr+i+4), *(ptr+i+5), *(ptr+i+6), *(ptr+i+7)); + DBG_88E("#############################\n"); + } else if (bDumpRxPkt == 2) { + if (type == WIFI_MGT_TYPE) { + int i; + DBG_88E("#############################\n"); + + for (i = 0; i < 64; i = i+8) + DBG_88E("%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:\n", *(ptr+i), + *(ptr+i+1), *(ptr+i+2), *(ptr+i+3), *(ptr+i+4), *(ptr+i+5), *(ptr+i+6), *(ptr+i+7)); + DBG_88E("#############################\n"); + } + } else if (bDumpRxPkt == 3) { + if (type == WIFI_DATA_TYPE) { + int i; + DBG_88E("#############################\n"); + + for (i = 0; i < 64; i = i+8) + DBG_88E("%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:\n", *(ptr+i), + *(ptr+i+1), *(ptr+i+2), *(ptr+i+3), *(ptr+i+4), *(ptr+i+5), *(ptr+i+6), *(ptr+i+7)); + DBG_88E("#############################\n"); + } + } + switch (type) { + case WIFI_MGT_TYPE: /* mgnt */ + retval = validate_recv_mgnt_frame(adapter, precv_frame); + if (retval == _FAIL) + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("validate_recv_mgnt_frame fail\n")); + retval = _FAIL; /* only data frame return _SUCCESS */ + break; + case WIFI_CTRL_TYPE: /* ctrl */ + retval = validate_recv_ctrl_frame(adapter, precv_frame); + if (retval == _FAIL) + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("validate_recv_ctrl_frame fail\n")); + retval = _FAIL; /* only data frame return _SUCCESS */ + break; + case WIFI_DATA_TYPE: /* data */ + rtw_led_control(adapter, LED_CTL_RX); + pattrib->qos = (subtype & BIT(7)) ? 1 : 0; + retval = validate_recv_data_frame(adapter, precv_frame); + if (retval == _FAIL) { + struct recv_priv *precvpriv = &adapter->recvpriv; + precvpriv->rx_drop++; + } + break; + default: + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("validate_recv_data_frame fail! type= 0x%x\n", type)); + retval = _FAIL; + break; + } + +exit: + +_func_exit_; + + return retval; +} + +/* remove the wlanhdr and add the eth_hdr */ + +static int wlanhdr_to_ethhdr (union recv_frame *precvframe) +{ + int rmv_len; + u16 eth_type, len; + __be16 be_tmp; + u8 bsnaphdr; + u8 *psnap_type; + struct ieee80211_snap_hdr *psnap; + + int ret = _SUCCESS; + struct adapter *adapter = precvframe->u.hdr.adapter; + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + + u8 *ptr = get_recvframe_data(precvframe); /* point to frame_ctrl field */ + struct rx_pkt_attrib *pattrib = &precvframe->u.hdr.attrib; + +_func_enter_; + + if (pattrib->encrypt) + recvframe_pull_tail(precvframe, pattrib->icv_len); + + psnap = (struct ieee80211_snap_hdr *)(ptr+pattrib->hdrlen + pattrib->iv_len); + psnap_type = ptr+pattrib->hdrlen + pattrib->iv_len+SNAP_SIZE; + /* convert hdr + possible LLC headers into Ethernet header */ + if ((_rtw_memcmp(psnap, rtw_rfc1042_header, SNAP_SIZE) && + (_rtw_memcmp(psnap_type, SNAP_ETH_TYPE_IPX, 2) == false) && + (_rtw_memcmp(psnap_type, SNAP_ETH_TYPE_APPLETALK_AARP, 2) == false)) || + _rtw_memcmp(psnap, rtw_bridge_tunnel_header, SNAP_SIZE)) { + /* remove RFC1042 or Bridge-Tunnel encapsulation and replace EtherType */ + bsnaphdr = true; + } else { + /* Leave Ethernet header part of hdr and full payload */ + bsnaphdr = false; + } + + rmv_len = pattrib->hdrlen + pattrib->iv_len + (bsnaphdr ? SNAP_SIZE : 0); + len = precvframe->u.hdr.len - rmv_len; + + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, + ("\n===pattrib->hdrlen: %x, pattrib->iv_len:%x===\n\n", pattrib->hdrlen, pattrib->iv_len)); + + memcpy(&be_tmp, ptr+rmv_len, 2); + eth_type = ntohs(be_tmp); /* pattrib->ether_type */ + pattrib->eth_type = eth_type; + + if ((check_fwstate(pmlmepriv, WIFI_MP_STATE))) { + ptr += rmv_len; + *ptr = 0x87; + *(ptr+1) = 0x12; + + eth_type = 0x8712; + /* append rx status for mp test packets */ + ptr = recvframe_pull(precvframe, (rmv_len-sizeof(struct ethhdr)+2)-24); + memcpy(ptr, get_rxmem(precvframe), 24); + ptr += 24; + } else { + ptr = recvframe_pull(precvframe, (rmv_len-sizeof(struct ethhdr) + (bsnaphdr ? 2 : 0))); + } + + memcpy(ptr, pattrib->dst, ETH_ALEN); + memcpy(ptr+ETH_ALEN, pattrib->src, ETH_ALEN); + + if (!bsnaphdr) { + be_tmp = htons(len); + memcpy(ptr+12, &be_tmp, 2); + } + +_func_exit_; + return ret; +} + +/* perform defrag */ +static union recv_frame *recvframe_defrag(struct adapter *adapter, struct __queue *defrag_q) +{ + struct list_head *plist, *phead; + u8 wlanhdr_offset; + u8 curfragnum; + struct recv_frame_hdr *pfhdr, *pnfhdr; + union recv_frame *prframe, *pnextrframe; + struct __queue *pfree_recv_queue; + +_func_enter_; + + curfragnum = 0; + pfree_recv_queue = &adapter->recvpriv.free_recv_queue; + + phead = get_list_head(defrag_q); + plist = get_next(phead); + prframe = LIST_CONTAINOR(plist, union recv_frame, u); + pfhdr = &prframe->u.hdr; + rtw_list_delete(&(prframe->u.list)); + + if (curfragnum != pfhdr->attrib.frag_num) { + /* the first fragment number must be 0 */ + /* free the whole queue */ + rtw_free_recvframe(prframe, pfree_recv_queue); + rtw_free_recvframe_queue(defrag_q, pfree_recv_queue); + + return NULL; + } + + curfragnum++; + + plist = get_list_head(defrag_q); + + plist = get_next(plist); + + while (rtw_end_of_queue_search(phead, plist) == false) { + pnextrframe = LIST_CONTAINOR(plist, union recv_frame , u); + pnfhdr = &pnextrframe->u.hdr; + + /* check the fragment sequence (2nd ~n fragment frame) */ + + if (curfragnum != pnfhdr->attrib.frag_num) { + /* the fragment number must be increasing (after decache) */ + /* release the defrag_q & prframe */ + rtw_free_recvframe(prframe, pfree_recv_queue); + rtw_free_recvframe_queue(defrag_q, pfree_recv_queue); + return NULL; + } + + curfragnum++; + + /* copy the 2nd~n fragment frame's payload to the first fragment */ + /* get the 2nd~last fragment frame's payload */ + + wlanhdr_offset = pnfhdr->attrib.hdrlen + pnfhdr->attrib.iv_len; + + recvframe_pull(pnextrframe, wlanhdr_offset); + + /* append to first fragment frame's tail (if privacy frame, pull the ICV) */ + recvframe_pull_tail(prframe, pfhdr->attrib.icv_len); + + /* memcpy */ + memcpy(pfhdr->rx_tail, pnfhdr->rx_data, pnfhdr->len); + + recvframe_put(prframe, pnfhdr->len); + + pfhdr->attrib.icv_len = pnfhdr->attrib.icv_len; + plist = get_next(plist); + }; + + /* free the defrag_q queue and return the prframe */ + rtw_free_recvframe_queue(defrag_q, pfree_recv_queue); + + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("Performance defrag!!!!!\n")); + +_func_exit_; + + return prframe; +} + +/* check if need to defrag, if needed queue the frame to defrag_q */ +union recv_frame *recvframe_chk_defrag(struct adapter *padapter, union recv_frame *precv_frame) +{ + u8 ismfrag; + u8 fragnum; + u8 *psta_addr; + struct recv_frame_hdr *pfhdr; + struct sta_info *psta; + struct sta_priv *pstapriv; + struct list_head *phead; + union recv_frame *prtnframe = NULL; + struct __queue *pfree_recv_queue, *pdefrag_q; + +_func_enter_; + + pstapriv = &padapter->stapriv; + + pfhdr = &precv_frame->u.hdr; + + pfree_recv_queue = &padapter->recvpriv.free_recv_queue; + + /* need to define struct of wlan header frame ctrl */ + ismfrag = pfhdr->attrib.mfrag; + fragnum = pfhdr->attrib.frag_num; + + psta_addr = pfhdr->attrib.ta; + psta = rtw_get_stainfo(pstapriv, psta_addr); + if (psta == NULL) { + u8 type = GetFrameType(pfhdr->rx_data); + if (type != WIFI_DATA_TYPE) { + psta = rtw_get_bcmc_stainfo(padapter); + pdefrag_q = &psta->sta_recvpriv.defrag_q; + } else { + pdefrag_q = NULL; + } + } else { + pdefrag_q = &psta->sta_recvpriv.defrag_q; + } + + if ((ismfrag == 0) && (fragnum == 0)) + prtnframe = precv_frame;/* isn't a fragment frame */ + + if (ismfrag == 1) { + /* 0~(n-1) fragment frame */ + /* enqueue to defraf_g */ + if (pdefrag_q != NULL) { + if (fragnum == 0) { + /* the first fragment */ + if (_rtw_queue_empty(pdefrag_q) == false) { + /* free current defrag_q */ + rtw_free_recvframe_queue(pdefrag_q, pfree_recv_queue); + } + } + + /* Then enqueue the 0~(n-1) fragment into the defrag_q */ + + phead = get_list_head(pdefrag_q); + rtw_list_insert_tail(&pfhdr->list, phead); + + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("Enqueuq: ismfrag=%d, fragnum=%d\n", ismfrag, fragnum)); + + prtnframe = NULL; + } else { + /* can't find this ta's defrag_queue, so free this recv_frame */ + rtw_free_recvframe(precv_frame, pfree_recv_queue); + prtnframe = NULL; + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("Free because pdefrag_q==NULL: ismfrag=%d, fragnum=%d\n", ismfrag, fragnum)); + } + } + + if ((ismfrag == 0) && (fragnum != 0)) { + /* the last fragment frame */ + /* enqueue the last fragment */ + if (pdefrag_q != NULL) { + phead = get_list_head(pdefrag_q); + rtw_list_insert_tail(&pfhdr->list, phead); + + /* call recvframe_defrag to defrag */ + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("defrag: ismfrag=%d, fragnum=%d\n", ismfrag, fragnum)); + precv_frame = recvframe_defrag(padapter, pdefrag_q); + prtnframe = precv_frame; + } else { + /* can't find this ta's defrag_queue, so free this recv_frame */ + rtw_free_recvframe(precv_frame, pfree_recv_queue); + prtnframe = NULL; + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("Free because pdefrag_q==NULL: ismfrag=%d, fragnum=%d\n", ismfrag, fragnum)); + } + } + + if ((prtnframe != NULL) && (prtnframe->u.hdr.attrib.privacy)) { + /* after defrag we must check tkip mic code */ + if (recvframe_chkmic(padapter, prtnframe) == _FAIL) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("recvframe_chkmic(padapter, prtnframe)==_FAIL\n")); + rtw_free_recvframe(prtnframe, pfree_recv_queue); + prtnframe = NULL; + } + } + +_func_exit_; + + return prtnframe; +} + +static int amsdu_to_msdu(struct adapter *padapter, union recv_frame *prframe) +{ + int a_len, padding_len; + u16 eth_type, nSubframe_Length; + u8 nr_subframes, i; + unsigned char *pdata; + struct rx_pkt_attrib *pattrib; + unsigned char *data_ptr; + struct sk_buff *sub_skb, *subframes[MAX_SUBFRAME_COUNT]; + struct recv_priv *precvpriv = &padapter->recvpriv; + struct __queue *pfree_recv_queue = &(precvpriv->free_recv_queue); + int ret = _SUCCESS; + nr_subframes = 0; + + pattrib = &prframe->u.hdr.attrib; + + recvframe_pull(prframe, prframe->u.hdr.attrib.hdrlen); + + if (prframe->u.hdr.attrib.iv_len > 0) + recvframe_pull(prframe, prframe->u.hdr.attrib.iv_len); + + a_len = prframe->u.hdr.len; + + pdata = prframe->u.hdr.rx_data; + + while (a_len > ETH_HLEN) { + /* Offset 12 denote 2 mac address */ + nSubframe_Length = RTW_GET_BE16(pdata + 12); + + if (a_len < (ETHERNET_HEADER_SIZE + nSubframe_Length)) { + DBG_88E("nRemain_Length is %d and nSubframe_Length is : %d\n", a_len, nSubframe_Length); + goto exit; + } + + /* move the data point to data content */ + pdata += ETH_HLEN; + a_len -= ETH_HLEN; + + /* Allocate new skb for releasing to upper layer */ + sub_skb = dev_alloc_skb(nSubframe_Length + 12); + if (sub_skb) { + skb_reserve(sub_skb, 12); + data_ptr = (u8 *)skb_put(sub_skb, nSubframe_Length); + memcpy(data_ptr, pdata, nSubframe_Length); + } else { + sub_skb = skb_clone(prframe->u.hdr.pkt, GFP_ATOMIC); + if (sub_skb) { + sub_skb->data = pdata; + sub_skb->len = nSubframe_Length; + skb_set_tail_pointer(sub_skb, nSubframe_Length); + } else { + DBG_88E("skb_clone() Fail!!! , nr_subframes=%d\n", nr_subframes); + break; + } + } + + subframes[nr_subframes++] = sub_skb; + + if (nr_subframes >= MAX_SUBFRAME_COUNT) { + DBG_88E("ParseSubframe(): Too many Subframes! Packets dropped!\n"); + break; + } + + pdata += nSubframe_Length; + a_len -= nSubframe_Length; + if (a_len != 0) { + padding_len = 4 - ((nSubframe_Length + ETH_HLEN) & (4-1)); + if (padding_len == 4) { + padding_len = 0; + } + + if (a_len < padding_len) { + goto exit; + } + pdata += padding_len; + a_len -= padding_len; + } + } + + for (i = 0; i < nr_subframes; i++) { + sub_skb = subframes[i]; + /* convert hdr + possible LLC headers into Ethernet header */ + eth_type = RTW_GET_BE16(&sub_skb->data[6]); + if (sub_skb->len >= 8 && + ((_rtw_memcmp(sub_skb->data, rtw_rfc1042_header, SNAP_SIZE) && + eth_type != ETH_P_AARP && eth_type != ETH_P_IPX) || + _rtw_memcmp(sub_skb->data, rtw_bridge_tunnel_header, SNAP_SIZE))) { + /* remove RFC1042 or Bridge-Tunnel encapsulation and replace EtherType */ + skb_pull(sub_skb, SNAP_SIZE); + memcpy(skb_push(sub_skb, ETH_ALEN), pattrib->src, ETH_ALEN); + memcpy(skb_push(sub_skb, ETH_ALEN), pattrib->dst, ETH_ALEN); + } else { + __be16 len; + /* Leave Ethernet header part of hdr and full payload */ + len = htons(sub_skb->len); + memcpy(skb_push(sub_skb, 2), &len, 2); + memcpy(skb_push(sub_skb, ETH_ALEN), pattrib->src, ETH_ALEN); + memcpy(skb_push(sub_skb, ETH_ALEN), pattrib->dst, ETH_ALEN); + } + + /* Indicat the packets to upper layer */ + if (sub_skb) { + /* Insert NAT2.5 RX here! */ + sub_skb->protocol = eth_type_trans(sub_skb, padapter->pnetdev); + sub_skb->dev = padapter->pnetdev; + + sub_skb->ip_summed = CHECKSUM_NONE; + + netif_rx(sub_skb); + } + } + +exit: + + prframe->u.hdr.len = 0; + rtw_free_recvframe(prframe, pfree_recv_queue);/* free this recv_frame */ + + return ret; +} + +static int check_indicate_seq(struct recv_reorder_ctrl *preorder_ctrl, u16 seq_num) +{ + u8 wsize = preorder_ctrl->wsize_b; + u16 wend = (preorder_ctrl->indicate_seq + wsize - 1) & 0xFFF;/* 4096; */ + + /* Rx Reorder initialize condition. */ + if (preorder_ctrl->indicate_seq == 0xFFFF) + preorder_ctrl->indicate_seq = seq_num; + + /* Drop out the packet which SeqNum is smaller than WinStart */ + if (SN_LESS(seq_num, preorder_ctrl->indicate_seq)) + return false; + + /* */ + /* Sliding window manipulation. Conditions includes: */ + /* 1. Incoming SeqNum is equal to WinStart =>Window shift 1 */ + /* 2. Incoming SeqNum is larger than the WinEnd => Window shift N */ + /* */ + if (SN_EQUAL(seq_num, preorder_ctrl->indicate_seq)) { + preorder_ctrl->indicate_seq = (preorder_ctrl->indicate_seq + 1) & 0xFFF; + } else if (SN_LESS(wend, seq_num)) { + if (seq_num >= (wsize - 1)) + preorder_ctrl->indicate_seq = seq_num + 1 - wsize; + else + preorder_ctrl->indicate_seq = 0xFFF - (wsize - (seq_num + 1)) + 1; + } + + return true; +} + +int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, union recv_frame *prframe); +int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, union recv_frame *prframe) +{ + struct rx_pkt_attrib *pattrib = &prframe->u.hdr.attrib; + struct __queue *ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue; + struct list_head *phead, *plist; + union recv_frame *pnextrframe; + struct rx_pkt_attrib *pnextattrib; + + phead = get_list_head(ppending_recvframe_queue); + plist = get_next(phead); + + while (rtw_end_of_queue_search(phead, plist) == false) { + pnextrframe = LIST_CONTAINOR(plist, union recv_frame, u); + pnextattrib = &pnextrframe->u.hdr.attrib; + + if (SN_LESS(pnextattrib->seq_num, pattrib->seq_num)) + plist = get_next(plist); + else if (SN_EQUAL(pnextattrib->seq_num, pattrib->seq_num)) + return false; + else + break; + } + + rtw_list_delete(&(prframe->u.hdr.list)); + + rtw_list_insert_tail(&(prframe->u.hdr.list), plist); + return true; +} + +static int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reorder_ctrl *preorder_ctrl, int bforced) +{ + struct list_head *phead, *plist; + union recv_frame *prframe; + struct rx_pkt_attrib *pattrib; + int bPktInBuf = false; + struct recv_priv *precvpriv = &padapter->recvpriv; + struct __queue *ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue; + + phead = get_list_head(ppending_recvframe_queue); + plist = get_next(phead); + + /* Handling some condition for forced indicate case. */ + if (bforced) { + if (rtw_is_list_empty(phead)) + return true; + + prframe = LIST_CONTAINOR(plist, union recv_frame, u); + pattrib = &prframe->u.hdr.attrib; + preorder_ctrl->indicate_seq = pattrib->seq_num; + } + + /* Prepare indication list and indication. */ + /* Check if there is any packet need indicate. */ + while (!rtw_is_list_empty(phead)) { + prframe = LIST_CONTAINOR(plist, union recv_frame, u); + pattrib = &prframe->u.hdr.attrib; + + if (!SN_LESS(preorder_ctrl->indicate_seq, pattrib->seq_num)) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, + ("recv_indicatepkts_in_order: indicate=%d seq=%d amsdu=%d\n", + preorder_ctrl->indicate_seq, pattrib->seq_num, pattrib->amsdu)); + plist = get_next(plist); + rtw_list_delete(&(prframe->u.hdr.list)); + + if (SN_EQUAL(preorder_ctrl->indicate_seq, pattrib->seq_num)) + preorder_ctrl->indicate_seq = (preorder_ctrl->indicate_seq + 1) & 0xFFF; + + /* Set this as a lock to make sure that only one thread is indicating packet. */ + + /* indicate this recv_frame */ + if (!pattrib->amsdu) { + if ((!padapter->bDriverStopped) && + (!padapter->bSurpriseRemoved)) + rtw_recv_indicatepkt(padapter, prframe);/* indicate this recv_frame */ + } else if (pattrib->amsdu == 1) { + if (amsdu_to_msdu(padapter, prframe) != _SUCCESS) + rtw_free_recvframe(prframe, &precvpriv->free_recv_queue); + } else { + /* error condition; */ + } + + /* Update local variables. */ + bPktInBuf = false; + } else { + bPktInBuf = true; + break; + } + } + return bPktInBuf; +} + +static int recv_indicatepkt_reorder(struct adapter *padapter, union recv_frame *prframe) +{ + unsigned long irql; + int retval = _SUCCESS; + struct rx_pkt_attrib *pattrib = &prframe->u.hdr.attrib; + struct recv_reorder_ctrl *preorder_ctrl = prframe->u.hdr.preorder_ctrl; + struct __queue *ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue; + + if (!pattrib->amsdu) { + /* s1. */ + wlanhdr_to_ethhdr(prframe); + + if ((pattrib->qos != 1) || (pattrib->eth_type == 0x0806) || + (pattrib->ack_policy != 0)) { + if ((!padapter->bDriverStopped) && + (!padapter->bSurpriseRemoved)) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("@@@@ recv_indicatepkt_reorder -recv_func recv_indicatepkt\n")); + + rtw_recv_indicatepkt(padapter, prframe); + return _SUCCESS; + } + + return _FAIL; + } + + if (!preorder_ctrl->enable) { + /* indicate this recv_frame */ + preorder_ctrl->indicate_seq = pattrib->seq_num; + rtw_recv_indicatepkt(padapter, prframe); + + preorder_ctrl->indicate_seq = (preorder_ctrl->indicate_seq + 1)%4096; + return _SUCCESS; + } + } else if (pattrib->amsdu == 1) { /* temp filter -> means didn't support A-MSDUs in a A-MPDU */ + if (!preorder_ctrl->enable) { + preorder_ctrl->indicate_seq = pattrib->seq_num; + retval = amsdu_to_msdu(padapter, prframe); + + preorder_ctrl->indicate_seq = (preorder_ctrl->indicate_seq + 1)%4096; + return retval; + } + } + + _enter_critical_bh(&ppending_recvframe_queue->lock, &irql); + + RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, + ("recv_indicatepkt_reorder: indicate=%d seq=%d\n", + preorder_ctrl->indicate_seq, pattrib->seq_num)); + + /* s2. check if winstart_b(indicate_seq) needs to been updated */ + if (!check_indicate_seq(preorder_ctrl, pattrib->seq_num)) { + rtw_recv_indicatepkt(padapter, prframe); + + _exit_critical_bh(&ppending_recvframe_queue->lock, &irql); + + goto _success_exit; + } + + /* s3. Insert all packet into Reorder Queue to maintain its ordering. */ + if (!enqueue_reorder_recvframe(preorder_ctrl, prframe)) + goto _err_exit; + + /* s4. */ + /* Indication process. */ + /* After Packet dropping and Sliding Window shifting as above, we can now just indicate the packets */ + /* with the SeqNum smaller than latest WinStart and buffer other packets. */ + /* */ + /* For Rx Reorder condition: */ + /* 1. All packets with SeqNum smaller than WinStart => Indicate */ + /* 2. All packets with SeqNum larger than or equal to WinStart => Buffer it. */ + /* */ + + /* recv_indicatepkts_in_order(padapter, preorder_ctrl, true); */ + if (recv_indicatepkts_in_order(padapter, preorder_ctrl, false)) { + _set_timer(&preorder_ctrl->reordering_ctrl_timer, REORDER_WAIT_TIME); + _exit_critical_bh(&ppending_recvframe_queue->lock, &irql); + } else { + _exit_critical_bh(&ppending_recvframe_queue->lock, &irql); + _cancel_timer_ex(&preorder_ctrl->reordering_ctrl_timer); + } + +_success_exit: + + return _SUCCESS; + +_err_exit: + + _exit_critical_bh(&ppending_recvframe_queue->lock, &irql); + + return _FAIL; +} + +void rtw_reordering_ctrl_timeout_handler(void *pcontext) +{ + unsigned long irql; + struct recv_reorder_ctrl *preorder_ctrl = (struct recv_reorder_ctrl *)pcontext; + struct adapter *padapter = preorder_ctrl->padapter; + struct __queue *ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue; + + if (padapter->bDriverStopped || padapter->bSurpriseRemoved) + return; + + _enter_critical_bh(&ppending_recvframe_queue->lock, &irql); + + if (recv_indicatepkts_in_order(padapter, preorder_ctrl, true) == true) + _set_timer(&preorder_ctrl->reordering_ctrl_timer, REORDER_WAIT_TIME); + + _exit_critical_bh(&ppending_recvframe_queue->lock, &irql); +} + +static int process_recv_indicatepkts(struct adapter *padapter, union recv_frame *prframe) +{ + int retval = _SUCCESS; + /* struct recv_priv *precvpriv = &padapter->recvpriv; */ + /* struct rx_pkt_attrib *pattrib = &prframe->u.hdr.attrib; */ + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct ht_priv *phtpriv = &pmlmepriv->htpriv; + + if (phtpriv->ht_option) { /* B/G/N Mode */ + /* prframe->u.hdr.preorder_ctrl = &precvpriv->recvreorder_ctrl[pattrib->priority]; */ + + if (recv_indicatepkt_reorder(padapter, prframe) != _SUCCESS) { + /* including perform A-MPDU Rx Ordering Buffer Control */ + if ((!padapter->bDriverStopped) && + (!padapter->bSurpriseRemoved)) { + retval = _FAIL; + return retval; + } + } + } else { /* B/G mode */ + retval = wlanhdr_to_ethhdr (prframe); + if (retval != _SUCCESS) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("wlanhdr_to_ethhdr: drop pkt\n")); + return retval; + } + + if ((!padapter->bDriverStopped) && + (!padapter->bSurpriseRemoved)) { + /* indicate this recv_frame */ + RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("@@@@ process_recv_indicatepkts- recv_func recv_indicatepkt\n")); + rtw_recv_indicatepkt(padapter, prframe); + } else { + RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("@@@@ process_recv_indicatepkts- recv_func free_indicatepkt\n")); + + RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("recv_func:bDriverStopped(%d) OR bSurpriseRemoved(%d)", padapter->bDriverStopped, padapter->bSurpriseRemoved)); + retval = _FAIL; + return retval; + } + } + + return retval; +} + +static int recv_func_prehandle(struct adapter *padapter, union recv_frame *rframe) +{ + int ret = _SUCCESS; + struct rx_pkt_attrib *pattrib = &rframe->u.hdr.attrib; + struct __queue *pfree_recv_queue = &padapter->recvpriv.free_recv_queue; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + + if (padapter->registrypriv.mp_mode == 1) { + if ((check_fwstate(pmlmepriv, WIFI_MP_STATE) == true)) { /* padapter->mppriv.check_mp_pkt == 0)) */ + if (pattrib->crc_err == 1) + padapter->mppriv.rx_crcerrpktcount++; + else + padapter->mppriv.rx_pktcount++; + + if (check_fwstate(pmlmepriv, WIFI_MP_LPBK_STATE) == false) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_alert_, ("MP - Not in loopback mode , drop pkt\n")); + ret = _FAIL; + rtw_free_recvframe(rframe, pfree_recv_queue);/* free this recv_frame */ + goto exit; + } + } + } + + /* check the frame crtl field and decache */ + ret = validate_recv_frame(padapter, rframe); + if (ret != _SUCCESS) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("recv_func: validate_recv_frame fail! drop pkt\n")); + rtw_free_recvframe(rframe, pfree_recv_queue);/* free this recv_frame */ + goto exit; + } + +exit: + return ret; +} + +static int recv_func_posthandle(struct adapter *padapter, union recv_frame *prframe) +{ + int ret = _SUCCESS; + union recv_frame *orig_prframe = prframe; + struct recv_priv *precvpriv = &padapter->recvpriv; + struct __queue *pfree_recv_queue = &padapter->recvpriv.free_recv_queue; + + /* DATA FRAME */ + rtw_led_control(padapter, LED_CTL_RX); + + prframe = decryptor(padapter, prframe); + if (prframe == NULL) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("decryptor: drop pkt\n")); + ret = _FAIL; + goto _recv_data_drop; + } + + prframe = recvframe_chk_defrag(padapter, prframe); + if (prframe == NULL) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("recvframe_chk_defrag: drop pkt\n")); + goto _recv_data_drop; + } + + prframe = portctrl(padapter, prframe); + if (prframe == NULL) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("portctrl: drop pkt\n")); + ret = _FAIL; + goto _recv_data_drop; + } + + count_rx_stats(padapter, prframe, NULL); + + ret = process_recv_indicatepkts(padapter, prframe); + if (ret != _SUCCESS) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("recv_func: process_recv_indicatepkts fail!\n")); + rtw_free_recvframe(orig_prframe, pfree_recv_queue);/* free this recv_frame */ + goto _recv_data_drop; + } + return ret; + +_recv_data_drop: + precvpriv->rx_drop++; + return ret; +} + +static int recv_func(struct adapter *padapter, union recv_frame *rframe) +{ + int ret; + struct rx_pkt_attrib *prxattrib = &rframe->u.hdr.attrib; + struct security_priv *psecuritypriv = &padapter->securitypriv; + struct mlme_priv *mlmepriv = &padapter->mlmepriv; + + /* check if need to handle uc_swdec_pending_queue*/ + if (check_fwstate(mlmepriv, WIFI_STATION_STATE) && psecuritypriv->busetkipkey) { + union recv_frame *pending_frame; + + while ((pending_frame = rtw_alloc_recvframe(&padapter->recvpriv.uc_swdec_pending_queue))) { + if (recv_func_posthandle(padapter, pending_frame) == _SUCCESS) + DBG_88E("%s: dequeue uc_swdec_pending_queue\n", __func__); + } + } + + ret = recv_func_prehandle(padapter, rframe); + + if (ret == _SUCCESS) { + /* check if need to enqueue into uc_swdec_pending_queue*/ + if (check_fwstate(mlmepriv, WIFI_STATION_STATE) && + !IS_MCAST(prxattrib->ra) && prxattrib->encrypt > 0 && + (prxattrib->bdecrypted == 0 || psecuritypriv->sw_decrypt) && + !is_wep_enc(psecuritypriv->dot11PrivacyAlgrthm) && + !psecuritypriv->busetkipkey) { + rtw_enqueue_recvframe(rframe, &padapter->recvpriv.uc_swdec_pending_queue); + DBG_88E("%s: no key, enqueue uc_swdec_pending_queue\n", __func__); + goto exit; + } + + ret = recv_func_posthandle(padapter, rframe); + } + +exit: + return ret; +} + +s32 rtw_recv_entry(union recv_frame *precvframe) +{ + struct adapter *padapter; + struct recv_priv *precvpriv; + s32 ret = _SUCCESS; + +_func_enter_; + + padapter = precvframe->u.hdr.adapter; + + precvpriv = &padapter->recvpriv; + + ret = recv_func(padapter, precvframe); + if (ret == _FAIL) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("rtw_recv_entry: recv_func return fail!!!\n")); + goto _recv_entry_drop; + } + + precvpriv->rx_pkts++; + +_func_exit_; + + return ret; + +_recv_entry_drop: + + if (padapter->registrypriv.mp_mode == 1) + padapter->mppriv.rx_pktloss = precvpriv->rx_drop; + +_func_exit_; + + return ret; +} + +void rtw_signal_stat_timer_hdl(RTW_TIMER_HDL_ARGS) +{ + struct adapter *adapter = (struct adapter *)FunctionContext; + struct recv_priv *recvpriv = &adapter->recvpriv; + + u32 tmp_s, tmp_q; + u8 avg_signal_strength = 0; + u8 avg_signal_qual = 0; + u8 _alpha = 3; /* this value is based on converging_constant = 5000 and sampling_interval = 1000 */ + + if (adapter->recvpriv.is_signal_dbg) { + /* update the user specific value, signal_strength_dbg, to signal_strength, rssi */ + adapter->recvpriv.signal_strength = adapter->recvpriv.signal_strength_dbg; + adapter->recvpriv.rssi = (s8)translate_percentage_to_dbm((u8)adapter->recvpriv.signal_strength_dbg); + } else { + if (recvpriv->signal_strength_data.update_req == 0) {/* update_req is clear, means we got rx */ + avg_signal_strength = recvpriv->signal_strength_data.avg_val; + /* after avg_vals are accquired, we can re-stat the signal values */ + recvpriv->signal_strength_data.update_req = 1; + } + + if (recvpriv->signal_qual_data.update_req == 0) {/* update_req is clear, means we got rx */ + avg_signal_qual = recvpriv->signal_qual_data.avg_val; + /* after avg_vals are accquired, we can re-stat the signal values */ + recvpriv->signal_qual_data.update_req = 1; + } + + /* update value of signal_strength, rssi, signal_qual */ + if (check_fwstate(&adapter->mlmepriv, _FW_UNDER_SURVEY) == false) { + tmp_s = (avg_signal_strength+(_alpha-1)*recvpriv->signal_strength); + if (tmp_s % _alpha) + tmp_s = tmp_s/_alpha + 1; + else + tmp_s = tmp_s/_alpha; + if (tmp_s > 100) + tmp_s = 100; + + tmp_q = (avg_signal_qual+(_alpha-1)*recvpriv->signal_qual); + if (tmp_q % _alpha) + tmp_q = tmp_q/_alpha + 1; + else + tmp_q = tmp_q/_alpha; + if (tmp_q > 100) + tmp_q = 100; + + recvpriv->signal_strength = tmp_s; + recvpriv->rssi = (s8)translate_percentage_to_dbm(tmp_s); + recvpriv->signal_qual = tmp_q; + } + } + rtw_set_signal_stat_timer(recvpriv); +} diff --git a/drivers/staging/rtl8188eu/core/rtw_rf.c b/drivers/staging/rtl8188eu/core/rtw_rf.c new file mode 100644 index 0000000000000..1170dd001c1fe --- /dev/null +++ b/drivers/staging/rtl8188eu/core/rtw_rf.c @@ -0,0 +1,89 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTW_RF_C_ + +#include +#include +#include +#include + + +struct ch_freq { + u32 channel; + u32 frequency; +}; + +static struct ch_freq ch_freq_map[] = { + {1, 2412}, {2, 2417}, {3, 2422}, {4, 2427}, {5, 2432}, + {6, 2437}, {7, 2442}, {8, 2447}, {9, 2452}, {10, 2457}, + {11, 2462}, {12, 2467}, {13, 2472}, {14, 2484}, + /* UNII */ + {36, 5180}, {40, 5200}, {44, 5220}, {48, 5240}, {52, 5260}, + {56, 5280}, {60, 5300}, {64, 5320}, {149, 5745}, {153, 5765}, + {157, 5785}, {161, 5805}, {165, 5825}, {167, 5835}, {169, 5845}, + {171, 5855}, {173, 5865}, + /* HiperLAN2 */ + {100, 5500}, {104, 5520}, {108, 5540}, {112, 5560}, {116, 5580}, + {120, 5600}, {124, 5620}, {128, 5640}, {132, 5660}, {136, 5680}, + {140, 5700}, + /* Japan MMAC */ + {34, 5170}, {38, 5190}, {42, 5210}, {46, 5230}, + /* Japan */ + {184, 4920}, {188, 4940}, {192, 4960}, {196, 4980}, + {208, 5040},/* Japan, means J08 */ + {212, 5060},/* Japan, means J12 */ + {216, 5080},/* Japan, means J16 */ +}; + +static int ch_freq_map_num = (sizeof(ch_freq_map) / sizeof(struct ch_freq)); + +u32 rtw_ch2freq(u32 channel) +{ + u8 i; + u32 freq = 0; + + for (i = 0; i < ch_freq_map_num; i++) { + if (channel == ch_freq_map[i].channel) { + freq = ch_freq_map[i].frequency; + break; + } + } + if (i == ch_freq_map_num) + freq = 2412; + + return freq; +} + +u32 rtw_freq2ch(u32 freq) +{ + u8 i; + u32 ch = 0; + + for (i = 0; i < ch_freq_map_num; i++) { + if (freq == ch_freq_map[i].frequency) { + ch = ch_freq_map[i].channel; + break; + } + } + if (i == ch_freq_map_num) + ch = 1; + + return ch; +} -- GitLab From 1b509caf5c7468a300741d76e4c3591f92887822 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 21 Aug 2013 22:33:48 -0500 Subject: [PATCH 764/942] staging: r8188eu: Add files for new driver - part 6 This commit adds core/rtw_security.c, core/rtw_sreset.c, and core/rtw_sta_mgt.c. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_security.c | 1779 +++++++++++++++++ drivers/staging/rtl8188eu/core/rtw_sreset.c | 79 + drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 655 ++++++ 3 files changed, 2513 insertions(+) create mode 100644 drivers/staging/rtl8188eu/core/rtw_security.c create mode 100644 drivers/staging/rtl8188eu/core/rtw_sreset.c create mode 100644 drivers/staging/rtl8188eu/core/rtw_sta_mgt.c diff --git a/drivers/staging/rtl8188eu/core/rtw_security.c b/drivers/staging/rtl8188eu/core/rtw_security.c new file mode 100644 index 0000000000000..0f076d0cb5f85 --- /dev/null +++ b/drivers/staging/rtl8188eu/core/rtw_security.c @@ -0,0 +1,1779 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTW_SECURITY_C_ + +#include +#include +#include +#include + +/* WEP related ===== */ + +#define CRC32_POLY 0x04c11db7 + +struct arc4context { + u32 x; + u32 y; + u8 state[256]; +}; + +static void arcfour_init(struct arc4context *parc4ctx, u8 *key, u32 key_len) +{ + u32 t, u; + u32 keyindex; + u32 stateindex; + u8 *state; + u32 counter; +_func_enter_; + state = parc4ctx->state; + parc4ctx->x = 0; + parc4ctx->y = 0; + for (counter = 0; counter < 256; counter++) + state[counter] = (u8)counter; + keyindex = 0; + stateindex = 0; + for (counter = 0; counter < 256; counter++) { + t = state[counter]; + stateindex = (stateindex + key[keyindex] + t) & 0xff; + u = state[stateindex]; + state[stateindex] = (u8)t; + state[counter] = (u8)u; + if (++keyindex >= key_len) + keyindex = 0; + } +_func_exit_; +} + +static u32 arcfour_byte(struct arc4context *parc4ctx) +{ + u32 x; + u32 y; + u32 sx, sy; + u8 *state; +_func_enter_; + state = parc4ctx->state; + x = (parc4ctx->x + 1) & 0xff; + sx = state[x]; + y = (sx + parc4ctx->y) & 0xff; + sy = state[y]; + parc4ctx->x = x; + parc4ctx->y = y; + state[y] = (u8)sx; + state[x] = (u8)sy; +_func_exit_; + return state[(sx + sy) & 0xff]; +} + +static void arcfour_encrypt(struct arc4context *parc4ctx, u8 *dest, u8 *src, u32 len) +{ + u32 i; +_func_enter_; + for (i = 0; i < len; i++) + dest[i] = src[i] ^ (unsigned char)arcfour_byte(parc4ctx); +_func_exit_; +} + +static int bcrc32initialized; +static u32 crc32_table[256]; + +static u8 crc32_reverseBit(u8 data) +{ + return (u8)((data<<7)&0x80) | ((data<<5)&0x40) | ((data<<3)&0x20) | + ((data<<1)&0x10) | ((data>>1)&0x08) | ((data>>3)&0x04) | + ((data>>5)&0x02) | ((data>>7)&0x01); +} + +static void crc32_init(void) +{ +_func_enter_; + if (bcrc32initialized == 1) { + goto exit; + } else { + int i, j; + u32 c; + u8 *p = (u8 *)&c, *p1; + u8 k; + + c = 0x12340000; + + for (i = 0; i < 256; ++i) { + k = crc32_reverseBit((u8)i); + for (c = ((u32)k) << 24, j = 8; j > 0; --j) + c = c & 0x80000000 ? (c << 1) ^ CRC32_POLY : (c << 1); + p1 = (u8 *)&crc32_table[i]; + + p1[0] = crc32_reverseBit(p[3]); + p1[1] = crc32_reverseBit(p[2]); + p1[2] = crc32_reverseBit(p[1]); + p1[3] = crc32_reverseBit(p[0]); + } + bcrc32initialized = 1; + } +exit: +_func_exit_; +} + +static __le32 getcrc32(u8 *buf, int len) +{ + u8 *p; + u32 crc; +_func_enter_; + if (bcrc32initialized == 0) + crc32_init(); + + crc = 0xffffffff; /* preload shift register, per CRC-32 spec */ + + for (p = buf; len > 0; ++p, --len) + crc = crc32_table[(crc ^ *p) & 0xff] ^ (crc >> 8); +_func_exit_; + return cpu_to_le32(~crc); /* transmit complement, per CRC-32 spec */ +} + +/* + Need to consider the fragment situation +*/ +void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe) +{ /* exclude ICV */ + + unsigned char crc[4]; + struct arc4context mycontext; + + int curfragnum, length; + u32 keylength; + + u8 *pframe, *payload, *iv; /* wepkey */ + u8 wepkey[16]; + u8 hw_hdr_offset = 0; + struct pkt_attrib *pattrib = &((struct xmit_frame *)pxmitframe)->attrib; + struct security_priv *psecuritypriv = &padapter->securitypriv; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + +_func_enter_; + + if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL) + return; + + hw_hdr_offset = TXDESC_SIZE + + (((struct xmit_frame *)pxmitframe)->pkt_offset * PACKET_OFFSET_SZ); + + pframe = ((struct xmit_frame *)pxmitframe)->buf_addr + hw_hdr_offset; + + /* start to encrypt each fragment */ + if ((pattrib->encrypt == _WEP40_) || (pattrib->encrypt == _WEP104_)) { + keylength = psecuritypriv->dot11DefKeylen[psecuritypriv->dot11PrivacyKeyIndex]; + + for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { + iv = pframe+pattrib->hdrlen; + memcpy(&wepkey[0], iv, 3); + memcpy(&wepkey[3], &psecuritypriv->dot11DefKey[psecuritypriv->dot11PrivacyKeyIndex].skey[0], keylength); + payload = pframe+pattrib->iv_len+pattrib->hdrlen; + + if ((curfragnum+1) == pattrib->nr_frags) { /* the last fragment */ + length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; + + *((__le32 *)crc) = getcrc32(payload, length); + + arcfour_init(&mycontext, wepkey, 3+keylength); + arcfour_encrypt(&mycontext, payload, payload, length); + arcfour_encrypt(&mycontext, payload+length, crc, 4); + } else { + length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; + *((__le32 *)crc) = getcrc32(payload, length); + arcfour_init(&mycontext, wepkey, 3+keylength); + arcfour_encrypt(&mycontext, payload, payload, length); + arcfour_encrypt(&mycontext, payload+length, crc, 4); + + pframe += pxmitpriv->frag_len; + pframe = (u8 *)RND4((size_t)(pframe)); + } + } + } + +_func_exit_; +} + +void rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe) +{ + /* exclude ICV */ + u8 crc[4]; + struct arc4context mycontext; + int length; + u32 keylength; + u8 *pframe, *payload, *iv, wepkey[16]; + u8 keyindex; + struct rx_pkt_attrib *prxattrib = &(((union recv_frame *)precvframe)->u.hdr.attrib); + struct security_priv *psecuritypriv = &padapter->securitypriv; + +_func_enter_; + + pframe = (unsigned char *)((union recv_frame *)precvframe)->u.hdr.rx_data; + + /* start to decrypt recvframe */ + if ((prxattrib->encrypt == _WEP40_) || (prxattrib->encrypt == _WEP104_)) { + iv = pframe+prxattrib->hdrlen; + keyindex = prxattrib->key_index; + keylength = psecuritypriv->dot11DefKeylen[keyindex]; + memcpy(&wepkey[0], iv, 3); + memcpy(&wepkey[3], &psecuritypriv->dot11DefKey[keyindex].skey[0], keylength); + length = ((union recv_frame *)precvframe)->u.hdr.len-prxattrib->hdrlen-prxattrib->iv_len; + + payload = pframe+prxattrib->iv_len+prxattrib->hdrlen; + + /* decrypt payload include icv */ + arcfour_init(&mycontext, wepkey, 3+keylength); + arcfour_encrypt(&mycontext, payload, payload, length); + + /* calculate icv and compare the icv */ + *((__le32 *)crc) = getcrc32(payload, length - 4); + + if (crc[3] != payload[length-1] || + crc[2] != payload[length-2] || + crc[1] != payload[length-3] || + crc[0] != payload[length-4]) { + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, + ("rtw_wep_decrypt:icv error crc (%4ph)!=payload (%4ph)\n", + &crc, &payload[length-4])); + } + } +_func_exit_; + return; +} + +/* 3 ===== TKIP related ===== */ + +static u32 secmicgetuint32(u8 *p) +/* Convert from Byte[] to Us3232 in a portable way */ +{ + s32 i; + u32 res = 0; +_func_enter_; + for (i = 0; i < 4; i++) + res |= ((u32)(*p++)) << (8*i); +_func_exit_; + return res; +} + +static void secmicputuint32(u8 *p, u32 val) +/* Convert from Us3232 to Byte[] in a portable way */ +{ + long i; +_func_enter_; + for (i = 0; i < 4; i++) { + *p++ = (u8) (val & 0xff); + val >>= 8; + } +_func_exit_; +} + +static void secmicclear(struct mic_data *pmicdata) +{ +/* Reset the state to the empty message. */ +_func_enter_; + pmicdata->L = pmicdata->K0; + pmicdata->R = pmicdata->K1; + pmicdata->nBytesInM = 0; + pmicdata->M = 0; +_func_exit_; +} + +void rtw_secmicsetkey(struct mic_data *pmicdata, u8 *key) +{ + /* Set the key */ +_func_enter_; + pmicdata->K0 = secmicgetuint32(key); + pmicdata->K1 = secmicgetuint32(key + 4); + /* and reset the message */ + secmicclear(pmicdata); +_func_exit_; +} + +void rtw_secmicappendbyte(struct mic_data *pmicdata, u8 b) +{ +_func_enter_; + /* Append the byte to our word-sized buffer */ + pmicdata->M |= ((unsigned long)b) << (8*pmicdata->nBytesInM); + pmicdata->nBytesInM++; + /* Process the word if it is full. */ + if (pmicdata->nBytesInM >= 4) { + pmicdata->L ^= pmicdata->M; + pmicdata->R ^= ROL32(pmicdata->L, 17); + pmicdata->L += pmicdata->R; + pmicdata->R ^= ((pmicdata->L & 0xff00ff00) >> 8) | ((pmicdata->L & 0x00ff00ff) << 8); + pmicdata->L += pmicdata->R; + pmicdata->R ^= ROL32(pmicdata->L, 3); + pmicdata->L += pmicdata->R; + pmicdata->R ^= ROR32(pmicdata->L, 2); + pmicdata->L += pmicdata->R; + /* Clear the buffer */ + pmicdata->M = 0; + pmicdata->nBytesInM = 0; + } +_func_exit_; +} + +void rtw_secmicappend(struct mic_data *pmicdata, u8 *src, u32 nbytes) +{ +_func_enter_; + /* This is simple */ + while (nbytes > 0) { + rtw_secmicappendbyte(pmicdata, *src++); + nbytes--; + } +_func_exit_; +} + +void rtw_secgetmic(struct mic_data *pmicdata, u8 *dst) +{ +_func_enter_; + /* Append the minimum padding */ + rtw_secmicappendbyte(pmicdata, 0x5a); + rtw_secmicappendbyte(pmicdata, 0); + rtw_secmicappendbyte(pmicdata, 0); + rtw_secmicappendbyte(pmicdata, 0); + rtw_secmicappendbyte(pmicdata, 0); + /* and then zeroes until the length is a multiple of 4 */ + while (pmicdata->nBytesInM != 0) + rtw_secmicappendbyte(pmicdata, 0); + /* The appendByte function has already computed the result. */ + secmicputuint32(dst, pmicdata->L); + secmicputuint32(dst+4, pmicdata->R); + /* Reset to the empty message. */ + secmicclear(pmicdata); +_func_exit_; +} + +void rtw_seccalctkipmic(u8 *key, u8 *header, u8 *data, u32 data_len, u8 *mic_code, u8 pri) +{ + struct mic_data micdata; + u8 priority[4] = {0x0, 0x0, 0x0, 0x0}; +_func_enter_; + rtw_secmicsetkey(&micdata, key); + priority[0] = pri; + + /* Michael MIC pseudo header: DA, SA, 3 x 0, Priority */ + if (header[1]&1) { /* ToDS == 1 */ + rtw_secmicappend(&micdata, &header[16], 6); /* DA */ + if (header[1]&2) /* From Ds == 1 */ + rtw_secmicappend(&micdata, &header[24], 6); + else + rtw_secmicappend(&micdata, &header[10], 6); + } else { /* ToDS == 0 */ + rtw_secmicappend(&micdata, &header[4], 6); /* DA */ + if (header[1]&2) /* From Ds == 1 */ + rtw_secmicappend(&micdata, &header[16], 6); + else + rtw_secmicappend(&micdata, &header[10], 6); + } + rtw_secmicappend(&micdata, &priority[0], 4); + + rtw_secmicappend(&micdata, data, data_len); + + rtw_secgetmic(&micdata, mic_code); +_func_exit_; +} + + + +/* macros for extraction/creation of unsigned char/unsigned short values */ +#define RotR1(v16) ((((v16) >> 1) & 0x7FFF) ^ (((v16) & 1) << 15)) +#define Lo8(v16) ((u8)((v16) & 0x00FF)) +#define Hi8(v16) ((u8)(((v16) >> 8) & 0x00FF)) +#define Lo16(v32) ((u16)((v32) & 0xFFFF)) +#define Hi16(v32) ((u16)(((v32) >> 16) & 0xFFFF)) +#define Mk16(hi, lo) ((lo) ^ (((u16)(hi)) << 8)) + +/* select the Nth 16-bit word of the temporal key unsigned char array TK[] */ +#define TK16(N) Mk16(tk[2*(N)+1], tk[2*(N)]) + +/* S-box lookup: 16 bits --> 16 bits */ +#define _S_(v16) (Sbox1[0][Lo8(v16)] ^ Sbox1[1][Hi8(v16)]) + +/* fixed algorithm "parameters" */ +#define PHASE1_LOOP_CNT 8 /* this needs to be "big enough" */ +#define TA_SIZE 6 /* 48-bit transmitter address */ +#define TK_SIZE 16 /* 128-bit temporal key */ +#define P1K_SIZE 10 /* 80-bit Phase1 key */ +#define RC4_KEY_SIZE 16 /* 128-bit RC4KEY (104 bits unknown) */ + +/* 2-unsigned char by 2-unsigned char subset of the full AES S-box table */ +static const unsigned short Sbox1[2][256] = { /* Sbox for hash (can be in ROM) */ +{ + 0xC6A5, 0xF884, 0xEE99, 0xF68D, 0xFF0D, 0xD6BD, 0xDEB1, 0x9154, + 0x6050, 0x0203, 0xCEA9, 0x567D, 0xE719, 0xB562, 0x4DE6, 0xEC9A, + 0x8F45, 0x1F9D, 0x8940, 0xFA87, 0xEF15, 0xB2EB, 0x8EC9, 0xFB0B, + 0x41EC, 0xB367, 0x5FFD, 0x45EA, 0x23BF, 0x53F7, 0xE496, 0x9B5B, + 0x75C2, 0xE11C, 0x3DAE, 0x4C6A, 0x6C5A, 0x7E41, 0xF502, 0x834F, + 0x685C, 0x51F4, 0xD134, 0xF908, 0xE293, 0xAB73, 0x6253, 0x2A3F, + 0x080C, 0x9552, 0x4665, 0x9D5E, 0x3028, 0x37A1, 0x0A0F, 0x2FB5, + 0x0E09, 0x2436, 0x1B9B, 0xDF3D, 0xCD26, 0x4E69, 0x7FCD, 0xEA9F, + 0x121B, 0x1D9E, 0x5874, 0x342E, 0x362D, 0xDCB2, 0xB4EE, 0x5BFB, + 0xA4F6, 0x764D, 0xB761, 0x7DCE, 0x527B, 0xDD3E, 0x5E71, 0x1397, + 0xA6F5, 0xB968, 0x0000, 0xC12C, 0x4060, 0xE31F, 0x79C8, 0xB6ED, + 0xD4BE, 0x8D46, 0x67D9, 0x724B, 0x94DE, 0x98D4, 0xB0E8, 0x854A, + 0xBB6B, 0xC52A, 0x4FE5, 0xED16, 0x86C5, 0x9AD7, 0x6655, 0x1194, + 0x8ACF, 0xE910, 0x0406, 0xFE81, 0xA0F0, 0x7844, 0x25BA, 0x4BE3, + 0xA2F3, 0x5DFE, 0x80C0, 0x058A, 0x3FAD, 0x21BC, 0x7048, 0xF104, + 0x63DF, 0x77C1, 0xAF75, 0x4263, 0x2030, 0xE51A, 0xFD0E, 0xBF6D, + 0x814C, 0x1814, 0x2635, 0xC32F, 0xBEE1, 0x35A2, 0x88CC, 0x2E39, + 0x9357, 0x55F2, 0xFC82, 0x7A47, 0xC8AC, 0xBAE7, 0x322B, 0xE695, + 0xC0A0, 0x1998, 0x9ED1, 0xA37F, 0x4466, 0x547E, 0x3BAB, 0x0B83, + 0x8CCA, 0xC729, 0x6BD3, 0x283C, 0xA779, 0xBCE2, 0x161D, 0xAD76, + 0xDB3B, 0x6456, 0x744E, 0x141E, 0x92DB, 0x0C0A, 0x486C, 0xB8E4, + 0x9F5D, 0xBD6E, 0x43EF, 0xC4A6, 0x39A8, 0x31A4, 0xD337, 0xF28B, + 0xD532, 0x8B43, 0x6E59, 0xDAB7, 0x018C, 0xB164, 0x9CD2, 0x49E0, + 0xD8B4, 0xACFA, 0xF307, 0xCF25, 0xCAAF, 0xF48E, 0x47E9, 0x1018, + 0x6FD5, 0xF088, 0x4A6F, 0x5C72, 0x3824, 0x57F1, 0x73C7, 0x9751, + 0xCB23, 0xA17C, 0xE89C, 0x3E21, 0x96DD, 0x61DC, 0x0D86, 0x0F85, + 0xE090, 0x7C42, 0x71C4, 0xCCAA, 0x90D8, 0x0605, 0xF701, 0x1C12, + 0xC2A3, 0x6A5F, 0xAEF9, 0x69D0, 0x1791, 0x9958, 0x3A27, 0x27B9, + 0xD938, 0xEB13, 0x2BB3, 0x2233, 0xD2BB, 0xA970, 0x0789, 0x33A7, + 0x2DB6, 0x3C22, 0x1592, 0xC920, 0x8749, 0xAAFF, 0x5078, 0xA57A, + 0x038F, 0x59F8, 0x0980, 0x1A17, 0x65DA, 0xD731, 0x84C6, 0xD0B8, + 0x82C3, 0x29B0, 0x5A77, 0x1E11, 0x7BCB, 0xA8FC, 0x6DD6, 0x2C3A, + }, + + { /* second half of table is unsigned char-reversed version of first! */ + 0xA5C6, 0x84F8, 0x99EE, 0x8DF6, 0x0DFF, 0xBDD6, 0xB1DE, 0x5491, + 0x5060, 0x0302, 0xA9CE, 0x7D56, 0x19E7, 0x62B5, 0xE64D, 0x9AEC, + 0x458F, 0x9D1F, 0x4089, 0x87FA, 0x15EF, 0xEBB2, 0xC98E, 0x0BFB, + 0xEC41, 0x67B3, 0xFD5F, 0xEA45, 0xBF23, 0xF753, 0x96E4, 0x5B9B, + 0xC275, 0x1CE1, 0xAE3D, 0x6A4C, 0x5A6C, 0x417E, 0x02F5, 0x4F83, + 0x5C68, 0xF451, 0x34D1, 0x08F9, 0x93E2, 0x73AB, 0x5362, 0x3F2A, + 0x0C08, 0x5295, 0x6546, 0x5E9D, 0x2830, 0xA137, 0x0F0A, 0xB52F, + 0x090E, 0x3624, 0x9B1B, 0x3DDF, 0x26CD, 0x694E, 0xCD7F, 0x9FEA, + 0x1B12, 0x9E1D, 0x7458, 0x2E34, 0x2D36, 0xB2DC, 0xEEB4, 0xFB5B, + 0xF6A4, 0x4D76, 0x61B7, 0xCE7D, 0x7B52, 0x3EDD, 0x715E, 0x9713, + 0xF5A6, 0x68B9, 0x0000, 0x2CC1, 0x6040, 0x1FE3, 0xC879, 0xEDB6, + 0xBED4, 0x468D, 0xD967, 0x4B72, 0xDE94, 0xD498, 0xE8B0, 0x4A85, + 0x6BBB, 0x2AC5, 0xE54F, 0x16ED, 0xC586, 0xD79A, 0x5566, 0x9411, + 0xCF8A, 0x10E9, 0x0604, 0x81FE, 0xF0A0, 0x4478, 0xBA25, 0xE34B, + 0xF3A2, 0xFE5D, 0xC080, 0x8A05, 0xAD3F, 0xBC21, 0x4870, 0x04F1, + 0xDF63, 0xC177, 0x75AF, 0x6342, 0x3020, 0x1AE5, 0x0EFD, 0x6DBF, + 0x4C81, 0x1418, 0x3526, 0x2FC3, 0xE1BE, 0xA235, 0xCC88, 0x392E, + 0x5793, 0xF255, 0x82FC, 0x477A, 0xACC8, 0xE7BA, 0x2B32, 0x95E6, + 0xA0C0, 0x9819, 0xD19E, 0x7FA3, 0x6644, 0x7E54, 0xAB3B, 0x830B, + 0xCA8C, 0x29C7, 0xD36B, 0x3C28, 0x79A7, 0xE2BC, 0x1D16, 0x76AD, + 0x3BDB, 0x5664, 0x4E74, 0x1E14, 0xDB92, 0x0A0C, 0x6C48, 0xE4B8, + 0x5D9F, 0x6EBD, 0xEF43, 0xA6C4, 0xA839, 0xA431, 0x37D3, 0x8BF2, + 0x32D5, 0x438B, 0x596E, 0xB7DA, 0x8C01, 0x64B1, 0xD29C, 0xE049, + 0xB4D8, 0xFAAC, 0x07F3, 0x25CF, 0xAFCA, 0x8EF4, 0xE947, 0x1810, + 0xD56F, 0x88F0, 0x6F4A, 0x725C, 0x2438, 0xF157, 0xC773, 0x5197, + 0x23CB, 0x7CA1, 0x9CE8, 0x213E, 0xDD96, 0xDC61, 0x860D, 0x850F, + 0x90E0, 0x427C, 0xC471, 0xAACC, 0xD890, 0x0506, 0x01F7, 0x121C, + 0xA3C2, 0x5F6A, 0xF9AE, 0xD069, 0x9117, 0x5899, 0x273A, 0xB927, + 0x38D9, 0x13EB, 0xB32B, 0x3322, 0xBBD2, 0x70A9, 0x8907, 0xA733, + 0xB62D, 0x223C, 0x9215, 0x20C9, 0x4987, 0xFFAA, 0x7850, 0x7AA5, + 0x8F03, 0xF859, 0x8009, 0x171A, 0xDA65, 0x31D7, 0xC684, 0xB8D0, + 0xC382, 0xB029, 0x775A, 0x111E, 0xCB7B, 0xFCA8, 0xD66D, 0x3A2C, + } +}; + + /* +********************************************************************** +* Routine: Phase 1 -- generate P1K, given TA, TK, IV32 +* +* Inputs: +* tk[] = temporal key [128 bits] +* ta[] = transmitter's MAC address [ 48 bits] +* iv32 = upper 32 bits of IV [ 32 bits] +* Output: +* p1k[] = Phase 1 key [ 80 bits] +* +* Note: +* This function only needs to be called every 2**16 packets, +* although in theory it could be called every packet. +* +********************************************************************** +*/ +static void phase1(u16 *p1k, const u8 *tk, const u8 *ta, u32 iv32) +{ + int i; +_func_enter_; + /* Initialize the 80 bits of P1K[] from IV32 and TA[0..5] */ + p1k[0] = Lo16(iv32); + p1k[1] = Hi16(iv32); + p1k[2] = Mk16(ta[1], ta[0]); /* use TA[] as little-endian */ + p1k[3] = Mk16(ta[3], ta[2]); + p1k[4] = Mk16(ta[5], ta[4]); + + /* Now compute an unbalanced Feistel cipher with 80-bit block */ + /* size on the 80-bit block P1K[], using the 128-bit key TK[] */ + for (i = 0; i < PHASE1_LOOP_CNT; i++) { /* Each add operation here is mod 2**16 */ + p1k[0] += _S_(p1k[4] ^ TK16((i&1)+0)); + p1k[1] += _S_(p1k[0] ^ TK16((i&1)+2)); + p1k[2] += _S_(p1k[1] ^ TK16((i&1)+4)); + p1k[3] += _S_(p1k[2] ^ TK16((i&1)+6)); + p1k[4] += _S_(p1k[3] ^ TK16((i&1)+0)); + p1k[4] += (unsigned short)i; /* avoid "slide attacks" */ + } +_func_exit_; +} + +/* +********************************************************************** +* Routine: Phase 2 -- generate RC4KEY, given TK, P1K, IV16 +* +* Inputs: +* tk[] = Temporal key [128 bits] +* p1k[] = Phase 1 output key [ 80 bits] +* iv16 = low 16 bits of IV counter [ 16 bits] +* Output: +* rc4key[] = the key used to encrypt the packet [128 bits] +* +* Note: +* The value {TA, IV32, IV16} for Phase1/Phase2 must be unique +* across all packets using the same key TK value. Then, for a +* given value of TK[], this TKIP48 construction guarantees that +* the final RC4KEY value is unique across all packets. +* +* Suggested implementation optimization: if PPK[] is "overlaid" +* appropriately on RC4KEY[], there is no need for the final +* for loop below that copies the PPK[] result into RC4KEY[]. +* +********************************************************************** +*/ +static void phase2(u8 *rc4key, const u8 *tk, const u16 *p1k, u16 iv16) +{ + int i; + u16 PPK[6]; /* temporary key for mixing */ +_func_enter_; + /* Note: all adds in the PPK[] equations below are mod 2**16 */ + for (i = 0; i < 5; i++) + PPK[i] = p1k[i]; /* first, copy P1K to PPK */ + PPK[5] = p1k[4] + iv16; /* next, add in IV16 */ + + /* Bijective non-linear mixing of the 96 bits of PPK[0..5] */ + PPK[0] += _S_(PPK[5] ^ TK16(0)); /* Mix key in each "round" */ + PPK[1] += _S_(PPK[0] ^ TK16(1)); + PPK[2] += _S_(PPK[1] ^ TK16(2)); + PPK[3] += _S_(PPK[2] ^ TK16(3)); + PPK[4] += _S_(PPK[3] ^ TK16(4)); + PPK[5] += _S_(PPK[4] ^ TK16(5)); /* Total # S-box lookups == 6 */ + + /* Final sweep: bijective, "linear". Rotates kill LSB correlations */ + PPK[0] += RotR1(PPK[5] ^ TK16(6)); + PPK[1] += RotR1(PPK[0] ^ TK16(7)); /* Use all of TK[] in Phase2 */ + PPK[2] += RotR1(PPK[1]); + PPK[3] += RotR1(PPK[2]); + PPK[4] += RotR1(PPK[3]); + PPK[5] += RotR1(PPK[4]); + /* Note: At this point, for a given key TK[0..15], the 96-bit output */ + /* value PPK[0..5] is guaranteed to be unique, as a function */ + /* of the 96-bit "input" value {TA, IV32, IV16}. That is, P1K */ + /* is now a keyed permutation of {TA, IV32, IV16}. */ + + /* Set RC4KEY[0..3], which includes "cleartext" portion of RC4 key */ + rc4key[0] = Hi8(iv16); /* RC4KEY[0..2] is the WEP IV */ + rc4key[1] = (Hi8(iv16) | 0x20) & 0x7F; /* Help avoid weak (FMS) keys */ + rc4key[2] = Lo8(iv16); + rc4key[3] = Lo8((PPK[5] ^ TK16(0)) >> 1); + + /* Copy 96 bits of PPK[0..5] to RC4KEY[4..15] (little-endian) */ + for (i = 0; i < 6; i++) { + rc4key[4+2*i] = Lo8(PPK[i]); + rc4key[5+2*i] = Hi8(PPK[i]); + } +_func_exit_; +} + +/* The hlen isn't include the IV */ +u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe) +{ /* exclude ICV */ + u16 pnl; + u32 pnh; + u8 rc4key[16]; + u8 ttkey[16]; + u8 crc[4]; + u8 hw_hdr_offset = 0; + struct arc4context mycontext; + int curfragnum, length; + + u8 *pframe, *payload, *iv, *prwskey; + union pn48 dot11txpn; + struct sta_info *stainfo; + struct pkt_attrib *pattrib = &((struct xmit_frame *)pxmitframe)->attrib; + struct security_priv *psecuritypriv = &padapter->securitypriv; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + u32 res = _SUCCESS; +_func_enter_; + + if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL) + return _FAIL; + + hw_hdr_offset = TXDESC_SIZE + + (((struct xmit_frame *)pxmitframe)->pkt_offset * PACKET_OFFSET_SZ); + pframe = ((struct xmit_frame *)pxmitframe)->buf_addr + hw_hdr_offset; + /* 4 start to encrypt each fragment */ + if (pattrib->encrypt == _TKIP_) { + if (pattrib->psta) + stainfo = pattrib->psta; + else + stainfo = rtw_get_stainfo(&padapter->stapriv, &pattrib->ra[0]); + + if (stainfo != NULL) { + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_tkip_encrypt: stainfo!= NULL!!!\n")); + + if (IS_MCAST(pattrib->ra)) + prwskey = psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey; + else + prwskey = &stainfo->dot118021x_UncstKey.skey[0]; + + for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { + iv = pframe+pattrib->hdrlen; + payload = pframe+pattrib->iv_len+pattrib->hdrlen; + + GET_TKIP_PN(iv, dot11txpn); + + pnl = (u16)(dot11txpn.val); + pnh = (u32)(dot11txpn.val>>16); + phase1((u16 *)&ttkey[0], prwskey, &pattrib->ta[0], pnh); + phase2(&rc4key[0], prwskey, (u16 *)&ttkey[0], pnl); + + if ((curfragnum+1) == pattrib->nr_frags) { /* 4 the last fragment */ + length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; + RT_TRACE(_module_rtl871x_security_c_, _drv_info_, + ("pattrib->iv_len=%x, pattrib->icv_len=%x\n", + pattrib->iv_len, pattrib->icv_len)); + *((__le32 *)crc) = getcrc32(payload, length);/* modified by Amy*/ + + arcfour_init(&mycontext, rc4key, 16); + arcfour_encrypt(&mycontext, payload, payload, length); + arcfour_encrypt(&mycontext, payload+length, crc, 4); + } else { + length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len ; + *((__le32 *)crc) = getcrc32(payload, length);/* modified by Amy*/ + arcfour_init(&mycontext, rc4key, 16); + arcfour_encrypt(&mycontext, payload, payload, length); + arcfour_encrypt(&mycontext, payload+length, crc, 4); + + pframe += pxmitpriv->frag_len; + pframe = (u8 *)RND4((size_t)(pframe)); + } + } + } else { + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_tkip_encrypt: stainfo==NULL!!!\n")); + res = _FAIL; + } + } +_func_exit_; + return res; +} + +/* The hlen isn't include the IV */ +u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe) +{ /* exclude ICV */ + u16 pnl; + u32 pnh; + u8 rc4key[16]; + u8 ttkey[16]; + u8 crc[4]; + struct arc4context mycontext; + int length; + + u8 *pframe, *payload, *iv, *prwskey; + union pn48 dot11txpn; + struct sta_info *stainfo; + struct rx_pkt_attrib *prxattrib = &((union recv_frame *)precvframe)->u.hdr.attrib; + struct security_priv *psecuritypriv = &padapter->securitypriv; + u32 res = _SUCCESS; + +_func_enter_; + + pframe = (unsigned char *)((union recv_frame *)precvframe)->u.hdr.rx_data; + + /* 4 start to decrypt recvframe */ + if (prxattrib->encrypt == _TKIP_) { + stainfo = rtw_get_stainfo(&padapter->stapriv, &prxattrib->ta[0]); + if (stainfo != NULL) { + if (IS_MCAST(prxattrib->ra)) { + if (!psecuritypriv->binstallGrpkey) { + res = _FAIL; + DBG_88E("%s:rx bc/mc packets, but didn't install group key!!!!!!!!!!\n", __func__); + goto exit; + } + prwskey = psecuritypriv->dot118021XGrpKey[prxattrib->key_index].skey; + } else { + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_tkip_decrypt: stainfo!= NULL!!!\n")); + prwskey = &stainfo->dot118021x_UncstKey.skey[0]; + } + + iv = pframe+prxattrib->hdrlen; + payload = pframe+prxattrib->iv_len+prxattrib->hdrlen; + length = ((union recv_frame *)precvframe)->u.hdr.len-prxattrib->hdrlen-prxattrib->iv_len; + + GET_TKIP_PN(iv, dot11txpn); + + pnl = (u16)(dot11txpn.val); + pnh = (u32)(dot11txpn.val>>16); + + phase1((u16 *)&ttkey[0], prwskey, &prxattrib->ta[0], pnh); + phase2(&rc4key[0], prwskey, (unsigned short *)&ttkey[0], pnl); + + /* 4 decrypt payload include icv */ + + arcfour_init(&mycontext, rc4key, 16); + arcfour_encrypt(&mycontext, payload, payload, length); + + *((__le32 *)crc) = getcrc32(payload, length-4); + + if (crc[3] != payload[length-1] || + crc[2] != payload[length-2] || + crc[1] != payload[length-3] || + crc[0] != payload[length-4]) { + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, + ("rtw_wep_decrypt:icv error crc (%4ph)!=payload (%4ph)\n", + &crc, &payload[length-4])); + res = _FAIL; + } + } else { + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_tkip_decrypt: stainfo==NULL!!!\n")); + res = _FAIL; + } + } +_func_exit_; +exit: + return res; +} + +/* 3 ===== AES related ===== */ + + +#define MAX_MSG_SIZE 2048 +/*****************************/ +/******** SBOX Table *********/ +/*****************************/ + +static u8 sbox_table[256] = { + 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, + 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, + 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, + 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, + 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, + 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, + 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, + 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, + 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, + 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, + 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, + 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, + 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, + 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, + 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, + 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, + 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, + 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, + 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, + 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, + 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, + 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, + 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, + 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, + 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, + 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, + 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, + 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, + 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, + 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, + 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, + 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 +}; + +/*****************************/ +/**** Function Prototypes ****/ +/*****************************/ + +static void bitwise_xor(u8 *ina, u8 *inb, u8 *out); +static void construct_mic_iv(u8 *mic_header1, int qc_exists, int a4_exists, u8 *mpdu, uint payload_length, u8 *pn_vector); +static void construct_mic_header1(u8 *mic_header1, int header_length, u8 *mpdu); +static void construct_mic_header2(u8 *mic_header2, u8 *mpdu, int a4_exists, int qc_exists); +static void construct_ctr_preload(u8 *ctr_preload, int a4_exists, int qc_exists, u8 *mpdu, u8 *pn_vector, int c); +static void xor_128(u8 *a, u8 *b, u8 *out); +static void xor_32(u8 *a, u8 *b, u8 *out); +static u8 sbox(u8 a); +static void next_key(u8 *key, int round); +static void byte_sub(u8 *in, u8 *out); +static void shift_row(u8 *in, u8 *out); +static void mix_column(u8 *in, u8 *out); +static void aes128k128d(u8 *key, u8 *data, u8 *ciphertext); + +/****************************************/ +/* aes128k128d() */ +/* Performs a 128 bit AES encrypt with */ +/* 128 bit data. */ +/****************************************/ +static void xor_128(u8 *a, u8 *b, u8 *out) +{ + int i; +_func_enter_; + for (i = 0; i < 16; i++) + out[i] = a[i] ^ b[i]; +_func_exit_; +} + +static void xor_32(u8 *a, u8 *b, u8 *out) +{ + int i; +_func_enter_; + for (i = 0; i < 4; i++) + out[i] = a[i] ^ b[i]; +_func_exit_; +} + +static u8 sbox(u8 a) +{ + return sbox_table[(int)a]; +} + +static void next_key(u8 *key, int round) +{ + u8 rcon; + u8 sbox_key[4]; + u8 rcon_table[12] = { + 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, + 0x1b, 0x36, 0x36, 0x36 + }; +_func_enter_; + sbox_key[0] = sbox(key[13]); + sbox_key[1] = sbox(key[14]); + sbox_key[2] = sbox(key[15]); + sbox_key[3] = sbox(key[12]); + + rcon = rcon_table[round]; + + xor_32(&key[0], sbox_key, &key[0]); + key[0] = key[0] ^ rcon; + + xor_32(&key[4], &key[0], &key[4]); + xor_32(&key[8], &key[4], &key[8]); + xor_32(&key[12], &key[8], &key[12]); +_func_exit_; +} + +static void byte_sub(u8 *in, u8 *out) +{ + int i; +_func_enter_; + for (i = 0; i < 16; i++) + out[i] = sbox(in[i]); +_func_exit_; +} + +static void shift_row(u8 *in, u8 *out) +{ +_func_enter_; + out[0] = in[0]; + out[1] = in[5]; + out[2] = in[10]; + out[3] = in[15]; + out[4] = in[4]; + out[5] = in[9]; + out[6] = in[14]; + out[7] = in[3]; + out[8] = in[8]; + out[9] = in[13]; + out[10] = in[2]; + out[11] = in[7]; + out[12] = in[12]; + out[13] = in[1]; + out[14] = in[6]; + out[15] = in[11]; +_func_exit_; +} + +static void mix_column(u8 *in, u8 *out) +{ + int i; + u8 add1b[4]; + u8 add1bf7[4]; + u8 rotl[4]; + u8 swap_halfs[4]; + u8 andf7[4]; + u8 rotr[4]; + u8 temp[4]; + u8 tempb[4]; +_func_enter_; + for (i = 0 ; i < 4; i++) { + if ((in[i] & 0x80) == 0x80) + add1b[i] = 0x1b; + else + add1b[i] = 0x00; + } + + swap_halfs[0] = in[2]; /* Swap halfs */ + swap_halfs[1] = in[3]; + swap_halfs[2] = in[0]; + swap_halfs[3] = in[1]; + + rotl[0] = in[3]; /* Rotate left 8 bits */ + rotl[1] = in[0]; + rotl[2] = in[1]; + rotl[3] = in[2]; + + andf7[0] = in[0] & 0x7f; + andf7[1] = in[1] & 0x7f; + andf7[2] = in[2] & 0x7f; + andf7[3] = in[3] & 0x7f; + + for (i = 3; i > 0; i--) { /* logical shift left 1 bit */ + andf7[i] = andf7[i] << 1; + if ((andf7[i-1] & 0x80) == 0x80) + andf7[i] = (andf7[i] | 0x01); + } + andf7[0] = andf7[0] << 1; + andf7[0] = andf7[0] & 0xfe; + + xor_32(add1b, andf7, add1bf7); + + xor_32(in, add1bf7, rotr); + + temp[0] = rotr[0]; /* Rotate right 8 bits */ + rotr[0] = rotr[1]; + rotr[1] = rotr[2]; + rotr[2] = rotr[3]; + rotr[3] = temp[0]; + + xor_32(add1bf7, rotr, temp); + xor_32(swap_halfs, rotl, tempb); + xor_32(temp, tempb, out); +_func_exit_; +} + +static void aes128k128d(u8 *key, u8 *data, u8 *ciphertext) +{ + int round; + int i; + u8 intermediatea[16]; + u8 intermediateb[16]; + u8 round_key[16]; +_func_enter_; + for (i = 0; i < 16; i++) + round_key[i] = key[i]; + for (round = 0; round < 11; round++) { + if (round == 0) { + xor_128(round_key, data, ciphertext); + next_key(round_key, round); + } else if (round == 10) { + byte_sub(ciphertext, intermediatea); + shift_row(intermediatea, intermediateb); + xor_128(intermediateb, round_key, ciphertext); + } else { /* 1 - 9 */ + byte_sub(ciphertext, intermediatea); + shift_row(intermediatea, intermediateb); + mix_column(&intermediateb[0], &intermediatea[0]); + mix_column(&intermediateb[4], &intermediatea[4]); + mix_column(&intermediateb[8], &intermediatea[8]); + mix_column(&intermediateb[12], &intermediatea[12]); + xor_128(intermediatea, round_key, ciphertext); + next_key(round_key, round); + } + } +_func_exit_; +} + +/************************************************/ +/* construct_mic_iv() */ +/* Builds the MIC IV from header fields and PN */ +/************************************************/ +static void construct_mic_iv(u8 *mic_iv, int qc_exists, int a4_exists, u8 *mpdu, + uint payload_length, u8 *pn_vector) +{ + int i; +_func_enter_; + mic_iv[0] = 0x59; + if (qc_exists && a4_exists) + mic_iv[1] = mpdu[30] & 0x0f; /* QoS_TC */ + if (qc_exists && !a4_exists) + mic_iv[1] = mpdu[24] & 0x0f; /* mute bits 7-4 */ + if (!qc_exists) + mic_iv[1] = 0x00; + for (i = 2; i < 8; i++) + mic_iv[i] = mpdu[i + 8]; /* mic_iv[2:7] = A2[0:5] = mpdu[10:15] */ + for (i = 8; i < 14; i++) + mic_iv[i] = pn_vector[13 - i]; /* mic_iv[8:13] = PN[5:0] */ + mic_iv[14] = (unsigned char) (payload_length / 256); + mic_iv[15] = (unsigned char) (payload_length % 256); +_func_exit_; +} + +/************************************************/ +/* construct_mic_header1() */ +/* Builds the first MIC header block from */ +/* header fields. */ +/************************************************/ +static void construct_mic_header1(u8 *mic_header1, int header_length, u8 *mpdu) +{ +_func_enter_; + mic_header1[0] = (u8)((header_length - 2) / 256); + mic_header1[1] = (u8)((header_length - 2) % 256); + mic_header1[2] = mpdu[0] & 0xcf; /* Mute CF poll & CF ack bits */ + mic_header1[3] = mpdu[1] & 0xc7; /* Mute retry, more data and pwr mgt bits */ + mic_header1[4] = mpdu[4]; /* A1 */ + mic_header1[5] = mpdu[5]; + mic_header1[6] = mpdu[6]; + mic_header1[7] = mpdu[7]; + mic_header1[8] = mpdu[8]; + mic_header1[9] = mpdu[9]; + mic_header1[10] = mpdu[10]; /* A2 */ + mic_header1[11] = mpdu[11]; + mic_header1[12] = mpdu[12]; + mic_header1[13] = mpdu[13]; + mic_header1[14] = mpdu[14]; + mic_header1[15] = mpdu[15]; +_func_exit_; +} + +/************************************************/ +/* construct_mic_header2() */ +/* Builds the last MIC header block from */ +/* header fields. */ +/************************************************/ +static void construct_mic_header2(u8 *mic_header2, u8 *mpdu, int a4_exists, int qc_exists) +{ + int i; +_func_enter_; + for (i = 0; i < 16; i++) + mic_header2[i] = 0x00; + + mic_header2[0] = mpdu[16]; /* A3 */ + mic_header2[1] = mpdu[17]; + mic_header2[2] = mpdu[18]; + mic_header2[3] = mpdu[19]; + mic_header2[4] = mpdu[20]; + mic_header2[5] = mpdu[21]; + + mic_header2[6] = 0x00; + mic_header2[7] = 0x00; /* mpdu[23]; */ + + if (!qc_exists && a4_exists) { + for (i = 0; i < 6; i++) + mic_header2[8+i] = mpdu[24+i]; /* A4 */ + } + + if (qc_exists && !a4_exists) { + mic_header2[8] = mpdu[24] & 0x0f; /* mute bits 15 - 4 */ + mic_header2[9] = mpdu[25] & 0x00; + } + + if (qc_exists && a4_exists) { + for (i = 0; i < 6; i++) + mic_header2[8+i] = mpdu[24+i]; /* A4 */ + + mic_header2[14] = mpdu[30] & 0x0f; + mic_header2[15] = mpdu[31] & 0x00; + } + +_func_exit_; +} + +/************************************************/ +/* construct_mic_header2() */ +/* Builds the last MIC header block from */ +/* header fields. */ +/************************************************/ +static void construct_ctr_preload(u8 *ctr_preload, int a4_exists, int qc_exists, u8 *mpdu, u8 *pn_vector, int c) +{ + int i; +_func_enter_; + for (i = 0; i < 16; i++) + ctr_preload[i] = 0x00; + i = 0; + + ctr_preload[0] = 0x01; /* flag */ + if (qc_exists && a4_exists) + ctr_preload[1] = mpdu[30] & 0x0f; /* QoC_Control */ + if (qc_exists && !a4_exists) + ctr_preload[1] = mpdu[24] & 0x0f; + + for (i = 2; i < 8; i++) + ctr_preload[i] = mpdu[i + 8]; /* ctr_preload[2:7] = A2[0:5] = mpdu[10:15] */ + for (i = 8; i < 14; i++) + ctr_preload[i] = pn_vector[13 - i]; /* ctr_preload[8:13] = PN[5:0] */ + ctr_preload[14] = (unsigned char) (c / 256); /* Ctr */ + ctr_preload[15] = (unsigned char) (c % 256); +_func_exit_; +} + +/************************************/ +/* bitwise_xor() */ +/* A 128 bit, bitwise exclusive or */ +/************************************/ +static void bitwise_xor(u8 *ina, u8 *inb, u8 *out) +{ + int i; +_func_enter_; + for (i = 0; i < 16; i++) + out[i] = ina[i] ^ inb[i]; +_func_exit_; +} + +static int aes_cipher(u8 *key, uint hdrlen, u8 *pframe, uint plen) +{ + uint qc_exists, a4_exists, i, j, payload_remainder, + num_blocks, payload_index; + + u8 pn_vector[6]; + u8 mic_iv[16]; + u8 mic_header1[16]; + u8 mic_header2[16]; + u8 ctr_preload[16]; + + /* Intermediate Buffers */ + u8 chain_buffer[16]; + u8 aes_out[16]; + u8 padded_buffer[16]; + u8 mic[8]; + uint frtype = GetFrameType(pframe); + uint frsubtype = GetFrameSubType(pframe); + +_func_enter_; + frsubtype = frsubtype>>4; + + _rtw_memset((void *)mic_iv, 0, 16); + _rtw_memset((void *)mic_header1, 0, 16); + _rtw_memset((void *)mic_header2, 0, 16); + _rtw_memset((void *)ctr_preload, 0, 16); + _rtw_memset((void *)chain_buffer, 0, 16); + _rtw_memset((void *)aes_out, 0, 16); + _rtw_memset((void *)padded_buffer, 0, 16); + + if ((hdrlen == WLAN_HDR_A3_LEN) || (hdrlen == WLAN_HDR_A3_QOS_LEN)) + a4_exists = 0; + else + a4_exists = 1; + + if ((frtype == WIFI_DATA_CFACK) || (frtype == WIFI_DATA_CFPOLL) || (frtype == WIFI_DATA_CFACKPOLL)) { + qc_exists = 1; + if (hdrlen != WLAN_HDR_A3_QOS_LEN) + hdrlen += 2; + } else if ((frsubtype == 0x08) || (frsubtype == 0x09) || (frsubtype == 0x0a) || (frsubtype == 0x0b)) { + if (hdrlen != WLAN_HDR_A3_QOS_LEN) + hdrlen += 2; + qc_exists = 1; + } else { + qc_exists = 0; + } + + pn_vector[0] = pframe[hdrlen]; + pn_vector[1] = pframe[hdrlen+1]; + pn_vector[2] = pframe[hdrlen+4]; + pn_vector[3] = pframe[hdrlen+5]; + pn_vector[4] = pframe[hdrlen+6]; + pn_vector[5] = pframe[hdrlen+7]; + + construct_mic_iv(mic_iv, qc_exists, a4_exists, pframe, plen, pn_vector); + + construct_mic_header1(mic_header1, hdrlen, pframe); + construct_mic_header2(mic_header2, pframe, a4_exists, qc_exists); + + payload_remainder = plen % 16; + num_blocks = plen / 16; + + /* Find start of payload */ + payload_index = (hdrlen + 8); + + /* Calculate MIC */ + aes128k128d(key, mic_iv, aes_out); + bitwise_xor(aes_out, mic_header1, chain_buffer); + aes128k128d(key, chain_buffer, aes_out); + bitwise_xor(aes_out, mic_header2, chain_buffer); + aes128k128d(key, chain_buffer, aes_out); + + for (i = 0; i < num_blocks; i++) { + bitwise_xor(aes_out, &pframe[payload_index], chain_buffer);/* bitwise_xor(aes_out, &message[payload_index], chain_buffer); */ + + payload_index += 16; + aes128k128d(key, chain_buffer, aes_out); + } + + /* Add on the final payload block if it needs padding */ + if (payload_remainder > 0) { + for (j = 0; j < 16; j++) + padded_buffer[j] = 0x00; + for (j = 0; j < payload_remainder; j++) + padded_buffer[j] = pframe[payload_index++];/* padded_buffer[j] = message[payload_index++]; */ + bitwise_xor(aes_out, padded_buffer, chain_buffer); + aes128k128d(key, chain_buffer, aes_out); + } + + for (j = 0; j < 8; j++) + mic[j] = aes_out[j]; + + /* Insert MIC into payload */ + for (j = 0; j < 8; j++) + pframe[payload_index+j] = mic[j]; /* message[payload_index+j] = mic[j]; */ + + payload_index = hdrlen + 8; + for (i = 0; i < num_blocks; i++) { + construct_ctr_preload(ctr_preload, a4_exists, qc_exists, pframe, pn_vector, i+1); + aes128k128d(key, ctr_preload, aes_out); + bitwise_xor(aes_out, &pframe[payload_index], chain_buffer); + for (j = 0; j < 16; j++) + pframe[payload_index++] = chain_buffer[j]; + } + + if (payload_remainder > 0) { /* If there is a short final block, then pad it,*/ + /* encrypt it and copy the unpadded part back */ + construct_ctr_preload(ctr_preload, a4_exists, qc_exists, pframe, pn_vector, num_blocks+1); + + for (j = 0; j < 16; j++) + padded_buffer[j] = 0x00; + for (j = 0; j < payload_remainder; j++) + padded_buffer[j] = pframe[payload_index+j]; + aes128k128d(key, ctr_preload, aes_out); + bitwise_xor(aes_out, padded_buffer, chain_buffer); + for (j = 0; j < payload_remainder; j++) + pframe[payload_index++] = chain_buffer[j]; + } + /* Encrypt the MIC */ + construct_ctr_preload(ctr_preload, a4_exists, qc_exists, pframe, pn_vector, 0); + + for (j = 0; j < 16; j++) + padded_buffer[j] = 0x00; + for (j = 0; j < 8; j++) + padded_buffer[j] = pframe[j+hdrlen+8+plen]; + + aes128k128d(key, ctr_preload, aes_out); + bitwise_xor(aes_out, padded_buffer, chain_buffer); + for (j = 0; j < 8; j++) + pframe[payload_index++] = chain_buffer[j]; +_func_exit_; + return _SUCCESS; +} + +u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe) +{ /* exclude ICV */ + + /*static*/ +/* unsigned char message[MAX_MSG_SIZE]; */ + + /* Intermediate Buffers */ + int curfragnum, length; + u8 *pframe, *prwskey; /* *payload,*iv */ + u8 hw_hdr_offset = 0; + struct sta_info *stainfo; + struct pkt_attrib *pattrib = &((struct xmit_frame *)pxmitframe)->attrib; + struct security_priv *psecuritypriv = &padapter->securitypriv; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + +/* uint offset = 0; */ + u32 res = _SUCCESS; +_func_enter_; + + if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL) + return _FAIL; + + hw_hdr_offset = TXDESC_SIZE + + (((struct xmit_frame *)pxmitframe)->pkt_offset * PACKET_OFFSET_SZ); + + pframe = ((struct xmit_frame *)pxmitframe)->buf_addr + hw_hdr_offset; + + /* 4 start to encrypt each fragment */ + if ((pattrib->encrypt == _AES_)) { + if (pattrib->psta) + stainfo = pattrib->psta; + else + stainfo = rtw_get_stainfo(&padapter->stapriv, &pattrib->ra[0]); + + if (stainfo != NULL) { + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_aes_encrypt: stainfo!= NULL!!!\n")); + + if (IS_MCAST(pattrib->ra)) + prwskey = psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey; + else + prwskey = &stainfo->dot118021x_UncstKey.skey[0]; + for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { + if ((curfragnum+1) == pattrib->nr_frags) { /* 4 the last fragment */ + length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; + + aes_cipher(prwskey, pattrib->hdrlen, pframe, length); + } else{ + length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len ; + + aes_cipher(prwskey, pattrib->hdrlen, pframe, length); + pframe += pxmitpriv->frag_len; + pframe = (u8 *)RND4((size_t)(pframe)); + } + } + } else{ + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_aes_encrypt: stainfo==NULL!!!\n")); + res = _FAIL; + } + } + + +_func_exit_; + return res; +} + +static int aes_decipher(u8 *key, uint hdrlen, + u8 *pframe, uint plen) +{ + static u8 message[MAX_MSG_SIZE]; + uint qc_exists, a4_exists, i, j, payload_remainder, + num_blocks, payload_index; + int res = _SUCCESS; + u8 pn_vector[6]; + u8 mic_iv[16]; + u8 mic_header1[16]; + u8 mic_header2[16]; + u8 ctr_preload[16]; + + /* Intermediate Buffers */ + u8 chain_buffer[16]; + u8 aes_out[16]; + u8 padded_buffer[16]; + u8 mic[8]; + +/* uint offset = 0; */ + uint frtype = GetFrameType(pframe); + uint frsubtype = GetFrameSubType(pframe); +_func_enter_; + frsubtype = frsubtype>>4; + + _rtw_memset((void *)mic_iv, 0, 16); + _rtw_memset((void *)mic_header1, 0, 16); + _rtw_memset((void *)mic_header2, 0, 16); + _rtw_memset((void *)ctr_preload, 0, 16); + _rtw_memset((void *)chain_buffer, 0, 16); + _rtw_memset((void *)aes_out, 0, 16); + _rtw_memset((void *)padded_buffer, 0, 16); + + /* start to decrypt the payload */ + + num_blocks = (plen-8) / 16; /* plen including llc, payload_length and mic) */ + + payload_remainder = (plen-8) % 16; + + pn_vector[0] = pframe[hdrlen]; + pn_vector[1] = pframe[hdrlen+1]; + pn_vector[2] = pframe[hdrlen+4]; + pn_vector[3] = pframe[hdrlen+5]; + pn_vector[4] = pframe[hdrlen+6]; + pn_vector[5] = pframe[hdrlen+7]; + + if ((hdrlen == WLAN_HDR_A3_LEN) || (hdrlen == WLAN_HDR_A3_QOS_LEN)) + a4_exists = 0; + else + a4_exists = 1; + + if ((frtype == WIFI_DATA_CFACK) || (frtype == WIFI_DATA_CFPOLL) || + (frtype == WIFI_DATA_CFACKPOLL)) { + qc_exists = 1; + if (hdrlen != WLAN_HDR_A3_QOS_LEN) + hdrlen += 2; + } else if ((frsubtype == 0x08) || (frsubtype == 0x09) || + (frsubtype == 0x0a) || (frsubtype == 0x0b)) { + if (hdrlen != WLAN_HDR_A3_QOS_LEN) + hdrlen += 2; + qc_exists = 1; + } else { + qc_exists = 0; + } + + /* now, decrypt pframe with hdrlen offset and plen long */ + + payload_index = hdrlen + 8; /* 8 is for extiv */ + + for (i = 0; i < num_blocks; i++) { + construct_ctr_preload(ctr_preload, a4_exists, qc_exists, pframe, pn_vector, i+1); + + aes128k128d(key, ctr_preload, aes_out); + bitwise_xor(aes_out, &pframe[payload_index], chain_buffer); + + for (j = 0; j < 16; j++) + pframe[payload_index++] = chain_buffer[j]; + } + + if (payload_remainder > 0) { /* If there is a short final block, then pad it,*/ + /* encrypt it and copy the unpadded part back */ + construct_ctr_preload(ctr_preload, a4_exists, qc_exists, pframe, pn_vector, num_blocks+1); + + for (j = 0; j < 16; j++) + padded_buffer[j] = 0x00; + for (j = 0; j < payload_remainder; j++) + padded_buffer[j] = pframe[payload_index+j]; + aes128k128d(key, ctr_preload, aes_out); + bitwise_xor(aes_out, padded_buffer, chain_buffer); + for (j = 0; j < payload_remainder; j++) + pframe[payload_index++] = chain_buffer[j]; + } + + /* start to calculate the mic */ + if ((hdrlen+plen+8) <= MAX_MSG_SIZE) + memcpy(message, pframe, (hdrlen + plen+8)); /* 8 is for ext iv len */ + + pn_vector[0] = pframe[hdrlen]; + pn_vector[1] = pframe[hdrlen+1]; + pn_vector[2] = pframe[hdrlen+4]; + pn_vector[3] = pframe[hdrlen+5]; + pn_vector[4] = pframe[hdrlen+6]; + pn_vector[5] = pframe[hdrlen+7]; + construct_mic_iv(mic_iv, qc_exists, a4_exists, message, plen-8, pn_vector); + + construct_mic_header1(mic_header1, hdrlen, message); + construct_mic_header2(mic_header2, message, a4_exists, qc_exists); + + payload_remainder = (plen-8) % 16; + num_blocks = (plen-8) / 16; + + /* Find start of payload */ + payload_index = (hdrlen + 8); + + /* Calculate MIC */ + aes128k128d(key, mic_iv, aes_out); + bitwise_xor(aes_out, mic_header1, chain_buffer); + aes128k128d(key, chain_buffer, aes_out); + bitwise_xor(aes_out, mic_header2, chain_buffer); + aes128k128d(key, chain_buffer, aes_out); + + for (i = 0; i < num_blocks; i++) { + bitwise_xor(aes_out, &message[payload_index], chain_buffer); + + payload_index += 16; + aes128k128d(key, chain_buffer, aes_out); + } + + /* Add on the final payload block if it needs padding */ + if (payload_remainder > 0) { + for (j = 0; j < 16; j++) + padded_buffer[j] = 0x00; + for (j = 0; j < payload_remainder; j++) + padded_buffer[j] = message[payload_index++]; + bitwise_xor(aes_out, padded_buffer, chain_buffer); + aes128k128d(key, chain_buffer, aes_out); + } + + for (j = 0 ; j < 8; j++) + mic[j] = aes_out[j]; + + /* Insert MIC into payload */ + for (j = 0; j < 8; j++) + message[payload_index+j] = mic[j]; + + payload_index = hdrlen + 8; + for (i = 0; i < num_blocks; i++) { + construct_ctr_preload(ctr_preload, a4_exists, qc_exists, message, pn_vector, i+1); + aes128k128d(key, ctr_preload, aes_out); + bitwise_xor(aes_out, &message[payload_index], chain_buffer); + for (j = 0; j < 16; j++) + message[payload_index++] = chain_buffer[j]; + } + + if (payload_remainder > 0) { /* If there is a short final block, then pad it,*/ + /* encrypt it and copy the unpadded part back */ + construct_ctr_preload(ctr_preload, a4_exists, qc_exists, message, pn_vector, num_blocks+1); + + for (j = 0; j < 16; j++) + padded_buffer[j] = 0x00; + for (j = 0; j < payload_remainder; j++) + padded_buffer[j] = message[payload_index+j]; + aes128k128d(key, ctr_preload, aes_out); + bitwise_xor(aes_out, padded_buffer, chain_buffer); + for (j = 0; j < payload_remainder; j++) + message[payload_index++] = chain_buffer[j]; + } + + /* Encrypt the MIC */ + construct_ctr_preload(ctr_preload, a4_exists, qc_exists, message, pn_vector, 0); + + for (j = 0; j < 16; j++) + padded_buffer[j] = 0x00; + for (j = 0; j < 8; j++) + padded_buffer[j] = message[j+hdrlen+8+plen-8]; + + aes128k128d(key, ctr_preload, aes_out); + bitwise_xor(aes_out, padded_buffer, chain_buffer); + for (j = 0; j < 8; j++) + message[payload_index++] = chain_buffer[j]; + + /* compare the mic */ + for (i = 0; i < 8; i++) { + if (pframe[hdrlen+8+plen-8+i] != message[hdrlen+8+plen-8+i]) { + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, + ("aes_decipher:mic check error mic[%d]: pframe(%x)!=message(%x)\n", + i, pframe[hdrlen+8+plen-8+i], message[hdrlen+8+plen-8+i])); + DBG_88E("aes_decipher:mic check error mic[%d]: pframe(%x)!=message(%x)\n", + i, pframe[hdrlen+8+plen-8+i], message[hdrlen+8+plen-8+i]); + res = _FAIL; + } + } +_func_exit_; + return res; +} + +u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe) +{ /* exclude ICV */ + /* Intermediate Buffers */ + int length; + u8 *pframe, *prwskey; /* *payload,*iv */ + struct sta_info *stainfo; + struct rx_pkt_attrib *prxattrib = &((union recv_frame *)precvframe)->u.hdr.attrib; + struct security_priv *psecuritypriv = &padapter->securitypriv; + u32 res = _SUCCESS; +_func_enter_; + pframe = (unsigned char *)((union recv_frame *)precvframe)->u.hdr.rx_data; + /* 4 start to encrypt each fragment */ + if ((prxattrib->encrypt == _AES_)) { + stainfo = rtw_get_stainfo(&padapter->stapriv, &prxattrib->ta[0]); + if (stainfo != NULL) { + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_aes_decrypt: stainfo!= NULL!!!\n")); + + if (IS_MCAST(prxattrib->ra)) { + /* in concurrent we should use sw descrypt in group key, so we remove this message */ + if (!psecuritypriv->binstallGrpkey) { + res = _FAIL; + DBG_88E("%s:rx bc/mc packets, but didn't install group key!!!!!!!!!!\n", __func__); + goto exit; + } + prwskey = psecuritypriv->dot118021XGrpKey[prxattrib->key_index].skey; + if (psecuritypriv->dot118021XGrpKeyid != prxattrib->key_index) { + DBG_88E("not match packet_index=%d, install_index=%d\n", + prxattrib->key_index, psecuritypriv->dot118021XGrpKeyid); + res = _FAIL; + goto exit; + } + } else { + prwskey = &stainfo->dot118021x_UncstKey.skey[0]; + } + length = ((union recv_frame *)precvframe)->u.hdr.len-prxattrib->hdrlen-prxattrib->iv_len; + res = aes_decipher(prwskey, prxattrib->hdrlen, pframe, length); + } else { + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_aes_encrypt: stainfo==NULL!!!\n")); + res = _FAIL; + } + } +_func_exit_; +exit: + return res; +} + +/* AES tables*/ +const u32 Te0[256] = { + 0xc66363a5U, 0xf87c7c84U, 0xee777799U, 0xf67b7b8dU, + 0xfff2f20dU, 0xd66b6bbdU, 0xde6f6fb1U, 0x91c5c554U, + 0x60303050U, 0x02010103U, 0xce6767a9U, 0x562b2b7dU, + 0xe7fefe19U, 0xb5d7d762U, 0x4dababe6U, 0xec76769aU, + 0x8fcaca45U, 0x1f82829dU, 0x89c9c940U, 0xfa7d7d87U, + 0xeffafa15U, 0xb25959ebU, 0x8e4747c9U, 0xfbf0f00bU, + 0x41adadecU, 0xb3d4d467U, 0x5fa2a2fdU, 0x45afafeaU, + 0x239c9cbfU, 0x53a4a4f7U, 0xe4727296U, 0x9bc0c05bU, + 0x75b7b7c2U, 0xe1fdfd1cU, 0x3d9393aeU, 0x4c26266aU, + 0x6c36365aU, 0x7e3f3f41U, 0xf5f7f702U, 0x83cccc4fU, + 0x6834345cU, 0x51a5a5f4U, 0xd1e5e534U, 0xf9f1f108U, + 0xe2717193U, 0xabd8d873U, 0x62313153U, 0x2a15153fU, + 0x0804040cU, 0x95c7c752U, 0x46232365U, 0x9dc3c35eU, + 0x30181828U, 0x379696a1U, 0x0a05050fU, 0x2f9a9ab5U, + 0x0e070709U, 0x24121236U, 0x1b80809bU, 0xdfe2e23dU, + 0xcdebeb26U, 0x4e272769U, 0x7fb2b2cdU, 0xea75759fU, + 0x1209091bU, 0x1d83839eU, 0x582c2c74U, 0x341a1a2eU, + 0x361b1b2dU, 0xdc6e6eb2U, 0xb45a5aeeU, 0x5ba0a0fbU, + 0xa45252f6U, 0x763b3b4dU, 0xb7d6d661U, 0x7db3b3ceU, + 0x5229297bU, 0xdde3e33eU, 0x5e2f2f71U, 0x13848497U, + 0xa65353f5U, 0xb9d1d168U, 0x00000000U, 0xc1eded2cU, + 0x40202060U, 0xe3fcfc1fU, 0x79b1b1c8U, 0xb65b5bedU, + 0xd46a6abeU, 0x8dcbcb46U, 0x67bebed9U, 0x7239394bU, + 0x944a4adeU, 0x984c4cd4U, 0xb05858e8U, 0x85cfcf4aU, + 0xbbd0d06bU, 0xc5efef2aU, 0x4faaaae5U, 0xedfbfb16U, + 0x864343c5U, 0x9a4d4dd7U, 0x66333355U, 0x11858594U, + 0x8a4545cfU, 0xe9f9f910U, 0x04020206U, 0xfe7f7f81U, + 0xa05050f0U, 0x783c3c44U, 0x259f9fbaU, 0x4ba8a8e3U, + 0xa25151f3U, 0x5da3a3feU, 0x804040c0U, 0x058f8f8aU, + 0x3f9292adU, 0x219d9dbcU, 0x70383848U, 0xf1f5f504U, + 0x63bcbcdfU, 0x77b6b6c1U, 0xafdada75U, 0x42212163U, + 0x20101030U, 0xe5ffff1aU, 0xfdf3f30eU, 0xbfd2d26dU, + 0x81cdcd4cU, 0x180c0c14U, 0x26131335U, 0xc3ecec2fU, + 0xbe5f5fe1U, 0x359797a2U, 0x884444ccU, 0x2e171739U, + 0x93c4c457U, 0x55a7a7f2U, 0xfc7e7e82U, 0x7a3d3d47U, + 0xc86464acU, 0xba5d5de7U, 0x3219192bU, 0xe6737395U, + 0xc06060a0U, 0x19818198U, 0x9e4f4fd1U, 0xa3dcdc7fU, + 0x44222266U, 0x542a2a7eU, 0x3b9090abU, 0x0b888883U, + 0x8c4646caU, 0xc7eeee29U, 0x6bb8b8d3U, 0x2814143cU, + 0xa7dede79U, 0xbc5e5ee2U, 0x160b0b1dU, 0xaddbdb76U, + 0xdbe0e03bU, 0x64323256U, 0x743a3a4eU, 0x140a0a1eU, + 0x924949dbU, 0x0c06060aU, 0x4824246cU, 0xb85c5ce4U, + 0x9fc2c25dU, 0xbdd3d36eU, 0x43acacefU, 0xc46262a6U, + 0x399191a8U, 0x319595a4U, 0xd3e4e437U, 0xf279798bU, + 0xd5e7e732U, 0x8bc8c843U, 0x6e373759U, 0xda6d6db7U, + 0x018d8d8cU, 0xb1d5d564U, 0x9c4e4ed2U, 0x49a9a9e0U, + 0xd86c6cb4U, 0xac5656faU, 0xf3f4f407U, 0xcfeaea25U, + 0xca6565afU, 0xf47a7a8eU, 0x47aeaee9U, 0x10080818U, + 0x6fbabad5U, 0xf0787888U, 0x4a25256fU, 0x5c2e2e72U, + 0x381c1c24U, 0x57a6a6f1U, 0x73b4b4c7U, 0x97c6c651U, + 0xcbe8e823U, 0xa1dddd7cU, 0xe874749cU, 0x3e1f1f21U, + 0x964b4bddU, 0x61bdbddcU, 0x0d8b8b86U, 0x0f8a8a85U, + 0xe0707090U, 0x7c3e3e42U, 0x71b5b5c4U, 0xcc6666aaU, + 0x904848d8U, 0x06030305U, 0xf7f6f601U, 0x1c0e0e12U, + 0xc26161a3U, 0x6a35355fU, 0xae5757f9U, 0x69b9b9d0U, + 0x17868691U, 0x99c1c158U, 0x3a1d1d27U, 0x279e9eb9U, + 0xd9e1e138U, 0xebf8f813U, 0x2b9898b3U, 0x22111133U, + 0xd26969bbU, 0xa9d9d970U, 0x078e8e89U, 0x339494a7U, + 0x2d9b9bb6U, 0x3c1e1e22U, 0x15878792U, 0xc9e9e920U, + 0x87cece49U, 0xaa5555ffU, 0x50282878U, 0xa5dfdf7aU, + 0x038c8c8fU, 0x59a1a1f8U, 0x09898980U, 0x1a0d0d17U, + 0x65bfbfdaU, 0xd7e6e631U, 0x844242c6U, 0xd06868b8U, + 0x824141c3U, 0x299999b0U, 0x5a2d2d77U, 0x1e0f0f11U, + 0x7bb0b0cbU, 0xa85454fcU, 0x6dbbbbd6U, 0x2c16163aU, +}; + +const u32 Td0[256] = { + 0x51f4a750U, 0x7e416553U, 0x1a17a4c3U, 0x3a275e96U, + 0x3bab6bcbU, 0x1f9d45f1U, 0xacfa58abU, 0x4be30393U, + 0x2030fa55U, 0xad766df6U, 0x88cc7691U, 0xf5024c25U, + 0x4fe5d7fcU, 0xc52acbd7U, 0x26354480U, 0xb562a38fU, + 0xdeb15a49U, 0x25ba1b67U, 0x45ea0e98U, 0x5dfec0e1U, + 0xc32f7502U, 0x814cf012U, 0x8d4697a3U, 0x6bd3f9c6U, + 0x038f5fe7U, 0x15929c95U, 0xbf6d7aebU, 0x955259daU, + 0xd4be832dU, 0x587421d3U, 0x49e06929U, 0x8ec9c844U, + 0x75c2896aU, 0xf48e7978U, 0x99583e6bU, 0x27b971ddU, + 0xbee14fb6U, 0xf088ad17U, 0xc920ac66U, 0x7dce3ab4U, + 0x63df4a18U, 0xe51a3182U, 0x97513360U, 0x62537f45U, + 0xb16477e0U, 0xbb6bae84U, 0xfe81a01cU, 0xf9082b94U, + 0x70486858U, 0x8f45fd19U, 0x94de6c87U, 0x527bf8b7U, + 0xab73d323U, 0x724b02e2U, 0xe31f8f57U, 0x6655ab2aU, + 0xb2eb2807U, 0x2fb5c203U, 0x86c57b9aU, 0xd33708a5U, + 0x302887f2U, 0x23bfa5b2U, 0x02036abaU, 0xed16825cU, + 0x8acf1c2bU, 0xa779b492U, 0xf307f2f0U, 0x4e69e2a1U, + 0x65daf4cdU, 0x0605bed5U, 0xd134621fU, 0xc4a6fe8aU, + 0x342e539dU, 0xa2f355a0U, 0x058ae132U, 0xa4f6eb75U, + 0x0b83ec39U, 0x4060efaaU, 0x5e719f06U, 0xbd6e1051U, + 0x3e218af9U, 0x96dd063dU, 0xdd3e05aeU, 0x4de6bd46U, + 0x91548db5U, 0x71c45d05U, 0x0406d46fU, 0x605015ffU, + 0x1998fb24U, 0xd6bde997U, 0x894043ccU, 0x67d99e77U, + 0xb0e842bdU, 0x07898b88U, 0xe7195b38U, 0x79c8eedbU, + 0xa17c0a47U, 0x7c420fe9U, 0xf8841ec9U, 0x00000000U, + 0x09808683U, 0x322bed48U, 0x1e1170acU, 0x6c5a724eU, + 0xfd0efffbU, 0x0f853856U, 0x3daed51eU, 0x362d3927U, + 0x0a0fd964U, 0x685ca621U, 0x9b5b54d1U, 0x24362e3aU, + 0x0c0a67b1U, 0x9357e70fU, 0xb4ee96d2U, 0x1b9b919eU, + 0x80c0c54fU, 0x61dc20a2U, 0x5a774b69U, 0x1c121a16U, + 0xe293ba0aU, 0xc0a02ae5U, 0x3c22e043U, 0x121b171dU, + 0x0e090d0bU, 0xf28bc7adU, 0x2db6a8b9U, 0x141ea9c8U, + 0x57f11985U, 0xaf75074cU, 0xee99ddbbU, 0xa37f60fdU, + 0xf701269fU, 0x5c72f5bcU, 0x44663bc5U, 0x5bfb7e34U, + 0x8b432976U, 0xcb23c6dcU, 0xb6edfc68U, 0xb8e4f163U, + 0xd731dccaU, 0x42638510U, 0x13972240U, 0x84c61120U, + 0x854a247dU, 0xd2bb3df8U, 0xaef93211U, 0xc729a16dU, + 0x1d9e2f4bU, 0xdcb230f3U, 0x0d8652ecU, 0x77c1e3d0U, + 0x2bb3166cU, 0xa970b999U, 0x119448faU, 0x47e96422U, + 0xa8fc8cc4U, 0xa0f03f1aU, 0x567d2cd8U, 0x223390efU, + 0x87494ec7U, 0xd938d1c1U, 0x8ccaa2feU, 0x98d40b36U, + 0xa6f581cfU, 0xa57ade28U, 0xdab78e26U, 0x3fadbfa4U, + 0x2c3a9de4U, 0x5078920dU, 0x6a5fcc9bU, 0x547e4662U, + 0xf68d13c2U, 0x90d8b8e8U, 0x2e39f75eU, 0x82c3aff5U, + 0x9f5d80beU, 0x69d0937cU, 0x6fd52da9U, 0xcf2512b3U, + 0xc8ac993bU, 0x10187da7U, 0xe89c636eU, 0xdb3bbb7bU, + 0xcd267809U, 0x6e5918f4U, 0xec9ab701U, 0x834f9aa8U, + 0xe6956e65U, 0xaaffe67eU, 0x21bccf08U, 0xef15e8e6U, + 0xbae79bd9U, 0x4a6f36ceU, 0xea9f09d4U, 0x29b07cd6U, + 0x31a4b2afU, 0x2a3f2331U, 0xc6a59430U, 0x35a266c0U, + 0x744ebc37U, 0xfc82caa6U, 0xe090d0b0U, 0x33a7d815U, + 0xf104984aU, 0x41ecdaf7U, 0x7fcd500eU, 0x1791f62fU, + 0x764dd68dU, 0x43efb04dU, 0xccaa4d54U, 0xe49604dfU, + 0x9ed1b5e3U, 0x4c6a881bU, 0xc12c1fb8U, 0x4665517fU, + 0x9d5eea04U, 0x018c355dU, 0xfa877473U, 0xfb0b412eU, + 0xb3671d5aU, 0x92dbd252U, 0xe9105633U, 0x6dd64713U, + 0x9ad7618cU, 0x37a10c7aU, 0x59f8148eU, 0xeb133c89U, + 0xcea927eeU, 0xb761c935U, 0xe11ce5edU, 0x7a47b13cU, + 0x9cd2df59U, 0x55f2733fU, 0x1814ce79U, 0x73c737bfU, + 0x53f7cdeaU, 0x5ffdaa5bU, 0xdf3d6f14U, 0x7844db86U, + 0xcaaff381U, 0xb968c43eU, 0x3824342cU, 0xc2a3405fU, + 0x161dc372U, 0xbce2250cU, 0x283c498bU, 0xff0d9541U, + 0x39a80171U, 0x080cb3deU, 0xd8b4e49cU, 0x6456c190U, + 0x7bcb8461U, 0xd532b670U, 0x486c5c74U, 0xd0b85742U, +}; + +const u8 Td4s[256] = { + 0x52U, 0x09U, 0x6aU, 0xd5U, 0x30U, 0x36U, 0xa5U, 0x38U, + 0xbfU, 0x40U, 0xa3U, 0x9eU, 0x81U, 0xf3U, 0xd7U, 0xfbU, + 0x7cU, 0xe3U, 0x39U, 0x82U, 0x9bU, 0x2fU, 0xffU, 0x87U, + 0x34U, 0x8eU, 0x43U, 0x44U, 0xc4U, 0xdeU, 0xe9U, 0xcbU, + 0x54U, 0x7bU, 0x94U, 0x32U, 0xa6U, 0xc2U, 0x23U, 0x3dU, + 0xeeU, 0x4cU, 0x95U, 0x0bU, 0x42U, 0xfaU, 0xc3U, 0x4eU, + 0x08U, 0x2eU, 0xa1U, 0x66U, 0x28U, 0xd9U, 0x24U, 0xb2U, + 0x76U, 0x5bU, 0xa2U, 0x49U, 0x6dU, 0x8bU, 0xd1U, 0x25U, + 0x72U, 0xf8U, 0xf6U, 0x64U, 0x86U, 0x68U, 0x98U, 0x16U, + 0xd4U, 0xa4U, 0x5cU, 0xccU, 0x5dU, 0x65U, 0xb6U, 0x92U, + 0x6cU, 0x70U, 0x48U, 0x50U, 0xfdU, 0xedU, 0xb9U, 0xdaU, + 0x5eU, 0x15U, 0x46U, 0x57U, 0xa7U, 0x8dU, 0x9dU, 0x84U, + 0x90U, 0xd8U, 0xabU, 0x00U, 0x8cU, 0xbcU, 0xd3U, 0x0aU, + 0xf7U, 0xe4U, 0x58U, 0x05U, 0xb8U, 0xb3U, 0x45U, 0x06U, + 0xd0U, 0x2cU, 0x1eU, 0x8fU, 0xcaU, 0x3fU, 0x0fU, 0x02U, + 0xc1U, 0xafU, 0xbdU, 0x03U, 0x01U, 0x13U, 0x8aU, 0x6bU, + 0x3aU, 0x91U, 0x11U, 0x41U, 0x4fU, 0x67U, 0xdcU, 0xeaU, + 0x97U, 0xf2U, 0xcfU, 0xceU, 0xf0U, 0xb4U, 0xe6U, 0x73U, + 0x96U, 0xacU, 0x74U, 0x22U, 0xe7U, 0xadU, 0x35U, 0x85U, + 0xe2U, 0xf9U, 0x37U, 0xe8U, 0x1cU, 0x75U, 0xdfU, 0x6eU, + 0x47U, 0xf1U, 0x1aU, 0x71U, 0x1dU, 0x29U, 0xc5U, 0x89U, + 0x6fU, 0xb7U, 0x62U, 0x0eU, 0xaaU, 0x18U, 0xbeU, 0x1bU, + 0xfcU, 0x56U, 0x3eU, 0x4bU, 0xc6U, 0xd2U, 0x79U, 0x20U, + 0x9aU, 0xdbU, 0xc0U, 0xfeU, 0x78U, 0xcdU, 0x5aU, 0xf4U, + 0x1fU, 0xddU, 0xa8U, 0x33U, 0x88U, 0x07U, 0xc7U, 0x31U, + 0xb1U, 0x12U, 0x10U, 0x59U, 0x27U, 0x80U, 0xecU, 0x5fU, + 0x60U, 0x51U, 0x7fU, 0xa9U, 0x19U, 0xb5U, 0x4aU, 0x0dU, + 0x2dU, 0xe5U, 0x7aU, 0x9fU, 0x93U, 0xc9U, 0x9cU, 0xefU, + 0xa0U, 0xe0U, 0x3bU, 0x4dU, 0xaeU, 0x2aU, 0xf5U, 0xb0U, + 0xc8U, 0xebU, 0xbbU, 0x3cU, 0x83U, 0x53U, 0x99U, 0x61U, + 0x17U, 0x2bU, 0x04U, 0x7eU, 0xbaU, 0x77U, 0xd6U, 0x26U, + 0xe1U, 0x69U, 0x14U, 0x63U, 0x55U, 0x21U, 0x0cU, 0x7dU, +}; +const u8 rcons[] = { + 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1B, 0x36 + /* for 128-bit blocks, Rijndael never uses more than 10 rcon values */ +}; + +/** + * Expand the cipher key into the encryption key schedule. + * + * @return the number of rounds for the given cipher key size. + */ +#define ROUND(i, d, s) \ +do { \ + d##0 = TE0(s##0) ^ TE1(s##1) ^ TE2(s##2) ^ TE3(s##3) ^ rk[4 * i]; \ + d##1 = TE0(s##1) ^ TE1(s##2) ^ TE2(s##3) ^ TE3(s##0) ^ rk[4 * i + 1]; \ + d##2 = TE0(s##2) ^ TE1(s##3) ^ TE2(s##0) ^ TE3(s##1) ^ rk[4 * i + 2]; \ + d##3 = TE0(s##3) ^ TE1(s##0) ^ TE2(s##1) ^ TE3(s##2) ^ rk[4 * i + 3]; \ +} while (0); + +/** + * omac1_aes_128 - One-Key CBC MAC (OMAC1) hash with AES-128 (aka AES-CMAC) + * @key: 128-bit key for the hash operation + * @data: Data buffer for which a MAC is determined + * @data_len: Length of data buffer in bytes + * @mac: Buffer for MAC (128 bits, i.e., 16 bytes) + * Returns: 0 on success, -1 on failure + * + * This is a mode for using block cipher (AES in this case) for authentication. + * OMAC1 was standardized with the name CMAC by NIST in a Special Publication + * (SP) 800-38B. + */ +void rtw_use_tkipkey_handler(void *FunctionContext) +{ + struct adapter *padapter = (struct adapter *)FunctionContext; + +_func_enter_; + + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("^^^rtw_use_tkipkey_handler ^^^\n")); + + padapter->securitypriv.busetkipkey = true; + + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("^^^rtw_use_tkipkey_handler padapter->securitypriv.busetkipkey=%d^^^\n", padapter->securitypriv.busetkipkey)); + +_func_exit_; +} diff --git a/drivers/staging/rtl8188eu/core/rtw_sreset.c b/drivers/staging/rtl8188eu/core/rtw_sreset.c new file mode 100644 index 0000000000000..298f75400c8fb --- /dev/null +++ b/drivers/staging/rtl8188eu/core/rtw_sreset.c @@ -0,0 +1,79 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#include + +void sreset_init_value(struct adapter *padapter) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); + struct sreset_priv *psrtpriv = &pHalData->srestpriv; + + _rtw_mutex_init(&psrtpriv->silentreset_mutex); + psrtpriv->silent_reset_inprogress = false; + psrtpriv->Wifi_Error_Status = WIFI_STATUS_SUCCESS; + psrtpriv->last_tx_time = 0; + psrtpriv->last_tx_complete_time = 0; +} +void sreset_reset_value(struct adapter *padapter) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); + struct sreset_priv *psrtpriv = &pHalData->srestpriv; + + psrtpriv->silent_reset_inprogress = false; + psrtpriv->Wifi_Error_Status = WIFI_STATUS_SUCCESS; + psrtpriv->last_tx_time = 0; + psrtpriv->last_tx_complete_time = 0; +} + +u8 sreset_get_wifi_status(struct adapter *padapter) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); + struct sreset_priv *psrtpriv = &pHalData->srestpriv; + + u8 status = WIFI_STATUS_SUCCESS; + u32 val32 = 0; + + if (psrtpriv->silent_reset_inprogress) + return status; + val32 = rtw_read32(padapter, REG_TXDMA_STATUS); + if (val32 == 0xeaeaeaea) { + psrtpriv->Wifi_Error_Status = WIFI_IF_NOT_EXIST; + } else if (val32 != 0) { + DBG_88E("txdmastatu(%x)\n", val32); + psrtpriv->Wifi_Error_Status = WIFI_MAC_TXDMA_ERROR; + } + + if (WIFI_STATUS_SUCCESS != psrtpriv->Wifi_Error_Status) { + DBG_88E("==>%s error_status(0x%x)\n", __func__, psrtpriv->Wifi_Error_Status); + status = (psrtpriv->Wifi_Error_Status & (~(USB_READ_PORT_FAIL|USB_WRITE_PORT_FAIL))); + } + DBG_88E("==> %s wifi_status(0x%x)\n", __func__, status); + + /* status restore */ + psrtpriv->Wifi_Error_Status = WIFI_STATUS_SUCCESS; + + return status; +} + +void sreset_set_wifi_error_status(struct adapter *padapter, u32 status) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); + pHalData->srestpriv.Wifi_Error_Status = status; +} diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c new file mode 100644 index 0000000000000..c2977be92fb14 --- /dev/null +++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c @@ -0,0 +1,655 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTW_STA_MGT_C_ + +#include +#include +#include +#include +#include +#include + +static void _rtw_init_stainfo(struct sta_info *psta) +{ +_func_enter_; + _rtw_memset((u8 *)psta, 0, sizeof (struct sta_info)); + + _rtw_spinlock_init(&psta->lock); + _rtw_init_listhead(&psta->list); + _rtw_init_listhead(&psta->hash_list); + _rtw_init_queue(&psta->sleep_q); + psta->sleepq_len = 0; + + _rtw_init_sta_xmit_priv(&psta->sta_xmitpriv); + _rtw_init_sta_recv_priv(&psta->sta_recvpriv); + +#ifdef CONFIG_88EU_AP_MODE + + _rtw_init_listhead(&psta->asoc_list); + + _rtw_init_listhead(&psta->auth_list); + + psta->expire_to = 0; + + psta->flags = 0; + + psta->capability = 0; + + psta->bpairwise_key_installed = false; + +#ifdef CONFIG_88EU_AP_MODE + psta->nonerp_set = 0; + psta->no_short_slot_time_set = 0; + psta->no_short_preamble_set = 0; + psta->no_ht_gf_set = 0; + psta->no_ht_set = 0; + psta->ht_20mhz_set = 0; +#endif + + psta->under_exist_checking = 0; + + psta->keep_alive_trycnt = 0; + +#endif /* CONFIG_88EU_AP_MODE */ + +_func_exit_; +} + +u32 _rtw_init_sta_priv(struct sta_priv *pstapriv) +{ + struct sta_info *psta; + s32 i; + +_func_enter_; + + pstapriv->pallocated_stainfo_buf = rtw_zvmalloc(sizeof(struct sta_info) * NUM_STA + 4); + + if (!pstapriv->pallocated_stainfo_buf) + return _FAIL; + + pstapriv->pstainfo_buf = pstapriv->pallocated_stainfo_buf + 4 - + ((size_t)(pstapriv->pallocated_stainfo_buf) & 3); + + _rtw_init_queue(&pstapriv->free_sta_queue); + + _rtw_spinlock_init(&pstapriv->sta_hash_lock); + + pstapriv->asoc_sta_count = 0; + _rtw_init_queue(&pstapriv->sleep_q); + _rtw_init_queue(&pstapriv->wakeup_q); + + psta = (struct sta_info *)(pstapriv->pstainfo_buf); + + for (i = 0; i < NUM_STA; i++) { + _rtw_init_stainfo(psta); + + _rtw_init_listhead(&(pstapriv->sta_hash[i])); + + rtw_list_insert_tail(&psta->list, get_list_head(&pstapriv->free_sta_queue)); + + psta++; + } + +#ifdef CONFIG_88EU_AP_MODE + + pstapriv->sta_dz_bitmap = 0; + pstapriv->tim_bitmap = 0; + + _rtw_init_listhead(&pstapriv->asoc_list); + _rtw_init_listhead(&pstapriv->auth_list); + _rtw_spinlock_init(&pstapriv->asoc_list_lock); + _rtw_spinlock_init(&pstapriv->auth_list_lock); + pstapriv->asoc_list_cnt = 0; + pstapriv->auth_list_cnt = 0; + + pstapriv->auth_to = 3; /* 3*2 = 6 sec */ + pstapriv->assoc_to = 3; + pstapriv->expire_to = 3; /* 3*2 = 6 sec */ + pstapriv->max_num_sta = NUM_STA; +#endif + +_func_exit_; + + return _SUCCESS; +} + +inline int rtw_stainfo_offset(struct sta_priv *stapriv, struct sta_info *sta) +{ + int offset = (((u8 *)sta) - stapriv->pstainfo_buf)/sizeof(struct sta_info); + + if (!stainfo_offset_valid(offset)) + DBG_88E("%s invalid offset(%d), out of range!!!", __func__, offset); + + return offset; +} + +inline struct sta_info *rtw_get_stainfo_by_offset(struct sta_priv *stapriv, int offset) +{ + if (!stainfo_offset_valid(offset)) + DBG_88E("%s invalid offset(%d), out of range!!!", __func__, offset); + + return (struct sta_info *)(stapriv->pstainfo_buf + offset * sizeof(struct sta_info)); +} + +void _rtw_free_sta_xmit_priv_lock(struct sta_xmit_priv *psta_xmitpriv); +void _rtw_free_sta_xmit_priv_lock(struct sta_xmit_priv *psta_xmitpriv) +{ +_func_enter_; + + _rtw_spinlock_free(&psta_xmitpriv->lock); + + _rtw_spinlock_free(&(psta_xmitpriv->be_q.sta_pending.lock)); + _rtw_spinlock_free(&(psta_xmitpriv->bk_q.sta_pending.lock)); + _rtw_spinlock_free(&(psta_xmitpriv->vi_q.sta_pending.lock)); + _rtw_spinlock_free(&(psta_xmitpriv->vo_q.sta_pending.lock)); +_func_exit_; +} + +static void _rtw_free_sta_recv_priv_lock(struct sta_recv_priv *psta_recvpriv) +{ +_func_enter_; + + _rtw_spinlock_free(&psta_recvpriv->lock); + + _rtw_spinlock_free(&(psta_recvpriv->defrag_q.lock)); + +_func_exit_; +} + +void rtw_mfree_stainfo(struct sta_info *psta); +void rtw_mfree_stainfo(struct sta_info *psta) +{ +_func_enter_; + + if (&psta->lock != NULL) + _rtw_spinlock_free(&psta->lock); + + _rtw_free_sta_xmit_priv_lock(&psta->sta_xmitpriv); + _rtw_free_sta_recv_priv_lock(&psta->sta_recvpriv); + +_func_exit_; +} + +/* this function is used to free the memory of lock || sema for all stainfos */ +void rtw_mfree_all_stainfo(struct sta_priv *pstapriv); +void rtw_mfree_all_stainfo(struct sta_priv *pstapriv) +{ + unsigned long irql; + struct list_head *plist, *phead; + struct sta_info *psta = NULL; + +_func_enter_; + + _enter_critical_bh(&pstapriv->sta_hash_lock, &irql); + + phead = get_list_head(&pstapriv->free_sta_queue); + plist = get_next(phead); + + while ((rtw_end_of_queue_search(phead, plist)) == false) { + psta = LIST_CONTAINOR(plist, struct sta_info , list); + plist = get_next(plist); + + rtw_mfree_stainfo(psta); + } + + _exit_critical_bh(&pstapriv->sta_hash_lock, &irql); + +_func_exit_; +} + +static void rtw_mfree_sta_priv_lock(struct sta_priv *pstapriv) +{ +#ifdef CONFIG_88EU_AP_MODE + struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; +#endif + + rtw_mfree_all_stainfo(pstapriv); /* be done before free sta_hash_lock */ + + _rtw_spinlock_free(&pstapriv->free_sta_queue.lock); + + _rtw_spinlock_free(&pstapriv->sta_hash_lock); + _rtw_spinlock_free(&pstapriv->wakeup_q.lock); + _rtw_spinlock_free(&pstapriv->sleep_q.lock); + +#ifdef CONFIG_88EU_AP_MODE + _rtw_spinlock_free(&pstapriv->asoc_list_lock); + _rtw_spinlock_free(&pstapriv->auth_list_lock); + _rtw_spinlock_free(&pacl_list->acl_node_q.lock); +#endif +} + +u32 _rtw_free_sta_priv(struct sta_priv *pstapriv) +{ + unsigned long irql; + struct list_head *phead, *plist; + struct sta_info *psta = NULL; + struct recv_reorder_ctrl *preorder_ctrl; + int index; + +_func_enter_; + if (pstapriv) { + /* delete all reordering_ctrl_timer */ + _enter_critical_bh(&pstapriv->sta_hash_lock, &irql); + for (index = 0; index < NUM_STA; index++) { + phead = &(pstapriv->sta_hash[index]); + plist = get_next(phead); + + while ((rtw_end_of_queue_search(phead, plist)) == false) { + int i; + psta = LIST_CONTAINOR(plist, struct sta_info , hash_list); + plist = get_next(plist); + + for (i = 0; i < 16; i++) { + preorder_ctrl = &psta->recvreorder_ctrl[i]; + _cancel_timer_ex(&preorder_ctrl->reordering_ctrl_timer); + } + } + } + _exit_critical_bh(&pstapriv->sta_hash_lock, &irql); + /*===============================*/ + + rtw_mfree_sta_priv_lock(pstapriv); + + if (pstapriv->pallocated_stainfo_buf) { + rtw_vmfree(pstapriv->pallocated_stainfo_buf, sizeof(struct sta_info)*NUM_STA+4); + } + } + +_func_exit_; + return _SUCCESS; +} + +struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) +{ + unsigned long irql, irql2; + s32 index; + struct list_head *phash_list; + struct sta_info *psta; + struct __queue *pfree_sta_queue; + struct recv_reorder_ctrl *preorder_ctrl; + int i = 0; + u16 wRxSeqInitialValue = 0xffff; + +_func_enter_; + + pfree_sta_queue = &pstapriv->free_sta_queue; + + _enter_critical_bh(&(pfree_sta_queue->lock), &irql); + + if (_rtw_queue_empty(pfree_sta_queue) == true) { + _exit_critical_bh(&(pfree_sta_queue->lock), &irql); + psta = NULL; + } else { + psta = LIST_CONTAINOR(get_next(&pfree_sta_queue->queue), struct sta_info, list); + rtw_list_delete(&(psta->list)); + _exit_critical_bh(&(pfree_sta_queue->lock), &irql); + _rtw_init_stainfo(psta); + memcpy(psta->hwaddr, hwaddr, ETH_ALEN); + index = wifi_mac_hash(hwaddr); + RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_info_, ("rtw_alloc_stainfo: index=%x", index)); + if (index >= NUM_STA) { + RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_err_, ("ERROR => rtw_alloc_stainfo: index >= NUM_STA")); + psta = NULL; + goto exit; + } + phash_list = &(pstapriv->sta_hash[index]); + + _enter_critical_bh(&(pstapriv->sta_hash_lock), &irql2); + + rtw_list_insert_tail(&psta->hash_list, phash_list); + + pstapriv->asoc_sta_count++ ; + + _exit_critical_bh(&(pstapriv->sta_hash_lock), &irql2); + +/* Commented by Albert 2009/08/13 */ +/* For the SMC router, the sequence number of first packet of WPS handshake will be 0. */ +/* In this case, this packet will be dropped by recv_decache function if we use the 0x00 as the default value for tid_rxseq variable. */ +/* So, we initialize the tid_rxseq variable as the 0xffff. */ + + for (i = 0; i < 16; i++) + memcpy(&psta->sta_recvpriv.rxcache.tid_rxseq[i], &wRxSeqInitialValue, 2); + + RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_info_, + ("alloc number_%d stainfo with hwaddr = %pM\n", + pstapriv->asoc_sta_count , hwaddr)); + + init_addba_retry_timer(pstapriv->padapter, psta); + + /* for A-MPDU Rx reordering buffer control */ + for (i = 0; i < 16; i++) { + preorder_ctrl = &psta->recvreorder_ctrl[i]; + + preorder_ctrl->padapter = pstapriv->padapter; + + preorder_ctrl->enable = false; + + preorder_ctrl->indicate_seq = 0xffff; + preorder_ctrl->wend_b = 0xffff; + preorder_ctrl->wsize_b = 64;/* 64; */ + + _rtw_init_queue(&preorder_ctrl->pending_recvframe_queue); + + rtw_init_recv_timer(preorder_ctrl); + } + + /* init for DM */ + psta->rssi_stat.UndecoratedSmoothedPWDB = (-1); + psta->rssi_stat.UndecoratedSmoothedCCK = (-1); + + /* init for the sequence number of received management frame */ + psta->RxMgmtFrameSeqNum = 0xffff; + } + +exit: + +_func_exit_; + + return psta; +} + +/* using pstapriv->sta_hash_lock to protect */ +u32 rtw_free_stainfo(struct adapter *padapter , struct sta_info *psta) +{ + int i; + unsigned long irql0; + struct __queue *pfree_sta_queue; + struct recv_reorder_ctrl *preorder_ctrl; + struct sta_xmit_priv *pstaxmitpriv; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct sta_priv *pstapriv = &padapter->stapriv; + +_func_enter_; + + if (psta == NULL) + goto exit; + + pfree_sta_queue = &pstapriv->free_sta_queue; + + pstaxmitpriv = &psta->sta_xmitpriv; + + _enter_critical_bh(&pxmitpriv->lock, &irql0); + + rtw_free_xmitframe_queue(pxmitpriv, &psta->sleep_q); + psta->sleepq_len = 0; + + rtw_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->vo_q.sta_pending); + + rtw_list_delete(&(pstaxmitpriv->vo_q.tx_pending)); + + rtw_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->vi_q.sta_pending); + + rtw_list_delete(&(pstaxmitpriv->vi_q.tx_pending)); + + rtw_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->bk_q.sta_pending); + + rtw_list_delete(&(pstaxmitpriv->bk_q.tx_pending)); + + rtw_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->be_q.sta_pending); + + rtw_list_delete(&(pstaxmitpriv->be_q.tx_pending)); + + _exit_critical_bh(&pxmitpriv->lock, &irql0); + + rtw_list_delete(&psta->hash_list); + RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_err_, ("\n free number_%d stainfo with hwaddr=0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x\n", pstapriv->asoc_sta_count , psta->hwaddr[0], psta->hwaddr[1], psta->hwaddr[2], psta->hwaddr[3], psta->hwaddr[4], psta->hwaddr[5])); + pstapriv->asoc_sta_count--; + + /* re-init sta_info; 20061114 */ + _rtw_init_sta_xmit_priv(&psta->sta_xmitpriv); + _rtw_init_sta_recv_priv(&psta->sta_recvpriv); + + _cancel_timer_ex(&psta->addba_retry_timer); + + /* for A-MPDU Rx reordering buffer control, cancel reordering_ctrl_timer */ + for (i = 0; i < 16 ; i++) { + unsigned long irql; + struct list_head *phead, *plist; + union recv_frame *prframe; + struct __queue *ppending_recvframe_queue; + struct __queue *pfree_recv_queue = &padapter->recvpriv.free_recv_queue; + + preorder_ctrl = &psta->recvreorder_ctrl[i]; + + _cancel_timer_ex(&preorder_ctrl->reordering_ctrl_timer); + + ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue; + + _enter_critical_bh(&ppending_recvframe_queue->lock, &irql); + + phead = get_list_head(ppending_recvframe_queue); + plist = get_next(phead); + + while (!rtw_is_list_empty(phead)) { + prframe = LIST_CONTAINOR(plist, union recv_frame, u); + + plist = get_next(plist); + + rtw_list_delete(&(prframe->u.hdr.list)); + + rtw_free_recvframe(prframe, pfree_recv_queue); + } + + _exit_critical_bh(&ppending_recvframe_queue->lock, &irql); + } + + if (!(psta->state & WIFI_AP_STATE)) + rtw_hal_set_odm_var(padapter, HAL_ODM_STA_INFO, psta, false); + +#ifdef CONFIG_88EU_AP_MODE + + _enter_critical_bh(&pstapriv->auth_list_lock, &irql0); + if (!rtw_is_list_empty(&psta->auth_list)) { + rtw_list_delete(&psta->auth_list); + pstapriv->auth_list_cnt--; + } + _exit_critical_bh(&pstapriv->auth_list_lock, &irql0); + + psta->expire_to = 0; + + psta->sleepq_ac_len = 0; + psta->qos_info = 0; + + psta->max_sp_len = 0; + psta->uapsd_bk = 0; + psta->uapsd_be = 0; + psta->uapsd_vi = 0; + psta->uapsd_vo = 0; + psta->has_legacy_ac = 0; + + pstapriv->sta_dz_bitmap &= ~BIT(psta->aid); + pstapriv->tim_bitmap &= ~BIT(psta->aid); + + if ((psta->aid > 0) && (pstapriv->sta_aid[psta->aid - 1] == psta)) { + pstapriv->sta_aid[psta->aid - 1] = NULL; + psta->aid = 0; + } + + psta->under_exist_checking = 0; + +#endif /* CONFIG_88EU_AP_MODE */ + + _enter_critical_bh(&(pfree_sta_queue->lock), &irql0); + rtw_list_insert_tail(&psta->list, get_list_head(pfree_sta_queue)); + _exit_critical_bh(&(pfree_sta_queue->lock), &irql0); + +exit: + +_func_exit_; + + return _SUCCESS; +} + +/* free all stainfo which in sta_hash[all] */ +void rtw_free_all_stainfo(struct adapter *padapter) +{ + unsigned long irql; + struct list_head *plist, *phead; + s32 index; + struct sta_info *psta = NULL; + struct sta_priv *pstapriv = &padapter->stapriv; + struct sta_info *pbcmc_stainfo = rtw_get_bcmc_stainfo(padapter); + +_func_enter_; + + if (pstapriv->asoc_sta_count == 1) + goto exit; + + _enter_critical_bh(&pstapriv->sta_hash_lock, &irql); + + for (index = 0; index < NUM_STA; index++) { + phead = &(pstapriv->sta_hash[index]); + plist = get_next(phead); + + while ((!rtw_end_of_queue_search(phead, plist))) { + psta = LIST_CONTAINOR(plist, struct sta_info , hash_list); + + plist = get_next(plist); + + if (pbcmc_stainfo != psta) + rtw_free_stainfo(padapter , psta); + } + } + + _exit_critical_bh(&pstapriv->sta_hash_lock, &irql); + +exit: + +_func_exit_; +} + +/* any station allocated can be searched by hash list */ +struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) +{ + unsigned long irql; + struct list_head *plist, *phead; + struct sta_info *psta = NULL; + u32 index; + u8 *addr; + u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + +_func_enter_; + + if (hwaddr == NULL) + return NULL; + + if (IS_MCAST(hwaddr)) + addr = bc_addr; + else + addr = hwaddr; + + index = wifi_mac_hash(addr); + + _enter_critical_bh(&pstapriv->sta_hash_lock, &irql); + + phead = &(pstapriv->sta_hash[index]); + plist = get_next(phead); + + while ((!rtw_end_of_queue_search(phead, plist))) { + psta = LIST_CONTAINOR(plist, struct sta_info, hash_list); + + if ((_rtw_memcmp(psta->hwaddr, addr, ETH_ALEN)) == true) { + /* if found the matched address */ + break; + } + psta = NULL; + plist = get_next(plist); + } + + _exit_critical_bh(&pstapriv->sta_hash_lock, &irql); +_func_exit_; + return psta; +} + +u32 rtw_init_bcmc_stainfo(struct adapter *padapter) +{ + struct sta_info *psta; + u32 res = _SUCCESS; + unsigned char bcast_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + struct sta_priv *pstapriv = &padapter->stapriv; + +_func_enter_; + + psta = rtw_alloc_stainfo(pstapriv, bcast_addr); + + if (psta == NULL) { + res = _FAIL; + RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_err_, ("rtw_alloc_stainfo fail")); + goto exit; + } + + /* default broadcast & multicast use macid 1 */ + psta->mac_id = 1; + +exit: +_func_exit_; + return res; +} + +struct sta_info *rtw_get_bcmc_stainfo(struct adapter *padapter) +{ + struct sta_info *psta; + struct sta_priv *pstapriv = &padapter->stapriv; + u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; +_func_enter_; + psta = rtw_get_stainfo(pstapriv, bc_addr); +_func_exit_; + return psta; +} + +u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr) +{ + u8 res = true; +#ifdef CONFIG_88EU_AP_MODE + unsigned long irql; + struct list_head *plist, *phead; + struct rtw_wlan_acl_node *paclnode; + u8 match = false; + struct sta_priv *pstapriv = &padapter->stapriv; + struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; + struct __queue *pacl_node_q = &pacl_list->acl_node_q; + + _enter_critical_bh(&(pacl_node_q->lock), &irql); + phead = get_list_head(pacl_node_q); + plist = get_next(phead); + while ((!rtw_end_of_queue_search(phead, plist))) { + paclnode = LIST_CONTAINOR(plist, struct rtw_wlan_acl_node, list); + plist = get_next(plist); + + if (_rtw_memcmp(paclnode->addr, mac_addr, ETH_ALEN)) { + if (paclnode->valid) { + match = true; + break; + } + } + } + _exit_critical_bh(&(pacl_node_q->lock), &irql); + + if (pacl_list->mode == 1)/* accept unless in deny list */ + res = (match) ? false : true; + else if (pacl_list->mode == 2)/* deny unless in accept list */ + res = (match) ? true : false; + else + res = true; + +#endif + + return res; +} -- GitLab From d6846af679e0b91ddff5dcd6af731464465f9188 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 21 Aug 2013 22:33:49 -0500 Subject: [PATCH 765/942] staging: r8188eu: Add files for new driver - part 7 This commit adds core/rtw_wlan_util.c and core/rtw_xmit.c Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8188eu/core/rtw_wlan_util.c | 1689 ++++++++++++ drivers/staging/rtl8188eu/core/rtw_xmit.c | 2447 +++++++++++++++++ 2 files changed, 4136 insertions(+) create mode 100644 drivers/staging/rtl8188eu/core/rtw_wlan_util.c create mode 100644 drivers/staging/rtl8188eu/core/rtw_xmit.c diff --git a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c new file mode 100644 index 0000000000000..a43fc8892d612 --- /dev/null +++ b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c @@ -0,0 +1,1689 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTW_WLAN_UTIL_C_ + +#include +#include +#include + +static unsigned char ARTHEROS_OUI1[] = {0x00, 0x03, 0x7f}; +static unsigned char ARTHEROS_OUI2[] = {0x00, 0x13, 0x74}; + +static unsigned char BROADCOM_OUI1[] = {0x00, 0x10, 0x18}; +static unsigned char BROADCOM_OUI2[] = {0x00, 0x0a, 0xf7}; + +static unsigned char CISCO_OUI[] = {0x00, 0x40, 0x96}; +static unsigned char MARVELL_OUI[] = {0x00, 0x50, 0x43}; +static unsigned char RALINK_OUI[] = {0x00, 0x0c, 0x43}; +static unsigned char REALTEK_OUI[] = {0x00, 0xe0, 0x4c}; +static unsigned char AIRGOCAP_OUI[] = {0x00, 0x0a, 0xf5}; +static unsigned char EPIGRAM_OUI[] = {0x00, 0x90, 0x4c}; + +unsigned char REALTEK_96B_IE[] = {0x00, 0xe0, 0x4c, 0x02, 0x01, 0x20}; + +#define R2T_PHY_DELAY (0) + +/* define WAIT_FOR_BCN_TO_M (3000) */ +#define WAIT_FOR_BCN_TO_MIN (6000) +#define WAIT_FOR_BCN_TO_MAX (20000) + +static u8 rtw_basic_rate_cck[4] = { + IEEE80211_CCK_RATE_1MB|IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_2MB|IEEE80211_BASIC_RATE_MASK, + IEEE80211_CCK_RATE_5MB|IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_11MB|IEEE80211_BASIC_RATE_MASK +}; + +static u8 rtw_basic_rate_ofdm[3] = { + IEEE80211_OFDM_RATE_6MB|IEEE80211_BASIC_RATE_MASK, IEEE80211_OFDM_RATE_12MB|IEEE80211_BASIC_RATE_MASK, + IEEE80211_OFDM_RATE_24MB|IEEE80211_BASIC_RATE_MASK +}; + +static u8 rtw_basic_rate_mix[7] = { + IEEE80211_CCK_RATE_1MB|IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_2MB|IEEE80211_BASIC_RATE_MASK, + IEEE80211_CCK_RATE_5MB|IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_11MB|IEEE80211_BASIC_RATE_MASK, + IEEE80211_OFDM_RATE_6MB|IEEE80211_BASIC_RATE_MASK, IEEE80211_OFDM_RATE_12MB|IEEE80211_BASIC_RATE_MASK, + IEEE80211_OFDM_RATE_24MB|IEEE80211_BASIC_RATE_MASK +}; + +int cckrates_included(unsigned char *rate, int ratelen) +{ + int i; + + for (i = 0; i < ratelen; i++) { + if ((((rate[i]) & 0x7f) == 2) || (((rate[i]) & 0x7f) == 4) || + (((rate[i]) & 0x7f) == 11) || (((rate[i]) & 0x7f) == 22)) + return true; + } + return false; +} + +int cckratesonly_included(unsigned char *rate, int ratelen) +{ + int i; + + for (i = 0; i < ratelen; i++) { + if ((((rate[i]) & 0x7f) != 2) && (((rate[i]) & 0x7f) != 4) && + (((rate[i]) & 0x7f) != 11) && (((rate[i]) & 0x7f) != 22)) + return false; + } + + return true; +} + +unsigned char networktype_to_raid(unsigned char network_type) +{ + unsigned char raid; + + switch (network_type) { + case WIRELESS_11B: + raid = RATR_INX_WIRELESS_B; + break; + case WIRELESS_11A: + case WIRELESS_11G: + raid = RATR_INX_WIRELESS_G; + break; + case WIRELESS_11BG: + raid = RATR_INX_WIRELESS_GB; + break; + case WIRELESS_11_24N: + case WIRELESS_11_5N: + raid = RATR_INX_WIRELESS_N; + break; + case WIRELESS_11A_5N: + case WIRELESS_11G_24N: + raid = RATR_INX_WIRELESS_NG; + break; + case WIRELESS_11BG_24N: + raid = RATR_INX_WIRELESS_NGB; + break; + default: + raid = RATR_INX_WIRELESS_GB; + break; + } + return raid; +} + +u8 judge_network_type(struct adapter *padapter, unsigned char *rate, int ratelen) +{ + u8 network_type = 0; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + if (pmlmeext->cur_channel > 14) { + if (pmlmeinfo->HT_enable) + network_type = WIRELESS_11_5N; + + network_type |= WIRELESS_11A; + } else { + if (pmlmeinfo->HT_enable) + network_type = WIRELESS_11_24N; + + if ((cckratesonly_included(rate, ratelen)) == true) + network_type |= WIRELESS_11B; + else if ((cckrates_included(rate, ratelen)) == true) + network_type |= WIRELESS_11BG; + else + network_type |= WIRELESS_11G; + } + return network_type; +} + +static unsigned char ratetbl_val_2wifirate(unsigned char rate) +{ + unsigned char val = 0; + + switch (rate & 0x7f) { + case 0: + val = IEEE80211_CCK_RATE_1MB; + break; + case 1: + val = IEEE80211_CCK_RATE_2MB; + break; + case 2: + val = IEEE80211_CCK_RATE_5MB; + break; + case 3: + val = IEEE80211_CCK_RATE_11MB; + break; + case 4: + val = IEEE80211_OFDM_RATE_6MB; + break; + case 5: + val = IEEE80211_OFDM_RATE_9MB; + break; + case 6: + val = IEEE80211_OFDM_RATE_12MB; + break; + case 7: + val = IEEE80211_OFDM_RATE_18MB; + break; + case 8: + val = IEEE80211_OFDM_RATE_24MB; + break; + case 9: + val = IEEE80211_OFDM_RATE_36MB; + break; + case 10: + val = IEEE80211_OFDM_RATE_48MB; + break; + case 11: + val = IEEE80211_OFDM_RATE_54MB; + break; + } + return val; +} + +static int is_basicrate(struct adapter *padapter, unsigned char rate) +{ + int i; + unsigned char val; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + + for (i = 0; i < NumRates; i++) { + val = pmlmeext->basicrate[i]; + + if ((val != 0xff) && (val != 0xfe)) { + if (rate == ratetbl_val_2wifirate(val)) + return true; + } + } + return false; +} + +static unsigned int ratetbl2rateset(struct adapter *padapter, unsigned char *rateset) +{ + int i; + unsigned char rate; + unsigned int len = 0; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + + for (i = 0; i < NumRates; i++) { + rate = pmlmeext->datarate[i]; + + switch (rate) { + case 0xff: + return len; + case 0xfe: + continue; + default: + rate = ratetbl_val_2wifirate(rate); + + if (is_basicrate(padapter, rate) == true) + rate |= IEEE80211_BASIC_RATE_MASK; + + rateset[len] = rate; + len++; + break; + } + } + return len; +} + +void get_rate_set(struct adapter *padapter, unsigned char *pbssrate, int *bssrate_len) +{ + unsigned char supportedrates[NumRates]; + + _rtw_memset(supportedrates, 0, NumRates); + *bssrate_len = ratetbl2rateset(padapter, supportedrates); + memcpy(pbssrate, supportedrates, *bssrate_len); +} + +void UpdateBrateTbl(struct adapter *Adapter, u8 *mbrate) +{ + u8 i; + u8 rate; + + /* 1M, 2M, 5.5M, 11M, 6M, 12M, 24M are mandatory. */ + for (i = 0; i < NDIS_802_11_LENGTH_RATES_EX; i++) { + rate = mbrate[i] & 0x7f; + switch (rate) { + case IEEE80211_CCK_RATE_1MB: + case IEEE80211_CCK_RATE_2MB: + case IEEE80211_CCK_RATE_5MB: + case IEEE80211_CCK_RATE_11MB: + case IEEE80211_OFDM_RATE_6MB: + case IEEE80211_OFDM_RATE_12MB: + case IEEE80211_OFDM_RATE_24MB: + mbrate[i] |= IEEE80211_BASIC_RATE_MASK; + break; + } + } +} + +void UpdateBrateTblForSoftAP(u8 *bssrateset, u32 bssratelen) +{ + u8 i; + u8 rate; + + for (i = 0; i < bssratelen; i++) { + rate = bssrateset[i] & 0x7f; + switch (rate) { + case IEEE80211_CCK_RATE_1MB: + case IEEE80211_CCK_RATE_2MB: + case IEEE80211_CCK_RATE_5MB: + case IEEE80211_CCK_RATE_11MB: + bssrateset[i] |= IEEE80211_BASIC_RATE_MASK; + break; + } + } +} + +void Save_DM_Func_Flag(struct adapter *padapter) +{ + u8 saveflag = true; + + rtw_hal_set_hwreg(padapter, HW_VAR_DM_FUNC_OP, (u8 *)(&saveflag)); +} + +void Restore_DM_Func_Flag(struct adapter *padapter) +{ + u8 saveflag = false; + + rtw_hal_set_hwreg(padapter, HW_VAR_DM_FUNC_OP, (u8 *)(&saveflag)); +} + +void Switch_DM_Func(struct adapter *padapter, u32 mode, u8 enable) +{ + if (enable) + rtw_hal_set_hwreg(padapter, HW_VAR_DM_FUNC_SET, (u8 *)(&mode)); + else + rtw_hal_set_hwreg(padapter, HW_VAR_DM_FUNC_CLR, (u8 *)(&mode)); +} + +static void Set_NETYPE0_MSR(struct adapter *padapter, u8 type) +{ + rtw_hal_set_hwreg(padapter, HW_VAR_MEDIA_STATUS, (u8 *)(&type)); +} + +void Set_MSR(struct adapter *padapter, u8 type) +{ + Set_NETYPE0_MSR(padapter, type); +} + +inline u8 rtw_get_oper_ch(struct adapter *adapter) +{ + return adapter->mlmeextpriv.oper_channel; +} + +inline void rtw_set_oper_ch(struct adapter *adapter, u8 ch) +{ + adapter->mlmeextpriv.oper_channel = ch; +} + +inline u8 rtw_get_oper_bw(struct adapter *adapter) +{ + return adapter->mlmeextpriv.oper_bwmode; +} + +inline void rtw_set_oper_bw(struct adapter *adapter, u8 bw) +{ + adapter->mlmeextpriv.oper_bwmode = bw; +} + +inline u8 rtw_get_oper_choffset(struct adapter *adapter) +{ + return adapter->mlmeextpriv.oper_ch_offset; +} + +inline void rtw_set_oper_choffset(struct adapter *adapter, u8 offset) +{ + adapter->mlmeextpriv.oper_ch_offset = offset; +} + +void SelectChannel(struct adapter *padapter, unsigned char channel) +{ + /* saved channel info */ + rtw_set_oper_ch(padapter, channel); + rtw_hal_set_chan(padapter, channel); +} + +void SetBWMode(struct adapter *padapter, unsigned short bwmode, + unsigned char channel_offset) +{ + /* saved bw info */ + rtw_set_oper_bw(padapter, bwmode); + rtw_set_oper_choffset(padapter, channel_offset); + + rtw_hal_set_bwmode(padapter, (enum ht_channel_width)bwmode, channel_offset); +} + +void set_channel_bwmode(struct adapter *padapter, unsigned char channel, unsigned char channel_offset, unsigned short bwmode) +{ + u8 center_ch; + + if (padapter->bNotifyChannelChange) + DBG_88E("[%s] ch = %d, offset = %d, bwmode = %d\n", __func__, channel, channel_offset, bwmode); + + if ((bwmode == HT_CHANNEL_WIDTH_20) || + (channel_offset == HAL_PRIME_CHNL_OFFSET_DONT_CARE)) { + /* SelectChannel(padapter, channel); */ + center_ch = channel; + } else { + /* switch to the proper channel */ + if (channel_offset == HAL_PRIME_CHNL_OFFSET_LOWER) { + /* SelectChannel(padapter, channel + 2); */ + center_ch = channel + 2; + } else { + /* SelectChannel(padapter, channel - 2); */ + center_ch = channel - 2; + } + } + + /* set Channel */ + /* saved channel/bw info */ + rtw_set_oper_ch(padapter, channel); + rtw_set_oper_bw(padapter, bwmode); + rtw_set_oper_choffset(padapter, channel_offset); + + rtw_hal_set_chan(padapter, center_ch); /* set center channel */ + SetBWMode(padapter, bwmode, channel_offset); +} + +int get_bsstype(unsigned short capability) +{ + if (capability & BIT(0)) + return WIFI_FW_AP_STATE; + else if (capability & BIT(1)) + return WIFI_FW_ADHOC_STATE; + else + return 0; +} + +__inline u8 *get_my_bssid(struct wlan_bssid_ex *pnetwork) +{ + return pnetwork->MacAddress; +} + +u16 get_beacon_interval(struct wlan_bssid_ex *bss) +{ + __le16 val; + memcpy((unsigned char *)&val, rtw_get_beacon_interval_from_ie(bss->IEs), 2); + + return le16_to_cpu(val); +} + +int is_client_associated_to_ap(struct adapter *padapter) +{ + struct mlme_ext_priv *pmlmeext; + struct mlme_ext_info *pmlmeinfo; + + if (!padapter) + return _FAIL; + + pmlmeext = &padapter->mlmeextpriv; + pmlmeinfo = &(pmlmeext->mlmext_info); + + if ((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE)) + return true; + else + return _FAIL; +} + +int is_client_associated_to_ibss(struct adapter *padapter) +{ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + if ((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE)) + return true; + else + return _FAIL; +} + +int is_IBSS_empty(struct adapter *padapter) +{ + unsigned int i; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + for (i = IBSS_START_MAC_ID; i < NUM_STA; i++) { + if (pmlmeinfo->FW_sta_info[i].status == 1) + return _FAIL; + } + return true; +} + +unsigned int decide_wait_for_beacon_timeout(unsigned int bcn_interval) +{ + if ((bcn_interval << 2) < WAIT_FOR_BCN_TO_MIN) + return WAIT_FOR_BCN_TO_MIN; + else if ((bcn_interval << 2) > WAIT_FOR_BCN_TO_MAX) + return WAIT_FOR_BCN_TO_MAX; + else + return bcn_interval << 2; +} + +void CAM_empty_entry(struct adapter *Adapter, u8 ucIndex) +{ + rtw_hal_set_hwreg(Adapter, HW_VAR_CAM_EMPTY_ENTRY, (u8 *)(&ucIndex)); +} + +void invalidate_cam_all(struct adapter *padapter) +{ + rtw_hal_set_hwreg(padapter, HW_VAR_CAM_INVALID_ALL, NULL); +} + +void write_cam(struct adapter *padapter, u8 entry, u16 ctrl, u8 *mac, u8 *key) +{ + unsigned int i, val, addr; + int j; + u32 cam_val[2]; + + addr = entry << 3; + + for (j = 5; j >= 0; j--) { + switch (j) { + case 0: + val = (ctrl | (mac[0] << 16) | (mac[1] << 24)); + break; + case 1: + val = (mac[2] | (mac[3] << 8) | (mac[4] << 16) | (mac[5] << 24)); + break; + default: + i = (j - 2) << 2; + val = (key[i] | (key[i+1] << 8) | (key[i+2] << 16) | (key[i+3] << 24)); + break; + } + + cam_val[0] = val; + cam_val[1] = addr + (unsigned int)j; + + rtw_hal_set_hwreg(padapter, HW_VAR_CAM_WRITE, (u8 *)cam_val); + } +} + +void clear_cam_entry(struct adapter *padapter, u8 entry) +{ + unsigned char null_sta[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + unsigned char null_key[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + + write_cam(padapter, entry, 0, null_sta, null_key); +} + +int allocate_fw_sta_entry(struct adapter *padapter) +{ + unsigned int mac_id; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + for (mac_id = IBSS_START_MAC_ID; mac_id < NUM_STA; mac_id++) { + if (pmlmeinfo->FW_sta_info[mac_id].status == 0) { + pmlmeinfo->FW_sta_info[mac_id].status = 1; + pmlmeinfo->FW_sta_info[mac_id].retry = 0; + break; + } + } + + return mac_id; +} + +void flush_all_cam_entry(struct adapter *padapter) +{ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + rtw_hal_set_hwreg(padapter, HW_VAR_CAM_INVALID_ALL, NULL); + + _rtw_memset((u8 *)(pmlmeinfo->FW_sta_info), 0, sizeof(pmlmeinfo->FW_sta_info)); +} + +int WMM_param_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) +{ + /* struct registry_priv *pregpriv = &padapter->registrypriv; */ + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + if (pmlmepriv->qospriv.qos_option == 0) { + pmlmeinfo->WMM_enable = 0; + return _FAIL; + } + + pmlmeinfo->WMM_enable = 1; + memcpy(&(pmlmeinfo->WMM_param), (pIE->data + 6), sizeof(struct WMM_para_element)); + return true; +} + +void WMMOnAssocRsp(struct adapter *padapter) +{ + u8 ACI, ACM, AIFS, ECWMin, ECWMax, aSifsTime; + u8 acm_mask; + u16 TXOP; + u32 acParm, i; + u32 edca[4], inx[4]; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct registry_priv *pregpriv = &padapter->registrypriv; + + if (pmlmeinfo->WMM_enable == 0) { + padapter->mlmepriv.acm_mask = 0; + return; + } + + acm_mask = 0; + + if (pmlmeext->cur_wireless_mode == WIRELESS_11B) + aSifsTime = 10; + else + aSifsTime = 16; + + for (i = 0; i < 4; i++) { + ACI = (pmlmeinfo->WMM_param.ac_param[i].ACI_AIFSN >> 5) & 0x03; + ACM = (pmlmeinfo->WMM_param.ac_param[i].ACI_AIFSN >> 4) & 0x01; + + /* AIFS = AIFSN * slot time + SIFS - r2t phy delay */ + AIFS = (pmlmeinfo->WMM_param.ac_param[i].ACI_AIFSN & 0x0f) * pmlmeinfo->slotTime + aSifsTime; + + ECWMin = (pmlmeinfo->WMM_param.ac_param[i].CW & 0x0f); + ECWMax = (pmlmeinfo->WMM_param.ac_param[i].CW & 0xf0) >> 4; + TXOP = le16_to_cpu(pmlmeinfo->WMM_param.ac_param[i].TXOP_limit); + + acParm = AIFS | (ECWMin << 8) | (ECWMax << 12) | (TXOP << 16); + + switch (ACI) { + case 0x0: + rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_BE, (u8 *)(&acParm)); + acm_mask |= (ACM ? BIT(1) : 0); + edca[XMIT_BE_QUEUE] = acParm; + break; + case 0x1: + rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_BK, (u8 *)(&acParm)); + edca[XMIT_BK_QUEUE] = acParm; + break; + case 0x2: + rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_VI, (u8 *)(&acParm)); + acm_mask |= (ACM ? BIT(2) : 0); + edca[XMIT_VI_QUEUE] = acParm; + break; + case 0x3: + rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_VO, (u8 *)(&acParm)); + acm_mask |= (ACM ? BIT(3) : 0); + edca[XMIT_VO_QUEUE] = acParm; + break; + } + + DBG_88E("WMM(%x): %x, %x\n", ACI, ACM, acParm); + } + + if (padapter->registrypriv.acm_method == 1) + rtw_hal_set_hwreg(padapter, HW_VAR_ACM_CTRL, (u8 *)(&acm_mask)); + else + padapter->mlmepriv.acm_mask = acm_mask; + + inx[0] = 0; inx[1] = 1; inx[2] = 2; inx[3] = 3; + + if (pregpriv->wifi_spec == 1) { + u32 j, tmp, change_inx; + + /* entry indx: 0->vo, 1->vi, 2->be, 3->bk. */ + for (i = 0; i < 4; i++) { + for (j = i+1; j < 4; j++) { + /* compare CW and AIFS */ + if ((edca[j] & 0xFFFF) < (edca[i] & 0xFFFF)) { + change_inx = true; + } else if ((edca[j] & 0xFFFF) == (edca[i] & 0xFFFF)) { + /* compare TXOP */ + if ((edca[j] >> 16) > (edca[i] >> 16)) + change_inx = true; + } + + if (change_inx) { + tmp = edca[i]; + edca[i] = edca[j]; + edca[j] = tmp; + + tmp = inx[i]; + inx[i] = inx[j]; + inx[j] = tmp; + + change_inx = false; + } + } + } + } + + for (i = 0; i < 4; i++) { + pxmitpriv->wmm_para_seq[i] = inx[i]; + DBG_88E("wmm_para_seq(%d): %d\n", i, pxmitpriv->wmm_para_seq[i]); + } + + return; +} + +static void bwmode_update_check(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) +{ + unsigned char new_bwmode; + unsigned char new_ch_offset; + struct HT_info_element *pHT_info; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct registry_priv *pregistrypriv = &padapter->registrypriv; + struct ht_priv *phtpriv = &pmlmepriv->htpriv; + + if (!pIE) + return; + + if (!phtpriv) + return; + + if (pIE->Length > sizeof(struct HT_info_element)) + return; + + pHT_info = (struct HT_info_element *)pIE->data; + + if ((pHT_info->infos[0] & BIT(2)) && pregistrypriv->cbw40_enable) { + new_bwmode = HT_CHANNEL_WIDTH_40; + + switch (pHT_info->infos[0] & 0x3) { + case 1: + new_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER; + break; + case 3: + new_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER; + break; + default: + new_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; + break; + } + } else { + new_bwmode = HT_CHANNEL_WIDTH_20; + new_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; + } + + if ((new_bwmode != pmlmeext->cur_bwmode) || + (new_ch_offset != pmlmeext->cur_ch_offset)) { + pmlmeinfo->bwmode_updated = true; + + pmlmeext->cur_bwmode = new_bwmode; + pmlmeext->cur_ch_offset = new_ch_offset; + + /* update HT info also */ + HT_info_handler(padapter, pIE); + } else { + pmlmeinfo->bwmode_updated = false; + } + + if (pmlmeinfo->bwmode_updated) { + struct sta_info *psta; + struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); + struct sta_priv *pstapriv = &padapter->stapriv; + + /* set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); */ + + /* update ap's stainfo */ + psta = rtw_get_stainfo(pstapriv, cur_network->MacAddress); + if (psta) { + struct ht_priv *phtpriv_sta = &psta->htpriv; + + if (phtpriv_sta->ht_option) { + /* bwmode */ + phtpriv_sta->bwmode = pmlmeext->cur_bwmode; + phtpriv_sta->ch_offset = pmlmeext->cur_ch_offset; + } else { + phtpriv_sta->bwmode = HT_CHANNEL_WIDTH_20; + phtpriv_sta->ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; + } + } + } +} + +void HT_caps_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) +{ + unsigned int i; + u8 rf_type; + u8 max_AMPDU_len, min_MPDU_spacing; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct ht_priv *phtpriv = &pmlmepriv->htpriv; + + if (pIE == NULL) + return; + + if (!phtpriv->ht_option) + return; + + pmlmeinfo->HT_caps_enable = 1; + + for (i = 0; i < (pIE->Length); i++) { + if (i != 2) { + /* Got the endian issue here. */ + pmlmeinfo->HT_caps.u.HT_cap[i] &= (pIE->data[i]); + } else { + /* modify from fw by Thomas 2010/11/17 */ + if ((pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x3) > (pIE->data[i] & 0x3)) + max_AMPDU_len = (pIE->data[i] & 0x3); + else + max_AMPDU_len = (pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x3); + + if ((pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c) > (pIE->data[i] & 0x1c)) + min_MPDU_spacing = (pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c); + else + min_MPDU_spacing = (pIE->data[i] & 0x1c); + + pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para = max_AMPDU_len | min_MPDU_spacing; + } + } + + rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); + + /* update the MCS rates */ + for (i = 0; i < 16; i++) { + if ((rf_type == RF_1T1R) || (rf_type == RF_1T2R)) + pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate[i] &= MCS_rate_1R[i]; + else + pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate[i] &= MCS_rate_2R[i]; + } + return; +} + +void HT_info_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) +{ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct ht_priv *phtpriv = &pmlmepriv->htpriv; + + if (pIE == NULL) + return; + + if (!phtpriv->ht_option) + return; + + if (pIE->Length > sizeof(struct HT_info_element)) + return; + + pmlmeinfo->HT_info_enable = 1; + memcpy(&(pmlmeinfo->HT_info), pIE->data, pIE->Length); + return; +} + +void HTOnAssocRsp(struct adapter *padapter) +{ + unsigned char max_AMPDU_len; + unsigned char min_MPDU_spacing; + /* struct registry_priv *pregpriv = &padapter->registrypriv; */ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + DBG_88E("%s\n", __func__); + + if ((pmlmeinfo->HT_info_enable) && (pmlmeinfo->HT_caps_enable)) { + pmlmeinfo->HT_enable = 1; + } else { + pmlmeinfo->HT_enable = 0; + return; + } + + /* handle A-MPDU parameter field */ + /* + AMPDU_para [1:0]:Max AMPDU Len => 0:8k , 1:16k, 2:32k, 3:64k + AMPDU_para [4:2]:Min MPDU Start Spacing + */ + max_AMPDU_len = pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x03; + + min_MPDU_spacing = (pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c) >> 2; + + rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_MIN_SPACE, (u8 *)(&min_MPDU_spacing)); + + rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_FACTOR, (u8 *)(&max_AMPDU_len)); +} + +void ERP_IE_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) +{ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + if (pIE->Length > 1) + return; + + pmlmeinfo->ERP_enable = 1; + memcpy(&(pmlmeinfo->ERP_IE), pIE->data, pIE->Length); +} + +void VCS_update(struct adapter *padapter, struct sta_info *psta) +{ + struct registry_priv *pregpriv = &padapter->registrypriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + switch (pregpriv->vrtl_carrier_sense) { /* 0:off 1:on 2:auto */ + case 0: /* off */ + psta->rtsen = 0; + psta->cts2self = 0; + break; + case 1: /* on */ + if (pregpriv->vcs_type == 1) { /* 1:RTS/CTS 2:CTS to self */ + psta->rtsen = 1; + psta->cts2self = 0; + } else { + psta->rtsen = 0; + psta->cts2self = 1; + } + break; + case 2: /* auto */ + default: + if ((pmlmeinfo->ERP_enable) && (pmlmeinfo->ERP_IE & BIT(1))) { + if (pregpriv->vcs_type == 1) { + psta->rtsen = 1; + psta->cts2self = 0; + } else { + psta->rtsen = 0; + psta->cts2self = 1; + } + } else { + psta->rtsen = 0; + psta->cts2self = 0; + } + break; + } +} + +int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) +{ + unsigned int len; + unsigned char *p; + unsigned short val16, subtype; + struct wlan_network *cur_network = &(Adapter->mlmepriv.cur_network); + /* u8 wpa_ie[255], rsn_ie[255]; */ + u16 wpa_len = 0, rsn_len = 0; + u8 encryp_protocol = 0; + struct wlan_bssid_ex *bssid; + int group_cipher = 0, pairwise_cipher = 0, is_8021x = 0; + unsigned char *pbuf; + u32 wpa_ielen = 0; + u8 *pbssid = GetAddr3Ptr(pframe); + u32 hidden_ssid = 0; + struct HT_info_element *pht_info = NULL; + struct rtw_ieee80211_ht_cap *pht_cap = NULL; + u32 bcn_channel; + unsigned short ht_cap_info; + unsigned char ht_info_infos_0; + + if (is_client_associated_to_ap(Adapter) == false) + return true; + + len = packet_len - sizeof(struct rtw_ieee80211_hdr_3addr); + + if (len > MAX_IE_SZ) { + DBG_88E("%s IE too long for survey event\n", __func__); + return _FAIL; + } + + if (_rtw_memcmp(cur_network->network.MacAddress, pbssid, 6) == false) { + DBG_88E("Oops: rtw_check_network_encrypt linked but recv other bssid bcn\n%pM %pM\n", + (pbssid), (cur_network->network.MacAddress)); + return true; + } + + bssid = (struct wlan_bssid_ex *)rtw_zmalloc(sizeof(struct wlan_bssid_ex)); + + subtype = GetFrameSubType(pframe) >> 4; + + if (subtype == WIFI_BEACON) + bssid->Reserved[0] = 1; + + bssid->Length = sizeof(struct wlan_bssid_ex) - MAX_IE_SZ + len; + + /* below is to copy the information element */ + bssid->IELength = len; + memcpy(bssid->IEs, (pframe + sizeof(struct rtw_ieee80211_hdr_3addr)), bssid->IELength); + + /* check bw and channel offset */ + /* parsing HT_CAP_IE */ + p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _HT_CAPABILITY_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_); + if (p && len > 0) { + pht_cap = (struct rtw_ieee80211_ht_cap *)(p + 2); + ht_cap_info = pht_cap->cap_info; + } else { + ht_cap_info = 0; + } + /* parsing HT_INFO_IE */ + p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _HT_ADD_INFO_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_); + if (p && len > 0) { + pht_info = (struct HT_info_element *)(p + 2); + ht_info_infos_0 = pht_info->infos[0]; + } else { + ht_info_infos_0 = 0; + } + if (ht_cap_info != cur_network->BcnInfo.ht_cap_info || + ((ht_info_infos_0&0x03) != (cur_network->BcnInfo.ht_info_infos_0&0x03))) { + DBG_88E("%s bcn now: ht_cap_info:%x ht_info_infos_0:%x\n", __func__, + ht_cap_info, ht_info_infos_0); + DBG_88E("%s bcn link: ht_cap_info:%x ht_info_infos_0:%x\n", __func__, + cur_network->BcnInfo.ht_cap_info, cur_network->BcnInfo.ht_info_infos_0); + DBG_88E("%s bw mode change, disconnect\n", __func__); + /* bcn_info_update */ + cur_network->BcnInfo.ht_cap_info = ht_cap_info; + cur_network->BcnInfo.ht_info_infos_0 = ht_info_infos_0; + /* to do : need to check that whether modify related register of BB or not */ + /* goto _mismatch; */ + } + + /* Checking for channel */ + p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _DSSET_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_); + if (p) { + bcn_channel = *(p + 2); + } else {/* In 5G, some ap do not have DSSET IE checking HT info for channel */ + p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _HT_ADD_INFO_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_); + if (pht_info) { + bcn_channel = pht_info->primary_channel; + } else { /* we don't find channel IE, so don't check it */ + DBG_88E("Oops: %s we don't find channel IE, so don't check it\n", __func__); + bcn_channel = Adapter->mlmeextpriv.cur_channel; + } + } + if (bcn_channel != Adapter->mlmeextpriv.cur_channel) { + DBG_88E("%s beacon channel:%d cur channel:%d disconnect\n", __func__, + bcn_channel, Adapter->mlmeextpriv.cur_channel); + goto _mismatch; + } + + /* checking SSID */ + p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _SSID_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_); + if (p == NULL) { + DBG_88E("%s marc: cannot find SSID for survey event\n", __func__); + hidden_ssid = true; + } else { + hidden_ssid = false; + } + + if ((NULL != p) && (false == hidden_ssid && (*(p + 1)))) { + memcpy(bssid->Ssid.Ssid, (p + 2), *(p + 1)); + bssid->Ssid.SsidLength = *(p + 1); + } else { + bssid->Ssid.SsidLength = 0; + bssid->Ssid.Ssid[0] = '\0'; + } + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s bssid.Ssid.Ssid:%s bssid.Ssid.SsidLength:%d " + "cur_network->network.Ssid.Ssid:%s len:%d\n", __func__, bssid->Ssid.Ssid, + bssid->Ssid.SsidLength, cur_network->network.Ssid.Ssid, + cur_network->network.Ssid.SsidLength)); + + if (!_rtw_memcmp(bssid->Ssid.Ssid, cur_network->network.Ssid.Ssid, 32) || + bssid->Ssid.SsidLength != cur_network->network.Ssid.SsidLength) { + if (bssid->Ssid.Ssid[0] != '\0' && bssid->Ssid.SsidLength != 0) { /* not hidden ssid */ + DBG_88E("%s(), SSID is not match return FAIL\n", __func__); + goto _mismatch; + } + } + + /* check encryption info */ + val16 = rtw_get_capability((struct wlan_bssid_ex *)bssid); + + if (val16 & BIT(4)) + bssid->Privacy = 1; + else + bssid->Privacy = 0; + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, + ("%s(): cur_network->network.Privacy is %d, bssid.Privacy is %d\n", + __func__, cur_network->network.Privacy, bssid->Privacy)); + if (cur_network->network.Privacy != bssid->Privacy) { + DBG_88E("%s(), privacy is not match return FAIL\n", __func__); + goto _mismatch; + } + + rtw_get_sec_ie(bssid->IEs, bssid->IELength, NULL, &rsn_len, NULL, &wpa_len); + + if (rsn_len > 0) { + encryp_protocol = ENCRYP_PROTOCOL_WPA2; + } else if (wpa_len > 0) { + encryp_protocol = ENCRYP_PROTOCOL_WPA; + } else { + if (bssid->Privacy) + encryp_protocol = ENCRYP_PROTOCOL_WEP; + } + + if (cur_network->BcnInfo.encryp_protocol != encryp_protocol) { + DBG_88E("%s(): enctyp is not match , return FAIL\n", __func__); + goto _mismatch; + } + + if (encryp_protocol == ENCRYP_PROTOCOL_WPA || encryp_protocol == ENCRYP_PROTOCOL_WPA2) { + pbuf = rtw_get_wpa_ie(&bssid->IEs[12], &wpa_ielen, bssid->IELength-12); + if (pbuf && (wpa_ielen > 0)) { + if (_SUCCESS == rtw_parse_wpa_ie(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is_8021x)) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, + ("%s pnetwork->pairwise_cipher: %d, group_cipher is %d, is_8021x is %d\n", __func__, + pairwise_cipher, group_cipher, is_8021x)); + } + } else { + pbuf = rtw_get_wpa2_ie(&bssid->IEs[12], &wpa_ielen, bssid->IELength-12); + + if (pbuf && (wpa_ielen > 0)) { + if (_SUCCESS == rtw_parse_wpa2_ie(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is_8021x)) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, + ("%s pnetwork->pairwise_cipher: %d, pnetwork->group_cipher is %d, is_802x is %d\n", + __func__, pairwise_cipher, group_cipher, is_8021x)); + } + } + } + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, + ("%s cur_network->group_cipher is %d: %d\n", __func__, cur_network->BcnInfo.group_cipher, group_cipher)); + if (pairwise_cipher != cur_network->BcnInfo.pairwise_cipher || group_cipher != cur_network->BcnInfo.group_cipher) { + DBG_88E("%s pairwise_cipher(%x:%x) or group_cipher(%x:%x) is not match , return FAIL\n", __func__, + pairwise_cipher, cur_network->BcnInfo.pairwise_cipher, + group_cipher, cur_network->BcnInfo.group_cipher); + goto _mismatch; + } + + if (is_8021x != cur_network->BcnInfo.is_8021x) { + DBG_88E("%s authentication is not match , return FAIL\n", __func__); + goto _mismatch; + } + } + + kfree(bssid); + return _SUCCESS; + +_mismatch: + kfree(bssid); + return _FAIL; + + _func_exit_; +} + +void update_beacon_info(struct adapter *padapter, u8 *pframe, uint pkt_len, struct sta_info *psta) +{ + unsigned int i; + unsigned int len; + struct ndis_802_11_var_ie *pIE; + + len = pkt_len - (_BEACON_IE_OFFSET_ + WLAN_HDR_A3_LEN); + + for (i = 0; i < len;) { + pIE = (struct ndis_802_11_var_ie *)(pframe + (_BEACON_IE_OFFSET_ + WLAN_HDR_A3_LEN) + i); + + switch (pIE->ElementID) { + case _HT_EXTRA_INFO_IE_: /* HT info */ + /* HT_info_handler(padapter, pIE); */ + bwmode_update_check(padapter, pIE); + break; + case _ERPINFO_IE_: + ERP_IE_handler(padapter, pIE); + VCS_update(padapter, psta); + break; + default: + break; + } + + i += (pIE->Length + 2); + } +} + +unsigned int is_ap_in_tkip(struct adapter *padapter) +{ + u32 i; + struct ndis_802_11_var_ie *pIE; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); + + if (rtw_get_capability((struct wlan_bssid_ex *)cur_network) & WLAN_CAPABILITY_PRIVACY) { + for (i = sizeof(struct ndis_802_11_fixed_ie); i < pmlmeinfo->network.IELength;) { + pIE = (struct ndis_802_11_var_ie *)(pmlmeinfo->network.IEs + i); + + switch (pIE->ElementID) { + case _VENDOR_SPECIFIC_IE_: + if ((_rtw_memcmp(pIE->data, RTW_WPA_OUI, 4)) && (_rtw_memcmp((pIE->data + 12), WPA_TKIP_CIPHER, 4))) + return true; + break; + case _RSN_IE_2_: + if (_rtw_memcmp((pIE->data + 8), RSN_TKIP_CIPHER, 4)) + return true; + default: + break; + } + + i += (pIE->Length + 2); + } + return false; + } else { + return false; + } +} + +unsigned int should_forbid_n_rate(struct adapter *padapter) +{ + u32 i; + struct ndis_802_11_var_ie *pIE; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct wlan_bssid_ex *cur_network = &pmlmepriv->cur_network.network; + + if (rtw_get_capability((struct wlan_bssid_ex *)cur_network) & WLAN_CAPABILITY_PRIVACY) { + for (i = sizeof(struct ndis_802_11_fixed_ie); i < cur_network->IELength;) { + pIE = (struct ndis_802_11_var_ie *)(cur_network->IEs + i); + + switch (pIE->ElementID) { + case _VENDOR_SPECIFIC_IE_: + if (_rtw_memcmp(pIE->data, RTW_WPA_OUI, 4) && + ((_rtw_memcmp((pIE->data + 12), WPA_CIPHER_SUITE_CCMP, 4)) || + (_rtw_memcmp((pIE->data + 16), WPA_CIPHER_SUITE_CCMP, 4)))) + return false; + break; + case _RSN_IE_2_: + if ((_rtw_memcmp((pIE->data + 8), RSN_CIPHER_SUITE_CCMP, 4)) || + (_rtw_memcmp((pIE->data + 12), RSN_CIPHER_SUITE_CCMP, 4))) + return false; + default: + break; + } + + i += (pIE->Length + 2); + } + + return true; + } else { + return false; + } +} + +unsigned int is_ap_in_wep(struct adapter *padapter) +{ + u32 i; + struct ndis_802_11_var_ie *pIE; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); + + if (rtw_get_capability((struct wlan_bssid_ex *)cur_network) & WLAN_CAPABILITY_PRIVACY) { + for (i = sizeof(struct ndis_802_11_fixed_ie); i < pmlmeinfo->network.IELength;) { + pIE = (struct ndis_802_11_var_ie *)(pmlmeinfo->network.IEs + i); + + switch (pIE->ElementID) { + case _VENDOR_SPECIFIC_IE_: + if (_rtw_memcmp(pIE->data, RTW_WPA_OUI, 4)) + return false; + break; + case _RSN_IE_2_: + return false; + default: + break; + } + i += (pIE->Length + 2); + } + return true; + } else { + return false; + } +} + +int wifirate2_ratetbl_inx(unsigned char rate) +{ + int inx = 0; + rate = rate & 0x7f; + + switch (rate) { + case 54*2: + inx = 11; + break; + case 48*2: + inx = 10; + break; + case 36*2: + inx = 9; + break; + case 24*2: + inx = 8; + break; + case 18*2: + inx = 7; + break; + case 12*2: + inx = 6; + break; + case 9*2: + inx = 5; + break; + case 6*2: + inx = 4; + break; + case 11*2: + inx = 3; + break; + case 11: + inx = 2; + break; + case 2*2: + inx = 1; + break; + case 1*2: + inx = 0; + break; + } + return inx; +} + +unsigned int update_basic_rate(unsigned char *ptn, unsigned int ptn_sz) +{ + unsigned int i, num_of_rate; + unsigned int mask = 0; + + num_of_rate = (ptn_sz > NumRates) ? NumRates : ptn_sz; + + for (i = 0; i < num_of_rate; i++) { + if ((*(ptn + i)) & 0x80) + mask |= 0x1 << wifirate2_ratetbl_inx(*(ptn + i)); + } + return mask; +} + +unsigned int update_supported_rate(unsigned char *ptn, unsigned int ptn_sz) +{ + unsigned int i, num_of_rate; + unsigned int mask = 0; + + num_of_rate = (ptn_sz > NumRates) ? NumRates : ptn_sz; + + for (i = 0; i < num_of_rate; i++) + mask |= 0x1 << wifirate2_ratetbl_inx(*(ptn + i)); + return mask; +} + +unsigned int update_MSC_rate(struct HT_caps_element *pHT_caps) +{ + unsigned int mask = 0; + + mask = ((pHT_caps->u.HT_cap_element.MCS_rate[0] << 12) | (pHT_caps->u.HT_cap_element.MCS_rate[1] << 20)); + + return mask; +} + +int support_short_GI(struct adapter *padapter, struct HT_caps_element *pHT_caps) +{ + unsigned char bit_offset; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + if (!(pmlmeinfo->HT_enable)) + return _FAIL; + + if ((pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_RALINK)) + return _FAIL; + + bit_offset = (pmlmeext->cur_bwmode & HT_CHANNEL_WIDTH_40) ? 6 : 5; + + if (__le16_to_cpu(pHT_caps->u.HT_cap_element.HT_caps_info) & (0x1 << bit_offset)) + return _SUCCESS; + else + return _FAIL; +} + +unsigned char get_highest_rate_idx(u32 mask) +{ + int i; + unsigned char rate_idx = 0; + + for (i = 27; i >= 0; i--) { + if (mask & BIT(i)) { + rate_idx = i; + break; + } + } + return rate_idx; +} + +void Update_RA_Entry(struct adapter *padapter, u32 mac_id) +{ + rtw_hal_update_ra_mask(padapter, mac_id, 0); +} + +static void enable_rate_adaptive(struct adapter *padapter, u32 mac_id) +{ + Update_RA_Entry(padapter, mac_id); +} + +void set_sta_rate(struct adapter *padapter, struct sta_info *psta) +{ + /* rate adaptive */ + enable_rate_adaptive(padapter, psta->mac_id); +} + +/* Update RRSR and Rate for USERATE */ +void update_tx_basic_rate(struct adapter *padapter, u8 wirelessmode) +{ + unsigned char supported_rates[NDIS_802_11_LENGTH_RATES_EX]; +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &padapter->wdinfo; + + /* Added by Albert 2011/03/22 */ + /* In the P2P mode, the driver should not support the b mode. */ + /* So, the Tx packet shouldn't use the CCK rate */ + if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) + return; +#endif /* CONFIG_88EU_P2P */ + _rtw_memset(supported_rates, 0, NDIS_802_11_LENGTH_RATES_EX); + + if ((wirelessmode & WIRELESS_11B) && (wirelessmode == WIRELESS_11B)) { + memcpy(supported_rates, rtw_basic_rate_cck, 4); + } else if (wirelessmode & WIRELESS_11B) { + memcpy(supported_rates, rtw_basic_rate_mix, 7); + } else { + memcpy(supported_rates, rtw_basic_rate_ofdm, 3); + } + + if (wirelessmode & WIRELESS_11B) + update_mgnt_tx_rate(padapter, IEEE80211_CCK_RATE_1MB); + else + update_mgnt_tx_rate(padapter, IEEE80211_OFDM_RATE_6MB); + + rtw_hal_set_hwreg(padapter, HW_VAR_BASIC_RATE, supported_rates); +} + +unsigned char check_assoc_AP(u8 *pframe, uint len) +{ + unsigned int i; + struct ndis_802_11_var_ie *pIE; + u8 epigram_vendor_flag; + u8 ralink_vendor_flag; + epigram_vendor_flag = 0; + ralink_vendor_flag = 0; + + for (i = sizeof(struct ndis_802_11_fixed_ie); i < len;) { + pIE = (struct ndis_802_11_var_ie *)(pframe + i); + + switch (pIE->ElementID) { + case _VENDOR_SPECIFIC_IE_: + if ((_rtw_memcmp(pIE->data, ARTHEROS_OUI1, 3)) || + (_rtw_memcmp(pIE->data, ARTHEROS_OUI2, 3))) { + DBG_88E("link to Artheros AP\n"); + return HT_IOT_PEER_ATHEROS; + } else if ((_rtw_memcmp(pIE->data, BROADCOM_OUI1, 3)) || + (_rtw_memcmp(pIE->data, BROADCOM_OUI2, 3)) || + (_rtw_memcmp(pIE->data, BROADCOM_OUI2, 3))) { + DBG_88E("link to Broadcom AP\n"); + return HT_IOT_PEER_BROADCOM; + } else if (_rtw_memcmp(pIE->data, MARVELL_OUI, 3)) { + DBG_88E("link to Marvell AP\n"); + return HT_IOT_PEER_MARVELL; + } else if (_rtw_memcmp(pIE->data, RALINK_OUI, 3)) { + if (!ralink_vendor_flag) { + ralink_vendor_flag = 1; + } else { + DBG_88E("link to Ralink AP\n"); + return HT_IOT_PEER_RALINK; + } + } else if (_rtw_memcmp(pIE->data, CISCO_OUI, 3)) { + DBG_88E("link to Cisco AP\n"); + return HT_IOT_PEER_CISCO; + } else if (_rtw_memcmp(pIE->data, REALTEK_OUI, 3)) { + DBG_88E("link to Realtek 96B\n"); + return HT_IOT_PEER_REALTEK; + } else if (_rtw_memcmp(pIE->data, AIRGOCAP_OUI, 3)) { + DBG_88E("link to Airgo Cap\n"); + return HT_IOT_PEER_AIRGO; + } else if (_rtw_memcmp(pIE->data, EPIGRAM_OUI, 3)) { + epigram_vendor_flag = 1; + if (ralink_vendor_flag) { + DBG_88E("link to Tenda W311R AP\n"); + return HT_IOT_PEER_TENDA; + } else { + DBG_88E("Capture EPIGRAM_OUI\n"); + } + } else { + break; + } + + default: + break; + } + i += (pIE->Length + 2); + } + + if (ralink_vendor_flag && !epigram_vendor_flag) { + DBG_88E("link to Ralink AP\n"); + return HT_IOT_PEER_RALINK; + } else if (ralink_vendor_flag && epigram_vendor_flag) { + DBG_88E("link to Tenda W311R AP\n"); + return HT_IOT_PEER_TENDA; + } else { + DBG_88E("link to new AP\n"); + return HT_IOT_PEER_UNKNOWN; + } +} + +void update_IOT_info(struct adapter *padapter) +{ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + switch (pmlmeinfo->assoc_AP_vendor) { + case HT_IOT_PEER_MARVELL: + pmlmeinfo->turboMode_cts2self = 1; + pmlmeinfo->turboMode_rtsen = 0; + break; + case HT_IOT_PEER_RALINK: + pmlmeinfo->turboMode_cts2self = 0; + pmlmeinfo->turboMode_rtsen = 1; + /* disable high power */ + Switch_DM_Func(padapter, (~DYNAMIC_BB_DYNAMIC_TXPWR), false); + break; + case HT_IOT_PEER_REALTEK: + /* rtw_write16(padapter, 0x4cc, 0xffff); */ + /* rtw_write16(padapter, 0x546, 0x01c0); */ + /* disable high power */ + Switch_DM_Func(padapter, (~DYNAMIC_BB_DYNAMIC_TXPWR), false); + break; + default: + pmlmeinfo->turboMode_cts2self = 0; + pmlmeinfo->turboMode_rtsen = 1; + break; + } +} + +void update_capinfo(struct adapter *Adapter, u16 updateCap) +{ + struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + bool ShortPreamble; + + /* Check preamble mode, 2005.01.06, by rcnjko. */ + /* Mark to update preamble value forever, 2008.03.18 by lanhsin */ + + if (updateCap & cShortPreamble) { /* Short Preamble */ + if (pmlmeinfo->preamble_mode != PREAMBLE_SHORT) { /* PREAMBLE_LONG or PREAMBLE_AUTO */ + ShortPreamble = true; + pmlmeinfo->preamble_mode = PREAMBLE_SHORT; + rtw_hal_set_hwreg(Adapter, HW_VAR_ACK_PREAMBLE, (u8 *)&ShortPreamble); + } + } else { /* Long Preamble */ + if (pmlmeinfo->preamble_mode != PREAMBLE_LONG) { /* PREAMBLE_SHORT or PREAMBLE_AUTO */ + ShortPreamble = false; + pmlmeinfo->preamble_mode = PREAMBLE_LONG; + rtw_hal_set_hwreg(Adapter, HW_VAR_ACK_PREAMBLE, (u8 *)&ShortPreamble); + } + } + + if (updateCap & cIBSS) { + /* Filen: See 802.11-2007 p.91 */ + pmlmeinfo->slotTime = NON_SHORT_SLOT_TIME; + } else { /* Filen: See 802.11-2007 p.90 */ + if (pmlmeext->cur_wireless_mode & (WIRELESS_11G | WIRELESS_11_24N)) { + if (updateCap & cShortSlotTime) { /* Short Slot Time */ + if (pmlmeinfo->slotTime != SHORT_SLOT_TIME) + pmlmeinfo->slotTime = SHORT_SLOT_TIME; + } else { /* Long Slot Time */ + if (pmlmeinfo->slotTime != NON_SHORT_SLOT_TIME) + pmlmeinfo->slotTime = NON_SHORT_SLOT_TIME; + } + } else if (pmlmeext->cur_wireless_mode & (WIRELESS_11A | WIRELESS_11_5N)) { + pmlmeinfo->slotTime = SHORT_SLOT_TIME; + } else { + /* B Mode */ + pmlmeinfo->slotTime = NON_SHORT_SLOT_TIME; + } + } + + rtw_hal_set_hwreg(Adapter, HW_VAR_SLOT_TIME, &pmlmeinfo->slotTime); +} + +void update_wireless_mode(struct adapter *padapter) +{ + int ratelen, network_type = 0; + u32 SIFS_Timer; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); + unsigned char *rate = cur_network->SupportedRates; + + ratelen = rtw_get_rateset_len(cur_network->SupportedRates); + + if ((pmlmeinfo->HT_info_enable) && (pmlmeinfo->HT_caps_enable)) + pmlmeinfo->HT_enable = 1; + + if (pmlmeext->cur_channel > 14) { + if (pmlmeinfo->HT_enable) + network_type = WIRELESS_11_5N; + + network_type |= WIRELESS_11A; + } else { + if (pmlmeinfo->HT_enable) + network_type = WIRELESS_11_24N; + + if ((cckratesonly_included(rate, ratelen)) == true) + network_type |= WIRELESS_11B; + else if ((cckrates_included(rate, ratelen)) == true) + network_type |= WIRELESS_11BG; + else + network_type |= WIRELESS_11G; + } + + pmlmeext->cur_wireless_mode = network_type & padapter->registrypriv.wireless_mode; + + SIFS_Timer = 0x0a0a0808;/* 0x0808 -> for CCK, 0x0a0a -> for OFDM */ + /* change this value if having IOT issues. */ + + padapter->HalFunc.SetHwRegHandler(padapter, HW_VAR_RESP_SIFS, (u8 *)&SIFS_Timer); + + if (pmlmeext->cur_wireless_mode & WIRELESS_11B) + update_mgnt_tx_rate(padapter, IEEE80211_CCK_RATE_1MB); + else + update_mgnt_tx_rate(padapter, IEEE80211_OFDM_RATE_6MB); +} + +void update_bmc_sta_support_rate(struct adapter *padapter, u32 mac_id) +{ + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + if (pmlmeext->cur_wireless_mode & WIRELESS_11B) { + /* Only B, B/G, and B/G/N AP could use CCK rate */ + memcpy((pmlmeinfo->FW_sta_info[mac_id].SupportedRates), rtw_basic_rate_cck, 4); + } else { + memcpy((pmlmeinfo->FW_sta_info[mac_id].SupportedRates), rtw_basic_rate_ofdm, 4); + } +} + +int update_sta_support_rate(struct adapter *padapter, u8 *pvar_ie, uint var_ie_len, int cam_idx) +{ + unsigned int ie_len; + struct ndis_802_11_var_ie *pIE; + int supportRateNum = 0; + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + pIE = (struct ndis_802_11_var_ie *)rtw_get_ie(pvar_ie, _SUPPORTEDRATES_IE_, &ie_len, var_ie_len); + if (pIE == NULL) + return _FAIL; + + memcpy(pmlmeinfo->FW_sta_info[cam_idx].SupportedRates, pIE->data, ie_len); + supportRateNum = ie_len; + + pIE = (struct ndis_802_11_var_ie *)rtw_get_ie(pvar_ie, _EXT_SUPPORTEDRATES_IE_, &ie_len, var_ie_len); + if (pIE) + memcpy((pmlmeinfo->FW_sta_info[cam_idx].SupportedRates + supportRateNum), pIE->data, ie_len); + + return _SUCCESS; +} + +void process_addba_req(struct adapter *padapter, u8 *paddba_req, u8 *addr) +{ + struct sta_info *psta; + u16 tid; + u16 param; + struct recv_reorder_ctrl *preorder_ctrl; + struct sta_priv *pstapriv = &padapter->stapriv; + struct ADDBA_request *preq = (struct ADDBA_request *)paddba_req; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + psta = rtw_get_stainfo(pstapriv, addr); + + if (psta) { + param = le16_to_cpu(preq->BA_para_set); + tid = (param>>2)&0x0f; + preorder_ctrl = &psta->recvreorder_ctrl[tid]; + preorder_ctrl->indicate_seq = 0xffff; + preorder_ctrl->enable = (pmlmeinfo->bAcceptAddbaReq) ? true : false; + } +} + +void update_TSF(struct mlme_ext_priv *pmlmeext, u8 *pframe, uint len) +{ + u8 *pIE; + __le32 *pbuf; + + pIE = pframe + sizeof(struct rtw_ieee80211_hdr_3addr); + pbuf = (__le32 *)pIE; + + pmlmeext->TSFValue = le32_to_cpu(*(pbuf+1)); + + pmlmeext->TSFValue = pmlmeext->TSFValue << 32; + + pmlmeext->TSFValue |= le32_to_cpu(*pbuf); +} + +void correct_TSF(struct adapter *padapter, struct mlme_ext_priv *pmlmeext) +{ + rtw_hal_set_hwreg(padapter, HW_VAR_CORRECT_TSF, NULL); +} + +void beacon_timing_control(struct adapter *padapter) +{ + rtw_hal_bcn_related_reg_setting(padapter); +} + +static struct adapter *pbuddy_padapter; + +int rtw_handle_dualmac(struct adapter *adapter, bool init) +{ + int status = _SUCCESS; + + if (init) { + if (pbuddy_padapter == NULL) { + pbuddy_padapter = adapter; + DBG_88E("%s(): pbuddy_padapter == NULL, Set pbuddy_padapter\n", __func__); + } else { + adapter->pbuddy_adapter = pbuddy_padapter; + pbuddy_padapter->pbuddy_adapter = adapter; + /* clear global value */ + pbuddy_padapter = NULL; + DBG_88E("%s(): pbuddy_padapter exist, Exchange Information\n", __func__); + } + } else { + pbuddy_padapter = NULL; + } + return status; +} diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c new file mode 100644 index 0000000000000..bb5cd95c564e2 --- /dev/null +++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c @@ -0,0 +1,2447 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTW_XMIT_C_ + +#include +#include +#include +#include +#include +#include +#include + +static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 }; +static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 }; + +static void _init_txservq(struct tx_servq *ptxservq) +{ +_func_enter_; + _rtw_init_listhead(&ptxservq->tx_pending); + _rtw_init_queue(&ptxservq->sta_pending); + ptxservq->qcnt = 0; +_func_exit_; +} + +void _rtw_init_sta_xmit_priv(struct sta_xmit_priv *psta_xmitpriv) +{ +_func_enter_; + _rtw_memset((unsigned char *)psta_xmitpriv, 0, sizeof (struct sta_xmit_priv)); + _rtw_spinlock_init(&psta_xmitpriv->lock); + _init_txservq(&psta_xmitpriv->be_q); + _init_txservq(&psta_xmitpriv->bk_q); + _init_txservq(&psta_xmitpriv->vi_q); + _init_txservq(&psta_xmitpriv->vo_q); + _rtw_init_listhead(&psta_xmitpriv->legacy_dz); + _rtw_init_listhead(&psta_xmitpriv->apsd); + +_func_exit_; +} + +s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) +{ + int i; + struct xmit_buf *pxmitbuf; + struct xmit_frame *pxframe; + int res = _SUCCESS; + u32 max_xmit_extbuf_size = MAX_XMIT_EXTBUF_SZ; + u32 num_xmit_extbuf = NR_XMIT_EXTBUFF; + +_func_enter_; + + /* We don't need to memset padapter->XXX to zero, because adapter is allocated by rtw_zvmalloc(). */ + + _rtw_spinlock_init(&pxmitpriv->lock); + _rtw_init_sema(&pxmitpriv->xmit_sema, 0); + _rtw_init_sema(&pxmitpriv->terminate_xmitthread_sema, 0); + + /* + Please insert all the queue initializaiton using _rtw_init_queue below + */ + + pxmitpriv->adapter = padapter; + + _rtw_init_queue(&pxmitpriv->be_pending); + _rtw_init_queue(&pxmitpriv->bk_pending); + _rtw_init_queue(&pxmitpriv->vi_pending); + _rtw_init_queue(&pxmitpriv->vo_pending); + _rtw_init_queue(&pxmitpriv->bm_pending); + + _rtw_init_queue(&pxmitpriv->free_xmit_queue); + + /* + Please allocate memory with the sz = (struct xmit_frame) * NR_XMITFRAME, + and initialize free_xmit_frame below. + Please also apply free_txobj to link_up all the xmit_frames... + */ + + pxmitpriv->pallocated_frame_buf = rtw_zvmalloc(NR_XMITFRAME * sizeof(struct xmit_frame) + 4); + + if (pxmitpriv->pallocated_frame_buf == NULL) { + pxmitpriv->pxmit_frame_buf = NULL; + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("alloc xmit_frame fail!\n")); + res = _FAIL; + goto exit; + } + pxmitpriv->pxmit_frame_buf = (u8 *)N_BYTE_ALIGMENT((size_t)(pxmitpriv->pallocated_frame_buf), 4); + /* pxmitpriv->pxmit_frame_buf = pxmitpriv->pallocated_frame_buf + 4 - */ + /* ((size_t) (pxmitpriv->pallocated_frame_buf) &3); */ + + pxframe = (struct xmit_frame *)pxmitpriv->pxmit_frame_buf; + + for (i = 0; i < NR_XMITFRAME; i++) { + _rtw_init_listhead(&(pxframe->list)); + + pxframe->padapter = padapter; + pxframe->frame_tag = NULL_FRAMETAG; + + pxframe->pkt = NULL; + + pxframe->buf_addr = NULL; + pxframe->pxmitbuf = NULL; + + rtw_list_insert_tail(&(pxframe->list), &(pxmitpriv->free_xmit_queue.queue)); + + pxframe++; + } + + pxmitpriv->free_xmitframe_cnt = NR_XMITFRAME; + + pxmitpriv->frag_len = MAX_FRAG_THRESHOLD; + + /* init xmit_buf */ + _rtw_init_queue(&pxmitpriv->free_xmitbuf_queue); + _rtw_init_queue(&pxmitpriv->pending_xmitbuf_queue); + + pxmitpriv->pallocated_xmitbuf = rtw_zvmalloc(NR_XMITBUFF * sizeof(struct xmit_buf) + 4); + + if (pxmitpriv->pallocated_xmitbuf == NULL) { + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("alloc xmit_buf fail!\n")); + res = _FAIL; + goto exit; + } + + pxmitpriv->pxmitbuf = (u8 *)N_BYTE_ALIGMENT((size_t)(pxmitpriv->pallocated_xmitbuf), 4); + /* pxmitpriv->pxmitbuf = pxmitpriv->pallocated_xmitbuf + 4 - */ + /* ((size_t) (pxmitpriv->pallocated_xmitbuf) &3); */ + + pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmitbuf; + + for (i = 0; i < NR_XMITBUFF; i++) { + _rtw_init_listhead(&pxmitbuf->list); + + pxmitbuf->priv_data = NULL; + pxmitbuf->padapter = padapter; + pxmitbuf->ext_tag = false; + + /* Tx buf allocation may fail sometimes, so sleep and retry. */ + res = rtw_os_xmit_resource_alloc(padapter, pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ)); + if (res == _FAIL) { + rtw_msleep_os(10); + res = rtw_os_xmit_resource_alloc(padapter, pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ)); + if (res == _FAIL) { + goto exit; + } + } + + pxmitbuf->flags = XMIT_VO_QUEUE; + + rtw_list_insert_tail(&pxmitbuf->list, &(pxmitpriv->free_xmitbuf_queue.queue)); + pxmitbuf++; + } + + pxmitpriv->free_xmitbuf_cnt = NR_XMITBUFF; + + /* Init xmit extension buff */ + _rtw_init_queue(&pxmitpriv->free_xmit_extbuf_queue); + + pxmitpriv->pallocated_xmit_extbuf = rtw_zvmalloc(num_xmit_extbuf * sizeof(struct xmit_buf) + 4); + + if (pxmitpriv->pallocated_xmit_extbuf == NULL) { + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("alloc xmit_extbuf fail!\n")); + res = _FAIL; + goto exit; + } + + pxmitpriv->pxmit_extbuf = (u8 *)N_BYTE_ALIGMENT((size_t)(pxmitpriv->pallocated_xmit_extbuf), 4); + + pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmit_extbuf; + + for (i = 0; i < num_xmit_extbuf; i++) { + _rtw_init_listhead(&pxmitbuf->list); + + pxmitbuf->priv_data = NULL; + pxmitbuf->padapter = padapter; + pxmitbuf->ext_tag = true; + + res = rtw_os_xmit_resource_alloc(padapter, pxmitbuf, max_xmit_extbuf_size + XMITBUF_ALIGN_SZ); + if (res == _FAIL) { + res = _FAIL; + goto exit; + } + + rtw_list_insert_tail(&pxmitbuf->list, &(pxmitpriv->free_xmit_extbuf_queue.queue)); + pxmitbuf++; + } + + pxmitpriv->free_xmit_extbuf_cnt = num_xmit_extbuf; + + rtw_alloc_hwxmits(padapter); + rtw_init_hwxmits(pxmitpriv->hwxmits, pxmitpriv->hwxmit_entry); + + for (i = 0; i < 4; i++) + pxmitpriv->wmm_para_seq[i] = i; + + pxmitpriv->txirp_cnt = 1; + + _rtw_init_sema(&(pxmitpriv->tx_retevt), 0); + + /* per AC pending irp */ + pxmitpriv->beq_cnt = 0; + pxmitpriv->bkq_cnt = 0; + pxmitpriv->viq_cnt = 0; + pxmitpriv->voq_cnt = 0; + + pxmitpriv->ack_tx = false; + _rtw_mutex_init(&pxmitpriv->ack_tx_mutex); + rtw_sctx_init(&pxmitpriv->ack_tx_ops, 0); + + rtw_hal_init_xmit_priv(padapter); + +exit: + +_func_exit_; + + return res; +} + +static void rtw_mfree_xmit_priv_lock (struct xmit_priv *pxmitpriv) +{ + _rtw_spinlock_free(&pxmitpriv->lock); + _rtw_free_sema(&pxmitpriv->xmit_sema); + _rtw_free_sema(&pxmitpriv->terminate_xmitthread_sema); + + _rtw_spinlock_free(&pxmitpriv->be_pending.lock); + _rtw_spinlock_free(&pxmitpriv->bk_pending.lock); + _rtw_spinlock_free(&pxmitpriv->vi_pending.lock); + _rtw_spinlock_free(&pxmitpriv->vo_pending.lock); + _rtw_spinlock_free(&pxmitpriv->bm_pending.lock); + + _rtw_spinlock_free(&pxmitpriv->free_xmit_queue.lock); + _rtw_spinlock_free(&pxmitpriv->free_xmitbuf_queue.lock); + _rtw_spinlock_free(&pxmitpriv->pending_xmitbuf_queue.lock); +} + +void _rtw_free_xmit_priv (struct xmit_priv *pxmitpriv) +{ + int i; + struct adapter *padapter = pxmitpriv->adapter; + struct xmit_frame *pxmitframe = (struct xmit_frame *)pxmitpriv->pxmit_frame_buf; + struct xmit_buf *pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmitbuf; + u32 max_xmit_extbuf_size = MAX_XMIT_EXTBUF_SZ; + u32 num_xmit_extbuf = NR_XMIT_EXTBUFF; + + _func_enter_; + + rtw_hal_free_xmit_priv(padapter); + + rtw_mfree_xmit_priv_lock(pxmitpriv); + + if (pxmitpriv->pxmit_frame_buf == NULL) + goto out; + + for (i = 0; i < NR_XMITFRAME; i++) { + rtw_os_xmit_complete(padapter, pxmitframe); + + pxmitframe++; + } + + for (i = 0; i < NR_XMITBUFF; i++) { + rtw_os_xmit_resource_free(padapter, pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ)); + pxmitbuf++; + } + + if (pxmitpriv->pallocated_frame_buf) + rtw_vmfree(pxmitpriv->pallocated_frame_buf, NR_XMITFRAME * sizeof(struct xmit_frame) + 4); + + if (pxmitpriv->pallocated_xmitbuf) + rtw_vmfree(pxmitpriv->pallocated_xmitbuf, NR_XMITBUFF * sizeof(struct xmit_buf) + 4); + + /* free xmit extension buff */ + _rtw_spinlock_free(&pxmitpriv->free_xmit_extbuf_queue.lock); + + pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmit_extbuf; + for (i = 0; i < num_xmit_extbuf; i++) { + rtw_os_xmit_resource_free(padapter, pxmitbuf, (max_xmit_extbuf_size + XMITBUF_ALIGN_SZ)); + pxmitbuf++; + } + + if (pxmitpriv->pallocated_xmit_extbuf) { + rtw_vmfree(pxmitpriv->pallocated_xmit_extbuf, num_xmit_extbuf * sizeof(struct xmit_buf) + 4); + } + + rtw_free_hwxmits(padapter); + + _rtw_mutex_free(&pxmitpriv->ack_tx_mutex); + +out: + +_func_exit_; +} + +static void update_attrib_vcs_info(struct adapter *padapter, struct xmit_frame *pxmitframe) +{ + u32 sz; + struct pkt_attrib *pattrib = &pxmitframe->attrib; + struct sta_info *psta = pattrib->psta; + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + if (pattrib->nr_frags != 1) + sz = padapter->xmitpriv.frag_len; + else /* no frag */ + sz = pattrib->last_txcmdsz; + + /* (1) RTS_Threshold is compared to the MPDU, not MSDU. */ + /* (2) If there are more than one frag in this MSDU, only the first frag uses protection frame. */ + /* Other fragments are protected by previous fragment. */ + /* So we only need to check the length of first fragment. */ + if (pmlmeext->cur_wireless_mode < WIRELESS_11_24N || padapter->registrypriv.wifi_spec) { + if (sz > padapter->registrypriv.rts_thresh) { + pattrib->vcs_mode = RTS_CTS; + } else { + if (psta->rtsen) + pattrib->vcs_mode = RTS_CTS; + else if (psta->cts2self) + pattrib->vcs_mode = CTS_TO_SELF; + else + pattrib->vcs_mode = NONE_VCS; + } + } else { + while (true) { + /* IOT action */ + if ((pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_ATHEROS) && pattrib->ampdu_en && + (padapter->securitypriv.dot11PrivacyAlgrthm == _AES_)) { + pattrib->vcs_mode = CTS_TO_SELF; + break; + } + + /* check ERP protection */ + if (psta->rtsen || psta->cts2self) { + if (psta->rtsen) + pattrib->vcs_mode = RTS_CTS; + else if (psta->cts2self) + pattrib->vcs_mode = CTS_TO_SELF; + + break; + } + + /* check HT op mode */ + if (pattrib->ht_en) { + u8 htopmode = pmlmeinfo->HT_protection; + if ((pmlmeext->cur_bwmode && (htopmode == 2 || htopmode == 3)) || + (!pmlmeext->cur_bwmode && htopmode == 3)) { + pattrib->vcs_mode = RTS_CTS; + break; + } + } + + /* check rts */ + if (sz > padapter->registrypriv.rts_thresh) { + pattrib->vcs_mode = RTS_CTS; + break; + } + + /* to do list: check MIMO power save condition. */ + + /* check AMPDU aggregation for TXOP */ + if (pattrib->ampdu_en) { + pattrib->vcs_mode = RTS_CTS; + break; + } + + pattrib->vcs_mode = NONE_VCS; + break; + } + } +} + +static void update_attrib_phy_info(struct pkt_attrib *pattrib, struct sta_info *psta) +{ + /*if (psta->rtsen) + pattrib->vcs_mode = RTS_CTS; + else if (psta->cts2self) + pattrib->vcs_mode = CTS_TO_SELF; + else + pattrib->vcs_mode = NONE_VCS;*/ + + pattrib->mdata = 0; + pattrib->eosp = 0; + pattrib->triggered = 0; + + /* qos_en, ht_en, init rate, , bw, ch_offset, sgi */ + pattrib->qos_en = psta->qos_option; + + pattrib->raid = psta->raid; + pattrib->ht_en = psta->htpriv.ht_option; + pattrib->bwmode = psta->htpriv.bwmode; + pattrib->ch_offset = psta->htpriv.ch_offset; + pattrib->sgi = psta->htpriv.sgi; + pattrib->ampdu_en = false; + pattrib->retry_ctrl = false; +} + +u8 qos_acm(u8 acm_mask, u8 priority) +{ + u8 change_priority = priority; + + switch (priority) { + case 0: + case 3: + if (acm_mask & BIT(1)) + change_priority = 1; + break; + case 1: + case 2: + break; + case 4: + case 5: + if (acm_mask & BIT(2)) + change_priority = 0; + break; + case 6: + case 7: + if (acm_mask & BIT(3)) + change_priority = 5; + break; + default: + DBG_88E("qos_acm(): invalid pattrib->priority: %d!!!\n", priority); + break; + } + + return change_priority; +} + +static void set_qos(struct pkt_file *ppktfile, struct pkt_attrib *pattrib) +{ + struct ethhdr etherhdr; + struct iphdr ip_hdr; + s32 user_prio = 0; + + _rtw_open_pktfile(ppktfile->pkt, ppktfile); + _rtw_pktfile_read(ppktfile, (unsigned char *)ðerhdr, ETH_HLEN); + + /* get user_prio from IP hdr */ + if (pattrib->ether_type == 0x0800) { + _rtw_pktfile_read(ppktfile, (u8 *)&ip_hdr, sizeof(ip_hdr)); +/* user_prio = (ntohs(ip_hdr.tos) >> 5) & 0x3; */ + user_prio = ip_hdr.tos >> 5; + } else if (pattrib->ether_type == 0x888e) { + /* "When priority processing of data frames is supported, */ + /* a STA's SME should send EAPOL-Key frames at the highest priority." */ + user_prio = 7; + } + + pattrib->priority = user_prio; + pattrib->hdrlen = WLAN_HDR_A3_QOS_LEN; + pattrib->subtype = WIFI_QOS_DATA_TYPE; +} + +static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct pkt_attrib *pattrib) +{ + struct pkt_file pktfile; + struct sta_info *psta = NULL; + struct ethhdr etherhdr; + + int bmcast; + struct sta_priv *pstapriv = &padapter->stapriv; + struct security_priv *psecuritypriv = &padapter->securitypriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct qos_priv *pqospriv = &pmlmepriv->qospriv; + int res = _SUCCESS; + + _func_enter_; + + _rtw_open_pktfile(pkt, &pktfile); + _rtw_pktfile_read(&pktfile, (u8 *)ðerhdr, ETH_HLEN); + + pattrib->ether_type = ntohs(etherhdr.h_proto); + + memcpy(pattrib->dst, ðerhdr.h_dest, ETH_ALEN); + memcpy(pattrib->src, ðerhdr.h_source, ETH_ALEN); + + pattrib->pctrl = 0; + + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) || + check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { + memcpy(pattrib->ra, pattrib->dst, ETH_ALEN); + memcpy(pattrib->ta, pattrib->src, ETH_ALEN); + } else if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { + memcpy(pattrib->ra, get_bssid(pmlmepriv), ETH_ALEN); + memcpy(pattrib->ta, pattrib->src, ETH_ALEN); + } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { + memcpy(pattrib->ra, pattrib->dst, ETH_ALEN); + memcpy(pattrib->ta, get_bssid(pmlmepriv), ETH_ALEN); + } + + pattrib->pktlen = pktfile.pkt_len; + + if (ETH_P_IP == pattrib->ether_type) { + /* The following is for DHCP and ARP packet, we use cck1M to tx these packets and let LPS awake some time */ + /* to prevent DHCP protocol fail */ + u8 tmp[24]; + _rtw_pktfile_read(&pktfile, &tmp[0], 24); + pattrib->dhcp_pkt = 0; + if (pktfile.pkt_len > 282) {/* MINIMUM_DHCP_PACKET_SIZE) { */ + if (ETH_P_IP == pattrib->ether_type) {/* IP header */ + if (((tmp[21] == 68) && (tmp[23] == 67)) || + ((tmp[21] == 67) && (tmp[23] == 68))) { + /* 68 : UDP BOOTP client */ + /* 67 : UDP BOOTP server */ + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("====================== update_attrib: get DHCP Packet\n")); + /* Use low rate to send DHCP packet. */ + pattrib->dhcp_pkt = 1; + } + } + } + } else if (0x888e == pattrib->ether_type) { + DBG_88E_LEVEL(_drv_info_, "send eapol packet\n"); + } + + if ((pattrib->ether_type == 0x888e) || (pattrib->dhcp_pkt == 1)) + rtw_set_scan_deny(padapter, 3000); + + /* If EAPOL , ARP , OR DHCP packet, driver must be in active mode. */ + if ((pattrib->ether_type == 0x0806) || (pattrib->ether_type == 0x888e) || (pattrib->dhcp_pkt == 1)) + rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_SPECIAL_PACKET, 1); + + bmcast = IS_MCAST(pattrib->ra); + + /* get sta_info */ + if (bmcast) { + psta = rtw_get_bcmc_stainfo(padapter); + } else { + psta = rtw_get_stainfo(pstapriv, pattrib->ra); + if (psta == NULL) { /* if we cannot get psta => drrp the pkt */ + RT_TRACE(_module_rtl871x_xmit_c_, _drv_alert_, ("\nupdate_attrib => get sta_info fail, ra: %pM\n", (pattrib->ra))); + res = _FAIL; + goto exit; + } else if ((check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) && (!(psta->state & _FW_LINKED))) { + res = _FAIL; + goto exit; + } + } + + if (psta) { + pattrib->mac_id = psta->mac_id; + /* DBG_88E("%s ==> mac_id(%d)\n", __func__, pattrib->mac_id); */ + pattrib->psta = psta; + } else { + /* if we cannot get psta => drop the pkt */ + RT_TRACE(_module_rtl871x_xmit_c_, _drv_alert_, ("\nupdate_attrib => get sta_info fail, ra:%pM\n", (pattrib->ra))); + res = _FAIL; + goto exit; + } + + pattrib->ack_policy = 0; + /* get ether_hdr_len */ + pattrib->pkt_hdrlen = ETH_HLEN;/* pattrib->ether_type == 0x8100) ? (14 + 4): 14; vlan tag */ + + pattrib->hdrlen = WLAN_HDR_A3_LEN; + pattrib->subtype = WIFI_DATA_TYPE; + pattrib->priority = 0; + + if (check_fwstate(pmlmepriv, WIFI_AP_STATE|WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE)) { + if (psta->qos_option) + set_qos(&pktfile, pattrib); + } else { + if (pqospriv->qos_option) { + set_qos(&pktfile, pattrib); + + if (pmlmepriv->acm_mask != 0) + pattrib->priority = qos_acm(pmlmepriv->acm_mask, pattrib->priority); + } + } + + if (psta->ieee8021x_blocked) { + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("\n psta->ieee8021x_blocked == true\n")); + + pattrib->encrypt = 0; + + if ((pattrib->ether_type != 0x888e) && !check_fwstate(pmlmepriv, WIFI_MP_STATE)) { + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("\npsta->ieee8021x_blocked == true, pattrib->ether_type(%.4x) != 0x888e\n", pattrib->ether_type)); + res = _FAIL; + goto exit; + } + } else { + GET_ENCRY_ALGO(psecuritypriv, psta, pattrib->encrypt, bmcast); + + switch (psecuritypriv->dot11AuthAlgrthm) { + case dot11AuthAlgrthm_Open: + case dot11AuthAlgrthm_Shared: + case dot11AuthAlgrthm_Auto: + pattrib->key_idx = (u8)psecuritypriv->dot11PrivacyKeyIndex; + break; + case dot11AuthAlgrthm_8021X: + if (bmcast) + pattrib->key_idx = (u8)psecuritypriv->dot118021XGrpKeyid; + else + pattrib->key_idx = 0; + break; + default: + pattrib->key_idx = 0; + break; + } + } + + switch (pattrib->encrypt) { + case _WEP40_: + case _WEP104_: + pattrib->iv_len = 4; + pattrib->icv_len = 4; + break; + case _TKIP_: + pattrib->iv_len = 8; + pattrib->icv_len = 4; + + if (padapter->securitypriv.busetkipkey == _FAIL) { + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, + ("\npadapter->securitypriv.busetkipkey(%d) == _FAIL drop packet\n", + padapter->securitypriv.busetkipkey)); + res = _FAIL; + goto exit; + } + break; + case _AES_: + RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("pattrib->encrypt=%d (_AES_)\n", pattrib->encrypt)); + pattrib->iv_len = 8; + pattrib->icv_len = 8; + break; + default: + pattrib->iv_len = 0; + pattrib->icv_len = 0; + break; + } + + RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, + ("update_attrib: encrypt=%d securitypriv.sw_encrypt=%d\n", + pattrib->encrypt, padapter->securitypriv.sw_encrypt)); + + if (pattrib->encrypt && + (padapter->securitypriv.sw_encrypt || !psecuritypriv->hw_decrypted)) { + pattrib->bswenc = true; + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, + ("update_attrib: encrypt=%d securitypriv.hw_decrypted=%d bswenc = true\n", + pattrib->encrypt, padapter->securitypriv.sw_encrypt)); + } else { + pattrib->bswenc = false; + RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("update_attrib: bswenc = false\n")); + } + + rtw_set_tx_chksum_offload(pkt, pattrib); + + update_attrib_phy_info(pattrib, psta); + +exit: + +_func_exit_; + + return res; +} + +static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitframe) +{ + int curfragnum, length; + u8 *pframe, *payload, mic[8]; + struct mic_data micdata; + struct sta_info *stainfo; + struct pkt_attrib *pattrib = &pxmitframe->attrib; + struct security_priv *psecuritypriv = &padapter->securitypriv; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + u8 priority[4] = {0x0, 0x0, 0x0, 0x0}; + u8 hw_hdr_offset = 0; + int bmcst = IS_MCAST(pattrib->ra); + + if (pattrib->psta) + stainfo = pattrib->psta; + else + stainfo = rtw_get_stainfo(&padapter->stapriv , &pattrib->ra[0]); + +_func_enter_; + + hw_hdr_offset = TXDESC_SIZE + (pxmitframe->pkt_offset * PACKET_OFFSET_SZ);; + + if (pattrib->encrypt == _TKIP_) {/* if (psecuritypriv->dot11PrivacyAlgrthm == _TKIP_PRIVACY_) */ + /* encode mic code */ + if (stainfo != NULL) { + u8 null_key[16] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0}; + + pframe = pxmitframe->buf_addr + hw_hdr_offset; + + if (bmcst) { + if (_rtw_memcmp(psecuritypriv->dot118021XGrptxmickey[psecuritypriv->dot118021XGrpKeyid].skey, null_key, 16)) + return _FAIL; + /* start to calculate the mic code */ + rtw_secmicsetkey(&micdata, psecuritypriv->dot118021XGrptxmickey[psecuritypriv->dot118021XGrpKeyid].skey); + } else { + if (_rtw_memcmp(&stainfo->dot11tkiptxmickey.skey[0], null_key, 16) == true) { + /* DbgPrint("\nxmitframe_addmic:stainfo->dot11tkiptxmickey == 0\n"); */ + /* rtw_msleep_os(10); */ + return _FAIL; + } + /* start to calculate the mic code */ + rtw_secmicsetkey(&micdata, &stainfo->dot11tkiptxmickey.skey[0]); + } + + if (pframe[1]&1) { /* ToDS == 1 */ + rtw_secmicappend(&micdata, &pframe[16], 6); /* DA */ + if (pframe[1]&2) /* From Ds == 1 */ + rtw_secmicappend(&micdata, &pframe[24], 6); + else + rtw_secmicappend(&micdata, &pframe[10], 6); + } else { /* ToDS == 0 */ + rtw_secmicappend(&micdata, &pframe[4], 6); /* DA */ + if (pframe[1]&2) /* From Ds == 1 */ + rtw_secmicappend(&micdata, &pframe[16], 6); + else + rtw_secmicappend(&micdata, &pframe[10], 6); + } + + if (pattrib->qos_en) + priority[0] = (u8)pxmitframe->attrib.priority; + + rtw_secmicappend(&micdata, &priority[0], 4); + + payload = pframe; + + for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { + payload = (u8 *)RND4((size_t)(payload)); + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, + ("=== curfragnum=%d, pframe = 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x,!!!\n", + curfragnum, *payload, *(payload+1), + *(payload+2), *(payload+3), + *(payload+4), *(payload+5), + *(payload+6), *(payload+7))); + + payload = payload+pattrib->hdrlen+pattrib->iv_len; + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, + ("curfragnum=%d pattrib->hdrlen=%d pattrib->iv_len=%d", + curfragnum, pattrib->hdrlen, pattrib->iv_len)); + if ((curfragnum+1) == pattrib->nr_frags) { + length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-((pattrib->bswenc) ? pattrib->icv_len : 0); + rtw_secmicappend(&micdata, payload, length); + payload = payload+length; + } else { + length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-((pattrib->bswenc) ? pattrib->icv_len : 0); + rtw_secmicappend(&micdata, payload, length); + payload = payload+length+pattrib->icv_len; + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("curfragnum=%d length=%d pattrib->icv_len=%d", curfragnum, length, pattrib->icv_len)); + } + } + rtw_secgetmic(&micdata, &(mic[0])); + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("xmitframe_addmic: before add mic code!!!\n")); + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("xmitframe_addmic: pattrib->last_txcmdsz=%d!!!\n", pattrib->last_txcmdsz)); + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("xmitframe_addmic: mic[0]=0x%.2x , mic[1]=0x%.2x , mic[2]= 0x%.2x, mic[3]=0x%.2x\n\ + mic[4]= 0x%.2x , mic[5]= 0x%.2x , mic[6]= 0x%.2x , mic[7]= 0x%.2x !!!!\n", + mic[0], mic[1], mic[2], mic[3], mic[4], mic[5], mic[6], mic[7])); + /* add mic code and add the mic code length in last_txcmdsz */ + + memcpy(payload, &(mic[0]), 8); + pattrib->last_txcmdsz += 8; + + RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("\n ======== last pkt ========\n")); + payload = payload-pattrib->last_txcmdsz+8; + for (curfragnum = 0; curfragnum < pattrib->last_txcmdsz; curfragnum = curfragnum+8) + RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, + (" %.2x, %.2x, %.2x, %.2x, %.2x, %.2x, %.2x, %.2x ", + *(payload+curfragnum), *(payload+curfragnum+1), + *(payload+curfragnum+2), *(payload+curfragnum+3), + *(payload+curfragnum+4), *(payload+curfragnum+5), + *(payload+curfragnum+6), *(payload+curfragnum+7))); + } else { + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("xmitframe_addmic: rtw_get_stainfo==NULL!!!\n")); + } + } + +_func_exit_; + + return _SUCCESS; +} + +static s32 xmitframe_swencrypt(struct adapter *padapter, struct xmit_frame *pxmitframe) +{ + struct pkt_attrib *pattrib = &pxmitframe->attrib; + +_func_enter_; + + if (pattrib->bswenc) { + RT_TRACE(_module_rtl871x_xmit_c_, _drv_alert_, ("### xmitframe_swencrypt\n")); + switch (pattrib->encrypt) { + case _WEP40_: + case _WEP104_: + rtw_wep_encrypt(padapter, (u8 *)pxmitframe); + break; + case _TKIP_: + rtw_tkip_encrypt(padapter, (u8 *)pxmitframe); + break; + case _AES_: + rtw_aes_encrypt(padapter, (u8 *)pxmitframe); + break; + default: + break; + } + } else { + RT_TRACE(_module_rtl871x_xmit_c_, _drv_notice_, ("### xmitframe_hwencrypt\n")); + } + +_func_exit_; + + return _SUCCESS; +} + +s32 rtw_make_wlanhdr (struct adapter *padapter , u8 *hdr, struct pkt_attrib *pattrib) +{ + u16 *qc; + + struct rtw_ieee80211_hdr *pwlanhdr = (struct rtw_ieee80211_hdr *)hdr; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct qos_priv *pqospriv = &pmlmepriv->qospriv; + u8 qos_option = false; + + int res = _SUCCESS; + u16 *fctrl = &pwlanhdr->frame_ctl; + + struct sta_info *psta; + + int bmcst = IS_MCAST(pattrib->ra); + +_func_enter_; + + if (pattrib->psta) { + psta = pattrib->psta; + } else { + if (bmcst) { + psta = rtw_get_bcmc_stainfo(padapter); + } else { + psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra); + } + } + + _rtw_memset(hdr, 0, WLANHDR_OFFSET); + + SetFrameSubType(fctrl, pattrib->subtype); + + if (pattrib->subtype & WIFI_DATA_TYPE) { + if ((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true)) { + /* to_ds = 1, fr_ds = 0; */ + /* Data transfer to AP */ + SetToDs(fctrl); + memcpy(pwlanhdr->addr1, get_bssid(pmlmepriv), ETH_ALEN); + memcpy(pwlanhdr->addr2, pattrib->src, ETH_ALEN); + memcpy(pwlanhdr->addr3, pattrib->dst, ETH_ALEN); + + if (pqospriv->qos_option) + qos_option = true; + } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { + /* to_ds = 0, fr_ds = 1; */ + SetFrDs(fctrl); + memcpy(pwlanhdr->addr1, pattrib->dst, ETH_ALEN); + memcpy(pwlanhdr->addr2, get_bssid(pmlmepriv), ETH_ALEN); + memcpy(pwlanhdr->addr3, pattrib->src, ETH_ALEN); + + if (psta->qos_option) + qos_option = true; + } else if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) || + check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { + memcpy(pwlanhdr->addr1, pattrib->dst, ETH_ALEN); + memcpy(pwlanhdr->addr2, pattrib->src, ETH_ALEN); + memcpy(pwlanhdr->addr3, get_bssid(pmlmepriv), ETH_ALEN); + + if (psta->qos_option) + qos_option = true; + } else { + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("fw_state:%x is not allowed to xmit frame\n", get_fwstate(pmlmepriv))); + res = _FAIL; + goto exit; + } + + if (pattrib->mdata) + SetMData(fctrl); + + if (pattrib->encrypt) + SetPrivacy(fctrl); + + if (qos_option) { + qc = (unsigned short *)(hdr + pattrib->hdrlen - 2); + + if (pattrib->priority) + SetPriority(qc, pattrib->priority); + + SetEOSP(qc, pattrib->eosp); + + SetAckpolicy(qc, pattrib->ack_policy); + } + + /* TODO: fill HT Control Field */ + + /* Update Seq Num will be handled by f/w */ + if (psta) { + psta->sta_xmitpriv.txseq_tid[pattrib->priority]++; + psta->sta_xmitpriv.txseq_tid[pattrib->priority] &= 0xFFF; + + pattrib->seqnum = psta->sta_xmitpriv.txseq_tid[pattrib->priority]; + + SetSeqNum(hdr, pattrib->seqnum); + + /* check if enable ampdu */ + if (pattrib->ht_en && psta->htpriv.ampdu_enable) { + if (psta->htpriv.agg_enable_bitmap & BIT(pattrib->priority)) + pattrib->ampdu_en = true; + } + + /* re-check if enable ampdu by BA_starting_seqctrl */ + if (pattrib->ampdu_en) { + u16 tx_seq; + + tx_seq = psta->BA_starting_seqctrl[pattrib->priority & 0x0f]; + + /* check BA_starting_seqctrl */ + if (SN_LESS(pattrib->seqnum, tx_seq)) { + pattrib->ampdu_en = false;/* AGG BK */ + } else if (SN_EQUAL(pattrib->seqnum, tx_seq)) { + psta->BA_starting_seqctrl[pattrib->priority & 0x0f] = (tx_seq+1)&0xfff; + + pattrib->ampdu_en = true;/* AGG EN */ + } else { + psta->BA_starting_seqctrl[pattrib->priority & 0x0f] = (pattrib->seqnum+1)&0xfff; + pattrib->ampdu_en = true;/* AGG EN */ + } + } + } + } +exit: + +_func_exit_; + return res; +} + +s32 rtw_txframes_pending(struct adapter *padapter) +{ + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + + return ((_rtw_queue_empty(&pxmitpriv->be_pending) == false) || + (_rtw_queue_empty(&pxmitpriv->bk_pending) == false) || + (_rtw_queue_empty(&pxmitpriv->vi_pending) == false) || + (_rtw_queue_empty(&pxmitpriv->vo_pending) == false)); +} + +s32 rtw_txframes_sta_ac_pending(struct adapter *padapter, struct pkt_attrib *pattrib) +{ + struct sta_info *psta; + struct tx_servq *ptxservq; + int priority = pattrib->priority; + + psta = pattrib->psta; + + switch (priority) { + case 1: + case 2: + ptxservq = &(psta->sta_xmitpriv.bk_q); + break; + case 4: + case 5: + ptxservq = &(psta->sta_xmitpriv.vi_q); + break; + case 6: + case 7: + ptxservq = &(psta->sta_xmitpriv.vo_q); + break; + case 0: + case 3: + default: + ptxservq = &(psta->sta_xmitpriv.be_q); + break; + } + + return ptxservq->qcnt; +} + +/* + * Calculate wlan 802.11 packet MAX size from pkt_attrib + * This function doesn't consider fragment case + */ +u32 rtw_calculate_wlan_pkt_size_by_attribue(struct pkt_attrib *pattrib) +{ + u32 len = 0; + + len = pattrib->hdrlen + pattrib->iv_len; /* WLAN Header and IV */ + len += SNAP_SIZE + sizeof(u16); /* LLC */ + len += pattrib->pktlen; + if (pattrib->encrypt == _TKIP_) + len += 8; /* MIC */ + len += ((pattrib->bswenc) ? pattrib->icv_len : 0); /* ICV */ + + return len; +} + +/* + +This sub-routine will perform all the following: + +1. remove 802.3 header. +2. create wlan_header, based on the info in pxmitframe +3. append sta's iv/ext-iv +4. append LLC +5. move frag chunk from pframe to pxmitframe->mem +6. apply sw-encrypt, if necessary. + +*/ +s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct xmit_frame *pxmitframe) +{ + struct pkt_file pktfile; + s32 frg_inx, frg_len, mpdu_len, llc_sz, mem_sz; + size_t addr; + u8 *pframe, *mem_start; + u8 hw_hdr_offset; + struct sta_info *psta; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct pkt_attrib *pattrib = &pxmitframe->attrib; + u8 *pbuf_start; + s32 bmcst = IS_MCAST(pattrib->ra); + s32 res = _SUCCESS; + +_func_enter_; + + psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra); + + if (psta == NULL) + return _FAIL; + + if (pxmitframe->buf_addr == NULL) { + DBG_88E("==> %s buf_addr == NULL\n", __func__); + return _FAIL; + } + + pbuf_start = pxmitframe->buf_addr; + + hw_hdr_offset = TXDESC_SIZE + (pxmitframe->pkt_offset * PACKET_OFFSET_SZ); + + mem_start = pbuf_start + hw_hdr_offset; + + if (rtw_make_wlanhdr(padapter, mem_start, pattrib) == _FAIL) { + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("rtw_xmitframe_coalesce: rtw_make_wlanhdr fail; drop pkt\n")); + DBG_88E("rtw_xmitframe_coalesce: rtw_make_wlanhdr fail; drop pkt\n"); + res = _FAIL; + goto exit; + } + + _rtw_open_pktfile(pkt, &pktfile); + _rtw_pktfile_read(&pktfile, NULL, pattrib->pkt_hdrlen); + + frg_inx = 0; + frg_len = pxmitpriv->frag_len - 4;/* 2346-4 = 2342 */ + + while (1) { + llc_sz = 0; + + mpdu_len = frg_len; + + pframe = mem_start; + + SetMFrag(mem_start); + + pframe += pattrib->hdrlen; + mpdu_len -= pattrib->hdrlen; + + /* adding icv, if necessary... */ + if (pattrib->iv_len) { + if (psta != NULL) { + switch (pattrib->encrypt) { + case _WEP40_: + case _WEP104_: + WEP_IV(pattrib->iv, psta->dot11txpn, pattrib->key_idx); + break; + case _TKIP_: + if (bmcst) + TKIP_IV(pattrib->iv, psta->dot11txpn, pattrib->key_idx); + else + TKIP_IV(pattrib->iv, psta->dot11txpn, 0); + break; + case _AES_: + if (bmcst) + AES_IV(pattrib->iv, psta->dot11txpn, pattrib->key_idx); + else + AES_IV(pattrib->iv, psta->dot11txpn, 0); + break; + } + } + + memcpy(pframe, pattrib->iv, pattrib->iv_len); + + RT_TRACE(_module_rtl871x_xmit_c_, _drv_notice_, + ("rtw_xmitframe_coalesce: keyid=%d pattrib->iv[3]=%.2x pframe=%.2x %.2x %.2x %.2x\n", + padapter->securitypriv.dot11PrivacyKeyIndex, pattrib->iv[3], *pframe, *(pframe+1), *(pframe+2), *(pframe+3))); + + pframe += pattrib->iv_len; + + mpdu_len -= pattrib->iv_len; + } + + if (frg_inx == 0) { + llc_sz = rtw_put_snap(pframe, pattrib->ether_type); + pframe += llc_sz; + mpdu_len -= llc_sz; + } + + if ((pattrib->icv_len > 0) && (pattrib->bswenc)) { + mpdu_len -= pattrib->icv_len; + } + + if (bmcst) { + /* don't do fragment to broadcat/multicast packets */ + mem_sz = _rtw_pktfile_read(&pktfile, pframe, pattrib->pktlen); + } else { + mem_sz = _rtw_pktfile_read(&pktfile, pframe, mpdu_len); + } + + pframe += mem_sz; + + if ((pattrib->icv_len > 0) && (pattrib->bswenc)) { + memcpy(pframe, pattrib->icv, pattrib->icv_len); + pframe += pattrib->icv_len; + } + + frg_inx++; + + if (bmcst || rtw_endofpktfile(&pktfile)) { + pattrib->nr_frags = frg_inx; + + pattrib->last_txcmdsz = pattrib->hdrlen + pattrib->iv_len + ((pattrib->nr_frags == 1) ? llc_sz : 0) + + ((pattrib->bswenc) ? pattrib->icv_len : 0) + mem_sz; + + ClearMFrag(mem_start); + + break; + } else { + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("%s: There're still something in packet!\n", __func__)); + } + + addr = (size_t)(pframe); + + mem_start = (unsigned char *)RND4(addr) + hw_hdr_offset; + memcpy(mem_start, pbuf_start + hw_hdr_offset, pattrib->hdrlen); + } + + if (xmitframe_addmic(padapter, pxmitframe) == _FAIL) { + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("xmitframe_addmic(padapter, pxmitframe) == _FAIL\n")); + DBG_88E("xmitframe_addmic(padapter, pxmitframe) == _FAIL\n"); + res = _FAIL; + goto exit; + } + + xmitframe_swencrypt(padapter, pxmitframe); + + if (!bmcst) + update_attrib_vcs_info(padapter, pxmitframe); + else + pattrib->vcs_mode = NONE_VCS; + +exit: + +_func_exit_; + + return res; +} + +/* Logical Link Control(LLC) SubNetwork Attachment Point(SNAP) header + * IEEE LLC/SNAP header contains 8 octets + * First 3 octets comprise the LLC portion + * SNAP portion, 5 octets, is divided into two fields: + * Organizationally Unique Identifier(OUI), 3 octets, + * type, defined by that organization, 2 octets. + */ +s32 rtw_put_snap(u8 *data, u16 h_proto) +{ + struct ieee80211_snap_hdr *snap; + u8 *oui; + +_func_enter_; + + snap = (struct ieee80211_snap_hdr *)data; + snap->dsap = 0xaa; + snap->ssap = 0xaa; + snap->ctrl = 0x03; + + if (h_proto == 0x8137 || h_proto == 0x80f3) + oui = P802_1H_OUI; + else + oui = RFC1042_OUI; + + snap->oui[0] = oui[0]; + snap->oui[1] = oui[1]; + snap->oui[2] = oui[2]; + + *(__be16 *)(data + SNAP_SIZE) = htons(h_proto); + +_func_exit_; + + return SNAP_SIZE + sizeof(u16); +} + +void rtw_update_protection(struct adapter *padapter, u8 *ie, uint ie_len) +{ + uint protection; + u8 *perp; + int erp_len; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct registry_priv *pregistrypriv = &padapter->registrypriv; + +_func_enter_; + + switch (pxmitpriv->vcs_setting) { + case DISABLE_VCS: + pxmitpriv->vcs = NONE_VCS; + break; + case ENABLE_VCS: + break; + case AUTO_VCS: + default: + perp = rtw_get_ie(ie, _ERPINFO_IE_, &erp_len, ie_len); + if (perp == NULL) { + pxmitpriv->vcs = NONE_VCS; + } else { + protection = (*(perp + 2)) & BIT(1); + if (protection) { + if (pregistrypriv->vcs_type == RTS_CTS) + pxmitpriv->vcs = RTS_CTS; + else + pxmitpriv->vcs = CTS_TO_SELF; + } else { + pxmitpriv->vcs = NONE_VCS; + } + } + break; + } + +_func_exit_; +} + +void rtw_count_tx_stats(struct adapter *padapter, struct xmit_frame *pxmitframe, int sz) +{ + struct sta_info *psta = NULL; + struct stainfo_stats *pstats = NULL; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + + if ((pxmitframe->frame_tag&0x0f) == DATA_FRAMETAG) { + pxmitpriv->tx_bytes += sz; + pmlmepriv->LinkDetectInfo.NumTxOkInPeriod += pxmitframe->agg_num; + + psta = pxmitframe->attrib.psta; + if (psta) { + pstats = &psta->sta_stats; + pstats->tx_pkts += pxmitframe->agg_num; + pstats->tx_bytes += sz; + } + } +} + +struct xmit_buf *rtw_alloc_xmitbuf_ext(struct xmit_priv *pxmitpriv) +{ + unsigned long irql; + struct xmit_buf *pxmitbuf = NULL; + struct list_head *plist, *phead; + struct __queue *pfree_queue = &pxmitpriv->free_xmit_extbuf_queue; + +_func_enter_; + + _enter_critical(&pfree_queue->lock, &irql); + + if (_rtw_queue_empty(pfree_queue) == true) { + pxmitbuf = NULL; + } else { + phead = get_list_head(pfree_queue); + + plist = get_next(phead); + + pxmitbuf = LIST_CONTAINOR(plist, struct xmit_buf, list); + + rtw_list_delete(&(pxmitbuf->list)); + } + + if (pxmitbuf != NULL) { + pxmitpriv->free_xmit_extbuf_cnt--; + + pxmitbuf->priv_data = NULL; + /* pxmitbuf->ext_tag = true; */ + + if (pxmitbuf->sctx) { + DBG_88E("%s pxmitbuf->sctx is not NULL\n", __func__); + rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_BUF_ALLOC); + } + } + + _exit_critical(&pfree_queue->lock, &irql); + +_func_exit_; + + return pxmitbuf; +} + +s32 rtw_free_xmitbuf_ext(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf) +{ + unsigned long irql; + struct __queue *pfree_queue = &pxmitpriv->free_xmit_extbuf_queue; + +_func_enter_; + + if (pxmitbuf == NULL) + return _FAIL; + + _enter_critical(&pfree_queue->lock, &irql); + + rtw_list_delete(&pxmitbuf->list); + + rtw_list_insert_tail(&(pxmitbuf->list), get_list_head(pfree_queue)); + pxmitpriv->free_xmit_extbuf_cnt++; + + _exit_critical(&pfree_queue->lock, &irql); + +_func_exit_; + + return _SUCCESS; +} + +struct xmit_buf *rtw_alloc_xmitbuf(struct xmit_priv *pxmitpriv) +{ + unsigned long irql; + struct xmit_buf *pxmitbuf = NULL; + struct list_head *plist, *phead; + struct __queue *pfree_xmitbuf_queue = &pxmitpriv->free_xmitbuf_queue; + +_func_enter_; + + /* DBG_88E("+rtw_alloc_xmitbuf\n"); */ + + _enter_critical(&pfree_xmitbuf_queue->lock, &irql); + + if (_rtw_queue_empty(pfree_xmitbuf_queue) == true) { + pxmitbuf = NULL; + } else { + phead = get_list_head(pfree_xmitbuf_queue); + + plist = get_next(phead); + + pxmitbuf = LIST_CONTAINOR(plist, struct xmit_buf, list); + + rtw_list_delete(&(pxmitbuf->list)); + } + + if (pxmitbuf != NULL) { + pxmitpriv->free_xmitbuf_cnt--; + pxmitbuf->priv_data = NULL; + if (pxmitbuf->sctx) { + DBG_88E("%s pxmitbuf->sctx is not NULL\n", __func__); + rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_BUF_ALLOC); + } + } + _exit_critical(&pfree_xmitbuf_queue->lock, &irql); + +_func_exit_; + + return pxmitbuf; +} + +s32 rtw_free_xmitbuf(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf) +{ + unsigned long irql; + struct __queue *pfree_xmitbuf_queue = &pxmitpriv->free_xmitbuf_queue; + +_func_enter_; + if (pxmitbuf == NULL) + return _FAIL; + + if (pxmitbuf->sctx) { + DBG_88E("%s pxmitbuf->sctx is not NULL\n", __func__); + rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_BUF_FREE); + } + + if (pxmitbuf->ext_tag) { + rtw_free_xmitbuf_ext(pxmitpriv, pxmitbuf); + } else { + _enter_critical(&pfree_xmitbuf_queue->lock, &irql); + + rtw_list_delete(&pxmitbuf->list); + + rtw_list_insert_tail(&(pxmitbuf->list), get_list_head(pfree_xmitbuf_queue)); + + pxmitpriv->free_xmitbuf_cnt++; + _exit_critical(&pfree_xmitbuf_queue->lock, &irql); + } + +_func_exit_; + + return _SUCCESS; +} + +/* +Calling context: +1. OS_TXENTRY +2. RXENTRY (rx_thread or RX_ISR/RX_CallBack) + +If we turn on USE_RXTHREAD, then, no need for critical section. +Otherwise, we must use _enter/_exit critical to protect free_xmit_queue... + +Must be very very cautious... + +*/ + +struct xmit_frame *rtw_alloc_xmitframe(struct xmit_priv *pxmitpriv)/* _queue *pfree_xmit_queue) */ +{ + /* + Please remember to use all the osdep_service api, + and lock/unlock or _enter/_exit critical to protect + pfree_xmit_queue + */ + + unsigned long irql; + struct xmit_frame *pxframe = NULL; + struct list_head *plist, *phead; + struct __queue *pfree_xmit_queue = &pxmitpriv->free_xmit_queue; + +_func_enter_; + + _enter_critical_bh(&pfree_xmit_queue->lock, &irql); + + if (_rtw_queue_empty(pfree_xmit_queue) == true) { + RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_alloc_xmitframe:%d\n", pxmitpriv->free_xmitframe_cnt)); + pxframe = NULL; + } else { + phead = get_list_head(pfree_xmit_queue); + + plist = get_next(phead); + + pxframe = LIST_CONTAINOR(plist, struct xmit_frame, list); + + rtw_list_delete(&(pxframe->list)); + } + + if (pxframe != NULL) { /* default value setting */ + pxmitpriv->free_xmitframe_cnt--; + + RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_alloc_xmitframe():free_xmitframe_cnt=%d\n", pxmitpriv->free_xmitframe_cnt)); + + pxframe->buf_addr = NULL; + pxframe->pxmitbuf = NULL; + + _rtw_memset(&pxframe->attrib, 0, sizeof(struct pkt_attrib)); + /* pxframe->attrib.psta = NULL; */ + + pxframe->frame_tag = DATA_FRAMETAG; + + pxframe->pkt = NULL; + pxframe->pkt_offset = 1;/* default use pkt_offset to fill tx desc */ + + pxframe->agg_num = 1; + pxframe->ack_report = 0; + } + + _exit_critical_bh(&pfree_xmit_queue->lock, &irql); + +_func_exit_; + + return pxframe; +} + +s32 rtw_free_xmitframe(struct xmit_priv *pxmitpriv, struct xmit_frame *pxmitframe) +{ + unsigned long irql; + struct __queue *pfree_xmit_queue = &pxmitpriv->free_xmit_queue; + struct adapter *padapter = pxmitpriv->adapter; + struct sk_buff *pndis_pkt = NULL; + +_func_enter_; + + if (pxmitframe == NULL) { + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("====== rtw_free_xmitframe():pxmitframe == NULL!!!!!!!!!!\n")); + goto exit; + } + + _enter_critical_bh(&pfree_xmit_queue->lock, &irql); + + rtw_list_delete(&pxmitframe->list); + + if (pxmitframe->pkt) { + pndis_pkt = pxmitframe->pkt; + pxmitframe->pkt = NULL; + } + + rtw_list_insert_tail(&pxmitframe->list, get_list_head(pfree_xmit_queue)); + + pxmitpriv->free_xmitframe_cnt++; + RT_TRACE(_module_rtl871x_xmit_c_, _drv_debug_, ("rtw_free_xmitframe():free_xmitframe_cnt=%d\n", pxmitpriv->free_xmitframe_cnt)); + + _exit_critical_bh(&pfree_xmit_queue->lock, &irql); + + if (pndis_pkt) + rtw_os_pkt_complete(padapter, pndis_pkt); + +exit: + +_func_exit_; + + return _SUCCESS; +} + +void rtw_free_xmitframe_queue(struct xmit_priv *pxmitpriv, struct __queue *pframequeue) +{ + unsigned long irql; + struct list_head *plist, *phead; + struct xmit_frame *pxmitframe; + +_func_enter_; + + _enter_critical_bh(&(pframequeue->lock), &irql); + + phead = get_list_head(pframequeue); + plist = get_next(phead); + + while (!rtw_end_of_queue_search(phead, plist)) { + pxmitframe = LIST_CONTAINOR(plist, struct xmit_frame, list); + + plist = get_next(plist); + + rtw_free_xmitframe(pxmitpriv, pxmitframe); + } + _exit_critical_bh(&(pframequeue->lock), &irql); + +_func_exit_; +} + +s32 rtw_xmitframe_enqueue(struct adapter *padapter, struct xmit_frame *pxmitframe) +{ + if (rtw_xmit_classifier(padapter, pxmitframe) == _FAIL) { + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, + ("rtw_xmitframe_enqueue: drop xmit pkt for classifier fail\n")); +/* pxmitframe->pkt = NULL; */ + return _FAIL; + } + + return _SUCCESS; +} + +static struct xmit_frame *dequeue_one_xmitframe(struct xmit_priv *pxmitpriv, struct hw_xmit *phwxmit, struct tx_servq *ptxservq, struct __queue *pframe_queue) +{ + struct list_head *xmitframe_plist, *xmitframe_phead; + struct xmit_frame *pxmitframe = NULL; + + xmitframe_phead = get_list_head(pframe_queue); + xmitframe_plist = get_next(xmitframe_phead); + + while (!rtw_end_of_queue_search(xmitframe_phead, xmitframe_plist)) { + pxmitframe = LIST_CONTAINOR(xmitframe_plist, struct xmit_frame, list); + + xmitframe_plist = get_next(xmitframe_plist); + + rtw_list_delete(&pxmitframe->list); + + ptxservq->qcnt--; + + break; + + pxmitframe = NULL; + } + + return pxmitframe; +} + +struct xmit_frame *rtw_dequeue_xframe(struct xmit_priv *pxmitpriv, struct hw_xmit *phwxmit_i, int entry) +{ + unsigned long irql0; + struct list_head *sta_plist, *sta_phead; + struct hw_xmit *phwxmit; + struct tx_servq *ptxservq = NULL; + struct __queue *pframe_queue = NULL; + struct xmit_frame *pxmitframe = NULL; + struct adapter *padapter = pxmitpriv->adapter; + struct registry_priv *pregpriv = &padapter->registrypriv; + int i, inx[4]; + +_func_enter_; + + inx[0] = 0; inx[1] = 1; inx[2] = 2; inx[3] = 3; + + if (pregpriv->wifi_spec == 1) { + int j; + + for (j = 0; j < 4; j++) + inx[j] = pxmitpriv->wmm_para_seq[j]; + } + + _enter_critical_bh(&pxmitpriv->lock, &irql0); + + for (i = 0; i < entry; i++) { + phwxmit = phwxmit_i + inx[i]; + + sta_phead = get_list_head(phwxmit->sta_queue); + sta_plist = get_next(sta_phead); + + while (!rtw_end_of_queue_search(sta_phead, sta_plist)) { + ptxservq = LIST_CONTAINOR(sta_plist, struct tx_servq, tx_pending); + + pframe_queue = &ptxservq->sta_pending; + + pxmitframe = dequeue_one_xmitframe(pxmitpriv, phwxmit, ptxservq, pframe_queue); + + if (pxmitframe) { + phwxmit->accnt--; + + /* Remove sta node when there are no pending packets. */ + if (_rtw_queue_empty(pframe_queue)) /* must be done after get_next and before break */ + rtw_list_delete(&ptxservq->tx_pending); + goto exit; + } + + sta_plist = get_next(sta_plist); + } + } +exit: + _exit_critical_bh(&pxmitpriv->lock, &irql0); +_func_exit_; + return pxmitframe; +} + +struct tx_servq *rtw_get_sta_pending(struct adapter *padapter, struct sta_info *psta, int up, u8 *ac) +{ + struct tx_servq *ptxservq; + +_func_enter_; + switch (up) { + case 1: + case 2: + ptxservq = &(psta->sta_xmitpriv.bk_q); + *(ac) = 3; + RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_get_sta_pending : BK\n")); + break; + case 4: + case 5: + ptxservq = &(psta->sta_xmitpriv.vi_q); + *(ac) = 1; + RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_get_sta_pending : VI\n")); + break; + case 6: + case 7: + ptxservq = &(psta->sta_xmitpriv.vo_q); + *(ac) = 0; + RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_get_sta_pending : VO\n")); + break; + case 0: + case 3: + default: + ptxservq = &(psta->sta_xmitpriv.be_q); + *(ac) = 2; + RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_get_sta_pending : BE\n")); + break; + } + +_func_exit_; + + return ptxservq; +} + +/* + * Will enqueue pxmitframe to the proper queue, + * and indicate it to xx_pending list..... + */ +s32 rtw_xmit_classifier(struct adapter *padapter, struct xmit_frame *pxmitframe) +{ + /* unsigned long irql0; */ + u8 ac_index; + struct sta_info *psta; + struct tx_servq *ptxservq; + struct pkt_attrib *pattrib = &pxmitframe->attrib; + struct sta_priv *pstapriv = &padapter->stapriv; + struct hw_xmit *phwxmits = padapter->xmitpriv.hwxmits; + int res = _SUCCESS; + +_func_enter_; + + if (pattrib->psta) { + psta = pattrib->psta; + } else { + psta = rtw_get_stainfo(pstapriv, pattrib->ra); + } + + if (psta == NULL) { + res = _FAIL; + DBG_88E("rtw_xmit_classifier: psta == NULL\n"); + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("rtw_xmit_classifier: psta == NULL\n")); + goto exit; + } + + ptxservq = rtw_get_sta_pending(padapter, psta, pattrib->priority, (u8 *)(&ac_index)); + + if (rtw_is_list_empty(&ptxservq->tx_pending)) + rtw_list_insert_tail(&ptxservq->tx_pending, get_list_head(phwxmits[ac_index].sta_queue)); + + rtw_list_insert_tail(&pxmitframe->list, get_list_head(&ptxservq->sta_pending)); + ptxservq->qcnt++; + phwxmits[ac_index].accnt++; +exit: + +_func_exit_; + + return res; +} + +void rtw_alloc_hwxmits(struct adapter *padapter) +{ + struct hw_xmit *hwxmits; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + + pxmitpriv->hwxmit_entry = HWXMIT_ENTRY; + + pxmitpriv->hwxmits = (struct hw_xmit *)rtw_zmalloc(sizeof(struct hw_xmit) * pxmitpriv->hwxmit_entry); + + hwxmits = pxmitpriv->hwxmits; + + if (pxmitpriv->hwxmit_entry == 5) { + hwxmits[0] .sta_queue = &pxmitpriv->bm_pending; + hwxmits[1] .sta_queue = &pxmitpriv->vo_pending; + hwxmits[2] .sta_queue = &pxmitpriv->vi_pending; + hwxmits[3] .sta_queue = &pxmitpriv->bk_pending; + hwxmits[4] .sta_queue = &pxmitpriv->be_pending; + } else if (pxmitpriv->hwxmit_entry == 4) { + hwxmits[0] .sta_queue = &pxmitpriv->vo_pending; + hwxmits[1] .sta_queue = &pxmitpriv->vi_pending; + hwxmits[2] .sta_queue = &pxmitpriv->be_pending; + hwxmits[3] .sta_queue = &pxmitpriv->bk_pending; + } else { + } +} + +void rtw_free_hwxmits(struct adapter *padapter) +{ + struct hw_xmit *hwxmits; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + + hwxmits = pxmitpriv->hwxmits; + kfree(hwxmits); +} + +void rtw_init_hwxmits(struct hw_xmit *phwxmit, int entry) +{ + int i; +_func_enter_; + for (i = 0; i < entry; i++, phwxmit++) + phwxmit->accnt = 0; +_func_exit_; +} + +static int rtw_br_client_tx(struct adapter *padapter, struct sk_buff **pskb) +{ + struct sk_buff *skb = *pskb; + unsigned long irql; + int res, is_vlan_tag = 0, i, do_nat25 = 1; + unsigned short vlan_hdr = 0; + void *br_port = NULL; + + rcu_read_lock(); + br_port = rcu_dereference(padapter->pnetdev->rx_handler_data); + rcu_read_unlock(); + _enter_critical_bh(&padapter->br_ext_lock, &irql); + if (!(skb->data[0] & 1) && br_port && + memcmp(skb->data+MACADDRLEN, padapter->br_mac, MACADDRLEN) && + *((__be16 *)(skb->data+MACADDRLEN*2)) != __constant_htons(ETH_P_8021Q) && + *((__be16 *)(skb->data+MACADDRLEN*2)) == __constant_htons(ETH_P_IP) && + !memcmp(padapter->scdb_mac, skb->data+MACADDRLEN, MACADDRLEN) && padapter->scdb_entry) { + memcpy(skb->data+MACADDRLEN, GET_MY_HWADDR(padapter), MACADDRLEN); + padapter->scdb_entry->ageing_timer = jiffies; + _exit_critical_bh(&padapter->br_ext_lock, &irql); + } else { + if (*((__be16 *)(skb->data+MACADDRLEN*2)) == __constant_htons(ETH_P_8021Q)) { + is_vlan_tag = 1; + vlan_hdr = *((unsigned short *)(skb->data+MACADDRLEN*2+2)); + for (i = 0; i < 6; i++) + *((unsigned short *)(skb->data+MACADDRLEN*2+2-i*2)) = *((unsigned short *)(skb->data+MACADDRLEN*2-2-i*2)); + skb_pull(skb, 4); + } + if (!memcmp(skb->data+MACADDRLEN, padapter->br_mac, MACADDRLEN) && + (*((__be16 *)(skb->data+MACADDRLEN*2)) == __constant_htons(ETH_P_IP))) + memcpy(padapter->br_ip, skb->data+WLAN_ETHHDR_LEN+12, 4); + + if (*((__be16 *)(skb->data+MACADDRLEN*2)) == __constant_htons(ETH_P_IP)) { + if (memcmp(padapter->scdb_mac, skb->data+MACADDRLEN, MACADDRLEN)) { + padapter->scdb_entry = (struct nat25_network_db_entry *)scdb_findEntry(padapter, + skb->data+MACADDRLEN, skb->data+WLAN_ETHHDR_LEN+12); + if (padapter->scdb_entry) { + memcpy(padapter->scdb_mac, skb->data+MACADDRLEN, MACADDRLEN); + memcpy(padapter->scdb_ip, skb->data+WLAN_ETHHDR_LEN+12, 4); + padapter->scdb_entry->ageing_timer = jiffies; + do_nat25 = 0; + } + } else { + if (padapter->scdb_entry) { + padapter->scdb_entry->ageing_timer = jiffies; + do_nat25 = 0; + } else { + memset(padapter->scdb_mac, 0, MACADDRLEN); + memset(padapter->scdb_ip, 0, 4); + } + } + } + _exit_critical_bh(&padapter->br_ext_lock, &irql); + if (do_nat25) { + if (nat25_db_handle(padapter, skb, NAT25_CHECK) == 0) { + struct sk_buff *newskb; + + if (is_vlan_tag) { + skb_push(skb, 4); + for (i = 0; i < 6; i++) + *((unsigned short *)(skb->data+i*2)) = *((unsigned short *)(skb->data+4+i*2)); + *((__be16 *)(skb->data+MACADDRLEN*2)) = __constant_htons(ETH_P_8021Q); + *((unsigned short *)(skb->data+MACADDRLEN*2+2)) = vlan_hdr; + } + + newskb = skb_copy(skb, GFP_ATOMIC); + if (newskb == NULL) { + DEBUG_ERR("TX DROP: skb_copy fail!\n"); + return -1; + } + dev_kfree_skb_any(skb); + + *pskb = skb = newskb; + if (is_vlan_tag) { + vlan_hdr = *((unsigned short *)(skb->data+MACADDRLEN*2+2)); + for (i = 0; i < 6; i++) + *((unsigned short *)(skb->data+MACADDRLEN*2+2-i*2)) = *((unsigned short *)(skb->data+MACADDRLEN*2-2-i*2)); + skb_pull(skb, 4); + } + } + + if (skb_is_nonlinear(skb)) + DEBUG_ERR("%s(): skb_is_nonlinear!!\n", __func__); + + res = skb_linearize(skb); + if (res < 0) { + DEBUG_ERR("TX DROP: skb_linearize fail!\n"); + return -1; + } + + res = nat25_db_handle(padapter, skb, NAT25_INSERT); + if (res < 0) { + if (res == -2) { + DEBUG_ERR("TX DROP: nat25_db_handle fail!\n"); + return -1; + } + return 0; + } + } + + memcpy(skb->data+MACADDRLEN, GET_MY_HWADDR(padapter), MACADDRLEN); + + dhcp_flag_bcast(padapter, skb); + + if (is_vlan_tag) { + skb_push(skb, 4); + for (i = 0; i < 6; i++) + *((unsigned short *)(skb->data+i*2)) = *((unsigned short *)(skb->data+4+i*2)); + *((__be16 *)(skb->data+MACADDRLEN*2)) = __constant_htons(ETH_P_8021Q); + *((unsigned short *)(skb->data+MACADDRLEN*2+2)) = vlan_hdr; + } + } + + /* check if SA is equal to our MAC */ + if (memcmp(skb->data+MACADDRLEN, GET_MY_HWADDR(padapter), MACADDRLEN)) { + DEBUG_ERR("TX DROP: untransformed frame SA:%02X%02X%02X%02X%02X%02X!\n", + skb->data[6], skb->data[7], skb->data[8], skb->data[9], skb->data[10], skb->data[11]); + return -1; + } + return 0; +} + +u32 rtw_get_ff_hwaddr(struct xmit_frame *pxmitframe) +{ + u32 addr; + struct pkt_attrib *pattrib = &pxmitframe->attrib; + + switch (pattrib->qsel) { + case 0: + case 3: + addr = BE_QUEUE_INX; + break; + case 1: + case 2: + addr = BK_QUEUE_INX; + break; + case 4: + case 5: + addr = VI_QUEUE_INX; + break; + case 6: + case 7: + addr = VO_QUEUE_INX; + break; + case 0x10: + addr = BCN_QUEUE_INX; + break; + case 0x11:/* BC/MC in PS (HIQ) */ + addr = HIGH_QUEUE_INX; + break; + case 0x12: + default: + addr = MGT_QUEUE_INX; + break; + } + + return addr; +} + +static void do_queue_select(struct adapter *padapter, struct pkt_attrib *pattrib) +{ + u8 qsel; + + qsel = pattrib->priority; + RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("### do_queue_select priority=%d , qsel = %d\n", pattrib->priority , qsel)); + + pattrib->qsel = qsel; +} + +/* + * The main transmit(tx) entry + * + * Return + * 1 enqueue + * 0 success, hardware will handle this xmit frame(packet) + * <0 fail + */ +s32 rtw_xmit(struct adapter *padapter, struct sk_buff **ppkt) +{ +#ifdef CONFIG_88EU_AP_MODE + unsigned long irql0; +#endif + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct xmit_frame *pxmitframe = NULL; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + void *br_port = NULL; + s32 res; + + pxmitframe = rtw_alloc_xmitframe(pxmitpriv); + if (pxmitframe == NULL) { + RT_TRACE(_module_xmit_osdep_c_, _drv_err_, ("rtw_xmit: no more pxmitframe\n")); + DBG_88E("DBG_TX_DROP_FRAME %s no more pxmitframe\n", __func__); + return -1; + } + + rcu_read_lock(); + br_port = rcu_dereference(padapter->pnetdev->rx_handler_data); + rcu_read_unlock(); + + if (br_port && check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_ADHOC_STATE)) { + res = rtw_br_client_tx(padapter, ppkt); + if (res == -1) { + rtw_free_xmitframe(pxmitpriv, pxmitframe); + return -1; + } + } + + res = update_attrib(padapter, *ppkt, &pxmitframe->attrib); + + if (res == _FAIL) { + RT_TRACE(_module_xmit_osdep_c_, _drv_err_, ("rtw_xmit: update attrib fail\n")); + rtw_free_xmitframe(pxmitpriv, pxmitframe); + return -1; + } + pxmitframe->pkt = *ppkt; + + rtw_led_control(padapter, LED_CTL_TX); + + do_queue_select(padapter, &pxmitframe->attrib); + +#ifdef CONFIG_88EU_AP_MODE + _enter_critical_bh(&pxmitpriv->lock, &irql0); + if (xmitframe_enqueue_for_sleeping_sta(padapter, pxmitframe)) { + _exit_critical_bh(&pxmitpriv->lock, &irql0); + return 1; + } + _exit_critical_bh(&pxmitpriv->lock, &irql0); +#endif + + if (rtw_hal_xmit(padapter, pxmitframe) == false) + return 1; + + return 0; +} + +#if defined(CONFIG_88EU_AP_MODE) + +int xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_frame *pxmitframe) +{ + unsigned long irql; + int ret = false; + struct sta_info *psta = NULL; + struct sta_priv *pstapriv = &padapter->stapriv; + struct pkt_attrib *pattrib = &pxmitframe->attrib; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + int bmcst = IS_MCAST(pattrib->ra); + + if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == false) + return ret; + + if (pattrib->psta) + psta = pattrib->psta; + else + psta = rtw_get_stainfo(pstapriv, pattrib->ra); + + if (psta == NULL) + return ret; + + if (pattrib->triggered == 1) { + if (bmcst) + pattrib->qsel = 0x11;/* HIQ */ + return ret; + } + + if (bmcst) { + _enter_critical_bh(&psta->sleep_q.lock, &irql); + + if (pstapriv->sta_dz_bitmap) {/* if any one sta is in ps mode */ + rtw_list_delete(&pxmitframe->list); + + rtw_list_insert_tail(&pxmitframe->list, get_list_head(&psta->sleep_q)); + + psta->sleepq_len++; + + pstapriv->tim_bitmap |= BIT(0);/* */ + pstapriv->sta_dz_bitmap |= BIT(0); + + update_beacon(padapter, _TIM_IE_, NULL, false);/* tx bc/mc packets after upate bcn */ + + ret = true; + } + + _exit_critical_bh(&psta->sleep_q.lock, &irql); + + return ret; + } + + _enter_critical_bh(&psta->sleep_q.lock, &irql); + + if (psta->state&WIFI_SLEEP_STATE) { + u8 wmmps_ac = 0; + + if (pstapriv->sta_dz_bitmap&BIT(psta->aid)) { + rtw_list_delete(&pxmitframe->list); + + rtw_list_insert_tail(&pxmitframe->list, get_list_head(&psta->sleep_q)); + + psta->sleepq_len++; + + switch (pattrib->priority) { + case 1: + case 2: + wmmps_ac = psta->uapsd_bk&BIT(0); + break; + case 4: + case 5: + wmmps_ac = psta->uapsd_vi&BIT(0); + break; + case 6: + case 7: + wmmps_ac = psta->uapsd_vo&BIT(0); + break; + case 0: + case 3: + default: + wmmps_ac = psta->uapsd_be&BIT(0); + break; + } + + if (wmmps_ac) + psta->sleepq_ac_len++; + + if (((psta->has_legacy_ac) && (!wmmps_ac)) || + ((!psta->has_legacy_ac) && (wmmps_ac))) { + pstapriv->tim_bitmap |= BIT(psta->aid); + + if (psta->sleepq_len == 1) { + /* upate BCN for TIM IE */ + update_beacon(padapter, _TIM_IE_, NULL, false); + } + } + ret = true; + } + } + + _exit_critical_bh(&psta->sleep_q.lock, &irql); + + return ret; +} + +static void dequeue_xmitframes_to_sleeping_queue(struct adapter *padapter, struct sta_info *psta, struct __queue *pframequeue) +{ + struct list_head *plist, *phead; + u8 ac_index; + struct tx_servq *ptxservq; + struct pkt_attrib *pattrib; + struct xmit_frame *pxmitframe; + struct hw_xmit *phwxmits = padapter->xmitpriv.hwxmits; + + phead = get_list_head(pframequeue); + plist = get_next(phead); + + while (!rtw_end_of_queue_search(phead, plist)) { + pxmitframe = LIST_CONTAINOR(plist, struct xmit_frame, list); + + plist = get_next(plist); + + xmitframe_enqueue_for_sleeping_sta(padapter, pxmitframe); + + pattrib = &pxmitframe->attrib; + + ptxservq = rtw_get_sta_pending(padapter, psta, pattrib->priority, (u8 *)(&ac_index)); + + ptxservq->qcnt--; + phwxmits[ac_index].accnt--; + } +} + +void stop_sta_xmit(struct adapter *padapter, struct sta_info *psta) +{ + unsigned long irql0; + struct sta_info *psta_bmc; + struct sta_xmit_priv *pstaxmitpriv; + struct sta_priv *pstapriv = &padapter->stapriv; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + + pstaxmitpriv = &psta->sta_xmitpriv; + + /* for BC/MC Frames */ + psta_bmc = rtw_get_bcmc_stainfo(padapter); + + _enter_critical_bh(&pxmitpriv->lock, &irql0); + + psta->state |= WIFI_SLEEP_STATE; + + pstapriv->sta_dz_bitmap |= BIT(psta->aid); + + dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->vo_q.sta_pending); + rtw_list_delete(&(pstaxmitpriv->vo_q.tx_pending)); + + dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->vi_q.sta_pending); + rtw_list_delete(&(pstaxmitpriv->vi_q.tx_pending)); + + dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->be_q.sta_pending); + rtw_list_delete(&(pstaxmitpriv->be_q.tx_pending)); + + dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->bk_q.sta_pending); + rtw_list_delete(&(pstaxmitpriv->bk_q.tx_pending)); + + /* for BC/MC Frames */ + pstaxmitpriv = &psta_bmc->sta_xmitpriv; + dequeue_xmitframes_to_sleeping_queue(padapter, psta_bmc, &pstaxmitpriv->be_q.sta_pending); + rtw_list_delete(&(pstaxmitpriv->be_q.tx_pending)); + + _exit_critical_bh(&pxmitpriv->lock, &irql0); +} + +void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta) +{ + unsigned long irql; + u8 update_mask = 0, wmmps_ac = 0; + struct sta_info *psta_bmc; + struct list_head *xmitframe_plist, *xmitframe_phead; + struct xmit_frame *pxmitframe = NULL; + struct sta_priv *pstapriv = &padapter->stapriv; + + _enter_critical_bh(&psta->sleep_q.lock, &irql); + + xmitframe_phead = get_list_head(&psta->sleep_q); + xmitframe_plist = get_next(xmitframe_phead); + + while (!rtw_end_of_queue_search(xmitframe_phead, xmitframe_plist)) { + pxmitframe = LIST_CONTAINOR(xmitframe_plist, struct xmit_frame, list); + + xmitframe_plist = get_next(xmitframe_plist); + + rtw_list_delete(&pxmitframe->list); + + switch (pxmitframe->attrib.priority) { + case 1: + case 2: + wmmps_ac = psta->uapsd_bk&BIT(1); + break; + case 4: + case 5: + wmmps_ac = psta->uapsd_vi&BIT(1); + break; + case 6: + case 7: + wmmps_ac = psta->uapsd_vo&BIT(1); + break; + case 0: + case 3: + default: + wmmps_ac = psta->uapsd_be&BIT(1); + break; + } + + psta->sleepq_len--; + if (psta->sleepq_len > 0) + pxmitframe->attrib.mdata = 1; + else + pxmitframe->attrib.mdata = 0; + + if (wmmps_ac) { + psta->sleepq_ac_len--; + if (psta->sleepq_ac_len > 0) { + pxmitframe->attrib.mdata = 1; + pxmitframe->attrib.eosp = 0; + } else { + pxmitframe->attrib.mdata = 0; + pxmitframe->attrib.eosp = 1; + } + } + + pxmitframe->attrib.triggered = 1; + + _exit_critical_bh(&psta->sleep_q.lock, &irql); + if (rtw_hal_xmit(padapter, pxmitframe)) + rtw_os_xmit_complete(padapter, pxmitframe); + _enter_critical_bh(&psta->sleep_q.lock, &irql); + } + + if (psta->sleepq_len == 0) { + pstapriv->tim_bitmap &= ~BIT(psta->aid); + + update_mask = BIT(0); + + if (psta->state&WIFI_SLEEP_STATE) + psta->state ^= WIFI_SLEEP_STATE; + + if (psta->state & WIFI_STA_ALIVE_CHK_STATE) { + psta->expire_to = pstapriv->expire_to; + psta->state ^= WIFI_STA_ALIVE_CHK_STATE; + } + + pstapriv->sta_dz_bitmap &= ~BIT(psta->aid); + } + + _exit_critical_bh(&psta->sleep_q.lock, &irql); + + /* for BC/MC Frames */ + psta_bmc = rtw_get_bcmc_stainfo(padapter); + if (!psta_bmc) + return; + + if ((pstapriv->sta_dz_bitmap&0xfffe) == 0x0) { /* no any sta in ps mode */ + _enter_critical_bh(&psta_bmc->sleep_q.lock, &irql); + + xmitframe_phead = get_list_head(&psta_bmc->sleep_q); + xmitframe_plist = get_next(xmitframe_phead); + + while (!rtw_end_of_queue_search(xmitframe_phead, xmitframe_plist)) { + pxmitframe = LIST_CONTAINOR(xmitframe_plist, struct xmit_frame, list); + + xmitframe_plist = get_next(xmitframe_plist); + + rtw_list_delete(&pxmitframe->list); + + psta_bmc->sleepq_len--; + if (psta_bmc->sleepq_len > 0) + pxmitframe->attrib.mdata = 1; + else + pxmitframe->attrib.mdata = 0; + + pxmitframe->attrib.triggered = 1; + + _exit_critical_bh(&psta_bmc->sleep_q.lock, &irql); + if (rtw_hal_xmit(padapter, pxmitframe)) + rtw_os_xmit_complete(padapter, pxmitframe); + _enter_critical_bh(&psta_bmc->sleep_q.lock, &irql); + } + + if (psta_bmc->sleepq_len == 0) { + pstapriv->tim_bitmap &= ~BIT(0); + pstapriv->sta_dz_bitmap &= ~BIT(0); + + update_mask |= BIT(1); + } + + _exit_critical_bh(&psta_bmc->sleep_q.lock, &irql); + } + + if (update_mask) + update_beacon(padapter, _TIM_IE_, NULL, false); +} + +void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *psta) +{ + unsigned long irql; + u8 wmmps_ac = 0; + struct list_head *xmitframe_plist, *xmitframe_phead; + struct xmit_frame *pxmitframe = NULL; + struct sta_priv *pstapriv = &padapter->stapriv; + + _enter_critical_bh(&psta->sleep_q.lock, &irql); + + xmitframe_phead = get_list_head(&psta->sleep_q); + xmitframe_plist = get_next(xmitframe_phead); + + while (!rtw_end_of_queue_search(xmitframe_phead, xmitframe_plist)) { + pxmitframe = LIST_CONTAINOR(xmitframe_plist, struct xmit_frame, list); + + xmitframe_plist = get_next(xmitframe_plist); + + switch (pxmitframe->attrib.priority) { + case 1: + case 2: + wmmps_ac = psta->uapsd_bk&BIT(1); + break; + case 4: + case 5: + wmmps_ac = psta->uapsd_vi&BIT(1); + break; + case 6: + case 7: + wmmps_ac = psta->uapsd_vo&BIT(1); + break; + case 0: + case 3: + default: + wmmps_ac = psta->uapsd_be&BIT(1); + break; + } + + if (!wmmps_ac) + continue; + + rtw_list_delete(&pxmitframe->list); + + psta->sleepq_len--; + psta->sleepq_ac_len--; + + if (psta->sleepq_ac_len > 0) { + pxmitframe->attrib.mdata = 1; + pxmitframe->attrib.eosp = 0; + } else { + pxmitframe->attrib.mdata = 0; + pxmitframe->attrib.eosp = 1; + } + + pxmitframe->attrib.triggered = 1; + + if (rtw_hal_xmit(padapter, pxmitframe) == true) + rtw_os_xmit_complete(padapter, pxmitframe); + + if ((psta->sleepq_ac_len == 0) && (!psta->has_legacy_ac) && (wmmps_ac)) { + pstapriv->tim_bitmap &= ~BIT(psta->aid); + + /* upate BCN for TIM IE */ + update_beacon(padapter, _TIM_IE_, NULL, false); + } + } + + _exit_critical_bh(&psta->sleep_q.lock, &irql); +} + +#endif + +void rtw_sctx_init(struct submit_ctx *sctx, int timeout_ms) +{ + sctx->timeout_ms = timeout_ms; + sctx->submit_time = rtw_get_current_time(); + init_completion(&sctx->done); + sctx->status = RTW_SCTX_SUBMITTED; +} + +int rtw_sctx_wait(struct submit_ctx *sctx) +{ + int ret = _FAIL; + unsigned long expire; + int status = 0; + + expire = sctx->timeout_ms ? msecs_to_jiffies(sctx->timeout_ms) : MAX_SCHEDULE_TIMEOUT; + if (!wait_for_completion_timeout(&sctx->done, expire)) { + /* timeout, do something?? */ + status = RTW_SCTX_DONE_TIMEOUT; + DBG_88E("%s timeout\n", __func__); + } else { + status = sctx->status; + } + + if (status == RTW_SCTX_DONE_SUCCESS) + ret = _SUCCESS; + + return ret; +} + +static bool rtw_sctx_chk_waring_status(int status) +{ + switch (status) { + case RTW_SCTX_DONE_UNKNOWN: + case RTW_SCTX_DONE_BUF_ALLOC: + case RTW_SCTX_DONE_BUF_FREE: + + case RTW_SCTX_DONE_DRV_STOP: + case RTW_SCTX_DONE_DEV_REMOVE: + return true; + default: + return false; + } +} + +void rtw_sctx_done_err(struct submit_ctx **sctx, int status) +{ + if (*sctx) { + if (rtw_sctx_chk_waring_status(status)) + DBG_88E("%s status:%d\n", __func__, status); + (*sctx)->status = status; + complete(&((*sctx)->done)); + *sctx = NULL; + } +} + +void rtw_sctx_done(struct submit_ctx **sctx) +{ + rtw_sctx_done_err(sctx, RTW_SCTX_DONE_SUCCESS); +} + +int rtw_ack_tx_wait(struct xmit_priv *pxmitpriv, u32 timeout_ms) +{ + struct submit_ctx *pack_tx_ops = &pxmitpriv->ack_tx_ops; + + pack_tx_ops->submit_time = rtw_get_current_time(); + pack_tx_ops->timeout_ms = timeout_ms; + pack_tx_ops->status = RTW_SCTX_SUBMITTED; + + return rtw_sctx_wait(pack_tx_ops); +} + +void rtw_ack_tx_done(struct xmit_priv *pxmitpriv, int status) +{ + struct submit_ctx *pack_tx_ops = &pxmitpriv->ack_tx_ops; + + if (pxmitpriv->ack_tx) + rtw_sctx_done_err(&pack_tx_ops, status); + else + DBG_88E("%s ack_tx not set\n", __func__); +} -- GitLab From a0da203b14bc6dabec9e9568c82bc524d3f7b69b Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 21 Aug 2013 22:33:50 -0500 Subject: [PATCH 766/942] staging: r8188eu: Add files for new driver - part 8 This commit adds files hal/Hal8188EFWImg_CE.c, hal/Hal8188EPwrSeq.c, and hal/Hal8188ERateAdaptive.c. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8188eu/hal/Hal8188EFWImg_CE.c | 1761 +++++++++++++++++ .../staging/rtl8188eu/hal/Hal8188EPwrSeq.c | 86 + .../rtl8188eu/hal/Hal8188ERateAdaptive.c | 760 +++++++ 3 files changed, 2607 insertions(+) create mode 100644 drivers/staging/rtl8188eu/hal/Hal8188EFWImg_CE.c create mode 100644 drivers/staging/rtl8188eu/hal/Hal8188EPwrSeq.c create mode 100644 drivers/staging/rtl8188eu/hal/Hal8188ERateAdaptive.c diff --git a/drivers/staging/rtl8188eu/hal/Hal8188EFWImg_CE.c b/drivers/staging/rtl8188eu/hal/Hal8188EFWImg_CE.c new file mode 100644 index 0000000000000..95759bed54103 --- /dev/null +++ b/drivers/staging/rtl8188eu/hal/Hal8188EFWImg_CE.c @@ -0,0 +1,1761 @@ +/****************************************************************************** +* +* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* 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. +* +* You should have received a copy of the GNU General Public License along with +* this program; if not, write to the Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA +* +* +******************************************************************************/ +#include "odm_precomp.h" + +const u8 Rtl8188EFwImgArray[Rtl8188EFWImgArrayLength] = { + 0xE1, 0x88, 0x10, 0x00, 0x0B, 0x00, 0x01, 0x00, + 0x01, 0x21, 0x11, 0x27, 0x30, 0x36, 0x00, 0x00, + 0x2D, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x45, 0x4E, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xC1, 0x6F, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xA1, 0xE6, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x02, 0x56, 0xF7, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xC2, 0xAF, 0x80, 0xFE, 0x32, 0x12, 0x42, 0x04, + 0x85, 0xD0, 0x0B, 0x75, 0xD0, 0x08, 0xAA, 0xE0, + 0xC2, 0x8C, 0xE5, 0x8A, 0x24, 0x67, 0xF5, 0x8A, + 0xE5, 0x8C, 0x34, 0x79, 0xF5, 0x8C, 0xD2, 0x8C, + 0xEC, 0x24, 0x89, 0xF8, 0xE6, 0xBC, 0x03, 0x02, + 0x74, 0xFF, 0xC3, 0x95, 0x81, 0xB4, 0x40, 0x00, + 0x40, 0xCE, 0x79, 0x04, 0x78, 0x80, 0x16, 0xE6, + 0x08, 0x70, 0x0B, 0xC2, 0xAF, 0xE6, 0x30, 0xE1, + 0x03, 0x44, 0x18, 0xF6, 0xD2, 0xAF, 0x08, 0xD9, + 0xED, 0xEA, 0x8B, 0xD0, 0x22, 0xE5, 0x0C, 0xFF, + 0x23, 0x24, 0x81, 0xF8, 0x0F, 0x08, 0x08, 0xBF, + 0x04, 0x04, 0x7F, 0x00, 0x78, 0x81, 0xE6, 0x30, + 0xE4, 0xF2, 0x00, 0xE5, 0x0C, 0xC3, 0x9F, 0x50, + 0x20, 0x05, 0x0C, 0x74, 0x88, 0x25, 0x0C, 0xF8, + 0xE6, 0xFD, 0xA6, 0x81, 0x08, 0xE6, 0xAE, 0x0C, + 0xBE, 0x03, 0x02, 0x74, 0xFF, 0xCD, 0xF8, 0xE8, + 0x6D, 0x60, 0xE0, 0x08, 0xE6, 0xC0, 0xE0, 0x80, + 0xF6, 0xE5, 0x0C, 0xD3, 0x9F, 0x40, 0x27, 0xE5, + 0x0C, 0x24, 0x89, 0xF8, 0xE6, 0xAE, 0x0C, 0xBE, + 0x03, 0x02, 0x74, 0xFF, 0xFD, 0x18, 0xE6, 0xCD, + 0xF8, 0xE5, 0x81, 0x6D, 0x60, 0x06, 0xD0, 0xE0, + 0xF6, 0x18, 0x80, 0xF5, 0xE5, 0x0C, 0x24, 0x88, + 0xC8, 0xF6, 0x15, 0x0C, 0x80, 0xD3, 0xE5, 0x0C, + 0x23, 0x24, 0x81, 0xF8, 0x7F, 0x04, 0xC2, 0xAF, + 0xE6, 0x30, 0xE0, 0x03, 0x10, 0xE2, 0x0C, 0x7F, + 0x00, 0x30, 0xE1, 0x07, 0x30, 0xE3, 0x04, 0x7F, + 0x08, 0x54, 0xF4, 0x54, 0x7C, 0xC6, 0xD2, 0xAF, + 0x54, 0x80, 0x42, 0x07, 0x22, 0x78, 0x88, 0xA6, + 0x81, 0x74, 0x03, 0x60, 0x06, 0xFF, 0x08, 0x76, + 0xFF, 0xDF, 0xFB, 0x7F, 0x04, 0xE4, 0x78, 0x80, + 0xF6, 0x08, 0xF6, 0x08, 0xDF, 0xFA, 0x78, 0x81, + 0x76, 0x30, 0x90, 0x45, 0xDE, 0x74, 0x01, 0x93, + 0xC0, 0xE0, 0xE4, 0x93, 0xC0, 0xE0, 0x43, 0x89, + 0x01, 0x75, 0x8A, 0x60, 0x75, 0x8C, 0x79, 0xD2, + 0x8C, 0xD2, 0xAF, 0x22, 0x03, 0xEF, 0xD3, 0x94, + 0x03, 0x40, 0x03, 0x7F, 0xFF, 0x22, 0x74, 0x81, + 0x2F, 0x2F, 0xF8, 0xE6, 0x20, 0xE5, 0xF4, 0xC2, + 0xAF, 0xE6, 0x44, 0x30, 0xF6, 0xD2, 0xAF, 0xAE, + 0x0C, 0xEE, 0xC3, 0x9F, 0x50, 0x21, 0x0E, 0x74, + 0x88, 0x2E, 0xF8, 0xE6, 0xF9, 0x08, 0xE6, 0x18, + 0xBE, 0x03, 0x02, 0x74, 0xFF, 0xFD, 0xED, 0x69, + 0x60, 0x09, 0x09, 0xE7, 0x19, 0x19, 0xF7, 0x09, + 0x09, 0x80, 0xF3, 0x16, 0x16, 0x80, 0xDA, 0xEE, + 0xD3, 0x9F, 0x40, 0x04, 0x05, 0x81, 0x05, 0x81, + 0xEE, 0xD3, 0x9F, 0x40, 0x22, 0x74, 0x88, 0x2E, + 0xF8, 0x08, 0xE6, 0xF9, 0xEE, 0xB5, 0x0C, 0x02, + 0xA9, 0x81, 0x18, 0x06, 0x06, 0xE6, 0xFD, 0xED, + 0x69, 0x60, 0x09, 0x19, 0x19, 0xE7, 0x09, 0x09, + 0xF7, 0x19, 0x80, 0xF3, 0x1E, 0x80, 0xD9, 0xEF, + 0x24, 0x88, 0xF8, 0xE6, 0x04, 0xF8, 0xEF, 0x2F, + 0x04, 0x90, 0x45, 0xDE, 0x93, 0xF6, 0x08, 0xEF, + 0x2F, 0x93, 0xF6, 0x7F, 0x00, 0x22, 0xEF, 0xD3, + 0x94, 0x03, 0x40, 0x03, 0x7F, 0xFF, 0x22, 0xEF, + 0x23, 0x24, 0x81, 0xF8, 0xE6, 0x30, 0xE5, 0xF4, + 0xC2, 0xAF, 0xE6, 0x54, 0x8C, 0xF6, 0xD2, 0xAF, + 0xE5, 0x0C, 0xB5, 0x07, 0x0A, 0x74, 0x88, 0x2F, + 0xF8, 0xE6, 0xF5, 0x81, 0x02, 0x42, 0x4D, 0x50, + 0x2E, 0x74, 0x89, 0x2F, 0xF8, 0xE6, 0xBF, 0x03, + 0x02, 0x74, 0xFF, 0xFD, 0x18, 0xE6, 0xF9, 0x74, + 0x88, 0x2F, 0xF8, 0xFB, 0xE6, 0xFC, 0xE9, 0x6C, + 0x60, 0x08, 0xA8, 0x05, 0xE7, 0xF6, 0x1D, 0x19, + 0x80, 0xF4, 0xA8, 0x03, 0xA6, 0x05, 0x1F, 0xE5, + 0x0C, 0xB5, 0x07, 0xE3, 0x7F, 0x00, 0x22, 0x74, + 0x89, 0x2F, 0xF8, 0xE6, 0xFD, 0x18, 0x86, 0x01, + 0x0F, 0x74, 0x88, 0x2F, 0xF8, 0xA6, 0x01, 0x08, + 0x86, 0x04, 0xE5, 0x0C, 0xB5, 0x07, 0x02, 0xAC, + 0x81, 0xED, 0x6C, 0x60, 0x08, 0x0D, 0x09, 0xA8, + 0x05, 0xE6, 0xF7, 0x80, 0xF4, 0xE5, 0x0C, 0xB5, + 0x07, 0xDE, 0x89, 0x81, 0x7F, 0x00, 0x22, 0xEF, + 0xD3, 0x94, 0x03, 0x40, 0x03, 0x7F, 0xFF, 0x22, + 0xEF, 0x23, 0x24, 0x81, 0xF8, 0xC2, 0xAF, 0xE6, + 0x30, 0xE5, 0x05, 0x30, 0xE0, 0x02, 0xD2, 0xE4, + 0xD2, 0xE2, 0xC6, 0xD2, 0xAF, 0x7F, 0x00, 0x30, + 0xE2, 0x01, 0x0F, 0x02, 0x42, 0x4C, 0x8F, 0xF0, + 0xE4, 0xFF, 0xFE, 0xE5, 0x0C, 0x23, 0x24, 0x80, + 0xF8, 0xC2, 0xA9, 0x30, 0xF7, 0x0D, 0x7F, 0x08, + 0xE6, 0x60, 0x0B, 0x2D, 0xF6, 0x60, 0x30, 0x50, + 0x2E, 0x80, 0x07, 0x30, 0xF1, 0x06, 0xED, 0xF6, + 0x60, 0x25, 0x7E, 0x02, 0x08, 0x30, 0xF0, 0x10, + 0xC2, 0xAF, 0xE6, 0x10, 0xE7, 0x23, 0x0E, 0x30, + 0xE2, 0x0C, 0xD2, 0xAF, 0x7F, 0x04, 0x80, 0x12, + 0xC2, 0xAF, 0xE6, 0x10, 0xE7, 0x13, 0x54, 0xEC, + 0x4E, 0xF6, 0xD2, 0xAF, 0x02, 0x42, 0x4D, 0x7F, + 0x08, 0x08, 0xEF, 0x44, 0x83, 0xF4, 0xC2, 0xAF, + 0x56, 0xC6, 0xD2, 0xAF, 0x54, 0x80, 0x4F, 0xFF, + 0x22, 0xC5, 0xF0, 0xF8, 0xA3, 0xE0, 0x28, 0xF0, + 0xC5, 0xF0, 0xF8, 0xE5, 0x82, 0x15, 0x82, 0x70, + 0x02, 0x15, 0x83, 0xE0, 0x38, 0xF0, 0x22, 0xEF, + 0x5B, 0xFF, 0xEE, 0x5A, 0xFE, 0xED, 0x59, 0xFD, + 0xEC, 0x58, 0xFC, 0x22, 0xEF, 0x4B, 0xFF, 0xEE, + 0x4A, 0xFE, 0xED, 0x49, 0xFD, 0xEC, 0x48, 0xFC, + 0x22, 0xE0, 0xFC, 0xA3, 0xE0, 0xFD, 0xA3, 0xE0, + 0xFE, 0xA3, 0xE0, 0xFF, 0x22, 0xE2, 0xFC, 0x08, + 0xE2, 0xFD, 0x08, 0xE2, 0xFE, 0x08, 0xE2, 0xFF, + 0x22, 0xE2, 0xFB, 0x08, 0xE2, 0xF9, 0x08, 0xE2, + 0xFA, 0x08, 0xE2, 0xCB, 0xF8, 0x22, 0xEC, 0xF2, + 0x08, 0xED, 0xF2, 0x08, 0xEE, 0xF2, 0x08, 0xEF, + 0xF2, 0x22, 0xA4, 0x25, 0x82, 0xF5, 0x82, 0xE5, + 0xF0, 0x35, 0x83, 0xF5, 0x83, 0x22, 0xE0, 0xFB, + 0xA3, 0xE0, 0xFA, 0xA3, 0xE0, 0xF9, 0x22, 0xEB, + 0xF0, 0xA3, 0xEA, 0xF0, 0xA3, 0xE9, 0xF0, 0x22, + 0xD0, 0x83, 0xD0, 0x82, 0xF8, 0xE4, 0x93, 0x70, + 0x12, 0x74, 0x01, 0x93, 0x70, 0x0D, 0xA3, 0xA3, + 0x93, 0xF8, 0x74, 0x01, 0x93, 0xF5, 0x82, 0x88, + 0x83, 0xE4, 0x73, 0x74, 0x02, 0x93, 0x68, 0x60, + 0xEF, 0xA3, 0xA3, 0xA3, 0x80, 0xDF, 0x02, 0x45, + 0x8C, 0x02, 0x42, 0xDD, 0xE4, 0x93, 0xA3, 0xF8, + 0xE4, 0x93, 0xA3, 0x40, 0x03, 0xF6, 0x80, 0x01, + 0xF2, 0x08, 0xDF, 0xF4, 0x80, 0x29, 0xE4, 0x93, + 0xA3, 0xF8, 0x54, 0x07, 0x24, 0x0C, 0xC8, 0xC3, + 0x33, 0xC4, 0x54, 0x0F, 0x44, 0x20, 0xC8, 0x83, + 0x40, 0x04, 0xF4, 0x56, 0x80, 0x01, 0x46, 0xF6, + 0xDF, 0xE4, 0x80, 0x0B, 0x01, 0x02, 0x04, 0x08, + 0x10, 0x20, 0x40, 0x80, 0x90, 0x45, 0xD1, 0xE4, + 0x7E, 0x01, 0x93, 0x60, 0xBC, 0xA3, 0xFF, 0x54, + 0x3F, 0x30, 0xE5, 0x09, 0x54, 0x1F, 0xFE, 0xE4, + 0x93, 0xA3, 0x60, 0x01, 0x0E, 0xCF, 0x54, 0xC0, + 0x25, 0xE0, 0x60, 0xA8, 0x40, 0xB8, 0xE4, 0x93, + 0xA3, 0xFA, 0xE4, 0x93, 0xA3, 0xF8, 0xE4, 0x93, + 0xA3, 0xC8, 0xC5, 0x82, 0xC8, 0xCA, 0xC5, 0x83, + 0xCA, 0xF0, 0xA3, 0xC8, 0xC5, 0x82, 0xC8, 0xCA, + 0xC5, 0x83, 0xCA, 0xDF, 0xE9, 0xDE, 0xE7, 0x80, + 0xBE, 0x00, 0x41, 0x82, 0x09, 0x00, 0x41, 0x82, + 0x0A, 0x00, 0x41, 0x82, 0x17, 0x00, 0x59, 0xE2, + 0x5C, 0x24, 0x5E, 0x5D, 0x5F, 0xA1, 0xC0, 0xE0, + 0xC0, 0xF0, 0xC0, 0x83, 0xC0, 0x82, 0xC0, 0xD0, + 0x75, 0xD0, 0x00, 0xC0, 0x00, 0xC0, 0x01, 0xC0, + 0x02, 0xC0, 0x03, 0xC0, 0x04, 0xC0, 0x05, 0xC0, + 0x06, 0xC0, 0x07, 0x90, 0x01, 0xC4, 0x74, 0xE6, + 0xF0, 0x74, 0x45, 0xA3, 0xF0, 0xD1, 0x35, 0x74, + 0xE6, 0x04, 0x90, 0x01, 0xC4, 0xF0, 0x74, 0x45, + 0xA3, 0xF0, 0xD0, 0x07, 0xD0, 0x06, 0xD0, 0x05, + 0xD0, 0x04, 0xD0, 0x03, 0xD0, 0x02, 0xD0, 0x01, + 0xD0, 0x00, 0xD0, 0xD0, 0xD0, 0x82, 0xD0, 0x83, + 0xD0, 0xF0, 0xD0, 0xE0, 0x32, 0x90, 0x00, 0x54, + 0xE0, 0x55, 0x35, 0xF5, 0x39, 0xA3, 0xE0, 0x55, + 0x36, 0xF5, 0x3A, 0xA3, 0xE0, 0x55, 0x37, 0xF5, + 0x3B, 0xA3, 0xE0, 0x55, 0x38, 0xF5, 0x3C, 0xAD, + 0x39, 0x7F, 0x54, 0x12, 0x32, 0x1E, 0xAD, 0x3A, + 0x7F, 0x55, 0x12, 0x32, 0x1E, 0xAD, 0x3B, 0x7F, + 0x56, 0x12, 0x32, 0x1E, 0xAD, 0x3C, 0x7F, 0x57, + 0x12, 0x32, 0x1E, 0x53, 0x91, 0xEF, 0x22, 0xC0, + 0xE0, 0xC0, 0xF0, 0xC0, 0x83, 0xC0, 0x82, 0xC0, + 0xD0, 0x75, 0xD0, 0x00, 0xC0, 0x00, 0xC0, 0x01, + 0xC0, 0x02, 0xC0, 0x03, 0xC0, 0x04, 0xC0, 0x05, + 0xC0, 0x06, 0xC0, 0x07, 0x90, 0x01, 0xC4, 0x74, + 0x6F, 0xF0, 0x74, 0x46, 0xA3, 0xF0, 0x12, 0x6C, + 0x78, 0xE5, 0x41, 0x30, 0xE4, 0x04, 0x7F, 0x02, + 0x91, 0x27, 0xE5, 0x41, 0x30, 0xE6, 0x03, 0x12, + 0x6C, 0xD5, 0xE5, 0x43, 0x30, 0xE0, 0x03, 0x12, + 0x51, 0xC2, 0xE5, 0x43, 0x30, 0xE1, 0x03, 0x12, + 0x4D, 0x0C, 0xE5, 0x43, 0x30, 0xE2, 0x03, 0x12, + 0x4C, 0xC1, 0xE5, 0x43, 0x30, 0xE3, 0x03, 0x12, + 0x6C, 0xE2, 0xE5, 0x43, 0x30, 0xE4, 0x03, 0x12, + 0x6D, 0x04, 0xE5, 0x43, 0x30, 0xE5, 0x03, 0x12, + 0x6D, 0x33, 0xE5, 0x43, 0x30, 0xE6, 0x02, 0xF1, + 0x0F, 0xE5, 0x44, 0x30, 0xE1, 0x03, 0x12, 0x51, + 0x7F, 0x74, 0x6F, 0x04, 0x90, 0x01, 0xC4, 0xF0, + 0x74, 0x46, 0xA3, 0xF0, 0xD0, 0x07, 0xD0, 0x06, + 0xD0, 0x05, 0xD0, 0x04, 0xD0, 0x03, 0xD0, 0x02, + 0xD0, 0x01, 0xD0, 0x00, 0xD0, 0xD0, 0xD0, 0x82, + 0xD0, 0x83, 0xD0, 0xF0, 0xD0, 0xE0, 0x32, 0x90, + 0x80, 0xDE, 0xE0, 0xB4, 0x01, 0x13, 0x90, 0x81, + 0x27, 0xE0, 0x60, 0x0D, 0x90, 0x81, 0x2B, 0xE0, + 0x54, 0xFE, 0xF0, 0x54, 0x07, 0x70, 0x02, 0xF1, + 0x2A, 0x22, 0x90, 0x81, 0x1F, 0xE0, 0x90, 0x81, + 0x29, 0x30, 0xE0, 0x05, 0xE0, 0xFF, 0x02, 0x74, + 0x8F, 0xE0, 0xFF, 0x7D, 0x01, 0xD3, 0x10, 0xAF, + 0x01, 0xC3, 0xC0, 0xD0, 0x90, 0x82, 0x13, 0xED, + 0xF0, 0x90, 0x81, 0x2A, 0xE0, 0x90, 0x82, 0x14, + 0xF0, 0x90, 0x81, 0x24, 0xE0, 0xFE, 0xC4, 0x13, + 0x13, 0x54, 0x03, 0x30, 0xE0, 0x03, 0x02, 0x48, + 0xA0, 0xEE, 0xC4, 0x13, 0x13, 0x13, 0x54, 0x01, + 0x30, 0xE0, 0x03, 0x02, 0x48, 0xA0, 0x90, 0x82, + 0x14, 0xE0, 0xFE, 0x6F, 0x70, 0x03, 0x02, 0x48, + 0xA0, 0xEF, 0x70, 0x03, 0x02, 0x48, 0x17, 0x24, + 0xFE, 0x70, 0x03, 0x02, 0x48, 0x50, 0x24, 0xFE, + 0x60, 0x51, 0x24, 0xFC, 0x70, 0x03, 0x02, 0x48, + 0x8B, 0x24, 0xFC, 0x60, 0x03, 0x02, 0x48, 0xA0, + 0xEE, 0xB4, 0x0E, 0x03, 0x12, 0x49, 0x5E, 0x90, + 0x82, 0x14, 0xE0, 0x70, 0x05, 0x7F, 0x01, 0x12, + 0x49, 0x93, 0x90, 0x82, 0x14, 0xE0, 0xB4, 0x06, + 0x03, 0x12, 0x49, 0x34, 0x90, 0x82, 0x14, 0xE0, + 0xB4, 0x04, 0x0F, 0x90, 0x82, 0x13, 0xE0, 0xFF, + 0x60, 0x05, 0x12, 0x73, 0x75, 0x80, 0x03, 0x12, + 0x66, 0x26, 0x90, 0x82, 0x14, 0xE0, 0x64, 0x08, + 0x60, 0x03, 0x02, 0x48, 0xA0, 0x12, 0x73, 0xD3, + 0x02, 0x48, 0xA0, 0x90, 0x82, 0x14, 0xE0, 0x70, + 0x05, 0x7F, 0x01, 0x12, 0x49, 0x93, 0x90, 0x82, + 0x14, 0xE0, 0xB4, 0x06, 0x03, 0x12, 0x49, 0x34, + 0x90, 0x82, 0x14, 0xE0, 0xB4, 0x0E, 0x09, 0x12, + 0x48, 0xA5, 0xBF, 0x01, 0x03, 0x12, 0x49, 0x5E, + 0x90, 0x82, 0x14, 0xE0, 0x64, 0x0C, 0x60, 0x02, + 0x01, 0xA0, 0x11, 0xA5, 0xEF, 0x64, 0x01, 0x60, + 0x02, 0x01, 0xA0, 0x11, 0xFA, 0x01, 0xA0, 0x90, + 0x82, 0x14, 0xE0, 0xB4, 0x0E, 0x07, 0x11, 0xA5, + 0xBF, 0x01, 0x02, 0x31, 0x5E, 0x90, 0x82, 0x14, + 0xE0, 0xB4, 0x06, 0x02, 0x31, 0x34, 0x90, 0x82, + 0x14, 0xE0, 0xB4, 0x0C, 0x07, 0x11, 0xA5, 0xBF, + 0x01, 0x02, 0x11, 0xFA, 0x90, 0x82, 0x14, 0xE0, + 0x64, 0x04, 0x70, 0x5C, 0x12, 0x72, 0xF5, 0xEF, + 0x64, 0x01, 0x70, 0x54, 0x31, 0xBE, 0x80, 0x50, + 0x90, 0x82, 0x14, 0xE0, 0xB4, 0x0E, 0x07, 0x11, + 0xA5, 0xBF, 0x01, 0x02, 0x31, 0x5E, 0x90, 0x82, + 0x14, 0xE0, 0xB4, 0x06, 0x02, 0x31, 0x34, 0x90, + 0x82, 0x14, 0xE0, 0xB4, 0x0C, 0x07, 0x11, 0xA5, + 0xBF, 0x01, 0x02, 0x11, 0xFA, 0x90, 0x82, 0x14, + 0xE0, 0x70, 0x04, 0x7F, 0x01, 0x31, 0x93, 0x90, + 0x82, 0x14, 0xE0, 0xB4, 0x04, 0x1A, 0x12, 0x73, + 0xBB, 0x80, 0x15, 0x90, 0x82, 0x14, 0xE0, 0xB4, + 0x0C, 0x0E, 0x90, 0x81, 0x25, 0xE0, 0xFF, 0x13, + 0x13, 0x54, 0x3F, 0x30, 0xE0, 0x02, 0x31, 0xB1, + 0xD0, 0xD0, 0x92, 0xAF, 0x22, 0xD1, 0xAB, 0xEF, + 0x64, 0x01, 0x60, 0x08, 0x90, 0x01, 0xB8, 0x74, + 0x01, 0xF0, 0x80, 0x3D, 0x90, 0x81, 0x24, 0xE0, + 0xFF, 0x13, 0x13, 0x13, 0x54, 0x1F, 0x30, 0xE0, + 0x08, 0x90, 0x01, 0xB8, 0x74, 0x02, 0xF0, 0x80, + 0x28, 0xEF, 0xC4, 0x54, 0x0F, 0x30, 0xE0, 0x08, + 0x90, 0x01, 0xB8, 0x74, 0x04, 0xF0, 0x80, 0x19, + 0x90, 0x81, 0x29, 0xE0, 0xD3, 0x94, 0x04, 0x40, + 0x08, 0x90, 0x01, 0xB8, 0x74, 0x08, 0xF0, 0x80, + 0x08, 0x90, 0x01, 0xB8, 0xE4, 0xF0, 0x7F, 0x01, + 0x22, 0x90, 0x01, 0xB9, 0x74, 0x02, 0xF0, 0x7F, + 0x00, 0x22, 0x90, 0x80, 0xDE, 0xE0, 0x64, 0x01, + 0x70, 0x31, 0x90, 0x81, 0x25, 0xE0, 0x54, 0xFD, + 0xF0, 0x90, 0x05, 0x22, 0x74, 0x6F, 0xF0, 0x7F, + 0x01, 0xF1, 0x0D, 0xBF, 0x01, 0x12, 0x90, 0x81, + 0x24, 0xE0, 0x44, 0x80, 0xF0, 0x90, 0x81, 0x2A, + 0x74, 0x0E, 0xF0, 0x90, 0x81, 0x23, 0xF0, 0x22, + 0x90, 0x01, 0xB9, 0x74, 0x01, 0xF0, 0x90, 0x01, + 0xB8, 0x04, 0xF0, 0x22, 0x90, 0x81, 0x25, 0xE0, + 0x90, 0x06, 0x04, 0x20, 0xE0, 0x0C, 0xE0, 0x44, + 0x40, 0xF0, 0x90, 0x81, 0x2A, 0x74, 0x04, 0xF0, + 0x80, 0x0E, 0xE0, 0x54, 0x7F, 0xF0, 0x90, 0x81, + 0x2A, 0x74, 0x0C, 0xF0, 0x90, 0x81, 0x23, 0xF0, + 0x90, 0x05, 0x22, 0xE4, 0xF0, 0x22, 0x90, 0x81, + 0x25, 0xE0, 0xC3, 0x13, 0x20, 0xE0, 0x08, 0x90, + 0x81, 0x2A, 0x74, 0x0C, 0xF0, 0x80, 0x1E, 0x90, + 0x06, 0x04, 0xE0, 0x44, 0x40, 0xF0, 0xE0, 0x44, + 0x80, 0xF0, 0x90, 0x81, 0x2A, 0x74, 0x04, 0xF0, + 0x90, 0x05, 0x27, 0xE0, 0x44, 0x80, 0xF0, 0x90, + 0x81, 0x23, 0x74, 0x04, 0xF0, 0x90, 0x05, 0x22, + 0xE4, 0xF0, 0x22, 0x90, 0x82, 0x15, 0xEF, 0xF0, + 0x12, 0x54, 0x65, 0x90, 0x82, 0x15, 0xE0, 0x60, + 0x05, 0x90, 0x05, 0x22, 0xE4, 0xF0, 0x90, 0x81, + 0x2A, 0x74, 0x04, 0xF0, 0x90, 0x81, 0x23, 0xF0, + 0x22, 0x31, 0xE3, 0x90, 0x81, 0x2A, 0x74, 0x08, + 0xF0, 0x90, 0x81, 0x23, 0xF0, 0x22, 0x90, 0x05, + 0x22, 0x74, 0xFF, 0xF0, 0xF1, 0x3A, 0x90, 0x01, + 0x37, 0x74, 0x02, 0xF0, 0xFD, 0x7F, 0x03, 0x51, + 0x57, 0x31, 0xE3, 0xE4, 0x90, 0x81, 0x2A, 0xF0, + 0x90, 0x81, 0x23, 0xF0, 0x22, 0x90, 0x05, 0x22, + 0x74, 0xFF, 0xF0, 0xF1, 0x3A, 0x90, 0x85, 0xBB, + 0x12, 0x20, 0xDA, 0xCC, 0xF0, 0x00, 0xC0, 0x7F, + 0x8C, 0x7E, 0x08, 0x12, 0x2E, 0xA2, 0x90, 0x85, + 0xBB, 0x12, 0x20, 0xDA, 0x00, 0x00, 0x00, 0x14, + 0x7F, 0x70, 0x7E, 0x0E, 0x12, 0x2E, 0xA2, 0x90, + 0x81, 0xF9, 0x12, 0x20, 0xDA, 0x00, 0x00, 0x00, + 0x00, 0xE4, 0xFD, 0xFF, 0x12, 0x55, 0x1C, 0x7F, + 0x7C, 0x7E, 0x08, 0x12, 0x2D, 0x5C, 0xEC, 0x44, + 0x80, 0xFC, 0x90, 0x82, 0x05, 0x12, 0x20, 0xCE, + 0x90, 0x82, 0x05, 0x12, 0x44, 0xD9, 0x90, 0x85, + 0xBB, 0x12, 0x20, 0xCE, 0x7F, 0x7C, 0x7E, 0x08, + 0x12, 0x2E, 0xA2, 0x90, 0x01, 0x00, 0x74, 0x3F, + 0xF0, 0xA3, 0xE0, 0x54, 0xFD, 0xF0, 0x90, 0x05, + 0x53, 0xE0, 0x44, 0x20, 0xF0, 0x22, 0x90, 0x01, + 0x34, 0x74, 0x40, 0xF0, 0xFD, 0xE4, 0xFF, 0x74, + 0x3D, 0x2F, 0xF8, 0xE6, 0x4D, 0xFE, 0xF6, 0x74, + 0x30, 0x2F, 0xF5, 0x82, 0xE4, 0x34, 0x01, 0xF5, + 0x83, 0xEE, 0xF0, 0x22, 0xD3, 0x10, 0xAF, 0x01, + 0xC3, 0xC0, 0xD0, 0xE4, 0x90, 0x81, 0xCB, 0xF0, + 0x12, 0x1F, 0xA4, 0xFF, 0x54, 0x01, 0xFE, 0x90, + 0x81, 0x1F, 0xE0, 0x54, 0xFE, 0x4E, 0xFE, 0xF0, + 0xEF, 0x54, 0x02, 0xFF, 0xEE, 0x54, 0xFD, 0x4F, + 0xFF, 0xF0, 0x12, 0x1F, 0xA4, 0xFE, 0x54, 0x04, + 0xFD, 0xEF, 0x54, 0xFB, 0x4D, 0xFF, 0x90, 0x81, + 0x1F, 0xF0, 0xEE, 0x54, 0x08, 0xFE, 0xEF, 0x54, + 0xF7, 0x4E, 0xFF, 0xF0, 0x12, 0x1F, 0xA4, 0xFE, + 0x54, 0x10, 0xFD, 0xEF, 0x54, 0xEF, 0x4D, 0xFF, + 0x90, 0x81, 0x1F, 0xF0, 0xEE, 0x54, 0x20, 0xFE, + 0xEF, 0x54, 0xDF, 0x4E, 0xF0, 0x12, 0x1F, 0xA4, + 0xC3, 0x13, 0x20, 0xE0, 0x02, 0x61, 0x5E, 0x90, + 0x81, 0x1F, 0xE0, 0xFF, 0x30, 0xE0, 0x6D, 0x90, + 0x81, 0xCB, 0x74, 0x21, 0xF0, 0xEF, 0x13, 0x13, + 0x54, 0x3F, 0x30, 0xE0, 0x0B, 0x51, 0x4E, 0x90, + 0x81, 0xCB, 0xE0, 0x44, 0x08, 0xF0, 0x80, 0x0C, + 0xE4, 0x90, 0x81, 0x20, 0xF0, 0xA3, 0xF0, 0x7D, + 0x40, 0xFF, 0x91, 0x26, 0x90, 0x81, 0x1F, 0xE0, + 0xFD, 0x13, 0x13, 0x13, 0x54, 0x1F, 0x30, 0xE0, + 0x07, 0x90, 0x81, 0xCB, 0xE0, 0x44, 0x12, 0xF0, + 0xED, 0xC4, 0x54, 0x0F, 0x30, 0xE0, 0x07, 0x90, + 0x81, 0xCB, 0xE0, 0x44, 0x14, 0xF0, 0x90, 0x81, + 0x1F, 0xE0, 0xC4, 0x13, 0x54, 0x07, 0x30, 0xE0, + 0x07, 0x90, 0x81, 0xCB, 0xE0, 0x44, 0x80, 0xF0, + 0x90, 0x81, 0xCB, 0xE0, 0x90, 0x05, 0x27, 0xF0, + 0x90, 0x81, 0x22, 0xE0, 0x60, 0x02, 0x81, 0x17, + 0x7F, 0x01, 0x80, 0x15, 0x90, 0x81, 0xCB, 0x74, + 0x01, 0xF0, 0x90, 0x05, 0x27, 0xF0, 0x90, 0x81, + 0x22, 0xE0, 0x64, 0x04, 0x60, 0x02, 0x81, 0x17, + 0xFF, 0x12, 0x53, 0x0E, 0x81, 0x17, 0x90, 0x81, + 0x1F, 0xE0, 0xFF, 0x20, 0xE0, 0x02, 0x61, 0xE7, + 0x90, 0x81, 0xCB, 0x74, 0x31, 0xF0, 0xEF, 0x13, + 0x13, 0x54, 0x3F, 0x30, 0xE0, 0x0B, 0x51, 0x4E, + 0x90, 0x81, 0xCB, 0xE0, 0x44, 0x08, 0xF0, 0x80, + 0x06, 0x7D, 0x40, 0xE4, 0xFF, 0x91, 0x26, 0x90, + 0x81, 0x1F, 0xE0, 0xFD, 0x13, 0x13, 0x13, 0x54, + 0x1F, 0x30, 0xE0, 0x07, 0x90, 0x81, 0xCB, 0xE0, + 0x44, 0x02, 0xF0, 0xED, 0xC4, 0x54, 0x0F, 0x30, + 0xE0, 0x07, 0x90, 0x81, 0xCB, 0xE0, 0x44, 0x04, + 0xF0, 0x90, 0x81, 0xCB, 0xE0, 0x90, 0x05, 0x27, + 0xF0, 0x90, 0x81, 0x23, 0xE0, 0x64, 0x02, 0x70, + 0x1D, 0xFD, 0x7F, 0x04, 0x12, 0x47, 0x3D, 0x12, + 0x51, 0x73, 0xBF, 0x01, 0x09, 0x90, 0x81, 0x29, + 0xE0, 0xFF, 0x7D, 0x01, 0x80, 0x03, 0xE4, 0xFD, + 0xFF, 0x12, 0x47, 0x3D, 0x80, 0x41, 0x90, 0x81, + 0x2A, 0xE0, 0x90, 0x81, 0x23, 0xF0, 0x90, 0x05, + 0x27, 0xE0, 0x44, 0x40, 0xF0, 0x80, 0x30, 0x90, + 0x81, 0xCB, 0x74, 0x01, 0xF0, 0x90, 0x05, 0x27, + 0xF0, 0x90, 0x81, 0x23, 0xE0, 0xB4, 0x02, 0x06, + 0x7D, 0x01, 0x7F, 0x04, 0x80, 0x0B, 0x90, 0x81, + 0x23, 0xE0, 0xB4, 0x08, 0x07, 0x7D, 0x01, 0x7F, + 0x0C, 0x12, 0x47, 0x3D, 0xD1, 0x34, 0x90, 0x81, + 0x29, 0x12, 0x47, 0x39, 0x12, 0x5A, 0xA7, 0xD0, + 0xD0, 0x92, 0xAF, 0x22, 0x7D, 0x02, 0x7F, 0x02, + 0x91, 0x26, 0x7D, 0x01, 0x7F, 0x02, 0x74, 0x3D, + 0x2F, 0xF8, 0xE6, 0xFE, 0xED, 0xF4, 0x5E, 0xFE, + 0xF6, 0x74, 0x30, 0x2F, 0xF5, 0x82, 0xE4, 0x34, + 0x01, 0xF5, 0x83, 0xEE, 0xF0, 0x22, 0xEF, 0x70, + 0x37, 0x7D, 0x78, 0x7F, 0x02, 0x91, 0x26, 0x7D, + 0x02, 0x7F, 0x03, 0x91, 0x26, 0x7D, 0xC8, 0x7F, + 0x02, 0x12, 0x71, 0x8F, 0x90, 0x01, 0x57, 0xE4, + 0xF0, 0x90, 0x01, 0x3C, 0x74, 0x02, 0xF0, 0x7D, + 0x01, 0x7F, 0x0C, 0x12, 0x47, 0x3D, 0x90, 0x81, + 0x24, 0xE0, 0x54, 0xF7, 0xF0, 0x54, 0xEF, 0xF0, + 0x90, 0x06, 0x0A, 0xE0, 0x54, 0xF8, 0xF0, 0x22, + 0x90, 0x01, 0x36, 0x74, 0x78, 0xF0, 0xA3, 0x74, + 0x02, 0xF0, 0x7D, 0x78, 0xFF, 0x51, 0x57, 0x7D, + 0x02, 0x7F, 0x03, 0x51, 0x57, 0x90, 0x06, 0x0A, + 0xE0, 0x44, 0x07, 0xF0, 0x90, 0x81, 0x32, 0xA3, + 0xE0, 0x90, 0x05, 0x58, 0xF0, 0x90, 0x80, 0xDE, + 0xE0, 0xB4, 0x01, 0x15, 0x90, 0x81, 0x25, 0xE0, + 0x54, 0xFB, 0xF0, 0x90, 0x81, 0x2A, 0xE0, 0x20, + 0xE2, 0x0E, 0x7D, 0x01, 0x7F, 0x04, 0x02, 0x47, + 0x3D, 0x90, 0x81, 0x25, 0xE0, 0x44, 0x04, 0xF0, + 0x22, 0x90, 0x81, 0x1F, 0xE0, 0xFF, 0x30, 0xE0, + 0x08, 0x90, 0x81, 0x23, 0xE0, 0x64, 0x02, 0x60, + 0x3A, 0x90, 0x81, 0x27, 0xE0, 0x70, 0x04, 0xEF, + 0x30, 0xE0, 0x0A, 0x90, 0x81, 0x2A, 0xE0, 0x64, + 0x02, 0x60, 0x28, 0xB1, 0x83, 0x90, 0x81, 0x25, + 0xE0, 0x13, 0x13, 0x13, 0x54, 0x1F, 0x30, 0xE0, + 0x14, 0x90, 0x81, 0x2D, 0xE0, 0xFF, 0xA3, 0xE0, + 0x6F, 0x70, 0x0A, 0xF1, 0xCD, 0x91, 0x1C, 0x90, + 0x81, 0x2E, 0xE0, 0x14, 0xF0, 0x90, 0x01, 0xE6, + 0xE0, 0x04, 0xF0, 0x22, 0x90, 0x81, 0x1F, 0xE0, + 0x30, 0xE0, 0x06, 0x90, 0x81, 0x21, 0x74, 0x01, + 0xF0, 0x90, 0x81, 0x27, 0xE0, 0x60, 0x45, 0x90, + 0x81, 0x25, 0xE0, 0xFF, 0x13, 0x13, 0x13, 0x54, + 0x1F, 0x30, 0xE0, 0x12, 0x90, 0x01, 0x3B, 0xE0, + 0x30, 0xE4, 0x0B, 0x91, 0x1C, 0x90, 0x81, 0x2D, + 0xE0, 0x14, 0x90, 0x05, 0x73, 0xF0, 0x90, 0x82, + 0x0B, 0xE4, 0x75, 0xF0, 0x01, 0x12, 0x44, 0xA9, + 0xC3, 0x90, 0x82, 0x0C, 0xE0, 0x94, 0x80, 0x90, + 0x82, 0x0B, 0xE0, 0x64, 0x80, 0x94, 0x80, 0x40, + 0x0B, 0x90, 0x01, 0x98, 0xE0, 0x54, 0xFE, 0xF0, + 0xE0, 0x44, 0x01, 0xF0, 0x12, 0x75, 0xF8, 0xD1, + 0xD6, 0x90, 0x81, 0x3F, 0xE0, 0x30, 0xE0, 0x0C, + 0xE4, 0xF5, 0x1D, 0xA3, 0xF1, 0xFB, 0x90, 0x01, + 0x57, 0x74, 0x05, 0xF0, 0x90, 0x01, 0xBE, 0xE0, + 0x04, 0xF0, 0x22, 0x90, 0x80, 0xDE, 0xE0, 0x64, + 0x01, 0x60, 0x02, 0xC1, 0x23, 0x90, 0x81, 0x27, + 0xE0, 0x70, 0x02, 0xC1, 0x23, 0x90, 0x81, 0x26, + 0xE0, 0xC4, 0x54, 0x0F, 0x64, 0x01, 0x70, 0x22, + 0x90, 0x06, 0xAB, 0xE0, 0x90, 0x81, 0x2E, 0xF0, + 0x90, 0x06, 0xAA, 0xE0, 0x90, 0x81, 0x2D, 0xF0, + 0xA3, 0xE0, 0xFF, 0x70, 0x08, 0x90, 0x81, 0x2D, + 0xE0, 0xFE, 0xFF, 0x80, 0x00, 0x90, 0x81, 0x2E, + 0xEF, 0xF0, 0x90, 0x81, 0x25, 0xE0, 0x44, 0x04, + 0xF0, 0xE4, 0x90, 0x81, 0x30, 0xF0, 0x90, 0x81, + 0x32, 0xA3, 0xE0, 0x90, 0x05, 0x58, 0xF0, 0x90, + 0x01, 0x57, 0xE4, 0xF0, 0x90, 0x01, 0x3C, 0x74, + 0x02, 0xF0, 0x90, 0x81, 0x2B, 0xE0, 0x54, 0xFD, + 0xF0, 0x54, 0xEF, 0xF0, 0x90, 0x81, 0x26, 0xE0, + 0xFF, 0xC4, 0x54, 0x0F, 0x24, 0xFD, 0x50, 0x02, + 0x80, 0x0F, 0x90, 0x81, 0x1F, 0xE0, 0x30, 0xE0, + 0x05, 0x12, 0x6D, 0xF2, 0x80, 0x03, 0x12, 0x6E, + 0xC9, 0x90, 0x81, 0x25, 0xE0, 0x13, 0x13, 0x13, + 0x54, 0x1F, 0x30, 0xE0, 0x0E, 0x90, 0x81, 0x2D, + 0xE0, 0xFF, 0xA3, 0xE0, 0xB5, 0x07, 0x04, 0xF1, + 0xCD, 0x91, 0x22, 0x90, 0x81, 0x1F, 0xE0, 0xC3, + 0x13, 0x20, 0xE0, 0x07, 0x90, 0x81, 0x25, 0xE0, + 0x44, 0x04, 0xF0, 0x22, 0xD1, 0xAB, 0xEF, 0x70, + 0x02, 0xD1, 0x3C, 0x22, 0x90, 0x81, 0x27, 0xE0, + 0x64, 0x01, 0x70, 0x66, 0x90, 0x81, 0x26, 0xE0, + 0x54, 0x0F, 0x60, 0x51, 0x90, 0x81, 0x2A, 0xE0, + 0x70, 0x03, 0xFF, 0x31, 0x93, 0x90, 0x81, 0x2A, + 0xE0, 0x64, 0x0C, 0x60, 0x03, 0x12, 0x66, 0x26, + 0x90, 0x01, 0x5B, 0xE4, 0xF0, 0x90, 0x01, 0x3C, + 0x74, 0x04, 0xF0, 0xD1, 0xAB, 0xEF, 0x64, 0x01, + 0x60, 0x38, 0xE4, 0xF5, 0x1D, 0x90, 0x81, 0x3A, + 0xE0, 0xC3, 0x13, 0x54, 0x7F, 0xF5, 0x1E, 0xE4, + 0xFB, 0xFD, 0x7F, 0x58, 0x7E, 0x01, 0x12, 0x50, + 0x05, 0x90, 0x01, 0x5B, 0x74, 0x05, 0xF0, 0x90, + 0x06, 0x92, 0x74, 0x01, 0xF0, 0x90, 0x81, 0x24, + 0xE0, 0x44, 0x08, 0xF0, 0x22, 0x90, 0x81, 0x2A, + 0xE0, 0x70, 0x07, 0x7D, 0x01, 0x7F, 0x04, 0x12, + 0x47, 0x3D, 0x22, 0x90, 0x04, 0x1A, 0xE0, 0xF4, + 0x60, 0x03, 0x7F, 0x00, 0x22, 0x90, 0x04, 0x1B, + 0xE0, 0x54, 0x07, 0x64, 0x07, 0x7F, 0x01, 0x60, + 0x02, 0x7F, 0x00, 0x22, 0x12, 0x50, 0x60, 0x90, + 0x81, 0x2D, 0xE0, 0x14, 0x90, 0x05, 0x73, 0xF0, + 0x7D, 0x02, 0x7F, 0x02, 0x51, 0x57, 0x90, 0x81, + 0x42, 0xE0, 0x30, 0xE0, 0x2D, 0x90, 0x80, 0xDE, + 0xE0, 0xB4, 0x01, 0x26, 0x90, 0x82, 0x17, 0xE0, + 0x04, 0xF0, 0xE0, 0xB4, 0x0A, 0x0B, 0x90, 0x81, + 0x44, 0xE0, 0x04, 0xF0, 0xE4, 0x90, 0x82, 0x17, + 0xF0, 0x90, 0x81, 0x44, 0xE0, 0xFF, 0x90, 0x81, + 0x43, 0xE0, 0xB5, 0x07, 0x05, 0xE4, 0xA3, 0xF0, + 0xF1, 0x0B, 0x22, 0xE4, 0xFF, 0x8F, 0x53, 0x90, + 0x04, 0x1D, 0xE0, 0x60, 0x19, 0x90, 0x05, 0x22, + 0xE0, 0xF5, 0x56, 0x74, 0xFF, 0xF0, 0xF1, 0x3A, + 0xBF, 0x01, 0x03, 0x12, 0x74, 0xFB, 0x90, 0x05, + 0x22, 0xE5, 0x56, 0xF0, 0x80, 0x03, 0x12, 0x74, + 0xFB, 0x90, 0x04, 0x1F, 0x74, 0x20, 0xF0, 0x7F, + 0x01, 0x22, 0xE4, 0x90, 0x82, 0x0F, 0xF0, 0xA3, + 0xF0, 0x90, 0x05, 0xF8, 0xE0, 0x70, 0x0F, 0xA3, + 0xE0, 0x70, 0x0B, 0xA3, 0xE0, 0x70, 0x07, 0xA3, + 0xE0, 0x70, 0x03, 0x7F, 0x01, 0x22, 0xD3, 0x90, + 0x82, 0x10, 0xE0, 0x94, 0xE8, 0x90, 0x82, 0x0F, + 0xE0, 0x94, 0x03, 0x40, 0x0A, 0x90, 0x01, 0xC0, + 0xE0, 0x44, 0x20, 0xF0, 0x7F, 0x00, 0x22, 0x7F, + 0x32, 0x7E, 0x00, 0x12, 0x32, 0xAA, 0x90, 0x82, + 0x0F, 0xE4, 0x75, 0xF0, 0x01, 0x12, 0x44, 0xA9, + 0x80, 0xBF, 0x74, 0x1F, 0x2D, 0xF5, 0x82, 0xE4, + 0x34, 0xFC, 0xF5, 0x83, 0xE0, 0x54, 0x3F, 0xF0, + 0xEF, 0x60, 0x1D, 0x74, 0x21, 0x2D, 0xF5, 0x82, + 0xE4, 0x34, 0xFC, 0xF5, 0x83, 0xE0, 0x44, 0x10, + 0xF0, 0x74, 0x1F, 0x2D, 0xF5, 0x82, 0xE4, 0x34, + 0xFC, 0xF5, 0x83, 0xE0, 0x44, 0x80, 0xF0, 0x22, + 0x74, 0x21, 0x2D, 0xF5, 0x82, 0xE4, 0x34, 0xFC, + 0xF5, 0x83, 0xE0, 0x54, 0xEF, 0xF0, 0x74, 0x1F, + 0x2D, 0xF5, 0x82, 0xE4, 0x34, 0xFC, 0xF5, 0x83, + 0xE0, 0x44, 0x40, 0xF0, 0x22, 0xEF, 0x14, 0x90, + 0x05, 0x73, 0xF0, 0x90, 0x01, 0x3F, 0x74, 0x10, + 0xF0, 0xFD, 0x7F, 0x03, 0x74, 0x45, 0x2F, 0xF8, + 0xE6, 0x4D, 0xFE, 0xF6, 0x74, 0x38, 0x2F, 0xF5, + 0x82, 0xE4, 0x34, 0x01, 0xF5, 0x83, 0xEE, 0xF0, + 0x22, 0xE0, 0x44, 0x02, 0xF0, 0xE4, 0xF5, 0x1D, + 0x90, 0x81, 0x39, 0xE0, 0xF5, 0x1E, 0xE4, 0xFB, + 0xFD, 0x7F, 0x54, 0x7E, 0x01, 0x8E, 0x19, 0x8F, + 0x1A, 0xE5, 0x1E, 0x54, 0x07, 0xC4, 0x33, 0x54, + 0xE0, 0x85, 0x19, 0x83, 0x85, 0x1A, 0x82, 0xF0, + 0xE5, 0x1D, 0x54, 0x07, 0xC4, 0x33, 0x54, 0xE0, + 0xFF, 0xE5, 0x1E, 0x13, 0x13, 0x13, 0x54, 0x1F, + 0x4F, 0xA3, 0xF0, 0xEB, 0x54, 0x07, 0xC4, 0x33, + 0x54, 0xE0, 0xFF, 0xE5, 0x1D, 0x13, 0x13, 0x13, + 0x54, 0x1F, 0x4F, 0x85, 0x1A, 0x82, 0x85, 0x19, + 0x83, 0xA3, 0xA3, 0xF0, 0xBD, 0x01, 0x0C, 0x85, + 0x1A, 0x82, 0x8E, 0x83, 0xA3, 0xA3, 0xA3, 0x74, + 0x03, 0xF0, 0x22, 0x85, 0x1A, 0x82, 0x85, 0x19, + 0x83, 0xA3, 0xA3, 0xA3, 0x74, 0x01, 0xF0, 0x22, + 0xE4, 0x90, 0x81, 0x4D, 0xF0, 0x90, 0x81, 0x27, + 0xE0, 0x60, 0x58, 0x90, 0x80, 0xDE, 0xE0, 0x64, + 0x01, 0x70, 0x50, 0x90, 0x81, 0x4D, 0x04, 0xF0, + 0xE4, 0x90, 0x81, 0x2E, 0xF0, 0x90, 0x81, 0x1F, + 0xE0, 0x30, 0xE0, 0x15, 0x90, 0x81, 0x23, 0xE0, + 0xB4, 0x02, 0x05, 0xE4, 0x90, 0x81, 0x4D, 0xF0, + 0x31, 0x73, 0xEF, 0x70, 0x04, 0x90, 0x81, 0x4D, + 0xF0, 0x90, 0x81, 0x4D, 0xE0, 0x60, 0x24, 0x90, + 0x81, 0x2B, 0xE0, 0x44, 0x10, 0xF0, 0xE4, 0xF5, + 0x1D, 0x90, 0x81, 0x2F, 0x12, 0x4F, 0xFB, 0x90, + 0x01, 0x57, 0x74, 0x05, 0xF0, 0x90, 0x81, 0x2A, + 0xE0, 0x20, 0xE2, 0x07, 0x7D, 0x01, 0x7F, 0x04, + 0x12, 0x47, 0x3D, 0x22, 0xE4, 0x90, 0x81, 0x4C, + 0xF0, 0x90, 0x81, 0x27, 0xE0, 0x70, 0x02, 0x21, + 0x72, 0x90, 0x80, 0xDE, 0xE0, 0x64, 0x01, 0x60, + 0x02, 0x21, 0x72, 0x90, 0x81, 0x26, 0xE0, 0xFF, + 0xC4, 0x54, 0x0F, 0x60, 0x22, 0x24, 0xFE, 0x60, + 0x03, 0x04, 0x70, 0x21, 0x90, 0x81, 0x2E, 0xE0, + 0x14, 0xF0, 0xE0, 0xFF, 0x60, 0x06, 0x90, 0x81, + 0x30, 0xE0, 0x60, 0x11, 0xEF, 0x70, 0x08, 0x90, + 0x81, 0x2D, 0xE0, 0xA3, 0xF0, 0x80, 0x00, 0x90, + 0x81, 0x4C, 0x74, 0x01, 0xF0, 0x90, 0x81, 0x1F, + 0xE0, 0x30, 0xE0, 0x15, 0x90, 0x81, 0x23, 0xE0, + 0xB4, 0x02, 0x05, 0xE4, 0x90, 0x81, 0x4C, 0xF0, + 0x31, 0x73, 0xEF, 0x70, 0x04, 0x90, 0x81, 0x4C, + 0xF0, 0x90, 0x81, 0x4C, 0xE0, 0x60, 0x43, 0x90, + 0x81, 0x2B, 0xE0, 0x44, 0x10, 0xF0, 0x90, 0x81, + 0x30, 0xE0, 0x60, 0x03, 0xB4, 0x01, 0x09, 0xE4, + 0xF5, 0x1D, 0x90, 0x81, 0x30, 0xE0, 0x80, 0x0D, + 0xE4, 0xF5, 0x1D, 0x90, 0x81, 0x30, 0xE0, 0x75, + 0xF0, 0x03, 0xA4, 0x24, 0xFE, 0xFF, 0x90, 0x81, + 0x2F, 0xE0, 0x2F, 0x12, 0x4F, 0xFC, 0x90, 0x01, + 0x57, 0x74, 0x05, 0xF0, 0x90, 0x81, 0x2A, 0xE0, + 0x20, 0xE2, 0x07, 0x7D, 0x01, 0x7F, 0x04, 0x12, + 0x47, 0x3D, 0x22, 0x90, 0x05, 0x43, 0xE0, 0x7F, + 0x00, 0x30, 0xE7, 0x02, 0x7F, 0x01, 0x22, 0x90, + 0x81, 0x27, 0xE0, 0x70, 0x07, 0x90, 0x81, 0x1F, + 0xE0, 0x30, 0xE0, 0x11, 0x90, 0x81, 0x1F, 0xE0, + 0x30, 0xE0, 0x07, 0x31, 0x73, 0xBF, 0x01, 0x05, + 0x41, 0x5B, 0x12, 0x4E, 0x3C, 0x22, 0xD3, 0x10, + 0xAF, 0x01, 0xC3, 0xC0, 0xD0, 0x90, 0x81, 0x1E, + 0xE0, 0xB4, 0x01, 0x04, 0x7F, 0x04, 0x80, 0x0B, + 0x31, 0x73, 0xBF, 0x01, 0x04, 0x7F, 0x01, 0x80, + 0x02, 0x7F, 0x02, 0x71, 0x0E, 0xD0, 0xD0, 0x92, + 0xAF, 0x22, 0x90, 0x81, 0x4B, 0xE0, 0x60, 0x0F, + 0xE4, 0xF0, 0x90, 0x05, 0x53, 0xE0, 0x44, 0x02, + 0xF0, 0x90, 0x05, 0xFC, 0xE0, 0x04, 0xF0, 0x90, + 0x81, 0x1F, 0xE0, 0x30, 0xE0, 0x10, 0xA3, 0x74, + 0x01, 0xF0, 0x90, 0x81, 0x1F, 0xE0, 0xFF, 0xC3, + 0x13, 0x30, 0xE0, 0x02, 0x31, 0x9E, 0x11, 0xC4, + 0x90, 0x81, 0x3F, 0xE0, 0x30, 0xE0, 0x07, 0x91, + 0x65, 0x90, 0x05, 0x22, 0xE4, 0xF0, 0x22, 0x90, + 0x81, 0x1F, 0xE0, 0xFF, 0x30, 0xE0, 0x3D, 0x90, + 0x81, 0x23, 0xE0, 0x7E, 0x00, 0xB4, 0x02, 0x02, + 0x7E, 0x01, 0x90, 0x81, 0x22, 0xE0, 0x7D, 0x00, + 0xB4, 0x04, 0x02, 0x7D, 0x01, 0xED, 0x4E, 0x70, + 0x23, 0xEF, 0xC3, 0x13, 0x30, 0xE0, 0x02, 0x21, + 0x9E, 0x51, 0x45, 0x90, 0x81, 0x23, 0xE0, 0xB4, + 0x08, 0x06, 0xE4, 0xFD, 0x7F, 0x0C, 0x80, 0x09, + 0x90, 0x81, 0x23, 0xE0, 0x70, 0x06, 0xFD, 0x7F, + 0x04, 0x12, 0x47, 0x3D, 0x22, 0x90, 0x81, 0x1E, + 0xE0, 0xB4, 0x01, 0x0F, 0x90, 0x81, 0x23, 0xE0, + 0x64, 0x02, 0x60, 0x07, 0x7D, 0x01, 0x7F, 0x02, + 0x12, 0x47, 0x3D, 0x90, 0x81, 0x27, 0xE0, 0x64, + 0x02, 0x60, 0x14, 0x90, 0x81, 0x26, 0xE0, 0x54, + 0x0F, 0x60, 0x0C, 0x12, 0x4E, 0xAB, 0xEF, 0x70, + 0x06, 0xFD, 0x7F, 0x0C, 0x12, 0x47, 0x3D, 0x22, + 0x90, 0x81, 0x1F, 0xE0, 0xFF, 0x30, 0xE0, 0x3F, + 0x90, 0x81, 0x23, 0xE0, 0x7E, 0x00, 0xB4, 0x02, + 0x02, 0x7E, 0x01, 0x90, 0x81, 0x22, 0xE0, 0x7D, + 0x00, 0xB4, 0x04, 0x02, 0x7D, 0x01, 0xED, 0x4E, + 0x70, 0x25, 0xEF, 0xC3, 0x13, 0x30, 0xE0, 0x02, + 0x21, 0x9E, 0x12, 0x74, 0xAC, 0x90, 0x81, 0x23, + 0xE0, 0xB4, 0x0C, 0x06, 0xE4, 0xFD, 0x7F, 0x08, + 0x80, 0x0A, 0x90, 0x81, 0x23, 0xE0, 0xB4, 0x04, + 0x06, 0xE4, 0xFD, 0xFF, 0x12, 0x47, 0x3D, 0x22, + 0xD3, 0x10, 0xAF, 0x01, 0xC3, 0xC0, 0xD0, 0x90, + 0x81, 0xCB, 0x12, 0x45, 0x1F, 0x12, 0x1F, 0xA4, + 0xFF, 0x90, 0x81, 0x1E, 0xF0, 0xBF, 0x01, 0x12, + 0x90, 0x81, 0xCB, 0x12, 0x45, 0x16, 0x90, 0x00, + 0x01, 0x12, 0x1F, 0xBD, 0x64, 0x01, 0x60, 0x21, + 0x80, 0x1D, 0x90, 0x81, 0xCB, 0x12, 0x45, 0x16, + 0x90, 0x00, 0x01, 0x12, 0x1F, 0xBD, 0x64, 0x01, + 0x60, 0x0F, 0x90, 0x81, 0x1F, 0xE0, 0x20, 0xE0, + 0x06, 0xE4, 0xFF, 0x71, 0x0E, 0x80, 0x02, 0x31, + 0x9E, 0xD0, 0xD0, 0x92, 0xAF, 0x22, 0xD3, 0x10, + 0xAF, 0x01, 0xC3, 0xC0, 0xD0, 0x90, 0x81, 0x22, + 0xE0, 0x90, 0x82, 0x16, 0xF0, 0x6F, 0x70, 0x02, + 0x81, 0x04, 0xEF, 0x14, 0x60, 0x3E, 0x14, 0x60, + 0x62, 0x14, 0x70, 0x02, 0x61, 0xB8, 0x14, 0x70, + 0x02, 0x61, 0xDF, 0x24, 0x04, 0x60, 0x02, 0x81, + 0x04, 0x90, 0x82, 0x16, 0xE0, 0xFF, 0xB4, 0x04, + 0x04, 0x91, 0x41, 0x81, 0x04, 0xEF, 0xB4, 0x02, + 0x04, 0x91, 0x50, 0x81, 0x04, 0x90, 0x82, 0x16, + 0xE0, 0xFF, 0xB4, 0x03, 0x04, 0x91, 0x54, 0x81, + 0x04, 0xEF, 0x64, 0x01, 0x60, 0x02, 0x81, 0x04, + 0x91, 0x43, 0x81, 0x04, 0x90, 0x82, 0x16, 0xE0, + 0xFF, 0xB4, 0x04, 0x04, 0x91, 0xF3, 0x81, 0x04, + 0xEF, 0xB4, 0x02, 0x04, 0x91, 0x58, 0x81, 0x04, + 0x90, 0x82, 0x16, 0xE0, 0xFF, 0xB4, 0x03, 0x04, + 0x91, 0xE8, 0x81, 0x04, 0xEF, 0x70, 0x7D, 0x91, + 0x2B, 0x80, 0x79, 0x90, 0x82, 0x16, 0xE0, 0xB4, + 0x04, 0x05, 0x12, 0x74, 0x60, 0x80, 0x6D, 0x90, + 0x82, 0x16, 0xE0, 0xB4, 0x01, 0x04, 0x91, 0x21, + 0x80, 0x62, 0x90, 0x82, 0x16, 0xE0, 0xB4, 0x03, + 0x05, 0x12, 0x74, 0x71, 0x80, 0x56, 0x90, 0x82, + 0x16, 0xE0, 0x70, 0x50, 0x91, 0x1F, 0x80, 0x4C, + 0x90, 0x82, 0x16, 0xE0, 0xFF, 0xB4, 0x04, 0x05, + 0x12, 0x74, 0x4C, 0x80, 0x3F, 0xEF, 0xB4, 0x01, + 0x04, 0x91, 0x34, 0x80, 0x37, 0xEF, 0xB4, 0x02, + 0x04, 0x91, 0xDF, 0x80, 0x2F, 0x90, 0x82, 0x16, + 0xE0, 0x70, 0x29, 0x91, 0x32, 0x80, 0x25, 0x90, + 0x82, 0x16, 0xE0, 0xFF, 0xB4, 0x03, 0x05, 0x12, + 0x74, 0x7B, 0x80, 0x18, 0xEF, 0xB4, 0x01, 0x04, + 0x91, 0x0B, 0x80, 0x10, 0xEF, 0xB4, 0x02, 0x04, + 0xB1, 0x06, 0x80, 0x08, 0x90, 0x82, 0x16, 0xE0, + 0x70, 0x02, 0x91, 0x09, 0xD0, 0xD0, 0x92, 0xAF, + 0x22, 0x91, 0x2B, 0x90, 0x05, 0x22, 0x74, 0x6F, + 0xF0, 0x90, 0x05, 0x27, 0xE0, 0x54, 0xBF, 0xF0, + 0x90, 0x81, 0x22, 0x74, 0x04, 0xF0, 0x22, 0x91, + 0x2B, 0x12, 0x49, 0xDD, 0x90, 0x81, 0x22, 0x74, + 0x02, 0xF0, 0x22, 0x90, 0x81, 0x22, 0x74, 0x01, + 0xF0, 0x22, 0x91, 0x2B, 0x90, 0x05, 0x22, 0x74, + 0xFF, 0xF0, 0x90, 0x81, 0x22, 0x74, 0x03, 0xF0, + 0x22, 0x91, 0xF3, 0x90, 0x05, 0x27, 0xE0, 0x54, + 0xBF, 0xF0, 0xE4, 0x90, 0x81, 0x22, 0xF0, 0x22, + 0x91, 0x58, 0x80, 0xEF, 0x91, 0xE8, 0x80, 0xEB, + 0x91, 0x65, 0x90, 0x05, 0x22, 0xE4, 0xF0, 0x90, + 0x81, 0x22, 0x04, 0xF0, 0x22, 0xD3, 0x10, 0xAF, + 0x01, 0xC3, 0xC0, 0xD0, 0x90, 0x01, 0x01, 0xE0, + 0x44, 0x02, 0xF0, 0x90, 0x01, 0x00, 0x74, 0xFF, + 0xF0, 0x90, 0x06, 0xB7, 0x74, 0x09, 0xF0, 0x90, + 0x06, 0xB4, 0x74, 0x86, 0xF0, 0x7F, 0x7C, 0x7E, + 0x08, 0x12, 0x2D, 0x5C, 0xEC, 0x54, 0x7F, 0xFC, + 0x90, 0x82, 0x01, 0x12, 0x20, 0xCE, 0x90, 0x82, + 0x01, 0x12, 0x44, 0xD9, 0x90, 0x85, 0xBB, 0x12, + 0x20, 0xCE, 0x7F, 0x7C, 0x7E, 0x08, 0x12, 0x2E, + 0xA2, 0x90, 0x85, 0xBB, 0x12, 0x20, 0xDA, 0xCC, + 0xC0, 0x00, 0xC0, 0x7F, 0x8C, 0x7E, 0x08, 0x12, + 0x2E, 0xA2, 0x90, 0x85, 0xBB, 0x12, 0x20, 0xDA, + 0x00, 0xC0, 0x00, 0x14, 0x7F, 0x70, 0x7E, 0x0E, + 0x12, 0x2E, 0xA2, 0x90, 0x81, 0xF9, 0x12, 0x20, + 0xDA, 0x00, 0x03, 0x3E, 0x60, 0xE4, 0xFD, 0xFF, + 0xB1, 0x1C, 0xD0, 0xD0, 0x92, 0xAF, 0x22, 0x91, + 0x65, 0x90, 0x81, 0x22, 0x74, 0x03, 0xF0, 0x22, + 0x90, 0x05, 0x22, 0xE4, 0xF0, 0x90, 0x81, 0x22, + 0x04, 0xF0, 0x22, 0x90, 0x05, 0x22, 0xE4, 0xF0, + 0x90, 0x05, 0x27, 0xE0, 0x44, 0x40, 0xF0, 0x90, + 0x81, 0x22, 0x74, 0x01, 0xF0, 0x22, 0x91, 0x65, + 0x90, 0x05, 0x22, 0x74, 0x6F, 0xF0, 0x90, 0x05, + 0x27, 0xE0, 0x54, 0xBF, 0xF0, 0x90, 0x81, 0x22, + 0x74, 0x04, 0xF0, 0x22, 0xD3, 0x10, 0xAF, 0x01, + 0xC3, 0xC0, 0xD0, 0xC0, 0x07, 0xC0, 0x05, 0x90, + 0x81, 0xF9, 0x12, 0x44, 0xD9, 0x90, 0x81, 0xE5, + 0x12, 0x20, 0xCE, 0xD0, 0x05, 0xD0, 0x07, 0x12, + 0x60, 0xF5, 0xD0, 0xD0, 0x92, 0xAF, 0x22, 0x90, + 0x81, 0xC8, 0x12, 0x45, 0x1F, 0xEF, 0x12, 0x45, + 0x28, 0x55, 0x71, 0x00, 0x55, 0x7A, 0x01, 0x55, + 0x83, 0x02, 0x55, 0x8B, 0x03, 0x55, 0x94, 0x04, + 0x55, 0x9C, 0x20, 0x55, 0xA4, 0x21, 0x55, 0xAD, + 0x23, 0x55, 0xB5, 0x24, 0x55, 0xBE, 0x25, 0x55, + 0xC7, 0x26, 0x55, 0xCF, 0xC0, 0x00, 0x00, 0x55, + 0xD8, 0x90, 0x81, 0xC8, 0x12, 0x45, 0x16, 0x02, + 0x6A, 0xB0, 0x90, 0x81, 0xC8, 0x12, 0x45, 0x16, + 0x02, 0x65, 0x81, 0x90, 0x81, 0xC8, 0x12, 0x45, + 0x16, 0x41, 0xC0, 0x90, 0x81, 0xC8, 0x12, 0x45, + 0x16, 0x02, 0x75, 0xD8, 0x90, 0x81, 0xC8, 0x12, + 0x45, 0x16, 0x80, 0x44, 0x90, 0x81, 0xC8, 0x12, + 0x45, 0x16, 0xC1, 0x4B, 0x90, 0x81, 0xC8, 0x12, + 0x45, 0x16, 0x02, 0x6A, 0xF8, 0x90, 0x81, 0xC8, + 0x12, 0x45, 0x16, 0xE1, 0xE1, 0x90, 0x81, 0xC8, + 0x12, 0x45, 0x16, 0x02, 0x4A, 0x6C, 0x90, 0x81, + 0xC8, 0x12, 0x45, 0x16, 0x02, 0x6B, 0x3E, 0x90, + 0x81, 0xC8, 0x12, 0x45, 0x16, 0x80, 0x3E, 0x90, + 0x81, 0xC8, 0x12, 0x45, 0x16, 0x02, 0x6B, 0x4E, + 0x90, 0x01, 0xC0, 0xE0, 0x44, 0x01, 0xF0, 0x22, + 0x12, 0x5A, 0x4B, 0x12, 0x1F, 0xA4, 0xFF, 0x54, + 0x01, 0xFE, 0x90, 0x81, 0x45, 0xE0, 0x54, 0xFE, + 0x4E, 0xF0, 0xEF, 0xC3, 0x13, 0x30, 0xE0, 0x14, + 0x90, 0x00, 0x01, 0x12, 0x1F, 0xBD, 0x90, 0x81, + 0x46, 0xF0, 0x90, 0x00, 0x02, 0x12, 0x1F, 0xBD, + 0x90, 0x81, 0x47, 0xF0, 0x22, 0x12, 0x1F, 0xA4, + 0xFF, 0x54, 0x01, 0xFE, 0x90, 0x81, 0x3F, 0xE0, + 0x54, 0xFE, 0x4E, 0xF0, 0x90, 0x00, 0x01, 0x12, + 0x1F, 0xBD, 0xFE, 0x90, 0x05, 0x54, 0xE0, 0xC3, + 0x9E, 0x90, 0x81, 0x40, 0xF0, 0xEF, 0x20, 0xE0, + 0x07, 0x91, 0x65, 0x90, 0x05, 0x22, 0xE4, 0xF0, + 0x90, 0x81, 0x3F, 0xE0, 0x54, 0x01, 0x90, 0x01, + 0xBC, 0xF0, 0x90, 0x81, 0x40, 0xE0, 0x90, 0x01, + 0xBD, 0xF0, 0x22, 0x12, 0x1F, 0xA4, 0xFF, 0x54, + 0x7F, 0x90, 0x81, 0x27, 0xF0, 0xEF, 0xC4, 0x13, + 0x13, 0x13, 0x54, 0x01, 0xA3, 0xF0, 0x90, 0x00, + 0x01, 0x12, 0x1F, 0xBD, 0xFF, 0x54, 0xF0, 0xC4, + 0x54, 0x0F, 0xFE, 0x90, 0x81, 0x26, 0xE0, 0x54, + 0xF0, 0x4E, 0xF0, 0x90, 0x00, 0x03, 0x12, 0x1F, + 0xBD, 0x54, 0x01, 0x25, 0xE0, 0xFE, 0x90, 0x81, + 0x24, 0xE0, 0x54, 0xFD, 0x4E, 0xF0, 0xEF, 0x54, + 0x0F, 0xC4, 0x54, 0xF0, 0xFF, 0x90, 0x81, 0x26, + 0xE0, 0x54, 0x0F, 0x4F, 0xF0, 0x90, 0x00, 0x04, + 0x12, 0x1F, 0xBD, 0x90, 0x81, 0x29, 0xF0, 0xD1, + 0xC6, 0x90, 0x01, 0xB9, 0x74, 0x01, 0xF0, 0x90, + 0x01, 0xB8, 0xF0, 0x90, 0x81, 0x27, 0xE0, 0x90, + 0x01, 0xBA, 0xF0, 0x90, 0x81, 0x29, 0xE0, 0x90, + 0x01, 0xBB, 0xF0, 0x90, 0x81, 0x26, 0xE0, 0x54, + 0x0F, 0x90, 0x01, 0xBE, 0xF0, 0x22, 0x90, 0x81, + 0xCB, 0x12, 0x45, 0x1F, 0x12, 0x72, 0xB3, 0x90, + 0x81, 0x27, 0xE0, 0xFF, 0x12, 0x4C, 0x3E, 0x90, + 0x81, 0x27, 0xE0, 0x60, 0x19, 0x90, 0x81, 0xCB, + 0x12, 0x45, 0x16, 0x90, 0x00, 0x01, 0x12, 0x1F, + 0xBD, 0x54, 0x0F, 0xFF, 0x90, 0x00, 0x02, 0x12, + 0x1F, 0xBD, 0xFD, 0x12, 0x72, 0xC4, 0x22, 0xC0, + 0xE0, 0xC0, 0xF0, 0xC0, 0x83, 0xC0, 0x82, 0xC0, + 0xD0, 0x75, 0xD0, 0x00, 0xC0, 0x00, 0xC0, 0x01, + 0xC0, 0x02, 0xC0, 0x03, 0xC0, 0x04, 0xC0, 0x05, + 0xC0, 0x06, 0xC0, 0x07, 0x90, 0x01, 0xC4, 0x74, + 0xF7, 0xF0, 0x74, 0x56, 0xA3, 0xF0, 0x12, 0x6C, + 0xA5, 0xE5, 0x49, 0x30, 0xE1, 0x03, 0x12, 0x6F, + 0x79, 0xE5, 0x49, 0x30, 0xE2, 0x02, 0xF1, 0xA5, + 0xE5, 0x49, 0x30, 0xE3, 0x03, 0x12, 0x6F, 0x8D, + 0xE5, 0x4A, 0x30, 0xE0, 0x03, 0x12, 0x6F, 0xC9, + 0xE5, 0x4A, 0x30, 0xE4, 0x03, 0x12, 0x70, 0x22, + 0xE5, 0x4B, 0x30, 0xE1, 0x02, 0x51, 0x78, 0xE5, + 0x4B, 0x30, 0xE0, 0x02, 0x31, 0xFF, 0xE5, 0x4B, + 0x30, 0xE3, 0x02, 0xF1, 0xE0, 0xE5, 0x4C, 0x30, + 0xE1, 0x05, 0x7F, 0x03, 0x12, 0x44, 0x27, 0xE5, + 0x4C, 0x30, 0xE4, 0x03, 0x12, 0x4E, 0xC4, 0xE5, + 0x4C, 0x30, 0xE5, 0x03, 0x12, 0x70, 0x38, 0xE5, + 0x4C, 0x30, 0xE6, 0x03, 0x12, 0x70, 0xCE, 0x74, + 0xF7, 0x04, 0x90, 0x01, 0xC4, 0xF0, 0x74, 0x56, + 0xA3, 0xF0, 0xD0, 0x07, 0xD0, 0x06, 0xD0, 0x05, + 0xD0, 0x04, 0xD0, 0x03, 0xD0, 0x02, 0xD0, 0x01, + 0xD0, 0x00, 0xD0, 0xD0, 0xD0, 0x82, 0xD0, 0x83, + 0xD0, 0xF0, 0xD0, 0xE0, 0x32, 0x90, 0x81, 0x27, + 0xE0, 0x60, 0x34, 0x90, 0x06, 0x92, 0xE0, 0x30, + 0xE0, 0x23, 0xE4, 0xF5, 0x1D, 0x90, 0x81, 0x3A, + 0xE0, 0xC3, 0x13, 0x54, 0x7F, 0xF5, 0x1E, 0xE4, + 0xFB, 0xFD, 0x7F, 0x58, 0x7E, 0x01, 0x11, 0x05, + 0x90, 0x01, 0x5B, 0x74, 0x05, 0xF0, 0x90, 0x06, + 0x92, 0x74, 0x01, 0xF0, 0x22, 0x90, 0x81, 0x24, + 0xE0, 0x54, 0xF7, 0xF0, 0x12, 0x47, 0x2A, 0x22, + 0x22, 0x12, 0x1F, 0xA4, 0x90, 0x81, 0x31, 0xF0, + 0x22, 0x90, 0x01, 0xC8, 0xE4, 0xF0, 0xA3, 0xF0, + 0xA3, 0xF0, 0x7B, 0x01, 0x7A, 0x81, 0x79, 0x51, + 0x7F, 0xFF, 0xFE, 0x12, 0x2B, 0x27, 0xBF, 0x01, + 0x09, 0x90, 0x81, 0x51, 0xE0, 0x64, 0x03, 0x60, + 0x03, 0x22, 0x01, 0xAB, 0xE4, 0x90, 0x81, 0x56, + 0xF0, 0x90, 0x81, 0x56, 0xE0, 0xFF, 0xC3, 0x94, + 0x02, 0x40, 0x02, 0x01, 0xE6, 0xC3, 0x74, 0xFE, + 0x9F, 0xFF, 0xE4, 0x94, 0x00, 0xFE, 0x7B, 0x01, + 0x7A, 0x81, 0x79, 0x52, 0x12, 0x2B, 0x27, 0xEF, + 0x64, 0x01, 0x70, 0x77, 0x90, 0x81, 0x52, 0xE0, + 0xFF, 0x54, 0xC0, 0xFE, 0x60, 0x05, 0xEF, 0x54, + 0x0C, 0x70, 0x16, 0x90, 0x81, 0x52, 0xE0, 0xFF, + 0x54, 0x30, 0x60, 0x67, 0xEF, 0x54, 0x03, 0x60, + 0x62, 0x90, 0x81, 0x53, 0x74, 0x01, 0xF0, 0x80, + 0x05, 0xE4, 0x90, 0x81, 0x53, 0xF0, 0x90, 0x81, + 0x53, 0xE0, 0x90, 0x81, 0x52, 0x70, 0x16, 0xE0, + 0xFF, 0xEE, 0x13, 0x13, 0x54, 0x3F, 0x90, 0x81, + 0x54, 0xF0, 0xEF, 0x54, 0x0C, 0x13, 0x13, 0x54, + 0x3F, 0xA3, 0xF0, 0x80, 0x0D, 0xE0, 0xFE, 0x54, + 0x30, 0x90, 0x81, 0x54, 0xF0, 0xEE, 0x54, 0x03, + 0xA3, 0xF0, 0x90, 0x81, 0x54, 0xE0, 0x64, 0x30, + 0x70, 0x54, 0xA3, 0xE0, 0x64, 0x02, 0x70, 0x4E, + 0x90, 0x00, 0xF5, 0xE0, 0x54, 0x40, 0x90, 0x81, + 0x57, 0xF0, 0xE0, 0x70, 0x41, 0xA3, 0x74, 0x02, + 0xF0, 0x80, 0x10, 0x90, 0x81, 0x58, 0x74, 0x01, + 0xF0, 0x80, 0x08, 0x90, 0x81, 0x56, 0xE0, 0x04, + 0xF0, 0x01, 0x11, 0x90, 0x01, 0xC4, 0x74, 0xE9, + 0xF0, 0x74, 0x57, 0xA3, 0xF0, 0x90, 0x81, 0x58, + 0xE0, 0x90, 0x01, 0xC8, 0xF0, 0x90, 0x81, 0x52, + 0xE0, 0x90, 0x01, 0xC9, 0xF0, 0x90, 0x81, 0x53, + 0xE0, 0x90, 0x01, 0xCA, 0xF0, 0xE4, 0xFD, 0x7F, + 0x1F, 0x12, 0x32, 0x1E, 0x80, 0xD5, 0x22, 0x90, + 0x00, 0xF7, 0xE0, 0x20, 0xE7, 0x09, 0xE0, 0x7F, + 0x01, 0x20, 0xE6, 0x0C, 0x7F, 0x02, 0x22, 0x90, + 0x00, 0xF7, 0xE0, 0x30, 0xE6, 0x02, 0x7F, 0x03, + 0x22, 0x11, 0xE7, 0x90, 0x80, 0x3C, 0xEF, 0xF0, + 0x31, 0x13, 0x90, 0x01, 0x64, 0x74, 0x01, 0xF0, + 0x02, 0x2D, 0xA7, 0x31, 0x81, 0x31, 0xB1, 0x31, + 0x40, 0x31, 0x5F, 0xE4, 0xF5, 0x35, 0xF5, 0x36, + 0xF5, 0x37, 0xF5, 0x38, 0xAD, 0x35, 0x7F, 0x50, + 0x12, 0x32, 0x1E, 0xAD, 0x36, 0x7F, 0x51, 0x12, + 0x32, 0x1E, 0xAD, 0x37, 0x7F, 0x52, 0x12, 0x32, + 0x1E, 0xAD, 0x38, 0x7F, 0x53, 0x02, 0x32, 0x1E, + 0x75, 0x3D, 0x10, 0xE4, 0xF5, 0x3E, 0x75, 0x3F, + 0x07, 0x75, 0x40, 0x02, 0x90, 0x01, 0x30, 0xE5, + 0x3D, 0xF0, 0xA3, 0xE5, 0x3E, 0xF0, 0xA3, 0xE5, + 0x3F, 0xF0, 0xA3, 0xE5, 0x40, 0xF0, 0x22, 0x75, + 0x45, 0x0E, 0x75, 0x46, 0x01, 0x43, 0x46, 0x10, + 0x75, 0x47, 0x03, 0x75, 0x48, 0x62, 0x90, 0x01, + 0x38, 0xE5, 0x45, 0xF0, 0xA3, 0xE5, 0x46, 0xF0, + 0xA3, 0xE5, 0x47, 0xF0, 0xA3, 0xE5, 0x48, 0xF0, + 0x22, 0x90, 0x01, 0x30, 0xE4, 0xF0, 0xA3, 0xF0, + 0xA3, 0xF0, 0xA3, 0xF0, 0x90, 0x01, 0x38, 0xF0, + 0xA3, 0xF0, 0xA3, 0xF0, 0xA3, 0xF0, 0xFD, 0x7F, + 0x50, 0x12, 0x32, 0x1E, 0xE4, 0xFD, 0x7F, 0x51, + 0x12, 0x32, 0x1E, 0xE4, 0xFD, 0x7F, 0x52, 0x12, + 0x32, 0x1E, 0xE4, 0xFD, 0x7F, 0x53, 0x02, 0x32, + 0x1E, 0x90, 0x01, 0x34, 0x74, 0xFF, 0xF0, 0xA3, + 0xF0, 0xA3, 0xF0, 0xA3, 0xF0, 0x90, 0x01, 0x3C, + 0xF0, 0xA3, 0xF0, 0xA3, 0xF0, 0xA3, 0xF0, 0xFD, + 0x7F, 0x54, 0x12, 0x32, 0x1E, 0x7D, 0xFF, 0x7F, + 0x55, 0x12, 0x32, 0x1E, 0x7D, 0xFF, 0x7F, 0x56, + 0x12, 0x32, 0x1E, 0x7D, 0xFF, 0x7F, 0x57, 0x02, + 0x32, 0x1E, 0x90, 0x00, 0x80, 0xE0, 0x44, 0x80, + 0xFD, 0x7F, 0x80, 0x12, 0x32, 0x1E, 0x90, 0xFD, + 0x00, 0xE0, 0x54, 0xBF, 0xF0, 0x12, 0x57, 0xE9, + 0x51, 0x77, 0x12, 0x32, 0x77, 0x51, 0xC9, 0x51, + 0x5E, 0x7F, 0x01, 0x12, 0x43, 0x15, 0x90, 0x81, + 0x41, 0x74, 0x02, 0xF0, 0xFF, 0x12, 0x43, 0x15, + 0x90, 0x81, 0x41, 0xE0, 0x04, 0xF0, 0x7F, 0x03, + 0x12, 0x43, 0x15, 0x90, 0x81, 0x41, 0xE0, 0x04, + 0xF0, 0x31, 0x01, 0x51, 0x3F, 0x90, 0x00, 0x80, + 0xE0, 0x44, 0x40, 0xFD, 0x7F, 0x80, 0x12, 0x32, + 0x1E, 0x75, 0x20, 0xFF, 0x51, 0x68, 0x51, 0xF9, + 0x51, 0x7F, 0xE4, 0xFF, 0x02, 0x43, 0x9E, 0x51, + 0x62, 0x51, 0x6F, 0x51, 0xA7, 0x71, 0x4F, 0x51, + 0x8A, 0x51, 0x95, 0x90, 0x81, 0x45, 0xE0, 0x54, + 0xFE, 0xF0, 0xA3, 0x74, 0x03, 0xF0, 0xA3, 0xF0, + 0xE4, 0xA3, 0xF0, 0xA3, 0xF0, 0x22, 0xE4, 0xF5, + 0x4D, 0x22, 0xE4, 0x90, 0x80, 0xDE, 0xF0, 0x22, + 0x75, 0xE8, 0x03, 0x75, 0xA8, 0x84, 0x22, 0xE4, + 0x90, 0x80, 0xD8, 0xF0, 0xA3, 0xF0, 0x22, 0x90, + 0x01, 0x94, 0xE0, 0x44, 0x01, 0xF0, 0x22, 0x90, + 0x01, 0xE4, 0x74, 0x0B, 0xF0, 0xA3, 0x74, 0x01, + 0xF0, 0x22, 0x90, 0x81, 0x3F, 0xE0, 0x54, 0xFE, + 0xF0, 0xE4, 0xA3, 0xF0, 0x22, 0x90, 0x81, 0x42, + 0xE0, 0x54, 0xFE, 0xF0, 0x54, 0x7F, 0xF0, 0xA3, + 0x74, 0x0A, 0xF0, 0xE4, 0xA3, 0xF0, 0x22, 0x90, + 0x81, 0x1F, 0xE0, 0x54, 0xFE, 0xF0, 0x54, 0xFD, + 0xF0, 0x54, 0xFB, 0xF0, 0x54, 0xF7, 0xF0, 0x54, + 0xEF, 0xF0, 0x54, 0xDF, 0xF0, 0xE4, 0xA3, 0xF0, + 0xA3, 0xF0, 0xA3, 0xF0, 0xA3, 0x74, 0x0C, 0xF0, + 0x22, 0x90, 0x01, 0x01, 0xE0, 0x44, 0x04, 0xF0, + 0x90, 0x01, 0x9C, 0x74, 0x7E, 0xF0, 0xA3, 0x74, + 0x92, 0xF0, 0xA3, 0x74, 0xA0, 0xF0, 0xA3, 0x74, + 0x24, 0xF0, 0x90, 0x01, 0x9B, 0x74, 0x49, 0xF0, + 0x90, 0x01, 0x9A, 0x74, 0xE0, 0xF0, 0x90, 0x01, + 0x99, 0xE4, 0xF0, 0x90, 0x01, 0x98, 0x04, 0xF0, + 0x22, 0xE4, 0x90, 0x81, 0x51, 0xF0, 0xA3, 0xF0, + 0x90, 0x01, 0x98, 0xE0, 0x7F, 0x00, 0x30, 0xE4, + 0x02, 0x7F, 0x01, 0xEF, 0x64, 0x01, 0x60, 0x3E, + 0xC3, 0x90, 0x81, 0x52, 0xE0, 0x94, 0x88, 0x90, + 0x81, 0x51, 0xE0, 0x94, 0x13, 0x40, 0x08, 0x90, + 0x01, 0xC1, 0xE0, 0x44, 0x10, 0xF0, 0x22, 0x90, + 0x81, 0x51, 0xE4, 0x75, 0xF0, 0x01, 0x12, 0x44, + 0xA9, 0x7F, 0x14, 0x7E, 0x00, 0x12, 0x32, 0xAA, + 0xD3, 0x90, 0x81, 0x52, 0xE0, 0x94, 0x32, 0x90, + 0x81, 0x51, 0xE0, 0x94, 0x00, 0x40, 0xB9, 0x90, + 0x01, 0xC6, 0xE0, 0x30, 0xE3, 0xB2, 0x22, 0xE4, + 0x90, 0x81, 0x27, 0xF0, 0xA3, 0xF0, 0x90, 0x81, + 0x26, 0xE0, 0x54, 0x0F, 0xF0, 0x54, 0xF0, 0xF0, + 0x90, 0x81, 0x24, 0xE0, 0x54, 0xFD, 0xF0, 0x54, + 0xF7, 0xF0, 0x54, 0xEF, 0xF0, 0x90, 0x81, 0x2D, + 0x74, 0x01, 0xF0, 0xA3, 0xF0, 0x90, 0x81, 0x24, + 0xE0, 0x54, 0xFB, 0xF0, 0xA3, 0xE0, 0x54, 0xFB, + 0xF0, 0xE4, 0x90, 0x81, 0x30, 0xF0, 0x90, 0x81, + 0x2F, 0x74, 0x07, 0xF0, 0x90, 0x81, 0x32, 0xE4, + 0xF0, 0xA3, 0x74, 0x02, 0xF0, 0xE4, 0x90, 0x81, + 0x2B, 0xF0, 0x90, 0x81, 0x24, 0xE0, 0x54, 0xFE, + 0xF0, 0x90, 0x81, 0x29, 0x74, 0x0C, 0xF0, 0x90, + 0x81, 0x24, 0xE0, 0x54, 0xDF, 0xF0, 0x90, 0x81, + 0x2A, 0x74, 0x0C, 0xF0, 0x90, 0x81, 0x24, 0xE0, + 0x54, 0xBF, 0xF0, 0x54, 0x7F, 0xF0, 0xA3, 0xE0, + 0x54, 0xFE, 0xF0, 0x54, 0xFD, 0xF0, 0x54, 0xF7, + 0xF0, 0x90, 0x81, 0x34, 0x12, 0x20, 0xDA, 0x00, + 0x00, 0x00, 0x00, 0x90, 0x80, 0x3C, 0xE0, 0xB4, + 0x01, 0x08, 0x90, 0x81, 0x31, 0x74, 0x99, 0xF0, + 0x80, 0x12, 0x90, 0x80, 0x3C, 0xE0, 0x90, 0x81, + 0x31, 0xB4, 0x03, 0x05, 0x74, 0x90, 0xF0, 0x80, + 0x03, 0x74, 0x40, 0xF0, 0x90, 0x81, 0x38, 0x74, + 0x01, 0xF0, 0xA3, 0x74, 0x05, 0xF0, 0xA3, 0xE0, + 0x54, 0x01, 0x44, 0x28, 0xF0, 0xA3, 0x74, 0x05, + 0xF0, 0xE4, 0xA3, 0xF0, 0xA3, 0xE0, 0x54, 0xFD, + 0xF0, 0x54, 0xFB, 0xF0, 0x54, 0xF7, 0xF0, 0x54, + 0xEF, 0xF0, 0x54, 0xDF, 0xF0, 0x54, 0xBF, 0xF0, + 0xE4, 0xA3, 0xF0, 0x22, 0xE4, 0x90, 0x81, 0x59, + 0xF0, 0x90, 0x81, 0x59, 0xE0, 0x64, 0x01, 0xF0, + 0x24, 0x24, 0x90, 0x01, 0xC4, 0xF0, 0x74, 0x5C, + 0xA3, 0xF0, 0x90, 0x81, 0x2A, 0xE0, 0xFF, 0x90, + 0x81, 0x29, 0xE0, 0x6F, 0x60, 0x03, 0x12, 0x47, + 0x2A, 0xD1, 0x08, 0xBF, 0x01, 0x02, 0x91, 0x5F, + 0xB1, 0xF2, 0x12, 0x32, 0x9E, 0xBF, 0x01, 0x02, + 0xB1, 0x67, 0x12, 0x42, 0x4D, 0x80, 0xCA, 0xD3, + 0x10, 0xAF, 0x01, 0xC3, 0xC0, 0xD0, 0x90, 0x81, + 0x24, 0xE0, 0x30, 0xE0, 0x24, 0x90, 0x81, 0x1F, + 0xE0, 0xFF, 0x30, 0xE0, 0x1A, 0xC3, 0x13, 0x30, + 0xE0, 0x07, 0xB1, 0xFB, 0xBF, 0x01, 0x12, 0x80, + 0x0A, 0x90, 0x81, 0x23, 0xE0, 0xFF, 0x60, 0x03, + 0xB4, 0x08, 0x06, 0x91, 0x96, 0x80, 0x02, 0x91, + 0xA6, 0xD0, 0xD0, 0x92, 0xAF, 0x22, 0xD3, 0x10, + 0xAF, 0x01, 0xC3, 0xC0, 0xD0, 0xB1, 0x22, 0x91, + 0xBA, 0xD0, 0xD0, 0x92, 0xAF, 0x22, 0x90, 0x81, + 0x2A, 0xE0, 0x70, 0x0D, 0xD1, 0x2F, 0xBF, 0x01, + 0x08, 0x91, 0x96, 0x90, 0x01, 0xE5, 0xE0, 0x04, + 0xF0, 0x22, 0xB1, 0xF3, 0x90, 0x00, 0x08, 0xE0, + 0x54, 0xEF, 0xFD, 0x7F, 0x08, 0x12, 0x32, 0x1E, + 0xE4, 0xFF, 0x8F, 0x50, 0xE4, 0x90, 0x81, 0x5A, + 0xF0, 0xA3, 0xF0, 0x90, 0x01, 0x09, 0xE0, 0x7F, + 0x00, 0x30, 0xE7, 0x02, 0x7F, 0x01, 0xEF, 0x65, + 0x50, 0x60, 0x3E, 0xC3, 0x90, 0x81, 0x5B, 0xE0, + 0x94, 0x88, 0x90, 0x81, 0x5A, 0xE0, 0x94, 0x13, + 0x40, 0x08, 0x90, 0x01, 0xC0, 0xE0, 0x44, 0x10, + 0xF0, 0x22, 0x90, 0x81, 0x5A, 0xE4, 0x75, 0xF0, + 0x01, 0x12, 0x44, 0xA9, 0x7F, 0x14, 0x7E, 0x00, + 0x12, 0x32, 0xAA, 0xD3, 0x90, 0x81, 0x5B, 0xE0, + 0x94, 0x32, 0x90, 0x81, 0x5A, 0xE0, 0x94, 0x00, + 0x40, 0xB9, 0x90, 0x01, 0xC6, 0xE0, 0x30, 0xE0, + 0xB2, 0x22, 0x90, 0x81, 0x31, 0xE0, 0xFD, 0x7F, + 0x93, 0x12, 0x32, 0x1E, 0x90, 0x81, 0x28, 0xE0, + 0x60, 0x12, 0x90, 0x01, 0x2F, 0xE0, 0x30, 0xE7, + 0x05, 0x74, 0x10, 0xF0, 0x80, 0x06, 0x90, 0x01, + 0x2F, 0x74, 0x90, 0xF0, 0x90, 0x00, 0x08, 0xE0, + 0x44, 0x10, 0xFD, 0x7F, 0x08, 0x12, 0x32, 0x1E, + 0x7F, 0x01, 0x91, 0xCA, 0x90, 0x00, 0x90, 0xE0, + 0x44, 0x01, 0xFD, 0x7F, 0x90, 0x12, 0x32, 0x1E, + 0x7F, 0x14, 0x7E, 0x00, 0x02, 0x32, 0xAA, 0xD3, + 0x10, 0xAF, 0x01, 0xC3, 0xC0, 0xD0, 0x12, 0x2D, + 0xA7, 0xE4, 0xF5, 0x52, 0x12, 0x32, 0x9E, 0xEF, + 0x60, 0x73, 0x63, 0x52, 0x01, 0xE5, 0x52, 0x24, + 0x67, 0x90, 0x01, 0xC4, 0xF0, 0x74, 0x5D, 0xA3, + 0xF0, 0x90, 0x00, 0x88, 0xE0, 0xF5, 0x50, 0xF5, + 0x51, 0x54, 0x0F, 0x60, 0xDF, 0xE5, 0x50, 0x30, + 0xE0, 0x0B, 0x20, 0xE4, 0x03, 0x12, 0x29, 0xC5, + 0x53, 0x51, 0xEE, 0x80, 0x3F, 0xE5, 0x50, 0x30, + 0xE1, 0x16, 0x20, 0xE5, 0x0E, 0x12, 0x11, 0xBD, + 0xEF, 0x70, 0x03, 0x43, 0x51, 0x20, 0x90, 0x01, + 0x06, 0xE4, 0xF0, 0x53, 0x51, 0xFD, 0x80, 0x24, + 0xE5, 0x50, 0x30, 0xE2, 0x0B, 0x20, 0xE6, 0x03, + 0x12, 0x67, 0x06, 0x53, 0x51, 0xFB, 0x80, 0x14, + 0xE5, 0x50, 0x30, 0xE3, 0x0F, 0x20, 0xE7, 0x09, + 0x12, 0x61, 0x6E, 0xEF, 0x70, 0x03, 0x43, 0x51, + 0x80, 0x53, 0x51, 0xF7, 0xAD, 0x51, 0x7F, 0x88, + 0x12, 0x32, 0x1E, 0x80, 0x87, 0xD0, 0xD0, 0x92, + 0xAF, 0x22, 0x22, 0x90, 0x00, 0x90, 0xE0, 0x20, + 0xE0, 0xF9, 0x22, 0x90, 0x81, 0x22, 0xE0, 0x64, + 0x02, 0x7F, 0x01, 0x60, 0x02, 0x7F, 0x00, 0x22, + 0x7F, 0x02, 0x90, 0x81, 0x41, 0xE0, 0xFE, 0xEF, + 0xC3, 0x9E, 0x50, 0x18, 0xEF, 0x25, 0xE0, 0x24, + 0x81, 0xF8, 0xE6, 0x30, 0xE4, 0x0B, 0x90, 0x01, + 0xB8, 0x74, 0x08, 0xF0, 0xA3, 0xF0, 0x7F, 0x00, + 0x22, 0x0F, 0x80, 0xDE, 0x7F, 0x01, 0x22, 0x90, + 0x02, 0x87, 0xE0, 0x60, 0x08, 0x90, 0x01, 0xB8, + 0x74, 0x01, 0xF0, 0x80, 0x17, 0x90, 0x02, 0x86, + 0xE0, 0x20, 0xE1, 0x08, 0x90, 0x01, 0xB8, 0x74, + 0x04, 0xF0, 0x80, 0x08, 0x90, 0x01, 0xB8, 0xE4, + 0xF0, 0x7F, 0x01, 0x22, 0x90, 0x01, 0xB9, 0x74, + 0x08, 0xF0, 0x7F, 0x00, 0x22, 0xE4, 0xFB, 0xFA, + 0xFD, 0x7F, 0x01, 0x12, 0x44, 0x4E, 0x90, 0x81, + 0xBD, 0xEF, 0xF0, 0x60, 0xF0, 0xD1, 0x71, 0x80, + 0xEC, 0xD3, 0x10, 0xAF, 0x01, 0xC3, 0xC0, 0xD0, + 0x90, 0x01, 0xCC, 0xE0, 0x54, 0x0F, 0x90, 0x81, + 0xBE, 0xF0, 0x90, 0x81, 0xBE, 0xE0, 0xFD, 0x70, + 0x02, 0xE1, 0x9C, 0x90, 0x82, 0x09, 0xE0, 0xFF, + 0x74, 0x01, 0x7E, 0x00, 0xA8, 0x07, 0x08, 0x80, + 0x05, 0xC3, 0x33, 0xCE, 0x33, 0xCE, 0xD8, 0xF9, + 0xFF, 0xEF, 0x5D, 0x70, 0x02, 0xE1, 0x95, 0x90, + 0x82, 0x09, 0xE0, 0x75, 0xF0, 0x04, 0x90, 0x01, + 0xD0, 0x12, 0x45, 0x0A, 0xE0, 0x90, 0x81, 0xBF, + 0xF0, 0x75, 0x13, 0x01, 0x75, 0x14, 0x81, 0x75, + 0x15, 0xBF, 0x75, 0x16, 0x01, 0x7B, 0x01, 0x7A, + 0x81, 0x79, 0xC0, 0x12, 0x2B, 0xED, 0x90, 0x82, + 0x09, 0xE0, 0x75, 0xF0, 0x04, 0x90, 0x01, 0xD1, + 0x12, 0x45, 0x0A, 0xE0, 0x90, 0x81, 0xC1, 0xF0, + 0x90, 0x82, 0x09, 0xE0, 0x75, 0xF0, 0x04, 0x90, + 0x01, 0xD2, 0x12, 0x45, 0x0A, 0xE0, 0x90, 0x81, + 0xC2, 0xF0, 0x90, 0x82, 0x09, 0xE0, 0x75, 0xF0, + 0x04, 0x90, 0x01, 0xD3, 0x12, 0x45, 0x0A, 0xE0, + 0x90, 0x81, 0xC3, 0xF0, 0x90, 0x82, 0x09, 0xE0, + 0x75, 0xF0, 0x04, 0x90, 0x01, 0xF0, 0x12, 0x45, + 0x0A, 0xE0, 0x90, 0x81, 0xC4, 0xF0, 0x90, 0x82, + 0x09, 0xE0, 0x75, 0xF0, 0x04, 0x90, 0x01, 0xF1, + 0x12, 0x45, 0x0A, 0xE0, 0x90, 0x81, 0xC5, 0xF0, + 0x90, 0x82, 0x09, 0xE0, 0x75, 0xF0, 0x04, 0x90, + 0x01, 0xF2, 0x12, 0x45, 0x0A, 0xE0, 0x90, 0x81, + 0xC6, 0xF0, 0x90, 0x82, 0x09, 0xE0, 0x75, 0xF0, + 0x04, 0x90, 0x01, 0xF3, 0x12, 0x45, 0x0A, 0xE0, + 0x90, 0x81, 0xC7, 0xF0, 0x90, 0x81, 0xBE, 0xE0, + 0xFF, 0x90, 0x82, 0x09, 0xE0, 0xFE, 0x74, 0x01, + 0xA8, 0x06, 0x08, 0x80, 0x02, 0xC3, 0x33, 0xD8, + 0xFC, 0xF4, 0x5F, 0x90, 0x81, 0xBE, 0xF0, 0x90, + 0x82, 0x09, 0xE0, 0xFF, 0x74, 0x01, 0xA8, 0x07, + 0x08, 0x80, 0x02, 0xC3, 0x33, 0xD8, 0xFC, 0x90, + 0x01, 0xCC, 0xF0, 0x90, 0x81, 0xC0, 0xE0, 0xFF, + 0x7B, 0x01, 0x7A, 0x81, 0x79, 0xC1, 0x12, 0x55, + 0x3F, 0x90, 0x82, 0x09, 0xE0, 0x04, 0xF0, 0xE0, + 0x54, 0x03, 0xF0, 0xC1, 0x82, 0x90, 0x01, 0xC0, + 0xE0, 0x44, 0x02, 0xF0, 0xD0, 0xD0, 0x92, 0xAF, + 0x22, 0xE4, 0xFB, 0xFA, 0xFD, 0x7F, 0x01, 0x12, + 0x44, 0x4E, 0x90, 0x81, 0xD0, 0xEF, 0xF0, 0x60, + 0xF0, 0x12, 0x6C, 0x19, 0x80, 0xEB, 0x90, 0x81, + 0xD4, 0xEF, 0xF0, 0xA3, 0xED, 0xF0, 0xA3, 0x12, + 0x20, 0xDA, 0x00, 0x00, 0x00, 0x00, 0xE4, 0x90, + 0x81, 0xE2, 0xF0, 0x7F, 0x24, 0x7E, 0x08, 0x12, + 0x2D, 0x5C, 0x90, 0x81, 0xDA, 0x12, 0x20, 0xCE, + 0x90, 0x81, 0xD4, 0xE0, 0xFB, 0x70, 0x08, 0x90, + 0x81, 0xDA, 0x12, 0x44, 0xD9, 0x80, 0x16, 0xEB, + 0x75, 0xF0, 0x08, 0xA4, 0x24, 0x62, 0xF5, 0x82, + 0xE4, 0x34, 0x87, 0xF5, 0x83, 0xE0, 0xFE, 0xA3, + 0xE0, 0xFF, 0x12, 0x2D, 0x5C, 0x90, 0x81, 0xDE, + 0x12, 0x20, 0xCE, 0x90, 0x81, 0xD5, 0xE0, 0xFF, + 0xE4, 0xFC, 0xFD, 0xFE, 0x78, 0x17, 0x12, 0x20, + 0xBB, 0xA8, 0x04, 0xA9, 0x05, 0xAA, 0x06, 0xAB, + 0x07, 0x90, 0x81, 0xDE, 0x12, 0x44, 0xD9, 0xED, + 0x54, 0x7F, 0xFD, 0xEC, 0x54, 0x80, 0xFC, 0x12, + 0x44, 0xCC, 0xEC, 0x44, 0x80, 0xFC, 0x90, 0x81, + 0xDE, 0x12, 0x20, 0xCE, 0x90, 0x81, 0xDA, 0x12, + 0x44, 0xD9, 0xEC, 0x54, 0x7F, 0xFC, 0x90, 0x85, + 0xBB, 0x12, 0x20, 0xCE, 0x7F, 0x24, 0x7E, 0x08, + 0x12, 0x2E, 0xA2, 0x90, 0x81, 0xD4, 0xE0, 0x75, + 0xF0, 0x08, 0xA4, 0x24, 0x62, 0xF5, 0x82, 0xE4, + 0x34, 0x87, 0xF5, 0x83, 0xE0, 0xFE, 0xA3, 0xE0, + 0xFF, 0xC0, 0x06, 0xC0, 0x07, 0x90, 0x81, 0xDE, + 0x12, 0x44, 0xD9, 0x90, 0x85, 0xBB, 0x12, 0x20, + 0xCE, 0xD0, 0x07, 0xD0, 0x06, 0x12, 0x2E, 0xA2, + 0x90, 0x81, 0xDA, 0x12, 0x44, 0xD9, 0xEC, 0x44, + 0x80, 0xFC, 0x90, 0x85, 0xBB, 0x12, 0x20, 0xCE, + 0x7F, 0x24, 0x7E, 0x08, 0x12, 0x2E, 0xA2, 0x90, + 0x81, 0xD4, 0xE0, 0x70, 0x04, 0x7F, 0x20, 0x80, + 0x09, 0x90, 0x81, 0xD4, 0xE0, 0xB4, 0x01, 0x16, + 0x7F, 0x28, 0x7E, 0x08, 0x12, 0x2D, 0x5C, 0x78, + 0x08, 0x12, 0x20, 0xA8, 0xEF, 0x54, 0x01, 0xFF, + 0xE4, 0x90, 0x81, 0xE2, 0xEF, 0xF0, 0x90, 0x81, + 0xE2, 0xE0, 0x90, 0x81, 0xD4, 0x60, 0x0E, 0xE0, + 0x75, 0xF0, 0x08, 0xA4, 0x24, 0x66, 0xF5, 0x82, + 0xE4, 0x34, 0x87, 0x80, 0x0C, 0xE0, 0x75, 0xF0, + 0x08, 0xA4, 0x24, 0x64, 0xF5, 0x82, 0xE4, 0x34, + 0x87, 0xF5, 0x83, 0xE0, 0xFE, 0xA3, 0xE0, 0xFF, + 0x12, 0x2D, 0x5C, 0xED, 0x54, 0x0F, 0xFD, 0xE4, + 0xFC, 0x90, 0x81, 0xD6, 0x12, 0x20, 0xCE, 0x90, + 0x81, 0xD6, 0x02, 0x44, 0xD9, 0x90, 0x81, 0xE3, + 0xEF, 0xF0, 0xAB, 0x05, 0x90, 0x81, 0xE9, 0x12, + 0x20, 0xDA, 0x00, 0x00, 0x00, 0x00, 0xAF, 0x03, + 0xE4, 0xFC, 0xFD, 0xFE, 0x78, 0x14, 0x12, 0x20, + 0xBB, 0xA8, 0x04, 0xA9, 0x05, 0xAA, 0x06, 0xAB, + 0x07, 0x90, 0x81, 0xE5, 0x12, 0x44, 0xD9, 0xED, + 0x54, 0x0F, 0xFD, 0xE4, 0xFC, 0x12, 0x44, 0xCC, + 0xEC, 0x54, 0x0F, 0xFC, 0x90, 0x81, 0xE9, 0x12, + 0x20, 0xCE, 0x90, 0x81, 0xE3, 0xE0, 0x75, 0xF0, + 0x08, 0xA4, 0x24, 0x60, 0xF5, 0x82, 0xE4, 0x34, + 0x87, 0xF5, 0x83, 0xE0, 0xFE, 0xA3, 0xE0, 0xFF, + 0xC0, 0x06, 0xC0, 0x07, 0x90, 0x81, 0xE9, 0x12, + 0x44, 0xD9, 0x90, 0x85, 0xBB, 0x12, 0x20, 0xCE, + 0xD0, 0x07, 0xD0, 0x06, 0x02, 0x2E, 0xA2, 0xD3, + 0x10, 0xAF, 0x01, 0xC3, 0xC0, 0xD0, 0x12, 0x5F, + 0xB6, 0xD0, 0xD0, 0x92, 0xAF, 0x22, 0x78, 0x10, + 0x74, 0x01, 0xF2, 0x90, 0x02, 0x09, 0xE0, 0x78, + 0x00, 0xF2, 0x08, 0x74, 0x20, 0xF2, 0x18, 0xE2, + 0xFF, 0x30, 0xE0, 0x05, 0x08, 0xE2, 0x24, 0x80, + 0xF2, 0xEF, 0xC3, 0x13, 0x90, 0xFD, 0x10, 0xF0, + 0x78, 0x01, 0xE2, 0x24, 0x00, 0xF5, 0x82, 0xE4, + 0x34, 0xFC, 0xF5, 0x83, 0xE0, 0x78, 0x03, 0xF2, + 0x64, 0x04, 0x60, 0x0D, 0xE2, 0xFF, 0x64, 0x08, + 0x60, 0x07, 0xEF, 0x64, 0x0C, 0x60, 0x02, 0x61, + 0xDE, 0xE4, 0x78, 0x02, 0xF2, 0x78, 0x03, 0xE2, + 0xFF, 0x18, 0xE2, 0xC3, 0x9F, 0x50, 0x2D, 0xE2, + 0xFD, 0x18, 0xE2, 0x2D, 0x90, 0x81, 0x5A, 0xF0, + 0xE0, 0xFF, 0x24, 0x00, 0xF5, 0x82, 0xE4, 0x34, + 0xFC, 0xF5, 0x83, 0xE0, 0xFE, 0x74, 0x04, 0x2D, + 0xF8, 0xEE, 0xF2, 0xEF, 0xB4, 0xFF, 0x06, 0x90, + 0xFD, 0x10, 0xE0, 0x04, 0xF0, 0x78, 0x02, 0xE2, + 0x04, 0xF2, 0x80, 0xC9, 0x78, 0x04, 0xE2, 0x78, + 0x12, 0xF2, 0xFF, 0x78, 0x05, 0xE2, 0x78, 0x11, + 0xF2, 0x78, 0x06, 0xE2, 0x78, 0x13, 0xF2, 0x78, + 0x07, 0xE2, 0x78, 0x14, 0xF2, 0x78, 0x08, 0xE2, + 0x78, 0x33, 0xF2, 0x78, 0x09, 0xE2, 0x78, 0x34, + 0xF2, 0x78, 0x0A, 0xE2, 0x78, 0x35, 0xF2, 0x78, + 0x0B, 0xE2, 0x78, 0x36, 0xF2, 0x78, 0x0C, 0xE2, + 0x78, 0x37, 0xF2, 0x78, 0x0D, 0xE2, 0x78, 0x38, + 0xF2, 0x78, 0x0E, 0xE2, 0x78, 0x39, 0xF2, 0x78, + 0x0F, 0xE2, 0x78, 0x3A, 0xF2, 0xE4, 0x78, 0x15, + 0xF2, 0xEF, 0x24, 0xF8, 0x60, 0x75, 0x24, 0xFC, + 0x60, 0x6C, 0x24, 0x08, 0x60, 0x02, 0x61, 0xC0, + 0x78, 0x11, 0xE2, 0xB4, 0x01, 0x05, 0x12, 0x29, + 0xC5, 0x61, 0xC5, 0x78, 0x11, 0xE2, 0xB4, 0x02, + 0x05, 0x12, 0x11, 0xBD, 0x61, 0xC5, 0x78, 0x11, + 0xE2, 0xB4, 0x03, 0x04, 0xF1, 0x06, 0x61, 0xC5, + 0x78, 0x11, 0xE2, 0xB4, 0x10, 0x17, 0x78, 0x14, + 0xE2, 0xFE, 0x18, 0xE2, 0xFD, 0xED, 0xFF, 0x78, + 0x16, 0xEE, 0xF2, 0xFE, 0x08, 0xEF, 0xF2, 0xFF, + 0x12, 0x32, 0xAA, 0x61, 0xC5, 0x78, 0x11, 0xE2, + 0xB4, 0x11, 0x17, 0x78, 0x14, 0xE2, 0xFE, 0x18, + 0xE2, 0xFD, 0xED, 0xFF, 0x78, 0x16, 0xEE, 0xF2, + 0xFE, 0x08, 0xEF, 0xF2, 0xFF, 0x12, 0x32, 0x06, + 0x61, 0xC5, 0x78, 0x11, 0xE2, 0xF4, 0x60, 0x02, + 0x61, 0xC5, 0x18, 0xF2, 0x61, 0xC5, 0x78, 0x15, + 0x74, 0x01, 0xF2, 0x78, 0x11, 0xE2, 0x64, 0x07, + 0x60, 0x02, 0x61, 0xAA, 0x78, 0x34, 0xE2, 0xFF, + 0xE4, 0xFC, 0xFD, 0xFE, 0x78, 0x08, 0x12, 0x20, + 0xBB, 0xC0, 0x04, 0xA9, 0x05, 0xAA, 0x06, 0xAB, + 0x07, 0x78, 0x33, 0xE2, 0xFF, 0xE4, 0xFC, 0xFD, + 0xFE, 0xD0, 0x00, 0x12, 0x44, 0xCC, 0xC0, 0x04, + 0xC0, 0x05, 0xC0, 0x06, 0xC0, 0x07, 0x78, 0x35, + 0xE2, 0xFF, 0xE4, 0xFC, 0xFD, 0xFE, 0x78, 0x10, + 0x12, 0x20, 0xBB, 0xD0, 0x03, 0xD0, 0x02, 0xD0, + 0x01, 0xD0, 0x00, 0x12, 0x44, 0xCC, 0x78, 0x18, + 0x12, 0x44, 0xFE, 0x78, 0x15, 0xE2, 0x70, 0x02, + 0x61, 0x93, 0x18, 0xE2, 0xFF, 0x18, 0xE2, 0xFD, + 0x31, 0x5F, 0x78, 0x1C, 0x12, 0x44, 0xFE, 0x78, + 0x38, 0xE2, 0xFF, 0xE4, 0xFC, 0xFD, 0xFE, 0x78, + 0x08, 0x12, 0x20, 0xBB, 0xC0, 0x04, 0xA9, 0x05, + 0xAA, 0x06, 0xAB, 0x07, 0x78, 0x37, 0xE2, 0xFF, + 0xE4, 0xFC, 0xFD, 0xFE, 0xD0, 0x00, 0x12, 0x44, + 0xCC, 0xC0, 0x04, 0xC0, 0x05, 0xC0, 0x06, 0xC0, + 0x07, 0x78, 0x39, 0xE2, 0xFF, 0xE4, 0xFC, 0xFD, + 0xFE, 0x78, 0x10, 0x12, 0x20, 0xBB, 0xD0, 0x03, + 0xD0, 0x02, 0xD0, 0x01, 0xD0, 0x00, 0x12, 0x44, + 0xCC, 0x78, 0x20, 0x12, 0x44, 0xFE, 0x78, 0x20, + 0x12, 0x44, 0xE5, 0x12, 0x20, 0x9B, 0x78, 0x1C, + 0x12, 0x44, 0xF1, 0x12, 0x44, 0xBF, 0xC0, 0x04, + 0xC0, 0x05, 0xC0, 0x06, 0xC0, 0x07, 0x78, 0x18, + 0x12, 0x44, 0xE5, 0x78, 0x20, 0x12, 0x44, 0xF1, + 0x12, 0x44, 0xBF, 0xD0, 0x03, 0xD0, 0x02, 0xD0, + 0x01, 0xD0, 0x00, 0x12, 0x44, 0xCC, 0x78, 0x18, + 0x12, 0x44, 0xFE, 0x78, 0x18, 0x12, 0x44, 0xE5, + 0x90, 0x81, 0xF9, 0x12, 0x20, 0xCE, 0x78, 0x13, + 0xE2, 0xFD, 0x08, 0xE2, 0xFF, 0x12, 0x55, 0x1C, + 0x80, 0x1B, 0x78, 0x13, 0xE2, 0xFF, 0x08, 0xE2, + 0xFD, 0x78, 0x11, 0xE2, 0xFB, 0x78, 0x15, 0xE2, + 0x90, 0x81, 0xBC, 0xF0, 0x71, 0xE1, 0x80, 0x05, + 0x78, 0x10, 0x74, 0x02, 0xF2, 0x78, 0x10, 0xE2, + 0xFF, 0xC3, 0x94, 0x02, 0x50, 0x10, 0xEF, 0x60, + 0x0A, 0x78, 0x02, 0xE2, 0xFF, 0x18, 0xE2, 0x2F, + 0xF2, 0x21, 0x90, 0x7F, 0x01, 0x22, 0x7F, 0x00, + 0x22, 0xAC, 0x07, 0xED, 0xAD, 0x04, 0x78, 0x24, + 0xF2, 0xED, 0x08, 0xF2, 0xEB, 0xB4, 0x04, 0x07, + 0x78, 0x27, 0x74, 0x01, 0xF2, 0x80, 0x0E, 0xEB, + 0x78, 0x27, 0xB4, 0x05, 0x05, 0x74, 0x02, 0xF2, + 0x80, 0x03, 0x74, 0x04, 0xF2, 0xD3, 0x78, 0x25, + 0xE2, 0x94, 0xFF, 0x18, 0xE2, 0x94, 0x00, 0x50, + 0x63, 0xE4, 0x78, 0x26, 0xF2, 0x78, 0x27, 0xE2, + 0xFF, 0x18, 0xE2, 0xFE, 0xC3, 0x9F, 0x40, 0x02, + 0xA1, 0x7F, 0x74, 0x33, 0x2E, 0xF8, 0xE2, 0x78, + 0x28, 0xF2, 0x90, 0x81, 0xBC, 0xE0, 0x60, 0x2D, + 0x74, 0x37, 0x2E, 0xF8, 0xE2, 0x78, 0x32, 0xF2, + 0xEE, 0xFF, 0x78, 0x25, 0xE2, 0x2F, 0xFF, 0x18, + 0xE2, 0x34, 0x00, 0x8F, 0x82, 0xF5, 0x83, 0xE0, + 0x78, 0x29, 0xF2, 0x78, 0x32, 0xE2, 0xFF, 0xF4, + 0xFE, 0x78, 0x29, 0xE2, 0x5E, 0xFE, 0x18, 0xE2, + 0xFD, 0xEF, 0x5D, 0x4E, 0xF2, 0x78, 0x24, 0x08, + 0xE2, 0xFF, 0x08, 0xE2, 0x2F, 0xFF, 0x78, 0x28, + 0xE2, 0xFD, 0x12, 0x32, 0x1E, 0x78, 0x26, 0xE2, + 0x04, 0xF2, 0x80, 0xA1, 0xD3, 0x78, 0x25, 0xE2, + 0x94, 0xFF, 0x18, 0xE2, 0x94, 0x07, 0x50, 0x69, + 0xE4, 0x78, 0x26, 0xF2, 0x78, 0x27, 0xE2, 0xFF, + 0x18, 0xE2, 0xFE, 0xC3, 0x9F, 0x40, 0x02, 0xA1, + 0x7F, 0x74, 0x33, 0x2E, 0xF8, 0xE2, 0x78, 0x28, + 0xF2, 0x90, 0x81, 0xBC, 0xE0, 0x60, 0x2D, 0x78, + 0x26, 0xE2, 0xFF, 0xFD, 0x18, 0xE2, 0x2D, 0xFD, + 0x18, 0xE2, 0x34, 0x00, 0x8D, 0x82, 0xF5, 0x83, + 0xE0, 0x78, 0x29, 0xF2, 0x74, 0x37, 0x2F, 0xF8, + 0xE2, 0x78, 0x32, 0xF2, 0xE2, 0xFF, 0xF4, 0xFE, + 0x78, 0x29, 0xE2, 0x5E, 0xFE, 0x18, 0xE2, 0xFD, + 0xEF, 0x5D, 0x4E, 0xF2, 0x78, 0x28, 0xE2, 0xFF, + 0x78, 0x26, 0xE2, 0xFD, 0x18, 0xE2, 0x2D, 0xFD, + 0x18, 0xE2, 0x34, 0x00, 0x8D, 0x82, 0xF5, 0x83, + 0xEF, 0xF0, 0x78, 0x26, 0xE2, 0x04, 0xF2, 0x80, + 0x9B, 0x90, 0x81, 0xBC, 0xE0, 0x60, 0x0F, 0x78, + 0x24, 0xE2, 0xFE, 0x08, 0xE2, 0xFF, 0x12, 0x2D, + 0x5C, 0x78, 0x2E, 0x12, 0x44, 0xFE, 0xE4, 0x78, + 0x26, 0xF2, 0x78, 0x27, 0xE2, 0xFF, 0x18, 0xE2, + 0xFE, 0xC3, 0x9F, 0x50, 0x5D, 0x74, 0x33, 0x2E, + 0xF8, 0xE2, 0x78, 0x28, 0xF2, 0x90, 0x81, 0xBC, + 0xE0, 0x60, 0x2B, 0x78, 0x2E, 0x12, 0x44, 0xE5, + 0x78, 0x26, 0xE2, 0xFB, 0x75, 0xF0, 0x08, 0xA4, + 0xF9, 0xF8, 0x12, 0x20, 0xA8, 0x78, 0x29, 0xEF, + 0xF2, 0x74, 0x37, 0x2B, 0xF8, 0xE2, 0x78, 0x32, + 0xF2, 0xE2, 0xFE, 0xF4, 0x5F, 0xFF, 0x78, 0x28, + 0xE2, 0xFD, 0xEE, 0x5D, 0x4F, 0xF2, 0x78, 0x28, + 0xE2, 0xFF, 0x78, 0x26, 0xE2, 0xFD, 0xC3, 0x74, + 0x03, 0x9D, 0xFD, 0xE4, 0x94, 0x00, 0xFC, 0x7B, + 0xFE, 0x74, 0x2A, 0x2D, 0xF9, 0x74, 0x80, 0x3C, + 0xFA, 0xEF, 0x12, 0x1F, 0xEA, 0xE2, 0x04, 0xF2, + 0x80, 0x98, 0x78, 0x2A, 0x12, 0x44, 0xE5, 0x90, + 0x85, 0xBB, 0x12, 0x20, 0xCE, 0x78, 0x24, 0xE2, + 0xFE, 0x08, 0xE2, 0xFF, 0x12, 0x2E, 0xA2, 0x22, + 0x22, 0x90, 0x81, 0xCB, 0x12, 0x45, 0x1F, 0x90, + 0x00, 0x01, 0x12, 0x1F, 0xBD, 0xFF, 0xFE, 0x12, + 0x1F, 0xA4, 0xFD, 0xC3, 0x13, 0x30, 0xE0, 0x12, + 0x90, 0x81, 0xCB, 0x12, 0x45, 0x16, 0x90, 0x00, + 0x02, 0x12, 0x1F, 0xBD, 0x90, 0x81, 0xCF, 0xF0, + 0x80, 0x05, 0x90, 0x81, 0xCF, 0xEF, 0xF0, 0x90, + 0x81, 0xCE, 0xEE, 0xF0, 0x90, 0x81, 0xCF, 0xE0, + 0xFE, 0x90, 0x81, 0xCE, 0xE0, 0xFF, 0xD3, 0x9E, + 0x50, 0x38, 0x90, 0x81, 0xCB, 0x12, 0x45, 0x16, + 0x12, 0x1F, 0xA4, 0x54, 0x01, 0xFE, 0x74, 0xDE, + 0x2F, 0xF5, 0x82, 0xE4, 0x34, 0x80, 0xF5, 0x83, + 0xEE, 0xF0, 0x74, 0xDE, 0x2F, 0xF5, 0x82, 0xE4, + 0x34, 0x80, 0xF5, 0x83, 0xE0, 0x70, 0x04, 0xD1, + 0x25, 0x80, 0x07, 0x90, 0x81, 0xCE, 0xE0, 0xFF, + 0xB1, 0x80, 0x90, 0x81, 0xCE, 0xE0, 0x04, 0xF0, + 0x80, 0xBA, 0x90, 0x80, 0xDE, 0xE0, 0x70, 0x24, + 0x90, 0x81, 0x2A, 0xE0, 0x70, 0x04, 0xFF, 0x12, + 0x49, 0x93, 0x90, 0x81, 0x2A, 0xE0, 0x64, 0x0C, + 0x60, 0x02, 0xD1, 0x26, 0x90, 0x81, 0x24, 0xE0, + 0x54, 0xF7, 0xF0, 0x54, 0xEF, 0xF0, 0x54, 0xBF, + 0xF0, 0x54, 0x7F, 0xF0, 0x22, 0x22, 0x90, 0x06, + 0x04, 0xE0, 0x54, 0x7F, 0xF0, 0x90, 0x05, 0x22, + 0xE4, 0xF0, 0x90, 0x81, 0x2A, 0x74, 0x0C, 0xF0, + 0x22, 0x90, 0x81, 0xED, 0xEF, 0xF0, 0xA3, 0xED, + 0xF0, 0xAD, 0x03, 0xAC, 0x02, 0xE4, 0x90, 0x81, + 0xF5, 0xF0, 0xA3, 0xF0, 0x90, 0x01, 0xC4, 0x74, + 0x39, 0xF0, 0x74, 0x66, 0xA3, 0xF0, 0xEC, 0x54, + 0x3F, 0xFC, 0x90, 0x01, 0x40, 0xED, 0xF0, 0xAE, + 0x04, 0xEE, 0xA3, 0xF0, 0x90, 0x81, 0xED, 0xE0, + 0x24, 0x81, 0x60, 0x34, 0x24, 0xDA, 0x60, 0x1C, + 0x24, 0x3C, 0x70, 0x41, 0x90, 0x81, 0xEE, 0xE0, + 0xC4, 0x33, 0x33, 0x33, 0x54, 0x80, 0x90, 0x81, + 0xF2, 0xF0, 0xA3, 0x74, 0x69, 0xF0, 0xA3, 0x74, + 0x80, 0xF0, 0x80, 0x2C, 0x90, 0x81, 0xEE, 0xE0, + 0x54, 0x01, 0x90, 0x81, 0xF2, 0xF0, 0xA3, 0x74, + 0xA5, 0xF0, 0xA3, 0x74, 0x01, 0xF0, 0x80, 0x18, + 0x90, 0x81, 0xEE, 0xE0, 0xC4, 0x54, 0x10, 0x90, + 0x81, 0xF2, 0xF0, 0xA3, 0x74, 0x7F, 0xF0, 0xA3, + 0x74, 0x10, 0xF0, 0x80, 0x03, 0x7F, 0x00, 0x22, + 0x90, 0x81, 0xF3, 0xE0, 0x90, 0x01, 0x06, 0xF0, + 0x90, 0x81, 0xF2, 0xE0, 0x60, 0x0E, 0x90, 0x01, + 0x42, 0xF0, 0x90, 0x81, 0xF1, 0xE0, 0x90, 0x01, + 0x43, 0xF0, 0x80, 0x0D, 0x90, 0x01, 0x43, 0xE4, + 0xF0, 0x90, 0x81, 0xF2, 0xE0, 0x90, 0x01, 0x42, + 0xF0, 0x90, 0x81, 0xF4, 0xE0, 0xFF, 0x90, 0x01, + 0x42, 0xE0, 0x5F, 0xFF, 0x90, 0x81, 0xF2, 0xE0, + 0x6F, 0x60, 0xEE, 0x74, 0x39, 0x04, 0x90, 0x01, + 0xC4, 0xF0, 0x74, 0x66, 0xA3, 0xF0, 0x90, 0x01, + 0x43, 0xE4, 0xF0, 0x7F, 0x01, 0x22, 0xE4, 0x90, + 0x81, 0x6A, 0xF0, 0x90, 0x87, 0x5F, 0xE0, 0x90, + 0x81, 0x69, 0xF0, 0xE4, 0x90, 0x81, 0x76, 0xF0, + 0x90, 0x81, 0x66, 0xF0, 0x90, 0x81, 0x66, 0xE0, + 0xFF, 0xC3, 0x94, 0x40, 0x50, 0x15, 0x74, 0x79, + 0x2F, 0xF5, 0x82, 0xE4, 0x34, 0x81, 0xF5, 0x83, + 0x74, 0xFF, 0xF0, 0x90, 0x81, 0x66, 0xE0, 0x04, + 0xF0, 0x80, 0xE1, 0xE4, 0x90, 0x81, 0x66, 0xF0, + 0x90, 0x81, 0x69, 0xE0, 0xFF, 0x90, 0x81, 0x66, + 0xE0, 0xFE, 0xC3, 0x9F, 0x40, 0x03, 0x02, 0x68, + 0x12, 0x74, 0xDF, 0x2E, 0xF9, 0xE4, 0x34, 0x86, + 0x75, 0x13, 0x01, 0xF5, 0x14, 0x89, 0x15, 0x75, + 0x16, 0x0A, 0x7B, 0x01, 0x7A, 0x81, 0x79, 0x5B, + 0x12, 0x2B, 0xED, 0x90, 0x81, 0x5C, 0xE0, 0xFF, + 0x12, 0x2F, 0x27, 0xEF, 0x04, 0x90, 0x81, 0x76, + 0xF0, 0x90, 0x81, 0x5B, 0xE0, 0xFF, 0xA3, 0xE0, + 0xFD, 0x12, 0x31, 0xEA, 0xEF, 0x24, 0xC8, 0x90, + 0x81, 0x78, 0xF0, 0x75, 0xF0, 0x08, 0xA4, 0xF0, + 0x90, 0x81, 0x5C, 0xE0, 0x54, 0x0F, 0x90, 0x81, + 0x77, 0xF0, 0xE4, 0x90, 0x81, 0x65, 0xF0, 0x90, + 0x81, 0x67, 0xF0, 0x90, 0x81, 0x67, 0xE0, 0xFF, + 0xC3, 0x94, 0x04, 0x50, 0x57, 0x90, 0x81, 0x77, + 0xE0, 0xFE, 0xA8, 0x07, 0x08, 0x80, 0x02, 0xC3, + 0x13, 0xD8, 0xFC, 0x20, 0xE0, 0x3E, 0x90, 0x81, + 0x67, 0xE0, 0x25, 0xE0, 0xFF, 0x90, 0x81, 0x78, + 0xE0, 0x2F, 0x24, 0x79, 0xF9, 0xE4, 0x34, 0x81, + 0xFA, 0x7B, 0x01, 0xC0, 0x03, 0xC0, 0x01, 0x90, + 0x81, 0x65, 0xE0, 0x75, 0xF0, 0x02, 0xA4, 0x24, + 0x5D, 0xF9, 0x74, 0x81, 0x35, 0xF0, 0x8B, 0x13, + 0xF5, 0x14, 0x89, 0x15, 0x75, 0x16, 0x02, 0xD0, + 0x01, 0xD0, 0x03, 0x12, 0x2B, 0xED, 0x90, 0x81, + 0x65, 0xE0, 0x04, 0xF0, 0x90, 0x81, 0x67, 0xE0, + 0x04, 0xF0, 0x80, 0x9F, 0x90, 0x81, 0x76, 0xE0, + 0xFF, 0x90, 0x81, 0x66, 0xE0, 0x2F, 0xF0, 0x02, + 0x67, 0x40, 0xE4, 0x90, 0x81, 0x6A, 0xF0, 0x90, + 0x81, 0x6A, 0xE0, 0xC3, 0x94, 0x40, 0x40, 0x02, + 0x41, 0xAF, 0xE0, 0xFF, 0x24, 0x79, 0xF5, 0x82, + 0xE4, 0x34, 0x81, 0xF5, 0x83, 0xE0, 0x90, 0x81, + 0x6C, 0xF0, 0xE0, 0xFE, 0x54, 0xF0, 0xC4, 0x54, + 0x0F, 0xFD, 0x90, 0x81, 0x6B, 0xF0, 0xEE, 0x54, + 0x0F, 0xFE, 0xA3, 0xF0, 0x74, 0x7A, 0x2F, 0xF5, + 0x82, 0xE4, 0x34, 0x81, 0xF5, 0x83, 0xE0, 0x90, + 0x81, 0x6D, 0xF0, 0xFC, 0xEE, 0xFE, 0xEC, 0xFB, + 0xEB, 0xFF, 0x90, 0x81, 0x72, 0xEE, 0xF0, 0xA3, + 0xEF, 0xF0, 0xED, 0x12, 0x45, 0x28, 0x68, 0x8B, + 0x00, 0x68, 0xC2, 0x01, 0x69, 0x73, 0x02, 0x6A, + 0xA0, 0x03, 0x69, 0x8E, 0x04, 0x69, 0xAF, 0x05, + 0x69, 0xAF, 0x06, 0x69, 0xAF, 0x07, 0x69, 0xAF, + 0x08, 0x6A, 0x33, 0x09, 0x6A, 0x69, 0x0A, 0x00, + 0x00, 0x6A, 0xAF, 0x90, 0x81, 0x6A, 0xE0, 0xFD, + 0x24, 0x7C, 0xF5, 0x82, 0xE4, 0x34, 0x81, 0xF5, + 0x83, 0xE0, 0xFE, 0x74, 0x7B, 0x2D, 0xF5, 0x82, + 0xE4, 0x34, 0x81, 0xF5, 0x83, 0xE0, 0xFD, 0xED, + 0xFF, 0x90, 0x81, 0x74, 0xEE, 0xF0, 0xFC, 0xA3, + 0xEF, 0xF0, 0x90, 0x81, 0x6D, 0xE0, 0xFF, 0x12, + 0x2F, 0x96, 0x90, 0x81, 0x68, 0x74, 0x02, 0xF0, + 0x41, 0xA0, 0x90, 0x81, 0x6A, 0xE0, 0x24, 0x7C, + 0xF5, 0x82, 0xE4, 0x34, 0x81, 0xF5, 0x83, 0xE0, + 0xFF, 0xE4, 0xFC, 0xFD, 0xFE, 0x78, 0x08, 0x12, + 0x20, 0xBB, 0xA8, 0x04, 0xA9, 0x05, 0xAA, 0x06, + 0xAB, 0x07, 0x90, 0x81, 0x6A, 0xE0, 0x24, 0x7B, + 0xF5, 0x82, 0xE4, 0x34, 0x81, 0xF5, 0x83, 0xE0, + 0xFF, 0xE4, 0xFC, 0xFD, 0xFE, 0x12, 0x44, 0xCC, + 0xC0, 0x04, 0xC0, 0x05, 0xC0, 0x06, 0xC0, 0x07, + 0x90, 0x81, 0x6A, 0xE0, 0x24, 0x7D, 0xF5, 0x82, + 0xE4, 0x34, 0x81, 0xF5, 0x83, 0xE0, 0xFF, 0xE4, + 0xFC, 0xFD, 0xFE, 0x78, 0x10, 0x12, 0x20, 0xBB, + 0xD0, 0x03, 0xD0, 0x02, 0xD0, 0x01, 0xD0, 0x00, + 0x12, 0x44, 0xCC, 0xC0, 0x04, 0xC0, 0x05, 0xC0, + 0x06, 0xC0, 0x07, 0x90, 0x81, 0x6A, 0xE0, 0x24, + 0x7E, 0xF5, 0x82, 0xE4, 0x34, 0x81, 0xF5, 0x83, + 0xE0, 0xFF, 0xE4, 0xFC, 0xFD, 0xFE, 0x78, 0x18, + 0x12, 0x20, 0xBB, 0xD0, 0x03, 0xD0, 0x02, 0xD0, + 0x01, 0xD0, 0x00, 0x12, 0x44, 0xCC, 0x90, 0x81, + 0x6E, 0x12, 0x20, 0xCE, 0x90, 0x81, 0x6E, 0x12, + 0x44, 0xD9, 0x90, 0x85, 0x96, 0x12, 0x20, 0xCE, + 0x90, 0x81, 0x72, 0xE0, 0xFE, 0xA3, 0xE0, 0xFF, + 0x12, 0x2E, 0xE4, 0x90, 0x81, 0x68, 0x74, 0x04, + 0xF0, 0x41, 0xA0, 0x90, 0x81, 0x6D, 0xE0, 0xFD, + 0x90, 0x81, 0x6A, 0xE0, 0x24, 0x7B, 0xF5, 0x82, + 0xE4, 0x34, 0x81, 0xF5, 0x83, 0xE0, 0xFB, 0xE4, + 0xFF, 0x12, 0x30, 0xC7, 0x80, 0x19, 0x90, 0x81, + 0x6D, 0xE0, 0xFD, 0x90, 0x81, 0x6A, 0xE0, 0x24, + 0x7B, 0xF5, 0x82, 0xE4, 0x34, 0x81, 0xF5, 0x83, + 0xE0, 0xFB, 0xE4, 0xFF, 0x12, 0x30, 0x6A, 0x90, + 0x81, 0x68, 0x74, 0x01, 0xF0, 0x41, 0xA0, 0x90, + 0x81, 0x68, 0x74, 0x02, 0xF0, 0x90, 0x81, 0x6A, + 0xE0, 0x24, 0x7C, 0xF5, 0x82, 0xE4, 0x34, 0x81, + 0xF5, 0x83, 0xE0, 0xFF, 0xE4, 0xFC, 0xFD, 0xFE, + 0x78, 0x08, 0x12, 0x20, 0xBB, 0xA8, 0x04, 0xA9, + 0x05, 0xAA, 0x06, 0xAB, 0x07, 0x90, 0x81, 0x6A, + 0xE0, 0x24, 0x7B, 0xF5, 0x82, 0xE4, 0x34, 0x81, + 0xF5, 0x83, 0xE0, 0xFF, 0xE4, 0xFC, 0xFD, 0xFE, + 0x12, 0x44, 0xCC, 0xC0, 0x04, 0xC0, 0x05, 0xC0, + 0x06, 0xC0, 0x07, 0x90, 0x81, 0x6C, 0xE0, 0xFF, + 0xE4, 0xFC, 0xFD, 0xFE, 0x78, 0x10, 0x12, 0x20, + 0xBB, 0xD0, 0x03, 0xD0, 0x02, 0xD0, 0x01, 0xD0, + 0x00, 0x12, 0x44, 0xCC, 0x90, 0x81, 0x6E, 0x12, + 0x20, 0xCE, 0x90, 0x81, 0x6B, 0xE0, 0x24, 0xFB, + 0xFF, 0xC0, 0x07, 0x90, 0x81, 0x6E, 0x12, 0x44, + 0xD9, 0x90, 0x81, 0xF9, 0x12, 0x20, 0xCE, 0x90, + 0x81, 0x6D, 0xE0, 0xFD, 0xD0, 0x07, 0x12, 0x55, + 0x1C, 0x80, 0x6D, 0x90, 0x81, 0x68, 0x74, 0x01, + 0xF0, 0x90, 0x81, 0x6A, 0xE0, 0x24, 0x7B, 0xF9, + 0xE4, 0x34, 0x81, 0x75, 0x13, 0x01, 0xF5, 0x14, + 0x89, 0x15, 0x75, 0x16, 0x01, 0x7B, 0xFE, 0x7A, + 0x80, 0x79, 0x33, 0x12, 0x2B, 0xED, 0x90, 0x81, + 0x6D, 0xE0, 0xFF, 0x90, 0x81, 0x6C, 0xE0, 0xFD, + 0xE4, 0x90, 0x81, 0xBC, 0xF0, 0x7B, 0x04, 0x80, + 0x34, 0x90, 0x81, 0x68, 0x74, 0x04, 0xF0, 0x90, + 0x81, 0x6A, 0xE0, 0x24, 0x7B, 0xF9, 0xE4, 0x34, + 0x81, 0x75, 0x13, 0x01, 0xF5, 0x14, 0x89, 0x15, + 0x75, 0x16, 0x04, 0x7B, 0xFE, 0x7A, 0x80, 0x79, + 0x33, 0x12, 0x2B, 0xED, 0x90, 0x81, 0x6D, 0xE0, + 0xFF, 0x90, 0x81, 0x6C, 0xE0, 0xFD, 0xE4, 0x90, + 0x81, 0xBC, 0xF0, 0x7B, 0x06, 0x12, 0x63, 0xE1, + 0x90, 0x81, 0x68, 0xE0, 0x24, 0x02, 0xFF, 0x90, + 0x81, 0x6A, 0xE0, 0x2F, 0xF0, 0x01, 0x17, 0x22, + 0x90, 0x02, 0x09, 0xE0, 0xFD, 0x12, 0x1F, 0xA4, + 0xFE, 0xAF, 0x05, 0xED, 0x2E, 0x90, 0x80, 0x3D, + 0xF0, 0x90, 0x00, 0x01, 0x12, 0x1F, 0xBD, 0xFF, + 0xED, 0x2F, 0x90, 0x80, 0x3E, 0xF0, 0x90, 0x00, + 0x02, 0x12, 0x1F, 0xBD, 0xFF, 0xED, 0x2F, 0x90, + 0x80, 0x3F, 0xF0, 0x90, 0x00, 0x03, 0x12, 0x1F, + 0xBD, 0xFF, 0xED, 0x2F, 0x90, 0x80, 0x40, 0xF0, + 0x90, 0x00, 0x04, 0x12, 0x1F, 0xBD, 0xFF, 0xAE, + 0x05, 0xED, 0x2F, 0x90, 0x80, 0x41, 0xF0, 0x22, + 0x90, 0x00, 0x02, 0x12, 0x1F, 0xBD, 0xFF, 0x30, + 0xE0, 0x26, 0x12, 0x1F, 0xA4, 0x90, 0x81, 0x38, + 0xF0, 0x90, 0x00, 0x01, 0x12, 0x1F, 0xBD, 0x90, + 0x81, 0x39, 0xF0, 0xEF, 0x54, 0xFE, 0xFF, 0xA3, + 0xE0, 0x54, 0x01, 0x4F, 0xF0, 0x90, 0x00, 0x03, + 0x12, 0x1F, 0xBD, 0x90, 0x81, 0x3B, 0xF0, 0x22, + 0x90, 0x81, 0x38, 0x74, 0x01, 0xF0, 0xA3, 0x74, + 0x05, 0xF0, 0xA3, 0xE0, 0x54, 0x01, 0x44, 0x28, + 0xF0, 0xA3, 0x74, 0x05, 0xF0, 0x22, 0x12, 0x1F, + 0xA4, 0x90, 0x81, 0x3E, 0xF0, 0x90, 0x81, 0x3E, + 0xE0, 0x90, 0x01, 0xE7, 0xF0, 0x22, 0x12, 0x1F, + 0xA4, 0x90, 0x81, 0x4A, 0xF0, 0x90, 0x00, 0x01, + 0x12, 0x1F, 0xBD, 0x90, 0x81, 0x4B, 0xF0, 0x22, + 0xD3, 0x10, 0xAF, 0x01, 0xC3, 0xC0, 0xD0, 0x90, + 0x81, 0xFD, 0xEE, 0xF0, 0xA3, 0xEF, 0xF0, 0xE4, + 0xA3, 0xF0, 0xA3, 0xF0, 0x90, 0x81, 0xFD, 0xE0, + 0xFE, 0xA3, 0xE0, 0xF5, 0x82, 0x8E, 0x83, 0xE0, + 0x60, 0x2D, 0xC3, 0x90, 0x82, 0x00, 0xE0, 0x94, + 0xE8, 0x90, 0x81, 0xFF, 0xE0, 0x94, 0x03, 0x40, + 0x0B, 0x90, 0x01, 0xC0, 0xE0, 0x44, 0x80, 0xF0, + 0x7F, 0x00, 0x80, 0x15, 0x90, 0x81, 0xFF, 0xE4, + 0x75, 0xF0, 0x01, 0x12, 0x44, 0xA9, 0x7F, 0x0A, + 0x7E, 0x00, 0x12, 0x32, 0xAA, 0x80, 0xC5, 0x7F, + 0x01, 0xD0, 0xD0, 0x92, 0xAF, 0x22, 0xD3, 0x10, + 0xAF, 0x01, 0xC3, 0xC0, 0xD0, 0x90, 0x81, 0xD1, + 0x12, 0x45, 0x1F, 0x90, 0x82, 0x0A, 0xE0, 0xFF, + 0x04, 0xF0, 0x90, 0x00, 0x01, 0xEF, 0x12, 0x1F, + 0xFC, 0x7F, 0xAF, 0x7E, 0x01, 0x71, 0x60, 0xEF, + 0x60, 0x3A, 0x90, 0x81, 0xD1, 0x12, 0x45, 0x16, + 0x8B, 0x13, 0x8A, 0x14, 0x89, 0x15, 0x90, 0x00, + 0x0E, 0x12, 0x1F, 0xBD, 0x24, 0x02, 0xF5, 0x16, + 0x7B, 0x01, 0x7A, 0x01, 0x79, 0xA0, 0x12, 0x2B, + 0xED, 0x90, 0x81, 0xD1, 0x12, 0x45, 0x16, 0x90, + 0x00, 0x0E, 0x12, 0x1F, 0xBD, 0x90, 0x01, 0xAE, + 0xF0, 0xA3, 0x74, 0xFF, 0xF0, 0x90, 0x01, 0xCB, + 0xE0, 0x64, 0x80, 0xF0, 0xD0, 0xD0, 0x92, 0xAF, + 0x22, 0xD3, 0x10, 0xAF, 0x01, 0xC3, 0xC0, 0xD0, + 0xE4, 0xFF, 0x90, 0x80, 0xD9, 0xE0, 0xFE, 0x90, + 0x80, 0xD8, 0xE0, 0xFD, 0xB5, 0x06, 0x04, 0x7E, + 0x01, 0x80, 0x02, 0x7E, 0x00, 0xEE, 0x64, 0x01, + 0x60, 0x32, 0x90, 0x01, 0xAF, 0xE0, 0x70, 0x13, + 0xED, 0x75, 0xF0, 0x0F, 0xA4, 0x24, 0x42, 0xF9, + 0x74, 0x80, 0x35, 0xF0, 0xFA, 0x7B, 0x01, 0x71, + 0xB6, 0x7F, 0x01, 0xEF, 0x60, 0x16, 0x90, 0x80, + 0xD8, 0xE0, 0x04, 0xF0, 0xE0, 0x7F, 0x00, 0xB4, + 0x0A, 0x02, 0x7F, 0x01, 0xEF, 0x60, 0x05, 0xE4, + 0x90, 0x80, 0xD8, 0xF0, 0xD0, 0xD0, 0x92, 0xAF, + 0x22, 0x8F, 0x0D, 0x22, 0x8F, 0x0E, 0x22, 0x22, + 0x90, 0x01, 0x34, 0xE0, 0x55, 0x3D, 0xF5, 0x41, + 0xA3, 0xE0, 0x55, 0x3E, 0xF5, 0x42, 0xA3, 0xE0, + 0x55, 0x3F, 0xF5, 0x43, 0xA3, 0xE0, 0x55, 0x40, + 0xF5, 0x44, 0x90, 0x01, 0x34, 0xE5, 0x41, 0xF0, + 0xA3, 0xE5, 0x42, 0xF0, 0xA3, 0xE5, 0x43, 0xF0, + 0xA3, 0xE5, 0x44, 0xF0, 0x22, 0x90, 0x01, 0x3C, + 0xE0, 0x55, 0x45, 0xF5, 0x49, 0xA3, 0xE0, 0x55, + 0x46, 0xF5, 0x4A, 0xA3, 0xE0, 0x55, 0x47, 0xF5, + 0x4B, 0xA3, 0xE0, 0x55, 0x48, 0xF5, 0x4C, 0x90, + 0x01, 0x3C, 0xE5, 0x49, 0xF0, 0xA3, 0xE5, 0x4A, + 0xF0, 0xA3, 0xE5, 0x4B, 0xF0, 0xA3, 0xE5, 0x4C, + 0xF0, 0x53, 0x91, 0xDF, 0x22, 0x90, 0x81, 0x1F, + 0xE0, 0x30, 0xE0, 0x05, 0xE4, 0xA3, 0xF0, 0xA3, + 0xF0, 0x22, 0x90, 0x80, 0xDE, 0xE0, 0x64, 0x01, + 0x70, 0x19, 0x90, 0x81, 0x27, 0xE0, 0x60, 0x13, + 0x90, 0x01, 0x57, 0xE4, 0xF0, 0x90, 0x01, 0x3C, + 0x74, 0x02, 0x12, 0x4F, 0xF4, 0x90, 0x01, 0x57, + 0x74, 0x05, 0xF0, 0x22, 0x90, 0x80, 0xDE, 0xE0, + 0x64, 0x01, 0x70, 0x26, 0x90, 0x81, 0x27, 0xE0, + 0x60, 0x20, 0x90, 0x01, 0x57, 0xE4, 0xF0, 0x90, + 0x01, 0x3C, 0x74, 0x02, 0xF0, 0x90, 0x81, 0x24, + 0xE0, 0x54, 0xFB, 0xF0, 0x90, 0x81, 0x2B, 0xE0, + 0x54, 0xFD, 0xF0, 0x54, 0x07, 0x70, 0x03, 0x12, + 0x47, 0x2A, 0x22, 0x90, 0x80, 0xDE, 0xE0, 0xB4, + 0x01, 0x14, 0x90, 0x81, 0x27, 0xE0, 0x60, 0x0E, + 0x90, 0x81, 0x26, 0xE0, 0x54, 0x0F, 0x64, 0x02, + 0x60, 0x02, 0x80, 0x03, 0xD1, 0x7F, 0x22, 0x90, + 0x04, 0x1D, 0xE0, 0x70, 0x13, 0x90, 0x80, 0x3E, + 0xE0, 0xFF, 0xE4, 0xFD, 0xB1, 0x69, 0x8E, 0x4E, + 0x8F, 0x4F, 0x90, 0x04, 0x1F, 0x74, 0x20, 0xF0, + 0x22, 0xD3, 0x10, 0xAF, 0x01, 0xC3, 0xC0, 0xD0, + 0x90, 0x82, 0x0E, 0xED, 0xF0, 0x90, 0x82, 0x0D, + 0xEF, 0xF0, 0xE4, 0xFD, 0xFC, 0xF1, 0x37, 0x7C, + 0x00, 0xAD, 0x07, 0x90, 0x82, 0x0D, 0xE0, 0x90, + 0x04, 0x25, 0xF0, 0x90, 0x82, 0x0E, 0xE0, 0x60, + 0x0E, 0x74, 0x0F, 0x2F, 0xF5, 0x82, 0xE4, 0x34, + 0xFC, 0xF5, 0x83, 0xE0, 0x44, 0x80, 0xF0, 0xAF, + 0x05, 0x74, 0x08, 0x2F, 0xF5, 0x82, 0xE4, 0x34, + 0xFC, 0xF5, 0x83, 0xE4, 0xF0, 0x74, 0x09, 0x2F, + 0xF5, 0x82, 0xE4, 0x34, 0xFC, 0xF5, 0x83, 0xE0, + 0x54, 0xF0, 0xF0, 0x74, 0x21, 0x2D, 0xF5, 0x82, + 0xE4, 0x34, 0xFC, 0xF5, 0x83, 0xE0, 0x54, 0xF7, + 0xF0, 0xAE, 0x04, 0xAF, 0x05, 0xD0, 0xD0, 0x92, + 0xAF, 0x22, 0x8F, 0x4E, 0xF1, 0x4B, 0xBF, 0x01, + 0x18, 0x90, 0x80, 0x40, 0xE0, 0xFF, 0x7D, 0x01, + 0xB1, 0x69, 0xAD, 0x07, 0xAC, 0x06, 0xAF, 0x4E, + 0x12, 0x4F, 0x82, 0x90, 0x04, 0x1F, 0x74, 0x20, + 0xF0, 0x22, 0x90, 0x06, 0xA9, 0xE0, 0x90, 0x81, + 0x4C, 0xF0, 0xE0, 0xFD, 0x54, 0xC0, 0x70, 0x09, + 0x90, 0x81, 0x2B, 0xE0, 0x54, 0xFE, 0xF0, 0x80, + 0x72, 0xED, 0x30, 0xE6, 0x4B, 0x90, 0x81, 0x27, + 0xE0, 0x64, 0x02, 0x70, 0x2A, 0x90, 0x81, 0x24, + 0xE0, 0xFF, 0xC3, 0x13, 0x20, 0xE0, 0x09, 0x90, + 0x81, 0x2B, 0xE0, 0x44, 0x01, 0xF0, 0x80, 0x28, + 0x90, 0x81, 0x26, 0xE0, 0x54, 0x0F, 0x64, 0x01, + 0x70, 0x2D, 0x90, 0x81, 0x2B, 0xE0, 0x44, 0x04, + 0xF0, 0x7F, 0x01, 0xB1, 0xD2, 0x80, 0x20, 0x90, + 0x81, 0x2B, 0xE0, 0x44, 0x01, 0xF0, 0x90, 0x81, + 0x26, 0xE0, 0x54, 0x0F, 0x64, 0x02, 0x60, 0x04, + 0xB1, 0x4F, 0x80, 0x0B, 0xD1, 0x7F, 0x80, 0x07, + 0x90, 0x81, 0x2B, 0xE0, 0x54, 0xFE, 0xF0, 0x90, + 0x81, 0x4C, 0xE0, 0x90, 0x81, 0x2B, 0x30, 0xE7, + 0x11, 0x12, 0x4F, 0xF1, 0x90, 0x01, 0x57, 0x74, + 0x05, 0xF0, 0x90, 0x81, 0x24, 0xE0, 0x44, 0x04, + 0xF0, 0x22, 0xE0, 0x54, 0xFD, 0xF0, 0x22, 0x90, + 0x01, 0x5F, 0xE4, 0xF0, 0x90, 0x01, 0x3C, 0x74, + 0x08, 0xF0, 0xE4, 0xF5, 0x1D, 0x90, 0x81, 0x3A, + 0xE0, 0xC3, 0x13, 0x54, 0x7F, 0xF5, 0x1E, 0xE4, + 0xFB, 0xFD, 0x7F, 0x5C, 0x7E, 0x01, 0x12, 0x50, + 0x05, 0x90, 0x01, 0x5F, 0x74, 0x05, 0xF0, 0x90, + 0x06, 0x92, 0x74, 0x02, 0xF0, 0x90, 0x81, 0x24, + 0xE0, 0x44, 0x10, 0xF0, 0x90, 0x81, 0x2A, 0xE0, + 0x64, 0x0C, 0x60, 0x0C, 0xE4, 0xFD, 0x7F, 0x0C, + 0x12, 0x47, 0x3D, 0xE4, 0xFF, 0x12, 0x4F, 0x0D, + 0x22, 0xE4, 0x90, 0x81, 0x4C, 0xF0, 0x90, 0x06, + 0xA9, 0xE0, 0x90, 0x81, 0x4C, 0xF0, 0xE0, 0x54, + 0xC0, 0x70, 0x0D, 0x90, 0x81, 0x2B, 0xE0, 0x54, + 0xFE, 0xF0, 0x54, 0xFD, 0xF0, 0x02, 0x47, 0x2A, + 0x90, 0x81, 0x4C, 0xE0, 0x30, 0xE6, 0x21, 0x90, + 0x81, 0x27, 0xE0, 0x64, 0x01, 0x70, 0x20, 0x90, + 0x81, 0x2B, 0xE0, 0x44, 0x01, 0xF0, 0x90, 0x81, + 0x26, 0xE0, 0x54, 0x0F, 0x64, 0x02, 0x60, 0x04, + 0xB1, 0x4F, 0x80, 0x0B, 0xD1, 0x7F, 0x80, 0x07, + 0x90, 0x81, 0x2B, 0xE0, 0x54, 0xFE, 0xF0, 0x90, + 0x81, 0x4C, 0xE0, 0x90, 0x81, 0x2B, 0x30, 0xE7, + 0x11, 0x12, 0x4F, 0xF1, 0x90, 0x01, 0x57, 0x74, + 0x05, 0xF0, 0x90, 0x81, 0x24, 0xE0, 0x44, 0x04, + 0xF0, 0x22, 0xE0, 0x54, 0xFD, 0xF0, 0x22, 0xE4, + 0xFE, 0xEF, 0xC3, 0x13, 0xFD, 0xEF, 0x30, 0xE0, + 0x02, 0x7E, 0x80, 0x90, 0xFD, 0x10, 0xED, 0xF0, + 0xAF, 0x06, 0x22, 0xD3, 0x10, 0xAF, 0x01, 0xC3, + 0xC0, 0xD0, 0x90, 0x04, 0x1D, 0xE0, 0x60, 0x1A, + 0x90, 0x05, 0x22, 0xE0, 0x54, 0x90, 0x60, 0x07, + 0x90, 0x01, 0xC0, 0xE0, 0x44, 0x08, 0xF0, 0x90, + 0x01, 0xC6, 0xE0, 0x30, 0xE1, 0xE4, 0x7F, 0x00, + 0x80, 0x02, 0x7F, 0x01, 0xD0, 0xD0, 0x92, 0xAF, + 0x22, 0x90, 0x81, 0x27, 0xE0, 0x60, 0x03, 0x12, + 0x73, 0xE1, 0x90, 0x81, 0x3F, 0xE0, 0x30, 0xE0, + 0x03, 0x12, 0x49, 0xDD, 0x22, 0x90, 0x81, 0x27, + 0xE0, 0x60, 0x35, 0x90, 0x06, 0x92, 0xE0, 0x30, + 0xE1, 0x24, 0xE4, 0xF5, 0x1D, 0x90, 0x81, 0x3A, + 0xE0, 0xC3, 0x13, 0x54, 0x7F, 0xF5, 0x1E, 0xE4, + 0xFB, 0xFD, 0x7F, 0x5C, 0x7E, 0x01, 0x12, 0x50, + 0x05, 0x90, 0x01, 0x5F, 0x74, 0x05, 0xF0, 0x90, + 0x06, 0x92, 0x74, 0x02, 0xF0, 0x22, 0x90, 0x81, + 0x24, 0xE0, 0x54, 0xEF, 0xF0, 0x12, 0x47, 0x2A, + 0x22, 0x12, 0x71, 0x48, 0x90, 0x81, 0x4D, 0xEF, + 0xF0, 0x90, 0x81, 0x24, 0x30, 0xE0, 0x06, 0xE0, + 0x44, 0x01, 0xF0, 0x80, 0x04, 0xE0, 0x54, 0xFE, + 0xF0, 0x90, 0x81, 0x4D, 0xE0, 0x30, 0xE6, 0x11, + 0x90, 0x01, 0x2F, 0xE0, 0x30, 0xE7, 0x04, 0xE4, + 0xF0, 0x80, 0x06, 0x90, 0x01, 0x2F, 0x74, 0x80, + 0xF0, 0x90, 0x81, 0x24, 0xE0, 0x30, 0xE0, 0x1A, + 0x90, 0x81, 0x32, 0xE4, 0xF0, 0xA3, 0x74, 0x07, + 0xF0, 0x90, 0x81, 0x32, 0xA3, 0xE0, 0x90, 0x05, + 0x58, 0xF0, 0x90, 0x04, 0xEC, 0xE0, 0x54, 0xDD, + 0xF0, 0x22, 0x90, 0x04, 0xEC, 0xE0, 0x44, 0x22, + 0xF0, 0x22, 0x90, 0x81, 0x4A, 0xE0, 0x60, 0x0F, + 0xE4, 0xF0, 0x90, 0x05, 0x53, 0xE0, 0x44, 0x01, + 0xF0, 0x90, 0x05, 0xFD, 0xE0, 0x04, 0xF0, 0x22, + 0x90, 0x81, 0x24, 0xE0, 0xFF, 0xC4, 0x13, 0x13, + 0x54, 0x03, 0x30, 0xE0, 0x27, 0xEF, 0x54, 0xBF, + 0xF0, 0x90, 0x04, 0xE0, 0xE0, 0x90, 0x81, 0x25, + 0x30, 0xE0, 0x06, 0xE0, 0x44, 0x01, 0xF0, 0x80, + 0x10, 0xE0, 0x54, 0xFE, 0xF0, 0x90, 0x01, 0xB9, + 0x74, 0x01, 0xF0, 0x90, 0x01, 0xB8, 0x74, 0x04, + 0xF0, 0x12, 0x47, 0x2A, 0xE4, 0xFF, 0x90, 0x81, + 0x45, 0xE0, 0x30, 0xE0, 0x48, 0x90, 0x81, 0x49, + 0xE0, 0xFD, 0x60, 0x41, 0x74, 0x01, 0x7E, 0x00, + 0xA8, 0x07, 0x08, 0x80, 0x05, 0xC3, 0x33, 0xCE, + 0x33, 0xCE, 0xD8, 0xF9, 0xFF, 0x90, 0x04, 0xE0, + 0xE0, 0xFB, 0xEF, 0x5B, 0x60, 0x06, 0xE4, 0x90, + 0x81, 0x49, 0xF0, 0x22, 0x90, 0x81, 0x47, 0xE0, + 0xD3, 0x9D, 0x50, 0x10, 0x90, 0x01, 0xC7, 0x74, + 0x10, 0xF0, 0x11, 0xBE, 0x90, 0x81, 0x45, 0xE0, + 0x54, 0xFE, 0xF0, 0x22, 0x12, 0x4F, 0x0B, 0x90, + 0x81, 0x49, 0xE0, 0x04, 0xF0, 0x22, 0x90, 0x80, + 0x3C, 0xE0, 0x64, 0x02, 0x60, 0x07, 0x90, 0x06, + 0x90, 0xE0, 0x44, 0x01, 0xF0, 0x22, 0x90, 0x81, + 0x24, 0xE0, 0xFF, 0xC4, 0x13, 0x13, 0x13, 0x54, + 0x01, 0x30, 0xE0, 0x2C, 0xEF, 0x54, 0x7F, 0xF0, + 0x90, 0x04, 0xE0, 0xE0, 0x90, 0x81, 0x25, 0x30, + 0xE1, 0x06, 0xE0, 0x44, 0x02, 0xF0, 0x80, 0x0F, + 0xE0, 0x54, 0xFD, 0xF0, 0x90, 0x01, 0xB9, 0x74, + 0x01, 0xF0, 0x90, 0x01, 0xB8, 0x04, 0xF0, 0x90, + 0x81, 0x27, 0xE0, 0x60, 0x03, 0x12, 0x47, 0x2A, + 0x7F, 0x01, 0x01, 0x6E, 0xC3, 0xEE, 0x94, 0x01, + 0x40, 0x0A, 0x0D, 0xED, 0x13, 0x90, 0xFD, 0x10, + 0xF0, 0xE4, 0x2F, 0xFF, 0x22, 0xC3, 0xEE, 0x94, + 0x01, 0x40, 0x24, 0x90, 0xFD, 0x11, 0xE0, 0x6D, + 0x70, 0x1A, 0x90, 0x01, 0x17, 0xE0, 0xB5, 0x05, + 0x0D, 0x90, 0x01, 0xE4, 0x74, 0x77, 0xF0, 0x90, + 0xFD, 0x11, 0xE4, 0xF0, 0x80, 0x06, 0xED, 0x04, + 0x90, 0xFD, 0x11, 0xF0, 0xE4, 0x2F, 0xFF, 0x22, + 0xE4, 0x90, 0x81, 0x4E, 0xF0, 0xA3, 0xF0, 0xA3, + 0xF0, 0x90, 0x00, 0x83, 0xE0, 0x90, 0x81, 0x4E, + 0xF0, 0x90, 0x00, 0x83, 0xE0, 0xFE, 0x90, 0x81, + 0x4E, 0xE0, 0xFF, 0xB5, 0x06, 0x01, 0x22, 0xC3, + 0x90, 0x81, 0x50, 0xE0, 0x94, 0x64, 0x90, 0x81, + 0x4F, 0xE0, 0x94, 0x00, 0x40, 0x0D, 0x90, 0x01, + 0xC0, 0xE0, 0x44, 0x40, 0xF0, 0x90, 0x81, 0x4E, + 0xE0, 0xFF, 0x22, 0x90, 0x81, 0x4F, 0xE4, 0x75, + 0xF0, 0x01, 0x12, 0x44, 0xA9, 0x80, 0xC2, 0x74, + 0x45, 0x2F, 0xF8, 0xE6, 0xFE, 0xED, 0xF4, 0x5E, + 0xFE, 0xF6, 0x74, 0x38, 0x2F, 0xF5, 0x82, 0xE4, + 0x34, 0x01, 0xF5, 0x83, 0xEE, 0xF0, 0x22, 0xD3, + 0x10, 0xAF, 0x01, 0xC3, 0xC0, 0xD0, 0x90, 0x82, + 0x12, 0xED, 0xF0, 0x90, 0x82, 0x11, 0xEF, 0xF0, + 0xD3, 0x94, 0x07, 0x50, 0x70, 0xE0, 0xFF, 0x74, + 0x01, 0xA8, 0x07, 0x08, 0x80, 0x02, 0xC3, 0x33, + 0xD8, 0xFC, 0xF4, 0xFF, 0x90, 0x00, 0x47, 0xE0, + 0x5F, 0xFD, 0x7F, 0x47, 0x12, 0x32, 0x1E, 0x90, + 0x82, 0x11, 0xE0, 0xFF, 0x74, 0x01, 0xA8, 0x07, + 0x08, 0x80, 0x02, 0xC3, 0x33, 0xD8, 0xFC, 0xFF, + 0x90, 0x00, 0x46, 0xE0, 0x4F, 0xFD, 0x7F, 0x46, + 0x12, 0x32, 0x1E, 0x90, 0x82, 0x12, 0xE0, 0x60, + 0x18, 0x90, 0x82, 0x11, 0xE0, 0xFF, 0x74, 0x01, + 0xA8, 0x07, 0x08, 0x80, 0x02, 0xC3, 0x33, 0xD8, + 0xFC, 0xFF, 0x90, 0x00, 0x45, 0xE0, 0x4F, 0x80, + 0x17, 0x90, 0x82, 0x11, 0xE0, 0xFF, 0x74, 0x01, + 0xA8, 0x07, 0x08, 0x80, 0x02, 0xC3, 0x33, 0xD8, + 0xFC, 0xF4, 0xFF, 0x90, 0x00, 0x45, 0xE0, 0x5F, + 0xFD, 0x7F, 0x45, 0x80, 0x7E, 0x90, 0x82, 0x11, + 0xE0, 0x24, 0xF8, 0xF0, 0xE0, 0x24, 0x04, 0xFF, + 0x74, 0x01, 0xA8, 0x07, 0x08, 0x80, 0x02, 0xC3, + 0x33, 0xD8, 0xFC, 0xF4, 0xFF, 0x90, 0x00, 0x43, + 0xE0, 0x5F, 0xFD, 0x7F, 0x43, 0x12, 0x32, 0x1E, + 0x90, 0x82, 0x11, 0xE0, 0xFF, 0x74, 0x01, 0xA8, + 0x07, 0x08, 0x80, 0x02, 0xC3, 0x33, 0xD8, 0xFC, + 0xFF, 0x90, 0x00, 0x43, 0xE0, 0x4F, 0xFD, 0x7F, + 0x43, 0x12, 0x32, 0x1E, 0x90, 0x82, 0x12, 0xE0, + 0x60, 0x1D, 0x90, 0x82, 0x11, 0xE0, 0x24, 0x04, + 0xFF, 0x74, 0x01, 0xA8, 0x07, 0x08, 0x80, 0x02, + 0xC3, 0x33, 0xD8, 0xFC, 0xFF, 0x90, 0x00, 0x42, + 0xE0, 0x4F, 0xFD, 0x7F, 0x42, 0x80, 0x1C, 0x90, + 0x82, 0x11, 0xE0, 0x24, 0x04, 0xFF, 0x74, 0x01, + 0xA8, 0x07, 0x08, 0x80, 0x02, 0xC3, 0x33, 0xD8, + 0xFC, 0xF4, 0xFF, 0x90, 0x00, 0x42, 0xE0, 0x5F, + 0xFD, 0x7F, 0x42, 0x12, 0x32, 0x1E, 0xD0, 0xD0, + 0x92, 0xAF, 0x22, 0x90, 0x81, 0x24, 0xE0, 0x54, + 0xFB, 0xF0, 0xE4, 0x90, 0x81, 0x30, 0xF0, 0x90, + 0x81, 0x2B, 0xF0, 0x22, 0xEF, 0x24, 0xFE, 0x60, + 0x0C, 0x04, 0x70, 0x28, 0x90, 0x81, 0x2D, 0x74, + 0x01, 0xF0, 0xA3, 0xF0, 0x22, 0xED, 0x70, 0x0A, + 0x90, 0x81, 0x3B, 0xE0, 0x90, 0x81, 0x2D, 0xF0, + 0x80, 0x05, 0x90, 0x81, 0x2D, 0xED, 0xF0, 0x90, + 0x81, 0x2D, 0xE0, 0xA3, 0xF0, 0x90, 0x81, 0x25, + 0xE0, 0x44, 0x08, 0xF0, 0x22, 0x12, 0x4E, 0xAB, + 0xEF, 0x64, 0x01, 0x60, 0x08, 0x90, 0x01, 0xB8, + 0x74, 0x01, 0xF0, 0x80, 0x67, 0x90, 0x81, 0x2B, + 0xE0, 0xFF, 0x54, 0x03, 0x60, 0x08, 0x90, 0x01, + 0xB8, 0x74, 0x02, 0xF0, 0x80, 0x56, 0x90, 0x81, + 0x29, 0xE0, 0xFE, 0xE4, 0xC3, 0x9E, 0x50, 0x08, + 0x90, 0x01, 0xB8, 0x74, 0x04, 0xF0, 0x80, 0x44, + 0xEF, 0x30, 0xE2, 0x08, 0x90, 0x01, 0xB8, 0x74, + 0x08, 0xF0, 0x80, 0x38, 0x90, 0x81, 0x2B, 0xE0, + 0x30, 0xE4, 0x08, 0x90, 0x01, 0xB8, 0x74, 0x10, + 0xF0, 0x80, 0x29, 0x90, 0x81, 0x25, 0xE0, 0x13, + 0x13, 0x54, 0x3F, 0x20, 0xE0, 0x08, 0x90, 0x01, + 0xB8, 0x74, 0x20, 0xF0, 0x80, 0x16, 0x90, 0x81, + 0x3E, 0xE0, 0x60, 0x08, 0x90, 0x01, 0xB8, 0x74, + 0x80, 0xF0, 0x80, 0x08, 0x90, 0x01, 0xB8, 0xE4, + 0xF0, 0x7F, 0x01, 0x22, 0x90, 0x01, 0xB9, 0x74, + 0x04, 0xF0, 0x7F, 0x00, 0x22, 0xEF, 0x60, 0x42, + 0x90, 0x80, 0xDE, 0xE0, 0x64, 0x01, 0x70, 0x3A, + 0x90, 0x81, 0x25, 0xE0, 0x54, 0xFE, 0xF0, 0x90, + 0x05, 0x22, 0x74, 0x0F, 0xF0, 0x90, 0x06, 0x04, + 0xE0, 0x54, 0xBF, 0xF0, 0xE4, 0xFF, 0x12, 0x4F, + 0x0D, 0xBF, 0x01, 0x12, 0x90, 0x81, 0x24, 0xE0, + 0x44, 0x40, 0xF0, 0x90, 0x81, 0x2A, 0x74, 0x06, + 0xF0, 0x90, 0x81, 0x23, 0xF0, 0x22, 0x90, 0x01, + 0xB9, 0x74, 0x01, 0xF0, 0x90, 0x01, 0xB8, 0x74, + 0x08, 0xF0, 0x22, 0x90, 0x05, 0x22, 0x74, 0x6F, + 0xF0, 0x90, 0x05, 0x27, 0xE0, 0x54, 0xBF, 0xF0, + 0x90, 0x81, 0x2A, 0x74, 0x02, 0xF0, 0x90, 0x81, + 0x23, 0xF0, 0x22, 0x12, 0x54, 0x65, 0x90, 0x81, + 0x2A, 0x74, 0x0C, 0xF0, 0x90, 0x81, 0x23, 0xF0, + 0x22, 0x90, 0x81, 0x24, 0xE0, 0xFF, 0x13, 0x13, + 0x54, 0x3F, 0x30, 0xE0, 0x11, 0xEF, 0x54, 0xFB, + 0xF0, 0x90, 0x81, 0x2B, 0xE0, 0x54, 0xFD, 0xF0, + 0x54, 0x07, 0x70, 0x42, 0x80, 0x3D, 0x90, 0x81, + 0x30, 0xE0, 0x04, 0xF0, 0x90, 0x81, 0x2B, 0xE0, + 0x54, 0xEF, 0xF0, 0x90, 0x81, 0x30, 0xE0, 0xFF, + 0xB4, 0x01, 0x02, 0x80, 0x04, 0xEF, 0xB4, 0x02, + 0x06, 0x90, 0x05, 0x58, 0xE0, 0x04, 0xF0, 0x90, + 0x81, 0x38, 0xE0, 0xFF, 0x90, 0x81, 0x30, 0xE0, + 0xD3, 0x9F, 0x40, 0x0F, 0x90, 0x80, 0xDE, 0xE0, + 0xB4, 0x01, 0x0B, 0x90, 0x81, 0x25, 0xE0, 0x54, + 0xFB, 0xF0, 0x22, 0x12, 0x47, 0x2A, 0x22, 0x22, + 0x90, 0x05, 0x2B, 0xE0, 0x7F, 0x00, 0x30, 0xE7, + 0x02, 0x7F, 0x01, 0x22, 0x90, 0x05, 0x22, 0x74, + 0xFF, 0xF0, 0x90, 0x05, 0x27, 0xE0, 0x44, 0x40, + 0xF0, 0x90, 0x81, 0x22, 0x74, 0x03, 0xF0, 0x22, + 0x90, 0x05, 0x27, 0xE0, 0x44, 0x40, 0xF0, 0x12, + 0x49, 0xDD, 0x90, 0x81, 0x22, 0x74, 0x02, 0xF0, + 0x22, 0x12, 0x49, 0xE3, 0x90, 0x81, 0x22, 0x74, + 0x02, 0xF0, 0x22, 0x90, 0x05, 0x22, 0x74, 0x6F, + 0xF0, 0x90, 0x05, 0x27, 0xE0, 0x54, 0xBF, 0xF0, + 0x90, 0x81, 0x22, 0x74, 0x04, 0xF0, 0x22, 0xAE, + 0x07, 0x12, 0x51, 0x73, 0xBF, 0x01, 0x12, 0x90, + 0x81, 0x23, 0xE0, 0x64, 0x02, 0x60, 0x0A, 0xAF, + 0x06, 0x7D, 0x01, 0x12, 0x47, 0x3D, 0x7F, 0x01, + 0x22, 0x7F, 0x00, 0x22, 0x90, 0x01, 0x57, 0xE0, + 0x60, 0x48, 0xE4, 0xF0, 0x90, 0x01, 0x3C, 0x74, + 0x02, 0xF0, 0x90, 0x81, 0x24, 0xE0, 0xFF, 0x13, + 0x13, 0x54, 0x3F, 0x30, 0xE0, 0x0C, 0xEF, 0x54, + 0xFB, 0xF0, 0x90, 0x81, 0x2B, 0xE0, 0x54, 0xFD, + 0xF0, 0x22, 0x90, 0x81, 0x30, 0xE0, 0x04, 0xF0, + 0x90, 0x81, 0x2B, 0xE0, 0x54, 0xEF, 0xF0, 0x90, + 0x81, 0x38, 0xE0, 0xFF, 0x90, 0x81, 0x30, 0xE0, + 0xD3, 0x9F, 0x40, 0x0E, 0x90, 0x80, 0xDE, 0xE0, + 0xB4, 0x01, 0x07, 0x90, 0x81, 0x25, 0xE0, 0x54, + 0xFB, 0xF0, 0x22, 0x90, 0x80, 0x3F, 0xE0, 0xFF, + 0x7D, 0x01, 0x12, 0x6D, 0x69, 0x8E, 0x54, 0x8F, + 0x55, 0xAD, 0x55, 0xAC, 0x54, 0xAF, 0x53, 0x12, + 0x4F, 0x82, 0xAF, 0x55, 0xAE, 0x54, 0x90, 0x04, + 0x80, 0xE0, 0x54, 0x0F, 0xFD, 0xAC, 0x07, 0x74, + 0x11, 0x2C, 0xF5, 0x82, 0xE4, 0x34, 0xFC, 0xF5, + 0x83, 0xE0, 0x44, 0x01, 0xF0, 0x74, 0x11, 0x2C, + 0xF5, 0x82, 0xE4, 0x34, 0xFC, 0xF5, 0x83, 0xE0, + 0x54, 0xFB, 0xF0, 0xAC, 0x07, 0x74, 0x16, 0x2C, + 0xF5, 0x82, 0xE4, 0x34, 0xFC, 0xF5, 0x83, 0xE0, + 0x44, 0xFA, 0xF0, 0x74, 0x15, 0x2C, 0xF5, 0x82, + 0xE4, 0x34, 0xFC, 0xF5, 0x83, 0xE0, 0x44, 0x1F, + 0xF0, 0xAC, 0x07, 0x74, 0x06, 0x2C, 0xF5, 0x82, + 0xE4, 0x34, 0xFC, 0xF5, 0x83, 0xE0, 0x44, 0x0F, + 0xF0, 0x90, 0x04, 0x53, 0xE4, 0xF0, 0x90, 0x04, + 0x52, 0xF0, 0x90, 0x04, 0x51, 0x74, 0xFF, 0xF0, + 0x90, 0x04, 0x50, 0x74, 0xFD, 0xF0, 0x74, 0x14, + 0x2C, 0xF5, 0x82, 0xE4, 0x34, 0xFC, 0xF5, 0x83, + 0xE0, 0x54, 0xC0, 0x4D, 0xFD, 0x74, 0x14, 0x2F, + 0xF5, 0x82, 0xE4, 0x34, 0xFC, 0xF5, 0x83, 0xED, + 0xF0, 0x22, 0xAB, 0x07, 0xAA, 0x06, 0xED, 0x2B, + 0xFB, 0xE4, 0x3A, 0xFA, 0xC3, 0x90, 0x80, 0xDB, + 0xE0, 0x9B, 0x90, 0x80, 0xDA, 0xE0, 0x9A, 0x50, + 0x13, 0xA3, 0xE0, 0x24, 0x01, 0xFF, 0x90, 0x80, + 0xDA, 0xE0, 0x34, 0x00, 0xFE, 0xC3, 0xEB, 0x9F, + 0xFB, 0xEA, 0x9E, 0xFA, 0xEA, 0x90, 0xFD, 0x11, + 0xF0, 0xAF, 0x03, 0x74, 0x00, 0x2F, 0xF5, 0x82, + 0xE4, 0x34, 0xFB, 0xF5, 0x83, 0xE0, 0xFF, 0x22, + 0x12, 0x1F, 0xA4, 0xFF, 0x54, 0x01, 0xFE, 0x90, + 0x81, 0x42, 0xE0, 0x54, 0xFE, 0x4E, 0xF0, 0xEF, + 0xC3, 0x13, 0x30, 0xE0, 0x0A, 0x90, 0x00, 0x01, + 0x12, 0x1F, 0xBD, 0x90, 0x81, 0x43, 0xF0, 0x22, + 0x90, 0x81, 0x45, 0xE0, 0x30, 0xE0, 0x2D, 0x90, + 0x81, 0x48, 0xE0, 0x04, 0xF0, 0xE0, 0xFF, 0x90, + 0x81, 0x46, 0xE0, 0xB5, 0x07, 0x1E, 0x90, 0x06, + 0x92, 0xE0, 0x54, 0x1C, 0x70, 0x0B, 0x12, 0x4F, + 0x0B, 0x90, 0x81, 0x49, 0xE0, 0x04, 0xF0, 0x80, + 0x06, 0x90, 0x06, 0x92, 0x74, 0x1C, 0xF0, 0xE4, + 0x90, 0x81, 0x48, 0xF0, 0x22, 0x00, 0xBB, 0x8E, +}; diff --git a/drivers/staging/rtl8188eu/hal/Hal8188EPwrSeq.c b/drivers/staging/rtl8188eu/hal/Hal8188EPwrSeq.c new file mode 100644 index 0000000000000..fc23bf1593458 --- /dev/null +++ b/drivers/staging/rtl8188eu/hal/Hal8188EPwrSeq.c @@ -0,0 +1,86 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#include "Hal8188EPwrSeq.h" +#include + +/* + drivers should parse below arrays and do the corresponding actions +*/ +/* 3 Power on Array */ +struct wl_pwr_cfg rtl8188E_power_on_flow[RTL8188E_TRANS_CARDEMU_TO_ACT_STEPS + RTL8188E_TRANS_END_STEPS] = { + RTL8188E_TRANS_CARDEMU_TO_ACT + RTL8188E_TRANS_END +}; + +/* 3Radio off Array */ +struct wl_pwr_cfg rtl8188E_radio_off_flow[RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS + RTL8188E_TRANS_END_STEPS] = { + RTL8188E_TRANS_ACT_TO_CARDEMU + RTL8188E_TRANS_END +}; + +/* 3Card Disable Array */ +struct wl_pwr_cfg rtl8188E_card_disable_flow[RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS + RTL8188E_TRANS_CARDEMU_TO_PDN_STEPS + RTL8188E_TRANS_END_STEPS] = { + RTL8188E_TRANS_ACT_TO_CARDEMU + RTL8188E_TRANS_CARDEMU_TO_CARDDIS + RTL8188E_TRANS_END +}; + +/* 3 Card Enable Array */ +struct wl_pwr_cfg rtl8188E_card_enable_flow[RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS + RTL8188E_TRANS_CARDEMU_TO_PDN_STEPS + RTL8188E_TRANS_END_STEPS] = { + RTL8188E_TRANS_CARDDIS_TO_CARDEMU + RTL8188E_TRANS_CARDEMU_TO_ACT + RTL8188E_TRANS_END +}; + +/* 3Suspend Array */ +struct wl_pwr_cfg rtl8188E_suspend_flow[RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS + RTL8188E_TRANS_CARDEMU_TO_SUS_STEPS + RTL8188E_TRANS_END_STEPS] = { + RTL8188E_TRANS_ACT_TO_CARDEMU + RTL8188E_TRANS_CARDEMU_TO_SUS + RTL8188E_TRANS_END +}; + +/* 3 Resume Array */ +struct wl_pwr_cfg rtl8188E_resume_flow[RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS + RTL8188E_TRANS_CARDEMU_TO_SUS_STEPS + RTL8188E_TRANS_END_STEPS] = { + RTL8188E_TRANS_SUS_TO_CARDEMU + RTL8188E_TRANS_CARDEMU_TO_ACT + RTL8188E_TRANS_END +}; + +/* 3HWPDN Array */ +struct wl_pwr_cfg rtl8188E_hwpdn_flow[RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS + RTL8188E_TRANS_CARDEMU_TO_PDN_STEPS + RTL8188E_TRANS_END_STEPS] = { + RTL8188E_TRANS_ACT_TO_CARDEMU + RTL8188E_TRANS_CARDEMU_TO_PDN + RTL8188E_TRANS_END +}; + +/* 3 Enter LPS */ +struct wl_pwr_cfg rtl8188E_enter_lps_flow[RTL8188E_TRANS_ACT_TO_LPS_STEPS + RTL8188E_TRANS_END_STEPS] = { + /* FW behavior */ + RTL8188E_TRANS_ACT_TO_LPS + RTL8188E_TRANS_END +}; + +/* 3 Leave LPS */ +struct wl_pwr_cfg rtl8188E_leave_lps_flow[RTL8188E_TRANS_LPS_TO_ACT_STEPS + RTL8188E_TRANS_END_STEPS] = { + /* FW behavior */ + RTL8188E_TRANS_LPS_TO_ACT + RTL8188E_TRANS_END +}; diff --git a/drivers/staging/rtl8188eu/hal/Hal8188ERateAdaptive.c b/drivers/staging/rtl8188eu/hal/Hal8188ERateAdaptive.c new file mode 100644 index 0000000000000..aaa261771ab9b --- /dev/null +++ b/drivers/staging/rtl8188eu/hal/Hal8188ERateAdaptive.c @@ -0,0 +1,760 @@ +/*++ +Copyright (c) Realtek Semiconductor Corp. All rights reserved. + +Module Name: + RateAdaptive.c + +Abstract: + Implement Rate Adaptive functions for common operations. + +Major Change History: + When Who What + ---------- --------------- ------------------------------- + 2011-08-12 Page Create. + +--*/ +#include "odm_precomp.h" + +/* Rate adaptive parameters */ + +static u8 RETRY_PENALTY[PERENTRY][RETRYSIZE+1] = { + {5, 4, 3, 2, 0, 3}, /* 92 , idx = 0 */ + {6, 5, 4, 3, 0, 4}, /* 86 , idx = 1 */ + {6, 5, 4, 2, 0, 4}, /* 81 , idx = 2 */ + {8, 7, 6, 4, 0, 6}, /* 75 , idx = 3 */ + {10, 9, 8, 6, 0, 8}, /* 71 , idx = 4 */ + {10, 9, 8, 4, 0, 8}, /* 66 , idx = 5 */ + {10, 9, 8, 2, 0, 8}, /* 62 , idx = 6 */ + {10, 9, 8, 0, 0, 8}, /* 59 , idx = 7 */ + {18, 17, 16, 8, 0, 16}, /* 53 , idx = 8 */ + {26, 25, 24, 16, 0, 24}, /* 50 , idx = 9 */ + {34, 33, 32, 24, 0, 32}, /* 47 , idx = 0x0a */ + {34, 31, 28, 20, 0, 32}, /* 43 , idx = 0x0b */ + {34, 31, 27, 18, 0, 32}, /* 40 , idx = 0x0c */ + {34, 31, 26, 16, 0, 32}, /* 37 , idx = 0x0d */ + {34, 30, 22, 16, 0, 32}, /* 32 , idx = 0x0e */ + {34, 30, 24, 16, 0, 32}, /* 26 , idx = 0x0f */ + {49, 46, 40, 16, 0, 48}, /* 20 , idx = 0x10 */ + {49, 45, 32, 0, 0, 48}, /* 17 , idx = 0x11 */ + {49, 45, 22, 18, 0, 48}, /* 15 , idx = 0x12 */ + {49, 40, 24, 16, 0, 48}, /* 12 , idx = 0x13 */ + {49, 32, 18, 12, 0, 48}, /* 9 , idx = 0x14 */ + {49, 22, 18, 14, 0, 48}, /* 6 , idx = 0x15 */ + {49, 16, 16, 0, 0, 48} + }; /* 3, idx = 0x16 */ + +static u8 PT_PENALTY[RETRYSIZE+1] = {34, 31, 30, 24, 0, 32}; + +/* wilson modify */ +static u8 RETRY_PENALTY_IDX[2][RATESIZE] = { + {4, 4, 4, 5, 4, 4, 5, 7, 7, 7, 8, 0x0a, /* SS>TH */ + 4, 4, 4, 4, 6, 0x0a, 0x0b, 0x0d, + 5, 5, 7, 7, 8, 0x0b, 0x0d, 0x0f}, /* 0329 R01 */ + {0x0a, 0x0a, 0x0b, 0x0c, 0x0a, + 0x0a, 0x0b, 0x0c, 0x0d, 0x10, 0x13, 0x14, /* SSTH */ + 0x0f, 0x10, 0x10, 0x12, 0x12, 0x13, 0x14, 0x15, + 0x11, 0x11, 0x12, 0x13, 0x13, 0x13, 0x14, 0x15}; + +static u8 RSSI_THRESHOLD[RATESIZE] = { + 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0x24, 0x26, 0x2a, + 0x18, 0x1a, 0x1d, 0x1f, 0x21, 0x27, 0x29, 0x2a, + 0, 0, 0, 0x1f, 0x23, 0x28, 0x2a, 0x2c}; + +static u16 N_THRESHOLD_HIGH[RATESIZE] = { + 4, 4, 8, 16, + 24, 36, 48, 72, 96, 144, 192, 216, + 60, 80, 100, 160, 240, 400, 560, 640, + 300, 320, 480, 720, 1000, 1200, 1600, 2000}; +static u16 N_THRESHOLD_LOW[RATESIZE] = { + 2, 2, 4, 8, + 12, 18, 24, 36, 48, 72, 96, 108, + 30, 40, 50, 80, 120, 200, 280, 320, + 150, 160, 240, 360, 500, 600, 800, 1000}; + +static u8 DROPING_NECESSARY[RATESIZE] = { + 1, 1, 1, 1, + 1, 2, 3, 4, 5, 6, 7, 8, + 1, 2, 3, 4, 5, 6, 7, 8, + 5, 6, 7, 8, 9, 10, 11, 12}; + +static u8 PendingForRateUpFail[5] = {2, 10, 24, 40, 60}; +static u16 DynamicTxRPTTiming[6] = { + 0x186a, 0x30d4, 0x493e, 0x61a8, 0x7a12 , 0x927c}; /* 200ms-1200ms */ + +/* End Rate adaptive parameters */ + +static void odm_SetTxRPTTiming_8188E( + struct odm_dm_struct *dm_odm, + struct odm_ra_info *pRaInfo, + u8 extend + ) +{ + u8 idx = 0; + + for (idx = 0; idx < 5; idx++) + if (DynamicTxRPTTiming[idx] == pRaInfo->RptTime) + break; + + if (extend == 0) { /* back to default timing */ + idx = 0; /* 200ms */ + } else if (extend == 1) {/* increase the timing */ + idx += 1; + if (idx > 5) + idx = 5; + } else if (extend == 2) {/* decrease the timing */ + if (idx != 0) + idx -= 1; + } + pRaInfo->RptTime = DynamicTxRPTTiming[idx]; + + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("pRaInfo->RptTime = 0x%x\n", pRaInfo->RptTime)); +} + +static int odm_RateDown_8188E(struct odm_dm_struct *dm_odm, struct odm_ra_info *pRaInfo) +{ + u8 RateID, LowestRate, HighestRate; + u8 i; + + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("=====>odm_RateDown_8188E()\n")); + if (NULL == pRaInfo) { + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("odm_RateDown_8188E(): pRaInfo is NULL\n")); + return -1; + } + RateID = pRaInfo->PreRate; + LowestRate = pRaInfo->LowestRate; + HighestRate = pRaInfo->HighestRate; + + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, + (" RateID =%d LowestRate =%d HighestRate =%d RateSGI =%d\n", + RateID, LowestRate, HighestRate, pRaInfo->RateSGI)); + if (RateID > HighestRate) { + RateID = HighestRate; + } else if (pRaInfo->RateSGI) { + pRaInfo->RateSGI = 0; + } else if (RateID > LowestRate) { + if (RateID > 0) { + for (i = RateID-1; i > LowestRate; i--) { + if (pRaInfo->RAUseRate & BIT(i)) { + RateID = i; + goto RateDownFinish; + } + } + } + } else if (RateID <= LowestRate) { + RateID = LowestRate; + } +RateDownFinish: + if (pRaInfo->RAWaitingCounter == 1) { + pRaInfo->RAWaitingCounter += 1; + pRaInfo->RAPendingCounter += 1; + } else if (pRaInfo->RAWaitingCounter == 0) { + ; + } else { + pRaInfo->RAWaitingCounter = 0; + pRaInfo->RAPendingCounter = 0; + } + + if (pRaInfo->RAPendingCounter >= 4) + pRaInfo->RAPendingCounter = 4; + + pRaInfo->DecisionRate = RateID; + odm_SetTxRPTTiming_8188E(dm_odm, pRaInfo, 2); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("Rate down, RPT Timing default\n")); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("RAWaitingCounter %d, RAPendingCounter %d", pRaInfo->RAWaitingCounter, pRaInfo->RAPendingCounter)); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("Rate down to RateID %d RateSGI %d\n", RateID, pRaInfo->RateSGI)); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("<===== odm_RateDown_8188E()\n")); + return 0; +} + +static int odm_RateUp_8188E( + struct odm_dm_struct *dm_odm, + struct odm_ra_info *pRaInfo + ) +{ + u8 RateID, HighestRate; + u8 i; + + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("=====>odm_RateUp_8188E()\n")); + if (NULL == pRaInfo) { + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("odm_RateUp_8188E(): pRaInfo is NULL\n")); + return -1; + } + RateID = pRaInfo->PreRate; + HighestRate = pRaInfo->HighestRate; + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, + (" RateID =%d HighestRate =%d\n", + RateID, HighestRate)); + if (pRaInfo->RAWaitingCounter == 1) { + pRaInfo->RAWaitingCounter = 0; + pRaInfo->RAPendingCounter = 0; + } else if (pRaInfo->RAWaitingCounter > 1) { + pRaInfo->PreRssiStaRA = pRaInfo->RssiStaRA; + goto RateUpfinish; + } + odm_SetTxRPTTiming_8188E(dm_odm, pRaInfo, 0); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("odm_RateUp_8188E():Decrease RPT Timing\n")); + + if (RateID < HighestRate) { + for (i = RateID+1; i <= HighestRate; i++) { + if (pRaInfo->RAUseRate & BIT(i)) { + RateID = i; + goto RateUpfinish; + } + } + } else if (RateID == HighestRate) { + if (pRaInfo->SGIEnable && (pRaInfo->RateSGI != 1)) + pRaInfo->RateSGI = 1; + else if ((pRaInfo->SGIEnable) != 1) + pRaInfo->RateSGI = 0; + } else { + RateID = HighestRate; + } +RateUpfinish: + if (pRaInfo->RAWaitingCounter == (4+PendingForRateUpFail[pRaInfo->RAPendingCounter])) + pRaInfo->RAWaitingCounter = 0; + else + pRaInfo->RAWaitingCounter++; + + pRaInfo->DecisionRate = RateID; + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("Rate up to RateID %d\n", RateID)); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("RAWaitingCounter %d, RAPendingCounter %d", pRaInfo->RAWaitingCounter, pRaInfo->RAPendingCounter)); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("<===== odm_RateUp_8188E()\n")); + return 0; +} + +static void odm_ResetRaCounter_8188E(struct odm_ra_info *pRaInfo) +{ + u8 RateID; + + RateID = pRaInfo->DecisionRate; + pRaInfo->NscUp = (N_THRESHOLD_HIGH[RateID]+N_THRESHOLD_LOW[RateID])>>1; + pRaInfo->NscDown = (N_THRESHOLD_HIGH[RateID]+N_THRESHOLD_LOW[RateID])>>1; +} + +static void odm_RateDecision_8188E(struct odm_dm_struct *dm_odm, + struct odm_ra_info *pRaInfo + ) +{ + u8 RateID = 0, RtyPtID = 0, PenaltyID1 = 0, PenaltyID2 = 0; + /* u32 pool_retry; */ + static u8 DynamicTxRPTTimingCounter; + + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("=====>odm_RateDecision_8188E()\n")); + + if (pRaInfo->Active && (pRaInfo->TOTAL > 0)) { /* STA used and data packet exits */ + if ((pRaInfo->RssiStaRA < (pRaInfo->PreRssiStaRA - 3)) || + (pRaInfo->RssiStaRA > (pRaInfo->PreRssiStaRA + 3))) { + pRaInfo->RAWaitingCounter = 0; + pRaInfo->RAPendingCounter = 0; + } + /* Start RA decision */ + if (pRaInfo->PreRate > pRaInfo->HighestRate) + RateID = pRaInfo->HighestRate; + else + RateID = pRaInfo->PreRate; + if (pRaInfo->RssiStaRA > RSSI_THRESHOLD[RateID]) + RtyPtID = 0; + else + RtyPtID = 1; + PenaltyID1 = RETRY_PENALTY_IDX[RtyPtID][RateID]; /* TODO by page */ + + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, + (" NscDown init is %d\n", pRaInfo->NscDown)); + pRaInfo->NscDown += pRaInfo->RTY[0] * RETRY_PENALTY[PenaltyID1][0]; + pRaInfo->NscDown += pRaInfo->RTY[1] * RETRY_PENALTY[PenaltyID1][1]; + pRaInfo->NscDown += pRaInfo->RTY[2] * RETRY_PENALTY[PenaltyID1][2]; + pRaInfo->NscDown += pRaInfo->RTY[3] * RETRY_PENALTY[PenaltyID1][3]; + pRaInfo->NscDown += pRaInfo->RTY[4] * RETRY_PENALTY[PenaltyID1][4]; + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, + (" NscDown is %d, total*penalty[5] is %d\n", + pRaInfo->NscDown, (pRaInfo->TOTAL * RETRY_PENALTY[PenaltyID1][5]))); + if (pRaInfo->NscDown > (pRaInfo->TOTAL * RETRY_PENALTY[PenaltyID1][5])) + pRaInfo->NscDown -= pRaInfo->TOTAL * RETRY_PENALTY[PenaltyID1][5]; + else + pRaInfo->NscDown = 0; + + /* rate up */ + PenaltyID2 = RETRY_PENALTY_UP_IDX[RateID]; + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, + (" NscUp init is %d\n", pRaInfo->NscUp)); + pRaInfo->NscUp += pRaInfo->RTY[0] * RETRY_PENALTY[PenaltyID2][0]; + pRaInfo->NscUp += pRaInfo->RTY[1] * RETRY_PENALTY[PenaltyID2][1]; + pRaInfo->NscUp += pRaInfo->RTY[2] * RETRY_PENALTY[PenaltyID2][2]; + pRaInfo->NscUp += pRaInfo->RTY[3] * RETRY_PENALTY[PenaltyID2][3]; + pRaInfo->NscUp += pRaInfo->RTY[4] * RETRY_PENALTY[PenaltyID2][4]; + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, + ("NscUp is %d, total*up[5] is %d\n", + pRaInfo->NscUp, (pRaInfo->TOTAL * RETRY_PENALTY[PenaltyID2][5]))); + if (pRaInfo->NscUp > (pRaInfo->TOTAL * RETRY_PENALTY[PenaltyID2][5])) + pRaInfo->NscUp -= pRaInfo->TOTAL * RETRY_PENALTY[PenaltyID2][5]; + else + pRaInfo->NscUp = 0; + + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE|ODM_COMP_INIT, ODM_DBG_LOUD, + (" RssiStaRa = %d RtyPtID =%d PenaltyID1 = 0x%x PenaltyID2 = 0x%x RateID =%d NscDown =%d NscUp =%d SGI =%d\n", + pRaInfo->RssiStaRA, RtyPtID, PenaltyID1, PenaltyID2, RateID, pRaInfo->NscDown, pRaInfo->NscUp, pRaInfo->RateSGI)); + if ((pRaInfo->NscDown < N_THRESHOLD_LOW[RateID]) || + (pRaInfo->DROP > DROPING_NECESSARY[RateID])) + odm_RateDown_8188E(dm_odm, pRaInfo); + else if (pRaInfo->NscUp > N_THRESHOLD_HIGH[RateID]) + odm_RateUp_8188E(dm_odm, pRaInfo); + + if (pRaInfo->DecisionRate > pRaInfo->HighestRate) + pRaInfo->DecisionRate = pRaInfo->HighestRate; + + if ((pRaInfo->DecisionRate) == (pRaInfo->PreRate)) + DynamicTxRPTTimingCounter += 1; + else + DynamicTxRPTTimingCounter = 0; + + if (DynamicTxRPTTimingCounter >= 4) { + odm_SetTxRPTTiming_8188E(dm_odm, pRaInfo, 1); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, + ODM_DBG_LOUD, ("<===== Rate don't change 4 times, Extend RPT Timing\n")); + DynamicTxRPTTimingCounter = 0; + } + + pRaInfo->PreRate = pRaInfo->DecisionRate; /* YJ, add, 120120 */ + + odm_ResetRaCounter_8188E(pRaInfo); + } + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("<===== odm_RateDecision_8188E()\n")); +} + +static int odm_ARFBRefresh_8188E(struct odm_dm_struct *dm_odm, struct odm_ra_info *pRaInfo) +{ /* Wilson 2011/10/26 */ + u32 MaskFromReg; + s8 i; + + switch (pRaInfo->RateID) { + case RATR_INX_WIRELESS_NGB: + pRaInfo->RAUseRate = (pRaInfo->RateMask)&0x0f8ff015; + break; + case RATR_INX_WIRELESS_NG: + pRaInfo->RAUseRate = (pRaInfo->RateMask)&0x0f8ff010; + break; + case RATR_INX_WIRELESS_NB: + pRaInfo->RAUseRate = (pRaInfo->RateMask)&0x0f8ff005; + break; + case RATR_INX_WIRELESS_N: + pRaInfo->RAUseRate = (pRaInfo->RateMask)&0x0f8ff000; + break; + case RATR_INX_WIRELESS_GB: + pRaInfo->RAUseRate = (pRaInfo->RateMask)&0x00000ff5; + break; + case RATR_INX_WIRELESS_G: + pRaInfo->RAUseRate = (pRaInfo->RateMask)&0x00000ff0; + break; + case RATR_INX_WIRELESS_B: + pRaInfo->RAUseRate = (pRaInfo->RateMask)&0x0000000d; + break; + case 12: + MaskFromReg = ODM_Read4Byte(dm_odm, REG_ARFR0); + pRaInfo->RAUseRate = (pRaInfo->RateMask)&MaskFromReg; + break; + case 13: + MaskFromReg = ODM_Read4Byte(dm_odm, REG_ARFR1); + pRaInfo->RAUseRate = (pRaInfo->RateMask)&MaskFromReg; + break; + case 14: + MaskFromReg = ODM_Read4Byte(dm_odm, REG_ARFR2); + pRaInfo->RAUseRate = (pRaInfo->RateMask)&MaskFromReg; + break; + case 15: + MaskFromReg = ODM_Read4Byte(dm_odm, REG_ARFR3); + pRaInfo->RAUseRate = (pRaInfo->RateMask)&MaskFromReg; + break; + default: + pRaInfo->RAUseRate = (pRaInfo->RateMask); + break; + } + /* Highest rate */ + if (pRaInfo->RAUseRate) { + for (i = RATESIZE; i >= 0; i--) { + if ((pRaInfo->RAUseRate)&BIT(i)) { + pRaInfo->HighestRate = i; + break; + } + } + } else { + pRaInfo->HighestRate = 0; + } + /* Lowest rate */ + if (pRaInfo->RAUseRate) { + for (i = 0; i < RATESIZE; i++) { + if ((pRaInfo->RAUseRate) & BIT(i)) { + pRaInfo->LowestRate = i; + break; + } + } + } else { + pRaInfo->LowestRate = 0; + } + if (pRaInfo->HighestRate > 0x13) + pRaInfo->PTModeSS = 3; + else if (pRaInfo->HighestRate > 0x0b) + pRaInfo->PTModeSS = 2; + else if (pRaInfo->HighestRate > 0x0b) + pRaInfo->PTModeSS = 1; + else + pRaInfo->PTModeSS = 0; + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, + ("ODM_ARFBRefresh_8188E(): PTModeSS =%d\n", pRaInfo->PTModeSS)); + + if (pRaInfo->DecisionRate > pRaInfo->HighestRate) + pRaInfo->DecisionRate = pRaInfo->HighestRate; + + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, + ("ODM_ARFBRefresh_8188E(): RateID =%d RateMask =%8.8x RAUseRate =%8.8x HighestRate =%d, DecisionRate =%d\n", + pRaInfo->RateID, pRaInfo->RateMask, pRaInfo->RAUseRate, pRaInfo->HighestRate, pRaInfo->DecisionRate)); + return 0; +} + +static void odm_PTTryState_8188E(struct odm_ra_info *pRaInfo) +{ + pRaInfo->PTTryState = 0; + switch (pRaInfo->PTModeSS) { + case 3: + if (pRaInfo->DecisionRate >= 0x19) + pRaInfo->PTTryState = 1; + break; + case 2: + if (pRaInfo->DecisionRate >= 0x11) + pRaInfo->PTTryState = 1; + break; + case 1: + if (pRaInfo->DecisionRate >= 0x0a) + pRaInfo->PTTryState = 1; + break; + case 0: + if (pRaInfo->DecisionRate >= 0x03) + pRaInfo->PTTryState = 1; + break; + default: + pRaInfo->PTTryState = 0; + break; + } + + if (pRaInfo->RssiStaRA < 48) { + pRaInfo->PTStage = 0; + } else if (pRaInfo->PTTryState == 1) { + if ((pRaInfo->PTStopCount >= 10) || + (pRaInfo->PTPreRssi > pRaInfo->RssiStaRA + 5) || + (pRaInfo->PTPreRssi < pRaInfo->RssiStaRA - 5) || + (pRaInfo->DecisionRate != pRaInfo->PTPreRate)) { + if (pRaInfo->PTStage == 0) + pRaInfo->PTStage = 1; + else if (pRaInfo->PTStage == 1) + pRaInfo->PTStage = 3; + else + pRaInfo->PTStage = 5; + + pRaInfo->PTPreRssi = pRaInfo->RssiStaRA; + pRaInfo->PTStopCount = 0; + } else { + pRaInfo->RAstage = 0; + pRaInfo->PTStopCount++; + } + } else { + pRaInfo->PTStage = 0; + pRaInfo->RAstage = 0; + } + pRaInfo->PTPreRate = pRaInfo->DecisionRate; +} + +static void odm_PTDecision_8188E(struct odm_ra_info *pRaInfo) +{ + u8 j; + u8 temp_stage; + u32 numsc; + u32 num_total; + u8 stage_id; + + numsc = 0; + num_total = pRaInfo->TOTAL * PT_PENALTY[5]; + for (j = 0; j <= 4; j++) { + numsc += pRaInfo->RTY[j] * PT_PENALTY[j]; + if (numsc > num_total) + break; + } + + j = j >> 1; + temp_stage = (pRaInfo->PTStage + 1) >> 1; + if (temp_stage > j) + stage_id = temp_stage-j; + else + stage_id = 0; + + pRaInfo->PTSmoothFactor = (pRaInfo->PTSmoothFactor>>1) + (pRaInfo->PTSmoothFactor>>2) + stage_id*16+2; + if (pRaInfo->PTSmoothFactor > 192) + pRaInfo->PTSmoothFactor = 192; + stage_id = pRaInfo->PTSmoothFactor >> 6; + temp_stage = stage_id*2; + if (temp_stage != 0) + temp_stage -= 1; + if (pRaInfo->DROP > 3) + temp_stage = 0; + pRaInfo->PTStage = temp_stage; +} + +static void +odm_RATxRPTTimerSetting( + struct odm_dm_struct *dm_odm, + u16 minRptTime +) +{ + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, (" =====>odm_RATxRPTTimerSetting()\n")); + + if (dm_odm->CurrminRptTime != minRptTime) { + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, + (" CurrminRptTime = 0x%04x minRptTime = 0x%04x\n", dm_odm->CurrminRptTime, minRptTime)); + rtw_rpt_timer_cfg_cmd(dm_odm->Adapter, minRptTime); + dm_odm->CurrminRptTime = minRptTime; + } + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, (" <===== odm_RATxRPTTimerSetting()\n")); +} + +void +ODM_RASupport_Init( + struct odm_dm_struct *dm_odm + ) +{ + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("=====>ODM_RASupport_Init()\n")); + + /* 2012/02/14 MH Be noticed, the init must be after IC type is recognized!!!!! */ + if (dm_odm->SupportICType == ODM_RTL8188E) + dm_odm->RaSupport88E = true; +} + +int ODM_RAInfo_Init(struct odm_dm_struct *dm_odm, u8 macid) +{ + struct odm_ra_info *pRaInfo = &dm_odm->RAInfo[macid]; + u8 WirelessMode = 0xFF; /* invalid value */ + u8 max_rate_idx = 0x13; /* MCS7 */ + if (dm_odm->pWirelessMode != NULL) + WirelessMode = *(dm_odm->pWirelessMode); + + if (WirelessMode != 0xFF) { + if (WirelessMode & ODM_WM_N24G) + max_rate_idx = 0x13; + else if (WirelessMode & ODM_WM_G) + max_rate_idx = 0x0b; + else if (WirelessMode & ODM_WM_B) + max_rate_idx = 0x03; + } + + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, + ("ODM_RAInfo_Init(): WirelessMode:0x%08x , max_raid_idx:0x%02x\n", + WirelessMode, max_rate_idx)); + + pRaInfo->DecisionRate = max_rate_idx; + pRaInfo->PreRate = max_rate_idx; + pRaInfo->HighestRate = max_rate_idx; + pRaInfo->LowestRate = 0; + pRaInfo->RateID = 0; + pRaInfo->RateMask = 0xffffffff; + pRaInfo->RssiStaRA = 0; + pRaInfo->PreRssiStaRA = 0; + pRaInfo->SGIEnable = 0; + pRaInfo->RAUseRate = 0xffffffff; + pRaInfo->NscDown = (N_THRESHOLD_HIGH[0x13]+N_THRESHOLD_LOW[0x13])/2; + pRaInfo->NscUp = (N_THRESHOLD_HIGH[0x13]+N_THRESHOLD_LOW[0x13])/2; + pRaInfo->RateSGI = 0; + pRaInfo->Active = 1; /* Active is not used at present. by page, 110819 */ + pRaInfo->RptTime = 0x927c; + pRaInfo->DROP = 0; + pRaInfo->RTY[0] = 0; + pRaInfo->RTY[1] = 0; + pRaInfo->RTY[2] = 0; + pRaInfo->RTY[3] = 0; + pRaInfo->RTY[4] = 0; + pRaInfo->TOTAL = 0; + pRaInfo->RAWaitingCounter = 0; + pRaInfo->RAPendingCounter = 0; + pRaInfo->PTActive = 1; /* Active when this STA is use */ + pRaInfo->PTTryState = 0; + pRaInfo->PTStage = 5; /* Need to fill into HW_PWR_STATUS */ + pRaInfo->PTSmoothFactor = 192; + pRaInfo->PTStopCount = 0; + pRaInfo->PTPreRate = 0; + pRaInfo->PTPreRssi = 0; + pRaInfo->PTModeSS = 0; + pRaInfo->RAstage = 0; + return 0; +} + +int ODM_RAInfo_Init_all(struct odm_dm_struct *dm_odm) +{ + u8 macid = 0; + + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("=====>\n")); + dm_odm->CurrminRptTime = 0; + + for (macid = 0; macid < ODM_ASSOCIATE_ENTRY_NUM; macid++) + ODM_RAInfo_Init(dm_odm, macid); + + return 0; +} + +u8 ODM_RA_GetShortGI_8188E(struct odm_dm_struct *dm_odm, u8 macid) +{ + if ((NULL == dm_odm) || (macid >= ASSOCIATE_ENTRY_NUM)) + return 0; + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, + ("macid =%d SGI =%d\n", macid, dm_odm->RAInfo[macid].RateSGI)); + return dm_odm->RAInfo[macid].RateSGI; +} + +u8 ODM_RA_GetDecisionRate_8188E(struct odm_dm_struct *dm_odm, u8 macid) +{ + u8 DecisionRate = 0; + + if ((NULL == dm_odm) || (macid >= ASSOCIATE_ENTRY_NUM)) + return 0; + DecisionRate = (dm_odm->RAInfo[macid].DecisionRate); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, + (" macid =%d DecisionRate = 0x%x\n", macid, DecisionRate)); + return DecisionRate; +} + +u8 ODM_RA_GetHwPwrStatus_8188E(struct odm_dm_struct *dm_odm, u8 macid) +{ + u8 PTStage = 5; + + if ((NULL == dm_odm) || (macid >= ASSOCIATE_ENTRY_NUM)) + return 0; + PTStage = (dm_odm->RAInfo[macid].PTStage); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, + ("macid =%d PTStage = 0x%x\n", macid, PTStage)); + return PTStage; +} + +void ODM_RA_UpdateRateInfo_8188E(struct odm_dm_struct *dm_odm, u8 macid, u8 RateID, u32 RateMask, u8 SGIEnable) +{ + struct odm_ra_info *pRaInfo = NULL; + + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, + ("macid =%d RateID = 0x%x RateMask = 0x%x SGIEnable =%d\n", + macid, RateID, RateMask, SGIEnable)); + if ((NULL == dm_odm) || (macid >= ASSOCIATE_ENTRY_NUM)) + return; + + pRaInfo = &(dm_odm->RAInfo[macid]); + pRaInfo->RateID = RateID; + pRaInfo->RateMask = RateMask; + pRaInfo->SGIEnable = SGIEnable; + odm_ARFBRefresh_8188E(dm_odm, pRaInfo); +} + +void ODM_RA_SetRSSI_8188E(struct odm_dm_struct *dm_odm, u8 macid, u8 Rssi) +{ + struct odm_ra_info *pRaInfo = NULL; + + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, + (" macid =%d Rssi =%d\n", macid, Rssi)); + if ((NULL == dm_odm) || (macid >= ASSOCIATE_ENTRY_NUM)) + return; + + pRaInfo = &(dm_odm->RAInfo[macid]); + pRaInfo->RssiStaRA = Rssi; +} + +void ODM_RA_Set_TxRPT_Time(struct odm_dm_struct *dm_odm, u16 minRptTime) +{ + ODM_Write2Byte(dm_odm, REG_TX_RPT_TIME, minRptTime); +} + +void ODM_RA_TxRPT2Handle_8188E(struct odm_dm_struct *dm_odm, u8 *TxRPT_Buf, u16 TxRPT_Len, u32 macid_entry0, u32 macid_entry1) +{ + struct odm_ra_info *pRAInfo = NULL; + u8 MacId = 0; + u8 *pBuffer = NULL; + u32 valid = 0, ItemNum = 0; + u16 minRptTime = 0x927c; + + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, + ("=====>ODM_RA_TxRPT2Handle_8188E(): valid0 =%d valid1 =%d BufferLength =%d\n", + macid_entry0, macid_entry1, TxRPT_Len)); + + ItemNum = TxRPT_Len >> 3; + pBuffer = TxRPT_Buf; + + do { + if (MacId >= ASSOCIATE_ENTRY_NUM) + valid = 0; + else if (MacId >= 32) + valid = (1 << (MacId - 32)) & macid_entry1; + else + valid = (1 << MacId) & macid_entry0; + + pRAInfo = &(dm_odm->RAInfo[MacId]); + if (valid) { + pRAInfo->RTY[0] = (u16)GET_TX_REPORT_TYPE1_RERTY_0(pBuffer); + pRAInfo->RTY[1] = (u16)GET_TX_REPORT_TYPE1_RERTY_1(pBuffer); + pRAInfo->RTY[2] = (u16)GET_TX_REPORT_TYPE1_RERTY_2(pBuffer); + pRAInfo->RTY[3] = (u16)GET_TX_REPORT_TYPE1_RERTY_3(pBuffer); + pRAInfo->RTY[4] = (u16)GET_TX_REPORT_TYPE1_RERTY_4(pBuffer); + pRAInfo->DROP = (u16)GET_TX_REPORT_TYPE1_DROP_0(pBuffer); + pRAInfo->TOTAL = pRAInfo->RTY[0] + pRAInfo->RTY[1] + + pRAInfo->RTY[2] + pRAInfo->RTY[3] + + pRAInfo->RTY[4] + pRAInfo->DROP; + if (pRAInfo->TOTAL != 0) { + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, + ("macid =%d Total =%d R0 =%d R1 =%d R2 =%d R3 =%d R4 =%d D0 =%d valid0 =%x valid1 =%x\n", + MacId, pRAInfo->TOTAL, + pRAInfo->RTY[0], pRAInfo->RTY[1], + pRAInfo->RTY[2], pRAInfo->RTY[3], + pRAInfo->RTY[4], pRAInfo->DROP, + macid_entry0 , macid_entry1)); + if (pRAInfo->PTActive) { + if (pRAInfo->RAstage < 5) + odm_RateDecision_8188E(dm_odm, pRAInfo); + else if (pRAInfo->RAstage == 5) /* Power training try state */ + odm_PTTryState_8188E(pRAInfo); + else /* RAstage == 6 */ + odm_PTDecision_8188E(pRAInfo); + + /* Stage_RA counter */ + if (pRAInfo->RAstage <= 5) + pRAInfo->RAstage++; + else + pRAInfo->RAstage = 0; + } else { + odm_RateDecision_8188E(dm_odm, pRAInfo); + } + ODM_RT_TRACE(dm_odm, ODM_COMP_INIT, ODM_DBG_LOUD, + ("macid =%d R0 =%d R1 =%d R2 =%d R3 =%d R4 =%d drop =%d valid0 =%x RateID =%d SGI =%d\n", + MacId, + pRAInfo->RTY[0], + pRAInfo->RTY[1], + pRAInfo->RTY[2], + pRAInfo->RTY[3], + pRAInfo->RTY[4], + pRAInfo->DROP, + macid_entry0, + pRAInfo->DecisionRate, + pRAInfo->RateSGI)); + } else { + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, (" TOTAL = 0!!!!\n")); + } + } + + if (minRptTime > pRAInfo->RptTime) + minRptTime = pRAInfo->RptTime; + + pBuffer += TX_RPT2_ITEM_SIZE; + MacId++; + } while (MacId < ItemNum); + + odm_RATxRPTTimerSetting(dm_odm, minRptTime); + + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("<===== ODM_RA_TxRPT2Handle_8188E()\n")); +} -- GitLab From c59c7267a287f2545390b651c326d50f71bdb382 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 21 Aug 2013 22:33:51 -0500 Subject: [PATCH 767/942] staging: r8188eu: Add files for new driver - part 9 This commit adds files hal/HalHWImg8188E_BB.c, hal/HalHWImg8188E_MAC.c, hal/HalHWImg8188E_RF.c, and hal/hal_com.c. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8188eu/hal/HalHWImg8188E_BB.c | 721 ++++++++++++++++++ .../staging/rtl8188eu/hal/HalHWImg8188E_MAC.c | 231 ++++++ .../staging/rtl8188eu/hal/HalHWImg8188E_RF.c | 269 +++++++ drivers/staging/rtl8188eu/hal/hal_com.c | 381 +++++++++ 4 files changed, 1602 insertions(+) create mode 100644 drivers/staging/rtl8188eu/hal/HalHWImg8188E_BB.c create mode 100644 drivers/staging/rtl8188eu/hal/HalHWImg8188E_MAC.c create mode 100644 drivers/staging/rtl8188eu/hal/HalHWImg8188E_RF.c create mode 100644 drivers/staging/rtl8188eu/hal/hal_com.c diff --git a/drivers/staging/rtl8188eu/hal/HalHWImg8188E_BB.c b/drivers/staging/rtl8188eu/hal/HalHWImg8188E_BB.c new file mode 100644 index 0000000000000..787e8f1f97f96 --- /dev/null +++ b/drivers/staging/rtl8188eu/hal/HalHWImg8188E_BB.c @@ -0,0 +1,721 @@ +/****************************************************************************** +* +* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* 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. +* +* You should have received a copy of the GNU General Public License along with +* this program; if not, write to the Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA +* +* +******************************************************************************/ + +#include "odm_precomp.h" + +#include + +#define read_next_pair(array, v1, v2, i) \ + do { \ + i += 2; \ + v1 = array[i]; \ + v2 = array[i+1]; \ + } while (0) + +static bool CheckCondition(const u32 condition, const u32 hex) +{ + u32 _board = (hex & 0x000000FF); + u32 _interface = (hex & 0x0000FF00) >> 8; + u32 _platform = (hex & 0x00FF0000) >> 16; + u32 cond = condition; + + if (condition == 0xCDCDCDCD) + return true; + + cond = condition & 0x000000FF; + if ((_board == cond) && cond != 0x00) + return false; + + cond = condition & 0x0000FF00; + cond = cond >> 8; + if ((_interface & cond) == 0 && cond != 0x07) + return false; + + cond = condition & 0x00FF0000; + cond = cond >> 16; + if ((_platform & cond) == 0 && cond != 0x0F) + return false; + return true; +} + + +/****************************************************************************** +* AGC_TAB_1T.TXT +******************************************************************************/ + +static u32 array_agc_tab_1t_8188e[] = { + 0xC78, 0xFB000001, + 0xC78, 0xFB010001, + 0xC78, 0xFB020001, + 0xC78, 0xFB030001, + 0xC78, 0xFB040001, + 0xC78, 0xFB050001, + 0xC78, 0xFA060001, + 0xC78, 0xF9070001, + 0xC78, 0xF8080001, + 0xC78, 0xF7090001, + 0xC78, 0xF60A0001, + 0xC78, 0xF50B0001, + 0xC78, 0xF40C0001, + 0xC78, 0xF30D0001, + 0xC78, 0xF20E0001, + 0xC78, 0xF10F0001, + 0xC78, 0xF0100001, + 0xC78, 0xEF110001, + 0xC78, 0xEE120001, + 0xC78, 0xED130001, + 0xC78, 0xEC140001, + 0xC78, 0xEB150001, + 0xC78, 0xEA160001, + 0xC78, 0xE9170001, + 0xC78, 0xE8180001, + 0xC78, 0xE7190001, + 0xC78, 0xE61A0001, + 0xC78, 0xE51B0001, + 0xC78, 0xE41C0001, + 0xC78, 0xE31D0001, + 0xC78, 0xE21E0001, + 0xC78, 0xE11F0001, + 0xC78, 0x8A200001, + 0xC78, 0x89210001, + 0xC78, 0x88220001, + 0xC78, 0x87230001, + 0xC78, 0x86240001, + 0xC78, 0x85250001, + 0xC78, 0x84260001, + 0xC78, 0x83270001, + 0xC78, 0x82280001, + 0xC78, 0x6B290001, + 0xC78, 0x6A2A0001, + 0xC78, 0x692B0001, + 0xC78, 0x682C0001, + 0xC78, 0x672D0001, + 0xC78, 0x662E0001, + 0xC78, 0x652F0001, + 0xC78, 0x64300001, + 0xC78, 0x63310001, + 0xC78, 0x62320001, + 0xC78, 0x61330001, + 0xC78, 0x46340001, + 0xC78, 0x45350001, + 0xC78, 0x44360001, + 0xC78, 0x43370001, + 0xC78, 0x42380001, + 0xC78, 0x41390001, + 0xC78, 0x403A0001, + 0xC78, 0x403B0001, + 0xC78, 0x403C0001, + 0xC78, 0x403D0001, + 0xC78, 0x403E0001, + 0xC78, 0x403F0001, + 0xC78, 0xFB400001, + 0xC78, 0xFB410001, + 0xC78, 0xFB420001, + 0xC78, 0xFB430001, + 0xC78, 0xFB440001, + 0xC78, 0xFB450001, + 0xC78, 0xFB460001, + 0xC78, 0xFB470001, + 0xC78, 0xFB480001, + 0xC78, 0xFA490001, + 0xC78, 0xF94A0001, + 0xC78, 0xF84B0001, + 0xC78, 0xF74C0001, + 0xC78, 0xF64D0001, + 0xC78, 0xF54E0001, + 0xC78, 0xF44F0001, + 0xC78, 0xF3500001, + 0xC78, 0xF2510001, + 0xC78, 0xF1520001, + 0xC78, 0xF0530001, + 0xC78, 0xEF540001, + 0xC78, 0xEE550001, + 0xC78, 0xED560001, + 0xC78, 0xEC570001, + 0xC78, 0xEB580001, + 0xC78, 0xEA590001, + 0xC78, 0xE95A0001, + 0xC78, 0xE85B0001, + 0xC78, 0xE75C0001, + 0xC78, 0xE65D0001, + 0xC78, 0xE55E0001, + 0xC78, 0xE45F0001, + 0xC78, 0xE3600001, + 0xC78, 0xE2610001, + 0xC78, 0xC3620001, + 0xC78, 0xC2630001, + 0xC78, 0xC1640001, + 0xC78, 0x8B650001, + 0xC78, 0x8A660001, + 0xC78, 0x89670001, + 0xC78, 0x88680001, + 0xC78, 0x87690001, + 0xC78, 0x866A0001, + 0xC78, 0x856B0001, + 0xC78, 0x846C0001, + 0xC78, 0x676D0001, + 0xC78, 0x666E0001, + 0xC78, 0x656F0001, + 0xC78, 0x64700001, + 0xC78, 0x63710001, + 0xC78, 0x62720001, + 0xC78, 0x61730001, + 0xC78, 0x60740001, + 0xC78, 0x46750001, + 0xC78, 0x45760001, + 0xC78, 0x44770001, + 0xC78, 0x43780001, + 0xC78, 0x42790001, + 0xC78, 0x417A0001, + 0xC78, 0x407B0001, + 0xC78, 0x407C0001, + 0xC78, 0x407D0001, + 0xC78, 0x407E0001, + 0xC78, 0x407F0001, +}; + +enum HAL_STATUS ODM_ReadAndConfig_AGC_TAB_1T_8188E(struct odm_dm_struct *dm_odm) +{ + u32 hex = 0; + u32 i = 0; + u8 platform = dm_odm->SupportPlatform; + u8 interfaceValue = dm_odm->SupportInterface; + u8 board = dm_odm->BoardType; + u32 arraylen = sizeof(array_agc_tab_1t_8188e)/sizeof(u32); + u32 *array = array_agc_tab_1t_8188e; + bool biol = false; + struct adapter *adapter = dm_odm->Adapter; + struct xmit_frame *pxmit_frame = NULL; + u8 bndy_cnt = 1; + enum HAL_STATUS rst = HAL_STATUS_SUCCESS; + + hex += board; + hex += interfaceValue << 8; + hex += platform << 16; + hex += 0xFF000000; + biol = rtw_IOL_applied(adapter); + + if (biol) { + pxmit_frame = rtw_IOL_accquire_xmit_frame(adapter); + if (pxmit_frame == NULL) { + pr_info("rtw_IOL_accquire_xmit_frame failed\n"); + return HAL_STATUS_FAILURE; + } + } + + for (i = 0; i < arraylen; i += 2) { + u32 v1 = array[i]; + u32 v2 = array[i+1]; + + /* This (offset, data) pair meets the condition. */ + if (v1 < 0xCDCDCDCD) { + if (biol) { + if (rtw_IOL_cmd_boundary_handle(pxmit_frame)) + bndy_cnt++; + rtw_IOL_append_WD_cmd(pxmit_frame, (u16)v1, v2, bMaskDWord); + } else { + odm_ConfigBB_AGC_8188E(dm_odm, v1, bMaskDWord, v2); + } + continue; + } else { + /* This line is the start line of branch. */ + if (!CheckCondition(array[i], hex)) { + /* Discard the following (offset, data) pairs. */ + read_next_pair(array, v1, v2, i); + while (v2 != 0xDEAD && + v2 != 0xCDEF && + v2 != 0xCDCD && i < arraylen - 2) + read_next_pair(array, v1, v2, i); + i -= 2; /* prevent from for-loop += 2 */ + } else { /* Configure matched pairs and skip to end of if-else. */ + read_next_pair(array, v1, v2, i); + while (v2 != 0xDEAD && + v2 != 0xCDEF && + v2 != 0xCDCD && i < arraylen - 2) { + if (biol) { + if (rtw_IOL_cmd_boundary_handle(pxmit_frame)) + bndy_cnt++; + rtw_IOL_append_WD_cmd(pxmit_frame, (u16)v1, v2, bMaskDWord); + } else { + odm_ConfigBB_AGC_8188E(dm_odm, v1, bMaskDWord, v2); + } + read_next_pair(array, v1, v2, i); + } + + while (v2 != 0xDEAD && i < arraylen - 2) + read_next_pair(array, v1, v2, i); + } + } + } + if (biol) { + if (!rtw_IOL_exec_cmds_sync(dm_odm->Adapter, pxmit_frame, 1000, bndy_cnt)) { + printk("~~~ %s IOL_exec_cmds Failed !!!\n", __func__); + rst = HAL_STATUS_FAILURE; + } + } + return rst; +} + +/****************************************************************************** +* PHY_REG_1T.TXT +******************************************************************************/ + +static u32 array_phy_reg_1t_8188e[] = { + 0x800, 0x80040000, + 0x804, 0x00000003, + 0x808, 0x0000FC00, + 0x80C, 0x0000000A, + 0x810, 0x10001331, + 0x814, 0x020C3D10, + 0x818, 0x02200385, + 0x81C, 0x00000000, + 0x820, 0x01000100, + 0x824, 0x00390204, + 0x828, 0x00000000, + 0x82C, 0x00000000, + 0x830, 0x00000000, + 0x834, 0x00000000, + 0x838, 0x00000000, + 0x83C, 0x00000000, + 0x840, 0x00010000, + 0x844, 0x00000000, + 0x848, 0x00000000, + 0x84C, 0x00000000, + 0x850, 0x00000000, + 0x854, 0x00000000, + 0x858, 0x569A11A9, + 0x85C, 0x01000014, + 0x860, 0x66F60110, + 0x864, 0x061F0649, + 0x868, 0x00000000, + 0x86C, 0x27272700, + 0x870, 0x07000760, + 0x874, 0x25004000, + 0x878, 0x00000808, + 0x87C, 0x00000000, + 0x880, 0xB0000C1C, + 0x884, 0x00000001, + 0x888, 0x00000000, + 0x88C, 0xCCC000C0, + 0x890, 0x00000800, + 0x894, 0xFFFFFFFE, + 0x898, 0x40302010, + 0x89C, 0x00706050, + 0x900, 0x00000000, + 0x904, 0x00000023, + 0x908, 0x00000000, + 0x90C, 0x81121111, + 0x910, 0x00000002, + 0x914, 0x00000201, + 0xA00, 0x00D047C8, + 0xA04, 0x80FF000C, + 0xA08, 0x8C838300, + 0xA0C, 0x2E7F120F, + 0xA10, 0x9500BB78, + 0xA14, 0x1114D028, + 0xA18, 0x00881117, + 0xA1C, 0x89140F00, + 0xA20, 0x1A1B0000, + 0xA24, 0x090E1317, + 0xA28, 0x00000204, + 0xA2C, 0x00D30000, + 0xA70, 0x101FBF00, + 0xA74, 0x00000007, + 0xA78, 0x00000900, + 0xA7C, 0x225B0606, + 0xA80, 0x218075B1, + 0xB2C, 0x80000000, + 0xC00, 0x48071D40, + 0xC04, 0x03A05611, + 0xC08, 0x000000E4, + 0xC0C, 0x6C6C6C6C, + 0xC10, 0x08800000, + 0xC14, 0x40000100, + 0xC18, 0x08800000, + 0xC1C, 0x40000100, + 0xC20, 0x00000000, + 0xC24, 0x00000000, + 0xC28, 0x00000000, + 0xC2C, 0x00000000, + 0xC30, 0x69E9AC47, + 0xC34, 0x469652AF, + 0xC38, 0x49795994, + 0xC3C, 0x0A97971C, + 0xC40, 0x1F7C403F, + 0xC44, 0x000100B7, + 0xC48, 0xEC020107, + 0xC4C, 0x007F037F, + 0xC50, 0x69553420, + 0xC54, 0x43BC0094, + 0xC58, 0x00013169, + 0xC5C, 0x00250492, + 0xC60, 0x00000000, + 0xC64, 0x7112848B, + 0xC68, 0x47C00BFF, + 0xC6C, 0x00000036, + 0xC70, 0x2C7F000D, + 0xC74, 0x020610DB, + 0xC78, 0x0000001F, + 0xC7C, 0x00B91612, + 0xC80, 0x390000E4, + 0xC84, 0x20F60000, + 0xC88, 0x40000100, + 0xC8C, 0x20200000, + 0xC90, 0x00091521, + 0xC94, 0x00000000, + 0xC98, 0x00121820, + 0xC9C, 0x00007F7F, + 0xCA0, 0x00000000, + 0xCA4, 0x000300A0, + 0xCA8, 0x00000000, + 0xCAC, 0x00000000, + 0xCB0, 0x00000000, + 0xCB4, 0x00000000, + 0xCB8, 0x00000000, + 0xCBC, 0x28000000, + 0xCC0, 0x00000000, + 0xCC4, 0x00000000, + 0xCC8, 0x00000000, + 0xCCC, 0x00000000, + 0xCD0, 0x00000000, + 0xCD4, 0x00000000, + 0xCD8, 0x64B22427, + 0xCDC, 0x00766932, + 0xCE0, 0x00222222, + 0xCE4, 0x00000000, + 0xCE8, 0x37644302, + 0xCEC, 0x2F97D40C, + 0xD00, 0x00000740, + 0xD04, 0x00020401, + 0xD08, 0x0000907F, + 0xD0C, 0x20010201, + 0xD10, 0xA0633333, + 0xD14, 0x3333BC43, + 0xD18, 0x7A8F5B6F, + 0xD2C, 0xCC979975, + 0xD30, 0x00000000, + 0xD34, 0x80608000, + 0xD38, 0x00000000, + 0xD3C, 0x00127353, + 0xD40, 0x00000000, + 0xD44, 0x00000000, + 0xD48, 0x00000000, + 0xD4C, 0x00000000, + 0xD50, 0x6437140A, + 0xD54, 0x00000000, + 0xD58, 0x00000282, + 0xD5C, 0x30032064, + 0xD60, 0x4653DE68, + 0xD64, 0x04518A3C, + 0xD68, 0x00002101, + 0xD6C, 0x2A201C16, + 0xD70, 0x1812362E, + 0xD74, 0x322C2220, + 0xD78, 0x000E3C24, + 0xE00, 0x2D2D2D2D, + 0xE04, 0x2D2D2D2D, + 0xE08, 0x0390272D, + 0xE10, 0x2D2D2D2D, + 0xE14, 0x2D2D2D2D, + 0xE18, 0x2D2D2D2D, + 0xE1C, 0x2D2D2D2D, + 0xE28, 0x00000000, + 0xE30, 0x1000DC1F, + 0xE34, 0x10008C1F, + 0xE38, 0x02140102, + 0xE3C, 0x681604C2, + 0xE40, 0x01007C00, + 0xE44, 0x01004800, + 0xE48, 0xFB000000, + 0xE4C, 0x000028D1, + 0xE50, 0x1000DC1F, + 0xE54, 0x10008C1F, + 0xE58, 0x02140102, + 0xE5C, 0x28160D05, + 0xE60, 0x00000008, + 0xE68, 0x001B25A4, + 0xE6C, 0x00C00014, + 0xE70, 0x00C00014, + 0xE74, 0x01000014, + 0xE78, 0x01000014, + 0xE7C, 0x01000014, + 0xE80, 0x01000014, + 0xE84, 0x00C00014, + 0xE88, 0x01000014, + 0xE8C, 0x00C00014, + 0xED0, 0x00C00014, + 0xED4, 0x00C00014, + 0xED8, 0x00C00014, + 0xEDC, 0x00000014, + 0xEE0, 0x00000014, + 0xEEC, 0x01C00014, + 0xF14, 0x00000003, + 0xF4C, 0x00000000, + 0xF00, 0x00000300, +}; + +enum HAL_STATUS ODM_ReadAndConfig_PHY_REG_1T_8188E(struct odm_dm_struct *dm_odm) +{ + u32 hex = 0; + u32 i = 0; + u8 platform = dm_odm->SupportPlatform; + u8 interfaceValue = dm_odm->SupportInterface; + u8 board = dm_odm->BoardType; + u32 arraylen = sizeof(array_phy_reg_1t_8188e)/sizeof(u32); + u32 *array = array_phy_reg_1t_8188e; + bool biol = false; + struct adapter *adapter = dm_odm->Adapter; + struct xmit_frame *pxmit_frame = NULL; + u8 bndy_cnt = 1; + enum HAL_STATUS rst = HAL_STATUS_SUCCESS; + hex += board; + hex += interfaceValue << 8; + hex += platform << 16; + hex += 0xFF000000; + biol = rtw_IOL_applied(adapter); + + if (biol) { + pxmit_frame = rtw_IOL_accquire_xmit_frame(adapter); + if (pxmit_frame == NULL) { + pr_info("rtw_IOL_accquire_xmit_frame failed\n"); + return HAL_STATUS_FAILURE; + } + } + + for (i = 0; i < arraylen; i += 2) { + u32 v1 = array[i]; + u32 v2 = array[i+1]; + + /* This (offset, data) pair meets the condition. */ + if (v1 < 0xCDCDCDCD) { + if (biol) { + if (rtw_IOL_cmd_boundary_handle(pxmit_frame)) + bndy_cnt++; + if (v1 == 0xfe) { + rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 50); + } else if (v1 == 0xfd) { + rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 5); + } else if (v1 == 0xfc) { + rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 1); + } else if (v1 == 0xfb) { + rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 50); + } else if (v1 == 0xfa) { + rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 5); + } else if (v1 == 0xf9) { + rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 1); + } else { + if (v1 == 0xa24) + dm_odm->RFCalibrateInfo.RegA24 = v2; + rtw_IOL_append_WD_cmd(pxmit_frame, (u16)v1, v2, bMaskDWord); + } + } else { + odm_ConfigBB_PHY_8188E(dm_odm, v1, bMaskDWord, v2); + } + continue; + } else { /* This line is the start line of branch. */ + if (!CheckCondition(array[i], hex)) { + /* Discard the following (offset, data) pairs. */ + read_next_pair(array, v1, v2, i); + while (v2 != 0xDEAD && + v2 != 0xCDEF && + v2 != 0xCDCD && i < arraylen - 2) + read_next_pair(array, v1, v2, i); + i -= 2; /* prevent from for-loop += 2 */ + } else { /* Configure matched pairs and skip to end of if-else. */ + read_next_pair(array, v1, v2, i); + while (v2 != 0xDEAD && + v2 != 0xCDEF && + v2 != 0xCDCD && i < arraylen - 2) { + if (biol) { + if (rtw_IOL_cmd_boundary_handle(pxmit_frame)) + bndy_cnt++; + if (v1 == 0xfe) { + rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 50); + } else if (v1 == 0xfd) { + rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 5); + } else if (v1 == 0xfc) { + rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 1); + } else if (v1 == 0xfb) { + rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 50); + } else if (v1 == 0xfa) { + rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 5); + } else if (v1 == 0xf9) { + rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 1); + } else{ + if (v1 == 0xa24) + dm_odm->RFCalibrateInfo.RegA24 = v2; + + rtw_IOL_append_WD_cmd(pxmit_frame, (u16)v1, v2, bMaskDWord); + } + } else { + odm_ConfigBB_PHY_8188E(dm_odm, v1, bMaskDWord, v2); + } + read_next_pair(array, v1, v2, i); + } + + while (v2 != 0xDEAD && i < arraylen - 2) + read_next_pair(array, v1, v2, i); + } + } + } + if (biol) { + if (!rtw_IOL_exec_cmds_sync(dm_odm->Adapter, pxmit_frame, 1000, bndy_cnt)) { + rst = HAL_STATUS_FAILURE; + pr_info("~~~ IOL Config %s Failed !!!\n", __func__); + } + } + return rst; +} + +/****************************************************************************** +* PHY_REG_PG.TXT +******************************************************************************/ + +static u32 array_phy_reg_pg_8188e[] = { + 0xE00, 0xFFFFFFFF, 0x06070809, + 0xE04, 0xFFFFFFFF, 0x02020405, + 0xE08, 0x0000FF00, 0x00000006, + 0x86C, 0xFFFFFF00, 0x00020400, + 0xE10, 0xFFFFFFFF, 0x08090A0B, + 0xE14, 0xFFFFFFFF, 0x01030607, + 0xE18, 0xFFFFFFFF, 0x08090A0B, + 0xE1C, 0xFFFFFFFF, 0x01030607, + 0xE00, 0xFFFFFFFF, 0x00000000, + 0xE04, 0xFFFFFFFF, 0x00000000, + 0xE08, 0x0000FF00, 0x00000000, + 0x86C, 0xFFFFFF00, 0x00000000, + 0xE10, 0xFFFFFFFF, 0x00000000, + 0xE14, 0xFFFFFFFF, 0x00000000, + 0xE18, 0xFFFFFFFF, 0x00000000, + 0xE1C, 0xFFFFFFFF, 0x00000000, + 0xE00, 0xFFFFFFFF, 0x02020202, + 0xE04, 0xFFFFFFFF, 0x00020202, + 0xE08, 0x0000FF00, 0x00000000, + 0x86C, 0xFFFFFF00, 0x00000000, + 0xE10, 0xFFFFFFFF, 0x04040404, + 0xE14, 0xFFFFFFFF, 0x00020404, + 0xE18, 0xFFFFFFFF, 0x00000000, + 0xE1C, 0xFFFFFFFF, 0x00000000, + 0xE00, 0xFFFFFFFF, 0x02020202, + 0xE04, 0xFFFFFFFF, 0x00020202, + 0xE08, 0x0000FF00, 0x00000000, + 0x86C, 0xFFFFFF00, 0x00000000, + 0xE10, 0xFFFFFFFF, 0x04040404, + 0xE14, 0xFFFFFFFF, 0x00020404, + 0xE18, 0xFFFFFFFF, 0x00000000, + 0xE1C, 0xFFFFFFFF, 0x00000000, + 0xE00, 0xFFFFFFFF, 0x00000000, + 0xE04, 0xFFFFFFFF, 0x00000000, + 0xE08, 0x0000FF00, 0x00000000, + 0x86C, 0xFFFFFF00, 0x00000000, + 0xE10, 0xFFFFFFFF, 0x00000000, + 0xE14, 0xFFFFFFFF, 0x00000000, + 0xE18, 0xFFFFFFFF, 0x00000000, + 0xE1C, 0xFFFFFFFF, 0x00000000, + 0xE00, 0xFFFFFFFF, 0x02020202, + 0xE04, 0xFFFFFFFF, 0x00020202, + 0xE08, 0x0000FF00, 0x00000000, + 0x86C, 0xFFFFFF00, 0x00000000, + 0xE10, 0xFFFFFFFF, 0x04040404, + 0xE14, 0xFFFFFFFF, 0x00020404, + 0xE18, 0xFFFFFFFF, 0x00000000, + 0xE1C, 0xFFFFFFFF, 0x00000000, + 0xE00, 0xFFFFFFFF, 0x00000000, + 0xE04, 0xFFFFFFFF, 0x00000000, + 0xE08, 0x0000FF00, 0x00000000, + 0x86C, 0xFFFFFF00, 0x00000000, + 0xE10, 0xFFFFFFFF, 0x00000000, + 0xE14, 0xFFFFFFFF, 0x00000000, + 0xE18, 0xFFFFFFFF, 0x00000000, + 0xE1C, 0xFFFFFFFF, 0x00000000, + 0xE00, 0xFFFFFFFF, 0x00000000, + 0xE04, 0xFFFFFFFF, 0x00000000, + 0xE08, 0x0000FF00, 0x00000000, + 0x86C, 0xFFFFFF00, 0x00000000, + 0xE10, 0xFFFFFFFF, 0x00000000, + 0xE14, 0xFFFFFFFF, 0x00000000, + 0xE18, 0xFFFFFFFF, 0x00000000, + 0xE1C, 0xFFFFFFFF, 0x00000000, + 0xE00, 0xFFFFFFFF, 0x00000000, + 0xE04, 0xFFFFFFFF, 0x00000000, + 0xE08, 0x0000FF00, 0x00000000, + 0x86C, 0xFFFFFF00, 0x00000000, + 0xE10, 0xFFFFFFFF, 0x00000000, + 0xE14, 0xFFFFFFFF, 0x00000000, + 0xE18, 0xFFFFFFFF, 0x00000000, + 0xE1C, 0xFFFFFFFF, 0x00000000, + 0xE00, 0xFFFFFFFF, 0x00000000, + 0xE04, 0xFFFFFFFF, 0x00000000, + 0xE08, 0x0000FF00, 0x00000000, + 0x86C, 0xFFFFFF00, 0x00000000, + 0xE10, 0xFFFFFFFF, 0x00000000, + 0xE14, 0xFFFFFFFF, 0x00000000, + 0xE18, 0xFFFFFFFF, 0x00000000, + 0xE1C, 0xFFFFFFFF, 0x00000000, + 0xE00, 0xFFFFFFFF, 0x00000000, + 0xE04, 0xFFFFFFFF, 0x00000000, + 0xE08, 0x0000FF00, 0x00000000, + 0x86C, 0xFFFFFF00, 0x00000000, + 0xE10, 0xFFFFFFFF, 0x00000000, + 0xE14, 0xFFFFFFFF, 0x00000000, + 0xE18, 0xFFFFFFFF, 0x00000000, + 0xE1C, 0xFFFFFFFF, 0x00000000, + +}; + +void ODM_ReadAndConfig_PHY_REG_PG_8188E(struct odm_dm_struct *dm_odm) +{ + u32 hex; + u32 i = 0; + u8 platform = dm_odm->SupportPlatform; + u8 interfaceValue = dm_odm->SupportInterface; + u8 board = dm_odm->BoardType; + u32 arraylen = sizeof(array_phy_reg_pg_8188e) / sizeof(u32); + u32 *array = array_phy_reg_pg_8188e; + + hex = board + (interfaceValue << 8); + hex += (platform << 16) + 0xFF000000; + + for (i = 0; i < arraylen; i += 3) { + u32 v1 = array[i]; + u32 v2 = array[i+1]; + u32 v3 = array[i+2]; + + /* this line is a line of pure_body */ + if (v1 < 0xCDCDCDCD) { + odm_ConfigBB_PHY_REG_PG_8188E(dm_odm, v1, v2, v3); + continue; + } else { /* this line is the start of branch */ + if (!CheckCondition(array[i], hex)) { + /* don't need the hw_body */ + i += 2; /* skip the pair of expression */ + v1 = array[i]; + v2 = array[i+1]; + v3 = array[i+2]; + while (v2 != 0xDEAD) { + i += 3; + v1 = array[i]; + v2 = array[i+1]; + v3 = array[i+1]; + } + } + } + } +} diff --git a/drivers/staging/rtl8188eu/hal/HalHWImg8188E_MAC.c b/drivers/staging/rtl8188eu/hal/HalHWImg8188E_MAC.c new file mode 100644 index 0000000000000..b49b5ab48b182 --- /dev/null +++ b/drivers/staging/rtl8188eu/hal/HalHWImg8188E_MAC.c @@ -0,0 +1,231 @@ +/****************************************************************************** +* +* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* 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. +* +* You should have received a copy of the GNU General Public License along with +* this program; if not, write to the Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA +* +* +******************************************************************************/ + +#include "odm_precomp.h" +#include + +static bool Checkcondition(const u32 condition, const u32 hex) +{ + u32 _board = (hex & 0x000000FF); + u32 _interface = (hex & 0x0000FF00) >> 8; + u32 _platform = (hex & 0x00FF0000) >> 16; + u32 cond = condition; + + if (condition == 0xCDCDCDCD) + return true; + + cond = condition & 0x000000FF; + if ((_board == cond) && cond != 0x00) + return false; + + cond = condition & 0x0000FF00; + cond = cond >> 8; + if ((_interface & cond) == 0 && cond != 0x07) + return false; + + cond = condition & 0x00FF0000; + cond = cond >> 16; + if ((_platform & cond) == 0 && cond != 0x0F) + return false; + return true; +} + + +/****************************************************************************** +* MAC_REG.TXT +******************************************************************************/ + +static u32 array_MAC_REG_8188E[] = { + 0x026, 0x00000041, + 0x027, 0x00000035, + 0x428, 0x0000000A, + 0x429, 0x00000010, + 0x430, 0x00000000, + 0x431, 0x00000001, + 0x432, 0x00000002, + 0x433, 0x00000004, + 0x434, 0x00000005, + 0x435, 0x00000006, + 0x436, 0x00000007, + 0x437, 0x00000008, + 0x438, 0x00000000, + 0x439, 0x00000000, + 0x43A, 0x00000001, + 0x43B, 0x00000002, + 0x43C, 0x00000004, + 0x43D, 0x00000005, + 0x43E, 0x00000006, + 0x43F, 0x00000007, + 0x440, 0x0000005D, + 0x441, 0x00000001, + 0x442, 0x00000000, + 0x444, 0x00000015, + 0x445, 0x000000F0, + 0x446, 0x0000000F, + 0x447, 0x00000000, + 0x458, 0x00000041, + 0x459, 0x000000A8, + 0x45A, 0x00000072, + 0x45B, 0x000000B9, + 0x460, 0x00000066, + 0x461, 0x00000066, + 0x480, 0x00000008, + 0x4C8, 0x000000FF, + 0x4C9, 0x00000008, + 0x4CC, 0x000000FF, + 0x4CD, 0x000000FF, + 0x4CE, 0x00000001, + 0x4D3, 0x00000001, + 0x500, 0x00000026, + 0x501, 0x000000A2, + 0x502, 0x0000002F, + 0x503, 0x00000000, + 0x504, 0x00000028, + 0x505, 0x000000A3, + 0x506, 0x0000005E, + 0x507, 0x00000000, + 0x508, 0x0000002B, + 0x509, 0x000000A4, + 0x50A, 0x0000005E, + 0x50B, 0x00000000, + 0x50C, 0x0000004F, + 0x50D, 0x000000A4, + 0x50E, 0x00000000, + 0x50F, 0x00000000, + 0x512, 0x0000001C, + 0x514, 0x0000000A, + 0x516, 0x0000000A, + 0x525, 0x0000004F, + 0x550, 0x00000010, + 0x551, 0x00000010, + 0x559, 0x00000002, + 0x55D, 0x000000FF, + 0x605, 0x00000030, + 0x608, 0x0000000E, + 0x609, 0x0000002A, + 0x620, 0x000000FF, + 0x621, 0x000000FF, + 0x622, 0x000000FF, + 0x623, 0x000000FF, + 0x624, 0x000000FF, + 0x625, 0x000000FF, + 0x626, 0x000000FF, + 0x627, 0x000000FF, + 0x652, 0x00000020, + 0x63C, 0x0000000A, + 0x63D, 0x0000000A, + 0x63E, 0x0000000E, + 0x63F, 0x0000000E, + 0x640, 0x00000040, + 0x66E, 0x00000005, + 0x700, 0x00000021, + 0x701, 0x00000043, + 0x702, 0x00000065, + 0x703, 0x00000087, + 0x708, 0x00000021, + 0x709, 0x00000043, + 0x70A, 0x00000065, + 0x70B, 0x00000087, +}; + +enum HAL_STATUS ODM_ReadAndConfig_MAC_REG_8188E(struct odm_dm_struct *dm_odm) +{ + #define READ_NEXT_PAIR(v1, v2, i) do { i += 2; v1 = array[i]; v2 = array[i+1]; } while (0) + + u32 hex = 0; + u32 i; + u8 platform = dm_odm->SupportPlatform; + u8 interface_val = dm_odm->SupportInterface; + u8 board = dm_odm->BoardType; + u32 array_len = sizeof(array_MAC_REG_8188E)/sizeof(u32); + u32 *array = array_MAC_REG_8188E; + bool biol = false; + + struct adapter *adapt = dm_odm->Adapter; + struct xmit_frame *pxmit_frame = NULL; + u8 bndy_cnt = 1; + enum HAL_STATUS rst = HAL_STATUS_SUCCESS; + hex += board; + hex += interface_val << 8; + hex += platform << 16; + hex += 0xFF000000; + + biol = rtw_IOL_applied(adapt); + + if (biol) { + pxmit_frame = rtw_IOL_accquire_xmit_frame(adapt); + if (pxmit_frame == NULL) { + pr_info("rtw_IOL_accquire_xmit_frame failed\n"); + return HAL_STATUS_FAILURE; + } + } + + for (i = 0; i < array_len; i += 2) { + u32 v1 = array[i]; + u32 v2 = array[i+1]; + + /* This (offset, data) pair meets the condition. */ + if (v1 < 0xCDCDCDCD) { + if (biol) { + if (rtw_IOL_cmd_boundary_handle(pxmit_frame)) + bndy_cnt++; + rtw_IOL_append_WB_cmd(pxmit_frame, (u16)v1, (u8)v2, 0xFF); + } else { + odm_ConfigMAC_8188E(dm_odm, v1, (u8)v2); + } + continue; + } else { /* This line is the start line of branch. */ + if (!Checkcondition(array[i], hex)) { + /* Discard the following (offset, data) pairs. */ + READ_NEXT_PAIR(v1, v2, i); + while (v2 != 0xDEAD && + v2 != 0xCDEF && + v2 != 0xCDCD && i < array_len - 2) { + READ_NEXT_PAIR(v1, v2, i); + } + i -= 2; /* prevent from for-loop += 2 */ + } else { /* Configure matched pairs and skip to end of if-else. */ + READ_NEXT_PAIR(v1, v2, i); + while (v2 != 0xDEAD && + v2 != 0xCDEF && + v2 != 0xCDCD && i < array_len - 2) { + if (biol) { + if (rtw_IOL_cmd_boundary_handle(pxmit_frame)) + bndy_cnt++; + rtw_IOL_append_WB_cmd(pxmit_frame, (u16)v1, (u8)v2, 0xFF); + } else { + odm_ConfigMAC_8188E(dm_odm, v1, (u8)v2); + } + + READ_NEXT_PAIR(v1, v2, i); + } + while (v2 != 0xDEAD && i < array_len - 2) + READ_NEXT_PAIR(v1, v2, i); + } + } + } + if (biol) { + if (!rtw_IOL_exec_cmds_sync(dm_odm->Adapter, pxmit_frame, 1000, bndy_cnt)) { + pr_info("~~~ MAC IOL_exec_cmds Failed !!!\n"); + rst = HAL_STATUS_FAILURE; + } + } + return rst; +} diff --git a/drivers/staging/rtl8188eu/hal/HalHWImg8188E_RF.c b/drivers/staging/rtl8188eu/hal/HalHWImg8188E_RF.c new file mode 100644 index 0000000000000..480c810c44681 --- /dev/null +++ b/drivers/staging/rtl8188eu/hal/HalHWImg8188E_RF.c @@ -0,0 +1,269 @@ +/****************************************************************************** +* +* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* 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. +* +* You should have received a copy of the GNU General Public License along with +* this program; if not, write to the Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA +* +* +******************************************************************************/ + +#include "odm_precomp.h" + +#include + +static bool CheckCondition(const u32 Condition, const u32 Hex) +{ + u32 _board = (Hex & 0x000000FF); + u32 _interface = (Hex & 0x0000FF00) >> 8; + u32 _platform = (Hex & 0x00FF0000) >> 16; + u32 cond = Condition; + + if (Condition == 0xCDCDCDCD) + return true; + + cond = Condition & 0x000000FF; + if ((_board == cond) && cond != 0x00) + return false; + + cond = Condition & 0x0000FF00; + cond = cond >> 8; + if ((_interface & cond) == 0 && cond != 0x07) + return false; + + cond = Condition & 0x00FF0000; + cond = cond >> 16; + if ((_platform & cond) == 0 && cond != 0x0F) + return false; + return true; +} + + +/****************************************************************************** +* RadioA_1T.TXT +******************************************************************************/ + +static u32 Array_RadioA_1T_8188E[] = { + 0x000, 0x00030000, + 0x008, 0x00084000, + 0x018, 0x00000407, + 0x019, 0x00000012, + 0x01E, 0x00080009, + 0x01F, 0x00000880, + 0x02F, 0x0001A060, + 0x03F, 0x00000000, + 0x042, 0x000060C0, + 0x057, 0x000D0000, + 0x058, 0x000BE180, + 0x067, 0x00001552, + 0x083, 0x00000000, + 0x0B0, 0x000FF8FC, + 0x0B1, 0x00054400, + 0x0B2, 0x000CCC19, + 0x0B4, 0x00043003, + 0x0B6, 0x0004953E, + 0x0B7, 0x0001C718, + 0x0B8, 0x000060FF, + 0x0B9, 0x00080001, + 0x0BA, 0x00040000, + 0x0BB, 0x00000400, + 0x0BF, 0x000C0000, + 0x0C2, 0x00002400, + 0x0C3, 0x00000009, + 0x0C4, 0x00040C91, + 0x0C5, 0x00099999, + 0x0C6, 0x000000A3, + 0x0C7, 0x00088820, + 0x0C8, 0x00076C06, + 0x0C9, 0x00000000, + 0x0CA, 0x00080000, + 0x0DF, 0x00000180, + 0x0EF, 0x000001A0, + 0x051, 0x0006B27D, + 0xFF0F041F, 0xABCD, + 0x052, 0x0007E4DD, + 0xCDCDCDCD, 0xCDCD, + 0x052, 0x0007E49D, + 0xFF0F041F, 0xDEAD, + 0x053, 0x00000073, + 0x056, 0x00051FF3, + 0x035, 0x00000086, + 0x035, 0x00000186, + 0x035, 0x00000286, + 0x036, 0x00001C25, + 0x036, 0x00009C25, + 0x036, 0x00011C25, + 0x036, 0x00019C25, + 0x0B6, 0x00048538, + 0x018, 0x00000C07, + 0x05A, 0x0004BD00, + 0x019, 0x000739D0, + 0x034, 0x0000ADF3, + 0x034, 0x00009DF0, + 0x034, 0x00008DED, + 0x034, 0x00007DEA, + 0x034, 0x00006DE7, + 0x034, 0x000054EE, + 0x034, 0x000044EB, + 0x034, 0x000034E8, + 0x034, 0x0000246B, + 0x034, 0x00001468, + 0x034, 0x0000006D, + 0x000, 0x00030159, + 0x084, 0x00068200, + 0x086, 0x000000CE, + 0x087, 0x00048A00, + 0x08E, 0x00065540, + 0x08F, 0x00088000, + 0x0EF, 0x000020A0, + 0x03B, 0x000F02B0, + 0x03B, 0x000EF7B0, + 0x03B, 0x000D4FB0, + 0x03B, 0x000CF060, + 0x03B, 0x000B0090, + 0x03B, 0x000A0080, + 0x03B, 0x00090080, + 0x03B, 0x0008F780, + 0x03B, 0x000722B0, + 0x03B, 0x0006F7B0, + 0x03B, 0x00054FB0, + 0x03B, 0x0004F060, + 0x03B, 0x00030090, + 0x03B, 0x00020080, + 0x03B, 0x00010080, + 0x03B, 0x0000F780, + 0x0EF, 0x000000A0, + 0x000, 0x00010159, + 0x018, 0x0000F407, + 0xFFE, 0x00000000, + 0xFFE, 0x00000000, + 0x01F, 0x00080003, + 0xFFE, 0x00000000, + 0xFFE, 0x00000000, + 0x01E, 0x00000001, + 0x01F, 0x00080000, + 0x000, 0x00033E60, +}; + +enum HAL_STATUS ODM_ReadAndConfig_RadioA_1T_8188E(struct odm_dm_struct *pDM_Odm) +{ + #define READ_NEXT_PAIR(v1, v2, i) do \ + { i += 2; v1 = Array[i]; \ + v2 = Array[i+1]; } while (0) + + u32 hex = 0; + u32 i = 0; + u8 platform = pDM_Odm->SupportPlatform; + u8 interfaceValue = pDM_Odm->SupportInterface; + u8 board = pDM_Odm->BoardType; + u32 ArrayLen = sizeof(Array_RadioA_1T_8188E)/sizeof(u32); + u32 *Array = Array_RadioA_1T_8188E; + bool biol = false; + struct adapter *Adapter = pDM_Odm->Adapter; + struct xmit_frame *pxmit_frame = NULL; + u8 bndy_cnt = 1; + enum HAL_STATUS rst = HAL_STATUS_SUCCESS; + + hex += board; + hex += interfaceValue << 8; + hex += platform << 16; + hex += 0xFF000000; + biol = rtw_IOL_applied(Adapter); + + if (biol) { + pxmit_frame = rtw_IOL_accquire_xmit_frame(Adapter); + if (pxmit_frame == NULL) { + pr_info("rtw_IOL_accquire_xmit_frame failed\n"); + return HAL_STATUS_FAILURE; + } + } + + for (i = 0; i < ArrayLen; i += 2) { + u32 v1 = Array[i]; + u32 v2 = Array[i+1]; + + /* This (offset, data) pair meets the condition. */ + if (v1 < 0xCDCDCDCD) { + if (biol) { + if (rtw_IOL_cmd_boundary_handle(pxmit_frame)) + bndy_cnt++; + + if (v1 == 0xffe) + rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 50); + else if (v1 == 0xfd) + rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 5); + else if (v1 == 0xfc) + rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 1); + else if (v1 == 0xfb) + rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 50); + else if (v1 == 0xfa) + rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 5); + else if (v1 == 0xf9) + rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 1); + else + rtw_IOL_append_WRF_cmd(pxmit_frame, ODM_RF_PATH_A, (u16)v1, v2, bRFRegOffsetMask); + } else { + odm_ConfigRF_RadioA_8188E(pDM_Odm, v1, v2); + } + continue; + } else { /* This line is the start line of branch. */ + if (!CheckCondition(Array[i], hex)) { + /* Discard the following (offset, data) pairs. */ + READ_NEXT_PAIR(v1, v2, i); + while (v2 != 0xDEAD && + v2 != 0xCDEF && + v2 != 0xCDCD && i < ArrayLen - 2) + READ_NEXT_PAIR(v1, v2, i); + i -= 2; /* prevent from for-loop += 2 */ + } else { /* Configure matched pairs and skip to end of if-else. */ + READ_NEXT_PAIR(v1, v2, i); + while (v2 != 0xDEAD && + v2 != 0xCDEF && + v2 != 0xCDCD && i < ArrayLen - 2) { + if (biol) { + if (rtw_IOL_cmd_boundary_handle(pxmit_frame)) + bndy_cnt++; + + if (v1 == 0xffe) + rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 50); + else if (v1 == 0xfd) + rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 5); + else if (v1 == 0xfc) + rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 1); + else if (v1 == 0xfb) + rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 50); + else if (v1 == 0xfa) + rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 5); + else if (v1 == 0xf9) + rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 1); + else + rtw_IOL_append_WRF_cmd(pxmit_frame, ODM_RF_PATH_A, (u16)v1, v2, bRFRegOffsetMask); + } else { + odm_ConfigRF_RadioA_8188E(pDM_Odm, v1, v2); + } + READ_NEXT_PAIR(v1, v2, i); + } + + while (v2 != 0xDEAD && i < ArrayLen - 2) + READ_NEXT_PAIR(v1, v2, i); + } + } + } + if (biol) { + if (!rtw_IOL_exec_cmds_sync(pDM_Odm->Adapter, pxmit_frame, 1000, bndy_cnt)) { + rst = HAL_STATUS_FAILURE; + pr_info("~~~ IOL Config %s Failed !!!\n", __func__); + } + } + return rst; +} diff --git a/drivers/staging/rtl8188eu/hal/hal_com.c b/drivers/staging/rtl8188eu/hal/hal_com.c new file mode 100644 index 0000000000000..829b900ee9384 --- /dev/null +++ b/drivers/staging/rtl8188eu/hal/hal_com.c @@ -0,0 +1,381 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#include +#include + +#include +#include +#include + +#define _HAL_INIT_C_ + +void dump_chip_info(struct HAL_VERSION chip_vers) +{ + uint cnt = 0; + char buf[128]; + + if (IS_81XXC(chip_vers)) { + cnt += sprintf((buf+cnt), "Chip Version Info: %s_", + IS_92C_SERIAL(chip_vers) ? + "CHIP_8192C" : "CHIP_8188C"); + } else if (IS_92D(chip_vers)) { + cnt += sprintf((buf+cnt), "Chip Version Info: CHIP_8192D_"); + } else if (IS_8723_SERIES(chip_vers)) { + cnt += sprintf((buf+cnt), "Chip Version Info: CHIP_8723A_"); + } else if (IS_8188E(chip_vers)) { + cnt += sprintf((buf+cnt), "Chip Version Info: CHIP_8188E_"); + } + + cnt += sprintf((buf+cnt), "%s_", IS_NORMAL_CHIP(chip_vers) ? + "Normal_Chip" : "Test_Chip"); + cnt += sprintf((buf+cnt), "%s_", IS_CHIP_VENDOR_TSMC(chip_vers) ? + "TSMC" : "UMC"); + if (IS_A_CUT(chip_vers)) + cnt += sprintf((buf+cnt), "A_CUT_"); + else if (IS_B_CUT(chip_vers)) + cnt += sprintf((buf+cnt), "B_CUT_"); + else if (IS_C_CUT(chip_vers)) + cnt += sprintf((buf+cnt), "C_CUT_"); + else if (IS_D_CUT(chip_vers)) + cnt += sprintf((buf+cnt), "D_CUT_"); + else if (IS_E_CUT(chip_vers)) + cnt += sprintf((buf+cnt), "E_CUT_"); + else + cnt += sprintf((buf+cnt), "UNKNOWN_CUT(%d)_", + chip_vers.CUTVersion); + + if (IS_1T1R(chip_vers)) + cnt += sprintf((buf+cnt), "1T1R_"); + else if (IS_1T2R(chip_vers)) + cnt += sprintf((buf+cnt), "1T2R_"); + else if (IS_2T2R(chip_vers)) + cnt += sprintf((buf+cnt), "2T2R_"); + else + cnt += sprintf((buf+cnt), "UNKNOWN_RFTYPE(%d)_", + chip_vers.RFType); + + cnt += sprintf((buf+cnt), "RomVer(%d)\n", chip_vers.ROMVer); + + pr_info("%s", buf); +} + +#define CHAN_PLAN_HW 0x80 + +u8 /* return the final channel plan decision */ +hal_com_get_channel_plan(struct adapter *padapter, u8 hw_channel_plan, + u8 sw_channel_plan, u8 def_channel_plan, + bool load_fail) +{ + u8 sw_cfg; + u8 chnlplan; + + sw_cfg = true; + if (!load_fail) { + if (!rtw_is_channel_plan_valid(sw_channel_plan)) + sw_cfg = false; + if (hw_channel_plan & CHAN_PLAN_HW) + sw_cfg = false; + } + + if (sw_cfg) + chnlplan = sw_channel_plan; + else + chnlplan = hw_channel_plan & (~CHAN_PLAN_HW); + + if (!rtw_is_channel_plan_valid(chnlplan)) + chnlplan = def_channel_plan; + + return chnlplan; +} + +u8 MRateToHwRate(u8 rate) +{ + u8 ret = DESC_RATE1M; + + switch (rate) { + /* CCK and OFDM non-HT rates */ + case IEEE80211_CCK_RATE_1MB: + ret = DESC_RATE1M; + break; + case IEEE80211_CCK_RATE_2MB: + ret = DESC_RATE2M; + break; + case IEEE80211_CCK_RATE_5MB: + ret = DESC_RATE5_5M; + break; + case IEEE80211_CCK_RATE_11MB: + ret = DESC_RATE11M; + break; + case IEEE80211_OFDM_RATE_6MB: + ret = DESC_RATE6M; + break; + case IEEE80211_OFDM_RATE_9MB: + ret = DESC_RATE9M; + break; + case IEEE80211_OFDM_RATE_12MB: + ret = DESC_RATE12M; + break; + case IEEE80211_OFDM_RATE_18MB: + ret = DESC_RATE18M; + break; + case IEEE80211_OFDM_RATE_24MB: + ret = DESC_RATE24M; + break; + case IEEE80211_OFDM_RATE_36MB: + ret = DESC_RATE36M; + break; + case IEEE80211_OFDM_RATE_48MB: + ret = DESC_RATE48M; + break; + case IEEE80211_OFDM_RATE_54MB: + ret = DESC_RATE54M; + break; + default: + break; + } + return ret; +} + +void HalSetBrateCfg(struct adapter *adapt, u8 *brates, u16 *rate_cfg) +{ + u8 i, is_brate, brate; + + for (i = 0; i < NDIS_802_11_LENGTH_RATES_EX; i++) { + is_brate = brates[i] & IEEE80211_BASIC_RATE_MASK; + brate = brates[i] & 0x7f; + + if (is_brate) { + switch (brate) { + case IEEE80211_CCK_RATE_1MB: + *rate_cfg |= RATE_1M; + break; + case IEEE80211_CCK_RATE_2MB: + *rate_cfg |= RATE_2M; + break; + case IEEE80211_CCK_RATE_5MB: + *rate_cfg |= RATE_5_5M; + break; + case IEEE80211_CCK_RATE_11MB: + *rate_cfg |= RATE_11M; + break; + case IEEE80211_OFDM_RATE_6MB: + *rate_cfg |= RATE_6M; + break; + case IEEE80211_OFDM_RATE_9MB: + *rate_cfg |= RATE_9M; + break; + case IEEE80211_OFDM_RATE_12MB: + *rate_cfg |= RATE_12M; + break; + case IEEE80211_OFDM_RATE_18MB: + *rate_cfg |= RATE_18M; + break; + case IEEE80211_OFDM_RATE_24MB: + *rate_cfg |= RATE_24M; + break; + case IEEE80211_OFDM_RATE_36MB: + *rate_cfg |= RATE_36M; + break; + case IEEE80211_OFDM_RATE_48MB: + *rate_cfg |= RATE_48M; + break; + case IEEE80211_OFDM_RATE_54MB: + *rate_cfg |= RATE_54M; + break; + } + } + } +} + +static void one_out_pipe(struct adapter *adapter) +{ + struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapter); + + pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */ + pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[0];/* VI */ + pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[0];/* BE */ + pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[0];/* BK */ + + pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */ + pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */ + pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */ + pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */ +} + +static void two_out_pipe(struct adapter *adapter, bool wifi_cfg) +{ + struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapter); + + if (wifi_cfg) { /* WMM */ + /* BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA */ + /* 0, 1, 0, 1, 0, 0, 0, 0, 0}; */ + /* 0:H, 1:L */ + + pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[1];/* VO */ + pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[0];/* VI */ + pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[1];/* BE */ + pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[0];/* BK */ + + pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */ + pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */ + pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */ + pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */ + + } else {/* typical setting */ + /* BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA */ + /* 1, 1, 0, 0, 0, 0, 0, 0, 0}; */ + /* 0:H, 1:L */ + + pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */ + pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[0];/* VI */ + pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[1];/* BE */ + pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[1];/* BK */ + + pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */ + pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */ + pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */ + pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */ + } +} + +static void three_out_pipe(struct adapter *adapter, bool wifi_cfg) +{ + struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapter); + + if (wifi_cfg) {/* for WMM */ + /* BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA */ + /* 1, 2, 1, 0, 0, 0, 0, 0, 0}; */ + /* 0:H, 1:N, 2:L */ + + pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */ + pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[1];/* VI */ + pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[2];/* BE */ + pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[1];/* BK */ + + pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */ + pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */ + pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */ + pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */ + + } else {/* typical setting */ + /* BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA */ + /* 2, 2, 1, 0, 0, 0, 0, 0, 0}; */ + /* 0:H, 1:N, 2:L */ + + pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */ + pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[1];/* VI */ + pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[2];/* BE */ + pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[2];/* BK */ + + pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */ + pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */ + pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */ + pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */ + } +} + +bool Hal_MappingOutPipe(struct adapter *adapter, u8 numoutpipe) +{ + struct registry_priv *pregistrypriv = &adapter->registrypriv; + bool wifi_cfg = (pregistrypriv->wifi_spec) ? true : false; + bool result = true; + + switch (numoutpipe) { + case 2: + two_out_pipe(adapter, wifi_cfg); + break; + case 3: + three_out_pipe(adapter, wifi_cfg); + break; + case 1: + one_out_pipe(adapter); + break; + default: + result = false; + break; + } + return result; +} + +void hal_init_macaddr(struct adapter *adapter) +{ + rtw_hal_set_hwreg(adapter, HW_VAR_MAC_ADDR, + adapter->eeprompriv.mac_addr); +} + +/* +* C2H event format: +* Field TRIGGER CONTENT CMD_SEQ CMD_LEN CMD_ID +* BITS [127:120] [119:16] [15:8] [7:4] [3:0] +*/ + +void c2h_evt_clear(struct adapter *adapter) +{ + rtw_write8(adapter, REG_C2HEVT_CLEAR, C2H_EVT_HOST_CLOSE); +} + +s32 c2h_evt_read(struct adapter *adapter, u8 *buf) +{ + s32 ret = _FAIL; + struct c2h_evt_hdr *c2h_evt; + int i; + u8 trigger; + + if (buf == NULL) + goto exit; + + trigger = rtw_read8(adapter, REG_C2HEVT_CLEAR); + + if (trigger == C2H_EVT_HOST_CLOSE) + goto exit; /* Not ready */ + else if (trigger != C2H_EVT_FW_CLOSE) + goto clear_evt; /* Not a valid value */ + + c2h_evt = (struct c2h_evt_hdr *)buf; + + _rtw_memset(c2h_evt, 0, 16); + + *buf = rtw_read8(adapter, REG_C2HEVT_MSG_NORMAL); + *(buf+1) = rtw_read8(adapter, REG_C2HEVT_MSG_NORMAL + 1); + + RT_PRINT_DATA(_module_hal_init_c_, _drv_info_, "c2h_evt_read(): ", + &c2h_evt , sizeof(c2h_evt)); + + /* Read the content */ + for (i = 0; i < c2h_evt->plen; i++) + c2h_evt->payload[i] = rtw_read8(adapter, REG_C2HEVT_MSG_NORMAL + + sizeof(*c2h_evt) + i); + + RT_PRINT_DATA(_module_hal_init_c_, _drv_info_, + "c2h_evt_read(): Command Content:\n", + c2h_evt->payload, c2h_evt->plen); + + ret = _SUCCESS; + +clear_evt: + /* + * Clear event to notify FW we have read the command. + * If this field isn't clear, the FW won't update the next + * command message. + */ + c2h_evt_clear(adapter); +exit: + return ret; +} -- GitLab From 8ccfdd440eb6356ab1dfc45af0fad9dc607eceb8 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 21 Aug 2013 22:33:52 -0500 Subject: [PATCH 768/942] staging: r8188eu: Add files for new driver - part 10 This commit adds files hal/HalPhyRf.c, hal/HalPhyRf_8188e.c, and hal/hal_intf.c. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/HalPhyRf.c | 49 + .../staging/rtl8188eu/hal/HalPhyRf_8188e.c | 1928 +++++++++++++++++ drivers/staging/rtl8188eu/hal/hal_intf.c | 464 ++++ 3 files changed, 2441 insertions(+) create mode 100644 drivers/staging/rtl8188eu/hal/HalPhyRf.c create mode 100644 drivers/staging/rtl8188eu/hal/HalPhyRf_8188e.c create mode 100644 drivers/staging/rtl8188eu/hal/hal_intf.c diff --git a/drivers/staging/rtl8188eu/hal/HalPhyRf.c b/drivers/staging/rtl8188eu/hal/HalPhyRf.c new file mode 100644 index 0000000000000..980f7da8ab3bd --- /dev/null +++ b/drivers/staging/rtl8188eu/hal/HalPhyRf.c @@ -0,0 +1,49 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + + #include "odm_precomp.h" + +/* 3============================================================ */ +/* 3 IQ Calibration */ +/* 3============================================================ */ + +void ODM_ResetIQKResult(struct odm_dm_struct *pDM_Odm) +{ +} + +u8 ODM_GetRightChnlPlaceforIQK(u8 chnl) +{ + u8 channel_all[ODM_TARGET_CHNL_NUM_2G_5G] = { + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, + 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, + 124, 126, 128, 130, 132, 134, 136, 138, 140, 149, 151, 153, + 155, 157, 159, 161, 163, 165 + }; + u8 place = chnl; + + if (chnl > 14) { + for (place = 14; place < sizeof(channel_all); place++) { + if (channel_all[place] == chnl) + return place-13; + } + } + return 0; +} diff --git a/drivers/staging/rtl8188eu/hal/HalPhyRf_8188e.c b/drivers/staging/rtl8188eu/hal/HalPhyRf_8188e.c new file mode 100644 index 0000000000000..e4f20da91b433 --- /dev/null +++ b/drivers/staging/rtl8188eu/hal/HalPhyRf_8188e.c @@ -0,0 +1,1928 @@ + +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#include "odm_precomp.h" + +/*---------------------------Define Local Constant---------------------------*/ +/* 2010/04/25 MH Define the max tx power tracking tx agc power. */ +#define ODM_TXPWRTRACK_MAX_IDX_88E 6 + +/*---------------------------Define Local Constant---------------------------*/ + +/* 3============================================================ */ +/* 3 Tx Power Tracking */ +/* 3============================================================ */ +/*----------------------------------------------------------------------------- + * Function: ODM_TxPwrTrackAdjust88E() + * + * Overview: 88E we can not write 0xc80/c94/c4c/ 0xa2x. Instead of write TX agc. + * No matter OFDM & CCK use the same method. + * + * Input: NONE + * + * Output: NONE + * + * Return: NONE + * + * Revised History: + * When Who Remark + * 04/23/2012 MHC Create Version 0. + * 04/23/2012 MHC Adjust TX agc directly not throughput BB digital. + * + *---------------------------------------------------------------------------*/ +void ODM_TxPwrTrackAdjust88E(struct odm_dm_struct *dm_odm, u8 Type,/* 0 = OFDM, 1 = CCK */ + u8 *pDirection, /* 1 = +(increase) 2 = -(decrease) */ + u32 *pOutWriteVal /* Tx tracking CCK/OFDM BB swing index adjust */ + ) +{ + u8 pwr_value = 0; + /* Tx power tracking BB swing table. */ + /* The base index = 12. +((12-n)/2)dB 13~?? = decrease tx pwr by -((n-12)/2)dB */ + if (Type == 0) { /* For OFDM afjust */ + ODM_RT_TRACE(dm_odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, + ("BbSwingIdxOfdm = %d BbSwingFlagOfdm=%d\n", + dm_odm->BbSwingIdxOfdm, dm_odm->BbSwingFlagOfdm)); + + if (dm_odm->BbSwingIdxOfdm <= dm_odm->BbSwingIdxOfdmBase) { + *pDirection = 1; + pwr_value = (dm_odm->BbSwingIdxOfdmBase - dm_odm->BbSwingIdxOfdm); + } else { + *pDirection = 2; + pwr_value = (dm_odm->BbSwingIdxOfdm - dm_odm->BbSwingIdxOfdmBase); + } + + ODM_RT_TRACE(dm_odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, + ("BbSwingIdxOfdm = %d BbSwingFlagOfdm=%d\n", + dm_odm->BbSwingIdxOfdm, dm_odm->BbSwingFlagOfdm)); + } else if (Type == 1) { /* For CCK adjust. */ + ODM_RT_TRACE(dm_odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, + ("dm_odm->BbSwingIdxCck = %d dm_odm->BbSwingIdxCckBase = %d\n", + dm_odm->BbSwingIdxCck, dm_odm->BbSwingIdxCckBase)); + + if (dm_odm->BbSwingIdxCck <= dm_odm->BbSwingIdxCckBase) { + *pDirection = 1; + pwr_value = (dm_odm->BbSwingIdxCckBase - dm_odm->BbSwingIdxCck); + } else { + *pDirection = 2; + pwr_value = (dm_odm->BbSwingIdxCck - dm_odm->BbSwingIdxCckBase); + } + } + + /* */ + /* 2012/04/25 MH According to Ed/Luke.Lees estimate for EVM the max tx power tracking */ + /* need to be less than 6 power index for 88E. */ + /* */ + if (pwr_value >= ODM_TXPWRTRACK_MAX_IDX_88E && *pDirection == 1) + pwr_value = ODM_TXPWRTRACK_MAX_IDX_88E; + + *pOutWriteVal = pwr_value | (pwr_value<<8) | (pwr_value<<16) | (pwr_value<<24); +} /* ODM_TxPwrTrackAdjust88E */ + +/*----------------------------------------------------------------------------- + * Function: odm_TxPwrTrackSetPwr88E() + * + * Overview: 88E change all channel tx power accordign to flag. + * OFDM & CCK are all different. + * + * Input: NONE + * + * Output: NONE + * + * Return: NONE + * + * Revised History: + * When Who Remark + * 04/23/2012 MHC Create Version 0. + * + *---------------------------------------------------------------------------*/ +static void odm_TxPwrTrackSetPwr88E(struct odm_dm_struct *dm_odm) +{ + if (dm_odm->BbSwingFlagOfdm || dm_odm->BbSwingFlagCck) { + ODM_RT_TRACE(dm_odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, ("odm_TxPwrTrackSetPwr88E CH=%d\n", *(dm_odm->pChannel))); + PHY_SetTxPowerLevel8188E(dm_odm->Adapter, *(dm_odm->pChannel)); + dm_odm->BbSwingFlagOfdm = false; + dm_odm->BbSwingFlagCck = false; + } +} /* odm_TxPwrTrackSetPwr88E */ + +/* 091212 chiyokolin */ +void +odm_TXPowerTrackingCallback_ThermalMeter_8188E( + struct adapter *Adapter + ) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + u8 ThermalValue = 0, delta, delta_LCK, delta_IQK, offset; + u8 ThermalValue_AVG_count = 0; + u32 ThermalValue_AVG = 0; + s32 ele_A = 0, ele_D, TempCCk, X, value32; + s32 Y, ele_C = 0; + s8 OFDM_index[2], CCK_index = 0; + s8 OFDM_index_old[2] = {0, 0}, CCK_index_old = 0; + u32 i = 0, j = 0; + bool is2t = false; + + u8 OFDM_min_index = 6, rf; /* OFDM BB Swing should be less than +3.0dB, which is required by Arthur */ + u8 Indexforchannel = 0/*GetRightChnlPlaceforIQK(pHalData->CurrentChannel)*/; + s8 OFDM_index_mapping[2][index_mapping_NUM_88E] = { + {0, 0, 2, 3, 4, 4, /* 2.4G, decrease power */ + 5, 6, 7, 7, 8, 9, + 10, 10, 11}, /* For lower temperature, 20120220 updated on 20120220. */ + {0, 0, -1, -2, -3, -4, /* 2.4G, increase power */ + -4, -4, -4, -5, -7, -8, + -9, -9, -10}, + }; + u8 Thermal_mapping[2][index_mapping_NUM_88E] = { + {0, 2, 4, 6, 8, 10, /* 2.4G, decrease power */ + 12, 14, 16, 18, 20, 22, + 24, 26, 27}, + {0, 2, 4, 6, 8, 10, /* 2.4G,, increase power */ + 12, 14, 16, 18, 20, 22, + 25, 25, 25}, + }; + struct odm_dm_struct *dm_odm = &pHalData->odmpriv; + + /* 2012/04/25 MH Add for tx power tracking to set tx power in tx agc for 88E. */ + odm_TxPwrTrackSetPwr88E(dm_odm); + + dm_odm->RFCalibrateInfo.TXPowerTrackingCallbackCnt++; /* cosa add for debug */ + dm_odm->RFCalibrateInfo.bTXPowerTrackingInit = true; + + /* RFCalibrateInfo.RegA24 will be initialized when ODM HW configuring, but MP configures with para files. */ + dm_odm->RFCalibrateInfo.RegA24 = 0x090e1317; + + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("===>dm_TXPowerTrackingCallback_ThermalMeter_8188E txpowercontrol %d\n", + dm_odm->RFCalibrateInfo.TxPowerTrackControl)); + + ThermalValue = (u8)ODM_GetRFReg(dm_odm, RF_PATH_A, RF_T_METER_88E, 0xfc00); /* 0x42: RF Reg[15:10] 88E */ + + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("Readback Thermal Meter = 0x%x pre thermal meter 0x%x EEPROMthermalmeter 0x%x\n", + ThermalValue, dm_odm->RFCalibrateInfo.ThermalValue, pHalData->EEPROMThermalMeter)); + + if (is2t) + rf = 2; + else + rf = 1; + + if (ThermalValue) { + /* Query OFDM path A default setting */ + ele_D = ODM_GetBBReg(dm_odm, rOFDM0_XATxIQImbalance, bMaskDWord)&bMaskOFDM_D; + for (i = 0; i < OFDM_TABLE_SIZE_92D; i++) { /* find the index */ + if (ele_D == (OFDMSwingTable[i]&bMaskOFDM_D)) { + OFDM_index_old[0] = (u8)i; + dm_odm->BbSwingIdxOfdmBase = (u8)i; + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("Initial pathA ele_D reg0x%x = 0x%x, OFDM_index=0x%x\n", + rOFDM0_XATxIQImbalance, ele_D, OFDM_index_old[0])); + break; + } + } + + /* Query OFDM path B default setting */ + if (is2t) { + ele_D = ODM_GetBBReg(dm_odm, rOFDM0_XBTxIQImbalance, bMaskDWord)&bMaskOFDM_D; + for (i = 0; i < OFDM_TABLE_SIZE_92D; i++) { /* find the index */ + if (ele_D == (OFDMSwingTable[i]&bMaskOFDM_D)) { + OFDM_index_old[1] = (u8)i; + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("Initial pathB ele_D reg0x%x = 0x%x, OFDM_index=0x%x\n", + rOFDM0_XBTxIQImbalance, ele_D, OFDM_index_old[1])); + break; + } + } + } + + /* Query CCK default setting From 0xa24 */ + TempCCk = dm_odm->RFCalibrateInfo.RegA24; + + for (i = 0; i < CCK_TABLE_SIZE; i++) { + if (dm_odm->RFCalibrateInfo.bCCKinCH14) { + if (ODM_CompareMemory(dm_odm, (void *)&TempCCk, (void *)&CCKSwingTable_Ch14[i][2], 4) == 0) { + CCK_index_old = (u8)i; + dm_odm->BbSwingIdxCckBase = (u8)i; + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("Initial reg0x%x = 0x%x, CCK_index=0x%x, ch 14 %d\n", + rCCK0_TxFilter2, TempCCk, CCK_index_old, dm_odm->RFCalibrateInfo.bCCKinCH14)); + break; + } + } else { + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("RegA24: 0x%X, CCKSwingTable_Ch1_Ch13[%d][2]: CCKSwingTable_Ch1_Ch13[i][2]: 0x%X\n", + TempCCk, i, CCKSwingTable_Ch1_Ch13[i][2])); + if (ODM_CompareMemory(dm_odm, (void *)&TempCCk, (void *)&CCKSwingTable_Ch1_Ch13[i][2], 4) == 0) { + CCK_index_old = (u8)i; + dm_odm->BbSwingIdxCckBase = (u8)i; + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("Initial reg0x%x = 0x%x, CCK_index=0x%x, ch14 %d\n", + rCCK0_TxFilter2, TempCCk, CCK_index_old, dm_odm->RFCalibrateInfo.bCCKinCH14)); + break; + } + } + } + + if (!dm_odm->RFCalibrateInfo.ThermalValue) { + dm_odm->RFCalibrateInfo.ThermalValue = pHalData->EEPROMThermalMeter; + dm_odm->RFCalibrateInfo.ThermalValue_LCK = ThermalValue; + dm_odm->RFCalibrateInfo.ThermalValue_IQK = ThermalValue; + + for (i = 0; i < rf; i++) + dm_odm->RFCalibrateInfo.OFDM_index[i] = OFDM_index_old[i]; + dm_odm->RFCalibrateInfo.CCK_index = CCK_index_old; + } + + if (dm_odm->RFCalibrateInfo.bReloadtxpowerindex) + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("reload ofdm index for band switch\n")); + + /* calculate average thermal meter */ + dm_odm->RFCalibrateInfo.ThermalValue_AVG[dm_odm->RFCalibrateInfo.ThermalValue_AVG_index] = ThermalValue; + dm_odm->RFCalibrateInfo.ThermalValue_AVG_index++; + if (dm_odm->RFCalibrateInfo.ThermalValue_AVG_index == AVG_THERMAL_NUM_88E) + dm_odm->RFCalibrateInfo.ThermalValue_AVG_index = 0; + + for (i = 0; i < AVG_THERMAL_NUM_88E; i++) { + if (dm_odm->RFCalibrateInfo.ThermalValue_AVG[i]) { + ThermalValue_AVG += dm_odm->RFCalibrateInfo.ThermalValue_AVG[i]; + ThermalValue_AVG_count++; + } + } + + if (ThermalValue_AVG_count) { + ThermalValue = (u8)(ThermalValue_AVG / ThermalValue_AVG_count); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("AVG Thermal Meter = 0x%x\n", ThermalValue)); + } + + if (dm_odm->RFCalibrateInfo.bReloadtxpowerindex) { + delta = ThermalValue > pHalData->EEPROMThermalMeter ? + (ThermalValue - pHalData->EEPROMThermalMeter) : + (pHalData->EEPROMThermalMeter - ThermalValue); + dm_odm->RFCalibrateInfo.bReloadtxpowerindex = false; + dm_odm->RFCalibrateInfo.bDoneTxpower = false; + } else if (dm_odm->RFCalibrateInfo.bDoneTxpower) { + delta = (ThermalValue > dm_odm->RFCalibrateInfo.ThermalValue) ? + (ThermalValue - dm_odm->RFCalibrateInfo.ThermalValue) : + (dm_odm->RFCalibrateInfo.ThermalValue - ThermalValue); + } else { + delta = ThermalValue > pHalData->EEPROMThermalMeter ? + (ThermalValue - pHalData->EEPROMThermalMeter) : + (pHalData->EEPROMThermalMeter - ThermalValue); + } + delta_LCK = (ThermalValue > dm_odm->RFCalibrateInfo.ThermalValue_LCK) ? + (ThermalValue - dm_odm->RFCalibrateInfo.ThermalValue_LCK) : + (dm_odm->RFCalibrateInfo.ThermalValue_LCK - ThermalValue); + delta_IQK = (ThermalValue > dm_odm->RFCalibrateInfo.ThermalValue_IQK) ? + (ThermalValue - dm_odm->RFCalibrateInfo.ThermalValue_IQK) : + (dm_odm->RFCalibrateInfo.ThermalValue_IQK - ThermalValue); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("Readback Thermal Meter = 0x%x pre thermal meter 0x%x EEPROMthermalmeter 0x%x delta 0x%x delta_LCK 0x%x delta_IQK 0x%x\n", + ThermalValue, dm_odm->RFCalibrateInfo.ThermalValue, + pHalData->EEPROMThermalMeter, delta, delta_LCK, delta_IQK)); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("pre thermal meter LCK 0x%x pre thermal meter IQK 0x%x delta_LCK_bound 0x%x delta_IQK_bound 0x%x\n", + dm_odm->RFCalibrateInfo.ThermalValue_LCK, + dm_odm->RFCalibrateInfo.ThermalValue_IQK, + dm_odm->RFCalibrateInfo.Delta_LCK, + dm_odm->RFCalibrateInfo.Delta_IQK)); + + if ((delta_LCK >= 8)) { /* Delta temperature is equal to or larger than 20 centigrade. */ + dm_odm->RFCalibrateInfo.ThermalValue_LCK = ThermalValue; + PHY_LCCalibrate_8188E(Adapter); + } + + if (delta > 0 && dm_odm->RFCalibrateInfo.TxPowerTrackControl) { + delta = ThermalValue > pHalData->EEPROMThermalMeter ? + (ThermalValue - pHalData->EEPROMThermalMeter) : + (pHalData->EEPROMThermalMeter - ThermalValue); + /* calculate new OFDM / CCK offset */ + if (ThermalValue > pHalData->EEPROMThermalMeter) + j = 1; + else + j = 0; + for (offset = 0; offset < index_mapping_NUM_88E; offset++) { + if (delta < Thermal_mapping[j][offset]) { + if (offset != 0) + offset--; + break; + } + } + if (offset >= index_mapping_NUM_88E) + offset = index_mapping_NUM_88E-1; + for (i = 0; i < rf; i++) + OFDM_index[i] = dm_odm->RFCalibrateInfo.OFDM_index[i] + OFDM_index_mapping[j][offset]; + CCK_index = dm_odm->RFCalibrateInfo.CCK_index + OFDM_index_mapping[j][offset]; + + if (is2t) { + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("temp OFDM_A_index=0x%x, OFDM_B_index=0x%x, CCK_index=0x%x\n", + dm_odm->RFCalibrateInfo.OFDM_index[0], + dm_odm->RFCalibrateInfo.OFDM_index[1], + dm_odm->RFCalibrateInfo.CCK_index)); + } else { + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("temp OFDM_A_index=0x%x, CCK_index=0x%x\n", + dm_odm->RFCalibrateInfo.OFDM_index[0], + dm_odm->RFCalibrateInfo.CCK_index)); + } + + for (i = 0; i < rf; i++) { + if (OFDM_index[i] > OFDM_TABLE_SIZE_92D-1) + OFDM_index[i] = OFDM_TABLE_SIZE_92D-1; + else if (OFDM_index[i] < OFDM_min_index) + OFDM_index[i] = OFDM_min_index; + } + + if (CCK_index > CCK_TABLE_SIZE-1) + CCK_index = CCK_TABLE_SIZE-1; + else if (CCK_index < 0) + CCK_index = 0; + + if (is2t) { + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("new OFDM_A_index=0x%x, OFDM_B_index=0x%x, CCK_index=0x%x\n", + OFDM_index[0], OFDM_index[1], CCK_index)); + } else { + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("new OFDM_A_index=0x%x, CCK_index=0x%x\n", + OFDM_index[0], CCK_index)); + } + + /* 2 temporarily remove bNOPG */ + /* Config by SwingTable */ + if (dm_odm->RFCalibrateInfo.TxPowerTrackControl) { + dm_odm->RFCalibrateInfo.bDoneTxpower = true; + + /* Adujst OFDM Ant_A according to IQK result */ + ele_D = (OFDMSwingTable[(u8)OFDM_index[0]] & 0xFFC00000)>>22; + X = dm_odm->RFCalibrateInfo.IQKMatrixRegSetting[Indexforchannel].Value[0][0]; + Y = dm_odm->RFCalibrateInfo.IQKMatrixRegSetting[Indexforchannel].Value[0][1]; + + /* Revse TX power table. */ + dm_odm->BbSwingIdxOfdm = (u8)OFDM_index[0]; + dm_odm->BbSwingIdxCck = (u8)CCK_index; + + if (dm_odm->BbSwingIdxOfdmCurrent != dm_odm->BbSwingIdxOfdm) { + dm_odm->BbSwingIdxOfdmCurrent = dm_odm->BbSwingIdxOfdm; + dm_odm->BbSwingFlagOfdm = true; + } + + if (dm_odm->BbSwingIdxCckCurrent != dm_odm->BbSwingIdxCck) { + dm_odm->BbSwingIdxCckCurrent = dm_odm->BbSwingIdxCck; + dm_odm->BbSwingFlagCck = true; + } + + if (X != 0) { + if ((X & 0x00000200) != 0) + X = X | 0xFFFFFC00; + ele_A = ((X * ele_D)>>8)&0x000003FF; + + /* new element C = element D x Y */ + if ((Y & 0x00000200) != 0) + Y = Y | 0xFFFFFC00; + ele_C = ((Y * ele_D)>>8)&0x000003FF; + + /* 2012/04/23 MH According to Luke's suggestion, we can not write BB digital */ + /* to increase TX power. Otherwise, EVM will be bad. */ + } + + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("TxPwrTracking for path A: X=0x%x, Y=0x%x ele_A=0x%x ele_C=0x%x ele_D=0x%x 0xe94=0x%x 0xe9c=0x%x\n", + (u32)X, (u32)Y, (u32)ele_A, (u32)ele_C, (u32)ele_D, (u32)X, (u32)Y)); + + if (is2t) { + ele_D = (OFDMSwingTable[(u8)OFDM_index[1]] & 0xFFC00000)>>22; + + /* new element A = element D x X */ + X = dm_odm->RFCalibrateInfo.IQKMatrixRegSetting[Indexforchannel].Value[0][4]; + Y = dm_odm->RFCalibrateInfo.IQKMatrixRegSetting[Indexforchannel].Value[0][5]; + + if ((X != 0) && (*(dm_odm->pBandType) == ODM_BAND_2_4G)) { + if ((X & 0x00000200) != 0) /* consider minus */ + X = X | 0xFFFFFC00; + ele_A = ((X * ele_D)>>8)&0x000003FF; + + /* new element C = element D x Y */ + if ((Y & 0x00000200) != 0) + Y = Y | 0xFFFFFC00; + ele_C = ((Y * ele_D)>>8)&0x00003FF; + + /* wtite new elements A, C, D to regC88 and regC9C, element B is always 0 */ + value32 = (ele_D<<22) | ((ele_C&0x3F)<<16) | ele_A; + ODM_SetBBReg(dm_odm, rOFDM0_XBTxIQImbalance, bMaskDWord, value32); + + value32 = (ele_C&0x000003C0)>>6; + ODM_SetBBReg(dm_odm, rOFDM0_XDTxAFE, bMaskH4Bits, value32); + + value32 = ((X * ele_D)>>7)&0x01; + ODM_SetBBReg(dm_odm, rOFDM0_ECCAThreshold, BIT28, value32); + } else { + ODM_SetBBReg(dm_odm, rOFDM0_XBTxIQImbalance, bMaskDWord, OFDMSwingTable[(u8)OFDM_index[1]]); + ODM_SetBBReg(dm_odm, rOFDM0_XDTxAFE, bMaskH4Bits, 0x00); + ODM_SetBBReg(dm_odm, rOFDM0_ECCAThreshold, BIT28, 0x00); + } + + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("TxPwrTracking path B: X=0x%x, Y=0x%x ele_A=0x%x ele_C=0x%x ele_D=0x%x 0xeb4=0x%x 0xebc=0x%x\n", + (u32)X, (u32)Y, (u32)ele_A, + (u32)ele_C, (u32)ele_D, (u32)X, (u32)Y)); + } + + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("TxPwrTracking 0xc80 = 0x%x, 0xc94 = 0x%x RF 0x24 = 0x%x\n", + ODM_GetBBReg(dm_odm, 0xc80, bMaskDWord), ODM_GetBBReg(dm_odm, + 0xc94, bMaskDWord), ODM_GetRFReg(dm_odm, RF_PATH_A, 0x24, bRFRegOffsetMask))); + } + } + + if (delta_IQK >= 8) { /* Delta temperature is equal to or larger than 20 centigrade. */ + ODM_ResetIQKResult(dm_odm); + + dm_odm->RFCalibrateInfo.ThermalValue_IQK = ThermalValue; + PHY_IQCalibrate_8188E(Adapter, false); + } + /* update thermal meter value */ + if (dm_odm->RFCalibrateInfo.TxPowerTrackControl) + dm_odm->RFCalibrateInfo.ThermalValue = ThermalValue; + } + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("<===dm_TXPowerTrackingCallback_ThermalMeter_8188E\n")); + dm_odm->RFCalibrateInfo.TXPowercount = 0; +} + +/* 1 7. IQK */ +#define MAX_TOLERANCE 5 +#define IQK_DELAY_TIME 1 /* ms */ + +static u8 /* bit0 = 1 => Tx OK, bit1 = 1 => Rx OK */ +phy_PathA_IQK_8188E(struct adapter *adapt, bool configPathB) +{ + u32 regeac, regE94, regE9C, regEA4; + u8 result = 0x00; + struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); + struct odm_dm_struct *dm_odm = &pHalData->odmpriv; + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path A IQK!\n")); + + /* 1 Tx IQK */ + /* path-A IQK setting */ + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path-A IQK setting!\n")); + ODM_SetBBReg(dm_odm, rTx_IQK_Tone_A, bMaskDWord, 0x10008c1c); + ODM_SetBBReg(dm_odm, rRx_IQK_Tone_A, bMaskDWord, 0x30008c1c); + ODM_SetBBReg(dm_odm, rTx_IQK_PI_A, bMaskDWord, 0x8214032a); + ODM_SetBBReg(dm_odm, rRx_IQK_PI_A, bMaskDWord, 0x28160000); + + /* LO calibration setting */ + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("LO calibration setting!\n")); + ODM_SetBBReg(dm_odm, rIQK_AGC_Rsp, bMaskDWord, 0x00462911); + + /* One shot, path A LOK & IQK */ + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("One shot, path A LOK & IQK!\n")); + ODM_SetBBReg(dm_odm, rIQK_AGC_Pts, bMaskDWord, 0xf9000000); + ODM_SetBBReg(dm_odm, rIQK_AGC_Pts, bMaskDWord, 0xf8000000); + + /* delay x ms */ + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Delay %d ms for One shot, path A LOK & IQK.\n", IQK_DELAY_TIME_88E)); + /* PlatformStallExecution(IQK_DELAY_TIME_88E*1000); */ + ODM_delay_ms(IQK_DELAY_TIME_88E); + + /* Check failed */ + regeac = ODM_GetBBReg(dm_odm, rRx_Power_After_IQK_A_2, bMaskDWord); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("0xeac = 0x%x\n", regeac)); + regE94 = ODM_GetBBReg(dm_odm, rTx_Power_Before_IQK_A, bMaskDWord); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("0xe94 = 0x%x\n", regE94)); + regE9C = ODM_GetBBReg(dm_odm, rTx_Power_After_IQK_A, bMaskDWord); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("0xe9c = 0x%x\n", regE9C)); + regEA4 = ODM_GetBBReg(dm_odm, rRx_Power_Before_IQK_A_2, bMaskDWord); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("0xea4 = 0x%x\n", regEA4)); + + if (!(regeac & BIT28) && + (((regE94 & 0x03FF0000)>>16) != 0x142) && + (((regE9C & 0x03FF0000)>>16) != 0x42)) + result |= 0x01; + return result; +} + +static u8 /* bit0 = 1 => Tx OK, bit1 = 1 => Rx OK */ +phy_PathA_RxIQK(struct adapter *adapt, bool configPathB) +{ + u32 regeac, regE94, regE9C, regEA4, u4tmp; + u8 result = 0x00; + struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); + struct odm_dm_struct *dm_odm = &pHalData->odmpriv; + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path A Rx IQK!\n")); + + /* 1 Get TXIMR setting */ + /* modify RXIQK mode table */ + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path-A Rx IQK modify RXIQK mode table!\n")); + ODM_SetBBReg(dm_odm, rFPGA0_IQK, bMaskDWord, 0x00000000); + ODM_SetRFReg(dm_odm, RF_PATH_A, RF_WE_LUT, bRFRegOffsetMask, 0x800a0); + ODM_SetRFReg(dm_odm, RF_PATH_A, RF_RCK_OS, bRFRegOffsetMask, 0x30000); + ODM_SetRFReg(dm_odm, RF_PATH_A, RF_TXPA_G1, bRFRegOffsetMask, 0x0000f); + ODM_SetRFReg(dm_odm, RF_PATH_A, RF_TXPA_G2, bRFRegOffsetMask, 0xf117B); + + /* PA,PAD off */ + ODM_SetRFReg(dm_odm, RF_PATH_A, 0xdf, bRFRegOffsetMask, 0x980); + ODM_SetRFReg(dm_odm, RF_PATH_A, 0x56, bRFRegOffsetMask, 0x51000); + + ODM_SetBBReg(dm_odm, rFPGA0_IQK, bMaskDWord, 0x80800000); + + /* IQK setting */ + ODM_SetBBReg(dm_odm, rTx_IQK, bMaskDWord, 0x01007c00); + ODM_SetBBReg(dm_odm, rRx_IQK, bMaskDWord, 0x81004800); + + /* path-A IQK setting */ + ODM_SetBBReg(dm_odm, rTx_IQK_Tone_A, bMaskDWord, 0x10008c1c); + ODM_SetBBReg(dm_odm, rRx_IQK_Tone_A, bMaskDWord, 0x30008c1c); + ODM_SetBBReg(dm_odm, rTx_IQK_PI_A, bMaskDWord, 0x82160c1f); + ODM_SetBBReg(dm_odm, rRx_IQK_PI_A, bMaskDWord, 0x28160000); + + /* LO calibration setting */ + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("LO calibration setting!\n")); + ODM_SetBBReg(dm_odm, rIQK_AGC_Rsp, bMaskDWord, 0x0046a911); + + /* One shot, path A LOK & IQK */ + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("One shot, path A LOK & IQK!\n")); + ODM_SetBBReg(dm_odm, rIQK_AGC_Pts, bMaskDWord, 0xf9000000); + ODM_SetBBReg(dm_odm, rIQK_AGC_Pts, bMaskDWord, 0xf8000000); + + /* delay x ms */ + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("Delay %d ms for One shot, path A LOK & IQK.\n", + IQK_DELAY_TIME_88E)); + ODM_delay_ms(IQK_DELAY_TIME_88E); + + /* Check failed */ + regeac = ODM_GetBBReg(dm_odm, rRx_Power_After_IQK_A_2, bMaskDWord); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("0xeac = 0x%x\n", regeac)); + regE94 = ODM_GetBBReg(dm_odm, rTx_Power_Before_IQK_A, bMaskDWord); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("0xe94 = 0x%x\n", regE94)); + regE9C = ODM_GetBBReg(dm_odm, rTx_Power_After_IQK_A, bMaskDWord); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("0xe9c = 0x%x\n", regE9C)); + + if (!(regeac & BIT28) && + (((regE94 & 0x03FF0000)>>16) != 0x142) && + (((regE9C & 0x03FF0000)>>16) != 0x42)) + result |= 0x01; + else /* if Tx not OK, ignore Rx */ + return result; + + u4tmp = 0x80007C00 | (regE94&0x3FF0000) | ((regE9C&0x3FF0000) >> 16); + ODM_SetBBReg(dm_odm, rTx_IQK, bMaskDWord, u4tmp); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("0xe40 = 0x%x u4tmp = 0x%x\n", ODM_GetBBReg(dm_odm, rTx_IQK, bMaskDWord), u4tmp)); + + /* 1 RX IQK */ + /* modify RXIQK mode table */ + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path-A Rx IQK modify RXIQK mode table 2!\n")); + ODM_SetBBReg(dm_odm, rFPGA0_IQK, bMaskDWord, 0x00000000); + ODM_SetRFReg(dm_odm, RF_PATH_A, RF_WE_LUT, bRFRegOffsetMask, 0x800a0); + ODM_SetRFReg(dm_odm, RF_PATH_A, RF_RCK_OS, bRFRegOffsetMask, 0x30000); + ODM_SetRFReg(dm_odm, RF_PATH_A, RF_TXPA_G1, bRFRegOffsetMask, 0x0000f); + ODM_SetRFReg(dm_odm, RF_PATH_A, RF_TXPA_G2, bRFRegOffsetMask, 0xf7ffa); + ODM_SetBBReg(dm_odm, rFPGA0_IQK, bMaskDWord, 0x80800000); + + /* IQK setting */ + ODM_SetBBReg(dm_odm, rRx_IQK, bMaskDWord, 0x01004800); + + /* path-A IQK setting */ + ODM_SetBBReg(dm_odm, rTx_IQK_Tone_A, bMaskDWord, 0x38008c1c); + ODM_SetBBReg(dm_odm, rRx_IQK_Tone_A, bMaskDWord, 0x18008c1c); + ODM_SetBBReg(dm_odm, rTx_IQK_PI_A, bMaskDWord, 0x82160c05); + ODM_SetBBReg(dm_odm, rRx_IQK_PI_A, bMaskDWord, 0x28160c1f); + + /* LO calibration setting */ + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("LO calibration setting!\n")); + ODM_SetBBReg(dm_odm, rIQK_AGC_Rsp, bMaskDWord, 0x0046a911); + + /* One shot, path A LOK & IQK */ + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("One shot, path A LOK & IQK!\n")); + ODM_SetBBReg(dm_odm, rIQK_AGC_Pts, bMaskDWord, 0xf9000000); + ODM_SetBBReg(dm_odm, rIQK_AGC_Pts, bMaskDWord, 0xf8000000); + + /* delay x ms */ + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Delay %d ms for One shot, path A LOK & IQK.\n", IQK_DELAY_TIME_88E)); + /* PlatformStallExecution(IQK_DELAY_TIME_88E*1000); */ + ODM_delay_ms(IQK_DELAY_TIME_88E); + + /* Check failed */ + regeac = ODM_GetBBReg(dm_odm, rRx_Power_After_IQK_A_2, bMaskDWord); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("0xeac = 0x%x\n", regeac)); + regE94 = ODM_GetBBReg(dm_odm, rTx_Power_Before_IQK_A, bMaskDWord); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("0xe94 = 0x%x\n", regE94)); + regE9C = ODM_GetBBReg(dm_odm, rTx_Power_After_IQK_A, bMaskDWord); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("0xe9c = 0x%x\n", regE9C)); + regEA4 = ODM_GetBBReg(dm_odm, rRx_Power_Before_IQK_A_2, bMaskDWord); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("0xea4 = 0x%x\n", regEA4)); + + /* reload RF 0xdf */ + ODM_SetBBReg(dm_odm, rFPGA0_IQK, bMaskDWord, 0x00000000); + ODM_SetRFReg(dm_odm, RF_PATH_A, 0xdf, bRFRegOffsetMask, 0x180); + + if (!(regeac & BIT27) && /* if Tx is OK, check whether Rx is OK */ + (((regEA4 & 0x03FF0000)>>16) != 0x132) && + (((regeac & 0x03FF0000)>>16) != 0x36)) + result |= 0x02; + else + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path A Rx IQK fail!!\n")); + + return result; +} + +static u8 /* bit0 = 1 => Tx OK, bit1 = 1 => Rx OK */ +phy_PathB_IQK_8188E(struct adapter *adapt) +{ + u32 regeac, regeb4, regebc, regec4, regecc; + u8 result = 0x00; + struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); + struct odm_dm_struct *dm_odm = &pHalData->odmpriv; + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path B IQK!\n")); + + /* One shot, path B LOK & IQK */ + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("One shot, path A LOK & IQK!\n")); + ODM_SetBBReg(dm_odm, rIQK_AGC_Cont, bMaskDWord, 0x00000002); + ODM_SetBBReg(dm_odm, rIQK_AGC_Cont, bMaskDWord, 0x00000000); + + /* delay x ms */ + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("Delay %d ms for One shot, path B LOK & IQK.\n", + IQK_DELAY_TIME_88E)); + ODM_delay_ms(IQK_DELAY_TIME_88E); + + /* Check failed */ + regeac = ODM_GetBBReg(dm_odm, rRx_Power_After_IQK_A_2, bMaskDWord); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("0xeac = 0x%x\n", regeac)); + regeb4 = ODM_GetBBReg(dm_odm, rTx_Power_Before_IQK_B, bMaskDWord); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("0xeb4 = 0x%x\n", regeb4)); + regebc = ODM_GetBBReg(dm_odm, rTx_Power_After_IQK_B, bMaskDWord); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("0xebc = 0x%x\n", regebc)); + regec4 = ODM_GetBBReg(dm_odm, rRx_Power_Before_IQK_B_2, bMaskDWord); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("0xec4 = 0x%x\n", regec4)); + regecc = ODM_GetBBReg(dm_odm, rRx_Power_After_IQK_B_2, bMaskDWord); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("0xecc = 0x%x\n", regecc)); + + if (!(regeac & BIT31) && + (((regeb4 & 0x03FF0000)>>16) != 0x142) && + (((regebc & 0x03FF0000)>>16) != 0x42)) + result |= 0x01; + else + return result; + + if (!(regeac & BIT30) && + (((regec4 & 0x03FF0000)>>16) != 0x132) && + (((regecc & 0x03FF0000)>>16) != 0x36)) + result |= 0x02; + else + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path B Rx IQK fail!!\n")); + return result; +} + +static void patha_fill_iqk(struct adapter *adapt, bool iqkok, s32 result[][8], u8 final_candidate, bool txonly) +{ + u32 Oldval_0, X, TX0_A, reg; + s32 Y, TX0_C; + struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); + struct odm_dm_struct *dm_odm = &pHalData->odmpriv; + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("Path A IQ Calibration %s !\n", + (iqkok) ? "Success" : "Failed")); + + if (final_candidate == 0xFF) { + return; + } else if (iqkok) { + Oldval_0 = (ODM_GetBBReg(dm_odm, rOFDM0_XATxIQImbalance, bMaskDWord) >> 22) & 0x3FF; + + X = result[final_candidate][0]; + if ((X & 0x00000200) != 0) + X = X | 0xFFFFFC00; + TX0_A = (X * Oldval_0) >> 8; + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("X = 0x%x, TX0_A = 0x%x, Oldval_0 0x%x\n", + X, TX0_A, Oldval_0)); + ODM_SetBBReg(dm_odm, rOFDM0_XATxIQImbalance, 0x3FF, TX0_A); + + ODM_SetBBReg(dm_odm, rOFDM0_ECCAThreshold, BIT(31), ((X * Oldval_0>>7) & 0x1)); + + Y = result[final_candidate][1]; + if ((Y & 0x00000200) != 0) + Y = Y | 0xFFFFFC00; + + TX0_C = (Y * Oldval_0) >> 8; + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Y = 0x%x, TX = 0x%x\n", Y, TX0_C)); + ODM_SetBBReg(dm_odm, rOFDM0_XCTxAFE, 0xF0000000, ((TX0_C&0x3C0)>>6)); + ODM_SetBBReg(dm_odm, rOFDM0_XATxIQImbalance, 0x003F0000, (TX0_C&0x3F)); + + ODM_SetBBReg(dm_odm, rOFDM0_ECCAThreshold, BIT(29), ((Y * Oldval_0>>7) & 0x1)); + + if (txonly) { + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("patha_fill_iqk only Tx OK\n")); + return; + } + + reg = result[final_candidate][2]; + ODM_SetBBReg(dm_odm, rOFDM0_XARxIQImbalance, 0x3FF, reg); + + reg = result[final_candidate][3] & 0x3F; + ODM_SetBBReg(dm_odm, rOFDM0_XARxIQImbalance, 0xFC00, reg); + + reg = (result[final_candidate][3] >> 6) & 0xF; + ODM_SetBBReg(dm_odm, rOFDM0_RxIQExtAnta, 0xF0000000, reg); + } +} + +static void pathb_fill_iqk(struct adapter *adapt, bool iqkok, s32 result[][8], u8 final_candidate, bool txonly) +{ + u32 Oldval_1, X, TX1_A, reg; + s32 Y, TX1_C; + struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); + struct odm_dm_struct *dm_odm = &pHalData->odmpriv; + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("Path B IQ Calibration %s !\n", + (iqkok) ? "Success" : "Failed")); + + if (final_candidate == 0xFF) { + return; + } else if (iqkok) { + Oldval_1 = (ODM_GetBBReg(dm_odm, rOFDM0_XBTxIQImbalance, bMaskDWord) >> 22) & 0x3FF; + + X = result[final_candidate][4]; + if ((X & 0x00000200) != 0) + X = X | 0xFFFFFC00; + TX1_A = (X * Oldval_1) >> 8; + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("X = 0x%x, TX1_A = 0x%x\n", X, TX1_A)); + ODM_SetBBReg(dm_odm, rOFDM0_XBTxIQImbalance, 0x3FF, TX1_A); + + ODM_SetBBReg(dm_odm, rOFDM0_ECCAThreshold, BIT(27), ((X * Oldval_1>>7) & 0x1)); + + Y = result[final_candidate][5]; + if ((Y & 0x00000200) != 0) + Y = Y | 0xFFFFFC00; + + TX1_C = (Y * Oldval_1) >> 8; + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Y = 0x%x, TX1_C = 0x%x\n", Y, TX1_C)); + ODM_SetBBReg(dm_odm, rOFDM0_XDTxAFE, 0xF0000000, ((TX1_C&0x3C0)>>6)); + ODM_SetBBReg(dm_odm, rOFDM0_XBTxIQImbalance, 0x003F0000, (TX1_C&0x3F)); + + ODM_SetBBReg(dm_odm, rOFDM0_ECCAThreshold, BIT(25), ((Y * Oldval_1>>7) & 0x1)); + + if (txonly) + return; + + reg = result[final_candidate][6]; + ODM_SetBBReg(dm_odm, rOFDM0_XBRxIQImbalance, 0x3FF, reg); + + reg = result[final_candidate][7] & 0x3F; + ODM_SetBBReg(dm_odm, rOFDM0_XBRxIQImbalance, 0xFC00, reg); + + reg = (result[final_candidate][7] >> 6) & 0xF; + ODM_SetBBReg(dm_odm, rOFDM0_AGCRSSITable, 0x0000F000, reg); + } +} + +/* */ +/* 2011/07/26 MH Add an API for testing IQK fail case. */ +/* */ +/* MP Already declare in odm.c */ +static bool ODM_CheckPowerStatus(struct adapter *Adapter) +{ + return true; +} + +void _PHY_SaveADDARegisters(struct adapter *adapt, u32 *ADDAReg, u32 *ADDABackup, u32 RegisterNum) +{ + u32 i; + struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); + struct odm_dm_struct *dm_odm = &pHalData->odmpriv; + + if (ODM_CheckPowerStatus(adapt) == false) + return; + + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Save ADDA parameters.\n")); + for (i = 0; i < RegisterNum; i++) { + ADDABackup[i] = ODM_GetBBReg(dm_odm, ADDAReg[i], bMaskDWord); + } +} + +static void _PHY_SaveMACRegisters( + struct adapter *adapt, + u32 *MACReg, + u32 *MACBackup + ) +{ + u32 i; + struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); + struct odm_dm_struct *dm_odm = &pHalData->odmpriv; + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Save MAC parameters.\n")); + for (i = 0; i < (IQK_MAC_REG_NUM - 1); i++) { + MACBackup[i] = ODM_Read1Byte(dm_odm, MACReg[i]); + } + MACBackup[i] = ODM_Read4Byte(dm_odm, MACReg[i]); +} + +static void reload_adda_reg(struct adapter *adapt, u32 *ADDAReg, u32 *ADDABackup, u32 RegiesterNum) +{ + u32 i; + struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); + struct odm_dm_struct *dm_odm = &pHalData->odmpriv; + + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Reload ADDA power saving parameters !\n")); + for (i = 0; i < RegiesterNum; i++) + ODM_SetBBReg(dm_odm, ADDAReg[i], bMaskDWord, ADDABackup[i]); +} + +static void +_PHY_ReloadMACRegisters( + struct adapter *adapt, + u32 *MACReg, + u32 *MACBackup + ) +{ + u32 i; + struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); + struct odm_dm_struct *dm_odm = &pHalData->odmpriv; + + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Reload MAC parameters !\n")); + for (i = 0; i < (IQK_MAC_REG_NUM - 1); i++) { + ODM_Write1Byte(dm_odm, MACReg[i], (u8)MACBackup[i]); + } + ODM_Write4Byte(dm_odm, MACReg[i], MACBackup[i]); +} + +void +_PHY_PathADDAOn( + struct adapter *adapt, + u32 *ADDAReg, + bool isPathAOn, + bool is2t + ) +{ + u32 pathOn; + u32 i; + struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); + struct odm_dm_struct *dm_odm = &pHalData->odmpriv; + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("ADDA ON.\n")); + + pathOn = isPathAOn ? 0x04db25a4 : 0x0b1b25a4; + if (false == is2t) { + pathOn = 0x0bdb25a0; + ODM_SetBBReg(dm_odm, ADDAReg[0], bMaskDWord, 0x0b1b25a0); + } else { + ODM_SetBBReg(dm_odm, ADDAReg[0], bMaskDWord, pathOn); + } + + for (i = 1; i < IQK_ADDA_REG_NUM; i++) + ODM_SetBBReg(dm_odm, ADDAReg[i], bMaskDWord, pathOn); +} + +void +_PHY_MACSettingCalibration( + struct adapter *adapt, + u32 *MACReg, + u32 *MACBackup + ) +{ + u32 i = 0; + struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); + struct odm_dm_struct *dm_odm = &pHalData->odmpriv; + + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("MAC settings for Calibration.\n")); + + ODM_Write1Byte(dm_odm, MACReg[i], 0x3F); + + for (i = 1; i < (IQK_MAC_REG_NUM - 1); i++) { + ODM_Write1Byte(dm_odm, MACReg[i], (u8)(MACBackup[i]&(~BIT3))); + } + ODM_Write1Byte(dm_odm, MACReg[i], (u8)(MACBackup[i]&(~BIT5))); +} + +void +_PHY_PathAStandBy( + struct adapter *adapt + ) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); + struct odm_dm_struct *dm_odm = &pHalData->odmpriv; + + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path-A standby mode!\n")); + + ODM_SetBBReg(dm_odm, rFPGA0_IQK, bMaskDWord, 0x0); + ODM_SetBBReg(dm_odm, 0x840, bMaskDWord, 0x00010000); + ODM_SetBBReg(dm_odm, rFPGA0_IQK, bMaskDWord, 0x80800000); +} + +static void _PHY_PIModeSwitch( + struct adapter *adapt, + bool PIMode + ) +{ + u32 mode; + struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); + struct odm_dm_struct *dm_odm = &pHalData->odmpriv; + + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("BB Switch to %s mode!\n", (PIMode ? "PI" : "SI"))); + + mode = PIMode ? 0x01000100 : 0x01000000; + ODM_SetBBReg(dm_odm, rFPGA0_XA_HSSIParameter1, bMaskDWord, mode); + ODM_SetBBReg(dm_odm, rFPGA0_XB_HSSIParameter1, bMaskDWord, mode); +} + +static bool phy_SimularityCompare_8188E( + struct adapter *adapt, + s32 resulta[][8], + u8 c1, + u8 c2 + ) +{ + u32 i, j, diff, sim_bitmap, bound = 0; + struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); + struct odm_dm_struct *dm_odm = &pHalData->odmpriv; + u8 final_candidate[2] = {0xFF, 0xFF}; /* for path A and path B */ + bool result = true; + bool is2t; + s32 tmp1 = 0, tmp2 = 0; + + if ((dm_odm->RFType == ODM_2T2R) || (dm_odm->RFType == ODM_2T3R) || (dm_odm->RFType == ODM_2T4R)) + is2t = true; + else + is2t = false; + + if (is2t) + bound = 8; + else + bound = 4; + + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("===> IQK:phy_SimularityCompare_8188E c1 %d c2 %d!!!\n", c1, c2)); + + sim_bitmap = 0; + + for (i = 0; i < bound; i++) { + if ((i == 1) || (i == 3) || (i == 5) || (i == 7)) { + if ((resulta[c1][i] & 0x00000200) != 0) + tmp1 = resulta[c1][i] | 0xFFFFFC00; + else + tmp1 = resulta[c1][i]; + + if ((resulta[c2][i] & 0x00000200) != 0) + tmp2 = resulta[c2][i] | 0xFFFFFC00; + else + tmp2 = resulta[c2][i]; + } else { + tmp1 = resulta[c1][i]; + tmp2 = resulta[c2][i]; + } + + diff = (tmp1 > tmp2) ? (tmp1 - tmp2) : (tmp2 - tmp1); + + if (diff > MAX_TOLERANCE) { + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("IQK:phy_SimularityCompare_8188E differnece overflow index %d compare1 0x%x compare2 0x%x!!!\n", + i, resulta[c1][i], resulta[c2][i])); + + if ((i == 2 || i == 6) && !sim_bitmap) { + if (resulta[c1][i] + resulta[c1][i+1] == 0) + final_candidate[(i/4)] = c2; + else if (resulta[c2][i] + resulta[c2][i+1] == 0) + final_candidate[(i/4)] = c1; + else + sim_bitmap = sim_bitmap | (1<odmpriv; + u32 i; + u8 PathAOK, PathBOK; + u32 ADDA_REG[IQK_ADDA_REG_NUM] = { + rFPGA0_XCD_SwitchControl, rBlue_Tooth, + rRx_Wait_CCA, rTx_CCK_RFON, + rTx_CCK_BBON, rTx_OFDM_RFON, + rTx_OFDM_BBON, rTx_To_Rx, + rTx_To_Tx, rRx_CCK, + rRx_OFDM, rRx_Wait_RIFS, + rRx_TO_Rx, rStandby, + rSleep, rPMPD_ANAEN }; + u32 IQK_MAC_REG[IQK_MAC_REG_NUM] = { + REG_TXPAUSE, REG_BCN_CTRL, + REG_BCN_CTRL_1, REG_GPIO_MUXCFG}; + + /* since 92C & 92D have the different define in IQK_BB_REG */ + u32 IQK_BB_REG_92C[IQK_BB_REG_NUM] = { + rOFDM0_TRxPathEnable, rOFDM0_TRMuxPar, + rFPGA0_XCD_RFInterfaceSW, rConfig_AntA, rConfig_AntB, + rFPGA0_XAB_RFInterfaceSW, rFPGA0_XA_RFInterfaceOE, + rFPGA0_XB_RFInterfaceOE, rFPGA0_RFMOD + }; + + u32 retryCount = 9; + if (*(dm_odm->mp_mode) == 1) + retryCount = 9; + else + retryCount = 2; + /* Note: IQ calibration must be performed after loading */ + /* PHY_REG.txt , and radio_a, radio_b.txt */ + + if (t == 0) { + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQ Calibration for %s for %d times\n", (is2t ? "2T2R" : "1T1R"), t)); + + /* Save ADDA parameters, turn Path A ADDA on */ + _PHY_SaveADDARegisters(adapt, ADDA_REG, dm_odm->RFCalibrateInfo.ADDA_backup, IQK_ADDA_REG_NUM); + _PHY_SaveMACRegisters(adapt, IQK_MAC_REG, dm_odm->RFCalibrateInfo.IQK_MAC_backup); + _PHY_SaveADDARegisters(adapt, IQK_BB_REG_92C, dm_odm->RFCalibrateInfo.IQK_BB_backup, IQK_BB_REG_NUM); + } + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQ Calibration for %s for %d times\n", (is2t ? "2T2R" : "1T1R"), t)); + + _PHY_PathADDAOn(adapt, ADDA_REG, true, is2t); + if (t == 0) + dm_odm->RFCalibrateInfo.bRfPiEnable = (u8)ODM_GetBBReg(dm_odm, rFPGA0_XA_HSSIParameter1, BIT(8)); + + if (!dm_odm->RFCalibrateInfo.bRfPiEnable) { + /* Switch BB to PI mode to do IQ Calibration. */ + _PHY_PIModeSwitch(adapt, true); + } + + /* BB setting */ + ODM_SetBBReg(dm_odm, rFPGA0_RFMOD, BIT24, 0x00); + ODM_SetBBReg(dm_odm, rOFDM0_TRxPathEnable, bMaskDWord, 0x03a05600); + ODM_SetBBReg(dm_odm, rOFDM0_TRMuxPar, bMaskDWord, 0x000800e4); + ODM_SetBBReg(dm_odm, rFPGA0_XCD_RFInterfaceSW, bMaskDWord, 0x22204000); + + ODM_SetBBReg(dm_odm, rFPGA0_XAB_RFInterfaceSW, BIT10, 0x01); + ODM_SetBBReg(dm_odm, rFPGA0_XAB_RFInterfaceSW, BIT26, 0x01); + ODM_SetBBReg(dm_odm, rFPGA0_XA_RFInterfaceOE, BIT10, 0x00); + ODM_SetBBReg(dm_odm, rFPGA0_XB_RFInterfaceOE, BIT10, 0x00); + + if (is2t) { + ODM_SetBBReg(dm_odm, rFPGA0_XA_LSSIParameter, bMaskDWord, 0x00010000); + ODM_SetBBReg(dm_odm, rFPGA0_XB_LSSIParameter, bMaskDWord, 0x00010000); + } + + /* MAC settings */ + _PHY_MACSettingCalibration(adapt, IQK_MAC_REG, dm_odm->RFCalibrateInfo.IQK_MAC_backup); + + /* Page B init */ + /* AP or IQK */ + ODM_SetBBReg(dm_odm, rConfig_AntA, bMaskDWord, 0x0f600000); + + if (is2t) + ODM_SetBBReg(dm_odm, rConfig_AntB, bMaskDWord, 0x0f600000); + + /* IQ calibration setting */ + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQK setting!\n")); + ODM_SetBBReg(dm_odm, rFPGA0_IQK, bMaskDWord, 0x80800000); + ODM_SetBBReg(dm_odm, rTx_IQK, bMaskDWord, 0x01007c00); + ODM_SetBBReg(dm_odm, rRx_IQK, bMaskDWord, 0x81004800); + + for (i = 0; i < retryCount; i++) { + PathAOK = phy_PathA_IQK_8188E(adapt, is2t); + if (PathAOK == 0x01) { + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path A Tx IQK Success!!\n")); + result[t][0] = (ODM_GetBBReg(dm_odm, rTx_Power_Before_IQK_A, bMaskDWord)&0x3FF0000)>>16; + result[t][1] = (ODM_GetBBReg(dm_odm, rTx_Power_After_IQK_A, bMaskDWord)&0x3FF0000)>>16; + break; + } + } + + for (i = 0; i < retryCount; i++) { + PathAOK = phy_PathA_RxIQK(adapt, is2t); + if (PathAOK == 0x03) { + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path A Rx IQK Success!!\n")); + result[t][2] = (ODM_GetBBReg(dm_odm, rRx_Power_Before_IQK_A_2, bMaskDWord)&0x3FF0000)>>16; + result[t][3] = (ODM_GetBBReg(dm_odm, rRx_Power_After_IQK_A_2, bMaskDWord)&0x3FF0000)>>16; + break; + } else { + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path A Rx IQK Fail!!\n")); + } + } + + if (0x00 == PathAOK) { + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path A IQK failed!!\n")); + } + + if (is2t) { + _PHY_PathAStandBy(adapt); + + /* Turn Path B ADDA on */ + _PHY_PathADDAOn(adapt, ADDA_REG, false, is2t); + + for (i = 0; i < retryCount; i++) { + PathBOK = phy_PathB_IQK_8188E(adapt); + if (PathBOK == 0x03) { + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path B IQK Success!!\n")); + result[t][4] = (ODM_GetBBReg(dm_odm, rTx_Power_Before_IQK_B, bMaskDWord)&0x3FF0000)>>16; + result[t][5] = (ODM_GetBBReg(dm_odm, rTx_Power_After_IQK_B, bMaskDWord)&0x3FF0000)>>16; + result[t][6] = (ODM_GetBBReg(dm_odm, rRx_Power_Before_IQK_B_2, bMaskDWord)&0x3FF0000)>>16; + result[t][7] = (ODM_GetBBReg(dm_odm, rRx_Power_After_IQK_B_2, bMaskDWord)&0x3FF0000)>>16; + break; + } else if (i == (retryCount - 1) && PathBOK == 0x01) { /* Tx IQK OK */ + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path B Only Tx IQK Success!!\n")); + result[t][4] = (ODM_GetBBReg(dm_odm, rTx_Power_Before_IQK_B, bMaskDWord)&0x3FF0000)>>16; + result[t][5] = (ODM_GetBBReg(dm_odm, rTx_Power_After_IQK_B, bMaskDWord)&0x3FF0000)>>16; + } + } + + if (0x00 == PathBOK) { + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path B IQK failed!!\n")); + } + } + + /* Back to BB mode, load original value */ + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQK:Back to BB mode, load original value!\n")); + ODM_SetBBReg(dm_odm, rFPGA0_IQK, bMaskDWord, 0); + + if (t != 0) { + if (!dm_odm->RFCalibrateInfo.bRfPiEnable) { + /* Switch back BB to SI mode after finish IQ Calibration. */ + _PHY_PIModeSwitch(adapt, false); + } + + /* Reload ADDA power saving parameters */ + reload_adda_reg(adapt, ADDA_REG, dm_odm->RFCalibrateInfo.ADDA_backup, IQK_ADDA_REG_NUM); + + /* Reload MAC parameters */ + _PHY_ReloadMACRegisters(adapt, IQK_MAC_REG, dm_odm->RFCalibrateInfo.IQK_MAC_backup); + + reload_adda_reg(adapt, IQK_BB_REG_92C, dm_odm->RFCalibrateInfo.IQK_BB_backup, IQK_BB_REG_NUM); + + /* Restore RX initial gain */ + ODM_SetBBReg(dm_odm, rFPGA0_XA_LSSIParameter, bMaskDWord, 0x00032ed3); + if (is2t) + ODM_SetBBReg(dm_odm, rFPGA0_XB_LSSIParameter, bMaskDWord, 0x00032ed3); + + /* load 0xe30 IQC default value */ + ODM_SetBBReg(dm_odm, rTx_IQK_Tone_A, bMaskDWord, 0x01008c00); + ODM_SetBBReg(dm_odm, rRx_IQK_Tone_A, bMaskDWord, 0x01008c00); + } + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("phy_IQCalibrate_8188E() <==\n")); +} + +static void phy_LCCalibrate_8188E(struct adapter *adapt, bool is2t) +{ + u8 tmpreg; + u32 RF_Amode = 0, RF_Bmode = 0, LC_Cal; + struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); + struct odm_dm_struct *dm_odm = &pHalData->odmpriv; + + /* Check continuous TX and Packet TX */ + tmpreg = ODM_Read1Byte(dm_odm, 0xd03); + + if ((tmpreg&0x70) != 0) /* Deal with contisuous TX case */ + ODM_Write1Byte(dm_odm, 0xd03, tmpreg&0x8F); /* disable all continuous TX */ + else /* Deal with Packet TX case */ + ODM_Write1Byte(dm_odm, REG_TXPAUSE, 0xFF); /* block all queues */ + + if ((tmpreg&0x70) != 0) { + /* 1. Read original RF mode */ + /* Path-A */ + RF_Amode = PHY_QueryRFReg(adapt, RF_PATH_A, RF_AC, bMask12Bits); + + /* Path-B */ + if (is2t) + RF_Bmode = PHY_QueryRFReg(adapt, RF_PATH_B, RF_AC, bMask12Bits); + + /* 2. Set RF mode = standby mode */ + /* Path-A */ + ODM_SetRFReg(dm_odm, RF_PATH_A, RF_AC, bMask12Bits, (RF_Amode&0x8FFFF)|0x10000); + + /* Path-B */ + if (is2t) + ODM_SetRFReg(dm_odm, RF_PATH_B, RF_AC, bMask12Bits, (RF_Bmode&0x8FFFF)|0x10000); + } + + /* 3. Read RF reg18 */ + LC_Cal = PHY_QueryRFReg(adapt, RF_PATH_A, RF_CHNLBW, bMask12Bits); + + /* 4. Set LC calibration begin bit15 */ + ODM_SetRFReg(dm_odm, RF_PATH_A, RF_CHNLBW, bMask12Bits, LC_Cal|0x08000); + + ODM_sleep_ms(100); + + /* Restore original situation */ + if ((tmpreg&0x70) != 0) { + /* Deal with continuous TX case */ + /* Path-A */ + ODM_Write1Byte(dm_odm, 0xd03, tmpreg); + ODM_SetRFReg(dm_odm, RF_PATH_A, RF_AC, bMask12Bits, RF_Amode); + + /* Path-B */ + if (is2t) + ODM_SetRFReg(dm_odm, RF_PATH_B, RF_AC, bMask12Bits, RF_Bmode); + } else { + /* Deal with Packet TX case */ + ODM_Write1Byte(dm_odm, REG_TXPAUSE, 0x00); + } +} + +/* Analog Pre-distortion calibration */ +#define APK_BB_REG_NUM 8 +#define APK_CURVE_REG_NUM 4 +#define PATH_NUM 2 + +static void phy_APCalibrate_8188E(struct adapter *adapt, s8 delta, bool is2t) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); + struct odm_dm_struct *dm_odm = &pHalData->odmpriv; + u32 regD[PATH_NUM]; + u32 tmpreg, index, offset, apkbound; + u8 path, i, pathbound = PATH_NUM; + u32 BB_backup[APK_BB_REG_NUM]; + u32 BB_REG[APK_BB_REG_NUM] = { + rFPGA1_TxBlock, rOFDM0_TRxPathEnable, + rFPGA0_RFMOD, rOFDM0_TRMuxPar, + rFPGA0_XCD_RFInterfaceSW, rFPGA0_XAB_RFInterfaceSW, + rFPGA0_XA_RFInterfaceOE, rFPGA0_XB_RFInterfaceOE }; + u32 BB_AP_MODE[APK_BB_REG_NUM] = { + 0x00000020, 0x00a05430, 0x02040000, + 0x000800e4, 0x00204000 }; + u32 BB_normal_AP_MODE[APK_BB_REG_NUM] = { + 0x00000020, 0x00a05430, 0x02040000, + 0x000800e4, 0x22204000 }; + + u32 AFE_backup[IQK_ADDA_REG_NUM]; + u32 AFE_REG[IQK_ADDA_REG_NUM] = { + rFPGA0_XCD_SwitchControl, rBlue_Tooth, + rRx_Wait_CCA, rTx_CCK_RFON, + rTx_CCK_BBON, rTx_OFDM_RFON, + rTx_OFDM_BBON, rTx_To_Rx, + rTx_To_Tx, rRx_CCK, + rRx_OFDM, rRx_Wait_RIFS, + rRx_TO_Rx, rStandby, + rSleep, rPMPD_ANAEN }; + + u32 MAC_backup[IQK_MAC_REG_NUM]; + u32 MAC_REG[IQK_MAC_REG_NUM] = { + REG_TXPAUSE, REG_BCN_CTRL, + REG_BCN_CTRL_1, REG_GPIO_MUXCFG}; + + u32 APK_RF_init_value[PATH_NUM][APK_BB_REG_NUM] = { + {0x0852c, 0x1852c, 0x5852c, 0x1852c, 0x5852c}, + {0x2852e, 0x0852e, 0x3852e, 0x0852e, 0x0852e} + }; + + u32 APK_normal_RF_init_value[PATH_NUM][APK_BB_REG_NUM] = { + {0x0852c, 0x0a52c, 0x3a52c, 0x5a52c, 0x5a52c}, /* path settings equal to path b settings */ + {0x0852c, 0x0a52c, 0x5a52c, 0x5a52c, 0x5a52c} + }; + + u32 APK_RF_value_0[PATH_NUM][APK_BB_REG_NUM] = { + {0x52019, 0x52014, 0x52013, 0x5200f, 0x5208d}, + {0x5201a, 0x52019, 0x52016, 0x52033, 0x52050} + }; + + u32 APK_normal_RF_value_0[PATH_NUM][APK_BB_REG_NUM] = { + {0x52019, 0x52017, 0x52010, 0x5200d, 0x5206a}, /* path settings equal to path b settings */ + {0x52019, 0x52017, 0x52010, 0x5200d, 0x5206a} + }; + + u32 AFE_on_off[PATH_NUM] = { + 0x04db25a4, 0x0b1b25a4}; /* path A on path B off / path A off path B on */ + + u32 APK_offset[PATH_NUM] = { + rConfig_AntA, rConfig_AntB}; + + u32 APK_normal_offset[PATH_NUM] = { + rConfig_Pmpd_AntA, rConfig_Pmpd_AntB}; + + u32 APK_value[PATH_NUM] = { + 0x92fc0000, 0x12fc0000}; + + u32 APK_normal_value[PATH_NUM] = { + 0x92680000, 0x12680000}; + + s8 APK_delta_mapping[APK_BB_REG_NUM][13] = { + {-4, -3, -2, -2, -1, -1, 0, 1, 2, 3, 4, 5, 6}, + {-4, -3, -2, -2, -1, -1, 0, 1, 2, 3, 4, 5, 6}, + {-6, -4, -2, -2, -1, -1, 0, 1, 2, 3, 4, 5, 6}, + {-1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6}, + {-11, -9, -7, -5, -3, -1, 0, 0, 0, 0, 0, 0, 0} + }; + + u32 APK_normal_setting_value_1[13] = { + 0x01017018, 0xf7ed8f84, 0x1b1a1816, 0x2522201e, 0x322e2b28, + 0x433f3a36, 0x5b544e49, 0x7b726a62, 0xa69a8f84, 0xdfcfc0b3, + 0x12680000, 0x00880000, 0x00880000 + }; + + u32 APK_normal_setting_value_2[16] = { + 0x01c7021d, 0x01670183, 0x01000123, 0x00bf00e2, 0x008d00a3, + 0x0068007b, 0x004d0059, 0x003a0042, 0x002b0031, 0x001f0025, + 0x0017001b, 0x00110014, 0x000c000f, 0x0009000b, 0x00070008, + 0x00050006 + }; + + u32 APK_result[PATH_NUM][APK_BB_REG_NUM]; /* val_1_1a, val_1_2a, val_2a, val_3a, val_4a */ + s32 BB_offset, delta_V, delta_offset; + + if (*(dm_odm->mp_mode) == 1) { + struct mpt_context *pMptCtx = &(adapt->mppriv.MptCtx); + pMptCtx->APK_bound[0] = 45; + pMptCtx->APK_bound[1] = 52; + } + + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("==>phy_APCalibrate_8188E() delta %d\n", delta)); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("AP Calibration for %s\n", (is2t ? "2T2R" : "1T1R"))); + if (!is2t) + pathbound = 1; + + /* 2 FOR NORMAL CHIP SETTINGS */ + +/* Temporarily do not allow normal driver to do the following settings + * because these offset and value will cause RF internal PA to be + * unpredictably disabled by HW, such that RF Tx signal will disappear + * after disable/enable card many times on 88CU. RF SD and DD have not + * find the root cause, so we remove these actions temporarily. + */ + if (*(dm_odm->mp_mode) != 1) + return; + /* settings adjust for normal chip */ + for (index = 0; index < PATH_NUM; index++) { + APK_offset[index] = APK_normal_offset[index]; + APK_value[index] = APK_normal_value[index]; + AFE_on_off[index] = 0x6fdb25a4; + } + + for (index = 0; index < APK_BB_REG_NUM; index++) { + for (path = 0; path < pathbound; path++) { + APK_RF_init_value[path][index] = APK_normal_RF_init_value[path][index]; + APK_RF_value_0[path][index] = APK_normal_RF_value_0[path][index]; + } + BB_AP_MODE[index] = BB_normal_AP_MODE[index]; + } + + apkbound = 6; + + /* save BB default value */ + for (index = 0; index < APK_BB_REG_NUM; index++) { + if (index == 0) /* skip */ + continue; + BB_backup[index] = ODM_GetBBReg(dm_odm, BB_REG[index], bMaskDWord); + } + + /* save MAC default value */ + _PHY_SaveMACRegisters(adapt, MAC_REG, MAC_backup); + + /* save AFE default value */ + _PHY_SaveADDARegisters(adapt, AFE_REG, AFE_backup, IQK_ADDA_REG_NUM); + + for (path = 0; path < pathbound; path++) { + if (path == RF_PATH_A) { + /* path A APK */ + /* load APK setting */ + /* path-A */ + offset = rPdp_AntA; + for (index = 0; index < 11; index++) { + ODM_SetBBReg(dm_odm, offset, bMaskDWord, APK_normal_setting_value_1[index]); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("phy_APCalibrate_8188E() offset 0x%x value 0x%x\n", + offset, ODM_GetBBReg(dm_odm, offset, bMaskDWord))); + offset += 0x04; + } + + ODM_SetBBReg(dm_odm, rConfig_Pmpd_AntB, bMaskDWord, 0x12680000); + + offset = rConfig_AntA; + for (; index < 13; index++) { + ODM_SetBBReg(dm_odm, offset, bMaskDWord, APK_normal_setting_value_1[index]); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("phy_APCalibrate_8188E() offset 0x%x value 0x%x\n", + offset, ODM_GetBBReg(dm_odm, offset, bMaskDWord))); + offset += 0x04; + } + + /* page-B1 */ + ODM_SetBBReg(dm_odm, rFPGA0_IQK, bMaskDWord, 0x40000000); + + /* path A */ + offset = rPdp_AntA; + for (index = 0; index < 16; index++) { + ODM_SetBBReg(dm_odm, offset, bMaskDWord, APK_normal_setting_value_2[index]); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("phy_APCalibrate_8188E() offset 0x%x value 0x%x\n", + offset, ODM_GetBBReg(dm_odm, offset, bMaskDWord))); + + offset += 0x04; + } + ODM_SetBBReg(dm_odm, rFPGA0_IQK, bMaskDWord, 0x00000000); + } else if (path == RF_PATH_B) { + /* path B APK */ + /* load APK setting */ + /* path-B */ + offset = rPdp_AntB; + for (index = 0; index < 10; index++) { + ODM_SetBBReg(dm_odm, offset, bMaskDWord, APK_normal_setting_value_1[index]); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("phy_APCalibrate_8188E() offset 0x%x value 0x%x\n", + offset, ODM_GetBBReg(dm_odm, offset, bMaskDWord))); + + offset += 0x04; + } + ODM_SetBBReg(dm_odm, rConfig_Pmpd_AntA, bMaskDWord, 0x12680000); + PHY_SetBBReg(adapt, rConfig_Pmpd_AntB, bMaskDWord, 0x12680000); + + offset = rConfig_AntA; + index = 11; + for (; index < 13; index++) { /* offset 0xb68, 0xb6c */ + ODM_SetBBReg(dm_odm, offset, bMaskDWord, APK_normal_setting_value_1[index]); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("phy_APCalibrate_8188E() offset 0x%x value 0x%x\n", + offset, ODM_GetBBReg(dm_odm, offset, bMaskDWord))); + offset += 0x04; + } + + /* page-B1 */ + ODM_SetBBReg(dm_odm, rFPGA0_IQK, bMaskDWord, 0x40000000); + + /* path B */ + offset = 0xb60; + for (index = 0; index < 16; index++) { + ODM_SetBBReg(dm_odm, offset, bMaskDWord, APK_normal_setting_value_2[index]); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("phy_APCalibrate_8188E() offset 0x%x value 0x%x\n", + offset, ODM_GetBBReg(dm_odm, offset, bMaskDWord))); + + offset += 0x04; + } + ODM_SetBBReg(dm_odm, rFPGA0_IQK, bMaskDWord, 0); + } + + /* save RF default value */ + regD[path] = PHY_QueryRFReg(adapt, path, RF_TXBIAS_A, bMaskDWord); + + /* Path A AFE all on, path B AFE All off or vise versa */ + for (index = 0; index < IQK_ADDA_REG_NUM; index++) + ODM_SetBBReg(dm_odm, AFE_REG[index], bMaskDWord, AFE_on_off[path]); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("phy_APCalibrate_8188E() offset 0xe70 %x\n", + ODM_GetBBReg(dm_odm, rRx_Wait_CCA, bMaskDWord))); + + /* BB to AP mode */ + if (path == 0) { + for (index = 0; index < APK_BB_REG_NUM; index++) { + if (index == 0) /* skip */ + continue; + else if (index < 5) + ODM_SetBBReg(dm_odm, BB_REG[index], bMaskDWord, BB_AP_MODE[index]); + else if (BB_REG[index] == 0x870) + ODM_SetBBReg(dm_odm, BB_REG[index], bMaskDWord, BB_backup[index]|BIT10|BIT26); + else + ODM_SetBBReg(dm_odm, BB_REG[index], BIT10, 0x0); + } + + ODM_SetBBReg(dm_odm, rTx_IQK_Tone_A, bMaskDWord, 0x01008c00); + ODM_SetBBReg(dm_odm, rRx_IQK_Tone_A, bMaskDWord, 0x01008c00); + } else { + /* path B */ + ODM_SetBBReg(dm_odm, rTx_IQK_Tone_B, bMaskDWord, 0x01008c00); + ODM_SetBBReg(dm_odm, rRx_IQK_Tone_B, bMaskDWord, 0x01008c00); + } + + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("phy_APCalibrate_8188E() offset 0x800 %x\n", + ODM_GetBBReg(dm_odm, 0x800, bMaskDWord))); + + /* MAC settings */ + _PHY_MACSettingCalibration(adapt, MAC_REG, MAC_backup); + + if (path == RF_PATH_A) { + /* Path B to standby mode */ + ODM_SetRFReg(dm_odm, RF_PATH_B, RF_AC, bMaskDWord, 0x10000); + } else { + /* Path A to standby mode */ + ODM_SetRFReg(dm_odm, RF_PATH_A, RF_AC, bMaskDWord, 0x10000); + ODM_SetRFReg(dm_odm, RF_PATH_A, RF_MODE1, bMaskDWord, 0x1000f); + ODM_SetRFReg(dm_odm, RF_PATH_A, RF_MODE2, bMaskDWord, 0x20103); + } + + delta_offset = ((delta+14)/2); + if (delta_offset < 0) + delta_offset = 0; + else if (delta_offset > 12) + delta_offset = 12; + + /* AP calibration */ + for (index = 0; index < APK_BB_REG_NUM; index++) { + if (index != 1) /* only DO PA11+PAD01001, AP RF setting */ + continue; + + tmpreg = APK_RF_init_value[path][index]; + if (!dm_odm->RFCalibrateInfo.bAPKThermalMeterIgnore) { + BB_offset = (tmpreg & 0xF0000) >> 16; + + if (!(tmpreg & BIT15)) /* sign bit 0 */ + BB_offset = -BB_offset; + + delta_V = APK_delta_mapping[index][delta_offset]; + + BB_offset += delta_V; + + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("phy_APCalibrate_8188E() APK index %d tmpreg 0x%x delta_V %d delta_offset %d\n", + index, tmpreg, delta_V, delta_offset)); + + if (BB_offset < 0) { + tmpreg = tmpreg & (~BIT15); + BB_offset = -BB_offset; + } else { + tmpreg = tmpreg | BIT15; + } + tmpreg = (tmpreg & 0xFFF0FFFF) | (BB_offset << 16); + } + + ODM_SetRFReg(dm_odm, path, RF_IPA_A, bMaskDWord, 0x8992e); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("phy_APCalibrate_8188E() offset 0xc %x\n", PHY_QueryRFReg(adapt, path, RF_IPA_A, bMaskDWord))); + ODM_SetRFReg(dm_odm, path, RF_AC, bMaskDWord, APK_RF_value_0[path][index]); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("phy_APCalibrate_8188E() offset 0x0 %x\n", PHY_QueryRFReg(adapt, path, RF_AC, bMaskDWord))); + ODM_SetRFReg(dm_odm, path, RF_TXBIAS_A, bMaskDWord, tmpreg); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("phy_APCalibrate_8188E() offset 0xd %x\n", PHY_QueryRFReg(adapt, path, RF_TXBIAS_A, bMaskDWord))); + /* PA11+PAD01111, one shot */ + i = 0; + do { + ODM_SetBBReg(dm_odm, rFPGA0_IQK, bMaskDWord, 0x80000000); + ODM_SetBBReg(dm_odm, APK_offset[path], bMaskDWord, APK_value[0]); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("phy_APCalibrate_8188E() offset 0x%x value 0x%x\n", APK_offset[path], ODM_GetBBReg(dm_odm, APK_offset[path], bMaskDWord))); + ODM_delay_ms(3); + ODM_SetBBReg(dm_odm, APK_offset[path], bMaskDWord, APK_value[1]); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("phy_APCalibrate_8188E() offset 0x%x value 0x%x\n", APK_offset[path], ODM_GetBBReg(dm_odm, APK_offset[path], bMaskDWord))); + + ODM_delay_ms(20); + ODM_SetBBReg(dm_odm, rFPGA0_IQK, bMaskDWord, 0x00000000); + + if (path == RF_PATH_A) + tmpreg = ODM_GetBBReg(dm_odm, rAPK, 0x03E00000); + else + tmpreg = ODM_GetBBReg(dm_odm, rAPK, 0xF8000000); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("phy_APCalibrate_8188E() offset 0xbd8[25:21] %x\n", tmpreg)); + + i++; + } while (tmpreg > apkbound && i < 4); + + APK_result[path][index] = tmpreg; + } + } + + /* reload MAC default value */ + _PHY_ReloadMACRegisters(adapt, MAC_REG, MAC_backup); + + /* reload BB default value */ + for (index = 0; index < APK_BB_REG_NUM; index++) { + if (index == 0) /* skip */ + continue; + ODM_SetBBReg(dm_odm, BB_REG[index], bMaskDWord, BB_backup[index]); + } + + /* reload AFE default value */ + reload_adda_reg(adapt, AFE_REG, AFE_backup, IQK_ADDA_REG_NUM); + + /* reload RF path default value */ + for (path = 0; path < pathbound; path++) { + ODM_SetRFReg(dm_odm, path, 0xd, bMaskDWord, regD[path]); + if (path == RF_PATH_B) { + ODM_SetRFReg(dm_odm, RF_PATH_A, RF_MODE1, bMaskDWord, 0x1000f); + ODM_SetRFReg(dm_odm, RF_PATH_A, RF_MODE2, bMaskDWord, 0x20101); + } + + /* note no index == 0 */ + if (APK_result[path][1] > 6) + APK_result[path][1] = 6; + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("apk path %d result %d 0x%x \t", path, 1, APK_result[path][1])); + } + + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("\n")); + + for (path = 0; path < pathbound; path++) { + ODM_SetRFReg(dm_odm, path, 0x3, bMaskDWord, + ((APK_result[path][1] << 15) | (APK_result[path][1] << 10) | (APK_result[path][1] << 5) | APK_result[path][1])); + if (path == RF_PATH_A) + ODM_SetRFReg(dm_odm, path, 0x4, bMaskDWord, + ((APK_result[path][1] << 15) | (APK_result[path][1] << 10) | (0x00 << 5) | 0x05)); + else + ODM_SetRFReg(dm_odm, path, 0x4, bMaskDWord, + ((APK_result[path][1] << 15) | (APK_result[path][1] << 10) | (0x02 << 5) | 0x05)); + ODM_SetRFReg(dm_odm, path, RF_BS_PA_APSET_G9_G11, bMaskDWord, + ((0x08 << 15) | (0x08 << 10) | (0x08 << 5) | 0x08)); + } + + dm_odm->RFCalibrateInfo.bAPKdone = true; + + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("<==phy_APCalibrate_8188E()\n")); +} + +#define DP_BB_REG_NUM 7 +#define DP_RF_REG_NUM 1 +#define DP_RETRY_LIMIT 10 +#define DP_PATH_NUM 2 +#define DP_DPK_NUM 3 +#define DP_DPK_VALUE_NUM 2 + +void PHY_IQCalibrate_8188E(struct adapter *adapt, bool recovery) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); + struct odm_dm_struct *dm_odm = &pHalData->odmpriv; + struct mpt_context *pMptCtx = &(adapt->mppriv.MptCtx); + s32 result[4][8]; /* last is final result */ + u8 i, final_candidate, Indexforchannel; + bool pathaok, pathbok; + s32 RegE94, RegE9C, RegEA4, RegEAC, RegEB4, RegEBC, RegEC4, RegECC; + bool is12simular, is13simular, is23simular; + bool singletone = false, carrier_sup = false; + u32 IQK_BB_REG_92C[IQK_BB_REG_NUM] = { + rOFDM0_XARxIQImbalance, rOFDM0_XBRxIQImbalance, + rOFDM0_ECCAThreshold, rOFDM0_AGCRSSITable, + rOFDM0_XATxIQImbalance, rOFDM0_XBTxIQImbalance, + rOFDM0_XCTxAFE, rOFDM0_XDTxAFE, + rOFDM0_RxIQExtAnta}; + bool is2t; + + is2t = (dm_odm->RFType == ODM_2T2R) ? true : false; + if (ODM_CheckPowerStatus(adapt) == false) + return; + + if (!(dm_odm->SupportAbility & ODM_RF_CALIBRATION)) + return; + + if (*(dm_odm->mp_mode) == 1) { + singletone = pMptCtx->bSingleTone; + carrier_sup = pMptCtx->bCarrierSuppression; + } + + /* 20120213 Turn on when continuous Tx to pass lab testing. (required by Edlu) */ + if (singletone || carrier_sup) + return; + + if (recovery) { + ODM_RT_TRACE(dm_odm, ODM_COMP_INIT, ODM_DBG_LOUD, ("PHY_IQCalibrate_8188E: Return due to recovery!\n")); + reload_adda_reg(adapt, IQK_BB_REG_92C, dm_odm->RFCalibrateInfo.IQK_BB_backup_recover, 9); + return; + } + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQK:Start!!!\n")); + + for (i = 0; i < 8; i++) { + result[0][i] = 0; + result[1][i] = 0; + result[2][i] = 0; + if ((i == 0) || (i == 2) || (i == 4) || (i == 6)) + result[3][i] = 0x100; + else + result[3][i] = 0; + } + final_candidate = 0xff; + pathaok = false; + pathbok = false; + is12simular = false; + is23simular = false; + is13simular = false; + + for (i = 0; i < 3; i++) { + phy_IQCalibrate_8188E(adapt, result, i, is2t); + + if (i == 1) { + is12simular = phy_SimularityCompare_8188E(adapt, result, 0, 1); + if (is12simular) { + final_candidate = 0; + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQK: is12simular final_candidate is %x\n", final_candidate)); + break; + } + } + + if (i == 2) { + is13simular = phy_SimularityCompare_8188E(adapt, result, 0, 2); + if (is13simular) { + final_candidate = 0; + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQK: is13simular final_candidate is %x\n", final_candidate)); + + break; + } + is23simular = phy_SimularityCompare_8188E(adapt, result, 1, 2); + if (is23simular) { + final_candidate = 1; + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQK: is23simular final_candidate is %x\n", final_candidate)); + } else { + final_candidate = 3; + } + } + } + + for (i = 0; i < 4; i++) { + RegE94 = result[i][0]; + RegE9C = result[i][1]; + RegEA4 = result[i][2]; + RegEAC = result[i][3]; + RegEB4 = result[i][4]; + RegEBC = result[i][5]; + RegEC4 = result[i][6]; + RegECC = result[i][7]; + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("IQK: RegE94=%x RegE9C=%x RegEA4=%x RegEAC=%x RegEB4=%x RegEBC=%x RegEC4=%x RegECC=%x\n", + RegE94, RegE9C, RegEA4, RegEAC, RegEB4, RegEBC, RegEC4, RegECC)); + } + + if (final_candidate != 0xff) { + RegE94 = result[final_candidate][0]; + RegE9C = result[final_candidate][1]; + RegEA4 = result[final_candidate][2]; + RegEAC = result[final_candidate][3]; + RegEB4 = result[final_candidate][4]; + RegEBC = result[final_candidate][5]; + dm_odm->RFCalibrateInfo.RegE94 = RegE94; + dm_odm->RFCalibrateInfo.RegE9C = RegE9C; + dm_odm->RFCalibrateInfo.RegEB4 = RegEB4; + dm_odm->RFCalibrateInfo.RegEBC = RegEBC; + RegEC4 = result[final_candidate][6]; + RegECC = result[final_candidate][7]; + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("IQK: final_candidate is %x\n", final_candidate)); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("IQK: RegE94=%x RegE9C=%x RegEA4=%x RegEAC=%x RegEB4=%x RegEBC=%x RegEC4=%x RegECC=%x\n", + RegE94, RegE9C, RegEA4, RegEAC, RegEB4, RegEBC, RegEC4, RegECC)); + pathaok = true; + pathbok = true; + } else { + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQK: FAIL use default value\n")); + dm_odm->RFCalibrateInfo.RegE94 = 0x100; + dm_odm->RFCalibrateInfo.RegEB4 = 0x100; /* X default value */ + dm_odm->RFCalibrateInfo.RegE9C = 0x0; + dm_odm->RFCalibrateInfo.RegEBC = 0x0; /* Y default value */ + } + if (RegE94 != 0) + patha_fill_iqk(adapt, pathaok, result, final_candidate, (RegEA4 == 0)); + if (is2t) { + if (RegEB4 != 0) + pathb_fill_iqk(adapt, pathbok, result, final_candidate, (RegEC4 == 0)); + } + + Indexforchannel = ODM_GetRightChnlPlaceforIQK(pHalData->CurrentChannel); + +/* To Fix BSOD when final_candidate is 0xff */ +/* by sherry 20120321 */ + if (final_candidate < 4) { + for (i = 0; i < IQK_Matrix_REG_NUM; i++) + dm_odm->RFCalibrateInfo.IQKMatrixRegSetting[Indexforchannel].Value[0][i] = result[final_candidate][i]; + dm_odm->RFCalibrateInfo.IQKMatrixRegSetting[Indexforchannel].bIQKDone = true; + } + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("\nIQK OK Indexforchannel %d.\n", Indexforchannel)); + + _PHY_SaveADDARegisters(adapt, IQK_BB_REG_92C, dm_odm->RFCalibrateInfo.IQK_BB_backup_recover, 9); + + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQK finished\n")); +} + +void PHY_LCCalibrate_8188E(struct adapter *adapt) +{ + bool singletone = false, carrier_sup = false; + u32 timeout = 2000, timecount = 0; + struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); + struct odm_dm_struct *dm_odm = &pHalData->odmpriv; + struct mpt_context *pMptCtx = &(adapt->mppriv.MptCtx); + + if (*(dm_odm->mp_mode) == 1) { + singletone = pMptCtx->bSingleTone; + carrier_sup = pMptCtx->bCarrierSuppression; + } + if (!(dm_odm->SupportAbility & ODM_RF_CALIBRATION)) + return; + /* 20120213 Turn on when continuous Tx to pass lab testing. (required by Edlu) */ + if (singletone || carrier_sup) + return; + + while (*(dm_odm->pbScanInProcess) && timecount < timeout) { + ODM_delay_ms(50); + timecount += 50; + } + + dm_odm->RFCalibrateInfo.bLCKInProgress = true; + + if (dm_odm->RFType == ODM_2T2R) { + phy_LCCalibrate_8188E(adapt, true); + } else { + /* For 88C 1T1R */ + phy_LCCalibrate_8188E(adapt, false); + } + + dm_odm->RFCalibrateInfo.bLCKInProgress = false; + + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("LCK:Finish!!!interface %d\n", dm_odm->InterfaceIndex)); +} + +void PHY_APCalibrate_8188E(struct adapter *adapt, s8 delta) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); + struct odm_dm_struct *dm_odm = &pHalData->odmpriv; + + return; + if (!(dm_odm->SupportAbility & ODM_RF_CALIBRATION)) + return; + +#if FOR_BRAZIL_PRETEST != 1 + if (dm_odm->RFCalibrateInfo.bAPKdone) +#endif + return; + + if (dm_odm->RFType == ODM_2T2R) { + phy_APCalibrate_8188E(adapt, delta, true); + } else { + /* For 88C 1T1R */ + phy_APCalibrate_8188E(adapt, delta, false); + } +} + +static void phy_setrfpathswitch_8188e(struct adapter *adapt, bool main, bool is2t) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); + struct odm_dm_struct *dm_odm = &pHalData->odmpriv; + + if (!adapt->hw_init_completed) { + u8 u1btmp; + u1btmp = ODM_Read1Byte(dm_odm, REG_LEDCFG2) | BIT7; + ODM_Write1Byte(dm_odm, REG_LEDCFG2, u1btmp); + ODM_SetBBReg(dm_odm, rFPGA0_XAB_RFParameter, BIT13, 0x01); + } + + if (is2t) { /* 92C */ + if (main) + ODM_SetBBReg(dm_odm, rFPGA0_XB_RFInterfaceOE, BIT5|BIT6, 0x1); /* 92C_Path_A */ + else + ODM_SetBBReg(dm_odm, rFPGA0_XB_RFInterfaceOE, BIT5|BIT6, 0x2); /* BT */ + } else { /* 88C */ + if (main) + ODM_SetBBReg(dm_odm, rFPGA0_XA_RFInterfaceOE, BIT8|BIT9, 0x2); /* Main */ + else + ODM_SetBBReg(dm_odm, rFPGA0_XA_RFInterfaceOE, BIT8|BIT9, 0x1); /* Aux */ + } +} + +void PHY_SetRFPathSwitch_8188E(struct adapter *adapt, bool main) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); + struct odm_dm_struct *dm_odm = &pHalData->odmpriv; + + if (dm_odm->RFType == ODM_2T2R) { + phy_setrfpathswitch_8188e(adapt, main, true); + } else { + /* For 88C 1T1R */ + phy_setrfpathswitch_8188e(adapt, main, false); + } +} diff --git a/drivers/staging/rtl8188eu/hal/hal_intf.c b/drivers/staging/rtl8188eu/hal/hal_intf.c new file mode 100644 index 0000000000000..598140464f051 --- /dev/null +++ b/drivers/staging/rtl8188eu/hal/hal_intf.c @@ -0,0 +1,464 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#define _HAL_INTF_C_ +#include +#include +#include +#include + +void rtw_hal_chip_configure(struct adapter *adapt) +{ + if (adapt->HalFunc.intf_chip_configure) + adapt->HalFunc.intf_chip_configure(adapt); +} + +void rtw_hal_read_chip_info(struct adapter *adapt) +{ + if (adapt->HalFunc.read_adapter_info) + adapt->HalFunc.read_adapter_info(adapt); +} + +void rtw_hal_read_chip_version(struct adapter *adapt) +{ + if (adapt->HalFunc.read_chip_version) + adapt->HalFunc.read_chip_version(adapt); +} + +void rtw_hal_def_value_init(struct adapter *adapt) +{ + if (adapt->HalFunc.init_default_value) + adapt->HalFunc.init_default_value(adapt); +} + +void rtw_hal_free_data(struct adapter *adapt) +{ + if (adapt->HalFunc.free_hal_data) + adapt->HalFunc.free_hal_data(adapt); +} + +void rtw_hal_dm_init(struct adapter *adapt) +{ + if (adapt->HalFunc.dm_init) + adapt->HalFunc.dm_init(adapt); +} + +void rtw_hal_dm_deinit(struct adapter *adapt) +{ + /* cancel dm timer */ + if (adapt->HalFunc.dm_deinit) + adapt->HalFunc.dm_deinit(adapt); +} + +void rtw_hal_sw_led_init(struct adapter *adapt) +{ + if (adapt->HalFunc.InitSwLeds) + adapt->HalFunc.InitSwLeds(adapt); +} + +void rtw_hal_sw_led_deinit(struct adapter *adapt) +{ + if (adapt->HalFunc.DeInitSwLeds) + adapt->HalFunc.DeInitSwLeds(adapt); +} + +u32 rtw_hal_power_on(struct adapter *adapt) +{ + if (adapt->HalFunc.hal_power_on) + return adapt->HalFunc.hal_power_on(adapt); + return _FAIL; +} + +uint rtw_hal_init(struct adapter *adapt) +{ + uint status = _SUCCESS; + + adapt->hw_init_completed = false; + + status = adapt->HalFunc.hal_init(adapt); + + if (status == _SUCCESS) { + adapt->hw_init_completed = true; + + if (adapt->registrypriv.notch_filter == 1) + rtw_hal_notch_filter(adapt, 1); + + rtw_hal_reset_security_engine(adapt); + } else { + adapt->hw_init_completed = false; + DBG_88E("rtw_hal_init: hal__init fail\n"); + } + + RT_TRACE(_module_hal_init_c_, _drv_err_, + ("-rtl871x_hal_init:status=0x%x\n", status)); + + return status; +} + +uint rtw_hal_deinit(struct adapter *adapt) +{ + uint status = _SUCCESS; + +_func_enter_; + + status = adapt->HalFunc.hal_deinit(adapt); + + if (status == _SUCCESS) + adapt->hw_init_completed = false; + else + DBG_88E("\n rtw_hal_deinit: hal_init fail\n"); + +_func_exit_; + + return status; +} + +void rtw_hal_set_hwreg(struct adapter *adapt, u8 variable, u8 *val) +{ + if (adapt->HalFunc.SetHwRegHandler) + adapt->HalFunc.SetHwRegHandler(adapt, variable, val); +} + +void rtw_hal_get_hwreg(struct adapter *adapt, u8 variable, u8 *val) +{ + if (adapt->HalFunc.GetHwRegHandler) + adapt->HalFunc.GetHwRegHandler(adapt, variable, val); +} + +u8 rtw_hal_set_def_var(struct adapter *adapt, enum hal_def_variable var, + void *val) +{ + if (adapt->HalFunc.SetHalDefVarHandler) + return adapt->HalFunc.SetHalDefVarHandler(adapt, var, val); + return _FAIL; +} + +u8 rtw_hal_get_def_var(struct adapter *adapt, + enum hal_def_variable var, void *val) +{ + if (adapt->HalFunc.GetHalDefVarHandler) + return adapt->HalFunc.GetHalDefVarHandler(adapt, var, val); + return _FAIL; +} + +void rtw_hal_set_odm_var(struct adapter *adapt, + enum hal_odm_variable var, void *val1, + bool set) +{ + if (adapt->HalFunc.SetHalODMVarHandler) + adapt->HalFunc.SetHalODMVarHandler(adapt, var, + val1, set); +} + +void rtw_hal_get_odm_var(struct adapter *adapt, + enum hal_odm_variable var, void *val1, + bool set) +{ + if (adapt->HalFunc.GetHalODMVarHandler) + adapt->HalFunc.GetHalODMVarHandler(adapt, var, + val1, set); +} + +void rtw_hal_enable_interrupt(struct adapter *adapt) +{ + if (adapt->HalFunc.enable_interrupt) + adapt->HalFunc.enable_interrupt(adapt); + else + DBG_88E("%s: HalFunc.enable_interrupt is NULL!\n", __func__); +} + +void rtw_hal_disable_interrupt(struct adapter *adapt) +{ + if (adapt->HalFunc.disable_interrupt) + adapt->HalFunc.disable_interrupt(adapt); + else + DBG_88E("%s: HalFunc.disable_interrupt is NULL!\n", __func__); +} + +u32 rtw_hal_inirp_init(struct adapter *adapt) +{ + u32 rst = _FAIL; + + if (adapt->HalFunc.inirp_init) + rst = adapt->HalFunc.inirp_init(adapt); + else + DBG_88E(" %s HalFunc.inirp_init is NULL!!!\n", __func__); + return rst; +} + +u32 rtw_hal_inirp_deinit(struct adapter *adapt) +{ + if (adapt->HalFunc.inirp_deinit) + return adapt->HalFunc.inirp_deinit(adapt); + + return _FAIL; +} + +u8 rtw_hal_intf_ps_func(struct adapter *adapt, + enum hal_intf_ps_func efunc_id, u8 *val) +{ + if (adapt->HalFunc.interface_ps_func) + return adapt->HalFunc.interface_ps_func(adapt, efunc_id, + val); + return _FAIL; +} + +s32 rtw_hal_xmit(struct adapter *adapt, struct xmit_frame *pxmitframe) +{ + if (adapt->HalFunc.hal_xmit) + return adapt->HalFunc.hal_xmit(adapt, pxmitframe); + + return false; +} + +s32 rtw_hal_mgnt_xmit(struct adapter *adapt, struct xmit_frame *pmgntframe) +{ + s32 ret = _FAIL; + if (adapt->HalFunc.mgnt_xmit) + ret = adapt->HalFunc.mgnt_xmit(adapt, pmgntframe); + return ret; +} + +s32 rtw_hal_init_xmit_priv(struct adapter *adapt) +{ + if (adapt->HalFunc.init_xmit_priv != NULL) + return adapt->HalFunc.init_xmit_priv(adapt); + return _FAIL; +} + +void rtw_hal_free_xmit_priv(struct adapter *adapt) +{ + if (adapt->HalFunc.free_xmit_priv != NULL) + adapt->HalFunc.free_xmit_priv(adapt); +} + +s32 rtw_hal_init_recv_priv(struct adapter *adapt) +{ + if (adapt->HalFunc.init_recv_priv) + return adapt->HalFunc.init_recv_priv(adapt); + + return _FAIL; +} + +void rtw_hal_free_recv_priv(struct adapter *adapt) +{ + if (adapt->HalFunc.free_recv_priv) + adapt->HalFunc.free_recv_priv(adapt); +} + +void rtw_hal_update_ra_mask(struct adapter *adapt, u32 mac_id, u8 rssi_level) +{ + struct mlme_priv *pmlmepriv = &(adapt->mlmepriv); + + if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) { +#ifdef CONFIG_88EU_AP_MODE + struct sta_info *psta = NULL; + struct sta_priv *pstapriv = &adapt->stapriv; + if ((mac_id-1) > 0) + psta = pstapriv->sta_aid[(mac_id-1) - 1]; + if (psta) + add_RATid(adapt, psta, 0);/* todo: based on rssi_level*/ +#endif + } else { + if (adapt->HalFunc.UpdateRAMaskHandler) + adapt->HalFunc.UpdateRAMaskHandler(adapt, mac_id, + rssi_level); + } +} + +void rtw_hal_add_ra_tid(struct adapter *adapt, u32 bitmap, u8 arg, + u8 rssi_level) +{ + if (adapt->HalFunc.Add_RateATid) + adapt->HalFunc.Add_RateATid(adapt, bitmap, arg, + rssi_level); +} + +/* Start specifical interface thread */ +void rtw_hal_start_thread(struct adapter *adapt) +{ + if (adapt->HalFunc.run_thread) + adapt->HalFunc.run_thread(adapt); +} + +/* Start specifical interface thread */ +void rtw_hal_stop_thread(struct adapter *adapt) +{ + if (adapt->HalFunc.cancel_thread) + adapt->HalFunc.cancel_thread(adapt); +} + +u32 rtw_hal_read_bbreg(struct adapter *adapt, u32 regaddr, u32 bitmask) +{ + u32 data = 0; + + if (adapt->HalFunc.read_bbreg) + data = adapt->HalFunc.read_bbreg(adapt, regaddr, bitmask); + return data; +} + +void rtw_hal_write_bbreg(struct adapter *adapt, u32 regaddr, u32 bitmask, + u32 data) +{ + if (adapt->HalFunc.write_bbreg) + adapt->HalFunc.write_bbreg(adapt, regaddr, bitmask, data); +} + +u32 rtw_hal_read_rfreg(struct adapter *adapt, enum rf_radio_path rfpath, + u32 regaddr, u32 bitmask) +{ + u32 data = 0; + + if (adapt->HalFunc.read_rfreg) + data = adapt->HalFunc.read_rfreg(adapt, rfpath, regaddr, + bitmask); + return data; +} + +void rtw_hal_write_rfreg(struct adapter *adapt, enum rf_radio_path rfpath, + u32 regaddr, u32 bitmask, u32 data) +{ + if (adapt->HalFunc.write_rfreg) + adapt->HalFunc.write_rfreg(adapt, rfpath, regaddr, + bitmask, data); +} + +s32 rtw_hal_interrupt_handler(struct adapter *adapt) +{ + if (adapt->HalFunc.interrupt_handler) + return adapt->HalFunc.interrupt_handler(adapt); + return _FAIL; +} + +void rtw_hal_set_bwmode(struct adapter *adapt, + enum ht_channel_width bandwidth, u8 offset) +{ + if (adapt->HalFunc.set_bwmode_handler) + adapt->HalFunc.set_bwmode_handler(adapt, bandwidth, + offset); +} + +void rtw_hal_set_chan(struct adapter *adapt, u8 channel) +{ + if (adapt->HalFunc.set_channel_handler) + adapt->HalFunc.set_channel_handler(adapt, channel); +} + +void rtw_hal_dm_watchdog(struct adapter *adapt) +{ + if (adapt->HalFunc.hal_dm_watchdog) + adapt->HalFunc.hal_dm_watchdog(adapt); +} + +void rtw_hal_bcn_related_reg_setting(struct adapter *adapt) +{ + if (adapt->HalFunc.SetBeaconRelatedRegistersHandler) + adapt->HalFunc.SetBeaconRelatedRegistersHandler(adapt); +} + +u8 rtw_hal_antdiv_before_linked(struct adapter *adapt) +{ + if (adapt->HalFunc.AntDivBeforeLinkHandler) + return adapt->HalFunc.AntDivBeforeLinkHandler(adapt); + return false; +} + +void rtw_hal_antdiv_rssi_compared(struct adapter *adapt, + struct wlan_bssid_ex *dst, + struct wlan_bssid_ex *src) +{ + if (adapt->HalFunc.AntDivCompareHandler) + adapt->HalFunc.AntDivCompareHandler(adapt, dst, src); +} + +void rtw_hal_sreset_init(struct adapter *adapt) +{ + if (adapt->HalFunc.sreset_init_value) + adapt->HalFunc.sreset_init_value(adapt); +} + +void rtw_hal_sreset_reset(struct adapter *adapt) +{ + if (adapt->HalFunc.silentreset) + adapt->HalFunc.silentreset(adapt); +} + +void rtw_hal_sreset_reset_value(struct adapter *adapt) +{ + if (adapt->HalFunc.sreset_reset_value) + adapt->HalFunc.sreset_reset_value(adapt); +} + +void rtw_hal_sreset_xmit_status_check(struct adapter *adapt) +{ + if (adapt->HalFunc.sreset_xmit_status_check) + adapt->HalFunc.sreset_xmit_status_check(adapt); +} + +void rtw_hal_sreset_linked_status_check(struct adapter *adapt) +{ + if (adapt->HalFunc.sreset_linked_status_check) + adapt->HalFunc.sreset_linked_status_check(adapt); +} + +u8 rtw_hal_sreset_get_wifi_status(struct adapter *adapt) +{ + u8 status = 0; + + if (adapt->HalFunc.sreset_get_wifi_status) + status = adapt->HalFunc.sreset_get_wifi_status(adapt); + return status; +} + +int rtw_hal_iol_cmd(struct adapter *adapter, struct xmit_frame *xmit_frame, + u32 max_wating_ms, u32 bndy_cnt) +{ + if (adapter->HalFunc.IOL_exec_cmds_sync) + return adapter->HalFunc.IOL_exec_cmds_sync(adapter, xmit_frame, + max_wating_ms, + bndy_cnt); + return _FAIL; +} + +void rtw_hal_notch_filter(struct adapter *adapter, bool enable) +{ + if (adapter->HalFunc.hal_notch_filter) + adapter->HalFunc.hal_notch_filter(adapter, enable); +} + +void rtw_hal_reset_security_engine(struct adapter *adapter) +{ + if (adapter->HalFunc.hal_reset_security_engine) + adapter->HalFunc.hal_reset_security_engine(adapter); +} + +s32 rtw_hal_c2h_handler(struct adapter *adapter, struct c2h_evt_hdr *c2h_evt) +{ + s32 ret = _FAIL; + + if (adapter->HalFunc.c2h_handler) + ret = adapter->HalFunc.c2h_handler(adapter, c2h_evt); + return ret; +} + +c2h_id_filter rtw_hal_c2h_id_filter_ccx(struct adapter *adapter) +{ + return adapter->HalFunc.c2h_id_filter_ccx; +} -- GitLab From 18b0950e02649674d2cf690465c89ee0becff41f Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 21 Aug 2013 22:33:53 -0500 Subject: [PATCH 769/942] staging: r8188eu: Add files for new driver - part 11 This commit adds files hal/HalPwrSeqCmd.c, hal/odm.c, and hal/odm_debug.c. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/HalPwrSeqCmd.c | 132 ++ drivers/staging/rtl8188eu/hal/odm.c | 2171 ++++++++++++++++++ drivers/staging/rtl8188eu/hal/odm_debug.c | 32 + 3 files changed, 2335 insertions(+) create mode 100644 drivers/staging/rtl8188eu/hal/HalPwrSeqCmd.c create mode 100644 drivers/staging/rtl8188eu/hal/odm.c create mode 100644 drivers/staging/rtl8188eu/hal/odm_debug.c diff --git a/drivers/staging/rtl8188eu/hal/HalPwrSeqCmd.c b/drivers/staging/rtl8188eu/hal/HalPwrSeqCmd.c new file mode 100644 index 0000000000000..e913a22a6426a --- /dev/null +++ b/drivers/staging/rtl8188eu/hal/HalPwrSeqCmd.c @@ -0,0 +1,132 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +/*++ +Copyright (c) Realtek Semiconductor Corp. All rights reserved. + +Module Name: + HalPwrSeqCmd.c + +Abstract: + Implement HW Power sequence configuration CMD handling routine for Realtek devices. + +Major Change History: + When Who What + ---------- --------------- ------------------------------- + 2011-10-26 Lucas Modify to be compatible with SD4-CE driver. + 2011-07-07 Roger Create. + +--*/ + +#include + +/* Description: */ +/* This routine deals with the Power Configuration CMDs parsing + * for RTL8723/RTL8188E Series IC. + * Assumption: + * We should follow specific format which was released from HW SD. + */ +u8 HalPwrSeqCmdParsing(struct adapter *padapter, u8 cut_vers, u8 fab_vers, + u8 ifacetype, struct wl_pwr_cfg pwrseqcmd[]) +{ + struct wl_pwr_cfg pwrcfgcmd = {0}; + u8 poll_bit = false; + u32 aryidx = 0; + u8 value = 0; + u32 offset = 0; + u32 poll_count = 0; /* polling autoload done. */ + u32 max_poll_count = 5000; + + do { + pwrcfgcmd = pwrseqcmd[aryidx]; + + RT_TRACE(_module_hal_init_c_ , _drv_info_, + ("HalPwrSeqCmdParsing: offset(%#x) cut_msk(%#x) fab_msk(%#x) interface_msk(%#x) base(%#x) cmd(%#x) msk(%#x) value(%#x)\n", + GET_PWR_CFG_OFFSET(pwrcfgcmd), + GET_PWR_CFG_CUT_MASK(pwrcfgcmd), + GET_PWR_CFG_FAB_MASK(pwrcfgcmd), + GET_PWR_CFG_INTF_MASK(pwrcfgcmd), + GET_PWR_CFG_BASE(pwrcfgcmd), + GET_PWR_CFG_CMD(pwrcfgcmd), + GET_PWR_CFG_MASK(pwrcfgcmd), + GET_PWR_CFG_VALUE(pwrcfgcmd))); + + /* 2 Only Handle the command whose FAB, CUT, and Interface are matched */ + if ((GET_PWR_CFG_FAB_MASK(pwrcfgcmd) & fab_vers) && + (GET_PWR_CFG_CUT_MASK(pwrcfgcmd) & cut_vers) && + (GET_PWR_CFG_INTF_MASK(pwrcfgcmd) & ifacetype)) { + switch (GET_PWR_CFG_CMD(pwrcfgcmd)) { + case PWR_CMD_READ: + RT_TRACE(_module_hal_init_c_ , _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_READ\n")); + break; + case PWR_CMD_WRITE: + RT_TRACE(_module_hal_init_c_ , _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_WRITE\n")); + offset = GET_PWR_CFG_OFFSET(pwrcfgcmd); + + /* Read the value from system register */ + value = rtw_read8(padapter, offset); + + value &= ~(GET_PWR_CFG_MASK(pwrcfgcmd)); + value |= (GET_PWR_CFG_VALUE(pwrcfgcmd) & GET_PWR_CFG_MASK(pwrcfgcmd)); + + /* Write the value back to sytem register */ + rtw_write8(padapter, offset, value); + break; + case PWR_CMD_POLLING: + RT_TRACE(_module_hal_init_c_ , _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_POLLING\n")); + + poll_bit = false; + offset = GET_PWR_CFG_OFFSET(pwrcfgcmd); + do { + value = rtw_read8(padapter, offset); + + value &= GET_PWR_CFG_MASK(pwrcfgcmd); + if (value == (GET_PWR_CFG_VALUE(pwrcfgcmd) & GET_PWR_CFG_MASK(pwrcfgcmd))) + poll_bit = true; + else + rtw_udelay_os(10); + + if (poll_count++ > max_poll_count) { + DBG_88E("Fail to polling Offset[%#x]\n", offset); + return false; + } + } while (!poll_bit); + break; + case PWR_CMD_DELAY: + RT_TRACE(_module_hal_init_c_ , _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_DELAY\n")); + if (GET_PWR_CFG_VALUE(pwrcfgcmd) == PWRSEQ_DELAY_US) + rtw_udelay_os(GET_PWR_CFG_OFFSET(pwrcfgcmd)); + else + rtw_udelay_os(GET_PWR_CFG_OFFSET(pwrcfgcmd)*1000); + break; + case PWR_CMD_END: + /* When this command is parsed, end the process */ + RT_TRACE(_module_hal_init_c_ , _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_END\n")); + return true; + break; + default: + RT_TRACE(_module_hal_init_c_ , _drv_err_, ("HalPwrSeqCmdParsing: Unknown CMD!!\n")); + break; + } + } + + aryidx++;/* Add Array Index */ + } while (1); + return true; +} diff --git a/drivers/staging/rtl8188eu/hal/odm.c b/drivers/staging/rtl8188eu/hal/odm.c new file mode 100644 index 0000000000000..285475f9613cf --- /dev/null +++ b/drivers/staging/rtl8188eu/hal/odm.c @@ -0,0 +1,2171 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +/* include files */ + +#include "odm_precomp.h" + +static const u16 dB_Invert_Table[8][12] = { + {1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4}, + {4, 5, 6, 6, 7, 8, 9, 10, 11, 13, 14, 16}, + {18, 20, 22, 25, 28, 32, 35, 40, 45, 50, 56, 63}, + {71, 79, 89, 100, 112, 126, 141, 158, 178, 200, 224, 251}, + {282, 316, 355, 398, 447, 501, 562, 631, 708, 794, 891, 1000}, + {1122, 1259, 1413, 1585, 1778, 1995, 2239, 2512, 2818, 3162, 3548, 3981}, + {4467, 5012, 5623, 6310, 7079, 7943, 8913, 10000, 11220, 12589, 14125, 15849}, + {17783, 19953, 22387, 25119, 28184, 31623, 35481, 39811, 44668, 50119, 56234, 65535} +}; + +/* avoid to warn in FreeBSD ==> To DO modify */ +static u32 EDCAParam[HT_IOT_PEER_MAX][3] = { + /* UL DL */ + {0x5ea42b, 0x5ea42b, 0x5ea42b}, /* 0:unknown AP */ + {0xa44f, 0x5ea44f, 0x5e431c}, /* 1:realtek AP */ + {0x5ea42b, 0x5ea42b, 0x5ea42b}, /* 2:unknown AP => realtek_92SE */ + {0x5ea32b, 0x5ea42b, 0x5e4322}, /* 3:broadcom AP */ + {0x5ea422, 0x00a44f, 0x00a44f}, /* 4:ralink AP */ + {0x5ea322, 0x00a630, 0x00a44f}, /* 5:atheros AP */ + {0x5e4322, 0x5e4322, 0x5e4322},/* 6:cisco AP */ + {0x5ea44f, 0x00a44f, 0x5ea42b}, /* 8:marvell AP */ + {0x5ea42b, 0x5ea42b, 0x5ea42b}, /* 10:unknown AP=> 92U AP */ + {0x5ea42b, 0xa630, 0x5e431c}, /* 11:airgocap AP */ +}; + +/* Global var */ +u32 OFDMSwingTable[OFDM_TABLE_SIZE_92D] = { + 0x7f8001fe, /* 0, +6.0dB */ + 0x788001e2, /* 1, +5.5dB */ + 0x71c001c7, /* 2, +5.0dB */ + 0x6b8001ae, /* 3, +4.5dB */ + 0x65400195, /* 4, +4.0dB */ + 0x5fc0017f, /* 5, +3.5dB */ + 0x5a400169, /* 6, +3.0dB */ + 0x55400155, /* 7, +2.5dB */ + 0x50800142, /* 8, +2.0dB */ + 0x4c000130, /* 9, +1.5dB */ + 0x47c0011f, /* 10, +1.0dB */ + 0x43c0010f, /* 11, +0.5dB */ + 0x40000100, /* 12, +0dB */ + 0x3c8000f2, /* 13, -0.5dB */ + 0x390000e4, /* 14, -1.0dB */ + 0x35c000d7, /* 15, -1.5dB */ + 0x32c000cb, /* 16, -2.0dB */ + 0x300000c0, /* 17, -2.5dB */ + 0x2d4000b5, /* 18, -3.0dB */ + 0x2ac000ab, /* 19, -3.5dB */ + 0x288000a2, /* 20, -4.0dB */ + 0x26000098, /* 21, -4.5dB */ + 0x24000090, /* 22, -5.0dB */ + 0x22000088, /* 23, -5.5dB */ + 0x20000080, /* 24, -6.0dB */ + 0x1e400079, /* 25, -6.5dB */ + 0x1c800072, /* 26, -7.0dB */ + 0x1b00006c, /* 27. -7.5dB */ + 0x19800066, /* 28, -8.0dB */ + 0x18000060, /* 29, -8.5dB */ + 0x16c0005b, /* 30, -9.0dB */ + 0x15800056, /* 31, -9.5dB */ + 0x14400051, /* 32, -10.0dB */ + 0x1300004c, /* 33, -10.5dB */ + 0x12000048, /* 34, -11.0dB */ + 0x11000044, /* 35, -11.5dB */ + 0x10000040, /* 36, -12.0dB */ + 0x0f00003c,/* 37, -12.5dB */ + 0x0e400039,/* 38, -13.0dB */ + 0x0d800036,/* 39, -13.5dB */ + 0x0cc00033,/* 40, -14.0dB */ + 0x0c000030,/* 41, -14.5dB */ + 0x0b40002d,/* 42, -15.0dB */ +}; + +u8 CCKSwingTable_Ch1_Ch13[CCK_TABLE_SIZE][8] = { + {0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04}, /* 0, +0dB */ + {0x33, 0x32, 0x2b, 0x23, 0x1a, 0x11, 0x08, 0x04}, /* 1, -0.5dB */ + {0x30, 0x2f, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03}, /* 2, -1.0dB */ + {0x2d, 0x2d, 0x27, 0x1f, 0x18, 0x0f, 0x08, 0x03}, /* 3, -1.5dB */ + {0x2b, 0x2a, 0x25, 0x1e, 0x16, 0x0e, 0x07, 0x03}, /* 4, -2.0dB */ + {0x28, 0x28, 0x22, 0x1c, 0x15, 0x0d, 0x07, 0x03}, /* 5, -2.5dB */ + {0x26, 0x25, 0x21, 0x1b, 0x14, 0x0d, 0x06, 0x03}, /* 6, -3.0dB */ + {0x24, 0x23, 0x1f, 0x19, 0x13, 0x0c, 0x06, 0x03}, /* 7, -3.5dB */ + {0x22, 0x21, 0x1d, 0x18, 0x11, 0x0b, 0x06, 0x02}, /* 8, -4.0dB */ + {0x20, 0x20, 0x1b, 0x16, 0x11, 0x08, 0x05, 0x02}, /* 9, -4.5dB */ + {0x1f, 0x1e, 0x1a, 0x15, 0x10, 0x0a, 0x05, 0x02}, /* 10, -5.0dB */ + {0x1d, 0x1c, 0x18, 0x14, 0x0f, 0x0a, 0x05, 0x02}, /* 11, -5.5dB */ + {0x1b, 0x1a, 0x17, 0x13, 0x0e, 0x09, 0x04, 0x02}, /* 12, -6.0dB */ + {0x1a, 0x19, 0x16, 0x12, 0x0d, 0x09, 0x04, 0x02}, /* 13, -6.5dB */ + {0x18, 0x17, 0x15, 0x11, 0x0c, 0x08, 0x04, 0x02}, /* 14, -7.0dB */ + {0x17, 0x16, 0x13, 0x10, 0x0c, 0x08, 0x04, 0x02}, /* 15, -7.5dB */ + {0x16, 0x15, 0x12, 0x0f, 0x0b, 0x07, 0x04, 0x01}, /* 16, -8.0dB */ + {0x14, 0x14, 0x11, 0x0e, 0x0b, 0x07, 0x03, 0x02}, /* 17, -8.5dB */ + {0x13, 0x13, 0x10, 0x0d, 0x0a, 0x06, 0x03, 0x01}, /* 18, -9.0dB */ + {0x12, 0x12, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, /* 19, -9.5dB */ + {0x11, 0x11, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, /* 20, -10.0dB */ + {0x10, 0x10, 0x0e, 0x0b, 0x08, 0x05, 0x03, 0x01}, /* 21, -10.5dB */ + {0x0f, 0x0f, 0x0d, 0x0b, 0x08, 0x05, 0x03, 0x01}, /* 22, -11.0dB */ + {0x0e, 0x0e, 0x0c, 0x0a, 0x08, 0x05, 0x02, 0x01}, /* 23, -11.5dB */ + {0x0d, 0x0d, 0x0c, 0x0a, 0x07, 0x05, 0x02, 0x01}, /* 24, -12.0dB */ + {0x0d, 0x0c, 0x0b, 0x09, 0x07, 0x04, 0x02, 0x01}, /* 25, -12.5dB */ + {0x0c, 0x0c, 0x0a, 0x09, 0x06, 0x04, 0x02, 0x01}, /* 26, -13.0dB */ + {0x0b, 0x0b, 0x0a, 0x08, 0x06, 0x04, 0x02, 0x01}, /* 27, -13.5dB */ + {0x0b, 0x0a, 0x09, 0x08, 0x06, 0x04, 0x02, 0x01}, /* 28, -14.0dB */ + {0x0a, 0x0a, 0x09, 0x07, 0x05, 0x03, 0x02, 0x01}, /* 29, -14.5dB */ + {0x0a, 0x09, 0x08, 0x07, 0x05, 0x03, 0x02, 0x01}, /* 30, -15.0dB */ + {0x09, 0x09, 0x08, 0x06, 0x05, 0x03, 0x01, 0x01}, /* 31, -15.5dB */ + {0x09, 0x08, 0x07, 0x06, 0x04, 0x03, 0x01, 0x01} /* 32, -16.0dB */ +}; + +u8 CCKSwingTable_Ch14[CCK_TABLE_SIZE][8] = { + {0x36, 0x35, 0x2e, 0x1b, 0x00, 0x00, 0x00, 0x00}, /* 0, +0dB */ + {0x33, 0x32, 0x2b, 0x19, 0x00, 0x00, 0x00, 0x00}, /* 1, -0.5dB */ + {0x30, 0x2f, 0x29, 0x18, 0x00, 0x00, 0x00, 0x00}, /* 2, -1.0dB */ + {0x2d, 0x2d, 0x17, 0x17, 0x00, 0x00, 0x00, 0x00}, /* 3, -1.5dB */ + {0x2b, 0x2a, 0x25, 0x15, 0x00, 0x00, 0x00, 0x00}, /* 4, -2.0dB */ + {0x28, 0x28, 0x24, 0x14, 0x00, 0x00, 0x00, 0x00}, /* 5, -2.5dB */ + {0x26, 0x25, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00}, /* 6, -3.0dB */ + {0x24, 0x23, 0x1f, 0x12, 0x00, 0x00, 0x00, 0x00}, /* 7, -3.5dB */ + {0x22, 0x21, 0x1d, 0x11, 0x00, 0x00, 0x00, 0x00}, /* 8, -4.0dB */ + {0x20, 0x20, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x00}, /* 9, -4.5dB */ + {0x1f, 0x1e, 0x1a, 0x0f, 0x00, 0x00, 0x00, 0x00}, /* 10, -5.0dB */ + {0x1d, 0x1c, 0x18, 0x0e, 0x00, 0x00, 0x00, 0x00}, /* 11, -5.5dB */ + {0x1b, 0x1a, 0x17, 0x0e, 0x00, 0x00, 0x00, 0x00}, /* 12, -6.0dB */ + {0x1a, 0x19, 0x16, 0x0d, 0x00, 0x00, 0x00, 0x00}, /* 13, -6.5dB */ + {0x18, 0x17, 0x15, 0x0c, 0x00, 0x00, 0x00, 0x00}, /* 14, -7.0dB */ + {0x17, 0x16, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x00}, /* 15, -7.5dB */ + {0x16, 0x15, 0x12, 0x0b, 0x00, 0x00, 0x00, 0x00}, /* 16, -8.0dB */ + {0x14, 0x14, 0x11, 0x0a, 0x00, 0x00, 0x00, 0x00}, /* 17, -8.5dB */ + {0x13, 0x13, 0x10, 0x0a, 0x00, 0x00, 0x00, 0x00}, /* 18, -9.0dB */ + {0x12, 0x12, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, /* 19, -9.5dB */ + {0x11, 0x11, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, /* 20, -10.0dB */ + {0x10, 0x10, 0x0e, 0x08, 0x00, 0x00, 0x00, 0x00}, /* 21, -10.5dB */ + {0x0f, 0x0f, 0x0d, 0x08, 0x00, 0x00, 0x00, 0x00}, /* 22, -11.0dB */ + {0x0e, 0x0e, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00}, /* 23, -11.5dB */ + {0x0d, 0x0d, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00}, /* 24, -12.0dB */ + {0x0d, 0x0c, 0x0b, 0x06, 0x00, 0x00, 0x00, 0x00}, /* 25, -12.5dB */ + {0x0c, 0x0c, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00}, /* 26, -13.0dB */ + {0x0b, 0x0b, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00}, /* 27, -13.5dB */ + {0x0b, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 28, -14.0dB */ + {0x0a, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 29, -14.5dB */ + {0x0a, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 30, -15.0dB */ + {0x09, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 31, -15.5dB */ + {0x09, 0x08, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00} /* 32, -16.0dB */ +}; + + +#define RxDefaultAnt1 0x65a9 +#define RxDefaultAnt2 0x569a + +/* 3 Export Interface */ + +/* 2011/09/21 MH Add to describe different team necessary resource allocate?? */ +void ODM_DMInit(struct odm_dm_struct *pDM_Odm) +{ + /* 2012.05.03 Luke: For all IC series */ + odm_CommonInfoSelfInit(pDM_Odm); + odm_CmnInfoInit_Debug(pDM_Odm); + odm_DIGInit(pDM_Odm); + odm_RateAdaptiveMaskInit(pDM_Odm); + + if (pDM_Odm->SupportICType & ODM_IC_11AC_SERIES) { + ; + } else if (pDM_Odm->SupportICType & ODM_IC_11N_SERIES) { + odm_PrimaryCCA_Init(pDM_Odm); /* Gary */ + odm_DynamicBBPowerSavingInit(pDM_Odm); + odm_DynamicTxPowerInit(pDM_Odm); + odm_TXPowerTrackingInit(pDM_Odm); + ODM_EdcaTurboInit(pDM_Odm); + ODM_RAInfo_Init_all(pDM_Odm); + if ((pDM_Odm->AntDivType == CG_TRX_HW_ANTDIV) || + (pDM_Odm->AntDivType == CGCS_RX_HW_ANTDIV) || + (pDM_Odm->AntDivType == CG_TRX_SMART_ANTDIV)) + odm_InitHybridAntDiv(pDM_Odm); + else if (pDM_Odm->AntDivType == CGCS_RX_SW_ANTDIV) + odm_SwAntDivInit(pDM_Odm); + } +} + +/* 2011/09/20 MH This is the entry pointer for all team to execute HW out source DM. */ +/* You can not add any dummy function here, be care, you can only use DM structure */ +/* to perform any new ODM_DM. */ +void ODM_DMWatchdog(struct odm_dm_struct *pDM_Odm) +{ + /* 2012.05.03 Luke: For all IC series */ + odm_GlobalAdapterCheck(); + odm_CmnInfoHook_Debug(pDM_Odm); + odm_CmnInfoUpdate_Debug(pDM_Odm); + odm_CommonInfoSelfUpdate(pDM_Odm); + odm_FalseAlarmCounterStatistics(pDM_Odm); + odm_RSSIMonitorCheck(pDM_Odm); + + /* For CE Platform(SPRD or Tablet) */ + /* 8723A or 8189ES platform */ + /* NeilChen--2012--08--24-- */ + /* Fix Leave LPS issue */ + if ((pDM_Odm->Adapter->pwrctrlpriv.pwr_mode != PS_MODE_ACTIVE) &&/* in LPS mode */ + ((pDM_Odm->SupportICType & (ODM_RTL8723A)) || + (pDM_Odm->SupportICType & (ODM_RTL8188E) && + ((pDM_Odm->SupportInterface == ODM_ITRF_SDIO))))) { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("----Step1: odm_DIG is in LPS mode\n")); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("---Step2: 8723AS is in LPS mode\n")); + odm_DIGbyRSSI_LPS(pDM_Odm); + } else { + odm_DIG(pDM_Odm); + } + odm_CCKPacketDetectionThresh(pDM_Odm); + + if (*(pDM_Odm->pbPowerSaving)) + return; + + odm_RefreshRateAdaptiveMask(pDM_Odm); + + odm_DynamicBBPowerSaving(pDM_Odm); + odm_DynamicPrimaryCCA(pDM_Odm); + if ((pDM_Odm->AntDivType == CG_TRX_HW_ANTDIV) || + (pDM_Odm->AntDivType == CGCS_RX_HW_ANTDIV) || + (pDM_Odm->AntDivType == CG_TRX_SMART_ANTDIV)) + odm_HwAntDiv(pDM_Odm); + else if (pDM_Odm->AntDivType == CGCS_RX_SW_ANTDIV) + odm_SwAntDivChkAntSwitch(pDM_Odm, SWAW_STEP_PEAK); + + if (pDM_Odm->SupportICType & ODM_IC_11AC_SERIES) { + ; + } else if (pDM_Odm->SupportICType & ODM_IC_11N_SERIES) { + ODM_TXPowerTrackingCheck(pDM_Odm); + odm_EdcaTurboCheck(pDM_Odm); + odm_DynamicTxPower(pDM_Odm); + } + odm_dtc(pDM_Odm); +} + +/* Init /.. Fixed HW value. Only init time. */ +void ODM_CmnInfoInit(struct odm_dm_struct *pDM_Odm, enum odm_common_info_def CmnInfo, u32 Value) +{ + /* This section is used for init value */ + switch (CmnInfo) { + /* Fixed ODM value. */ + case ODM_CMNINFO_ABILITY: + pDM_Odm->SupportAbility = (u32)Value; + break; + case ODM_CMNINFO_PLATFORM: + pDM_Odm->SupportPlatform = (u8)Value; + break; + case ODM_CMNINFO_INTERFACE: + pDM_Odm->SupportInterface = (u8)Value; + break; + case ODM_CMNINFO_MP_TEST_CHIP: + pDM_Odm->bIsMPChip = (u8)Value; + break; + case ODM_CMNINFO_IC_TYPE: + pDM_Odm->SupportICType = Value; + break; + case ODM_CMNINFO_CUT_VER: + pDM_Odm->CutVersion = (u8)Value; + break; + case ODM_CMNINFO_FAB_VER: + pDM_Odm->FabVersion = (u8)Value; + break; + case ODM_CMNINFO_RF_TYPE: + pDM_Odm->RFType = (u8)Value; + break; + case ODM_CMNINFO_RF_ANTENNA_TYPE: + pDM_Odm->AntDivType = (u8)Value; + break; + case ODM_CMNINFO_BOARD_TYPE: + pDM_Odm->BoardType = (u8)Value; + break; + case ODM_CMNINFO_EXT_LNA: + pDM_Odm->ExtLNA = (u8)Value; + break; + case ODM_CMNINFO_EXT_PA: + pDM_Odm->ExtPA = (u8)Value; + break; + case ODM_CMNINFO_EXT_TRSW: + pDM_Odm->ExtTRSW = (u8)Value; + break; + case ODM_CMNINFO_PATCH_ID: + pDM_Odm->PatchID = (u8)Value; + break; + case ODM_CMNINFO_BINHCT_TEST: + pDM_Odm->bInHctTest = (bool)Value; + break; + case ODM_CMNINFO_BWIFI_TEST: + pDM_Odm->bWIFITest = (bool)Value; + break; + case ODM_CMNINFO_SMART_CONCURRENT: + pDM_Odm->bDualMacSmartConcurrent = (bool)Value; + break; + /* To remove the compiler warning, must add an empty default statement to handle the other values. */ + default: + /* do nothing */ + break; + } + + /* Tx power tracking BB swing table. */ + /* The base index = 12. +((12-n)/2)dB 13~?? = decrease tx pwr by -((n-12)/2)dB */ + pDM_Odm->BbSwingIdxOfdm = 12; /* Set defalut value as index 12. */ + pDM_Odm->BbSwingIdxOfdmCurrent = 12; + pDM_Odm->BbSwingFlagOfdm = false; +} + +void ODM_CmnInfoHook(struct odm_dm_struct *pDM_Odm, enum odm_common_info_def CmnInfo, void *pValue) +{ + /* */ + /* Hook call by reference pointer. */ + /* */ + switch (CmnInfo) { + /* Dynamic call by reference pointer. */ + case ODM_CMNINFO_MAC_PHY_MODE: + pDM_Odm->pMacPhyMode = (u8 *)pValue; + break; + case ODM_CMNINFO_TX_UNI: + pDM_Odm->pNumTxBytesUnicast = (u64 *)pValue; + break; + case ODM_CMNINFO_RX_UNI: + pDM_Odm->pNumRxBytesUnicast = (u64 *)pValue; + break; + case ODM_CMNINFO_WM_MODE: + pDM_Odm->pWirelessMode = (u8 *)pValue; + break; + case ODM_CMNINFO_BAND: + pDM_Odm->pBandType = (u8 *)pValue; + break; + case ODM_CMNINFO_SEC_CHNL_OFFSET: + pDM_Odm->pSecChOffset = (u8 *)pValue; + break; + case ODM_CMNINFO_SEC_MODE: + pDM_Odm->pSecurity = (u8 *)pValue; + break; + case ODM_CMNINFO_BW: + pDM_Odm->pBandWidth = (u8 *)pValue; + break; + case ODM_CMNINFO_CHNL: + pDM_Odm->pChannel = (u8 *)pValue; + break; + case ODM_CMNINFO_DMSP_GET_VALUE: + pDM_Odm->pbGetValueFromOtherMac = (bool *)pValue; + break; + case ODM_CMNINFO_BUDDY_ADAPTOR: + pDM_Odm->pBuddyAdapter = (struct adapter **)pValue; + break; + case ODM_CMNINFO_DMSP_IS_MASTER: + pDM_Odm->pbMasterOfDMSP = (bool *)pValue; + break; + case ODM_CMNINFO_SCAN: + pDM_Odm->pbScanInProcess = (bool *)pValue; + break; + case ODM_CMNINFO_POWER_SAVING: + pDM_Odm->pbPowerSaving = (bool *)pValue; + break; + case ODM_CMNINFO_ONE_PATH_CCA: + pDM_Odm->pOnePathCCA = (u8 *)pValue; + break; + case ODM_CMNINFO_DRV_STOP: + pDM_Odm->pbDriverStopped = (bool *)pValue; + break; + case ODM_CMNINFO_PNP_IN: + pDM_Odm->pbDriverIsGoingToPnpSetPowerSleep = (bool *)pValue; + break; + case ODM_CMNINFO_INIT_ON: + pDM_Odm->pinit_adpt_in_progress = (bool *)pValue; + break; + case ODM_CMNINFO_ANT_TEST: + pDM_Odm->pAntennaTest = (u8 *)pValue; + break; + case ODM_CMNINFO_NET_CLOSED: + pDM_Odm->pbNet_closed = (bool *)pValue; + break; + case ODM_CMNINFO_MP_MODE: + pDM_Odm->mp_mode = (u8 *)pValue; + break; + /* To remove the compiler warning, must add an empty default statement to handle the other values. */ + default: + /* do nothing */ + break; + } +} + +void ODM_CmnInfoPtrArrayHook(struct odm_dm_struct *pDM_Odm, enum odm_common_info_def CmnInfo, u16 Index, void *pValue) +{ + /* Hook call by reference pointer. */ + switch (CmnInfo) { + /* Dynamic call by reference pointer. */ + case ODM_CMNINFO_STA_STATUS: + pDM_Odm->pODM_StaInfo[Index] = (struct sta_info *)pValue; + break; + /* To remove the compiler warning, must add an empty default statement to handle the other values. */ + default: + /* do nothing */ + break; + } +} + +/* Update Band/CHannel/.. The values are dynamic but non-per-packet. */ +void ODM_CmnInfoUpdate(struct odm_dm_struct *pDM_Odm, u32 CmnInfo, u64 Value) +{ + /* */ + /* This init variable may be changed in run time. */ + /* */ + switch (CmnInfo) { + case ODM_CMNINFO_ABILITY: + pDM_Odm->SupportAbility = (u32)Value; + break; + case ODM_CMNINFO_RF_TYPE: + pDM_Odm->RFType = (u8)Value; + break; + case ODM_CMNINFO_WIFI_DIRECT: + pDM_Odm->bWIFI_Direct = (bool)Value; + break; + case ODM_CMNINFO_WIFI_DISPLAY: + pDM_Odm->bWIFI_Display = (bool)Value; + break; + case ODM_CMNINFO_LINK: + pDM_Odm->bLinked = (bool)Value; + break; + case ODM_CMNINFO_RSSI_MIN: + pDM_Odm->RSSI_Min = (u8)Value; + break; + case ODM_CMNINFO_DBG_COMP: + pDM_Odm->DebugComponents = Value; + break; + case ODM_CMNINFO_DBG_LEVEL: + pDM_Odm->DebugLevel = (u32)Value; + break; + case ODM_CMNINFO_RA_THRESHOLD_HIGH: + pDM_Odm->RateAdaptive.HighRSSIThresh = (u8)Value; + break; + case ODM_CMNINFO_RA_THRESHOLD_LOW: + pDM_Odm->RateAdaptive.LowRSSIThresh = (u8)Value; + break; + } +} + +void odm_CommonInfoSelfInit(struct odm_dm_struct *pDM_Odm) +{ + pDM_Odm->bCckHighPower = (bool) ODM_GetBBReg(pDM_Odm, 0x824, BIT9); + pDM_Odm->RFPathRxEnable = (u8) ODM_GetBBReg(pDM_Odm, 0xc04, 0x0F); + if (pDM_Odm->SupportICType & (ODM_RTL8192C|ODM_RTL8192D)) + pDM_Odm->AntDivType = CG_TRX_HW_ANTDIV; + if (pDM_Odm->SupportICType & (ODM_RTL8723A)) + pDM_Odm->AntDivType = CGCS_RX_SW_ANTDIV; + + ODM_InitDebugSetting(pDM_Odm); +} + +void odm_CommonInfoSelfUpdate(struct odm_dm_struct *pDM_Odm) +{ + u8 EntryCnt = 0; + u8 i; + struct sta_info *pEntry; + + if (*(pDM_Odm->pBandWidth) == ODM_BW40M) { + if (*(pDM_Odm->pSecChOffset) == 1) + pDM_Odm->ControlChannel = *(pDM_Odm->pChannel) - 2; + else if (*(pDM_Odm->pSecChOffset) == 2) + pDM_Odm->ControlChannel = *(pDM_Odm->pChannel) + 2; + } else { + pDM_Odm->ControlChannel = *(pDM_Odm->pChannel); + } + + for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) { + pEntry = pDM_Odm->pODM_StaInfo[i]; + if (IS_STA_VALID(pEntry)) + EntryCnt++; + } + if (EntryCnt == 1) + pDM_Odm->bOneEntryOnly = true; + else + pDM_Odm->bOneEntryOnly = false; +} + +void odm_CmnInfoInit_Debug(struct odm_dm_struct *pDM_Odm) +{ + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("odm_CmnInfoInit_Debug==>\n")); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("SupportPlatform=%d\n", pDM_Odm->SupportPlatform)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("SupportAbility=0x%x\n", pDM_Odm->SupportAbility)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("SupportInterface=%d\n", pDM_Odm->SupportInterface)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("SupportICType=0x%x\n", pDM_Odm->SupportICType)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("CutVersion=%d\n", pDM_Odm->CutVersion)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("FabVersion=%d\n", pDM_Odm->FabVersion)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("RFType=%d\n", pDM_Odm->RFType)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("BoardType=%d\n", pDM_Odm->BoardType)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("ExtLNA=%d\n", pDM_Odm->ExtLNA)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("ExtPA=%d\n", pDM_Odm->ExtPA)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("ExtTRSW=%d\n", pDM_Odm->ExtTRSW)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("PatchID=%d\n", pDM_Odm->PatchID)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bInHctTest=%d\n", pDM_Odm->bInHctTest)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bWIFITest=%d\n", pDM_Odm->bWIFITest)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bDualMacSmartConcurrent=%d\n", pDM_Odm->bDualMacSmartConcurrent)); +} + +void odm_CmnInfoHook_Debug(struct odm_dm_struct *pDM_Odm) +{ + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("odm_CmnInfoHook_Debug==>\n")); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("pNumTxBytesUnicast=%llu\n", *(pDM_Odm->pNumTxBytesUnicast))); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("pNumRxBytesUnicast=%llu\n", *(pDM_Odm->pNumRxBytesUnicast))); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("pWirelessMode=0x%x\n", *(pDM_Odm->pWirelessMode))); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("pSecChOffset=%d\n", *(pDM_Odm->pSecChOffset))); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("pSecurity=%d\n", *(pDM_Odm->pSecurity))); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("pBandWidth=%d\n", *(pDM_Odm->pBandWidth))); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("pChannel=%d\n", *(pDM_Odm->pChannel))); + + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("pbScanInProcess=%d\n", *(pDM_Odm->pbScanInProcess))); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("pbPowerSaving=%d\n", *(pDM_Odm->pbPowerSaving))); + + if (pDM_Odm->SupportPlatform & (ODM_AP|ODM_ADSL)) + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("pOnePathCCA=%d\n", *(pDM_Odm->pOnePathCCA))); +} + +void odm_CmnInfoUpdate_Debug(struct odm_dm_struct *pDM_Odm) +{ + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("odm_CmnInfoUpdate_Debug==>\n")); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bWIFI_Direct=%d\n", pDM_Odm->bWIFI_Direct)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bWIFI_Display=%d\n", pDM_Odm->bWIFI_Display)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bLinked=%d\n", pDM_Odm->bLinked)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("RSSI_Min=%d\n", pDM_Odm->RSSI_Min)); +} + +static int getIGIForDiff(int value_IGI) +{ + #define ONERCCA_LOW_TH 0x30 + #define ONERCCA_LOW_DIFF 8 + + if (value_IGI < ONERCCA_LOW_TH) { + if ((ONERCCA_LOW_TH - value_IGI) < ONERCCA_LOW_DIFF) + return ONERCCA_LOW_TH; + else + return value_IGI + ONERCCA_LOW_DIFF; + } else { + return value_IGI; + } +} + +void ODM_Write_DIG(struct odm_dm_struct *pDM_Odm, u8 CurrentIGI) +{ + struct rtw_dig *pDM_DigTable = &pDM_Odm->DM_DigTable; + + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, + ("ODM_REG(IGI_A,pDM_Odm)=0x%x, ODM_BIT(IGI,pDM_Odm)=0x%x\n", + ODM_REG(IGI_A, pDM_Odm), ODM_BIT(IGI, pDM_Odm))); + + if (pDM_DigTable->CurIGValue != CurrentIGI) { + if (pDM_Odm->SupportPlatform & (ODM_CE|ODM_MP)) { + ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_A, pDM_Odm), ODM_BIT(IGI, pDM_Odm), CurrentIGI); + if (pDM_Odm->SupportICType != ODM_RTL8188E) + ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_B, pDM_Odm), ODM_BIT(IGI, pDM_Odm), CurrentIGI); + } else if (pDM_Odm->SupportPlatform & (ODM_AP|ODM_ADSL)) { + switch (*(pDM_Odm->pOnePathCCA)) { + case ODM_CCA_2R: + ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_A, pDM_Odm), ODM_BIT(IGI, pDM_Odm), CurrentIGI); + if (pDM_Odm->SupportICType != ODM_RTL8188E) + ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_B, pDM_Odm), ODM_BIT(IGI, pDM_Odm), CurrentIGI); + break; + case ODM_CCA_1R_A: + ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_A, pDM_Odm), ODM_BIT(IGI, pDM_Odm), CurrentIGI); + if (pDM_Odm->SupportICType != ODM_RTL8188E) + ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_B, pDM_Odm), ODM_BIT(IGI, pDM_Odm), getIGIForDiff(CurrentIGI)); + break; + case ODM_CCA_1R_B: + ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_A, pDM_Odm), ODM_BIT(IGI, pDM_Odm), getIGIForDiff(CurrentIGI)); + if (pDM_Odm->SupportICType != ODM_RTL8188E) + ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_B, pDM_Odm), ODM_BIT(IGI, pDM_Odm), CurrentIGI); + break; + } + } + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("CurrentIGI(0x%02x).\n", CurrentIGI)); + /* pDM_DigTable->PreIGValue = pDM_DigTable->CurIGValue; */ + pDM_DigTable->CurIGValue = CurrentIGI; + } + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("ODM_Write_DIG():CurrentIGI=0x%x\n", CurrentIGI)); + +/* Add by Neil Chen to enable edcca to MP Platform */ +} + +/* Need LPS mode for CE platform --2012--08--24--- */ +/* 8723AS/8189ES */ +void odm_DIGbyRSSI_LPS(struct odm_dm_struct *pDM_Odm) +{ + struct adapter *pAdapter = pDM_Odm->Adapter; + struct false_alarm_stats *pFalseAlmCnt = &pDM_Odm->FalseAlmCnt; + + u8 RSSI_Lower = DM_DIG_MIN_NIC; /* 0x1E or 0x1C */ + u8 bFwCurrentInPSMode = false; + u8 CurrentIGI = pDM_Odm->RSSI_Min; + + if (!(pDM_Odm->SupportICType & (ODM_RTL8723A | ODM_RTL8188E))) + return; + + CurrentIGI = CurrentIGI + RSSI_OFFSET_DIG; + bFwCurrentInPSMode = pAdapter->pwrctrlpriv.bFwCurrentInPSMode; + + /* Using FW PS mode to make IGI */ + if (bFwCurrentInPSMode) { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("---Neil---odm_DIG is in LPS mode\n")); + /* Adjust by FA in LPS MODE */ + if (pFalseAlmCnt->Cnt_all > DM_DIG_FA_TH2_LPS) + CurrentIGI = CurrentIGI+2; + else if (pFalseAlmCnt->Cnt_all > DM_DIG_FA_TH1_LPS) + CurrentIGI = CurrentIGI+1; + else if (pFalseAlmCnt->Cnt_all < DM_DIG_FA_TH0_LPS) + CurrentIGI = CurrentIGI-1; + } else { + CurrentIGI = RSSI_Lower; + } + + /* Lower bound checking */ + + /* RSSI Lower bound check */ + if ((pDM_Odm->RSSI_Min-10) > DM_DIG_MIN_NIC) + RSSI_Lower = (pDM_Odm->RSSI_Min-10); + else + RSSI_Lower = DM_DIG_MIN_NIC; + + /* Upper and Lower Bound checking */ + if (CurrentIGI > DM_DIG_MAX_NIC) + CurrentIGI = DM_DIG_MAX_NIC; + else if (CurrentIGI < RSSI_Lower) + CurrentIGI = RSSI_Lower; + + ODM_Write_DIG(pDM_Odm, CurrentIGI);/* ODM_Write_DIG(pDM_Odm, pDM_DigTable->CurIGValue); */ +} + +void odm_DIGInit(struct odm_dm_struct *pDM_Odm) +{ + struct rtw_dig *pDM_DigTable = &pDM_Odm->DM_DigTable; + + pDM_DigTable->CurIGValue = (u8) ODM_GetBBReg(pDM_Odm, ODM_REG(IGI_A, pDM_Odm), ODM_BIT(IGI, pDM_Odm)); + pDM_DigTable->RssiLowThresh = DM_DIG_THRESH_LOW; + pDM_DigTable->RssiHighThresh = DM_DIG_THRESH_HIGH; + pDM_DigTable->FALowThresh = DM_false_ALARM_THRESH_LOW; + pDM_DigTable->FAHighThresh = DM_false_ALARM_THRESH_HIGH; + if (pDM_Odm->BoardType == ODM_BOARD_HIGHPWR) { + pDM_DigTable->rx_gain_range_max = DM_DIG_MAX_NIC; + pDM_DigTable->rx_gain_range_min = DM_DIG_MIN_NIC; + } else { + pDM_DigTable->rx_gain_range_max = DM_DIG_MAX_NIC; + pDM_DigTable->rx_gain_range_min = DM_DIG_MIN_NIC; + } + pDM_DigTable->BackoffVal = DM_DIG_BACKOFF_DEFAULT; + pDM_DigTable->BackoffVal_range_max = DM_DIG_BACKOFF_MAX; + pDM_DigTable->BackoffVal_range_min = DM_DIG_BACKOFF_MIN; + pDM_DigTable->PreCCK_CCAThres = 0xFF; + pDM_DigTable->CurCCK_CCAThres = 0x83; + pDM_DigTable->ForbiddenIGI = DM_DIG_MIN_NIC; + pDM_DigTable->LargeFAHit = 0; + pDM_DigTable->Recover_cnt = 0; + pDM_DigTable->DIG_Dynamic_MIN_0 = DM_DIG_MIN_NIC; + pDM_DigTable->DIG_Dynamic_MIN_1 = DM_DIG_MIN_NIC; + pDM_DigTable->bMediaConnect_0 = false; + pDM_DigTable->bMediaConnect_1 = false; + + /* To Initialize pDM_Odm->bDMInitialGainEnable == false to avoid DIG error */ + pDM_Odm->bDMInitialGainEnable = true; +} + +void odm_DIG(struct odm_dm_struct *pDM_Odm) +{ + struct rtw_dig *pDM_DigTable = &pDM_Odm->DM_DigTable; + struct false_alarm_stats *pFalseAlmCnt = &pDM_Odm->FalseAlmCnt; + u8 DIG_Dynamic_MIN; + u8 DIG_MaxOfMin; + bool FirstConnect, FirstDisConnect; + u8 dm_dig_max, dm_dig_min; + u8 CurrentIGI = pDM_DigTable->CurIGValue; + + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG()==>\n")); + if ((!(pDM_Odm->SupportAbility&ODM_BB_DIG)) || (!(pDM_Odm->SupportAbility&ODM_BB_FA_CNT))) { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, + ("odm_DIG() Return: SupportAbility ODM_BB_DIG or ODM_BB_FA_CNT is disabled\n")); + return; + } + + if (*(pDM_Odm->pbScanInProcess)) { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG() Return: In Scan Progress\n")); + return; + } + + /* add by Neil Chen to avoid PSD is processing */ + if (pDM_Odm->bDMInitialGainEnable == false) { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG() Return: PSD is Processing\n")); + return; + } + + if (pDM_Odm->SupportICType == ODM_RTL8192D) { + if (*(pDM_Odm->pMacPhyMode) == ODM_DMSP) { + if (*(pDM_Odm->pbMasterOfDMSP)) { + DIG_Dynamic_MIN = pDM_DigTable->DIG_Dynamic_MIN_0; + FirstConnect = (pDM_Odm->bLinked) && (!pDM_DigTable->bMediaConnect_0); + FirstDisConnect = (!pDM_Odm->bLinked) && (pDM_DigTable->bMediaConnect_0); + } else { + DIG_Dynamic_MIN = pDM_DigTable->DIG_Dynamic_MIN_1; + FirstConnect = (pDM_Odm->bLinked) && (!pDM_DigTable->bMediaConnect_1); + FirstDisConnect = (!pDM_Odm->bLinked) && (pDM_DigTable->bMediaConnect_1); + } + } else { + if (*(pDM_Odm->pBandType) == ODM_BAND_5G) { + DIG_Dynamic_MIN = pDM_DigTable->DIG_Dynamic_MIN_0; + FirstConnect = (pDM_Odm->bLinked) && (!pDM_DigTable->bMediaConnect_0); + FirstDisConnect = (!pDM_Odm->bLinked) && (pDM_DigTable->bMediaConnect_0); + } else { + DIG_Dynamic_MIN = pDM_DigTable->DIG_Dynamic_MIN_1; + FirstConnect = (pDM_Odm->bLinked) && (!pDM_DigTable->bMediaConnect_1); + FirstDisConnect = (!pDM_Odm->bLinked) && (pDM_DigTable->bMediaConnect_1); + } + } + } else { + DIG_Dynamic_MIN = pDM_DigTable->DIG_Dynamic_MIN_0; + FirstConnect = (pDM_Odm->bLinked) && (!pDM_DigTable->bMediaConnect_0); + FirstDisConnect = (!pDM_Odm->bLinked) && (pDM_DigTable->bMediaConnect_0); + } + + /* 1 Boundary Decision */ + if ((pDM_Odm->SupportICType & (ODM_RTL8192C|ODM_RTL8723A)) && + ((pDM_Odm->BoardType == ODM_BOARD_HIGHPWR) || pDM_Odm->ExtLNA)) { + if (pDM_Odm->SupportPlatform & (ODM_AP|ODM_ADSL)) { + dm_dig_max = DM_DIG_MAX_AP_HP; + dm_dig_min = DM_DIG_MIN_AP_HP; + } else { + dm_dig_max = DM_DIG_MAX_NIC_HP; + dm_dig_min = DM_DIG_MIN_NIC_HP; + } + DIG_MaxOfMin = DM_DIG_MAX_AP_HP; + } else { + if (pDM_Odm->SupportPlatform & (ODM_AP|ODM_ADSL)) { + dm_dig_max = DM_DIG_MAX_AP; + dm_dig_min = DM_DIG_MIN_AP; + DIG_MaxOfMin = dm_dig_max; + } else { + dm_dig_max = DM_DIG_MAX_NIC; + dm_dig_min = DM_DIG_MIN_NIC; + DIG_MaxOfMin = DM_DIG_MAX_AP; + } + } + if (pDM_Odm->bLinked) { + /* 2 8723A Series, offset need to be 10 */ + if (pDM_Odm->SupportICType == (ODM_RTL8723A)) { + /* 2 Upper Bound */ + if ((pDM_Odm->RSSI_Min + 10) > DM_DIG_MAX_NIC) + pDM_DigTable->rx_gain_range_max = DM_DIG_MAX_NIC; + else if ((pDM_Odm->RSSI_Min + 10) < DM_DIG_MIN_NIC) + pDM_DigTable->rx_gain_range_max = DM_DIG_MIN_NIC; + else + pDM_DigTable->rx_gain_range_max = pDM_Odm->RSSI_Min + 10; + /* 2 If BT is Concurrent, need to set Lower Bound */ + DIG_Dynamic_MIN = DM_DIG_MIN_NIC; + } else { + /* 2 Modify DIG upper bound */ + if ((pDM_Odm->RSSI_Min + 20) > dm_dig_max) + pDM_DigTable->rx_gain_range_max = dm_dig_max; + else if ((pDM_Odm->RSSI_Min + 20) < dm_dig_min) + pDM_DigTable->rx_gain_range_max = dm_dig_min; + else + pDM_DigTable->rx_gain_range_max = pDM_Odm->RSSI_Min + 20; + /* 2 Modify DIG lower bound */ + if (pDM_Odm->bOneEntryOnly) { + if (pDM_Odm->RSSI_Min < dm_dig_min) + DIG_Dynamic_MIN = dm_dig_min; + else if (pDM_Odm->RSSI_Min > DIG_MaxOfMin) + DIG_Dynamic_MIN = DIG_MaxOfMin; + else + DIG_Dynamic_MIN = pDM_Odm->RSSI_Min; + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, + ("odm_DIG() : bOneEntryOnly=true, DIG_Dynamic_MIN=0x%x\n", + DIG_Dynamic_MIN)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, + ("odm_DIG() : pDM_Odm->RSSI_Min=%d\n", + pDM_Odm->RSSI_Min)); + } else if ((pDM_Odm->SupportICType == ODM_RTL8188E) && + (pDM_Odm->SupportAbility & ODM_BB_ANT_DIV)) { + /* 1 Lower Bound for 88E AntDiv */ + if (pDM_Odm->AntDivType == CG_TRX_HW_ANTDIV) { + DIG_Dynamic_MIN = (u8) pDM_DigTable->AntDiv_RSSI_max; + ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, + ("odm_DIG(): pDM_DigTable->AntDiv_RSSI_max=%d\n", + pDM_DigTable->AntDiv_RSSI_max)); + } + } else { + DIG_Dynamic_MIN = dm_dig_min; + } + } + } else { + pDM_DigTable->rx_gain_range_max = dm_dig_max; + DIG_Dynamic_MIN = dm_dig_min; + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG() : No Link\n")); + } + + /* 1 Modify DIG lower bound, deal with abnormally large false alarm */ + if (pFalseAlmCnt->Cnt_all > 10000) { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("dm_DIG(): Abnornally false alarm case.\n")); + + if (pDM_DigTable->LargeFAHit != 3) + pDM_DigTable->LargeFAHit++; + if (pDM_DigTable->ForbiddenIGI < CurrentIGI) { + pDM_DigTable->ForbiddenIGI = CurrentIGI; + pDM_DigTable->LargeFAHit = 1; + } + + if (pDM_DigTable->LargeFAHit >= 3) { + if ((pDM_DigTable->ForbiddenIGI+1) > pDM_DigTable->rx_gain_range_max) + pDM_DigTable->rx_gain_range_min = pDM_DigTable->rx_gain_range_max; + else + pDM_DigTable->rx_gain_range_min = (pDM_DigTable->ForbiddenIGI + 1); + pDM_DigTable->Recover_cnt = 3600; /* 3600=2hr */ + } + + } else { + /* Recovery mechanism for IGI lower bound */ + if (pDM_DigTable->Recover_cnt != 0) { + pDM_DigTable->Recover_cnt--; + } else { + if (pDM_DigTable->LargeFAHit < 3) { + if ((pDM_DigTable->ForbiddenIGI-1) < DIG_Dynamic_MIN) { /* DM_DIG_MIN) */ + pDM_DigTable->ForbiddenIGI = DIG_Dynamic_MIN; /* DM_DIG_MIN; */ + pDM_DigTable->rx_gain_range_min = DIG_Dynamic_MIN; /* DM_DIG_MIN; */ + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): Normal Case: At Lower Bound\n")); + } else { + pDM_DigTable->ForbiddenIGI--; + pDM_DigTable->rx_gain_range_min = (pDM_DigTable->ForbiddenIGI + 1); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): Normal Case: Approach Lower Bound\n")); + } + } else { + pDM_DigTable->LargeFAHit = 0; + } + } + } + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, + ("odm_DIG(): pDM_DigTable->LargeFAHit=%d\n", + pDM_DigTable->LargeFAHit)); + + /* 1 Adjust initial gain by false alarm */ + if (pDM_Odm->bLinked) { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): DIG AfterLink\n")); + if (FirstConnect) { + CurrentIGI = pDM_Odm->RSSI_Min; + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("DIG: First Connect\n")); + } else { + if (pDM_Odm->SupportICType == ODM_RTL8192D) { + if (pFalseAlmCnt->Cnt_all > DM_DIG_FA_TH2_92D) + CurrentIGI = CurrentIGI + 2;/* pDM_DigTable->CurIGValue = pDM_DigTable->PreIGValue+2; */ + else if (pFalseAlmCnt->Cnt_all > DM_DIG_FA_TH1_92D) + CurrentIGI = CurrentIGI + 1; /* pDM_DigTable->CurIGValue = pDM_DigTable->PreIGValue+1; */ + else if (pFalseAlmCnt->Cnt_all < DM_DIG_FA_TH0_92D) + CurrentIGI = CurrentIGI - 1;/* pDM_DigTable->CurIGValue =pDM_DigTable->PreIGValue-1; */ + } else { + if (pFalseAlmCnt->Cnt_all > DM_DIG_FA_TH2) + CurrentIGI = CurrentIGI + 4;/* pDM_DigTable->CurIGValue = pDM_DigTable->PreIGValue+2; */ + else if (pFalseAlmCnt->Cnt_all > DM_DIG_FA_TH1) + CurrentIGI = CurrentIGI + 2;/* pDM_DigTable->CurIGValue = pDM_DigTable->PreIGValue+1; */ + else if (pFalseAlmCnt->Cnt_all < DM_DIG_FA_TH0) + CurrentIGI = CurrentIGI - 2;/* pDM_DigTable->CurIGValue =pDM_DigTable->PreIGValue-1; */ + } + } + } else { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): DIG BeforeLink\n")); + if (FirstDisConnect) { + CurrentIGI = pDM_DigTable->rx_gain_range_min; + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): First DisConnect\n")); + } else { + /* 2012.03.30 LukeLee: enable DIG before link but with very high thresholds */ + if (pFalseAlmCnt->Cnt_all > 10000) + CurrentIGI = CurrentIGI + 2;/* pDM_DigTable->CurIGValue = pDM_DigTable->PreIGValue+2; */ + else if (pFalseAlmCnt->Cnt_all > 8000) + CurrentIGI = CurrentIGI + 1;/* pDM_DigTable->CurIGValue = pDM_DigTable->PreIGValue+1; */ + else if (pFalseAlmCnt->Cnt_all < 500) + CurrentIGI = CurrentIGI - 1;/* pDM_DigTable->CurIGValue =pDM_DigTable->PreIGValue-1; */ + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): England DIG\n")); + } + } + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): DIG End Adjust IGI\n")); + /* 1 Check initial gain by upper/lower bound */ + if (CurrentIGI > pDM_DigTable->rx_gain_range_max) + CurrentIGI = pDM_DigTable->rx_gain_range_max; + if (CurrentIGI < pDM_DigTable->rx_gain_range_min) + CurrentIGI = pDM_DigTable->rx_gain_range_min; + + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, + ("odm_DIG(): rx_gain_range_max=0x%x, rx_gain_range_min=0x%x\n", + pDM_DigTable->rx_gain_range_max, pDM_DigTable->rx_gain_range_min)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): TotalFA=%d\n", pFalseAlmCnt->Cnt_all)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): CurIGValue=0x%x\n", CurrentIGI)); + + /* 2 High power RSSI threshold */ + + ODM_Write_DIG(pDM_Odm, CurrentIGI);/* ODM_Write_DIG(pDM_Odm, pDM_DigTable->CurIGValue); */ + pDM_DigTable->bMediaConnect_0 = pDM_Odm->bLinked; + pDM_DigTable->DIG_Dynamic_MIN_0 = DIG_Dynamic_MIN; +} + +/* 3============================================================ */ +/* 3 FASLE ALARM CHECK */ +/* 3============================================================ */ + +void odm_FalseAlarmCounterStatistics(struct odm_dm_struct *pDM_Odm) +{ + u32 ret_value; + struct false_alarm_stats *FalseAlmCnt = &(pDM_Odm->FalseAlmCnt); + + if (!(pDM_Odm->SupportAbility & ODM_BB_FA_CNT)) + return; + + if (pDM_Odm->SupportICType & ODM_IC_11N_SERIES) { + /* hold ofdm counter */ + ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_HOLDC_11N, BIT31, 1); /* hold page C counter */ + ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTD_11N, BIT31, 1); /* hold page D counter */ + + ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_OFDM_FA_TYPE1_11N, bMaskDWord); + FalseAlmCnt->Cnt_Fast_Fsync = (ret_value&0xffff); + FalseAlmCnt->Cnt_SB_Search_fail = ((ret_value&0xffff0000)>>16); + ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_OFDM_FA_TYPE2_11N, bMaskDWord); + FalseAlmCnt->Cnt_OFDM_CCA = (ret_value&0xffff); + FalseAlmCnt->Cnt_Parity_Fail = ((ret_value&0xffff0000)>>16); + ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_OFDM_FA_TYPE3_11N, bMaskDWord); + FalseAlmCnt->Cnt_Rate_Illegal = (ret_value&0xffff); + FalseAlmCnt->Cnt_Crc8_fail = ((ret_value&0xffff0000)>>16); + ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_OFDM_FA_TYPE4_11N, bMaskDWord); + FalseAlmCnt->Cnt_Mcs_fail = (ret_value&0xffff); + + FalseAlmCnt->Cnt_Ofdm_fail = FalseAlmCnt->Cnt_Parity_Fail + FalseAlmCnt->Cnt_Rate_Illegal + + FalseAlmCnt->Cnt_Crc8_fail + FalseAlmCnt->Cnt_Mcs_fail + + FalseAlmCnt->Cnt_Fast_Fsync + FalseAlmCnt->Cnt_SB_Search_fail; + + if (pDM_Odm->SupportICType == ODM_RTL8188E) { + ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_SC_CNT_11N, bMaskDWord); + FalseAlmCnt->Cnt_BW_LSC = (ret_value&0xffff); + FalseAlmCnt->Cnt_BW_USC = ((ret_value&0xffff0000)>>16); + } + + /* hold cck counter */ + ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT12, 1); + ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT14, 1); + + ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_CCK_FA_LSB_11N, bMaskByte0); + FalseAlmCnt->Cnt_Cck_fail = ret_value; + ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_CCK_FA_MSB_11N, bMaskByte3); + FalseAlmCnt->Cnt_Cck_fail += (ret_value & 0xff)<<8; + + ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_CCK_CCA_CNT_11N, bMaskDWord); + FalseAlmCnt->Cnt_CCK_CCA = ((ret_value&0xFF)<<8) | ((ret_value&0xFF00)>>8); + + FalseAlmCnt->Cnt_all = (FalseAlmCnt->Cnt_Fast_Fsync + + FalseAlmCnt->Cnt_SB_Search_fail + + FalseAlmCnt->Cnt_Parity_Fail + + FalseAlmCnt->Cnt_Rate_Illegal + + FalseAlmCnt->Cnt_Crc8_fail + + FalseAlmCnt->Cnt_Mcs_fail + + FalseAlmCnt->Cnt_Cck_fail); + + FalseAlmCnt->Cnt_CCA_all = FalseAlmCnt->Cnt_OFDM_CCA + FalseAlmCnt->Cnt_CCK_CCA; + + if (pDM_Odm->SupportICType >= ODM_RTL8723A) { + /* reset false alarm counter registers */ + ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTC_11N, BIT31, 1); + ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTC_11N, BIT31, 0); + ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTD_11N, BIT27, 1); + ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTD_11N, BIT27, 0); + /* update ofdm counter */ + ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_HOLDC_11N, BIT31, 0); /* update page C counter */ + ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTD_11N, BIT31, 0); /* update page D counter */ + + /* reset CCK CCA counter */ + ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT13|BIT12, 0); + ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT13|BIT12, 2); + /* reset CCK FA counter */ + ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT15|BIT14, 0); + ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT15|BIT14, 2); + } + + ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Enter odm_FalseAlarmCounterStatistics\n")); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, + ("Cnt_Fast_Fsync=%d, Cnt_SB_Search_fail=%d\n", + FalseAlmCnt->Cnt_Fast_Fsync, FalseAlmCnt->Cnt_SB_Search_fail)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, + ("Cnt_Parity_Fail=%d, Cnt_Rate_Illegal=%d\n", + FalseAlmCnt->Cnt_Parity_Fail, FalseAlmCnt->Cnt_Rate_Illegal)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, + ("Cnt_Crc8_fail=%d, Cnt_Mcs_fail=%d\n", + FalseAlmCnt->Cnt_Crc8_fail, FalseAlmCnt->Cnt_Mcs_fail)); + } else { /* FOR ODM_IC_11AC_SERIES */ + /* read OFDM FA counter */ + FalseAlmCnt->Cnt_Ofdm_fail = ODM_GetBBReg(pDM_Odm, ODM_REG_OFDM_FA_11AC, bMaskLWord); + FalseAlmCnt->Cnt_Cck_fail = ODM_GetBBReg(pDM_Odm, ODM_REG_CCK_FA_11AC, bMaskLWord); + FalseAlmCnt->Cnt_all = FalseAlmCnt->Cnt_Ofdm_fail + FalseAlmCnt->Cnt_Cck_fail; + + /* reset OFDM FA coutner */ + ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RST_11AC, BIT17, 1); + ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RST_11AC, BIT17, 0); + /* reset CCK FA counter */ + ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11AC, BIT15, 0); + ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11AC, BIT15, 1); + } + ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Cnt_Cck_fail=%d\n", FalseAlmCnt->Cnt_Cck_fail)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Cnt_Ofdm_fail=%d\n", FalseAlmCnt->Cnt_Ofdm_fail)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Total False Alarm=%d\n", FalseAlmCnt->Cnt_all)); +} + +/* 3============================================================ */ +/* 3 CCK Packet Detect Threshold */ +/* 3============================================================ */ + +void odm_CCKPacketDetectionThresh(struct odm_dm_struct *pDM_Odm) +{ + u8 CurCCK_CCAThres; + struct false_alarm_stats *FalseAlmCnt = &(pDM_Odm->FalseAlmCnt); + + if (!(pDM_Odm->SupportAbility & (ODM_BB_CCK_PD|ODM_BB_FA_CNT))) + return; + if (pDM_Odm->ExtLNA) + return; + if (pDM_Odm->bLinked) { + if (pDM_Odm->RSSI_Min > 25) { + CurCCK_CCAThres = 0xcd; + } else if ((pDM_Odm->RSSI_Min <= 25) && (pDM_Odm->RSSI_Min > 10)) { + CurCCK_CCAThres = 0x83; + } else { + if (FalseAlmCnt->Cnt_Cck_fail > 1000) + CurCCK_CCAThres = 0x83; + else + CurCCK_CCAThres = 0x40; + } + } else { + if (FalseAlmCnt->Cnt_Cck_fail > 1000) + CurCCK_CCAThres = 0x83; + else + CurCCK_CCAThres = 0x40; + } + ODM_Write_CCK_CCA_Thres(pDM_Odm, CurCCK_CCAThres); +} + +void ODM_Write_CCK_CCA_Thres(struct odm_dm_struct *pDM_Odm, u8 CurCCK_CCAThres) +{ + struct rtw_dig *pDM_DigTable = &pDM_Odm->DM_DigTable; + + if (pDM_DigTable->CurCCK_CCAThres != CurCCK_CCAThres) /* modify by Guo.Mingzhi 2012-01-03 */ + ODM_Write1Byte(pDM_Odm, ODM_REG(CCK_CCA, pDM_Odm), CurCCK_CCAThres); + pDM_DigTable->PreCCK_CCAThres = pDM_DigTable->CurCCK_CCAThres; + pDM_DigTable->CurCCK_CCAThres = CurCCK_CCAThres; +} + +/* 3============================================================ */ +/* 3 BB Power Save */ +/* 3============================================================ */ +void odm_DynamicBBPowerSavingInit(struct odm_dm_struct *pDM_Odm) +{ + struct rtl_ps *pDM_PSTable = &pDM_Odm->DM_PSTable; + + pDM_PSTable->PreCCAState = CCA_MAX; + pDM_PSTable->CurCCAState = CCA_MAX; + pDM_PSTable->PreRFState = RF_MAX; + pDM_PSTable->CurRFState = RF_MAX; + pDM_PSTable->Rssi_val_min = 0; + pDM_PSTable->initialize = 0; +} + +void odm_DynamicBBPowerSaving(struct odm_dm_struct *pDM_Odm) +{ + if ((pDM_Odm->SupportICType != ODM_RTL8192C) && (pDM_Odm->SupportICType != ODM_RTL8723A)) + return; + if (!(pDM_Odm->SupportAbility & ODM_BB_PWR_SAVE)) + return; + if (!(pDM_Odm->SupportPlatform & (ODM_MP|ODM_CE))) + return; + + /* 1 2.Power Saving for 92C */ + if ((pDM_Odm->SupportICType == ODM_RTL8192C) && (pDM_Odm->RFType == ODM_2T2R)) { + odm_1R_CCA(pDM_Odm); + } else { + /* 20100628 Joseph: Turn off BB power save for 88CE because it makesthroughput unstable. */ + /* 20100831 Joseph: Turn ON BB power save again after modifying AGC delay from 900ns ot 600ns. */ + /* 1 3.Power Saving for 88C */ + ODM_RF_Saving(pDM_Odm, false); + } +} + +void odm_1R_CCA(struct odm_dm_struct *pDM_Odm) +{ + struct rtl_ps *pDM_PSTable = &pDM_Odm->DM_PSTable; + + if (pDM_Odm->RSSI_Min != 0xFF) { + if (pDM_PSTable->PreCCAState == CCA_2R) { + if (pDM_Odm->RSSI_Min >= 35) + pDM_PSTable->CurCCAState = CCA_1R; + else + pDM_PSTable->CurCCAState = CCA_2R; + } else { + if (pDM_Odm->RSSI_Min <= 30) + pDM_PSTable->CurCCAState = CCA_2R; + else + pDM_PSTable->CurCCAState = CCA_1R; + } + } else { + pDM_PSTable->CurCCAState = CCA_MAX; + } + + if (pDM_PSTable->PreCCAState != pDM_PSTable->CurCCAState) { + if (pDM_PSTable->CurCCAState == CCA_1R) { + if (pDM_Odm->RFType == ODM_2T2R) + ODM_SetBBReg(pDM_Odm, 0xc04, bMaskByte0, 0x13); + else + ODM_SetBBReg(pDM_Odm, 0xc04, bMaskByte0, 0x23); + } else { + ODM_SetBBReg(pDM_Odm, 0xc04, bMaskByte0, 0x33); + } + pDM_PSTable->PreCCAState = pDM_PSTable->CurCCAState; + } +} + +void ODM_RF_Saving(struct odm_dm_struct *pDM_Odm, u8 bForceInNormal) +{ + struct rtl_ps *pDM_PSTable = &pDM_Odm->DM_PSTable; + u8 Rssi_Up_bound = 30; + u8 Rssi_Low_bound = 25; + + if (pDM_Odm->PatchID == 40) { /* RT_CID_819x_FUNAI_TV */ + Rssi_Up_bound = 50; + Rssi_Low_bound = 45; + } + if (pDM_PSTable->initialize == 0) { + pDM_PSTable->Reg874 = (ODM_GetBBReg(pDM_Odm, 0x874, bMaskDWord)&0x1CC000)>>14; + pDM_PSTable->RegC70 = (ODM_GetBBReg(pDM_Odm, 0xc70, bMaskDWord)&BIT3)>>3; + pDM_PSTable->Reg85C = (ODM_GetBBReg(pDM_Odm, 0x85c, bMaskDWord)&0xFF000000)>>24; + pDM_PSTable->RegA74 = (ODM_GetBBReg(pDM_Odm, 0xa74, bMaskDWord)&0xF000)>>12; + pDM_PSTable->initialize = 1; + } + + if (!bForceInNormal) { + if (pDM_Odm->RSSI_Min != 0xFF) { + if (pDM_PSTable->PreRFState == RF_Normal) { + if (pDM_Odm->RSSI_Min >= Rssi_Up_bound) + pDM_PSTable->CurRFState = RF_Save; + else + pDM_PSTable->CurRFState = RF_Normal; + } else { + if (pDM_Odm->RSSI_Min <= Rssi_Low_bound) + pDM_PSTable->CurRFState = RF_Normal; + else + pDM_PSTable->CurRFState = RF_Save; + } + } else { + pDM_PSTable->CurRFState = RF_MAX; + } + } else { + pDM_PSTable->CurRFState = RF_Normal; + } + + if (pDM_PSTable->PreRFState != pDM_PSTable->CurRFState) { + if (pDM_PSTable->CurRFState == RF_Save) { + /* 8723 RSSI report will be wrong. Set 0x874[5]=1 when enter BB power saving mode. */ + /* Suggested by SD3 Yu-Nan. 2011.01.20. */ + if (pDM_Odm->SupportICType == ODM_RTL8723A) + ODM_SetBBReg(pDM_Odm, 0x874 , BIT5, 0x1); /* Reg874[5]=1b'1 */ + ODM_SetBBReg(pDM_Odm, 0x874 , 0x1C0000, 0x2); /* Reg874[20:18]=3'b010 */ + ODM_SetBBReg(pDM_Odm, 0xc70, BIT3, 0); /* RegC70[3]=1'b0 */ + ODM_SetBBReg(pDM_Odm, 0x85c, 0xFF000000, 0x63); /* Reg85C[31:24]=0x63 */ + ODM_SetBBReg(pDM_Odm, 0x874, 0xC000, 0x2); /* Reg874[15:14]=2'b10 */ + ODM_SetBBReg(pDM_Odm, 0xa74, 0xF000, 0x3); /* RegA75[7:4]=0x3 */ + ODM_SetBBReg(pDM_Odm, 0x818, BIT28, 0x0); /* Reg818[28]=1'b0 */ + ODM_SetBBReg(pDM_Odm, 0x818, BIT28, 0x1); /* Reg818[28]=1'b1 */ + } else { + ODM_SetBBReg(pDM_Odm, 0x874 , 0x1CC000, pDM_PSTable->Reg874); + ODM_SetBBReg(pDM_Odm, 0xc70, BIT3, pDM_PSTable->RegC70); + ODM_SetBBReg(pDM_Odm, 0x85c, 0xFF000000, pDM_PSTable->Reg85C); + ODM_SetBBReg(pDM_Odm, 0xa74, 0xF000, pDM_PSTable->RegA74); + ODM_SetBBReg(pDM_Odm, 0x818, BIT28, 0x0); + + if (pDM_Odm->SupportICType == ODM_RTL8723A) + ODM_SetBBReg(pDM_Odm, 0x874, BIT5, 0x0); /* Reg874[5]=1b'0 */ + } + pDM_PSTable->PreRFState = pDM_PSTable->CurRFState; + } +} + +/* 3============================================================ */ +/* 3 RATR MASK */ +/* 3============================================================ */ +/* 3============================================================ */ +/* 3 Rate Adaptive */ +/* 3============================================================ */ + +void odm_RateAdaptiveMaskInit(struct odm_dm_struct *pDM_Odm) +{ + struct odm_rate_adapt *pOdmRA = &pDM_Odm->RateAdaptive; + + pOdmRA->Type = DM_Type_ByDriver; + if (pOdmRA->Type == DM_Type_ByDriver) + pDM_Odm->bUseRAMask = true; + else + pDM_Odm->bUseRAMask = false; + + pOdmRA->RATRState = DM_RATR_STA_INIT; + pOdmRA->HighRSSIThresh = 50; + pOdmRA->LowRSSIThresh = 20; +} + +u32 ODM_Get_Rate_Bitmap(struct odm_dm_struct *pDM_Odm, u32 macid, u32 ra_mask, u8 rssi_level) +{ + struct sta_info *pEntry; + u32 rate_bitmap = 0x0fffffff; + u8 WirelessMode; + + pEntry = pDM_Odm->pODM_StaInfo[macid]; + if (!IS_STA_VALID(pEntry)) + return ra_mask; + + WirelessMode = pEntry->wireless_mode; + + switch (WirelessMode) { + case ODM_WM_B: + if (ra_mask & 0x0000000c) /* 11M or 5.5M enable */ + rate_bitmap = 0x0000000d; + else + rate_bitmap = 0x0000000f; + break; + case (ODM_WM_A|ODM_WM_G): + if (rssi_level == DM_RATR_STA_HIGH) + rate_bitmap = 0x00000f00; + else + rate_bitmap = 0x00000ff0; + break; + case (ODM_WM_B|ODM_WM_G): + if (rssi_level == DM_RATR_STA_HIGH) + rate_bitmap = 0x00000f00; + else if (rssi_level == DM_RATR_STA_MIDDLE) + rate_bitmap = 0x00000ff0; + else + rate_bitmap = 0x00000ff5; + break; + case (ODM_WM_B|ODM_WM_G|ODM_WM_N24G): + case (ODM_WM_A|ODM_WM_B|ODM_WM_G|ODM_WM_N24G): + if (pDM_Odm->RFType == ODM_1T2R || pDM_Odm->RFType == ODM_1T1R) { + if (rssi_level == DM_RATR_STA_HIGH) { + rate_bitmap = 0x000f0000; + } else if (rssi_level == DM_RATR_STA_MIDDLE) { + rate_bitmap = 0x000ff000; + } else { + if (*(pDM_Odm->pBandWidth) == ODM_BW40M) + rate_bitmap = 0x000ff015; + else + rate_bitmap = 0x000ff005; + } + } else { + if (rssi_level == DM_RATR_STA_HIGH) { + rate_bitmap = 0x0f8f0000; + } else if (rssi_level == DM_RATR_STA_MIDDLE) { + rate_bitmap = 0x0f8ff000; + } else { + if (*(pDM_Odm->pBandWidth) == ODM_BW40M) + rate_bitmap = 0x0f8ff015; + else + rate_bitmap = 0x0f8ff005; + } + } + break; + default: + /* case WIRELESS_11_24N: */ + /* case WIRELESS_11_5N: */ + if (pDM_Odm->RFType == RF_1T2R) + rate_bitmap = 0x000fffff; + else + rate_bitmap = 0x0fffffff; + break; + } + + ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, + (" ==> rssi_level:0x%02x, WirelessMode:0x%02x, rate_bitmap:0x%08x\n", + rssi_level, WirelessMode, rate_bitmap)); + + return rate_bitmap; +} + +/*----------------------------------------------------------------------------- + * Function: odm_RefreshRateAdaptiveMask() + * + * Overview: Update rate table mask according to rssi + * + * Input: NONE + * + * Output: NONE + * + * Return: NONE + * + * Revised History: + * When Who Remark + * 05/27/2009 hpfan Create Version 0. + * + *---------------------------------------------------------------------------*/ +void odm_RefreshRateAdaptiveMask(struct odm_dm_struct *pDM_Odm) +{ + if (!(pDM_Odm->SupportAbility & ODM_BB_RA_MASK)) + return; + /* */ + /* 2011/09/29 MH In HW integration first stage, we provide 4 different handle to operate */ + /* at the same time. In the stage2/3, we need to prive universal interface and merge all */ + /* HW dynamic mechanism. */ + /* */ + switch (pDM_Odm->SupportPlatform) { + case ODM_MP: + odm_RefreshRateAdaptiveMaskMP(pDM_Odm); + break; + case ODM_CE: + odm_RefreshRateAdaptiveMaskCE(pDM_Odm); + break; + case ODM_AP: + case ODM_ADSL: + odm_RefreshRateAdaptiveMaskAPADSL(pDM_Odm); + break; + } +} + +void odm_RefreshRateAdaptiveMaskMP(struct odm_dm_struct *pDM_Odm) +{ +} + +void odm_RefreshRateAdaptiveMaskCE(struct odm_dm_struct *pDM_Odm) +{ + u8 i; + struct adapter *pAdapter = pDM_Odm->Adapter; + + if (pAdapter->bDriverStopped) { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_TRACE, ("<---- odm_RefreshRateAdaptiveMask(): driver is going to unload\n")); + return; + } + + if (!pDM_Odm->bUseRAMask) { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, ("<---- odm_RefreshRateAdaptiveMask(): driver does not control rate adaptive mask\n")); + return; + } + + for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) { + struct sta_info *pstat = pDM_Odm->pODM_StaInfo[i]; + if (IS_STA_VALID(pstat)) { + if (ODM_RAStateCheck(pDM_Odm, pstat->rssi_stat.UndecoratedSmoothedPWDB, false , &pstat->rssi_level)) { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, + ("RSSI:%d, RSSI_LEVEL:%d\n", + pstat->rssi_stat.UndecoratedSmoothedPWDB, pstat->rssi_level)); + rtw_hal_update_ra_mask(pAdapter, i, pstat->rssi_level); + } + } + } +} + +void odm_RefreshRateAdaptiveMaskAPADSL(struct odm_dm_struct *pDM_Odm) +{ +} + +/* Return Value: bool */ +/* - true: RATRState is changed. */ +bool ODM_RAStateCheck(struct odm_dm_struct *pDM_Odm, s32 RSSI, bool bForceUpdate, u8 *pRATRState) +{ + struct odm_rate_adapt *pRA = &pDM_Odm->RateAdaptive; + const u8 GoUpGap = 5; + u8 HighRSSIThreshForRA = pRA->HighRSSIThresh; + u8 LowRSSIThreshForRA = pRA->LowRSSIThresh; + u8 RATRState; + + /* Threshold Adjustment: */ + /* when RSSI state trends to go up one or two levels, make sure RSSI is high enough. */ + /* Here GoUpGap is added to solve the boundary's level alternation issue. */ + switch (*pRATRState) { + case DM_RATR_STA_INIT: + case DM_RATR_STA_HIGH: + break; + case DM_RATR_STA_MIDDLE: + HighRSSIThreshForRA += GoUpGap; + break; + case DM_RATR_STA_LOW: + HighRSSIThreshForRA += GoUpGap; + LowRSSIThreshForRA += GoUpGap; + break; + default: + ODM_RT_ASSERT(pDM_Odm, false, ("wrong rssi level setting %d !", *pRATRState)); + break; + } + + /* Decide RATRState by RSSI. */ + if (RSSI > HighRSSIThreshForRA) + RATRState = DM_RATR_STA_HIGH; + else if (RSSI > LowRSSIThreshForRA) + RATRState = DM_RATR_STA_MIDDLE; + else + RATRState = DM_RATR_STA_LOW; + + if (*pRATRState != RATRState || bForceUpdate) { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, ("RSSI Level %d -> %d\n", *pRATRState, RATRState)); + *pRATRState = RATRState; + return true; + } + return false; +} + +/* 3============================================================ */ +/* 3 Dynamic Tx Power */ +/* 3============================================================ */ + +void odm_DynamicTxPowerInit(struct odm_dm_struct *pDM_Odm) +{ + struct adapter *Adapter = pDM_Odm->Adapter; + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + struct dm_priv *pdmpriv = &pHalData->dmpriv; + pdmpriv->bDynamicTxPowerEnable = false; + pdmpriv->LastDTPLvl = TxHighPwrLevel_Normal; + pdmpriv->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal; +} + +void odm_DynamicTxPower(struct odm_dm_struct *pDM_Odm) +{ + /* For AP/ADSL use struct rtl8192cd_priv * */ + /* For CE/NIC use struct adapter * */ + + if (!(pDM_Odm->SupportAbility & ODM_BB_DYNAMIC_TXPWR)) + return; + + /* 2012/01/12 MH According to Luke's suggestion, only high power will support the feature. */ + if (!pDM_Odm->ExtPA) + return; + + /* 2011/09/29 MH In HW integration first stage, we provide 4 different handle to operate */ + /* at the same time. In the stage2/3, we need to prive universal interface and merge all */ + /* HW dynamic mechanism. */ + switch (pDM_Odm->SupportPlatform) { + case ODM_MP: + case ODM_CE: + odm_DynamicTxPowerNIC(pDM_Odm); + break; + case ODM_AP: + odm_DynamicTxPowerAP(pDM_Odm); + break; + case ODM_ADSL: + break; + } +} + +void odm_DynamicTxPowerNIC(struct odm_dm_struct *pDM_Odm) +{ + if (!(pDM_Odm->SupportAbility & ODM_BB_DYNAMIC_TXPWR)) + return; + + if (pDM_Odm->SupportICType == ODM_RTL8188E) { + /* ??? */ + /* This part need to be redefined. */ + } +} + +void odm_DynamicTxPowerAP(struct odm_dm_struct *pDM_Odm) +{ +} + +/* 3============================================================ */ +/* 3 RSSI Monitor */ +/* 3============================================================ */ + +void odm_RSSIMonitorCheck(struct odm_dm_struct *pDM_Odm) +{ + if (!(pDM_Odm->SupportAbility & ODM_BB_RSSI_MONITOR)) + return; + + /* */ + /* 2011/09/29 MH In HW integration first stage, we provide 4 different handle to operate */ + /* at the same time. In the stage2/3, we need to prive universal interface and merge all */ + /* HW dynamic mechanism. */ + /* */ + switch (pDM_Odm->SupportPlatform) { + case ODM_MP: + odm_RSSIMonitorCheckMP(pDM_Odm); + break; + case ODM_CE: + odm_RSSIMonitorCheckCE(pDM_Odm); + break; + case ODM_AP: + odm_RSSIMonitorCheckAP(pDM_Odm); + break; + case ODM_ADSL: + /* odm_DIGAP(pDM_Odm); */ + break; + } + +} /* odm_RSSIMonitorCheck */ + +void odm_RSSIMonitorCheckMP(struct odm_dm_struct *pDM_Odm) +{ +} + +static void FindMinimumRSSI(struct adapter *pAdapter) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); + struct dm_priv *pdmpriv = &pHalData->dmpriv; + struct mlme_priv *pmlmepriv = &pAdapter->mlmepriv; + + /* 1 1.Determine the minimum RSSI */ + if ((check_fwstate(pmlmepriv, _FW_LINKED) == false) && + (pdmpriv->EntryMinUndecoratedSmoothedPWDB == 0)) + pdmpriv->MinUndecoratedPWDBForDM = 0; + if (check_fwstate(pmlmepriv, _FW_LINKED) == true) /* Default port */ + pdmpriv->MinUndecoratedPWDBForDM = pdmpriv->EntryMinUndecoratedSmoothedPWDB; + else /* associated entry pwdb */ + pdmpriv->MinUndecoratedPWDBForDM = pdmpriv->EntryMinUndecoratedSmoothedPWDB; +} + +void odm_RSSIMonitorCheckCE(struct odm_dm_struct *pDM_Odm) +{ + struct adapter *Adapter = pDM_Odm->Adapter; + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + struct dm_priv *pdmpriv = &pHalData->dmpriv; + int i; + int tmpEntryMaxPWDB = 0, tmpEntryMinPWDB = 0xff; + u8 sta_cnt = 0; + u32 PWDB_rssi[NUM_STA] = {0};/* 0~15]:MACID, [16~31]:PWDB_rssi */ + struct sta_info *psta; + u8 bcast_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + + if (!check_fwstate(&Adapter->mlmepriv, _FW_LINKED)) + return; + + for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) { + psta = pDM_Odm->pODM_StaInfo[i]; + if (IS_STA_VALID(psta) && + (psta->state & WIFI_ASOC_STATE) && + !_rtw_memcmp(psta->hwaddr, bcast_addr, ETH_ALEN) && + !_rtw_memcmp(psta->hwaddr, myid(&Adapter->eeprompriv), ETH_ALEN)) { + if (psta->rssi_stat.UndecoratedSmoothedPWDB < tmpEntryMinPWDB) + tmpEntryMinPWDB = psta->rssi_stat.UndecoratedSmoothedPWDB; + + if (psta->rssi_stat.UndecoratedSmoothedPWDB > tmpEntryMaxPWDB) + tmpEntryMaxPWDB = psta->rssi_stat.UndecoratedSmoothedPWDB; + if (psta->rssi_stat.UndecoratedSmoothedPWDB != (-1)) + PWDB_rssi[sta_cnt++] = (psta->mac_id | (psta->rssi_stat.UndecoratedSmoothedPWDB<<16)); + } + } + + for (i = 0; i < sta_cnt; i++) { + if (PWDB_rssi[i] != (0)) { + if (pHalData->fw_ractrl) { + /* Report every sta's RSSI to FW */ + } else { + ODM_RA_SetRSSI_8188E( + &(pHalData->odmpriv), (PWDB_rssi[i]&0xFF), (u8)((PWDB_rssi[i]>>16) & 0xFF)); + } + } + } + + if (tmpEntryMaxPWDB != 0) /* If associated entry is found */ + pdmpriv->EntryMaxUndecoratedSmoothedPWDB = tmpEntryMaxPWDB; + else + pdmpriv->EntryMaxUndecoratedSmoothedPWDB = 0; + + if (tmpEntryMinPWDB != 0xff) /* If associated entry is found */ + pdmpriv->EntryMinUndecoratedSmoothedPWDB = tmpEntryMinPWDB; + else + pdmpriv->EntryMinUndecoratedSmoothedPWDB = 0; + + FindMinimumRSSI(Adapter); + ODM_CmnInfoUpdate(&pHalData->odmpriv , ODM_CMNINFO_RSSI_MIN, pdmpriv->MinUndecoratedPWDBForDM); +} + +void odm_RSSIMonitorCheckAP(struct odm_dm_struct *pDM_Odm) +{ +} + +void ODM_InitAllTimers(struct odm_dm_struct *pDM_Odm) +{ + ODM_InitializeTimer(pDM_Odm, &pDM_Odm->DM_SWAT_Table.SwAntennaSwitchTimer, + (void *)odm_SwAntDivChkAntSwitchCallback, NULL, "SwAntennaSwitchTimer"); +} + +void ODM_CancelAllTimers(struct odm_dm_struct *pDM_Odm) +{ + ODM_CancelTimer(pDM_Odm, &pDM_Odm->DM_SWAT_Table.SwAntennaSwitchTimer); +} + +void ODM_ReleaseAllTimers(struct odm_dm_struct *pDM_Odm) +{ + ODM_ReleaseTimer(pDM_Odm, &pDM_Odm->DM_SWAT_Table.SwAntennaSwitchTimer); + + ODM_ReleaseTimer(pDM_Odm, &pDM_Odm->FastAntTrainingTimer); +} + +/* 3============================================================ */ +/* 3 Tx Power Tracking */ +/* 3============================================================ */ + +void odm_TXPowerTrackingInit(struct odm_dm_struct *pDM_Odm) +{ + odm_TXPowerTrackingThermalMeterInit(pDM_Odm); +} + +void odm_TXPowerTrackingThermalMeterInit(struct odm_dm_struct *pDM_Odm) +{ + pDM_Odm->RFCalibrateInfo.bTXPowerTracking = true; + pDM_Odm->RFCalibrateInfo.TXPowercount = 0; + pDM_Odm->RFCalibrateInfo.bTXPowerTrackingInit = false; + if (*(pDM_Odm->mp_mode) != 1) + pDM_Odm->RFCalibrateInfo.TxPowerTrackControl = true; + MSG_88E("pDM_Odm TxPowerTrackControl = %d\n", pDM_Odm->RFCalibrateInfo.TxPowerTrackControl); + + pDM_Odm->RFCalibrateInfo.TxPowerTrackControl = true; +} + +void ODM_TXPowerTrackingCheck(struct odm_dm_struct *pDM_Odm) +{ + /* 2011/09/29 MH In HW integration first stage, we provide 4 different handle to operate */ + /* at the same time. In the stage2/3, we need to prive universal interface and merge all */ + /* HW dynamic mechanism. */ + switch (pDM_Odm->SupportPlatform) { + case ODM_MP: + odm_TXPowerTrackingCheckMP(pDM_Odm); + break; + case ODM_CE: + odm_TXPowerTrackingCheckCE(pDM_Odm); + break; + case ODM_AP: + odm_TXPowerTrackingCheckAP(pDM_Odm); + break; + case ODM_ADSL: + break; + } +} + +void odm_TXPowerTrackingCheckCE(struct odm_dm_struct *pDM_Odm) +{ + struct adapter *Adapter = pDM_Odm->Adapter; + + if (!(pDM_Odm->SupportAbility & ODM_RF_TX_PWR_TRACK)) + return; + + if (!pDM_Odm->RFCalibrateInfo.TM_Trigger) { /* at least delay 1 sec */ + PHY_SetRFReg(Adapter, RF_PATH_A, RF_T_METER_88E, BIT17 | BIT16, 0x03); + + pDM_Odm->RFCalibrateInfo.TM_Trigger = 1; + return; + } else { + odm_TXPowerTrackingCallback_ThermalMeter_8188E(Adapter); + pDM_Odm->RFCalibrateInfo.TM_Trigger = 0; + } +} + +void odm_TXPowerTrackingCheckMP(struct odm_dm_struct *pDM_Odm) +{ +} + +void odm_TXPowerTrackingCheckAP(struct odm_dm_struct *pDM_Odm) +{ +} + +/* antenna mapping info */ +/* 1: right-side antenna */ +/* 2/0: left-side antenna */ +/* PDM_SWAT_Table->CCK_Ant1_Cnt /OFDM_Ant1_Cnt: for right-side antenna: Ant:1 RxDefaultAnt1 */ +/* PDM_SWAT_Table->CCK_Ant2_Cnt /OFDM_Ant2_Cnt: for left-side antenna: Ant:0 RxDefaultAnt2 */ +/* We select left antenna as default antenna in initial process, modify it as needed */ +/* */ + +/* 3============================================================ */ +/* 3 SW Antenna Diversity */ +/* 3============================================================ */ +void odm_SwAntDivInit(struct odm_dm_struct *pDM_Odm) +{ +} + +void ODM_SwAntDivChkPerPktRssi(struct odm_dm_struct *pDM_Odm, u8 StationID, struct odm_phy_status_info *pPhyInfo) +{ +} + +void odm_SwAntDivChkAntSwitch(struct odm_dm_struct *pDM_Odm, u8 Step) +{ +} + +void ODM_SwAntDivRestAfterLink(struct odm_dm_struct *pDM_Odm) +{ +} + +void odm_SwAntDivChkAntSwitchCallback(void *FunctionContext) +{ +} + +/* 3============================================================ */ +/* 3 SW Antenna Diversity */ +/* 3============================================================ */ + +void odm_InitHybridAntDiv(struct odm_dm_struct *pDM_Odm) +{ + if (!(pDM_Odm->SupportAbility & ODM_BB_ANT_DIV)) { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Return: Not Support HW AntDiv\n")); + return; + } + + if (pDM_Odm->SupportICType & (ODM_RTL8192C | ODM_RTL8192D)) + ; + else if (pDM_Odm->SupportICType == ODM_RTL8188E) + ODM_AntennaDiversityInit_88E(pDM_Odm); +} + +void ODM_AntselStatistics_88C(struct odm_dm_struct *pDM_Odm, u8 MacId, u32 PWDBAll, bool isCCKrate) +{ + struct sw_ant_switch *pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table; + + if (pDM_SWAT_Table->antsel == 1) { + if (isCCKrate) { + pDM_SWAT_Table->CCK_Ant1_Cnt[MacId]++; + } else { + pDM_SWAT_Table->OFDM_Ant1_Cnt[MacId]++; + pDM_SWAT_Table->RSSI_Ant1_Sum[MacId] += PWDBAll; + } + } else { + if (isCCKrate) { + pDM_SWAT_Table->CCK_Ant2_Cnt[MacId]++; + } else { + pDM_SWAT_Table->OFDM_Ant2_Cnt[MacId]++; + pDM_SWAT_Table->RSSI_Ant2_Sum[MacId] += PWDBAll; + } + } +} + +void odm_HwAntDiv(struct odm_dm_struct *pDM_Odm) +{ + if (!(pDM_Odm->SupportAbility & ODM_BB_ANT_DIV)) { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Return: Not Support HW AntDiv\n")); + return; + } + + if (pDM_Odm->SupportICType == ODM_RTL8188E) + ODM_AntennaDiversity_88E(pDM_Odm); +} + +/* EDCA Turbo */ +void ODM_EdcaTurboInit(struct odm_dm_struct *pDM_Odm) +{ + struct adapter *Adapter = pDM_Odm->Adapter; + pDM_Odm->DM_EDCA_Table.bCurrentTurboEDCA = false; + pDM_Odm->DM_EDCA_Table.bIsCurRDLState = false; + Adapter->recvpriv.bIsAnyNonBEPkts = false; + + ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("Orginial VO PARAM: 0x%x\n", ODM_Read4Byte(pDM_Odm, ODM_EDCA_VO_PARAM))); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("Orginial VI PARAM: 0x%x\n", ODM_Read4Byte(pDM_Odm, ODM_EDCA_VI_PARAM))); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("Orginial BE PARAM: 0x%x\n", ODM_Read4Byte(pDM_Odm, ODM_EDCA_BE_PARAM))); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("Orginial BK PARAM: 0x%x\n", ODM_Read4Byte(pDM_Odm, ODM_EDCA_BK_PARAM))); +} /* ODM_InitEdcaTurbo */ + +void odm_EdcaTurboCheck(struct odm_dm_struct *pDM_Odm) +{ + /* 2011/09/29 MH In HW integration first stage, we provide 4 different handle to operate */ + /* at the same time. In the stage2/3, we need to prive universal interface and merge all */ + /* HW dynamic mechanism. */ + ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("odm_EdcaTurboCheck========================>\n")); + + if (!(pDM_Odm->SupportAbility & ODM_MAC_EDCA_TURBO)) + return; + + switch (pDM_Odm->SupportPlatform) { + case ODM_MP: + break; + case ODM_CE: + odm_EdcaTurboCheckCE(pDM_Odm); + break; + case ODM_AP: + case ODM_ADSL: + break; + } + ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("<========================odm_EdcaTurboCheck\n")); +} /* odm_CheckEdcaTurbo */ + +void odm_EdcaTurboCheckCE(struct odm_dm_struct *pDM_Odm) +{ + struct adapter *Adapter = pDM_Odm->Adapter; + u32 trafficIndex; + u32 edca_param; + u64 cur_tx_bytes = 0; + u64 cur_rx_bytes = 0; + u8 bbtchange = false; + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + struct xmit_priv *pxmitpriv = &(Adapter->xmitpriv); + struct recv_priv *precvpriv = &(Adapter->recvpriv); + struct registry_priv *pregpriv = &Adapter->registrypriv; + struct mlme_ext_priv *pmlmeext = &(Adapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + if ((pregpriv->wifi_spec == 1))/* (pmlmeinfo->HT_enable == 0)) */ + goto dm_CheckEdcaTurbo_EXIT; + + if (pmlmeinfo->assoc_AP_vendor >= HT_IOT_PEER_MAX) + goto dm_CheckEdcaTurbo_EXIT; + + /* Check if the status needs to be changed. */ + if ((bbtchange) || (!precvpriv->bIsAnyNonBEPkts)) { + cur_tx_bytes = pxmitpriv->tx_bytes - pxmitpriv->last_tx_bytes; + cur_rx_bytes = precvpriv->rx_bytes - precvpriv->last_rx_bytes; + + /* traffic, TX or RX */ + if ((pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_RALINK) || + (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_ATHEROS)) { + if (cur_tx_bytes > (cur_rx_bytes << 2)) { + /* Uplink TP is present. */ + trafficIndex = UP_LINK; + } else { + /* Balance TP is present. */ + trafficIndex = DOWN_LINK; + } + } else { + if (cur_rx_bytes > (cur_tx_bytes << 2)) { + /* Downlink TP is present. */ + trafficIndex = DOWN_LINK; + } else { + /* Balance TP is present. */ + trafficIndex = UP_LINK; + } + } + + if ((pDM_Odm->DM_EDCA_Table.prv_traffic_idx != trafficIndex) || (!pDM_Odm->DM_EDCA_Table.bCurrentTurboEDCA)) { + if ((pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_CISCO) && (pmlmeext->cur_wireless_mode & WIRELESS_11_24N)) + edca_param = EDCAParam[pmlmeinfo->assoc_AP_vendor][trafficIndex]; + else + edca_param = EDCAParam[HT_IOT_PEER_UNKNOWN][trafficIndex]; + + rtw_write32(Adapter, REG_EDCA_BE_PARAM, edca_param); + + pDM_Odm->DM_EDCA_Table.prv_traffic_idx = trafficIndex; + } + + pDM_Odm->DM_EDCA_Table.bCurrentTurboEDCA = true; + } else { + /* Turn Off EDCA turbo here. */ + /* Restore original EDCA according to the declaration of AP. */ + if (pDM_Odm->DM_EDCA_Table.bCurrentTurboEDCA) { + rtw_write32(Adapter, REG_EDCA_BE_PARAM, pHalData->AcParam_BE); + pDM_Odm->DM_EDCA_Table.bCurrentTurboEDCA = false; + } + } + +dm_CheckEdcaTurbo_EXIT: + /* Set variables for next time. */ + precvpriv->bIsAnyNonBEPkts = false; + pxmitpriv->last_tx_bytes = pxmitpriv->tx_bytes; + precvpriv->last_rx_bytes = precvpriv->rx_bytes; +} + +/* need to ODM CE Platform */ +/* move to here for ANT detection mechanism using */ + +u32 GetPSDData(struct odm_dm_struct *pDM_Odm, unsigned int point, u8 initial_gain_psd) +{ + u32 psd_report; + + /* Set DCO frequency index, offset=(40MHz/SamplePts)*point */ + ODM_SetBBReg(pDM_Odm, 0x808, 0x3FF, point); + + /* Start PSD calculation, Reg808[22]=0->1 */ + ODM_SetBBReg(pDM_Odm, 0x808, BIT22, 1); + /* Need to wait for HW PSD report */ + ODM_StallExecution(30); + ODM_SetBBReg(pDM_Odm, 0x808, BIT22, 0); + /* Read PSD report, Reg8B4[15:0] */ + psd_report = ODM_GetBBReg(pDM_Odm, 0x8B4, bMaskDWord) & 0x0000FFFF; + + psd_report = (u32) (ConvertTo_dB(psd_report))+(u32)(initial_gain_psd-0x1c); + + return psd_report; +} + +u32 ConvertTo_dB(u32 Value) +{ + u8 i; + u8 j; + u32 dB; + + Value = Value & 0xFFFF; + for (i = 0; i < 8; i++) { + if (Value <= dB_Invert_Table[i][11]) + break; + } + + if (i >= 8) + return 96; /* maximum 96 dB */ + + for (j = 0; j < 12; j++) { + if (Value <= dB_Invert_Table[i][j]) + break; + } + + dB = i*12 + j + 1; + + return dB; +} + +/* 2011/09/22 MH Add for 92D global spin lock utilization. */ +void odm_GlobalAdapterCheck(void) +{ +} /* odm_GlobalAdapterCheck */ + +/* Description: */ +/* Set Single/Dual Antenna default setting for products that do not do detection in advance. */ +/* Added by Joseph, 2012.03.22 */ +void ODM_SingleDualAntennaDefaultSetting(struct odm_dm_struct *pDM_Odm) +{ + struct sw_ant_switch *pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table; + + pDM_SWAT_Table->ANTA_ON = true; + pDM_SWAT_Table->ANTB_ON = true; +} + + +/* 2 8723A ANT DETECT */ + +static void odm_PHY_SaveAFERegisters(struct odm_dm_struct *pDM_Odm, u32 *AFEReg, u32 *AFEBackup, u32 RegisterNum) +{ + u32 i; + + /* RTPRINT(FINIT, INIT_IQK, ("Save ADDA parameters.\n")); */ + for (i = 0; i < RegisterNum; i++) + AFEBackup[i] = ODM_GetBBReg(pDM_Odm, AFEReg[i], bMaskDWord); +} + +static void odm_PHY_ReloadAFERegisters(struct odm_dm_struct *pDM_Odm, u32 *AFEReg, u32 *AFEBackup, u32 RegiesterNum) +{ + u32 i; + + for (i = 0; i < RegiesterNum; i++) + ODM_SetBBReg(pDM_Odm, AFEReg[i], bMaskDWord, AFEBackup[i]); +} + +/* 2 8723A ANT DETECT */ +/* Description: */ +/* Implement IQK single tone for RF DPK loopback and BB PSD scanning. */ +/* This function is cooperated with BB team Neil. */ +bool ODM_SingleDualAntennaDetection(struct odm_dm_struct *pDM_Odm, u8 mode) +{ + struct sw_ant_switch *pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table; + u32 CurrentChannel, RfLoopReg; + u8 n; + u32 Reg88c, Regc08, Reg874, Regc50; + u8 initial_gain = 0x5a; + u32 PSD_report_tmp; + u32 AntA_report = 0x0, AntB_report = 0x0, AntO_report = 0x0; + bool bResult = true; + u32 AFE_Backup[16]; + u32 AFE_REG_8723A[16] = { + rRx_Wait_CCA, rTx_CCK_RFON, + rTx_CCK_BBON, rTx_OFDM_RFON, + rTx_OFDM_BBON, rTx_To_Rx, + rTx_To_Tx, rRx_CCK, + rRx_OFDM, rRx_Wait_RIFS, + rRx_TO_Rx, rStandby, + rSleep, rPMPD_ANAEN, + rFPGA0_XCD_SwitchControl, rBlue_Tooth}; + + if (!(pDM_Odm->SupportICType & (ODM_RTL8723A|ODM_RTL8192C))) + return bResult; + + if (!(pDM_Odm->SupportAbility&ODM_BB_ANT_DIV)) + return bResult; + + if (pDM_Odm->SupportICType == ODM_RTL8192C) { + /* Which path in ADC/DAC is turnned on for PSD: both I/Q */ + ODM_SetBBReg(pDM_Odm, 0x808, BIT10|BIT11, 0x3); + /* Ageraged number: 8 */ + ODM_SetBBReg(pDM_Odm, 0x808, BIT12|BIT13, 0x1); + /* pts = 128; */ + ODM_SetBBReg(pDM_Odm, 0x808, BIT14|BIT15, 0x0); + } + + /* 1 Backup Current RF/BB Settings */ + + CurrentChannel = ODM_GetRFReg(pDM_Odm, RF_PATH_A, ODM_CHANNEL, bRFRegOffsetMask); + RfLoopReg = ODM_GetRFReg(pDM_Odm, RF_PATH_A, 0x00, bRFRegOffsetMask); + ODM_SetBBReg(pDM_Odm, rFPGA0_XA_RFInterfaceOE, ODM_DPDT, Antenna_A); /* change to Antenna A */ + /* Step 1: USE IQK to transmitter single tone */ + + ODM_StallExecution(10); + + /* Store A Path Register 88c, c08, 874, c50 */ + Reg88c = ODM_GetBBReg(pDM_Odm, rFPGA0_AnalogParameter4, bMaskDWord); + Regc08 = ODM_GetBBReg(pDM_Odm, rOFDM0_TRMuxPar, bMaskDWord); + Reg874 = ODM_GetBBReg(pDM_Odm, rFPGA0_XCD_RFInterfaceSW, bMaskDWord); + Regc50 = ODM_GetBBReg(pDM_Odm, rOFDM0_XAAGCCore1, bMaskDWord); + + /* Store AFE Registers */ + odm_PHY_SaveAFERegisters(pDM_Odm, AFE_REG_8723A, AFE_Backup, 16); + + /* Set PSD 128 pts */ + ODM_SetBBReg(pDM_Odm, rFPGA0_PSDFunction, BIT14|BIT15, 0x0); /* 128 pts */ + + /* To SET CH1 to do */ + ODM_SetRFReg(pDM_Odm, RF_PATH_A, ODM_CHANNEL, bRFRegOffsetMask, 0x01); /* Channel 1 */ + + /* AFE all on step */ + ODM_SetBBReg(pDM_Odm, rRx_Wait_CCA, bMaskDWord, 0x6FDB25A4); + ODM_SetBBReg(pDM_Odm, rTx_CCK_RFON, bMaskDWord, 0x6FDB25A4); + ODM_SetBBReg(pDM_Odm, rTx_CCK_BBON, bMaskDWord, 0x6FDB25A4); + ODM_SetBBReg(pDM_Odm, rTx_OFDM_RFON, bMaskDWord, 0x6FDB25A4); + ODM_SetBBReg(pDM_Odm, rTx_OFDM_BBON, bMaskDWord, 0x6FDB25A4); + ODM_SetBBReg(pDM_Odm, rTx_To_Rx, bMaskDWord, 0x6FDB25A4); + ODM_SetBBReg(pDM_Odm, rTx_To_Tx, bMaskDWord, 0x6FDB25A4); + ODM_SetBBReg(pDM_Odm, rRx_CCK, bMaskDWord, 0x6FDB25A4); + ODM_SetBBReg(pDM_Odm, rRx_OFDM, bMaskDWord, 0x6FDB25A4); + ODM_SetBBReg(pDM_Odm, rRx_Wait_RIFS, bMaskDWord, 0x6FDB25A4); + ODM_SetBBReg(pDM_Odm, rRx_TO_Rx, bMaskDWord, 0x6FDB25A4); + ODM_SetBBReg(pDM_Odm, rStandby, bMaskDWord, 0x6FDB25A4); + ODM_SetBBReg(pDM_Odm, rSleep, bMaskDWord, 0x6FDB25A4); + ODM_SetBBReg(pDM_Odm, rPMPD_ANAEN, bMaskDWord, 0x6FDB25A4); + ODM_SetBBReg(pDM_Odm, rFPGA0_XCD_SwitchControl, bMaskDWord, 0x6FDB25A4); + ODM_SetBBReg(pDM_Odm, rBlue_Tooth, bMaskDWord, 0x6FDB25A4); + + /* 3 wire Disable */ + ODM_SetBBReg(pDM_Odm, rFPGA0_AnalogParameter4, bMaskDWord, 0xCCF000C0); + + /* BB IQK Setting */ + ODM_SetBBReg(pDM_Odm, rOFDM0_TRMuxPar, bMaskDWord, 0x000800E4); + ODM_SetBBReg(pDM_Odm, rFPGA0_XCD_RFInterfaceSW, bMaskDWord, 0x22208000); + + /* IQK setting tone@ 4.34Mhz */ + ODM_SetBBReg(pDM_Odm, rTx_IQK_Tone_A, bMaskDWord, 0x10008C1C); + ODM_SetBBReg(pDM_Odm, rTx_IQK, bMaskDWord, 0x01007c00); + + + /* Page B init */ + ODM_SetBBReg(pDM_Odm, rConfig_AntA, bMaskDWord, 0x00080000); + ODM_SetBBReg(pDM_Odm, rConfig_AntA, bMaskDWord, 0x0f600000); + ODM_SetBBReg(pDM_Odm, rRx_IQK, bMaskDWord, 0x01004800); + ODM_SetBBReg(pDM_Odm, rRx_IQK_Tone_A, bMaskDWord, 0x10008c1f); + ODM_SetBBReg(pDM_Odm, rTx_IQK_PI_A, bMaskDWord, 0x82150008); + ODM_SetBBReg(pDM_Odm, rRx_IQK_PI_A, bMaskDWord, 0x28150008); + ODM_SetBBReg(pDM_Odm, rIQK_AGC_Rsp, bMaskDWord, 0x001028d0); + + /* RF loop Setting */ + ODM_SetRFReg(pDM_Odm, RF_PATH_A, 0x0, 0xFFFFF, 0x50008); + + /* IQK Single tone start */ + ODM_SetBBReg(pDM_Odm, rFPGA0_IQK, bMaskDWord, 0x80800000); + ODM_SetBBReg(pDM_Odm, rIQK_AGC_Pts, bMaskDWord, 0xf8000000); + ODM_StallExecution(1000); + PSD_report_tmp = 0x0; + + for (n = 0; n < 2; n++) { + PSD_report_tmp = GetPSDData(pDM_Odm, 14, initial_gain); + if (PSD_report_tmp > AntA_report) + AntA_report = PSD_report_tmp; + } + + PSD_report_tmp = 0x0; + + ODM_SetBBReg(pDM_Odm, rFPGA0_XA_RFInterfaceOE, 0x300, Antenna_B); /* change to Antenna B */ + ODM_StallExecution(10); + + + for (n = 0; n < 2; n++) { + PSD_report_tmp = GetPSDData(pDM_Odm, 14, initial_gain); + if (PSD_report_tmp > AntB_report) + AntB_report = PSD_report_tmp; + } + + /* change to open case */ + ODM_SetBBReg(pDM_Odm, rFPGA0_XA_RFInterfaceOE, 0x300, 0); /* change to Ant A and B all open case */ + ODM_StallExecution(10); + + for (n = 0; n < 2; n++) { + PSD_report_tmp = GetPSDData(pDM_Odm, 14, initial_gain); + if (PSD_report_tmp > AntO_report) + AntO_report = PSD_report_tmp; + } + + /* Close IQK Single Tone function */ + ODM_SetBBReg(pDM_Odm, rFPGA0_IQK, bMaskDWord, 0x00000000); + PSD_report_tmp = 0x0; + + /* 1 Return to antanna A */ + ODM_SetBBReg(pDM_Odm, rFPGA0_XA_RFInterfaceOE, 0x300, Antenna_A); + ODM_SetBBReg(pDM_Odm, rFPGA0_AnalogParameter4, bMaskDWord, Reg88c); + ODM_SetBBReg(pDM_Odm, rOFDM0_TRMuxPar, bMaskDWord, Regc08); + ODM_SetBBReg(pDM_Odm, rFPGA0_XCD_RFInterfaceSW, bMaskDWord, Reg874); + ODM_SetBBReg(pDM_Odm, rOFDM0_XAAGCCore1, 0x7F, 0x40); + ODM_SetBBReg(pDM_Odm, rOFDM0_XAAGCCore1, bMaskDWord, Regc50); + ODM_SetRFReg(pDM_Odm, RF_PATH_A, RF_CHNLBW, bRFRegOffsetMask, CurrentChannel); + ODM_SetRFReg(pDM_Odm, RF_PATH_A, 0x00, bRFRegOffsetMask, RfLoopReg); + + /* Reload AFE Registers */ + odm_PHY_ReloadAFERegisters(pDM_Odm, AFE_REG_8723A, AFE_Backup, 16); + + ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("psd_report_A[%d]= %d\n", 2416, AntA_report)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("psd_report_B[%d]= %d\n", 2416, AntB_report)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("psd_report_O[%d]= %d\n", 2416, AntO_report)); + + + if (pDM_Odm->SupportICType == ODM_RTL8723A) { + /* 2 Test Ant B based on Ant A is ON */ + if (mode == ANTTESTB) { + if (AntA_report >= 100) { + if (AntB_report > (AntA_report+1)) { + pDM_SWAT_Table->ANTB_ON = false; + ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("ODM_SingleDualAntennaDetection(): Single Antenna A\n")); + } else { + pDM_SWAT_Table->ANTB_ON = true; + ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("ODM_SingleDualAntennaDetection(): Dual Antenna is A and B\n")); + } + } else { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("ODM_SingleDualAntennaDetection(): Need to check again\n")); + pDM_SWAT_Table->ANTB_ON = false; /* Set Antenna B off as default */ + bResult = false; + } + } else if (mode == ANTTESTALL) { + /* 2 Test Ant A and B based on DPDT Open */ + if ((AntO_report >= 100)&(AntO_report < 118)) { + if (AntA_report > (AntO_report+1)) { + pDM_SWAT_Table->ANTA_ON = false; + ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Ant A is OFF")); + } else { + pDM_SWAT_Table->ANTA_ON = true; + ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Ant A is ON")); + } + + if (AntB_report > (AntO_report+2)) { + pDM_SWAT_Table->ANTB_ON = false; + ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Ant B is OFF")); + } else { + pDM_SWAT_Table->ANTB_ON = true; + ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Ant B is ON")); + } + } + } + } else if (pDM_Odm->SupportICType == ODM_RTL8192C) { + if (AntA_report >= 100) { + if (AntB_report > (AntA_report+2)) { + pDM_SWAT_Table->ANTA_ON = false; + pDM_SWAT_Table->ANTB_ON = true; + ODM_SetBBReg(pDM_Odm, rFPGA0_XA_RFInterfaceOE, 0x300, Antenna_B); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("ODM_SingleDualAntennaDetection(): Single Antenna B\n")); + } else if (AntA_report > (AntB_report+2)) { + pDM_SWAT_Table->ANTA_ON = true; + pDM_SWAT_Table->ANTB_ON = false; + ODM_SetBBReg(pDM_Odm, rFPGA0_XA_RFInterfaceOE, 0x300, Antenna_A); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("ODM_SingleDualAntennaDetection(): Single Antenna A\n")); + } else { + pDM_SWAT_Table->ANTA_ON = true; + pDM_SWAT_Table->ANTB_ON = true; + ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, + ("ODM_SingleDualAntennaDetection(): Dual Antenna\n")); + } + } else { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("ODM_SingleDualAntennaDetection(): Need to check again\n")); + pDM_SWAT_Table->ANTA_ON = true; /* Set Antenna A on as default */ + pDM_SWAT_Table->ANTB_ON = false; /* Set Antenna B off as default */ + bResult = false; + } + } + return bResult; +} + +/* Justin: According to the current RRSI to adjust Response Frame TX power, 2012/11/05 */ +void odm_dtc(struct odm_dm_struct *pDM_Odm) +{ +} diff --git a/drivers/staging/rtl8188eu/hal/odm_debug.c b/drivers/staging/rtl8188eu/hal/odm_debug.c new file mode 100644 index 0000000000000..84caadd6c8e58 --- /dev/null +++ b/drivers/staging/rtl8188eu/hal/odm_debug.c @@ -0,0 +1,32 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +/* include files */ + +#include "odm_precomp.h" + +void ODM_InitDebugSetting(struct odm_dm_struct *pDM_Odm) +{ + pDM_Odm->DebugLevel = ODM_DBG_TRACE; + + pDM_Odm->DebugComponents = 0; +} + +u32 GlobalDebugLevel; -- GitLab From 6c984c81fe27106da26652ad2142b6a03ec78058 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 21 Aug 2013 22:33:54 -0500 Subject: [PATCH 770/942] staging: r8188eu: Add files for new driver - part 12 This commit adds files odm_HWConfig.c and odm_interface.c. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/odm_HWConfig.c | 596 ++++++++++++++++++ drivers/staging/rtl8188eu/hal/odm_interface.c | 203 ++++++ 2 files changed, 799 insertions(+) create mode 100644 drivers/staging/rtl8188eu/hal/odm_HWConfig.c create mode 100644 drivers/staging/rtl8188eu/hal/odm_interface.c diff --git a/drivers/staging/rtl8188eu/hal/odm_HWConfig.c b/drivers/staging/rtl8188eu/hal/odm_HWConfig.c new file mode 100644 index 0000000000000..19c509a2bebf7 --- /dev/null +++ b/drivers/staging/rtl8188eu/hal/odm_HWConfig.c @@ -0,0 +1,596 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +/* include files */ + +#include "odm_precomp.h" + +#define READ_AND_CONFIG READ_AND_CONFIG_MP + +#define READ_AND_CONFIG_MP(ic, txt) (ODM_ReadAndConfig##txt##ic(dm_odm)) +#define READ_AND_CONFIG_TC(ic, txt) (ODM_ReadAndConfig_TC##txt##ic(dm_odm)) + +static u8 odm_QueryRxPwrPercentage(s8 AntPower) +{ + if ((AntPower <= -100) || (AntPower >= 20)) + return 0; + else if (AntPower >= 0) + return 100; + else + return 100+AntPower; +} + +/* 2012/01/12 MH MOve some signal strength smooth method to MP HAL layer. */ +/* IF other SW team do not support the feature, remove this section.?? */ +static s32 odm_sig_patch_lenove(struct odm_dm_struct *dm_odm, s32 CurrSig) +{ + return 0; +} + +static s32 odm_sig_patch_netcore(struct odm_dm_struct *dm_odm, s32 CurrSig) +{ + return 0; +} + +static s32 odm_SignalScaleMapping_92CSeries(struct odm_dm_struct *dm_odm, s32 CurrSig) +{ + s32 RetSig = 0; + + if ((dm_odm->SupportInterface == ODM_ITRF_USB) || + (dm_odm->SupportInterface == ODM_ITRF_SDIO)) { + if (CurrSig >= 51 && CurrSig <= 100) + RetSig = 100; + else if (CurrSig >= 41 && CurrSig <= 50) + RetSig = 80 + ((CurrSig - 40)*2); + else if (CurrSig >= 31 && CurrSig <= 40) + RetSig = 66 + (CurrSig - 30); + else if (CurrSig >= 21 && CurrSig <= 30) + RetSig = 54 + (CurrSig - 20); + else if (CurrSig >= 10 && CurrSig <= 20) + RetSig = 42 + (((CurrSig - 10) * 2) / 3); + else if (CurrSig >= 5 && CurrSig <= 9) + RetSig = 22 + (((CurrSig - 5) * 3) / 2); + else if (CurrSig >= 1 && CurrSig <= 4) + RetSig = 6 + (((CurrSig - 1) * 3) / 2); + else + RetSig = CurrSig; + } + return RetSig; +} + +static s32 odm_SignalScaleMapping(struct odm_dm_struct *dm_odm, s32 CurrSig) +{ + if ((dm_odm->SupportPlatform == ODM_MP) && + (dm_odm->SupportInterface != ODM_ITRF_PCIE) && /* USB & SDIO */ + (dm_odm->PatchID == 10)) + return odm_sig_patch_netcore(dm_odm, CurrSig); + else if ((dm_odm->SupportPlatform == ODM_MP) && + (dm_odm->SupportInterface == ODM_ITRF_PCIE) && + (dm_odm->PatchID == 19)) + return odm_sig_patch_lenove(dm_odm, CurrSig); + else + return odm_SignalScaleMapping_92CSeries(dm_odm, CurrSig); +} + +/* pMgntInfo->CustomerID == RT_CID_819x_Lenovo */ +static u8 odm_SQ_process_patch_RT_CID_819x_Lenovo(struct odm_dm_struct *dm_odm, + u8 isCCKrate, u8 PWDB_ALL, u8 path, u8 RSSI) +{ + return 0; +} + +static u8 odm_EVMdbToPercentage(s8 Value) +{ + /* -33dB~0dB to 0%~99% */ + s8 ret_val; + + ret_val = Value; + + if (ret_val >= 0) + ret_val = 0; + if (ret_val <= -33) + ret_val = -33; + + ret_val = 0 - ret_val; + ret_val *= 3; + + if (ret_val == 99) + ret_val = 100; + return ret_val; +} + +static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm, + struct odm_phy_status_info *pPhyInfo, + u8 *pPhyStatus, + struct odm_per_pkt_info *pPktinfo) +{ + struct sw_ant_switch *pDM_SWAT_Table = &dm_odm->DM_SWAT_Table; + u8 i, Max_spatial_stream; + s8 rx_pwr[4], rx_pwr_all = 0; + u8 EVM, PWDB_ALL = 0, PWDB_ALL_BT; + u8 RSSI, total_rssi = 0; + u8 isCCKrate = 0; + u8 rf_rx_num = 0; + u8 cck_highpwr = 0; + u8 LNA_idx, VGA_idx; + + struct phy_status_rpt *pPhyStaRpt = (struct phy_status_rpt *)pPhyStatus; + + isCCKrate = ((pPktinfo->Rate >= DESC92C_RATE1M) && (pPktinfo->Rate <= DESC92C_RATE11M)) ? true : false; + + pPhyInfo->RxMIMOSignalQuality[ODM_RF_PATH_A] = -1; + pPhyInfo->RxMIMOSignalQuality[ODM_RF_PATH_B] = -1; + + if (isCCKrate) { + u8 report; + u8 cck_agc_rpt; + + dm_odm->PhyDbgInfo.NumQryPhyStatusCCK++; + /* (1)Hardware does not provide RSSI for CCK */ + /* (2)PWDB, Average PWDB cacluated by hardware (for rate adaptive) */ + + cck_highpwr = dm_odm->bCckHighPower; + + cck_agc_rpt = pPhyStaRpt->cck_agc_rpt_ofdm_cfosho_a ; + + /* 2011.11.28 LukeLee: 88E use different LNA & VGA gain table */ + /* The RSSI formula should be modified according to the gain table */ + /* In 88E, cck_highpwr is always set to 1 */ + if (dm_odm->SupportICType & (ODM_RTL8188E|ODM_RTL8812)) { + LNA_idx = ((cck_agc_rpt & 0xE0) >> 5); + VGA_idx = (cck_agc_rpt & 0x1F); + switch (LNA_idx) { + case 7: + if (VGA_idx <= 27) + rx_pwr_all = -100 + 2*(27-VGA_idx); /* VGA_idx = 27~2 */ + else + rx_pwr_all = -100; + break; + case 6: + rx_pwr_all = -48 + 2*(2-VGA_idx); /* VGA_idx = 2~0 */ + break; + case 5: + rx_pwr_all = -42 + 2*(7-VGA_idx); /* VGA_idx = 7~5 */ + break; + case 4: + rx_pwr_all = -36 + 2*(7-VGA_idx); /* VGA_idx = 7~4 */ + break; + case 3: + rx_pwr_all = -24 + 2*(7-VGA_idx); /* VGA_idx = 7~0 */ + break; + case 2: + if (cck_highpwr) + rx_pwr_all = -12 + 2*(5-VGA_idx); /* VGA_idx = 5~0 */ + else + rx_pwr_all = -6 + 2*(5-VGA_idx); + break; + case 1: + rx_pwr_all = 8-2*VGA_idx; + break; + case 0: + rx_pwr_all = 14-2*VGA_idx; + break; + default: + break; + } + rx_pwr_all += 6; + PWDB_ALL = odm_QueryRxPwrPercentage(rx_pwr_all); + if (!cck_highpwr) { + if (PWDB_ALL >= 80) + PWDB_ALL = ((PWDB_ALL-80)<<1)+((PWDB_ALL-80)>>1)+80; + else if ((PWDB_ALL <= 78) && (PWDB_ALL >= 20)) + PWDB_ALL += 3; + if (PWDB_ALL > 100) + PWDB_ALL = 100; + } + } else { + if (!cck_highpwr) { + report = (cck_agc_rpt & 0xc0)>>6; + switch (report) { + /* 03312009 modified by cosa */ + /* Modify the RF RNA gain value to -40, -20, -2, 14 by Jenyu's suggestion */ + /* Note: different RF with the different RNA gain. */ + case 0x3: + rx_pwr_all = -46 - (cck_agc_rpt & 0x3e); + break; + case 0x2: + rx_pwr_all = -26 - (cck_agc_rpt & 0x3e); + break; + case 0x1: + rx_pwr_all = -12 - (cck_agc_rpt & 0x3e); + break; + case 0x0: + rx_pwr_all = 16 - (cck_agc_rpt & 0x3e); + break; + } + } else { + report = (cck_agc_rpt & 0x60)>>5; + switch (report) { + case 0x3: + rx_pwr_all = -46 - ((cck_agc_rpt & 0x1f)<<1) ; + break; + case 0x2: + rx_pwr_all = -26 - ((cck_agc_rpt & 0x1f)<<1); + break; + case 0x1: + rx_pwr_all = -12 - ((cck_agc_rpt & 0x1f)<<1); + break; + case 0x0: + rx_pwr_all = 16 - ((cck_agc_rpt & 0x1f)<<1); + break; + } + } + + PWDB_ALL = odm_QueryRxPwrPercentage(rx_pwr_all); + + /* Modification for ext-LNA board */ + if (dm_odm->BoardType == ODM_BOARD_HIGHPWR) { + if ((cck_agc_rpt>>7) == 0) { + PWDB_ALL = (PWDB_ALL > 94) ? 100 : (PWDB_ALL+6); + } else { + if (PWDB_ALL > 38) + PWDB_ALL -= 16; + else + PWDB_ALL = (PWDB_ALL <= 16) ? (PWDB_ALL>>2) : (PWDB_ALL-12); + } + + /* CCK modification */ + if (PWDB_ALL > 25 && PWDB_ALL <= 60) + PWDB_ALL += 6; + } else {/* Modification for int-LNA board */ + if (PWDB_ALL > 99) + PWDB_ALL -= 8; + else if (PWDB_ALL > 50 && PWDB_ALL <= 68) + PWDB_ALL += 4; + } + } + + pPhyInfo->RxPWDBAll = PWDB_ALL; + pPhyInfo->BTRxRSSIPercentage = PWDB_ALL; + pPhyInfo->RecvSignalPower = rx_pwr_all; + /* (3) Get Signal Quality (EVM) */ + if (pPktinfo->bPacketMatchBSSID) { + u8 SQ, SQ_rpt; + + if ((dm_odm->SupportPlatform == ODM_MP) && (dm_odm->PatchID == 19)) { + SQ = odm_SQ_process_patch_RT_CID_819x_Lenovo(dm_odm, isCCKrate, PWDB_ALL, 0, 0); + } else if (pPhyInfo->RxPWDBAll > 40 && !dm_odm->bInHctTest) { + SQ = 100; + } else { + SQ_rpt = pPhyStaRpt->cck_sig_qual_ofdm_pwdb_all; + + if (SQ_rpt > 64) + SQ = 0; + else if (SQ_rpt < 20) + SQ = 100; + else + SQ = ((64-SQ_rpt) * 100) / 44; + } + pPhyInfo->SignalQuality = SQ; + pPhyInfo->RxMIMOSignalQuality[ODM_RF_PATH_A] = SQ; + pPhyInfo->RxMIMOSignalQuality[ODM_RF_PATH_B] = -1; + } + } else { /* is OFDM rate */ + dm_odm->PhyDbgInfo.NumQryPhyStatusOFDM++; + + /* (1)Get RSSI for HT rate */ + + for (i = ODM_RF_PATH_A; i < ODM_RF_PATH_MAX; i++) { + /* 2008/01/30 MH we will judge RF RX path now. */ + if (dm_odm->RFPathRxEnable & BIT(i)) + rf_rx_num++; + + rx_pwr[i] = ((pPhyStaRpt->path_agc[i].gain & 0x3F)*2) - 110; + + pPhyInfo->RxPwr[i] = rx_pwr[i]; + + /* Translate DBM to percentage. */ + RSSI = odm_QueryRxPwrPercentage(rx_pwr[i]); + total_rssi += RSSI; + + /* Modification for ext-LNA board */ + if (dm_odm->BoardType == ODM_BOARD_HIGHPWR) { + if ((pPhyStaRpt->path_agc[i].trsw) == 1) + RSSI = (RSSI > 94) ? 100 : (RSSI + 6); + else + RSSI = (RSSI <= 16) ? (RSSI >> 3) : (RSSI - 16); + + if ((RSSI <= 34) && (RSSI >= 4)) + RSSI -= 4; + } + + pPhyInfo->RxMIMOSignalStrength[i] = (u8)RSSI; + + /* Get Rx snr value in DB */ + pPhyInfo->RxSNR[i] = (s32)(pPhyStaRpt->path_rxsnr[i]/2); + dm_odm->PhyDbgInfo.RxSNRdB[i] = (s32)(pPhyStaRpt->path_rxsnr[i]/2); + + /* Record Signal Strength for next packet */ + if (pPktinfo->bPacketMatchBSSID) { + if ((dm_odm->SupportPlatform == ODM_MP) && (dm_odm->PatchID == 19)) { + if (i == ODM_RF_PATH_A) + pPhyInfo->SignalQuality = odm_SQ_process_patch_RT_CID_819x_Lenovo(dm_odm, isCCKrate, PWDB_ALL, i, RSSI); + } + } + } + /* (2)PWDB, Average PWDB cacluated by hardware (for rate adaptive) */ + rx_pwr_all = (((pPhyStaRpt->cck_sig_qual_ofdm_pwdb_all) >> 1) & 0x7f) - 110; + + PWDB_ALL = odm_QueryRxPwrPercentage(rx_pwr_all); + PWDB_ALL_BT = PWDB_ALL; + + pPhyInfo->RxPWDBAll = PWDB_ALL; + pPhyInfo->BTRxRSSIPercentage = PWDB_ALL_BT; + pPhyInfo->RxPower = rx_pwr_all; + pPhyInfo->RecvSignalPower = rx_pwr_all; + + if ((dm_odm->SupportPlatform == ODM_MP) && (dm_odm->PatchID == 19)) { + /* do nothing */ + } else { + /* (3)EVM of HT rate */ + if (pPktinfo->Rate >= DESC92C_RATEMCS8 && pPktinfo->Rate <= DESC92C_RATEMCS15) + Max_spatial_stream = 2; /* both spatial stream make sense */ + else + Max_spatial_stream = 1; /* only spatial stream 1 makes sense */ + + for (i = 0; i < Max_spatial_stream; i++) { + /* Do not use shift operation like "rx_evmX >>= 1" because the compilor of free build environment */ + /* fill most significant bit to "zero" when doing shifting operation which may change a negative */ + /* value to positive one, then the dbm value (which is supposed to be negative) is not correct anymore. */ + EVM = odm_EVMdbToPercentage((pPhyStaRpt->stream_rxevm[i])); /* dbm */ + + if (pPktinfo->bPacketMatchBSSID) { + if (i == ODM_RF_PATH_A) /* Fill value in RFD, Get the first spatial stream only */ + pPhyInfo->SignalQuality = (u8)(EVM & 0xff); + pPhyInfo->RxMIMOSignalQuality[i] = (u8)(EVM & 0xff); + } + } + } + } + /* UI BSS List signal strength(in percentage), make it good looking, from 0~100. */ + /* It is assigned to the BSS List in GetValueFromBeaconOrProbeRsp(). */ + if (isCCKrate) { + pPhyInfo->SignalStrength = (u8)(odm_SignalScaleMapping(dm_odm, PWDB_ALL));/* PWDB_ALL; */ + } else { + if (rf_rx_num != 0) + pPhyInfo->SignalStrength = (u8)(odm_SignalScaleMapping(dm_odm, total_rssi /= rf_rx_num)); + } + + /* For 92C/92D HW (Hybrid) Antenna Diversity */ + pDM_SWAT_Table->antsel = pPhyStaRpt->ant_sel; + /* For 88E HW Antenna Diversity */ + dm_odm->DM_FatTable.antsel_rx_keep_0 = pPhyStaRpt->ant_sel; + dm_odm->DM_FatTable.antsel_rx_keep_1 = pPhyStaRpt->ant_sel_b; + dm_odm->DM_FatTable.antsel_rx_keep_2 = pPhyStaRpt->antsel_rx_keep_2; +} + +void odm_Init_RSSIForDM(struct odm_dm_struct *dm_odm) +{ +} + +static void odm_Process_RSSIForDM(struct odm_dm_struct *dm_odm, + struct odm_phy_status_info *pPhyInfo, + struct odm_per_pkt_info *pPktinfo) +{ + s32 UndecoratedSmoothedPWDB, UndecoratedSmoothedCCK; + s32 UndecoratedSmoothedOFDM, RSSI_Ave; + u8 isCCKrate = 0; + u8 RSSI_max, RSSI_min, i; + u32 OFDM_pkt = 0; + u32 Weighting = 0; + struct sta_info *pEntry; + + if (pPktinfo->StationID == 0xFF) + return; + pEntry = dm_odm->pODM_StaInfo[pPktinfo->StationID]; + if (!IS_STA_VALID(pEntry)) + return; + if ((!pPktinfo->bPacketMatchBSSID)) + return; + + isCCKrate = ((pPktinfo->Rate >= DESC92C_RATE1M) && (pPktinfo->Rate <= DESC92C_RATE11M)) ? true : false; + + /* Smart Antenna Debug Message------------------ */ + if (dm_odm->SupportICType == ODM_RTL8188E) { + u8 antsel_tr_mux; + struct fast_ant_train *pDM_FatTable = &dm_odm->DM_FatTable; + + if (dm_odm->AntDivType == CG_TRX_SMART_ANTDIV) { + if (pDM_FatTable->FAT_State == FAT_TRAINING_STATE) { + if (pPktinfo->bPacketToSelf) { + antsel_tr_mux = (pDM_FatTable->antsel_rx_keep_2<<2) | + (pDM_FatTable->antsel_rx_keep_1<<1) | + pDM_FatTable->antsel_rx_keep_0; + pDM_FatTable->antSumRSSI[antsel_tr_mux] += pPhyInfo->RxPWDBAll; + pDM_FatTable->antRSSIcnt[antsel_tr_mux]++; + } + } + } else if ((dm_odm->AntDivType == CG_TRX_HW_ANTDIV) || (dm_odm->AntDivType == CGCS_RX_HW_ANTDIV)) { + if (pPktinfo->bPacketToSelf || pPktinfo->bPacketBeacon) { + antsel_tr_mux = (pDM_FatTable->antsel_rx_keep_2<<2) | + (pDM_FatTable->antsel_rx_keep_1<<1) | pDM_FatTable->antsel_rx_keep_0; + ODM_AntselStatistics_88E(dm_odm, antsel_tr_mux, pPktinfo->StationID, pPhyInfo->RxPWDBAll); + } + } + } + /* Smart Antenna Debug Message------------------ */ + + UndecoratedSmoothedCCK = pEntry->rssi_stat.UndecoratedSmoothedCCK; + UndecoratedSmoothedOFDM = pEntry->rssi_stat.UndecoratedSmoothedOFDM; + UndecoratedSmoothedPWDB = pEntry->rssi_stat.UndecoratedSmoothedPWDB; + + if (pPktinfo->bPacketToSelf || pPktinfo->bPacketBeacon) { + if (!isCCKrate) { /* ofdm rate */ + if (pPhyInfo->RxMIMOSignalStrength[ODM_RF_PATH_B] == 0) { + RSSI_Ave = pPhyInfo->RxMIMOSignalStrength[ODM_RF_PATH_A]; + } else { + if (pPhyInfo->RxMIMOSignalStrength[ODM_RF_PATH_A] > pPhyInfo->RxMIMOSignalStrength[ODM_RF_PATH_B]) { + RSSI_max = pPhyInfo->RxMIMOSignalStrength[ODM_RF_PATH_A]; + RSSI_min = pPhyInfo->RxMIMOSignalStrength[ODM_RF_PATH_B]; + } else { + RSSI_max = pPhyInfo->RxMIMOSignalStrength[ODM_RF_PATH_B]; + RSSI_min = pPhyInfo->RxMIMOSignalStrength[ODM_RF_PATH_A]; + } + if ((RSSI_max - RSSI_min) < 3) + RSSI_Ave = RSSI_max; + else if ((RSSI_max - RSSI_min) < 6) + RSSI_Ave = RSSI_max - 1; + else if ((RSSI_max - RSSI_min) < 10) + RSSI_Ave = RSSI_max - 2; + else + RSSI_Ave = RSSI_max - 3; + } + + /* 1 Process OFDM RSSI */ + if (UndecoratedSmoothedOFDM <= 0) { /* initialize */ + UndecoratedSmoothedOFDM = pPhyInfo->RxPWDBAll; + } else { + if (pPhyInfo->RxPWDBAll > (u32)UndecoratedSmoothedOFDM) { + UndecoratedSmoothedOFDM = + (((UndecoratedSmoothedOFDM)*(Rx_Smooth_Factor-1)) + + (RSSI_Ave)) / (Rx_Smooth_Factor); + UndecoratedSmoothedOFDM = UndecoratedSmoothedOFDM + 1; + } else { + UndecoratedSmoothedOFDM = + (((UndecoratedSmoothedOFDM)*(Rx_Smooth_Factor-1)) + + (RSSI_Ave)) / (Rx_Smooth_Factor); + } + } + + pEntry->rssi_stat.PacketMap = (pEntry->rssi_stat.PacketMap<<1) | BIT0; + + } else { + RSSI_Ave = pPhyInfo->RxPWDBAll; + + /* 1 Process CCK RSSI */ + if (UndecoratedSmoothedCCK <= 0) { /* initialize */ + UndecoratedSmoothedCCK = pPhyInfo->RxPWDBAll; + } else { + if (pPhyInfo->RxPWDBAll > (u32)UndecoratedSmoothedCCK) { + UndecoratedSmoothedCCK = + ((UndecoratedSmoothedCCK * (Rx_Smooth_Factor-1)) + + pPhyInfo->RxPWDBAll) / Rx_Smooth_Factor; + UndecoratedSmoothedCCK = UndecoratedSmoothedCCK + 1; + } else { + UndecoratedSmoothedCCK = + ((UndecoratedSmoothedCCK * (Rx_Smooth_Factor-1)) + + pPhyInfo->RxPWDBAll) / Rx_Smooth_Factor; + } + } + pEntry->rssi_stat.PacketMap = pEntry->rssi_stat.PacketMap<<1; + } + /* 2011.07.28 LukeLee: modified to prevent unstable CCK RSSI */ + if (pEntry->rssi_stat.ValidBit >= 64) + pEntry->rssi_stat.ValidBit = 64; + else + pEntry->rssi_stat.ValidBit++; + + for (i = 0; i < pEntry->rssi_stat.ValidBit; i++) + OFDM_pkt += (u8)(pEntry->rssi_stat.PacketMap>>i)&BIT0; + + if (pEntry->rssi_stat.ValidBit == 64) { + Weighting = ((OFDM_pkt<<4) > 64) ? 64 : (OFDM_pkt<<4); + UndecoratedSmoothedPWDB = (Weighting*UndecoratedSmoothedOFDM+(64-Weighting)*UndecoratedSmoothedCCK)>>6; + } else { + if (pEntry->rssi_stat.ValidBit != 0) + UndecoratedSmoothedPWDB = (OFDM_pkt * UndecoratedSmoothedOFDM + + (pEntry->rssi_stat.ValidBit-OFDM_pkt) * + UndecoratedSmoothedCCK)/pEntry->rssi_stat.ValidBit; + else + UndecoratedSmoothedPWDB = 0; + } + pEntry->rssi_stat.UndecoratedSmoothedCCK = UndecoratedSmoothedCCK; + pEntry->rssi_stat.UndecoratedSmoothedOFDM = UndecoratedSmoothedOFDM; + pEntry->rssi_stat.UndecoratedSmoothedPWDB = UndecoratedSmoothedPWDB; + } +} + +/* Endianness before calling this API */ +static void ODM_PhyStatusQuery_92CSeries(struct odm_dm_struct *dm_odm, + struct odm_phy_status_info *pPhyInfo, + u8 *pPhyStatus, + struct odm_per_pkt_info *pPktinfo) +{ + odm_RxPhyStatus92CSeries_Parsing(dm_odm, pPhyInfo, pPhyStatus, + pPktinfo); + if (dm_odm->RSSI_test) { + /* Select the packets to do RSSI checking for antenna switching. */ + if (pPktinfo->bPacketToSelf || pPktinfo->bPacketBeacon) + ODM_SwAntDivChkPerPktRssi(dm_odm, pPktinfo->StationID, pPhyInfo); + } else { + odm_Process_RSSIForDM(dm_odm, pPhyInfo, pPktinfo); + } +} + +void ODM_PhyStatusQuery(struct odm_dm_struct *dm_odm, + struct odm_phy_status_info *pPhyInfo, + u8 *pPhyStatus, struct odm_per_pkt_info *pPktinfo) +{ + ODM_PhyStatusQuery_92CSeries(dm_odm, pPhyInfo, pPhyStatus, pPktinfo); +} + +/* For future use. */ +void ODM_MacStatusQuery(struct odm_dm_struct *dm_odm, u8 *mac_stat, + u8 macid, bool pkt_match_bssid, + bool pkttoself, bool pkt_beacon) +{ + /* 2011/10/19 Driver team will handle in the future. */ +} + +enum HAL_STATUS ODM_ConfigRFWithHeaderFile(struct odm_dm_struct *dm_odm, + enum ODM_RF_RADIO_PATH content, + enum ODM_RF_RADIO_PATH rfpath) +{ + ODM_RT_TRACE(dm_odm, ODM_COMP_INIT, ODM_DBG_LOUD, ("===>ODM_ConfigRFWithHeaderFile\n")); + if (dm_odm->SupportICType == ODM_RTL8188E) { + if (rfpath == ODM_RF_PATH_A) + READ_AND_CONFIG(8188E, _RadioA_1T_); + ODM_RT_TRACE(dm_odm, ODM_COMP_INIT, ODM_DBG_LOUD, (" ===> ODM_ConfigRFWithHeaderFile() Radio_A:Rtl8188ERadioA_1TArray\n")); + ODM_RT_TRACE(dm_odm, ODM_COMP_INIT, ODM_DBG_LOUD, (" ===> ODM_ConfigRFWithHeaderFile() Radio_B:Rtl8188ERadioB_1TArray\n")); + } + + ODM_RT_TRACE(dm_odm, ODM_COMP_INIT, ODM_DBG_TRACE, ("ODM_ConfigRFWithHeaderFile: Radio No %x\n", rfpath)); + return HAL_STATUS_SUCCESS; +} + +enum HAL_STATUS ODM_ConfigBBWithHeaderFile(struct odm_dm_struct *dm_odm, + enum odm_bb_config_type config_tp) +{ + if (dm_odm->SupportICType == ODM_RTL8188E) { + if (config_tp == CONFIG_BB_PHY_REG) { + READ_AND_CONFIG(8188E, _PHY_REG_1T_); + } else if (config_tp == CONFIG_BB_AGC_TAB) { + READ_AND_CONFIG(8188E, _AGC_TAB_1T_); + } else if (config_tp == CONFIG_BB_PHY_REG_PG) { + READ_AND_CONFIG(8188E, _PHY_REG_PG_); + ODM_RT_TRACE(dm_odm, ODM_COMP_INIT, ODM_DBG_LOUD, + (" ===> phy_ConfigBBWithHeaderFile() agc:Rtl8188EPHY_REG_PGArray\n")); + } + } + return HAL_STATUS_SUCCESS; +} + +enum HAL_STATUS ODM_ConfigMACWithHeaderFile(struct odm_dm_struct *dm_odm) +{ + u8 result = HAL_STATUS_SUCCESS; + if (dm_odm->SupportICType == ODM_RTL8188E) + result = READ_AND_CONFIG(8188E, _MAC_REG_); + return result; +} diff --git a/drivers/staging/rtl8188eu/hal/odm_interface.c b/drivers/staging/rtl8188eu/hal/odm_interface.c new file mode 100644 index 0000000000000..59ad5bf4d9415 --- /dev/null +++ b/drivers/staging/rtl8188eu/hal/odm_interface.c @@ -0,0 +1,203 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#include "odm_precomp.h" +/* ODM IO Relative API. */ + +u8 ODM_Read1Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr) +{ + struct adapter *Adapter = pDM_Odm->Adapter; + return rtw_read8(Adapter, RegAddr); +} + +u16 ODM_Read2Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr) +{ + struct adapter *Adapter = pDM_Odm->Adapter; + return rtw_read16(Adapter, RegAddr); +} + +u32 ODM_Read4Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr) +{ + struct adapter *Adapter = pDM_Odm->Adapter; + return rtw_read32(Adapter, RegAddr); +} + +void ODM_Write1Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u8 Data) +{ + struct adapter *Adapter = pDM_Odm->Adapter; + rtw_write8(Adapter, RegAddr, Data); +} + +void ODM_Write2Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u16 Data) +{ + struct adapter *Adapter = pDM_Odm->Adapter; + rtw_write16(Adapter, RegAddr, Data); +} + +void ODM_Write4Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u32 Data) +{ + struct adapter *Adapter = pDM_Odm->Adapter; + rtw_write32(Adapter, RegAddr, Data); +} + +void ODM_SetMACReg(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u32 BitMask, u32 Data) +{ + struct adapter *Adapter = pDM_Odm->Adapter; + PHY_SetBBReg(Adapter, RegAddr, BitMask, Data); +} + +u32 ODM_GetMACReg(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u32 BitMask) +{ + struct adapter *Adapter = pDM_Odm->Adapter; + return PHY_QueryBBReg(Adapter, RegAddr, BitMask); +} + +void ODM_SetBBReg(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u32 BitMask, u32 Data) +{ + struct adapter *Adapter = pDM_Odm->Adapter; + PHY_SetBBReg(Adapter, RegAddr, BitMask, Data); +} + +u32 ODM_GetBBReg(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u32 BitMask) +{ + struct adapter *Adapter = pDM_Odm->Adapter; + return PHY_QueryBBReg(Adapter, RegAddr, BitMask); +} + +void ODM_SetRFReg(struct odm_dm_struct *pDM_Odm, enum ODM_RF_RADIO_PATH eRFPath, u32 RegAddr, u32 BitMask, u32 Data) +{ + struct adapter *Adapter = pDM_Odm->Adapter; + PHY_SetRFReg(Adapter, (enum rf_radio_path)eRFPath, RegAddr, BitMask, Data); +} + +u32 ODM_GetRFReg(struct odm_dm_struct *pDM_Odm, enum ODM_RF_RADIO_PATH eRFPath, u32 RegAddr, u32 BitMask) +{ + struct adapter *Adapter = pDM_Odm->Adapter; + return PHY_QueryRFReg(Adapter, (enum rf_radio_path)eRFPath, RegAddr, BitMask); +} + +/* ODM Memory relative API. */ +void ODM_AllocateMemory(struct odm_dm_struct *pDM_Odm, void **pPtr, u32 length) +{ + *pPtr = rtw_zvmalloc(length); +} + +/* length could be ignored, used to detect memory leakage. */ +void ODM_FreeMemory(struct odm_dm_struct *pDM_Odm, void *pPtr, u32 length) +{ + rtw_vmfree(pPtr, length); +} + +s32 ODM_CompareMemory(struct odm_dm_struct *pDM_Odm, void *pBuf1, void *pBuf2, u32 length) +{ + return _rtw_memcmp(pBuf1, pBuf2, length); +} + +/* ODM MISC relative API. */ +void ODM_AcquireSpinLock(struct odm_dm_struct *pDM_Odm, enum RT_SPINLOCK_TYPE type) +{ +} + +void ODM_ReleaseSpinLock(struct odm_dm_struct *pDM_Odm, enum RT_SPINLOCK_TYPE type) +{ +} + +/* Work item relative API. FOr MP driver only~! */ +void ODM_InitializeWorkItem(struct odm_dm_struct *pDM_Odm, void *pRtWorkItem, + RT_WORKITEM_CALL_BACK RtWorkItemCallback, + void *pContext, const char *szID) +{ +} + +void ODM_StartWorkItem(void *pRtWorkItem) +{ +} + +void ODM_StopWorkItem(void *pRtWorkItem) +{ +} + +void ODM_FreeWorkItem(void *pRtWorkItem) +{ +} + +void ODM_ScheduleWorkItem(void *pRtWorkItem) +{ +} + +void ODM_IsWorkItemScheduled(void *pRtWorkItem) +{ +} + +/* ODM Timer relative API. */ +void ODM_StallExecution(u32 usDelay) +{ + rtw_udelay_os(usDelay); +} + +void ODM_delay_ms(u32 ms) +{ + rtw_mdelay_os(ms); +} + +void ODM_delay_us(u32 us) +{ + rtw_udelay_os(us); +} + +void ODM_sleep_ms(u32 ms) +{ + rtw_msleep_os(ms); +} + +void ODM_sleep_us(u32 us) +{ + rtw_usleep_os(us); +} + +void ODM_SetTimer(struct odm_dm_struct *pDM_Odm, struct timer_list *pTimer, u32 msDelay) +{ + _set_timer(pTimer, msDelay); /* ms */ +} + +void ODM_InitializeTimer(struct odm_dm_struct *pDM_Odm, struct timer_list *pTimer, + void *CallBackFunc, void *pContext, + const char *szID) +{ + struct adapter *Adapter = pDM_Odm->Adapter; + _init_timer(pTimer, Adapter->pnetdev, CallBackFunc, pDM_Odm); +} + +void ODM_CancelTimer(struct odm_dm_struct *pDM_Odm, struct timer_list *pTimer) +{ + _cancel_timer_ex(pTimer); +} + +void ODM_ReleaseTimer(struct odm_dm_struct *pDM_Odm, struct timer_list *pTimer) +{ +} + +/* ODM FW relative API. */ +u32 ODM_FillH2CCmd(u8 *pH2CBuffer, u32 H2CBufferLen, u32 CmdNum, + u32 *pElementID, u32 *pCmdLen, + u8 **pCmbBuffer, u8 *CmdStartSeq) +{ + return true; +} -- GitLab From 7ef8ded0cfdb690e37581af85eea35fa67cdb38d Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 21 Aug 2013 22:33:55 -0500 Subject: [PATCH 771/942] staging: r8188eu: Add files for new driver - part 13 This commit adds files hal/odm_RTL8188E.c, hal/odm_RegConfig8188E.c, hal/rtl8188e_cmd.c, and hal/rtl8188e_dm.c. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/odm_RTL8188E.c | 399 +++++++++ .../rtl8188eu/hal/odm_RegConfig8188E.c | 130 +++ drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c | 779 ++++++++++++++++++ drivers/staging/rtl8188eu/hal/rtl8188e_dm.c | 268 ++++++ 4 files changed, 1576 insertions(+) create mode 100644 drivers/staging/rtl8188eu/hal/odm_RTL8188E.c create mode 100644 drivers/staging/rtl8188eu/hal/odm_RegConfig8188E.c create mode 100644 drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c create mode 100644 drivers/staging/rtl8188eu/hal/rtl8188e_dm.c diff --git a/drivers/staging/rtl8188eu/hal/odm_RTL8188E.c b/drivers/staging/rtl8188eu/hal/odm_RTL8188E.c new file mode 100644 index 0000000000000..58410f3e5316e --- /dev/null +++ b/drivers/staging/rtl8188eu/hal/odm_RTL8188E.c @@ -0,0 +1,399 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#include "odm_precomp.h" + +void ODM_DIG_LowerBound_88E(struct odm_dm_struct *dm_odm) +{ + struct rtw_dig *pDM_DigTable = &dm_odm->DM_DigTable; + + if (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) { + pDM_DigTable->rx_gain_range_min = (u8) pDM_DigTable->AntDiv_RSSI_max; + ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, + ("ODM_DIG_LowerBound_88E(): pDM_DigTable->AntDiv_RSSI_max=%d\n", pDM_DigTable->AntDiv_RSSI_max)); + } + /* If only one Entry connected */ +} + +static void odm_RX_HWAntDivInit(struct odm_dm_struct *dm_odm) +{ + u32 value32; + + if (*(dm_odm->mp_mode) == 1) { + dm_odm->AntDivType = CGCS_RX_SW_ANTDIV; + ODM_SetBBReg(dm_odm, ODM_REG_IGI_A_11N, BIT7, 0); /* disable HW AntDiv */ + ODM_SetBBReg(dm_odm, ODM_REG_LNA_SWITCH_11N, BIT31, 1); /* 1:CG, 0:CS */ + return; + } + ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("odm_RX_HWAntDivInit()\n")); + + /* MAC Setting */ + value32 = ODM_GetMACReg(dm_odm, ODM_REG_ANTSEL_PIN_11N, bMaskDWord); + ODM_SetMACReg(dm_odm, ODM_REG_ANTSEL_PIN_11N, bMaskDWord, value32|(BIT23|BIT25)); /* Reg4C[25]=1, Reg4C[23]=1 for pin output */ + /* Pin Settings */ + ODM_SetBBReg(dm_odm, ODM_REG_PIN_CTRL_11N, BIT9|BIT8, 0);/* Reg870[8]=1'b0, Reg870[9]=1'b0 antsel antselb by HW */ + ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT10, 0); /* Reg864[10]=1'b0 antsel2 by HW */ + ODM_SetBBReg(dm_odm, ODM_REG_LNA_SWITCH_11N, BIT22, 1); /* Regb2c[22]=1'b0 disable CS/CG switch */ + ODM_SetBBReg(dm_odm, ODM_REG_LNA_SWITCH_11N, BIT31, 1); /* Regb2c[31]=1'b1 output at CG only */ + /* OFDM Settings */ + ODM_SetBBReg(dm_odm, ODM_REG_ANTDIV_PARA1_11N, bMaskDWord, 0x000000a0); + /* CCK Settings */ + ODM_SetBBReg(dm_odm, ODM_REG_BB_PWR_SAV4_11N, BIT7, 1); /* Fix CCK PHY status report issue */ + ODM_SetBBReg(dm_odm, ODM_REG_CCK_ANTDIV_PARA2_11N, BIT4, 1); /* CCK complete HW AntDiv within 64 samples */ + ODM_UpdateRxIdleAnt_88E(dm_odm, MAIN_ANT); + ODM_SetBBReg(dm_odm, ODM_REG_ANT_MAPPING1_11N, 0xFFFF, 0x0201); /* antenna mapping table */ +} + +static void odm_TRX_HWAntDivInit(struct odm_dm_struct *dm_odm) +{ + u32 value32; + + if (*(dm_odm->mp_mode) == 1) { + dm_odm->AntDivType = CGCS_RX_SW_ANTDIV; + ODM_SetBBReg(dm_odm, ODM_REG_IGI_A_11N, BIT7, 0); /* disable HW AntDiv */ + ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT5|BIT4|BIT3, 0); /* Default RX (0/1) */ + return; + } + ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("odm_TRX_HWAntDivInit()\n")); + + /* MAC Setting */ + value32 = ODM_GetMACReg(dm_odm, ODM_REG_ANTSEL_PIN_11N, bMaskDWord); + ODM_SetMACReg(dm_odm, ODM_REG_ANTSEL_PIN_11N, bMaskDWord, value32|(BIT23|BIT25)); /* Reg4C[25]=1, Reg4C[23]=1 for pin output */ + /* Pin Settings */ + ODM_SetBBReg(dm_odm, ODM_REG_PIN_CTRL_11N, BIT9|BIT8, 0);/* Reg870[8]=1'b0, Reg870[9]=1'b0 antsel antselb by HW */ + ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT10, 0); /* Reg864[10]=1'b0 antsel2 by HW */ + ODM_SetBBReg(dm_odm, ODM_REG_LNA_SWITCH_11N, BIT22, 0); /* Regb2c[22]=1'b0 disable CS/CG switch */ + ODM_SetBBReg(dm_odm, ODM_REG_LNA_SWITCH_11N, BIT31, 1); /* Regb2c[31]=1'b1 output at CG only */ + /* OFDM Settings */ + ODM_SetBBReg(dm_odm, ODM_REG_ANTDIV_PARA1_11N, bMaskDWord, 0x000000a0); + /* CCK Settings */ + ODM_SetBBReg(dm_odm, ODM_REG_BB_PWR_SAV4_11N, BIT7, 1); /* Fix CCK PHY status report issue */ + ODM_SetBBReg(dm_odm, ODM_REG_CCK_ANTDIV_PARA2_11N, BIT4, 1); /* CCK complete HW AntDiv within 64 samples */ + /* Tx Settings */ + ODM_SetBBReg(dm_odm, ODM_REG_TX_ANT_CTRL_11N, BIT21, 0); /* Reg80c[21]=1'b0 from TX Reg */ + ODM_UpdateRxIdleAnt_88E(dm_odm, MAIN_ANT); + + /* antenna mapping table */ + if (!dm_odm->bIsMPChip) { /* testchip */ + ODM_SetBBReg(dm_odm, ODM_REG_RX_DEFUALT_A_11N, BIT10|BIT9|BIT8, 1); /* Reg858[10:8]=3'b001 */ + ODM_SetBBReg(dm_odm, ODM_REG_RX_DEFUALT_A_11N, BIT13|BIT12|BIT11, 2); /* Reg858[13:11]=3'b010 */ + } else { /* MPchip */ + ODM_SetBBReg(dm_odm, ODM_REG_ANT_MAPPING1_11N, bMaskDWord, 0x0201); /* Reg914=3'b010, Reg915=3'b001 */ + } +} + +static void odm_FastAntTrainingInit(struct odm_dm_struct *dm_odm) +{ + u32 value32, i; + struct fast_ant_train *dm_fat_tbl = &dm_odm->DM_FatTable; + u32 AntCombination = 2; + + ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("odm_FastAntTrainingInit()\n")); + + if (*(dm_odm->mp_mode) == 1) { + ODM_RT_TRACE(dm_odm, ODM_COMP_INIT, ODM_DBG_LOUD, ("dm_odm->AntDivType: %d\n", dm_odm->AntDivType)); + return; + } + + for (i = 0; i < 6; i++) { + dm_fat_tbl->Bssid[i] = 0; + dm_fat_tbl->antSumRSSI[i] = 0; + dm_fat_tbl->antRSSIcnt[i] = 0; + dm_fat_tbl->antAveRSSI[i] = 0; + } + dm_fat_tbl->TrainIdx = 0; + dm_fat_tbl->FAT_State = FAT_NORMAL_STATE; + + /* MAC Setting */ + value32 = ODM_GetMACReg(dm_odm, 0x4c, bMaskDWord); + ODM_SetMACReg(dm_odm, 0x4c, bMaskDWord, value32|(BIT23|BIT25)); /* Reg4C[25]=1, Reg4C[23]=1 for pin output */ + value32 = ODM_GetMACReg(dm_odm, 0x7B4, bMaskDWord); + ODM_SetMACReg(dm_odm, 0x7b4, bMaskDWord, value32|(BIT16|BIT17)); /* Reg7B4[16]=1 enable antenna training, Reg7B4[17]=1 enable A2 match */ + + /* Match MAC ADDR */ + ODM_SetMACReg(dm_odm, 0x7b4, 0xFFFF, 0); + ODM_SetMACReg(dm_odm, 0x7b0, bMaskDWord, 0); + + ODM_SetBBReg(dm_odm, 0x870, BIT9|BIT8, 0);/* Reg870[8]=1'b0, Reg870[9]=1'b0 antsel antselb by HW */ + ODM_SetBBReg(dm_odm, 0x864, BIT10, 0); /* Reg864[10]=1'b0 antsel2 by HW */ + ODM_SetBBReg(dm_odm, 0xb2c, BIT22, 0); /* Regb2c[22]=1'b0 disable CS/CG switch */ + ODM_SetBBReg(dm_odm, 0xb2c, BIT31, 1); /* Regb2c[31]=1'b1 output at CG only */ + ODM_SetBBReg(dm_odm, 0xca4, bMaskDWord, 0x000000a0); + + /* antenna mapping table */ + if (AntCombination == 2) { + if (!dm_odm->bIsMPChip) { /* testchip */ + ODM_SetBBReg(dm_odm, 0x858, BIT10|BIT9|BIT8, 1); /* Reg858[10:8]=3'b001 */ + ODM_SetBBReg(dm_odm, 0x858, BIT13|BIT12|BIT11, 2); /* Reg858[13:11]=3'b010 */ + } else { /* MPchip */ + ODM_SetBBReg(dm_odm, 0x914, bMaskByte0, 1); + ODM_SetBBReg(dm_odm, 0x914, bMaskByte1, 2); + } + } else if (AntCombination == 7) { + if (!dm_odm->bIsMPChip) { /* testchip */ + ODM_SetBBReg(dm_odm, 0x858, BIT10|BIT9|BIT8, 0); /* Reg858[10:8]=3'b000 */ + ODM_SetBBReg(dm_odm, 0x858, BIT13|BIT12|BIT11, 1); /* Reg858[13:11]=3'b001 */ + ODM_SetBBReg(dm_odm, 0x878, BIT16, 0); + ODM_SetBBReg(dm_odm, 0x858, BIT15|BIT14, 2); /* Reg878[0],Reg858[14:15])=3'b010 */ + ODM_SetBBReg(dm_odm, 0x878, BIT19|BIT18|BIT17, 3);/* Reg878[3:1]=3b'011 */ + ODM_SetBBReg(dm_odm, 0x878, BIT22|BIT21|BIT20, 4);/* Reg878[6:4]=3b'100 */ + ODM_SetBBReg(dm_odm, 0x878, BIT25|BIT24|BIT23, 5);/* Reg878[9:7]=3b'101 */ + ODM_SetBBReg(dm_odm, 0x878, BIT28|BIT27|BIT26, 6);/* Reg878[12:10]=3b'110 */ + ODM_SetBBReg(dm_odm, 0x878, BIT31|BIT30|BIT29, 7);/* Reg878[15:13]=3b'111 */ + } else { /* MPchip */ + ODM_SetBBReg(dm_odm, 0x914, bMaskByte0, 0); + ODM_SetBBReg(dm_odm, 0x914, bMaskByte1, 1); + ODM_SetBBReg(dm_odm, 0x914, bMaskByte2, 2); + ODM_SetBBReg(dm_odm, 0x914, bMaskByte3, 3); + ODM_SetBBReg(dm_odm, 0x918, bMaskByte0, 4); + ODM_SetBBReg(dm_odm, 0x918, bMaskByte1, 5); + ODM_SetBBReg(dm_odm, 0x918, bMaskByte2, 6); + ODM_SetBBReg(dm_odm, 0x918, bMaskByte3, 7); + } + } + + /* Default Ant Setting when no fast training */ + ODM_SetBBReg(dm_odm, 0x80c, BIT21, 1); /* Reg80c[21]=1'b1 from TX Info */ + ODM_SetBBReg(dm_odm, 0x864, BIT5|BIT4|BIT3, 0); /* Default RX */ + ODM_SetBBReg(dm_odm, 0x864, BIT8|BIT7|BIT6, 1); /* Optional RX */ + + /* Enter Traing state */ + ODM_SetBBReg(dm_odm, 0x864, BIT2|BIT1|BIT0, (AntCombination-1)); /* Reg864[2:0]=3'd6 ant combination=reg864[2:0]+1 */ + ODM_SetBBReg(dm_odm, 0xc50, BIT7, 1); /* RegC50[7]=1'b1 enable HW AntDiv */ +} + +void ODM_AntennaDiversityInit_88E(struct odm_dm_struct *dm_odm) +{ + if (dm_odm->SupportICType != ODM_RTL8188E) + return; + + ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("dm_odm->AntDivType=%d\n", dm_odm->AntDivType)); + ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("dm_odm->bIsMPChip=%s\n", (dm_odm->bIsMPChip ? "true" : "false"))); + + if (dm_odm->AntDivType == CGCS_RX_HW_ANTDIV) + odm_RX_HWAntDivInit(dm_odm); + else if (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) + odm_TRX_HWAntDivInit(dm_odm); + else if (dm_odm->AntDivType == CG_TRX_SMART_ANTDIV) + odm_FastAntTrainingInit(dm_odm); +} + +void ODM_UpdateRxIdleAnt_88E(struct odm_dm_struct *dm_odm, u8 Ant) +{ + struct fast_ant_train *dm_fat_tbl = &dm_odm->DM_FatTable; + u32 DefaultAnt, OptionalAnt; + + if (dm_fat_tbl->RxIdleAnt != Ant) { + ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Need to Update Rx Idle Ant\n")); + if (Ant == MAIN_ANT) { + DefaultAnt = (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) ? MAIN_ANT_CG_TRX : MAIN_ANT_CGCS_RX; + OptionalAnt = (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) ? AUX_ANT_CG_TRX : AUX_ANT_CGCS_RX; + } else { + DefaultAnt = (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) ? AUX_ANT_CG_TRX : AUX_ANT_CGCS_RX; + OptionalAnt = (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) ? MAIN_ANT_CG_TRX : MAIN_ANT_CGCS_RX; + } + + if (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) { + ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT5|BIT4|BIT3, DefaultAnt); /* Default RX */ + ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT8|BIT7|BIT6, OptionalAnt); /* Optional RX */ + ODM_SetBBReg(dm_odm, ODM_REG_ANTSEL_CTRL_11N, BIT14|BIT13|BIT12, DefaultAnt); /* Default TX */ + ODM_SetMACReg(dm_odm, ODM_REG_RESP_TX_11N, BIT6|BIT7, DefaultAnt); /* Resp Tx */ + } else if (dm_odm->AntDivType == CGCS_RX_HW_ANTDIV) { + ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT5|BIT4|BIT3, DefaultAnt); /* Default RX */ + ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT8|BIT7|BIT6, OptionalAnt); /* Optional RX */ + } + } + dm_fat_tbl->RxIdleAnt = Ant; + ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("RxIdleAnt=%s\n", (Ant == MAIN_ANT) ? "MAIN_ANT" : "AUX_ANT")); + pr_info("RxIdleAnt=%s\n", (Ant == MAIN_ANT) ? "MAIN_ANT" : "AUX_ANT"); +} + +static void odm_UpdateTxAnt_88E(struct odm_dm_struct *dm_odm, u8 Ant, u32 MacId) +{ + struct fast_ant_train *dm_fat_tbl = &dm_odm->DM_FatTable; + u8 TargetAnt; + + if (Ant == MAIN_ANT) + TargetAnt = MAIN_ANT_CG_TRX; + else + TargetAnt = AUX_ANT_CG_TRX; + dm_fat_tbl->antsel_a[MacId] = TargetAnt&BIT0; + dm_fat_tbl->antsel_b[MacId] = (TargetAnt&BIT1)>>1; + dm_fat_tbl->antsel_c[MacId] = (TargetAnt&BIT2)>>2; + + ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, + ("Tx from TxInfo, TargetAnt=%s\n", + (Ant == MAIN_ANT) ? "MAIN_ANT" : "AUX_ANT")); + ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, + ("antsel_tr_mux=3'b%d%d%d\n", + dm_fat_tbl->antsel_c[MacId], dm_fat_tbl->antsel_b[MacId], dm_fat_tbl->antsel_a[MacId])); +} + +void ODM_SetTxAntByTxInfo_88E(struct odm_dm_struct *dm_odm, u8 *pDesc, u8 macId) +{ + struct fast_ant_train *dm_fat_tbl = &dm_odm->DM_FatTable; + + if ((dm_odm->AntDivType == CG_TRX_HW_ANTDIV) || (dm_odm->AntDivType == CG_TRX_SMART_ANTDIV)) { + SET_TX_DESC_ANTSEL_A_88E(pDesc, dm_fat_tbl->antsel_a[macId]); + SET_TX_DESC_ANTSEL_B_88E(pDesc, dm_fat_tbl->antsel_b[macId]); + SET_TX_DESC_ANTSEL_C_88E(pDesc, dm_fat_tbl->antsel_c[macId]); + } +} + +void ODM_AntselStatistics_88E(struct odm_dm_struct *dm_odm, u8 antsel_tr_mux, u32 MacId, u8 RxPWDBAll) +{ + struct fast_ant_train *dm_fat_tbl = &dm_odm->DM_FatTable; + if (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) { + if (antsel_tr_mux == MAIN_ANT_CG_TRX) { + dm_fat_tbl->MainAnt_Sum[MacId] += RxPWDBAll; + dm_fat_tbl->MainAnt_Cnt[MacId]++; + } else { + dm_fat_tbl->AuxAnt_Sum[MacId] += RxPWDBAll; + dm_fat_tbl->AuxAnt_Cnt[MacId]++; + } + } else if (dm_odm->AntDivType == CGCS_RX_HW_ANTDIV) { + if (antsel_tr_mux == MAIN_ANT_CGCS_RX) { + dm_fat_tbl->MainAnt_Sum[MacId] += RxPWDBAll; + dm_fat_tbl->MainAnt_Cnt[MacId]++; + } else { + dm_fat_tbl->AuxAnt_Sum[MacId] += RxPWDBAll; + dm_fat_tbl->AuxAnt_Cnt[MacId]++; + } + } +} + +static void odm_HWAntDiv(struct odm_dm_struct *dm_odm) +{ + u32 i, MinRSSI = 0xFF, AntDivMaxRSSI = 0, MaxRSSI = 0, LocalMinRSSI, LocalMaxRSSI; + u32 Main_RSSI, Aux_RSSI; + u8 RxIdleAnt = 0, TargetAnt = 7; + struct fast_ant_train *dm_fat_tbl = &dm_odm->DM_FatTable; + struct rtw_dig *pDM_DigTable = &dm_odm->DM_DigTable; + struct sta_info *pEntry; + + for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) { + pEntry = dm_odm->pODM_StaInfo[i]; + if (IS_STA_VALID(pEntry)) { + /* 2 Caculate RSSI per Antenna */ + Main_RSSI = (dm_fat_tbl->MainAnt_Cnt[i] != 0) ? (dm_fat_tbl->MainAnt_Sum[i]/dm_fat_tbl->MainAnt_Cnt[i]) : 0; + Aux_RSSI = (dm_fat_tbl->AuxAnt_Cnt[i] != 0) ? (dm_fat_tbl->AuxAnt_Sum[i]/dm_fat_tbl->AuxAnt_Cnt[i]) : 0; + TargetAnt = (Main_RSSI >= Aux_RSSI) ? MAIN_ANT : AUX_ANT; + ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, + ("MacID=%d, MainAnt_Sum=%d, MainAnt_Cnt=%d\n", + i, dm_fat_tbl->MainAnt_Sum[i], + dm_fat_tbl->MainAnt_Cnt[i])); + ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, + ("MacID=%d, AuxAnt_Sum=%d, AuxAnt_Cnt=%d\n", + i, dm_fat_tbl->AuxAnt_Sum[i], dm_fat_tbl->AuxAnt_Cnt[i])); + ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, + ("MacID=%d, Main_RSSI= %d, Aux_RSSI= %d\n", + i, Main_RSSI, Aux_RSSI)); + /* 2 Select MaxRSSI for DIG */ + LocalMaxRSSI = (Main_RSSI > Aux_RSSI) ? Main_RSSI : Aux_RSSI; + if ((LocalMaxRSSI > AntDivMaxRSSI) && (LocalMaxRSSI < 40)) + AntDivMaxRSSI = LocalMaxRSSI; + if (LocalMaxRSSI > MaxRSSI) + MaxRSSI = LocalMaxRSSI; + + /* 2 Select RX Idle Antenna */ + if ((dm_fat_tbl->RxIdleAnt == MAIN_ANT) && (Main_RSSI == 0)) + Main_RSSI = Aux_RSSI; + else if ((dm_fat_tbl->RxIdleAnt == AUX_ANT) && (Aux_RSSI == 0)) + Aux_RSSI = Main_RSSI; + + LocalMinRSSI = (Main_RSSI > Aux_RSSI) ? Aux_RSSI : Main_RSSI; + if (LocalMinRSSI < MinRSSI) { + MinRSSI = LocalMinRSSI; + RxIdleAnt = TargetAnt; + } + /* 2 Select TRX Antenna */ + if (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) + odm_UpdateTxAnt_88E(dm_odm, TargetAnt, i); + } + dm_fat_tbl->MainAnt_Sum[i] = 0; + dm_fat_tbl->AuxAnt_Sum[i] = 0; + dm_fat_tbl->MainAnt_Cnt[i] = 0; + dm_fat_tbl->AuxAnt_Cnt[i] = 0; + } + + /* 2 Set RX Idle Antenna */ + ODM_UpdateRxIdleAnt_88E(dm_odm, RxIdleAnt); + + pDM_DigTable->AntDiv_RSSI_max = AntDivMaxRSSI; + pDM_DigTable->RSSI_max = MaxRSSI; +} + +void ODM_AntennaDiversity_88E(struct odm_dm_struct *dm_odm) +{ + struct fast_ant_train *dm_fat_tbl = &dm_odm->DM_FatTable; + if ((dm_odm->SupportICType != ODM_RTL8188E) || (!(dm_odm->SupportAbility & ODM_BB_ANT_DIV))) + return; + if (!dm_odm->bLinked) { + ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("ODM_AntennaDiversity_88E(): No Link.\n")); + if (dm_fat_tbl->bBecomeLinked) { + ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Need to Turn off HW AntDiv\n")); + ODM_SetBBReg(dm_odm, ODM_REG_IGI_A_11N, BIT7, 0); /* RegC50[7]=1'b1 enable HW AntDiv */ + ODM_SetBBReg(dm_odm, ODM_REG_CCK_ANTDIV_PARA1_11N, BIT15, 0); /* Enable CCK AntDiv */ + if (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) + ODM_SetBBReg(dm_odm, ODM_REG_TX_ANT_CTRL_11N, BIT21, 0); /* Reg80c[21]=1'b0 from TX Reg */ + dm_fat_tbl->bBecomeLinked = dm_odm->bLinked; + } + return; + } else { + if (!dm_fat_tbl->bBecomeLinked) { + ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Need to Turn on HW AntDiv\n")); + /* Because HW AntDiv is disabled before Link, we enable HW AntDiv after link */ + ODM_SetBBReg(dm_odm, ODM_REG_IGI_A_11N, BIT7, 1); /* RegC50[7]=1'b1 enable HW AntDiv */ + ODM_SetBBReg(dm_odm, ODM_REG_CCK_ANTDIV_PARA1_11N, BIT15, 1); /* Enable CCK AntDiv */ + if (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) + ODM_SetBBReg(dm_odm, ODM_REG_TX_ANT_CTRL_11N, BIT21, 1); /* Reg80c[21]=1'b1 from TX Info */ + dm_fat_tbl->bBecomeLinked = dm_odm->bLinked; + } + } + if ((dm_odm->AntDivType == CG_TRX_HW_ANTDIV) || (dm_odm->AntDivType == CGCS_RX_HW_ANTDIV)) + odm_HWAntDiv(dm_odm); +} + +/* 3============================================================ */ +/* 3 Dynamic Primary CCA */ +/* 3============================================================ */ + +void odm_PrimaryCCA_Init(struct odm_dm_struct *dm_odm) +{ + struct dyn_primary_cca *PrimaryCCA = &(dm_odm->DM_PriCCA); + + PrimaryCCA->DupRTS_flag = 0; + PrimaryCCA->intf_flag = 0; + PrimaryCCA->intf_type = 0; + PrimaryCCA->Monitor_flag = 0; + PrimaryCCA->PriCCA_flag = 0; +} + +bool ODM_DynamicPrimaryCCA_DupRTS(struct odm_dm_struct *dm_odm) +{ + struct dyn_primary_cca *PrimaryCCA = &(dm_odm->DM_PriCCA); + + return PrimaryCCA->DupRTS_flag; +} + +void odm_DynamicPrimaryCCA(struct odm_dm_struct *dm_odm) +{ + return; +} diff --git a/drivers/staging/rtl8188eu/hal/odm_RegConfig8188E.c b/drivers/staging/rtl8188eu/hal/odm_RegConfig8188E.c new file mode 100644 index 0000000000000..18c0533fbd016 --- /dev/null +++ b/drivers/staging/rtl8188eu/hal/odm_RegConfig8188E.c @@ -0,0 +1,130 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#include "odm_precomp.h" + +void odm_ConfigRFReg_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, + u32 Data, enum ODM_RF_RADIO_PATH RF_PATH, + u32 RegAddr) +{ + if (Addr == 0xffe) { + ODM_sleep_ms(50); + } else if (Addr == 0xfd) { + ODM_delay_ms(5); + } else if (Addr == 0xfc) { + ODM_delay_ms(1); + } else if (Addr == 0xfb) { + ODM_delay_us(50); + } else if (Addr == 0xfa) { + ODM_delay_us(5); + } else if (Addr == 0xf9) { + ODM_delay_us(1); + } else { + ODM_SetRFReg(pDM_Odm, RF_PATH, RegAddr, bRFRegOffsetMask, Data); + /* Add 1us delay between BB/RF register setting. */ + ODM_delay_us(1); + } +} + +void odm_ConfigRF_RadioA_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u32 Data) +{ + u32 content = 0x1000; /* RF_Content: radioa_txt */ + u32 maskforPhySet = (u32)(content&0xE000); + + odm_ConfigRFReg_8188E(pDM_Odm, Addr, Data, ODM_RF_PATH_A, Addr|maskforPhySet); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE, ("===> ODM_ConfigRFWithHeaderFile: [RadioA] %08X %08X\n", Addr, Data)); +} + +void odm_ConfigRF_RadioB_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u32 Data) +{ + u32 content = 0x1001; /* RF_Content: radiob_txt */ + u32 maskforPhySet = (u32)(content&0xE000); + + odm_ConfigRFReg_8188E(pDM_Odm, Addr, Data, ODM_RF_PATH_B, Addr|maskforPhySet); + + ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE, ("===> ODM_ConfigRFWithHeaderFile: [RadioB] %08X %08X\n", Addr, Data)); +} + +void odm_ConfigMAC_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u8 Data) +{ + ODM_Write1Byte(pDM_Odm, Addr, Data); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE, ("===> ODM_ConfigMACWithHeaderFile: [MAC_REG] %08X %08X\n", Addr, Data)); +} + +void odm_ConfigBB_AGC_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u32 Bitmask, u32 Data) +{ + ODM_SetBBReg(pDM_Odm, Addr, Bitmask, Data); + /* Add 1us delay between BB/RF register setting. */ + ODM_delay_us(1); + + ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE, + ("===> ODM_ConfigBBWithHeaderFile: [AGC_TAB] %08X %08X\n", + Addr, Data)); +} + +void odm_ConfigBB_PHY_REG_PG_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, + u32 Bitmask, u32 Data) +{ + if (Addr == 0xfe) { + ODM_sleep_ms(50); + } else if (Addr == 0xfd) { + ODM_delay_ms(5); + } else if (Addr == 0xfc) { + ODM_delay_ms(1); + } else if (Addr == 0xfb) { + ODM_delay_us(50); + } else if (Addr == 0xfa) { + ODM_delay_us(5); + } else if (Addr == 0xf9) { + ODM_delay_us(1); + } else{ + ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD, + ("===> @@@@@@@ ODM_ConfigBBWithHeaderFile: [PHY_REG] %08X %08X %08X\n", + Addr, Bitmask, Data)); + storePwrIndexDiffRateOffset(pDM_Odm->Adapter, Addr, Bitmask, Data); + } +} + +void odm_ConfigBB_PHY_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u32 Bitmask, u32 Data) +{ + if (Addr == 0xfe) { + ODM_sleep_ms(50); + } else if (Addr == 0xfd) { + ODM_delay_ms(5); + } else if (Addr == 0xfc) { + ODM_delay_ms(1); + } else if (Addr == 0xfb) { + ODM_delay_us(50); + } else if (Addr == 0xfa) { + ODM_delay_us(5); + } else if (Addr == 0xf9) { + ODM_delay_us(1); + } else { + if (Addr == 0xa24) + pDM_Odm->RFCalibrateInfo.RegA24 = Data; + ODM_SetBBReg(pDM_Odm, Addr, Bitmask, Data); + + /* Add 1us delay between BB/RF register setting. */ + ODM_delay_us(1); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE, + ("===> ODM_ConfigBBWithHeaderFile: [PHY_REG] %08X %08X\n", + Addr, Data)); + } +} diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c b/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c new file mode 100644 index 0000000000000..8c8587754517f --- /dev/null +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c @@ -0,0 +1,779 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTL8188E_CMD_C_ + +#include +#include +#include +#include +#include +#include + +#include + +#define RTL88E_MAX_H2C_BOX_NUMS 4 +#define RTL88E_MAX_CMD_LEN 7 +#define RTL88E_MESSAGE_BOX_SIZE 4 +#define RTL88E_EX_MESSAGE_BOX_SIZE 4 + +static u8 _is_fw_read_cmd_down(struct adapter *adapt, u8 msgbox_num) +{ + u8 read_down = false; + int retry_cnts = 100; + + u8 valid; + + do { + valid = rtw_read8(adapt, REG_HMETFR) & BIT(msgbox_num); + if (0 == valid) + read_down = true; + } while ((!read_down) && (retry_cnts--)); + + return read_down; +} + +/***************************************** +* H2C Msg format : +* 0x1DF - 0x1D0 +*| 31 - 8 | 7-5 4 - 0 | +*| h2c_msg |Class_ID CMD_ID | +* +* Extend 0x1FF - 0x1F0 +*|31 - 0 | +*|ext_msg| +******************************************/ +static s32 FillH2CCmd_88E(struct adapter *adapt, u8 ElementID, u32 CmdLen, u8 *pCmdBuffer) +{ + u8 bcmd_down = false; + s32 retry_cnts = 100; + u8 h2c_box_num; + u32 msgbox_addr; + u32 msgbox_ex_addr; + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + u8 cmd_idx, ext_cmd_len; + u32 h2c_cmd = 0; + u32 h2c_cmd_ex = 0; + s32 ret = _FAIL; + +_func_enter_; + + if (!adapt->bFWReady) { + DBG_88E("FillH2CCmd_88E(): return H2C cmd because fw is not ready\n"); + return ret; + } + + if (!pCmdBuffer) + goto exit; + if (CmdLen > RTL88E_MAX_CMD_LEN) + goto exit; + if (adapt->bSurpriseRemoved) + goto exit; + + /* pay attention to if race condition happened in H2C cmd setting. */ + do { + h2c_box_num = haldata->LastHMEBoxNum; + + if (!_is_fw_read_cmd_down(adapt, h2c_box_num)) { + DBG_88E(" fw read cmd failed...\n"); + goto exit; + } + + *(u8 *)(&h2c_cmd) = ElementID; + + if (CmdLen <= 3) { + memcpy((u8 *)(&h2c_cmd)+1, pCmdBuffer, CmdLen); + } else { + memcpy((u8 *)(&h2c_cmd)+1, pCmdBuffer, 3); + ext_cmd_len = CmdLen-3; + memcpy((u8 *)(&h2c_cmd_ex), pCmdBuffer+3, ext_cmd_len); + + /* Write Ext command */ + msgbox_ex_addr = REG_HMEBOX_EXT_0 + (h2c_box_num * RTL88E_EX_MESSAGE_BOX_SIZE); + for (cmd_idx = 0; cmd_idx < ext_cmd_len; cmd_idx++) { + rtw_write8(adapt, msgbox_ex_addr+cmd_idx, *((u8 *)(&h2c_cmd_ex)+cmd_idx)); + } + } + /* Write command */ + msgbox_addr = REG_HMEBOX_0 + (h2c_box_num * RTL88E_MESSAGE_BOX_SIZE); + for (cmd_idx = 0; cmd_idx < RTL88E_MESSAGE_BOX_SIZE; cmd_idx++) { + rtw_write8(adapt, msgbox_addr+cmd_idx, *((u8 *)(&h2c_cmd)+cmd_idx)); + } + bcmd_down = true; + + haldata->LastHMEBoxNum = (h2c_box_num+1) % RTL88E_MAX_H2C_BOX_NUMS; + + } while ((!bcmd_down) && (retry_cnts--)); + + ret = _SUCCESS; + +exit: + +_func_exit_; + + return ret; +} + +u8 rtl8188e_set_rssi_cmd(struct adapter *adapt, u8 *param) +{ + u8 res = _SUCCESS; + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); +_func_enter_; + + if (haldata->fw_ractrl) { + ; + } else { + DBG_88E("==>%s fw dont support RA\n", __func__); + res = _FAIL; + } + +_func_exit_; + + return res; +} + +u8 rtl8188e_set_raid_cmd(struct adapter *adapt, u32 mask) +{ + u8 buf[3]; + u8 res = _SUCCESS; + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + +_func_enter_; + if (haldata->fw_ractrl) { + __le32 lmask; + + _rtw_memset(buf, 0, 3); + lmask = cpu_to_le32(mask); + memcpy(buf, &lmask, 3); + + FillH2CCmd_88E(adapt, H2C_DM_MACID_CFG, 3, buf); + } else { + DBG_88E("==>%s fw dont support RA\n", __func__); + res = _FAIL; + } + +_func_exit_; + + return res; +} + +/* bitmap[0:27] = tx_rate_bitmap */ +/* bitmap[28:31]= Rate Adaptive id */ +/* arg[0:4] = macid */ +/* arg[5] = Short GI */ +void rtl8188e_Add_RateATid(struct adapter *pAdapter, u32 bitmap, u8 arg, u8 rssi_level) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(pAdapter); + + u8 macid, init_rate, raid, shortGIrate = false; + + macid = arg&0x1f; + + raid = (bitmap>>28) & 0x0f; + bitmap &= 0x0fffffff; + + if (rssi_level != DM_RATR_STA_INIT) + bitmap = ODM_Get_Rate_Bitmap(&haldata->odmpriv, macid, bitmap, rssi_level); + + bitmap |= ((raid<<28)&0xf0000000); + + init_rate = get_highest_rate_idx(bitmap&0x0fffffff)&0x3f; + + shortGIrate = (arg&BIT(5)) ? true : false; + + if (shortGIrate) + init_rate |= BIT(6); + + raid = (bitmap>>28) & 0x0f; + + bitmap &= 0x0fffffff; + + DBG_88E("%s=> mac_id:%d, raid:%d, ra_bitmap=0x%x, shortGIrate=0x%02x\n", + __func__, macid, raid, bitmap, shortGIrate); + + ODM_RA_UpdateRateInfo_8188E(&(haldata->odmpriv), macid, raid, bitmap, shortGIrate); +} + +void rtl8188e_set_FwPwrMode_cmd(struct adapter *adapt, u8 Mode) +{ + struct setpwrmode_parm H2CSetPwrMode; + struct pwrctrl_priv *pwrpriv = &adapt->pwrctrlpriv; + u8 RLBM = 0; /* 0:Min, 1:Max, 2:User define */ +_func_enter_; + + DBG_88E("%s: Mode=%d SmartPS=%d UAPSD=%d\n", __func__, + Mode, pwrpriv->smart_ps, adapt->registrypriv.uapsd_enable); + + switch (Mode) { + case PS_MODE_ACTIVE: + H2CSetPwrMode.Mode = 0; + break; + case PS_MODE_MIN: + H2CSetPwrMode.Mode = 1; + break; + case PS_MODE_MAX: + RLBM = 1; + H2CSetPwrMode.Mode = 1; + break; + case PS_MODE_DTIM: + RLBM = 2; + H2CSetPwrMode.Mode = 1; + break; + case PS_MODE_UAPSD_WMM: + H2CSetPwrMode.Mode = 2; + break; + default: + H2CSetPwrMode.Mode = 0; + break; + } + + H2CSetPwrMode.SmartPS_RLBM = (((pwrpriv->smart_ps<<4)&0xf0) | (RLBM & 0x0f)); + + H2CSetPwrMode.AwakeInterval = 1; + + H2CSetPwrMode.bAllQueueUAPSD = adapt->registrypriv.uapsd_enable; + + if (Mode > 0) + H2CSetPwrMode.PwrState = 0x00;/* AllON(0x0C), RFON(0x04), RFOFF(0x00) */ + else + H2CSetPwrMode.PwrState = 0x0C;/* AllON(0x0C), RFON(0x04), RFOFF(0x00) */ + + FillH2CCmd_88E(adapt, H2C_PS_PWR_MODE, sizeof(H2CSetPwrMode), (u8 *)&H2CSetPwrMode); + +_func_exit_; +} + +void rtl8188e_set_FwMediaStatus_cmd(struct adapter *adapt, __le16 mstatus_rpt) +{ + u8 opmode, macid; + u16 mst_rpt = le16_to_cpu(mstatus_rpt); + opmode = (u8) mst_rpt; + macid = (u8)(mst_rpt >> 8); + + DBG_88E("### %s: MStatus=%x MACID=%d\n", __func__, opmode, macid); + FillH2CCmd_88E(adapt, H2C_COM_MEDIA_STATUS_RPT, sizeof(mst_rpt), (u8 *)&mst_rpt); +} + +static void ConstructBeacon(struct adapter *adapt, u8 *pframe, u32 *pLength) +{ + struct rtw_ieee80211_hdr *pwlanhdr; + u16 *fctrl; + u32 rate_len, pktlen; + struct mlme_ext_priv *pmlmeext = &(adapt->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); + u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + + memcpy(pwlanhdr->addr1, bc_addr, ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&(adapt->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr3, get_my_bssid(cur_network), ETH_ALEN); + + SetSeqNum(pwlanhdr, 0/*pmlmeext->mgnt_seq*/); + SetFrameSubType(pframe, WIFI_BEACON); + + pframe += sizeof(struct rtw_ieee80211_hdr_3addr); + pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); + + /* timestamp will be inserted by hardware */ + pframe += 8; + pktlen += 8; + + /* beacon interval: 2 bytes */ + memcpy(pframe, (unsigned char *)(rtw_get_beacon_interval_from_ie(cur_network->IEs)), 2); + + pframe += 2; + pktlen += 2; + + /* capability info: 2 bytes */ + memcpy(pframe, (unsigned char *)(rtw_get_capability_from_ie(cur_network->IEs)), 2); + + pframe += 2; + pktlen += 2; + + if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) { + pktlen += cur_network->IELength - sizeof(struct ndis_802_11_fixed_ie); + memcpy(pframe, cur_network->IEs+sizeof(struct ndis_802_11_fixed_ie), pktlen); + + goto _ConstructBeacon; + } + + /* below for ad-hoc mode */ + + /* SSID */ + pframe = rtw_set_ie(pframe, _SSID_IE_, cur_network->Ssid.SsidLength, cur_network->Ssid.Ssid, &pktlen); + + /* supported rates... */ + rate_len = rtw_get_rateset_len(cur_network->SupportedRates); + pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, ((rate_len > 8) ? 8 : rate_len), cur_network->SupportedRates, &pktlen); + + /* DS parameter set */ + pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&(cur_network->Configuration.DSConfig), &pktlen); + + if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { + u32 ATIMWindow; + /* IBSS Parameter Set... */ + ATIMWindow = 0; + pframe = rtw_set_ie(pframe, _IBSS_PARA_IE_, 2, (unsigned char *)(&ATIMWindow), &pktlen); + } + + /* todo: ERP IE */ + + /* EXTERNDED SUPPORTED RATE */ + if (rate_len > 8) + pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (rate_len - 8), (cur_network->SupportedRates + 8), &pktlen); + + /* todo:HT for adhoc */ + +_ConstructBeacon: + + if ((pktlen + TXDESC_SIZE) > 512) { + DBG_88E("beacon frame too large\n"); + return; + } + + *pLength = pktlen; +} + +static void ConstructPSPoll(struct adapter *adapt, u8 *pframe, u32 *pLength) +{ + struct rtw_ieee80211_hdr *pwlanhdr; + struct mlme_ext_priv *pmlmeext = &(adapt->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + u16 *fctrl; + + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + /* Frame control. */ + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + SetPwrMgt(fctrl); + SetFrameSubType(pframe, WIFI_PSPOLL); + + /* AID. */ + SetDuration(pframe, (pmlmeinfo->aid | 0xc000)); + + /* BSSID. */ + memcpy(pwlanhdr->addr1, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); + + /* TA. */ + memcpy(pwlanhdr->addr2, myid(&(adapt->eeprompriv)), ETH_ALEN); + + *pLength = 16; +} + +static void ConstructNullFunctionData(struct adapter *adapt, u8 *pframe, + u32 *pLength, + u8 *StaAddr, + u8 bQoS, + u8 AC, + u8 bEosp, + u8 bForcePowerSave) +{ + struct rtw_ieee80211_hdr *pwlanhdr; + u16 *fctrl; + u32 pktlen; + struct mlme_priv *pmlmepriv = &adapt->mlmepriv; + struct wlan_network *cur_network = &pmlmepriv->cur_network; + struct mlme_ext_priv *pmlmeext = &(adapt->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + fctrl = &pwlanhdr->frame_ctl; + *(fctrl) = 0; + if (bForcePowerSave) + SetPwrMgt(fctrl); + + switch (cur_network->network.InfrastructureMode) { + case Ndis802_11Infrastructure: + SetToDs(fctrl); + memcpy(pwlanhdr->addr1, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&(adapt->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr3, StaAddr, ETH_ALEN); + break; + case Ndis802_11APMode: + SetFrDs(fctrl); + memcpy(pwlanhdr->addr1, StaAddr, ETH_ALEN); + memcpy(pwlanhdr->addr2, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); + memcpy(pwlanhdr->addr3, myid(&(adapt->eeprompriv)), ETH_ALEN); + break; + case Ndis802_11IBSS: + default: + memcpy(pwlanhdr->addr1, StaAddr, ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&(adapt->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr3, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); + break; + } + + SetSeqNum(pwlanhdr, 0); + + if (bQoS) { + struct rtw_ieee80211_hdr_3addr_qos *pwlanqoshdr; + + SetFrameSubType(pframe, WIFI_QOS_DATA_NULL); + + pwlanqoshdr = (struct rtw_ieee80211_hdr_3addr_qos *)pframe; + SetPriority(&pwlanqoshdr->qc, AC); + SetEOSP(&pwlanqoshdr->qc, bEosp); + + pktlen = sizeof(struct rtw_ieee80211_hdr_3addr_qos); + } else { + SetFrameSubType(pframe, WIFI_DATA_NULL); + + pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); + } + + *pLength = pktlen; +} + +static void ConstructProbeRsp(struct adapter *adapt, u8 *pframe, u32 *pLength, u8 *StaAddr, bool bHideSSID) +{ + struct rtw_ieee80211_hdr *pwlanhdr; + u16 *fctrl; + u8 *mac, *bssid; + u32 pktlen; + struct mlme_ext_priv *pmlmeext = &(adapt->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); + + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + mac = myid(&(adapt->eeprompriv)); + bssid = cur_network->MacAddress; + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + memcpy(pwlanhdr->addr1, StaAddr, ETH_ALEN); + memcpy(pwlanhdr->addr2, mac, ETH_ALEN); + memcpy(pwlanhdr->addr3, bssid, ETH_ALEN); + + SetSeqNum(pwlanhdr, 0); + SetFrameSubType(fctrl, WIFI_PROBERSP); + + pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); + pframe += pktlen; + + if (cur_network->IELength > MAX_IE_SZ) + return; + + memcpy(pframe, cur_network->IEs, cur_network->IELength); + pframe += cur_network->IELength; + pktlen += cur_network->IELength; + + *pLength = pktlen; +} + +/* To check if reserved page content is destroyed by beacon beacuse beacon is too large. */ +/* 2010.06.23. Added by tynli. */ +void CheckFwRsvdPageContent(struct adapter *Adapter) +{ +} + +/* */ +/* Description: Fill the reserved packets that FW will use to RSVD page. */ +/* Now we just send 4 types packet to rsvd page. */ +/* (1)Beacon, (2)Ps-poll, (3)Null data, (4)ProbeRsp. */ +/* Input: */ +/* bDLFinished - false: At the first time we will send all the packets as a large packet to Hw, */ +/* so we need to set the packet length to total lengh. */ +/* true: At the second time, we should send the first packet (default:beacon) */ +/* to Hw again and set the lengh in descriptor to the real beacon lengh. */ +/* 2009.10.15 by tynli. */ +static void SetFwRsvdPagePkt(struct adapter *adapt, bool bDLFinished) +{ + struct hal_data_8188e *haldata; + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + struct xmit_priv *pxmitpriv; + struct mlme_ext_priv *pmlmeext; + struct mlme_ext_info *pmlmeinfo; + u32 BeaconLength = 0, ProbeRspLength = 0, PSPollLength; + u32 NullDataLength, QosNullLength; + u8 *ReservedPagePacket; + u8 PageNum, PageNeed, TxDescLen; + u16 BufIndex; + u32 TotalPacketLen; + struct rsvdpage_loc RsvdPageLoc; + + DBG_88E("%s\n", __func__); + ReservedPagePacket = (u8 *)rtw_zmalloc(1000); + if (ReservedPagePacket == NULL) { + DBG_88E("%s: alloc ReservedPagePacket fail!\n", __func__); + return; + } + + haldata = GET_HAL_DATA(adapt); + pxmitpriv = &adapt->xmitpriv; + pmlmeext = &adapt->mlmeextpriv; + pmlmeinfo = &pmlmeext->mlmext_info; + + TxDescLen = TXDESC_SIZE; + PageNum = 0; + + /* 3 (1) beacon * 2 pages */ + BufIndex = TXDESC_OFFSET; + ConstructBeacon(adapt, &ReservedPagePacket[BufIndex], &BeaconLength); + + /* When we count the first page size, we need to reserve description size for the RSVD */ + /* packet, it will be filled in front of the packet in TXPKTBUF. */ + PageNeed = (u8)PageNum_128(TxDescLen + BeaconLength); + /* To reserved 2 pages for beacon buffer. 2010.06.24. */ + if (PageNeed == 1) + PageNeed += 1; + PageNum += PageNeed; + haldata->FwRsvdPageStartOffset = PageNum; + + BufIndex += PageNeed*128; + + /* 3 (2) ps-poll *1 page */ + RsvdPageLoc.LocPsPoll = PageNum; + ConstructPSPoll(adapt, &ReservedPagePacket[BufIndex], &PSPollLength); + rtl8188e_fill_fake_txdesc(adapt, &ReservedPagePacket[BufIndex-TxDescLen], PSPollLength, true, false); + + PageNeed = (u8)PageNum_128(TxDescLen + PSPollLength); + PageNum += PageNeed; + + BufIndex += PageNeed*128; + + /* 3 (3) null data * 1 page */ + RsvdPageLoc.LocNullData = PageNum; + ConstructNullFunctionData(adapt, &ReservedPagePacket[BufIndex], &NullDataLength, get_my_bssid(&pmlmeinfo->network), false, 0, 0, false); + rtl8188e_fill_fake_txdesc(adapt, &ReservedPagePacket[BufIndex-TxDescLen], NullDataLength, false, false); + + PageNeed = (u8)PageNum_128(TxDescLen + NullDataLength); + PageNum += PageNeed; + + BufIndex += PageNeed*128; + + /* 3 (4) probe response * 1page */ + RsvdPageLoc.LocProbeRsp = PageNum; + ConstructProbeRsp(adapt, &ReservedPagePacket[BufIndex], &ProbeRspLength, get_my_bssid(&pmlmeinfo->network), false); + rtl8188e_fill_fake_txdesc(adapt, &ReservedPagePacket[BufIndex-TxDescLen], ProbeRspLength, false, false); + + PageNeed = (u8)PageNum_128(TxDescLen + ProbeRspLength); + PageNum += PageNeed; + + BufIndex += PageNeed*128; + + /* 3 (5) Qos null data */ + RsvdPageLoc.LocQosNull = PageNum; + ConstructNullFunctionData(adapt, &ReservedPagePacket[BufIndex], + &QosNullLength, get_my_bssid(&pmlmeinfo->network), true, 0, 0, false); + rtl8188e_fill_fake_txdesc(adapt, &ReservedPagePacket[BufIndex-TxDescLen], QosNullLength, false, false); + + PageNeed = (u8)PageNum_128(TxDescLen + QosNullLength); + PageNum += PageNeed; + + TotalPacketLen = BufIndex + QosNullLength; + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + goto exit; + + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(adapt, pattrib); + pattrib->qsel = 0x10; + pattrib->last_txcmdsz = TotalPacketLen - TXDESC_OFFSET; + pattrib->pktlen = pattrib->last_txcmdsz; + memcpy(pmgntframe->buf_addr, ReservedPagePacket, TotalPacketLen); + + rtw_hal_mgnt_xmit(adapt, pmgntframe); + + DBG_88E("%s: Set RSVD page location to Fw\n", __func__); + FillH2CCmd_88E(adapt, H2C_COM_RSVD_PAGE, sizeof(RsvdPageLoc), (u8 *)&RsvdPageLoc); + +exit: + kfree(ReservedPagePacket); +} + +void rtl8188e_set_FwJoinBssReport_cmd(struct adapter *adapt, u8 mstatus) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + struct mlme_ext_priv *pmlmeext = &(adapt->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + bool bSendBeacon = false; + bool bcn_valid = false; + u8 DLBcnCount = 0; + u32 poll = 0; + +_func_enter_; + + DBG_88E("%s mstatus(%x)\n", __func__, mstatus); + + if (mstatus == 1) { + /* We should set AID, correct TSF, HW seq enable before set JoinBssReport to Fw in 88/92C. */ + /* Suggested by filen. Added by tynli. */ + rtw_write16(adapt, REG_BCN_PSR_RPT, (0xC000|pmlmeinfo->aid)); + /* Do not set TSF again here or vWiFi beacon DMA INT will not work. */ + + /* Set REG_CR bit 8. DMA beacon by SW. */ + haldata->RegCR_1 |= BIT0; + rtw_write8(adapt, REG_CR+1, haldata->RegCR_1); + + /* Disable Hw protection for a time which revserd for Hw sending beacon. */ + /* Fix download reserved page packet fail that access collision with the protection time. */ + /* 2010.05.11. Added by tynli. */ + rtw_write8(adapt, REG_BCN_CTRL, rtw_read8(adapt, REG_BCN_CTRL)&(~BIT(3))); + rtw_write8(adapt, REG_BCN_CTRL, rtw_read8(adapt, REG_BCN_CTRL)|BIT(4)); + + if (haldata->RegFwHwTxQCtrl&BIT6) { + DBG_88E("HalDownloadRSVDPage(): There is an Adapter is sending beacon.\n"); + bSendBeacon = true; + } + + /* Set FWHW_TXQ_CTRL 0x422[6]=0 to tell Hw the packet is not a real beacon frame. */ + rtw_write8(adapt, REG_FWHW_TXQ_CTRL+2, (haldata->RegFwHwTxQCtrl&(~BIT6))); + haldata->RegFwHwTxQCtrl &= (~BIT6); + + /* Clear beacon valid check bit. */ + rtw_hal_set_hwreg(adapt, HW_VAR_BCN_VALID, NULL); + DLBcnCount = 0; + poll = 0; + do { + /* download rsvd page. */ + SetFwRsvdPagePkt(adapt, false); + DLBcnCount++; + do { + rtw_yield_os(); + /* rtw_mdelay_os(10); */ + /* check rsvd page download OK. */ + rtw_hal_get_hwreg(adapt, HW_VAR_BCN_VALID, (u8 *)(&bcn_valid)); + poll++; + } while (!bcn_valid && (poll%10) != 0 && !adapt->bSurpriseRemoved && !adapt->bDriverStopped); + } while (!bcn_valid && DLBcnCount <= 100 && !adapt->bSurpriseRemoved && !adapt->bDriverStopped); + + if (adapt->bSurpriseRemoved || adapt->bDriverStopped) + ; + else if (!bcn_valid) + DBG_88E("%s: 1 Download RSVD page failed! DLBcnCount:%u, poll:%u\n", __func__, DLBcnCount, poll); + else + DBG_88E("%s: 1 Download RSVD success! DLBcnCount:%u, poll:%u\n", __func__, DLBcnCount, poll); + /* */ + /* We just can send the reserved page twice during the time that Tx thread is stopped (e.g. pnpsetpower) */ + /* becuase we need to free the Tx BCN Desc which is used by the first reserved page packet. */ + /* At run time, we cannot get the Tx Desc until it is released in TxHandleInterrupt() so we will return */ + /* the beacon TCB in the following code. 2011.11.23. by tynli. */ + /* */ + + /* Enable Bcn */ + rtw_write8(adapt, REG_BCN_CTRL, rtw_read8(adapt, REG_BCN_CTRL)|BIT(3)); + rtw_write8(adapt, REG_BCN_CTRL, rtw_read8(adapt, REG_BCN_CTRL)&(~BIT(4))); + + /* To make sure that if there exists an adapter which would like to send beacon. */ + /* If exists, the origianl value of 0x422[6] will be 1, we should check this to */ + /* prevent from setting 0x422[6] to 0 after download reserved page, or it will cause */ + /* the beacon cannot be sent by HW. */ + /* 2010.06.23. Added by tynli. */ + if (bSendBeacon) { + rtw_write8(adapt, REG_FWHW_TXQ_CTRL+2, (haldata->RegFwHwTxQCtrl|BIT6)); + haldata->RegFwHwTxQCtrl |= BIT6; + } + + /* Update RSVD page location H2C to Fw. */ + if (bcn_valid) { + rtw_hal_set_hwreg(adapt, HW_VAR_BCN_VALID, NULL); + DBG_88E("Set RSVD page location to Fw.\n"); + } + + /* Do not enable HW DMA BCN or it will cause Pcie interface hang by timing issue. 2011.11.24. by tynli. */ + /* Clear CR[8] or beacon packet will not be send to TxBuf anymore. */ + haldata->RegCR_1 &= (~BIT0); + rtw_write8(adapt, REG_CR+1, haldata->RegCR_1); + } +_func_exit_; +} + +void rtl8188e_set_p2p_ps_offload_cmd(struct adapter *adapt, u8 p2p_ps_state) +{ +#ifdef CONFIG_88EU_P2P + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + struct wifidirect_info *pwdinfo = &(adapt->wdinfo); + struct P2P_PS_Offload_t *p2p_ps_offload = &haldata->p2p_ps_offload; + u8 i; + +_func_enter_; + + switch (p2p_ps_state) { + case P2P_PS_DISABLE: + DBG_88E("P2P_PS_DISABLE\n"); + _rtw_memset(p2p_ps_offload, 0, 1); + break; + case P2P_PS_ENABLE: + DBG_88E("P2P_PS_ENABLE\n"); + /* update CTWindow value. */ + if (pwdinfo->ctwindow > 0) { + p2p_ps_offload->CTWindow_En = 1; + rtw_write8(adapt, REG_P2P_CTWIN, pwdinfo->ctwindow); + } + + /* hw only support 2 set of NoA */ + for (i = 0; i < pwdinfo->noa_num; i++) { + /* To control the register setting for which NOA */ + rtw_write8(adapt, REG_NOA_DESC_SEL, (i << 4)); + if (i == 0) + p2p_ps_offload->NoA0_En = 1; + else + p2p_ps_offload->NoA1_En = 1; + + /* config P2P NoA Descriptor Register */ + rtw_write32(adapt, REG_NOA_DESC_DURATION, pwdinfo->noa_duration[i]); + rtw_write32(adapt, REG_NOA_DESC_INTERVAL, pwdinfo->noa_interval[i]); + rtw_write32(adapt, REG_NOA_DESC_START, pwdinfo->noa_start_time[i]); + rtw_write8(adapt, REG_NOA_DESC_COUNT, pwdinfo->noa_count[i]); + } + + if ((pwdinfo->opp_ps == 1) || (pwdinfo->noa_num > 0)) { + /* rst p2p circuit */ + rtw_write8(adapt, REG_DUAL_TSF_RST, BIT(4)); + + p2p_ps_offload->Offload_En = 1; + + if (pwdinfo->role == P2P_ROLE_GO) { + p2p_ps_offload->role = 1; + p2p_ps_offload->AllStaSleep = 0; + } else { + p2p_ps_offload->role = 0; + } + + p2p_ps_offload->discovery = 0; + } + break; + case P2P_PS_SCAN: + DBG_88E("P2P_PS_SCAN\n"); + p2p_ps_offload->discovery = 1; + break; + case P2P_PS_SCAN_DONE: + DBG_88E("P2P_PS_SCAN_DONE\n"); + p2p_ps_offload->discovery = 0; + pwdinfo->p2p_ps_state = P2P_PS_ENABLE; + break; + default: + break; + } + + FillH2CCmd_88E(adapt, H2C_PS_P2P_OFFLOAD, 1, (u8 *)p2p_ps_offload); +#endif + +_func_exit_; +} diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_dm.c b/drivers/staging/rtl8188eu/hal/rtl8188e_dm.c new file mode 100644 index 0000000000000..9c2e7a20c09ea --- /dev/null +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_dm.c @@ -0,0 +1,268 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +/* */ +/* Description: */ +/* */ +/* This file is for 92CE/92CU dynamic mechanism only */ +/* */ +/* */ +/* */ +#define _RTL8188E_DM_C_ + +#include +#include + +#include + +static void dm_CheckStatistics(struct adapter *Adapter) +{ +} + +/* Initialize GPIO setting registers */ +static void dm_InitGPIOSetting(struct adapter *Adapter) +{ + u8 tmp1byte; + + tmp1byte = rtw_read8(Adapter, REG_GPIO_MUXCFG); + tmp1byte &= (GPIOSEL_GPIO | ~GPIOSEL_ENBT); + + rtw_write8(Adapter, REG_GPIO_MUXCFG, tmp1byte); +} + +/* */ +/* functions */ +/* */ +static void Init_ODM_ComInfo_88E(struct adapter *Adapter) +{ + struct hal_data_8188e *hal_data = GET_HAL_DATA(Adapter); + struct dm_priv *pdmpriv = &hal_data->dmpriv; + struct odm_dm_struct *dm_odm = &(hal_data->odmpriv); + u8 cut_ver, fab_ver; + + /* Init Value */ + _rtw_memset(dm_odm, 0, sizeof(dm_odm)); + + dm_odm->Adapter = Adapter; + + ODM_CmnInfoInit(dm_odm, ODM_CMNINFO_PLATFORM, ODM_CE); + + if (Adapter->interface_type == RTW_GSPI) + ODM_CmnInfoInit(dm_odm, ODM_CMNINFO_INTERFACE, ODM_ITRF_SDIO); + else + ODM_CmnInfoInit(dm_odm, ODM_CMNINFO_INTERFACE, Adapter->interface_type);/* RTL871X_HCI_TYPE */ + + ODM_CmnInfoInit(dm_odm, ODM_CMNINFO_IC_TYPE, ODM_RTL8188E); + + fab_ver = ODM_TSMC; + cut_ver = ODM_CUT_A; + + ODM_CmnInfoInit(dm_odm, ODM_CMNINFO_FAB_VER, fab_ver); + ODM_CmnInfoInit(dm_odm, ODM_CMNINFO_CUT_VER, cut_ver); + + ODM_CmnInfoInit(dm_odm, ODM_CMNINFO_MP_TEST_CHIP, IS_NORMAL_CHIP(hal_data->VersionID)); + + ODM_CmnInfoInit(dm_odm, ODM_CMNINFO_PATCH_ID, hal_data->CustomerID); + ODM_CmnInfoInit(dm_odm, ODM_CMNINFO_BWIFI_TEST, Adapter->registrypriv.wifi_spec); + + + if (hal_data->rf_type == RF_1T1R) + ODM_CmnInfoUpdate(dm_odm, ODM_CMNINFO_RF_TYPE, ODM_1T1R); + else if (hal_data->rf_type == RF_2T2R) + ODM_CmnInfoUpdate(dm_odm, ODM_CMNINFO_RF_TYPE, ODM_2T2R); + else if (hal_data->rf_type == RF_1T2R) + ODM_CmnInfoUpdate(dm_odm, ODM_CMNINFO_RF_TYPE, ODM_1T2R); + + ODM_CmnInfoInit(dm_odm, ODM_CMNINFO_RF_ANTENNA_TYPE, hal_data->TRxAntDivType); + + pdmpriv->InitODMFlag = ODM_RF_CALIBRATION | + ODM_RF_TX_PWR_TRACK; + + ODM_CmnInfoUpdate(dm_odm, ODM_CMNINFO_ABILITY, pdmpriv->InitODMFlag); +} + +static void Update_ODM_ComInfo_88E(struct adapter *Adapter) +{ + struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; + struct mlme_priv *pmlmepriv = &Adapter->mlmepriv; + struct pwrctrl_priv *pwrctrlpriv = &Adapter->pwrctrlpriv; + struct hal_data_8188e *hal_data = GET_HAL_DATA(Adapter); + struct odm_dm_struct *dm_odm = &(hal_data->odmpriv); + struct dm_priv *pdmpriv = &hal_data->dmpriv; + int i; + + pdmpriv->InitODMFlag = ODM_BB_DIG | + ODM_BB_RA_MASK | + ODM_BB_DYNAMIC_TXPWR | + ODM_BB_FA_CNT | + ODM_BB_RSSI_MONITOR | + ODM_BB_CCK_PD | + ODM_BB_PWR_SAVE | + ODM_MAC_EDCA_TURBO | + ODM_RF_CALIBRATION | + ODM_RF_TX_PWR_TRACK; + if (hal_data->AntDivCfg) + pdmpriv->InitODMFlag |= ODM_BB_ANT_DIV; + + if (Adapter->registrypriv.mp_mode == 1) { + pdmpriv->InitODMFlag = ODM_RF_CALIBRATION | + ODM_RF_TX_PWR_TRACK; + } + + ODM_CmnInfoUpdate(dm_odm, ODM_CMNINFO_ABILITY, pdmpriv->InitODMFlag); + + ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_TX_UNI, &(Adapter->xmitpriv.tx_bytes)); + ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_RX_UNI, &(Adapter->recvpriv.rx_bytes)); + ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_WM_MODE, &(pmlmeext->cur_wireless_mode)); + ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_SEC_CHNL_OFFSET, &(hal_data->nCur40MhzPrimeSC)); + ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_SEC_MODE, &(Adapter->securitypriv.dot11PrivacyAlgrthm)); + ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_BW, &(hal_data->CurrentChannelBW)); + ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_CHNL, &(hal_data->CurrentChannel)); + ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_NET_CLOSED, &(Adapter->net_closed)); + ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_MP_MODE, &(Adapter->registrypriv.mp_mode)); + ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_SCAN, &(pmlmepriv->bScanInProcess)); + ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_POWER_SAVING, &(pwrctrlpriv->bpower_saving)); + ODM_CmnInfoInit(dm_odm, ODM_CMNINFO_RF_ANTENNA_TYPE, hal_data->TRxAntDivType); + + for (i = 0; i < NUM_STA; i++) + ODM_CmnInfoPtrArrayHook(dm_odm, ODM_CMNINFO_STA_STATUS, i, NULL); +} + +void rtl8188e_InitHalDm(struct adapter *Adapter) +{ + struct hal_data_8188e *hal_data = GET_HAL_DATA(Adapter); + struct dm_priv *pdmpriv = &hal_data->dmpriv; + struct odm_dm_struct *dm_odm = &(hal_data->odmpriv); + + dm_InitGPIOSetting(Adapter); + pdmpriv->DM_Type = DM_Type_ByDriver; + pdmpriv->DMFlag = DYNAMIC_FUNC_DISABLE; + Update_ODM_ComInfo_88E(Adapter); + ODM_DMInit(dm_odm); + Adapter->fix_rate = 0xFF; +} + +void rtl8188e_HalDmWatchDog(struct adapter *Adapter) +{ + bool fw_cur_in_ps = false; + bool fw_ps_awake = true; + u8 hw_init_completed = false; + struct hal_data_8188e *hal_data = GET_HAL_DATA(Adapter); + + _func_enter_; + hw_init_completed = Adapter->hw_init_completed; + + if (!hw_init_completed) + goto skip_dm; + + fw_cur_in_ps = Adapter->pwrctrlpriv.bFwCurrentInPSMode; + rtw_hal_get_hwreg(Adapter, HW_VAR_FWLPS_RF_ON, (u8 *)(&fw_ps_awake)); + + /* Fw is under p2p powersaving mode, driver should stop dynamic mechanism. */ + /* modifed by thomas. 2011.06.11. */ + if (Adapter->wdinfo.p2p_ps_mode) + fw_ps_awake = false; + + if (hw_init_completed && ((!fw_cur_in_ps) && fw_ps_awake)) { + /* Calculate Tx/Rx statistics. */ + dm_CheckStatistics(Adapter); + + _func_exit_; + } + + /* ODM */ + if (hw_init_completed) { + struct mlme_priv *pmlmepriv = &Adapter->mlmepriv; + u8 bLinked = false; + + if ((check_fwstate(pmlmepriv, WIFI_AP_STATE)) || + (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE | WIFI_ADHOC_MASTER_STATE))) { + if (Adapter->stapriv.asoc_sta_count > 2) + bLinked = true; + } else {/* Station mode */ + if (check_fwstate(pmlmepriv, _FW_LINKED)) + bLinked = true; + } + + ODM_CmnInfoUpdate(&hal_data->odmpriv, ODM_CMNINFO_LINK, bLinked); + ODM_DMWatchdog(&hal_data->odmpriv); + } +skip_dm: + /* Check GPIO to determine current RF on/off and Pbc status. */ + /* Check Hardware Radio ON/OFF or not */ + return; +} + +void rtl8188e_init_dm_priv(struct adapter *Adapter) +{ + struct hal_data_8188e *hal_data = GET_HAL_DATA(Adapter); + struct dm_priv *pdmpriv = &hal_data->dmpriv; + struct odm_dm_struct *podmpriv = &hal_data->odmpriv; + + _rtw_memset(pdmpriv, 0, sizeof(struct dm_priv)); + Init_ODM_ComInfo_88E(Adapter); + ODM_InitDebugSetting(podmpriv); +} + +void rtl8188e_deinit_dm_priv(struct adapter *Adapter) +{ +} + +/* Add new function to reset the state of antenna diversity before link. */ +/* Compare RSSI for deciding antenna */ +void AntDivCompare8188E(struct adapter *Adapter, struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src) +{ + struct hal_data_8188e *hal_data = GET_HAL_DATA(Adapter); + + if (0 != hal_data->AntDivCfg) { + /* select optimum_antenna for before linked =>For antenna diversity */ + if (dst->Rssi >= src->Rssi) {/* keep org parameter */ + src->Rssi = dst->Rssi; + src->PhyInfo.Optimum_antenna = dst->PhyInfo.Optimum_antenna; + } + } +} + +/* Add new function to reset the state of antenna diversity before link. */ +u8 AntDivBeforeLink8188E(struct adapter *Adapter) +{ + struct hal_data_8188e *hal_data = GET_HAL_DATA(Adapter); + struct odm_dm_struct *dm_odm = &hal_data->odmpriv; + struct sw_ant_switch *dm_swat_tbl = &dm_odm->DM_SWAT_Table; + struct mlme_priv *pmlmepriv = &(Adapter->mlmepriv); + + /* Condition that does not need to use antenna diversity. */ + if (hal_data->AntDivCfg == 0) + return false; + + if (check_fwstate(pmlmepriv, _FW_LINKED)) + return false; + + if (dm_swat_tbl->SWAS_NoLink_State == 0) { + /* switch channel */ + dm_swat_tbl->SWAS_NoLink_State = 1; + dm_swat_tbl->CurAntenna = (dm_swat_tbl->CurAntenna == Antenna_A) ? Antenna_B : Antenna_A; + + rtw_antenna_select_cmd(Adapter, dm_swat_tbl->CurAntenna, false); + return true; + } else { + dm_swat_tbl->SWAS_NoLink_State = 0; + return false; + } +} -- GitLab From 615a4d12e55690269ce07e183553cb2752e1fa29 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 21 Aug 2013 22:33:56 -0500 Subject: [PATCH 772/942] staging: r8188eu: Add files for new driver - part 14 This commit adds files hal/rtl8188e_hal_init.c, hal/rtl8188e_mp.c, hal/rtl8188e_phycfg.c, and hal/rtl8188e_rf6052.c. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8188eu/hal/rtl8188e_hal_init.c | 2378 +++++++++++++++++ drivers/staging/rtl8188eu/hal/rtl8188e_mp.c | 860 ++++++ .../staging/rtl8188eu/hal/rtl8188e_phycfg.c | 1144 ++++++++ .../staging/rtl8188eu/hal/rtl8188e_rf6052.c | 572 ++++ 4 files changed, 4954 insertions(+) create mode 100644 drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c create mode 100644 drivers/staging/rtl8188eu/hal/rtl8188e_mp.c create mode 100644 drivers/staging/rtl8188eu/hal/rtl8188e_phycfg.c create mode 100644 drivers/staging/rtl8188eu/hal/rtl8188e_rf6052.c diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c new file mode 100644 index 0000000000000..292ba62d722f6 --- /dev/null +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c @@ -0,0 +1,2378 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _HAL_INIT_C_ + +#include +#include + +#include + +#include + +#include + +static void iol_mode_enable(struct adapter *padapter, u8 enable) +{ + u8 reg_0xf0 = 0; + + if (enable) { + /* Enable initial offload */ + reg_0xf0 = rtw_read8(padapter, REG_SYS_CFG); + rtw_write8(padapter, REG_SYS_CFG, reg_0xf0|SW_OFFLOAD_EN); + + if (!padapter->bFWReady) { + DBG_88E("bFWReady == false call reset 8051...\n"); + _8051Reset88E(padapter); + } + + } else { + /* disable initial offload */ + reg_0xf0 = rtw_read8(padapter, REG_SYS_CFG); + rtw_write8(padapter, REG_SYS_CFG, reg_0xf0 & ~SW_OFFLOAD_EN); + } +} + +static s32 iol_execute(struct adapter *padapter, u8 control) +{ + s32 status = _FAIL; + u8 reg_0x88 = 0; + u32 start = 0, passing_time = 0; + + control = control&0x0f; + reg_0x88 = rtw_read8(padapter, REG_HMEBOX_E0); + rtw_write8(padapter, REG_HMEBOX_E0, reg_0x88|control); + + start = rtw_get_current_time(); + while ((reg_0x88 = rtw_read8(padapter, REG_HMEBOX_E0)) & control && + (passing_time = rtw_get_passing_time_ms(start)) < 1000) { + ; + } + + reg_0x88 = rtw_read8(padapter, REG_HMEBOX_E0); + status = (reg_0x88 & control) ? _FAIL : _SUCCESS; + if (reg_0x88 & control<<4) + status = _FAIL; + return status; +} + +static s32 iol_InitLLTTable(struct adapter *padapter, u8 txpktbuf_bndy) +{ + s32 rst = _SUCCESS; + iol_mode_enable(padapter, 1); + rtw_write8(padapter, REG_TDECTRL+1, txpktbuf_bndy); + rst = iol_execute(padapter, CMD_INIT_LLT); + iol_mode_enable(padapter, 0); + return rst; +} + +static void +efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8 *pbuf) +{ + u8 *efuseTbl = NULL; + u8 rtemp8; + u16 eFuse_Addr = 0; + u8 offset, wren; + u16 i, j; + u16 **eFuseWord = NULL; + u16 efuse_utilized = 0; + u8 u1temp = 0; + + efuseTbl = (u8 *)rtw_zmalloc(EFUSE_MAP_LEN_88E); + if (efuseTbl == NULL) { + DBG_88E("%s: alloc efuseTbl fail!\n", __func__); + goto exit; + } + + eFuseWord = (u16 **)rtw_malloc2d(EFUSE_MAX_SECTION_88E, EFUSE_MAX_WORD_UNIT, sizeof(u16)); + if (eFuseWord == NULL) { + DBG_88E("%s: alloc eFuseWord fail!\n", __func__); + goto exit; + } + + /* 0. Refresh efuse init map as all oxFF. */ + for (i = 0; i < EFUSE_MAX_SECTION_88E; i++) + for (j = 0; j < EFUSE_MAX_WORD_UNIT; j++) + eFuseWord[i][j] = 0xFFFF; + + /* */ + /* 1. Read the first byte to check if efuse is empty!!! */ + /* */ + /* */ + rtemp8 = *(phymap+eFuse_Addr); + if (rtemp8 != 0xFF) { + efuse_utilized++; + eFuse_Addr++; + } else { + DBG_88E("EFUSE is empty efuse_Addr-%d efuse_data =%x\n", eFuse_Addr, rtemp8); + goto exit; + } + + /* */ + /* 2. Read real efuse content. Filter PG header and every section data. */ + /* */ + while ((rtemp8 != 0xFF) && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN_88E)) { + /* Check PG header for section num. */ + if ((rtemp8 & 0x1F) == 0x0F) { /* extended header */ + u1temp = ((rtemp8 & 0xE0) >> 5); + rtemp8 = *(phymap+eFuse_Addr); + if ((rtemp8 & 0x0F) == 0x0F) { + eFuse_Addr++; + rtemp8 = *(phymap+eFuse_Addr); + + if (rtemp8 != 0xFF && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN_88E)) + eFuse_Addr++; + continue; + } else { + offset = ((rtemp8 & 0xF0) >> 1) | u1temp; + wren = (rtemp8 & 0x0F); + eFuse_Addr++; + } + } else { + offset = ((rtemp8 >> 4) & 0x0f); + wren = (rtemp8 & 0x0f); + } + + if (offset < EFUSE_MAX_SECTION_88E) { + /* Get word enable value from PG header */ + for (i = 0; i < EFUSE_MAX_WORD_UNIT; i++) { + /* Check word enable condition in the section */ + if (!(wren & 0x01)) { + rtemp8 = *(phymap+eFuse_Addr); + eFuse_Addr++; + efuse_utilized++; + eFuseWord[offset][i] = (rtemp8 & 0xff); + if (eFuse_Addr >= EFUSE_REAL_CONTENT_LEN_88E) + break; + rtemp8 = *(phymap+eFuse_Addr); + eFuse_Addr++; + efuse_utilized++; + eFuseWord[offset][i] |= (((u16)rtemp8 << 8) & 0xff00); + + if (eFuse_Addr >= EFUSE_REAL_CONTENT_LEN_88E) + break; + } + wren >>= 1; + } + } + /* Read next PG header */ + rtemp8 = *(phymap+eFuse_Addr); + + if (rtemp8 != 0xFF && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN_88E)) { + efuse_utilized++; + eFuse_Addr++; + } + } + + /* */ + /* 3. Collect 16 sections and 4 word unit into Efuse map. */ + /* */ + for (i = 0; i < EFUSE_MAX_SECTION_88E; i++) { + for (j = 0; j < EFUSE_MAX_WORD_UNIT; j++) { + efuseTbl[(i*8)+(j*2)] = (eFuseWord[i][j] & 0xff); + efuseTbl[(i*8)+((j*2)+1)] = ((eFuseWord[i][j] >> 8) & 0xff); + } + } + + /* */ + /* 4. Copy from Efuse map to output pointer memory!!! */ + /* */ + for (i = 0; i < _size_byte; i++) + pbuf[i] = efuseTbl[_offset+i]; + + /* */ + /* 5. Calculate Efuse utilization. */ + /* */ + +exit: + kfree(efuseTbl); + + if (eFuseWord) + rtw_mfree2d((void *)eFuseWord, EFUSE_MAX_SECTION_88E, EFUSE_MAX_WORD_UNIT, sizeof(u16)); +} + +static void efuse_read_phymap_from_txpktbuf( + struct adapter *adapter, + int bcnhead, /* beacon head, where FW store len(2-byte) and efuse physical map. */ + u8 *content, /* buffer to store efuse physical map */ + u16 *size /* for efuse content: the max byte to read. will update to byte read */ + ) +{ + u16 dbg_addr = 0; + u32 start = 0, passing_time = 0; + u8 reg_0x143 = 0; + u32 lo32 = 0, hi32 = 0; + u16 len = 0, count = 0; + int i = 0; + u16 limit = *size; + + u8 *pos = content; + + if (bcnhead < 0) /* if not valid */ + bcnhead = rtw_read8(adapter, REG_TDECTRL+1); + + DBG_88E("%s bcnhead:%d\n", __func__, bcnhead); + + rtw_write8(adapter, REG_PKT_BUFF_ACCESS_CTRL, TXPKT_BUF_SELECT); + + dbg_addr = bcnhead*128/8; /* 8-bytes addressing */ + + while (1) { + rtw_write16(adapter, REG_PKTBUF_DBG_ADDR, dbg_addr+i); + + rtw_write8(adapter, REG_TXPKTBUF_DBG, 0); + start = rtw_get_current_time(); + while (!(reg_0x143 = rtw_read8(adapter, REG_TXPKTBUF_DBG)) && + (passing_time = rtw_get_passing_time_ms(start)) < 1000) { + DBG_88E("%s polling reg_0x143:0x%02x, reg_0x106:0x%02x\n", __func__, reg_0x143, rtw_read8(adapter, 0x106)); + rtw_usleep_os(100); + } + + lo32 = rtw_read32(adapter, REG_PKTBUF_DBG_DATA_L); + hi32 = rtw_read32(adapter, REG_PKTBUF_DBG_DATA_H); + + if (i == 0) { + u8 lenc[2]; + u16 lenbak, aaabak; + u16 aaa; + lenc[0] = rtw_read8(adapter, REG_PKTBUF_DBG_DATA_L); + lenc[1] = rtw_read8(adapter, REG_PKTBUF_DBG_DATA_L+1); + + aaabak = le16_to_cpup((__le16 *)lenc); + lenbak = le16_to_cpu(*((__le16 *)lenc)); + aaa = le16_to_cpup((__le16 *)&lo32); + len = le16_to_cpu(*((__le16 *)&lo32)); + + limit = (len-2 < limit) ? len-2 : limit; + + DBG_88E("%s len:%u, lenbak:%u, aaa:%u, aaabak:%u\n", __func__, len, lenbak, aaa, aaabak); + + memcpy(pos, ((u8 *)&lo32)+2, (limit >= count+2) ? 2 : limit-count); + count += (limit >= count+2) ? 2 : limit-count; + pos = content+count; + + } else { + memcpy(pos, ((u8 *)&lo32), (limit >= count+4) ? 4 : limit-count); + count += (limit >= count+4) ? 4 : limit-count; + pos = content+count; + } + + if (limit > count && len-2 > count) { + memcpy(pos, (u8 *)&hi32, (limit >= count+4) ? 4 : limit-count); + count += (limit >= count+4) ? 4 : limit-count; + pos = content+count; + } + + if (limit <= count || len-2 <= count) + break; + i++; + } + rtw_write8(adapter, REG_PKT_BUFF_ACCESS_CTRL, DISABLE_TRXPKT_BUF_ACCESS); + DBG_88E("%s read count:%u\n", __func__, count); + *size = count; +} + +static s32 iol_read_efuse(struct adapter *padapter, u8 txpktbuf_bndy, u16 offset, u16 size_byte, u8 *logical_map) +{ + s32 status = _FAIL; + u8 physical_map[512]; + u16 size = 512; + + rtw_write8(padapter, REG_TDECTRL+1, txpktbuf_bndy); + _rtw_memset(physical_map, 0xFF, 512); + rtw_write8(padapter, REG_PKT_BUFF_ACCESS_CTRL, TXPKT_BUF_SELECT); + status = iol_execute(padapter, CMD_READ_EFUSE_MAP); + if (status == _SUCCESS) + efuse_read_phymap_from_txpktbuf(padapter, txpktbuf_bndy, physical_map, &size); + efuse_phymap_to_logical(physical_map, offset, size_byte, logical_map); + return status; +} + +s32 rtl8188e_iol_efuse_patch(struct adapter *padapter) +{ + s32 result = _SUCCESS; + + DBG_88E("==> %s\n", __func__); + if (rtw_IOL_applied(padapter)) { + iol_mode_enable(padapter, 1); + result = iol_execute(padapter, CMD_READ_EFUSE_MAP); + if (result == _SUCCESS) + result = iol_execute(padapter, CMD_EFUSE_PATCH); + + iol_mode_enable(padapter, 0); + } + return result; +} + +static s32 iol_ioconfig(struct adapter *padapter, u8 iocfg_bndy) +{ + s32 rst = _SUCCESS; + + rtw_write8(padapter, REG_TDECTRL+1, iocfg_bndy); + rst = iol_execute(padapter, CMD_IOCONFIG); + return rst; +} + +static int rtl8188e_IOL_exec_cmds_sync(struct adapter *adapter, struct xmit_frame *xmit_frame, u32 max_wating_ms, u32 bndy_cnt) +{ + struct pkt_attrib *pattrib = &xmit_frame->attrib; + u8 i; + int ret = _FAIL; + + if (rtw_IOL_append_END_cmd(xmit_frame) != _SUCCESS) + goto exit; + if (rtw_usb_bulk_size_boundary(adapter, TXDESC_SIZE+pattrib->last_txcmdsz)) { + if (rtw_IOL_append_END_cmd(xmit_frame) != _SUCCESS) + goto exit; + } + + dump_mgntframe_and_wait(adapter, xmit_frame, max_wating_ms); + + iol_mode_enable(adapter, 1); + for (i = 0; i < bndy_cnt; i++) { + u8 page_no = 0; + page_no = i*2; + ret = iol_ioconfig(adapter, page_no); + if (ret != _SUCCESS) + break; + } + iol_mode_enable(adapter, 0); +exit: + /* restore BCN_HEAD */ + rtw_write8(adapter, REG_TDECTRL+1, 0); + return ret; +} + +void rtw_IOL_cmd_tx_pkt_buf_dump(struct adapter *Adapter, int data_len) +{ + u32 fifo_data, reg_140; + u32 addr, rstatus, loop = 0; + u16 data_cnts = (data_len/8)+1; + u8 *pbuf = rtw_zvmalloc(data_len+10); + DBG_88E("###### %s ######\n", __func__); + + rtw_write8(Adapter, REG_PKT_BUFF_ACCESS_CTRL, TXPKT_BUF_SELECT); + if (pbuf) { + for (addr = 0; addr < data_cnts; addr++) { + rtw_write32(Adapter, 0x140, addr); + rtw_usleep_os(2); + loop = 0; + do { + rstatus = (reg_140 = rtw_read32(Adapter, REG_PKTBUF_DBG_CTRL)&BIT24); + if (rstatus) { + fifo_data = rtw_read32(Adapter, REG_PKTBUF_DBG_DATA_L); + memcpy(pbuf+(addr*8), &fifo_data, 4); + + fifo_data = rtw_read32(Adapter, REG_PKTBUF_DBG_DATA_H); + memcpy(pbuf+(addr*8+4), &fifo_data, 4); + } + rtw_usleep_os(2); + } while (!rstatus && (loop++ < 10)); + } + rtw_IOL_cmd_buf_dump(Adapter, data_len, pbuf); + rtw_vmfree(pbuf, data_len+10); + } + DBG_88E("###### %s ######\n", __func__); +} + +static void _FWDownloadEnable(struct adapter *padapter, bool enable) +{ + u8 tmp; + + if (enable) { + /* MCU firmware download enable. */ + tmp = rtw_read8(padapter, REG_MCUFWDL); + rtw_write8(padapter, REG_MCUFWDL, tmp | 0x01); + + /* 8051 reset */ + tmp = rtw_read8(padapter, REG_MCUFWDL+2); + rtw_write8(padapter, REG_MCUFWDL+2, tmp&0xf7); + } else { + /* MCU firmware download disable. */ + tmp = rtw_read8(padapter, REG_MCUFWDL); + rtw_write8(padapter, REG_MCUFWDL, tmp&0xfe); + + /* Reserved for fw extension. */ + rtw_write8(padapter, REG_MCUFWDL+1, 0x00); + } +} + +#define MAX_REG_BOLCK_SIZE 196 + +static int _BlockWrite(struct adapter *padapter, void *buffer, u32 buffSize) +{ + int ret = _SUCCESS; + u32 blockSize_p1 = 4; /* (Default) Phase #1 : PCI muse use 4-byte write to download FW */ + u32 blockSize_p2 = 8; /* Phase #2 : Use 8-byte, if Phase#1 use big size to write FW. */ + u32 blockSize_p3 = 1; /* Phase #3 : Use 1-byte, the remnant of FW image. */ + u32 blockCount_p1 = 0, blockCount_p2 = 0, blockCount_p3 = 0; + u32 remainSize_p1 = 0, remainSize_p2 = 0; + u8 *bufferPtr = (u8 *)buffer; + u32 i = 0, offset = 0; + + blockSize_p1 = MAX_REG_BOLCK_SIZE; + + /* 3 Phase #1 */ + blockCount_p1 = buffSize / blockSize_p1; + remainSize_p1 = buffSize % blockSize_p1; + + if (blockCount_p1) { + RT_TRACE(_module_hal_init_c_, _drv_notice_, + ("_BlockWrite: [P1] buffSize(%d) blockSize_p1(%d) blockCount_p1(%d) remainSize_p1(%d)\n", + buffSize, blockSize_p1, blockCount_p1, remainSize_p1)); + } + + for (i = 0; i < blockCount_p1; i++) { + ret = rtw_writeN(padapter, (FW_8188E_START_ADDRESS + i * blockSize_p1), blockSize_p1, (bufferPtr + i * blockSize_p1)); + if (ret == _FAIL) + goto exit; + } + + /* 3 Phase #2 */ + if (remainSize_p1) { + offset = blockCount_p1 * blockSize_p1; + + blockCount_p2 = remainSize_p1/blockSize_p2; + remainSize_p2 = remainSize_p1%blockSize_p2; + + if (blockCount_p2) { + RT_TRACE(_module_hal_init_c_, _drv_notice_, + ("_BlockWrite: [P2] buffSize_p2(%d) blockSize_p2(%d) blockCount_p2(%d) remainSize_p2(%d)\n", + (buffSize-offset), blockSize_p2 , blockCount_p2, remainSize_p2)); + } + + for (i = 0; i < blockCount_p2; i++) { + ret = rtw_writeN(padapter, (FW_8188E_START_ADDRESS + offset + i*blockSize_p2), blockSize_p2, (bufferPtr + offset + i*blockSize_p2)); + + if (ret == _FAIL) + goto exit; + } + } + + /* 3 Phase #3 */ + if (remainSize_p2) { + offset = (blockCount_p1 * blockSize_p1) + (blockCount_p2 * blockSize_p2); + + blockCount_p3 = remainSize_p2 / blockSize_p3; + + RT_TRACE(_module_hal_init_c_, _drv_notice_, + ("_BlockWrite: [P3] buffSize_p3(%d) blockSize_p3(%d) blockCount_p3(%d)\n", + (buffSize-offset), blockSize_p3, blockCount_p3)); + + for (i = 0; i < blockCount_p3; i++) { + ret = rtw_write8(padapter, (FW_8188E_START_ADDRESS + offset + i), *(bufferPtr + offset + i)); + + if (ret == _FAIL) + goto exit; + } + } + +exit: + return ret; +} + +static int _PageWrite(struct adapter *padapter, u32 page, void *buffer, u32 size) +{ + u8 value8; + u8 u8Page = (u8)(page & 0x07); + + value8 = (rtw_read8(padapter, REG_MCUFWDL+2) & 0xF8) | u8Page; + rtw_write8(padapter, REG_MCUFWDL+2, value8); + + return _BlockWrite(padapter, buffer, size); +} + +static int _WriteFW(struct adapter *padapter, void *buffer, u32 size) +{ + /* Since we need dynamic decide method of dwonload fw, so we call this function to get chip version. */ + /* We can remove _ReadChipVersion from ReadpadapterInfo8192C later. */ + int ret = _SUCCESS; + u32 pageNums, remainSize; + u32 page, offset; + u8 *bufferPtr = (u8 *)buffer; + + pageNums = size / MAX_PAGE_SIZE; + remainSize = size % MAX_PAGE_SIZE; + + for (page = 0; page < pageNums; page++) { + offset = page * MAX_PAGE_SIZE; + ret = _PageWrite(padapter, page, bufferPtr+offset, MAX_PAGE_SIZE); + + if (ret == _FAIL) + goto exit; + } + if (remainSize) { + offset = pageNums * MAX_PAGE_SIZE; + page = pageNums; + ret = _PageWrite(padapter, page, bufferPtr+offset, remainSize); + + if (ret == _FAIL) + goto exit; + } + RT_TRACE(_module_hal_init_c_, _drv_info_, ("_WriteFW Done- for Normal chip.\n")); +exit: + return ret; +} + +void _8051Reset88E(struct adapter *padapter) +{ + u8 u1bTmp; + + u1bTmp = rtw_read8(padapter, REG_SYS_FUNC_EN+1); + rtw_write8(padapter, REG_SYS_FUNC_EN+1, u1bTmp&(~BIT2)); + rtw_write8(padapter, REG_SYS_FUNC_EN+1, u1bTmp|(BIT2)); + DBG_88E("=====> _8051Reset88E(): 8051 reset success .\n"); +} + +static s32 _FWFreeToGo(struct adapter *padapter) +{ + u32 counter = 0; + u32 value32; + + /* polling CheckSum report */ + do { + value32 = rtw_read32(padapter, REG_MCUFWDL); + if (value32 & FWDL_ChkSum_rpt) + break; + } while (counter++ < POLLING_READY_TIMEOUT_COUNT); + + if (counter >= POLLING_READY_TIMEOUT_COUNT) { + DBG_88E("%s: chksum report fail! REG_MCUFWDL:0x%08x\n", __func__, value32); + return _FAIL; + } + DBG_88E("%s: Checksum report OK! REG_MCUFWDL:0x%08x\n", __func__, value32); + + value32 = rtw_read32(padapter, REG_MCUFWDL); + value32 |= MCUFWDL_RDY; + value32 &= ~WINTINI_RDY; + rtw_write32(padapter, REG_MCUFWDL, value32); + + _8051Reset88E(padapter); + + /* polling for FW ready */ + counter = 0; + do { + value32 = rtw_read32(padapter, REG_MCUFWDL); + if (value32 & WINTINI_RDY) { + DBG_88E("%s: Polling FW ready success!! REG_MCUFWDL:0x%08x\n", __func__, value32); + return _SUCCESS; + } + rtw_udelay_os(5); + } while (counter++ < POLLING_READY_TIMEOUT_COUNT); + + DBG_88E("%s: Polling FW ready fail!! REG_MCUFWDL:0x%08x\n", __func__, value32); + return _FAIL; +} + +#define IS_FW_81xxC(padapter) (((GET_HAL_DATA(padapter))->FirmwareSignature & 0xFFF0) == 0x88C0) + +s32 rtl8188e_FirmwareDownload(struct adapter *padapter) +{ + s32 rtStatus = _SUCCESS; + u8 writeFW_retry = 0; + u32 fwdl_start_time; + struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); + + u8 *FwImage; + u32 FwImageLen; + struct rt_firmware *pFirmware = NULL; + struct rt_firmware_hdr *pFwHdr = NULL; + u8 *pFirmwareBuf; + u32 FirmwareLen; + + RT_TRACE(_module_hal_init_c_, _drv_info_, ("+%s\n", __func__)); + pFirmware = (struct rt_firmware *)rtw_zmalloc(sizeof(struct rt_firmware)); + if (!pFirmware) { + rtStatus = _FAIL; + goto Exit; + } + + FwImage = (u8 *)Rtl8188E_FwImageArray; + FwImageLen = Rtl8188E_FWImgArrayLength; + + pFirmware->eFWSource = FW_SOURCE_HEADER_FILE; + + switch (pFirmware->eFWSource) { + case FW_SOURCE_IMG_FILE: + break; + case FW_SOURCE_HEADER_FILE: + if (FwImageLen > FW_8188E_SIZE) { + rtStatus = _FAIL; + RT_TRACE(_module_hal_init_c_, _drv_err_, ("Firmware size exceed 0x%X. Check it.\n", FW_8188E_SIZE)); + goto Exit; + } + + pFirmware->szFwBuffer = FwImage; + pFirmware->ulFwLength = FwImageLen; + break; + } + pFirmwareBuf = pFirmware->szFwBuffer; + FirmwareLen = pFirmware->ulFwLength; + DBG_88E_LEVEL(_drv_info_, "+%s: !bUsedWoWLANFw, FmrmwareLen:%d+\n", __func__, FirmwareLen); + + /* To Check Fw header. Added by tynli. 2009.12.04. */ + pFwHdr = (struct rt_firmware_hdr *)pFirmware->szFwBuffer; + + pHalData->FirmwareVersion = le16_to_cpu(pFwHdr->Version); + pHalData->FirmwareSubVersion = pFwHdr->Subversion; + pHalData->FirmwareSignature = le16_to_cpu(pFwHdr->Signature); + + DBG_88E("%s: fw_ver =%d fw_subver =%d sig = 0x%x\n", + __func__, pHalData->FirmwareVersion, pHalData->FirmwareSubVersion, pHalData->FirmwareSignature); + + if (IS_FW_HEADER_EXIST(pFwHdr)) { + /* Shift 32 bytes for FW header */ + pFirmwareBuf = pFirmwareBuf + 32; + FirmwareLen = FirmwareLen - 32; + } + + /* Suggested by Filen. If 8051 is running in RAM code, driver should inform Fw to reset by itself, */ + /* or it will cause download Fw fail. 2010.02.01. by tynli. */ + if (rtw_read8(padapter, REG_MCUFWDL) & RAM_DL_SEL) { /* 8051 RAM code */ + rtw_write8(padapter, REG_MCUFWDL, 0x00); + _8051Reset88E(padapter); + } + + _FWDownloadEnable(padapter, true); + fwdl_start_time = rtw_get_current_time(); + while (1) { + /* reset the FWDL chksum */ + rtw_write8(padapter, REG_MCUFWDL, rtw_read8(padapter, REG_MCUFWDL) | FWDL_ChkSum_rpt); + + rtStatus = _WriteFW(padapter, pFirmwareBuf, FirmwareLen); + + if (rtStatus == _SUCCESS || + (rtw_get_passing_time_ms(fwdl_start_time) > 500 && writeFW_retry++ >= 3)) + break; + + DBG_88E("%s writeFW_retry:%u, time after fwdl_start_time:%ums\n", + __func__, writeFW_retry, rtw_get_passing_time_ms(fwdl_start_time) + ); + } + _FWDownloadEnable(padapter, false); + if (_SUCCESS != rtStatus) { + DBG_88E("DL Firmware failed!\n"); + goto Exit; + } + + rtStatus = _FWFreeToGo(padapter); + if (_SUCCESS != rtStatus) { + DBG_88E("DL Firmware failed!\n"); + goto Exit; + } + RT_TRACE(_module_hal_init_c_, _drv_info_, ("Firmware is ready to run!\n")); + +Exit: + + kfree(pFirmware); + return rtStatus; +} + +void rtl8188e_InitializeFirmwareVars(struct adapter *padapter) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); + + /* Init Fw LPS related. */ + padapter->pwrctrlpriv.bFwCurrentInPSMode = false; + + /* Init H2C counter. by tynli. 2009.12.09. */ + pHalData->LastHMEBoxNum = 0; +} + +static void rtl8188e_free_hal_data(struct adapter *padapter) +{ +_func_enter_; + kfree(padapter->HalData); + padapter->HalData = NULL; +_func_exit_; +} + +/* */ +/* Efuse related code */ +/* */ +enum{ + VOLTAGE_V25 = 0x03, + LDOE25_SHIFT = 28 , + }; + +static bool +hal_EfusePgPacketWrite2ByteHeader( + struct adapter *pAdapter, + u8 efuseType, + u16 *pAddr, + struct pgpkt *pTargetPkt, + bool bPseudoTest); +static bool +hal_EfusePgPacketWrite1ByteHeader( + struct adapter *pAdapter, + u8 efuseType, + u16 *pAddr, + struct pgpkt *pTargetPkt, + bool bPseudoTest); +static bool +hal_EfusePgPacketWriteData( + struct adapter *pAdapter, + u8 efuseType, + u16 *pAddr, + struct pgpkt *pTargetPkt, + bool bPseudoTest); + +static void +hal_EfusePowerSwitch_RTL8188E( + struct adapter *pAdapter, + u8 bWrite, + u8 PwrState) +{ + u8 tempval; + u16 tmpV16; + + if (PwrState) { + rtw_write8(pAdapter, REG_EFUSE_ACCESS, EFUSE_ACCESS_ON); + + /* 1.2V Power: From VDDON with Power Cut(0x0000h[15]), defualt valid */ + tmpV16 = rtw_read16(pAdapter, REG_SYS_ISO_CTRL); + if (!(tmpV16 & PWC_EV12V)) { + tmpV16 |= PWC_EV12V; + rtw_write16(pAdapter, REG_SYS_ISO_CTRL, tmpV16); + } + /* Reset: 0x0000h[28], default valid */ + tmpV16 = rtw_read16(pAdapter, REG_SYS_FUNC_EN); + if (!(tmpV16 & FEN_ELDR)) { + tmpV16 |= FEN_ELDR; + rtw_write16(pAdapter, REG_SYS_FUNC_EN, tmpV16); + } + + /* Clock: Gated(0x0008h[5]) 8M(0x0008h[1]) clock from ANA, default valid */ + tmpV16 = rtw_read16(pAdapter, REG_SYS_CLKR); + if ((!(tmpV16 & LOADER_CLK_EN)) || (!(tmpV16 & ANA8M))) { + tmpV16 |= (LOADER_CLK_EN | ANA8M); + rtw_write16(pAdapter, REG_SYS_CLKR, tmpV16); + } + + if (bWrite) { + /* Enable LDO 2.5V before read/write action */ + tempval = rtw_read8(pAdapter, EFUSE_TEST+3); + tempval &= 0x0F; + tempval |= (VOLTAGE_V25 << 4); + rtw_write8(pAdapter, EFUSE_TEST+3, (tempval | 0x80)); + } + } else { + rtw_write8(pAdapter, REG_EFUSE_ACCESS, EFUSE_ACCESS_OFF); + + if (bWrite) { + /* Disable LDO 2.5V after read/write action */ + tempval = rtw_read8(pAdapter, EFUSE_TEST+3); + rtw_write8(pAdapter, EFUSE_TEST+3, (tempval & 0x7F)); + } + } +} + +static void +rtl8188e_EfusePowerSwitch( + struct adapter *pAdapter, + u8 bWrite, + u8 PwrState) +{ + hal_EfusePowerSwitch_RTL8188E(pAdapter, bWrite, PwrState); +} + + +static void Hal_EfuseReadEFuse88E(struct adapter *Adapter, + u16 _offset, + u16 _size_byte, + u8 *pbuf, + bool bPseudoTest + ) +{ + u8 *efuseTbl = NULL; + u8 rtemp8[1]; + u16 eFuse_Addr = 0; + u8 offset, wren; + u16 i, j; + u16 **eFuseWord = NULL; + u16 efuse_utilized = 0; + u8 u1temp = 0; + + /* */ + /* Do NOT excess total size of EFuse table. Added by Roger, 2008.11.10. */ + /* */ + if ((_offset + _size_byte) > EFUSE_MAP_LEN_88E) {/* total E-Fuse table is 512bytes */ + DBG_88E("Hal_EfuseReadEFuse88E(): Invalid offset(%#x) with read bytes(%#x)!!\n", _offset, _size_byte); + goto exit; + } + + efuseTbl = (u8 *)rtw_zmalloc(EFUSE_MAP_LEN_88E); + if (efuseTbl == NULL) { + DBG_88E("%s: alloc efuseTbl fail!\n", __func__); + goto exit; + } + + eFuseWord = (u16 **)rtw_malloc2d(EFUSE_MAX_SECTION_88E, EFUSE_MAX_WORD_UNIT, sizeof(u16)); + if (eFuseWord == NULL) { + DBG_88E("%s: alloc eFuseWord fail!\n", __func__); + goto exit; + } + + /* 0. Refresh efuse init map as all oxFF. */ + for (i = 0; i < EFUSE_MAX_SECTION_88E; i++) + for (j = 0; j < EFUSE_MAX_WORD_UNIT; j++) + eFuseWord[i][j] = 0xFFFF; + + /* */ + /* 1. Read the first byte to check if efuse is empty!!! */ + /* */ + /* */ + ReadEFuseByte(Adapter, eFuse_Addr, rtemp8, bPseudoTest); + if (*rtemp8 != 0xFF) { + efuse_utilized++; + eFuse_Addr++; + } else { + DBG_88E("EFUSE is empty efuse_Addr-%d efuse_data =%x\n", eFuse_Addr, *rtemp8); + goto exit; + } + + /* */ + /* 2. Read real efuse content. Filter PG header and every section data. */ + /* */ + while ((*rtemp8 != 0xFF) && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN_88E)) { + /* Check PG header for section num. */ + if ((*rtemp8 & 0x1F) == 0x0F) { /* extended header */ + u1temp = ((*rtemp8 & 0xE0) >> 5); + + ReadEFuseByte(Adapter, eFuse_Addr, rtemp8, bPseudoTest); + + if ((*rtemp8 & 0x0F) == 0x0F) { + eFuse_Addr++; + ReadEFuseByte(Adapter, eFuse_Addr, rtemp8, bPseudoTest); + + if (*rtemp8 != 0xFF && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN_88E)) + eFuse_Addr++; + continue; + } else { + offset = ((*rtemp8 & 0xF0) >> 1) | u1temp; + wren = (*rtemp8 & 0x0F); + eFuse_Addr++; + } + } else { + offset = ((*rtemp8 >> 4) & 0x0f); + wren = (*rtemp8 & 0x0f); + } + + if (offset < EFUSE_MAX_SECTION_88E) { + /* Get word enable value from PG header */ + + for (i = 0; i < EFUSE_MAX_WORD_UNIT; i++) { + /* Check word enable condition in the section */ + if (!(wren & 0x01)) { + ReadEFuseByte(Adapter, eFuse_Addr, rtemp8, bPseudoTest); + eFuse_Addr++; + efuse_utilized++; + eFuseWord[offset][i] = (*rtemp8 & 0xff); + if (eFuse_Addr >= EFUSE_REAL_CONTENT_LEN_88E) + break; + ReadEFuseByte(Adapter, eFuse_Addr, rtemp8, bPseudoTest); + eFuse_Addr++; + efuse_utilized++; + eFuseWord[offset][i] |= (((u16)*rtemp8 << 8) & 0xff00); + if (eFuse_Addr >= EFUSE_REAL_CONTENT_LEN_88E) + break; + } + wren >>= 1; + } + } + + /* Read next PG header */ + ReadEFuseByte(Adapter, eFuse_Addr, rtemp8, bPseudoTest); + + if (*rtemp8 != 0xFF && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN_88E)) { + efuse_utilized++; + eFuse_Addr++; + } + } + + /* 3. Collect 16 sections and 4 word unit into Efuse map. */ + for (i = 0; i < EFUSE_MAX_SECTION_88E; i++) { + for (j = 0; j < EFUSE_MAX_WORD_UNIT; j++) { + efuseTbl[(i*8)+(j*2)] = (eFuseWord[i][j] & 0xff); + efuseTbl[(i*8)+((j*2)+1)] = ((eFuseWord[i][j] >> 8) & 0xff); + } + } + + /* 4. Copy from Efuse map to output pointer memory!!! */ + for (i = 0; i < _size_byte; i++) + pbuf[i] = efuseTbl[_offset+i]; + + /* 5. Calculate Efuse utilization. */ + rtw_hal_set_hwreg(Adapter, HW_VAR_EFUSE_BYTES, (u8 *)&eFuse_Addr); + +exit: + kfree(efuseTbl); + + if (eFuseWord) + rtw_mfree2d((void *)eFuseWord, EFUSE_MAX_SECTION_88E, EFUSE_MAX_WORD_UNIT, sizeof(u16)); +} + +static void ReadEFuseByIC(struct adapter *Adapter, u8 efuseType, u16 _offset, u16 _size_byte, u8 *pbuf, bool bPseudoTest) +{ + if (!bPseudoTest) { + int ret = _FAIL; + if (rtw_IOL_applied(Adapter)) { + rtw_hal_power_on(Adapter); + + iol_mode_enable(Adapter, 1); + ret = iol_read_efuse(Adapter, 0, _offset, _size_byte, pbuf); + iol_mode_enable(Adapter, 0); + + if (_SUCCESS == ret) + goto exit; + } + } + Hal_EfuseReadEFuse88E(Adapter, _offset, _size_byte, pbuf, bPseudoTest); + +exit: + return; +} + +static void ReadEFuse_Pseudo(struct adapter *Adapter, u8 efuseType, u16 _offset, u16 _size_byte, u8 *pbuf, bool bPseudoTest) +{ + Hal_EfuseReadEFuse88E(Adapter, _offset, _size_byte, pbuf, bPseudoTest); +} + +static void rtl8188e_ReadEFuse(struct adapter *Adapter, u8 efuseType, + u16 _offset, u16 _size_byte, u8 *pbuf, + bool bPseudoTest) +{ + if (bPseudoTest) + ReadEFuse_Pseudo (Adapter, efuseType, _offset, _size_byte, pbuf, bPseudoTest); + else + ReadEFuseByIC(Adapter, efuseType, _offset, _size_byte, pbuf, bPseudoTest); +} + +/* Do not support BT */ +static void Hal_EFUSEGetEfuseDefinition88E(struct adapter *pAdapter, u8 efuseType, u8 type, void *pOut) +{ + switch (type) { + case TYPE_EFUSE_MAX_SECTION: + { + u8 *pMax_section; + pMax_section = (u8 *)pOut; + *pMax_section = EFUSE_MAX_SECTION_88E; + } + break; + case TYPE_EFUSE_REAL_CONTENT_LEN: + { + u16 *pu2Tmp; + pu2Tmp = (u16 *)pOut; + *pu2Tmp = EFUSE_REAL_CONTENT_LEN_88E; + } + break; + case TYPE_EFUSE_CONTENT_LEN_BANK: + { + u16 *pu2Tmp; + pu2Tmp = (u16 *)pOut; + *pu2Tmp = EFUSE_REAL_CONTENT_LEN_88E; + } + break; + case TYPE_AVAILABLE_EFUSE_BYTES_BANK: + { + u16 *pu2Tmp; + pu2Tmp = (u16 *)pOut; + *pu2Tmp = (u16)(EFUSE_REAL_CONTENT_LEN_88E-EFUSE_OOB_PROTECT_BYTES_88E); + } + break; + case TYPE_AVAILABLE_EFUSE_BYTES_TOTAL: + { + u16 *pu2Tmp; + pu2Tmp = (u16 *)pOut; + *pu2Tmp = (u16)(EFUSE_REAL_CONTENT_LEN_88E-EFUSE_OOB_PROTECT_BYTES_88E); + } + break; + case TYPE_EFUSE_MAP_LEN: + { + u16 *pu2Tmp; + pu2Tmp = (u16 *)pOut; + *pu2Tmp = (u16)EFUSE_MAP_LEN_88E; + } + break; + case TYPE_EFUSE_PROTECT_BYTES_BANK: + { + u8 *pu1Tmp; + pu1Tmp = (u8 *)pOut; + *pu1Tmp = (u8)(EFUSE_OOB_PROTECT_BYTES_88E); + } + break; + default: + { + u8 *pu1Tmp; + pu1Tmp = (u8 *)pOut; + *pu1Tmp = 0; + } + break; + } +} + +static void Hal_EFUSEGetEfuseDefinition_Pseudo88E(struct adapter *pAdapter, u8 efuseType, u8 type, void *pOut) +{ + switch (type) { + case TYPE_EFUSE_MAX_SECTION: + { + u8 *pMax_section; + pMax_section = (u8 *)pOut; + *pMax_section = EFUSE_MAX_SECTION_88E; + } + break; + case TYPE_EFUSE_REAL_CONTENT_LEN: + { + u16 *pu2Tmp; + pu2Tmp = (u16 *)pOut; + *pu2Tmp = EFUSE_REAL_CONTENT_LEN_88E; + } + break; + case TYPE_EFUSE_CONTENT_LEN_BANK: + { + u16 *pu2Tmp; + pu2Tmp = (u16 *)pOut; + *pu2Tmp = EFUSE_REAL_CONTENT_LEN_88E; + } + break; + case TYPE_AVAILABLE_EFUSE_BYTES_BANK: + { + u16 *pu2Tmp; + pu2Tmp = (u16 *)pOut; + *pu2Tmp = (u16)(EFUSE_REAL_CONTENT_LEN_88E-EFUSE_OOB_PROTECT_BYTES_88E); + } + break; + case TYPE_AVAILABLE_EFUSE_BYTES_TOTAL: + { + u16 *pu2Tmp; + pu2Tmp = (u16 *)pOut; + *pu2Tmp = (u16)(EFUSE_REAL_CONTENT_LEN_88E-EFUSE_OOB_PROTECT_BYTES_88E); + } + break; + case TYPE_EFUSE_MAP_LEN: + { + u16 *pu2Tmp; + pu2Tmp = (u16 *)pOut; + *pu2Tmp = (u16)EFUSE_MAP_LEN_88E; + } + break; + case TYPE_EFUSE_PROTECT_BYTES_BANK: + { + u8 *pu1Tmp; + pu1Tmp = (u8 *)pOut; + *pu1Tmp = (u8)(EFUSE_OOB_PROTECT_BYTES_88E); + } + break; + default: + { + u8 *pu1Tmp; + pu1Tmp = (u8 *)pOut; + *pu1Tmp = 0; + } + break; + } +} + +static void rtl8188e_EFUSE_GetEfuseDefinition(struct adapter *pAdapter, u8 efuseType, u8 type, void *pOut, bool bPseudoTest) +{ + if (bPseudoTest) + Hal_EFUSEGetEfuseDefinition_Pseudo88E(pAdapter, efuseType, type, pOut); + else + Hal_EFUSEGetEfuseDefinition88E(pAdapter, efuseType, type, pOut); +} + +static u8 Hal_EfuseWordEnableDataWrite(struct adapter *pAdapter, u16 efuse_addr, u8 word_en, u8 *data, bool bPseudoTest) +{ + u16 tmpaddr = 0; + u16 start_addr = efuse_addr; + u8 badworden = 0x0F; + u8 tmpdata[8]; + + _rtw_memset((void *)tmpdata, 0xff, PGPKT_DATA_SIZE); + + if (!(word_en&BIT0)) { + tmpaddr = start_addr; + efuse_OneByteWrite(pAdapter, start_addr++, data[0], bPseudoTest); + efuse_OneByteWrite(pAdapter, start_addr++, data[1], bPseudoTest); + + efuse_OneByteRead(pAdapter, tmpaddr, &tmpdata[0], bPseudoTest); + efuse_OneByteRead(pAdapter, tmpaddr+1, &tmpdata[1], bPseudoTest); + if ((data[0] != tmpdata[0]) || (data[1] != tmpdata[1])) + badworden &= (~BIT0); + } + if (!(word_en&BIT1)) { + tmpaddr = start_addr; + efuse_OneByteWrite(pAdapter, start_addr++, data[2], bPseudoTest); + efuse_OneByteWrite(pAdapter, start_addr++, data[3], bPseudoTest); + + efuse_OneByteRead(pAdapter, tmpaddr , &tmpdata[2], bPseudoTest); + efuse_OneByteRead(pAdapter, tmpaddr+1, &tmpdata[3], bPseudoTest); + if ((data[2] != tmpdata[2]) || (data[3] != tmpdata[3])) + badworden &= (~BIT1); + } + if (!(word_en&BIT2)) { + tmpaddr = start_addr; + efuse_OneByteWrite(pAdapter, start_addr++, data[4], bPseudoTest); + efuse_OneByteWrite(pAdapter, start_addr++, data[5], bPseudoTest); + + efuse_OneByteRead(pAdapter, tmpaddr, &tmpdata[4], bPseudoTest); + efuse_OneByteRead(pAdapter, tmpaddr+1, &tmpdata[5], bPseudoTest); + if ((data[4] != tmpdata[4]) || (data[5] != tmpdata[5])) + badworden &= (~BIT2); + } + if (!(word_en&BIT3)) { + tmpaddr = start_addr; + efuse_OneByteWrite(pAdapter, start_addr++, data[6], bPseudoTest); + efuse_OneByteWrite(pAdapter, start_addr++, data[7], bPseudoTest); + + efuse_OneByteRead(pAdapter, tmpaddr, &tmpdata[6], bPseudoTest); + efuse_OneByteRead(pAdapter, tmpaddr+1, &tmpdata[7], bPseudoTest); + if ((data[6] != tmpdata[6]) || (data[7] != tmpdata[7])) + badworden &= (~BIT3); + } + return badworden; +} + +static u8 Hal_EfuseWordEnableDataWrite_Pseudo(struct adapter *pAdapter, u16 efuse_addr, u8 word_en, u8 *data, bool bPseudoTest) +{ + u8 ret; + + ret = Hal_EfuseWordEnableDataWrite(pAdapter, efuse_addr, word_en, data, bPseudoTest); + return ret; +} + +static u8 rtl8188e_Efuse_WordEnableDataWrite(struct adapter *pAdapter, u16 efuse_addr, u8 word_en, u8 *data, bool bPseudoTest) +{ + u8 ret = 0; + + if (bPseudoTest) + ret = Hal_EfuseWordEnableDataWrite_Pseudo (pAdapter, efuse_addr, word_en, data, bPseudoTest); + else + ret = Hal_EfuseWordEnableDataWrite(pAdapter, efuse_addr, word_en, data, bPseudoTest); + return ret; +} + +static u16 hal_EfuseGetCurrentSize_8188e(struct adapter *pAdapter, bool bPseudoTest) +{ + int bContinual = true; + u16 efuse_addr = 0; + u8 hoffset = 0, hworden = 0; + u8 efuse_data, word_cnts = 0; + + if (bPseudoTest) + efuse_addr = (u16)(fakeEfuseUsedBytes); + else + rtw_hal_get_hwreg(pAdapter, HW_VAR_EFUSE_BYTES, (u8 *)&efuse_addr); + + while (bContinual && + efuse_OneByteRead(pAdapter, efuse_addr, &efuse_data, bPseudoTest) && + AVAILABLE_EFUSE_ADDR(efuse_addr)) { + if (efuse_data != 0xFF) { + if ((efuse_data&0x1F) == 0x0F) { /* extended header */ + hoffset = efuse_data; + efuse_addr++; + efuse_OneByteRead(pAdapter, efuse_addr, &efuse_data, bPseudoTest); + if ((efuse_data & 0x0F) == 0x0F) { + efuse_addr++; + continue; + } else { + hoffset = ((hoffset & 0xE0) >> 5) | ((efuse_data & 0xF0) >> 1); + hworden = efuse_data & 0x0F; + } + } else { + hoffset = (efuse_data>>4) & 0x0F; + hworden = efuse_data & 0x0F; + } + word_cnts = Efuse_CalculateWordCnts(hworden); + /* read next header */ + efuse_addr = efuse_addr + (word_cnts*2)+1; + } else { + bContinual = false; + } + } + + if (bPseudoTest) + fakeEfuseUsedBytes = efuse_addr; + else + rtw_hal_set_hwreg(pAdapter, HW_VAR_EFUSE_BYTES, (u8 *)&efuse_addr); + + return efuse_addr; +} + +static u16 Hal_EfuseGetCurrentSize_Pseudo(struct adapter *pAdapter, bool bPseudoTest) +{ + u16 ret = 0; + + ret = hal_EfuseGetCurrentSize_8188e(pAdapter, bPseudoTest); + return ret; +} + +static u16 rtl8188e_EfuseGetCurrentSize(struct adapter *pAdapter, u8 efuseType, bool bPseudoTest) +{ + u16 ret = 0; + + if (bPseudoTest) + ret = Hal_EfuseGetCurrentSize_Pseudo(pAdapter, bPseudoTest); + else + ret = hal_EfuseGetCurrentSize_8188e(pAdapter, bPseudoTest); + return ret; +} + +static int hal_EfusePgPacketRead_8188e(struct adapter *pAdapter, u8 offset, u8 *data, bool bPseudoTest) +{ + u8 ReadState = PG_STATE_HEADER; + int bContinual = true; + int bDataEmpty = true; + u8 efuse_data, word_cnts = 0; + u16 efuse_addr = 0; + u8 hoffset = 0, hworden = 0; + u8 tmpidx = 0; + u8 tmpdata[8]; + u8 max_section = 0; + u8 tmp_header = 0; + + EFUSE_GetEfuseDefinition(pAdapter, EFUSE_WIFI, TYPE_EFUSE_MAX_SECTION, (void *)&max_section, bPseudoTest); + + if (data == NULL) + return false; + if (offset > max_section) + return false; + + _rtw_memset((void *)data, 0xff, sizeof(u8)*PGPKT_DATA_SIZE); + _rtw_memset((void *)tmpdata, 0xff, sizeof(u8)*PGPKT_DATA_SIZE); + + /* Efuse has been pre-programmed dummy 5Bytes at the end of Efuse by CP. */ + /* Skip dummy parts to prevent unexpected data read from Efuse. */ + /* By pass right now. 2009.02.19. */ + while (bContinual && AVAILABLE_EFUSE_ADDR(efuse_addr)) { + /* Header Read ------------- */ + if (ReadState & PG_STATE_HEADER) { + if (efuse_OneByteRead(pAdapter, efuse_addr, &efuse_data, bPseudoTest) && (efuse_data != 0xFF)) { + if (EXT_HEADER(efuse_data)) { + tmp_header = efuse_data; + efuse_addr++; + efuse_OneByteRead(pAdapter, efuse_addr, &efuse_data, bPseudoTest); + if (!ALL_WORDS_DISABLED(efuse_data)) { + hoffset = ((tmp_header & 0xE0) >> 5) | ((efuse_data & 0xF0) >> 1); + hworden = efuse_data & 0x0F; + } else { + DBG_88E("Error, All words disabled\n"); + efuse_addr++; + continue; + } + } else { + hoffset = (efuse_data>>4) & 0x0F; + hworden = efuse_data & 0x0F; + } + word_cnts = Efuse_CalculateWordCnts(hworden); + bDataEmpty = true; + + if (hoffset == offset) { + for (tmpidx = 0; tmpidx < word_cnts*2; tmpidx++) { + if (efuse_OneByteRead(pAdapter, efuse_addr+1+tmpidx, &efuse_data, bPseudoTest)) { + tmpdata[tmpidx] = efuse_data; + if (efuse_data != 0xff) + bDataEmpty = false; + } + } + if (bDataEmpty == false) { + ReadState = PG_STATE_DATA; + } else {/* read next header */ + efuse_addr = efuse_addr + (word_cnts*2)+1; + ReadState = PG_STATE_HEADER; + } + } else {/* read next header */ + efuse_addr = efuse_addr + (word_cnts*2)+1; + ReadState = PG_STATE_HEADER; + } + } else { + bContinual = false; + } + } else if (ReadState & PG_STATE_DATA) { + /* Data section Read ------------- */ + efuse_WordEnableDataRead(hworden, tmpdata, data); + efuse_addr = efuse_addr + (word_cnts*2)+1; + ReadState = PG_STATE_HEADER; + } + + } + + if ((data[0] == 0xff) && (data[1] == 0xff) && (data[2] == 0xff) && (data[3] == 0xff) && + (data[4] == 0xff) && (data[5] == 0xff) && (data[6] == 0xff) && (data[7] == 0xff)) + return false; + else + return true; +} + +static int Hal_EfusePgPacketRead(struct adapter *pAdapter, u8 offset, u8 *data, bool bPseudoTest) +{ + int ret; + + ret = hal_EfusePgPacketRead_8188e(pAdapter, offset, data, bPseudoTest); + return ret; +} + +static int Hal_EfusePgPacketRead_Pseudo(struct adapter *pAdapter, u8 offset, u8 *data, bool bPseudoTest) +{ + int ret; + + ret = hal_EfusePgPacketRead_8188e(pAdapter, offset, data, bPseudoTest); + return ret; +} + +static int rtl8188e_Efuse_PgPacketRead(struct adapter *pAdapter, u8 offset, u8 *data, bool bPseudoTest) +{ + int ret; + + if (bPseudoTest) + ret = Hal_EfusePgPacketRead_Pseudo (pAdapter, offset, data, bPseudoTest); + else + ret = Hal_EfusePgPacketRead(pAdapter, offset, data, bPseudoTest); + return ret; +} + +static bool hal_EfuseFixHeaderProcess(struct adapter *pAdapter, u8 efuseType, struct pgpkt *pFixPkt, u16 *pAddr, bool bPseudoTest) +{ + u8 originaldata[8], badworden = 0; + u16 efuse_addr = *pAddr; + u32 PgWriteSuccess = 0; + + _rtw_memset((void *)originaldata, 0xff, 8); + + if (Efuse_PgPacketRead(pAdapter, pFixPkt->offset, originaldata, bPseudoTest)) { + /* check if data exist */ + badworden = Efuse_WordEnableDataWrite(pAdapter, efuse_addr+1, pFixPkt->word_en, originaldata, bPseudoTest); + + if (badworden != 0xf) { /* write fail */ + PgWriteSuccess = Efuse_PgPacketWrite(pAdapter, pFixPkt->offset, badworden, originaldata, bPseudoTest); + + if (!PgWriteSuccess) + return false; + else + efuse_addr = Efuse_GetCurrentSize(pAdapter, efuseType, bPseudoTest); + } else { + efuse_addr = efuse_addr + (pFixPkt->word_cnts*2) + 1; + } + } else { + efuse_addr = efuse_addr + (pFixPkt->word_cnts*2) + 1; + } + *pAddr = efuse_addr; + return true; +} + +static bool hal_EfusePgPacketWrite2ByteHeader(struct adapter *pAdapter, u8 efuseType, u16 *pAddr, struct pgpkt *pTargetPkt, bool bPseudoTest) +{ + bool bRet = false; + u16 efuse_addr = *pAddr, efuse_max_available_len = 0; + u8 pg_header = 0, tmp_header = 0, pg_header_temp = 0; + u8 repeatcnt = 0; + + EFUSE_GetEfuseDefinition(pAdapter, efuseType, TYPE_AVAILABLE_EFUSE_BYTES_BANK, (void *)&efuse_max_available_len, bPseudoTest); + + while (efuse_addr < efuse_max_available_len) { + pg_header = ((pTargetPkt->offset & 0x07) << 5) | 0x0F; + efuse_OneByteWrite(pAdapter, efuse_addr, pg_header, bPseudoTest); + efuse_OneByteRead(pAdapter, efuse_addr, &tmp_header, bPseudoTest); + + while (tmp_header == 0xFF) { + if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_) + return false; + + efuse_OneByteWrite(pAdapter, efuse_addr, pg_header, bPseudoTest); + efuse_OneByteRead(pAdapter, efuse_addr, &tmp_header, bPseudoTest); + } + + /* to write ext_header */ + if (tmp_header == pg_header) { + efuse_addr++; + pg_header_temp = pg_header; + pg_header = ((pTargetPkt->offset & 0x78) << 1) | pTargetPkt->word_en; + + efuse_OneByteWrite(pAdapter, efuse_addr, pg_header, bPseudoTest); + efuse_OneByteRead(pAdapter, efuse_addr, &tmp_header, bPseudoTest); + + while (tmp_header == 0xFF) { + if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_) + return false; + + efuse_OneByteWrite(pAdapter, efuse_addr, pg_header, bPseudoTest); + efuse_OneByteRead(pAdapter, efuse_addr, &tmp_header, bPseudoTest); + } + + if ((tmp_header & 0x0F) == 0x0F) { /* word_en PG fail */ + if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_) { + return false; + } else { + efuse_addr++; + continue; + } + } else if (pg_header != tmp_header) { /* offset PG fail */ + struct pgpkt fixPkt; + fixPkt.offset = ((pg_header_temp & 0xE0) >> 5) | ((tmp_header & 0xF0) >> 1); + fixPkt.word_en = tmp_header & 0x0F; + fixPkt.word_cnts = Efuse_CalculateWordCnts(fixPkt.word_en); + if (!hal_EfuseFixHeaderProcess(pAdapter, efuseType, &fixPkt, &efuse_addr, bPseudoTest)) + return false; + } else { + bRet = true; + break; + } + } else if ((tmp_header & 0x1F) == 0x0F) { /* wrong extended header */ + efuse_addr += 2; + continue; + } + } + + *pAddr = efuse_addr; + return bRet; +} + +static bool hal_EfusePgPacketWrite1ByteHeader(struct adapter *pAdapter, u8 efuseType, u16 *pAddr, struct pgpkt *pTargetPkt, bool bPseudoTest) +{ + bool bRet = false; + u8 pg_header = 0, tmp_header = 0; + u16 efuse_addr = *pAddr; + u8 repeatcnt = 0; + + pg_header = ((pTargetPkt->offset << 4) & 0xf0) | pTargetPkt->word_en; + + efuse_OneByteWrite(pAdapter, efuse_addr, pg_header, bPseudoTest); + efuse_OneByteRead(pAdapter, efuse_addr, &tmp_header, bPseudoTest); + + while (tmp_header == 0xFF) { + if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_) + return false; + efuse_OneByteWrite(pAdapter, efuse_addr, pg_header, bPseudoTest); + efuse_OneByteRead(pAdapter, efuse_addr, &tmp_header, bPseudoTest); + } + + if (pg_header == tmp_header) { + bRet = true; + } else { + struct pgpkt fixPkt; + fixPkt.offset = (tmp_header>>4) & 0x0F; + fixPkt.word_en = tmp_header & 0x0F; + fixPkt.word_cnts = Efuse_CalculateWordCnts(fixPkt.word_en); + if (!hal_EfuseFixHeaderProcess(pAdapter, efuseType, &fixPkt, &efuse_addr, bPseudoTest)) + return false; + } + + *pAddr = efuse_addr; + return bRet; +} + +static bool hal_EfusePgPacketWriteData(struct adapter *pAdapter, u8 efuseType, u16 *pAddr, struct pgpkt *pTargetPkt, bool bPseudoTest) +{ + bool bRet = false; + u16 efuse_addr = *pAddr; + u8 badworden = 0; + u32 PgWriteSuccess = 0; + + badworden = 0x0f; + badworden = Efuse_WordEnableDataWrite(pAdapter, efuse_addr+1, pTargetPkt->word_en, pTargetPkt->data, bPseudoTest); + if (badworden == 0x0F) { + /* write ok */ + return true; + } else { + /* reorganize other pg packet */ + PgWriteSuccess = Efuse_PgPacketWrite(pAdapter, pTargetPkt->offset, badworden, pTargetPkt->data, bPseudoTest); + if (!PgWriteSuccess) + return false; + else + return true; + } + return bRet; +} + +static bool +hal_EfusePgPacketWriteHeader( + struct adapter *pAdapter, + u8 efuseType, + u16 *pAddr, + struct pgpkt *pTargetPkt, + bool bPseudoTest) +{ + bool bRet = false; + + if (pTargetPkt->offset >= EFUSE_MAX_SECTION_BASE) + bRet = hal_EfusePgPacketWrite2ByteHeader(pAdapter, efuseType, pAddr, pTargetPkt, bPseudoTest); + else + bRet = hal_EfusePgPacketWrite1ByteHeader(pAdapter, efuseType, pAddr, pTargetPkt, bPseudoTest); + + return bRet; +} + +static bool wordEnMatched(struct pgpkt *pTargetPkt, struct pgpkt *pCurPkt, + u8 *pWden) +{ + u8 match_word_en = 0x0F; /* default all words are disabled */ + + /* check if the same words are enabled both target and current PG packet */ + if (((pTargetPkt->word_en & BIT0) == 0) && + ((pCurPkt->word_en & BIT0) == 0)) + match_word_en &= ~BIT0; /* enable word 0 */ + if (((pTargetPkt->word_en & BIT1) == 0) && + ((pCurPkt->word_en & BIT1) == 0)) + match_word_en &= ~BIT1; /* enable word 1 */ + if (((pTargetPkt->word_en & BIT2) == 0) && + ((pCurPkt->word_en & BIT2) == 0)) + match_word_en &= ~BIT2; /* enable word 2 */ + if (((pTargetPkt->word_en & BIT3) == 0) && + ((pCurPkt->word_en & BIT3) == 0)) + match_word_en &= ~BIT3; /* enable word 3 */ + + *pWden = match_word_en; + + if (match_word_en != 0xf) + return true; + else + return false; +} + +static bool hal_EfuseCheckIfDatafollowed(struct adapter *pAdapter, u8 word_cnts, u16 startAddr, bool bPseudoTest) +{ + bool bRet = false; + u8 i, efuse_data; + + for (i = 0; i < (word_cnts*2); i++) { + if (efuse_OneByteRead(pAdapter, (startAddr+i), &efuse_data, bPseudoTest) && (efuse_data != 0xFF)) + bRet = true; + } + return bRet; +} + +static bool hal_EfusePartialWriteCheck(struct adapter *pAdapter, u8 efuseType, u16 *pAddr, struct pgpkt *pTargetPkt, bool bPseudoTest) +{ + bool bRet = false; + u8 i, efuse_data = 0, cur_header = 0; + u8 matched_wden = 0, badworden = 0; + u16 startAddr = 0, efuse_max_available_len = 0, efuse_max = 0; + struct pgpkt curPkt; + + EFUSE_GetEfuseDefinition(pAdapter, efuseType, TYPE_AVAILABLE_EFUSE_BYTES_BANK, (void *)&efuse_max_available_len, bPseudoTest); + EFUSE_GetEfuseDefinition(pAdapter, efuseType, TYPE_EFUSE_REAL_CONTENT_LEN, (void *)&efuse_max, bPseudoTest); + + if (efuseType == EFUSE_WIFI) { + if (bPseudoTest) { + startAddr = (u16)(fakeEfuseUsedBytes%EFUSE_REAL_CONTENT_LEN); + } else { + rtw_hal_get_hwreg(pAdapter, HW_VAR_EFUSE_BYTES, (u8 *)&startAddr); + startAddr %= EFUSE_REAL_CONTENT_LEN; + } + } else { + if (bPseudoTest) + startAddr = (u16)(fakeBTEfuseUsedBytes%EFUSE_REAL_CONTENT_LEN); + else + startAddr = (u16)(BTEfuseUsedBytes%EFUSE_REAL_CONTENT_LEN); + } + + while (1) { + if (startAddr >= efuse_max_available_len) { + bRet = false; + break; + } + + if (efuse_OneByteRead(pAdapter, startAddr, &efuse_data, bPseudoTest) && (efuse_data != 0xFF)) { + if (EXT_HEADER(efuse_data)) { + cur_header = efuse_data; + startAddr++; + efuse_OneByteRead(pAdapter, startAddr, &efuse_data, bPseudoTest); + if (ALL_WORDS_DISABLED(efuse_data)) { + bRet = false; + break; + } else { + curPkt.offset = ((cur_header & 0xE0) >> 5) | ((efuse_data & 0xF0) >> 1); + curPkt.word_en = efuse_data & 0x0F; + } + } else { + cur_header = efuse_data; + curPkt.offset = (cur_header>>4) & 0x0F; + curPkt.word_en = cur_header & 0x0F; + } + + curPkt.word_cnts = Efuse_CalculateWordCnts(curPkt.word_en); + /* if same header is found but no data followed */ + /* write some part of data followed by the header. */ + if ((curPkt.offset == pTargetPkt->offset) && + (!hal_EfuseCheckIfDatafollowed(pAdapter, curPkt.word_cnts, startAddr+1, bPseudoTest)) && + wordEnMatched(pTargetPkt, &curPkt, &matched_wden)) { + /* Here to write partial data */ + badworden = Efuse_WordEnableDataWrite(pAdapter, startAddr+1, matched_wden, pTargetPkt->data, bPseudoTest); + if (badworden != 0x0F) { + u32 PgWriteSuccess = 0; + /* if write fail on some words, write these bad words again */ + + PgWriteSuccess = Efuse_PgPacketWrite(pAdapter, pTargetPkt->offset, badworden, pTargetPkt->data, bPseudoTest); + + if (!PgWriteSuccess) { + bRet = false; /* write fail, return */ + break; + } + } + /* partial write ok, update the target packet for later use */ + for (i = 0; i < 4; i++) { + if ((matched_wden & (0x1<word_en |= (0x1<word_cnts = Efuse_CalculateWordCnts(pTargetPkt->word_en); + } + /* read from next header */ + startAddr = startAddr + (curPkt.word_cnts*2) + 1; + } else { + /* not used header, 0xff */ + *pAddr = startAddr; + bRet = true; + break; + } + } + return bRet; +} + +static bool +hal_EfusePgCheckAvailableAddr( + struct adapter *pAdapter, + u8 efuseType, + bool bPseudoTest + ) +{ + u16 efuse_max_available_len = 0; + + /* Change to check TYPE_EFUSE_MAP_LEN , beacuse 8188E raw 256, logic map over 256. */ + EFUSE_GetEfuseDefinition(pAdapter, EFUSE_WIFI, TYPE_EFUSE_MAP_LEN, (void *)&efuse_max_available_len, false); + + if (Efuse_GetCurrentSize(pAdapter, efuseType, bPseudoTest) >= efuse_max_available_len) + return false; + return true; +} + +static void hal_EfuseConstructPGPkt(u8 offset, u8 word_en, u8 *pData, struct pgpkt *pTargetPkt) +{ + _rtw_memset((void *)pTargetPkt->data, 0xFF, sizeof(u8)*8); + pTargetPkt->offset = offset; + pTargetPkt->word_en = word_en; + efuse_WordEnableDataRead(word_en, pData, pTargetPkt->data); + pTargetPkt->word_cnts = Efuse_CalculateWordCnts(pTargetPkt->word_en); +} + +static bool hal_EfusePgPacketWrite_8188e(struct adapter *pAdapter, u8 offset, u8 word_en, u8 *pData, bool bPseudoTest) +{ + struct pgpkt targetPkt; + u16 startAddr = 0; + u8 efuseType = EFUSE_WIFI; + + if (!hal_EfusePgCheckAvailableAddr(pAdapter, efuseType, bPseudoTest)) + return false; + + hal_EfuseConstructPGPkt(offset, word_en, pData, &targetPkt); + + if (!hal_EfusePartialWriteCheck(pAdapter, efuseType, &startAddr, &targetPkt, bPseudoTest)) + return false; + + if (!hal_EfusePgPacketWriteHeader(pAdapter, efuseType, &startAddr, &targetPkt, bPseudoTest)) + return false; + + if (!hal_EfusePgPacketWriteData(pAdapter, efuseType, &startAddr, &targetPkt, bPseudoTest)) + return false; + + return true; +} + +static int Hal_EfusePgPacketWrite_Pseudo(struct adapter *pAdapter, u8 offset, u8 word_en, u8 *data, bool bPseudoTest) +{ + int ret; + + ret = hal_EfusePgPacketWrite_8188e(pAdapter, offset, word_en, data, bPseudoTest); + return ret; +} + +static int Hal_EfusePgPacketWrite(struct adapter *pAdapter, u8 offset, u8 word_en, u8 *data, bool bPseudoTest) +{ + int ret = 0; + ret = hal_EfusePgPacketWrite_8188e(pAdapter, offset, word_en, data, bPseudoTest); + + return ret; +} + +static int rtl8188e_Efuse_PgPacketWrite(struct adapter *pAdapter, u8 offset, u8 word_en, u8 *data, bool bPseudoTest) +{ + int ret; + + if (bPseudoTest) + ret = Hal_EfusePgPacketWrite_Pseudo (pAdapter, offset, word_en, data, bPseudoTest); + else + ret = Hal_EfusePgPacketWrite(pAdapter, offset, word_en, data, bPseudoTest); + return ret; +} + +static struct HAL_VERSION ReadChipVersion8188E(struct adapter *padapter) +{ + u32 value32; + struct HAL_VERSION ChipVersion; + struct hal_data_8188e *pHalData; + + pHalData = GET_HAL_DATA(padapter); + + value32 = rtw_read32(padapter, REG_SYS_CFG); + ChipVersion.ICType = CHIP_8188E; + ChipVersion.ChipType = ((value32 & RTL_ID) ? TEST_CHIP : NORMAL_CHIP); + + ChipVersion.RFType = RF_TYPE_1T1R; + ChipVersion.VendorType = ((value32 & VENDOR_ID) ? CHIP_VENDOR_UMC : CHIP_VENDOR_TSMC); + ChipVersion.CUTVersion = (value32 & CHIP_VER_RTL_MASK)>>CHIP_VER_RTL_SHIFT; /* IC version (CUT) */ + + /* For regulator mode. by tynli. 2011.01.14 */ + pHalData->RegulatorMode = ((value32 & TRP_BT_EN) ? RT_LDO_REGULATOR : RT_SWITCHING_REGULATOR); + + ChipVersion.ROMVer = 0; /* ROM code version. */ + pHalData->MultiFunc = RT_MULTI_FUNC_NONE; + + dump_chip_info(ChipVersion); + + pHalData->VersionID = ChipVersion; + + if (IS_1T2R(ChipVersion)) { + pHalData->rf_type = RF_1T2R; + pHalData->NumTotalRFPath = 2; + } else if (IS_2T2R(ChipVersion)) { + pHalData->rf_type = RF_2T2R; + pHalData->NumTotalRFPath = 2; + } else{ + pHalData->rf_type = RF_1T1R; + pHalData->NumTotalRFPath = 1; + } + + MSG_88E("RF_Type is %x!!\n", pHalData->rf_type); + + return ChipVersion; +} + +static void rtl8188e_read_chip_version(struct adapter *padapter) +{ + ReadChipVersion8188E(padapter); +} + +static void rtl8188e_GetHalODMVar(struct adapter *Adapter, enum hal_odm_variable eVariable, void *pValue1, bool bSet) +{ +} + +static void rtl8188e_SetHalODMVar(struct adapter *Adapter, enum hal_odm_variable eVariable, void *pValue1, bool bSet) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + struct odm_dm_struct *podmpriv = &pHalData->odmpriv; + switch (eVariable) { + case HAL_ODM_STA_INFO: + { + struct sta_info *psta = (struct sta_info *)pValue1; + if (bSet) { + DBG_88E("### Set STA_(%d) info\n", psta->mac_id); + ODM_CmnInfoPtrArrayHook(podmpriv, ODM_CMNINFO_STA_STATUS, psta->mac_id, psta); + ODM_RAInfo_Init(podmpriv, psta->mac_id); + } else { + DBG_88E("### Clean STA_(%d) info\n", psta->mac_id); + ODM_CmnInfoPtrArrayHook(podmpriv, ODM_CMNINFO_STA_STATUS, psta->mac_id, NULL); + } + } + break; + case HAL_ODM_P2P_STATE: + ODM_CmnInfoUpdate(podmpriv, ODM_CMNINFO_WIFI_DIRECT, bSet); + break; + case HAL_ODM_WIFI_DISPLAY_STATE: + ODM_CmnInfoUpdate(podmpriv, ODM_CMNINFO_WIFI_DISPLAY, bSet); + break; + default: + break; + } +} + +void rtl8188e_clone_haldata(struct adapter *dst_adapter, struct adapter *src_adapter) +{ + memcpy(dst_adapter->HalData, src_adapter->HalData, dst_adapter->hal_data_sz); +} + +void rtl8188e_start_thread(struct adapter *padapter) +{ +} + +void rtl8188e_stop_thread(struct adapter *padapter) +{ +} + +static void hal_notch_filter_8188e(struct adapter *adapter, bool enable) +{ + if (enable) { + DBG_88E("Enable notch filter\n"); + rtw_write8(adapter, rOFDM0_RxDSP+1, rtw_read8(adapter, rOFDM0_RxDSP+1) | BIT1); + } else { + DBG_88E("Disable notch filter\n"); + rtw_write8(adapter, rOFDM0_RxDSP+1, rtw_read8(adapter, rOFDM0_RxDSP+1) & ~BIT1); + } +} +void rtl8188e_set_hal_ops(struct hal_ops *pHalFunc) +{ + pHalFunc->free_hal_data = &rtl8188e_free_hal_data; + + pHalFunc->dm_init = &rtl8188e_init_dm_priv; + pHalFunc->dm_deinit = &rtl8188e_deinit_dm_priv; + + pHalFunc->read_chip_version = &rtl8188e_read_chip_version; + + pHalFunc->set_bwmode_handler = &PHY_SetBWMode8188E; + pHalFunc->set_channel_handler = &PHY_SwChnl8188E; + + pHalFunc->hal_dm_watchdog = &rtl8188e_HalDmWatchDog; + + pHalFunc->Add_RateATid = &rtl8188e_Add_RateATid; + pHalFunc->run_thread = &rtl8188e_start_thread; + pHalFunc->cancel_thread = &rtl8188e_stop_thread; + + pHalFunc->AntDivBeforeLinkHandler = &AntDivBeforeLink8188E; + pHalFunc->AntDivCompareHandler = &AntDivCompare8188E; + pHalFunc->read_bbreg = &rtl8188e_PHY_QueryBBReg; + pHalFunc->write_bbreg = &rtl8188e_PHY_SetBBReg; + pHalFunc->read_rfreg = &rtl8188e_PHY_QueryRFReg; + pHalFunc->write_rfreg = &rtl8188e_PHY_SetRFReg; + + /* Efuse related function */ + pHalFunc->EfusePowerSwitch = &rtl8188e_EfusePowerSwitch; + pHalFunc->ReadEFuse = &rtl8188e_ReadEFuse; + pHalFunc->EFUSEGetEfuseDefinition = &rtl8188e_EFUSE_GetEfuseDefinition; + pHalFunc->EfuseGetCurrentSize = &rtl8188e_EfuseGetCurrentSize; + pHalFunc->Efuse_PgPacketRead = &rtl8188e_Efuse_PgPacketRead; + pHalFunc->Efuse_PgPacketWrite = &rtl8188e_Efuse_PgPacketWrite; + pHalFunc->Efuse_WordEnableDataWrite = &rtl8188e_Efuse_WordEnableDataWrite; + + pHalFunc->sreset_init_value = &sreset_init_value; + pHalFunc->sreset_reset_value = &sreset_reset_value; + pHalFunc->silentreset = &rtl8188e_silentreset_for_specific_platform; + pHalFunc->sreset_xmit_status_check = &rtl8188e_sreset_xmit_status_check; + pHalFunc->sreset_linked_status_check = &rtl8188e_sreset_linked_status_check; + pHalFunc->sreset_get_wifi_status = &sreset_get_wifi_status; + + pHalFunc->GetHalODMVarHandler = &rtl8188e_GetHalODMVar; + pHalFunc->SetHalODMVarHandler = &rtl8188e_SetHalODMVar; + + pHalFunc->IOL_exec_cmds_sync = &rtl8188e_IOL_exec_cmds_sync; + + pHalFunc->hal_notch_filter = &hal_notch_filter_8188e; +} + +u8 GetEEPROMSize8188E(struct adapter *padapter) +{ + u8 size = 0; + u32 cr; + + cr = rtw_read16(padapter, REG_9346CR); + /* 6: EEPROM used is 93C46, 4: boot from E-Fuse. */ + size = (cr & BOOT_FROM_EEPROM) ? 6 : 4; + + MSG_88E("EEPROM type is %s\n", size == 4 ? "E-FUSE" : "93C46"); + + return size; +} + +/* */ +/* */ +/* LLT R/W/Init function */ +/* */ +/* */ +static s32 _LLTWrite(struct adapter *padapter, u32 address, u32 data) +{ + s32 status = _SUCCESS; + s32 count = 0; + u32 value = _LLT_INIT_ADDR(address) | _LLT_INIT_DATA(data) | _LLT_OP(_LLT_WRITE_ACCESS); + u16 LLTReg = REG_LLT_INIT; + + rtw_write32(padapter, LLTReg, value); + + /* polling */ + do { + value = rtw_read32(padapter, LLTReg); + if (_LLT_NO_ACTIVE == _LLT_OP_VALUE(value)) + break; + + if (count > POLLING_LLT_THRESHOLD) { + RT_TRACE(_module_hal_init_c_, _drv_err_, ("Failed to polling write LLT done at address %d!\n", address)); + status = _FAIL; + break; + } + } while (count++); + + return status; +} + +s32 InitLLTTable(struct adapter *padapter, u8 txpktbuf_bndy) +{ + s32 status = _FAIL; + u32 i; + u32 Last_Entry_Of_TxPktBuf = LAST_ENTRY_OF_TX_PKT_BUFFER;/* 176, 22k */ + + if (rtw_IOL_applied(padapter)) { + status = iol_InitLLTTable(padapter, txpktbuf_bndy); + } else { + for (i = 0; i < (txpktbuf_bndy - 1); i++) { + status = _LLTWrite(padapter, i, i + 1); + if (_SUCCESS != status) + return status; + } + + /* end of list */ + status = _LLTWrite(padapter, (txpktbuf_bndy - 1), 0xFF); + if (_SUCCESS != status) + return status; + + /* Make the other pages as ring buffer */ + /* This ring buffer is used as beacon buffer if we config this MAC as two MAC transfer. */ + /* Otherwise used as local loopback buffer. */ + for (i = txpktbuf_bndy; i < Last_Entry_Of_TxPktBuf; i++) { + status = _LLTWrite(padapter, i, (i + 1)); + if (_SUCCESS != status) + return status; + } + + /* Let last entry point to the start entry of ring buffer */ + status = _LLTWrite(padapter, Last_Entry_Of_TxPktBuf, txpktbuf_bndy); + if (_SUCCESS != status) { + return status; + } + } + + return status; +} + +void +Hal_InitPGData88E(struct adapter *padapter) +{ + struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter); + + if (!pEEPROM->bautoload_fail_flag) { /* autoload OK. */ + if (!is_boot_from_eeprom(padapter)) { + /* Read EFUSE real map to shadow. */ + EFUSE_ShadowMapUpdate(padapter, EFUSE_WIFI, false); + } + } else {/* autoload fail */ + RT_TRACE(_module_hci_hal_init_c_, _drv_notice_, ("AutoLoad Fail reported from CR9346!!\n")); + /* update to default value 0xFF */ + if (!is_boot_from_eeprom(padapter)) + EFUSE_ShadowMapUpdate(padapter, EFUSE_WIFI, false); + } +} + +void +Hal_EfuseParseIDCode88E( + struct adapter *padapter, + u8 *hwinfo + ) +{ + struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter); + u16 EEPROMId; + + /* Checl 0x8129 again for making sure autoload status!! */ + EEPROMId = le16_to_cpu(*((__le16 *)hwinfo)); + if (EEPROMId != RTL_EEPROM_ID) { + DBG_88E("EEPROM ID(%#x) is invalid!!\n", EEPROMId); + pEEPROM->bautoload_fail_flag = true; + } else { + pEEPROM->bautoload_fail_flag = false; + } + + DBG_88E("EEPROM ID = 0x%04x\n", EEPROMId); +} + +static void Hal_ReadPowerValueFromPROM_8188E(struct txpowerinfo24g *pwrInfo24G, u8 *PROMContent, bool AutoLoadFail) +{ + u32 rfPath, eeAddr = EEPROM_TX_PWR_INX_88E, group, TxCount = 0; + + _rtw_memset(pwrInfo24G, 0, sizeof(struct txpowerinfo24g)); + + if (AutoLoadFail) { + for (rfPath = 0; rfPath < MAX_RF_PATH; rfPath++) { + /* 2.4G default value */ + for (group = 0; group < MAX_CHNL_GROUP_24G; group++) { + pwrInfo24G->IndexCCK_Base[rfPath][group] = EEPROM_DEFAULT_24G_INDEX; + pwrInfo24G->IndexBW40_Base[rfPath][group] = EEPROM_DEFAULT_24G_INDEX; + } + for (TxCount = 0; TxCount < MAX_TX_COUNT; TxCount++) { + if (TxCount == 0) { + pwrInfo24G->BW20_Diff[rfPath][0] = EEPROM_DEFAULT_24G_HT20_DIFF; + pwrInfo24G->OFDM_Diff[rfPath][0] = EEPROM_DEFAULT_24G_OFDM_DIFF; + } else { + pwrInfo24G->BW20_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; + pwrInfo24G->BW40_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; + pwrInfo24G->CCK_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; + pwrInfo24G->OFDM_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; + } + } + } + return; + } + + for (rfPath = 0; rfPath < MAX_RF_PATH; rfPath++) { + /* 2.4G default value */ + for (group = 0; group < MAX_CHNL_GROUP_24G; group++) { + pwrInfo24G->IndexCCK_Base[rfPath][group] = PROMContent[eeAddr++]; + if (pwrInfo24G->IndexCCK_Base[rfPath][group] == 0xFF) + pwrInfo24G->IndexCCK_Base[rfPath][group] = EEPROM_DEFAULT_24G_INDEX; + } + for (group = 0; group < MAX_CHNL_GROUP_24G-1; group++) { + pwrInfo24G->IndexBW40_Base[rfPath][group] = PROMContent[eeAddr++]; + if (pwrInfo24G->IndexBW40_Base[rfPath][group] == 0xFF) + pwrInfo24G->IndexBW40_Base[rfPath][group] = EEPROM_DEFAULT_24G_INDEX; + } + for (TxCount = 0; TxCount < MAX_TX_COUNT; TxCount++) { + if (TxCount == 0) { + pwrInfo24G->BW40_Diff[rfPath][TxCount] = 0; + if (PROMContent[eeAddr] == 0xFF) { + pwrInfo24G->BW20_Diff[rfPath][TxCount] = EEPROM_DEFAULT_24G_HT20_DIFF; + } else { + pwrInfo24G->BW20_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0xf0)>>4; + if (pwrInfo24G->BW20_Diff[rfPath][TxCount] & BIT3) /* 4bit sign number to 8 bit sign number */ + pwrInfo24G->BW20_Diff[rfPath][TxCount] |= 0xF0; + } + + if (PROMContent[eeAddr] == 0xFF) { + pwrInfo24G->OFDM_Diff[rfPath][TxCount] = EEPROM_DEFAULT_24G_OFDM_DIFF; + } else { + pwrInfo24G->OFDM_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0x0f); + if (pwrInfo24G->OFDM_Diff[rfPath][TxCount] & BIT3) /* 4bit sign number to 8 bit sign number */ + pwrInfo24G->OFDM_Diff[rfPath][TxCount] |= 0xF0; + } + pwrInfo24G->CCK_Diff[rfPath][TxCount] = 0; + eeAddr++; + } else { + if (PROMContent[eeAddr] == 0xFF) { + pwrInfo24G->BW40_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; + } else { + pwrInfo24G->BW40_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0xf0)>>4; + if (pwrInfo24G->BW40_Diff[rfPath][TxCount] & BIT3) /* 4bit sign number to 8 bit sign number */ + pwrInfo24G->BW40_Diff[rfPath][TxCount] |= 0xF0; + } + + if (PROMContent[eeAddr] == 0xFF) { + pwrInfo24G->BW20_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; + } else { + pwrInfo24G->BW20_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0x0f); + if (pwrInfo24G->BW20_Diff[rfPath][TxCount] & BIT3) /* 4bit sign number to 8 bit sign number */ + pwrInfo24G->BW20_Diff[rfPath][TxCount] |= 0xF0; + } + eeAddr++; + + if (PROMContent[eeAddr] == 0xFF) { + pwrInfo24G->OFDM_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; + } else { + pwrInfo24G->OFDM_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0xf0)>>4; + if (pwrInfo24G->OFDM_Diff[rfPath][TxCount] & BIT3) /* 4bit sign number to 8 bit sign number */ + pwrInfo24G->OFDM_Diff[rfPath][TxCount] |= 0xF0; + } + + if (PROMContent[eeAddr] == 0xFF) { + pwrInfo24G->CCK_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; + } else { + pwrInfo24G->CCK_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0x0f); + if (pwrInfo24G->CCK_Diff[rfPath][TxCount] & BIT3) /* 4bit sign number to 8 bit sign number */ + pwrInfo24G->CCK_Diff[rfPath][TxCount] |= 0xF0; + } + eeAddr++; + } + } + } +} + +static u8 Hal_GetChnlGroup88E(u8 chnl, u8 *pGroup) +{ + u8 bIn24G = true; + + if (chnl <= 14) { + bIn24G = true; + + if (chnl < 3) /* Chanel 1-2 */ + *pGroup = 0; + else if (chnl < 6) /* Channel 3-5 */ + *pGroup = 1; + else if (chnl < 9) /* Channel 6-8 */ + *pGroup = 2; + else if (chnl < 12) /* Channel 9-11 */ + *pGroup = 3; + else if (chnl < 14) /* Channel 12-13 */ + *pGroup = 4; + else if (chnl == 14) /* Channel 14 */ + *pGroup = 5; + } else { + bIn24G = false; + + if (chnl <= 40) + *pGroup = 0; + else if (chnl <= 48) + *pGroup = 1; + else if (chnl <= 56) + *pGroup = 2; + else if (chnl <= 64) + *pGroup = 3; + else if (chnl <= 104) + *pGroup = 4; + else if (chnl <= 112) + *pGroup = 5; + else if (chnl <= 120) + *pGroup = 5; + else if (chnl <= 128) + *pGroup = 6; + else if (chnl <= 136) + *pGroup = 7; + else if (chnl <= 144) + *pGroup = 8; + else if (chnl <= 153) + *pGroup = 9; + else if (chnl <= 161) + *pGroup = 10; + else if (chnl <= 177) + *pGroup = 11; + } + return bIn24G; +} + +void Hal_ReadPowerSavingMode88E(struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail) +{ + if (AutoLoadFail) { + padapter->pwrctrlpriv.bHWPowerdown = false; + padapter->pwrctrlpriv.bSupportRemoteWakeup = false; + } else { + /* hw power down mode selection , 0:rf-off / 1:power down */ + + if (padapter->registrypriv.hwpdn_mode == 2) + padapter->pwrctrlpriv.bHWPowerdown = (hwinfo[EEPROM_RF_FEATURE_OPTION_88E] & BIT4); + else + padapter->pwrctrlpriv.bHWPowerdown = padapter->registrypriv.hwpdn_mode; + + /* decide hw if support remote wakeup function */ + /* if hw supported, 8051 (SIE) will generate WeakUP signal(D+/D- toggle) when autoresume */ + padapter->pwrctrlpriv.bSupportRemoteWakeup = (hwinfo[EEPROM_USB_OPTIONAL_FUNCTION0] & BIT1) ? true : false; + + DBG_88E("%s...bHWPwrPindetect(%x)-bHWPowerdown(%x) , bSupportRemoteWakeup(%x)\n", __func__, + padapter->pwrctrlpriv.bHWPwrPindetect, padapter->pwrctrlpriv.bHWPowerdown , padapter->pwrctrlpriv.bSupportRemoteWakeup); + + DBG_88E("### PS params => power_mgnt(%x), usbss_enable(%x) ###\n", padapter->registrypriv.power_mgnt, padapter->registrypriv.usbss_enable); + } +} + +void Hal_ReadTxPowerInfo88E(struct adapter *padapter, u8 *PROMContent, bool AutoLoadFail) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); + struct txpowerinfo24g pwrInfo24G; + u8 rfPath, ch, group; + u8 bIn24G, TxCount; + + Hal_ReadPowerValueFromPROM_8188E(&pwrInfo24G, PROMContent, AutoLoadFail); + + if (!AutoLoadFail) + pHalData->bTXPowerDataReadFromEEPORM = true; + + for (rfPath = 0; rfPath < pHalData->NumTotalRFPath; rfPath++) { + for (ch = 0; ch <= CHANNEL_MAX_NUMBER; ch++) { + bIn24G = Hal_GetChnlGroup88E(ch, &group); + if (bIn24G) { + pHalData->Index24G_CCK_Base[rfPath][ch] = pwrInfo24G.IndexCCK_Base[rfPath][group]; + if (ch == 14) + pHalData->Index24G_BW40_Base[rfPath][ch] = pwrInfo24G.IndexBW40_Base[rfPath][4]; + else + pHalData->Index24G_BW40_Base[rfPath][ch] = pwrInfo24G.IndexBW40_Base[rfPath][group]; + } + if (bIn24G) { + DBG_88E("======= Path %d, Channel %d =======\n", rfPath, ch); + DBG_88E("Index24G_CCK_Base[%d][%d] = 0x%x\n", rfPath, ch , pHalData->Index24G_CCK_Base[rfPath][ch]); + DBG_88E("Index24G_BW40_Base[%d][%d] = 0x%x\n", rfPath, ch , pHalData->Index24G_BW40_Base[rfPath][ch]); + } + } + for (TxCount = 0; TxCount < MAX_TX_COUNT; TxCount++) { + pHalData->CCK_24G_Diff[rfPath][TxCount] = pwrInfo24G.CCK_Diff[rfPath][TxCount]; + pHalData->OFDM_24G_Diff[rfPath][TxCount] = pwrInfo24G.OFDM_Diff[rfPath][TxCount]; + pHalData->BW20_24G_Diff[rfPath][TxCount] = pwrInfo24G.BW20_Diff[rfPath][TxCount]; + pHalData->BW40_24G_Diff[rfPath][TxCount] = pwrInfo24G.BW40_Diff[rfPath][TxCount]; + DBG_88E("======= TxCount %d =======\n", TxCount); + DBG_88E("CCK_24G_Diff[%d][%d] = %d\n", rfPath, TxCount, pHalData->CCK_24G_Diff[rfPath][TxCount]); + DBG_88E("OFDM_24G_Diff[%d][%d] = %d\n", rfPath, TxCount, pHalData->OFDM_24G_Diff[rfPath][TxCount]); + DBG_88E("BW20_24G_Diff[%d][%d] = %d\n", rfPath, TxCount, pHalData->BW20_24G_Diff[rfPath][TxCount]); + DBG_88E("BW40_24G_Diff[%d][%d] = %d\n", rfPath, TxCount, pHalData->BW40_24G_Diff[rfPath][TxCount]); + } + } + + /* 2010/10/19 MH Add Regulator recognize for CU. */ + if (!AutoLoadFail) { + pHalData->EEPROMRegulatory = (PROMContent[EEPROM_RF_BOARD_OPTION_88E]&0x7); /* bit0~2 */ + if (PROMContent[EEPROM_RF_BOARD_OPTION_88E] == 0xFF) + pHalData->EEPROMRegulatory = (EEPROM_DEFAULT_BOARD_OPTION&0x7); /* bit0~2 */ + } else { + pHalData->EEPROMRegulatory = 0; + } + DBG_88E("EEPROMRegulatory = 0x%x\n", pHalData->EEPROMRegulatory); +} + +void Hal_EfuseParseXtal_8188E(struct adapter *pAdapter, u8 *hwinfo, bool AutoLoadFail) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); + + if (!AutoLoadFail) { + pHalData->CrystalCap = hwinfo[EEPROM_XTAL_88E]; + if (pHalData->CrystalCap == 0xFF) + pHalData->CrystalCap = EEPROM_Default_CrystalCap_88E; + } else { + pHalData->CrystalCap = EEPROM_Default_CrystalCap_88E; + } + DBG_88E("CrystalCap: 0x%2x\n", pHalData->CrystalCap); +} + +void Hal_EfuseParseBoardType88E(struct adapter *pAdapter, u8 *hwinfo, bool AutoLoadFail) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); + + if (!AutoLoadFail) + pHalData->BoardType = ((hwinfo[EEPROM_RF_BOARD_OPTION_88E]&0xE0)>>5); + else + pHalData->BoardType = 0; + DBG_88E("Board Type: 0x%2x\n", pHalData->BoardType); +} + +void Hal_EfuseParseEEPROMVer88E(struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); + + if (!AutoLoadFail) { + pHalData->EEPROMVersion = hwinfo[EEPROM_VERSION_88E]; + if (pHalData->EEPROMVersion == 0xFF) + pHalData->EEPROMVersion = EEPROM_Default_Version; + } else { + pHalData->EEPROMVersion = 1; + } + RT_TRACE(_module_hci_hal_init_c_, _drv_info_, + ("Hal_EfuseParseEEPROMVer(), EEVer = %d\n", + pHalData->EEPROMVersion)); +} + +void rtl8188e_EfuseParseChnlPlan(struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail) +{ + padapter->mlmepriv.ChannelPlan = + hal_com_get_channel_plan(padapter, + hwinfo ? hwinfo[EEPROM_ChannelPlan_88E] : 0xFF, + padapter->registrypriv.channel_plan, + RT_CHANNEL_DOMAIN_WORLD_WIDE_13, AutoLoadFail); + + DBG_88E("mlmepriv.ChannelPlan = 0x%02x\n", padapter->mlmepriv.ChannelPlan); +} + +void Hal_EfuseParseCustomerID88E(struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); + + if (!AutoLoadFail) { + pHalData->EEPROMCustomerID = hwinfo[EEPROM_CUSTOMERID_88E]; + } else { + pHalData->EEPROMCustomerID = 0; + pHalData->EEPROMSubCustomerID = 0; + } + DBG_88E("EEPROM Customer ID: 0x%2x\n", pHalData->EEPROMCustomerID); +} + +void Hal_ReadAntennaDiversity88E(struct adapter *pAdapter, u8 *PROMContent, bool AutoLoadFail) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); + struct registry_priv *registry_par = &pAdapter->registrypriv; + + if (!AutoLoadFail) { + /* Antenna Diversity setting. */ + if (registry_par->antdiv_cfg == 2) { /* 2:By EFUSE */ + pHalData->AntDivCfg = (PROMContent[EEPROM_RF_BOARD_OPTION_88E]&0x18)>>3; + if (PROMContent[EEPROM_RF_BOARD_OPTION_88E] == 0xFF) + pHalData->AntDivCfg = (EEPROM_DEFAULT_BOARD_OPTION&0x18)>>3;; + } else { + pHalData->AntDivCfg = registry_par->antdiv_cfg; /* 0:OFF , 1:ON, 2:By EFUSE */ + } + + if (registry_par->antdiv_type == 0) { + /* If TRxAntDivType is AUTO in advanced setting, use EFUSE value instead. */ + pHalData->TRxAntDivType = PROMContent[EEPROM_RF_ANTENNA_OPT_88E]; + if (pHalData->TRxAntDivType == 0xFF) + pHalData->TRxAntDivType = CG_TRX_HW_ANTDIV; /* For 88EE, 1Tx and 1RxCG are fixed.(1Ant, Tx and RxCG are both on aux port) */ + } else { + pHalData->TRxAntDivType = registry_par->antdiv_type; + } + + if (pHalData->TRxAntDivType == CG_TRX_HW_ANTDIV || pHalData->TRxAntDivType == CGCS_RX_HW_ANTDIV) + pHalData->AntDivCfg = 1; /* 0xC1[3] is ignored. */ + } else { + pHalData->AntDivCfg = 0; + pHalData->TRxAntDivType = pHalData->TRxAntDivType; /* The value in the driver setting of device manager. */ + } + DBG_88E("EEPROM : AntDivCfg = %x, TRxAntDivType = %x\n", pHalData->AntDivCfg, pHalData->TRxAntDivType); +} + +void Hal_ReadThermalMeter_88E(struct adapter *Adapter, u8 *PROMContent, bool AutoloadFail) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + + /* ThermalMeter from EEPROM */ + if (!AutoloadFail) + pHalData->EEPROMThermalMeter = PROMContent[EEPROM_THERMAL_METER_88E]; + else + pHalData->EEPROMThermalMeter = EEPROM_Default_ThermalMeter_88E; + + if (pHalData->EEPROMThermalMeter == 0xff || AutoloadFail) { + pHalData->bAPKThermalMeterIgnore = true; + pHalData->EEPROMThermalMeter = EEPROM_Default_ThermalMeter_88E; + } + DBG_88E("ThermalMeter = 0x%x\n", pHalData->EEPROMThermalMeter); +} + +void Hal_InitChannelPlan(struct adapter *padapter) +{ +} + +bool HalDetectPwrDownMode88E(struct adapter *Adapter) +{ + u8 tmpvalue = 0; + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + struct pwrctrl_priv *pwrctrlpriv = &Adapter->pwrctrlpriv; + + EFUSE_ShadowRead(Adapter, 1, EEPROM_RF_FEATURE_OPTION_88E, (u32 *)&tmpvalue); + + /* 2010/08/25 MH INF priority > PDN Efuse value. */ + if (tmpvalue & BIT(4) && pwrctrlpriv->reg_pdnmode) + pHalData->pwrdown = true; + else + pHalData->pwrdown = false; + + DBG_88E("HalDetectPwrDownMode(): PDN =%d\n", pHalData->pwrdown); + + return pHalData->pwrdown; +} /* HalDetectPwrDownMode */ + +/* This function is used only for 92C to set REG_BCN_CTRL(0x550) register. */ +/* We just reserve the value of the register in variable pHalData->RegBcnCtrlVal and then operate */ +/* the value of the register via atomic operation. */ +/* This prevents from race condition when setting this register. */ +/* The value of pHalData->RegBcnCtrlVal is initialized in HwConfigureRTL8192CE() function. */ + +void SetBcnCtrlReg(struct adapter *padapter, u8 SetBits, u8 ClearBits) +{ + struct hal_data_8188e *pHalData; + + pHalData = GET_HAL_DATA(padapter); + + pHalData->RegBcnCtrlVal |= SetBits; + pHalData->RegBcnCtrlVal &= ~ClearBits; + + rtw_write8(padapter, REG_BCN_CTRL, (u8)pHalData->RegBcnCtrlVal); +} diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_mp.c b/drivers/staging/rtl8188eu/hal/rtl8188e_mp.c new file mode 100644 index 0000000000000..e97ba02fa0452 --- /dev/null +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_mp.c @@ -0,0 +1,860 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTL8188E_MP_C_ + +#include +#include +#include +#include + +s32 Hal_SetPowerTracking(struct adapter *padapter, u8 enable) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); + struct odm_dm_struct *pDM_Odm = &(pHalData->odmpriv); + + if (!netif_running(padapter->pnetdev)) { + RT_TRACE(_module_mp_, _drv_warning_, + ("SetPowerTracking! Fail: interface not opened!\n")); + return _FAIL; + } + + if (!check_fwstate(&padapter->mlmepriv, WIFI_MP_STATE)) { + RT_TRACE(_module_mp_, _drv_warning_, + ("SetPowerTracking! Fail: not in MP mode!\n")); + return _FAIL; + } + + if (enable) + pDM_Odm->RFCalibrateInfo.bTXPowerTracking = true; + else + pDM_Odm->RFCalibrateInfo.bTXPowerTrackingInit = false; + + return _SUCCESS; +} + +void Hal_GetPowerTracking(struct adapter *padapter, u8 *enable) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); + struct odm_dm_struct *pDM_Odm = &(pHalData->odmpriv); + + *enable = pDM_Odm->RFCalibrateInfo.TxPowerTrackControl; +} + +/*----------------------------------------------------------------------------- + * Function: mpt_SwitchRfSetting + * + * Overview: Change RF Setting when we siwthc channel/rate/BW for MP. + * + * Input: struct adapter * pAdapter + * + * Output: NONE + * + * Return: NONE + * + * Revised History: + * When Who Remark + * 01/08/2009 MHC Suggestion from SD3 Willis for 92S series. + * 01/09/2009 MHC Add CCK modification for 40MHZ. Suggestion from SD3. + * + *---------------------------------------------------------------------------*/ +void Hal_mpt_SwitchRfSetting(struct adapter *pAdapter) +{ + struct mp_priv *pmp = &pAdapter->mppriv; + + /* <20120525, Kordan> Dynamic mechanism for APK, asked by Dennis. */ + pmp->MptCtx.backup0x52_RF_A = (u8)PHY_QueryRFReg(pAdapter, RF_PATH_A, RF_0x52, 0x000F0); + pmp->MptCtx.backup0x52_RF_B = (u8)PHY_QueryRFReg(pAdapter, RF_PATH_B, RF_0x52, 0x000F0); + PHY_SetRFReg(pAdapter, RF_PATH_A, RF_0x52, 0x000F0, 0xD); + PHY_SetRFReg(pAdapter, RF_PATH_B, RF_0x52, 0x000F0, 0xD); + + return; +} +/*---------------------------hal\rtl8192c\MPT_Phy.c---------------------------*/ + +/*---------------------------hal\rtl8192c\MPT_HelperFunc.c---------------------------*/ +void Hal_MPT_CCKTxPowerAdjust(struct adapter *Adapter, bool bInCH14) +{ + u32 TempVal = 0, TempVal2 = 0, TempVal3 = 0; + u32 CurrCCKSwingVal = 0, CCKSwingIndex = 12; + u8 i; + + /* get current cck swing value and check 0xa22 & 0xa23 later to match the table. */ + CurrCCKSwingVal = read_bbreg(Adapter, rCCK0_TxFilter1, bMaskHWord); + + if (!bInCH14) { + /* Readback the current bb cck swing value and compare with the table to */ + /* get the current swing index */ + for (i = 0; i < CCK_TABLE_SIZE; i++) { + if (((CurrCCKSwingVal&0xff) == (u32)CCKSwingTable_Ch1_Ch13[i][0]) && + (((CurrCCKSwingVal&0xff00)>>8) == (u32)CCKSwingTable_Ch1_Ch13[i][1])) { + CCKSwingIndex = i; + break; + } + } + + /* Write 0xa22 0xa23 */ + TempVal = CCKSwingTable_Ch1_Ch13[CCKSwingIndex][0] + + (CCKSwingTable_Ch1_Ch13[CCKSwingIndex][1]<<8); + + + /* Write 0xa24 ~ 0xa27 */ + TempVal2 = 0; + TempVal2 = CCKSwingTable_Ch1_Ch13[CCKSwingIndex][2] + + (CCKSwingTable_Ch1_Ch13[CCKSwingIndex][3]<<8) + + (CCKSwingTable_Ch1_Ch13[CCKSwingIndex][4]<<16)+ + (CCKSwingTable_Ch1_Ch13[CCKSwingIndex][5]<<24); + + /* Write 0xa28 0xa29 */ + TempVal3 = 0; + TempVal3 = CCKSwingTable_Ch1_Ch13[CCKSwingIndex][6] + + (CCKSwingTable_Ch1_Ch13[CCKSwingIndex][7]<<8); + } else { + for (i = 0; i < CCK_TABLE_SIZE; i++) { + if (((CurrCCKSwingVal&0xff) == (u32)CCKSwingTable_Ch14[i][0]) && + (((CurrCCKSwingVal&0xff00)>>8) == (u32)CCKSwingTable_Ch14[i][1])) { + CCKSwingIndex = i; + break; + } + } + + /* Write 0xa22 0xa23 */ + TempVal = CCKSwingTable_Ch14[CCKSwingIndex][0] + + (CCKSwingTable_Ch14[CCKSwingIndex][1]<<8); + + /* Write 0xa24 ~ 0xa27 */ + TempVal2 = 0; + TempVal2 = CCKSwingTable_Ch14[CCKSwingIndex][2] + + (CCKSwingTable_Ch14[CCKSwingIndex][3]<<8) + + (CCKSwingTable_Ch14[CCKSwingIndex][4]<<16)+ + (CCKSwingTable_Ch14[CCKSwingIndex][5]<<24); + + /* Write 0xa28 0xa29 */ + TempVal3 = 0; + TempVal3 = CCKSwingTable_Ch14[CCKSwingIndex][6] + + (CCKSwingTable_Ch14[CCKSwingIndex][7]<<8); + } + + write_bbreg(Adapter, rCCK0_TxFilter1, bMaskHWord, TempVal); + write_bbreg(Adapter, rCCK0_TxFilter2, bMaskDWord, TempVal2); + write_bbreg(Adapter, rCCK0_DebugPort, bMaskLWord, TempVal3); +} + +void Hal_MPT_CCKTxPowerAdjustbyIndex(struct adapter *pAdapter, bool beven) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); + struct mpt_context *pMptCtx = &pAdapter->mppriv.MptCtx; + struct odm_dm_struct *pDM_Odm = &(pHalData->odmpriv); + s32 TempCCk; + u8 CCK_index, CCK_index_old = 0; + u8 Action = 0; /* 0: no action, 1: even->odd, 2:odd->even */ + s32 i = 0; + + + if (!IS_92C_SERIAL(pHalData->VersionID)) + return; + if (beven && !pMptCtx->bMptIndexEven) { + /* odd->even */ + Action = 2; + pMptCtx->bMptIndexEven = true; + } else if (!beven && pMptCtx->bMptIndexEven) { + /* even->odd */ + Action = 1; + pMptCtx->bMptIndexEven = false; + } + + if (Action != 0) { + /* Query CCK default setting From 0xa24 */ + TempCCk = read_bbreg(pAdapter, rCCK0_TxFilter2, bMaskDWord) & bMaskCCK; + for (i = 0; i < CCK_TABLE_SIZE; i++) { + if (pDM_Odm->RFCalibrateInfo.bCCKinCH14) { + if (_rtw_memcmp((void *)&TempCCk, (void *)&CCKSwingTable_Ch14[i][2], 4)) { + CCK_index_old = (u8)i; + break; + } + } else { + if (_rtw_memcmp((void *)&TempCCk, (void *)&CCKSwingTable_Ch1_Ch13[i][2], 4)) { + CCK_index_old = (u8)i; + break; + } + } + } + + if (Action == 1) + CCK_index = CCK_index_old - 1; + else + CCK_index = CCK_index_old + 1; + + /* Adjust CCK according to gain index */ + if (!pDM_Odm->RFCalibrateInfo.bCCKinCH14) { + rtw_write8(pAdapter, 0xa22, CCKSwingTable_Ch1_Ch13[CCK_index][0]); + rtw_write8(pAdapter, 0xa23, CCKSwingTable_Ch1_Ch13[CCK_index][1]); + rtw_write8(pAdapter, 0xa24, CCKSwingTable_Ch1_Ch13[CCK_index][2]); + rtw_write8(pAdapter, 0xa25, CCKSwingTable_Ch1_Ch13[CCK_index][3]); + rtw_write8(pAdapter, 0xa26, CCKSwingTable_Ch1_Ch13[CCK_index][4]); + rtw_write8(pAdapter, 0xa27, CCKSwingTable_Ch1_Ch13[CCK_index][5]); + rtw_write8(pAdapter, 0xa28, CCKSwingTable_Ch1_Ch13[CCK_index][6]); + rtw_write8(pAdapter, 0xa29, CCKSwingTable_Ch1_Ch13[CCK_index][7]); + } else { + rtw_write8(pAdapter, 0xa22, CCKSwingTable_Ch14[CCK_index][0]); + rtw_write8(pAdapter, 0xa23, CCKSwingTable_Ch14[CCK_index][1]); + rtw_write8(pAdapter, 0xa24, CCKSwingTable_Ch14[CCK_index][2]); + rtw_write8(pAdapter, 0xa25, CCKSwingTable_Ch14[CCK_index][3]); + rtw_write8(pAdapter, 0xa26, CCKSwingTable_Ch14[CCK_index][4]); + rtw_write8(pAdapter, 0xa27, CCKSwingTable_Ch14[CCK_index][5]); + rtw_write8(pAdapter, 0xa28, CCKSwingTable_Ch14[CCK_index][6]); + rtw_write8(pAdapter, 0xa29, CCKSwingTable_Ch14[CCK_index][7]); + } + } +} +/*---------------------------hal\rtl8192c\MPT_HelperFunc.c---------------------------*/ + +/* + * SetChannel + * Description + * Use H2C command to change channel, + * not only modify rf register, but also other setting need to be done. + */ +void Hal_SetChannel(struct adapter *pAdapter) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); + struct mp_priv *pmp = &pAdapter->mppriv; + struct odm_dm_struct *pDM_Odm = &(pHalData->odmpriv); + u8 eRFPath; + u8 channel = pmp->channel; + + /* set RF channel register */ + for (eRFPath = 0; eRFPath < pHalData->NumTotalRFPath; eRFPath++) + _write_rfreg(pAdapter, eRFPath, ODM_CHANNEL, 0x3FF, channel); + Hal_mpt_SwitchRfSetting(pAdapter); + + SelectChannel(pAdapter, channel); + + if (pHalData->CurrentChannel == 14 && !pDM_Odm->RFCalibrateInfo.bCCKinCH14) { + pDM_Odm->RFCalibrateInfo.bCCKinCH14 = true; + Hal_MPT_CCKTxPowerAdjust(pAdapter, pDM_Odm->RFCalibrateInfo.bCCKinCH14); + } else if (pHalData->CurrentChannel != 14 && pDM_Odm->RFCalibrateInfo.bCCKinCH14) { + pDM_Odm->RFCalibrateInfo.bCCKinCH14 = false; + Hal_MPT_CCKTxPowerAdjust(pAdapter, pDM_Odm->RFCalibrateInfo.bCCKinCH14); + } +} + +/* + * Notice + * Switch bandwitdth may change center frequency(channel) + */ +void Hal_SetBandwidth(struct adapter *pAdapter) +{ + struct mp_priv *pmp = &pAdapter->mppriv; + + + SetBWMode(pAdapter, pmp->bandwidth, pmp->prime_channel_offset); + Hal_mpt_SwitchRfSetting(pAdapter); +} + +void Hal_SetCCKTxPower(struct adapter *pAdapter, u8 *TxPower) +{ + u32 tmpval = 0; + + + /* rf-A cck tx power */ + write_bbreg(pAdapter, rTxAGC_A_CCK1_Mcs32, bMaskByte1, TxPower[RF_PATH_A]); + tmpval = (TxPower[RF_PATH_A]<<16) | (TxPower[RF_PATH_A]<<8) | TxPower[RF_PATH_A]; + write_bbreg(pAdapter, rTxAGC_B_CCK11_A_CCK2_11, 0xffffff00, tmpval); + + /* rf-B cck tx power */ + write_bbreg(pAdapter, rTxAGC_B_CCK11_A_CCK2_11, bMaskByte0, TxPower[RF_PATH_B]); + tmpval = (TxPower[RF_PATH_B]<<16) | (TxPower[RF_PATH_B]<<8) | TxPower[RF_PATH_B]; + write_bbreg(pAdapter, rTxAGC_B_CCK1_55_Mcs32, 0xffffff00, tmpval); + + RT_TRACE(_module_mp_, _drv_notice_, + ("-SetCCKTxPower: A[0x%02x] B[0x%02x]\n", + TxPower[RF_PATH_A], TxPower[RF_PATH_B])); +} + +void Hal_SetOFDMTxPower(struct adapter *pAdapter, u8 *TxPower) +{ + u32 TxAGC = 0; + u8 tmpval = 0; + + /* HT Tx-rf(A) */ + tmpval = TxPower[RF_PATH_A]; + TxAGC = (tmpval<<24) | (tmpval<<16) | (tmpval<<8) | tmpval; + + write_bbreg(pAdapter, rTxAGC_A_Rate18_06, bMaskDWord, TxAGC); + write_bbreg(pAdapter, rTxAGC_A_Rate54_24, bMaskDWord, TxAGC); + write_bbreg(pAdapter, rTxAGC_A_Mcs03_Mcs00, bMaskDWord, TxAGC); + write_bbreg(pAdapter, rTxAGC_A_Mcs07_Mcs04, bMaskDWord, TxAGC); + write_bbreg(pAdapter, rTxAGC_A_Mcs11_Mcs08, bMaskDWord, TxAGC); + write_bbreg(pAdapter, rTxAGC_A_Mcs15_Mcs12, bMaskDWord, TxAGC); + + /* HT Tx-rf(B) */ + tmpval = TxPower[RF_PATH_B]; + TxAGC = (tmpval<<24) | (tmpval<<16) | (tmpval<<8) | tmpval; + + write_bbreg(pAdapter, rTxAGC_B_Rate18_06, bMaskDWord, TxAGC); + write_bbreg(pAdapter, rTxAGC_B_Rate54_24, bMaskDWord, TxAGC); + write_bbreg(pAdapter, rTxAGC_B_Mcs03_Mcs00, bMaskDWord, TxAGC); + write_bbreg(pAdapter, rTxAGC_B_Mcs07_Mcs04, bMaskDWord, TxAGC); + write_bbreg(pAdapter, rTxAGC_B_Mcs11_Mcs08, bMaskDWord, TxAGC); + write_bbreg(pAdapter, rTxAGC_B_Mcs15_Mcs12, bMaskDWord, TxAGC); +} + +void Hal_SetAntennaPathPower(struct adapter *pAdapter) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); + u8 TxPowerLevel[MAX_RF_PATH_NUMS]; + u8 rfPath; + + TxPowerLevel[RF_PATH_A] = pAdapter->mppriv.txpoweridx; + TxPowerLevel[RF_PATH_B] = pAdapter->mppriv.txpoweridx_b; + + switch (pAdapter->mppriv.antenna_tx) { + case ANTENNA_A: + default: + rfPath = RF_PATH_A; + break; + case ANTENNA_B: + rfPath = RF_PATH_B; + break; + case ANTENNA_C: + rfPath = RF_PATH_C; + break; + } + + switch (pHalData->rf_chip) { + case RF_8225: + case RF_8256: + case RF_6052: + Hal_SetCCKTxPower(pAdapter, TxPowerLevel); + if (pAdapter->mppriv.rateidx < MPT_RATE_6M) /* CCK rate */ + Hal_MPT_CCKTxPowerAdjustbyIndex(pAdapter, TxPowerLevel[rfPath]%2 == 0); + Hal_SetOFDMTxPower(pAdapter, TxPowerLevel); + break; + default: + break; + } +} + +void Hal_SetTxPower(struct adapter *pAdapter) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); + u8 TxPower = pAdapter->mppriv.txpoweridx; + u8 TxPowerLevel[MAX_RF_PATH_NUMS]; + u8 rf, rfPath; + + for (rf = 0; rf < MAX_RF_PATH_NUMS; rf++) + TxPowerLevel[rf] = TxPower; + + switch (pAdapter->mppriv.antenna_tx) { + case ANTENNA_A: + default: + rfPath = RF_PATH_A; + break; + case ANTENNA_B: + rfPath = RF_PATH_B; + break; + case ANTENNA_C: + rfPath = RF_PATH_C; + break; + } + + switch (pHalData->rf_chip) { + /* 2008/09/12 MH Test only !! We enable the TX power tracking for MP!!!!! */ + /* We should call normal driver API later!! */ + case RF_8225: + case RF_8256: + case RF_6052: + Hal_SetCCKTxPower(pAdapter, TxPowerLevel); + if (pAdapter->mppriv.rateidx < MPT_RATE_6M) /* CCK rate */ + Hal_MPT_CCKTxPowerAdjustbyIndex(pAdapter, TxPowerLevel[rfPath]%2 == 0); + Hal_SetOFDMTxPower(pAdapter, TxPowerLevel); + break; + default: + break; + } +} + +void Hal_SetDataRate(struct adapter *pAdapter) +{ + Hal_mpt_SwitchRfSetting(pAdapter); +} + +void Hal_SetAntenna(struct adapter *pAdapter) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); + + struct ant_sel_ofdm *p_ofdm_tx; /* OFDM Tx register */ + struct ant_sel_cck *p_cck_txrx; + u8 r_rx_antenna_ofdm = 0, r_ant_select_cck_val = 0; + u8 chgTx = 0, chgRx = 0; + u32 r_ant_select_ofdm_val = 0, r_ofdm_tx_en_val = 0; + + + p_ofdm_tx = (struct ant_sel_ofdm *)&r_ant_select_ofdm_val; + p_cck_txrx = (struct ant_sel_cck *)&r_ant_select_cck_val; + + p_ofdm_tx->r_ant_ht1 = 0x1; + p_ofdm_tx->r_ant_ht2 = 0x2; /* Second TX RF path is A */ + p_ofdm_tx->r_ant_non_ht = 0x3; /* 0x1+0x2=0x3 */ + + switch (pAdapter->mppriv.antenna_tx) { + case ANTENNA_A: + p_ofdm_tx->r_tx_antenna = 0x1; + r_ofdm_tx_en_val = 0x1; + p_ofdm_tx->r_ant_l = 0x1; + p_ofdm_tx->r_ant_ht_s1 = 0x1; + p_ofdm_tx->r_ant_non_ht_s1 = 0x1; + p_cck_txrx->r_ccktx_enable = 0x8; + chgTx = 1; + + /* From SD3 Willis suggestion !!! Set RF A=TX and B as standby */ + write_bbreg(pAdapter, rFPGA0_XA_HSSIParameter2, 0xe, 2); + write_bbreg(pAdapter, rFPGA0_XB_HSSIParameter2, 0xe, 1); + r_ofdm_tx_en_val = 0x3; + + /* Power save */ + + /* We need to close RFB by SW control */ + if (pHalData->rf_type == RF_2T2R) { + PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFInterfaceSW, BIT10, 0); + PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFInterfaceSW, BIT26, 1); + PHY_SetBBReg(pAdapter, rFPGA0_XB_RFInterfaceOE, BIT10, 0); + PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFParameter, BIT1, 1); + PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFParameter, BIT17, 0); + } + break; + case ANTENNA_B: + p_ofdm_tx->r_tx_antenna = 0x2; + r_ofdm_tx_en_val = 0x2; + p_ofdm_tx->r_ant_l = 0x2; + p_ofdm_tx->r_ant_ht_s1 = 0x2; + p_ofdm_tx->r_ant_non_ht_s1 = 0x2; + p_cck_txrx->r_ccktx_enable = 0x4; + chgTx = 1; + /* From SD3 Willis suggestion !!! Set RF A as standby */ + PHY_SetBBReg(pAdapter, rFPGA0_XA_HSSIParameter2, 0xe, 1); + PHY_SetBBReg(pAdapter, rFPGA0_XB_HSSIParameter2, 0xe, 2); + + /* Power save */ + /* cosa r_ant_select_ofdm_val = 0x22222222; */ + + /* 2008/10/31 MH From SD3 Willi's suggestion. We must read RF 1T table. */ + /* 2009/01/08 MH From Sd3 Willis. We need to close RFA by SW control */ + if (pHalData->rf_type == RF_2T2R || pHalData->rf_type == RF_1T2R) { + PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFInterfaceSW, BIT10, 1); + PHY_SetBBReg(pAdapter, rFPGA0_XA_RFInterfaceOE, BIT10, 0); + PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFInterfaceSW, BIT26, 0); + PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFParameter, BIT1, 0); + PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFParameter, BIT17, 1); + } + break; + case ANTENNA_AB: /* For 8192S */ + p_ofdm_tx->r_tx_antenna = 0x3; + r_ofdm_tx_en_val = 0x3; + p_ofdm_tx->r_ant_l = 0x3; + p_ofdm_tx->r_ant_ht_s1 = 0x3; + p_ofdm_tx->r_ant_non_ht_s1 = 0x3; + p_cck_txrx->r_ccktx_enable = 0xC; + chgTx = 1; + + /* From SD3 Willis suggestion !!! Set RF B as standby */ + PHY_SetBBReg(pAdapter, rFPGA0_XA_HSSIParameter2, 0xe, 2); + PHY_SetBBReg(pAdapter, rFPGA0_XB_HSSIParameter2, 0xe, 2); + + /* Disable Power save */ + /* cosa r_ant_select_ofdm_val = 0x3321333; */ + /* 2009/01/08 MH From Sd3 Willis. We need to enable RFA/B by SW control */ + if (pHalData->rf_type == RF_2T2R) { + PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFInterfaceSW, BIT10, 0); + PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFInterfaceSW, BIT26, 0); + PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFParameter, BIT1, 1); + PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFParameter, BIT17, 1); + } + break; + default: + break; + } + + /* r_rx_antenna_ofdm, bit0=A, bit1=B, bit2=C, bit3=D */ + /* r_cckrx_enable : CCK default, 0=A, 1=B, 2=C, 3=D */ + /* r_cckrx_enable_2 : CCK option, 0=A, 1=B, 2=C, 3=D */ + switch (pAdapter->mppriv.antenna_rx) { + case ANTENNA_A: + r_rx_antenna_ofdm = 0x1; /* A */ + p_cck_txrx->r_cckrx_enable = 0x0; /* default: A */ + p_cck_txrx->r_cckrx_enable_2 = 0x0; /* option: A */ + chgRx = 1; + break; + case ANTENNA_B: + r_rx_antenna_ofdm = 0x2; /* B */ + p_cck_txrx->r_cckrx_enable = 0x1; /* default: B */ + p_cck_txrx->r_cckrx_enable_2 = 0x1; /* option: B */ + chgRx = 1; + break; + case ANTENNA_AB: + r_rx_antenna_ofdm = 0x3; /* AB */ + p_cck_txrx->r_cckrx_enable = 0x0; /* default:A */ + p_cck_txrx->r_cckrx_enable_2 = 0x1; /* option:B */ + chgRx = 1; + break; + default: + break; + } + + if (chgTx && chgRx) { + switch (pHalData->rf_chip) { + case RF_8225: + case RF_8256: + case RF_6052: + /* r_ant_sel_cck_val = r_ant_select_cck_val; */ + PHY_SetBBReg(pAdapter, rFPGA1_TxInfo, 0x7fffffff, r_ant_select_ofdm_val); /* OFDM Tx */ + PHY_SetBBReg(pAdapter, rFPGA0_TxInfo, 0x0000000f, r_ofdm_tx_en_val); /* OFDM Tx */ + PHY_SetBBReg(pAdapter, rOFDM0_TRxPathEnable, 0x0000000f, r_rx_antenna_ofdm); /* OFDM Rx */ + PHY_SetBBReg(pAdapter, rOFDM1_TRxPathEnable, 0x0000000f, r_rx_antenna_ofdm); /* OFDM Rx */ + PHY_SetBBReg(pAdapter, rCCK0_AFESetting, bMaskByte3, r_ant_select_cck_val); /* CCK TxRx */ + + break; + default: + break; + } + } + + RT_TRACE(_module_mp_, _drv_notice_, ("-SwitchAntenna: finished\n")); +} + +s32 Hal_SetThermalMeter(struct adapter *pAdapter, u8 target_ther) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); + + + if (!netif_running(pAdapter->pnetdev)) { + RT_TRACE(_module_mp_, _drv_warning_, ("SetThermalMeter! Fail: interface not opened!\n")); + return _FAIL; + } + + if (check_fwstate(&pAdapter->mlmepriv, WIFI_MP_STATE) == false) { + RT_TRACE(_module_mp_, _drv_warning_, ("SetThermalMeter: Fail! not in MP mode!\n")); + return _FAIL; + } + + target_ther &= 0xff; + if (target_ther < 0x07) + target_ther = 0x07; + else if (target_ther > 0x1d) + target_ther = 0x1d; + + pHalData->EEPROMThermalMeter = target_ther; + + return _SUCCESS; +} + +void Hal_TriggerRFThermalMeter(struct adapter *pAdapter) +{ + _write_rfreg(pAdapter, RF_PATH_A , RF_T_METER_88E , BIT17 | BIT16 , 0x03); +} + +u8 Hal_ReadRFThermalMeter(struct adapter *pAdapter) +{ + u32 ThermalValue = 0; + + ThermalValue = _read_rfreg(pAdapter, RF_PATH_A, RF_T_METER_88E, 0xfc00); + return (u8)ThermalValue; +} + +void Hal_GetThermalMeter(struct adapter *pAdapter, u8 *value) +{ + Hal_TriggerRFThermalMeter(pAdapter); + rtw_msleep_os(1000); + *value = Hal_ReadRFThermalMeter(pAdapter); +} + +void Hal_SetSingleCarrierTx(struct adapter *pAdapter, u8 bStart) +{ + pAdapter->mppriv.MptCtx.bSingleCarrier = bStart; + if (bStart) { + /* Start Single Carrier. */ + RT_TRACE(_module_mp_, _drv_alert_, ("SetSingleCarrierTx: test start\n")); + /* 1. if OFDM block on? */ + if (!read_bbreg(pAdapter, rFPGA0_RFMOD, bOFDMEn)) + write_bbreg(pAdapter, rFPGA0_RFMOD, bOFDMEn, bEnable);/* set OFDM block on */ + + /* 2. set CCK test mode off, set to CCK normal mode */ + write_bbreg(pAdapter, rCCK0_System, bCCKBBMode, bDisable); + /* 3. turn on scramble setting */ + write_bbreg(pAdapter, rCCK0_System, bCCKScramble, bEnable); + /* 4. Turn On Single Carrier Tx and turn off the other test modes. */ + write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMContinueTx, bDisable); + write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMSingleCarrier, bEnable); + write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMSingleTone, bDisable); + /* for dynamic set Power index. */ + write_bbreg(pAdapter, rFPGA0_XA_HSSIParameter1, bMaskDWord, 0x01000500); + write_bbreg(pAdapter, rFPGA0_XB_HSSIParameter1, bMaskDWord, 0x01000500); + } else { + /* Stop Single Carrier. */ + RT_TRACE(_module_mp_, _drv_alert_, ("SetSingleCarrierTx: test stop\n")); + + /* Turn off all test modes. */ + write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMContinueTx, bDisable); + write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMSingleCarrier, bDisable); + write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMSingleTone, bDisable); + rtw_msleep_os(10); + + /* BB Reset */ + write_bbreg(pAdapter, rPMAC_Reset, bBBResetB, 0x0); + write_bbreg(pAdapter, rPMAC_Reset, bBBResetB, 0x1); + + /* Stop for dynamic set Power index. */ + write_bbreg(pAdapter, rFPGA0_XA_HSSIParameter1, bMaskDWord, 0x01000100); + write_bbreg(pAdapter, rFPGA0_XB_HSSIParameter1, bMaskDWord, 0x01000100); + } +} + + +void Hal_SetSingleToneTx(struct adapter *pAdapter, u8 bStart) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); + bool is92C = IS_92C_SERIAL(pHalData->VersionID); + + u8 rfPath; + u32 reg58 = 0x0; + switch (pAdapter->mppriv.antenna_tx) { + case ANTENNA_A: + default: + rfPath = RF_PATH_A; + break; + case ANTENNA_B: + rfPath = RF_PATH_B; + break; + case ANTENNA_C: + rfPath = RF_PATH_C; + break; + } + + pAdapter->mppriv.MptCtx.bSingleTone = bStart; + if (bStart) { + /* Start Single Tone. */ + RT_TRACE(_module_mp_, _drv_alert_, ("SetSingleToneTx: test start\n")); + /* <20120326, Kordan> To amplify the power of tone for Xtal calibration. (asked by Edlu) */ + if (IS_HARDWARE_TYPE_8188E(pAdapter)) { + reg58 = PHY_QueryRFReg(pAdapter, RF_PATH_A, LNA_Low_Gain_3, bRFRegOffsetMask); + reg58 &= 0xFFFFFFF0; + reg58 += 2; + PHY_SetRFReg(pAdapter, RF_PATH_A, LNA_Low_Gain_3, bRFRegOffsetMask, reg58); + } + PHY_SetBBReg(pAdapter, rFPGA0_RFMOD, bCCKEn, 0x0); + PHY_SetBBReg(pAdapter, rFPGA0_RFMOD, bOFDMEn, 0x0); + + if (is92C) { + _write_rfreg(pAdapter, RF_PATH_A, 0x21, BIT19, 0x01); + rtw_usleep_os(100); + if (rfPath == RF_PATH_A) + write_rfreg(pAdapter, RF_PATH_B, 0x00, 0x10000); /* PAD all on. */ + else if (rfPath == RF_PATH_B) + write_rfreg(pAdapter, RF_PATH_A, 0x00, 0x10000); /* PAD all on. */ + write_rfreg(pAdapter, rfPath, 0x00, 0x2001f); /* PAD all on. */ + rtw_usleep_os(100); + } else { + write_rfreg(pAdapter, rfPath, 0x21, 0xd4000); + rtw_usleep_os(100); + write_rfreg(pAdapter, rfPath, 0x00, 0x2001f); /* PAD all on. */ + rtw_usleep_os(100); + } + + /* for dynamic set Power index. */ + write_bbreg(pAdapter, rFPGA0_XA_HSSIParameter1, bMaskDWord, 0x01000500); + write_bbreg(pAdapter, rFPGA0_XB_HSSIParameter1, bMaskDWord, 0x01000500); + + } else { + /* Stop Single Tone. */ + RT_TRACE(_module_mp_, _drv_alert_, ("SetSingleToneTx: test stop\n")); + + /* <20120326, Kordan> To amplify the power of tone for Xtal calibration. (asked by Edlu) */ + /* <20120326, Kordan> Only in single tone mode. (asked by Edlu) */ + if (IS_HARDWARE_TYPE_8188E(pAdapter)) { + reg58 = PHY_QueryRFReg(pAdapter, RF_PATH_A, LNA_Low_Gain_3, bRFRegOffsetMask); + reg58 &= 0xFFFFFFF0; + PHY_SetRFReg(pAdapter, RF_PATH_A, LNA_Low_Gain_3, bRFRegOffsetMask, reg58); + } + write_bbreg(pAdapter, rFPGA0_RFMOD, bCCKEn, 0x1); + write_bbreg(pAdapter, rFPGA0_RFMOD, bOFDMEn, 0x1); + if (is92C) { + _write_rfreg(pAdapter, RF_PATH_A, 0x21, BIT19, 0x00); + rtw_usleep_os(100); + write_rfreg(pAdapter, RF_PATH_A, 0x00, 0x32d75); /* PAD all on. */ + write_rfreg(pAdapter, RF_PATH_B, 0x00, 0x32d75); /* PAD all on. */ + rtw_usleep_os(100); + } else { + write_rfreg(pAdapter, rfPath, 0x21, 0x54000); + rtw_usleep_os(100); + write_rfreg(pAdapter, rfPath, 0x00, 0x30000); /* PAD all on. */ + rtw_usleep_os(100); + } + + /* Stop for dynamic set Power index. */ + write_bbreg(pAdapter, rFPGA0_XA_HSSIParameter1, bMaskDWord, 0x01000100); + write_bbreg(pAdapter, rFPGA0_XB_HSSIParameter1, bMaskDWord, 0x01000100); + } +} + + + +void Hal_SetCarrierSuppressionTx(struct adapter *pAdapter, u8 bStart) +{ + pAdapter->mppriv.MptCtx.bCarrierSuppression = bStart; + if (bStart) { + /* Start Carrier Suppression. */ + RT_TRACE(_module_mp_, _drv_alert_, ("SetCarrierSuppressionTx: test start\n")); + if (pAdapter->mppriv.rateidx <= MPT_RATE_11M) { + /* 1. if CCK block on? */ + if (!read_bbreg(pAdapter, rFPGA0_RFMOD, bCCKEn)) + write_bbreg(pAdapter, rFPGA0_RFMOD, bCCKEn, bEnable);/* set CCK block on */ + + /* Turn Off All Test Mode */ + write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMContinueTx, bDisable); + write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMSingleCarrier, bDisable); + write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMSingleTone, bDisable); + + write_bbreg(pAdapter, rCCK0_System, bCCKBBMode, 0x2); /* transmit mode */ + write_bbreg(pAdapter, rCCK0_System, bCCKScramble, 0x0); /* turn off scramble setting */ + + /* Set CCK Tx Test Rate */ + write_bbreg(pAdapter, rCCK0_System, bCCKTxRate, 0x0); /* Set FTxRate to 1Mbps */ + } + + /* for dynamic set Power index. */ + write_bbreg(pAdapter, rFPGA0_XA_HSSIParameter1, bMaskDWord, 0x01000500); + write_bbreg(pAdapter, rFPGA0_XB_HSSIParameter1, bMaskDWord, 0x01000500); + } else { + /* Stop Carrier Suppression. */ + RT_TRACE(_module_mp_, _drv_alert_, ("SetCarrierSuppressionTx: test stop\n")); + if (pAdapter->mppriv.rateidx <= MPT_RATE_11M) { + write_bbreg(pAdapter, rCCK0_System, bCCKBBMode, 0x0); /* normal mode */ + write_bbreg(pAdapter, rCCK0_System, bCCKScramble, 0x1); /* turn on scramble setting */ + + /* BB Reset */ + write_bbreg(pAdapter, rPMAC_Reset, bBBResetB, 0x0); + write_bbreg(pAdapter, rPMAC_Reset, bBBResetB, 0x1); + } + + /* Stop for dynamic set Power index. */ + write_bbreg(pAdapter, rFPGA0_XA_HSSIParameter1, bMaskDWord, 0x01000100); + write_bbreg(pAdapter, rFPGA0_XB_HSSIParameter1, bMaskDWord, 0x01000100); + } +} + +void Hal_SetCCKContinuousTx(struct adapter *pAdapter, u8 bStart) +{ + u32 cckrate; + + if (bStart) { + RT_TRACE(_module_mp_, _drv_alert_, + ("SetCCKContinuousTx: test start\n")); + + /* 1. if CCK block on? */ + if (!read_bbreg(pAdapter, rFPGA0_RFMOD, bCCKEn)) + write_bbreg(pAdapter, rFPGA0_RFMOD, bCCKEn, bEnable);/* set CCK block on */ + + /* Turn Off All Test Mode */ + write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMContinueTx, bDisable); + write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMSingleCarrier, bDisable); + write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMSingleTone, bDisable); + /* Set CCK Tx Test Rate */ + cckrate = pAdapter->mppriv.rateidx; + write_bbreg(pAdapter, rCCK0_System, bCCKTxRate, cckrate); + write_bbreg(pAdapter, rCCK0_System, bCCKBBMode, 0x2); /* transmit mode */ + write_bbreg(pAdapter, rCCK0_System, bCCKScramble, bEnable); /* turn on scramble setting */ + + /* for dynamic set Power index. */ + write_bbreg(pAdapter, rFPGA0_XA_HSSIParameter1, bMaskDWord, 0x01000500); + write_bbreg(pAdapter, rFPGA0_XB_HSSIParameter1, bMaskDWord, 0x01000500); + } else { + RT_TRACE(_module_mp_, _drv_info_, + ("SetCCKContinuousTx: test stop\n")); + + write_bbreg(pAdapter, rCCK0_System, bCCKBBMode, 0x0); /* normal mode */ + write_bbreg(pAdapter, rCCK0_System, bCCKScramble, bEnable); /* turn on scramble setting */ + + /* BB Reset */ + write_bbreg(pAdapter, rPMAC_Reset, bBBResetB, 0x0); + write_bbreg(pAdapter, rPMAC_Reset, bBBResetB, 0x1); + + /* Stop for dynamic set Power index. */ + write_bbreg(pAdapter, rFPGA0_XA_HSSIParameter1, bMaskDWord, 0x01000100); + write_bbreg(pAdapter, rFPGA0_XB_HSSIParameter1, bMaskDWord, 0x01000100); + } + + pAdapter->mppriv.MptCtx.bCckContTx = bStart; + pAdapter->mppriv.MptCtx.bOfdmContTx = false; +} /* mpt_StartCckContTx */ + +void Hal_SetOFDMContinuousTx(struct adapter *pAdapter, u8 bStart) +{ + if (bStart) { + RT_TRACE(_module_mp_, _drv_info_, ("SetOFDMContinuousTx: test start\n")); + /* 1. if OFDM block on? */ + if (!read_bbreg(pAdapter, rFPGA0_RFMOD, bOFDMEn)) + write_bbreg(pAdapter, rFPGA0_RFMOD, bOFDMEn, bEnable);/* set OFDM block on */ + + /* 2. set CCK test mode off, set to CCK normal mode */ + write_bbreg(pAdapter, rCCK0_System, bCCKBBMode, bDisable); + + /* 3. turn on scramble setting */ + write_bbreg(pAdapter, rCCK0_System, bCCKScramble, bEnable); + /* 4. Turn On Continue Tx and turn off the other test modes. */ + write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMContinueTx, bEnable); + write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMSingleCarrier, bDisable); + write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMSingleTone, bDisable); + + /* for dynamic set Power index. */ + write_bbreg(pAdapter, rFPGA0_XA_HSSIParameter1, bMaskDWord, 0x01000500); + write_bbreg(pAdapter, rFPGA0_XB_HSSIParameter1, bMaskDWord, 0x01000500); + + } else { + RT_TRACE(_module_mp_, _drv_info_, ("SetOFDMContinuousTx: test stop\n")); + write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMContinueTx, bDisable); + write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMSingleCarrier, bDisable); + write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMSingleTone, bDisable); + /* Delay 10 ms */ + rtw_msleep_os(10); + /* BB Reset */ + write_bbreg(pAdapter, rPMAC_Reset, bBBResetB, 0x0); + write_bbreg(pAdapter, rPMAC_Reset, bBBResetB, 0x1); + + /* Stop for dynamic set Power index. */ + write_bbreg(pAdapter, rFPGA0_XA_HSSIParameter1, bMaskDWord, 0x01000100); + write_bbreg(pAdapter, rFPGA0_XB_HSSIParameter1, bMaskDWord, 0x01000100); + } + + pAdapter->mppriv.MptCtx.bCckContTx = false; + pAdapter->mppriv.MptCtx.bOfdmContTx = bStart; +} /* mpt_StartOfdmContTx */ + +void Hal_SetContinuousTx(struct adapter *pAdapter, u8 bStart) +{ + RT_TRACE(_module_mp_, _drv_info_, + ("SetContinuousTx: rate:%d\n", pAdapter->mppriv.rateidx)); + + pAdapter->mppriv.MptCtx.bStartContTx = bStart; + if (pAdapter->mppriv.rateidx <= MPT_RATE_11M) + Hal_SetCCKContinuousTx(pAdapter, bStart); + else if ((pAdapter->mppriv.rateidx >= MPT_RATE_6M) && + (pAdapter->mppriv.rateidx <= MPT_RATE_MCS15)) + Hal_SetOFDMContinuousTx(pAdapter, bStart); +} diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_phycfg.c b/drivers/staging/rtl8188eu/hal/rtl8188e_phycfg.c new file mode 100644 index 0000000000000..ff468a68e327b --- /dev/null +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_phycfg.c @@ -0,0 +1,1144 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTL8188E_PHYCFG_C_ + +#include +#include +#include +#include + +/*---------------------------Define Local Constant---------------------------*/ +/* Channel switch:The size of command tables for switch channel*/ +#define MAX_PRECMD_CNT 16 +#define MAX_RFDEPENDCMD_CNT 16 +#define MAX_POSTCMD_CNT 16 + +#define MAX_DOZE_WAITING_TIMES_9x 64 + +/*---------------------------Define Local Constant---------------------------*/ + + +/*------------------------Define global variable-----------------------------*/ + +/*------------------------Define local variable------------------------------*/ + + +/*--------------------Define export function prototype-----------------------*/ +/* Please refer to header file */ +/*--------------------Define export function prototype-----------------------*/ + +/*----------------------------Function Body----------------------------------*/ +/* */ +/* 1. BB register R/W API */ +/* */ + +/** +* Function: phy_CalculateBitShift +* +* OverView: Get shifted position of the BitMask +* +* Input: +* u32 BitMask, +* +* Output: none +* Return: u32 Return the shift bit bit position of the mask +*/ +static u32 phy_CalculateBitShift(u32 BitMask) +{ + u32 i; + + for (i = 0; i <= 31; i++) { + if (((BitMask>>i) & 0x1) == 1) + break; + } + return i; +} + +/** +* Function: PHY_QueryBBReg +* +* OverView: Read "sepcific bits" from BB register +* +* Input: +* struct adapter *Adapter, +* u32 RegAddr, The target address to be readback +* u32 BitMask The target bit position in the target address +* to be readback +* Output: None +* Return: u32 Data The readback register value +* Note: This function is equal to "GetRegSetting" in PHY programming guide +*/ +u32 +rtl8188e_PHY_QueryBBReg( + struct adapter *Adapter, + u32 RegAddr, + u32 BitMask + ) +{ + u32 ReturnValue = 0, OriginalValue, BitShift; + + OriginalValue = rtw_read32(Adapter, RegAddr); + BitShift = phy_CalculateBitShift(BitMask); + ReturnValue = (OriginalValue & BitMask) >> BitShift; + return ReturnValue; +} + + +/** +* Function: PHY_SetBBReg +* +* OverView: Write "Specific bits" to BB register (page 8~) +* +* Input: +* struct adapter *Adapter, +* u32 RegAddr, The target address to be modified +* u32 BitMask The target bit position in the target address +* to be modified +* u32 Data The new register value in the target bit position +* of the target address +* +* Output: None +* Return: None +* Note: This function is equal to "PutRegSetting" in PHY programming guide +*/ + +void rtl8188e_PHY_SetBBReg(struct adapter *Adapter, u32 RegAddr, u32 BitMask, u32 Data) +{ + u32 OriginalValue, BitShift; + + if (BitMask != bMaskDWord) { /* if not "double word" write */ + OriginalValue = rtw_read32(Adapter, RegAddr); + BitShift = phy_CalculateBitShift(BitMask); + Data = ((OriginalValue & (~BitMask)) | (Data << BitShift)); + } + + rtw_write32(Adapter, RegAddr, Data); +} + + +/* */ +/* 2. RF register R/W API */ +/* */ +/** +* Function: phy_RFSerialRead +* +* OverView: Read regster from RF chips +* +* Input: +* struct adapter *Adapter, +* enum rf_radio_path eRFPath, Radio path of A/B/C/D +* u32 Offset, The target address to be read +* +* Output: None +* Return: u32 reback value +* Note: Threre are three types of serial operations: +* 1. Software serial write +* 2. Hardware LSSI-Low Speed Serial Interface +* 3. Hardware HSSI-High speed +* serial write. Driver need to implement (1) and (2). +* This function is equal to the combination of RF_ReadReg() and RFLSSIRead() +*/ +static u32 +phy_RFSerialRead( + struct adapter *Adapter, + enum rf_radio_path eRFPath, + u32 Offset + ) +{ + u32 retValue = 0; + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + struct bb_reg_def *pPhyReg = &pHalData->PHYRegDef[eRFPath]; + u32 NewOffset; + u32 tmplong, tmplong2; + u8 RfPiEnable = 0; + /* */ + /* Make sure RF register offset is correct */ + /* */ + Offset &= 0xff; + + /* */ + /* Switch page for 8256 RF IC */ + /* */ + NewOffset = Offset; + + /* For 92S LSSI Read RFLSSIRead */ + /* For RF A/B write 0x824/82c(does not work in the future) */ + /* We must use 0x824 for RF A and B to execute read trigger */ + tmplong = PHY_QueryBBReg(Adapter, rFPGA0_XA_HSSIParameter2, bMaskDWord); + if (eRFPath == RF_PATH_A) + tmplong2 = tmplong; + else + tmplong2 = PHY_QueryBBReg(Adapter, pPhyReg->rfHSSIPara2, bMaskDWord); + + tmplong2 = (tmplong2 & (~bLSSIReadAddress)) | (NewOffset<<23) | bLSSIReadEdge; /* T65 RF */ + + PHY_SetBBReg(Adapter, rFPGA0_XA_HSSIParameter2, bMaskDWord, tmplong&(~bLSSIReadEdge)); + rtw_udelay_os(10);/* PlatformStallExecution(10); */ + + PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2, bMaskDWord, tmplong2); + rtw_udelay_os(100);/* PlatformStallExecution(100); */ + + rtw_udelay_os(10);/* PlatformStallExecution(10); */ + + if (eRFPath == RF_PATH_A) + RfPiEnable = (u8)PHY_QueryBBReg(Adapter, rFPGA0_XA_HSSIParameter1, BIT8); + else if (eRFPath == RF_PATH_B) + RfPiEnable = (u8)PHY_QueryBBReg(Adapter, rFPGA0_XB_HSSIParameter1, BIT8); + + if (RfPiEnable) { /* Read from BBreg8b8, 12 bits for 8190, 20bits for T65 RF */ + retValue = PHY_QueryBBReg(Adapter, pPhyReg->rfLSSIReadBackPi, bLSSIReadBackData); + } else { /* Read from BBreg8a0, 12 bits for 8190, 20 bits for T65 RF */ + retValue = PHY_QueryBBReg(Adapter, pPhyReg->rfLSSIReadBack, bLSSIReadBackData); + } + return retValue; +} + +/** +* Function: phy_RFSerialWrite +* +* OverView: Write data to RF register (page 8~) +* +* Input: +* struct adapter *Adapter, +* enum rf_radio_path eRFPath, Radio path of A/B/C/D +* u32 Offset, The target address to be read +* u32 Data The new register Data in the target bit position +* of the target to be read +* +* Output: None +* Return: None +* Note: Threre are three types of serial operations: +* 1. Software serial write +* 2. Hardware LSSI-Low Speed Serial Interface +* 3. Hardware HSSI-High speed +* serial write. Driver need to implement (1) and (2). +* This function is equal to the combination of RF_ReadReg() and RFLSSIRead() + * + * Note: For RF8256 only + * The total count of RTL8256(Zebra4) register is around 36 bit it only employs + * 4-bit RF address. RTL8256 uses "register mode control bit" (Reg00[12], Reg00[10]) + * to access register address bigger than 0xf. See "Appendix-4 in PHY Configuration + * programming guide" for more details. + * Thus, we define a sub-finction for RTL8526 register address conversion + * =========================================================== + * Register Mode RegCTL[1] RegCTL[0] Note + * (Reg00[12]) (Reg00[10]) + * =========================================================== + * Reg_Mode0 0 x Reg 0 ~15(0x0 ~ 0xf) + * ------------------------------------------------------------------ + * Reg_Mode1 1 0 Reg 16 ~30(0x1 ~ 0xf) + * ------------------------------------------------------------------ + * Reg_Mode2 1 1 Reg 31 ~ 45(0x1 ~ 0xf) + * ------------------------------------------------------------------ + * + * 2008/09/02 MH Add 92S RF definition + * + * + * +*/ +static void +phy_RFSerialWrite( + struct adapter *Adapter, + enum rf_radio_path eRFPath, + u32 Offset, + u32 Data + ) +{ + u32 DataAndAddr = 0; + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + struct bb_reg_def *pPhyReg = &pHalData->PHYRegDef[eRFPath]; + u32 NewOffset; + + + /* 2009/06/17 MH We can not execute IO for power save or other accident mode. */ + + Offset &= 0xff; + + /* */ + /* Switch page for 8256 RF IC */ + /* */ + NewOffset = Offset; + + /* */ + /* Put write addr in [5:0] and write data in [31:16] */ + /* */ + DataAndAddr = ((NewOffset<<20) | (Data&0x000fffff)) & 0x0fffffff; /* T65 RF */ + + /* */ + /* Write Operation */ + /* */ + PHY_SetBBReg(Adapter, pPhyReg->rf3wireOffset, bMaskDWord, DataAndAddr); +} + +/** +* Function: PHY_QueryRFReg +* +* OverView: Query "Specific bits" to RF register (page 8~) +* +* Input: +* struct adapter *Adapter, +* enum rf_radio_path eRFPath, Radio path of A/B/C/D +* u32 RegAddr, The target address to be read +* u32 BitMask The target bit position in the target address +* to be read +* +* Output: None +* Return: u32 Readback value +* Note: This function is equal to "GetRFRegSetting" in PHY programming guide +*/ +u32 rtl8188e_PHY_QueryRFReg(struct adapter *Adapter, enum rf_radio_path eRFPath, + u32 RegAddr, u32 BitMask) +{ + u32 Original_Value, Readback_Value, BitShift; + + Original_Value = phy_RFSerialRead(Adapter, eRFPath, RegAddr); + + BitShift = phy_CalculateBitShift(BitMask); + Readback_Value = (Original_Value & BitMask) >> BitShift; + return Readback_Value; +} + +/** +* Function: PHY_SetRFReg +* +* OverView: Write "Specific bits" to RF register (page 8~) +* +* Input: +* struct adapter *Adapter, +* enum rf_radio_path eRFPath, Radio path of A/B/C/D +* u32 RegAddr, The target address to be modified +* u32 BitMask The target bit position in the target address +* to be modified +* u32 Data The new register Data in the target bit position +* of the target address +* +* Output: None +* Return: None +* Note: This function is equal to "PutRFRegSetting" in PHY programming guide +*/ +void +rtl8188e_PHY_SetRFReg( + struct adapter *Adapter, + enum rf_radio_path eRFPath, + u32 RegAddr, + u32 BitMask, + u32 Data + ) +{ + u32 Original_Value, BitShift; + + /* RF data is 12 bits only */ + if (BitMask != bRFRegOffsetMask) { + Original_Value = phy_RFSerialRead(Adapter, eRFPath, RegAddr); + BitShift = phy_CalculateBitShift(BitMask); + Data = ((Original_Value & (~BitMask)) | (Data << BitShift)); + } + + phy_RFSerialWrite(Adapter, eRFPath, RegAddr, Data); +} + +/* */ +/* 3. Initial MAC/BB/RF config by reading MAC/BB/RF txt. */ +/* */ + +/*----------------------------------------------------------------------------- + * Function: PHY_MACConfig8192C + * + * Overview: Condig MAC by header file or parameter file. + * + * Input: NONE + * + * Output: NONE + * + * Return: NONE + * + * Revised History: + * When Who Remark + * 08/12/2008 MHC Create Version 0. + * + *---------------------------------------------------------------------------*/ +s32 PHY_MACConfig8188E(struct adapter *Adapter) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + int rtStatus = _SUCCESS; + + /* */ + /* Config MAC */ + /* */ + if (HAL_STATUS_FAILURE == ODM_ConfigMACWithHeaderFile(&pHalData->odmpriv)) + rtStatus = _FAIL; + + /* 2010.07.13 AMPDU aggregation number B */ + rtw_write16(Adapter, REG_MAX_AGGR_NUM, MAX_AGGR_NUM); + + return rtStatus; +} + +/** +* Function: phy_InitBBRFRegisterDefinition +* +* OverView: Initialize Register definition offset for Radio Path A/B/C/D +* +* Input: +* struct adapter *Adapter, +* +* Output: None +* Return: None +* Note: The initialization value is constant and it should never be changes +*/ +static void +phy_InitBBRFRegisterDefinition( + struct adapter *Adapter +) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + + /* RF Interface Sowrtware Control */ + pHalData->PHYRegDef[RF_PATH_A].rfintfs = rFPGA0_XAB_RFInterfaceSW; /* 16 LSBs if read 32-bit from 0x870 */ + pHalData->PHYRegDef[RF_PATH_B].rfintfs = rFPGA0_XAB_RFInterfaceSW; /* 16 MSBs if read 32-bit from 0x870 (16-bit for 0x872) */ + pHalData->PHYRegDef[RF_PATH_C].rfintfs = rFPGA0_XCD_RFInterfaceSW;/* 16 LSBs if read 32-bit from 0x874 */ + pHalData->PHYRegDef[RF_PATH_D].rfintfs = rFPGA0_XCD_RFInterfaceSW;/* 16 MSBs if read 32-bit from 0x874 (16-bit for 0x876) */ + + /* RF Interface Readback Value */ + pHalData->PHYRegDef[RF_PATH_A].rfintfi = rFPGA0_XAB_RFInterfaceRB; /* 16 LSBs if read 32-bit from 0x8E0 */ + pHalData->PHYRegDef[RF_PATH_B].rfintfi = rFPGA0_XAB_RFInterfaceRB;/* 16 MSBs if read 32-bit from 0x8E0 (16-bit for 0x8E2) */ + pHalData->PHYRegDef[RF_PATH_C].rfintfi = rFPGA0_XCD_RFInterfaceRB;/* 16 LSBs if read 32-bit from 0x8E4 */ + pHalData->PHYRegDef[RF_PATH_D].rfintfi = rFPGA0_XCD_RFInterfaceRB;/* 16 MSBs if read 32-bit from 0x8E4 (16-bit for 0x8E6) */ + + /* RF Interface Output (and Enable) */ + pHalData->PHYRegDef[RF_PATH_A].rfintfo = rFPGA0_XA_RFInterfaceOE; /* 16 LSBs if read 32-bit from 0x860 */ + pHalData->PHYRegDef[RF_PATH_B].rfintfo = rFPGA0_XB_RFInterfaceOE; /* 16 LSBs if read 32-bit from 0x864 */ + + /* RF Interface (Output and) Enable */ + pHalData->PHYRegDef[RF_PATH_A].rfintfe = rFPGA0_XA_RFInterfaceOE; /* 16 MSBs if read 32-bit from 0x860 (16-bit for 0x862) */ + pHalData->PHYRegDef[RF_PATH_B].rfintfe = rFPGA0_XB_RFInterfaceOE; /* 16 MSBs if read 32-bit from 0x864 (16-bit for 0x866) */ + + /* Addr of LSSI. Wirte RF register by driver */ + pHalData->PHYRegDef[RF_PATH_A].rf3wireOffset = rFPGA0_XA_LSSIParameter; /* LSSI Parameter */ + pHalData->PHYRegDef[RF_PATH_B].rf3wireOffset = rFPGA0_XB_LSSIParameter; + + /* RF parameter */ + pHalData->PHYRegDef[RF_PATH_A].rfLSSI_Select = rFPGA0_XAB_RFParameter; /* BB Band Select */ + pHalData->PHYRegDef[RF_PATH_B].rfLSSI_Select = rFPGA0_XAB_RFParameter; + pHalData->PHYRegDef[RF_PATH_C].rfLSSI_Select = rFPGA0_XCD_RFParameter; + pHalData->PHYRegDef[RF_PATH_D].rfLSSI_Select = rFPGA0_XCD_RFParameter; + + /* Tx AGC Gain Stage (same for all path. Should we remove this?) */ + pHalData->PHYRegDef[RF_PATH_A].rfTxGainStage = rFPGA0_TxGainStage; /* Tx gain stage */ + pHalData->PHYRegDef[RF_PATH_B].rfTxGainStage = rFPGA0_TxGainStage; /* Tx gain stage */ + pHalData->PHYRegDef[RF_PATH_C].rfTxGainStage = rFPGA0_TxGainStage; /* Tx gain stage */ + pHalData->PHYRegDef[RF_PATH_D].rfTxGainStage = rFPGA0_TxGainStage; /* Tx gain stage */ + + /* Tranceiver A~D HSSI Parameter-1 */ + pHalData->PHYRegDef[RF_PATH_A].rfHSSIPara1 = rFPGA0_XA_HSSIParameter1; /* wire control parameter1 */ + pHalData->PHYRegDef[RF_PATH_B].rfHSSIPara1 = rFPGA0_XB_HSSIParameter1; /* wire control parameter1 */ + + /* Tranceiver A~D HSSI Parameter-2 */ + pHalData->PHYRegDef[RF_PATH_A].rfHSSIPara2 = rFPGA0_XA_HSSIParameter2; /* wire control parameter2 */ + pHalData->PHYRegDef[RF_PATH_B].rfHSSIPara2 = rFPGA0_XB_HSSIParameter2; /* wire control parameter2 */ + + /* RF switch Control */ + pHalData->PHYRegDef[RF_PATH_A].rfSwitchControl = rFPGA0_XAB_SwitchControl; /* TR/Ant switch control */ + pHalData->PHYRegDef[RF_PATH_B].rfSwitchControl = rFPGA0_XAB_SwitchControl; + pHalData->PHYRegDef[RF_PATH_C].rfSwitchControl = rFPGA0_XCD_SwitchControl; + pHalData->PHYRegDef[RF_PATH_D].rfSwitchControl = rFPGA0_XCD_SwitchControl; + + /* AGC control 1 */ + pHalData->PHYRegDef[RF_PATH_A].rfAGCControl1 = rOFDM0_XAAGCCore1; + pHalData->PHYRegDef[RF_PATH_B].rfAGCControl1 = rOFDM0_XBAGCCore1; + pHalData->PHYRegDef[RF_PATH_C].rfAGCControl1 = rOFDM0_XCAGCCore1; + pHalData->PHYRegDef[RF_PATH_D].rfAGCControl1 = rOFDM0_XDAGCCore1; + + /* AGC control 2 */ + pHalData->PHYRegDef[RF_PATH_A].rfAGCControl2 = rOFDM0_XAAGCCore2; + pHalData->PHYRegDef[RF_PATH_B].rfAGCControl2 = rOFDM0_XBAGCCore2; + pHalData->PHYRegDef[RF_PATH_C].rfAGCControl2 = rOFDM0_XCAGCCore2; + pHalData->PHYRegDef[RF_PATH_D].rfAGCControl2 = rOFDM0_XDAGCCore2; + + /* RX AFE control 1 */ + pHalData->PHYRegDef[RF_PATH_A].rfRxIQImbalance = rOFDM0_XARxIQImbalance; + pHalData->PHYRegDef[RF_PATH_B].rfRxIQImbalance = rOFDM0_XBRxIQImbalance; + pHalData->PHYRegDef[RF_PATH_C].rfRxIQImbalance = rOFDM0_XCRxIQImbalance; + pHalData->PHYRegDef[RF_PATH_D].rfRxIQImbalance = rOFDM0_XDRxIQImbalance; + + /* RX AFE control 1 */ + pHalData->PHYRegDef[RF_PATH_A].rfRxAFE = rOFDM0_XARxAFE; + pHalData->PHYRegDef[RF_PATH_B].rfRxAFE = rOFDM0_XBRxAFE; + pHalData->PHYRegDef[RF_PATH_C].rfRxAFE = rOFDM0_XCRxAFE; + pHalData->PHYRegDef[RF_PATH_D].rfRxAFE = rOFDM0_XDRxAFE; + + /* Tx AFE control 1 */ + pHalData->PHYRegDef[RF_PATH_A].rfTxIQImbalance = rOFDM0_XATxIQImbalance; + pHalData->PHYRegDef[RF_PATH_B].rfTxIQImbalance = rOFDM0_XBTxIQImbalance; + pHalData->PHYRegDef[RF_PATH_C].rfTxIQImbalance = rOFDM0_XCTxIQImbalance; + pHalData->PHYRegDef[RF_PATH_D].rfTxIQImbalance = rOFDM0_XDTxIQImbalance; + + /* Tx AFE control 2 */ + pHalData->PHYRegDef[RF_PATH_A].rfTxAFE = rOFDM0_XATxAFE; + pHalData->PHYRegDef[RF_PATH_B].rfTxAFE = rOFDM0_XBTxAFE; + pHalData->PHYRegDef[RF_PATH_C].rfTxAFE = rOFDM0_XCTxAFE; + pHalData->PHYRegDef[RF_PATH_D].rfTxAFE = rOFDM0_XDTxAFE; + + /* Tranceiver LSSI Readback SI mode */ + pHalData->PHYRegDef[RF_PATH_A].rfLSSIReadBack = rFPGA0_XA_LSSIReadBack; + pHalData->PHYRegDef[RF_PATH_B].rfLSSIReadBack = rFPGA0_XB_LSSIReadBack; + pHalData->PHYRegDef[RF_PATH_C].rfLSSIReadBack = rFPGA0_XC_LSSIReadBack; + pHalData->PHYRegDef[RF_PATH_D].rfLSSIReadBack = rFPGA0_XD_LSSIReadBack; + + /* Tranceiver LSSI Readback PI mode */ + pHalData->PHYRegDef[RF_PATH_A].rfLSSIReadBackPi = TransceiverA_HSPI_Readback; + pHalData->PHYRegDef[RF_PATH_B].rfLSSIReadBackPi = TransceiverB_HSPI_Readback; +} + +void storePwrIndexDiffRateOffset(struct adapter *Adapter, u32 RegAddr, u32 BitMask, u32 Data) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + + if (RegAddr == rTxAGC_A_Rate18_06) + pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][0] = Data; + if (RegAddr == rTxAGC_A_Rate54_24) + pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][1] = Data; + if (RegAddr == rTxAGC_A_CCK1_Mcs32) + pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][6] = Data; + if (RegAddr == rTxAGC_B_CCK11_A_CCK2_11 && BitMask == 0xffffff00) + pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][7] = Data; + if (RegAddr == rTxAGC_A_Mcs03_Mcs00) + pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][2] = Data; + if (RegAddr == rTxAGC_A_Mcs07_Mcs04) + pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][3] = Data; + if (RegAddr == rTxAGC_A_Mcs11_Mcs08) + pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][4] = Data; + if (RegAddr == rTxAGC_A_Mcs15_Mcs12) { + pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][5] = Data; + if (pHalData->rf_type == RF_1T1R) + pHalData->pwrGroupCnt++; + } + if (RegAddr == rTxAGC_B_Rate18_06) + pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][8] = Data; + if (RegAddr == rTxAGC_B_Rate54_24) + pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][9] = Data; + if (RegAddr == rTxAGC_B_CCK1_55_Mcs32) + pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][14] = Data; + if (RegAddr == rTxAGC_B_CCK11_A_CCK2_11 && BitMask == 0x000000ff) + pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][15] = Data; + if (RegAddr == rTxAGC_B_Mcs03_Mcs00) + pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][10] = Data; + if (RegAddr == rTxAGC_B_Mcs07_Mcs04) + pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][11] = Data; + if (RegAddr == rTxAGC_B_Mcs11_Mcs08) + pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][12] = Data; + if (RegAddr == rTxAGC_B_Mcs15_Mcs12) { + pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][13] = Data; + if (pHalData->rf_type != RF_1T1R) + pHalData->pwrGroupCnt++; + } +} + +static int phy_BB8188E_Config_ParaFile(struct adapter *Adapter) +{ + struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(Adapter); + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + int rtStatus = _SUCCESS; + + /* */ + /* 1. Read PHY_REG.TXT BB INIT!! */ + /* We will seperate as 88C / 92C according to chip version */ + /* */ + if (HAL_STATUS_FAILURE == ODM_ConfigBBWithHeaderFile(&pHalData->odmpriv, CONFIG_BB_PHY_REG)) + rtStatus = _FAIL; + if (rtStatus != _SUCCESS) + goto phy_BB8190_Config_ParaFile_Fail; + + /* 2. If EEPROM or EFUSE autoload OK, We must config by PHY_REG_PG.txt */ + if (!pEEPROM->bautoload_fail_flag) { + pHalData->pwrGroupCnt = 0; + + if (HAL_STATUS_FAILURE == ODM_ConfigBBWithHeaderFile(&pHalData->odmpriv, CONFIG_BB_PHY_REG_PG)) + rtStatus = _FAIL; + } + + if (rtStatus != _SUCCESS) + goto phy_BB8190_Config_ParaFile_Fail; + + /* 3. BB AGC table Initialization */ + if (HAL_STATUS_FAILURE == ODM_ConfigBBWithHeaderFile(&pHalData->odmpriv, CONFIG_BB_AGC_TAB)) + rtStatus = _FAIL; + + if (rtStatus != _SUCCESS) + goto phy_BB8190_Config_ParaFile_Fail; + +phy_BB8190_Config_ParaFile_Fail: + + return rtStatus; +} + +int +PHY_BBConfig8188E( + struct adapter *Adapter + ) +{ + int rtStatus = _SUCCESS; + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + u32 RegVal; + u8 CrystalCap; + + phy_InitBBRFRegisterDefinition(Adapter); + + + /* Enable BB and RF */ + RegVal = rtw_read16(Adapter, REG_SYS_FUNC_EN); + rtw_write16(Adapter, REG_SYS_FUNC_EN, (u16)(RegVal|BIT13|BIT0|BIT1)); + + /* 20090923 Joseph: Advised by Steven and Jenyu. Power sequence before init RF. */ + + rtw_write8(Adapter, REG_RF_CTRL, RF_EN|RF_RSTB|RF_SDMRSTB); + + rtw_write8(Adapter, REG_SYS_FUNC_EN, FEN_USBA | FEN_USBD | FEN_BB_GLB_RSTn | FEN_BBRSTB); + + /* Config BB and AGC */ + rtStatus = phy_BB8188E_Config_ParaFile(Adapter); + + /* write 0x24[16:11] = 0x24[22:17] = CrystalCap */ + CrystalCap = pHalData->CrystalCap & 0x3F; + PHY_SetBBReg(Adapter, REG_AFE_XTAL_CTRL, 0x7ff800, (CrystalCap | (CrystalCap << 6))); + + return rtStatus; +} + +int PHY_RFConfig8188E(struct adapter *Adapter) +{ + int rtStatus = _SUCCESS; + + /* RF config */ + rtStatus = PHY_RF6052_Config8188E(Adapter); + return rtStatus; +} + + +/*----------------------------------------------------------------------------- + * Function: PHY_ConfigRFWithParaFile() + * + * Overview: This function read RF parameters from general file format, and do RF 3-wire + * + * Input: struct adapter *Adapter + * ps8 pFileName + * enum rf_radio_path eRFPath + * + * Output: NONE + * + * Return: RT_STATUS_SUCCESS: configuration file exist + * + * Note: Delay may be required for RF configuration + *---------------------------------------------------------------------------*/ +int rtl8188e_PHY_ConfigRFWithParaFile(struct adapter *Adapter, u8 *pFileName, enum rf_radio_path eRFPath) +{ + return _SUCCESS; +} + +void +rtl8192c_PHY_GetHWRegOriginalValue( + struct adapter *Adapter + ) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + + /* read rx initial gain */ + pHalData->DefaultInitialGain[0] = (u8)PHY_QueryBBReg(Adapter, rOFDM0_XAAGCCore1, bMaskByte0); + pHalData->DefaultInitialGain[1] = (u8)PHY_QueryBBReg(Adapter, rOFDM0_XBAGCCore1, bMaskByte0); + pHalData->DefaultInitialGain[2] = (u8)PHY_QueryBBReg(Adapter, rOFDM0_XCAGCCore1, bMaskByte0); + pHalData->DefaultInitialGain[3] = (u8)PHY_QueryBBReg(Adapter, rOFDM0_XDAGCCore1, bMaskByte0); + + /* read framesync */ + pHalData->framesync = (u8)PHY_QueryBBReg(Adapter, rOFDM0_RxDetector3, bMaskByte0); + pHalData->framesyncC34 = PHY_QueryBBReg(Adapter, rOFDM0_RxDetector2, bMaskDWord); +} + +/* */ +/* Description: */ +/* Map dBm into Tx power index according to */ +/* current HW model, for example, RF and PA, and */ +/* current wireless mode. */ +/* By Bruce, 2008-01-29. */ +/* */ +static u8 phy_DbmToTxPwrIdx(struct adapter *Adapter, enum wireless_mode WirelessMode, int PowerInDbm) +{ + u8 TxPwrIdx = 0; + int Offset = 0; + + + /* */ + /* Tested by MP, we found that CCK Index 0 equals to 8dbm, OFDM legacy equals to */ + /* 3dbm, and OFDM HT equals to 0dbm repectively. */ + /* Note: */ + /* The mapping may be different by different NICs. Do not use this formula for what needs accurate result. */ + /* By Bruce, 2008-01-29. */ + /* */ + switch (WirelessMode) { + case WIRELESS_MODE_B: + Offset = -7; + break; + + case WIRELESS_MODE_G: + case WIRELESS_MODE_N_24G: + default: + Offset = -8; + break; + } + + if ((PowerInDbm - Offset) > 0) + TxPwrIdx = (u8)((PowerInDbm - Offset) * 2); + else + TxPwrIdx = 0; + + /* Tx Power Index is too large. */ + if (TxPwrIdx > MAX_TXPWR_IDX_NMODE_92S) + TxPwrIdx = MAX_TXPWR_IDX_NMODE_92S; + + return TxPwrIdx; +} + +/* */ +/* Description: */ +/* Map Tx power index into dBm according to */ +/* current HW model, for example, RF and PA, and */ +/* current wireless mode. */ +/* By Bruce, 2008-01-29. */ +/* */ +static int phy_TxPwrIdxToDbm(struct adapter *Adapter, enum wireless_mode WirelessMode, u8 TxPwrIdx) +{ + int Offset = 0; + int PwrOutDbm = 0; + + /* */ + /* Tested by MP, we found that CCK Index 0 equals to -7dbm, OFDM legacy equals to -8dbm. */ + /* Note: */ + /* The mapping may be different by different NICs. Do not use this formula for what needs accurate result. */ + /* By Bruce, 2008-01-29. */ + /* */ + switch (WirelessMode) { + case WIRELESS_MODE_B: + Offset = -7; + break; + case WIRELESS_MODE_G: + case WIRELESS_MODE_N_24G: + default: + Offset = -8; + break; + } + + PwrOutDbm = TxPwrIdx / 2 + Offset; /* Discard the decimal part. */ + + return PwrOutDbm; +} + + +/*----------------------------------------------------------------------------- + * Function: GetTxPowerLevel8190() + * + * Overview: This function is export to "common" moudule + * + * Input: struct adapter *Adapter + * psByte Power Level + * + * Output: NONE + * + * Return: NONE + * + *---------------------------------------------------------------------------*/ +void PHY_GetTxPowerLevel8188E(struct adapter *Adapter, u32 *powerlevel) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + u8 TxPwrLevel = 0; + int TxPwrDbm; + + /* */ + /* Because the Tx power indexes are different, we report the maximum of them to */ + /* meet the CCX TPC request. By Bruce, 2008-01-31. */ + /* */ + + /* CCK */ + TxPwrLevel = pHalData->CurrentCckTxPwrIdx; + TxPwrDbm = phy_TxPwrIdxToDbm(Adapter, WIRELESS_MODE_B, TxPwrLevel); + + /* Legacy OFDM */ + TxPwrLevel = pHalData->CurrentOfdm24GTxPwrIdx + pHalData->LegacyHTTxPowerDiff; + + /* Compare with Legacy OFDM Tx power. */ + if (phy_TxPwrIdxToDbm(Adapter, WIRELESS_MODE_G, TxPwrLevel) > TxPwrDbm) + TxPwrDbm = phy_TxPwrIdxToDbm(Adapter, WIRELESS_MODE_G, TxPwrLevel); + + /* HT OFDM */ + TxPwrLevel = pHalData->CurrentOfdm24GTxPwrIdx; + + /* Compare with HT OFDM Tx power. */ + if (phy_TxPwrIdxToDbm(Adapter, WIRELESS_MODE_N_24G, TxPwrLevel) > TxPwrDbm) + TxPwrDbm = phy_TxPwrIdxToDbm(Adapter, WIRELESS_MODE_N_24G, TxPwrLevel); + + *powerlevel = TxPwrDbm; +} + +static void getTxPowerIndex88E(struct adapter *Adapter, u8 channel, u8 *cckPowerLevel, + u8 *ofdmPowerLevel, u8 *BW20PowerLevel, + u8 *BW40PowerLevel) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + u8 index = (channel - 1); + u8 TxCount = 0, path_nums; + + if ((RF_1T2R == pHalData->rf_type) || (RF_1T1R == pHalData->rf_type)) + path_nums = 1; + else + path_nums = 2; + + for (TxCount = 0; TxCount < path_nums; TxCount++) { + if (TxCount == RF_PATH_A) { + /* 1. CCK */ + cckPowerLevel[TxCount] = pHalData->Index24G_CCK_Base[TxCount][index]; + /* 2. OFDM */ + ofdmPowerLevel[TxCount] = pHalData->Index24G_BW40_Base[RF_PATH_A][index]+ + pHalData->OFDM_24G_Diff[TxCount][RF_PATH_A]; + /* 1. BW20 */ + BW20PowerLevel[TxCount] = pHalData->Index24G_BW40_Base[RF_PATH_A][index]+ + pHalData->BW20_24G_Diff[TxCount][RF_PATH_A]; + /* 2. BW40 */ + BW40PowerLevel[TxCount] = pHalData->Index24G_BW40_Base[TxCount][index]; + } else if (TxCount == RF_PATH_B) { + /* 1. CCK */ + cckPowerLevel[TxCount] = pHalData->Index24G_CCK_Base[TxCount][index]; + /* 2. OFDM */ + ofdmPowerLevel[TxCount] = pHalData->Index24G_BW40_Base[RF_PATH_A][index]+ + pHalData->BW20_24G_Diff[RF_PATH_A][index]+ + pHalData->BW20_24G_Diff[TxCount][index]; + /* 1. BW20 */ + BW20PowerLevel[TxCount] = pHalData->Index24G_BW40_Base[RF_PATH_A][index]+ + pHalData->BW20_24G_Diff[TxCount][RF_PATH_A]+ + pHalData->BW20_24G_Diff[TxCount][index]; + /* 2. BW40 */ + BW40PowerLevel[TxCount] = pHalData->Index24G_BW40_Base[TxCount][index]; + } else if (TxCount == RF_PATH_C) { + /* 1. CCK */ + cckPowerLevel[TxCount] = pHalData->Index24G_CCK_Base[TxCount][index]; + /* 2. OFDM */ + ofdmPowerLevel[TxCount] = pHalData->Index24G_BW40_Base[RF_PATH_A][index]+ + pHalData->BW20_24G_Diff[RF_PATH_A][index]+ + pHalData->BW20_24G_Diff[RF_PATH_B][index]+ + pHalData->BW20_24G_Diff[TxCount][index]; + /* 1. BW20 */ + BW20PowerLevel[TxCount] = pHalData->Index24G_BW40_Base[RF_PATH_A][index]+ + pHalData->BW20_24G_Diff[RF_PATH_A][index]+ + pHalData->BW20_24G_Diff[RF_PATH_B][index]+ + pHalData->BW20_24G_Diff[TxCount][index]; + /* 2. BW40 */ + BW40PowerLevel[TxCount] = pHalData->Index24G_BW40_Base[TxCount][index]; + } else if (TxCount == RF_PATH_D) { + /* 1. CCK */ + cckPowerLevel[TxCount] = pHalData->Index24G_CCK_Base[TxCount][index]; + /* 2. OFDM */ + ofdmPowerLevel[TxCount] = pHalData->Index24G_BW40_Base[RF_PATH_A][index]+ + pHalData->BW20_24G_Diff[RF_PATH_A][index]+ + pHalData->BW20_24G_Diff[RF_PATH_B][index]+ + pHalData->BW20_24G_Diff[RF_PATH_C][index]+ + pHalData->BW20_24G_Diff[TxCount][index]; + + /* 1. BW20 */ + BW20PowerLevel[TxCount] = pHalData->Index24G_BW40_Base[RF_PATH_A][index]+ + pHalData->BW20_24G_Diff[RF_PATH_A][index]+ + pHalData->BW20_24G_Diff[RF_PATH_B][index]+ + pHalData->BW20_24G_Diff[RF_PATH_C][index]+ + pHalData->BW20_24G_Diff[TxCount][index]; + + /* 2. BW40 */ + BW40PowerLevel[TxCount] = pHalData->Index24G_BW40_Base[TxCount][index]; + } + } +} + +static void phy_PowerIndexCheck88E(struct adapter *Adapter, u8 channel, u8 *cckPowerLevel, + u8 *ofdmPowerLevel, u8 *BW20PowerLevel, u8 *BW40PowerLevel) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + + pHalData->CurrentCckTxPwrIdx = cckPowerLevel[0]; + pHalData->CurrentOfdm24GTxPwrIdx = ofdmPowerLevel[0]; + pHalData->CurrentBW2024GTxPwrIdx = BW20PowerLevel[0]; + pHalData->CurrentBW4024GTxPwrIdx = BW40PowerLevel[0]; +} + +/*----------------------------------------------------------------------------- + * Function: SetTxPowerLevel8190() + * + * Overview: This function is export to "HalCommon" moudule + * We must consider RF path later!!!!!!! + * + * Input: struct adapter *Adapter + * u8 channel + * + * Output: NONE + * + * Return: NONE + * 2008/11/04 MHC We remove EEPROM_93C56. + * We need to move CCX relative code to independet file. + * 2009/01/21 MHC Support new EEPROM format from SD3 requirement. + * + *---------------------------------------------------------------------------*/ +void +PHY_SetTxPowerLevel8188E( + struct adapter *Adapter, + u8 channel + ) +{ + u8 cckPowerLevel[MAX_TX_COUNT] = {0}; + u8 ofdmPowerLevel[MAX_TX_COUNT] = {0};/* [0]:RF-A, [1]:RF-B */ + u8 BW20PowerLevel[MAX_TX_COUNT] = {0}; + u8 BW40PowerLevel[MAX_TX_COUNT] = {0}; + + getTxPowerIndex88E(Adapter, channel, &cckPowerLevel[0], &ofdmPowerLevel[0], &BW20PowerLevel[0], &BW40PowerLevel[0]); + + phy_PowerIndexCheck88E(Adapter, channel, &cckPowerLevel[0], &ofdmPowerLevel[0], &BW20PowerLevel[0], &BW40PowerLevel[0]); + + rtl8188e_PHY_RF6052SetCckTxPower(Adapter, &cckPowerLevel[0]); + rtl8188e_PHY_RF6052SetOFDMTxPower(Adapter, &ofdmPowerLevel[0], &BW20PowerLevel[0], &BW40PowerLevel[0], channel); +} + +/* */ +/* Description: */ +/* Update transmit power level of all channel supported. */ +/* */ +/* TODO: */ +/* A mode. */ +/* By Bruce, 2008-02-04. */ +/* */ +bool +PHY_UpdateTxPowerDbm8188E( + struct adapter *Adapter, + int powerInDbm + ) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + u8 idx; + u8 rf_path; + + /* TODO: A mode Tx power. */ + u8 CckTxPwrIdx = phy_DbmToTxPwrIdx(Adapter, WIRELESS_MODE_B, powerInDbm); + u8 OfdmTxPwrIdx = phy_DbmToTxPwrIdx(Adapter, WIRELESS_MODE_N_24G, powerInDbm); + + if (OfdmTxPwrIdx - pHalData->LegacyHTTxPowerDiff > 0) + OfdmTxPwrIdx -= pHalData->LegacyHTTxPowerDiff; + else + OfdmTxPwrIdx = 0; + + for (idx = 0; idx < 14; idx++) { + for (rf_path = 0; rf_path < 2; rf_path++) { + pHalData->TxPwrLevelCck[rf_path][idx] = CckTxPwrIdx; + pHalData->TxPwrLevelHT40_1S[rf_path][idx] = + pHalData->TxPwrLevelHT40_2S[rf_path][idx] = OfdmTxPwrIdx; + } + } + return true; +} + +void +PHY_ScanOperationBackup8188E( + struct adapter *Adapter, + u8 Operation + ) +{ +} + +/*----------------------------------------------------------------------------- + * Function: PHY_SetBWModeCallback8192C() + * + * Overview: Timer callback function for SetSetBWMode + * + * Input: PRT_TIMER pTimer + * + * Output: NONE + * + * Return: NONE + * + * Note: (1) We do not take j mode into consideration now + * (2) Will two workitem of "switch channel" and "switch channel bandwidth" run + * concurrently? + *---------------------------------------------------------------------------*/ +static void +_PHY_SetBWMode92C( + struct adapter *Adapter +) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + u8 regBwOpMode; + u8 regRRSR_RSC; + + if (pHalData->rf_chip == RF_PSEUDO_11N) + return; + + /* There is no 40MHz mode in RF_8225. */ + if (pHalData->rf_chip == RF_8225) + return; + + if (Adapter->bDriverStopped) + return; + + /* 3 */ + /* 3<1>Set MAC register */ + /* 3 */ + + regBwOpMode = rtw_read8(Adapter, REG_BWOPMODE); + regRRSR_RSC = rtw_read8(Adapter, REG_RRSR+2); + + switch (pHalData->CurrentChannelBW) { + case HT_CHANNEL_WIDTH_20: + regBwOpMode |= BW_OPMODE_20MHZ; + /* 2007/02/07 Mark by Emily becasue we have not verify whether this register works */ + rtw_write8(Adapter, REG_BWOPMODE, regBwOpMode); + break; + case HT_CHANNEL_WIDTH_40: + regBwOpMode &= ~BW_OPMODE_20MHZ; + /* 2007/02/07 Mark by Emily becasue we have not verify whether this register works */ + rtw_write8(Adapter, REG_BWOPMODE, regBwOpMode); + regRRSR_RSC = (regRRSR_RSC&0x90) | (pHalData->nCur40MhzPrimeSC<<5); + rtw_write8(Adapter, REG_RRSR+2, regRRSR_RSC); + break; + default: + break; + } + + /* 3 */ + /* 3 <2>Set PHY related register */ + /* 3 */ + switch (pHalData->CurrentChannelBW) { + /* 20 MHz channel*/ + case HT_CHANNEL_WIDTH_20: + PHY_SetBBReg(Adapter, rFPGA0_RFMOD, bRFMOD, 0x0); + PHY_SetBBReg(Adapter, rFPGA1_RFMOD, bRFMOD, 0x0); + break; + /* 40 MHz channel*/ + case HT_CHANNEL_WIDTH_40: + PHY_SetBBReg(Adapter, rFPGA0_RFMOD, bRFMOD, 0x1); + PHY_SetBBReg(Adapter, rFPGA1_RFMOD, bRFMOD, 0x1); + /* Set Control channel to upper or lower. These settings are required only for 40MHz */ + PHY_SetBBReg(Adapter, rCCK0_System, bCCKSideBand, (pHalData->nCur40MhzPrimeSC>>1)); + PHY_SetBBReg(Adapter, rOFDM1_LSTF, 0xC00, pHalData->nCur40MhzPrimeSC); + PHY_SetBBReg(Adapter, 0x818, (BIT26 | BIT27), + (pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) ? 2 : 1); + break; + default: + break; + } + /* Skip over setting of J-mode in BB register here. Default value is "None J mode". Emily 20070315 */ + + /* 3<3>Set RF related register */ + switch (pHalData->rf_chip) { + case RF_8225: + break; + case RF_8256: + /* Please implement this function in Hal8190PciPhy8256.c */ + break; + case RF_8258: + /* Please implement this function in Hal8190PciPhy8258.c */ + break; + case RF_PSEUDO_11N: + break; + case RF_6052: + rtl8188e_PHY_RF6052SetBandwidth(Adapter, pHalData->CurrentChannelBW); + break; + default: + break; + } +} + + /*----------------------------------------------------------------------------- + * Function: SetBWMode8190Pci() + * + * Overview: This function is export to "HalCommon" moudule + * + * Input: struct adapter *Adapter + * enum ht_channel_width Bandwidth 20M or 40M + * + * Output: NONE + * + * Return: NONE + * + * Note: We do not take j mode into consideration now + *---------------------------------------------------------------------------*/ +void PHY_SetBWMode8188E(struct adapter *Adapter, enum ht_channel_width Bandwidth, /* 20M or 40M */ + unsigned char Offset) /* Upper, Lower, or Don't care */ +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + enum ht_channel_width tmpBW = pHalData->CurrentChannelBW; + + pHalData->CurrentChannelBW = Bandwidth; + + pHalData->nCur40MhzPrimeSC = Offset; + + if ((!Adapter->bDriverStopped) && (!Adapter->bSurpriseRemoved)) + _PHY_SetBWMode92C(Adapter); + else + pHalData->CurrentChannelBW = tmpBW; +} + +static void _PHY_SwChnl8192C(struct adapter *Adapter, u8 channel) +{ + u8 eRFPath; + u32 param1, param2; + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + + if (Adapter->bNotifyChannelChange) + DBG_88E("[%s] ch = %d\n", __func__, channel); + + /* s1. pre common command - CmdID_SetTxPowerLevel */ + PHY_SetTxPowerLevel8188E(Adapter, channel); + + /* s2. RF dependent command - CmdID_RF_WriteReg, param1=RF_CHNLBW, param2=channel */ + param1 = RF_CHNLBW; + param2 = channel; + for (eRFPath = 0; eRFPath < pHalData->NumTotalRFPath; eRFPath++) { + pHalData->RfRegChnlVal[eRFPath] = ((pHalData->RfRegChnlVal[eRFPath] & 0xfffffc00) | param2); + PHY_SetRFReg(Adapter, (enum rf_radio_path)eRFPath, param1, bRFRegOffsetMask, pHalData->RfRegChnlVal[eRFPath]); + } +} + +void PHY_SwChnl8188E(struct adapter *Adapter, u8 channel) +{ + /* Call after initialization */ + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + u8 tmpchannel = pHalData->CurrentChannel; + bool bResult = true; + + if (pHalData->rf_chip == RF_PSEUDO_11N) + return; /* return immediately if it is peudo-phy */ + + if (channel == 0) + channel = 1; + + pHalData->CurrentChannel = channel; + + if ((!Adapter->bDriverStopped) && (!Adapter->bSurpriseRemoved)) { + _PHY_SwChnl8192C(Adapter, channel); + + if (bResult) + ; + else + pHalData->CurrentChannel = tmpchannel; + + } else { + pHalData->CurrentChannel = tmpchannel; + } +} diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_rf6052.c b/drivers/staging/rtl8188eu/hal/rtl8188e_rf6052.c new file mode 100644 index 0000000000000..bfdf9b3ce77fe --- /dev/null +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_rf6052.c @@ -0,0 +1,572 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +/****************************************************************************** + * + * + * Module: rtl8192c_rf6052.c ( Source C File) + * + * Note: Provide RF 6052 series relative API. + * + * Function: + * + * Export: + * + * Abbrev: + * + * History: + * Data Who Remark + * + * 09/25/2008 MHC Create initial version. + * 11/05/2008 MHC Add API for tw power setting. + * + * +******************************************************************************/ + +#define _RTL8188E_RF6052_C_ + +#include +#include + +#include + +/*---------------------------Define Local Constant---------------------------*/ +/* Define local structure for debug!!!!! */ +struct rf_shadow { + /* Shadow register value */ + u32 Value; + /* Compare or not flag */ + u8 Compare; + /* Record If it had ever modified unpredicted */ + u8 ErrorOrNot; + /* Recorver Flag */ + u8 Recorver; + /* */ + u8 Driver_Write; +}; + +/*---------------------------Define Local Constant---------------------------*/ + + +/*------------------------Define global variable-----------------------------*/ + +/*------------------------Define local variable------------------------------*/ + +/*----------------------------------------------------------------------------- + * Function: RF_ChangeTxPath + * + * Overview: For RL6052, we must change some RF settign for 1T or 2T. + * + * Input: u16 DataRate 0x80-8f, 0x90-9f + * + * Output: NONE + * + * Return: NONE + * + * Revised History: + * When Who Remark + * 09/25/2008 MHC Create Version 0. + * Firmwaer support the utility later. + * + *---------------------------------------------------------------------------*/ +void rtl8188e_RF_ChangeTxPath(struct adapter *Adapter, u16 DataRate) +{ +/* We do not support gain table change inACUT now !!!! Delete later !!! */ +} /* RF_ChangeTxPath */ + + +/*----------------------------------------------------------------------------- + * Function: PHY_RF6052SetBandwidth() + * + * Overview: This function is called by SetBWModeCallback8190Pci() only + * + * Input: struct adapter *Adapter + * WIRELESS_BANDWIDTH_E Bandwidth 20M or 40M + * + * Output: NONE + * + * Return: NONE + * + * Note: For RF type 0222D + *---------------------------------------------------------------------------*/ +void rtl8188e_PHY_RF6052SetBandwidth(struct adapter *Adapter, + enum ht_channel_width Bandwidth) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + + switch (Bandwidth) { + case HT_CHANNEL_WIDTH_20: + pHalData->RfRegChnlVal[0] = ((pHalData->RfRegChnlVal[0] & 0xfffff3ff) | BIT(10) | BIT(11)); + PHY_SetRFReg(Adapter, RF_PATH_A, RF_CHNLBW, bRFRegOffsetMask, pHalData->RfRegChnlVal[0]); + break; + case HT_CHANNEL_WIDTH_40: + pHalData->RfRegChnlVal[0] = ((pHalData->RfRegChnlVal[0] & 0xfffff3ff) | BIT(10)); + PHY_SetRFReg(Adapter, RF_PATH_A, RF_CHNLBW, bRFRegOffsetMask, pHalData->RfRegChnlVal[0]); + break; + default: + break; + } +} + +/*----------------------------------------------------------------------------- + * Function: PHY_RF6052SetCckTxPower + * + * Overview: + * + * Input: NONE + * + * Output: NONE + * + * Return: NONE + * + * Revised History: + * When Who Remark + * 11/05/2008 MHC Simulate 8192series.. + * + *---------------------------------------------------------------------------*/ + +void +rtl8188e_PHY_RF6052SetCckTxPower( + struct adapter *Adapter, + u8 *pPowerlevel) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + struct dm_priv *pdmpriv = &pHalData->dmpriv; + struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; + u32 TxAGC[2] = {0, 0}, tmpval = 0, pwrtrac_value; + bool TurboScanOff = false; + u8 idx1, idx2; + u8 *ptr; + u8 direction; + /* FOR CE ,must disable turbo scan */ + TurboScanOff = true; + + + if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) { + TxAGC[RF_PATH_A] = 0x3f3f3f3f; + TxAGC[RF_PATH_B] = 0x3f3f3f3f; + + TurboScanOff = true;/* disable turbo scan */ + + if (TurboScanOff) { + for (idx1 = RF_PATH_A; idx1 <= RF_PATH_B; idx1++) { + TxAGC[idx1] = + pPowerlevel[idx1] | (pPowerlevel[idx1]<<8) | + (pPowerlevel[idx1]<<16) | (pPowerlevel[idx1]<<24); + /* 2010/10/18 MH For external PA module. We need to limit power index to be less than 0x20. */ + if (TxAGC[idx1] > 0x20 && pHalData->ExternalPA) + TxAGC[idx1] = 0x20; + } + } + } else { + /* Driver dynamic Tx power shall not affect Tx power. + * It shall be determined by power training mechanism. +i * Currently, we cannot fully disable driver dynamic + * tx power mechanism because it is referenced by BT + * coexist mechanism. + * In the future, two mechanism shall be separated from + * each other and maintained independantly. */ + if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_Level1) { + TxAGC[RF_PATH_A] = 0x10101010; + TxAGC[RF_PATH_B] = 0x10101010; + } else if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_Level2) { + TxAGC[RF_PATH_A] = 0x00000000; + TxAGC[RF_PATH_B] = 0x00000000; + } else { + for (idx1 = RF_PATH_A; idx1 <= RF_PATH_B; idx1++) { + TxAGC[idx1] = + pPowerlevel[idx1] | (pPowerlevel[idx1]<<8) | + (pPowerlevel[idx1]<<16) | (pPowerlevel[idx1]<<24); + } + if (pHalData->EEPROMRegulatory == 0) { + tmpval = (pHalData->MCSTxPowerLevelOriginalOffset[0][6]) + + (pHalData->MCSTxPowerLevelOriginalOffset[0][7]<<8); + TxAGC[RF_PATH_A] += tmpval; + + tmpval = (pHalData->MCSTxPowerLevelOriginalOffset[0][14]) + + (pHalData->MCSTxPowerLevelOriginalOffset[0][15]<<24); + TxAGC[RF_PATH_B] += tmpval; + } + } + } + for (idx1 = RF_PATH_A; idx1 <= RF_PATH_B; idx1++) { + ptr = (u8 *)(&(TxAGC[idx1])); + for (idx2 = 0; idx2 < 4; idx2++) { + if (*ptr > RF6052_MAX_TX_PWR) + *ptr = RF6052_MAX_TX_PWR; + ptr++; + } + } + ODM_TxPwrTrackAdjust88E(&pHalData->odmpriv, 1, &direction, &pwrtrac_value); + + if (direction == 1) { + /* Increase TX pwoer */ + TxAGC[0] += pwrtrac_value; + TxAGC[1] += pwrtrac_value; + } else if (direction == 2) { + /* Decrease TX pwoer */ + TxAGC[0] -= pwrtrac_value; + TxAGC[1] -= pwrtrac_value; + } + + /* rf-A cck tx power */ + tmpval = TxAGC[RF_PATH_A]&0xff; + PHY_SetBBReg(Adapter, rTxAGC_A_CCK1_Mcs32, bMaskByte1, tmpval); + tmpval = TxAGC[RF_PATH_A]>>8; + PHY_SetBBReg(Adapter, rTxAGC_B_CCK11_A_CCK2_11, 0xffffff00, tmpval); + + /* rf-B cck tx power */ + tmpval = TxAGC[RF_PATH_B]>>24; + PHY_SetBBReg(Adapter, rTxAGC_B_CCK11_A_CCK2_11, bMaskByte0, tmpval); + tmpval = TxAGC[RF_PATH_B]&0x00ffffff; + PHY_SetBBReg(Adapter, rTxAGC_B_CCK1_55_Mcs32, 0xffffff00, tmpval); +} /* PHY_RF6052SetCckTxPower */ + +/* */ +/* powerbase0 for OFDM rates */ +/* powerbase1 for HT MCS rates */ +/* */ +static void getpowerbase88e(struct adapter *Adapter, u8 *pPowerLevelOFDM, + u8 *pPowerLevelBW20, u8 *pPowerLevelBW40, u8 Channel, u32 *OfdmBase, u32 *MCSBase) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + u32 powerBase0, powerBase1; + u8 i, powerlevel[2]; + + for (i = 0; i < 2; i++) { + powerBase0 = pPowerLevelOFDM[i]; + + powerBase0 = (powerBase0<<24) | (powerBase0<<16) | (powerBase0<<8) | powerBase0; + *(OfdmBase+i) = powerBase0; + } + for (i = 0; i < pHalData->NumTotalRFPath; i++) { + /* Check HT20 to HT40 diff */ + if (pHalData->CurrentChannelBW == HT_CHANNEL_WIDTH_20) + powerlevel[i] = pPowerLevelBW20[i]; + else + powerlevel[i] = pPowerLevelBW40[i]; + powerBase1 = powerlevel[i]; + powerBase1 = (powerBase1<<24) | (powerBase1<<16) | (powerBase1<<8) | powerBase1; + *(MCSBase+i) = powerBase1; + } +} +static void get_rx_power_val_by_reg(struct adapter *Adapter, u8 Channel, + u8 index, u32 *powerBase0, u32 *powerBase1, + u32 *pOutWriteVal) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + struct dm_priv *pdmpriv = &pHalData->dmpriv; + u8 i, chnlGroup = 0, pwr_diff_limit[4], customer_pwr_limit; + s8 pwr_diff = 0; + u32 writeVal, customer_limit, rf; + u8 Regulatory = pHalData->EEPROMRegulatory; + + /* Index 0 & 1= legacy OFDM, 2-5=HT_MCS rate */ + + for (rf = 0; rf < 2; rf++) { + switch (Regulatory) { + case 0: /* Realtek better performance */ + /* increase power diff defined by Realtek for large power */ + chnlGroup = 0; + writeVal = pHalData->MCSTxPowerLevelOriginalOffset[chnlGroup][index+(rf ? 8 : 0)] + + ((index < 2) ? powerBase0[rf] : powerBase1[rf]); + break; + case 1: /* Realtek regulatory */ + /* increase power diff defined by Realtek for regulatory */ + if (pHalData->pwrGroupCnt == 1) + chnlGroup = 0; + if (pHalData->pwrGroupCnt >= pHalData->PGMaxGroup) { + if (Channel < 3) /* Chanel 1-2 */ + chnlGroup = 0; + else if (Channel < 6) /* Channel 3-5 */ + chnlGroup = 1; + else if (Channel < 9) /* Channel 6-8 */ + chnlGroup = 2; + else if (Channel < 12) /* Channel 9-11 */ + chnlGroup = 3; + else if (Channel < 14) /* Channel 12-13 */ + chnlGroup = 4; + else if (Channel == 14) /* Channel 14 */ + chnlGroup = 5; + } + writeVal = pHalData->MCSTxPowerLevelOriginalOffset[chnlGroup][index+(rf ? 8 : 0)] + + ((index < 2) ? powerBase0[rf] : powerBase1[rf]); + break; + case 2: /* Better regulatory */ + /* don't increase any power diff */ + writeVal = ((index < 2) ? powerBase0[rf] : powerBase1[rf]); + break; + case 3: /* Customer defined power diff. */ + /* increase power diff defined by customer. */ + chnlGroup = 0; + + if (index < 2) + pwr_diff = pHalData->TxPwrLegacyHtDiff[rf][Channel-1]; + else if (pHalData->CurrentChannelBW == HT_CHANNEL_WIDTH_20) + pwr_diff = pHalData->TxPwrHt20Diff[rf][Channel-1]; + + if (pHalData->CurrentChannelBW == HT_CHANNEL_WIDTH_40) + customer_pwr_limit = pHalData->PwrGroupHT40[rf][Channel-1]; + else + customer_pwr_limit = pHalData->PwrGroupHT20[rf][Channel-1]; + + if (pwr_diff >= customer_pwr_limit) + pwr_diff = 0; + else + pwr_diff = customer_pwr_limit - pwr_diff; + + for (i = 0; i < 4; i++) { + pwr_diff_limit[i] = (u8)((pHalData->MCSTxPowerLevelOriginalOffset[chnlGroup][index+(rf ? 8 : 0)]&(0x7f<<(i*8)))>>(i*8)); + + if (pwr_diff_limit[i] > pwr_diff) + pwr_diff_limit[i] = pwr_diff; + } + customer_limit = (pwr_diff_limit[3]<<24) | (pwr_diff_limit[2]<<16) | + (pwr_diff_limit[1]<<8) | (pwr_diff_limit[0]); + writeVal = customer_limit + ((index < 2) ? powerBase0[rf] : powerBase1[rf]); + break; + default: + chnlGroup = 0; + writeVal = pHalData->MCSTxPowerLevelOriginalOffset[chnlGroup][index+(rf ? 8 : 0)] + + ((index < 2) ? powerBase0[rf] : powerBase1[rf]); + break; + } +/* 20100427 Joseph: Driver dynamic Tx power shall not affect Tx power. It shall be determined by power training mechanism. */ +/* Currently, we cannot fully disable driver dynamic tx power mechanism because it is referenced by BT coexist mechanism. */ +/* In the future, two mechanism shall be separated from each other and maintained independantly. Thanks for Lanhsin's reminder. */ + /* 92d do not need this */ + if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_Level1) + writeVal = 0x14141414; + else if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_Level2) + writeVal = 0x00000000; + + /* 20100628 Joseph: High power mode for BT-Coexist mechanism. */ + /* This mechanism is only applied when Driver-Highpower-Mechanism is OFF. */ + if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_BT1) + writeVal = writeVal - 0x06060606; + else if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_BT2) + writeVal = writeVal; + *(pOutWriteVal+rf) = writeVal; + } +} +static void writeOFDMPowerReg88E(struct adapter *Adapter, u8 index, u32 *pValue) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + u16 regoffset_a[6] = { + rTxAGC_A_Rate18_06, rTxAGC_A_Rate54_24, + rTxAGC_A_Mcs03_Mcs00, rTxAGC_A_Mcs07_Mcs04, + rTxAGC_A_Mcs11_Mcs08, rTxAGC_A_Mcs15_Mcs12}; + u16 regoffset_b[6] = { + rTxAGC_B_Rate18_06, rTxAGC_B_Rate54_24, + rTxAGC_B_Mcs03_Mcs00, rTxAGC_B_Mcs07_Mcs04, + rTxAGC_B_Mcs11_Mcs08, rTxAGC_B_Mcs15_Mcs12}; + u8 i, rf, pwr_val[4]; + u32 writeVal; + u16 regoffset; + + for (rf = 0; rf < 2; rf++) { + writeVal = pValue[rf]; + for (i = 0; i < 4; i++) { + pwr_val[i] = (u8)((writeVal & (0x7f<<(i*8)))>>(i*8)); + if (pwr_val[i] > RF6052_MAX_TX_PWR) + pwr_val[i] = RF6052_MAX_TX_PWR; + } + writeVal = (pwr_val[3]<<24) | (pwr_val[2]<<16) | (pwr_val[1]<<8) | pwr_val[0]; + + if (rf == 0) + regoffset = regoffset_a[index]; + else + regoffset = regoffset_b[index]; + + PHY_SetBBReg(Adapter, regoffset, bMaskDWord, writeVal); + + /* 201005115 Joseph: Set Tx Power diff for Tx power training mechanism. */ + if (((pHalData->rf_type == RF_2T2R) && + (regoffset == rTxAGC_A_Mcs15_Mcs12 || regoffset == rTxAGC_B_Mcs15_Mcs12)) || + ((pHalData->rf_type != RF_2T2R) && + (regoffset == rTxAGC_A_Mcs07_Mcs04 || regoffset == rTxAGC_B_Mcs07_Mcs04))) { + writeVal = pwr_val[3]; + if (regoffset == rTxAGC_A_Mcs15_Mcs12 || regoffset == rTxAGC_A_Mcs07_Mcs04) + regoffset = 0xc90; + if (regoffset == rTxAGC_B_Mcs15_Mcs12 || regoffset == rTxAGC_B_Mcs07_Mcs04) + regoffset = 0xc98; + for (i = 0; i < 3; i++) { + if (i != 2) + writeVal = (writeVal > 8) ? (writeVal-8) : 0; + else + writeVal = (writeVal > 6) ? (writeVal-6) : 0; + rtw_write8(Adapter, (u32)(regoffset+i), (u8)writeVal); + } + } + } +} + +/*----------------------------------------------------------------------------- + * Function: PHY_RF6052SetOFDMTxPower + * + * Overview: For legacy and HY OFDM, we must read EEPROM TX power index for + * different channel and read original value in TX power register area from + * 0xe00. We increase offset and original value to be correct tx pwr. + * + * Input: NONE + * + * Output: NONE + * + * Return: NONE + * + * Revised History: + * When Who Remark + * 11/05/2008 MHC Simulate 8192 series method. + * 01/06/2009 MHC 1. Prevent Path B tx power overflow or underflow dure to + * A/B pwr difference or legacy/HT pwr diff. + * 2. We concern with path B legacy/HT OFDM difference. + * 01/22/2009 MHC Support new EPRO format from SD3. + * + *---------------------------------------------------------------------------*/ + +void +rtl8188e_PHY_RF6052SetOFDMTxPower( + struct adapter *Adapter, + u8 *pPowerLevelOFDM, + u8 *pPowerLevelBW20, + u8 *pPowerLevelBW40, + u8 Channel) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + u32 writeVal[2], powerBase0[2], powerBase1[2], pwrtrac_value; + u8 direction; + u8 index = 0; + + getpowerbase88e(Adapter, pPowerLevelOFDM, pPowerLevelBW20, pPowerLevelBW40, Channel, &powerBase0[0], &powerBase1[0]); + + /* 2012/04/23 MH According to power tracking value, we need to revise OFDM tx power. */ + /* This is ued to fix unstable power tracking mode. */ + ODM_TxPwrTrackAdjust88E(&pHalData->odmpriv, 0, &direction, &pwrtrac_value); + + for (index = 0; index < 6; index++) { + get_rx_power_val_by_reg(Adapter, Channel, index, + &powerBase0[0], &powerBase1[0], + &writeVal[0]); + + if (direction == 1) { + writeVal[0] += pwrtrac_value; + writeVal[1] += pwrtrac_value; + } else if (direction == 2) { + writeVal[0] -= pwrtrac_value; + writeVal[1] -= pwrtrac_value; + } + writeOFDMPowerReg88E(Adapter, index, &writeVal[0]); + } +} + +static int phy_RF6052_Config_ParaFile(struct adapter *Adapter) +{ + struct bb_reg_def *pPhyReg; + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + u32 u4RegValue = 0; + u8 eRFPath; + int rtStatus = _SUCCESS; + + /* 3----------------------------------------------------------------- */ + /* 3 <2> Initialize RF */ + /* 3----------------------------------------------------------------- */ + for (eRFPath = 0; eRFPath < pHalData->NumTotalRFPath; eRFPath++) { + pPhyReg = &pHalData->PHYRegDef[eRFPath]; + + /*----Store original RFENV control type----*/ + switch (eRFPath) { + case RF_PATH_A: + case RF_PATH_C: + u4RegValue = PHY_QueryBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV); + break; + case RF_PATH_B: + case RF_PATH_D: + u4RegValue = PHY_QueryBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV<<16); + break; + } + /*----Set RF_ENV enable----*/ + PHY_SetBBReg(Adapter, pPhyReg->rfintfe, bRFSI_RFENV<<16, 0x1); + rtw_udelay_os(1);/* PlatformStallExecution(1); */ + + /*----Set RF_ENV output high----*/ + PHY_SetBBReg(Adapter, pPhyReg->rfintfo, bRFSI_RFENV, 0x1); + rtw_udelay_os(1);/* PlatformStallExecution(1); */ + + /* Set bit number of Address and Data for RF register */ + PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2, b3WireAddressLength, 0x0); /* Set 1 to 4 bits for 8255 */ + rtw_udelay_os(1);/* PlatformStallExecution(1); */ + + PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2, b3WireDataLength, 0x0); /* Set 0 to 12 bits for 8255 */ + rtw_udelay_os(1);/* PlatformStallExecution(1); */ + + /*----Initialize RF fom connfiguration file----*/ + switch (eRFPath) { + case RF_PATH_A: + if (HAL_STATUS_FAILURE == ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv, (enum ODM_RF_RADIO_PATH)eRFPath, (enum ODM_RF_RADIO_PATH)eRFPath)) + rtStatus = _FAIL; + break; + case RF_PATH_B: + if (HAL_STATUS_FAILURE == ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv, (enum ODM_RF_RADIO_PATH)eRFPath, (enum ODM_RF_RADIO_PATH)eRFPath)) + rtStatus = _FAIL; + break; + case RF_PATH_C: + break; + case RF_PATH_D: + break; + } + /*----Restore RFENV control type----*/; + switch (eRFPath) { + case RF_PATH_A: + case RF_PATH_C: + PHY_SetBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV, u4RegValue); + break; + case RF_PATH_B: + case RF_PATH_D: + PHY_SetBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV<<16, u4RegValue); + break; + } + if (rtStatus != _SUCCESS) + goto phy_RF6052_Config_ParaFile_Fail; + } + return rtStatus; + +phy_RF6052_Config_ParaFile_Fail: + return rtStatus; +} + +int PHY_RF6052_Config8188E(struct adapter *Adapter) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + int rtStatus = _SUCCESS; + + /* */ + /* Initialize general global value */ + /* */ + /* TODO: Extend RF_PATH_C and RF_PATH_D in the future */ + if (pHalData->rf_type == RF_1T1R) + pHalData->NumTotalRFPath = 1; + else + pHalData->NumTotalRFPath = 2; + + /* */ + /* Config BB and RF */ + /* */ + rtStatus = phy_RF6052_Config_ParaFile(Adapter); + return rtStatus; +} -- GitLab From fc324b6a9303b290915d92977ec5aa3751b950ed Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 21 Aug 2013 22:33:57 -0500 Subject: [PATCH 773/942] staging: r8188eu: Add files for new driver - part 15 This commit adds files hal/rtl8188e_rxdesc.c, hal/rtl8188e_sreset.c, and hal/rtl8188e_xmit.c. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8188eu/hal/rtl8188e_rxdesc.c | 202 ++++++++++++++++++ .../staging/rtl8188eu/hal/rtl8188e_sreset.c | 80 +++++++ drivers/staging/rtl8188eu/hal/rtl8188e_xmit.c | 91 ++++++++ 3 files changed, 373 insertions(+) create mode 100644 drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c create mode 100644 drivers/staging/rtl8188eu/hal/rtl8188e_sreset.c create mode 100644 drivers/staging/rtl8188eu/hal/rtl8188e_xmit.c diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c b/drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c new file mode 100644 index 0000000000000..05e2475cfd613 --- /dev/null +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c @@ -0,0 +1,202 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTL8188E_REDESC_C_ + +#include +#include +#include + +static void process_rssi(struct adapter *padapter, union recv_frame *prframe) +{ + struct rx_pkt_attrib *pattrib = &prframe->u.hdr.attrib; + struct signal_stat *signal_stat = &padapter->recvpriv.signal_strength_data; + + if (signal_stat->update_req) { + signal_stat->total_num = 0; + signal_stat->total_val = 0; + signal_stat->update_req = 0; + } + + signal_stat->total_num++; + signal_stat->total_val += pattrib->phy_info.SignalStrength; + signal_stat->avg_val = signal_stat->total_val / signal_stat->total_num; +} /* Process_UI_RSSI_8192C */ + +static void process_link_qual(struct adapter *padapter, union recv_frame *prframe) +{ + struct rx_pkt_attrib *pattrib; + struct signal_stat *signal_stat; + + if (prframe == NULL || padapter == NULL) + return; + + pattrib = &prframe->u.hdr.attrib; + signal_stat = &padapter->recvpriv.signal_qual_data; + + if (signal_stat->update_req) { + signal_stat->total_num = 0; + signal_stat->total_val = 0; + signal_stat->update_req = 0; + } + + signal_stat->total_num++; + signal_stat->total_val += pattrib->phy_info.SignalQuality; + signal_stat->avg_val = signal_stat->total_val / signal_stat->total_num; +} + +void rtl8188e_process_phy_info(struct adapter *padapter, void *prframe) +{ + union recv_frame *precvframe = (union recv_frame *)prframe; + + /* Check RSSI */ + process_rssi(padapter, precvframe); + /* Check EVM */ + process_link_qual(padapter, precvframe); +} + +void update_recvframe_attrib_88e(union recv_frame *precvframe, struct recv_stat *prxstat) +{ + struct rx_pkt_attrib *pattrib; + struct recv_stat report; + + report.rxdw0 = prxstat->rxdw0; + report.rxdw1 = prxstat->rxdw1; + report.rxdw2 = prxstat->rxdw2; + report.rxdw3 = prxstat->rxdw3; + report.rxdw4 = prxstat->rxdw4; + report.rxdw5 = prxstat->rxdw5; + + pattrib = &precvframe->u.hdr.attrib; + _rtw_memset(pattrib, 0, sizeof(struct rx_pkt_attrib)); + + pattrib->crc_err = (u8)((le32_to_cpu(report.rxdw0) >> 14) & 0x1);;/* u8)prxreport->crc32; */ + + /* update rx report to recv_frame attribute */ + pattrib->pkt_rpt_type = (u8)((le32_to_cpu(report.rxdw3) >> 14) & 0x3);/* prxreport->rpt_sel; */ + + if (pattrib->pkt_rpt_type == NORMAL_RX) { /* Normal rx packet */ + pattrib->pkt_len = (u16)(le32_to_cpu(report.rxdw0) & 0x00003fff);/* u16)prxreport->pktlen; */ + pattrib->drvinfo_sz = (u8)((le32_to_cpu(report.rxdw0) >> 16) & 0xf) * 8;/* u8)(prxreport->drvinfosize << 3); */ + + pattrib->physt = (u8)((le32_to_cpu(report.rxdw0) >> 26) & 0x1);/* u8)prxreport->physt; */ + + pattrib->bdecrypted = (le32_to_cpu(report.rxdw0) & BIT(27)) ? 0 : 1;/* u8)(prxreport->swdec ? 0 : 1); */ + pattrib->encrypt = (u8)((le32_to_cpu(report.rxdw0) >> 20) & 0x7);/* u8)prxreport->security; */ + + pattrib->qos = (u8)((le32_to_cpu(report.rxdw0) >> 23) & 0x1);/* u8)prxreport->qos; */ + pattrib->priority = (u8)((le32_to_cpu(report.rxdw1) >> 8) & 0xf);/* u8)prxreport->tid; */ + + pattrib->amsdu = (u8)((le32_to_cpu(report.rxdw1) >> 13) & 0x1);/* u8)prxreport->amsdu; */ + + pattrib->seq_num = (u16)(le32_to_cpu(report.rxdw2) & 0x00000fff);/* u16)prxreport->seq; */ + pattrib->frag_num = (u8)((le32_to_cpu(report.rxdw2) >> 12) & 0xf);/* u8)prxreport->frag; */ + pattrib->mfrag = (u8)((le32_to_cpu(report.rxdw1) >> 27) & 0x1);/* u8)prxreport->mf; */ + pattrib->mdata = (u8)((le32_to_cpu(report.rxdw1) >> 26) & 0x1);/* u8)prxreport->md; */ + + pattrib->mcs_rate = (u8)(le32_to_cpu(report.rxdw3) & 0x3f);/* u8)prxreport->rxmcs; */ + pattrib->rxht = (u8)((le32_to_cpu(report.rxdw3) >> 6) & 0x1);/* u8)prxreport->rxht; */ + + pattrib->icv_err = (u8)((le32_to_cpu(report.rxdw0) >> 15) & 0x1);/* u8)prxreport->icverr; */ + pattrib->shift_sz = (u8)((le32_to_cpu(report.rxdw0) >> 24) & 0x3); + } else if (pattrib->pkt_rpt_type == TX_REPORT1) { /* CCX */ + pattrib->pkt_len = TX_RPT1_PKT_LEN; + pattrib->drvinfo_sz = 0; + } else if (pattrib->pkt_rpt_type == TX_REPORT2) { /* TX RPT */ + pattrib->pkt_len = (u16)(le32_to_cpu(report.rxdw0) & 0x3FF);/* Rx length[9:0] */ + pattrib->drvinfo_sz = 0; + + /* */ + /* Get TX report MAC ID valid. */ + /* */ + pattrib->MacIDValidEntry[0] = le32_to_cpu(report.rxdw4); + pattrib->MacIDValidEntry[1] = le32_to_cpu(report.rxdw5); + + } else if (pattrib->pkt_rpt_type == HIS_REPORT) { /* USB HISR RPT */ + pattrib->pkt_len = (u16)(le32_to_cpu(report.rxdw0) & 0x00003fff);/* u16)prxreport->pktlen; */ + } +} + +/* + * Notice: + * Before calling this function, + * precvframe->u.hdr.rx_data should be ready! + */ +void update_recvframe_phyinfo_88e(union recv_frame *precvframe, struct phy_stat *pphy_status) +{ + struct adapter *padapter = precvframe->u.hdr.adapter; + struct rx_pkt_attrib *pattrib = &precvframe->u.hdr.attrib; + struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); + struct odm_phy_status_info *pPHYInfo = (struct odm_phy_status_info *)(&pattrib->phy_info); + u8 *wlanhdr; + struct odm_per_pkt_info pkt_info; + u8 *sa = NULL; + struct sta_priv *pstapriv; + struct sta_info *psta; + + pkt_info.bPacketMatchBSSID = false; + pkt_info.bPacketToSelf = false; + pkt_info.bPacketBeacon = false; + + wlanhdr = get_recvframe_data(precvframe); + + pkt_info.bPacketMatchBSSID = ((!IsFrameTypeCtrl(wlanhdr)) && + !pattrib->icv_err && !pattrib->crc_err && + _rtw_memcmp(get_hdr_bssid(wlanhdr), + get_bssid(&padapter->mlmepriv), ETH_ALEN)); + + pkt_info.bPacketToSelf = pkt_info.bPacketMatchBSSID && + (_rtw_memcmp(get_da(wlanhdr), + myid(&padapter->eeprompriv), ETH_ALEN)); + + pkt_info.bPacketBeacon = pkt_info.bPacketMatchBSSID && + (GetFrameSubType(wlanhdr) == WIFI_BEACON); + + if (pkt_info.bPacketBeacon) { + if (check_fwstate(&padapter->mlmepriv, WIFI_STATION_STATE)) + sa = padapter->mlmepriv.cur_network.network.MacAddress; + /* to do Ad-hoc */ + } else { + sa = get_sa(wlanhdr); + } + + pstapriv = &padapter->stapriv; + pkt_info.StationID = 0xFF; + psta = rtw_get_stainfo(pstapriv, sa); + if (psta) + pkt_info.StationID = psta->mac_id; + pkt_info.Rate = pattrib->mcs_rate; + + ODM_PhyStatusQuery(&pHalData->odmpriv, pPHYInfo, (u8 *)pphy_status, &(pkt_info)); + + precvframe->u.hdr.psta = NULL; + if (pkt_info.bPacketMatchBSSID && + (check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE))) { + if (psta) { + precvframe->u.hdr.psta = psta; + rtl8188e_process_phy_info(padapter, precvframe); + } + } else if (pkt_info.bPacketToSelf || pkt_info.bPacketBeacon) { + if (check_fwstate(&padapter->mlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE)) { + if (psta) + precvframe->u.hdr.psta = psta; + } + rtl8188e_process_phy_info(padapter, precvframe); + } +} diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_sreset.c b/drivers/staging/rtl8188eu/hal/rtl8188e_sreset.c new file mode 100644 index 0000000000000..96d698e1f33ee --- /dev/null +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_sreset.c @@ -0,0 +1,80 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTL8188E_SRESET_C_ + +#include +#include + +void rtl8188e_silentreset_for_specific_platform(struct adapter *padapter) +{ +} + +void rtl8188e_sreset_xmit_status_check(struct adapter *padapter) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); + struct sreset_priv *psrtpriv = &pHalData->srestpriv; + + unsigned long current_time; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + unsigned int diff_time; + u32 txdma_status; + + txdma_status = rtw_read32(padapter, REG_TXDMA_STATUS); + if (txdma_status != 0x00) { + DBG_88E("%s REG_TXDMA_STATUS:0x%08x\n", __func__, txdma_status); + rtw_write32(padapter, REG_TXDMA_STATUS, txdma_status); + rtl8188e_silentreset_for_specific_platform(padapter); + } + /* total xmit irp = 4 */ + current_time = rtw_get_current_time(); + if (0 == pxmitpriv->free_xmitbuf_cnt) { + diff_time = jiffies_to_msecs(current_time - psrtpriv->last_tx_time); + + if (diff_time > 2000) { + if (psrtpriv->last_tx_complete_time == 0) { + psrtpriv->last_tx_complete_time = current_time; + } else { + diff_time = jiffies_to_msecs(current_time - psrtpriv->last_tx_complete_time); + if (diff_time > 4000) { + DBG_88E("%s tx hang\n", __func__); + rtl8188e_silentreset_for_specific_platform(padapter); + } + } + } + } +} + +void rtl8188e_sreset_linked_status_check(struct adapter *padapter) +{ + u32 rx_dma_status = 0; + u8 fw_status = 0; + rx_dma_status = rtw_read32(padapter, REG_RXDMA_STATUS); + if (rx_dma_status != 0x00) { + DBG_88E("%s REG_RXDMA_STATUS:0x%08x\n", __func__, rx_dma_status); + rtw_write32(padapter, REG_RXDMA_STATUS, rx_dma_status); + } + fw_status = rtw_read8(padapter, REG_FMETHR); + if (fw_status != 0x00) { + if (fw_status == 1) + DBG_88E("%s REG_FW_STATUS (0x%02x), Read_Efuse_Fail !!\n", __func__, fw_status); + else if (fw_status == 2) + DBG_88E("%s REG_FW_STATUS (0x%02x), Condition_No_Match !!\n", __func__, fw_status); + } +} diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_xmit.c b/drivers/staging/rtl8188eu/hal/rtl8188e_xmit.c new file mode 100644 index 0000000000000..7ecbcf731ea93 --- /dev/null +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_xmit.c @@ -0,0 +1,91 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTL8188E_XMIT_C_ + +#include +#include +#include + +void dump_txrpt_ccx_88e(void *buf) +{ + struct txrpt_ccx_88e *txrpt_ccx = (struct txrpt_ccx_88e *)buf; + + DBG_88E("%s:\n" + "tag1:%u, pkt_num:%u, txdma_underflow:%u, int_bt:%u, int_tri:%u, int_ccx:%u\n" + "mac_id:%u, pkt_ok:%u, bmc:%u\n" + "retry_cnt:%u, lifetime_over:%u, retry_over:%u\n" + "ccx_qtime:%u\n" + "final_data_rate:0x%02x\n" + "qsel:%u, sw:0x%03x\n", + __func__, txrpt_ccx->tag1, txrpt_ccx->pkt_num, + txrpt_ccx->txdma_underflow, txrpt_ccx->int_bt, + txrpt_ccx->int_tri, txrpt_ccx->int_ccx, + txrpt_ccx->mac_id, txrpt_ccx->pkt_ok, txrpt_ccx->bmc, + txrpt_ccx->retry_cnt, txrpt_ccx->lifetime_over, + txrpt_ccx->retry_over, txrpt_ccx_qtime_88e(txrpt_ccx), + txrpt_ccx->final_data_rate, txrpt_ccx->qsel, + txrpt_ccx_sw_88e(txrpt_ccx) + ); +} + +void handle_txrpt_ccx_88e(struct adapter *adapter, u8 *buf) +{ + struct txrpt_ccx_88e *txrpt_ccx = (struct txrpt_ccx_88e *)buf; + + if (txrpt_ccx->int_ccx) { + if (txrpt_ccx->pkt_ok) + rtw_ack_tx_done(&adapter->xmitpriv, + RTW_SCTX_DONE_SUCCESS); + else + rtw_ack_tx_done(&adapter->xmitpriv, + RTW_SCTX_DONE_CCX_PKT_FAIL); + } +} + +void _dbg_dump_tx_info(struct adapter *padapter, int frame_tag, + struct tx_desc *ptxdesc) +{ + u8 dmp_txpkt; + bool dump_txdesc = false; + rtw_hal_get_def_var(padapter, HAL_DEF_DBG_DUMP_TXPKT, &(dmp_txpkt)); + + if (dmp_txpkt == 1) {/* dump txdesc for data frame */ + DBG_88E("dump tx_desc for data frame\n"); + if ((frame_tag & 0x0f) == DATA_FRAMETAG) + dump_txdesc = true; + } else if (dmp_txpkt == 2) {/* dump txdesc for mgnt frame */ + DBG_88E("dump tx_desc for mgnt frame\n"); + if ((frame_tag & 0x0f) == MGNT_FRAMETAG) + dump_txdesc = true; + } + + if (dump_txdesc) { + DBG_88E("=====================================\n"); + DBG_88E("txdw0(0x%08x)\n", ptxdesc->txdw0); + DBG_88E("txdw1(0x%08x)\n", ptxdesc->txdw1); + DBG_88E("txdw2(0x%08x)\n", ptxdesc->txdw2); + DBG_88E("txdw3(0x%08x)\n", ptxdesc->txdw3); + DBG_88E("txdw4(0x%08x)\n", ptxdesc->txdw4); + DBG_88E("txdw5(0x%08x)\n", ptxdesc->txdw5); + DBG_88E("txdw6(0x%08x)\n", ptxdesc->txdw6); + DBG_88E("txdw7(0x%08x)\n", ptxdesc->txdw7); + DBG_88E("=====================================\n"); + } +} -- GitLab From a2c60d42d97cdbeee3c7371cd3502fca77f07d39 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 21 Aug 2013 22:33:58 -0500 Subject: [PATCH 774/942] staging: r8188eu: Add files for new driver - part 16 This commit adds files os_dep/ioctl_linux.c, os_dep/mlme_linux.c, and os_dep/osdep_service.c. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8188eu/os_dep/ioctl_linux.c | 8224 +++++++++++++++++ drivers/staging/rtl8188eu/os_dep/mlme_linux.c | 246 + .../staging/rtl8188eu/os_dep/osdep_service.c | 815 ++ 3 files changed, 9285 insertions(+) create mode 100644 drivers/staging/rtl8188eu/os_dep/ioctl_linux.c create mode 100644 drivers/staging/rtl8188eu/os_dep/mlme_linux.c create mode 100644 drivers/staging/rtl8188eu/os_dep/osdep_service.c diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c new file mode 100644 index 0000000000000..554ca63813923 --- /dev/null +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -0,0 +1,8224 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _IOCTL_LINUX_C_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#define RTL_IOCTL_WPA_SUPPLICANT (SIOCIWFIRSTPRIV + 30) + +#define SCAN_ITEM_SIZE 768 +#define MAX_CUSTOM_LEN 64 +#define RATE_COUNT 4 + +/* combo scan */ +#define WEXT_CSCAN_AMOUNT 9 +#define WEXT_CSCAN_BUF_LEN 360 +#define WEXT_CSCAN_HEADER "CSCAN S\x01\x00\x00S\x00" +#define WEXT_CSCAN_HEADER_SIZE 12 +#define WEXT_CSCAN_SSID_SECTION 'S' +#define WEXT_CSCAN_CHANNEL_SECTION 'C' +#define WEXT_CSCAN_NPROBE_SECTION 'N' +#define WEXT_CSCAN_ACTV_DWELL_SECTION 'A' +#define WEXT_CSCAN_PASV_DWELL_SECTION 'P' +#define WEXT_CSCAN_HOME_DWELL_SECTION 'H' +#define WEXT_CSCAN_TYPE_SECTION 'T' + +static struct mp_ioctl_handler mp_ioctl_hdl[] = { +/*0*/ GEN_HANDLER(sizeof(u32), oid_rt_pro_start_test_hdl, OID_RT_PRO_START_TEST) + GEN_HANDLER(sizeof(u32), oid_rt_pro_stop_test_hdl, OID_RT_PRO_STOP_TEST) + + GEN_HANDLER(sizeof(struct rwreg_param), oid_rt_pro_read_register_hdl, OID_RT_PRO_READ_REGISTER) + GEN_HANDLER(sizeof(struct rwreg_param), oid_rt_pro_write_register_hdl, OID_RT_PRO_WRITE_REGISTER) + GEN_HANDLER(sizeof(struct bb_reg_param), oid_rt_pro_read_bb_reg_hdl, OID_RT_PRO_READ_BB_REG) +/*5*/ GEN_HANDLER(sizeof(struct bb_reg_param), oid_rt_pro_write_bb_reg_hdl, OID_RT_PRO_WRITE_BB_REG) + GEN_HANDLER(sizeof(struct rf_reg_param), oid_rt_pro_read_rf_reg_hdl, OID_RT_PRO_RF_READ_REGISTRY) + GEN_HANDLER(sizeof(struct rf_reg_param), oid_rt_pro_write_rf_reg_hdl, OID_RT_PRO_RF_WRITE_REGISTRY) + + GEN_HANDLER(sizeof(u32), oid_rt_pro_set_channel_direct_call_hdl, OID_RT_PRO_SET_CHANNEL_DIRECT_CALL) + GEN_HANDLER(sizeof(struct txpower_param), oid_rt_pro_set_tx_power_control_hdl, OID_RT_PRO_SET_TX_POWER_CONTROL) +/*10*/ GEN_HANDLER(sizeof(u32), oid_rt_pro_set_data_rate_hdl, OID_RT_PRO_SET_DATA_RATE) + GEN_HANDLER(sizeof(u32), oid_rt_set_bandwidth_hdl, OID_RT_SET_BANDWIDTH) + GEN_HANDLER(sizeof(u32), oid_rt_pro_set_antenna_bb_hdl, OID_RT_PRO_SET_ANTENNA_BB) + + GEN_HANDLER(sizeof(u32), oid_rt_pro_set_continuous_tx_hdl, OID_RT_PRO_SET_CONTINUOUS_TX) + GEN_HANDLER(sizeof(u32), oid_rt_pro_set_single_carrier_tx_hdl, OID_RT_PRO_SET_SINGLE_CARRIER_TX) +/*15*/ GEN_HANDLER(sizeof(u32), oid_rt_pro_set_carrier_suppression_tx_hdl, OID_RT_PRO_SET_CARRIER_SUPPRESSION_TX) + GEN_HANDLER(sizeof(u32), oid_rt_pro_set_single_tone_tx_hdl, OID_RT_PRO_SET_SINGLE_TONE_TX) + + EXT_MP_IOCTL_HANDLER(0, xmit_packet, 0) + + GEN_HANDLER(sizeof(u32), oid_rt_set_rx_packet_type_hdl, OID_RT_SET_RX_PACKET_TYPE) + GEN_HANDLER(0, oid_rt_reset_phy_rx_packet_count_hdl, OID_RT_RESET_PHY_RX_PACKET_COUNT) +/*20*/ GEN_HANDLER(sizeof(u32), oid_rt_get_phy_rx_packet_received_hdl, OID_RT_GET_PHY_RX_PACKET_RECEIVED) + GEN_HANDLER(sizeof(u32), oid_rt_get_phy_rx_packet_crc32_error_hdl, OID_RT_GET_PHY_RX_PACKET_CRC32_ERROR) + + GEN_HANDLER(sizeof(struct eeprom_rw_param), NULL, 0) + GEN_HANDLER(sizeof(struct eeprom_rw_param), NULL, 0) + GEN_HANDLER(sizeof(struct efuse_access_struct), oid_rt_pro_efuse_hdl, OID_RT_PRO_EFUSE) +/*25*/ GEN_HANDLER(0, oid_rt_pro_efuse_map_hdl, OID_RT_PRO_EFUSE_MAP) + GEN_HANDLER(sizeof(u32), oid_rt_get_efuse_max_size_hdl, OID_RT_GET_EFUSE_MAX_SIZE) + GEN_HANDLER(sizeof(u32), oid_rt_get_efuse_current_size_hdl, OID_RT_GET_EFUSE_CURRENT_SIZE) + + GEN_HANDLER(sizeof(u32), oid_rt_get_thermal_meter_hdl, OID_RT_PRO_GET_THERMAL_METER) + GEN_HANDLER(sizeof(u8), oid_rt_pro_set_power_tracking_hdl, OID_RT_PRO_SET_POWER_TRACKING) +/*30*/ GEN_HANDLER(sizeof(u8), oid_rt_set_power_down_hdl, OID_RT_SET_POWER_DOWN) +/*31*/ GEN_HANDLER(0, oid_rt_pro_trigger_gpio_hdl, 0) +}; + +static u32 rtw_rates[] = {1000000, 2000000, 5500000, 11000000, + 6000000, 9000000, 12000000, 18000000, 24000000, 36000000, + 48000000, 54000000}; + +static const char * const iw_operation_mode[] = { + "Auto", "Ad-Hoc", "Managed", "Master", "Repeater", + "Secondary", "Monitor" +}; + +static int hex2num_i(char c) +{ + if (c >= '0' && c <= '9') + return c - '0'; + if (c >= 'a' && c <= 'f') + return c - 'a' + 10; + if (c >= 'A' && c <= 'F') + return c - 'A' + 10; + return -1; +} + +/** + * hwaddr_aton - Convert ASCII string to MAC address + * @txt: MAC address as a string (e.g., "00:11:22:33:44:55") + * @addr: Buffer for the MAC address (ETH_ALEN = 6 bytes) + * Returns: 0 on success, -1 on failure (e.g., string not a MAC address) + */ +static int hwaddr_aton_i(const char *txt, u8 *addr) +{ + int i; + + for (i = 0; i < 6; i++) { + int a, b; + + a = hex2num_i(*txt++); + if (a < 0) + return -1; + b = hex2num_i(*txt++); + if (b < 0) + return -1; + *addr++ = (a << 4) | b; + if (i < 5 && *txt++ != ':') + return -1; + } + + return 0; +} + +void indicate_wx_scan_complete_event(struct adapter *padapter) +{ + union iwreq_data wrqu; + + _rtw_memset(&wrqu, 0, sizeof(union iwreq_data)); + wireless_send_event(padapter->pnetdev, SIOCGIWSCAN, &wrqu, NULL); +} + +void rtw_indicate_wx_assoc_event(struct adapter *padapter) +{ + union iwreq_data wrqu; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + + _rtw_memset(&wrqu, 0, sizeof(union iwreq_data)); + + wrqu.ap_addr.sa_family = ARPHRD_ETHER; + + memcpy(wrqu.ap_addr.sa_data, pmlmepriv->cur_network.network.MacAddress, ETH_ALEN); + + DBG_88E_LEVEL(_drv_always_, "assoc success\n"); + wireless_send_event(padapter->pnetdev, SIOCGIWAP, &wrqu, NULL); +} + +void rtw_indicate_wx_disassoc_event(struct adapter *padapter) +{ + union iwreq_data wrqu; + + _rtw_memset(&wrqu, 0, sizeof(union iwreq_data)); + + wrqu.ap_addr.sa_family = ARPHRD_ETHER; + _rtw_memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN); + + DBG_88E_LEVEL(_drv_always_, "indicate disassoc\n"); + wireless_send_event(padapter->pnetdev, SIOCGIWAP, &wrqu, NULL); +} + +static char *translate_scan(struct adapter *padapter, + struct iw_request_info *info, + struct wlan_network *pnetwork, + char *start, char *stop) +{ + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct iw_event iwe; + u16 cap; + __le16 le_tmp; + u32 ht_ielen = 0; + char custom[MAX_CUSTOM_LEN]; + char *p; + u16 max_rate = 0, rate, ht_cap = false; + u32 i = 0; + u8 bw_40MHz = 0, short_GI = 0; + u16 mcs_rate = 0; + u8 ss, sq; +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &padapter->wdinfo; + + if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { + u32 blnGotP2PIE = false; + + /* User is doing the P2P device discovery */ + /* The prefix of SSID should be "DIRECT-" and the IE should contains the P2P IE. */ + /* If not, the driver should ignore this AP and go to the next AP. */ + + /* Verifying the SSID */ + if (!memcmp(pnetwork->network.Ssid.Ssid, pwdinfo->p2p_wildcard_ssid, P2P_WILDCARD_SSID_LEN)) { + u32 p2pielen = 0; + + if (pnetwork->network.Reserved[0] == 2) {/* Probe Request */ + /* Verifying the P2P IE */ + if (rtw_get_p2p_ie(pnetwork->network.IEs, pnetwork->network.IELength, NULL, &p2pielen)) + blnGotP2PIE = true; + } else {/* Beacon or Probe Respones */ + /* Verifying the P2P IE */ + if (rtw_get_p2p_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &p2pielen)) + blnGotP2PIE = true; + } + } + + if (!blnGotP2PIE) + return start; + } +#endif /* CONFIG_88EU_P2P */ + + /* AP MAC address */ + iwe.cmd = SIOCGIWAP; + iwe.u.ap_addr.sa_family = ARPHRD_ETHER; + + memcpy(iwe.u.ap_addr.sa_data, pnetwork->network.MacAddress, ETH_ALEN); + start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_ADDR_LEN); + + /* Add the ESSID */ + iwe.cmd = SIOCGIWESSID; + iwe.u.data.flags = 1; + iwe.u.data.length = min_t(u16, pnetwork->network.Ssid.SsidLength, 32); + start = iwe_stream_add_point(info, start, stop, &iwe, pnetwork->network.Ssid.Ssid); + + /* parsing HT_CAP_IE */ + p = rtw_get_ie(&pnetwork->network.IEs[12], _HT_CAPABILITY_IE_, &ht_ielen, pnetwork->network.IELength-12); + + if (p && ht_ielen > 0) { + struct rtw_ieee80211_ht_cap *pht_capie; + ht_cap = true; + pht_capie = (struct rtw_ieee80211_ht_cap *)(p+2); + memcpy(&mcs_rate, pht_capie->supp_mcs_set, 2); + bw_40MHz = (pht_capie->cap_info&IEEE80211_HT_CAP_SUP_WIDTH) ? 1 : 0; + short_GI = (pht_capie->cap_info&(IEEE80211_HT_CAP_SGI_20|IEEE80211_HT_CAP_SGI_40)) ? 1 : 0; + } + + /* Add the protocol name */ + iwe.cmd = SIOCGIWNAME; + if ((rtw_is_cckratesonly_included((u8 *)&pnetwork->network.SupportedRates))) { + if (ht_cap) + snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bn"); + else + snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11b"); + } else if ((rtw_is_cckrates_included((u8 *)&pnetwork->network.SupportedRates))) { + if (ht_cap) + snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bgn"); + else + snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bg"); + } else { + if (pnetwork->network.Configuration.DSConfig > 14) { + if (ht_cap) + snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11an"); + else + snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11a"); + } else { + if (ht_cap) + snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11gn"); + else + snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11g"); + } + } + + start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_CHAR_LEN); + + /* Add mode */ + iwe.cmd = SIOCGIWMODE; + memcpy(&le_tmp, rtw_get_capability_from_ie(pnetwork->network.IEs), 2); + + cap = le16_to_cpu(le_tmp); + + if (cap & (WLAN_CAPABILITY_IBSS | WLAN_CAPABILITY_BSS)) { + if (cap & WLAN_CAPABILITY_BSS) + iwe.u.mode = IW_MODE_MASTER; + else + iwe.u.mode = IW_MODE_ADHOC; + + start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_UINT_LEN); + } + + if (pnetwork->network.Configuration.DSConfig < 1) + pnetwork->network.Configuration.DSConfig = 1; + + /* Add frequency/channel */ + iwe.cmd = SIOCGIWFREQ; + iwe.u.freq.m = rtw_ch2freq(pnetwork->network.Configuration.DSConfig) * 100000; + iwe.u.freq.e = 1; + iwe.u.freq.i = pnetwork->network.Configuration.DSConfig; + start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_FREQ_LEN); + + /* Add encryption capability */ + iwe.cmd = SIOCGIWENCODE; + if (cap & WLAN_CAPABILITY_PRIVACY) + iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY; + else + iwe.u.data.flags = IW_ENCODE_DISABLED; + iwe.u.data.length = 0; + start = iwe_stream_add_point(info, start, stop, &iwe, pnetwork->network.Ssid.Ssid); + + /*Add basic and extended rates */ + max_rate = 0; + p = custom; + p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), " Rates (Mb/s): "); + while (pnetwork->network.SupportedRates[i] != 0) { + rate = pnetwork->network.SupportedRates[i]&0x7F; + if (rate > max_rate) + max_rate = rate; + p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), + "%d%s ", rate >> 1, (rate & 1) ? ".5" : ""); + i++; + } + + if (ht_cap) { + if (mcs_rate&0x8000)/* MCS15 */ + max_rate = (bw_40MHz) ? ((short_GI) ? 300 : 270) : ((short_GI) ? 144 : 130); + else if (mcs_rate&0x0080)/* MCS7 */ + ; + else/* default MCS7 */ + max_rate = (bw_40MHz) ? ((short_GI) ? 150 : 135) : ((short_GI) ? 72 : 65); + + max_rate = max_rate*2;/* Mbps/2; */ + } + + iwe.cmd = SIOCGIWRATE; + iwe.u.bitrate.fixed = 0; + iwe.u.bitrate.disabled = 0; + iwe.u.bitrate.value = max_rate * 500000; + start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_PARAM_LEN); + + /* parsing WPA/WPA2 IE */ + { + u8 buf[MAX_WPA_IE_LEN]; + u8 wpa_ie[255], rsn_ie[255]; + u16 wpa_len = 0, rsn_len = 0; + u8 *p; + + rtw_get_sec_ie(pnetwork->network.IEs, pnetwork->network.IELength, rsn_ie, &rsn_len, wpa_ie, &wpa_len); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_scan: ssid =%s\n", pnetwork->network.Ssid.Ssid)); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_scan: wpa_len =%d rsn_len =%d\n", wpa_len, rsn_len)); + + if (wpa_len > 0) { + p = buf; + _rtw_memset(buf, 0, MAX_WPA_IE_LEN); + p += sprintf(p, "wpa_ie ="); + for (i = 0; i < wpa_len; i++) + p += sprintf(p, "%02x", wpa_ie[i]); + + _rtw_memset(&iwe, 0, sizeof(iwe)); + iwe.cmd = IWEVCUSTOM; + iwe.u.data.length = strlen(buf); + start = iwe_stream_add_point(info, start, stop, &iwe, buf); + + _rtw_memset(&iwe, 0, sizeof(iwe)); + iwe.cmd = IWEVGENIE; + iwe.u.data.length = wpa_len; + start = iwe_stream_add_point(info, start, stop, &iwe, wpa_ie); + } + if (rsn_len > 0) { + p = buf; + _rtw_memset(buf, 0, MAX_WPA_IE_LEN); + p += sprintf(p, "rsn_ie ="); + for (i = 0; i < rsn_len; i++) + p += sprintf(p, "%02x", rsn_ie[i]); + _rtw_memset(&iwe, 0, sizeof(iwe)); + iwe.cmd = IWEVCUSTOM; + iwe.u.data.length = strlen(buf); + start = iwe_stream_add_point(info, start, stop, &iwe, buf); + + _rtw_memset(&iwe, 0, sizeof(iwe)); + iwe.cmd = IWEVGENIE; + iwe.u.data.length = rsn_len; + start = iwe_stream_add_point(info, start, stop, &iwe, rsn_ie); + } + } + + {/* parsing WPS IE */ + uint cnt = 0, total_ielen; + u8 *wpsie_ptr = NULL; + uint wps_ielen = 0; + + u8 *ie_ptr = pnetwork->network.IEs + _FIXED_IE_LENGTH_; + total_ielen = pnetwork->network.IELength - _FIXED_IE_LENGTH_; + + while (cnt < total_ielen) { + if (rtw_is_wps_ie(&ie_ptr[cnt], &wps_ielen) && (wps_ielen > 2)) { + wpsie_ptr = &ie_ptr[cnt]; + iwe.cmd = IWEVGENIE; + iwe.u.data.length = (u16)wps_ielen; + start = iwe_stream_add_point(info, start, stop, &iwe, wpsie_ptr); + } + cnt += ie_ptr[cnt+1]+2; /* goto next */ + } + } + + /* Add quality statistics */ + iwe.cmd = IWEVQUAL; + iwe.u.qual.updated = IW_QUAL_QUAL_UPDATED | IW_QUAL_LEVEL_UPDATED | IW_QUAL_NOISE_INVALID; + + if (check_fwstate(pmlmepriv, _FW_LINKED) == true && + is_same_network(&pmlmepriv->cur_network.network, &pnetwork->network)) { + ss = padapter->recvpriv.signal_strength; + sq = padapter->recvpriv.signal_qual; + } else { + ss = pnetwork->network.PhyInfo.SignalStrength; + sq = pnetwork->network.PhyInfo.SignalQuality; + } + + iwe.u.qual.level = (u8)ss; + iwe.u.qual.qual = (u8)sq; /* signal quality */ + iwe.u.qual.noise = 0; /* noise level */ + start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_QUAL_LEN); + return start; +} + +static int wpa_set_auth_algs(struct net_device *dev, u32 value) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + int ret = 0; + + if ((value & AUTH_ALG_SHARED_KEY) && (value & AUTH_ALG_OPEN_SYSTEM)) { + DBG_88E("wpa_set_auth_algs, AUTH_ALG_SHARED_KEY and AUTH_ALG_OPEN_SYSTEM [value:0x%x]\n", value); + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; + padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeAutoSwitch; + padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Auto; + } else if (value & AUTH_ALG_SHARED_KEY) { + DBG_88E("wpa_set_auth_algs, AUTH_ALG_SHARED_KEY [value:0x%x]\n", value); + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; + + padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeShared; + padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Shared; + } else if (value & AUTH_ALG_OPEN_SYSTEM) { + DBG_88E("wpa_set_auth_algs, AUTH_ALG_OPEN_SYSTEM\n"); + if (padapter->securitypriv.ndisauthtype < Ndis802_11AuthModeWPAPSK) { + padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen; + padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open; + } + } else if (value & AUTH_ALG_LEAP) { + DBG_88E("wpa_set_auth_algs, AUTH_ALG_LEAP\n"); + } else { + DBG_88E("wpa_set_auth_algs, error!\n"); + ret = -EINVAL; + } + return ret; +} + +static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, u32 param_len) +{ + int ret = 0; + u32 wep_key_idx, wep_key_len, wep_total_len; + struct ndis_802_11_wep *pwep = NULL; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct security_priv *psecuritypriv = &padapter->securitypriv; +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &padapter->wdinfo; +#endif /* CONFIG_88EU_P2P */ + +_func_enter_; + + param->u.crypt.err = 0; + param->u.crypt.alg[IEEE_CRYPT_ALG_NAME_LEN - 1] = '\0'; + + if (param_len < (u32) ((u8 *)param->u.crypt.key - (u8 *)param) + param->u.crypt.key_len) { + ret = -EINVAL; + goto exit; + } + + if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && + param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && + param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) { + if (param->u.crypt.idx >= WEP_KEYS) { + ret = -EINVAL; + goto exit; + } + } else { + ret = -EINVAL; + goto exit; + } + + if (strcmp(param->u.crypt.alg, "WEP") == 0) { + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, ("wpa_set_encryption, crypt.alg = WEP\n")); + DBG_88E("wpa_set_encryption, crypt.alg = WEP\n"); + + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; + padapter->securitypriv.dot11PrivacyAlgrthm = _WEP40_; + padapter->securitypriv.dot118021XGrpPrivacy = _WEP40_; + + wep_key_idx = param->u.crypt.idx; + wep_key_len = param->u.crypt.key_len; + + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("(1)wep_key_idx =%d\n", wep_key_idx)); + DBG_88E("(1)wep_key_idx =%d\n", wep_key_idx); + + if (wep_key_idx > WEP_KEYS) + return -EINVAL; + + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("(2)wep_key_idx =%d\n", wep_key_idx)); + + if (wep_key_len > 0) { + wep_key_len = wep_key_len <= 5 ? 5 : 13; + wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial); + pwep = (struct ndis_802_11_wep *)rtw_malloc(wep_total_len); + if (pwep == NULL) { + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, (" wpa_set_encryption: pwep allocate fail !!!\n")); + goto exit; + } + _rtw_memset(pwep, 0, wep_total_len); + pwep->KeyLength = wep_key_len; + pwep->Length = wep_total_len; + if (wep_key_len == 13) { + padapter->securitypriv.dot11PrivacyAlgrthm = _WEP104_; + padapter->securitypriv.dot118021XGrpPrivacy = _WEP104_; + } + } else { + ret = -EINVAL; + goto exit; + } + pwep->KeyIndex = wep_key_idx; + pwep->KeyIndex |= 0x80000000; + memcpy(pwep->KeyMaterial, param->u.crypt.key, pwep->KeyLength); + if (param->u.crypt.set_tx) { + DBG_88E("wep, set_tx = 1\n"); + if (rtw_set_802_11_add_wep(padapter, pwep) == (u8)_FAIL) + ret = -EOPNOTSUPP; + } else { + DBG_88E("wep, set_tx = 0\n"); + if (wep_key_idx >= WEP_KEYS) { + ret = -EOPNOTSUPP; + goto exit; + } + memcpy(&(psecuritypriv->dot11DefKey[wep_key_idx].skey[0]), pwep->KeyMaterial, pwep->KeyLength); + psecuritypriv->dot11DefKeylen[wep_key_idx] = pwep->KeyLength; + rtw_set_key(padapter, psecuritypriv, wep_key_idx, 0); + } + goto exit; + } + + if (padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) { /* 802_1x */ + struct sta_info *psta, *pbcmc_sta; + struct sta_priv *pstapriv = &padapter->stapriv; + + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE | WIFI_MP_STATE)) { /* sta mode */ + psta = rtw_get_stainfo(pstapriv, get_bssid(pmlmepriv)); + if (psta == NULL) { + ; + } else { + if (strcmp(param->u.crypt.alg, "none") != 0) + psta->ieee8021x_blocked = false; + + if ((padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption2Enabled) || + (padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption3Enabled)) + psta->dot118021XPrivacy = padapter->securitypriv.dot11PrivacyAlgrthm; + + if (param->u.crypt.set_tx == 1) { /* pairwise key */ + memcpy(psta->dot118021x_UncstKey.skey, param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); + + if (strcmp(param->u.crypt.alg, "TKIP") == 0) { /* set mic key */ + memcpy(psta->dot11tkiptxmickey.skey, &(param->u.crypt.key[16]), 8); + memcpy(psta->dot11tkiprxmickey.skey, &(param->u.crypt.key[24]), 8); + padapter->securitypriv.busetkipkey = false; + } + + DBG_88E(" ~~~~set sta key:unicastkey\n"); + + rtw_setstakey_cmd(padapter, (unsigned char *)psta, true); + } else { /* group key */ + memcpy(padapter->securitypriv.dot118021XGrpKey[param->u.crypt.idx].skey, param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); + memcpy(padapter->securitypriv.dot118021XGrptxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[16]), 8); + memcpy(padapter->securitypriv.dot118021XGrprxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[24]), 8); + padapter->securitypriv.binstallGrpkey = true; + DBG_88E(" ~~~~set sta key:groupkey\n"); + + padapter->securitypriv.dot118021XGrpKeyid = param->u.crypt.idx; + + rtw_set_key(padapter, &padapter->securitypriv, param->u.crypt.idx, 1); +#ifdef CONFIG_88EU_P2P + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_PROVISIONING_ING)) + rtw_p2p_set_state(pwdinfo, P2P_STATE_PROVISIONING_DONE); +#endif /* CONFIG_88EU_P2P */ + } + } + pbcmc_sta = rtw_get_bcmc_stainfo(padapter); + if (pbcmc_sta == NULL) { + ; + } else { + /* Jeff: don't disable ieee8021x_blocked while clearing key */ + if (strcmp(param->u.crypt.alg, "none") != 0) + pbcmc_sta->ieee8021x_blocked = false; + + if ((padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption2Enabled) || + (padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption3Enabled)) + pbcmc_sta->dot118021XPrivacy = padapter->securitypriv.dot11PrivacyAlgrthm; + } + } + } + +exit: + + kfree(pwep); + +_func_exit_; + + return ret; +} + +static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ielen) +{ + u8 *buf = NULL; + int group_cipher = 0, pairwise_cipher = 0; + int ret = 0; +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &padapter->wdinfo; +#endif /* CONFIG_88EU_P2P */ + + if ((ielen > MAX_WPA_IE_LEN) || (pie == NULL)) { + _clr_fwstate_(&padapter->mlmepriv, WIFI_UNDER_WPS); + if (pie == NULL) + return ret; + else + return -EINVAL; + } + + if (ielen) { + buf = rtw_zmalloc(ielen); + if (buf == NULL) { + ret = -ENOMEM; + goto exit; + } + + memcpy(buf, pie, ielen); + + /* dump */ + { + int i; + DBG_88E("\n wpa_ie(length:%d):\n", ielen); + for (i = 0; i < ielen; i += 8) + DBG_88E("0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x\n", buf[i], buf[i+1], buf[i+2], buf[i+3], buf[i+4], buf[i+5], buf[i+6], buf[i+7]); + } + + if (ielen < RSN_HEADER_LEN) { + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, ("Ie len too short %d\n", ielen)); + ret = -1; + goto exit; + } + + if (rtw_parse_wpa_ie(buf, ielen, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) { + padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; + padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeWPAPSK; + memcpy(padapter->securitypriv.supplicant_ie, &buf[0], ielen); + } + + if (rtw_parse_wpa2_ie(buf, ielen, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) { + padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; + padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeWPA2PSK; + memcpy(padapter->securitypriv.supplicant_ie, &buf[0], ielen); + } + + switch (group_cipher) { + case WPA_CIPHER_NONE: + padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; + break; + case WPA_CIPHER_WEP40: + padapter->securitypriv.dot118021XGrpPrivacy = _WEP40_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; + break; + case WPA_CIPHER_TKIP: + padapter->securitypriv.dot118021XGrpPrivacy = _TKIP_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption2Enabled; + break; + case WPA_CIPHER_CCMP: + padapter->securitypriv.dot118021XGrpPrivacy = _AES_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption3Enabled; + break; + case WPA_CIPHER_WEP104: + padapter->securitypriv.dot118021XGrpPrivacy = _WEP104_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; + break; + } + + switch (pairwise_cipher) { + case WPA_CIPHER_NONE: + padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; + break; + case WPA_CIPHER_WEP40: + padapter->securitypriv.dot11PrivacyAlgrthm = _WEP40_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; + break; + case WPA_CIPHER_TKIP: + padapter->securitypriv.dot11PrivacyAlgrthm = _TKIP_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption2Enabled; + break; + case WPA_CIPHER_CCMP: + padapter->securitypriv.dot11PrivacyAlgrthm = _AES_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption3Enabled; + break; + case WPA_CIPHER_WEP104: + padapter->securitypriv.dot11PrivacyAlgrthm = _WEP104_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; + break; + } + + _clr_fwstate_(&padapter->mlmepriv, WIFI_UNDER_WPS); + {/* set wps_ie */ + u16 cnt = 0; + u8 eid, wps_oui[4] = {0x0, 0x50, 0xf2, 0x04}; + + while (cnt < ielen) { + eid = buf[cnt]; + if ((eid == _VENDOR_SPECIFIC_IE_) && (!memcmp(&buf[cnt+2], wps_oui, 4))) { + DBG_88E("SET WPS_IE\n"); + + padapter->securitypriv.wps_ie_len = ((buf[cnt+1]+2) < (MAX_WPA_IE_LEN<<2)) ? (buf[cnt+1]+2) : (MAX_WPA_IE_LEN<<2); + + memcpy(padapter->securitypriv.wps_ie, &buf[cnt], padapter->securitypriv.wps_ie_len); + + set_fwstate(&padapter->mlmepriv, WIFI_UNDER_WPS); +#ifdef CONFIG_88EU_P2P + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_OK)) + rtw_p2p_set_state(pwdinfo, P2P_STATE_PROVISIONING_ING); +#endif /* CONFIG_88EU_P2P */ + cnt += buf[cnt+1]+2; + break; + } else { + cnt += buf[cnt+1]+2; /* goto next */ + } + } + } + } + + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, + ("rtw_set_wpa_ie: pairwise_cipher = 0x%08x padapter->securitypriv.ndisencryptstatus =%d padapter->securitypriv.ndisauthtype =%d\n", + pairwise_cipher, padapter->securitypriv.ndisencryptstatus, padapter->securitypriv.ndisauthtype)); +exit: + kfree(buf); + return ret; +} + +typedef unsigned char NDIS_802_11_RATES_EX[NDIS_802_11_LENGTH_RATES_EX]; + +static int rtw_wx_get_name(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + u32 ht_ielen = 0; + char *p; + u8 ht_cap = false; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; + NDIS_802_11_RATES_EX *prates = NULL; + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("cmd_code =%x\n", info->cmd)); + + _func_enter_; + + if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE) == true) { + /* parsing HT_CAP_IE */ + p = rtw_get_ie(&pcur_bss->IEs[12], _HT_CAPABILITY_IE_, &ht_ielen, pcur_bss->IELength-12); + if (p && ht_ielen > 0) + ht_cap = true; + + prates = &pcur_bss->SupportedRates; + + if (rtw_is_cckratesonly_included((u8 *)prates) == true) { + if (ht_cap) + snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bn"); + else + snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11b"); + } else if ((rtw_is_cckrates_included((u8 *)prates)) == true) { + if (ht_cap) + snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bgn"); + else + snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bg"); + } else { + if (pcur_bss->Configuration.DSConfig > 14) { + if (ht_cap) + snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11an"); + else + snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11a"); + } else { + if (ht_cap) + snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11gn"); + else + snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11g"); + } + } + } else { + snprintf(wrqu->name, IFNAMSIZ, "unassociated"); + } + + _func_exit_; + + return 0; +} + +static int rtw_wx_set_freq(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + _func_enter_; + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, ("+rtw_wx_set_freq\n")); + + _func_exit_; + + return 0; +} + +static int rtw_wx_get_freq(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; + + if (check_fwstate(pmlmepriv, _FW_LINKED)) { + /* wrqu->freq.m = ieee80211_wlan_frequencies[pcur_bss->Configuration.DSConfig-1] * 100000; */ + wrqu->freq.m = rtw_ch2freq(pcur_bss->Configuration.DSConfig) * 100000; + wrqu->freq.e = 1; + wrqu->freq.i = pcur_bss->Configuration.DSConfig; + } else { + wrqu->freq.m = rtw_ch2freq(padapter->mlmeextpriv.cur_channel) * 100000; + wrqu->freq.e = 1; + wrqu->freq.i = padapter->mlmeextpriv.cur_channel; + } + + return 0; +} + +static int rtw_wx_set_mode(struct net_device *dev, struct iw_request_info *a, + union iwreq_data *wrqu, char *b) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + enum ndis_802_11_network_infra networkType; + int ret = 0; + + _func_enter_; + + if (_FAIL == rtw_pwr_wakeup(padapter)) { + ret = -EPERM; + goto exit; + } + + if (!padapter->hw_init_completed) { + ret = -EPERM; + goto exit; + } + + switch (wrqu->mode) { + case IW_MODE_AUTO: + networkType = Ndis802_11AutoUnknown; + DBG_88E("set_mode = IW_MODE_AUTO\n"); + break; + case IW_MODE_ADHOC: + networkType = Ndis802_11IBSS; + DBG_88E("set_mode = IW_MODE_ADHOC\n"); + break; + case IW_MODE_MASTER: + networkType = Ndis802_11APMode; + DBG_88E("set_mode = IW_MODE_MASTER\n"); + break; + case IW_MODE_INFRA: + networkType = Ndis802_11Infrastructure; + DBG_88E("set_mode = IW_MODE_INFRA\n"); + break; + default: + ret = -EINVAL; + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, ("\n Mode: %s is not supported\n", iw_operation_mode[wrqu->mode])); + goto exit; + } + if (rtw_set_802_11_infrastructure_mode(padapter, networkType) == false) { + ret = -EPERM; + goto exit; + } + rtw_setopmode_cmd(padapter, networkType); +exit: + _func_exit_; + return ret; +} + +static int rtw_wx_get_mode(struct net_device *dev, struct iw_request_info *a, + union iwreq_data *wrqu, char *b) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, (" rtw_wx_get_mode\n")); + + _func_enter_; + + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) + wrqu->mode = IW_MODE_INFRA; + else if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) || + (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE))) + wrqu->mode = IW_MODE_ADHOC; + else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) + wrqu->mode = IW_MODE_MASTER; + else + wrqu->mode = IW_MODE_AUTO; + + _func_exit_; + + return 0; +} + +static int rtw_wx_set_pmkid(struct net_device *dev, + struct iw_request_info *a, + union iwreq_data *wrqu, char *extra) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + u8 j, blInserted = false; + int ret = false; + struct security_priv *psecuritypriv = &padapter->securitypriv; + struct iw_pmksa *pPMK = (struct iw_pmksa *)extra; + u8 strZeroMacAddress[ETH_ALEN] = {0x00}; + u8 strIssueBssid[ETH_ALEN] = {0x00}; + + memcpy(strIssueBssid, pPMK->bssid.sa_data, ETH_ALEN); + if (pPMK->cmd == IW_PMKSA_ADD) { + DBG_88E("[rtw_wx_set_pmkid] IW_PMKSA_ADD!\n"); + if (!memcmp(strIssueBssid, strZeroMacAddress, ETH_ALEN) == true) + return ret; + else + ret = true; + blInserted = false; + + /* overwrite PMKID */ + for (j = 0; j < NUM_PMKID_CACHE; j++) { + if (!memcmp(psecuritypriv->PMKIDList[j].Bssid, strIssueBssid, ETH_ALEN)) { + /* BSSID is matched, the same AP => rewrite with new PMKID. */ + DBG_88E("[rtw_wx_set_pmkid] BSSID exists in the PMKList.\n"); + memcpy(psecuritypriv->PMKIDList[j].PMKID, pPMK->pmkid, IW_PMKID_LEN); + psecuritypriv->PMKIDList[j].bUsed = true; + psecuritypriv->PMKIDIndex = j+1; + blInserted = true; + break; + } + } + + if (!blInserted) { + /* Find a new entry */ + DBG_88E("[rtw_wx_set_pmkid] Use the new entry index = %d for this PMKID.\n", + psecuritypriv->PMKIDIndex); + + memcpy(psecuritypriv->PMKIDList[psecuritypriv->PMKIDIndex].Bssid, strIssueBssid, ETH_ALEN); + memcpy(psecuritypriv->PMKIDList[psecuritypriv->PMKIDIndex].PMKID, pPMK->pmkid, IW_PMKID_LEN); + + psecuritypriv->PMKIDList[psecuritypriv->PMKIDIndex].bUsed = true; + psecuritypriv->PMKIDIndex++; + if (psecuritypriv->PMKIDIndex == 16) + psecuritypriv->PMKIDIndex = 0; + } + } else if (pPMK->cmd == IW_PMKSA_REMOVE) { + DBG_88E("[rtw_wx_set_pmkid] IW_PMKSA_REMOVE!\n"); + ret = true; + for (j = 0; j < NUM_PMKID_CACHE; j++) { + if (!memcmp(psecuritypriv->PMKIDList[j].Bssid, strIssueBssid, ETH_ALEN)) { + /* BSSID is matched, the same AP => Remove this PMKID information and reset it. */ + _rtw_memset(psecuritypriv->PMKIDList[j].Bssid, 0x00, ETH_ALEN); + psecuritypriv->PMKIDList[j].bUsed = false; + break; + } + } + } else if (pPMK->cmd == IW_PMKSA_FLUSH) { + DBG_88E("[rtw_wx_set_pmkid] IW_PMKSA_FLUSH!\n"); + _rtw_memset(&psecuritypriv->PMKIDList[0], 0x00, sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE); + psecuritypriv->PMKIDIndex = 0; + ret = true; + } + return ret; +} + +static int rtw_wx_get_sens(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + wrqu->sens.value = 0; + wrqu->sens.fixed = 0; /* no auto select */ + wrqu->sens.disabled = 1; + return 0; +} + +static int rtw_wx_get_range(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct iw_range *range = (struct iw_range *)extra; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + + u16 val; + int i; + + _func_enter_; + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_range. cmd_code =%x\n", info->cmd)); + + wrqu->data.length = sizeof(*range); + _rtw_memset(range, 0, sizeof(*range)); + + /* Let's try to keep this struct in the same order as in + * linux/include/wireless.h + */ + + /* TODO: See what values we can set, and remove the ones we can't + * set, or fill them with some default data. + */ + + /* ~5 Mb/s real (802.11b) */ + range->throughput = 5 * 1000 * 1000; + + /* signal level threshold range */ + + /* percent values between 0 and 100. */ + range->max_qual.qual = 100; + range->max_qual.level = 100; + range->max_qual.noise = 100; + range->max_qual.updated = 7; /* Updated all three */ + + range->avg_qual.qual = 92; /* > 8% missed beacons is 'bad' */ + /* TODO: Find real 'good' to 'bad' threshol value for RSSI */ + range->avg_qual.level = 20 + -98; + range->avg_qual.noise = 0; + range->avg_qual.updated = 7; /* Updated all three */ + + range->num_bitrates = RATE_COUNT; + + for (i = 0; i < RATE_COUNT && i < IW_MAX_BITRATES; i++) + range->bitrate[i] = rtw_rates[i]; + + range->min_frag = MIN_FRAG_THRESHOLD; + range->max_frag = MAX_FRAG_THRESHOLD; + + range->pm_capa = 0; + + range->we_version_compiled = WIRELESS_EXT; + range->we_version_source = 16; + + for (i = 0, val = 0; i < MAX_CHANNEL_NUM; i++) { + /* Include only legal frequencies for some countries */ + if (pmlmeext->channel_set[i].ChannelNum != 0) { + range->freq[val].i = pmlmeext->channel_set[i].ChannelNum; + range->freq[val].m = rtw_ch2freq(pmlmeext->channel_set[i].ChannelNum) * 100000; + range->freq[val].e = 1; + val++; + } + + if (val == IW_MAX_FREQUENCIES) + break; + } + + range->num_channels = val; + range->num_frequency = val; + +/* The following code will proivde the security capability to network manager. */ +/* If the driver doesn't provide this capability to network manager, */ +/* the WPA/WPA2 routers can't be choosen in the network manager. */ + +/* +#define IW_SCAN_CAPA_NONE 0x00 +#define IW_SCAN_CAPA_ESSID 0x01 +#define IW_SCAN_CAPA_BSSID 0x02 +#define IW_SCAN_CAPA_CHANNEL 0x04 +#define IW_SCAN_CAPA_MODE 0x08 +#define IW_SCAN_CAPA_RATE 0x10 +#define IW_SCAN_CAPA_TYPE 0x20 +#define IW_SCAN_CAPA_TIME 0x40 +*/ + + range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 | + IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP; + + range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | + IW_SCAN_CAPA_BSSID | IW_SCAN_CAPA_CHANNEL | + IW_SCAN_CAPA_MODE | IW_SCAN_CAPA_RATE; + _func_exit_; + + return 0; +} + +/* set bssid flow */ +/* s1. rtw_set_802_11_infrastructure_mode() */ +/* s2. rtw_set_802_11_authentication_mode() */ +/* s3. set_802_11_encryption_mode() */ +/* s4. rtw_set_802_11_bssid() */ +static int rtw_wx_set_wap(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *awrq, + char *extra) +{ + unsigned long irqL; + uint ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct sockaddr *temp = (struct sockaddr *)awrq; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct list_head *phead; + u8 *dst_bssid, *src_bssid; + struct __queue *queue = &(pmlmepriv->scanned_queue); + struct wlan_network *pnetwork = NULL; + enum ndis_802_11_auth_mode authmode; + + _func_enter_; + + if (_FAIL == rtw_pwr_wakeup(padapter)) { + ret = -1; + goto exit; + } + + if (!padapter->bup) { + ret = -1; + goto exit; + } + + if (temp->sa_family != ARPHRD_ETHER) { + ret = -EINVAL; + goto exit; + } + + authmode = padapter->securitypriv.ndisauthtype; + _enter_critical_bh(&queue->lock, &irqL); + phead = get_list_head(queue); + pmlmepriv->pscanned = get_next(phead); + + while (1) { + if ((rtw_end_of_queue_search(phead, pmlmepriv->pscanned)) == true) + break; + + pnetwork = LIST_CONTAINOR(pmlmepriv->pscanned, struct wlan_network, list); + + pmlmepriv->pscanned = get_next(pmlmepriv->pscanned); + + dst_bssid = pnetwork->network.MacAddress; + + src_bssid = temp->sa_data; + + if ((!memcmp(dst_bssid, src_bssid, ETH_ALEN))) { + if (!rtw_set_802_11_infrastructure_mode(padapter, pnetwork->network.InfrastructureMode)) { + ret = -1; + _exit_critical_bh(&queue->lock, &irqL); + goto exit; + } + + break; + } + } + _exit_critical_bh(&queue->lock, &irqL); + + rtw_set_802_11_authentication_mode(padapter, authmode); + /* set_802_11_encryption_mode(padapter, padapter->securitypriv.ndisencryptstatus); */ + if (rtw_set_802_11_bssid(padapter, temp->sa_data) == false) { + ret = -1; + goto exit; + } + +exit: + + _func_exit_; + + return ret; +} + +static int rtw_wx_get_wap(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; + + wrqu->ap_addr.sa_family = ARPHRD_ETHER; + + _rtw_memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN); + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_wap\n")); + + _func_enter_; + + if (((check_fwstate(pmlmepriv, _FW_LINKED)) == true) || + ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) == true) || + ((check_fwstate(pmlmepriv, WIFI_AP_STATE)) == true)) + memcpy(wrqu->ap_addr.sa_data, pcur_bss->MacAddress, ETH_ALEN); + else + _rtw_memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN); + + _func_exit_; + + return 0; +} + +static int rtw_wx_set_mlme(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + u16 reason; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct iw_mlme *mlme = (struct iw_mlme *)extra; + + if (mlme == NULL) + return -1; + + DBG_88E("%s\n", __func__); + + reason = mlme->reason_code; + + DBG_88E("%s, cmd =%d, reason =%d\n", __func__, mlme->cmd, reason); + + switch (mlme->cmd) { + case IW_MLME_DEAUTH: + if (!rtw_set_802_11_disassociate(padapter)) + ret = -1; + break; + case IW_MLME_DISASSOC: + if (!rtw_set_802_11_disassociate(padapter)) + ret = -1; + break; + default: + return -EOPNOTSUPP; + } + return ret; +} + +static int rtw_wx_set_scan(struct net_device *dev, struct iw_request_info *a, + union iwreq_data *wrqu, char *extra) +{ + u8 _status = false; + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct ndis_802_11_ssid ssid[RTW_SSID_SCAN_AMOUNT]; + unsigned long irqL; +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); +#endif /* CONFIG_88EU_P2P */ + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_set_scan\n")); + +_func_enter_; + if (padapter->registrypriv.mp_mode == 1) { + if (check_fwstate(pmlmepriv, WIFI_MP_STATE)) { + ret = -1; + goto exit; + } + } + if (_FAIL == rtw_pwr_wakeup(padapter)) { + ret = -1; + goto exit; + } + + if (padapter->bDriverStopped) { + DBG_88E("bDriverStopped =%d\n", padapter->bDriverStopped); + ret = -1; + goto exit; + } + + if (!padapter->bup) { + ret = -1; + goto exit; + } + + if (!padapter->hw_init_completed) { + ret = -1; + goto exit; + } + + /* When Busy Traffic, driver do not site survey. So driver return success. */ + /* wpa_supplicant will not issue SIOCSIWSCAN cmd again after scan timeout. */ + /* modify by thomas 2011-02-22. */ + if (pmlmepriv->LinkDetectInfo.bBusyTraffic) { + indicate_wx_scan_complete_event(padapter); + goto exit; + } + + if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING)) { + indicate_wx_scan_complete_event(padapter); + goto exit; + } + +/* For the DMP WiFi Display project, the driver won't to scan because */ +/* the pmlmepriv->scan_interval is always equal to 3. */ +/* So, the wpa_supplicant won't find out the WPS SoftAP. */ + +#ifdef CONFIG_88EU_P2P + if (pwdinfo->p2p_state != P2P_STATE_NONE) { + rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo)); + rtw_p2p_set_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH); + rtw_p2p_findphase_ex_set(pwdinfo, P2P_FINDPHASE_EX_FULL); + rtw_free_network_queue(padapter, true); + } +#endif /* CONFIG_88EU_P2P */ + + _rtw_memset(ssid, 0, sizeof(struct ndis_802_11_ssid)*RTW_SSID_SCAN_AMOUNT); + + if (wrqu->data.length == sizeof(struct iw_scan_req)) { + struct iw_scan_req *req = (struct iw_scan_req *)extra; + + if (wrqu->data.flags & IW_SCAN_THIS_ESSID) { + int len = min((int)req->essid_len, IW_ESSID_MAX_SIZE); + + memcpy(ssid[0].Ssid, req->essid, len); + ssid[0].SsidLength = len; + + DBG_88E("IW_SCAN_THIS_ESSID, ssid =%s, len =%d\n", req->essid, req->essid_len); + + _enter_critical_bh(&pmlmepriv->lock, &irqL); + + _status = rtw_sitesurvey_cmd(padapter, ssid, 1, NULL, 0); + + _exit_critical_bh(&pmlmepriv->lock, &irqL); + } else if (req->scan_type == IW_SCAN_TYPE_PASSIVE) { + DBG_88E("rtw_wx_set_scan, req->scan_type == IW_SCAN_TYPE_PASSIVE\n"); + } + } else { + if (wrqu->data.length >= WEXT_CSCAN_HEADER_SIZE && + !memcmp(extra, WEXT_CSCAN_HEADER, WEXT_CSCAN_HEADER_SIZE)) { + int len = wrqu->data.length - WEXT_CSCAN_HEADER_SIZE; + char *pos = extra+WEXT_CSCAN_HEADER_SIZE; + char section; + char sec_len; + int ssid_index = 0; + + while (len >= 1) { + section = *(pos++); + len -= 1; + + switch (section) { + case WEXT_CSCAN_SSID_SECTION: + if (len < 1) { + len = 0; + break; + } + sec_len = *(pos++); len -= 1; + if (sec_len > 0 && sec_len <= len) { + ssid[ssid_index].SsidLength = sec_len; + memcpy(ssid[ssid_index].Ssid, pos, ssid[ssid_index].SsidLength); + ssid_index++; + } + pos += sec_len; + len -= sec_len; + break; + case WEXT_CSCAN_TYPE_SECTION: + case WEXT_CSCAN_CHANNEL_SECTION: + pos += 1; + len -= 1; + break; + case WEXT_CSCAN_PASV_DWELL_SECTION: + case WEXT_CSCAN_HOME_DWELL_SECTION: + case WEXT_CSCAN_ACTV_DWELL_SECTION: + pos += 2; + len -= 2; + break; + default: + len = 0; /* stop parsing */ + } + } + + /* it has still some scan paramater to parse, we only do this now... */ + _status = rtw_set_802_11_bssid_list_scan(padapter, ssid, RTW_SSID_SCAN_AMOUNT); + } else { + _status = rtw_set_802_11_bssid_list_scan(padapter, NULL, 0); + } + } + + if (!_status) + ret = -1; + +exit: + +_func_exit_; + return ret; +} + +static int rtw_wx_get_scan(struct net_device *dev, struct iw_request_info *a, + union iwreq_data *wrqu, char *extra) +{ + unsigned long irqL; + struct list_head *plist, *phead; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct __queue *queue = &(pmlmepriv->scanned_queue); + struct wlan_network *pnetwork = NULL; + char *ev = extra; + char *stop = ev + wrqu->data.length; + u32 ret = 0; + u32 cnt = 0; + u32 wait_for_surveydone; + int wait_status; +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &padapter->wdinfo; +#endif /* CONFIG_88EU_P2P */ + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_scan\n")); + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, (" Start of Query SIOCGIWSCAN .\n")); + + _func_enter_; + + if (padapter->pwrctrlpriv.brfoffbyhw && padapter->bDriverStopped) { + ret = -EINVAL; + goto exit; + } + +#ifdef CONFIG_88EU_P2P + if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { + /* P2P is enabled */ + wait_for_surveydone = 200; + } else { + /* P2P is disabled */ + wait_for_surveydone = 100; + } +#else + { + wait_for_surveydone = 100; + } +#endif /* CONFIG_88EU_P2P */ + + wait_status = _FW_UNDER_SURVEY | _FW_UNDER_LINKING; + + while (check_fwstate(pmlmepriv, wait_status)) { + rtw_msleep_os(30); + cnt++; + if (cnt > wait_for_surveydone) + break; + } + + _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); + + phead = get_list_head(queue); + plist = get_next(phead); + + while (1) { + if (rtw_end_of_queue_search(phead, plist)) + break; + + if ((stop - ev) < SCAN_ITEM_SIZE) { + ret = -E2BIG; + break; + } + + pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); + + /* report network only if the current channel set contains the channel to which this network belongs */ + if (rtw_ch_set_search_ch(padapter->mlmeextpriv.channel_set, pnetwork->network.Configuration.DSConfig) >= 0) + ev = translate_scan(padapter, a, pnetwork, ev, stop); + + plist = get_next(plist); + } + + _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); + + wrqu->data.length = ev-extra; + wrqu->data.flags = 0; + +exit: + _func_exit_; + return ret; +} + +/* set ssid flow */ +/* s1. rtw_set_802_11_infrastructure_mode() */ +/* s2. set_802_11_authenticaion_mode() */ +/* s3. set_802_11_encryption_mode() */ +/* s4. rtw_set_802_11_ssid() */ +static int rtw_wx_set_essid(struct net_device *dev, + struct iw_request_info *a, + union iwreq_data *wrqu, char *extra) +{ + unsigned long irqL; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct __queue *queue = &pmlmepriv->scanned_queue; + struct list_head *phead; + struct wlan_network *pnetwork = NULL; + enum ndis_802_11_auth_mode authmode; + struct ndis_802_11_ssid ndis_ssid; + u8 *dst_ssid, *src_ssid; + + uint ret = 0, len; + + _func_enter_; + + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, + ("+rtw_wx_set_essid: fw_state = 0x%08x\n", get_fwstate(pmlmepriv))); + if (_FAIL == rtw_pwr_wakeup(padapter)) { + ret = -1; + goto exit; + } + + if (!padapter->bup) { + ret = -1; + goto exit; + } + + if (wrqu->essid.length > IW_ESSID_MAX_SIZE) { + ret = -E2BIG; + goto exit; + } + + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { + ret = -1; + goto exit; + } + + authmode = padapter->securitypriv.ndisauthtype; + DBG_88E("=>%s\n", __func__); + if (wrqu->essid.flags && wrqu->essid.length) { + len = (wrqu->essid.length < IW_ESSID_MAX_SIZE) ? wrqu->essid.length : IW_ESSID_MAX_SIZE; + + if (wrqu->essid.length != 33) + DBG_88E("ssid =%s, len =%d\n", extra, wrqu->essid.length); + + _rtw_memset(&ndis_ssid, 0, sizeof(struct ndis_802_11_ssid)); + ndis_ssid.SsidLength = len; + memcpy(ndis_ssid.Ssid, extra, len); + src_ssid = ndis_ssid.Ssid; + + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("rtw_wx_set_essid: ssid =[%s]\n", src_ssid)); + _enter_critical_bh(&queue->lock, &irqL); + phead = get_list_head(queue); + pmlmepriv->pscanned = get_next(phead); + + while (1) { + if (rtw_end_of_queue_search(phead, pmlmepriv->pscanned) == true) { + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_warning_, + ("rtw_wx_set_essid: scan_q is empty, set ssid to check if scanning again!\n")); + + break; + } + + pnetwork = LIST_CONTAINOR(pmlmepriv->pscanned, struct wlan_network, list); + + pmlmepriv->pscanned = get_next(pmlmepriv->pscanned); + + dst_ssid = pnetwork->network.Ssid.Ssid; + + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, + ("rtw_wx_set_essid: dst_ssid =%s\n", + pnetwork->network.Ssid.Ssid)); + + if ((!memcmp(dst_ssid, src_ssid, ndis_ssid.SsidLength)) && + (pnetwork->network.Ssid.SsidLength == ndis_ssid.SsidLength)) { + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, + ("rtw_wx_set_essid: find match, set infra mode\n")); + + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) { + if (pnetwork->network.InfrastructureMode != pmlmepriv->cur_network.network.InfrastructureMode) + continue; + } + + if (!rtw_set_802_11_infrastructure_mode(padapter, pnetwork->network.InfrastructureMode)) { + ret = -1; + _exit_critical_bh(&queue->lock, &irqL); + goto exit; + } + + break; + } + } + _exit_critical_bh(&queue->lock, &irqL); + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, + ("set ssid: set_802_11_auth. mode =%d\n", authmode)); + rtw_set_802_11_authentication_mode(padapter, authmode); + if (rtw_set_802_11_ssid(padapter, &ndis_ssid) == false) { + ret = -1; + goto exit; + } + } + +exit: + + DBG_88E("<=%s, ret %d\n", __func__, ret); + + _func_exit_; + + return ret; +} + +static int rtw_wx_get_essid(struct net_device *dev, + struct iw_request_info *a, + union iwreq_data *wrqu, char *extra) +{ + u32 len, ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_essid\n")); + + _func_enter_; + + if ((check_fwstate(pmlmepriv, _FW_LINKED)) || + (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE))) { + len = pcur_bss->Ssid.SsidLength; + + wrqu->essid.length = len; + + memcpy(extra, pcur_bss->Ssid.Ssid, len); + + wrqu->essid.flags = 1; + } else { + ret = -1; + goto exit; + } + +exit: + + _func_exit_; + + return ret; +} + +static int rtw_wx_set_rate(struct net_device *dev, + struct iw_request_info *a, + union iwreq_data *wrqu, char *extra) +{ + int i, ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + u8 datarates[NumRates]; + u32 target_rate = wrqu->bitrate.value; + u32 fixed = wrqu->bitrate.fixed; + u32 ratevalue = 0; + u8 mpdatarate[NumRates] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0xff}; + +_func_enter_; + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, (" rtw_wx_set_rate\n")); + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("target_rate = %d, fixed = %d\n", target_rate, fixed)); + + if (target_rate == -1) { + ratevalue = 11; + goto set_rate; + } + target_rate = target_rate/100000; + + switch (target_rate) { + case 10: + ratevalue = 0; + break; + case 20: + ratevalue = 1; + break; + case 55: + ratevalue = 2; + break; + case 60: + ratevalue = 3; + break; + case 90: + ratevalue = 4; + break; + case 110: + ratevalue = 5; + break; + case 120: + ratevalue = 6; + break; + case 180: + ratevalue = 7; + break; + case 240: + ratevalue = 8; + break; + case 360: + ratevalue = 9; + break; + case 480: + ratevalue = 10; + break; + case 540: + ratevalue = 11; + break; + default: + ratevalue = 11; + break; + } + +set_rate: + + for (i = 0; i < NumRates; i++) { + if (ratevalue == mpdatarate[i]) { + datarates[i] = mpdatarate[i]; + if (fixed == 0) + break; + } else { + datarates[i] = 0xff; + } + + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("datarate_inx =%d\n", datarates[i])); + } + + if (rtw_setdatarate_cmd(padapter, datarates) != _SUCCESS) { + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, ("rtw_wx_set_rate Fail!!!\n")); + ret = -1; + } + +_func_exit_; + + return ret; +} + +static int rtw_wx_get_rate(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + u16 max_rate = 0; + + max_rate = rtw_get_cur_max_rate((struct adapter *)rtw_netdev_priv(dev)); + + if (max_rate == 0) + return -EPERM; + + wrqu->bitrate.fixed = 0; /* no auto select */ + wrqu->bitrate.value = max_rate * 100000; + + return 0; +} + +static int rtw_wx_set_rts(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + + _func_enter_; + + if (wrqu->rts.disabled) { + padapter->registrypriv.rts_thresh = 2347; + } else { + if (wrqu->rts.value < 0 || + wrqu->rts.value > 2347) + return -EINVAL; + + padapter->registrypriv.rts_thresh = wrqu->rts.value; + } + + DBG_88E("%s, rts_thresh =%d\n", __func__, padapter->registrypriv.rts_thresh); + + _func_exit_; + + return 0; +} + +static int rtw_wx_get_rts(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + + _func_enter_; + + DBG_88E("%s, rts_thresh =%d\n", __func__, padapter->registrypriv.rts_thresh); + + wrqu->rts.value = padapter->registrypriv.rts_thresh; + wrqu->rts.fixed = 0; /* no auto select */ + /* wrqu->rts.disabled = (wrqu->rts.value == DEFAULT_RTS_THRESHOLD); */ + + _func_exit_; + + return 0; +} + +static int rtw_wx_set_frag(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + + _func_enter_; + + if (wrqu->frag.disabled) { + padapter->xmitpriv.frag_len = MAX_FRAG_THRESHOLD; + } else { + if (wrqu->frag.value < MIN_FRAG_THRESHOLD || + wrqu->frag.value > MAX_FRAG_THRESHOLD) + return -EINVAL; + + padapter->xmitpriv.frag_len = wrqu->frag.value & ~0x1; + } + + DBG_88E("%s, frag_len =%d\n", __func__, padapter->xmitpriv.frag_len); + + _func_exit_; + + return 0; +} + +static int rtw_wx_get_frag(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + + _func_enter_; + + DBG_88E("%s, frag_len =%d\n", __func__, padapter->xmitpriv.frag_len); + + wrqu->frag.value = padapter->xmitpriv.frag_len; + wrqu->frag.fixed = 0; /* no auto select */ + + _func_exit_; + + return 0; +} + +static int rtw_wx_get_retry(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + wrqu->retry.value = 7; + wrqu->retry.fixed = 0; /* no auto select */ + wrqu->retry.disabled = 1; + + return 0; +} + +static int rtw_wx_set_enc(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *keybuf) +{ + u32 key, ret = 0; + u32 keyindex_provided; + struct ndis_802_11_wep wep; + enum ndis_802_11_auth_mode authmode; + + struct iw_point *erq = &(wrqu->encoding); + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; + DBG_88E("+rtw_wx_set_enc, flags = 0x%x\n", erq->flags); + + _rtw_memset(&wep, 0, sizeof(struct ndis_802_11_wep)); + + key = erq->flags & IW_ENCODE_INDEX; + + _func_enter_; + + if (erq->flags & IW_ENCODE_DISABLED) { + DBG_88E("EncryptionDisabled\n"); + padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; + padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; + padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_; + padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */ + authmode = Ndis802_11AuthModeOpen; + padapter->securitypriv.ndisauthtype = authmode; + + goto exit; + } + + if (key) { + if (key > WEP_KEYS) + return -EINVAL; + key--; + keyindex_provided = 1; + } else { + keyindex_provided = 0; + key = padapter->securitypriv.dot11PrivacyKeyIndex; + DBG_88E("rtw_wx_set_enc, key =%d\n", key); + } + + /* set authentication mode */ + if (erq->flags & IW_ENCODE_OPEN) { + DBG_88E("rtw_wx_set_enc():IW_ENCODE_OPEN\n"); + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;/* Ndis802_11EncryptionDisabled; */ + padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open; + padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; + padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_; + authmode = Ndis802_11AuthModeOpen; + padapter->securitypriv.ndisauthtype = authmode; + } else if (erq->flags & IW_ENCODE_RESTRICTED) { + DBG_88E("rtw_wx_set_enc():IW_ENCODE_RESTRICTED\n"); + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; + padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Shared; + padapter->securitypriv.dot11PrivacyAlgrthm = _WEP40_; + padapter->securitypriv.dot118021XGrpPrivacy = _WEP40_; + authmode = Ndis802_11AuthModeShared; + padapter->securitypriv.ndisauthtype = authmode; + } else { + DBG_88E("rtw_wx_set_enc():erq->flags = 0x%x\n", erq->flags); + + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;/* Ndis802_11EncryptionDisabled; */ + padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */ + padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; + padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_; + authmode = Ndis802_11AuthModeOpen; + padapter->securitypriv.ndisauthtype = authmode; + } + + wep.KeyIndex = key; + if (erq->length > 0) { + wep.KeyLength = erq->length <= 5 ? 5 : 13; + + wep.Length = wep.KeyLength + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial); + } else { + wep.KeyLength = 0; + + if (keyindex_provided == 1) { + /* set key_id only, no given KeyMaterial(erq->length == 0). */ + padapter->securitypriv.dot11PrivacyKeyIndex = key; + + DBG_88E("(keyindex_provided == 1), keyid =%d, key_len =%d\n", key, padapter->securitypriv.dot11DefKeylen[key]); + + switch (padapter->securitypriv.dot11DefKeylen[key]) { + case 5: + padapter->securitypriv.dot11PrivacyAlgrthm = _WEP40_; + break; + case 13: + padapter->securitypriv.dot11PrivacyAlgrthm = _WEP104_; + break; + default: + padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; + break; + } + + goto exit; + } + } + + wep.KeyIndex |= 0x80000000; + + memcpy(wep.KeyMaterial, keybuf, wep.KeyLength); + + if (rtw_set_802_11_add_wep(padapter, &wep) == false) { + if (rf_on == pwrpriv->rf_pwrstate) + ret = -EOPNOTSUPP; + goto exit; + } + +exit: + + _func_exit_; + + return ret; +} + +static int rtw_wx_get_enc(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *keybuf) +{ + uint key, ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct iw_point *erq = &(wrqu->encoding); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + + _func_enter_; + + if (check_fwstate(pmlmepriv, _FW_LINKED) != true) { + if (!check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { + erq->length = 0; + erq->flags |= IW_ENCODE_DISABLED; + return 0; + } + } + + key = erq->flags & IW_ENCODE_INDEX; + + if (key) { + if (key > WEP_KEYS) + return -EINVAL; + key--; + } else { + key = padapter->securitypriv.dot11PrivacyKeyIndex; + } + + erq->flags = key + 1; + + switch (padapter->securitypriv.ndisencryptstatus) { + case Ndis802_11EncryptionNotSupported: + case Ndis802_11EncryptionDisabled: + erq->length = 0; + erq->flags |= IW_ENCODE_DISABLED; + break; + case Ndis802_11Encryption1Enabled: + erq->length = padapter->securitypriv.dot11DefKeylen[key]; + if (erq->length) { + memcpy(keybuf, padapter->securitypriv.dot11DefKey[key].skey, padapter->securitypriv.dot11DefKeylen[key]); + + erq->flags |= IW_ENCODE_ENABLED; + + if (padapter->securitypriv.ndisauthtype == Ndis802_11AuthModeOpen) + erq->flags |= IW_ENCODE_OPEN; + else if (padapter->securitypriv.ndisauthtype == Ndis802_11AuthModeShared) + erq->flags |= IW_ENCODE_RESTRICTED; + } else { + erq->length = 0; + erq->flags |= IW_ENCODE_DISABLED; + } + break; + case Ndis802_11Encryption2Enabled: + case Ndis802_11Encryption3Enabled: + erq->length = 16; + erq->flags |= (IW_ENCODE_ENABLED | IW_ENCODE_OPEN | IW_ENCODE_NOKEY); + break; + default: + erq->length = 0; + erq->flags |= IW_ENCODE_DISABLED; + break; + } + _func_exit_; + + return ret; +} + +static int rtw_wx_get_power(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + wrqu->power.value = 0; + wrqu->power.fixed = 0; /* no auto select */ + wrqu->power.disabled = 1; + + return 0; +} + +static int rtw_wx_set_gen_ie(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + + ret = rtw_set_wpa_ie(padapter, extra, wrqu->data.length); + return ret; +} + +static int rtw_wx_set_auth(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct iw_param *param = (struct iw_param *)&(wrqu->param); + int ret = 0; + + switch (param->flags & IW_AUTH_INDEX) { + case IW_AUTH_WPA_VERSION: + break; + case IW_AUTH_CIPHER_PAIRWISE: + + break; + case IW_AUTH_CIPHER_GROUP: + + break; + case IW_AUTH_KEY_MGMT: + /* + * ??? does not use these parameters + */ + break; + case IW_AUTH_TKIP_COUNTERMEASURES: + if (param->value) { + /* wpa_supplicant is enabling the tkip countermeasure. */ + padapter->securitypriv.btkip_countermeasure = true; + } else { + /* wpa_supplicant is disabling the tkip countermeasure. */ + padapter->securitypriv.btkip_countermeasure = false; + } + break; + case IW_AUTH_DROP_UNENCRYPTED: + /* HACK: + * + * wpa_supplicant calls set_wpa_enabled when the driver + * is loaded and unloaded, regardless of if WPA is being + * used. No other calls are made which can be used to + * determine if encryption will be used or not prior to + * association being expected. If encryption is not being + * used, drop_unencrypted is set to false, else true -- we + * can use this to determine if the CAP_PRIVACY_ON bit should + * be set. + */ + + if (padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption1Enabled) + break;/* it means init value, or using wep, ndisencryptstatus = Ndis802_11Encryption1Enabled, */ + /* then it needn't reset it; */ + + if (param->value) { + padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; + padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; + padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_; + padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */ + padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen; + } + + break; + case IW_AUTH_80211_AUTH_ALG: + /* + * It's the starting point of a link layer connection using wpa_supplicant + */ + if (check_fwstate(&padapter->mlmepriv, _FW_LINKED)) { + LeaveAllPowerSaveMode(padapter); + rtw_disassoc_cmd(padapter, 500, false); + DBG_88E("%s...call rtw_indicate_disconnect\n ", __func__); + rtw_indicate_disconnect(padapter); + rtw_free_assoc_resources(padapter, 1); + } + ret = wpa_set_auth_algs(dev, (u32)param->value); + break; + case IW_AUTH_WPA_ENABLED: + break; + case IW_AUTH_RX_UNENCRYPTED_EAPOL: + break; + case IW_AUTH_PRIVACY_INVOKED: + break; + default: + return -EOPNOTSUPP; + } + + return ret; +} + +static int rtw_wx_set_enc_ext(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + char *alg_name; + u32 param_len; + struct ieee_param *param = NULL; + struct iw_point *pencoding = &wrqu->encoding; + struct iw_encode_ext *pext = (struct iw_encode_ext *)extra; + int ret = 0; + + param_len = sizeof(struct ieee_param) + pext->key_len; + param = (struct ieee_param *)rtw_malloc(param_len); + if (param == NULL) + return -1; + + _rtw_memset(param, 0, param_len); + + param->cmd = IEEE_CMD_SET_ENCRYPTION; + _rtw_memset(param->sta_addr, 0xff, ETH_ALEN); + + switch (pext->alg) { + case IW_ENCODE_ALG_NONE: + /* todo: remove key */ + /* remove = 1; */ + alg_name = "none"; + break; + case IW_ENCODE_ALG_WEP: + alg_name = "WEP"; + break; + case IW_ENCODE_ALG_TKIP: + alg_name = "TKIP"; + break; + case IW_ENCODE_ALG_CCMP: + alg_name = "CCMP"; + break; + default: + return -1; + } + + strncpy((char *)param->u.crypt.alg, alg_name, IEEE_CRYPT_ALG_NAME_LEN); + + if (pext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) + param->u.crypt.set_tx = 1; + + /* cliW: WEP does not have group key + * just not checking GROUP key setting + */ + if ((pext->alg != IW_ENCODE_ALG_WEP) && + (pext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)) + param->u.crypt.set_tx = 0; + + param->u.crypt.idx = (pencoding->flags&0x00FF) - 1; + + if (pext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) + memcpy(param->u.crypt.seq, pext->rx_seq, 8); + + if (pext->key_len) { + param->u.crypt.key_len = pext->key_len; + memcpy(param->u.crypt.key, pext + 1, pext->key_len); + } + + ret = wpa_set_encryption(dev, param, param_len); + + kfree(param); + return ret; +} + +static int rtw_wx_get_nick(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + if (extra) { + wrqu->data.length = 14; + wrqu->data.flags = 1; + memcpy(extra, "", 14); + } + + /* dump debug info here */ + return 0; +} + +static int rtw_wx_read32(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct adapter *padapter; + struct iw_point *p; + u16 len; + u32 addr; + u32 data32; + u32 bytes; + u8 *ptmp; + + padapter = (struct adapter *)rtw_netdev_priv(dev); + p = &wrqu->data; + len = p->length; + ptmp = (u8 *)rtw_malloc(len); + if (NULL == ptmp) + return -ENOMEM; + + if (copy_from_user(ptmp, p->pointer, len)) { + kfree(ptmp); + return -EFAULT; + } + + bytes = 0; + addr = 0; + sscanf(ptmp, "%d,%x", &bytes, &addr); + + switch (bytes) { + case 1: + data32 = rtw_read8(padapter, addr); + sprintf(extra, "0x%02X", data32); + break; + case 2: + data32 = rtw_read16(padapter, addr); + sprintf(extra, "0x%04X", data32); + break; + case 4: + data32 = rtw_read32(padapter, addr); + sprintf(extra, "0x%08X", data32); + break; + default: + DBG_88E(KERN_INFO "%s: usage> read [bytes],[address(hex)]\n", __func__); + return -EINVAL; + } + DBG_88E(KERN_INFO "%s: addr = 0x%08X data =%s\n", __func__, addr, extra); + + kfree(ptmp); + return 0; +} + +static int rtw_wx_write32(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + + u32 addr; + u32 data32; + u32 bytes; + + bytes = 0; + addr = 0; + data32 = 0; + sscanf(extra, "%d,%x,%x", &bytes, &addr, &data32); + + switch (bytes) { + case 1: + rtw_write8(padapter, addr, (u8)data32); + DBG_88E(KERN_INFO "%s: addr = 0x%08X data = 0x%02X\n", __func__, addr, (u8)data32); + break; + case 2: + rtw_write16(padapter, addr, (u16)data32); + DBG_88E(KERN_INFO "%s: addr = 0x%08X data = 0x%04X\n", __func__, addr, (u16)data32); + break; + case 4: + rtw_write32(padapter, addr, data32); + DBG_88E(KERN_INFO "%s: addr = 0x%08X data = 0x%08X\n", __func__, addr, data32); + break; + default: + DBG_88E(KERN_INFO "%s: usage> write [bytes],[address(hex)],[data(hex)]\n", __func__); + return -EINVAL; + } + + return 0; +} + +static int rtw_wx_read_rf(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + u32 path, addr, data32; + + path = *(u32 *)extra; + addr = *((u32 *)extra + 1); + data32 = rtw_hal_read_rfreg(padapter, path, addr, 0xFFFFF); + /* + * IMPORTANT!! + * Only when wireless private ioctl is at odd order, + * "extra" would be copied to user space. + */ + sprintf(extra, "0x%05x", data32); + + return 0; +} + +static int rtw_wx_write_rf(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + u32 path, addr, data32; + + path = *(u32 *)extra; + addr = *((u32 *)extra + 1); + data32 = *((u32 *)extra + 2); + rtw_hal_write_rfreg(padapter, path, addr, 0xFFFFF, data32); + + return 0; +} + +static int rtw_wx_priv_null(struct net_device *dev, struct iw_request_info *a, + union iwreq_data *wrqu, char *b) +{ + return -1; +} + +static int dummy(struct net_device *dev, struct iw_request_info *a, + union iwreq_data *wrqu, char *b) +{ + return -1; +} + +static int rtw_wx_set_channel_plan(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + u8 channel_plan_req = (u8) (*((int *)wrqu)); + + if (_SUCCESS == rtw_set_chplan_cmd(padapter, channel_plan_req, 1)) + DBG_88E("%s set channel_plan = 0x%02X\n", __func__, pmlmepriv->ChannelPlan); + else + return -EPERM; + + return 0; +} + +static int rtw_wx_set_mtk_wps_probe_ie(struct net_device *dev, + struct iw_request_info *a, + union iwreq_data *wrqu, char *b) +{ + return 0; +} + +static int rtw_wx_get_sensitivity(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *buf) +{ + return 0; +} + +static int rtw_wx_set_mtk_wps_ie(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + return 0; +} + +/* + * For all data larger than 16 octets, we need to use a + * pointer to memory allocated in user space. + */ +static int rtw_drvext_hdl(struct net_device *dev, struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + return 0; +} + +static void rtw_dbg_mode_hdl(struct adapter *padapter, u32 id, u8 *pdata, u32 len) +{ + struct mp_rw_reg *RegRWStruct; + struct rf_reg_param *prfreg; + u8 path; + u8 offset; + u32 value; + + DBG_88E("%s\n", __func__); + + switch (id) { + case GEN_MP_IOCTL_SUBCODE(MP_START): + DBG_88E("871x_driver is only for normal mode, can't enter mp mode\n"); + break; + case GEN_MP_IOCTL_SUBCODE(READ_REG): + RegRWStruct = (struct mp_rw_reg *)pdata; + switch (RegRWStruct->width) { + case 1: + RegRWStruct->value = rtw_read8(padapter, RegRWStruct->offset); + break; + case 2: + RegRWStruct->value = rtw_read16(padapter, RegRWStruct->offset); + break; + case 4: + RegRWStruct->value = rtw_read32(padapter, RegRWStruct->offset); + break; + default: + break; + } + + break; + case GEN_MP_IOCTL_SUBCODE(WRITE_REG): + RegRWStruct = (struct mp_rw_reg *)pdata; + switch (RegRWStruct->width) { + case 1: + rtw_write8(padapter, RegRWStruct->offset, (u8)RegRWStruct->value); + break; + case 2: + rtw_write16(padapter, RegRWStruct->offset, (u16)RegRWStruct->value); + break; + case 4: + rtw_write32(padapter, RegRWStruct->offset, (u32)RegRWStruct->value); + break; + default: + break; + } + + break; + case GEN_MP_IOCTL_SUBCODE(READ_RF_REG): + + prfreg = (struct rf_reg_param *)pdata; + + path = (u8)prfreg->path; + offset = (u8)prfreg->offset; + + value = rtw_hal_read_rfreg(padapter, path, offset, 0xffffffff); + + prfreg->value = value; + + break; + case GEN_MP_IOCTL_SUBCODE(WRITE_RF_REG): + + prfreg = (struct rf_reg_param *)pdata; + + path = (u8)prfreg->path; + offset = (u8)prfreg->offset; + value = prfreg->value; + + rtw_hal_write_rfreg(padapter, path, offset, 0xffffffff, value); + + break; + case GEN_MP_IOCTL_SUBCODE(TRIGGER_GPIO): + DBG_88E("==> trigger gpio 0\n"); + rtw_hal_set_hwreg(padapter, HW_VAR_TRIGGER_GPIO_0, NULL); + break; + case GEN_MP_IOCTL_SUBCODE(GET_WIFI_STATUS): + *pdata = rtw_hal_sreset_get_wifi_status(padapter); + break; + default: + break; + } +} + +static int rtw_mp_ioctl_hdl(struct net_device *dev, struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + u32 BytesRead, BytesWritten, BytesNeeded; + struct oid_par_priv oid_par; + struct mp_ioctl_handler *phandler; + struct mp_ioctl_param *poidparam; + uint status = 0; + u16 len; + u8 *pparmbuf = NULL, bset; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct iw_point *p = &wrqu->data; + + if ((!p->length) || (!p->pointer)) { + ret = -EINVAL; + goto _rtw_mp_ioctl_hdl_exit; + } + pparmbuf = NULL; + bset = (u8)(p->flags & 0xFFFF); + len = p->length; + pparmbuf = (u8 *)rtw_malloc(len); + if (pparmbuf == NULL) { + ret = -ENOMEM; + goto _rtw_mp_ioctl_hdl_exit; + } + + if (copy_from_user(pparmbuf, p->pointer, len)) { + ret = -EFAULT; + goto _rtw_mp_ioctl_hdl_exit; + } + + poidparam = (struct mp_ioctl_param *)pparmbuf; + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, + ("rtw_mp_ioctl_hdl: subcode [%d], len[%d], buffer_len[%d]\r\n", + poidparam->subcode, poidparam->len, len)); + + if (poidparam->subcode >= MAX_MP_IOCTL_SUBCODE) { + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, ("no matching drvext subcodes\r\n")); + ret = -EINVAL; + goto _rtw_mp_ioctl_hdl_exit; + } + + if (padapter->registrypriv.mp_mode == 1) { + phandler = mp_ioctl_hdl + poidparam->subcode; + + if ((phandler->paramsize != 0) && (poidparam->len < phandler->paramsize)) { + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, + ("no matching drvext param size %d vs %d\r\n", + poidparam->len, phandler->paramsize)); + ret = -EINVAL; + goto _rtw_mp_ioctl_hdl_exit; + } + + if (phandler->handler) { + oid_par.adapter_context = padapter; + oid_par.oid = phandler->oid; + oid_par.information_buf = poidparam->data; + oid_par.information_buf_len = poidparam->len; + oid_par.dbg = 0; + + BytesWritten = 0; + BytesNeeded = 0; + + if (bset) { + oid_par.bytes_rw = &BytesRead; + oid_par.bytes_needed = &BytesNeeded; + oid_par.type_of_oid = SET_OID; + } else { + oid_par.bytes_rw = &BytesWritten; + oid_par.bytes_needed = &BytesNeeded; + oid_par.type_of_oid = QUERY_OID; + } + + status = phandler->handler(&oid_par); + } else { + DBG_88E("rtw_mp_ioctl_hdl(): err!, subcode =%d, oid =%d, handler =%p\n", + poidparam->subcode, phandler->oid, phandler->handler); + ret = -EFAULT; + goto _rtw_mp_ioctl_hdl_exit; + } + } else { + rtw_dbg_mode_hdl(padapter, poidparam->subcode, poidparam->data, poidparam->len); + } + + if (bset == 0x00) {/* query info */ + if (copy_to_user(p->pointer, pparmbuf, len)) + ret = -EFAULT; + } + + if (status) { + ret = -EFAULT; + goto _rtw_mp_ioctl_hdl_exit; + } + +_rtw_mp_ioctl_hdl_exit: + + kfree(pparmbuf); + return ret; +} + +static int rtw_get_ap_info(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + u32 cnt = 0, wpa_ielen; + unsigned long irqL; + struct list_head *plist, *phead; + unsigned char *pbuf; + u8 bssid[ETH_ALEN]; + char data[32]; + struct wlan_network *pnetwork = NULL; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct __queue *queue = &(pmlmepriv->scanned_queue); + struct iw_point *pdata = &wrqu->data; + + DBG_88E("+rtw_get_aplist_info\n"); + + if ((padapter->bDriverStopped) || (pdata == NULL)) { + ret = -EINVAL; + goto exit; + } + + while ((check_fwstate(pmlmepriv, (_FW_UNDER_SURVEY|_FW_UNDER_LINKING)))) { + rtw_msleep_os(30); + cnt++; + if (cnt > 100) + break; + } + pdata->flags = 0; + if (pdata->length >= 32) { + if (copy_from_user(data, pdata->pointer, 32)) { + ret = -EINVAL; + goto exit; + } + } else { + ret = -EINVAL; + goto exit; + } + + _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); + + phead = get_list_head(queue); + plist = get_next(phead); + + while (1) { + if (rtw_end_of_queue_search(phead, plist) == true) + break; + + pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); + + if (hwaddr_aton_i(data, bssid)) { + DBG_88E("Invalid BSSID '%s'.\n", (u8 *)data); + _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); + return -EINVAL; + } + + if (!memcmp(bssid, pnetwork->network.MacAddress, ETH_ALEN) == true) { + /* BSSID match, then check if supporting wpa/wpa2 */ + DBG_88E("BSSID:%pM\n", (bssid)); + + pbuf = rtw_get_wpa_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength-12); + if (pbuf && (wpa_ielen > 0)) { + pdata->flags = 1; + break; + } + + pbuf = rtw_get_wpa2_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength-12); + if (pbuf && (wpa_ielen > 0)) { + pdata->flags = 2; + break; + } + } + + plist = get_next(plist); + } + + _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); + + if (pdata->length >= 34) { + if (copy_to_user(pdata->pointer+32, (u8 *)&pdata->flags, 1)) { + ret = -EINVAL; + goto exit; + } + } + +exit: + + return ret; +} + +static int rtw_set_pid(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = rtw_netdev_priv(dev); + int *pdata = (int *)wrqu; + int selector; + + if ((padapter->bDriverStopped) || (pdata == NULL)) { + ret = -EINVAL; + goto exit; + } + + selector = *pdata; + if (selector < 3 && selector >= 0) { + padapter->pid[selector] = *(pdata+1); + ui_pid[selector] = *(pdata+1); + DBG_88E("%s set pid[%d] =%d\n", __func__, selector, padapter->pid[selector]); + } else { + DBG_88E("%s selector %d error\n", __func__, selector); + } +exit: + return ret; +} + +static int rtw_wps_start(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct iw_point *pdata = &wrqu->data; + u32 u32wps_start = 0; + + ret = copy_from_user((void *)&u32wps_start, pdata->pointer, 4); + if (ret) { + ret = -EINVAL; + goto exit; + } + + if ((padapter->bDriverStopped) || (pdata == NULL)) { + ret = -EINVAL; + goto exit; + } + + if (u32wps_start == 0) + u32wps_start = *extra; + + DBG_88E("[%s] wps_start = %d\n", __func__, u32wps_start); + + if (u32wps_start == 1) /* WPS Start */ + rtw_led_control(padapter, LED_CTL_START_WPS); + else if (u32wps_start == 2) /* WPS Stop because of wps success */ + rtw_led_control(padapter, LED_CTL_STOP_WPS); + else if (u32wps_start == 3) /* WPS Stop because of wps fail */ + rtw_led_control(padapter, LED_CTL_STOP_WPS_FAIL); + +exit: + return ret; +} + +#ifdef CONFIG_88EU_P2P +static int rtw_wext_p2p_enable(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + enum P2P_ROLE init_role = P2P_ROLE_DISABLE; + + if (*extra == '0') + init_role = P2P_ROLE_DISABLE; + else if (*extra == '1') + init_role = P2P_ROLE_DEVICE; + else if (*extra == '2') + init_role = P2P_ROLE_CLIENT; + else if (*extra == '3') + init_role = P2P_ROLE_GO; + + if (_FAIL == rtw_p2p_enable(padapter, init_role)) { + ret = -EFAULT; + goto exit; + } + + /* set channel/bandwidth */ + if (init_role != P2P_ROLE_DISABLE) { + u8 channel, ch_offset; + u16 bwmode; + + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_LISTEN)) { + /* Stay at the listen state and wait for discovery. */ + channel = pwdinfo->listen_channel; + pwdinfo->operating_channel = pwdinfo->listen_channel; + ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; + bwmode = HT_CHANNEL_WIDTH_20; + } else { + pwdinfo->operating_channel = pmlmeext->cur_channel; + + channel = pwdinfo->operating_channel; + ch_offset = pmlmeext->cur_ch_offset; + bwmode = pmlmeext->cur_bwmode; + } + + set_channel_bwmode(padapter, channel, ch_offset, bwmode); + } + +exit: + return ret; +} + +static int rtw_p2p_set_go_nego_ssid(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + + DBG_88E("[%s] ssid = %s, len = %zu\n", __func__, extra, strlen(extra)); + memcpy(pwdinfo->nego_ssid, extra, strlen(extra)); + pwdinfo->nego_ssidlen = strlen(extra); + + return ret; +} + +static int rtw_p2p_set_intent(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + u8 intent = pwdinfo->intent; + + switch (wrqu->data.length) { + case 1: + intent = extra[0] - '0'; + break; + case 2: + intent = str_2char2num(extra[0], extra[1]); + break; + } + if (intent <= 15) + pwdinfo->intent = intent; + else + ret = -1; + DBG_88E("[%s] intent = %d\n", __func__, intent); + return ret; +} + +static int rtw_p2p_set_listen_ch(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + u8 listen_ch = pwdinfo->listen_channel; /* Listen channel number */ + + switch (wrqu->data.length) { + case 1: + listen_ch = extra[0] - '0'; + break; + case 2: + listen_ch = str_2char2num(extra[0], extra[1]); + break; + } + + if ((listen_ch == 1) || (listen_ch == 6) || (listen_ch == 11)) { + pwdinfo->listen_channel = listen_ch; + set_channel_bwmode(padapter, pwdinfo->listen_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); + } else { + ret = -1; + } + + DBG_88E("[%s] listen_ch = %d\n", __func__, pwdinfo->listen_channel); + + return ret; +} + +static int rtw_p2p_set_op_ch(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ +/* Commented by Albert 20110524 */ +/* This function is used to set the operating channel if the driver will become the group owner */ + + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + u8 op_ch = pwdinfo->operating_channel; /* Operating channel number */ + + switch (wrqu->data.length) { + case 1: + op_ch = extra[0] - '0'; + break; + case 2: + op_ch = str_2char2num(extra[0], extra[1]); + break; + } + + if (op_ch > 0) + pwdinfo->operating_channel = op_ch; + else + ret = -1; + + DBG_88E("[%s] op_ch = %d\n", __func__, pwdinfo->operating_channel); + + return ret; +} + +static int rtw_p2p_profilefound(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + + /* Comment by Albert 2010/10/13 */ + /* Input data format: */ + /* Ex: 0 */ + /* Ex: 1XX:XX:XX:XX:XX:XXYYSSID */ + /* 0 => Reflush the profile record list. */ + /* 1 => Add the profile list */ + /* XX:XX:XX:XX:XX:XX => peer's MAC Address (ex: 00:E0:4C:00:00:01) */ + /* YY => SSID Length */ + /* SSID => SSID for persistence group */ + + DBG_88E("[%s] In value = %s, len = %d\n", __func__, extra, wrqu->data.length - 1); + + /* The upper application should pass the SSID to driver by using this rtw_p2p_profilefound function. */ + if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { + if (extra[0] == '0') { + /* Remove all the profile information of wifidirect_info structure. */ + _rtw_memset(&pwdinfo->profileinfo[0], 0x00, sizeof(struct profile_info) * P2P_MAX_PERSISTENT_GROUP_NUM); + pwdinfo->profileindex = 0; + } else { + if (pwdinfo->profileindex >= P2P_MAX_PERSISTENT_GROUP_NUM) { + ret = -1; + } else { + int jj, kk; + + /* Add this profile information into pwdinfo->profileinfo */ + /* Ex: 1XX:XX:XX:XX:XX:XXYYSSID */ + for (jj = 0, kk = 1; jj < ETH_ALEN; jj++, kk += 3) + pwdinfo->profileinfo[pwdinfo->profileindex].peermac[jj] = key_2char2num(extra[kk], extra[kk + 1]); + + pwdinfo->profileinfo[pwdinfo->profileindex].ssidlen = (extra[18] - '0') * 10 + (extra[19] - '0'); + memcpy(pwdinfo->profileinfo[pwdinfo->profileindex].ssid, &extra[20], pwdinfo->profileinfo[pwdinfo->profileindex].ssidlen); + pwdinfo->profileindex++; + } + } + } + + return ret; +} + +static int rtw_p2p_setDN(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + + DBG_88E("[%s] %s %d\n", __func__, extra, wrqu->data.length - 1); + _rtw_memset(pwdinfo->device_name, 0x00, WPS_MAX_DEVICE_NAME_LEN); + memcpy(pwdinfo->device_name, extra, wrqu->data.length - 1); + pwdinfo->device_name_len = wrqu->data.length - 1; + + return ret; +} + +static int rtw_p2p_get_status(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + + if (padapter->bShowGetP2PState) + DBG_88E("[%s] Role = %d, Status = %d, peer addr = %.2X:%.2X:%.2X:%.2X:%.2X:%.2X\n", __func__, rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo), + pwdinfo->p2p_peer_interface_addr[0], pwdinfo->p2p_peer_interface_addr[1], pwdinfo->p2p_peer_interface_addr[2], + pwdinfo->p2p_peer_interface_addr[3], pwdinfo->p2p_peer_interface_addr[4], pwdinfo->p2p_peer_interface_addr[5]); + + /* Commented by Albert 2010/10/12 */ + /* Because of the output size limitation, I had removed the "Role" information. */ + /* About the "Role" information, we will use the new private IOCTL to get the "Role" information. */ + sprintf(extra, "\n\nStatus =%.2d\n", rtw_p2p_state(pwdinfo)); + wrqu->data.length = strlen(extra); + + return ret; +} + +/* Commented by Albert 20110520 */ +/* This function will return the config method description */ +/* This config method description will show us which config method the remote P2P device is intented to use */ +/* by sending the provisioning discovery request frame. */ + +static int rtw_p2p_get_req_cm(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + + sprintf(extra, "\n\nCM =%s\n", pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req); + wrqu->data.length = strlen(extra); + return ret; +} + +static int rtw_p2p_get_role(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + + DBG_88E("[%s] Role = %d, Status = %d, peer addr = %.2X:%.2X:%.2X:%.2X:%.2X:%.2X\n", __func__, rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo), + pwdinfo->p2p_peer_interface_addr[0], pwdinfo->p2p_peer_interface_addr[1], pwdinfo->p2p_peer_interface_addr[2], + pwdinfo->p2p_peer_interface_addr[3], pwdinfo->p2p_peer_interface_addr[4], pwdinfo->p2p_peer_interface_addr[5]); + + sprintf(extra, "\n\nRole =%.2d\n", rtw_p2p_role(pwdinfo)); + wrqu->data.length = strlen(extra); + return ret; +} + +static int rtw_p2p_get_peer_ifaddr(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + + DBG_88E("[%s] Role = %d, Status = %d, peer addr = %pM\n", __func__, + rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo), + pwdinfo->p2p_peer_interface_addr); + sprintf(extra, "\nMAC %pM", + pwdinfo->p2p_peer_interface_addr); + wrqu->data.length = strlen(extra); + return ret; +} + +static int rtw_p2p_get_peer_devaddr(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) + +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + + DBG_88E("[%s] Role = %d, Status = %d, peer addr = %pM\n", __func__, + rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo), + pwdinfo->rx_prov_disc_info.peerDevAddr); + sprintf(extra, "\n%pM", + pwdinfo->rx_prov_disc_info.peerDevAddr); + wrqu->data.length = strlen(extra); + return ret; +} + +static int rtw_p2p_get_peer_devaddr_by_invitation(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) + +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + + DBG_88E("[%s] Role = %d, Status = %d, peer addr = %pM\n", + __func__, rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo), + pwdinfo->p2p_peer_device_addr); + sprintf(extra, "\nMAC %pM", + pwdinfo->p2p_peer_device_addr); + wrqu->data.length = strlen(extra); + return ret; +} + +static int rtw_p2p_get_groupid(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) + +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + + sprintf(extra, "\n%.2X:%.2X:%.2X:%.2X:%.2X:%.2X %s", + pwdinfo->groupid_info.go_device_addr[0], pwdinfo->groupid_info.go_device_addr[1], + pwdinfo->groupid_info.go_device_addr[2], pwdinfo->groupid_info.go_device_addr[3], + pwdinfo->groupid_info.go_device_addr[4], pwdinfo->groupid_info.go_device_addr[5], + pwdinfo->groupid_info.ssid); + wrqu->data.length = strlen(extra); + return ret; +} + +static int rtw_p2p_get_op_ch(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) + +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + + DBG_88E("[%s] Op_ch = %02x\n", __func__, pwdinfo->operating_channel); + + sprintf(extra, "\n\nOp_ch =%.2d\n", pwdinfo->operating_channel); + wrqu->data.length = strlen(extra); + return ret; +} + +static int rtw_p2p_get_wps_configmethod(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + u8 peerMAC[ETH_ALEN] = {0x00}; + int jj, kk; + u8 peerMACStr[17] = {0x00}; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + unsigned long irqL; + struct list_head *plist, *phead; + struct __queue *queue = &(pmlmepriv->scanned_queue); + struct wlan_network *pnetwork = NULL; + u8 blnMatch = 0; + u16 attr_content = 0; + uint attr_contentlen = 0; + /* 6 is the string "wpsCM =", 17 is the MAC addr, we have to clear it at wrqu->data.pointer */ + u8 attr_content_str[6 + 17] = {0x00}; + + /* Commented by Albert 20110727 */ + /* The input data is the MAC address which the application wants to know its WPS config method. */ + /* After knowing its WPS config method, the application can decide the config method for provisioning discovery. */ + /* Format: iwpriv wlanx p2p_get_wpsCM 00:E0:4C:00:00:05 */ + + DBG_88E("[%s] data = %s\n", __func__, (char *)extra); + if (copy_from_user(peerMACStr, wrqu->data.pointer + 6, 17)) + return -EFAULT; + + for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) + peerMAC[jj] = key_2char2num(peerMACStr[kk], peerMACStr[kk + 1]); + + _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); + + phead = get_list_head(queue); + plist = get_next(phead); + + while (1) { + if (rtw_end_of_queue_search(phead, plist) == true) + break; + + pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); + if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) { + u8 *wpsie; + uint wpsie_len = 0; + __be16 be_tmp; + + /* The mac address is matched. */ + wpsie = rtw_get_wps_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &wpsie_len); + if (wpsie) { + rtw_get_wps_attr_content(wpsie, wpsie_len, WPS_ATTR_CONF_METHOD, (u8 *) &be_tmp, &attr_contentlen); + if (attr_contentlen) { + attr_content = be16_to_cpu(be_tmp); + sprintf(attr_content_str, "\n\nM =%.4d", attr_content); + blnMatch = 1; + } + } + break; + } + plist = get_next(plist); + } + + _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); + + if (!blnMatch) + sprintf(attr_content_str, "\n\nM = 0000"); + + if (copy_to_user(wrqu->data.pointer, attr_content_str, 6 + 17)) + return -EFAULT; + return ret; +} + +static int rtw_p2p_get_go_device_address(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + u8 peerMAC[ETH_ALEN] = {0x00}; + int jj, kk; + u8 peerMACStr[17] = {0x00}; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + unsigned long irqL; + struct list_head *plist, *phead; + struct __queue *queue = &(pmlmepriv->scanned_queue); + struct wlan_network *pnetwork = NULL; + u8 blnMatch = 0; + u8 *p2pie; + uint p2pielen = 0, attr_contentlen = 0; + u8 attr_content[100] = {0x00}; + + u8 go_devadd_str[17 + 10] = {0x00}; + /* +10 is for the str "go_devadd =", we have to clear it at wrqu->data.pointer */ + + /* Commented by Albert 20121209 */ + /* The input data is the GO's interface address which the application wants to know its device address. */ + /* Format: iwpriv wlanx p2p_get2 go_devadd = 00:E0:4C:00:00:05 */ + + DBG_88E("[%s] data = %s\n", __func__, (char *)extra); + if (copy_from_user(peerMACStr, wrqu->data.pointer + 10, 17)) + return -EFAULT; + + for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) + peerMAC[jj] = key_2char2num(peerMACStr[kk], peerMACStr[kk + 1]); + + _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); + + phead = get_list_head(queue); + plist = get_next(phead); + + while (1) { + if (rtw_end_of_queue_search(phead, plist) == true) + break; + + pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); + if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) { + /* Commented by Albert 2011/05/18 */ + /* Match the device address located in the P2P IE */ + /* This is for the case that the P2P device address is not the same as the P2P interface address. */ + + p2pie = rtw_get_p2p_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &p2pielen); + if (p2pie) { + while (p2pie) { + /* The P2P Device ID attribute is included in the Beacon frame. */ + /* The P2P Device Info attribute is included in the probe response frame. */ + + _rtw_memset(attr_content, 0x00, 100); + if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_DEVICE_ID, attr_content, &attr_contentlen)) { + /* Handle the P2P Device ID attribute of Beacon first */ + blnMatch = 1; + break; + } else if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_DEVICE_INFO, attr_content, &attr_contentlen)) { + /* Handle the P2P Device Info attribute of probe response */ + blnMatch = 1; + break; + } + + /* Get the next P2P IE */ + p2pie = rtw_get_p2p_ie(p2pie+p2pielen, pnetwork->network.IELength - 12 - (p2pie - &pnetwork->network.IEs[12] + p2pielen), NULL, &p2pielen); + } + } + } + + plist = get_next(plist); + } + + _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); + + if (!blnMatch) + sprintf(go_devadd_str, "\n\ndev_add = NULL"); + else + sprintf(go_devadd_str, "\n\ndev_add =%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", + attr_content[0], attr_content[1], attr_content[2], attr_content[3], attr_content[4], attr_content[5]); + + if (copy_to_user(wrqu->data.pointer, go_devadd_str, 10 + 17)) + return -EFAULT; + return ret; +} + +static int rtw_p2p_get_device_type(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + u8 peerMAC[ETH_ALEN] = {0x00}; + int jj, kk; + u8 peerMACStr[17] = {0x00}; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + unsigned long irqL; + struct list_head *plist, *phead; + struct __queue *queue = &(pmlmepriv->scanned_queue); + struct wlan_network *pnetwork = NULL; + u8 blnMatch = 0; + u8 dev_type[8] = {0x00}; + uint dev_type_len = 0; + u8 dev_type_str[17 + 9] = {0x00}; /* +9 is for the str "dev_type =", we have to clear it at wrqu->data.pointer */ + + /* Commented by Albert 20121209 */ + /* The input data is the MAC address which the application wants to know its device type. */ + /* Such user interface could know the device type. */ + /* Format: iwpriv wlanx p2p_get2 dev_type = 00:E0:4C:00:00:05 */ + + DBG_88E("[%s] data = %s\n", __func__, (char *)extra); + if (copy_from_user(peerMACStr, wrqu->data.pointer + 9, 17)) + return -EFAULT; + + for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) + peerMAC[jj] = key_2char2num(peerMACStr[kk], peerMACStr[kk + 1]); + + _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); + + phead = get_list_head(queue); + plist = get_next(phead); + + while (1) { + if (rtw_end_of_queue_search(phead, plist) == true) + break; + + pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); + if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) { + u8 *wpsie; + uint wpsie_len = 0; + + /* The mac address is matched. */ + + wpsie = rtw_get_wps_ie(&pnetwork->network.IEs[12], + pnetwork->network.IELength - 12, + NULL, &wpsie_len); + if (wpsie) { + rtw_get_wps_attr_content(wpsie, wpsie_len, WPS_ATTR_PRIMARY_DEV_TYPE, dev_type, &dev_type_len); + if (dev_type_len) { + u16 type = 0; + __be16 be_tmp; + + memcpy(&be_tmp, dev_type, 2); + type = be16_to_cpu(be_tmp); + sprintf(dev_type_str, "\n\nN =%.2d", type); + blnMatch = 1; + } + } + break; + } + + plist = get_next(plist); + } + + _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); + + if (!blnMatch) + sprintf(dev_type_str, "\n\nN = 00"); + + if (copy_to_user(wrqu->data.pointer, dev_type_str, 9 + 17)) { + return -EFAULT; + } + + return ret; +} + +static int rtw_p2p_get_device_name(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + u8 peerMAC[ETH_ALEN] = {0x00}; + int jj, kk; + u8 peerMACStr[17] = {0x00}; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + unsigned long irqL; + struct list_head *plist, *phead; + struct __queue *queue = &(pmlmepriv->scanned_queue); + struct wlan_network *pnetwork = NULL; + u8 blnMatch = 0; + u8 dev_name[WPS_MAX_DEVICE_NAME_LEN] = {0x00}; + uint dev_len = 0; + u8 dev_name_str[WPS_MAX_DEVICE_NAME_LEN + 5] = {0x00}; /* +5 is for the str "devN =", we have to clear it at wrqu->data.pointer */ + + /* Commented by Albert 20121225 */ + /* The input data is the MAC address which the application wants to know its device name. */ + /* Such user interface could show peer device's device name instead of ssid. */ + /* Format: iwpriv wlanx p2p_get2 devN = 00:E0:4C:00:00:05 */ + + DBG_88E("[%s] data = %s\n", __func__, (char *)extra); + if (copy_from_user(peerMACStr, wrqu->data.pointer + 5, 17)) + return -EFAULT; + + for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) + peerMAC[jj] = key_2char2num(peerMACStr[kk], peerMACStr[kk + 1]); + + _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); + + phead = get_list_head(queue); + plist = get_next(phead); + + while (1) { + if (rtw_end_of_queue_search(phead, plist) == true) + break; + + pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); + if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) { + u8 *wpsie; + uint wpsie_len = 0; + + /* The mac address is matched. */ + wpsie = rtw_get_wps_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &wpsie_len); + if (wpsie) { + rtw_get_wps_attr_content(wpsie, wpsie_len, WPS_ATTR_DEVICE_NAME, dev_name, &dev_len); + if (dev_len) { + sprintf(dev_name_str, "\n\nN =%s", dev_name); + blnMatch = 1; + } + } + break; + } + + plist = get_next(plist); + } + + _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); + + if (!blnMatch) + sprintf(dev_name_str, "\n\nN = 0000"); + + if (copy_to_user(wrqu->data.pointer, dev_name_str, 5 + ((dev_len > 17) ? dev_len : 17))) + return -EFAULT; + return ret; +} + +static int rtw_p2p_get_invitation_procedure(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + u8 peerMAC[ETH_ALEN] = {0x00}; + int jj, kk; + u8 peerMACStr[17] = {0x00}; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + unsigned long irqL; + struct list_head *plist, *phead; + struct __queue *queue = &(pmlmepriv->scanned_queue); + struct wlan_network *pnetwork = NULL; + u8 blnMatch = 0; + u8 *p2pie; + uint p2pielen = 0, attr_contentlen = 0; + u8 attr_content[2] = {0x00}; + + u8 inv_proc_str[17 + 8] = {0x00}; + /* +8 is for the str "InvProc =", we have to clear it at wrqu->data.pointer */ + + /* Commented by Ouden 20121226 */ + /* The application wants to know P2P initation procedure is support or not. */ + /* Format: iwpriv wlanx p2p_get2 InvProc = 00:E0:4C:00:00:05 */ + + DBG_88E("[%s] data = %s\n", __func__, (char *)extra); + if (copy_from_user(peerMACStr, wrqu->data.pointer + 8, 17)) + return -EFAULT; + + for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) + peerMAC[jj] = key_2char2num(peerMACStr[kk], peerMACStr[kk + 1]); + + _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); + + phead = get_list_head(queue); + plist = get_next(phead); + + while (1) { + if (rtw_end_of_queue_search(phead, plist) == true) + break; + + pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); + if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) { + /* Commented by Albert 20121226 */ + /* Match the device address located in the P2P IE */ + /* This is for the case that the P2P device address is not the same as the P2P interface address. */ + + p2pie = rtw_get_p2p_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &p2pielen); + if (p2pie) { + while (p2pie) { + if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_CAPABILITY, attr_content, &attr_contentlen)) { + /* Handle the P2P capability attribute */ + blnMatch = 1; + break; + } + + /* Get the next P2P IE */ + p2pie = rtw_get_p2p_ie(p2pie+p2pielen, pnetwork->network.IELength - 12 - (p2pie - &pnetwork->network.IEs[12] + p2pielen), NULL, &p2pielen); + } + } + } + plist = get_next(plist); + } + + _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); + + if (!blnMatch) { + sprintf(inv_proc_str, "\nIP =-1"); + } else { + if (attr_content[0] & 0x20) + sprintf(inv_proc_str, "\nIP = 1"); + else + sprintf(inv_proc_str, "\nIP = 0"); + } + if (copy_to_user(wrqu->data.pointer, inv_proc_str, 8 + 17)) + return -EFAULT; + return ret; +} + +static int rtw_p2p_connect(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + u8 peerMAC[ETH_ALEN] = {0x00}; + int jj, kk; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + unsigned long irqL; + struct list_head *plist, *phead; + struct __queue *queue = &(pmlmepriv->scanned_queue); + struct wlan_network *pnetwork = NULL; + uint uintPeerChannel = 0; + + /* Commented by Albert 20110304 */ + /* The input data contains two informations. */ + /* 1. First information is the MAC address which wants to formate with */ + /* 2. Second information is the WPS PINCode or "pbc" string for push button method */ + /* Format: 00:E0:4C:00:00:05 */ + /* Format: 00:E0:4C:00:00:05 */ + + DBG_88E("[%s] data = %s\n", __func__, extra); + + if (pwdinfo->p2p_state == P2P_STATE_NONE) { + DBG_88E("[%s] WiFi Direct is disable!\n", __func__); + return ret; + } + + if (pwdinfo->ui_got_wps_info == P2P_NO_WPSINFO) + return -1; + + for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) + peerMAC[jj] = key_2char2num(extra[kk], extra[kk + 1]); + + _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); + + phead = get_list_head(queue); + plist = get_next(phead); + + while (1) { + if (rtw_end_of_queue_search(phead, plist) == true) + break; + + pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); + if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) { + uintPeerChannel = pnetwork->network.Configuration.DSConfig; + break; + } + + plist = get_next(plist); + } + + _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); + + if (uintPeerChannel) { + _rtw_memset(&pwdinfo->nego_req_info, 0x00, sizeof(struct tx_nego_req_info)); + _rtw_memset(&pwdinfo->groupid_info, 0x00, sizeof(struct group_id_info)); + + pwdinfo->nego_req_info.peer_channel_num[0] = uintPeerChannel; + memcpy(pwdinfo->nego_req_info.peerDevAddr, pnetwork->network.MacAddress, ETH_ALEN); + pwdinfo->nego_req_info.benable = true; + + _cancel_timer_ex(&pwdinfo->restore_p2p_state_timer); + if (rtw_p2p_state(pwdinfo) != P2P_STATE_GONEGO_OK) { + /* Restore to the listen state if the current p2p state is not nego OK */ + rtw_p2p_set_state(pwdinfo, P2P_STATE_LISTEN); + } + + rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo)); + rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_ING); + + DBG_88E("[%s] Start PreTx Procedure!\n", __func__); + _set_timer(&pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT); + _set_timer(&pwdinfo->restore_p2p_state_timer, P2P_GO_NEGO_TIMEOUT); + } else { + DBG_88E("[%s] Not Found in Scanning Queue~\n", __func__); + ret = -1; + } + return ret; +} + +static int rtw_p2p_invite_req(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + int jj, kk; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct list_head *plist, *phead; + struct __queue *queue = &(pmlmepriv->scanned_queue); + struct wlan_network *pnetwork = NULL; + uint uintPeerChannel = 0; + u8 attr_content[50] = {0x00}; + u8 *p2pie; + uint p2pielen = 0, attr_contentlen = 0; + unsigned long irqL; + struct tx_invite_req_info *pinvite_req_info = &pwdinfo->invitereq_info; + + /* The input data contains two informations. */ + /* 1. First information is the P2P device address which you want to send to. */ + /* 2. Second information is the group id which combines with GO's mac address, space and GO's ssid. */ + /* Command line sample: iwpriv wlan0 p2p_set invite ="00:11:22:33:44:55 00:E0:4C:00:00:05 DIRECT-xy" */ + /* Format: 00:11:22:33:44:55 00:E0:4C:00:00:05 DIRECT-xy */ + + DBG_88E("[%s] data = %s\n", __func__, extra); + + if (wrqu->data.length <= 37) { + DBG_88E("[%s] Wrong format!\n", __func__); + return ret; + } + + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { + DBG_88E("[%s] WiFi Direct is disable!\n", __func__); + return ret; + } else { + /* Reset the content of struct tx_invite_req_info */ + pinvite_req_info->benable = false; + _rtw_memset(pinvite_req_info->go_bssid, 0x00, ETH_ALEN); + _rtw_memset(pinvite_req_info->go_ssid, 0x00, WLAN_SSID_MAXLEN); + pinvite_req_info->ssidlen = 0x00; + pinvite_req_info->operating_ch = pwdinfo->operating_channel; + _rtw_memset(pinvite_req_info->peer_macaddr, 0x00, ETH_ALEN); + pinvite_req_info->token = 3; + } + + for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) + pinvite_req_info->peer_macaddr[jj] = key_2char2num(extra[kk], extra[kk + 1]); + + _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); + + phead = get_list_head(queue); + plist = get_next(phead); + + while (1) { + if (rtw_end_of_queue_search(phead, plist) == true) + break; + + pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); + + /* Commented by Albert 2011/05/18 */ + /* Match the device address located in the P2P IE */ + /* This is for the case that the P2P device address is not the same as the P2P interface address. */ + + p2pie = rtw_get_p2p_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &p2pielen); + if (p2pie) { + /* The P2P Device ID attribute is included in the Beacon frame. */ + /* The P2P Device Info attribute is included in the probe response frame. */ + + if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_DEVICE_ID, attr_content, &attr_contentlen)) { + /* Handle the P2P Device ID attribute of Beacon first */ + if (!memcmp(attr_content, pinvite_req_info->peer_macaddr, ETH_ALEN)) { + uintPeerChannel = pnetwork->network.Configuration.DSConfig; + break; + } + } else if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_DEVICE_INFO, attr_content, &attr_contentlen)) { + /* Handle the P2P Device Info attribute of probe response */ + if (!memcmp(attr_content, pinvite_req_info->peer_macaddr, ETH_ALEN)) { + uintPeerChannel = pnetwork->network.Configuration.DSConfig; + break; + } + } + } + plist = get_next(plist); + } + + _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); + + if (uintPeerChannel) { + /* Store the GO's bssid */ + for (jj = 0, kk = 18; jj < ETH_ALEN; jj++, kk += 3) + pinvite_req_info->go_bssid[jj] = key_2char2num(extra[kk], extra[kk + 1]); + + /* Store the GO's ssid */ + pinvite_req_info->ssidlen = wrqu->data.length - 36; + memcpy(pinvite_req_info->go_ssid, &extra[36], (u32) pinvite_req_info->ssidlen); + pinvite_req_info->benable = true; + pinvite_req_info->peer_ch = uintPeerChannel; + + rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo)); + rtw_p2p_set_state(pwdinfo, P2P_STATE_TX_INVITE_REQ); + + set_channel_bwmode(padapter, uintPeerChannel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); + + _set_timer(&pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT); + + _set_timer(&pwdinfo->restore_p2p_state_timer, P2P_INVITE_TIMEOUT); + } else { + DBG_88E("[%s] NOT Found in the Scanning Queue!\n", __func__); + } + return ret; +} + +static int rtw_p2p_set_persistent(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + + /* The input data is 0 or 1 */ + /* 0: disable persistent group functionality */ + /* 1: enable persistent group founctionality */ + + DBG_88E("[%s] data = %s\n", __func__, extra); + + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { + DBG_88E("[%s] WiFi Direct is disable!\n", __func__); + return ret; + } else { + if (extra[0] == '0') /* Disable the persistent group function. */ + pwdinfo->persistent_supported = false; + else if (extra[0] == '1') /* Enable the persistent group function. */ + pwdinfo->persistent_supported = true; + else + pwdinfo->persistent_supported = false; + } + pr_info("[%s] persistent_supported = %d\n", __func__, pwdinfo->persistent_supported); + return ret; +} + +static int rtw_p2p_prov_disc(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + u8 peerMAC[ETH_ALEN] = {0x00}; + int jj, kk; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct list_head *plist, *phead; + struct __queue *queue = &(pmlmepriv->scanned_queue); + struct wlan_network *pnetwork = NULL; + uint uintPeerChannel = 0; + u8 attr_content[100] = {0x00}; + u8 *p2pie; + uint p2pielen = 0, attr_contentlen = 0; + unsigned long irqL; + + /* The input data contains two informations. */ + /* 1. First information is the MAC address which wants to issue the provisioning discovery request frame. */ + /* 2. Second information is the WPS configuration method which wants to discovery */ + /* Format: 00:E0:4C:00:00:05_display */ + /* Format: 00:E0:4C:00:00:05_keypad */ + /* Format: 00:E0:4C:00:00:05_pbc */ + /* Format: 00:E0:4C:00:00:05_label */ + + DBG_88E("[%s] data = %s\n", __func__, extra); + + if (pwdinfo->p2p_state == P2P_STATE_NONE) { + DBG_88E("[%s] WiFi Direct is disable!\n", __func__); + return ret; + } else { + /* Reset the content of struct tx_provdisc_req_info excluded the wps_config_method_request. */ + _rtw_memset(pwdinfo->tx_prov_disc_info.peerDevAddr, 0x00, ETH_ALEN); + _rtw_memset(pwdinfo->tx_prov_disc_info.peerIFAddr, 0x00, ETH_ALEN); + _rtw_memset(&pwdinfo->tx_prov_disc_info.ssid, 0x00, sizeof(struct ndis_802_11_ssid)); + pwdinfo->tx_prov_disc_info.peer_channel_num[0] = 0; + pwdinfo->tx_prov_disc_info.peer_channel_num[1] = 0; + pwdinfo->tx_prov_disc_info.benable = false; + } + + for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) + peerMAC[jj] = key_2char2num(extra[kk], extra[kk + 1]); + + if (!memcmp(&extra[18], "display", 7)) { + pwdinfo->tx_prov_disc_info.wps_config_method_request = WPS_CM_DISPLYA; + } else if (!memcmp(&extra[18], "keypad", 7)) { + pwdinfo->tx_prov_disc_info.wps_config_method_request = WPS_CM_KEYPAD; + } else if (!memcmp(&extra[18], "pbc", 3)) { + pwdinfo->tx_prov_disc_info.wps_config_method_request = WPS_CM_PUSH_BUTTON; + } else if (!memcmp(&extra[18], "label", 5)) { + pwdinfo->tx_prov_disc_info.wps_config_method_request = WPS_CM_LABEL; + } else { + DBG_88E("[%s] Unknown WPS config methodn", __func__); + return ret; + } + + _enter_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); + + phead = get_list_head(queue); + plist = get_next(phead); + + while (1) { + if (rtw_end_of_queue_search(phead, plist) == true) + break; + + if (uintPeerChannel != 0) + break; + + pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); + + /* Commented by Albert 2011/05/18 */ + /* Match the device address located in the P2P IE */ + /* This is for the case that the P2P device address is not the same as the P2P interface address. */ + + p2pie = rtw_get_p2p_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &p2pielen); + if (p2pie) { + while (p2pie) { + /* The P2P Device ID attribute is included in the Beacon frame. */ + /* The P2P Device Info attribute is included in the probe response frame. */ + + if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_DEVICE_ID, attr_content, &attr_contentlen)) { + /* Handle the P2P Device ID attribute of Beacon first */ + if (!memcmp(attr_content, peerMAC, ETH_ALEN)) { + uintPeerChannel = pnetwork->network.Configuration.DSConfig; + break; + } + } else if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_DEVICE_INFO, attr_content, &attr_contentlen)) { + /* Handle the P2P Device Info attribute of probe response */ + if (!memcmp(attr_content, peerMAC, ETH_ALEN)) { + uintPeerChannel = pnetwork->network.Configuration.DSConfig; + break; + } + } + + /* Get the next P2P IE */ + p2pie = rtw_get_p2p_ie(p2pie+p2pielen, pnetwork->network.IELength - 12 - (p2pie - &pnetwork->network.IEs[12] + p2pielen), NULL, &p2pielen); + } + } + + plist = get_next(plist); + } + + _exit_critical_bh(&(pmlmepriv->scanned_queue.lock), &irqL); + + if (uintPeerChannel) { + DBG_88E("[%s] peer channel: %d!\n", __func__, uintPeerChannel); + memcpy(pwdinfo->tx_prov_disc_info.peerIFAddr, pnetwork->network.MacAddress, ETH_ALEN); + memcpy(pwdinfo->tx_prov_disc_info.peerDevAddr, peerMAC, ETH_ALEN); + pwdinfo->tx_prov_disc_info.peer_channel_num[0] = (u16) uintPeerChannel; + pwdinfo->tx_prov_disc_info.benable = true; + rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo)); + rtw_p2p_set_state(pwdinfo, P2P_STATE_TX_PROVISION_DIS_REQ); + + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_CLIENT)) { + memcpy(&pwdinfo->tx_prov_disc_info.ssid, &pnetwork->network.Ssid, sizeof(struct ndis_802_11_ssid)); + } else if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE) || rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { + memcpy(pwdinfo->tx_prov_disc_info.ssid.Ssid, pwdinfo->p2p_wildcard_ssid, P2P_WILDCARD_SSID_LEN); + pwdinfo->tx_prov_disc_info.ssid.SsidLength = P2P_WILDCARD_SSID_LEN; + } + + set_channel_bwmode(padapter, uintPeerChannel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); + + _set_timer(&pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT); + + _set_timer(&pwdinfo->restore_p2p_state_timer, P2P_PROVISION_TIMEOUT); + } else { + DBG_88E("[%s] NOT Found in the Scanning Queue!\n", __func__); + } + return ret; +} + +/* This function is used to inform the driver the user had specified the pin code value or pbc */ +/* to application. */ + +static int rtw_p2p_got_wpsinfo(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + + DBG_88E("[%s] data = %s\n", __func__, extra); + /* Added by Albert 20110328 */ + /* if the input data is P2P_NO_WPSINFO -> reset the wpsinfo */ + /* if the input data is P2P_GOT_WPSINFO_PEER_DISPLAY_PIN -> the utility just input the PIN code got from the peer P2P device. */ + /* if the input data is P2P_GOT_WPSINFO_SELF_DISPLAY_PIN -> the utility just got the PIN code from itself. */ + /* if the input data is P2P_GOT_WPSINFO_PBC -> the utility just determine to use the PBC */ + + if (*extra == '0') + pwdinfo->ui_got_wps_info = P2P_NO_WPSINFO; + else if (*extra == '1') + pwdinfo->ui_got_wps_info = P2P_GOT_WPSINFO_PEER_DISPLAY_PIN; + else if (*extra == '2') + pwdinfo->ui_got_wps_info = P2P_GOT_WPSINFO_SELF_DISPLAY_PIN; + else if (*extra == '3') + pwdinfo->ui_got_wps_info = P2P_GOT_WPSINFO_PBC; + else + pwdinfo->ui_got_wps_info = P2P_NO_WPSINFO; + return ret; +} + +#endif /* CONFIG_88EU_P2P */ + +static int rtw_p2p_set(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + +#ifdef CONFIG_88EU_P2P + DBG_88E("[%s] extra = %s\n", __func__, extra); + if (!memcmp(extra, "enable =", 7)) { + rtw_wext_p2p_enable(dev, info, wrqu, &extra[7]); + } else if (!memcmp(extra, "setDN =", 6)) { + wrqu->data.length -= 6; + rtw_p2p_setDN(dev, info, wrqu, &extra[6]); + } else if (!memcmp(extra, "profilefound =", 13)) { + wrqu->data.length -= 13; + rtw_p2p_profilefound(dev, info, wrqu, &extra[13]); + } else if (!memcmp(extra, "prov_disc =", 10)) { + wrqu->data.length -= 10; + rtw_p2p_prov_disc(dev, info, wrqu, &extra[10]); + } else if (!memcmp(extra, "nego =", 5)) { + wrqu->data.length -= 5; + rtw_p2p_connect(dev, info, wrqu, &extra[5]); + } else if (!memcmp(extra, "intent =", 7)) { + /* Commented by Albert 2011/03/23 */ + /* The wrqu->data.length will include the null character */ + /* So, we will decrease 7 + 1 */ + wrqu->data.length -= 8; + rtw_p2p_set_intent(dev, info, wrqu, &extra[7]); + } else if (!memcmp(extra, "ssid =", 5)) { + wrqu->data.length -= 5; + rtw_p2p_set_go_nego_ssid(dev, info, wrqu, &extra[5]); + } else if (!memcmp(extra, "got_wpsinfo =", 12)) { + wrqu->data.length -= 12; + rtw_p2p_got_wpsinfo(dev, info, wrqu, &extra[12]); + } else if (!memcmp(extra, "listen_ch =", 10)) { + /* Commented by Albert 2011/05/24 */ + /* The wrqu->data.length will include the null character */ + /* So, we will decrease (10 + 1) */ + wrqu->data.length -= 11; + rtw_p2p_set_listen_ch(dev, info, wrqu, &extra[10]); + } else if (!memcmp(extra, "op_ch =", 6)) { + /* Commented by Albert 2011/05/24 */ + /* The wrqu->data.length will include the null character */ + /* So, we will decrease (6 + 1) */ + wrqu->data.length -= 7; + rtw_p2p_set_op_ch(dev, info, wrqu, &extra[6]); + } else if (!memcmp(extra, "invite =", 7)) { + wrqu->data.length -= 8; + rtw_p2p_invite_req(dev, info, wrqu, &extra[7]); + } else if (!memcmp(extra, "persistent =", 11)) { + wrqu->data.length -= 11; + rtw_p2p_set_persistent(dev, info, wrqu, &extra[11]); + } +#endif /* CONFIG_88EU_P2P */ + + return ret; +} + +static int rtw_p2p_get(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + +#ifdef CONFIG_88EU_P2P + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + + if (padapter->bShowGetP2PState) + DBG_88E("[%s] extra = %s\n", __func__, (char *)wrqu->data.pointer); + if (!memcmp(wrqu->data.pointer, "status", 6)) { + rtw_p2p_get_status(dev, info, wrqu, extra); + } else if (!memcmp(wrqu->data.pointer, "role", 4)) { + rtw_p2p_get_role(dev, info, wrqu, extra); + } else if (!memcmp(wrqu->data.pointer, "peer_ifa", 8)) { + rtw_p2p_get_peer_ifaddr(dev, info, wrqu, extra); + } else if (!memcmp(wrqu->data.pointer, "req_cm", 6)) { + rtw_p2p_get_req_cm(dev, info, wrqu, extra); + } else if (!memcmp(wrqu->data.pointer, "peer_deva", 9)) { + /* Get the P2P device address when receiving the provision discovery request frame. */ + rtw_p2p_get_peer_devaddr(dev, info, wrqu, extra); + } else if (!memcmp(wrqu->data.pointer, "group_id", 8)) { + rtw_p2p_get_groupid(dev, info, wrqu, extra); + } else if (!memcmp(wrqu->data.pointer, "peer_deva_inv", 9)) { + /* Get the P2P device address when receiving the P2P Invitation request frame. */ + rtw_p2p_get_peer_devaddr_by_invitation(dev, info, wrqu, extra); + } else if (!memcmp(wrqu->data.pointer, "op_ch", 5)) { + rtw_p2p_get_op_ch(dev, info, wrqu, extra); + } +#endif /* CONFIG_88EU_P2P */ + return ret; +} + +static int rtw_p2p_get2(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + +#ifdef CONFIG_88EU_P2P + DBG_88E("[%s] extra = %s\n", __func__, (char *)wrqu->data.pointer); + if (!memcmp(extra, "wpsCM =", 6)) { + wrqu->data.length -= 6; + rtw_p2p_get_wps_configmethod(dev, info, wrqu, &extra[6]); + } else if (!memcmp(extra, "devN =", 5)) { + wrqu->data.length -= 5; + rtw_p2p_get_device_name(dev, info, wrqu, &extra[5]); + } else if (!memcmp(extra, "dev_type =", 9)) { + wrqu->data.length -= 9; + rtw_p2p_get_device_type(dev, info, wrqu, &extra[9]); + } else if (!memcmp(extra, "go_devadd =", 10)) { + wrqu->data.length -= 10; + rtw_p2p_get_go_device_address(dev, info, wrqu, &extra[10]); + } else if (!memcmp(extra, "InvProc =", 8)) { + wrqu->data.length -= 8; + rtw_p2p_get_invitation_procedure(dev, info, wrqu, &extra[8]); + } + +#endif /* CONFIG_88EU_P2P */ + + return ret; +} + +static int rtw_cta_test_start(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + DBG_88E("%s %s\n", __func__, extra); + if (!strcmp(extra, "1")) + padapter->in_cta_test = 1; + else + padapter->in_cta_test = 0; + + if (padapter->in_cta_test) { + u32 v = rtw_read32(padapter, REG_RCR); + v &= ~(RCR_CBSSID_DATA | RCR_CBSSID_BCN);/* RCR_ADF */ + rtw_write32(padapter, REG_RCR, v); + DBG_88E("enable RCR_ADF\n"); + } else { + u32 v = rtw_read32(padapter, REG_RCR); + v |= RCR_CBSSID_DATA | RCR_CBSSID_BCN;/* RCR_ADF */ + rtw_write32(padapter, REG_RCR, v); + DBG_88E("disable RCR_ADF\n"); + } + return ret; +} + +static int rtw_rereg_nd_name(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = rtw_netdev_priv(dev); + struct rereg_nd_name_data *rereg_priv = &padapter->rereg_nd_name_priv; + char new_ifname[IFNAMSIZ]; + + if (rereg_priv->old_ifname[0] == 0) { + char *reg_ifname; + reg_ifname = padapter->registrypriv.if2name; + + strncpy(rereg_priv->old_ifname, reg_ifname, IFNAMSIZ); + rereg_priv->old_ifname[IFNAMSIZ-1] = 0; + } + + if (wrqu->data.length > IFNAMSIZ) + return -EFAULT; + + if (copy_from_user(new_ifname, wrqu->data.pointer, IFNAMSIZ)) + return -EFAULT; + + if (0 == strcmp(rereg_priv->old_ifname, new_ifname)) + return ret; + + DBG_88E("%s new_ifname:%s\n", __func__, new_ifname); + ret = rtw_change_ifname(padapter, new_ifname); + if (0 != ret) + goto exit; + + if (!memcmp(rereg_priv->old_ifname, "disable%d", 9) == true) { + padapter->ledpriv.bRegUseLed = rereg_priv->old_bRegUseLed; + rtw_hal_sw_led_init(padapter); + rtw_ips_mode_req(&padapter->pwrctrlpriv, rereg_priv->old_ips_mode); + } + + strncpy(rereg_priv->old_ifname, new_ifname, IFNAMSIZ); + rereg_priv->old_ifname[IFNAMSIZ-1] = 0; + + if (!memcmp(new_ifname, "disable%d", 9) == true) { + DBG_88E("%s disable\n", __func__); + /* free network queue for Android's timming issue */ + rtw_free_network_queue(padapter, true); + + /* close led */ + rtw_led_control(padapter, LED_CTL_POWER_OFF); + rereg_priv->old_bRegUseLed = padapter->ledpriv.bRegUseLed; + padapter->ledpriv.bRegUseLed = false; + rtw_hal_sw_led_deinit(padapter); + + /* the interface is being "disabled", we can do deeper IPS */ + rereg_priv->old_ips_mode = rtw_get_ips_mode_req(&padapter->pwrctrlpriv); + rtw_ips_mode_req(&padapter->pwrctrlpriv, IPS_NORMAL); + } +exit: + return ret; +} + +static void mac_reg_dump(struct adapter *padapter) +{ + int i, j = 1; + pr_info("\n ======= MAC REG =======\n"); + for (i = 0x0; i < 0x300; i += 4) { + if (j%4 == 1) + pr_info("0x%02x", i); + pr_info(" 0x%08x ", rtw_read32(padapter, i)); + if ((j++)%4 == 0) + pr_info("\n"); + } + for (i = 0x400; i < 0x800; i += 4) { + if (j%4 == 1) + pr_info("0x%02x", i); + pr_info(" 0x%08x ", rtw_read32(padapter, i)); + if ((j++)%4 == 0) + pr_info("\n"); + } +} + +static void bb_reg_dump(struct adapter *padapter) +{ + int i, j = 1; + pr_info("\n ======= BB REG =======\n"); + for (i = 0x800; i < 0x1000; i += 4) { + if (j%4 == 1) + pr_info("0x%02x", i); + + pr_info(" 0x%08x ", rtw_read32(padapter, i)); + if ((j++)%4 == 0) + pr_info("\n"); + } +} + +static void rf_reg_dump(struct adapter *padapter) +{ + int i, j = 1, path; + u32 value; + u8 rf_type, path_nums = 0; + rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); + + pr_info("\n ======= RF REG =======\n"); + if ((RF_1T2R == rf_type) || (RF_1T1R == rf_type)) + path_nums = 1; + else + path_nums = 2; + + for (path = 0; path < path_nums; path++) { + pr_info("\nRF_Path(%x)\n", path); + for (i = 0; i < 0x100; i++) { + value = rtw_hal_read_rfreg(padapter, path, i, 0xffffffff); + if (j%4 == 1) + pr_info("0x%02x ", i); + pr_info(" 0x%08x ", value); + if ((j++)%4 == 0) + pr_info("\n"); + } + } +} + +static int rtw_dbg_port(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + unsigned long irqL; + int ret = 0; + u8 major_cmd, minor_cmd; + u16 arg; + s32 extra_arg; + u32 *pdata, val32; + struct sta_info *psta; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct security_priv *psecuritypriv = &padapter->securitypriv; + struct wlan_network *cur_network = &(pmlmepriv->cur_network); + struct sta_priv *pstapriv = &padapter->stapriv; + + pdata = (u32 *)&wrqu->data; + + val32 = *pdata; + arg = (u16)(val32 & 0x0000ffff); + major_cmd = (u8)(val32 >> 24); + minor_cmd = (u8)((val32 >> 16) & 0x00ff); + + extra_arg = *(pdata+1); + + switch (major_cmd) { + case 0x70:/* read_reg */ + switch (minor_cmd) { + case 1: + DBG_88E("rtw_read8(0x%x) = 0x%02x\n", arg, rtw_read8(padapter, arg)); + break; + case 2: + DBG_88E("rtw_read16(0x%x) = 0x%04x\n", arg, rtw_read16(padapter, arg)); + break; + case 4: + DBG_88E("rtw_read32(0x%x) = 0x%08x\n", arg, rtw_read32(padapter, arg)); + break; + } + break; + case 0x71:/* write_reg */ + switch (minor_cmd) { + case 1: + rtw_write8(padapter, arg, extra_arg); + DBG_88E("rtw_write8(0x%x) = 0x%02x\n", arg, rtw_read8(padapter, arg)); + break; + case 2: + rtw_write16(padapter, arg, extra_arg); + DBG_88E("rtw_write16(0x%x) = 0x%04x\n", arg, rtw_read16(padapter, arg)); + break; + case 4: + rtw_write32(padapter, arg, extra_arg); + DBG_88E("rtw_write32(0x%x) = 0x%08x\n", arg, rtw_read32(padapter, arg)); + break; + } + break; + case 0x72:/* read_bb */ + DBG_88E("read_bbreg(0x%x) = 0x%x\n", arg, rtw_hal_read_bbreg(padapter, arg, 0xffffffff)); + break; + case 0x73:/* write_bb */ + rtw_hal_write_bbreg(padapter, arg, 0xffffffff, extra_arg); + DBG_88E("write_bbreg(0x%x) = 0x%x\n", arg, rtw_hal_read_bbreg(padapter, arg, 0xffffffff)); + break; + case 0x74:/* read_rf */ + DBG_88E("read RF_reg path(0x%02x), offset(0x%x), value(0x%08x)\n", minor_cmd, arg, rtw_hal_read_rfreg(padapter, minor_cmd, arg, 0xffffffff)); + break; + case 0x75:/* write_rf */ + rtw_hal_write_rfreg(padapter, minor_cmd, arg, 0xffffffff, extra_arg); + DBG_88E("write RF_reg path(0x%02x), offset(0x%x), value(0x%08x)\n", minor_cmd, arg, rtw_hal_read_rfreg(padapter, minor_cmd, arg, 0xffffffff)); + break; + + case 0x76: + switch (minor_cmd) { + case 0x00: /* normal mode, */ + padapter->recvpriv.is_signal_dbg = 0; + break; + case 0x01: /* dbg mode */ + padapter->recvpriv.is_signal_dbg = 1; + extra_arg = extra_arg > 100 ? 100 : extra_arg; + extra_arg = extra_arg < 0 ? 0 : extra_arg; + padapter->recvpriv.signal_strength_dbg = extra_arg; + break; + } + break; + case 0x78: /* IOL test */ + switch (minor_cmd) { + case 0x04: /* LLT table initialization test */ + { + u8 page_boundary = 0xf9; + struct xmit_frame *xmit_frame; + + xmit_frame = rtw_IOL_accquire_xmit_frame(padapter); + if (xmit_frame == NULL) { + ret = -ENOMEM; + break; + } + + rtw_IOL_append_LLT_cmd(xmit_frame, page_boundary); + + if (_SUCCESS != rtw_IOL_exec_cmds_sync(padapter, xmit_frame, 500, 0)) + ret = -EPERM; + } + break; + case 0x05: /* blink LED test */ + { + u16 reg = 0x4c; + u32 blink_num = 50; + u32 blink_delay_ms = 200; + int i; + struct xmit_frame *xmit_frame; + + xmit_frame = rtw_IOL_accquire_xmit_frame(padapter); + if (xmit_frame == NULL) { + ret = -ENOMEM; + break; + } + + for (i = 0; i < blink_num; i++) { + rtw_IOL_append_WB_cmd(xmit_frame, reg, 0x00, 0xff); + rtw_IOL_append_DELAY_MS_cmd(xmit_frame, blink_delay_ms); + rtw_IOL_append_WB_cmd(xmit_frame, reg, 0x08, 0xff); + rtw_IOL_append_DELAY_MS_cmd(xmit_frame, blink_delay_ms); + } + if (_SUCCESS != rtw_IOL_exec_cmds_sync(padapter, xmit_frame, (blink_delay_ms*blink_num*2)+200, 0)) + ret = -EPERM; + } + break; + + case 0x06: /* continuous write byte test */ + { + u16 reg = arg; + u16 start_value = 0; + u32 write_num = extra_arg; + int i; + u8 final; + struct xmit_frame *xmit_frame; + + xmit_frame = rtw_IOL_accquire_xmit_frame(padapter); + if (xmit_frame == NULL) { + ret = -ENOMEM; + break; + } + + for (i = 0; i < write_num; i++) + rtw_IOL_append_WB_cmd(xmit_frame, reg, i+start_value, 0xFF); + if (_SUCCESS != rtw_IOL_exec_cmds_sync(padapter, xmit_frame, 5000, 0)) + ret = -EPERM; + + final = rtw_read8(padapter, reg); + if (start_value+write_num-1 == final) + DBG_88E("continuous IOL_CMD_WB_REG to 0x%x %u times Success, start:%u, final:%u\n", reg, write_num, start_value, final); + else + DBG_88E("continuous IOL_CMD_WB_REG to 0x%x %u times Fail, start:%u, final:%u\n", reg, write_num, start_value, final); + } + break; + + case 0x07: /* continuous write word test */ + { + u16 reg = arg; + u16 start_value = 200; + u32 write_num = extra_arg; + + int i; + u16 final; + struct xmit_frame *xmit_frame; + + xmit_frame = rtw_IOL_accquire_xmit_frame(padapter); + if (xmit_frame == NULL) { + ret = -ENOMEM; + break; + } + + for (i = 0; i < write_num; i++) + rtw_IOL_append_WW_cmd(xmit_frame, reg, i+start_value, 0xFFFF); + if (_SUCCESS != rtw_IOL_exec_cmds_sync(padapter, xmit_frame, 5000, 0)) + ret = -EPERM; + + final = rtw_read16(padapter, reg); + if (start_value+write_num-1 == final) + DBG_88E("continuous IOL_CMD_WW_REG to 0x%x %u times Success, start:%u, final:%u\n", reg, write_num, start_value, final); + else + DBG_88E("continuous IOL_CMD_WW_REG to 0x%x %u times Fail, start:%u, final:%u\n", reg, write_num, start_value, final); + } + break; + case 0x08: /* continuous write dword test */ + { + u16 reg = arg; + u32 start_value = 0x110000c7; + u32 write_num = extra_arg; + + int i; + u32 final; + struct xmit_frame *xmit_frame; + + xmit_frame = rtw_IOL_accquire_xmit_frame(padapter); + if (xmit_frame == NULL) { + ret = -ENOMEM; + break; + } + + for (i = 0; i < write_num; i++) + rtw_IOL_append_WD_cmd(xmit_frame, reg, i+start_value, 0xFFFFFFFF); + if (_SUCCESS != rtw_IOL_exec_cmds_sync(padapter, xmit_frame, 5000, 0)) + ret = -EPERM; + + final = rtw_read32(padapter, reg); + if (start_value+write_num-1 == final) + DBG_88E("continuous IOL_CMD_WD_REG to 0x%x %u times Success, start:%u, final:%u\n", + reg, write_num, start_value, final); + else + DBG_88E("continuous IOL_CMD_WD_REG to 0x%x %u times Fail, start:%u, final:%u\n", + reg, write_num, start_value, final); + } + break; + } + break; + case 0x79: + { + /* + * dbg 0x79000000 [value], set RESP_TXAGC to + value, value:0~15 + * dbg 0x79010000 [value], set RESP_TXAGC to - value, value:0~15 + */ + u8 value = extra_arg & 0x0f; + u8 sign = minor_cmd; + u16 write_value = 0; + + DBG_88E("%s set RESP_TXAGC to %s %u\n", __func__, sign ? "minus" : "plus", value); + + if (sign) + value = value | 0x10; + + write_value = value | (value << 5); + rtw_write16(padapter, 0x6d9, write_value); + } + break; + case 0x7a: + receive_disconnect(padapter, pmlmeinfo->network.MacAddress + , WLAN_REASON_EXPIRATION_CHK); + break; + case 0x7F: + switch (minor_cmd) { + case 0x0: + DBG_88E("fwstate = 0x%x\n", get_fwstate(pmlmepriv)); + break; + case 0x01: + DBG_88E("auth_alg = 0x%x, enc_alg = 0x%x, auth_type = 0x%x, enc_type = 0x%x\n", + psecuritypriv->dot11AuthAlgrthm, psecuritypriv->dot11PrivacyAlgrthm, + psecuritypriv->ndisauthtype, psecuritypriv->ndisencryptstatus); + break; + case 0x02: + DBG_88E("pmlmeinfo->state = 0x%x\n", pmlmeinfo->state); + break; + case 0x03: + DBG_88E("qos_option =%d\n", pmlmepriv->qospriv.qos_option); + DBG_88E("ht_option =%d\n", pmlmepriv->htpriv.ht_option); + break; + case 0x04: + DBG_88E("cur_ch =%d\n", pmlmeext->cur_channel); + DBG_88E("cur_bw =%d\n", pmlmeext->cur_bwmode); + DBG_88E("cur_ch_off =%d\n", pmlmeext->cur_ch_offset); + break; + case 0x05: + psta = rtw_get_stainfo(pstapriv, cur_network->network.MacAddress); + if (psta) { + int i; + struct recv_reorder_ctrl *preorder_ctrl; + + DBG_88E("SSID =%s\n", cur_network->network.Ssid.Ssid); + DBG_88E("sta's macaddr: %pM\n", psta->hwaddr); + DBG_88E("cur_channel =%d, cur_bwmode =%d, cur_ch_offset =%d\n", pmlmeext->cur_channel, pmlmeext->cur_bwmode, pmlmeext->cur_ch_offset); + DBG_88E("rtsen =%d, cts2slef =%d\n", psta->rtsen, psta->cts2self); + DBG_88E("state = 0x%x, aid =%d, macid =%d, raid =%d\n", psta->state, psta->aid, psta->mac_id, psta->raid); + DBG_88E("qos_en =%d, ht_en =%d, init_rate =%d\n", psta->qos_option, psta->htpriv.ht_option, psta->init_rate); + DBG_88E("bwmode =%d, ch_offset =%d, sgi =%d\n", psta->htpriv.bwmode, psta->htpriv.ch_offset, psta->htpriv.sgi); + DBG_88E("ampdu_enable = %d\n", psta->htpriv.ampdu_enable); + DBG_88E("agg_enable_bitmap =%x, candidate_tid_bitmap =%x\n", psta->htpriv.agg_enable_bitmap, psta->htpriv.candidate_tid_bitmap); + for (i = 0; i < 16; i++) { + preorder_ctrl = &psta->recvreorder_ctrl[i]; + if (preorder_ctrl->enable) + DBG_88E("tid =%d, indicate_seq =%d\n", i, preorder_ctrl->indicate_seq); + } + } else { + DBG_88E("can't get sta's macaddr, cur_network's macaddr:%pM\n", (cur_network->network.MacAddress)); + } + break; + case 0x06: + { + u32 ODMFlag; + rtw_hal_get_hwreg(padapter, HW_VAR_DM_FLAG, (u8 *)(&ODMFlag)); + DBG_88E("(B)DMFlag = 0x%x, arg = 0x%x\n", ODMFlag, arg); + ODMFlag = (u32)(0x0f&arg); + DBG_88E("(A)DMFlag = 0x%x\n", ODMFlag); + rtw_hal_set_hwreg(padapter, HW_VAR_DM_FLAG, (u8 *)(&ODMFlag)); + } + break; + case 0x07: + DBG_88E("bSurpriseRemoved =%d, bDriverStopped =%d\n", + padapter->bSurpriseRemoved, padapter->bDriverStopped); + break; + case 0x08: + { + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct recv_priv *precvpriv = &padapter->recvpriv; + + DBG_88E("free_xmitbuf_cnt =%d, free_xmitframe_cnt =%d, free_xmit_extbuf_cnt =%d\n", + pxmitpriv->free_xmitbuf_cnt, pxmitpriv->free_xmitframe_cnt, pxmitpriv->free_xmit_extbuf_cnt); + DBG_88E("rx_urb_pending_cn =%d\n", precvpriv->rx_pending_cnt); + } + break; + case 0x09: + { + int i, j; + struct list_head *plist, *phead; + struct recv_reorder_ctrl *preorder_ctrl; + +#ifdef CONFIG_88EU_AP_MODE + DBG_88E("sta_dz_bitmap = 0x%x, tim_bitmap = 0x%x\n", pstapriv->sta_dz_bitmap, pstapriv->tim_bitmap); +#endif + _enter_critical_bh(&pstapriv->sta_hash_lock, &irqL); + + for (i = 0; i < NUM_STA; i++) { + phead = &(pstapriv->sta_hash[i]); + plist = get_next(phead); + + while ((rtw_end_of_queue_search(phead, plist)) == false) { + psta = LIST_CONTAINOR(plist, struct sta_info, hash_list); + + plist = get_next(plist); + + if (extra_arg == psta->aid) { + DBG_88E("sta's macaddr:%pM\n", (psta->hwaddr)); + DBG_88E("rtsen =%d, cts2slef =%d\n", psta->rtsen, psta->cts2self); + DBG_88E("state = 0x%x, aid =%d, macid =%d, raid =%d\n", psta->state, psta->aid, psta->mac_id, psta->raid); + DBG_88E("qos_en =%d, ht_en =%d, init_rate =%d\n", psta->qos_option, psta->htpriv.ht_option, psta->init_rate); + DBG_88E("bwmode =%d, ch_offset =%d, sgi =%d\n", psta->htpriv.bwmode, psta->htpriv.ch_offset, psta->htpriv.sgi); + DBG_88E("ampdu_enable = %d\n", psta->htpriv.ampdu_enable); + DBG_88E("agg_enable_bitmap =%x, candidate_tid_bitmap =%x\n", psta->htpriv.agg_enable_bitmap, psta->htpriv.candidate_tid_bitmap); + +#ifdef CONFIG_88EU_AP_MODE + DBG_88E("capability = 0x%x\n", psta->capability); + DBG_88E("flags = 0x%x\n", psta->flags); + DBG_88E("wpa_psk = 0x%x\n", psta->wpa_psk); + DBG_88E("wpa2_group_cipher = 0x%x\n", psta->wpa2_group_cipher); + DBG_88E("wpa2_pairwise_cipher = 0x%x\n", psta->wpa2_pairwise_cipher); + DBG_88E("qos_info = 0x%x\n", psta->qos_info); +#endif + DBG_88E("dot118021XPrivacy = 0x%x\n", psta->dot118021XPrivacy); + + for (j = 0; j < 16; j++) { + preorder_ctrl = &psta->recvreorder_ctrl[j]; + if (preorder_ctrl->enable) + DBG_88E("tid =%d, indicate_seq =%d\n", j, preorder_ctrl->indicate_seq); + } + } + } + } + _exit_critical_bh(&pstapriv->sta_hash_lock, &irqL); + } + break; + case 0x0c:/* dump rx/tx packet */ + if (arg == 0) { + DBG_88E("dump rx packet (%d)\n", extra_arg); + rtw_hal_set_def_var(padapter, HAL_DEF_DBG_DUMP_RXPKT, &(extra_arg)); + } else if (arg == 1) { + DBG_88E("dump tx packet (%d)\n", extra_arg); + rtw_hal_set_def_var(padapter, HAL_DEF_DBG_DUMP_TXPKT, &(extra_arg)); + } + break; + case 0x0f: + if (extra_arg == 0) { + DBG_88E("###### silent reset test.......#####\n"); + rtw_hal_sreset_reset(padapter); + } + break; + case 0x15: + { + struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; + DBG_88E("==>silent resete cnts:%d\n", pwrpriv->ips_enter_cnts); + } + break; + case 0x10:/* driver version display */ + DBG_88E("rtw driver version =%s\n", DRIVERVERSION); + break; + case 0x11: + DBG_88E("turn %s Rx RSSI display function\n", (extra_arg == 1) ? "on" : "off"); + padapter->bRxRSSIDisplay = extra_arg; + rtw_hal_set_def_var(padapter, HW_DEF_FA_CNT_DUMP, &extra_arg); + break; + case 0x12: /* set rx_stbc */ + { + struct registry_priv *pregpriv = &padapter->registrypriv; + /* 0: disable, bit(0):enable 2.4g, bit(1):enable 5g, 0x3: enable both 2.4g and 5g */ + /* default is set to enable 2.4GHZ for IOT issue with bufflao's AP at 5GHZ */ + if (pregpriv && + (extra_arg == 0 || + extra_arg == 1 || + extra_arg == 2 || + extra_arg == 3)) { + pregpriv->rx_stbc = extra_arg; + DBG_88E("set rx_stbc =%d\n", pregpriv->rx_stbc); + } else { + DBG_88E("get rx_stbc =%d\n", pregpriv->rx_stbc); + } + } + break; + case 0x13: /* set ampdu_enable */ + { + struct registry_priv *pregpriv = &padapter->registrypriv; + /* 0: disable, 0x1:enable (but wifi_spec should be 0), 0x2: force enable (don't care wifi_spec) */ + if (pregpriv && extra_arg >= 0 && extra_arg < 3) { + pregpriv->ampdu_enable = extra_arg; + DBG_88E("set ampdu_enable =%d\n", pregpriv->ampdu_enable); + } else { + DBG_88E("get ampdu_enable =%d\n", pregpriv->ampdu_enable); + } + } + break; + case 0x14: /* get wifi_spec */ + { + struct registry_priv *pregpriv = &padapter->registrypriv; + DBG_88E("get wifi_spec =%d\n", pregpriv->wifi_spec); + } + break; + case 0x16: + if (arg == 0xff) { + pr_info("ODM_COMP_DIG\t\tBIT0\n"); + pr_info("ODM_COMP_RA_MASK\t\tBIT1\n"); + pr_info("ODM_COMP_DYNAMIC_TXPWR\tBIT2\n"); + pr_info("ODM_COMP_FA_CNT\t\tBIT3\n"); + pr_info("ODM_COMP_RSSI_MONITOR\tBIT4\n"); + pr_info("ODM_COMP_CCK_PD\t\tBIT5\n"); + pr_info("ODM_COMP_ANT_DIV\t\tBIT6\n"); + pr_info("ODM_COMP_PWR_SAVE\t\tBIT7\n"); + pr_info("ODM_COMP_PWR_TRAIN\tBIT8\n"); + pr_info("ODM_COMP_RATE_ADAPTIVE\tBIT9\n"); + pr_info("ODM_COMP_PATH_DIV\t\tBIT10\n"); + pr_info("ODM_COMP_PSD \tBIT11\n"); + pr_info("ODM_COMP_DYNAMIC_PRICCA\tBIT12\n"); + pr_info("ODM_COMP_RXHP\t\tBIT13\n"); + pr_info("ODM_COMP_EDCA_TURBO\tBIT16\n"); + pr_info("ODM_COMP_EARLY_MODE\tBIT17\n"); + pr_info("ODM_COMP_TX_PWR_TRACK\tBIT24\n"); + pr_info("ODM_COMP_RX_GAIN_TRACK\tBIT25\n"); + pr_info("ODM_COMP_CALIBRATION\tBIT26\n"); + rtw_hal_get_def_var(padapter, HW_DEF_ODM_DBG_FLAG, &extra_arg); + } else { + rtw_hal_set_def_var(padapter, HW_DEF_ODM_DBG_FLAG, &extra_arg); + } + break; + case 0x23: + DBG_88E("turn %s the bNotifyChannelChange Variable\n", (extra_arg == 1) ? "on" : "off"); + padapter->bNotifyChannelChange = extra_arg; + break; + case 0x24: +#ifdef CONFIG_88EU_P2P + DBG_88E("turn %s the bShowGetP2PState Variable\n", (extra_arg == 1) ? "on" : "off"); + padapter->bShowGetP2PState = extra_arg; +#endif /* CONFIG_88EU_P2P */ + break; + case 0xaa: + if (extra_arg > 0x13) + extra_arg = 0xFF; + DBG_88E("chang data rate to :0x%02x\n", extra_arg); + padapter->fix_rate = extra_arg; + break; + case 0xdd:/* registers dump, 0 for mac reg, 1 for bb reg, 2 for rf reg */ + if (extra_arg == 0) + mac_reg_dump(padapter); + else if (extra_arg == 1) + bb_reg_dump(padapter); + else if (extra_arg == 2) + rf_reg_dump(padapter); + break; + case 0xee:/* turn on/off dynamic funcs */ + { + u32 odm_flag; + + if (0xf == extra_arg) { + rtw_hal_get_def_var(padapter, HAL_DEF_DBG_DM_FUNC, &odm_flag); + DBG_88E(" === DMFlag(0x%08x) ===\n", odm_flag); + DBG_88E("extra_arg = 0 - disable all dynamic func\n"); + DBG_88E("extra_arg = 1 - disable DIG- BIT(0)\n"); + DBG_88E("extra_arg = 2 - disable High power - BIT(1)\n"); + DBG_88E("extra_arg = 3 - disable tx power tracking - BIT(2)\n"); + DBG_88E("extra_arg = 4 - disable BT coexistence - BIT(3)\n"); + DBG_88E("extra_arg = 5 - disable antenna diversity - BIT(4)\n"); + DBG_88E("extra_arg = 6 - enable all dynamic func\n"); + } else { + /* extra_arg = 0 - disable all dynamic func + extra_arg = 1 - disable DIG + extra_arg = 2 - disable tx power tracking + extra_arg = 3 - turn on all dynamic func + */ + rtw_hal_set_def_var(padapter, HAL_DEF_DBG_DM_FUNC, &(extra_arg)); + rtw_hal_get_def_var(padapter, HAL_DEF_DBG_DM_FUNC, &odm_flag); + DBG_88E(" === DMFlag(0x%08x) ===\n", odm_flag); + } + } + break; + + case 0xfd: + rtw_write8(padapter, 0xc50, arg); + DBG_88E("wr(0xc50) = 0x%x\n", rtw_read8(padapter, 0xc50)); + rtw_write8(padapter, 0xc58, arg); + DBG_88E("wr(0xc58) = 0x%x\n", rtw_read8(padapter, 0xc58)); + break; + case 0xfe: + DBG_88E("rd(0xc50) = 0x%x\n", rtw_read8(padapter, 0xc50)); + DBG_88E("rd(0xc58) = 0x%x\n", rtw_read8(padapter, 0xc58)); + break; + case 0xff: + DBG_88E("dbg(0x210) = 0x%x\n", rtw_read32(padapter, 0x210)); + DBG_88E("dbg(0x608) = 0x%x\n", rtw_read32(padapter, 0x608)); + DBG_88E("dbg(0x280) = 0x%x\n", rtw_read32(padapter, 0x280)); + DBG_88E("dbg(0x284) = 0x%x\n", rtw_read32(padapter, 0x284)); + DBG_88E("dbg(0x288) = 0x%x\n", rtw_read32(padapter, 0x288)); + + DBG_88E("dbg(0x664) = 0x%x\n", rtw_read32(padapter, 0x664)); + + DBG_88E("\n"); + + DBG_88E("dbg(0x430) = 0x%x\n", rtw_read32(padapter, 0x430)); + DBG_88E("dbg(0x438) = 0x%x\n", rtw_read32(padapter, 0x438)); + + DBG_88E("dbg(0x440) = 0x%x\n", rtw_read32(padapter, 0x440)); + + DBG_88E("dbg(0x458) = 0x%x\n", rtw_read32(padapter, 0x458)); + + DBG_88E("dbg(0x484) = 0x%x\n", rtw_read32(padapter, 0x484)); + DBG_88E("dbg(0x488) = 0x%x\n", rtw_read32(padapter, 0x488)); + + DBG_88E("dbg(0x444) = 0x%x\n", rtw_read32(padapter, 0x444)); + DBG_88E("dbg(0x448) = 0x%x\n", rtw_read32(padapter, 0x448)); + DBG_88E("dbg(0x44c) = 0x%x\n", rtw_read32(padapter, 0x44c)); + DBG_88E("dbg(0x450) = 0x%x\n", rtw_read32(padapter, 0x450)); + break; + } + break; + default: + DBG_88E("error dbg cmd!\n"); + break; + } + return ret; +} + +static int wpa_set_param(struct net_device *dev, u8 name, u32 value) +{ + uint ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + + switch (name) { + case IEEE_PARAM_WPA_ENABLED: + padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; /* 802.1x */ + switch ((value)&0xff) { + case 1: /* WPA */ + padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeWPAPSK; /* WPA_PSK */ + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption2Enabled; + break; + case 2: /* WPA2 */ + padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeWPA2PSK; /* WPA2_PSK */ + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption3Enabled; + break; + } + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, + ("wpa_set_param:padapter->securitypriv.ndisauthtype =%d\n", padapter->securitypriv.ndisauthtype)); + break; + case IEEE_PARAM_TKIP_COUNTERMEASURES: + break; + case IEEE_PARAM_DROP_UNENCRYPTED: { + /* HACK: + * + * wpa_supplicant calls set_wpa_enabled when the driver + * is loaded and unloaded, regardless of if WPA is being + * used. No other calls are made which can be used to + * determine if encryption will be used or not prior to + * association being expected. If encryption is not being + * used, drop_unencrypted is set to false, else true -- we + * can use this to determine if the CAP_PRIVACY_ON bit should + * be set. + */ + + break; + } + case IEEE_PARAM_PRIVACY_INVOKED: + break; + + case IEEE_PARAM_AUTH_ALGS: + ret = wpa_set_auth_algs(dev, value); + break; + case IEEE_PARAM_IEEE_802_1X: + break; + case IEEE_PARAM_WPAX_SELECT: + break; + default: + ret = -EOPNOTSUPP; + break; + } + return ret; +} + +static int wpa_mlme(struct net_device *dev, u32 command, u32 reason) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + + switch (command) { + case IEEE_MLME_STA_DEAUTH: + if (!rtw_set_802_11_disassociate(padapter)) + ret = -1; + break; + case IEEE_MLME_STA_DISASSOC: + if (!rtw_set_802_11_disassociate(padapter)) + ret = -1; + break; + default: + ret = -EOPNOTSUPP; + break; + } + + return ret; +} + +static int wpa_supplicant_ioctl(struct net_device *dev, struct iw_point *p) +{ + struct ieee_param *param; + uint ret = 0; + + if (p->length < sizeof(struct ieee_param) || !p->pointer) { + ret = -EINVAL; + goto out; + } + + param = (struct ieee_param *)rtw_malloc(p->length); + if (param == NULL) { + ret = -ENOMEM; + goto out; + } + + if (copy_from_user(param, p->pointer, p->length)) { + kfree(param); + ret = -EFAULT; + goto out; + } + + switch (param->cmd) { + case IEEE_CMD_SET_WPA_PARAM: + ret = wpa_set_param(dev, param->u.wpa_param.name, param->u.wpa_param.value); + break; + + case IEEE_CMD_SET_WPA_IE: + ret = rtw_set_wpa_ie((struct adapter *)rtw_netdev_priv(dev), + (char *)param->u.wpa_ie.data, (u16)param->u.wpa_ie.len); + break; + + case IEEE_CMD_SET_ENCRYPTION: + ret = wpa_set_encryption(dev, param, p->length); + break; + + case IEEE_CMD_MLME: + ret = wpa_mlme(dev, param->u.mlme.command, param->u.mlme.reason_code); + break; + + default: + DBG_88E("Unknown WPA supplicant request: %d\n", param->cmd); + ret = -EOPNOTSUPP; + break; + } + + if (ret == 0 && copy_to_user(p->pointer, param, p->length)) + ret = -EFAULT; + + kfree(param); + +out: + + return ret; +} + +#ifdef CONFIG_88EU_AP_MODE +static u8 set_pairwise_key(struct adapter *padapter, struct sta_info *psta) +{ + struct cmd_obj *ph2c; + struct set_stakey_parm *psetstakey_para; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; + + ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + + psetstakey_para = (struct set_stakey_parm *)rtw_zmalloc(sizeof(struct set_stakey_parm)); + if (psetstakey_para == NULL) { + kfree(ph2c); + res = _FAIL; + goto exit; + } + + init_h2fwcmd_w_parm_no_rsp(ph2c, psetstakey_para, _SetStaKey_CMD_); + + psetstakey_para->algorithm = (u8)psta->dot118021XPrivacy; + + memcpy(psetstakey_para->addr, psta->hwaddr, ETH_ALEN); + + memcpy(psetstakey_para->key, &psta->dot118021x_UncstKey, 16); + + res = rtw_enqueue_cmd(pcmdpriv, ph2c); + +exit: + + return res; +} + +static int set_group_key(struct adapter *padapter, u8 *key, u8 alg, int keyid) +{ + u8 keylen; + struct cmd_obj *pcmd; + struct setkey_parm *psetkeyparm; + struct cmd_priv *pcmdpriv = &(padapter->cmdpriv); + int res = _SUCCESS; + + DBG_88E("%s\n", __func__); + + pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (pcmd == NULL) { + res = _FAIL; + goto exit; + } + psetkeyparm = (struct setkey_parm *)rtw_zmalloc(sizeof(struct setkey_parm)); + if (psetkeyparm == NULL) { + kfree(pcmd); + res = _FAIL; + goto exit; + } + + _rtw_memset(psetkeyparm, 0, sizeof(struct setkey_parm)); + + psetkeyparm->keyid = (u8)keyid; + + psetkeyparm->algorithm = alg; + + psetkeyparm->set_tx = 1; + + switch (alg) { + case _WEP40_: + keylen = 5; + break; + case _WEP104_: + keylen = 13; + break; + case _TKIP_: + case _TKIP_WTMIC_: + case _AES_: + keylen = 16; + default: + keylen = 16; + } + + memcpy(&(psetkeyparm->key[0]), key, keylen); + + pcmd->cmdcode = _SetKey_CMD_; + pcmd->parmbuf = (u8 *)psetkeyparm; + pcmd->cmdsz = (sizeof(struct setkey_parm)); + pcmd->rsp = NULL; + pcmd->rspsz = 0; + + _rtw_init_listhead(&pcmd->list); + + res = rtw_enqueue_cmd(pcmdpriv, pcmd); + +exit: + + return res; +} + +static int set_wep_key(struct adapter *padapter, u8 *key, u8 keylen, int keyid) +{ + u8 alg; + + switch (keylen) { + case 5: + alg = _WEP40_; + break; + case 13: + alg = _WEP104_; + break; + default: + alg = _NO_PRIVACY_; + } + + return set_group_key(padapter, key, alg, keyid); +} + +static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, u32 param_len) +{ + int ret = 0; + u32 wep_key_idx, wep_key_len, wep_total_len; + struct ndis_802_11_wep *pwep = NULL; + struct sta_info *psta = NULL, *pbcmc_sta = NULL; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct security_priv *psecuritypriv = &(padapter->securitypriv); + struct sta_priv *pstapriv = &padapter->stapriv; + + DBG_88E("%s\n", __func__); + param->u.crypt.err = 0; + param->u.crypt.alg[IEEE_CRYPT_ALG_NAME_LEN - 1] = '\0'; + if (param_len != sizeof(struct ieee_param) + param->u.crypt.key_len) { + ret = -EINVAL; + goto exit; + } + if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && + param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && + param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) { + if (param->u.crypt.idx >= WEP_KEYS) { + ret = -EINVAL; + goto exit; + } + } else { + psta = rtw_get_stainfo(pstapriv, param->sta_addr); + if (!psta) { + DBG_88E("rtw_set_encryption(), sta has already been removed or never been added\n"); + goto exit; + } + } + + if (strcmp(param->u.crypt.alg, "none") == 0 && (psta == NULL)) { + /* todo:clear default encryption keys */ + + DBG_88E("clear default encryption keys, keyid =%d\n", param->u.crypt.idx); + goto exit; + } + if (strcmp(param->u.crypt.alg, "WEP") == 0 && (psta == NULL)) { + DBG_88E("r871x_set_encryption, crypt.alg = WEP\n"); + wep_key_idx = param->u.crypt.idx; + wep_key_len = param->u.crypt.key_len; + DBG_88E("r871x_set_encryption, wep_key_idx=%d, len=%d\n", wep_key_idx, wep_key_len); + if ((wep_key_idx >= WEP_KEYS) || (wep_key_len <= 0)) { + ret = -EINVAL; + goto exit; + } + + if (wep_key_len > 0) { + wep_key_len = wep_key_len <= 5 ? 5 : 13; + wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial); + pwep = (struct ndis_802_11_wep *)rtw_malloc(wep_total_len); + if (pwep == NULL) { + DBG_88E(" r871x_set_encryption: pwep allocate fail !!!\n"); + goto exit; + } + + _rtw_memset(pwep, 0, wep_total_len); + + pwep->KeyLength = wep_key_len; + pwep->Length = wep_total_len; + } + + pwep->KeyIndex = wep_key_idx; + + memcpy(pwep->KeyMaterial, param->u.crypt.key, pwep->KeyLength); + + if (param->u.crypt.set_tx) { + DBG_88E("wep, set_tx = 1\n"); + + psecuritypriv->ndisencryptstatus = Ndis802_11Encryption1Enabled; + psecuritypriv->dot11PrivacyAlgrthm = _WEP40_; + psecuritypriv->dot118021XGrpPrivacy = _WEP40_; + + if (pwep->KeyLength == 13) { + psecuritypriv->dot11PrivacyAlgrthm = _WEP104_; + psecuritypriv->dot118021XGrpPrivacy = _WEP104_; + } + + psecuritypriv->dot11PrivacyKeyIndex = wep_key_idx; + + memcpy(&(psecuritypriv->dot11DefKey[wep_key_idx].skey[0]), pwep->KeyMaterial, pwep->KeyLength); + + psecuritypriv->dot11DefKeylen[wep_key_idx] = pwep->KeyLength; + + set_wep_key(padapter, pwep->KeyMaterial, pwep->KeyLength, wep_key_idx); + } else { + DBG_88E("wep, set_tx = 0\n"); + + /* don't update "psecuritypriv->dot11PrivacyAlgrthm" and */ + /* psecuritypriv->dot11PrivacyKeyIndex = keyid", but can rtw_set_key to cam */ + + memcpy(&(psecuritypriv->dot11DefKey[wep_key_idx].skey[0]), pwep->KeyMaterial, pwep->KeyLength); + + psecuritypriv->dot11DefKeylen[wep_key_idx] = pwep->KeyLength; + + set_wep_key(padapter, pwep->KeyMaterial, pwep->KeyLength, wep_key_idx); + } + + goto exit; + } + + if (!psta && check_fwstate(pmlmepriv, WIFI_AP_STATE)) { /* group key */ + if (param->u.crypt.set_tx == 1) { + if (strcmp(param->u.crypt.alg, "WEP") == 0) { + DBG_88E("%s, set group_key, WEP\n", __func__); + + memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, + param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); + + psecuritypriv->dot118021XGrpPrivacy = _WEP40_; + if (param->u.crypt.key_len == 13) + psecuritypriv->dot118021XGrpPrivacy = _WEP104_; + } else if (strcmp(param->u.crypt.alg, "TKIP") == 0) { + DBG_88E("%s, set group_key, TKIP\n", __func__); + psecuritypriv->dot118021XGrpPrivacy = _TKIP_; + memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, + param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); + /* set mic key */ + memcpy(psecuritypriv->dot118021XGrptxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[16]), 8); + memcpy(psecuritypriv->dot118021XGrprxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[24]), 8); + + psecuritypriv->busetkipkey = true; + } else if (strcmp(param->u.crypt.alg, "CCMP") == 0) { + DBG_88E("%s, set group_key, CCMP\n", __func__); + psecuritypriv->dot118021XGrpPrivacy = _AES_; + memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, + param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); + } else { + DBG_88E("%s, set group_key, none\n", __func__); + psecuritypriv->dot118021XGrpPrivacy = _NO_PRIVACY_; + } + psecuritypriv->dot118021XGrpKeyid = param->u.crypt.idx; + psecuritypriv->binstallGrpkey = true; + psecuritypriv->dot11PrivacyAlgrthm = psecuritypriv->dot118021XGrpPrivacy;/* */ + set_group_key(padapter, param->u.crypt.key, psecuritypriv->dot118021XGrpPrivacy, param->u.crypt.idx); + pbcmc_sta = rtw_get_bcmc_stainfo(padapter); + if (pbcmc_sta) { + pbcmc_sta->ieee8021x_blocked = false; + pbcmc_sta->dot118021XPrivacy = psecuritypriv->dot118021XGrpPrivacy;/* rx will use bmc_sta's dot118021XPrivacy */ + } + } + goto exit; + } + + if (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X && psta) { /* psk/802_1x */ + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { + if (param->u.crypt.set_tx == 1) { + memcpy(psta->dot118021x_UncstKey.skey, param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); + + if (strcmp(param->u.crypt.alg, "WEP") == 0) { + DBG_88E("%s, set pairwise key, WEP\n", __func__); + + psta->dot118021XPrivacy = _WEP40_; + if (param->u.crypt.key_len == 13) + psta->dot118021XPrivacy = _WEP104_; + } else if (strcmp(param->u.crypt.alg, "TKIP") == 0) { + DBG_88E("%s, set pairwise key, TKIP\n", __func__); + + psta->dot118021XPrivacy = _TKIP_; + + /* set mic key */ + memcpy(psta->dot11tkiptxmickey.skey, &(param->u.crypt.key[16]), 8); + memcpy(psta->dot11tkiprxmickey.skey, &(param->u.crypt.key[24]), 8); + + psecuritypriv->busetkipkey = true; + } else if (strcmp(param->u.crypt.alg, "CCMP") == 0) { + DBG_88E("%s, set pairwise key, CCMP\n", __func__); + + psta->dot118021XPrivacy = _AES_; + } else { + DBG_88E("%s, set pairwise key, none\n", __func__); + + psta->dot118021XPrivacy = _NO_PRIVACY_; + } + + set_pairwise_key(padapter, psta); + + psta->ieee8021x_blocked = false; + } else { /* group key??? */ + if (strcmp(param->u.crypt.alg, "WEP") == 0) { + memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, + param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); + psecuritypriv->dot118021XGrpPrivacy = _WEP40_; + if (param->u.crypt.key_len == 13) + psecuritypriv->dot118021XGrpPrivacy = _WEP104_; + } else if (strcmp(param->u.crypt.alg, "TKIP") == 0) { + psecuritypriv->dot118021XGrpPrivacy = _TKIP_; + + memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, + param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); + + /* set mic key */ + memcpy(psecuritypriv->dot118021XGrptxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[16]), 8); + memcpy(psecuritypriv->dot118021XGrprxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[24]), 8); + + psecuritypriv->busetkipkey = true; + } else if (strcmp(param->u.crypt.alg, "CCMP") == 0) { + psecuritypriv->dot118021XGrpPrivacy = _AES_; + + memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, + param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); + } else { + psecuritypriv->dot118021XGrpPrivacy = _NO_PRIVACY_; + } + + psecuritypriv->dot118021XGrpKeyid = param->u.crypt.idx; + + psecuritypriv->binstallGrpkey = true; + + psecuritypriv->dot11PrivacyAlgrthm = psecuritypriv->dot118021XGrpPrivacy;/* */ + + set_group_key(padapter, param->u.crypt.key, psecuritypriv->dot118021XGrpPrivacy, param->u.crypt.idx); + + pbcmc_sta = rtw_get_bcmc_stainfo(padapter); + if (pbcmc_sta) { + pbcmc_sta->ieee8021x_blocked = false; + pbcmc_sta->dot118021XPrivacy = psecuritypriv->dot118021XGrpPrivacy;/* rx will use bmc_sta's dot118021XPrivacy */ + } + } + } + } + +exit: + + kfree(pwep); + + return ret; +} + +static int rtw_set_beacon(struct net_device *dev, struct ieee_param *param, int len) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct sta_priv *pstapriv = &padapter->stapriv; + unsigned char *pbuf = param->u.bcn_ie.buf; + + DBG_88E("%s, len =%d\n", __func__, len); + + if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) + return -EINVAL; + + memcpy(&pstapriv->max_num_sta, param->u.bcn_ie.reserved, 2); + + if ((pstapriv->max_num_sta > NUM_STA) || (pstapriv->max_num_sta <= 0)) + pstapriv->max_num_sta = NUM_STA; + + if (rtw_check_beacon_data(padapter, pbuf, (len-12-2)) == _SUCCESS)/* 12 = param header, 2:no packed */ + ret = 0; + else + ret = -EINVAL; + + return ret; +} + +static int rtw_hostapd_sta_flush(struct net_device *dev) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + + DBG_88E("%s\n", __func__); + + flush_all_cam_entry(padapter); /* clear CAM */ + + ret = rtw_sta_flush(padapter); + + return ret; +} + +static int rtw_add_sta(struct net_device *dev, struct ieee_param *param) +{ + int ret = 0; + struct sta_info *psta = NULL; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct sta_priv *pstapriv = &padapter->stapriv; + + DBG_88E("rtw_add_sta(aid =%d) =%pM\n", param->u.add_sta.aid, (param->sta_addr)); + + if (!check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE))) + return -EINVAL; + + if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && + param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && + param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) + return -EINVAL; + + psta = rtw_get_stainfo(pstapriv, param->sta_addr); + if (psta) { + int flags = param->u.add_sta.flags; + + psta->aid = param->u.add_sta.aid;/* aid = 1~2007 */ + + memcpy(psta->bssrateset, param->u.add_sta.tx_supp_rates, 16); + + /* check wmm cap. */ + if (WLAN_STA_WME&flags) + psta->qos_option = 1; + else + psta->qos_option = 0; + + if (pmlmepriv->qospriv.qos_option == 0) + psta->qos_option = 0; + + /* chec 802.11n ht cap. */ + if (WLAN_STA_HT&flags) { + psta->htpriv.ht_option = true; + psta->qos_option = 1; + memcpy((void *)&psta->htpriv.ht_cap, (void *)¶m->u.add_sta.ht_cap, sizeof(struct rtw_ieee80211_ht_cap)); + } else { + psta->htpriv.ht_option = false; + } + + if (pmlmepriv->htpriv.ht_option == false) + psta->htpriv.ht_option = false; + + update_sta_info_apmode(padapter, psta); + } else { + ret = -ENOMEM; + } + + return ret; +} + +static int rtw_del_sta(struct net_device *dev, struct ieee_param *param) +{ + unsigned long irqL; + int ret = 0; + struct sta_info *psta = NULL; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct sta_priv *pstapriv = &padapter->stapriv; + int updated = 0; + + DBG_88E("rtw_del_sta =%pM\n", (param->sta_addr)); + + if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true) + return -EINVAL; + + if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && + param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && + param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) + return -EINVAL; + + psta = rtw_get_stainfo(pstapriv, param->sta_addr); + if (psta) { + _enter_critical_bh(&pstapriv->asoc_list_lock, &irqL); + if (!rtw_is_list_empty(&psta->asoc_list)) { + rtw_list_delete(&psta->asoc_list); + pstapriv->asoc_list_cnt--; + updated = ap_free_sta(padapter, psta, true, WLAN_REASON_DEAUTH_LEAVING); + } + _exit_critical_bh(&pstapriv->asoc_list_lock, &irqL); + associated_clients_update(padapter, updated); + psta = NULL; + } else { + DBG_88E("rtw_del_sta(), sta has already been removed or never been added\n"); + } + + return ret; +} + +static int rtw_ioctl_get_sta_data(struct net_device *dev, struct ieee_param *param, int len) +{ + int ret = 0; + struct sta_info *psta = NULL; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct sta_priv *pstapriv = &padapter->stapriv; + struct ieee_param_ex *param_ex = (struct ieee_param_ex *)param; + struct sta_data *psta_data = (struct sta_data *)param_ex->data; + + DBG_88E("rtw_ioctl_get_sta_info, sta_addr: %pM\n", (param_ex->sta_addr)); + + if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true) + return -EINVAL; + + if (param_ex->sta_addr[0] == 0xff && param_ex->sta_addr[1] == 0xff && + param_ex->sta_addr[2] == 0xff && param_ex->sta_addr[3] == 0xff && + param_ex->sta_addr[4] == 0xff && param_ex->sta_addr[5] == 0xff) + return -EINVAL; + + psta = rtw_get_stainfo(pstapriv, param_ex->sta_addr); + if (psta) { + psta_data->aid = (u16)psta->aid; + psta_data->capability = psta->capability; + psta_data->flags = psta->flags; + +/* + nonerp_set : BIT(0) + no_short_slot_time_set : BIT(1) + no_short_preamble_set : BIT(2) + no_ht_gf_set : BIT(3) + no_ht_set : BIT(4) + ht_20mhz_set : BIT(5) +*/ + + psta_data->sta_set = ((psta->nonerp_set) | + (psta->no_short_slot_time_set << 1) | + (psta->no_short_preamble_set << 2) | + (psta->no_ht_gf_set << 3) | + (psta->no_ht_set << 4) | + (psta->ht_20mhz_set << 5)); + psta_data->tx_supp_rates_len = psta->bssratelen; + memcpy(psta_data->tx_supp_rates, psta->bssrateset, psta->bssratelen); + memcpy(&psta_data->ht_cap, &psta->htpriv.ht_cap, sizeof(struct rtw_ieee80211_ht_cap)); + psta_data->rx_pkts = psta->sta_stats.rx_data_pkts; + psta_data->rx_bytes = psta->sta_stats.rx_bytes; + psta_data->rx_drops = psta->sta_stats.rx_drops; + psta_data->tx_pkts = psta->sta_stats.tx_pkts; + psta_data->tx_bytes = psta->sta_stats.tx_bytes; + psta_data->tx_drops = psta->sta_stats.tx_drops; + } else { + ret = -1; + } + + return ret; +} + +static int rtw_get_sta_wpaie(struct net_device *dev, struct ieee_param *param) +{ + int ret = 0; + struct sta_info *psta = NULL; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct sta_priv *pstapriv = &padapter->stapriv; + + DBG_88E("rtw_get_sta_wpaie, sta_addr: %pM\n", (param->sta_addr)); + + if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true) + return -EINVAL; + + if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && + param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && + param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) + return -EINVAL; + + psta = rtw_get_stainfo(pstapriv, param->sta_addr); + if (psta) { + if ((psta->wpa_ie[0] == WLAN_EID_RSN) || (psta->wpa_ie[0] == WLAN_EID_GENERIC)) { + int wpa_ie_len; + int copy_len; + + wpa_ie_len = psta->wpa_ie[1]; + copy_len = ((wpa_ie_len+2) > sizeof(psta->wpa_ie)) ? (sizeof(psta->wpa_ie)) : (wpa_ie_len+2); + param->u.wpa_ie.len = copy_len; + memcpy(param->u.wpa_ie.reserved, psta->wpa_ie, copy_len); + } else { + DBG_88E("sta's wpa_ie is NONE\n"); + } + } else { + ret = -1; + } + + return ret; +} + +static int rtw_set_wps_beacon(struct net_device *dev, struct ieee_param *param, int len) +{ + int ret = 0; + unsigned char wps_oui[4] = {0x0, 0x50, 0xf2, 0x04}; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + int ie_len; + + DBG_88E("%s, len =%d\n", __func__, len); + + if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) + return -EINVAL; + + ie_len = len-12-2;/* 12 = param header, 2:no packed */ + + if (pmlmepriv->wps_beacon_ie) { + kfree(pmlmepriv->wps_beacon_ie); + pmlmepriv->wps_beacon_ie = NULL; + } + + if (ie_len > 0) { + pmlmepriv->wps_beacon_ie = rtw_malloc(ie_len); + pmlmepriv->wps_beacon_ie_len = ie_len; + if (pmlmepriv->wps_beacon_ie == NULL) { + DBG_88E("%s()-%d: rtw_malloc() ERROR!\n", __func__, __LINE__); + return -EINVAL; + } + + memcpy(pmlmepriv->wps_beacon_ie, param->u.bcn_ie.buf, ie_len); + + update_beacon(padapter, _VENDOR_SPECIFIC_IE_, wps_oui, true); + + pmlmeext->bstart_bss = true; + } + + return ret; +} + +static int rtw_set_wps_probe_resp(struct net_device *dev, struct ieee_param *param, int len) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + int ie_len; + + DBG_88E("%s, len =%d\n", __func__, len); + + if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) + return -EINVAL; + + ie_len = len-12-2;/* 12 = param header, 2:no packed */ + + if (pmlmepriv->wps_probe_resp_ie) { + kfree(pmlmepriv->wps_probe_resp_ie); + pmlmepriv->wps_probe_resp_ie = NULL; + } + + if (ie_len > 0) { + pmlmepriv->wps_probe_resp_ie = rtw_malloc(ie_len); + pmlmepriv->wps_probe_resp_ie_len = ie_len; + if (pmlmepriv->wps_probe_resp_ie == NULL) { + DBG_88E("%s()-%d: rtw_malloc() ERROR!\n", __func__, __LINE__); + return -EINVAL; + } + memcpy(pmlmepriv->wps_probe_resp_ie, param->u.bcn_ie.buf, ie_len); + } + + return ret; +} + +static int rtw_set_wps_assoc_resp(struct net_device *dev, struct ieee_param *param, int len) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + int ie_len; + + DBG_88E("%s, len =%d\n", __func__, len); + + if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) + return -EINVAL; + + ie_len = len-12-2;/* 12 = param header, 2:no packed */ + + if (pmlmepriv->wps_assoc_resp_ie) { + kfree(pmlmepriv->wps_assoc_resp_ie); + pmlmepriv->wps_assoc_resp_ie = NULL; + } + + if (ie_len > 0) { + pmlmepriv->wps_assoc_resp_ie = rtw_malloc(ie_len); + pmlmepriv->wps_assoc_resp_ie_len = ie_len; + if (pmlmepriv->wps_assoc_resp_ie == NULL) { + DBG_88E("%s()-%d: rtw_malloc() ERROR!\n", __func__, __LINE__); + return -EINVAL; + } + + memcpy(pmlmepriv->wps_assoc_resp_ie, param->u.bcn_ie.buf, ie_len); + } + + return ret; +} + +static int rtw_set_hidden_ssid(struct net_device *dev, struct ieee_param *param, int len) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + u8 value; + + if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) + return -EINVAL; + + if (param->u.wpa_param.name != 0) /* dummy test... */ + DBG_88E("%s name(%u) != 0\n", __func__, param->u.wpa_param.name); + value = param->u.wpa_param.value; + + /* use the same definition of hostapd's ignore_broadcast_ssid */ + if (value != 1 && value != 2) + value = 0; + DBG_88E("%s value(%u)\n", __func__, value); + pmlmeinfo->hidden_ssid_mode = value; + return ret; +} + +static int rtw_ioctl_acl_remove_sta(struct net_device *dev, struct ieee_param *param, int len) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + + if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) + return -EINVAL; + + if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && + param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && + param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) + return -EINVAL; + ret = rtw_acl_remove_sta(padapter, param->sta_addr); + return ret; +} + +static int rtw_ioctl_acl_add_sta(struct net_device *dev, struct ieee_param *param, int len) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + + if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) + return -EINVAL; + + if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && + param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && + param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) + return -EINVAL; + ret = rtw_acl_add_sta(padapter, param->sta_addr); + return ret; +} + +static int rtw_ioctl_set_macaddr_acl(struct net_device *dev, struct ieee_param *param, int len) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + + if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) + return -EINVAL; + + rtw_set_macaddr_acl(padapter, param->u.mlme.command); + + return ret; +} + +static int rtw_hostapd_ioctl(struct net_device *dev, struct iw_point *p) +{ + struct ieee_param *param; + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + + /* + * this function is expect to call in master mode, which allows no power saving + * so, we just check hw_init_completed + */ + + if (!padapter->hw_init_completed) { + ret = -EPERM; + goto out; + } + + if (!p->pointer) { + ret = -EINVAL; + goto out; + } + + param = (struct ieee_param *)rtw_malloc(p->length); + if (param == NULL) { + ret = -ENOMEM; + goto out; + } + + if (copy_from_user(param, p->pointer, p->length)) { + kfree(param); + ret = -EFAULT; + goto out; + } + + switch (param->cmd) { + case RTL871X_HOSTAPD_FLUSH: + ret = rtw_hostapd_sta_flush(dev); + break; + case RTL871X_HOSTAPD_ADD_STA: + ret = rtw_add_sta(dev, param); + break; + case RTL871X_HOSTAPD_REMOVE_STA: + ret = rtw_del_sta(dev, param); + break; + case RTL871X_HOSTAPD_SET_BEACON: + ret = rtw_set_beacon(dev, param, p->length); + break; + case RTL871X_SET_ENCRYPTION: + ret = rtw_set_encryption(dev, param, p->length); + break; + case RTL871X_HOSTAPD_GET_WPAIE_STA: + ret = rtw_get_sta_wpaie(dev, param); + break; + case RTL871X_HOSTAPD_SET_WPS_BEACON: + ret = rtw_set_wps_beacon(dev, param, p->length); + break; + case RTL871X_HOSTAPD_SET_WPS_PROBE_RESP: + ret = rtw_set_wps_probe_resp(dev, param, p->length); + break; + case RTL871X_HOSTAPD_SET_WPS_ASSOC_RESP: + ret = rtw_set_wps_assoc_resp(dev, param, p->length); + break; + case RTL871X_HOSTAPD_SET_HIDDEN_SSID: + ret = rtw_set_hidden_ssid(dev, param, p->length); + break; + case RTL871X_HOSTAPD_GET_INFO_STA: + ret = rtw_ioctl_get_sta_data(dev, param, p->length); + break; + case RTL871X_HOSTAPD_SET_MACADDR_ACL: + ret = rtw_ioctl_set_macaddr_acl(dev, param, p->length); + break; + case RTL871X_HOSTAPD_ACL_ADD_STA: + ret = rtw_ioctl_acl_add_sta(dev, param, p->length); + break; + case RTL871X_HOSTAPD_ACL_REMOVE_STA: + ret = rtw_ioctl_acl_remove_sta(dev, param, p->length); + break; + default: + DBG_88E("Unknown hostapd request: %d\n", param->cmd); + ret = -EOPNOTSUPP; + break; + } + + if (ret == 0 && copy_to_user(p->pointer, param, p->length)) + ret = -EFAULT; + kfree(param); +out: + return ret; +} +#endif + +#include +static int rtw_wx_set_priv(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *awrq, + char *extra) +{ + int ret = 0; + int len = 0; + char *ext; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct iw_point *dwrq = (struct iw_point *)awrq; + + if (dwrq->length == 0) + return -EFAULT; + + len = dwrq->length; + ext = rtw_vmalloc(len); + if (!ext) + return -ENOMEM; + + if (copy_from_user(ext, dwrq->pointer, len)) { + rtw_vmfree(ext, len); + return -EFAULT; + } + + /* added for wps2.0 @20110524 */ + if (dwrq->flags == 0x8766 && len > 8) { + u32 cp_sz; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + u8 *probereq_wpsie = ext; + int probereq_wpsie_len = len; + u8 wps_oui[4] = {0x0, 0x50, 0xf2, 0x04}; + + if ((_VENDOR_SPECIFIC_IE_ == probereq_wpsie[0]) && + (!memcmp(&probereq_wpsie[2], wps_oui, 4))) { + cp_sz = probereq_wpsie_len > MAX_WPS_IE_LEN ? MAX_WPS_IE_LEN : probereq_wpsie_len; + + pmlmepriv->wps_probe_req_ie_len = 0; + kfree(pmlmepriv->wps_probe_req_ie); + pmlmepriv->wps_probe_req_ie = NULL; + + pmlmepriv->wps_probe_req_ie = rtw_malloc(cp_sz); + if (pmlmepriv->wps_probe_req_ie == NULL) { + pr_info("%s()-%d: rtw_malloc() ERROR!\n", __func__, __LINE__); + ret = -EINVAL; + goto FREE_EXT; + } + memcpy(pmlmepriv->wps_probe_req_ie, probereq_wpsie, cp_sz); + pmlmepriv->wps_probe_req_ie_len = cp_sz; + } + goto FREE_EXT; + } + + if (len >= WEXT_CSCAN_HEADER_SIZE && + !memcmp(ext, WEXT_CSCAN_HEADER, WEXT_CSCAN_HEADER_SIZE)) { + ret = rtw_wx_set_scan(dev, info, awrq, ext); + goto FREE_EXT; + } + +FREE_EXT: + + rtw_vmfree(ext, len); + + return ret; +} + +static int rtw_pm_set(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + unsigned mode = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + + DBG_88E("[%s] extra = %s\n", __func__, extra); + + if (!memcmp(extra, "lps =", 4)) { + sscanf(extra+4, "%u", &mode); + ret = rtw_pm_set_lps(padapter, mode); + } else if (!memcmp(extra, "ips =", 4)) { + sscanf(extra+4, "%u", &mode); + ret = rtw_pm_set_ips(padapter, mode); + } else { + ret = -EINVAL; + } + + return ret; +} + +static int rtw_mp_efuse_get(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wdata, char *extra) +{ + struct adapter *padapter = rtw_netdev_priv(dev); + struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter); + struct hal_data_8188e *haldata = GET_HAL_DATA(padapter); + struct efuse_hal *pEfuseHal; + struct iw_point *wrqu; + + u8 *PROMContent = pEEPROM->efuse_eeprom_data; + u8 ips_mode = 0, lps_mode = 0; + struct pwrctrl_priv *pwrctrlpriv; + u8 *data = NULL; + u8 *rawdata = NULL; + char *pch, *ptmp, *token, *tmp[3] = {NULL, NULL, NULL}; + u16 i = 0, j = 0, mapLen = 0, addr = 0, cnts = 0; + u16 max_available_size = 0, raw_cursize = 0, raw_maxsize = 0; + int err; + u8 org_fw_iol = padapter->registrypriv.fw_iol;/* 0:Disable, 1:enable, 2:by usb speed */ + + wrqu = (struct iw_point *)wdata; + pwrctrlpriv = &padapter->pwrctrlpriv; + pEfuseHal = &haldata->EfuseHal; + + err = 0; + data = _rtw_zmalloc(EFUSE_BT_MAX_MAP_LEN); + if (data == NULL) { + err = -ENOMEM; + goto exit; + } + rawdata = _rtw_zmalloc(EFUSE_BT_MAX_MAP_LEN); + if (rawdata == NULL) { + err = -ENOMEM; + goto exit; + } + + if (copy_from_user(extra, wrqu->pointer, wrqu->length)) { + err = -EFAULT; + goto exit; + } + lps_mode = pwrctrlpriv->power_mgnt;/* keep org value */ + rtw_pm_set_lps(padapter, PS_MODE_ACTIVE); + + ips_mode = pwrctrlpriv->ips_mode;/* keep org value */ + rtw_pm_set_ips(padapter, IPS_NONE); + + pch = extra; + DBG_88E("%s: in =%s\n", __func__, extra); + + i = 0; + /* mac 16 "00e04c871200" rmap, 00, 2 */ + while ((token = strsep(&pch, ",")) != NULL) { + if (i > 2) + break; + tmp[i] = token; + i++; + } + padapter->registrypriv.fw_iol = 0;/* 0:Disable, 1:enable, 2:by usb speed */ + + if (strcmp(tmp[0], "status") == 0) { + sprintf(extra, "Load File efuse =%s, Load File MAC =%s", (pEEPROM->bloadfile_fail_flag ? "FAIL" : "OK"), (pEEPROM->bloadmac_fail_flag ? "FAIL" : "OK")); + + goto exit; + } else if (strcmp(tmp[0], "filemap") == 0) { + mapLen = EFUSE_MAP_SIZE; + + sprintf(extra, "\n"); + for (i = 0; i < EFUSE_MAP_SIZE; i += 16) { + sprintf(extra, "%s0x%02x\t", extra, i); + for (j = 0; j < 8; j++) + sprintf(extra, "%s%02X ", extra, PROMContent[i+j]); + sprintf(extra, "%s\t", extra); + for (; j < 16; j++) + sprintf(extra, "%s%02X ", extra, PROMContent[i+j]); + sprintf(extra, "%s\n", extra); + } + } else if (strcmp(tmp[0], "realmap") == 0) { + mapLen = EFUSE_MAP_SIZE; + if (rtw_efuse_map_read(padapter, 0, mapLen, pEfuseHal->fakeEfuseInitMap) == _FAIL) { + DBG_88E("%s: read realmap Fail!!\n", __func__); + err = -EFAULT; + goto exit; + } + + sprintf(extra, "\n"); + for (i = 0; i < EFUSE_MAP_SIZE; i += 16) { + sprintf(extra, "%s0x%02x\t", extra, i); + for (j = 0; j < 8; j++) + sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeEfuseInitMap[i+j]); + sprintf(extra, "%s\t", extra); + for (; j < 16; j++) + sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeEfuseInitMap[i+j]); + sprintf(extra, "%s\n", extra); + } + } else if (strcmp(tmp[0], "rmap") == 0) { + if ((tmp[1] == NULL) || (tmp[2] == NULL)) { + DBG_88E("%s: rmap Fail!! Parameters error!\n", __func__); + err = -EINVAL; + goto exit; + } + + /* rmap addr cnts */ + addr = simple_strtoul(tmp[1], &ptmp, 16); + DBG_88E("%s: addr =%x\n", __func__, addr); + + cnts = simple_strtoul(tmp[2], &ptmp, 10); + if (cnts == 0) { + DBG_88E("%s: rmap Fail!! cnts error!\n", __func__); + err = -EINVAL; + goto exit; + } + DBG_88E("%s: cnts =%d\n", __func__, cnts); + + EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); + if ((addr + cnts) > max_available_size) { + DBG_88E("%s: addr(0x%X)+cnts(%d) parameter error!\n", __func__, addr, cnts); + err = -EINVAL; + goto exit; + } + + if (rtw_efuse_map_read(padapter, addr, cnts, data) == _FAIL) { + DBG_88E("%s: rtw_efuse_map_read error!\n", __func__); + err = -EFAULT; + goto exit; + } + + *extra = 0; + for (i = 0; i < cnts; i++) + sprintf(extra, "%s0x%02X ", extra, data[i]); + } else if (strcmp(tmp[0], "realraw") == 0) { + addr = 0; + mapLen = EFUSE_MAX_SIZE; + if (rtw_efuse_access(padapter, false, addr, mapLen, rawdata) == _FAIL) { + DBG_88E("%s: rtw_efuse_access Fail!!\n", __func__); + err = -EFAULT; + goto exit; + } + + sprintf(extra, "\n"); + for (i = 0; i < mapLen; i++) { + sprintf(extra, "%s%02X", extra, rawdata[i]); + + if ((i & 0xF) == 0xF) + sprintf(extra, "%s\n", extra); + else if ((i & 0x7) == 0x7) + sprintf(extra, "%s\t", extra); + else + sprintf(extra, "%s ", extra); + } + } else if (strcmp(tmp[0], "mac") == 0) { + cnts = 6; + + EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); + if ((addr + cnts) > max_available_size) { + DBG_88E("%s: addr(0x%02x)+cnts(%d) parameter error!\n", __func__, addr, cnts); + err = -EFAULT; + goto exit; + } + + if (rtw_efuse_map_read(padapter, addr, cnts, data) == _FAIL) { + DBG_88E("%s: rtw_efuse_map_read error!\n", __func__); + err = -EFAULT; + goto exit; + } + + *extra = 0; + for (i = 0; i < cnts; i++) { + sprintf(extra, "%s%02X", extra, data[i]); + if (i != (cnts-1)) + sprintf(extra, "%s:", extra); + } + } else if (strcmp(tmp[0], "vidpid") == 0) { + cnts = 4; + + EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); + if ((addr + cnts) > max_available_size) { + DBG_88E("%s: addr(0x%02x)+cnts(%d) parameter error!\n", __func__, addr, cnts); + err = -EFAULT; + goto exit; + } + if (rtw_efuse_map_read(padapter, addr, cnts, data) == _FAIL) { + DBG_88E("%s: rtw_efuse_access error!!\n", __func__); + err = -EFAULT; + goto exit; + } + + *extra = 0; + for (i = 0; i < cnts; i++) { + sprintf(extra, "%s0x%02X", extra, data[i]); + if (i != (cnts-1)) + sprintf(extra, "%s,", extra); + } + } else if (strcmp(tmp[0], "ableraw") == 0) { + efuse_GetCurrentSize(padapter, &raw_cursize); + raw_maxsize = efuse_GetMaxSize(padapter); + sprintf(extra, "[available raw size] = %d bytes", raw_maxsize-raw_cursize); + } else if (strcmp(tmp[0], "btfmap") == 0) { + mapLen = EFUSE_BT_MAX_MAP_LEN; + if (rtw_BT_efuse_map_read(padapter, 0, mapLen, pEfuseHal->BTEfuseInitMap) == _FAIL) { + DBG_88E("%s: rtw_BT_efuse_map_read Fail!!\n", __func__); + err = -EFAULT; + goto exit; + } + + sprintf(extra, "\n"); + for (i = 0; i < 512; i += 16) { + /* set 512 because the iwpriv's extra size have limit 0x7FF */ + sprintf(extra, "%s0x%03x\t", extra, i); + for (j = 0; j < 8; j++) + sprintf(extra, "%s%02X ", extra, pEfuseHal->BTEfuseInitMap[i+j]); + sprintf(extra, "%s\t", extra); + for (; j < 16; j++) + sprintf(extra, "%s%02X ", extra, pEfuseHal->BTEfuseInitMap[i+j]); + sprintf(extra, "%s\n", extra); + } + } else if (strcmp(tmp[0], "btbmap") == 0) { + mapLen = EFUSE_BT_MAX_MAP_LEN; + if (rtw_BT_efuse_map_read(padapter, 0, mapLen, pEfuseHal->BTEfuseInitMap) == _FAIL) { + DBG_88E("%s: rtw_BT_efuse_map_read Fail!!\n", __func__); + err = -EFAULT; + goto exit; + } + + sprintf(extra, "\n"); + for (i = 512; i < 1024; i += 16) { + sprintf(extra, "%s0x%03x\t", extra, i); + for (j = 0; j < 8; j++) + sprintf(extra, "%s%02X ", extra, pEfuseHal->BTEfuseInitMap[i+j]); + sprintf(extra, "%s\t", extra); + for (; j < 16; j++) + sprintf(extra, "%s%02X ", extra, pEfuseHal->BTEfuseInitMap[i+j]); + sprintf(extra, "%s\n", extra); + } + } else if (strcmp(tmp[0], "btrmap") == 0) { + if ((tmp[1] == NULL) || (tmp[2] == NULL)) { + err = -EINVAL; + goto exit; + } + + /* rmap addr cnts */ + addr = simple_strtoul(tmp[1], &ptmp, 16); + DBG_88E("%s: addr = 0x%X\n", __func__, addr); + + cnts = simple_strtoul(tmp[2], &ptmp, 10); + if (cnts == 0) { + DBG_88E("%s: btrmap Fail!! cnts error!\n", __func__); + err = -EINVAL; + goto exit; + } + DBG_88E("%s: cnts =%d\n", __func__, cnts); + + EFUSE_GetEfuseDefinition(padapter, EFUSE_BT, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); + if ((addr + cnts) > max_available_size) { + DBG_88E("%s: addr(0x%X)+cnts(%d) parameter error!\n", __func__, addr, cnts); + err = -EFAULT; + goto exit; + } + + if (rtw_BT_efuse_map_read(padapter, addr, cnts, data) == _FAIL) { + DBG_88E("%s: rtw_BT_efuse_map_read error!!\n", __func__); + err = -EFAULT; + goto exit; + } + + *extra = 0; + for (i = 0; i < cnts; i++) + sprintf(extra, "%s 0x%02X ", extra, data[i]); + } else if (strcmp(tmp[0], "btffake") == 0) { + sprintf(extra, "\n"); + for (i = 0; i < 512; i += 16) { + sprintf(extra, "%s0x%03x\t", extra, i); + for (j = 0; j < 8; j++) + sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeBTEfuseModifiedMap[i+j]); + sprintf(extra, "%s\t", extra); + for (; j < 16; j++) + sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeBTEfuseModifiedMap[i+j]); + sprintf(extra, "%s\n", extra); + } + } else if (strcmp(tmp[0], "btbfake") == 0) { + sprintf(extra, "\n"); + for (i = 512; i < 1024; i += 16) { + sprintf(extra, "%s0x%03x\t", extra, i); + for (j = 0; j < 8; j++) + sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeBTEfuseModifiedMap[i+j]); + sprintf(extra, "%s\t", extra); + for (; j < 16; j++) + sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeBTEfuseModifiedMap[i+j]); + sprintf(extra, "%s\n", extra); + } + } else if (strcmp(tmp[0], "wlrfkmap") == 0) { + sprintf(extra, "\n"); + for (i = 0; i < EFUSE_MAP_SIZE; i += 16) { + sprintf(extra, "%s0x%02x\t", extra, i); + for (j = 0; j < 8; j++) + sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeEfuseModifiedMap[i+j]); + sprintf(extra, "%s\t", extra); + for (; j < 16; j++) + sprintf(extra, "%s %02X", extra, pEfuseHal->fakeEfuseModifiedMap[i+j]); + sprintf(extra, "%s\n", extra); + } + } else { + sprintf(extra, "Command not found!"); + } + +exit: + kfree(data); + kfree(rawdata); + if (!err) + wrqu->length = strlen(extra); + + rtw_pm_set_ips(padapter, ips_mode); + rtw_pm_set_lps(padapter, lps_mode); + padapter->registrypriv.fw_iol = org_fw_iol;/* 0:Disable, 1:enable, 2:by usb speed */ + return err; +} + +static int rtw_mp_efuse_set(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wdata, char *extra) +{ + struct adapter *padapter; + struct pwrctrl_priv *pwrctrlpriv; + struct hal_data_8188e *haldata; + struct efuse_hal *pEfuseHal; + + u8 ips_mode = 0, lps_mode = 0; + u32 i, jj, kk; + u8 *setdata = NULL; + u8 *ShadowMapBT = NULL; + u8 *ShadowMapWiFi = NULL; + u8 *setrawdata = NULL; + char *pch, *ptmp, *token, *tmp[3] = {NULL, NULL, NULL}; + u16 addr = 0, cnts = 0, max_available_size = 0; + int err; + + padapter = rtw_netdev_priv(dev); + pwrctrlpriv = &padapter->pwrctrlpriv; + haldata = GET_HAL_DATA(padapter); + pEfuseHal = &haldata->EfuseHal; + err = 0; + setdata = _rtw_zmalloc(1024); + if (setdata == NULL) { + err = -ENOMEM; + goto exit; + } + ShadowMapBT = _rtw_malloc(EFUSE_BT_MAX_MAP_LEN); + if (ShadowMapBT == NULL) { + err = -ENOMEM; + goto exit; + } + ShadowMapWiFi = _rtw_malloc(EFUSE_MAP_SIZE); + if (ShadowMapWiFi == NULL) { + err = -ENOMEM; + goto exit; + } + setrawdata = _rtw_malloc(EFUSE_MAX_SIZE); + if (setrawdata == NULL) { + err = -ENOMEM; + goto exit; + } + + lps_mode = pwrctrlpriv->power_mgnt;/* keep org value */ + rtw_pm_set_lps(padapter, PS_MODE_ACTIVE); + + ips_mode = pwrctrlpriv->ips_mode;/* keep org value */ + rtw_pm_set_ips(padapter, IPS_NONE); + + pch = extra; + DBG_88E("%s: in =%s\n", __func__, extra); + + i = 0; + while ((token = strsep(&pch, ",")) != NULL) { + if (i > 2) + break; + tmp[i] = token; + i++; + } + + /* tmp[0],[1],[2] */ + /* wmap, addr, 00e04c871200 */ + if (strcmp(tmp[0], "wmap") == 0) { + if ((tmp[1] == NULL) || (tmp[2] == NULL)) { + err = -EINVAL; + goto exit; + } + + addr = simple_strtoul(tmp[1], &ptmp, 16); + addr &= 0xFFF; + + cnts = strlen(tmp[2]); + if (cnts%2) { + err = -EINVAL; + goto exit; + } + cnts /= 2; + if (cnts == 0) { + err = -EINVAL; + goto exit; + } + + DBG_88E("%s: addr = 0x%X\n", __func__, addr); + DBG_88E("%s: cnts =%d\n", __func__, cnts); + DBG_88E("%s: map data =%s\n", __func__, tmp[2]); + + for (jj = 0, kk = 0; jj < cnts; jj++, kk += 2) + setdata[jj] = key_2char2num(tmp[2][kk], tmp[2][kk + 1]); + /* Change to check TYPE_EFUSE_MAP_LEN, beacuse 8188E raw 256, logic map over 256. */ + EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_EFUSE_MAP_LEN, (void *)&max_available_size, false); + if ((addr+cnts) > max_available_size) { + DBG_88E("%s: addr(0x%X)+cnts(%d) parameter error!\n", __func__, addr, cnts); + err = -EFAULT; + goto exit; + } + + if (rtw_efuse_map_write(padapter, addr, cnts, setdata) == _FAIL) { + DBG_88E("%s: rtw_efuse_map_write error!!\n", __func__); + err = -EFAULT; + goto exit; + } + } else if (strcmp(tmp[0], "wraw") == 0) { + if ((tmp[1] == NULL) || (tmp[2] == NULL)) { + err = -EINVAL; + goto exit; + } + + addr = simple_strtoul(tmp[1], &ptmp, 16); + addr &= 0xFFF; + + cnts = strlen(tmp[2]); + if (cnts%2) { + err = -EINVAL; + goto exit; + } + cnts /= 2; + if (cnts == 0) { + err = -EINVAL; + goto exit; + } + + DBG_88E("%s: addr = 0x%X\n", __func__, addr); + DBG_88E("%s: cnts =%d\n", __func__, cnts); + DBG_88E("%s: raw data =%s\n", __func__, tmp[2]); + + for (jj = 0, kk = 0; jj < cnts; jj++, kk += 2) + setrawdata[jj] = key_2char2num(tmp[2][kk], tmp[2][kk + 1]); + + if (rtw_efuse_access(padapter, true, addr, cnts, setrawdata) == _FAIL) { + DBG_88E("%s: rtw_efuse_access error!!\n", __func__); + err = -EFAULT; + goto exit; + } + } else if (strcmp(tmp[0], "mac") == 0) { + if (tmp[1] == NULL) { + err = -EINVAL; + goto exit; + } + + /* mac, 00e04c871200 */ + addr = EEPROM_MAC_ADDR_88EU; + cnts = strlen(tmp[1]); + if (cnts%2) { + err = -EINVAL; + goto exit; + } + cnts /= 2; + if (cnts == 0) { + err = -EINVAL; + goto exit; + } + if (cnts > 6) { + DBG_88E("%s: error data for mac addr =\"%s\"\n", __func__, tmp[1]); + err = -EFAULT; + goto exit; + } + + DBG_88E("%s: addr = 0x%X\n", __func__, addr); + DBG_88E("%s: cnts =%d\n", __func__, cnts); + DBG_88E("%s: MAC address =%s\n", __func__, tmp[1]); + + for (jj = 0, kk = 0; jj < cnts; jj++, kk += 2) + setdata[jj] = key_2char2num(tmp[1][kk], tmp[1][kk + 1]); + /* Change to check TYPE_EFUSE_MAP_LEN, beacuse 8188E raw 256, logic map over 256. */ + EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_EFUSE_MAP_LEN, (void *)&max_available_size, false); + if ((addr+cnts) > max_available_size) { + DBG_88E("%s: addr(0x%X)+cnts(%d) parameter error!\n", __func__, addr, cnts); + err = -EFAULT; + goto exit; + } + + if (rtw_efuse_map_write(padapter, addr, cnts, setdata) == _FAIL) { + DBG_88E("%s: rtw_efuse_map_write error!!\n", __func__); + err = -EFAULT; + goto exit; + } + } else if (strcmp(tmp[0], "vidpid") == 0) { + if (tmp[1] == NULL) { + err = -EINVAL; + goto exit; + } + + /* pidvid, da0b7881 */ + addr = EEPROM_VID_88EE; + cnts = strlen(tmp[1]); + if (cnts%2) { + err = -EINVAL; + goto exit; + } + cnts /= 2; + if (cnts == 0) { + err = -EINVAL; + goto exit; + } + + DBG_88E("%s: addr = 0x%X\n", __func__, addr); + DBG_88E("%s: cnts =%d\n", __func__, cnts); + DBG_88E("%s: VID/PID =%s\n", __func__, tmp[1]); + + for (jj = 0, kk = 0; jj < cnts; jj++, kk += 2) + setdata[jj] = key_2char2num(tmp[1][kk], tmp[1][kk + 1]); + + EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); + if ((addr+cnts) > max_available_size) { + DBG_88E("%s: addr(0x%X)+cnts(%d) parameter error!\n", __func__, addr, cnts); + err = -EFAULT; + goto exit; + } + + if (rtw_efuse_map_write(padapter, addr, cnts, setdata) == _FAIL) { + DBG_88E("%s: rtw_efuse_map_write error!!\n", __func__); + err = -EFAULT; + goto exit; + } + } else if (strcmp(tmp[0], "btwmap") == 0) { + if ((tmp[1] == NULL) || (tmp[2] == NULL)) { + err = -EINVAL; + goto exit; + } + + addr = simple_strtoul(tmp[1], &ptmp, 16); + addr &= 0xFFF; + + cnts = strlen(tmp[2]); + if (cnts%2) { + err = -EINVAL; + goto exit; + } + cnts /= 2; + if (cnts == 0) { + err = -EINVAL; + goto exit; + } + + DBG_88E("%s: addr = 0x%X\n", __func__, addr); + DBG_88E("%s: cnts =%d\n", __func__, cnts); + DBG_88E("%s: BT data =%s\n", __func__, tmp[2]); + + for (jj = 0, kk = 0; jj < cnts; jj++, kk += 2) + setdata[jj] = key_2char2num(tmp[2][kk], tmp[2][kk + 1]); + + EFUSE_GetEfuseDefinition(padapter, EFUSE_BT, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); + if ((addr+cnts) > max_available_size) { + DBG_88E("%s: addr(0x%X)+cnts(%d) parameter error!\n", __func__, addr, cnts); + err = -EFAULT; + goto exit; + } + + if (rtw_BT_efuse_map_write(padapter, addr, cnts, setdata) == _FAIL) { + DBG_88E("%s: rtw_BT_efuse_map_write error!!\n", __func__); + err = -EFAULT; + goto exit; + } + } else if (strcmp(tmp[0], "btwfake") == 0) { + if ((tmp[1] == NULL) || (tmp[2] == NULL)) { + err = -EINVAL; + goto exit; + } + + addr = simple_strtoul(tmp[1], &ptmp, 16); + addr &= 0xFFF; + + cnts = strlen(tmp[2]); + if (cnts%2) { + err = -EINVAL; + goto exit; + } + cnts /= 2; + if (cnts == 0) { + err = -EINVAL; + goto exit; + } + + DBG_88E("%s: addr = 0x%X\n", __func__, addr); + DBG_88E("%s: cnts =%d\n", __func__, cnts); + DBG_88E("%s: BT tmp data =%s\n", __func__, tmp[2]); + + for (jj = 0, kk = 0; jj < cnts; jj++, kk += 2) + pEfuseHal->fakeBTEfuseModifiedMap[addr+jj] = key_2char2num(tmp[2][kk], tmp[2][kk + 1]); + } else if (strcmp(tmp[0], "btdumpfake") == 0) { + if (rtw_BT_efuse_map_read(padapter, 0, EFUSE_BT_MAX_MAP_LEN, pEfuseHal->fakeBTEfuseModifiedMap) == _SUCCESS) { + DBG_88E("%s: BT read all map success\n", __func__); + } else { + DBG_88E("%s: BT read all map Fail!\n", __func__); + err = -EFAULT; + } + } else if (strcmp(tmp[0], "wldumpfake") == 0) { + if (rtw_efuse_map_read(padapter, 0, EFUSE_BT_MAX_MAP_LEN, pEfuseHal->fakeEfuseModifiedMap) == _SUCCESS) { + DBG_88E("%s: BT read all map success\n", __func__); + } else { + DBG_88E("%s: BT read all map Fail\n", __func__); + err = -EFAULT; + } + } else if (strcmp(tmp[0], "btfk2map") == 0) { + memcpy(pEfuseHal->BTEfuseModifiedMap, pEfuseHal->fakeBTEfuseModifiedMap, EFUSE_BT_MAX_MAP_LEN); + + EFUSE_GetEfuseDefinition(padapter, EFUSE_BT, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); + if (max_available_size < 1) { + err = -EFAULT; + goto exit; + } + + if (rtw_BT_efuse_map_write(padapter, 0x00, EFUSE_BT_MAX_MAP_LEN, pEfuseHal->fakeBTEfuseModifiedMap) == _FAIL) { + DBG_88E("%s: rtw_BT_efuse_map_write error!\n", __func__); + err = -EFAULT; + goto exit; + } + } else if (strcmp(tmp[0], "wlfk2map") == 0) { + EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); + if (max_available_size < 1) { + err = -EFAULT; + goto exit; + } + + if (rtw_efuse_map_write(padapter, 0x00, EFUSE_MAX_MAP_LEN, pEfuseHal->fakeEfuseModifiedMap) == _FAIL) { + DBG_88E("%s: rtw_efuse_map_write error!\n", __func__); + err = -EFAULT; + goto exit; + } + } else if (strcmp(tmp[0], "wlwfake") == 0) { + if ((tmp[1] == NULL) || (tmp[2] == NULL)) { + err = -EINVAL; + goto exit; + } + + addr = simple_strtoul(tmp[1], &ptmp, 16); + addr &= 0xFFF; + + cnts = strlen(tmp[2]); + if (cnts%2) { + err = -EINVAL; + goto exit; + } + cnts /= 2; + if (cnts == 0) { + err = -EINVAL; + goto exit; + } + + DBG_88E("%s: addr = 0x%X\n", __func__, addr); + DBG_88E("%s: cnts =%d\n", __func__, cnts); + DBG_88E("%s: map tmp data =%s\n", __func__, tmp[2]); + + for (jj = 0, kk = 0; jj < cnts; jj++, kk += 2) + pEfuseHal->fakeEfuseModifiedMap[addr+jj] = key_2char2num(tmp[2][kk], tmp[2][kk + 1]); + } + +exit: + kfree(setdata); + kfree(ShadowMapBT); + kfree(ShadowMapWiFi); + kfree(setrawdata); + + rtw_pm_set_ips(padapter, ips_mode); + rtw_pm_set_lps(padapter, lps_mode); + + return err; +} + +/* + * Input Format: %s,%d,%d + * %s is width, could be + * "b" for 1 byte + * "w" for WORD (2 bytes) + * "dw" for DWORD (4 bytes) + * 1st %d is address(offset) + * 2st %d is data to write + */ +static int rtw_mp_write_reg(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *wrqu, char *extra) +{ + char *pch, *pnext, *ptmp; + char *width_str; + char width; + u32 addr, data; + int ret; + struct adapter *padapter = rtw_netdev_priv(dev); + + pch = extra; + pnext = strpbrk(pch, ",.-"); + if (pnext == NULL) + return -EINVAL; + *pnext = 0; + width_str = pch; + + pch = pnext + 1; + pnext = strpbrk(pch, ",.-"); + if (pnext == NULL) + return -EINVAL; + *pnext = 0; + addr = simple_strtoul(pch, &ptmp, 16); + if (addr > 0x3FFF) + return -EINVAL; + + pch = pnext + 1; + if ((pch - extra) >= wrqu->length) + return -EINVAL; + data = simple_strtoul(pch, &ptmp, 16); + + ret = 0; + width = width_str[0]; + switch (width) { + case 'b': + /* 1 byte */ + if (data > 0xFF) { + ret = -EINVAL; + break; + } + rtw_write8(padapter, addr, data); + break; + case 'w': + /* 2 bytes */ + if (data > 0xFFFF) { + ret = -EINVAL; + break; + } + rtw_write16(padapter, addr, data); + break; + case 'd': + /* 4 bytes */ + rtw_write32(padapter, addr, data); + break; + default: + ret = -EINVAL; + break; + } + + return ret; +} + +/* + * Input Format: %s,%d + * %s is width, could be + * "b" for 1 byte + * "w" for WORD (2 bytes) + * "dw" for DWORD (4 bytes) + * %d is address(offset) + * + * Return: + * %d for data readed + */ +static int rtw_mp_read_reg(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *wrqu, char *extra) +{ + struct adapter *padapter = rtw_netdev_priv(dev); + char *input = kmalloc(wrqu->length, GFP_KERNEL); + char *pch, *pnext, *ptmp; + char *width_str; + char width; + char data[20], tmp[20]; + u32 addr; + u32 ret, i = 0, j = 0, strtout = 0; + + if (!input) + return -ENOMEM; + if (copy_from_user(input, wrqu->pointer, wrqu->length)) { + kfree(input); + return -EFAULT; + } + _rtw_memset(data, 0, 20); + _rtw_memset(tmp, 0, 20); + _rtw_memset(extra, 0, wrqu->length); + + pch = input; + pnext = strpbrk(pch, ",.-"); + if (pnext == NULL) { + kfree(input); + return -EINVAL; + } + *pnext = 0; + width_str = pch; + + pch = pnext + 1; + if ((pch - input) >= wrqu->length) { + kfree(input); + return -EINVAL; + } + kfree(input); + addr = simple_strtoul(pch, &ptmp, 16); + if (addr > 0x3FFF) + return -EINVAL; + + ret = 0; + width = width_str[0]; + switch (width) { + case 'b': + /* 1 byte */ + sprintf(extra, "%d\n", rtw_read8(padapter, addr)); + wrqu->length = strlen(extra); + break; + case 'w': + /* 2 bytes */ + sprintf(data, "%04x\n", rtw_read16(padapter, addr)); + for (i = 0; i <= strlen(data); i++) { + if (i%2 == 0) { + tmp[j] = ' '; + j++; + } + if (data[i] != '\0') + tmp[j] = data[i]; + j++; + } + pch = tmp; + DBG_88E("pch =%s", pch); + + while (*pch != '\0') { + pnext = strpbrk(pch, " "); + if (!pnext) + break; + + pnext++; + if (*pnext != '\0') { + strtout = simple_strtoul(pnext, &ptmp, 16); + sprintf(extra, "%s %d", extra, strtout); + } else { + break; + } + pch = pnext; + } + wrqu->length = 6; + break; + case 'd': + /* 4 bytes */ + sprintf(data, "%08x", rtw_read32(padapter, addr)); + /* add read data format blank */ + for (i = 0; i <= strlen(data); i++) { + if (i%2 == 0) { + tmp[j] = ' '; + j++; + } + if (data[i] != '\0') + tmp[j] = data[i]; + + j++; + } + pch = tmp; + DBG_88E("pch =%s", pch); + + while (*pch != '\0') { + pnext = strpbrk(pch, " "); + if (!pnext) + break; + pnext++; + if (*pnext != '\0') { + strtout = simple_strtoul(pnext, &ptmp, 16); + sprintf(extra, "%s %d", extra, strtout); + } else { + break; + } + pch = pnext; + } + wrqu->length = strlen(extra); + break; + default: + wrqu->length = 0; + ret = -EINVAL; + break; + } + + return ret; +} + +/* + * Input Format: %d,%x,%x + * %d is RF path, should be smaller than MAX_RF_PATH_NUMS + * 1st %x is address(offset) + * 2st %x is data to write + */ + static int rtw_mp_write_rf(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *wrqu, char *extra) +{ + u32 path, addr, data; + int ret; + struct adapter *padapter = rtw_netdev_priv(dev); + + ret = sscanf(extra, "%d,%x,%x", &path, &addr, &data); + if (ret < 3) + return -EINVAL; + + if (path >= MAX_RF_PATH_NUMS) + return -EINVAL; + if (addr > 0xFF) + return -EINVAL; + if (data > 0xFFFFF) + return -EINVAL; + + _rtw_memset(extra, 0, wrqu->length); + + write_rfreg(padapter, path, addr, data); + + sprintf(extra, "write_rf completed\n"); + wrqu->length = strlen(extra); + + return 0; +} + +/* + * Input Format: %d,%x + * %d is RF path, should be smaller than MAX_RF_PATH_NUMS + * %x is address(offset) + * + * Return: + * %d for data readed + */ +static int rtw_mp_read_rf(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *wrqu, char *extra) +{ + char *input = kmalloc(wrqu->length, GFP_KERNEL); + char *pch, *pnext, *ptmp; + char data[20], tmp[20]; + u32 path, addr; + u32 ret, i = 0, j = 0, strtou = 0; + struct adapter *padapter = rtw_netdev_priv(dev); + + if (!input) + return -ENOMEM; + if (copy_from_user(input, wrqu->pointer, wrqu->length)) { + kfree(input); + return -EFAULT; + } + ret = sscanf(input, "%d,%x", &path, &addr); + kfree(input); + if (ret < 2) + return -EINVAL; + + if (path >= MAX_RF_PATH_NUMS) + return -EINVAL; + if (addr > 0xFF) + return -EINVAL; + + _rtw_memset(extra, 0, wrqu->length); + + sprintf(data, "%08x", read_rfreg(padapter, path, addr)); + /* add read data format blank */ + for (i = 0; i <= strlen(data); i++) { + if (i%2 == 0) { + tmp[j] = ' '; + j++; + } + tmp[j] = data[i]; + j++; + } + pch = tmp; + DBG_88E("pch =%s", pch); + + while (*pch != '\0') { + pnext = strpbrk(pch, " "); + pnext++; + if (*pnext != '\0') { + strtou = simple_strtoul(pnext, &ptmp, 16); + sprintf(extra, "%s %d", extra, strtou); + } else { + break; + } + pch = pnext; + } + wrqu->length = strlen(extra); + return 0; +} + +static int rtw_mp_start(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *wrqu, char *extra) +{ + struct adapter *padapter = rtw_netdev_priv(dev); + + if (padapter->registrypriv.mp_mode == 0) { + padapter->registrypriv.mp_mode = 1; + + rtw_pm_set_ips(padapter, IPS_NONE); + LeaveAllPowerSaveMode(padapter); + + MPT_InitializeAdapter(padapter, 1); + } + if (padapter->registrypriv.mp_mode == 0) + return -EPERM; + if (padapter->mppriv.mode == MP_OFF) { + if (mp_start_test(padapter) == _FAIL) + return -EPERM; + padapter->mppriv.mode = MP_ON; + } + return 0; +} + +static int rtw_mp_stop(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *wrqu, char *extra) +{ + struct adapter *padapter = rtw_netdev_priv(dev); + + if (padapter->registrypriv.mp_mode == 1) { + MPT_DeInitAdapter(padapter); + padapter->registrypriv.mp_mode = 0; + } + + if (padapter->mppriv.mode != MP_OFF) { + mp_stop_test(padapter); + padapter->mppriv.mode = MP_OFF; + } + + return 0; +} + +extern int wifirate2_ratetbl_inx(unsigned char rate); + +static int rtw_mp_rate(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *wrqu, char *extra) +{ + u32 rate = MPT_RATE_1M; + char *input = kmalloc(wrqu->length, GFP_KERNEL); + struct adapter *padapter = rtw_netdev_priv(dev); + + if (!input) + return -ENOMEM; + if (copy_from_user(input, wrqu->pointer, wrqu->length)) { + kfree(input); + return -EFAULT; + } + rate = rtw_atoi(input); + sprintf(extra, "Set data rate to %d", rate); + kfree(input); + if (rate <= 0x7f) + rate = wifirate2_ratetbl_inx((u8)rate); + else + rate = (rate-0x80+MPT_RATE_MCS0); + + if (rate >= MPT_RATE_LAST) + return -EINVAL; + + padapter->mppriv.rateidx = rate; + Hal_SetDataRate(padapter); + + wrqu->length = strlen(extra) + 1; + return 0; +} + +static int rtw_mp_channel(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *wrqu, char *extra) +{ + struct adapter *padapter = rtw_netdev_priv(dev); + char *input = kmalloc(wrqu->length, GFP_KERNEL); + u32 channel = 1; + + if (!input) + return -ENOMEM; + if (copy_from_user(input, wrqu->pointer, wrqu->length)) { + kfree(input); + return -EFAULT; + } + channel = rtw_atoi(input); + sprintf(extra, "Change channel %d to channel %d", padapter->mppriv.channel, channel); + + padapter->mppriv.channel = channel; + Hal_SetChannel(padapter); + + wrqu->length = strlen(extra) + 1; + kfree(input); + return 0; +} + +static int rtw_mp_bandwidth(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *wrqu, char *extra) +{ + u32 bandwidth = 0, sg = 0; + struct adapter *padapter = rtw_netdev_priv(dev); + + sscanf(extra, "40M =%d, shortGI =%d", &bandwidth, &sg); + + if (bandwidth != HT_CHANNEL_WIDTH_40) + bandwidth = HT_CHANNEL_WIDTH_20; + + padapter->mppriv.bandwidth = (u8)bandwidth; + padapter->mppriv.preamble = sg; + + SetBandwidth(padapter); + + return 0; +} + +static int rtw_mp_txpower(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *wrqu, char *extra) +{ + u32 idx_a = 0, idx_b = 0; + char *input = kmalloc(wrqu->length, GFP_KERNEL); + struct adapter *padapter = rtw_netdev_priv(dev); + + if (!input) + return -ENOMEM; + if (copy_from_user(input, wrqu->pointer, wrqu->length)) { + kfree(input); + return -EFAULT; + } + sscanf(input, "patha =%d, pathb =%d", &idx_a, &idx_b); + + sprintf(extra, "Set power level path_A:%d path_B:%d", idx_a, idx_b); + padapter->mppriv.txpoweridx = (u8)idx_a; + padapter->mppriv.txpoweridx_b = (u8)idx_b; + padapter->mppriv.bSetTxPower = 1; + Hal_SetAntennaPathPower(padapter); + + wrqu->length = strlen(extra) + 1; + kfree(input); + return 0; +} + +static int rtw_mp_ant_tx(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *wrqu, char *extra) +{ + u8 i; + char *input = kmalloc(wrqu->length, GFP_KERNEL); + u16 antenna = 0; + struct adapter *padapter = rtw_netdev_priv(dev); + + if (!input) + return -ENOMEM; + if (copy_from_user(input, wrqu->pointer, wrqu->length)) { + kfree(input); + return -EFAULT; + } + + sprintf(extra, "switch Tx antenna to %s", input); + + for (i = 0; i < strlen(input); i++) { + switch (input[i]) { + case 'a': + antenna |= ANTENNA_A; + break; + case 'b': + antenna |= ANTENNA_B; + break; + } + } + padapter->mppriv.antenna_tx = antenna; + + Hal_SetAntenna(padapter); + + wrqu->length = strlen(extra) + 1; + kfree(input); + return 0; +} + +static int rtw_mp_ant_rx(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *wrqu, char *extra) +{ + u8 i; + u16 antenna = 0; + char *input = kmalloc(wrqu->length, GFP_KERNEL); + struct adapter *padapter = rtw_netdev_priv(dev); + + if (!input) + return -ENOMEM; + if (copy_from_user(input, wrqu->pointer, wrqu->length)) { + kfree(input); + return -EFAULT; + } + _rtw_memset(extra, 0, wrqu->length); + + sprintf(extra, "switch Rx antenna to %s", input); + + for (i = 0; i < strlen(input); i++) { + switch (input[i]) { + case 'a': + antenna |= ANTENNA_A; + break; + case 'b': + antenna |= ANTENNA_B; + break; + } + } + + padapter->mppriv.antenna_rx = antenna; + Hal_SetAntenna(padapter); + wrqu->length = strlen(extra); + kfree(input); + return 0; +} + +static int rtw_mp_ctx(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *wrqu, char *extra) +{ + u32 pkTx = 1, countPkTx = 1, cotuTx = 1, CarrSprTx = 1, scTx = 1, sgleTx = 1, stop = 1; + u32 bStartTest = 1; + u32 count = 0; + struct mp_priv *pmp_priv; + struct pkt_attrib *pattrib; + + struct adapter *padapter = rtw_netdev_priv(dev); + + pmp_priv = &padapter->mppriv; + + if (copy_from_user(extra, wrqu->pointer, wrqu->length)) + return -EFAULT; + + DBG_88E("%s: in =%s\n", __func__, extra); + + countPkTx = strncmp(extra, "count =", 5); /* strncmp true is 0 */ + cotuTx = strncmp(extra, "background", 20); + CarrSprTx = strncmp(extra, "background, cs", 20); + scTx = strncmp(extra, "background, sc", 20); + sgleTx = strncmp(extra, "background, stone", 20); + pkTx = strncmp(extra, "background, pkt", 20); + stop = strncmp(extra, "stop", 4); + sscanf(extra, "count =%d, pkt", &count); + + _rtw_memset(extra, '\0', sizeof(extra)); + + if (stop == 0) { + bStartTest = 0; /* To set Stop */ + pmp_priv->tx.stop = 1; + sprintf(extra, "Stop continuous Tx"); + } else { + bStartTest = 1; + if (pmp_priv->mode != MP_ON) { + if (pmp_priv->tx.stop != 1) { + DBG_88E("%s: MP_MODE != ON %d\n", __func__, pmp_priv->mode); + return -EFAULT; + } + } + } + + if (pkTx == 0 || countPkTx == 0) + pmp_priv->mode = MP_PACKET_TX; + if (sgleTx == 0) + pmp_priv->mode = MP_SINGLE_TONE_TX; + if (cotuTx == 0) + pmp_priv->mode = MP_CONTINUOUS_TX; + if (CarrSprTx == 0) + pmp_priv->mode = MP_CARRIER_SUPPRISSION_TX; + if (scTx == 0) + pmp_priv->mode = MP_SINGLE_CARRIER_TX; + + switch (pmp_priv->mode) { + case MP_PACKET_TX: + if (bStartTest == 0) { + pmp_priv->tx.stop = 1; + pmp_priv->mode = MP_ON; + sprintf(extra, "Stop continuous Tx"); + } else if (pmp_priv->tx.stop == 1) { + sprintf(extra, "Start continuous DA = ffffffffffff len = 1500 count =%u,\n", count); + pmp_priv->tx.stop = 0; + pmp_priv->tx.count = count; + pmp_priv->tx.payload = 2; + pattrib = &pmp_priv->tx.attrib; + pattrib->pktlen = 1500; + _rtw_memset(pattrib->dst, 0xFF, ETH_ALEN); + SetPacketTx(padapter); + } else { + return -EFAULT; + } + wrqu->length = strlen(extra); + return 0; + case MP_SINGLE_TONE_TX: + if (bStartTest != 0) + sprintf(extra, "Start continuous DA = ffffffffffff len = 1500\n infinite = yes."); + Hal_SetSingleToneTx(padapter, (u8)bStartTest); + break; + case MP_CONTINUOUS_TX: + if (bStartTest != 0) + sprintf(extra, "Start continuous DA = ffffffffffff len = 1500\n infinite = yes."); + Hal_SetContinuousTx(padapter, (u8)bStartTest); + break; + case MP_CARRIER_SUPPRISSION_TX: + if (bStartTest != 0) { + if (pmp_priv->rateidx <= MPT_RATE_11M) { + sprintf(extra, "Start continuous DA = ffffffffffff len = 1500\n infinite = yes."); + Hal_SetCarrierSuppressionTx(padapter, (u8)bStartTest); + } else { + sprintf(extra, "Specify carrier suppression but not CCK rate"); + } + } + break; + case MP_SINGLE_CARRIER_TX: + if (bStartTest != 0) + sprintf(extra, "Start continuous DA = ffffffffffff len = 1500\n infinite = yes."); + Hal_SetSingleCarrierTx(padapter, (u8)bStartTest); + break; + default: + sprintf(extra, "Error! Continuous-Tx is not on-going."); + return -EFAULT; + } + + if (bStartTest == 1 && pmp_priv->mode != MP_ON) { + struct mp_priv *pmp_priv = &padapter->mppriv; + if (pmp_priv->tx.stop == 0) { + pmp_priv->tx.stop = 1; + rtw_msleep_os(5); + } + pmp_priv->tx.stop = 0; + pmp_priv->tx.count = 1; + SetPacketTx(padapter); + } else { + pmp_priv->mode = MP_ON; + } + + wrqu->length = strlen(extra); + return 0; +} + +static int rtw_mp_arx(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *wrqu, char *extra) +{ + u8 bStartRx = 0, bStopRx = 0, bQueryPhy; + u32 cckok = 0, cckcrc = 0, ofdmok = 0, ofdmcrc = 0, htok = 0, htcrc = 0, OFDM_FA = 0, CCK_FA = 0; + char *input = kmalloc(wrqu->length, GFP_KERNEL); + struct adapter *padapter = rtw_netdev_priv(dev); + + if (!input) + return -ENOMEM; + + if (copy_from_user(input, wrqu->pointer, wrqu->length)) { + kfree(input); + return -EFAULT; + } + DBG_88E("%s: %s\n", __func__, input); + + bStartRx = (strncmp(input, "start", 5) == 0) ? 1 : 0; /* strncmp true is 0 */ + bStopRx = (strncmp(input, "stop", 5) == 0) ? 1 : 0; /* strncmp true is 0 */ + bQueryPhy = (strncmp(input, "phy", 3) == 0) ? 1 : 0; /* strncmp true is 0 */ + + if (bStartRx) { + sprintf(extra, "start"); + SetPacketRx(padapter, bStartRx); + } else if (bStopRx) { + SetPacketRx(padapter, 0); + sprintf(extra, "Received packet OK:%d CRC error:%d", padapter->mppriv.rx_pktcount, padapter->mppriv.rx_crcerrpktcount); + } else if (bQueryPhy) { + /* + OFDM FA + RegCF0[15:0] + RegCF2[31:16] + RegDA0[31:16] + RegDA4[15:0] + RegDA4[31:16] + RegDA8[15:0] + CCK FA + (RegA5B<<8) | RegA5C + */ + cckok = read_bbreg(padapter, 0xf88, 0xffffffff); + cckcrc = read_bbreg(padapter, 0xf84, 0xffffffff); + ofdmok = read_bbreg(padapter, 0xf94, 0x0000FFFF); + ofdmcrc = read_bbreg(padapter, 0xf94, 0xFFFF0000); + htok = read_bbreg(padapter, 0xf90, 0x0000FFFF); + htcrc = read_bbreg(padapter, 0xf90, 0xFFFF0000); + + OFDM_FA = read_bbreg(padapter, 0xcf0, 0x0000FFFF); + OFDM_FA = read_bbreg(padapter, 0xcf2, 0xFFFF0000); + OFDM_FA = read_bbreg(padapter, 0xda0, 0xFFFF0000); + OFDM_FA = read_bbreg(padapter, 0xda4, 0x0000FFFF); + OFDM_FA = read_bbreg(padapter, 0xda4, 0xFFFF0000); + OFDM_FA = read_bbreg(padapter, 0xda8, 0x0000FFFF); + CCK_FA = (rtw_read8(padapter, 0xa5b)<<8) | (rtw_read8(padapter, 0xa5c)); + + sprintf(extra, "Phy Received packet OK:%d CRC error:%d FA Counter: %d", cckok+ofdmok+htok, cckcrc+ofdmcrc+htcrc, OFDM_FA+CCK_FA); + } + wrqu->length = strlen(extra) + 1; + kfree(input); + return 0; +} + +static int rtw_mp_trx_query(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *wrqu, char *extra) +{ + u32 txok, txfail, rxok, rxfail; + struct adapter *padapter = rtw_netdev_priv(dev); + + txok = padapter->mppriv.tx.sended; + txfail = 0; + rxok = padapter->mppriv.rx_pktcount; + rxfail = padapter->mppriv.rx_crcerrpktcount; + + _rtw_memset(extra, '\0', 128); + + sprintf(extra, "Tx OK:%d, Tx Fail:%d, Rx OK:%d, CRC error:%d ", txok, txfail, rxok, rxfail); + + wrqu->length = strlen(extra)+1; + + return 0; +} + +static int rtw_mp_pwrtrk(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *wrqu, char *extra) +{ + u8 enable; + u32 thermal; + s32 ret; + struct adapter *padapter = rtw_netdev_priv(dev); + char *input = kmalloc(wrqu->length, GFP_KERNEL); + + if (!input) + return -ENOMEM; + if (copy_from_user(input, wrqu->pointer, wrqu->length)) { + kfree(input); + return -EFAULT; + } + _rtw_memset(extra, 0, wrqu->length); + + enable = 1; + if (wrqu->length > 1) {/* not empty string */ + if (strncmp(input, "stop", 4) == 0) { + enable = 0; + sprintf(extra, "mp tx power tracking stop"); + } else if (sscanf(input, "ther =%d", &thermal)) { + ret = Hal_SetThermalMeter(padapter, (u8)thermal); + if (ret == _FAIL) + return -EPERM; + sprintf(extra, "mp tx power tracking start, target value =%d ok ", thermal); + } else { + kfree(input); + return -EINVAL; + } + } + + kfree(input); + ret = Hal_SetPowerTracking(padapter, enable); + if (ret == _FAIL) + return -EPERM; + + wrqu->length = strlen(extra); + return 0; +} + +static int rtw_mp_psd(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *wrqu, char *extra) +{ + struct adapter *padapter = rtw_netdev_priv(dev); + char *input = kmalloc(wrqu->length, GFP_KERNEL); + + if (!input) + return -ENOMEM; + if (copy_from_user(input, wrqu->pointer, wrqu->length)) { + kfree(input); + return -EFAULT; + } + + strcpy(extra, input); + + wrqu->length = mp_query_psd(padapter, extra); + kfree(input); + return 0; +} + +static int rtw_mp_thermal(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *wrqu, char *extra) +{ + u8 val; + u16 bwrite = 1; + u16 addr = EEPROM_THERMAL_METER_88E; + + u16 cnt = 1; + u16 max_available_size = 0; + struct adapter *padapter = rtw_netdev_priv(dev); + + if (copy_from_user(extra, wrqu->pointer, wrqu->length)) + return -EFAULT; + + bwrite = strncmp(extra, "write", 6); /* strncmp true is 0 */ + + Hal_GetThermalMeter(padapter, &val); + + if (bwrite == 0) { + EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); + if (2 > max_available_size) { + DBG_88E("no available efuse!\n"); + return -EFAULT; + } + if (rtw_efuse_map_write(padapter, addr, cnt, &val) == _FAIL) { + DBG_88E("rtw_efuse_map_write error\n"); + return -EFAULT; + } else { + sprintf(extra, " efuse write ok :%d", val); + } + } else { + sprintf(extra, "%d", val); + } + wrqu->length = strlen(extra); + + return 0; +} + +static int rtw_mp_reset_stats(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *wrqu, char *extra) +{ + struct mp_priv *pmp_priv; + struct adapter *padapter = rtw_netdev_priv(dev); + + pmp_priv = &padapter->mppriv; + + pmp_priv->tx.sended = 0; + pmp_priv->tx_pktcount = 0; + pmp_priv->rx_pktcount = 0; + pmp_priv->rx_crcerrpktcount = 0; + + /* reset phy counter */ + write_bbreg(padapter, 0xf14, BIT16, 0x1); + rtw_msleep_os(10); + write_bbreg(padapter, 0xf14, BIT16, 0x0); + + return 0; +} + +static int rtw_mp_dump(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *wrqu, char *extra) +{ + u32 value; + u8 rf_type, path_nums = 0; + u32 i, j = 1, path; + struct adapter *padapter = rtw_netdev_priv(dev); + + if (strncmp(extra, "all", 4) == 0) { + DBG_88E("\n ======= MAC REG =======\n"); + for (i = 0x0; i < 0x300; i += 4) { + if (j%4 == 1) + DBG_88E("0x%02x", i); + DBG_88E(" 0x%08x ", rtw_read32(padapter, i)); + if ((j++)%4 == 0) + DBG_88E("\n"); + } + for (i = 0x400; i < 0x1000; i += 4) { + if (j%4 == 1) + DBG_88E("0x%02x", i); + DBG_88E(" 0x%08x ", rtw_read32(padapter, i)); + if ((j++)%4 == 0) + DBG_88E("\n"); + } + + j = 1; + rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); + + DBG_88E("\n ======= RF REG =======\n"); + if ((RF_1T2R == rf_type) || (RF_1T1R == rf_type)) + path_nums = 1; + else + path_nums = 2; + + for (path = 0; path < path_nums; path++) { + for (i = 0; i < 0x34; i++) { + value = rtw_hal_read_rfreg(padapter, path, i, 0xffffffff); + if (j%4 == 1) + DBG_88E("0x%02x ", i); + DBG_88E(" 0x%08x ", value); + if ((j++)%4 == 0) + DBG_88E("\n"); + } + } + } + return 0; +} + +static int rtw_mp_phypara(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *wrqu, char *extra) +{ + char *input = kmalloc(wrqu->length, GFP_KERNEL); + u32 valxcap; + + if (!input) + return -ENOMEM; + if (copy_from_user(input, wrqu->pointer, wrqu->length)) { + kfree(input); + return -EFAULT; + } + + DBG_88E("%s:iwpriv in =%s\n", __func__, input); + + sscanf(input, "xcap =%d", &valxcap); + + kfree(input); + return 0; +} + +static int rtw_mp_SetRFPath(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct adapter *padapter = rtw_netdev_priv(dev); + char *input = kmalloc(wrqu->data.length, GFP_KERNEL); + u8 bMain = 1, bTurnoff = 1; + + if (!input) + return -ENOMEM; + if (copy_from_user(input, wrqu->data.pointer, wrqu->data.length)) + return -EFAULT; + DBG_88E("%s:iwpriv in =%s\n", __func__, input); + + bMain = strncmp(input, "1", 2); /* strncmp true is 0 */ + bTurnoff = strncmp(input, "0", 3); /* strncmp true is 0 */ + + if (bMain == 0) { + MP_PHY_SetRFPathSwitch(padapter, true); + DBG_88E("%s:PHY_SetRFPathSwitch = true\n", __func__); + } else if (bTurnoff == 0) { + MP_PHY_SetRFPathSwitch(padapter, false); + DBG_88E("%s:PHY_SetRFPathSwitch = false\n", __func__); + } + kfree(input); + return 0; +} + +static int rtw_mp_QueryDrv(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct adapter *padapter = rtw_netdev_priv(dev); + char *input = kmalloc(wrqu->data.length, GFP_KERNEL); + u8 qAutoLoad = 1; + struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter); + + if (!input) + return -ENOMEM; + + if (copy_from_user(input, wrqu->data.pointer, wrqu->data.length)) + return -EFAULT; + DBG_88E("%s:iwpriv in =%s\n", __func__, input); + + qAutoLoad = strncmp(input, "autoload", 8); /* strncmp true is 0 */ + + if (qAutoLoad == 0) { + DBG_88E("%s:qAutoLoad\n", __func__); + + if (pEEPROM->bautoload_fail_flag) + sprintf(extra, "fail"); + else + sprintf(extra, "ok"); + } + wrqu->data.length = strlen(extra) + 1; + kfree(input); + return 0; +} + +static int rtw_mp_set(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wdata, char *extra) +{ + struct iw_point *wrqu = (struct iw_point *)wdata; + u32 subcmd = wrqu->flags; + struct adapter *padapter = rtw_netdev_priv(dev); + + if (padapter == NULL) + return -ENETDOWN; + + if (extra == NULL) { + wrqu->length = 0; + return -EIO; + } + + switch (subcmd) { + case MP_START: + DBG_88E("set case mp_start\n"); + rtw_mp_start(dev, info, wrqu, extra); + break; + case MP_STOP: + DBG_88E("set case mp_stop\n"); + rtw_mp_stop(dev, info, wrqu, extra); + break; + case MP_BANDWIDTH: + DBG_88E("set case mp_bandwidth\n"); + rtw_mp_bandwidth(dev, info, wrqu, extra); + break; + case MP_RESET_STATS: + DBG_88E("set case MP_RESET_STATS\n"); + rtw_mp_reset_stats(dev, info, wrqu, extra); + break; + case MP_SetRFPathSwh: + DBG_88E("set MP_SetRFPathSwitch\n"); + rtw_mp_SetRFPath(dev, info, wdata, extra); + break; + case CTA_TEST: + DBG_88E("set CTA_TEST\n"); + rtw_cta_test_start(dev, info, wdata, extra); + break; + } + + return 0; +} + +static int rtw_mp_get(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wdata, char *extra) +{ + struct iw_point *wrqu = (struct iw_point *)wdata; + u32 subcmd = wrqu->flags; + struct adapter *padapter = rtw_netdev_priv(dev); + + if (padapter == NULL) + return -ENETDOWN; + if (extra == NULL) { + wrqu->length = 0; + return -EIO; + } + + switch (subcmd) { + case WRITE_REG: + rtw_mp_write_reg(dev, info, wrqu, extra); + break; + case WRITE_RF: + rtw_mp_write_rf(dev, info, wrqu, extra); + break; + case MP_PHYPARA: + DBG_88E("mp_get MP_PHYPARA\n"); + rtw_mp_phypara(dev, info, wrqu, extra); + break; + case MP_CHANNEL: + DBG_88E("set case mp_channel\n"); + rtw_mp_channel(dev, info, wrqu, extra); + break; + case READ_REG: + DBG_88E("mp_get READ_REG\n"); + rtw_mp_read_reg(dev, info, wrqu, extra); + break; + case READ_RF: + DBG_88E("mp_get READ_RF\n"); + rtw_mp_read_rf(dev, info, wrqu, extra); + break; + case MP_RATE: + DBG_88E("set case mp_rate\n"); + rtw_mp_rate(dev, info, wrqu, extra); + break; + case MP_TXPOWER: + DBG_88E("set case MP_TXPOWER\n"); + rtw_mp_txpower(dev, info, wrqu, extra); + break; + case MP_ANT_TX: + DBG_88E("set case MP_ANT_TX\n"); + rtw_mp_ant_tx(dev, info, wrqu, extra); + break; + case MP_ANT_RX: + DBG_88E("set case MP_ANT_RX\n"); + rtw_mp_ant_rx(dev, info, wrqu, extra); + break; + case MP_QUERY: + rtw_mp_trx_query(dev, info, wrqu, extra); + break; + case MP_CTX: + DBG_88E("set case MP_CTX\n"); + rtw_mp_ctx(dev, info, wrqu, extra); + break; + case MP_ARX: + DBG_88E("set case MP_ARX\n"); + rtw_mp_arx(dev, info, wrqu, extra); + break; + case EFUSE_GET: + DBG_88E("efuse get EFUSE_GET\n"); + rtw_mp_efuse_get(dev, info, wdata, extra); + break; + case MP_DUMP: + DBG_88E("set case MP_DUMP\n"); + rtw_mp_dump(dev, info, wrqu, extra); + break; + case MP_PSD: + DBG_88E("set case MP_PSD\n"); + rtw_mp_psd(dev, info, wrqu, extra); + break; + case MP_THER: + DBG_88E("set case MP_THER\n"); + rtw_mp_thermal(dev, info, wrqu, extra); + break; + case MP_QueryDrvStats: + DBG_88E("mp_get MP_QueryDrvStats\n"); + rtw_mp_QueryDrv (dev, info, wdata, extra); + break; + case MP_PWRTRK: + DBG_88E("set case MP_PWRTRK\n"); + rtw_mp_pwrtrk(dev, info, wrqu, extra); + break; + case EFUSE_SET: + DBG_88E("set case efuse set\n"); + rtw_mp_efuse_set(dev, info, wdata, extra); + break; + } + + rtw_msleep_os(10); /* delay 5ms for sending pkt before exit adb shell operation */ + return 0; +} + +static int rtw_tdls(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + return 0; +} + +static int rtw_tdls_get(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + return 0; +} + +static int rtw_test( + struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + u32 len; + u8 *pbuf, *pch; + char *ptmp; + u8 *delim = ","; + + DBG_88E("+%s\n", __func__); + len = wrqu->data.length; + + pbuf = (u8 *)rtw_zmalloc(len); + if (pbuf == NULL) { + DBG_88E("%s: no memory!\n", __func__); + return -ENOMEM; + } + + if (copy_from_user(pbuf, wrqu->data.pointer, len)) { + kfree(pbuf); + DBG_88E("%s: copy from user fail!\n", __func__); + return -EFAULT; + } + DBG_88E("%s: string =\"%s\"\n", __func__, pbuf); + + ptmp = (char *)pbuf; + pch = strsep(&ptmp, delim); + if ((pch == NULL) || (strlen(pch) == 0)) { + kfree(pbuf); + DBG_88E("%s: parameter error(level 1)!\n", __func__); + return -EFAULT; + } + kfree(pbuf); + return 0; +} + +static iw_handler rtw_handlers[] = { + NULL, /* SIOCSIWCOMMIT */ + rtw_wx_get_name, /* SIOCGIWNAME */ + dummy, /* SIOCSIWNWID */ + dummy, /* SIOCGIWNWID */ + rtw_wx_set_freq, /* SIOCSIWFREQ */ + rtw_wx_get_freq, /* SIOCGIWFREQ */ + rtw_wx_set_mode, /* SIOCSIWMODE */ + rtw_wx_get_mode, /* SIOCGIWMODE */ + dummy, /* SIOCSIWSENS */ + rtw_wx_get_sens, /* SIOCGIWSENS */ + NULL, /* SIOCSIWRANGE */ + rtw_wx_get_range, /* SIOCGIWRANGE */ + rtw_wx_set_priv, /* SIOCSIWPRIV */ + NULL, /* SIOCGIWPRIV */ + NULL, /* SIOCSIWSTATS */ + NULL, /* SIOCGIWSTATS */ + dummy, /* SIOCSIWSPY */ + dummy, /* SIOCGIWSPY */ + NULL, /* SIOCGIWTHRSPY */ + NULL, /* SIOCWIWTHRSPY */ + rtw_wx_set_wap, /* SIOCSIWAP */ + rtw_wx_get_wap, /* SIOCGIWAP */ + rtw_wx_set_mlme, /* request MLME operation; uses struct iw_mlme */ + dummy, /* SIOCGIWAPLIST -- depricated */ + rtw_wx_set_scan, /* SIOCSIWSCAN */ + rtw_wx_get_scan, /* SIOCGIWSCAN */ + rtw_wx_set_essid, /* SIOCSIWESSID */ + rtw_wx_get_essid, /* SIOCGIWESSID */ + dummy, /* SIOCSIWNICKN */ + rtw_wx_get_nick, /* SIOCGIWNICKN */ + NULL, /* -- hole -- */ + NULL, /* -- hole -- */ + rtw_wx_set_rate, /* SIOCSIWRATE */ + rtw_wx_get_rate, /* SIOCGIWRATE */ + rtw_wx_set_rts, /* SIOCSIWRTS */ + rtw_wx_get_rts, /* SIOCGIWRTS */ + rtw_wx_set_frag, /* SIOCSIWFRAG */ + rtw_wx_get_frag, /* SIOCGIWFRAG */ + dummy, /* SIOCSIWTXPOW */ + dummy, /* SIOCGIWTXPOW */ + dummy, /* SIOCSIWRETRY */ + rtw_wx_get_retry, /* SIOCGIWRETRY */ + rtw_wx_set_enc, /* SIOCSIWENCODE */ + rtw_wx_get_enc, /* SIOCGIWENCODE */ + dummy, /* SIOCSIWPOWER */ + rtw_wx_get_power, /* SIOCGIWPOWER */ + NULL, /*---hole---*/ + NULL, /*---hole---*/ + rtw_wx_set_gen_ie, /* SIOCSIWGENIE */ + NULL, /* SIOCGWGENIE */ + rtw_wx_set_auth, /* SIOCSIWAUTH */ + NULL, /* SIOCGIWAUTH */ + rtw_wx_set_enc_ext, /* SIOCSIWENCODEEXT */ + NULL, /* SIOCGIWENCODEEXT */ + rtw_wx_set_pmkid, /* SIOCSIWPMKSA */ + NULL, /*---hole---*/ +}; + +static const struct iw_priv_args rtw_private_args[] = { + { + SIOCIWFIRSTPRIV + 0x0, + IW_PRIV_TYPE_CHAR | 0x7FF, 0, "write" + }, + { + SIOCIWFIRSTPRIV + 0x1, + IW_PRIV_TYPE_CHAR | 0x7FF, + IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | IFNAMSIZ, "read" + }, + { + SIOCIWFIRSTPRIV + 0x2, 0, 0, "driver_ext" + }, + { + SIOCIWFIRSTPRIV + 0x3, 0, 0, "mp_ioctl" + }, + { + SIOCIWFIRSTPRIV + 0x4, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "apinfo" + }, + { + SIOCIWFIRSTPRIV + 0x5, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "setpid" + }, + { + SIOCIWFIRSTPRIV + 0x6, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "wps_start" + }, + { + SIOCIWFIRSTPRIV + 0x7, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "get_sensitivity" + }, + { + SIOCIWFIRSTPRIV + 0x8, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "wps_prob_req_ie" + }, + { + SIOCIWFIRSTPRIV + 0x9, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "wps_assoc_req_ie" + }, + + { + SIOCIWFIRSTPRIV + 0xA, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "channel_plan" + }, + + { + SIOCIWFIRSTPRIV + 0xB, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "dbg" + }, + { + SIOCIWFIRSTPRIV + 0xC, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "rfw" + }, + { + SIOCIWFIRSTPRIV + 0xD, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | IFNAMSIZ, "rfr" + }, + { + SIOCIWFIRSTPRIV + 0x10, + IW_PRIV_TYPE_CHAR | P2P_PRIVATE_IOCTL_SET_LEN, 0, "p2p_set" + }, + { + SIOCIWFIRSTPRIV + 0x11, + IW_PRIV_TYPE_CHAR | P2P_PRIVATE_IOCTL_SET_LEN, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | P2P_PRIVATE_IOCTL_SET_LEN, "p2p_get" + }, + { + SIOCIWFIRSTPRIV + 0x12, + IW_PRIV_TYPE_CHAR | P2P_PRIVATE_IOCTL_SET_LEN, IW_PRIV_TYPE_CHAR | IFNAMSIZ, "p2p_get2" + }, + {SIOCIWFIRSTPRIV + 0x13, IW_PRIV_TYPE_CHAR | 128, 0, "NULL"}, + { + SIOCIWFIRSTPRIV + 0x14, + IW_PRIV_TYPE_CHAR | 64, 0, "tdls" + }, + { + SIOCIWFIRSTPRIV + 0x15, + IW_PRIV_TYPE_CHAR | P2P_PRIVATE_IOCTL_SET_LEN, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | P2P_PRIVATE_IOCTL_SET_LEN, "tdls_get" + }, + { + SIOCIWFIRSTPRIV + 0x16, + IW_PRIV_TYPE_CHAR | 64, 0, "pm_set" + }, + + {SIOCIWFIRSTPRIV + 0x18, IW_PRIV_TYPE_CHAR | IFNAMSIZ, 0, "rereg_nd_name"}, + + {SIOCIWFIRSTPRIV + 0x1A, IW_PRIV_TYPE_CHAR | 1024, 0, "efuse_set"}, + {SIOCIWFIRSTPRIV + 0x1B, IW_PRIV_TYPE_CHAR | 128, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "efuse_get"}, + {SIOCIWFIRSTPRIV + 0x1D, IW_PRIV_TYPE_CHAR | 40, IW_PRIV_TYPE_CHAR | 0x7FF, "test" + }, + + {SIOCIWFIRSTPRIV + 0x0E, IW_PRIV_TYPE_CHAR | 1024, 0, ""}, /* set */ + {SIOCIWFIRSTPRIV + 0x0F, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, ""},/* get */ +/* --- sub-ioctls definitions --- */ + + {MP_START, IW_PRIV_TYPE_CHAR | 1024, 0, "mp_start"}, /* set */ + {MP_PHYPARA, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_phypara"},/* get */ + {MP_STOP, IW_PRIV_TYPE_CHAR | 1024, 0, "mp_stop"}, /* set */ + {MP_CHANNEL, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_channel"},/* get */ + {MP_BANDWIDTH, IW_PRIV_TYPE_CHAR | 1024, 0, "mp_bandwidth"}, /* set */ + {MP_RATE, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_rate"},/* get */ + {MP_RESET_STATS, IW_PRIV_TYPE_CHAR | 1024, 0, "mp_reset_stats"}, + {MP_QUERY, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_query"}, /* get */ + {READ_REG, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "read_reg"}, + {MP_RATE, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_rate"}, + {READ_RF, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "read_rf"}, + {MP_PSD, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_psd"}, + {MP_DUMP, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_dump"}, + {MP_TXPOWER, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_txpower"}, + {MP_ANT_TX, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_ant_tx"}, + {MP_ANT_RX, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_ant_rx"}, + {WRITE_REG, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "write_reg"}, + {WRITE_RF, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "write_rf"}, + {MP_CTX, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_ctx"}, + {MP_ARX, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_arx"}, + {MP_THER, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_ther"}, + {EFUSE_SET, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "efuse_set"}, + {EFUSE_GET, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "efuse_get"}, + {MP_PWRTRK, IW_PRIV_TYPE_CHAR | 1024, 0, "mp_pwrtrk"}, + {MP_QueryDrvStats, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_drvquery"}, + {MP_IOCTL, IW_PRIV_TYPE_CHAR | 1024, 0, "mp_ioctl"}, /* mp_ioctl */ + {MP_SetRFPathSwh, IW_PRIV_TYPE_CHAR | 1024, 0, "mp_setrfpath"}, + {CTA_TEST, IW_PRIV_TYPE_CHAR | 1024, 0, "cta_test"}, +}; + +static iw_handler rtw_private_handler[] = { +rtw_wx_write32, /* 0x00 */ +rtw_wx_read32, /* 0x01 */ +rtw_drvext_hdl, /* 0x02 */ +rtw_mp_ioctl_hdl, /* 0x03 */ + +/* for MM DTV platform */ + rtw_get_ap_info, /* 0x04 */ + + rtw_set_pid, /* 0x05 */ + rtw_wps_start, /* 0x06 */ + + rtw_wx_get_sensitivity, /* 0x07 */ + rtw_wx_set_mtk_wps_probe_ie, /* 0x08 */ + rtw_wx_set_mtk_wps_ie, /* 0x09 */ + +/* Set Channel depend on the country code */ + rtw_wx_set_channel_plan, /* 0x0A */ + + rtw_dbg_port, /* 0x0B */ + rtw_wx_write_rf, /* 0x0C */ + rtw_wx_read_rf, /* 0x0D */ + + rtw_mp_set, /* 0x0E */ + rtw_mp_get, /* 0x0F */ + rtw_p2p_set, /* 0x10 */ + rtw_p2p_get, /* 0x11 */ + rtw_p2p_get2, /* 0x12 */ + + NULL, /* 0x13 */ + rtw_tdls, /* 0x14 */ + rtw_tdls_get, /* 0x15 */ + + rtw_pm_set, /* 0x16 */ + rtw_wx_priv_null, /* 0x17 */ + rtw_rereg_nd_name, /* 0x18 */ + rtw_wx_priv_null, /* 0x19 */ + + rtw_mp_efuse_set, /* 0x1A */ + rtw_mp_efuse_get, /* 0x1B */ + NULL, /* 0x1C is reserved for hostapd */ + rtw_test, /* 0x1D */ +}; + +static struct iw_statistics *rtw_get_wireless_stats(struct net_device *dev) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct iw_statistics *piwstats = &padapter->iwstats; + int tmp_level = 0; + int tmp_qual = 0; + int tmp_noise = 0; + + if (!check_fwstate(&padapter->mlmepriv, _FW_LINKED)) { + piwstats->qual.qual = 0; + piwstats->qual.level = 0; + piwstats->qual.noise = 0; + } else { + tmp_level = padapter->recvpriv.signal_strength; + tmp_qual = padapter->recvpriv.signal_qual; + tmp_noise = padapter->recvpriv.noise; + + piwstats->qual.level = tmp_level; + piwstats->qual.qual = tmp_qual; + piwstats->qual.noise = tmp_noise; + } + piwstats->qual.updated = IW_QUAL_ALL_UPDATED;/* IW_QUAL_DBM; */ + return &padapter->iwstats; +} + +struct iw_handler_def rtw_handlers_def = { + .standard = rtw_handlers, + .num_standard = sizeof(rtw_handlers) / sizeof(iw_handler), + .private = rtw_private_handler, + .private_args = (struct iw_priv_args *)rtw_private_args, + .num_private = sizeof(rtw_private_handler) / sizeof(iw_handler), + .num_private_args = sizeof(rtw_private_args) / sizeof(struct iw_priv_args), + .get_wireless_stats = rtw_get_wireless_stats, +}; + +/* copy from net/wireless/wext.c start */ +/* ---------------------------------------------------------------- */ +/* + * Calculate size of private arguments + */ +static const char iw_priv_type_size[] = { + 0, /* IW_PRIV_TYPE_NONE */ + 1, /* IW_PRIV_TYPE_BYTE */ + 1, /* IW_PRIV_TYPE_CHAR */ + 0, /* Not defined */ + sizeof(__u32), /* IW_PRIV_TYPE_INT */ + sizeof(struct iw_freq), /* IW_PRIV_TYPE_FLOAT */ + sizeof(struct sockaddr), /* IW_PRIV_TYPE_ADDR */ + 0, /* Not defined */ +}; + +static int get_priv_size(__u16 args) +{ + int num = args & IW_PRIV_SIZE_MASK; + int type = (args & IW_PRIV_TYPE_MASK) >> 12; + + return num * iw_priv_type_size[type]; +} +/* copy from net/wireless/wext.c end */ + +static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_data) +{ + int err = 0; + u8 *input = NULL; + u32 input_len = 0; + const char delim[] = " "; + u8 *output = NULL; + u32 output_len = 0; + u32 count = 0; + u8 *buffer = NULL; + u32 buffer_len = 0; + char *ptr = NULL; + u8 cmdname[17] = {0}; /* IFNAMSIZ+1 */ + u32 cmdlen; + s32 len; + u8 *extra = NULL; + u32 extra_size = 0; + + s32 k; + const iw_handler *priv; /* Private ioctl */ + const struct iw_priv_args *priv_args; /* Private ioctl description */ + u32 num_priv_args; /* Number of descriptions */ + iw_handler handler; + int temp; + int subcmd = 0; /* sub-ioctl index */ + int offset = 0; /* Space for sub-ioctl index */ + + union iwreq_data wdata; + + memcpy(&wdata, wrq_data, sizeof(wdata)); + + input_len = wdata.data.length; + input = rtw_zmalloc(input_len); + if (NULL == input) + return -ENOMEM; + if (copy_from_user(input, wdata.data.pointer, input_len)) { + err = -EFAULT; + goto exit; + } + ptr = input; + len = input_len; + + sscanf(ptr, "%16s", cmdname); + cmdlen = strlen(cmdname); + DBG_88E("%s: cmd =%s\n", __func__, cmdname); + + /* skip command string */ + if (cmdlen > 0) + cmdlen += 1; /* skip one space */ + ptr += cmdlen; + len -= cmdlen; + DBG_88E("%s: parameters =%s\n", __func__, ptr); + + priv = rtw_private_handler; + priv_args = rtw_private_args; + num_priv_args = sizeof(rtw_private_args) / sizeof(struct iw_priv_args); + + if (num_priv_args == 0) { + err = -EOPNOTSUPP; + goto exit; + } + + /* Search the correct ioctl */ + k = -1; + while ((++k < num_priv_args) && strcmp(priv_args[k].name, cmdname)); + + /* If not found... */ + if (k == num_priv_args) { + err = -EOPNOTSUPP; + goto exit; + } + + /* Watch out for sub-ioctls ! */ + if (priv_args[k].cmd < SIOCDEVPRIVATE) { + int j = -1; + + /* Find the matching *real* ioctl */ + while ((++j < num_priv_args) && ((priv_args[j].name[0] != '\0') || + (priv_args[j].set_args != priv_args[k].set_args) || + (priv_args[j].get_args != priv_args[k].get_args))); + + /* If not found... */ + if (j == num_priv_args) { + err = -EINVAL; + goto exit; + } + + /* Save sub-ioctl number */ + subcmd = priv_args[k].cmd; + /* Reserve one int (simplify alignment issues) */ + offset = sizeof(__u32); + /* Use real ioctl definition from now on */ + k = j; + } + + buffer = rtw_zmalloc(4096); + if (NULL == buffer) { + err = -ENOMEM; + goto exit; + } + + /* If we have to set some data */ + if ((priv_args[k].set_args & IW_PRIV_TYPE_MASK) && + (priv_args[k].set_args & IW_PRIV_SIZE_MASK)) { + u8 *str; + + switch (priv_args[k].set_args & IW_PRIV_TYPE_MASK) { + case IW_PRIV_TYPE_BYTE: + /* Fetch args */ + count = 0; + do { + str = strsep(&ptr, delim); + if (NULL == str) + break; + sscanf(str, "%i", &temp); + buffer[count++] = (u8)temp; + } while (1); + buffer_len = count; + /* Number of args to fetch */ + wdata.data.length = count; + if (wdata.data.length > (priv_args[k].set_args & IW_PRIV_SIZE_MASK)) + wdata.data.length = priv_args[k].set_args & IW_PRIV_SIZE_MASK; + break; + case IW_PRIV_TYPE_INT: + /* Fetch args */ + count = 0; + do { + str = strsep(&ptr, delim); + if (NULL == str) + break; + sscanf(str, "%i", &temp); + ((s32 *)buffer)[count++] = (s32)temp; + } while (1); + buffer_len = count * sizeof(s32); + /* Number of args to fetch */ + wdata.data.length = count; + if (wdata.data.length > (priv_args[k].set_args & IW_PRIV_SIZE_MASK)) + wdata.data.length = priv_args[k].set_args & IW_PRIV_SIZE_MASK; + break; + case IW_PRIV_TYPE_CHAR: + if (len > 0) { + /* Size of the string to fetch */ + wdata.data.length = len; + if (wdata.data.length > (priv_args[k].set_args & IW_PRIV_SIZE_MASK)) + wdata.data.length = priv_args[k].set_args & IW_PRIV_SIZE_MASK; + + /* Fetch string */ + memcpy(buffer, ptr, wdata.data.length); + } else { + wdata.data.length = 1; + buffer[0] = '\0'; + } + buffer_len = wdata.data.length; + break; + default: + DBG_88E("%s: Not yet implemented...\n", __func__); + err = -1; + goto exit; + } + + if ((priv_args[k].set_args & IW_PRIV_SIZE_FIXED) && + (wdata.data.length != (priv_args[k].set_args & IW_PRIV_SIZE_MASK))) { + DBG_88E("%s: The command %s needs exactly %d argument(s)...\n", + __func__, cmdname, priv_args[k].set_args & IW_PRIV_SIZE_MASK); + err = -EINVAL; + goto exit; + } + } else { + /* if args to set */ + wdata.data.length = 0L; + } + + /* Those two tests are important. They define how the driver + * will have to handle the data */ + if ((priv_args[k].set_args & IW_PRIV_SIZE_FIXED) && + ((get_priv_size(priv_args[k].set_args) + offset) <= IFNAMSIZ)) { + /* First case : all SET args fit within wrq */ + if (offset) + wdata.mode = subcmd; + memcpy(wdata.name + offset, buffer, IFNAMSIZ - offset); + } else { + if ((priv_args[k].set_args == 0) && + (priv_args[k].get_args & IW_PRIV_SIZE_FIXED) && + (get_priv_size(priv_args[k].get_args) <= IFNAMSIZ)) { + /* Second case : no SET args, GET args fit within wrq */ + if (offset) + wdata.mode = subcmd; + } else { + /* Third case : args won't fit in wrq, or variable number of args */ + if (copy_to_user(wdata.data.pointer, buffer, buffer_len)) { + err = -EFAULT; + goto exit; + } + wdata.data.flags = subcmd; + } + } + + kfree(input); + input = NULL; + + extra_size = 0; + if (IW_IS_SET(priv_args[k].cmd)) { + /* Size of set arguments */ + extra_size = get_priv_size(priv_args[k].set_args); + + /* Does it fits in iwr ? */ + if ((priv_args[k].set_args & IW_PRIV_SIZE_FIXED) && + ((extra_size + offset) <= IFNAMSIZ)) + extra_size = 0; + } else { + /* Size of get arguments */ + extra_size = get_priv_size(priv_args[k].get_args); + + /* Does it fits in iwr ? */ + if ((priv_args[k].get_args & IW_PRIV_SIZE_FIXED) && + (extra_size <= IFNAMSIZ)) + extra_size = 0; + } + + if (extra_size == 0) { + extra = (u8 *)&wdata; + kfree(buffer); + buffer = NULL; + } else { + extra = buffer; + } + + handler = priv[priv_args[k].cmd - SIOCIWFIRSTPRIV]; + err = handler(dev, NULL, &wdata, extra); + + /* If we have to get some data */ + if ((priv_args[k].get_args & IW_PRIV_TYPE_MASK) && + (priv_args[k].get_args & IW_PRIV_SIZE_MASK)) { + int j; + int n = 0; /* number of args */ + u8 str[20] = {0}; + + /* Check where is the returned data */ + if ((priv_args[k].get_args & IW_PRIV_SIZE_FIXED) && + (get_priv_size(priv_args[k].get_args) <= IFNAMSIZ)) + n = priv_args[k].get_args & IW_PRIV_SIZE_MASK; + else + n = wdata.data.length; + + output = rtw_zmalloc(4096); + if (NULL == output) { + err = -ENOMEM; + goto exit; + } + switch (priv_args[k].get_args & IW_PRIV_TYPE_MASK) { + case IW_PRIV_TYPE_BYTE: + /* Display args */ + for (j = 0; j < n; j++) { + sprintf(str, "%d ", extra[j]); + len = strlen(str); + output_len = strlen(output); + if ((output_len + len + 1) > 4096) { + err = -E2BIG; + goto exit; + } + memcpy(output+output_len, str, len); + } + break; + case IW_PRIV_TYPE_INT: + /* Display args */ + for (j = 0; j < n; j++) { + sprintf(str, "%d ", ((__s32 *)extra)[j]); + len = strlen(str); + output_len = strlen(output); + if ((output_len + len + 1) > 4096) { + err = -E2BIG; + goto exit; + } + memcpy(output+output_len, str, len); + } + break; + case IW_PRIV_TYPE_CHAR: + /* Display args */ + memcpy(output, extra, n); + break; + default: + DBG_88E("%s: Not yet implemented...\n", __func__); + err = -1; + goto exit; + } + + output_len = strlen(output) + 1; + wrq_data->data.length = output_len; + if (copy_to_user(wrq_data->data.pointer, output, output_len)) { + err = -EFAULT; + goto exit; + } + } else { + /* if args to set */ + wrq_data->data.length = 0; + } + +exit: + kfree(input); + kfree(buffer); + kfree(output); + return err; +} + +#include +int rtw_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) +{ + struct iwreq *wrq = (struct iwreq *)rq; + int ret = 0; + + switch (cmd) { + case RTL_IOCTL_WPA_SUPPLICANT: + ret = wpa_supplicant_ioctl(dev, &wrq->u.data); + break; +#ifdef CONFIG_88EU_AP_MODE + case RTL_IOCTL_HOSTAPD: + ret = rtw_hostapd_ioctl(dev, &wrq->u.data); + break; +#endif /* CONFIG_88EU_AP_MODE */ + case SIOCDEVPRIVATE: + ret = rtw_ioctl_wext_private(dev, &wrq->u); + break; + case (SIOCDEVPRIVATE+1): + ret = rtw_android_priv_cmd(dev, rq, cmd); + break; + default: + ret = -EOPNOTSUPP; + break; + } + return ret; +} diff --git a/drivers/staging/rtl8188eu/os_dep/mlme_linux.c b/drivers/staging/rtl8188eu/os_dep/mlme_linux.c new file mode 100644 index 0000000000000..57d1ff750d525 --- /dev/null +++ b/drivers/staging/rtl8188eu/os_dep/mlme_linux.c @@ -0,0 +1,246 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + + +#define _MLME_OSDEP_C_ + +#include +#include +#include + +void rtw_join_timeout_handler (void *FunctionContext) +{ + struct adapter *adapter = (struct adapter *)FunctionContext; + + _rtw_join_timeout_handler(adapter); +} + + +void _rtw_scan_timeout_handler (void *FunctionContext) +{ + struct adapter *adapter = (struct adapter *)FunctionContext; + + rtw_scan_timeout_handler(adapter); +} + +static void _dynamic_check_timer_handlder(void *FunctionContext) +{ + struct adapter *adapter = (struct adapter *)FunctionContext; + + if (adapter->registrypriv.mp_mode == 1) + return; + rtw_dynamic_check_timer_handlder(adapter); + _set_timer(&adapter->mlmepriv.dynamic_chk_timer, 2000); +} + +void rtw_init_mlme_timer(struct adapter *padapter) +{ + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + + _init_timer(&(pmlmepriv->assoc_timer), padapter->pnetdev, rtw_join_timeout_handler, padapter); + _init_timer(&(pmlmepriv->scan_to_timer), padapter->pnetdev, _rtw_scan_timeout_handler, padapter); + _init_timer(&(pmlmepriv->dynamic_chk_timer), padapter->pnetdev, _dynamic_check_timer_handlder, padapter); +} + +void rtw_os_indicate_connect(struct adapter *adapter) +{ +_func_enter_; + rtw_indicate_wx_assoc_event(adapter); + netif_carrier_on(adapter->pnetdev); + if (adapter->pid[2] != 0) + rtw_signal_process(adapter->pid[2], SIGALRM); +_func_exit_; +} + +void rtw_os_indicate_scan_done(struct adapter *padapter, bool aborted) +{ + indicate_wx_scan_complete_event(padapter); +} + +static struct rt_pmkid_list backup_pmkid[NUM_PMKID_CACHE]; + +void rtw_reset_securitypriv(struct adapter *adapter) +{ + u8 backup_index = 0; + u8 backup_counter = 0x00; + u32 backup_time = 0; + + if (adapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) { + /* 802.1x */ + /* We have to backup the PMK information for WiFi PMK Caching test item. */ + /* Backup the btkip_countermeasure information. */ + /* When the countermeasure is trigger, the driver have to disconnect with AP for 60 seconds. */ + _rtw_memset(&backup_pmkid[0], 0x00, sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE); + memcpy(&backup_pmkid[0], &adapter->securitypriv.PMKIDList[0], sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE); + backup_index = adapter->securitypriv.PMKIDIndex; + backup_counter = adapter->securitypriv.btkip_countermeasure; + backup_time = adapter->securitypriv.btkip_countermeasure_time; + _rtw_memset((unsigned char *)&adapter->securitypriv, 0, sizeof(struct security_priv)); + + /* Restore the PMK information to securitypriv structure for the following connection. */ + memcpy(&adapter->securitypriv.PMKIDList[0], + &backup_pmkid[0], + sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE); + adapter->securitypriv.PMKIDIndex = backup_index; + adapter->securitypriv.btkip_countermeasure = backup_counter; + adapter->securitypriv.btkip_countermeasure_time = backup_time; + adapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen; + adapter->securitypriv.ndisencryptstatus = Ndis802_11WEPDisabled; + } else { + /* reset values in securitypriv */ + struct security_priv *psec_priv = &adapter->securitypriv; + + psec_priv->dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */ + psec_priv->dot11PrivacyAlgrthm = _NO_PRIVACY_; + psec_priv->dot11PrivacyKeyIndex = 0; + psec_priv->dot118021XGrpPrivacy = _NO_PRIVACY_; + psec_priv->dot118021XGrpKeyid = 1; + psec_priv->ndisauthtype = Ndis802_11AuthModeOpen; + psec_priv->ndisencryptstatus = Ndis802_11WEPDisabled; + } +} + +void rtw_os_indicate_disconnect(struct adapter *adapter) +{ +_func_enter_; + netif_carrier_off(adapter->pnetdev); /* Do it first for tx broadcast pkt after disconnection issue! */ + rtw_indicate_wx_disassoc_event(adapter); + rtw_reset_securitypriv(adapter); +_func_exit_; +} + +void rtw_report_sec_ie(struct adapter *adapter, u8 authmode, u8 *sec_ie) +{ + uint len; + u8 *buff, *p, i; + union iwreq_data wrqu; + +_func_enter_; + RT_TRACE(_module_mlme_osdep_c_, _drv_info_, + ("+rtw_report_sec_ie, authmode=%d\n", authmode)); + buff = NULL; + if (authmode == _WPA_IE_ID_) { + RT_TRACE(_module_mlme_osdep_c_, _drv_info_, + ("rtw_report_sec_ie, authmode=%d\n", authmode)); + buff = rtw_malloc(IW_CUSTOM_MAX); + if (!buff) + goto exit; + _rtw_memset(buff, 0, IW_CUSTOM_MAX); + p = buff; + p += sprintf(p, "ASSOCINFO(ReqIEs ="); + len = sec_ie[1]+2; + len = (len < IW_CUSTOM_MAX) ? len : IW_CUSTOM_MAX; + for (i = 0; i < len; i++) + p += sprintf(p, "%02x", sec_ie[i]); + p += sprintf(p, ")"); + _rtw_memset(&wrqu, 0, sizeof(wrqu)); + wrqu.data.length = p-buff; + wrqu.data.length = (wrqu.data.length < IW_CUSTOM_MAX) ? + wrqu.data.length : IW_CUSTOM_MAX; + wireless_send_event(adapter->pnetdev, IWEVCUSTOM, &wrqu, buff); + kfree(buff); + } +exit: +_func_exit_; +} + +static void _survey_timer_hdl(void *FunctionContext) +{ + struct adapter *padapter = (struct adapter *)FunctionContext; + + survey_timer_hdl(padapter); +} + +static void _link_timer_hdl(void *FunctionContext) +{ + struct adapter *padapter = (struct adapter *)FunctionContext; + link_timer_hdl(padapter); +} + +static void _addba_timer_hdl(void *FunctionContext) +{ + struct sta_info *psta = (struct sta_info *)FunctionContext; + addba_timer_hdl(psta); +} + +void init_addba_retry_timer(struct adapter *padapter, struct sta_info *psta) +{ + _init_timer(&psta->addba_retry_timer, padapter->pnetdev, _addba_timer_hdl, psta); +} + +void init_mlme_ext_timer(struct adapter *padapter) +{ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + + _init_timer(&pmlmeext->survey_timer, padapter->pnetdev, _survey_timer_hdl, padapter); + _init_timer(&pmlmeext->link_timer, padapter->pnetdev, _link_timer_hdl, padapter); +} + +#ifdef CONFIG_88EU_AP_MODE + +void rtw_indicate_sta_assoc_event(struct adapter *padapter, struct sta_info *psta) +{ + union iwreq_data wrqu; + struct sta_priv *pstapriv = &padapter->stapriv; + + if (psta == NULL) + return; + + if (psta->aid > NUM_STA) + return; + + if (pstapriv->sta_aid[psta->aid - 1] != psta) + return; + + + wrqu.addr.sa_family = ARPHRD_ETHER; + + memcpy(wrqu.addr.sa_data, psta->hwaddr, ETH_ALEN); + + DBG_88E("+rtw_indicate_sta_assoc_event\n"); + + wireless_send_event(padapter->pnetdev, IWEVREGISTERED, &wrqu, NULL); +} + +void rtw_indicate_sta_disassoc_event(struct adapter *padapter, struct sta_info *psta) +{ + union iwreq_data wrqu; + struct sta_priv *pstapriv = &padapter->stapriv; + + if (psta == NULL) + return; + + if (psta->aid > NUM_STA) + return; + + if (pstapriv->sta_aid[psta->aid - 1] != psta) + return; + + + wrqu.addr.sa_family = ARPHRD_ETHER; + + memcpy(wrqu.addr.sa_data, psta->hwaddr, ETH_ALEN); + + DBG_88E("+rtw_indicate_sta_disassoc_event\n"); + + wireless_send_event(padapter->pnetdev, IWEVEXPIRED, &wrqu, NULL); +} + +#endif diff --git a/drivers/staging/rtl8188eu/os_dep/osdep_service.c b/drivers/staging/rtl8188eu/os_dep/osdep_service.c new file mode 100644 index 0000000000000..4e0bfb7e153b8 --- /dev/null +++ b/drivers/staging/rtl8188eu/os_dep/osdep_service.c @@ -0,0 +1,815 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + + +#define _OSDEP_SERVICE_C_ + +#include +#include +#include +#include +#include + +/* +* Translate the OS dependent @param error_code to OS independent RTW_STATUS_CODE +* @return: one of RTW_STATUS_CODE +*/ +inline int RTW_STATUS_CODE(int error_code) +{ + if (error_code >= 0) + return _SUCCESS; + return _FAIL; +} + +u32 rtw_atoi(u8 *s) +{ + int num = 0, flag = 0; + int i; + for (i = 0; i <= strlen(s); i++) { + if (s[i] >= '0' && s[i] <= '9') + num = num * 10 + s[i] - '0'; + else if (s[0] == '-' && i == 0) + flag = 1; + else + break; + } + if (flag == 1) + num = num * -1; + return num; +} + +inline u8 *_rtw_vmalloc(u32 sz) +{ + u8 *pbuf; + pbuf = vmalloc(sz); + return pbuf; +} + +inline u8 *_rtw_zvmalloc(u32 sz) +{ + u8 *pbuf; + pbuf = _rtw_vmalloc(sz); + if (pbuf != NULL) + memset(pbuf, 0, sz); + return pbuf; +} + +inline void _rtw_vmfree(u8 *pbuf, u32 sz) +{ + vfree(pbuf); +} + +u8 *_rtw_malloc(u32 sz) +{ + u8 *pbuf = NULL; + + pbuf = kmalloc(sz, in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); + return pbuf; +} + +u8 *_rtw_zmalloc(u32 sz) +{ + u8 *pbuf = _rtw_malloc(sz); + + if (pbuf != NULL) + memset(pbuf, 0, sz); + return pbuf; +} + +void *rtw_malloc2d(int h, int w, int size) +{ + int j; + + void **a = (void **)rtw_zmalloc(h*sizeof(void *) + h*w*size); + if (a == NULL) { + pr_info("%s: alloc memory fail!\n", __func__); + return NULL; + } + + for (j = 0; j < h; j++) + a[j] = ((char *)(a+h)) + j*w*size; + + return a; +} + +void rtw_mfree2d(void *pbuf, int h, int w, int size) +{ + kfree(pbuf); +} + +int _rtw_memcmp(void *dst, void *src, u32 sz) +{ +/* under Linux/GNU/GLibc, the return value of memcmp for two same + * mem. chunk is 0 */ + if (!(memcmp(dst, src, sz))) + return true; + else + return false; +} + +void _rtw_memset(void *pbuf, int c, u32 sz) +{ + memset(pbuf, c, sz); +} + +void _rtw_init_listhead(struct list_head *list) +{ + INIT_LIST_HEAD(list); +} + +/* +For the following list_xxx operations, +caller must guarantee the atomic context. +Otherwise, there will be racing condition. +*/ +u32 rtw_is_list_empty(struct list_head *phead) +{ + if (list_empty(phead)) + return true; + else + return false; +} + +void rtw_list_insert_head(struct list_head *plist, struct list_head *phead) +{ + list_add(plist, phead); +} + +void rtw_list_insert_tail(struct list_head *plist, struct list_head *phead) +{ + list_add_tail(plist, phead); +} + +/* +Caller must check if the list is empty before calling rtw_list_delete +*/ + +void _rtw_init_sema(struct semaphore *sema, int init_val) +{ + sema_init(sema, init_val); +} + +void _rtw_free_sema(struct semaphore *sema) +{ +} + +void _rtw_up_sema(struct semaphore *sema) +{ + up(sema); +} + +u32 _rtw_down_sema(struct semaphore *sema) +{ + if (down_interruptible(sema)) + return _FAIL; + else + return _SUCCESS; +} + +void _rtw_mutex_init(struct mutex *pmutex) +{ + mutex_init(pmutex); +} + +void _rtw_mutex_free(struct mutex *pmutex) +{ + mutex_destroy(pmutex); +} + +void _rtw_spinlock_init(spinlock_t *plock) +{ + spin_lock_init(plock); +} + +void _rtw_spinlock_free(spinlock_t *plock) +{ +} + +void _rtw_init_queue(struct __queue *pqueue) +{ + _rtw_init_listhead(&(pqueue->queue)); + _rtw_spinlock_init(&(pqueue->lock)); +} + +u32 _rtw_queue_empty(struct __queue *pqueue) +{ + return rtw_is_list_empty(&(pqueue->queue)); +} + +u32 rtw_end_of_queue_search(struct list_head *head, struct list_head *plist) +{ + if (head == plist) + return true; + else + return false; +} + +u32 rtw_get_current_time(void) +{ + return jiffies; +} + +inline u32 rtw_systime_to_ms(u32 systime) +{ + return systime * 1000 / HZ; +} + +inline u32 rtw_ms_to_systime(u32 ms) +{ + return ms * HZ / 1000; +} + +/* the input parameter start use the same unit as returned by + * rtw_get_current_time */ +inline s32 rtw_get_passing_time_ms(u32 start) +{ + return rtw_systime_to_ms(jiffies-start); +} + +inline s32 rtw_get_time_interval_ms(u32 start, u32 end) +{ + return rtw_systime_to_ms(end-start); +} + +void rtw_sleep_schedulable(int ms) +{ + u32 delta; + + delta = (ms * HZ)/1000;/* ms) */ + if (delta == 0) + delta = 1;/* 1 ms */ + set_current_state(TASK_INTERRUPTIBLE); + if (schedule_timeout(delta) != 0) + return; +} + +void rtw_msleep_os(int ms) +{ + msleep((unsigned int)ms); +} + +void rtw_usleep_os(int us) +{ + if (1 < (us/1000)) + msleep(1); + else + msleep((us/1000) + 1); +} + +void rtw_mdelay_os(int ms) +{ + mdelay((unsigned long)ms); +} + +void rtw_udelay_os(int us) +{ + udelay((unsigned long)us); +} + +void rtw_yield_os(void) +{ + yield(); +} + +#define RTW_SUSPEND_LOCK_NAME "rtw_wifi" + +inline void rtw_suspend_lock_init(void) +{ +} + +inline void rtw_suspend_lock_uninit(void) +{ +} + +inline void rtw_lock_suspend(void) +{ +} + +inline void rtw_unlock_suspend(void) +{ +} + +inline void ATOMIC_SET(ATOMIC_T *v, int i) +{ + atomic_set(v, i); +} + +inline int ATOMIC_READ(ATOMIC_T *v) +{ + return atomic_read(v); +} + +inline void ATOMIC_ADD(ATOMIC_T *v, int i) +{ + atomic_add(i, v); +} + +inline void ATOMIC_SUB(ATOMIC_T *v, int i) +{ + atomic_sub(i, v); +} + +inline void ATOMIC_INC(ATOMIC_T *v) +{ + atomic_inc(v); +} + +inline void ATOMIC_DEC(ATOMIC_T *v) +{ + atomic_dec(v); +} + +inline int ATOMIC_ADD_RETURN(ATOMIC_T *v, int i) +{ + return atomic_add_return(i, v); +} + +inline int ATOMIC_SUB_RETURN(ATOMIC_T *v, int i) +{ + return atomic_sub_return(i, v); +} + +inline int ATOMIC_INC_RETURN(ATOMIC_T *v) +{ + return atomic_inc_return(v); +} + +inline int ATOMIC_DEC_RETURN(ATOMIC_T *v) +{ + return atomic_dec_return(v); +} + +/* Open a file with the specific @param path, @param flag, @param mode + * @param fpp the pointer of struct file pointer to get struct file pointer while file opening is success + * @param path the path of the file to open + * @param flag file operation flags, please refer to linux document + * @param mode please refer to linux document + * @return Linux specific error code + */ +static int openfile(struct file **fpp, char *path, int flag, int mode) +{ + struct file *fp; + + fp = filp_open(path, flag, mode); + if (IS_ERR(fp)) { + *fpp = NULL; + return PTR_ERR(fp); + } else { + *fpp = fp; + return 0; + } +} + +/* Close the file with the specific @param fp + * @param fp the pointer of struct file to close + * @return always 0 + */ +static int closefile(struct file *fp) +{ + filp_close(fp, NULL); + return 0; +} + +static int readfile(struct file *fp, char __user *buf, int len) +{ + int rlen = 0, sum = 0; + + if (!fp->f_op || !fp->f_op->read) + return -EPERM; + + while (sum < len) { + rlen = fp->f_op->read(fp, buf+sum, len-sum, &fp->f_pos); + if (rlen > 0) + sum += rlen; + else if (0 != rlen) + return rlen; + else + break; + } + return sum; +} + +static int writefile(struct file *fp, char __user *buf, int len) +{ + int wlen = 0, sum = 0; + + if (!fp->f_op || !fp->f_op->write) + return -EPERM; + + while (sum < len) { + wlen = fp->f_op->write(fp, buf+sum, len-sum, &fp->f_pos); + if (wlen > 0) + sum += wlen; + else if (0 != wlen) + return wlen; + else + break; + } + return sum; +} + +/* Test if the specifi @param path is a file and readable + * @param path the path of the file to test + * @return Linux specific error code + */ +static int isfilereadable(char *path) +{ + struct file *fp; + int ret = 0; + mm_segment_t oldfs; + char __user buf; + + fp = filp_open(path, O_RDONLY, 0); + if (IS_ERR(fp)) { + ret = PTR_ERR(fp); + } else { + oldfs = get_fs(); set_fs(get_ds()); + + if (1 != readfile(fp, &buf, 1)) + ret = PTR_ERR(fp); + + set_fs(oldfs); + filp_close(fp, NULL); + } + return ret; +} + +/* Open the file with @param path and retrive the file content into + * memory starting from @param buf for @param sz at most + * @param path the path of the file to open and read + * @param buf the starting address of the buffer to store file content + * @param sz how many bytes to read at most + * @return the byte we've read, or Linux specific error code + */ +static int retrievefromfile(char *path, u8 __user *buf, u32 sz) +{ + int ret = -1; + mm_segment_t oldfs; + struct file *fp; + + if (path && buf) { + ret = openfile(&fp, path, O_RDONLY, 0); + if (0 == ret) { + DBG_88E("%s openfile path:%s fp =%p\n", __func__, + path, fp); + + oldfs = get_fs(); set_fs(get_ds()); + ret = readfile(fp, buf, sz); + set_fs(oldfs); + closefile(fp); + + DBG_88E("%s readfile, ret:%d\n", __func__, ret); + + } else { + DBG_88E("%s openfile path:%s Fail, ret:%d\n", __func__, + path, ret); + } + } else { + DBG_88E("%s NULL pointer\n", __func__); + ret = -EINVAL; + } + return ret; +} + +/* +* Open the file with @param path and wirte @param sz byte of data starting from @param buf into the file +* @param path the path of the file to open and write +* @param buf the starting address of the data to write into file +* @param sz how many bytes to write at most +* @return the byte we've written, or Linux specific error code +*/ +static int storetofile(char *path, u8 __user *buf, u32 sz) +{ + int ret = 0; + mm_segment_t oldfs; + struct file *fp; + + if (path && buf) { + ret = openfile(&fp, path, O_CREAT|O_WRONLY, 0666); + if (0 == ret) { + DBG_88E("%s openfile path:%s fp =%p\n", __func__, path, fp); + + oldfs = get_fs(); set_fs(get_ds()); + ret = writefile(fp, buf, sz); + set_fs(oldfs); + closefile(fp); + + DBG_88E("%s writefile, ret:%d\n", __func__, ret); + + } else { + DBG_88E("%s openfile path:%s Fail, ret:%d\n", __func__, path, ret); + } + } else { + DBG_88E("%s NULL pointer\n", __func__); + ret = -EINVAL; + } + return ret; +} + +/* +* Test if the specifi @param path is a file and readable +* @param path the path of the file to test +* @return true or false +*/ +int rtw_is_file_readable(char *path) +{ + if (isfilereadable(path) == 0) + return true; + else + return false; +} + +/* +* Open the file with @param path and retrive the file content into memory starting from @param buf for @param sz at most +* @param path the path of the file to open and read +* @param buf the starting address of the buffer to store file content +* @param sz how many bytes to read at most +* @return the byte we've read +*/ +int rtw_retrive_from_file(char *path, u8 __user *buf, u32 sz) +{ + int ret = retrievefromfile(path, buf, sz); + + return ret >= 0 ? ret : 0; +} + +/* + * Open the file with @param path and wirte @param sz byte of data + * starting from @param buf into the file + * @param path the path of the file to open and write + * @param buf the starting address of the data to write into file + * @param sz how many bytes to write at most + * @return the byte we've written + */ +int rtw_store_to_file(char *path, u8 __user *buf, u32 sz) +{ + int ret = storetofile(path, buf, sz); + return ret >= 0 ? ret : 0; +} + +struct net_device *rtw_alloc_etherdev_with_old_priv(int sizeof_priv, + void *old_priv) +{ + struct net_device *pnetdev; + struct rtw_netdev_priv_indicator *pnpi; + + pnetdev = alloc_etherdev_mq(sizeof(struct rtw_netdev_priv_indicator), 4); + if (!pnetdev) + goto RETURN; + + pnpi = netdev_priv(pnetdev); + pnpi->priv = old_priv; + pnpi->sizeof_priv = sizeof_priv; + +RETURN: + return pnetdev; +} + +struct net_device *rtw_alloc_etherdev(int sizeof_priv) +{ + struct net_device *pnetdev; + struct rtw_netdev_priv_indicator *pnpi; + + pnetdev = alloc_etherdev_mq(sizeof(struct rtw_netdev_priv_indicator), 4); + if (!pnetdev) + goto RETURN; + + pnpi = netdev_priv(pnetdev); + + pnpi->priv = rtw_zvmalloc(sizeof_priv); + if (!pnpi->priv) { + free_netdev(pnetdev); + pnetdev = NULL; + goto RETURN; + } + + pnpi->sizeof_priv = sizeof_priv; +RETURN: + return pnetdev; +} + +void rtw_free_netdev(struct net_device *netdev) +{ + struct rtw_netdev_priv_indicator *pnpi; + + if (!netdev) + goto RETURN; + + pnpi = netdev_priv(netdev); + + if (!pnpi->priv) + goto RETURN; + + rtw_vmfree(pnpi->priv, pnpi->sizeof_priv); + free_netdev(netdev); + +RETURN: + return; +} + +int rtw_change_ifname(struct adapter *padapter, const char *ifname) +{ + struct net_device *pnetdev; + struct net_device *cur_pnetdev = padapter->pnetdev; + struct rereg_nd_name_data *rereg_priv; + int ret; + + if (!padapter) + goto error; + + rereg_priv = &padapter->rereg_nd_name_priv; + + /* free the old_pnetdev */ + if (rereg_priv->old_pnetdev) { + free_netdev(rereg_priv->old_pnetdev); + rereg_priv->old_pnetdev = NULL; + } + + if (!rtnl_is_locked()) + unregister_netdev(cur_pnetdev); + else + unregister_netdevice(cur_pnetdev); + + rtw_proc_remove_one(cur_pnetdev); + + rereg_priv->old_pnetdev = cur_pnetdev; + + pnetdev = rtw_init_netdev(padapter); + if (!pnetdev) { + ret = -1; + goto error; + } + + SET_NETDEV_DEV(pnetdev, dvobj_to_dev(adapter_to_dvobj(padapter))); + + rtw_init_netdev_name(pnetdev, ifname); + + memcpy(pnetdev->dev_addr, padapter->eeprompriv.mac_addr, ETH_ALEN); + + if (!rtnl_is_locked()) + ret = register_netdev(pnetdev); + else + ret = register_netdevice(pnetdev); + if (ret != 0) { + RT_TRACE(_module_hci_intfs_c_, _drv_err_, + ("register_netdev() failed\n")); + goto error; + } + rtw_proc_init_one(pnetdev); + return 0; +error: + return -1; +} + +u64 rtw_modular64(u64 x, u64 y) +{ + return do_div(x, y); +} + +u64 rtw_division64(u64 x, u64 y) +{ + do_div(x, y); + return x; +} + +void rtw_buf_free(u8 **buf, u32 *buf_len) +{ + *buf_len = 0; + kfree(*buf); + *buf = NULL; +} + +void rtw_buf_update(u8 **buf, u32 *buf_len, u8 *src, u32 src_len) +{ + u32 ori_len = 0, dup_len = 0; + u8 *ori = NULL; + u8 *dup = NULL; + + if (!buf || !buf_len) + return; + + if (!src || !src_len) + goto keep_ori; + + /* duplicate src */ + dup = rtw_malloc(src_len); + if (dup) { + dup_len = src_len; + memcpy(dup, src, dup_len); + } + +keep_ori: + ori = *buf; + ori_len = *buf_len; + + /* replace buf with dup */ + *buf_len = 0; + *buf = dup; + *buf_len = dup_len; + + /* free ori */ + kfree(ori); +} + + +/** + * rtw_cbuf_full - test if cbuf is full + * @cbuf: pointer of struct rtw_cbuf + * + * Returns: true if cbuf is full + */ +inline bool rtw_cbuf_full(struct rtw_cbuf *cbuf) +{ + return (cbuf->write == cbuf->read-1) ? true : false; +} + +/** + * rtw_cbuf_empty - test if cbuf is empty + * @cbuf: pointer of struct rtw_cbuf + * + * Returns: true if cbuf is empty + */ +inline bool rtw_cbuf_empty(struct rtw_cbuf *cbuf) +{ + return (cbuf->write == cbuf->read) ? true : false; +} + +/** + * rtw_cbuf_push - push a pointer into cbuf + * @cbuf: pointer of struct rtw_cbuf + * @buf: pointer to push in + * + * Lock free operation, be careful of the use scheme + * Returns: true push success + */ +bool rtw_cbuf_push(struct rtw_cbuf *cbuf, void *buf) +{ + if (rtw_cbuf_full(cbuf)) + return _FAIL; + + if (0) + DBG_88E("%s on %u\n", __func__, cbuf->write); + cbuf->bufs[cbuf->write] = buf; + cbuf->write = (cbuf->write+1)%cbuf->size; + + return _SUCCESS; +} + +/** + * rtw_cbuf_pop - pop a pointer from cbuf + * @cbuf: pointer of struct rtw_cbuf + * + * Lock free operation, be careful of the use scheme + * Returns: pointer popped out + */ +void *rtw_cbuf_pop(struct rtw_cbuf *cbuf) +{ + void *buf; + if (rtw_cbuf_empty(cbuf)) + return NULL; + + if (0) + DBG_88E("%s on %u\n", __func__, cbuf->read); + buf = cbuf->bufs[cbuf->read]; + cbuf->read = (cbuf->read+1)%cbuf->size; + + return buf; +} + +/** + * rtw_cbuf_alloc - allocte a rtw_cbuf with given size and do initialization + * @size: size of pointer + * + * Returns: pointer of srtuct rtw_cbuf, NULL for allocation failure + */ +struct rtw_cbuf *rtw_cbuf_alloc(u32 size) +{ + struct rtw_cbuf *cbuf; + + cbuf = (struct rtw_cbuf *)rtw_malloc(sizeof(*cbuf) + + sizeof(void *)*size); + + if (cbuf) { + cbuf->write = 0; + cbuf->read = 0; + cbuf->size = size; + } + return cbuf; +} -- GitLab From 7bc88639ad3610b1f3026792ac0371c5b14bc8d6 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 21 Aug 2013 22:33:59 -0500 Subject: [PATCH 775/942] staging: r8188eu: Add files for new driver - part 17 This commit adds files hal/rtl8188eu_led.c, hal/rtl8188eu_recv.c, and hal/rtl8188eu_xmit.c. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188eu_led.c | 111 +++ .../staging/rtl8188eu/hal/rtl8188eu_recv.c | 138 ++++ .../staging/rtl8188eu/hal/rtl8188eu_xmit.c | 706 ++++++++++++++++++ 3 files changed, 955 insertions(+) create mode 100644 drivers/staging/rtl8188eu/hal/rtl8188eu_led.c create mode 100644 drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c create mode 100644 drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c new file mode 100644 index 0000000000000..1cce948a37fb4 --- /dev/null +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c @@ -0,0 +1,111 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#include +#include +#include +#include + +/* LED object. */ + +/* LED_819xUsb routines. */ +/* Description: */ +/* Turn on LED according to LedPin specified. */ +void SwLedOn(struct adapter *padapter, struct LED_871x *pLed) +{ + u8 LedCfg; + + if (padapter->bSurpriseRemoved || padapter->bDriverStopped) + return; + LedCfg = rtw_read8(padapter, REG_LEDCFG2); + switch (pLed->LedPin) { + case LED_PIN_LED0: + rtw_write8(padapter, REG_LEDCFG2, (LedCfg&0xf0)|BIT5|BIT6); /* SW control led0 on. */ + break; + case LED_PIN_LED1: + rtw_write8(padapter, REG_LEDCFG2, (LedCfg&0x0f)|BIT5); /* SW control led1 on. */ + break; + default: + break; + } + pLed->bLedOn = true; +} + +/* Description: */ +/* Turn off LED according to LedPin specified. */ +void SwLedOff(struct adapter *padapter, struct LED_871x *pLed) +{ + u8 LedCfg; + struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); + + if (padapter->bSurpriseRemoved || padapter->bDriverStopped) + goto exit; + + LedCfg = rtw_read8(padapter, REG_LEDCFG2);/* 0x4E */ + + switch (pLed->LedPin) { + case LED_PIN_LED0: + if (pHalData->bLedOpenDrain) { + /* Open-drain arrangement for controlling the LED) */ + LedCfg &= 0x90; /* Set to software control. */ + rtw_write8(padapter, REG_LEDCFG2, (LedCfg|BIT3)); + LedCfg = rtw_read8(padapter, REG_MAC_PINMUX_CFG); + LedCfg &= 0xFE; + rtw_write8(padapter, REG_MAC_PINMUX_CFG, LedCfg); + } else { + rtw_write8(padapter, REG_LEDCFG2, (LedCfg|BIT3|BIT5|BIT6)); + } + break; + case LED_PIN_LED1: + LedCfg &= 0x0f; /* Set to software control. */ + rtw_write8(padapter, REG_LEDCFG2, (LedCfg|BIT3)); + break; + default: + break; + } +exit: + pLed->bLedOn = false; +} + +/* Interface to manipulate LED objects. */ +/* Default LED behavior. */ + +/* Description: */ +/* Initialize all LED_871x objects. */ +void rtl8188eu_InitSwLeds(struct adapter *padapter) +{ + struct led_priv *pledpriv = &(padapter->ledpriv); + + pledpriv->LedControlHandler = LedControl871x; + + InitLed871x(padapter, &(pledpriv->SwLed0), LED_PIN_LED0); + + InitLed871x(padapter, &(pledpriv->SwLed1), LED_PIN_LED1); +} + +/* Description: */ +/* DeInitialize all LED_819xUsb objects. */ +void rtl8188eu_DeInitSwLeds(struct adapter *padapter) +{ + struct led_priv *ledpriv = &(padapter->ledpriv); + + DeInitLed871x(&(ledpriv->SwLed0)); + DeInitLed871x(&(ledpriv->SwLed1)); +} diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c new file mode 100644 index 0000000000000..0f47b89185932 --- /dev/null +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c @@ -0,0 +1,138 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTL8188EU_RECV_C_ +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +void rtl8188eu_init_recvbuf(struct adapter *padapter, struct recv_buf *precvbuf) +{ + precvbuf->transfer_len = 0; + + precvbuf->len = 0; + + precvbuf->ref_cnt = 0; + + if (precvbuf->pbuf) { + precvbuf->pdata = precvbuf->pbuf; + precvbuf->phead = precvbuf->pbuf; + precvbuf->ptail = precvbuf->pbuf; + precvbuf->pend = precvbuf->pdata + MAX_RECVBUF_SZ; + } +} + +int rtl8188eu_init_recv_priv(struct adapter *padapter) +{ + struct recv_priv *precvpriv = &padapter->recvpriv; + int i, res = _SUCCESS; + struct recv_buf *precvbuf; + + tasklet_init(&precvpriv->recv_tasklet, + (void(*)(unsigned long))rtl8188eu_recv_tasklet, + (unsigned long)padapter); + + /* init recv_buf */ + _rtw_init_queue(&precvpriv->free_recv_buf_queue); + + precvpriv->pallocated_recv_buf = rtw_zmalloc(NR_RECVBUFF * sizeof(struct recv_buf) + 4); + if (precvpriv->pallocated_recv_buf == NULL) { + res = _FAIL; + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("alloc recv_buf fail!\n")); + goto exit; + } + _rtw_memset(precvpriv->pallocated_recv_buf, 0, NR_RECVBUFF * sizeof(struct recv_buf) + 4); + + precvpriv->precv_buf = (u8 *)N_BYTE_ALIGMENT((size_t)(precvpriv->pallocated_recv_buf), 4); + + + precvbuf = (struct recv_buf *)precvpriv->precv_buf; + + for (i = 0; i < NR_RECVBUFF; i++) { + _rtw_init_listhead(&precvbuf->list); + _rtw_spinlock_init(&precvbuf->recvbuf_lock); + precvbuf->alloc_sz = MAX_RECVBUF_SZ; + res = rtw_os_recvbuf_resource_alloc(padapter, precvbuf); + if (res == _FAIL) + break; + precvbuf->ref_cnt = 0; + precvbuf->adapter = padapter; + precvbuf++; + } + precvpriv->free_recv_buf_queue_cnt = NR_RECVBUFF; + skb_queue_head_init(&precvpriv->rx_skb_queue); + { + int i; + size_t tmpaddr = 0; + size_t alignment = 0; + struct sk_buff *pskb = NULL; + + skb_queue_head_init(&precvpriv->free_recv_skb_queue); + + for (i = 0; i < NR_PREALLOC_RECV_SKB; i++) { + pskb = __netdev_alloc_skb(padapter->pnetdev, MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ, GFP_KERNEL); + if (pskb) { + pskb->dev = padapter->pnetdev; + tmpaddr = (size_t)pskb->data; + alignment = tmpaddr & (RECVBUFF_ALIGN_SZ-1); + skb_reserve(pskb, (RECVBUFF_ALIGN_SZ - alignment)); + + skb_queue_tail(&precvpriv->free_recv_skb_queue, pskb); + } + pskb = NULL; + } + } +exit: + return res; +} + +void rtl8188eu_free_recv_priv(struct adapter *padapter) +{ + int i; + struct recv_buf *precvbuf; + struct recv_priv *precvpriv = &padapter->recvpriv; + + precvbuf = (struct recv_buf *)precvpriv->precv_buf; + + for (i = 0; i < NR_RECVBUFF; i++) { + rtw_os_recvbuf_resource_free(padapter, precvbuf); + precvbuf++; + } + + kfree(precvpriv->pallocated_recv_buf); + + if (skb_queue_len(&precvpriv->rx_skb_queue)) + DBG_88E(KERN_WARNING "rx_skb_queue not empty\n"); + skb_queue_purge(&precvpriv->rx_skb_queue); + + + if (skb_queue_len(&precvpriv->free_recv_skb_queue)) + DBG_88E(KERN_WARNING "free_recv_skb_queue not empty, %d\n", skb_queue_len(&precvpriv->free_recv_skb_queue)); + + skb_queue_purge(&precvpriv->free_recv_skb_queue); +} diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c new file mode 100644 index 0000000000000..bd8a9ae5d0770 --- /dev/null +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c @@ -0,0 +1,706 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTL8188E_XMIT_C_ +#include +#include +#include +#include +#include +#include + +s32 rtl8188eu_init_xmit_priv(struct adapter *adapt) +{ + struct xmit_priv *pxmitpriv = &adapt->xmitpriv; + + tasklet_init(&pxmitpriv->xmit_tasklet, + (void(*)(unsigned long))rtl8188eu_xmit_tasklet, + (unsigned long)adapt); + return _SUCCESS; +} + +void rtl8188eu_free_xmit_priv(struct adapter *adapt) +{ +} + +static u8 urb_zero_packet_chk(struct adapter *adapt, int sz) +{ + u8 set_tx_desc_offset; + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + set_tx_desc_offset = (((sz + TXDESC_SIZE) % haldata->UsbBulkOutSize) == 0) ? 1 : 0; + + return set_tx_desc_offset; +} + +static void rtl8188eu_cal_txdesc_chksum(struct tx_desc *ptxdesc) +{ + u16 *usptr = (u16 *)ptxdesc; + u32 count = 16; /* (32 bytes / 2 bytes per XOR) => 16 times */ + u32 index; + u16 checksum = 0; + + /* Clear first */ + ptxdesc->txdw7 &= cpu_to_le32(0xffff0000); + + for (index = 0; index < count; index++) + checksum = checksum ^ le16_to_cpu(*(__le16 *)(usptr + index)); + ptxdesc->txdw7 |= cpu_to_le32(0x0000ffff & checksum); +} + +/* Description: In normal chip, we should send some packet to Hw which will be used by Fw */ +/* in FW LPS mode. The function is to fill the Tx descriptor of this packets, then */ +/* Fw can tell Hw to send these packet derectly. */ +void rtl8188e_fill_fake_txdesc(struct adapter *adapt, u8 *desc, u32 BufferLen, u8 ispspoll, u8 is_btqosnull) +{ + struct tx_desc *ptxdesc; + + /* Clear all status */ + ptxdesc = (struct tx_desc *)desc; + _rtw_memset(desc, 0, TXDESC_SIZE); + + /* offset 0 */ + ptxdesc->txdw0 |= cpu_to_le32(OWN | FSG | LSG); /* own, bFirstSeg, bLastSeg; */ + + ptxdesc->txdw0 |= cpu_to_le32(((TXDESC_SIZE+OFFSET_SZ)<txdw0 |= cpu_to_le32(BufferLen&0x0000ffff); /* Buffer size + command header */ + + /* offset 4 */ + ptxdesc->txdw1 |= cpu_to_le32((QSLT_MGNT<txdw1 |= cpu_to_le32(NAVUSEHDR); + } else { + ptxdesc->txdw4 |= cpu_to_le32(BIT(7)); /* Hw set sequence number */ + ptxdesc->txdw3 |= cpu_to_le32((8 << 28)); /* set bit3 to 1. Suugested by TimChen. 2009.12.29. */ + } + + if (is_btqosnull) + ptxdesc->txdw2 |= cpu_to_le32(BIT(23)); /* BT NULL */ + + /* offset 16 */ + ptxdesc->txdw4 |= cpu_to_le32(BIT(8));/* driver uses rate */ + + /* USB interface drop packet if the checksum of descriptor isn't correct. */ + /* Using this checksum can let hardware recovery from packet bulk out error (e.g. Cancel URC, Bulk out error.). */ + rtl8188eu_cal_txdesc_chksum(ptxdesc); +} + +static void fill_txdesc_sectype(struct pkt_attrib *pattrib, struct tx_desc *ptxdesc) +{ + if ((pattrib->encrypt > 0) && !pattrib->bswenc) { + switch (pattrib->encrypt) { + /* SEC_TYPE : 0:NO_ENC,1:WEP40/TKIP,2:WAPI,3:AES */ + case _WEP40_: + case _WEP104_: + ptxdesc->txdw1 |= cpu_to_le32((0x01<txdw2 |= cpu_to_le32(0x7 << AMPDU_DENSITY_SHT); + break; + case _TKIP_: + case _TKIP_WTMIC_: + ptxdesc->txdw1 |= cpu_to_le32((0x01<txdw2 |= cpu_to_le32(0x7 << AMPDU_DENSITY_SHT); + break; + case _AES_: + ptxdesc->txdw1 |= cpu_to_le32((0x03<txdw2 |= cpu_to_le32(0x7 << AMPDU_DENSITY_SHT); + break; + case _NO_PRIVACY_: + default: + break; + } + } +} + +static void fill_txdesc_vcs(struct pkt_attrib *pattrib, __le32 *pdw) +{ + switch (pattrib->vcs_mode) { + case RTS_CTS: + *pdw |= cpu_to_le32(RTS_EN); + break; + case CTS_TO_SELF: + *pdw |= cpu_to_le32(CTS_2_SELF); + break; + case NONE_VCS: + default: + break; + } + if (pattrib->vcs_mode) { + *pdw |= cpu_to_le32(HW_RTS_EN); + /* Set RTS BW */ + if (pattrib->ht_en) { + *pdw |= (pattrib->bwmode&HT_CHANNEL_WIDTH_40) ? cpu_to_le32(BIT(27)) : 0; + + if (pattrib->ch_offset == HAL_PRIME_CHNL_OFFSET_LOWER) + *pdw |= cpu_to_le32((0x01 << 28) & 0x30000000); + else if (pattrib->ch_offset == HAL_PRIME_CHNL_OFFSET_UPPER) + *pdw |= cpu_to_le32((0x02 << 28) & 0x30000000); + else if (pattrib->ch_offset == HAL_PRIME_CHNL_OFFSET_DONT_CARE) + *pdw |= 0; + else + *pdw |= cpu_to_le32((0x03 << 28) & 0x30000000); + } + } +} + +static void fill_txdesc_phy(struct pkt_attrib *pattrib, __le32 *pdw) +{ + if (pattrib->ht_en) { + *pdw |= (pattrib->bwmode&HT_CHANNEL_WIDTH_40) ? cpu_to_le32(BIT(25)) : 0; + + if (pattrib->ch_offset == HAL_PRIME_CHNL_OFFSET_LOWER) + *pdw |= cpu_to_le32((0x01 << DATA_SC_SHT) & 0x003f0000); + else if (pattrib->ch_offset == HAL_PRIME_CHNL_OFFSET_UPPER) + *pdw |= cpu_to_le32((0x02 << DATA_SC_SHT) & 0x003f0000); + else if (pattrib->ch_offset == HAL_PRIME_CHNL_OFFSET_DONT_CARE) + *pdw |= 0; + else + *pdw |= cpu_to_le32((0x03 << DATA_SC_SHT) & 0x003f0000); + } +} + +static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz, u8 bagg_pkt) +{ + int pull = 0; + uint qsel; + u8 data_rate, pwr_status, offset; + struct adapter *adapt = pxmitframe->padapter; + struct pkt_attrib *pattrib = &pxmitframe->attrib; + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + struct tx_desc *ptxdesc = (struct tx_desc *)pmem; + struct mlme_ext_priv *pmlmeext = &adapt->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + int bmcst = IS_MCAST(pattrib->ra); + + if (adapt->registrypriv.mp_mode == 0) { + if ((!bagg_pkt) && (urb_zero_packet_chk(adapt, sz) == 0)) { + ptxdesc = (struct tx_desc *)(pmem+PACKET_OFFSET_SZ); + pull = 1; + } + } + + _rtw_memset(ptxdesc, 0, sizeof(struct tx_desc)); + + /* 4 offset 0 */ + ptxdesc->txdw0 |= cpu_to_le32(OWN | FSG | LSG); + ptxdesc->txdw0 |= cpu_to_le32(sz & 0x0000ffff);/* update TXPKTSIZE */ + + offset = TXDESC_SIZE + OFFSET_SZ; + + ptxdesc->txdw0 |= cpu_to_le32(((offset) << OFFSET_SHT) & 0x00ff0000);/* 32 bytes for TX Desc */ + + if (bmcst) + ptxdesc->txdw0 |= cpu_to_le32(BMC); + + if (adapt->registrypriv.mp_mode == 0) { + if (!bagg_pkt) { + if ((pull) && (pxmitframe->pkt_offset > 0)) + pxmitframe->pkt_offset = pxmitframe->pkt_offset - 1; + } + } + + /* pkt_offset, unit:8 bytes padding */ + if (pxmitframe->pkt_offset > 0) + ptxdesc->txdw1 |= cpu_to_le32((pxmitframe->pkt_offset << 26) & 0x7c000000); + + /* driver uses rate */ + ptxdesc->txdw4 |= cpu_to_le32(USERATE);/* rate control always by driver */ + + if ((pxmitframe->frame_tag & 0x0f) == DATA_FRAMETAG) { + /* offset 4 */ + ptxdesc->txdw1 |= cpu_to_le32(pattrib->mac_id & 0x3F); + + qsel = (uint)(pattrib->qsel & 0x0000001f); + ptxdesc->txdw1 |= cpu_to_le32((qsel << QSEL_SHT) & 0x00001f00); + + ptxdesc->txdw1 |= cpu_to_le32((pattrib->raid << RATE_ID_SHT) & 0x000F0000); + + fill_txdesc_sectype(pattrib, ptxdesc); + + if (pattrib->ampdu_en) { + ptxdesc->txdw2 |= cpu_to_le32(AGG_EN);/* AGG EN */ + ptxdesc->txdw6 = cpu_to_le32(0x6666f800); + } else { + ptxdesc->txdw2 |= cpu_to_le32(AGG_BK);/* AGG BK */ + } + + /* offset 8 */ + + /* offset 12 */ + ptxdesc->txdw3 |= cpu_to_le32((pattrib->seqnum << SEQ_SHT) & 0x0FFF0000); + + /* offset 16 , offset 20 */ + if (pattrib->qos_en) + ptxdesc->txdw4 |= cpu_to_le32(QOS);/* QoS */ + + /* offset 20 */ + if (pxmitframe->agg_num > 1) + ptxdesc->txdw5 |= cpu_to_le32((pxmitframe->agg_num << USB_TXAGG_NUM_SHT) & 0xFF000000); + + if ((pattrib->ether_type != 0x888e) && + (pattrib->ether_type != 0x0806) && + (pattrib->ether_type != 0x88b4) && + (pattrib->dhcp_pkt != 1)) { + /* Non EAP & ARP & DHCP type data packet */ + + fill_txdesc_vcs(pattrib, &ptxdesc->txdw4); + fill_txdesc_phy(pattrib, &ptxdesc->txdw4); + + ptxdesc->txdw4 |= cpu_to_le32(0x00000008);/* RTS Rate=24M */ + ptxdesc->txdw5 |= cpu_to_le32(0x0001ff00);/* DATA/RTS Rate FB LMT */ + + if (pattrib->ht_en) { + if (ODM_RA_GetShortGI_8188E(&haldata->odmpriv, pattrib->mac_id)) + ptxdesc->txdw5 |= cpu_to_le32(SGI);/* SGI */ + } + data_rate = ODM_RA_GetDecisionRate_8188E(&haldata->odmpriv, pattrib->mac_id); + ptxdesc->txdw5 |= cpu_to_le32(data_rate & 0x3F); + pwr_status = ODM_RA_GetHwPwrStatus_8188E(&haldata->odmpriv, pattrib->mac_id); + ptxdesc->txdw4 |= cpu_to_le32((pwr_status & 0x7) << PWR_STATUS_SHT); + } else { + /* EAP data packet and ARP packet and DHCP. */ + /* Use the 1M data rate to send the EAP/ARP packet. */ + /* This will maybe make the handshake smooth. */ + ptxdesc->txdw2 |= cpu_to_le32(AGG_BK);/* AGG BK */ + if (pmlmeinfo->preamble_mode == PREAMBLE_SHORT) + ptxdesc->txdw4 |= cpu_to_le32(BIT(24));/* DATA_SHORT */ + ptxdesc->txdw5 |= cpu_to_le32(MRateToHwRate(pmlmeext->tx_rate)); + } + } else if ((pxmitframe->frame_tag&0x0f) == MGNT_FRAMETAG) { + /* offset 4 */ + ptxdesc->txdw1 |= cpu_to_le32(pattrib->mac_id & 0x3f); + + qsel = (uint)(pattrib->qsel&0x0000001f); + ptxdesc->txdw1 |= cpu_to_le32((qsel << QSEL_SHT) & 0x00001f00); + + ptxdesc->txdw1 |= cpu_to_le32((pattrib->raid << RATE_ID_SHT) & 0x000f0000); + + /* offset 8 */ + /* CCX-TXRPT ack for xmit mgmt frames. */ + if (pxmitframe->ack_report) + ptxdesc->txdw2 |= cpu_to_le32(BIT(19)); + + /* offset 12 */ + ptxdesc->txdw3 |= cpu_to_le32((pattrib->seqnum<txdw5 |= cpu_to_le32(RTY_LMT_EN);/* retry limit enable */ + if (pattrib->retry_ctrl) + ptxdesc->txdw5 |= cpu_to_le32(0x00180000);/* retry limit = 6 */ + else + ptxdesc->txdw5 |= cpu_to_le32(0x00300000);/* retry limit = 12 */ + + ptxdesc->txdw5 |= cpu_to_le32(MRateToHwRate(pmlmeext->tx_rate)); + } else if ((pxmitframe->frame_tag&0x0f) == TXAGG_FRAMETAG) { + DBG_88E("pxmitframe->frame_tag == TXAGG_FRAMETAG\n"); + } else if (((pxmitframe->frame_tag&0x0f) == MP_FRAMETAG) && + (adapt->registrypriv.mp_mode == 1)) { + fill_txdesc_for_mp(adapt, ptxdesc); + } else { + DBG_88E("pxmitframe->frame_tag = %d\n", pxmitframe->frame_tag); + + /* offset 4 */ + ptxdesc->txdw1 |= cpu_to_le32((4) & 0x3f);/* CAM_ID(MAC_ID) */ + + ptxdesc->txdw1 |= cpu_to_le32((6 << RATE_ID_SHT) & 0x000f0000);/* raid */ + + /* offset 8 */ + + /* offset 12 */ + ptxdesc->txdw3 |= cpu_to_le32((pattrib->seqnum<txdw5 |= cpu_to_le32(MRateToHwRate(pmlmeext->tx_rate)); + } + + /* 2009.11.05. tynli_test. Suggested by SD4 Filen for FW LPS. */ + /* (1) The sequence number of each non-Qos frame / broadcast / multicast / */ + /* mgnt frame should be controled by Hw because Fw will also send null data */ + /* which we cannot control when Fw LPS enable. */ + /* --> default enable non-Qos data sequense number. 2010.06.23. by tynli. */ + /* (2) Enable HW SEQ control for beacon packet, because we use Hw beacon. */ + /* (3) Use HW Qos SEQ to control the seq num of Ext port non-Qos packets. */ + /* 2010.06.23. Added by tynli. */ + if (!pattrib->qos_en) { + ptxdesc->txdw3 |= cpu_to_le32(EN_HWSEQ); /* Hw set sequence number */ + ptxdesc->txdw4 |= cpu_to_le32(HW_SSN); /* Hw set sequence number */ + } + + ODM_SetTxAntByTxInfo_88E(&haldata->odmpriv, pmem, pattrib->mac_id); + + rtl8188eu_cal_txdesc_chksum(ptxdesc); + _dbg_dump_tx_info(adapt, pxmitframe->frame_tag, ptxdesc); + return pull; +} + +/* for non-agg data frame or management frame */ +static s32 rtw_dump_xframe(struct adapter *adapt, struct xmit_frame *pxmitframe) +{ + s32 ret = _SUCCESS; + s32 inner_ret = _SUCCESS; + int t, sz, w_sz, pull = 0; + u8 *mem_addr; + u32 ff_hwaddr; + struct xmit_buf *pxmitbuf = pxmitframe->pxmitbuf; + struct pkt_attrib *pattrib = &pxmitframe->attrib; + struct xmit_priv *pxmitpriv = &adapt->xmitpriv; + struct security_priv *psecuritypriv = &adapt->securitypriv; + if ((pxmitframe->frame_tag == DATA_FRAMETAG) && + (pxmitframe->attrib.ether_type != 0x0806) && + (pxmitframe->attrib.ether_type != 0x888e) && + (pxmitframe->attrib.ether_type != 0x88b4) && + (pxmitframe->attrib.dhcp_pkt != 1)) + rtw_issue_addbareq_cmd(adapt, pxmitframe); + mem_addr = pxmitframe->buf_addr; + + RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_dump_xframe()\n")); + + for (t = 0; t < pattrib->nr_frags; t++) { + if (inner_ret != _SUCCESS && ret == _SUCCESS) + ret = _FAIL; + + if (t != (pattrib->nr_frags - 1)) { + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("pattrib->nr_frags=%d\n", pattrib->nr_frags)); + + sz = pxmitpriv->frag_len; + sz = sz - 4 - (psecuritypriv->sw_encrypt ? 0 : pattrib->icv_len); + } else { + /* no frag */ + sz = pattrib->last_txcmdsz; + } + + pull = update_txdesc(pxmitframe, mem_addr, sz, false); + + if (pull) { + mem_addr += PACKET_OFFSET_SZ; /* pull txdesc head */ + pxmitframe->buf_addr = mem_addr; + w_sz = sz + TXDESC_SIZE; + } else { + w_sz = sz + TXDESC_SIZE + PACKET_OFFSET_SZ; + } + ff_hwaddr = rtw_get_ff_hwaddr(pxmitframe); + + inner_ret = rtw_write_port(adapt, ff_hwaddr, w_sz, (unsigned char *)pxmitbuf); + + rtw_count_tx_stats(adapt, pxmitframe, sz); + + RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_write_port, w_sz=%d\n", w_sz)); + + mem_addr += w_sz; + + mem_addr = (u8 *)RND4(((size_t)(mem_addr))); + } + + rtw_free_xmitframe(pxmitpriv, pxmitframe); + + if (ret != _SUCCESS) + rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_UNKNOWN); + + return ret; +} + +static u32 xmitframe_need_length(struct xmit_frame *pxmitframe) +{ + struct pkt_attrib *pattrib = &pxmitframe->attrib; + + u32 len = 0; + + /* no consider fragement */ + len = pattrib->hdrlen + pattrib->iv_len + + SNAP_SIZE + sizeof(u16) + + pattrib->pktlen + + ((pattrib->bswenc) ? pattrib->icv_len : 0); + + if (pattrib->encrypt == _TKIP_) + len += 8; + + return len; +} + +s32 rtl8188eu_xmitframe_complete(struct adapter *adapt, struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + struct xmit_frame *pxmitframe = NULL; + struct xmit_frame *pfirstframe = NULL; + + /* aggregate variable */ + struct hw_xmit *phwxmit; + struct sta_info *psta = NULL; + struct tx_servq *ptxservq = NULL; + + unsigned long irql; + struct list_head *xmitframe_plist = NULL, *xmitframe_phead = NULL; + + u32 pbuf; /* next pkt address */ + u32 pbuf_tail; /* last pkt tail */ + u32 len; /* packet length, except TXDESC_SIZE and PKT_OFFSET */ + + u32 bulksize = haldata->UsbBulkOutSize; + u8 desc_cnt; + u32 bulkptr; + + /* dump frame variable */ + u32 ff_hwaddr; + + RT_TRACE(_module_rtl8192c_xmit_c_, _drv_info_, ("+xmitframe_complete\n")); + + /* check xmitbuffer is ok */ + if (pxmitbuf == NULL) { + pxmitbuf = rtw_alloc_xmitbuf(pxmitpriv); + if (pxmitbuf == NULL) + return false; + } + + /* 3 1. pick up first frame */ + do { + rtw_free_xmitframe(pxmitpriv, pxmitframe); + + pxmitframe = rtw_dequeue_xframe(pxmitpriv, pxmitpriv->hwxmits, pxmitpriv->hwxmit_entry); + if (pxmitframe == NULL) { + /* no more xmit frame, release xmit buffer */ + rtw_free_xmitbuf(pxmitpriv, pxmitbuf); + return false; + } + + pxmitframe->pxmitbuf = pxmitbuf; + pxmitframe->buf_addr = pxmitbuf->pbuf; + pxmitbuf->priv_data = pxmitframe; + + pxmitframe->agg_num = 1; /* alloc xmitframe should assign to 1. */ + pxmitframe->pkt_offset = 1; /* first frame of aggregation, reserve offset */ + + rtw_xmitframe_coalesce(adapt, pxmitframe->pkt, pxmitframe); + + /* always return ndis_packet after rtw_xmitframe_coalesce */ + rtw_os_xmit_complete(adapt, pxmitframe); + + break; + } while (1); + + /* 3 2. aggregate same priority and same DA(AP or STA) frames */ + pfirstframe = pxmitframe; + len = xmitframe_need_length(pfirstframe) + TXDESC_SIZE + (pfirstframe->pkt_offset*PACKET_OFFSET_SZ); + pbuf_tail = len; + pbuf = _RND8(pbuf_tail); + + /* check pkt amount in one bulk */ + desc_cnt = 0; + bulkptr = bulksize; + if (pbuf < bulkptr) { + desc_cnt++; + } else { + desc_cnt = 0; + bulkptr = ((pbuf / bulksize) + 1) * bulksize; /* round to next bulksize */ + } + + /* dequeue same priority packet from station tx queue */ + psta = pfirstframe->attrib.psta; + switch (pfirstframe->attrib.priority) { + case 1: + case 2: + ptxservq = &(psta->sta_xmitpriv.bk_q); + phwxmit = pxmitpriv->hwxmits + 3; + break; + case 4: + case 5: + ptxservq = &(psta->sta_xmitpriv.vi_q); + phwxmit = pxmitpriv->hwxmits + 1; + break; + case 6: + case 7: + ptxservq = &(psta->sta_xmitpriv.vo_q); + phwxmit = pxmitpriv->hwxmits; + break; + case 0: + case 3: + default: + ptxservq = &(psta->sta_xmitpriv.be_q); + phwxmit = pxmitpriv->hwxmits + 2; + break; + } + _enter_critical_bh(&pxmitpriv->lock, &irql); + + xmitframe_phead = get_list_head(&ptxservq->sta_pending); + xmitframe_plist = get_next(xmitframe_phead); + + while (!rtw_end_of_queue_search(xmitframe_phead, xmitframe_plist)) { + pxmitframe = LIST_CONTAINOR(xmitframe_plist, struct xmit_frame, list); + xmitframe_plist = get_next(xmitframe_plist); + + pxmitframe->agg_num = 0; /* not first frame of aggregation */ + pxmitframe->pkt_offset = 0; /* not first frame of aggregation, no need to reserve offset */ + + len = xmitframe_need_length(pxmitframe) + TXDESC_SIZE + (pxmitframe->pkt_offset*PACKET_OFFSET_SZ); + + if (_RND8(pbuf + len) > MAX_XMITBUF_SZ) { + pxmitframe->agg_num = 1; + pxmitframe->pkt_offset = 1; + break; + } + rtw_list_delete(&pxmitframe->list); + ptxservq->qcnt--; + phwxmit->accnt--; + + pxmitframe->buf_addr = pxmitbuf->pbuf + pbuf; + + rtw_xmitframe_coalesce(adapt, pxmitframe->pkt, pxmitframe); + /* always return ndis_packet after rtw_xmitframe_coalesce */ + rtw_os_xmit_complete(adapt, pxmitframe); + + /* (len - TXDESC_SIZE) == pxmitframe->attrib.last_txcmdsz */ + update_txdesc(pxmitframe, pxmitframe->buf_addr, pxmitframe->attrib.last_txcmdsz, true); + + /* don't need xmitframe any more */ + rtw_free_xmitframe(pxmitpriv, pxmitframe); + + /* handle pointer and stop condition */ + pbuf_tail = pbuf + len; + pbuf = _RND8(pbuf_tail); + + pfirstframe->agg_num++; + if (MAX_TX_AGG_PACKET_NUMBER == pfirstframe->agg_num) + break; + + if (pbuf < bulkptr) { + desc_cnt++; + if (desc_cnt == haldata->UsbTxAggDescNum) + break; + } else { + desc_cnt = 0; + bulkptr = ((pbuf / bulksize) + 1) * bulksize; + } + } /* end while (aggregate same priority and same DA(AP or STA) frames) */ + + if (_rtw_queue_empty(&ptxservq->sta_pending) == true) + rtw_list_delete(&ptxservq->tx_pending); + + _exit_critical_bh(&pxmitpriv->lock, &irql); + if ((pfirstframe->attrib.ether_type != 0x0806) && + (pfirstframe->attrib.ether_type != 0x888e) && + (pfirstframe->attrib.ether_type != 0x88b4) && + (pfirstframe->attrib.dhcp_pkt != 1)) + rtw_issue_addbareq_cmd(adapt, pfirstframe); + /* 3 3. update first frame txdesc */ + if ((pbuf_tail % bulksize) == 0) { + /* remove pkt_offset */ + pbuf_tail -= PACKET_OFFSET_SZ; + pfirstframe->buf_addr += PACKET_OFFSET_SZ; + pfirstframe->pkt_offset--; + } + + update_txdesc(pfirstframe, pfirstframe->buf_addr, pfirstframe->attrib.last_txcmdsz, true); + + /* 3 4. write xmit buffer to USB FIFO */ + ff_hwaddr = rtw_get_ff_hwaddr(pfirstframe); + rtw_write_port(adapt, ff_hwaddr, pbuf_tail, (u8 *)pxmitbuf); + + /* 3 5. update statisitc */ + pbuf_tail -= (pfirstframe->agg_num * TXDESC_SIZE); + pbuf_tail -= (pfirstframe->pkt_offset * PACKET_OFFSET_SZ); + + rtw_count_tx_stats(adapt, pfirstframe, pbuf_tail); + + rtw_free_xmitframe(pxmitpriv, pfirstframe); + + return true; +} + +static s32 xmitframe_direct(struct adapter *adapt, struct xmit_frame *pxmitframe) +{ + s32 res = _SUCCESS; + + res = rtw_xmitframe_coalesce(adapt, pxmitframe->pkt, pxmitframe); + if (res == _SUCCESS) + rtw_dump_xframe(adapt, pxmitframe); + else + DBG_88E("==> %s xmitframe_coalsece failed\n", __func__); + return res; +} + +/* + * Return + * true dump packet directly + * false enqueue packet + */ +static s32 pre_xmitframe(struct adapter *adapt, struct xmit_frame *pxmitframe) +{ + unsigned long irql; + s32 res; + struct xmit_buf *pxmitbuf = NULL; + struct xmit_priv *pxmitpriv = &adapt->xmitpriv; + struct pkt_attrib *pattrib = &pxmitframe->attrib; + struct mlme_priv *pmlmepriv = &adapt->mlmepriv; + + _enter_critical_bh(&pxmitpriv->lock, &irql); + + if (rtw_txframes_sta_ac_pending(adapt, pattrib) > 0) + goto enqueue; + + if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING) == true) + goto enqueue; + + pxmitbuf = rtw_alloc_xmitbuf(pxmitpriv); + if (pxmitbuf == NULL) + goto enqueue; + + _exit_critical_bh(&pxmitpriv->lock, &irql); + + pxmitframe->pxmitbuf = pxmitbuf; + pxmitframe->buf_addr = pxmitbuf->pbuf; + pxmitbuf->priv_data = pxmitframe; + + if (xmitframe_direct(adapt, pxmitframe) != _SUCCESS) { + rtw_free_xmitbuf(pxmitpriv, pxmitbuf); + rtw_free_xmitframe(pxmitpriv, pxmitframe); + } + + return true; + +enqueue: + res = rtw_xmitframe_enqueue(adapt, pxmitframe); + _exit_critical_bh(&pxmitpriv->lock, &irql); + + if (res != _SUCCESS) { + RT_TRACE(_module_xmit_osdep_c_, _drv_err_, ("pre_xmitframe: enqueue xmitframe fail\n")); + rtw_free_xmitframe(pxmitpriv, pxmitframe); + + /* Trick, make the statistics correct */ + pxmitpriv->tx_pkts--; + pxmitpriv->tx_drop++; + return true; + } + + return false; +} + +s32 rtl8188eu_mgnt_xmit(struct adapter *adapt, struct xmit_frame *pmgntframe) +{ + return rtw_dump_xframe(adapt, pmgntframe); +} + +/* + * Return + * true dump packet directly ok + * false temporary can't transmit packets to hardware + */ +s32 rtl8188eu_hal_xmit(struct adapter *adapt, struct xmit_frame *pxmitframe) +{ + return pre_xmitframe(adapt, pxmitframe); +} -- GitLab From d3f4b8280abe2890072df62c3f0c3ab6c0414f44 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 21 Aug 2013 22:34:00 -0500 Subject: [PATCH 776/942] staging: r8188eu: Add files for new driver - part 18 This commit adds files hal/usb_halinit.c and hal/usb_ops_linux.c. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/usb_halinit.c | 2346 +++++++++++++++++ drivers/staging/rtl8188eu/hal/usb_ops_linux.c | 726 +++++ 2 files changed, 3072 insertions(+) create mode 100644 drivers/staging/rtl8188eu/hal/usb_halinit.c create mode 100644 drivers/staging/rtl8188eu/hal/usb_ops_linux.c diff --git a/drivers/staging/rtl8188eu/hal/usb_halinit.c b/drivers/staging/rtl8188eu/hal/usb_halinit.c new file mode 100644 index 0000000000000..5e656ce454070 --- /dev/null +++ b/drivers/staging/rtl8188eu/hal/usb_halinit.c @@ -0,0 +1,2346 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _HCI_HAL_INIT_C_ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#define HAL_MAC_ENABLE 1 +#define HAL_BB_ENABLE 1 +#define HAL_RF_ENABLE 1 + +static void _ConfigNormalChipOutEP_8188E(struct adapter *adapt, u8 NumOutPipe) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + + switch (NumOutPipe) { + case 3: + haldata->OutEpQueueSel = TX_SELE_HQ | TX_SELE_LQ | TX_SELE_NQ; + haldata->OutEpNumber = 3; + break; + case 2: + haldata->OutEpQueueSel = TX_SELE_HQ | TX_SELE_NQ; + haldata->OutEpNumber = 2; + break; + case 1: + haldata->OutEpQueueSel = TX_SELE_HQ; + haldata->OutEpNumber = 1; + break; + default: + break; + } + DBG_88E("%s OutEpQueueSel(0x%02x), OutEpNumber(%d)\n", __func__, haldata->OutEpQueueSel, haldata->OutEpNumber); +} + +static bool HalUsbSetQueuePipeMapping8188EUsb(struct adapter *adapt, u8 NumInPipe, u8 NumOutPipe) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + bool result = false; + + _ConfigNormalChipOutEP_8188E(adapt, NumOutPipe); + + /* Normal chip with one IN and one OUT doesn't have interrupt IN EP. */ + if (1 == haldata->OutEpNumber) { + if (1 != NumInPipe) + return result; + } + + /* All config other than above support one Bulk IN and one Interrupt IN. */ + + result = Hal_MappingOutPipe(adapt, NumOutPipe); + + return result; +} + +static void rtl8188eu_interface_configure(struct adapter *adapt) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapt); + + if (pdvobjpriv->ishighspeed) + haldata->UsbBulkOutSize = USB_HIGH_SPEED_BULK_SIZE;/* 512 bytes */ + else + haldata->UsbBulkOutSize = USB_FULL_SPEED_BULK_SIZE;/* 64 bytes */ + + haldata->interfaceIndex = pdvobjpriv->InterfaceNumber; + + haldata->UsbTxAggMode = 1; + haldata->UsbTxAggDescNum = 0x6; /* only 4 bits */ + + haldata->UsbRxAggMode = USB_RX_AGG_DMA;/* USB_RX_AGG_DMA; */ + haldata->UsbRxAggBlockCount = 8; /* unit : 512b */ + haldata->UsbRxAggBlockTimeout = 0x6; + haldata->UsbRxAggPageCount = 48; /* uint :128 b 0x0A; 10 = MAX_RX_DMA_BUFFER_SIZE/2/haldata->UsbBulkOutSize */ + haldata->UsbRxAggPageTimeout = 0x4; /* 6, absolute time = 34ms/(2^6) */ + + HalUsbSetQueuePipeMapping8188EUsb(adapt, + pdvobjpriv->RtNumInPipes, pdvobjpriv->RtNumOutPipes); +} + +static u32 rtl8188eu_InitPowerOn(struct adapter *adapt) +{ + u16 value16; + /* HW Power on sequence */ + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + if (haldata->bMacPwrCtrlOn) + return _SUCCESS; + + if (!HalPwrSeqCmdParsing(adapt, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK, Rtl8188E_NIC_PWR_ON_FLOW)) { + DBG_88E(KERN_ERR "%s: run power on flow fail\n", __func__); + return _FAIL; + } + + /* Enable MAC DMA/WMAC/SCHEDULE/SEC block */ + /* Set CR bit10 to enable 32k calibration. Suggested by SD1 Gimmy. Added by tynli. 2011.08.31. */ + rtw_write16(adapt, REG_CR, 0x00); /* suggseted by zhouzhou, by page, 20111230 */ + + /* Enable MAC DMA/WMAC/SCHEDULE/SEC block */ + value16 = rtw_read16(adapt, REG_CR); + value16 |= (HCI_TXDMA_EN | HCI_RXDMA_EN | TXDMA_EN | RXDMA_EN + | PROTOCOL_EN | SCHEDULE_EN | ENSEC | CALTMR_EN); + /* for SDIO - Set CR bit10 to enable 32k calibration. Suggested by SD1 Gimmy. Added by tynli. 2011.08.31. */ + + rtw_write16(adapt, REG_CR, value16); + haldata->bMacPwrCtrlOn = true; + + return _SUCCESS; +} + +/* Shall USB interface init this? */ +static void _InitInterrupt(struct adapter *Adapter) +{ + u32 imr, imr_ex; + u8 usb_opt; + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + + /* HISR write one to clear */ + rtw_write32(Adapter, REG_HISR_88E, 0xFFFFFFFF); + /* HIMR - */ + imr = IMR_PSTIMEOUT_88E | IMR_TBDER_88E | IMR_CPWM_88E | IMR_CPWM2_88E; + rtw_write32(Adapter, REG_HIMR_88E, imr); + haldata->IntrMask[0] = imr; + + imr_ex = IMR_TXERR_88E | IMR_RXERR_88E | IMR_TXFOVW_88E | IMR_RXFOVW_88E; + rtw_write32(Adapter, REG_HIMRE_88E, imr_ex); + haldata->IntrMask[1] = imr_ex; + + /* REG_USB_SPECIAL_OPTION - BIT(4) */ + /* 0; Use interrupt endpoint to upload interrupt pkt */ + /* 1; Use bulk endpoint to upload interrupt pkt, */ + usb_opt = rtw_read8(Adapter, REG_USB_SPECIAL_OPTION); + + if (!adapter_to_dvobj(Adapter)->ishighspeed) + usb_opt = usb_opt & (~INT_BULK_SEL); + else + usb_opt = usb_opt | (INT_BULK_SEL); + + rtw_write8(Adapter, REG_USB_SPECIAL_OPTION, usb_opt); +} + +static void _InitQueueReservedPage(struct adapter *Adapter) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + struct registry_priv *pregistrypriv = &Adapter->registrypriv; + u32 numHQ = 0; + u32 numLQ = 0; + u32 numNQ = 0; + u32 numPubQ; + u32 value32; + u8 value8; + bool bWiFiConfig = pregistrypriv->wifi_spec; + + if (bWiFiConfig) { + if (haldata->OutEpQueueSel & TX_SELE_HQ) + numHQ = 0x29; + + if (haldata->OutEpQueueSel & TX_SELE_LQ) + numLQ = 0x1C; + + /* NOTE: This step shall be proceed before writting REG_RQPN. */ + if (haldata->OutEpQueueSel & TX_SELE_NQ) + numNQ = 0x1C; + value8 = (u8)_NPQ(numNQ); + rtw_write8(Adapter, REG_RQPN_NPQ, value8); + + numPubQ = 0xA8 - numHQ - numLQ - numNQ; + + /* TX DMA */ + value32 = _HPQ(numHQ) | _LPQ(numLQ) | _PUBQ(numPubQ) | LD_RQPN; + rtw_write32(Adapter, REG_RQPN, value32); + } else { + rtw_write16(Adapter, REG_RQPN_NPQ, 0x0000);/* Just follow MP Team,??? Georgia 03/28 */ + rtw_write16(Adapter, REG_RQPN_NPQ, 0x0d); + rtw_write32(Adapter, REG_RQPN, 0x808E000d);/* reserve 7 page for LPS */ + } +} + +static void _InitTxBufferBoundary(struct adapter *Adapter, u8 txpktbuf_bndy) +{ + rtw_write8(Adapter, REG_TXPKTBUF_BCNQ_BDNY, txpktbuf_bndy); + rtw_write8(Adapter, REG_TXPKTBUF_MGQ_BDNY, txpktbuf_bndy); + rtw_write8(Adapter, REG_TXPKTBUF_WMAC_LBK_BF_HD, txpktbuf_bndy); + rtw_write8(Adapter, REG_TRXFF_BNDY, txpktbuf_bndy); + rtw_write8(Adapter, REG_TDECTRL+1, txpktbuf_bndy); +} + +static void _InitPageBoundary(struct adapter *Adapter) +{ + /* RX Page Boundary */ + /* */ + u16 rxff_bndy = MAX_RX_DMA_BUFFER_SIZE_88E-1; + + rtw_write16(Adapter, (REG_TRXFF_BNDY + 2), rxff_bndy); +} + +static void _InitNormalChipRegPriority(struct adapter *Adapter, u16 beQ, + u16 bkQ, u16 viQ, u16 voQ, u16 mgtQ, + u16 hiQ) +{ + u16 value16 = (rtw_read16(Adapter, REG_TRXDMA_CTRL) & 0x7); + + value16 |= _TXDMA_BEQ_MAP(beQ) | _TXDMA_BKQ_MAP(bkQ) | + _TXDMA_VIQ_MAP(viQ) | _TXDMA_VOQ_MAP(voQ) | + _TXDMA_MGQ_MAP(mgtQ) | _TXDMA_HIQ_MAP(hiQ); + + rtw_write16(Adapter, REG_TRXDMA_CTRL, value16); +} + +static void _InitNormalChipOneOutEpPriority(struct adapter *Adapter) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + + u16 value = 0; + switch (haldata->OutEpQueueSel) { + case TX_SELE_HQ: + value = QUEUE_HIGH; + break; + case TX_SELE_LQ: + value = QUEUE_LOW; + break; + case TX_SELE_NQ: + value = QUEUE_NORMAL; + break; + default: + break; + } + _InitNormalChipRegPriority(Adapter, value, value, value, value, + value, value); +} + +static void _InitNormalChipTwoOutEpPriority(struct adapter *Adapter) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + struct registry_priv *pregistrypriv = &Adapter->registrypriv; + u16 beQ, bkQ, viQ, voQ, mgtQ, hiQ; + u16 valueHi = 0; + u16 valueLow = 0; + + switch (haldata->OutEpQueueSel) { + case (TX_SELE_HQ | TX_SELE_LQ): + valueHi = QUEUE_HIGH; + valueLow = QUEUE_LOW; + break; + case (TX_SELE_NQ | TX_SELE_LQ): + valueHi = QUEUE_NORMAL; + valueLow = QUEUE_LOW; + break; + case (TX_SELE_HQ | TX_SELE_NQ): + valueHi = QUEUE_HIGH; + valueLow = QUEUE_NORMAL; + break; + default: + break; + } + + if (!pregistrypriv->wifi_spec) { + beQ = valueLow; + bkQ = valueLow; + viQ = valueHi; + voQ = valueHi; + mgtQ = valueHi; + hiQ = valueHi; + } else {/* for WMM ,CONFIG_OUT_EP_WIFI_MODE */ + beQ = valueLow; + bkQ = valueHi; + viQ = valueHi; + voQ = valueLow; + mgtQ = valueHi; + hiQ = valueHi; + } + _InitNormalChipRegPriority(Adapter, beQ, bkQ, viQ, voQ, mgtQ, hiQ); +} + +static void _InitNormalChipThreeOutEpPriority(struct adapter *Adapter) +{ + struct registry_priv *pregistrypriv = &Adapter->registrypriv; + u16 beQ, bkQ, viQ, voQ, mgtQ, hiQ; + + if (!pregistrypriv->wifi_spec) {/* typical setting */ + beQ = QUEUE_LOW; + bkQ = QUEUE_LOW; + viQ = QUEUE_NORMAL; + voQ = QUEUE_HIGH; + mgtQ = QUEUE_HIGH; + hiQ = QUEUE_HIGH; + } else {/* for WMM */ + beQ = QUEUE_LOW; + bkQ = QUEUE_NORMAL; + viQ = QUEUE_NORMAL; + voQ = QUEUE_HIGH; + mgtQ = QUEUE_HIGH; + hiQ = QUEUE_HIGH; + } + _InitNormalChipRegPriority(Adapter, beQ, bkQ, viQ, voQ, mgtQ, hiQ); +} + +static void _InitQueuePriority(struct adapter *Adapter) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + + switch (haldata->OutEpNumber) { + case 1: + _InitNormalChipOneOutEpPriority(Adapter); + break; + case 2: + _InitNormalChipTwoOutEpPriority(Adapter); + break; + case 3: + _InitNormalChipThreeOutEpPriority(Adapter); + break; + default: + break; + } +} + +static void _InitNetworkType(struct adapter *Adapter) +{ + u32 value32; + + value32 = rtw_read32(Adapter, REG_CR); + /* TODO: use the other function to set network type */ + value32 = (value32 & ~MASK_NETTYPE) | _NETTYPE(NT_LINK_AP); + + rtw_write32(Adapter, REG_CR, value32); +} + +static void _InitTransferPageSize(struct adapter *Adapter) +{ + /* Tx page size is always 128. */ + + u8 value8; + value8 = _PSRX(PBP_128) | _PSTX(PBP_128); + rtw_write8(Adapter, REG_PBP, value8); +} + +static void _InitDriverInfoSize(struct adapter *Adapter, u8 drvInfoSize) +{ + rtw_write8(Adapter, REG_RX_DRVINFO_SZ, drvInfoSize); +} + +static void _InitWMACSetting(struct adapter *Adapter) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + + haldata->ReceiveConfig = RCR_AAP | RCR_APM | RCR_AM | RCR_AB | + RCR_CBSSID_DATA | RCR_CBSSID_BCN | + RCR_APP_ICV | RCR_AMF | RCR_HTC_LOC_CTRL | + RCR_APP_MIC | RCR_APP_PHYSTS; + + /* some REG_RCR will be modified later by phy_ConfigMACWithHeaderFile() */ + rtw_write32(Adapter, REG_RCR, haldata->ReceiveConfig); + + /* Accept all multicast address */ + rtw_write32(Adapter, REG_MAR, 0xFFFFFFFF); + rtw_write32(Adapter, REG_MAR + 4, 0xFFFFFFFF); +} + +static void _InitAdaptiveCtrl(struct adapter *Adapter) +{ + u16 value16; + u32 value32; + + /* Response Rate Set */ + value32 = rtw_read32(Adapter, REG_RRSR); + value32 &= ~RATE_BITMAP_ALL; + value32 |= RATE_RRSR_CCK_ONLY_1M; + rtw_write32(Adapter, REG_RRSR, value32); + + /* CF-END Threshold */ + + /* SIFS (used in NAV) */ + value16 = _SPEC_SIFS_CCK(0x10) | _SPEC_SIFS_OFDM(0x10); + rtw_write16(Adapter, REG_SPEC_SIFS, value16); + + /* Retry Limit */ + value16 = _LRL(0x30) | _SRL(0x30); + rtw_write16(Adapter, REG_RL, value16); +} + +static void _InitEDCA(struct adapter *Adapter) +{ + /* Set Spec SIFS (used in NAV) */ + rtw_write16(Adapter, REG_SPEC_SIFS, 0x100a); + rtw_write16(Adapter, REG_MAC_SPEC_SIFS, 0x100a); + + /* Set SIFS for CCK */ + rtw_write16(Adapter, REG_SIFS_CTX, 0x100a); + + /* Set SIFS for OFDM */ + rtw_write16(Adapter, REG_SIFS_TRX, 0x100a); + + /* TXOP */ + rtw_write32(Adapter, REG_EDCA_BE_PARAM, 0x005EA42B); + rtw_write32(Adapter, REG_EDCA_BK_PARAM, 0x0000A44F); + rtw_write32(Adapter, REG_EDCA_VI_PARAM, 0x005EA324); + rtw_write32(Adapter, REG_EDCA_VO_PARAM, 0x002FA226); +} + +static void _InitBeaconMaxError(struct adapter *Adapter, bool InfraMode) +{ +} + +static void _InitHWLed(struct adapter *Adapter) +{ + struct led_priv *pledpriv = &(Adapter->ledpriv); + + if (pledpriv->LedStrategy != HW_LED) + return; + +/* HW led control */ +/* to do .... */ +/* must consider cases of antenna diversity/ commbo card/solo card/mini card */ +} + +static void _InitRDGSetting(struct adapter *Adapter) +{ + rtw_write8(Adapter, REG_RD_CTRL, 0xFF); + rtw_write16(Adapter, REG_RD_NAV_NXT, 0x200); + rtw_write8(Adapter, REG_RD_RESP_PKT_TH, 0x05); +} + +static void _InitRxSetting(struct adapter *Adapter) +{ + rtw_write32(Adapter, REG_MACID, 0x87654321); + rtw_write32(Adapter, 0x0700, 0x87654321); +} + +static void _InitRetryFunction(struct adapter *Adapter) +{ + u8 value8; + + value8 = rtw_read8(Adapter, REG_FWHW_TXQ_CTRL); + value8 |= EN_AMPDU_RTY_NEW; + rtw_write8(Adapter, REG_FWHW_TXQ_CTRL, value8); + + /* Set ACK timeout */ + rtw_write8(Adapter, REG_ACKTO, 0x40); +} + +/*----------------------------------------------------------------------------- + * Function: usb_AggSettingTxUpdate() + * + * Overview: Seperate TX/RX parameters update independent for TP detection and + * dynamic TX/RX aggreagtion parameters update. + * + * Input: struct adapter * + * + * Output/Return: NONE + * + * Revised History: + * When Who Remark + * 12/10/2010 MHC Seperate to smaller function. + * + *---------------------------------------------------------------------------*/ +static void usb_AggSettingTxUpdate(struct adapter *Adapter) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + u32 value32; + + if (Adapter->registrypriv.wifi_spec) + haldata->UsbTxAggMode = false; + + if (haldata->UsbTxAggMode) { + value32 = rtw_read32(Adapter, REG_TDECTRL); + value32 = value32 & ~(BLK_DESC_NUM_MASK << BLK_DESC_NUM_SHIFT); + value32 |= ((haldata->UsbTxAggDescNum & BLK_DESC_NUM_MASK) << BLK_DESC_NUM_SHIFT); + + rtw_write32(Adapter, REG_TDECTRL, value32); + } +} /* usb_AggSettingTxUpdate */ + +/*----------------------------------------------------------------------------- + * Function: usb_AggSettingRxUpdate() + * + * Overview: Seperate TX/RX parameters update independent for TP detection and + * dynamic TX/RX aggreagtion parameters update. + * + * Input: struct adapter * + * + * Output/Return: NONE + * + * Revised History: + * When Who Remark + * 12/10/2010 MHC Seperate to smaller function. + * + *---------------------------------------------------------------------------*/ +static void +usb_AggSettingRxUpdate( + struct adapter *Adapter + ) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + u8 valueDMA; + u8 valueUSB; + + valueDMA = rtw_read8(Adapter, REG_TRXDMA_CTRL); + valueUSB = rtw_read8(Adapter, REG_USB_SPECIAL_OPTION); + + switch (haldata->UsbRxAggMode) { + case USB_RX_AGG_DMA: + valueDMA |= RXDMA_AGG_EN; + valueUSB &= ~USB_AGG_EN; + break; + case USB_RX_AGG_USB: + valueDMA &= ~RXDMA_AGG_EN; + valueUSB |= USB_AGG_EN; + break; + case USB_RX_AGG_MIX: + valueDMA |= RXDMA_AGG_EN; + valueUSB |= USB_AGG_EN; + break; + case USB_RX_AGG_DISABLE: + default: + valueDMA &= ~RXDMA_AGG_EN; + valueUSB &= ~USB_AGG_EN; + break; + } + + rtw_write8(Adapter, REG_TRXDMA_CTRL, valueDMA); + rtw_write8(Adapter, REG_USB_SPECIAL_OPTION, valueUSB); + + switch (haldata->UsbRxAggMode) { + case USB_RX_AGG_DMA: + rtw_write8(Adapter, REG_RXDMA_AGG_PG_TH, haldata->UsbRxAggPageCount); + rtw_write8(Adapter, REG_RXDMA_AGG_PG_TH+1, haldata->UsbRxAggPageTimeout); + break; + case USB_RX_AGG_USB: + rtw_write8(Adapter, REG_USB_AGG_TH, haldata->UsbRxAggBlockCount); + rtw_write8(Adapter, REG_USB_AGG_TO, haldata->UsbRxAggBlockTimeout); + break; + case USB_RX_AGG_MIX: + rtw_write8(Adapter, REG_RXDMA_AGG_PG_TH, haldata->UsbRxAggPageCount); + rtw_write8(Adapter, REG_RXDMA_AGG_PG_TH+1, (haldata->UsbRxAggPageTimeout & 0x1F));/* 0x280[12:8] */ + rtw_write8(Adapter, REG_USB_AGG_TH, haldata->UsbRxAggBlockCount); + rtw_write8(Adapter, REG_USB_AGG_TO, haldata->UsbRxAggBlockTimeout); + break; + case USB_RX_AGG_DISABLE: + default: + /* TODO: */ + break; + } + + switch (PBP_128) { + case PBP_128: + haldata->HwRxPageSize = 128; + break; + case PBP_64: + haldata->HwRxPageSize = 64; + break; + case PBP_256: + haldata->HwRxPageSize = 256; + break; + case PBP_512: + haldata->HwRxPageSize = 512; + break; + case PBP_1024: + haldata->HwRxPageSize = 1024; + break; + default: + break; + } +} /* usb_AggSettingRxUpdate */ + +static void InitUsbAggregationSetting(struct adapter *Adapter) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + + /* Tx aggregation setting */ + usb_AggSettingTxUpdate(Adapter); + + /* Rx aggregation setting */ + usb_AggSettingRxUpdate(Adapter); + + /* 201/12/10 MH Add for USB agg mode dynamic switch. */ + haldata->UsbRxHighSpeedMode = false; +} + +static void _InitOperationMode(struct adapter *Adapter) +{ +} + +static void _InitBeaconParameters(struct adapter *Adapter) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + + rtw_write16(Adapter, REG_BCN_CTRL, 0x1010); + + /* TODO: Remove these magic number */ + rtw_write16(Adapter, REG_TBTT_PROHIBIT, 0x6404);/* ms */ + rtw_write8(Adapter, REG_DRVERLYINT, DRIVER_EARLY_INT_TIME);/* 5ms */ + rtw_write8(Adapter, REG_BCNDMATIM, BCN_DMA_ATIME_INT_TIME); /* 2ms */ + + /* Suggested by designer timchen. Change beacon AIFS to the largest number */ + /* beacause test chip does not contension before sending beacon. by tynli. 2009.11.03 */ + rtw_write16(Adapter, REG_BCNTCFG, 0x660F); + + haldata->RegBcnCtrlVal = rtw_read8(Adapter, REG_BCN_CTRL); + haldata->RegTxPause = rtw_read8(Adapter, REG_TXPAUSE); + haldata->RegFwHwTxQCtrl = rtw_read8(Adapter, REG_FWHW_TXQ_CTRL+2); + haldata->RegReg542 = rtw_read8(Adapter, REG_TBTT_PROHIBIT+2); + haldata->RegCR_1 = rtw_read8(Adapter, REG_CR+1); +} + +static void _BeaconFunctionEnable(struct adapter *Adapter, + bool Enable, bool Linked) +{ + rtw_write8(Adapter, REG_BCN_CTRL, (BIT4 | BIT3 | BIT1)); + + rtw_write8(Adapter, REG_RD_CTRL+1, 0x6F); +} + +/* Set CCK and OFDM Block "ON" */ +static void _BBTurnOnBlock(struct adapter *Adapter) +{ + PHY_SetBBReg(Adapter, rFPGA0_RFMOD, bCCKEn, 0x1); + PHY_SetBBReg(Adapter, rFPGA0_RFMOD, bOFDMEn, 0x1); +} + +enum { + Antenna_Lfet = 1, + Antenna_Right = 2, +}; + +static void _InitAntenna_Selection(struct adapter *Adapter) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + + if (haldata->AntDivCfg == 0) + return; + DBG_88E("==> %s ....\n", __func__); + + rtw_write32(Adapter, REG_LEDCFG0, rtw_read32(Adapter, REG_LEDCFG0)|BIT23); + PHY_SetBBReg(Adapter, rFPGA0_XAB_RFParameter, BIT13, 0x01); + + if (PHY_QueryBBReg(Adapter, rFPGA0_XA_RFInterfaceOE, 0x300) == Antenna_A) + haldata->CurAntenna = Antenna_A; + else + haldata->CurAntenna = Antenna_B; + DBG_88E("%s,Cur_ant:(%x)%s\n", __func__, haldata->CurAntenna, (haldata->CurAntenna == Antenna_A) ? "Antenna_A" : "Antenna_B"); +} + +/*----------------------------------------------------------------------------- + * Function: HwSuspendModeEnable92Cu() + * + * Overview: HW suspend mode switch. + * + * Input: NONE + * + * Output: NONE + * + * Return: NONE + * + * Revised History: + * When Who Remark + * 08/23/2010 MHC HW suspend mode switch test.. + *---------------------------------------------------------------------------*/ +enum rt_rf_power_state RfOnOffDetect(struct adapter *adapt) +{ + u8 val8; + enum rt_rf_power_state rfpowerstate = rf_off; + + if (adapt->pwrctrlpriv.bHWPowerdown) { + val8 = rtw_read8(adapt, REG_HSISR); + DBG_88E("pwrdown, 0x5c(BIT7)=%02x\n", val8); + rfpowerstate = (val8 & BIT7) ? rf_off : rf_on; + } else { /* rf on/off */ + rtw_write8(adapt, REG_MAC_PINMUX_CFG, rtw_read8(adapt, REG_MAC_PINMUX_CFG)&~(BIT3)); + val8 = rtw_read8(adapt, REG_GPIO_IO_SEL); + DBG_88E("GPIO_IN=%02x\n", val8); + rfpowerstate = (val8 & BIT3) ? rf_on : rf_off; + } + return rfpowerstate; +} /* HalDetectPwrDownMode */ + +static u32 rtl8188eu_hal_init(struct adapter *Adapter) +{ + u8 value8 = 0; + u16 value16; + u8 txpktbuf_bndy; + u32 status = _SUCCESS; + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + struct pwrctrl_priv *pwrctrlpriv = &Adapter->pwrctrlpriv; + struct registry_priv *pregistrypriv = &Adapter->registrypriv; + u32 init_start_time = rtw_get_current_time(); + + #define HAL_INIT_PROFILE_TAG(stage) do {} while (0) + +_func_enter_; + + HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_BEGIN); + + if (Adapter->pwrctrlpriv.bkeepfwalive) { + _ps_open_RF(Adapter); + + if (haldata->odmpriv.RFCalibrateInfo.bIQKInitialized) { + PHY_IQCalibrate_8188E(Adapter, true); + } else { + PHY_IQCalibrate_8188E(Adapter, false); + haldata->odmpriv.RFCalibrateInfo.bIQKInitialized = true; + } + + ODM_TXPowerTrackingCheck(&haldata->odmpriv); + PHY_LCCalibrate_8188E(Adapter); + + goto exit; + } + + HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_INIT_PW_ON); + status = rtl8188eu_InitPowerOn(Adapter); + if (status == _FAIL) { + RT_TRACE(_module_hci_hal_init_c_, _drv_err_, ("Failed to init power on!\n")); + goto exit; + } + + /* Save target channel */ + haldata->CurrentChannel = 6;/* default set to 6 */ + + if (pwrctrlpriv->reg_rfoff) { + pwrctrlpriv->rf_pwrstate = rf_off; + } + + /* 2010/08/09 MH We need to check if we need to turnon or off RF after detecting */ + /* HW GPIO pin. Before PHY_RFConfig8192C. */ + /* 2010/08/26 MH If Efuse does not support sective suspend then disable the function. */ + + if (!pregistrypriv->wifi_spec) { + txpktbuf_bndy = TX_PAGE_BOUNDARY_88E; + } else { + /* for WMM */ + txpktbuf_bndy = WMM_NORMAL_TX_PAGE_BOUNDARY_88E; + } + + HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_MISC01); + _InitQueueReservedPage(Adapter); + _InitQueuePriority(Adapter); + _InitPageBoundary(Adapter); + _InitTransferPageSize(Adapter); + + _InitTxBufferBoundary(Adapter, 0); + + HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_DOWNLOAD_FW); + if (Adapter->registrypriv.mp_mode == 1) { + _InitRxSetting(Adapter); + Adapter->bFWReady = false; + haldata->fw_ractrl = false; + } else { + status = rtl8188e_FirmwareDownload(Adapter); + + if (status != _SUCCESS) { + DBG_88E("%s: Download Firmware failed!!\n", __func__); + Adapter->bFWReady = false; + haldata->fw_ractrl = false; + return status; + } else { + RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("Initializeadapt8192CSdio(): Download Firmware Success!!\n")); + Adapter->bFWReady = true; + haldata->fw_ractrl = false; + } + } + rtl8188e_InitializeFirmwareVars(Adapter); + + HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_MAC); +#if (HAL_MAC_ENABLE == 1) + status = PHY_MACConfig8188E(Adapter); + if (status == _FAIL) { + DBG_88E(" ### Failed to init MAC ......\n "); + goto exit; + } +#endif + + /* */ + /* d. Initialize BB related configurations. */ + /* */ + HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_BB); +#if (HAL_BB_ENABLE == 1) + status = PHY_BBConfig8188E(Adapter); + if (status == _FAIL) { + DBG_88E(" ### Failed to init BB ......\n "); + goto exit; + } +#endif + + HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_RF); +#if (HAL_RF_ENABLE == 1) + status = PHY_RFConfig8188E(Adapter); + if (status == _FAIL) { + DBG_88E(" ### Failed to init RF ......\n "); + goto exit; + } +#endif + + HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_EFUSE_PATCH); + status = rtl8188e_iol_efuse_patch(Adapter); + if (status == _FAIL) { + DBG_88E("%s rtl8188e_iol_efuse_patch failed\n", __func__); + goto exit; + } + + _InitTxBufferBoundary(Adapter, txpktbuf_bndy); + + HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_INIT_LLTT); + status = InitLLTTable(Adapter, txpktbuf_bndy); + if (status == _FAIL) { + RT_TRACE(_module_hci_hal_init_c_, _drv_err_, ("Failed to init LLT table\n")); + goto exit; + } + + HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_MISC02); + /* Get Rx PHY status in order to report RSSI and others. */ + _InitDriverInfoSize(Adapter, DRVINFO_SZ); + + _InitInterrupt(Adapter); + hal_init_macaddr(Adapter);/* set mac_address */ + _InitNetworkType(Adapter);/* set msr */ + _InitWMACSetting(Adapter); + _InitAdaptiveCtrl(Adapter); + _InitEDCA(Adapter); + _InitRetryFunction(Adapter); + InitUsbAggregationSetting(Adapter); + _InitOperationMode(Adapter);/* todo */ + _InitBeaconParameters(Adapter); + _InitBeaconMaxError(Adapter, true); + + /* */ + /* Init CR MACTXEN, MACRXEN after setting RxFF boundary REG_TRXFF_BNDY to patch */ + /* Hw bug which Hw initials RxFF boundry size to a value which is larger than the real Rx buffer size in 88E. */ + /* */ + /* Enable MACTXEN/MACRXEN block */ + value16 = rtw_read16(Adapter, REG_CR); + value16 |= (MACTXEN | MACRXEN); + rtw_write8(Adapter, REG_CR, value16); + + if (haldata->bRDGEnable) + _InitRDGSetting(Adapter); + + /* Enable TX Report */ + /* Enable Tx Report Timer */ + value8 = rtw_read8(Adapter, REG_TX_RPT_CTRL); + rtw_write8(Adapter, REG_TX_RPT_CTRL, (value8|BIT1|BIT0)); + /* Set MAX RPT MACID */ + rtw_write8(Adapter, REG_TX_RPT_CTRL+1, 2);/* FOR sta mode ,0: bc/mc ,1:AP */ + /* Tx RPT Timer. Unit: 32us */ + rtw_write16(Adapter, REG_TX_RPT_TIME, 0xCdf0); + + rtw_write8(Adapter, REG_EARLY_MODE_CONTROL, 0); + + rtw_write16(Adapter, REG_PKT_VO_VI_LIFE_TIME, 0x0400); /* unit: 256us. 256ms */ + rtw_write16(Adapter, REG_PKT_BE_BK_LIFE_TIME, 0x0400); /* unit: 256us. 256ms */ + + _InitHWLed(Adapter); + + /* Keep RfRegChnlVal for later use. */ + haldata->RfRegChnlVal[0] = PHY_QueryRFReg(Adapter, (enum rf_radio_path)0, RF_CHNLBW, bRFRegOffsetMask); + haldata->RfRegChnlVal[1] = PHY_QueryRFReg(Adapter, (enum rf_radio_path)1, RF_CHNLBW, bRFRegOffsetMask); + +HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_TURN_ON_BLOCK); + _BBTurnOnBlock(Adapter); + +HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_INIT_SECURITY); + invalidate_cam_all(Adapter); + +HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_MISC11); + /* 2010/12/17 MH We need to set TX power according to EFUSE content at first. */ + PHY_SetTxPowerLevel8188E(Adapter, haldata->CurrentChannel); + +/* Move by Neo for USB SS to below setp */ +/* _RfPowerSave(Adapter); */ + + _InitAntenna_Selection(Adapter); + + /* */ + /* Disable BAR, suggested by Scott */ + /* 2010.04.09 add by hpfan */ + /* */ + rtw_write32(Adapter, REG_BAR_MODE_CTRL, 0x0201ffff); + + /* HW SEQ CTRL */ + /* set 0x0 to 0xFF by tynli. Default enable HW SEQ NUM. */ + rtw_write8(Adapter, REG_HWSEQ_CTRL, 0xFF); + + if (pregistrypriv->wifi_spec) + rtw_write16(Adapter, REG_FAST_EDCA_CTRL, 0); + + /* Nav limit , suggest by scott */ + rtw_write8(Adapter, 0x652, 0x0); + +HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_INIT_HAL_DM); + rtl8188e_InitHalDm(Adapter); + + if (Adapter->registrypriv.mp_mode == 1) { + Adapter->mppriv.channel = haldata->CurrentChannel; + MPT_InitializeAdapter(Adapter, Adapter->mppriv.channel); + } else { + /* 2010/08/11 MH Merge from 8192SE for Minicard init. We need to confirm current radio status */ + /* and then decide to enable RF or not.!!!??? For Selective suspend mode. We may not */ + /* call initstruct adapter. May cause some problem?? */ + /* Fix the bug that Hw/Sw radio off before S3/S4, the RF off action will not be executed */ + /* in MgntActSet_RF_State() after wake up, because the value of haldata->eRFPowerState */ + /* is the same as eRfOff, we should change it to eRfOn after we config RF parameters. */ + /* Added by tynli. 2010.03.30. */ + pwrctrlpriv->rf_pwrstate = rf_on; + + /* enable Tx report. */ + rtw_write8(Adapter, REG_FWHW_TXQ_CTRL+1, 0x0F); + + /* Suggested by SD1 pisa. Added by tynli. 2011.10.21. */ + rtw_write8(Adapter, REG_EARLY_MODE_CONTROL+3, 0x01);/* Pretx_en, for WEP/TKIP SEC */ + + /* tynli_test_tx_report. */ + rtw_write16(Adapter, REG_TX_RPT_TIME, 0x3DF0); + + /* enable tx DMA to drop the redundate data of packet */ + rtw_write16(Adapter, REG_TXDMA_OFFSET_CHK, (rtw_read16(Adapter, REG_TXDMA_OFFSET_CHK) | DROP_DATA_EN)); + +HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_IQK); + /* 2010/08/26 MH Merge from 8192CE. */ + if (pwrctrlpriv->rf_pwrstate == rf_on) { + if (haldata->odmpriv.RFCalibrateInfo.bIQKInitialized) { + PHY_IQCalibrate_8188E(Adapter, true); + } else { + PHY_IQCalibrate_8188E(Adapter, false); + haldata->odmpriv.RFCalibrateInfo.bIQKInitialized = true; + } + +HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_PW_TRACK); + + ODM_TXPowerTrackingCheck(&haldata->odmpriv); + +HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_LCK); + PHY_LCCalibrate_8188E(Adapter); + } + } + +/* HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_INIT_PABIAS); */ +/* _InitPABias(Adapter); */ + rtw_write8(Adapter, REG_USB_HRPWM, 0); + + /* ack for xmit mgmt frames. */ + rtw_write32(Adapter, REG_FWHW_TXQ_CTRL, rtw_read32(Adapter, REG_FWHW_TXQ_CTRL)|BIT(12)); + +exit: +HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_END); + + DBG_88E("%s in %dms\n", __func__, rtw_get_passing_time_ms(init_start_time)); + +_func_exit_; + + return status; +} + +void _ps_open_RF(struct adapter *adapt) +{ + /* here call with bRegSSPwrLvl 1, bRegSSPwrLvl 2 needs to be verified */ + /* phy_SsPwrSwitch92CU(adapt, rf_on, 1); */ +} + +static void _ps_close_RF(struct adapter *adapt) +{ + /* here call with bRegSSPwrLvl 1, bRegSSPwrLvl 2 needs to be verified */ + /* phy_SsPwrSwitch92CU(adapt, rf_off, 1); */ +} + +static void CardDisableRTL8188EU(struct adapter *Adapter) +{ + u8 val8; + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + + RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("CardDisableRTL8188EU\n")); + + /* Stop Tx Report Timer. 0x4EC[Bit1]=b'0 */ + val8 = rtw_read8(Adapter, REG_TX_RPT_CTRL); + rtw_write8(Adapter, REG_TX_RPT_CTRL, val8&(~BIT1)); + + /* stop rx */ + rtw_write8(Adapter, REG_CR, 0x0); + + /* Run LPS WL RFOFF flow */ + HalPwrSeqCmdParsing(Adapter, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK, Rtl8188E_NIC_LPS_ENTER_FLOW); + + /* 2. 0x1F[7:0] = 0 turn off RF */ + + val8 = rtw_read8(Adapter, REG_MCUFWDL); + if ((val8 & RAM_DL_SEL) && Adapter->bFWReady) { /* 8051 RAM code */ + /* Reset MCU 0x2[10]=0. */ + val8 = rtw_read8(Adapter, REG_SYS_FUNC_EN+1); + val8 &= ~BIT(2); /* 0x2[10], FEN_CPUEN */ + rtw_write8(Adapter, REG_SYS_FUNC_EN+1, val8); + } + + /* reset MCU ready status */ + rtw_write8(Adapter, REG_MCUFWDL, 0); + + /* YJ,add,111212 */ + /* Disable 32k */ + val8 = rtw_read8(Adapter, REG_32K_CTRL); + rtw_write8(Adapter, REG_32K_CTRL, val8&(~BIT0)); + + /* Card disable power action flow */ + HalPwrSeqCmdParsing(Adapter, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK, Rtl8188E_NIC_DISABLE_FLOW); + + /* Reset MCU IO Wrapper */ + val8 = rtw_read8(Adapter, REG_RSV_CTRL+1); + rtw_write8(Adapter, REG_RSV_CTRL+1, (val8&(~BIT3))); + val8 = rtw_read8(Adapter, REG_RSV_CTRL+1); + rtw_write8(Adapter, REG_RSV_CTRL+1, val8|BIT3); + + /* YJ,test add, 111207. For Power Consumption. */ + val8 = rtw_read8(Adapter, GPIO_IN); + rtw_write8(Adapter, GPIO_OUT, val8); + rtw_write8(Adapter, GPIO_IO_SEL, 0xFF);/* Reg0x46 */ + + val8 = rtw_read8(Adapter, REG_GPIO_IO_SEL); + rtw_write8(Adapter, REG_GPIO_IO_SEL, (val8<<4)); + val8 = rtw_read8(Adapter, REG_GPIO_IO_SEL+1); + rtw_write8(Adapter, REG_GPIO_IO_SEL+1, val8|0x0F);/* Reg0x43 */ + rtw_write32(Adapter, REG_BB_PAD_CTRL, 0x00080808);/* set LNA ,TRSW,EX_PA Pin to output mode */ + haldata->bMacPwrCtrlOn = false; + Adapter->bFWReady = false; +} +static void rtl8192cu_hw_power_down(struct adapter *adapt) +{ + /* 2010/-8/09 MH For power down module, we need to enable register block contrl reg at 0x1c. */ + /* Then enable power down control bit of register 0x04 BIT4 and BIT15 as 1. */ + + /* Enable register area 0x0-0xc. */ + rtw_write8(adapt, REG_RSV_CTRL, 0x0); + rtw_write16(adapt, REG_APS_FSMCO, 0x8812); +} + +static u32 rtl8188eu_hal_deinit(struct adapter *Adapter) +{ + + DBG_88E("==> %s\n", __func__); + + rtw_write32(Adapter, REG_HIMR_88E, IMR_DISABLED_88E); + rtw_write32(Adapter, REG_HIMRE_88E, IMR_DISABLED_88E); + + DBG_88E("bkeepfwalive(%x)\n", Adapter->pwrctrlpriv.bkeepfwalive); + if (Adapter->pwrctrlpriv.bkeepfwalive) { + _ps_close_RF(Adapter); + if ((Adapter->pwrctrlpriv.bHWPwrPindetect) && (Adapter->pwrctrlpriv.bHWPowerdown)) + rtl8192cu_hw_power_down(Adapter); + } else { + if (Adapter->hw_init_completed) { + CardDisableRTL8188EU(Adapter); + + if ((Adapter->pwrctrlpriv.bHWPwrPindetect) && (Adapter->pwrctrlpriv.bHWPowerdown)) + rtl8192cu_hw_power_down(Adapter); + } + } + return _SUCCESS; + } + +static unsigned int rtl8188eu_inirp_init(struct adapter *Adapter) +{ + u8 i; + struct recv_buf *precvbuf; + uint status; + struct intf_hdl *pintfhdl = &Adapter->iopriv.intf; + struct recv_priv *precvpriv = &(Adapter->recvpriv); + u32 (*_read_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); + +_func_enter_; + + _read_port = pintfhdl->io_ops._read_port; + + status = _SUCCESS; + + RT_TRACE(_module_hci_hal_init_c_, _drv_info_, + ("===> usb_inirp_init\n")); + + precvpriv->ff_hwaddr = RECV_BULK_IN_ADDR; + + /* issue Rx irp to receive data */ + precvbuf = (struct recv_buf *)precvpriv->precv_buf; + for (i = 0; i < NR_RECVBUFF; i++) { + if (_read_port(pintfhdl, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf) == false) { + RT_TRACE(_module_hci_hal_init_c_, _drv_err_, ("usb_rx_init: usb_read_port error\n")); + status = _FAIL; + goto exit; + } + + precvbuf++; + precvpriv->free_recv_buf_queue_cnt--; + } + +exit: + + RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("<=== usb_inirp_init\n")); + +_func_exit_; + + return status; +} + +static unsigned int rtl8188eu_inirp_deinit(struct adapter *Adapter) +{ + RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("\n ===> usb_rx_deinit\n")); + + rtw_read_port_cancel(Adapter); + + RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("\n <=== usb_rx_deinit\n")); + + return _SUCCESS; +} + +/* */ +/* */ +/* EEPROM/EFUSE Content Parsing */ +/* */ +/* */ +static void _ReadLEDSetting(struct adapter *Adapter, u8 *PROMContent, bool AutoloadFail) +{ + struct led_priv *pledpriv = &(Adapter->ledpriv); + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + + pledpriv->bRegUseLed = true; + pledpriv->LedStrategy = SW_LED_MODE1; + haldata->bLedOpenDrain = true;/* Support Open-drain arrangement for controlling the LED. */ +} + +static void Hal_EfuseParsePIDVID_8188EU(struct adapter *adapt, u8 *hwinfo, bool AutoLoadFail) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + + if (!AutoLoadFail) { + /* VID, PID */ + haldata->EEPROMVID = EF2BYTE(*(__le16 *)&hwinfo[EEPROM_VID_88EU]); + haldata->EEPROMPID = EF2BYTE(*(__le16 *)&hwinfo[EEPROM_PID_88EU]); + + /* Customer ID, 0x00 and 0xff are reserved for Realtek. */ + haldata->EEPROMCustomerID = *(u8 *)&hwinfo[EEPROM_CUSTOMERID_88E]; + haldata->EEPROMSubCustomerID = EEPROM_Default_SubCustomerID; + } else { + haldata->EEPROMVID = EEPROM_Default_VID; + haldata->EEPROMPID = EEPROM_Default_PID; + + /* Customer ID, 0x00 and 0xff are reserved for Realtek. */ + haldata->EEPROMCustomerID = EEPROM_Default_CustomerID; + haldata->EEPROMSubCustomerID = EEPROM_Default_SubCustomerID; + } + + DBG_88E("VID = 0x%04X, PID = 0x%04X\n", haldata->EEPROMVID, haldata->EEPROMPID); + DBG_88E("Customer ID: 0x%02X, SubCustomer ID: 0x%02X\n", haldata->EEPROMCustomerID, haldata->EEPROMSubCustomerID); +} + +static void Hal_EfuseParseMACAddr_8188EU(struct adapter *adapt, u8 *hwinfo, bool AutoLoadFail) +{ + u16 i; + u8 sMacAddr[6] = {0x00, 0xE0, 0x4C, 0x81, 0x88, 0x02}; + struct eeprom_priv *eeprom = GET_EEPROM_EFUSE_PRIV(adapt); + + if (AutoLoadFail) { + for (i = 0; i < 6; i++) + eeprom->mac_addr[i] = sMacAddr[i]; + } else { + /* Read Permanent MAC address */ + memcpy(eeprom->mac_addr, &hwinfo[EEPROM_MAC_ADDR_88EU], ETH_ALEN); + } + RT_TRACE(_module_hci_hal_init_c_, _drv_notice_, + ("Hal_EfuseParseMACAddr_8188EU: Permanent Address = %02x-%02x-%02x-%02x-%02x-%02x\n", + eeprom->mac_addr[0], eeprom->mac_addr[1], + eeprom->mac_addr[2], eeprom->mac_addr[3], + eeprom->mac_addr[4], eeprom->mac_addr[5])); +} + +static void Hal_CustomizeByCustomerID_8188EU(struct adapter *adapt) +{ +} + +static void +readAdapterInfo_8188EU( + struct adapter *adapt + ) +{ + struct eeprom_priv *eeprom = GET_EEPROM_EFUSE_PRIV(adapt); + + /* parse the eeprom/efuse content */ + Hal_EfuseParseIDCode88E(adapt, eeprom->efuse_eeprom_data); + Hal_EfuseParsePIDVID_8188EU(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); + Hal_EfuseParseMACAddr_8188EU(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); + + Hal_ReadPowerSavingMode88E(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); + Hal_ReadTxPowerInfo88E(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); + Hal_EfuseParseEEPROMVer88E(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); + rtl8188e_EfuseParseChnlPlan(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); + Hal_EfuseParseXtal_8188E(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); + Hal_EfuseParseCustomerID88E(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); + Hal_ReadAntennaDiversity88E(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); + Hal_EfuseParseBoardType88E(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); + Hal_ReadThermalMeter_88E(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); + + /* */ + /* The following part initialize some vars by PG info. */ + /* */ + Hal_InitChannelPlan(adapt); + Hal_CustomizeByCustomerID_8188EU(adapt); + + _ReadLEDSetting(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); +} + +static void _ReadPROMContent( + struct adapter *Adapter + ) +{ + struct eeprom_priv *eeprom = GET_EEPROM_EFUSE_PRIV(Adapter); + u8 eeValue; + + /* check system boot selection */ + eeValue = rtw_read8(Adapter, REG_9346CR); + eeprom->EepromOrEfuse = (eeValue & BOOT_FROM_EEPROM) ? true : false; + eeprom->bautoload_fail_flag = (eeValue & EEPROM_EN) ? false : true; + + DBG_88E("Boot from %s, Autoload %s !\n", (eeprom->EepromOrEfuse ? "EEPROM" : "EFUSE"), + (eeprom->bautoload_fail_flag ? "Fail" : "OK")); + + Hal_InitPGData88E(Adapter); + readAdapterInfo_8188EU(Adapter); +} + +static void _ReadRFType(struct adapter *Adapter) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + + haldata->rf_chip = RF_6052; +} + +static int _ReadAdapterInfo8188EU(struct adapter *Adapter) +{ + u32 start = rtw_get_current_time(); + + MSG_88E("====> %s\n", __func__); + + _ReadRFType(Adapter);/* rf_chip -> _InitRFType() */ + _ReadPROMContent(Adapter); + + MSG_88E("<==== %s in %d ms\n", __func__, rtw_get_passing_time_ms(start)); + + return _SUCCESS; +} + +static void ReadAdapterInfo8188EU(struct adapter *Adapter) +{ + /* Read EEPROM size before call any EEPROM function */ + Adapter->EepromAddressSize = GetEEPROMSize8188E(Adapter); + + _ReadAdapterInfo8188EU(Adapter); +} + +#define GPIO_DEBUG_PORT_NUM 0 +static void rtl8192cu_trigger_gpio_0(struct adapter *adapt) +{ +} + +static void ResumeTxBeacon(struct adapter *adapt) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + + /* 2010.03.01. Marked by tynli. No need to call workitem beacause we record the value */ + /* which should be read from register to a global variable. */ + + rtw_write8(adapt, REG_FWHW_TXQ_CTRL+2, (haldata->RegFwHwTxQCtrl) | BIT6); + haldata->RegFwHwTxQCtrl |= BIT6; + rtw_write8(adapt, REG_TBTT_PROHIBIT+1, 0xff); + haldata->RegReg542 |= BIT0; + rtw_write8(adapt, REG_TBTT_PROHIBIT+2, haldata->RegReg542); +} + +static void StopTxBeacon(struct adapter *adapt) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + + /* 2010.03.01. Marked by tynli. No need to call workitem beacause we record the value */ + /* which should be read from register to a global variable. */ + + rtw_write8(adapt, REG_FWHW_TXQ_CTRL+2, (haldata->RegFwHwTxQCtrl) & (~BIT6)); + haldata->RegFwHwTxQCtrl &= (~BIT6); + rtw_write8(adapt, REG_TBTT_PROHIBIT+1, 0x64); + haldata->RegReg542 &= ~(BIT0); + rtw_write8(adapt, REG_TBTT_PROHIBIT+2, haldata->RegReg542); + + /* todo: CheckFwRsvdPageContent(Adapter); 2010.06.23. Added by tynli. */ +} + +static void hw_var_set_opmode(struct adapter *Adapter, u8 variable, u8 *val) +{ + u8 val8; + u8 mode = *((u8 *)val); + + /* disable Port0 TSF update */ + rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)|BIT(4)); + + /* set net_type */ + val8 = rtw_read8(Adapter, MSR)&0x0c; + val8 |= mode; + rtw_write8(Adapter, MSR, val8); + + DBG_88E("%s()-%d mode = %d\n", __func__, __LINE__, mode); + + if ((mode == _HW_STATE_STATION_) || (mode == _HW_STATE_NOLINK_)) { + StopTxBeacon(Adapter); + + rtw_write8(Adapter, REG_BCN_CTRL, 0x19);/* disable atim wnd */ + } else if ((mode == _HW_STATE_ADHOC_)) { + ResumeTxBeacon(Adapter); + rtw_write8(Adapter, REG_BCN_CTRL, 0x1a); + } else if (mode == _HW_STATE_AP_) { + ResumeTxBeacon(Adapter); + + rtw_write8(Adapter, REG_BCN_CTRL, 0x12); + + /* Set RCR */ + rtw_write32(Adapter, REG_RCR, 0x7000208e);/* CBSSID_DATA must set to 0,reject ICV_ERR packet */ + /* enable to rx data frame */ + rtw_write16(Adapter, REG_RXFLTMAP2, 0xFFFF); + /* enable to rx ps-poll */ + rtw_write16(Adapter, REG_RXFLTMAP1, 0x0400); + + /* Beacon Control related register for first time */ + rtw_write8(Adapter, REG_BCNDMATIM, 0x02); /* 2ms */ + + rtw_write8(Adapter, REG_ATIMWND, 0x0a); /* 10ms */ + rtw_write16(Adapter, REG_BCNTCFG, 0x00); + rtw_write16(Adapter, REG_TBTT_PROHIBIT, 0xff04); + rtw_write16(Adapter, REG_TSFTR_SYN_OFFSET, 0x7fff);/* +32767 (~32ms) */ + + /* reset TSF */ + rtw_write8(Adapter, REG_DUAL_TSF_RST, BIT(0)); + + /* BIT3 - If set 0, hw will clr bcnq when tx becon ok/fail or port 0 */ + rtw_write8(Adapter, REG_MBID_NUM, rtw_read8(Adapter, REG_MBID_NUM) | BIT(3) | BIT(4)); + + /* enable BCN0 Function for if1 */ + /* don't enable update TSF0 for if1 (due to TSF update when beacon/probe rsp are received) */ + rtw_write8(Adapter, REG_BCN_CTRL, (DIS_TSF_UDT0_NORMAL_CHIP|EN_BCN_FUNCTION | BIT(1))); + + /* dis BCN1 ATIM WND if if2 is station */ + rtw_write8(Adapter, REG_BCN_CTRL_1, rtw_read8(Adapter, REG_BCN_CTRL_1) | BIT(0)); + } +} + +static void hw_var_set_macaddr(struct adapter *Adapter, u8 variable, u8 *val) +{ + u8 idx = 0; + u32 reg_macid; + + reg_macid = REG_MACID; + + for (idx = 0; idx < 6; idx++) + rtw_write8(Adapter, (reg_macid+idx), val[idx]); +} + +static void hw_var_set_bssid(struct adapter *Adapter, u8 variable, u8 *val) +{ + u8 idx = 0; + u32 reg_bssid; + + reg_bssid = REG_BSSID; + + for (idx = 0; idx < 6; idx++) + rtw_write8(Adapter, (reg_bssid+idx), val[idx]); +} + +static void hw_var_set_bcn_func(struct adapter *Adapter, u8 variable, u8 *val) +{ + u32 bcn_ctrl_reg; + + bcn_ctrl_reg = REG_BCN_CTRL; + + if (*((u8 *)val)) + rtw_write8(Adapter, bcn_ctrl_reg, (EN_BCN_FUNCTION | EN_TXBCN_RPT)); + else + rtw_write8(Adapter, bcn_ctrl_reg, rtw_read8(Adapter, bcn_ctrl_reg)&(~(EN_BCN_FUNCTION | EN_TXBCN_RPT))); +} + +static void SetHwReg8188EU(struct adapter *Adapter, u8 variable, u8 *val) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + struct dm_priv *pdmpriv = &haldata->dmpriv; + struct odm_dm_struct *podmpriv = &haldata->odmpriv; +_func_enter_; + + switch (variable) { + case HW_VAR_MEDIA_STATUS: + { + u8 val8; + + val8 = rtw_read8(Adapter, MSR)&0x0c; + val8 |= *((u8 *)val); + rtw_write8(Adapter, MSR, val8); + } + break; + case HW_VAR_MEDIA_STATUS1: + { + u8 val8; + + val8 = rtw_read8(Adapter, MSR) & 0x03; + val8 |= *((u8 *)val) << 2; + rtw_write8(Adapter, MSR, val8); + } + break; + case HW_VAR_SET_OPMODE: + hw_var_set_opmode(Adapter, variable, val); + break; + case HW_VAR_MAC_ADDR: + hw_var_set_macaddr(Adapter, variable, val); + break; + case HW_VAR_BSSID: + hw_var_set_bssid(Adapter, variable, val); + break; + case HW_VAR_BASIC_RATE: + { + u16 BrateCfg = 0; + u8 RateIndex = 0; + + /* 2007.01.16, by Emily */ + /* Select RRSR (in Legacy-OFDM and CCK) */ + /* For 8190, we select only 24M, 12M, 6M, 11M, 5.5M, 2M, and 1M from the Basic rate. */ + /* We do not use other rates. */ + HalSetBrateCfg(Adapter, val, &BrateCfg); + DBG_88E("HW_VAR_BASIC_RATE: BrateCfg(%#x)\n", BrateCfg); + + /* 2011.03.30 add by Luke Lee */ + /* CCK 2M ACK should be disabled for some BCM and Atheros AP IOT */ + /* because CCK 2M has poor TXEVM */ + /* CCK 5.5M & 11M ACK should be enabled for better performance */ + + BrateCfg = (BrateCfg | 0xd) & 0x15d; + haldata->BasicRateSet = BrateCfg; + + BrateCfg |= 0x01; /* default enable 1M ACK rate */ + /* Set RRSR rate table. */ + rtw_write8(Adapter, REG_RRSR, BrateCfg & 0xff); + rtw_write8(Adapter, REG_RRSR+1, (BrateCfg >> 8) & 0xff); + rtw_write8(Adapter, REG_RRSR+2, rtw_read8(Adapter, REG_RRSR+2)&0xf0); + + /* Set RTS initial rate */ + while (BrateCfg > 0x1) { + BrateCfg = (BrateCfg >> 1); + RateIndex++; + } + /* Ziv - Check */ + rtw_write8(Adapter, REG_INIRTS_RATE_SEL, RateIndex); + } + break; + case HW_VAR_TXPAUSE: + rtw_write8(Adapter, REG_TXPAUSE, *((u8 *)val)); + break; + case HW_VAR_BCN_FUNC: + hw_var_set_bcn_func(Adapter, variable, val); + break; + case HW_VAR_CORRECT_TSF: + { + u64 tsf; + struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + tsf = pmlmeext->TSFValue - rtw_modular64(pmlmeext->TSFValue, (pmlmeinfo->bcn_interval*1024)) - 1024; /* us */ + + if (((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE)) + StopTxBeacon(Adapter); + + /* disable related TSF function */ + rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)&(~BIT(3))); + + rtw_write32(Adapter, REG_TSFTR, tsf); + rtw_write32(Adapter, REG_TSFTR+4, tsf>>32); + + /* enable related TSF function */ + rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)|BIT(3)); + + if (((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE)) + ResumeTxBeacon(Adapter); + } + break; + case HW_VAR_CHECK_BSSID: + if (*((u8 *)val)) { + rtw_write32(Adapter, REG_RCR, rtw_read32(Adapter, REG_RCR)|RCR_CBSSID_DATA|RCR_CBSSID_BCN); + } else { + u32 val32; + + val32 = rtw_read32(Adapter, REG_RCR); + + val32 &= ~(RCR_CBSSID_DATA | RCR_CBSSID_BCN); + + rtw_write32(Adapter, REG_RCR, val32); + } + break; + case HW_VAR_MLME_DISCONNECT: + /* Set RCR to not to receive data frame when NO LINK state */ + /* reject all data frames */ + rtw_write16(Adapter, REG_RXFLTMAP2, 0x00); + + /* reset TSF */ + rtw_write8(Adapter, REG_DUAL_TSF_RST, (BIT(0)|BIT(1))); + + /* disable update TSF */ + rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)|BIT(4)); + break; + case HW_VAR_MLME_SITESURVEY: + if (*((u8 *)val)) { /* under sitesurvey */ + /* config RCR to receive different BSSID & not to receive data frame */ + u32 v = rtw_read32(Adapter, REG_RCR); + v &= ~(RCR_CBSSID_BCN); + rtw_write32(Adapter, REG_RCR, v); + /* reject all data frame */ + rtw_write16(Adapter, REG_RXFLTMAP2, 0x00); + + /* disable update TSF */ + rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)|BIT(4)); + } else { /* sitesurvey done */ + struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + if ((is_client_associated_to_ap(Adapter)) || + ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE)) { + /* enable to rx data frame */ + rtw_write16(Adapter, REG_RXFLTMAP2, 0xFFFF); + + /* enable update TSF */ + rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)&(~BIT(4))); + } else if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) { + rtw_write16(Adapter, REG_RXFLTMAP2, 0xFFFF); + /* enable update TSF */ + rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)&(~BIT(4))); + } + if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) { + rtw_write32(Adapter, REG_RCR, rtw_read32(Adapter, REG_RCR)|RCR_CBSSID_BCN); + } else { + if (Adapter->in_cta_test) { + u32 v = rtw_read32(Adapter, REG_RCR); + v &= ~(RCR_CBSSID_DATA | RCR_CBSSID_BCN);/* RCR_ADF */ + rtw_write32(Adapter, REG_RCR, v); + } else { + rtw_write32(Adapter, REG_RCR, rtw_read32(Adapter, REG_RCR)|RCR_CBSSID_BCN); + } + } + } + break; + case HW_VAR_MLME_JOIN: + { + u8 RetryLimit = 0x30; + u8 type = *((u8 *)val); + struct mlme_priv *pmlmepriv = &Adapter->mlmepriv; + + if (type == 0) { /* prepare to join */ + /* enable to rx data frame.Accept all data frame */ + rtw_write16(Adapter, REG_RXFLTMAP2, 0xFFFF); + + if (Adapter->in_cta_test) { + u32 v = rtw_read32(Adapter, REG_RCR); + v &= ~(RCR_CBSSID_DATA | RCR_CBSSID_BCN);/* RCR_ADF */ + rtw_write32(Adapter, REG_RCR, v); + } else { + rtw_write32(Adapter, REG_RCR, rtw_read32(Adapter, REG_RCR)|RCR_CBSSID_DATA|RCR_CBSSID_BCN); + } + + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) + RetryLimit = (haldata->CustomerID == RT_CID_CCX) ? 7 : 48; + else /* Ad-hoc Mode */ + RetryLimit = 0x7; + } else if (type == 1) { + /* joinbss_event call back when join res < 0 */ + rtw_write16(Adapter, REG_RXFLTMAP2, 0x00); + } else if (type == 2) { + /* sta add event call back */ + /* enable update TSF */ + rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)&(~BIT(4))); + + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE)) + RetryLimit = 0x7; + } + rtw_write16(Adapter, REG_RL, RetryLimit << RETRY_LIMIT_SHORT_SHIFT | RetryLimit << RETRY_LIMIT_LONG_SHIFT); + } + break; + case HW_VAR_BEACON_INTERVAL: + rtw_write16(Adapter, REG_BCN_INTERVAL, *((u16 *)val)); + break; + case HW_VAR_SLOT_TIME: + { + u8 u1bAIFS, aSifsTime; + struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + rtw_write8(Adapter, REG_SLOT, val[0]); + + if (pmlmeinfo->WMM_enable == 0) { + if (pmlmeext->cur_wireless_mode == WIRELESS_11B) + aSifsTime = 10; + else + aSifsTime = 16; + + u1bAIFS = aSifsTime + (2 * pmlmeinfo->slotTime); + + /* Temporary removed, 2008.06.20. */ + rtw_write8(Adapter, REG_EDCA_VO_PARAM, u1bAIFS); + rtw_write8(Adapter, REG_EDCA_VI_PARAM, u1bAIFS); + rtw_write8(Adapter, REG_EDCA_BE_PARAM, u1bAIFS); + rtw_write8(Adapter, REG_EDCA_BK_PARAM, u1bAIFS); + } + } + break; + case HW_VAR_RESP_SIFS: + /* RESP_SIFS for CCK */ + rtw_write8(Adapter, REG_R2T_SIFS, val[0]); /* SIFS_T2T_CCK (0x08) */ + rtw_write8(Adapter, REG_R2T_SIFS+1, val[1]); /* SIFS_R2T_CCK(0x08) */ + /* RESP_SIFS for OFDM */ + rtw_write8(Adapter, REG_T2T_SIFS, val[2]); /* SIFS_T2T_OFDM (0x0a) */ + rtw_write8(Adapter, REG_T2T_SIFS+1, val[3]); /* SIFS_R2T_OFDM(0x0a) */ + break; + case HW_VAR_ACK_PREAMBLE: + { + u8 regTmp; + u8 bShortPreamble = *((bool *)val); + /* Joseph marked out for Netgear 3500 TKIP channel 7 issue.(Temporarily) */ + regTmp = (haldata->nCur40MhzPrimeSC)<<5; + if (bShortPreamble) + regTmp |= 0x80; + + rtw_write8(Adapter, REG_RRSR+2, regTmp); + } + break; + case HW_VAR_SEC_CFG: + rtw_write8(Adapter, REG_SECCFG, *((u8 *)val)); + break; + case HW_VAR_DM_FLAG: + podmpriv->SupportAbility = *((u8 *)val); + break; + case HW_VAR_DM_FUNC_OP: + if (val[0]) + podmpriv->BK_SupportAbility = podmpriv->SupportAbility; + else + podmpriv->SupportAbility = podmpriv->BK_SupportAbility; + break; + case HW_VAR_DM_FUNC_SET: + if (*((u32 *)val) == DYNAMIC_ALL_FUNC_ENABLE) { + pdmpriv->DMFlag = pdmpriv->InitDMFlag; + podmpriv->SupportAbility = pdmpriv->InitODMFlag; + } else { + podmpriv->SupportAbility |= *((u32 *)val); + } + break; + case HW_VAR_DM_FUNC_CLR: + podmpriv->SupportAbility &= *((u32 *)val); + break; + case HW_VAR_CAM_EMPTY_ENTRY: + { + u8 ucIndex = *((u8 *)val); + u8 i; + u32 ulCommand = 0; + u32 ulContent = 0; + u32 ulEncAlgo = CAM_AES; + + for (i = 0; i < CAM_CONTENT_COUNT; i++) { + /* filled id in CAM config 2 byte */ + if (i == 0) + ulContent |= (ucIndex & 0x03) | ((u16)(ulEncAlgo)<<2); + else + ulContent = 0; + /* polling bit, and No Write enable, and address */ + ulCommand = CAM_CONTENT_COUNT*ucIndex+i; + ulCommand = ulCommand | CAM_POLLINIG|CAM_WRITE; + /* write content 0 is equall to mark invalid */ + rtw_write32(Adapter, WCAMI, ulContent); /* delay_ms(40); */ + rtw_write32(Adapter, RWCAM, ulCommand); /* delay_ms(40); */ + } + } + break; + case HW_VAR_CAM_INVALID_ALL: + rtw_write32(Adapter, RWCAM, BIT(31)|BIT(30)); + break; + case HW_VAR_CAM_WRITE: + { + u32 cmd; + u32 *cam_val = (u32 *)val; + rtw_write32(Adapter, WCAMI, cam_val[0]); + + cmd = CAM_POLLINIG | CAM_WRITE | cam_val[1]; + rtw_write32(Adapter, RWCAM, cmd); + } + break; + case HW_VAR_AC_PARAM_VO: + rtw_write32(Adapter, REG_EDCA_VO_PARAM, ((u32 *)(val))[0]); + break; + case HW_VAR_AC_PARAM_VI: + rtw_write32(Adapter, REG_EDCA_VI_PARAM, ((u32 *)(val))[0]); + break; + case HW_VAR_AC_PARAM_BE: + haldata->AcParam_BE = ((u32 *)(val))[0]; + rtw_write32(Adapter, REG_EDCA_BE_PARAM, ((u32 *)(val))[0]); + break; + case HW_VAR_AC_PARAM_BK: + rtw_write32(Adapter, REG_EDCA_BK_PARAM, ((u32 *)(val))[0]); + break; + case HW_VAR_ACM_CTRL: + { + u8 acm_ctrl = *((u8 *)val); + u8 AcmCtrl = rtw_read8(Adapter, REG_ACMHWCTRL); + + if (acm_ctrl > 1) + AcmCtrl = AcmCtrl | 0x1; + + if (acm_ctrl & BIT(3)) + AcmCtrl |= AcmHw_VoqEn; + else + AcmCtrl &= (~AcmHw_VoqEn); + + if (acm_ctrl & BIT(2)) + AcmCtrl |= AcmHw_ViqEn; + else + AcmCtrl &= (~AcmHw_ViqEn); + + if (acm_ctrl & BIT(1)) + AcmCtrl |= AcmHw_BeqEn; + else + AcmCtrl &= (~AcmHw_BeqEn); + + DBG_88E("[HW_VAR_ACM_CTRL] Write 0x%X\n", AcmCtrl); + rtw_write8(Adapter, REG_ACMHWCTRL, AcmCtrl); + } + break; + case HW_VAR_AMPDU_MIN_SPACE: + { + u8 MinSpacingToSet; + u8 SecMinSpace; + + MinSpacingToSet = *((u8 *)val); + if (MinSpacingToSet <= 7) { + switch (Adapter->securitypriv.dot11PrivacyAlgrthm) { + case _NO_PRIVACY_: + case _AES_: + SecMinSpace = 0; + break; + case _WEP40_: + case _WEP104_: + case _TKIP_: + case _TKIP_WTMIC_: + SecMinSpace = 6; + break; + default: + SecMinSpace = 7; + break; + } + if (MinSpacingToSet < SecMinSpace) + MinSpacingToSet = SecMinSpace; + rtw_write8(Adapter, REG_AMPDU_MIN_SPACE, (rtw_read8(Adapter, REG_AMPDU_MIN_SPACE) & 0xf8) | MinSpacingToSet); + } + } + break; + case HW_VAR_AMPDU_FACTOR: + { + u8 RegToSet_Normal[4] = {0x41, 0xa8, 0x72, 0xb9}; + u8 FactorToSet; + u8 *pRegToSet; + u8 index = 0; + + pRegToSet = RegToSet_Normal; /* 0xb972a841; */ + FactorToSet = *((u8 *)val); + if (FactorToSet <= 3) { + FactorToSet = (1<<(FactorToSet + 2)); + if (FactorToSet > 0xf) + FactorToSet = 0xf; + + for (index = 0; index < 4; index++) { + if ((pRegToSet[index] & 0xf0) > (FactorToSet<<4)) + pRegToSet[index] = (pRegToSet[index] & 0x0f) | (FactorToSet<<4); + + if ((pRegToSet[index] & 0x0f) > FactorToSet) + pRegToSet[index] = (pRegToSet[index] & 0xf0) | (FactorToSet); + + rtw_write8(Adapter, (REG_AGGLEN_LMT+index), pRegToSet[index]); + } + } + } + break; + case HW_VAR_RXDMA_AGG_PG_TH: + { + u8 threshold = *((u8 *)val); + if (threshold == 0) + threshold = haldata->UsbRxAggPageCount; + rtw_write8(Adapter, REG_RXDMA_AGG_PG_TH, threshold); + } + break; + case HW_VAR_SET_RPWM: + break; + case HW_VAR_H2C_FW_PWRMODE: + { + u8 psmode = (*(u8 *)val); + + /* Forece leave RF low power mode for 1T1R to prevent conficting setting in Fw power */ + /* saving sequence. 2010.06.07. Added by tynli. Suggested by SD3 yschang. */ + if ((psmode != PS_MODE_ACTIVE) && (!IS_92C_SERIAL(haldata->VersionID))) + ODM_RF_Saving(podmpriv, true); + rtl8188e_set_FwPwrMode_cmd(Adapter, psmode); + } + break; + case HW_VAR_H2C_FW_JOINBSSRPT: + { + u8 mstatus = (*(u8 *)val); + rtl8188e_set_FwJoinBssReport_cmd(Adapter, mstatus); + } + break; +#ifdef CONFIG_88EU_P2P + case HW_VAR_H2C_FW_P2P_PS_OFFLOAD: + { + u8 p2p_ps_state = (*(u8 *)val); + rtl8188e_set_p2p_ps_offload_cmd(Adapter, p2p_ps_state); + } + break; +#endif + case HW_VAR_INITIAL_GAIN: + { + struct rtw_dig *pDigTable = &podmpriv->DM_DigTable; + u32 rx_gain = ((u32 *)(val))[0]; + + if (rx_gain == 0xff) {/* restore rx gain */ + ODM_Write_DIG(podmpriv, pDigTable->BackupIGValue); + } else { + pDigTable->BackupIGValue = pDigTable->CurIGValue; + ODM_Write_DIG(podmpriv, rx_gain); + } + } + break; + case HW_VAR_TRIGGER_GPIO_0: + rtl8192cu_trigger_gpio_0(Adapter); + break; + case HW_VAR_RPT_TIMER_SETTING: + { + u16 min_rpt_time = (*(u16 *)val); + ODM_RA_Set_TxRPT_Time(podmpriv, min_rpt_time); + } + break; + case HW_VAR_ANTENNA_DIVERSITY_SELECT: + { + u8 Optimum_antenna = (*(u8 *)val); + u8 Ant; + /* switch antenna to Optimum_antenna */ + if (haldata->CurAntenna != Optimum_antenna) { + Ant = (Optimum_antenna == 2) ? MAIN_ANT : AUX_ANT; + ODM_UpdateRxIdleAnt_88E(&haldata->odmpriv, Ant); + + haldata->CurAntenna = Optimum_antenna; + } + } + break; + case HW_VAR_EFUSE_BYTES: /* To set EFUE total used bytes, added by Roger, 2008.12.22. */ + haldata->EfuseUsedBytes = *((u16 *)val); + break; + case HW_VAR_FIFO_CLEARN_UP: + { + struct pwrctrl_priv *pwrpriv = &Adapter->pwrctrlpriv; + u8 trycnt = 100; + + /* pause tx */ + rtw_write8(Adapter, REG_TXPAUSE, 0xff); + + /* keep sn */ + Adapter->xmitpriv.nqos_ssn = rtw_read16(Adapter, REG_NQOS_SEQ); + + if (!pwrpriv->bkeepfwalive) { + /* RX DMA stop */ + rtw_write32(Adapter, REG_RXPKT_NUM, (rtw_read32(Adapter, REG_RXPKT_NUM)|RW_RELEASE_EN)); + do { + if (!(rtw_read32(Adapter, REG_RXPKT_NUM)&RXDMA_IDLE)) + break; + } while (trycnt--); + if (trycnt == 0) + DBG_88E("Stop RX DMA failed......\n"); + + /* RQPN Load 0 */ + rtw_write16(Adapter, REG_RQPN_NPQ, 0x0); + rtw_write32(Adapter, REG_RQPN, 0x80000000); + rtw_mdelay_os(10); + } + } + break; + case HW_VAR_CHECK_TXBUF: + break; + case HW_VAR_APFM_ON_MAC: + haldata->bMacPwrCtrlOn = *val; + DBG_88E("%s: bMacPwrCtrlOn=%d\n", __func__, haldata->bMacPwrCtrlOn); + break; + case HW_VAR_TX_RPT_MAX_MACID: + { + u8 maxMacid = *val; + DBG_88E("### MacID(%d),Set Max Tx RPT MID(%d)\n", maxMacid, maxMacid+1); + rtw_write8(Adapter, REG_TX_RPT_CTRL+1, maxMacid+1); + } + break; + case HW_VAR_H2C_MEDIA_STATUS_RPT: + rtl8188e_set_FwMediaStatus_cmd(Adapter , (*(__le16 *)val)); + break; + case HW_VAR_BCN_VALID: + /* BCN_VALID, BIT16 of REG_TDECTRL = BIT0 of REG_TDECTRL+2, write 1 to clear, Clear by sw */ + rtw_write8(Adapter, REG_TDECTRL+2, rtw_read8(Adapter, REG_TDECTRL+2) | BIT0); + break; + default: + break; + } +_func_exit_; +} + +static void GetHwReg8188EU(struct adapter *Adapter, u8 variable, u8 *val) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + struct odm_dm_struct *podmpriv = &haldata->odmpriv; +_func_enter_; + + switch (variable) { + case HW_VAR_BASIC_RATE: + *((u16 *)(val)) = haldata->BasicRateSet; + case HW_VAR_TXPAUSE: + val[0] = rtw_read8(Adapter, REG_TXPAUSE); + break; + case HW_VAR_BCN_VALID: + /* BCN_VALID, BIT16 of REG_TDECTRL = BIT0 of REG_TDECTRL+2 */ + val[0] = (BIT0 & rtw_read8(Adapter, REG_TDECTRL+2)) ? true : false; + break; + case HW_VAR_DM_FLAG: + val[0] = podmpriv->SupportAbility; + break; + case HW_VAR_RF_TYPE: + val[0] = haldata->rf_type; + break; + case HW_VAR_FWLPS_RF_ON: + { + /* When we halt NIC, we should check if FW LPS is leave. */ + if (Adapter->pwrctrlpriv.rf_pwrstate == rf_off) { + /* If it is in HW/SW Radio OFF or IPS state, we do not check Fw LPS Leave, */ + /* because Fw is unload. */ + val[0] = true; + } else { + u32 valRCR; + valRCR = rtw_read32(Adapter, REG_RCR); + valRCR &= 0x00070000; + if (valRCR) + val[0] = false; + else + val[0] = true; + } + } + break; + case HW_VAR_CURRENT_ANTENNA: + val[0] = haldata->CurAntenna; + break; + case HW_VAR_EFUSE_BYTES: /* To get EFUE total used bytes, added by Roger, 2008.12.22. */ + *((u16 *)(val)) = haldata->EfuseUsedBytes; + break; + case HW_VAR_APFM_ON_MAC: + *val = haldata->bMacPwrCtrlOn; + break; + case HW_VAR_CHK_HI_QUEUE_EMPTY: + *val = ((rtw_read32(Adapter, REG_HGQ_INFORMATION)&0x0000ff00) == 0) ? true : false; + break; + default: + break; + } + +_func_exit_; +} + +/* */ +/* Description: */ +/* Query setting of specified variable. */ +/* */ +static u8 +GetHalDefVar8188EUsb( + struct adapter *Adapter, + enum hal_def_variable eVariable, + void *pValue + ) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + u8 bResult = _SUCCESS; + + switch (eVariable) { + case HAL_DEF_UNDERCORATEDSMOOTHEDPWDB: + { + struct mlme_priv *pmlmepriv = &Adapter->mlmepriv; + struct sta_priv *pstapriv = &Adapter->stapriv; + struct sta_info *psta; + psta = rtw_get_stainfo(pstapriv, pmlmepriv->cur_network.network.MacAddress); + if (psta) + *((int *)pValue) = psta->rssi_stat.UndecoratedSmoothedPWDB; + } + break; + case HAL_DEF_IS_SUPPORT_ANT_DIV: + *((u8 *)pValue) = (haldata->AntDivCfg == 0) ? false : true; + break; + case HAL_DEF_CURRENT_ANTENNA: + *((u8 *)pValue) = haldata->CurAntenna; + break; + case HAL_DEF_DRVINFO_SZ: + *((u32 *)pValue) = DRVINFO_SZ; + break; + case HAL_DEF_MAX_RECVBUF_SZ: + *((u32 *)pValue) = MAX_RECVBUF_SZ; + break; + case HAL_DEF_RX_PACKET_OFFSET: + *((u32 *)pValue) = RXDESC_SIZE + DRVINFO_SZ; + break; + case HAL_DEF_DBG_DM_FUNC: + *((u32 *)pValue) = haldata->odmpriv.SupportAbility; + break; + case HAL_DEF_RA_DECISION_RATE: + { + u8 MacID = *((u8 *)pValue); + *((u8 *)pValue) = ODM_RA_GetDecisionRate_8188E(&(haldata->odmpriv), MacID); + } + break; + case HAL_DEF_RA_SGI: + { + u8 MacID = *((u8 *)pValue); + *((u8 *)pValue) = ODM_RA_GetShortGI_8188E(&(haldata->odmpriv), MacID); + } + break; + case HAL_DEF_PT_PWR_STATUS: + { + u8 MacID = *((u8 *)pValue); + *((u8 *)pValue) = ODM_RA_GetHwPwrStatus_8188E(&(haldata->odmpriv), MacID); + } + break; + case HW_VAR_MAX_RX_AMPDU_FACTOR: + *((u32 *)pValue) = MAX_AMPDU_FACTOR_64K; + break; + case HW_DEF_RA_INFO_DUMP: + { + u8 entry_id = *((u8 *)pValue); + if (check_fwstate(&Adapter->mlmepriv, _FW_LINKED)) { + DBG_88E("============ RA status check ===================\n"); + DBG_88E("Mac_id:%d , RateID = %d, RAUseRate = 0x%08x, RateSGI = %d, DecisionRate = 0x%02x ,PTStage = %d\n", + entry_id, + haldata->odmpriv.RAInfo[entry_id].RateID, + haldata->odmpriv.RAInfo[entry_id].RAUseRate, + haldata->odmpriv.RAInfo[entry_id].RateSGI, + haldata->odmpriv.RAInfo[entry_id].DecisionRate, + haldata->odmpriv.RAInfo[entry_id].PTStage); + } + } + break; + case HW_DEF_ODM_DBG_FLAG: + { + struct odm_dm_struct *dm_ocm = &(haldata->odmpriv); + pr_info("dm_ocm->DebugComponents = 0x%llx\n", dm_ocm->DebugComponents); + } + break; + case HAL_DEF_DBG_DUMP_RXPKT: + *((u8 *)pValue) = haldata->bDumpRxPkt; + break; + case HAL_DEF_DBG_DUMP_TXPKT: + *((u8 *)pValue) = haldata->bDumpTxPkt; + break; + default: + bResult = _FAIL; + break; + } + + return bResult; +} + +/* */ +/* Description: */ +/* Change default setting of specified variable. */ +/* */ +static u8 SetHalDefVar8188EUsb(struct adapter *Adapter, enum hal_def_variable eVariable, void *pValue) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + u8 bResult = _SUCCESS; + + switch (eVariable) { + case HAL_DEF_DBG_DM_FUNC: + { + u8 dm_func = *((u8 *)pValue); + struct odm_dm_struct *podmpriv = &haldata->odmpriv; + + if (dm_func == 0) { /* disable all dynamic func */ + podmpriv->SupportAbility = DYNAMIC_FUNC_DISABLE; + DBG_88E("==> Disable all dynamic function...\n"); + } else if (dm_func == 1) {/* disable DIG */ + podmpriv->SupportAbility &= (~DYNAMIC_BB_DIG); + DBG_88E("==> Disable DIG...\n"); + } else if (dm_func == 2) {/* disable High power */ + podmpriv->SupportAbility &= (~DYNAMIC_BB_DYNAMIC_TXPWR); + } else if (dm_func == 3) {/* disable tx power tracking */ + podmpriv->SupportAbility &= (~DYNAMIC_RF_CALIBRATION); + DBG_88E("==> Disable tx power tracking...\n"); + } else if (dm_func == 5) {/* disable antenna diversity */ + podmpriv->SupportAbility &= (~DYNAMIC_BB_ANT_DIV); + } else if (dm_func == 6) {/* turn on all dynamic func */ + if (!(podmpriv->SupportAbility & DYNAMIC_BB_DIG)) { + struct rtw_dig *pDigTable = &podmpriv->DM_DigTable; + pDigTable->CurIGValue = rtw_read8(Adapter, 0xc50); + } + podmpriv->SupportAbility = DYNAMIC_ALL_FUNC_ENABLE; + DBG_88E("==> Turn on all dynamic function...\n"); + } + } + break; + case HAL_DEF_DBG_DUMP_RXPKT: + haldata->bDumpRxPkt = *((u8 *)pValue); + break; + case HAL_DEF_DBG_DUMP_TXPKT: + haldata->bDumpTxPkt = *((u8 *)pValue); + break; + case HW_DEF_FA_CNT_DUMP: + { + u8 bRSSIDump = *((u8 *)pValue); + struct odm_dm_struct *dm_ocm = &(haldata->odmpriv); + if (bRSSIDump) + dm_ocm->DebugComponents = ODM_COMP_DIG|ODM_COMP_FA_CNT ; + else + dm_ocm->DebugComponents = 0; + } + break; + case HW_DEF_ODM_DBG_FLAG: + { + u64 DebugComponents = *((u64 *)pValue); + struct odm_dm_struct *dm_ocm = &(haldata->odmpriv); + dm_ocm->DebugComponents = DebugComponents; + } + break; + default: + bResult = _FAIL; + break; + } + + return bResult; +} + +static void UpdateHalRAMask8188EUsb(struct adapter *adapt, u32 mac_id, u8 rssi_level) +{ + u8 init_rate = 0; + u8 networkType, raid; + u32 mask, rate_bitmap; + u8 shortGIrate = false; + int supportRateNum = 0; + struct sta_info *psta; + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + struct mlme_ext_priv *pmlmeext = &adapt->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); + + if (mac_id >= NUM_STA) /* CAM_SIZE */ + return; + psta = pmlmeinfo->FW_sta_info[mac_id].psta; + if (psta == NULL) + return; + switch (mac_id) { + case 0:/* for infra mode */ + supportRateNum = rtw_get_rateset_len(cur_network->SupportedRates); + networkType = judge_network_type(adapt, cur_network->SupportedRates, supportRateNum) & 0xf; + raid = networktype_to_raid(networkType); + mask = update_supported_rate(cur_network->SupportedRates, supportRateNum); + mask |= (pmlmeinfo->HT_enable) ? update_MSC_rate(&(pmlmeinfo->HT_caps)) : 0; + if (support_short_GI(adapt, &(pmlmeinfo->HT_caps))) + shortGIrate = true; + break; + case 1:/* for broadcast/multicast */ + supportRateNum = rtw_get_rateset_len(pmlmeinfo->FW_sta_info[mac_id].SupportedRates); + if (pmlmeext->cur_wireless_mode & WIRELESS_11B) + networkType = WIRELESS_11B; + else + networkType = WIRELESS_11G; + raid = networktype_to_raid(networkType); + mask = update_basic_rate(cur_network->SupportedRates, supportRateNum); + break; + default: /* for each sta in IBSS */ + supportRateNum = rtw_get_rateset_len(pmlmeinfo->FW_sta_info[mac_id].SupportedRates); + networkType = judge_network_type(adapt, pmlmeinfo->FW_sta_info[mac_id].SupportedRates, supportRateNum) & 0xf; + raid = networktype_to_raid(networkType); + mask = update_supported_rate(cur_network->SupportedRates, supportRateNum); + + /* todo: support HT in IBSS */ + break; + } + + rate_bitmap = 0x0fffffff; + rate_bitmap = ODM_Get_Rate_Bitmap(&haldata->odmpriv, mac_id, mask, rssi_level); + DBG_88E("%s => mac_id:%d, networkType:0x%02x, mask:0x%08x\n\t ==> rssi_level:%d, rate_bitmap:0x%08x\n", + __func__, mac_id, networkType, mask, rssi_level, rate_bitmap); + + mask &= rate_bitmap; + + init_rate = get_highest_rate_idx(mask)&0x3f; + + if (haldata->fw_ractrl) { + u8 arg; + + arg = mac_id & 0x1f;/* MACID */ + arg |= BIT(7); + if (shortGIrate) + arg |= BIT(5); + mask |= ((raid << 28) & 0xf0000000); + DBG_88E("update raid entry, mask=0x%x, arg=0x%x\n", mask, arg); + psta->ra_mask = mask; + mask |= ((raid << 28) & 0xf0000000); + + /* to do ,for 8188E-SMIC */ + rtl8188e_set_raid_cmd(adapt, mask); + } else { + ODM_RA_UpdateRateInfo_8188E(&(haldata->odmpriv), + mac_id, + raid, + mask, + shortGIrate + ); + } + /* set ra_id */ + psta->raid = raid; + psta->init_rate = init_rate; +} + +static void SetBeaconRelatedRegisters8188EUsb(struct adapter *adapt) +{ + u32 value32; + struct mlme_ext_priv *pmlmeext = &(adapt->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + u32 bcn_ctrl_reg = REG_BCN_CTRL; + /* reset TSF, enable update TSF, correcting TSF On Beacon */ + + /* BCN interval */ + rtw_write16(adapt, REG_BCN_INTERVAL, pmlmeinfo->bcn_interval); + rtw_write8(adapt, REG_ATIMWND, 0x02);/* 2ms */ + + _InitBeaconParameters(adapt); + + rtw_write8(adapt, REG_SLOT, 0x09); + + value32 = rtw_read32(adapt, REG_TCR); + value32 &= ~TSFRST; + rtw_write32(adapt, REG_TCR, value32); + + value32 |= TSFRST; + rtw_write32(adapt, REG_TCR, value32); + + /* NOTE: Fix test chip's bug (about contention windows's randomness) */ + rtw_write8(adapt, REG_RXTSF_OFFSET_CCK, 0x50); + rtw_write8(adapt, REG_RXTSF_OFFSET_OFDM, 0x50); + + _BeaconFunctionEnable(adapt, true, true); + + ResumeTxBeacon(adapt); + + rtw_write8(adapt, bcn_ctrl_reg, rtw_read8(adapt, bcn_ctrl_reg)|BIT(1)); +} + +static void rtl8188eu_init_default_value(struct adapter *adapt) +{ + struct hal_data_8188e *haldata; + struct pwrctrl_priv *pwrctrlpriv; + u8 i; + + haldata = GET_HAL_DATA(adapt); + pwrctrlpriv = &adapt->pwrctrlpriv; + + /* init default value */ + haldata->fw_ractrl = false; + if (!pwrctrlpriv->bkeepfwalive) + haldata->LastHMEBoxNum = 0; + + /* init dm default value */ + haldata->odmpriv.RFCalibrateInfo.bIQKInitialized = false; + haldata->odmpriv.RFCalibrateInfo.TM_Trigger = 0;/* for IQK */ + haldata->pwrGroupCnt = 0; + haldata->PGMaxGroup = 13; + haldata->odmpriv.RFCalibrateInfo.ThermalValue_HP_index = 0; + for (i = 0; i < HP_THERMAL_NUM; i++) + haldata->odmpriv.RFCalibrateInfo.ThermalValue_HP[i] = 0; +} + +static u8 rtl8188eu_ps_func(struct adapter *Adapter, enum hal_intf_ps_func efunc_id, u8 *val) +{ + u8 bResult = true; + return bResult; +} + +void rtl8188eu_set_hal_ops(struct adapter *adapt) +{ + struct hal_ops *halfunc = &adapt->HalFunc; + +_func_enter_; + + adapt->HalData = rtw_zmalloc(sizeof(struct hal_data_8188e)); + if (adapt->HalData == NULL) + DBG_88E("cant not alloc memory for HAL DATA\n"); + adapt->hal_data_sz = sizeof(struct hal_data_8188e); + + halfunc->hal_power_on = rtl8188eu_InitPowerOn; + halfunc->hal_init = &rtl8188eu_hal_init; + halfunc->hal_deinit = &rtl8188eu_hal_deinit; + + halfunc->inirp_init = &rtl8188eu_inirp_init; + halfunc->inirp_deinit = &rtl8188eu_inirp_deinit; + + halfunc->init_xmit_priv = &rtl8188eu_init_xmit_priv; + halfunc->free_xmit_priv = &rtl8188eu_free_xmit_priv; + + halfunc->init_recv_priv = &rtl8188eu_init_recv_priv; + halfunc->free_recv_priv = &rtl8188eu_free_recv_priv; + halfunc->InitSwLeds = &rtl8188eu_InitSwLeds; + halfunc->DeInitSwLeds = &rtl8188eu_DeInitSwLeds; + + halfunc->init_default_value = &rtl8188eu_init_default_value; + halfunc->intf_chip_configure = &rtl8188eu_interface_configure; + halfunc->read_adapter_info = &ReadAdapterInfo8188EU; + + halfunc->SetHwRegHandler = &SetHwReg8188EU; + halfunc->GetHwRegHandler = &GetHwReg8188EU; + halfunc->GetHalDefVarHandler = &GetHalDefVar8188EUsb; + halfunc->SetHalDefVarHandler = &SetHalDefVar8188EUsb; + + halfunc->UpdateRAMaskHandler = &UpdateHalRAMask8188EUsb; + halfunc->SetBeaconRelatedRegistersHandler = &SetBeaconRelatedRegisters8188EUsb; + + halfunc->hal_xmit = &rtl8188eu_hal_xmit; + halfunc->mgnt_xmit = &rtl8188eu_mgnt_xmit; + + halfunc->interface_ps_func = &rtl8188eu_ps_func; + + rtl8188e_set_hal_ops(halfunc); +_func_exit_; +} diff --git a/drivers/staging/rtl8188eu/hal/usb_ops_linux.c b/drivers/staging/rtl8188eu/hal/usb_ops_linux.c new file mode 100644 index 0000000000000..bc564169b2f05 --- /dev/null +++ b/drivers/staging/rtl8188eu/hal/usb_ops_linux.c @@ -0,0 +1,726 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _HCI_OPS_OS_C_ + +#include +#include +#include +#include +#include +#include + +static int usbctrl_vendorreq(struct intf_hdl *pintfhdl, u8 request, u16 value, u16 index, void *pdata, u16 len, u8 requesttype) +{ + struct adapter *adapt = pintfhdl->padapter; + struct dvobj_priv *dvobjpriv = adapter_to_dvobj(adapt); + struct usb_device *udev = dvobjpriv->pusbdev; + unsigned int pipe; + int status = 0; + u8 reqtype; + u8 *pIo_buf; + int vendorreq_times = 0; + + if ((adapt->bSurpriseRemoved) || (adapt->pwrctrlpriv.pnp_bstop_trx)) { + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usbctrl_vendorreq:(adapt->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n")); + status = -EPERM; + goto exit; + } + + if (len > MAX_VENDOR_REQ_CMD_SIZE) { + DBG_88E("[%s] Buffer len error ,vendor request failed\n", __func__); + status = -EINVAL; + goto exit; + } + + _enter_critical_mutex(&dvobjpriv->usb_vendor_req_mutex, NULL); + + /* Acquire IO memory for vendorreq */ + pIo_buf = dvobjpriv->usb_vendor_req_buf; + + if (pIo_buf == NULL) { + DBG_88E("[%s] pIo_buf == NULL\n", __func__); + status = -ENOMEM; + goto release_mutex; + } + + while (++vendorreq_times <= MAX_USBCTRL_VENDORREQ_TIMES) { + _rtw_memset(pIo_buf, 0, len); + + if (requesttype == 0x01) { + pipe = usb_rcvctrlpipe(udev, 0);/* read_in */ + reqtype = REALTEK_USB_VENQT_READ; + } else { + pipe = usb_sndctrlpipe(udev, 0);/* write_out */ + reqtype = REALTEK_USB_VENQT_WRITE; + memcpy(pIo_buf, pdata, len); + } + + status = rtw_usb_control_msg(udev, pipe, request, reqtype, value, index, pIo_buf, len, RTW_USB_CONTROL_MSG_TIMEOUT); + + if (status == len) { /* Success this control transfer. */ + rtw_reset_continual_urb_error(dvobjpriv); + if (requesttype == 0x01) + memcpy(pdata, pIo_buf, len); + } else { /* error cases */ + DBG_88E("reg 0x%x, usb %s %u fail, status:%d value=0x%x, vendorreq_times:%d\n", + value, (requesttype == 0x01) ? "read" : "write", + len, status, *(u32 *)pdata, vendorreq_times); + + if (status < 0) { + if (status == (-ESHUTDOWN) || status == -ENODEV) { + adapt->bSurpriseRemoved = true; + } else { + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + haldata->srestpriv.Wifi_Error_Status = USB_VEN_REQ_CMD_FAIL; + } + } else { /* status != len && status >= 0 */ + if (status > 0) { + if (requesttype == 0x01) { + /* For Control read transfer, we have to copy the read data from pIo_buf to pdata. */ + memcpy(pdata, pIo_buf, len); + } + } + } + + if (rtw_inc_and_chk_continual_urb_error(dvobjpriv)) { + adapt->bSurpriseRemoved = true; + break; + } + + } + + /* firmware download is checksumed, don't retry */ + if ((value >= FW_8188E_START_ADDRESS && value <= FW_8188E_END_ADDRESS) || status == len) + break; + } +release_mutex: + _exit_critical_mutex(&dvobjpriv->usb_vendor_req_mutex, NULL); +exit: + return status; +} + +static u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr) +{ + u8 request; + u8 requesttype; + u16 wvalue; + u16 index; + u16 len; + u8 data = 0; + + _func_enter_; + + request = 0x05; + requesttype = 0x01;/* read_in */ + index = 0;/* n/a */ + + wvalue = (u16)(addr&0x0000ffff); + len = 1; + + usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); + + _func_exit_; + + return data; + +} + +static u16 usb_read16(struct intf_hdl *pintfhdl, u32 addr) +{ + u8 request; + u8 requesttype; + u16 wvalue; + u16 index; + u16 len; + __le32 data; + +_func_enter_; + request = 0x05; + requesttype = 0x01;/* read_in */ + index = 0;/* n/a */ + wvalue = (u16)(addr&0x0000ffff); + len = 2; + usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); +_func_exit_; + + return (u16)(le32_to_cpu(data)&0xffff); +} + +static u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr) +{ + u8 request; + u8 requesttype; + u16 wvalue; + u16 index; + u16 len; + __le32 data; + +_func_enter_; + + request = 0x05; + requesttype = 0x01;/* read_in */ + index = 0;/* n/a */ + + wvalue = (u16)(addr&0x0000ffff); + len = 4; + + usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); + +_func_exit_; + + return le32_to_cpu(data); +} + +static int usb_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val) +{ + u8 request; + u8 requesttype; + u16 wvalue; + u16 index; + u16 len; + u8 data; + int ret; + + _func_enter_; + request = 0x05; + requesttype = 0x00;/* write_out */ + index = 0;/* n/a */ + wvalue = (u16)(addr&0x0000ffff); + len = 1; + data = val; + ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); + _func_exit_; + return ret; +} + +static int usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val) +{ + u8 request; + u8 requesttype; + u16 wvalue; + u16 index; + u16 len; + __le32 data; + int ret; + + _func_enter_; + + request = 0x05; + requesttype = 0x00;/* write_out */ + index = 0;/* n/a */ + + wvalue = (u16)(addr&0x0000ffff); + len = 2; + + data = cpu_to_le32(val & 0x0000ffff); + + ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); + + _func_exit_; + + return ret; +} + +static int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val) +{ + u8 request; + u8 requesttype; + u16 wvalue; + u16 index; + u16 len; + __le32 data; + int ret; + + _func_enter_; + + request = 0x05; + requesttype = 0x00;/* write_out */ + index = 0;/* n/a */ + + wvalue = (u16)(addr&0x0000ffff); + len = 4; + data = cpu_to_le32(val); + + ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); + + _func_exit_; + + return ret; +} + +static int usb_writeN(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata) +{ + u8 request; + u8 requesttype; + u16 wvalue; + u16 index; + u16 len; + u8 buf[VENDOR_CMD_MAX_DATA_LEN] = {0}; + int ret; + + _func_enter_; + + request = 0x05; + requesttype = 0x00;/* write_out */ + index = 0;/* n/a */ + + wvalue = (u16)(addr&0x0000ffff); + len = length; + memcpy(buf, pdata, len); + + ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, buf, len, requesttype); + + _func_exit_; + + return ret; +} + +static void interrupt_handler_8188eu(struct adapter *adapt, u16 pkt_len, u8 *pbuf) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + + if (pkt_len != INTERRUPT_MSG_FORMAT_LEN) { + DBG_88E("%s Invalid interrupt content length (%d)!\n", __func__, pkt_len); + return; + } + + /* HISR */ + memcpy(&(haldata->IntArray[0]), &(pbuf[USB_INTR_CONTENT_HISR_OFFSET]), 4); + memcpy(&(haldata->IntArray[1]), &(pbuf[USB_INTR_CONTENT_HISRE_OFFSET]), 4); + + /* C2H Event */ + if (pbuf[0] != 0) + memcpy(&(haldata->C2hArray[0]), &(pbuf[USB_INTR_CONTENT_C2H_OFFSET]), 16); +} + +static int recvbuf2recvframe(struct adapter *adapt, struct sk_buff *pskb) +{ + u8 *pbuf; + u8 shift_sz = 0; + u16 pkt_cnt; + u32 pkt_offset, skb_len, alloc_sz; + s32 transfer_len; + struct recv_stat *prxstat; + struct phy_stat *pphy_status = NULL; + struct sk_buff *pkt_copy = NULL; + union recv_frame *precvframe = NULL; + struct rx_pkt_attrib *pattrib = NULL; + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + struct recv_priv *precvpriv = &adapt->recvpriv; + struct __queue *pfree_recv_queue = &precvpriv->free_recv_queue; + + transfer_len = (s32)pskb->len; + pbuf = pskb->data; + + prxstat = (struct recv_stat *)pbuf; + pkt_cnt = (le32_to_cpu(prxstat->rxdw2) >> 16) & 0xff; + + do { + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, + ("recvbuf2recvframe: rxdesc=offsset 0:0x%08x, 4:0x%08x, 8:0x%08x, C:0x%08x\n", + prxstat->rxdw0, prxstat->rxdw1, prxstat->rxdw2, prxstat->rxdw4)); + + prxstat = (struct recv_stat *)pbuf; + + precvframe = rtw_alloc_recvframe(pfree_recv_queue); + if (precvframe == NULL) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("recvbuf2recvframe: precvframe==NULL\n")); + DBG_88E("%s()-%d: rtw_alloc_recvframe() failed! RX Drop!\n", __func__, __LINE__); + goto _exit_recvbuf2recvframe; + } + + _rtw_init_listhead(&precvframe->u.hdr.list); + precvframe->u.hdr.precvbuf = NULL; /* can't access the precvbuf for new arch. */ + precvframe->u.hdr.len = 0; + + update_recvframe_attrib_88e(precvframe, prxstat); + + pattrib = &precvframe->u.hdr.attrib; + + if ((pattrib->crc_err) || (pattrib->icv_err)) { + DBG_88E("%s: RX Warning! crc_err=%d icv_err=%d, skip!\n", __func__, pattrib->crc_err, pattrib->icv_err); + + rtw_free_recvframe(precvframe, pfree_recv_queue); + goto _exit_recvbuf2recvframe; + } + + if ((pattrib->physt) && (pattrib->pkt_rpt_type == NORMAL_RX)) + pphy_status = (struct phy_stat *)(pbuf + RXDESC_OFFSET); + + pkt_offset = RXDESC_SIZE + pattrib->drvinfo_sz + pattrib->shift_sz + pattrib->pkt_len; + + if ((pattrib->pkt_len <= 0) || (pkt_offset > transfer_len)) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("recvbuf2recvframe: pkt_len<=0\n")); + DBG_88E("%s()-%d: RX Warning!,pkt_len<=0 or pkt_offset> transfoer_len\n", __func__, __LINE__); + rtw_free_recvframe(precvframe, pfree_recv_queue); + goto _exit_recvbuf2recvframe; + } + + /* Modified by Albert 20101213 */ + /* For 8 bytes IP header alignment. */ + if (pattrib->qos) /* Qos data, wireless lan header length is 26 */ + shift_sz = 6; + else + shift_sz = 0; + + skb_len = pattrib->pkt_len; + + /* for first fragment packet, driver need allocate 1536+drvinfo_sz+RXDESC_SIZE to defrag packet. */ + /* modify alloc_sz for recvive crc error packet by thomas 2011-06-02 */ + if ((pattrib->mfrag == 1) && (pattrib->frag_num == 0)) { + if (skb_len <= 1650) + alloc_sz = 1664; + else + alloc_sz = skb_len + 14; + } else { + alloc_sz = skb_len; + /* 6 is for IP header 8 bytes alignment in QoS packet case. */ + /* 8 is for skb->data 4 bytes alignment. */ + alloc_sz += 14; + } + + pkt_copy = netdev_alloc_skb(adapt->pnetdev, alloc_sz); + if (pkt_copy) { + pkt_copy->dev = adapt->pnetdev; + precvframe->u.hdr.pkt = pkt_copy; + precvframe->u.hdr.rx_head = pkt_copy->data; + precvframe->u.hdr.rx_end = pkt_copy->data + alloc_sz; + skb_reserve(pkt_copy, 8 - ((size_t)(pkt_copy->data) & 7));/* force pkt_copy->data at 8-byte alignment address */ + skb_reserve(pkt_copy, shift_sz);/* force ip_hdr at 8-byte alignment address according to shift_sz. */ + memcpy(pkt_copy->data, (pbuf + pattrib->drvinfo_sz + RXDESC_SIZE), skb_len); + precvframe->u.hdr.rx_tail = pkt_copy->data; + precvframe->u.hdr.rx_data = pkt_copy->data; + } else { + if ((pattrib->mfrag == 1) && (pattrib->frag_num == 0)) { + DBG_88E("recvbuf2recvframe: alloc_skb fail , drop frag frame\n"); + rtw_free_recvframe(precvframe, pfree_recv_queue); + goto _exit_recvbuf2recvframe; + } + precvframe->u.hdr.pkt = skb_clone(pskb, GFP_ATOMIC); + if (precvframe->u.hdr.pkt) { + precvframe->u.hdr.rx_tail = pbuf + pattrib->drvinfo_sz + RXDESC_SIZE; + precvframe->u.hdr.rx_head = precvframe->u.hdr.rx_tail; + precvframe->u.hdr.rx_data = precvframe->u.hdr.rx_tail; + precvframe->u.hdr.rx_end = pbuf + pattrib->drvinfo_sz + RXDESC_SIZE + alloc_sz; + } else { + DBG_88E("recvbuf2recvframe: skb_clone fail\n"); + rtw_free_recvframe(precvframe, pfree_recv_queue); + goto _exit_recvbuf2recvframe; + } + } + + recvframe_put(precvframe, skb_len); + + switch (haldata->UsbRxAggMode) { + case USB_RX_AGG_DMA: + case USB_RX_AGG_MIX: + pkt_offset = (u16)_RND128(pkt_offset); + break; + case USB_RX_AGG_USB: + pkt_offset = (u16)_RND4(pkt_offset); + break; + case USB_RX_AGG_DISABLE: + default: + break; + } + if (pattrib->pkt_rpt_type == NORMAL_RX) { /* Normal rx packet */ + if (pattrib->physt) + update_recvframe_phyinfo_88e(precvframe, (struct phy_stat *)pphy_status); + if (rtw_recv_entry(precvframe) != _SUCCESS) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, + ("recvbuf2recvframe: rtw_recv_entry(precvframe) != _SUCCESS\n")); + } + } else { + /* enqueue recvframe to txrtp queue */ + if (pattrib->pkt_rpt_type == TX_REPORT1) { + /* CCX-TXRPT ack for xmit mgmt frames. */ + handle_txrpt_ccx_88e(adapt, precvframe->u.hdr.rx_data); + } else if (pattrib->pkt_rpt_type == TX_REPORT2) { + ODM_RA_TxRPT2Handle_8188E( + &haldata->odmpriv, + precvframe->u.hdr.rx_data, + pattrib->pkt_len, + pattrib->MacIDValidEntry[0], + pattrib->MacIDValidEntry[1] + ); + } else if (pattrib->pkt_rpt_type == HIS_REPORT) { + interrupt_handler_8188eu(adapt, pattrib->pkt_len, precvframe->u.hdr.rx_data); + } + rtw_free_recvframe(precvframe, pfree_recv_queue); + } + pkt_cnt--; + transfer_len -= pkt_offset; + pbuf += pkt_offset; + precvframe = NULL; + pkt_copy = NULL; + + if (transfer_len > 0 && pkt_cnt == 0) + pkt_cnt = (le32_to_cpu(prxstat->rxdw2)>>16) & 0xff; + + } while ((transfer_len > 0) && (pkt_cnt > 0)); + +_exit_recvbuf2recvframe: + + return _SUCCESS; +} + +void rtl8188eu_recv_tasklet(void *priv) +{ + struct sk_buff *pskb; + struct adapter *adapt = (struct adapter *)priv; + struct recv_priv *precvpriv = &adapt->recvpriv; + + while (NULL != (pskb = skb_dequeue(&precvpriv->rx_skb_queue))) { + if ((adapt->bDriverStopped) || (adapt->bSurpriseRemoved)) { + DBG_88E("recv_tasklet => bDriverStopped or bSurpriseRemoved\n"); + dev_kfree_skb_any(pskb); + break; + } + recvbuf2recvframe(adapt, pskb); + skb_reset_tail_pointer(pskb); + pskb->len = 0; + skb_queue_tail(&precvpriv->free_recv_skb_queue, pskb); + } +} + +static void usb_read_port_complete(struct urb *purb, struct pt_regs *regs) +{ + struct recv_buf *precvbuf = (struct recv_buf *)purb->context; + struct adapter *adapt = (struct adapter *)precvbuf->adapter; + struct recv_priv *precvpriv = &adapt->recvpriv; + + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_read_port_complete!!!\n")); + + precvpriv->rx_pending_cnt--; + + if (adapt->bSurpriseRemoved || adapt->bDriverStopped || adapt->bReadPortCancel) { + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, + ("usb_read_port_complete:bDriverStopped(%d) OR bSurpriseRemoved(%d)\n", + adapt->bDriverStopped, adapt->bSurpriseRemoved)); + + precvbuf->reuse = true; + DBG_88E("%s() RX Warning! bDriverStopped(%d) OR bSurpriseRemoved(%d) bReadPortCancel(%d)\n", + __func__, adapt->bDriverStopped, + adapt->bSurpriseRemoved, adapt->bReadPortCancel); + goto exit; + } + + if (purb->status == 0) { /* SUCCESS */ + if ((purb->actual_length > MAX_RECVBUF_SZ) || (purb->actual_length < RXDESC_SIZE)) { + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, + ("usb_read_port_complete: (purb->actual_length > MAX_RECVBUF_SZ) || (purb->actual_length < RXDESC_SIZE)\n")); + precvbuf->reuse = true; + rtw_read_port(adapt, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf); + DBG_88E("%s()-%d: RX Warning!\n", __func__, __LINE__); + } else { + rtw_reset_continual_urb_error(adapter_to_dvobj(adapt)); + + precvbuf->transfer_len = purb->actual_length; + skb_put(precvbuf->pskb, purb->actual_length); + skb_queue_tail(&precvpriv->rx_skb_queue, precvbuf->pskb); + + if (skb_queue_len(&precvpriv->rx_skb_queue) <= 1) + tasklet_schedule(&precvpriv->recv_tasklet); + + precvbuf->pskb = NULL; + precvbuf->reuse = false; + rtw_read_port(adapt, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf); + } + } else { + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_read_port_complete : purb->status(%d) != 0\n", purb->status)); + + DBG_88E("###=> usb_read_port_complete => urb status(%d)\n", purb->status); + + if (rtw_inc_and_chk_continual_urb_error(adapter_to_dvobj(adapt))) + adapt->bSurpriseRemoved = true; + + switch (purb->status) { + case -EINVAL: + case -EPIPE: + case -ENODEV: + case -ESHUTDOWN: + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_read_port_complete:bSurpriseRemoved=true\n")); + case -ENOENT: + adapt->bDriverStopped = true; + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_read_port_complete:bDriverStopped=true\n")); + break; + case -EPROTO: + case -EOVERFLOW: + { + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + haldata->srestpriv.Wifi_Error_Status = USB_READ_PORT_FAIL; + } + precvbuf->reuse = true; + rtw_read_port(adapt, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf); + break; + case -EINPROGRESS: + DBG_88E("ERROR: URB IS IN PROGRESS!/n"); + break; + default: + break; + } + } + +exit: +_func_exit_; +} + +static u32 usb_read_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem) +{ + struct urb *purb = NULL; + struct recv_buf *precvbuf = (struct recv_buf *)rmem; + struct adapter *adapter = pintfhdl->padapter; + struct dvobj_priv *pdvobj = adapter_to_dvobj(adapter); + struct recv_priv *precvpriv = &adapter->recvpriv; + struct usb_device *pusbd = pdvobj->pusbdev; + int err; + unsigned int pipe; + size_t tmpaddr = 0; + size_t alignment = 0; + u32 ret = _SUCCESS; + +_func_enter_; + + if (adapter->bDriverStopped || adapter->bSurpriseRemoved || + adapter->pwrctrlpriv.pnp_bstop_trx) { + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, + ("usb_read_port:(adapt->bDriverStopped ||adapt->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n")); + return _FAIL; + } + + if ((!precvbuf->reuse) || (precvbuf->pskb == NULL)) { + precvbuf->pskb = skb_dequeue(&precvpriv->free_recv_skb_queue); + if (NULL != precvbuf->pskb) + precvbuf->reuse = true; + } + + if (precvbuf != NULL) { + rtl8188eu_init_recvbuf(adapter, precvbuf); + + /* re-assign for linux based on skb */ + if ((!precvbuf->reuse) || (precvbuf->pskb == NULL)) { + precvbuf->pskb = netdev_alloc_skb(adapter->pnetdev, MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ); + if (precvbuf->pskb == NULL) { + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("init_recvbuf(): alloc_skb fail!\n")); + DBG_88E("#### usb_read_port() alloc_skb fail!#####\n"); + return _FAIL; + } + + tmpaddr = (size_t)precvbuf->pskb->data; + alignment = tmpaddr & (RECVBUFF_ALIGN_SZ-1); + skb_reserve(precvbuf->pskb, (RECVBUFF_ALIGN_SZ - alignment)); + + precvbuf->phead = precvbuf->pskb->head; + precvbuf->pdata = precvbuf->pskb->data; + precvbuf->ptail = skb_tail_pointer(precvbuf->pskb); + precvbuf->pend = skb_end_pointer(precvbuf->pskb); + precvbuf->pbuf = precvbuf->pskb->data; + } else { /* reuse skb */ + precvbuf->phead = precvbuf->pskb->head; + precvbuf->pdata = precvbuf->pskb->data; + precvbuf->ptail = skb_tail_pointer(precvbuf->pskb); + precvbuf->pend = skb_end_pointer(precvbuf->pskb); + precvbuf->pbuf = precvbuf->pskb->data; + + precvbuf->reuse = false; + } + + precvpriv->rx_pending_cnt++; + + purb = precvbuf->purb; + + /* translate DMA FIFO addr to pipehandle */ + pipe = ffaddr2pipehdl(pdvobj, addr); + + usb_fill_bulk_urb(purb, pusbd, pipe, + precvbuf->pbuf, + MAX_RECVBUF_SZ, + usb_read_port_complete, + precvbuf);/* context is precvbuf */ + + err = usb_submit_urb(purb, GFP_ATOMIC); + if ((err) && (err != (-EPERM))) { + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, + ("cannot submit rx in-token(err=0x%.8x), URB_STATUS =0x%.8x", + err, purb->status)); + DBG_88E("cannot submit rx in-token(err = 0x%08x),urb_status = %d\n", + err, purb->status); + ret = _FAIL; + } + } else { + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, + ("usb_read_port:precvbuf ==NULL\n")); + ret = _FAIL; + } + +_func_exit_; + return ret; +} + +void rtl8188eu_xmit_tasklet(void *priv) +{ + int ret = false; + struct adapter *adapt = (struct adapter *)priv; + struct xmit_priv *pxmitpriv = &adapt->xmitpriv; + + if (check_fwstate(&adapt->mlmepriv, _FW_UNDER_SURVEY)) + return; + + while (1) { + if ((adapt->bDriverStopped) || + (adapt->bSurpriseRemoved) || + (adapt->bWritePortCancel)) { + DBG_88E("xmit_tasklet => bDriverStopped or bSurpriseRemoved or bWritePortCancel\n"); + break; + } + + ret = rtl8188eu_xmitframe_complete(adapt, pxmitpriv, NULL); + + if (!ret) + break; + } +} + +void rtl8188eu_set_intf_ops(struct _io_ops *pops) +{ + _func_enter_; + _rtw_memset((u8 *)pops, 0, sizeof(struct _io_ops)); + pops->_read8 = &usb_read8; + pops->_read16 = &usb_read16; + pops->_read32 = &usb_read32; + pops->_read_mem = &usb_read_mem; + pops->_read_port = &usb_read_port; + pops->_write8 = &usb_write8; + pops->_write16 = &usb_write16; + pops->_write32 = &usb_write32; + pops->_writeN = &usb_writeN; + pops->_write_mem = &usb_write_mem; + pops->_write_port = &usb_write_port; + pops->_read_port_cancel = &usb_read_port_cancel; + pops->_write_port_cancel = &usb_write_port_cancel; + _func_exit_; +} + +void rtl8188eu_set_hw_type(struct adapter *adapt) +{ + adapt->chip_type = RTL8188E; + adapt->HardwareType = HARDWARE_TYPE_RTL8188EU; + DBG_88E("CHIP TYPE: RTL8188E\n"); +} -- GitLab From 5adef66acf73705ae95ea0b1e6b5fc7f17d82d30 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 21 Aug 2013 22:34:01 -0500 Subject: [PATCH 777/942] staging: r8188eu: Add files for new driver - part 19 This commit adds files os_dep/os_intfs.c, os_dep/recv_linux.c, and os_dep/rtw_android.c. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/os_intfs.c | 1251 +++++++++++++++++ drivers/staging/rtl8188eu/os_dep/recv_linux.c | 261 ++++ .../staging/rtl8188eu/os_dep/rtw_android.c | 293 ++++ 3 files changed, 1805 insertions(+) create mode 100644 drivers/staging/rtl8188eu/os_dep/os_intfs.c create mode 100644 drivers/staging/rtl8188eu/os_dep/recv_linux.c create mode 100644 drivers/staging/rtl8188eu/os_dep/rtw_android.c diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c new file mode 100644 index 0000000000000..63bc913eba6d8 --- /dev/null +++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c @@ -0,0 +1,1251 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _OS_INTFS_C_ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("Realtek Wireless Lan Driver"); +MODULE_AUTHOR("Realtek Semiconductor Corp."); +MODULE_VERSION(DRIVERVERSION); + +#define CONFIG_BR_EXT_BRNAME "br0" +#define RTW_NOTCH_FILTER 0 /* 0:Disable, 1:Enable, */ + +/* module param defaults */ +static int rtw_chip_version = 0x00; +static int rtw_rfintfs = HWPI; +static int rtw_lbkmode;/* RTL8712_AIR_TRX; */ +static int rtw_network_mode = Ndis802_11IBSS;/* Ndis802_11Infrastructure; infra, ad-hoc, auto */ +static int rtw_channel = 1;/* ad-hoc support requirement */ +static int rtw_wireless_mode = WIRELESS_11BG_24N; +static int rtw_vrtl_carrier_sense = AUTO_VCS; +static int rtw_vcs_type = RTS_CTS;/* */ +static int rtw_rts_thresh = 2347;/* */ +static int rtw_frag_thresh = 2346;/* */ +static int rtw_preamble = PREAMBLE_LONG;/* long, short, auto */ +static int rtw_scan_mode = 1;/* active, passive */ +static int rtw_adhoc_tx_pwr = 1; +static int rtw_soft_ap; +static int rtw_power_mgnt = 1; +static int rtw_ips_mode = IPS_NORMAL; + +static int rtw_smart_ps = 2; + +module_param(rtw_ips_mode, int, 0644); +MODULE_PARM_DESC(rtw_ips_mode, "The default IPS mode"); + +static int rtw_debug = 1; +static int rtw_radio_enable = 1; +static int rtw_long_retry_lmt = 7; +static int rtw_short_retry_lmt = 7; +static int rtw_busy_thresh = 40; +static int rtw_ack_policy = NORMAL_ACK; + +static int rtw_mp_mode; + +static int rtw_software_encrypt; +static int rtw_software_decrypt; + +static int rtw_acm_method;/* 0:By SW 1:By HW. */ + +static int rtw_wmm_enable = 1;/* default is set to enable the wmm. */ +static int rtw_uapsd_enable; +static int rtw_uapsd_max_sp = NO_LIMIT; +static int rtw_uapsd_acbk_en; +static int rtw_uapsd_acbe_en; +static int rtw_uapsd_acvi_en; +static int rtw_uapsd_acvo_en; + +int rtw_ht_enable = 1; +int rtw_cbw40_enable = 3; /* 0 :diable, bit(0): enable 2.4g, bit(1): enable 5g */ +int rtw_ampdu_enable = 1;/* for enable tx_ampdu */ +static int rtw_rx_stbc = 1;/* 0: disable, bit(0):enable 2.4g, bit(1):enable 5g, default is set to enable 2.4GHZ for IOT issue with bufflao's AP at 5GHZ */ +static int rtw_ampdu_amsdu;/* 0: disabled, 1:enabled, 2:auto */ + +static int rtw_lowrate_two_xmit = 1;/* Use 2 path Tx to transmit MCS0~7 and legacy mode */ + +static int rtw_rf_config = RF_819X_MAX_TYPE; /* auto */ +static int rtw_low_power; +static int rtw_wifi_spec; +static int rtw_channel_plan = RT_CHANNEL_DOMAIN_MAX; +static int rtw_AcceptAddbaReq = true;/* 0:Reject AP's Add BA req, 1:Accept AP's Add BA req. */ + +static int rtw_antdiv_cfg = 2; /* 0:OFF , 1:ON, 2:decide by Efuse config */ +static int rtw_antdiv_type; /* 0:decide by efuse 1: for 88EE, 1Tx and 1RxCG are diversity.(2 Ant with SPDT), 2: for 88EE, 1Tx and 2Rx are diversity.(2 Ant, Tx and RxCG are both on aux port, RxCS is on main port), 3: for 88EE, 1Tx and 1RxCG are fixed.(1Ant, Tx and RxCG are both on aux port) */ + +static int rtw_enusbss;/* 0:disable, 1:enable */ + +static int rtw_hwpdn_mode = 2;/* 0:disable, 1:enable, 2: by EFUSE config */ + +static int rtw_hwpwrp_detect; /* HW power ping detect 0:disable , 1:enable */ + +static int rtw_hw_wps_pbc = 1; + +int rtw_mc2u_disable; + +static int rtw_80211d; + +static char *ifname = "wlan%d"; +module_param(ifname, charp, 0644); +MODULE_PARM_DESC(ifname, "The default name to allocate for first interface"); + +static char *if2name = "wlan%d"; +module_param(if2name, charp, 0644); +MODULE_PARM_DESC(if2name, "The default name to allocate for second interface"); + +char *rtw_initmac; /* temp mac address if users want to use instead of the mac address in Efuse */ + +module_param(rtw_initmac, charp, 0644); +module_param(rtw_channel_plan, int, 0644); +module_param(rtw_chip_version, int, 0644); +module_param(rtw_rfintfs, int, 0644); +module_param(rtw_lbkmode, int, 0644); +module_param(rtw_network_mode, int, 0644); +module_param(rtw_channel, int, 0644); +module_param(rtw_mp_mode, int, 0644); +module_param(rtw_wmm_enable, int, 0644); +module_param(rtw_vrtl_carrier_sense, int, 0644); +module_param(rtw_vcs_type, int, 0644); +module_param(rtw_busy_thresh, int, 0644); +module_param(rtw_ht_enable, int, 0644); +module_param(rtw_cbw40_enable, int, 0644); +module_param(rtw_ampdu_enable, int, 0644); +module_param(rtw_rx_stbc, int, 0644); +module_param(rtw_ampdu_amsdu, int, 0644); +module_param(rtw_lowrate_two_xmit, int, 0644); +module_param(rtw_rf_config, int, 0644); +module_param(rtw_power_mgnt, int, 0644); +module_param(rtw_smart_ps, int, 0644); +module_param(rtw_low_power, int, 0644); +module_param(rtw_wifi_spec, int, 0644); +module_param(rtw_antdiv_cfg, int, 0644); +module_param(rtw_antdiv_type, int, 0644); +module_param(rtw_enusbss, int, 0644); +module_param(rtw_hwpdn_mode, int, 0644); +module_param(rtw_hwpwrp_detect, int, 0644); +module_param(rtw_hw_wps_pbc, int, 0644); + +static uint rtw_max_roaming_times = 2; +module_param(rtw_max_roaming_times, uint, 0644); +MODULE_PARM_DESC(rtw_max_roaming_times, "The max roaming times to try"); + +static int rtw_fw_iol = 1;/* 0:Disable, 1:enable, 2:by usb speed */ +module_param(rtw_fw_iol, int, 0644); +MODULE_PARM_DESC(rtw_fw_iol, "FW IOL"); + +module_param(rtw_mc2u_disable, int, 0644); + +module_param(rtw_80211d, int, 0644); +MODULE_PARM_DESC(rtw_80211d, "Enable 802.11d mechanism"); + +static uint rtw_notch_filter = RTW_NOTCH_FILTER; +module_param(rtw_notch_filter, uint, 0644); +MODULE_PARM_DESC(rtw_notch_filter, "0:Disable, 1:Enable, 2:Enable only for P2P"); +module_param_named(debug, rtw_debug, int, 0444); +MODULE_PARM_DESC(debug, "Set debug level (1-9) (default 1)"); + +/* dummy routines */ +void rtw_proc_remove_one(struct net_device *dev) +{ +} + +void rtw_proc_init_one(struct net_device *dev) +{ +} + +#if 0 /* TODO: Convert these to /sys */ +void rtw_proc_init_one(struct net_device *dev) +{ + struct proc_dir_entry *dir_dev = NULL; + struct proc_dir_entry *entry = NULL; + struct adapter *padapter = rtw_netdev_priv(dev); + u8 rf_type; + + if (rtw_proc == NULL) { + memcpy(rtw_proc_name, DRV_NAME, sizeof(DRV_NAME)); + + rtw_proc = create_proc_entry(rtw_proc_name, S_IFDIR, init_net.proc_net); + if (rtw_proc == NULL) { + DBG_88E(KERN_ERR "Unable to create rtw_proc directory\n"); + return; + } + + entry = create_proc_read_entry("ver_info", S_IFREG | S_IRUGO, rtw_proc, proc_get_drv_version, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + } + + if (padapter->dir_dev == NULL) { + padapter->dir_dev = create_proc_entry(dev->name, + S_IFDIR | S_IRUGO | S_IXUGO, + rtw_proc); + dir_dev = padapter->dir_dev; + if (dir_dev == NULL) { + if (rtw_proc_cnt == 0) { + if (rtw_proc) { + remove_proc_entry(rtw_proc_name, init_net.proc_net); + rtw_proc = NULL; + } + } + + pr_info("Unable to create dir_dev directory\n"); + return; + } + } else { + return; + } + + rtw_proc_cnt++; + + entry = create_proc_read_entry("write_reg", S_IFREG | S_IRUGO, + dir_dev, proc_get_write_reg, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + entry->write_proc = proc_set_write_reg; + + entry = create_proc_read_entry("read_reg", S_IFREG | S_IRUGO, + dir_dev, proc_get_read_reg, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + entry->write_proc = proc_set_read_reg; + + + entry = create_proc_read_entry("fwstate", S_IFREG | S_IRUGO, + dir_dev, proc_get_fwstate, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + + entry = create_proc_read_entry("sec_info", S_IFREG | S_IRUGO, + dir_dev, proc_get_sec_info, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + + entry = create_proc_read_entry("mlmext_state", S_IFREG | S_IRUGO, + dir_dev, proc_get_mlmext_state, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + + entry = create_proc_read_entry("qos_option", S_IFREG | S_IRUGO, + dir_dev, proc_get_qos_option, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + + entry = create_proc_read_entry("ht_option", S_IFREG | S_IRUGO, + dir_dev, proc_get_ht_option, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + + entry = create_proc_read_entry("rf_info", S_IFREG | S_IRUGO, + dir_dev, proc_get_rf_info, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + + entry = create_proc_read_entry("ap_info", S_IFREG | S_IRUGO, + dir_dev, proc_get_ap_info, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + + entry = create_proc_read_entry("adapter_state", S_IFREG | S_IRUGO, + dir_dev, proc_getstruct adapter_state, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + + entry = create_proc_read_entry("trx_info", S_IFREG | S_IRUGO, + dir_dev, proc_get_trx_info, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + + entry = create_proc_read_entry("mac_reg_dump1", S_IFREG | S_IRUGO, + dir_dev, proc_get_mac_reg_dump1, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + + entry = create_proc_read_entry("mac_reg_dump2", S_IFREG | S_IRUGO, + dir_dev, proc_get_mac_reg_dump2, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + + entry = create_proc_read_entry("mac_reg_dump3", S_IFREG | S_IRUGO, + dir_dev, proc_get_mac_reg_dump3, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + + entry = create_proc_read_entry("bb_reg_dump1", S_IFREG | S_IRUGO, + dir_dev, proc_get_bb_reg_dump1, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + + entry = create_proc_read_entry("bb_reg_dump2", S_IFREG | S_IRUGO, + dir_dev, proc_get_bb_reg_dump2, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + + entry = create_proc_read_entry("bb_reg_dump3", S_IFREG | S_IRUGO, + dir_dev, proc_get_bb_reg_dump3, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + + entry = create_proc_read_entry("rf_reg_dump1", S_IFREG | S_IRUGO, + dir_dev, proc_get_rf_reg_dump1, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + + entry = create_proc_read_entry("rf_reg_dump2", S_IFREG | S_IRUGO, + dir_dev, proc_get_rf_reg_dump2, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + + rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); + if ((RF_1T2R == rf_type) || (RF_1T1R == rf_type)) { + entry = create_proc_read_entry("rf_reg_dump3", S_IFREG | S_IRUGO, + dir_dev, proc_get_rf_reg_dump3, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + + entry = create_proc_read_entry("rf_reg_dump4", S_IFREG | S_IRUGO, + dir_dev, proc_get_rf_reg_dump4, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + } + +#ifdef CONFIG_88EU_AP_MODE + + entry = create_proc_read_entry("all_sta_info", S_IFREG | S_IRUGO, + dir_dev, proc_get_all_sta_info, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } +#endif + + entry = create_proc_read_entry("best_channel", S_IFREG | S_IRUGO, + dir_dev, proc_get_best_channel, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + + entry = create_proc_read_entry("rx_signal", S_IFREG | S_IRUGO, + dir_dev, proc_get_rx_signal, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + entry->write_proc = proc_set_rx_signal; + entry = create_proc_read_entry("ht_enable", S_IFREG | S_IRUGO, + dir_dev, proc_get_ht_enable, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + entry->write_proc = proc_set_ht_enable; + + entry = create_proc_read_entry("cbw40_enable", S_IFREG | S_IRUGO, + dir_dev, proc_get_cbw40_enable, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + entry->write_proc = proc_set_cbw40_enable; + + entry = create_proc_read_entry("ampdu_enable", S_IFREG | S_IRUGO, + dir_dev, proc_get_ampdu_enable, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + entry->write_proc = proc_set_ampdu_enable; + + entry = create_proc_read_entry("rx_stbc", S_IFREG | S_IRUGO, + dir_dev, proc_get_rx_stbc, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + entry->write_proc = proc_set_rx_stbc; + + entry = create_proc_read_entry("path_rssi", S_IFREG | S_IRUGO, + dir_dev, proc_get_two_path_rssi, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + entry = create_proc_read_entry("rssi_disp", S_IFREG | S_IRUGO, + dir_dev, proc_get_rssi_disp, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + entry->write_proc = proc_set_rssi_disp; +} + +void rtw_proc_remove_one(struct net_device *dev) +{ + struct proc_dir_entry *dir_dev = NULL; + struct adapter *padapter = rtw_netdev_priv(dev); + u8 rf_type; + + dir_dev = padapter->dir_dev; + padapter->dir_dev = NULL; + + if (dir_dev) { + remove_proc_entry("write_reg", dir_dev); + remove_proc_entry("read_reg", dir_dev); + remove_proc_entry("fwstate", dir_dev); + remove_proc_entry("sec_info", dir_dev); + remove_proc_entry("mlmext_state", dir_dev); + remove_proc_entry("qos_option", dir_dev); + remove_proc_entry("ht_option", dir_dev); + remove_proc_entry("rf_info", dir_dev); + remove_proc_entry("ap_info", dir_dev); + remove_proc_entry("adapter_state", dir_dev); + remove_proc_entry("trx_info", dir_dev); + remove_proc_entry("mac_reg_dump1", dir_dev); + remove_proc_entry("mac_reg_dump2", dir_dev); + remove_proc_entry("mac_reg_dump3", dir_dev); + remove_proc_entry("bb_reg_dump1", dir_dev); + remove_proc_entry("bb_reg_dump2", dir_dev); + remove_proc_entry("bb_reg_dump3", dir_dev); + remove_proc_entry("rf_reg_dump1", dir_dev); + remove_proc_entry("rf_reg_dump2", dir_dev); + rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); + if ((RF_1T2R == rf_type) || (RF_1T1R == rf_type)) { + remove_proc_entry("rf_reg_dump3", dir_dev); + remove_proc_entry("rf_reg_dump4", dir_dev); + } +#ifdef CONFIG_88EU_AP_MODE + remove_proc_entry("all_sta_info", dir_dev); +#endif + + remove_proc_entry("best_channel", dir_dev); + remove_proc_entry("rx_signal", dir_dev); + remove_proc_entry("cbw40_enable", dir_dev); + remove_proc_entry("ht_enable", dir_dev); + remove_proc_entry("ampdu_enable", dir_dev); + remove_proc_entry("rx_stbc", dir_dev); + remove_proc_entry("path_rssi", dir_dev); + remove_proc_entry("rssi_disp", dir_dev); + remove_proc_entry(dev->name, rtw_proc); + dir_dev = NULL; + } else { + return; + } + rtw_proc_cnt--; + + if (rtw_proc_cnt == 0) { + if (rtw_proc) { + remove_proc_entry("ver_info", rtw_proc); + + remove_proc_entry(rtw_proc_name, init_net.proc_net); + rtw_proc = NULL; + } + } +} +#endif + +static uint loadparam(struct adapter *padapter, struct net_device *pnetdev) +{ + uint status = _SUCCESS; + struct registry_priv *registry_par = &padapter->registrypriv; + +_func_enter_; + + GlobalDebugLevel = rtw_debug; + registry_par->chip_version = (u8)rtw_chip_version; + registry_par->rfintfs = (u8)rtw_rfintfs; + registry_par->lbkmode = (u8)rtw_lbkmode; + registry_par->network_mode = (u8)rtw_network_mode; + + memcpy(registry_par->ssid.Ssid, "ANY", 3); + registry_par->ssid.SsidLength = 3; + + registry_par->channel = (u8)rtw_channel; + registry_par->wireless_mode = (u8)rtw_wireless_mode; + registry_par->vrtl_carrier_sense = (u8)rtw_vrtl_carrier_sense ; + registry_par->vcs_type = (u8)rtw_vcs_type; + registry_par->rts_thresh = (u16)rtw_rts_thresh; + registry_par->frag_thresh = (u16)rtw_frag_thresh; + registry_par->preamble = (u8)rtw_preamble; + registry_par->scan_mode = (u8)rtw_scan_mode; + registry_par->adhoc_tx_pwr = (u8)rtw_adhoc_tx_pwr; + registry_par->soft_ap = (u8)rtw_soft_ap; + registry_par->smart_ps = (u8)rtw_smart_ps; + registry_par->power_mgnt = (u8)rtw_power_mgnt; + registry_par->ips_mode = (u8)rtw_ips_mode; + registry_par->radio_enable = (u8)rtw_radio_enable; + registry_par->long_retry_lmt = (u8)rtw_long_retry_lmt; + registry_par->short_retry_lmt = (u8)rtw_short_retry_lmt; + registry_par->busy_thresh = (u16)rtw_busy_thresh; + registry_par->ack_policy = (u8)rtw_ack_policy; + registry_par->mp_mode = (u8)rtw_mp_mode; + registry_par->software_encrypt = (u8)rtw_software_encrypt; + registry_par->software_decrypt = (u8)rtw_software_decrypt; + registry_par->acm_method = (u8)rtw_acm_method; + + /* UAPSD */ + registry_par->wmm_enable = (u8)rtw_wmm_enable; + registry_par->uapsd_enable = (u8)rtw_uapsd_enable; + registry_par->uapsd_max_sp = (u8)rtw_uapsd_max_sp; + registry_par->uapsd_acbk_en = (u8)rtw_uapsd_acbk_en; + registry_par->uapsd_acbe_en = (u8)rtw_uapsd_acbe_en; + registry_par->uapsd_acvi_en = (u8)rtw_uapsd_acvi_en; + registry_par->uapsd_acvo_en = (u8)rtw_uapsd_acvo_en; + + registry_par->ht_enable = (u8)rtw_ht_enable; + registry_par->cbw40_enable = (u8)rtw_cbw40_enable; + registry_par->ampdu_enable = (u8)rtw_ampdu_enable; + registry_par->rx_stbc = (u8)rtw_rx_stbc; + registry_par->ampdu_amsdu = (u8)rtw_ampdu_amsdu; + registry_par->lowrate_two_xmit = (u8)rtw_lowrate_two_xmit; + registry_par->rf_config = (u8)rtw_rf_config; + registry_par->low_power = (u8)rtw_low_power; + registry_par->wifi_spec = (u8)rtw_wifi_spec; + registry_par->channel_plan = (u8)rtw_channel_plan; + registry_par->bAcceptAddbaReq = (u8)rtw_AcceptAddbaReq; + registry_par->antdiv_cfg = (u8)rtw_antdiv_cfg; + registry_par->antdiv_type = (u8)rtw_antdiv_type; + registry_par->hwpdn_mode = (u8)rtw_hwpdn_mode;/* 0:disable, 1:enable, 2:by EFUSE config */ + registry_par->hwpwrp_detect = (u8)rtw_hwpwrp_detect;/* 0:disable, 1:enable */ + registry_par->hw_wps_pbc = (u8)rtw_hw_wps_pbc; + + registry_par->max_roaming_times = (u8)rtw_max_roaming_times; + + registry_par->fw_iol = rtw_fw_iol; + + registry_par->enable80211d = (u8)rtw_80211d; + snprintf(registry_par->ifname, 16, "%s", ifname); + snprintf(registry_par->if2name, 16, "%s", if2name); + registry_par->notch_filter = (u8)rtw_notch_filter; +_func_exit_; + return status; +} + +static int rtw_net_set_mac_address(struct net_device *pnetdev, void *p) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev); + struct sockaddr *addr = p; + + if (!padapter->bup) + memcpy(padapter->eeprompriv.mac_addr, addr->sa_data, ETH_ALEN); + + return 0; +} + +static struct net_device_stats *rtw_net_get_stats(struct net_device *pnetdev) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev); + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct recv_priv *precvpriv = &(padapter->recvpriv); + + padapter->stats.tx_packets = pxmitpriv->tx_pkts;/* pxmitpriv->tx_pkts++; */ + padapter->stats.rx_packets = precvpriv->rx_pkts;/* precvpriv->rx_pkts++; */ + padapter->stats.tx_dropped = pxmitpriv->tx_drop; + padapter->stats.rx_dropped = precvpriv->rx_drop; + padapter->stats.tx_bytes = pxmitpriv->tx_bytes; + padapter->stats.rx_bytes = precvpriv->rx_bytes; + return &padapter->stats; +} + +/* + * AC to queue mapping + * + * AC_VO -> queue 0 + * AC_VI -> queue 1 + * AC_BE -> queue 2 + * AC_BK -> queue 3 + */ +static const u16 rtw_1d_to_queue[8] = { 2, 3, 3, 2, 1, 1, 0, 0 }; + +/* Given a data frame determine the 802.1p/1d tag to use. */ +static unsigned int rtw_classify8021d(struct sk_buff *skb) +{ + unsigned int dscp; + + /* skb->priority values from 256->263 are magic values to + * directly indicate a specific 802.1d priority. This is used + * to allow 802.1d priority to be passed directly in from VLAN + * tags, etc. + */ + if (skb->priority >= 256 && skb->priority <= 263) + return skb->priority - 256; + + switch (skb->protocol) { + case htons(ETH_P_IP): + dscp = ip_hdr(skb)->tos & 0xfc; + break; + default: + return 0; + } + + return dscp >> 5; +} + +static u16 rtw_select_queue(struct net_device *dev, struct sk_buff *skb) +{ + struct adapter *padapter = rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + + skb->priority = rtw_classify8021d(skb); + + if (pmlmepriv->acm_mask != 0) + skb->priority = qos_acm(pmlmepriv->acm_mask, skb->priority); + + return rtw_1d_to_queue[skb->priority]; +} + +u16 rtw_recv_select_queue(struct sk_buff *skb) +{ + struct iphdr *piphdr; + unsigned int dscp; + __be16 eth_type; + u32 priority; + u8 *pdata = skb->data; + + memcpy(ð_type, pdata+(ETH_ALEN<<1), 2); + + switch (eth_type) { + case htons(ETH_P_IP): + piphdr = (struct iphdr *)(pdata+ETH_HLEN); + dscp = piphdr->tos & 0xfc; + priority = dscp >> 5; + break; + default: + priority = 0; + } + + return rtw_1d_to_queue[priority]; +} + +static const struct net_device_ops rtw_netdev_ops = { + .ndo_open = netdev_open, + .ndo_stop = netdev_close, + .ndo_start_xmit = rtw_xmit_entry, + .ndo_select_queue = rtw_select_queue, + .ndo_set_mac_address = rtw_net_set_mac_address, + .ndo_get_stats = rtw_net_get_stats, + .ndo_do_ioctl = rtw_ioctl, +}; + +int rtw_init_netdev_name(struct net_device *pnetdev, const char *ifname) +{ + if (dev_alloc_name(pnetdev, ifname) < 0) + RT_TRACE(_module_os_intfs_c_, _drv_err_, ("dev_alloc_name, fail!\n")); + + netif_carrier_off(pnetdev); + return 0; +} + +struct net_device *rtw_init_netdev(struct adapter *old_padapter) +{ + struct adapter *padapter; + struct net_device *pnetdev; + + RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+init_net_dev\n")); + + if (old_padapter != NULL) + pnetdev = rtw_alloc_etherdev_with_old_priv(sizeof(struct adapter), (void *)old_padapter); + else + pnetdev = rtw_alloc_etherdev(sizeof(struct adapter)); + + if (!pnetdev) + return NULL; + + padapter = rtw_netdev_priv(pnetdev); + padapter->pnetdev = pnetdev; + DBG_88E("register rtw_netdev_ops to netdev_ops\n"); + pnetdev->netdev_ops = &rtw_netdev_ops; + pnetdev->watchdog_timeo = HZ*3; /* 3 second timeout */ + pnetdev->wireless_handlers = (struct iw_handler_def *)&rtw_handlers_def; + + /* step 2. */ + loadparam(padapter, pnetdev); + + return pnetdev; +} + +u32 rtw_start_drv_threads(struct adapter *padapter) +{ + u32 _status = _SUCCESS; + + RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+rtw_start_drv_threads\n")); + + padapter->cmdThread = kthread_run(rtw_cmd_thread, padapter, "RTW_CMD_THREAD"); + if (IS_ERR(padapter->cmdThread)) + _status = _FAIL; + else + _rtw_down_sema(&padapter->cmdpriv.terminate_cmdthread_sema); /* wait for cmd_thread to run */ + + rtw_hal_start_thread(padapter); + return _status; +} + +void rtw_stop_drv_threads(struct adapter *padapter) +{ + RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+rtw_stop_drv_threads\n")); + + /* Below is to termindate rtw_cmd_thread & event_thread... */ + _rtw_up_sema(&padapter->cmdpriv.cmd_queue_sema); + if (padapter->cmdThread) + _rtw_down_sema(&padapter->cmdpriv.terminate_cmdthread_sema); + + rtw_hal_stop_thread(padapter); +} + +static u8 rtw_init_default_value(struct adapter *padapter) +{ + u8 ret = _SUCCESS; + struct registry_priv *pregistrypriv = &padapter->registrypriv; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct security_priv *psecuritypriv = &padapter->securitypriv; + + /* xmit_priv */ + pxmitpriv->vcs_setting = pregistrypriv->vrtl_carrier_sense; + pxmitpriv->vcs = pregistrypriv->vcs_type; + pxmitpriv->vcs_type = pregistrypriv->vcs_type; + pxmitpriv->frag_len = pregistrypriv->frag_thresh; + + /* mlme_priv */ + pmlmepriv->scan_interval = SCAN_INTERVAL;/* 30*2 sec = 60sec */ + pmlmepriv->scan_mode = SCAN_ACTIVE; + + /* ht_priv */ + pmlmepriv->htpriv.ampdu_enable = false;/* set to disabled */ + + /* security_priv */ + psecuritypriv->binstallGrpkey = _FAIL; + psecuritypriv->sw_encrypt = pregistrypriv->software_encrypt; + psecuritypriv->sw_decrypt = pregistrypriv->software_decrypt; + psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */ + psecuritypriv->dot11PrivacyAlgrthm = _NO_PRIVACY_; + psecuritypriv->dot11PrivacyKeyIndex = 0; + psecuritypriv->dot118021XGrpPrivacy = _NO_PRIVACY_; + psecuritypriv->dot118021XGrpKeyid = 1; + psecuritypriv->ndisauthtype = Ndis802_11AuthModeOpen; + psecuritypriv->ndisencryptstatus = Ndis802_11WEPDisabled; + + /* registry_priv */ + rtw_init_registrypriv_dev_network(padapter); + rtw_update_registrypriv_dev_network(padapter); + + /* hal_priv */ + rtw_hal_def_value_init(padapter); + + /* misc. */ + padapter->bReadPortCancel = false; + padapter->bWritePortCancel = false; + padapter->bRxRSSIDisplay = 0; + padapter->bNotifyChannelChange = 0; +#ifdef CONFIG_88EU_P2P + padapter->bShowGetP2PState = 1; +#endif + return ret; +} + +u8 rtw_reset_drv_sw(struct adapter *padapter) +{ + u8 ret8 = _SUCCESS; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv; + + /* hal_priv */ + rtw_hal_def_value_init(padapter); + padapter->bReadPortCancel = false; + padapter->bWritePortCancel = false; + padapter->bRxRSSIDisplay = 0; + pmlmepriv->scan_interval = SCAN_INTERVAL;/* 30*2 sec = 60sec */ + + padapter->xmitpriv.tx_pkts = 0; + padapter->recvpriv.rx_pkts = 0; + + pmlmepriv->LinkDetectInfo.bBusyTraffic = false; + + _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY | _FW_UNDER_LINKING); + + rtw_hal_sreset_reset_value(padapter); + pwrctrlpriv->pwr_state_check_cnts = 0; + + /* mlmeextpriv */ + padapter->mlmeextpriv.sitesurvey_res.state = SCAN_DISABLE; + + rtw_set_signal_stat_timer(&padapter->recvpriv); + + return ret8; +} + +u8 rtw_init_drv_sw(struct adapter *padapter) +{ + u8 ret8 = _SUCCESS; + +_func_enter_; + + RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+rtw_init_drv_sw\n")); + + if ((rtw_init_cmd_priv(&padapter->cmdpriv)) == _FAIL) { + RT_TRACE(_module_os_intfs_c_, _drv_err_, ("\n Can't init cmd_priv\n")); + ret8 = _FAIL; + goto exit; + } + + padapter->cmdpriv.padapter = padapter; + + if ((rtw_init_evt_priv(&padapter->evtpriv)) == _FAIL) { + RT_TRACE(_module_os_intfs_c_, _drv_err_, ("\n Can't init evt_priv\n")); + ret8 = _FAIL; + goto exit; + } + + if (rtw_init_mlme_priv(padapter) == _FAIL) { + RT_TRACE(_module_os_intfs_c_, _drv_err_, ("\n Can't init mlme_priv\n")); + ret8 = _FAIL; + goto exit; + } + +#ifdef CONFIG_88EU_P2P + rtw_init_wifidirect_timers(padapter); + init_wifidirect_info(padapter, P2P_ROLE_DISABLE); + reset_global_wifidirect_info(padapter); +#endif /* CONFIG_88EU_P2P */ + + if (init_mlme_ext_priv(padapter) == _FAIL) { + RT_TRACE(_module_os_intfs_c_, _drv_err_, ("\n Can't init mlme_ext_priv\n")); + ret8 = _FAIL; + goto exit; + } + + if (_rtw_init_xmit_priv(&padapter->xmitpriv, padapter) == _FAIL) { + DBG_88E("Can't _rtw_init_xmit_priv\n"); + ret8 = _FAIL; + goto exit; + } + + if (_rtw_init_recv_priv(&padapter->recvpriv, padapter) == _FAIL) { + DBG_88E("Can't _rtw_init_recv_priv\n"); + ret8 = _FAIL; + goto exit; + } + + if (_rtw_init_sta_priv(&padapter->stapriv) == _FAIL) { + DBG_88E("Can't _rtw_init_sta_priv\n"); + ret8 = _FAIL; + goto exit; + } + + padapter->stapriv.padapter = padapter; + + rtw_init_bcmc_stainfo(padapter); + + rtw_init_pwrctrl_priv(padapter); + + if (init_mp_priv(padapter) == _FAIL) + DBG_88E("%s: initialize MP private data Fail!\n", __func__); + + ret8 = rtw_init_default_value(padapter); + + rtw_hal_dm_init(padapter); + rtw_hal_sw_led_init(padapter); + + rtw_hal_sreset_init(padapter); + + _rtw_spinlock_init(&padapter->br_ext_lock); + +exit: + RT_TRACE(_module_os_intfs_c_, _drv_info_, ("-rtw_init_drv_sw\n")); + + _func_exit_; + + return ret8; +} + +void rtw_cancel_all_timer(struct adapter *padapter) +{ + RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+rtw_cancel_all_timer\n")); + + _cancel_timer_ex(&padapter->mlmepriv.assoc_timer); + RT_TRACE(_module_os_intfs_c_, _drv_info_, ("rtw_cancel_all_timer:cancel association timer complete!\n")); + + _cancel_timer_ex(&padapter->mlmepriv.scan_to_timer); + RT_TRACE(_module_os_intfs_c_, _drv_info_, ("rtw_cancel_all_timer:cancel scan_to_timer!\n")); + + _cancel_timer_ex(&padapter->mlmepriv.dynamic_chk_timer); + RT_TRACE(_module_os_intfs_c_, _drv_info_, ("rtw_cancel_all_timer:cancel dynamic_chk_timer!\n")); + + /* cancel sw led timer */ + rtw_hal_sw_led_deinit(padapter); + RT_TRACE(_module_os_intfs_c_, _drv_info_, ("rtw_cancel_all_timer:cancel DeInitSwLeds!\n")); + + _cancel_timer_ex(&padapter->pwrctrlpriv.pwr_state_check_timer); + + _cancel_timer_ex(&padapter->recvpriv.signal_stat_timer); + /* cancel dm timer */ + rtw_hal_dm_deinit(padapter); +} + +u8 rtw_free_drv_sw(struct adapter *padapter) +{ + RT_TRACE(_module_os_intfs_c_, _drv_info_, ("==>rtw_free_drv_sw")); + + /* we can call rtw_p2p_enable here, but: */ + /* 1. rtw_p2p_enable may have IO operation */ + /* 2. rtw_p2p_enable is bundled with wext interface */ + #ifdef CONFIG_88EU_P2P + { + struct wifidirect_info *pwdinfo = &padapter->wdinfo; + if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { + _cancel_timer_ex(&pwdinfo->find_phase_timer); + _cancel_timer_ex(&pwdinfo->restore_p2p_state_timer); + _cancel_timer_ex(&pwdinfo->pre_tx_scan_timer); + rtw_p2p_set_state(pwdinfo, P2P_STATE_NONE); + } + } + #endif + + + _rtw_spinlock_free(&padapter->br_ext_lock); + + free_mlme_ext_priv(&padapter->mlmeextpriv); + + rtw_free_cmd_priv(&padapter->cmdpriv); + + rtw_free_evt_priv(&padapter->evtpriv); + + rtw_free_mlme_priv(&padapter->mlmepriv); + _rtw_free_xmit_priv(&padapter->xmitpriv); + + _rtw_free_sta_priv(&padapter->stapriv); /* will free bcmc_stainfo here */ + + _rtw_free_recv_priv(&padapter->recvpriv); + + rtw_free_pwrctrl_priv(padapter); + + rtw_hal_free_data(padapter); + + RT_TRACE(_module_os_intfs_c_, _drv_info_, ("<== rtw_free_drv_sw\n")); + + /* free the old_pnetdev */ + if (padapter->rereg_nd_name_priv.old_pnetdev) { + free_netdev(padapter->rereg_nd_name_priv.old_pnetdev); + padapter->rereg_nd_name_priv.old_pnetdev = NULL; + } + + /* clear pbuddystruct adapter to avoid access wrong pointer. */ + if (padapter->pbuddy_adapter != NULL) + padapter->pbuddy_adapter->pbuddy_adapter = NULL; + + RT_TRACE(_module_os_intfs_c_, _drv_info_, ("-rtw_free_drv_sw\n")); + + return _SUCCESS; +} + +void netdev_br_init(struct net_device *netdev) +{ + struct adapter *adapter = (struct adapter *)rtw_netdev_priv(netdev); + + rcu_read_lock(); + + if (rcu_dereference(adapter->pnetdev->rx_handler_data)) { + struct net_device *br_netdev; + struct net *devnet = NULL; + + devnet = dev_net(netdev); + br_netdev = dev_get_by_name(devnet, CONFIG_BR_EXT_BRNAME); + if (br_netdev) { + memcpy(adapter->br_mac, br_netdev->dev_addr, ETH_ALEN); + dev_put(br_netdev); + } else { + pr_info("%s()-%d: dev_get_by_name(%s) failed!", + __func__, __LINE__, CONFIG_BR_EXT_BRNAME); + } + } + adapter->ethBrExtInfo.addPPPoETag = 1; + + rcu_read_unlock(); +} + +int _netdev_open(struct net_device *pnetdev) +{ + uint status; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev); + struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv; + + RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+88eu_drv - dev_open\n")); + DBG_88E("+88eu_drv - drv_open, bup =%d\n", padapter->bup); + + if (pwrctrlpriv->ps_flag) { + padapter->net_closed = false; + goto netdev_open_normal_process; + } + + if (!padapter->bup) { + padapter->bDriverStopped = false; + padapter->bSurpriseRemoved = false; + padapter->bCardDisableWOHSM = false; + + status = rtw_hal_init(padapter); + if (status == _FAIL) { + RT_TRACE(_module_os_intfs_c_, _drv_err_, ("rtl88eu_hal_init(): Can't init h/w!\n")); + goto netdev_open_error; + } + + pr_info("MAC Address = %pM\n", pnetdev->dev_addr); + + status = rtw_start_drv_threads(padapter); + if (status == _FAIL) { + pr_info("Initialize driver software resource Failed!\n"); + goto netdev_open_error; + } + + if (init_hw_mlme_ext(padapter) == _FAIL) { + pr_info("can't init mlme_ext_priv\n"); + goto netdev_open_error; + } + if (padapter->intf_start) + padapter->intf_start(padapter); + rtw_proc_init_one(pnetdev); + + rtw_led_control(padapter, LED_CTL_NO_LINK); + + padapter->bup = true; + } + padapter->net_closed = false; + + _set_timer(&padapter->mlmepriv.dynamic_chk_timer, 2000); + + padapter->pwrctrlpriv.bips_processing = false; + rtw_set_pwr_state_check_timer(&padapter->pwrctrlpriv); + + if (!rtw_netif_queue_stopped(pnetdev)) + rtw_netif_start_queue(pnetdev); + else + rtw_netif_wake_queue(pnetdev); + + netdev_br_init(pnetdev); + +netdev_open_normal_process: + RT_TRACE(_module_os_intfs_c_, _drv_info_, ("-88eu_drv - dev_open\n")); + DBG_88E("-88eu_drv - drv_open, bup =%d\n", padapter->bup); + return 0; + +netdev_open_error: + padapter->bup = false; + netif_carrier_off(pnetdev); + rtw_netif_stop_queue(pnetdev); + RT_TRACE(_module_os_intfs_c_, _drv_err_, ("-88eu_drv - dev_open, fail!\n")); + DBG_88E("-88eu_drv - drv_open fail, bup =%d\n", padapter->bup); + return -1; +} + +int netdev_open(struct net_device *pnetdev) +{ + int ret; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev); + + _enter_critical_mutex(padapter->hw_init_mutex, NULL); + ret = _netdev_open(pnetdev); + _exit_critical_mutex(padapter->hw_init_mutex, NULL); + return ret; +} + +static int ips_netdrv_open(struct adapter *padapter) +{ + int status = _SUCCESS; + padapter->net_closed = false; + DBG_88E("===> %s.........\n", __func__); + + padapter->bDriverStopped = false; + padapter->bSurpriseRemoved = false; + padapter->bCardDisableWOHSM = false; + + status = rtw_hal_init(padapter); + if (status == _FAIL) { + RT_TRACE(_module_os_intfs_c_, _drv_err_, ("ips_netdrv_open(): Can't init h/w!\n")); + goto netdev_open_error; + } + + if (padapter->intf_start) + padapter->intf_start(padapter); + + rtw_set_pwr_state_check_timer(&padapter->pwrctrlpriv); + _set_timer(&padapter->mlmepriv.dynamic_chk_timer, 5000); + + return _SUCCESS; + +netdev_open_error: + DBG_88E("-ips_netdrv_open - drv_open failure, bup =%d\n", padapter->bup); + + return _FAIL; +} + + +int rtw_ips_pwr_up(struct adapter *padapter) +{ + int result; + u32 start_time = rtw_get_current_time(); + DBG_88E("===> rtw_ips_pwr_up..............\n"); + rtw_reset_drv_sw(padapter); + + result = ips_netdrv_open(padapter); + + rtw_led_control(padapter, LED_CTL_NO_LINK); + + DBG_88E("<=== rtw_ips_pwr_up.............. in %dms\n", rtw_get_passing_time_ms(start_time)); + return result; +} + +void rtw_ips_pwr_down(struct adapter *padapter) +{ + u32 start_time = rtw_get_current_time(); + DBG_88E("===> rtw_ips_pwr_down...................\n"); + + padapter->bCardDisableWOHSM = true; + padapter->net_closed = true; + + rtw_led_control(padapter, LED_CTL_POWER_OFF); + + rtw_ips_dev_unload(padapter); + padapter->bCardDisableWOHSM = false; + DBG_88E("<=== rtw_ips_pwr_down..................... in %dms\n", rtw_get_passing_time_ms(start_time)); +} + +void rtw_ips_dev_unload(struct adapter *padapter) +{ + DBG_88E("====> %s...\n", __func__); + + rtw_hal_set_hwreg(padapter, HW_VAR_FIFO_CLEARN_UP, NULL); + + if (padapter->intf_stop) + padapter->intf_stop(padapter); + + /* s5. */ + if (!padapter->bSurpriseRemoved) + rtw_hal_deinit(padapter); +} + +int pm_netdev_open(struct net_device *pnetdev, u8 bnormal) +{ + int status; + + if (bnormal) + status = netdev_open(pnetdev); + else + status = (_SUCCESS == ips_netdrv_open((struct adapter *)rtw_netdev_priv(pnetdev))) ? (0) : (-1); + return status; +} + +int netdev_close(struct net_device *pnetdev) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev); + + RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+88eu_drv - drv_close\n")); + + if (padapter->pwrctrlpriv.bInternalAutoSuspend) { + if (padapter->pwrctrlpriv.rf_pwrstate == rf_off) + padapter->pwrctrlpriv.ps_flag = true; + } + padapter->net_closed = true; + + if (padapter->pwrctrlpriv.rf_pwrstate == rf_on) { + DBG_88E("(2)88eu_drv - drv_close, bup =%d, hw_init_completed =%d\n", + padapter->bup, padapter->hw_init_completed); + + /* s1. */ + if (pnetdev) { + if (!rtw_netif_queue_stopped(pnetdev)) + rtw_netif_stop_queue(pnetdev); + } + + /* s2. */ + LeaveAllPowerSaveMode(padapter); + rtw_disassoc_cmd(padapter, 500, false); + /* s2-2. indicate disconnect to os */ + rtw_indicate_disconnect(padapter); + /* s2-3. */ + rtw_free_assoc_resources(padapter, 1); + /* s2-4. */ + rtw_free_network_queue(padapter, true); + /* Close LED */ + rtw_led_control(padapter, LED_CTL_POWER_OFF); + } + + nat25_db_cleanup(padapter); + +#ifdef CONFIG_88EU_P2P + rtw_p2p_enable(padapter, P2P_ROLE_DISABLE); +#endif /* CONFIG_88EU_P2P */ + + RT_TRACE(_module_os_intfs_c_, _drv_info_, ("-88eu_drv - drv_close\n")); + DBG_88E("-88eu_drv - drv_close, bup =%d\n", padapter->bup); + return 0; +} diff --git a/drivers/staging/rtl8188eu/os_dep/recv_linux.c b/drivers/staging/rtl8188eu/os_dep/recv_linux.c new file mode 100644 index 0000000000000..e2f4e7d771704 --- /dev/null +++ b/drivers/staging/rtl8188eu/os_dep/recv_linux.c @@ -0,0 +1,261 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RECV_OSDEP_C_ + +#include +#include + +#include +#include + +#include +#include +#include + +/* init os related resource in struct recv_priv */ +int rtw_os_recv_resource_init(struct recv_priv *precvpriv, + struct adapter *padapter) +{ + return _SUCCESS; +} + +/* alloc os related resource in union recv_frame */ +int rtw_os_recv_resource_alloc(struct adapter *padapter, + union recv_frame *precvframe) +{ + precvframe->u.hdr.pkt_newalloc = NULL; + precvframe->u.hdr.pkt = NULL; + return _SUCCESS; +} + +/* free os related resource in union recv_frame */ +void rtw_os_recv_resource_free(struct recv_priv *precvpriv) +{ +} + +/* alloc os related resource in struct recv_buf */ +int rtw_os_recvbuf_resource_alloc(struct adapter *padapter, + struct recv_buf *precvbuf) +{ + int res = _SUCCESS; + + precvbuf->irp_pending = false; + precvbuf->purb = usb_alloc_urb(0, GFP_KERNEL); + if (precvbuf->purb == NULL) + res = _FAIL; + precvbuf->pskb = NULL; + precvbuf->reuse = false; + precvbuf->pallocated_buf = NULL; + precvbuf->pbuf = NULL; + precvbuf->pdata = NULL; + precvbuf->phead = NULL; + precvbuf->ptail = NULL; + precvbuf->pend = NULL; + precvbuf->transfer_len = 0; + precvbuf->len = 0; + return res; +} + +/* free os related resource in struct recv_buf */ +int rtw_os_recvbuf_resource_free(struct adapter *padapter, + struct recv_buf *precvbuf) +{ + if (precvbuf->purb) + usb_free_urb(precvbuf->purb); + return _SUCCESS; +} + +void rtw_handle_tkip_mic_err(struct adapter *padapter, u8 bgroup) +{ + union iwreq_data wrqu; + struct iw_michaelmicfailure ev; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct security_priv *psecuritypriv = &padapter->securitypriv; + u32 cur_time = 0; + + if (psecuritypriv->last_mic_err_time == 0) { + psecuritypriv->last_mic_err_time = rtw_get_current_time(); + } else { + cur_time = rtw_get_current_time(); + + if (cur_time - psecuritypriv->last_mic_err_time < 60*HZ) { + psecuritypriv->btkip_countermeasure = true; + psecuritypriv->last_mic_err_time = 0; + psecuritypriv->btkip_countermeasure_time = cur_time; + } else { + psecuritypriv->last_mic_err_time = rtw_get_current_time(); + } + } + + _rtw_memset(&ev, 0x00, sizeof(ev)); + if (bgroup) + ev.flags |= IW_MICFAILURE_GROUP; + else + ev.flags |= IW_MICFAILURE_PAIRWISE; + + ev.src_addr.sa_family = ARPHRD_ETHER; + memcpy(ev.src_addr.sa_data, &pmlmepriv->assoc_bssid[0], ETH_ALEN); + _rtw_memset(&wrqu, 0x00, sizeof(wrqu)); + wrqu.data.length = sizeof(ev); + wireless_send_event(padapter->pnetdev, IWEVMICHAELMICFAILURE, + &wrqu, (char *)&ev); +} + +void rtw_hostapd_mlme_rx(struct adapter *padapter, + union recv_frame *precv_frame) +{ +} + +int rtw_recv_indicatepkt(struct adapter *padapter, + union recv_frame *precv_frame) +{ + struct recv_priv *precvpriv; + struct __queue *pfree_recv_queue; + struct sk_buff *skb; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + +_func_enter_; + + precvpriv = &(padapter->recvpriv); + pfree_recv_queue = &(precvpriv->free_recv_queue); + + skb = precv_frame->u.hdr.pkt; + if (skb == NULL) { + RT_TRACE(_module_recv_osdep_c_, _drv_err_, + ("rtw_recv_indicatepkt():skb == NULL something wrong!!!!\n")); + goto _recv_indicatepkt_drop; + } + + RT_TRACE(_module_recv_osdep_c_, _drv_info_, + ("rtw_recv_indicatepkt():skb != NULL !!!\n")); + RT_TRACE(_module_recv_osdep_c_, _drv_info_, + ("rtw_recv_indicatepkt():precv_frame->u.hdr.rx_head =%p precv_frame->hdr.rx_data =%p\n", + precv_frame->u.hdr.rx_head, precv_frame->u.hdr.rx_data)); + RT_TRACE(_module_recv_osdep_c_, _drv_info_, + ("precv_frame->hdr.rx_tail =%p precv_frame->u.hdr.rx_end =%p precv_frame->hdr.len =%d\n", + precv_frame->u.hdr.rx_tail, precv_frame->u.hdr.rx_end, + precv_frame->u.hdr.len)); + + skb->data = precv_frame->u.hdr.rx_data; + + skb_set_tail_pointer(skb, precv_frame->u.hdr.len); + + skb->len = precv_frame->u.hdr.len; + + RT_TRACE(_module_recv_osdep_c_, _drv_info_, + ("skb->head =%p skb->data =%p skb->tail =%p skb->end =%p skb->len =%d\n", + skb->head, skb->data, skb_tail_pointer(skb), + skb_end_pointer(skb), skb->len)); + + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { + struct sk_buff *pskb2 = NULL; + struct sta_info *psta = NULL; + struct sta_priv *pstapriv = &padapter->stapriv; + struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib; + int bmcast = IS_MCAST(pattrib->dst); + + if (!_rtw_memcmp(pattrib->dst, myid(&padapter->eeprompriv), + ETH_ALEN)) { + if (bmcast) { + psta = rtw_get_bcmc_stainfo(padapter); + pskb2 = skb_clone(skb, GFP_ATOMIC); + } else { + psta = rtw_get_stainfo(pstapriv, pattrib->dst); + } + + if (psta) { + struct net_device *pnetdev; + + pnetdev = (struct net_device *)padapter->pnetdev; + skb->dev = pnetdev; + skb_set_queue_mapping(skb, rtw_recv_select_queue(skb)); + + rtw_xmit_entry(skb, pnetdev); + + if (bmcast) + skb = pskb2; + else + goto _recv_indicatepkt_end; + } + } + } + + rcu_read_lock(); + rcu_dereference(padapter->pnetdev->rx_handler_data); + rcu_read_unlock(); + + skb->ip_summed = CHECKSUM_NONE; + skb->dev = padapter->pnetdev; + skb->protocol = eth_type_trans(skb, padapter->pnetdev); + + netif_rx(skb); + +_recv_indicatepkt_end: + + /* pointers to NULL before rtw_free_recvframe() */ + precv_frame->u.hdr.pkt = NULL; + + rtw_free_recvframe(precv_frame, pfree_recv_queue); + + RT_TRACE(_module_recv_osdep_c_, _drv_info_, + ("\n rtw_recv_indicatepkt :after netif_rx!!!!\n")); + +_func_exit_; + + return _SUCCESS; + +_recv_indicatepkt_drop: + + /* enqueue back to free_recv_queue */ + if (precv_frame) + rtw_free_recvframe(precv_frame, pfree_recv_queue); + +_func_exit_; + return _FAIL; +} + +void rtw_os_read_port(struct adapter *padapter, struct recv_buf *precvbuf) +{ + struct recv_priv *precvpriv = &padapter->recvpriv; + + precvbuf->ref_cnt--; + /* free skb in recv_buf */ + dev_kfree_skb_any(precvbuf->pskb); + precvbuf->pskb = NULL; + precvbuf->reuse = false; + if (!precvbuf->irp_pending) + rtw_read_port(padapter, precvpriv->ff_hwaddr, 0, + (unsigned char *)precvbuf); +} + +static void _rtw_reordering_ctrl_timeout_handler(void *func_context) +{ + struct recv_reorder_ctrl *preorder_ctrl; + + preorder_ctrl = (struct recv_reorder_ctrl *)func_context; + rtw_reordering_ctrl_timeout_handler(preorder_ctrl); +} + +void rtw_init_recv_timer(struct recv_reorder_ctrl *preorder_ctrl) +{ + struct adapter *padapter = preorder_ctrl->padapter; + + _init_timer(&(preorder_ctrl->reordering_ctrl_timer), padapter->pnetdev, _rtw_reordering_ctrl_timeout_handler, preorder_ctrl); +} diff --git a/drivers/staging/rtl8188eu/os_dep/rtw_android.c b/drivers/staging/rtl8188eu/os_dep/rtw_android.c new file mode 100644 index 0000000000000..6cf71cc2ca2ef --- /dev/null +++ b/drivers/staging/rtl8188eu/os_dep/rtw_android.c @@ -0,0 +1,293 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#include +#include + +#include +#include +#include +#include +#include + +static const char *android_wifi_cmd_str[ANDROID_WIFI_CMD_MAX] = { + "START", + "STOP", + "SCAN-ACTIVE", + "SCAN-PASSIVE", + "RSSI", + "LINKSPEED", + "RXFILTER-START", + "RXFILTER-STOP", + "RXFILTER-ADD", + "RXFILTER-REMOVE", + "BTCOEXSCAN-START", + "BTCOEXSCAN-STOP", + "BTCOEXMODE", + "SETSUSPENDOPT", + "P2P_DEV_ADDR", + "SETFWPATH", + "SETBAND", + "GETBAND", + "COUNTRY", + "P2P_SET_NOA", + "P2P_GET_NOA", + "P2P_SET_PS", + "SET_AP_WPS_P2P_IE", + "MACADDR", + "BLOCK", + "WFD-ENABLE", + "WFD-DISABLE", + "WFD-SET-TCPPORT", + "WFD-SET-MAXTPUT", + "WFD-SET-DEVTYPE", +}; + +struct android_wifi_priv_cmd { + const char __user *buf; + int used_len; + int total_len; +}; + +/** + * Local (static) functions and variables + */ + +/* Initialize g_wifi_on to 1 so dhd_bus_start will be called for the first + * time (only) in dhd_open, subsequential wifi on will be handled by + * wl_android_wifi_on + */ +static int g_wifi_on = true; + +int rtw_android_cmdstr_to_num(char *cmdstr) +{ + int cmd_num; + for (cmd_num = 0; cmd_num < ANDROID_WIFI_CMD_MAX; cmd_num++) + if (0 == strnicmp(cmdstr , android_wifi_cmd_str[cmd_num], + strlen(android_wifi_cmd_str[cmd_num]))) + break; + return cmd_num; +} + +static int rtw_android_get_rssi(struct net_device *net, char *command, + int total_len) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(net); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct wlan_network *pcur_network = &pmlmepriv->cur_network; + int bytes_written = 0; + + if (check_fwstate(pmlmepriv, _FW_LINKED)) { + bytes_written += snprintf(&command[bytes_written], total_len, + "%s rssi %d", + pcur_network->network.Ssid.Ssid, + padapter->recvpriv.rssi); + } + return bytes_written; +} + +static int rtw_android_get_link_speed(struct net_device *net, char *command, + int total_len) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(net); + int bytes_written; + u16 link_speed; + + link_speed = rtw_get_cur_max_rate(padapter) / 10; + bytes_written = snprintf(command, total_len, "LinkSpeed %d", + link_speed); + return bytes_written; +} + +static int rtw_android_get_macaddr(struct net_device *net, char *command, + int total_len) +{ + int bytes_written; + + bytes_written = snprintf(command, total_len, "Macaddr = %pM", + net->dev_addr); + return bytes_written; +} + +static int android_set_cntry(struct net_device *net, char *command, + int total_len) +{ + struct adapter *adapter = (struct adapter *)rtw_netdev_priv(net); + char *country_code = command + strlen(android_wifi_cmd_str[ANDROID_WIFI_CMD_COUNTRY]) + 1; + int ret; + + ret = rtw_set_country(adapter, country_code); + return (ret == _SUCCESS) ? 0 : -1; +} + +static int android_get_p2p_addr(struct net_device *net, char *command, + int total_len) +{ + /* We use the same address as our HW MAC address */ + memcpy(command, net->dev_addr, ETH_ALEN); + return ETH_ALEN; +} + +static int rtw_android_set_block(struct net_device *net, char *command, + int total_len) +{ + return 0; +} + +int rtw_android_priv_cmd(struct net_device *net, struct ifreq *ifr, int cmd) +{ + int ret = 0; + char *command = NULL; + int cmd_num; + int bytes_written = 0; + struct android_wifi_priv_cmd priv_cmd; + + rtw_lock_suspend(); + if (!ifr->ifr_data) { + ret = -EINVAL; + goto exit; + } + if (copy_from_user(&priv_cmd, ifr->ifr_data, + sizeof(struct android_wifi_priv_cmd))) { + ret = -EFAULT; + goto exit; + } + command = kmalloc(priv_cmd.total_len, GFP_KERNEL); + if (!command) { + DBG_88E("%s: failed to allocate memory\n", __func__); + ret = -ENOMEM; + goto exit; + } + if (!access_ok(VERIFY_READ, priv_cmd.buf, priv_cmd.total_len)) { + DBG_88E("%s: failed to access memory\n", __func__); + ret = -EFAULT; + goto exit; + } + if (copy_from_user(command, (char __user *)priv_cmd.buf, + priv_cmd.total_len)) { + ret = -EFAULT; + goto exit; + } + DBG_88E("%s: Android private cmd \"%s\" on %s\n", + __func__, command, ifr->ifr_name); + cmd_num = rtw_android_cmdstr_to_num(command); + switch (cmd_num) { + case ANDROID_WIFI_CMD_START: + goto response; + case ANDROID_WIFI_CMD_SETFWPATH: + goto response; + } + if (!g_wifi_on) { + DBG_88E("%s: Ignore private cmd \"%s\" - iface %s is down\n", + __func__, command, ifr->ifr_name); + ret = 0; + goto exit; + } + switch (cmd_num) { + case ANDROID_WIFI_CMD_STOP: + break; + case ANDROID_WIFI_CMD_SCAN_ACTIVE: + break; + case ANDROID_WIFI_CMD_SCAN_PASSIVE: + break; + case ANDROID_WIFI_CMD_RSSI: + bytes_written = rtw_android_get_rssi(net, command, + priv_cmd.total_len); + break; + case ANDROID_WIFI_CMD_LINKSPEED: + bytes_written = rtw_android_get_link_speed(net, command, + priv_cmd.total_len); + break; + case ANDROID_WIFI_CMD_MACADDR: + bytes_written = rtw_android_get_macaddr(net, command, + priv_cmd.total_len); + break; + case ANDROID_WIFI_CMD_BLOCK: + bytes_written = rtw_android_set_block(net, command, + priv_cmd.total_len); + break; + case ANDROID_WIFI_CMD_RXFILTER_START: + break; + case ANDROID_WIFI_CMD_RXFILTER_STOP: + break; + case ANDROID_WIFI_CMD_RXFILTER_ADD: + break; + case ANDROID_WIFI_CMD_RXFILTER_REMOVE: + break; + case ANDROID_WIFI_CMD_BTCOEXSCAN_START: + /* TBD: BTCOEXSCAN-START */ + break; + case ANDROID_WIFI_CMD_BTCOEXSCAN_STOP: + /* TBD: BTCOEXSCAN-STOP */ + break; + case ANDROID_WIFI_CMD_BTCOEXMODE: + break; + case ANDROID_WIFI_CMD_SETSUSPENDOPT: + break; + case ANDROID_WIFI_CMD_SETBAND: + break; + case ANDROID_WIFI_CMD_GETBAND: + break; + case ANDROID_WIFI_CMD_COUNTRY: + bytes_written = android_set_cntry(net, command, + priv_cmd.total_len); + break; + case ANDROID_WIFI_CMD_P2P_DEV_ADDR: + bytes_written = android_get_p2p_addr(net, command, + priv_cmd.total_len); + break; + case ANDROID_WIFI_CMD_P2P_SET_NOA: + break; + case ANDROID_WIFI_CMD_P2P_GET_NOA: + break; + case ANDROID_WIFI_CMD_P2P_SET_PS: + break; + default: + DBG_88E("Unknown PRIVATE command %s - ignored\n", command); + snprintf(command, 3, "OK"); + bytes_written = strlen("OK"); + } + +response: + if (bytes_written >= 0) { + if ((bytes_written == 0) && (priv_cmd.total_len > 0)) + command[0] = '\0'; + if (bytes_written >= priv_cmd.total_len) { + DBG_88E("%s: bytes_written = %d\n", __func__, + bytes_written); + bytes_written = priv_cmd.total_len; + } else { + bytes_written++; + } + priv_cmd.used_len = bytes_written; + if (copy_to_user((char __user *)priv_cmd.buf, command, + bytes_written)) { + DBG_88E("%s: failed to copy data to user buffer\n", + __func__); + ret = -EFAULT; + } + } else { + ret = bytes_written; + } +exit: + rtw_unlock_suspend(); + kfree(command); + return ret; +} -- GitLab From c2478d39076bf3c22c4ad66342fd27afdd305bd5 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 21 Aug 2013 22:34:02 -0500 Subject: [PATCH 778/942] staging: r8188eu: Add files for new driver - part 20 This commit adds files os_dep/usb_intf.c, os_dep/usb_ops_linux.c, and os_dep/xmit_linux.c. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/usb_intf.c | 892 ++++++++++++++++++ .../staging/rtl8188eu/os_dep/usb_ops_linux.c | 288 ++++++ drivers/staging/rtl8188eu/os_dep/xmit_linux.c | 289 ++++++ 3 files changed, 1469 insertions(+) create mode 100644 drivers/staging/rtl8188eu/os_dep/usb_intf.c create mode 100644 drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c create mode 100644 drivers/staging/rtl8188eu/os_dep/xmit_linux.c diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c new file mode 100644 index 0000000000000..d3078d200e505 --- /dev/null +++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c @@ -0,0 +1,892 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _HCI_INTF_C_ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +int ui_pid[3] = {0, 0, 0}; + +static int rtw_suspend(struct usb_interface *intf, pm_message_t message); +static int rtw_resume(struct usb_interface *intf); + + +static int rtw_drv_init(struct usb_interface *pusb_intf, const struct usb_device_id *pdid); +static void rtw_dev_remove(struct usb_interface *pusb_intf); + + +#define USB_VENDER_ID_REALTEK 0x0bda + +/* DID_USB_v916_20130116 */ +static struct usb_device_id rtw_usb_id_tbl[] = { + /*=== Realtek demoboard ===*/ + {USB_DEVICE(USB_VENDER_ID_REALTEK, 0x8179)}, /* 8188EUS */ + {USB_DEVICE(USB_VENDER_ID_REALTEK, 0x0179)}, /* 8188ETV */ + /*=== Customer ID ===*/ + /****** 8188EUS ********/ + {USB_DEVICE(0x8179, 0x07B8)}, /* Abocom - Abocom */ + {} /* Terminating entry */ +}; + +MODULE_DEVICE_TABLE(usb, rtw_usb_id_tbl); + +static struct specific_device_id specific_device_id_tbl[] = { + {} /* empty table for now */ +}; + +struct rtw_usb_drv { + struct usb_driver usbdrv; + int drv_registered; + struct mutex hw_init_mutex; +}; + +static struct rtw_usb_drv rtl8188e_usb_drv = { + .usbdrv.name = (char *)"r8188eu", + .usbdrv.probe = rtw_drv_init, + .usbdrv.disconnect = rtw_dev_remove, + .usbdrv.id_table = rtw_usb_id_tbl, + .usbdrv.suspend = rtw_suspend, + .usbdrv.resume = rtw_resume, + .usbdrv.reset_resume = rtw_resume, +}; + +static struct rtw_usb_drv *usb_drv = &rtl8188e_usb_drv; + +static inline int RT_usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd) +{ + return (epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN; +} + +static inline int RT_usb_endpoint_dir_out(const struct usb_endpoint_descriptor *epd) +{ + return (epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT; +} + +static inline int RT_usb_endpoint_xfer_int(const struct usb_endpoint_descriptor *epd) +{ + return (epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT; +} + +static inline int RT_usb_endpoint_xfer_bulk(const struct usb_endpoint_descriptor *epd) +{ + return (epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_BULK; +} + +static inline int RT_usb_endpoint_is_bulk_in(const struct usb_endpoint_descriptor *epd) +{ + return RT_usb_endpoint_xfer_bulk(epd) && RT_usb_endpoint_dir_in(epd); +} + +static inline int RT_usb_endpoint_is_bulk_out(const struct usb_endpoint_descriptor *epd) +{ + return RT_usb_endpoint_xfer_bulk(epd) && RT_usb_endpoint_dir_out(epd); +} + +static inline int usb_endpoint_is_int(const struct usb_endpoint_descriptor *epd) +{ + return RT_usb_endpoint_xfer_int(epd) && RT_usb_endpoint_dir_in(epd); +} + +static inline int RT_usb_endpoint_num(const struct usb_endpoint_descriptor *epd) +{ + return epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; +} + +static u8 rtw_init_intf_priv(struct dvobj_priv *dvobj) +{ + u8 rst = _SUCCESS; + + _rtw_mutex_init(&dvobj->usb_vendor_req_mutex); + + dvobj->usb_alloc_vendor_req_buf = rtw_zmalloc(MAX_USB_IO_CTL_SIZE); + if (dvobj->usb_alloc_vendor_req_buf == NULL) { + DBG_88E("alloc usb_vendor_req_buf failed... /n"); + rst = _FAIL; + goto exit; + } + dvobj->usb_vendor_req_buf = (u8 *)N_BYTE_ALIGMENT((size_t)(dvobj->usb_alloc_vendor_req_buf), ALIGNMENT_UNIT); +exit: + return rst; +} + +static u8 rtw_deinit_intf_priv(struct dvobj_priv *dvobj) +{ + u8 rst = _SUCCESS; + + kfree(dvobj->usb_alloc_vendor_req_buf); + _rtw_mutex_free(&dvobj->usb_vendor_req_mutex); + return rst; +} + +static struct dvobj_priv *usb_dvobj_init(struct usb_interface *usb_intf) +{ + int i; + int status = _FAIL; + struct dvobj_priv *pdvobjpriv; + struct usb_host_config *phost_conf; + struct usb_config_descriptor *pconf_desc; + struct usb_host_interface *phost_iface; + struct usb_interface_descriptor *piface_desc; + struct usb_host_endpoint *phost_endp; + struct usb_endpoint_descriptor *pendp_desc; + struct usb_device *pusbd; + +_func_enter_; + + pdvobjpriv = (struct dvobj_priv *)rtw_zmalloc(sizeof(*pdvobjpriv)); + if (pdvobjpriv == NULL) + goto exit; + + pdvobjpriv->pusbintf = usb_intf; + pusbd = interface_to_usbdev(usb_intf); + pdvobjpriv->pusbdev = pusbd; + usb_set_intfdata(usb_intf, pdvobjpriv); + + pdvobjpriv->RtNumInPipes = 0; + pdvobjpriv->RtNumOutPipes = 0; + + phost_conf = pusbd->actconfig; + pconf_desc = &phost_conf->desc; + + phost_iface = &usb_intf->altsetting[0]; + piface_desc = &phost_iface->desc; + + pdvobjpriv->NumInterfaces = pconf_desc->bNumInterfaces; + pdvobjpriv->InterfaceNumber = piface_desc->bInterfaceNumber; + pdvobjpriv->nr_endpoint = piface_desc->bNumEndpoints; + + for (i = 0; i < pdvobjpriv->nr_endpoint; i++) { + phost_endp = phost_iface->endpoint + i; + if (phost_endp) { + pendp_desc = &phost_endp->desc; + + DBG_88E("\nusb_endpoint_descriptor(%d):\n", i); + DBG_88E("bLength=%x\n", pendp_desc->bLength); + DBG_88E("bDescriptorType=%x\n", + pendp_desc->bDescriptorType); + DBG_88E("bEndpointAddress=%x\n", + pendp_desc->bEndpointAddress); + DBG_88E("wMaxPacketSize=%d\n", + le16_to_cpu(pendp_desc->wMaxPacketSize)); + DBG_88E("bInterval=%x\n", pendp_desc->bInterval); + + if (RT_usb_endpoint_is_bulk_in(pendp_desc)) { + DBG_88E("RT_usb_endpoint_is_bulk_in = %x\n", + RT_usb_endpoint_num(pendp_desc)); + pdvobjpriv->RtInPipe[pdvobjpriv->RtNumInPipes] = RT_usb_endpoint_num(pendp_desc); + pdvobjpriv->RtNumInPipes++; + } else if (usb_endpoint_is_int(pendp_desc)) { + DBG_88E("usb_endpoint_is_int = %x, Interval = %x\n", + RT_usb_endpoint_num(pendp_desc), + pendp_desc->bInterval); + pdvobjpriv->RtInPipe[pdvobjpriv->RtNumInPipes] = RT_usb_endpoint_num(pendp_desc); + pdvobjpriv->RtNumInPipes++; + } else if (RT_usb_endpoint_is_bulk_out(pendp_desc)) { + DBG_88E("RT_usb_endpoint_is_bulk_out = %x\n", + RT_usb_endpoint_num(pendp_desc)); + pdvobjpriv->RtOutPipe[pdvobjpriv->RtNumOutPipes] = RT_usb_endpoint_num(pendp_desc); + pdvobjpriv->RtNumOutPipes++; + } + pdvobjpriv->ep_num[i] = RT_usb_endpoint_num(pendp_desc); + } + } + + DBG_88E("nr_endpoint=%d, in_num=%d, out_num=%d\n\n", + pdvobjpriv->nr_endpoint, pdvobjpriv->RtNumInPipes, + pdvobjpriv->RtNumOutPipes); + + if (pusbd->speed == USB_SPEED_HIGH) { + pdvobjpriv->ishighspeed = true; + DBG_88E("USB_SPEED_HIGH\n"); + } else { + pdvobjpriv->ishighspeed = false; + DBG_88E("NON USB_SPEED_HIGH\n"); + } + + if (rtw_init_intf_priv(pdvobjpriv) == _FAIL) { + RT_TRACE(_module_os_intfs_c_, _drv_err_, + ("\n Can't INIT rtw_init_intf_priv\n")); + goto free_dvobj; + } + + /* 3 misc */ + _rtw_init_sema(&(pdvobjpriv->usb_suspend_sema), 0); + rtw_reset_continual_urb_error(pdvobjpriv); + + usb_get_dev(pusbd); + + status = _SUCCESS; + +free_dvobj: + if (status != _SUCCESS && pdvobjpriv) { + usb_set_intfdata(usb_intf, NULL); + kfree(pdvobjpriv); + pdvobjpriv = NULL; + } +exit: +_func_exit_; + return pdvobjpriv; +} + +static void usb_dvobj_deinit(struct usb_interface *usb_intf) +{ + struct dvobj_priv *dvobj = usb_get_intfdata(usb_intf); + +_func_enter_; + + usb_set_intfdata(usb_intf, NULL); + if (dvobj) { + /* Modify condition for 92DU DMDP 2010.11.18, by Thomas */ + if ((dvobj->NumInterfaces != 2 && + dvobj->NumInterfaces != 3) || + (dvobj->InterfaceNumber == 1)) { + if (interface_to_usbdev(usb_intf)->state != + USB_STATE_NOTATTACHED) { + /* If we didn't unplug usb dongle and + * remove/insert module, driver fails + * on sitesurvey for the first time when + * device is up . Reset usb port for sitesurvey + * fail issue. */ + DBG_88E("usb attached..., try to reset usb device\n"); + usb_reset_device(interface_to_usbdev(usb_intf)); + } + } + rtw_deinit_intf_priv(dvobj); + kfree(dvobj); + } + + usb_put_dev(interface_to_usbdev(usb_intf)); + +_func_exit_; +} + +static void chip_by_usb_id(struct adapter *padapter, + const struct usb_device_id *pdid) +{ + padapter->chip_type = NULL_CHIP_TYPE; + hal_set_hw_type(padapter); +} + +static void usb_intf_start(struct adapter *padapter) +{ + RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+usb_intf_start\n")); + + rtw_hal_inirp_init(padapter); + + RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("-usb_intf_start\n")); +} + +static void usb_intf_stop(struct adapter *padapter) +{ + RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+usb_intf_stop\n")); + + /* disabel_hw_interrupt */ + if (!padapter->bSurpriseRemoved) { + /* device still exists, so driver can do i/o operation */ + /* TODO: */ + RT_TRACE(_module_hci_intfs_c_, _drv_err_, + ("SurpriseRemoved == false\n")); + } + + /* cancel in irp */ + rtw_hal_inirp_deinit(padapter); + + /* cancel out irp */ + rtw_write_port_cancel(padapter); + + /* todo:cancel other irps */ + + RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("-usb_intf_stop\n")); +} + +static void rtw_dev_unload(struct adapter *padapter) +{ + RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+rtw_dev_unload\n")); + + if (padapter->bup) { + DBG_88E("===> rtw_dev_unload\n"); + padapter->bDriverStopped = true; + if (padapter->xmitpriv.ack_tx) + rtw_ack_tx_done(&padapter->xmitpriv, RTW_SCTX_DONE_DRV_STOP); + /* s3. */ + if (padapter->intf_stop) + padapter->intf_stop(padapter); + /* s4. */ + if (!padapter->pwrctrlpriv.bInternalAutoSuspend) + rtw_stop_drv_threads(padapter); + + /* s5. */ + if (!padapter->bSurpriseRemoved) { + rtw_hal_deinit(padapter); + padapter->bSurpriseRemoved = true; + } + + padapter->bup = false; + } else { + RT_TRACE(_module_hci_intfs_c_, _drv_err_, + ("r871x_dev_unload():padapter->bup == false\n")); + } + + DBG_88E("<=== rtw_dev_unload\n"); + + RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("-rtw_dev_unload\n")); +} + +static void process_spec_devid(const struct usb_device_id *pdid) +{ + u16 vid, pid; + u32 flags; + int i; + int num = sizeof(specific_device_id_tbl) / + sizeof(struct specific_device_id); + + for (i = 0; i < num; i++) { + vid = specific_device_id_tbl[i].idVendor; + pid = specific_device_id_tbl[i].idProduct; + flags = specific_device_id_tbl[i].flags; + + if ((pdid->idVendor == vid) && (pdid->idProduct == pid) && + (flags&SPEC_DEV_ID_DISABLE_HT)) { + rtw_ht_enable = 0; + rtw_cbw40_enable = 0; + rtw_ampdu_enable = 0; + } + } +} + +int rtw_hw_suspend(struct adapter *padapter) +{ + struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; + struct net_device *pnetdev = padapter->pnetdev; + + _func_enter_; + + if ((!padapter->bup) || (padapter->bDriverStopped) || + (padapter->bSurpriseRemoved)) { + DBG_88E("padapter->bup=%d bDriverStopped=%d bSurpriseRemoved = %d\n", + padapter->bup, padapter->bDriverStopped, + padapter->bSurpriseRemoved); + goto error_exit; + } + + if (padapter) { /* system suspend */ + LeaveAllPowerSaveMode(padapter); + + DBG_88E("==> rtw_hw_suspend\n"); + _enter_pwrlock(&pwrpriv->lock); + pwrpriv->bips_processing = true; + /* s1. */ + if (pnetdev) { + netif_carrier_off(pnetdev); + rtw_netif_stop_queue(pnetdev); + } + + /* s2. */ + rtw_disassoc_cmd(padapter, 500, false); + + /* s2-2. indicate disconnect to os */ + { + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + + if (check_fwstate(pmlmepriv, _FW_LINKED)) { + _clr_fwstate_(pmlmepriv, _FW_LINKED); + + rtw_led_control(padapter, LED_CTL_NO_LINK); + + rtw_os_indicate_disconnect(padapter); + + /* donnot enqueue cmd */ + rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_DISCONNECT, 0); + } + } + /* s2-3. */ + rtw_free_assoc_resources(padapter, 1); + + /* s2-4. */ + rtw_free_network_queue(padapter, true); + rtw_ips_dev_unload(padapter); + pwrpriv->rf_pwrstate = rf_off; + pwrpriv->bips_processing = false; + + _exit_pwrlock(&pwrpriv->lock); + } else { + goto error_exit; + } + _func_exit_; + return 0; + +error_exit: + DBG_88E("%s, failed\n", __func__); + return -1; +} + +int rtw_hw_resume(struct adapter *padapter) +{ + struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; + struct net_device *pnetdev = padapter->pnetdev; + + _func_enter_; + + if (padapter) { /* system resume */ + DBG_88E("==> rtw_hw_resume\n"); + _enter_pwrlock(&pwrpriv->lock); + pwrpriv->bips_processing = true; + rtw_reset_drv_sw(padapter); + + if (pm_netdev_open(pnetdev, false) != 0) { + _exit_pwrlock(&pwrpriv->lock); + goto error_exit; + } + + netif_device_attach(pnetdev); + netif_carrier_on(pnetdev); + + if (!netif_queue_stopped(pnetdev)) + netif_start_queue(pnetdev); + else + netif_wake_queue(pnetdev); + + pwrpriv->bkeepfwalive = false; + pwrpriv->brfoffbyhw = false; + + pwrpriv->rf_pwrstate = rf_on; + pwrpriv->bips_processing = false; + + _exit_pwrlock(&pwrpriv->lock); + } else { + goto error_exit; + } + + _func_exit_; + + return 0; +error_exit: + DBG_88E("%s, Open net dev failed\n", __func__); + return -1; +} + +static int rtw_suspend(struct usb_interface *pusb_intf, pm_message_t message) +{ + struct dvobj_priv *dvobj = usb_get_intfdata(pusb_intf); + struct adapter *padapter = dvobj->if1; + struct net_device *pnetdev = padapter->pnetdev; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; + + int ret = 0; + u32 start_time = rtw_get_current_time(); + + _func_enter_; + + DBG_88E("==> %s (%s:%d)\n", __func__, current->comm, current->pid); + + if ((!padapter->bup) || (padapter->bDriverStopped) || + (padapter->bSurpriseRemoved)) { + DBG_88E("padapter->bup=%d bDriverStopped=%d bSurpriseRemoved = %d\n", + padapter->bup, padapter->bDriverStopped, + padapter->bSurpriseRemoved); + goto exit; + } + + pwrpriv->bInSuspend = true; + rtw_cancel_all_timer(padapter); + LeaveAllPowerSaveMode(padapter); + + _enter_pwrlock(&pwrpriv->lock); + /* s1. */ + if (pnetdev) { + netif_carrier_off(pnetdev); + rtw_netif_stop_queue(pnetdev); + } + + /* s2. */ + rtw_disassoc_cmd(padapter, 0, false); + + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) && + check_fwstate(pmlmepriv, _FW_LINKED)) { + DBG_88E("%s:%d %s(%pM), length:%d assoc_ssid.length:%d\n", + __func__, __LINE__, + pmlmepriv->cur_network.network.Ssid.Ssid, + pmlmepriv->cur_network.network.MacAddress, + pmlmepriv->cur_network.network.Ssid.SsidLength, + pmlmepriv->assoc_ssid.SsidLength); + + pmlmepriv->to_roaming = 1; + } + /* s2-2. indicate disconnect to os */ + rtw_indicate_disconnect(padapter); + /* s2-3. */ + rtw_free_assoc_resources(padapter, 1); + /* s2-4. */ + rtw_free_network_queue(padapter, true); + + rtw_dev_unload(padapter); + _exit_pwrlock(&pwrpriv->lock); + + if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) + rtw_indicate_scan_done(padapter, 1); + + if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) + rtw_indicate_disconnect(padapter); + +exit: + DBG_88E("<=== %s return %d.............. in %dms\n", __func__ + , ret, rtw_get_passing_time_ms(start_time)); + + _func_exit_; + return ret; +} + +static int rtw_resume(struct usb_interface *pusb_intf) +{ + struct dvobj_priv *dvobj = usb_get_intfdata(pusb_intf); + struct adapter *padapter = dvobj->if1; + struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; + int ret = 0; + + if (pwrpriv->bInternalAutoSuspend) + ret = rtw_resume_process(padapter); + else + ret = rtw_resume_process(padapter); + return ret; +} + +int rtw_resume_process(struct adapter *padapter) +{ + struct net_device *pnetdev; + struct pwrctrl_priv *pwrpriv = NULL; + int ret = -1; + u32 start_time = rtw_get_current_time(); + _func_enter_; + + DBG_88E("==> %s (%s:%d)\n", __func__, current->comm, current->pid); + + if (padapter) { + pnetdev = padapter->pnetdev; + pwrpriv = &padapter->pwrctrlpriv; + } else { + goto exit; + } + + _enter_pwrlock(&pwrpriv->lock); + rtw_reset_drv_sw(padapter); + if (pwrpriv) + pwrpriv->bkeepfwalive = false; + + DBG_88E("bkeepfwalive(%x)\n", pwrpriv->bkeepfwalive); + if (pm_netdev_open(pnetdev, true) != 0) + goto exit; + + netif_device_attach(pnetdev); + netif_carrier_on(pnetdev); + + _exit_pwrlock(&pwrpriv->lock); + + if (padapter->pid[1] != 0) { + DBG_88E("pid[1]:%d\n", padapter->pid[1]); + rtw_signal_process(padapter->pid[1], SIGUSR2); + } + + rtw_roaming(padapter, NULL); + + ret = 0; +exit: + if (pwrpriv) + pwrpriv->bInSuspend = false; + DBG_88E("<=== %s return %d.............. in %dms\n", __func__, + ret, rtw_get_passing_time_ms(start_time)); + + _func_exit_; + + return ret; +} + +/* + * drv_init() - a device potentially for us + * + * notes: drv_init() is called when the bus driver has located + * a card for us to support. + * We accept the new device by returning 0. + */ + +static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, + struct usb_interface *pusb_intf, const struct usb_device_id *pdid) +{ + struct adapter *padapter = NULL; + struct net_device *pnetdev = NULL; + int status = _FAIL; + + padapter = (struct adapter *)rtw_zvmalloc(sizeof(*padapter)); + if (padapter == NULL) + goto exit; + padapter->dvobj = dvobj; + dvobj->if1 = padapter; + + padapter->bDriverStopped = true; + + padapter->hw_init_mutex = &usb_drv->hw_init_mutex; + + /* step 1-1., decide the chip_type via vid/pid */ + padapter->interface_type = RTW_USB; + chip_by_usb_id(padapter, pdid); + + if (rtw_handle_dualmac(padapter, 1) != _SUCCESS) + goto free_adapter; + + pnetdev = rtw_init_netdev(padapter); + if (pnetdev == NULL) + goto handle_dualmac; + SET_NETDEV_DEV(pnetdev, dvobj_to_dev(dvobj)); + padapter = rtw_netdev_priv(pnetdev); + + /* step 2. hook HalFunc, allocate HalData */ + hal_set_hal_ops(padapter); + + padapter->intf_start = &usb_intf_start; + padapter->intf_stop = &usb_intf_stop; + + /* step init_io_priv */ + rtw_init_io_priv(padapter, usb_set_intf_ops); + + /* step read_chip_version */ + rtw_hal_read_chip_version(padapter); + + /* step usb endpoint mapping */ + rtw_hal_chip_configure(padapter); + + /* step read efuse/eeprom data and get mac_addr */ + rtw_hal_read_chip_info(padapter); + + /* step 5. */ + if (rtw_init_drv_sw(padapter) == _FAIL) { + RT_TRACE(_module_hci_intfs_c_, _drv_err_, + ("Initialize driver software resource Failed!\n")); + goto free_hal_data; + } + +#ifdef CONFIG_PM + if (padapter->pwrctrlpriv.bSupportRemoteWakeup) { + dvobj->pusbdev->do_remote_wakeup = 1; + pusb_intf->needs_remote_wakeup = 1; + device_init_wakeup(&pusb_intf->dev, 1); + DBG_88E("\n padapter->pwrctrlpriv.bSupportRemoteWakeup~~~~~~\n"); + DBG_88E("\n padapter->pwrctrlpriv.bSupportRemoteWakeup~~~[%d]~~~\n", + device_may_wakeup(&pusb_intf->dev)); + } +#endif + + /* 2012-07-11 Move here to prevent the 8723AS-VAU BT auto + * suspend influence */ + if (usb_autopm_get_interface(pusb_intf) < 0) + DBG_88E("can't get autopm:\n"); + + /* alloc dev name after read efuse. */ + rtw_init_netdev_name(pnetdev, padapter->registrypriv.ifname); + rtw_macaddr_cfg(padapter->eeprompriv.mac_addr); +#ifdef CONFIG_88EU_P2P + rtw_init_wifidirect_addrs(padapter, padapter->eeprompriv.mac_addr, + padapter->eeprompriv.mac_addr); +#endif + memcpy(pnetdev->dev_addr, padapter->eeprompriv.mac_addr, ETH_ALEN); + DBG_88E("MAC Address from pnetdev->dev_addr = %pM\n", + pnetdev->dev_addr); + + /* step 6. Tell the network stack we exist */ + if (register_netdev(pnetdev) != 0) { + RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("register_netdev() failed\n")); + goto free_hal_data; + } + + DBG_88E("bDriverStopped:%d, bSurpriseRemoved:%d, bup:%d, hw_init_completed:%d\n" + , padapter->bDriverStopped + , padapter->bSurpriseRemoved + , padapter->bup + , padapter->hw_init_completed + ); + + status = _SUCCESS; + +free_hal_data: + if (status != _SUCCESS && padapter->HalData) + kfree(padapter->HalData); +handle_dualmac: + if (status != _SUCCESS) + rtw_handle_dualmac(padapter, 0); +free_adapter: + if (status != _SUCCESS) { + if (pnetdev) + rtw_free_netdev(pnetdev); + else if (padapter) + rtw_vmfree((u8 *)padapter, sizeof(*padapter)); + padapter = NULL; + } +exit: + return padapter; +} + +static void rtw_usb_if1_deinit(struct adapter *if1) +{ + struct net_device *pnetdev = if1->pnetdev; + struct mlme_priv *pmlmepriv = &if1->mlmepriv; + + if (check_fwstate(pmlmepriv, _FW_LINKED)) + rtw_disassoc_cmd(if1, 0, false); + +#ifdef CONFIG_88EU_AP_MODE + free_mlme_ap_info(if1); +#endif + + if (if1->DriverState != DRIVER_DISAPPEAR) { + if (pnetdev) { + /* will call netdev_close() */ + unregister_netdev(pnetdev); + rtw_proc_remove_one(pnetdev); + } + } + rtw_cancel_all_timer(if1); + + rtw_dev_unload(if1); + DBG_88E("+r871xu_dev_remove, hw_init_completed=%d\n", + if1->hw_init_completed); + rtw_handle_dualmac(if1, 0); + rtw_free_drv_sw(if1); + if (pnetdev) + rtw_free_netdev(pnetdev); +} + +static int rtw_drv_init(struct usb_interface *pusb_intf, const struct usb_device_id *pdid) +{ + struct adapter *if1 = NULL; + int status; + struct dvobj_priv *dvobj; + + RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+rtw_drv_init\n")); + + /* step 0. */ + process_spec_devid(pdid); + + /* Initialize dvobj_priv */ + dvobj = usb_dvobj_init(pusb_intf); + if (dvobj == NULL) { + RT_TRACE(_module_hci_intfs_c_, _drv_err_, + ("initialize device object priv Failed!\n")); + goto exit; + } + + if1 = rtw_usb_if1_init(dvobj, pusb_intf, pdid); + if (if1 == NULL) { + DBG_88E("rtw_init_primarystruct adapter Failed!\n"); + goto free_dvobj; + } + + if (ui_pid[1] != 0) { + DBG_88E("ui_pid[1]:%d\n", ui_pid[1]); + rtw_signal_process(ui_pid[1], SIGUSR2); + } + + RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("-871x_drv - drv_init, success!\n")); + + status = _SUCCESS; + + if (status != _SUCCESS && if1) + rtw_usb_if1_deinit(if1); +free_dvobj: + if (status != _SUCCESS) + usb_dvobj_deinit(pusb_intf); +exit: + return status == _SUCCESS ? 0 : -ENODEV; +} + +/* + * dev_remove() - our device is being removed +*/ +/* rmmod module & unplug(SurpriseRemoved) will call r871xu_dev_remove() => how to recognize both */ +static void rtw_dev_remove(struct usb_interface *pusb_intf) +{ + struct dvobj_priv *dvobj = usb_get_intfdata(pusb_intf); + struct adapter *padapter = dvobj->if1; + +_func_enter_; + + DBG_88E("+rtw_dev_remove\n"); + RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+dev_remove()\n")); + + if (usb_drv->drv_registered) + padapter->bSurpriseRemoved = true; + + rtw_pm_set_ips(padapter, IPS_NONE); + rtw_pm_set_lps(padapter, PS_MODE_ACTIVE); + + LeaveAllPowerSaveMode(padapter); + + rtw_usb_if1_deinit(padapter); + + usb_dvobj_deinit(pusb_intf); + + RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("-dev_remove()\n")); + DBG_88E("-r871xu_dev_remove, done\n"); +_func_exit_; + + return; +} + +static int __init rtw_drv_entry(void) +{ + RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+rtw_drv_entry\n")); + + DBG_88E(DRV_NAME " driver version=%s\n", DRIVERVERSION); + DBG_88E("build time: %s %s\n", __DATE__, __TIME__); + + rtw_suspend_lock_init(); + + _rtw_mutex_init(&usb_drv->hw_init_mutex); + + usb_drv->drv_registered = true; + return usb_register(&usb_drv->usbdrv); +} + +static void __exit rtw_drv_halt(void) +{ + RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+rtw_drv_halt\n")); + DBG_88E("+rtw_drv_halt\n"); + + rtw_suspend_lock_uninit(); + + usb_drv->drv_registered = false; + usb_deregister(&usb_drv->usbdrv); + + _rtw_mutex_free(&usb_drv->hw_init_mutex); + DBG_88E("-rtw_drv_halt\n"); +} + +module_init(rtw_drv_entry); +module_exit(rtw_drv_halt); diff --git a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c new file mode 100644 index 0000000000000..4c71e3b93b58d --- /dev/null +++ b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c @@ -0,0 +1,288 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + ******************************************************************************/ +#define _USB_OPS_LINUX_C_ + +#include +#include +#include + +unsigned int ffaddr2pipehdl(struct dvobj_priv *pdvobj, u32 addr) +{ + unsigned int pipe = 0, ep_num = 0; + struct usb_device *pusbd = pdvobj->pusbdev; + + if (addr == RECV_BULK_IN_ADDR) { + pipe = usb_rcvbulkpipe(pusbd, pdvobj->RtInPipe[0]); + } else if (addr == RECV_INT_IN_ADDR) { + pipe = usb_rcvbulkpipe(pusbd, pdvobj->RtInPipe[1]); + } else if (addr < HW_QUEUE_ENTRY) { + ep_num = pdvobj->Queue2Pipe[addr]; + pipe = usb_sndbulkpipe(pusbd, ep_num); + } + + return pipe; +} + +struct zero_bulkout_context { + void *pbuf; + void *purb; + void *pirp; + void *padapter; +}; + +void usb_read_mem(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem) +{ +} + +void usb_write_mem(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem) +{ +} + +void usb_read_port_cancel(struct intf_hdl *pintfhdl) +{ + int i; + struct recv_buf *precvbuf; + struct adapter *padapter = pintfhdl->padapter; + precvbuf = (struct recv_buf *)padapter->recvpriv.precv_buf; + + DBG_88E("%s\n", __func__); + + padapter->bReadPortCancel = true; + + for (i = 0; i < NR_RECVBUFF; i++) { + precvbuf->reuse = true; + if (precvbuf->purb) + usb_kill_urb(precvbuf->purb); + precvbuf++; + } +} + +static void usb_write_port_complete(struct urb *purb, struct pt_regs *regs) +{ + struct xmit_buf *pxmitbuf = (struct xmit_buf *)purb->context; + struct adapter *padapter = pxmitbuf->padapter; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct hal_data_8188e *haldata; + +_func_enter_; + + switch (pxmitbuf->flags) { + case VO_QUEUE_INX: + pxmitpriv->voq_cnt--; + break; + case VI_QUEUE_INX: + pxmitpriv->viq_cnt--; + break; + case BE_QUEUE_INX: + pxmitpriv->beq_cnt--; + break; + case BK_QUEUE_INX: + pxmitpriv->bkq_cnt--; + break; + case HIGH_QUEUE_INX: +#ifdef CONFIG_88EU_AP_MODE + rtw_chk_hi_queue_cmd(padapter); +#endif + break; + default: + break; + } + + if (padapter->bSurpriseRemoved || padapter->bDriverStopped || + padapter->bWritePortCancel) { + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, + ("usb_write_port_complete:bDriverStopped(%d) OR bSurpriseRemoved(%d)", + padapter->bDriverStopped, padapter->bSurpriseRemoved)); + DBG_88E("%s(): TX Warning! bDriverStopped(%d) OR bSurpriseRemoved(%d) bWritePortCancel(%d) pxmitbuf->ext_tag(%x)\n", + __func__, padapter->bDriverStopped, + padapter->bSurpriseRemoved, padapter->bReadPortCancel, + pxmitbuf->ext_tag); + + goto check_completion; + } + + if (purb->status) { + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_write_port_complete : purb->status(%d) != 0\n", purb->status)); + DBG_88E("###=> urb_write_port_complete status(%d)\n", purb->status); + if ((purb->status == -EPIPE) || (purb->status == -EPROTO)) { + sreset_set_wifi_error_status(padapter, USB_WRITE_PORT_FAIL); + } else if (purb->status == -EINPROGRESS) { + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_write_port_complete: EINPROGESS\n")); + goto check_completion; + } else if (purb->status == -ENOENT) { + DBG_88E("%s: -ENOENT\n", __func__); + goto check_completion; + } else if (purb->status == -ECONNRESET) { + DBG_88E("%s: -ECONNRESET\n", __func__); + goto check_completion; + } else if (purb->status == -ESHUTDOWN) { + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_write_port_complete: ESHUTDOWN\n")); + padapter->bDriverStopped = true; + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_write_port_complete:bDriverStopped = true\n")); + goto check_completion; + } else { + padapter->bSurpriseRemoved = true; + DBG_88E("bSurpriseRemoved = true\n"); + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_write_port_complete:bSurpriseRemoved = true\n")); + + goto check_completion; + } + } + + haldata = GET_HAL_DATA(padapter); + haldata->srestpriv.last_tx_complete_time = rtw_get_current_time(); + +check_completion: + rtw_sctx_done_err(&pxmitbuf->sctx, + purb->status ? RTW_SCTX_DONE_WRITE_PORT_ERR : + RTW_SCTX_DONE_SUCCESS); + + rtw_free_xmitbuf(pxmitpriv, pxmitbuf); + + tasklet_hi_schedule(&pxmitpriv->xmit_tasklet); + +_func_exit_; +} + +u32 usb_write_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem) +{ + unsigned long irqL; + unsigned int pipe; + int status; + u32 ret = _FAIL; + struct urb *purb = NULL; + struct adapter *padapter = (struct adapter *)pintfhdl->padapter; + struct dvobj_priv *pdvobj = adapter_to_dvobj(padapter); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct xmit_buf *pxmitbuf = (struct xmit_buf *)wmem; + struct xmit_frame *pxmitframe = (struct xmit_frame *)pxmitbuf->priv_data; + struct usb_device *pusbd = pdvobj->pusbdev; + +_func_enter_; + + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("+usb_write_port\n")); + + if ((padapter->bDriverStopped) || (padapter->bSurpriseRemoved) || + (padapter->pwrctrlpriv.pnp_bstop_trx)) { + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, + ("usb_write_port:( padapter->bDriverStopped ||padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n")); + rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_TX_DENY); + goto exit; + } + + _enter_critical(&pxmitpriv->lock, &irqL); + + switch (addr) { + case VO_QUEUE_INX: + pxmitpriv->voq_cnt++; + pxmitbuf->flags = VO_QUEUE_INX; + break; + case VI_QUEUE_INX: + pxmitpriv->viq_cnt++; + pxmitbuf->flags = VI_QUEUE_INX; + break; + case BE_QUEUE_INX: + pxmitpriv->beq_cnt++; + pxmitbuf->flags = BE_QUEUE_INX; + break; + case BK_QUEUE_INX: + pxmitpriv->bkq_cnt++; + pxmitbuf->flags = BK_QUEUE_INX; + break; + case HIGH_QUEUE_INX: + pxmitbuf->flags = HIGH_QUEUE_INX; + break; + default: + pxmitbuf->flags = MGT_QUEUE_INX; + break; + } + + _exit_critical(&pxmitpriv->lock, &irqL); + + purb = pxmitbuf->pxmit_urb[0]; + + /* translate DMA FIFO addr to pipehandle */ + pipe = ffaddr2pipehdl(pdvobj, addr); + + usb_fill_bulk_urb(purb, pusbd, pipe, + pxmitframe->buf_addr, /* pxmitbuf->pbuf */ + cnt, + usb_write_port_complete, + pxmitbuf);/* context is pxmitbuf */ + + status = usb_submit_urb(purb, GFP_ATOMIC); + if (!status) { + struct hal_data_8188e *haldata = GET_HAL_DATA(padapter); + + haldata->srestpriv.last_tx_time = rtw_get_current_time(); + } else { + rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_WRITE_PORT_ERR); + DBG_88E("usb_write_port, status =%d\n", status); + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_write_port(): usb_submit_urb, status =%x\n", status)); + + switch (status) { + case -ENODEV: + padapter->bDriverStopped = true; + break; + default: + break; + } + goto exit; + } + + ret = _SUCCESS; + +/* We add the URB_ZERO_PACKET flag to urb so that the host will send the zero packet automatically. */ + + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("-usb_write_port\n")); + +exit: + if (ret != _SUCCESS) + rtw_free_xmitbuf(pxmitpriv, pxmitbuf); +_func_exit_; + return ret; +} + +void usb_write_port_cancel(struct intf_hdl *pintfhdl) +{ + int i, j; + struct adapter *padapter = pintfhdl->padapter; + struct xmit_buf *pxmitbuf = (struct xmit_buf *)padapter->xmitpriv.pxmitbuf; + + DBG_88E("%s\n", __func__); + + padapter->bWritePortCancel = true; + + for (i = 0; i < NR_XMITBUFF; i++) { + for (j = 0; j < 8; j++) { + if (pxmitbuf->pxmit_urb[j]) + usb_kill_urb(pxmitbuf->pxmit_urb[j]); + } + pxmitbuf++; + } + + pxmitbuf = (struct xmit_buf *)padapter->xmitpriv.pxmit_extbuf; + for (i = 0; i < NR_XMIT_EXTBUFF; i++) { + for (j = 0; j < 8; j++) { + if (pxmitbuf->pxmit_urb[j]) + usb_kill_urb(pxmitbuf->pxmit_urb[j]); + } + pxmitbuf++; + } +} diff --git a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c new file mode 100644 index 0000000000000..1e2c8abd7dd2a --- /dev/null +++ b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c @@ -0,0 +1,289 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _XMIT_OSDEP_C_ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +uint rtw_remainder_len(struct pkt_file *pfile) +{ + return pfile->buf_len - ((size_t)(pfile->cur_addr) - + (size_t)(pfile->buf_start)); +} + +void _rtw_open_pktfile(struct sk_buff *pktptr, struct pkt_file *pfile) +{ +_func_enter_; + + pfile->pkt = pktptr; + pfile->cur_addr = pktptr->data; + pfile->buf_start = pktptr->data; + pfile->pkt_len = pktptr->len; + pfile->buf_len = pktptr->len; + + pfile->cur_buffer = pfile->buf_start; + +_func_exit_; +} + +uint _rtw_pktfile_read (struct pkt_file *pfile, u8 *rmem, uint rlen) +{ + uint len = 0; + +_func_enter_; + + len = rtw_remainder_len(pfile); + len = (rlen > len) ? len : rlen; + + if (rmem) + skb_copy_bits(pfile->pkt, pfile->buf_len-pfile->pkt_len, rmem, len); + + pfile->cur_addr += len; + pfile->pkt_len -= len; + +_func_exit_; + + return len; +} + +int rtw_endofpktfile(struct pkt_file *pfile) +{ +_func_enter_; + + if (pfile->pkt_len == 0) { + _func_exit_; + return true; + } + +_func_exit_; + + return false; +} + +void rtw_set_tx_chksum_offload(struct sk_buff *pkt, struct pkt_attrib *pattrib) +{ +} + +int rtw_os_xmit_resource_alloc(struct adapter *padapter, struct xmit_buf *pxmitbuf, u32 alloc_sz) +{ + int i; + + pxmitbuf->pallocated_buf = rtw_zmalloc(alloc_sz); + if (pxmitbuf->pallocated_buf == NULL) + return _FAIL; + + pxmitbuf->pbuf = (u8 *)N_BYTE_ALIGMENT((size_t)(pxmitbuf->pallocated_buf), XMITBUF_ALIGN_SZ); + pxmitbuf->dma_transfer_addr = 0; + + for (i = 0; i < 8; i++) { + pxmitbuf->pxmit_urb[i] = usb_alloc_urb(0, GFP_KERNEL); + if (pxmitbuf->pxmit_urb[i] == NULL) { + DBG_88E("pxmitbuf->pxmit_urb[i]==NULL"); + return _FAIL; + } + } + return _SUCCESS; +} + +void rtw_os_xmit_resource_free(struct adapter *padapter, + struct xmit_buf *pxmitbuf, u32 free_sz) +{ + int i; + + for (i = 0; i < 8; i++) + usb_free_urb(pxmitbuf->pxmit_urb[i]); + + kfree(pxmitbuf->pallocated_buf); +} + +#define WMM_XMIT_THRESHOLD (NR_XMITFRAME*2/5) + +void rtw_os_pkt_complete(struct adapter *padapter, struct sk_buff *pkt) +{ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)) + u16 queue; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + + queue = skb_get_queue_mapping(pkt); + if (padapter->registrypriv.wifi_spec) { + if (__netif_subqueue_stopped(padapter->pnetdev, queue) && + (pxmitpriv->hwxmits[queue].accnt < WMM_XMIT_THRESHOLD)) + netif_wake_subqueue(padapter->pnetdev, queue); + } else { + if (__netif_subqueue_stopped(padapter->pnetdev, queue)) + netif_wake_subqueue(padapter->pnetdev, queue); + } +#else + if (netif_queue_stopped(padapter->pnetdev)) + netif_wake_queue(padapter->pnetdev); +#endif + + dev_kfree_skb_any(pkt); +} + +void rtw_os_xmit_complete(struct adapter *padapter, struct xmit_frame *pxframe) +{ + if (pxframe->pkt) + rtw_os_pkt_complete(padapter, pxframe->pkt); + pxframe->pkt = NULL; +} + +void rtw_os_xmit_schedule(struct adapter *padapter) +{ + unsigned long irql; + struct xmit_priv *pxmitpriv; + + if (!padapter) + return; + + pxmitpriv = &padapter->xmitpriv; + + _enter_critical_bh(&pxmitpriv->lock, &irql); + + if (rtw_txframes_pending(padapter)) + tasklet_hi_schedule(&pxmitpriv->xmit_tasklet); + + _exit_critical_bh(&pxmitpriv->lock, &irql); +} + +static void rtw_check_xmit_resource(struct adapter *padapter, struct sk_buff *pkt) +{ + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + u16 queue; + + queue = skb_get_queue_mapping(pkt); + if (padapter->registrypriv.wifi_spec) { + /* No free space for Tx, tx_worker is too slow */ + if (pxmitpriv->hwxmits[queue].accnt > WMM_XMIT_THRESHOLD) + netif_stop_subqueue(padapter->pnetdev, queue); + } else { + if (pxmitpriv->free_xmitframe_cnt <= 4) { + if (!netif_tx_queue_stopped(netdev_get_tx_queue(padapter->pnetdev, queue))) + netif_stop_subqueue(padapter->pnetdev, queue); + } + } +} + +static int rtw_mlcst2unicst(struct adapter *padapter, struct sk_buff *skb) +{ + struct sta_priv *pstapriv = &padapter->stapriv; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + unsigned long irql; + struct list_head *phead, *plist; + struct sk_buff *newskb; + struct sta_info *psta = NULL; + s32 res; + + _enter_critical_bh(&pstapriv->asoc_list_lock, &irql); + phead = &pstapriv->asoc_list; + plist = get_next(phead); + + /* free sta asoc_queue */ + while (!rtw_end_of_queue_search(phead, plist)) { + psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); + + plist = get_next(plist); + + /* avoid come from STA1 and send back STA1 */ + if (!memcmp(psta->hwaddr, &skb->data[6], 6)) + continue; + + newskb = skb_copy(skb, GFP_ATOMIC); + + if (newskb) { + memcpy(newskb->data, psta->hwaddr, 6); + res = rtw_xmit(padapter, &newskb); + if (res < 0) { + DBG_88E("%s()-%d: rtw_xmit() return error!\n", __func__, __LINE__); + pxmitpriv->tx_drop++; + dev_kfree_skb_any(newskb); + } else { + pxmitpriv->tx_pkts++; + } + } else { + DBG_88E("%s-%d: skb_copy() failed!\n", __func__, __LINE__); + pxmitpriv->tx_drop++; + + _exit_critical_bh(&pstapriv->asoc_list_lock, &irql); + return false; /* Caller shall tx this multicast frame via normal way. */ + } + } + + _exit_critical_bh(&pstapriv->asoc_list_lock, &irql); + dev_kfree_skb_any(skb); + return true; +} + + +int rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + s32 res = 0; + +_func_enter_; + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("+xmit_enry\n")); + + if (rtw_if_up(padapter) == false) { + RT_TRACE(_module_xmit_osdep_c_, _drv_err_, ("rtw_xmit_entry: rtw_if_up fail\n")); + goto drop_packet; + } + + rtw_check_xmit_resource(padapter, pkt); + + if (!rtw_mc2u_disable && check_fwstate(pmlmepriv, WIFI_AP_STATE) && + (IP_MCAST_MAC(pkt->data) || ICMPV6_MCAST_MAC(pkt->data)) && + (padapter->registrypriv.wifi_spec == 0)) { + if (pxmitpriv->free_xmitframe_cnt > (NR_XMITFRAME/4)) { + res = rtw_mlcst2unicst(padapter, pkt); + if (res) + goto exit; + } + } + + res = rtw_xmit(padapter, &pkt); + if (res < 0) + goto drop_packet; + + pxmitpriv->tx_pkts++; + RT_TRACE(_module_xmit_osdep_c_, _drv_info_, ("rtw_xmit_entry: tx_pkts=%d\n", (u32)pxmitpriv->tx_pkts)); + goto exit; + +drop_packet: + pxmitpriv->tx_drop++; + dev_kfree_skb_any(pkt); + RT_TRACE(_module_xmit_osdep_c_, _drv_notice_, ("rtw_xmit_entry: drop, tx_drop=%d\n", (u32)pxmitpriv->tx_drop)); + +exit: + +_func_exit_; + + return 0; +} -- GitLab From a7c947b7f3a4e120e7baadfe7a3b3675088100fe Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 21 Aug 2013 22:34:03 -0500 Subject: [PATCH 779/942] staging: r8188eu: Add files for new driver - part 21 This commit adds files include/autoconf.h, include/basic_types.h, include/cmd_osdep.h, include/drv_types.h, include/drv_types_linux.h, include/ethernet.h. include/h2clbk.h, include/hal_com.h, and include/hal_intf.h. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/autoconf.h | 43 ++ .../staging/rtl8188eu/include/basic_types.h | 184 ++++++++ drivers/staging/rtl8188eu/include/cmd_osdep.h | 32 ++ drivers/staging/rtl8188eu/include/drv_types.h | 335 ++++++++++++++ .../rtl8188eu/include/drv_types_linux.h | 24 + drivers/staging/rtl8188eu/include/ethernet.h | 42 ++ drivers/staging/rtl8188eu/include/h2clbk.h | 35 ++ drivers/staging/rtl8188eu/include/hal_com.h | 173 +++++++ drivers/staging/rtl8188eu/include/hal_intf.h | 426 ++++++++++++++++++ 9 files changed, 1294 insertions(+) create mode 100644 drivers/staging/rtl8188eu/include/autoconf.h create mode 100644 drivers/staging/rtl8188eu/include/basic_types.h create mode 100644 drivers/staging/rtl8188eu/include/cmd_osdep.h create mode 100644 drivers/staging/rtl8188eu/include/drv_types.h create mode 100644 drivers/staging/rtl8188eu/include/drv_types_linux.h create mode 100644 drivers/staging/rtl8188eu/include/ethernet.h create mode 100644 drivers/staging/rtl8188eu/include/h2clbk.h create mode 100644 drivers/staging/rtl8188eu/include/hal_com.h create mode 100644 drivers/staging/rtl8188eu/include/hal_intf.h diff --git a/drivers/staging/rtl8188eu/include/autoconf.h b/drivers/staging/rtl8188eu/include/autoconf.h new file mode 100644 index 0000000000000..8c81eef008d5d --- /dev/null +++ b/drivers/staging/rtl8188eu/include/autoconf.h @@ -0,0 +1,43 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +/* temporarily flag ******* */ +/* + * Public General Config + */ +#define RTL871X_MODULE_NAME "88EU" +#define DRV_NAME "rtl8188eu" + +/* + * Internal General Config + */ + +#define CONFIG_88EU_AP_MODE + +#define CONFIG_88EU_P2P + +#define RTW_NOTCH_FILTER 0 /* 0:Disable, 1:Enable, */ + +#define CONFIG_BR_EXT_BRNAME "br0" + +/* + * Debug Related Config + */ +#define DBG 1 diff --git a/drivers/staging/rtl8188eu/include/basic_types.h b/drivers/staging/rtl8188eu/include/basic_types.h new file mode 100644 index 0000000000000..8a7ca992674aa --- /dev/null +++ b/drivers/staging/rtl8188eu/include/basic_types.h @@ -0,0 +1,184 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __BASIC_TYPES_H__ +#define __BASIC_TYPES_H__ + +#define SUCCESS 0 +#define FAIL (-1) + +#include +#define NDIS_OID uint + +typedef void (*proc_t)(void *); + +#define FIELD_OFFSET(s, field) ((ssize_t)&((s *)(0))->field) + +#define MEM_ALIGNMENT_OFFSET (sizeof(size_t)) +#define MEM_ALIGNMENT_PADDING (sizeof(size_t) - 1) + +/* port from fw */ +/* TODO: Macros Below are Sync from SD7-Driver. It is necessary + * to check correctness */ + +/* + * Call endian free function when + * 1. Read/write packet content. + * 2. Before write integer to IO. + * 3. After read integer from IO. +*/ + +/* Convert little data endian to host ordering */ +#define EF1BYTE(_val) \ + ((u8)(_val)) +#define EF2BYTE(_val) \ + (le16_to_cpu(_val)) +#define EF4BYTE(_val) \ + (le32_to_cpu(_val)) + +/* Read data from memory */ +#define READEF1BYTE(_ptr) \ + EF1BYTE(*((u8 *)(_ptr))) +/* Read le16 data from memory and convert to host ordering */ +#define READEF2BYTE(_ptr) \ + EF2BYTE(*(_ptr)) +#define READEF4BYTE(_ptr) \ + EF4BYTE(*(_ptr)) + +/* Write data to memory */ +#define WRITEEF1BYTE(_ptr, _val) \ + do { \ + (*((u8 *)(_ptr))) = EF1BYTE(_val) \ + } while (0) +/* Write le data to memory in host ordering */ +#define WRITEEF2BYTE(_ptr, _val) \ + do { \ + (*((u16 *)(_ptr))) = EF2BYTE(_val) \ + } while (0) + +#define WRITEEF4BYTE(_ptr, _val) \ + do { \ + (*((u32 *)(_ptr))) = EF2BYTE(_val) \ + } while (0) + +/* Create a bit mask + * Examples: + * BIT_LEN_MASK_32(0) => 0x00000000 + * BIT_LEN_MASK_32(1) => 0x00000001 + * BIT_LEN_MASK_32(2) => 0x00000003 + * BIT_LEN_MASK_32(32) => 0xFFFFFFFF + */ +#define BIT_LEN_MASK_32(__bitlen) \ + (0xFFFFFFFF >> (32 - (__bitlen))) +#define BIT_LEN_MASK_16(__bitlen) \ + (0xFFFF >> (16 - (__bitlen))) +#define BIT_LEN_MASK_8(__bitlen) \ + (0xFF >> (8 - (__bitlen))) + +/* Create an offset bit mask + * Examples: + * BIT_OFFSET_LEN_MASK_32(0, 2) => 0x00000003 + * BIT_OFFSET_LEN_MASK_32(16, 2) => 0x00030000 + */ +#define BIT_OFFSET_LEN_MASK_32(__bitoffset, __bitlen) \ + (BIT_LEN_MASK_32(__bitlen) << (__bitoffset)) +#define BIT_OFFSET_LEN_MASK_16(__bitoffset, __bitlen) \ + (BIT_LEN_MASK_16(__bitlen) << (__bitoffset)) +#define BIT_OFFSET_LEN_MASK_8(__bitoffset, __bitlen) \ + (BIT_LEN_MASK_8(__bitlen) << (__bitoffset)) + +/*Description: + * Return 4-byte value in host byte ordering from + * 4-byte pointer in little-endian system. + */ +#define LE_P4BYTE_TO_HOST_4BYTE(__pstart) \ + (EF4BYTE(*((__le32 *)(__pstart)))) +#define LE_P2BYTE_TO_HOST_2BYTE(__pstart) \ + (EF2BYTE(*((__le16 *)(__pstart)))) +#define LE_P1BYTE_TO_HOST_1BYTE(__pstart) \ + (EF1BYTE(*((u8 *)(__pstart)))) + +/*Description: +Translate subfield (continuous bits in little-endian) of 4-byte +value to host byte ordering.*/ +#define LE_BITS_TO_4BYTE(__pstart, __bitoffset, __bitlen) \ + ( \ + (LE_P4BYTE_TO_HOST_4BYTE(__pstart) >> (__bitoffset)) & \ + BIT_LEN_MASK_32(__bitlen) \ + ) +#define LE_BITS_TO_2BYTE(__pstart, __bitoffset, __bitlen) \ + ( \ + (LE_P2BYTE_TO_HOST_2BYTE(__pstart) >> (__bitoffset)) & \ + BIT_LEN_MASK_16(__bitlen) \ + ) +#define LE_BITS_TO_1BYTE(__pstart, __bitoffset, __bitlen) \ + ( \ + (LE_P1BYTE_TO_HOST_1BYTE(__pstart) >> (__bitoffset)) & \ + BIT_LEN_MASK_8(__bitlen) \ + ) + +/* Description: + * Mask subfield (continuous bits in little-endian) of 4-byte value + * and return the result in 4-byte value in host byte ordering. + */ +#define LE_BITS_CLEARED_TO_4BYTE(__pstart, __bitoffset, __bitlen) \ + ( \ + LE_P4BYTE_TO_HOST_4BYTE(__pstart) & \ + (~BIT_OFFSET_LEN_MASK_32(__bitoffset, __bitlen)) \ + ) +#define LE_BITS_CLEARED_TO_2BYTE(__pstart, __bitoffset, __bitlen) \ + ( \ + LE_P2BYTE_TO_HOST_2BYTE(__pstart) & \ + (~BIT_OFFSET_LEN_MASK_16(__bitoffset, __bitlen)) \ + ) +#define LE_BITS_CLEARED_TO_1BYTE(__pstart, __bitoffset, __bitlen) \ + ( \ + LE_P1BYTE_TO_HOST_1BYTE(__pstart) & \ + (~BIT_OFFSET_LEN_MASK_8(__bitoffset, __bitlen)) \ + ) + +/* Description: + * Set subfield of little-endian 4-byte value to specified value. + */ +#define SET_BITS_TO_LE_4BYTE(__pstart, __bitoffset, __bitlen, __val) \ + *((u32 *)(__pstart)) = \ + ( \ + LE_BITS_CLEARED_TO_4BYTE(__pstart, __bitoffset, __bitlen) | \ + ((((u32)__val) & BIT_LEN_MASK_32(__bitlen)) << (__bitoffset)) \ + ) + +#define SET_BITS_TO_LE_2BYTE(__pstart, __bitoffset, __bitlen, __val) \ + *((u16 *)(__pstart)) = \ + ( \ + LE_BITS_CLEARED_TO_2BYTE(__pstart, __bitoffset, __bitlen) | \ + ((((u16)__val) & BIT_LEN_MASK_16(__bitlen)) << (__bitoffset)) \ + ); + +#define SET_BITS_TO_LE_1BYTE(__pstart, __bitoffset, __bitlen, __val) \ + *((u8 *)(__pstart)) = EF1BYTE \ + ( \ + LE_BITS_CLEARED_TO_1BYTE(__pstart, __bitoffset, __bitlen) | \ + ((((u8)__val) & BIT_LEN_MASK_8(__bitlen)) << (__bitoffset)) \ + ) + +/* Get the N-bytes aligment offset from the current length */ +#define N_BYTE_ALIGMENT(__value, __aligment) ((__aligment == 1) ? \ + (__value) : (((__value + __aligment - 1) / __aligment) * __aligment)) + +#endif /* __BASIC_TYPES_H__ */ diff --git a/drivers/staging/rtl8188eu/include/cmd_osdep.h b/drivers/staging/rtl8188eu/include/cmd_osdep.h new file mode 100644 index 0000000000000..5a8465e147b32 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/cmd_osdep.h @@ -0,0 +1,32 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __CMD_OSDEP_H_ +#define __CMD_OSDEP_H_ + +#include +#include + +extern int _rtw_init_cmd_priv(struct cmd_priv *pcmdpriv); +extern int _rtw_init_evt_priv(struct evt_priv *pevtpriv); +extern void _rtw_free_cmd_priv(struct cmd_priv *pcmdpriv); +extern int _rtw_enqueue_cmd(struct __queue *queue, struct cmd_obj *obj); +extern struct cmd_obj *_rtw_dequeue_cmd(struct __queue *queue); + +#endif diff --git a/drivers/staging/rtl8188eu/include/drv_types.h b/drivers/staging/rtl8188eu/include/drv_types.h new file mode 100644 index 0000000000000..6e49359a182d9 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/drv_types.h @@ -0,0 +1,335 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +/*----------------------------------------------------------------------------- + + For type defines and data structure defines + +------------------------------------------------------------------------------*/ + + +#ifndef __DRV_TYPES_H__ +#define __DRV_TYPES_H__ + +#define DRV_NAME "r8188eu" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +enum _NIC_VERSION { + RTL8711_NIC, + RTL8712_NIC, + RTL8713_NIC, + RTL8716_NIC +}; + +#define SPEC_DEV_ID_NONE BIT(0) +#define SPEC_DEV_ID_DISABLE_HT BIT(1) +#define SPEC_DEV_ID_ENABLE_PS BIT(2) +#define SPEC_DEV_ID_RF_CONFIG_1T1R BIT(3) +#define SPEC_DEV_ID_RF_CONFIG_2T2R BIT(4) +#define SPEC_DEV_ID_ASSIGN_IFNAME BIT(5) + +struct specific_device_id { + u32 flags; + u16 idVendor; + u16 idProduct; +}; + +struct registry_priv { + u8 chip_version; + u8 rfintfs; + u8 lbkmode; + u8 hci; + struct ndis_802_11_ssid ssid; + u8 network_mode; /* infra, ad-hoc, auto */ + u8 channel;/* ad-hoc support requirement */ + u8 wireless_mode;/* A, B, G, auto */ + u8 scan_mode;/* active, passive */ + u8 radio_enable; + u8 preamble;/* long, short, auto */ + u8 vrtl_carrier_sense;/* Enable, Disable, Auto */ + u8 vcs_type;/* RTS/CTS, CTS-to-self */ + u16 rts_thresh; + u16 frag_thresh; + u8 adhoc_tx_pwr; + u8 soft_ap; + u8 power_mgnt; + u8 ips_mode; + u8 smart_ps; + u8 long_retry_lmt; + u8 short_retry_lmt; + u16 busy_thresh; + u8 ack_policy; + u8 mp_mode; + u8 software_encrypt; + u8 software_decrypt; + u8 acm_method; + /* UAPSD */ + u8 wmm_enable; + u8 uapsd_enable; + u8 uapsd_max_sp; + u8 uapsd_acbk_en; + u8 uapsd_acbe_en; + u8 uapsd_acvi_en; + u8 uapsd_acvo_en; + + struct wlan_bssid_ex dev_network; + + u8 ht_enable; + u8 cbw40_enable; + u8 ampdu_enable;/* for tx */ + u8 rx_stbc; + u8 ampdu_amsdu;/* A-MPDU Supports A-MSDU is permitted */ + u8 lowrate_two_xmit; + + u8 rf_config; + u8 low_power; + + u8 wifi_spec;/* !turbo_mode */ + + u8 channel_plan; + bool bAcceptAddbaReq; + + u8 antdiv_cfg; + u8 antdiv_type; + + u8 usbss_enable;/* 0:disable,1:enable */ + u8 hwpdn_mode;/* 0:disable,1:enable,2:decide by EFUSE config */ + u8 hwpwrp_detect;/* 0:disable,1:enable */ + + u8 hw_wps_pbc;/* 0:disable,1:enable */ + + u8 max_roaming_times; /* the max number driver will try */ + + u8 fw_iol; /* enable iol without other concern */ + + u8 enable80211d; + + u8 ifname[16]; + u8 if2name[16]; + + u8 notch_filter; +}; + +/* For registry parameters */ +#define RGTRY_OFT(field) ((u32)FIELD_OFFSET(struct registry_priv, field)) +#define RGTRY_SZ(field) sizeof(((struct registry_priv *)0)->field) +#define BSSID_OFT(field) ((u32)FIELD_OFFSET(struct wlan_bssid_ex, field)) +#define BSSID_SZ(field) sizeof(((struct wlan_bssid_ex *)0)->field) + +#define MAX_CONTINUAL_URB_ERR 4 + +struct dvobj_priv { + struct adapter *if1; + struct adapter *if2; + + /* For 92D, DMDP have 2 interface. */ + u8 InterfaceNumber; + u8 NumInterfaces; + + /* In /Out Pipe information */ + int RtInPipe[2]; + int RtOutPipe[3]; + u8 Queue2Pipe[HW_QUEUE_ENTRY];/* for out pipe mapping */ + + u8 irq_alloc; + +/*-------- below is for USB INTERFACE --------*/ + + u8 nr_endpoint; + u8 ishighspeed; + u8 RtNumInPipes; + u8 RtNumOutPipes; + int ep_num[5]; /* endpoint number */ + int RegUsbSS; + struct semaphore usb_suspend_sema; + struct mutex usb_vendor_req_mutex; + + u8 *usb_alloc_vendor_req_buf; + u8 *usb_vendor_req_buf; + + struct usb_interface *pusbintf; + struct usb_device *pusbdev; + + ATOMIC_T continual_urb_error; +}; + +static inline struct device *dvobj_to_dev(struct dvobj_priv *dvobj) +{ + /* todo: get interface type from dvobj and the return + * the dev accordingly */ + return &dvobj->pusbintf->dev; +}; + +enum _IFACE_TYPE { + IFACE_PORT0, /* mapping to port0 for C/D series chips */ + IFACE_PORT1, /* mapping to port1 for C/D series chip */ + MAX_IFACE_PORT, +}; + +enum _ADAPTER_TYPE { + PRIMARY_ADAPTER, + SECONDARY_ADAPTER, + MAX_ADAPTER, +}; + +enum driver_state { + DRIVER_NORMAL = 0, + DRIVER_DISAPPEAR = 1, + DRIVER_REPLACE_DONGLE = 2, +}; + +struct adapter { + int DriverState;/* for disable driver using module, use dongle toi + * replace module. */ + int pid[3];/* process id from UI, 0:wps, 1:hostapd, 2:dhcpcd */ + int bDongle;/* build-in module or external dongle */ + u16 chip_type; + u16 HardwareType; + u16 interface_type;/* USB,SDIO,SPI,PCI */ + + struct dvobj_priv *dvobj; + struct mlme_priv mlmepriv; + struct mlme_ext_priv mlmeextpriv; + struct cmd_priv cmdpriv; + struct evt_priv evtpriv; + struct io_priv iopriv; + struct xmit_priv xmitpriv; + struct recv_priv recvpriv; + struct sta_priv stapriv; + struct security_priv securitypriv; + struct registry_priv registrypriv; + struct pwrctrl_priv pwrctrlpriv; + struct eeprom_priv eeprompriv; + struct led_priv ledpriv; + struct mp_priv mppriv; + +#ifdef CONFIG_88EU_AP_MODE + struct hostapd_priv *phostapdpriv; +#endif + + struct wifidirect_info wdinfo; + + void *HalData; + u32 hal_data_sz; + struct hal_ops HalFunc; + + s32 bDriverStopped; + s32 bSurpriseRemoved; + s32 bCardDisableWOHSM; + + u32 IsrContent; + u32 ImrContent; + + u8 EepromAddressSize; + u8 hw_init_completed; + u8 bDriverIsGoingToUnload; + u8 init_adpt_in_progress; + u8 bHaltInProgress; + + void *cmdThread; + void *evtThread; + void *xmitThread; + void *recvThread; + void (*intf_start)(struct adapter *adapter); + void (*intf_stop)(struct adapter *adapter); + struct net_device *pnetdev; + + /* used by rtw_rereg_nd_name related function */ + struct rereg_nd_name_data { + struct net_device *old_pnetdev; + char old_ifname[IFNAMSIZ]; + u8 old_ips_mode; + u8 old_bRegUseLed; + } rereg_nd_name_priv; + + int bup; + struct net_device_stats stats; + struct iw_statistics iwstats; + struct proc_dir_entry *dir_dev;/* for proc directory */ + + int net_closed; + u8 bFWReady; + u8 bBTFWReady; + u8 bReadPortCancel; + u8 bWritePortCancel; + u8 bRxRSSIDisplay; + /* The driver will show up the desired channel number + * when this flag is 1. */ + u8 bNotifyChannelChange; +#ifdef CONFIG_88EU_P2P + /* The driver will show the current P2P status when the + * upper application reads it. */ + u8 bShowGetP2PState; +#endif + struct adapter *pbuddy_adapter; + + struct mutex *hw_init_mutex; + + spinlock_t br_ext_lock; + struct nat25_network_db_entry *nethash[NAT25_HASH_SIZE]; + int pppoe_connection_in_progress; + unsigned char pppoe_addr[MACADDRLEN]; + unsigned char scdb_mac[MACADDRLEN]; + unsigned char scdb_ip[4]; + struct nat25_network_db_entry *scdb_entry; + unsigned char br_mac[MACADDRLEN]; + unsigned char br_ip[4]; + struct br_ext_info ethBrExtInfo; + + u8 fix_rate; + + unsigned char in_cta_test; +}; + +#define adapter_to_dvobj(adapter) (adapter->dvobj) + +int rtw_handle_dualmac(struct adapter *adapter, bool init); + +static inline u8 *myid(struct eeprom_priv *peepriv) +{ + return peepriv->mac_addr; +} + +#endif /* __DRV_TYPES_H__ */ diff --git a/drivers/staging/rtl8188eu/include/drv_types_linux.h b/drivers/staging/rtl8188eu/include/drv_types_linux.h new file mode 100644 index 0000000000000..812b7440d4b00 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/drv_types_linux.h @@ -0,0 +1,24 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __DRV_TYPES_LINUX_H__ +#define __DRV_TYPES_LINUX_H__ + + +#endif diff --git a/drivers/staging/rtl8188eu/include/ethernet.h b/drivers/staging/rtl8188eu/include/ethernet.h new file mode 100644 index 0000000000000..a59f9120cd7e7 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/ethernet.h @@ -0,0 +1,42 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +/*! \file */ +#ifndef __INC_ETHERNET_H +#define __INC_ETHERNET_H + +#define ETHERNET_ADDRESS_LENGTH 6 /* Ethernet Address Length */ +#define ETHERNET_HEADER_SIZE 14 /* Ethernet Header Length */ +#define LLC_HEADER_SIZE 6 /* LLC Header Length */ +#define TYPE_LENGTH_FIELD_SIZE 2 /* Type/Length Size */ +#define MINIMUM_ETHERNET_PACKET_SIZE 60 /* Min Ethernet Packet Size */ +#define MAXIMUM_ETHERNET_PACKET_SIZE 1514 /* Max Ethernet Packet Size */ + +/* Is Multicast Address? */ +#define RT_ETH_IS_MULTICAST(_addr) ((((u8 *)(_addr))[0]&0x01) != 0) +#define RT_ETH_IS_BROADCAST(_addr) ( \ + ((u8 *)(_addr))[0] == 0xff && \ + ((u8 *)(_addr))[1] == 0xff && \ + ((u8 *)(_addr))[2] == 0xff && \ + ((u8 *)(_addr))[3] == 0xff && \ + ((u8 *)(_addr))[4] == 0xff && \ + ((u8 *)(_addr))[5] == 0xff) /* Is Broadcast Address? */ + + +#endif /* #ifndef __INC_ETHERNET_H */ diff --git a/drivers/staging/rtl8188eu/include/h2clbk.h b/drivers/staging/rtl8188eu/include/h2clbk.h new file mode 100644 index 0000000000000..e595030ac8a32 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/h2clbk.h @@ -0,0 +1,35 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + + +#define _H2CLBK_H_ + + +#include +#include + + +void _lbk_cmd(struct adapter *adapter); + +void _lbk_rsp(struct adapter *adapter); + +void _lbk_evt(IN struct adapter *adapter); + +void h2c_event_callback(unsigned char *dev, unsigned char *pbuf); diff --git a/drivers/staging/rtl8188eu/include/hal_com.h b/drivers/staging/rtl8188eu/include/hal_com.h new file mode 100644 index 0000000000000..81c27090dd52c --- /dev/null +++ b/drivers/staging/rtl8188eu/include/hal_com.h @@ -0,0 +1,173 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __HAL_COMMON_H__ +#define __HAL_COMMON_H__ + +/* */ +/* Rate Definition */ +/* */ +/* CCK */ +#define RATR_1M 0x00000001 +#define RATR_2M 0x00000002 +#define RATR_55M 0x00000004 +#define RATR_11M 0x00000008 +/* OFDM */ +#define RATR_6M 0x00000010 +#define RATR_9M 0x00000020 +#define RATR_12M 0x00000040 +#define RATR_18M 0x00000080 +#define RATR_24M 0x00000100 +#define RATR_36M 0x00000200 +#define RATR_48M 0x00000400 +#define RATR_54M 0x00000800 +/* MCS 1 Spatial Stream */ +#define RATR_MCS0 0x00001000 +#define RATR_MCS1 0x00002000 +#define RATR_MCS2 0x00004000 +#define RATR_MCS3 0x00008000 +#define RATR_MCS4 0x00010000 +#define RATR_MCS5 0x00020000 +#define RATR_MCS6 0x00040000 +#define RATR_MCS7 0x00080000 +/* MCS 2 Spatial Stream */ +#define RATR_MCS8 0x00100000 +#define RATR_MCS9 0x00200000 +#define RATR_MCS10 0x00400000 +#define RATR_MCS11 0x00800000 +#define RATR_MCS12 0x01000000 +#define RATR_MCS13 0x02000000 +#define RATR_MCS14 0x04000000 +#define RATR_MCS15 0x08000000 + +/* CCK */ +#define RATE_1M BIT(0) +#define RATE_2M BIT(1) +#define RATE_5_5M BIT(2) +#define RATE_11M BIT(3) +/* OFDM */ +#define RATE_6M BIT(4) +#define RATE_9M BIT(5) +#define RATE_12M BIT(6) +#define RATE_18M BIT(7) +#define RATE_24M BIT(8) +#define RATE_36M BIT(9) +#define RATE_48M BIT(10) +#define RATE_54M BIT(11) +/* MCS 1 Spatial Stream */ +#define RATE_MCS0 BIT(12) +#define RATE_MCS1 BIT(13) +#define RATE_MCS2 BIT(14) +#define RATE_MCS3 BIT(15) +#define RATE_MCS4 BIT(16) +#define RATE_MCS5 BIT(17) +#define RATE_MCS6 BIT(18) +#define RATE_MCS7 BIT(19) +/* MCS 2 Spatial Stream */ +#define RATE_MCS8 BIT(20) +#define RATE_MCS9 BIT(21) +#define RATE_MCS10 BIT(22) +#define RATE_MCS11 BIT(23) +#define RATE_MCS12 BIT(24) +#define RATE_MCS13 BIT(25) +#define RATE_MCS14 BIT(26) +#define RATE_MCS15 BIT(27) + +/* ALL CCK Rate */ +#define RATE_ALL_CCK (RATR_1M | RATR_2M | RATR_55M | RATR_11M) +#define RATE_ALL_OFDM_AG (RATR_6M | RATR_9M | RATR_12M | RATR_18M | \ + RATR_24M | RATR_36M | RATR_48M | RATR_54M) +#define RATE_ALL_OFDM_1SS (RATR_MCS0 | RATR_MCS1 | RATR_MCS2 | \ + RATR_MCS3 | RATR_MCS4 | RATR_MCS5|RATR_MCS6 | \ + RATR_MCS7) +#define RATE_ALL_OFDM_2SS (RATR_MCS8 | RATR_MCS9 | RATR_MCS10 | \ + RATR_MCS11 | RATR_MCS12 | RATR_MCS13 | \ + RATR_MCS14 | RATR_MCS15) + +/*------------------------------ Tx Desc definition Macro --------------------*/ +/* pragma mark -- Tx Desc related definition. -- */ +/* Rate */ +/* CCK Rates, TxHT = 0 */ +#define DESC_RATE1M 0x00 +#define DESC_RATE2M 0x01 +#define DESC_RATE5_5M 0x02 +#define DESC_RATE11M 0x03 + +/* OFDM Rates, TxHT = 0 */ +#define DESC_RATE6M 0x04 +#define DESC_RATE9M 0x05 +#define DESC_RATE12M 0x06 +#define DESC_RATE18M 0x07 +#define DESC_RATE24M 0x08 +#define DESC_RATE36M 0x09 +#define DESC_RATE48M 0x0a +#define DESC_RATE54M 0x0b + +/* MCS Rates, TxHT = 1 */ +#define DESC_RATEMCS0 0x0c +#define DESC_RATEMCS1 0x0d +#define DESC_RATEMCS2 0x0e +#define DESC_RATEMCS3 0x0f +#define DESC_RATEMCS4 0x10 +#define DESC_RATEMCS5 0x11 +#define DESC_RATEMCS6 0x12 +#define DESC_RATEMCS7 0x13 +#define DESC_RATEMCS8 0x14 +#define DESC_RATEMCS9 0x15 +#define DESC_RATEMCS10 0x16 +#define DESC_RATEMCS11 0x17 +#define DESC_RATEMCS12 0x18 +#define DESC_RATEMCS13 0x19 +#define DESC_RATEMCS14 0x1a +#define DESC_RATEMCS15 0x1b +#define DESC_RATEMCS15_SG 0x1c +#define DESC_RATEMCS32 0x20 + +/* 1 Byte long (in unit of TU) */ +#define REG_P2P_CTWIN 0x0572 +#define REG_NOA_DESC_SEL 0x05CF +#define REG_NOA_DESC_DURATION 0x05E0 +#define REG_NOA_DESC_INTERVAL 0x05E4 +#define REG_NOA_DESC_START 0x05E8 +#define REG_NOA_DESC_COUNT 0x05EC + +#include "HalVerDef.h" +void dump_chip_info(struct HAL_VERSION ChipVersion); + + +/* return the final channel plan decision */ +u8 hal_com_get_channel_plan(struct adapter *padapter, + u8 hw_channel_plan, + u8 sw_channel_plan, + u8 def_channel_plan, + bool AutoLoadFail +); + +u8 MRateToHwRate(u8 rate); + +void HalSetBrateCfg(struct adapter *Adapter, u8 *mBratesOS, u16 *pBrateCfg); + +bool Hal_MappingOutPipe(struct adapter *pAdapter, u8 NumOutPipe); + +void hal_init_macaddr(struct adapter *adapter); + +void c2h_evt_clear(struct adapter *adapter); +s32 c2h_evt_read(struct adapter *adapter, u8 *buf); + +#endif /* __HAL_COMMON_H__ */ diff --git a/drivers/staging/rtl8188eu/include/hal_intf.h b/drivers/staging/rtl8188eu/include/hal_intf.h new file mode 100644 index 0000000000000..439c3c941ba19 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/hal_intf.h @@ -0,0 +1,426 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __HAL_INTF_H__ +#define __HAL_INTF_H__ + +#include +#include +#include + +enum RTL871X_HCI_TYPE { + RTW_PCIE = BIT0, + RTW_USB = BIT1, + RTW_SDIO = BIT2, + RTW_GSPI = BIT3, +}; + +enum _CHIP_TYPE { + NULL_CHIP_TYPE, + RTL8712_8188S_8191S_8192S, + RTL8188C_8192C, + RTL8192D, + RTL8723A, + RTL8188E, + MAX_CHIP_TYPE +}; + +enum hw_variables { + HW_VAR_MEDIA_STATUS, + HW_VAR_MEDIA_STATUS1, + HW_VAR_SET_OPMODE, + HW_VAR_MAC_ADDR, + HW_VAR_BSSID, + HW_VAR_INIT_RTS_RATE, + HW_VAR_BASIC_RATE, + HW_VAR_TXPAUSE, + HW_VAR_BCN_FUNC, + HW_VAR_CORRECT_TSF, + HW_VAR_CHECK_BSSID, + HW_VAR_MLME_DISCONNECT, + HW_VAR_MLME_SITESURVEY, + HW_VAR_MLME_JOIN, + HW_VAR_BEACON_INTERVAL, + HW_VAR_SLOT_TIME, + HW_VAR_RESP_SIFS, + HW_VAR_ACK_PREAMBLE, + HW_VAR_SEC_CFG, + HW_VAR_BCN_VALID, + HW_VAR_RF_TYPE, + HW_VAR_DM_FLAG, + HW_VAR_DM_FUNC_OP, + HW_VAR_DM_FUNC_SET, + HW_VAR_DM_FUNC_CLR, + HW_VAR_CAM_EMPTY_ENTRY, + HW_VAR_CAM_INVALID_ALL, + HW_VAR_CAM_WRITE, + HW_VAR_CAM_READ, + HW_VAR_AC_PARAM_VO, + HW_VAR_AC_PARAM_VI, + HW_VAR_AC_PARAM_BE, + HW_VAR_AC_PARAM_BK, + HW_VAR_ACM_CTRL, + HW_VAR_AMPDU_MIN_SPACE, + HW_VAR_AMPDU_FACTOR, + HW_VAR_RXDMA_AGG_PG_TH, + HW_VAR_SET_RPWM, + HW_VAR_H2C_FW_PWRMODE, + HW_VAR_H2C_FW_JOINBSSRPT, + HW_VAR_FWLPS_RF_ON, + HW_VAR_H2C_FW_P2P_PS_OFFLOAD, + HW_VAR_TDLS_WRCR, + HW_VAR_TDLS_INIT_CH_SEN, + HW_VAR_TDLS_RS_RCR, + HW_VAR_TDLS_DONE_CH_SEN, + HW_VAR_INITIAL_GAIN, + HW_VAR_TRIGGER_GPIO_0, + HW_VAR_BT_SET_COEXIST, + HW_VAR_BT_ISSUE_DELBA, + HW_VAR_CURRENT_ANTENNA, + HW_VAR_ANTENNA_DIVERSITY_LINK, + HW_VAR_ANTENNA_DIVERSITY_SELECT, + HW_VAR_SWITCH_EPHY_WoWLAN, + HW_VAR_EFUSE_USAGE, + HW_VAR_EFUSE_BYTES, + HW_VAR_EFUSE_BT_USAGE, + HW_VAR_EFUSE_BT_BYTES, + HW_VAR_FIFO_CLEARN_UP, + HW_VAR_CHECK_TXBUF, + HW_VAR_APFM_ON_MAC, /* Auto FSM to Turn On, include clock, isolation, + * power control for MAC only */ + /* The valid upper nav range for the HW updating, if the true value is + * larger than the upper range, the HW won't update it. */ + /* Unit in microsecond. 0 means disable this function. */ + HW_VAR_NAV_UPPER, + HW_VAR_RPT_TIMER_SETTING, + HW_VAR_TX_RPT_MAX_MACID, + HW_VAR_H2C_MEDIA_STATUS_RPT, + HW_VAR_CHK_HI_QUEUE_EMPTY, +}; + +enum hal_def_variable { + HAL_DEF_UNDERCORATEDSMOOTHEDPWDB, + HAL_DEF_IS_SUPPORT_ANT_DIV, + HAL_DEF_CURRENT_ANTENNA, + HAL_DEF_DRVINFO_SZ, + HAL_DEF_MAX_RECVBUF_SZ, + HAL_DEF_RX_PACKET_OFFSET, + HAL_DEF_DBG_DUMP_RXPKT,/* for dbg */ + HAL_DEF_DBG_DM_FUNC,/* for dbg */ + HAL_DEF_RA_DECISION_RATE, + HAL_DEF_RA_SGI, + HAL_DEF_PT_PWR_STATUS, + HW_VAR_MAX_RX_AMPDU_FACTOR, + HW_DEF_RA_INFO_DUMP, + HAL_DEF_DBG_DUMP_TXPKT, + HW_DEF_FA_CNT_DUMP, + HW_DEF_ODM_DBG_FLAG, +}; + +enum hal_odm_variable { + HAL_ODM_STA_INFO, + HAL_ODM_P2P_STATE, + HAL_ODM_WIFI_DISPLAY_STATE, +}; + +enum hal_intf_ps_func { + HAL_USB_SELECT_SUSPEND, + HAL_MAX_ID, +}; + +typedef s32 (*c2h_id_filter)(u8 id); + +struct hal_ops { + u32 (*hal_power_on)(struct adapter *padapter); + u32 (*hal_init)(struct adapter *padapter); + u32 (*hal_deinit)(struct adapter *padapter); + + void (*free_hal_data)(struct adapter *padapter); + + u32 (*inirp_init)(struct adapter *padapter); + u32 (*inirp_deinit)(struct adapter *padapter); + + s32 (*init_xmit_priv)(struct adapter *padapter); + void (*free_xmit_priv)(struct adapter *padapter); + + s32 (*init_recv_priv)(struct adapter *padapter); + void (*free_recv_priv)(struct adapter *padapter); + + void (*InitSwLeds)(struct adapter *padapter); + void (*DeInitSwLeds)(struct adapter *padapter); + + void (*dm_init)(struct adapter *padapter); + void (*dm_deinit)(struct adapter *padapter); + void (*read_chip_version)(struct adapter *padapter); + + void (*init_default_value)(struct adapter *padapter); + + void (*intf_chip_configure)(struct adapter *padapter); + + void (*read_adapter_info)(struct adapter *padapter); + + void (*enable_interrupt)(struct adapter *padapter); + void (*disable_interrupt)(struct adapter *padapter); + s32 (*interrupt_handler)(struct adapter *padapter); + + void (*set_bwmode_handler)(struct adapter *padapter, + enum ht_channel_width Bandwidth, + u8 Offset); + void (*set_channel_handler)(struct adapter *padapter, u8 channel); + + void (*hal_dm_watchdog)(struct adapter *padapter); + + void (*SetHwRegHandler)(struct adapter *padapter, u8 variable, + u8 *val); + void (*GetHwRegHandler)(struct adapter *padapter, u8 variable, + u8 *val); + + u8 (*GetHalDefVarHandler)(struct adapter *padapter, + enum hal_def_variable eVariable, + void *pValue); + u8 (*SetHalDefVarHandler)(struct adapter *padapter, + enum hal_def_variable eVariable, + void *pValue); + + void (*GetHalODMVarHandler)(struct adapter *padapter, + enum hal_odm_variable eVariable, + void *pValue1, bool bSet); + void (*SetHalODMVarHandler)(struct adapter *padapter, + enum hal_odm_variable eVariable, + void *pValue1, bool bSet); + + void (*UpdateRAMaskHandler)(struct adapter *padapter, + u32 mac_id, u8 rssi_level); + void (*SetBeaconRelatedRegistersHandler)(struct adapter *padapter); + + void (*Add_RateATid)(struct adapter *adapter, u32 bitmap, u8 arg, + u8 rssi_level); + void (*run_thread)(struct adapter *adapter); + void (*cancel_thread)(struct adapter *adapter); + + u8 (*AntDivBeforeLinkHandler)(struct adapter *adapter); + void (*AntDivCompareHandler)(struct adapter *adapter, + struct wlan_bssid_ex *dst, + struct wlan_bssid_ex *src); + u8 (*interface_ps_func)(struct adapter *padapter, + enum hal_intf_ps_func efunc_id, u8 *val); + + s32 (*hal_xmit)(struct adapter *padapter, + struct xmit_frame *pxmitframe); + s32 (*mgnt_xmit)(struct adapter *padapter, + struct xmit_frame *pmgntframe); + + u32 (*read_bbreg)(struct adapter *padapter, u32 RegAddr, + u32 BitMask); + void (*write_bbreg)(struct adapter *padapter, u32 RegAddr, + u32 BitMask, u32 Data); + u32 (*read_rfreg)(struct adapter *padapter, + enum rf_radio_path eRFPath, u32 RegAddr, + u32 BitMask); + void (*write_rfreg)(struct adapter *padapter, + enum rf_radio_path eRFPath, u32 RegAddr, + u32 BitMask, u32 Data); + + void (*EfusePowerSwitch)(struct adapter *padapter, u8 bWrite, + u8 PwrState); + void (*ReadEFuse)(struct adapter *padapter, u8 efuseType, u16 _offset, + u16 _size_byte, u8 *pbuf, bool bPseudoTest); + void (*EFUSEGetEfuseDefinition)(struct adapter *padapter, u8 efuseType, + u8 type, void *pOut, bool bPseudoTest); + u16 (*EfuseGetCurrentSize)(struct adapter *padapter, u8 efuseType, + bool bPseudoTest); + int (*Efuse_PgPacketRead)(struct adapter *adapter, u8 offset, + u8 *data, bool bPseudoTest); + int (*Efuse_PgPacketWrite)(struct adapter *padapter, u8 offset, + u8 word_en, u8 *data, bool bPseudoTest); + u8 (*Efuse_WordEnableDataWrite)(struct adapter *padapter, + u16 efuse_addr, u8 word_en, + u8 *data, bool bPseudoTest); + bool (*Efuse_PgPacketWrite_BT)(struct adapter *padapter, u8 offset, + u8 word_en, u8 *data, bool test); + + void (*sreset_init_value)(struct adapter *padapter); + void (*sreset_reset_value)(struct adapter *padapter); + void (*silentreset)(struct adapter *padapter); + void (*sreset_xmit_status_check)(struct adapter *padapter); + void (*sreset_linked_status_check) (struct adapter *padapter); + u8 (*sreset_get_wifi_status)(struct adapter *padapter); + + int (*IOL_exec_cmds_sync)(struct adapter *padapter, + struct xmit_frame *frame, u32 max_wait, + u32 bndy_cnt); + + void (*hal_notch_filter)(struct adapter *adapter, bool enable); + void (*hal_reset_security_engine)(struct adapter *adapter); + s32 (*c2h_handler)(struct adapter *padapter, + struct c2h_evt_hdr *c2h_evt); + c2h_id_filter c2h_id_filter_ccx; +}; + +enum rt_eeprom_type { + EEPROM_93C46, + EEPROM_93C56, + EEPROM_BOOT_EFUSE, +}; + +#define RF_CHANGE_BY_INIT 0 +#define RF_CHANGE_BY_IPS BIT28 +#define RF_CHANGE_BY_PS BIT29 +#define RF_CHANGE_BY_HW BIT30 +#define RF_CHANGE_BY_SW BIT31 + +enum hardware_type { + HARDWARE_TYPE_RTL8180, + HARDWARE_TYPE_RTL8185, + HARDWARE_TYPE_RTL8187, + HARDWARE_TYPE_RTL8188, + HARDWARE_TYPE_RTL8190P, + HARDWARE_TYPE_RTL8192E, + HARDWARE_TYPE_RTL819xU, + HARDWARE_TYPE_RTL8192SE, + HARDWARE_TYPE_RTL8192SU, + HARDWARE_TYPE_RTL8192CE, + HARDWARE_TYPE_RTL8192CU, + HARDWARE_TYPE_RTL8192DE, + HARDWARE_TYPE_RTL8192DU, + HARDWARE_TYPE_RTL8723AE, + HARDWARE_TYPE_RTL8723AU, + HARDWARE_TYPE_RTL8723AS, + HARDWARE_TYPE_RTL8188EE, + HARDWARE_TYPE_RTL8188EU, + HARDWARE_TYPE_RTL8188ES, + HARDWARE_TYPE_MAX, +}; + +/* RTL8188E Series */ +#define IS_HARDWARE_TYPE_8188EE(_Adapter) \ +(((struct adapter *)_Adapter)->HardwareType == HARDWARE_TYPE_RTL8188EE) +#define IS_HARDWARE_TYPE_8188EU(_Adapter) \ +(((struct adapter *)_Adapter)->HardwareType == HARDWARE_TYPE_RTL8188EU) +#define IS_HARDWARE_TYPE_8188ES(_Adapter) \ +(((struct adapter *)_Adapter)->HardwareType == HARDWARE_TYPE_RTL8188ES) +#define IS_HARDWARE_TYPE_8188E(_Adapter) \ +(IS_HARDWARE_TYPE_8188EE(_Adapter) || IS_HARDWARE_TYPE_8188EU(_Adapter) || \ + IS_HARDWARE_TYPE_8188ES(_Adapter)) + +#define GET_EEPROM_EFUSE_PRIV(adapter) (&adapter->eeprompriv) + +#define is_boot_from_eeprom(adapter) (adapter->eeprompriv.EepromOrEfuse) + +void rtw_hal_def_value_init(struct adapter *padapter); + +void rtw_hal_free_data(struct adapter *padapter); + +void rtw_hal_dm_init(struct adapter *padapter); +void rtw_hal_dm_deinit(struct adapter *padapter); +void rtw_hal_sw_led_init(struct adapter *padapter); +void rtw_hal_sw_led_deinit(struct adapter *padapter); + +u32 rtw_hal_power_on(struct adapter *padapter); +uint rtw_hal_init(struct adapter *padapter); +uint rtw_hal_deinit(struct adapter *padapter); +void rtw_hal_stop(struct adapter *padapter); +void rtw_hal_set_hwreg(struct adapter *padapter, u8 variable, u8 *val); +void rtw_hal_get_hwreg(struct adapter *padapter, u8 variable, u8 *val); + +void rtw_hal_chip_configure(struct adapter *padapter); +void rtw_hal_read_chip_info(struct adapter *padapter); +void rtw_hal_read_chip_version(struct adapter *padapter); + +u8 rtw_hal_set_def_var(struct adapter *padapter, + enum hal_def_variable eVariable, void *pValue); +u8 rtw_hal_get_def_var(struct adapter *padapter, + enum hal_def_variable eVariable, void *pValue); + +void rtw_hal_set_odm_var(struct adapter *padapter, + enum hal_odm_variable eVariable, void *pValue1, + bool bSet); +void rtw_hal_get_odm_var(struct adapter *padapter, + enum hal_odm_variable eVariable, + void *pValue1, bool bSet); + +void rtw_hal_enable_interrupt(struct adapter *padapter); +void rtw_hal_disable_interrupt(struct adapter *padapter); + +u32 rtw_hal_inirp_init(struct adapter *padapter); +u32 rtw_hal_inirp_deinit(struct adapter *padapter); + +u8 rtw_hal_intf_ps_func(struct adapter *padapter, + enum hal_intf_ps_func efunc_id, u8 *val); + +s32 rtw_hal_xmit(struct adapter *padapter, struct xmit_frame *pxmitframe); +s32 rtw_hal_mgnt_xmit(struct adapter *padapter, + struct xmit_frame *pmgntframe); + +s32 rtw_hal_init_xmit_priv(struct adapter *padapter); +void rtw_hal_free_xmit_priv(struct adapter *padapter); + +s32 rtw_hal_init_recv_priv(struct adapter *padapter); +void rtw_hal_free_recv_priv(struct adapter *padapter); + +void rtw_hal_update_ra_mask(struct adapter *padapter, u32 mac_id, u8 level); +void rtw_hal_add_ra_tid(struct adapter *adapt, u32 bitmap, u8 arg, u8 level); +void rtw_hal_clone_data(struct adapter *dst_adapt, + struct adapter *src_adapt); +void rtw_hal_start_thread(struct adapter *padapter); +void rtw_hal_stop_thread(struct adapter *padapter); + +void rtw_hal_bcn_related_reg_setting(struct adapter *padapter); + +u32 rtw_hal_read_bbreg(struct adapter *padapter, u32 RegAddr, u32 BitMask); +void rtw_hal_write_bbreg(struct adapter *padapter, u32 RegAddr, u32 BitMask, + u32 Data); +u32 rtw_hal_read_rfreg(struct adapter *padapter, enum rf_radio_path eRFPath, + u32 RegAddr, u32 BitMask); +void rtw_hal_write_rfreg(struct adapter *padapter, + enum rf_radio_path eRFPath, u32 RegAddr, + u32 BitMask, u32 Data); + +s32 rtw_hal_interrupt_handler(struct adapter *padapter); + +void rtw_hal_set_bwmode(struct adapter *padapter, + enum ht_channel_width Bandwidth, u8 Offset); +void rtw_hal_set_chan(struct adapter *padapter, u8 channel); +void rtw_hal_dm_watchdog(struct adapter *padapter); + +u8 rtw_hal_antdiv_before_linked(struct adapter *padapter); +void rtw_hal_antdiv_rssi_compared(struct adapter *padapter, + struct wlan_bssid_ex *dst, + struct wlan_bssid_ex *src); + +void rtw_hal_sreset_init(struct adapter *padapter); +void rtw_hal_sreset_reset(struct adapter *padapter); +void rtw_hal_sreset_reset_value(struct adapter *padapter); +void rtw_hal_sreset_xmit_status_check(struct adapter *padapter); +void rtw_hal_sreset_linked_status_check(struct adapter *padapter); +u8 rtw_hal_sreset_get_wifi_status(struct adapter *padapter); + +int rtw_hal_iol_cmd(struct adapter *adapter, struct xmit_frame *xmit_frame, + u32 max_wating_ms, u32 bndy_cnt); + +void rtw_hal_notch_filter(struct adapter *adapter, bool enable); +void rtw_hal_reset_security_engine(struct adapter *adapter); + +s32 rtw_hal_c2h_handler(struct adapter *adapter, + struct c2h_evt_hdr *c2h_evt); +c2h_id_filter rtw_hal_c2h_id_filter_ccx(struct adapter *adapter); +void indicate_wx_scan_complete_event(struct adapter *padapter); +u8 rtw_do_join(struct adapter *padapter); + +#endif /* __HAL_INTF_H__ */ -- GitLab From b1da99bbf28fb4f7e5cdcaec4e723e0913f222ff Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 21 Aug 2013 22:34:04 -0500 Subject: [PATCH 780/942] staging: r8188eu: Add files for new driver - part 22 This commit adds files include/Hal8188EFWImg_CE.h, include/Hal8188EPhyCfg.h, include/Hal8188EPhyReg.h, include/Hal8188EPwrSeq.h, include/Hal8188ERateAdaptive.h, include/Hal8188EReg.h, include/HalHWImg8188E_BB.h, include/HalHWImg8188E_FW.h, include/HalHWImg8188E_MAC.h, include/HalHWImg8188E_RF.h, include/HalPhyRf.h, include/HalPhyRf_8188e.h, include/HalPwrSeqCmd.h, and include/HalVerDef.h. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- .../rtl8188eu/include/Hal8188EFWImg_CE.h | 28 + .../rtl8188eu/include/Hal8188EPhyCfg.h | 276 +++++ .../rtl8188eu/include/Hal8188EPhyReg.h | 1094 +++++++++++++++++ .../rtl8188eu/include/Hal8188EPwrSeq.h | 176 +++ .../rtl8188eu/include/Hal8188ERateAdaptive.h | 75 ++ .../staging/rtl8188eu/include/Hal8188EReg.h | 46 + .../rtl8188eu/include/HalHWImg8188E_BB.h | 44 + .../rtl8188eu/include/HalHWImg8188E_FW.h | 34 + .../rtl8188eu/include/HalHWImg8188E_MAC.h | 30 + .../rtl8188eu/include/HalHWImg8188E_RF.h | 30 + drivers/staging/rtl8188eu/include/HalPhyRf.h | 30 + .../rtl8188eu/include/HalPhyRf_8188e.h | 63 + .../staging/rtl8188eu/include/HalPwrSeqCmd.h | 128 ++ drivers/staging/rtl8188eu/include/HalVerDef.h | 167 +++ 14 files changed, 2221 insertions(+) create mode 100644 drivers/staging/rtl8188eu/include/Hal8188EFWImg_CE.h create mode 100644 drivers/staging/rtl8188eu/include/Hal8188EPhyCfg.h create mode 100644 drivers/staging/rtl8188eu/include/Hal8188EPhyReg.h create mode 100644 drivers/staging/rtl8188eu/include/Hal8188EPwrSeq.h create mode 100644 drivers/staging/rtl8188eu/include/Hal8188ERateAdaptive.h create mode 100644 drivers/staging/rtl8188eu/include/Hal8188EReg.h create mode 100644 drivers/staging/rtl8188eu/include/HalHWImg8188E_BB.h create mode 100644 drivers/staging/rtl8188eu/include/HalHWImg8188E_FW.h create mode 100644 drivers/staging/rtl8188eu/include/HalHWImg8188E_MAC.h create mode 100644 drivers/staging/rtl8188eu/include/HalHWImg8188E_RF.h create mode 100644 drivers/staging/rtl8188eu/include/HalPhyRf.h create mode 100644 drivers/staging/rtl8188eu/include/HalPhyRf_8188e.h create mode 100644 drivers/staging/rtl8188eu/include/HalPwrSeqCmd.h create mode 100644 drivers/staging/rtl8188eu/include/HalVerDef.h diff --git a/drivers/staging/rtl8188eu/include/Hal8188EFWImg_CE.h b/drivers/staging/rtl8188eu/include/Hal8188EFWImg_CE.h new file mode 100644 index 0000000000000..949c33b9ed68c --- /dev/null +++ b/drivers/staging/rtl8188eu/include/Hal8188EFWImg_CE.h @@ -0,0 +1,28 @@ +/****************************************************************************** +* +* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* 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. +* +* You should have received a copy of the GNU General Public License along with +* this program; if not, write to the Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA +* +* +******************************************************************************/ +#ifndef __INC_HAL8188E_FW_IMG_H +#define __INC_HAL8188E_FW_IMG_H + +/* V10(1641) */ +#define Rtl8188EFWImgArrayLength 13904 + +extern const u8 Rtl8188EFwImgArray[Rtl8188EFWImgArrayLength]; + +#endif /* __INC_HAL8188E_FW_IMG_H */ diff --git a/drivers/staging/rtl8188eu/include/Hal8188EPhyCfg.h b/drivers/staging/rtl8188eu/include/Hal8188EPhyCfg.h new file mode 100644 index 0000000000000..c4769e20a5c37 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/Hal8188EPhyCfg.h @@ -0,0 +1,276 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __INC_HAL8188EPHYCFG_H__ +#define __INC_HAL8188EPHYCFG_H__ + + +/*--------------------------Define Parameters-------------------------------*/ +#define LOOP_LIMIT 5 +#define MAX_STALL_TIME 50 /* us */ +#define AntennaDiversityValue 0x80 +#define MAX_TXPWR_IDX_NMODE_92S 63 +#define Reset_Cnt_Limit 3 + +#define IQK_MAC_REG_NUM 4 +#define IQK_ADDA_REG_NUM 16 +#define IQK_BB_REG_NUM 9 +#define HP_THERMAL_NUM 8 + +#define MAX_AGGR_NUM 0x07 + + +/*--------------------------Define Parameters-------------------------------*/ + + +/*------------------------------Define structure----------------------------*/ +enum sw_chnl_cmd_id { + CmdID_End, + CmdID_SetTxPowerLevel, + CmdID_BBRegWrite10, + CmdID_WritePortUlong, + CmdID_WritePortUshort, + CmdID_WritePortUchar, + CmdID_RF_WriteReg, +}; + +/* 1. Switch channel related */ +struct sw_chnl_cmd { + enum sw_chnl_cmd_id CmdID; + u32 Para1; + u32 Para2; + u32 msDelay; +}; + +enum hw90_block { + HW90_BLOCK_MAC = 0, + HW90_BLOCK_PHY0 = 1, + HW90_BLOCK_PHY1 = 2, + HW90_BLOCK_RF = 3, + HW90_BLOCK_MAXIMUM = 4, /* Never use this */ +}; + +enum rf_radio_path { + RF_PATH_A = 0, /* Radio Path A */ + RF_PATH_B = 1, /* Radio Path B */ + RF_PATH_C = 2, /* Radio Path C */ + RF_PATH_D = 3, /* Radio Path D */ +}; + +#define MAX_PG_GROUP 13 + +#define RF_PATH_MAX 2 +#define MAX_RF_PATH RF_PATH_MAX +#define MAX_TX_COUNT 4 /* path numbers */ + +#define CHANNEL_MAX_NUMBER 14 /* 14 is the max chnl number */ +#define MAX_CHNL_GROUP_24G 6 /* ch1~2, ch3~5, ch6~8, + *ch9~11, ch12~13, CH 14 + * total three groups */ +#define CHANNEL_GROUP_MAX_88E 6 + +enum wireless_mode { + WIRELESS_MODE_UNKNOWN = 0x00, + WIRELESS_MODE_A = BIT2, + WIRELESS_MODE_B = BIT0, + WIRELESS_MODE_G = BIT1, + WIRELESS_MODE_AUTO = BIT5, + WIRELESS_MODE_N_24G = BIT3, + WIRELESS_MODE_N_5G = BIT4, + WIRELESS_MODE_AC = BIT6 +}; + +enum phy_rate_tx_offset_area { + RA_OFFSET_LEGACY_OFDM1, + RA_OFFSET_LEGACY_OFDM2, + RA_OFFSET_HT_OFDM1, + RA_OFFSET_HT_OFDM2, + RA_OFFSET_HT_OFDM3, + RA_OFFSET_HT_OFDM4, + RA_OFFSET_HT_CCK, +}; + +/* BB/RF related */ +enum RF_TYPE_8190P { + RF_TYPE_MIN, /* 0 */ + RF_8225 = 1, /* 1 11b/g RF for verification only */ + RF_8256 = 2, /* 2 11b/g/n */ + RF_8258 = 3, /* 3 11a/b/g/n RF */ + RF_6052 = 4, /* 4 11b/g/n RF */ + /* TODO: We should remove this psudo PHY RF after we get new RF. */ + RF_PSEUDO_11N = 5, /* 5, It is a temporality RF. */ +}; + +struct bb_reg_def { + u32 rfintfs; /* set software control: */ + /* 0x870~0x877[8 bytes] */ + u32 rfintfi; /* readback data: */ + /* 0x8e0~0x8e7[8 bytes] */ + u32 rfintfo; /* output data: */ + /* 0x860~0x86f [16 bytes] */ + u32 rfintfe; /* output enable: */ + /* 0x860~0x86f [16 bytes] */ + u32 rf3wireOffset; /* LSSI data: */ + /* 0x840~0x84f [16 bytes] */ + u32 rfLSSI_Select; /* BB Band Select: */ + /* 0x878~0x87f [8 bytes] */ + u32 rfTxGainStage; /* Tx gain stage: */ + /* 0x80c~0x80f [4 bytes] */ + u32 rfHSSIPara1; /* wire parameter control1 : */ + /* 0x820~0x823,0x828~0x82b, + * 0x830~0x833, 0x838~0x83b [16 bytes] */ + u32 rfHSSIPara2; /* wire parameter control2 : */ + /* 0x824~0x827,0x82c~0x82f, 0x834~0x837, + * 0x83c~0x83f [16 bytes] */ + u32 rfSwitchControl; /* Tx Rx antenna control : */ + /* 0x858~0x85f [16 bytes] */ + u32 rfAGCControl1; /* AGC parameter control1 : */ + /* 0xc50~0xc53,0xc58~0xc5b, 0xc60~0xc63, + * 0xc68~0xc6b [16 bytes] */ + u32 rfAGCControl2; /* AGC parameter control2 : */ + /* 0xc54~0xc57,0xc5c~0xc5f, 0xc64~0xc67, + * 0xc6c~0xc6f [16 bytes] */ + u32 rfRxIQImbalance; /* OFDM Rx IQ imbalance matrix : */ + /* 0xc14~0xc17,0xc1c~0xc1f, 0xc24~0xc27, + * 0xc2c~0xc2f [16 bytes] */ + u32 rfRxAFE; /* Rx IQ DC ofset and Rx digital filter, + * Rx DC notch filter : */ + /* 0xc10~0xc13,0xc18~0xc1b, 0xc20~0xc23, + * 0xc28~0xc2b [16 bytes] */ + u32 rfTxIQImbalance; /* OFDM Tx IQ imbalance matrix */ + /* 0xc80~0xc83,0xc88~0xc8b, 0xc90~0xc93, + * 0xc98~0xc9b [16 bytes] */ + u32 rfTxAFE; /* Tx IQ DC Offset and Tx DFIR type */ + /* 0xc84~0xc87,0xc8c~0xc8f, 0xc94~0xc97, + * 0xc9c~0xc9f [16 bytes] */ + u32 rfLSSIReadBack; /* LSSI RF readback data SI mode */ + /* 0x8a0~0x8af [16 bytes] */ + u32 rfLSSIReadBackPi; /* LSSI RF readback data PI mode 0x8b8-8bc for + * Path A and B */ +}; + +struct ant_sel_ofdm { + u32 r_tx_antenna:4; + u32 r_ant_l:4; + u32 r_ant_non_ht:4; + u32 r_ant_ht1:4; + u32 r_ant_ht2:4; + u32 r_ant_ht_s1:4; + u32 r_ant_non_ht_s1:4; + u32 OFDM_TXSC:2; + u32 reserved:2; +}; + +struct ant_sel_cck { + u8 r_cckrx_enable_2:2; + u8 r_cckrx_enable:2; + u8 r_ccktx_enable:4; +}; + +/*------------------------------Define structure----------------------------*/ + + +/*------------------------Export global variable----------------------------*/ +/*------------------------Export global variable----------------------------*/ + + +/*------------------------Export Marco Definition---------------------------*/ +/*------------------------Export Marco Definition---------------------------*/ + + +/*--------------------------Exported Function prototype---------------------*/ +/* */ +/* BB and RF register read/write */ +/* */ +u32 rtl8188e_PHY_QueryBBReg(struct adapter *adapter, u32 regaddr, u32 mask); +void rtl8188e_PHY_SetBBReg(struct adapter *Adapter, u32 RegAddr, + u32 mask, u32 data); +u32 rtl8188e_PHY_QueryRFReg(struct adapter *adapter, enum rf_radio_path rfpath, + u32 regaddr, u32 mask); +void rtl8188e_PHY_SetRFReg(struct adapter *adapter, enum rf_radio_path rfpath, + u32 regaddr, u32 mask, u32 data); + +/* Initialization related function */ +/* MAC/BB/RF HAL config */ +int PHY_MACConfig8188E(struct adapter *adapter); +int PHY_BBConfig8188E(struct adapter *adapter); +int PHY_RFConfig8188E(struct adapter *adapter); + +/* RF config */ +int rtl8188e_PHY_ConfigRFWithParaFile(struct adapter *adapter, u8 *filename, + enum rf_radio_path rfpath); +int rtl8188e_PHY_ConfigRFWithHeaderFile(struct adapter *adapter, + enum rf_radio_path rfpath); + +/* Read initi reg value for tx power setting. */ +void rtl8192c_PHY_GetHWRegOriginalValue(struct adapter *adapter); + +/* BB TX Power R/W */ +void PHY_GetTxPowerLevel8188E(struct adapter *adapter, u32 *powerlevel); +void PHY_SetTxPowerLevel8188E(struct adapter *adapter, u8 channel); +bool PHY_UpdateTxPowerDbm8188E(struct adapter *adapter, int power); + +void PHY_ScanOperationBackup8188E(struct adapter *Adapter, u8 Operation); + +/* Switch bandwidth for 8192S */ +void PHY_SetBWMode8188E(struct adapter *adapter, + enum ht_channel_width chnlwidth, unsigned char offset); + +/* channel switch related funciton */ +void PHY_SwChnl8188E(struct adapter *adapter, u8 channel); +/* Call after initialization */ +void ChkFwCmdIoDone(struct adapter *adapter); + +/* BB/MAC/RF other monitor API */ +void PHY_SetRFPathSwitch_8188E(struct adapter *adapter, bool main); + +void PHY_SwitchEphyParameter(struct adapter *adapter); + +void PHY_EnableHostClkReq(struct adapter *adapter); + +bool SetAntennaConfig92C(struct adapter *adapter, u8 defaultant); + +void storePwrIndexDiffRateOffset(struct adapter *adapter, u32 regaddr, + u32 mask, u32 data); +/*--------------------------Exported Function prototype---------------------*/ + +#define PHY_QueryBBReg(adapt, regaddr, mask) \ + rtl8188e_PHY_QueryBBReg((adapt), (regaddr), (mask)) +#define PHY_SetBBReg(adapt, regaddr, bitmask, data) \ + rtl8188e_PHY_SetBBReg((adapt), (regaddr), (bitmask), (data)) +#define PHY_QueryRFReg(adapt, rfpath, regaddr, bitmask) \ + rtl8188e_PHY_QueryRFReg((adapt), (rfpath), (regaddr), (bitmask)) +#define PHY_SetRFReg(adapt, rfpath, regaddr, bitmask, data) \ + rtl8188e_PHY_SetRFReg((adapt), (rfpath), (regaddr), (bitmask), (data)) + +#define PHY_SetMacReg PHY_SetBBReg + +#define SIC_HW_SUPPORT 0 + +#define SIC_MAX_POLL_CNT 5 + +#define SIC_CMD_READY 0 +#define SIC_CMD_WRITE 1 +#define SIC_CMD_READ 2 + +#define SIC_CMD_REG 0x1EB /* 1byte */ +#define SIC_ADDR_REG 0x1E8 /* 1b9~1ba, 2 bytes */ +#define SIC_DATA_REG 0x1EC /* 1bc~1bf */ + +#endif /* __INC_HAL8192CPHYCFG_H */ diff --git a/drivers/staging/rtl8188eu/include/Hal8188EPhyReg.h b/drivers/staging/rtl8188eu/include/Hal8188EPhyReg.h new file mode 100644 index 0000000000000..0e06d29b2d2a8 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/Hal8188EPhyReg.h @@ -0,0 +1,1094 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __INC_HAL8188EPHYREG_H__ +#define __INC_HAL8188EPHYREG_H__ +/*--------------------------Define Parameters-------------------------------*/ +/* */ +/* BB-PHY register PMAC 0x100 PHY 0x800 - 0xEFF */ +/* 1. PMAC duplicate register due to connection: RF_Mode, TRxRN, NumOf L-STF */ +/* 2. 0x800/0x900/0xA00/0xC00/0xD00/0xE00 */ +/* 3. RF register 0x00-2E */ +/* 4. Bit Mask for BB/RF register */ +/* 5. Other defintion for BB/RF R/W */ +/* */ + + +/* */ +/* 1. PMAC duplicate register due to connection: RF_Mode, TRxRN, NumOf L-STF */ +/* 1. Page1(0x100) */ +/* */ +#define rPMAC_Reset 0x100 +#define rPMAC_TxStart 0x104 +#define rPMAC_TxLegacySIG 0x108 +#define rPMAC_TxHTSIG1 0x10c +#define rPMAC_TxHTSIG2 0x110 +#define rPMAC_PHYDebug 0x114 +#define rPMAC_TxPacketNum 0x118 +#define rPMAC_TxIdle 0x11c +#define rPMAC_TxMACHeader0 0x120 +#define rPMAC_TxMACHeader1 0x124 +#define rPMAC_TxMACHeader2 0x128 +#define rPMAC_TxMACHeader3 0x12c +#define rPMAC_TxMACHeader4 0x130 +#define rPMAC_TxMACHeader5 0x134 +#define rPMAC_TxDataType 0x138 +#define rPMAC_TxRandomSeed 0x13c +#define rPMAC_CCKPLCPPreamble 0x140 +#define rPMAC_CCKPLCPHeader 0x144 +#define rPMAC_CCKCRC16 0x148 +#define rPMAC_OFDMRxCRC32OK 0x170 +#define rPMAC_OFDMRxCRC32Er 0x174 +#define rPMAC_OFDMRxParityEr 0x178 +#define rPMAC_OFDMRxCRC8Er 0x17c +#define rPMAC_CCKCRxRC16Er 0x180 +#define rPMAC_CCKCRxRC32Er 0x184 +#define rPMAC_CCKCRxRC32OK 0x188 +#define rPMAC_TxStatus 0x18c + +/* 2. Page2(0x200) */ +/* The following two definition are only used for USB interface. */ +#define RF_BB_CMD_ADDR 0x02c0 /* RF/BB r/w cmd address. */ +#define RF_BB_CMD_DATA 0x02c4 /* RF/BB r/w cmd data. */ + +/* 3. Page8(0x800) */ +#define rFPGA0_RFMOD 0x800 /* RF mode & CCK TxSC RF BW Setting */ + +#define rFPGA0_TxInfo 0x804 /* Status report?? */ +#define rFPGA0_PSDFunction 0x808 + +#define rFPGA0_TxGainStage 0x80c /* Set TX PWR init gain? */ + +#define rFPGA0_RFTiming1 0x810 /* Useless now */ +#define rFPGA0_RFTiming2 0x814 + +#define rFPGA0_XA_HSSIParameter1 0x820 /* RF 3 wire register */ +#define rFPGA0_XA_HSSIParameter2 0x824 +#define rFPGA0_XB_HSSIParameter1 0x828 +#define rFPGA0_XB_HSSIParameter2 0x82c + +#define rFPGA0_XA_LSSIParameter 0x840 +#define rFPGA0_XB_LSSIParameter 0x844 + +#define rFPGA0_RFWakeUpParameter 0x850 /* Useless now */ +#define rFPGA0_RFSleepUpParameter 0x854 + +#define rFPGA0_XAB_SwitchControl 0x858 /* RF Channel switch */ +#define rFPGA0_XCD_SwitchControl 0x85c + +#define rFPGA0_XA_RFInterfaceOE 0x860 /* RF Channel switch */ +#define rFPGA0_XB_RFInterfaceOE 0x864 + +#define rFPGA0_XAB_RFInterfaceSW 0x870 /* RF Iface Software Control */ +#define rFPGA0_XCD_RFInterfaceSW 0x874 + +#define rFPGA0_XAB_RFParameter 0x878 /* RF Parameter */ +#define rFPGA0_XCD_RFParameter 0x87c + +/* Crystal cap setting RF-R/W protection for parameter4?? */ +#define rFPGA0_AnalogParameter1 0x880 +#define rFPGA0_AnalogParameter2 0x884 +#define rFPGA0_AnalogParameter3 0x888 +/* enable ad/da clock1 for dual-phy */ +#define rFPGA0_AdDaClockEn 0x888 +#define rFPGA0_AnalogParameter4 0x88c + +#define rFPGA0_XA_LSSIReadBack 0x8a0 /* Tranceiver LSSI Readback */ +#define rFPGA0_XB_LSSIReadBack 0x8a4 +#define rFPGA0_XC_LSSIReadBack 0x8a8 +#define rFPGA0_XD_LSSIReadBack 0x8ac + +#define rFPGA0_PSDReport 0x8b4 /* Useless now */ +/* Transceiver A HSPI Readback */ +#define TransceiverA_HSPI_Readback 0x8b8 +/* Transceiver B HSPI Readback */ +#define TransceiverB_HSPI_Readback 0x8bc +/* Useless now RF Interface Readback Value */ +#define rFPGA0_XAB_RFInterfaceRB 0x8e0 +#define rFPGA0_XCD_RFInterfaceRB 0x8e4 /* Useless now */ + +/* 4. Page9(0x900) */ +/* RF mode & OFDM TxSC RF BW Setting?? */ +#define rFPGA1_RFMOD 0x900 + +#define rFPGA1_TxBlock 0x904 /* Useless now */ +#define rFPGA1_DebugSelect 0x908 /* Useless now */ +#define rFPGA1_TxInfo 0x90c /* Useless now Status report */ + +/* 5. PageA(0xA00) */ +/* Set Control channel to upper or lower - required only for 40MHz */ +#define rCCK0_System 0xa00 + +/* Disable init gain now Select RX path by RSSI */ +#define rCCK0_AFESetting 0xa04 +/* Disable init gain now Init gain */ +#define rCCK0_CCA 0xa08 + +/* AGC default value, saturation level Antenna Diversity, RX AGC, LNA Threshold, + * RX LNA Threshold useless now. Not the same as 90 series */ +#define rCCK0_RxAGC1 0xa0c +#define rCCK0_RxAGC2 0xa10 /* AGC & DAGC */ + +#define rCCK0_RxHP 0xa14 + +/* Timing recovery & Channel estimation threshold */ +#define rCCK0_DSPParameter1 0xa18 +#define rCCK0_DSPParameter2 0xa1c /* SQ threshold */ + +#define rCCK0_TxFilter1 0xa20 +#define rCCK0_TxFilter2 0xa24 +#define rCCK0_DebugPort 0xa28 /* debug port and Tx filter3 */ +#define rCCK0_FalseAlarmReport 0xa2c /* 0xa2d useless now */ +#define rCCK0_TRSSIReport 0xa50 +#define rCCK0_RxReport 0xa54 /* 0xa57 */ +#define rCCK0_FACounterLower 0xa5c /* 0xa5b */ +#define rCCK0_FACounterUpper 0xa58 /* 0xa5c */ + +/* */ +/* PageB(0xB00) */ +/* */ +#define rPdp_AntA 0xb00 +#define rPdp_AntA_4 0xb04 +#define rConfig_Pmpd_AntA 0xb28 +#define rConfig_AntA 0xb68 +#define rConfig_AntB 0xb6c +#define rPdp_AntB 0xb70 +#define rPdp_AntB_4 0xb74 +#define rConfig_Pmpd_AntB 0xb98 +#define rAPK 0xbd8 + +/* */ +/* 6. PageC(0xC00) */ +/* */ +#define rOFDM0_LSTF 0xc00 + +#define rOFDM0_TRxPathEnable 0xc04 +#define rOFDM0_TRMuxPar 0xc08 +#define rOFDM0_TRSWIsolation 0xc0c + +/* RxIQ DC offset, Rx digital filter, DC notch filter */ +#define rOFDM0_XARxAFE 0xc10 +#define rOFDM0_XARxIQImbalance 0xc14 /* RxIQ imblance matrix */ +#define rOFDM0_XBRxAFE 0xc18 +#define rOFDM0_XBRxIQImbalance 0xc1c +#define rOFDM0_XCRxAFE 0xc20 +#define rOFDM0_XCRxIQImbalance 0xc24 +#define rOFDM0_XDRxAFE 0xc28 +#define rOFDM0_XDRxIQImbalance 0xc2c + +#define rOFDM0_RxDetector1 0xc30 /*PD,BW & SBD DM tune init gain*/ +#define rOFDM0_RxDetector2 0xc34 /* SBD & Fame Sync. */ +#define rOFDM0_RxDetector3 0xc38 /* Frame Sync. */ +#define rOFDM0_RxDetector4 0xc3c /* PD, SBD, Frame Sync & Short-GI */ + +#define rOFDM0_RxDSP 0xc40 /* Rx Sync Path */ +#define rOFDM0_CFOandDAGC 0xc44 /* CFO & DAGC */ +#define rOFDM0_CCADropThreshold 0xc48 /* CCA Drop threshold */ +#define rOFDM0_ECCAThreshold 0xc4c /* energy CCA */ + +#define rOFDM0_XAAGCCore1 0xc50 /* DIG */ +#define rOFDM0_XAAGCCore2 0xc54 +#define rOFDM0_XBAGCCore1 0xc58 +#define rOFDM0_XBAGCCore2 0xc5c +#define rOFDM0_XCAGCCore1 0xc60 +#define rOFDM0_XCAGCCore2 0xc64 +#define rOFDM0_XDAGCCore1 0xc68 +#define rOFDM0_XDAGCCore2 0xc6c + +#define rOFDM0_AGCParameter1 0xc70 +#define rOFDM0_AGCParameter2 0xc74 +#define rOFDM0_AGCRSSITable 0xc78 +#define rOFDM0_HTSTFAGC 0xc7c + +#define rOFDM0_XATxIQImbalance 0xc80 /* TX PWR TRACK and DIG */ +#define rOFDM0_XATxAFE 0xc84 +#define rOFDM0_XBTxIQImbalance 0xc88 +#define rOFDM0_XBTxAFE 0xc8c +#define rOFDM0_XCTxIQImbalance 0xc90 +#define rOFDM0_XCTxAFE 0xc94 +#define rOFDM0_XDTxIQImbalance 0xc98 +#define rOFDM0_XDTxAFE 0xc9c + +#define rOFDM0_RxIQExtAnta 0xca0 +#define rOFDM0_TxCoeff1 0xca4 +#define rOFDM0_TxCoeff2 0xca8 +#define rOFDM0_TxCoeff3 0xcac +#define rOFDM0_TxCoeff4 0xcb0 +#define rOFDM0_TxCoeff5 0xcb4 +#define rOFDM0_TxCoeff6 0xcb8 +#define rOFDM0_RxHPParameter 0xce0 +#define rOFDM0_TxPseudoNoiseWgt 0xce4 +#define rOFDM0_FrameSync 0xcf0 +#define rOFDM0_DFSReport 0xcf4 + + +/* */ +/* 7. PageD(0xD00) */ +/* */ +#define rOFDM1_LSTF 0xd00 +#define rOFDM1_TRxPathEnable 0xd04 + +#define rOFDM1_CFO 0xd08 /* No setting now */ +#define rOFDM1_CSI1 0xd10 +#define rOFDM1_SBD 0xd14 +#define rOFDM1_CSI2 0xd18 +#define rOFDM1_CFOTracking 0xd2c +#define rOFDM1_TRxMesaure1 0xd34 +#define rOFDM1_IntfDet 0xd3c +#define rOFDM1_PseudoNoiseStateAB 0xd50 +#define rOFDM1_PseudoNoiseStateCD 0xd54 +#define rOFDM1_RxPseudoNoiseWgt 0xd58 + +#define rOFDM_PHYCounter1 0xda0 /* cca, parity fail */ +#define rOFDM_PHYCounter2 0xda4 /* rate illegal, crc8 fail */ +#define rOFDM_PHYCounter3 0xda8 /* MCS not support */ + +#define rOFDM_ShortCFOAB 0xdac /* No setting now */ +#define rOFDM_ShortCFOCD 0xdb0 +#define rOFDM_LongCFOAB 0xdb4 +#define rOFDM_LongCFOCD 0xdb8 +#define rOFDM_TailCFOAB 0xdbc +#define rOFDM_TailCFOCD 0xdc0 +#define rOFDM_PWMeasure1 0xdc4 +#define rOFDM_PWMeasure2 0xdc8 +#define rOFDM_BWReport 0xdcc +#define rOFDM_AGCReport 0xdd0 +#define rOFDM_RxSNR 0xdd4 +#define rOFDM_RxEVMCSI 0xdd8 +#define rOFDM_SIGReport 0xddc + + +/* */ +/* 8. PageE(0xE00) */ +/* */ +#define rTxAGC_A_Rate18_06 0xe00 +#define rTxAGC_A_Rate54_24 0xe04 +#define rTxAGC_A_CCK1_Mcs32 0xe08 +#define rTxAGC_A_Mcs03_Mcs00 0xe10 +#define rTxAGC_A_Mcs07_Mcs04 0xe14 +#define rTxAGC_A_Mcs11_Mcs08 0xe18 +#define rTxAGC_A_Mcs15_Mcs12 0xe1c + +#define rTxAGC_B_Rate18_06 0x830 +#define rTxAGC_B_Rate54_24 0x834 +#define rTxAGC_B_CCK1_55_Mcs32 0x838 +#define rTxAGC_B_Mcs03_Mcs00 0x83c +#define rTxAGC_B_Mcs07_Mcs04 0x848 +#define rTxAGC_B_Mcs11_Mcs08 0x84c +#define rTxAGC_B_Mcs15_Mcs12 0x868 +#define rTxAGC_B_CCK11_A_CCK2_11 0x86c + +#define rFPGA0_IQK 0xe28 +#define rTx_IQK_Tone_A 0xe30 +#define rRx_IQK_Tone_A 0xe34 +#define rTx_IQK_PI_A 0xe38 +#define rRx_IQK_PI_A 0xe3c + +#define rTx_IQK 0xe40 +#define rRx_IQK 0xe44 +#define rIQK_AGC_Pts 0xe48 +#define rIQK_AGC_Rsp 0xe4c +#define rTx_IQK_Tone_B 0xe50 +#define rRx_IQK_Tone_B 0xe54 +#define rTx_IQK_PI_B 0xe58 +#define rRx_IQK_PI_B 0xe5c +#define rIQK_AGC_Cont 0xe60 + +#define rBlue_Tooth 0xe6c +#define rRx_Wait_CCA 0xe70 +#define rTx_CCK_RFON 0xe74 +#define rTx_CCK_BBON 0xe78 +#define rTx_OFDM_RFON 0xe7c +#define rTx_OFDM_BBON 0xe80 +#define rTx_To_Rx 0xe84 +#define rTx_To_Tx 0xe88 +#define rRx_CCK 0xe8c + +#define rTx_Power_Before_IQK_A 0xe94 +#define rTx_Power_After_IQK_A 0xe9c + +#define rRx_Power_Before_IQK_A 0xea0 +#define rRx_Power_Before_IQK_A_2 0xea4 +#define rRx_Power_After_IQK_A 0xea8 +#define rRx_Power_After_IQK_A_2 0xeac + +#define rTx_Power_Before_IQK_B 0xeb4 +#define rTx_Power_After_IQK_B 0xebc + +#define rRx_Power_Before_IQK_B 0xec0 +#define rRx_Power_Before_IQK_B_2 0xec4 +#define rRx_Power_After_IQK_B 0xec8 +#define rRx_Power_After_IQK_B_2 0xecc + +#define rRx_OFDM 0xed0 +#define rRx_Wait_RIFS 0xed4 +#define rRx_TO_Rx 0xed8 +#define rStandby 0xedc +#define rSleep 0xee0 +#define rPMPD_ANAEN 0xeec + +/* */ +/* 7. RF Register 0x00-0x2E (RF 8256) */ +/* RF-0222D 0x00-3F */ +/* */ +/* Zebra1 */ +#define rZebra1_HSSIEnable 0x0 /* Useless now */ +#define rZebra1_TRxEnable1 0x1 +#define rZebra1_TRxEnable2 0x2 +#define rZebra1_AGC 0x4 +#define rZebra1_ChargePump 0x5 +#define rZebra1_Channel 0x7 /* RF channel switch */ + +/* endif */ +#define rZebra1_TxGain 0x8 /* Useless now */ +#define rZebra1_TxLPF 0x9 +#define rZebra1_RxLPF 0xb +#define rZebra1_RxHPFCorner 0xc + +/* Zebra4 */ +#define rGlobalCtrl 0 /* Useless now */ +#define rRTL8256_TxLPF 19 +#define rRTL8256_RxLPF 11 + +/* RTL8258 */ +#define rRTL8258_TxLPF 0x11 /* Useless now */ +#define rRTL8258_RxLPF 0x13 +#define rRTL8258_RSSILPF 0xa + +/* */ +/* RL6052 Register definition */ +/* */ +#define RF_AC 0x00 /* */ + +#define RF_IQADJ_G1 0x01 /* */ +#define RF_IQADJ_G2 0x02 /* */ + +#define RF_POW_TRSW 0x05 /* */ + +#define RF_GAIN_RX 0x06 /* */ +#define RF_GAIN_TX 0x07 /* */ + +#define RF_TXM_IDAC 0x08 /* */ +#define RF_IPA_G 0x09 /* */ +#define RF_TXBIAS_G 0x0A +#define RF_TXPA_AG 0x0B +#define RF_IPA_A 0x0C /* */ +#define RF_TXBIAS_A 0x0D +#define RF_BS_PA_APSET_G9_G11 0x0E +#define RF_BS_IQGEN 0x0F /* */ + +#define RF_MODE1 0x10 /* */ +#define RF_MODE2 0x11 /* */ + +#define RF_RX_AGC_HP 0x12 /* */ +#define RF_TX_AGC 0x13 /* */ +#define RF_BIAS 0x14 /* */ +#define RF_IPA 0x15 /* */ +#define RF_TXBIAS 0x16 +#define RF_POW_ABILITY 0x17 /* */ +#define RF_CHNLBW 0x18 /* RF channel and BW switch */ +#define RF_TOP 0x19 /* */ + +#define RF_RX_G1 0x1A /* */ +#define RF_RX_G2 0x1B /* */ + +#define RF_RX_BB2 0x1C /* */ +#define RF_RX_BB1 0x1D /* */ + +#define RF_RCK1 0x1E /* */ +#define RF_RCK2 0x1F /* */ + +#define RF_TX_G1 0x20 /* */ +#define RF_TX_G2 0x21 /* */ +#define RF_TX_G3 0x22 /* */ + +#define RF_TX_BB1 0x23 /* */ + +#define RF_T_METER_92D 0x42 /* */ +#define RF_T_METER_88E 0x42 /* */ +#define RF_T_METER 0x24 /* */ + +#define RF_SYN_G1 0x25 /* RF TX Power control */ +#define RF_SYN_G2 0x26 /* RF TX Power control */ +#define RF_SYN_G3 0x27 /* RF TX Power control */ +#define RF_SYN_G4 0x28 /* RF TX Power control */ +#define RF_SYN_G5 0x29 /* RF TX Power control */ +#define RF_SYN_G6 0x2A /* RF TX Power control */ +#define RF_SYN_G7 0x2B /* RF TX Power control */ +#define RF_SYN_G8 0x2C /* RF TX Power control */ + +#define RF_RCK_OS 0x30 /* RF TX PA control */ +#define RF_TXPA_G1 0x31 /* RF TX PA control */ +#define RF_TXPA_G2 0x32 /* RF TX PA control */ +#define RF_TXPA_G3 0x33 /* RF TX PA control */ +#define RF_TX_BIAS_A 0x35 +#define RF_TX_BIAS_D 0x36 +#define RF_LOBF_9 0x38 +#define RF_RXRF_A3 0x3C /* */ +#define RF_TRSW 0x3F + +#define RF_TXRF_A2 0x41 +#define RF_TXPA_G4 0x46 +#define RF_TXPA_A4 0x4B +#define RF_0x52 0x52 +#define RF_WE_LUT 0xEF + + +/* */ +/* Bit Mask */ +/* */ +/* 1. Page1(0x100) */ +#define bBBResetB 0x100 /* Useless now? */ +#define bGlobalResetB 0x200 +#define bOFDMTxStart 0x4 +#define bCCKTxStart 0x8 +#define bCRC32Debug 0x100 +#define bPMACLoopback 0x10 +#define bTxLSIG 0xffffff +#define bOFDMTxRate 0xf +#define bOFDMTxReserved 0x10 +#define bOFDMTxLength 0x1ffe0 +#define bOFDMTxParity 0x20000 +#define bTxHTSIG1 0xffffff +#define bTxHTMCSRate 0x7f +#define bTxHTBW 0x80 +#define bTxHTLength 0xffff00 +#define bTxHTSIG2 0xffffff +#define bTxHTSmoothing 0x1 +#define bTxHTSounding 0x2 +#define bTxHTReserved 0x4 +#define bTxHTAggreation 0x8 +#define bTxHTSTBC 0x30 +#define bTxHTAdvanceCoding 0x40 +#define bTxHTShortGI 0x80 +#define bTxHTNumberHT_LTF 0x300 +#define bTxHTCRC8 0x3fc00 +#define bCounterReset 0x10000 +#define bNumOfOFDMTx 0xffff +#define bNumOfCCKTx 0xffff0000 +#define bTxIdleInterval 0xffff +#define bOFDMService 0xffff0000 +#define bTxMACHeader 0xffffffff +#define bTxDataInit 0xff +#define bTxHTMode 0x100 +#define bTxDataType 0x30000 +#define bTxRandomSeed 0xffffffff +#define bCCKTxPreamble 0x1 +#define bCCKTxSFD 0xffff0000 +#define bCCKTxSIG 0xff +#define bCCKTxService 0xff00 +#define bCCKLengthExt 0x8000 +#define bCCKTxLength 0xffff0000 +#define bCCKTxCRC16 0xffff +#define bCCKTxStatus 0x1 +#define bOFDMTxStatus 0x2 + +#define IS_BB_REG_OFFSET_92S(_Offset) \ + ((_Offset >= 0x800) && (_Offset <= 0xfff)) + +/* 2. Page8(0x800) */ +#define bRFMOD 0x1 /* Reg 0x800 rFPGA0_RFMOD */ +#define bJapanMode 0x2 +#define bCCKTxSC 0x30 +#define bCCKEn 0x1000000 +#define bOFDMEn 0x2000000 + +#define bOFDMRxADCPhase 0x10000 /* Useless now */ +#define bOFDMTxDACPhase 0x40000 +#define bXATxAGC 0x3f + +#define bAntennaSelect 0x0300 + +#define bXBTxAGC 0xf00 /* Reg 80c rFPGA0_TxGainStage */ +#define bXCTxAGC 0xf000 +#define bXDTxAGC 0xf0000 + +#define bPAStart 0xf0000000 /* Useless now */ +#define bTRStart 0x00f00000 +#define bRFStart 0x0000f000 +#define bBBStart 0x000000f0 +#define bBBCCKStart 0x0000000f +#define bPAEnd 0xf /* Reg0x814 */ +#define bTREnd 0x0f000000 +#define bRFEnd 0x000f0000 +#define bCCAMask 0x000000f0 /* T2R */ +#define bR2RCCAMask 0x00000f00 +#define bHSSI_R2TDelay 0xf8000000 +#define bHSSI_T2RDelay 0xf80000 +#define bContTxHSSI 0x400 /* change gain at continue Tx */ +#define bIGFromCCK 0x200 +#define bAGCAddress 0x3f +#define bRxHPTx 0x7000 +#define bRxHPT2R 0x38000 +#define bRxHPCCKIni 0xc0000 +#define bAGCTxCode 0xc00000 +#define bAGCRxCode 0x300000 + +/* Reg 0x820~84f rFPGA0_XA_HSSIParameter1 */ +#define b3WireDataLength 0x800 +#define b3WireAddressLength 0x400 + +#define b3WireRFPowerDown 0x1 /* Useless now */ +#define b5GPAPEPolarity 0x40000000 +#define b2GPAPEPolarity 0x80000000 +#define bRFSW_TxDefaultAnt 0x3 +#define bRFSW_TxOptionAnt 0x30 +#define bRFSW_RxDefaultAnt 0x300 +#define bRFSW_RxOptionAnt 0x3000 +#define bRFSI_3WireData 0x1 +#define bRFSI_3WireClock 0x2 +#define bRFSI_3WireLoad 0x4 +#define bRFSI_3WireRW 0x8 +#define bRFSI_3Wire 0xf + +#define bRFSI_RFENV 0x10 /* Reg 0x870 rFPGA0_XAB_RFInterfaceSW */ + +#define bRFSI_TRSW 0x20 /* Useless now */ +#define bRFSI_TRSWB 0x40 +#define bRFSI_ANTSW 0x100 +#define bRFSI_ANTSWB 0x200 +#define bRFSI_PAPE 0x400 +#define bRFSI_PAPE5G 0x800 +#define bBandSelect 0x1 +#define bHTSIG2_GI 0x80 +#define bHTSIG2_Smoothing 0x01 +#define bHTSIG2_Sounding 0x02 +#define bHTSIG2_Aggreaton 0x08 +#define bHTSIG2_STBC 0x30 +#define bHTSIG2_AdvCoding 0x40 +#define bHTSIG2_NumOfHTLTF 0x300 +#define bHTSIG2_CRC8 0x3fc +#define bHTSIG1_MCS 0x7f +#define bHTSIG1_BandWidth 0x80 +#define bHTSIG1_HTLength 0xffff +#define bLSIG_Rate 0xf +#define bLSIG_Reserved 0x10 +#define bLSIG_Length 0x1fffe +#define bLSIG_Parity 0x20 +#define bCCKRxPhase 0x4 + +#define bLSSIReadAddress 0x7f800000 /* T65 RF */ + +#define bLSSIReadEdge 0x80000000 /* LSSI "Read" edge signal */ + +#define bLSSIReadBackData 0xfffff /* T65 RF */ + +#define bLSSIReadOKFlag 0x1000 /* Useless now */ +#define bCCKSampleRate 0x8 /* 0: 44MHz, 1:88MHz */ +#define bRegulator0Standby 0x1 +#define bRegulatorPLLStandby 0x2 +#define bRegulator1Standby 0x4 +#define bPLLPowerUp 0x8 +#define bDPLLPowerUp 0x10 +#define bDA10PowerUp 0x20 +#define bAD7PowerUp 0x200 +#define bDA6PowerUp 0x2000 +#define bXtalPowerUp 0x4000 +#define b40MDClkPowerUP 0x8000 +#define bDA6DebugMode 0x20000 +#define bDA6Swing 0x380000 + +/* Reg 0x880 rFPGA0_AnalogParameter1 20/40 CCK support switch 40/80 BB MHZ */ +#define bADClkPhase 0x4000000 + +#define b80MClkDelay 0x18000000 /* Useless */ +#define bAFEWatchDogEnable 0x20000000 + +/* Reg 0x884 rFPGA0_AnalogParameter2 Crystal cap */ +#define bXtalCap01 0xc0000000 +#define bXtalCap23 0x3 +#define bXtalCap92x 0x0f000000 +#define bXtalCap 0x0f000000 + +#define bIntDifClkEnable 0x400 /* Useless */ +#define bExtSigClkEnable 0x800 +#define bBandgapMbiasPowerUp 0x10000 +#define bAD11SHGain 0xc0000 +#define bAD11InputRange 0x700000 +#define bAD11OPCurrent 0x3800000 +#define bIPathLoopback 0x4000000 +#define bQPathLoopback 0x8000000 +#define bAFELoopback 0x10000000 +#define bDA10Swing 0x7e0 +#define bDA10Reverse 0x800 +#define bDAClkSource 0x1000 +#define bAD7InputRange 0x6000 +#define bAD7Gain 0x38000 +#define bAD7OutputCMMode 0x40000 +#define bAD7InputCMMode 0x380000 +#define bAD7Current 0xc00000 +#define bRegulatorAdjust 0x7000000 +#define bAD11PowerUpAtTx 0x1 +#define bDA10PSAtTx 0x10 +#define bAD11PowerUpAtRx 0x100 +#define bDA10PSAtRx 0x1000 +#define bCCKRxAGCFormat 0x200 +#define bPSDFFTSamplepPoint 0xc000 +#define bPSDAverageNum 0x3000 +#define bIQPathControl 0xc00 +#define bPSDFreq 0x3ff +#define bPSDAntennaPath 0x30 +#define bPSDIQSwitch 0x40 +#define bPSDRxTrigger 0x400000 +#define bPSDTxTrigger 0x80000000 +#define bPSDSineToneScale 0x7f000000 +#define bPSDReport 0xffff + +/* 3. Page9(0x900) */ +#define bOFDMTxSC 0x30000000 /* Useless */ +#define bCCKTxOn 0x1 +#define bOFDMTxOn 0x2 +#define bDebugPage 0xfff /* reset debug page and HWord, LWord */ +#define bDebugItem 0xff /* reset debug page and LWord */ +#define bAntL 0x10 +#define bAntNonHT 0x100 +#define bAntHT1 0x1000 +#define bAntHT2 0x10000 +#define bAntHT1S1 0x100000 +#define bAntNonHTS1 0x1000000 + +/* 4. PageA(0xA00) */ +#define bCCKBBMode 0x3 /* Useless */ +#define bCCKTxPowerSaving 0x80 +#define bCCKRxPowerSaving 0x40 + +#define bCCKSideBand 0x10 /* Reg 0xa00 rCCK0_System 20/40 */ + +#define bCCKScramble 0x8 /* Useless */ +#define bCCKAntDiversity 0x8000 +#define bCCKCarrierRecovery 0x4000 +#define bCCKTxRate 0x3000 +#define bCCKDCCancel 0x0800 +#define bCCKISICancel 0x0400 +#define bCCKMatchFilter 0x0200 +#define bCCKEqualizer 0x0100 +#define bCCKPreambleDetect 0x800000 +#define bCCKFastFalseCCA 0x400000 +#define bCCKChEstStart 0x300000 +#define bCCKCCACount 0x080000 +#define bCCKcs_lim 0x070000 +#define bCCKBistMode 0x80000000 +#define bCCKCCAMask 0x40000000 +#define bCCKTxDACPhase 0x4 +#define bCCKRxADCPhase 0x20000000 /* r_rx_clk */ +#define bCCKr_cp_mode0 0x0100 +#define bCCKTxDCOffset 0xf0 +#define bCCKRxDCOffset 0xf +#define bCCKCCAMode 0xc000 +#define bCCKFalseCS_lim 0x3f00 +#define bCCKCS_ratio 0xc00000 +#define bCCKCorgBit_sel 0x300000 +#define bCCKPD_lim 0x0f0000 +#define bCCKNewCCA 0x80000000 +#define bCCKRxHPofIG 0x8000 +#define bCCKRxIG 0x7f00 +#define bCCKLNAPolarity 0x800000 +#define bCCKRx1stGain 0x7f0000 +#define bCCKRFExtend 0x20000000 /* CCK Rx Iinital gain polarity */ +#define bCCKRxAGCSatLevel 0x1f000000 +#define bCCKRxAGCSatCount 0xe0 +#define bCCKRxRFSettle 0x1f /* AGCsamp_dly */ +#define bCCKFixedRxAGC 0x8000 +#define bCCKAntennaPolarity 0x2000 +#define bCCKTxFilterType 0x0c00 +#define bCCKRxAGCReportType 0x0300 +#define bCCKRxDAGCEn 0x80000000 +#define bCCKRxDAGCPeriod 0x20000000 +#define bCCKRxDAGCSatLevel 0x1f000000 +#define bCCKTimingRecovery 0x800000 +#define bCCKTxC0 0x3f0000 +#define bCCKTxC1 0x3f000000 +#define bCCKTxC2 0x3f +#define bCCKTxC3 0x3f00 +#define bCCKTxC4 0x3f0000 +#define bCCKTxC5 0x3f000000 +#define bCCKTxC6 0x3f +#define bCCKTxC7 0x3f00 +#define bCCKDebugPort 0xff0000 +#define bCCKDACDebug 0x0f000000 +#define bCCKFalseAlarmEnable 0x8000 +#define bCCKFalseAlarmRead 0x4000 +#define bCCKTRSSI 0x7f +#define bCCKRxAGCReport 0xfe +#define bCCKRxReport_AntSel 0x80000000 +#define bCCKRxReport_MFOff 0x40000000 +#define bCCKRxRxReport_SQLoss 0x20000000 +#define bCCKRxReport_Pktloss 0x10000000 +#define bCCKRxReport_Lockedbit 0x08000000 +#define bCCKRxReport_RateError 0x04000000 +#define bCCKRxReport_RxRate 0x03000000 +#define bCCKRxFACounterLower 0xff +#define bCCKRxFACounterUpper 0xff000000 +#define bCCKRxHPAGCStart 0xe000 +#define bCCKRxHPAGCFinal 0x1c00 +#define bCCKRxFalseAlarmEnable 0x8000 +#define bCCKFACounterFreeze 0x4000 +#define bCCKTxPathSel 0x10000000 +#define bCCKDefaultRxPath 0xc000000 +#define bCCKOptionRxPath 0x3000000 + +/* 5. PageC(0xC00) */ +#define bNumOfSTF 0x3 /* Useless */ +#define bShift_L 0xc0 +#define bGI_TH 0xc +#define bRxPathA 0x1 +#define bRxPathB 0x2 +#define bRxPathC 0x4 +#define bRxPathD 0x8 +#define bTxPathA 0x1 +#define bTxPathB 0x2 +#define bTxPathC 0x4 +#define bTxPathD 0x8 +#define bTRSSIFreq 0x200 +#define bADCBackoff 0x3000 +#define bDFIRBackoff 0xc000 +#define bTRSSILatchPhase 0x10000 +#define bRxIDCOffset 0xff +#define bRxQDCOffset 0xff00 +#define bRxDFIRMode 0x1800000 +#define bRxDCNFType 0xe000000 +#define bRXIQImb_A 0x3ff +#define bRXIQImb_B 0xfc00 +#define bRXIQImb_C 0x3f0000 +#define bRXIQImb_D 0xffc00000 +#define bDC_dc_Notch 0x60000 +#define bRxNBINotch 0x1f000000 +#define bPD_TH 0xf +#define bPD_TH_Opt2 0xc000 +#define bPWED_TH 0x700 +#define bIfMF_Win_L 0x800 +#define bPD_Option 0x1000 +#define bMF_Win_L 0xe000 +#define bBW_Search_L 0x30000 +#define bwin_enh_L 0xc0000 +#define bBW_TH 0x700000 +#define bED_TH2 0x3800000 +#define bBW_option 0x4000000 +#define bRatio_TH 0x18000000 +#define bWindow_L 0xe0000000 +#define bSBD_Option 0x1 +#define bFrame_TH 0x1c +#define bFS_Option 0x60 +#define bDC_Slope_check 0x80 +#define bFGuard_Counter_DC_L 0xe00 +#define bFrame_Weight_Short 0x7000 +#define bSub_Tune 0xe00000 +#define bFrame_DC_Length 0xe000000 +#define bSBD_start_offset 0x30000000 +#define bFrame_TH_2 0x7 +#define bFrame_GI2_TH 0x38 +#define bGI2_Sync_en 0x40 +#define bSarch_Short_Early 0x300 +#define bSarch_Short_Late 0xc00 +#define bSarch_GI2_Late 0x70000 +#define bCFOAntSum 0x1 +#define bCFOAcc 0x2 +#define bCFOStartOffset 0xc +#define bCFOLookBack 0x70 +#define bCFOSumWeight 0x80 +#define bDAGCEnable 0x10000 +#define bTXIQImb_A 0x3ff +#define bTXIQImb_B 0xfc00 +#define bTXIQImb_C 0x3f0000 +#define bTXIQImb_D 0xffc00000 +#define bTxIDCOffset 0xff +#define bTxQDCOffset 0xff00 +#define bTxDFIRMode 0x10000 +#define bTxPesudoNoiseOn 0x4000000 +#define bTxPesudoNoise_A 0xff +#define bTxPesudoNoise_B 0xff00 +#define bTxPesudoNoise_C 0xff0000 +#define bTxPesudoNoise_D 0xff000000 +#define bCCADropOption 0x20000 +#define bCCADropThres 0xfff00000 +#define bEDCCA_H 0xf +#define bEDCCA_L 0xf0 +#define bLambda_ED 0x300 +#define bRxInitialGain 0x7f +#define bRxAntDivEn 0x80 +#define bRxAGCAddressForLNA 0x7f00 +#define bRxHighPowerFlow 0x8000 +#define bRxAGCFreezeThres 0xc0000 +#define bRxFreezeStep_AGC1 0x300000 +#define bRxFreezeStep_AGC2 0xc00000 +#define bRxFreezeStep_AGC3 0x3000000 +#define bRxFreezeStep_AGC0 0xc000000 +#define bRxRssi_Cmp_En 0x10000000 +#define bRxQuickAGCEn 0x20000000 +#define bRxAGCFreezeThresMode 0x40000000 +#define bRxOverFlowCheckType 0x80000000 +#define bRxAGCShift 0x7f +#define bTRSW_Tri_Only 0x80 +#define bPowerThres 0x300 +#define bRxAGCEn 0x1 +#define bRxAGCTogetherEn 0x2 +#define bRxAGCMin 0x4 +#define bRxHP_Ini 0x7 +#define bRxHP_TRLNA 0x70 +#define bRxHP_RSSI 0x700 +#define bRxHP_BBP1 0x7000 +#define bRxHP_BBP2 0x70000 +#define bRxHP_BBP3 0x700000 +#define bRSSI_H 0x7f0000 /* threshold for high power */ +#define bRSSI_Gen 0x7f000000 /* threshold for ant diversity */ +#define bRxSettle_TRSW 0x7 +#define bRxSettle_LNA 0x38 +#define bRxSettle_RSSI 0x1c0 +#define bRxSettle_BBP 0xe00 +#define bRxSettle_RxHP 0x7000 +#define bRxSettle_AntSW_RSSI 0x38000 +#define bRxSettle_AntSW 0xc0000 +#define bRxProcessTime_DAGC 0x300000 +#define bRxSettle_HSSI 0x400000 +#define bRxProcessTime_BBPPW 0x800000 +#define bRxAntennaPowerShift 0x3000000 +#define bRSSITableSelect 0xc000000 +#define bRxHP_Final 0x7000000 +#define bRxHTSettle_BBP 0x7 +#define bRxHTSettle_HSSI 0x8 +#define bRxHTSettle_RxHP 0x70 +#define bRxHTSettle_BBPPW 0x80 +#define bRxHTSettle_Idle 0x300 +#define bRxHTSettle_Reserved 0x1c00 +#define bRxHTRxHPEn 0x8000 +#define bRxHTAGCFreezeThres 0x30000 +#define bRxHTAGCTogetherEn 0x40000 +#define bRxHTAGCMin 0x80000 +#define bRxHTAGCEn 0x100000 +#define bRxHTDAGCEn 0x200000 +#define bRxHTRxHP_BBP 0x1c00000 +#define bRxHTRxHP_Final 0xe0000000 +#define bRxPWRatioTH 0x3 +#define bRxPWRatioEn 0x4 +#define bRxMFHold 0x3800 +#define bRxPD_Delay_TH1 0x38 +#define bRxPD_Delay_TH2 0x1c0 +#define bRxPD_DC_COUNT_MAX 0x600 +#define bRxPD_Delay_TH 0x8000 +#define bRxProcess_Delay 0xf0000 +#define bRxSearchrange_GI2_Early 0x700000 +#define bRxFrame_Guard_Counter_L 0x3800000 +#define bRxSGI_Guard_L 0xc000000 +#define bRxSGI_Search_L 0x30000000 +#define bRxSGI_TH 0xc0000000 +#define bDFSCnt0 0xff +#define bDFSCnt1 0xff00 +#define bDFSFlag 0xf0000 +#define bMFWeightSum 0x300000 +#define bMinIdxTH 0x7f000000 +#define bDAFormat 0x40000 +#define bTxChEmuEnable 0x01000000 +#define bTRSWIsolation_A 0x7f +#define bTRSWIsolation_B 0x7f00 +#define bTRSWIsolation_C 0x7f0000 +#define bTRSWIsolation_D 0x7f000000 +#define bExtLNAGain 0x7c00 + +/* 6. PageE(0xE00) */ +#define bSTBCEn 0x4 /* Useless */ +#define bAntennaMapping 0x10 +#define bNss 0x20 +#define bCFOAntSumD 0x200 +#define bPHYCounterReset 0x8000000 +#define bCFOReportGet 0x4000000 +#define bOFDMContinueTx 0x10000000 +#define bOFDMSingleCarrier 0x20000000 +#define bOFDMSingleTone 0x40000000 +#define bHTDetect 0x100 +#define bCFOEn 0x10000 +#define bCFOValue 0xfff00000 +#define bSigTone_Re 0x3f +#define bSigTone_Im 0x7f00 +#define bCounter_CCA 0xffff +#define bCounter_ParityFail 0xffff0000 +#define bCounter_RateIllegal 0xffff +#define bCounter_CRC8Fail 0xffff0000 +#define bCounter_MCSNoSupport 0xffff +#define bCounter_FastSync 0xffff +#define bShortCFO 0xfff +#define bShortCFOTLength 12 /* total */ +#define bShortCFOFLength 11 /* fraction */ +#define bLongCFO 0x7ff +#define bLongCFOTLength 11 +#define bLongCFOFLength 11 +#define bTailCFO 0x1fff +#define bTailCFOTLength 13 +#define bTailCFOFLength 12 +#define bmax_en_pwdB 0xffff +#define bCC_power_dB 0xffff0000 +#define bnoise_pwdB 0xffff +#define bPowerMeasTLength 10 +#define bPowerMeasFLength 3 +#define bRx_HT_BW 0x1 +#define bRxSC 0x6 +#define bRx_HT 0x8 +#define bNB_intf_det_on 0x1 +#define bIntf_win_len_cfg 0x30 +#define bNB_Intf_TH_cfg 0x1c0 +#define bRFGain 0x3f +#define bTableSel 0x40 +#define bTRSW 0x80 +#define bRxSNR_A 0xff +#define bRxSNR_B 0xff00 +#define bRxSNR_C 0xff0000 +#define bRxSNR_D 0xff000000 +#define bSNREVMTLength 8 +#define bSNREVMFLength 1 +#define bCSI1st 0xff +#define bCSI2nd 0xff00 +#define bRxEVM1st 0xff0000 +#define bRxEVM2nd 0xff000000 +#define bSIGEVM 0xff +#define bPWDB 0xff00 +#define bSGIEN 0x10000 + +#define bSFactorQAM1 0xf /* Useless */ +#define bSFactorQAM2 0xf0 +#define bSFactorQAM3 0xf00 +#define bSFactorQAM4 0xf000 +#define bSFactorQAM5 0xf0000 +#define bSFactorQAM6 0xf0000 +#define bSFactorQAM7 0xf00000 +#define bSFactorQAM8 0xf000000 +#define bSFactorQAM9 0xf0000000 +#define bCSIScheme 0x100000 + +#define bNoiseLvlTopSet 0x3 /* Useless */ +#define bChSmooth 0x4 +#define bChSmoothCfg1 0x38 +#define bChSmoothCfg2 0x1c0 +#define bChSmoothCfg3 0xe00 +#define bChSmoothCfg4 0x7000 +#define bMRCMode 0x800000 +#define bTHEVMCfg 0x7000000 + +#define bLoopFitType 0x1 /* Useless */ +#define bUpdCFO 0x40 +#define bUpdCFOOffData 0x80 +#define bAdvUpdCFO 0x100 +#define bAdvTimeCtrl 0x800 +#define bUpdClko 0x1000 +#define bFC 0x6000 +#define bTrackingMode 0x8000 +#define bPhCmpEnable 0x10000 +#define bUpdClkoLTF 0x20000 +#define bComChCFO 0x40000 +#define bCSIEstiMode 0x80000 +#define bAdvUpdEqz 0x100000 +#define bUChCfg 0x7000000 +#define bUpdEqz 0x8000000 + +/* Rx Pseduo noise */ +#define bRxPesudoNoiseOn 0x20000000 /* Useless */ +#define bRxPesudoNoise_A 0xff +#define bRxPesudoNoise_B 0xff00 +#define bRxPesudoNoise_C 0xff0000 +#define bRxPesudoNoise_D 0xff000000 +#define bPesudoNoiseState_A 0xffff +#define bPesudoNoiseState_B 0xffff0000 +#define bPesudoNoiseState_C 0xffff +#define bPesudoNoiseState_D 0xffff0000 + +/* 7. RF Register */ +/* Zebra1 */ +#define bZebra1_HSSIEnable 0x8 /* Useless */ +#define bZebra1_TRxControl 0xc00 +#define bZebra1_TRxGainSetting 0x07f +#define bZebra1_RxCorner 0xc00 +#define bZebra1_TxChargePump 0x38 +#define bZebra1_RxChargePump 0x7 +#define bZebra1_ChannelNum 0xf80 +#define bZebra1_TxLPFBW 0x400 +#define bZebra1_RxLPFBW 0x600 + +/* Zebra4 */ +#define bRTL8256RegModeCtrl1 0x100 /* Useless */ +#define bRTL8256RegModeCtrl0 0x40 +#define bRTL8256_TxLPFBW 0x18 +#define bRTL8256_RxLPFBW 0x600 + +/* RTL8258 */ +#define bRTL8258_TxLPFBW 0xc /* Useless */ +#define bRTL8258_RxLPFBW 0xc00 +#define bRTL8258_RSSILPFBW 0xc0 + + +/* */ +/* Other Definition */ +/* */ + +/* byte endable for sb_write */ +#define bByte0 0x1 /* Useless */ +#define bByte1 0x2 +#define bByte2 0x4 +#define bByte3 0x8 +#define bWord0 0x3 +#define bWord1 0xc +#define bDWord 0xf + +/* for PutRegsetting & GetRegSetting BitMask */ +#define bMaskByte0 0xff /* Reg 0xc50 rOFDM0_XAAGCCore~0xC6f */ +#define bMaskByte1 0xff00 +#define bMaskByte2 0xff0000 +#define bMaskByte3 0xff000000 +#define bMaskHWord 0xffff0000 +#define bMaskLWord 0x0000ffff +#define bMaskDWord 0xffffffff +#define bMask12Bits 0xfff +#define bMaskH4Bits 0xf0000000 +#define bMaskOFDM_D 0xffc00000 +#define bMaskCCK 0x3f3f3f3f + +/* for PutRFRegsetting & GetRFRegSetting BitMask */ +#define bRFRegOffsetMask 0xfffff + +#define bEnable 0x1 /* Useless */ +#define bDisable 0x0 + +#define LeftAntenna 0x0 /* Useless */ +#define RightAntenna 0x1 + +#define tCheckTxStatus 500 /* 500ms Useless */ +#define tUpdateRxCounter 100 /* 100ms */ + +#define rateCCK 0 /* Useless */ +#define rateOFDM 1 +#define rateHT 2 + +/* define Register-End */ +#define bPMAC_End 0x1ff /* Useless */ +#define bFPGAPHY0_End 0x8ff +#define bFPGAPHY1_End 0x9ff +#define bCCKPHY0_End 0xaff +#define bOFDMPHY0_End 0xcff +#define bOFDMPHY1_End 0xdff + +#define bPMACControl 0x0 /* Useless */ +#define bWMACControl 0x1 +#define bWNICControl 0x2 + +#define PathA 0x0 /* Useless */ +#define PathB 0x1 +#define PathC 0x2 +#define PathD 0x3 + +/*--------------------------Define Parameters-------------------------------*/ + + +#endif diff --git a/drivers/staging/rtl8188eu/include/Hal8188EPwrSeq.h b/drivers/staging/rtl8188eu/include/Hal8188EPwrSeq.h new file mode 100644 index 0000000000000..20d0b3e3ad714 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/Hal8188EPwrSeq.h @@ -0,0 +1,176 @@ + +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#ifndef __HAL8188EPWRSEQ_H__ +#define __HAL8188EPWRSEQ_H__ + +#include "HalPwrSeqCmd.h" + +/* + Check document WM-20110607-Paul-RTL8188E_Power_Architecture-R02.vsd + There are 6 HW Power States: + 0: POFF--Power Off + 1: PDN--Power Down + 2: CARDEMU--Card Emulation + 3: ACT--Active Mode + 4: LPS--Low Power State + 5: SUS--Suspend + + The transision from different states are defined below + TRANS_CARDEMU_TO_ACT + TRANS_ACT_TO_CARDEMU + TRANS_CARDEMU_TO_SUS + TRANS_SUS_TO_CARDEMU + TRANS_CARDEMU_TO_PDN + TRANS_ACT_TO_LPS + TRANS_LPS_TO_ACT + + TRANS_END + + PWR SEQ Version: rtl8188E_PwrSeq_V09.h +*/ +#define RTL8188E_TRANS_CARDEMU_TO_ACT_STEPS 10 +#define RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS 10 +#define RTL8188E_TRANS_CARDEMU_TO_SUS_STEPS 10 +#define RTL8188E_TRANS_SUS_TO_CARDEMU_STEPS 10 +#define RTL8188E_TRANS_CARDEMU_TO_PDN_STEPS 10 +#define RTL8188E_TRANS_PDN_TO_CARDEMU_STEPS 10 +#define RTL8188E_TRANS_ACT_TO_LPS_STEPS 15 +#define RTL8188E_TRANS_LPS_TO_ACT_STEPS 15 +#define RTL8188E_TRANS_END_STEPS 1 + + +#define RTL8188E_TRANS_CARDEMU_TO_ACT \ + /* format */ \ + /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, comments here*/ \ + {0x0006, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_POLLING, BIT1, BIT1},/* wait till 0x04[17] = 1 power ready*/ \ + {0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT0|BIT1, 0}, /* 0x02[1:0] = 0 reset BB*/ \ + {0x0026, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT7, BIT7}, /*0x24[23] = 2b'01 schmit trigger */ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT7, 0}, /* 0x04[15] = 0 disable HWPDN (control by DRV)*/\ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT4|BIT3, 0}, /*0x04[12:11] = 2b'00 disable WL suspend*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT0, BIT0}, /*0x04[8] = 1 polling until return 0*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_POLLING, BIT0, 0}, /*wait till 0x04[8] = 0*/ \ + {0x0023, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT4, 0}, /*LDO normal mode*/ \ + {0x0074, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT4, BIT4}, /*SDIO Driving*/ \ + +#define RTL8188E_TRANS_ACT_TO_CARDEMU \ + /* format */ \ + /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, comments here*/ \ + {0x001F, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0},/*0x1F[7:0] = 0 turn off RF*/ \ + {0x0023, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT4, BIT4}, /*LDO Sleep mode*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT1, BIT1}, /*0x04[9] = 1 turn off MAC by HW state machine*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_POLLING, BIT1, 0}, /*wait till 0x04[9] = 0 polling until return 0 to disable*/ \ + +#define RTL8188E_TRANS_CARDEMU_TO_SUS \ + /* format */ \ + /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, comments here*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT3|BIT4, BIT3}, /*0x04[12:11] = 2b'01enable WL suspend*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_PCI_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT3|BIT4, BIT3|BIT4}, /*0x04[12:11] = 2b'11enable WL suspend for PCIe*/ \ + {0x0007, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, BIT7}, /* 0x04[31:30] = 2b'10 enable enable bandgap mbias in suspend */ \ + {0x0041, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT4, 0}, /*Clear SIC_EN register 0x40[12] = 1'b0 */ \ + {0xfe10, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT4, BIT4}, /*Set USB suspend enable local register 0xfe10[4]=1 */ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_WRITE, BIT0, BIT0}, /*Set SDIO suspend local register*/ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_POLLING, BIT1, 0}, /*wait power state to suspend*/ + +#define RTL8188E_TRANS_SUS_TO_CARDEMU \ + /* format */ \ + /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, comments here*/ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_WRITE, BIT0, 0}, /*Set SDIO suspend local register*/ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_POLLING, BIT1, BIT1}, /*wait power state to suspend*/\ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT3|BIT4, 0}, /*0x04[12:11] = 2b'01enable WL suspend*/ + +#define RTL8188E_TRANS_CARDEMU_TO_CARDDIS \ + /* format */ \ + /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, comments here*/ \ + {0x0026, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT7, BIT7}, /*0x24[23] = 2b'01 schmit trigger */ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT3|BIT4, BIT3}, /*0x04[12:11] = 2b'01 enable WL suspend*/ \ + {0x0007, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0}, /* 0x04[31:30] = 2b'10 enable enable bandgap mbias in suspend */ \ + {0x0041, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT4, 0}, /*Clear SIC_EN register 0x40[12] = 1'b0 */ \ + {0xfe10, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT4, BIT4}, /*Set USB suspend enable local register 0xfe10[4]=1 */ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_WRITE, BIT0, BIT0}, /*Set SDIO suspend local register*/ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_POLLING, BIT1, 0}, /*wait power state to suspend*/ + +#define RTL8188E_TRANS_CARDDIS_TO_CARDEMU \ + /* format */ \ + /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, comments here*/ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_WRITE, BIT0, 0}, /*Set SDIO suspend local register*/ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_POLLING, BIT1, BIT1}, /*wait power state to suspend*/\ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT3|BIT4, 0}, /*0x04[12:11] = 2b'01enable WL suspend*/ + +#define RTL8188E_TRANS_CARDEMU_TO_PDN \ + /* format */ \ + /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, comments here*/ \ + {0x0006, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT0, 0},/* 0x04[16] = 0*/\ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT7, BIT7},/* 0x04[15] = 1*/ + +#define RTL8188E_TRANS_PDN_TO_CARDEMU \ + /* format */ \ + /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, comments here */ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT7, 0},/* 0x04[15] = 0*/ + +/* This is used by driver for LPSRadioOff Procedure, not for FW LPS Step */ +#define RTL8188E_TRANS_ACT_TO_LPS \ + /* format */ \ + /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, comments here */ \ + {0x0522, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0x7F},/*Tx Pause*/ \ + {0x05F8, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_POLLING, 0xFF, 0},/*Should be zero if no packet is transmitting*/ \ + {0x05F9, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_POLLING, 0xFF, 0},/*Should be zero if no packet is transmitting*/ \ + {0x05FA, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_POLLING, 0xFF, 0},/*Should be zero if no packet is transmitting*/ \ + {0x05FB, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_POLLING, 0xFF, 0},/*Should be zero if no packet is transmitting*/ \ + {0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT0, 0},/*CCK and OFDM are disabled,and clock are gated*/ \ + {0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_DELAY, 0, PWRSEQ_DELAY_US},/*Delay 1us*/ \ + {0x0100, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0x3F},/*Reset MAC TRX*/ \ + {0x0101, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT1, 0},/*check if removed later*/ \ + {0x0553, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT5, BIT5},/*Respond TxOK to scheduler*/ \ + + +#define RTL8188E_TRANS_LPS_TO_ACT \ + /* format */ \ + /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, comments here */ \ + {0x0080, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_WRITE, 0xFF, 0x84}, /*SDIO RPWM*/\ + {0xFE58, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0x84}, /*USB RPWM*/\ + {0x0361, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_PCI_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0x84}, /*PCIe RPWM*/\ + {0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_DELAY, 0, PWRSEQ_DELAY_MS}, /*Delay*/\ + {0x0008, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT4, 0}, /*. 0x08[4] = 0 switch TSF to 40M*/\ + {0x0109, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_POLLING, BIT7, 0}, /*Polling 0x109[7]=0 TSF in 40M*/\ + {0x0029, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT6|BIT7, 0}, /*. 0x29[7:6] = 2b'00 enable BB clock*/\ + {0x0101, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT1, BIT1}, /*. 0x101[1] = 1*/\ + {0x0100, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0xFF}, /*. 0x100[7:0] = 0xFF enable WMAC TRX*/\ + {0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT1|BIT0, BIT1|BIT0}, /*. 0x02[1:0] = 2b'11 enable BB macro*/\ + {0x0522, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0}, /*. 0x522 = 0*/ + +#define RTL8188E_TRANS_END \ + /* format */ \ + /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, comments here*/ \ + {0xFFFF, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,0, PWR_CMD_END, 0, 0}, /* */ + + +extern struct wl_pwr_cfg rtl8188E_power_on_flow[RTL8188E_TRANS_CARDEMU_TO_ACT_STEPS+RTL8188E_TRANS_END_STEPS]; +extern struct wl_pwr_cfg rtl8188E_radio_off_flow[RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS+RTL8188E_TRANS_END_STEPS]; +extern struct wl_pwr_cfg rtl8188E_card_disable_flow[RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS+RTL8188E_TRANS_CARDEMU_TO_PDN_STEPS+RTL8188E_TRANS_END_STEPS]; +extern struct wl_pwr_cfg rtl8188E_card_enable_flow[RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS+RTL8188E_TRANS_CARDEMU_TO_PDN_STEPS+RTL8188E_TRANS_END_STEPS]; +extern struct wl_pwr_cfg rtl8188E_suspend_flow[RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS+RTL8188E_TRANS_CARDEMU_TO_SUS_STEPS+RTL8188E_TRANS_END_STEPS]; +extern struct wl_pwr_cfg rtl8188E_resume_flow[RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS+RTL8188E_TRANS_CARDEMU_TO_SUS_STEPS+RTL8188E_TRANS_END_STEPS]; +extern struct wl_pwr_cfg rtl8188E_hwpdn_flow[RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS+RTL8188E_TRANS_CARDEMU_TO_PDN_STEPS+RTL8188E_TRANS_END_STEPS]; +extern struct wl_pwr_cfg rtl8188E_enter_lps_flow[RTL8188E_TRANS_ACT_TO_LPS_STEPS+RTL8188E_TRANS_END_STEPS]; +extern struct wl_pwr_cfg rtl8188E_leave_lps_flow[RTL8188E_TRANS_LPS_TO_ACT_STEPS+RTL8188E_TRANS_END_STEPS]; + +#endif /* __HAL8188EPWRSEQ_H__ */ diff --git a/drivers/staging/rtl8188eu/include/Hal8188ERateAdaptive.h b/drivers/staging/rtl8188eu/include/Hal8188ERateAdaptive.h new file mode 100644 index 0000000000000..21996a1173ef5 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/Hal8188ERateAdaptive.h @@ -0,0 +1,75 @@ +#ifndef __INC_RA_H +#define __INC_RA_H +/*++ +Copyright (c) Realtek Semiconductor Corp. All rights reserved. + +Module Name: + RateAdaptive.h + +Abstract: + Prototype of RA and related data structure. + +Major Change History: + When Who What + ---------- --------------- ------------------------------- + 2011-08-12 Page Create. +--*/ + +/* Rate adaptive define */ +#define PERENTRY 23 +#define RETRYSIZE 5 +#define RATESIZE 28 +#define TX_RPT2_ITEM_SIZE 8 + +/* */ +/* TX report 2 format in Rx desc */ +/* */ +#define GET_TX_RPT2_DESC_PKT_LEN_88E(__pRxStatusDesc) \ + LE_BITS_TO_4BYTE(__pRxStatusDesc, 0, 9) +#define GET_TX_RPT2_DESC_MACID_VALID_1_88E(__pRxStatusDesc) \ + LE_BITS_TO_4BYTE(__pRxStatusDesc+16, 0, 32) +#define GET_TX_RPT2_DESC_MACID_VALID_2_88E(__pRxStatusDesc) \ + LE_BITS_TO_4BYTE(__pRxStatusDesc+20, 0, 32) + +#define GET_TX_REPORT_TYPE1_RERTY_0(__pAddr) \ + LE_BITS_TO_4BYTE(__pAddr, 0, 16) +#define GET_TX_REPORT_TYPE1_RERTY_1(__pAddr) \ + LE_BITS_TO_1BYTE(__pAddr+2, 0, 8) +#define GET_TX_REPORT_TYPE1_RERTY_2(__pAddr) \ + LE_BITS_TO_1BYTE(__pAddr+3, 0, 8) +#define GET_TX_REPORT_TYPE1_RERTY_3(__pAddr) \ + LE_BITS_TO_1BYTE(__pAddr+4, 0, 8) +#define GET_TX_REPORT_TYPE1_RERTY_4(__pAddr) \ + LE_BITS_TO_1BYTE(__pAddr+4+1, 0, 8) +#define GET_TX_REPORT_TYPE1_DROP_0(__pAddr) \ + LE_BITS_TO_1BYTE(__pAddr+4+2, 0, 8) +#define GET_TX_REPORT_TYPE1_DROP_1(__pAddr) \ + LE_BITS_TO_1BYTE(__pAddr+4+3, 0, 8) + +/* End rate adaptive define */ + +void ODM_RASupport_Init(struct odm_dm_struct *dm_odm); + +int ODM_RAInfo_Init_all(struct odm_dm_struct *dm_odm); + +int ODM_RAInfo_Init(struct odm_dm_struct *dm_odm, u8 MacID); + +u8 ODM_RA_GetShortGI_8188E(struct odm_dm_struct *dm_odm, u8 MacID); + +u8 ODM_RA_GetDecisionRate_8188E(struct odm_dm_struct *dm_odm, u8 MacID); + +u8 ODM_RA_GetHwPwrStatus_8188E(struct odm_dm_struct *dm_odm, u8 MacID); +void ODM_RA_UpdateRateInfo_8188E(struct odm_dm_struct *dm_odm, u8 MacID, + u8 RateID, u32 RateMask, + u8 SGIEnable); + +void ODM_RA_SetRSSI_8188E(struct odm_dm_struct *dm_odm, u8 macid, + u8 rssi); + +void ODM_RA_TxRPT2Handle_8188E(struct odm_dm_struct *dm_odm, + u8 *txrpt_buf, u16 txrpt_len, + u32 validentry0, u32 validentry1); + +void ODM_RA_Set_TxRPT_Time(struct odm_dm_struct *dm_odm, u16 minRptTime); + +#endif diff --git a/drivers/staging/rtl8188eu/include/Hal8188EReg.h b/drivers/staging/rtl8188eu/include/Hal8188EReg.h new file mode 100644 index 0000000000000..d880b0cc803f2 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/Hal8188EReg.h @@ -0,0 +1,46 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +/* */ +/* File Name: Hal8188EReg.h */ +/* */ +/* Description: */ +/* */ +/* This file is for RTL8188E register definition. */ +/* */ +/* */ +/* */ +#ifndef __HAL_8188E_REG_H__ +#define __HAL_8188E_REG_H__ + +/* */ +/* Register Definition */ +/* */ +#define TRX_ANTDIV_PATH 0x860 +#define RX_ANTDIV_PATH 0xb2c +#define ODM_R_A_AGC_CORE1_8188E 0xc50 + + +/* */ +/* Bitmap Definition */ +/* */ +#define BIT_FA_RESET_8188E BIT0 + + +#endif diff --git a/drivers/staging/rtl8188eu/include/HalHWImg8188E_BB.h b/drivers/staging/rtl8188eu/include/HalHWImg8188E_BB.h new file mode 100644 index 0000000000000..e57452104bfb1 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/HalHWImg8188E_BB.h @@ -0,0 +1,44 @@ +/****************************************************************************** +* +* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* 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. +* +* You should have received a copy of the GNU General Public License along with +* this program; if not, write to the Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA +* +* +******************************************************************************/ + +#ifndef __INC_BB_8188E_HW_IMG_H +#define __INC_BB_8188E_HW_IMG_H + +/* static bool CheckCondition(const u32 Condition, const u32 Hex); */ + +/****************************************************************************** +* AGC_TAB_1T.TXT +******************************************************************************/ + +enum HAL_STATUS ODM_ReadAndConfig_AGC_TAB_1T_8188E(struct odm_dm_struct *odm); + +/****************************************************************************** +* PHY_REG_1T.TXT +******************************************************************************/ + +enum HAL_STATUS ODM_ReadAndConfig_PHY_REG_1T_8188E(struct odm_dm_struct *odm); + +/****************************************************************************** +* PHY_REG_PG.TXT +******************************************************************************/ + +void ODM_ReadAndConfig_PHY_REG_PG_8188E(struct odm_dm_struct *dm_odm); + +#endif diff --git a/drivers/staging/rtl8188eu/include/HalHWImg8188E_FW.h b/drivers/staging/rtl8188eu/include/HalHWImg8188E_FW.h new file mode 100644 index 0000000000000..1bf9bc70a6969 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/HalHWImg8188E_FW.h @@ -0,0 +1,34 @@ +/****************************************************************************** +* +* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* 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. +* +* You should have received a copy of the GNU General Public License along with +* this program; if not, write to the Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA +* +* +******************************************************************************/ + +#ifndef __INC_FW_8188E_HW_IMG_H +#define __INC_FW_8188E_HW_IMG_H + + +/****************************************************************************** +* FW_AP.TXT +******************************************************************************/ +/****************************************************************************** +* FW_WoWLAN.TXT +******************************************************************************/ +#define ArrayLength_8188E_FW_WoWLAN 15764 +extern const u8 Array_8188E_FW_WoWLAN[ArrayLength_8188E_FW_WoWLAN]; + +#endif diff --git a/drivers/staging/rtl8188eu/include/HalHWImg8188E_MAC.h b/drivers/staging/rtl8188eu/include/HalHWImg8188E_MAC.h new file mode 100644 index 0000000000000..acf78b94fddb0 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/HalHWImg8188E_MAC.h @@ -0,0 +1,30 @@ +/****************************************************************************** +* +* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* 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. +* +* You should have received a copy of the GNU General Public License along with +* this program; if not, write to the Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA +* +* +******************************************************************************/ + +#ifndef __INC_MAC_8188E_HW_IMG_H +#define __INC_MAC_8188E_HW_IMG_H + +/****************************************************************************** +* MAC_REG.TXT +******************************************************************************/ + +enum HAL_STATUS ODM_ReadAndConfig_MAC_REG_8188E(struct odm_dm_struct *pDM_Odm); + +#endif /* end of HWIMG_SUPPORT */ diff --git a/drivers/staging/rtl8188eu/include/HalHWImg8188E_RF.h b/drivers/staging/rtl8188eu/include/HalHWImg8188E_RF.h new file mode 100644 index 0000000000000..8ecb40d26c700 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/HalHWImg8188E_RF.h @@ -0,0 +1,30 @@ +/****************************************************************************** +* +* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* 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. +* +* You should have received a copy of the GNU General Public License along with +* this program; if not, write to the Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA +* +* +******************************************************************************/ + +#ifndef __INC_RF_8188E_HW_IMG_H +#define __INC_RF_8188E_HW_IMG_H + +/****************************************************************************** + * RadioA_1T.TXT + ******************************************************************************/ + +enum HAL_STATUS ODM_ReadAndConfig_RadioA_1T_8188E(struct odm_dm_struct *odm); + +#endif /* end of HWIMG_SUPPORT */ diff --git a/drivers/staging/rtl8188eu/include/HalPhyRf.h b/drivers/staging/rtl8188eu/include/HalPhyRf.h new file mode 100644 index 0000000000000..1ec497100da14 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/HalPhyRf.h @@ -0,0 +1,30 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + + #ifndef __HAL_PHY_RF_H__ + #define __HAL_PHY_RF_H__ + +#define ODM_TARGET_CHNL_NUM_2G_5G 59 + +void ODM_ResetIQKResult(struct odm_dm_struct *pDM_Odm); + +u8 ODM_GetRightChnlPlaceforIQK(u8 chnl); + +#endif /* #ifndef __HAL_PHY_RF_H__ */ diff --git a/drivers/staging/rtl8188eu/include/HalPhyRf_8188e.h b/drivers/staging/rtl8188eu/include/HalPhyRf_8188e.h new file mode 100644 index 0000000000000..fa583f2483201 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/HalPhyRf_8188e.h @@ -0,0 +1,63 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#ifndef __HAL_PHY_RF_8188E_H__ +#define __HAL_PHY_RF_8188E_H__ + +/*--------------------------Define Parameters-------------------------------*/ +#define IQK_DELAY_TIME_88E 10 /* ms */ +#define index_mapping_NUM_88E 15 +#define AVG_THERMAL_NUM_88E 4 + + +void ODM_TxPwrTrackAdjust88E(struct odm_dm_struct *pDM_Odm, + u8 Type, /* 0 = OFDM, 1 = CCK */ + u8 *pDirection,/* 1 = +(incr) 2 = -(decr) */ + u32 *pOutWriteVal); /* Tx tracking CCK/OFDM BB + * swing index adjust */ + + +void odm_TXPowerTrackingCallback_ThermalMeter_8188E(struct adapter *Adapter); + + +/* 1 7. IQK */ + +void PHY_IQCalibrate_8188E(struct adapter *Adapter, bool ReCovery); + +/* LC calibrate */ +void PHY_LCCalibrate_8188E(struct adapter *pAdapter); + +/* AP calibrate */ +void PHY_APCalibrate_8188E(struct adapter *pAdapter, s8 delta); + +void PHY_DigitalPredistortion_8188E(struct adapter *pAdapter); + +void _PHY_SaveADDARegisters(struct adapter *pAdapter, u32 *ADDAReg, + u32 *ADDABackup, u32 RegisterNum); + +void _PHY_PathADDAOn(struct adapter *pAdapter, u32 *ADDAReg, + bool isPathAOn, bool is2T); + +void _PHY_MACSettingCalibration(struct adapter *pAdapter, u32 *MACReg, + u32 *MACBackup); + +void _PHY_PathAStandBy(struct adapter *pAdapter); + +#endif /* #ifndef __HAL_PHY_RF_8188E_H__ */ diff --git a/drivers/staging/rtl8188eu/include/HalPwrSeqCmd.h b/drivers/staging/rtl8188eu/include/HalPwrSeqCmd.h new file mode 100644 index 0000000000000..d945784ed5d9a --- /dev/null +++ b/drivers/staging/rtl8188eu/include/HalPwrSeqCmd.h @@ -0,0 +1,128 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __HALPWRSEQCMD_H__ +#define __HALPWRSEQCMD_H__ + +#include + +/*---------------------------------------------*/ +/* 3 The value of cmd: 4 bits */ +/*---------------------------------------------*/ +#define PWR_CMD_READ 0x00 + /* offset: the read register offset */ + /* msk: the mask of the read value */ + /* value: N/A, left by 0 */ + /* note: dirver shall implement this function by read & msk */ + +#define PWR_CMD_WRITE 0x01 + /* offset: the read register offset */ + /* msk: the mask of the write bits */ + /* value: write value */ + /* note: driver shall implement this cmd by read & msk after write */ + +#define PWR_CMD_POLLING 0x02 + /* offset: the read register offset */ + /* msk: the mask of the polled value */ + /* value: the value to be polled, masked by the msd field. */ + /* note: driver shall implement this cmd by */ + /* do{ */ + /* if ( (Read(offset) & msk) == (value & msk) ) */ + /* break; */ + /* } while (not timeout); */ + +#define PWR_CMD_DELAY 0x03 + /* offset: the value to delay */ + /* msk: N/A */ + /* value: the unit of delay, 0: us, 1: ms */ + +#define PWR_CMD_END 0x04 + /* offset: N/A */ + /* msk: N/A */ + /* value: N/A */ + +/*---------------------------------------------*/ +/* 3 The value of base: 4 bits */ +/*---------------------------------------------*/ + /* define the base address of each block */ +#define PWR_BASEADDR_MAC 0x00 +#define PWR_BASEADDR_USB 0x01 +#define PWR_BASEADDR_PCIE 0x02 +#define PWR_BASEADDR_SDIO 0x03 + +/*---------------------------------------------*/ +/* 3 The value of interface_msk: 4 bits */ +/*---------------------------------------------*/ +#define PWR_INTF_SDIO_MSK BIT(0) +#define PWR_INTF_USB_MSK BIT(1) +#define PWR_INTF_PCI_MSK BIT(2) +#define PWR_INTF_ALL_MSK (BIT(0)|BIT(1)|BIT(2)|BIT(3)) + +/*---------------------------------------------*/ +/* 3 The value of fab_msk: 4 bits */ +/*---------------------------------------------*/ +#define PWR_FAB_TSMC_MSK BIT(0) +#define PWR_FAB_UMC_MSK BIT(1) +#define PWR_FAB_ALL_MSK (BIT(0)|BIT(1)|BIT(2)|BIT(3)) + +/*---------------------------------------------*/ +/* 3 The value of cut_msk: 8 bits */ +/*---------------------------------------------*/ +#define PWR_CUT_TESTCHIP_MSK BIT(0) +#define PWR_CUT_A_MSK BIT(1) +#define PWR_CUT_B_MSK BIT(2) +#define PWR_CUT_C_MSK BIT(3) +#define PWR_CUT_D_MSK BIT(4) +#define PWR_CUT_E_MSK BIT(5) +#define PWR_CUT_F_MSK BIT(6) +#define PWR_CUT_G_MSK BIT(7) +#define PWR_CUT_ALL_MSK 0xFF + + +enum pwrseq_cmd_delat_unit { + PWRSEQ_DELAY_US, + PWRSEQ_DELAY_MS, +}; + +struct wl_pwr_cfg { + u16 offset; + u8 cut_msk; + u8 fab_msk:4; + u8 interface_msk:4; + u8 base:4; + u8 cmd:4; + u8 msk; + u8 value; +}; + +#define GET_PWR_CFG_OFFSET(__PWR_CMD) __PWR_CMD.offset +#define GET_PWR_CFG_CUT_MASK(__PWR_CMD) __PWR_CMD.cut_msk +#define GET_PWR_CFG_FAB_MASK(__PWR_CMD) __PWR_CMD.fab_msk +#define GET_PWR_CFG_INTF_MASK(__PWR_CMD) __PWR_CMD.interface_msk +#define GET_PWR_CFG_BASE(__PWR_CMD) __PWR_CMD.base +#define GET_PWR_CFG_CMD(__PWR_CMD) __PWR_CMD.cmd +#define GET_PWR_CFG_MASK(__PWR_CMD) __PWR_CMD.msk +#define GET_PWR_CFG_VALUE(__PWR_CMD) __PWR_CMD.value + + +/* Prototype of protected function. */ +u8 HalPwrSeqCmdParsing(struct adapter *padapter, u8 CutVersion, u8 FabVersion, + u8 InterfaceType, struct wl_pwr_cfg PwrCfgCmd[]); + +#endif diff --git a/drivers/staging/rtl8188eu/include/HalVerDef.h b/drivers/staging/rtl8188eu/include/HalVerDef.h new file mode 100644 index 0000000000000..97047cf06780f --- /dev/null +++ b/drivers/staging/rtl8188eu/include/HalVerDef.h @@ -0,0 +1,167 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __HAL_VERSION_DEF_H__ +#define __HAL_VERSION_DEF_H__ + +enum HAL_IC_TYPE { + CHIP_8192S = 0, + CHIP_8188C = 1, + CHIP_8192C = 2, + CHIP_8192D = 3, + CHIP_8723A = 4, + CHIP_8188E = 5, + CHIP_8881A = 6, + CHIP_8812A = 7, + CHIP_8821A = 8, + CHIP_8723B = 9, + CHIP_8192E = 10, +}; + +enum HAL_CHIP_TYPE { + TEST_CHIP = 0, + NORMAL_CHIP = 1, + FPGA = 2, +}; + +enum HAL_CUT_VERSION { + A_CUT_VERSION = 0, + B_CUT_VERSION = 1, + C_CUT_VERSION = 2, + D_CUT_VERSION = 3, + E_CUT_VERSION = 4, + F_CUT_VERSION = 5, + G_CUT_VERSION = 6, +}; + +enum HAL_VENDOR { + CHIP_VENDOR_TSMC = 0, + CHIP_VENDOR_UMC = 1, +}; + +enum HAL_RF_TYPE { + RF_TYPE_1T1R = 0, + RF_TYPE_1T2R = 1, + RF_TYPE_2T2R = 2, + RF_TYPE_2T3R = 3, + RF_TYPE_2T4R = 4, + RF_TYPE_3T3R = 5, + RF_TYPE_3T4R = 6, + RF_TYPE_4T4R = 7, +}; + +struct HAL_VERSION { + enum HAL_IC_TYPE ICType; + enum HAL_CHIP_TYPE ChipType; + enum HAL_CUT_VERSION CUTVersion; + enum HAL_VENDOR VendorType; + enum HAL_RF_TYPE RFType; + u8 ROMVer; +}; + +/* Get element */ +#define GET_CVID_IC_TYPE(version) (((version).ICType)) +#define GET_CVID_CHIP_TYPE(version) (((version).ChipType)) +#define GET_CVID_RF_TYPE(version) (((version).RFType)) +#define GET_CVID_MANUFACTUER(version) (((version).VendorType)) +#define GET_CVID_CUT_VERSION(version) (((version).CUTVersion)) +#define GET_CVID_ROM_VERSION(version) (((version).ROMVer) & ROM_VERSION_MASK) + +/* Common Macro. -- */ +/* HAL_VERSION VersionID */ + +/* HAL_IC_TYPE_E */ +#define IS_81XXC(version) \ + (((GET_CVID_IC_TYPE(version) == CHIP_8192C) || \ + (GET_CVID_IC_TYPE(version) == CHIP_8188C)) ? true : false) +#define IS_8723_SERIES(version) \ + ((GET_CVID_IC_TYPE(version) == CHIP_8723A) ? true : false) +#define IS_92D(version) \ + ((GET_CVID_IC_TYPE(version) == CHIP_8192D) ? true : false) +#define IS_8188E(version) \ + ((GET_CVID_IC_TYPE(version) == CHIP_8188E) ? true : false) + +/* HAL_CHIP_TYPE_E */ +#define IS_TEST_CHIP(version) \ + ((GET_CVID_CHIP_TYPE(version) == TEST_CHIP) ? true : false) +#define IS_NORMAL_CHIP(version) \ + ((GET_CVID_CHIP_TYPE(version) == NORMAL_CHIP) ? true : false) + +/* HAL_CUT_VERSION_E */ +#define IS_A_CUT(version) \ + ((GET_CVID_CUT_VERSION(version) == A_CUT_VERSION) ? true : false) +#define IS_B_CUT(version) \ + ((GET_CVID_CUT_VERSION(version) == B_CUT_VERSION) ? true : false) +#define IS_C_CUT(version) \ + ((GET_CVID_CUT_VERSION(version) == C_CUT_VERSION) ? true : false) +#define IS_D_CUT(version) \ + ((GET_CVID_CUT_VERSION(version) == D_CUT_VERSION) ? true : false) +#define IS_E_CUT(version) \ + ((GET_CVID_CUT_VERSION(version) == E_CUT_VERSION) ? true : false) + + +/* HAL_VENDOR_E */ +#define IS_CHIP_VENDOR_TSMC(version) \ + ((GET_CVID_MANUFACTUER(version) == CHIP_VENDOR_TSMC) ? true : false) +#define IS_CHIP_VENDOR_UMC(version) \ + ((GET_CVID_MANUFACTUER(version) == CHIP_VENDOR_UMC) ? true : false) + +/* HAL_RF_TYPE_E */ +#define IS_1T1R(version) \ + ((GET_CVID_RF_TYPE(version) == RF_TYPE_1T1R) ? true : false) +#define IS_1T2R(version) \ + ((GET_CVID_RF_TYPE(version) == RF_TYPE_1T2R) ? true : false) +#define IS_2T2R(version) \ + ((GET_CVID_RF_TYPE(version) == RF_TYPE_2T2R) ? true : false) + +/* Chip version Macro. -- */ +#define IS_81XXC_TEST_CHIP(version) \ + ((IS_81XXC(version) && (!IS_NORMAL_CHIP(version))) ? true : false) + +#define IS_92C_SERIAL(version) \ + ((IS_81XXC(version) && IS_2T2R(version)) ? true : false) +#define IS_81xxC_VENDOR_UMC_A_CUT(version) \ + (IS_81XXC(version) ? (IS_CHIP_VENDOR_UMC(version) ? \ + (IS_A_CUT(version) ? true : false) : false) : false) +#define IS_81xxC_VENDOR_UMC_B_CUT(version) \ + (IS_81XXC(version) ? (IS_CHIP_VENDOR_UMC(version) ? \ + (IS_B_CUT(version) ? true : false) : false) : false) +#define IS_81xxC_VENDOR_UMC_C_CUT(version) \ + (IS_81XXC(version) ? (IS_CHIP_VENDOR_UMC(version) ? \ + (IS_C_CUT(version) ? true : false) : false) : false) + +#define IS_NORMAL_CHIP92D(version) \ + ((IS_92D(version)) ? \ + ((GET_CVID_CHIP_TYPE(version) == NORMAL_CHIP) ? true : false) : false) + +#define IS_92D_SINGLEPHY(version) \ + ((IS_92D(version)) ? (IS_2T2R(version) ? true : false) : false) +#define IS_92D_C_CUT(version) \ + ((IS_92D(version)) ? (IS_C_CUT(version) ? true : false) : false) +#define IS_92D_D_CUT(version) \ + ((IS_92D(version)) ? (IS_D_CUT(version) ? true : false) : false) +#define IS_92D_E_CUT(version) \ + ((IS_92D(version)) ? (IS_E_CUT(version) ? true : false) : false) + +#define IS_8723A_A_CUT(version) \ + ((IS_8723_SERIES(version)) ? (IS_A_CUT(version) ? true : false) : false) +#define IS_8723A_B_CUT(version) \ + ((IS_8723_SERIES(version)) ? (IS_B_CUT(version) ? true : false) : false) + +#endif -- GitLab From fe223017c4cc99bb36426e8e97545624350dd2d4 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 21 Aug 2013 22:34:05 -0500 Subject: [PATCH 781/942] staging: r8188eu: Add files for new driver - part 23 This commit adds files include/ieee80211.h, include/ieee80211_ext.h, include/if_ether.h, include/ioctl_cfg80211.h, include/ip.h, include/mlme_osdep.h, include/mp_custom_oid.h, and include/nic_spec.h. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/ieee80211.h | 1274 +++++++++++++++++ .../staging/rtl8188eu/include/ieee80211_ext.h | 290 ++++ drivers/staging/rtl8188eu/include/if_ether.h | 111 ++ .../rtl8188eu/include/ioctl_cfg80211.h | 107 ++ drivers/staging/rtl8188eu/include/ip.h | 126 ++ .../staging/rtl8188eu/include/mlme_osdep.h | 35 + .../staging/rtl8188eu/include/mp_custom_oid.h | 352 +++++ drivers/staging/rtl8188eu/include/nic_spec.h | 44 + 8 files changed, 2339 insertions(+) create mode 100644 drivers/staging/rtl8188eu/include/ieee80211.h create mode 100644 drivers/staging/rtl8188eu/include/ieee80211_ext.h create mode 100644 drivers/staging/rtl8188eu/include/if_ether.h create mode 100644 drivers/staging/rtl8188eu/include/ioctl_cfg80211.h create mode 100644 drivers/staging/rtl8188eu/include/ip.h create mode 100644 drivers/staging/rtl8188eu/include/mlme_osdep.h create mode 100644 drivers/staging/rtl8188eu/include/mp_custom_oid.h create mode 100644 drivers/staging/rtl8188eu/include/nic_spec.h diff --git a/drivers/staging/rtl8188eu/include/ieee80211.h b/drivers/staging/rtl8188eu/include/ieee80211.h new file mode 100644 index 0000000000000..cd37ea4df4cbe --- /dev/null +++ b/drivers/staging/rtl8188eu/include/ieee80211.h @@ -0,0 +1,1274 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __IEEE80211_H +#define __IEEE80211_H + +#include +#include +#include "wifi.h" +#include + +#define MGMT_QUEUE_NUM 5 + +#define ETH_ALEN 6 +#define ETH_TYPE_LEN 2 +#define PAYLOAD_TYPE_LEN 1 + +#ifdef CONFIG_88EU_AP_MODE + +#define RTL_IOCTL_HOSTAPD (SIOCIWFIRSTPRIV + 28) + +/* RTL871X_IOCTL_HOSTAPD ioctl() cmd: */ +enum { + RTL871X_HOSTAPD_FLUSH = 1, + RTL871X_HOSTAPD_ADD_STA = 2, + RTL871X_HOSTAPD_REMOVE_STA = 3, + RTL871X_HOSTAPD_GET_INFO_STA = 4, + /* REMOVED: PRISM2_HOSTAPD_RESET_TXEXC_STA = 5, */ + RTL871X_HOSTAPD_GET_WPAIE_STA = 5, + RTL871X_SET_ENCRYPTION = 6, + RTL871X_GET_ENCRYPTION = 7, + RTL871X_HOSTAPD_SET_FLAGS_STA = 8, + RTL871X_HOSTAPD_GET_RID = 9, + RTL871X_HOSTAPD_SET_RID = 10, + RTL871X_HOSTAPD_SET_ASSOC_AP_ADDR = 11, + RTL871X_HOSTAPD_SET_GENERIC_ELEMENT = 12, + RTL871X_HOSTAPD_MLME = 13, + RTL871X_HOSTAPD_SCAN_REQ = 14, + RTL871X_HOSTAPD_STA_CLEAR_STATS = 15, + RTL871X_HOSTAPD_SET_BEACON = 16, + RTL871X_HOSTAPD_SET_WPS_BEACON = 17, + RTL871X_HOSTAPD_SET_WPS_PROBE_RESP = 18, + RTL871X_HOSTAPD_SET_WPS_ASSOC_RESP = 19, + RTL871X_HOSTAPD_SET_HIDDEN_SSID = 20, + RTL871X_HOSTAPD_SET_MACADDR_ACL = 21, + RTL871X_HOSTAPD_ACL_ADD_STA = 22, + RTL871X_HOSTAPD_ACL_REMOVE_STA = 23, +}; + +/* STA flags */ +#define WLAN_STA_AUTH BIT(0) +#define WLAN_STA_ASSOC BIT(1) +#define WLAN_STA_PS BIT(2) +#define WLAN_STA_TIM BIT(3) +#define WLAN_STA_PERM BIT(4) +#define WLAN_STA_AUTHORIZED BIT(5) +#define WLAN_STA_PENDING_POLL BIT(6) /* pending activity poll not ACKed */ +#define WLAN_STA_SHORT_PREAMBLE BIT(7) +#define WLAN_STA_PREAUTH BIT(8) +#define WLAN_STA_WME BIT(9) +#define WLAN_STA_MFP BIT(10) +#define WLAN_STA_HT BIT(11) +#define WLAN_STA_WPS BIT(12) +#define WLAN_STA_MAYBE_WPS BIT(13) +#define WLAN_STA_NONERP BIT(31) + +#endif + +#define IEEE_CMD_SET_WPA_PARAM 1 +#define IEEE_CMD_SET_WPA_IE 2 +#define IEEE_CMD_SET_ENCRYPTION 3 +#define IEEE_CMD_MLME 4 + +#define IEEE_PARAM_WPA_ENABLED 1 +#define IEEE_PARAM_TKIP_COUNTERMEASURES 2 +#define IEEE_PARAM_DROP_UNENCRYPTED 3 +#define IEEE_PARAM_PRIVACY_INVOKED 4 +#define IEEE_PARAM_AUTH_ALGS 5 +#define IEEE_PARAM_IEEE_802_1X 6 +#define IEEE_PARAM_WPAX_SELECT 7 + +#define AUTH_ALG_OPEN_SYSTEM 0x1 +#define AUTH_ALG_SHARED_KEY 0x2 +#define AUTH_ALG_LEAP 0x00000004 + +#define IEEE_MLME_STA_DEAUTH 1 +#define IEEE_MLME_STA_DISASSOC 2 + +#define IEEE_CRYPT_ERR_UNKNOWN_ALG 2 +#define IEEE_CRYPT_ERR_UNKNOWN_ADDR 3 +#define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED 4 +#define IEEE_CRYPT_ERR_KEY_SET_FAILED 5 +#define IEEE_CRYPT_ERR_TX_KEY_SET_FAILED 6 +#define IEEE_CRYPT_ERR_CARD_CONF_FAILED 7 + + +#define IEEE_CRYPT_ALG_NAME_LEN 16 + +#define WPA_CIPHER_NONE BIT(0) +#define WPA_CIPHER_WEP40 BIT(1) +#define WPA_CIPHER_WEP104 BIT(2) +#define WPA_CIPHER_TKIP BIT(3) +#define WPA_CIPHER_CCMP BIT(4) + + + +#define WPA_SELECTOR_LEN 4 +extern u8 RTW_WPA_OUI_TYPE[]; +extern u16 RTW_WPA_VERSION; +extern u8 WPA_AUTH_KEY_MGMT_NONE[]; +extern u8 WPA_AUTH_KEY_MGMT_UNSPEC_802_1X[]; +extern u8 WPA_AUTH_KEY_MGMT_PSK_OVER_802_1X[]; +extern u8 WPA_CIPHER_SUITE_NONE[]; +extern u8 WPA_CIPHER_SUITE_WEP40[]; +extern u8 WPA_CIPHER_SUITE_TKIP[]; +extern u8 WPA_CIPHER_SUITE_WRAP[]; +extern u8 WPA_CIPHER_SUITE_CCMP[]; +extern u8 WPA_CIPHER_SUITE_WEP104[]; + + +#define RSN_HEADER_LEN 4 +#define RSN_SELECTOR_LEN 4 + +extern u16 RSN_VERSION_BSD; +extern u8 RSN_AUTH_KEY_MGMT_UNSPEC_802_1X[]; +extern u8 RSN_AUTH_KEY_MGMT_PSK_OVER_802_1X[]; +extern u8 RSN_CIPHER_SUITE_NONE[]; +extern u8 RSN_CIPHER_SUITE_WEP40[]; +extern u8 RSN_CIPHER_SUITE_TKIP[]; +extern u8 RSN_CIPHER_SUITE_WRAP[]; +extern u8 RSN_CIPHER_SUITE_CCMP[]; +extern u8 RSN_CIPHER_SUITE_WEP104[]; + +enum ratr_table_mode { + RATR_INX_WIRELESS_NGB = 0, /* BGN 40 Mhz 2SS 1SS */ + RATR_INX_WIRELESS_NG = 1, /* GN or N */ + RATR_INX_WIRELESS_NB = 2, /* BGN 20 Mhz 2SS 1SS or BN */ + RATR_INX_WIRELESS_N = 3, + RATR_INX_WIRELESS_GB = 4, + RATR_INX_WIRELESS_G = 5, + RATR_INX_WIRELESS_B = 6, + RATR_INX_WIRELESS_MC = 7, + RATR_INX_WIRELESS_AC_N = 8, +}; + +enum NETWORK_TYPE { + WIRELESS_INVALID = 0, + /* Sub-Element */ + WIRELESS_11B = BIT(0), /* tx:cck only, rx:cck only, hw: cck */ + WIRELESS_11G = BIT(1), /* tx:ofdm only, rx:ofdm & cck, hw:cck & ofdm*/ + WIRELESS_11A = BIT(2), /* tx:ofdm only, rx: ofdm only, hw:ofdm only */ + WIRELESS_11_24N = BIT(3), /* tx:MCS only, rx:MCS & cck, hw:MCS & cck */ + WIRELESS_11_5N = BIT(4), /* tx:MCS only, rx:MCS & ofdm, hw:ofdm only */ + WIRELESS_AC = BIT(6), + + /* Combination */ + /* tx: cck & ofdm, rx: cck & ofdm & MCS, hw: cck & ofdm */ + WIRELESS_11BG = (WIRELESS_11B | WIRELESS_11G), + /* tx: ofdm & MCS, rx: ofdm & cck & MCS, hw: cck & ofdm */ + WIRELESS_11G_24N = (WIRELESS_11G | WIRELESS_11_24N), + /* tx: ofdm & MCS, rx: ofdm & MCS, hw: ofdm only */ + WIRELESS_11A_5N = (WIRELESS_11A | WIRELESS_11_5N), + /* tx: ofdm & cck & MCS, rx: ofdm & cck & MCS, hw: ofdm & cck */ + WIRELESS_11BG_24N = (WIRELESS_11B | WIRELESS_11G | WIRELESS_11_24N), + /* tx: ofdm & MCS, rx: ofdm & MCS, hw: ofdm only */ + WIRELESS_11AGN = (WIRELESS_11A | WIRELESS_11G | WIRELESS_11_24N | + WIRELESS_11_5N), + WIRELESS_11ABGN = (WIRELESS_11A | WIRELESS_11B | WIRELESS_11G | + WIRELESS_11_24N | WIRELESS_11_5N), +}; + +#define SUPPORTED_24G_NETTYPE_MSK \ + (WIRELESS_11B | WIRELESS_11G | WIRELESS_11_24N) +#define SUPPORTED_5G_NETTYPE_MSK \ + (WIRELESS_11A | WIRELESS_11_5N) + +#define IsSupported24G(NetType) \ + ((NetType) & SUPPORTED_24G_NETTYPE_MSK ? true : false) +#define IsSupported5G(NetType) \ + ((NetType) & SUPPORTED_5G_NETTYPE_MSK ? true : false) + +#define IsEnableHWCCK(NetType) \ + IsSupported24G(NetType) +#define IsEnableHWOFDM(NetType) \ + ((NetType) & (WIRELESS_11G | WIRELESS_11_24N | \ + SUPPORTED_5G_NETTYPE_MSK) ? true : false) + +#define IsSupportedRxCCK(NetType) IsEnableHWCCK(NetType) +#define IsSupportedRxOFDM(NetType) IsEnableHWOFDM(NetType) +#define IsSupportedRxMCS(NetType) IsEnableHWOFDM(NetType) + +#define IsSupportedTxCCK(NetType) \ + ((NetType) & (WIRELESS_11B) ? true : false) +#define IsSupportedTxOFDM(NetType) \ + ((NetType) & (WIRELESS_11G|WIRELESS_11A) ? true : false) +#define IsSupportedTxMCS(NetType) \ + ((NetType) & (WIRELESS_11_24N|WIRELESS_11_5N) ? true : false) + + +struct ieee_param { + u32 cmd; + u8 sta_addr[ETH_ALEN]; + union { + struct { + u8 name; + u32 value; + } wpa_param; + struct { + u32 len; + u8 reserved[32]; + u8 data[0]; + } wpa_ie; + struct { + int command; + int reason_code; + } mlme; + struct { + u8 alg[IEEE_CRYPT_ALG_NAME_LEN]; + u8 set_tx; + u32 err; + u8 idx; + u8 seq[8]; /* sequence counter (set: RX, get: TX) */ + u16 key_len; + u8 key[0]; + } crypt; +#ifdef CONFIG_88EU_AP_MODE + struct { + u16 aid; + u16 capability; + int flags; + u8 tx_supp_rates[16]; + struct rtw_ieee80211_ht_cap ht_cap; + } add_sta; + struct { + u8 reserved[2];/* for set max_num_sta */ + u8 buf[0]; + } bcn_ie; +#endif + + } u; +}; + +#ifdef CONFIG_88EU_AP_MODE +struct ieee_param_ex { + u32 cmd; + u8 sta_addr[ETH_ALEN]; + u8 data[0]; +}; + +struct sta_data { + u16 aid; + u16 capability; + int flags; + u32 sta_set; + u8 tx_supp_rates[16]; + u32 tx_supp_rates_len; + struct rtw_ieee80211_ht_cap ht_cap; + u64 rx_pkts; + u64 rx_bytes; + u64 rx_drops; + u64 tx_pkts; + u64 tx_bytes; + u64 tx_drops; +}; +#endif + +#define IEEE80211_DATA_LEN 2304 +/* Maximum size for the MA-UNITDATA primitive, 802.11 standard section + 6.2.1.1.2. + + The figure in section 7.1.2 suggests a body size of up to 2312 + bytes is allowed, which is a bit confusing, I suspect this + represents the 2304 bytes of real data, plus a possible 8 bytes of + WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */ + + +#define IEEE80211_HLEN 30 +#define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN) + + +/* this is stolen from ipw2200 driver */ +#define IEEE_IBSS_MAC_HASH_SIZE 31 + +struct ieee_ibss_seq { + u8 mac[ETH_ALEN]; + u16 seq_num; + u16 frag_num; + unsigned long packet_time; + struct list_head list; +}; + +struct rtw_ieee80211_hdr { + u16 frame_ctl; + u16 duration_id; + u8 addr1[ETH_ALEN]; + u8 addr2[ETH_ALEN]; + u8 addr3[ETH_ALEN]; + u16 seq_ctl; + u8 addr4[ETH_ALEN]; +} __packed; + +struct rtw_ieee80211_hdr_3addr { + u16 frame_ctl; + u16 duration_id; + u8 addr1[ETH_ALEN]; + u8 addr2[ETH_ALEN]; + u8 addr3[ETH_ALEN]; + u16 seq_ctl; +} __packed; + +struct rtw_ieee80211_hdr_qos { + u16 frame_ctl; + u16 duration_id; + u8 addr1[ETH_ALEN]; + u8 addr2[ETH_ALEN]; + u8 addr3[ETH_ALEN]; + u16 seq_ctl; + u8 addr4[ETH_ALEN]; + u16 qc; +} __packed; + +struct rtw_ieee80211_hdr_3addr_qos { + u16 frame_ctl; + u16 duration_id; + u8 addr1[ETH_ALEN]; + u8 addr2[ETH_ALEN]; + u8 addr3[ETH_ALEN]; + u16 seq_ctl; + u16 qc; +} __packed; + +struct eapol { + u8 snap[6]; + u16 ethertype; + u8 version; + u8 type; + u16 length; +} __packed; + +enum eap_type { + EAP_PACKET = 0, + EAPOL_START, + EAPOL_LOGOFF, + EAPOL_KEY, + EAPOL_ENCAP_ASF_ALERT +}; + +#define IEEE80211_3ADDR_LEN 24 +#define IEEE80211_4ADDR_LEN 30 +#define IEEE80211_FCS_LEN 4 + +#define MIN_FRAG_THRESHOLD 256U +#define MAX_FRAG_THRESHOLD 2346U + +/* Frame control field constants */ +#define RTW_IEEE80211_FCTL_VERS 0x0003 +#define RTW_IEEE80211_FCTL_FTYPE 0x000c +#define RTW_IEEE80211_FCTL_STYPE 0x00f0 +#define RTW_IEEE80211_FCTL_TODS 0x0100 +#define RTW_IEEE80211_FCTL_FROMDS 0x0200 +#define RTW_IEEE80211_FCTL_MOREFRAGS 0x0400 +#define RTW_IEEE80211_FCTL_RETRY 0x0800 +#define RTW_IEEE80211_FCTL_PM 0x1000 +#define RTW_IEEE80211_FCTL_MOREDATA 0x2000 +#define RTW_IEEE80211_FCTL_PROTECTED 0x4000 +#define RTW_IEEE80211_FCTL_ORDER 0x8000 +#define RTW_IEEE80211_FCTL_CTL_EXT 0x0f00 + +#define RTW_IEEE80211_FTYPE_MGMT 0x0000 +#define RTW_IEEE80211_FTYPE_CTL 0x0004 +#define RTW_IEEE80211_FTYPE_DATA 0x0008 +#define RTW_IEEE80211_FTYPE_EXT 0x000c + +/* management */ +#define RTW_IEEE80211_STYPE_ASSOC_REQ 0x0000 +#define RTW_IEEE80211_STYPE_ASSOC_RESP 0x0010 +#define RTW_IEEE80211_STYPE_REASSOC_REQ 0x0020 +#define RTW_IEEE80211_STYPE_REASSOC_RESP 0x0030 +#define RTW_IEEE80211_STYPE_PROBE_REQ 0x0040 +#define RTW_IEEE80211_STYPE_PROBE_RESP 0x0050 +#define RTW_IEEE80211_STYPE_BEACON 0x0080 +#define RTW_IEEE80211_STYPE_ATIM 0x0090 +#define RTW_IEEE80211_STYPE_DISASSOC 0x00A0 +#define RTW_IEEE80211_STYPE_AUTH 0x00B0 +#define RTW_IEEE80211_STYPE_DEAUTH 0x00C0 +#define RTW_IEEE80211_STYPE_ACTION 0x00D0 + +/* control */ +#define RTW_IEEE80211_STYPE_CTL_EXT 0x0060 +#define RTW_IEEE80211_STYPE_BACK_REQ 0x0080 +#define RTW_IEEE80211_STYPE_BACK 0x0090 +#define RTW_IEEE80211_STYPE_PSPOLL 0x00A0 +#define RTW_IEEE80211_STYPE_RTS 0x00B0 +#define RTW_IEEE80211_STYPE_CTS 0x00C0 +#define RTW_IEEE80211_STYPE_ACK 0x00D0 +#define RTW_IEEE80211_STYPE_CFEND 0x00E0 +#define RTW_IEEE80211_STYPE_CFENDACK 0x00F0 + +/* data */ +#define RTW_IEEE80211_STYPE_DATA 0x0000 +#define RTW_IEEE80211_STYPE_DATA_CFACK 0x0010 +#define RTW_IEEE80211_STYPE_DATA_CFPOLL 0x0020 +#define RTW_IEEE80211_STYPE_DATA_CFACKPOLL 0x0030 +#define RTW_IEEE80211_STYPE_NULLFUNC 0x0040 +#define RTW_IEEE80211_STYPE_CFACK 0x0050 +#define RTW_IEEE80211_STYPE_CFPOLL 0x0060 +#define RTW_IEEE80211_STYPE_CFACKPOLL 0x0070 +#define RTW_IEEE80211_STYPE_QOS_DATA 0x0080 +#define RTW_IEEE80211_STYPE_QOS_DATA_CFACK 0x0090 +#define RTW_IEEE80211_STYPE_QOS_DATA_CFPOLL 0x00A0 +#define RTW_IEEE80211_STYPE_QOS_DATA_CFACKPOLL 0x00B0 +#define RTW_IEEE80211_STYPE_QOS_NULLFUNC 0x00C0 +#define RTW_IEEE80211_STYPE_QOS_CFACK 0x00D0 +#define RTW_IEEE80211_STYPE_QOS_CFPOLL 0x00E0 +#define RTW_IEEE80211_STYPE_QOS_CFACKPOLL 0x00F0 + +/* sequence control field */ +#define RTW_IEEE80211_SCTL_FRAG 0x000F +#define RTW_IEEE80211_SCTL_SEQ 0xFFF0 + + +#define RTW_ERP_INFO_NON_ERP_PRESENT BIT(0) +#define RTW_ERP_INFO_USE_PROTECTION BIT(1) +#define RTW_ERP_INFO_BARKER_PREAMBLE_MODE BIT(2) + +/* QoS, QOS */ +#define NORMAL_ACK 0 +#define NO_ACK 1 +#define NON_EXPLICIT_ACK 2 +#define BLOCK_ACK 3 + +#ifndef ETH_P_PAE +#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */ +#endif /* ETH_P_PAE */ + +#define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */ + +#define ETH_P_ECONET 0x0018 + +#ifndef ETH_P_80211_RAW +#define ETH_P_80211_RAW (ETH_P_ECONET + 1) +#endif + +/* IEEE 802.11 defines */ + +#define P80211_OUI_LEN 3 + +struct ieee80211_snap_hdr { + u8 dsap; /* always 0xAA */ + u8 ssap; /* always 0xAA */ + u8 ctrl; /* always 0x03 */ + u8 oui[P80211_OUI_LEN]; /* organizational universal id */ +} __packed; + +#define SNAP_SIZE sizeof(struct ieee80211_snap_hdr) + +#define WLAN_FC_GET_TYPE(fc) ((fc) & RTW_IEEE80211_FCTL_FTYPE) +#define WLAN_FC_GET_STYPE(fc) ((fc) & RTW_IEEE80211_FCTL_STYPE) + +#define WLAN_QC_GET_TID(qc) ((qc) & 0x0f) + +#define WLAN_GET_SEQ_FRAG(seq) ((seq) & RTW_IEEE80211_SCTL_FRAG) +#define WLAN_GET_SEQ_SEQ(seq) ((seq) & RTW_IEEE80211_SCTL_SEQ) + +/* Authentication algorithms */ +#define WLAN_AUTH_OPEN 0 +#define WLAN_AUTH_SHARED_KEY 1 + +#define WLAN_AUTH_CHALLENGE_LEN 128 + +#define WLAN_CAPABILITY_BSS (1<<0) +#define WLAN_CAPABILITY_IBSS (1<<1) +#define WLAN_CAPABILITY_CF_POLLABLE (1<<2) +#define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3) +#define WLAN_CAPABILITY_PRIVACY (1<<4) +#define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5) +#define WLAN_CAPABILITY_PBCC (1<<6) +#define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7) +#define WLAN_CAPABILITY_SHORT_SLOT (1<<10) + +/* Status codes */ +#define WLAN_STATUS_SUCCESS 0 +#define WLAN_STATUS_UNSPECIFIED_FAILURE 1 +#define WLAN_STATUS_CAPS_UNSUPPORTED 10 +#define WLAN_STATUS_REASSOC_NO_ASSOC 11 +#define WLAN_STATUS_ASSOC_DENIED_UNSPEC 12 +#define WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG 13 +#define WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION 14 +#define WLAN_STATUS_CHALLENGE_FAIL 15 +#define WLAN_STATUS_AUTH_TIMEOUT 16 +#define WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA 17 +#define WLAN_STATUS_ASSOC_DENIED_RATES 18 +/* 802.11b */ +#define WLAN_STATUS_ASSOC_DENIED_NOSHORT 19 +#define WLAN_STATUS_ASSOC_DENIED_NOPBCC 20 +#define WLAN_STATUS_ASSOC_DENIED_NOAGILITY 21 + +/* Reason codes */ +#define WLAN_REASON_UNSPECIFIED 1 +#define WLAN_REASON_PREV_AUTH_NOT_VALID 2 +#define WLAN_REASON_DEAUTH_LEAVING 3 +#define WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY 4 +#define WLAN_REASON_DISASSOC_AP_BUSY 5 +#define WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA 6 +#define WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA 7 +#define WLAN_REASON_DISASSOC_STA_HAS_LEFT 8 +#define WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH 9 +#define WLAN_REASON_JOIN_WRONG_CHANNEL 65534 +#define WLAN_REASON_EXPIRATION_CHK 65535 + +/* Information Element IDs */ +#define WLAN_EID_SSID 0 +#define WLAN_EID_SUPP_RATES 1 +#define WLAN_EID_FH_PARAMS 2 +#define WLAN_EID_DS_PARAMS 3 +#define WLAN_EID_CF_PARAMS 4 +#define WLAN_EID_TIM 5 +#define WLAN_EID_IBSS_PARAMS 6 +#define WLAN_EID_CHALLENGE 16 +/* EIDs defined by IEEE 802.11h - START */ +#define WLAN_EID_PWR_CONSTRAINT 32 +#define WLAN_EID_PWR_CAPABILITY 33 +#define WLAN_EID_TPC_REQUEST 34 +#define WLAN_EID_TPC_REPORT 35 +#define WLAN_EID_SUPPORTED_CHANNELS 36 +#define WLAN_EID_CHANNEL_SWITCH 37 +#define WLAN_EID_MEASURE_REQUEST 38 +#define WLAN_EID_MEASURE_REPORT 39 +#define WLAN_EID_QUITE 40 +#define WLAN_EID_IBSS_DFS 41 +/* EIDs defined by IEEE 802.11h - END */ +#define WLAN_EID_ERP_INFO 42 +#define WLAN_EID_HT_CAP 45 +#define WLAN_EID_RSN 48 +#define WLAN_EID_EXT_SUPP_RATES 50 +#define WLAN_EID_MOBILITY_DOMAIN 54 +#define WLAN_EID_FAST_BSS_TRANSITION 55 +#define WLAN_EID_TIMEOUT_INTERVAL 56 +#define WLAN_EID_RIC_DATA 57 +#define WLAN_EID_HT_OPERATION 61 +#define WLAN_EID_SECONDARY_CHANNEL_OFFSET 62 +#define WLAN_EID_20_40_BSS_COEXISTENCE 72 +#define WLAN_EID_20_40_BSS_INTOLERANT 73 +#define WLAN_EID_OVERLAPPING_BSS_SCAN_PARAMS 74 +#define WLAN_EID_MMIE 76 +#define WLAN_EID_VENDOR_SPECIFIC 221 +#define WLAN_EID_GENERIC (WLAN_EID_VENDOR_SPECIFIC) + +#define IEEE80211_MGMT_HDR_LEN 24 +#define IEEE80211_DATA_HDR3_LEN 24 +#define IEEE80211_DATA_HDR4_LEN 30 + + +#define IEEE80211_STATMASK_SIGNAL (1<<0) +#define IEEE80211_STATMASK_RSSI (1<<1) +#define IEEE80211_STATMASK_NOISE (1<<2) +#define IEEE80211_STATMASK_RATE (1<<3) +#define IEEE80211_STATMASK_WEMASK 0x7 + + +#define IEEE80211_CCK_MODULATION (1<<0) +#define IEEE80211_OFDM_MODULATION (1<<1) + +#define IEEE80211_24GHZ_BAND (1<<0) +#define IEEE80211_52GHZ_BAND (1<<1) + +#define IEEE80211_CCK_RATE_LEN 4 +#define IEEE80211_NUM_OFDM_RATESLEN 8 + + +#define IEEE80211_CCK_RATE_1MB 0x02 +#define IEEE80211_CCK_RATE_2MB 0x04 +#define IEEE80211_CCK_RATE_5MB 0x0B +#define IEEE80211_CCK_RATE_11MB 0x16 +#define IEEE80211_OFDM_RATE_LEN 8 +#define IEEE80211_OFDM_RATE_6MB 0x0C +#define IEEE80211_OFDM_RATE_9MB 0x12 +#define IEEE80211_OFDM_RATE_12MB 0x18 +#define IEEE80211_OFDM_RATE_18MB 0x24 +#define IEEE80211_OFDM_RATE_24MB 0x30 +#define IEEE80211_OFDM_RATE_36MB 0x48 +#define IEEE80211_OFDM_RATE_48MB 0x60 +#define IEEE80211_OFDM_RATE_54MB 0x6C +#define IEEE80211_BASIC_RATE_MASK 0x80 + +#define IEEE80211_CCK_RATE_1MB_MASK (1<<0) +#define IEEE80211_CCK_RATE_2MB_MASK (1<<1) +#define IEEE80211_CCK_RATE_5MB_MASK (1<<2) +#define IEEE80211_CCK_RATE_11MB_MASK (1<<3) +#define IEEE80211_OFDM_RATE_6MB_MASK (1<<4) +#define IEEE80211_OFDM_RATE_9MB_MASK (1<<5) +#define IEEE80211_OFDM_RATE_12MB_MASK (1<<6) +#define IEEE80211_OFDM_RATE_18MB_MASK (1<<7) +#define IEEE80211_OFDM_RATE_24MB_MASK (1<<8) +#define IEEE80211_OFDM_RATE_36MB_MASK (1<<9) +#define IEEE80211_OFDM_RATE_48MB_MASK (1<<10) +#define IEEE80211_OFDM_RATE_54MB_MASK (1<<11) + +#define IEEE80211_CCK_RATES_MASK 0x0000000F +#define IEEE80211_CCK_BASIC_RATES_MASK (IEEE80211_CCK_RATE_1MB_MASK | \ + IEEE80211_CCK_RATE_2MB_MASK) +#define IEEE80211_CCK_DEFAULT_RATES_MASK \ + (IEEE80211_CCK_BASIC_RATES_MASK | \ + IEEE80211_CCK_RATE_5MB_MASK | \ + IEEE80211_CCK_RATE_11MB_MASK) + +#define IEEE80211_OFDM_RATES_MASK 0x00000FF0 +#define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \ + IEEE80211_OFDM_RATE_12MB_MASK | \ + IEEE80211_OFDM_RATE_24MB_MASK) +#define IEEE80211_OFDM_DEFAULT_RATES_MASK \ + (IEEE80211_OFDM_BASIC_RATES_MASK | \ + IEEE80211_OFDM_RATE_9MB_MASK | \ + IEEE80211_OFDM_RATE_18MB_MASK | \ + IEEE80211_OFDM_RATE_36MB_MASK | \ + IEEE80211_OFDM_RATE_48MB_MASK | \ + IEEE80211_OFDM_RATE_54MB_MASK) +#define IEEE80211_DEFAULT_RATES_MASK \ + (IEEE80211_OFDM_DEFAULT_RATES_MASK | \ + IEEE80211_CCK_DEFAULT_RATES_MASK) + +#define IEEE80211_NUM_OFDM_RATES 8 +#define IEEE80211_NUM_CCK_RATES 4 +#define IEEE80211_OFDM_SHIFT_MASK_A 4 + +/* NOTE: This data is for statistical purposes; not all hardware provides this + * information for frames received. Not setting these will not cause + * any adverse affects. */ +struct ieee80211_rx_stats { + /* u32 mac_time[2]; */ + s8 rssi; + u8 signal; + u8 noise; + u8 received_channel; + u16 rate; /* in 100 kbps */ + /* u8 control; */ + u8 mask; + u8 freq; + u16 len; +}; + +/* IEEE 802.11 requires that STA supports concurrent reception of at least + * three fragmented frames. This define can be increased to support more + * concurrent frames, but it should be noted that each entry can consume about + * 2 kB of RAM and increasing cache size will slow down frame reassembly. */ +#define IEEE80211_FRAG_CACHE_LEN 4 + +struct ieee80211_frag_entry { + u32 first_frag_time; + uint seq; + uint last_frag; + uint qos; /* jackson */ + uint tid; /* jackson */ + struct sk_buff *skb; + u8 src_addr[ETH_ALEN]; + u8 dst_addr[ETH_ALEN]; +}; + +struct ieee80211_stats { + uint tx_unicast_frames; + uint tx_multicast_frames; + uint tx_fragments; + uint tx_unicast_octets; + uint tx_multicast_octets; + uint tx_deferred_transmissions; + uint tx_single_retry_frames; + uint tx_multiple_retry_frames; + uint tx_retry_limit_exceeded; + uint tx_discards; + uint rx_unicast_frames; + uint rx_multicast_frames; + uint rx_fragments; + uint rx_unicast_octets; + uint rx_multicast_octets; + uint rx_fcs_errors; + uint rx_discards_no_buffer; + uint tx_discards_wrong_sa; + uint rx_discards_undecryptable; + uint rx_message_in_msg_fragments; + uint rx_message_in_bad_msg_fragments; +}; + +struct ieee80211_softmac_stats { + uint rx_ass_ok; + uint rx_ass_err; + uint rx_probe_rq; + uint tx_probe_rs; + uint tx_beacons; + uint rx_auth_rq; + uint rx_auth_rs_ok; + uint rx_auth_rs_err; + uint tx_auth_rq; + uint no_auth_rs; + uint no_ass_rs; + uint tx_ass_rq; + uint rx_ass_rq; + uint tx_probe_rq; + uint reassoc; + uint swtxstop; + uint swtxawake; +}; + +#define SEC_KEY_1 (1<<0) +#define SEC_KEY_2 (1<<1) +#define SEC_KEY_3 (1<<2) +#define SEC_KEY_4 (1<<3) +#define SEC_ACTIVE_KEY (1<<4) +#define SEC_AUTH_MODE (1<<5) +#define SEC_UNICAST_GROUP (1<<6) +#define SEC_LEVEL (1<<7) +#define SEC_ENABLED (1<<8) + +#define SEC_LEVEL_0 0 /* None */ +#define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */ +#define SEC_LEVEL_2 2 /* Level 1 + TKIP */ +#define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */ +#define SEC_LEVEL_3 4 /* Level 2 + CCMP */ + +#define WEP_KEYS 4 +#define WEP_KEY_LEN 13 + +struct ieee80211_security { + u16 active_key:2, + enabled:1, + auth_mode:2, + auth_algo:4, + unicast_uses_group:1; + u8 key_sizes[WEP_KEYS]; + u8 keys[WEP_KEYS][WEP_KEY_LEN]; + u8 level; + u16 flags; +} __packed; + +/* + + 802.11 data frame from AP + + ,-------------------------------------------------------------------. +Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 | + |------|------|---------|---------|---------|------|---------|------| +Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs | + | | tion | (BSSID) | | | ence | data | | + `-------------------------------------------------------------------' + +Total: 28-2340 bytes + +*/ + +struct ieee80211_header_data { + u16 frame_ctl; + u16 duration_id; + u8 addr1[6]; + u8 addr2[6]; + u8 addr3[6]; + u16 seq_ctrl; +}; + +#define BEACON_PROBE_SSID_ID_POSITION 12 + +/* Management Frame Information Element Types */ +#define MFIE_TYPE_SSID 0 +#define MFIE_TYPE_RATES 1 +#define MFIE_TYPE_FH_SET 2 +#define MFIE_TYPE_DS_SET 3 +#define MFIE_TYPE_CF_SET 4 +#define MFIE_TYPE_TIM 5 +#define MFIE_TYPE_IBSS_SET 6 +#define MFIE_TYPE_CHALLENGE 16 +#define MFIE_TYPE_ERP 42 +#define MFIE_TYPE_RSN 48 +#define MFIE_TYPE_RATES_EX 50 +#define MFIE_TYPE_GENERIC 221 + +struct ieee80211_info_element_hdr { + u8 id; + u8 len; +} __packed; + +struct ieee80211_info_element { + u8 id; + u8 len; + u8 data[0]; +} __packed; + +/* + * These are the data types that can make up management packets + * + u16 auth_algorithm; + u16 auth_sequence; + u16 beacon_interval; + u16 capability; + u8 current_ap[ETH_ALEN]; + u16 listen_interval; + struct { + u16 association_id:14, reserved:2; + } __packed; + u32 time_stamp[2]; + u16 reason; + u16 status; +*/ + +#define IEEE80211_DEFAULT_TX_ESSID "Penguin" +#define IEEE80211_DEFAULT_BASIC_RATE 10 + +struct ieee80211_authentication { + struct ieee80211_header_data header; + u16 algorithm; + u16 transaction; + u16 status; + /* struct ieee80211_info_element_hdr info_element; */ +} __packed; + +struct ieee80211_probe_response { + struct ieee80211_header_data header; + u32 time_stamp[2]; + u16 beacon_interval; + u16 capability; + struct ieee80211_info_element info_element; +} __packed; + +struct ieee80211_probe_request { + struct ieee80211_header_data header; +} __packed; + +struct ieee80211_assoc_request_frame { + struct rtw_ieee80211_hdr_3addr header; + u16 capability; + u16 listen_interval; + struct ieee80211_info_element_hdr info_element; +} __packed; + +struct ieee80211_assoc_response_frame { + struct rtw_ieee80211_hdr_3addr header; + u16 capability; + u16 status; + u16 aid; +} __packed; + +struct ieee80211_txb { + u8 nr_frags; + u8 encrypted; + u16 reserved; + u16 frag_size; + u16 payload_size; + struct sk_buff *fragments[0]; +}; + + +/* SWEEP TABLE ENTRIES NUMBER*/ +#define MAX_SWEEP_TAB_ENTRIES 42 +#define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7 +/* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs + * only use 8, and then use extended rates for the remaining supported + * rates. Other APs, however, stick all of their supported rates on the + * main rates information element... */ +#define MAX_RATES_LENGTH ((u8)12) +#define MAX_RATES_EX_LENGTH ((u8)16) +#define MAX_NETWORK_COUNT 128 +#define MAX_CHANNEL_NUMBER 161 +#define IEEE80211_SOFTMAC_SCAN_TIME 400 +/* HZ / 2) */ +#define IEEE80211_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2) + +#define CRC_LENGTH 4U + +#define MAX_WPA_IE_LEN (256) +#define MAX_WPS_IE_LEN (512) +#define MAX_P2P_IE_LEN (256) +#define MAX_WFD_IE_LEN (128) + +#define NETWORK_EMPTY_ESSID (1<<0) +#define NETWORK_HAS_OFDM (1<<1) +#define NETWORK_HAS_CCK (1<<2) + +#define IEEE80211_DTIM_MBCAST 4 +#define IEEE80211_DTIM_UCAST 2 +#define IEEE80211_DTIM_VALID 1 +#define IEEE80211_DTIM_INVALID 0 + +#define IEEE80211_PS_DISABLED 0 +#define IEEE80211_PS_UNICAST IEEE80211_DTIM_UCAST +#define IEEE80211_PS_MBCAST IEEE80211_DTIM_MBCAST +#define IW_ESSID_MAX_SIZE 32 +/* +join_res: +-1: authentication fail +-2: association fail +> 0: TID +*/ + +enum ieee80211_state { + /* the card is not linked at all */ + IEEE80211_NOLINK = 0, + + /* IEEE80211_ASSOCIATING* are for BSS client mode + * the driver shall not perform RX filtering unless + * the state is LINKED. + * The driver shall just check for the state LINKED and + * defaults to NOLINK for ALL the other states (including + * LINKED_SCANNING) + */ + + /* the association procedure will start (wq scheduling)*/ + IEEE80211_ASSOCIATING, + IEEE80211_ASSOCIATING_RETRY, + + /* the association procedure is sending AUTH request*/ + IEEE80211_ASSOCIATING_AUTHENTICATING, + + /* the association procedure has successfully authentcated + * and is sending association request + */ + IEEE80211_ASSOCIATING_AUTHENTICATED, + + /* the link is ok. the card associated to a BSS or linked + * to a ibss cell or acting as an AP and creating the bss + */ + IEEE80211_LINKED, + + /* same as LINKED, but the driver shall apply RX filter + * rules as we are in NO_LINK mode. As the card is still + * logically linked, but it is doing a syncro site survey + * then it will be back to LINKED state. + */ + IEEE80211_LINKED_SCANNING, + +}; + +#define DEFAULT_MAX_SCAN_AGE (15 * HZ) +#define DEFAULT_FTS 2346 + +static inline int is_multicast_mac_addr(const u8 *addr) +{ + return ((addr[0] != 0xff) && (0x01 & addr[0])); +} + +static inline int is_broadcast_mac_addr(const u8 *addr) +{ + return (addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && + (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff); +} + +#define CFG_IEEE80211_RESERVE_FCS (1<<0) +#define CFG_IEEE80211_COMPUTE_FCS (1<<1) + +struct tx_pending { + int frag; + struct ieee80211_txb *txb; +}; + +#define MAXTID 16 + +#define IEEE_A (1<<0) +#define IEEE_B (1<<1) +#define IEEE_G (1<<2) +#define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G) + +/* Baron move to ieee80211.c */ +int ieee80211_is_empty_essid(const char *essid, int essid_len); +int ieee80211_get_hdrlen(u16 fc); + +/* Action category code */ +enum rtw_ieee80211_category { + RTW_WLAN_CATEGORY_SPECTRUM_MGMT = 0, + RTW_WLAN_CATEGORY_QOS = 1, + RTW_WLAN_CATEGORY_DLS = 2, + RTW_WLAN_CATEGORY_BACK = 3, + RTW_WLAN_CATEGORY_PUBLIC = 4, /* IEEE 802.11 public action frames */ + RTW_WLAN_CATEGORY_RADIO_MEASUREMENT = 5, + RTW_WLAN_CATEGORY_FT = 6, + RTW_WLAN_CATEGORY_HT = 7, + RTW_WLAN_CATEGORY_SA_QUERY = 8, + RTW_WLAN_CATEGORY_TDLS = 12, + RTW_WLAN_CATEGORY_WMM = 17, + RTW_WLAN_CATEGORY_P2P = 0x7f,/* P2P action frames */ +}; + +/* SPECTRUM_MGMT action code */ +enum rtw_ieee80211_spectrum_mgmt_actioncode { + RTW_WLAN_ACTION_SPCT_MSR_REQ = 0, + RTW_WLAN_ACTION_SPCT_MSR_RPRT = 1, + RTW_WLAN_ACTION_SPCT_TPC_REQ = 2, + RTW_WLAN_ACTION_SPCT_TPC_RPRT = 3, + RTW_WLAN_ACTION_SPCT_CHL_SWITCH = 4, + RTW_WLAN_ACTION_SPCT_EXT_CHL_SWITCH = 5, +}; + +enum _PUBLIC_ACTION { + ACT_PUBLIC_BSSCOEXIST = 0, /* 20/40 BSS Coexistence */ + ACT_PUBLIC_DSE_ENABLE = 1, + ACT_PUBLIC_DSE_DEENABLE = 2, + ACT_PUBLIC_DSE_REG_LOCATION = 3, + ACT_PUBLIC_EXT_CHL_SWITCH = 4, + ACT_PUBLIC_DSE_MSR_REQ = 5, + ACT_PUBLIC_DSE_MSR_RPRT = 6, + ACT_PUBLIC_MP = 7, /* Measurement Pilot */ + ACT_PUBLIC_DSE_PWR_CONSTRAINT = 8, + ACT_PUBLIC_VENDOR = 9, /* for WIFI_DIRECT */ + ACT_PUBLIC_GAS_INITIAL_REQ = 10, + ACT_PUBLIC_GAS_INITIAL_RSP = 11, + ACT_PUBLIC_GAS_COMEBACK_REQ = 12, + ACT_PUBLIC_GAS_COMEBACK_RSP = 13, + ACT_PUBLIC_TDLS_DISCOVERY_RSP = 14, + ACT_PUBLIC_LOCATION_TRACK = 15, + ACT_PUBLIC_MAX +}; + +/* BACK action code */ +enum rtw_ieee80211_back_actioncode { + RTW_WLAN_ACTION_ADDBA_REQ = 0, + RTW_WLAN_ACTION_ADDBA_RESP = 1, + RTW_WLAN_ACTION_DELBA = 2, +}; + +/* HT features action code */ +enum rtw_ieee80211_ht_actioncode { + RTW_WLAN_ACTION_NOTIFY_CH_WIDTH = 0, + RTW_WLAN_ACTION_SM_PS = 1, + RTW_WLAN_ACTION_PSPM = 2, + RTW_WLAN_ACTION_PCO_PHASE = 3, + RTW_WLAN_ACTION_MIMO_CSI_MX = 4, + RTW_WLAN_ACTION_MIMO_NONCP_BF = 5, + RTW_WLAN_ACTION_MIMP_CP_BF = 6, + RTW_WLAN_ACTION_ASEL_INDICATES_FB = 7, + RTW_WLAN_ACTION_HI_INFO_EXCHG = 8, +}; + +/* BACK (block-ack) parties */ +enum rtw_ieee80211_back_parties { + RTW_WLAN_BACK_RECIPIENT = 0, + RTW_WLAN_BACK_INITIATOR = 1, + RTW_WLAN_BACK_TIMER = 2, +}; + +#define OUI_MICROSOFT 0x0050f2 /* Microsoft (also used in Wi-Fi specs) + * 00:50:F2 */ +#define WME_OUI_TYPE 2 +#define WME_OUI_SUBTYPE_INFORMATION_ELEMENT 0 +#define WME_OUI_SUBTYPE_PARAMETER_ELEMENT 1 +#define WME_OUI_SUBTYPE_TSPEC_ELEMENT 2 +#define WME_VERSION 1 + +#define WME_ACTION_CODE_SETUP_REQUEST 0 +#define WME_ACTION_CODE_SETUP_RESPONSE 1 +#define WME_ACTION_CODE_TEARDOWN 2 + +#define WME_SETUP_RESPONSE_STATUS_ADMISSION_ACCEPTED 0 +#define WME_SETUP_RESPONSE_STATUS_INVALID_PARAMETERS 1 +#define WME_SETUP_RESPONSE_STATUS_REFUSED 3 + +#define WME_TSPEC_DIRECTION_UPLINK 0 +#define WME_TSPEC_DIRECTION_DOWNLINK 1 +#define WME_TSPEC_DIRECTION_BI_DIRECTIONAL 3 + + +#define OUI_BROADCOM 0x00904c /* Broadcom (Epigram) */ + +#define VENDOR_HT_CAPAB_OUI_TYPE 0x33 /* 00-90-4c:0x33 */ + +/** + * enum rtw_ieee80211_channel_flags - channel flags + * + * Channel flags set by the regulatory control code. + * + * @RTW_IEEE80211_CHAN_DISABLED: This channel is disabled. + * @RTW_IEEE80211_CHAN_PASSIVE_SCAN: Only passive scanning is permitted + * on this channel. + * @RTW_IEEE80211_CHAN_NO_IBSS: IBSS is not allowed on this channel. + * @RTW_IEEE80211_CHAN_RADAR: Radar detection is required on this channel. + * @RTW_IEEE80211_CHAN_NO_HT40PLUS: extension channel above this channel + * is not permitted. + * @RTW_IEEE80211_CHAN_NO_HT40MINUS: extension channel below this channel + * is not permitted. + */ +enum rtw_ieee80211_channel_flags { + RTW_IEEE80211_CHAN_DISABLED = 1<<0, + RTW_IEEE80211_CHAN_PASSIVE_SCAN = 1<<1, + RTW_IEEE80211_CHAN_NO_IBSS = 1<<2, + RTW_IEEE80211_CHAN_RADAR = 1<<3, + RTW_IEEE80211_CHAN_NO_HT40PLUS = 1<<4, + RTW_IEEE80211_CHAN_NO_HT40MINUS = 1<<5, +}; + +#define RTW_IEEE80211_CHAN_NO_HT40 \ + (RTW_IEEE80211_CHAN_NO_HT40PLUS | RTW_IEEE80211_CHAN_NO_HT40MINUS) + +/* Represent channel details, subset of ieee80211_channel */ +struct rtw_ieee80211_channel { + u16 hw_value; + u32 flags; +}; + +#define CHAN_FMT \ + "hw_value:%u, " \ + "flags:0x%08x" \ + +#define CHAN_ARG(channel) \ + (channel)->hw_value \ + , (channel)->flags \ + +/* Parsed Information Elements */ +struct rtw_ieee802_11_elems { + u8 *ssid; + u8 ssid_len; + u8 *supp_rates; + u8 supp_rates_len; + u8 *fh_params; + u8 fh_params_len; + u8 *ds_params; + u8 ds_params_len; + u8 *cf_params; + u8 cf_params_len; + u8 *tim; + u8 tim_len; + u8 *ibss_params; + u8 ibss_params_len; + u8 *challenge; + u8 challenge_len; + u8 *erp_info; + u8 erp_info_len; + u8 *ext_supp_rates; + u8 ext_supp_rates_len; + u8 *wpa_ie; + u8 wpa_ie_len; + u8 *rsn_ie; + u8 rsn_ie_len; + u8 *wme; + u8 wme_len; + u8 *wme_tspec; + u8 wme_tspec_len; + u8 *wps_ie; + u8 wps_ie_len; + u8 *power_cap; + u8 power_cap_len; + u8 *supp_channels; + u8 supp_channels_len; + u8 *mdie; + u8 mdie_len; + u8 *ftie; + u8 ftie_len; + u8 *timeout_int; + u8 timeout_int_len; + u8 *ht_capabilities; + u8 ht_capabilities_len; + u8 *ht_operation; + u8 ht_operation_len; + u8 *vendor_ht_cap; + u8 vendor_ht_cap_len; +}; + +enum parse_res { + ParseOK = 0, + ParseUnknown = 1, + ParseFailed = -1 +}; + +enum parse_res rtw_ieee802_11_parse_elems(u8 *start, uint len, + struct rtw_ieee802_11_elems *elems, + int show_errors); + +u8 *rtw_set_fixed_ie(unsigned char *pbuf, unsigned int len, + unsigned char *source, unsigned int *frlen); +u8 *rtw_set_ie(u8 *pbuf, int index, uint len, u8 *source, uint *frlen); + +enum secondary_ch_offset { + SCN = 0, /* no secondary channel */ + SCA = 1, /* secondary channel above */ + SCB = 3, /* secondary channel below */ +}; +u8 secondary_ch_offset_to_hal_ch_offset(u8 ch_offset); +u8 hal_ch_offset_to_secondary_ch_offset(u8 ch_offset); +u8 *rtw_set_ie_ch_switch(u8 *buf, u32 *buf_len, u8 ch_switch_mode, + u8 new_ch, u8 ch_switch_cnt); +u8 *rtw_set_ie_secondary_ch_offset(u8 *buf, u32 *buf_len, + u8 secondary_ch_offset); +u8 *rtw_set_ie_mesh_ch_switch_parm(u8 *buf, u32 *buf_len, u8 ttl, + u8 flags, u16 reason, u16 precedence); + +u8 *rtw_get_ie(u8 *pbuf, int index, int *len, int limit); +u8 *rtw_get_ie_ex(u8 *in_ie, uint in_len, u8 eid, u8 *oui, + u8 oui_len, u8 *ie, uint *ielen); +int rtw_ies_remove_ie(u8 *ies, uint *ies_len, uint offset, + u8 eid, u8 *oui, u8 oui_len); + +void rtw_set_supported_rate(u8 *SupportedRates, uint mode); + +unsigned char *rtw_get_wpa_ie(unsigned char *pie, int *wpa_ie_len, int limit); +unsigned char *rtw_get_wpa2_ie(unsigned char *pie, int *rsn_ie_len, int limit); +int rtw_get_wpa_cipher_suite(u8 *s); +int rtw_get_wpa2_cipher_suite(u8 *s); +int rtw_get_wapi_ie(u8 *in_ie, uint in_len, u8 *wapi_ie, u16 *wapi_len); +int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, + int *pairwise_cipher, int *is_8021x); +int rtw_parse_wpa2_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, + int *pairwise_cipher, int *is_8021x); + +int rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, + u8 *wpa_ie, u16 *wpa_len); + +u8 rtw_is_wps_ie(u8 *ie_ptr, uint *wps_ielen); +u8 *rtw_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen); +u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, + u8 *buf_attr, u32 *len_attr); +u8 *rtw_get_wps_attr_content(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, + u8 *buf_content, uint *len_content); + +/** + * for_each_ie - iterate over continuous IEs + * @ie: + * @buf: + * @buf_len: + */ +#define for_each_ie(ie, buf, buf_len) \ + for (ie = (void *)buf; (((u8 *)ie) - ((u8 *)buf) + 1) < buf_len; \ + ie = (void *)(((u8 *)ie) + *(((u8 *)ie)+1) + 2)) + +void dump_ies(u8 *buf, u32 buf_len); +void dump_wps_ie(u8 *ie, u32 ie_len); + +#ifdef CONFIG_88EU_P2P +void dump_p2p_ie(u8 *ie, u32 ie_len); +u8 *rtw_get_p2p_ie(u8 *in_ie, int in_len, u8 *p2p_ie, uint *p2p_ielen); +u8 *rtw_get_p2p_attr(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id, + u8 *buf_attr, u32 *len_attr); +u8 *rtw_get_p2p_attr_content(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id, + u8 *buf_content, uint *len_content); +u32 rtw_set_p2p_attr_content(u8 *pbuf, u8 attr_id, u16 attr_len, + u8 *pdata_attr); +void rtw_wlan_bssid_ex_remove_p2p_attr(struct wlan_bssid_ex *bss_ex, + u8 attr_id); +#endif + +uint rtw_get_rateset_len(u8 *rateset); + +struct registry_priv; +int rtw_generate_ie(struct registry_priv *pregistrypriv); + + +int rtw_get_bit_value_from_ieee_value(u8 val); + +uint rtw_is_cckrates_included(u8 *rate); + +uint rtw_is_cckratesonly_included(u8 *rate); + +int rtw_check_network_type(unsigned char *rate, int ratelen, int channel); + +void rtw_get_bcn_info(struct wlan_network *pnetwork); + +void rtw_macaddr_cfg(u8 *mac_addr); + +u16 rtw_mcs_rate(u8 rf_type, u8 bw_40MHz, u8 short_GI_20, u8 short_GI_40, + unsigned char *MCS_rate); + +int rtw_action_frame_parse(const u8 *frame, u32 frame_len, u8 *category, + u8 *action); +const char *action_public_str(u8 action); + +#endif /* IEEE80211_H */ diff --git a/drivers/staging/rtl8188eu/include/ieee80211_ext.h b/drivers/staging/rtl8188eu/include/ieee80211_ext.h new file mode 100644 index 0000000000000..1052d1817a972 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/ieee80211_ext.h @@ -0,0 +1,290 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __IEEE80211_EXT_H +#define __IEEE80211_EXT_H + +#include +#include + +#define WMM_OUI_TYPE 2 +#define WMM_OUI_SUBTYPE_INFORMATION_ELEMENT 0 +#define WMM_OUI_SUBTYPE_PARAMETER_ELEMENT 1 +#define WMM_OUI_SUBTYPE_TSPEC_ELEMENT 2 +#define WMM_VERSION 1 + +#define WPA_PROTO_WPA BIT(0) +#define WPA_PROTO_RSN BIT(1) + +#define WPA_KEY_MGMT_IEEE8021X BIT(0) +#define WPA_KEY_MGMT_PSK BIT(1) +#define WPA_KEY_MGMT_NONE BIT(2) +#define WPA_KEY_MGMT_IEEE8021X_NO_WPA BIT(3) +#define WPA_KEY_MGMT_WPA_NONE BIT(4) + + +#define WPA_CAPABILITY_PREAUTH BIT(0) +#define WPA_CAPABILITY_MGMT_FRAME_PROTECTION BIT(6) +#define WPA_CAPABILITY_PEERKEY_ENABLED BIT(9) + + +#define PMKID_LEN 16 + + +struct wpa_ie_hdr { + u8 elem_id; + u8 len; + u8 oui[4]; /* 24-bit OUI followed by 8-bit OUI type */ + u8 version[2]; /* little endian */ +} __packed; + +struct rsn_ie_hdr { + u8 elem_id; /* WLAN_EID_RSN */ + u8 len; + u8 version[2]; /* little endian */ +} __packed; + +struct wme_ac_parameter { +#if defined(__LITTLE_ENDIAN) + /* byte 1 */ + u8 aifsn:4, + acm:1, + aci:2, + reserved:1; + + /* byte 2 */ + u8 eCWmin:4, + eCWmax:4; +#elif defined(__BIG_ENDIAN) + /* byte 1 */ + u8 reserved:1, + aci:2, + acm:1, + aifsn:4; + + /* byte 2 */ + u8 eCWmax:4, + eCWmin:4; +#else +#error "Please fix " +#endif + + /* bytes 3 & 4 */ + u16 txopLimit; +} __packed; + +struct wme_parameter_element { + /* required fields for WME version 1 */ + u8 oui[3]; + u8 oui_type; + u8 oui_subtype; + u8 version; + u8 acInfo; + u8 reserved; + struct wme_ac_parameter ac[4]; + +} __packed; + +#define WPA_PUT_LE16(a, val) \ + do { \ + (a)[1] = ((u16) (val)) >> 8; \ + (a)[0] = ((u16) (val)) & 0xff; \ + } while (0) + +#define WPA_PUT_BE32(a, val) \ + do { \ + (a)[0] = (u8) ((((u32) (val)) >> 24) & 0xff); \ + (a)[1] = (u8) ((((u32) (val)) >> 16) & 0xff); \ + (a)[2] = (u8) ((((u32) (val)) >> 8) & 0xff); \ + (a)[3] = (u8) (((u32) (val)) & 0xff); \ + } while (0) + +#define WPA_PUT_LE32(a, val) \ + do { \ + (a)[3] = (u8) ((((u32) (val)) >> 24) & 0xff); \ + (a)[2] = (u8) ((((u32) (val)) >> 16) & 0xff); \ + (a)[1] = (u8) ((((u32) (val)) >> 8) & 0xff); \ + (a)[0] = (u8) (((u32) (val)) & 0xff); \ + } while (0) + +#define RSN_SELECTOR_PUT(a, val) WPA_PUT_BE32((u8 *)(a), (val)) + +/* Action category code */ +enum ieee80211_category { + WLAN_CATEGORY_SPECTRUM_MGMT = 0, + WLAN_CATEGORY_QOS = 1, + WLAN_CATEGORY_DLS = 2, + WLAN_CATEGORY_BACK = 3, + WLAN_CATEGORY_HT = 7, + WLAN_CATEGORY_WMM = 17, +}; + +/* SPECTRUM_MGMT action code */ +enum ieee80211_spectrum_mgmt_actioncode { + WLAN_ACTION_SPCT_MSR_REQ = 0, + WLAN_ACTION_SPCT_MSR_RPRT = 1, + WLAN_ACTION_SPCT_TPC_REQ = 2, + WLAN_ACTION_SPCT_TPC_RPRT = 3, + WLAN_ACTION_SPCT_CHL_SWITCH = 4, + WLAN_ACTION_SPCT_EXT_CHL_SWITCH = 5, +}; + +/* BACK action code */ +enum ieee80211_back_actioncode { + WLAN_ACTION_ADDBA_REQ = 0, + WLAN_ACTION_ADDBA_RESP = 1, + WLAN_ACTION_DELBA = 2, +}; + +/* HT features action code */ +enum ieee80211_ht_actioncode { + WLAN_ACTION_NOTIFY_CH_WIDTH = 0, + WLAN_ACTION_SM_PS = 1, + WLAN_ACTION_PSPM = 2, + WLAN_ACTION_PCO_PHASE = 3, + WLAN_ACTION_MIMO_CSI_MX = 4, + WLAN_ACTION_MIMO_NONCP_BF = 5, + WLAN_ACTION_MIMP_CP_BF = 6, + WLAN_ACTION_ASEL_INDICATES_FB = 7, + WLAN_ACTION_HI_INFO_EXCHG = 8, +}; + +/* BACK (block-ack) parties */ +enum ieee80211_back_parties { + WLAN_BACK_RECIPIENT = 0, + WLAN_BACK_INITIATOR = 1, + WLAN_BACK_TIMER = 2, +}; + +struct ieee80211_mgmt { + u16 frame_control; + u16 duration; + u8 da[6]; + u8 sa[6]; + u8 bssid[6]; + u16 seq_ctrl; + union { + struct { + u16 auth_alg; + u16 auth_transaction; + u16 status_code; + /* possibly followed by Challenge text */ + u8 variable[0]; + } __packed auth; + struct { + u16 reason_code; + } __packed deauth; + struct { + u16 capab_info; + u16 listen_interval; + /* followed by SSID and Supported rates */ + u8 variable[0]; + } __packed assoc_req; + struct { + u16 capab_info; + u16 status_code; + u16 aid; + /* followed by Supported rates */ + u8 variable[0]; + } __packed assoc_resp, reassoc_resp; + struct { + u16 capab_info; + u16 listen_interval; + u8 current_ap[6]; + /* followed by SSID and Supported rates */ + u8 variable[0]; + } __packed reassoc_req; + struct { + u16 reason_code; + } __packed disassoc; + struct { + __le64 timestamp; + u16 beacon_int; + u16 capab_info; + /* followed by some of SSID, Supported rates, + * FH Params, DS Params, CF Params, IBSS Params, TIM */ + u8 variable[0]; + } __packed beacon; + struct { + /* only variable items: SSID, Supported rates */ + u8 variable[0]; + } __packed probe_req; + struct { + __le64 timestamp; + u16 beacon_int; + u16 capab_info; + /* followed by some of SSID, Supported rates, + * FH Params, DS Params, CF Params, IBSS Params */ + u8 variable[0]; + } __packed probe_resp; + struct { + u8 category; + union { + struct { + u8 action_code; + u8 dialog_token; + u8 status_code; + u8 variable[0]; + } __packed wme_action; + struct { + u8 action_code; + u8 dialog_token; + u16 capab; + u16 timeout; + u16 start_seq_num; + } __packed addba_req; + struct { + u8 action_code; + u8 dialog_token; + u16 status; + u16 capab; + u16 timeout; + } __packed addba_resp; + struct { + u8 action_code; + u16 params; + u16 reason_code; + } __packed delba; + structi { + u8 action_code; + /* capab_info for open and confirm, + * reason for close + */ + u16 aux; + /* Followed in plink_confirm by status + * code, AID and supported rates, + * and directly by supported rates in + * plink_open and plink_close + */ + u8 variable[0]; + } __packed plink_action; + struct{ + u8 action_code; + u8 variable[0]; + } __packed mesh_action; + } __packed u; + } __packed action; + } __packed u; +} __packed; + +/* mgmt header + 1 byte category code */ +#define IEEE80211_MIN_ACTION_SIZE \ + FIELD_OFFSET(struct ieee80211_mgmt, u.action.u) + +#endif diff --git a/drivers/staging/rtl8188eu/include/if_ether.h b/drivers/staging/rtl8188eu/include/if_ether.h new file mode 100644 index 0000000000000..db157712a2030 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/if_ether.h @@ -0,0 +1,111 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#ifndef _LINUX_IF_ETHER_H +#define _LINUX_IF_ETHER_H + +/* + * IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble + * and FCS/CRC (frame check sequence). + */ + +#define ETH_ALEN 6 /* Octets in one ethernet addr */ +#define ETH_HLEN 14 /* Total octets in header. */ +#define ETH_ZLEN 60 /* Min. octets in frame sans FCS */ +#define ETH_DATA_LEN 1500 /* Max. octets in payload */ +#define ETH_FRAME_LEN 1514 /* Max. octets in frame sans FCS */ + +/* + * These are the defined Ethernet Protocol ID's. + */ + +#define ETH_P_LOOP 0x0060 /* Ethernet Loopback packet */ +#define ETH_P_PUP 0x0200 /* Xerox PUP packet */ +#define ETH_P_PUPAT 0x0201 /* Xerox PUP Addr Trans packet */ +#define ETH_P_IP 0x0800 /* Internet Protocol packet */ +#define ETH_P_X25 0x0805 /* CCITT X.25 */ +#define ETH_P_ARP 0x0806 /* Address Resolution packet */ +#define ETH_P_BPQ 0x08FF /* G8BPQ AX.25 Ethernet Packet */ +#define ETH_P_IEEEPUP 0x0a00 /* Xerox IEEE802.3 PUP packet */ +#define ETH_P_IEEEPUPAT 0x0a01 /* Xerox IEEE802.3 PUP */ +#define ETH_P_DEC 0x6000 /* DEC Assigned proto */ +#define ETH_P_DNA_DL 0x6001 /* DEC DNA Dump/Load */ +#define ETH_P_DNA_RC 0x6002 /* DEC DNA Remote Console */ +#define ETH_P_DNA_RT 0x6003 /* DEC DNA Routing */ +#define ETH_P_LAT 0x6004 /* DEC LAT */ +#define ETH_P_DIAG 0x6005 /* DEC Diagnostics */ +#define ETH_P_CUST 0x6006 /* DEC Customer use */ +#define ETH_P_SCA 0x6007 /* DEC Systems Comms Arch */ +#define ETH_P_RARP 0x8035 /* Reverse Addr Res packet */ +#define ETH_P_ATALK 0x809B /* Appletalk DDP */ +#define ETH_P_AARP 0x80F3 /* Appletalk AARP */ +#define ETH_P_8021Q 0x8100 /* 802.1Q VLAN Extended Header */ +#define ETH_P_IPX 0x8137 /* IPX over DIX */ +#define ETH_P_IPV6 0x86DD /* IPv6 over bluebook */ +#define ETH_P_PPP_DISC 0x8863 /* PPPoE discovery messages */ +#define ETH_P_PPP_SES 0x8864 /* PPPoE session messages */ +#define ETH_P_ATMMPOA 0x884c /* MultiProtocol Over ATM */ +#define ETH_P_ATMFATE 0x8884 /* Frame-based ATM Transport + * over Ethernet + */ + +/* + * Non DIX types. Won't clash for 1500 types. + */ + +#define ETH_P_802_3 0x0001 /* Dummy type for 802.3 frames */ +#define ETH_P_AX25 0x0002 /* Dummy protocol id for AX.25 */ +#define ETH_P_ALL 0x0003 /* Every packet (be careful!!!) */ +#define ETH_P_802_2 0x0004 /* 802.2 frames */ +#define ETH_P_SNAP 0x0005 /* Internal only */ +#define ETH_P_DDCMP 0x0006 /* DEC DDCMP: Internal only */ +#define ETH_P_WAN_PPP 0x0007 /* Dummy type for WAN PPP frames*/ +#define ETH_P_PPP_MP 0x0008 /* Dummy type for PPP MP frames */ +#define ETH_P_LOCALTALK 0x0009 /* Localtalk pseudo type */ +#define ETH_P_PPPTALK 0x0010 /* Dummy type for Atalk over PPP*/ +#define ETH_P_TR_802_2 0x0011 /* 802.2 frames */ +#define ETH_P_MOBITEX 0x0015 /* Mobitex (kaz@cafe.net) */ +#define ETH_P_CONTROL 0x0016 /* Card specific control frames */ +#define ETH_P_IRDA 0x0017 /* Linux-IrDA */ +#define ETH_P_ECONET 0x0018 /* Acorn Econet */ + +/* + * This is an Ethernet frame header. + */ + +struct ethhdr { + unsigned char h_dest[ETH_ALEN]; /* destination eth addr */ + unsigned char h_source[ETH_ALEN]; /* source ether addr */ + unsigned short h_proto; /* packet type ID field */ +}; + +struct _vlan { + unsigned short h_vlan_TCI; /* Encap prio and VLAN ID */ + unsigned short h_vlan_encapsulated_proto; +}; + +#define get_vlan_id(pvlan) \ + ((ntohs((unsigned short)pvlan->h_vlan_TCI)) & 0xfff) +#define get_vlan_priority(pvlan) \ + ((ntohs((unsigned short)pvlan->h_vlan_TCI))>>13) +#define get_vlan_encap_proto(pvlan) \ + (ntohs((unsigned short)pvlan->h_vlan_encapsulated_proto)) + +#endif /* _LINUX_IF_ETHER_H */ diff --git a/drivers/staging/rtl8188eu/include/ioctl_cfg80211.h b/drivers/staging/rtl8188eu/include/ioctl_cfg80211.h new file mode 100644 index 0000000000000..037e9a5e5af99 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/ioctl_cfg80211.h @@ -0,0 +1,107 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __IOCTL_CFG80211_H__ +#define __IOCTL_CFG80211_H__ + +struct rtw_wdev_invit_info { + u8 token; + u8 flags; + u8 status; + u8 req_op_ch; + u8 rsp_op_ch; +}; + +#define rtw_wdev_invit_info_init(invit_info) \ + do { \ + (invit_info)->token = 0; \ + (invit_info)->flags = 0x00; \ + (invit_info)->status = 0xff; \ + (invit_info)->req_op_ch = 0; \ + (invit_info)->rsp_op_ch = 0; \ + } while (0) + +struct rtw_wdev_priv { + struct wireless_dev *rtw_wdev; + + struct adapter *padapter; + + struct cfg80211_scan_request *scan_request; + spinlock_t scan_req_lock; + + struct net_device *pmon_ndev;/* for monitor interface */ + char ifname_mon[IFNAMSIZ + 1]; /* name of monitor interface */ + + u8 p2p_enabled; + + u8 provdisc_req_issued; + + struct rtw_wdev_invit_info invit_info; + + u8 bandroid_scan; + bool block; + bool power_mgmt; +}; + +#define wdev_to_priv(w) ((struct rtw_wdev_priv *)(wdev_priv(w))) + +#define wiphy_to_wdev(x) \ +((struct wireless_dev *)(((struct rtw_wdev_priv *)wiphy_priv(x))->rtw_wdev)) + +int rtw_wdev_alloc(struct adapter *padapter, struct device *dev); +void rtw_wdev_free(struct wireless_dev *wdev); +void rtw_wdev_unregister(struct wireless_dev *wdev); + +void rtw_cfg80211_init_wiphy(struct adapter *padapter); + +void rtw_cfg80211_surveydone_event_callback(struct adapter *padapter); + +void rtw_cfg80211_indicate_connect(struct adapter *padapter); +void rtw_cfg80211_indicate_disconnect(struct adapter *padapter); +void rtw_cfg80211_indicate_scan_done(struct rtw_wdev_priv *pwdev_priv, + bool aborted); + +#ifdef CONFIG_88EU_AP_MODE +void rtw_cfg80211_indicate_sta_assoc(struct adapter *padapter, + u8 *pmgmt_frame, uint frame_len); +void rtw_cfg80211_indicate_sta_disassoc(struct adapter *padapter, + unsigned char *da, + unsigned short reason); +#endif /* CONFIG_88EU_AP_MODE */ + +void rtw_cfg80211_issue_p2p_provision_request(struct adapter *padapter, + const u8 *buf, size_t len); +void rtw_cfg80211_rx_p2p_action_public(struct adapter *padapter, + u8 *pmgmt_frame, uint frame_len); +void rtw_cfg80211_rx_action_p2p(struct adapter *padapter, u8 *pmgmt_frame, + uint frame_len); +void rtw_cfg80211_rx_action(struct adapter *adapter, u8 *frame, + uint frame_len, const char *msg); + +int rtw_cfg80211_set_mgnt_wpsp2pie(struct net_device *net, + char *buf, int len, int type); + +bool rtw_cfg80211_pwr_mgmt(struct adapter *adapter); + +#define rtw_cfg80211_rx_mgmt(dev, freq, sig_dbm, buf, len, gfp) \ + cfg80211_rx_mgmt(dev, freq, sig_dbm, buf, len, gfp) +#define rtw_cfg80211_send_rx_assoc(dev, bss, buf, len) \ + cfg80211_send_rx_assoc(dev, bss, buf, len) + +#endif /* __IOCTL_CFG80211_H__ */ diff --git a/drivers/staging/rtl8188eu/include/ip.h b/drivers/staging/rtl8188eu/include/ip.h new file mode 100644 index 0000000000000..9fdac6d42d177 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/ip.h @@ -0,0 +1,126 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef _LINUX_IP_H +#define _LINUX_IP_H + +/* SOL_IP socket options */ + +#define IPTOS_TOS_MASK 0x1E +#define IPTOS_TOS(tos) ((tos)&IPTOS_TOS_MASK) +#define IPTOS_LOWDELAY 0x10 +#define IPTOS_THROUGHPUT 0x08 +#define IPTOS_RELIABILITY 0x04 +#define IPTOS_MINCOST 0x02 + +#define IPTOS_PREC_MASK 0xE0 +#define IPTOS_PREC(tos) ((tos)&IPTOS_PREC_MASK) +#define IPTOS_PREC_NETCONTROL 0xe0 +#define IPTOS_PREC_INTERNETCONTROL 0xc0 +#define IPTOS_PREC_CRITIC_ECP 0xa0 +#define IPTOS_PREC_FLASHOVERRIDE 0x80 +#define IPTOS_PREC_FLASH 0x60 +#define IPTOS_PREC_IMMEDIATE 0x40 +#define IPTOS_PREC_PRIORITY 0x20 +#define IPTOS_PREC_ROUTINE 0x00 + + +/* IP options */ +#define IPOPT_COPY 0x80 +#define IPOPT_CLASS_MASK 0x60 +#define IPOPT_NUMBER_MASK 0x1f + +#define IPOPT_COPIED(o) ((o)&IPOPT_COPY) +#define IPOPT_CLASS(o) ((o)&IPOPT_CLASS_MASK) +#define IPOPT_NUMBER(o) ((o)&IPOPT_NUMBER_MASK) + +#define IPOPT_CONTROL 0x00 +#define IPOPT_RESERVED1 0x20 +#define IPOPT_MEASUREMENT 0x40 +#define IPOPT_RESERVED2 0x60 + +#define IPOPT_END (0 | IPOPT_CONTROL) +#define IPOPT_NOOP (1 | IPOPT_CONTROL) +#define IPOPT_SEC (2 | IPOPT_CONTROL | IPOPT_COPY) +#define IPOPT_LSRR (3 | IPOPT_CONTROL | IPOPT_COPY) +#define IPOPT_TIMESTAMP (4 | IPOPT_MEASUREMENT) +#define IPOPT_RR (7 | IPOPT_CONTROL) +#define IPOPT_SID (8 | IPOPT_CONTROL | IPOPT_COPY) +#define IPOPT_SSRR (9 | IPOPT_CONTROL | IPOPT_COPY) +#define IPOPT_RA (20 | IPOPT_CONTROL | IPOPT_COPY) + +#define IPVERSION 4 +#define MAXTTL 255 +#define IPDEFTTL 64 +#define IPOPT_OPTVAL 0 +#define IPOPT_OLEN 1 +#define IPOPT_OFFSET 2 +#define IPOPT_MINOFF 4 +#define MAX_IPOPTLEN 40 +#define IPOPT_NOP IPOPT_NOOP +#define IPOPT_EOL IPOPT_END +#define IPOPT_TS IPOPT_TIMESTAMP + +#define IPOPT_TS_TSONLY 0 /* timestamps only */ +#define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */ +#define IPOPT_TS_PRESPEC 3 /* specified modules only */ + +struct ip_options { + __u32 faddr; /* Saved first hop address */ + unsigned char optlen; + unsigned char srr; + unsigned char rr; + unsigned char ts; + unsigned char is_setbyuser:1, /* Set by setsockopt? */ + is_data:1, /* Options in __data, rather than skb*/ + is_strictroute:1,/* Strict source route */ + srr_is_hit:1, /* Packet destn addr was ours */ + is_changed:1, /* IP checksum more not valid */ + rr_needaddr:1, /* Need to record addr of out dev*/ + ts_needtime:1, /* Need to record timestamp */ + ts_needaddr:1; /* Need to record addr of out dev */ + unsigned char router_alert; + unsigned char __pad1; + unsigned char __pad2; + unsigned char __data[0]; +}; + +#define optlength(opt) (sizeof(struct ip_options) + opt->optlen) + +struct iphdr { +#if defined(__LITTLE_ENDIAN_BITFIELD) + __u8 ihl:4, + version:4; +#elif defined(__BIG_ENDIAN_BITFIELD) + __u8 version:4, + ihl:4; +#endif + __u8 tos; + __u16 tot_len; + __u16 id; + __u16 frag_off; + __u8 ttl; + __u8 protocol; + __u16 check; + __u32 saddr; + __u32 daddr; + /*The options start here. */ +}; + +#endif /* _LINUX_IP_H */ diff --git a/drivers/staging/rtl8188eu/include/mlme_osdep.h b/drivers/staging/rtl8188eu/include/mlme_osdep.h new file mode 100644 index 0000000000000..ae1722c67032a --- /dev/null +++ b/drivers/staging/rtl8188eu/include/mlme_osdep.h @@ -0,0 +1,35 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __MLME_OSDEP_H_ +#define __MLME_OSDEP_H_ + +#include +#include + +void rtw_init_mlme_timer(struct adapter *padapter); +void rtw_os_indicate_disconnect(struct adapter *adapter); +void rtw_os_indicate_connect(struct adapter *adapter); +void rtw_os_indicate_scan_done(struct adapter *padapter, bool aborted); +void rtw_report_sec_ie(struct adapter *adapter, u8 authmode, u8 *sec_ie); + +void rtw_reset_securitypriv(struct adapter *adapter); +void indicate_wx_scan_complete_event(struct adapter *padapter); + +#endif /* _MLME_OSDEP_H_ */ diff --git a/drivers/staging/rtl8188eu/include/mp_custom_oid.h b/drivers/staging/rtl8188eu/include/mp_custom_oid.h new file mode 100644 index 0000000000000..6fa52cf99c4ed --- /dev/null +++ b/drivers/staging/rtl8188eu/include/mp_custom_oid.h @@ -0,0 +1,352 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __CUSTOM_OID_H +#define __CUSTOM_OID_H + +/* by Owen */ +/* 0xFF818000 - 0xFF81802F RTL8180 Mass Production Kit */ +/* 0xFF818500 - 0xFF81850F RTL8185 Setup Utility */ +/* 0xFF818580 - 0xFF81858F RTL8185 Phy Status Utility */ + +/* */ + +/* by Owen for Production Kit */ +/* For Production Kit with Agilent Equipments */ +/* in order to make our custom oids hopefully somewhat unique */ +/* we will use 0xFF (indicating implementation specific OID) */ +/* 81(first byte of non zero Realtek unique identifier) */ +/* 80 (second byte of non zero Realtek unique identifier) */ +/* XX (the custom OID number - providing 255 possible custom oids) */ + +#define OID_RT_PRO_RESET_DUT 0xFF818000 +#define OID_RT_PRO_SET_DATA_RATE 0xFF818001 +#define OID_RT_PRO_START_TEST 0xFF818002 +#define OID_RT_PRO_STOP_TEST 0xFF818003 +#define OID_RT_PRO_SET_PREAMBLE 0xFF818004 +#define OID_RT_PRO_SET_SCRAMBLER 0xFF818005 +#define OID_RT_PRO_SET_FILTER_BB 0xFF818006 +#define OID_RT_PRO_SET_MANUAL_DIVERSITY_BB 0xFF818007 +#define OID_RT_PRO_SET_CHANNEL_DIRECT_CALL 0xFF818008 +#define OID_RT_PRO_SET_SLEEP_MODE_DIRECT_CALL 0xFF818009 +#define OID_RT_PRO_SET_WAKE_MODE_DIRECT_CALL 0xFF81800A + +#define OID_RT_PRO_SET_TX_ANTENNA_BB 0xFF81800D +#define OID_RT_PRO_SET_ANTENNA_BB 0xFF81800E +#define OID_RT_PRO_SET_CR_SCRAMBLER 0xFF81800F +#define OID_RT_PRO_SET_CR_NEW_FILTER 0xFF818010 +#define OID_RT_PRO_SET_TX_POWER_CONTROL 0xFF818011 +#define OID_RT_PRO_SET_CR_TX_CONFIG 0xFF818012 +#define OID_RT_PRO_GET_TX_POWER_CONTROL 0xFF818013 +#define OID_RT_PRO_GET_CR_SIGNAL_QUALITY 0xFF818014 +#define OID_RT_PRO_SET_CR_SETPOINT 0xFF818015 +#define OID_RT_PRO_SET_INTEGRATOR 0xFF818016 +#define OID_RT_PRO_SET_SIGNAL_QUALITY 0xFF818017 +#define OID_RT_PRO_GET_INTEGRATOR 0xFF818018 +#define OID_RT_PRO_GET_SIGNAL_QUALITY 0xFF818019 +#define OID_RT_PRO_QUERY_EEPROM_TYPE 0xFF81801A +#define OID_RT_PRO_WRITE_MAC_ADDRESS 0xFF81801B +#define OID_RT_PRO_READ_MAC_ADDRESS 0xFF81801C +#define OID_RT_PRO_WRITE_CIS_DATA 0xFF81801D +#define OID_RT_PRO_READ_CIS_DATA 0xFF81801E +#define OID_RT_PRO_WRITE_POWER_CONTROL 0xFF81801F +#define OID_RT_PRO_READ_POWER_CONTROL 0xFF818020 +#define OID_RT_PRO_WRITE_EEPROM 0xFF818021 +#define OID_RT_PRO_READ_EEPROM 0xFF818022 +#define OID_RT_PRO_RESET_TX_PACKET_SENT 0xFF818023 +#define OID_RT_PRO_QUERY_TX_PACKET_SENT 0xFF818024 +#define OID_RT_PRO_RESET_RX_PACKET_RECEIVED 0xFF818025 +#define OID_RT_PRO_QUERY_RX_PACKET_RECEIVED 0xFF818026 +#define OID_RT_PRO_QUERY_RX_PACKET_CRC32_ERROR 0xFF818027 +#define OID_RT_PRO_QUERY_CURRENT_ADDRESS 0xFF818028 +#define OID_RT_PRO_QUERY_PERMANENT_ADDRESS 0xFF818029 +#define OID_RT_PRO_SET_PHILIPS_RF_PARAMETERS 0xFF81802A +#define OID_RT_PRO_RECEIVE_PACKET 0xFF81802C +/* added by Owen on 04/08/03 for Cameo's request */ +#define OID_RT_PRO_WRITE_EEPROM_BYTE 0xFF81802D +#define OID_RT_PRO_READ_EEPROM_BYTE 0xFF81802E +#define OID_RT_PRO_SET_MODULATION 0xFF81802F +/* */ + +/* Sean */ +#define OID_RT_DRIVER_OPTION 0xFF818080 +#define OID_RT_RF_OFF 0xFF818081 +#define OID_RT_AUTH_STATUS 0xFF818082 + +/* */ +#define OID_RT_PRO_SET_CONTINUOUS_TX 0xFF81800B +#define OID_RT_PRO_SET_SINGLE_CARRIER_TX 0xFF81800C +#define OID_RT_PRO_SET_CARRIER_SUPPRESSION_TX 0xFF81802B +#define OID_RT_PRO_SET_SINGLE_TONE_TX 0xFF818043 +/* */ + + +/* by Owen for RTL8185 Phy Status Report Utility */ +#define OID_RT_UTILITY_false_ALARM_COUNTERS 0xFF818580 +#define OID_RT_UTILITY_SELECT_DEBUG_MODE 0xFF818581 +#define OID_RT_UTILITY_SELECT_SUBCARRIER_NUMBER 0xFF818582 +#define OID_RT_UTILITY_GET_RSSI_STATUS 0xFF818583 +#define OID_RT_UTILITY_GET_FRAME_DETECTION_STATUS 0xFF818584 +#define OID_RT_UTILITY_GET_AGC_AND_FREQUENCY_OFFSET_ESTIMATION_STATUS \ + 0xFF818585 +#define OID_RT_UTILITY_GET_CHANNEL_ESTIMATION_STATUS 0xFF818586 +/* */ + +/* by Owen on 03/09/19-03/09/22 for RTL8185 */ +#define OID_RT_WIRELESS_MODE 0xFF818500 +#define OID_RT_SUPPORTED_RATES 0xFF818501 +#define OID_RT_DESIRED_RATES 0xFF818502 +#define OID_RT_WIRELESS_MODE_STARTING_ADHOC 0xFF818503 +/* */ + +#define OID_RT_GET_CONNECT_STATE 0xFF030001 +#define OID_RT_RESCAN 0xFF030002 +#define OID_RT_SET_KEY_LENGTH 0xFF030003 +#define OID_RT_SET_DEFAULT_KEY_ID 0xFF030004 + +#define OID_RT_SET_CHANNEL 0xFF010182 +#define OID_RT_SET_SNIFFER_MODE 0xFF010183 +#define OID_RT_GET_SIGNAL_QUALITY 0xFF010184 +#define OID_RT_GET_SMALL_PACKET_CRC 0xFF010185 +#define OID_RT_GET_MIDDLE_PACKET_CRC 0xFF010186 +#define OID_RT_GET_LARGE_PACKET_CRC 0xFF010187 +#define OID_RT_GET_TX_RETRY 0xFF010188 +#define OID_RT_GET_RX_RETRY 0xFF010189 +#define OID_RT_PRO_SET_FW_DIG_STATE 0xFF01018A/* S */ +#define OID_RT_PRO_SET_FW_RA_STATE 0xFF01018B/* S */ + +#define OID_RT_GET_RX_TOTAL_PACKET 0xFF010190 +#define OID_RT_GET_TX_BEACON_OK 0xFF010191 +#define OID_RT_GET_TX_BEACON_ERR 0xFF010192 +#define OID_RT_GET_RX_ICV_ERR 0xFF010193 +#define OID_RT_SET_ENCRYPTION_ALGORITHM 0xFF010194 +#define OID_RT_SET_NO_AUTO_RESCAN 0xFF010195 +#define OID_RT_GET_PREAMBLE_MODE 0xFF010196 +#define OID_RT_GET_DRIVER_UP_DELTA_TIME 0xFF010197 +#define OID_RT_GET_AP_IP 0xFF010198 +#define OID_RT_GET_CHANNELPLAN 0xFF010199 +#define OID_RT_SET_PREAMBLE_MODE 0xFF01019A +#define OID_RT_SET_BCN_INTVL 0xFF01019B +#define OID_RT_GET_RF_VENDER 0xFF01019C +#define OID_RT_DEDICATE_PROBE 0xFF01019D +#define OID_RT_PRO_RX_FILTER_PATTERN 0xFF01019E + +#define OID_RT_GET_DCST_CURRENT_THRESHOLD 0xFF01019F + +#define OID_RT_GET_CCA_ERR 0xFF0101A0 +#define OID_RT_GET_CCA_UPGRADE_THRESHOLD 0xFF0101A1 +#define OID_RT_GET_CCA_FALLBACK_THRESHOLD 0xFF0101A2 + +#define OID_RT_GET_CCA_UPGRADE_EVALUATE_TIMES 0xFF0101A3 +#define OID_RT_GET_CCA_FALLBACK_EVALUATE_TIMES 0xFF0101A4 + +/* by Owen on 03/31/03 for Cameo's request */ +#define OID_RT_SET_RATE_ADAPTIVE 0xFF0101A5 +/* */ +#define OID_RT_GET_DCST_EVALUATE_PERIOD 0xFF0101A5 +#define OID_RT_GET_DCST_TIME_UNIT_INDEX 0xFF0101A6 +#define OID_RT_GET_TOTAL_TX_BYTES 0xFF0101A7 +#define OID_RT_GET_TOTAL_RX_BYTES 0xFF0101A8 +#define OID_RT_CURRENT_TX_POWER_LEVEL 0xFF0101A9 +#define OID_RT_GET_ENC_KEY_MISMATCH_COUNT 0xFF0101AA +#define OID_RT_GET_ENC_KEY_MATCH_COUNT 0xFF0101AB +#define OID_RT_GET_CHANNEL 0xFF0101AC + +#define OID_RT_SET_CHANNELPLAN 0xFF0101AD +#define OID_RT_GET_HARDWARE_RADIO_OFF 0xFF0101AE +#define OID_RT_CHANNELPLAN_BY_COUNTRY 0xFF0101AF +#define OID_RT_SCAN_AVAILABLE_BSSID 0xFF0101B0 +#define OID_RT_GET_HARDWARE_VERSION 0xFF0101B1 +#define OID_RT_GET_IS_ROAMING 0xFF0101B2 +#define OID_RT_GET_IS_PRIVACY 0xFF0101B3 +#define OID_RT_GET_KEY_MISMATCH 0xFF0101B4 +#define OID_RT_SET_RSSI_ROAM_TRAFFIC_TH 0xFF0101B5 +#define OID_RT_SET_RSSI_ROAM_SIGNAL_TH 0xFF0101B6 +#define OID_RT_RESET_LOG 0xFF0101B7 +#define OID_RT_GET_LOG 0xFF0101B8 +#define OID_RT_SET_INDICATE_HIDDEN_AP 0xFF0101B9 +#define OID_RT_GET_HEADER_FAIL 0xFF0101BA +#define OID_RT_SUPPORTED_WIRELESS_MODE 0xFF0101BB +#define OID_RT_GET_CHANNEL_LIST 0xFF0101BC +#define OID_RT_GET_SCAN_IN_PROGRESS 0xFF0101BD +#define OID_RT_GET_TX_INFO 0xFF0101BE +#define OID_RT_RF_READ_WRITE_OFFSET 0xFF0101BF +#define OID_RT_RF_READ_WRITE 0xFF0101C0 + +/* For Netgear request. 2005.01.13, by rcnjko. */ +#define OID_RT_FORCED_DATA_RATE 0xFF0101C1 +#define OID_RT_WIRELESS_MODE_FOR_SCAN_LIST 0xFF0101C2 +/* For Netgear request. 2005.02.17, by rcnjko. */ +#define OID_RT_GET_BSS_WIRELESS_MODE 0xFF0101C3 +/* For AZ project. 2005.06.27, by rcnjko. */ +#define OID_RT_SCAN_WITH_MAGIC_PACKET 0xFF0101C4 + +/* Vincent 8185MP */ +#define OID_RT_PRO_RX_FILTER 0xFF0111C0 + +#define OID_CE_USB_WRITE_REGISTRY 0xFF0111C1 +#define OID_CE_USB_READ_REGISTRY 0xFF0111C2 + +#define OID_RT_PRO_SET_INITIAL_GA 0xFF0111C3 +#define OID_RT_PRO_SET_BB_RF_STANDBY_MODE 0xFF0111C4 +#define OID_RT_PRO_SET_BB_RF_SHUTDOWN_MODE 0xFF0111C5 +#define OID_RT_PRO_SET_TX_CHARGE_PUMP 0xFF0111C6 +#define OID_RT_PRO_SET_RX_CHARGE_PUMP 0xFF0111C7 +#define OID_RT_PRO_RF_WRITE_REGISTRY 0xFF0111C8 +#define OID_RT_PRO_RF_READ_REGISTRY 0xFF0111C9 +#define OID_RT_PRO_QUERY_RF_TYPE 0xFF0111CA + +/* AP OID */ +#define OID_RT_AP_GET_ASSOCIATED_STATION_LIST 0xFF010300 +#define OID_RT_AP_GET_CURRENT_TIME_STAMP 0xFF010301 +#define OID_RT_AP_SWITCH_INTO_AP_MODE 0xFF010302 +#define OID_RT_AP_SET_DTIM_PERIOD 0xFF010303 +/* Determine if driver supports AP mode. */ +#define OID_RT_AP_SUPPORTED 0xFF010304 +/* Set WPA-PSK passphrase into authenticator. */ +#define OID_RT_AP_SET_PASSPHRASE 0xFF010305 + +/* 8187MP. 2004.09.06, by rcnjko. */ +#define OID_RT_PRO8187_WI_POLL 0xFF818780 +#define OID_RT_PRO_WRITE_BB_REG 0xFF818781 +#define OID_RT_PRO_READ_BB_REG 0xFF818782 +#define OID_RT_PRO_WRITE_RF_REG 0xFF818783 +#define OID_RT_PRO_READ_RF_REG 0xFF818784 + +/* Meeting House. added by Annie, 2005-07-20. */ +#define OID_RT_MH_VENDER_ID 0xFFEDC100 + +/* 8711 MP OID added 20051230. */ +#define OID_RT_PRO8711_JOIN_BSS 0xFF871100/* S */ + +#define OID_RT_PRO_READ_REGISTER 0xFF871101 /* Q */ +#define OID_RT_PRO_WRITE_REGISTER 0xFF871102 /* S */ + +#define OID_RT_PRO_BURST_READ_REGISTER 0xFF871103 /* Q */ +#define OID_RT_PRO_BURST_WRITE_REGISTER 0xFF871104 /* S */ + +#define OID_RT_PRO_WRITE_TXCMD 0xFF871105 /* S */ + +#define OID_RT_PRO_READ16_EEPROM 0xFF871106 /* Q */ +#define OID_RT_PRO_WRITE16_EEPROM 0xFF871107 /* S */ + +#define OID_RT_PRO_H2C_SET_COMMAND 0xFF871108 /* S */ +#define OID_RT_PRO_H2C_QUERY_RESULT 0xFF871109 /* Q */ + +#define OID_RT_PRO8711_WI_POLL 0xFF87110A /* Q */ +#define OID_RT_PRO8711_PKT_LOSS 0xFF87110B /* Q */ +#define OID_RT_RD_ATTRIB_MEM 0xFF87110C/* Q */ +#define OID_RT_WR_ATTRIB_MEM 0xFF87110D/* S */ + + +/* Method 2 for H2C/C2H */ +#define OID_RT_PRO_H2C_CMD_MODE 0xFF871110 /* S */ +#define OID_RT_PRO_H2C_CMD_RSP_MODE 0xFF871111 /* Q */ +#define OID_RT_PRO_H2C_CMD_EVENT_MODE 0xFF871112 /* S */ +#define OID_RT_PRO_WAIT_C2H_EVENT 0xFF871113 /* Q */ +#define OID_RT_PRO_RW_ACCESS_PROTOCOL_TEST 0xFF871114/* Q */ + +#define OID_RT_PRO_SCSI_ACCESS_TEST 0xFF871115 /* Q, S */ + +#define OID_RT_PRO_SCSI_TCPIPOFFLOAD_OUT 0xFF871116 /* S */ +#define OID_RT_PRO_SCSI_TCPIPOFFLOAD_IN 0xFF871117 /* Q,S */ +#define OID_RT_RRO_RX_PKT_VIA_IOCTRL 0xFF871118 /* Q */ +#define OID_RT_RRO_RX_PKTARRAY_VIA_IOCTRL 0xFF871119 /* Q */ + +#define OID_RT_RPO_SET_PWRMGT_TEST 0xFF87111A /* S */ +#define OID_RT_PRO_QRY_PWRMGT_TEST 0XFF87111B /* Q */ +#define OID_RT_RPO_ASYNC_RWIO_TEST 0xFF87111C /* S */ +#define OID_RT_RPO_ASYNC_RWIO_POLL 0xFF87111D /* Q */ +#define OID_RT_PRO_SET_RF_INTFS 0xFF87111E /* S */ +#define OID_RT_POLL_RX_STATUS 0xFF87111F /* Q */ + +#define OID_RT_PRO_CFG_DEBUG_MESSAGE 0xFF871120 /* Q,S */ +#define OID_RT_PRO_SET_DATA_RATE_EX 0xFF871121/* S */ +#define OID_RT_PRO_SET_BASIC_RATE 0xFF871122/* S */ +#define OID_RT_PRO_READ_TSSI 0xFF871123/* S */ +#define OID_RT_PRO_SET_POWER_TRACKING 0xFF871124/* S */ + + +#define OID_RT_PRO_QRY_PWRSTATE 0xFF871150 /* Q */ +#define OID_RT_PRO_SET_PWRSTATE 0xFF871151 /* S */ + +/* Method 2 , using workitem */ +#define OID_RT_SET_READ_REG 0xFF871181 /* S */ +#define OID_RT_SET_WRITE_REG 0xFF871182 /* S */ +#define OID_RT_SET_BURST_READ_REG 0xFF871183 /* S */ +#define OID_RT_SET_BURST_WRITE_REG 0xFF871184 /* S */ +#define OID_RT_SET_WRITE_TXCMD 0xFF871185 /* S */ +#define OID_RT_SET_READ16_EEPROM 0xFF871186 /* S */ +#define OID_RT_SET_WRITE16_EEPROM 0xFF871187 /* S */ +#define OID_RT_QRY_POLL_WKITEM 0xFF871188 /* Q */ + +/* For SDIO INTERFACE only */ +#define OID_RT_PRO_SYNCPAGERW_SRAM 0xFF8711A0 /* Q, S */ +#define OID_RT_PRO_871X_DRV_EXT 0xFF8711A1 + +/* For USB INTERFACE only */ +#define OID_RT_PRO_USB_VENDOR_REQ 0xFF8711B0 /* Q, S */ +#define OID_RT_PRO_SCSI_AUTO_TEST 0xFF8711B1 /* S */ +#define OID_RT_PRO_USB_MAC_AC_FIFO_WRITE 0xFF8711B2 /* S */ +#define OID_RT_PRO_USB_MAC_RX_FIFO_READ 0xFF8711B3 /* Q */ +#define OID_RT_PRO_USB_MAC_RX_FIFO_POLLING 0xFF8711B4 /* Q */ + +#define OID_RT_PRO_H2C_SET_RATE_TABLE 0xFF8711FB /* S */ +#define OID_RT_PRO_H2C_GET_RATE_TABLE 0xFF8711FC /* S */ +#define OID_RT_PRO_H2C_C2H_LBK_TEST 0xFF8711FE + +#define OID_RT_PRO_ENCRYPTION_CTRL 0xFF871200 /* Q, S */ +#define OID_RT_PRO_ADD_STA_INFO 0xFF871201 /* S */ +#define OID_RT_PRO_DELE_STA_INFO 0xFF871202 /* S */ +#define OID_RT_PRO_QUERY_DR_VARIABLE 0xFF871203 /* Q */ + +#define OID_RT_PRO_RX_PACKET_TYPE 0xFF871204 /* Q, S */ + +#define OID_RT_PRO_READ_EFUSE 0xFF871205 /* Q */ +#define OID_RT_PRO_WRITE_EFUSE 0xFF871206 /* S */ +#define OID_RT_PRO_RW_EFUSE_PGPKT 0xFF871207 /* Q, S */ +#define OID_RT_GET_EFUSE_CURRENT_SIZE 0xFF871208 /* Q */ + +#define OID_RT_SET_BANDWIDTH 0xFF871209 /* S */ +#define OID_RT_SET_CRYSTAL_CAP 0xFF87120A /* S */ + +#define OID_RT_SET_RX_PACKET_TYPE 0xFF87120B /* S */ + +#define OID_RT_GET_EFUSE_MAX_SIZE 0xFF87120C /* Q */ + +#define OID_RT_PRO_SET_TX_AGC_OFFSET 0xFF87120D /* S */ + +#define OID_RT_PRO_SET_PKT_TEST_MODE 0xFF87120E /* S */ + +#define OID_RT_PRO_FOR_EVM_TEST_SETTING 0xFF87120F /* S */ + +#define OID_RT_PRO_GET_THERMAL_METER 0xFF871210 /* Q */ + +#define OID_RT_RESET_PHY_RX_PACKET_COUNT 0xFF871211 /* S */ +#define OID_RT_GET_PHY_RX_PACKET_RECEIVED 0xFF871212 /* Q */ +#define OID_RT_GET_PHY_RX_PACKET_CRC32_ERROR 0xFF871213 /* Q */ + +#define OID_RT_SET_POWER_DOWN 0xFF871214 /* S */ + +#define OID_RT_GET_POWER_MODE 0xFF871215 /* Q */ + +#define OID_RT_PRO_EFUSE 0xFF871216 /* Q, S */ +#define OID_RT_PRO_EFUSE_MAP 0xFF871217 /* Q, S */ + +#endif /* ifndef __CUSTOM_OID_H */ diff --git a/drivers/staging/rtl8188eu/include/nic_spec.h b/drivers/staging/rtl8188eu/include/nic_spec.h new file mode 100644 index 0000000000000..d42244788ca9e --- /dev/null +++ b/drivers/staging/rtl8188eu/include/nic_spec.h @@ -0,0 +1,44 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + + +#ifndef __NIC_SPEC_H__ +#define __NIC_SPEC_H__ + +#define RTL8711_MCTRL_ (0x20000) +#define RTL8711_UART_ (0x30000) +#define RTL8711_TIMER_ (0x40000) +#define RTL8711_FINT_ (0x50000) +#define RTL8711_HINT_ (0x50000) +#define RTL8711_GPIO_ (0x60000) +#define RTL8711_WLANCTRL_ (0x200000) +#define RTL8711_WLANFF_ (0xe00000) +#define RTL8711_HCICTRL_ (0x600000) +#define RTL8711_SYSCFG_ (0x620000) +#define RTL8711_SYSCTRL_ (0x620000) +#define RTL8711_MCCTRL_ (0x020000) + + +#include + +#include + + +#endif /* __RTL8711_SPEC_H__ */ -- GitLab From f9f08d70b0081c0f5ff4eabefc47f0832fdb7697 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 21 Aug 2013 22:34:06 -0500 Subject: [PATCH 782/942] staging: r8188eu: Add files for new driver - part 24 This commit adds files include/odm.h, include/odm_HWConfig.h, include/odm_RTL8188E.h, include/odm_RegConfig8188E.h, include/odm_RegDefine11AC.h, include/odm_RegDefine11N.h, include/odm_debug.h, include/odm_interface.h, include/odm_precomp.h, include/odm_reg.h, include/odm_types.h, include/osdep_intf.h, and include/osdep_service.h. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/odm.h | 1198 +++++++++++++++++ .../staging/rtl8188eu/include/odm_HWConfig.h | 132 ++ .../staging/rtl8188eu/include/odm_RTL8188E.h | 56 + .../rtl8188eu/include/odm_RegConfig8188E.h | 43 + .../rtl8188eu/include/odm_RegDefine11AC.h | 54 + .../rtl8188eu/include/odm_RegDefine11N.h | 171 +++ drivers/staging/rtl8188eu/include/odm_debug.h | 145 ++ .../staging/rtl8188eu/include/odm_interface.h | 164 +++ .../staging/rtl8188eu/include/odm_precomp.h | 104 ++ drivers/staging/rtl8188eu/include/odm_reg.h | 119 ++ drivers/staging/rtl8188eu/include/odm_types.h | 62 + .../staging/rtl8188eu/include/osdep_intf.h | 83 ++ .../staging/rtl8188eu/include/osdep_service.h | 548 ++++++++ 13 files changed, 2879 insertions(+) create mode 100644 drivers/staging/rtl8188eu/include/odm.h create mode 100644 drivers/staging/rtl8188eu/include/odm_HWConfig.h create mode 100644 drivers/staging/rtl8188eu/include/odm_RTL8188E.h create mode 100644 drivers/staging/rtl8188eu/include/odm_RegConfig8188E.h create mode 100644 drivers/staging/rtl8188eu/include/odm_RegDefine11AC.h create mode 100644 drivers/staging/rtl8188eu/include/odm_RegDefine11N.h create mode 100644 drivers/staging/rtl8188eu/include/odm_debug.h create mode 100644 drivers/staging/rtl8188eu/include/odm_interface.h create mode 100644 drivers/staging/rtl8188eu/include/odm_precomp.h create mode 100644 drivers/staging/rtl8188eu/include/odm_reg.h create mode 100644 drivers/staging/rtl8188eu/include/odm_types.h create mode 100644 drivers/staging/rtl8188eu/include/osdep_intf.h create mode 100644 drivers/staging/rtl8188eu/include/osdep_service.h diff --git a/drivers/staging/rtl8188eu/include/odm.h b/drivers/staging/rtl8188eu/include/odm.h new file mode 100644 index 0000000000000..2bfe72841921b --- /dev/null +++ b/drivers/staging/rtl8188eu/include/odm.h @@ -0,0 +1,1198 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + + +#ifndef __HALDMOUTSRC_H__ +#define __HALDMOUTSRC_H__ + +/* Definition */ +/* Define all team support ability. */ + +/* Define for all teams. Please Define the constant in your precomp header. */ + +/* define DM_ODM_SUPPORT_AP 0 */ +/* define DM_ODM_SUPPORT_ADSL 0 */ +/* define DM_ODM_SUPPORT_CE 0 */ +/* define DM_ODM_SUPPORT_MP 1 */ + +/* Define ODM SW team support flag. */ + +/* Antenna Switch Relative Definition. */ + +/* Add new function SwAntDivCheck8192C(). */ +/* This is the main function of Antenna diversity function before link. */ +/* Mainly, it just retains last scan result and scan again. */ +/* After that, it compares the scan result to see which one gets better + * RSSI. It selects antenna with better receiving power and returns better + * scan result. */ + +#define TP_MODE 0 +#define RSSI_MODE 1 +#define TRAFFIC_LOW 0 +#define TRAFFIC_HIGH 1 + +/* 3 Tx Power Tracking */ +/* 3============================================================ */ +#define DPK_DELTA_MAPPING_NUM 13 +#define index_mapping_HP_NUM 15 + + +/* */ +/* 3 PSD Handler */ +/* 3============================================================ */ + +#define AFH_PSD 1 /* 0:normal PSD scan, 1: only do 20 pts PSD */ +#define MODE_40M 0 /* 0:20M, 1:40M */ +#define PSD_TH2 3 +#define PSD_CHM 20 /* Minimum channel number for BT AFH */ +#define SIR_STEP_SIZE 3 +#define Smooth_Size_1 5 +#define Smooth_TH_1 3 +#define Smooth_Size_2 10 +#define Smooth_TH_2 4 +#define Smooth_Size_3 20 +#define Smooth_TH_3 4 +#define Smooth_Step_Size 5 +#define Adaptive_SIR 1 +#define PSD_RESCAN 4 +#define PSD_SCAN_INTERVAL 700 /* ms */ + +/* 8723A High Power IGI Setting */ +#define DM_DIG_HIGH_PWR_IGI_LOWER_BOUND 0x22 +#define DM_DIG_Gmode_HIGH_PWR_IGI_LOWER_BOUND 0x28 +#define DM_DIG_HIGH_PWR_THRESHOLD 0x3a + +/* LPS define */ +#define DM_DIG_FA_TH0_LPS 4 /* 4 in lps */ +#define DM_DIG_FA_TH1_LPS 15 /* 15 lps */ +#define DM_DIG_FA_TH2_LPS 30 /* 30 lps */ +#define RSSI_OFFSET_DIG 0x05; + +/* ANT Test */ +#define ANTTESTALL 0x00 /* Ant A or B will be Testing */ +#define ANTTESTA 0x01 /* Ant A will be Testing */ +#define ANTTESTB 0x02 /* Ant B will be testing */ + +/* structure and define */ + +/* Add for AP/ADSLpseudo DM structuer requirement. */ +/* We need to remove to other position??? */ +struct rtl8192cd_priv { + u8 temp; +}; + +struct rtw_dig { + u8 Dig_Enable_Flag; + u8 Dig_Ext_Port_Stage; + + int RssiLowThresh; + int RssiHighThresh; + + u32 FALowThresh; + u32 FAHighThresh; + + u8 CurSTAConnectState; + u8 PreSTAConnectState; + u8 CurMultiSTAConnectState; + + u8 PreIGValue; + u8 CurIGValue; + u8 BackupIGValue; + + s8 BackoffVal; + s8 BackoffVal_range_max; + s8 BackoffVal_range_min; + u8 rx_gain_range_max; + u8 rx_gain_range_min; + u8 Rssi_val_min; + + u8 PreCCK_CCAThres; + u8 CurCCK_CCAThres; + u8 PreCCKPDState; + u8 CurCCKPDState; + + u8 LargeFAHit; + u8 ForbiddenIGI; + u32 Recover_cnt; + + u8 DIG_Dynamic_MIN_0; + u8 DIG_Dynamic_MIN_1; + bool bMediaConnect_0; + bool bMediaConnect_1; + + u32 AntDiv_RSSI_max; + u32 RSSI_max; +}; + +struct rtl_ps { + u8 PreCCAState; + u8 CurCCAState; + + u8 PreRFState; + u8 CurRFState; + + int Rssi_val_min; + + u8 initialize; + u32 Reg874,RegC70,Reg85C,RegA74; + +}; + +struct false_alarm_stats { + u32 Cnt_Parity_Fail; + u32 Cnt_Rate_Illegal; + u32 Cnt_Crc8_fail; + u32 Cnt_Mcs_fail; + u32 Cnt_Ofdm_fail; + u32 Cnt_Cck_fail; + u32 Cnt_all; + u32 Cnt_Fast_Fsync; + u32 Cnt_SB_Search_fail; + u32 Cnt_OFDM_CCA; + u32 Cnt_CCK_CCA; + u32 Cnt_CCA_all; + u32 Cnt_BW_USC; /* Gary */ + u32 Cnt_BW_LSC; /* Gary */ +}; + +struct dyn_primary_cca { + u8 PriCCA_flag; + u8 intf_flag; + u8 intf_type; + u8 DupRTS_flag; + u8 Monitor_flag; +}; + +struct rx_hpc { + u8 RXHP_flag; + u8 PSD_func_trigger; + u8 PSD_bitmap_RXHP[80]; + u8 Pre_IGI; + u8 Cur_IGI; + u8 Pre_pw_th; + u8 Cur_pw_th; + bool First_time_enter; + bool RXHP_enable; + u8 TP_Mode; + struct timer_list PSDTimer; +}; + +#define ASSOCIATE_ENTRY_NUM 32 /* Max size of AsocEntry[]. */ +#define ODM_ASSOCIATE_ENTRY_NUM ASSOCIATE_ENTRY_NUM + +/* This indicates two different steps. */ +/* In SWAW_STEP_PEAK, driver needs to switch antenna and listen to + * the signal on the air. */ +/* In SWAW_STEP_DETERMINE, driver just compares the signal captured in + * SWAW_STEP_PEAK with original RSSI to determine if it is necessary to + * switch antenna. */ + +#define SWAW_STEP_PEAK 0 +#define SWAW_STEP_DETERMINE 1 + +#define TP_MODE 0 +#define RSSI_MODE 1 +#define TRAFFIC_LOW 0 +#define TRAFFIC_HIGH 1 + +struct sw_ant_switch { + u8 try_flag; + s32 PreRSSI; + u8 CurAntenna; + u8 PreAntenna; + u8 RSSI_Trying; + u8 TestMode; + u8 bTriggerAntennaSwitch; + u8 SelectAntennaMap; + u8 RSSI_target; + + /* Before link Antenna Switch check */ + u8 SWAS_NoLink_State; + u32 SWAS_NoLink_BK_Reg860; + bool ANTA_ON; /* To indicate Ant A is or not */ + bool ANTB_ON; /* To indicate Ant B is on or not */ + + s32 RSSI_sum_A; + s32 RSSI_sum_B; + s32 RSSI_cnt_A; + s32 RSSI_cnt_B; + u64 lastTxOkCnt; + u64 lastRxOkCnt; + u64 TXByteCnt_A; + u64 TXByteCnt_B; + u64 RXByteCnt_A; + u64 RXByteCnt_B; + u8 TrafficLoad; + struct timer_list SwAntennaSwitchTimer; + /* Hybrid Antenna Diversity */ + u32 CCK_Ant1_Cnt[ASSOCIATE_ENTRY_NUM]; + u32 CCK_Ant2_Cnt[ASSOCIATE_ENTRY_NUM]; + u32 OFDM_Ant1_Cnt[ASSOCIATE_ENTRY_NUM]; + u32 OFDM_Ant2_Cnt[ASSOCIATE_ENTRY_NUM]; + u32 RSSI_Ant1_Sum[ASSOCIATE_ENTRY_NUM]; + u32 RSSI_Ant2_Sum[ASSOCIATE_ENTRY_NUM]; + u8 TxAnt[ASSOCIATE_ENTRY_NUM]; + u8 TargetSTA; + u8 antsel; + u8 RxIdleAnt; +}; + +struct edca_turbo { + bool bCurrentTurboEDCA; + bool bIsCurRDLState; + u32 prv_traffic_idx; /* edca turbo */ +}; + +struct odm_rate_adapt { + u8 Type; /* DM_Type_ByFW/DM_Type_ByDriver */ + u8 HighRSSIThresh; /* if RSSI > HighRSSIThresh => RATRState is DM_RATR_STA_HIGH */ + u8 LowRSSIThresh; /* if RSSI <= LowRSSIThresh => RATRState is DM_RATR_STA_LOW */ + u8 RATRState; /* Current RSSI level, DM_RATR_STA_HIGH/DM_RATR_STA_MIDDLE/DM_RATR_STA_LOW */ + u32 LastRATR; /* RATR Register Content */ +}; + +#define IQK_MAC_REG_NUM 4 +#define IQK_ADDA_REG_NUM 16 +#define IQK_BB_REG_NUM_MAX 10 +#define IQK_BB_REG_NUM 9 +#define HP_THERMAL_NUM 8 + +#define AVG_THERMAL_NUM 8 +#define IQK_Matrix_REG_NUM 8 +#define IQK_Matrix_Settings_NUM 1+24+21 + +#define DM_Type_ByFWi 0 +#define DM_Type_ByDriver 1 + +/* Declare for common info */ + +#define MAX_PATH_NUM_92CS 2 + +struct odm_phy_status_info { + u8 RxPWDBAll; + u8 SignalQuality; /* in 0-100 index. */ + u8 RxMIMOSignalQuality[MAX_PATH_NUM_92CS]; /* EVM */ + u8 RxMIMOSignalStrength[MAX_PATH_NUM_92CS];/* in 0~100 index */ + s8 RxPower; /* in dBm Translate from PWdB */ + s8 RecvSignalPower;/* Real power in dBm for this packet, no + * beautification and aggregation. Keep this raw + * info to be used for the other procedures. */ + u8 BTRxRSSIPercentage; + u8 SignalStrength; /* in 0-100 index. */ + u8 RxPwr[MAX_PATH_NUM_92CS];/* per-path's pwdb */ + u8 RxSNR[MAX_PATH_NUM_92CS];/* per-path's SNR */ +}; + +struct odm_phy_dbg_info { + /* ODM Write,debug info */ + s8 RxSNRdB[MAX_PATH_NUM_92CS]; + u64 NumQryPhyStatus; + u64 NumQryPhyStatusCCK; + u64 NumQryPhyStatusOFDM; + /* Others */ + s32 RxEVM[MAX_PATH_NUM_92CS]; +}; + +struct odm_per_pkt_info { + s8 Rate; + u8 StationID; + bool bPacketMatchBSSID; + bool bPacketToSelf; + bool bPacketBeacon; +}; + +struct odm_mac_status_info { + u8 test; +}; + +enum odm_ability { + /* BB Team */ + ODM_DIG = 0x00000001, + ODM_HIGH_POWER = 0x00000002, + ODM_CCK_CCA_TH = 0x00000004, + ODM_FA_STATISTICS = 0x00000008, + ODM_RAMASK = 0x00000010, + ODM_RSSI_MONITOR = 0x00000020, + ODM_SW_ANTDIV = 0x00000040, + ODM_HW_ANTDIV = 0x00000080, + ODM_BB_PWRSV = 0x00000100, + ODM_2TPATHDIV = 0x00000200, + ODM_1TPATHDIV = 0x00000400, + ODM_PSD2AFH = 0x00000800 +}; + +/* 2011/20/20 MH For MP driver RT_WLAN_STA = struct sta_info */ +/* Please declare below ODM relative info in your STA info structure. */ + +struct odm_sta_info { + /* Driver Write */ + bool bUsed; /* record the sta status link or not? */ + u8 IOTPeer; /* Enum value. HT_IOT_PEER_E */ + + /* ODM Write */ + /* 1 PHY_STATUS_INFO */ + u8 RSSI_Path[4]; /* */ + u8 RSSI_Ave; + u8 RXEVM[4]; + u8 RXSNR[4]; +}; + +/* 2011/10/20 MH Define Common info enum for all team. */ + +enum odm_common_info_def { + /* Fixed value: */ + + /* HOOK BEFORE REG INIT----------- */ + ODM_CMNINFO_PLATFORM = 0, + ODM_CMNINFO_ABILITY, /* ODM_ABILITY_E */ + ODM_CMNINFO_INTERFACE, /* ODM_INTERFACE_E */ + ODM_CMNINFO_MP_TEST_CHIP, + ODM_CMNINFO_IC_TYPE, /* ODM_IC_TYPE_E */ + ODM_CMNINFO_CUT_VER, /* ODM_CUT_VERSION_E */ + ODM_CMNINFO_FAB_VER, /* ODM_FAB_E */ + ODM_CMNINFO_RF_TYPE, /* ODM_RF_PATH_E or ODM_RF_TYPE_E? */ + ODM_CMNINFO_BOARD_TYPE, /* ODM_BOARD_TYPE_E */ + ODM_CMNINFO_EXT_LNA, /* true */ + ODM_CMNINFO_EXT_PA, + ODM_CMNINFO_EXT_TRSW, + ODM_CMNINFO_PATCH_ID, /* CUSTOMER ID */ + ODM_CMNINFO_BINHCT_TEST, + ODM_CMNINFO_BWIFI_TEST, + ODM_CMNINFO_SMART_CONCURRENT, + /* HOOK BEFORE REG INIT----------- */ + + /* Dynamic value: */ +/* POINTER REFERENCE----------- */ + ODM_CMNINFO_MAC_PHY_MODE, /* ODM_MAC_PHY_MODE_E */ + ODM_CMNINFO_TX_UNI, + ODM_CMNINFO_RX_UNI, + ODM_CMNINFO_WM_MODE, /* ODM_WIRELESS_MODE_E */ + ODM_CMNINFO_BAND, /* ODM_BAND_TYPE_E */ + ODM_CMNINFO_SEC_CHNL_OFFSET, /* ODM_SEC_CHNL_OFFSET_E */ + ODM_CMNINFO_SEC_MODE, /* ODM_SECURITY_E */ + ODM_CMNINFO_BW, /* ODM_BW_E */ + ODM_CMNINFO_CHNL, + + ODM_CMNINFO_DMSP_GET_VALUE, + ODM_CMNINFO_BUDDY_ADAPTOR, + ODM_CMNINFO_DMSP_IS_MASTER, + ODM_CMNINFO_SCAN, + ODM_CMNINFO_POWER_SAVING, + ODM_CMNINFO_ONE_PATH_CCA, /* ODM_CCA_PATH_E */ + ODM_CMNINFO_DRV_STOP, + ODM_CMNINFO_PNP_IN, + ODM_CMNINFO_INIT_ON, + ODM_CMNINFO_ANT_TEST, + ODM_CMNINFO_NET_CLOSED, + ODM_CMNINFO_MP_MODE, +/* POINTER REFERENCE----------- */ + +/* CALL BY VALUE------------- */ + ODM_CMNINFO_WIFI_DIRECT, + ODM_CMNINFO_WIFI_DISPLAY, + ODM_CMNINFO_LINK, + ODM_CMNINFO_RSSI_MIN, + ODM_CMNINFO_DBG_COMP, /* u64 */ + ODM_CMNINFO_DBG_LEVEL, /* u32 */ + ODM_CMNINFO_RA_THRESHOLD_HIGH, /* u8 */ + ODM_CMNINFO_RA_THRESHOLD_LOW, /* u8 */ + ODM_CMNINFO_RF_ANTENNA_TYPE, /* u8 */ + ODM_CMNINFO_BT_DISABLED, + ODM_CMNINFO_BT_OPERATION, + ODM_CMNINFO_BT_DIG, + ODM_CMNINFO_BT_BUSY, /* Check Bt is using or not */ + ODM_CMNINFO_BT_DISABLE_EDCA, +/* CALL BY VALUE-------------*/ + + /* Dynamic ptr array hook itms. */ + ODM_CMNINFO_STA_STATUS, + ODM_CMNINFO_PHY_STATUS, + ODM_CMNINFO_MAC_STATUS, + ODM_CMNINFO_MAX, +}; + +/* 2011/10/20 MH Define ODM support ability. ODM_CMNINFO_ABILITY */ + +enum odm_ability_def { + /* BB ODM section BIT 0-15 */ + ODM_BB_DIG = BIT0, + ODM_BB_RA_MASK = BIT1, + ODM_BB_DYNAMIC_TXPWR = BIT2, + ODM_BB_FA_CNT = BIT3, + ODM_BB_RSSI_MONITOR = BIT4, + ODM_BB_CCK_PD = BIT5, + ODM_BB_ANT_DIV = BIT6, + ODM_BB_PWR_SAVE = BIT7, + ODM_BB_PWR_TRA = BIT8, + ODM_BB_RATE_ADAPTIVE = BIT9, + ODM_BB_PATH_DIV = BIT10, + ODM_BB_PSD = BIT11, + ODM_BB_RXHP = BIT12, + + /* MAC DM section BIT 16-23 */ + ODM_MAC_EDCA_TURBO = BIT16, + ODM_MAC_EARLY_MODE = BIT17, + + /* RF ODM section BIT 24-31 */ + ODM_RF_TX_PWR_TRACK = BIT24, + ODM_RF_RX_GAIN_TRACK = BIT25, + ODM_RF_CALIBRATION = BIT26, +}; + +/* ODM_CMNINFO_INTERFACE */ +enum odm_interface_def { + ODM_ITRF_PCIE = 0x1, + ODM_ITRF_USB = 0x2, + ODM_ITRF_SDIO = 0x4, + ODM_ITRF_ALL = 0x7, +}; + +/* ODM_CMNINFO_IC_TYPE */ +enum odm_ic_type { + ODM_RTL8192S = BIT0, + ODM_RTL8192C = BIT1, + ODM_RTL8192D = BIT2, + ODM_RTL8723A = BIT3, + ODM_RTL8188E = BIT4, + ODM_RTL8812 = BIT5, + ODM_RTL8821 = BIT6, +}; + +#define ODM_IC_11N_SERIES \ + (ODM_RTL8192S | ODM_RTL8192C | ODM_RTL8192D | \ + ODM_RTL8723A | ODM_RTL8188E) +#define ODM_IC_11AC_SERIES (ODM_RTL8812) + +/* ODM_CMNINFO_CUT_VER */ +enum odm_cut_version { + ODM_CUT_A = 1, + ODM_CUT_B = 2, + ODM_CUT_C = 3, + ODM_CUT_D = 4, + ODM_CUT_E = 5, + ODM_CUT_F = 6, + ODM_CUT_TEST = 7, +}; + +/* ODM_CMNINFO_FAB_VER */ +enum odm_fab_Version { + ODM_TSMC = 0, + ODM_UMC = 1, +}; + +/* ODM_CMNINFO_RF_TYPE */ +/* For example 1T2R (A+AB = BIT0|BIT4|BIT5) */ +enum odm_rf_path { + ODM_RF_TX_A = BIT0, + ODM_RF_TX_B = BIT1, + ODM_RF_TX_C = BIT2, + ODM_RF_TX_D = BIT3, + ODM_RF_RX_A = BIT4, + ODM_RF_RX_B = BIT5, + ODM_RF_RX_C = BIT6, + ODM_RF_RX_D = BIT7, +}; + +enum odm_rf_type { + ODM_1T1R = 0, + ODM_1T2R = 1, + ODM_2T2R = 2, + ODM_2T3R = 3, + ODM_2T4R = 4, + ODM_3T3R = 5, + ODM_3T4R = 6, + ODM_4T4R = 7, +}; + +/* ODM Dynamic common info value definition */ + +enum odm_mac_phy_mode { + ODM_SMSP = 0, + ODM_DMSP = 1, + ODM_DMDP = 2, +}; + +enum odm_bt_coexist { + ODM_BT_BUSY = 1, + ODM_BT_ON = 2, + ODM_BT_OFF = 3, + ODM_BT_NONE = 4, +}; + +/* ODM_CMNINFO_OP_MODE */ +enum odm_operation_mode { + ODM_NO_LINK = BIT0, + ODM_LINK = BIT1, + ODM_SCAN = BIT2, + ODM_POWERSAVE = BIT3, + ODM_AP_MODE = BIT4, + ODM_CLIENT_MODE = BIT5, + ODM_AD_HOC = BIT6, + ODM_WIFI_DIRECT = BIT7, + ODM_WIFI_DISPLAY = BIT8, +}; + +/* ODM_CMNINFO_WM_MODE */ +enum odm_wireless_mode { + ODM_WM_UNKNOW = 0x0, + ODM_WM_B = BIT0, + ODM_WM_G = BIT1, + ODM_WM_A = BIT2, + ODM_WM_N24G = BIT3, + ODM_WM_N5G = BIT4, + ODM_WM_AUTO = BIT5, + ODM_WM_AC = BIT6, +}; + +/* ODM_CMNINFO_BAND */ +enum odm_band_type { + ODM_BAND_2_4G = BIT0, + ODM_BAND_5G = BIT1, +}; + +/* ODM_CMNINFO_SEC_CHNL_OFFSET */ +enum odm_sec_chnl_offset { + ODM_DONT_CARE = 0, + ODM_BELOW = 1, + ODM_ABOVE = 2 +}; + +/* ODM_CMNINFO_SEC_MODE */ +enum odm_security { + ODM_SEC_OPEN = 0, + ODM_SEC_WEP40 = 1, + ODM_SEC_TKIP = 2, + ODM_SEC_RESERVE = 3, + ODM_SEC_AESCCMP = 4, + ODM_SEC_WEP104 = 5, + ODM_WEP_WPA_MIXED = 6, /* WEP + WPA */ + ODM_SEC_SMS4 = 7, +}; + +/* ODM_CMNINFO_BW */ +enum odm_bw { + ODM_BW20M = 0, + ODM_BW40M = 1, + ODM_BW80M = 2, + ODM_BW160M = 3, + ODM_BW10M = 4, +}; + +/* ODM_CMNINFO_BOARD_TYPE */ +enum odm_board_type { + ODM_BOARD_NORMAL = 0, + ODM_BOARD_HIGHPWR = 1, + ODM_BOARD_MINICARD = 2, + ODM_BOARD_SLIM = 3, + ODM_BOARD_COMBO = 4, +}; + +/* ODM_CMNINFO_ONE_PATH_CCA */ +enum odm_cca_path { + ODM_CCA_2R = 0, + ODM_CCA_1R_A = 1, + ODM_CCA_1R_B = 2, +}; + +struct odm_ra_info { + u8 RateID; + u32 RateMask; + u32 RAUseRate; + u8 RateSGI; + u8 RssiStaRA; + u8 PreRssiStaRA; + u8 SGIEnable; + u8 DecisionRate; + u8 PreRate; + u8 HighestRate; + u8 LowestRate; + u32 NscUp; + u32 NscDown; + u16 RTY[5]; + u32 TOTAL; + u16 DROP; + u8 Active; + u16 RptTime; + u8 RAWaitingCounter; + u8 RAPendingCounter; + u8 PTActive; /* on or off */ + u8 PTTryState; /* 0 trying state, 1 for decision state */ + u8 PTStage; /* 0~6 */ + u8 PTStopCount; /* Stop PT counter */ + u8 PTPreRate; /* if rate change do PT */ + u8 PTPreRssi; /* if RSSI change 5% do PT */ + u8 PTModeSS; /* decide whitch rate should do PT */ + u8 RAstage; /* StageRA, decide how many times RA will be done + * between PT */ + u8 PTSmoothFactor; +}; + +struct ijk_matrix_regs_set { + bool bIQKDone; + s32 Value[1][IQK_Matrix_REG_NUM]; +}; + +struct odm_rf_cal { + /* for tx power tracking */ + u32 RegA24; /* for TempCCK */ + s32 RegE94; + s32 RegE9C; + s32 RegEB4; + s32 RegEBC; + + u8 TXPowercount; + bool bTXPowerTrackingInit; + bool bTXPowerTracking; + u8 TxPowerTrackControl; /* for mp mode, turn off txpwrtracking + * as default */ + u8 TM_Trigger; + u8 InternalPA5G[2]; /* pathA / pathB */ + + u8 ThermalMeter[2]; /* ThermalMeter, index 0 for RFIC0, + * and 1 for RFIC1 */ + u8 ThermalValue; + u8 ThermalValue_LCK; + u8 ThermalValue_IQK; + u8 ThermalValue_DPK; + u8 ThermalValue_AVG[AVG_THERMAL_NUM]; + u8 ThermalValue_AVG_index; + u8 ThermalValue_RxGain; + u8 ThermalValue_Crystal; + u8 ThermalValue_DPKstore; + u8 ThermalValue_DPKtrack; + bool TxPowerTrackingInProgress; + bool bDPKenable; + + bool bReloadtxpowerindex; + u8 bRfPiEnable; + u32 TXPowerTrackingCallbackCnt; /* cosa add for debug */ + + u8 bCCKinCH14; + u8 CCK_index; + u8 OFDM_index[2]; + bool bDoneTxpower; + + u8 ThermalValue_HP[HP_THERMAL_NUM]; + u8 ThermalValue_HP_index; + struct ijk_matrix_regs_set IQKMatrixRegSetting[IQK_Matrix_Settings_NUM]; + + u8 Delta_IQK; + u8 Delta_LCK; + + /* for IQK */ + u32 RegC04; + u32 Reg874; + u32 RegC08; + u32 RegB68; + u32 RegB6C; + u32 Reg870; + u32 Reg860; + u32 Reg864; + + bool bIQKInitialized; + bool bLCKInProgress; + bool bAntennaDetected; + u32 ADDA_backup[IQK_ADDA_REG_NUM]; + u32 IQK_MAC_backup[IQK_MAC_REG_NUM]; + u32 IQK_BB_backup_recover[9]; + u32 IQK_BB_backup[IQK_BB_REG_NUM]; + + /* for APK */ + u32 APKoutput[2][2]; /* path A/B; output1_1a/output1_2a */ + u8 bAPKdone; + u8 bAPKThermalMeterIgnore; + u8 bDPdone; + u8 bDPPathAOK; + u8 bDPPathBOK; +}; + +/* ODM Dynamic common info value definition */ + +struct fast_ant_train { + u8 Bssid[6]; + u8 antsel_rx_keep_0; + u8 antsel_rx_keep_1; + u8 antsel_rx_keep_2; + u32 antSumRSSI[7]; + u32 antRSSIcnt[7]; + u32 antAveRSSI[7]; + u8 FAT_State; + u32 TrainIdx; + u8 antsel_a[ODM_ASSOCIATE_ENTRY_NUM]; + u8 antsel_b[ODM_ASSOCIATE_ENTRY_NUM]; + u8 antsel_c[ODM_ASSOCIATE_ENTRY_NUM]; + u32 MainAnt_Sum[ODM_ASSOCIATE_ENTRY_NUM]; + u32 AuxAnt_Sum[ODM_ASSOCIATE_ENTRY_NUM]; + u32 MainAnt_Cnt[ODM_ASSOCIATE_ENTRY_NUM]; + u32 AuxAnt_Cnt[ODM_ASSOCIATE_ENTRY_NUM]; + u8 RxIdleAnt; + bool bBecomeLinked; +}; + +enum fat_state { + FAT_NORMAL_STATE = 0, + FAT_TRAINING_STATE = 1, +}; + +enum ant_div_type { + NO_ANTDIV = 0xFF, + CG_TRX_HW_ANTDIV = 0x01, + CGCS_RX_HW_ANTDIV = 0x02, + FIXED_HW_ANTDIV = 0x03, + CG_TRX_SMART_ANTDIV = 0x04, + CGCS_RX_SW_ANTDIV = 0x05, +}; + +/* Copy from SD4 defined structure. We use to support PHY DM integration. */ +struct odm_dm_struct { + /* Add for different team use temporarily */ + struct adapter *Adapter; /* For CE/NIC team */ + struct rtl8192cd_priv *priv; /* For AP/ADSL team */ + /* WHen you use above pointers, they must be initialized. */ + bool odm_ready; + + struct rtl8192cd_priv *fake_priv; + u64 DebugComponents; + u32 DebugLevel; + +/* ODM HANDLE, DRIVER NEEDS NOT TO HOOK------ */ + bool bCckHighPower; + u8 RFPathRxEnable; /* ODM_CMNINFO_RFPATH_ENABLE */ + u8 ControlChannel; +/* ODM HANDLE, DRIVER NEEDS NOT TO HOOK------ */ + +/* 1 COMMON INFORMATION */ + /* Init Value */ +/* HOOK BEFORE REG INIT----------- */ + /* ODM Platform info AP/ADSL/CE/MP = 1/2/3/4 */ + u8 SupportPlatform; + /* ODM Support Ability DIG/RATR/TX_PWR_TRACK/ ¡K¡K = 1/2/3/¡K */ + u32 SupportAbility; + /* ODM PCIE/USB/SDIO/GSPI = 0/1/2/3 */ + u8 SupportInterface; + /* ODM composite or independent. Bit oriented/ 92C+92D+ .... or any + * other type = 1/2/3/... */ + u32 SupportICType; + /* Cut Version TestChip/A-cut/B-cut... = 0/1/2/3/... */ + u8 CutVersion; + /* Fab Version TSMC/UMC = 0/1 */ + u8 FabVersion; + /* RF Type 4T4R/3T3R/2T2R/1T2R/1T1R/... */ + u8 RFType; + /* Board Type Normal/HighPower/MiniCard/SLIM/Combo/. = 0/1/2/3/4/. */ + u8 BoardType; + /* with external LNA NO/Yes = 0/1 */ + u8 ExtLNA; + /* with external PA NO/Yes = 0/1 */ + u8 ExtPA; + /* with external TRSW NO/Yes = 0/1 */ + u8 ExtTRSW; + u8 PatchID; /* Customer ID */ + bool bInHctTest; + bool bWIFITest; + + bool bDualMacSmartConcurrent; + u32 BK_SupportAbility; + u8 AntDivType; +/* HOOK BEFORE REG INIT----------- */ + + /* Dynamic Value */ +/* POINTER REFERENCE----------- */ + + u8 u8_temp; + bool bool_temp; + struct adapter *adapter_temp; + + /* MAC PHY Mode SMSP/DMSP/DMDP = 0/1/2 */ + u8 *pMacPhyMode; + /* TX Unicast byte count */ + u64 *pNumTxBytesUnicast; + /* RX Unicast byte count */ + u64 *pNumRxBytesUnicast; + /* Wireless mode B/G/A/N = BIT0/BIT1/BIT2/BIT3 */ + u8 *pWirelessMode; /* ODM_WIRELESS_MODE_E */ + /* Frequence band 2.4G/5G = 0/1 */ + u8 *pBandType; + /* Secondary channel offset don't_care/below/above = 0/1/2 */ + u8 *pSecChOffset; + /* Security mode Open/WEP/AES/TKIP = 0/1/2/3 */ + u8 *pSecurity; + /* BW info 20M/40M/80M = 0/1/2 */ + u8 *pBandWidth; + /* Central channel location Ch1/Ch2/.... */ + u8 *pChannel; /* central channel number */ + /* Common info for 92D DMSP */ + + bool *pbGetValueFromOtherMac; + struct adapter **pBuddyAdapter; + bool *pbMasterOfDMSP; /* MAC0: master, MAC1: slave */ + /* Common info for Status */ + bool *pbScanInProcess; + bool *pbPowerSaving; + /* CCA Path 2-path/path-A/path-B = 0/1/2; using ODM_CCA_PATH_E. */ + u8 *pOnePathCCA; + /* pMgntInfo->AntennaTest */ + u8 *pAntennaTest; + bool *pbNet_closed; +/* POINTER REFERENCE----------- */ + /* */ +/* CALL BY VALUE------------- */ + bool bWIFI_Direct; + bool bWIFI_Display; + bool bLinked; + u8 RSSI_Min; + u8 InterfaceIndex; /* Add for 92D dual MAC: 0--Mac0 1--Mac1 */ + bool bIsMPChip; + bool bOneEntryOnly; + /* Common info for BTDM */ + bool bBtDisabled; /* BT is disabled */ + bool bBtHsOperation; /* BT HS mode is under progress */ + u8 btHsDigVal; /* use BT rssi to decide the DIG value */ + bool bBtDisableEdcaTurbo;/* Under some condition, don't enable the + * EDCA Turbo */ + bool bBtBusy; /* BT is busy. */ +/* CALL BY VALUE------------- */ + + /* 2 Define STA info. */ + /* _ODM_STA_INFO */ + /* For MP, we need to reduce one array pointer for default port.?? */ + struct sta_info *pODM_StaInfo[ODM_ASSOCIATE_ENTRY_NUM]; + + u16 CurrminRptTime; + struct odm_ra_info RAInfo[ODM_ASSOCIATE_ENTRY_NUM]; /* Use MacID as + * array index. STA MacID=0, + * VWiFi Client MacID={1, ODM_ASSOCIATE_ENTRY_NUM-1} */ + /* */ + /* 2012/02/14 MH Add to share 88E ra with other SW team. */ + /* We need to colelct all support abilit to a proper area. */ + /* */ + bool RaSupport88E; + + /* Define ........... */ + + /* Latest packet phy info (ODM write) */ + struct odm_phy_dbg_info PhyDbgInfo; + + /* Latest packet phy info (ODM write) */ + struct odm_mac_status_info *pMacInfo; + + /* Different Team independt structure?? */ + + /* ODM Structure */ + struct fast_ant_train DM_FatTable; + struct rtw_dig DM_DigTable; + struct rtl_ps DM_PSTable; + struct dyn_primary_cca DM_PriCCA; + struct rx_hpc DM_RXHP_Table; + struct false_alarm_stats FalseAlmCnt; + struct false_alarm_stats FlaseAlmCntBuddyAdapter; + struct sw_ant_switch DM_SWAT_Table; + bool RSSI_test; + + struct edca_turbo DM_EDCA_Table; + u32 WMMEDCA_BE; + /* Copy from SD4 structure */ + /* */ + /* ================================================== */ + /* */ + + bool *pbDriverStopped; + bool *pbDriverIsGoingToPnpSetPowerSleep; + bool *pinit_adpt_in_progress; + + /* PSD */ + bool bUserAssignLevel; + struct timer_list PSDTimer; + u8 RSSI_BT; /* come from BT */ + bool bPSDinProcess; + bool bDMInitialGainEnable; + + /* for rate adaptive, in fact, 88c/92c fw will handle this */ + u8 bUseRAMask; + + struct odm_rate_adapt RateAdaptive; + + struct odm_rf_cal RFCalibrateInfo; + + /* TX power tracking */ + u8 BbSwingIdxOfdm; + u8 BbSwingIdxOfdmCurrent; + u8 BbSwingIdxOfdmBase; + bool BbSwingFlagOfdm; + u8 BbSwingIdxCck; + u8 BbSwingIdxCckCurrent; + u8 BbSwingIdxCckBase; + bool BbSwingFlagCck; + u8 *mp_mode; + /* ODM system resource. */ + + /* ODM relative time. */ + struct timer_list PathDivSwitchTimer; + /* 2011.09.27 add for Path Diversity */ + struct timer_list CCKPathDiversityTimer; + struct timer_list FastAntTrainingTimer; +}; /* DM_Dynamic_Mechanism_Structure */ + +#define ODM_RF_PATH_MAX 2 + +enum ODM_RF_RADIO_PATH { + ODM_RF_PATH_A = 0, /* Radio Path A */ + ODM_RF_PATH_B = 1, /* Radio Path B */ + ODM_RF_PATH_C = 2, /* Radio Path C */ + ODM_RF_PATH_D = 3, /* Radio Path D */ +}; + +enum ODM_RF_CONTENT { + odm_radioa_txt = 0x1000, + odm_radiob_txt = 0x1001, + odm_radioc_txt = 0x1002, + odm_radiod_txt = 0x1003 +}; + +enum odm_bb_config_type { + CONFIG_BB_PHY_REG, + CONFIG_BB_AGC_TAB, + CONFIG_BB_AGC_TAB_2G, + CONFIG_BB_AGC_TAB_5G, + CONFIG_BB_PHY_REG_PG, +}; + +/* Status code */ +enum rt_status { + RT_STATUS_SUCCESS, + RT_STATUS_FAILURE, + RT_STATUS_PENDING, + RT_STATUS_RESOURCE, + RT_STATUS_INVALID_CONTEXT, + RT_STATUS_INVALID_PARAMETER, + RT_STATUS_NOT_SUPPORT, + RT_STATUS_OS_API_FAILED, +}; + +/* 3=========================================================== */ +/* 3 DIG */ +/* 3=========================================================== */ + +enum dm_dig_op { + RT_TYPE_THRESH_HIGH = 0, + RT_TYPE_THRESH_LOW = 1, + RT_TYPE_BACKOFF = 2, + RT_TYPE_RX_GAIN_MIN = 3, + RT_TYPE_RX_GAIN_MAX = 4, + RT_TYPE_ENABLE = 5, + RT_TYPE_DISABLE = 6, + DIG_OP_TYPE_MAX +}; + +#define DM_DIG_THRESH_HIGH 40 +#define DM_DIG_THRESH_LOW 35 + +#define DM_SCAN_RSSI_TH 0x14 /* scan return issue for LC */ + + +#define DM_false_ALARM_THRESH_LOW 400 +#define DM_false_ALARM_THRESH_HIGH 1000 + +#define DM_DIG_MAX_NIC 0x3e +#define DM_DIG_MIN_NIC 0x1e /* 0x22/0x1c */ + +#define DM_DIG_MAX_AP 0x32 +#define DM_DIG_MIN_AP 0x20 + +#define DM_DIG_MAX_NIC_HP 0x46 +#define DM_DIG_MIN_NIC_HP 0x2e + +#define DM_DIG_MAX_AP_HP 0x42 +#define DM_DIG_MIN_AP_HP 0x30 + +/* vivi 92c&92d has different definition, 20110504 */ +/* this is for 92c */ +#define DM_DIG_FA_TH0 0x200/* 0x20 */ +#define DM_DIG_FA_TH1 0x300/* 0x100 */ +#define DM_DIG_FA_TH2 0x400/* 0x200 */ +/* this is for 92d */ +#define DM_DIG_FA_TH0_92D 0x100 +#define DM_DIG_FA_TH1_92D 0x400 +#define DM_DIG_FA_TH2_92D 0x600 + +#define DM_DIG_BACKOFF_MAX 12 +#define DM_DIG_BACKOFF_MIN -4 +#define DM_DIG_BACKOFF_DEFAULT 10 + +/* 3=========================================================== */ +/* 3 AGC RX High Power Mode */ +/* 3=========================================================== */ +#define LNA_Low_Gain_1 0x64 +#define LNA_Low_Gain_2 0x5A +#define LNA_Low_Gain_3 0x58 + +#define FA_RXHP_TH1 5000 +#define FA_RXHP_TH2 1500 +#define FA_RXHP_TH3 800 +#define FA_RXHP_TH4 600 +#define FA_RXHP_TH5 500 + +/* 3=========================================================== */ +/* 3 EDCA */ +/* 3=========================================================== */ + +/* 3=========================================================== */ +/* 3 Dynamic Tx Power */ +/* 3=========================================================== */ +/* Dynamic Tx Power Control Threshold */ +#define TX_POWER_NEAR_FIELD_THRESH_LVL2 74 +#define TX_POWER_NEAR_FIELD_THRESH_LVL1 67 +#define TX_POWER_NEAR_FIELD_THRESH_AP 0x3F + +#define TxHighPwrLevel_Normal 0 +#define TxHighPwrLevel_Level1 1 +#define TxHighPwrLevel_Level2 2 +#define TxHighPwrLevel_BT1 3 +#define TxHighPwrLevel_BT2 4 +#define TxHighPwrLevel_15 5 +#define TxHighPwrLevel_35 6 +#define TxHighPwrLevel_50 7 +#define TxHighPwrLevel_70 8 +#define TxHighPwrLevel_100 9 + +/* 3=========================================================== */ +/* 3 Rate Adaptive */ +/* 3=========================================================== */ +#define DM_RATR_STA_INIT 0 +#define DM_RATR_STA_HIGH 1 +#define DM_RATR_STA_MIDDLE 2 +#define DM_RATR_STA_LOW 3 + +/* 3=========================================================== */ +/* 3 BB Power Save */ +/* 3=========================================================== */ + + +enum dm_1r_cca { + CCA_1R = 0, + CCA_2R = 1, + CCA_MAX = 2, +}; + +enum dm_rf { + RF_Save = 0, + RF_Normal = 1, + RF_MAX = 2, +}; + +/* 3=========================================================== */ +/* 3 Antenna Diversity */ +/* 3=========================================================== */ +enum dm_swas { + Antenna_A = 1, + Antenna_B = 2, + Antenna_MAX = 3, +}; + +/* Maximal number of antenna detection mechanism needs to perform. */ +#define MAX_ANTENNA_DETECTION_CNT 10 + +/* Extern Global Variables. */ +#define OFDM_TABLE_SIZE_92C 37 +#define OFDM_TABLE_SIZE_92D 43 +#define CCK_TABLE_SIZE 33 + +extern u32 OFDMSwingTable[OFDM_TABLE_SIZE_92D]; +extern u8 CCKSwingTable_Ch1_Ch13[CCK_TABLE_SIZE][8]; +extern u8 CCKSwingTable_Ch14 [CCK_TABLE_SIZE][8]; + +/* check Sta pointer valid or not */ +#define IS_STA_VALID(pSta) (pSta) +/* 20100514 Joseph: Add definition for antenna switching test after link. */ +/* This indicates two different the steps. */ +/* In SWAW_STEP_PEAK, driver needs to switch antenna and listen to the + * signal on the air. */ +/* In SWAW_STEP_DETERMINE, driver just compares the signal captured in + * SWAW_STEP_PEAK */ +/* with original RSSI to determine if it is necessary to switch antenna. */ +#define SWAW_STEP_PEAK 0 +#define SWAW_STEP_DETERMINE 1 + +void ODM_Write_DIG(struct odm_dm_struct *pDM_Odm, u8 CurrentIGI); +void ODM_Write_CCK_CCA_Thres(struct odm_dm_struct *pDM_Odm, u8 CurCCK_CCAThres); + +void ODM_SetAntenna(struct odm_dm_struct *pDM_Odm, u8 Antenna); + + +#define dm_RF_Saving ODM_RF_Saving +void ODM_RF_Saving(struct odm_dm_struct *pDM_Odm, u8 bForceInNormal); + +#define SwAntDivRestAfterLink ODM_SwAntDivRestAfterLink +void ODM_SwAntDivRestAfterLink(struct odm_dm_struct *pDM_Odm); + +#define dm_CheckTXPowerTracking ODM_TXPowerTrackingCheck +void ODM_TXPowerTrackingCheck(struct odm_dm_struct *pDM_Odm); + +bool ODM_RAStateCheck(struct odm_dm_struct *pDM_Odm, s32 RSSI, + bool bForceUpdate, u8 *pRATRState); + +#define dm_SWAW_RSSI_Check ODM_SwAntDivChkPerPktRssi +void ODM_SwAntDivChkPerPktRssi(struct odm_dm_struct *pDM_Odm, u8 StationID, + struct odm_phy_status_info *pPhyInfo); + +u32 ConvertTo_dB(u32 Value); + +u32 GetPSDData(struct odm_dm_struct *pDM_Odm, unsigned int point, + u8 initial_gain_psd); + +void odm_DIGbyRSSI_LPS(struct odm_dm_struct *pDM_Odm); + +u32 ODM_Get_Rate_Bitmap(struct odm_dm_struct *pDM_Odm, u32 macid, + u32 ra_mask, u8 rssi_level); + +void ODM_DMInit(struct odm_dm_struct *pDM_Odm); + +void ODM_DMWatchdog(struct odm_dm_struct *pDM_Odm); + +void ODM_CmnInfoInit(struct odm_dm_struct *pDM_Odm, + enum odm_common_info_def CmnInfo, u32 Value); + +void ODM_CmnInfoHook(struct odm_dm_struct *pDM_Odm, + enum odm_common_info_def CmnInfo, void *pValue); + +void ODM_CmnInfoPtrArrayHook(struct odm_dm_struct *pDM_Odm, + enum odm_common_info_def CmnInfo, + u16 Index, void *pValue); + +void ODM_CmnInfoUpdate(struct odm_dm_struct *pDM_Odm, u32 CmnInfo, u64 Value); + +void ODM_InitAllTimers(struct odm_dm_struct *pDM_Odm); + +void ODM_CancelAllTimers(struct odm_dm_struct *pDM_Odm); + +void ODM_ReleaseAllTimers(struct odm_dm_struct *pDM_Odm); + +void ODM_ResetIQKResult(struct odm_dm_struct *pDM_Odm); + +void ODM_AntselStatistics_88C(struct odm_dm_struct *pDM_Odm, u8 MacId, + u32 PWDBAll, bool isCCKrate); + +void ODM_SingleDualAntennaDefaultSetting(struct odm_dm_struct *pDM_Odm); + +bool ODM_SingleDualAntennaDetection(struct odm_dm_struct *pDM_Odm, u8 mode); + +void odm_dtc(struct odm_dm_struct *pDM_Odm); + +#endif diff --git a/drivers/staging/rtl8188eu/include/odm_HWConfig.h b/drivers/staging/rtl8188eu/include/odm_HWConfig.h new file mode 100644 index 0000000000000..63779f5b2a3c1 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/odm_HWConfig.h @@ -0,0 +1,132 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#ifndef __HALHWOUTSRC_H__ +#define __HALHWOUTSRC_H__ + +/* Definition */ +/* CCK Rates, TxHT = 0 */ +#define DESC92C_RATE1M 0x00 +#define DESC92C_RATE2M 0x01 +#define DESC92C_RATE5_5M 0x02 +#define DESC92C_RATE11M 0x03 + +/* OFDM Rates, TxHT = 0 */ +#define DESC92C_RATE6M 0x04 +#define DESC92C_RATE9M 0x05 +#define DESC92C_RATE12M 0x06 +#define DESC92C_RATE18M 0x07 +#define DESC92C_RATE24M 0x08 +#define DESC92C_RATE36M 0x09 +#define DESC92C_RATE48M 0x0a +#define DESC92C_RATE54M 0x0b + +/* MCS Rates, TxHT = 1 */ +#define DESC92C_RATEMCS0 0x0c +#define DESC92C_RATEMCS1 0x0d +#define DESC92C_RATEMCS2 0x0e +#define DESC92C_RATEMCS3 0x0f +#define DESC92C_RATEMCS4 0x10 +#define DESC92C_RATEMCS5 0x11 +#define DESC92C_RATEMCS6 0x12 +#define DESC92C_RATEMCS7 0x13 +#define DESC92C_RATEMCS8 0x14 +#define DESC92C_RATEMCS9 0x15 +#define DESC92C_RATEMCS10 0x16 +#define DESC92C_RATEMCS11 0x17 +#define DESC92C_RATEMCS12 0x18 +#define DESC92C_RATEMCS13 0x19 +#define DESC92C_RATEMCS14 0x1a +#define DESC92C_RATEMCS15 0x1b +#define DESC92C_RATEMCS15_SG 0x1c +#define DESC92C_RATEMCS32 0x20 + +/* structure and define */ + +struct phy_rx_agc_info { + #ifdef __LITTLE_ENDIAN + u8 gain:7, trsw:1; + #else + u8 trsw:1, gain:7; + #endif +}; + +struct phy_status_rpt { + struct phy_rx_agc_info path_agc[2]; + u8 ch_corr[2]; + u8 cck_sig_qual_ofdm_pwdb_all; + u8 cck_agc_rpt_ofdm_cfosho_a; + u8 cck_rpt_b_ofdm_cfosho_b; + u8 rsvd_1;/* ch_corr_msb; */ + u8 noise_power_db_msb; + u8 path_cfotail[2]; + u8 pcts_mask[2]; + s8 stream_rxevm[2]; + u8 path_rxsnr[2]; + u8 noise_power_db_lsb; + u8 rsvd_2[3]; + u8 stream_csi[2]; + u8 stream_target_csi[2]; + s8 sig_evm; + u8 rsvd_3; + +#ifdef __LITTLE_ENDIAN + u8 antsel_rx_keep_2:1; /* ex_intf_flg:1; */ + u8 sgi_en:1; + u8 rxsc:2; + u8 idle_long:1; + u8 r_ant_train_en:1; + u8 ant_sel_b:1; + u8 ant_sel:1; +#else /* _BIG_ENDIAN_ */ + u8 ant_sel:1; + u8 ant_sel_b:1; + u8 r_ant_train_en:1; + u8 idle_long:1; + u8 rxsc:2; + u8 sgi_en:1; + u8 antsel_rx_keep_2:1; /* ex_intf_flg:1; */ +#endif +}; + +void odm_Init_RSSIForDM(struct odm_dm_struct *pDM_Odm); + +void ODM_PhyStatusQuery(struct odm_dm_struct *pDM_Odm, + struct odm_phy_status_info *pPhyInfo, + u8 *pPhyStatus, + struct odm_per_pkt_info *pPktinfo); + +void ODM_MacStatusQuery(struct odm_dm_struct *pDM_Odm, + u8 *pMacStatus, + u8 MacID, + bool bPacketMatchBSSID, + bool bPacketToSelf, + bool bPacketBeacon); + +enum HAL_STATUS ODM_ConfigRFWithHeaderFile(struct odm_dm_struct *pDM_Odm, + enum ODM_RF_RADIO_PATH Content, + enum ODM_RF_RADIO_PATH eRFPath); + +enum HAL_STATUS ODM_ConfigBBWithHeaderFile(struct odm_dm_struct *pDM_Odm, + enum odm_bb_config_type ConfigType); + +enum HAL_STATUS ODM_ConfigMACWithHeaderFile(struct odm_dm_struct *pDM_Odm); + +#endif diff --git a/drivers/staging/rtl8188eu/include/odm_RTL8188E.h b/drivers/staging/rtl8188eu/include/odm_RTL8188E.h new file mode 100644 index 0000000000000..f96ad5af4bd5a --- /dev/null +++ b/drivers/staging/rtl8188eu/include/odm_RTL8188E.h @@ -0,0 +1,56 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __ODM_RTL8188E_H__ +#define __ODM_RTL8188E_H__ + +#define MAIN_ANT 0 +#define AUX_ANT 1 +#define MAIN_ANT_CG_TRX 1 +#define AUX_ANT_CG_TRX 0 +#define MAIN_ANT_CGCS_RX 0 +#define AUX_ANT_CGCS_RX 1 + +void ODM_DIG_LowerBound_88E(struct odm_dm_struct *pDM_Odm); + +void ODM_AntennaDiversityInit_88E(struct odm_dm_struct *pDM_Odm); + +void ODM_AntennaDiversity_88E(struct odm_dm_struct *pDM_Odm); + +void ODM_SetTxAntByTxInfo_88E(struct odm_dm_struct *pDM_Odm, u8 *pDesc, + u8 macId); + +void ODM_UpdateRxIdleAnt_88E(struct odm_dm_struct *pDM_Odm, u8 Ant); + +void ODM_AntselStatistics_88E(struct odm_dm_struct *pDM_Odm, u8 antsel_tr_mux, + u32 MacId, u8 RxPWDBAll); + +void odm_FastAntTraining(struct odm_dm_struct *pDM_Odm); + +void odm_FastAntTrainingCallback(struct odm_dm_struct *pDM_Odm); + +void odm_FastAntTrainingWorkItemCallback(struct odm_dm_struct *pDM_Odm); + +void odm_PrimaryCCA_Init(struct odm_dm_struct *pDM_Odm); + +bool ODM_DynamicPrimaryCCA_DupRTS(struct odm_dm_struct *pDM_Odm); + +void odm_DynamicPrimaryCCA(struct odm_dm_struct *pDM_Odm); + +#endif diff --git a/drivers/staging/rtl8188eu/include/odm_RegConfig8188E.h b/drivers/staging/rtl8188eu/include/odm_RegConfig8188E.h new file mode 100644 index 0000000000000..727e6b26fb086 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/odm_RegConfig8188E.h @@ -0,0 +1,43 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __INC_ODM_REGCONFIG_H_8188E +#define __INC_ODM_REGCONFIG_H_8188E + +void odm_ConfigRFReg_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u32 Data, + enum ODM_RF_RADIO_PATH RF_PATH, u32 RegAddr); + +void odm_ConfigRF_RadioA_8188E(struct odm_dm_struct *pDM_Odm, + u32 Addr, u32 Data); + +void odm_ConfigRF_RadioB_8188E(struct odm_dm_struct *pDM_Odm, + u32 Addr, u32 Data); + +void odm_ConfigMAC_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u8 Data); + +void odm_ConfigBB_AGC_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, + u32 Bitmask, u32 Data); + +void odm_ConfigBB_PHY_REG_PG_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, + u32 Bitmask, u32 Data); + +void odm_ConfigBB_PHY_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, + u32 Bitmask, u32 Data); + +#endif diff --git a/drivers/staging/rtl8188eu/include/odm_RegDefine11AC.h b/drivers/staging/rtl8188eu/include/odm_RegDefine11AC.h new file mode 100644 index 0000000000000..f08775c0dd8e4 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/odm_RegDefine11AC.h @@ -0,0 +1,54 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#ifndef __ODM_REGDEFINE11AC_H__ +#define __ODM_REGDEFINE11AC_H__ + +/* 2 RF REG LIST */ + + + +/* 2 BB REG LIST */ +/* PAGE 8 */ +/* PAGE 9 */ +#define ODM_REG_OFDM_FA_RST_11AC 0x9A4 +/* PAGE A */ +#define ODM_REG_CCK_CCA_11AC 0xA0A +#define ODM_REG_CCK_FA_RST_11AC 0xA2C +#define ODM_REG_CCK_FA_11AC 0xA5C +/* PAGE C */ +#define ODM_REG_IGI_A_11AC 0xC50 +/* PAGE E */ +#define ODM_REG_IGI_B_11AC 0xE50 +/* PAGE F */ +#define ODM_REG_OFDM_FA_11AC 0xF48 + + +/* 2 MAC REG LIST */ + + + + +/* DIG Related */ +#define ODM_BIT_IGI_11AC 0xFFFFFFFF + + + +#endif diff --git a/drivers/staging/rtl8188eu/include/odm_RegDefine11N.h b/drivers/staging/rtl8188eu/include/odm_RegDefine11N.h new file mode 100644 index 0000000000000..5a61f902bc1b8 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/odm_RegDefine11N.h @@ -0,0 +1,171 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#ifndef __ODM_REGDEFINE11N_H__ +#define __ODM_REGDEFINE11N_H__ + + +/* 2 RF REG LIST */ +#define ODM_REG_RF_MODE_11N 0x00 +#define ODM_REG_RF_0B_11N 0x0B +#define ODM_REG_CHNBW_11N 0x18 +#define ODM_REG_T_METER_11N 0x24 +#define ODM_REG_RF_25_11N 0x25 +#define ODM_REG_RF_26_11N 0x26 +#define ODM_REG_RF_27_11N 0x27 +#define ODM_REG_RF_2B_11N 0x2B +#define ODM_REG_RF_2C_11N 0x2C +#define ODM_REG_RXRF_A3_11N 0x3C +#define ODM_REG_T_METER_92D_11N 0x42 +#define ODM_REG_T_METER_88E_11N 0x42 + + + +/* 2 BB REG LIST */ +/* PAGE 8 */ +#define ODM_REG_BB_CTRL_11N 0x800 +#define ODM_REG_RF_PIN_11N 0x804 +#define ODM_REG_PSD_CTRL_11N 0x808 +#define ODM_REG_TX_ANT_CTRL_11N 0x80C +#define ODM_REG_BB_PWR_SAV5_11N 0x818 +#define ODM_REG_CCK_RPT_FORMAT_11N 0x824 +#define ODM_REG_RX_DEFUALT_A_11N 0x858 +#define ODM_REG_RX_DEFUALT_B_11N 0x85A +#define ODM_REG_BB_PWR_SAV3_11N 0x85C +#define ODM_REG_ANTSEL_CTRL_11N 0x860 +#define ODM_REG_RX_ANT_CTRL_11N 0x864 +#define ODM_REG_PIN_CTRL_11N 0x870 +#define ODM_REG_BB_PWR_SAV1_11N 0x874 +#define ODM_REG_ANTSEL_PATH_11N 0x878 +#define ODM_REG_BB_3WIRE_11N 0x88C +#define ODM_REG_SC_CNT_11N 0x8C4 +#define ODM_REG_PSD_DATA_11N 0x8B4 +/* PAGE 9 */ +#define ODM_REG_ANT_MAPPING1_11N 0x914 +#define ODM_REG_ANT_MAPPING2_11N 0x918 +/* PAGE A */ +#define ODM_REG_CCK_ANTDIV_PARA1_11N 0xA00 +#define ODM_REG_CCK_CCA_11N 0xA0A +#define ODM_REG_CCK_ANTDIV_PARA2_11N 0xA0C +#define ODM_REG_CCK_ANTDIV_PARA3_11N 0xA10 +#define ODM_REG_CCK_ANTDIV_PARA4_11N 0xA14 +#define ODM_REG_CCK_FILTER_PARA1_11N 0xA22 +#define ODM_REG_CCK_FILTER_PARA2_11N 0xA23 +#define ODM_REG_CCK_FILTER_PARA3_11N 0xA24 +#define ODM_REG_CCK_FILTER_PARA4_11N 0xA25 +#define ODM_REG_CCK_FILTER_PARA5_11N 0xA26 +#define ODM_REG_CCK_FILTER_PARA6_11N 0xA27 +#define ODM_REG_CCK_FILTER_PARA7_11N 0xA28 +#define ODM_REG_CCK_FILTER_PARA8_11N 0xA29 +#define ODM_REG_CCK_FA_RST_11N 0xA2C +#define ODM_REG_CCK_FA_MSB_11N 0xA58 +#define ODM_REG_CCK_FA_LSB_11N 0xA5C +#define ODM_REG_CCK_CCA_CNT_11N 0xA60 +#define ODM_REG_BB_PWR_SAV4_11N 0xA74 +/* PAGE B */ +#define ODM_REG_LNA_SWITCH_11N 0xB2C +#define ODM_REG_PATH_SWITCH_11N 0xB30 +#define ODM_REG_RSSI_CTRL_11N 0xB38 +#define ODM_REG_CONFIG_ANTA_11N 0xB68 +#define ODM_REG_RSSI_BT_11N 0xB9C +/* PAGE C */ +#define ODM_REG_OFDM_FA_HOLDC_11N 0xC00 +#define ODM_REG_RX_PATH_11N 0xC04 +#define ODM_REG_TRMUX_11N 0xC08 +#define ODM_REG_OFDM_FA_RSTC_11N 0xC0C +#define ODM_REG_RXIQI_MATRIX_11N 0xC14 +#define ODM_REG_TXIQK_MATRIX_LSB1_11N 0xC4C +#define ODM_REG_IGI_A_11N 0xC50 +#define ODM_REG_ANTDIV_PARA2_11N 0xC54 +#define ODM_REG_IGI_B_11N 0xC58 +#define ODM_REG_ANTDIV_PARA3_11N 0xC5C +#define ODM_REG_BB_PWR_SAV2_11N 0xC70 +#define ODM_REG_RX_OFF_11N 0xC7C +#define ODM_REG_TXIQK_MATRIXA_11N 0xC80 +#define ODM_REG_TXIQK_MATRIXB_11N 0xC88 +#define ODM_REG_TXIQK_MATRIXA_LSB2_11N 0xC94 +#define ODM_REG_TXIQK_MATRIXB_LSB2_11N 0xC9C +#define ODM_REG_RXIQK_MATRIX_LSB_11N 0xCA0 +#define ODM_REG_ANTDIV_PARA1_11N 0xCA4 +#define ODM_REG_OFDM_FA_TYPE1_11N 0xCF0 +/* PAGE D */ +#define ODM_REG_OFDM_FA_RSTD_11N 0xD00 +#define ODM_REG_OFDM_FA_TYPE2_11N 0xDA0 +#define ODM_REG_OFDM_FA_TYPE3_11N 0xDA4 +#define ODM_REG_OFDM_FA_TYPE4_11N 0xDA8 +/* PAGE E */ +#define ODM_REG_TXAGC_A_6_18_11N 0xE00 +#define ODM_REG_TXAGC_A_24_54_11N 0xE04 +#define ODM_REG_TXAGC_A_1_MCS32_11N 0xE08 +#define ODM_REG_TXAGC_A_MCS0_3_11N 0xE10 +#define ODM_REG_TXAGC_A_MCS4_7_11N 0xE14 +#define ODM_REG_TXAGC_A_MCS8_11_11N 0xE18 +#define ODM_REG_TXAGC_A_MCS12_15_11N 0xE1C +#define ODM_REG_FPGA0_IQK_11N 0xE28 +#define ODM_REG_TXIQK_TONE_A_11N 0xE30 +#define ODM_REG_RXIQK_TONE_A_11N 0xE34 +#define ODM_REG_TXIQK_PI_A_11N 0xE38 +#define ODM_REG_RXIQK_PI_A_11N 0xE3C +#define ODM_REG_TXIQK_11N 0xE40 +#define ODM_REG_RXIQK_11N 0xE44 +#define ODM_REG_IQK_AGC_PTS_11N 0xE48 +#define ODM_REG_IQK_AGC_RSP_11N 0xE4C +#define ODM_REG_BLUETOOTH_11N 0xE6C +#define ODM_REG_RX_WAIT_CCA_11N 0xE70 +#define ODM_REG_TX_CCK_RFON_11N 0xE74 +#define ODM_REG_TX_CCK_BBON_11N 0xE78 +#define ODM_REG_OFDM_RFON_11N 0xE7C +#define ODM_REG_OFDM_BBON_11N 0xE80 +#define ODM_REG_TX2RX_11N 0xE84 +#define ODM_REG_TX2TX_11N 0xE88 +#define ODM_REG_RX_CCK_11N 0xE8C +#define ODM_REG_RX_OFDM_11N 0xED0 +#define ODM_REG_RX_WAIT_RIFS_11N 0xED4 +#define ODM_REG_RX2RX_11N 0xED8 +#define ODM_REG_STANDBY_11N 0xEDC +#define ODM_REG_SLEEP_11N 0xEE0 +#define ODM_REG_PMPD_ANAEN_11N 0xEEC + + + + + + + +/* 2 MAC REG LIST */ +#define ODM_REG_BB_RST_11N 0x02 +#define ODM_REG_ANTSEL_PIN_11N 0x4C +#define ODM_REG_EARLY_MODE_11N 0x4D0 +#define ODM_REG_RSSI_MONITOR_11N 0x4FE +#define ODM_REG_EDCA_VO_11N 0x500 +#define ODM_REG_EDCA_VI_11N 0x504 +#define ODM_REG_EDCA_BE_11N 0x508 +#define ODM_REG_EDCA_BK_11N 0x50C +#define ODM_REG_TXPAUSE_11N 0x522 +#define ODM_REG_RESP_TX_11N 0x6D8 +#define ODM_REG_ANT_TRAIN_PARA1_11N 0x7b0 +#define ODM_REG_ANT_TRAIN_PARA2_11N 0x7b4 + + +/* DIG Related */ +#define ODM_BIT_IGI_11N 0x0000007F + + +#endif diff --git a/drivers/staging/rtl8188eu/include/odm_debug.h b/drivers/staging/rtl8188eu/include/odm_debug.h new file mode 100644 index 0000000000000..a9ba6df26b9dc --- /dev/null +++ b/drivers/staging/rtl8188eu/include/odm_debug.h @@ -0,0 +1,145 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + + +#ifndef __ODM_DBG_H__ +#define __ODM_DBG_H__ + + +/* */ +/* Define the debug levels */ +/* */ +/* 1. DBG_TRACE and DBG_LOUD are used for normal cases. */ +/* They can help SW engineer to develope or trace states changed */ +/* and also help HW enginner to trace every operation to and from HW, */ +/* e.g IO, Tx, Rx. */ +/* */ +/* 2. DBG_WARNNING and DBG_SERIOUS are used for unusual or error cases, */ +/* which help us to debug SW or HW. */ + +/* Never used in a call to ODM_RT_TRACE()! */ +#define ODM_DBG_OFF 1 + +/* Fatal bug. */ +/* For example, Tx/Rx/IO locked up, OS hangs, memory access violation, */ +/* resource allocation failed, unexpected HW behavior, HW BUG and so on. */ +#define ODM_DBG_SERIOUS 2 + +/* Abnormal, rare, or unexpeted cases. */ +/* For example, IRP/Packet/OID canceled, device suprisely unremoved and so on. */ +#define ODM_DBG_WARNING 3 + +/* Normal case with useful information about current SW or HW state. */ +/* For example, Tx/Rx descriptor to fill, Tx/Rx descr. completed status, */ +/* SW protocol state change, dynamic mechanism state change and so on. */ +/* */ +#define ODM_DBG_LOUD 4 + +/* Normal case with detail execution flow or information. */ +#define ODM_DBG_TRACE 5 + +/* Define the tracing components */ +/* BB Functions */ +#define ODM_COMP_DIG BIT0 +#define ODM_COMP_RA_MASK BIT1 +#define ODM_COMP_DYNAMIC_TXPWR BIT2 +#define ODM_COMP_FA_CNT BIT3 +#define ODM_COMP_RSSI_MONITOR BIT4 +#define ODM_COMP_CCK_PD BIT5 +#define ODM_COMP_ANT_DIV BIT6 +#define ODM_COMP_PWR_SAVE BIT7 +#define ODM_COMP_PWR_TRA BIT8 +#define ODM_COMP_RATE_ADAPTIVE BIT9 +#define ODM_COMP_PATH_DIV BIT10 +#define ODM_COMP_PSD BIT11 +#define ODM_COMP_DYNAMIC_PRICCA BIT12 +#define ODM_COMP_RXHP BIT13 +/* MAC Functions */ +#define ODM_COMP_EDCA_TURBO BIT16 +#define ODM_COMP_EARLY_MODE BIT17 +/* RF Functions */ +#define ODM_COMP_TX_PWR_TRACK BIT24 +#define ODM_COMP_RX_GAIN_TRACK BIT25 +#define ODM_COMP_CALIBRATION BIT26 +/* Common Functions */ +#define ODM_COMP_COMMON BIT30 +#define ODM_COMP_INIT BIT31 + +/*------------------------Export Marco Definition---------------------------*/ +#define DbgPrint pr_info +#define RT_PRINTK(fmt, args...) \ + DbgPrint( "%s(): " fmt, __func__, ## args); + +#ifndef ASSERT + #define ASSERT(expr) +#endif + +#define ODM_RT_TRACE(pDM_Odm, comp, level, fmt) \ + if (((comp) & pDM_Odm->DebugComponents) && \ + (level <= pDM_Odm->DebugLevel)) { \ + if (pDM_Odm->SupportICType == ODM_RTL8192C) \ + DbgPrint("[ODM-92C] "); \ + else if (pDM_Odm->SupportICType == ODM_RTL8192D) \ + DbgPrint("[ODM-92D] "); \ + else if (pDM_Odm->SupportICType == ODM_RTL8723A) \ + DbgPrint("[ODM-8723A] "); \ + else if (pDM_Odm->SupportICType == ODM_RTL8188E) \ + DbgPrint("[ODM-8188E] "); \ + else if (pDM_Odm->SupportICType == ODM_RTL8812) \ + DbgPrint("[ODM-8812] "); \ + else if (pDM_Odm->SupportICType == ODM_RTL8821) \ + DbgPrint("[ODM-8821] "); \ + RT_PRINTK fmt; \ + } + +#define ODM_RT_TRACE_F(pDM_Odm, comp, level, fmt) \ + if (((comp) & pDM_Odm->DebugComponents) && \ + (level <= pDM_Odm->DebugLevel)) { \ + RT_PRINTK fmt; \ + } + +#define ODM_RT_ASSERT(pDM_Odm, expr, fmt) \ + if (!(expr)) { \ + DbgPrint( "Assertion failed! %s at ......\n", #expr); \ + DbgPrint( " ......%s,%s,line=%d\n", __FILE__, \ + __func__, __LINE__); \ + RT_PRINTK fmt; \ + ASSERT(false); \ + } +#define ODM_dbg_enter() { DbgPrint("==> %s\n", __func__); } +#define ODM_dbg_exit() { DbgPrint("<== %s\n", __func__); } +#define ODM_dbg_trace(str) { DbgPrint("%s:%s\n", __func__, str); } + +#define ODM_PRINT_ADDR(pDM_Odm, comp, level, title_str, ptr) \ + if (((comp) & pDM_Odm->DebugComponents) && \ + (level <= pDM_Odm->DebugLevel)) { \ + int __i; \ + u8 *__ptr = (u8 *)ptr; \ + DbgPrint("[ODM] "); \ + DbgPrint(title_str); \ + DbgPrint(" "); \ + for (__i = 0; __i < 6; __i++) \ + DbgPrint("%02X%s", __ptr[__i], (__i==5)?"":"-");\ + DbgPrint("\n"); \ + } + +void ODM_InitDebugSetting(struct odm_dm_struct *pDM_Odm); + +#endif /* __ODM_DBG_H__ */ diff --git a/drivers/staging/rtl8188eu/include/odm_interface.h b/drivers/staging/rtl8188eu/include/odm_interface.h new file mode 100644 index 0000000000000..e5c8704ac0104 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/odm_interface.h @@ -0,0 +1,164 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#ifndef __ODM_INTERFACE_H__ +#define __ODM_INTERFACE_H__ + +/* */ +/* =========== Constant/Structure/Enum/... Define */ +/* */ + +/* */ +/* =========== Macro Define */ +/* */ + +#define _reg_all(_name) ODM_##_name +#define _reg_ic(_name, _ic) ODM_##_name##_ic +#define _bit_all(_name) BIT_##_name +#define _bit_ic(_name, _ic) BIT_##_name##_ic + +/* _cat: implemented by Token-Pasting Operator. */ + +/*=================================== + +#define ODM_REG_DIG_11N 0xC50 +#define ODM_REG_DIG_11AC 0xDDD + +ODM_REG(DIG,_pDM_Odm) +=====================================*/ + +#define _reg_11N(_name) ODM_REG_##_name##_11N +#define _reg_11AC(_name) ODM_REG_##_name##_11AC +#define _bit_11N(_name) ODM_BIT_##_name##_11N +#define _bit_11AC(_name) ODM_BIT_##_name##_11AC + +#define _cat(_name, _ic_type, _func) \ + ( \ + ((_ic_type) & ODM_IC_11N_SERIES) ? _func##_11N(_name) : \ + _func##_11AC(_name) \ + ) + +/* _name: name of register or bit. */ +/* Example: "ODM_REG(R_A_AGC_CORE1, pDM_Odm)" */ +/* gets "ODM_R_A_AGC_CORE1" or "ODM_R_A_AGC_CORE1_8192C", + * depends on SupportICType. */ +#define ODM_REG(_name, _pDM_Odm) _cat(_name, _pDM_Odm->SupportICType, _reg) +#define ODM_BIT(_name, _pDM_Odm) _cat(_name, _pDM_Odm->SupportICType, _bit) + +enum odm_h2c_cmd { + ODM_H2C_RSSI_REPORT = 0, + ODM_H2C_PSD_RESULT= 1, + ODM_H2C_PathDiv = 2, + ODM_MAX_H2CCMD +}; + +/* 2012/02/17 MH For non-MP compile pass only. Linux does not support workitem. */ +/* Suggest HW team to use thread instead of workitem. Windows also support the feature. */ +typedef void (*RT_WORKITEM_CALL_BACK)(void *pContext); + +/* =========== Extern Variable ??? It should be forbidden. */ + +/* =========== EXtern Function Prototype */ + +u8 ODM_Read1Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr); + +u16 ODM_Read2Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr); + +u32 ODM_Read4Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr); + +void ODM_Write1Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u8 Data); + +void ODM_Write2Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u16 Data); + +void ODM_Write4Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u32 Data); + +void ODM_SetMACReg(struct odm_dm_struct *pDM_Odm, u32 RegAddr, + u32 BitMask, u32 Data); + +u32 ODM_GetMACReg(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u32 BitMask); + +void ODM_SetBBReg(struct odm_dm_struct *pDM_Odm, u32 RegAddr, + u32 BitMask, u32 Data); + +u32 ODM_GetBBReg(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u32 BitMask); + +void ODM_SetRFReg(struct odm_dm_struct *pDM_Odm, enum ODM_RF_RADIO_PATH eRFPath, + u32 RegAddr, u32 BitMask, u32 Data); + +u32 ODM_GetRFReg(struct odm_dm_struct *pDM_Odm, enum ODM_RF_RADIO_PATH eRFPath, + u32 RegAddr, u32 BitMask); + +/* Memory Relative Function. */ +void ODM_AllocateMemory(struct odm_dm_struct *pDM_Odm, void **pPtr, u32 length); +void ODM_FreeMemory(struct odm_dm_struct *pDM_Odm, void *pPtr, u32 length); + +s32 ODM_CompareMemory(struct odm_dm_struct *pDM_Odm, void *pBuf1, void *pBuf2, + u32 length); + +/* ODM MISC-spin lock relative API. */ +void ODM_AcquireSpinLock(struct odm_dm_struct *pDM_Odm, + enum RT_SPINLOCK_TYPE type); + +void ODM_ReleaseSpinLock(struct odm_dm_struct *pDM_Odm, + enum RT_SPINLOCK_TYPE type); + +/* ODM MISC-workitem relative API. */ +void ODM_InitializeWorkItem(struct odm_dm_struct *pDM_Odm, void *pRtWorkItem, + RT_WORKITEM_CALL_BACK RtWorkItemCallback, + void *pContext, const char *szID); + +void ODM_StartWorkItem(void *pRtWorkItem); + +void ODM_StopWorkItem(void *pRtWorkItem); + +void ODM_FreeWorkItem(void *pRtWorkItem); + +void ODM_ScheduleWorkItem(void *pRtWorkItem); + +void ODM_IsWorkItemScheduled(void *pRtWorkItem); + +/* ODM Timer relative API. */ +void ODM_StallExecution(u32 usDelay); + +void ODM_delay_ms(u32 ms); + +void ODM_delay_us(u32 us); + +void ODM_sleep_ms(u32 ms); + +void ODM_sleep_us(u32 us); + +void ODM_SetTimer(struct odm_dm_struct *pDM_Odm, struct timer_list *pTimer, + u32 msDelay); + +void ODM_InitializeTimer(struct odm_dm_struct *pDM_Odm, + struct timer_list *pTimer, void *CallBackFunc, + void *pContext, const char *szID); + +void ODM_CancelTimer(struct odm_dm_struct *pDM_Odm, struct timer_list *pTimer); + +void ODM_ReleaseTimer(struct odm_dm_struct *pDM_Odm, struct timer_list *pTimer); + +/* ODM FW relative API. */ +u32 ODM_FillH2CCmd(u8 *pH2CBuffer, u32 H2CBufferLen, u32 CmdNum, + u32 *pElementID, u32 *pCmdLen, u8 **pCmbBuffer, + u8 *CmdStartSeq); + +#endif /* __ODM_INTERFACE_H__ */ diff --git a/drivers/staging/rtl8188eu/include/odm_precomp.h b/drivers/staging/rtl8188eu/include/odm_precomp.h new file mode 100644 index 0000000000000..520cbbaac35f8 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/odm_precomp.h @@ -0,0 +1,104 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#ifndef __ODM_PRECOMP_H__ +#define __ODM_PRECOMP_H__ + +#include "odm_types.h" + +#define TEST_FALG___ 1 + +/* 2 Config Flags and Structs - defined by each ODM Type */ + +#include +#include +#include + +/* 2 Hardware Parameter Files */ + +#include "Hal8188EFWImg_CE.h" + + +/* 2 OutSrc Header Files */ + +#include "odm.h" +#include "odm_HWConfig.h" +#include "odm_debug.h" +#include "odm_RegDefine11AC.h" +#include "odm_RegDefine11N.h" + +#include "HalPhyRf.h" +#include "HalPhyRf_8188e.h"/* for IQK,LCK,Power-tracking */ +#include "Hal8188ERateAdaptive.h"/* for RA,Power training */ +#include "rtl8188e_hal.h" + +#include "odm_interface.h" +#include "odm_reg.h" + +#include "HalHWImg8188E_MAC.h" +#include "HalHWImg8188E_RF.h" +#include "HalHWImg8188E_BB.h" +#include "Hal8188EReg.h" + +#include "odm_RegConfig8188E.h" +#include "odm_RTL8188E.h" + +void odm_CmnInfoHook_Debug(struct odm_dm_struct *pDM_Odm); +void odm_CmnInfoInit_Debug(struct odm_dm_struct *pDM_Odm); +void odm_DIGInit(struct odm_dm_struct *pDM_Odm); +void odm_RateAdaptiveMaskInit(struct odm_dm_struct *pDM_Odm); +void odm_DynamicBBPowerSavingInit(struct odm_dm_struct *pDM_Odm); +void odm_DynamicTxPowerInit(struct odm_dm_struct *pDM_Odm); +void odm_TXPowerTrackingInit(struct odm_dm_struct *pDM_Odm); +void ODM_EdcaTurboInit(struct odm_dm_struct *pDM_Odm); +void odm_SwAntDivInit_NIC(struct odm_dm_struct *pDM_Odm); +void odm_GlobalAdapterCheck(void); +void odm_CmnInfoUpdate_Debug(struct odm_dm_struct *pDM_Odm); +void odm_CommonInfoSelfUpdate(struct odm_dm_struct *pDM_Odm); +void odm_FalseAlarmCounterStatistics(struct odm_dm_struct *pDM_Odm); +void odm_DIG(struct odm_dm_struct *pDM_Odm); +void odm_CCKPacketDetectionThresh(struct odm_dm_struct *pDM_Odm); +void odm_RefreshRateAdaptiveMaskMP(struct odm_dm_struct *pDM_Odm); +void odm_DynamicBBPowerSaving(struct odm_dm_struct *pDM_Odm); +void odm_SwAntDivChkAntSwitch(struct odm_dm_struct *pDM_Odm, u8 Step); +void odm_EdcaTurboCheck(struct odm_dm_struct *pDM_Odm); +void odm_DynamicTxPower(struct odm_dm_struct *pDM_Odm); +void odm_CommonInfoSelfInit(struct odm_dm_struct *pDM_Odm); +void odm_SwAntDivInit(struct odm_dm_struct *pDM_Odm); +void odm_RSSIMonitorCheck(struct odm_dm_struct *pDM_Odm); +void odm_RefreshRateAdaptiveMask(struct odm_dm_struct *pDM_Odm); +void odm_1R_CCA(struct odm_dm_struct *pDM_Odm); +void odm_RefreshRateAdaptiveMaskCE(struct odm_dm_struct *pDM_Odm); +void odm_RefreshRateAdaptiveMaskAPADSL(struct odm_dm_struct *pDM_Odm); +void odm_DynamicTxPowerNIC(struct odm_dm_struct *pDM_Odm); +void odm_DynamicTxPowerAP(struct odm_dm_struct *pDM_Odm); +void odm_RSSIMonitorCheckMP(struct odm_dm_struct *pDM_Odm); +void odm_RSSIMonitorCheckCE(struct odm_dm_struct *pDM_Odm); +void odm_RSSIMonitorCheckAP(struct odm_dm_struct *pDM_Odm); +void odm_TXPowerTrackingThermalMeterInit(struct odm_dm_struct *pDM_Odm); +void odm_EdcaTurboCheckCE(struct odm_dm_struct *pDM_Odm); +void odm_TXPowerTrackingCheckCE(struct odm_dm_struct *pDM_Odm); +void odm_TXPowerTrackingCheckMP(struct odm_dm_struct *pDM_Odm); +void odm_TXPowerTrackingCheckAP(struct odm_dm_struct *pDM_Odm); +void odm_SwAntDivChkAntSwitchCallback(void *FunctionContext); +void odm_InitHybridAntDiv(struct odm_dm_struct *pDM_Odm); +void odm_HwAntDiv(struct odm_dm_struct *pDM_Odm); + +#endif /* __ODM_PRECOMP_H__ */ diff --git a/drivers/staging/rtl8188eu/include/odm_reg.h b/drivers/staging/rtl8188eu/include/odm_reg.h new file mode 100644 index 0000000000000..89bc46bc71b00 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/odm_reg.h @@ -0,0 +1,119 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +/* */ +/* File Name: odm_reg.h */ +/* */ +/* Description: */ +/* */ +/* This file is for general register definition. */ +/* */ +/* */ +/* */ +#ifndef __HAL_ODM_REG_H__ +#define __HAL_ODM_REG_H__ + +/* */ +/* Register Definition */ +/* */ + +/* MAC REG */ +#define ODM_BB_RESET 0x002 +#define ODM_DUMMY 0x4fe +#define ODM_EDCA_VO_PARAM 0x500 +#define ODM_EDCA_VI_PARAM 0x504 +#define ODM_EDCA_BE_PARAM 0x508 +#define ODM_EDCA_BK_PARAM 0x50C +#define ODM_TXPAUSE 0x522 + +/* BB REG */ +#define ODM_FPGA_PHY0_PAGE8 0x800 +#define ODM_PSD_SETTING 0x808 +#define ODM_AFE_SETTING 0x818 +#define ODM_TXAGC_B_6_18 0x830 +#define ODM_TXAGC_B_24_54 0x834 +#define ODM_TXAGC_B_MCS32_5 0x838 +#define ODM_TXAGC_B_MCS0_MCS3 0x83c +#define ODM_TXAGC_B_MCS4_MCS7 0x848 +#define ODM_TXAGC_B_MCS8_MCS11 0x84c +#define ODM_ANALOG_REGISTER 0x85c +#define ODM_RF_INTERFACE_OUTPUT 0x860 +#define ODM_TXAGC_B_MCS12_MCS15 0x868 +#define ODM_TXAGC_B_11_A_2_11 0x86c +#define ODM_AD_DA_LSB_MASK 0x874 +#define ODM_ENABLE_3_WIRE 0x88c +#define ODM_PSD_REPORT 0x8b4 +#define ODM_R_ANT_SELECT 0x90c +#define ODM_CCK_ANT_SELECT 0xa07 +#define ODM_CCK_PD_THRESH 0xa0a +#define ODM_CCK_RF_REG1 0xa11 +#define ODM_CCK_MATCH_FILTER 0xa20 +#define ODM_CCK_RAKE_MAC 0xa2e +#define ODM_CCK_CNT_RESET 0xa2d +#define ODM_CCK_TX_DIVERSITY 0xa2f +#define ODM_CCK_FA_CNT_MSB 0xa5b +#define ODM_CCK_FA_CNT_LSB 0xa5c +#define ODM_CCK_NEW_FUNCTION 0xa75 +#define ODM_OFDM_PHY0_PAGE_C 0xc00 +#define ODM_OFDM_RX_ANT 0xc04 +#define ODM_R_A_RXIQI 0xc14 +#define ODM_R_A_AGC_CORE1 0xc50 +#define ODM_R_A_AGC_CORE2 0xc54 +#define ODM_R_B_AGC_CORE1 0xc58 +#define ODM_R_AGC_PAR 0xc70 +#define ODM_R_HTSTF_AGC_PAR 0xc7c +#define ODM_TX_PWR_TRAINING_A 0xc90 +#define ODM_TX_PWR_TRAINING_B 0xc98 +#define ODM_OFDM_FA_CNT1 0xcf0 +#define ODM_OFDM_PHY0_PAGE_D 0xd00 +#define ODM_OFDM_FA_CNT2 0xda0 +#define ODM_OFDM_FA_CNT3 0xda4 +#define ODM_OFDM_FA_CNT4 0xda8 +#define ODM_TXAGC_A_6_18 0xe00 +#define ODM_TXAGC_A_24_54 0xe04 +#define ODM_TXAGC_A_1_MCS32 0xe08 +#define ODM_TXAGC_A_MCS0_MCS3 0xe10 +#define ODM_TXAGC_A_MCS4_MCS7 0xe14 +#define ODM_TXAGC_A_MCS8_MCS11 0xe18 +#define ODM_TXAGC_A_MCS12_MCS15 0xe1c + +/* RF REG */ +#define ODM_GAIN_SETTING 0x00 +#define ODM_CHANNEL 0x18 + +/* Ant Detect Reg */ +#define ODM_DPDT 0x300 + +/* PSD Init */ +#define ODM_PSDREG 0x808 + +/* 92D Path Div */ +#define PATHDIV_REG 0xB30 +#define PATHDIV_TRI 0xBA0 + + +/* */ +/* Bitmap Definition */ +/* */ + +#define BIT_FA_RESET BIT0 + + + +#endif diff --git a/drivers/staging/rtl8188eu/include/odm_types.h b/drivers/staging/rtl8188eu/include/odm_types.h new file mode 100644 index 0000000000000..78ee2bac0d8da --- /dev/null +++ b/drivers/staging/rtl8188eu/include/odm_types.h @@ -0,0 +1,62 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __ODM_TYPES_H__ +#define __ODM_TYPES_H__ + +/* */ +/* Define Different SW team support */ +/* */ +#define ODM_AP 0x01 /* BIT0 */ +#define ODM_ADSL 0x02 /* BIT1 */ +#define ODM_CE 0x04 /* BIT2 */ +#define ODM_MP 0x08 /* BIT3 */ + +#define RT_PCI_INTERFACE 1 +#define RT_USB_INTERFACE 2 +#define RT_SDIO_INTERFACE 3 + +enum HAL_STATUS { + HAL_STATUS_SUCCESS, + HAL_STATUS_FAILURE, +}; + +enum RT_SPINLOCK_TYPE { + RT_TEMP = 1, +}; + +#include + +#define DEV_BUS_TYPE RT_USB_INTERFACE + +#define SET_TX_DESC_ANTSEL_A_88E(__pTxDesc, __Value) \ + SET_BITS_TO_LE_4BYTE(__pTxDesc+8, 24, 1, __Value) +#define SET_TX_DESC_ANTSEL_B_88E(__pTxDesc, __Value) \ + SET_BITS_TO_LE_4BYTE(__pTxDesc+8, 25, 1, __Value) +#define SET_TX_DESC_ANTSEL_C_88E(__pTxDesc, __Value) \ + SET_BITS_TO_LE_4BYTE(__pTxDesc+28, 29, 1, __Value) + +/* define useless flag to avoid compile warning */ +#define USE_WORKITEM 0 +#define FOR_BRAZIL_PRETEST 0 +#define BT_30_SUPPORT 0 +#define FPGA_TWO_MAC_VERIFICATION 0 + + +#endif /* __ODM_TYPES_H__ */ diff --git a/drivers/staging/rtl8188eu/include/osdep_intf.h b/drivers/staging/rtl8188eu/include/osdep_intf.h new file mode 100644 index 0000000000000..c4599c583b59c --- /dev/null +++ b/drivers/staging/rtl8188eu/include/osdep_intf.h @@ -0,0 +1,83 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#ifndef __OSDEP_INTF_H_ +#define __OSDEP_INTF_H_ + +#include +#include + +struct intf_priv { + u8 *intf_dev; + u32 max_iosz; /* USB2.0: 128, USB1.1: 64, SDIO:64 */ + u32 max_xmitsz; /* USB2.0: unlimited, SDIO:512 */ + u32 max_recvsz; /* USB2.0: unlimited, SDIO:512 */ + + u8 *io_rwmem; + u8 *allocated_io_rwmem; + u32 io_wsz; /* unit: 4bytes */ + u32 io_rsz;/* unit: 4bytes */ + u8 intf_status; + + void (*_bus_io)(u8 *priv); + +/* +Under Sync. IRP (SDIO/USB) +A protection mechanism is necessary for the io_rwmem(read/write protocol) + +Under Async. IRP (SDIO/USB) +The protection mechanism is through the pending queue. +*/ + struct mutex ioctl_mutex; + /* when in USB, IO is through interrupt in/out endpoints */ + struct usb_device *udev; + struct urb *piorw_urb; + u8 io_irp_cnt; + u8 bio_irp_pending; + struct semaphore io_retevt; + struct timer_list io_timer; + u8 bio_irp_timeout; + u8 bio_timer_cancel; +}; + +u8 rtw_init_drv_sw(struct adapter *padapter); +u8 rtw_free_drv_sw(struct adapter *padapter); +u8 rtw_reset_drv_sw(struct adapter *padapter); + +u32 rtw_start_drv_threads(struct adapter *padapter); +void rtw_stop_drv_threads (struct adapter *padapter); +void rtw_cancel_all_timer(struct adapter *padapter); + +int rtw_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); + +int rtw_init_netdev_name(struct net_device *pnetdev, const char *ifname); +struct net_device *rtw_init_netdev(struct adapter *padapter); +u16 rtw_recv_select_queue(struct sk_buff *skb); +void rtw_proc_init_one(struct net_device *dev); +void rtw_proc_remove_one(struct net_device *dev); + +void rtw_ips_dev_unload(struct adapter *padapter); + +int rtw_ips_pwr_up(struct adapter *padapter); +void rtw_ips_pwr_down(struct adapter *padapter); +int rtw_hw_suspend(struct adapter *padapter); +int rtw_hw_resume(struct adapter *padapter); + +#endif /* _OSDEP_INTF_H_ */ diff --git a/drivers/staging/rtl8188eu/include/osdep_service.h b/drivers/staging/rtl8188eu/include/osdep_service.h new file mode 100644 index 0000000000000..1be33b74f8354 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/osdep_service.h @@ -0,0 +1,548 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __OSDEP_SERVICE_H_ +#define __OSDEP_SERVICE_H_ + +#include + +#define _FAIL 0 +#define _SUCCESS 1 +#define RTW_RX_HANDLED 2 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /* Necessary because we use the proc fs */ +#include /* for struct tasklet_struct */ +#include +#include + +#include +#include + +struct __queue { + struct list_head queue; + spinlock_t lock; +}; + +#define thread_exit() complete_and_exit(NULL, 0) + +static inline struct list_head *get_next(struct list_head *list) +{ + return list->next; +} + +static inline struct list_head *get_list_head(struct __queue *queue) +{ + return (&(queue->queue)); +} + + +#define LIST_CONTAINOR(ptr, type, member) \ + ((type *)((char *)(ptr)-(size_t)(&((type *)0)->member))) + + +static inline void _enter_critical(spinlock_t *plock, unsigned long *pirqL) +{ + spin_lock_irqsave(plock, *pirqL); +} + +static inline void _exit_critical(spinlock_t *plock, unsigned long *pirqL) +{ + spin_unlock_irqrestore(plock, *pirqL); +} + +static inline void _enter_critical_ex(spinlock_t *plock, unsigned long *pirqL) +{ + spin_lock_irqsave(plock, *pirqL); +} + +static inline void _exit_critical_ex(spinlock_t *plock, unsigned long *pirqL) +{ + spin_unlock_irqrestore(plock, *pirqL); +} + +static inline void _enter_critical_bh(spinlock_t *plock, unsigned long *pirqL) +{ + spin_lock_bh(plock); +} + +static inline void _exit_critical_bh(spinlock_t *plock, unsigned long *pirqL) +{ + spin_unlock_bh(plock); +} + +static inline int _enter_critical_mutex(struct mutex *pmutex, unsigned long *pirqL) +{ + int ret; + + ret = mutex_lock_interruptible(pmutex); + return ret; +} + + +static inline void _exit_critical_mutex(struct mutex *pmutex, unsigned long *pirqL) +{ + mutex_unlock(pmutex); +} + +static inline void rtw_list_delete(struct list_head *plist) +{ + list_del_init(plist); +} + +static inline void _init_timer(struct timer_list *ptimer,struct net_device *nic_hdl,void *pfunc,void* cntx) +{ + ptimer->function = pfunc; + ptimer->data = (unsigned long)cntx; + init_timer(ptimer); +} + +static inline void _set_timer(struct timer_list *ptimer,u32 delay_time) +{ + mod_timer(ptimer , (jiffies+(delay_time*HZ/1000))); +} + +static inline void _cancel_timer(struct timer_list *ptimer,u8 *bcancelled) +{ + del_timer_sync(ptimer); + *bcancelled= true;/* true ==1; false==0 */ +} + +#define RTW_TIMER_HDL_ARGS void *FunctionContext +#define RTW_TIMER_HDL_NAME(name) rtw_##name##_timer_hdl +#define RTW_DECLARE_TIMER_HDL(name) void RTW_TIMER_HDL_NAME(name)(RTW_TIMER_HDL_ARGS) + +static inline void _init_workitem(struct work_struct *pwork, void *pfunc, void * cntx) +{ + INIT_WORK(pwork, pfunc); +} + +static inline void _set_workitem(struct work_struct *pwork) +{ + schedule_work(pwork); +} + +static inline void _cancel_workitem_sync(struct work_struct *pwork) +{ + cancel_work_sync(pwork); +} +/* */ +/* Global Mutex: can only be used at PASSIVE level. */ +/* */ + +#define ACQUIRE_GLOBAL_MUTEX(_MutexCounter) \ +{ \ + while (atomic_inc_return((atomic_t *)&(_MutexCounter)) != 1)\ + { \ + atomic_dec((atomic_t *)&(_MutexCounter)); \ + msleep(10); \ + } \ +} + +#define RELEASE_GLOBAL_MUTEX(_MutexCounter) \ +{ \ + atomic_dec((atomic_t *)&(_MutexCounter)); \ +} + +static inline int rtw_netif_queue_stopped(struct net_device *pnetdev) +{ + return netif_tx_queue_stopped(netdev_get_tx_queue(pnetdev, 0)) && + netif_tx_queue_stopped(netdev_get_tx_queue(pnetdev, 1)) && + netif_tx_queue_stopped(netdev_get_tx_queue(pnetdev, 2)) && + netif_tx_queue_stopped(netdev_get_tx_queue(pnetdev, 3)); +} + +static inline void rtw_netif_wake_queue(struct net_device *pnetdev) +{ + netif_tx_wake_all_queues(pnetdev); +} + +static inline void rtw_netif_start_queue(struct net_device *pnetdev) +{ + netif_tx_start_all_queues(pnetdev); +} + +static inline void rtw_netif_stop_queue(struct net_device *pnetdev) +{ + netif_tx_stop_all_queues(pnetdev); +} + +#ifndef BIT + #define BIT(x) ( 1 << (x)) +#endif + +#define BIT0 0x00000001 +#define BIT1 0x00000002 +#define BIT2 0x00000004 +#define BIT3 0x00000008 +#define BIT4 0x00000010 +#define BIT5 0x00000020 +#define BIT6 0x00000040 +#define BIT7 0x00000080 +#define BIT8 0x00000100 +#define BIT9 0x00000200 +#define BIT10 0x00000400 +#define BIT11 0x00000800 +#define BIT12 0x00001000 +#define BIT13 0x00002000 +#define BIT14 0x00004000 +#define BIT15 0x00008000 +#define BIT16 0x00010000 +#define BIT17 0x00020000 +#define BIT18 0x00040000 +#define BIT19 0x00080000 +#define BIT20 0x00100000 +#define BIT21 0x00200000 +#define BIT22 0x00400000 +#define BIT23 0x00800000 +#define BIT24 0x01000000 +#define BIT25 0x02000000 +#define BIT26 0x04000000 +#define BIT27 0x08000000 +#define BIT28 0x10000000 +#define BIT29 0x20000000 +#define BIT30 0x40000000 +#define BIT31 0x80000000 +#define BIT32 0x0100000000 +#define BIT33 0x0200000000 +#define BIT34 0x0400000000 +#define BIT35 0x0800000000 +#define BIT36 0x1000000000 + +extern int RTW_STATUS_CODE(int error_code); + +/* flags used for rtw_update_mem_stat() */ +enum { + MEM_STAT_VIR_ALLOC_SUCCESS, + MEM_STAT_VIR_ALLOC_FAIL, + MEM_STAT_VIR_FREE, + MEM_STAT_PHY_ALLOC_SUCCESS, + MEM_STAT_PHY_ALLOC_FAIL, + MEM_STAT_PHY_FREE, + MEM_STAT_TX, /* used to distinguish TX/RX, asigned from caller */ + MEM_STAT_TX_ALLOC_SUCCESS, + MEM_STAT_TX_ALLOC_FAIL, + MEM_STAT_TX_FREE, + MEM_STAT_RX, /* used to distinguish TX/RX, asigned from caller */ + MEM_STAT_RX_ALLOC_SUCCESS, + MEM_STAT_RX_ALLOC_FAIL, + MEM_STAT_RX_FREE +}; + +extern unsigned char MCS_rate_2R[16]; +extern unsigned char MCS_rate_1R[16]; +extern unsigned char RTW_WPA_OUI[]; +extern unsigned char WPA_TKIP_CIPHER[4]; +extern unsigned char RSN_TKIP_CIPHER[4]; + +#define rtw_update_mem_stat(flag, sz) do {} while (0) +u8 *_rtw_vmalloc(u32 sz); +u8 *_rtw_zvmalloc(u32 sz); +void _rtw_vmfree(u8 *pbuf, u32 sz); +u8 *_rtw_zmalloc(u32 sz); +u8 *_rtw_malloc(u32 sz); +void _rtw_mfree(u8 *pbuf, u32 sz); +#define rtw_vmalloc(sz) _rtw_vmalloc((sz)) +#define rtw_zvmalloc(sz) _rtw_zvmalloc((sz)) +#define rtw_vmfree(pbuf, sz) _rtw_vmfree((pbuf), (sz)) +#define rtw_malloc(sz) _rtw_malloc((sz)) +#define rtw_zmalloc(sz) _rtw_zmalloc((sz)) +#define rtw_mfree(pbuf, sz) _rtw_mfree((pbuf), (sz)) + +void *rtw_malloc2d(int h, int w, int size); +void rtw_mfree2d(void *pbuf, int h, int w, int size); + +void _rtw_memcpy(void *dec, void *sour, u32 sz); +int _rtw_memcmp(void *dst, void *src, u32 sz); +void _rtw_memset(void *pbuf, int c, u32 sz); + +void _rtw_init_listhead(struct list_head *list); +u32 rtw_is_list_empty(struct list_head *phead); +void rtw_list_insert_head(struct list_head *plist, struct list_head *phead); +void rtw_list_insert_tail(struct list_head *plist, struct list_head *phead); +void rtw_list_delete(struct list_head *plist); + +void _rtw_init_sema(struct semaphore *sema, int init_val); +void _rtw_free_sema(struct semaphore *sema); +void _rtw_up_sema(struct semaphore *sema); +u32 _rtw_down_sema(struct semaphore *sema); +void _rtw_mutex_init(struct mutex *pmutex); +void _rtw_mutex_free(struct mutex *pmutex); +void _rtw_spinlock_init(spinlock_t *plock); +void _rtw_spinlock_free(spinlock_t *plock); + +void _rtw_init_queue(struct __queue *pqueue); +u32 _rtw_queue_empty(struct __queue *pqueue); +u32 rtw_end_of_queue_search(struct list_head *queue, struct list_head *pelement); + +u32 rtw_get_current_time(void); +u32 rtw_systime_to_ms(u32 systime); +u32 rtw_ms_to_systime(u32 ms); +s32 rtw_get_passing_time_ms(u32 start); +s32 rtw_get_time_interval_ms(u32 start, u32 end); + +void rtw_sleep_schedulable(int ms); + +void rtw_msleep_os(int ms); +void rtw_usleep_os(int us); + +u32 rtw_atoi(u8 *s); + +void rtw_mdelay_os(int ms); +void rtw_udelay_os(int us); + +void rtw_yield_os(void); + +static inline unsigned char _cancel_timer_ex(struct timer_list *ptimer) +{ + return del_timer_sync(ptimer); +} + +static __inline void thread_enter(char *name) +{ +#ifdef daemonize + daemonize("%s", name); +#endif + allow_signal(SIGTERM); +} + +static inline void flush_signals_thread(void) +{ + if (signal_pending (current)) + flush_signals(current); +} + +static inline int res_to_status(int res) +{ + return res; +} + +#define _RND(sz, r) ((((sz)+((r)-1))/(r))*(r)) +#define RND4(x) (((x >> 2) + (((x & 3) == 0) ? 0: 1)) << 2) + +static inline u32 _RND4(u32 sz) +{ + u32 val; + + val = ((sz >> 2) + ((sz & 3) ? 1: 0)) << 2; + return val; +} + +static inline u32 _RND8(u32 sz) +{ + u32 val; + + val = ((sz >> 3) + ((sz & 7) ? 1: 0)) << 3; + return val; +} + +static inline u32 _RND128(u32 sz) +{ + u32 val; + + val = ((sz >> 7) + ((sz & 127) ? 1: 0)) << 7; + return val; +} + +static inline u32 _RND256(u32 sz) +{ + u32 val; + + val = ((sz >> 8) + ((sz & 255) ? 1: 0)) << 8; + return val; +} + +static inline u32 _RND512(u32 sz) +{ + u32 val; + + val = ((sz >> 9) + ((sz & 511) ? 1: 0)) << 9; + return val; +} + +static inline u32 bitshift(u32 bitmask) +{ + u32 i; + + for (i = 0; i <= 31; i++) + if (((bitmask>>i) & 0x1) == 1) break; + return i; +} + +/* limitation of path length */ +#define PATH_LENGTH_MAX PATH_MAX + +void rtw_suspend_lock_init(void); +void rtw_suspend_lock_uninit(void); +void rtw_lock_suspend(void); +void rtw_unlock_suspend(void); + +/* Atomic integer operations */ +#define ATOMIC_T atomic_t + +void ATOMIC_SET(ATOMIC_T *v, int i); +int ATOMIC_READ(ATOMIC_T *v); +void ATOMIC_ADD(ATOMIC_T *v, int i); +void ATOMIC_SUB(ATOMIC_T *v, int i); +void ATOMIC_INC(ATOMIC_T *v); +void ATOMIC_DEC(ATOMIC_T *v); +int ATOMIC_ADD_RETURN(ATOMIC_T *v, int i); +int ATOMIC_SUB_RETURN(ATOMIC_T *v, int i); +int ATOMIC_INC_RETURN(ATOMIC_T *v); +int ATOMIC_DEC_RETURN(ATOMIC_T *v); + +/* File operation APIs, just for linux now */ +int rtw_is_file_readable(char *path); +int rtw_retrive_from_file(char *path, u8 __user *buf, u32 sz); +int rtw_store_to_file(char *path, u8 __user *buf, u32 sz); + +struct rtw_netdev_priv_indicator { + void *priv; + u32 sizeof_priv; +}; +struct net_device *rtw_alloc_etherdev_with_old_priv(int sizeof_priv, + void *old_priv); +struct net_device *rtw_alloc_etherdev(int sizeof_priv); + +#define rtw_netdev_priv(netdev) \ + (((struct rtw_netdev_priv_indicator *)netdev_priv(netdev))->priv) +void rtw_free_netdev(struct net_device *netdev); + +#define NDEV_FMT "%s" +#define NDEV_ARG(ndev) ndev->name +#define ADPT_FMT "%s" +#define ADPT_ARG(adapter) adapter->pnetdev->name +#define FUNC_NDEV_FMT "%s(%s)" +#define FUNC_NDEV_ARG(ndev) __func__, ndev->name +#define FUNC_ADPT_FMT "%s(%s)" +#define FUNC_ADPT_ARG(adapter) __func__, adapter->pnetdev->name + +#define rtw_signal_process(pid, sig) kill_pid(find_vpid((pid)),(sig), 1) + +u64 rtw_modular64(u64 x, u64 y); +u64 rtw_division64(u64 x, u64 y); + +/* Macros for handling unaligned memory accesses */ + +#define RTW_GET_BE16(a) ((u16) (((a)[0] << 8) | (a)[1])) +#define RTW_PUT_BE16(a, val) \ + do { \ + (a)[0] = ((u16) (val)) >> 8; \ + (a)[1] = ((u16) (val)) & 0xff; \ + } while (0) + +#define RTW_GET_LE16(a) ((u16) (((a)[1] << 8) | (a)[0])) +#define RTW_PUT_LE16(a, val) \ + do { \ + (a)[1] = ((u16) (val)) >> 8; \ + (a)[0] = ((u16) (val)) & 0xff; \ + } while (0) + +#define RTW_GET_BE24(a) ((((u32) (a)[0]) << 16) | (((u32) (a)[1]) << 8) | \ + ((u32) (a)[2])) +#define RTW_PUT_BE24(a, val) \ + do { \ + (a)[0] = (u8) ((((u32) (val)) >> 16) & 0xff); \ + (a)[1] = (u8) ((((u32) (val)) >> 8) & 0xff); \ + (a)[2] = (u8) (((u32) (val)) & 0xff); \ + } while (0) + +#define RTW_GET_BE32(a) ((((u32) (a)[0]) << 24) | (((u32) (a)[1]) << 16) | \ + (((u32) (a)[2]) << 8) | ((u32) (a)[3])) +#define RTW_PUT_BE32(a, val) \ + do { \ + (a)[0] = (u8) ((((u32) (val)) >> 24) & 0xff); \ + (a)[1] = (u8) ((((u32) (val)) >> 16) & 0xff); \ + (a)[2] = (u8) ((((u32) (val)) >> 8) & 0xff); \ + (a)[3] = (u8) (((u32) (val)) & 0xff); \ + } while (0) + +#define RTW_GET_LE32(a) ((((u32) (a)[3]) << 24) | (((u32) (a)[2]) << 16) | \ + (((u32) (a)[1]) << 8) | ((u32) (a)[0])) +#define RTW_PUT_LE32(a, val) \ + do { \ + (a)[3] = (u8) ((((u32) (val)) >> 24) & 0xff); \ + (a)[2] = (u8) ((((u32) (val)) >> 16) & 0xff); \ + (a)[1] = (u8) ((((u32) (val)) >> 8) & 0xff); \ + (a)[0] = (u8) (((u32) (val)) & 0xff); \ + } while (0) + +#define RTW_GET_BE64(a) ((((u64) (a)[0]) << 56) | (((u64) (a)[1]) << 48) | \ + (((u64) (a)[2]) << 40) | (((u64) (a)[3]) << 32) | \ + (((u64) (a)[4]) << 24) | (((u64) (a)[5]) << 16) | \ + (((u64) (a)[6]) << 8) | ((u64) (a)[7])) +#define RTW_PUT_BE64(a, val) \ + do { \ + (a)[0] = (u8) (((u64) (val)) >> 56); \ + (a)[1] = (u8) (((u64) (val)) >> 48); \ + (a)[2] = (u8) (((u64) (val)) >> 40); \ + (a)[3] = (u8) (((u64) (val)) >> 32); \ + (a)[4] = (u8) (((u64) (val)) >> 24); \ + (a)[5] = (u8) (((u64) (val)) >> 16); \ + (a)[6] = (u8) (((u64) (val)) >> 8); \ + (a)[7] = (u8) (((u64) (val)) & 0xff); \ + } while (0) + +#define RTW_GET_LE64(a) ((((u64) (a)[7]) << 56) | (((u64) (a)[6]) << 48) | \ + (((u64) (a)[5]) << 40) | (((u64) (a)[4]) << 32) | \ + (((u64) (a)[3]) << 24) | (((u64) (a)[2]) << 16) | \ + (((u64) (a)[1]) << 8) | ((u64) (a)[0])) + +void rtw_buf_free(u8 **buf, u32 *buf_len); +void rtw_buf_update(u8 **buf, u32 *buf_len, u8 *src, u32 src_len); + +struct rtw_cbuf { + u32 write; + u32 read; + u32 size; + void *bufs[0]; +}; + +bool rtw_cbuf_full(struct rtw_cbuf *cbuf); +bool rtw_cbuf_empty(struct rtw_cbuf *cbuf); +bool rtw_cbuf_push(struct rtw_cbuf *cbuf, void *buf); +void *rtw_cbuf_pop(struct rtw_cbuf *cbuf); +struct rtw_cbuf *rtw_cbuf_alloc(u32 size); +int wifirate2_ratetbl_inx(unsigned char rate); + +#endif -- GitLab From 58c434013a22fccfdb14abc2bb8408ca29073b76 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 21 Aug 2013 22:34:07 -0500 Subject: [PATCH 783/942] staging: r8188eu: Add files for new driver - part 25 This commit adds files include/recv_osdep.h, include/rtl8188e_cmd.h, include/rtl8188e_dm.h, include/rtl8188e_hal.h, include/rtl8188e_led.h, include/rtl8188e_recv.h, include/rtl8188e_rf.h, include/rtl8188e_spec.h, include/rtl8188e_sreset.h, and include/rtl8188e_xmit.h. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8188eu/include/recv_osdep.h | 56 + .../staging/rtl8188eu/include/rtl8188e_cmd.h | 122 ++ .../staging/rtl8188eu/include/rtl8188e_dm.h | 62 + .../staging/rtl8188eu/include/rtl8188e_hal.h | 487 ++++++ .../staging/rtl8188eu/include/rtl8188e_led.h | 35 + .../staging/rtl8188eu/include/rtl8188e_recv.h | 69 + .../staging/rtl8188eu/include/rtl8188e_rf.h | 36 + .../staging/rtl8188eu/include/rtl8188e_spec.h | 1439 +++++++++++++++++ .../rtl8188eu/include/rtl8188e_sreset.h | 31 + .../staging/rtl8188eu/include/rtl8188e_xmit.h | 178 ++ 10 files changed, 2515 insertions(+) create mode 100644 drivers/staging/rtl8188eu/include/recv_osdep.h create mode 100644 drivers/staging/rtl8188eu/include/rtl8188e_cmd.h create mode 100644 drivers/staging/rtl8188eu/include/rtl8188e_dm.h create mode 100644 drivers/staging/rtl8188eu/include/rtl8188e_hal.h create mode 100644 drivers/staging/rtl8188eu/include/rtl8188e_led.h create mode 100644 drivers/staging/rtl8188eu/include/rtl8188e_recv.h create mode 100644 drivers/staging/rtl8188eu/include/rtl8188e_rf.h create mode 100644 drivers/staging/rtl8188eu/include/rtl8188e_spec.h create mode 100644 drivers/staging/rtl8188eu/include/rtl8188e_sreset.h create mode 100644 drivers/staging/rtl8188eu/include/rtl8188e_xmit.h diff --git a/drivers/staging/rtl8188eu/include/recv_osdep.h b/drivers/staging/rtl8188eu/include/recv_osdep.h new file mode 100644 index 0000000000000..6912380780757 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/recv_osdep.h @@ -0,0 +1,56 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __RECV_OSDEP_H_ +#define __RECV_OSDEP_H_ + +#include +#include + + +int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter); +void _rtw_free_recv_priv(struct recv_priv *precvpriv); + + +s32 rtw_recv_entry(union recv_frame *precv_frame); +int rtw_recv_indicatepkt(struct adapter *adapter, union recv_frame *recv_frame); +void rtw_recv_returnpacket(struct net_device *cnxt, struct sk_buff *retpkt); + +void rtw_hostapd_mlme_rx(struct adapter *padapter, union recv_frame *recv_fr); +void rtw_handle_tkip_mic_err(struct adapter *padapter, u8 bgroup); + +int rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter); +void rtw_free_recv_priv(struct recv_priv *precvpriv); + +int rtw_os_recv_resource_init(struct recv_priv *recvpr, struct adapter *adapt); +int rtw_os_recv_resource_alloc(struct adapter *adapt, union recv_frame *recvfr); +void rtw_os_recv_resource_free(struct recv_priv *precvpriv); + +int rtw_os_recvbuf_resource_alloc(struct adapter *adapt, struct recv_buf *buf); +int rtw_os_recvbuf_resource_free(struct adapter *adapt, struct recv_buf *buf); + +void rtw_os_read_port(struct adapter *padapter, struct recv_buf *precvbuf); + +void rtw_init_recv_timer(struct recv_reorder_ctrl *preorder_ctrl); +int nat25_handle_frame(struct adapter *priv, struct sk_buff *skb); +int _netdev_open(struct net_device *pnetdev); +int netdev_open(struct net_device *pnetdev); +int netdev_close(struct net_device *pnetdev); + +#endif /* */ diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_cmd.h b/drivers/staging/rtl8188eu/include/rtl8188e_cmd.h new file mode 100644 index 0000000000000..b32bc28503d0a --- /dev/null +++ b/drivers/staging/rtl8188eu/include/rtl8188e_cmd.h @@ -0,0 +1,122 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __RTL8188E_CMD_H__ +#define __RTL8188E_CMD_H__ + +enum RTL8188E_H2C_CMD_ID { + /* Class Common */ + H2C_COM_RSVD_PAGE = 0x00, + H2C_COM_MEDIA_STATUS_RPT = 0x01, + H2C_COM_SCAN = 0x02, + H2C_COM_KEEP_ALIVE = 0x03, + H2C_COM_DISCNT_DECISION = 0x04, + H2C_COM_INIT_OFFLOAD = 0x06, + H2C_COM_REMOTE_WAKE_CTL = 0x07, + H2C_COM_AP_OFFLOAD = 0x08, + H2C_COM_BCN_RSVD_PAGE = 0x09, + H2C_COM_PROB_RSP_RSVD_PAGE = 0x0A, + + /* Class PS */ + H2C_PS_PWR_MODE = 0x20, + H2C_PS_TUNE_PARA = 0x21, + H2C_PS_TUNE_PARA_2 = 0x22, + H2C_PS_LPS_PARA = 0x23, + H2C_PS_P2P_OFFLOAD = 0x24, + + /* Class DM */ + H2C_DM_MACID_CFG = 0x40, + H2C_DM_TXBF = 0x41, + + /* Class BT */ + H2C_BT_COEX_MASK = 0x60, + H2C_BT_COEX_GPIO_MODE = 0x61, + H2C_BT_DAC_SWING_VAL = 0x62, + H2C_BT_PSD_RST = 0x63, + + /* Class */ + H2C_RESET_TSF = 0xc0, +}; + +struct cmd_msg_parm { + u8 eid; /* element id */ + u8 sz; /* sz */ + u8 buf[6]; +}; + +enum { + PWRS +}; + +struct setpwrmode_parm { + u8 Mode;/* 0:Active,1:LPS,2:WMMPS */ + u8 SmartPS_RLBM;/* LPS= 0:PS_Poll,1:PS_Poll,2:NullData,WMM= 0:PS_Poll,1:NullData */ + u8 AwakeInterval; /* unit: beacon interval */ + u8 bAllQueueUAPSD; + u8 PwrState;/* AllON(0x0c),RFON(0x04),RFOFF(0x00) */ +}; + +struct H2C_SS_RFOFF_PARAM { + u8 ROFOn; /* 1: on, 0:off */ + u16 gpio_period; /* unit: 1024 us */ +} __packed; + +struct joinbssrpt_parm { + u8 OpMode; /* RT_MEDIA_STATUS */ +}; + +struct rsvdpage_loc { + u8 LocProbeRsp; + u8 LocPsPoll; + u8 LocNullData; + u8 LocQosNull; + u8 LocBTQosNull; +}; + +struct P2P_PS_Offload_t { + u8 Offload_En:1; + u8 role:1; /* 1: Owner, 0: Client */ + u8 CTWindow_En:1; + u8 NoA0_En:1; + u8 NoA1_En:1; + u8 AllStaSleep:1; /* Only valid in Owner */ + u8 discovery:1; + u8 rsvd:1; +}; + +struct P2P_PS_CTWPeriod_t { + u8 CTWPeriod; /* TU */ +}; + +/* host message to firmware cmd */ +void rtl8188e_set_FwPwrMode_cmd(struct adapter *padapter, u8 Mode); +void rtl8188e_set_FwJoinBssReport_cmd(struct adapter *padapter, u8 mstatus); +u8 rtl8188e_set_rssi_cmd(struct adapter *padapter, u8 *param); +u8 rtl8188e_set_raid_cmd(struct adapter *padapter, u32 mask); +void rtl8188e_Add_RateATid(struct adapter *padapter, u32 bitmap, u8 arg, + u8 rssi_level); + +#ifdef CONFIG_88EU_P2P +void rtl8188e_set_p2p_ps_offload_cmd(struct adapter *adapt, u8 p2p_ps_state); +#endif /* CONFIG_88EU_P2P */ + +void CheckFwRsvdPageContent(struct adapter *adapt); +void rtl8188e_set_FwMediaStatus_cmd(struct adapter *adapt, __le16 mstatus_rpt); + +#endif/* __RTL8188E_CMD_H__ */ diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_dm.h b/drivers/staging/rtl8188eu/include/rtl8188e_dm.h new file mode 100644 index 0000000000000..97a3175250ef7 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/rtl8188e_dm.h @@ -0,0 +1,62 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __RTL8188E_DM_H__ +#define __RTL8188E_DM_H__ +enum{ + UP_LINK, + DOWN_LINK, +}; +/* duplicate code,will move to ODM ######### */ +#define IQK_MAC_REG_NUM 4 +#define IQK_ADDA_REG_NUM 16 +#define IQK_BB_REG_NUM 9 +#define HP_THERMAL_NUM 8 +/* duplicate code,will move to ODM ######### */ +struct dm_priv { + u8 DM_Type; + u8 DMFlag; + u8 InitDMFlag; + u32 InitODMFlag; + + /* Upper and Lower Signal threshold for Rate Adaptive*/ + int UndecoratedSmoothedPWDB; + int UndecoratedSmoothedCCK; + int EntryMinUndecoratedSmoothedPWDB; + int EntryMaxUndecoratedSmoothedPWDB; + int MinUndecoratedPWDBForDM; + int LastMinUndecoratedPWDBForDM; + + /* for High Power */ + u8 bDynamicTxPowerEnable; + u8 LastDTPLvl; + u8 DynamicTxHighPowerLvl;/* Tx Power Control for Near/Far Range */ + u8 PowerIndex_backup[6]; +}; + +void rtl8188e_init_dm_priv(struct adapter *adapt); +void rtl8188e_deinit_dm_priv(struct adapter *adapt); +void rtl8188e_InitHalDm(struct adapter *adapt); +void rtl8188e_HalDmWatchDog(struct adapter *adapt); + +void AntDivCompare8188E(struct adapter *adapt, struct wlan_bssid_ex *dst, + struct wlan_bssid_ex *src); +u8 AntDivBeforeLink8188E(struct adapter *adapt); + +#endif diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h new file mode 100644 index 0000000000000..fc4adb614bfed --- /dev/null +++ b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h @@ -0,0 +1,487 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __RTL8188E_HAL_H__ +#define __RTL8188E_HAL_H__ + + +/* include HAL Related header after HAL Related compiling flags */ +#include "rtl8188e_spec.h" +#include "Hal8188EPhyReg.h" +#include "Hal8188EPhyCfg.h" +#include "rtl8188e_rf.h" +#include "rtl8188e_dm.h" +#include "rtl8188e_recv.h" +#include "rtl8188e_xmit.h" +#include "rtl8188e_cmd.h" +#include "Hal8188EPwrSeq.h" +#include "rtl8188e_sreset.h" +#include "rtw_efuse.h" + +#include "odm_precomp.h" + +/* Fw Array */ +#define Rtl8188E_FwImageArray Rtl8188EFwImgArray +#define Rtl8188E_FWImgArrayLength Rtl8188EFWImgArrayLength + +#define RTL8188E_FW_UMC_IMG "rtl8188E\\rtl8188efw.bin" +#define RTL8188E_PHY_REG "rtl8188E\\PHY_REG_1T.txt" +#define RTL8188E_PHY_RADIO_A "rtl8188E\\radio_a_1T.txt" +#define RTL8188E_PHY_RADIO_B "rtl8188E\\radio_b_1T.txt" +#define RTL8188E_AGC_TAB "rtl8188E\\AGC_TAB_1T.txt" +#define RTL8188E_PHY_MACREG "rtl8188E\\MAC_REG.txt" +#define RTL8188E_PHY_REG_PG "rtl8188E\\PHY_REG_PG.txt" +#define RTL8188E_PHY_REG_MP "rtl8188E\\PHY_REG_MP.txt" + +/* RTL8188E Power Configuration CMDs for USB/SDIO interfaces */ +#define Rtl8188E_NIC_PWR_ON_FLOW rtl8188E_power_on_flow +#define Rtl8188E_NIC_RF_OFF_FLOW rtl8188E_radio_off_flow +#define Rtl8188E_NIC_DISABLE_FLOW rtl8188E_card_disable_flow +#define Rtl8188E_NIC_ENABLE_FLOW rtl8188E_card_enable_flow +#define Rtl8188E_NIC_SUSPEND_FLOW rtl8188E_suspend_flow +#define Rtl8188E_NIC_RESUME_FLOW rtl8188E_resume_flow +#define Rtl8188E_NIC_PDN_FLOW rtl8188E_hwpdn_flow +#define Rtl8188E_NIC_LPS_ENTER_FLOW rtl8188E_enter_lps_flow +#define Rtl8188E_NIC_LPS_LEAVE_FLOW rtl8188E_leave_lps_flow + +#define DRVINFO_SZ 4 /* unit is 8bytes */ +#define PageNum_128(_Len) (u32)(((_Len)>>7) + ((_Len) & 0x7F ? 1 : 0)) + +/* download firmware related data structure */ +#define FW_8188E_SIZE 0x4000 /* 16384,16k */ +#define FW_8188E_START_ADDRESS 0x1000 +#define FW_8188E_END_ADDRESS 0x1FFF /* 0x5FFF */ + +#define MAX_PAGE_SIZE 4096 /* @ page : 4k bytes */ + +#define IS_FW_HEADER_EXIST(_pFwHdr) \ + ((le16_to_cpu(_pFwHdr->Signature)&0xFFF0) == 0x92C0 || \ + (le16_to_cpu(_pFwHdr->Signature)&0xFFF0) == 0x88C0 || \ + (le16_to_cpu(_pFwHdr->Signature)&0xFFF0) == 0x2300 || \ + (le16_to_cpu(_pFwHdr->Signature)&0xFFF0) == 0x88E0) + +enum firmware_source { + FW_SOURCE_IMG_FILE = 0, + FW_SOURCE_HEADER_FILE = 1, /* from header file */ +}; + +struct rt_firmware { + enum firmware_source eFWSource; + u8 *szFwBuffer; + u32 ulFwLength; +}; + +/* This structure must be careful with byte-ordering */ + +struct rt_firmware_hdr { + /* 8-byte alinment required */ + /* LONG WORD 0 ---- */ + __le16 Signature; /* 92C0: test chip; 92C, + * 88C0: test chip; 88C1: MP A-cut; + * 92C1: MP A-cut */ + u8 Category; /* AP/NIC and USB/PCI */ + u8 Function; /* Reserved for different FW function + * indcation, for further use when + * driver needs to download different + * FW for different conditions */ + __le16 Version; /* FW Version */ + u8 Subversion; /* FW Subversion, default 0x00 */ + u16 Rsvd1; + + /* LONG WORD 1 ---- */ + u8 Month; /* Release time Month field */ + u8 Date; /* Release time Date field */ + u8 Hour; /* Release time Hour field */ + u8 Minute; /* Release time Minute field */ + __le16 RamCodeSize; /* The size of RAM code */ + u8 Foundry; + u8 Rsvd2; + + /* LONG WORD 2 ---- */ + __le32 SvnIdx; /* The SVN entry index */ + u32 Rsvd3; + + /* LONG WORD 3 ---- */ + u32 Rsvd4; + u32 Rsvd5; +}; + +#define DRIVER_EARLY_INT_TIME 0x05 +#define BCN_DMA_ATIME_INT_TIME 0x02 + +enum usb_rx_agg_mode { + USB_RX_AGG_DISABLE, + USB_RX_AGG_DMA, + USB_RX_AGG_USB, + USB_RX_AGG_MIX +}; + +#define MAX_RX_DMA_BUFFER_SIZE_88E \ + 0x2400 /* 9k for 88E nornal chip , MaxRxBuff=10k-max(TxReportSize(64*8), + * WOLPattern(16*24)) */ + +#define MAX_TX_REPORT_BUFFER_SIZE 0x0400 /* 1k */ + + +/* BK, BE, VI, VO, HCCA, MANAGEMENT, COMMAND, HIGH, BEACON. */ +#define MAX_TX_QUEUE 9 + +#define TX_SELE_HQ BIT(0) /* High Queue */ +#define TX_SELE_LQ BIT(1) /* Low Queue */ +#define TX_SELE_NQ BIT(2) /* Normal Queue */ + +/* Note: We will divide number of page equally for each queue other + * than public queue! */ +/* 22k = 22528 bytes = 176 pages (@page = 128 bytes) */ +/* must reserved about 7 pages for LPS => 176-7 = 169 (0xA9) */ +/* 2*BCN / 1*ps-poll / 1*null-data /1*prob_rsp /1*QOS null-data /1*BT QOS + * null-data */ + +#define TX_TOTAL_PAGE_NUMBER_88E 0xA9/* 169 (21632=> 21k) */ + +#define TX_PAGE_BOUNDARY_88E (TX_TOTAL_PAGE_NUMBER_88E + 1) + +/* Note: For Normal Chip Setting ,modify later */ +#define WMM_NORMAL_TX_TOTAL_PAGE_NUMBER \ + TX_TOTAL_PAGE_NUMBER_88E /* 0xA9 , 0xb0=>176=>22k */ +#define WMM_NORMAL_TX_PAGE_BOUNDARY_88E \ + (WMM_NORMAL_TX_TOTAL_PAGE_NUMBER + 1) /* 0xA9 */ + +/* Chip specific */ +#define CHIP_BONDING_IDENTIFIER(_value) (((_value)>>22)&0x3) +#define CHIP_BONDING_92C_1T2R 0x1 +#define CHIP_BONDING_88C_USB_MCARD 0x2 +#define CHIP_BONDING_88C_USB_HP 0x1 +#include "HalVerDef.h" +#include "hal_com.h" + +/* Channel Plan */ +enum ChannelPlan { + CHPL_FCC = 0, + CHPL_IC = 1, + CHPL_ETSI = 2, + CHPL_SPA = 3, + CHPL_FRANCE = 4, + CHPL_MKK = 5, + CHPL_MKK1 = 6, + CHPL_ISRAEL = 7, + CHPL_TELEC = 8, + CHPL_GLOBAL = 9, + CHPL_WORLD = 10, +}; + +struct txpowerinfo24g { + u8 IndexCCK_Base[MAX_RF_PATH][MAX_CHNL_GROUP_24G]; + u8 IndexBW40_Base[MAX_RF_PATH][MAX_CHNL_GROUP_24G-1]; + /* If only one tx, only BW20 and OFDM are used. */ + s8 CCK_Diff[MAX_RF_PATH][MAX_TX_COUNT]; + s8 OFDM_Diff[MAX_RF_PATH][MAX_TX_COUNT]; + s8 BW20_Diff[MAX_RF_PATH][MAX_TX_COUNT]; + s8 BW40_Diff[MAX_RF_PATH][MAX_TX_COUNT]; +}; + +#define EFUSE_REAL_CONTENT_LEN 512 +#define EFUSE_MAP_LEN 128 +#define EFUSE_MAX_SECTION 16 +#define EFUSE_IC_ID_OFFSET 506 /* For some inferior IC purpose*/ +#define AVAILABLE_EFUSE_ADDR(addr) (addr < EFUSE_REAL_CONTENT_LEN) +/* To prevent out of boundary programming case, */ +/* leave 1byte and program full section */ +/* 9bytes + 1byt + 5bytes and pre 1byte. */ +/* For worst case: */ +/* | 1byte|----8bytes----|1byte|--5bytes--| */ +/* | | Reserved(14bytes) | */ + +/* PG data exclude header, dummy 6 bytes frome CP test and reserved 1byte. */ +#define EFUSE_OOB_PROTECT_BYTES 15 + +#define HWSET_MAX_SIZE_88E 512 + +#define EFUSE_REAL_CONTENT_LEN_88E 256 +#define EFUSE_MAP_LEN_88E 512 +#define EFUSE_MAX_SECTION_88E 64 +#define EFUSE_MAX_WORD_UNIT_88E 4 +#define EFUSE_IC_ID_OFFSET_88E 506 +#define AVAILABLE_EFUSE_ADDR_88E(addr) \ + (addr < EFUSE_REAL_CONTENT_LEN_88E) +/* To prevent out of boundary programming case, leave 1byte and program + * full section */ +/* 9bytes + 1byt + 5bytes and pre 1byte. */ +/* For worst case: */ +/* | 2byte|----8bytes----|1byte|--7bytes--| 92D */ +/* PG data exclude header, dummy 7 bytes frome CP test and reserved 1byte. */ +#define EFUSE_OOB_PROTECT_BYTES_88E 18 +#define EFUSE_PROTECT_BYTES_BANK_88E 16 + +/* EFUSE for BT definition */ +#define EFUSE_BT_REAL_CONTENT_LEN 1536 /* 512*3 */ +#define EFUSE_BT_MAP_LEN 1024 /* 1k bytes */ +#define EFUSE_BT_MAX_SECTION 128 /* 1024/8 */ + +#define EFUSE_PROTECT_BYTES_BANK 16 + +/* For RTL8723 WiFi/BT/GPS multi-function configuration. */ +enum rt_multi_func { + RT_MULTI_FUNC_NONE = 0x00, + RT_MULTI_FUNC_WIFI = 0x01, + RT_MULTI_FUNC_BT = 0x02, + RT_MULTI_FUNC_GPS = 0x04, +}; + +/* For RTL8723 regulator mode. */ +enum rt_regulator_mode { + RT_SWITCHING_REGULATOR = 0, + RT_LDO_REGULATOR = 1, +}; + +struct hal_data_8188e { + struct HAL_VERSION VersionID; + enum rt_multi_func MultiFunc; /* For multi-function consideration. */ + enum rt_regulator_mode RegulatorMode; /* switching regulator or LDO */ + u16 CustomerID; + + u16 FirmwareVersion; + u16 FirmwareVersionRev; + u16 FirmwareSubVersion; + u16 FirmwareSignature; + u8 PGMaxGroup; + /* current WIFI_PHY values */ + u32 ReceiveConfig; + enum wireless_mode CurrentWirelessMode; + enum ht_channel_width CurrentChannelBW; + u8 CurrentChannel; + u8 nCur40MhzPrimeSC;/* Control channel sub-carrier */ + + u16 BasicRateSet; + + /* rf_ctrl */ + u8 rf_chip; + u8 rf_type; + u8 NumTotalRFPath; + + u8 BoardType; + + /* EEPROM setting. */ + u16 EEPROMVID; + u16 EEPROMPID; + u16 EEPROMSVID; + u16 EEPROMSDID; + u8 EEPROMCustomerID; + u8 EEPROMSubCustomerID; + u8 EEPROMVersion; + u8 EEPROMRegulatory; + + u8 bTXPowerDataReadFromEEPORM; + u8 EEPROMThermalMeter; + u8 bAPKThermalMeterIgnore; + + bool EepromOrEfuse; + /* 92C:256bytes, 88E:512bytes, we use union set (512bytes) */ + u8 EfuseMap[2][HWSET_MAX_SIZE_512]; + u8 EfuseUsedPercentage; + struct efuse_hal EfuseHal; + + u8 Index24G_CCK_Base[MAX_RF_PATH][CHANNEL_MAX_NUMBER]; + u8 Index24G_BW40_Base[MAX_RF_PATH][CHANNEL_MAX_NUMBER]; + /* If only one tx, only BW20 and OFDM are used. */ + s8 CCK_24G_Diff[MAX_RF_PATH][MAX_TX_COUNT]; + s8 OFDM_24G_Diff[MAX_RF_PATH][MAX_TX_COUNT]; + s8 BW20_24G_Diff[MAX_RF_PATH][MAX_TX_COUNT]; + s8 BW40_24G_Diff[MAX_RF_PATH][MAX_TX_COUNT]; + + u8 TxPwrLevelCck[RF_PATH_MAX][CHANNEL_MAX_NUMBER]; + /* For HT 40MHZ pwr */ + u8 TxPwrLevelHT40_1S[RF_PATH_MAX][CHANNEL_MAX_NUMBER]; + /* For HT 40MHZ pwr */ + u8 TxPwrLevelHT40_2S[RF_PATH_MAX][CHANNEL_MAX_NUMBER]; + /* HT 20<->40 Pwr diff */ + u8 TxPwrHt20Diff[RF_PATH_MAX][CHANNEL_MAX_NUMBER]; + /* For HT<->legacy pwr diff */ + u8 TxPwrLegacyHtDiff[RF_PATH_MAX][CHANNEL_MAX_NUMBER]; + /* For power group */ + u8 PwrGroupHT20[RF_PATH_MAX][CHANNEL_MAX_NUMBER]; + u8 PwrGroupHT40[RF_PATH_MAX][CHANNEL_MAX_NUMBER]; + + u8 LegacyHTTxPowerDiff;/* Legacy to HT rate power diff */ + /* The current Tx Power Level */ + u8 CurrentCckTxPwrIdx; + u8 CurrentOfdm24GTxPwrIdx; + u8 CurrentBW2024GTxPwrIdx; + u8 CurrentBW4024GTxPwrIdx; + + + /* Read/write are allow for following hardware information variables */ + u8 framesync; + u32 framesyncC34; + u8 framesyncMonitor; + u8 DefaultInitialGain[4]; + u8 pwrGroupCnt; + u32 MCSTxPowerLevelOriginalOffset[MAX_PG_GROUP][16]; + u32 CCKTxPowerLevelOriginalOffset; + + u8 CrystalCap; + u32 AntennaTxPath; /* Antenna path Tx */ + u32 AntennaRxPath; /* Antenna path Rx */ + u8 BluetoothCoexist; + u8 ExternalPA; + + u8 bLedOpenDrain; /* Open-drain support for controlling the LED.*/ + + u8 b1x1RecvCombine; /* for 1T1R receive combining */ + + u32 AcParam_BE; /* Original parameter for BE, use for EDCA turbo. */ + + struct bb_reg_def PHYRegDef[4]; /* Radio A/B/C/D */ + + u32 RfRegChnlVal[2]; + + /* RDG enable */ + bool bRDGEnable; + + /* for host message to fw */ + u8 LastHMEBoxNum; + + u8 fw_ractrl; + u8 RegTxPause; + /* Beacon function related global variable. */ + u32 RegBcnCtrlVal; + u8 RegFwHwTxQCtrl; + u8 RegReg542; + u8 RegCR_1; + + struct dm_priv dmpriv; + struct odm_dm_struct odmpriv; + struct sreset_priv srestpriv; + + u8 CurAntenna; + u8 AntDivCfg; + u8 TRxAntDivType; + + + u8 bDumpRxPkt;/* for debug */ + u8 bDumpTxPkt;/* for debug */ + u8 FwRsvdPageStartOffset; /* Reserve page start offset except + * beacon in TxQ. */ + + /* 2010/08/09 MH Add CU power down mode. */ + bool pwrdown; + + /* Add for dual MAC 0--Mac0 1--Mac1 */ + u32 interfaceIndex; + + u8 OutEpQueueSel; + u8 OutEpNumber; + + /* Add for USB aggreation mode dynamic shceme. */ + bool UsbRxHighSpeedMode; + + /* 2010/11/22 MH Add for slim combo debug mode selective. */ + /* This is used for fix the drawback of CU TSMC-A/UMC-A cut. + * HW auto suspend ability. Close BT clock. */ + bool SlimComboDbg; + + u16 EfuseUsedBytes; + +#ifdef CONFIG_88EU_P2P + struct P2P_PS_Offload_t p2p_ps_offload; +#endif + + /* Auto FSM to Turn On, include clock, isolation, power control + * for MAC only */ + u8 bMacPwrCtrlOn; + + u32 UsbBulkOutSize; + + /* Interrupt relatd register information. */ + u32 IntArray[3];/* HISR0,HISR1,HSISR */ + u32 IntrMask[3]; + u8 C2hArray[16]; + u8 UsbTxAggMode; + u8 UsbTxAggDescNum; + u16 HwRxPageSize; /* Hardware setting */ + u32 MaxUsbRxAggBlock; + + enum usb_rx_agg_mode UsbRxAggMode; + u8 UsbRxAggBlockCount; /* USB Block count. Block size is + * 512-byte in high speed and 64-byte + * in full speed */ + u8 UsbRxAggBlockTimeout; + u8 UsbRxAggPageCount; /* 8192C DMA page count */ + u8 UsbRxAggPageTimeout; +}; + +#define GET_HAL_DATA(__pAdapter) \ + ((struct hal_data_8188e *)((__pAdapter)->HalData)) +#define GET_RF_TYPE(priv) (GET_HAL_DATA(priv)->rf_type) + +#define INCLUDE_MULTI_FUNC_BT(_Adapter) \ + (GET_HAL_DATA(_Adapter)->MultiFunc & RT_MULTI_FUNC_BT) +#define INCLUDE_MULTI_FUNC_GPS(_Adapter) \ + (GET_HAL_DATA(_Adapter)->MultiFunc & RT_MULTI_FUNC_GPS) + +/* rtl8188e_hal_init.c */ +s32 rtl8188e_FirmwareDownload(struct adapter *padapter); +void _8051Reset88E(struct adapter *padapter); +void rtl8188e_InitializeFirmwareVars(struct adapter *padapter); + + +s32 InitLLTTable(struct adapter *padapter, u8 txpktbuf_bndy); + +/* EFuse */ +u8 GetEEPROMSize8188E(struct adapter *padapter); +void Hal_InitPGData88E(struct adapter *padapter); +void Hal_EfuseParseIDCode88E(struct adapter *padapter, u8 *hwinfo); +void Hal_ReadTxPowerInfo88E(struct adapter *padapter, u8 *hwinfo, + bool AutoLoadFail); + +void Hal_EfuseParseEEPROMVer88E(struct adapter *padapter, u8 *hwinfo, + bool AutoLoadFail); +void rtl8188e_EfuseParseChnlPlan(struct adapter *padapter, u8 *hwinfo, + bool AutoLoadFail); +void Hal_EfuseParseCustomerID88E(struct adapter *padapter, u8 *hwinfo, + bool AutoLoadFail); +void Hal_ReadAntennaDiversity88E(struct adapter *pAdapter,u8 *PROMContent, + bool AutoLoadFail); +void Hal_ReadThermalMeter_88E(struct adapter * dapter, u8 *PROMContent, + bool AutoloadFail); +void Hal_EfuseParseXtal_8188E(struct adapter *pAdapter, u8 *hwinfo, + bool AutoLoadFail); +void Hal_EfuseParseBoardType88E(struct adapter *pAdapter, u8 *hwinfo, + bool AutoLoadFail); +void Hal_ReadPowerSavingMode88E(struct adapter *pAdapter, u8 *hwinfo, + bool AutoLoadFail); + +bool HalDetectPwrDownMode88E(struct adapter *Adapter); + +void Hal_InitChannelPlan(struct adapter *padapter); +void rtl8188e_set_hal_ops(struct hal_ops *pHalFunc); + +/* register */ +void SetBcnCtrlReg(struct adapter *padapter, u8 SetBits, u8 ClearBits); + +void rtl8188e_clone_haldata(struct adapter *dst, struct adapter *src); +void rtl8188e_start_thread(struct adapter *padapter); +void rtl8188e_stop_thread(struct adapter *padapter); + +void rtw_IOL_cmd_tx_pkt_buf_dump(struct adapter *Adapter, int len); +s32 rtl8188e_iol_efuse_patch(struct adapter *padapter); +void rtw_cancel_all_timer(struct adapter *padapter); +void _ps_open_RF(struct adapter *adapt); + +#endif /* __RTL8188E_HAL_H__ */ diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_led.h b/drivers/staging/rtl8188eu/include/rtl8188e_led.h new file mode 100644 index 0000000000000..c0147e73cd8c1 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/rtl8188e_led.h @@ -0,0 +1,35 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __RTL8188E_LED_H__ +#define __RTL8188E_LED_H__ + +#include +#include + + +/* */ +/* Interface to manipulate LED objects. */ +/* */ +void rtl8188eu_InitSwLeds(struct adapter *padapter); +void rtl8188eu_DeInitSwLeds(struct adapter *padapter); +void SwLedOn(struct adapter *padapter, struct LED_871x *pLed); +void SwLedOff(struct adapter *padapter, struct LED_871x *pLed); + +#endif diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_recv.h b/drivers/staging/rtl8188eu/include/rtl8188e_recv.h new file mode 100644 index 0000000000000..02ccb404f53d2 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/rtl8188e_recv.h @@ -0,0 +1,69 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __RTL8188E_RECV_H__ +#define __RTL8188E_RECV_H__ + +#define TX_RPT1_PKT_LEN 8 + +#define RECV_BLK_SZ 512 +#define RECV_BLK_CNT 16 +#define RECV_BLK_TH RECV_BLK_CNT +#define RECV_BULK_IN_ADDR 0x80 +#define RECV_INT_IN_ADDR 0x81 + +#define NR_PREALLOC_RECV_SKB (8) + +#define NR_RECVBUFF (4) + +#define MAX_RECVBUF_SZ (15360) /* 15k < 16k */ + +struct phy_stat { + unsigned int phydw0; + unsigned int phydw1; + unsigned int phydw2; + unsigned int phydw3; + unsigned int phydw4; + unsigned int phydw5; + unsigned int phydw6; + unsigned int phydw7; +}; + +/* Rx smooth factor */ +#define Rx_Smooth_Factor (20) + +enum rx_packet_type { + NORMAL_RX,/* Normal rx packet */ + TX_REPORT1,/* CCX */ + TX_REPORT2,/* TX RPT */ + HIS_REPORT,/* USB HISR RPT */ +}; + +#define INTERRUPT_MSG_FORMAT_LEN 60 +void rtl8188eu_init_recvbuf(struct adapter *padapter, struct recv_buf *buf); +s32 rtl8188eu_init_recv_priv(struct adapter *padapter); +void rtl8188eu_free_recv_priv(struct adapter * padapter); +void rtl8188eu_recv_hdl(struct adapter * padapter, struct recv_buf *precvbuf); +void rtl8188eu_recv_tasklet(void *priv); +void rtl8188e_query_rx_phy_status(union recv_frame *fr, struct phy_stat *phy); +void rtl8188e_process_phy_info(struct adapter * padapter, void *prframe); +void update_recvframe_phyinfo_88e(union recv_frame *fra, struct phy_stat *phy); +void update_recvframe_attrib_88e(union recv_frame *fra, struct recv_stat *stat); + +#endif diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_rf.h b/drivers/staging/rtl8188eu/include/rtl8188e_rf.h new file mode 100644 index 0000000000000..10fc356e02095 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/rtl8188e_rf.h @@ -0,0 +1,36 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __RTL8188E_RF_H__ +#define __RTL8188E_RF_H__ + +#define RF6052_MAX_TX_PWR 0x3F +#define RF6052_MAX_REG 0x3F +#define RF6052_MAX_PATH 2 + + +int PHY_RF6052_Config8188E(struct adapter *Adapter); +void rtl8188e_RF_ChangeTxPath(struct adapter *Adapter, u16 DataRate); +void rtl8188e_PHY_RF6052SetBandwidth(struct adapter *Adapter, + enum ht_channel_width Bandwidth); +void rtl8188e_PHY_RF6052SetCckTxPower(struct adapter *Adapter, u8 *level); +void rtl8188e_PHY_RF6052SetOFDMTxPower(struct adapter *Adapter, u8 *ofdm, + u8 *pwrbw20, u8 *pwrbw40, u8 channel); + +#endif/* __RTL8188E_RF_H__ */ diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_spec.h b/drivers/staging/rtl8188eu/include/rtl8188e_spec.h new file mode 100644 index 0000000000000..c12c56b97343b --- /dev/null +++ b/drivers/staging/rtl8188eu/include/rtl8188e_spec.h @@ -0,0 +1,1439 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + *******************************************************************************/ +#ifndef __RTL8188E_SPEC_H__ +#define __RTL8188E_SPEC_H__ + +#ifndef BIT +#define BIT(x) (1 << (x)) +#endif + +#define BIT0 0x00000001 +#define BIT1 0x00000002 +#define BIT2 0x00000004 +#define BIT3 0x00000008 +#define BIT4 0x00000010 +#define BIT5 0x00000020 +#define BIT6 0x00000040 +#define BIT7 0x00000080 +#define BIT8 0x00000100 +#define BIT9 0x00000200 +#define BIT10 0x00000400 +#define BIT11 0x00000800 +#define BIT12 0x00001000 +#define BIT13 0x00002000 +#define BIT14 0x00004000 +#define BIT15 0x00008000 +#define BIT16 0x00010000 +#define BIT17 0x00020000 +#define BIT18 0x00040000 +#define BIT19 0x00080000 +#define BIT20 0x00100000 +#define BIT21 0x00200000 +#define BIT22 0x00400000 +#define BIT23 0x00800000 +#define BIT24 0x01000000 +#define BIT25 0x02000000 +#define BIT26 0x04000000 +#define BIT27 0x08000000 +#define BIT28 0x10000000 +#define BIT29 0x20000000 +#define BIT30 0x40000000 +#define BIT31 0x80000000 + +/* 8192C Regsiter offset definition */ + +#define HAL_PS_TIMER_INT_DELAY 50 /* 50 microseconds */ +#define HAL_92C_NAV_UPPER_UNIT 128 /* micro-second */ + +#define MAC_ADDR_LEN 6 +/* 8188E PKT_BUFF_ACCESS_CTRL value */ +#define TXPKT_BUF_SELECT 0x69 +#define RXPKT_BUF_SELECT 0xA5 +#define DISABLE_TRXPKT_BUF_ACCESS 0x0 + + +/* 0x0000h ~ 0x00FFh System Configuration */ +#define REG_SYS_ISO_CTRL 0x0000 +#define REG_SYS_FUNC_EN 0x0002 +#define REG_APS_FSMCO 0x0004 +#define REG_SYS_CLKR 0x0008 +#define REG_9346CR 0x000A +#define REG_EE_VPD 0x000C +#define REG_AFE_MISC 0x0010 +#define REG_SPS0_CTRL 0x0011 +#define REG_SPS_OCP_CFG 0x0018 +#define REG_RSV_CTRL 0x001C +#define REG_RF_CTRL 0x001F +#define REG_LDOA15_CTRL 0x0020 +#define REG_LDOV12D_CTRL 0x0021 +#define REG_LDOHCI12_CTRL 0x0022 +#define REG_LPLDO_CTRL 0x0023 +#define REG_AFE_XTAL_CTRL 0x0024 +#define REG_AFE_PLL_CTRL 0x0028 +#define REG_APE_PLL_CTRL_EXT 0x002c +#define REG_EFUSE_CTRL 0x0030 +#define REG_EFUSE_TEST 0x0034 +#define REG_GPIO_MUXCFG 0x0040 +#define REG_GPIO_IO_SEL 0x0042 +#define REG_MAC_PINMUX_CFG 0x0043 +#define REG_GPIO_PIN_CTRL 0x0044 +#define REG_GPIO_INTM 0x0048 +#define REG_LEDCFG0 0x004C +#define REG_LEDCFG1 0x004D +#define REG_LEDCFG2 0x004E +#define REG_LEDCFG3 0x004F +#define REG_FSIMR 0x0050 +#define REG_FSISR 0x0054 +#define REG_HSIMR 0x0058 +#define REG_HSISR 0x005c +#define REG_GPIO_PIN_CTRL_2 0x0060 /* RTL8723 WIFI/BT/GPS + * Multi-Function GPIO Pin Control. */ +#define REG_GPIO_IO_SEL_2 0x0062 /* RTL8723 WIFI/BT/GPS + * Multi-Function GPIO Select. */ +#define REG_BB_PAD_CTRL 0x0064 +#define REG_MULTI_FUNC_CTRL 0x0068 /* RTL8723 WIFI/BT/GPS + * Multi-Function control source. */ +#define REG_GPIO_OUTPUT 0x006c +#define REG_AFE_XTAL_CTRL_EXT 0x0078 /* RTL8188E */ +#define REG_XCK_OUT_CTRL 0x007c /* RTL8188E */ +#define REG_MCUFWDL 0x0080 +#define REG_WOL_EVENT 0x0081 /* RTL8188E */ +#define REG_MCUTSTCFG 0x0084 +#define REG_HMEBOX_E0 0x0088 +#define REG_HMEBOX_E1 0x008A +#define REG_HMEBOX_E2 0x008C +#define REG_HMEBOX_E3 0x008E +#define REG_HMEBOX_EXT_0 0x01F0 +#define REG_HMEBOX_EXT_1 0x01F4 +#define REG_HMEBOX_EXT_2 0x01F8 +#define REG_HMEBOX_EXT_3 0x01FC +#define REG_HIMR_88E 0x00B0 +#define REG_HISR_88E 0x00B4 +#define REG_HIMRE_88E 0x00B8 +#define REG_HISRE_88E 0x00BC +#define REG_EFUSE_ACCESS 0x00CF /* Efuse access protection + * for RTL8723 */ +#define REG_BIST_SCAN 0x00D0 +#define REG_BIST_RPT 0x00D4 +#define REG_BIST_ROM_RPT 0x00D8 +#define REG_USB_SIE_INTF 0x00E0 +#define REG_PCIE_MIO_INTF 0x00E4 +#define REG_PCIE_MIO_INTD 0x00E8 +#define REG_HPON_FSM 0x00EC +#define REG_SYS_CFG 0x00F0 +#define REG_GPIO_OUTSTS 0x00F4 /* For RTL8723 only. */ +#define REG_TYPE_ID 0x00FC + +#define REG_MAC_PHY_CTRL_NORMAL 0x00f8 + +/* 0x0100h ~ 0x01FFh MACTOP General Configuration */ +#define REG_CR 0x0100 +#define REG_PBP 0x0104 +#define REG_PKT_BUFF_ACCESS_CTRL 0x0106 +#define REG_TRXDMA_CTRL 0x010C +#define REG_TRXFF_BNDY 0x0114 +#define REG_TRXFF_STATUS 0x0118 +#define REG_RXFF_PTR 0x011C +/* define REG_HIMR 0x0120 */ +/* define REG_HISR 0x0124 */ +#define REG_HIMRE 0x0128 +#define REG_HISRE 0x012C +#define REG_CPWM 0x012F +#define REG_FWIMR 0x0130 +#define REG_FTIMR 0x0138 +#define REG_FWISR 0x0134 +#define REG_PKTBUF_DBG_CTRL 0x0140 +#define REG_PKTBUF_DBG_ADDR (REG_PKTBUF_DBG_CTRL) +#define REG_RXPKTBUF_DBG (REG_PKTBUF_DBG_CTRL+2) +#define REG_TXPKTBUF_DBG (REG_PKTBUF_DBG_CTRL+3) +#define REG_RXPKTBUF_CTRL (REG_PKTBUF_DBG_CTRL+2) +#define REG_PKTBUF_DBG_DATA_L 0x0144 +#define REG_PKTBUF_DBG_DATA_H 0x0148 + +#define REG_TC0_CTRL 0x0150 +#define REG_TC1_CTRL 0x0154 +#define REG_TC2_CTRL 0x0158 +#define REG_TC3_CTRL 0x015C +#define REG_TC4_CTRL 0x0160 +#define REG_TCUNIT_BASE 0x0164 +#define REG_MBIST_START 0x0174 +#define REG_MBIST_DONE 0x0178 +#define REG_MBIST_FAIL 0x017C +#define REG_32K_CTRL 0x0194 /* RTL8188E */ +#define REG_C2HEVT_MSG_NORMAL 0x01A0 +#define REG_C2HEVT_CLEAR 0x01AF +#define REG_MCUTST_1 0x01c0 +#define REG_FMETHR 0x01C8 +#define REG_HMETFR 0x01CC +#define REG_HMEBOX_0 0x01D0 +#define REG_HMEBOX_1 0x01D4 +#define REG_HMEBOX_2 0x01D8 +#define REG_HMEBOX_3 0x01DC + +#define REG_LLT_INIT 0x01E0 + +/* 0x0200h ~ 0x027Fh TXDMA Configuration */ +#define REG_RQPN 0x0200 +#define REG_FIFOPAGE 0x0204 +#define REG_TDECTRL 0x0208 +#define REG_TXDMA_OFFSET_CHK 0x020C +#define REG_TXDMA_STATUS 0x0210 +#define REG_RQPN_NPQ 0x0214 + +/* 0x0280h ~ 0x02FFh RXDMA Configuration */ +#define REG_RXDMA_AGG_PG_TH 0x0280 +#define REG_RXPKT_NUM 0x0284 +#define REG_RXDMA_STATUS 0x0288 + +/* 0x0300h ~ 0x03FFh PCIe */ +#define REG_PCIE_CTRL_REG 0x0300 +#define REG_INT_MIG 0x0304 /* Interrupt Migration */ +#define REG_BCNQ_DESA 0x0308 /* TX Beacon Descr Address */ +#define REG_HQ_DESA 0x0310 /* TX High Queue Descr Addr */ +#define REG_MGQ_DESA 0x0318 /* TX Manage Queue Descr Addr*/ +#define REG_VOQ_DESA 0x0320 /* TX VO Queue Descr Addr */ +#define REG_VIQ_DESA 0x0328 /* TX VI Queue Descr Addr */ +#define REG_BEQ_DESA 0x0330 /* TX BE Queue Descr Addr */ +#define REG_BKQ_DESA 0x0338 /* TX BK Queue Descr Addr */ +#define REG_RX_DESA 0x0340 /* RX Queue Descr Addr */ +#define REG_MDIO 0x0354 /* MDIO for Access PCIE PHY */ +#define REG_DBG_SEL 0x0360 /* Debug Selection Register */ +#define REG_PCIE_HRPWM 0x0361 /* PCIe RPWM */ +#define REG_PCIE_HCPWM 0x0363 /* PCIe CPWM */ +#define REG_WATCH_DOG 0x0368 + +/* RTL8723 series ------------------------------ */ +#define REG_PCIE_HISR 0x03A0 + +/* spec version 11 */ +/* 0x0400h ~ 0x047Fh Protocol Configuration */ +#define REG_VOQ_INFORMATION 0x0400 +#define REG_VIQ_INFORMATION 0x0404 +#define REG_BEQ_INFORMATION 0x0408 +#define REG_BKQ_INFORMATION 0x040C +#define REG_MGQ_INFORMATION 0x0410 +#define REG_HGQ_INFORMATION 0x0414 +#define REG_BCNQ_INFORMATION 0x0418 +#define REG_TXPKT_EMPTY 0x041A + +#define REG_CPU_MGQ_INFORMATION 0x041C +#define REG_FWHW_TXQ_CTRL 0x0420 +#define REG_HWSEQ_CTRL 0x0423 +#define REG_TXPKTBUF_BCNQ_BDNY 0x0424 +#define REG_TXPKTBUF_MGQ_BDNY 0x0425 +#define REG_LIFETIME_EN 0x0426 +#define REG_MULTI_BCNQ_OFFSET 0x0427 +#define REG_SPEC_SIFS 0x0428 +#define REG_RL 0x042A +#define REG_DARFRC 0x0430 +#define REG_RARFRC 0x0438 +#define REG_RRSR 0x0440 +#define REG_ARFR0 0x0444 +#define REG_ARFR1 0x0448 +#define REG_ARFR2 0x044C +#define REG_ARFR3 0x0450 +#define REG_AGGLEN_LMT 0x0458 +#define REG_AMPDU_MIN_SPACE 0x045C +#define REG_TXPKTBUF_WMAC_LBK_BF_HD 0x045D +#define REG_FAST_EDCA_CTRL 0x0460 +#define REG_RD_RESP_PKT_TH 0x0463 +#define REG_INIRTS_RATE_SEL 0x0480 +/* define REG_INIDATA_RATE_SEL 0x0484 */ +#define REG_POWER_STATUS 0x04A4 +#define REG_POWER_STAGE1 0x04B4 +#define REG_POWER_STAGE2 0x04B8 +#define REG_PKT_VO_VI_LIFE_TIME 0x04C0 +#define REG_PKT_BE_BK_LIFE_TIME 0x04C2 +#define REG_STBC_SETTING 0x04C4 +#define REG_PROT_MODE_CTRL 0x04C8 +#define REG_MAX_AGGR_NUM 0x04CA +#define REG_RTS_MAX_AGGR_NUM 0x04CB +#define REG_BAR_MODE_CTRL 0x04CC +#define REG_RA_TRY_RATE_AGG_LMT 0x04CF +#define REG_EARLY_MODE_CONTROL 0x4D0 +#define REG_NQOS_SEQ 0x04DC +#define REG_QOS_SEQ 0x04DE +#define REG_NEED_CPU_HANDLE 0x04E0 +#define REG_PKT_LOSE_RPT 0x04E1 +#define REG_PTCL_ERR_STATUS 0x04E2 +#define REG_TX_RPT_CTRL 0x04EC +#define REG_TX_RPT_TIME 0x04F0 /* 2 byte */ +#define REG_DUMMY 0x04FC + +/* 0x0500h ~ 0x05FFh EDCA Configuration */ +#define REG_EDCA_VO_PARAM 0x0500 +#define REG_EDCA_VI_PARAM 0x0504 +#define REG_EDCA_BE_PARAM 0x0508 +#define REG_EDCA_BK_PARAM 0x050C +#define REG_BCNTCFG 0x0510 +#define REG_PIFS 0x0512 +#define REG_RDG_PIFS 0x0513 +#define REG_SIFS_CTX 0x0514 +#define REG_SIFS_TRX 0x0516 +#define REG_TSFTR_SYN_OFFSET 0x0518 +#define REG_AGGR_BREAK_TIME 0x051A +#define REG_SLOT 0x051B +#define REG_TX_PTCL_CTRL 0x0520 +#define REG_TXPAUSE 0x0522 +#define REG_DIS_TXREQ_CLR 0x0523 +#define REG_RD_CTRL 0x0524 +/* Format for offset 540h-542h: */ +/* [3:0]: TBTT prohibit setup in unit of 32us. The time for HW getting + * beacon content before TBTT. */ +/* [7:4]: Reserved. */ +/* [19:8]: TBTT prohibit hold in unit of 32us. The time for HW holding + * to send the beacon packet. */ +/* [23:20]: Reserved */ +/* Description: */ +/* | */ +/* |<--Setup--|--Hold------------>| */ +/* --------------|---------------------- */ +/* | */ +/* TBTT */ +/* Note: We cannot update beacon content to HW or send any AC packets during + * the time between Setup and Hold. */ +#define REG_TBTT_PROHIBIT 0x0540 +#define REG_RD_NAV_NXT 0x0544 +#define REG_NAV_PROT_LEN 0x0546 +#define REG_BCN_CTRL 0x0550 +#define REG_BCN_CTRL_1 0x0551 +#define REG_MBID_NUM 0x0552 +#define REG_DUAL_TSF_RST 0x0553 +#define REG_BCN_INTERVAL 0x0554 +#define REG_DRVERLYINT 0x0558 +#define REG_BCNDMATIM 0x0559 +#define REG_ATIMWND 0x055A +#define REG_BCN_MAX_ERR 0x055D +#define REG_RXTSF_OFFSET_CCK 0x055E +#define REG_RXTSF_OFFSET_OFDM 0x055F +#define REG_TSFTR 0x0560 +#define REG_TSFTR1 0x0568 +#define REG_ATIMWND_1 0x0570 +#define REG_PSTIMER 0x0580 +#define REG_TIMER0 0x0584 +#define REG_TIMER1 0x0588 +#define REG_ACMHWCTRL 0x05C0 + +/* define REG_FW_TSF_SYNC_CNT 0x04A0 */ +#define REG_FW_RESET_TSF_CNT_1 0x05FC +#define REG_FW_RESET_TSF_CNT_0 0x05FD +#define REG_FW_BCN_DIS_CNT 0x05FE + +/* 0x0600h ~ 0x07FFh WMAC Configuration */ +#define REG_APSD_CTRL 0x0600 +#define REG_BWOPMODE 0x0603 +#define REG_TCR 0x0604 +#define REG_RCR 0x0608 +#define REG_RX_PKT_LIMIT 0x060C +#define REG_RX_DLK_TIME 0x060D +#define REG_RX_DRVINFO_SZ 0x060F + +#define REG_MACID 0x0610 +#define REG_BSSID 0x0618 +#define REG_MAR 0x0620 +#define REG_MBIDCAMCFG 0x0628 + +#define REG_USTIME_EDCA 0x0638 +#define REG_MAC_SPEC_SIFS 0x063A + +/* 20100719 Joseph: Hardware register definition change. (HW datasheet v54) */ +/* [15:8]SIFS_R2T_OFDM, [7:0]SIFS_R2T_CCK */ +#define REG_R2T_SIFS 0x063C +/* [15:8]SIFS_T2T_OFDM, [7:0]SIFS_T2T_CCK */ +#define REG_T2T_SIFS 0x063E +#define REG_ACKTO 0x0640 +#define REG_CTS2TO 0x0641 +#define REG_EIFS 0x0642 + +/* RXERR_RPT */ +#define RXERR_TYPE_OFDM_PPDU 0 +#define RXERR_TYPE_OFDM_false_ALARM 1 +#define RXERR_TYPE_OFDM_MPDU_OK 2 +#define RXERR_TYPE_OFDM_MPDU_FAIL 3 +#define RXERR_TYPE_CCK_PPDU 4 +#define RXERR_TYPE_CCK_false_ALARM 5 +#define RXERR_TYPE_CCK_MPDU_OK 6 +#define RXERR_TYPE_CCK_MPDU_FAIL 7 +#define RXERR_TYPE_HT_PPDU 8 +#define RXERR_TYPE_HT_false_ALARM 9 +#define RXERR_TYPE_HT_MPDU_TOTAL 10 +#define RXERR_TYPE_HT_MPDU_OK 11 +#define RXERR_TYPE_HT_MPDU_FAIL 12 +#define RXERR_TYPE_RX_FULL_DROP 15 + +#define RXERR_COUNTER_MASK 0xFFFFF +#define RXERR_RPT_RST BIT(27) +#define _RXERR_RPT_SEL(type) ((type) << 28) + +/* Note: */ +/* The NAV upper value is very important to WiFi 11n 5.2.3 NAV test. + * The default value is always too small, but the WiFi TestPlan test + * by 25,000 microseconds of NAV through sending CTS in the air. + * We must update this value greater than 25,000 microseconds to pass + * the item. The offset of NAV_UPPER in 8192C Spec is incorrect, and + * the offset should be 0x0652. */ +#define REG_NAV_UPPER 0x0652 /* unit of 128 */ + +/* WMA, BA, CCX */ +/* define REG_NAV_CTRL 0x0650 */ +#define REG_BACAMCMD 0x0654 +#define REG_BACAMCONTENT 0x0658 +#define REG_LBDLY 0x0660 +#define REG_FWDLY 0x0661 +#define REG_RXERR_RPT 0x0664 +#define REG_WMAC_TRXPTCL_CTL 0x0668 + +/* Security */ +#define REG_CAMCMD 0x0670 +#define REG_CAMWRITE 0x0674 +#define REG_CAMREAD 0x0678 +#define REG_CAMDBG 0x067C +#define REG_SECCFG 0x0680 + +/* Power */ +#define REG_WOW_CTRL 0x0690 +#define REG_PS_RX_INFO 0x0692 +#define REG_UAPSD_TID 0x0693 +#define REG_WKFMCAM_CMD 0x0698 +#define REG_WKFMCAM_NUM_88E 0x698 +#define REG_RXFLTMAP0 0x06A0 +#define REG_RXFLTMAP1 0x06A2 +#define REG_RXFLTMAP2 0x06A4 +#define REG_BCN_PSR_RPT 0x06A8 +#define REG_BT_COEX_TABLE 0x06C0 + +/* Hardware Port 2 */ +#define REG_MACID1 0x0700 +#define REG_BSSID1 0x0708 + +/* 0xFE00h ~ 0xFE55h USB Configuration */ +#define REG_USB_INFO 0xFE17 +#define REG_USB_SPECIAL_OPTION 0xFE55 +#define REG_USB_DMA_AGG_TO 0xFE5B +#define REG_USB_AGG_TO 0xFE5C +#define REG_USB_AGG_TH 0xFE5D + +/* For normal chip */ +#define REG_NORMAL_SIE_VID 0xFE60 /* 0xFE60~0xFE61 */ +#define REG_NORMAL_SIE_PID 0xFE62 /* 0xFE62~0xFE63 */ +#define REG_NORMAL_SIE_OPTIONAL 0xFE64 +#define REG_NORMAL_SIE_EP 0xFE65 /* 0xFE65~0xFE67 */ +#define REG_NORMAL_SIE_PHY 0xFE68 /* 0xFE68~0xFE6B */ +#define REG_NORMAL_SIE_OPTIONAL2 0xFE6C +#define REG_NORMAL_SIE_GPS_EP 0xFE6D /* 0xFE6D, for RTL8723 only. */ +#define REG_NORMAL_SIE_MAC_ADDR 0xFE70 /* 0xFE70~0xFE75 */ +#define REG_NORMAL_SIE_STRING 0xFE80 /* 0xFE80~0xFEDF */ + +/* TODO: use these definition when using REG_xxx naming rule. */ +/* NOTE: DO NOT Remove these definition. Use later. */ + +#define EFUSE_CTRL REG_EFUSE_CTRL /* E-Fuse Control. */ +#define EFUSE_TEST REG_EFUSE_TEST /* E-Fuse Test. */ +#define MSR (REG_CR + 2) /* Media Status reg */ +#define ISR REG_HISR_88E +/* Timing Sync Function Timer Register. */ +#define TSFR REG_TSFTR + +#define PBP REG_PBP + +/* Redifine MACID register, to compatible prior ICs. */ +/* MAC ID Register, Offset 0x0050-0x0053 */ +#define IDR0 REG_MACID +/* MAC ID Register, Offset 0x0054-0x0055 */ +#define IDR4 (REG_MACID + 4) + +/* 9. Security Control Registers (Offset: ) */ +/* IN 8190 Data Sheet is called CAMcmd */ +#define RWCAM REG_CAMCMD +/* Software write CAM input content */ +#define WCAMI REG_CAMWRITE +/* Software read/write CAM config */ +#define RCAMO REG_CAMREAD +#define CAMDBG REG_CAMDBG +/* Security Configuration Register */ +#define SECR REG_SECCFG + +/* Unused register */ +#define UnusedRegister 0x1BF +#define DCAM UnusedRegister +#define PSR UnusedRegister +#define BBAddr UnusedRegister +#define PhyDataR UnusedRegister + +/* Min Spacing related settings. */ +#define MAX_MSS_DENSITY_2T 0x13 +#define MAX_MSS_DENSITY_1T 0x0A + +/* EEPROM enable when set 1 */ +#define CmdEEPROM_En BIT5 +/* System EEPROM select, 0: boot from E-FUSE, 1: The EEPROM used is 9346 */ +#define CmdEERPOMSEL BIT4 +#define Cmd9346CR_9356SEL BIT4 + +/* 8192C GPIO MUX Configuration Register (offset 0x40, 4 byte) */ +#define GPIOSEL_GPIO 0 +#define GPIOSEL_ENBT BIT5 + +/* 8192C GPIO PIN Control Register (offset 0x44, 4 byte) */ +/* GPIO pins input value */ +#define GPIO_IN REG_GPIO_PIN_CTRL +/* GPIO pins output value */ +#define GPIO_OUT (REG_GPIO_PIN_CTRL+1) +/* GPIO pins output enable when a bit is set to "1"; otherwise, + * input is configured. */ +#define GPIO_IO_SEL (REG_GPIO_PIN_CTRL+2) +#define GPIO_MOD (REG_GPIO_PIN_CTRL+3) + +/* 8723/8188E Host System Interrupt Mask Register (offset 0x58, 32 byte) */ +#define HSIMR_GPIO12_0_INT_EN BIT0 +#define HSIMR_SPS_OCP_INT_EN BIT5 +#define HSIMR_RON_INT_EN BIT6 +#define HSIMR_PDN_INT_EN BIT7 +#define HSIMR_GPIO9_INT_EN BIT25 + +/* 8723/8188E Host System Interrupt Status Register (offset 0x5C, 32 byte) */ +#define HSISR_GPIO12_0_INT BIT0 +#define HSISR_SPS_OCP_INT BIT5 +#define HSISR_RON_INT_EN BIT6 +#define HSISR_PDNINT BIT7 +#define HSISR_GPIO9_INT BIT25 + +/* 8192C (MSR) Media Status Register (Offset 0x4C, 8 bits) */ +/* +Network Type +00: No link +01: Link in ad hoc network +10: Link in infrastructure network +11: AP mode +Default: 00b. +*/ +#define MSR_NOLINK 0x00 +#define MSR_ADHOC 0x01 +#define MSR_INFRA 0x02 +#define MSR_AP 0x03 + +/* 88EU (MSR) Media Status Register (Offset 0x4C, 8 bits) */ +#define USB_INTR_CONTENT_C2H_OFFSET 0 +#define USB_INTR_CONTENT_CPWM1_OFFSET 16 +#define USB_INTR_CONTENT_CPWM2_OFFSET 20 +#define USB_INTR_CONTENT_HISR_OFFSET 48 +#define USB_INTR_CONTENT_HISRE_OFFSET 52 + +/* 88E Driver Initialization Offload REG_FDHM0(Offset 0x88, 8 bits) */ +/* IOL config for REG_FDHM0(Reg0x88) */ +#define CMD_INIT_LLT BIT0 +#define CMD_READ_EFUSE_MAP BIT1 +#define CMD_EFUSE_PATCH BIT2 +#define CMD_IOCONFIG BIT3 +#define CMD_INIT_LLT_ERR BIT4 +#define CMD_READ_EFUSE_MAP_ERR BIT5 +#define CMD_EFUSE_PATCH_ERR BIT6 +#define CMD_IOCONFIG_ERR BIT7 + +/* 6. Adaptive Control Registers (Offset: 0x0160 - 0x01CF) */ +/* 8192C Response Rate Set Register (offset 0x181, 24bits) */ +#define RRSR_1M BIT0 +#define RRSR_2M BIT1 +#define RRSR_5_5M BIT2 +#define RRSR_11M BIT3 +#define RRSR_6M BIT4 +#define RRSR_9M BIT5 +#define RRSR_12M BIT6 +#define RRSR_18M BIT7 +#define RRSR_24M BIT8 +#define RRSR_36M BIT9 +#define RRSR_48M BIT10 +#define RRSR_54M BIT11 +#define RRSR_MCS0 BIT12 +#define RRSR_MCS1 BIT13 +#define RRSR_MCS2 BIT14 +#define RRSR_MCS3 BIT15 +#define RRSR_MCS4 BIT16 +#define RRSR_MCS5 BIT17 +#define RRSR_MCS6 BIT18 +#define RRSR_MCS7 BIT19 + +/* 8192C Response Rate Set Register (offset 0x1BF, 8bits) */ +/* WOL bit information */ +#define HAL92C_WOL_PTK_UPDATE_EVENT BIT0 +#define HAL92C_WOL_GTK_UPDATE_EVENT BIT1 + +/* 8192C BW_OPMODE bits (Offset 0x203, 8bit) */ +#define BW_OPMODE_20MHZ BIT2 +#define BW_OPMODE_5G BIT1 + +/* 8192C CAM Config Setting (offset 0x250, 1 byte) */ +#define CAM_VALID BIT15 +#define CAM_NOTVALID 0x0000 +#define CAM_USEDK BIT5 + +#define CAM_CONTENT_COUNT 8 + +#define CAM_NONE 0x0 +#define CAM_WEP40 0x01 +#define CAM_TKIP 0x02 +#define CAM_AES 0x04 +#define CAM_WEP104 0x05 +#define CAM_SMS4 0x6 + +#define TOTAL_CAM_ENTRY 32 +#define HALF_CAM_ENTRY 16 + +#define CAM_CONFIG_USEDK true +#define CAM_CONFIG_NO_USEDK false + +#define CAM_WRITE BIT16 +#define CAM_READ 0x00000000 +#define CAM_POLLINIG BIT31 + +#define SCR_UseDK 0x01 +#define SCR_TxSecEnable 0x02 +#define SCR_RxSecEnable 0x04 + +/* 10. Power Save Control Registers (Offset: 0x0260 - 0x02DF) */ +#define WOW_PMEN BIT0 /* Power management Enable. */ +#define WOW_WOMEN BIT1 /* WoW function on or off. */ +#define WOW_MAGIC BIT2 /* Magic packet */ +#define WOW_UWF BIT3 /* Unicast Wakeup frame. */ + +/* 12. Host Interrupt Status Registers (Offset: 0x0300 - 0x030F) */ +/* 8188 IMR/ISR bits */ +#define IMR_DISABLED_88E 0x0 +/* IMR DW0(0x0060-0063) Bit 0-31 */ +#define IMR_TXCCK_88E BIT30 /* TXRPT interrupt when CCX bit of the packet is set */ +#define IMR_PSTIMEOUT_88E BIT29 /* Power Save Time Out Interrupt */ +#define IMR_GTINT4_88E BIT28 /* When GTIMER4 expires, this bit is set to 1 */ +#define IMR_GTINT3_88E BIT27 /* When GTIMER3 expires, this bit is set to 1 */ +#define IMR_TBDER_88E BIT26 /* Transmit Beacon0 Error */ +#define IMR_TBDOK_88E BIT25 /* Transmit Beacon0 OK */ +#define IMR_TSF_BIT32_TOGGLE_88E BIT24 /* TSF Timer BIT32 toggle indication interrupt */ +#define IMR_BCNDMAINT0_88E BIT20 /* Beacon DMA Interrupt 0 */ +#define IMR_BCNDERR0_88E BIT16 /* Beacon Queue DMA Error 0 */ +#define IMR_HSISR_IND_ON_INT_88E BIT15 /* HSISR Indicator (HSIMR & HSISR is true, this bit is set to 1) */ +#define IMR_BCNDMAINT_E_88E BIT14 /* Beacon DMA Interrupt Extension for Win7 */ +#define IMR_ATIMEND_88E BIT12 /* CTWidnow End or ATIM Window End */ +#define IMR_HISR1_IND_INT_88E BIT11 /* HISR1 Indicator (HISR1 & HIMR1 is true, this bit is set to 1) */ +#define IMR_C2HCMD_88E BIT10 /* CPU to Host Command INT Status, Write 1 clear */ +#define IMR_CPWM2_88E BIT9 /* CPU power Mode exchange INT Status, Write 1 clear */ +#define IMR_CPWM_88E BIT8 /* CPU power Mode exchange INT Status, Write 1 clear */ +#define IMR_HIGHDOK_88E BIT7 /* High Queue DMA OK */ +#define IMR_MGNTDOK_88E BIT6 /* Management Queue DMA OK */ +#define IMR_BKDOK_88E BIT5 /* AC_BK DMA OK */ +#define IMR_BEDOK_88E BIT4 /* AC_BE DMA OK */ +#define IMR_VIDOK_88E BIT3 /* AC_VI DMA OK */ +#define IMR_VODOK_88E BIT2 /* AC_VO DMA OK */ +#define IMR_RDU_88E BIT1 /* Rx Descriptor Unavailable */ +#define IMR_ROK_88E BIT0 /* Receive DMA OK */ + +/* IMR DW1(0x00B4-00B7) Bit 0-31 */ +#define IMR_BCNDMAINT7_88E BIT27 /* Beacon DMA Interrupt 7 */ +#define IMR_BCNDMAINT6_88E BIT26 /* Beacon DMA Interrupt 6 */ +#define IMR_BCNDMAINT5_88E BIT25 /* Beacon DMA Interrupt 5 */ +#define IMR_BCNDMAINT4_88E BIT24 /* Beacon DMA Interrupt 4 */ +#define IMR_BCNDMAINT3_88E BIT23 /* Beacon DMA Interrupt 3 */ +#define IMR_BCNDMAINT2_88E BIT22 /* Beacon DMA Interrupt 2 */ +#define IMR_BCNDMAINT1_88E BIT21 /* Beacon DMA Interrupt 1 */ +#define IMR_BCNDERR7_88E BIT20 /* Beacon DMA Error Int 7 */ +#define IMR_BCNDERR6_88E BIT19 /* Beacon DMA Error Int 6 */ +#define IMR_BCNDERR5_88E BIT18 /* Beacon DMA Error Int 5 */ +#define IMR_BCNDERR4_88E BIT17 /* Beacon DMA Error Int 4 */ +#define IMR_BCNDERR3_88E BIT16 /* Beacon DMA Error Int 3 */ +#define IMR_BCNDERR2_88E BIT15 /* Beacon DMA Error Int 2 */ +#define IMR_BCNDERR1_88E BIT14 /* Beacon DMA Error Int 1 */ +#define IMR_ATIMEND_E_88E BIT13 /* ATIM Window End Ext for Win7 */ +#define IMR_TXERR_88E BIT11 /* Tx Err Flag Int Status, write 1 clear. */ +#define IMR_RXERR_88E BIT10 /* Rx Err Flag INT Status, Write 1 clear */ +#define IMR_TXFOVW_88E BIT9 /* Transmit FIFO Overflow */ +#define IMR_RXFOVW_88E BIT8 /* Receive FIFO Overflow */ + +#define HAL_NIC_UNPLUG_ISR 0xFFFFFFFF /* The value when the NIC is unplugged for PCI. */ + +/* 8192C EFUSE */ +#define HWSET_MAX_SIZE 256 +#define HWSET_MAX_SIZE_88E 512 + +/*=================================================================== +===================================================================== +Here the register defines are for 92C. When the define is as same with 92C, +we will use the 92C's define for the consistency +So the following defines for 92C is not entire!!!!!! +===================================================================== +=====================================================================*/ +/* +Based on Datasheet V33---090401 +Register Summary +Current IOREG MAP +0x0000h ~ 0x00FFh System Configuration (256 Bytes) +0x0100h ~ 0x01FFh MACTOP General Configuration (256 Bytes) +0x0200h ~ 0x027Fh TXDMA Configuration (128 Bytes) +0x0280h ~ 0x02FFh RXDMA Configuration (128 Bytes) +0x0300h ~ 0x03FFh PCIE EMAC Reserved Region (256 Bytes) +0x0400h ~ 0x04FFh Protocol Configuration (256 Bytes) +0x0500h ~ 0x05FFh EDCA Configuration (256 Bytes) +0x0600h ~ 0x07FFh WMAC Configuration (512 Bytes) +0x2000h ~ 0x3FFFh 8051 FW Download Region (8196 Bytes) +*/ +/* 8192C (TXPAUSE) transmission pause (Offset 0x522, 8 bits) */ +/* Note: */ +/* The bits of stopping AC(VO/VI/BE/BK) queue in datasheet + * RTL8192S/RTL8192C are wrong, */ +/* the correct arragement is VO - Bit0, VI - Bit1, BE - Bit2, + * and BK - Bit3. */ +/* 8723 and 88E may be not correct either in the earlier version. */ +#define StopBecon BIT6 +#define StopHigh BIT5 +#define StopMgt BIT4 +#define StopBK BIT3 +#define StopBE BIT2 +#define StopVI BIT1 +#define StopVO BIT0 + +/* 8192C (RCR) Receive Configuration Register(Offset 0x608, 32 bits) */ +#define RCR_APPFCS BIT31 /* WMAC append FCS after payload */ +#define RCR_APP_MIC BIT30 +#define RCR_APP_PHYSTS BIT28 +#define RCR_APP_ICV BIT29 +#define RCR_APP_PHYST_RXFF BIT28 +#define RCR_APP_BA_SSN BIT27 /* Accept BA SSN */ +#define RCR_ENMBID BIT24 /* Enable Multiple BssId. */ +#define RCR_LSIGEN BIT23 +#define RCR_MFBEN BIT22 +#define RCR_HTC_LOC_CTRL BIT14 /* MFC<--HTC=1 MFC-->HTC=0 */ +#define RCR_AMF BIT13 /* Accept management type frame */ +#define RCR_ACF BIT12 /* Accept control type frame */ +#define RCR_ADF BIT11 /* Accept data type frame */ +#define RCR_AICV BIT9 /* Accept ICV error packet */ +#define RCR_ACRC32 BIT8 /* Accept CRC32 error packet */ +#define RCR_CBSSID_BCN BIT7 /* Accept BSSID match packet + * (Rx beacon, probe rsp) */ +#define RCR_CBSSID_DATA BIT6 /* Accept BSSID match (Data)*/ +#define RCR_CBSSID RCR_CBSSID_DATA /* Accept BSSID match */ +#define RCR_APWRMGT BIT5 /* Accept power management pkt*/ +#define RCR_ADD3 BIT4 /* Accept address 3 match pkt */ +#define RCR_AB BIT3 /* Accept broadcast packet */ +#define RCR_AM BIT2 /* Accept multicast packet */ +#define RCR_APM BIT1 /* Accept physical match pkt */ +#define RCR_AAP BIT0 /* Accept all unicast packet */ +#define RCR_MXDMA_OFFSET 8 +#define RCR_FIFO_OFFSET 13 + +/* 0xFE00h ~ 0xFE55h USB Configuration */ +#define REG_USB_INFO 0xFE17 +#define REG_USB_SPECIAL_OPTION 0xFE55 +#define REG_USB_DMA_AGG_TO 0xFE5B +#define REG_USB_AGG_TO 0xFE5C +#define REG_USB_AGG_TH 0xFE5D + +#define REG_USB_HRPWM 0xFE58 +#define REG_USB_HCPWM 0xFE57 +/* 8192C Regsiter Bit and Content definition */ +/* 0x0000h ~ 0x00FFh System Configuration */ + +/* 2 SYS_ISO_CTRL */ +#define ISO_MD2PP BIT(0) +#define ISO_UA2USB BIT(1) +#define ISO_UD2CORE BIT(2) +#define ISO_PA2PCIE BIT(3) +#define ISO_PD2CORE BIT(4) +#define ISO_IP2MAC BIT(5) +#define ISO_DIOP BIT(6) +#define ISO_DIOE BIT(7) +#define ISO_EB2CORE BIT(8) +#define ISO_DIOR BIT(9) +#define PWC_EV12V BIT(15) + +/* 2 SYS_FUNC_EN */ +#define FEN_BBRSTB BIT(0) +#define FEN_BB_GLB_RSTn BIT(1) +#define FEN_USBA BIT(2) +#define FEN_UPLL BIT(3) +#define FEN_USBD BIT(4) +#define FEN_DIO_PCIE BIT(5) +#define FEN_PCIEA BIT(6) +#define FEN_PPLL BIT(7) +#define FEN_PCIED BIT(8) +#define FEN_DIOE BIT(9) +#define FEN_CPUEN BIT(10) +#define FEN_DCORE BIT(11) +#define FEN_ELDR BIT(12) +#define FEN_DIO_RF BIT(13) +#define FEN_HWPDN BIT(14) +#define FEN_MREGEN BIT(15) + +/* 2 APS_FSMCO */ +#define PFM_LDALL BIT(0) +#define PFM_ALDN BIT(1) +#define PFM_LDKP BIT(2) +#define PFM_WOWL BIT(3) +#define EnPDN BIT(4) +#define PDN_PL BIT(5) +#define APFM_ONMAC BIT(8) +#define APFM_OFF BIT(9) +#define APFM_RSM BIT(10) +#define AFSM_HSUS BIT(11) +#define AFSM_PCIE BIT(12) +#define APDM_MAC BIT(13) +#define APDM_HOST BIT(14) +#define APDM_HPDN BIT(15) +#define RDY_MACON BIT(16) +#define SUS_HOST BIT(17) +#define ROP_ALD BIT(20) +#define ROP_PWR BIT(21) +#define ROP_SPS BIT(22) +#define SOP_MRST BIT(25) +#define SOP_FUSE BIT(26) +#define SOP_ABG BIT(27) +#define SOP_AMB BIT(28) +#define SOP_RCK BIT(29) +#define SOP_A8M BIT(30) +#define XOP_BTCK BIT(31) + +/* 2 SYS_CLKR */ +#define ANAD16V_EN BIT(0) +#define ANA8M BIT(1) +#define MACSLP BIT(4) +#define LOADER_CLK_EN BIT(5) + +/* 2 9346CR */ + +#define BOOT_FROM_EEPROM BIT(4) +#define EEPROM_EN BIT(5) + +/* 2 SPS0_CTRL */ + +/* 2 SPS_OCP_CFG */ + +/* 2 RF_CTRL */ +#define RF_EN BIT(0) +#define RF_RSTB BIT(1) +#define RF_SDMRSTB BIT(2) + +/* 2 LDOV12D_CTRL */ +#define LDV12_EN BIT(0) +#define LDV12_SDBY BIT(1) +#define LPLDO_HSM BIT(2) +#define LPLDO_LSM_DIS BIT(3) +#define _LDV12_VADJ(x) (((x) & 0xF) << 4) + +/* 2EFUSE_CTRL */ +#define ALD_EN BIT(18) +#define EF_PD BIT(19) +#define EF_FLAG BIT(31) + +/* 2 EFUSE_TEST (For RTL8723 partially) */ +#define EF_TRPT BIT(7) +/* 00: Wifi Efuse, 01: BT Efuse0, 10: BT Efuse1, 11: BT Efuse2 */ +#define EF_CELL_SEL (BIT(8)|BIT(9)) +#define LDOE25_EN BIT(31) +#define EFUSE_SEL(x) (((x) & 0x3) << 8) +#define EFUSE_SEL_MASK 0x300 +#define EFUSE_WIFI_SEL_0 0x0 +#define EFUSE_BT_SEL_0 0x1 +#define EFUSE_BT_SEL_1 0x2 +#define EFUSE_BT_SEL_2 0x3 + +#define EFUSE_ACCESS_ON 0x69 /* For RTL8723 only. */ +#define EFUSE_ACCESS_OFF 0x00 /* For RTL8723 only. */ + +/* 2 8051FWDL */ +/* 2 MCUFWDL */ +#define MCUFWDL_EN BIT(0) +#define MCUFWDL_RDY BIT(1) +#define FWDL_ChkSum_rpt BIT(2) +#define MACINI_RDY BIT(3) +#define BBINI_RDY BIT(4) +#define RFINI_RDY BIT(5) +#define WINTINI_RDY BIT(6) +#define RAM_DL_SEL BIT(7) /* 1:RAM, 0:ROM */ +#define ROM_DLEN BIT(19) +#define CPRST BIT(23) + +/* 2 REG_SYS_CFG */ +#define XCLK_VLD BIT(0) +#define ACLK_VLD BIT(1) +#define UCLK_VLD BIT(2) +#define PCLK_VLD BIT(3) +#define PCIRSTB BIT(4) +#define V15_VLD BIT(5) +#define SW_OFFLOAD_EN BIT(7) +#define SIC_IDLE BIT(8) +#define BD_MAC2 BIT(9) +#define BD_MAC1 BIT(10) +#define IC_MACPHY_MODE BIT(11) +#define CHIP_VER (BIT(12)|BIT(13)|BIT(14)|BIT(15)) +#define BT_FUNC BIT(16) +#define VENDOR_ID BIT(19) +#define PAD_HWPD_IDN BIT(22) +#define TRP_VAUX_EN BIT(23) /* RTL ID */ +#define TRP_BT_EN BIT(24) +#define BD_PKG_SEL BIT(25) +#define BD_HCI_SEL BIT(26) +#define TYPE_ID BIT(27) + +#define CHIP_VER_RTL_MASK 0xF000 /* Bit 12 ~ 15 */ +#define CHIP_VER_RTL_SHIFT 12 + +/* 2REG_GPIO_OUTSTS (For RTL8723 only) */ +#define EFS_HCI_SEL (BIT(0)|BIT(1)) +#define PAD_HCI_SEL (BIT(2)|BIT(3)) +#define HCI_SEL (BIT(4)|BIT(5)) +#define PKG_SEL_HCI BIT(6) +#define FEN_GPS BIT(7) +#define FEN_BT BIT(8) +#define FEN_WL BIT(9) +#define FEN_PCI BIT(10) +#define FEN_USB BIT(11) +#define BTRF_HWPDN_N BIT(12) +#define WLRF_HWPDN_N BIT(13) +#define PDN_BT_N BIT(14) +#define PDN_GPS_N BIT(15) +#define BT_CTL_HWPDN BIT(16) +#define GPS_CTL_HWPDN BIT(17) +#define PPHY_SUSB BIT(20) +#define UPHY_SUSB BIT(21) +#define PCI_SUSEN BIT(22) +#define USB_SUSEN BIT(23) +#define RF_RL_ID (BIT(31)|BIT(30)|BIT(29)|BIT(28)) + +/* 2SYS_CFG */ +#define RTL_ID BIT(23) /* TestChip ID, 1:Test(RLE); 0:MP(RL) */ + +/* 0x0100h ~ 0x01FFh MACTOP General Configuration */ + +/* 2 Function Enable Registers */ +/* 2 CR */ + +#define HCI_TXDMA_EN BIT(0) +#define HCI_RXDMA_EN BIT(1) +#define TXDMA_EN BIT(2) +#define RXDMA_EN BIT(3) +#define PROTOCOL_EN BIT(4) +#define SCHEDULE_EN BIT(5) +#define MACTXEN BIT(6) +#define MACRXEN BIT(7) +#define ENSWBCN BIT(8) +#define ENSEC BIT(9) +#define CALTMR_EN BIT(10) /* 32k CAL TMR enable */ + +/* Network type */ +#define _NETTYPE(x) (((x) & 0x3) << 16) +#define MASK_NETTYPE 0x30000 +#define NT_NO_LINK 0x0 +#define NT_LINK_AD_HOC 0x1 +#define NT_LINK_AP 0x2 +#define NT_AS_AP 0x3 + +/* 2 PBP - Page Size Register */ +#define GET_RX_PAGE_SIZE(value) ((value) & 0xF) +#define GET_TX_PAGE_SIZE(value) (((value) & 0xF0) >> 4) +#define _PSRX_MASK 0xF +#define _PSTX_MASK 0xF0 +#define _PSRX(x) (x) +#define _PSTX(x) ((x) << 4) + +#define PBP_64 0x0 +#define PBP_128 0x1 +#define PBP_256 0x2 +#define PBP_512 0x3 +#define PBP_1024 0x4 + +/* 2 TX/RXDMA */ +#define RXDMA_ARBBW_EN BIT(0) +#define RXSHFT_EN BIT(1) +#define RXDMA_AGG_EN BIT(2) +#define QS_VO_QUEUE BIT(8) +#define QS_VI_QUEUE BIT(9) +#define QS_BE_QUEUE BIT(10) +#define QS_BK_QUEUE BIT(11) +#define QS_MANAGER_QUEUE BIT(12) +#define QS_HIGH_QUEUE BIT(13) + +#define HQSEL_VOQ BIT(0) +#define HQSEL_VIQ BIT(1) +#define HQSEL_BEQ BIT(2) +#define HQSEL_BKQ BIT(3) +#define HQSEL_MGTQ BIT(4) +#define HQSEL_HIQ BIT(5) + +/* For normal driver, 0x10C */ +#define _TXDMA_HIQ_MAP(x) (((x)&0x3) << 14) +#define _TXDMA_MGQ_MAP(x) (((x)&0x3) << 12) +#define _TXDMA_BKQ_MAP(x) (((x)&0x3) << 10) +#define _TXDMA_BEQ_MAP(x) (((x)&0x3) << 8 ) +#define _TXDMA_VIQ_MAP(x) (((x)&0x3) << 6 ) +#define _TXDMA_VOQ_MAP(x) (((x)&0x3) << 4 ) + +#define QUEUE_LOW 1 +#define QUEUE_NORMAL 2 +#define QUEUE_HIGH 3 + +/* 2 TRXFF_BNDY */ + +/* 2 LLT_INIT */ +#define _LLT_NO_ACTIVE 0x0 +#define _LLT_WRITE_ACCESS 0x1 +#define _LLT_READ_ACCESS 0x2 + +#define _LLT_INIT_DATA(x) ((x) & 0xFF) +#define _LLT_INIT_ADDR(x) (((x) & 0xFF) << 8) +#define _LLT_OP(x) (((x) & 0x3) << 30) +#define _LLT_OP_VALUE(x) (((x) >> 30) & 0x3) + +/* 0x0200h ~ 0x027Fh TXDMA Configuration */ +/* 2RQPN */ +#define _HPQ(x) ((x) & 0xFF) +#define _LPQ(x) (((x) & 0xFF) << 8) +#define _PUBQ(x) (((x) & 0xFF) << 16) +/* NOTE: in RQPN_NPQ register */ +#define _NPQ(x) ((x) & 0xFF) + +#define HPQ_PUBLIC_DIS BIT(24) +#define LPQ_PUBLIC_DIS BIT(25) +#define LD_RQPN BIT(31) + +/* 2TDECTRL */ +#define BCN_VALID BIT(16) +#define BCN_HEAD(x) (((x) & 0xFF) << 8) +#define BCN_HEAD_MASK 0xFF00 + +/* 2 TDECTL */ +#define BLK_DESC_NUM_SHIFT 4 +#define BLK_DESC_NUM_MASK 0xF + +/* 2 TXDMA_OFFSET_CHK */ +#define DROP_DATA_EN BIT(9) + +/* 0x0280h ~ 0x028Bh RX DMA Configuration */ + +/* REG_RXDMA_CONTROL, 0x0286h */ + +/* 2 REG_RXPKT_NUM, 0x0284 */ +#define RXPKT_RELEASE_POLL BIT(16) +#define RXDMA_IDLE BIT(17) +#define RW_RELEASE_EN BIT(18) + +/* 0x0400h ~ 0x047Fh Protocol Configuration */ +/* 2 FWHW_TXQ_CTRL */ +#define EN_AMPDU_RTY_NEW BIT(7) + +/* 2 SPEC SIFS */ +#define _SPEC_SIFS_CCK(x) ((x) & 0xFF) +#define _SPEC_SIFS_OFDM(x) (((x) & 0xFF) << 8) + +/* 2 RL */ +#define RETRY_LIMIT_SHORT_SHIFT 8 +#define RETRY_LIMIT_LONG_SHIFT 0 + +/* 0x0500h ~ 0x05FFh EDCA Configuration */ + +/* 2 EDCA setting */ +#define AC_PARAM_TXOP_LIMIT_OFFSET 16 +#define AC_PARAM_ECW_MAX_OFFSET 12 +#define AC_PARAM_ECW_MIN_OFFSET 8 +#define AC_PARAM_AIFS_OFFSET 0 + +#define _LRL(x) ((x) & 0x3F) +#define _SRL(x) (((x) & 0x3F) << 8) + +/* 2 BCN_CTRL */ +#define EN_MBSSID BIT(1) +#define EN_TXBCN_RPT BIT(2) +#define EN_BCN_FUNCTION BIT(3) +#define DIS_TSF_UPDATE BIT(3) + +/* The same function but different bit field. */ +#define DIS_TSF_UDT0_NORMAL_CHIP BIT(4) +#define DIS_TSF_UDT0_TEST_CHIP BIT(5) +#define STOP_BCNQ BIT(6) + +/* 2 ACMHWCTRL */ +#define AcmHw_HwEn BIT(0) +#define AcmHw_BeqEn BIT(1) +#define AcmHw_ViqEn BIT(2) +#define AcmHw_VoqEn BIT(3) +#define AcmHw_BeqStatus BIT(4) +#define AcmHw_ViqStatus BIT(5) +#define AcmHw_VoqStatus BIT(6) + +/* 0x0600h ~ 0x07FFh WMAC Configuration */ +/* 2APSD_CTRL */ +#define APSDOFF BIT(6) +#define APSDOFF_STATUS BIT(7) + +#define RATE_BITMAP_ALL 0xFFFFF + +/* Only use CCK 1M rate for ACK */ +#define RATE_RRSR_CCK_ONLY_1M 0xFFFF1 + +/* 2 TCR */ +#define TSFRST BIT(0) +#define DIS_GCLK BIT(1) +#define PAD_SEL BIT(2) +#define PWR_ST BIT(6) +#define PWRBIT_OW_EN BIT(7) +#define ACRC BIT(8) +#define CFENDFORM BIT(9) +#define ICV BIT(10) + +/* 2 RCR */ +#define AAP BIT(0) +#define APM BIT(1) +#define AM BIT(2) +#define AB BIT(3) +#define ADD3 BIT(4) +#define APWRMGT BIT(5) +#define CBSSID BIT(6) +#define CBSSID_DATA BIT(6) +#define CBSSID_BCN BIT(7) +#define ACRC32 BIT(8) +#define AICV BIT(9) +#define ADF BIT(11) +#define ACF BIT(12) +#define AMF BIT(13) +#define HTC_LOC_CTRL BIT(14) +#define UC_DATA_EN BIT(16) +#define BM_DATA_EN BIT(17) +#define MFBEN BIT(22) +#define LSIGEN BIT(23) +#define EnMBID BIT(24) +#define APP_BASSN BIT(27) +#define APP_PHYSTS BIT(28) +#define APP_ICV BIT(29) +#define APP_MIC BIT(30) +#define APP_FCS BIT(31) + +/* 2 SECCFG */ +#define SCR_TxUseDK BIT(0) /* Force Tx Use Default Key */ +#define SCR_RxUseDK BIT(1) /* Force Rx Use Default Key */ +#define SCR_TxEncEnable BIT(2) /* Enable Tx Encryption */ +#define SCR_RxDecEnable BIT(3) /* Enable Rx Decryption */ +#define SCR_SKByA2 BIT(4) /* Search kEY BY A2 */ +#define SCR_NoSKMC BIT(5) /* No Key Search Multicast */ +#define SCR_TXBCUSEDK BIT(6) /* Force Tx Bcast pkt Use Default Key */ +#define SCR_RXBCUSEDK BIT(7) /* Force Rx Bcast pkt Use Default Key */ + +/* RTL8188E SDIO Configuration */ + +/* I/O bus domain address mapping */ +#define SDIO_LOCAL_BASE 0x10250000 +#define WLAN_IOREG_BASE 0x10260000 +#define FIRMWARE_FIFO_BASE 0x10270000 +#define TX_HIQ_BASE 0x10310000 +#define TX_MIQ_BASE 0x10320000 +#define TX_LOQ_BASE 0x10330000 +#define RX_RX0FF_BASE 0x10340000 + +/* SDIO host local register space mapping. */ +#define SDIO_LOCAL_MSK 0x0FFF +#define WLAN_IOREG_MSK 0x7FFF +#define WLAN_FIFO_MSK 0x1FFF /* Aggregation Length[12:0] */ +#define WLAN_RX0FF_MSK 0x0003 + +/* Without ref to the SDIO Device ID */ +#define SDIO_WITHOUT_REF_DEVICE_ID 0 +#define SDIO_LOCAL_DEVICE_ID 0 /* 0b[16], 000b[15:13] */ +#define WLAN_TX_HIQ_DEVICE_ID 4 /* 0b[16], 100b[15:13] */ +#define WLAN_TX_MIQ_DEVICE_ID 5 /* 0b[16], 101b[15:13] */ +#define WLAN_TX_LOQ_DEVICE_ID 6 /* 0b[16], 110b[15:13] */ +#define WLAN_RX0FF_DEVICE_ID 7 /* 0b[16], 111b[15:13] */ +#define WLAN_IOREG_DEVICE_ID 8 /* 1b[16] */ + +/* SDIO Tx Free Page Index */ +#define HI_QUEUE_IDX 0 +#define MID_QUEUE_IDX 1 +#define LOW_QUEUE_IDX 2 +#define PUBLIC_QUEUE_IDX 3 + +#define SDIO_MAX_TX_QUEUE 3 /* HIQ, MIQ and LOQ */ +#define SDIO_MAX_RX_QUEUE 1 + +/* SDIO Tx Control */ +#define SDIO_REG_TX_CTRL 0x0000 +/* SDIO Host Interrupt Mask */ +#define SDIO_REG_HIMR 0x0014 +/* SDIO Host Interrupt Service Routine */ +#define SDIO_REG_HISR 0x0018 +/* HCI Current Power Mode */ +#define SDIO_REG_HCPWM 0x0019 +/* RXDMA Request Length */ +#define SDIO_REG_RX0_REQ_LEN 0x001C +/* Free Tx Buffer Page */ +#define SDIO_REG_FREE_TXPG 0x0020 +/* HCI Current Power Mode 1 */ +#define SDIO_REG_HCPWM1 0x0024 +/* HCI Current Power Mode 2 */ +#define SDIO_REG_HCPWM2 0x0026 +/* HTSF Informaion */ +#define SDIO_REG_HTSFR_INFO 0x0030 +/* HCI Request Power Mode 1 */ +#define SDIO_REG_HRPWM1 0x0080 +/* HCI Request Power Mode 2 */ +#define SDIO_REG_HRPWM2 0x0082 +/* HCI Power Save Clock */ +#define SDIO_REG_HPS_CLKR 0x0084 +/* SDIO HCI Suspend Control */ +#define SDIO_REG_HSUS_CTRL 0x0086 +/* SDIO Host Extension Interrupt Mask Always */ +#define SDIO_REG_HIMR_ON 0x0090 +/* SDIO Host Extension Interrupt Status Always */ +#define SDIO_REG_HISR_ON 0x0091 + +#define SDIO_HIMR_DISABLED 0 + +/* RTL8188E SDIO Host Interrupt Mask Register */ +#define SDIO_HIMR_RX_REQUEST_MSK BIT0 +#define SDIO_HIMR_AVAL_MSK BIT1 +#define SDIO_HIMR_TXERR_MSK BIT2 +#define SDIO_HIMR_RXERR_MSK BIT3 +#define SDIO_HIMR_TXFOVW_MSK BIT4 +#define SDIO_HIMR_RXFOVW_MSK BIT5 +#define SDIO_HIMR_TXBCNOK_MSK BIT6 +#define SDIO_HIMR_TXBCNERR_MSK BIT7 +#define SDIO_HIMR_BCNERLY_INT_MSK BIT16 +#define SDIO_HIMR_C2HCMD_MSK BIT17 +#define SDIO_HIMR_CPWM1_MSK BIT18 +#define SDIO_HIMR_CPWM2_MSK BIT19 +#define SDIO_HIMR_HSISR_IND_MSK BIT20 +#define SDIO_HIMR_GTINT3_IND_MSK BIT21 +#define SDIO_HIMR_GTINT4_IND_MSK BIT22 +#define SDIO_HIMR_PSTIMEOUT_MSK BIT23 +#define SDIO_HIMR_OCPINT_MSK BIT24 +#define SDIO_HIMR_ATIMEND_MSK BIT25 +#define SDIO_HIMR_ATIMEND_E_MSK BIT26 +#define SDIO_HIMR_CTWEND_MSK BIT27 + +/* RTL8188E SDIO Specific */ +#define SDIO_HIMR_MCU_ERR_MSK BIT28 +#define SDIO_HIMR_TSF_BIT32_TOGGLE_MSK BIT29 + +/* SDIO Host Interrupt Service Routine */ +#define SDIO_HISR_RX_REQUEST BIT0 +#define SDIO_HISR_AVAL BIT1 +#define SDIO_HISR_TXERR BIT2 +#define SDIO_HISR_RXERR BIT3 +#define SDIO_HISR_TXFOVW BIT4 +#define SDIO_HISR_RXFOVW BIT5 +#define SDIO_HISR_TXBCNOK BIT6 +#define SDIO_HISR_TXBCNERR BIT7 +#define SDIO_HISR_BCNERLY_INT BIT16 +#define SDIO_HISR_C2HCMD BIT17 +#define SDIO_HISR_CPWM1 BIT18 +#define SDIO_HISR_CPWM2 BIT19 +#define SDIO_HISR_HSISR_IND BIT20 +#define SDIO_HISR_GTINT3_IND BIT21 +#define SDIO_HISR_GTINT4_IND BIT22 +#define SDIO_HISR_PSTIME BIT23 +#define SDIO_HISR_OCPINT BIT24 +#define SDIO_HISR_ATIMEND BIT25 +#define SDIO_HISR_ATIMEND_E BIT26 +#define SDIO_HISR_CTWEND BIT27 + +/* RTL8188E SDIO Specific */ +#define SDIO_HISR_MCU_ERR BIT28 +#define SDIO_HISR_TSF_BIT32_TOGGLE BIT29 + +#define MASK_SDIO_HISR_CLEAR \ + (SDIO_HISR_TXERR | SDIO_HISR_RXERR | SDIO_HISR_TXFOVW |\ + SDIO_HISR_RXFOVW | SDIO_HISR_TXBCNOK | SDIO_HISR_TXBCNERR |\ + SDIO_HISR_C2HCMD | SDIO_HISR_CPWM1 | SDIO_HISR_CPWM2 |\ + SDIO_HISR_HSISR_IND | SDIO_HISR_GTINT3_IND | SDIO_HISR_GTINT4_IND |\ + SDIO_HISR_PSTIMEOUT | SDIO_HISR_OCPINT) + +/* SDIO HCI Suspend Control Register */ +#define HCI_RESUME_PWR_RDY BIT1 +#define HCI_SUS_CTRL BIT0 + +/* SDIO Tx FIFO related */ +/* The number of Tx FIFO free page */ +#define SDIO_TX_FREE_PG_QUEUE 4 +#define SDIO_TX_FIFO_PAGE_SZ 128 + +/* 0xFE00h ~ 0xFE55h USB Configuration */ + +/* 2 USB Information (0xFE17) */ +#define USB_IS_HIGH_SPEED 0 +#define USB_IS_FULL_SPEED 1 +#define USB_SPEED_MASK BIT(5) + +#define USB_NORMAL_SIE_EP_MASK 0xF +#define USB_NORMAL_SIE_EP_SHIFT 4 + +/* 2 Special Option */ +#define USB_AGG_EN BIT(3) + +/* 0; Use interrupt endpoint to upload interrupt pkt */ +/* 1; Use bulk endpoint to upload interrupt pkt, */ +#define INT_BULK_SEL BIT(4) + +/* 2REG_C2HEVT_CLEAR */ +/* Set by driver and notify FW that the driver has read + * the C2H command message */ +#define C2H_EVT_HOST_CLOSE 0x00 +/* Set by FW indicating that FW had set the C2H command + * message and it's not yet read by driver. */ +#define C2H_EVT_FW_CLOSE 0xFF + +/* 2REG_MULTI_FUNC_CTRL(For RTL8723 Only) */ +/* Enable GPIO[9] as WiFi HW PDn source */ +#define WL_HWPDN_EN BIT0 +/* WiFi HW PDn polarity control */ +#define WL_HWPDN_SL BIT1 +/* WiFi function enable */ +#define WL_FUNC_EN BIT2 +/* Enable GPIO[9] as WiFi RF HW PDn source */ +#define WL_HWROF_EN BIT3 +/* Enable GPIO[11] as BT HW PDn source */ +#define BT_HWPDN_EN BIT16 +/* BT HW PDn polarity control */ +#define BT_HWPDN_SL BIT17 +/* BT function enable */ +#define BT_FUNC_EN BIT18 +/* Enable GPIO[11] as BT/GPS RF HW PDn source */ +#define BT_HWROF_EN BIT19 +/* Enable GPIO[10] as GPS HW PDn source */ +#define GPS_HWPDN_EN BIT20 +/* GPS HW PDn polarity control */ +#define GPS_HWPDN_SL BIT21 +/* GPS function enable */ +#define GPS_FUNC_EN BIT22 + +/* 3 REG_LIFECTRL_CTRL */ +#define HAL92C_EN_PKT_LIFE_TIME_BK BIT3 +#define HAL92C_EN_PKT_LIFE_TIME_BE BIT2 +#define HAL92C_EN_PKT_LIFE_TIME_VI BIT1 +#define HAL92C_EN_PKT_LIFE_TIME_VO BIT0 + +#define HAL92C_MSDU_LIFE_TIME_UNIT 128 /* in us */ + +/* General definitions */ +#define LAST_ENTRY_OF_TX_PKT_BUFFER 176 /* 22k 22528 bytes */ + +#define POLLING_LLT_THRESHOLD 20 +#define POLLING_READY_TIMEOUT_COUNT 1000 +/* GPIO BIT */ +#define HAL_8192C_HW_GPIO_WPS_BIT BIT2 + +/* 8192C EEPROM/EFUSE share register definition. */ + +/* EEPROM/Efuse PG Offset for 88EE/88EU/88ES */ +#define EEPROM_TX_PWR_INX_88E 0x10 + +#define EEPROM_ChannelPlan_88E 0xB8 +#define EEPROM_XTAL_88E 0xB9 +#define EEPROM_THERMAL_METER_88E 0xBA +#define EEPROM_IQK_LCK_88E 0xBB + +#define EEPROM_RF_BOARD_OPTION_88E 0xC1 +#define EEPROM_RF_FEATURE_OPTION_88E 0xC2 +#define EEPROM_RF_BT_SETTING_88E 0xC3 +#define EEPROM_VERSION_88E 0xC4 +#define EEPROM_CUSTOMERID_88E 0xC5 +#define EEPROM_RF_ANTENNA_OPT_88E 0xC9 + +/* RTL88EE */ +#define EEPROM_MAC_ADDR_88EE 0xD0 +#define EEPROM_VID_88EE 0xD6 +#define EEPROM_DID_88EE 0xD8 +#define EEPROM_SVID_88EE 0xDA +#define EEPROM_SMID_88EE 0xDC + +/* RTL88EU */ +#define EEPROM_MAC_ADDR_88EU 0xD7 +#define EEPROM_VID_88EU 0xD0 +#define EEPROM_PID_88EU 0xD2 +#define EEPROM_USB_OPTIONAL_FUNCTION0 0xD4 + +/* RTL88ES */ +#define EEPROM_MAC_ADDR_88ES 0x11A + +/* EEPROM/Efuse Value Type */ +#define EETYPE_TX_PWR 0x0 + +/* Default Value for EEPROM or EFUSE!!! */ +#define EEPROM_Default_TSSI 0x0 +#define EEPROM_Default_TxPowerDiff 0x0 +#define EEPROM_Default_CrystalCap 0x5 +/* Default: 2X2, RTL8192CE(QFPN68) */ +#define EEPROM_Default_BoardType 0x02 +#define EEPROM_Default_TxPower 0x1010 +#define EEPROM_Default_HT2T_TxPwr 0x10 + +#define EEPROM_Default_LegacyHTTxPowerDiff 0x3 +#define EEPROM_Default_ThermalMeter 0x12 + +#define EEPROM_Default_AntTxPowerDiff 0x0 +#define EEPROM_Default_TxPwDiff_CrystalCap 0x5 +#define EEPROM_Default_TxPowerLevel 0x2A + +#define EEPROM_Default_HT40_2SDiff 0x0 +/* HT20<->40 default Tx Power Index Difference */ +#define EEPROM_Default_HT20_Diff 2 +#define EEPROM_Default_LegacyHTTxPowerDiff 0x3 +#define EEPROM_Default_HT40_PwrMaxOffset 0 +#define EEPROM_Default_HT20_PwrMaxOffset 0 + +#define EEPROM_Default_CrystalCap_88E 0x20 +#define EEPROM_Default_ThermalMeter_88E 0x18 + +/* New EFUSE deafult value */ +#define EEPROM_DEFAULT_24G_INDEX 0x2D +#define EEPROM_DEFAULT_24G_HT20_DIFF 0X02 +#define EEPROM_DEFAULT_24G_OFDM_DIFF 0X04 + +#define EEPROM_DEFAULT_5G_INDEX 0X2A +#define EEPROM_DEFAULT_5G_HT20_DIFF 0X00 +#define EEPROM_DEFAULT_5G_OFDM_DIFF 0X04 + +#define EEPROM_DEFAULT_DIFF 0XFE +#define EEPROM_DEFAULT_CHANNEL_PLAN 0x7F +#define EEPROM_DEFAULT_BOARD_OPTION 0x00 +#define EEPROM_DEFAULT_FEATURE_OPTION 0x00 +#define EEPROM_DEFAULT_BT_OPTION 0x10 + +/* For debug */ +#define EEPROM_Default_PID 0x1234 +#define EEPROM_Default_VID 0x5678 +#define EEPROM_Default_CustomerID 0xAB +#define EEPROM_Default_CustomerID_8188E 0x00 +#define EEPROM_Default_SubCustomerID 0xCD +#define EEPROM_Default_Version 0 + +#define EEPROM_CHANNEL_PLAN_FCC 0x0 +#define EEPROM_CHANNEL_PLAN_IC 0x1 +#define EEPROM_CHANNEL_PLAN_ETSI 0x2 +#define EEPROM_CHANNEL_PLAN_SPA 0x3 +#define EEPROM_CHANNEL_PLAN_FRANCE 0x4 +#define EEPROM_CHANNEL_PLAN_MKK 0x5 +#define EEPROM_CHANNEL_PLAN_MKK1 0x6 +#define EEPROM_CHANNEL_PLAN_ISRAEL 0x7 +#define EEPROM_CHANNEL_PLAN_TELEC 0x8 +#define EEPROM_CHANNEL_PLAN_GLOBAL_DOMA 0x9 +#define EEPROM_CHANNEL_PLAN_WORLD_WIDE_13 0xA +#define EEPROM_CHANNEL_PLAN_NCC 0xB +#define EEPROM_USB_OPTIONAL1 0xE +#define EEPROM_CHANNEL_PLAN_BY_HW_MASK 0x80 + +#define EEPROM_CID_DEFAULT 0x0 +#define EEPROM_CID_TOSHIBA 0x4 +#define EEPROM_CID_CCX 0x10 /* CCX test. */ +#define EEPROM_CID_QMI 0x0D +#define EEPROM_CID_WHQL 0xFE +#define RTL_EEPROM_ID 0x8129 + +#endif /* __RTL8188E_SPEC_H__ */ diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_sreset.h b/drivers/staging/rtl8188eu/include/rtl8188e_sreset.h new file mode 100644 index 0000000000000..a29e695197941 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/rtl8188e_sreset.h @@ -0,0 +1,31 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef _RTL8188E_SRESET_H_ +#define _RTL8188E_SRESET_H_ + +#include +#include +#include + +void rtl8188e_silentreset_for_specific_platform(struct adapter *padapter); +void rtl8188e_sreset_xmit_status_check(struct adapter *padapter); +void rtl8188e_sreset_linked_status_check(struct adapter *padapter); + +#endif diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_xmit.h b/drivers/staging/rtl8188eu/include/rtl8188e_xmit.h new file mode 100644 index 0000000000000..cf7267a53659c --- /dev/null +++ b/drivers/staging/rtl8188eu/include/rtl8188e_xmit.h @@ -0,0 +1,178 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __RTL8188E_XMIT_H__ +#define __RTL8188E_XMIT_H__ + +#define MAX_TX_AGG_PACKET_NUMBER 0xFF +/* */ +/* Queue Select Value in TxDesc */ +/* */ +#define QSLT_BK 0x2/* 0x01 */ +#define QSLT_BE 0x0 +#define QSLT_VI 0x5/* 0x4 */ +#define QSLT_VO 0x7/* 0x6 */ +#define QSLT_BEACON 0x10 +#define QSLT_HIGH 0x11 +#define QSLT_MGNT 0x12 +#define QSLT_CMD 0x13 + +/* For 88e early mode */ +#define SET_EARLYMODE_PKTNUM(__pAddr, __Value) \ + SET_BITS_TO_LE_4BYTE(__pAddr, 0, 3, __Value) +#define SET_EARLYMODE_LEN0(__pAddr, __Value) \ + SET_BITS_TO_LE_4BYTE(__pAddr, 4, 12, __Value) +#define SET_EARLYMODE_LEN1(__pAddr, __Value) \ + SET_BITS_TO_LE_4BYTE(__pAddr, 16, 12, __Value) +#define SET_EARLYMODE_LEN2_1(__pAddr, __Value) \ + SET_BITS_TO_LE_4BYTE(__pAddr, 28, 4, __Value) +#define SET_EARLYMODE_LEN2_2(__pAddr, __Value) \ + SET_BITS_TO_LE_4BYTE(__pAddr+4, 0, 8, __Value) +#define SET_EARLYMODE_LEN3(__pAddr, __Value) \ + SET_BITS_TO_LE_4BYTE(__pAddr+4, 8, 12, __Value) +#define SET_EARLYMODE_LEN4(__pAddr, __Value) \ + SET_BITS_TO_LE_4BYTE(__pAddr+4, 20, 12, __Value) + +/* */ +/* defined for TX DESC Operation */ +/* */ + +#define MAX_TID (15) + +/* OFFSET 0 */ +#define OFFSET_SZ 0 +#define OFFSET_SHT 16 +#define BMC BIT(24) +#define LSG BIT(26) +#define FSG BIT(27) +#define OWN BIT(31) + + +/* OFFSET 4 */ +#define PKT_OFFSET_SZ 0 +#define QSEL_SHT 8 +#define RATE_ID_SHT 16 +#define NAVUSEHDR BIT(20) +#define SEC_TYPE_SHT 22 +#define PKT_OFFSET_SHT 26 + +/* OFFSET 8 */ +#define AGG_EN BIT(12) +#define AGG_BK BIT(16) +#define AMPDU_DENSITY_SHT 20 +#define ANTSEL_A BIT(24) +#define ANTSEL_B BIT(25) +#define TX_ANT_CCK_SHT 26 +#define TX_ANTL_SHT 28 +#define TX_ANT_HT_SHT 30 + +/* OFFSET 12 */ +#define SEQ_SHT 16 +#define EN_HWSEQ BIT(31) + +/* OFFSET 16 */ +#define QOS BIT(6) +#define HW_SSN BIT(7) +#define USERATE BIT(8) +#define DISDATAFB BIT(10) +#define CTS_2_SELF BIT(11) +#define RTS_EN BIT(12) +#define HW_RTS_EN BIT(13) +#define DATA_SHORT BIT(24) +#define PWR_STATUS_SHT 15 +#define DATA_SC_SHT 20 +#define DATA_BW BIT(25) + +/* OFFSET 20 */ +#define RTY_LMT_EN BIT(17) + +enum TXDESC_SC { + SC_DONT_CARE = 0x00, + SC_UPPER = 0x01, + SC_LOWER = 0x02, + SC_DUPLICATE = 0x03 +}; +/* OFFSET 20 */ +#define SGI BIT(6) +#define USB_TXAGG_NUM_SHT 24 + +#define txdesc_set_ccx_sw_88e(txdesc, value) \ + do { \ + ((struct txdesc_88e *)(txdesc))->sw1 = (((value)>>8) & 0x0f); \ + ((struct txdesc_88e *)(txdesc))->sw0 = ((value) & 0xff); \ + } while (0) + +struct txrpt_ccx_88e { + /* offset 0 */ + u8 tag1:1; + u8 pkt_num:3; + u8 txdma_underflow:1; + u8 int_bt:1; + u8 int_tri:1; + u8 int_ccx:1; + + /* offset 1 */ + u8 mac_id:6; + u8 pkt_ok:1; + u8 bmc:1; + + /* offset 2 */ + u8 retry_cnt:6; + u8 lifetime_over:1; + u8 retry_over:1; + + /* offset 3 */ + u8 ccx_qtime0; + u8 ccx_qtime1; + + /* offset 5 */ + u8 final_data_rate; + + /* offset 6 */ + u8 sw1:4; + u8 qsel:4; + + /* offset 7 */ + u8 sw0; +}; + +#define txrpt_ccx_sw_88e(txrpt_ccx) ((txrpt_ccx)->sw0 + ((txrpt_ccx)->sw1<<8)) +#define txrpt_ccx_qtime_88e(txrpt_ccx) \ + ((txrpt_ccx)->ccx_qtime0+((txrpt_ccx)->ccx_qtime1<<8)) + +void rtl8188e_fill_fake_txdesc(struct adapter *padapter, u8 *pDesc, + u32 BufferLen, u8 IsPsPoll, u8 IsBTQosNull); +s32 rtl8188eu_init_xmit_priv(struct adapter *padapter); +void rtl8188eu_free_xmit_priv(struct adapter *padapter); +s32 rtl8188eu_hal_xmit(struct adapter *padapter, struct xmit_frame *frame); +s32 rtl8188eu_mgnt_xmit(struct adapter *padapter, struct xmit_frame *frame); +s32 rtl8188eu_xmit_buf_handler(struct adapter *padapter); +#define hal_xmit_handler rtl8188eu_xmit_buf_handler +void rtl8188eu_xmit_tasklet(void *priv); +s32 rtl8188eu_xmitframe_complete(struct adapter *padapter, + struct xmit_priv *pxmitpriv, + struct xmit_buf *pxmitbuf); + +void dump_txrpt_ccx_88e(void *buf); +void handle_txrpt_ccx_88e(struct adapter *adapter, u8 *buf); + +void _dbg_dump_tx_info(struct adapter *padapter, int frame_tag, + struct tx_desc *ptxdesc); + +#endif /* __RTL8188E_XMIT_H__ */ -- GitLab From 475b922e84a96e25f778a6178b33c21a84a827fc Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 21 Aug 2013 22:34:08 -0500 Subject: [PATCH 784/942] staging: r8188eu: Add files for new driver - part 26 This commit adds files include/rtw_android.h, include/rtw_ap.h, include/rtw_br_ext.h, include/rtw_cmd.h, include/rtw_debug.h, include/rtw_eeprom.h, include/rtw_efuse.h, and include/rtw_event.h. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8188eu/include/rtw_android.h | 64 ++ drivers/staging/rtl8188eu/include/rtw_ap.h | 65 ++ .../staging/rtl8188eu/include/rtw_br_ext.h | 66 ++ drivers/staging/rtl8188eu/include/rtw_cmd.h | 991 ++++++++++++++++++ drivers/staging/rtl8188eu/include/rtw_debug.h | 290 +++++ .../staging/rtl8188eu/include/rtw_eeprom.h | 130 +++ drivers/staging/rtl8188eu/include/rtw_efuse.h | 150 +++ drivers/staging/rtl8188eu/include/rtw_event.h | 115 ++ 8 files changed, 1871 insertions(+) create mode 100644 drivers/staging/rtl8188eu/include/rtw_android.h create mode 100644 drivers/staging/rtl8188eu/include/rtw_ap.h create mode 100644 drivers/staging/rtl8188eu/include/rtw_br_ext.h create mode 100644 drivers/staging/rtl8188eu/include/rtw_cmd.h create mode 100644 drivers/staging/rtl8188eu/include/rtw_debug.h create mode 100644 drivers/staging/rtl8188eu/include/rtw_eeprom.h create mode 100644 drivers/staging/rtl8188eu/include/rtw_efuse.h create mode 100644 drivers/staging/rtl8188eu/include/rtw_event.h diff --git a/drivers/staging/rtl8188eu/include/rtw_android.h b/drivers/staging/rtl8188eu/include/rtw_android.h new file mode 100644 index 0000000000000..e85bf1ff01f89 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/rtw_android.h @@ -0,0 +1,64 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#ifndef __RTW_ANDROID_H__ +#define __RTW_ANDROID_H__ + +#include +#include + +enum ANDROID_WIFI_CMD { + ANDROID_WIFI_CMD_START, + ANDROID_WIFI_CMD_STOP, + ANDROID_WIFI_CMD_SCAN_ACTIVE, + ANDROID_WIFI_CMD_SCAN_PASSIVE, + ANDROID_WIFI_CMD_RSSI, + ANDROID_WIFI_CMD_LINKSPEED, + ANDROID_WIFI_CMD_RXFILTER_START, + ANDROID_WIFI_CMD_RXFILTER_STOP, + ANDROID_WIFI_CMD_RXFILTER_ADD, + ANDROID_WIFI_CMD_RXFILTER_REMOVE, + ANDROID_WIFI_CMD_BTCOEXSCAN_START, + ANDROID_WIFI_CMD_BTCOEXSCAN_STOP, + ANDROID_WIFI_CMD_BTCOEXMODE, + ANDROID_WIFI_CMD_SETSUSPENDOPT, + ANDROID_WIFI_CMD_P2P_DEV_ADDR, + ANDROID_WIFI_CMD_SETFWPATH, + ANDROID_WIFI_CMD_SETBAND, + ANDROID_WIFI_CMD_GETBAND, + ANDROID_WIFI_CMD_COUNTRY, + ANDROID_WIFI_CMD_P2P_SET_NOA, + ANDROID_WIFI_CMD_P2P_GET_NOA, + ANDROID_WIFI_CMD_P2P_SET_PS, + ANDROID_WIFI_CMD_SET_AP_WPS_P2P_IE, + ANDROID_WIFI_CMD_MACADDR, + ANDROID_WIFI_CMD_BLOCK, + ANDROID_WIFI_CMD_WFD_ENABLE, + ANDROID_WIFI_CMD_WFD_DISABLE, + ANDROID_WIFI_CMD_WFD_SET_TCPPORT, + ANDROID_WIFI_CMD_WFD_SET_MAX_TPUT, + ANDROID_WIFI_CMD_WFD_SET_DEVTYPE, + ANDROID_WIFI_CMD_MAX +}; + +int rtw_android_cmdstr_to_num(char *cmdstr); +int rtw_android_priv_cmd(struct net_device *net, struct ifreq *ifr, int cmd); + +#endif /* __RTW_ANDROID_H__ */ diff --git a/drivers/staging/rtl8188eu/include/rtw_ap.h b/drivers/staging/rtl8188eu/include/rtw_ap.h new file mode 100644 index 0000000000000..9233401597988 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/rtw_ap.h @@ -0,0 +1,65 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __RTW_AP_H_ +#define __RTW_AP_H_ + +#include +#include + +#ifdef CONFIG_88EU_AP_MODE + +/* external function */ +void rtw_indicate_sta_assoc_event(struct adapter *padapter, + struct sta_info *psta); +void rtw_indicate_sta_disassoc_event(struct adapter *padapter, + struct sta_info *psta); +void init_mlme_ap_info(struct adapter *padapter); +void free_mlme_ap_info(struct adapter *padapter); +void rtw_add_bcn_ie(struct adapter *padapter, struct wlan_bssid_ex *pnetwork, + u8 index, u8 *data, u8 len); +void rtw_remove_bcn_ie(struct adapter *padapter, + struct wlan_bssid_ex *pnetwork, u8 index); +void update_beacon(struct adapter *padapter, u8 ie_id, + u8 *oui, u8 tx); +void add_RATid(struct adapter *padapter, struct sta_info *psta, + u8 rssi_level); +void expire_timeout_chk(struct adapter *padapter); +void update_sta_info_apmode(struct adapter *padapter, struct sta_info *psta); +int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len); +void rtw_set_macaddr_acl(struct adapter *padapter, int mode); +int rtw_acl_add_sta(struct adapter *padapter, u8 *addr); +int rtw_acl_remove_sta(struct adapter *padapter, u8 *addr); + +#ifdef CONFIG_88EU_AP_MODE +void associated_clients_update(struct adapter *padapter, u8 updated); +void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta); +u8 bss_cap_update_on_sta_leave(struct adapter *padapter, struct sta_info *psta); +void sta_info_update(struct adapter *padapter, struct sta_info *psta); +void ap_sta_info_defer_update(struct adapter *padapter, struct sta_info *psta); +u8 ap_free_sta(struct adapter *padapter, struct sta_info *psta, + bool active, u16 reason); +int rtw_sta_flush(struct adapter *padapter); +int rtw_ap_inform_ch_switch(struct adapter *padapter, u8 new_ch, u8 ch_offset); +void start_ap_mode(struct adapter *padapter); +void stop_ap_mode(struct adapter *padapter); +#endif +#endif /* end of CONFIG_88EU_AP_MODE */ + +#endif diff --git a/drivers/staging/rtl8188eu/include/rtw_br_ext.h b/drivers/staging/rtl8188eu/include/rtw_br_ext.h new file mode 100644 index 0000000000000..f21e7a4515d0e --- /dev/null +++ b/drivers/staging/rtl8188eu/include/rtw_br_ext.h @@ -0,0 +1,66 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef _RTW_BR_EXT_H_ +#define _RTW_BR_EXT_H_ + +#define MACADDRLEN 6 +#define _DEBUG_ERR DBG_88E +#define _DEBUG_INFO DBG_88E +#define DEBUG_WARN DBG_88E +#define DEBUG_INFO DBG_88E +#define DEBUG_ERR DBG_88E +#define GET_MY_HWADDR(padapter) ((padapter)->eeprompriv.mac_addr) + +#define NAT25_HASH_BITS 4 +#define NAT25_HASH_SIZE (1 << NAT25_HASH_BITS) +#define NAT25_AGEING_TIME 300 + +#define MAX_NETWORK_ADDR_LEN 17 + +struct nat25_network_db_entry { + struct nat25_network_db_entry *next_hash; + struct nat25_network_db_entry **pprev_hash; + atomic_t use_count; + unsigned char macAddr[6]; + unsigned long ageing_timer; + unsigned char networkAddr[MAX_NETWORK_ADDR_LEN]; +}; + +enum NAT25_METHOD { + NAT25_MIN, + NAT25_CHECK, + NAT25_INSERT, + NAT25_LOOKUP, + NAT25_PARSE, + NAT25_MAX +}; + +struct br_ext_info { + unsigned int nat25_disable; + unsigned int macclone_enable; + unsigned int dhcp_bcst_disable; + int addPPPoETag; /* 1: Add PPPoE relay-SID, 0: disable */ + unsigned char nat25_dmzMac[MACADDRLEN]; + unsigned int nat25sc_disable; +}; + +void nat25_db_cleanup(struct adapter *priv); + +#endif /* _RTW_BR_EXT_H_ */ diff --git a/drivers/staging/rtl8188eu/include/rtw_cmd.h b/drivers/staging/rtl8188eu/include/rtw_cmd.h new file mode 100644 index 0000000000000..819285b9a7814 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/rtw_cmd.h @@ -0,0 +1,991 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __RTW_CMD_H_ +#define __RTW_CMD_H_ + +#include +#include +#include + +#define C2H_MEM_SZ (16*1024) + +#include +#include /* */ + +#define FREE_CMDOBJ_SZ 128 + +#define MAX_CMDSZ 1024 +#define MAX_RSPSZ 512 +#define MAX_EVTSZ 1024 + +#define CMDBUFF_ALIGN_SZ 512 + +struct cmd_obj { + struct adapter *padapter; + u16 cmdcode; + u8 res; + u8 *parmbuf; + u32 cmdsz; + u8 *rsp; + u32 rspsz; + struct list_head list; +}; + +struct cmd_priv { + struct semaphore cmd_queue_sema; + struct semaphore terminate_cmdthread_sema; + struct __queue cmd_queue; + u8 cmd_seq; + u8 *cmd_buf; /* shall be non-paged, and 4 bytes aligned */ + u8 *cmd_allocated_buf; + u8 *rsp_buf; /* shall be non-paged, and 4 bytes aligned */ + u8 *rsp_allocated_buf; + u32 cmd_issued_cnt; + u32 cmd_done_cnt; + u32 rsp_cnt; + u8 cmdthd_running; + struct adapter *padapter; +}; + +struct evt_priv { + struct work_struct c2h_wk; + bool c2h_wk_alive; + struct rtw_cbuf *c2h_queue; + #define C2H_QUEUE_MAX_LEN 10 + ATOMIC_T event_seq; + u8 *evt_buf; /* shall be non-paged, and 4 bytes aligned */ + u8 *evt_allocated_buf; + u32 evt_done_cnt; +}; + +#define init_h2fwcmd_w_parm_no_rsp(pcmd, pparm, code) \ +do {\ + _rtw_init_listhead(&pcmd->list);\ + pcmd->cmdcode = code;\ + pcmd->parmbuf = (u8 *)(pparm);\ + pcmd->cmdsz = sizeof(*pparm);\ + pcmd->rsp = NULL;\ + pcmd->rspsz = 0;\ +} while (0) + +struct c2h_evt_hdr { + u8 id:4; + u8 plen:4; + u8 seq; + u8 payload[0]; +}; + +#define c2h_evt_exist(c2h_evt) ((c2h_evt)->id || (c2h_evt)->plen) + +u32 rtw_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *obj); +struct cmd_obj *rtw_dequeue_cmd(struct cmd_priv *pcmdpriv); +void rtw_free_cmd_obj(struct cmd_obj *pcmd); + +int rtw_cmd_thread(void *context); + +u32 rtw_init_cmd_priv(struct cmd_priv *pcmdpriv); +void rtw_free_cmd_priv(struct cmd_priv *pcmdpriv); + +u32 rtw_init_evt_priv(struct evt_priv *pevtpriv); +void rtw_free_evt_priv(struct evt_priv *pevtpriv); +void rtw_cmd_clr_isr(struct cmd_priv *pcmdpriv); +void rtw_evt_notify_isr(struct evt_priv *pevtpriv); +#ifdef CONFIG_88EU_P2P +u8 p2p_protocol_wk_cmd(struct adapter *padapter, int intCmdType); +#endif /* CONFIG_88EU_P2P */ + +enum rtw_drvextra_cmd_id { + NONE_WK_CID, + DYNAMIC_CHK_WK_CID, + DM_CTRL_WK_CID, + PBC_POLLING_WK_CID, + POWER_SAVING_CTRL_WK_CID,/* IPS,AUTOSuspend */ + LPS_CTRL_WK_CID, + ANT_SELECT_WK_CID, + P2P_PS_WK_CID, + P2P_PROTO_WK_CID, + CHECK_HIQ_WK_CID,/* for softap mode, check hi queue if empty */ + INTEl_WIDI_WK_CID, + C2H_WK_CID, + RTP_TIMER_CFG_WK_CID, + MAX_WK_CID +}; + +enum LPS_CTRL_TYPE { + LPS_CTRL_SCAN = 0, + LPS_CTRL_JOINBSS = 1, + LPS_CTRL_CONNECT = 2, + LPS_CTRL_DISCONNECT = 3, + LPS_CTRL_SPECIAL_PACKET = 4, + LPS_CTRL_LEAVE = 5, +}; + +enum RFINTFS { + SWSI, + HWSI, + HWPI, +}; + +/* +Caller Mode: Infra, Ad-HoC(C) + +Notes: To enter USB suspend mode + +Command Mode + +*/ +struct usb_suspend_parm { + u32 action;/* 1: sleep, 0:resume */ +}; + +/* +Caller Mode: Infra, Ad-HoC + +Notes: To join a known BSS. + +Command-Event Mode + +*/ + +/* +Caller Mode: Infra, Ad-Hoc + +Notes: To join the specified bss + +Command Event Mode + +*/ +struct joinbss_parm { + struct wlan_bssid_ex network; +}; + +/* +Caller Mode: Infra, Ad-HoC(C) + +Notes: To disconnect the current associated BSS + +Command Mode + +*/ +struct disconnect_parm { + u32 deauth_timeout_ms; +}; + +/* +Caller Mode: AP, Ad-HoC(M) + +Notes: To create a BSS + +Command Mode +*/ +struct createbss_parm { + struct wlan_bssid_ex network; +}; + +struct setopmode_parm { + u8 mode; + u8 rsvd[3]; +}; + +/* +Caller Mode: AP, Ad-HoC, Infra + +Notes: To ask RTL8711 performing site-survey + +Command-Event Mode + +*/ + +#define RTW_SSID_SCAN_AMOUNT 9 /* for WEXT_CSCAN_AMOUNT 9 */ +#define RTW_CHANNEL_SCAN_AMOUNT (14+37) +struct sitesurvey_parm { + int scan_mode; /* active: 1, passive: 0 */ + u8 ssid_num; + u8 ch_num; + struct ndis_802_11_ssid ssid[RTW_SSID_SCAN_AMOUNT]; + struct rtw_ieee80211_channel ch[RTW_CHANNEL_SCAN_AMOUNT]; +}; + +/* +Caller Mode: Any + +Notes: To set the auth type of RTL8711. open/shared/802.1x + +Command Mode + +*/ +struct setauth_parm { + u8 mode; /* 0: legacy open, 1: legacy shared 2: 802.1x */ + u8 _1x; /* 0: PSK, 1: TLS */ + u8 rsvd[2]; +}; + +/* +Caller Mode: Infra + +a. algorithm: wep40, wep104, tkip & aes +b. keytype: grp key/unicast key +c. key contents + +when shared key ==> keyid is the camid +when 802.1x ==> keyid [0:1] ==> grp key +when 802.1x ==> keyid > 2 ==> unicast key + +*/ +struct setkey_parm { + u8 algorithm; /* could be none, wep40, TKIP, CCMP, wep104 */ + u8 keyid; + u8 grpkey; /* 1: this is the grpkey for 802.1x. + * 0: this is the unicast key for 802.1x */ + u8 set_tx; /* 1: main tx key for wep. 0: other key. */ + u8 key[16]; /* this could be 40 or 104 */ +}; + +/* +When in AP or Ad-Hoc mode, this is used to +allocate an sw/hw entry for a newly associated sta. + +Command + +when shared key ==> algorithm/keyid + +*/ +struct set_stakey_parm { + u8 addr[ETH_ALEN]; + u8 algorithm; + u8 id;/* currently for erasing cam entry if + * algorithm == _NO_PRIVACY_ */ + u8 key[16]; +}; + +struct set_stakey_rsp { + u8 addr[ETH_ALEN]; + u8 keyid; + u8 rsvd; +}; + +/* +Caller Ad-Hoc/AP + +Command -Rsp(AID == CAMID) mode + +This is to force fw to add an sta_data entry per driver's request. + +FW will write an cam entry associated with it. + +*/ +struct set_assocsta_parm { + u8 addr[ETH_ALEN]; +}; + +struct set_assocsta_rsp { + u8 cam_id; + u8 rsvd[3]; +}; + +/* + Caller Ad-Hoc/AP + + Command mode + + This is to force fw to del an sta_data entry per driver's request + + FW will invalidate the cam entry associated with it. + +*/ +struct del_assocsta_parm { + u8 addr[ETH_ALEN]; +}; + +/* +Caller Mode: AP/Ad-HoC(M) + +Notes: To notify fw that given staid has changed its power state + +Command Mode + +*/ +struct setstapwrstate_parm { + u8 staid; + u8 status; + u8 hwaddr[6]; +}; + +/* +Caller Mode: Any + +Notes: To setup the basic rate of RTL8711 + +Command Mode + +*/ +struct setbasicrate_parm { + u8 basicrates[NumRates]; +}; + +/* +Caller Mode: Any + +Notes: To read the current basic rate + +Command-Rsp Mode + +*/ +struct getbasicrate_parm { + u32 rsvd; +}; + +struct getbasicrate_rsp { + u8 basicrates[NumRates]; +}; + +/* +Caller Mode: Any + +Notes: To setup the data rate of RTL8711 + +Command Mode + +*/ +struct setdatarate_parm { + u8 mac_id; + u8 datarates[NumRates]; +}; + +/* +Caller Mode: Any + +Notes: To read the current data rate + +Command-Rsp Mode + +*/ +struct getdatarate_parm { + u32 rsvd; + +}; +struct getdatarate_rsp { + u8 datarates[NumRates]; +}; + +/* +Caller Mode: Any +AP: AP can use the info for the contents of beacon frame +Infra: STA can use the info when sitesurveying +Ad-HoC(M): Like AP +Ad-HoC(C): Like STA + +Notes: To set the phy capability of the NIC + +Command Mode + +*/ + +struct setphyinfo_parm { + struct regulatory_class class_sets[NUM_REGULATORYS]; + u8 status; +}; + +struct getphyinfo_parm { + u32 rsvd; +}; + +struct getphyinfo_rsp { + struct regulatory_class class_sets[NUM_REGULATORYS]; + u8 status; +}; + +/* +Caller Mode: Any + +Notes: To set the channel/modem/band +This command will be used when channel/modem/band is changed. + +Command Mode + +*/ +struct setphy_parm { + u8 rfchannel; + u8 modem; +}; + +/* +Caller Mode: Any + +Notes: To get the current setting of channel/modem/band + +Command-Rsp Mode + +*/ +struct getphy_parm { + u32 rsvd; + +}; +struct getphy_rsp { + u8 rfchannel; + u8 modem; +}; + +struct readBB_parm { + u8 offset; +}; +struct readBB_rsp { + u8 value; +}; + +struct readTSSI_parm { + u8 offset; +}; +struct readTSSI_rsp { + u8 value; +}; + +struct writeBB_parm { + u8 offset; + u8 value; +}; + +struct readRF_parm { + u8 offset; +}; +struct readRF_rsp { + u32 value; +}; + +struct writeRF_parm { + u32 offset; + u32 value; +}; + +struct getrfintfs_parm { + u8 rfintfs; +}; + +struct Tx_Beacon_param +{ + struct wlan_bssid_ex network; +}; + +/* + Notes: This command is used for H2C/C2H loopback testing + + mac[0] == 0 + ==> CMD mode, return H2C_SUCCESS. + The following condition must be ture under CMD mode + mac[1] == mac[4], mac[2] == mac[3], mac[0]=mac[5]= 0; + s0 == 0x1234, s1 == 0xabcd, w0 == 0x78563412, w1 == 0x5aa5def7; + s2 == (b1 << 8 | b0); + + mac[0] == 1 + ==> CMD_RSP mode, return H2C_SUCCESS_RSP + + The rsp layout shall be: + rsp: parm: + mac[0] = mac[5]; + mac[1] = mac[4]; + mac[2] = mac[3]; + mac[3] = mac[2]; + mac[4] = mac[1]; + mac[5] = mac[0]; + s0 = s1; + s1 = swap16(s0); + w0 = swap32(w1); + b0 = b1 + s2 = s0 + s1 + b1 = b0 + w1 = w0 + + mac[0] == 2 + ==> CMD_EVENT mode, return H2C_SUCCESS + The event layout shall be: + event: parm: + mac[0] = mac[5]; + mac[1] = mac[4]; + mac[2] = event's seq no, starting from 1 to parm's marc[3] + mac[3] = mac[2]; + mac[4] = mac[1]; + mac[5] = mac[0]; + s0 = swap16(s0) - event.mac[2]; + s1 = s1 + event.mac[2]; + w0 = swap32(w0); + b0 = b1 + s2 = s0 + event.mac[2] + b1 = b0 + w1 = swap32(w1) - event.mac[2]; + + parm->mac[3] is the total event counts that host requested. + event will be the same with the cmd's param. +*/ + +/* CMD param Format for driver extra cmd handler */ +struct drvextra_cmd_parm { + int ec_id; /* extra cmd id */ + int type_size; /* Can use this field as the type id or command size */ + unsigned char *pbuf; +}; + +/*------------------- Below are used for RF/BB tunning ---------------------*/ + +struct setantenna_parm { + u8 tx_antset; + u8 rx_antset; + u8 tx_antenna; + u8 rx_antenna; +}; + +struct enrateadaptive_parm { + u32 en; +}; + +struct settxagctbl_parm { + u32 txagc[MAX_RATES_LENGTH]; +}; + +struct gettxagctbl_parm { + u32 rsvd; +}; +struct gettxagctbl_rsp { + u32 txagc[MAX_RATES_LENGTH]; +}; + +struct setagcctrl_parm { + u32 agcctrl; /* 0: pure hw, 1: fw */ +}; + +struct setssup_parm { + u32 ss_ForceUp[MAX_RATES_LENGTH]; +}; + +struct getssup_parm { + u32 rsvd; +}; + +struct getssup_rsp { + u8 ss_ForceUp[MAX_RATES_LENGTH]; +}; + +struct setssdlevel_parm { + u8 ss_DLevel[MAX_RATES_LENGTH]; +}; + +struct getssdlevel_parm { + u32 rsvd; +}; + +struct getssdlevel_rsp { + u8 ss_DLevel[MAX_RATES_LENGTH]; +}; + +struct setssulevel_parm { + u8 ss_ULevel[MAX_RATES_LENGTH]; +}; + +struct getssulevel_parm { + u32 rsvd; +}; + +struct getssulevel_rsp { + u8 ss_ULevel[MAX_RATES_LENGTH]; +}; + +struct setcountjudge_parm { + u8 count_judge[MAX_RATES_LENGTH]; +}; + +struct getcountjudge_parm { + u32 rsvd; +}; + +struct getcountjudge_rsp { + u8 count_judge[MAX_RATES_LENGTH]; +}; + +struct setratable_parm { + u8 ss_ForceUp[NumRates]; + u8 ss_ULevel[NumRates]; + u8 ss_DLevel[NumRates]; + u8 count_judge[NumRates]; +}; + +struct getratable_parm { + uint rsvd; +}; + +struct getratable_rsp { + u8 ss_ForceUp[NumRates]; + u8 ss_ULevel[NumRates]; + u8 ss_DLevel[NumRates]; + u8 count_judge[NumRates]; +}; + +/* to get TX,RX retry count */ + +struct gettxretrycnt_parm { + unsigned int rsvd; +}; + +struct gettxretrycnt_rsp { + unsigned long tx_retrycnt; +}; + +struct getrxretrycnt_parm { + unsigned int rsvd; +}; + +struct getrxretrycnt_rsp { + unsigned long rx_retrycnt; +}; + +/* to get BCNOK,BCNERR count */ +struct getbcnokcnt_parm { + unsigned int rsvd; +}; + +struct getbcnokcnt_rsp { + unsigned long bcnokcnt; +}; + +struct getbcnerrcnt_parm { + unsigned int rsvd; +}; + +struct getbcnerrcnt_rsp { + unsigned long bcnerrcnt; +}; + +/* to get current TX power level */ +struct getcurtxpwrlevel_parm { + unsigned int rsvd; +}; +struct getcurtxpwrlevel_rspi { + unsigned short tx_power; +}; + +struct setprobereqextraie_parm { + unsigned char e_id; + unsigned char ie_len; + unsigned char ie[0]; +}; + +struct setassocreqextraie_parm { + unsigned char e_id; + unsigned char ie_len; + unsigned char ie[0]; +}; + +struct setproberspextraie_parm { + unsigned char e_id; + unsigned char ie_len; + unsigned char ie[0]; +}; + +struct setassocrspextraie_parm { + unsigned char e_id; + unsigned char ie_len; + unsigned char ie[0]; +}; + +struct addBaReq_parm { + unsigned int tid; + u8 addr[ETH_ALEN]; +}; + +/*H2C Handler index: 46 */ +struct set_ch_parm { + u8 ch; + u8 bw; + u8 ch_offset; +}; + +/*H2C Handler index: 59 */ +struct SetChannelPlan_param +{ + u8 channel_plan; +}; + +/*H2C Handler index: 60 */ +struct LedBlink_param +{ + struct LED_871x *pLed; +}; + +/*H2C Handler index: 61 */ +struct SetChannelSwitch_param +{ + u8 new_ch_no; +}; + +/*H2C Handler index: 62 */ +struct TDLSoption_param +{ + u8 addr[ETH_ALEN]; + u8 option; +}; + +#define GEN_CMD_CODE(cmd) cmd ## _CMD_ + +/* + +Result: +0x00: success +0x01: sucess, and check Response. +0x02: cmd ignored due to duplicated sequcne number +0x03: cmd dropped due to invalid cmd code +0x04: reserved. + +*/ + +#define H2C_RSP_OFFSET 512 + +#define H2C_SUCCESS 0x00 +#define H2C_SUCCESS_RSP 0x01 +#define H2C_DUPLICATED 0x02 +#define H2C_DROPPED 0x03 +#define H2C_PARAMETERS_ERROR 0x04 +#define H2C_REJECTED 0x05 +#define H2C_CMD_OVERFLOW 0x06 +#define H2C_RESERVED 0x07 + +u8 rtw_setassocsta_cmd(struct adapter *padapter, u8 *mac_addr); +u8 rtw_setstandby_cmd(struct adapter *padapter, uint action); +u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid, + int ssid_num, struct rtw_ieee80211_channel *ch, + int ch_num); +u8 rtw_createbss_cmd(struct adapter *padapter); +u8 rtw_createbss_cmd_ex(struct adapter *padapter, unsigned char *pbss, + unsigned int sz); +u8 rtw_setphy_cmd(struct adapter *padapter, u8 modem, u8 ch); +u8 rtw_setstakey_cmd(struct adapter *padapter, u8 *psta, u8 unicast_key); +u8 rtw_clearstakey_cmd(struct adapter *padapter, u8 *psta, u8 entry, u8 enqueue); +u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network* pnetwork); +u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueue); +u8 rtw_setopmode_cmd(struct adapter *padapter, enum ndis_802_11_network_infra networktype); +u8 rtw_setdatarate_cmd(struct adapter *padapter, u8 *rateset); +u8 rtw_setbasicrate_cmd(struct adapter *padapter, u8 *rateset); +u8 rtw_setbbreg_cmd(struct adapter * padapter, u8 offset, u8 val); +u8 rtw_setrfreg_cmd(struct adapter * padapter, u8 offset, u32 val); +u8 rtw_getbbreg_cmd(struct adapter * padapter, u8 offset, u8 * pval); +u8 rtw_getrfreg_cmd(struct adapter * padapter, u8 offset, u8 * pval); +u8 rtw_setrfintfs_cmd(struct adapter *padapter, u8 mode); +u8 rtw_setrttbl_cmd(struct adapter *padapter, struct setratable_parm *prate_table); +u8 rtw_getrttbl_cmd(struct adapter *padapter, struct getratable_rsp *pval); + +u8 rtw_gettssi_cmd(struct adapter *padapter, u8 offset,u8 *pval); +u8 rtw_setfwdig_cmd(struct adapter*padapter, u8 type); +u8 rtw_setfwra_cmd(struct adapter*padapter, u8 type); + +u8 rtw_addbareq_cmd(struct adapter*padapter, u8 tid, u8 *addr); + +u8 rtw_dynamic_chk_wk_cmd(struct adapter *adapter); + +u8 rtw_lps_ctrl_wk_cmd(struct adapter*padapter, u8 lps_ctrl_type, u8 enqueue); +u8 rtw_rpt_timer_cfg_cmd(struct adapter*padapter, u16 minRptTime); + + u8 rtw_antenna_select_cmd(struct adapter*padapter, u8 antenna,u8 enqueue); +u8 rtw_ps_cmd(struct adapter*padapter); + +#ifdef CONFIG_88EU_AP_MODE +u8 rtw_chk_hi_queue_cmd(struct adapter*padapter); +#endif + +u8 rtw_set_ch_cmd(struct adapter*padapter, u8 ch, u8 bw, u8 ch_offset, u8 enqueue); +u8 rtw_set_chplan_cmd(struct adapter*padapter, u8 chplan, u8 enqueue); +u8 rtw_led_blink_cmd(struct adapter*padapter, struct LED_871x * pLed); +u8 rtw_set_csa_cmd(struct adapter*padapter, u8 new_ch_no); +u8 rtw_tdls_cmd(struct adapter *padapter, u8 *addr, u8 option); + +u8 rtw_c2h_wk_cmd(struct adapter *padapter, u8 *c2h_evt); + +u8 rtw_drvextra_cmd_hdl(struct adapter *padapter, unsigned char *pbuf); + +void rtw_survey_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd); +void rtw_disassoc_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd); +void rtw_joinbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd); +void rtw_createbss_cmd_callback(struct adapter *adapt, struct cmd_obj *pcmd); +void rtw_getbbrfreg_cmdrsp_callback(struct adapter *adapt, struct cmd_obj *cmd); +void rtw_readtssi_cmdrsp_callback(struct adapter *adapt, struct cmd_obj *cmd); + +void rtw_setstaKey_cmdrsp_callback(struct adapter *adapt, struct cmd_obj *cmd); +void rtw_setassocsta_cmdrsp_callback(struct adapter *adapt, struct cmd_obj *cm); +void rtw_getrttbl_cmdrsp_callback(struct adapter *adapt, struct cmd_obj *cmd); + +struct _cmd_callback { + u32 cmd_code; + void (*callback)(struct adapter *padapter, struct cmd_obj *cmd); +}; + +enum rtw_h2c_cmd { + GEN_CMD_CODE(_Read_MACREG), /*0*/ + GEN_CMD_CODE(_Write_MACREG), + GEN_CMD_CODE(_Read_BBREG), + GEN_CMD_CODE(_Write_BBREG), + GEN_CMD_CODE(_Read_RFREG), + GEN_CMD_CODE(_Write_RFREG), /*5*/ + GEN_CMD_CODE(_Read_EEPROM), + GEN_CMD_CODE(_Write_EEPROM), + GEN_CMD_CODE(_Read_EFUSE), + GEN_CMD_CODE(_Write_EFUSE), + + GEN_CMD_CODE(_Read_CAM), /*10*/ + GEN_CMD_CODE(_Write_CAM), + GEN_CMD_CODE(_setBCNITV), + GEN_CMD_CODE(_setMBIDCFG), + GEN_CMD_CODE(_JoinBss), /*14*/ + GEN_CMD_CODE(_DisConnect), /*15*/ + GEN_CMD_CODE(_CreateBss), + GEN_CMD_CODE(_SetOpMode), + GEN_CMD_CODE(_SiteSurvey), /*18*/ + GEN_CMD_CODE(_SetAuth), + + GEN_CMD_CODE(_SetKey), /*20*/ + GEN_CMD_CODE(_SetStaKey), + GEN_CMD_CODE(_SetAssocSta), + GEN_CMD_CODE(_DelAssocSta), + GEN_CMD_CODE(_SetStaPwrState), + GEN_CMD_CODE(_SetBasicRate), /*25*/ + GEN_CMD_CODE(_GetBasicRate), + GEN_CMD_CODE(_SetDataRate), + GEN_CMD_CODE(_GetDataRate), + GEN_CMD_CODE(_SetPhyInfo), + + GEN_CMD_CODE(_GetPhyInfo), /*30*/ + GEN_CMD_CODE(_SetPhy), + GEN_CMD_CODE(_GetPhy), + GEN_CMD_CODE(_readRssi), + GEN_CMD_CODE(_readGain), + GEN_CMD_CODE(_SetAtim), /*35*/ + GEN_CMD_CODE(_SetPwrMode), + GEN_CMD_CODE(_JoinbssRpt), + GEN_CMD_CODE(_SetRaTable), + GEN_CMD_CODE(_GetRaTable), + + GEN_CMD_CODE(_GetCCXReport), /*40*/ + GEN_CMD_CODE(_GetDTMReport), + GEN_CMD_CODE(_GetTXRateStatistics), + GEN_CMD_CODE(_SetUsbSuspend), + GEN_CMD_CODE(_SetH2cLbk), + GEN_CMD_CODE(_AddBAReq), /*45*/ + GEN_CMD_CODE(_SetChannel), /*46*/ + GEN_CMD_CODE(_SetTxPower), + GEN_CMD_CODE(_SwitchAntenna), + GEN_CMD_CODE(_SetCrystalCap), + GEN_CMD_CODE(_SetSingleCarrierTx), /*50*/ + + GEN_CMD_CODE(_SetSingleToneTx),/*51*/ + GEN_CMD_CODE(_SetCarrierSuppressionTx), + GEN_CMD_CODE(_SetContinuousTx), + GEN_CMD_CODE(_SwitchBandwidth), /*54*/ + GEN_CMD_CODE(_TX_Beacon), /*55*/ + + GEN_CMD_CODE(_Set_MLME_EVT), /*56*/ + GEN_CMD_CODE(_Set_Drv_Extra), /*57*/ + GEN_CMD_CODE(_Set_H2C_MSG), /*58*/ + + GEN_CMD_CODE(_SetChannelPlan), /*59*/ + GEN_CMD_CODE(_LedBlink), /*60*/ + + GEN_CMD_CODE(_SetChannelSwitch), /*61*/ + GEN_CMD_CODE(_TDLS), /*62*/ + + MAX_H2CCMD +}; + +#define _GetBBReg_CMD_ _Read_BBREG_CMD_ +#define _SetBBReg_CMD_ _Write_BBREG_CMD_ +#define _GetRFReg_CMD_ _Read_RFREG_CMD_ +#define _SetRFReg_CMD_ _Write_RFREG_CMD_ + +#ifdef _RTW_CMD_C_ +static struct _cmd_callback rtw_cmd_callback[] = +{ + {GEN_CMD_CODE(_Read_MACREG), NULL}, /*0*/ + {GEN_CMD_CODE(_Write_MACREG), NULL}, + {GEN_CMD_CODE(_Read_BBREG), &rtw_getbbrfreg_cmdrsp_callback}, + {GEN_CMD_CODE(_Write_BBREG), NULL}, + {GEN_CMD_CODE(_Read_RFREG), &rtw_getbbrfreg_cmdrsp_callback}, + {GEN_CMD_CODE(_Write_RFREG), NULL}, /*5*/ + {GEN_CMD_CODE(_Read_EEPROM), NULL}, + {GEN_CMD_CODE(_Write_EEPROM), NULL}, + {GEN_CMD_CODE(_Read_EFUSE), NULL}, + {GEN_CMD_CODE(_Write_EFUSE), NULL}, + + {GEN_CMD_CODE(_Read_CAM), NULL}, /*10*/ + {GEN_CMD_CODE(_Write_CAM), NULL}, + {GEN_CMD_CODE(_setBCNITV), NULL}, + {GEN_CMD_CODE(_setMBIDCFG), NULL}, + {GEN_CMD_CODE(_JoinBss), &rtw_joinbss_cmd_callback}, /*14*/ + {GEN_CMD_CODE(_DisConnect), &rtw_disassoc_cmd_callback}, /*15*/ + {GEN_CMD_CODE(_CreateBss), &rtw_createbss_cmd_callback}, + {GEN_CMD_CODE(_SetOpMode), NULL}, + {GEN_CMD_CODE(_SiteSurvey), &rtw_survey_cmd_callback}, /*18*/ + {GEN_CMD_CODE(_SetAuth), NULL}, + + {GEN_CMD_CODE(_SetKey), NULL}, /*20*/ + {GEN_CMD_CODE(_SetStaKey), &rtw_setstaKey_cmdrsp_callback}, + {GEN_CMD_CODE(_SetAssocSta), &rtw_setassocsta_cmdrsp_callback}, + {GEN_CMD_CODE(_DelAssocSta), NULL}, + {GEN_CMD_CODE(_SetStaPwrState), NULL}, + {GEN_CMD_CODE(_SetBasicRate), NULL}, /*25*/ + {GEN_CMD_CODE(_GetBasicRate), NULL}, + {GEN_CMD_CODE(_SetDataRate), NULL}, + {GEN_CMD_CODE(_GetDataRate), NULL}, + {GEN_CMD_CODE(_SetPhyInfo), NULL}, + + {GEN_CMD_CODE(_GetPhyInfo), NULL}, /*30*/ + {GEN_CMD_CODE(_SetPhy), NULL}, + {GEN_CMD_CODE(_GetPhy), NULL}, + {GEN_CMD_CODE(_readRssi), NULL}, + {GEN_CMD_CODE(_readGain), NULL}, + {GEN_CMD_CODE(_SetAtim), NULL}, /*35*/ + {GEN_CMD_CODE(_SetPwrMode), NULL}, + {GEN_CMD_CODE(_JoinbssRpt), NULL}, + {GEN_CMD_CODE(_SetRaTable), NULL}, + {GEN_CMD_CODE(_GetRaTable), NULL}, + + {GEN_CMD_CODE(_GetCCXReport), NULL}, /*40*/ + {GEN_CMD_CODE(_GetDTMReport), NULL}, + {GEN_CMD_CODE(_GetTXRateStatistics), NULL}, + {GEN_CMD_CODE(_SetUsbSuspend), NULL}, + {GEN_CMD_CODE(_SetH2cLbk), NULL}, + {GEN_CMD_CODE(_AddBAReq), NULL}, /*45*/ + {GEN_CMD_CODE(_SetChannel), NULL}, /*46*/ + {GEN_CMD_CODE(_SetTxPower), NULL}, + {GEN_CMD_CODE(_SwitchAntenna), NULL}, + {GEN_CMD_CODE(_SetCrystalCap), NULL}, + {GEN_CMD_CODE(_SetSingleCarrierTx), NULL}, /*50*/ + + {GEN_CMD_CODE(_SetSingleToneTx), NULL}, /*51*/ + {GEN_CMD_CODE(_SetCarrierSuppressionTx), NULL}, + {GEN_CMD_CODE(_SetContinuousTx), NULL}, + {GEN_CMD_CODE(_SwitchBandwidth), NULL}, /*54*/ + {GEN_CMD_CODE(_TX_Beacon), NULL},/*55*/ + + {GEN_CMD_CODE(_Set_MLME_EVT), NULL},/*56*/ + {GEN_CMD_CODE(_Set_Drv_Extra), NULL},/*57*/ + {GEN_CMD_CODE(_Set_H2C_MSG), NULL},/*58*/ + {GEN_CMD_CODE(_SetChannelPlan), NULL},/*59*/ + {GEN_CMD_CODE(_LedBlink), NULL},/*60*/ + + {GEN_CMD_CODE(_SetChannelSwitch), NULL},/*61*/ + {GEN_CMD_CODE(_TDLS), NULL},/*62*/ +}; +#endif + +#endif /* _CMD_H_ */ diff --git a/drivers/staging/rtl8188eu/include/rtw_debug.h b/drivers/staging/rtl8188eu/include/rtw_debug.h new file mode 100644 index 0000000000000..c6b193a2e795c --- /dev/null +++ b/drivers/staging/rtl8188eu/include/rtw_debug.h @@ -0,0 +1,290 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __RTW_DEBUG_H__ +#define __RTW_DEBUG_H__ + +#include +#include + + +#define _drv_always_ 1 +#define _drv_emerg_ 2 +#define _drv_alert_ 3 +#define _drv_crit_ 4 +#define _drv_err_ 5 +#define _drv_warning_ 6 +#define _drv_notice_ 7 +#define _drv_info_ 8 +#define _drv_debug_ 9 + + +#define _module_rtl871x_xmit_c_ BIT(0) +#define _module_xmit_osdep_c_ BIT(1) +#define _module_rtl871x_recv_c_ BIT(2) +#define _module_recv_osdep_c_ BIT(3) +#define _module_rtl871x_mlme_c_ BIT(4) +#define _module_mlme_osdep_c_ BIT(5) +#define _module_rtl871x_sta_mgt_c_ BIT(6) +#define _module_rtl871x_cmd_c_ BIT(7) +#define _module_cmd_osdep_c_ BIT(8) +#define _module_rtl871x_io_c_ BIT(9) +#define _module_io_osdep_c_ BIT(10) +#define _module_os_intfs_c_ BIT(11) +#define _module_rtl871x_security_c_ BIT(12) +#define _module_rtl871x_eeprom_c_ BIT(13) +#define _module_hal_init_c_ BIT(14) +#define _module_hci_hal_init_c_ BIT(15) +#define _module_rtl871x_ioctl_c_ BIT(16) +#define _module_rtl871x_ioctl_set_c_ BIT(17) +#define _module_rtl871x_ioctl_query_c_ BIT(18) +#define _module_rtl871x_pwrctrl_c_ BIT(19) +#define _module_hci_intfs_c_ BIT(20) +#define _module_hci_ops_c_ BIT(21) +#define _module_osdep_service_c_ BIT(22) +#define _module_mp_ BIT(23) +#define _module_hci_ops_os_c_ BIT(24) +#define _module_rtl871x_ioctl_os_c BIT(25) +#define _module_rtl8712_cmd_c_ BIT(26) +#define _module_rtl8192c_xmit_c_ BIT(27) +#define _module_hal_xmit_c_ BIT(28) +#define _module_efuse_ BIT(29) +#define _module_rtl8712_recv_c_ BIT(30) +#define _module_rtl8712_led_c_ BIT(31) + +#define DRIVER_PREFIX "R8188EU: " + +extern u32 GlobalDebugLevel; + +#define DBG_88E_LEVEL(_level, fmt, arg...) \ + do { \ + if (_level <= GlobalDebugLevel) \ + pr_info(DRIVER_PREFIX"ERROR " fmt, ##arg); \ + } while (0) + +#define DBG_88E(...) \ + do { \ + if (_drv_err_ <= GlobalDebugLevel) \ + pr_info(DRIVER_PREFIX __VA_ARGS__); \ + } while (0) + +#define MSG_88E(...) \ + do { \ + if (_drv_err_ <= GlobalDebugLevel) \ + pr_info(DRIVER_PREFIX __VA_ARGS__); \ + } while (0) + +#define RT_TRACE(_comp, _level, fmt) \ + do { \ + if (_level <= GlobalDebugLevel) { \ + pr_info("%s [0x%08x,%d]", DRIVER_PREFIX, \ + (unsigned int)_comp, _level); \ + pr_info fmt; \ + } \ + } while (0) + +#define _func_enter_ \ + do { \ + if (GlobalDebugLevel >= _drv_debug_) \ + pr_info("%s : %s enters at %d\n", \ + DRIVER_PREFIX, __func__, __LINE__); \ + } while (0) + +#define _func_exit_ \ + do { \ + if (GlobalDebugLevel >= _drv_debug_) \ + pr_info("%s : %s exits at %d\n", \ + DRIVER_PREFIX, __func__, __LINE__); \ + } while (0) + +#define RT_PRINT_DATA(_comp, _level, _titlestring, _hexdata, _hexdatalen)\ + do { \ + if (_level <= GlobalDebugLevel) { \ + int __i; \ + u8 *ptr = (u8 *)_hexdata; \ + pr_info("%s", DRIVER_PREFIX); \ + pr_info(_titlestring); \ + for (__i = 0; __i < (int)_hexdatalen; __i++ ) { \ + pr_info("%02X%s", ptr[__i], \ + (((__i + 1) % 4) == 0) ? \ + " " : " "); \ + if (((__i + 1) % 16) == 0) \ + printk("\n"); \ + } \ + printk("\n"); \ + } \ + } while (0) + +int proc_get_drv_version(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_get_write_reg(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_set_write_reg(struct file *file, const char __user *buffer, + unsigned long count, void *data); +int proc_get_read_reg(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_set_read_reg(struct file *file, const char __user *buffer, + unsigned long count, void *data); + +int proc_get_fwstate(char *page, char **start, + off_t offset, int count, + int *eof, void *data); +int proc_get_sec_info(char *page, char **start, + off_t offset, int count, + int *eof, void *data); +int proc_get_mlmext_state(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_get_qos_option(char *page, char **start, + off_t offset, int count, + int *eof, void *data); +int proc_get_ht_option(char *page, char **start, + off_t offset, int count, + int *eof, void *data); +int proc_get_rf_info(char *page, char **start, + off_t offset, int count, + int *eof, void *data); +int proc_get_ap_info(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_get_adapter_state(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_get_trx_info(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_get_mac_reg_dump1(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_get_mac_reg_dump2(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_get_mac_reg_dump3(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_get_bb_reg_dump1(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_get_bb_reg_dump2(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_get_bb_reg_dump3(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_get_rf_reg_dump1(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_get_rf_reg_dump2(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_get_rf_reg_dump3(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_get_rf_reg_dump4(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +#ifdef CONFIG_88EU_AP_MODE + +int proc_get_all_sta_info(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +#endif + +int proc_get_best_channel(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_get_rx_signal(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_set_rx_signal(struct file *file, const char __user *buffer, + unsigned long count, void *data); + +int proc_get_ht_enable(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_set_ht_enable(struct file *file, const char __user *buffer, + unsigned long count, void *data); + +int proc_get_cbw40_enable(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_set_cbw40_enable(struct file *file, const char __user *buffer, + unsigned long count, void *data); + +int proc_get_ampdu_enable(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_set_ampdu_enable(struct file *file, const char __user *buffer, + unsigned long count, void *data); + +int proc_get_rx_stbc(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_set_rx_stbc(struct file *file, const char __user *buffer, + unsigned long count, void *data); + +int proc_get_two_path_rssi(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_get_rssi_disp(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_set_rssi_disp(struct file *file, const char __user *buffer, + unsigned long count, void *data); + +#ifdef CONFIG_BT_COEXIST +int proc_get_btcoex_dbg(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_set_btcoex_dbg(struct file *file, const char *buffer, + signed long count, void *data); + +#endif /* CONFIG_BT_COEXIST */ + +#endif /* __RTW_DEBUG_H__ */ diff --git a/drivers/staging/rtl8188eu/include/rtw_eeprom.h b/drivers/staging/rtl8188eu/include/rtw_eeprom.h new file mode 100644 index 0000000000000..b2672c3febd18 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/rtw_eeprom.h @@ -0,0 +1,130 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __RTW_EEPROM_H__ +#define __RTW_EEPROM_H__ + +#include +#include + +#define RTL8712_EEPROM_ID 0x8712 + +#define HWSET_MAX_SIZE_512 512 +#define EEPROM_MAX_SIZE HWSET_MAX_SIZE_512 + +#define CLOCK_RATE 50 /* 100us */ + +/* EEPROM opcodes */ +#define EEPROM_READ_OPCODE 06 +#define EEPROM_WRITE_OPCODE 05 +#define EEPROM_ERASE_OPCODE 07 +#define EEPROM_EWEN_OPCODE 19 /* Erase/write enable */ +#define EEPROM_EWDS_OPCODE 16 /* Erase/write disable */ + +/* Country codes */ +#define USA 0x555320 +#define EUROPE 0x1 /* temp, should be provided later */ +#define JAPAN 0x2 /* temp, should be provided later */ + +#define EEPROM_CID_DEFAULT 0x0 +#define EEPROM_CID_ALPHA 0x1 +#define EEPROM_CID_Senao 0x3 +#define EEPROM_CID_NetCore 0x5 +#define EEPROM_CID_CAMEO 0X8 +#define EEPROM_CID_SITECOM 0x9 +#define EEPROM_CID_COREGA 0xB +#define EEPROM_CID_EDIMAX_BELK 0xC +#define EEPROM_CID_SERCOMM_BELK 0xE +#define EEPROM_CID_CAMEO1 0xF +#define EEPROM_CID_WNC_COREGA 0x12 +#define EEPROM_CID_CLEVO 0x13 +#define EEPROM_CID_WHQL 0xFE + +/* Customer ID, note that: */ +/* This variable is initiailzed through EEPROM or registry, */ +/* however, its definition may be different with that in EEPROM for */ +/* EEPROM size consideration. So, we have to perform proper translation + * between them. */ +/* Besides, CustomerID of registry has precedence of that of EEPROM. */ +/* defined below. 060703, by rcnjko. */ +enum RT_CUSTOMER_ID { + RT_CID_DEFAULT = 0, + RT_CID_8187_ALPHA0 = 1, + RT_CID_8187_SERCOMM_PS = 2, + RT_CID_8187_HW_LED = 3, + RT_CID_8187_NETGEAR = 4, + RT_CID_WHQL = 5, + RT_CID_819x_CAMEO = 6, + RT_CID_819x_RUNTOP = 7, + RT_CID_819x_Senao = 8, + RT_CID_TOSHIBA = 9, /* Merge by Jacken, 2008/01/31. */ + RT_CID_819x_Netcore = 10, + RT_CID_Nettronix = 11, + RT_CID_DLINK = 12, + RT_CID_PRONET = 13, + RT_CID_COREGA = 14, + RT_CID_CHINA_MOBILE = 15, + RT_CID_819x_ALPHA = 16, + RT_CID_819x_Sitecom = 17, + RT_CID_CCX = 18, /* It's set under CCX logo test and isn't demanded + * for CCX functions, but for test behavior like retry + * limit and tx report. By Bruce, 2009-02-17. */ + RT_CID_819x_Lenovo = 19, + RT_CID_819x_QMI = 20, + RT_CID_819x_Edimax_Belkin = 21, + RT_CID_819x_Sercomm_Belkin = 22, + RT_CID_819x_CAMEO1 = 23, + RT_CID_819x_MSI = 24, + RT_CID_819x_Acer = 25, + RT_CID_819x_AzWave_ASUS = 26, + RT_CID_819x_AzWave = 27, /* For AzWave in PCIe,i + * The ID is AzWave use and not only Asus */ + RT_CID_819x_HP = 28, + RT_CID_819x_WNC_COREGA = 29, + RT_CID_819x_Arcadyan_Belkin = 30, + RT_CID_819x_SAMSUNG = 31, + RT_CID_819x_CLEVO = 32, + RT_CID_819x_DELL = 33, + RT_CID_819x_PRONETS = 34, + RT_CID_819x_Edimax_ASUS = 35, + RT_CID_819x_CAMEO_NETGEAR = 36, + RT_CID_PLANEX = 37, + RT_CID_CC_C = 38, + RT_CID_819x_Xavi = 39, + RT_CID_819x_FUNAI_TV = 40, + RT_CID_819x_ALPHA_WD=41, +}; + +struct eeprom_priv { + u8 bautoload_fail_flag; + u8 bloadfile_fail_flag; + u8 bloadmac_fail_flag; + u8 mac_addr[6]; /* PermanentAddress */ + u16 channel_plan; + u8 EepromOrEfuse; + u8 efuse_eeprom_data[HWSET_MAX_SIZE_512]; +}; + +void eeprom_write16(struct adapter *padapter, u16 reg, u16 data); +u16 eeprom_read16(struct adapter *padapter, u16 reg); +void read_eeprom_content(struct adapter *padapter); +void eeprom_read_sz(struct adapter *adapt, u16 reg, u8 *data, u32 sz); +void read_eeprom_content_by_attrib(struct adapter *padapter); + +#endif /* __RTL871X_EEPROM_H__ */ diff --git a/drivers/staging/rtl8188eu/include/rtw_efuse.h b/drivers/staging/rtl8188eu/include/rtw_efuse.h new file mode 100644 index 0000000000000..4d45e1e82543b --- /dev/null +++ b/drivers/staging/rtl8188eu/include/rtw_efuse.h @@ -0,0 +1,150 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __RTW_EFUSE_H__ +#define __RTW_EFUSE_H__ + +#include + +#define EFUSE_ERROE_HANDLE 1 + +#define PG_STATE_HEADER 0x01 +#define PG_STATE_WORD_0 0x02 +#define PG_STATE_WORD_1 0x04 +#define PG_STATE_WORD_2 0x08 +#define PG_STATE_WORD_3 0x10 +#define PG_STATE_DATA 0x20 + +#define PG_SWBYTE_H 0x01 +#define PG_SWBYTE_L 0x02 + +#define PGPKT_DATA_SIZE 8 + +#define EFUSE_WIFI 0 +#define EFUSE_BT 1 + +enum _EFUSE_DEF_TYPE { + TYPE_EFUSE_MAX_SECTION = 0, + TYPE_EFUSE_REAL_CONTENT_LEN = 1, + TYPE_AVAILABLE_EFUSE_BYTES_BANK = 2, + TYPE_AVAILABLE_EFUSE_BYTES_TOTAL = 3, + TYPE_EFUSE_MAP_LEN = 4, + TYPE_EFUSE_PROTECT_BYTES_BANK = 5, + TYPE_EFUSE_CONTENT_LEN_BANK = 6, +}; + +/* E-Fuse */ +#define EFUSE_MAP_SIZE 512 +#define EFUSE_MAX_SIZE 256 +/* end of E-Fuse */ + +#define EFUSE_MAX_MAP_LEN 256 +#define EFUSE_MAX_HW_SIZE 512 +#define EFUSE_MAX_SECTION_BASE 16 + +#define EXT_HEADER(header) ((header & 0x1F) == 0x0F) +#define ALL_WORDS_DISABLED(wde) ((wde & 0x0F) == 0x0F) +#define GET_HDR_OFFSET_2_0(header) ((header & 0xE0) >> 5) + +#define EFUSE_REPEAT_THRESHOLD_ 3 + +/* The following is for BT Efuse definition */ +#define EFUSE_BT_MAX_MAP_LEN 1024 +#define EFUSE_MAX_BANK 4 +#define EFUSE_MAX_BT_BANK (EFUSE_MAX_BANK-1) +/*--------------------------Define Parameters-------------------------------*/ +#define EFUSE_MAX_WORD_UNIT 4 + +/*------------------------------Define structure----------------------------*/ +struct pgpkt { + u8 offset; + u8 word_en; + u8 data[8]; + u8 word_cnts; +}; + +/*------------------------------Define structure----------------------------*/ +struct efuse_hal { + u8 fakeEfuseBank; + u32 fakeEfuseUsedBytes; + u8 fakeEfuseContent[EFUSE_MAX_HW_SIZE]; + u8 fakeEfuseInitMap[EFUSE_MAX_MAP_LEN]; + u8 fakeEfuseModifiedMap[EFUSE_MAX_MAP_LEN]; + + u16 BTEfuseUsedBytes; + u8 BTEfuseUsedPercentage; + u8 BTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE]; + u8 BTEfuseInitMap[EFUSE_BT_MAX_MAP_LEN]; + u8 BTEfuseModifiedMap[EFUSE_BT_MAX_MAP_LEN]; + + u16 fakeBTEfuseUsedBytes; + u8 fakeBTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE]; + u8 fakeBTEfuseInitMap[EFUSE_BT_MAX_MAP_LEN]; + u8 fakeBTEfuseModifiedMap[EFUSE_BT_MAX_MAP_LEN]; +}; + +/*------------------------Export global variable----------------------------*/ +extern u8 fakeEfuseBank; +extern u32 fakeEfuseUsedBytes; +extern u8 fakeEfuseContent[]; +extern u8 fakeEfuseInitMap[]; +extern u8 fakeEfuseModifiedMap[]; + +extern u32 BTEfuseUsedBytes; +extern u8 BTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE]; +extern u8 BTEfuseInitMap[]; +extern u8 BTEfuseModifiedMap[]; + +extern u32 fakeBTEfuseUsedBytes; +extern u8 fakeBTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE]; +extern u8 fakeBTEfuseInitMap[]; +extern u8 fakeBTEfuseModifiedMap[]; +/*------------------------Export global variable----------------------------*/ + +u8 efuse_GetCurrentSize(struct adapter *adapter, u16 *size); +u16 efuse_GetMaxSize(struct adapter *adapter); +u8 rtw_efuse_access(struct adapter *adapter, u8 read, u16 start_addr, + u16 cnts, u8 *data); +u8 rtw_efuse_map_read(struct adapter *adapter, u16 addr, u16 cnts, u8 *data); +u8 rtw_efuse_map_write(struct adapter *adapter, u16 addr, u16 cnts, u8 *data); +u8 rtw_BT_efuse_map_read(struct adapter *adapter, u16 addr, + u16 cnts, u8 *data); +u8 rtw_BT_efuse_map_write(struct adapter *adapter, u16 addr, + u16 cnts, u8 *data); +u16 Efuse_GetCurrentSize(struct adapter *adapter, u8 efusetype, bool test); +u8 Efuse_CalculateWordCnts(u8 word_en); +void ReadEFuseByte(struct adapter *adapter, u16 _offset, u8 *pbuf, bool test); +void EFUSE_GetEfuseDefinition(struct adapter *adapt, u8 type, u8 type1, + void *out, bool bPseudoTest); +u8 efuse_OneByteRead(struct adapter *adapter, u16 addr, u8 *data, bool test); +u8 efuse_OneByteWrite(struct adapter *adapter, u16 addr, u8 data, bool test); + +void Efuse_PowerSwitch(struct adapter *adapt,u8 bWrite,u8 PwrState); +int Efuse_PgPacketRead(struct adapter *adapt, u8 offset, u8 *data, bool test); +int Efuse_PgPacketWrite(struct adapter *adapter, u8 offset, u8 word, u8 *data, + bool test); +void efuse_WordEnableDataRead(u8 word_en, u8 *sourdata, u8 *targetdata); +u8 Efuse_WordEnableDataWrite(struct adapter *adapter, u16 efuse_addr, + u8 word_en, u8 *data, bool test); + +u8 EFUSE_Read1Byte(struct adapter *adapter, u16 address); +void EFUSE_ShadowMapUpdate(struct adapter *adapter, u8 efusetype, bool test); +void EFUSE_ShadowRead(struct adapter *adapt, u8 type, u16 offset, u32 *val); + +#endif diff --git a/drivers/staging/rtl8188eu/include/rtw_event.h b/drivers/staging/rtl8188eu/include/rtw_event.h new file mode 100644 index 0000000000000..52151dc4495ac --- /dev/null +++ b/drivers/staging/rtl8188eu/include/rtw_event.h @@ -0,0 +1,115 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef _RTW_EVENT_H_ +#define _RTW_EVENT_H_ + +#include + +#include +#include +#include + +/* +Used to report a bss has been scanned +*/ +struct survey_event { + struct wlan_bssid_ex bss; +}; + +/* +Used to report that the requested site survey has been done. + +bss_cnt indicates the number of bss that has been reported. + + +*/ +struct surveydone_event { + unsigned int bss_cnt; + +}; + +/* +Used to report the link result of joinning the given bss + + +join_res: +-1: authentication fail +-2: association fail +> 0: TID + +*/ +struct joinbss_event { + struct wlan_network network; +}; + +/* +Used to report a given STA has joinned the created BSS. +It is used in AP/Ad-HoC(M) mode. +*/ + +struct stassoc_event { + unsigned char macaddr[6]; + unsigned char rsvd[2]; + int cam_id; +}; + +struct stadel_event { + unsigned char macaddr[6]; + unsigned char rsvd[2]; /* for reason */ + int mac_id; +}; + +struct addba_event { + unsigned int tid; +}; + +#define GEN_EVT_CODE(event) event ## _EVT_ + +struct fwevent { + u32 parmsize; + void (*event_callback)(struct adapter *dev, u8 *pbuf); +}; + +#define C2HEVENT_SZ 32 + +struct event_node { + unsigned char *node; + unsigned char evt_code; + unsigned short evt_sz; + int *caller_ff_tail; + int caller_ff_sz; +}; + +struct c2hevent_queue { + int head; + int tail; + struct event_node nodes[C2HEVENT_SZ]; + unsigned char seq; +}; + +#define NETWORK_QUEUE_SZ 4 + +struct network_queue { + int head; + int tail; + struct wlan_bssid_ex networks[NETWORK_QUEUE_SZ]; +}; + +#endif /* _WLANEVENT_H_ */ -- GitLab From 93dc9cc6611413670552612b7ba5ca62d21600b0 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 21 Aug 2013 22:34:09 -0500 Subject: [PATCH 785/942] staging: r8188eu: Add files for new driver - part 27 This commit adds files include/rtw_ht.h, include/rtw_io.h, include/rtw_ioctl.h, include/rtw_ioctl_rtl.h, include/rtw_ioctl_set.h, include/rtw_iol.h, and include/rtw_led.h. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/rtw_ht.h | 44 ++ drivers/staging/rtl8188eu/include/rtw_io.h | 387 ++++++++++++++++++ drivers/staging/rtl8188eu/include/rtw_ioctl.h | 124 ++++++ .../staging/rtl8188eu/include/rtw_ioctl_rtl.h | 79 ++++ .../staging/rtl8188eu/include/rtw_ioctl_set.h | 50 +++ drivers/staging/rtl8188eu/include/rtw_iol.h | 84 ++++ drivers/staging/rtl8188eu/include/rtw_led.h | 197 +++++++++ 7 files changed, 965 insertions(+) create mode 100644 drivers/staging/rtl8188eu/include/rtw_ht.h create mode 100644 drivers/staging/rtl8188eu/include/rtw_io.h create mode 100644 drivers/staging/rtl8188eu/include/rtw_ioctl.h create mode 100644 drivers/staging/rtl8188eu/include/rtw_ioctl_rtl.h create mode 100644 drivers/staging/rtl8188eu/include/rtw_ioctl_set.h create mode 100644 drivers/staging/rtl8188eu/include/rtw_iol.h create mode 100644 drivers/staging/rtl8188eu/include/rtw_led.h diff --git a/drivers/staging/rtl8188eu/include/rtw_ht.h b/drivers/staging/rtl8188eu/include/rtw_ht.h new file mode 100644 index 0000000000000..beb210b370836 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/rtw_ht.h @@ -0,0 +1,44 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef _RTW_HT_H_ +#define _RTW_HT_H_ + +#include +#include "wifi.h" + +struct ht_priv { + u32 ht_option; + u32 ampdu_enable;/* for enable Tx A-MPDU */ + u32 tx_amsdu_enable;/* for enable Tx A-MSDU */ + u32 tx_amdsu_maxlen; /* 1: 8k, 0:4k ; default:8k, for tx */ + u32 rx_ampdu_maxlen; /* for rx reordering ctrl win_sz, + * updated when join_callback. */ + u8 bwmode;/* */ + u8 ch_offset;/* PRIME_CHNL_OFFSET */ + u8 sgi;/* short GI */ + + /* for processing Tx A-MPDU */ + u8 agg_enable_bitmap; + u8 candidate_tid_bitmap; + + struct rtw_ieee80211_ht_cap ht_cap; +}; + +#endif /* _RTL871X_HT_H_ */ diff --git a/drivers/staging/rtl8188eu/include/rtw_io.h b/drivers/staging/rtl8188eu/include/rtw_io.h new file mode 100644 index 0000000000000..eb6f0e550acfa --- /dev/null +++ b/drivers/staging/rtl8188eu/include/rtw_io.h @@ -0,0 +1,387 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#ifndef _RTW_IO_H_ +#define _RTW_IO_H_ + +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + +#define rtw_usb_buffer_alloc(dev, size, dma) \ + usb_alloc_coherent((dev), (size), (in_interrupt() ? \ + GFP_ATOMIC : GFP_KERNEL), (dma)) +#define rtw_usb_buffer_free(dev, size, addr, dma) \ + usb_free_coherent((dev), (size), (addr), (dma)) + +#define NUM_IOREQ 8 + +#define MAX_PROT_SZ (64-16) + +#define _IOREADY 0 +#define _IO_WAIT_COMPLETE 1 +#define _IO_WAIT_RSP 2 + +/* IO COMMAND TYPE */ +#define _IOSZ_MASK_ (0x7F) +#define _IO_WRITE_ BIT(7) +#define _IO_FIXED_ BIT(8) +#define _IO_BURST_ BIT(9) +#define _IO_BYTE_ BIT(10) +#define _IO_HW_ BIT(11) +#define _IO_WORD_ BIT(12) +#define _IO_SYNC_ BIT(13) +#define _IO_CMDMASK_ (0x1F80) + +/* + For prompt mode accessing, caller shall free io_req + Otherwise, io_handler will free io_req +*/ + +/* IO STATUS TYPE */ +#define _IO_ERR_ BIT(2) +#define _IO_SUCCESS_ BIT(1) +#define _IO_DONE_ BIT(0) + +#define IO_RD32 (_IO_SYNC_ | _IO_WORD_) +#define IO_RD16 (_IO_SYNC_ | _IO_HW_) +#define IO_RD8 (_IO_SYNC_ | _IO_BYTE_) + +#define IO_RD32_ASYNC (_IO_WORD_) +#define IO_RD16_ASYNC (_IO_HW_) +#define IO_RD8_ASYNC (_IO_BYTE_) + +#define IO_WR32 (_IO_WRITE_ | _IO_SYNC_ | _IO_WORD_) +#define IO_WR16 (_IO_WRITE_ | _IO_SYNC_ | _IO_HW_) +#define IO_WR8 (_IO_WRITE_ | _IO_SYNC_ | _IO_BYTE_) + +#define IO_WR32_ASYNC (_IO_WRITE_ | _IO_WORD_) +#define IO_WR16_ASYNC (_IO_WRITE_ | _IO_HW_) +#define IO_WR8_ASYNC (_IO_WRITE_ | _IO_BYTE_) + +/* + Only Sync. burst accessing is provided. +*/ + +#define IO_WR_BURST(x) \ + (_IO_WRITE_ | _IO_SYNC_ | _IO_BURST_ | ((x) & _IOSZ_MASK_)) +#define IO_RD_BURST(x) \ + (_IO_SYNC_ | _IO_BURST_ | ((x) & _IOSZ_MASK_)) + +/* below is for the intf_option bit defition... */ + +#define _INTF_ASYNC_ BIT(0) /* support async io */ + +struct intf_priv; +struct intf_hdl; +struct io_queue; + +struct _io_ops { + u8 (*_read8)(struct intf_hdl *pintfhdl, u32 addr); + u16 (*_read16)(struct intf_hdl *pintfhdl, u32 addr); + u32 (*_read32)(struct intf_hdl *pintfhdl, u32 addr); + int (*_write8)(struct intf_hdl *pintfhdl, u32 addr, u8 val); + int (*_write16)(struct intf_hdl *pintfhdl, u32 addr, u16 val); + int (*_write32)(struct intf_hdl *pintfhdl, u32 addr, u32 val); + int (*_writeN)(struct intf_hdl *pintfhdl, u32 addr, u32 length, + u8 *pdata); + int (*_write8_async)(struct intf_hdl *pintfhdl, u32 addr, u8 val); + int (*_write16_async)(struct intf_hdl *pintfhdl, u32 addr, u16 val); + int (*_write32_async)(struct intf_hdl *pintfhdl, u32 addr, u32 val); + void (*_read_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, + u8 *pmem); + void (*_write_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, + u8 *pmem); + void (*_sync_irp_protocol_rw)(struct io_queue *pio_q); + u32 (*_read_interrupt)(struct intf_hdl *pintfhdl, u32 addr); + u32 (*_read_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, + u8 *pmem); + u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, + u8 *pmem); + u32 (*_write_scsi)(struct intf_hdl *pintfhdl,u32 cnt, u8 *pmem); + void (*_read_port_cancel)(struct intf_hdl *pintfhdl); + void (*_write_port_cancel)(struct intf_hdl *pintfhdl); +}; + +struct io_req { + struct list_head list; + u32 addr; + u32 val; + u32 command; + u32 status; + u8 *pbuf; + struct semaphore sema; + + void (*_async_io_callback)(struct adapter *padater, + struct io_req *pio_req, u8 *cnxt); + u8 *cnxt; +}; + +struct intf_hdl { + struct adapter *padapter; + struct dvobj_priv *pintf_dev; + struct _io_ops io_ops; +}; + +struct reg_protocol_rd { +#ifdef __LITTLE_ENDIAN + /* DW1 */ + u32 NumOfTrans:4; + u32 Reserved1:4; + u32 Reserved2:24; + /* DW2 */ + u32 ByteCount:7; + u32 WriteEnable:1; /* 0:read, 1:write */ + u32 FixOrContinuous:1; /* 0:continuous, 1: Fix */ + u32 BurstMode:1; + u32 Byte1Access:1; + u32 Byte2Access:1; + u32 Byte4Access:1; + u32 Reserved3:3; + u32 Reserved4:16; + /* DW3 */ + u32 BusAddress; + /* DW4 */ + /* u32 Value; */ +#else +/* DW1 */ + u32 Reserved1:4; + u32 NumOfTrans:4; + u32 Reserved2:24; + /* DW2 */ + u32 WriteEnable:1; + u32 ByteCount:7; + u32 Reserved3:3; + u32 Byte4Access:1; + + u32 Byte2Access:1; + u32 Byte1Access:1; + u32 BurstMode:1; + u32 FixOrContinuous:1; + u32 Reserved4:16; + /* DW3 */ + u32 BusAddress; + + /* DW4 */ +#endif +}; + +struct reg_protocol_wt { +#ifdef __LITTLE_ENDIAN + /* DW1 */ + u32 NumOfTrans:4; + u32 Reserved1:4; + u32 Reserved2:24; + /* DW2 */ + u32 ByteCount:7; + u32 WriteEnable:1; /* 0:read, 1:write */ + u32 FixOrContinuous:1; /* 0:continuous, 1: Fix */ + u32 BurstMode:1; + u32 Byte1Access:1; + u32 Byte2Access:1; + u32 Byte4Access:1; + u32 Reserved3:3; + u32 Reserved4:16; + /* DW3 */ + u32 BusAddress; + /* DW4 */ + u32 Value; +#else + /* DW1 */ + u32 Reserved1 :4; + u32 NumOfTrans:4; + u32 Reserved2:24; + /* DW2 */ + u32 WriteEnable:1; + u32 ByteCount:7; + u32 Reserved3:3; + u32 Byte4Access:1; + u32 Byte2Access:1; + u32 Byte1Access:1; + u32 BurstMode:1; + u32 FixOrContinuous:1; + u32 Reserved4:16; + /* DW3 */ + u32 BusAddress; + /* DW4 */ + u32 Value; +#endif +}; + +/* +Below is the data structure used by _io_handler +*/ + +struct io_queue { + spinlock_t lock; + struct list_head free_ioreqs; + struct list_head pending; /* The io_req list that will be served + * in the single protocol read/write.*/ + struct list_head processing; + u8 *free_ioreqs_buf; /* 4-byte aligned */ + u8 *pallocated_free_ioreqs_buf; + struct intf_hdl intf; +}; + +struct io_priv { + struct adapter *padapter; + struct intf_hdl intf; +}; + +uint ioreq_flush(struct adapter *adapter, struct io_queue *ioqueue); +void sync_ioreq_enqueue(struct io_req *preq,struct io_queue *ioqueue); +uint sync_ioreq_flush(struct adapter *adapter, struct io_queue *ioqueue); +uint free_ioreq(struct io_req *preq, struct io_queue *pio_queue); +struct io_req *alloc_ioreq(struct io_queue *pio_q); + +uint register_intf_hdl(u8 *dev, struct intf_hdl *pintfhdl); +void unregister_intf_hdl(struct intf_hdl *pintfhdl); + +void _rtw_attrib_read(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem); +void _rtw_attrib_write(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem); + +u8 _rtw_read8(struct adapter *adapter, u32 addr); +u16 _rtw_read16(struct adapter *adapter, u32 addr); +u32 _rtw_read32(struct adapter *adapter, u32 addr); +void _rtw_read_mem(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem); +void _rtw_read_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem); +void _rtw_read_port_cancel(struct adapter *adapter); + +int _rtw_write8(struct adapter *adapter, u32 addr, u8 val); +int _rtw_write16(struct adapter *adapter, u32 addr, u16 val); +int _rtw_write32(struct adapter *adapter, u32 addr, u32 val); +int _rtw_writeN(struct adapter *adapter, u32 addr, u32 length, u8 *pdata); + +int _rtw_write8_async(struct adapter *adapter, u32 addr, u8 val); +int _rtw_write16_async(struct adapter *adapter, u32 addr, u16 val); +int _rtw_write32_async(struct adapter *adapter, u32 addr, u32 val); + +void _rtw_write_mem(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem); +u32 _rtw_write_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem); +u32 _rtw_write_port_and_wait(struct adapter *adapter, u32 addr, u32 cnt, + u8 *pmem, int timeout_ms); +void _rtw_write_port_cancel(struct adapter *adapter); + +#define rtw_read8(adapter, addr) _rtw_read8((adapter), (addr)) +#define rtw_read16(adapter, addr) _rtw_read16((adapter), (addr)) +#define rtw_read32(adapter, addr) _rtw_read32((adapter), (addr)) +#define rtw_read_mem(adapter, addr, cnt, mem) \ + _rtw_read_mem((adapter), (addr), (cnt), (mem)) +#define rtw_read_port(adapter, addr, cnt, mem) \ + _rtw_read_port((adapter), (addr), (cnt), (mem)) +#define rtw_read_port_cancel(adapter) _rtw_read_port_cancel((adapter)) + +#define rtw_write8(adapter, addr, val) \ + _rtw_write8((adapter), (addr), (val)) +#define rtw_write16(adapter, addr, val) \ + _rtw_write16((adapter), (addr), (val)) +#define rtw_write32(adapter, addr, val) \ + _rtw_write32((adapter), (addr), (val)) +#define rtw_writeN(adapter, addr, length, data) \ + _rtw_writeN((adapter), (addr), (length), (data)) +#define rtw_write8_async(adapter, addr, val) \ + _rtw_write8_async((adapter), (addr), (val)) +#define rtw_write16_async(adapter, addr, val) \ + _rtw_write16_async((adapter), (addr), (val)) +#define rtw_write32_async(adapter, addr, val) \ + _rtw_write32_async((adapter), (addr), (val)) +#define rtw_write_mem(adapter, addr, cnt, mem) \ + _rtw_write_mem((adapter), (addr), (cnt), (mem)) +#define rtw_write_port(adapter, addr, cnt, mem) \ + _rtw_write_port((adapter), (addr), (cnt), (mem)) +#define rtw_write_port_and_wait(adapter, addr, cnt, mem, timeout_ms) \ + _rtw_write_port_and_wait((adapter), (addr), (cnt), (mem), (timeout_ms)) +#define rtw_write_port_cancel(adapter) _rtw_write_port_cancel((adapter)) + +void rtw_write_scsi(struct adapter *adapter, u32 cnt, u8 *pmem); + +/* ioreq */ +void ioreq_read8(struct adapter *adapter, u32 addr, u8 *pval); +void ioreq_read16(struct adapter *adapter, u32 addr, u16 *pval); +void ioreq_read32(struct adapter *adapter, u32 addr, u32 *pval); +void ioreq_write8(struct adapter *adapter, u32 addr, u8 val); +void ioreq_write16(struct adapter *adapter, u32 addr, u16 val); +void ioreq_write32(struct adapter *adapter, u32 addr, u32 val); + +uint async_read8(struct adapter *adapter, u32 addr, u8 *pbuff, + void (*_async_io_callback)(struct adapter *padater, + struct io_req *pio_req, + u8 *cnxt), u8 *cnxt); +uint async_read16(struct adapter *adapter, u32 addr, u8 *pbuff, + void (*_async_io_callback)(struct adapter *padater, + struct io_req *pio_req, + u8 *cnxt), u8 *cnxt); +uint async_read32(struct adapter *adapter, u32 addr, u8 *pbuff, + void (*_async_io_callback)(struct adapter *padater, + struct io_req *pio_req, + u8 *cnxt), u8 *cnxt); + +void async_read_mem(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem); +void async_read_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem); + +void async_write8(struct adapter *adapter, u32 addr, u8 val, + void (*_async_io_callback)(struct adapter *padater, + struct io_req *pio_req, + u8 *cnxt), u8 *cnxt); +void async_write16(struct adapter *adapter, u32 addr, u16 val, + void (*_async_io_callback)(struct adapter *padater, + struct io_req *pio_req, + u8 *cnxt), u8 *cnxt); +void async_write32(struct adapter *adapter, u32 addr, u32 val, + void (*_async_io_callback)(struct adapter *padater, + struct io_req *pio_req, + u8 *cnxt), u8 *cnxt); + +void async_write_mem(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem); +void async_write_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem); + +int rtw_init_io_priv(struct adapter *padapter, + void (*set_intf_ops)(struct _io_ops *pops)); + +uint alloc_io_queue(struct adapter *adapter); +void free_io_queue(struct adapter *adapter); +void async_bus_io(struct io_queue *pio_q); +void bus_sync_io(struct io_queue *pio_q); +u32 _ioreq2rwmem(struct io_queue *pio_q); +void dev_power_down(struct adapter * Adapter, u8 bpwrup); + +#define PlatformEFIOWrite1Byte(_a,_b,_c) \ + rtw_write8(_a,_b,_c) +#define PlatformEFIOWrite2Byte(_a,_b,_c) \ + rtw_write16(_a,_b,_c) +#define PlatformEFIOWrite4Byte(_a,_b,_c) \ + rtw_write32(_a,_b,_c) + +#define PlatformEFIORead1Byte(_a,_b) \ + rtw_read8(_a,_b) +#define PlatformEFIORead2Byte(_a,_b) \ + rtw_read16(_a,_b) +#define PlatformEFIORead4Byte(_a,_b) \ + rtw_read32(_a,_b) + +#endif /* _RTL8711_IO_H_ */ diff --git a/drivers/staging/rtl8188eu/include/rtw_ioctl.h b/drivers/staging/rtl8188eu/include/rtw_ioctl.h new file mode 100644 index 0000000000000..8772d1d178c65 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/rtw_ioctl.h @@ -0,0 +1,124 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef _RTW_IOCTL_H_ +#define _RTW_IOCTL_H_ + +#include +#include + + +#ifndef OID_802_11_CAPABILITY + #define OID_802_11_CAPABILITY 0x0d010122 +#endif + +#ifndef OID_802_11_PMKID + #define OID_802_11_PMKID 0x0d010123 +#endif + + +/* For DDK-defined OIDs */ +#define OID_NDIS_SEG1 0x00010100 +#define OID_NDIS_SEG2 0x00010200 +#define OID_NDIS_SEG3 0x00020100 +#define OID_NDIS_SEG4 0x01010100 +#define OID_NDIS_SEG5 0x01020100 +#define OID_NDIS_SEG6 0x01020200 +#define OID_NDIS_SEG7 0xFD010100 +#define OID_NDIS_SEG8 0x0D010100 +#define OID_NDIS_SEG9 0x0D010200 +#define OID_NDIS_SEG10 0x0D020200 + +#define SZ_OID_NDIS_SEG1 23 +#define SZ_OID_NDIS_SEG2 3 +#define SZ_OID_NDIS_SEG3 6 +#define SZ_OID_NDIS_SEG4 6 +#define SZ_OID_NDIS_SEG5 4 +#define SZ_OID_NDIS_SEG6 8 +#define SZ_OID_NDIS_SEG7 7 +#define SZ_OID_NDIS_SEG8 36 +#define SZ_OID_NDIS_SEG9 24 +#define SZ_OID_NDIS_SEG10 19 + +/* For Realtek-defined OIDs */ +#define OID_MP_SEG1 0xFF871100 +#define OID_MP_SEG2 0xFF818000 + +#define OID_MP_SEG3 0xFF818700 +#define OID_MP_SEG4 0xFF011100 + +#define DEBUG_OID(dbg, str) \ + if ((!dbg)) { \ + RT_TRACE(_module_rtl871x_ioctl_c_, _drv_info_, \ + ("%s(%d): %s", __func__, __line__, str)); \ + } + +enum oid_type { + QUERY_OID, + SET_OID +}; + +struct oid_funs_node { + unsigned int oid_start; /* the starting number for OID */ + unsigned int oid_end; /* the ending number for OID */ + struct oid_obj_priv *node_array; + unsigned int array_sz; /* the size of node_array */ + int query_counter; /* count the number of query hits for this segment */ + int set_counter; /* count the number of set hits for this segment */ +}; + +struct oid_par_priv { + void *adapter_context; + NDIS_OID oid; + void *information_buf; + u32 information_buf_len; + u32 *bytes_rw; + u32 *bytes_needed; + enum oid_type type_of_oid; + u32 dbg; +}; + +struct oid_obj_priv { + unsigned char dbg; /* 0: without OID debug message + * 1: with OID debug message */ + int (*oidfuns)(struct oid_par_priv *poid_par_priv); +}; + +#if defined(_RTW_MP_IOCTL_C_) +static int oid_null_function(struct oid_par_priv *poid_par_priv) { + _func_enter_; + _func_exit_; + return NDIS_STATUS_SUCCESS; +} +#endif + +extern struct iw_handler_def rtw_handlers_def; + +int drv_query_info(struct net_device *miniportadaptercontext, NDIS_OID oid, + void *informationbuffer, u32 informationbufferlength, + u32 *byteswritten, u32 *bytesneeded); + +int drv_set_info(struct net_device *MiniportAdapterContext, + NDIS_OID oid, void *informationbuffer, + u32 informationbufferlength, u32 *bytesread, + u32 *bytesneeded); + +extern int ui_pid[3]; + +#endif /* #ifndef __INC_CEINFO_ */ diff --git a/drivers/staging/rtl8188eu/include/rtw_ioctl_rtl.h b/drivers/staging/rtl8188eu/include/rtw_ioctl_rtl.h new file mode 100644 index 0000000000000..8fa3858cb7769 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/rtw_ioctl_rtl.h @@ -0,0 +1,79 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef _RTW_IOCTL_RTL_H_ +#define _RTW_IOCTL_RTL_H_ + +#include +#include + +/* oid_rtl_seg_01_01 ************** */ +int oid_rt_get_signal_quality_hdl(struct oid_par_priv *poid_par_priv);/* 84 */ +int oid_rt_get_small_packet_crc_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_middle_packet_crc_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_large_packet_crc_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_tx_retry_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_rx_retry_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_rx_total_packet_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_tx_beacon_ok_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_tx_beacon_err_hdl(struct oid_par_priv *poid_par_priv); + +int oid_rt_pro_set_fw_dig_state_hdl(struct oid_par_priv *poid_par_priv);/* 8a */ +int oid_rt_pro_set_fw_ra_state_hdl(struct oid_par_priv *poid_par_priv); /* 8b */ + +int oid_rt_get_rx_icv_err_hdl(struct oid_par_priv *poid_par_priv);/* 93 */ +int oid_rt_set_encryption_algorithm_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_preamble_mode_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_ap_ip_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_channelplan_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_set_channelplan_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_set_preamble_mode_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_set_bcn_intvl_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_dedicate_probe_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_total_tx_bytes_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_total_rx_bytes_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_current_tx_power_level_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_enc_key_mismatch_count_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_enc_key_match_count_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_channel_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_hardware_radio_off_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_key_mismatch_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_supported_wireless_mode_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_channel_list_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_scan_in_progress_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_forced_data_rate_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_wireless_mode_for_scan_list_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_bss_wireless_mode_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_scan_with_magic_packet_hdl(struct oid_par_priv *poid_par_priv); + +/* oid_rtl_seg_01_03 section start ************** */ +int oid_rt_ap_get_associated_station_list_hdl(struct oid_par_priv *priv); +int oid_rt_ap_switch_into_ap_mode_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_ap_supported_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_ap_set_passphrase_hdl(struct oid_par_priv *poid_par_priv); + +/* oid_rtl_seg_01_11 */ +int oid_rt_pro_rf_write_registry_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_pro_rf_read_registry_hdl(struct oid_par_priv *poid_par_priv); + +/* oid_rtl_seg_03_00 section start ************** */ +int oid_rt_get_connect_state_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_set_default_key_id_hdl(struct oid_par_priv *poid_par_priv); + +#endif diff --git a/drivers/staging/rtl8188eu/include/rtw_ioctl_set.h b/drivers/staging/rtl8188eu/include/rtw_ioctl_set.h new file mode 100644 index 0000000000000..49efb23747de6 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/rtw_ioctl_set.h @@ -0,0 +1,50 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __RTW_IOCTL_SET_H_ +#define __RTW_IOCTL_SET_H_ + +#include + + +typedef u8 NDIS_802_11_PMKID_VALUE[16]; + +u8 rtw_set_802_11_add_key(struct adapter *adapt, struct ndis_802_11_key *key); +u8 rtw_set_802_11_authentication_mode(struct adapter *adapt, + enum ndis_802_11_auth_mode authmode); +u8 rtw_set_802_11_bssid(struct adapter*adapter, u8 *bssid); +u8 rtw_set_802_11_add_wep(struct adapter *adapter, struct ndis_802_11_wep *wep); +u8 rtw_set_802_11_disassociate(struct adapter *adapter); +u8 rtw_set_802_11_bssid_list_scan(struct adapter*adapter, + struct ndis_802_11_ssid *pssid, + int ssid_max_num); +u8 rtw_set_802_11_infrastructure_mode(struct adapter *adapter, + enum ndis_802_11_network_infra type); +u8 rtw_set_802_11_remove_wep(struct adapter *adapter, u32 keyindex); +u8 rtw_set_802_11_ssid(struct adapter *adapt, struct ndis_802_11_ssid *ssid); +u8 rtw_set_802_11_remove_key(struct adapter *adapt, + struct ndis_802_11_remove_key *key); +u8 rtw_validate_ssid(struct ndis_802_11_ssid *ssid); +u16 rtw_get_cur_max_rate(struct adapter *adapter); +int rtw_set_scan_mode(struct adapter *adapter, enum rt_scan_type scan_mode); +int rtw_set_channel_plan(struct adapter *adapter, u8 channel_plan); +int rtw_set_country(struct adapter *adapter, const char *country_code); +int rtw_change_ifname(struct adapter *padapter, const char *ifname); + +#endif diff --git a/drivers/staging/rtl8188eu/include/rtw_iol.h b/drivers/staging/rtl8188eu/include/rtw_iol.h new file mode 100644 index 0000000000000..6949922baa659 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/rtw_iol.h @@ -0,0 +1,84 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __RTW_IOL_H_ +#define __RTW_IOL_H_ + +#include +#include + +#define IOREG_CMD_END_LEN 4 + +struct ioreg_cfg { + u8 length; + u8 cmd_id; + __le16 address; + __le32 data; + __le32 mask; +}; + +enum ioreg_cmd { + IOREG_CMD_LLT = 0x01, + IOREG_CMD_REFUSE = 0x02, + IOREG_CMD_EFUSE_PATH = 0x03, + IOREG_CMD_WB_REG = 0x04, + IOREG_CMD_WW_REG = 0x05, + IOREG_CMD_WD_REG = 0x06, + IOREG_CMD_W_RF = 0x07, + IOREG_CMD_DELAY_US = 0x10, + IOREG_CMD_DELAY_MS = 0x11, + IOREG_CMD_END = 0xFF, +}; + +struct xmit_frame *rtw_IOL_accquire_xmit_frame(struct adapter *adapter); +int rtw_IOL_append_cmds(struct xmit_frame *xmit_frame, u8 *IOL_cmds, + u32 cmd_len); +int rtw_IOL_append_LLT_cmd(struct xmit_frame *xmit_frame, u8 page_boundary); +int rtw_IOL_exec_cmds_sync(struct adapter *adapter, + struct xmit_frame *xmit_frame, u32 max_wating_ms, + u32 bndy_cnt); +bool rtw_IOL_applied(struct adapter *adapter); +int rtw_IOL_append_DELAY_US_cmd(struct xmit_frame *xmit_frame, u16 us); +int rtw_IOL_append_DELAY_MS_cmd(struct xmit_frame *xmit_frame, u16 ms); +int rtw_IOL_append_END_cmd(struct xmit_frame *xmit_frame); + +void read_efuse_from_txpktbuf(struct adapter *adapter, int bcnhead, + u8 *content, u16 *size); + +int _rtw_IOL_append_WB_cmd(struct xmit_frame *xmit_frame, u16 addr, + u8 value, u8 mask); +int _rtw_IOL_append_WW_cmd(struct xmit_frame *xmit_frame, u16 addr, + u16 value, u16 mask); +int _rtw_IOL_append_WD_cmd(struct xmit_frame *xmit_frame, u16 addr, + u32 value, u32 mask); +int _rtw_IOL_append_WRF_cmd(struct xmit_frame *xmit_frame, u8 rf_path, + u16 addr, u32 value, u32 mask); +#define rtw_IOL_append_WB_cmd(xmit_frame, addr, value, mask) \ + _rtw_IOL_append_WB_cmd((xmit_frame), (addr), (value) ,(mask)) +#define rtw_IOL_append_WW_cmd(xmit_frame, addr, value, mask) \ + _rtw_IOL_append_WW_cmd((xmit_frame), (addr), (value),(mask)) +#define rtw_IOL_append_WD_cmd(xmit_frame, addr, value, mask) \ + _rtw_IOL_append_WD_cmd((xmit_frame), (addr), (value), (mask)) +#define rtw_IOL_append_WRF_cmd(xmit_frame, rf_path, addr, value, mask) \ + _rtw_IOL_append_WRF_cmd((xmit_frame),(rf_path), (addr), (value), (mask)) + +u8 rtw_IOL_cmd_boundary_handle(struct xmit_frame *pxmit_frame); +void rtw_IOL_cmd_buf_dump(struct adapter *Adapter,int buf_len,u8 *pbuf); + +#endif /* __RTW_IOL_H_ */ diff --git a/drivers/staging/rtl8188eu/include/rtw_led.h b/drivers/staging/rtl8188eu/include/rtw_led.h new file mode 100644 index 0000000000000..19d5753d9e272 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/rtw_led.h @@ -0,0 +1,197 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __RTW_LED_H_ +#define __RTW_LED_H_ + +#include +#include + +#define MSECS(t) (HZ * ((t) / 1000) + (HZ * ((t) % 1000)) / 1000) + +#define LED_BLINK_NORMAL_INTERVAL 100 +#define LED_BLINK_SLOWLY_INTERVAL 200 +#define LED_BLINK_LONG_INTERVAL 400 + +#define LED_BLINK_NO_LINK_INTERVAL_ALPHA 1000 +#define LED_BLINK_LINK_INTERVAL_ALPHA 500 /* 500 */ +#define LED_BLINK_SCAN_INTERVAL_ALPHA 180 /* 150 */ +#define LED_BLINK_FASTER_INTERVAL_ALPHA 50 +#define LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA 5000 + +#define LED_BLINK_NORMAL_INTERVAL_NETTRONIX 100 +#define LED_BLINK_SLOWLY_INTERVAL_NETTRONIX 2000 + +#define LED_BLINK_SLOWLY_INTERVAL_PORNET 1000 +#define LED_BLINK_NORMAL_INTERVAL_PORNET 100 + +#define LED_BLINK_FAST_INTERVAL_BITLAND 30 + +/* 060403, rcnjko: Customized for AzWave. */ +#define LED_CM2_BLINK_ON_INTERVAL 250 +#define LED_CM2_BLINK_OFF_INTERVAL 4750 + +#define LED_CM8_BLINK_INTERVAL 500 /* for QMI */ +#define LED_CM8_BLINK_OFF_INTERVAL 3750 /* for QMI */ + +/* 080124, lanhsin: Customized for RunTop */ +#define LED_RunTop_BLINK_INTERVAL 300 + +/* 060421, rcnjko: Customized for Sercomm Printer Server case. */ +#define LED_CM3_BLINK_INTERVAL 1500 + +enum LED_CTL_MODE { + LED_CTL_POWER_ON = 1, + LED_CTL_LINK = 2, + LED_CTL_NO_LINK = 3, + LED_CTL_TX = 4, + LED_CTL_RX = 5, + LED_CTL_SITE_SURVEY = 6, + LED_CTL_POWER_OFF = 7, + LED_CTL_START_TO_LINK = 8, + LED_CTL_START_WPS = 9, + LED_CTL_STOP_WPS = 10, + LED_CTL_START_WPS_BOTTON = 11, /* added for runtop */ + LED_CTL_STOP_WPS_FAIL = 12, /* added for ALPHA */ + LED_CTL_STOP_WPS_FAIL_OVERLAP = 13, /* added for BELKIN */ + LED_CTL_CONNECTION_NO_TRANSFER = 14, +}; + +enum LED_STATE_871x { + LED_UNKNOWN = 0, + RTW_LED_ON = 1, + RTW_LED_OFF = 2, + LED_BLINK_NORMAL = 3, + LED_BLINK_SLOWLY = 4, + LED_BLINK_POWER_ON = 5, + LED_BLINK_SCAN = 6, /* LED is blinking during scanning period, + * the # of times to blink is depend on time + * for scanning. */ + LED_BLINK_NO_LINK = 7, /* LED is blinking during no link state. */ + LED_BLINK_StartToBlink = 8,/* Customzied for Sercomm Printer + * Server case */ + LED_BLINK_TXRX = 9, + LED_BLINK_WPS = 10, /* LED is blinkg during WPS communication */ + LED_BLINK_WPS_STOP = 11, /* for ALPHA */ + LED_BLINK_WPS_STOP_OVERLAP = 12, /* for BELKIN */ + LED_BLINK_RUNTOP = 13, /* Customized for RunTop */ + LED_BLINK_CAMEO = 14, + LED_BLINK_XAVI = 15, + LED_BLINK_ALWAYS_ON = 16, +}; + +enum LED_PIN_871x { + LED_PIN_NULL = 0, + LED_PIN_LED0 = 1, + LED_PIN_LED1 = 2, + LED_PIN_LED2 = 3, + LED_PIN_GPIO0 = 4, +}; + +struct LED_871x { + struct adapter *padapter; + + enum LED_PIN_871x LedPin; /* Identify how to implement this + * SW led. */ + enum LED_STATE_871x CurrLedState; /* Current LED state. */ + enum LED_STATE_871x BlinkingLedState; /* Next state for blinking, + * either RTW_LED_ON or RTW_LED_OFF are. */ + + u8 bLedOn; /* true if LED is ON, false if LED is OFF. */ + + u8 bLedBlinkInProgress; /* true if it is blinking, false o.w.. */ + + u8 bLedWPSBlinkInProgress; + + u32 BlinkTimes; /* Number of times to toggle led state for blinking. */ + + struct timer_list BlinkTimer; /* Timer object for led blinking. */ + + u8 bSWLedCtrl; + + /* ALPHA, added by chiyoko, 20090106 */ + u8 bLedNoLinkBlinkInProgress; + u8 bLedLinkBlinkInProgress; + u8 bLedStartToLinkBlinkInProgress; + u8 bLedScanBlinkInProgress; + struct work_struct BlinkWorkItem; /* Workitem used by BlinkTimer to + * manipulate H/W to blink LED. */ +}; + +#define IS_LED_WPS_BLINKING(_LED_871x) \ + (((struct LED_871x *)_LED_871x)->CurrLedState == LED_BLINK_WPS || \ + ((struct LED_871x *)_LED_871x)->CurrLedState == LED_BLINK_WPS_STOP || \ + ((struct LED_871x *)_LED_871x)->bLedWPSBlinkInProgress) + +#define IS_LED_BLINKING(_LED_871x) \ + (((struct LED_871x *)_LED_871x)->bLedWPSBlinkInProgress || \ + ((struct LED_871x *)_LED_871x)->bLedScanBlinkInProgress) + +/* LED customization. */ + +enum LED_STRATEGY_871x { + SW_LED_MODE0 = 0, /* SW control 1 LED via GPIO0. It is default option.*/ + SW_LED_MODE1= 1, /* 2 LEDs, through LED0 and LED1. For ALPHA. */ + SW_LED_MODE2 = 2, /* SW control 1 LED via GPIO0, customized for AzWave + * 8187 minicard. */ + SW_LED_MODE3 = 3, /* SW control 1 LED via GPIO0, customized for Sercomm + * Printer Server case. */ + SW_LED_MODE4 = 4, /* for Edimax / Belkin */ + SW_LED_MODE5 = 5, /* for Sercomm / Belkin */ + SW_LED_MODE6 = 6, /* for 88CU minicard, porting from ce SW_LED_MODE7 */ + HW_LED = 50, /* HW control 2 LEDs, LED0 and LED1 (there are 4 + * different control modes, see MAC.CONFIG1 for details.)*/ + LED_ST_NONE = 99, +}; + +void LedControl871x(struct adapter *padapter, enum LED_CTL_MODE LedAction); + +struct led_priv{ + /* add for led controll */ + struct LED_871x SwLed0; + struct LED_871x SwLed1; + enum LED_STRATEGY_871x LedStrategy; + u8 bRegUseLed; + void (*LedControlHandler)(struct adapter *padapter, + enum LED_CTL_MODE LedAction); + /* add for led controll */ +}; + +#define rtw_led_control(adapt, action) \ + do { \ + if ((adapt)->ledpriv.LedControlHandler) \ + (adapt)->ledpriv.LedControlHandler((adapt), (action)); \ + } while (0) + +void BlinkTimerCallback(void *data); +void BlinkWorkItemCallback(struct work_struct *work); + +void ResetLedStatus(struct LED_871x * pLed); + +void InitLed871x(struct adapter *padapter, struct LED_871x *pLed, + enum LED_PIN_871x LedPin); + +void DeInitLed871x(struct LED_871x *pLed); + +/* hal... */ +void BlinkHandler(struct LED_871x * pLed); +void SwLedOn(struct adapter *padapter, struct LED_871x *pLed); +void SwLedOff(struct adapter *padapter, struct LED_871x *pLed); + +#endif /* __RTW_LED_H_ */ -- GitLab From 4218e5be86f81212bade97dc96552ffc70705ea6 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 21 Aug 2013 22:34:10 -0500 Subject: [PATCH 786/942] staging: r8188eu: Add files for new driver - part 28 This commit adds files include/rtw_mlme.h, include/rtw_mlme_ext.h, include/rtw_mp.h, include/rtw_mp_ioctl.h, and include/rtw_mp_phy_regdef.h. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/rtw_mlme.h | 655 ++++++++++ .../staging/rtl8188eu/include/rtw_mlme_ext.h | 877 +++++++++++++ drivers/staging/rtl8188eu/include/rtw_mp.h | 495 ++++++++ .../staging/rtl8188eu/include/rtw_mp_ioctl.h | 340 ++++++ .../rtl8188eu/include/rtw_mp_phy_regdef.h | 1084 +++++++++++++++++ 5 files changed, 3451 insertions(+) create mode 100644 drivers/staging/rtl8188eu/include/rtw_mlme.h create mode 100644 drivers/staging/rtl8188eu/include/rtw_mlme_ext.h create mode 100644 drivers/staging/rtl8188eu/include/rtw_mp.h create mode 100644 drivers/staging/rtl8188eu/include/rtw_mp_ioctl.h create mode 100644 drivers/staging/rtl8188eu/include/rtw_mp_phy_regdef.h diff --git a/drivers/staging/rtl8188eu/include/rtw_mlme.h b/drivers/staging/rtl8188eu/include/rtw_mlme.h new file mode 100644 index 0000000000000..22538e61695a1 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/rtw_mlme.h @@ -0,0 +1,655 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __RTW_MLME_H_ +#define __RTW_MLME_H_ + +#include +#include +#include +#include + +#define MAX_BSS_CNT 128 +#define MAX_JOIN_TIMEOUT 6500 + +/* Increase the scanning timeout because of increasing the SURVEY_TO value. */ + +#define SCANNING_TIMEOUT 8000 + +#define SCAN_INTERVAL (30) /* unit:2sec, 30*2=60sec */ + +#define SCANQUEUE_LIFETIME 20 /* unit:sec */ + +#define WIFI_NULL_STATE 0x00000000 + +#define WIFI_ASOC_STATE 0x00000001 /* Under Linked state */ +#define WIFI_REASOC_STATE 0x00000002 +#define WIFI_SLEEP_STATE 0x00000004 +#define WIFI_STATION_STATE 0x00000008 + +#define WIFI_AP_STATE 0x00000010 +#define WIFI_ADHOC_STATE 0x00000020 +#define WIFI_ADHOC_MASTER_STATE 0x00000040 +#define WIFI_UNDER_LINKING 0x00000080 + +#define WIFI_UNDER_WPS 0x00000100 +#define WIFI_STA_ALIVE_CHK_STATE 0x00000400 +#define WIFI_SITE_MONITOR 0x00000800 /* to indicate the station is under site surveying */ + +#define WIFI_MP_STATE 0x00010000 +#define WIFI_MP_CTX_BACKGROUND 0x00020000 /* in continous tx background */ +#define WIFI_MP_CTX_ST 0x00040000 /* in continous tx with single-tone */ +#define WIFI_MP_CTX_BACKGROUND_PENDING 0x00080000 /* pending in continous tx background due to out of skb */ +#define WIFI_MP_CTX_CCK_HW 0x00100000 /* in continous tx */ +#define WIFI_MP_CTX_CCK_CS 0x00200000 /* in continous tx with carrier suppression */ +#define WIFI_MP_LPBK_STATE 0x00400000 + +#define _FW_UNDER_LINKING WIFI_UNDER_LINKING +#define _FW_LINKED WIFI_ASOC_STATE +#define _FW_UNDER_SURVEY WIFI_SITE_MONITOR + +enum dot11AuthAlgrthmNum { + dot11AuthAlgrthm_Open = 0, + dot11AuthAlgrthm_Shared, + dot11AuthAlgrthm_8021X, + dot11AuthAlgrthm_Auto, + dot11AuthAlgrthm_WAPI, + dot11AuthAlgrthm_MaxNum +}; + +/* Scan type including active and passive scan. */ +enum rt_scan_type { + SCAN_PASSIVE, + SCAN_ACTIVE, + SCAN_MIX, +}; + +enum SCAN_RESULT_TYPE { + SCAN_RESULT_P2P_ONLY = 0, /* Will return all the P2P devices. */ + SCAN_RESULT_ALL = 1, /* Will return all the scanned device, + * include AP. */ + SCAN_RESULT_WFD_TYPE = 2 /* Will just return the correct WFD + * device. */ + /* If this device is Miracast sink + * device, it will just return all the + * Miracast source devices. */ +}; + +/* +there are several "locks" in mlme_priv, +since mlme_priv is a shared resource between many threads, +like ISR/Call-Back functions, the OID handlers, and even timer functions. + +Each _queue has its own locks, already. +Other items are protected by mlme_priv.lock. + +To avoid possible dead lock, any thread trying to modifiying mlme_priv +SHALL not lock up more than one lock at a time! +*/ + +#define traffic_threshold 10 +#define traffic_scan_period 500 + +struct sitesurvey_ctrl { + u64 last_tx_pkts; + uint last_rx_pkts; + int traffic_busy; + struct timer_list sitesurvey_ctrl_timer; +}; + +struct rt_link_detect { + u32 NumTxOkInPeriod; + u32 NumRxOkInPeriod; + u32 NumRxUnicastOkInPeriod; + bool bBusyTraffic; + bool bTxBusyTraffic; + bool bRxBusyTraffic; + bool bHigherBusyTraffic; /* For interrupt migration purpose. */ + bool bHigherBusyRxTraffic; /* We may disable Tx interrupt according + * to Rx traffic. */ + bool bHigherBusyTxTraffic; /* We may disable Tx interrupt according + * to Tx traffic. */ +}; + +struct profile_info { + u8 ssidlen; + u8 ssid[ WLAN_SSID_MAXLEN ]; + u8 peermac[ ETH_ALEN ]; +}; + +struct tx_invite_req_info { + u8 token; + u8 benable; + u8 go_ssid[ WLAN_SSID_MAXLEN ]; + u8 ssidlen; + u8 go_bssid[ ETH_ALEN ]; + u8 peer_macaddr[ ETH_ALEN ]; + u8 operating_ch; /* This information will be set by using the + * p2p_set op_ch=x */ + u8 peer_ch; /* The listen channel for peer P2P device */ +}; + +struct tx_invite_resp_info { + u8 token; /* Used to record the dialog token of p2p invitation + * request frame. */ +}; + +struct tx_provdisc_req_info { + u16 wps_config_method_request; /* Used when sending the + * provisioning request frame*/ + u16 peer_channel_num[2]; /* The channel number which the + * receiver stands. */ + struct ndis_802_11_ssid ssid; + u8 peerDevAddr[ETH_ALEN]; /* Peer device address */ + u8 peerIFAddr[ETH_ALEN]; /* Peer interface address */ + u8 benable; /* This provision discovery + * request frame is trigger + * to send or not */ +}; + +/* When peer device issue prov_disc_req first, we should store the following + * information */ +/* The UI must know this information to know which config method the + * remote p2p device needs. */ +struct rx_provdisc_req_info { + u8 peerDevAddr[ETH_ALEN]; /* Peer device address */ + u8 strconfig_method_desc_of_prov_disc_req[4]; /* description + * for the config method located in the provisioning + * discovery request frame. */ +}; + +struct tx_nego_req_info { + u16 peer_channel_num[2]; /* The channel number. */ + u8 peerDevAddr[ETH_ALEN]; /* Peer device address */ + u8 benable; /* This negotiation request frame is + * trigger to send or not */ +}; + +struct group_id_info { + u8 go_device_addr[ ETH_ALEN ]; /* The GO's device address of + * this P2P group */ + u8 ssid[ WLAN_SSID_MAXLEN ]; /* The SSID of this P2P group */ +}; + +struct scan_limit_info { + u8 scan_op_ch_only; /* When this flag is set, the driver + * should only scan the op. channel */ + u8 operation_ch[2]; /* Store the op. chan of invitation */ +}; + +struct wifidirect_info { + struct adapter *padapter; + struct timer_list find_phase_timer; + struct timer_list restore_p2p_state_timer; + + /* Used to do the scanning. After confirming the peer is availalble, + * the driver transmits the P2P frame to peer. */ + struct timer_list pre_tx_scan_timer; + struct timer_list reset_ch_sitesurvey; + struct timer_list reset_ch_sitesurvey2; /* Just for resetting the scan + * limit function by using p2p nego */ + struct tx_provdisc_req_info tx_prov_disc_info; + struct rx_provdisc_req_info rx_prov_disc_info; + struct tx_invite_req_info invitereq_info; + /* Store the profile information of persistent group */ + struct profile_info profileinfo[P2P_MAX_PERSISTENT_GROUP_NUM]; + struct tx_invite_resp_info inviteresp_info; + struct tx_nego_req_info nego_req_info; + /* Store the group id info when doing the group negot handshake. */ + struct group_id_info groupid_info; + /* Used for get the limit scan channel from the Invitation procedure */ + struct scan_limit_info rx_invitereq_info; + /* Used for get the limit scan chan from the P2P negotiation handshake*/ + struct scan_limit_info p2p_info; + enum P2P_ROLE role; + enum P2P_STATE pre_p2p_state; + enum P2P_STATE p2p_state; + /* The device address should be the mac address of this device. */ + u8 device_addr[ETH_ALEN]; + u8 interface_addr[ETH_ALEN]; + u8 social_chan[4]; + u8 listen_channel; + u8 operating_channel; + u8 listen_dwell; /* This value should be between 1 and 3 */ + u8 support_rate[8]; + u8 p2p_wildcard_ssid[P2P_WILDCARD_SSID_LEN]; + u8 intent; /* should only include the intent value. */ + u8 p2p_peer_interface_addr[ETH_ALEN]; + u8 p2p_peer_device_addr[ETH_ALEN]; + u8 peer_intent; /* Included the intent value and tie breaker value. */ + /* Device name for displaying on searching device screen */ + u8 device_name[WPS_MAX_DEVICE_NAME_LEN]; + u8 device_name_len; + u8 profileindex; /* Used to point to the index of profileinfo array */ + u8 peer_operating_ch; + u8 find_phase_state_exchange_cnt; + /* The device password ID for group negotation */ + u16 device_password_id_for_nego; + u8 negotiation_dialog_token; + /* SSID information for group negotitation */ + u8 nego_ssid[WLAN_SSID_MAXLEN]; + u8 nego_ssidlen; + u8 p2p_group_ssid[WLAN_SSID_MAXLEN]; + u8 p2p_group_ssid_len; + /* Flag to know if the persistent function should be supported or not.*/ + u8 persistent_supported; + /* In the Sigma test, the Sigma will provide this enable from the + * sta_set_p2p CAPI. */ + /* 0: disable */ + /* 1: enable */ + u8 session_available; /* Flag to set the WFD session available to + * enable or disable "by Sigma" */ + /* In the Sigma test, the Sigma will disable the session available + * by using the sta_preset CAPI. */ + /* 0: disable */ + /* 1: enable */ + u8 wfd_tdls_enable; /* Flag to enable or disable the TDLS by WFD Sigma*/ + /* 0: disable */ + /* 1: enable */ + u8 wfd_tdls_weaksec; /* Flag to enable or disable the weak security + * function for TDLS by WFD Sigma */ + /* 0: disable */ + /* In this case, the driver can't issue the tdsl + * setup request frame. */ + /* 1: enable */ + /* In this case, the driver can issue the tdls + * setup request frame */ + /* even the current security is weak security. */ + + /* This field will store the WPS value (PIN value or PBC) that UI had + * got from the user. */ + enum P2P_WPSINFO ui_got_wps_info; + u16 supported_wps_cm; /* This field describes the WPS config method + * which this driver supported. */ + /* The value should be the combination of config + * method defined in page104 of WPS v2.0 spec.*/ + /* This field will contain the length of body of P2P Channel List + * attribute of group negotiation response frame. */ + uint channel_list_attr_len; + /* This field will contain the body of P2P Channel List attribute of + * group negotitation response frame. */ + /* We will use the channel_cnt and channel_list fields when constructing + * the group negotiation confirm frame. */ + u8 channel_list_attr[100]; + enum P2P_PS_MODE p2p_ps_mode; /* indicate p2p ps mode */ + enum P2P_PS_STATE p2p_ps_state; /* indicate p2p ps state */ + u8 noa_index; /* Identifies and instance of Notice of Absence timing. */ + u8 ctwindow; /* Client traffic window. A period of time in TU after TBTT. */ + u8 opp_ps; /* opportunistic power save. */ + u8 noa_num; /* number of NoA descriptor in P2P IE. */ + u8 noa_count[P2P_MAX_NOA_NUM]; /* Count for owner, Type of client. */ + /* Max duration for owner, preferred or min acceptable duration for + * client. */ + u32 noa_duration[P2P_MAX_NOA_NUM]; + /* Length of interval for owner, preferred or max acceptable interval + * of client. */ + u32 noa_interval[P2P_MAX_NOA_NUM]; + /* schedule expressed in terms of the lower 4 bytes of the TSF timer. */ + u32 noa_start_time[P2P_MAX_NOA_NUM]; +}; + +struct tdls_ss_record { /* signal strength record */ + u8 macaddr[ETH_ALEN]; + u8 RxPWDBAll; + u8 is_tdls_sta; /* true: direct link sta, false: else */ +}; + +struct tdls_info { + u8 ap_prohibited; + uint setup_state; + u8 sta_cnt; + u8 sta_maximum; /* 1:tdls sta is equal (NUM_STA-1), reach max direct link number; 0: else; */ + struct tdls_ss_record ss_record; + u8 macid_index; /* macid entry that is ready to write */ + u8 clear_cam; /* cam entry that is trying to clear, using it in direct link teardown */ + u8 ch_sensing; + u8 cur_channel; + u8 candidate_ch; + u8 collect_pkt_num[MAX_CHANNEL_NUM]; + spinlock_t cmd_lock; + spinlock_t hdl_lock; + u8 watchdog_count; + u8 dev_discovered; /* WFD_TDLS: for sigma test */ + u8 enable; +}; + +struct mlme_priv { + spinlock_t lock; + int fw_state; /* shall we protect this variable? maybe not necessarily... */ + u8 bScanInProcess; + u8 to_join; /* flag */ + u8 to_roaming; /* roaming trying times */ + + u8 *nic_hdl; + + u8 not_indic_disco; + struct list_head *pscanned; + struct __queue free_bss_pool; + struct __queue scanned_queue; + u8 *free_bss_buf; + u32 num_of_scanned; + + struct ndis_802_11_ssid assoc_ssid; + u8 assoc_bssid[6]; + + struct wlan_network cur_network; + + u32 scan_interval; + + struct timer_list assoc_timer; + + uint assoc_by_bssid; + uint assoc_by_rssi; + + struct timer_list scan_to_timer; /* driver itself handles scan_timeout status. */ + u32 scan_start_time; /* used to evaluate the time spent in scanning */ + + struct qos_priv qospriv; + + /* Number of non-HT AP/stations */ + int num_sta_no_ht; + + /* Number of HT AP/stations 20 MHz */ + /* int num_sta_ht_20mhz; */ + + int num_FortyMHzIntolerant; + struct ht_priv htpriv; + struct rt_link_detect LinkDetectInfo; + struct timer_list dynamic_chk_timer; /* dynamic/periodic check timer */ + + u8 key_mask; /* use for ips to set wep key after ips_leave */ + u8 acm_mask; /* for wmm acm mask */ + u8 ChannelPlan; + enum rt_scan_type scan_mode; /* active: 1, passive: 0 */ + + /* u8 probereq_wpsie[MAX_WPS_IE_LEN];added in probe req */ + /* int probereq_wpsie_len; */ + u8 *wps_probe_req_ie; + u32 wps_probe_req_ie_len; + + u8 *assoc_req; + u32 assoc_req_len; + u8 *assoc_rsp; + u32 assoc_rsp_len; + +#if defined (CONFIG_88EU_AP_MODE) + /* Number of associated Non-ERP stations (i.e., stations using 802.11b + * in 802.11g BSS) */ + int num_sta_non_erp; + + /* Number of associated stations that do not support Short Slot Time */ + int num_sta_no_short_slot_time; + + /* Number of associated stations that do not support Short Preamble */ + int num_sta_no_short_preamble; + + int olbc; /* Overlapping Legacy BSS Condition */ + + /* Number of HT assoc sta that do not support greenfield */ + int num_sta_ht_no_gf; + + /* Number of associated non-HT stations */ + /* int num_sta_no_ht; */ + + /* Number of HT associated stations 20 MHz */ + int num_sta_ht_20mhz; + + /* Overlapping BSS information */ + int olbc_ht; + + u16 ht_op_mode; + + u8 *wps_beacon_ie; + /* u8 *wps_probe_req_ie; */ + u8 *wps_probe_resp_ie; + u8 *wps_assoc_resp_ie; + + u32 wps_beacon_ie_len; + u32 wps_probe_resp_ie_len; + u32 wps_assoc_resp_ie_len; + + u8 *p2p_beacon_ie; + u8 *p2p_probe_req_ie; + u8 *p2p_probe_resp_ie; + u8 *p2p_go_probe_resp_ie; /* for GO */ + u8 *p2p_assoc_req_ie; + + u32 p2p_beacon_ie_len; + u32 p2p_probe_req_ie_len; + u32 p2p_probe_resp_ie_len; + u32 p2p_go_probe_resp_ie_len; /* for GO */ + u32 p2p_assoc_req_ie_len; + spinlock_t bcn_update_lock; + u8 update_bcn; +#endif /* if defined (CONFIG_88EU_AP_MODE) */ +}; + +#ifdef CONFIG_88EU_AP_MODE + +struct hostapd_priv { + struct adapter *padapter; +}; + +int hostapd_mode_init(struct adapter *padapter); +void hostapd_mode_unload(struct adapter *padapter); +#endif + +extern unsigned char WPA_TKIP_CIPHER[4]; +extern unsigned char RSN_TKIP_CIPHER[4]; +extern unsigned char REALTEK_96B_IE[]; +extern unsigned char MCS_rate_2R[16]; +extern unsigned char MCS_rate_1R[16]; + +void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf); +void rtw_survey_event_callback(struct adapter *adapter, u8 *pbuf); +void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf); +void rtw_joinbss_event_callback(struct adapter *adapter, u8 *pbuf); +void rtw_stassoc_event_callback(struct adapter *adapter, u8 *pbuf); +void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf); +void rtw_atimdone_event_callback(struct adapter *adapter, u8 *pbuf); +void rtw_cpwm_event_callback(struct adapter *adapter, u8 *pbuf); +void indicate_wx_scan_complete_event(struct adapter *padapter); +void rtw_indicate_wx_assoc_event(struct adapter *padapter); +void rtw_indicate_wx_disassoc_event(struct adapter *padapter); +int event_thread(void *context); +void rtw_join_timeout_handler(void *FunctionContext); +void _rtw_scan_timeout_handler(void *FunctionContext); +void rtw_free_network_queue(struct adapter *adapter, u8 isfreeall); +int rtw_init_mlme_priv(struct adapter *adapter); +void rtw_free_mlme_priv (struct mlme_priv *pmlmepriv); +int rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv); +int rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, + int keyid, u8 set_tx); +int rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv); + +static inline u8 *get_bssid(struct mlme_priv *pmlmepriv) +{ /* if sta_mode:pmlmepriv->cur_network.network.MacAddress=> bssid */ + /* if adhoc_mode:pmlmepriv->cur_network.network.MacAddress=> ibss mac address */ + return pmlmepriv->cur_network.network.MacAddress; +} + +static inline int check_fwstate(struct mlme_priv *pmlmepriv, int state) +{ + if (pmlmepriv->fw_state & state) + return true; + + return false; +} + +static inline int get_fwstate(struct mlme_priv *pmlmepriv) +{ + return pmlmepriv->fw_state; +} + +/* + * No Limit on the calling context, + * therefore set it to be the critical section... + * + * ### NOTE:#### (!!!!) + * MUST TAKE CARE THAT BEFORE CALLING THIS FUNC, YOU SHOULD HAVE LOCKED pmlmepriv->lock + */ +static inline void set_fwstate(struct mlme_priv *pmlmepriv, int state) +{ + pmlmepriv->fw_state |= state; + /* FOR HW integration */ + if (_FW_UNDER_SURVEY==state) + pmlmepriv->bScanInProcess = true; +} + +static inline void _clr_fwstate_(struct mlme_priv *pmlmepriv, int state) +{ + pmlmepriv->fw_state &= ~state; + /* FOR HW integration */ + if (_FW_UNDER_SURVEY==state) + pmlmepriv->bScanInProcess = false; +} + +/* + * No Limit on the calling context, + * therefore set it to be the critical section... + */ +static inline void clr_fwstate(struct mlme_priv *pmlmepriv, int state) +{ + unsigned long irql; + + _enter_critical_bh(&pmlmepriv->lock, &irql); + if (check_fwstate(pmlmepriv, state) == true) + pmlmepriv->fw_state ^= state; + _exit_critical_bh(&pmlmepriv->lock, &irql); +} + +static inline void clr_fwstate_ex(struct mlme_priv *pmlmepriv, int state) +{ + unsigned long irql; + + _enter_critical_bh(&pmlmepriv->lock, &irql); + _clr_fwstate_(pmlmepriv, state); + _exit_critical_bh(&pmlmepriv->lock, &irql); +} + +static inline void up_scanned_network(struct mlme_priv *pmlmepriv) +{ + unsigned long irql; + + _enter_critical_bh(&pmlmepriv->lock, &irql); + pmlmepriv->num_of_scanned++; + _exit_critical_bh(&pmlmepriv->lock, &irql); +} + +static inline void down_scanned_network(struct mlme_priv *pmlmepriv) +{ + unsigned long irql; + + _enter_critical_bh(&pmlmepriv->lock, &irql); + pmlmepriv->num_of_scanned--; + _exit_critical_bh(&pmlmepriv->lock, &irql); +} + +static inline void set_scanned_network_val(struct mlme_priv *pmlmepriv, int val) +{ + unsigned long irql; + + _enter_critical_bh(&pmlmepriv->lock, &irql); + pmlmepriv->num_of_scanned = val; + _exit_critical_bh(&pmlmepriv->lock, &irql); +} + +u16 rtw_get_capability(struct wlan_bssid_ex *bss); +void rtw_update_scanned_network(struct adapter *adapter, + struct wlan_bssid_ex *target); +void rtw_disconnect_hdl_under_linked(struct adapter *adapter, + struct sta_info *psta, u8 free_assoc); +void rtw_generate_random_ibss(u8 *pibss); +struct wlan_network *rtw_find_network(struct __queue *scanned_queue, u8 *addr); +struct wlan_network *rtw_get_oldest_wlan_network(struct __queue *scanned_queue); + +void rtw_free_assoc_resources(struct adapter *adapter, int lock_scanned_queue); +void rtw_indicate_disconnect(struct adapter *adapter); +void rtw_indicate_connect(struct adapter *adapter); +void rtw_indicate_scan_done( struct adapter *padapter, bool aborted); +void rtw_scan_abort(struct adapter *adapter); + +int rtw_restruct_sec_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, + uint in_len); +int rtw_restruct_wmm_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, + uint in_len, uint initial_out_len); +void rtw_init_registrypriv_dev_network(struct adapter *adapter); + +void rtw_update_registrypriv_dev_network(struct adapter *adapter); + +void rtw_get_encrypt_decrypt_from_registrypriv(struct adapter *adapter); + +void _rtw_join_timeout_handler(struct adapter *adapter); +void rtw_scan_timeout_handler(struct adapter *adapter); + + void rtw_dynamic_check_timer_handlder(struct adapter *adapter); +#define rtw_is_scan_deny(adapter) false +#define rtw_clear_scan_deny(adapter) do {} while (0) +#define rtw_set_scan_deny_timer_hdl(adapter) do {} while (0) +#define rtw_set_scan_deny(adapter, ms) do {} while (0) + + +int _rtw_init_mlme_priv(struct adapter *padapter); + +void rtw_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv); + +void _rtw_free_mlme_priv(struct mlme_priv *pmlmepriv); + +int _rtw_enqueue_network(struct __queue *queue, struct wlan_network *pnetwork); + +struct wlan_network *_rtw_dequeue_network(struct __queue *queue); + + struct wlan_network *_rtw_alloc_network(struct mlme_priv *pmlmepriv); + + +void _rtw_free_network(struct mlme_priv *pmlmepriv, + struct wlan_network *pnetwork, u8 isfreeall); +void _rtw_free_network_nolock(struct mlme_priv *pmlmepriv, + struct wlan_network *pnetwork); + + +struct wlan_network* _rtw_find_network(struct __queue *scanned_queue, u8 *addr); + +void _rtw_free_network_queue(struct adapter *padapter, u8 isfreeall); + +int rtw_if_up(struct adapter *padapter); + + +u8 *rtw_get_capability_from_ie(u8 *ie); +u8 *rtw_get_timestampe_from_ie(u8 *ie); +u8 *rtw_get_beacon_interval_from_ie(u8 *ie); + + +void rtw_joinbss_reset(struct adapter *padapter); + +unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, + u8 *out_ie, uint in_len, uint *pout_len); +void rtw_update_ht_cap(struct adapter *padapter, u8 *pie, uint ie_len); +void rtw_issue_addbareq_cmd(struct adapter *padapter, + struct xmit_frame *pxmitframe); + +int rtw_is_same_ibss(struct adapter *adapter, struct wlan_network *pnetwork); +int is_same_network(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst); + +void rtw_roaming(struct adapter *padapter, struct wlan_network *tgt_network); +void _rtw_roaming(struct adapter *padapter, struct wlan_network *tgt_network); + +void rtw_stassoc_hw_rpt(struct adapter *adapter,struct sta_info *psta); + +#endif /* __RTL871X_MLME_H_ */ diff --git a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h new file mode 100644 index 0000000000000..a96b018e5e6a3 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h @@ -0,0 +1,877 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __RTW_MLME_EXT_H_ +#define __RTW_MLME_EXT_H_ + +#include +#include +#include + + +/* Commented by Albert 20101105 */ +/* Increase the SURVEY_TO value from 100 to 150 ( 100ms to 150ms ) */ +/* The Realtek 8188CE SoftAP will spend around 100ms to send the probe response after receiving the probe request. */ +/* So, this driver tried to extend the dwell time for each scanning channel. */ +/* This will increase the chance to receive the probe response from SoftAP. */ + +#define SURVEY_TO (100) +#define REAUTH_TO (300) /* 50) */ +#define REASSOC_TO (300) /* 50) */ +/* define DISCONNECT_TO (3000) */ +#define ADDBA_TO (2000) + +#define LINKED_TO (1) /* unit:2 sec, 1x2=2 sec */ + +#define REAUTH_LIMIT (4) +#define REASSOC_LIMIT (4) +#define READDBA_LIMIT (2) + +#define ROAMING_LIMIT 8 + +#define DYNAMIC_FUNC_DISABLE (0x0) + +/* ====== ODM_ABILITY_E ======== */ +/* BB ODM section BIT 0-15 */ +#define DYNAMIC_BB_DIG BIT(0) +#define DYNAMIC_BB_RA_MASK BIT(1) +#define DYNAMIC_BB_DYNAMIC_TXPWR BIT(2) +#define DYNAMIC_BB_BB_FA_CNT BIT(3) + +#define DYNAMIC_BB_RSSI_MONITOR BIT(4) +#define DYNAMIC_BB_CCK_PD BIT(5) +#define DYNAMIC_BB_ANT_DIV BIT(6) +#define DYNAMIC_BB_PWR_SAVE BIT(7) +#define DYNAMIC_BB_PWR_TRA BIT(8) +#define DYNAMIC_BB_RATE_ADAPTIVE BIT(9) +#define DYNAMIC_BB_PATH_DIV BIT(10) +#define DYNAMIC_BB_PSD BIT(11) + +/* MAC DM section BIT 16-23 */ +#define DYNAMIC_MAC_EDCA_TURBO BIT(16) +#define DYNAMIC_MAC_EARLY_MODE BIT(17) + +/* RF ODM section BIT 24-31 */ +#define DYNAMIC_RF_TX_PWR_TRACK BIT(24) +#define DYNAMIC_RF_RX_GAIN_TRACK BIT(25) +#define DYNAMIC_RF_CALIBRATION BIT(26) + +#define DYNAMIC_ALL_FUNC_ENABLE 0xFFFFFFF + +#define _HW_STATE_NOLINK_ 0x00 +#define _HW_STATE_ADHOC_ 0x01 +#define _HW_STATE_STATION_ 0x02 +#define _HW_STATE_AP_ 0x03 + + +#define _1M_RATE_ 0 +#define _2M_RATE_ 1 +#define _5M_RATE_ 2 +#define _11M_RATE_ 3 +#define _6M_RATE_ 4 +#define _9M_RATE_ 5 +#define _12M_RATE_ 6 +#define _18M_RATE_ 7 +#define _24M_RATE_ 8 +#define _36M_RATE_ 9 +#define _48M_RATE_ 10 +#define _54M_RATE_ 11 + + +extern unsigned char RTW_WPA_OUI[]; +extern unsigned char WMM_OUI[]; +extern unsigned char WPS_OUI[]; +extern unsigned char WFD_OUI[]; +extern unsigned char P2P_OUI[]; + +extern unsigned char WMM_INFO_OUI[]; +extern unsigned char WMM_PARA_OUI[]; + +/* Channel Plan Type. */ +/* Note: */ +/* We just add new channel plan when the new channel plan is different + * from any of the following channel plan. */ +/* If you just wnat to customize the acitions(scan period or join actions) + * about one of the channel plan, */ +/* customize them in struct rt_channel_info in the RT_CHANNEL_LIST. */ +enum RT_CHANNEL_DOMAIN { + /* old channel plan mapping ===== */ + RT_CHANNEL_DOMAIN_FCC = 0x00, + RT_CHANNEL_DOMAIN_IC = 0x01, + RT_CHANNEL_DOMAIN_ETSI = 0x02, + RT_CHANNEL_DOMAIN_SPAIN = 0x03, + RT_CHANNEL_DOMAIN_FRANCE = 0x04, + RT_CHANNEL_DOMAIN_MKK = 0x05, + RT_CHANNEL_DOMAIN_MKK1 = 0x06, + RT_CHANNEL_DOMAIN_ISRAEL = 0x07, + RT_CHANNEL_DOMAIN_TELEC = 0x08, + RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN = 0x09, + RT_CHANNEL_DOMAIN_WORLD_WIDE_13 = 0x0A, + RT_CHANNEL_DOMAIN_TAIWAN = 0x0B, + RT_CHANNEL_DOMAIN_CHINA = 0x0C, + RT_CHANNEL_DOMAIN_SINGAPORE_INDIA_MEXICO = 0x0D, + RT_CHANNEL_DOMAIN_KOREA = 0x0E, + RT_CHANNEL_DOMAIN_TURKEY = 0x0F, + RT_CHANNEL_DOMAIN_JAPAN = 0x10, + RT_CHANNEL_DOMAIN_FCC_NO_DFS = 0x11, + RT_CHANNEL_DOMAIN_JAPAN_NO_DFS = 0x12, + RT_CHANNEL_DOMAIN_WORLD_WIDE_5G = 0x13, + RT_CHANNEL_DOMAIN_TAIWAN_NO_DFS = 0x14, + + /* new channel plan mapping, (2GDOMAIN_5GDOMAIN) ===== */ + RT_CHANNEL_DOMAIN_WORLD_NULL = 0x20, + RT_CHANNEL_DOMAIN_ETSI1_NULL = 0x21, + RT_CHANNEL_DOMAIN_FCC1_NULL = 0x22, + RT_CHANNEL_DOMAIN_MKK1_NULL = 0x23, + RT_CHANNEL_DOMAIN_ETSI2_NULL = 0x24, + RT_CHANNEL_DOMAIN_FCC1_FCC1 = 0x25, + RT_CHANNEL_DOMAIN_WORLD_ETSI1 = 0x26, + RT_CHANNEL_DOMAIN_MKK1_MKK1 = 0x27, + RT_CHANNEL_DOMAIN_WORLD_KCC1 = 0x28, + RT_CHANNEL_DOMAIN_WORLD_FCC2 = 0x29, + RT_CHANNEL_DOMAIN_WORLD_FCC3 = 0x30, + RT_CHANNEL_DOMAIN_WORLD_FCC4 = 0x31, + RT_CHANNEL_DOMAIN_WORLD_FCC5 = 0x32, + RT_CHANNEL_DOMAIN_WORLD_FCC6 = 0x33, + RT_CHANNEL_DOMAIN_FCC1_FCC7 = 0x34, + RT_CHANNEL_DOMAIN_WORLD_ETSI2 = 0x35, + RT_CHANNEL_DOMAIN_WORLD_ETSI3 = 0x36, + RT_CHANNEL_DOMAIN_MKK1_MKK2 = 0x37, + RT_CHANNEL_DOMAIN_MKK1_MKK3 = 0x38, + RT_CHANNEL_DOMAIN_FCC1_NCC1 = 0x39, + RT_CHANNEL_DOMAIN_FCC1_NCC2 = 0x40, + RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN_2G = 0x41, + /* Add new channel plan above this line=============== */ + RT_CHANNEL_DOMAIN_MAX, + RT_CHANNEL_DOMAIN_REALTEK_DEFINE = 0x7F, +}; + +enum RT_CHANNEL_DOMAIN_2G { + RT_CHANNEL_DOMAIN_2G_WORLD = 0x00, /* Worldwide 13 */ + RT_CHANNEL_DOMAIN_2G_ETSI1 = 0x01, /* Europe */ + RT_CHANNEL_DOMAIN_2G_FCC1 = 0x02, /* US */ + RT_CHANNEL_DOMAIN_2G_MKK1 = 0x03, /* Japan */ + RT_CHANNEL_DOMAIN_2G_ETSI2 = 0x04, /* France */ + RT_CHANNEL_DOMAIN_2G_NULL = 0x05, + /* Add new channel plan above this line=============== */ + RT_CHANNEL_DOMAIN_2G_MAX, +}; + +#define rtw_is_channel_plan_valid(chplan) \ + (chplan < RT_CHANNEL_DOMAIN_MAX || \ + chplan == RT_CHANNEL_DOMAIN_REALTEK_DEFINE) + +struct rt_channel_plan { + unsigned char Channel[MAX_CHANNEL_NUM]; + unsigned char Len; +}; + +struct rt_channel_plan_2g { + unsigned char Channel[MAX_CHANNEL_NUM_2G]; + unsigned char Len; +}; + +struct rt_channel_plan_map { + unsigned char Index2G; +}; + +enum Associated_AP { + atherosAP = 0, + broadcomAP = 1, + ciscoAP = 2, + marvellAP = 3, + ralinkAP = 4, + realtekAP = 5, + airgocapAP = 6, + unknownAP = 7, + maxAP, +}; + +enum HT_IOT_PEER { + HT_IOT_PEER_UNKNOWN = 0, + HT_IOT_PEER_REALTEK = 1, + HT_IOT_PEER_REALTEK_92SE = 2, + HT_IOT_PEER_BROADCOM = 3, + HT_IOT_PEER_RALINK = 4, + HT_IOT_PEER_ATHEROS = 5, + HT_IOT_PEER_CISCO = 6, + HT_IOT_PEER_MERU = 7, + HT_IOT_PEER_MARVELL = 8, + HT_IOT_PEER_REALTEK_SOFTAP = 9,/* peer is RealTek SOFT_AP */ + HT_IOT_PEER_SELF_SOFTAP = 10, /* Self is SoftAP */ + HT_IOT_PEER_AIRGO = 11, + HT_IOT_PEER_INTEL = 12, + HT_IOT_PEER_RTK_APCLIENT = 13, + HT_IOT_PEER_REALTEK_81XX = 14, + HT_IOT_PEER_REALTEK_WOW = 15, + HT_IOT_PEER_TENDA = 16, + HT_IOT_PEER_MAX = 17 +}; + +enum SCAN_STATE { + SCAN_DISABLE = 0, + SCAN_START = 1, + SCAN_TXNULL = 2, + SCAN_PROCESS = 3, + SCAN_COMPLETE = 4, + SCAN_STATE_MAX, +}; + +struct mlme_handler { + unsigned int num; + char *str; + unsigned int (*func)(struct adapter *adapt, union recv_frame *frame); +}; + +struct action_handler { + unsigned int num; + char* str; + unsigned int (*func)(struct adapter *adapt, union recv_frame *frame); +}; + +struct ss_res { + int state; + int bss_cnt; + int channel_idx; + int scan_mode; + u8 ssid_num; + u8 ch_num; + struct ndis_802_11_ssid ssid[RTW_SSID_SCAN_AMOUNT]; + struct rtw_ieee80211_channel ch[RTW_CHANNEL_SCAN_AMOUNT]; +}; + +/* define AP_MODE 0x0C */ +/* define STATION_MODE 0x08 */ +/* define AD_HOC_MODE 0x04 */ +/* define NO_LINK_MODE 0x00 */ + +#define WIFI_FW_NULL_STATE _HW_STATE_NOLINK_ +#define WIFI_FW_STATION_STATE _HW_STATE_STATION_ +#define WIFI_FW_AP_STATE _HW_STATE_AP_ +#define WIFI_FW_ADHOC_STATE _HW_STATE_ADHOC_ + +#define WIFI_FW_AUTH_NULL 0x00000100 +#define WIFI_FW_AUTH_STATE 0x00000200 +#define WIFI_FW_AUTH_SUCCESS 0x00000400 + +#define WIFI_FW_ASSOC_STATE 0x00002000 +#define WIFI_FW_ASSOC_SUCCESS 0x00004000 + +#define WIFI_FW_LINKING_STATE (WIFI_FW_AUTH_NULL | \ + WIFI_FW_AUTH_STATE | \ + WIFI_FW_AUTH_SUCCESS | \ + WIFI_FW_ASSOC_STATE) + +struct FW_Sta_Info { + struct sta_info *psta; + u32 status; + u32 rx_pkt; + u32 retry; + unsigned char SupportedRates[NDIS_802_11_LENGTH_RATES_EX]; +}; + +/* + * Usage: + * When one iface acted as AP mode and the other iface is STA mode and scanning, + * it should switch back to AP's operating channel periodically. + * Parameters info: + * When the driver scanned RTW_SCAN_NUM_OF_CH channels, it would switch back to + * AP's operating channel for + * RTW_STAY_AP_CH_MILLISECOND * SURVEY_TO milliseconds. + * Example: + * For chip supports 2.4G + 5GHz and AP mode is operating in channel 1, + * RTW_SCAN_NUM_OF_CH is 8, RTW_STAY_AP_CH_MS is 3 and SURVEY_TO is 100. + * When it's STA mode gets set_scan command, + * it would + * 1. Doing the scan on channel 1.2.3.4.5.6.7.8 + * 2. Back to channel 1 for 300 milliseconds + * 3. Go through doing site survey on channel 9.10.11.36.40.44.48.52 + * 4. Back to channel 1 for 300 milliseconds + * 5. ... and so on, till survey done. + */ + +struct mlme_ext_info { + u32 state; + u32 reauth_count; + u32 reassoc_count; + u32 link_count; + u32 auth_seq; + u32 auth_algo; /* 802.11 auth, could be open, shared, auto */ + u32 authModeToggle; + u32 enc_algo;/* encrypt algorithm; */ + u32 key_index; /* this is only valid for legacy wep, + * 0~3 for key id. */ + u32 iv; + u8 chg_txt[128]; + u16 aid; + u16 bcn_interval; + u16 capability; + u8 assoc_AP_vendor; + u8 slotTime; + u8 preamble_mode; + u8 WMM_enable; + u8 ERP_enable; + u8 ERP_IE; + u8 HT_enable; + u8 HT_caps_enable; + u8 HT_info_enable; + u8 HT_protection; + u8 turboMode_cts2self; + u8 turboMode_rtsen; + u8 SM_PS; + u8 agg_enable_bitmap; + u8 ADDBA_retry_count; + u8 candidate_tid_bitmap; + u8 dialogToken; + /* Accept ADDBA Request */ + bool bAcceptAddbaReq; + u8 bwmode_updated; + u8 hidden_ssid_mode; + + struct ADDBA_request ADDBA_req; + struct WMM_para_element WMM_param; + struct HT_caps_element HT_caps; + struct HT_info_element HT_info; + struct wlan_bssid_ex network;/* join network or bss_network, + * if in ap mode, it is the same + * as cur_network.network */ + struct FW_Sta_Info FW_sta_info[NUM_STA]; +}; + +/* The channel information about this channel including joining, + * scanning, and power constraints. */ +struct rt_channel_info { + u8 ChannelNum; /* The channel number. */ + enum rt_scan_type ScanType; /* Scan type such as passive + * or active scan. */ + u32 rx_count; +}; + +int rtw_ch_set_search_ch(struct rt_channel_info *ch_set, const u32 ch); + +/* P2P_MAX_REG_CLASSES - Maximum number of regulatory classes */ +#define P2P_MAX_REG_CLASSES 10 + +/* P2P_MAX_REG_CLASS_CHANNELS - Maximum number of chan per regulatory class */ +#define P2P_MAX_REG_CLASS_CHANNELS 20 + +/* struct p2p_channels - List of supported channels */ +struct p2p_channels { + /* struct p2p_reg_class - Supported regulatory class */ + struct p2p_reg_class { + /* reg_class - Regulatory class (IEEE 802.11-2007, Annex J) */ + u8 reg_class; + + /* channel - Supported channels */ + u8 channel[P2P_MAX_REG_CLASS_CHANNELS]; + + /* channels - Number of channel entries in use */ + size_t channels; + } reg_class[P2P_MAX_REG_CLASSES]; + + /* reg_classes - Number of reg_class entries in use */ + size_t reg_classes; +}; + +struct p2p_oper_class_map { + enum hw_mode {IEEE80211G} mode; + u8 op_class; + u8 min_chan; + u8 max_chan; + u8 inc; + enum {BW20, BW40PLUS, BW40MINUS} bw; +}; + +struct mlme_ext_priv { + struct adapter *padapter; + u8 mlmeext_init; + ATOMIC_T event_seq; + u16 mgnt_seq; + + unsigned char cur_channel; + unsigned char cur_bwmode; + unsigned char cur_ch_offset;/* PRIME_CHNL_OFFSET */ + unsigned char cur_wireless_mode; /* NETWORK_TYPE */ + + unsigned char oper_channel; /* saved chan info when call + * set_channel_bw */ + unsigned char oper_bwmode; + unsigned char oper_ch_offset;/* PRIME_CHNL_OFFSET */ + + unsigned char max_chan_nums; + struct rt_channel_info channel_set[MAX_CHANNEL_NUM]; + struct p2p_channels channel_list; + unsigned char basicrate[NumRates]; + unsigned char datarate[NumRates]; + + struct ss_res sitesurvey_res; + struct mlme_ext_info mlmext_info;/* for sta/adhoc mode, including + * current scan/connecting/connected + * related info. For ap mode, + * network includes ap's cap_info*/ + struct timer_list survey_timer; + struct timer_list link_timer; + u16 chan_scan_time; + + u8 scan_abort; + u8 tx_rate; /* TXRATE when USERATE is set. */ + + u32 retry; /* retry for issue probereq */ + + u64 TSFValue; + +#ifdef CONFIG_88EU_AP_MODE + unsigned char bstart_bss; +#endif + u8 update_channel_plan_by_ap_done; + /* recv_decache check for Action_public frame */ + u8 action_public_dialog_token; + u16 action_public_rxseq; + u8 active_keep_alive_check; +}; + +int init_mlme_ext_priv(struct adapter *adapter); +int init_hw_mlme_ext(struct adapter *padapter); +void free_mlme_ext_priv (struct mlme_ext_priv *pmlmeext); +extern void init_mlme_ext_timer(struct adapter *padapter); +extern void init_addba_retry_timer(struct adapter *adapt, struct sta_info *sta); +extern struct xmit_frame *alloc_mgtxmitframe(struct xmit_priv *pxmitpriv); + +unsigned char networktype_to_raid(unsigned char network_type); +u8 judge_network_type(struct adapter *padapter, unsigned char *rate, int len); +void get_rate_set(struct adapter *padapter, unsigned char *pbssrate, int *len); +void UpdateBrateTbl(struct adapter *padapter, u8 *mBratesOS); +void UpdateBrateTblForSoftAP(u8 *bssrateset, u32 bssratelen); + +void Save_DM_Func_Flag(struct adapter *padapter); +void Restore_DM_Func_Flag(struct adapter *padapter); +void Switch_DM_Func(struct adapter *padapter, u32 mode, u8 enable); + +void Set_MSR(struct adapter *padapter, u8 type); + +u8 rtw_get_oper_ch(struct adapter *adapter); +void rtw_set_oper_ch(struct adapter *adapter, u8 ch); +u8 rtw_get_oper_bw(struct adapter *adapter); +void rtw_set_oper_bw(struct adapter *adapter, u8 bw); +u8 rtw_get_oper_choffset(struct adapter *adapter); +void rtw_set_oper_choffset(struct adapter *adapter, u8 offset); + +void set_channel_bwmode(struct adapter *padapter, unsigned char channel, + unsigned char channel_offset, unsigned short bwmode); +void SelectChannel(struct adapter *padapter, unsigned char channel); +void SetBWMode(struct adapter *padapter, unsigned short bwmode, + unsigned char channel_offset); + +unsigned int decide_wait_for_beacon_timeout(unsigned int bcn_interval); + +void write_cam(struct adapter *padapter, u8 entry, u16 ctrl, u8 *mac, u8 *key); +void clear_cam_entry(struct adapter *padapter, u8 entry); + +void invalidate_cam_all(struct adapter *padapter); +void CAM_empty_entry(struct adapter * Adapter, u8 ucIndex); + +int allocate_fw_sta_entry(struct adapter *padapter); +void flush_all_cam_entry(struct adapter *padapter); + +void site_survey(struct adapter *padapter); +u8 collect_bss_info(struct adapter *padapter, union recv_frame *precv_frame, + struct wlan_bssid_ex *bssid); +void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, + struct adapter *adapter, bool update_ie); + +int get_bsstype(unsigned short capability); +u8 *get_my_bssid(struct wlan_bssid_ex *pnetwork); +u16 get_beacon_interval(struct wlan_bssid_ex *bss); + +int is_client_associated_to_ap(struct adapter *padapter); +int is_client_associated_to_ibss(struct adapter *padapter); +int is_IBSS_empty(struct adapter *padapter); + +unsigned char check_assoc_AP(u8 *pframe, uint len); + +int WMM_param_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE); +void WMMOnAssocRsp(struct adapter *padapter); + +void HT_caps_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE); +void HT_info_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE); +void HTOnAssocRsp(struct adapter *padapter); + +void ERP_IE_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE); +void VCS_update(struct adapter *padapter, struct sta_info *psta); + +void update_beacon_info(struct adapter *padapter, u8 *pframe, uint len, + struct sta_info *psta); +int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len); +void update_IOT_info(struct adapter *padapter); +void update_capinfo(struct adapter *adapter, u16 updatecap); +void update_wireless_mode(struct adapter *padapter); +void update_tx_basic_rate(struct adapter *padapter, u8 modulation); +void update_bmc_sta_support_rate(struct adapter *padapter, u32 mac_id); +int update_sta_support_rate(struct adapter *padapter, u8 *pvar_ie, + uint var_ie_len, int cam_idx); + +/* for sta/adhoc mode */ +void update_sta_info(struct adapter *padapter, struct sta_info *psta); +unsigned int update_basic_rate(unsigned char *ptn, unsigned int ptn_sz); +unsigned int update_supported_rate(unsigned char *ptn, unsigned int ptn_sz); +unsigned int update_MSC_rate(struct HT_caps_element *pHT_caps); +void Update_RA_Entry(struct adapter *padapter, u32 mac_id); +void set_sta_rate(struct adapter *padapter, struct sta_info *psta); + +unsigned int receive_disconnect(struct adapter *padapter, + unsigned char *macaddr, unsigned short reason); + +unsigned char get_highest_rate_idx(u32 mask); +int support_short_GI(struct adapter *padapter, struct HT_caps_element *caps); +unsigned int is_ap_in_tkip(struct adapter *padapter); +unsigned int is_ap_in_wep(struct adapter *padapter); +unsigned int should_forbid_n_rate(struct adapter *padapter); + +void report_join_res(struct adapter *padapter, int res); +void report_survey_event(struct adapter *padapter, union recv_frame *precv_frame); +void report_surveydone_event(struct adapter *padapter); +void report_del_sta_event(struct adapter *padapter, + unsigned char *addr, unsigned short reason); +void report_add_sta_event(struct adapter *padapter, unsigned char* addr, + int cam_idx); + +void beacon_timing_control(struct adapter *padapter); +extern u8 set_tx_beacon_cmd(struct adapter*padapter); +unsigned int setup_beacon_frame(struct adapter *padapter, + unsigned char *beacon_frame); +void update_mgnt_tx_rate(struct adapter *padapter, u8 rate); +void update_mgntframe_attrib(struct adapter *padapter, + struct pkt_attrib *pattrib); +void dump_mgntframe(struct adapter *padapter, struct xmit_frame *pmgntframe); +s32 dump_mgntframe_and_wait(struct adapter *padapter, + struct xmit_frame *pmgntframe, int timeout_ms); +s32 dump_mgntframe_and_wait_ack(struct adapter *padapter, + struct xmit_frame *pmgntframe); + +#ifdef CONFIG_88EU_P2P +void issue_probersp_p2p(struct adapter *padapter, unsigned char *da); +void issue_p2p_provision_request(struct adapter *padapter, u8 *pssid, + u8 ussidlen, u8 *pdev_raddr); +void issue_p2p_GO_request(struct adapter *padapter, u8 *raddr); +void issue_probereq_p2p(struct adapter *padapter, u8 *da); +int issue_probereq_p2p_ex(struct adapter *adapter, u8 *da, int try_cnt, + int wait_ms); +void issue_p2p_invitation_response(struct adapter *padapter, u8 *raddr, + u8 dialogToken, u8 success); +void issue_p2p_invitation_request(struct adapter *padapter, u8* raddr); +#endif /* CONFIG_88EU_P2P */ +void issue_beacon(struct adapter *padapter, int timeout_ms); +void issue_probersp(struct adapter *padapter, unsigned char *da, + u8 is_valid_p2p_probereq); +void issue_assocreq(struct adapter *padapter); +void issue_asocrsp(struct adapter *padapter, unsigned short status, + struct sta_info *pstat, int pkt_type); +void issue_auth(struct adapter *padapter, struct sta_info *psta, + unsigned short status); +void issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *pssid, + u8 *da); +s32 issue_probereq_ex(struct adapter *adapter, struct ndis_802_11_ssid *pssid, + u8* da, int try_cnt, int wait_ms); +int issue_nulldata(struct adapter *padapter, unsigned char *da, + unsigned int power_mode, int try_cnt, int wait_ms); +int issue_qos_nulldata(struct adapter *padapter, unsigned char *da, + u16 tid, int try_cnt, int wait_ms); +int issue_deauth(struct adapter *padapter, unsigned char *da, + unsigned short reason); +int issue_deauth_ex(struct adapter *padapter, u8 *da, unsigned short reason, + int try_cnt, int wait_ms); +void issue_action_spct_ch_switch(struct adapter *padapter, u8 *ra, u8 new_ch, + u8 ch_offset); +void issue_action_BA(struct adapter *padapter, unsigned char *raddr, + unsigned char action, unsigned short status); +unsigned int send_delba(struct adapter *padapter, u8 initiator, u8 *addr); +unsigned int send_beacon(struct adapter *padapter); + +void start_clnt_assoc(struct adapter *padapter); +void start_clnt_auth(struct adapter *padapter); +void start_clnt_join(struct adapter *padapter); +void start_create_ibss(struct adapter *padapter); + +unsigned int OnAssocReq(struct adapter *padapter, + union recv_frame *precv_frame); +unsigned int OnAssocRsp(struct adapter *padapter, + union recv_frame *precv_frame); +unsigned int OnProbeReq(struct adapter *padapter, + union recv_frame *precv_frame); +unsigned int OnProbeRsp(struct adapter *padapter, + union recv_frame *precv_frame); +unsigned int DoReserved(struct adapter *padapter, + union recv_frame *precv_frame); +unsigned int OnBeacon(struct adapter *padapter, + union recv_frame *precv_frame); +unsigned int OnAtim(struct adapter *padapter, + union recv_frame *precv_frame); +unsigned int OnDisassoc(struct adapter *padapter, + union recv_frame *precv_frame); +unsigned int OnAuth(struct adapter *padapter, + union recv_frame *precv_frame); +unsigned int OnAuthClient(struct adapter *padapter, + union recv_frame *precv_frame); +unsigned int OnDeAuth(struct adapter *padapter, + union recv_frame *precv_frame); +unsigned int OnAction(struct adapter *padapter, + union recv_frame *precv_frame); + +unsigned int on_action_spct(struct adapter *padapter, + union recv_frame *precv_frame); +unsigned int OnAction_qos(struct adapter *padapter, + union recv_frame *precv_frame); +unsigned int OnAction_dls(struct adapter *padapter, + union recv_frame *precv_frame); +unsigned int OnAction_back(struct adapter *padapter, + union recv_frame *precv_frame); +unsigned int on_action_public(struct adapter *padapter, + union recv_frame *precv_frame); +unsigned int OnAction_ht(struct adapter *padapter, + union recv_frame *precv_frame); +unsigned int OnAction_wmm(struct adapter *padapter, + union recv_frame *precv_frame); +unsigned int OnAction_p2p(struct adapter *padapter, + union recv_frame *precv_frame); + +void mlmeext_joinbss_event_callback(struct adapter *padapter, int join_res); +void mlmeext_sta_del_event_callback(struct adapter *padapter); +void mlmeext_sta_add_event_callback(struct adapter *padapter, + struct sta_info *psta); + +void linked_status_chk(struct adapter *padapter); + +void survey_timer_hdl (struct adapter *padapter); +void link_timer_hdl (struct adapter *padapter); +void addba_timer_hdl(struct sta_info *psta); + +#define set_survey_timer(mlmeext, ms) \ + do { \ + _set_timer(&(mlmeext)->survey_timer, (ms)); \ + } while (0) + +#define set_link_timer(mlmeext, ms) \ + do { \ + _set_timer(&(mlmeext)->link_timer, (ms)); \ + } while (0) + +int cckrates_included(unsigned char *rate, int ratelen); +int cckratesonly_included(unsigned char *rate, int ratelen); + +void process_addba_req(struct adapter *padapter, u8 *paddba_req, u8 *addr); + +void update_TSF(struct mlme_ext_priv *pmlmeext, u8 *pframe, uint len); +void correct_TSF(struct adapter *padapter, struct mlme_ext_priv *pmlmeext); + +struct cmd_hdl { + uint parmsize; + u8 (*h2cfuns)(struct adapter *padapter, u8 *pbuf); +}; + +u8 read_macreg_hdl(struct adapter *padapter, u8 *pbuf); +u8 write_macreg_hdl(struct adapter *padapter, u8 *pbuf); +u8 read_bbreg_hdl(struct adapter *padapter, u8 *pbuf); +u8 write_bbreg_hdl(struct adapter *padapter, u8 *pbuf); +u8 read_rfreg_hdl(struct adapter *padapter, u8 *pbuf); +u8 write_rfreg_hdl(struct adapter *padapter, u8 *pbuf); +u8 NULL_hdl(struct adapter *padapter, u8 *pbuf); +u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf); +u8 disconnect_hdl(struct adapter *padapter, u8 *pbuf); +u8 createbss_hdl(struct adapter *padapter, u8 *pbuf); +u8 setopmode_hdl(struct adapter *padapter, u8 *pbuf); +u8 sitesurvey_cmd_hdl(struct adapter *padapter, u8 *pbuf); +u8 setauth_hdl(struct adapter *padapter, u8 *pbuf); +u8 setkey_hdl(struct adapter *padapter, u8 *pbuf); +u8 set_stakey_hdl(struct adapter *padapter, u8 *pbuf); +u8 set_assocsta_hdl(struct adapter *padapter, u8 *pbuf); +u8 del_assocsta_hdl(struct adapter *padapter, u8 *pbuf); +u8 add_ba_hdl(struct adapter *padapter, unsigned char *pbuf); + +u8 mlme_evt_hdl(struct adapter *padapter, unsigned char *pbuf); +u8 h2c_msg_hdl(struct adapter *padapter, unsigned char *pbuf); +u8 tx_beacon_hdl(struct adapter *padapter, unsigned char *pbuf); +u8 set_ch_hdl(struct adapter *padapter, u8 *pbuf); +u8 set_chplan_hdl(struct adapter *padapter, unsigned char *pbuf); +u8 led_blink_hdl(struct adapter *padapter, unsigned char *pbuf); +/* Handling DFS channel switch announcement ie. */ +u8 set_csa_hdl(struct adapter *padapter, unsigned char *pbuf); +u8 tdls_hdl(struct adapter *padapter, unsigned char *pbuf); + +#define GEN_DRV_CMD_HANDLER(size, cmd) {size, &cmd ## _hdl}, +#define GEN_MLME_EXT_HANDLER(size, cmd) {size, cmd}, + +#ifdef _RTW_CMD_C_ + +static struct cmd_hdl wlancmds[] = { + GEN_DRV_CMD_HANDLER(0, NULL) /*0*/ + GEN_DRV_CMD_HANDLER(0, NULL) + GEN_DRV_CMD_HANDLER(0, NULL) + GEN_DRV_CMD_HANDLER(0, NULL) + GEN_DRV_CMD_HANDLER(0, NULL) + GEN_DRV_CMD_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) /*10*/ + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(sizeof (struct joinbss_parm), join_cmd_hdl) /*14*/ + GEN_MLME_EXT_HANDLER(sizeof (struct disconnect_parm), disconnect_hdl) + GEN_MLME_EXT_HANDLER(sizeof (struct createbss_parm), createbss_hdl) + GEN_MLME_EXT_HANDLER(sizeof (struct setopmode_parm), setopmode_hdl) + GEN_MLME_EXT_HANDLER(sizeof (struct sitesurvey_parm), + sitesurvey_cmd_hdl) /*18*/ + GEN_MLME_EXT_HANDLER(sizeof (struct setauth_parm), setauth_hdl) + GEN_MLME_EXT_HANDLER(sizeof (struct setkey_parm), setkey_hdl) /*20*/ + GEN_MLME_EXT_HANDLER(sizeof (struct set_stakey_parm), set_stakey_hdl) + GEN_MLME_EXT_HANDLER(sizeof (struct set_assocsta_parm), NULL) + GEN_MLME_EXT_HANDLER(sizeof (struct del_assocsta_parm), NULL) + GEN_MLME_EXT_HANDLER(sizeof (struct setstapwrstate_parm), NULL) + GEN_MLME_EXT_HANDLER(sizeof (struct setbasicrate_parm), NULL) + GEN_MLME_EXT_HANDLER(sizeof (struct getbasicrate_parm), NULL) + GEN_MLME_EXT_HANDLER(sizeof (struct setdatarate_parm), NULL) + GEN_MLME_EXT_HANDLER(sizeof (struct getdatarate_parm), NULL) + GEN_MLME_EXT_HANDLER(sizeof (struct setphyinfo_parm), NULL) + GEN_MLME_EXT_HANDLER(sizeof (struct getphyinfo_parm), NULL) /*30*/ + GEN_MLME_EXT_HANDLER(sizeof (struct setphy_parm), NULL) + GEN_MLME_EXT_HANDLER(sizeof (struct getphy_parm), NULL) + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) /*40*/ + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(sizeof(struct addBaReq_parm), add_ba_hdl) + GEN_MLME_EXT_HANDLER(sizeof(struct set_ch_parm), set_ch_hdl) /* 46 */ + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) /*50*/ + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(sizeof(struct Tx_Beacon_param), + tx_beacon_hdl) /*55*/ + + GEN_MLME_EXT_HANDLER(0, mlme_evt_hdl) /*56*/ + GEN_MLME_EXT_HANDLER(0, rtw_drvextra_cmd_hdl) /*57*/ + + GEN_MLME_EXT_HANDLER(0, h2c_msg_hdl) /*58*/ + GEN_MLME_EXT_HANDLER(sizeof(struct SetChannelPlan_param), + set_chplan_hdl) /*59*/ + GEN_MLME_EXT_HANDLER(sizeof(struct LedBlink_param), + led_blink_hdl) /*60*/ + + GEN_MLME_EXT_HANDLER(sizeof(struct SetChannelSwitch_param), + set_csa_hdl) /*61*/ + GEN_MLME_EXT_HANDLER(sizeof(struct TDLSoption_param), + tdls_hdl) /*62*/ +}; + +#endif + +struct C2HEvent_Header { +#ifdef __LITTLE_ENDIAN + unsigned int len:16; + unsigned int ID:8; + unsigned int seq:8; +#elif defined(__BIG_ENDIAN) + unsigned int seq:8; + unsigned int ID:8; + unsigned int len:16; +#endif + unsigned int rsvd; +}; + +void rtw_dummy_event_callback(struct adapter *adapter, u8 *pbuf); +void rtw_fwdbg_event_callback(struct adapter *adapter, u8 *pbuf); + +enum rtw_c2h_event { + GEN_EVT_CODE(_Read_MACREG) = 0, /*0*/ + GEN_EVT_CODE(_Read_BBREG), + GEN_EVT_CODE(_Read_RFREG), + GEN_EVT_CODE(_Read_EEPROM), + GEN_EVT_CODE(_Read_EFUSE), + GEN_EVT_CODE(_Read_CAM), /*5*/ + GEN_EVT_CODE(_Get_BasicRate), + GEN_EVT_CODE(_Get_DataRate), + GEN_EVT_CODE(_Survey), /*8*/ + GEN_EVT_CODE(_SurveyDone), /*9*/ + + GEN_EVT_CODE(_JoinBss) , /*10*/ + GEN_EVT_CODE(_AddSTA), + GEN_EVT_CODE(_DelSTA), + GEN_EVT_CODE(_AtimDone), + GEN_EVT_CODE(_TX_Report), + GEN_EVT_CODE(_CCX_Report), /*15*/ + GEN_EVT_CODE(_DTM_Report), + GEN_EVT_CODE(_TX_Rate_Statistics), + GEN_EVT_CODE(_C2HLBK), + GEN_EVT_CODE(_FWDBG), + GEN_EVT_CODE(_C2HFEEDBACK), /*20*/ + GEN_EVT_CODE(_ADDBA), + GEN_EVT_CODE(_C2HBCN), + GEN_EVT_CODE(_ReportPwrState), /* filen: only for PCIE, USB */ + GEN_EVT_CODE(_CloseRF), /* filen: only for PCIE, + * work around ASPM */ + MAX_C2HEVT +}; + + +#ifdef _RTW_MLME_EXT_C_ + +static struct fwevent wlanevents[] = { + {0, rtw_dummy_event_callback}, /*0*/ + {0, NULL}, + {0, NULL}, + {0, NULL}, + {0, NULL}, + {0, NULL}, + {0, NULL}, + {0, NULL}, + {0, &rtw_survey_event_callback}, /*8*/ + {sizeof (struct surveydone_event), &rtw_surveydone_event_callback},/*9*/ + {0, &rtw_joinbss_event_callback}, /*10*/ + {sizeof(struct stassoc_event), &rtw_stassoc_event_callback}, + {sizeof(struct stadel_event), &rtw_stadel_event_callback}, + {0, &rtw_atimdone_event_callback}, + {0, rtw_dummy_event_callback}, + {0, NULL}, /*15*/ + {0, NULL}, + {0, NULL}, + {0, NULL}, + {0, rtw_fwdbg_event_callback}, + {0, NULL}, /*20*/ + {0, NULL}, + {0, NULL}, + {0, &rtw_cpwm_event_callback}, +}; + +#endif/* _RTL_MLME_EXT_C_ */ + +#endif /* __RTW_MLME_EXT_H_ */ diff --git a/drivers/staging/rtl8188eu/include/rtw_mp.h b/drivers/staging/rtl8188eu/include/rtw_mp.h new file mode 100644 index 0000000000000..59bdbb5f396b9 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/rtw_mp.h @@ -0,0 +1,495 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef _RTW_MP_H_ +#define _RTW_MP_H_ + +/* 00 - Success */ +/* 11 - Error */ +#define STATUS_SUCCESS (0x00000000L) +#define STATUS_PENDING (0x00000103L) + +#define STATUS_UNSUCCESSFUL (0xC0000001L) +#define STATUS_INSUFFICIENT_RESOURCES (0xC000009AL) +#define STATUS_NOT_SUPPORTED (0xC00000BBL) + +#define NDIS_STATUS_SUCCESS ((int)STATUS_SUCCESS) +#define NDIS_STATUS_PENDING ((int)STATUS_PENDING) +#define NDIS_STATUS_NOT_RECOGNIZED ((int)0x00010001L) +#define NDIS_STATUS_NOT_COPIED ((int)0x00010002L) +#define NDIS_STATUS_NOT_ACCEPTED ((int)0x00010003L) +#define NDIS_STATUS_CALL_ACTIVE ((int)0x00010007L) + +#define NDIS_STATUS_FAILURE ((int)STATUS_UNSUCCESSFUL) +#define NDIS_STATUS_RESOURCES ((int)STATUS_INSUFFICIENT_RESOURCES) +#define NDIS_STATUS_CLOSING ((int)0xC0010002L) +#define NDIS_STATUS_BAD_VERSION ((int)0xC0010004L) +#define NDIS_STATUS_BAD_CHARACTERISTICS ((int)0xC0010005L) +#define NDIS_STATUS_ADAPTER_NOT_FOUND ((int)0xC0010006L) +#define NDIS_STATUS_OPEN_FAILED ((int)0xC0010007L) +#define NDIS_STATUS_DEVICE_FAILED ((int)0xC0010008L) +#define NDIS_STATUS_MULTICAST_FULL ((int)0xC0010009L) +#define NDIS_STATUS_MULTICAST_EXISTS ((int)0xC001000AL) +#define NDIS_STATUS_MULTICAST_NOT_FOUND ((int)0xC001000BL) +#define NDIS_STATUS_REQUEST_ABORTED ((int)0xC001000CL) +#define NDIS_STATUS_RESET_IN_PROGRESS ((int)0xC001000DL) +#define NDIS_STATUS_CLOSING_INDICATING ((int)0xC001000EL) +#define NDIS_STATUS_NOT_SUPPORTED ((int)STATUS_NOT_SUPPORTED) +#define NDIS_STATUS_INVALID_PACKET ((int)0xC001000FL) +#define NDIS_STATUS_OPEN_LIST_FULL ((int)0xC0010010L) +#define NDIS_STATUS_ADAPTER_NOT_READY ((int)0xC0010011L) +#define NDIS_STATUS_ADAPTER_NOT_OPEN ((int)0xC0010012L) +#define NDIS_STATUS_NOT_INDICATING ((int)0xC0010013L) +#define NDIS_STATUS_INVALID_LENGTH ((int)0xC0010014L) +#define NDIS_STATUS_INVALID_DATA ((int)0xC0010015L) +#define NDIS_STATUS_BUFFER_TOO_SHORT ((int)0xC0010016L) +#define NDIS_STATUS_INVALID_OID ((int)0xC0010017L) +#define NDIS_STATUS_ADAPTER_REMOVED ((int)0xC0010018L) +#define NDIS_STATUS_UNSUPPORTED_MEDIA ((int)0xC0010019L) +#define NDIS_STATUS_GROUP_ADDRESS_IN_USE ((int)0xC001001AL) +#define NDIS_STATUS_FILE_NOT_FOUND ((int)0xC001001BL) +#define NDIS_STATUS_ERROR_READING_FILE ((int)0xC001001CL) +#define NDIS_STATUS_ALREADY_MAPPED ((int)0xC001001DL) +#define NDIS_STATUS_RESOURCE_CONFLICT ((int)0xC001001EL) +#define NDIS_STATUS_NO_CABLE ((int)0xC001001FL) + +#define NDIS_STATUS_INVALID_SAP ((int)0xC0010020L) +#define NDIS_STATUS_SAP_IN_USE ((int)0xC0010021L) +#define NDIS_STATUS_INVALID_ADDRESS ((int)0xC0010022L) +#define NDIS_STATUS_VC_NOT_ACTIVATED ((int)0xC0010023L) +#define NDIS_STATUS_DEST_OUT_OF_ORDER ((int)0xC0010024L) /*cause 27*/ +#define NDIS_STATUS_VC_NOT_AVAILABLE ((int)0xC0010025L) /*cause 35,45 */ +#define NDIS_STATUS_CELLRATE_NOT_AVAILABLE ((int)0xC0010026L) /*cause 37*/ +#define NDIS_STATUS_INCOMPATABLE_QOS ((int)0xC0010027L) /*cause 49*/ +#define NDIS_STATUS_AAL_PARAMS_UNSUPPORTED ((int)0xC0010028L) /*cause 93*/ +#define NDIS_STATUS_NO_ROUTE_TO_DESTINATION ((int)0xC0010029L) /*cause 3 */ + +enum antenna_path { + ANTENNA_NONE = 0x00, + ANTENNA_D, + ANTENNA_C, + ANTENNA_CD, + ANTENNA_B, + ANTENNA_BD, + ANTENNA_BC, + ANTENNA_BCD, + ANTENNA_A, + ANTENNA_AD, + ANTENNA_AC, + ANTENNA_ACD, + ANTENNA_AB, + ANTENNA_ABD, + ANTENNA_ABC, + ANTENNA_ABCD +}; + + +#define MAX_MP_XMITBUF_SZ 2048 +#define NR_MP_XMITFRAME 8 + +struct mp_xmit_frame { + struct list_head list; + struct pkt_attrib attrib; + struct sk_buff *pkt; + int frame_tag; + struct adapter *padapter; + struct urb *pxmit_urb[8]; + /* insert urb, irp, and irpcnt info below... */ + u8 *mem_addr; + u32 sz[8]; + u8 bpending[8]; + int ac_tag[8]; + int last[8]; + uint irpcnt; + uint fragcnt; + uint mem[(MAX_MP_XMITBUF_SZ >> 2)]; +}; + +struct mp_wiparam { + u32 bcompleted; + u32 act_type; + u32 io_offset; + u32 io_value; +}; + +typedef void(*wi_act_func)(void *padapter); + +struct mp_tx { + u8 stop; + u32 count, sended; + u8 payload; + struct pkt_attrib attrib; + struct tx_desc desc; + u8 *pallocated_buf; + u8 *buf; + u32 buf_size, write_size; + void *PktTxThread; +}; + +#include + +#define MP_MAX_LINES 1000 +#define MP_MAX_LINES_BYTES 256 + +typedef void (*MPT_WORK_ITEM_HANDLER)(void *Adapter); + +struct mpt_context { + /* Indicate if we have started Mass Production Test. */ + bool bMassProdTest; + + /* Indicate if the driver is unloading or unloaded. */ + bool bMptDrvUnload; + + struct semaphore MPh2c_Sema; + struct timer_list MPh2c_timeout_timer; +/* Event used to sync H2c for BT control */ + + bool MptH2cRspEvent; + bool MptBtC2hEvent; + bool bMPh2c_timeout; + + /* 8190 PCI does not support NDIS_WORK_ITEM. */ + /* Work Item for Mass Production Test. */ + /* Event used to sync the case unloading driver and MptWorkItem + * is still in progress. */ + /* Indicate a MptWorkItem is scheduled and not yet finished. */ + bool bMptWorkItemInProgress; + /* An instance which implements function and context of MptWorkItem. */ + MPT_WORK_ITEM_HANDLER CurrMptAct; + + /* 1=Start, 0=Stop from UI. */ + u32 MptTestStart; + /* _TEST_MODE, defined in MPT_Req2.h */ + u32 MptTestItem; + /* Variable needed in each implementation of CurrMptAct. */ + u32 MptActType; /* Type of action performed in CurrMptAct. */ + /* The Offset of IO operation is depend of MptActType. */ + u32 MptIoOffset; + /* The Value of IO operation is depend of MptActType. */ + u32 MptIoValue; + /* The RfPath of IO operation is depend of MptActType. */ + u32 MptRfPath; + + enum wireless_mode MptWirelessModeToSw; /* Wireless mode to switch. */ + u8 MptChannelToSw; /* Channel to switch. */ + u8 MptInitGainToSet; /* Initial gain to set. */ + u32 MptBandWidth; /* bandwidth to switch. */ + u32 MptRateIndex; /* rate index. */ + /* Register value kept for Single Carrier Tx test. */ + u8 btMpCckTxPower; + /* Register value kept for Single Carrier Tx test. */ + u8 btMpOfdmTxPower; + /* For MP Tx Power index */ + u8 TxPwrLevel[2]; /* rf-A, rf-B */ + + /* Content of RCR Regsiter for Mass Production Test. */ + u32 MptRCR; + /* true if we only receive packets with specific pattern. */ + bool bMptFilterPattern; + /* Rx OK count, statistics used in Mass Production Test. */ + u32 MptRxOkCnt; + /* Rx CRC32 error count, statistics used in Mass Production Test. */ + u32 MptRxCrcErrCnt; + + bool bCckContTx; /* true if we are in CCK Continuous Tx test. */ + bool bOfdmContTx; /* true if we are in OFDM Continuous Tx test. */ + bool bStartContTx; /* true if we have start Continuous Tx test. */ + /* true if we are in Single Carrier Tx test. */ + bool bSingleCarrier; + /* true if we are in Carrier Suppression Tx Test. */ + bool bCarrierSuppression; + /* true if we are in Single Tone Tx test. */ + bool bSingleTone; + + /* ACK counter asked by K.Y.. */ + bool bMptEnableAckCounter; + u32 MptAckCounter; + + u8 APK_bound[2]; /* for APK path A/path B */ + bool bMptIndexEven; + + u8 backup0xc50; + u8 backup0xc58; + u8 backup0xc30; + u8 backup0x52_RF_A; + u8 backup0x52_RF_B; + + u8 h2cReqNum; + u8 c2hBuf[20]; + + u8 btInBuf[100]; + u32 mptOutLen; + u8 mptOutBuf[100]; +}; + +enum { + WRITE_REG = 1, + READ_REG, + WRITE_RF, + READ_RF, + MP_START, + MP_STOP, + MP_RATE, + MP_CHANNEL, + MP_BANDWIDTH, + MP_TXPOWER, + MP_ANT_TX, + MP_ANT_RX, + MP_CTX, + MP_QUERY, + MP_ARX, + MP_PSD, + MP_PWRTRK, + MP_THER, + MP_IOCTL, + EFUSE_GET, + EFUSE_SET, + MP_RESET_STATS, + MP_DUMP, + MP_PHYPARA, + MP_SetRFPathSwh, + MP_QueryDrvStats, + MP_SetBT, + CTA_TEST, + MP_NULL, +}; + +struct mp_priv { + struct adapter *papdater; + + /* Testing Flag */ + /* 0 for normal type packet, 1 for loopback packet (16bytes TXCMD) */ + u32 mode; + + u32 prev_fw_state; + + /* OID cmd handler */ + struct mp_wiparam workparam; + + /* Tx Section */ + u8 TID; + u32 tx_pktcount; + struct mp_tx tx; + + /* Rx Section */ + u32 rx_pktcount; + u32 rx_crcerrpktcount; + u32 rx_pktloss; + + struct recv_stat rxstat; + + /* RF/BB relative */ + u8 channel; + u8 bandwidth; + u8 prime_channel_offset; + u8 txpoweridx; + u8 txpoweridx_b; + u8 rateidx; + u32 preamble; + u32 CrystalCap; + + u16 antenna_tx; + u16 antenna_rx; + + u8 check_mp_pkt; + + u8 bSetTxPower; + + struct wlan_network mp_network; + unsigned char network_macaddr[ETH_ALEN]; + + u8 *pallocated_mp_xmitframe_buf; + u8 *pmp_xmtframe_buf; + struct __queue free_mp_xmitqueue; + u32 free_mp_xmitframe_cnt; + + struct mpt_context MptCtx; +}; + +struct iocmd_struct { + u8 cmdclass; + u16 value; + u8 index; +}; + +struct rf_reg_param { + u32 path; + u32 offset; + u32 value; +}; + +struct bb_reg_param { + u32 offset; + u32 value; +}; +/* */ + +#define LOWER true +#define RAISE false + +/* Hardware Registers */ +#define BB_REG_BASE_ADDR 0x800 + +/* MP variables */ +enum mp_mode_{ + MP_OFF, + MP_ON, + MP_ERR, + MP_CONTINUOUS_TX, + MP_SINGLE_CARRIER_TX, + MP_CARRIER_SUPPRISSION_TX, + MP_SINGLE_TONE_TX, + MP_PACKET_TX, + MP_PACKET_RX +}; + +#define MAX_RF_PATH_NUMS RF_PATH_MAX + +extern u8 mpdatarate[NumRates]; + +/* MP set force data rate base on the definition. */ +enum mpt_rate_index { + /* CCK rate. */ + MPT_RATE_1M, /* 0 */ + MPT_RATE_2M, + MPT_RATE_55M, + MPT_RATE_11M, /* 3 */ + + /* OFDM rate. */ + MPT_RATE_6M, /* 4 */ + MPT_RATE_9M, + MPT_RATE_12M, + MPT_RATE_18M, + MPT_RATE_24M, + MPT_RATE_36M, + MPT_RATE_48M, + MPT_RATE_54M, /* 11 */ + + /* HT rate. */ + MPT_RATE_MCS0, /* 12 */ + MPT_RATE_MCS1, + MPT_RATE_MCS2, + MPT_RATE_MCS3, + MPT_RATE_MCS4, + MPT_RATE_MCS5, + MPT_RATE_MCS6, + MPT_RATE_MCS7, /* 19 */ + MPT_RATE_MCS8, + MPT_RATE_MCS9, + MPT_RATE_MCS10, + MPT_RATE_MCS11, + MPT_RATE_MCS12, + MPT_RATE_MCS13, + MPT_RATE_MCS14, + MPT_RATE_MCS15, /* 27 */ + MPT_RATE_LAST +}; + +#define MAX_TX_PWR_INDEX_N_MODE 64 /* 0x3F */ + +enum power_mode { + POWER_LOW = 0, + POWER_NORMAL +}; + +#define RX_PKT_BROADCAST 1 +#define RX_PKT_DEST_ADDR 2 +#define RX_PKT_PHY_MATCH 3 + +enum encry_ctrl_state { + HW_CONTROL, /* hw encryption& decryption */ + SW_CONTROL, /* sw encryption& decryption */ + HW_ENCRY_SW_DECRY, /* hw encryption & sw decryption */ + SW_ENCRY_HW_DECRY /* sw encryption & hw decryption */ +}; + +s32 init_mp_priv(struct adapter *padapter); +void free_mp_priv(struct mp_priv *pmp_priv); +s32 MPT_InitializeAdapter(struct adapter *padapter, u8 Channel); +void MPT_DeInitAdapter(struct adapter *padapter); +s32 mp_start_test(struct adapter *padapter); +void mp_stop_test(struct adapter *padapter); + +u32 _read_rfreg(struct adapter *padapter, u8 rfpath, u32 addr, u32 bitmask); +void _write_rfreg(struct adapter *padapter, u8 rfpath, u32 addr, u32 bitmask, u32 val); + +u32 read_macreg(struct adapter *padapter, u32 addr, u32 sz); +void write_macreg(struct adapter *padapter, u32 addr, u32 val, u32 sz); +u32 read_bbreg(struct adapter *padapter, u32 addr, u32 bitmask); +void write_bbreg(struct adapter *padapter, u32 addr, u32 bitmask, u32 val); +u32 read_rfreg(struct adapter *padapter, u8 rfpath, u32 addr); +void write_rfreg(struct adapter *padapter, u8 rfpath, u32 addr, u32 val); + +void SetChannel(struct adapter *pAdapter); +void SetBandwidth(struct adapter *pAdapter); +void SetTxPower(struct adapter *pAdapter); +void SetAntennaPathPower(struct adapter *pAdapter); +void SetDataRate(struct adapter *pAdapter); + +void SetAntenna(struct adapter *pAdapter); + +s32 SetThermalMeter(struct adapter *pAdapter, u8 target_ther); +void GetThermalMeter(struct adapter *pAdapter, u8 *value); + +void SetContinuousTx(struct adapter *pAdapter, u8 bStart); +void SetSingleCarrierTx(struct adapter *pAdapter, u8 bStart); +void SetSingleToneTx(struct adapter *pAdapter, u8 bStart); +void SetCarrierSuppressionTx(struct adapter *pAdapter, u8 bStart); +void PhySetTxPowerLevel(struct adapter *pAdapter); + +void fill_txdesc_for_mp(struct adapter *padapter, struct tx_desc *ptxdesc); +void SetPacketTx(struct adapter *padapter); +void SetPacketRx(struct adapter *pAdapter, u8 bStartRx); + +void ResetPhyRxPktCount(struct adapter *pAdapter); +u32 GetPhyRxPktReceived(struct adapter *pAdapter); +u32 GetPhyRxPktCRC32Error(struct adapter *pAdapter); + +s32 SetPowerTracking(struct adapter *padapter, u8 enable); +void GetPowerTracking(struct adapter *padapter, u8 *enable); +u32 mp_query_psd(struct adapter *pAdapter, u8 *data); +void Hal_SetAntenna(struct adapter *pAdapter); +void Hal_SetBandwidth(struct adapter *pAdapter); +void Hal_SetTxPower(struct adapter *pAdapter); +void Hal_SetCarrierSuppressionTx(struct adapter *pAdapter, u8 bStart); +void Hal_SetSingleToneTx(struct adapter *pAdapter, u8 bStart); +void Hal_SetSingleCarrierTx (struct adapter *pAdapter, u8 bStart); +void Hal_SetContinuousTx (struct adapter *pAdapter, u8 bStart); +void Hal_SetBandwidth(struct adapter *pAdapter); +void Hal_SetDataRate(struct adapter *pAdapter); +void Hal_SetChannel(struct adapter *pAdapter); +void Hal_SetAntennaPathPower(struct adapter *pAdapter); +s32 Hal_SetThermalMeter(struct adapter *pAdapter, u8 target_ther); +s32 Hal_SetPowerTracking(struct adapter *padapter, u8 enable); +void Hal_GetPowerTracking(struct adapter *padapter, u8 * enable); +void Hal_GetThermalMeter(struct adapter *pAdapter, u8 *value); +void Hal_mpt_SwitchRfSetting(struct adapter *pAdapter); +void Hal_MPT_CCKTxPowerAdjust(struct adapter * Adapter, bool bInCH14); +void Hal_MPT_CCKTxPowerAdjustbyIndex(struct adapter *pAdapter, bool beven); +void Hal_SetCCKTxPower(struct adapter *pAdapter, u8 * TxPower); +void Hal_SetOFDMTxPower(struct adapter *pAdapter, u8 * TxPower); +void Hal_TriggerRFThermalMeter(struct adapter *pAdapter); +u8 Hal_ReadRFThermalMeter(struct adapter *pAdapter); +void Hal_SetCCKContinuousTx(struct adapter *pAdapter, u8 bStart); +void Hal_SetOFDMContinuousTx(struct adapter *pAdapter, u8 bStart); +void Hal_ProSetCrystalCap (struct adapter *pAdapter , u32 CrystalCapVal); +void _rtw_mp_xmit_priv(struct xmit_priv *pxmitpriv); +void MP_PHY_SetRFPathSwitch(struct adapter *pAdapter ,bool bMain); + +#endif /* _RTW_MP_H_ */ diff --git a/drivers/staging/rtl8188eu/include/rtw_mp_ioctl.h b/drivers/staging/rtl8188eu/include/rtw_mp_ioctl.h new file mode 100644 index 0000000000000..db2116d3b18ec --- /dev/null +++ b/drivers/staging/rtl8188eu/include/rtw_mp_ioctl.h @@ -0,0 +1,340 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef _RTW_MP_IOCTL_H_ +#define _RTW_MP_IOCTL_H_ + +#include +#include +#include +#include +#include +#include + +/* */ +struct cfg_dbg_msg_struct { + u32 DebugLevel; + u32 DebugComponent_H32; + u32 DebugComponent_L32; +}; + +struct mp_rw_reg { + u32 offset; + u32 width; + u32 value; +}; + +struct efuse_access_struct { + u16 start_addr; + u16 cnts; + u8 data[0]; +}; + +struct burst_rw_reg { + u32 offset; + u32 len; + u8 Data[256]; +}; + +struct usb_vendor_req { + u8 bRequest; + u16 wValue; + u16 wIndex; + u16 wLength; + u8 u8Dir;/* 0:OUT, 1:IN */ + u8 u8InData; +}; + +struct dr_variable_struct { + u8 offset; + u32 variable; +}; + +#define _irqlevel_changed_(a, b) + +/* oid_rtl_seg_81_80_00 */ +int oid_rt_pro_set_data_rate_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_pro_start_test_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_pro_stop_test_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_pro_set_channel_direct_call_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_pro_set_antenna_bb_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_pro_set_tx_power_control_hdl(struct oid_par_priv *poid_par_priv); + +/* oid_rtl_seg_81_80_20 */ +int oid_rt_pro_query_tx_packet_sent_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_pro_query_rx_packet_received_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_pro_query_rx_packet_crc32_error_hdl(struct oid_par_priv *par_priv); +int oid_rt_pro_reset_tx_packet_sent_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_pro_reset_rx_packet_received_hdl(struct oid_par_priv *par_priv); +int oid_rt_pro_set_modulation_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_pro_set_continuous_tx_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_pro_set_single_carrier_tx_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_pro_set_carrier_suppression_tx_hdl(struct oid_par_priv *par_priv); +int oid_rt_pro_set_single_tone_tx_hdl(struct oid_par_priv *poid_par_priv); + +/* oid_rtl_seg_81_87 */ +int oid_rt_pro_write_bb_reg_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_pro_read_bb_reg_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_pro_write_rf_reg_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_pro_read_rf_reg_hdl(struct oid_par_priv *poid_par_priv); + +/* oid_rtl_seg_81_85 */ +int oid_rt_wireless_mode_hdl(struct oid_par_priv *poid_par_priv); + +/* oid_rtl_seg_87_11_00 */ +int oid_rt_pro8711_join_bss_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_pro_read_register_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_pro_write_register_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_pro_burst_read_register_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_pro_burst_write_register_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_pro_write_txcmd_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_pro_read16_eeprom_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_pro_write16_eeprom_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_pro8711_wi_poll_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_pro8711_pkt_loss_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_rd_attrib_mem_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_wr_attrib_mem_hdl (struct oid_par_priv *poid_par_priv); +int oid_rt_pro_set_rf_intfs_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_poll_rx_status_hdl(struct oid_par_priv *poid_par_priv); +/* oid_rtl_seg_87_11_20 */ +int oid_rt_pro_cfg_debug_message_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_pro_set_data_rate_ex_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_pro_set_basic_rate_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_pro_read_tssi_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_pro_set_power_tracking_hdl(struct oid_par_priv *poid_par_priv); +/* oid_rtl_seg_87_11_50 */ +int oid_rt_pro_qry_pwrstate_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_pro_set_pwrstate_hdl(struct oid_par_priv *poid_par_priv); +/* oid_rtl_seg_87_11_F0 */ +int oid_rt_pro_h2c_set_rate_table_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_pro_h2c_get_rate_table_hdl(struct oid_par_priv *poid_par_priv); + +/* oid_rtl_seg_87_12_00 */ +int oid_rt_pro_encryption_ctrl_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_pro_add_sta_info_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_pro_dele_sta_info_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_pro_query_dr_variable_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_pro_rx_packet_type_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_pro_read_efuse_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_pro_write_efuse_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_pro_rw_efuse_pgpkt_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_efuse_current_size_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_pro_efuse_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_pro_efuse_map_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_set_bandwidth_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_set_crystal_cap_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_set_rx_packet_type_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_efuse_max_size_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_pro_set_tx_agc_offset_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_pro_set_pkt_test_mode_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_thermal_meter_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_reset_phy_rx_packet_count_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_phy_rx_packet_received_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_phy_rx_packet_crc32_error_hdl(struct oid_par_priv *par_priv); +int oid_rt_set_power_down_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_power_mode_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_pro_trigger_gpio_hdl(struct oid_par_priv *poid_par_priv); + +#ifdef _RTW_MP_IOCTL_C_ + +static const struct oid_obj_priv oid_rtl_seg_81_80_00[] = { + {1, &oid_null_function}, /* 0x00 OID_RT_PRO_RESET_DUT */ + {1, &oid_rt_pro_set_data_rate_hdl}, /* 0x01 */ + {1, &oid_rt_pro_start_test_hdl}, /* 0x02 */ + {1, &oid_rt_pro_stop_test_hdl}, /* 0x03 */ + {1, &oid_null_function}, /* 0x04 OID_RT_PRO_SET_PREAMBLE */ + {1, &oid_null_function}, /* 0x05 OID_RT_PRO_SET_SCRAMBLER */ + {1, &oid_null_function}, /* 0x06 OID_RT_PRO_SET_FILTER_BB */ + {1, &oid_null_function},/* 0x07 OID_RT_PRO_SET_MANUAL_DIVERSITY_BB */ + {1, &oid_rt_pro_set_channel_direct_call_hdl}, /* 0x08 */ + {1, &oid_null_function},/* 0x09 OID_RT_PRO_SET_SLEEP_MODE_DIRECT_CALL */ + {1, &oid_null_function},/* 0x0A OID_RT_PRO_SET_WAKE_MODE_DIRECT_CALL */ + {1, &oid_rt_pro_set_continuous_tx_hdl}, /* 0x0B OID_RT_PRO_SET_TX_CONTINUOUS_DIRECT_CALL */ + {1, &oid_rt_pro_set_single_carrier_tx_hdl},/* 0x0C OID_RT_PRO_SET_SINGLE_CARRIER_TX_CONTINUOUS */ + {1, &oid_null_function}, /* 0x0D OID_RT_PRO_SET_TX_ANTENNA_BB */ + {1, &oid_rt_pro_set_antenna_bb_hdl}, /* 0x0E */ + {1, &oid_null_function}, /* 0x0F OID_RT_PRO_SET_CR_SCRAMBLER */ + {1, &oid_null_function}, /* 0x10 OID_RT_PRO_SET_CR_NEW_FILTER */ + {1, &oid_rt_pro_set_tx_power_control_hdl},/* 0x11 OID_RT_PRO_SET_TX_POWER_CONTROL */ + {1, &oid_null_function}, /* 0x12 OID_RT_PRO_SET_CR_TX_CONFIG */ + {1, &oid_null_function}, /* 0x13 OID_RT_PRO_GET_TX_POWER_CONTROL */ + {1, &oid_null_function}, /* 0x14 OID_RT_PRO_GET_CR_SIGNAL_QUALITY */ + {1, &oid_null_function}, /* 0x15 OID_RT_PRO_SET_CR_SETPOINT */ + {1, &oid_null_function}, /* 0x16 OID_RT_PRO_SET_INTEGRATOR */ + {1, &oid_null_function}, /* 0x17 OID_RT_PRO_SET_SIGNAL_QUALITY */ + {1, &oid_null_function}, /* 0x18 OID_RT_PRO_GET_INTEGRATOR */ + {1, &oid_null_function}, /* 0x19 OID_RT_PRO_GET_SIGNAL_QUALITY */ + {1, &oid_null_function}, /* 0x1A OID_RT_PRO_QUERY_EEPROM_TYPE */ + {1, &oid_null_function}, /* 0x1B OID_RT_PRO_WRITE_MAC_ADDRESS */ + {1, &oid_null_function}, /* 0x1C OID_RT_PRO_READ_MAC_ADDRESS */ + {1, &oid_null_function}, /* 0x1D OID_RT_PRO_WRITE_CIS_DATA */ + {1, &oid_null_function}, /* 0x1E OID_RT_PRO_READ_CIS_DATA */ + {1, &oid_null_function} /* 0x1F OID_RT_PRO_WRITE_POWER_CONTROL */ +}; + +static const struct oid_obj_priv oid_rtl_seg_81_80_20[] = { + {1, &oid_null_function}, /* 0x20 OID_RT_PRO_READ_POWER_CONTROL */ + {1, &oid_null_function}, /* 0x21 OID_RT_PRO_WRITE_EEPROM */ + {1, &oid_null_function}, /* 0x22 OID_RT_PRO_READ_EEPROM */ + {1, &oid_rt_pro_reset_tx_packet_sent_hdl}, /* 0x23 */ + {1, &oid_rt_pro_query_tx_packet_sent_hdl}, /* 0x24 */ + {1, &oid_rt_pro_reset_rx_packet_received_hdl}, /* 0x25 */ + {1, &oid_rt_pro_query_rx_packet_received_hdl}, /* 0x26 */ + {1, &oid_rt_pro_query_rx_packet_crc32_error_hdl}, /* 0x27 */ + {1, &oid_null_function}, /* 0x28 OID_RT_PRO_QUERY_CURRENT_ADDRESS */ + {1, &oid_null_function}, /* 0x29 OID_RT_PRO_QUERY_PERMANENT_ADDRESS */ + {1, &oid_null_function}, /* 0x2A OID_RT_PRO_SET_PHILIPS_RF_PARAMETERS */ + {1, &oid_rt_pro_set_carrier_suppression_tx_hdl},/* 0x2B OID_RT_PRO_SET_CARRIER_SUPPRESSION_TX */ + {1, &oid_null_function}, /* 0x2C OID_RT_PRO_RECEIVE_PACKET */ + {1, &oid_null_function}, /* 0x2D OID_RT_PRO_WRITE_EEPROM_BYTE */ + {1, &oid_null_function}, /* 0x2E OID_RT_PRO_READ_EEPROM_BYTE */ + {1, &oid_rt_pro_set_modulation_hdl} /* 0x2F */ +}; + +static const struct oid_obj_priv oid_rtl_seg_81_80_40[] = { + {1, &oid_null_function}, /* 0x40 */ + {1, &oid_null_function}, /* 0x41 */ + {1, &oid_null_function}, /* 0x42 */ + {1, &oid_rt_pro_set_single_tone_tx_hdl}, /* 0x43 */ + {1, &oid_null_function}, /* 0x44 */ + {1, &oid_null_function} /* 0x45 */ +}; + +static const struct oid_obj_priv oid_rtl_seg_81_80_80[] = { + {1, &oid_null_function}, /* 0x80 OID_RT_DRIVER_OPTION */ + {1, &oid_null_function}, /* 0x81 OID_RT_RF_OFF */ + {1, &oid_null_function} /* 0x82 OID_RT_AUTH_STATUS */ +}; + +static const struct oid_obj_priv oid_rtl_seg_81_85[] = { + {1, &oid_rt_wireless_mode_hdl} /* 0x00 OID_RT_WIRELESS_MODE */ +}; + +#endif /* _RTL871X_MP_IOCTL_C_ */ + +struct rwreg_param { + u32 offset; + u32 width; + u32 value; +}; + +struct bbreg_param { + u32 offset; + u32 phymask; + u32 value; +}; + +struct txpower_param { + u32 pwr_index; +}; + +struct datarate_param { + u32 rate_index; +}; + +struct rfintfs_parm { + u32 rfintfs; +}; + +struct mp_xmit_parm { + u8 enable; + u32 count; + u16 length; + u8 payload_type; + u8 da[ETH_ALEN]; +}; + +struct mp_xmit_packet { + u32 len; + u32 mem[MAX_MP_XMITBUF_SZ >> 2]; +}; + +struct psmode_param { + u32 ps_mode; + u32 smart_ps; +}; + +/* for OID_RT_PRO_READ16_EEPROM & OID_RT_PRO_WRITE16_EEPROM */ +struct eeprom_rw_param { + u32 offset; + u16 value; +}; + +struct mp_ioctl_handler { + u32 paramsize; + s32 (*handler)(struct oid_par_priv* poid_par_priv); + u32 oid; +}; + +struct mp_ioctl_param{ + u32 subcode; + u32 len; + u8 data[0]; +}; + +#define GEN_MP_IOCTL_SUBCODE(code) _MP_IOCTL_ ## code ## _CMD_ + +enum RTL871X_MP_IOCTL_SUBCODE { + GEN_MP_IOCTL_SUBCODE(MP_START), /*0*/ + GEN_MP_IOCTL_SUBCODE(MP_STOP), + GEN_MP_IOCTL_SUBCODE(READ_REG), + GEN_MP_IOCTL_SUBCODE(WRITE_REG), + GEN_MP_IOCTL_SUBCODE(READ_BB_REG), + GEN_MP_IOCTL_SUBCODE(WRITE_BB_REG), /*5*/ + GEN_MP_IOCTL_SUBCODE(READ_RF_REG), + GEN_MP_IOCTL_SUBCODE(WRITE_RF_REG), + GEN_MP_IOCTL_SUBCODE(SET_CHANNEL), + GEN_MP_IOCTL_SUBCODE(SET_TXPOWER), + GEN_MP_IOCTL_SUBCODE(SET_DATARATE), /*10*/ + GEN_MP_IOCTL_SUBCODE(SET_BANDWIDTH), + GEN_MP_IOCTL_SUBCODE(SET_ANTENNA), + GEN_MP_IOCTL_SUBCODE(CNTU_TX), + GEN_MP_IOCTL_SUBCODE(SC_TX), + GEN_MP_IOCTL_SUBCODE(CS_TX), /*15*/ + GEN_MP_IOCTL_SUBCODE(ST_TX), + GEN_MP_IOCTL_SUBCODE(IOCTL_XMIT_PACKET), + GEN_MP_IOCTL_SUBCODE(SET_RX_PKT_TYPE), + GEN_MP_IOCTL_SUBCODE(RESET_PHY_RX_PKT_CNT), + GEN_MP_IOCTL_SUBCODE(GET_PHY_RX_PKT_RECV), /*20*/ + GEN_MP_IOCTL_SUBCODE(GET_PHY_RX_PKT_ERROR), + GEN_MP_IOCTL_SUBCODE(READ16_EEPROM), + GEN_MP_IOCTL_SUBCODE(WRITE16_EEPROM), + GEN_MP_IOCTL_SUBCODE(EFUSE), + GEN_MP_IOCTL_SUBCODE(EFUSE_MAP), /*25*/ + GEN_MP_IOCTL_SUBCODE(GET_EFUSE_MAX_SIZE), + GEN_MP_IOCTL_SUBCODE(GET_EFUSE_CURRENT_SIZE), + GEN_MP_IOCTL_SUBCODE(GET_THERMAL_METER), + GEN_MP_IOCTL_SUBCODE(SET_PTM), + GEN_MP_IOCTL_SUBCODE(SET_POWER_DOWN), /*30*/ + GEN_MP_IOCTL_SUBCODE(TRIGGER_GPIO), + GEN_MP_IOCTL_SUBCODE(SET_DM_BT), /*35*/ + GEN_MP_IOCTL_SUBCODE(DEL_BA), /*36*/ + GEN_MP_IOCTL_SUBCODE(GET_WIFI_STATUS), /*37*/ + MAX_MP_IOCTL_SUBCODE, +}; + +s32 mp_ioctl_xmit_packet_hdl(struct oid_par_priv *poid_par_priv); + +#define GEN_HANDLER(sz, hdl, oid) {sz, hdl, oid}, + +#define EXT_MP_IOCTL_HANDLER(sz, subcode, oid) \ + {sz, mp_ioctl_##subcode##_hdl, oid}, + + +#endif diff --git a/drivers/staging/rtl8188eu/include/rtw_mp_phy_regdef.h b/drivers/staging/rtl8188eu/include/rtw_mp_phy_regdef.h new file mode 100644 index 0000000000000..3ad22076de3fc --- /dev/null +++ b/drivers/staging/rtl8188eu/include/rtw_mp_phy_regdef.h @@ -0,0 +1,1084 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +/***************************************************************************** + * + * Module: __RTW_MP_PHY_REGDEF_H_ + * + * + * Note: 1. Define PMAC/BB register map + * 2. Define RF register map + * 3. PMAC/BB register bit mask. + * 4. RF reg bit mask. + * 5. Other BB/RF relative definition. + * + * + * Export: Constants, macro, functions(API), global variables(None). + * + * Abbrev: + * + * History: + * Data Who Remark + * 08/07/2007 MHC 1. Porting from 9x series PHYCFG.h. + * 2. Reorganize code architecture. + * 09/25/2008 MH 1. Add RL6052 register definition + * + *****************************************************************************/ +#ifndef __RTW_MP_PHY_REGDEF_H_ +#define __RTW_MP_PHY_REGDEF_H_ + + +/*--------------------------Define Parameters-------------------------------*/ + +/* */ +/* 8192S Regsiter offset definition */ +/* */ + +/* */ +/* BB-PHY register PMAC 0x100 PHY 0x800 - 0xEFF */ +/* 1. PMAC duplicate register due to connection: RF_Mode, TRxRN, NumOf L-STF */ +/* 2. 0x800/0x900/0xA00/0xC00/0xD00/0xE00 */ +/* 3. RF register 0x00-2E */ +/* 4. Bit Mask for BB/RF register */ +/* 5. Other defintion for BB/RF R/W */ +/* */ + + +/* */ +/* 1. PMAC duplicate register due to connection: RF_Mode, TRxRN, NumOf L-STF */ +/* 1. Page1(0x100) */ +/* */ +#define rPMAC_Reset 0x100 +#define rPMAC_TxStart 0x104 +#define rPMAC_TxLegacySIG 0x108 +#define rPMAC_TxHTSIG1 0x10c +#define rPMAC_TxHTSIG2 0x110 +#define rPMAC_PHYDebug 0x114 +#define rPMAC_TxPacketNum 0x118 +#define rPMAC_TxIdle 0x11c +#define rPMAC_TxMACHeader0 0x120 +#define rPMAC_TxMACHeader1 0x124 +#define rPMAC_TxMACHeader2 0x128 +#define rPMAC_TxMACHeader3 0x12c +#define rPMAC_TxMACHeader4 0x130 +#define rPMAC_TxMACHeader5 0x134 +#define rPMAC_TxDataType 0x138 +#define rPMAC_TxRandomSeed 0x13c +#define rPMAC_CCKPLCPPreamble 0x140 +#define rPMAC_CCKPLCPHeader 0x144 +#define rPMAC_CCKCRC16 0x148 +#define rPMAC_OFDMRxCRC32OK 0x170 +#define rPMAC_OFDMRxCRC32Er 0x174 +#define rPMAC_OFDMRxParityEr 0x178 +#define rPMAC_OFDMRxCRC8Er 0x17c +#define rPMAC_CCKCRxRC16Er 0x180 +#define rPMAC_CCKCRxRC32Er 0x184 +#define rPMAC_CCKCRxRC32OK 0x188 +#define rPMAC_TxStatus 0x18c + +/* */ +/* 2. Page2(0x200) */ +/* */ +/* The following two definition are only used for USB interface. */ +/* define RF_BB_CMD_ADDR 0x02c0 RF/BB read/write command address. */ +/* define RF_BB_CMD_DATA 0x02c4 RF/BB read/write command data. */ + +/* */ +/* 3. Page8(0x800) */ +/* */ +#define rFPGA0_RFMOD 0x800 /* RF mode & CCK TxSC RF BW Setting?? */ + +#define rFPGA0_TxInfo 0x804 /* Status report?? */ +#define rFPGA0_PSDFunction 0x808 + +#define rFPGA0_TxGainStage 0x80c /* Set TX PWR init gain? */ + +#define rFPGA0_RFTiming1 0x810 /* Useless now */ +#define rFPGA0_RFTiming2 0x814 +/* define rFPGA0_XC_RFTiming 0x818 */ +/* define rFPGA0_XD_RFTiming 0x81c */ + +#define rFPGA0_XA_HSSIParameter1 0x820 /* RF 3 wire register */ +#define rFPGA0_XA_HSSIParameter2 0x824 +#define rFPGA0_XB_HSSIParameter1 0x828 +#define rFPGA0_XB_HSSIParameter2 0x82c +#define rFPGA0_XC_HSSIParameter1 0x830 +#define rFPGA0_XC_HSSIParameter2 0x834 +#define rFPGA0_XD_HSSIParameter1 0x838 +#define rFPGA0_XD_HSSIParameter2 0x83c +#define rFPGA0_XA_LSSIParameter 0x840 +#define rFPGA0_XB_LSSIParameter 0x844 +#define rFPGA0_XC_LSSIParameter 0x848 +#define rFPGA0_XD_LSSIParameter 0x84c + +#define rFPGA0_RFWakeUpParameter 0x850 /* Useless now */ +#define rFPGA0_RFSleepUpParameter 0x854 + +#define rFPGA0_XAB_SwitchControl 0x858 /* RF Channel switch */ +#define rFPGA0_XCD_SwitchControl 0x85c + +#define rFPGA0_XA_RFInterfaceOE 0x860 /* RF Channel switch */ +#define rFPGA0_XB_RFInterfaceOE 0x864 +#define rFPGA0_XC_RFInterfaceOE 0x868 +#define rFPGA0_XD_RFInterfaceOE 0x86c + +#define rFPGA0_XAB_RFInterfaceSW 0x870 /* RF Interface Software Control */ +#define rFPGA0_XCD_RFInterfaceSW 0x874 + +#define rFPGA0_XAB_RFParameter 0x878 /* RF Parameter */ +#define rFPGA0_XCD_RFParameter 0x87c + +#define rFPGA0_AnalogParameter1 0x880 /* Crystal cap setting RF-R/W protection for parameter4?? */ +#define rFPGA0_AnalogParameter2 0x884 +#define rFPGA0_AnalogParameter3 0x888 /* Useless now */ +#define rFPGA0_AnalogParameter4 0x88c + +#define rFPGA0_XA_LSSIReadBack 0x8a0 /* Tranceiver LSSI Readback */ +#define rFPGA0_XB_LSSIReadBack 0x8a4 +#define rFPGA0_XC_LSSIReadBack 0x8a8 +#define rFPGA0_XD_LSSIReadBack 0x8ac + +#define rFPGA0_PSDReport 0x8b4 /* Useless now */ +#define rFPGA0_XAB_RFInterfaceRB 0x8e0 /* Useless now RF Interface Readback Value */ +#define rFPGA0_XCD_RFInterfaceRB 0x8e4 /* Useless now */ + +/* */ +/* 4. Page9(0x900) */ +/* */ +#define rFPGA1_RFMOD 0x900 /* RF mode & OFDM TxSC RF BW Setting?? */ + +#define rFPGA1_TxBlock 0x904 /* Useless now */ +#define rFPGA1_DebugSelect 0x908 /* Useless now */ +#define rFPGA1_TxInfo 0x90c /* Useless now Status report?? */ + +/* */ +/* 5. PageA(0xA00) */ +/* */ +/* Set Control channel to upper or lower. These settings are required only for 40MHz */ +#define rCCK0_System 0xa00 + +#define rCCK0_AFESetting 0xa04 /* Disable init gain now Select RX path by RSSI */ +#define rCCK0_CCA 0xa08 /* Disable init gain now Init gain */ + +#define rCCK0_RxAGC1 0xa0c /* AGC default value, saturation level Antenna Diversity, RX AGC, LNA Threshold, RX LNA Threshold useless now. Not the same as 90 series */ +#define rCCK0_RxAGC2 0xa10 /* AGC & DAGC */ + +#define rCCK0_RxHP 0xa14 + +#define rCCK0_DSPParameter1 0xa18 /* Timing recovery & Channel estimation threshold */ +#define rCCK0_DSPParameter2 0xa1c /* SQ threshold */ + +#define rCCK0_TxFilter1 0xa20 +#define rCCK0_TxFilter2 0xa24 +#define rCCK0_DebugPort 0xa28 /* debug port and Tx filter3 */ +#define rCCK0_FalseAlarmReport 0xa2c /* 0xa2d useless now 0xa30-a4f channel report */ +#define rCCK0_TRSSIReport 0xa50 +#define rCCK0_RxReport 0xa54 /* 0xa57 */ +#define rCCK0_FACounterLower 0xa5c /* 0xa5b */ +#define rCCK0_FACounterUpper 0xa58 /* 0xa5c */ + +/* */ +/* 6. PageC(0xC00) */ +/* */ +#define rOFDM0_LSTF 0xc00 + +#define rOFDM0_TRxPathEnable 0xc04 +#define rOFDM0_TRMuxPar 0xc08 +#define rOFDM0_TRSWIsolation 0xc0c + +#define rOFDM0_XARxAFE 0xc10 /* RxIQ DC offset, Rx digital filter, DC notch filter */ +#define rOFDM0_XARxIQImbalance 0xc14 /* RxIQ imblance matrix */ +#define rOFDM0_XBRxAFE 0xc18 +#define rOFDM0_XBRxIQImbalance 0xc1c +#define rOFDM0_XCRxAFE 0xc20 +#define rOFDM0_XCRxIQImbalance 0xc24 +#define rOFDM0_XDRxAFE 0xc28 +#define rOFDM0_XDRxIQImbalance 0xc2c + +#define rOFDM0_RxDetector1 0xc30 /* PD,BW & SBD DM tune init gain */ +#define rOFDM0_RxDetector2 0xc34 /* SBD & Fame Sync. */ +#define rOFDM0_RxDetector3 0xc38 /* Frame Sync. */ +#define rOFDM0_RxDetector4 0xc3c /* PD, SBD, Frame Sync & Short-GI */ + +#define rOFDM0_RxDSP 0xc40 /* Rx Sync Path */ +#define rOFDM0_CFOandDAGC 0xc44 /* CFO & DAGC */ +#define rOFDM0_CCADropThreshold 0xc48 /* CCA Drop threshold */ +#define rOFDM0_ECCAThreshold 0xc4c /* energy CCA */ + +#define rOFDM0_XAAGCCore1 0xc50 /* DIG */ +#define rOFDM0_XAAGCCore2 0xc54 +#define rOFDM0_XBAGCCore1 0xc58 +#define rOFDM0_XBAGCCore2 0xc5c +#define rOFDM0_XCAGCCore1 0xc60 +#define rOFDM0_XCAGCCore2 0xc64 +#define rOFDM0_XDAGCCore1 0xc68 +#define rOFDM0_XDAGCCore2 0xc6c + +#define rOFDM0_AGCParameter1 0xc70 +#define rOFDM0_AGCParameter2 0xc74 +#define rOFDM0_AGCRSSITable 0xc78 +#define rOFDM0_HTSTFAGC 0xc7c + +#define rOFDM0_XATxIQImbalance 0xc80 /* TX PWR TRACK and DIG */ +#define rOFDM0_XATxAFE 0xc84 +#define rOFDM0_XBTxIQImbalance 0xc88 +#define rOFDM0_XBTxAFE 0xc8c +#define rOFDM0_XCTxIQImbalance 0xc90 +#define rOFDM0_XCTxAFE 0xc94 +#define rOFDM0_XDTxIQImbalance 0xc98 +#define rOFDM0_XDTxAFE 0xc9c +#define rOFDM0_RxIQExtAnta 0xca0 + +#define rOFDM0_RxHPParameter 0xce0 +#define rOFDM0_TxPseudoNoiseWgt 0xce4 +#define rOFDM0_FrameSync 0xcf0 +#define rOFDM0_DFSReport 0xcf4 +#define rOFDM0_TxCoeff1 0xca4 +#define rOFDM0_TxCoeff2 0xca8 +#define rOFDM0_TxCoeff3 0xcac +#define rOFDM0_TxCoeff4 0xcb0 +#define rOFDM0_TxCoeff5 0xcb4 +#define rOFDM0_TxCoeff6 0xcb8 + +/* 7. PageD(0xD00) */ +#define rOFDM1_LSTF 0xd00 +#define rOFDM1_TRxPathEnable 0xd04 + +#define rOFDM1_CFO 0xd08 /* No setting now */ +#define rOFDM1_CSI1 0xd10 +#define rOFDM1_SBD 0xd14 +#define rOFDM1_CSI2 0xd18 +#define rOFDM1_CFOTracking 0xd2c +#define rOFDM1_TRxMesaure1 0xd34 +#define rOFDM1_IntfDet 0xd3c +#define rOFDM1_PseudoNoiseStateAB 0xd50 +#define rOFDM1_PseudoNoiseStateCD 0xd54 +#define rOFDM1_RxPseudoNoiseWgt 0xd58 + +#define rOFDM_PHYCounter1 0xda0 /* cca, parity fail */ +#define rOFDM_PHYCounter2 0xda4 /* rate illegal, crc8 fail */ +#define rOFDM_PHYCounter3 0xda8 /* MCS not support */ + +#define rOFDM_ShortCFOAB 0xdac /* No setting now */ +#define rOFDM_ShortCFOCD 0xdb0 +#define rOFDM_LongCFOAB 0xdb4 +#define rOFDM_LongCFOCD 0xdb8 +#define rOFDM_TailCFOAB 0xdbc +#define rOFDM_TailCFOCD 0xdc0 +#define rOFDM_PWMeasure1 0xdc4 +#define rOFDM_PWMeasure2 0xdc8 +#define rOFDM_BWReport 0xdcc +#define rOFDM_AGCReport 0xdd0 +#define rOFDM_RxSNR 0xdd4 +#define rOFDM_RxEVMCSI 0xdd8 +#define rOFDM_SIGReport 0xddc + + +/* */ +/* 8. PageE(0xE00) */ +/* */ +#define rTxAGC_Rate18_06 0xe00 +#define rTxAGC_Rate54_24 0xe04 +#define rTxAGC_CCK_Mcs32 0xe08 +#define rTxAGC_Mcs03_Mcs00 0xe10 +#define rTxAGC_Mcs07_Mcs04 0xe14 +#define rTxAGC_Mcs11_Mcs08 0xe18 +#define rTxAGC_Mcs15_Mcs12 0xe1c + +/* Analog- control in RX_WAIT_CCA : REG: EE0 [Analog- Power & Control Register] */ +#define rRx_Wait_CCCA 0xe70 +#define rAnapar_Ctrl_BB 0xee0 + +/* */ +/* 7. RF Register 0x00-0x2E (RF 8256) */ +/* RF-0222D 0x00-3F */ +/* */ +/* Zebra1 */ +#define RTL92SE_FPGA_VERIFY 0 +#define rZebra1_HSSIEnable 0x0 /* Useless now */ +#define rZebra1_TRxEnable1 0x1 +#define rZebra1_TRxEnable2 0x2 +#define rZebra1_AGC 0x4 +#define rZebra1_ChargePump 0x5 +/* if (RTL92SE_FPGA_VERIFY == 1) */ +#define rZebra1_Channel 0x7 /* RF channel switch */ +/* else */ + +/* endif */ +#define rZebra1_TxGain 0x8 /* Useless now */ +#define rZebra1_TxLPF 0x9 +#define rZebra1_RxLPF 0xb +#define rZebra1_RxHPFCorner 0xc + +/* Zebra4 */ +#define rGlobalCtrl 0 /* Useless now */ +#define rRTL8256_TxLPF 19 +#define rRTL8256_RxLPF 11 + +/* RTL8258 */ +#define rRTL8258_TxLPF 0x11 /* Useless now */ +#define rRTL8258_RxLPF 0x13 +#define rRTL8258_RSSILPF 0xa + +/* */ +/* RL6052 Register definition */ +#define RF_AC 0x00 /* */ + +#define RF_IQADJ_G1 0x01 /* */ +#define RF_IQADJ_G2 0x02 /* */ +#define RF_POW_TRSW 0x05 /* */ + +#define RF_GAIN_RX 0x06 /* */ +#define RF_GAIN_TX 0x07 /* */ + +#define RF_TXM_IDAC 0x08 /* */ +#define RF_BS_IQGEN 0x0F /* */ + +#define RF_MODE1 0x10 /* */ +#define RF_MODE2 0x11 /* */ + +#define RF_RX_AGC_HP 0x12 /* */ +#define RF_TX_AGC 0x13 /* */ +#define RF_BIAS 0x14 /* */ +#define RF_IPA 0x15 /* */ +#define RF_TXBIAS 0x16 /* */ +#define RF_POW_ABILITY 0x17 /* */ +#define RF_MODE_AG 0x18 /* */ +#define rRfChannel 0x18 /* RF channel and BW switch */ +#define RF_CHNLBW 0x18 /* RF channel and BW switch */ +#define RF_TOP 0x19 /* */ + +#define RF_RX_G1 0x1A /* */ +#define RF_RX_G2 0x1B /* */ + +#define RF_RX_BB2 0x1C /* */ +#define RF_RX_BB1 0x1D /* */ + +#define RF_RCK1 0x1E /* */ +#define RF_RCK2 0x1F /* */ + +#define RF_TX_G1 0x20 /* */ +#define RF_TX_G2 0x21 /* */ +#define RF_TX_G3 0x22 /* */ + +#define RF_TX_BB1 0x23 /* */ + +#define RF_T_METER 0x24 /* */ + +#define RF_SYN_G1 0x25 /* RF TX Power control */ +#define RF_SYN_G2 0x26 /* RF TX Power control */ +#define RF_SYN_G3 0x27 /* RF TX Power control */ +#define RF_SYN_G4 0x28 /* RF TX Power control */ +#define RF_SYN_G5 0x29 /* RF TX Power control */ +#define RF_SYN_G6 0x2A /* RF TX Power control */ +#define RF_SYN_G7 0x2B /* RF TX Power control */ +#define RF_SYN_G8 0x2C /* RF TX Power control */ + +#define RF_RCK_OS 0x30 /* RF TX PA control */ +#define RF_TXPA_G1 0x31 /* RF TX PA control */ +#define RF_TXPA_G2 0x32 /* RF TX PA control */ +#define RF_TXPA_G3 0x33 /* RF TX PA control */ + +/* */ +/* Bit Mask */ +/* */ +/* 1. Page1(0x100) */ +#define bBBResetB 0x100 /* Useless now? */ +#define bGlobalResetB 0x200 +#define bOFDMTxStart 0x4 +#define bCCKTxStart 0x8 +#define bCRC32Debug 0x100 +#define bPMACLoopback 0x10 +#define bTxLSIG 0xffffff +#define bOFDMTxRate 0xf +#define bOFDMTxReserved 0x10 +#define bOFDMTxLength 0x1ffe0 +#define bOFDMTxParity 0x20000 +#define bTxHTSIG1 0xffffff +#define bTxHTMCSRate 0x7f +#define bTxHTBW 0x80 +#define bTxHTLength 0xffff00 +#define bTxHTSIG2 0xffffff +#define bTxHTSmoothing 0x1 +#define bTxHTSounding 0x2 +#define bTxHTReserved 0x4 +#define bTxHTAggreation 0x8 +#define bTxHTSTBC 0x30 +#define bTxHTAdvanceCoding 0x40 +#define bTxHTShortGI 0x80 +#define bTxHTNumberHT_LTF 0x300 +#define bTxHTCRC8 0x3fc00 +#define bCounterReset 0x10000 +#define bNumOfOFDMTx 0xffff +#define bNumOfCCKTx 0xffff0000 +#define bTxIdleInterval 0xffff +#define bOFDMService 0xffff0000 +#define bTxMACHeader 0xffffffff +#define bTxDataInit 0xff +#define bTxHTMode 0x100 +#define bTxDataType 0x30000 +#define bTxRandomSeed 0xffffffff +#define bCCKTxPreamble 0x1 +#define bCCKTxSFD 0xffff0000 +#define bCCKTxSIG 0xff +#define bCCKTxService 0xff00 +#define bCCKLengthExt 0x8000 +#define bCCKTxLength 0xffff0000 +#define bCCKTxCRC16 0xffff +#define bCCKTxStatus 0x1 +#define bOFDMTxStatus 0x2 + +#define IS_BB_REG_OFFSET_92S(_Offset) ((_Offset >= 0x800) && (_Offset <= 0xfff)) + +/* 2. Page8(0x800) */ +#define bRFMOD 0x1 /* Reg 0x800 rFPGA0_RFMOD */ +#define bJapanMode 0x2 +#define bCCKTxSC 0x30 +#define bCCKEn 0x1000000 +#define bOFDMEn 0x2000000 + +#define bOFDMRxADCPhase 0x10000 /* Useless now */ +#define bOFDMTxDACPhase 0x40000 +#define bXATxAGC 0x3f + +#define bXBTxAGC 0xf00 /* Reg 80c rFPGA0_TxGainStage */ +#define bXCTxAGC 0xf000 +#define bXDTxAGC 0xf0000 + +#define bPAStart 0xf0000000 /* Useless now */ +#define bTRStart 0x00f00000 +#define bRFStart 0x0000f000 +#define bBBStart 0x000000f0 +#define bBBCCKStart 0x0000000f +#define bPAEnd 0xf /* Reg0x814 */ +#define bTREnd 0x0f000000 +#define bRFEnd 0x000f0000 +#define bCCAMask 0x000000f0 /* T2R */ +#define bR2RCCAMask 0x00000f00 +#define bHSSI_R2TDelay 0xf8000000 +#define bHSSI_T2RDelay 0xf80000 +#define bContTxHSSI 0x400 /* chane gain at continue Tx */ +#define bIGFromCCK 0x200 +#define bAGCAddress 0x3f +#define bRxHPTx 0x7000 +#define bRxHPT2R 0x38000 +#define bRxHPCCKIni 0xc0000 +#define bAGCTxCode 0xc00000 +#define bAGCRxCode 0x300000 + +#define b3WireDataLength 0x800 /* Reg 0x820~84f rFPGA0_XA_HSSIParameter1 */ +#define b3WireAddressLength 0x400 + +#define b3WireRFPowerDown 0x1 /* Useless now */ +/* define bHWSISelect 0x8 */ +#define b5GPAPEPolarity 0x40000000 +#define b2GPAPEPolarity 0x80000000 +#define bRFSW_TxDefaultAnt 0x3 +#define bRFSW_TxOptionAnt 0x30 +#define bRFSW_RxDefaultAnt 0x300 +#define bRFSW_RxOptionAnt 0x3000 +#define bRFSI_3WireData 0x1 +#define bRFSI_3WireClock 0x2 +#define bRFSI_3WireLoad 0x4 +#define bRFSI_3WireRW 0x8 +#define bRFSI_3Wire 0xf + +#define bRFSI_RFENV 0x10 /* Reg 0x870 rFPGA0_XAB_RFInterfaceSW */ + +#define bRFSI_TRSW 0x20 /* Useless now */ +#define bRFSI_TRSWB 0x40 +#define bRFSI_ANTSW 0x100 +#define bRFSI_ANTSWB 0x200 +#define bRFSI_PAPE 0x400 +#define bRFSI_PAPE5G 0x800 +#define bBandSelect 0x1 +#define bHTSIG2_GI 0x80 +#define bHTSIG2_Smoothing 0x01 +#define bHTSIG2_Sounding 0x02 +#define bHTSIG2_Aggreaton 0x08 +#define bHTSIG2_STBC 0x30 +#define bHTSIG2_AdvCoding 0x40 +#define bHTSIG2_NumOfHTLTF 0x300 +#define bHTSIG2_CRC8 0x3fc +#define bHTSIG1_MCS 0x7f +#define bHTSIG1_BandWidth 0x80 +#define bHTSIG1_HTLength 0xffff +#define bLSIG_Rate 0xf +#define bLSIG_Reserved 0x10 +#define bLSIG_Length 0x1fffe +#define bLSIG_Parity 0x20 +#define bCCKRxPhase 0x4 +#if (RTL92SE_FPGA_VERIFY == 1) +#define bLSSIReadAddress 0x3f000000 /* LSSI "Read" Address + Reg 0x824 rFPGA0_XA_HSSIParameter2 */ +#else +#define bLSSIReadAddress 0x7f800000 /* T65 RF */ +#endif +#define bLSSIReadEdge 0x80000000 /* LSSI "Read" edge signal */ +#if (RTL92SE_FPGA_VERIFY == 1) +#define bLSSIReadBackData 0xfff /* Reg 0x8a0 + rFPGA0_XA_LSSIReadBack */ +#else +#define bLSSIReadBackData 0xfffff /* T65 RF */ +#endif +#define bLSSIReadOKFlag 0x1000 /* Useless now */ +#define bCCKSampleRate 0x8 /* 0: 44MHz, 1:88MHz */ +#define bRegulator0Standby 0x1 +#define bRegulatorPLLStandby 0x2 +#define bRegulator1Standby 0x4 +#define bPLLPowerUp 0x8 +#define bDPLLPowerUp 0x10 +#define bDA10PowerUp 0x20 +#define bAD7PowerUp 0x200 +#define bDA6PowerUp 0x2000 +#define bXtalPowerUp 0x4000 +#define b40MDClkPowerUP 0x8000 +#define bDA6DebugMode 0x20000 +#define bDA6Swing 0x380000 + +#define bADClkPhase 0x4000000 /* Reg 0x880 + rFPGA0_AnalogParameter1 20/40 CCK support switch 40/80 BB MHZ */ + +#define b80MClkDelay 0x18000000 /* Useless */ +#define bAFEWatchDogEnable 0x20000000 + +#define bXtalCap01 0xc0000000 /* Reg 0x884 + rFPGA0_AnalogParameter2 Crystal cap */ +#define bXtalCap23 0x3 +#define bXtalCap92x 0x0f000000 +#define bXtalCap 0x0f000000 + +#define bIntDifClkEnable 0x400 /* Useless */ +#define bExtSigClkEnable 0x800 +#define bBandgapMbiasPowerUp 0x10000 +#define bAD11SHGain 0xc0000 +#define bAD11InputRange 0x700000 +#define bAD11OPCurrent 0x3800000 +#define bIPathLoopback 0x4000000 +#define bQPathLoopback 0x8000000 +#define bAFELoopback 0x10000000 +#define bDA10Swing 0x7e0 +#define bDA10Reverse 0x800 +#define bDAClkSource 0x1000 +#define bAD7InputRange 0x6000 +#define bAD7Gain 0x38000 +#define bAD7OutputCMMode 0x40000 +#define bAD7InputCMMode 0x380000 +#define bAD7Current 0xc00000 +#define bRegulatorAdjust 0x7000000 +#define bAD11PowerUpAtTx 0x1 +#define bDA10PSAtTx 0x10 +#define bAD11PowerUpAtRx 0x100 +#define bDA10PSAtRx 0x1000 +#define bCCKRxAGCFormat 0x200 +#define bPSDFFTSamplepPoint 0xc000 +#define bPSDAverageNum 0x3000 +#define bIQPathControl 0xc00 +#define bPSDFreq 0x3ff +#define bPSDAntennaPath 0x30 +#define bPSDIQSwitch 0x40 +#define bPSDRxTrigger 0x400000 +#define bPSDTxTrigger 0x80000000 +#define bPSDSineToneScale 0x7f000000 +#define bPSDReport 0xffff + +/* 3. Page9(0x900) */ +#define bOFDMTxSC 0x30000000 /* Useless */ +#define bCCKTxOn 0x1 +#define bOFDMTxOn 0x2 +#define bDebugPage 0xfff /* reset debug page and HWord, + * LWord */ +#define bDebugItem 0xff /* reset debug page and LWord */ +#define bAntL 0x10 +#define bAntNonHT 0x100 +#define bAntHT1 0x1000 +#define bAntHT2 0x10000 +#define bAntHT1S1 0x100000 +#define bAntNonHTS1 0x1000000 + +/* 4. PageA(0xA00) */ +#define bCCKBBMode 0x3 /* Useless */ +#define bCCKTxPowerSaving 0x80 +#define bCCKRxPowerSaving 0x40 + +#define bCCKSideBand 0x10 /* Reg 0xa00 rCCK0 20/40 sw */ + +#define bCCKScramble 0x8 /* Useless */ +#define bCCKAntDiversity 0x8000 +#define bCCKCarrierRecovery 0x4000 +#define bCCKTxRate 0x3000 +#define bCCKDCCancel 0x0800 +#define bCCKISICancel 0x0400 +#define bCCKMatchFilter 0x0200 +#define bCCKEqualizer 0x0100 +#define bCCKPreambleDetect 0x800000 +#define bCCKFastFalseCCA 0x400000 +#define bCCKChEstStart 0x300000 +#define bCCKCCACount 0x080000 +#define bCCKcs_lim 0x070000 +#define bCCKBistMode 0x80000000 +#define bCCKCCAMask 0x40000000 +#define bCCKTxDACPhase 0x4 +#define bCCKRxADCPhase 0x20000000 /* r_rx_clk */ +#define bCCKr_cp_mode0 0x0100 +#define bCCKTxDCOffset 0xf0 +#define bCCKRxDCOffset 0xf +#define bCCKCCAMode 0xc000 +#define bCCKFalseCS_lim 0x3f00 +#define bCCKCS_ratio 0xc00000 +#define bCCKCorgBit_sel 0x300000 +#define bCCKPD_lim 0x0f0000 +#define bCCKNewCCA 0x80000000 +#define bCCKRxHPofIG 0x8000 +#define bCCKRxIG 0x7f00 +#define bCCKLNAPolarity 0x800000 +#define bCCKRx1stGain 0x7f0000 +#define bCCKRFExtend 0x20000000 /* CCK Rx init gain polar */ +#define bCCKRxAGCSatLevel 0x1f000000 +#define bCCKRxAGCSatCount 0xe0 +#define bCCKRxRFSettle 0x1f /* AGCsamp_dly */ +#define bCCKFixedRxAGC 0x8000 +#define bCCKAntennaPolarity 0x2000 +#define bCCKTxFilterType 0x0c00 +#define bCCKRxAGCReportType 0x0300 +#define bCCKRxDAGCEn 0x80000000 +#define bCCKRxDAGCPeriod 0x20000000 +#define bCCKRxDAGCSatLevel 0x1f000000 +#define bCCKTimingRecovery 0x800000 +#define bCCKTxC0 0x3f0000 +#define bCCKTxC1 0x3f000000 +#define bCCKTxC2 0x3f +#define bCCKTxC3 0x3f00 +#define bCCKTxC4 0x3f0000 +#define bCCKTxC5 0x3f000000 +#define bCCKTxC6 0x3f +#define bCCKTxC7 0x3f00 +#define bCCKDebugPort 0xff0000 +#define bCCKDACDebug 0x0f000000 +#define bCCKFalseAlarmEnable 0x8000 +#define bCCKFalseAlarmRead 0x4000 +#define bCCKTRSSI 0x7f +#define bCCKRxAGCReport 0xfe +#define bCCKRxReport_AntSel 0x80000000 +#define bCCKRxReport_MFOff 0x40000000 +#define bCCKRxRxReport_SQLoss 0x20000000 +#define bCCKRxReport_Pktloss 0x10000000 +#define bCCKRxReport_Lockedbit 0x08000000 +#define bCCKRxReport_RateError 0x04000000 +#define bCCKRxReport_RxRate 0x03000000 +#define bCCKRxFACounterLower 0xff +#define bCCKRxFACounterUpper 0xff000000 +#define bCCKRxHPAGCStart 0xe000 +#define bCCKRxHPAGCFinal 0x1c00 +#define bCCKRxFalseAlarmEnable 0x8000 +#define bCCKFACounterFreeze 0x4000 +#define bCCKTxPathSel 0x10000000 +#define bCCKDefaultRxPath 0xc000000 +#define bCCKOptionRxPath 0x3000000 + +/* 5. PageC(0xC00) */ +#define bNumOfSTF 0x3 /* Useless */ +#define bShift_L 0xc0 +#define bGI_TH 0xc +#define bRxPathA 0x1 +#define bRxPathB 0x2 +#define bRxPathC 0x4 +#define bRxPathD 0x8 +#define bTxPathA 0x1 +#define bTxPathB 0x2 +#define bTxPathC 0x4 +#define bTxPathD 0x8 +#define bTRSSIFreq 0x200 +#define bADCBackoff 0x3000 +#define bDFIRBackoff 0xc000 +#define bTRSSILatchPhase 0x10000 +#define bRxIDCOffset 0xff +#define bRxQDCOffset 0xff00 +#define bRxDFIRMode 0x1800000 +#define bRxDCNFType 0xe000000 +#define bRXIQImb_A 0x3ff +#define bRXIQImb_B 0xfc00 +#define bRXIQImb_C 0x3f0000 +#define bRXIQImb_D 0xffc00000 +#define bDC_dc_Notch 0x60000 +#define bRxNBINotch 0x1f000000 +#define bPD_TH 0xf +#define bPD_TH_Opt2 0xc000 +#define bPWED_TH 0x700 +#define bIfMF_Win_L 0x800 +#define bPD_Option 0x1000 +#define bMF_Win_L 0xe000 +#define bBW_Search_L 0x30000 +#define bwin_enh_L 0xc0000 +#define bBW_TH 0x700000 +#define bED_TH2 0x3800000 +#define bBW_option 0x4000000 +#define bRatio_TH 0x18000000 +#define bWindow_L 0xe0000000 +#define bSBD_Option 0x1 +#define bFrame_TH 0x1c +#define bFS_Option 0x60 +#define bDC_Slope_check 0x80 +#define bFGuard_Counter_DC_L 0xe00 +#define bFrame_Weight_Short 0x7000 +#define bSub_Tune 0xe00000 +#define bFrame_DC_Length 0xe000000 +#define bSBD_start_offset 0x30000000 +#define bFrame_TH_2 0x7 +#define bFrame_GI2_TH 0x38 +#define bGI2_Sync_en 0x40 +#define bSarch_Short_Early 0x300 +#define bSarch_Short_Late 0xc00 +#define bSarch_GI2_Late 0x70000 +#define bCFOAntSum 0x1 +#define bCFOAcc 0x2 +#define bCFOStartOffset 0xc +#define bCFOLookBack 0x70 +#define bCFOSumWeight 0x80 +#define bDAGCEnable 0x10000 +#define bTXIQImb_A 0x3ff +#define bTXIQImb_B 0xfc00 +#define bTXIQImb_C 0x3f0000 +#define bTXIQImb_D 0xffc00000 +#define bTxIDCOffset 0xff +#define bTxQDCOffset 0xff00 +#define bTxDFIRMode 0x10000 +#define bTxPesudoNoiseOn 0x4000000 +#define bTxPesudoNoise_A 0xff +#define bTxPesudoNoise_B 0xff00 +#define bTxPesudoNoise_C 0xff0000 +#define bTxPesudoNoise_D 0xff000000 +#define bCCADropOption 0x20000 +#define bCCADropThres 0xfff00000 +#define bEDCCA_H 0xf +#define bEDCCA_L 0xf0 +#define bLambda_ED 0x300 +#define bRxInitialGain 0x7f +#define bRxAntDivEn 0x80 +#define bRxAGCAddressForLNA 0x7f00 +#define bRxHighPowerFlow 0x8000 +#define bRxAGCFreezeThres 0xc0000 +#define bRxFreezeStep_AGC1 0x300000 +#define bRxFreezeStep_AGC2 0xc00000 +#define bRxFreezeStep_AGC3 0x3000000 +#define bRxFreezeStep_AGC0 0xc000000 +#define bRxRssi_Cmp_En 0x10000000 +#define bRxQuickAGCEn 0x20000000 +#define bRxAGCFreezeThresMode 0x40000000 +#define bRxOverFlowCheckType 0x80000000 +#define bRxAGCShift 0x7f +#define bTRSW_Tri_Only 0x80 +#define bPowerThres 0x300 +#define bRxAGCEn 0x1 +#define bRxAGCTogetherEn 0x2 +#define bRxAGCMin 0x4 +#define bRxHP_Ini 0x7 +#define bRxHP_TRLNA 0x70 +#define bRxHP_RSSI 0x700 +#define bRxHP_BBP1 0x7000 +#define bRxHP_BBP2 0x70000 +#define bRxHP_BBP3 0x700000 +#define bRSSI_H 0x7f0000 /* thresh for hi power */ +#define bRSSI_Gen 0x7f000000 /* thresh for ant div */ +#define bRxSettle_TRSW 0x7 +#define bRxSettle_LNA 0x38 +#define bRxSettle_RSSI 0x1c0 +#define bRxSettle_BBP 0xe00 +#define bRxSettle_RxHP 0x7000 +#define bRxSettle_AntSW_RSSI 0x38000 +#define bRxSettle_AntSW 0xc0000 +#define bRxProcessTime_DAGC 0x300000 +#define bRxSettle_HSSI 0x400000 +#define bRxProcessTime_BBPPW 0x800000 +#define bRxAntennaPowerShift 0x3000000 +#define bRSSITableSelect 0xc000000 +#define bRxHP_Final 0x7000000 +#define bRxHTSettle_BBP 0x7 +#define bRxHTSettle_HSSI 0x8 +#define bRxHTSettle_RxHP 0x70 +#define bRxHTSettle_BBPPW 0x80 +#define bRxHTSettle_Idle 0x300 +#define bRxHTSettle_Reserved 0x1c00 +#define bRxHTRxHPEn 0x8000 +#define bRxHTAGCFreezeThres 0x30000 +#define bRxHTAGCTogetherEn 0x40000 +#define bRxHTAGCMin 0x80000 +#define bRxHTAGCEn 0x100000 +#define bRxHTDAGCEn 0x200000 +#define bRxHTRxHP_BBP 0x1c00000 +#define bRxHTRxHP_Final 0xe0000000 +#define bRxPWRatioTH 0x3 +#define bRxPWRatioEn 0x4 +#define bRxMFHold 0x3800 +#define bRxPD_Delay_TH1 0x38 +#define bRxPD_Delay_TH2 0x1c0 +#define bRxPD_DC_COUNT_MAX 0x600 +/* define bRxMF_Hold 0x3800 */ +#define bRxPD_Delay_TH 0x8000 +#define bRxProcess_Delay 0xf0000 +#define bRxSearchrange_GI2_Early 0x700000 +#define bRxFrame_Guard_Counter_L 0x3800000 +#define bRxSGI_Guard_L 0xc000000 +#define bRxSGI_Search_L 0x30000000 +#define bRxSGI_TH 0xc0000000 +#define bDFSCnt0 0xff +#define bDFSCnt1 0xff00 +#define bDFSFlag 0xf0000 +#define bMFWeightSum 0x300000 +#define bMinIdxTH 0x7f000000 +#define bDAFormat 0x40000 +#define bTxChEmuEnable 0x01000000 +#define bTRSWIsolation_A 0x7f +#define bTRSWIsolation_B 0x7f00 +#define bTRSWIsolation_C 0x7f0000 +#define bTRSWIsolation_D 0x7f000000 +#define bExtLNAGain 0x7c00 + +/* 6. PageE(0xE00) */ +#define bSTBCEn 0x4 /* Useless */ +#define bAntennaMapping 0x10 +#define bNss 0x20 +#define bCFOAntSumD 0x200 +#define bPHYCounterReset 0x8000000 +#define bCFOReportGet 0x4000000 +#define bOFDMContinueTx 0x10000000 +#define bOFDMSingleCarrier 0x20000000 +#define bOFDMSingleTone 0x40000000 +/* define bRxPath1 0x01 */ +/* define bRxPath2 0x02 */ +/* define bRxPath3 0x04 */ +/* define bRxPath4 0x08 */ +/* define bTxPath1 0x10 */ +/* define bTxPath2 0x20 */ +#define bHTDetect 0x100 +#define bCFOEn 0x10000 +#define bCFOValue 0xfff00000 +#define bSigTone_Re 0x3f +#define bSigTone_Im 0x7f00 +#define bCounter_CCA 0xffff +#define bCounter_ParityFail 0xffff0000 +#define bCounter_RateIllegal 0xffff +#define bCounter_CRC8Fail 0xffff0000 +#define bCounter_MCSNoSupport 0xffff +#define bCounter_FastSync 0xffff +#define bShortCFO 0xfff +#define bShortCFOTLength 12 /* total */ +#define bShortCFOFLength 11 /* fraction */ +#define bLongCFO 0x7ff +#define bLongCFOTLength 11 +#define bLongCFOFLength 11 +#define bTailCFO 0x1fff +#define bTailCFOTLength 13 +#define bTailCFOFLength 12 +#define bmax_en_pwdB 0xffff +#define bCC_power_dB 0xffff0000 +#define bnoise_pwdB 0xffff +#define bPowerMeasTLength 10 +#define bPowerMeasFLength 3 +#define bRx_HT_BW 0x1 +#define bRxSC 0x6 +#define bRx_HT 0x8 +#define bNB_intf_det_on 0x1 +#define bIntf_win_len_cfg 0x30 +#define bNB_Intf_TH_cfg 0x1c0 +#define bRFGain 0x3f +#define bTableSel 0x40 +#define bTRSW 0x80 +#define bRxSNR_A 0xff +#define bRxSNR_B 0xff00 +#define bRxSNR_C 0xff0000 +#define bRxSNR_D 0xff000000 +#define bSNREVMTLength 8 +#define bSNREVMFLength 1 +#define bCSI1st 0xff +#define bCSI2nd 0xff00 +#define bRxEVM1st 0xff0000 +#define bRxEVM2nd 0xff000000 +#define bSIGEVM 0xff +#define bPWDB 0xff00 +#define bSGIEN 0x10000 + +#define bSFactorQAM1 0xf /* Useless */ +#define bSFactorQAM2 0xf0 +#define bSFactorQAM3 0xf00 +#define bSFactorQAM4 0xf000 +#define bSFactorQAM5 0xf0000 +#define bSFactorQAM6 0xf0000 +#define bSFactorQAM7 0xf00000 +#define bSFactorQAM8 0xf000000 +#define bSFactorQAM9 0xf0000000 +#define bCSIScheme 0x100000 + +#define bNoiseLvlTopSet 0x3 /* Useless */ +#define bChSmooth 0x4 +#define bChSmoothCfg1 0x38 +#define bChSmoothCfg2 0x1c0 +#define bChSmoothCfg3 0xe00 +#define bChSmoothCfg4 0x7000 +#define bMRCMode 0x800000 +#define bTHEVMCfg 0x7000000 + +#define bLoopFitType 0x1 /* Useless */ +#define bUpdCFO 0x40 +#define bUpdCFOOffData 0x80 +#define bAdvUpdCFO 0x100 +#define bAdvTimeCtrl 0x800 +#define bUpdClko 0x1000 +#define bFC 0x6000 +#define bTrackingMode 0x8000 +#define bPhCmpEnable 0x10000 +#define bUpdClkoLTF 0x20000 +#define bComChCFO 0x40000 +#define bCSIEstiMode 0x80000 +#define bAdvUpdEqz 0x100000 +#define bUChCfg 0x7000000 +#define bUpdEqz 0x8000000 + +#define bTxAGCRate18_06 0x7f7f7f7f /* Useless */ +#define bTxAGCRate54_24 0x7f7f7f7f +#define bTxAGCRateMCS32 0x7f +#define bTxAGCRateCCK 0x7f00 +#define bTxAGCRateMCS3_MCS0 0x7f7f7f7f +#define bTxAGCRateMCS7_MCS4 0x7f7f7f7f +#define bTxAGCRateMCS11_MCS8 0x7f7f7f7f +#define bTxAGCRateMCS15_MCS12 0x7f7f7f7f + +/* Rx Pseduo noise */ +#define bRxPesudoNoiseOn 0x20000000 /* Useless */ +#define bRxPesudoNoise_A 0xff +#define bRxPesudoNoise_B 0xff00 +#define bRxPesudoNoise_C 0xff0000 +#define bRxPesudoNoise_D 0xff000000 +#define bPesudoNoiseState_A 0xffff +#define bPesudoNoiseState_B 0xffff0000 +#define bPesudoNoiseState_C 0xffff +#define bPesudoNoiseState_D 0xffff0000 + +/* 7. RF Register */ +/* Zebra1 */ +#define bZebra1_HSSIEnable 0x8 /* Useless */ +#define bZebra1_TRxControl 0xc00 +#define bZebra1_TRxGainSetting 0x07f +#define bZebra1_RxCorner 0xc00 +#define bZebra1_TxChargePump 0x38 +#define bZebra1_RxChargePump 0x7 +#define bZebra1_ChannelNum 0xf80 +#define bZebra1_TxLPFBW 0x400 +#define bZebra1_RxLPFBW 0x600 + +/* Zebra4 */ +#define bRTL8256RegModeCtrl1 0x100 /* Useless */ +#define bRTL8256RegModeCtrl0 0x40 +#define bRTL8256_TxLPFBW 0x18 +#define bRTL8256_RxLPFBW 0x600 + +/* RTL8258 */ +#define bRTL8258_TxLPFBW 0xc /* Useless */ +#define bRTL8258_RxLPFBW 0xc00 +#define bRTL8258_RSSILPFBW 0xc0 + + +/* */ +/* Other Definition */ +/* */ + +/* byte endable for sb_write */ +#define bByte0 0x1 /* Useless */ +#define bByte1 0x2 +#define bByte2 0x4 +#define bByte3 0x8 +#define bWord0 0x3 +#define bWord1 0xc +#define bDWord 0xf + +/* for PutRegsetting & GetRegSetting BitMask */ +#define bMaskByte0 0xff /* Reg 0xc50 rOFDM0_XAAGCCore~0xC6f */ +#define bMaskByte1 0xff00 +#define bMaskByte2 0xff0000 +#define bMaskByte3 0xff000000 +#define bMaskHWord 0xffff0000 +#define bMaskLWord 0x0000ffff +#define bMaskDWord 0xffffffff +#define bMaskH4Bits 0xf0000000 +#define bMaskOFDM_D 0xffc00000 +#define bMaskCCK 0x3f3f3f3f +#define bMask12Bits 0xfff + +/* for PutRFRegsetting & GetRFRegSetting BitMask */ +#if (RTL92SE_FPGA_VERIFY == 1) +#define bRFRegOffsetMask 0xfff +#else +#define bRFRegOffsetMask 0xfffff +#endif +#define bEnable 0x1 /* Useless */ +#define bDisabl 0x0 + +#define LeftAntenna 0x0 /* Useless */ +#define RightAntenna 0x1 + +#define tCheckTxStatus 500 /* 500ms Useless */ +#define tUpdateRxCounter 100 /* 100ms */ + +#define rateCCK 0 /* Useless */ +#define rateOFDM 1 +#define rateHT 2 + +/* define Register-End */ +#define bPMAC_End 0x1ff /* Useless */ +#define bFPGAPHY0_End 0x8ff +#define bFPGAPHY1_End 0x9ff +#define bCCKPHY0_End 0xaff +#define bOFDMPHY0_End 0xcff +#define bOFDMPHY1_End 0xdff + +/* define max debug item in each debug page */ +/* define bMaxItem_FPGA_PHY0 0x9 */ +/* define bMaxItem_FPGA_PHY1 0x3 */ +/* define bMaxItem_PHY_11B 0x16 */ +/* define bMaxItem_OFDM_PHY0 0x29 */ +/* define bMaxItem_OFDM_PHY1 0x0 */ + +#define bPMACControl 0x0 /* Useless */ +#define bWMACControl 0x1 +#define bWNICControl 0x2 + +#define RCR_AAP BIT(0) /* accept all physical address */ +#define RCR_APM BIT(1) /* accept physical match */ +#define RCR_AM BIT(2) /* accept multicast */ +#define RCR_AB BIT(3) /* accept broadcast */ +#define RCR_ACRC32 BIT(5) /* accept error packet */ +#define RCR_9356SEL BIT(6) +#define RCR_AICV BIT(12) /* Accept ICV error packet */ +#define RCR_RXFTH0 (BIT(13)|BIT(14)|BIT(15)) /* Rx FIFO threshold */ +#define RCR_ADF BIT(18) /* Accept Data(frame type) frame */ +#define RCR_ACF BIT(19) /* Accept control frame */ +#define RCR_AMF BIT(20) /* Accept management frame */ +#define RCR_ADD3 BIT(21) +#define RCR_APWRMGT BIT(22) /* Accept power management packet */ +#define RCR_CBSSID BIT(23) /* Accept BSSID match packet */ +#define RCR_ENMARP BIT(28) /* enable mac auto reset phy */ +#define RCR_EnCS1 BIT(29) /* enable carrier sense method 1 */ +#define RCR_EnCS2 BIT(30) /* enable carrier sense method 2 */ +#define RCR_OnlyErlPkt BIT(31) /* Rx Early mode is performed for + * packet size greater than 1536 */ + +/*--------------------------Define Parameters-------------------------------*/ + + +#endif /* __INC_HAL8192SPHYREG_H */ -- GitLab From fff3340fc0fa032034016662d3d047ae152f1f8d Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 21 Aug 2013 22:34:11 -0500 Subject: [PATCH 787/942] staging: r8188eu: Add files for new driver - part 29 This commit adds files include/rtw_p2p.h, include/rtw_pwrctrl.h, include/rtw_qos.h, include/rtw_recv.h, and include/rtw_rf.h. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/rtw_p2p.h | 135 +++++ .../staging/rtl8188eu/include/rtw_pwrctrl.h | 283 ++++++++++ drivers/staging/rtl8188eu/include/rtw_qos.h | 30 ++ drivers/staging/rtl8188eu/include/rtw_recv.h | 485 ++++++++++++++++++ drivers/staging/rtl8188eu/include/rtw_rf.h | 146 ++++++ 5 files changed, 1079 insertions(+) create mode 100644 drivers/staging/rtl8188eu/include/rtw_p2p.h create mode 100644 drivers/staging/rtl8188eu/include/rtw_pwrctrl.h create mode 100644 drivers/staging/rtl8188eu/include/rtw_qos.h create mode 100644 drivers/staging/rtl8188eu/include/rtw_recv.h create mode 100644 drivers/staging/rtl8188eu/include/rtw_rf.h diff --git a/drivers/staging/rtl8188eu/include/rtw_p2p.h b/drivers/staging/rtl8188eu/include/rtw_p2p.h new file mode 100644 index 0000000000000..a3e3adc92b99f --- /dev/null +++ b/drivers/staging/rtl8188eu/include/rtw_p2p.h @@ -0,0 +1,135 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __RTW_P2P_H_ +#define __RTW_P2P_H_ + +#include + +u32 build_beacon_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf); +u32 build_probe_resp_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf); +u32 build_prov_disc_request_p2p_ie(struct wifidirect_info *pwdinfo, + u8 *pbuf, u8 *pssid, u8 ussidlen, + u8 *pdev_raddr); +u32 build_assoc_resp_p2p_ie(struct wifidirect_info *pwdinfo, + u8 *pbuf, u8 status_code); +u32 build_deauth_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf); +u32 process_probe_req_p2p_ie(struct wifidirect_info *pwdinfo, + u8 *pframe, uint len); +u32 process_assoc_req_p2p_ie(struct wifidirect_info *pwdinfo, + u8 *pframe, uint len, struct sta_info *psta); +u32 process_p2p_devdisc_req(struct wifidirect_info *pwdinfo, + u8 *pframe, uint len); +u32 process_p2p_devdisc_resp(struct wifidirect_info *pwdinfo, + u8 *pframe, uint len); +u8 process_p2p_provdisc_req(struct wifidirect_info *pwdinfo, + u8 *pframe, uint len); +u8 process_p2p_provdisc_resp(struct wifidirect_info *pwdinfo, u8 *pframe); +u8 process_p2p_group_negotation_req(struct wifidirect_info *pwdinfo, + u8 *pframe, uint len); +u8 process_p2p_group_negotation_resp(struct wifidirect_info *pwdinfo, + u8 *pframe, uint len); +u8 process_p2p_group_negotation_confirm(struct wifidirect_info *pwdinfo, + u8 *pframe, uint len); +u8 process_p2p_presence_req(struct wifidirect_info *pwdinfo, u8 *pframe, + uint len); +void p2p_protocol_wk_hdl(struct adapter *padapter, int intcmdtype); +void process_p2p_ps_ie(struct adapter *padapter, u8 *ies, u32 ielength); +void p2p_ps_wk_hdl(struct adapter *padapter, u8 p2p_ps_state); +u8 p2p_ps_wk_cmd(struct adapter *padapter, u8 p2p_ps_state, u8 enqueue); +void reset_global_wifidirect_info(struct adapter *padapter); +int rtw_init_wifi_display_info(struct adapter *padapter); +void rtw_init_wifidirect_timers(struct adapter *padapter); +void rtw_init_wifidirect_addrs(struct adapter *padapter, u8 *dev_addr, + u8 *iface_addr); +void init_wifidirect_info(struct adapter *padapter, enum P2P_ROLE role); +int rtw_p2p_enable(struct adapter *padapter, enum P2P_ROLE role); + +static inline void _rtw_p2p_set_state(struct wifidirect_info *wdinfo, + enum P2P_STATE state) +{ + if (wdinfo->p2p_state != state) + wdinfo->p2p_state = state; +} + +static inline void _rtw_p2p_set_pre_state(struct wifidirect_info *wdinfo, + enum P2P_STATE state) +{ + if (wdinfo->pre_p2p_state != state) + wdinfo->pre_p2p_state = state; +} + +static inline void _rtw_p2p_set_role(struct wifidirect_info *wdinfo, + enum P2P_ROLE role) +{ + if (wdinfo->role != role) + wdinfo->role = role; +} + +static inline int _rtw_p2p_state(struct wifidirect_info *wdinfo) +{ + return wdinfo->p2p_state; +} + +static inline int _rtw_p2p_pre_state(struct wifidirect_info *wdinfo) +{ + return wdinfo->pre_p2p_state; +} + +static inline int _rtw_p2p_role(struct wifidirect_info *wdinfo) +{ + return wdinfo->role; +} + +static inline bool _rtw_p2p_chk_state(struct wifidirect_info *wdinfo, + enum P2P_STATE state) +{ + return wdinfo->p2p_state == state; +} + +static inline bool _rtw_p2p_chk_role(struct wifidirect_info *wdinfo, + enum P2P_ROLE role) +{ + return wdinfo->role == role; +} + +#define rtw_p2p_set_state(wdinfo, state) _rtw_p2p_set_state(wdinfo, state) +#define rtw_p2p_set_pre_state(wdinfo, state) \ + _rtw_p2p_set_pre_state(wdinfo, state) +#define rtw_p2p_set_role(wdinfo, role) _rtw_p2p_set_role(wdinfo, role) + +#define rtw_p2p_state(wdinfo) _rtw_p2p_state(wdinfo) +#define rtw_p2p_pre_state(wdinfo) _rtw_p2p_pre_state(wdinfo) +#define rtw_p2p_role(wdinfo) _rtw_p2p_role(wdinfo) +#define rtw_p2p_chk_state(wdinfo, state) _rtw_p2p_chk_state(wdinfo, state) +#define rtw_p2p_chk_role(wdinfo, role) _rtw_p2p_chk_role(wdinfo, role) + +#define rtw_p2p_findphase_ex_set(wdinfo, value) \ + ((wdinfo)->find_phase_state_exchange_cnt = (value)) + +/* is this find phase exchange for social channel scan? */ +#define rtw_p2p_findphase_ex_is_social(wdinfo) \ +((wdinfo)->find_phase_state_exchange_cnt >= P2P_FINDPHASE_EX_SOCIAL_FIRST) + +/* should we need find phase exchange anymore? */ +#define rtw_p2p_findphase_ex_is_needed(wdinfo) \ + ((wdinfo)->find_phase_state_exchange_cnt < P2P_FINDPHASE_EX_MAX && \ + (wdinfo)->find_phase_state_exchange_cnt != P2P_FINDPHASE_EX_NONE) + +#endif diff --git a/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h b/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h new file mode 100644 index 0000000000000..d4b8acb8025b3 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h @@ -0,0 +1,283 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __RTW_PWRCTRL_H_ +#define __RTW_PWRCTRL_H_ + +#include +#include + +#define FW_PWR0 0 +#define FW_PWR1 1 +#define FW_PWR2 2 +#define FW_PWR3 3 +#define HW_PWR0 7 +#define HW_PWR1 6 +#define HW_PWR2 2 +#define HW_PWR3 0 +#define HW_PWR4 8 + +#define FW_PWRMSK 0x7 + +#define XMIT_ALIVE BIT(0) +#define RECV_ALIVE BIT(1) +#define CMD_ALIVE BIT(2) +#define EVT_ALIVE BIT(3) + +enum power_mgnt { + PS_MODE_ACTIVE = 0, + PS_MODE_MIN, + PS_MODE_MAX, + PS_MODE_DTIM, + PS_MODE_VOIP, + PS_MODE_UAPSD_WMM, + PS_MODE_UAPSD, + PS_MODE_IBSS, + PS_MODE_WWLAN, + PM_Radio_Off, + PM_Card_Disable, + PS_MODE_NUM +}; + +/* + BIT[2:0] = HW state + BIT[3] = Protocol PS state, 0: register active state, + 1: register sleep state + BIT[4] = sub-state +*/ + +#define PS_DPS BIT(0) +#define PS_LCLK (PS_DPS) +#define PS_RF_OFF BIT(1) +#define PS_ALL_ON BIT(2) +#define PS_ST_ACTIVE BIT(3) + +#define PS_ISR_ENABLE BIT(4) +#define PS_IMR_ENABLE BIT(5) +#define PS_ACK BIT(6) +#define PS_TOGGLE BIT(7) + +#define PS_STATE_MASK (0x0F) +#define PS_STATE_HW_MASK (0x07) +#define PS_SEQ_MASK (0xc0) + +#define PS_STATE(x) (PS_STATE_MASK & (x)) +#define PS_STATE_HW(x) (PS_STATE_HW_MASK & (x)) +#define PS_SEQ(x) (PS_SEQ_MASK & (x)) + +#define PS_STATE_S0 (PS_DPS) +#define PS_STATE_S1 (PS_LCLK) +#define PS_STATE_S2 (PS_RF_OFF) +#define PS_STATE_S3 (PS_ALL_ON) +#define PS_STATE_S4 ((PS_ST_ACTIVE) | (PS_ALL_ON)) + +#define PS_IS_RF_ON(x) ((x) & (PS_ALL_ON)) +#define PS_IS_ACTIVE(x) ((x) & (PS_ST_ACTIVE)) +#define CLR_PS_STATE(x) ((x) = ((x) & (0xF0))) + +struct reportpwrstate_parm { + unsigned char mode; + unsigned char state; /* the CPWM value */ + unsigned short rsvd; +}; + +static inline void _init_pwrlock(struct semaphore *plock) +{ + _rtw_init_sema(plock, 1); +} + +static inline void _free_pwrlock(struct semaphore *plock) +{ + _rtw_free_sema(plock); +} + +static inline void _enter_pwrlock(struct semaphore *plock) +{ + _rtw_down_sema(plock); +} + +static inline void _exit_pwrlock(struct semaphore *plock) +{ + _rtw_up_sema(plock); +} + +#define LPS_DELAY_TIME 1*HZ /* 1 sec */ + +#define EXE_PWR_NONE 0x01 +#define EXE_PWR_IPS 0x02 +#define EXE_PWR_LPS 0x04 + +/* RF state. */ +enum rt_rf_power_state { + rf_on, /* RF is on after RFSleep or RFOff */ + rf_sleep, /* 802.11 Power Save mode */ + rf_off, /* HW/SW Radio OFF or Inactive Power Save */ + /* Add the new RF state above this line===== */ + rf_max +}; + +/* RF Off Level for IPS or HW/SW radio off */ +#define RT_RF_OFF_LEVL_ASPM BIT(0) /* PCI ASPM */ +#define RT_RF_OFF_LEVL_CLK_REQ BIT(1) /* PCI clock request */ +#define RT_RF_OFF_LEVL_PCI_D3 BIT(2) /* PCI D3 mode */ +#define RT_RF_OFF_LEVL_HALT_NIC BIT(3) /* NIC halt, re-init hw param*/ +#define RT_RF_OFF_LEVL_FREE_FW BIT(4) /* FW free, re-download the FW*/ +#define RT_RF_OFF_LEVL_FW_32K BIT(5) /* FW in 32k */ +#define RT_RF_PS_LEVEL_ALWAYS_ASPM BIT(6) /* Always enable ASPM and Clock + * Req in initialization. */ +#define RT_RF_LPS_DISALBE_2R BIT(30) /* When LPS is on, disable 2R + * if no packet is RX or TX. */ +#define RT_RF_LPS_LEVEL_ASPM BIT(31) /* LPS with ASPM */ + +#define RT_IN_PS_LEVEL(ppsc, _PS_FLAG) \ + ((ppsc->cur_ps_level & _PS_FLAG) ? true : false) +#define RT_CLEAR_PS_LEVEL(ppsc, _PS_FLAG) \ + (ppsc->cur_ps_level &= (~(_PS_FLAG))) +#define RT_SET_PS_LEVEL(ppsc, _PS_FLAG) \ + (ppsc->cur_ps_level |= _PS_FLAG) + +enum _PS_BBRegBackup_ { + PSBBREG_RF0 = 0, + PSBBREG_RF1, + PSBBREG_RF2, + PSBBREG_AFE0, + PSBBREG_TOTALCNT +}; + +enum { /* for ips_mode */ + IPS_NONE = 0, + IPS_NORMAL, + IPS_LEVEL_2, +}; + +struct pwrctrl_priv { + struct semaphore lock; + volatile u8 rpwm; /* requested power state for fw */ + volatile u8 cpwm; /* fw current power state. updated when + * 1. read from HCPWM 2. driver lowers power level */ + volatile u8 tog; /* toggling */ + volatile u8 cpwm_tog; /* toggling */ + + u8 pwr_mode; + u8 smart_ps; + u8 bcn_ant_mode; + + u32 alives; + struct work_struct cpwm_event; + u8 bpower_saving; + + u8 b_hw_radio_off; + u8 reg_rfoff; + u8 reg_pdnmode; /* powerdown mode */ + u32 rfoff_reason; + + /* RF OFF Level */ + u32 cur_ps_level; + u32 reg_rfps_level; + uint ips_enter_cnts; + uint ips_leave_cnts; + + u8 ips_mode; + u8 ips_mode_req; /* used to accept the mode setting request, + * will update to ipsmode later */ + uint bips_processing; + u32 ips_deny_time; /* will deny IPS when system time less than this */ + u8 ps_processing; /* temp used to mark whether in rtw_ps_processor */ + + u8 bLeisurePs; + u8 LpsIdleCount; + u8 power_mgnt; + u8 bFwCurrentInPSMode; + u32 DelayLPSLastTimeStamp; + u8 btcoex_rfon; + s32 pnp_current_pwr_state; + u8 pnp_bstop_trx; + + u8 bInternalAutoSuspend; + u8 bInSuspend; +#ifdef CONFIG_BT_COEXIST + u8 bAutoResume; + u8 autopm_cnt; +#endif + u8 bSupportRemoteWakeup; + struct timer_list pwr_state_check_timer; + int pwr_state_check_interval; + u8 pwr_state_check_cnts; + + int ps_flag; + + enum rt_rf_power_state rf_pwrstate;/* cur power state */ + enum rt_rf_power_state change_rfpwrstate; + + u8 wepkeymask; + u8 bHWPowerdown;/* if support hw power down */ + u8 bHWPwrPindetect; + u8 bkeepfwalive; + u8 brfoffbyhw; + unsigned long PS_BBRegBackup[PSBBREG_TOTALCNT]; +}; + +#define rtw_get_ips_mode_req(pwrctrlpriv) \ + (pwrctrlpriv)->ips_mode_req + +#define rtw_ips_mode_req(pwrctrlpriv, ips_mode) \ + ((pwrctrlpriv)->ips_mode_req = (ips_mode)) + +#define RTW_PWR_STATE_CHK_INTERVAL 2000 + +#define _rtw_set_pwr_state_check_timer(pwrctrlpriv, ms) \ + do { \ + _set_timer(&(pwrctrlpriv)->pwr_state_check_timer, (ms)); \ + } while (0) + +#define rtw_set_pwr_state_check_timer(pwrctrl) \ + _rtw_set_pwr_state_check_timer((pwrctrl), \ + (pwrctrl)->pwr_state_check_interval) + +void rtw_init_pwrctrl_priv(struct adapter *adapter); +void rtw_free_pwrctrl_priv(struct adapter *adapter); + +void rtw_set_ps_mode(struct adapter *adapter, u8 ps_mode, u8 smart_ps, + u8 bcn_ant_mode); +void rtw_set_rpwm(struct adapter *adapter, u8 val8); +void LeaveAllPowerSaveMode(struct adapter *adapter); +void ips_enter(struct adapter *padapter); +int ips_leave(struct adapter *padapter); + +void rtw_ps_processor(struct adapter *padapter); + +enum rt_rf_power_state RfOnOffDetect(struct adapter *iadapter); + +s32 LPS_RF_ON_check(struct adapter *adapter, u32 delay_ms); +void LPS_Enter(struct adapter *adapter); +void LPS_Leave(struct adapter *adapter); + +u8 rtw_interface_ps_func(struct adapter *adapter, + enum hal_intf_ps_func efunc_id, u8 *val); +void rtw_set_ips_deny(struct adapter *adapter, u32 ms); +int _rtw_pwr_wakeup(struct adapter *adapter, u32 ips_defer_ms, + const char *caller); +#define rtw_pwr_wakeup(adapter) \ + _rtw_pwr_wakeup(adapter, RTW_PWR_STATE_CHK_INTERVAL, __func__) +#define rtw_pwr_wakeup_ex(adapter, ips_deffer_ms) \ + _rtw_pwr_wakeup(adapter, ips_deffer_ms, __func__) +int rtw_pm_set_ips(struct adapter *adapter, u8 mode); +int rtw_pm_set_lps(struct adapter *adapter, u8 mode); + +#endif /* __RTL871X_PWRCTRL_H_ */ diff --git a/drivers/staging/rtl8188eu/include/rtw_qos.h b/drivers/staging/rtl8188eu/include/rtw_qos.h new file mode 100644 index 0000000000000..bbee1ddc00bbe --- /dev/null +++ b/drivers/staging/rtl8188eu/include/rtw_qos.h @@ -0,0 +1,30 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef _RTW_QOS_H_ +#define _RTW_QOS_H_ + +#include + +struct qos_priv { + unsigned int qos_option; /* bit mask option: u-apsd, + * s-apsd, ts, block ack... */ +}; + +#endif /* _RTL871X_QOS_H_ */ diff --git a/drivers/staging/rtl8188eu/include/rtw_recv.h b/drivers/staging/rtl8188eu/include/rtw_recv.h new file mode 100644 index 0000000000000..bae8885c57f92 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/rtw_recv.h @@ -0,0 +1,485 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef _RTW_RECV_H_ +#define _RTW_RECV_H_ + +#include +#include + + +#define NR_RECVFRAME 256 + +#define RXFRAME_ALIGN 8 +#define RXFRAME_ALIGN_SZ (1<signal_stat_timer, \ + (recvpriv)->signal_stat_sampling_interval) + +struct sta_recv_priv { + spinlock_t lock; + int option; + struct __queue defrag_q; /* keeping the fragment frame until defrag */ + struct stainfo_rxcache rxcache; +}; + +struct recv_buf { + struct list_head list; + spinlock_t recvbuf_lock; + u32 ref_cnt; + struct adapter *adapter; + u8 *pbuf; + u8 *pallocated_buf; + u32 len; + u8 *phead; + u8 *pdata; + u8 *ptail; + u8 *pend; + struct urb *purb; + dma_addr_t dma_transfer_addr; /* (in) dma addr for transfer_buffer */ + u32 alloc_sz; + u8 irp_pending; + int transfer_len; + struct sk_buff *pskb; + u8 reuse; +}; + +/* + head -----> + + data -----> + + payload + + tail -----> + + + end -----> + + len = (unsigned int )(tail - data); + +*/ +struct recv_frame_hdr { + struct list_head list; + struct sk_buff *pkt; + struct sk_buff *pkt_newalloc; + struct adapter *adapter; + u8 fragcnt; + int frame_tag; + struct rx_pkt_attrib attrib; + uint len; + u8 *rx_head; + u8 *rx_data; + u8 *rx_tail; + u8 *rx_end; + void *precvbuf; + struct sta_info *psta; + /* for A-MPDU Rx reordering buffer control */ + struct recv_reorder_ctrl *preorder_ctrl; +}; + +union recv_frame { + union { + struct list_head list; + struct recv_frame_hdr hdr; + uint mem[RECVFRAME_HDR_ALIGN>>2]; + } u; +}; + +union recv_frame *_rtw_alloc_recvframe(struct __queue *pfree_recv_queue); +union recv_frame *rtw_alloc_recvframe(struct __queue *pfree_recv_queue); +void rtw_init_recvframe(union recv_frame *precvframe, + struct recv_priv *precvpriv); +int rtw_free_recvframe(union recv_frame *precvframe, + struct __queue *pfree_recv_queue); +#define rtw_dequeue_recvframe(queue) rtw_alloc_recvframe(queue) +int _rtw_enqueue_recvframe(union recv_frame *precvframe, struct __queue *queue); +int rtw_enqueue_recvframe(union recv_frame *precvframe, struct __queue *queue); +void rtw_free_recvframe_queue(struct __queue *pframequeue, + struct __queue *pfree_recv_queue); +u32 rtw_free_uc_swdec_pending_queue(struct adapter *adapter); +int rtw_enqueue_recvbuf_to_head(struct recv_buf *buf, struct __queue *queue); +int rtw_enqueue_recvbuf(struct recv_buf *precvbuf, struct __queue *queue); +struct recv_buf *rtw_dequeue_recvbuf(struct __queue *queue); + +void rtw_reordering_ctrl_timeout_handler(void *pcontext); + +static inline u8 *get_rxmem(union recv_frame *precvframe) +{ + /* always return rx_head... */ + if (precvframe == NULL) + return NULL; + return precvframe->u.hdr.rx_head; +} + +static inline u8 *get_rx_status(union recv_frame *precvframe) +{ + return get_rxmem(precvframe); +} + +static inline u8 *get_recvframe_data(union recv_frame *precvframe) +{ + /* always return rx_data */ + if (precvframe == NULL) + return NULL; + + return precvframe->u.hdr.rx_data; +} + +static inline u8 *recvframe_push(union recv_frame *precvframe, int sz) +{ + /* append data before rx_data */ + + /* add data to the start of recv_frame + * + * This function extends the used data area of the recv_frame at the buffer + * start. rx_data must be still larger than rx_head, after pushing. + */ + if (precvframe == NULL) + return NULL; + precvframe->u.hdr.rx_data -= sz ; + if (precvframe->u.hdr.rx_data < precvframe->u.hdr.rx_head) { + precvframe->u.hdr.rx_data += sz; + return NULL; + } + precvframe->u.hdr.len += sz; + return precvframe->u.hdr.rx_data; +} + +static inline u8 *recvframe_pull(union recv_frame *precvframe, int sz) +{ + /* rx_data += sz; move rx_data sz bytes hereafter */ + + /* used for extract sz bytes from rx_data, update rx_data and return + * the updated rx_data to the caller */ + + if (precvframe == NULL) + return NULL; + precvframe->u.hdr.rx_data += sz; + if (precvframe->u.hdr.rx_data > precvframe->u.hdr.rx_tail) { + precvframe->u.hdr.rx_data -= sz; + return NULL; + } + precvframe->u.hdr.len -= sz; + return precvframe->u.hdr.rx_data; +} + +static inline u8 *recvframe_put(union recv_frame *precvframe, int sz) +{ + /* used for append sz bytes from ptr to rx_tail, update rx_tail + * and return the updated rx_tail to the caller */ + /* after putting, rx_tail must be still larger than rx_end. */ + + if (precvframe == NULL) + return NULL; + + precvframe->u.hdr.rx_tail += sz; + + if (precvframe->u.hdr.rx_tail > precvframe->u.hdr.rx_end) { + precvframe->u.hdr.rx_tail -= sz; + return NULL; + } + precvframe->u.hdr.len += sz; + return precvframe->u.hdr.rx_tail; +} + +static inline u8 *recvframe_pull_tail(union recv_frame *precvframe, int sz) +{ + /* rmv data from rx_tail (by yitsen) */ + + /* used for extract sz bytes from rx_end, update rx_end and return + * the updated rx_end to the caller */ + /* after pulling, rx_end must be still larger than rx_data. */ + + if (precvframe == NULL) + return NULL; + precvframe->u.hdr.rx_tail -= sz; + if (precvframe->u.hdr.rx_tail < precvframe->u.hdr.rx_data) { + precvframe->u.hdr.rx_tail += sz; + return NULL; + } + precvframe->u.hdr.len -= sz; + return precvframe->u.hdr.rx_tail; +} + +static inline unsigned char *get_rxbuf_desc(union recv_frame *precvframe) +{ + unsigned char *buf_desc; + + if (precvframe == NULL) + return NULL; + return buf_desc; +} + +static inline union recv_frame *rxmem_to_recvframe(u8 *rxmem) +{ + /* due to the design of 2048 bytes alignment of recv_frame, + * we can reference the union recv_frame */ + /* from any given member of recv_frame. */ + /* rxmem indicates the any member/address in recv_frame */ + + return (union recv_frame *)(((size_t)rxmem >> RXFRAME_ALIGN) << RXFRAME_ALIGN); +} + +static inline union recv_frame *pkt_to_recvframe(struct sk_buff *pkt) +{ + u8 *buf_star; + union recv_frame *precv_frame; + precv_frame = rxmem_to_recvframe((unsigned char *)buf_star); + + return precv_frame; +} + +static inline u8 *pkt_to_recvmem(struct sk_buff *pkt) +{ + /* return the rx_head */ + + union recv_frame *precv_frame = pkt_to_recvframe(pkt); + + return precv_frame->u.hdr.rx_head; +} + +static inline u8 *pkt_to_recvdata(struct sk_buff *pkt) +{ + /* return the rx_data */ + + union recv_frame *precv_frame = pkt_to_recvframe(pkt); + + return precv_frame->u.hdr.rx_data; +} + +static inline int get_recvframe_len(union recv_frame *precvframe) +{ + return precvframe->u.hdr.len; +} + +static inline s32 translate_percentage_to_dbm(u32 sig_stren_index) +{ + s32 power; /* in dBm. */ + + /* Translate to dBm (x=0.5y-95). */ + power = (s32)((sig_stren_index + 1) >> 1); + power -= 95; + + return power; +} + + +struct sta_info; + +void _rtw_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv); + +void mgt_dispatcher(struct adapter *padapter, union recv_frame *precv_frame); + +#endif diff --git a/drivers/staging/rtl8188eu/include/rtw_rf.h b/drivers/staging/rtl8188eu/include/rtw_rf.h new file mode 100644 index 0000000000000..089ecee6c1f9e --- /dev/null +++ b/drivers/staging/rtl8188eu/include/rtw_rf.h @@ -0,0 +1,146 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __RTW_RF_H_ +#define __RTW_RF_H_ + +#include + +#define OFDM_PHY 1 +#define MIXED_PHY 2 +#define CCK_PHY 3 + +#define NumRates (13) + +/* slot time for 11g */ +#define SHORT_SLOT_TIME 9 +#define NON_SHORT_SLOT_TIME 20 + +#define RTL8711_RF_MAX_SENS 6 +#define RTL8711_RF_DEF_SENS 4 + +/* We now define the following channels as the max channels in each + * channel plan. */ +/* 2G, total 14 chnls */ +/* {1,2,3,4,5,6,7,8,9,10,11,12,13,14} */ +#define MAX_CHANNEL_NUM_2G 14 +#define MAX_CHANNEL_NUM 14 /* 2.4 GHz only */ + +#define NUM_REGULATORYS 1 + +/* Country codes */ +#define USA 0x555320 +#define EUROPE 0x1 /* temp, should be provided later */ +#define JAPAN 0x2 /* temp, should be provided later */ + +struct regulatory_class { + u32 starting_freq; /* MHz, */ + u8 channel_set[MAX_CHANNEL_NUM]; + u8 channel_cck_power[MAX_CHANNEL_NUM]; /* dbm */ + u8 channel_ofdm_power[MAX_CHANNEL_NUM]; /* dbm */ + u8 txpower_limit; /* dbm */ + u8 channel_spacing; /* MHz */ + u8 modem; +}; + +enum capability { + cESS = 0x0001, + cIBSS = 0x0002, + cPollable = 0x0004, + cPollReq = 0x0008, + cPrivacy = 0x0010, + cShortPreamble = 0x0020, + cPBCC = 0x0040, + cChannelAgility = 0x0080, + cSpectrumMgnt = 0x0100, + cQos = 0x0200, /* For HCCA, use with CF-Pollable + * and CF-PollReq */ + cShortSlotTime = 0x0400, + cAPSD = 0x0800, + cRM = 0x1000, /* RRM (Radio Request Measurement) */ + cDSSS_OFDM = 0x2000, + cDelayedBA = 0x4000, + cImmediateBA = 0x8000, +}; + +enum _REG_PREAMBLE_MODE { + PREAMBLE_LONG = 1, + PREAMBLE_AUTO = 2, + PREAMBLE_SHORT = 3, +}; + +enum _RTL8712_RF_MIMO_CONFIG_ { + RTL8712_RFCONFIG_1T = 0x10, + RTL8712_RFCONFIG_2T = 0x20, + RTL8712_RFCONFIG_1R = 0x01, + RTL8712_RFCONFIG_2R = 0x02, + RTL8712_RFCONFIG_1T1R = 0x11, + RTL8712_RFCONFIG_1T2R = 0x12, + RTL8712_RFCONFIG_TURBO = 0x92, + RTL8712_RFCONFIG_2T2R = 0x22 +}; + +enum rf90_radio_path { + RF90_PATH_A = 0, /* Radio Path A */ + RF90_PATH_B = 1, /* Radio Path B */ + RF90_PATH_C = 2, /* Radio Path C */ + RF90_PATH_D = 3 /* Radio Path D */ +}; + +/* Bandwidth Offset */ +#define HAL_PRIME_CHNL_OFFSET_DONT_CARE 0 +#define HAL_PRIME_CHNL_OFFSET_LOWER 1 +#define HAL_PRIME_CHNL_OFFSET_UPPER 2 + +/* Represent Channel Width in HT Capabilities */ +/* */ +enum ht_channel_width { + HT_CHANNEL_WIDTH_20 = 0, + HT_CHANNEL_WIDTH_40 = 1, + HT_CHANNEL_WIDTH_80 = 2, + HT_CHANNEL_WIDTH_160 = 3, + HT_CHANNEL_WIDTH_10 = 4, +}; + +/* */ +/* Represent Extention Channel Offset in HT Capabilities */ +/* This is available only in 40Mhz mode. */ +/* */ +enum ht_extchnl_offset { + HT_EXTCHNL_OFFSET_NO_EXT = 0, + HT_EXTCHNL_OFFSET_UPPER = 1, + HT_EXTCHNL_OFFSET_NO_DEF = 2, + HT_EXTCHNL_OFFSET_LOWER = 3, +}; + +/* 2007/11/15 MH Define different RF type. */ +enum rt_rf_type_def { + RF_1T2R = 0, + RF_2T4R = 1, + RF_2T2R = 2, + RF_1T1R = 3, + RF_2T2R_GREEN = 4, + RF_819X_MAX_TYPE = 5, +}; + +u32 rtw_ch2freq(u32 ch); +u32 rtw_freq2ch(u32 freq); + + +#endif /* _RTL8711_RF_H_ */ -- GitLab From 7f8a0fba8c345f538674410139a08d1037594c7a Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 21 Aug 2013 22:34:12 -0500 Subject: [PATCH 788/942] staging: r8188eu: Add files for new driver - part 30 This commit adds files include/rtw_security.h, include/rtw_sreset.h, include/rtw_version.h, and include/rtw_xmit.h. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8188eu/include/rtw_security.h | 383 +++++++++++++++++ .../staging/rtl8188eu/include/rtw_sreset.h | 50 +++ .../staging/rtl8188eu/include/rtw_version.h | 1 + drivers/staging/rtl8188eu/include/rtw_xmit.h | 384 ++++++++++++++++++ 4 files changed, 818 insertions(+) create mode 100644 drivers/staging/rtl8188eu/include/rtw_security.h create mode 100644 drivers/staging/rtl8188eu/include/rtw_sreset.h create mode 100644 drivers/staging/rtl8188eu/include/rtw_version.h create mode 100644 drivers/staging/rtl8188eu/include/rtw_xmit.h diff --git a/drivers/staging/rtl8188eu/include/rtw_security.h b/drivers/staging/rtl8188eu/include/rtw_security.h new file mode 100644 index 0000000000000..23c7814a50ed4 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/rtw_security.h @@ -0,0 +1,383 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __RTW_SECURITY_H_ +#define __RTW_SECURITY_H_ + +#include +#include + +#define _NO_PRIVACY_ 0x0 +#define _WEP40_ 0x1 +#define _TKIP_ 0x2 +#define _TKIP_WTMIC_ 0x3 +#define _AES_ 0x4 +#define _WEP104_ 0x5 +#define _WEP_WPA_MIXED_ 0x07 /* WEP + WPA */ +#define _SMS4_ 0x06 + +#define is_wep_enc(alg) (((alg) == _WEP40_) || ((alg) == _WEP104_)) + +#define _WPA_IE_ID_ 0xdd +#define _WPA2_IE_ID_ 0x30 + +#define SHA256_MAC_LEN 32 +#define AES_BLOCK_SIZE 16 +#define AES_PRIV_SIZE (4 * 44) + +enum { + ENCRYP_PROTOCOL_OPENSYS, /* open system */ + ENCRYP_PROTOCOL_WEP, /* WEP */ + ENCRYP_PROTOCOL_WPA, /* WPA */ + ENCRYP_PROTOCOL_WPA2, /* WPA2 */ + ENCRYP_PROTOCOL_WAPI, /* WAPI: Not support in this version */ + ENCRYP_PROTOCOL_MAX +}; + + +#ifndef Ndis802_11AuthModeWPA2 +#define Ndis802_11AuthModeWPA2 (Ndis802_11AuthModeWPANone + 1) +#endif + +#ifndef Ndis802_11AuthModeWPA2PSK +#define Ndis802_11AuthModeWPA2PSK (Ndis802_11AuthModeWPANone + 2) +#endif + +union pn48 { + u64 val; + +#ifdef __LITTLE_ENDIAN + struct { + u8 TSC0; + u8 TSC1; + u8 TSC2; + u8 TSC3; + u8 TSC4; + u8 TSC5; + u8 TSC6; + u8 TSC7; + } _byte_; + +#elif defined(__BIG_ENDIAN) + + struct { + u8 TSC7; + u8 TSC6; + u8 TSC5; + u8 TSC4; + u8 TSC3; + u8 TSC2; + u8 TSC1; + u8 TSC0; + } _byte_; +#endif +}; + +union Keytype { + u8 skey[16]; + u32 lkey[4]; +}; + +struct rt_pmkid_list { + u8 bUsed; + u8 Bssid[6]; + u8 PMKID[16]; + u8 SsidBuf[33]; + u8 *ssid_octet; + u16 ssid_length; +}; + +struct security_priv { + u32 dot11AuthAlgrthm; /* 802.11 auth, could be open, + * shared, 8021x and authswitch */ + u32 dot11PrivacyAlgrthm; /* This specify the privacy for + * shared auth. algorithm. */ + /* WEP */ + u32 dot11PrivacyKeyIndex; /* this is only valid for legendary + * wep, 0~3 for key id.(tx key index) */ + union Keytype dot11DefKey[4]; /* this is only valid for def. key */ + u32 dot11DefKeylen[4]; + u32 dot118021XGrpPrivacy; /* This specify the privacy algthm. + * used for Grp key */ + u32 dot118021XGrpKeyid; /* key id used for Grp Key + * ( tx key index) */ + union Keytype dot118021XGrpKey[4]; /* 802.1x Group Key, + * for inx0 and inx1 */ + union Keytype dot118021XGrptxmickey[4]; + union Keytype dot118021XGrprxmickey[4]; + union pn48 dot11Grptxpn; /* PN48 used for Grp Key xmit.*/ + union pn48 dot11Grprxpn; /* PN48 used for Grp Key recv.*/ +#ifdef CONFIG_88EU_AP_MODE + /* extend security capabilities for AP_MODE */ + unsigned int dot8021xalg;/* 0:disable, 1:psk, 2:802.1x */ + unsigned int wpa_psk;/* 0:disable, bit(0): WPA, bit(1):WPA2 */ + unsigned int wpa_group_cipher; + unsigned int wpa2_group_cipher; + unsigned int wpa_pairwise_cipher; + unsigned int wpa2_pairwise_cipher; +#endif + u8 wps_ie[MAX_WPS_IE_LEN];/* added in assoc req */ + int wps_ie_len; + u8 binstallGrpkey; + u8 busetkipkey; + u8 bcheck_grpkey; + u8 bgrpkey_handshake; + s32 sw_encrypt;/* from registry_priv */ + s32 sw_decrypt;/* from registry_priv */ + s32 hw_decrypted;/* if the rx packets is hw_decrypted==false,i + * it means the hw has not been ready. */ + + /* keeps the auth_type & enc_status from upper layer + * ioctl(wpa_supplicant or wzc) */ + u32 ndisauthtype; /* NDIS_802_11_AUTHENTICATION_MODE */ + u32 ndisencryptstatus; /* NDIS_802_11_ENCRYPTION_STATUS */ + struct wlan_bssid_ex sec_bss; /* for joinbss (h2c buffer) usage */ + struct ndis_802_11_wep ndiswep; + u8 assoc_info[600]; + u8 szofcapability[256]; /* for wpa2 usage */ + u8 oidassociation[512]; /* for wpa/wpa2 usage */ + u8 authenticator_ie[256]; /* store ap security information element */ + u8 supplicant_ie[256]; /* store sta security information element */ + + /* for tkip countermeasure */ + u32 last_mic_err_time; + u8 btkip_countermeasure; + u8 btkip_wait_report; + u32 btkip_countermeasure_time; + + /* */ + /* For WPA2 Pre-Authentication. */ + /* */ + struct rt_pmkid_list PMKIDList[NUM_PMKID_CACHE]; + u8 PMKIDIndex; + u8 bWepDefaultKeyIdxSet; +}; + +struct sha256_state { + u64 length; + u32 state[8], curlen; + u8 buf[64]; +}; + +#define GET_ENCRY_ALGO(psecuritypriv, psta, encry_algo, bmcst) \ +do { \ + switch (psecuritypriv->dot11AuthAlgrthm) { \ + case dot11AuthAlgrthm_Open: \ + case dot11AuthAlgrthm_Shared: \ + case dot11AuthAlgrthm_Auto: \ + encry_algo = (u8)psecuritypriv->dot11PrivacyAlgrthm; \ + break; \ + case dot11AuthAlgrthm_8021X: \ + if (bmcst) \ + encry_algo = (u8)psecuritypriv->dot118021XGrpPrivacy;\ + else \ + encry_algo = (u8)psta->dot118021XPrivacy; \ + break; \ + case dot11AuthAlgrthm_WAPI: \ + encry_algo = (u8)psecuritypriv->dot11PrivacyAlgrthm; \ + break; \ + } \ +} while (0) + +#define SET_ICE_IV_LEN(iv_len, icv_len, encrypt) \ +do { \ + switch (encrypt) { \ + case _WEP40_: \ + case _WEP104_: \ + iv_len = 4; \ + icv_len = 4; \ + break; \ + case _TKIP_: \ + iv_len = 8; \ + icv_len = 4; \ + break; \ + case _AES_: \ + iv_len = 8; \ + icv_len = 8; \ + break; \ + case _SMS4_: \ + iv_len = 18; \ + icv_len = 16; \ + break; \ + default: \ + iv_len = 0; \ + icv_len = 0; \ + break; \ + } \ +} while (0) + + +#define GET_TKIP_PN(iv, dot11txpn) \ +do { \ + dot11txpn._byte_.TSC0 = iv[2]; \ + dot11txpn._byte_.TSC1 = iv[0]; \ + dot11txpn._byte_.TSC2 = iv[4]; \ + dot11txpn._byte_.TSC3 = iv[5]; \ + dot11txpn._byte_.TSC4 = iv[6]; \ + dot11txpn._byte_.TSC5 = iv[7]; \ +} while (0) + + +#define ROL32(A, n) (((A) << (n)) | (((A)>>(32-(n))) & ((1UL << (n)) - 1))) +#define ROR32(A, n) ROL32((A), 32-(n)) + +struct mic_data { + u32 K0, K1; /* Key */ + u32 L, R; /* Current state */ + u32 M; /* Message accumulator (single word) */ + u32 nBytesInM; /* # bytes in M */ +}; + +extern const u32 Te0[256]; +extern const u32 Te1[256]; +extern const u32 Te2[256]; +extern const u32 Te3[256]; +extern const u32 Te4[256]; +extern const u32 Td0[256]; +extern const u32 Td1[256]; +extern const u32 Td2[256]; +extern const u32 Td3[256]; +extern const u32 Td4[256]; +extern const u32 rcon[10]; +extern const u8 Td4s[256]; +extern const u8 rcons[10]; + +#define RCON(i) (rcons[(i)] << 24) + +static inline u32 rotr(u32 val, int bits) +{ + return (val >> bits) | (val << (32 - bits)); +} + +#define TE0(i) Te0[((i) >> 24) & 0xff] +#define TE1(i) rotr(Te0[((i) >> 16) & 0xff], 8) +#define TE2(i) rotr(Te0[((i) >> 8) & 0xff], 16) +#define TE3(i) rotr(Te0[(i) & 0xff], 24) +#define TE41(i) ((Te0[((i) >> 24) & 0xff] << 8) & 0xff000000) +#define TE42(i) (Te0[((i) >> 16) & 0xff] & 0x00ff0000) +#define TE43(i) (Te0[((i) >> 8) & 0xff] & 0x0000ff00) +#define TE44(i) ((Te0[(i) & 0xff] >> 8) & 0x000000ff) +#define TE421(i) ((Te0[((i) >> 16) & 0xff] << 8) & 0xff000000) +#define TE432(i) (Te0[((i) >> 8) & 0xff] & 0x00ff0000) +#define TE443(i) (Te0[(i) & 0xff] & 0x0000ff00) +#define TE414(i) ((Te0[((i) >> 24) & 0xff] >> 8) & 0x000000ff) +#define TE4(i) ((Te0[(i)] >> 8) & 0x000000ff) + +#define TD0(i) Td0[((i) >> 24) & 0xff] +#define TD1(i) rotr(Td0[((i) >> 16) & 0xff], 8) +#define TD2(i) rotr(Td0[((i) >> 8) & 0xff], 16) +#define TD3(i) rotr(Td0[(i) & 0xff], 24) +#define TD41(i) (Td4s[((i) >> 24) & 0xff] << 24) +#define TD42(i) (Td4s[((i) >> 16) & 0xff] << 16) +#define TD43(i) (Td4s[((i) >> 8) & 0xff] << 8) +#define TD44(i) (Td4s[(i) & 0xff]) +#define TD0_(i) Td0[(i) & 0xff] +#define TD1_(i) rotr(Td0[(i) & 0xff], 8) +#define TD2_(i) rotr(Td0[(i) & 0xff], 16) +#define TD3_(i) rotr(Td0[(i) & 0xff], 24) + +#define GETU32(pt) (((u32)(pt)[0] << 24) ^ ((u32)(pt)[1] << 16) ^ \ + ((u32)(pt)[2] << 8) ^ ((u32)(pt)[3])) + +#define PUTU32(ct, st) { \ +(ct)[0] = (u8)((st) >> 24); (ct)[1] = (u8)((st) >> 16); \ +(ct)[2] = (u8)((st) >> 8); (ct)[3] = (u8)(st); } + +#define WPA_GET_BE32(a) ((((u32)(a)[0]) << 24) | (((u32)(a)[1]) << 16) | \ + (((u32)(a)[2]) << 8) | ((u32)(a)[3])) + +#define WPA_PUT_LE16(a, val) \ + do { \ + (a)[1] = ((u16)(val)) >> 8; \ + (a)[0] = ((u16)(val)) & 0xff; \ + } while (0) + +#define WPA_PUT_BE32(a, val) \ + do { \ + (a)[0] = (u8)((((u32)(val)) >> 24) & 0xff); \ + (a)[1] = (u8)((((u32)(val)) >> 16) & 0xff); \ + (a)[2] = (u8)((((u32)(val)) >> 8) & 0xff); \ + (a)[3] = (u8)(((u32)(val)) & 0xff); \ + } while (0) + +#define WPA_PUT_BE64(a, val) \ + do { \ + (a)[0] = (u8)(((u64)(val)) >> 56); \ + (a)[1] = (u8)(((u64)(val)) >> 48); \ + (a)[2] = (u8)(((u64)(val)) >> 40); \ + (a)[3] = (u8)(((u64)(val)) >> 32); \ + (a)[4] = (u8)(((u64)(val)) >> 24); \ + (a)[5] = (u8)(((u64)(val)) >> 16); \ + (a)[6] = (u8)(((u64)(val)) >> 8); \ + (a)[7] = (u8)(((u64)(val)) & 0xff); \ + } while (0) + +/* ===== start - public domain SHA256 implementation ===== */ + +/* This is based on SHA256 implementation in LibTomCrypt that was released into + * public domain by Tom St Denis. */ + +/* the K array */ +static const unsigned long K[64] = { + 0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL, 0x3956c25bUL, + 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL, 0xd807aa98UL, 0x12835b01UL, + 0x243185beUL, 0x550c7dc3UL, 0x72be5d74UL, 0x80deb1feUL, 0x9bdc06a7UL, + 0xc19bf174UL, 0xe49b69c1UL, 0xefbe4786UL, 0x0fc19dc6UL, 0x240ca1ccUL, + 0x2de92c6fUL, 0x4a7484aaUL, 0x5cb0a9dcUL, 0x76f988daUL, 0x983e5152UL, + 0xa831c66dUL, 0xb00327c8UL, 0xbf597fc7UL, 0xc6e00bf3UL, 0xd5a79147UL, + 0x06ca6351UL, 0x14292967UL, 0x27b70a85UL, 0x2e1b2138UL, 0x4d2c6dfcUL, + 0x53380d13UL, 0x650a7354UL, 0x766a0abbUL, 0x81c2c92eUL, 0x92722c85UL, + 0xa2bfe8a1UL, 0xa81a664bUL, 0xc24b8b70UL, 0xc76c51a3UL, 0xd192e819UL, + 0xd6990624UL, 0xf40e3585UL, 0x106aa070UL, 0x19a4c116UL, 0x1e376c08UL, + 0x2748774cUL, 0x34b0bcb5UL, 0x391c0cb3UL, 0x4ed8aa4aUL, 0x5b9cca4fUL, + 0x682e6ff3UL, 0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL, + 0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL +}; + +/* Various logical functions */ +#define RORc(x, y) \ + (((((unsigned long)(x) & 0xFFFFFFFFUL) >> (unsigned long)((y)&31)) | \ + ((unsigned long)(x) << (unsigned long)(32-((y)&31)))) & 0xFFFFFFFFUL) +#define Ch(x, y ,z) (z ^ (x & (y ^ z))) +#define Maj(x, y, z) (((x | y) & z) | (x & y)) +#define S(x, n) RORc((x), (n)) +#define R(x, n) (((x)&0xFFFFFFFFUL)>>(n)) +#define Sigma0(x) (S(x, 2) ^ S(x, 13) ^ S(x, 22)) +#define Sigma1(x) (S(x, 6) ^ S(x, 11) ^ S(x, 25)) +#define Gamma0(x) (S(x, 7) ^ S(x, 18) ^ R(x, 3)) +#define Gamma1(x) (S(x, 17) ^ S(x, 19) ^ R(x, 10)) +#ifndef MIN +#define MIN(x, y) (((x) < (y)) ? (x) : (y)) +#endif + +void rtw_secmicsetkey(struct mic_data *pmicdata, u8 *key); +void rtw_secmicappendbyte(struct mic_data *pmicdata, u8 b); +void rtw_secmicappend(struct mic_data *pmicdata, u8 *src, u32 nBytes); +void rtw_secgetmic(struct mic_data *pmicdata, u8 *dst); +void rtw_seccalctkipmic(u8 *key, u8 *header, u8 *data, u32 data_len, + u8 *Miccode, u8 priority); +u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe); +u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe); +void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe); +u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe); +u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe); +void rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe); +void rtw_use_tkipkey_handler(void *FunctionContext); + +#endif /* __RTL871X_SECURITY_H_ */ diff --git a/drivers/staging/rtl8188eu/include/rtw_sreset.h b/drivers/staging/rtl8188eu/include/rtw_sreset.h new file mode 100644 index 0000000000000..2a1244f75790d --- /dev/null +++ b/drivers/staging/rtl8188eu/include/rtw_sreset.h @@ -0,0 +1,50 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef _RTW_SRESET_C_ +#define _RTW_SRESET_C_ + +#include +#include + +struct sreset_priv { + struct mutex silentreset_mutex; + u8 silent_reset_inprogress; + u8 Wifi_Error_Status; + unsigned long last_tx_time; + unsigned long last_tx_complete_time; +}; + +#include + +#define WIFI_STATUS_SUCCESS 0 +#define USB_VEN_REQ_CMD_FAIL BIT0 +#define USB_READ_PORT_FAIL BIT1 +#define USB_WRITE_PORT_FAIL BIT2 +#define WIFI_MAC_TXDMA_ERROR BIT3 +#define WIFI_TX_HANG BIT4 +#define WIFI_RX_HANG BIT5 +#define WIFI_IF_NOT_EXIST BIT6 + +void sreset_init_value(struct adapter *padapter); +void sreset_reset_value(struct adapter *padapter); +u8 sreset_get_wifi_status(struct adapter *padapter); +void sreset_set_wifi_error_status(struct adapter *padapter, u32 status); + +#endif diff --git a/drivers/staging/rtl8188eu/include/rtw_version.h b/drivers/staging/rtl8188eu/include/rtw_version.h new file mode 100644 index 0000000000000..6d2d52cbb3d3b --- /dev/null +++ b/drivers/staging/rtl8188eu/include/rtw_version.h @@ -0,0 +1 @@ +#define DRIVERVERSION "v4.1.4_6773.20130222" diff --git a/drivers/staging/rtl8188eu/include/rtw_xmit.h b/drivers/staging/rtl8188eu/include/rtw_xmit.h new file mode 100644 index 0000000000000..1ac1dd31db68c --- /dev/null +++ b/drivers/staging/rtl8188eu/include/rtw_xmit.h @@ -0,0 +1,384 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef _RTW_XMIT_H_ +#define _RTW_XMIT_H_ + +#include +#include + +#define MAX_XMITBUF_SZ (20480) /* 20k */ +#define NR_XMITBUFF (4) + +#define XMITBUF_ALIGN_SZ 4 + +/* xmit extension buff defination */ +#define MAX_XMIT_EXTBUF_SZ (1536) +#define NR_XMIT_EXTBUFF (32) + +#define MAX_NUMBLKS (1) + +#define XMIT_VO_QUEUE (0) +#define XMIT_VI_QUEUE (1) +#define XMIT_BE_QUEUE (2) +#define XMIT_BK_QUEUE (3) + +#define VO_QUEUE_INX 0 +#define VI_QUEUE_INX 1 +#define BE_QUEUE_INX 2 +#define BK_QUEUE_INX 3 +#define BCN_QUEUE_INX 4 +#define MGT_QUEUE_INX 5 +#define HIGH_QUEUE_INX 6 +#define TXCMD_QUEUE_INX 7 + +#define HW_QUEUE_ENTRY 8 + +#define WEP_IV(pattrib_iv, dot11txpn, keyidx)\ +do {\ + pattrib_iv[0] = dot11txpn._byte_.TSC0;\ + pattrib_iv[1] = dot11txpn._byte_.TSC1;\ + pattrib_iv[2] = dot11txpn._byte_.TSC2;\ + pattrib_iv[3] = ((keyidx & 0x3)<<6);\ + dot11txpn.val = (dot11txpn.val == 0xffffff) ? 0 : (dot11txpn.val+1);\ +} while (0) + + +#define TKIP_IV(pattrib_iv, dot11txpn, keyidx)\ +do {\ + pattrib_iv[0] = dot11txpn._byte_.TSC1;\ + pattrib_iv[1] = (dot11txpn._byte_.TSC1 | 0x20) & 0x7f;\ + pattrib_iv[2] = dot11txpn._byte_.TSC0;\ + pattrib_iv[3] = BIT(5) | ((keyidx & 0x3)<<6);\ + pattrib_iv[4] = dot11txpn._byte_.TSC2;\ + pattrib_iv[5] = dot11txpn._byte_.TSC3;\ + pattrib_iv[6] = dot11txpn._byte_.TSC4;\ + pattrib_iv[7] = dot11txpn._byte_.TSC5;\ + dot11txpn.val = dot11txpn.val == 0xffffffffffffULL ? 0 : (dot11txpn.val+1);\ +} while (0) + +#define AES_IV(pattrib_iv, dot11txpn, keyidx)\ +do { \ + pattrib_iv[0] = dot11txpn._byte_.TSC0; \ + pattrib_iv[1] = dot11txpn._byte_.TSC1; \ + pattrib_iv[2] = 0; \ + pattrib_iv[3] = BIT(5) | ((keyidx & 0x3)<<6); \ + pattrib_iv[4] = dot11txpn._byte_.TSC2; \ + pattrib_iv[5] = dot11txpn._byte_.TSC3; \ + pattrib_iv[6] = dot11txpn._byte_.TSC4; \ + pattrib_iv[7] = dot11txpn._byte_.TSC5; \ + dot11txpn.val = dot11txpn.val == 0xffffffffffffULL ? 0 : (dot11txpn.val+1);\ +} while (0) + +#define HWXMIT_ENTRY 4 + +#define TXDESC_SIZE 32 + +#define PACKET_OFFSET_SZ (8) +#define TXDESC_OFFSET (TXDESC_SIZE + PACKET_OFFSET_SZ) + +struct tx_desc { + /* DWORD 0 */ + __le32 txdw0; + __le32 txdw1; + __le32 txdw2; + __le32 txdw3; + __le32 txdw4; + __le32 txdw5; + __le32 txdw6; + __le32 txdw7; +}; + +union txdesc { + struct tx_desc txdesc; + unsigned int value[TXDESC_SIZE>>2]; +}; + +struct hw_xmit { + struct __queue *sta_queue; + int accnt; +}; + +/* reduce size */ +struct pkt_attrib { + u8 type; + u8 subtype; + u8 bswenc; + u8 dhcp_pkt; + u16 ether_type; + u16 seqnum; + u16 pkt_hdrlen; /* the original 802.3 pkt header len */ + u16 hdrlen; /* the WLAN Header Len */ + u32 pktlen; /* the original 802.3 pkt raw_data len (not include + * ether_hdr data) */ + u32 last_txcmdsz; + u8 nr_frags; + u8 encrypt; /* when 0 indicate no encrypt. when non-zero, + * indicate the encrypt algorith */ + u8 iv_len; + u8 icv_len; + u8 iv[18]; + u8 icv[16]; + u8 priority; + u8 ack_policy; + u8 mac_id; + u8 vcs_mode; /* virtual carrier sense method */ + u8 dst[ETH_ALEN]; + u8 src[ETH_ALEN]; + u8 ta[ETH_ALEN]; + u8 ra[ETH_ALEN]; + u8 key_idx; + u8 qos_en; + u8 ht_en; + u8 raid;/* rate adpative id */ + u8 bwmode; + u8 ch_offset;/* PRIME_CHNL_OFFSET */ + u8 sgi;/* short GI */ + u8 ampdu_en;/* tx ampdu enable */ + u8 mdata;/* more data bit */ + u8 pctrl;/* per packet txdesc control enable */ + u8 triggered;/* for ap mode handling Power Saving sta */ + u8 qsel; + u8 eosp; + u8 rate; + u8 intel_proxim; + u8 retry_ctrl; + struct sta_info *psta; +}; + +#define WLANHDR_OFFSET 64 + +#define NULL_FRAMETAG (0x0) +#define DATA_FRAMETAG 0x01 +#define L2_FRAMETAG 0x02 +#define MGNT_FRAMETAG 0x03 +#define AMSDU_FRAMETAG 0x04 + +#define EII_FRAMETAG 0x05 +#define IEEE8023_FRAMETAG 0x06 + +#define MP_FRAMETAG 0x07 + +#define TXAGG_FRAMETAG 0x08 + +struct submit_ctx { + u32 submit_time; /* */ + u32 timeout_ms; /* <0: not synchronous, 0: wait forever, >0: up to ms waiting */ + int status; /* status for operation */ + struct completion done; +}; + +enum { + RTW_SCTX_SUBMITTED = -1, + RTW_SCTX_DONE_SUCCESS = 0, + RTW_SCTX_DONE_UNKNOWN, + RTW_SCTX_DONE_TIMEOUT, + RTW_SCTX_DONE_BUF_ALLOC, + RTW_SCTX_DONE_BUF_FREE, + RTW_SCTX_DONE_WRITE_PORT_ERR, + RTW_SCTX_DONE_TX_DESC_NA, + RTW_SCTX_DONE_TX_DENY, + RTW_SCTX_DONE_CCX_PKT_FAIL, + RTW_SCTX_DONE_DRV_STOP, + RTW_SCTX_DONE_DEV_REMOVE, +}; + +void rtw_sctx_init(struct submit_ctx *sctx, int timeout_ms); +int rtw_sctx_wait(struct submit_ctx *sctx); +void rtw_sctx_done_err(struct submit_ctx **sctx, int status); +void rtw_sctx_done(struct submit_ctx **sctx); + +struct xmit_buf { + struct list_head list; + struct adapter *padapter; + u8 *pallocated_buf; + u8 *pbuf; + void *priv_data; + u16 ext_tag; /* 0: Normal xmitbuf, 1: extension xmitbuf. */ + u16 flags; + u32 alloc_sz; + u32 len; + struct submit_ctx *sctx; + u32 ff_hwaddr; + struct urb *pxmit_urb[8]; + dma_addr_t dma_transfer_addr; /* (in) dma addr for transfer_buffer */ + u8 bpending[8]; + int last[8]; +}; + +struct xmit_frame { + struct list_head list; + struct pkt_attrib attrib; + struct sk_buff *pkt; + int frame_tag; + struct adapter *padapter; + u8 *buf_addr; + struct xmit_buf *pxmitbuf; + + u8 agg_num; + s8 pkt_offset; + u8 ack_report; +}; + +struct tx_servq { + struct list_head tx_pending; + struct __queue sta_pending; + int qcnt; +}; + +struct sta_xmit_priv { + spinlock_t lock; + int option; + int apsd_setting; /* When bit mask is on, the associated edca + * queue supports APSD. */ + struct tx_servq be_q; /* priority == 0,3 */ + struct tx_servq bk_q; /* priority == 1,2 */ + struct tx_servq vi_q; /* priority == 4,5 */ + struct tx_servq vo_q; /* priority == 6,7 */ + struct list_head legacy_dz; + struct list_head apsd; + u16 txseq_tid[16]; +}; + +struct hw_txqueue { + volatile int head; + volatile int tail; + volatile int free_sz; /* in units of 64 bytes */ + volatile int free_cmdsz; + volatile int txsz[8]; + uint ff_hwaddr; + uint cmd_hwaddr; + int ac_tag; +}; + +struct agg_pkt_info { + u16 offset; + u16 pkt_len; +}; + +struct xmit_priv { + spinlock_t lock; + struct semaphore xmit_sema; + struct semaphore terminate_xmitthread_sema; + struct __queue be_pending; + struct __queue bk_pending; + struct __queue vi_pending; + struct __queue vo_pending; + struct __queue bm_pending; + u8 *pallocated_frame_buf; + u8 *pxmit_frame_buf; + uint free_xmitframe_cnt; + struct __queue free_xmit_queue; + uint frag_len; + struct adapter *adapter; + u8 vcs_setting; + u8 vcs; + u8 vcs_type; + u64 tx_bytes; + u64 tx_pkts; + u64 tx_drop; + u64 last_tx_bytes; + u64 last_tx_pkts; + struct hw_xmit *hwxmits; + u8 hwxmit_entry; + u8 wmm_para_seq[4];/* sequence for wmm ac parameter strength + * from large to small. it's value is 0->vo, + * 1->vi, 2->be, 3->bk. */ + struct semaphore tx_retevt;/* all tx return event; */ + u8 txirp_cnt;/* */ + struct tasklet_struct xmit_tasklet; + /* per AC pending irp */ + int beq_cnt; + int bkq_cnt; + int viq_cnt; + int voq_cnt; + struct __queue free_xmitbuf_queue; + struct __queue pending_xmitbuf_queue; + u8 *pallocated_xmitbuf; + u8 *pxmitbuf; + uint free_xmitbuf_cnt; + struct __queue free_xmit_extbuf_queue; + u8 *pallocated_xmit_extbuf; + u8 *pxmit_extbuf; + uint free_xmit_extbuf_cnt; + u16 nqos_ssn; + int ack_tx; + struct mutex ack_tx_mutex; + struct submit_ctx ack_tx_ops; +}; + +struct xmit_buf *rtw_alloc_xmitbuf_ext(struct xmit_priv *pxmitpriv); +s32 rtw_free_xmitbuf_ext(struct xmit_priv *pxmitpriv, + struct xmit_buf *pxmitbuf); +struct xmit_buf *rtw_alloc_xmitbuf(struct xmit_priv *pxmitpriv); +s32 rtw_free_xmitbuf(struct xmit_priv *pxmitpriv, + struct xmit_buf *pxmitbuf); +void rtw_count_tx_stats(struct adapter *padapter, + struct xmit_frame *pxmitframe, int sz); +void rtw_update_protection(struct adapter *padapter, u8 *ie, uint ie_len); +s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, + struct pkt_attrib *pattrib); +s32 rtw_put_snap(u8 *data, u16 h_proto); + +struct xmit_frame *rtw_alloc_xmitframe(struct xmit_priv *pxmitpriv); +s32 rtw_free_xmitframe(struct xmit_priv *pxmitpriv, + struct xmit_frame *pxmitframe); +void rtw_free_xmitframe_queue(struct xmit_priv *pxmitpriv, + struct __queue *pframequeue); +struct tx_servq *rtw_get_sta_pending(struct adapter *padapter, + struct sta_info *psta, int up, u8 *ac); +s32 rtw_xmitframe_enqueue(struct adapter *padapter, + struct xmit_frame *pxmitframe); +struct xmit_frame *rtw_dequeue_xframe(struct xmit_priv *pxmitpriv, + struct hw_xmit *phwxmit_i, int entry); + +s32 rtw_xmit_classifier(struct adapter *padapter, + struct xmit_frame *pxmitframe); +u32 rtw_calculate_wlan_pkt_size_by_attribue(struct pkt_attrib *pattrib); +#define rtw_wlan_pkt_size(f) rtw_calculate_wlan_pkt_size_by_attribue(&f->attrib) +s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, + struct xmit_frame *pxmitframe); +s32 _rtw_init_hw_txqueue(struct hw_txqueue *phw_txqueue, u8 ac_tag); +void _rtw_init_sta_xmit_priv(struct sta_xmit_priv *psta_xmitpriv); +s32 rtw_txframes_pending(struct adapter *padapter); +s32 rtw_txframes_sta_ac_pending(struct adapter *padapter, + struct pkt_attrib *pattrib); +void rtw_init_hwxmits(struct hw_xmit *phwxmit, int entry); +s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter); +void _rtw_free_xmit_priv(struct xmit_priv *pxmitpriv); +void rtw_alloc_hwxmits(struct adapter *padapter); +void rtw_free_hwxmits(struct adapter *padapter); +s32 rtw_xmit(struct adapter *padapter, struct sk_buff **pkt); + +#if defined(CONFIG_88EU_AP_MODE) +int xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_frame *pxmitframe); +void stop_sta_xmit(struct adapter *padapter, struct sta_info *psta); +void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta); +void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *psta); +#endif + +u8 qos_acm(u8 acm_mask, u8 priority); +u32 rtw_get_ff_hwaddr(struct xmit_frame *pxmitframe); +int rtw_ack_tx_wait(struct xmit_priv *pxmitpriv, u32 timeout_ms); +void rtw_ack_tx_done(struct xmit_priv *pxmitpriv, int status); + +/* include after declaring struct xmit_buf, in order to avoid warning */ +#include + +#endif /* _RTL871X_XMIT_H_ */ -- GitLab From 6ddfa35a4a98d28f9506c1bb25c82927dff9eff2 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 21 Aug 2013 22:34:13 -0500 Subject: [PATCH 789/942] staging: r8188eu: Insert Kconfig files for new driver The configuration options include those to add code needed for AP mode, and peer-to-peer mode. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/Kconfig | 2 ++ drivers/staging/rtl8188eu/Kconfig | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 drivers/staging/rtl8188eu/Kconfig diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index 0d9d92b275ba5..6fade33de8eb0 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -50,6 +50,8 @@ source "drivers/staging/rtl8192e/Kconfig" source "drivers/staging/rtl8712/Kconfig" +source "drivers/staging/rtl8188eu/Kconfig" + source "drivers/staging/rts5139/Kconfig" source "drivers/staging/frontier/Kconfig" diff --git a/drivers/staging/rtl8188eu/Kconfig b/drivers/staging/rtl8188eu/Kconfig new file mode 100644 index 0000000000000..c9c548f174949 --- /dev/null +++ b/drivers/staging/rtl8188eu/Kconfig @@ -0,0 +1,29 @@ +config R8188EU + tristate "Realtek RTL8188EU Wireless LAN NIC driver" + depends on WLAN && USB + select WIRELESS_EXT + select WEXT_PRIV + default N + ---help--- + This option adds the Realtek RTL8188EU USB device such as TP-Link TL-WN725N. + If built as a module, it will be called r8188eu. + +if R8188EU + +config 88EU_AP_MODE + bool "Realtek RTL8188EU AP mode" + default Y + ---help--- + This option enables Access Point mode. Unless you know that your system + will never be used as an AP, or the target system has limited memory, + "Y" should be selected. + +config 88EU_P2P + bool "Realtek RTL8188EU Peer-to-peer mode" + default Y + ---help--- + This option enables peer-to-peer mode for the r8188eu driver. Unless you + know that peer-to-peer (P2P) mode will never be used, or the target system has + limited memory, "Y" should be selected. + +endif -- GitLab From 9a602711878714d71209e89ea3510929a5de6ee5 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 21 Aug 2013 22:34:14 -0500 Subject: [PATCH 790/942] staging: r8188eu: Add files for new driver - part 31 This commit adds files include/sta_info.h, include/usb_hal.h, include/usb_ops.h, include/usb_ops_linux.h, include/usb_osintf.h, include/usb_vendor_req.h, include/wifi.h, include/wlan_bssdef.h, and include/xmit_osdep.h. The commit also deleted include/autoconf.h, which is no longer needed. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/sta_info.h | 384 ++++++ .../include/{autoconf.h => usb_hal.h} | 27 +- drivers/staging/rtl8188eu/include/usb_ops.h | 114 ++ .../staging/rtl8188eu/include/usb_ops_linux.h | 55 + .../staging/rtl8188eu/include/usb_osintf.h | 45 + .../rtl8188eu/include/usb_vendor_req.h | 52 + drivers/staging/rtl8188eu/include/wifi.h | 1127 +++++++++++++++++ .../staging/rtl8188eu/include/wlan_bssdef.h | 347 +++++ .../staging/rtl8188eu/include/xmit_osdep.h | 67 + 9 files changed, 2196 insertions(+), 22 deletions(-) create mode 100644 drivers/staging/rtl8188eu/include/sta_info.h rename drivers/staging/rtl8188eu/include/{autoconf.h => usb_hal.h} (71%) create mode 100644 drivers/staging/rtl8188eu/include/usb_ops.h create mode 100644 drivers/staging/rtl8188eu/include/usb_ops_linux.h create mode 100644 drivers/staging/rtl8188eu/include/usb_osintf.h create mode 100644 drivers/staging/rtl8188eu/include/usb_vendor_req.h create mode 100644 drivers/staging/rtl8188eu/include/wifi.h create mode 100644 drivers/staging/rtl8188eu/include/wlan_bssdef.h create mode 100644 drivers/staging/rtl8188eu/include/xmit_osdep.h diff --git a/drivers/staging/rtl8188eu/include/sta_info.h b/drivers/staging/rtl8188eu/include/sta_info.h new file mode 100644 index 0000000000000..acc632ae5ae0d --- /dev/null +++ b/drivers/staging/rtl8188eu/include/sta_info.h @@ -0,0 +1,384 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __STA_INFO_H_ +#define __STA_INFO_H_ + +#include +#include +#include + +#define IBSS_START_MAC_ID 2 +#define NUM_STA 32 +#define NUM_ACL 16 + +/* if mode ==0, then the sta is allowed once the addr is hit. */ +/* if mode ==1, then the sta is rejected once the addr is non-hit. */ +struct rtw_wlan_acl_node { + struct list_head list; + u8 addr[ETH_ALEN]; + u8 valid; +}; + +/* mode=0, disable */ +/* mode=1, accept unless in deny list */ +/* mode=2, deny unless in accept list */ +struct wlan_acl_pool { + int mode; + int num; + struct rtw_wlan_acl_node aclnode[NUM_ACL]; + struct __queue acl_node_q; +}; + +struct rssi_sta { + s32 UndecoratedSmoothedPWDB; + s32 UndecoratedSmoothedCCK; + s32 UndecoratedSmoothedOFDM; + u64 PacketMap; + u8 ValidBit; +}; + +struct stainfo_stats { + u64 rx_mgnt_pkts; + u64 rx_beacon_pkts; + u64 rx_probereq_pkts; + u64 rx_probersp_pkts; + u64 rx_probersp_bm_pkts; + u64 rx_probersp_uo_pkts; + u64 rx_ctrl_pkts; + u64 rx_data_pkts; + + u64 last_rx_mgnt_pkts; + u64 last_rx_beacon_pkts; + u64 last_rx_probereq_pkts; + u64 last_rx_probersp_pkts; + u64 last_rx_probersp_bm_pkts; + u64 last_rx_probersp_uo_pkts; + u64 last_rx_ctrl_pkts; + u64 last_rx_data_pkts; + u64 rx_bytes; + u64 rx_drops; + u64 tx_pkts; + u64 tx_bytes; + u64 tx_drops; +}; + +struct sta_info { + spinlock_t lock; + struct list_head list; /* free_sta_queue */ + struct list_head hash_list; /* sta_hash */ + + struct sta_xmit_priv sta_xmitpriv; + struct sta_recv_priv sta_recvpriv; + + struct __queue sleep_q; + unsigned int sleepq_len; + + uint state; + uint aid; + uint mac_id; + uint qos_option; + u8 hwaddr[ETH_ALEN]; + + uint ieee8021x_blocked; /* 0: allowed, 1:blocked */ + uint dot118021XPrivacy; /* aes, tkip... */ + union Keytype dot11tkiptxmickey; + union Keytype dot11tkiprxmickey; + union Keytype dot118021x_UncstKey; + union pn48 dot11txpn; /* PN48 used for Unicast xmit. */ + union pn48 dot11rxpn; /* PN48 used for Unicast recv. */ + u8 bssrateset[16]; + u32 bssratelen; + s32 rssi; + s32 signal_quality; + + u8 cts2self; + u8 rtsen; + + u8 raid; + u8 init_rate; + u32 ra_mask; + u8 wireless_mode; /* NETWORK_TYPE */ + struct stainfo_stats sta_stats; + + /* for A-MPDU TX, ADDBA timeout check */ + struct timer_list addba_retry_timer; + + /* for A-MPDU Rx reordering buffer control */ + struct recv_reorder_ctrl recvreorder_ctrl[16]; + + /* for A-MPDU Tx */ + /* unsigned char ampdu_txen_bitmap; */ + u16 BA_starting_seqctrl[16]; + + struct ht_priv htpriv; + + /* Notes: */ + /* STA_Mode: */ + /* curr_network(mlme_priv/security_priv/qos/ht) + + * sta_info: (STA & AP) CAP/INFO */ + /* scan_q: AP CAP/INFO */ + + /* AP_Mode: */ + /* curr_network(mlme_priv/security_priv/qos/ht) : AP CAP/INFO */ + /* sta_info: (AP & STA) CAP/INFO */ + + struct list_head asoc_list; +#ifdef CONFIG_88EU_AP_MODE + struct list_head auth_list; + + unsigned int expire_to; + unsigned int auth_seq; + unsigned int authalg; + unsigned char chg_txt[128]; + + u16 capability; + int flags; + + int dot8021xalg;/* 0:disable, 1:psk, 2:802.1x */ + int wpa_psk;/* 0:disable, bit(0): WPA, bit(1):WPA2 */ + int wpa_group_cipher; + int wpa2_group_cipher; + int wpa_pairwise_cipher; + int wpa2_pairwise_cipher; + + u8 bpairwise_key_installed; + + u8 wpa_ie[32]; + + u8 nonerp_set; + u8 no_short_slot_time_set; + u8 no_short_preamble_set; + u8 no_ht_gf_set; + u8 no_ht_set; + u8 ht_20mhz_set; + + unsigned int tx_ra_bitmap; + u8 qos_info; + + u8 max_sp_len; + u8 uapsd_bk;/* BIT(0): Delivery enabled, BIT(1): Trigger enabled */ + u8 uapsd_be; + u8 uapsd_vi; + u8 uapsd_vo; + + u8 has_legacy_ac; + unsigned int sleepq_ac_len; + +#ifdef CONFIG_88EU_P2P + /* p2p priv data */ + u8 is_p2p_device; + u8 p2p_status_code; + + /* p2p client info */ + u8 dev_addr[ETH_ALEN]; + u8 dev_cap; + u16 config_methods; + u8 primary_dev_type[8]; + u8 num_of_secdev_type; + u8 secdev_types_list[32];/* 32/8 == 4; */ + u16 dev_name_len; + u8 dev_name[32]; +#endif /* CONFIG_88EU_P2P */ + u8 under_exist_checking; + u8 keep_alive_trycnt; +#endif /* CONFIG_88EU_AP_MODE */ + + /* for DM */ + struct rssi_sta rssi_stat; + + /* ================ODM Relative Info======================= */ + /* Please be careful, don't declare too much structure here. + * It will cost memory * STA support num. */ + /* 2011/10/20 MH Add for ODM STA info. */ + /* Driver Write */ + u8 bValid; /* record the sta status link or not? */ + u8 IOTPeer; /* Enum value. HT_IOT_PEER_E */ + u8 rssi_level; /* for Refresh RA mask */ + /* ODM Write */ + /* 1 PHY_STATUS_INFO */ + u8 RSSI_Path[4]; /* */ + u8 RSSI_Ave; + u8 RXEVM[4]; + u8 RXSNR[4]; + + /* ================ODM Relative Info======================= */ + /* */ + + /* To store the sequence number of received management frame */ + u16 RxMgmtFrameSeqNum; +}; + +#define sta_rx_pkts(sta) \ + (sta->sta_stats.rx_mgnt_pkts \ + + sta->sta_stats.rx_ctrl_pkts \ + + sta->sta_stats.rx_data_pkts) + +#define sta_last_rx_pkts(sta) \ + (sta->sta_stats.last_rx_mgnt_pkts \ + + sta->sta_stats.last_rx_ctrl_pkts \ + + sta->sta_stats.last_rx_data_pkts) + +#define sta_rx_data_pkts(sta) \ + (sta->sta_stats.rx_data_pkts) + +#define sta_last_rx_data_pkts(sta) \ + (sta->sta_stats.last_rx_data_pkts) + +#define sta_rx_mgnt_pkts(sta) \ + (sta->sta_stats.rx_mgnt_pkts) + +#define sta_last_rx_mgnt_pkts(sta) \ + (sta->sta_stats.last_rx_mgnt_pkts) + +#define sta_rx_beacon_pkts(sta) \ + (sta->sta_stats.rx_beacon_pkts) + +#define sta_last_rx_beacon_pkts(sta) \ + (sta->sta_stats.last_rx_beacon_pkts) + +#define sta_rx_probereq_pkts(sta) \ + (sta->sta_stats.rx_probereq_pkts) + +#define sta_last_rx_probereq_pkts(sta) \ + (sta->sta_stats.last_rx_probereq_pkts) + +#define sta_rx_probersp_pkts(sta) \ + (sta->sta_stats.rx_probersp_pkts) + +#define sta_last_rx_probersp_pkts(sta) \ + (sta->sta_stats.last_rx_probersp_pkts) + +#define sta_rx_probersp_bm_pkts(sta) \ + (sta->sta_stats.rx_probersp_bm_pkts) + +#define sta_last_rx_probersp_bm_pkts(sta) \ + (sta->sta_stats.last_rx_probersp_bm_pkts) + +#define sta_rx_probersp_uo_pkts(sta) \ + (sta->sta_stats.rx_probersp_uo_pkts) + +#define sta_last_rx_probersp_uo_pkts(sta) \ + (sta->sta_stats.last_rx_probersp_uo_pkts) + +#define sta_update_last_rx_pkts(sta) \ +do { \ + sta->sta_stats.last_rx_mgnt_pkts = sta->sta_stats.rx_mgnt_pkts; \ + sta->sta_stats.last_rx_beacon_pkts = sta->sta_stats.rx_beacon_pkts; \ + sta->sta_stats.last_rx_probereq_pkts = sta->sta_stats.rx_probereq_pkts; \ + sta->sta_stats.last_rx_probersp_pkts = sta->sta_stats.rx_probersp_pkts; \ + sta->sta_stats.last_rx_probersp_bm_pkts = sta->sta_stats.rx_probersp_bm_pkts; \ + sta->sta_stats.last_rx_probersp_uo_pkts = sta->sta_stats.rx_probersp_uo_pkts; \ + sta->sta_stats.last_rx_ctrl_pkts = sta->sta_stats.rx_ctrl_pkts; \ + sta->sta_stats.last_rx_data_pkts = sta->sta_stats.rx_data_pkts; \ +} while (0) + +#define STA_RX_PKTS_ARG(sta) \ + sta->sta_stats.rx_mgnt_pkts \ + , sta->sta_stats.rx_ctrl_pkts \ + , sta->sta_stats.rx_data_pkts + +#define STA_LAST_RX_PKTS_ARG(sta) \ + sta->sta_stats.last_rx_mgnt_pkts \ + , sta->sta_stats.last_rx_ctrl_pkts \ + , sta->sta_stats.last_rx_data_pkts + +#define STA_RX_PKTS_DIFF_ARG(sta) \ + sta->sta_stats.rx_mgnt_pkts - sta->sta_stats.last_rx_mgnt_pkts \ + , sta->sta_stats.rx_ctrl_pkts - sta->sta_stats.last_rx_ctrl_pkts \ + , sta->sta_stats.rx_data_pkts - sta->sta_stats.last_rx_data_pkts + +#define STA_PKTS_FMT "(m:%llu, c:%llu, d:%llu)" + +struct sta_priv { + u8 *pallocated_stainfo_buf; + u8 *pstainfo_buf; + struct __queue free_sta_queue; + + spinlock_t sta_hash_lock; + struct list_head sta_hash[NUM_STA]; + int asoc_sta_count; + struct __queue sleep_q; + struct __queue wakeup_q; + + struct adapter *padapter; + + spinlock_t asoc_list_lock; + struct list_head asoc_list; + +#ifdef CONFIG_88EU_AP_MODE + struct list_head auth_list; + spinlock_t auth_list_lock; + u8 asoc_list_cnt; + u8 auth_list_cnt; + + unsigned int auth_to; /* sec, time to expire in authenticating. */ + unsigned int assoc_to; /* sec, time to expire before associating. */ + unsigned int expire_to; /* sec , time to expire after associated. */ + + /* pointers to STA info; based on allocated AID or NULL if AID free + * AID is in the range 1-2007, so sta_aid[0] corresponders to AID 1 + * and so on + */ + struct sta_info *sta_aid[NUM_STA]; + + u16 sta_dz_bitmap;/* only support 15 stations, staion aid bitmap + * for sleeping sta. */ + u16 tim_bitmap; /* only support 15 stations, aid=0~15 mapping + * bit0~bit15 */ + + u16 max_num_sta; + + struct wlan_acl_pool acl_list; +#endif + +}; + +static inline u32 wifi_mac_hash(u8 *mac) +{ + u32 x; + + x = mac[0]; + x = (x << 2) ^ mac[1]; + x = (x << 2) ^ mac[2]; + x = (x << 2) ^ mac[3]; + x = (x << 2) ^ mac[4]; + x = (x << 2) ^ mac[5]; + + x ^= x >> 8; + x = x & (NUM_STA - 1); + return x; +} + +extern u32 _rtw_init_sta_priv(struct sta_priv *pstapriv); +extern u32 _rtw_free_sta_priv(struct sta_priv *pstapriv); + +#define stainfo_offset_valid(offset) (offset < NUM_STA && offset >= 0) +int rtw_stainfo_offset(struct sta_priv *stapriv, struct sta_info *sta); +struct sta_info *rtw_get_stainfo_by_offset(struct sta_priv *stapriv, int off); + +extern struct sta_info *rtw_alloc_stainfo(struct sta_priv *stapriv, u8 *hwaddr); +extern u32 rtw_free_stainfo(struct adapter *adapt, struct sta_info *psta); +extern void rtw_free_all_stainfo(struct adapter *adapt); +extern struct sta_info *rtw_get_stainfo(struct sta_priv *stapriv, u8 *hwaddr); +extern u32 rtw_init_bcmc_stainfo(struct adapter *adapt); +extern struct sta_info *rtw_get_bcmc_stainfo(struct adapter *padapter); +extern u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr); + +#endif /* _STA_INFO_H_ */ diff --git a/drivers/staging/rtl8188eu/include/autoconf.h b/drivers/staging/rtl8188eu/include/usb_hal.h similarity index 71% rename from drivers/staging/rtl8188eu/include/autoconf.h rename to drivers/staging/rtl8188eu/include/usb_hal.h index 8c81eef008d5d..8a65995d5e48b 100644 --- a/drivers/staging/rtl8188eu/include/autoconf.h +++ b/drivers/staging/rtl8188eu/include/usb_hal.h @@ -17,27 +17,10 @@ * * ******************************************************************************/ +#ifndef __USB_HAL_H__ +#define __USB_HAL_H__ -/* temporarily flag ******* */ -/* - * Public General Config - */ -#define RTL871X_MODULE_NAME "88EU" -#define DRV_NAME "rtl8188eu" +void rtl8188eu_set_hal_ops(struct adapter *padapter); +#define hal_set_hal_ops rtl8188eu_set_hal_ops -/* - * Internal General Config - */ - -#define CONFIG_88EU_AP_MODE - -#define CONFIG_88EU_P2P - -#define RTW_NOTCH_FILTER 0 /* 0:Disable, 1:Enable, */ - -#define CONFIG_BR_EXT_BRNAME "br0" - -/* - * Debug Related Config - */ -#define DBG 1 +#endif /* __USB_HAL_H__ */ diff --git a/drivers/staging/rtl8188eu/include/usb_ops.h b/drivers/staging/rtl8188eu/include/usb_ops.h new file mode 100644 index 0000000000000..c23de7bd36e3b --- /dev/null +++ b/drivers/staging/rtl8188eu/include/usb_ops.h @@ -0,0 +1,114 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __USB_OPS_H_ +#define __USB_OPS_H_ + +#include +#include +#include + +#define REALTEK_USB_VENQT_READ 0xC0 +#define REALTEK_USB_VENQT_WRITE 0x40 +#define REALTEK_USB_VENQT_CMD_REQ 0x05 +#define REALTEK_USB_VENQT_CMD_IDX 0x00 + +enum{ + VENDOR_WRITE = 0x00, + VENDOR_READ = 0x01, +}; +#define ALIGNMENT_UNIT 16 +#define MAX_VENDOR_REQ_CMD_SIZE 254 /* 8188cu SIE Support */ +#define MAX_USB_IO_CTL_SIZE (MAX_VENDOR_REQ_CMD_SIZE + ALIGNMENT_UNIT) + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 12)) +#define rtw_usb_control_msg(dev, pipe, request, requesttype, \ + value, index, data, size, timeout_ms) \ + usb_control_msg((dev), (pipe), (request), (requesttype), (value),\ + (index), (data), (size), (timeout_ms)) +#define rtw_usb_bulk_msg(usb_dev, pipe, data, len, actual_length, timeout_ms) \ + usb_bulk_msg((usb_dev), (pipe), (data), (len), \ + (actual_length), (timeout_ms)) +#else +#define rtw_usb_control_msg(dev, pipe, request, requesttype, \ + value, index, data, size, timeout_ms) \ + usb_control_msg((dev), (pipe), (request), (requesttype), \ + (value), (index), (data), (size), \ + ((timeout_ms) == 0) || \ + ((timeout_ms)*HZ/1000 > 0) ? \ + ((timeout_ms)*HZ/1000) : 1) +#define rtw_usb_bulk_msg(usb_dev, pipe, data, len, \ + actual_length, timeout_ms) \ + usb_bulk_msg((usb_dev), (pipe), (data), (len), (actual_length), \ + ((timeout_ms) == 0) || ((timeout_ms)*HZ/1000 > 0) ?\ + ((timeout_ms)*HZ/1000) : 1) +#endif +#include + +void rtl8188eu_set_hw_type(struct adapter *padapter); +#define hal_set_hw_type rtl8188eu_set_hw_type +void rtl8188eu_set_intf_ops(struct _io_ops *pops); +#define usb_set_intf_ops rtl8188eu_set_intf_ops + +/* + * Increase and check if the continual_urb_error of this @param dvobjprivei + * is larger than MAX_CONTINUAL_URB_ERR + * @return true: + * @return false: + */ +static inline int rtw_inc_and_chk_continual_urb_error(struct dvobj_priv *dvobj) +{ + int ret = false; + int value; + value = ATOMIC_INC_RETURN(&dvobj->continual_urb_error); + if (value > MAX_CONTINUAL_URB_ERR) { + DBG_88E("[dvobj:%p][ERROR] continual_urb_error:%d > %d\n", + dvobj, value, MAX_CONTINUAL_URB_ERR); + ret = true; + } + return ret; +} + +/* +* Set the continual_urb_error of this @param dvobjprive to 0 +*/ +static inline void rtw_reset_continual_urb_error(struct dvobj_priv *dvobj) +{ + ATOMIC_SET(&dvobj->continual_urb_error, 0); +} + +#define USB_HIGH_SPEED_BULK_SIZE 512 +#define USB_FULL_SPEED_BULK_SIZE 64 + +static inline u8 rtw_usb_bulk_size_boundary(struct adapter *padapter, + int buf_len) +{ + u8 rst = true; + struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(padapter); + + if (pdvobjpriv->ishighspeed) + rst = (0 == (buf_len) % USB_HIGH_SPEED_BULK_SIZE) ? + true : false; + else + rst = (0 == (buf_len) % USB_FULL_SPEED_BULK_SIZE) ? + true : false; + return rst; +} + +#endif /* __USB_OPS_H_ */ diff --git a/drivers/staging/rtl8188eu/include/usb_ops_linux.h b/drivers/staging/rtl8188eu/include/usb_ops_linux.h new file mode 100644 index 0000000000000..e5b758a81a5c6 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/usb_ops_linux.h @@ -0,0 +1,55 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __USB_OPS_LINUX_H__ +#define __USB_OPS_LINUX_H__ + +#define VENDOR_CMD_MAX_DATA_LEN 254 + +#define RTW_USB_CONTROL_MSG_TIMEOUT_TEST 10/* ms */ +#define RTW_USB_CONTROL_MSG_TIMEOUT 500/* ms */ + +#define MAX_USBCTRL_VENDORREQ_TIMES 10 + +#define RTW_USB_BULKOUT_TIME 5000/* ms */ + +#define _usbctrl_vendorreq_async_callback(urb, regs) \ + _usbctrl_vendorreq_async_callback(urb) +#define usb_bulkout_zero_complete(purb, regs) \ + usb_bulkout_zero_complete(purb) +#define usb_write_mem_complete(purb, regs) \ + usb_write_mem_complete(purb) +#define usb_write_port_complete(purb, regs) \ + usb_write_port_complete(purb) +#define usb_read_port_complete(purb, regs) \ + usb_read_port_complete(purb) +#define usb_read_interrupt_complete(purb, regs) \ + usb_read_interrupt_complete(purb) + +unsigned int ffaddr2pipehdl(struct dvobj_priv *pdvobj, u32 addr); + +void usb_read_mem(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem); +void usb_write_mem(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem); + +void usb_read_port_cancel(struct intf_hdl *pintfhdl); + +u32 usb_write_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem); +void usb_write_port_cancel(struct intf_hdl *pintfhdl); + +#endif diff --git a/drivers/staging/rtl8188eu/include/usb_osintf.h b/drivers/staging/rtl8188eu/include/usb_osintf.h new file mode 100644 index 0000000000000..9de99ca9799ac --- /dev/null +++ b/drivers/staging/rtl8188eu/include/usb_osintf.h @@ -0,0 +1,45 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __USB_OSINTF_H +#define __USB_OSINTF_H + +#include +#include +#include + +extern char *rtw_initmac; +extern int rtw_mc2u_disable; + +#define USBD_HALTED(Status) ((u32)(Status) >> 30 == 3) + +u8 usbvendorrequest(struct dvobj_priv *pdvobjpriv, enum bt_usb_request brequest, + enum rt_usb_wvalue wvalue, u8 windex, void *data, + u8 datalen, u8 isdirectionin); +int pm_netdev_open(struct net_device *pnetdev, u8 bnormal); +void netdev_br_init(struct net_device *netdev); +void dhcp_flag_bcast(struct adapter *priv, struct sk_buff *skb); +void *scdb_findEntry(struct adapter *priv, unsigned char *macAddr, + unsigned char *ipAddr); +void nat25_db_expire(struct adapter *priv); +int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method); + +int rtw_resume_process(struct adapter *padapter); + +#endif diff --git a/drivers/staging/rtl8188eu/include/usb_vendor_req.h b/drivers/staging/rtl8188eu/include/usb_vendor_req.h new file mode 100644 index 0000000000000..7f26c8f2c78e0 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/usb_vendor_req.h @@ -0,0 +1,52 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef _USB_VENDOR_REQUEST_H_ +#define _USB_VENDOR_REQUEST_H_ + +/* 4 Set/Get Register related wIndex/Data */ +#define RT_USB_RESET_MASK_OFF 0 +#define RT_USB_RESET_MASK_ON 1 +#define RT_USB_SLEEP_MASK_OFF 0 +#define RT_USB_SLEEP_MASK_ON 1 +#define RT_USB_LDO_ON 1 +#define RT_USB_LDO_OFF 0 + +/* 4 Set/Get SYSCLK related wValue or Data */ +#define RT_USB_SYSCLK_32KHZ 0 +#define RT_USB_SYSCLK_40MHZ 1 +#define RT_USB_SYSCLK_60MHZ 2 + + +enum bt_usb_request { + RT_USB_SET_REGISTER = 1, + RT_USB_SET_SYSCLK = 2, + RT_USB_GET_SYSCLK = 3, + RT_USB_GET_REGISTER = 4 +}; + +enum rt_usb_wvalue { + RT_USB_RESET_MASK = 1, + RT_USB_SLEEP_MASK = 2, + RT_USB_USB_HRCPWM = 3, + RT_USB_LDO = 4, + RT_USB_BOOT_TYPE = 5 +}; + +#endif diff --git a/drivers/staging/rtl8188eu/include/wifi.h b/drivers/staging/rtl8188eu/include/wifi.h new file mode 100644 index 0000000000000..a615659f94717 --- /dev/null +++ b/drivers/staging/rtl8188eu/include/wifi.h @@ -0,0 +1,1127 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef _WIFI_H_ +#define _WIFI_H_ + + +#ifdef BIT +/* error "BIT define occurred earlier elsewhere!\n" */ +#undef BIT +#endif +#define BIT(x) (1 << (x)) + + +#define WLAN_ETHHDR_LEN 14 +#define WLAN_ETHADDR_LEN 6 +#define WLAN_IEEE_OUI_LEN 3 +#define WLAN_ADDR_LEN 6 +#define WLAN_CRC_LEN 4 +#define WLAN_BSSID_LEN 6 +#define WLAN_BSS_TS_LEN 8 +#define WLAN_HDR_A3_LEN 24 +#define WLAN_HDR_A4_LEN 30 +#define WLAN_HDR_A3_QOS_LEN 26 +#define WLAN_HDR_A4_QOS_LEN 32 +#define WLAN_SSID_MAXLEN 32 +#define WLAN_DATA_MAXLEN 2312 + +#define WLAN_A3_PN_OFFSET 24 +#define WLAN_A4_PN_OFFSET 30 + +#define WLAN_MIN_ETHFRM_LEN 60 +#define WLAN_MAX_ETHFRM_LEN 1514 +#define WLAN_ETHHDR_LEN 14 + +#define P80211CAPTURE_VERSION 0x80211001 + +/* This value is tested by WiFi 11n Test Plan 5.2.3. */ +/* This test verifies the WLAN NIC can update the NAV through sending + * the CTS with large duration. */ +#define WiFiNavUpperUs 30000 /* 30 ms */ + +enum WIFI_FRAME_TYPE { + WIFI_MGT_TYPE = (0), + WIFI_CTRL_TYPE = (BIT(2)), + WIFI_DATA_TYPE = (BIT(3)), + WIFI_QOS_DATA_TYPE = (BIT(7)|BIT(3)), /* QoS Data */ +}; + +enum WIFI_FRAME_SUBTYPE { + /* below is for mgt frame */ + WIFI_ASSOCREQ = (0 | WIFI_MGT_TYPE), + WIFI_ASSOCRSP = (BIT(4) | WIFI_MGT_TYPE), + WIFI_REASSOCREQ = (BIT(5) | WIFI_MGT_TYPE), + WIFI_REASSOCRSP = (BIT(5) | BIT(4) | WIFI_MGT_TYPE), + WIFI_PROBEREQ = (BIT(6) | WIFI_MGT_TYPE), + WIFI_PROBERSP = (BIT(6) | BIT(4) | WIFI_MGT_TYPE), + WIFI_BEACON = (BIT(7) | WIFI_MGT_TYPE), + WIFI_ATIM = (BIT(7) | BIT(4) | WIFI_MGT_TYPE), + WIFI_DISASSOC = (BIT(7) | BIT(5) | WIFI_MGT_TYPE), + WIFI_AUTH = (BIT(7) | BIT(5) | BIT(4) | WIFI_MGT_TYPE), + WIFI_DEAUTH = (BIT(7) | BIT(6) | WIFI_MGT_TYPE), + WIFI_ACTION = (BIT(7) | BIT(6) | BIT(4) | WIFI_MGT_TYPE), + + /* below is for control frame */ + WIFI_PSPOLL = (BIT(7) | BIT(5) | WIFI_CTRL_TYPE), + WIFI_RTS = (BIT(7) | BIT(5) | BIT(4) | WIFI_CTRL_TYPE), + WIFI_CTS = (BIT(7) | BIT(6) | WIFI_CTRL_TYPE), + WIFI_ACK = (BIT(7) | BIT(6) | BIT(4) | WIFI_CTRL_TYPE), + WIFI_CFEND = (BIT(7) | BIT(6) | BIT(5) | WIFI_CTRL_TYPE), + WIFI_CFEND_CFACK = (BIT(7) | BIT(6) | BIT(5) | BIT(4) | + WIFI_CTRL_TYPE), + + /* below is for data frame */ + WIFI_DATA = (0 | WIFI_DATA_TYPE), + WIFI_DATA_CFACK = (BIT(4) | WIFI_DATA_TYPE), + WIFI_DATA_CFPOLL = (BIT(5) | WIFI_DATA_TYPE), + WIFI_DATA_CFACKPOLL = (BIT(5) | BIT(4) | WIFI_DATA_TYPE), + WIFI_DATA_NULL = (BIT(6) | WIFI_DATA_TYPE), + WIFI_CF_ACK = (BIT(6) | BIT(4) | WIFI_DATA_TYPE), + WIFI_CF_POLL = (BIT(6) | BIT(5) | WIFI_DATA_TYPE), + WIFI_CF_ACKPOLL = (BIT(6) | BIT(5) | BIT(4) | WIFI_DATA_TYPE), + WIFI_QOS_DATA_NULL = (BIT(6) | WIFI_QOS_DATA_TYPE), +}; + +enum WIFI_REASON_CODE { + _RSON_RESERVED_ = 0, + _RSON_UNSPECIFIED_ = 1, + _RSON_AUTH_NO_LONGER_VALID_ = 2, + _RSON_DEAUTH_STA_LEAVING_ = 3, + _RSON_INACTIVITY_ = 4, + _RSON_UNABLE_HANDLE_ = 5, + _RSON_CLS2_ = 6, + _RSON_CLS3_ = 7, + _RSON_DISAOC_STA_LEAVING_ = 8, + _RSON_ASOC_NOT_AUTH_ = 9, + + /* WPA reason */ + _RSON_INVALID_IE_ = 13, + _RSON_MIC_FAILURE_ = 14, + _RSON_4WAY_HNDSHK_TIMEOUT_ = 15, + _RSON_GROUP_KEY_UPDATE_TIMEOUT_ = 16, + _RSON_DIFF_IE_ = 17, + _RSON_MLTCST_CIPHER_NOT_VALID_ = 18, + _RSON_UNICST_CIPHER_NOT_VALID_ = 19, + _RSON_AKMP_NOT_VALID_ = 20, + _RSON_UNSUPPORT_RSNE_VER_ = 21, + _RSON_INVALID_RSNE_CAP_ = 22, + _RSON_IEEE_802DOT1X_AUTH_FAIL_ = 23, + + /* belowing are Realtek definition */ + _RSON_PMK_NOT_AVAILABLE_ = 24, + _RSON_TDLS_TEAR_TOOFAR_ = 25, + _RSON_TDLS_TEAR_UN_RSN_ = 26, +}; + +/* Reason codes (IEEE 802.11-2007, 7.3.1.7, Table 7-22) + +#define WLAN_REASON_UNSPECIFIED 1 +#define WLAN_REASON_PREV_AUTH_NOT_VALID 2 +#define WLAN_REASON_DEAUTH_LEAVING 3 +#define WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY 4 +#define WLAN_REASON_DISASSOC_AP_BUSY 5 +#define WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA 6 +#define WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA 7 +#define WLAN_REASON_DISASSOC_STA_HAS_LEFT 8 +#define WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH 9 */ +/* IEEE 802.11h */ +#define WLAN_REASON_PWR_CAPABILITY_NOT_VALID 10 +#define WLAN_REASON_SUPPORTED_CHANNEL_NOT_VALID 11 + +/* IEEE 802.11i +#define WLAN_REASON_INVALID_IE 13 +#define WLAN_REASON_MICHAEL_MIC_FAILURE 14 +#define WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT 15 +#define WLAN_REASON_GROUP_KEY_UPDATE_TIMEOUT 16 +#define WLAN_REASON_IE_IN_4WAY_DIFFERS 17 +#define WLAN_REASON_GROUP_CIPHER_NOT_VALID 18 +#define WLAN_REASON_PAIRWISE_CIPHER_NOT_VALID 19 +#define WLAN_REASON_AKMP_NOT_VALID 20 +#define WLAN_REASON_UNSUPPORTED_RSN_IE_VERSION 21 +#define WLAN_REASON_INVALID_RSN_IE_CAPAB 22 +#define WLAN_REASON_IEEE_802_1X_AUTH_FAILED 23 +#define WLAN_REASON_CIPHER_SUITE_REJECTED 24 */ + +enum WIFI_STATUS_CODE { + _STATS_SUCCESSFUL_ = 0, + _STATS_FAILURE_ = 1, + _STATS_CAP_FAIL_ = 10, + _STATS_NO_ASOC_ = 11, + _STATS_OTHER_ = 12, + _STATS_NO_SUPP_ALG_ = 13, + _STATS_OUT_OF_AUTH_SEQ_ = 14, + _STATS_CHALLENGE_FAIL_ = 15, + _STATS_AUTH_TIMEOUT_ = 16, + _STATS_UNABLE_HANDLE_STA_ = 17, + _STATS_RATE_FAIL_ = 18, +}; + +/* Status codes (IEEE 802.11-2007, 7.3.1.9, Table 7-23) +#define WLAN_STATUS_SUCCESS 0 +#define WLAN_STATUS_UNSPECIFIED_FAILURE 1 +#define WLAN_STATUS_CAPS_UNSUPPORTED 10 +#define WLAN_STATUS_REASSOC_NO_ASSOC 11 +#define WLAN_STATUS_ASSOC_DENIED_UNSPEC 12 +#define WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG 13 +#define WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION 14 +#define WLAN_STATUS_CHALLENGE_FAIL 15 +#define WLAN_STATUS_AUTH_TIMEOUT 16 +#define WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA 17 +#define WLAN_STATUS_ASSOC_DENIED_RATES 18 */ + +/* entended */ +/* IEEE 802.11b */ +#define WLAN_STATUS_ASSOC_DENIED_NOSHORT 19 +#define WLAN_STATUS_ASSOC_DENIED_NOPBCC 20 +#define WLAN_STATUS_ASSOC_DENIED_NOAGILITY 21 +/* IEEE 802.11h */ +#define WLAN_STATUS_SPEC_MGMT_REQUIRED 22 +#define WLAN_STATUS_PWR_CAPABILITY_NOT_VALID 23 +#define WLAN_STATUS_SUPPORTED_CHANNEL_NOT_VALID 24 +/* IEEE 802.11g */ +#define WLAN_STATUS_ASSOC_DENIED_NO_SHORT_SLOT_TIME 25 +#define WLAN_STATUS_ASSOC_DENIED_NO_ER_PBCC 26 +#define WLAN_STATUS_ASSOC_DENIED_NO_DSSS_OFDM 27 +/* IEEE 802.11w */ +#define WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY 30 +#define WLAN_STATUS_ROBUST_MGMT_FRAME_POLICY_VIOLATION 31 +/* IEEE 802.11i */ +#define WLAN_STATUS_INVALID_IE 40 +#define WLAN_STATUS_GROUP_CIPHER_NOT_VALID 41 +#define WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID 42 +#define WLAN_STATUS_AKMP_NOT_VALID 43 +#define WLAN_STATUS_UNSUPPORTED_RSN_IE_VERSION 44 +#define WLAN_STATUS_INVALID_RSN_IE_CAPAB 45 +#define WLAN_STATUS_CIPHER_REJECTED_PER_POLICY 46 +#define WLAN_STATUS_TS_NOT_CREATED 47 +#define WLAN_STATUS_DIRECT_LINK_NOT_ALLOWED 48 +#define WLAN_STATUS_DEST_STA_NOT_PRESENT 49 +#define WLAN_STATUS_DEST_STA_NOT_QOS_STA 50 +#define WLAN_STATUS_ASSOC_DENIED_LISTEN_INT_TOO_LARGE 51 +/* IEEE 802.11r */ +#define WLAN_STATUS_INVALID_FT_ACTION_FRAME_COUNT 52 +#define WLAN_STATUS_INVALID_PMKID 53 +#define WLAN_STATUS_INVALID_MDIE 54 +#define WLAN_STATUS_INVALID_FTIE 55 + +enum WIFI_REG_DOMAIN { + DOMAIN_FCC = 1, + DOMAIN_IC = 2, + DOMAIN_ETSI = 3, + DOMAIN_SPA = 4, + DOMAIN_FRANCE = 5, + DOMAIN_MKK = 6, + DOMAIN_ISRAEL = 7, + DOMAIN_MKK1 = 8, + DOMAIN_MKK2 = 9, + DOMAIN_MKK3 = 10, + DOMAIN_MAX +}; + +#define _TO_DS_ BIT(8) +#define _FROM_DS_ BIT(9) +#define _MORE_FRAG_ BIT(10) +#define _RETRY_ BIT(11) +#define _PWRMGT_ BIT(12) +#define _MORE_DATA_ BIT(13) +#define _PRIVACY_ BIT(14) +#define _ORDER_ BIT(15) + +#define SetToDs(pbuf) \ + *(__le16 *)(pbuf) |= cpu_to_le16(_TO_DS_) + +#define GetToDs(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(_TO_DS_)) != 0) + +#define ClearToDs(pbuf) \ + *(__le16 *)(pbuf) &= (~cpu_to_le16(_TO_DS_)) + +#define SetFrDs(pbuf) \ + *(__le16 *)(pbuf) |= cpu_to_le16(_FROM_DS_) + +#define GetFrDs(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(_FROM_DS_)) != 0) + +#define ClearFrDs(pbuf) \ + *(__le16 *)(pbuf) &= (~cpu_to_le16(_FROM_DS_)) + +#define get_tofr_ds(pframe) ((GetToDs(pframe) << 1) | GetFrDs(pframe)) + + +#define SetMFrag(pbuf) \ + *(__le16 *)(pbuf) |= cpu_to_le16(_MORE_FRAG_) + +#define GetMFrag(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(_MORE_FRAG_)) != 0) + +#define ClearMFrag(pbuf) \ + *(__le16 *)(pbuf) &= (~cpu_to_le16(_MORE_FRAG_)) + +#define SetRetry(pbuf) \ + *(__le16 *)(pbuf) |= cpu_to_le16(_RETRY_) + +#define GetRetry(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(_RETRY_)) != 0) + +#define ClearRetry(pbuf) \ + *(__le16 *)(pbuf) &= (~cpu_to_le16(_RETRY_)) + +#define SetPwrMgt(pbuf) \ + *(__le16 *)(pbuf) |= cpu_to_le16(_PWRMGT_) + +#define GetPwrMgt(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(_PWRMGT_)) != 0) + +#define ClearPwrMgt(pbuf) \ + *(__le16 *)(pbuf) &= (~cpu_to_le16(_PWRMGT_)) + +#define SetMData(pbuf) \ + *(__le16 *)(pbuf) |= cpu_to_le16(_MORE_DATA_) + +#define GetMData(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(_MORE_DATA_)) != 0) + +#define ClearMData(pbuf) \ + *(__le16 *)(pbuf) &= (~cpu_to_le16(_MORE_DATA_)) + +#define SetPrivacy(pbuf) \ + *(__le16 *)(pbuf) |= cpu_to_le16(_PRIVACY_) + +#define GetPrivacy(pbuf) \ + (((*(__le16 *)(pbuf)) & cpu_to_le16(_PRIVACY_)) != 0) + +#define ClearPrivacy(pbuf) \ + *(__le16 *)(pbuf) &= (~cpu_to_le16(_PRIVACY_)) + + +#define GetOrder(pbuf) \ + (((*(__le16 *)(pbuf)) & cpu_to_le16(_ORDER_)) != 0) + +#define GetFrameType(pbuf) \ + (le16_to_cpu(*(__le16 *)(pbuf)) & (BIT(3) | BIT(2))) + +#define SetFrameType(pbuf, type) \ + do { \ + *(unsigned short *)(pbuf) &= __constant_cpu_to_le16(~(BIT(3) | BIT(2))); \ + *(unsigned short *)(pbuf) |= __constant_cpu_to_le16(type); \ + } while (0) + +#define GetFrameSubType(pbuf) (le16_to_cpu(*(__le16 *)(pbuf)) & (BIT(7) |\ + BIT(6) | BIT(5) | BIT(4) | BIT(3) | BIT(2))) + +#define SetFrameSubType(pbuf, type) \ + do { \ + *(__le16 *)(pbuf) &= cpu_to_le16(~(BIT(7) | BIT(6) | \ + BIT(5) | BIT(4) | BIT(3) | BIT(2))); \ + *(__le16 *)(pbuf) |= cpu_to_le16(type); \ + } while (0) + +#define GetSequence(pbuf) \ + (le16_to_cpu(*(__le16 *)((size_t)(pbuf) + 22)) >> 4) + +#define GetFragNum(pbuf) \ + (le16_to_cpu(*(__le16 *)((size_t)(pbuf) + 22)) & 0x0f) + +#define GetTupleCache(pbuf) \ + (cpu_to_le16(*(unsigned short *)((size_t)(pbuf) + 22))) + +#define SetFragNum(pbuf, num) \ + do { \ + *(unsigned short *)((size_t)(pbuf) + 22) = \ + ((*(unsigned short *)((size_t)(pbuf) + 22)) & \ + le16_to_cpu(~(0x000f))) | \ + cpu_to_le16(0x0f & (num)); \ + } while (0) + +#define SetSeqNum(pbuf, num) \ + do { \ + *(__le16 *)((size_t)(pbuf) + 22) = \ + ((*(__le16 *)((size_t)(pbuf) + 22)) & cpu_to_le16((unsigned short)0x000f)) | \ + cpu_to_le16((unsigned short)(0xfff0 & (num << 4))); \ + } while (0) + +#define SetDuration(pbuf, dur) \ + *(__le16 *)((size_t)(pbuf) + 2) = cpu_to_le16(0xffff & (dur)) + + +#define SetPriority(pbuf, tid) \ + *(__le16 *)(pbuf) |= cpu_to_le16(tid & 0xf) + +#define GetPriority(pbuf) ((le16_to_cpu(*(__le16 *)(pbuf))) & 0xf) + +#define SetEOSP(pbuf, eosp) \ + *(__le16 *)(pbuf) |= cpu_to_le16((eosp & 1) << 4) + +#define SetAckpolicy(pbuf, ack) \ + *(__le16 *)(pbuf) |= cpu_to_le16((ack & 3) << 5) + +#define GetAckpolicy(pbuf) (((le16_to_cpu(*(__le16 *)pbuf)) >> 5) & 0x3) + +#define GetAMsdu(pbuf) (((le16_to_cpu(*(__le16 *)pbuf)) >> 7) & 0x1) + +#define SetAMsdu(pbuf, amsdu) \ + *(__le16 *)(pbuf) |= cpu_to_le16((amsdu & 1) << 7) + +#define GetAid(pbuf) (le16_to_cpu(*(__le16 *)((size_t)(pbuf) + 2)) & 0x3fff) + +#define GetTid(pbuf) (le16_to_cpu(*(__le16 *)((size_t)(pbuf) + \ + (((GetToDs(pbuf)<<1) | GetFrDs(pbuf)) == 3 ? \ + 30 : 24))) & 0x000f) + +#define GetAddr1Ptr(pbuf) ((unsigned char *)((size_t)(pbuf) + 4)) + +#define GetAddr2Ptr(pbuf) ((unsigned char *)((size_t)(pbuf) + 10)) + +#define GetAddr3Ptr(pbuf) ((unsigned char *)((size_t)(pbuf) + 16)) + +#define GetAddr4Ptr(pbuf) ((unsigned char *)((size_t)(pbuf) + 24)) + +#define MacAddr_isBcst(addr) \ + ( \ + ((addr[0] == 0xff) && (addr[1] == 0xff) && \ + (addr[2] == 0xff) && (addr[3] == 0xff) && \ + (addr[4] == 0xff) && (addr[5] == 0xff)) ? true : false \ +) + +static inline int IS_MCAST(unsigned char *da) +{ + if ((*da) & 0x01) + return true; + else + return false; +} + +static inline unsigned char *get_da(unsigned char *pframe) +{ + unsigned char *da; + unsigned int to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe); + + switch (to_fr_ds) { + case 0x00: /* ToDs=0, FromDs=0 */ + da = GetAddr1Ptr(pframe); + break; + case 0x01: /* ToDs=0, FromDs=1 */ + da = GetAddr1Ptr(pframe); + break; + case 0x02: /* ToDs=1, FromDs=0 */ + da = GetAddr3Ptr(pframe); + break; + default: /* ToDs=1, FromDs=1 */ + da = GetAddr3Ptr(pframe); + break; + } + return da; +} + +static inline unsigned char *get_sa(unsigned char *pframe) +{ + unsigned char *sa; + unsigned int to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe); + + switch (to_fr_ds) { + case 0x00: /* ToDs=0, FromDs=0 */ + sa = GetAddr2Ptr(pframe); + break; + case 0x01: /* ToDs=0, FromDs=1 */ + sa = GetAddr3Ptr(pframe); + break; + case 0x02: /* ToDs=1, FromDs=0 */ + sa = GetAddr2Ptr(pframe); + break; + default: /* ToDs=1, FromDs=1 */ + sa = GetAddr4Ptr(pframe); + break; + } + return sa; +} + +static inline unsigned char *get_hdr_bssid(unsigned char *pframe) +{ + unsigned char *sa; + unsigned int to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe); + + switch (to_fr_ds) { + case 0x00: /* ToDs=0, FromDs=0 */ + sa = GetAddr3Ptr(pframe); + break; + case 0x01: /* ToDs=0, FromDs=1 */ + sa = GetAddr2Ptr(pframe); + break; + case 0x02: /* ToDs=1, FromDs=0 */ + sa = GetAddr1Ptr(pframe); + break; + case 0x03: /* ToDs=1, FromDs=1 */ + sa = GetAddr1Ptr(pframe); + break; + default: + sa = NULL; /* */ + break; + } + return sa; +} + +static inline int IsFrameTypeCtrl(unsigned char *pframe) +{ + if (WIFI_CTRL_TYPE == GetFrameType(pframe)) + return true; + else + return false; +} +/*----------------------------------------------------------------------------- + Below is for the security related definition +------------------------------------------------------------------------------*/ +#define _RESERVED_FRAME_TYPE_ 0 +#define _SKB_FRAME_TYPE_ 2 +#define _PRE_ALLOCMEM_ 1 +#define _PRE_ALLOCHDR_ 3 +#define _PRE_ALLOCLLCHDR_ 4 +#define _PRE_ALLOCICVHDR_ 5 +#define _PRE_ALLOCMICHDR_ 6 + +#define _SIFSTIME_ \ + ((priv->pmib->dot11BssType.net_work_type & WIRELESS_11A) ? 16 : 10) +#define _ACKCTSLNG_ 14 /* 14 bytes long, including crclng */ +#define _CRCLNG_ 4 + +#define _ASOCREQ_IE_OFFSET_ 4 /* excluding wlan_hdr */ +#define _ASOCRSP_IE_OFFSET_ 6 +#define _REASOCREQ_IE_OFFSET_ 10 +#define _REASOCRSP_IE_OFFSET_ 6 +#define _PROBEREQ_IE_OFFSET_ 0 +#define _PROBERSP_IE_OFFSET_ 12 +#define _AUTH_IE_OFFSET_ 6 +#define _DEAUTH_IE_OFFSET_ 0 +#define _BEACON_IE_OFFSET_ 12 +#define _PUBLIC_ACTION_IE_OFFSET_ 8 + +#define _FIXED_IE_LENGTH_ _BEACON_IE_OFFSET_ + +#define _SSID_IE_ 0 +#define _SUPPORTEDRATES_IE_ 1 +#define _DSSET_IE_ 3 +#define _TIM_IE_ 5 +#define _IBSS_PARA_IE_ 6 +#define _COUNTRY_IE_ 7 +#define _CHLGETXT_IE_ 16 +#define _SUPPORTED_CH_IE_ 36 +#define _CH_SWTICH_ANNOUNCE_ 37 /* Secondary Channel Offset */ +#define _RSN_IE_2_ 48 +#define _SSN_IE_1_ 221 +#define _ERPINFO_IE_ 42 +#define _EXT_SUPPORTEDRATES_IE_ 50 + +#define _HT_CAPABILITY_IE_ 45 +#define _FTIE_ 55 +#define _TIMEOUT_ITVL_IE_ 56 +#define _SRC_IE_ 59 +#define _HT_EXTRA_INFO_IE_ 61 +#define _HT_ADD_INFO_IE_ 61 /* _HT_EXTRA_INFO_IE_ */ +#define _WAPI_IE_ 68 + + +#define EID_BSSCoexistence 72 /* 20/40 BSS Coexistence */ +#define EID_BSSIntolerantChlReport 73 +#define _RIC_Descriptor_IE_ 75 + +#define _LINK_ID_IE_ 101 +#define _CH_SWITCH_TIMING_ 104 +#define _PTI_BUFFER_STATUS_ 106 +#define _EXT_CAP_IE_ 127 +#define _VENDOR_SPECIFIC_IE_ 221 + +#define _RESERVED47_ 47 + +/* --------------------------------------------------------------------------- + Below is the fixed elements... +-----------------------------------------------------------------------------*/ +#define _AUTH_ALGM_NUM_ 2 +#define _AUTH_SEQ_NUM_ 2 +#define _BEACON_ITERVAL_ 2 +#define _CAPABILITY_ 2 +#define _CURRENT_APADDR_ 6 +#define _LISTEN_INTERVAL_ 2 +#define _RSON_CODE_ 2 +#define _ASOC_ID_ 2 +#define _STATUS_CODE_ 2 +#define _TIMESTAMP_ 8 + +#define AUTH_ODD_TO 0 +#define AUTH_EVEN_TO 1 + +#define WLAN_ETHCONV_ENCAP 1 +#define WLAN_ETHCONV_RFC1042 2 +#define WLAN_ETHCONV_8021h 3 + +#define cap_ESS BIT(0) +#define cap_IBSS BIT(1) +#define cap_CFPollable BIT(2) +#define cap_CFRequest BIT(3) +#define cap_Privacy BIT(4) +#define cap_ShortPremble BIT(5) +#define cap_PBCC BIT(6) +#define cap_ChAgility BIT(7) +#define cap_SpecMgmt BIT(8) +#define cap_QoSi BIT(9) +#define cap_ShortSlot BIT(10) + +/*----------------------------------------------------------------------------- + Below is the definition for 802.11i / 802.1x +------------------------------------------------------------------------------*/ +#define _IEEE8021X_MGT_ 1 /* WPA */ +#define _IEEE8021X_PSK_ 2 /* WPA with pre-shared key */ + +/* +#define _NO_PRIVACY_ 0 +#define _WEP_40_PRIVACY_ 1 +#define _TKIP_PRIVACY_ 2 +#define _WRAP_PRIVACY_ 3 +#define _CCMP_PRIVACY_ 4 +#define _WEP_104_PRIVACY_ 5 +#define _WEP_WPA_MIXED_PRIVACY_ 6 WEP + WPA +*/ + +/*----------------------------------------------------------------------------- + Below is the definition for WMM +------------------------------------------------------------------------------*/ +#define _WMM_IE_Length_ 7 /* for WMM STA */ +#define _WMM_Para_Element_Length_ 24 + + +/*----------------------------------------------------------------------------- + Below is the definition for 802.11n +------------------------------------------------------------------------------*/ + +#define SetOrderBit(pbuf) \ + do { \ + *(unsigned short *)(pbuf) |= cpu_to_le16(_ORDER_); \ + } while (0) + +#define GetOrderBit(pbuf) \ + (((*(unsigned short *)(pbuf)) & le16_to_cpu(_ORDER_)) != 0) + + +/** + * struct rtw_ieee80211_bar - HT Block Ack Request + * + * This structure refers to "HT BlockAckReq" as + * described in 802.11n draft section 7.2.1.7.1 + */ +struct rtw_ieee80211_bar { + unsigned short frame_control; + unsigned short duration; + unsigned char ra[6]; + unsigned char ta[6]; + unsigned short control; + unsigned short start_seq_num; +} __packed; + +/* 802.11 BAR control masks */ +#define IEEE80211_BAR_CTRL_ACK_POLICY_NORMAL 0x0000 +#define IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA 0x0004 + + /** + * struct rtw_ieee80211_ht_cap - HT capabilities + * + * This structure refers to "HT capabilities element" as + * described in 802.11n draft section 7.3.2.52 + */ + +struct rtw_ieee80211_ht_cap { + unsigned short cap_info; + unsigned char ampdu_params_info; + unsigned char supp_mcs_set[16]; + unsigned short extended_ht_cap_info; + unsigned int tx_BF_cap_info; + unsigned char antenna_selection_info; +} __packed; + +/** + * struct rtw_ieee80211_ht_cap - HT additional information + * + * This structure refers to "HT information element" as + * described in 802.11n draft section 7.3.2.53 + */ +struct ieee80211_ht_addt_info { + unsigned char control_chan; + unsigned char ht_param; + unsigned short operation_mode; + unsigned short stbc_param; + unsigned char basic_set[16]; +} __packed; + +struct HT_caps_element { + union { + struct { + __le16 HT_caps_info; + unsigned char AMPDU_para; + unsigned char MCS_rate[16]; + unsigned short HT_ext_caps; + unsigned int Beamforming_caps; + unsigned char ASEL_caps; + } HT_cap_element; + unsigned char HT_cap[26]; + } u; +} __packed; + +struct HT_info_element { + unsigned char primary_channel; + unsigned char infos[5]; + unsigned char MCS_rate[16]; +} __packed; + +struct AC_param { + unsigned char ACI_AIFSN; + unsigned char CW; + __le16 TXOP_limit; +} __packed; + +struct WMM_para_element { + unsigned char QoS_info; + unsigned char reserved; + struct AC_param ac_param[4]; +} __packed; + +struct ADDBA_request { + unsigned char dialog_token; + unsigned short BA_para_set; + unsigned short BA_timeout_value; + unsigned short BA_starting_seqctrl; +} __packed; + +enum ht_cap_ampdu_factor { + MAX_AMPDU_FACTOR_8K = 0, + MAX_AMPDU_FACTOR_16K = 1, + MAX_AMPDU_FACTOR_32K = 2, + MAX_AMPDU_FACTOR_64K = 3, +}; + +/* 802.11n HT capabilities masks */ +#define IEEE80211_HT_CAP_SUP_WIDTH 0x0002 +#define IEEE80211_HT_CAP_SM_PS 0x000C +#define IEEE80211_HT_CAP_GRN_FLD 0x0010 +#define IEEE80211_HT_CAP_SGI_20 0x0020 +#define IEEE80211_HT_CAP_SGI_40 0x0040 +#define IEEE80211_HT_CAP_TX_STBC 0x0080 +#define IEEE80211_HT_CAP_RX_STBC 0x0300 +#define IEEE80211_HT_CAP_DELAY_BA 0x0400 +#define IEEE80211_HT_CAP_MAX_AMSDU 0x0800 +#define IEEE80211_HT_CAP_DSSSCCK40 0x1000 +/* 802.11n HT capability AMPDU settings */ +#define IEEE80211_HT_CAP_AMPDU_FACTOR 0x03 +#define IEEE80211_HT_CAP_AMPDU_DENSITY 0x1C +/* 802.11n HT capability MSC set */ +#define IEEE80211_SUPP_MCS_SET_UEQM 4 +#define IEEE80211_HT_CAP_MAX_STREAMS 4 +#define IEEE80211_SUPP_MCS_SET_LEN 10 +/* maximum streams the spec allows */ +#define IEEE80211_HT_CAP_MCS_TX_DEFINED 0x01 +#define IEEE80211_HT_CAP_MCS_TX_RX_DIFF 0x02 +#define IEEE80211_HT_CAP_MCS_TX_STREAMS 0x0C +#define IEEE80211_HT_CAP_MCS_TX_UEQM 0x10 +/* 802.11n HT IE masks */ +#define IEEE80211_HT_IE_CHA_SEC_OFFSET 0x03 +#define IEEE80211_HT_IE_CHA_SEC_NONE 0x00 +#define IEEE80211_HT_IE_CHA_SEC_ABOVE 0x01 +#define IEEE80211_HT_IE_CHA_SEC_BELOW 0x03 +#define IEEE80211_HT_IE_CHA_WIDTH 0x04 +#define IEEE80211_HT_IE_HT_PROTECTION 0x0003 +#define IEEE80211_HT_IE_NON_GF_STA_PRSNT 0x0004 +#define IEEE80211_HT_IE_NON_HT_STA_PRSNT 0x0010 + +/* block-ack parameters */ +#define IEEE80211_ADDBA_PARAM_POLICY_MASK 0x0002 +#define IEEE80211_ADDBA_PARAM_TID_MASK 0x003C +#define RTW_IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK 0xFFC0 +#define IEEE80211_DELBA_PARAM_TID_MASK 0xF000 +#define IEEE80211_DELBA_PARAM_INITIATOR_MASK 0x0800 + +/* + * A-PMDU buffer sizes + * According to IEEE802.11n spec size varies from 8K to 64K (in powers of 2) + */ +#define IEEE80211_MIN_AMPDU_BUF 0x8 +#define IEEE80211_MAX_AMPDU_BUF 0x40 + + +/* Spatial Multiplexing Power Save Modes */ +#define WLAN_HT_CAP_SM_PS_STATIC 0 +#define WLAN_HT_CAP_SM_PS_DYNAMIC 1 +#define WLAN_HT_CAP_SM_PS_INVALID 2 +#define WLAN_HT_CAP_SM_PS_DISABLED 3 + + +#define OP_MODE_PURE 0 +#define OP_MODE_MAY_BE_LEGACY_STAS 1 +#define OP_MODE_20MHZ_HT_STA_ASSOCED 2 +#define OP_MODE_MIXED 3 + +#define HT_INFO_HT_PARAM_SECONDARY_CHNL_OFF_MASK ((u8) BIT(0) | BIT(1)) +#define HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE ((u8) BIT(0)) +#define HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW ((u8) BIT(0) | BIT(1)) +#define HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH ((u8) BIT(2)) +#define HT_INFO_HT_PARAM_RIFS_MODE ((u8) BIT(3)) +#define HT_INFO_HT_PARAM_CTRL_ACCESS_ONLY ((u8) BIT(4)) +#define HT_INFO_HT_PARAM_SRV_INTERVAL_GRANULARITY ((u8) BIT(5)) + +#define HT_INFO_OPERATION_MODE_OP_MODE_MASK \ + ((u16) (0x0001 | 0x0002)) +#define HT_INFO_OPERATION_MODE_OP_MODE_OFFSET 0 +#define HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT ((u8) BIT(2)) +#define HT_INFO_OPERATION_MODE_TRANSMIT_BURST_LIMIT ((u8) BIT(3)) +#define HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT ((u8) BIT(4)) + +#define HT_INFO_STBC_PARAM_DUAL_BEACON ((u16) BIT(6)) +#define HT_INFO_STBC_PARAM_DUAL_STBC_PROTECT ((u16) BIT(7)) +#define HT_INFO_STBC_PARAM_SECONDARY_BC ((u16) BIT(8)) +#define HT_INFO_STBC_PARAM_LSIG_TXOP_PROTECT_ALLOWED ((u16) BIT(9)) +#define HT_INFO_STBC_PARAM_PCO_ACTIVE ((u16) BIT(10)) +#define HT_INFO_STBC_PARAM_PCO_PHASE ((u16) BIT(11)) + +/* ===============WPS Section=============== */ +/* For WPSv1.0 */ +#define WPSOUI 0x0050f204 +/* WPS attribute ID */ +#define WPS_ATTR_VER1 0x104A +#define WPS_ATTR_SIMPLE_CONF_STATE 0x1044 +#define WPS_ATTR_RESP_TYPE 0x103B +#define WPS_ATTR_UUID_E 0x1047 +#define WPS_ATTR_MANUFACTURER 0x1021 +#define WPS_ATTR_MODEL_NAME 0x1023 +#define WPS_ATTR_MODEL_NUMBER 0x1024 +#define WPS_ATTR_SERIAL_NUMBER 0x1042 +#define WPS_ATTR_PRIMARY_DEV_TYPE 0x1054 +#define WPS_ATTR_SEC_DEV_TYPE_LIST 0x1055 +#define WPS_ATTR_DEVICE_NAME 0x1011 +#define WPS_ATTR_CONF_METHOD 0x1008 +#define WPS_ATTR_RF_BANDS 0x103C +#define WPS_ATTR_DEVICE_PWID 0x1012 +#define WPS_ATTR_REQUEST_TYPE 0x103A +#define WPS_ATTR_ASSOCIATION_STATE 0x1002 +#define WPS_ATTR_CONFIG_ERROR 0x1009 +#define WPS_ATTR_VENDOR_EXT 0x1049 +#define WPS_ATTR_SELECTED_REGISTRAR 0x1041 + +/* Value of WPS attribute "WPS_ATTR_DEVICE_NAME */ +#define WPS_MAX_DEVICE_NAME_LEN 32 + +/* Value of WPS Request Type Attribute */ +#define WPS_REQ_TYPE_ENROLLEE_INFO_ONLY 0x00 +#define WPS_REQ_TYPE_ENROLLEE_OPEN_8021X 0x01 +#define WPS_REQ_TYPE_REGISTRAR 0x02 +#define WPS_REQ_TYPE_WLAN_MANAGER_REGISTRAR 0x03 + +/* Value of WPS Response Type Attribute */ +#define WPS_RESPONSE_TYPE_INFO_ONLY 0x00 +#define WPS_RESPONSE_TYPE_8021X 0x01 +#define WPS_RESPONSE_TYPE_REGISTRAR 0x02 +#define WPS_RESPONSE_TYPE_AP 0x03 + +/* Value of WPS WiFi Simple Configuration State Attribute */ +#define WPS_WSC_STATE_NOT_CONFIG 0x01 +#define WPS_WSC_STATE_CONFIG 0x02 + +/* Value of WPS Version Attribute */ +#define WPS_VERSION_1 0x10 + +/* Value of WPS Configuration Method Attribute */ +#define WPS_CONFIG_METHOD_FLASH 0x0001 +#define WPS_CONFIG_METHOD_ETHERNET 0x0002 +#define WPS_CONFIG_METHOD_LABEL 0x0004 +#define WPS_CONFIG_METHOD_DISPLAY 0x0008 +#define WPS_CONFIG_METHOD_E_NFC 0x0010 +#define WPS_CONFIG_METHOD_I_NFC 0x0020 +#define WPS_CONFIG_METHOD_NFC 0x0040 +#define WPS_CONFIG_METHOD_PBC 0x0080 +#define WPS_CONFIG_METHOD_KEYPAD 0x0100 +#define WPS_CONFIG_METHOD_VPBC 0x0280 +#define WPS_CONFIG_METHOD_PPBC 0x0480 +#define WPS_CONFIG_METHOD_VDISPLAY 0x2008 +#define WPS_CONFIG_METHOD_PDISPLAY 0x4008 + +/* Value of Category ID of WPS Primary Device Type Attribute */ +#define WPS_PDT_CID_DISPLAYS 0x0007 +#define WPS_PDT_CID_MULIT_MEDIA 0x0008 +#define WPS_PDT_CID_RTK_WIDI WPS_PDT_CID_MULIT_MEDIA + +/* Value of Sub Category ID of WPS Primary Device Type Attribute */ +#define WPS_PDT_SCID_MEDIA_SERVER 0x0005 +#define WPS_PDT_SCID_RTK_DMP WPS_PDT_SCID_MEDIA_SERVER + +/* Value of Device Password ID */ +#define WPS_DPID_P 0x0000 +#define WPS_DPID_USER_SPEC 0x0001 +#define WPS_DPID_MACHINE_SPEC 0x0002 +#define WPS_DPID_REKEY 0x0003 +#define WPS_DPID_PBC 0x0004 +#define WPS_DPID_REGISTRAR_SPEC 0x0005 + +/* Value of WPS RF Bands Attribute */ +#define WPS_RF_BANDS_2_4_GHZ 0x01 +#define WPS_RF_BANDS_5_GHZ 0x02 + +/* Value of WPS Association State Attribute */ +#define WPS_ASSOC_STATE_NOT_ASSOCIATED 0x00 +#define WPS_ASSOC_STATE_CONNECTION_SUCCESS 0x01 +#define WPS_ASSOC_STATE_CONFIGURATION_FAILURE 0x02 +#define WPS_ASSOC_STATE_ASSOCIATION_FAILURE 0x03 +#define WPS_ASSOC_STATE_IP_FAILURE 0x04 + +/* =====================P2P Section===================== */ +/* For P2P */ +#define P2POUI 0x506F9A09 + +/* P2P Attribute ID */ +#define P2P_ATTR_STATUS 0x00 +#define P2P_ATTR_MINOR_REASON_CODE 0x01 +#define P2P_ATTR_CAPABILITY 0x02 +#define P2P_ATTR_DEVICE_ID 0x03 +#define P2P_ATTR_GO_INTENT 0x04 +#define P2P_ATTR_CONF_TIMEOUT 0x05 +#define P2P_ATTR_LISTEN_CH 0x06 +#define P2P_ATTR_GROUP_BSSID 0x07 +#define P2P_ATTR_EX_LISTEN_TIMING 0x08 +#define P2P_ATTR_INTENTED_IF_ADDR 0x09 +#define P2P_ATTR_MANAGEABILITY 0x0A +#define P2P_ATTR_CH_LIST 0x0B +#define P2P_ATTR_NOA 0x0C +#define P2P_ATTR_DEVICE_INFO 0x0D +#define P2P_ATTR_GROUP_INFO 0x0E +#define P2P_ATTR_GROUP_ID 0x0F +#define P2P_ATTR_INTERFACE 0x10 +#define P2P_ATTR_OPERATING_CH 0x11 +#define P2P_ATTR_INVITATION_FLAGS 0x12 + +/* Value of Status Attribute */ +#define P2P_STATUS_SUCCESS 0x00 +#define P2P_STATUS_FAIL_INFO_UNAVAILABLE 0x01 +#define P2P_STATUS_FAIL_INCOMPATIBLE_PARAM 0x02 +#define P2P_STATUS_FAIL_LIMIT_REACHED 0x03 +#define P2P_STATUS_FAIL_INVALID_PARAM 0x04 +#define P2P_STATUS_FAIL_REQUEST_UNABLE 0x05 +#define P2P_STATUS_FAIL_PREVOUS_PROTO_ERR 0x06 +#define P2P_STATUS_FAIL_NO_COMMON_CH 0x07 +#define P2P_STATUS_FAIL_UNKNOWN_P2PGROUP 0x08 +#define P2P_STATUS_FAIL_BOTH_GOINTENT_15 0x09 +#define P2P_STATUS_FAIL_INCOMPATIBLE_PROVSION 0x0A +#define P2P_STATUS_FAIL_USER_REJECT 0x0B + +/* Value of Inviation Flags Attribute */ +#define P2P_INVITATION_FLAGS_PERSISTENT BIT(0) + +#define DMP_P2P_DEVCAP_SUPPORT (P2P_DEVCAP_SERVICE_DISCOVERY | \ + P2P_DEVCAP_CLIENT_DISCOVERABILITY | \ + P2P_DEVCAP_CONCURRENT_OPERATION | \ + P2P_DEVCAP_INVITATION_PROC) + +#define DMP_P2P_GRPCAP_SUPPORT (P2P_GRPCAP_INTRABSS) + +/* Value of Device Capability Bitmap */ +#define P2P_DEVCAP_SERVICE_DISCOVERY BIT(0) +#define P2P_DEVCAP_CLIENT_DISCOVERABILITY BIT(1) +#define P2P_DEVCAP_CONCURRENT_OPERATION BIT(2) +#define P2P_DEVCAP_INFRA_MANAGED BIT(3) +#define P2P_DEVCAP_DEVICE_LIMIT BIT(4) +#define P2P_DEVCAP_INVITATION_PROC BIT(5) + +/* Value of Group Capability Bitmap */ +#define P2P_GRPCAP_GO BIT(0) +#define P2P_GRPCAP_PERSISTENT_GROUP BIT(1) +#define P2P_GRPCAP_GROUP_LIMIT BIT(2) +#define P2P_GRPCAP_INTRABSS BIT(3) +#define P2P_GRPCAP_CROSS_CONN BIT(4) +#define P2P_GRPCAP_PERSISTENT_RECONN BIT(5) +#define P2P_GRPCAP_GROUP_FORMATION BIT(6) + +/* P2P Public Action Frame (Management Frame) */ +#define P2P_PUB_ACTION_ACTION 0x09 + +/* P2P Public Action Frame Type */ +#define P2P_GO_NEGO_REQ 0 +#define P2P_GO_NEGO_RESP 1 +#define P2P_GO_NEGO_CONF 2 +#define P2P_INVIT_REQ 3 +#define P2P_INVIT_RESP 4 +#define P2P_DEVDISC_REQ 5 +#define P2P_DEVDISC_RESP 6 +#define P2P_PROVISION_DISC_REQ 7 +#define P2P_PROVISION_DISC_RESP 8 + +/* P2P Action Frame Type */ +#define P2P_NOTICE_OF_ABSENCE 0 +#define P2P_PRESENCE_REQUEST 1 +#define P2P_PRESENCE_RESPONSE 2 +#define P2P_GO_DISC_REQUEST 3 + + +#define P2P_MAX_PERSISTENT_GROUP_NUM 10 + +#define P2P_PROVISIONING_SCAN_CNT 3 + +#define P2P_WILDCARD_SSID_LEN 7 + +/* default value, used when: (1)p2p disabed or (2)p2p enabled + * but only do 1 scan phase */ +#define P2P_FINDPHASE_EX_NONE 0 +/* used when p2p enabled and want to do 1 scan phase and + * P2P_FINDPHASE_EX_MAX-1 find phase */ +#define P2P_FINDPHASE_EX_FULL 1 +#define P2P_FINDPHASE_EX_SOCIAL_FIRST (P2P_FINDPHASE_EX_FULL+1) +#define P2P_FINDPHASE_EX_MAX 4 +#define P2P_FINDPHASE_EX_SOCIAL_LAST P2P_FINDPHASE_EX_MAX + +/* 5 seconds timeout for sending the provision discovery request */ +#define P2P_PROVISION_TIMEOUT 5000 +/* 3 seconds timeout for sending the prov disc request concurrent mode */ +#define P2P_CONCURRENT_PROVISION_TIME 3000 +/* 5 seconds timeout for receiving the group negotation response */ +#define P2P_GO_NEGO_TIMEOUT 5000 +/* 3 seconds timeout for sending the negotiation request under concurrent mode */ +#define P2P_CONCURRENT_GO_NEGO_TIME 3000 +/* 100ms */ +#define P2P_TX_PRESCAN_TIMEOUT 100 +/* 5 seconds timeout for sending the invitation request */ +#define P2P_INVITE_TIMEOUT 5000 +/* 3 seconds timeout for sending the invitation request under concurrent mode */ +#define P2P_CONCURRENT_INVITE_TIME 3000 +/* 25 seconds timeout to reset the scan channel (based on channel plan) */ +#define P2P_RESET_SCAN_CH 25000 +#define P2P_MAX_INTENT 15 + +#define P2P_MAX_NOA_NUM 2 + +/* WPS Configuration Method */ +#define WPS_CM_NONE 0x0000 +#define WPS_CM_LABEL 0x0004 +#define WPS_CM_DISPLYA 0x0008 +#define WPS_CM_EXTERNAL_NFC_TOKEN 0x0010 +#define WPS_CM_INTEGRATED_NFC_TOKEN 0x0020 +#define WPS_CM_NFC_INTERFACE 0x0040 +#define WPS_CM_PUSH_BUTTON 0x0080 +#define WPS_CM_KEYPAD 0x0100 +#define WPS_CM_SW_PUHS_BUTTON 0x0280 +#define WPS_CM_HW_PUHS_BUTTON 0x0480 +#define WPS_CM_SW_DISPLAY_P 0x2008 +#define WPS_CM_LCD_DISPLAY_P 0x4008 + +enum P2P_ROLE { + P2P_ROLE_DISABLE = 0, + P2P_ROLE_DEVICE = 1, + P2P_ROLE_CLIENT = 2, + P2P_ROLE_GO = 3 +}; + +enum P2P_STATE { + P2P_STATE_NONE = 0, /* P2P disable */ + /* P2P had enabled and do nothing */ + P2P_STATE_IDLE = 1, + P2P_STATE_LISTEN = 2, /* In pure listen state */ + P2P_STATE_SCAN = 3, /* In scan phase */ + /* In the listen state of find phase */ + P2P_STATE_FIND_PHASE_LISTEN = 4, + /* In the search state of find phase */ + P2P_STATE_FIND_PHASE_SEARCH = 5, + /* In P2P provisioning discovery */ + P2P_STATE_TX_PROVISION_DIS_REQ = 6, + P2P_STATE_RX_PROVISION_DIS_RSP = 7, + P2P_STATE_RX_PROVISION_DIS_REQ = 8, + /* Doing the group owner negoitation handshake */ + P2P_STATE_GONEGO_ING = 9, + /* finish the group negoitation handshake with success */ + P2P_STATE_GONEGO_OK = 10, + /* finish the group negoitation handshake with failure */ + P2P_STATE_GONEGO_FAIL = 11, + /* receiving the P2P Inviation request and match with the profile. */ + P2P_STATE_RECV_INVITE_REQ_MATCH = 12, + /* Doing the P2P WPS */ + P2P_STATE_PROVISIONING_ING = 13, + /* Finish the P2P WPS */ + P2P_STATE_PROVISIONING_DONE = 14, + /* Transmit the P2P Invitation request */ + P2P_STATE_TX_INVITE_REQ = 15, + /* Receiving the P2P Invitation response */ + P2P_STATE_RX_INVITE_RESP_OK = 16, + /* receiving the P2P Inviation request and dismatch with the profile. */ + P2P_STATE_RECV_INVITE_REQ_DISMATCH = 17, + /* receiving the P2P Inviation request and this wifi is GO. */ + P2P_STATE_RECV_INVITE_REQ_GO = 18, + /* receiving the P2P Inviation request to join an existing P2P Group. */ + P2P_STATE_RECV_INVITE_REQ_JOIN = 19, + /* recveing the P2P Inviation response with failure */ + P2P_STATE_RX_INVITE_RESP_FAIL = 20, + /* receiving p2p negoitation response with information is not available */ + P2P_STATE_RX_INFOR_NOREADY = 21, + /* sending p2p negoitation response with information is not available */ + P2P_STATE_TX_INFOR_NOREADY = 22, +}; + +enum P2P_WPSINFO { + P2P_NO_WPSINFO = 0, + P2P_GOT_WPSINFO_PEER_DISPLAY_PIN = 1, + P2P_GOT_WPSINFO_SELF_DISPLAY_PIN = 2, + P2P_GOT_WPSINFO_PBC = 3, +}; + +#define P2P_PRIVATE_IOCTL_SET_LEN 64 + +enum P2P_PROTO_WK_ID { + P2P_FIND_PHASE_WK = 0, + P2P_RESTORE_STATE_WK = 1, + P2P_PRE_TX_PROVDISC_PROCESS_WK = 2, + P2P_PRE_TX_NEGOREQ_PROCESS_WK = 3, + P2P_PRE_TX_INVITEREQ_PROCESS_WK = 4, + P2P_AP_P2P_CH_SWITCH_PROCESS_WK =5, + P2P_RO_CH_WK = 6, +}; + +enum P2P_PS_STATE { + P2P_PS_DISABLE = 0, + P2P_PS_ENABLE = 1, + P2P_PS_SCAN = 2, + P2P_PS_SCAN_DONE = 3, + P2P_PS_ALLSTASLEEP = 4, /* for P2P GO */ +}; + +enum P2P_PS_MODE { + P2P_PS_NONE = 0, + P2P_PS_CTWINDOW = 1, + P2P_PS_NOA = 2, + P2P_PS_MIX = 3, /* CTWindow and NoA */ +}; + +/* =====================WFD Section===================== */ +/* For Wi-Fi Display */ +#define WFD_ATTR_DEVICE_INFO 0x00 +#define WFD_ATTR_ASSOC_BSSID 0x01 +#define WFD_ATTR_COUPLED_SINK_INFO 0x06 +#define WFD_ATTR_LOCAL_IP_ADDR 0x08 +#define WFD_ATTR_SESSION_INFO 0x09 +#define WFD_ATTR_ALTER_MAC 0x0a + +/* For WFD Device Information Attribute */ +#define WFD_DEVINFO_SOURCE 0x0000 +#define WFD_DEVINFO_PSINK 0x0001 +#define WFD_DEVINFO_SSINK 0x0002 +#define WFD_DEVINFO_DUAL 0x0003 + +#define WFD_DEVINFO_SESSION_AVAIL 0x0010 +#define WFD_DEVINFO_WSD 0x0040 +#define WFD_DEVINFO_PC_TDLS 0x0080 +#define WFD_DEVINFO_HDCP_SUPPORT 0x0100 + +#define IP_MCAST_MAC(mac) \ + ((mac[0] == 0x01) && (mac[1] == 0x00) && (mac[2] == 0x5e)) +#define ICMPV6_MCAST_MAC(mac) \ + ((mac[0] == 0x33) && (mac[1] == 0x33) && (mac[2] != 0xff)) + +#endif /* _WIFI_H_ */ diff --git a/drivers/staging/rtl8188eu/include/wlan_bssdef.h b/drivers/staging/rtl8188eu/include/wlan_bssdef.h new file mode 100644 index 0000000000000..e70075d586d7d --- /dev/null +++ b/drivers/staging/rtl8188eu/include/wlan_bssdef.h @@ -0,0 +1,347 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __WLAN_BSSDEF_H__ +#define __WLAN_BSSDEF_H__ + + +#define MAX_IE_SZ 768 + +#define NDIS_802_11_LENGTH_SSID 32 +#define NDIS_802_11_LENGTH_RATES 8 +#define NDIS_802_11_LENGTH_RATES_EX 16 + +#define NDIS_802_11_RSSI long /* in dBm */ + +struct ndis_802_11_ssid { + u32 SsidLength; + u8 Ssid[32]; +}; + +enum NDIS_802_11_NETWORK_TYPE { + Ndis802_11FH, + Ndis802_11DS, + Ndis802_11OFDM5, + Ndis802_11OFDM24, + Ndis802_11NetworkTypeMax /* dummy upper bound */ +}; + +struct ndis_802_11_config_fh { + u32 Length; /* Length of structure */ + u32 HopPattern; /* As defined by 802.11, MSB set */ + u32 HopSet; /* to one if non-802.11 */ + u32 DwellTime; /* units are Kusec */ +}; + +/* + * FW will only save the channel number in DSConfig. + * ODI Handler will convert the channel number to freq. number. + */ +struct ndis_802_11_config { + u32 Length; /* Length of structure */ + u32 BeaconPeriod; /* units are Kusec */ + u32 ATIMWindow; /* units are Kusec */ + u32 DSConfig; /* Frequency, units are kHz */ + struct ndis_802_11_config_fh FHConfig; +}; + +enum ndis_802_11_network_infra { + Ndis802_11IBSS, + Ndis802_11Infrastructure, + Ndis802_11AutoUnknown, + Ndis802_11InfrastructureMax, /* dummy upper bound */ + Ndis802_11APMode +}; + +struct ndis_802_11_fixed_ie { + u8 Timestamp[8]; + u16 BeaconInterval; + u16 Capabilities; +}; + + + +struct ndis_802_11_var_ie { + u8 ElementID; + u8 Length; + u8 data[1]; +}; + +/* + * Length is the 4 bytes multiples of the sume of + * [ETH_ALEN] + 2 + sizeof (struct ndis_802_11_ssid) + sizeof (u32) + * + sizeof (NDIS_802_11_RSSI) + sizeof (enum NDIS_802_11_NETWORK_TYPE) + * + sizeof (struct ndis_802_11_config) + * + NDIS_802_11_LENGTH_RATES_EX + IELength + * + * Except the IELength, all other fields are fixed length. + * Therefore, we can define a macro to represent the partial sum. */ + +enum ndis_802_11_auth_mode { + Ndis802_11AuthModeOpen, + Ndis802_11AuthModeShared, + Ndis802_11AuthModeAutoSwitch, + Ndis802_11AuthModeWPA, + Ndis802_11AuthModeWPAPSK, + Ndis802_11AuthModeWPANone, + Ndis802_11AuthModeWAPI, + Ndis802_11AuthModeMax /* Not a real mode, upper bound */ +}; + +enum ndis_802_11_wep_status { + Ndis802_11WEPEnabled, + Ndis802_11Encryption1Enabled = Ndis802_11WEPEnabled, + Ndis802_11WEPDisabled, + Ndis802_11EncryptionDisabled = Ndis802_11WEPDisabled, + Ndis802_11WEPKeyAbsent, + Ndis802_11Encryption1KeyAbsent = Ndis802_11WEPKeyAbsent, + Ndis802_11WEPNotSupported, + Ndis802_11EncryptionNotSupported = Ndis802_11WEPNotSupported, + Ndis802_11Encryption2Enabled, + Ndis802_11Encryption2KeyAbsent, + Ndis802_11Encryption3Enabled, + Ndis802_11Encryption3KeyAbsent, + Ndis802_11_EncryptionWAPI +}; + +#define NDIS_802_11_AI_REQFI_CAPABILITIES 1 +#define NDIS_802_11_AI_REQFI_LISTENINTERVAL 2 +#define NDIS_802_11_AI_REQFI_CURRENTAPADDRESS 4 + +#define NDIS_802_11_AI_RESFI_CAPABILITIES 1 +#define NDIS_802_11_AI_RESFI_STATUSCODE 2 +#define NDIS_802_11_AI_RESFI_ASSOCIATIONID 4 + +struct ndis_802_11_ai_reqfi { + u16 Capabilities; + u16 ListenInterval; + unsigned char CurrentAPAddress[ETH_ALEN]; +}; + +struct ndis_802_11_ai_resfi { + u16 Capabilities; + u16 StatusCode; + u16 AssociationId; +}; + +struct ndis_802_11_assoc_info { + u32 Length; + u16 AvailableRequestFixedIEs; + struct ndis_802_11_ai_reqfi RequestFixedIEs; + u32 RequestIELength; + u32 OffsetRequestIEs; + u16 AvailableResponseFixedIEs; + struct ndis_802_11_ai_resfi ResponseFixedIEs; + u32 ResponseIELength; + u32 OffsetResponseIEs; +}; + +enum ndis_802_11_reload_def { + Ndis802_11ReloadWEPKeys +}; + +/* Key mapping keys require a BSSID */ +struct ndis_802_11_key { + u32 Length; /* Length of this structure */ + u32 KeyIndex; + u32 KeyLength; /* length of key in bytes */ + unsigned char BSSID[ETH_ALEN]; + unsigned long long KeyRSC; + u8 KeyMaterial[32]; /* var len depending on above field */ +}; + +struct ndis_802_11_remove_key { + u32 Length; /* Length */ + u32 KeyIndex; + unsigned char BSSID[ETH_ALEN]; +}; + +struct ndis_802_11_wep { + u32 Length; /* Length of this structure */ + u32 KeyIndex; /* 0 is the per-client key, + * 1-N are the global keys */ + u32 KeyLength; /* length of key in bytes */ + u8 KeyMaterial[16];/* variable len depending on above field */ +}; + +struct ndis_802_11_auth_req { + u32 Length; /* Length of structure */ + unsigned char Bssid[ETH_ALEN]; + u32 Flags; +}; + +enum ndis_802_11_status_type { + Ndis802_11StatusType_Authentication, + Ndis802_11StatusType_MediaStreamMode, + Ndis802_11StatusType_PMKID_CandidateList, + Ndis802_11StatusTypeMax /* not a real type, defined as + * an upper bound */ +}; + +struct ndis_802_11_status_ind { + enum ndis_802_11_status_type StatusType; +}; + +/* mask for authentication/integrity fields */ +#define NDIS_802_11_AUTH_REQUEST_AUTH_FIELDS 0x0f +#define NDIS_802_11_AUTH_REQUEST_REAUTH 0x01 +#define NDIS_802_11_AUTH_REQUEST_KEYUPDATE 0x02 +#define NDIS_802_11_AUTH_REQUEST_PAIRWISE_ERROR 0x06 +#define NDIS_802_11_AUTH_REQUEST_GROUP_ERROR 0x0E + +/* MIC check time, 60 seconds. */ +#define MIC_CHECK_TIME 60000000 + +struct ndis_802_11_auth_evt { + struct ndis_802_11_status_ind Status; + struct ndis_802_11_auth_req Request[1]; +}; + +struct ndis_802_11_test { + u32 Length; + u32 Type; + union { + struct ndis_802_11_auth_evt AuthenticationEvent; + NDIS_802_11_RSSI RssiTrigger; + } tt; +}; + + +#ifndef Ndis802_11APMode +#define Ndis802_11APMode (Ndis802_11InfrastructureMax+1) +#endif + +struct wlan_phy_info { + u8 SignalStrength;/* in percentage) */ + u8 SignalQuality;/* in percentage) */ + u8 Optimum_antenna; /* for Antenna diversity */ + u8 Reserved_0; +}; + +struct wlan_bcn_info { + /* these infor get from rtw_get_encrypt_info when + * * translate scan to UI */ + u8 encryp_protocol;/* ENCRYP_PROTOCOL_E: OPEN/WEP/WPA/WPA2/WAPI */ + int group_cipher; /* WPA/WPA2 group cipher */ + int pairwise_cipher;/* WPA/WPA2/WEP pairwise cipher */ + int is_8021x; + + /* bwmode 20/40 and ch_offset UP/LOW */ + unsigned short ht_cap_info; + unsigned char ht_info_infos_0; +}; + +/* temporally add #pragma pack for structure alignment issue of +* struct wlan_bssid_ex and get_struct wlan_bssid_ex_sz() +*/ +struct wlan_bssid_ex { + u32 Length; + unsigned char MacAddress[ETH_ALEN]; + u8 Reserved[2];/* 0]: IS beacon frame */ + struct ndis_802_11_ssid Ssid; + u32 Privacy; + NDIS_802_11_RSSI Rssi;/* in dBM,raw data ,get from PHY) */ + enum NDIS_802_11_NETWORK_TYPE NetworkTypeInUse; + struct ndis_802_11_config Configuration; + enum ndis_802_11_network_infra InfrastructureMode; + unsigned char SupportedRates[NDIS_802_11_LENGTH_RATES_EX]; + struct wlan_phy_info PhyInfo; + u32 IELength; + u8 IEs[MAX_IE_SZ]; /* timestamp, beacon interval, and + * capability information) */ +} __packed; + +static inline uint get_wlan_bssid_ex_sz(struct wlan_bssid_ex *bss) +{ + return sizeof(struct wlan_bssid_ex) - MAX_IE_SZ + bss->IELength; +} + +struct wlan_network { + struct list_head list; + int network_type; /* refer to ieee80211.h for WIRELESS_11A/B/G */ + int fixed; /* set fixed when not to be removed + * in site-surveying */ + unsigned long last_scanned; /* timestamp for the network */ + int aid; /* will only be valid when a BSS is joinned. */ + int join_res; + struct wlan_bssid_ex network; /* must be the last item */ + struct wlan_bcn_info BcnInfo; +}; + +enum VRTL_CARRIER_SENSE { + DISABLE_VCS, + ENABLE_VCS, + AUTO_VCS +}; + +enum VCS_TYPE { + NONE_VCS, + RTS_CTS, + CTS_TO_SELF +}; + +#define PWR_CAM 0 +#define PWR_MINPS 1 +#define PWR_MAXPS 2 +#define PWR_UAPSD 3 +#define PWR_VOIP 4 + +enum UAPSD_MAX_SP { + NO_LIMIT, + TWO_MSDU, + FOUR_MSDU, + SIX_MSDU +}; + +#define NUM_PRE_AUTH_KEY 16 +#define NUM_PMKID_CACHE NUM_PRE_AUTH_KEY + +/* +* WPA2 +*/ + +struct pmkid_candidate { + unsigned char BSSID[ETH_ALEN]; + u32 Flags; +}; + +struct ndis_802_11_pmkid_list { + u32 Version; /* Version of the structure */ + u32 NumCandidates; /* No. of pmkid candidates */ + struct pmkid_candidate CandidateList[1]; +}; + +struct ndis_802_11_auth_encrypt { + enum ndis_802_11_auth_mode AuthModeSupported; + enum ndis_802_11_wep_status EncryptStatusSupported; +}; + +struct ndis_802_11_cap { + u32 Length; + u32 Version; + u32 NoOfPMKIDs; + u32 NoOfAuthEncryptPairsSupported; + struct ndis_802_11_auth_encrypt AuthenticationEncryptionSupported[1]; +}; + +u8 key_2char2num(u8 hch, u8 lch); +u8 key_char2num(u8 ch); +u8 str_2char2num(u8 hch, u8 lch); + +#endif /* ifndef WLAN_BSSDEF_H_ */ diff --git a/drivers/staging/rtl8188eu/include/xmit_osdep.h b/drivers/staging/rtl8188eu/include/xmit_osdep.h new file mode 100644 index 0000000000000..2ff622ba24f0b --- /dev/null +++ b/drivers/staging/rtl8188eu/include/xmit_osdep.h @@ -0,0 +1,67 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __XMIT_OSDEP_H_ +#define __XMIT_OSDEP_H_ + +#include +#include + +struct pkt_file { + struct sk_buff *pkt; + size_t pkt_len; /* the remainder length of the open_file */ + unsigned char *cur_buffer; + u8 *buf_start; + u8 *cur_addr; + size_t buf_len; +}; + +extern int rtw_ht_enable; +extern int rtw_cbw40_enable; +extern int rtw_ampdu_enable;/* for enable tx_ampdu */ + +#define NR_XMITFRAME 256 + +struct xmit_priv; +struct pkt_attrib; +struct sta_xmit_priv; +struct xmit_frame; +struct xmit_buf; + +int rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev); + +void rtw_os_xmit_schedule(struct adapter *padapter); + +int rtw_os_xmit_resource_alloc(struct adapter *padapter, + struct xmit_buf *pxmitbuf, u32 alloc_sz); +void rtw_os_xmit_resource_free(struct adapter *padapter, + struct xmit_buf *pxmitbuf, u32 free_sz); + +void rtw_set_tx_chksum_offload(struct sk_buff *pkt, struct pkt_attrib *pattrib); + +uint rtw_remainder_len(struct pkt_file *pfile); +void _rtw_open_pktfile(struct sk_buff *pkt, struct pkt_file *pfile); +uint _rtw_pktfile_read(struct pkt_file *pfile, u8 *rmem, uint rlen); +int rtw_endofpktfile(struct pkt_file *pfile); + +void rtw_os_pkt_complete(struct adapter *padapter, struct sk_buff *pkt); +void rtw_os_xmit_complete(struct adapter *padapter, + struct xmit_frame *pxframe); + +#endif /* __XMIT_OSDEP_H_ */ -- GitLab From b63c05394f3fe9ae547e1fa9df30f1ba0bcdabb4 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 21 Aug 2013 22:34:15 -0500 Subject: [PATCH 791/942] staging: r8188eu: Turn on build of new driver This commit modifies drivers/staging/Makefile, and adds the drivers/staging/rtl8188eu/Makefile. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/Makefile | 1 + drivers/staging/rtl8188eu/Makefile | 70 ++++++++++++++++++++++++++++++ drivers/staging/rtl8188eu/TODO | 15 +++++++ 3 files changed, 86 insertions(+) create mode 100644 drivers/staging/rtl8188eu/Makefile create mode 100644 drivers/staging/rtl8188eu/TODO diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index 0086ceb3285de..7d9ef62baee5d 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -17,6 +17,7 @@ obj-$(CONFIG_R8187SE) += rtl8187se/ obj-$(CONFIG_RTL8192U) += rtl8192u/ obj-$(CONFIG_RTL8192E) += rtl8192e/ obj-$(CONFIG_R8712U) += rtl8712/ +obj-$(CONFIG_R8188EU) += rtl8188eu/ obj-$(CONFIG_RTS5139) += rts5139/ obj-$(CONFIG_TRANZPORT) += frontier/ obj-$(CONFIG_IDE_PHISON) += phison/ diff --git a/drivers/staging/rtl8188eu/Makefile b/drivers/staging/rtl8188eu/Makefile new file mode 100644 index 0000000000000..1639a45da9482 --- /dev/null +++ b/drivers/staging/rtl8188eu/Makefile @@ -0,0 +1,70 @@ +EXTRA_CFLAGS += -I$(src)/include + +r8188eu-y := \ + core/rtw_ap.o \ + core/rtw_br_ext.o \ + core/rtw_cmd.o \ + core/rtw_debug.o \ + core/rtw_efuse.o \ + core/rtw_ieee80211.o \ + core/rtw_io.o \ + core/rtw_ioctl_set.o \ + core/rtw_iol.o \ + core/rtw_led.o \ + core/rtw_mlme.o \ + core/rtw_mlme_ext.o \ + core/rtw_mp.o \ + core/rtw_mp_ioctl.o \ + core/rtw_pwrctrl.o \ + core/rtw_p2p.o \ + core/rtw_recv.o \ + core/rtw_rf.o \ + core/rtw_security.o \ + core/rtw_sreset.o \ + core/rtw_sta_mgt.o \ + core/rtw_wlan_util.o \ + core/rtw_xmit.o \ + hal/HalHWImg8188E_MAC.o \ + hal/HalHWImg8188E_BB.o \ + hal/HalHWImg8188E_RF.o \ + hal/HalPhyRf.o \ + hal/HalPhyRf_8188e.o \ + hal/HalPwrSeqCmd.o \ + hal/Hal8188EFWImg_CE.o \ + hal/Hal8188EPwrSeq.o \ + hal/Hal8188ERateAdaptive.o\ + hal/hal_intf.o \ + hal/hal_com.o \ + hal/odm.o \ + hal/odm_debug.o \ + hal/odm_interface.o \ + hal/odm_HWConfig.o \ + hal/odm_RegConfig8188E.o\ + hal/odm_RTL8188E.o \ + hal/rtl8188e_cmd.o \ + hal/rtl8188e_dm.o \ + hal/rtl8188e_hal_init.o \ + hal/rtl8188e_mp.o \ + hal/rtl8188e_phycfg.o \ + hal/rtl8188e_rf6052.o \ + hal/rtl8188e_rxdesc.o \ + hal/rtl8188e_sreset.o \ + hal/rtl8188e_xmit.o \ + hal/rtl8188eu_led.o \ + hal/rtl8188eu_recv.o \ + hal/rtl8188eu_xmit.o \ + hal/usb_halinit.o \ + hal/usb_ops_linux.o \ + os_dep/ioctl_linux.o \ + os_dep/mlme_linux.o \ + os_dep/os_intfs.o \ + os_dep/osdep_service.o \ + os_dep/recv_linux.o \ + os_dep/rtw_android.o \ + os_dep/usb_intf.o \ + os_dep/usb_ops_linux.o \ + os_dep/xmit_linux.o + +obj-$(CONFIG_R8188EU) := r8188eu.o + +ccflags-y += -D__CHECK_ENDIAN__ diff --git a/drivers/staging/rtl8188eu/TODO b/drivers/staging/rtl8188eu/TODO new file mode 100644 index 0000000000000..e50aa50bdb478 --- /dev/null +++ b/drivers/staging/rtl8188eu/TODO @@ -0,0 +1,15 @@ +TODO: +- find and remove remaining code valid only for 5 HGz. Most of the obvious + ones have been removed, but things like channel > 14 still exist. +- find and remove any code for other chips that is left over +- convert to external firmware +- convert any remaining unusual variable types +- find codes that can use %pM and %Nph formatting +- checkpatch.pl fixes - most of the remaining ones are lines too long. Many + of them will require refactoring +- merge Realtek's bugfixes and new features into the driver +- switch to use LIB80211 +- switch to use MAC80211 + +Please send any patches to Greg Kroah-Hartman , +and Larry Finger . -- GitLab From b3cc872c1b51b9c4166264a3f5e614b9f2d3b263 Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Thu, 22 Aug 2013 13:40:35 -0400 Subject: [PATCH 792/942] staging: dgap: adds driver to kernel build This patch adds the dgap driver to the kernel build process. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/Kconfig | 2 ++ drivers/staging/Makefile | 1 + 2 files changed, 3 insertions(+) diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index 6fade33de8eb0..3626dbc8eb0bb 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -146,4 +146,6 @@ source "drivers/staging/xillybus/Kconfig" source "drivers/staging/dgnc/Kconfig" +source "drivers/staging/dgap/Kconfig" + endif # STAGING diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index 7d9ef62baee5d..d1b4b8003c2d4 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -65,3 +65,4 @@ obj-$(CONFIG_LUSTRE_FS) += lustre/ obj-$(CONFIG_USB_BTMTK) += btmtk_usb/ obj-$(CONFIG_XILLYBUS) += xillybus/ obj-$(CONFIG_DGNC) += dgnc/ +obj-$(CONFIG_DGAP) += dgap/ -- GitLab From 8287ac00ddfece19834d40a424406eecc692b407 Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Thu, 22 Aug 2013 14:54:15 -0400 Subject: [PATCH 793/942] staging: dgnc: driver.c: removes dgnc_mbuf function This patch removes the dgnc_mbuf function. This function was causing the errors: drivers/staging/dgnc/dgnc_driver.c: In function 'dgnc_mbuf.constprop.0': drivers/staging/dgnc/dgnc_driver.c:945:1: warning: the frame size of 1032 bytes is larger than 1024 bytes [-Wframe-larger-than=] drivers/staging/dgnc/dgnc_tty.c: In function 'dgnc_sniff_nowait_nolock': drivers/staging/dgnc/dgnc_tty.c:614:1: warning: the frame size of 1056 bytes is larger than 1024 bytes [-Wframe-larger-than=] This patch removes it so the kernel won't be making noise when its device is found on the system. Reported-by: Fengguang Wu Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_driver.c | 40 ------------------------------ 1 file changed, 40 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c index 80323686f3909..9fef18ac5358d 100644 --- a/drivers/staging/dgnc/dgnc_driver.c +++ b/drivers/staging/dgnc/dgnc_driver.c @@ -81,8 +81,6 @@ static int dgnc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) static void dgnc_remove_one(struct pci_dev *dev); static int dgnc_probe1(struct pci_dev *pdev, int card_type); static void dgnc_do_remap(struct board_t *brd); -static void dgnc_mbuf(struct board_t *brd, const char *fmt, ...); - /* Driver load/unload functions */ int dgnc_init_module(void); @@ -709,10 +707,6 @@ static int dgnc_found_board(struct pci_dev *pdev, int id) /* init our poll helper tasklet */ tasklet_init(&brd->helper_tasklet, brd->bd_ops->tasklet, (unsigned long) brd); - /* Log the information about the board */ - dgnc_mbuf(brd, DRVSTR": board %d: %s (rev %d), irq %d\n", - dgnc_NumBoards, brd->name, brd->rev, brd->irq); - DPR_INIT(("dgnc_scan(%d) - printing out the msgbuf\n", i)); DGNC_LOCK(dgnc_global_lock, flags); brd->msgbuf = NULL; @@ -910,40 +904,6 @@ void *dgnc_driver_kzmalloc(size_t size, int priority) } -/* - * dgnc_mbuf() - * - * Used to print to the message buffer during board init. - */ -static void dgnc_mbuf(struct board_t *brd, const char *fmt, ...) { - va_list ap; - char buf[1024]; - int i; - unsigned long flags; - - DGNC_LOCK(dgnc_global_lock, flags); - - /* Format buf using fmt and arguments contained in ap. */ - va_start(ap, fmt); - i = vsprintf(buf, fmt, ap); - va_end(ap); - - DPR((buf)); - - if (!brd || !brd->msgbuf) { - printk(buf); - DGNC_UNLOCK(dgnc_global_lock, flags); - return; - } - - memcpy(brd->msgbuf, buf, strlen(buf)); - brd->msgbuf += strlen(buf); - *brd->msgbuf = '\0'; - - DGNC_UNLOCK(dgnc_global_lock, flags); -} - - /* * dgnc_ms_sleep() * -- GitLab From 37351073d83027f1bd5ccacd7deb216c87b3a004 Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Thu, 22 Aug 2013 21:35:17 -0400 Subject: [PATCH 794/942] staging: dgap: removes references to mgmt code This patch removes references to mgmt functions from the code. The files mgmt.c and mgmt.h will be removed in the patches that follow. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap_driver.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/dgap/dgap_driver.c b/drivers/staging/dgap/dgap_driver.c index 0e09ce3c6f368..ed56d02e11dfc 100644 --- a/drivers/staging/dgap/dgap_driver.c +++ b/drivers/staging/dgap/dgap_driver.c @@ -102,9 +102,6 @@ module_exit(dgap_cleanup_module); static struct file_operations DgapBoardFops = { .owner = THIS_MODULE, - .unlocked_ioctl = dgap_mgmt_ioctl, - .open = dgap_mgmt_open, - .release = dgap_mgmt_close }; -- GitLab From 6dacb8b687fbfe36c20b849a1014c644ce076932 Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Thu, 22 Aug 2013 21:35:18 -0400 Subject: [PATCH 795/942] staging: dgap: removes mgmt.c This patch removes mgmt.c. This file isn't needed for the driver to work with the kernel. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/Makefile | 2 +- drivers/staging/dgap/dgap_mgmt.c | 761 ------------------------------- 2 files changed, 1 insertion(+), 762 deletions(-) delete mode 100644 drivers/staging/dgap/dgap_mgmt.c diff --git a/drivers/staging/dgap/Makefile b/drivers/staging/dgap/Makefile index 15b7704cd5b70..9f1fce157c771 100644 --- a/drivers/staging/dgap/Makefile +++ b/drivers/staging/dgap/Makefile @@ -3,7 +3,7 @@ EXTRA_CFLAGS += -DDG_NAME=\"dgap-1.3-16\" -DDG_PART=\"40002347_C\" obj-$(CONFIG_DGAP) += dgap.o -dgap-objs := dgap_driver.o dgap_fep5.o dgap_mgmt.o \ +dgap-objs := dgap_driver.o dgap_fep5.o \ dgap_parse.o dgap_trace.o \ dgap_tty.o dgap_sysfs.o diff --git a/drivers/staging/dgap/dgap_mgmt.c b/drivers/staging/dgap/dgap_mgmt.c deleted file mode 100644 index 1ed737542507e..0000000000000 --- a/drivers/staging/dgap/dgap_mgmt.c +++ /dev/null @@ -1,761 +0,0 @@ -/* - * Copyright 2003 Digi International (www.digi.com) - * Scott H Kilau - * - * 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, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * - * NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE! - * - * This is shared code between Digi's CVS archive and the - * Linux Kernel sources. - * Changing the source just for reformatting needlessly breaks - * our CVS diff history. - * - * Send any bug fixes/changes to: Eng.Linux at digi dot com. - * Thank you. - * - */ - -/************************************************************************ - * - * This file implements the mgmt functionality for the - * FEP5 based product lines. - * - ************************************************************************ - * $Id: dgap_mgmt.c,v 1.2 2010/12/13 19:38:04 markh Exp $ - */ - -#include -#include -#include -#include /* For jiffies, task states */ -#include /* For tasklet and interrupt structs/defines */ -#include -#include -#include -#include /* For copy_from_user/copy_to_user */ -#include /* For read[bwl]/write[bwl] */ - -#include "dgap_driver.h" -#include "dgap_kcompat.h" /* Kernel 2.4/2.6 compat includes */ -#include "dgap_fep5.h" -#include "dgap_parse.h" -#include "dgap_mgmt.h" -#include "dgap_downld.h" -#include "dgap_tty.h" -#include "dgap_proc.h" -#include "dgap_sysfs.h" - - -/* This holds the status of the KME buffer */ -static int dgap_kmebusy = 0; - -/* Our "in use" variables, to enforce 1 open only */ -static int dgap_mgmt_in_use = 0; -static int dgap_downld_in_use = 0; - - -/* - * dgap_mgmt_open() - * - * Open the mgmt/downld/dpa device - */ -int dgap_mgmt_open(struct inode *inode, struct file *file) -{ - unsigned long lock_flags; - unsigned int minor = iminor(inode); - - DPR_MGMT(("dgap_mgmt_open start.\n")); - - DGAP_LOCK(dgap_global_lock, lock_flags); - - /* mgmt device */ - if (minor == MGMT_MGMT) { - /* Only allow 1 open at a time on mgmt device */ - if (dgap_mgmt_in_use) { - DGAP_UNLOCK(dgap_global_lock, lock_flags); - return (-EBUSY); - } - dgap_mgmt_in_use++; - } - /* downld device */ - else if (minor == MGMT_DOWNLD) { - /* Only allow 1 open at a time on downld device */ - if (dgap_downld_in_use) { - DGAP_UNLOCK(dgap_global_lock, lock_flags); - return (-EBUSY); - } - dgap_downld_in_use++; - } - else { - DGAP_UNLOCK(dgap_global_lock, lock_flags); - return (-ENXIO); - } - - DGAP_UNLOCK(dgap_global_lock, lock_flags); - - DPR_MGMT(("dgap_mgmt_open finish.\n")); - - return 0; -} - -/* - * dgap_mgmt_close() - * - * Open the mgmt/dpa device - */ -int dgap_mgmt_close(struct inode *inode, struct file *file) -{ - unsigned long lock_flags; - unsigned int minor = iminor(inode); - - DPR_MGMT(("dgap_mgmt_close start.\n")); - - DGAP_LOCK(dgap_global_lock, lock_flags); - - /* mgmt device */ - if (minor == MGMT_MGMT) { - if (dgap_mgmt_in_use) { - dgap_mgmt_in_use = 0; - } - } - /* downld device */ - else if (minor == MGMT_DOWNLD) { - if (dgap_downld_in_use) { - dgap_downld_in_use = 0; - } - } - - DGAP_UNLOCK(dgap_global_lock, lock_flags); - - DPR_MGMT(("dgap_mgmt_close finish.\n")); - - return 0; -} - - -/* - * dgap_mgmt_ioctl() - * - * ioctl the mgmt/dpa device - */ -long dgap_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg) -{ - unsigned long lock_flags; - int error = 0; - int i = 0; - int j = 0; - struct board_t *brd; - struct channel_t *ch; - static struct downldio dlio; - void __user *uarg = (void __user *) arg; - - DPR_MGMT(("dgap_mgmt_ioctl start.\n")); - - switch (cmd) { - - /* HiJack the usage of SEDELAY to turn on/off debugging. */ - case DIGI_SEDELAY: - { - unsigned int value = 0; - - if (copy_from_user((unsigned int *) &value, uarg, sizeof(unsigned int))) { - return (-EFAULT); - } - - printk("Setting debug of value: %x\n", value); - dgap_debug = value; - return 0; - } - - case DIGI_DLREQ_GET: - { - -get_service: - - DGAP_LOCK(dgap_global_lock, lock_flags); - - if (dgap_driver_state == DRIVER_NEED_CONFIG_LOAD) { - - dgap_driver_state = DRIVER_REQUESTED_CONFIG; - - dlio.req_type = DLREQ_CONFIG; - dlio.bdid = 0; - dlio.image.fi.type = 0; - - DGAP_UNLOCK(dgap_global_lock, lock_flags); - - if (copy_to_user(uarg, &dlio, sizeof(struct downldio))) { - DGAP_LOCK(dgap_global_lock, lock_flags); - dgap_driver_state = DRIVER_NEED_CONFIG_LOAD; - DGAP_UNLOCK(dgap_global_lock, lock_flags); - return(-EFAULT); - } - - return(0); - } - - DGAP_UNLOCK(dgap_global_lock, lock_flags); - - /* - * Loop thru each board. - * Check state, force state machine to start running. - */ - for (i = 0; i < dgap_NumBoards; i++ ) { - - brd = dgap_Board[i]; - - DGAP_LOCK(brd->bd_lock, lock_flags); - - switch (brd->state) { - - case NEED_DEVICE_CREATION: - - /* - * Let go of lock, tty_register() (and us also) - * does a non-atomic malloc, so it would be - * possible to deadlock the system if the - * malloc went to sleep. - */ - DGAP_UNLOCK(brd->bd_lock, lock_flags); - dgap_tty_register(brd); - dgap_finalize_board_init(brd); - DGAP_LOCK(brd->bd_lock, lock_flags); - - brd->state = REQUESTED_DEVICE_CREATION; - - dlio.req_type = DLREQ_DEVCREATE; - dlio.bdid = i; - dlio.image.fi.type = brd->dpatype; - - DGAP_UNLOCK(brd->bd_lock, lock_flags); - - if (copy_to_user(uarg, &dlio, sizeof(struct downldio))) { - DGAP_LOCK(brd->bd_lock, lock_flags); - brd->state = NEED_DEVICE_CREATION; - DGAP_UNLOCK(brd->bd_lock, lock_flags); - return(-EFAULT); - } - - return(0); - - case NEED_BIOS_LOAD: - - brd->state = REQUESTED_BIOS; - - dlio.req_type = DLREQ_BIOS; - dlio.bdid = i; - dlio.image.fi.type = brd->dpatype; - - DGAP_UNLOCK(brd->bd_lock, lock_flags); - if (copy_to_user(uarg, &dlio, sizeof(struct downldio))) { - DGAP_LOCK(brd->bd_lock, lock_flags); - brd->state = NEED_BIOS_LOAD; - DGAP_UNLOCK(brd->bd_lock, lock_flags); - return(-EFAULT); - } - - return(0); - - case NEED_FEP_LOAD: - brd->state = REQUESTED_FEP; - - dlio.req_type = DLREQ_FEP; - dlio.bdid = i; - dlio.image.fi.type = brd->dpatype; - - DGAP_UNLOCK(brd->bd_lock, lock_flags); - - if (copy_to_user(uarg, &dlio, sizeof(struct downldio))) { - DGAP_LOCK(brd->bd_lock, lock_flags); - brd->state = NEED_FEP_LOAD; - DGAP_UNLOCK(brd->bd_lock, lock_flags); - return(-EFAULT); - } - return(0); - - case NEED_PROC_CREATION: - - DGAP_UNLOCK(brd->bd_lock, lock_flags); - //dgap_proc_register_channel_postscan(brd->boardnum); - - ch = brd->channels[0]; - for (j = 0; j < brd->nasync; j++, ch = brd->channels[j]) { - struct device *classp; - classp = - tty_register_device(brd->SerialDriver, j, - &(ch->ch_bd->pdev->dev)); - ch->ch_tun.un_sysfs = classp; - dgap_create_tty_sysfs(&ch->ch_tun, classp); - - classp = - tty_register_device(brd->PrintDriver, j, - &(ch->ch_bd->pdev->dev)); - ch->ch_pun.un_sysfs = classp; - dgap_create_tty_sysfs(&ch->ch_pun, classp); - } - dgap_create_ports_sysfiles(brd); - - DGAP_LOCK(brd->bd_lock, lock_flags); - brd->state = FINISHED_PROC_CREATION; - DGAP_UNLOCK(brd->bd_lock, lock_flags); - break; - - default: - DGAP_UNLOCK(brd->bd_lock, lock_flags); - break; - - } - - DGAP_LOCK(brd->bd_lock, lock_flags); - - switch (brd->conc_dl_status) { - - case NEED_CONCENTRATOR: - { - u16 offset = 0; - char *vaddr; - struct downld_t *to_dp; - - vaddr = brd->re_map_membase; - if (!vaddr) { - brd->conc_dl_status = NO_PENDING_CONCENTRATOR_REQUESTS; - DGAP_UNLOCK(brd->bd_lock, lock_flags); - break; - } - - dlio.req_type = DLREQ_CONC; - dlio.bdid = i; - - offset = readw((u16 *) (vaddr + DOWNREQ)); - to_dp = (struct downld_t *) (vaddr + (int) offset); - - if (!to_dp) { - brd->conc_dl_status = NO_PENDING_CONCENTRATOR_REQUESTS; - DGAP_UNLOCK(brd->bd_lock, lock_flags); - break; - } - - memcpy(&dlio.image.dl, to_dp, sizeof(struct downld_t)); - - brd->conc_dl_status = REQUESTED_CONCENTRATOR; - - DGAP_UNLOCK(brd->bd_lock, lock_flags); - - if (copy_to_user(uarg, &dlio, sizeof(struct downldio))) { - DGAP_LOCK(brd->bd_lock, lock_flags); - brd->conc_dl_status = NEED_CONCENTRATOR; - DGAP_UNLOCK(brd->bd_lock, lock_flags); - return(-EFAULT); - } - - return(0); - } - - default: - DGAP_UNLOCK(brd->bd_lock, lock_flags); - break; - } - } - - /* - * Go to sleep waiting for the driver to signal an event to us. - */ - error = wait_event_interruptible(dgap_dl_wait, (dgap_dl_action)); - - DGAP_LOCK(dgap_dl_lock, lock_flags); - dgap_dl_action = 0; - DGAP_UNLOCK(dgap_dl_lock, lock_flags); - - /* Break out of ioctl if user cancelled us */ - if (error) - break; - - goto get_service; - - } - - case DIGI_DLREQ_SET: - { - uchar __user *uaddr = NULL; - uchar *uaddr2 = NULL; - - if (copy_from_user((char *) &dlio, uarg, sizeof(struct downldio))) { - return (-EFAULT); - } - - if (dlio.req_type == DLREQ_CONFIG) { - - uaddr = uarg + - (int) ( ((struct downldio *)0)->image.fi.fepimage); - - dgap_do_config_load(uaddr, dlio.image.fi.len); - dgap_after_config_loaded(); - - DGAP_LOCK(dgap_global_lock, lock_flags); - dgap_driver_state = DRIVER_READY; - DGAP_UNLOCK(dgap_global_lock, lock_flags); - - break; - - } - - if (dlio.bdid < 0 || dlio.bdid > dgap_NumBoards) { - return(-ENXIO); - } - - brd = dgap_Board[dlio.bdid]; - - switch(dlio.req_type) { - - case DLREQ_BIOS: - if (brd->state == BOARD_FAILED || brd->state == BOARD_READY) { - break; - } - - if (dlio.image.fi.type == -1) { - DGAP_LOCK(brd->bd_lock, lock_flags); - brd->state = BOARD_FAILED; - brd->dpastatus = BD_NOBIOS; - DGAP_UNLOCK(brd->bd_lock, lock_flags); - break; - } - - - uaddr = uarg + - (int) ( ((struct downldio *)0)->image.fi.fepimage); - - dgap_do_bios_load(brd, uaddr, dlio.image.fi.len); - - break; - case DLREQ_FEP: - if (brd->state == BOARD_FAILED || brd->state == BOARD_READY) { - break; - } - - if (dlio.image.fi.type == -1) { - DGAP_LOCK(brd->bd_lock, lock_flags); - brd->state = BOARD_FAILED; - brd->dpastatus = BD_NOBIOS; - DGAP_UNLOCK(brd->bd_lock, lock_flags); - break; - } - - uaddr = uarg + - (int) ( ((struct downldio *)0)->image.fi.fepimage); - - dgap_do_fep_load(brd, uaddr, dlio.image.fi.len); - - break; - - case DLREQ_CONC: - - if (brd->state == BOARD_FAILED) { - break; - } - - if (dlio.image.fi.type == -1) { - break; - } - - uaddr2 = (char *) &dlio.image.dl; - dgap_do_conc_load(brd, uaddr2, sizeof(struct downld_t)); - - break; - - case DLREQ_DEVCREATE: - if (brd->state == BOARD_FAILED || brd->state == BOARD_READY) { - break; - } - - DGAP_LOCK(brd->bd_lock, lock_flags); - brd->state = FINISHED_DEVICE_CREATION; - DGAP_UNLOCK(brd->bd_lock, lock_flags); - - break; - - } - - break; - } - - - case DIGI_GETDD: - { - /* - * This returns the total number of boards - * in the system, as well as driver version - * and has space for a reserved entry - */ - struct digi_dinfo ddi; - - DGAP_LOCK(dgap_global_lock, lock_flags); - - ddi.dinfo_nboards = dgap_NumBoards; - sprintf(ddi.dinfo_version, "%s", DG_PART); - - DGAP_UNLOCK(dgap_global_lock, lock_flags); - - DPR_MGMT(("DIGI_GETDD returning numboards: %lu version: %s\n", - ddi.dinfo_nboards, ddi.dinfo_version)); - - if (copy_to_user(uarg, &ddi, sizeof(ddi))) - return(-EFAULT); - - break; - } - - case DIGI_GETBD: - { - int brd2; - struct digi_info di; - - if (copy_from_user(&brd2, uarg, sizeof(int))) { - return(-EFAULT); - } - - DPR_MGMT(("DIGI_GETBD asking about board: %d\n", brd2)); - - if ((brd2 < 0) || (brd2 > dgap_NumBoards) || (dgap_NumBoards == 0)) - return (-ENODEV); - - memset(&di, 0, sizeof(di)); - - di.info_bdnum = brd2; - - DGAP_LOCK(dgap_Board[brd2]->bd_lock, lock_flags); - - di.info_bdtype = dgap_Board[brd2]->dpatype; - di.info_bdstate = dgap_Board[brd2]->dpastatus; - di.info_ioport = (ulong) dgap_Board[brd2]->port; - di.info_physaddr = (ulong) dgap_Board[brd2]->membase; - di.info_physsize = (ulong) dgap_Board[brd2]->membase - dgap_Board[brd2]->membase_end; - if (dgap_Board[brd2]->state != BOARD_FAILED) - di.info_nports = dgap_Board[brd2]->nasync; - else - di.info_nports = 0; - - DGAP_UNLOCK(dgap_Board[brd2]->bd_lock, lock_flags); - - DPR_MGMT(("DIGI_GETBD returning type: %x state: %x ports: %x size: %lx\n", - di.info_bdtype, di.info_bdstate, di.info_nports, di.info_physsize)); - - if (copy_to_user(uarg, &di, sizeof (di))) - return(-EFAULT); - - break; - } - - case DIGI_KME: - { - int itmp, jtmp; - unchar *memaddr = NULL; - struct rw_t kme; - struct rw_t *mp = NULL; - int brd2 = 0; - struct board_t *bd; - - /* This ioctl takes an argument of type 'rw_t' - * and uses it to interact with the KME struct - * located on the digiboard itself. - */ - if (copy_from_user(&kme, uarg, sizeof(kme))) - return(-EFAULT); - - if (kme.rw_size > 128) - kme.rw_size = 128; - - brd2 = kme.rw_board; - - DPR_MGMT(("dgap_mgmt: DIGI_KME: %s asked for board %d\n", current->comm, brd2)); - - /* Sanity Checking... */ - if ((brd2 < 0) || (brd2 > dgap_NumBoards) || (dgap_NumBoards == 0)) - return (-ENODEV); - - bd = dgap_Board[brd2]; - - DGAP_LOCK(dgap_Board[brd2]->bd_lock, lock_flags); - - if (bd->state != BOARD_READY) { - DGAP_UNLOCK(dgap_Board[brd2]->bd_lock, lock_flags); - return(-ENODEV); - } - - memaddr = bd->re_map_membase; - - DGAP_UNLOCK(dgap_Board[brd2]->bd_lock, lock_flags); - - /* If the concentrator number is 0... */ - if (kme.rw_conc == 0 && kme.rw_addr < 0x100000) { - int addr = kme.rw_addr; - int size = kme.rw_size; - caddr_t data = (caddr_t) kme.rw_data; - - while ((itmp = size)) { - - switch (kme.rw_req) { - case RW_READ: - { - register caddr_t cp1 = (char *)memaddr + addr; - register caddr_t cp2 = kme.rw_data; - - DPR_MGMT(("RW_READ CARDMEM - page=%d rw_addr=0x%lx rw_size=%x\n", - page, kme.rw_addr, kme.rw_size)); - - for (jtmp = 0; jtmp < itmp; jtmp++) { - *cp2++ = readb(cp1++); - } - } - - break; - - case RW_WRITE: - { - register caddr_t cp1 = memaddr + addr; - register caddr_t cp2 = data; - - DPR_MGMT(("RW_WRITE CARDMEM - page=%d rw_addr=0x%lx rw_size=%d\n", - page, kme.rw_addr, kme.rw_size)); - - for (jtmp = 0; jtmp < itmp; jtmp++) { - writeb(*cp2++, cp1++); - } - } - break; - } - - addr += itmp; - data += itmp; - size -= itmp; - - } - - } - else { - - /* - * Read/Write memory in a REMOTE CONCENTRATOR.. - * There is only 1 buffer, so do mutual - * exclusion to make sure only one KME - * request is pending... - */ - - mp = (struct rw_t *) (memaddr + KMEMEM); - - while (dgap_kmebusy != 0) { - dgap_kmebusy = 2; - error = wait_event_interruptible(bd->kme_wait, (!dgap_kmebusy)); - if (error) - goto endkme; - } - - dgap_kmebusy = 1; - - /* Copy KME request to the board.. */ - - mp->rw_board = kme.rw_board; - mp->rw_conc = kme.rw_conc; - mp->rw_reserved = kme.rw_reserved; - memcpy(&mp->rw_addr, &kme.rw_addr, sizeof(int)); - memcpy(&mp->rw_size, &kme.rw_size, sizeof(short)); - - if(kme.rw_req == RW_WRITE) { - register caddr_t cp1 = (caddr_t) mp->rw_data; - register caddr_t cp2 = (caddr_t) kme.rw_data; - - DPR_MGMT(("RW_WRITE CONCMEM - rw_addr=0x%lx rw_size=%d\n", - kme.rw_addr, kme.rw_size)); - - for (jtmp = 0; jtmp < (int) kme.rw_size; jtmp++) { - writeb(*cp2++, cp1++); - } - } - - /* EXECUTE REQUEST */ - - mp->rw_req = kme.rw_req; - - /* - * Wait for the board to process the - * request, but limit the wait to 2 secs - */ - - for (itmp = jiffies + (2 * HZ); mp->rw_req;) { - if(jiffies >= itmp) { - error = ENXIO; - /* Set request back to 0.. */ - mp->rw_req = 0; - goto endkme; - } - - schedule_timeout(HZ / 10); - } - - /* - * Since this portion of code is looksee - * ported from the HPUX EMUX code, i'm - * leaving OUT a portion of that code where - * the HP/UX code actually puts the process - * to sleep for some reason - */ - if (mp->rw_size < kme.rw_size) - memcpy(&kme.rw_size, &mp->rw_size, sizeof(short)); - - /* Copy the READ data back to the source buffer... */ - if (kme.rw_req == RW_READ) { - register caddr_t cp1 = (caddr_t) mp->rw_data; - register caddr_t cp2 = (caddr_t) kme.rw_data; - - DPR_MGMT(("RW_READ CONCMEM - rw_addr=0x%lx rw_size=%d\n", - kme.rw_addr, kme.rw_size)); - - for (jtmp = 0; jtmp < (int) kme.rw_size; jtmp++) { - *cp2++ = readb(cp1++); - } - } - - /* - * Common exit point for code sharing the - * kme buffer. Before exiting, always wake - * another process waiting for the buffer - */ - - endkme: - - if (dgap_kmebusy != 1) - wake_up_interruptible(&bd->kme_wait); - dgap_kmebusy = 0; - if (error == ENXIO) - return(-EINVAL); - } - - /* Copy the whole (Possibly Modified) mess */ - /* back out to user space... */ - - if (!error) { - if (copy_to_user(uarg, &kme, sizeof(kme))) - return (-EFAULT); - - return(0); - } - } - } - - DPR_MGMT(("dgap_mgmt_ioctl finish.\n")); - - return 0; -} -- GitLab From 07b96937cf444939768760220dda1e1f2c3dfafc Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Thu, 22 Aug 2013 21:35:19 -0400 Subject: [PATCH 796/942] staging: dgap: removes mgmt.h This patch removes mgmt.h and the headers that include it of files in dgap. This file isn't needed for the driver to work with the kernel. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap_driver.c | 1 - drivers/staging/dgap/dgap_fep5.c | 1 - drivers/staging/dgap/dgap_mgmt.h | 33 ------------------------------ drivers/staging/dgap/dgap_proc.c | 1 - drivers/staging/dgap/dgap_sysfs.c | 1 - 5 files changed, 37 deletions(-) delete mode 100644 drivers/staging/dgap/dgap_mgmt.h diff --git a/drivers/staging/dgap/dgap_driver.c b/drivers/staging/dgap/dgap_driver.c index ed56d02e11dfc..8e8c1e3ec96a0 100644 --- a/drivers/staging/dgap/dgap_driver.c +++ b/drivers/staging/dgap/dgap_driver.c @@ -49,7 +49,6 @@ #include "dgap_tty.h" #include "dgap_conf.h" #include "dgap_parse.h" -#include "dgap_mgmt.h" #include "dgap_trace.h" #include "dgap_sysfs.h" diff --git a/drivers/staging/dgap/dgap_fep5.c b/drivers/staging/dgap/dgap_fep5.c index 2bbbcd3c398ef..45b0f28a202a7 100644 --- a/drivers/staging/dgap/dgap_fep5.c +++ b/drivers/staging/dgap/dgap_fep5.c @@ -51,7 +51,6 @@ #include "dgap_tty.h" #include "dgap_conf.h" #include "dgap_parse.h" -#include "dgap_mgmt.h" #include "dgap_trace.h" /* diff --git a/drivers/staging/dgap/dgap_mgmt.h b/drivers/staging/dgap/dgap_mgmt.h deleted file mode 100644 index 4b153f2dd7f22..0000000000000 --- a/drivers/staging/dgap/dgap_mgmt.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2003 Digi International (www.digi.com) - * Scott H Kilau - * - * 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, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! - */ - -#ifndef __DGAP_MGMT_H -#define __DGAP_MGMT_H - -#define MGMT_MGMT 0 -#define MGMT_DOWNLD 1 - -int dgap_mgmt_open(struct inode *inode, struct file *file); -int dgap_mgmt_close(struct inode *inode, struct file *file); -long dgap_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg); - -#endif - diff --git a/drivers/staging/dgap/dgap_proc.c b/drivers/staging/dgap/dgap_proc.c index 6950a6c9b87db..8c46b24848238 100644 --- a/drivers/staging/dgap/dgap_proc.c +++ b/drivers/staging/dgap/dgap_proc.c @@ -46,7 +46,6 @@ #include "dgap_driver.h" #include "dgap_proc.h" -#include "dgap_mgmt.h" #include "dgap_conf.h" #include "dgap_parse.h" #include "dgap_fep5.h" diff --git a/drivers/staging/dgap/dgap_sysfs.c b/drivers/staging/dgap/dgap_sysfs.c index 6f98ac6248305..a35c8ed69eff0 100644 --- a/drivers/staging/dgap/dgap_sysfs.c +++ b/drivers/staging/dgap/dgap_sysfs.c @@ -45,7 +45,6 @@ #include "dgap_driver.h" #include "dgap_proc.h" -#include "dgap_mgmt.h" #include "dgap_conf.h" #include "dgap_parse.h" -- GitLab From cbe0ffb5201fc5b2185a83e46923cf038607fe41 Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Thu, 22 Aug 2013 22:17:10 -0400 Subject: [PATCH 797/942] staging: dgap: removes references to proc code This patch removes references to proc functions and structs in the code. The kernel uses sysfs instead of proc now. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap_driver.h | 8 -------- drivers/staging/dgap/dgap_fep5.c | 2 -- 2 files changed, 10 deletions(-) diff --git a/drivers/staging/dgap/dgap_driver.h b/drivers/staging/dgap/dgap_driver.h index b76ec3c39ef0a..b1cf489a729c8 100644 --- a/drivers/staging/dgap/dgap_driver.h +++ b/drivers/staging/dgap/dgap_driver.h @@ -412,10 +412,6 @@ struct board_t */ char *msgbuf_head; char *msgbuf; - - /* /proc/ entries */ - struct proc_dir_entry *proc_entry_pointer; - struct dgap_proc_entry *dgap_board_table; }; @@ -564,10 +560,6 @@ struct channel_t { ulong ch_err_break; /* Count of breaks on channel */ ulong ch_err_overrun; /* Count of overruns on channel */ - /* /proc// entries */ - struct proc_dir_entry *proc_entry_pointer; - struct dgap_proc_entry *dgap_channel_table; - uint ch_sniff_in; uint ch_sniff_out; char *ch_sniff_buf; /* Sniff buffer for proc */ diff --git a/drivers/staging/dgap/dgap_fep5.c b/drivers/staging/dgap/dgap_fep5.c index 45b0f28a202a7..291b414863c12 100644 --- a/drivers/staging/dgap/dgap_fep5.c +++ b/drivers/staging/dgap/dgap_fep5.c @@ -133,8 +133,6 @@ int dgap_after_config_loaded(void) */ dgap_Board[i]->flipbuf = dgap_driver_kzmalloc(MYFLIPLEN, GFP_ATOMIC); dgap_Board[i]->flipflagbuf = dgap_driver_kzmalloc(MYFLIPLEN, GFP_ATOMIC); - - //dgap_proc_register_basic_postscan(i); } return (rc); -- GitLab From 13db3befdb460365cbdd6666472ae8d4ce18c85f Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Thu, 22 Aug 2013 22:17:11 -0400 Subject: [PATCH 798/942] staging: dgap: removes proc.c This patch removes proc.c. This code isn't needed anymore because a previous patch removed references to it and because the kernel uses sysfs instead of proc. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap_proc.c | 1923 ------------------------------ 1 file changed, 1923 deletions(-) delete mode 100644 drivers/staging/dgap/dgap_proc.c diff --git a/drivers/staging/dgap/dgap_proc.c b/drivers/staging/dgap/dgap_proc.c deleted file mode 100644 index 8c46b24848238..0000000000000 --- a/drivers/staging/dgap/dgap_proc.c +++ /dev/null @@ -1,1923 +0,0 @@ -/* - * Copyright 2003 Digi International (www.digi.com) - * Scott H Kilau - * - * 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, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * - * NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE! - * - * This is shared code between Digi's CVS archive and the - * Linux Kernel sources. - * Changing the source just for reformatting needlessly breaks - * our CVS diff history. - * - * Send any bug fixes/changes to: Eng.Linux at digi dot com. - * Thank you. - * - * - * $Id: dgap_proc.c,v 1.2 2010/12/22 21:22:39 markh Exp $ - */ - -#include -#include -#include /* For jiffies, task states */ -#include /* For tasklet and interrupt structs/defines */ -#include -#include -#include -#include -#include /* For in_egroup_p() */ -#include -#include /* For copy_from_user/copy_to_user */ -#include - -#include "dgap_driver.h" -#include "dgap_proc.h" -#include "dgap_conf.h" -#include "dgap_parse.h" -#include "dgap_fep5.h" - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37) -#define init_MUTEX(sem) sema_init(sem, 1) -#endif - -/* The /proc/dgap directory */ -static struct proc_dir_entry *ProcDGAP; - - -/* File operation declarations */ -static int dgap_gen_proc_open(struct inode *, struct file *); -static int dgap_gen_proc_close(struct inode *, struct file *); -static ssize_t dgap_gen_proc_read(struct file *file, char __user *buf, size_t count, loff_t *ppos); -static ssize_t dgap_gen_proc_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos); - -static int dgap_proc_chk_perm(struct inode *, int); - -static const struct file_operations dgap_proc_file_ops = -{ - .owner = THIS_MODULE, - .read = dgap_gen_proc_read, /* read */ - .write = dgap_gen_proc_write, /* write */ - .open = dgap_gen_proc_open, /* open */ - .release = dgap_gen_proc_close, /* release */ -}; - - -static struct inode_operations dgap_proc_inode_ops = -{ - .permission = dgap_proc_chk_perm -}; - - -static void dgap_register_proc_table(struct dgap_proc_entry *, struct proc_dir_entry *); -static void dgap_unregister_proc_table(struct dgap_proc_entry *, struct proc_dir_entry *); -static void dgap_remove_proc_entry(struct proc_dir_entry *pde); - - -/* Stuff in /proc/ */ -static int dgap_read_info(struct dgap_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos); -static int dgap_write_info(struct dgap_proc_entry *table, int dir, struct file *filp, - const char __user *buffer, ssize_t *lenp, loff_t *ppos); - -static int dgap_read_mknod(struct dgap_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos); - -static struct dgap_proc_entry dgap_table[] = { - {DGAP_INFO, "info", 0600, NULL, NULL, NULL, &dgap_read_info, &dgap_write_info, - NULL, __SEMAPHORE_INITIALIZER(dgap_table[0].excl_sem, 1), 0, NULL }, - {DGAP_MKNOD, "mknod", 0600, NULL, NULL, NULL, &dgap_read_mknod, NULL, - NULL, __SEMAPHORE_INITIALIZER(dgap_table[1].excl_sem, 1), 0, NULL }, - - {0} -}; - - -/* Stuff in /proc// */ -static int dgap_read_board_info(struct dgap_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos); -static int dgap_read_board_vpd(struct dgap_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos); -static int dgap_read_board_vpddata(struct dgap_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos); -static int dgap_read_board_mknod(struct dgap_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos); -static int dgap_read_board_ttystats(struct dgap_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos); -static int dgap_read_board_ttyflags(struct dgap_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos); - -static struct dgap_proc_entry dgap_board_table[] = { - {DGAP_BOARD_INFO, "info", 0600, NULL, NULL, NULL, &dgap_read_board_info, NULL, - NULL, __SEMAPHORE_INITIALIZER(dgap_board_table[0].excl_sem, 1), 0, NULL }, - {DGAP_BOARD_VPD, "vpd", 0600, NULL, NULL, NULL, &dgap_read_board_vpd, NULL, - NULL, __SEMAPHORE_INITIALIZER(dgap_board_table[1].excl_sem, 1), 0, NULL }, - {DGAP_BOARD_VPDDATA, "vpddata", 0600, NULL, NULL, NULL, &dgap_read_board_vpddata, NULL, - NULL, __SEMAPHORE_INITIALIZER(dgap_board_table[2].excl_sem, 1), 0, NULL }, - {DGAP_BOARD_TTYSTATS, "stats", 0600, NULL, NULL, NULL, &dgap_read_board_ttystats, NULL, - NULL, __SEMAPHORE_INITIALIZER(dgap_board_table[3].excl_sem, 1), 0, NULL }, - {DGAP_BOARD_TTYFLAGS, "flags", 0600, NULL, NULL, NULL, &dgap_read_board_ttyflags, NULL, - NULL, __SEMAPHORE_INITIALIZER(dgap_board_table[4].excl_sem, 1), 0, NULL }, - {DGAP_BOARD_MKNOD, "mknod", 0600, NULL, NULL, NULL, &dgap_read_board_mknod, NULL, - NULL, __SEMAPHORE_INITIALIZER(dgap_board_table[5].excl_sem, 1), 0, NULL }, - {0} -}; - - -/* Stuff in /proc// */ -static int dgap_read_channel_info(struct dgap_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos); -static int dgap_open_channel_sniff(struct dgap_proc_entry *table, int dir, struct file *filp, - void *buffer, ssize_t *lenp, loff_t *ppos); -static int dgap_close_channel_sniff(struct dgap_proc_entry *table, int dir, struct file *filp, - void *buffer, ssize_t *lenp, loff_t *ppos); -static int dgap_read_channel_sniff(struct dgap_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos); -static int dgap_read_channel_custom_ttyname(struct dgap_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos); -static int dgap_read_channel_custom_prname(struct dgap_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos); -static int dgap_read_channel_fepstate(struct dgap_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos); - - -static struct dgap_proc_entry dgap_channel_table[] = { - {DGAP_PORT_INFO, "info", 0600, NULL, NULL, NULL, &dgap_read_channel_info, NULL, - NULL, __SEMAPHORE_INITIALIZER(dgap_channel_table[0].excl_sem, 1), 0, NULL }, - {DGAP_PORT_SNIFF, "sniff", 0600, NULL, &dgap_open_channel_sniff, &dgap_close_channel_sniff, &dgap_read_channel_sniff, NULL, - NULL, __SEMAPHORE_INITIALIZER(dgap_channel_table[1].excl_sem, 1), 0, NULL}, - {DGAP_PORT_CUSTOM_TTYNAME, "ttyname", 0600, NULL, NULL, NULL, &dgap_read_channel_custom_ttyname, NULL, - NULL, __SEMAPHORE_INITIALIZER(dgap_channel_table[2].excl_sem, 1), 0, NULL }, - {DGAP_PORT_CUSTOM_PRNAME, "prname", 0600, NULL, NULL, NULL, &dgap_read_channel_custom_prname, NULL, - NULL, __SEMAPHORE_INITIALIZER(dgap_channel_table[3].excl_sem, 1), 0, NULL }, - {DGAP_PORT_FEPSTATE, "fepstate", 0600, NULL, NULL, NULL, &dgap_read_channel_fepstate, NULL, - NULL, __SEMAPHORE_INITIALIZER(dgap_channel_table[4].excl_sem, 1), 0, NULL }, - {0} -}; - - -/* - * test_perm does NOT grant the superuser all rights automatically, because - * some entries are readonly even to root. - */ -static inline int test_perm(int mode, int op) -{ - if (!current_euid()) - mode >>= 6; - else if (in_egroup_p(0)) - mode >>= 3; - if ((mode & op & 0007) == op) - return 0; - if (capable(CAP_SYS_ADMIN)) - return 0; - return -EACCES; -} - - -/* - * /proc/sys support - */ -static inline int dgap_proc_match(int len, const char *name, struct proc_dir_entry *de) -{ - if (!de || !de->low_ino) - return 0; - if (de->namelen != len) - return 0; - return !memcmp(name, de->name, len); -} - - -/* - * Scan the entries in table and add them all to /proc at the position - * referred to by "root" - */ -static void dgap_register_proc_table(struct dgap_proc_entry *table, struct proc_dir_entry *root) -{ - struct proc_dir_entry *de; - int len; - mode_t mode; - - for (; table->magic; table++) { - /* Can't do anything without a proc name. */ - if (!table->name) { - DPR_PROC(("dgap_register_proc_table, no name...\n")); - continue; - } - - /* Maybe we can't do anything with it... */ - if (!table->read_handler && !table->write_handler && !table->child) { - DPR_PROC((KERN_WARNING "DGAP PROC: Can't register %s\n", table->name)); - continue; - } - - len = strlen(table->name); - mode = table->mode; - de = NULL; - - if (!table->child) { - mode |= S_IFREG; - } else { - mode |= S_IFDIR; - for (de = root->subdir; de; de = de->next) { - if (dgap_proc_match(len, table->name, de)) - break; - } - - /* If the subdir exists already, de is non-NULL */ - } - - if (!de) { - de = create_proc_entry(table->name, mode, root); - if (!de) - continue; - de->data = (void *) table; - if (!table->child) { - de->proc_iops = &dgap_proc_inode_ops; - de->proc_fops = &dgap_proc_file_ops; - } - } - - table->de = de; - - if (de->mode & S_IFDIR) - dgap_register_proc_table(table->child, de); - - } -} - - - -/* - * Unregister a /proc sysctl table and any subdirectories. - */ -static void dgap_unregister_proc_table(struct dgap_proc_entry *table, struct proc_dir_entry *root) -{ - struct proc_dir_entry *de; - - for (; table->magic; table++) { - if (!(de = table->de)) - continue; - - if (de->mode & S_IFDIR) { - if (!table->child) { - DPR_PROC((KERN_ALERT "Help - malformed sysctl tree on free\n")); - continue; - } - - /* recurse down into subdirectory... */ - DPR_PROC(("Recursing down a directory...\n")); - dgap_unregister_proc_table(table->child, de); - - /* Don't unregister directories which still have entries.. */ - if (de->subdir) - continue; - } - /* Don't unregister proc entries that are still being used.. */ - if ((atomic_read(&de->count)) != 1) { - DPR_PROC(("proc entry in use... Not removing...\n")); - continue; - } - dgap_remove_proc_entry(de); - table->de = NULL; - } -} - - - -static int dgap_gen_proc_open(struct inode *inode, struct file *file) -{ - struct proc_dir_entry *de; - struct dgap_proc_entry *entry; - int (*handler) (struct dgap_proc_entry *table, int dir, struct file *filp, - void *buffer, ssize_t *lenp, loff_t *ppos); - int ret = 0, error = 0; - - de = (struct proc_dir_entry *) PDE(file->f_dentry->d_inode); - if (!de || !de->data) { - ret = -ENXIO; - goto done; - } - - entry = (struct dgap_proc_entry *) de->data; - if (!entry) { - ret = -ENXIO; - goto done; - } - - down(&entry->excl_sem); - - if (entry->excl_cnt) { - ret = -EBUSY; - } else { - entry->excl_cnt++; - handler = entry->open_handler; - if (handler) { - error = (*handler) (entry, OUTBOUND, file, NULL, NULL, NULL); - if (error) { - entry->excl_cnt--; - ret = error; - } - } - } - - up(&entry->excl_sem); - -done: - - return ret; -} - - -static int dgap_gen_proc_close(struct inode *inode, struct file *file) -{ - struct proc_dir_entry *de; - int (*handler) (struct dgap_proc_entry *table, int dir, struct file *filp, - void *buffer, ssize_t *lenp, loff_t *ppos); - struct dgap_proc_entry *entry; - int error = 0; - - de = (struct proc_dir_entry *) PDE(file->f_dentry->d_inode); - if (!de || !de->data) - goto done; - - entry = (struct dgap_proc_entry *) de->data; - if (!entry) - goto done; - - down(&entry->excl_sem); - - if (entry->excl_cnt) - entry->excl_cnt = 0; - - - handler = entry->close_handler; - if (handler) { - error = (*handler) (entry, OUTBOUND, file, NULL, NULL, NULL); - } - - up(&entry->excl_sem); - -done: - return 0; -} - - -static ssize_t dgap_gen_proc_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) -{ - struct proc_dir_entry *de; - struct dgap_proc_entry *entry; - int (*handler) (struct dgap_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos2); - ssize_t res; - ssize_t error; - - de = (struct proc_dir_entry*) PDE(file->f_dentry->d_inode); - if (!de || !de->data) - return -ENXIO; - - entry = (struct dgap_proc_entry *) de->data; - if (!entry) - return -ENXIO; - - /* Test for read permission */ - if (test_perm(entry->mode, 4)) - return -EPERM; - - res = count; - - handler = entry->read_handler; - if (!handler) - return -ENXIO; - - error = (*handler) (entry, OUTBOUND, file, buf, &res, ppos); - if (error) - return error; - - return res; -} - - -static ssize_t dgap_gen_proc_write(struct file *file, const char __user *buf, - size_t count, loff_t *ppos) -{ - struct proc_dir_entry *de; - struct dgap_proc_entry *entry; - int (*handler) (struct dgap_proc_entry *table, int dir, struct file *filp, - const char __user *buffer, ssize_t *lenp, loff_t *ppos2); - ssize_t res; - ssize_t error; - - de = (struct proc_dir_entry *) PDE(file->f_dentry->d_inode); - if (!de || !de->data) - return -ENXIO; - - entry = (struct dgap_proc_entry *) de->data; - if (!entry) - return -ENXIO; - - /* Test for write permission */ - if (test_perm(entry->mode, 2)) - return -EPERM; - - res = count; - - handler = entry->write_handler; - if (!handler) - return -ENXIO; - - error = (*handler) (entry, INBOUND, file, buf, &res, ppos); - if (error) - return error; - - return res; -} - - -static int dgap_proc_chk_perm(struct inode *inode, int op) -{ - return test_perm(inode->i_mode, op); -} - - -/* - * Return what is (hopefully) useful information about the - * driver. - */ -static int dgap_read_info(struct dgap_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos) -{ - static int done = 0; - static char buf[4096]; - char *p = buf; - - DPR_PROC(("dgap_proc_info\n")); - - if (done) { - done = 0; - *lenp = 0; - return 0; - } - - p += sprintf(p, "Driver:\t\t%s\n", DG_NAME); - p += sprintf(p, "\n"); - p += sprintf(p, "Debug:\t\t0x%x\n", dgap_debug); - p += sprintf(p, "Rawreadok:\t0x%x\n", dgap_rawreadok); - p += sprintf(p, "Max Boards:\t%d\n", MAXBOARDS); - p += sprintf(p, "Total Boards:\t%d\n", dgap_NumBoards); - p += sprintf(p, "Poll rate:\t%dms\n", dgap_poll_tick); - p += sprintf(p, "Poll counter:\t%ld\n", dgap_poll_counter); - p += sprintf(p, "State:\t\t%s\n", dgap_driver_state_text[dgap_driver_state]); - - if (copy_to_user(buffer, buf, (p - (char *) buf))) - return -EFAULT; - - *lenp = p - (char *) buf; - *ppos += p - (char *) buf; - done = 1; - return 0; -} - - -/* - * When writing to the "info" entry point, I actually allow one - * to modify certain variables. This may be a sleazy overload - * of this /proc entry, but I don't want: - * - * a. to clutter /proc more than I have to - * b. to overload the "config" entry, which would be somewhat - * more natural - * c. necessarily advertise the fact this ability exists - * - * The continued support of this feature has not yet been - * guaranteed. - * - * Writing operates on a "state machine" principle. - * - * State 0: waiting for a symbol to start. Waiting for anything - * which isn't " ' = or whitespace. - * State 1: reading a symbol. If the character is a space, move - * to state 2. If =, move to state 3. If " or ', move - * to state 0. - * State 2: Waiting for =... suck whitespace. If anything other - * than whitespace, drop to state 0. - * State 3: Got =. Suck whitespace waiting for value to start. - * If " or ', go to state 4 (and remember which quote it - * was). Otherwise, go to state 5. - * State 4: Reading value, within quotes. Everything is added to - * value up until the matching quote. When you hit the - * matching quote, try to set the variable, then state 0. - * State 5: Reading value, outside quotes. Everything not " ' = - * or whitespace goes in value. Hitting one of the - * terminators tosses us back to state 0 after trying to - * set the variable. - */ -typedef enum { - INFO_NONE, INFO_INT, INFO_CHAR, INFO_SHORT, - INFO_LONG, INFO_PTR, INFO_STRING, INFO_END -} info_proc_var_val; - -static struct { - char *name; - info_proc_var_val type; - int rw; /* 0=readonly */ - void *val_ptr; -} dgap_info_vars[] = { - { "rawreadok", INFO_INT, 1, (void *) &dgap_rawreadok }, - { "pollrate", INFO_INT, 1, (void *) &dgap_poll_tick }, - { NULL, INFO_NONE, 0, NULL }, - { "debug", INFO_LONG, 1, (void *) &dgap_debug }, - { NULL, INFO_END, 0, NULL } -}; - -static void dgap_set_info_var(char *name, char *val) -{ - int i; - unsigned long newval; - unsigned char charval; - unsigned short shortval; - unsigned int intval; - - for (i = 0; dgap_info_vars[i].type != INFO_END; i++) { - if (dgap_info_vars[i].name) - if (!strcmp(name, dgap_info_vars[i].name)) - break; - } - - if (dgap_info_vars[i].type == INFO_END) - return; - if (dgap_info_vars[i].rw == 0) - return; - if (dgap_info_vars[i].val_ptr == NULL) - return; - - newval = simple_strtoul(val, NULL, 0 ); - - switch (dgap_info_vars[i].type) { - case INFO_CHAR: - charval = newval & 0xff; - APR(("Modifying %s (%lx) <= 0x%02x (%d)\n", - name, (long)(dgap_info_vars[i].val_ptr ), - charval, charval)); - *(uchar *)(dgap_info_vars[i].val_ptr) = charval; - break; - case INFO_SHORT: - shortval = newval & 0xffff; - APR(("Modifying %s (%lx) <= 0x%04x (%d)\n", - name, (long)(dgap_info_vars[i].val_ptr), - shortval, shortval)); - *(ushort *)(dgap_info_vars[i].val_ptr) = shortval; - break; - case INFO_INT: - intval = newval & 0xffffffff; - APR(("Modifying %s (%lx) <= 0x%08x (%d)\n", - name, (long)(dgap_info_vars[i].val_ptr), - intval, intval)); - *(uint *)(dgap_info_vars[i].val_ptr) = intval; - break; - case INFO_LONG: - APR(("Modifying %s (%lx) <= 0x%lx (%ld)\n", - name, (long)(dgap_info_vars[i].val_ptr), - newval, newval)); - *(ulong *)(dgap_info_vars[i].val_ptr) = newval; - break; - case INFO_PTR: - case INFO_STRING: - case INFO_END: - case INFO_NONE: - default: - break; - } -} - -static int dgap_write_info(struct dgap_proc_entry *table, int dir, struct file *filp, - const char __user *buffer, ssize_t *lenp, loff_t *ppos) -{ - static int state = 0; - #define MAXSYM 255 - static int sympos, valpos; - static char sym[MAXSYM + 1]; - static char val[MAXSYM + 1]; - static int quotchar = 0; - - int i; - - long len; - #define INBUFLEN 256 - char inbuf[INBUFLEN]; - - if (*ppos == 0) { - state = 0; - sympos = 0; sym[0] = 0; - valpos = 0; val[0] = 0; - quotchar = 0; - } - - if ((!*lenp) || (dir != INBOUND)) { - *lenp = 0; - return 0; - } - - len = *lenp; - - if (len > INBUFLEN - 1) - len = INBUFLEN - 1; - - if (copy_from_user(inbuf, buffer, len)) - return -EFAULT; - - inbuf[len] = 0; - - for (i = 0; i < len; i++) { - unsigned char c = inbuf[i]; - - switch (state) { - case 0: - quotchar = sympos = valpos = sym[0] = val[0] = 0; - if (!isspace(c) && (c != '\"') && - (c != '\'') && (c != '=')) { - sym[sympos++] = c; - state = 1; - break; - } - break; - case 1: - if (isspace(c)) { - sym[sympos] = 0; - state = 2; - break; - } - if (c == '=') { - sym[sympos] = 0; - state = 3; - break; - } - if ((c == '\"' ) || ( c == '\'' )) { - state = 0; - break; - } - if (sympos < MAXSYM) sym[sympos++] = c; - break; - case 2: - if (isspace(c)) break; - if (c == '=') { - state = 3; - break; - } - if ((c != '\"') && (c != '\'')) { - quotchar = sympos = valpos = sym[0] = val[0] = 0; - sym[sympos++] = c; - state = 1; - break; - } - state = 0; - break; - case 3: - if (isspace(c)) break; - if (c == '=') { - state = 0; - break; - } - if ((c == '\"') || (c == '\'')) { - state = 4; - quotchar = c; - break; - } - val[valpos++] = c; - state = 5; - break; - case 4: - if (c == quotchar) { - val[valpos] = 0; - dgap_set_info_var(sym, val); - state = 0; - break; - } - if (valpos < MAXSYM) val[valpos++] = c; - break; - case 5: - if (isspace(c) || (c == '\"') || - (c == '\'') || (c == '=')) { - val[valpos] = 0; - dgap_set_info_var(sym, val); - state = 0; - break; - } - if (valpos < MAXSYM) val[valpos++] = c; - break; - default: - break; - } - } - - *lenp = len; - *ppos += len; - - return len; -} - - -/* - * Return mknod information for the driver's devices. - */ -static int dgap_read_mknod(struct dgap_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos) -{ - static int done = 0; - static char buf[4096]; - char *p = buf; - - DPR_PROC(("dgap_proc_info\n")); - - if (done) { - done = 0; - *lenp = 0; - return 0; - } - - DPR_PROC(("dgap_proc_mknod\n")); - - p += sprintf(p, "#\tCreate the management device.\n"); - p += sprintf(p, "/dev/dg/dgap/mgmt\t%d\t%d\t%d\t%d\n", DIGI_DGAP_MAJOR, MGMT_MGMT, 1, 0); - p += sprintf(p, "/dev/dg/dgap/downld\t%d\t%d\t%d\t%d\n", DIGI_DGAP_MAJOR, MGMT_DOWNLD, 1, 0); - - if (copy_to_user(buffer, buf, (p - (char *) buf))) - return -EFAULT; - - *lenp = p - (char *) buf; - *ppos += p - (char *) buf; - done = 1; - return 0; -} - - - -/* - * Return what is (hopefully) useful information about the specific board. - */ -static int dgap_read_board_info(struct dgap_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos) -{ - struct board_t *brd; - static int done = 0; - static char buf[4096]; - char *p = buf; - char *name; - - DPR_PROC(("dgap_proc_brd_info\n")); - - brd = (struct board_t *) table->data; - - if (done || !brd || (brd->magic != DGAP_BOARD_MAGIC)) { - done = 0; - *lenp = 0; - return 0; - } - - name = brd->name; - - p += sprintf(p, "Board Name = %s\n", name); - p += sprintf(p, "Board Type = %d\n", brd->type); - p += sprintf(p, "Number of Ports = %d\n", brd->nasync); - - /* - * report some things about the PCI bus that are important - * to some applications - */ - p += sprintf(p, "Vendor ID = 0x%x\n", brd->vendor); - p += sprintf(p, "Device ID = 0x%x\n", brd->device); - p += sprintf(p, "Subvendor ID = 0x%x\n", brd->subvendor); - p += sprintf(p, "Subdevice ID = 0x%x\n", brd->subdevice); - p += sprintf(p, "Bus = %d\n", brd->pci_bus); - p += sprintf(p, "Slot = %d\n", brd->pci_slot); - - /* - * report the physical addresses assigned to us when we got - * registered - */ - p += sprintf(p, "Memory Base Address = 0x%lx\n", brd->membase); - p += sprintf(p, "Remapped Memory Base Address = 0x%p\n", brd->re_map_membase); - - p += sprintf(p, "Current state of board = %s\n", dgap_state_text[brd->state]); - - if (brd->bd_flags & BD_FEP5PLUS) - p += sprintf(p, "FEP5+ Support = Yes\n"); - else - p += sprintf(p, "FEP5+ Support = No\n"); - - p += sprintf(p, "Interrupt #: %ld. Times interrupted: %ld\n", - brd->irq, brd->intr_count); - p += sprintf(p, "Majors allocated to board = TTY: %d PR: %d\n", - brd->SerialDriver->major, brd->PrintDriver->major); - - - if (copy_to_user(buffer, buf, (p - (char *) buf))) - return -EFAULT; - - *lenp = p - (char *) buf; - *ppos += p - (char *) buf; - done = 1; - return 0; -} - - -static int dgap_read_board_vpddata(struct dgap_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos) -{ - struct board_t *brd; - static int done = 0; - static char buf[4096]; - int i = 0, j = 0; - char *p = buf; - - DPR_PROC(("dgap_proc_brd_info\n")); - - brd = (struct board_t *) table->data; - - if (done || !brd || (brd->magic != DGAP_BOARD_MAGIC)) { - done = 0; - *lenp = 0; - return 0; - } - - p += sprintf(p, "\n 0 1 2 3 4 5 6 7 8 9 A B C D E F\n"); - - /* Ending at 0xC0, because nothing but zeros exist after that offset */ - for (i = 0; i < 0xC0; i++) { - j = i; - if (!(i % 16)) { - if (j > 0) { - p += sprintf(p, " "); - for (j = i - 16; j < i; j++) { - if (0x20 <= brd->vpd[j] && brd->vpd[j] <= 0x7e) - p += sprintf(p, "%c", brd->vpd[j]); - else - p += sprintf(p, "."); - } - p += sprintf(p, "\n"); - } - p += sprintf(p, "%04X ", i); - } - p += sprintf(p, "%02X ", brd->vpd[i]); - } - if (!(i % 16)) { - p += sprintf(p, " "); - for (j = i - 16; j < i; j++) { - if (0x20 <= brd->vpd[j] && brd->vpd[j] <= 0x7e) - p += sprintf(p, "%c", brd->vpd[j]); - else - p += sprintf(p, "."); - } - p += sprintf(p, "\n"); - } - - p += sprintf(p, "\n"); - - if (copy_to_user(buffer, buf, (p - (char *) buf))) - return -EFAULT; - - *lenp = p - (char *) buf; - *ppos += p - (char *) buf; - done = 1; - return 0; -} - - -static int dgap_read_board_vpd(struct dgap_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos) -{ - struct board_t *brd; - static int done = 0; - static char buf[4096]; - char *p = buf; - long ptr; - u16 i, j; - uchar len; - - DPR_PROC(("dgap_proc_brd_info\n")); - - brd = (struct board_t *) table->data; - - if (done || !brd || (brd->magic != DGAP_BOARD_MAGIC) || !(brd->bd_flags & BD_HAS_VPD)) { - done = 0; - *lenp = 0; - return 0; - } - - ptr = 0; - - /* Description */ - if (brd->vpd[ptr] == 0x82) { - ptr++; - - p += sprintf(p, "*DS: "); - len = brd->vpd[ptr]; - ptr += 2; - for (i = len; i; i--) { - uchar a; - a = brd->vpd[ptr]; - ptr++; - p += sprintf(p, "%c", a); - } - p += sprintf(p, "\n"); - } - - /* VPD */ - if (brd->vpd[ptr] == 0x90) { - ptr += 3; - - i = brd->vpd[ptr]; - - while (i > 0) { - - uchar a, b; - uchar str1[16]; - - a = brd->vpd[ptr]; - ptr++; - b = brd->vpd[ptr]; - ptr++; - - if ((a == 'P') && (b == 'N')) { - strcpy (str1, "*PN"); - } - else if ((a == 'E') && (b == 'C')) { - strcpy (str1, "*EC"); - } - else if ((a == 'F') && (b == 'N')) { - strcpy (str1, "*FN"); - } - else if ((a == 'M') && (b == 'N')) { - strcpy (str1, "*MF"); - } - else if ((a == 'S') && (b == 'N')) { - strcpy (str1, "*SN"); - } - else if ((a == 'R') && (b == 'L')) { - strcpy (str1, "*RL"); - } - else if ((a == 'D') && (b == 'D')) { - strcpy (str1, "*DD"); - } - else if ((a == 'D') && (b == 'G')) { - strcpy (str1, "*DG"); - } - else if ((a == 'L') && (b == 'L')) { - strcpy (str1, "*LL"); - } - else { - break; - } - - len = brd->vpd[ptr]; - ptr++; - - p += sprintf(p, "%s: ", str1); - - for (j = len; j; j--) { - uchar aa; - aa = brd->vpd[ptr]; - ptr++; - p += sprintf(p, "%c", aa); - } - - p += sprintf(p, "\n"); - - i -= (3 + len); - } - } - - if (copy_to_user(buffer, buf, (p - (char *) buf))) - return -EFAULT; - - *lenp = p - (char *) buf; - *ppos += p - (char *) buf; - done = 1; - return 0; -} - - - -/* - * Return what is (hopefully) useful stats about the specific board's ttys - */ -static int dgap_read_board_ttystats(struct dgap_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos) -{ - struct board_t *brd; - static int done = 0; - static char buf[4096]; - char *p = buf; - int i = 0; - - DPR_PROC(("dgap_proc_brd_info\n")); - - brd = (struct board_t *) table->data; - - if (done || !brd || (brd->magic != DGAP_BOARD_MAGIC)) { - done = 0; - *lenp = 0; - return 0; - } - - /* Prepare the Header Labels */ - p += sprintf(p, "%2s %10s %23s %10s\n", - "Ch", "Chars Rx", " Rx Par--Brk--Frm--Ovr", "Chars Tx"); - - for (i = 0; i < brd->nasync; i++) { - - struct channel_t *ch = brd->channels[i]; - p += sprintf(p, "%2d ", i); - p += sprintf(p, "%10ld ", ch->ch_rxcount); - p += sprintf(p, " %4ld %4ld %4ld %4ld ", ch->ch_err_parity, - ch->ch_err_break, ch->ch_err_frame, ch->ch_err_overrun); - p += sprintf(p, "%10ld ", ch->ch_txcount); - p += sprintf(p, "\n"); - } - - if (copy_to_user(buffer, buf, (p - (char *) buf))) - return -EFAULT; - - *lenp = p - (char *) buf; - *ppos += p - (char *) buf; - done = 1; - return 0; -} - - -/* - * Return what is (hopefully) useful flags about the specific board's ttys - */ -static int dgap_read_board_ttyflags(struct dgap_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos) -{ - struct board_t *brd; - static int done = 0; - static char buf[4096]; - char *p = buf; - int i = 0; - - DPR_PROC(("dgap_proc_brd_info\n")); - - brd = (struct board_t *) table->data; - - if (done || !brd || (brd->magic != DGAP_BOARD_MAGIC)) { - done = 0; - *lenp = 0; - return 0; - } - - /* Prepare the Header Labels */ - p += sprintf(p, "%2s %5s %5s %5s %5s %5s %10s Line Status Flags\n", - "Ch", "CFlag", "IFlag", "OFlag", "LFlag", "DFlag", "Baud"); - - for (i = 0; i < brd->nasync; i++) { - - struct channel_t *ch = brd->channels[i]; - - p += sprintf(p, "%2d ", i); - p += sprintf(p, "%5x ", ch->ch_c_cflag); - p += sprintf(p, "%5x ", ch->ch_c_iflag); - p += sprintf(p, "%5x ", ch->ch_c_oflag); - p += sprintf(p, "%5x ", ch->ch_c_lflag); - p += sprintf(p, "%5x ", ch->ch_digi.digi_flags); - p += sprintf(p, "%10d ", ch->ch_baud_info); - - if (!ch->ch_open_count) { - p += sprintf(p, " -- -- -- -- -- -- --") ; - } else { - p += sprintf(p, " op %s %s %s %s %s %s", - (ch->ch_mostat & UART_MCR_RTS) ? "rs" : "--", - (ch->ch_mistat & UART_MSR_CTS) ? "cs" : "--", - (ch->ch_mostat & UART_MCR_DTR) ? "tr" : "--", - (ch->ch_mistat & UART_MSR_DSR) ? "mr" : "--", - (ch->ch_mistat & UART_MSR_DCD) ? "cd" : "--", - (ch->ch_mistat & UART_MSR_RI) ? "ri" : "--"); - } - - p += sprintf(p, "\n"); - } - if (copy_to_user(buffer, buf, (p - (char *) buf))) - return -EFAULT; - - *lenp = p - (char *) buf; - *ppos += p - (char *) buf; - done = 1; - return 0; -} - - -/* - * Return mknod information for the board's devices. - */ -static int dgap_read_board_mknod(struct dgap_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos) -{ - struct board_t *brd; - static int done = 0; - static char buf[4096]; - char *p = buf; - - int bn; - struct cnode *cptr = NULL; - int found = FALSE; - int ncount = 0; - int starto = 0; - - - DPR_PROC(("dgap_proc_brd_info\n")); - - brd = (struct board_t *) table->data; - - if (done || !brd || (brd->magic != DGAP_BOARD_MAGIC)) { - done = 0; - *lenp = 0; - return 0; - } - - bn = brd->boardnum; - - /* - * For each board, output the device information in - * a handy table format... - */ - p += sprintf(p, "# NAME\t\tMAJOR\tMINOR\tCOUNT\tSTART\n"); - - - for (cptr = brd->bd_config; cptr; cptr = cptr->next) { - - if ((cptr->type == BNODE) && - ((cptr->u.board.type == APORT2_920P) || (cptr->u.board.type == APORT4_920P) || - (cptr->u.board.type == APORT8_920P) || (cptr->u.board.type == PAPORT4) || - (cptr->u.board.type == PAPORT8))) { - - found = TRUE; - if (cptr->u.board.v_start) - starto = cptr->u.board.start; - else - starto = 1; - } - - if (cptr->type == TNODE && found == TRUE) { - char *ptr1; - if (strstr(cptr->u.ttyname, "tty")) { - ptr1 = cptr->u.ttyname; - ptr1 += 3; - } - else { - ptr1 = cptr->u.ttyname; - } - - /* TTY devices */ - p += sprintf(p, "tty%s\t\t%d\t%d\t%d\t%d\n", - ptr1, brd->SerialDriver->major, - 0, dgap_config_get_number_of_ports(brd), starto); - - /* PR devices */ - p += sprintf(p, "pr%s\t\t%d\t%d\t%d\t%d\n", - ptr1, brd->PrintDriver->major, - 0, dgap_config_get_number_of_ports(brd), starto); - } - - if (cptr->type == CNODE) { - - /* TTY devices */ - p += sprintf(p, "tty%s\t\t%d\t%d\t%d\t%d\n", - cptr->u.conc.id, brd->SerialDriver->major, - ncount, cptr->u.conc.nport, - cptr->u.conc.v_start ? cptr->u.conc.start : 1); - - /* PR devices */ - p += sprintf(p, "pr%s\t\t%d\t%d\t%d\t%d\n", - cptr->u.conc.id, brd->PrintDriver->major, - ncount, cptr->u.conc.nport, - cptr->u.conc.v_start ? cptr->u.conc.start : 1); - - ncount += cptr->u.conc.nport; - } - - if (cptr->type == MNODE) { - - /* TTY devices */ - p += sprintf(p, "tty%s\t\t%d\t%d\t%d\t%d\n", - cptr->u.module.id, brd->SerialDriver->major, - ncount, cptr->u.module.nport, - cptr->u.module.v_start ? cptr->u.module.start : 1); - - /* PR devices */ - p += sprintf(p, "pr%s\t\t%d\t%d\t%d\t%d\n", - cptr->u.module.id, brd->PrintDriver->major, - ncount, cptr->u.module.nport, - cptr->u.module.v_start ? cptr->u.module.start : 1); - - ncount += cptr->u.module.nport; - - } - } - - if (copy_to_user(buffer, buf, (p - (char *) buf))) - return -EFAULT; - - *lenp = p - (char *) buf; - *ppos += p - (char *) buf; - done = 1; - return 0; -} - - - - - -/* - * Return what is (hopefully) useful information about the specific channel. - */ -static int dgap_read_channel_info(struct dgap_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos) -{ - struct channel_t *ch; - static int done = 0; - static char buf[4096]; - char *p = buf; - - DPR_PROC(("dgap_proc_info\n")); - - ch = (struct channel_t *) table->data; - - if (done || !ch || (ch->magic != DGAP_CHANNEL_MAGIC)) { - done = 0; - *lenp = 0; - return 0; - } - - p += sprintf(p, "Port number:\t\t%d\n", ch->ch_portnum); - p += sprintf(p, "\n"); - - /* Prepare the Header Labels */ - p += sprintf(p, "%10s %23s %10s\n", - "Chars Rx", " Rx Par--Brk--Frm--Ovr", "Chars Tx"); - p += sprintf(p, "%10ld ", ch->ch_rxcount); - p += sprintf(p, " %4ld %4ld %4ld %4ld ", ch->ch_err_parity, - ch->ch_err_break, ch->ch_err_frame, ch->ch_err_overrun); - p += sprintf(p, "%10ld ", ch->ch_txcount); - p += sprintf(p, "\n\n"); - - /* Prepare the Header Labels */ - p += sprintf(p, "%5s %5s %5s %5s %5s %10s Line Status Flags\n", - "CFlag", "IFlag", "OFlag", "LFlag", "DFlag", "Baud"); - - p += sprintf(p, "%5x ", ch->ch_c_cflag); - p += sprintf(p, "%5x ", ch->ch_c_iflag); - p += sprintf(p, "%5x ", ch->ch_c_oflag); - p += sprintf(p, "%5x ", ch->ch_c_lflag); - p += sprintf(p, "%5x ", ch->ch_digi.digi_flags); - p += sprintf(p, "%10d ", ch->ch_baud_info); - if (!ch->ch_open_count) { - p += sprintf(p, " -- -- -- -- -- -- --") ; - } else { - p += sprintf(p, " op %s %s %s %s %s %s", - (ch->ch_mostat & UART_MCR_RTS) ? "rs" : "--", - (ch->ch_mistat & UART_MSR_CTS) ? "cs" : "--", - (ch->ch_mostat & UART_MCR_DTR) ? "tr" : "--", - (ch->ch_mistat & UART_MSR_DSR) ? "mr" : "--", - (ch->ch_mistat & UART_MSR_DCD) ? "cd" : "--", - (ch->ch_mistat & UART_MSR_RI) ? "ri" : "--"); - } - p += sprintf(p, "\n\n"); - - if (copy_to_user(buffer, buf, (p - (char *) buf))) - return -EFAULT; - - *lenp = p - (char *) buf; - *ppos += p - (char *) buf; - done = 1; - return 0; -} - - -/* - * Return mknod information for the board's devices. - */ -static int dgap_read_channel_custom_ttyname(struct dgap_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos) -{ - struct channel_t *ch; - struct board_t *brd; - static int done = 0; - static char buf[4096]; - char *p = buf; - - int cn; - int bn; - struct cnode *cptr = NULL; - int found = FALSE; - int ncount = 0; - int starto = 0; - int i = 0; - - DPR_PROC(("dgap_proc_brd_info\n")); - - ch = (struct channel_t *) table->data; - - if (done || !ch || (ch->magic != DGAP_CHANNEL_MAGIC)) { - done = 0; - *lenp = 0; - return 0; - } - - brd = ch->ch_bd; - - if (done || !brd || (brd->magic != DGAP_BOARD_MAGIC)) { - done = 0; - *lenp = 0; - return 0; - } - - bn = brd->boardnum; - cn = ch->ch_portnum; - - /* - * For each board, output the device information in - * a handy table format... - */ - - for (cptr = brd->bd_config; cptr; cptr = cptr->next) { - - if ((cptr->type == BNODE) && - ((cptr->u.board.type == APORT2_920P) || (cptr->u.board.type == APORT4_920P) || - (cptr->u.board.type == APORT8_920P) || (cptr->u.board.type == PAPORT4) || - (cptr->u.board.type == PAPORT8))) { - - found = TRUE; - if (cptr->u.board.v_start) - starto = cptr->u.board.start; - else - starto = 1; - } - - if (cptr->type == TNODE && found == TRUE) { - char *ptr1; - if (strstr(cptr->u.ttyname, "tty")) { - ptr1 = cptr->u.ttyname; - ptr1 += 3; - } - else { - ptr1 = cptr->u.ttyname; - } - - for (i = 0; i < dgap_config_get_number_of_ports(brd); i++) { - if (cn == i) { - p += sprintf(p, "tty%s%02d\n", - ptr1, i + starto); - } - } - } - - if (cptr->type == CNODE) { - - for (i = 0; i < cptr->u.conc.nport; i++) { - if (cn == (i + ncount)) { - p += sprintf(p, "tty%s%02d\n", cptr->u.conc.id, - i + (cptr->u.conc.v_start ? cptr->u.conc.start : 1)); - } - } - - ncount += cptr->u.conc.nport; - } - - if (cptr->type == MNODE) { - - for (i = 0; i < cptr->u.module.nport; i++) { - if (cn == (i + ncount)) { - p += sprintf(p, "tty%s%02d\n", cptr->u.module.id, - i + (cptr->u.module.v_start ? cptr->u.module.start : 1)); - } - } - - ncount += cptr->u.module.nport; - - } - } - - if (copy_to_user(buffer, buf, (p - (char *) buf))) - return -EFAULT; - - *lenp = p - (char *) buf; - *ppos += p - (char *) buf; - done = 1; - return 0; -} - - -/* - * Return mknod information for the board's devices. - */ -static int dgap_read_channel_custom_prname(struct dgap_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos) -{ - struct channel_t *ch; - struct board_t *brd; - static int done = 0; - static char buf[4096]; - char *p = buf; - - int cn; - int bn; - struct cnode *cptr = NULL; - int found = FALSE; - int ncount = 0; - int starto = 0; - int i = 0; - - DPR_PROC(("dgap_proc_brd_info\n")); - - ch = (struct channel_t *) table->data; - - if (done || !ch || (ch->magic != DGAP_CHANNEL_MAGIC)) { - done = 0; - *lenp = 0; - return 0; - } - - brd = ch->ch_bd; - - if (done || !brd || (brd->magic != DGAP_BOARD_MAGIC)) { - done = 0; - *lenp = 0; - return 0; - } - - bn = brd->boardnum; - cn = ch->ch_portnum; - - /* - * For each board, output the device information in - * a handy table format... - */ - - for (cptr = brd->bd_config; cptr; cptr = cptr->next) { - - if ((cptr->type == BNODE) && - ((cptr->u.board.type == APORT2_920P) || (cptr->u.board.type == APORT4_920P) || - (cptr->u.board.type == APORT8_920P) || (cptr->u.board.type == PAPORT4) || - (cptr->u.board.type == PAPORT8))) { - - found = TRUE; - if (cptr->u.board.v_start) - starto = cptr->u.board.start; - else - starto = 1; - } - - if (cptr->type == TNODE && found == TRUE) { - char *ptr1; - if (strstr(cptr->u.ttyname, "tty")) { - ptr1 = cptr->u.ttyname; - ptr1 += 3; - } - else { - ptr1 = cptr->u.ttyname; - } - - for (i = 0; i < dgap_config_get_number_of_ports(brd); i++) { - if (cn == i) { - p += sprintf(p, "pr%s%02d\n", - ptr1, i + starto); - } - } - } - - if (cptr->type == CNODE) { - - for (i = 0; i < cptr->u.conc.nport; i++) { - if (cn == (i + ncount)) { - p += sprintf(p, "pr%s%02d\n", cptr->u.conc.id, - i + (cptr->u.conc.v_start ? cptr->u.conc.start : 1)); - } - } - - ncount += cptr->u.conc.nport; - } - - if (cptr->type == MNODE) { - - for (i = 0; i < cptr->u.module.nport; i++) { - if (cn == (i + ncount)) { - p += sprintf(p, "pr%s%02d\n", cptr->u.module.id, - i + (cptr->u.module.v_start ? cptr->u.module.start : 1)); - } - } - - ncount += cptr->u.module.nport; - - } - } - - if (copy_to_user(buffer, buf, (p - (char *) buf))) - return -EFAULT; - - *lenp = p - (char *) buf; - *ppos += p - (char *) buf; - done = 1; - return 0; -} - - - - - -static int dgap_open_channel_sniff(struct dgap_proc_entry *table, int dir, struct file *filp, - void *buffer, ssize_t *lenp, loff_t *ppos) -{ - struct channel_t *ch; - ulong lock_flags; - - ch = (struct channel_t *) table->data; - - if (!ch || (ch->magic != DGAP_CHANNEL_MAGIC)) - return 0; - - ch->ch_sniff_buf = dgap_driver_kzmalloc(SNIFF_MAX, GFP_KERNEL); - - DGAP_LOCK(ch->ch_lock, lock_flags); - ch->ch_sniff_flags |= SNIFF_OPEN; - DGAP_UNLOCK(ch->ch_lock, lock_flags); - - return 0; -} - -static int dgap_close_channel_sniff(struct dgap_proc_entry *table, int dir, struct file *filp, - void *buffer, ssize_t *lenp, loff_t *ppos) -{ - struct channel_t *ch; - ulong lock_flags; - - ch = (struct channel_t *) table->data; - - if (!ch || (ch->magic != DGAP_CHANNEL_MAGIC)) - return 0; - - DGAP_LOCK(ch->ch_lock, lock_flags); - ch->ch_sniff_flags &= ~(SNIFF_OPEN); - kfree(ch->ch_sniff_buf); - DGAP_UNLOCK(ch->ch_lock, lock_flags); - - return 0; -} - - -/* - * Copy data from the monitoring buffer to the user, freeing space - * in the monitoring buffer for more messages - * - */ -static int dgap_read_channel_sniff(struct dgap_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos) -{ - struct channel_t *ch; - int n; - int r; - int offset = 0; - int res = 0; - ssize_t rtn = 0; - ulong lock_flags; - - ch = (struct channel_t *) table->data; - - if (!ch || (ch->magic != DGAP_CHANNEL_MAGIC)) { - rtn = -ENXIO; - goto done; - } - - /* - * Wait for some data to appear in the buffer. - */ - DGAP_LOCK(ch->ch_lock, lock_flags); - - for (;;) { - n = (ch->ch_sniff_in - ch->ch_sniff_out) & SNIFF_MASK; - - if (n != 0) - break; - - ch->ch_sniff_flags |= SNIFF_WAIT_DATA; - - DGAP_UNLOCK(ch->ch_lock, lock_flags); - - /* - * Go to sleep waiting until the condition becomes true. - */ - rtn = wait_event_interruptible(ch->ch_sniff_wait, - ((ch->ch_sniff_flags & SNIFF_WAIT_DATA) == 0)); - - if (rtn) - goto done; - - DGAP_LOCK(ch->ch_lock, lock_flags); - } - - /* - * Read whatever is there. - */ - - if (n > *lenp) - n = *lenp; - - res = n; - - r = SNIFF_MAX - ch->ch_sniff_out; - - if (r <= n) { - DGAP_UNLOCK(ch->ch_lock, lock_flags); - rtn = copy_to_user(buffer, ch->ch_sniff_buf + ch->ch_sniff_out, r); - if (rtn) { - rtn = -EFAULT; - goto done; - } - - DGAP_LOCK(ch->ch_lock, lock_flags); - - ch->ch_sniff_out = 0; - n -= r; - offset = r; - } - - DGAP_UNLOCK(ch->ch_lock, lock_flags); - rtn = copy_to_user(buffer + offset, ch->ch_sniff_buf + ch->ch_sniff_out, n); - if (rtn) { - rtn = -EFAULT; - goto done; - } - DGAP_LOCK(ch->ch_lock, lock_flags); - - ch->ch_sniff_out += n; - *ppos += res; - rtn = res; -// rtn = 0; - - /* - * Wakeup any thread waiting for buffer space. - */ - - if (ch->ch_sniff_flags & SNIFF_WAIT_SPACE) { - ch->ch_sniff_flags &= ~SNIFF_WAIT_SPACE; - wake_up_interruptible(&ch->ch_sniff_wait); - } - - DGAP_UNLOCK(ch->ch_lock, lock_flags); - -done: - return rtn; -} - - -static int dgap_read_channel_fepstate(struct dgap_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos) -{ - struct channel_t *ch; - static int done = 0; - static char buf[4096]; - char *p = buf; - - DPR_PROC(("dgap_proc_info\n")); - - ch = (struct channel_t *) table->data; - - if (done || !ch || (ch->magic != DGAP_CHANNEL_MAGIC) || (ch->ch_bd->state != BOARD_READY)) { - done = 0; - *lenp = 0; - return 0; - } - - p += sprintf(p, "Port number: %d\n", ch->ch_portnum); - p += sprintf(p, "\n"); - - p += sprintf(p, "\tTPJMP:\t%x\n", ch->ch_bs->tp_jmp); - p += sprintf(p, "\tTCJMP:\t%x\n", ch->ch_bs->tc_jmp); - p += sprintf(p, "\tTPJMP:\t%x\n", ch->ch_bs->ri_jmp); - p += sprintf(p, "\tRPJMP:\t%x\n", ch->ch_bs->rp_jmp); - - p += sprintf(p, "\tTSEG:\t%x\n", ch->ch_bs->tx_seg); - p += sprintf(p, "\tTIN:\t%x\n", ch->ch_bs->tx_head); - p += sprintf(p, "\tTOUT:\t%x\n", ch->ch_bs->tx_tail); - p += sprintf(p, "\tTMAX:\t%x\n", ch->ch_bs->tx_max); - - p += sprintf(p, "\tRSEG:\t%x\n", ch->ch_bs->rx_seg); - p += sprintf(p, "\tRIN:\t%x\n", ch->ch_bs->rx_head); - p += sprintf(p, "\tROUT:\t%x\n", ch->ch_bs->rx_tail); - p += sprintf(p, "\tRMAX:\t%x\n", ch->ch_bs->rx_max); - - p += sprintf(p, "\tTLOW:\t%x\n", ch->ch_bs->tx_lw); - p += sprintf(p, "\tRLOW:\t%x\n", ch->ch_bs->rx_lw); - p += sprintf(p, "\tRHIGH:\t%x\n", ch->ch_bs->rx_hw); - p += sprintf(p, "\tINCR:\t%x\n", ch->ch_bs->incr); - - p += sprintf(p, "\tDEV:\t%x\n", ch->ch_bs->fepdev); - p += sprintf(p, "\tEDELAY:\t%x\n", ch->ch_bs->edelay); - p += sprintf(p, "\tBLEN:\t%x\n", ch->ch_bs->blen); - p += sprintf(p, "\tBTIME:\t%x\n", ch->ch_bs->btime); - - p += sprintf(p, "\tIFLAG:\t%x\n", ch->ch_bs->iflag); - p += sprintf(p, "\tOFLAG:\t%x\n", ch->ch_bs->oflag); - p += sprintf(p, "\tCFLAG:\t%x\n", ch->ch_bs->cflag); - - p += sprintf(p, "\tNUM:\t%x\n", ch->ch_bs->num); - p += sprintf(p, "\tRACT:\t%x\n", ch->ch_bs->ract); - p += sprintf(p, "\tBSTAT:\t%x\n", ch->ch_bs->bstat); - p += sprintf(p, "\tTBUSY:\t%x\n", ch->ch_bs->tbusy); - p += sprintf(p, "\tIEMPTY:\t%x\n", ch->ch_bs->iempty); - p += sprintf(p, "\tILOW:\t%x\n", ch->ch_bs->ilow); - p += sprintf(p, "\tIDATA:\t%x\n", ch->ch_bs->idata); - p += sprintf(p, "\tEFLAG:\t%x\n", ch->ch_bs->eflag); - - p += sprintf(p, "\tTFLAG:\t%x\n", ch->ch_bs->tflag); - p += sprintf(p, "\tRFLAG:\t%x\n", ch->ch_bs->rflag); - p += sprintf(p, "\tXMASK:\t%x\n", ch->ch_bs->xmask); - p += sprintf(p, "\tXVAL:\t%x\n", ch->ch_bs->xval); - p += sprintf(p, "\tMSTAT:\t%x\n", ch->ch_bs->m_stat); - p += sprintf(p, "\tEFMASK:\t%x\n", ch->ch_bs->m_change); - p += sprintf(p, "\tMINT:\t%x\n", ch->ch_bs->m_int); - p += sprintf(p, "\tLSTAT:\t%x\n", ch->ch_bs->m_last); - - p += sprintf(p, "\tMTRAN:\t%x\n", ch->ch_bs->mtran); - p += sprintf(p, "\tORUN:\t%x\n", ch->ch_bs->orun); - p += sprintf(p, "\tSTARTCA:%x\n", ch->ch_bs->astartc); - p += sprintf(p, "\tSTOPCA:\t%x\n", ch->ch_bs->astopc); - p += sprintf(p, "\tSTARTC\t%x\n", ch->ch_bs->startc); - p += sprintf(p, "\tSTOPC:\t%x\n", ch->ch_bs->stopc); - p += sprintf(p, "\tVNEXT:\t%x\n", ch->ch_bs->vnextc); - p += sprintf(p, "\tHFLOW:\t%x\n", ch->ch_bs->hflow); - p += sprintf(p, "\tFILLC:\t%x\n", ch->ch_bs->fillc); - p += sprintf(p, "\tOCHAR:\t%x\n", ch->ch_bs->ochar); - p += sprintf(p, "\tOMASK:\t%x\n", ch->ch_bs->omask); - - if (copy_to_user(buffer, buf, (p - (char *) buf))) - return -EFAULT; - - *lenp = p - (char *) buf; - *ppos += p - (char *) buf; - done = 1; - return 0; -} - - -/* - * Register the basic /proc/dgap files that appear whenever - * the driver is loaded. - */ -void dgap_proc_register_basic_prescan(void) -{ - int i; - - /* Initialize semaphores in each table slot */ - for (i = 0; i < DGAP_MAX_PROC_ENTRIES; i++) { - if (!dgap_table[i].magic) { - break; - } - init_MUTEX(&(dgap_table[i].excl_sem)); - } - - /* - * Register /proc/dgap - */ - ProcDGAP = proc_create("dgap", (0700 | S_IFDIR), NULL, &dgap_proc_file_ops); - dgap_register_proc_table(dgap_table, ProcDGAP); -} - - -/* - * Register the basic /proc/dgap files that appear whenever - * the driver is loaded. - */ -void dgap_proc_register_basic_postscan(int board_num) -{ - int i; - char board[10]; - sprintf(board, "%d", board_num); - - /* Set proc board entry pointer */ - dgap_Board[board_num]->proc_entry_pointer = create_proc_entry(board, (0700 | S_IFDIR), ProcDGAP); - - /* Create a new copy of the board_table... */ - dgap_Board[board_num]->dgap_board_table = dgap_driver_kzmalloc(sizeof(dgap_board_table), - GFP_KERNEL); - - /* Now copy the default table into that memory */ - memcpy(dgap_Board[board_num]->dgap_board_table, dgap_board_table, sizeof(dgap_board_table)); - - /* Initialize semaphores in each table slot */ - for (i = 0; i < DGAP_MAX_PROC_ENTRIES; i++) { - if (!dgap_Board[board_num]->dgap_board_table[i].magic) { - break; - } - - init_MUTEX(&(dgap_Board[board_num]->dgap_board_table[i].excl_sem)); - dgap_Board[board_num]->dgap_board_table[i].data = dgap_Board[board_num]; - - } - - /* Register board table into proc */ - dgap_register_proc_table(dgap_Board[board_num]->dgap_board_table, - dgap_Board[board_num]->proc_entry_pointer); -} - - -/* - * Register the channel /proc/dgap files that appear whenever - * the driver is loaded. - */ -void dgap_proc_register_channel_postscan(int board_num) -{ - int i, j; - - /* - * Add new entries for each port. - */ - for (i = 0; i < dgap_Board[board_num]->nasync; i++) { - - char channel[10]; - sprintf(channel, "%d", i); - - /* Set proc channel entry pointer */ - dgap_Board[board_num]->channels[i]->proc_entry_pointer = - create_proc_entry(channel, (0700 | S_IFDIR), - dgap_Board[board_num]->proc_entry_pointer); - - /* Create a new copy of the channel_table... */ - dgap_Board[board_num]->channels[i]->dgap_channel_table = - dgap_driver_kzmalloc(sizeof(dgap_channel_table), GFP_KERNEL); - - /* Now copy the default table into that memory */ - memcpy(dgap_Board[board_num]->channels[i]->dgap_channel_table, - dgap_channel_table, sizeof(dgap_channel_table)); - - /* Initialize semaphores in each table slot */ - for (j = 0; j < DGAP_MAX_PROC_ENTRIES; j++) { - if (!dgap_Board[board_num]->channels[i]->dgap_channel_table[j].magic) { - break; - } - - init_MUTEX(&(dgap_Board[board_num]->channels[i]->dgap_channel_table[j].excl_sem)); - dgap_Board[board_num]->channels[i]->dgap_channel_table[j].data = - dgap_Board[board_num]->channels[i]; - } - - /* Register channel table into proc */ - dgap_register_proc_table(dgap_Board[board_num]->channels[i]->dgap_channel_table, - dgap_Board[board_num]->channels[i]->proc_entry_pointer); - } -} - - -static void dgap_remove_proc_entry(struct proc_dir_entry *pde) -{ - if (!pde) { - DPR_PROC(("dgap_remove_proc_entry... NULL entry... not removing...\n")); - return; - } - - remove_proc_entry(pde->name, pde->parent); -} - - -void dgap_proc_unregister_all(void) -{ - int i = 0, j = 0; - - /* Walk each board, blowing away their proc entries... */ - for (i = 0; i < dgap_NumBoards; i++) { - - /* Walk each channel, blowing away their proc entries... */ - for (j = 0; j < dgap_Board[i]->nasync; j++) { - - if (dgap_Board[i]->channels[j]->dgap_channel_table) { - dgap_unregister_proc_table(dgap_Board[i]->channels[j]->dgap_channel_table, - dgap_Board[i]->channels[j]->proc_entry_pointer); - dgap_remove_proc_entry(dgap_Board[i]->channels[j]->proc_entry_pointer); - kfree(dgap_Board[i]->channels[j]->dgap_channel_table); - } - } - - if (dgap_Board[i]->dgap_board_table) { - dgap_unregister_proc_table(dgap_Board[i]->dgap_board_table, - dgap_Board[i]->proc_entry_pointer); - dgap_remove_proc_entry(dgap_Board[i]->proc_entry_pointer); - kfree(dgap_Board[i]->dgap_board_table); - } - } - - /* Blow away the top proc entry */ - dgap_unregister_proc_table(dgap_table, ProcDGAP); - dgap_remove_proc_entry(ProcDGAP); -} -- GitLab From f6f92a300e2b6c835001efb38faac41474992bc6 Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Thu, 22 Aug 2013 22:17:12 -0400 Subject: [PATCH 799/942] staging: dgap: removes proc.h This patch removes the proc.h file and removes '#include dgap_proc.h' from headers in the driver. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap_driver.c | 1 - drivers/staging/dgap/dgap_fep5.c | 1 - drivers/staging/dgap/dgap_proc.h | 151 ----------------------------- drivers/staging/dgap/dgap_sysfs.c | 1 - 4 files changed, 154 deletions(-) delete mode 100644 drivers/staging/dgap/dgap_proc.h diff --git a/drivers/staging/dgap/dgap_driver.c b/drivers/staging/dgap/dgap_driver.c index 8e8c1e3ec96a0..9f777e41c9a63 100644 --- a/drivers/staging/dgap/dgap_driver.c +++ b/drivers/staging/dgap/dgap_driver.c @@ -44,7 +44,6 @@ #include "dgap_driver.h" #include "dgap_pci.h" -#include "dgap_proc.h" #include "dgap_fep5.h" #include "dgap_tty.h" #include "dgap_conf.h" diff --git a/drivers/staging/dgap/dgap_fep5.c b/drivers/staging/dgap/dgap_fep5.c index 291b414863c12..4464f02c95757 100644 --- a/drivers/staging/dgap/dgap_fep5.c +++ b/drivers/staging/dgap/dgap_fep5.c @@ -46,7 +46,6 @@ #include "dgap_driver.h" #include "dgap_pci.h" -#include "dgap_proc.h" #include "dgap_fep5.h" #include "dgap_tty.h" #include "dgap_conf.h" diff --git a/drivers/staging/dgap/dgap_proc.h b/drivers/staging/dgap/dgap_proc.h deleted file mode 100644 index 9970d28816eec..0000000000000 --- a/drivers/staging/dgap/dgap_proc.h +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright 2003 Digi International (www.digi.com) - * Scott H Kilau - * - * 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, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the - * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!! - * - * - * $Id: dgap_proc.h,v 1.1 2009/10/23 14:01:57 markh Exp $ - * - * Description: - * - * Describes the private structures used to manipulate the "special" - * proc constructs (not read-only) used by the Digi Neo software. - * The concept is borrowed heavily from the "sysctl" interface of - * the kernel. I decided not to use the structures and functions - * provided by the kernel for two reasons: - * - * 1. Due to the planned use of "/proc" in the Neo driver, many - * of the functions of the "sysctl" interface would go unused. - * A simpler interface will be easier to maintain. - * - * 2. I'd rather divorce our "added package" from the kernel internals. - * If the "sysctl" structures should change, I will be insulated - * from those changes. These "/proc" entries won't be under the - * "sys" tree anyway, so there is no need to maintain a strict - * dependence relationship. - * - * Author: - * - * Scott H Kilau - * - */ - -#ifndef _DGAP_RW_PROC_H -#define _DGAP_RW_PROC_H - -/* - * The list of DGAP entries with r/w capabilities. - * These magic numbers are used for identification purposes. - */ -enum { - DGAP_INFO = 1, /* Get info about the running module */ - DGAP_MKNOD = 2, /* Get info about driver devices */ - DGAP_BOARD_INFO = 3, /* Get info about the specific board */ - DGAP_BOARD_VPD = 4, /* Get info about the board's VPD */ - DGAP_BOARD_VPDDATA = 5, /* Get info about the board's VPD */ - DGAP_BOARD_TTYSTATS = 6, /* Get info about the board's tty stats */ - DGAP_BOARD_TTYFLAGS = 7, /* Get info about the board's tty flags */ - DGAP_BOARD_MKNOD = 8, /* Get info about board devices */ - DGAP_PORT_INFO = 9, /* Get info about the specific port */ - DGAP_PORT_SNIFF = 10, /* Sniff data in/out of specific port */ - DGAP_PORT_CUSTOM_TTYNAME = 11, /* Get info about UDEV tty name */ - DGAP_PORT_CUSTOM_PRNAME = 12, /* Get info about UDEV pr name */ - DGAP_PORT_FEPSTATE = 13, /* Get info about Ports FEP state */ -}; - -#define DGAP_MAX_PROC_ENTRIES 999 - -/* - * Directions for proc handlers - */ -enum { - INBOUND = 1, /* Data being written to kernel */ - OUTBOUND = 2, /* Data being read from the kernel */ -}; - -/* - * Each entry in a DGAP proc directory is described with a - * "dgap_proc_entry" structure. A collection of these - * entries (in an array) represents the members associated - * with a particular "/proc" directory, and is referred to - * as a table. All "tables" are terminated by an entry with - * zeros for every member. - * - * The structure members are as follows: - * - * int magic -- ID number associated with this particular - * entry. Should be unique across all of - * DGAP. - * - * const char *name -- ASCII name associated with the /proc entry. - * - * mode_t mode -- File access permisssions for the /proc entry. - * - * dgap_proc_entry *child -- When set, this entry refers to a directory, - * and points to the table which describes the - * entries in the subdirectory - * - * dgap_proc_handler *open_handler -- When set, points to the fxn which - * does any "extra" open stuff. - * - * dgap_proc_handler *close_handler -- When set, points to the fxn which - * does any "extra" close stuff. - * - * dgap_proc_handler *read_handler -- When set, points to the fxn which - * handle outbound data flow - * - * dgap_proc_handler *write_handler -- When set, points to the fxn which - * handles inbound data flow - * - * struct proc_dir_entry *de -- Pointer to the directory entry for this - * object once registered. Used to grab - * the handle of the object for - * unregistration - * - * void *data; When set, points to the parent structure - * - */ - -struct dgap_proc_entry { - int magic; /* Integer identifier */ - const char *name; /* ASCII identifier */ - mode_t mode; /* File access permissions */ - struct dgap_proc_entry *child; /* Child pointer */ - - int (*open_handler) (struct dgap_proc_entry *table, int dir, struct file *filp, - void *buffer, ssize_t *lenp, loff_t *ppos); - int (*close_handler) (struct dgap_proc_entry *table, int dir, struct file *filp, - void *buffer, ssize_t *lenp, loff_t *ppos); - int (*read_handler) (struct dgap_proc_entry *table, int dir, struct file *filp, - char __user *buffer, ssize_t *lenp, loff_t *ppos); - int (*write_handler) (struct dgap_proc_entry *table, int dir, struct file *filp, - const char __user *buffer, ssize_t *lenp, loff_t *ppos); - - struct proc_dir_entry *de; /* proc entry pointer */ - struct semaphore excl_sem; /* Protects exclusive access var */ - int excl_cnt; /* Counts number of curr accesses */ - void *data; /* Allows storing a pointer to parent */ -}; - - -void dgap_proc_register_basic_prescan(void); -void dgap_proc_unregister_all(void); -void dgap_proc_register_basic_postscan(int board_num); -void dgap_proc_register_channel_postscan(int board_num); - -#endif /* _DGAP_RW_PROC_H */ diff --git a/drivers/staging/dgap/dgap_sysfs.c b/drivers/staging/dgap/dgap_sysfs.c index a35c8ed69eff0..d4300ce7b6bdb 100644 --- a/drivers/staging/dgap/dgap_sysfs.c +++ b/drivers/staging/dgap/dgap_sysfs.c @@ -44,7 +44,6 @@ #include #include "dgap_driver.h" -#include "dgap_proc.h" #include "dgap_conf.h" #include "dgap_parse.h" -- GitLab From 9ead219b3150d864696f6476f37ecefb2f3e9d86 Mon Sep 17 00:00:00 2001 From: Anthony Foiani Date: Thu, 22 Aug 2013 22:06:39 -0600 Subject: [PATCH 800/942] staging: usbip: add "-P" / "--pid" option to save usbipd process id Introduce option "-P" / "--pid" to request that usbipd save its PID to a file while running. Signed-off-by: Anthony Foiani Signed-off-by: Greg Kroah-Hartman --- drivers/staging/usbip/userspace/src/usbipd.c | 40 +++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/drivers/staging/usbip/userspace/src/usbipd.c b/drivers/staging/usbip/userspace/src/usbipd.c index 1ecca9dd99458..f31b8b4246a36 100644 --- a/drivers/staging/usbip/userspace/src/usbipd.c +++ b/drivers/staging/usbip/userspace/src/usbipd.c @@ -50,6 +50,8 @@ #define MAIN_LOOP_TIMEOUT 10 +#define DEFAULT_PID_FILE "/var/run/" PROGNAME ".pid" + static const char usbip_version_string[] = PACKAGE_STRING; static const char usbipd_help_string[] = @@ -60,6 +62,10 @@ static const char usbipd_help_string[] = " -d, --debug\n" " Print debugging information.\n" "\n" + " -PFILE, --pid FILE\n" + " Write process id to FILE.\n" + " If no FILE specified, use " DEFAULT_PID_FILE "\n" + "\n" " -h, --help\n" " Print this help.\n" "\n" @@ -439,6 +445,31 @@ static void set_signal(void) sigaction(SIGCLD, &act, NULL); } +static const char *pid_file; + +static void write_pid_file() +{ + if (pid_file) { + dbg("creating pid file %s", pid_file); + FILE *fp = fopen(pid_file, "w"); + if (!fp) { + err("pid_file: %s: %d (%s)", + pid_file, errno, strerror(errno)); + return; + } + fprintf(fp, "%d\n", getpid()); + fclose(fp); + } +} + +static void remove_pid_file() +{ + if (pid_file) { + dbg("removing pid file %s", pid_file); + unlink(pid_file); + } +} + static int do_standalone_mode(int daemonize) { struct addrinfo *ai_head; @@ -465,6 +496,7 @@ static int do_standalone_mode(int daemonize) usbip_use_syslog = 1; } set_signal(); + write_pid_file(); ai_head = do_getaddrinfo(NULL, PF_UNSPEC); if (!ai_head) { @@ -527,6 +559,7 @@ int main(int argc, char *argv[]) static const struct option longopts[] = { { "daemon", no_argument, NULL, 'D' }, { "debug", no_argument, NULL, 'd' }, + { "pid", optional_argument, NULL, 'P' }, { "help", no_argument, NULL, 'h' }, { "version", no_argument, NULL, 'v' }, { NULL, 0, NULL, 0 } @@ -540,6 +573,7 @@ int main(int argc, char *argv[]) int daemonize = 0; int opt, rc = -1; + pid_file = NULL; usbip_use_stderr = 1; usbip_use_syslog = 0; @@ -549,7 +583,7 @@ int main(int argc, char *argv[]) cmd = cmd_standalone_mode; for (;;) { - opt = getopt_long(argc, argv, "Ddhv", longopts, NULL); + opt = getopt_long(argc, argv, "DdP::hv", longopts, NULL); if (opt == -1) break; @@ -564,6 +598,9 @@ int main(int argc, char *argv[]) case 'h': cmd = cmd_help; break; + case 'P': + pid_file = optarg ? optarg : DEFAULT_PID_FILE; + break; case 'v': cmd = cmd_version; break; @@ -577,6 +614,7 @@ int main(int argc, char *argv[]) switch (cmd) { case cmd_standalone_mode: rc = do_standalone_mode(daemonize); + remove_pid_file(); break; case cmd_version: printf(PROGNAME " (%s)\n", usbip_version_string); -- GitLab From 7182f8f81a8c6425061c144d04477048826315e5 Mon Sep 17 00:00:00 2001 From: Anthony Foiani Date: Thu, 22 Aug 2013 22:06:40 -0600 Subject: [PATCH 801/942] staging: usbip: set usbipd server port via "-t" / "--tcp-port" option. Add an option "-t" / "--tcp-port" to specify the TCP port to listen on. Downcase associated variables as they're no longer constants. Signed-off-by: Anthony Foiani Signed-off-by: Greg Kroah-Hartman --- drivers/staging/usbip/userspace/src/usbip.c | 9 ++++-- .../usbip/userspace/src/usbip_attach.c | 4 +-- .../staging/usbip/userspace/src/usbip_list.c | 6 ++-- .../usbip/userspace/src/usbip_network.c | 30 +++++++++++++++++++ .../usbip/userspace/src/usbip_network.h | 5 ++-- drivers/staging/usbip/userspace/src/usbipd.c | 13 ++++++-- 6 files changed, 55 insertions(+), 12 deletions(-) diff --git a/drivers/staging/usbip/userspace/src/usbip.c b/drivers/staging/usbip/userspace/src/usbip.c index fff4b768e7052..69ac4b569c360 100644 --- a/drivers/staging/usbip/userspace/src/usbip.c +++ b/drivers/staging/usbip/userspace/src/usbip.c @@ -26,6 +26,7 @@ #include #include "usbip_common.h" +#include "usbip_network.h" #include "usbip.h" static int usbip_help(int argc, char *argv[]); @@ -34,7 +35,7 @@ static int usbip_version(int argc, char *argv[]); static const char usbip_version_string[] = PACKAGE_STRING; static const char usbip_usage_string[] = - "usbip [--debug] [--log] [version]\n" + "usbip [--debug] [--log] [--tcp-port PORT] [version]\n" " [help] \n"; static void usbip_usage(void) @@ -140,6 +141,7 @@ int main(int argc, char *argv[]) static const struct option opts[] = { { "debug", no_argument, NULL, 'd' }, { "log", no_argument, NULL, 'l' }, + { "tcp-port", required_argument, NULL, 't' }, { NULL, 0, NULL, 0 } }; @@ -150,7 +152,7 @@ int main(int argc, char *argv[]) usbip_use_stderr = 1; opterr = 0; for (;;) { - opt = getopt_long(argc, argv, "+d", opts, NULL); + opt = getopt_long(argc, argv, "+dt:", opts, NULL); if (opt == -1) break; @@ -163,6 +165,9 @@ int main(int argc, char *argv[]) usbip_use_syslog = 1; openlog("", LOG_PID, LOG_USER); break; + case 't': + usbip_setup_port_number(optarg); + break; case '?': printf("usbip: invalid option\n"); default: diff --git a/drivers/staging/usbip/userspace/src/usbip_attach.c b/drivers/staging/usbip/userspace/src/usbip_attach.c index 99a24747af0c9..085841196522b 100644 --- a/drivers/staging/usbip/userspace/src/usbip_attach.c +++ b/drivers/staging/usbip/userspace/src/usbip_attach.c @@ -175,7 +175,7 @@ static int attach_device(char *host, char *busid) int rc; int rhport; - sockfd = usbip_net_tcp_connect(host, USBIP_PORT_STRING); + sockfd = usbip_net_tcp_connect(host, usbip_port_string); if (sockfd < 0) { err("tcp connect"); return -1; @@ -189,7 +189,7 @@ static int attach_device(char *host, char *busid) close(sockfd); - rc = record_connection(host, USBIP_PORT_STRING, busid, rhport); + rc = record_connection(host, usbip_port_string, busid, rhport); if (rc < 0) { err("record connection"); return -1; diff --git a/drivers/staging/usbip/userspace/src/usbip_list.c b/drivers/staging/usbip/userspace/src/usbip_list.c index ff56255f497a2..237e099337a1f 100644 --- a/drivers/staging/usbip/userspace/src/usbip_list.c +++ b/drivers/staging/usbip/userspace/src/usbip_list.c @@ -131,13 +131,13 @@ static int list_exported_devices(char *host) int rc; int sockfd; - sockfd = usbip_net_tcp_connect(host, USBIP_PORT_STRING); + sockfd = usbip_net_tcp_connect(host, usbip_port_string); if (sockfd < 0) { err("could not connect to %s:%s: %s", host, - USBIP_PORT_STRING, gai_strerror(sockfd)); + usbip_port_string, gai_strerror(sockfd)); return -1; } - dbg("connected to %s:%s", host, USBIP_PORT_STRING); + dbg("connected to %s:%s", host, usbip_port_string); rc = get_exported_devices(host, sockfd); if (rc < 0) { diff --git a/drivers/staging/usbip/userspace/src/usbip_network.c b/drivers/staging/usbip/userspace/src/usbip_network.c index b12448ec69ab4..c39a07f1d38cd 100644 --- a/drivers/staging/usbip/userspace/src/usbip_network.c +++ b/drivers/staging/usbip/userspace/src/usbip_network.c @@ -28,6 +28,36 @@ #include "usbip_common.h" #include "usbip_network.h" +int usbip_port = 3240; +char *usbip_port_string = "3240"; + +void usbip_setup_port_number(char *arg) +{ + dbg("parsing port arg '%s'", arg); + char *end; + unsigned long int port = strtoul(arg, &end, 10); + + if (end == arg) { + err("port: could not parse '%s' as a decimal integer", arg); + return; + } + + if (*end != '\0') { + err("port: garbage at end of '%s'", arg); + return; + } + + if (port > UINT16_MAX) { + err("port: %s too high (max=%d)", + arg, UINT16_MAX); + return; + } + + usbip_port = port; + usbip_port_string = arg; + info("using port %d (\"%s\")", usbip_port, usbip_port_string); +} + void usbip_net_pack_uint32_t(int pack, uint32_t *num) { uint32_t i; diff --git a/drivers/staging/usbip/userspace/src/usbip_network.h b/drivers/staging/usbip/userspace/src/usbip_network.h index 1bbefc993fb1f..2d0e4277b62be 100644 --- a/drivers/staging/usbip/userspace/src/usbip_network.h +++ b/drivers/staging/usbip/userspace/src/usbip_network.h @@ -14,8 +14,9 @@ #include -#define USBIP_PORT 3240 -#define USBIP_PORT_STRING "3240" +extern int usbip_port; +extern char *usbip_port_string; +void usbip_setup_port_number(char *arg); /* ---------------------------------------------------------------------- */ /* Common header for all the kinds of PDUs. */ diff --git a/drivers/staging/usbip/userspace/src/usbipd.c b/drivers/staging/usbip/userspace/src/usbipd.c index f31b8b4246a36..f41ba5beb4043 100644 --- a/drivers/staging/usbip/userspace/src/usbipd.c +++ b/drivers/staging/usbip/userspace/src/usbipd.c @@ -66,6 +66,9 @@ static const char usbipd_help_string[] = " Write process id to FILE.\n" " If no FILE specified, use " DEFAULT_PID_FILE "\n" "\n" + " -tPORT, --tcp-port PORT\n" + " Listen on TCP/IP port PORT.\n" + "\n" " -h, --help\n" " Print this help.\n" "\n" @@ -417,9 +420,9 @@ static struct addrinfo *do_getaddrinfo(char *host, int ai_family) hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_PASSIVE; - rc = getaddrinfo(host, USBIP_PORT_STRING, &hints, &ai_head); + rc = getaddrinfo(host, usbip_port_string, &hints, &ai_head); if (rc) { - err("failed to get a network address %s: %s", USBIP_PORT_STRING, + err("failed to get a network address %s: %s", usbip_port_string, gai_strerror(rc)); return NULL; } @@ -560,6 +563,7 @@ int main(int argc, char *argv[]) { "daemon", no_argument, NULL, 'D' }, { "debug", no_argument, NULL, 'd' }, { "pid", optional_argument, NULL, 'P' }, + { "tcp-port", required_argument, NULL, 't' }, { "help", no_argument, NULL, 'h' }, { "version", no_argument, NULL, 'v' }, { NULL, 0, NULL, 0 } @@ -583,7 +587,7 @@ int main(int argc, char *argv[]) cmd = cmd_standalone_mode; for (;;) { - opt = getopt_long(argc, argv, "DdP::hv", longopts, NULL); + opt = getopt_long(argc, argv, "DdP::t:hv", longopts, NULL); if (opt == -1) break; @@ -601,6 +605,9 @@ int main(int argc, char *argv[]) case 'P': pid_file = optarg ? optarg : DEFAULT_PID_FILE; break; + case 't': + usbip_setup_port_number(optarg); + break; case 'v': cmd = cmd_version; break; -- GitLab From 5894af89f22a94f2356474a2e1e14ca6267019d4 Mon Sep 17 00:00:00 2001 From: Anthony Foiani Date: Thu, 22 Aug 2013 22:06:41 -0600 Subject: [PATCH 802/942] staging: usbip: properly handle "-l" / "--log" option This option is in the long options list, and it's handled in the option processing loop, but the optstring didn't include it. Signed-off-by: Anthony Foiani Signed-off-by: Greg Kroah-Hartman --- drivers/staging/usbip/userspace/src/usbip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/usbip/userspace/src/usbip.c b/drivers/staging/usbip/userspace/src/usbip.c index 69ac4b569c360..b4f299ee5dd4b 100644 --- a/drivers/staging/usbip/userspace/src/usbip.c +++ b/drivers/staging/usbip/userspace/src/usbip.c @@ -152,7 +152,7 @@ int main(int argc, char *argv[]) usbip_use_stderr = 1; opterr = 0; for (;;) { - opt = getopt_long(argc, argv, "+dt:", opts, NULL); + opt = getopt_long(argc, argv, "+dlt:", opts, NULL); if (opt == -1) break; -- GitLab From 92e11aef70fbac9724a60195b9670901971e8f3b Mon Sep 17 00:00:00 2001 From: Anthony Foiani Date: Thu, 22 Aug 2013 22:06:42 -0600 Subject: [PATCH 803/942] staging: usbip: fix up alignment in long options list Re-align the option lists. Signed-off-by: Anthony Foiani Signed-off-by: Greg Kroah-Hartman --- drivers/staging/usbip/userspace/src/usbip.c | 8 ++++---- drivers/staging/usbip/userspace/src/usbipd.c | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/usbip/userspace/src/usbip.c b/drivers/staging/usbip/userspace/src/usbip.c index b4f299ee5dd4b..04a5f20bea65d 100644 --- a/drivers/staging/usbip/userspace/src/usbip.c +++ b/drivers/staging/usbip/userspace/src/usbip.c @@ -139,10 +139,10 @@ static int run_command(const struct command *cmd, int argc, char *argv[]) int main(int argc, char *argv[]) { static const struct option opts[] = { - { "debug", no_argument, NULL, 'd' }, - { "log", no_argument, NULL, 'l' }, - { "tcp-port", required_argument, NULL, 't' }, - { NULL, 0, NULL, 0 } + { "debug", no_argument, NULL, 'd' }, + { "log", no_argument, NULL, 'l' }, + { "tcp-port", required_argument, NULL, 't' }, + { NULL, 0, NULL, 0 } }; char *cmd; diff --git a/drivers/staging/usbip/userspace/src/usbipd.c b/drivers/staging/usbip/userspace/src/usbipd.c index f41ba5beb4043..1c76cfd274d05 100644 --- a/drivers/staging/usbip/userspace/src/usbipd.c +++ b/drivers/staging/usbip/userspace/src/usbipd.c @@ -560,13 +560,13 @@ static int do_standalone_mode(int daemonize) int main(int argc, char *argv[]) { static const struct option longopts[] = { - { "daemon", no_argument, NULL, 'D' }, - { "debug", no_argument, NULL, 'd' }, - { "pid", optional_argument, NULL, 'P' }, + { "daemon", no_argument, NULL, 'D' }, + { "debug", no_argument, NULL, 'd' }, + { "pid", optional_argument, NULL, 'P' }, { "tcp-port", required_argument, NULL, 't' }, - { "help", no_argument, NULL, 'h' }, - { "version", no_argument, NULL, 'v' }, - { NULL, 0, NULL, 0 } + { "help", no_argument, NULL, 'h' }, + { "version", no_argument, NULL, 'v' }, + { NULL, 0, NULL, 0 } }; enum { -- GitLab From 9fc0944a85e4ae5ce9217b1de63c58363e405a53 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Fri, 23 Aug 2013 18:24:02 +0530 Subject: [PATCH 804/942] staging: rtl8187se: Remove pt_regs * irq handler parameter struct pt_regs pointer is no longer passed as a irq handler argument. v2: remove rtl8180_interrupt cast to (void *) . Signed-off-by: navin patidar Cc: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8187se/r8180_core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8187se/r8180_core.c b/drivers/staging/rtl8187se/r8180_core.c index ca691550436a2..eee4fd3c0643c 100644 --- a/drivers/staging/rtl8187se/r8180_core.c +++ b/drivers/staging/rtl8187se/r8180_core.c @@ -197,7 +197,7 @@ inline void force_pci_posting(struct net_device *dev) mb(); } -irqreturn_t rtl8180_interrupt(int irq, void *netdev, struct pt_regs *regs); +static irqreturn_t rtl8180_interrupt(int irq, void *netdev); void set_nic_rxring(struct net_device *dev); void set_nic_txring(struct net_device *dev); static struct net_device_stats *rtl8180_stats(struct net_device *dev); @@ -2666,7 +2666,7 @@ short rtl8180_init(struct net_device *dev) TX_BEACON_RING_ADDR)) return -ENOMEM; - if (request_irq(dev->irq, (void *)rtl8180_interrupt, IRQF_SHARED, dev->name, dev)) { + if (request_irq(dev->irq, rtl8180_interrupt, IRQF_SHARED, dev->name, dev)) { DMESGE("Error allocating IRQ %d", dev->irq); return -1; } else { @@ -3537,7 +3537,7 @@ void rtl8180_tx_isr(struct net_device *dev, int pri, short error) spin_unlock_irqrestore(&priv->tx_lock, flag); } -irqreturn_t rtl8180_interrupt(int irq, void *netdev, struct pt_regs *regs) +irqreturn_t rtl8180_interrupt(int irq, void *netdev) { struct net_device *dev = (struct net_device *) netdev; struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); -- GitLab From 6abaf5803d7a8e7b2ad4fb4899b0016f6e9aad31 Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Fri, 23 Aug 2013 22:55:31 +0900 Subject: [PATCH 805/942] staging: bcm: Fix typo in comments Correct spelling typo in staging/bcm Signed-off-by: Masanari Iida Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Ioctl.h | 2 +- drivers/staging/bcm/Misc.c | 2 +- drivers/staging/bcm/nvm.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/bcm/Ioctl.h b/drivers/staging/bcm/Ioctl.h index e253c080a787e..797f862b90cf7 100644 --- a/drivers/staging/bcm/Ioctl.h +++ b/drivers/staging/bcm/Ioctl.h @@ -175,7 +175,7 @@ struct bcm_flash2x_copy_section { /* * This section provide the complete bitmap of the Flash. - * using this map lib/APP will isssue read/write command. + * using this map lib/APP will issue read/write command. * Fields are defined as : * Bit [0] = section is present //1:present, 0: Not present * Bit [1] = section is valid //1: valid, 0: not valid diff --git a/drivers/staging/bcm/Misc.c b/drivers/staging/bcm/Misc.c index d23eeeb95064f..4cfc2c33c6966 100644 --- a/drivers/staging/bcm/Misc.c +++ b/drivers/staging/bcm/Misc.c @@ -210,7 +210,7 @@ static int BcmFileDownload(struct bcm_mini_adapter *Adapter, const char *path, u * @ingroup ctrl_pkt_functions * This function copies the contents of given buffer * to the control packet and queues it for transmission. - * @note Do not acquire the spinock, as it it already acquired. + * @note Do not acquire the spinlock, as it it already acquired. * @return SUCCESS/FAILURE. * Arguments: * Logical Adapter diff --git a/drivers/staging/bcm/nvm.c b/drivers/staging/bcm/nvm.c index bea1330f7ea69..91a5715964b93 100644 --- a/drivers/staging/bcm/nvm.c +++ b/drivers/staging/bcm/nvm.c @@ -2966,7 +2966,7 @@ int BcmFlash2xBulkWrite(struct bcm_mini_adapter *Adapter, * @Adapter :-Drivers private Data Structure * * Return Value:- - * Return STATUS_SUCESS if get success in setting the right DSD else negaive error code + * Return STATUS_SUCESS if get success in setting the right DSD else negative error code * */ -- GitLab From 26085a70b32763c2c5bfa451666cb544a662a263 Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Fri, 23 Aug 2013 22:43:39 +0900 Subject: [PATCH 806/942] staging: gdm724x: Fix typo in comments Correct spelling typo in comments within staging/gdm724x Signed-off-by: Masanari Iida Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm724x/gdm_lte.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/gdm724x/gdm_lte.c b/drivers/staging/gdm724x/gdm_lte.c index 7165d3a1490e4..bc0d510fb0af3 100644 --- a/drivers/staging/gdm724x/gdm_lte.c +++ b/drivers/staging/gdm724x/gdm_lte.c @@ -434,7 +434,7 @@ static int gdm_lte_tx(struct sk_buff *skb, struct net_device *dev) /* Need byte shift (that is, remove VLAN tag) if there is one For the case of ARP, this breaks the offset as vlan_ethhdr+4 is treated as ethhdr - However, it shouldn't be a problem as the reponse starts from arp_hdr and ethhdr + However, it shouldn't be a problem as the response starts from arp_hdr and ethhdr is created by this driver based on the NIC mac */ if (nic_type & NIC_TYPE_F_VLAN) { @@ -448,7 +448,7 @@ static int gdm_lte_tx(struct sk_buff *skb, struct net_device *dev) data_len = skb->len; } - /* If it is a ICMPV6 packet, clear all the other bits : for backward compatibilty with the firmware */ + /* If it is a ICMPV6 packet, clear all the other bits : for backward compatibility with the firmware */ if (nic_type & NIC_TYPE_ICMPV6) nic_type = NIC_TYPE_ICMPV6; -- GitLab From cfabe4b43c8f688304e6b25176612e32e6e7a8d8 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Thu, 22 Aug 2013 21:03:40 +0100 Subject: [PATCH 807/942] staging: vt6656: s_uGetRTSCTSRsvTime return u16 endian corrected value. s_uGetRTSCTSRsvTime always needs to be corrected to u16 endian value. Change function to return u16 endian corrected value. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index d4b9b60f02ccd..4f36ec89ff420 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -121,7 +121,7 @@ static void s_vSWencryption(struct vnt_private *pDevice, static unsigned int s_uGetTxRsvTime(struct vnt_private *pDevice, u8 byPktType, u32 cbFrameLength, u16 wRate, int bNeedAck); -static u32 s_uGetRTSCTSRsvTime(struct vnt_private *pDevice, u8 byRTSRsvType, +static u16 s_uGetRTSCTSRsvTime(struct vnt_private *pDevice, u8 byRTSRsvType, u8 byPktType, u32 cbFrameLength, u16 wCurrentRate); static void s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx, @@ -349,7 +349,7 @@ static u32 s_uGetTxRsvTime(struct vnt_private *pDevice, u8 byPktType, } //byFreqType: 0=>5GHZ 1=>2.4GHZ -static u32 s_uGetRTSCTSRsvTime(struct vnt_private *pDevice, +static u16 s_uGetRTSCTSRsvTime(struct vnt_private *pDevice, u8 byRTSRsvType, u8 byPktType, u32 cbFrameLength, u16 wCurrentRate) { u32 uRrvTime, uRTSTime, uCTSTime, uAckTime, uDataTime; @@ -379,7 +379,7 @@ static u32 s_uGetRTSCTSRsvTime(struct vnt_private *pDevice, //RTSRrvTime uRrvTime = uRTSTime + uCTSTime + uAckTime + uDataTime + 3*pDevice->uSIFS; - return uRrvTime; + return cpu_to_le16((u16)uRrvTime); } //byFreqType 0: 5GHz, 1:2.4Ghz @@ -876,9 +876,12 @@ static void s_vGenerateTxParameter(struct vnt_private *pDevice, if (pvRrvTime) { struct vnt_rrv_time_rts *pBuf = (struct vnt_rrv_time_rts *)pvRrvTime; - pBuf->wRTSTxRrvTime_aa = cpu_to_le16((u16)s_uGetRTSCTSRsvTime(pDevice, 2, byPktType, cbFrameSize, wCurrentRate));//2:RTSTxRrvTime_aa, 1:2.4GHz - pBuf->wRTSTxRrvTime_ba = cpu_to_le16((u16)s_uGetRTSCTSRsvTime(pDevice, 1, byPktType, cbFrameSize, wCurrentRate));//1:RTSTxRrvTime_ba, 1:2.4GHz - pBuf->wRTSTxRrvTime_bb = cpu_to_le16((u16)s_uGetRTSCTSRsvTime(pDevice, 0, byPktType, cbFrameSize, wCurrentRate));//0:RTSTxRrvTime_bb, 1:2.4GHz + pBuf->wRTSTxRrvTime_aa = s_uGetRTSCTSRsvTime(pDevice, 2, + byPktType, cbFrameSize, wCurrentRate); + pBuf->wRTSTxRrvTime_ba = s_uGetRTSCTSRsvTime(pDevice, 1, + byPktType, cbFrameSize, wCurrentRate); + pBuf->wRTSTxRrvTime_bb = s_uGetRTSCTSRsvTime(pDevice, 0, + byPktType, cbFrameSize, wCurrentRate); pBuf->wTxRrvTime_a = cpu_to_le16((u16) s_uGetTxRsvTime(pDevice, byPktType, cbFrameSize, wCurrentRate, bNeedACK));//2.4G OFDM pBuf->wTxRrvTime_b = cpu_to_le16((u16) s_uGetTxRsvTime(pDevice, PK_TYPE_11B, cbFrameSize, pDevice->byTopCCKBasicRate, bNeedACK));//1:CCK } @@ -893,7 +896,8 @@ static void s_vGenerateTxParameter(struct vnt_private *pDevice, (struct vnt_rrv_time_cts *)pvRrvTime; pBuf->wTxRrvTime_a = cpu_to_le16((u16)s_uGetTxRsvTime(pDevice, byPktType, cbFrameSize, wCurrentRate, bNeedACK));//2.4G OFDM pBuf->wTxRrvTime_b = cpu_to_le16((u16)s_uGetTxRsvTime(pDevice, PK_TYPE_11B, cbFrameSize, pDevice->byTopCCKBasicRate, bNeedACK));//1:CCK - pBuf->wCTSTxRrvTime_ba = cpu_to_le16((u16)s_uGetRTSCTSRsvTime(pDevice, 3, byPktType, cbFrameSize, wCurrentRate));//3:CTSTxRrvTime_Ba, 1:2.4GHz + pBuf->wCTSTxRrvTime_ba = s_uGetRTSCTSRsvTime(pDevice, 3, + byPktType, cbFrameSize, wCurrentRate); } //Fill CTS s_vFillCTSHead(pDevice, uDMAIdx, byPktType, pvCTS, cbFrameSize, bNeedACK, bDisCRC, wCurrentRate, byFBOption); @@ -906,7 +910,8 @@ static void s_vGenerateTxParameter(struct vnt_private *pDevice, if (pvRrvTime) { struct vnt_rrv_time_ab *pBuf = (struct vnt_rrv_time_ab *)pvRrvTime; - pBuf->wRTSTxRrvTime = cpu_to_le16((u16)s_uGetRTSCTSRsvTime(pDevice, 2, byPktType, cbFrameSize, wCurrentRate));//2:RTSTxRrvTime_aa, 0:5GHz + pBuf->wRTSTxRrvTime = s_uGetRTSCTSRsvTime(pDevice, 2, + byPktType, cbFrameSize, wCurrentRate); pBuf->wTxRrvTime = cpu_to_le16((u16)s_uGetTxRsvTime(pDevice, byPktType, cbFrameSize, wCurrentRate, bNeedACK));//0:OFDM } //Fill RTS @@ -928,7 +933,8 @@ static void s_vGenerateTxParameter(struct vnt_private *pDevice, if (pvRrvTime) { struct vnt_rrv_time_ab *pBuf = (struct vnt_rrv_time_ab *)pvRrvTime; - pBuf->wRTSTxRrvTime = cpu_to_le16((u16)s_uGetRTSCTSRsvTime(pDevice, 0, byPktType, cbFrameSize, wCurrentRate));//0:RTSTxRrvTime_bb, 1:2.4GHz + pBuf->wRTSTxRrvTime = s_uGetRTSCTSRsvTime(pDevice, 0, + byPktType, cbFrameSize, wCurrentRate); pBuf->wTxRrvTime = cpu_to_le16((u16)s_uGetTxRsvTime(pDevice, PK_TYPE_11B, cbFrameSize, wCurrentRate, bNeedACK));//1:CCK } //Fill RTS -- GitLab From 9c3806d5a82a2050ecb6ae77dae0c84562e0524a Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Fri, 23 Aug 2013 11:32:26 +0100 Subject: [PATCH 808/942] staging: vt6656: rxtx.c s_create new function to endian correct uGetTxRsvTime. We can't endian correct uGetTxRsvTime because it is called by other functions. Create new function to vnt_rxtx_rsvtime_le16 to return little endian u16 value. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 4f36ec89ff420..f1eec60437336 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -348,6 +348,13 @@ static u32 s_uGetTxRsvTime(struct vnt_private *pDevice, u8 byPktType, } } +static u16 vnt_rxtx_rsvtime_le16(struct vnt_private *priv, u8 pkt_type, + u32 frame_length, u16 rate, int need_ack) +{ + return cpu_to_le16((u16)s_uGetTxRsvTime(priv, pkt_type, + frame_length, rate, need_ack)); +} + //byFreqType: 0=>5GHZ 1=>2.4GHZ static u16 s_uGetRTSCTSRsvTime(struct vnt_private *pDevice, u8 byRTSRsvType, u8 byPktType, u32 cbFrameLength, u16 wCurrentRate) @@ -882,8 +889,11 @@ static void s_vGenerateTxParameter(struct vnt_private *pDevice, byPktType, cbFrameSize, wCurrentRate); pBuf->wRTSTxRrvTime_bb = s_uGetRTSCTSRsvTime(pDevice, 0, byPktType, cbFrameSize, wCurrentRate); - pBuf->wTxRrvTime_a = cpu_to_le16((u16) s_uGetTxRsvTime(pDevice, byPktType, cbFrameSize, wCurrentRate, bNeedACK));//2.4G OFDM - pBuf->wTxRrvTime_b = cpu_to_le16((u16) s_uGetTxRsvTime(pDevice, PK_TYPE_11B, cbFrameSize, pDevice->byTopCCKBasicRate, bNeedACK));//1:CCK + pBuf->wTxRrvTime_a = vnt_rxtx_rsvtime_le16(pDevice, + byPktType, cbFrameSize, wCurrentRate, bNeedACK); + pBuf->wTxRrvTime_b = vnt_rxtx_rsvtime_le16(pDevice, + PK_TYPE_11B, cbFrameSize, pDevice->byTopCCKBasicRate, + bNeedACK); } //Fill RTS s_vFillRTSHead(pDevice, byPktType, pvRTS, cbFrameSize, bNeedACK, bDisCRC, psEthHeader, wCurrentRate, byFBOption); @@ -894,8 +904,11 @@ static void s_vGenerateTxParameter(struct vnt_private *pDevice, if (pvRrvTime) { struct vnt_rrv_time_cts *pBuf = (struct vnt_rrv_time_cts *)pvRrvTime; - pBuf->wTxRrvTime_a = cpu_to_le16((u16)s_uGetTxRsvTime(pDevice, byPktType, cbFrameSize, wCurrentRate, bNeedACK));//2.4G OFDM - pBuf->wTxRrvTime_b = cpu_to_le16((u16)s_uGetTxRsvTime(pDevice, PK_TYPE_11B, cbFrameSize, pDevice->byTopCCKBasicRate, bNeedACK));//1:CCK + pBuf->wTxRrvTime_a = vnt_rxtx_rsvtime_le16(pDevice, byPktType, + cbFrameSize, wCurrentRate, bNeedACK); + pBuf->wTxRrvTime_b = vnt_rxtx_rsvtime_le16(pDevice, + PK_TYPE_11B, cbFrameSize, + pDevice->byTopCCKBasicRate, bNeedACK); pBuf->wCTSTxRrvTime_ba = s_uGetRTSCTSRsvTime(pDevice, 3, byPktType, cbFrameSize, wCurrentRate); } @@ -912,7 +925,8 @@ static void s_vGenerateTxParameter(struct vnt_private *pDevice, (struct vnt_rrv_time_ab *)pvRrvTime; pBuf->wRTSTxRrvTime = s_uGetRTSCTSRsvTime(pDevice, 2, byPktType, cbFrameSize, wCurrentRate); - pBuf->wTxRrvTime = cpu_to_le16((u16)s_uGetTxRsvTime(pDevice, byPktType, cbFrameSize, wCurrentRate, bNeedACK));//0:OFDM + pBuf->wTxRrvTime = vnt_rxtx_rsvtime_le16(pDevice, byPktType, + cbFrameSize, wCurrentRate, bNeedACK); } //Fill RTS s_vFillRTSHead(pDevice, byPktType, pvRTS, cbFrameSize, bNeedACK, bDisCRC, psEthHeader, wCurrentRate, byFBOption); @@ -922,7 +936,8 @@ static void s_vGenerateTxParameter(struct vnt_private *pDevice, if (pvRrvTime) { struct vnt_rrv_time_ab *pBuf = (struct vnt_rrv_time_ab *)pvRrvTime; - pBuf->wTxRrvTime = cpu_to_le16((u16)s_uGetTxRsvTime(pDevice, PK_TYPE_11A, cbFrameSize, wCurrentRate, bNeedACK)); //0:OFDM + pBuf->wTxRrvTime = vnt_rxtx_rsvtime_le16(pDevice, PK_TYPE_11A, + cbFrameSize, wCurrentRate, bNeedACK); } } } @@ -935,7 +950,8 @@ static void s_vGenerateTxParameter(struct vnt_private *pDevice, (struct vnt_rrv_time_ab *)pvRrvTime; pBuf->wRTSTxRrvTime = s_uGetRTSCTSRsvTime(pDevice, 0, byPktType, cbFrameSize, wCurrentRate); - pBuf->wTxRrvTime = cpu_to_le16((u16)s_uGetTxRsvTime(pDevice, PK_TYPE_11B, cbFrameSize, wCurrentRate, bNeedACK));//1:CCK + pBuf->wTxRrvTime = vnt_rxtx_rsvtime_le16(pDevice, PK_TYPE_11B, + cbFrameSize, wCurrentRate, bNeedACK); } //Fill RTS s_vFillRTSHead(pDevice, byPktType, pvRTS, cbFrameSize, bNeedACK, bDisCRC, psEthHeader, wCurrentRate, byFBOption); @@ -945,7 +961,8 @@ static void s_vGenerateTxParameter(struct vnt_private *pDevice, if (pvRrvTime) { struct vnt_rrv_time_ab *pBuf = (struct vnt_rrv_time_ab *)pvRrvTime; - pBuf->wTxRrvTime = cpu_to_le16((u16)s_uGetTxRsvTime(pDevice, PK_TYPE_11B, cbFrameSize, wCurrentRate, bNeedACK)); //1:CCK + pBuf->wTxRrvTime = vnt_rxtx_rsvtime_le16(pDevice, PK_TYPE_11B, + cbFrameSize, wCurrentRate, bNeedACK); } } } -- GitLab From f115e76aea7f318df8535c8218ecbc9986e6d05a Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Fri, 23 Aug 2013 11:48:46 +0100 Subject: [PATCH 809/942] staging: vt6656: rxtx.c endian correct wTimeStampOff wTimeStampOff needs to be endian corrected Create new function vnt_time_stamp_off to return little endian u16 value. Private variable byPreambleType is common to all calling functions is included. variable rate to set the desired rate. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index f1eec60437336..ed3fdf48b6abd 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -323,6 +323,12 @@ static void s_vSWencryption(struct vnt_private *pDevice, } } +static u16 vnt_time_stamp_off(struct vnt_private *priv, u16 rate) +{ + return cpu_to_le16(wTimeStampOff[priv->byPreambleType % 2] + [rate % MAX_RATE]); +} + /*byPktType : PK_TYPE_11A 0 PK_TYPE_11B 1 PK_TYPE_11GB 2 @@ -519,8 +525,10 @@ static u32 s_uFillDataHead(struct vnt_private *pDevice, pBuf->wDuration_b = s_uGetDataDuration(pDevice, PK_TYPE_11B, bNeedAck); - pBuf->wTimeStampOff_a = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]; - pBuf->wTimeStampOff_b = wTimeStampOff[pDevice->byPreambleType%2][pDevice->byTopCCKBasicRate%MAX_RATE]; + pBuf->wTimeStampOff_a = vnt_time_stamp_off(pDevice, + wCurrentRate); + pBuf->wTimeStampOff_b = vnt_time_stamp_off(pDevice, + pDevice->byTopCCKBasicRate); return (pBuf->wDuration_a); } else { // Auto Fallback @@ -540,8 +548,10 @@ static u32 s_uFillDataHead(struct vnt_private *pDevice, byPktType, bNeedAck); pBuf->wDuration_a_f1 = s_uGetDataDuration(pDevice, byPktType, bNeedAck); - pBuf->wTimeStampOff_a = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]; - pBuf->wTimeStampOff_b = wTimeStampOff[pDevice->byPreambleType%2][pDevice->byTopCCKBasicRate%MAX_RATE]; + pBuf->wTimeStampOff_a = vnt_time_stamp_off(pDevice, + wCurrentRate); + pBuf->wTimeStampOff_b = vnt_time_stamp_off(pDevice, + pDevice->byTopCCKBasicRate); return (pBuf->wDuration_a); } //if (byFBOption == AUTO_FB_NONE) } @@ -559,7 +569,8 @@ static u32 s_uFillDataHead(struct vnt_private *pDevice, byPktType, bNeedAck); pBuf->wDuration_f1 = s_uGetDataDuration(pDevice, byPktType, bNeedAck); - pBuf->wTimeStampOff = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]; + pBuf->wTimeStampOff = vnt_time_stamp_off(pDevice, + wCurrentRate); return (pBuf->wDuration); } else { struct vnt_tx_datahead_ab *pBuf = @@ -570,8 +581,8 @@ static u32 s_uFillDataHead(struct vnt_private *pDevice, //Get Duration and TimeStampOff pBuf->wDuration = s_uGetDataDuration(pDevice, byPktType, bNeedAck); - pBuf->wTimeStampOff = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]; - + pBuf->wTimeStampOff = vnt_time_stamp_off(pDevice, + wCurrentRate); return (pBuf->wDuration); } } @@ -584,8 +595,8 @@ static u32 s_uFillDataHead(struct vnt_private *pDevice, //Get Duration and TimeStampOff pBuf->wDuration = s_uGetDataDuration(pDevice, byPktType, bNeedAck); - pBuf->wTimeStampOff = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]; - + pBuf->wTimeStampOff = vnt_time_stamp_off(pDevice, + wCurrentRate); return (pBuf->wDuration); } return 0; @@ -1830,7 +1841,7 @@ CMD_STATUS csBeacon_xmit(struct vnt_private *pDevice, //Get Duration and TimeStampOff pTxDataHead->wDuration = s_uGetDataDuration(pDevice, PK_TYPE_11A, false); - pTxDataHead->wTimeStampOff = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]; + pTxDataHead->wTimeStampOff = vnt_time_stamp_off(pDevice, wCurrentRate); cbHeaderSize = wTxBufSize + sizeof(struct vnt_tx_datahead_ab); } else { wCurrentRate = RATE_1M; @@ -1843,7 +1854,7 @@ CMD_STATUS csBeacon_xmit(struct vnt_private *pDevice, //Get Duration and TimeStampOff pTxDataHead->wDuration = s_uGetDataDuration(pDevice, PK_TYPE_11B, false); - pTxDataHead->wTimeStampOff = wTimeStampOff[pDevice->byPreambleType%2][wCurrentRate%MAX_RATE]; + pTxDataHead->wTimeStampOff = vnt_time_stamp_off(pDevice, wCurrentRate); cbHeaderSize = wTxBufSize + sizeof(struct vnt_tx_datahead_ab); } -- GitLab From 5a5d6a80cf8733ccb29d83951f1dd2f0e4a4fe2b Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Fri, 23 Aug 2013 14:33:55 +0100 Subject: [PATCH 810/942] staging: vt6656: desc.h Remove typedef struct tagSMICHDRHead to new structure in rxtx.h To new structure. typedef struct tagSMICHDRHead -> struct vnt_mic_hdr This is only needed by rxtc.c so moved to rxtx.h The new structure is the same size as the old but contains the members as pointer referenced in rxtx.c s_vFillTxKey u8 id *pMICHDR = 0x59; u8 tx_priority; *((u8 *)(pMICHDR+1)) = 0; // TxPriority u8 mic_addr2[6]; memcpy(pMICHDR+2, &(pMACHeader->addr2[0]), 6); __be32 tsc_47_16; pMICHDR+8 = HIBYTE(HIWORD(pTransmitKey->dwTSC47_16)); pMICHDR+9 = LOBYTE(HIWORD(pTransmitKey->dwTSC47_16)); pMICHDR+10 = HIBYTE(LOWORD(pTransmitKey->dwTSC47_16)); pMICHDR+11 = LOBYTE(LOWORD(pTransmitKey->dwTSC47_16)); __be16 tsc_15_0; pMICHDR+12 = HIBYTE(pTransmitKey->wTSC15_0); pMICHDR+13 = LOBYTE(pTransmitKey->wTSC15_0); __be16 payload_len; pMICHDR+14 = HIBYTE(wPayloadLen); pMICHDR+15 = LOBYTE(wPayloadLen); __be16 hlen; pMICHDR+16 = 0; // HLEN[15:8] pMICHDR+17 = 28; // HLEN[7:0] __le16 frame_control; memcpy(pMICHDR+18, (u8 *)&wValue, 2); // MSKFRACTL u8 addr1[6]; memcpy(pMICHDR+20, &(pMACHeader->addr1[0]), 6); u8 addr2[6]; memcpy(pMICHDR+26, &(pMACHeader->addr2[0]), 6); u8 addr3[6]; memcpy(pMICHDR+32, &(pMACHeader->addr3[0]), 6); __le16 seq_ctrl; memcpy(pMICHDR+38, (u8 *)&wValue, 2); // MSKSEQCTL u8 addr4[6]; memcpy(pMICHDR+40, &(pMACHeader->addr4[0]), 6); u16 packing; /* packing to 48 bytes */ Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/desc.h | 12 ------------ drivers/staging/vt6656/rxtx.c | 26 +++++++++++++------------- drivers/staging/vt6656/rxtx.h | 18 ++++++++++++++++++ 3 files changed, 31 insertions(+), 25 deletions(-) diff --git a/drivers/staging/vt6656/desc.h b/drivers/staging/vt6656/desc.h index b3e8cc106d125..4675135aa2583 100644 --- a/drivers/staging/vt6656/desc.h +++ b/drivers/staging/vt6656/desc.h @@ -163,18 +163,6 @@ typedef struct tagSTxShortBufHead { STxShortBufHead, *PSTxShortBufHead; typedef const STxShortBufHead *PCSTxShortBufHead; -/* - * MICHDR data header - */ -typedef struct tagSMICHDRHead { - u32 adwHDR0[4]; - u32 adwHDR1[4]; - u32 adwHDR2[4]; -} __attribute__ ((__packed__)) -SMICHDRHead, *PSMICHDRHead; - -typedef const SMICHDRHead *PCSMICHDRHead; - typedef struct tagSBEACONCtl { u32 BufReady:1; u32 TSF:15; diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index ed3fdf48b6abd..c055c76d8b9e9 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -1004,7 +1004,7 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, u32 uDuration; u32 cbHeaderLength = 0, uPadding = 0; void *pvRrvTime; - PSMICHDRHead pMICHDR; + struct vnt_mic_hdr *pMICHDR; void *pvRTS; void *pvCTS; void *pvTxDataHd; @@ -1121,7 +1121,7 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, if (pTransmitKey->byCipherSuite == KEY_CTL_CCMP) { cbIVlen = 8;//RSN Header cbICVlen = 8;//MIC - cbMICHDR = sizeof(SMICHDRHead); + cbMICHDR = sizeof(struct vnt_mic_hdr); } if (bSoftWEP == false) { //MAC Header should be padding 0 to DW alignment. @@ -1146,7 +1146,7 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, if (bRTS == true) {//RTS_need pvRrvTime = (struct vnt_rrv_time_rts *) (pbyTxBufferAddr + wTxBufSize); - pMICHDR = (PSMICHDRHead)(pbyTxBufferAddr + wTxBufSize + + pMICHDR = (struct vnt_mic_hdr *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_rts)); pvRTS = (struct vnt_rts_g *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_rts) + cbMICHDR); @@ -1161,7 +1161,7 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, else { //RTS_needless pvRrvTime = (struct vnt_rrv_time_cts *) (pbyTxBufferAddr + wTxBufSize); - pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + + pMICHDR = (struct vnt_mic_hdr *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_cts)); pvRTS = NULL; pvCTS = (struct vnt_cts *) (pbyTxBufferAddr + wTxBufSize + @@ -1178,7 +1178,7 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, if (bRTS == true) {//RTS_need pvRrvTime = (struct vnt_rrv_time_rts *)(pbyTxBufferAddr + wTxBufSize); - pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + + pMICHDR = (struct vnt_mic_hdr *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_rts)); pvRTS = (struct vnt_rts_g_fb *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_rts) + cbMICHDR); @@ -1193,7 +1193,7 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, else if (bRTS == false) { //RTS_needless pvRrvTime = (struct vnt_rrv_time_cts *) (pbyTxBufferAddr + wTxBufSize); - pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + + pMICHDR = (struct vnt_mic_hdr *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_cts)); pvRTS = NULL; pvCTS = (struct vnt_cts_fb *) (pbyTxBufferAddr + wTxBufSize + @@ -1212,7 +1212,7 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, if (bRTS == true) {//RTS_need pvRrvTime = (struct vnt_rrv_time_ab *) (pbyTxBufferAddr + wTxBufSize); - pMICHDR = (PSMICHDRHead)(pbyTxBufferAddr + wTxBufSize + + pMICHDR = (struct vnt_mic_hdr *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab)); pvRTS = (struct vnt_rts_ab *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab) + cbMICHDR); @@ -1227,7 +1227,7 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, else if (bRTS == false) { //RTS_needless, no MICHDR pvRrvTime = (struct vnt_rrv_time_ab *)(pbyTxBufferAddr + wTxBufSize); - pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + + pMICHDR = (struct vnt_mic_hdr *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab)); pvRTS = NULL; pvCTS = NULL; @@ -1241,7 +1241,7 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, if (bRTS == true) {//RTS_need pvRrvTime = (struct vnt_rrv_time_ab *)(pbyTxBufferAddr + wTxBufSize); - pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + + pMICHDR = (struct vnt_mic_hdr *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab)); pvRTS = (struct vnt_rts_a_fb *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab) + cbMICHDR); @@ -1256,7 +1256,7 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, else if (bRTS == false) { //RTS_needless pvRrvTime = (struct vnt_rrv_time_ab *)(pbyTxBufferAddr + wTxBufSize); - pMICHDR = (PSMICHDRHead)(pbyTxBufferAddr + wTxBufSize + + pMICHDR = (struct vnt_mic_hdr *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab)); pvRTS = NULL; pvCTS = NULL; @@ -2057,7 +2057,7 @@ void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb) else if (pDevice->eEncryptionStatus == Ndis802_11Encryption3Enabled) { cbIVlen = 8;//RSN Header cbICVlen = 8;//MIC - cbMICHDR = sizeof(SMICHDRHead); + cbMICHDR = sizeof(struct vnt_mic_hdr); pTxBufHead->wFragCtl |= FRAGCTL_AES; pDevice->bAES = true; } @@ -2076,7 +2076,7 @@ void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb) if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) {//802.11g packet pvRrvTime = (struct vnt_rrv_time_cts *) (pbyTxBufferAddr + wTxBufSize); - pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + + pMICHDR = (struct vnt_mic_hdr *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_cts)); pvRTS = NULL; pvCTS = (struct vnt_cts *) (pbyTxBufferAddr + wTxBufSize + @@ -2091,7 +2091,7 @@ void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb) else {//802.11a/b packet pvRrvTime = (struct vnt_rrv_time_ab *) (pbyTxBufferAddr + wTxBufSize); - pMICHDR = (PSMICHDRHead) (pbyTxBufferAddr + wTxBufSize + + pMICHDR = (struct vnt_mic_hdr *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab)); pvRTS = NULL; pvCTS = NULL; diff --git a/drivers/staging/vt6656/rxtx.h b/drivers/staging/vt6656/rxtx.h index 3484f2b16640b..ad6205255967d 100644 --- a/drivers/staging/vt6656/rxtx.h +++ b/drivers/staging/vt6656/rxtx.h @@ -33,6 +33,24 @@ #include "wcmd.h" #include "baseband.h" +/* MIC HDR data header */ +struct vnt_mic_hdr { + u8 id; + u8 tx_priority; + u8 mic_addr2[6]; + __be32 tsc_47_16; + __be16 tsc_15_0; + __be16 payload_len; + __be16 hlen; + __le16 frame_control; + u8 addr1[6]; + u8 addr2[6]; + u8 addr3[6]; + __le16 seq_ctrl; + u8 addr4[6]; + u16 packing; /* packing to 48 bytes */ +} __packed; + /* RsvTime buffer header */ struct vnt_rrv_time_rts { u16 wRTSTxRrvTime_ba; -- GitLab From ec37d8b67b276317778cb786adebc905f9c67937 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Fri, 23 Aug 2013 14:37:48 +0100 Subject: [PATCH 811/942] staging: vt6656: rxtx.c s_vFillTxKey fill structure vnt_mic_hdr Replace the pointer offsets with structure of mic_hdr with endian conversion where needed. Replace vFillTxKey argument u8 *pMICHDR with struct vnt_mic_hdr *mic_hdr and fix type of calling functions. An extra check that mic_hdr is not NULL Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 71 ++++++++++++++++------------------- 1 file changed, 32 insertions(+), 39 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index c055c76d8b9e9..14b7defe2b5d2 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -113,7 +113,7 @@ static void s_vGenerateMACHeader(struct vnt_private *pDevice, static void s_vFillTxKey(struct vnt_private *pDevice, u8 *pbyBuf, u8 *pbyIVHead, PSKeyItem pTransmitKey, u8 *pbyHdrBuf, u16 wPayloadLen, - u8 *pMICHDR); + struct vnt_mic_hdr *mic_hdr); static void s_vSWencryption(struct vnt_private *pDevice, PSKeyItem pTransmitKey, u8 *pbyPayloadHead, u16 wPayloadSize); @@ -183,11 +183,10 @@ static void s_vSaveTxPktInfo(struct vnt_private *pDevice, u8 byPktNum, static void s_vFillTxKey(struct vnt_private *pDevice, u8 *pbyBuf, u8 *pbyIVHead, PSKeyItem pTransmitKey, u8 *pbyHdrBuf, - u16 wPayloadLen, u8 *pMICHDR) + u16 wPayloadLen, struct vnt_mic_hdr *mic_hdr) { u32 *pdwIV = (u32 *)pbyIVHead; u32 *pdwExtIV = (u32 *)((u8 *)pbyIVHead + 4); - u16 wValue; struct ieee80211_hdr *pMACHeader = (struct ieee80211_hdr *)pbyHdrBuf; u32 dwRevIVCounter; @@ -251,40 +250,34 @@ static void s_vFillTxKey(struct vnt_private *pDevice, u8 *pbyBuf, //Append IV&ExtIV after Mac Header *pdwExtIV = cpu_to_le32(pTransmitKey->dwTSC47_16); - //Fill MICHDR0 - *pMICHDR = 0x59; - *((u8 *)(pMICHDR+1)) = 0; // TxPriority - memcpy(pMICHDR+2, &(pMACHeader->addr2[0]), 6); - *((u8 *)(pMICHDR+8)) = HIBYTE(HIWORD(pTransmitKey->dwTSC47_16)); - *((u8 *)(pMICHDR+9)) = LOBYTE(HIWORD(pTransmitKey->dwTSC47_16)); - *((u8 *)(pMICHDR+10)) = HIBYTE(LOWORD(pTransmitKey->dwTSC47_16)); - *((u8 *)(pMICHDR+11)) = LOBYTE(LOWORD(pTransmitKey->dwTSC47_16)); - *((u8 *)(pMICHDR+12)) = HIBYTE(pTransmitKey->wTSC15_0); - *((u8 *)(pMICHDR+13)) = LOBYTE(pTransmitKey->wTSC15_0); - *((u8 *)(pMICHDR+14)) = HIBYTE(wPayloadLen); - *((u8 *)(pMICHDR+15)) = LOBYTE(wPayloadLen); - - //Fill MICHDR1 - *((u8 *)(pMICHDR+16)) = 0; // HLEN[15:8] - if (pDevice->bLongHeader) { - *((u8 *)(pMICHDR+17)) = 28; // HLEN[7:0] - } else { - *((u8 *)(pMICHDR+17)) = 22; // HLEN[7:0] - } - wValue = cpu_to_le16(pMACHeader->frame_control & 0xC78F); - memcpy(pMICHDR+18, (u8 *)&wValue, 2); // MSKFRACTL - memcpy(pMICHDR+20, &(pMACHeader->addr1[0]), 6); - memcpy(pMICHDR+26, &(pMACHeader->addr2[0]), 6); - - //Fill MICHDR2 - memcpy(pMICHDR+32, &(pMACHeader->addr3[0]), 6); - wValue = pMACHeader->seq_ctrl; - wValue &= 0x000F; - wValue = cpu_to_le16(wValue); - memcpy(pMICHDR+38, (u8 *)&wValue, 2); // MSKSEQCTL - if (pDevice->bLongHeader) { - memcpy(pMICHDR+40, &(pMACHeader->addr4[0]), 6); - } + if (!mic_hdr) + return; + + /* MICHDR0 */ + mic_hdr->id = 0x59; + mic_hdr->payload_len = cpu_to_be16(wPayloadLen); + memcpy(mic_hdr->mic_addr2, pMACHeader->addr2, ETH_ALEN); + + mic_hdr->tsc_47_16 = cpu_to_be32(pTransmitKey->dwTSC47_16); + mic_hdr->tsc_15_0 = cpu_to_be16(pTransmitKey->wTSC15_0); + + /* MICHDR1 */ + if (pDevice->bLongHeader) + mic_hdr->hlen = cpu_to_be16(28); + else + mic_hdr->hlen = cpu_to_be16(22); + + memcpy(mic_hdr->addr1, pMACHeader->addr1, ETH_ALEN); + memcpy(mic_hdr->addr2, pMACHeader->addr2, ETH_ALEN); + + /* MICHDR2 */ + memcpy(mic_hdr->addr3, pMACHeader->addr3, ETH_ALEN); + mic_hdr->frame_control = cpu_to_le16(pMACHeader->frame_control + & 0xc78f); + mic_hdr->seq_ctrl = cpu_to_le16(pMACHeader->seq_ctrl & 0xf); + + if (pDevice->bLongHeader) + memcpy(mic_hdr->addr4, pMACHeader->addr4, ETH_ALEN); } } @@ -1294,7 +1287,7 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, if (bNeedEncryption == true) { //Fill TXKEY s_vFillTxKey(pDevice, (u8 *)(pTxBufHead->adwTxKey), pbyIVHead, pTransmitKey, - pbyMacHdr, (u16)cbFrameBodySize, (u8 *)pMICHDR); + pbyMacHdr, (u16)cbFrameBodySize, pMICHDR); if (pDevice->bEnableHostWEP) { pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16 = pTransmitKey->dwTSC47_16; @@ -2203,7 +2196,7 @@ void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb) } s_vFillTxKey(pDevice, (u8 *)(pTxBufHead->adwTxKey), pbyIVHead, pTransmitKey, - pbyMacHdr, (u16)cbFrameBodySize, (u8 *)pMICHDR); + pbyMacHdr, (u16)cbFrameBodySize, pMICHDR); if (pDevice->bEnableHostWEP) { pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16 = pTransmitKey->dwTSC47_16; -- GitLab From 9efed32c223a0dabebeeeca7c1b3cdafb97fbde4 Mon Sep 17 00:00:00 2001 From: Rupesh Gujare Date: Fri, 23 Aug 2013 16:11:00 +0100 Subject: [PATCH 812/942] staging: ozwpan: Remove memset As we are initialising structure, we do not require memset(). Signed-off-by: Rupesh Gujare Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozpd.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/ozwpan/ozpd.c b/drivers/staging/ozwpan/ozpd.c index 06004c8b85feb..5d24af3b4cd78 100644 --- a/drivers/staging/ozwpan/ozpd.c +++ b/drivers/staging/ozwpan/ozpd.c @@ -268,7 +268,6 @@ void oz_pd_destroy(struct oz_pd *pd) if (hrtimer_active(&pd->heartbeat)) hrtimer_cancel(&pd->heartbeat); - memset(&pd->workitem, 0, sizeof(pd->workitem)); INIT_WORK(&pd->workitem, oz_pd_free); ret = schedule_work(&pd->workitem); -- GitLab From dfc065f19fe0ce4ef7a52011801c5c19131e6529 Mon Sep 17 00:00:00 2001 From: Rupesh Gujare Date: Fri, 23 Aug 2013 16:11:01 +0100 Subject: [PATCH 813/942] staging: ozwpan: Fix wrong error check. schedule_work() returns true if succeeded & false on failure, error check was doing exactly reverse. Also removes extra variable. Signed-off-by: Rupesh Gujare Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozpd.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/staging/ozwpan/ozpd.c b/drivers/staging/ozwpan/ozpd.c index 5d24af3b4cd78..d39a3df4842be 100644 --- a/drivers/staging/ozwpan/ozpd.c +++ b/drivers/staging/ozwpan/ozpd.c @@ -261,17 +261,13 @@ void oz_pd_free(struct work_struct *work) */ void oz_pd_destroy(struct oz_pd *pd) { - int ret; - if (hrtimer_active(&pd->timeout)) hrtimer_cancel(&pd->timeout); if (hrtimer_active(&pd->heartbeat)) hrtimer_cancel(&pd->heartbeat); INIT_WORK(&pd->workitem, oz_pd_free); - ret = schedule_work(&pd->workitem); - - if (ret) + if (!schedule_work(&pd->workitem)) oz_pd_dbg(pd, ON, "failed to schedule workitem\n"); } -- GitLab From 4e7fb829771de2cf8a5ba9576290d76936d3e814 Mon Sep 17 00:00:00 2001 From: Rupesh Gujare Date: Fri, 23 Aug 2013 16:11:02 +0100 Subject: [PATCH 814/942] staging: ozwpan: Fix Documentation style. This patch fixes Kernel Documentation style. Signed-off-by: Rupesh Gujare Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozcdev.c | 40 ++++---- drivers/staging/ozwpan/ozeltbuf.c | 27 ++--- drivers/staging/ozwpan/ozhcd.c | 134 ++++++++++++------------- drivers/staging/ozwpan/ozmain.c | 8 +- drivers/staging/ozwpan/ozpd.c | 82 +++++++-------- drivers/staging/ozwpan/ozproto.c | 56 +++++------ drivers/staging/ozwpan/ozurbparanoia.c | 6 +- drivers/staging/ozwpan/ozusbsvc.c | 20 ++-- drivers/staging/ozwpan/ozusbsvc1.c | 24 ++--- 9 files changed, 179 insertions(+), 218 deletions(-) diff --git a/drivers/staging/ozwpan/ozcdev.c b/drivers/staging/ozwpan/ozcdev.c index 01673d4d5c4c3..03b41eecc62c2 100644 --- a/drivers/staging/ozwpan/ozcdev.c +++ b/drivers/staging/ozwpan/ozcdev.c @@ -18,8 +18,7 @@ #include "ozpd.h" #include "ozproto.h" #include "ozcdev.h" -/*------------------------------------------------------------------------------ - */ + #define OZ_RD_BUF_SZ 256 struct oz_cdev { dev_t devnum; @@ -39,12 +38,11 @@ struct oz_serial_ctx { int rd_in; int rd_out; }; -/*------------------------------------------------------------------------------ - */ + static struct oz_cdev g_cdev; static struct class *g_oz_class; -/*------------------------------------------------------------------------------ +/* * Context: process and softirq */ static struct oz_serial_ctx *oz_cdev_claim_ctx(struct oz_pd *pd) @@ -59,7 +57,7 @@ static struct oz_serial_ctx *oz_cdev_claim_ctx(struct oz_pd *pd) return ctx; } -/*------------------------------------------------------------------------------ +/* * Context: softirq or process */ static void oz_cdev_release_ctx(struct oz_serial_ctx *ctx) @@ -70,7 +68,7 @@ static void oz_cdev_release_ctx(struct oz_serial_ctx *ctx) } } -/*------------------------------------------------------------------------------ +/* * Context: process */ static int oz_cdev_open(struct inode *inode, struct file *filp) @@ -83,7 +81,7 @@ static int oz_cdev_open(struct inode *inode, struct file *filp) return 0; } -/*------------------------------------------------------------------------------ +/* * Context: process */ static int oz_cdev_release(struct inode *inode, struct file *filp) @@ -91,7 +89,7 @@ static int oz_cdev_release(struct inode *inode, struct file *filp) return 0; } -/*------------------------------------------------------------------------------ +/* * Context: process */ static ssize_t oz_cdev_read(struct file *filp, char __user *buf, size_t count, @@ -144,7 +142,7 @@ static ssize_t oz_cdev_read(struct file *filp, char __user *buf, size_t count, return count; } -/*------------------------------------------------------------------------------ +/* * Context: process */ static ssize_t oz_cdev_write(struct file *filp, const char __user *buf, @@ -202,7 +200,7 @@ static ssize_t oz_cdev_write(struct file *filp, const char __user *buf, return count; } -/*------------------------------------------------------------------------------ +/* * Context: process */ static int oz_set_active_pd(const u8 *addr) @@ -237,7 +235,7 @@ static int oz_set_active_pd(const u8 *addr) return rc; } -/*------------------------------------------------------------------------------ +/* * Context: process */ static long oz_cdev_ioctl(struct file *filp, unsigned int cmd, @@ -305,7 +303,7 @@ static long oz_cdev_ioctl(struct file *filp, unsigned int cmd, return rc; } -/*------------------------------------------------------------------------------ +/* * Context: process */ static unsigned int oz_cdev_poll(struct file *filp, poll_table *wait) @@ -329,7 +327,7 @@ static unsigned int oz_cdev_poll(struct file *filp, poll_table *wait) return ret; } -/*------------------------------------------------------------------------------ +/* */ static const struct file_operations oz_fops = { .owner = THIS_MODULE, @@ -341,7 +339,7 @@ static const struct file_operations oz_fops = { .poll = oz_cdev_poll }; -/*------------------------------------------------------------------------------ +/* * Context: process */ int oz_cdev_register(void) @@ -386,7 +384,7 @@ int oz_cdev_register(void) return err; } -/*------------------------------------------------------------------------------ +/* * Context: process */ int oz_cdev_deregister(void) @@ -400,7 +398,7 @@ int oz_cdev_deregister(void) return 0; } -/*------------------------------------------------------------------------------ +/* * Context: process */ int oz_cdev_init(void) @@ -409,7 +407,7 @@ int oz_cdev_init(void) return 0; } -/*------------------------------------------------------------------------------ +/* * Context: process */ void oz_cdev_term(void) @@ -417,7 +415,7 @@ void oz_cdev_term(void) oz_app_enable(OZ_APPID_SERIAL, 0); } -/*------------------------------------------------------------------------------ +/* * Context: softirq-serialized */ int oz_cdev_start(struct oz_pd *pd, int resume) @@ -455,7 +453,7 @@ int oz_cdev_start(struct oz_pd *pd, int resume) return 0; } -/*------------------------------------------------------------------------------ +/* * Context: softirq or process */ void oz_cdev_stop(struct oz_pd *pd, int pause) @@ -485,7 +483,7 @@ void oz_cdev_stop(struct oz_pd *pd, int pause) oz_dbg(ON, "Serial service stopped\n"); } -/*------------------------------------------------------------------------------ +/* * Context: softirq-serialized */ void oz_cdev_rx(struct oz_pd *pd, struct oz_elt *elt) diff --git a/drivers/staging/ozwpan/ozeltbuf.c b/drivers/staging/ozwpan/ozeltbuf.c index cfc0f3996b4c1..9b86486c6b114 100644 --- a/drivers/staging/ozwpan/ozeltbuf.c +++ b/drivers/staging/ozwpan/ozeltbuf.c @@ -11,11 +11,10 @@ #include "ozeltbuf.h" #include "ozpd.h" -/*------------------------------------------------------------------------------ - */ #define OZ_ELT_INFO_MAGIC_USED 0x35791057 #define OZ_ELT_INFO_MAGIC_FREE 0x78940102 -/*------------------------------------------------------------------------------ + +/* * Context: softirq-serialized */ int oz_elt_buf_init(struct oz_elt_buf *buf) @@ -29,7 +28,7 @@ int oz_elt_buf_init(struct oz_elt_buf *buf) return 0; } -/*------------------------------------------------------------------------------ +/* * Context: softirq or process */ void oz_elt_buf_term(struct oz_elt_buf *buf) @@ -62,7 +61,7 @@ void oz_elt_buf_term(struct oz_elt_buf *buf) buf->free_elts = 0; } -/*------------------------------------------------------------------------------ +/* * Context: softirq or process */ struct oz_elt_info *oz_elt_info_alloc(struct oz_elt_buf *buf) @@ -96,7 +95,7 @@ struct oz_elt_info *oz_elt_info_alloc(struct oz_elt_buf *buf) return ei; } -/*------------------------------------------------------------------------------ +/* * Precondition: oz_elt_buf.lock must be held. * Context: softirq or process */ @@ -133,8 +132,6 @@ void oz_elt_info_free_chain(struct oz_elt_buf *buf, struct list_head *list) spin_unlock_bh(&buf->lock); } -/*------------------------------------------------------------------------------ - */ int oz_elt_stream_create(struct oz_elt_buf *buf, u8 id, int max_buf_count) { struct oz_elt_stream *st; @@ -154,8 +151,6 @@ int oz_elt_stream_create(struct oz_elt_buf *buf, u8 id, int max_buf_count) return 0; } -/*------------------------------------------------------------------------------ - */ int oz_elt_stream_delete(struct oz_elt_buf *buf, u8 id) { struct list_head *e; @@ -194,15 +189,11 @@ int oz_elt_stream_delete(struct oz_elt_buf *buf, u8 id) return 0; } -/*------------------------------------------------------------------------------ - */ void oz_elt_stream_get(struct oz_elt_stream *st) { atomic_inc(&st->ref_count); } -/*------------------------------------------------------------------------------ - */ void oz_elt_stream_put(struct oz_elt_stream *st) { if (atomic_dec_and_test(&st->ref_count)) { @@ -211,7 +202,7 @@ void oz_elt_stream_put(struct oz_elt_stream *st) } } -/*------------------------------------------------------------------------------ +/* * Precondition: Element buffer lock must be held. * If this function fails the caller is responsible for deallocating the elt * info structure. @@ -275,8 +266,6 @@ int oz_queue_elt_info(struct oz_elt_buf *buf, u8 isoc, u8 id, return 0; } -/*------------------------------------------------------------------------------ - */ int oz_select_elts_for_tx(struct oz_elt_buf *buf, u8 isoc, unsigned *len, unsigned max_len, struct list_head *list) { @@ -322,15 +311,11 @@ int oz_select_elts_for_tx(struct oz_elt_buf *buf, u8 isoc, unsigned *len, return count; } -/*------------------------------------------------------------------------------ - */ int oz_are_elts_available(struct oz_elt_buf *buf) { return buf->order_list.next != &buf->order_list; } -/*------------------------------------------------------------------------------ - */ void oz_trim_elt_pool(struct oz_elt_buf *buf) { struct list_head *free = NULL; diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c index d5a3900d41817..ab93b74e34be4 100644 --- a/drivers/staging/ozwpan/ozhcd.c +++ b/drivers/staging/ozwpan/ozhcd.c @@ -35,7 +35,7 @@ #include "ozurbparanoia.h" #include "ozhcd.h" -/*------------------------------------------------------------------------------ +/* * Number of units of buffering to capture for an isochronous IN endpoint before * allowing data to be indicated up. */ @@ -57,7 +57,7 @@ */ #define EP0_TIMEOUT_COUNTER 13 -/*------------------------------------------------------------------------------ +/* * Used to link urbs together and also store some status information for each * urb. * A cache of these are kept in a pool to reduce number of calls to kmalloc. @@ -144,7 +144,7 @@ struct oz_hcd { */ #define OZ_HDC_F_SUSPENDED 0x1 -/*------------------------------------------------------------------------------ +/* * Static function prototypes. */ static int oz_hcd_start(struct usb_hcd *hcd); @@ -185,7 +185,7 @@ static struct oz_urb_link *oz_remove_urb(struct oz_endpoint *ep, struct urb *urb); static void oz_hcd_clear_orphanage(struct oz_hcd *ozhcd, int status); -/*------------------------------------------------------------------------------ +/* * Static external variables. */ static struct platform_device *g_plat_dev; @@ -231,7 +231,7 @@ static struct platform_driver g_oz_plat_drv = { }, }; -/*------------------------------------------------------------------------------ +/* * Gets our private context area (which is of type struct oz_hcd) from the * usb_hcd structure. * Context: any @@ -241,7 +241,7 @@ static inline struct oz_hcd *oz_hcd_private(struct usb_hcd *hcd) return (struct oz_hcd *)hcd->hcd_priv; } -/*------------------------------------------------------------------------------ +/* * Searches list of ports to find the index of the one with a specified USB * bus address. If none of the ports has the bus address then the connection * port is returned, if there is one or -1 otherwise. @@ -258,7 +258,7 @@ static int oz_get_port_from_addr(struct oz_hcd *ozhcd, u8 bus_addr) return ozhcd->conn_port; } -/*------------------------------------------------------------------------------ +/* * Allocates an urb link, first trying the pool but going to heap if empty. * Context: any */ @@ -279,7 +279,7 @@ static struct oz_urb_link *oz_alloc_urb_link(void) return urbl; } -/*------------------------------------------------------------------------------ +/* * Frees an urb link by putting it in the pool if there is enough space or * deallocating it to heap otherwise. * Context: any @@ -300,7 +300,7 @@ static void oz_free_urb_link(struct oz_urb_link *urbl) } } -/*------------------------------------------------------------------------------ +/* * Deallocates all the urb links in the pool. * Context: unknown */ @@ -322,7 +322,7 @@ static void oz_empty_link_pool(void) } } -/*------------------------------------------------------------------------------ +/* * Allocates endpoint structure and optionally a buffer. If a buffer is * allocated it immediately follows the endpoint structure. * Context: softirq @@ -343,7 +343,7 @@ static struct oz_endpoint *oz_ep_alloc(int buffer_size, gfp_t mem_flags) return ep; } -/*------------------------------------------------------------------------------ +/* * Pre-condition: Must be called with g_tasklet_lock held and interrupts * disabled. * Context: softirq or process @@ -363,7 +363,7 @@ static struct oz_urb_link *oz_uncancel_urb(struct oz_hcd *ozhcd, struct urb *urb return NULL; } -/*------------------------------------------------------------------------------ +/* * This is called when we have finished processing an urb. It unlinks it from * the ep and returns it to the core. * Context: softirq or process @@ -407,7 +407,7 @@ static void oz_complete_urb(struct usb_hcd *hcd, struct urb *urb, oz_free_urb_link(cancel_urbl); } -/*------------------------------------------------------------------------------ +/* * Deallocates an endpoint including deallocating any associated stream and * returning any queued urbs to the core. * Context: softirq @@ -432,7 +432,7 @@ static void oz_ep_free(struct oz_port *port, struct oz_endpoint *ep) kfree(ep); } -/*------------------------------------------------------------------------------ +/* * Context: softirq */ static void oz_complete_buffered_urb(struct oz_port *port, @@ -471,7 +471,7 @@ static void oz_complete_buffered_urb(struct oz_port *port, oz_complete_urb(port->ozhcd->hcd, urb, 0); } -/*------------------------------------------------------------------------------ +/* * Context: softirq */ static int oz_enqueue_ep_urb(struct oz_port *port, u8 ep_addr, int in_dir, @@ -543,7 +543,7 @@ static int oz_enqueue_ep_urb(struct oz_port *port, u8 ep_addr, int in_dir, return err; } -/*------------------------------------------------------------------------------ +/* * Removes an urb from the queue in the endpoint. * Returns 0 if it is found and -EIDRM otherwise. * Context: softirq @@ -576,7 +576,7 @@ static int oz_dequeue_ep_urb(struct oz_port *port, u8 ep_addr, int in_dir, return urbl ? 0 : -EIDRM; } -/*------------------------------------------------------------------------------ +/* * Finds an urb given its request id. * Context: softirq */ @@ -609,7 +609,7 @@ static struct urb *oz_find_urb_by_id(struct oz_port *port, int ep_ix, return urb; } -/*------------------------------------------------------------------------------ +/* * Pre-condition: Port lock must be held. * Context: softirq */ @@ -624,7 +624,7 @@ static void oz_acquire_port(struct oz_port *port, void *hpd) port->hpd = hpd; } -/*------------------------------------------------------------------------------ +/* * Context: softirq */ static struct oz_hcd *oz_hcd_claim(void) @@ -639,7 +639,7 @@ static struct oz_hcd *oz_hcd_claim(void) return ozhcd; } -/*------------------------------------------------------------------------------ +/* * Context: softirq */ static inline void oz_hcd_put(struct oz_hcd *ozhcd) @@ -648,7 +648,7 @@ static inline void oz_hcd_put(struct oz_hcd *ozhcd) usb_put_hcd(ozhcd->hcd); } -/*------------------------------------------------------------------------------ +/* * This is called by the protocol handler to notify that a PD has arrived. * We allocate a port to associate with the PD and create a structure for * endpoint 0. This port is made the connection port. @@ -714,7 +714,7 @@ struct oz_port *oz_hcd_pd_arrived(void *hpd) return NULL; } -/*------------------------------------------------------------------------------ +/* * This is called by the protocol handler to notify that the PD has gone away. * We need to deallocate all resources and then request that the root hub is * polled. We release the reference we hold on the PD. @@ -770,7 +770,7 @@ void oz_hcd_pd_departed(struct oz_port *port) oz_usb_put(hpd); } -/*------------------------------------------------------------------------------ +/* * Context: softirq */ void oz_hcd_pd_reset(void *hpd, void *hport) @@ -790,7 +790,7 @@ void oz_hcd_pd_reset(void *hpd, void *hport) usb_hcd_poll_rh_status(ozhcd->hcd); } -/*------------------------------------------------------------------------------ +/* * Context: softirq */ void oz_hcd_get_desc_cnf(void *hport, u8 req_id, int status, const u8 *desc, @@ -836,7 +836,7 @@ void oz_hcd_get_desc_cnf(void *hport, u8 req_id, int status, const u8 *desc, oz_complete_urb(port->ozhcd->hcd, urb, 0); } -/*------------------------------------------------------------------------------ +/* * Context: softirq */ static void oz_display_conf_type(u8 t) @@ -878,7 +878,7 @@ static void oz_display_conf_type(u8 t) } } -/*------------------------------------------------------------------------------ +/* * Context: softirq */ static void oz_hcd_complete_set_config(struct oz_port *port, struct urb *urb, @@ -900,7 +900,7 @@ static void oz_hcd_complete_set_config(struct oz_port *port, struct urb *urb, oz_complete_urb(hcd, urb, rc); } -/*------------------------------------------------------------------------------ +/* * Context: softirq */ static void oz_hcd_complete_set_interface(struct oz_port *port, struct urb *urb, @@ -927,7 +927,7 @@ static void oz_hcd_complete_set_interface(struct oz_port *port, struct urb *urb, oz_complete_urb(hcd, urb, rc); } -/*------------------------------------------------------------------------------ +/* * Context: softirq */ void oz_hcd_control_cnf(void *hport, u8 req_id, u8 rcode, const u8 *data, @@ -980,7 +980,7 @@ void oz_hcd_control_cnf(void *hport, u8 req_id, u8 rcode, const u8 *data, } } -/*------------------------------------------------------------------------------ +/* * Context: softirq-serialized */ static int oz_hcd_buffer_data(struct oz_endpoint *ep, const u8 *data, @@ -1018,7 +1018,7 @@ static int oz_hcd_buffer_data(struct oz_endpoint *ep, const u8 *data, return 0; } -/*------------------------------------------------------------------------------ +/* * Context: softirq-serialized */ void oz_hcd_data_ind(void *hport, u8 endpoint, const u8 *data, int data_len) @@ -1065,7 +1065,7 @@ void oz_hcd_data_ind(void *hport, u8 endpoint, const u8 *data, int data_len) spin_unlock_bh(&ozhcd->hcd_lock); } -/*------------------------------------------------------------------------------ +/* * Context: unknown */ static inline int oz_usb_get_frame_number(void) @@ -1073,7 +1073,7 @@ static inline int oz_usb_get_frame_number(void) return atomic_inc_return(&g_usb_frame_number); } -/*------------------------------------------------------------------------------ +/* * Context: softirq */ int oz_hcd_heartbeat(void *hport) @@ -1234,7 +1234,7 @@ int oz_hcd_heartbeat(void *hport) return rc; } -/*------------------------------------------------------------------------------ +/* * Context: softirq */ static int oz_build_endpoints_for_interface(struct usb_hcd *hcd, @@ -1315,7 +1315,7 @@ static int oz_build_endpoints_for_interface(struct usb_hcd *hcd, return 0; } -/*------------------------------------------------------------------------------ +/* * Context: softirq */ static void oz_clean_endpoints_for_interface(struct usb_hcd *hcd, @@ -1361,7 +1361,7 @@ static void oz_clean_endpoints_for_interface(struct usb_hcd *hcd, } } -/*------------------------------------------------------------------------------ +/* * Context: softirq */ static int oz_build_endpoints_for_config(struct usb_hcd *hcd, @@ -1397,7 +1397,7 @@ static int oz_build_endpoints_for_config(struct usb_hcd *hcd, return -1; } -/*------------------------------------------------------------------------------ +/* * Context: softirq */ static void oz_clean_endpoints_for_config(struct usb_hcd *hcd, @@ -1419,7 +1419,7 @@ static void oz_clean_endpoints_for_config(struct usb_hcd *hcd, spin_unlock_bh(&ozhcd->hcd_lock); } -/*------------------------------------------------------------------------------ +/* * Context: tasklet */ static void *oz_claim_hpd(struct oz_port *port) @@ -1435,7 +1435,7 @@ static void *oz_claim_hpd(struct oz_port *port) return hpd; } -/*------------------------------------------------------------------------------ +/* * Context: tasklet */ static void oz_process_ep0_urb(struct oz_hcd *ozhcd, struct urb *urb, @@ -1582,7 +1582,7 @@ static void oz_process_ep0_urb(struct oz_hcd *ozhcd, struct urb *urb, } } -/*------------------------------------------------------------------------------ +/* * Context: tasklet */ static int oz_urb_process(struct oz_hcd *ozhcd, struct urb *urb) @@ -1617,7 +1617,7 @@ static int oz_urb_process(struct oz_hcd *ozhcd, struct urb *urb) return rc; } -/*------------------------------------------------------------------------------ +/* * Context: tasklet */ static void oz_urb_process_tasklet(unsigned long unused) @@ -1651,7 +1651,7 @@ static void oz_urb_process_tasklet(unsigned long unused) oz_hcd_put(ozhcd); } -/*------------------------------------------------------------------------------ +/* * This function searches for the urb in any of the lists it could be in. * If it is found it is removed from the list and completed. If the urb is * being processed then it won't be in a list so won't be found. However, the @@ -1719,7 +1719,7 @@ static void oz_urb_cancel(struct oz_port *port, u8 ep_num, struct urb *urb) } } -/*------------------------------------------------------------------------------ +/* * Context: tasklet */ static void oz_urb_cancel_tasklet(unsigned long unused) @@ -1747,7 +1747,7 @@ static void oz_urb_cancel_tasklet(unsigned long unused) oz_hcd_put(ozhcd); } -/*------------------------------------------------------------------------------ +/* * Context: unknown */ static void oz_hcd_clear_orphanage(struct oz_hcd *ozhcd, int status) @@ -1764,7 +1764,7 @@ static void oz_hcd_clear_orphanage(struct oz_hcd *ozhcd, int status) } } -/*------------------------------------------------------------------------------ +/* * Context: unknown */ static int oz_hcd_start(struct usb_hcd *hcd) @@ -1775,21 +1775,21 @@ static int oz_hcd_start(struct usb_hcd *hcd) return 0; } -/*------------------------------------------------------------------------------ +/* * Context: unknown */ static void oz_hcd_stop(struct usb_hcd *hcd) { } -/*------------------------------------------------------------------------------ +/* * Context: unknown */ static void oz_hcd_shutdown(struct usb_hcd *hcd) { } -/*------------------------------------------------------------------------------ +/* * Called to queue an urb for the device. * This function should return a non-zero error code if it fails the urb but * should not call usb_hcd_giveback_urb(). @@ -1847,7 +1847,7 @@ static int oz_hcd_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, return 0; } -/*------------------------------------------------------------------------------ +/* * Context: tasklet */ static struct oz_urb_link *oz_remove_urb(struct oz_endpoint *ep, @@ -1873,7 +1873,7 @@ static struct oz_urb_link *oz_remove_urb(struct oz_endpoint *ep, return NULL; } -/*------------------------------------------------------------------------------ +/* * Called to dequeue a previously submitted urb for the device. * Context: any */ @@ -1915,7 +1915,7 @@ static int oz_hcd_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) return rc; } -/*------------------------------------------------------------------------------ +/* * Context: unknown */ static void oz_hcd_endpoint_disable(struct usb_hcd *hcd, @@ -1923,7 +1923,7 @@ static void oz_hcd_endpoint_disable(struct usb_hcd *hcd, { } -/*------------------------------------------------------------------------------ +/* * Context: unknown */ static void oz_hcd_endpoint_reset(struct usb_hcd *hcd, @@ -1931,7 +1931,7 @@ static void oz_hcd_endpoint_reset(struct usb_hcd *hcd, { } -/*------------------------------------------------------------------------------ +/* * Context: unknown */ static int oz_hcd_get_frame_number(struct usb_hcd *hcd) @@ -1940,7 +1940,7 @@ static int oz_hcd_get_frame_number(struct usb_hcd *hcd) return oz_usb_get_frame_number(); } -/*------------------------------------------------------------------------------ +/* * Context: softirq * This is called as a consquence of us calling usb_hcd_poll_rh_status() and we * always do that in softirq context. @@ -1971,7 +1971,7 @@ static int oz_hcd_hub_status_data(struct usb_hcd *hcd, char *buf) return 0; } -/*------------------------------------------------------------------------------ +/* * Context: process */ static void oz_get_hub_descriptor(struct usb_hcd *hcd, @@ -1985,7 +1985,7 @@ static void oz_get_hub_descriptor(struct usb_hcd *hcd, desc->bNbrPorts = OZ_NB_PORTS; } -/*------------------------------------------------------------------------------ +/* * Context: process */ static int oz_set_port_feature(struct usb_hcd *hcd, u16 wvalue, u16 windex) @@ -2061,7 +2061,7 @@ static int oz_set_port_feature(struct usb_hcd *hcd, u16 wvalue, u16 windex) return err; } -/*------------------------------------------------------------------------------ +/* * Context: process */ static int oz_clear_port_feature(struct usb_hcd *hcd, u16 wvalue, u16 windex) @@ -2137,7 +2137,7 @@ static int oz_clear_port_feature(struct usb_hcd *hcd, u16 wvalue, u16 windex) return err; } -/*------------------------------------------------------------------------------ +/* * Context: process */ static int oz_get_port_status(struct usb_hcd *hcd, u16 windex, char *buf) @@ -2155,7 +2155,7 @@ static int oz_get_port_status(struct usb_hcd *hcd, u16 windex, char *buf) return 0; } -/*------------------------------------------------------------------------------ +/* * Context: process */ static int oz_hcd_hub_control(struct usb_hcd *hcd, u16 req_type, u16 wvalue, @@ -2193,7 +2193,7 @@ static int oz_hcd_hub_control(struct usb_hcd *hcd, u16 req_type, u16 wvalue, return err; } -/*------------------------------------------------------------------------------ +/* * Context: process */ static int oz_hcd_bus_suspend(struct usb_hcd *hcd) @@ -2208,7 +2208,7 @@ static int oz_hcd_bus_suspend(struct usb_hcd *hcd) return 0; } -/*------------------------------------------------------------------------------ +/* * Context: process */ static int oz_hcd_bus_resume(struct usb_hcd *hcd) @@ -2223,13 +2223,11 @@ static int oz_hcd_bus_resume(struct usb_hcd *hcd) return 0; } -/*------------------------------------------------------------------------------ - */ static void oz_plat_shutdown(struct platform_device *dev) { } -/*------------------------------------------------------------------------------ +/* * Context: process */ static int oz_plat_probe(struct platform_device *dev) @@ -2272,7 +2270,7 @@ static int oz_plat_probe(struct platform_device *dev) return 0; } -/*------------------------------------------------------------------------------ +/* * Context: unknown */ static int oz_plat_remove(struct platform_device *dev) @@ -2296,7 +2294,7 @@ static int oz_plat_remove(struct platform_device *dev) return 0; } -/*------------------------------------------------------------------------------ +/* * Context: unknown */ static int oz_plat_suspend(struct platform_device *dev, pm_message_t msg) @@ -2305,7 +2303,7 @@ static int oz_plat_suspend(struct platform_device *dev, pm_message_t msg) } -/*------------------------------------------------------------------------------ +/* * Context: unknown */ static int oz_plat_resume(struct platform_device *dev) @@ -2313,7 +2311,7 @@ static int oz_plat_resume(struct platform_device *dev) return 0; } -/*------------------------------------------------------------------------------ +/* * Context: process */ int oz_hcd_init(void) @@ -2350,7 +2348,7 @@ int oz_hcd_init(void) return err; } -/*------------------------------------------------------------------------------ +/* * Context: process */ void oz_hcd_term(void) diff --git a/drivers/staging/ozwpan/ozmain.c b/drivers/staging/ozwpan/ozmain.c index 707ab287b6a5c..d1a5b7a2c16d6 100644 --- a/drivers/staging/ozwpan/ozmain.c +++ b/drivers/staging/ozwpan/ozmain.c @@ -18,7 +18,7 @@ unsigned int oz_dbg_mask = OZ_DEFAULT_DBG_MASK; -/*------------------------------------------------------------------------------ +/* * The name of the 802.11 mac device. Empty string is the default value but a * value can be supplied as a parameter to the module. An empty string means * bind to nothing. '*' means bind to all netcards - this includes non-802.11 @@ -26,7 +26,7 @@ unsigned int oz_dbg_mask = OZ_DEFAULT_DBG_MASK; */ static char *g_net_dev = ""; -/*------------------------------------------------------------------------------ +/* * Context: process */ static int __init ozwpan_init(void) @@ -38,7 +38,7 @@ static int __init ozwpan_init(void) return 0; } -/*------------------------------------------------------------------------------ +/* * Context: process */ static void __exit ozwpan_exit(void) @@ -48,8 +48,6 @@ static void __exit ozwpan_exit(void) oz_cdev_deregister(); } -/*------------------------------------------------------------------------------ - */ module_param(g_net_dev, charp, S_IRUGO); module_init(ozwpan_init); module_exit(ozwpan_exit); diff --git a/drivers/staging/ozwpan/ozpd.c b/drivers/staging/ozwpan/ozpd.c index d39a3df4842be..daaff2af14ae0 100644 --- a/drivers/staging/ozwpan/ozpd.c +++ b/drivers/staging/ozwpan/ozpd.c @@ -21,12 +21,8 @@ #include #include -/*------------------------------------------------------------------------------ - */ #define OZ_MAX_TX_POOL_SIZE 6 -/*------------------------------------------------------------------------------ - */ static struct oz_tx_frame *oz_tx_frame_alloc(struct oz_pd *pd); static void oz_tx_frame_free(struct oz_pd *pd, struct oz_tx_frame *f); static void oz_tx_isoc_free(struct oz_pd *pd, struct oz_tx_frame *f); @@ -42,7 +38,7 @@ static int oz_def_app_start(struct oz_pd *pd, int resume); static void oz_def_app_stop(struct oz_pd *pd, int pause); static void oz_def_app_rx(struct oz_pd *pd, struct oz_elt *elt); -/*------------------------------------------------------------------------------ +/* * Counts the uncompleted isoc frames submitted to netcard. */ static atomic_t g_submitted_isoc = ATOMIC_INIT(0); @@ -87,7 +83,7 @@ static const struct oz_app_if g_app_if[OZ_APPID_MAX] = { OZ_APPID_SERIAL}, }; -/*------------------------------------------------------------------------------ +/* * Context: process */ static int oz_def_app_init(void) @@ -95,14 +91,14 @@ static int oz_def_app_init(void) return 0; } -/*------------------------------------------------------------------------------ +/* * Context: process */ static void oz_def_app_term(void) { } -/*------------------------------------------------------------------------------ +/* * Context: softirq */ static int oz_def_app_start(struct oz_pd *pd, int resume) @@ -110,21 +106,21 @@ static int oz_def_app_start(struct oz_pd *pd, int resume) return 0; } -/*------------------------------------------------------------------------------ +/* * Context: softirq */ static void oz_def_app_stop(struct oz_pd *pd, int pause) { } -/*------------------------------------------------------------------------------ +/* * Context: softirq */ static void oz_def_app_rx(struct oz_pd *pd, struct oz_elt *elt) { } -/*------------------------------------------------------------------------------ +/* * Context: softirq or process */ void oz_pd_set_state(struct oz_pd *pd, unsigned state) @@ -146,7 +142,7 @@ void oz_pd_set_state(struct oz_pd *pd, unsigned state) } } -/*------------------------------------------------------------------------------ +/* * Context: softirq or process */ void oz_pd_get(struct oz_pd *pd) @@ -154,7 +150,7 @@ void oz_pd_get(struct oz_pd *pd) atomic_inc(&pd->ref_count); } -/*------------------------------------------------------------------------------ +/* * Context: softirq or process */ void oz_pd_put(struct oz_pd *pd) @@ -163,7 +159,7 @@ void oz_pd_put(struct oz_pd *pd) oz_pd_destroy(pd); } -/*------------------------------------------------------------------------------ +/* * Context: softirq-serialized */ struct oz_pd *oz_pd_alloc(const u8 *mac_addr) @@ -201,7 +197,7 @@ struct oz_pd *oz_pd_alloc(const u8 *mac_addr) return pd; } -/*------------------------------------------------------------------------------ +/* * Context: softirq or process */ void oz_pd_free(struct work_struct *work) @@ -256,7 +252,7 @@ void oz_pd_free(struct work_struct *work) kfree(pd); } -/*------------------------------------------------------------------------------ +/* * Context: softirq or Process */ void oz_pd_destroy(struct oz_pd *pd) @@ -271,7 +267,7 @@ void oz_pd_destroy(struct oz_pd *pd) oz_pd_dbg(pd, ON, "failed to schedule workitem\n"); } -/*------------------------------------------------------------------------------ +/* * Context: softirq-serialized */ int oz_services_start(struct oz_pd *pd, u16 apps, int resume) @@ -299,7 +295,7 @@ int oz_services_start(struct oz_pd *pd, u16 apps, int resume) return rc; } -/*------------------------------------------------------------------------------ +/* * Context: softirq or process */ void oz_services_stop(struct oz_pd *pd, u16 apps, int pause) @@ -322,7 +318,7 @@ void oz_services_stop(struct oz_pd *pd, u16 apps, int pause) } } -/*------------------------------------------------------------------------------ +/* * Context: softirq */ void oz_pd_heartbeat(struct oz_pd *pd, u16 apps) @@ -345,7 +341,7 @@ void oz_pd_heartbeat(struct oz_pd *pd, u16 apps) } } -/*------------------------------------------------------------------------------ +/* * Context: softirq or process */ void oz_pd_stop(struct oz_pd *pd) @@ -369,7 +365,7 @@ void oz_pd_stop(struct oz_pd *pd) oz_pd_put(pd); } -/*------------------------------------------------------------------------------ +/* * Context: softirq */ int oz_pd_sleep(struct oz_pd *pd) @@ -398,7 +394,7 @@ int oz_pd_sleep(struct oz_pd *pd) return do_stop; } -/*------------------------------------------------------------------------------ +/* * Context: softirq */ static struct oz_tx_frame *oz_tx_frame_alloc(struct oz_pd *pd) @@ -422,7 +418,7 @@ static struct oz_tx_frame *oz_tx_frame_alloc(struct oz_pd *pd) return f; } -/*------------------------------------------------------------------------------ +/* * Context: softirq or process */ static void oz_tx_isoc_free(struct oz_pd *pd, struct oz_tx_frame *f) @@ -440,7 +436,7 @@ static void oz_tx_isoc_free(struct oz_pd *pd, struct oz_tx_frame *f) pd->nb_queued_isoc_frames); } -/*------------------------------------------------------------------------------ +/* * Context: softirq or process */ static void oz_tx_frame_free(struct oz_pd *pd, struct oz_tx_frame *f) @@ -456,7 +452,7 @@ static void oz_tx_frame_free(struct oz_pd *pd, struct oz_tx_frame *f) kfree(f); } -/*------------------------------------------------------------------------------ +/* * Context: softirq-serialized */ static void oz_set_more_bit(struct sk_buff *skb) @@ -466,7 +462,7 @@ static void oz_set_more_bit(struct sk_buff *skb) oz_hdr->control |= OZ_F_MORE_DATA; } -/*------------------------------------------------------------------------------ +/* * Context: softirq-serialized */ static void oz_set_last_pkt_nb(struct oz_pd *pd, struct sk_buff *skb) @@ -476,7 +472,7 @@ static void oz_set_last_pkt_nb(struct oz_pd *pd, struct sk_buff *skb) oz_hdr->last_pkt_num = pd->trigger_pkt_num & OZ_LAST_PN_MASK; } -/*------------------------------------------------------------------------------ +/* * Context: softirq */ int oz_prepare_frame(struct oz_pd *pd, int empty) @@ -508,7 +504,7 @@ int oz_prepare_frame(struct oz_pd *pd, int empty) return 0; } -/*------------------------------------------------------------------------------ +/* * Context: softirq-serialized */ static struct sk_buff *oz_build_frame(struct oz_pd *pd, struct oz_tx_frame *f) @@ -554,7 +550,7 @@ static struct sk_buff *oz_build_frame(struct oz_pd *pd, struct oz_tx_frame *f) return NULL; } -/*------------------------------------------------------------------------------ +/* * Context: softirq or process */ static void oz_retire_frame(struct oz_pd *pd, struct oz_tx_frame *f) @@ -578,7 +574,7 @@ static void oz_retire_frame(struct oz_pd *pd, struct oz_tx_frame *f) oz_trim_elt_pool(&pd->elt_buff); } -/*------------------------------------------------------------------------------ +/* * Context: softirq-serialized */ static int oz_send_next_queued_frame(struct oz_pd *pd, int more_data) @@ -633,7 +629,7 @@ static int oz_send_next_queued_frame(struct oz_pd *pd, int more_data) return 0; } -/*------------------------------------------------------------------------------ +/* * Context: softirq-serialized */ void oz_send_queued_frames(struct oz_pd *pd, int backlog) @@ -672,7 +668,7 @@ out: oz_prepare_frame(pd, 1); oz_send_next_queued_frame(pd, 0); } -/*------------------------------------------------------------------------------ +/* * Context: softirq */ static int oz_send_isoc_frame(struct oz_pd *pd) @@ -722,7 +718,7 @@ static int oz_send_isoc_frame(struct oz_pd *pd) return 0; } -/*------------------------------------------------------------------------------ +/* * Context: softirq-serialized */ void oz_retire_tx_frames(struct oz_pd *pd, u8 lpn) @@ -764,7 +760,7 @@ void oz_retire_tx_frames(struct oz_pd *pd, u8 lpn) } } -/*------------------------------------------------------------------------------ +/* * Precondition: stream_lock must be held. * Context: softirq */ @@ -781,7 +777,7 @@ static struct oz_isoc_stream *pd_stream_find(struct oz_pd *pd, u8 ep_num) return NULL; } -/*------------------------------------------------------------------------------ +/* * Context: softirq */ int oz_isoc_stream_create(struct oz_pd *pd, u8 ep_num) @@ -801,7 +797,7 @@ int oz_isoc_stream_create(struct oz_pd *pd, u8 ep_num) return 0; } -/*------------------------------------------------------------------------------ +/* * Context: softirq or process */ static void oz_isoc_stream_free(struct oz_isoc_stream *st) @@ -810,7 +806,7 @@ static void oz_isoc_stream_free(struct oz_isoc_stream *st) kfree(st); } -/*------------------------------------------------------------------------------ +/* * Context: softirq */ int oz_isoc_stream_delete(struct oz_pd *pd, u8 ep_num) @@ -827,7 +823,7 @@ int oz_isoc_stream_delete(struct oz_pd *pd, u8 ep_num) return 0; } -/*------------------------------------------------------------------------------ +/* * Context: any */ static void oz_isoc_destructor(struct sk_buff *skb) @@ -835,7 +831,7 @@ static void oz_isoc_destructor(struct sk_buff *skb) atomic_dec(&g_submitted_isoc); } -/*------------------------------------------------------------------------------ +/* * Context: softirq */ int oz_send_isoc_unit(struct oz_pd *pd, u8 ep_num, const u8 *data, int len) @@ -957,7 +953,7 @@ out: kfree_skb(skb); return 0; } -/*------------------------------------------------------------------------------ +/* * Context: process */ void oz_apps_init(void) @@ -969,7 +965,7 @@ void oz_apps_init(void) g_app_if[i].init(); } -/*------------------------------------------------------------------------------ +/* * Context: process */ void oz_apps_term(void) @@ -982,7 +978,7 @@ void oz_apps_term(void) g_app_if[i].term(); } -/*------------------------------------------------------------------------------ +/* * Context: softirq-serialized */ void oz_handle_app_elt(struct oz_pd *pd, u8 app_id, struct oz_elt *elt) @@ -995,7 +991,7 @@ void oz_handle_app_elt(struct oz_pd *pd, u8 app_id, struct oz_elt *elt) ai->rx(pd, elt); } -/*------------------------------------------------------------------------------ +/* * Context: softirq or process */ void oz_pd_indicate_farewells(struct oz_pd *pd) diff --git a/drivers/staging/ozwpan/ozproto.c b/drivers/staging/ozwpan/ozproto.c index d8ac823f1c977..88714ec85705f 100644 --- a/drivers/staging/ozwpan/ozproto.c +++ b/drivers/staging/ozwpan/ozproto.c @@ -23,8 +23,6 @@ #include #include -/*------------------------------------------------------------------------------ - */ #define OZ_CF_CONN_SUCCESS 1 #define OZ_CF_CONN_FAILURE 2 @@ -33,15 +31,13 @@ #define OZ_MAX_TIMER_POOL_SIZE 16 -/*------------------------------------------------------------------------------ - */ struct oz_binding { struct packet_type ptype; char name[OZ_MAX_BINDING_LEN]; struct list_head link; }; -/*------------------------------------------------------------------------------ +/* * Static external variables. */ static DEFINE_SPINLOCK(g_polling_lock); @@ -53,7 +49,7 @@ static u8 g_session_id; static u16 g_apps = 0x1; static int g_processing_rx; -/*------------------------------------------------------------------------------ +/* * Context: softirq-serialized */ static u8 oz_get_new_session_id(u8 exclude) @@ -67,7 +63,7 @@ static u8 oz_get_new_session_id(u8 exclude) return g_session_id; } -/*------------------------------------------------------------------------------ +/* * Context: softirq-serialized */ static void oz_send_conn_rsp(struct oz_pd *pd, u8 status) @@ -113,7 +109,7 @@ static void oz_send_conn_rsp(struct oz_pd *pd, u8 status) return; } -/*------------------------------------------------------------------------------ +/* * Context: softirq-serialized */ static void pd_set_keepalive(struct oz_pd *pd, u8 kalive) @@ -139,7 +135,7 @@ static void pd_set_keepalive(struct oz_pd *pd, u8 kalive) oz_dbg(ON, "Keepalive = %lu mSec\n", pd->keep_alive); } -/*------------------------------------------------------------------------------ +/* * Context: softirq-serialized */ static void pd_set_presleep(struct oz_pd *pd, u8 presleep, u8 start_timer) @@ -156,7 +152,7 @@ static void pd_set_presleep(struct oz_pd *pd, u8 presleep, u8 start_timer) oz_dbg(ON, "Presleep time = %lu mSec\n", pd->presleep); } -/*------------------------------------------------------------------------------ +/* * Context: softirq-serialized */ static struct oz_pd *oz_connect_req(struct oz_pd *cur_pd, struct oz_elt *elt, @@ -291,7 +287,7 @@ static struct oz_pd *oz_connect_req(struct oz_pd *cur_pd, struct oz_elt *elt, return pd; } -/*------------------------------------------------------------------------------ +/* * Context: softirq-serialized */ static void oz_add_farewell(struct oz_pd *pd, u8 ep_num, u8 index, @@ -323,7 +319,7 @@ static void oz_add_farewell(struct oz_pd *pd, u8 ep_num, u8 index, kfree(f2); } -/*------------------------------------------------------------------------------ +/* * Context: softirq-serialized */ static void oz_rx_frame(struct sk_buff *skb) @@ -445,7 +441,7 @@ static void oz_rx_frame(struct sk_buff *skb) consume_skb(skb); } -/*------------------------------------------------------------------------------ +/* * Context: process */ void oz_protocol_term(void) @@ -483,7 +479,7 @@ void oz_protocol_term(void) oz_dbg(ON, "Protocol stopped\n"); } -/*------------------------------------------------------------------------------ +/* * Context: softirq */ void oz_pd_heartbeat_handler(unsigned long data) @@ -500,7 +496,7 @@ void oz_pd_heartbeat_handler(unsigned long data) oz_pd_put(pd); } -/*------------------------------------------------------------------------------ +/* * Context: softirq */ void oz_pd_timeout_handler(unsigned long data) @@ -522,7 +518,7 @@ void oz_pd_timeout_handler(unsigned long data) oz_pd_put(pd); } -/*------------------------------------------------------------------------------ +/* * Context: Interrupt */ enum hrtimer_restart oz_pd_heartbeat_event(struct hrtimer *timer) @@ -537,7 +533,7 @@ enum hrtimer_restart oz_pd_heartbeat_event(struct hrtimer *timer) return HRTIMER_RESTART; } -/*------------------------------------------------------------------------------ +/* * Context: Interrupt */ enum hrtimer_restart oz_pd_timeout_event(struct hrtimer *timer) @@ -550,7 +546,7 @@ enum hrtimer_restart oz_pd_timeout_event(struct hrtimer *timer) return HRTIMER_NORESTART; } -/*------------------------------------------------------------------------------ +/* * Context: softirq or process */ void oz_timer_add(struct oz_pd *pd, int type, unsigned long due_time) @@ -581,7 +577,7 @@ void oz_timer_add(struct oz_pd *pd, int type, unsigned long due_time) spin_unlock_bh(&g_polling_lock); } -/*------------------------------------------------------------------------------ +/* * Context: softirq or process */ void oz_pd_request_heartbeat(struct oz_pd *pd) @@ -590,7 +586,7 @@ void oz_pd_request_heartbeat(struct oz_pd *pd) pd->pulse_period : OZ_QUANTUM); } -/*------------------------------------------------------------------------------ +/* * Context: softirq or process */ struct oz_pd *oz_pd_find(const u8 *mac_addr) @@ -611,7 +607,7 @@ struct oz_pd *oz_pd_find(const u8 *mac_addr) return NULL; } -/*------------------------------------------------------------------------------ +/* * Context: process */ void oz_app_enable(int app_id, int enable) @@ -626,7 +622,7 @@ void oz_app_enable(int app_id, int enable) } } -/*------------------------------------------------------------------------------ +/* * Context: softirq */ static int oz_pkt_recv(struct sk_buff *skb, struct net_device *dev, @@ -661,7 +657,7 @@ static int oz_pkt_recv(struct sk_buff *skb, struct net_device *dev, return 0; } -/*------------------------------------------------------------------------------ +/* * Context: process */ void oz_binding_add(const char *net_dev) @@ -695,7 +691,7 @@ void oz_binding_add(const char *net_dev) } } -/*------------------------------------------------------------------------------ +/* * Context: process */ static void pd_stop_all_for_device(struct net_device *net_dev) @@ -720,7 +716,7 @@ static void pd_stop_all_for_device(struct net_device *net_dev) } } -/*------------------------------------------------------------------------------ +/* * Context: process */ void oz_binding_remove(const char *net_dev) @@ -749,7 +745,7 @@ void oz_binding_remove(const char *net_dev) } } -/*------------------------------------------------------------------------------ +/* * Context: process */ static char *oz_get_next_device_name(char *s, char *dname, int max_size) @@ -764,7 +760,7 @@ static char *oz_get_next_device_name(char *s, char *dname, int max_size) return s; } -/*------------------------------------------------------------------------------ +/* * Context: process */ int oz_protocol_init(char *devs) @@ -783,7 +779,7 @@ int oz_protocol_init(char *devs) return 0; } -/*------------------------------------------------------------------------------ +/* * Context: process */ int oz_get_pd_list(struct oz_mac_addr *addr, int max_count) @@ -803,15 +799,11 @@ int oz_get_pd_list(struct oz_mac_addr *addr, int max_count) return count; } -/*------------------------------------------------------------------------------ -*/ void oz_polling_lock_bh(void) { spin_lock_bh(&g_polling_lock); } -/*------------------------------------------------------------------------------ -*/ void oz_polling_unlock_bh(void) { spin_unlock_bh(&g_polling_lock); diff --git a/drivers/staging/ozwpan/ozurbparanoia.c b/drivers/staging/ozwpan/ozurbparanoia.c index d779877ef6f0b..cf6278a198a8b 100644 --- a/drivers/staging/ozwpan/ozurbparanoia.c +++ b/drivers/staging/ozwpan/ozurbparanoia.c @@ -10,15 +10,11 @@ #include "ozurbparanoia.h" -/*----------------------------------------------------------------------------- - */ #define OZ_MAX_URBS 1000 struct urb *g_urb_memory[OZ_MAX_URBS]; int g_nb_urbs; DEFINE_SPINLOCK(g_urb_mem_lock); -/*----------------------------------------------------------------------------- - */ void oz_remember_urb(struct urb *urb) { unsigned long irq_state; @@ -33,7 +29,7 @@ void oz_remember_urb(struct urb *urb) spin_unlock_irqrestore(&g_urb_mem_lock, irq_state); } -/*------------------------------------------------------------------------------ +/* */ int oz_forget_urb(struct urb *urb) { diff --git a/drivers/staging/ozwpan/ozusbsvc.c b/drivers/staging/ozwpan/ozusbsvc.c index 404941d55d787..cf263791cb300 100644 --- a/drivers/staging/ozwpan/ozusbsvc.c +++ b/drivers/staging/ozwpan/ozusbsvc.c @@ -28,7 +28,7 @@ #include "ozhcd.h" #include "ozusbsvc.h" -/*------------------------------------------------------------------------------ +/* * This is called once when the driver is loaded to initialise the USB service. * Context: process */ @@ -37,7 +37,7 @@ int oz_usb_init(void) return oz_hcd_init(); } -/*------------------------------------------------------------------------------ +/* * This is called once when the driver is unloaded to terminate the USB service. * Context: process */ @@ -46,7 +46,7 @@ void oz_usb_term(void) oz_hcd_term(); } -/*------------------------------------------------------------------------------ +/* * This is called when the USB service is started or resumed for a PD. * Context: softirq */ @@ -111,7 +111,7 @@ int oz_usb_start(struct oz_pd *pd, int resume) return rc; } -/*------------------------------------------------------------------------------ +/* * This is called when the USB service is stopped or paused for a PD. * Context: softirq or process */ @@ -152,7 +152,7 @@ void oz_usb_stop(struct oz_pd *pd, int pause) } } -/*------------------------------------------------------------------------------ +/* * This increments the reference count of the context area for a specific PD. * This ensures this context area does not disappear while still in use. * Context: softirq @@ -164,7 +164,7 @@ void oz_usb_get(void *hpd) atomic_inc(&usb_ctx->ref_count); } -/*------------------------------------------------------------------------------ +/* * This decrements the reference count of the context area for a specific PD * and destroys the context area if the reference count becomes zero. * Context: irq or process @@ -180,7 +180,7 @@ void oz_usb_put(void *hpd) } } -/*------------------------------------------------------------------------------ +/* * Context: softirq */ int oz_usb_heartbeat(struct oz_pd *pd) @@ -205,7 +205,7 @@ int oz_usb_heartbeat(struct oz_pd *pd) return rc; } -/*------------------------------------------------------------------------------ +/* * Context: softirq */ int oz_usb_stream_create(void *hpd, u8 ep_num) @@ -227,7 +227,7 @@ int oz_usb_stream_create(void *hpd, u8 ep_num) return 0; } -/*------------------------------------------------------------------------------ +/* * Context: softirq */ int oz_usb_stream_delete(void *hpd, u8 ep_num) @@ -250,7 +250,7 @@ int oz_usb_stream_delete(void *hpd, u8 ep_num) return 0; } -/*------------------------------------------------------------------------------ +/* * Context: softirq or process */ void oz_usb_request_heartbeat(void *hpd) diff --git a/drivers/staging/ozwpan/ozusbsvc1.c b/drivers/staging/ozwpan/ozusbsvc1.c index 4ec21b54f94b3..228bffaa69c91 100644 --- a/drivers/staging/ozwpan/ozusbsvc1.c +++ b/drivers/staging/ozwpan/ozusbsvc1.c @@ -22,11 +22,9 @@ #include "ozhcd.h" #include "ozusbsvc.h" -/*------------------------------------------------------------------------------ - */ #define MAX_ISOC_FIXED_DATA (253-sizeof(struct oz_isoc_fixed)) -/*------------------------------------------------------------------------------ +/* * Context: softirq */ static int oz_usb_submit_elt(struct oz_elt_buf *eb, struct oz_elt_info *ei, @@ -53,7 +51,7 @@ static int oz_usb_submit_elt(struct oz_elt_buf *eb, struct oz_elt_info *ei, return ret; } -/*------------------------------------------------------------------------------ +/* * Context: softirq */ int oz_usb_get_desc_req(void *hpd, u8 req_id, u8 req_type, u8 desc_type, @@ -90,7 +88,7 @@ int oz_usb_get_desc_req(void *hpd, u8 req_id, u8 req_type, u8 desc_type, return oz_usb_submit_elt(eb, ei, usb_ctx, 0, 0); } -/*------------------------------------------------------------------------------ +/* * Context: tasklet */ static int oz_usb_set_config_req(void *hpd, u8 req_id, u8 index) @@ -113,7 +111,7 @@ static int oz_usb_set_config_req(void *hpd, u8 req_id, u8 index) return oz_usb_submit_elt(eb, ei, usb_ctx, 0, 0); } -/*------------------------------------------------------------------------------ +/* * Context: tasklet */ static int oz_usb_set_interface_req(void *hpd, u8 req_id, u8 index, u8 alt) @@ -137,7 +135,7 @@ static int oz_usb_set_interface_req(void *hpd, u8 req_id, u8 index, u8 alt) return oz_usb_submit_elt(eb, ei, usb_ctx, 0, 0); } -/*------------------------------------------------------------------------------ +/* * Context: tasklet */ static int oz_usb_set_clear_feature_req(void *hpd, u8 req_id, u8 type, @@ -163,7 +161,7 @@ static int oz_usb_set_clear_feature_req(void *hpd, u8 req_id, u8 type, return oz_usb_submit_elt(eb, ei, usb_ctx, 0, 0); } -/*------------------------------------------------------------------------------ +/* * Context: tasklet */ static int oz_usb_vendor_class_req(void *hpd, u8 req_id, u8 req_type, @@ -192,7 +190,7 @@ static int oz_usb_vendor_class_req(void *hpd, u8 req_id, u8 req_type, return oz_usb_submit_elt(eb, ei, usb_ctx, 0, 0); } -/*------------------------------------------------------------------------------ +/* * Context: tasklet */ int oz_usb_control_req(void *hpd, u8 req_id, struct usb_ctrlrequest *setup, @@ -241,7 +239,7 @@ int oz_usb_control_req(void *hpd, u8 req_id, struct usb_ctrlrequest *setup, return rc; } -/*------------------------------------------------------------------------------ +/* * Context: softirq */ int oz_usb_send_isoc(void *hpd, u8 ep_num, struct urb *urb) @@ -313,7 +311,7 @@ int oz_usb_send_isoc(void *hpd, u8 ep_num, struct urb *urb) return 0; } -/*------------------------------------------------------------------------------ +/* * Context: softirq-serialized */ static void oz_usb_handle_ep_data(struct oz_usb_ctx *usb_ctx, @@ -357,7 +355,7 @@ static void oz_usb_handle_ep_data(struct oz_usb_ctx *usb_ctx, } -/*------------------------------------------------------------------------------ +/* * This is called when the PD has received a USB element. The type of element * is determined and is then passed to an appropriate handler function. * Context: softirq-serialized @@ -430,7 +428,7 @@ void oz_usb_rx(struct oz_pd *pd, struct oz_elt *elt) oz_usb_put(usb_ctx); } -/*------------------------------------------------------------------------------ +/* * Context: softirq, process */ void oz_usb_farewell(struct oz_pd *pd, u8 ep_num, u8 *data, u8 len) -- GitLab From 917ea9a3e1133841d1b1a496fa93036729cbf5c2 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Fri, 23 Aug 2013 17:46:48 +0200 Subject: [PATCH 815/942] staging: lustre: Use proper constant types for L*_POISON values MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 32-bit m68k, I get lots of warnings like: warning: integer constant is too large for ‘long’ type Switch the L*_POISON definitions from too-large constants and casts to the proper constant types to fix this. Signed-off-by: Geert Uytterhoeven Signed-off-by: Greg Kroah-Hartman --- .../staging/lustre/include/linux/libcfs/linux/kp30.h | 10 +++++++--- .../staging/lustre/lustre/include/linux/lustre_lib.h | 10 ++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/kp30.h b/drivers/staging/lustre/include/linux/libcfs/linux/kp30.h index 073f4d1f176e3..c204b677796fd 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/kp30.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/kp30.h @@ -187,9 +187,13 @@ extern int lwt_snapshot (cfs_cycles_t *now, int *ncpu, int *total_size, # endif #endif -# define LI_POISON ((int)0x5a5a5a5a5a5a5a5a) -# define LL_POISON ((long)0x5a5a5a5a5a5a5a5a) -# define LP_POISON ((void *)(long)0x5a5a5a5a5a5a5a5a) +# define LI_POISON 0x5a5a5a5a +#if BITS_PER_LONG > 32 +# define LL_POISON 0x5a5a5a5a5a5a5a5aL +#else +# define LL_POISON 0x5a5a5a5aL +#endif +# define LP_POISON ((void *)LL_POISON) /* this is a bit chunky */ diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_lib.h b/drivers/staging/lustre/lustre/include/linux/lustre_lib.h index b2f755acadf6e..57f3b01d1a326 100644 --- a/drivers/staging/lustre/lustre/include/linux/lustre_lib.h +++ b/drivers/staging/lustre/lustre/include/linux/lustre_lib.h @@ -53,15 +53,13 @@ # include #ifndef LP_POISON +# define LI_POISON 0x5a5a5a5a #if BITS_PER_LONG > 32 -# define LI_POISON ((int)0x5a5a5a5a5a5a5a5a) -# define LL_POISON ((long)0x5a5a5a5a5a5a5a5a) -# define LP_POISON ((void *)(long)0x5a5a5a5a5a5a5a5a) +# define LL_POISON 0x5a5a5a5a5a5a5a5aL #else -# define LI_POISON ((int)0x5a5a5a5a) -# define LL_POISON ((long)0x5a5a5a5a) -# define LP_POISON ((void *)(long)0x5a5a5a5a) +# define LL_POISON 0x5a5a5a5aL #endif +# define LP_POISON ((void *)LL_POISON) #endif /* This macro is only for compatibility reasons with older Linux Lustre user -- GitLab From 76e1f486b2e6775bba31118b362e01ea6033a0e6 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sat, 24 Aug 2013 10:24:40 -0700 Subject: [PATCH 816/942] staging: wlags49_h2: remove sysfs file The sysfs file in this driver is showing a raft of debugging values, none of which belong in sysfs, let alone in a single sysfs file. If these really need to be described somewhere, they should go into debugfs. For now, just delete the sysfs file, which removes a bunch of files from the tree. Cc: Henk de Groot Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlags49_h2/Makefile | 2 - drivers/staging/wlags49_h2/wl_cs.c | 4 - drivers/staging/wlags49_h2/wl_internal.h | 1 - drivers/staging/wlags49_h2/wl_sysfs.c | 138 ----------------------- drivers/staging/wlags49_h2/wl_sysfs.h | 7 -- drivers/staging/wlags49_h25/Makefile | 3 - drivers/staging/wlags49_h25/wl_sysfs.c | 2 - drivers/staging/wlags49_h25/wl_sysfs.h | 2 - 8 files changed, 159 deletions(-) delete mode 100644 drivers/staging/wlags49_h2/wl_sysfs.c delete mode 100644 drivers/staging/wlags49_h2/wl_sysfs.h delete mode 100644 drivers/staging/wlags49_h25/wl_sysfs.c delete mode 100644 drivers/staging/wlags49_h25/wl_sysfs.h diff --git a/drivers/staging/wlags49_h2/Makefile b/drivers/staging/wlags49_h2/Makefile index 31e1d89a3846b..6eeb5d1845eb7 100644 --- a/drivers/staging/wlags49_h2/Makefile +++ b/drivers/staging/wlags49_h2/Makefile @@ -51,5 +51,3 @@ $(WLNAME)-y += wl_profile.o \ mmd.o \ hcf.o \ dhf.o - -$(WLNAME)-$(CONFIG_SYSFS) += wl_sysfs.o diff --git a/drivers/staging/wlags49_h2/wl_cs.c b/drivers/staging/wlags49_h2/wl_cs.c index b55dc43a1d11f..a458705a379c0 100644 --- a/drivers/staging/wlags49_h2/wl_cs.c +++ b/drivers/staging/wlags49_h2/wl_cs.c @@ -99,7 +99,6 @@ #include #include #include -#include /******************************************************************************* @@ -178,7 +177,6 @@ static void wl_adapter_detach(struct pcmcia_device *link) wl_adapter_release(link); if (dev) { - unregister_wlags_sysfs(dev); unregister_netdev(dev); wl_device_dealloc(dev); } @@ -265,8 +263,6 @@ int wl_adapter_insert(struct pcmcia_device *link) goto failed; } - register_wlags_sysfs(dev); - printk(KERN_INFO "%s: Wireless, io_addr %#03lx, irq %d, mac_address" " %pM\n", dev->name, dev->base_addr, dev->irq, dev->dev_addr); diff --git a/drivers/staging/wlags49_h2/wl_internal.h b/drivers/staging/wlags49_h2/wl_internal.h index b230781641491..78129e93920fa 100644 --- a/drivers/staging/wlags49_h2/wl_internal.h +++ b/drivers/staging/wlags49_h2/wl_internal.h @@ -883,7 +883,6 @@ struct wl_private int is_registered; int is_handling_int; int firmware_present; - bool sysfsCreated; CFG_DRV_INFO_STRCT driverInfo; CFG_IDENTITY_STRCT driverIdentity; CFG_FW_IDENTITY_STRCT StationIdentity; diff --git a/drivers/staging/wlags49_h2/wl_sysfs.c b/drivers/staging/wlags49_h2/wl_sysfs.c deleted file mode 100644 index 1508f04b3c6f5..0000000000000 --- a/drivers/staging/wlags49_h2/wl_sysfs.c +++ /dev/null @@ -1,138 +0,0 @@ -/* - * ex: sw=4 - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -static inline int dev_isalive(const struct net_device *dev) -{ - return dev->reg_state == NETREG_REGISTERED; -} - -/* - * empirically even if tallies are defined as 32 bits entities, only - * high 16 bits are relevant; low half is always zero. It means tallies - * are pretty much useless for traffic counting but at least give overview - * about where error come from - */ -static ssize_t show_tallies(struct device *d, struct device_attribute *attr, - char *buf) -{ - struct net_device *dev = to_net_dev(d); - struct wl_private *lp = wl_priv(dev); - unsigned long flags; - CFG_HERMES_TALLIES_STRCT tallies; - ssize_t ret = -EINVAL; - - rcu_read_lock(); - if (dev_isalive(dev)) { - wl_lock(lp, &flags); - - ret = wl_get_tallies(lp, &tallies); - if (ret == 0) { - wl_unlock(lp, &flags); - ret = snprintf(buf, PAGE_SIZE, - "TxUnicastFrames: %u\n" - "TxMulticastFrames: %u\n" - "TxFragments: %u\n" - "TxUnicastOctets: %u\n" - "TxMulticastOctets: %u\n" - "TxDeferredTransmissions: %u\n" - "TxSingleRetryFrames: %u\n" - "TxMultipleRetryFrames: %u\n" - "TxRetryLimitExceeded: %u\n" - "TxDiscards: %u\n" - "RxUnicastFrames: %u\n" - "RxMulticastFrames: %u\n" - "RxFragments: %u\n" - "RxUnicastOctets: %u\n" - "RxMulticastOctets: %u\n" - "RxFCSErrors: %u\n" - "RxDiscardsNoBuffer: %u\n" - "TxDiscardsWrongSA: %u\n" - "RxWEPUndecryptable: %u\n" - "RxMsgInMsgFragments: %u\n" - "RxMsgInBadMsgFragments: %u\n" - "RxDiscardsWEPICVError: %u\n" - "RxDiscardsWEPExcluded: %u\n" - , - (unsigned int)tallies.TxUnicastFrames, - (unsigned int)tallies.TxMulticastFrames, - (unsigned int)tallies.TxFragments, - (unsigned int)tallies.TxUnicastOctets, - (unsigned int)tallies.TxMulticastOctets, - (unsigned int)tallies.TxDeferredTransmissions, - (unsigned int)tallies.TxSingleRetryFrames, - (unsigned int)tallies.TxMultipleRetryFrames, - (unsigned int)tallies.TxRetryLimitExceeded, - (unsigned int)tallies.TxDiscards, - (unsigned int)tallies.RxUnicastFrames, - (unsigned int)tallies.RxMulticastFrames, - (unsigned int)tallies.RxFragments, - (unsigned int)tallies.RxUnicastOctets, - (unsigned int)tallies.RxMulticastOctets, - (unsigned int)tallies.RxFCSErrors, - (unsigned int)tallies.RxDiscardsNoBuffer, - (unsigned int)tallies.TxDiscardsWrongSA, - (unsigned int)tallies.RxWEPUndecryptable, - (unsigned int)tallies.RxMsgInMsgFragments, - (unsigned int)tallies.RxMsgInBadMsgFragments, - (unsigned int)tallies.RxDiscardsWEPICVError, - (unsigned int)tallies.RxDiscardsWEPExcluded); - } else { - wl_unlock( lp, &flags ); - } - } - - rcu_read_unlock(); - return ret; -} - -static DEVICE_ATTR(tallies, S_IRUGO, show_tallies, NULL); - -static struct attribute *wlags_attrs[] = { - &dev_attr_tallies.attr, - NULL -}; - -static struct attribute_group wlags_group = { - .name = "wlags", - .attrs = wlags_attrs, -}; - -void register_wlags_sysfs(struct net_device *net) -{ - struct device *dev = &(net->dev); - struct wl_private *lp = wl_priv(net); - int err; - err = sysfs_create_group(&dev->kobj, &wlags_group); - if (!err) - lp->sysfsCreated = true; -} - -void unregister_wlags_sysfs(struct net_device *net) -{ - struct device *dev = &(net->dev); - struct wl_private *lp = wl_priv(net); - - if (lp->sysfsCreated) - sysfs_remove_group(&dev->kobj, &wlags_group); -} diff --git a/drivers/staging/wlags49_h2/wl_sysfs.h b/drivers/staging/wlags49_h2/wl_sysfs.h deleted file mode 100644 index fa658c38001e6..0000000000000 --- a/drivers/staging/wlags49_h2/wl_sysfs.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifdef CONFIG_SYSFS -extern void register_wlags_sysfs(struct net_device *); -extern void unregister_wlags_sysfs(struct net_device *); -#else -static inline void register_wlags_sysfs(struct net_device *net) { } -static inline void unregister_wlags_sysfs(struct net_device *net) { } -#endif diff --git a/drivers/staging/wlags49_h25/Makefile b/drivers/staging/wlags49_h25/Makefile index 6e0159d0a3407..513ba01c2d59a 100644 --- a/drivers/staging/wlags49_h25/Makefile +++ b/drivers/staging/wlags49_h25/Makefile @@ -50,6 +50,3 @@ $(WLNAME)-y += wl_profile.o \ mmd.o \ hcf.o \ dhf.o - -$(WLNAME)-$(CONFIG_SYSFS) += wl_sysfs.o - diff --git a/drivers/staging/wlags49_h25/wl_sysfs.c b/drivers/staging/wlags49_h25/wl_sysfs.c deleted file mode 100644 index 6458ee63350d7..0000000000000 --- a/drivers/staging/wlags49_h25/wl_sysfs.c +++ /dev/null @@ -1,2 +0,0 @@ -/* Use common source from wlags49_h2 */ -#include "../wlags49_h2/wl_sysfs.c" diff --git a/drivers/staging/wlags49_h25/wl_sysfs.h b/drivers/staging/wlags49_h25/wl_sysfs.h deleted file mode 100644 index eb819a5ef8b53..0000000000000 --- a/drivers/staging/wlags49_h25/wl_sysfs.h +++ /dev/null @@ -1,2 +0,0 @@ -/* Use common source from wlags49_h2 */ -#include "../wlags49_h2/wl_sysfs.h" -- GitLab From 9d3ab801740ab5ff1e22932fdfecdaacd0d64a18 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sat, 24 Aug 2013 10:27:29 -0700 Subject: [PATCH 817/942] staging: android: timed_output: fix sysfs file creation race The sysfs file for the driver was being created _after_ the device was announced to userspace, causing a race with any tools looking for sysfs files. Fix the race by using the default attribute group for the class. Cc: Kees Cook Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/timed_output.c | 27 ++++++++++---------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/drivers/staging/android/timed_output.c b/drivers/staging/android/timed_output.c index ee3a57f22832b..2c617834dc46c 100644 --- a/drivers/staging/android/timed_output.c +++ b/drivers/staging/android/timed_output.c @@ -28,7 +28,7 @@ static struct class *timed_output_class; static atomic_t device_count; static ssize_t enable_show(struct device *dev, struct device_attribute *attr, - char *buf) + char *buf) { struct timed_output_dev *tdev = dev_get_drvdata(dev); int remaining = tdev->get_time(tdev); @@ -36,9 +36,8 @@ static ssize_t enable_show(struct device *dev, struct device_attribute *attr, return sprintf(buf, "%d\n", remaining); } -static ssize_t enable_store( - struct device *dev, struct device_attribute *attr, - const char *buf, size_t size) +static ssize_t enable_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t size) { struct timed_output_dev *tdev = dev_get_drvdata(dev); int value; @@ -50,8 +49,13 @@ static ssize_t enable_store( return size; } +static DEVICE_ATTR_RW(enable); -static DEVICE_ATTR(enable, S_IRUGO | S_IWUSR, enable_show, enable_store); +static struct attribute *timed_output_attrs[] = { + &dev_attr_enable.attr, + NULL, +}; +ATTRIBUTE_GROUPS(timed_output); static int create_timed_output_class(void) { @@ -60,6 +64,7 @@ static int create_timed_output_class(void) if (IS_ERR(timed_output_class)) return PTR_ERR(timed_output_class); atomic_set(&device_count, 0); + timed_output_class->dev_groups = timed_output_groups; } return 0; @@ -82,27 +87,15 @@ int timed_output_dev_register(struct timed_output_dev *tdev) if (IS_ERR(tdev->dev)) return PTR_ERR(tdev->dev); - ret = device_create_file(tdev->dev, &dev_attr_enable); - if (ret < 0) - goto err_create_file; - dev_set_drvdata(tdev->dev, tdev); tdev->state = 0; return 0; - -err_create_file: - device_destroy(timed_output_class, MKDEV(0, tdev->index)); - pr_err("failed to register driver %s\n", - tdev->name); - - return ret; } EXPORT_SYMBOL_GPL(timed_output_dev_register); void timed_output_dev_unregister(struct timed_output_dev *tdev) { tdev->enable(tdev, 0); - device_remove_file(tdev->dev, &dev_attr_enable); device_destroy(timed_output_class, MKDEV(0, tdev->index)); dev_set_drvdata(tdev->dev, NULL); } -- GitLab From 89dcefb5af9651a4496ed53949ee0e287714f28b Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sat, 24 Aug 2013 10:30:28 -0700 Subject: [PATCH 818/942] staging: frontier: use better DEVICE_ATTR_ macros MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use the DEVICE_ATTR_RO/RW macros to better describe the permissions on the file, and make them easier to audit. Cc: David Täht Cc: Sara Bird Cc: Masanari Iida Signed-off-by: Greg Kroah-Hartman --- drivers/staging/frontier/tranzport.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/frontier/tranzport.c b/drivers/staging/frontier/tranzport.c index 6cbf9c7c1d386..074b0e5bcc68c 100644 --- a/drivers/staging/frontier/tranzport.c +++ b/drivers/staging/frontier/tranzport.c @@ -177,24 +177,24 @@ static void usb_tranzport_abort_transfers(struct usb_tranzport *dev) } #define show_int(value) \ - static ssize_t show_##value(struct device *dev, \ + static ssize_t value##_show(struct device *dev, \ struct device_attribute *attr, char *buf) \ { \ struct usb_interface *intf = to_usb_interface(dev); \ struct usb_tranzport *t = usb_get_intfdata(intf); \ return sprintf(buf, "%d\n", t->value); \ } \ - static DEVICE_ATTR(value, S_IRUGO, show_##value, NULL); + static DEVICE_ATTR_RO(value) #define show_set_int(value) \ - static ssize_t show_##value(struct device *dev, \ + static ssize_t value##_show(struct device *dev, \ struct device_attribute *attr, char *buf) \ { \ struct usb_interface *intf = to_usb_interface(dev); \ struct usb_tranzport *t = usb_get_intfdata(intf); \ return sprintf(buf, "%d\n", t->value); \ } \ - static ssize_t set_##value(struct device *dev, \ + static ssize_t value##_store(struct device *dev, \ struct device_attribute *attr, \ const char *buf, size_t count) \ { \ @@ -206,7 +206,7 @@ static void usb_tranzport_abort_transfers(struct usb_tranzport *dev) t->value = temp; \ return count; \ } \ - static DEVICE_ATTR(value, S_IWUSR | S_IRUGO, show_##value, set_##value); + static DEVICE_ATTR_RW(value) show_int(enable); show_int(offline); -- GitLab From 00009615c3fbd49d38771ad07cc9c9d96e05e9cb Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sat, 24 Aug 2013 10:33:07 -0700 Subject: [PATCH 819/942] staging: keucr: be explicit to the sysfs file permissions Use the DEVICE_ATTR_RW() macro to be clearer as to the permissions for the sysfs file, making it easier to audit the code. Cc: Al Cho Signed-off-by: Greg Kroah-Hartman --- drivers/staging/keucr/scsiglue.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/staging/keucr/scsiglue.c b/drivers/staging/keucr/scsiglue.c index afb00d84679df..ac3d34dcc4382 100644 --- a/drivers/staging/keucr/scsiglue.c +++ b/drivers/staging/keucr/scsiglue.c @@ -289,10 +289,7 @@ US_DO_ALL_FLAGS ***********************************************************************/ /* Output routine for the sysfs max_sectors file */ -/* - * show_max_sectors() - */ -static ssize_t show_max_sectors(struct device *dev, +static ssize_t max_sectors_show(struct device *dev, struct device_attribute *attr, char *buf) { struct scsi_device *sdev = to_scsi_device(dev); @@ -302,10 +299,7 @@ static ssize_t show_max_sectors(struct device *dev, } /* Input routine for the sysfs max_sectors file */ -/* - * store_max_sectors() - */ -static ssize_t store_max_sectors(struct device *dev, +static ssize_t max_sectors_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { @@ -319,9 +313,8 @@ static ssize_t store_max_sectors(struct device *dev, } return -EINVAL; } +static DEVICE_ATTR_RW(max_sectors); -static DEVICE_ATTR(max_sectors, S_IRUGO | S_IWUSR, show_max_sectors, - store_max_sectors); static struct device_attribute *sysfs_device_attr_list[] = { &dev_attr_max_sectors, NULL, }; -- GitLab From 3b7cf04f873d3317bdfeedb6c83396abd16f0955 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sat, 24 Aug 2013 10:34:53 -0700 Subject: [PATCH 820/942] staging: quickstart: fix up sysfs file permissions Use the default DEVICE_ATTR_RO/RW macros to specify the file permissions better, and make them easier to audit. And did we really want any user to be able to write to this file, I kind of doubt it... Cc: Jiang Liu Cc: Toshi Kani Signed-off-by: Greg Kroah-Hartman --- drivers/staging/quickstart/quickstart.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/drivers/staging/quickstart/quickstart.c b/drivers/staging/quickstart/quickstart.c index adb8da564cf63..4247d60c91861 100644 --- a/drivers/staging/quickstart/quickstart.c +++ b/drivers/staging/quickstart/quickstart.c @@ -71,9 +71,8 @@ static struct quickstart_button *pressed; static struct input_dev *quickstart_input; /* Platform driver functions */ -static ssize_t quickstart_buttons_show(struct device *dev, - struct device_attribute *attr, - char *buf) +static ssize_t buttons_show(struct device *dev, struct device_attribute *attr, + char *buf) { int count = 0; struct quickstart_button *b; @@ -94,18 +93,17 @@ static ssize_t quickstart_buttons_show(struct device *dev, return count; } -static ssize_t quickstart_pressed_button_show(struct device *dev, - struct device_attribute *attr, - char *buf) +static ssize_t pressed_button_show(struct device *dev, + struct device_attribute *attr, char *buf) { return scnprintf(buf, PAGE_SIZE, "%s\n", (pressed ? pressed->name : "none")); } -static ssize_t quickstart_pressed_button_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t pressed_button_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) { if (count < 2) return -EINVAL; @@ -319,9 +317,8 @@ static int quickstart_acpi_remove(struct acpi_device *device) } /* Platform driver structs */ -static DEVICE_ATTR(pressed_button, 0666, quickstart_pressed_button_show, - quickstart_pressed_button_store); -static DEVICE_ATTR(buttons, 0444, quickstart_buttons_show, NULL); +static DEVICE_ATTR_RW(pressed_button); +static DEVICE_ATTR_RO(buttons); static struct platform_device *pf_device; static struct platform_driver pf_driver = { .driver = { -- GitLab From e7c8a7e350e22bf60d94d5e9361cee29058684c1 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sat, 24 Aug 2013 10:36:49 -0700 Subject: [PATCH 821/942] staging: line6: use default sysfs attribute macros Move to use the DEVICE_ATTR_RW/RO macros, making it easier to audit the sysfs file permissions, and get rid of the "empty" callback for read-only files, saving lines of code. Cc: Stefan Hajnoczi Cc: Laurent Navet Cc: Johannes Thumshirn Signed-off-by: Greg Kroah-Hartman --- drivers/staging/line6/driver.c | 9 --------- drivers/staging/line6/driver.h | 3 --- drivers/staging/line6/pcm.c | 27 ++++++++++++--------------- drivers/staging/line6/pod.c | 21 +++++++++------------ 4 files changed, 21 insertions(+), 39 deletions(-) diff --git a/drivers/staging/line6/driver.c b/drivers/staging/line6/driver.c index 6252aca828662..471c10c116ec8 100644 --- a/drivers/staging/line6/driver.c +++ b/drivers/staging/line6/driver.c @@ -567,15 +567,6 @@ ssize_t line6_nop_read(struct device *dev, struct device_attribute *attr, return 0; } -/* - No operation (i.e., unsupported). -*/ -ssize_t line6_nop_write(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) -{ - return count; -} - /* Generic destructor. */ diff --git a/drivers/staging/line6/driver.h b/drivers/staging/line6/driver.h index a8341f9fdb981..34ae95e7e5128 100644 --- a/drivers/staging/line6/driver.h +++ b/drivers/staging/line6/driver.h @@ -190,9 +190,6 @@ extern char *line6_alloc_sysex_buffer(struct usb_line6 *line6, int code1, int code2, int size); extern ssize_t line6_nop_read(struct device *dev, struct device_attribute *attr, char *buf); -extern ssize_t line6_nop_write(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count); extern int line6_read_data(struct usb_line6 *line6, int address, void *data, size_t datalen); extern int line6_read_serial_number(struct usb_line6 *line6, diff --git a/drivers/staging/line6/pcm.c b/drivers/staging/line6/pcm.c index 0dd08ef51398c..6a0648cd03a70 100644 --- a/drivers/staging/line6/pcm.c +++ b/drivers/staging/line6/pcm.c @@ -34,8 +34,8 @@ static struct snd_line6_pcm *dev2pcm(struct device *dev) /* "read" request on "impulse_volume" special file. */ -static ssize_t pcm_get_impulse_volume(struct device *dev, - struct device_attribute *attr, char *buf) +static ssize_t impulse_volume_show(struct device *dev, + struct device_attribute *attr, char *buf) { return sprintf(buf, "%d\n", dev2pcm(dev)->impulse_volume); } @@ -43,9 +43,9 @@ static ssize_t pcm_get_impulse_volume(struct device *dev, /* "write" request on "impulse_volume" special file. */ -static ssize_t pcm_set_impulse_volume(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t impulse_volume_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) { struct snd_line6_pcm *line6pcm = dev2pcm(dev); int value; @@ -64,12 +64,13 @@ static ssize_t pcm_set_impulse_volume(struct device *dev, return count; } +static DEVICE_ATTR_RW(impulse_volume); /* "read" request on "impulse_period" special file. */ -static ssize_t pcm_get_impulse_period(struct device *dev, - struct device_attribute *attr, char *buf) +static ssize_t impulse_period_show(struct device *dev, + struct device_attribute *attr, char *buf) { return sprintf(buf, "%d\n", dev2pcm(dev)->impulse_period); } @@ -77,9 +78,9 @@ static ssize_t pcm_get_impulse_period(struct device *dev, /* "write" request on "impulse_period" special file. */ -static ssize_t pcm_set_impulse_period(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t impulse_period_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) { int value; int ret; @@ -91,11 +92,7 @@ static ssize_t pcm_set_impulse_period(struct device *dev, dev2pcm(dev)->impulse_period = value; return count; } - -static DEVICE_ATTR(impulse_volume, S_IWUSR | S_IRUGO, pcm_get_impulse_volume, - pcm_set_impulse_volume); -static DEVICE_ATTR(impulse_period, S_IWUSR | S_IRUGO, pcm_get_impulse_period, - pcm_set_impulse_period); +static DEVICE_ATTR_RW(impulse_period); #endif diff --git a/drivers/staging/line6/pod.c b/drivers/staging/line6/pod.c index 699b217250622..f4e95a614e3fd 100644 --- a/drivers/staging/line6/pod.c +++ b/drivers/staging/line6/pod.c @@ -192,8 +192,8 @@ static int pod_set_system_param_int(struct usb_line6_pod *pod, int value, /* "read" request on "serial_number" special file. */ -static ssize_t pod_get_serial_number(struct device *dev, - struct device_attribute *attr, char *buf) +static ssize_t serial_number_show(struct device *dev, + struct device_attribute *attr, char *buf) { struct usb_interface *interface = to_usb_interface(dev); struct usb_line6_pod *pod = usb_get_intfdata(interface); @@ -203,9 +203,8 @@ static ssize_t pod_get_serial_number(struct device *dev, /* "read" request on "firmware_version" special file. */ -static ssize_t pod_get_firmware_version(struct device *dev, - struct device_attribute *attr, - char *buf) +static ssize_t firmware_version_show(struct device *dev, + struct device_attribute *attr, char *buf) { struct usb_interface *interface = to_usb_interface(dev); struct usb_line6_pod *pod = usb_get_intfdata(interface); @@ -216,8 +215,8 @@ static ssize_t pod_get_firmware_version(struct device *dev, /* "read" request on "device_id" special file. */ -static ssize_t pod_get_device_id(struct device *dev, - struct device_attribute *attr, char *buf) +static ssize_t device_id_show(struct device *dev, + struct device_attribute *attr, char *buf) { struct usb_interface *interface = to_usb_interface(dev); struct usb_line6_pod *pod = usb_get_intfdata(interface); @@ -274,11 +273,9 @@ static void pod_startup4(struct work_struct *work) } /* POD special files: */ -static DEVICE_ATTR(device_id, S_IRUGO, pod_get_device_id, line6_nop_write); -static DEVICE_ATTR(firmware_version, S_IRUGO, pod_get_firmware_version, - line6_nop_write); -static DEVICE_ATTR(serial_number, S_IRUGO, pod_get_serial_number, - line6_nop_write); +static DEVICE_ATTR_RO(device_id); +static DEVICE_ATTR_RO(firmware_version); +static DEVICE_ATTR_RO(serial_number); /* control info callback */ static int snd_pod_control_monitor_info(struct snd_kcontrol *kcontrol, -- GitLab From 57f1d4d39e8a284188912417a1de5ecf6469a002 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Sun, 25 Aug 2013 11:49:37 -0500 Subject: [PATCH 822/942] staging: gdm724x: Remove tests of KERNELVERSION Kernel code need not test for KERNELVERSION. Besides being unnecessary for an in-kernel driver, these lines will cause a build failure for any source tree with a stale include/linux/version.h. This patch is only compile tested. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm724x/netlink_k.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/drivers/staging/gdm724x/netlink_k.c b/drivers/staging/gdm724x/netlink_k.c index 90004a7a16c2e..9e8be6a48261d 100644 --- a/drivers/staging/gdm724x/netlink_k.c +++ b/drivers/staging/gdm724x/netlink_k.c @@ -91,24 +91,15 @@ struct sock *netlink_init(int unit, void (*cb)(struct net_device *dev, u16 type, void *msg, int len)) { struct sock *sock; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0) struct netlink_kernel_cfg cfg = { .input = netlink_rcv, }; -#endif #if !defined(DEFINE_MUTEX) init_MUTEX(&netlink_mutex); #endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0) - sock = netlink_kernel_create(&init_net, unit, 0, netlink_rcv, NULL, - THIS_MODULE); -#elif LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0) - sock = netlink_kernel_create(&init_net, unit, THIS_MODULE, &cfg); -#else sock = netlink_kernel_create(&init_net, unit, &cfg); -#endif if (sock) rcv_cb = cb; @@ -142,11 +133,7 @@ int netlink_send(struct sock *sock, int group, u16 type, void *msg, int len) nlh = nlmsg_put(skb, 0, seq, type, len, 0); memcpy(NLMSG_DATA(nlh), msg, len); -#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0) - NETLINK_CB(skb).pid = 0; -#else NETLINK_CB(skb).portid = 0; -#endif NETLINK_CB(skb).dst_group = 0; ret = netlink_broadcast(sock, skb, 0, group+1, GFP_ATOMIC); -- GitLab From d33b128ea9076b32804af62dda433bc71512c01f Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Sun, 25 Aug 2013 11:55:15 -0500 Subject: [PATCH 823/942] staging: r8188eu: Fix build errors for allyesconfig This driver has some global names that are the same as found in driver r8712. Fix the allyesconfig build errors by changing the names of those routines. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_led.c | 2 +- drivers/staging/rtl8188eu/core/rtw_mp_ioctl.c | 270 +++++++++--------- drivers/staging/rtl8188eu/hal/rtl8188eu_led.c | 2 +- drivers/staging/rtl8188eu/include/rtw_led.h | 2 +- .../staging/rtl8188eu/include/rtw_mp_ioctl.h | 212 +++++++------- .../staging/rtl8188eu/os_dep/ioctl_linux.c | 66 ++--- 6 files changed, 277 insertions(+), 277 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_led.c b/drivers/staging/rtl8188eu/core/rtw_led.c index 2db23806a9ba8..afac537098436 100644 --- a/drivers/staging/rtl8188eu/core/rtw_led.c +++ b/drivers/staging/rtl8188eu/core/rtw_led.c @@ -1641,7 +1641,7 @@ void BlinkHandler(struct LED_871x *pLed) } } -void LedControl871x(struct adapter *padapter, enum LED_CTL_MODE LedAction) +void LedControl8188eu(struct adapter *padapter, enum LED_CTL_MODE LedAction) { struct led_priv *ledpriv = &(padapter->ledpriv); diff --git a/drivers/staging/rtl8188eu/core/rtw_mp_ioctl.c b/drivers/staging/rtl8188eu/core/rtw_mp_ioctl.c index 12fecdec40168..f06312c415817 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mp_ioctl.c +++ b/drivers/staging/rtl8188eu/core/rtw_mp_ioctl.c @@ -27,8 +27,8 @@ #include -/* oid_rtl_seg_81_85 section start **************** */ -int oid_rt_wireless_mode_hdl(struct oid_par_priv *poid_par_priv) +/* rtl8188eu_oid_rtl_seg_81_85 section start **************** */ +int rtl8188eu_oid_rt_wireless_mode_hdl(struct oid_par_priv *poid_par_priv) { int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); @@ -52,8 +52,8 @@ _func_exit_; return status; } -/* oid_rtl_seg_81_87_80 section start **************** */ -int oid_rt_pro_write_bb_reg_hdl(struct oid_par_priv *poid_par_priv) +/* rtl8188eu_oid_rtl_seg_81_87_80 section start **************** */ +int rtl8188eu_oid_rt_pro_write_bb_reg_hdl(struct oid_par_priv *poid_par_priv) { struct bb_reg_param *pbbreg; u16 offset; @@ -63,7 +63,7 @@ int oid_rt_pro_write_bb_reg_hdl(struct oid_par_priv *poid_par_priv) _func_enter_; - RT_TRACE(_module_mp_, _drv_notice_, ("+oid_rt_pro_write_bb_reg_hdl\n")); + RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_write_bb_reg_hdl\n")); if (poid_par_priv->type_of_oid != SET_OID) return NDIS_STATUS_NOT_ACCEPTED; @@ -80,7 +80,7 @@ _func_enter_; value = pbbreg->value; RT_TRACE(_module_mp_, _drv_notice_, - ("oid_rt_pro_write_bb_reg_hdl: offset=0x%03X value=0x%08X\n", + ("rtl8188eu_oid_rt_pro_write_bb_reg_hdl: offset=0x%03X value=0x%08X\n", offset, value)); _irqlevel_changed_(&oldirql, LOWER); @@ -92,7 +92,7 @@ _func_exit_; return status; } /* */ -int oid_rt_pro_read_bb_reg_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_read_bb_reg_hdl(struct oid_par_priv *poid_par_priv) { struct bb_reg_param *pbbreg; u16 offset; @@ -102,7 +102,7 @@ int oid_rt_pro_read_bb_reg_hdl(struct oid_par_priv *poid_par_priv) _func_enter_; - RT_TRACE(_module_mp_, _drv_notice_, ("+oid_rt_pro_read_bb_reg_hdl\n")); + RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_read_bb_reg_hdl\n")); if (poid_par_priv->type_of_oid != QUERY_OID) return NDIS_STATUS_NOT_ACCEPTED; @@ -124,14 +124,14 @@ _func_enter_; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; RT_TRACE(_module_mp_, _drv_notice_, - ("-oid_rt_pro_read_bb_reg_hdl: offset=0x%03X value:0x%08X\n", + ("-rtl8188eu_oid_rt_pro_read_bb_reg_hdl: offset=0x%03X value:0x%08X\n", offset, value)); _func_exit_; return status; } /* */ -int oid_rt_pro_write_rf_reg_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_write_rf_reg_hdl(struct oid_par_priv *poid_par_priv) { struct rf_reg_param *pbbreg; u8 path; @@ -142,7 +142,7 @@ int oid_rt_pro_write_rf_reg_hdl(struct oid_par_priv *poid_par_priv) _func_enter_; - RT_TRACE(_module_mp_, _drv_notice_, ("+oid_rt_pro_write_rf_reg_hdl\n")); + RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_write_rf_reg_hdl\n")); if (poid_par_priv->type_of_oid != SET_OID) return NDIS_STATUS_NOT_ACCEPTED; @@ -164,7 +164,7 @@ _func_enter_; value = pbbreg->value; RT_TRACE(_module_mp_, _drv_notice_, - ("oid_rt_pro_write_rf_reg_hdl: path=%d offset=0x%02X value=0x%05X\n", + ("rtl8188eu_oid_rt_pro_write_rf_reg_hdl: path=%d offset=0x%02X value=0x%05X\n", path, offset, value)); _irqlevel_changed_(&oldirql, LOWER); @@ -176,7 +176,7 @@ _func_exit_; return status; } /* */ -int oid_rt_pro_read_rf_reg_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_read_rf_reg_hdl(struct oid_par_priv *poid_par_priv) { struct rf_reg_param *pbbreg; u8 path; @@ -187,7 +187,7 @@ int oid_rt_pro_read_rf_reg_hdl(struct oid_par_priv *poid_par_priv) _func_enter_; - RT_TRACE(_module_mp_, _drv_notice_, ("+oid_rt_pro_read_rf_reg_hdl\n")); + RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_read_rf_reg_hdl\n")); if (poid_par_priv->type_of_oid != QUERY_OID) return NDIS_STATUS_NOT_ACCEPTED; @@ -214,19 +214,19 @@ _func_enter_; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; RT_TRACE(_module_mp_, _drv_notice_, - ("-oid_rt_pro_read_rf_reg_hdl: path=%d offset=0x%02X value=0x%05X\n", + ("-rtl8188eu_oid_rt_pro_read_rf_reg_hdl: path=%d offset=0x%02X value=0x%05X\n", path, offset, value)); _func_exit_; return status; } -/* oid_rtl_seg_81_87_00 section end**************** */ +/* rtl8188eu_oid_rtl_seg_81_87_00 section end**************** */ /* */ -/* oid_rtl_seg_81_80_00 section start **************** */ +/* rtl8188eu_oid_rtl_seg_81_80_00 section start **************** */ /* */ -int oid_rt_pro_set_data_rate_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_set_data_rate_hdl(struct oid_par_priv *poid_par_priv) { u32 ratevalue;/* 4 */ int status = NDIS_STATUS_SUCCESS; @@ -235,7 +235,7 @@ int oid_rt_pro_set_data_rate_hdl(struct oid_par_priv *poid_par_priv) _func_enter_; RT_TRACE(_module_mp_, _drv_notice_, - ("+oid_rt_pro_set_data_rate_hdl\n")); + ("+rtl8188eu_oid_rt_pro_set_data_rate_hdl\n")); if (poid_par_priv->type_of_oid != SET_OID) return NDIS_STATUS_NOT_ACCEPTED; @@ -245,7 +245,7 @@ _func_enter_; ratevalue = *((u32 *)poid_par_priv->information_buf);/* 4 */ RT_TRACE(_module_mp_, _drv_notice_, - ("oid_rt_pro_set_data_rate_hdl: data rate idx=%d\n", ratevalue)); + ("rtl8188eu_oid_rt_pro_set_data_rate_hdl: data rate idx=%d\n", ratevalue)); if (ratevalue >= MPT_RATE_LAST) return NDIS_STATUS_INVALID_DATA; @@ -260,7 +260,7 @@ _func_exit_; return status; } /* */ -int oid_rt_pro_start_test_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_start_test_hdl(struct oid_par_priv *poid_par_priv) { u32 mode; int status = NDIS_STATUS_SUCCESS; @@ -268,7 +268,7 @@ int oid_rt_pro_start_test_hdl(struct oid_par_priv *poid_par_priv) _func_enter_; - RT_TRACE(_module_mp_, _drv_notice_, ("+oid_rt_pro_start_test_hdl\n")); + RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_start_test_hdl\n")); if (Adapter->registrypriv.mp_mode == 0) return NDIS_STATUS_NOT_ACCEPTED; @@ -291,14 +291,14 @@ _func_enter_; exit: _irqlevel_changed_(&oldirql, RAISE); - RT_TRACE(_module_mp_, _drv_notice_, ("-oid_rt_pro_start_test_hdl: mp_mode=%d\n", Adapter->mppriv.mode)); + RT_TRACE(_module_mp_, _drv_notice_, ("-rtl8188eu_oid_rt_pro_start_test_hdl: mp_mode=%d\n", Adapter->mppriv.mode)); _func_exit_; return status; } /* */ -int oid_rt_pro_stop_test_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_stop_test_hdl(struct oid_par_priv *poid_par_priv) { int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); @@ -321,7 +321,7 @@ _func_exit_; return status; } /* */ -int oid_rt_pro_set_channel_direct_call_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_set_channel_direct_call_hdl(struct oid_par_priv *poid_par_priv) { u32 Channel; int status = NDIS_STATUS_SUCCESS; @@ -329,7 +329,7 @@ int oid_rt_pro_set_channel_direct_call_hdl(struct oid_par_priv *poid_par_priv) _func_enter_; - RT_TRACE(_module_mp_, _drv_notice_, ("+oid_rt_pro_set_channel_direct_call_hdl\n")); + RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_set_channel_direct_call_hdl\n")); if (poid_par_priv->information_buf_len != sizeof(u32)) return NDIS_STATUS_INVALID_LENGTH; @@ -343,7 +343,7 @@ _func_enter_; return NDIS_STATUS_NOT_ACCEPTED; Channel = *((u32 *)poid_par_priv->information_buf); - RT_TRACE(_module_mp_, _drv_notice_, ("oid_rt_pro_set_channel_direct_call_hdl: Channel=%d\n", Channel)); + RT_TRACE(_module_mp_, _drv_notice_, ("rtl8188eu_oid_rt_pro_set_channel_direct_call_hdl: Channel=%d\n", Channel)); if (Channel > 14) return NDIS_STATUS_NOT_ACCEPTED; Adapter->mppriv.channel = Channel; @@ -357,7 +357,7 @@ _func_exit_; return status; } /* */ -int oid_rt_set_bandwidth_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_set_bandwidth_hdl(struct oid_par_priv *poid_par_priv) { u16 bandwidth; u16 channel_offset; @@ -367,7 +367,7 @@ int oid_rt_set_bandwidth_hdl(struct oid_par_priv *poid_par_priv) _func_enter_; RT_TRACE(_module_mp_, _drv_info_, - ("+oid_rt_set_bandwidth_hdl\n")); + ("+rtl8188eu_oid_rt_set_bandwidth_hdl\n")); if (poid_par_priv->type_of_oid != SET_OID) return NDIS_STATUS_NOT_ACCEPTED; @@ -388,7 +388,7 @@ _func_enter_; _irqlevel_changed_(&oldirql, RAISE); RT_TRACE(_module_mp_, _drv_notice_, - ("-oid_rt_set_bandwidth_hdl: bandwidth=%d channel_offset=%d\n", + ("-rtl8188eu_oid_rt_set_bandwidth_hdl: bandwidth=%d channel_offset=%d\n", bandwidth, channel_offset)); _func_exit_; @@ -396,7 +396,7 @@ _func_exit_; return status; } /* */ -int oid_rt_pro_set_antenna_bb_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_set_antenna_bb_hdl(struct oid_par_priv *poid_par_priv) { u32 antenna; int status = NDIS_STATUS_SUCCESS; @@ -404,7 +404,7 @@ int oid_rt_pro_set_antenna_bb_hdl(struct oid_par_priv *poid_par_priv) _func_enter_; - RT_TRACE(_module_mp_, _drv_notice_, ("+oid_rt_pro_set_antenna_bb_hdl\n")); + RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_set_antenna_bb_hdl\n")); if (poid_par_priv->information_buf_len != sizeof(u32)) return NDIS_STATUS_INVALID_LENGTH; @@ -415,7 +415,7 @@ _func_enter_; Adapter->mppriv.antenna_tx = (u16)((antenna & 0xFFFF0000) >> 16); Adapter->mppriv.antenna_rx = (u16)(antenna & 0x0000FFFF); RT_TRACE(_module_mp_, _drv_notice_, - ("oid_rt_pro_set_antenna_bb_hdl: tx_ant=0x%04x rx_ant=0x%04x\n", + ("rtl8188eu_oid_rt_pro_set_antenna_bb_hdl: tx_ant=0x%04x rx_ant=0x%04x\n", Adapter->mppriv.antenna_tx, Adapter->mppriv.antenna_rx)); _irqlevel_changed_(&oldirql, LOWER); @@ -431,7 +431,7 @@ _func_exit_; return status; } -int oid_rt_pro_set_tx_power_control_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_set_tx_power_control_hdl(struct oid_par_priv *poid_par_priv) { u32 tx_pwr_idx; int status = NDIS_STATUS_SUCCESS; @@ -439,7 +439,7 @@ int oid_rt_pro_set_tx_power_control_hdl(struct oid_par_priv *poid_par_priv) _func_enter_; - RT_TRACE(_module_mp_, _drv_info_, ("+oid_rt_pro_set_tx_power_control_hdl\n")); + RT_TRACE(_module_mp_, _drv_info_, ("+rtl8188eu_oid_rt_pro_set_tx_power_control_hdl\n")); if (poid_par_priv->type_of_oid != SET_OID) return NDIS_STATUS_NOT_ACCEPTED; @@ -454,7 +454,7 @@ _func_enter_; Adapter->mppriv.txpoweridx = (u8)tx_pwr_idx; RT_TRACE(_module_mp_, _drv_notice_, - ("oid_rt_pro_set_tx_power_control_hdl: idx=0x%2x\n", + ("rtl8188eu_oid_rt_pro_set_tx_power_control_hdl: idx=0x%2x\n", Adapter->mppriv.txpoweridx)); _irqlevel_changed_(&oldirql, LOWER); @@ -467,9 +467,9 @@ _func_exit_; } /* */ -/* oid_rtl_seg_81_80_20 section start **************** */ +/* rtl8188eu_oid_rtl_seg_81_80_20 section start **************** */ /* */ -int oid_rt_pro_query_tx_packet_sent_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_query_tx_packet_sent_hdl(struct oid_par_priv *poid_par_priv) { int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); @@ -493,7 +493,7 @@ _func_exit_; return status; } /* */ -int oid_rt_pro_query_rx_packet_received_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_query_rx_packet_received_hdl(struct oid_par_priv *poid_par_priv) { int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); @@ -504,7 +504,7 @@ _func_enter_; status = NDIS_STATUS_NOT_ACCEPTED; return status; } - RT_TRACE(_module_mp_, _drv_alert_, ("===> oid_rt_pro_query_rx_packet_received_hdl.\n")); + RT_TRACE(_module_mp_, _drv_alert_, ("===> rtl8188eu_oid_rt_pro_query_rx_packet_received_hdl.\n")); if (poid_par_priv->information_buf_len == sizeof(u32)) { *(u32 *)poid_par_priv->information_buf = Adapter->mppriv.rx_pktcount; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; @@ -518,7 +518,7 @@ _func_exit_; return status; } /* */ -int oid_rt_pro_query_rx_packet_crc32_error_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_query_rx_packet_crc32_error_hdl(struct oid_par_priv *poid_par_priv) { int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); @@ -529,7 +529,7 @@ _func_enter_; status = NDIS_STATUS_NOT_ACCEPTED; return status; } - RT_TRACE(_module_mp_, _drv_alert_, ("===> oid_rt_pro_query_rx_packet_crc32_error_hdl.\n")); + RT_TRACE(_module_mp_, _drv_alert_, ("===> rtl8188eu_oid_rt_pro_query_rx_packet_crc32_error_hdl.\n")); if (poid_par_priv->information_buf_len == sizeof(u32)) { *(u32 *)poid_par_priv->information_buf = Adapter->mppriv.rx_crcerrpktcount; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; @@ -544,7 +544,7 @@ _func_exit_; } /* */ -int oid_rt_pro_reset_tx_packet_sent_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_reset_tx_packet_sent_hdl(struct oid_par_priv *poid_par_priv) { int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); @@ -556,7 +556,7 @@ _func_enter_; return status; } - RT_TRACE(_module_mp_, _drv_alert_, ("===> oid_rt_pro_reset_tx_packet_sent_hdl.\n")); + RT_TRACE(_module_mp_, _drv_alert_, ("===> rtl8188eu_oid_rt_pro_reset_tx_packet_sent_hdl.\n")); Adapter->mppriv.tx_pktcount = 0; _func_exit_; @@ -564,7 +564,7 @@ _func_exit_; return status; } /* */ -int oid_rt_pro_reset_rx_packet_received_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_reset_rx_packet_received_hdl(struct oid_par_priv *poid_par_priv) { int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); @@ -588,7 +588,7 @@ _func_exit_; return status; } /* */ -int oid_rt_reset_phy_rx_packet_count_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_reset_phy_rx_packet_count_hdl(struct oid_par_priv *poid_par_priv) { int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); @@ -609,14 +609,14 @@ _func_exit_; return status; } /* */ -int oid_rt_get_phy_rx_packet_received_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_get_phy_rx_packet_received_hdl(struct oid_par_priv *poid_par_priv) { int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); _func_enter_; - RT_TRACE(_module_mp_, _drv_info_, ("+oid_rt_get_phy_rx_packet_received_hdl\n")); + RT_TRACE(_module_mp_, _drv_info_, ("+rtl8188eu_oid_rt_get_phy_rx_packet_received_hdl\n")); if (poid_par_priv->type_of_oid != QUERY_OID) return NDIS_STATUS_NOT_ACCEPTED; @@ -630,21 +630,21 @@ _func_enter_; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - RT_TRACE(_module_mp_, _drv_notice_, ("-oid_rt_get_phy_rx_packet_received_hdl: recv_ok=%d\n", *(u32 *)poid_par_priv->information_buf)); + RT_TRACE(_module_mp_, _drv_notice_, ("-rtl8188eu_oid_rt_get_phy_rx_packet_received_hdl: recv_ok=%d\n", *(u32 *)poid_par_priv->information_buf)); _func_exit_; return status; } /* */ -int oid_rt_get_phy_rx_packet_crc32_error_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_get_phy_rx_packet_crc32_error_hdl(struct oid_par_priv *poid_par_priv) { int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); _func_enter_; - RT_TRACE(_module_mp_, _drv_info_, ("+oid_rt_get_phy_rx_packet_crc32_error_hdl\n")); + RT_TRACE(_module_mp_, _drv_info_, ("+rtl8188eu_oid_rt_get_phy_rx_packet_crc32_error_hdl\n")); if (poid_par_priv->type_of_oid != QUERY_OID) return NDIS_STATUS_NOT_ACCEPTED; @@ -660,15 +660,15 @@ _func_enter_; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; RT_TRACE(_module_mp_, _drv_info_, - ("-oid_rt_get_phy_rx_packet_crc32_error_hdl: recv_err =%d\n", + ("-rtl8188eu_oid_rt_get_phy_rx_packet_crc32_error_hdl: recv_err =%d\n", *(u32 *)poid_par_priv->information_buf)); _func_exit_; return status; } -/* oid_rtl_seg_81_80_20 section end **************** */ -int oid_rt_pro_set_continuous_tx_hdl(struct oid_par_priv *poid_par_priv) +/* rtl8188eu_oid_rtl_seg_81_80_20 section end **************** */ +int rtl8188eu_oid_rt_pro_set_continuous_tx_hdl(struct oid_par_priv *poid_par_priv) { u32 bStartTest; int status = NDIS_STATUS_SUCCESS; @@ -676,7 +676,7 @@ int oid_rt_pro_set_continuous_tx_hdl(struct oid_par_priv *poid_par_priv) _func_enter_; - RT_TRACE(_module_mp_, _drv_notice_, ("+oid_rt_pro_set_continuous_tx_hdl\n")); + RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_set_continuous_tx_hdl\n")); if (poid_par_priv->type_of_oid != SET_OID) return NDIS_STATUS_NOT_ACCEPTED; @@ -703,7 +703,7 @@ _func_exit_; return status; } -int oid_rt_pro_set_single_carrier_tx_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_set_single_carrier_tx_hdl(struct oid_par_priv *poid_par_priv) { u32 bStartTest; int status = NDIS_STATUS_SUCCESS; @@ -711,7 +711,7 @@ int oid_rt_pro_set_single_carrier_tx_hdl(struct oid_par_priv *poid_par_priv) _func_enter_; - RT_TRACE(_module_mp_, _drv_alert_, ("+oid_rt_pro_set_single_carrier_tx_hdl\n")); + RT_TRACE(_module_mp_, _drv_alert_, ("+rtl8188eu_oid_rt_pro_set_single_carrier_tx_hdl\n")); if (poid_par_priv->type_of_oid != SET_OID) return NDIS_STATUS_NOT_ACCEPTED; @@ -738,7 +738,7 @@ _func_exit_; return status; } -int oid_rt_pro_set_carrier_suppression_tx_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_set_carrier_suppression_tx_hdl(struct oid_par_priv *poid_par_priv) { u32 bStartTest; int status = NDIS_STATUS_SUCCESS; @@ -746,7 +746,7 @@ int oid_rt_pro_set_carrier_suppression_tx_hdl(struct oid_par_priv *poid_par_priv _func_enter_; - RT_TRACE(_module_mp_, _drv_notice_, ("+oid_rt_pro_set_carrier_suppression_tx_hdl\n")); + RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_set_carrier_suppression_tx_hdl\n")); if (poid_par_priv->type_of_oid != SET_OID) return NDIS_STATUS_NOT_ACCEPTED; @@ -773,7 +773,7 @@ _func_exit_; return status; } -int oid_rt_pro_set_single_tone_tx_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_set_single_tone_tx_hdl(struct oid_par_priv *poid_par_priv) { u32 bStartTest; int status = NDIS_STATUS_SUCCESS; @@ -781,7 +781,7 @@ int oid_rt_pro_set_single_tone_tx_hdl(struct oid_par_priv *poid_par_priv) _func_enter_; - RT_TRACE(_module_mp_, _drv_alert_, ("+oid_rt_pro_set_single_tone_tx_hdl\n")); + RT_TRACE(_module_mp_, _drv_alert_, ("+rtl8188eu_oid_rt_pro_set_single_tone_tx_hdl\n")); if (poid_par_priv->type_of_oid != SET_OID) return NDIS_STATUS_NOT_ACCEPTED; @@ -797,12 +797,12 @@ _func_exit_; return status; } -int oid_rt_pro_set_modulation_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_set_modulation_hdl(struct oid_par_priv *poid_par_priv) { return 0; } -int oid_rt_pro_trigger_gpio_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_trigger_gpio_hdl(struct oid_par_priv *poid_par_priv) { struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); int status = NDIS_STATUS_SUCCESS; @@ -819,14 +819,14 @@ _func_exit_; return status; } -/* oid_rtl_seg_81_80_00 section end **************** */ +/* rtl8188eu_oid_rtl_seg_81_80_00 section end **************** */ /* */ -int oid_rt_pro8711_join_bss_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro8711_join_bss_hdl(struct oid_par_priv *poid_par_priv) { return 0; } /* */ -int oid_rt_pro_read_register_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_read_register_hdl(struct oid_par_priv *poid_par_priv) { struct mp_rw_reg *RegRWStruct; u32 offset, width; @@ -836,7 +836,7 @@ int oid_rt_pro_read_register_hdl(struct oid_par_priv *poid_par_priv) _func_enter_; RT_TRACE(_module_mp_, _drv_info_, - ("+oid_rt_pro_read_register_hdl\n")); + ("+rtl8188eu_oid_rt_pro_read_register_hdl\n")); if (poid_par_priv->type_of_oid != QUERY_OID) return NDIS_STATUS_NOT_ACCEPTED; @@ -863,7 +863,7 @@ _func_enter_; break; } RT_TRACE(_module_mp_, _drv_notice_, - ("oid_rt_pro_read_register_hdl: offset:0x%04X value:0x%X\n", + ("rtl8188eu_oid_rt_pro_read_register_hdl: offset:0x%04X value:0x%X\n", offset, RegRWStruct->value)); _irqlevel_changed_(&oldirql, RAISE); @@ -875,7 +875,7 @@ _func_exit_; return status; } /* */ -int oid_rt_pro_write_register_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_write_register_hdl(struct oid_par_priv *poid_par_priv) { struct mp_rw_reg *RegRWStruct; u32 offset, width, value; @@ -885,7 +885,7 @@ int oid_rt_pro_write_register_hdl(struct oid_par_priv *poid_par_priv) _func_enter_; RT_TRACE(_module_mp_, _drv_info_, - ("+oid_rt_pro_write_register_hdl\n")); + ("+rtl8188eu_oid_rt_pro_write_register_hdl\n")); if (poid_par_priv->type_of_oid != SET_OID) return NDIS_STATUS_NOT_ACCEPTED; @@ -926,7 +926,7 @@ _func_enter_; _irqlevel_changed_(&oldirql, RAISE); RT_TRACE(_module_mp_, _drv_info_, - ("-oid_rt_pro_write_register_hdl: offset=0x%08X width=%d value=0x%X\n", + ("-rtl8188eu_oid_rt_pro_write_register_hdl: offset=0x%08X width=%d value=0x%X\n", offset, width, value)); _func_exit_; @@ -934,69 +934,69 @@ _func_exit_; return status; } /* */ -int oid_rt_pro_burst_read_register_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_burst_read_register_hdl(struct oid_par_priv *poid_par_priv) { return 0; } /* */ -int oid_rt_pro_burst_write_register_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_burst_write_register_hdl(struct oid_par_priv *poid_par_priv) { return 0; } /* */ -int oid_rt_pro_write_txcmd_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_write_txcmd_hdl(struct oid_par_priv *poid_par_priv) { return 0; } /* */ -int oid_rt_pro_read16_eeprom_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_read16_eeprom_hdl(struct oid_par_priv *poid_par_priv) { return 0; } /* */ -int oid_rt_pro_write16_eeprom_hdl (struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_write16_eeprom_hdl (struct oid_par_priv *poid_par_priv) { return 0; } /* */ -int oid_rt_pro8711_wi_poll_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro8711_wi_poll_hdl(struct oid_par_priv *poid_par_priv) { return 0; } /* */ -int oid_rt_pro8711_pkt_loss_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro8711_pkt_loss_hdl(struct oid_par_priv *poid_par_priv) { return 0; } /* */ -int oid_rt_rd_attrib_mem_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_rd_attrib_mem_hdl(struct oid_par_priv *poid_par_priv) { return 0; } /* */ -int oid_rt_wr_attrib_mem_hdl (struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_wr_attrib_mem_hdl (struct oid_par_priv *poid_par_priv) { return 0; } /* */ -int oid_rt_pro_set_rf_intfs_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_set_rf_intfs_hdl(struct oid_par_priv *poid_par_priv) { return 0; } /* */ -int oid_rt_poll_rx_status_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_poll_rx_status_hdl(struct oid_par_priv *poid_par_priv) { return 0; } /* */ -int oid_rt_pro_cfg_debug_message_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_cfg_debug_message_hdl(struct oid_par_priv *poid_par_priv) { return 0; } /* */ -int oid_rt_pro_set_data_rate_ex_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_set_data_rate_ex_hdl(struct oid_par_priv *poid_par_priv) { struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); @@ -1021,7 +1021,7 @@ _func_exit_; return status; } /* */ -int oid_rt_get_thermal_meter_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_get_thermal_meter_hdl(struct oid_par_priv *poid_par_priv) { int status = NDIS_STATUS_SUCCESS; u8 thermal = 0; @@ -1029,7 +1029,7 @@ int oid_rt_get_thermal_meter_hdl(struct oid_par_priv *poid_par_priv) _func_enter_; - RT_TRACE(_module_mp_, _drv_notice_, ("+oid_rt_get_thermal_meter_hdl\n")); + RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_get_thermal_meter_hdl\n")); if (poid_par_priv->type_of_oid != QUERY_OID) return NDIS_STATUS_NOT_ACCEPTED; @@ -1049,12 +1049,12 @@ _func_exit_; return status; } /* */ -int oid_rt_pro_read_tssi_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_read_tssi_hdl(struct oid_par_priv *poid_par_priv) { return 0; } /* */ -int oid_rt_pro_set_power_tracking_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_set_power_tracking_hdl(struct oid_par_priv *poid_par_priv) { int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); @@ -1071,7 +1071,7 @@ _func_enter_; enable = *(u8 *)poid_par_priv->information_buf; RT_TRACE(_module_mp_, _drv_notice_, - ("+oid_rt_pro_set_power_tracking_hdl: enable =%d\n", enable)); + ("+rtl8188eu_oid_rt_pro_set_power_tracking_hdl: enable =%d\n", enable)); SetPowerTracking(Adapter, enable); } else { @@ -1084,58 +1084,58 @@ _func_exit_; return status; } /* */ -int oid_rt_pro_set_basic_rate_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_set_basic_rate_hdl(struct oid_par_priv *poid_par_priv) { return 0; } /* */ -int oid_rt_pro_qry_pwrstate_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_qry_pwrstate_hdl(struct oid_par_priv *poid_par_priv) { return 0; } /* */ -int oid_rt_pro_set_pwrstate_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_set_pwrstate_hdl(struct oid_par_priv *poid_par_priv) { return 0; } /* */ -int oid_rt_pro_h2c_set_rate_table_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_h2c_set_rate_table_hdl(struct oid_par_priv *poid_par_priv) { return 0; } /* */ -int oid_rt_pro_h2c_get_rate_table_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_h2c_get_rate_table_hdl(struct oid_par_priv *poid_par_priv) { return 0; } -/* oid_rtl_seg_87_12_00 section start **************** */ -int oid_rt_pro_encryption_ctrl_hdl(struct oid_par_priv *poid_par_priv) +/* rtl8188eu_oid_rtl_seg_87_12_00 section start **************** */ +int rtl8188eu_oid_rt_pro_encryption_ctrl_hdl(struct oid_par_priv *poid_par_priv) { return 0; } -int oid_rt_pro_add_sta_info_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_add_sta_info_hdl(struct oid_par_priv *poid_par_priv) { return 0; } -int oid_rt_pro_dele_sta_info_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_dele_sta_info_hdl(struct oid_par_priv *poid_par_priv) { return 0; } -int oid_rt_pro_query_dr_variable_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_query_dr_variable_hdl(struct oid_par_priv *poid_par_priv) { return 0; } -int oid_rt_pro_rx_packet_type_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_rx_packet_type_hdl(struct oid_par_priv *poid_par_priv) { return NDIS_STATUS_SUCCESS; } /* */ -int oid_rt_pro_read_efuse_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_read_efuse_hdl(struct oid_par_priv *poid_par_priv) { struct efuse_access_struct *pefuse; u8 *data; @@ -1157,19 +1157,19 @@ _func_enter_; data = pefuse->data; RT_TRACE(_module_mp_, _drv_notice_, - ("+oid_rt_pro_read_efuse_hd: buf_len=%d addr=%d cnts=%d\n", + ("+rtl8188eu_oid_rt_pro_read_efuse_hd: buf_len=%d addr=%d cnts=%d\n", poid_par_priv->information_buf_len, addr, cnts)); EFUSE_GetEfuseDefinition(Adapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); if ((addr + cnts) > max_available_size) { - RT_TRACE(_module_mp_, _drv_err_, ("!oid_rt_pro_read_efuse_hdl: parameter error!\n")); + RT_TRACE(_module_mp_, _drv_err_, ("!rtl8188eu_oid_rt_pro_read_efuse_hdl: parameter error!\n")); return NDIS_STATUS_NOT_ACCEPTED; } _irqlevel_changed_(&oldirql, LOWER); if (rtw_efuse_access(Adapter, false, addr, cnts, data) == _FAIL) { - RT_TRACE(_module_mp_, _drv_err_, ("!oid_rt_pro_read_efuse_hdl: rtw_efuse_access FAIL!\n")); + RT_TRACE(_module_mp_, _drv_err_, ("!rtl8188eu_oid_rt_pro_read_efuse_hdl: rtw_efuse_access FAIL!\n")); status = NDIS_STATUS_FAILURE; } else { *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; @@ -1181,7 +1181,7 @@ _func_exit_; return status; } /* */ -int oid_rt_pro_write_efuse_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_write_efuse_hdl(struct oid_par_priv *poid_par_priv) { struct efuse_access_struct *pefuse; u8 *data; @@ -1201,13 +1201,13 @@ _func_enter_; data = pefuse->data; RT_TRACE(_module_mp_, _drv_notice_, - ("+oid_rt_pro_write_efuse_hdl: buf_len=%d addr=0x%04x cnts=%d\n", + ("+rtl8188eu_oid_rt_pro_write_efuse_hdl: buf_len=%d addr=0x%04x cnts=%d\n", poid_par_priv->information_buf_len, addr, cnts)); EFUSE_GetEfuseDefinition(Adapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); if ((addr + cnts) > max_available_size) { - RT_TRACE(_module_mp_, _drv_err_, ("!oid_rt_pro_write_efuse_hdl: parameter error")); + RT_TRACE(_module_mp_, _drv_err_, ("!rtl8188eu_oid_rt_pro_write_efuse_hdl: parameter error")); return NDIS_STATUS_NOT_ACCEPTED; } @@ -1221,7 +1221,7 @@ _func_exit_; return status; } /* */ -int oid_rt_pro_rw_efuse_pgpkt_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_rw_efuse_pgpkt_hdl(struct oid_par_priv *poid_par_priv) { struct pgpkt *ppgpkt; int status = NDIS_STATUS_SUCCESS; @@ -1240,7 +1240,7 @@ _func_enter_; if (poid_par_priv->type_of_oid == QUERY_OID) { RT_TRACE(_module_mp_, _drv_notice_, - ("oid_rt_pro_rw_efuse_pgpkt_hdl: Read offset=0x%x\n",\ + ("rtl8188eu_oid_rt_pro_rw_efuse_pgpkt_hdl: Read offset=0x%x\n",\ ppgpkt->offset)); Efuse_PowerSwitch(Adapter, false, true); @@ -1251,7 +1251,7 @@ _func_enter_; Efuse_PowerSwitch(Adapter, false, false); } else { RT_TRACE(_module_mp_, _drv_notice_, - ("oid_rt_pro_rw_efuse_pgpkt_hdl: Write offset=0x%x word_en=0x%x\n",\ + ("rtl8188eu_oid_rt_pro_rw_efuse_pgpkt_hdl: Write offset=0x%x word_en=0x%x\n",\ ppgpkt->offset, ppgpkt->word_en)); Efuse_PowerSwitch(Adapter, true, true); @@ -1265,14 +1265,14 @@ _func_enter_; _irqlevel_changed_(&oldirql, RAISE); RT_TRACE(_module_mp_, _drv_info_, - ("-oid_rt_pro_rw_efuse_pgpkt_hdl: status=0x%08X\n", status)); + ("-rtl8188eu_oid_rt_pro_rw_efuse_pgpkt_hdl: status=0x%08X\n", status)); _func_exit_; return status; } /* */ -int oid_rt_get_efuse_current_size_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_get_efuse_current_size_hdl(struct oid_par_priv *poid_par_priv) { u16 size; u8 ret; @@ -1301,7 +1301,7 @@ _func_exit_; return status; } /* */ -int oid_rt_get_efuse_max_size_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_get_efuse_max_size_hdl(struct oid_par_priv *poid_par_priv) { int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); @@ -1318,7 +1318,7 @@ _func_enter_; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; RT_TRACE(_module_mp_, _drv_info_, - ("-oid_rt_get_efuse_max_size_hdl: size=%d status=0x%08X\n", + ("-rtl8188eu_oid_rt_get_efuse_max_size_hdl: size=%d status=0x%08X\n", *(int *)poid_par_priv->information_buf, status)); _func_exit_; @@ -1326,27 +1326,27 @@ _func_exit_; return status; } /* */ -int oid_rt_pro_efuse_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_efuse_hdl(struct oid_par_priv *poid_par_priv) { int status; _func_enter_; - RT_TRACE(_module_mp_, _drv_info_, ("+oid_rt_pro_efuse_hdl\n")); + RT_TRACE(_module_mp_, _drv_info_, ("+rtl8188eu_oid_rt_pro_efuse_hdl\n")); if (poid_par_priv->type_of_oid == QUERY_OID) - status = oid_rt_pro_read_efuse_hdl(poid_par_priv); + status = rtl8188eu_oid_rt_pro_read_efuse_hdl(poid_par_priv); else - status = oid_rt_pro_write_efuse_hdl(poid_par_priv); + status = rtl8188eu_oid_rt_pro_write_efuse_hdl(poid_par_priv); - RT_TRACE(_module_mp_, _drv_info_, ("-oid_rt_pro_efuse_hdl: status=0x%08X\n", status)); + RT_TRACE(_module_mp_, _drv_info_, ("-rtl8188eu_oid_rt_pro_efuse_hdl: status=0x%08X\n", status)); _func_exit_; return status; } /* */ -int oid_rt_pro_efuse_map_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_efuse_map_hdl(struct oid_par_priv *poid_par_priv) { u8 *data; int status = NDIS_STATUS_SUCCESS; @@ -1355,7 +1355,7 @@ int oid_rt_pro_efuse_map_hdl(struct oid_par_priv *poid_par_priv) _func_enter_; - RT_TRACE(_module_mp_, _drv_notice_, ("+oid_rt_pro_efuse_map_hdl\n")); + RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_efuse_map_hdl\n")); EFUSE_GetEfuseDefinition(Adapter, EFUSE_WIFI, TYPE_EFUSE_MAP_LEN, (void *)&maplen, false); @@ -1370,25 +1370,25 @@ _func_enter_; if (poid_par_priv->type_of_oid == QUERY_OID) { RT_TRACE(_module_mp_, _drv_info_, - ("oid_rt_pro_efuse_map_hdl: READ\n")); + ("rtl8188eu_oid_rt_pro_efuse_map_hdl: READ\n")); if (rtw_efuse_map_read(Adapter, 0, maplen, data) == _SUCCESS) { *poid_par_priv->bytes_rw = maplen; } else { RT_TRACE(_module_mp_, _drv_err_, - ("oid_rt_pro_efuse_map_hdl: READ fail\n")); + ("rtl8188eu_oid_rt_pro_efuse_map_hdl: READ fail\n")); status = NDIS_STATUS_FAILURE; } } else { /* SET_OID */ RT_TRACE(_module_mp_, _drv_info_, - ("oid_rt_pro_efuse_map_hdl: WRITE\n")); + ("rtl8188eu_oid_rt_pro_efuse_map_hdl: WRITE\n")); if (rtw_efuse_map_write(Adapter, 0, maplen, data) == _SUCCESS) { *poid_par_priv->bytes_rw = maplen; } else { RT_TRACE(_module_mp_, _drv_err_, - ("oid_rt_pro_efuse_map_hdl: WRITE fail\n")); + ("rtl8188eu_oid_rt_pro_efuse_map_hdl: WRITE fail\n")); status = NDIS_STATUS_FAILURE; } } @@ -1396,27 +1396,27 @@ _func_enter_; _irqlevel_changed_(&oldirql, RAISE); RT_TRACE(_module_mp_, _drv_info_, - ("-oid_rt_pro_efuse_map_hdl: status=0x%08X\n", status)); + ("-rtl8188eu_oid_rt_pro_efuse_map_hdl: status=0x%08X\n", status)); _func_exit_; return status; } -int oid_rt_set_crystal_cap_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_set_crystal_cap_hdl(struct oid_par_priv *poid_par_priv) { int status = NDIS_STATUS_SUCCESS; return status; } -int oid_rt_set_rx_packet_type_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_set_rx_packet_type_hdl(struct oid_par_priv *poid_par_priv) { u8 rx_pkt_type; int status = NDIS_STATUS_SUCCESS; _func_enter_; - RT_TRACE(_module_mp_, _drv_notice_, ("+oid_rt_set_rx_packet_type_hdl\n")); + RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_set_rx_packet_type_hdl\n")); if (poid_par_priv->type_of_oid != SET_OID) return NDIS_STATUS_NOT_ACCEPTED; @@ -1432,17 +1432,17 @@ _func_exit_; return status; } -int oid_rt_pro_set_tx_agc_offset_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_set_tx_agc_offset_hdl(struct oid_par_priv *poid_par_priv) { return 0; } -int oid_rt_pro_set_pkt_test_mode_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_set_pkt_test_mode_hdl(struct oid_par_priv *poid_par_priv) { return 0; } -int mp_ioctl_xmit_packet_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_mp_ioctl_xmit_packet_hdl(struct oid_par_priv *poid_par_priv) { struct mp_xmit_parm *pparm; struct adapter *padapter; @@ -1478,7 +1478,7 @@ int mp_ioctl_xmit_packet_hdl(struct oid_par_priv *poid_par_priv) } /* */ -int oid_rt_set_power_down_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_set_power_down_hdl(struct oid_par_priv *poid_par_priv) { int status = NDIS_STATUS_SUCCESS; @@ -1490,7 +1490,7 @@ _func_enter_; } RT_TRACE(_module_mp_, _drv_info_, - ("\n ===> Setoid_rt_set_power_down_hdl.\n")); + ("\n ===> Setrtl8188eu_oid_rt_set_power_down_hdl.\n")); _irqlevel_changed_(&oldirql, LOWER); @@ -1502,7 +1502,7 @@ _func_exit_; return status; } /* */ -int oid_rt_get_power_mode_hdl(struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_get_power_mode_hdl(struct oid_par_priv *poid_par_priv) { return 0; } diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c index 1cce948a37fb4..08dfd94163e6b 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c @@ -93,7 +93,7 @@ void rtl8188eu_InitSwLeds(struct adapter *padapter) { struct led_priv *pledpriv = &(padapter->ledpriv); - pledpriv->LedControlHandler = LedControl871x; + pledpriv->LedControlHandler = LedControl8188eu; InitLed871x(padapter, &(pledpriv->SwLed0), LED_PIN_LED0); diff --git a/drivers/staging/rtl8188eu/include/rtw_led.h b/drivers/staging/rtl8188eu/include/rtw_led.h index 19d5753d9e272..2e618043d353e 100644 --- a/drivers/staging/rtl8188eu/include/rtw_led.h +++ b/drivers/staging/rtl8188eu/include/rtw_led.h @@ -160,7 +160,7 @@ enum LED_STRATEGY_871x { LED_ST_NONE = 99, }; -void LedControl871x(struct adapter *padapter, enum LED_CTL_MODE LedAction); +void LedControl8188eu(struct adapter *padapter, enum LED_CTL_MODE LedAction); struct led_priv{ /* add for led controll */ diff --git a/drivers/staging/rtl8188eu/include/rtw_mp_ioctl.h b/drivers/staging/rtl8188eu/include/rtw_mp_ioctl.h index db2116d3b18ec..494e90e5a7567 100644 --- a/drivers/staging/rtl8188eu/include/rtw_mp_ioctl.h +++ b/drivers/staging/rtl8188eu/include/rtw_mp_ioctl.h @@ -68,110 +68,110 @@ struct dr_variable_struct { #define _irqlevel_changed_(a, b) -/* oid_rtl_seg_81_80_00 */ -int oid_rt_pro_set_data_rate_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_pro_start_test_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_pro_stop_test_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_pro_set_channel_direct_call_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_pro_set_antenna_bb_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_pro_set_tx_power_control_hdl(struct oid_par_priv *poid_par_priv); - -/* oid_rtl_seg_81_80_20 */ -int oid_rt_pro_query_tx_packet_sent_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_pro_query_rx_packet_received_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_pro_query_rx_packet_crc32_error_hdl(struct oid_par_priv *par_priv); -int oid_rt_pro_reset_tx_packet_sent_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_pro_reset_rx_packet_received_hdl(struct oid_par_priv *par_priv); -int oid_rt_pro_set_modulation_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_pro_set_continuous_tx_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_pro_set_single_carrier_tx_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_pro_set_carrier_suppression_tx_hdl(struct oid_par_priv *par_priv); -int oid_rt_pro_set_single_tone_tx_hdl(struct oid_par_priv *poid_par_priv); - -/* oid_rtl_seg_81_87 */ -int oid_rt_pro_write_bb_reg_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_pro_read_bb_reg_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_pro_write_rf_reg_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_pro_read_rf_reg_hdl(struct oid_par_priv *poid_par_priv); - -/* oid_rtl_seg_81_85 */ -int oid_rt_wireless_mode_hdl(struct oid_par_priv *poid_par_priv); - -/* oid_rtl_seg_87_11_00 */ -int oid_rt_pro8711_join_bss_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_pro_read_register_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_pro_write_register_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_pro_burst_read_register_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_pro_burst_write_register_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_pro_write_txcmd_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_pro_read16_eeprom_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_pro_write16_eeprom_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_pro8711_wi_poll_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_pro8711_pkt_loss_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_rd_attrib_mem_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_wr_attrib_mem_hdl (struct oid_par_priv *poid_par_priv); -int oid_rt_pro_set_rf_intfs_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_poll_rx_status_hdl(struct oid_par_priv *poid_par_priv); -/* oid_rtl_seg_87_11_20 */ -int oid_rt_pro_cfg_debug_message_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_pro_set_data_rate_ex_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_pro_set_basic_rate_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_pro_read_tssi_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_pro_set_power_tracking_hdl(struct oid_par_priv *poid_par_priv); -/* oid_rtl_seg_87_11_50 */ -int oid_rt_pro_qry_pwrstate_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_pro_set_pwrstate_hdl(struct oid_par_priv *poid_par_priv); -/* oid_rtl_seg_87_11_F0 */ -int oid_rt_pro_h2c_set_rate_table_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_pro_h2c_get_rate_table_hdl(struct oid_par_priv *poid_par_priv); - -/* oid_rtl_seg_87_12_00 */ -int oid_rt_pro_encryption_ctrl_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_pro_add_sta_info_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_pro_dele_sta_info_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_pro_query_dr_variable_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_pro_rx_packet_type_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_pro_read_efuse_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_pro_write_efuse_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_pro_rw_efuse_pgpkt_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_get_efuse_current_size_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_pro_efuse_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_pro_efuse_map_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_set_bandwidth_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_set_crystal_cap_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_set_rx_packet_type_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_get_efuse_max_size_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_pro_set_tx_agc_offset_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_pro_set_pkt_test_mode_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_get_thermal_meter_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_reset_phy_rx_packet_count_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_get_phy_rx_packet_received_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_get_phy_rx_packet_crc32_error_hdl(struct oid_par_priv *par_priv); -int oid_rt_set_power_down_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_get_power_mode_hdl(struct oid_par_priv *poid_par_priv); -int oid_rt_pro_trigger_gpio_hdl(struct oid_par_priv *poid_par_priv); +/* rtl8188eu_oid_rtl_seg_81_80_00 */ +int rtl8188eu_oid_rt_pro_set_data_rate_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_start_test_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_stop_test_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_set_channel_direct_call_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_set_antenna_bb_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_set_tx_power_control_hdl(struct oid_par_priv *poid_par_priv); + +/* rtl8188eu_oid_rtl_seg_81_80_20 */ +int rtl8188eu_oid_rt_pro_query_tx_packet_sent_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_query_rx_packet_received_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_query_rx_packet_crc32_error_hdl(struct oid_par_priv *par_priv); +int rtl8188eu_oid_rt_pro_reset_tx_packet_sent_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_reset_rx_packet_received_hdl(struct oid_par_priv *par_priv); +int rtl8188eu_oid_rt_pro_set_modulation_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_set_continuous_tx_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_set_single_carrier_tx_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_set_carrier_suppression_tx_hdl(struct oid_par_priv *par_priv); +int rtl8188eu_oid_rt_pro_set_single_tone_tx_hdl(struct oid_par_priv *poid_par_priv); + +/* rtl8188eu_oid_rtl_seg_81_87 */ +int rtl8188eu_oid_rt_pro_write_bb_reg_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_read_bb_reg_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_write_rf_reg_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_read_rf_reg_hdl(struct oid_par_priv *poid_par_priv); + +/* rtl8188eu_oid_rtl_seg_81_85 */ +int rtl8188eu_oid_rt_wireless_mode_hdl(struct oid_par_priv *poid_par_priv); + +/* rtl8188eu_oid_rtl_seg_87_11_00 */ +int rtl8188eu_oid_rt_pro8711_join_bss_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_read_register_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_write_register_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_burst_read_register_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_burst_write_register_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_write_txcmd_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_read16_eeprom_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_write16_eeprom_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro8711_wi_poll_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro8711_pkt_loss_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_rd_attrib_mem_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_wr_attrib_mem_hdl (struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_set_rf_intfs_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_poll_rx_status_hdl(struct oid_par_priv *poid_par_priv); +/* rtl8188eu_oid_rtl_seg_87_11_20 */ +int rtl8188eu_oid_rt_pro_cfg_debug_message_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_set_data_rate_ex_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_set_basic_rate_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_read_tssi_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_set_power_tracking_hdl(struct oid_par_priv *poid_par_priv); +/* rtl8188eu_oid_rtl_seg_87_11_50 */ +int rtl8188eu_oid_rt_pro_qry_pwrstate_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_set_pwrstate_hdl(struct oid_par_priv *poid_par_priv); +/* rtl8188eu_oid_rtl_seg_87_11_F0 */ +int rtl8188eu_oid_rt_pro_h2c_set_rate_table_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_h2c_get_rate_table_hdl(struct oid_par_priv *poid_par_priv); + +/* rtl8188eu_oid_rtl_seg_87_12_00 */ +int rtl8188eu_oid_rt_pro_encryption_ctrl_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_add_sta_info_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_dele_sta_info_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_query_dr_variable_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_rx_packet_type_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_read_efuse_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_write_efuse_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_rw_efuse_pgpkt_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_get_efuse_current_size_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_efuse_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_efuse_map_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_set_bandwidth_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_set_crystal_cap_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_set_rx_packet_type_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_get_efuse_max_size_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_set_tx_agc_offset_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_set_pkt_test_mode_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_get_thermal_meter_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_reset_phy_rx_packet_count_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_get_phy_rx_packet_received_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_get_phy_rx_packet_crc32_error_hdl(struct oid_par_priv *par_priv); +int rtl8188eu_oid_rt_set_power_down_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_get_power_mode_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_trigger_gpio_hdl(struct oid_par_priv *poid_par_priv); #ifdef _RTW_MP_IOCTL_C_ -static const struct oid_obj_priv oid_rtl_seg_81_80_00[] = { +static const struct oid_obj_priv rtl8188eu_oid_rtl_seg_81_80_00[] = { {1, &oid_null_function}, /* 0x00 OID_RT_PRO_RESET_DUT */ - {1, &oid_rt_pro_set_data_rate_hdl}, /* 0x01 */ - {1, &oid_rt_pro_start_test_hdl}, /* 0x02 */ - {1, &oid_rt_pro_stop_test_hdl}, /* 0x03 */ + {1, &rtl8188eu_oid_rt_pro_set_data_rate_hdl}, /* 0x01 */ + {1, &rtl8188eu_oid_rt_pro_start_test_hdl}, /* 0x02 */ + {1, &rtl8188eu_oid_rt_pro_stop_test_hdl}, /* 0x03 */ {1, &oid_null_function}, /* 0x04 OID_RT_PRO_SET_PREAMBLE */ {1, &oid_null_function}, /* 0x05 OID_RT_PRO_SET_SCRAMBLER */ {1, &oid_null_function}, /* 0x06 OID_RT_PRO_SET_FILTER_BB */ {1, &oid_null_function},/* 0x07 OID_RT_PRO_SET_MANUAL_DIVERSITY_BB */ - {1, &oid_rt_pro_set_channel_direct_call_hdl}, /* 0x08 */ + {1, &rtl8188eu_oid_rt_pro_set_channel_direct_call_hdl}, /* 0x08 */ {1, &oid_null_function},/* 0x09 OID_RT_PRO_SET_SLEEP_MODE_DIRECT_CALL */ {1, &oid_null_function},/* 0x0A OID_RT_PRO_SET_WAKE_MODE_DIRECT_CALL */ - {1, &oid_rt_pro_set_continuous_tx_hdl}, /* 0x0B OID_RT_PRO_SET_TX_CONTINUOUS_DIRECT_CALL */ - {1, &oid_rt_pro_set_single_carrier_tx_hdl},/* 0x0C OID_RT_PRO_SET_SINGLE_CARRIER_TX_CONTINUOUS */ + {1, &rtl8188eu_oid_rt_pro_set_continuous_tx_hdl}, /* 0x0B OID_RT_PRO_SET_TX_CONTINUOUS_DIRECT_CALL */ + {1, &rtl8188eu_oid_rt_pro_set_single_carrier_tx_hdl},/* 0x0C OID_RT_PRO_SET_SINGLE_CARRIER_TX_CONTINUOUS */ {1, &oid_null_function}, /* 0x0D OID_RT_PRO_SET_TX_ANTENNA_BB */ - {1, &oid_rt_pro_set_antenna_bb_hdl}, /* 0x0E */ + {1, &rtl8188eu_oid_rt_pro_set_antenna_bb_hdl}, /* 0x0E */ {1, &oid_null_function}, /* 0x0F OID_RT_PRO_SET_CR_SCRAMBLER */ {1, &oid_null_function}, /* 0x10 OID_RT_PRO_SET_CR_NEW_FILTER */ - {1, &oid_rt_pro_set_tx_power_control_hdl},/* 0x11 OID_RT_PRO_SET_TX_POWER_CONTROL */ + {1, &rtl8188eu_oid_rt_pro_set_tx_power_control_hdl},/* 0x11 OID_RT_PRO_SET_TX_POWER_CONTROL */ {1, &oid_null_function}, /* 0x12 OID_RT_PRO_SET_CR_TX_CONFIG */ {1, &oid_null_function}, /* 0x13 OID_RT_PRO_GET_TX_POWER_CONTROL */ {1, &oid_null_function}, /* 0x14 OID_RT_PRO_GET_CR_SIGNAL_QUALITY */ @@ -188,42 +188,42 @@ static const struct oid_obj_priv oid_rtl_seg_81_80_00[] = { {1, &oid_null_function} /* 0x1F OID_RT_PRO_WRITE_POWER_CONTROL */ }; -static const struct oid_obj_priv oid_rtl_seg_81_80_20[] = { +static const struct oid_obj_priv rtl8188eu_oid_rtl_seg_81_80_20[] = { {1, &oid_null_function}, /* 0x20 OID_RT_PRO_READ_POWER_CONTROL */ {1, &oid_null_function}, /* 0x21 OID_RT_PRO_WRITE_EEPROM */ {1, &oid_null_function}, /* 0x22 OID_RT_PRO_READ_EEPROM */ - {1, &oid_rt_pro_reset_tx_packet_sent_hdl}, /* 0x23 */ - {1, &oid_rt_pro_query_tx_packet_sent_hdl}, /* 0x24 */ - {1, &oid_rt_pro_reset_rx_packet_received_hdl}, /* 0x25 */ - {1, &oid_rt_pro_query_rx_packet_received_hdl}, /* 0x26 */ - {1, &oid_rt_pro_query_rx_packet_crc32_error_hdl}, /* 0x27 */ + {1, &rtl8188eu_oid_rt_pro_reset_tx_packet_sent_hdl}, /* 0x23 */ + {1, &rtl8188eu_oid_rt_pro_query_tx_packet_sent_hdl}, /* 0x24 */ + {1, &rtl8188eu_oid_rt_pro_reset_rx_packet_received_hdl}, /* 0x25 */ + {1, &rtl8188eu_oid_rt_pro_query_rx_packet_received_hdl}, /* 0x26 */ + {1, &rtl8188eu_oid_rt_pro_query_rx_packet_crc32_error_hdl}, /* 0x27 */ {1, &oid_null_function}, /* 0x28 OID_RT_PRO_QUERY_CURRENT_ADDRESS */ {1, &oid_null_function}, /* 0x29 OID_RT_PRO_QUERY_PERMANENT_ADDRESS */ {1, &oid_null_function}, /* 0x2A OID_RT_PRO_SET_PHILIPS_RF_PARAMETERS */ - {1, &oid_rt_pro_set_carrier_suppression_tx_hdl},/* 0x2B OID_RT_PRO_SET_CARRIER_SUPPRESSION_TX */ + {1, &rtl8188eu_oid_rt_pro_set_carrier_suppression_tx_hdl},/* 0x2B OID_RT_PRO_SET_CARRIER_SUPPRESSION_TX */ {1, &oid_null_function}, /* 0x2C OID_RT_PRO_RECEIVE_PACKET */ {1, &oid_null_function}, /* 0x2D OID_RT_PRO_WRITE_EEPROM_BYTE */ {1, &oid_null_function}, /* 0x2E OID_RT_PRO_READ_EEPROM_BYTE */ - {1, &oid_rt_pro_set_modulation_hdl} /* 0x2F */ + {1, &rtl8188eu_oid_rt_pro_set_modulation_hdl} /* 0x2F */ }; -static const struct oid_obj_priv oid_rtl_seg_81_80_40[] = { +static const struct oid_obj_priv rtl8188eu_oid_rtl_seg_81_80_40[] = { {1, &oid_null_function}, /* 0x40 */ {1, &oid_null_function}, /* 0x41 */ {1, &oid_null_function}, /* 0x42 */ - {1, &oid_rt_pro_set_single_tone_tx_hdl}, /* 0x43 */ + {1, &rtl8188eu_oid_rt_pro_set_single_tone_tx_hdl}, /* 0x43 */ {1, &oid_null_function}, /* 0x44 */ {1, &oid_null_function} /* 0x45 */ }; -static const struct oid_obj_priv oid_rtl_seg_81_80_80[] = { +static const struct oid_obj_priv rtl8188eu_oid_rtl_seg_81_80_80[] = { {1, &oid_null_function}, /* 0x80 OID_RT_DRIVER_OPTION */ {1, &oid_null_function}, /* 0x81 OID_RT_RF_OFF */ {1, &oid_null_function} /* 0x82 OID_RT_AUTH_STATUS */ }; -static const struct oid_obj_priv oid_rtl_seg_81_85[] = { - {1, &oid_rt_wireless_mode_hdl} /* 0x00 OID_RT_WIRELESS_MODE */ +static const struct oid_obj_priv rtl8188eu_oid_rtl_seg_81_85[] = { + {1, &rtl8188eu_oid_rt_wireless_mode_hdl} /* 0x00 OID_RT_WIRELESS_MODE */ }; #endif /* _RTL871X_MP_IOCTL_C_ */ @@ -329,12 +329,12 @@ enum RTL871X_MP_IOCTL_SUBCODE { MAX_MP_IOCTL_SUBCODE, }; -s32 mp_ioctl_xmit_packet_hdl(struct oid_par_priv *poid_par_priv); +s32 rtl8188eu_mp_ioctl_xmit_packet_hdl(struct oid_par_priv *poid_par_priv); #define GEN_HANDLER(sz, hdl, oid) {sz, hdl, oid}, #define EXT_MP_IOCTL_HANDLER(sz, subcode, oid) \ - {sz, mp_ioctl_##subcode##_hdl, oid}, + {sz, rtl8188eu_mp_ioctl_##subcode##_hdl, oid}, #endif diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c index 554ca63813923..d438256a205f9 100644 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -58,45 +58,45 @@ #define WEXT_CSCAN_TYPE_SECTION 'T' static struct mp_ioctl_handler mp_ioctl_hdl[] = { -/*0*/ GEN_HANDLER(sizeof(u32), oid_rt_pro_start_test_hdl, OID_RT_PRO_START_TEST) - GEN_HANDLER(sizeof(u32), oid_rt_pro_stop_test_hdl, OID_RT_PRO_STOP_TEST) - - GEN_HANDLER(sizeof(struct rwreg_param), oid_rt_pro_read_register_hdl, OID_RT_PRO_READ_REGISTER) - GEN_HANDLER(sizeof(struct rwreg_param), oid_rt_pro_write_register_hdl, OID_RT_PRO_WRITE_REGISTER) - GEN_HANDLER(sizeof(struct bb_reg_param), oid_rt_pro_read_bb_reg_hdl, OID_RT_PRO_READ_BB_REG) -/*5*/ GEN_HANDLER(sizeof(struct bb_reg_param), oid_rt_pro_write_bb_reg_hdl, OID_RT_PRO_WRITE_BB_REG) - GEN_HANDLER(sizeof(struct rf_reg_param), oid_rt_pro_read_rf_reg_hdl, OID_RT_PRO_RF_READ_REGISTRY) - GEN_HANDLER(sizeof(struct rf_reg_param), oid_rt_pro_write_rf_reg_hdl, OID_RT_PRO_RF_WRITE_REGISTRY) - - GEN_HANDLER(sizeof(u32), oid_rt_pro_set_channel_direct_call_hdl, OID_RT_PRO_SET_CHANNEL_DIRECT_CALL) - GEN_HANDLER(sizeof(struct txpower_param), oid_rt_pro_set_tx_power_control_hdl, OID_RT_PRO_SET_TX_POWER_CONTROL) -/*10*/ GEN_HANDLER(sizeof(u32), oid_rt_pro_set_data_rate_hdl, OID_RT_PRO_SET_DATA_RATE) - GEN_HANDLER(sizeof(u32), oid_rt_set_bandwidth_hdl, OID_RT_SET_BANDWIDTH) - GEN_HANDLER(sizeof(u32), oid_rt_pro_set_antenna_bb_hdl, OID_RT_PRO_SET_ANTENNA_BB) - - GEN_HANDLER(sizeof(u32), oid_rt_pro_set_continuous_tx_hdl, OID_RT_PRO_SET_CONTINUOUS_TX) - GEN_HANDLER(sizeof(u32), oid_rt_pro_set_single_carrier_tx_hdl, OID_RT_PRO_SET_SINGLE_CARRIER_TX) -/*15*/ GEN_HANDLER(sizeof(u32), oid_rt_pro_set_carrier_suppression_tx_hdl, OID_RT_PRO_SET_CARRIER_SUPPRESSION_TX) - GEN_HANDLER(sizeof(u32), oid_rt_pro_set_single_tone_tx_hdl, OID_RT_PRO_SET_SINGLE_TONE_TX) +/*0*/ GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_pro_start_test_hdl, OID_RT_PRO_START_TEST) + GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_pro_stop_test_hdl, OID_RT_PRO_STOP_TEST) + + GEN_HANDLER(sizeof(struct rwreg_param), rtl8188eu_oid_rt_pro_read_register_hdl, OID_RT_PRO_READ_REGISTER) + GEN_HANDLER(sizeof(struct rwreg_param), rtl8188eu_oid_rt_pro_write_register_hdl, OID_RT_PRO_WRITE_REGISTER) + GEN_HANDLER(sizeof(struct bb_reg_param), rtl8188eu_oid_rt_pro_read_bb_reg_hdl, OID_RT_PRO_READ_BB_REG) +/*5*/ GEN_HANDLER(sizeof(struct bb_reg_param), rtl8188eu_oid_rt_pro_write_bb_reg_hdl, OID_RT_PRO_WRITE_BB_REG) + GEN_HANDLER(sizeof(struct rf_reg_param), rtl8188eu_oid_rt_pro_read_rf_reg_hdl, OID_RT_PRO_RF_READ_REGISTRY) + GEN_HANDLER(sizeof(struct rf_reg_param), rtl8188eu_oid_rt_pro_write_rf_reg_hdl, OID_RT_PRO_RF_WRITE_REGISTRY) + + GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_pro_set_channel_direct_call_hdl, OID_RT_PRO_SET_CHANNEL_DIRECT_CALL) + GEN_HANDLER(sizeof(struct txpower_param), rtl8188eu_oid_rt_pro_set_tx_power_control_hdl, OID_RT_PRO_SET_TX_POWER_CONTROL) +/*10*/ GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_pro_set_data_rate_hdl, OID_RT_PRO_SET_DATA_RATE) + GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_set_bandwidth_hdl, OID_RT_SET_BANDWIDTH) + GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_pro_set_antenna_bb_hdl, OID_RT_PRO_SET_ANTENNA_BB) + + GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_pro_set_continuous_tx_hdl, OID_RT_PRO_SET_CONTINUOUS_TX) + GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_pro_set_single_carrier_tx_hdl, OID_RT_PRO_SET_SINGLE_CARRIER_TX) +/*15*/ GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_pro_set_carrier_suppression_tx_hdl, OID_RT_PRO_SET_CARRIER_SUPPRESSION_TX) + GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_pro_set_single_tone_tx_hdl, OID_RT_PRO_SET_SINGLE_TONE_TX) EXT_MP_IOCTL_HANDLER(0, xmit_packet, 0) - GEN_HANDLER(sizeof(u32), oid_rt_set_rx_packet_type_hdl, OID_RT_SET_RX_PACKET_TYPE) - GEN_HANDLER(0, oid_rt_reset_phy_rx_packet_count_hdl, OID_RT_RESET_PHY_RX_PACKET_COUNT) -/*20*/ GEN_HANDLER(sizeof(u32), oid_rt_get_phy_rx_packet_received_hdl, OID_RT_GET_PHY_RX_PACKET_RECEIVED) - GEN_HANDLER(sizeof(u32), oid_rt_get_phy_rx_packet_crc32_error_hdl, OID_RT_GET_PHY_RX_PACKET_CRC32_ERROR) + GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_set_rx_packet_type_hdl, OID_RT_SET_RX_PACKET_TYPE) + GEN_HANDLER(0, rtl8188eu_oid_rt_reset_phy_rx_packet_count_hdl, OID_RT_RESET_PHY_RX_PACKET_COUNT) +/*20*/ GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_get_phy_rx_packet_received_hdl, OID_RT_GET_PHY_RX_PACKET_RECEIVED) + GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_get_phy_rx_packet_crc32_error_hdl, OID_RT_GET_PHY_RX_PACKET_CRC32_ERROR) GEN_HANDLER(sizeof(struct eeprom_rw_param), NULL, 0) GEN_HANDLER(sizeof(struct eeprom_rw_param), NULL, 0) - GEN_HANDLER(sizeof(struct efuse_access_struct), oid_rt_pro_efuse_hdl, OID_RT_PRO_EFUSE) -/*25*/ GEN_HANDLER(0, oid_rt_pro_efuse_map_hdl, OID_RT_PRO_EFUSE_MAP) - GEN_HANDLER(sizeof(u32), oid_rt_get_efuse_max_size_hdl, OID_RT_GET_EFUSE_MAX_SIZE) - GEN_HANDLER(sizeof(u32), oid_rt_get_efuse_current_size_hdl, OID_RT_GET_EFUSE_CURRENT_SIZE) - - GEN_HANDLER(sizeof(u32), oid_rt_get_thermal_meter_hdl, OID_RT_PRO_GET_THERMAL_METER) - GEN_HANDLER(sizeof(u8), oid_rt_pro_set_power_tracking_hdl, OID_RT_PRO_SET_POWER_TRACKING) -/*30*/ GEN_HANDLER(sizeof(u8), oid_rt_set_power_down_hdl, OID_RT_SET_POWER_DOWN) -/*31*/ GEN_HANDLER(0, oid_rt_pro_trigger_gpio_hdl, 0) + GEN_HANDLER(sizeof(struct efuse_access_struct), rtl8188eu_oid_rt_pro_efuse_hdl, OID_RT_PRO_EFUSE) +/*25*/ GEN_HANDLER(0, rtl8188eu_oid_rt_pro_efuse_map_hdl, OID_RT_PRO_EFUSE_MAP) + GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_get_efuse_max_size_hdl, OID_RT_GET_EFUSE_MAX_SIZE) + GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_get_efuse_current_size_hdl, OID_RT_GET_EFUSE_CURRENT_SIZE) + + GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_get_thermal_meter_hdl, OID_RT_PRO_GET_THERMAL_METER) + GEN_HANDLER(sizeof(u8), rtl8188eu_oid_rt_pro_set_power_tracking_hdl, OID_RT_PRO_SET_POWER_TRACKING) +/*30*/ GEN_HANDLER(sizeof(u8), rtl8188eu_oid_rt_set_power_down_hdl, OID_RT_SET_POWER_DOWN) +/*31*/ GEN_HANDLER(0, rtl8188eu_oid_rt_pro_trigger_gpio_hdl, 0) }; static u32 rtw_rates[] = {1000000, 2000000, 5500000, 11000000, -- GitLab From 4235f72fbcabebfeabb65cb7a740985337a1a1d4 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 24 Aug 2013 12:42:01 +0100 Subject: [PATCH 824/942] staging: vt6656: device.h Remove dead code bSoftwareGenCrcErr. Probably an error in earlier firmware is never enabled so remove. bPacketToWirelessUsb remove dead if/else and variables. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/device.h | 1 - drivers/staging/vt6656/rxtx.c | 21 +-------------------- 2 files changed, 1 insertion(+), 21 deletions(-) diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h index 49869108e7e0f..e8f4b194005e5 100644 --- a/drivers/staging/vt6656/device.h +++ b/drivers/staging/vt6656/device.h @@ -596,7 +596,6 @@ struct vnt_private { int bCCK; int bEncryptionEnable; int bLongHeader; - int bSoftwareGenCrcErr; int bShortSlotTime; int bProtectMode; int bNonERPPresent; diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 14b7defe2b5d2..80741c0d87660 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -1003,7 +1003,7 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, void *pvTxDataHd; u8 byFBOption = AUTO_FB_NONE, byFragType; u16 wTxBufSize; - u32 dwMICKey0, dwMICKey1, dwMIC_Priority, dwCRC; + u32 dwMICKey0, dwMICKey1, dwMIC_Priority; u32 *pdwMIC_L, *pdwMIC_R; int bSoftWEP = false; @@ -1058,10 +1058,6 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, if (pDevice->bLongHeader) pTxBufHead->wFIFOCtl |= FIFOCTL_LHEAD; - if (pDevice->bSoftwareGenCrcErr) { - pTxBufHead->wFIFOCtl |= FIFOCTL_CRCDIS; // set tx descriptors to NO hardware CRC - } - //Set FRAGCTL_MACHDCNT if (pDevice->bLongHeader) { cbMACHdLen = WLAN_HDR_ADDR3_LEN + 6; @@ -1386,22 +1382,7 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, cbFrameSize -= cbICVlen; } - if (pDevice->bSoftwareGenCrcErr == true) { - unsigned int cbLen; - u32 * pdwCRC; - - dwCRC = 0xFFFFFFFFL; - cbLen = cbFrameSize - cbFCSlen; - // calculate CRC, and wrtie CRC value to end of TD - dwCRC = CRCdwGetCrc32Ex(pbyMacHdr, cbLen, dwCRC); - pdwCRC = (u32 *)(pbyMacHdr + cbLen); - // finally, we must invert dwCRC to get the correct answer - *pdwCRC = ~dwCRC; - // Force Error - *pdwCRC -= 1; - } else { cbFrameSize -= cbFCSlen; - } *pcbHeaderLen = cbHeaderLength; *pcbTotalLen = cbHeaderLength + cbFrameSize ; -- GitLab From fedbfe7eb8deb73719307cb2369669fe94270a10 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 24 Aug 2013 12:50:50 +0100 Subject: [PATCH 825/942] staging: vt6656: rxtx.c s_vFillRTSHead remove dead bDiscCRC As result of patch vt6656: device.h Remove dead code bSoftwareGenCrcErr. dDiscCRC is unused. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 80741c0d87660..1b2effc050ee4 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -129,7 +129,7 @@ static void s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx, int bDisCRC, u16 wCurrentRate, u8 byFBOption); static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, - void *pvRTS, u32 cbFrameLength, int bNeedAck, int bDisCRC, + void *pvRTS, u32 cbFrameLength, int bNeedAck, struct ethhdr *psEthHeader, u16 wCurrentRate, u8 byFBOption); static u16 s_uGetDataDuration(struct vnt_private *pDevice, @@ -596,7 +596,7 @@ static u32 s_uFillDataHead(struct vnt_private *pDevice, } static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, - void *pvRTS, u32 cbFrameLength, int bNeedAck, int bDisCRC, + void *pvRTS, u32 cbFrameLength, int bNeedAck, struct ethhdr *psEthHeader, u16 wCurrentRate, u8 byFBOption) { u32 uRTSFrameLen = 20; @@ -604,12 +604,6 @@ static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, if (pvRTS == NULL) return; - if (bDisCRC) { - // When CRCDIS bit is on, H/W forgot to generate FCS for RTS frame, - // in this case we need to decrease its length by 4. - uRTSFrameLen -= 4; - } - // Note: So far RTSHead doesn't appear in ATIM & Beacom DMA, so we don't need to take them into account. // Otherwise, we need to modified codes for them. if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { @@ -900,7 +894,8 @@ static void s_vGenerateTxParameter(struct vnt_private *pDevice, bNeedACK); } //Fill RTS - s_vFillRTSHead(pDevice, byPktType, pvRTS, cbFrameSize, bNeedACK, bDisCRC, psEthHeader, wCurrentRate, byFBOption); + s_vFillRTSHead(pDevice, byPktType, pvRTS, cbFrameSize, bNeedACK, + psEthHeader, wCurrentRate, byFBOption); } else {//RTS_needless, PCF mode @@ -933,7 +928,8 @@ static void s_vGenerateTxParameter(struct vnt_private *pDevice, cbFrameSize, wCurrentRate, bNeedACK); } //Fill RTS - s_vFillRTSHead(pDevice, byPktType, pvRTS, cbFrameSize, bNeedACK, bDisCRC, psEthHeader, wCurrentRate, byFBOption); + s_vFillRTSHead(pDevice, byPktType, pvRTS, cbFrameSize, bNeedACK, + psEthHeader, wCurrentRate, byFBOption); } else if (pvRTS == NULL) {//RTS_needless, non PCF mode //Fill RsvTime @@ -958,7 +954,8 @@ static void s_vGenerateTxParameter(struct vnt_private *pDevice, cbFrameSize, wCurrentRate, bNeedACK); } //Fill RTS - s_vFillRTSHead(pDevice, byPktType, pvRTS, cbFrameSize, bNeedACK, bDisCRC, psEthHeader, wCurrentRate, byFBOption); + s_vFillRTSHead(pDevice, byPktType, pvRTS, cbFrameSize, bNeedACK, + psEthHeader, wCurrentRate, byFBOption); } else { //RTS_needless, non PCF mode //Fill RsvTime -- GitLab From 09bd0f3563dc49513ebc01975985fc74a8757d34 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 24 Aug 2013 12:56:11 +0100 Subject: [PATCH 826/942] staging: vt6656: rxtx.c s_vFillCTSHead remove dead code bDisCRC As result of patch vt6656: device.h Remove dead code bSoftwareGenCrcErr. dDiscCRC is unused. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 1b2effc050ee4..7b94a775cbdef 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -126,7 +126,7 @@ static u16 s_uGetRTSCTSRsvTime(struct vnt_private *pDevice, u8 byRTSRsvType, static void s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx, u8 byPktType, void *pvCTS, u32 cbFrameLength, int bNeedAck, - int bDisCRC, u16 wCurrentRate, u8 byFBOption); + u16 wCurrentRate, u8 byFBOption); static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, void *pvRTS, u32 cbFrameLength, int bNeedAck, @@ -769,7 +769,7 @@ static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, static void s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx, u8 byPktType, void *pvCTS, u32 cbFrameLength, int bNeedAck, - int bDisCRC, u16 wCurrentRate, u8 byFBOption) + u16 wCurrentRate, u8 byFBOption) { u32 uCTSFrameLen = 14; @@ -777,12 +777,6 @@ static void s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx, return; } - if (bDisCRC) { - // When CRCDIS bit is on, H/W forgot to generate FCS for CTS frame, - // in this case we need to decrease its length by 4. - uCTSFrameLen -= 4; - } - if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { if (byFBOption != AUTO_FB_NONE) { /* Auto Fall back */ @@ -912,7 +906,8 @@ static void s_vGenerateTxParameter(struct vnt_private *pDevice, byPktType, cbFrameSize, wCurrentRate); } //Fill CTS - s_vFillCTSHead(pDevice, uDMAIdx, byPktType, pvCTS, cbFrameSize, bNeedACK, bDisCRC, wCurrentRate, byFBOption); + s_vFillCTSHead(pDevice, uDMAIdx, byPktType, pvCTS, cbFrameSize, + bNeedACK, wCurrentRate, byFBOption); } } else if (byPktType == PK_TYPE_11A) { -- GitLab From b6c416ce68f31993612a7b45959fb8b7840e813a Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 24 Aug 2013 13:01:48 +0100 Subject: [PATCH 827/942] staging: vt6656: s_vGenerateTxParameter dead code bDisCRC As result of patch vt6656: rxtx.c s_vFillCTSHead remove dead code bDisCRC bDisCRC is unused. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 7b94a775cbdef..64ce7f0d8c0ed 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -846,7 +846,6 @@ static void s_vGenerateTxParameter(struct vnt_private *pDevice, { u32 cbMACHdLen = WLAN_HDR_ADDR3_LEN; /* 24 */ u16 wFifoCtl; - int bDisCRC = false; u8 byFBOption = AUTO_FB_NONE; //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"s_vGenerateTxParameter...\n"); @@ -854,10 +853,6 @@ static void s_vGenerateTxParameter(struct vnt_private *pDevice, pFifoHead->wReserved = wCurrentRate; wFifoCtl = pFifoHead->wFIFOCtl; - if (wFifoCtl & FIFOCTL_CRCDIS) { - bDisCRC = true; - } - if (wFifoCtl & FIFOCTL_AUTO_FB_0) { byFBOption = AUTO_FB_0; } -- GitLab From 2dc22d5a22d143e5ea2576e9e9c75da0d660d436 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sat, 24 Aug 2013 13:15:32 +0100 Subject: [PATCH 828/942] staging: vt6656: s_vGenerateTxParameter pvRrvTime should never be NULL If pvRrvTime is NULL the whole structure is NULL, so remove if statements and consolidate to single return. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 64ce7f0d8c0ed..dd2bfc9f88c55 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -860,6 +860,9 @@ static void s_vGenerateTxParameter(struct vnt_private *pDevice, byFBOption = AUTO_FB_1; } + if (!pvRrvTime) + return; + if (pDevice->bLongHeader) cbMACHdLen = WLAN_HDR_ADDR3_LEN + 6; @@ -867,7 +870,6 @@ static void s_vGenerateTxParameter(struct vnt_private *pDevice, if (pvRTS != NULL) { //RTS_need //Fill RsvTime - if (pvRrvTime) { struct vnt_rrv_time_rts *pBuf = (struct vnt_rrv_time_rts *)pvRrvTime; pBuf->wRTSTxRrvTime_aa = s_uGetRTSCTSRsvTime(pDevice, 2, @@ -881,15 +883,12 @@ static void s_vGenerateTxParameter(struct vnt_private *pDevice, pBuf->wTxRrvTime_b = vnt_rxtx_rsvtime_le16(pDevice, PK_TYPE_11B, cbFrameSize, pDevice->byTopCCKBasicRate, bNeedACK); - } //Fill RTS s_vFillRTSHead(pDevice, byPktType, pvRTS, cbFrameSize, bNeedACK, psEthHeader, wCurrentRate, byFBOption); } else {//RTS_needless, PCF mode - //Fill RsvTime - if (pvRrvTime) { struct vnt_rrv_time_cts *pBuf = (struct vnt_rrv_time_cts *)pvRrvTime; pBuf->wTxRrvTime_a = vnt_rxtx_rsvtime_le16(pDevice, byPktType, @@ -899,7 +898,6 @@ static void s_vGenerateTxParameter(struct vnt_private *pDevice, pDevice->byTopCCKBasicRate, bNeedACK); pBuf->wCTSTxRrvTime_ba = s_uGetRTSCTSRsvTime(pDevice, 3, byPktType, cbFrameSize, wCurrentRate); - } //Fill CTS s_vFillCTSHead(pDevice, uDMAIdx, byPktType, pvCTS, cbFrameSize, bNeedACK, wCurrentRate, byFBOption); @@ -909,52 +907,44 @@ static void s_vGenerateTxParameter(struct vnt_private *pDevice, if (pvRTS != NULL) {//RTS_need, non PCF mode //Fill RsvTime - if (pvRrvTime) { struct vnt_rrv_time_ab *pBuf = (struct vnt_rrv_time_ab *)pvRrvTime; pBuf->wRTSTxRrvTime = s_uGetRTSCTSRsvTime(pDevice, 2, byPktType, cbFrameSize, wCurrentRate); pBuf->wTxRrvTime = vnt_rxtx_rsvtime_le16(pDevice, byPktType, cbFrameSize, wCurrentRate, bNeedACK); - } //Fill RTS s_vFillRTSHead(pDevice, byPktType, pvRTS, cbFrameSize, bNeedACK, psEthHeader, wCurrentRate, byFBOption); } else if (pvRTS == NULL) {//RTS_needless, non PCF mode //Fill RsvTime - if (pvRrvTime) { struct vnt_rrv_time_ab *pBuf = (struct vnt_rrv_time_ab *)pvRrvTime; pBuf->wTxRrvTime = vnt_rxtx_rsvtime_le16(pDevice, PK_TYPE_11A, cbFrameSize, wCurrentRate, bNeedACK); - } } } else if (byPktType == PK_TYPE_11B) { if ((pvRTS != NULL)) {//RTS_need, non PCF mode //Fill RsvTime - if (pvRrvTime) { struct vnt_rrv_time_ab *pBuf = (struct vnt_rrv_time_ab *)pvRrvTime; pBuf->wRTSTxRrvTime = s_uGetRTSCTSRsvTime(pDevice, 0, byPktType, cbFrameSize, wCurrentRate); pBuf->wTxRrvTime = vnt_rxtx_rsvtime_le16(pDevice, PK_TYPE_11B, cbFrameSize, wCurrentRate, bNeedACK); - } //Fill RTS s_vFillRTSHead(pDevice, byPktType, pvRTS, cbFrameSize, bNeedACK, psEthHeader, wCurrentRate, byFBOption); } else { //RTS_needless, non PCF mode //Fill RsvTime - if (pvRrvTime) { struct vnt_rrv_time_ab *pBuf = (struct vnt_rrv_time_ab *)pvRrvTime; pBuf->wTxRrvTime = vnt_rxtx_rsvtime_le16(pDevice, PK_TYPE_11B, cbFrameSize, wCurrentRate, bNeedACK); - } } } //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"s_vGenerateTxParameter END.\n"); -- GitLab From 5e67ee4956b7c9a923e2719e3afea61f8b14926e Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 26 Aug 2013 11:04:50 +0100 Subject: [PATCH 829/942] staging: vt6656: rxtx.c s_vFillRTSHead Parse out struct vnt_rts_g to new functions. Parse out vnt_rts_g code to new function vnt_rxtx_rts_g_head. Also create a new common calling function vnt_fill_ieee80211_rts to fill the ieee80211_rts structure. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 75 ++++++++++++++++++++++------------- 1 file changed, 47 insertions(+), 28 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index dd2bfc9f88c55..57af55b391d0c 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -595,6 +595,50 @@ static u32 s_uFillDataHead(struct vnt_private *pDevice, return 0; } +static int vnt_fill_ieee80211_rts(struct vnt_private *priv, + struct ieee80211_rts *rts, struct ethhdr *eth_hdr, + u16 duration) +{ + rts->duration = duration; + rts->frame_control = TYPE_CTL_RTS; + + if (priv->eOPMode == OP_MODE_ADHOC || priv->eOPMode == OP_MODE_AP) + memcpy(rts->ra, eth_hdr->h_dest, ETH_ALEN); + else + memcpy(rts->ra, priv->abyBSSID, ETH_ALEN); + + if (priv->eOPMode == OP_MODE_AP) + memcpy(rts->ta, priv->abyBSSID, ETH_ALEN); + else + memcpy(rts->ta, eth_hdr->h_source, ETH_ALEN); + + return 0; +} + +static int vnt_rxtx_rts_g_head(struct vnt_private *priv, + struct vnt_rts_g *buf, struct ethhdr *eth_hdr, + u8 pkt_type, u32 frame_len, int need_ack, + u16 current_rate, u8 fb_option) +{ + u16 rts_frame_len = 20; + + BBvCalculateParameter(priv, rts_frame_len, priv->byTopCCKBasicRate, + PK_TYPE_11B, &buf->b); + BBvCalculateParameter(priv, rts_frame_len, + priv->byTopOFDMBasicRate, pkt_type, &buf->a); + + buf->wDuration_bb = s_uGetRTSCTSDuration(priv, RTSDUR_BB, frame_len, + PK_TYPE_11B, priv->byTopCCKBasicRate, need_ack, fb_option); + buf->wDuration_aa = s_uGetRTSCTSDuration(priv, RTSDUR_AA, frame_len, + pkt_type, current_rate, need_ack, fb_option); + buf->wDuration_ba = s_uGetRTSCTSDuration(priv, RTSDUR_BA, frame_len, + pkt_type, current_rate, need_ack, fb_option); + + vnt_fill_ieee80211_rts(priv, &buf->data, eth_hdr, buf->wDuration_aa); + + return 0; +} + static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, void *pvRTS, u32 cbFrameLength, int bNeedAck, struct ethhdr *psEthHeader, u16 wCurrentRate, u8 byFBOption) @@ -609,35 +653,10 @@ static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { if (byFBOption == AUTO_FB_NONE) { struct vnt_rts_g *pBuf = (struct vnt_rts_g *)pvRTS; - //Get SignalField,ServiceField,Length - BBvCalculateParameter(pDevice, uRTSFrameLen, - pDevice->byTopCCKBasicRate, PK_TYPE_11B, &pBuf->b); - BBvCalculateParameter(pDevice, uRTSFrameLen, - pDevice->byTopOFDMBasicRate, byPktType, &pBuf->a); - //Get Duration - pBuf->wDuration_bb = s_uGetRTSCTSDuration(pDevice, RTSDUR_BB, - cbFrameLength, PK_TYPE_11B, - pDevice->byTopCCKBasicRate, bNeedAck, byFBOption); - pBuf->wDuration_aa = s_uGetRTSCTSDuration(pDevice, RTSDUR_AA, - cbFrameLength, byPktType, - wCurrentRate, bNeedAck, byFBOption); - pBuf->wDuration_ba = s_uGetRTSCTSDuration(pDevice, RTSDUR_BA, - cbFrameLength, byPktType, - wCurrentRate, bNeedAck, byFBOption); - pBuf->data.duration = pBuf->wDuration_aa; - /*Get RTS Frame body */ - pBuf->data.frame_control = TYPE_CTL_RTS; - if (pDevice->eOPMode == OP_MODE_ADHOC || - pDevice->eOPMode == OP_MODE_AP) - memcpy(pBuf->data.ra, psEthHeader->h_dest, ETH_ALEN); - else - memcpy(pBuf->data.ra, pDevice->abyBSSID, ETH_ALEN); - - if (pDevice->eOPMode == OP_MODE_AP) - memcpy(pBuf->data.ta, pDevice->abyBSSID, ETH_ALEN); - else - memcpy(pBuf->data.ta, psEthHeader->h_source, ETH_ALEN); + vnt_rxtx_rts_g_head(pDevice, pBuf, + psEthHeader, byPktType, cbFrameLength, + bNeedAck, wCurrentRate, byFBOption); } else { struct vnt_rts_g_fb *pBuf = (struct vnt_rts_g_fb *)pvRTS; -- GitLab From ec91713a29a3670d92212170323d5861d12ca228 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 26 Aug 2013 11:07:46 +0100 Subject: [PATCH 830/942] staging: vt6656: rxtx.c s_vFillRTSHead Parse out struct vnt_rts_g_fb to new function. Parse out vnt_rts_g_fb code to new function vnt_rxtx_rts_g_fb_head. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 78 +++++++++++++++++------------------ 1 file changed, 38 insertions(+), 40 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 57af55b391d0c..5cfdfafda6f4c 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -639,6 +639,41 @@ static int vnt_rxtx_rts_g_head(struct vnt_private *priv, return 0; } +static int vnt_rxtx_rts_g_fb_head(struct vnt_private *priv, + struct vnt_rts_g_fb *buf, struct ethhdr *eth_hdr, + u8 pkt_type, u32 frame_len, int need_ack, + u16 current_rate, u8 fb_option) +{ + u16 rts_frame_len = 20; + + BBvCalculateParameter(priv, rts_frame_len, priv->byTopCCKBasicRate, + PK_TYPE_11B, &buf->b); + BBvCalculateParameter(priv, rts_frame_len, + priv->byTopOFDMBasicRate, pkt_type, &buf->a); + + + buf->wDuration_bb = s_uGetRTSCTSDuration(priv, RTSDUR_BB, frame_len, + PK_TYPE_11B, priv->byTopCCKBasicRate, need_ack, fb_option); + buf->wDuration_aa = s_uGetRTSCTSDuration(priv, RTSDUR_AA, frame_len, + pkt_type, current_rate, need_ack, fb_option); + buf->wDuration_ba = s_uGetRTSCTSDuration(priv, RTSDUR_BA, frame_len, + pkt_type, current_rate, need_ack, fb_option); + + + buf->wRTSDuration_ba_f0 = s_uGetRTSCTSDuration(priv, RTSDUR_BA_F0, + frame_len, pkt_type, current_rate, need_ack, fb_option); + buf->wRTSDuration_aa_f0 = s_uGetRTSCTSDuration(priv, RTSDUR_AA_F0, + frame_len, pkt_type, current_rate, need_ack, fb_option); + buf->wRTSDuration_ba_f1 = s_uGetRTSCTSDuration(priv, RTSDUR_BA_F1, + frame_len, pkt_type, current_rate, need_ack, fb_option); + buf->wRTSDuration_aa_f1 = s_uGetRTSCTSDuration(priv, RTSDUR_AA_F1, + frame_len, pkt_type, current_rate, need_ack, fb_option); + + vnt_fill_ieee80211_rts(priv, &buf->data, eth_hdr, buf->wDuration_aa); + + return 0; +} + static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, void *pvRTS, u32 cbFrameLength, int bNeedAck, struct ethhdr *psEthHeader, u16 wCurrentRate, u8 byFBOption) @@ -660,47 +695,10 @@ static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, } else { struct vnt_rts_g_fb *pBuf = (struct vnt_rts_g_fb *)pvRTS; - //Get SignalField,ServiceField,Length - BBvCalculateParameter(pDevice, uRTSFrameLen, - pDevice->byTopCCKBasicRate, PK_TYPE_11B, &pBuf->b); - BBvCalculateParameter(pDevice, uRTSFrameLen, - pDevice->byTopOFDMBasicRate, byPktType, &pBuf->a); - //Get Duration - pBuf->wDuration_bb = s_uGetRTSCTSDuration(pDevice, RTSDUR_BB, - cbFrameLength, PK_TYPE_11B, - pDevice->byTopCCKBasicRate, bNeedAck, byFBOption); - pBuf->wDuration_aa = s_uGetRTSCTSDuration(pDevice, RTSDUR_AA, - cbFrameLength, byPktType, - wCurrentRate, bNeedAck, byFBOption); - pBuf->wDuration_ba = s_uGetRTSCTSDuration(pDevice, RTSDUR_BA, - cbFrameLength, byPktType, - wCurrentRate, bNeedAck, byFBOption); - pBuf->wRTSDuration_ba_f0 = s_uGetRTSCTSDuration(pDevice, - RTSDUR_BA_F0, cbFrameLength, byPktType, wCurrentRate, - bNeedAck, byFBOption); - pBuf->wRTSDuration_aa_f0 = s_uGetRTSCTSDuration(pDevice, - RTSDUR_AA_F0, cbFrameLength, byPktType, - wCurrentRate, bNeedAck, byFBOption); - pBuf->wRTSDuration_ba_f1 = s_uGetRTSCTSDuration(pDevice, - RTSDUR_BA_F1, cbFrameLength, byPktType, wCurrentRate, - bNeedAck, byFBOption); - pBuf->wRTSDuration_aa_f1 = s_uGetRTSCTSDuration(pDevice, - RTSDUR_AA_F1, cbFrameLength, byPktType, wCurrentRate, - bNeedAck, byFBOption); - pBuf->data.duration = pBuf->wDuration_aa; - /*Get RTS Frame body*/ - pBuf->data.frame_control = TYPE_CTL_RTS; - - if (pDevice->eOPMode == OP_MODE_ADHOC || - pDevice->eOPMode == OP_MODE_AP) - memcpy(pBuf->data.ra, psEthHeader->h_dest, ETH_ALEN); - else - memcpy(pBuf->data.ra, pDevice->abyBSSID, ETH_ALEN); - if (pDevice->eOPMode == OP_MODE_AP) - memcpy(pBuf->data.ta, pDevice->abyBSSID, ETH_ALEN); - else - memcpy(pBuf->data.ta, psEthHeader->h_source, ETH_ALEN); + vnt_rxtx_rts_g_fb_head(pDevice, pBuf, + psEthHeader, byPktType, cbFrameLength, + bNeedAck, wCurrentRate, byFBOption); } // if (byFBOption == AUTO_FB_NONE) } else if (byPktType == PK_TYPE_11A) { -- GitLab From 1712633d7297b94e3d8c182645b3c50c867dc405 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 26 Aug 2013 11:09:38 +0100 Subject: [PATCH 831/942] staging: vt6656: rxtx.c s_vFillRTSHead Parse out struct vnt_rts_ab to new function. Parse out vnt_rts_ab code to new function vnt_rxtx_rts_ab_head. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 65 +++++++++++++---------------------- 1 file changed, 24 insertions(+), 41 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 5cfdfafda6f4c..ce8018e2b16e5 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -674,6 +674,24 @@ static int vnt_rxtx_rts_g_fb_head(struct vnt_private *priv, return 0; } +static int vnt_rxtx_rts_ab_head(struct vnt_private *priv, + struct vnt_rts_ab *buf, struct ethhdr *eth_hdr, + u8 pkt_type, u32 frame_len, int need_ack, + u16 current_rate, u8 fb_option) +{ + u16 rts_frame_len = 20; + + BBvCalculateParameter(priv, rts_frame_len, + priv->byTopOFDMBasicRate, pkt_type, &buf->ab); + + buf->wDuration = s_uGetRTSCTSDuration(priv, RTSDUR_AA, frame_len, + pkt_type, current_rate, need_ack, fb_option); + + vnt_fill_ieee80211_rts(priv, &buf->data, eth_hdr, buf->wDuration); + + return 0; +} + static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, void *pvRTS, u32 cbFrameLength, int bNeedAck, struct ethhdr *psEthHeader, u16 wCurrentRate, u8 byFBOption) @@ -704,27 +722,10 @@ static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, else if (byPktType == PK_TYPE_11A) { if (byFBOption == AUTO_FB_NONE) { struct vnt_rts_ab *pBuf = (struct vnt_rts_ab *)pvRTS; - //Get SignalField,ServiceField,Length - BBvCalculateParameter(pDevice, uRTSFrameLen, - pDevice->byTopOFDMBasicRate, byPktType, &pBuf->ab); - //Get Duration - pBuf->wDuration = s_uGetRTSCTSDuration(pDevice, RTSDUR_AA, - cbFrameLength, byPktType, wCurrentRate, - bNeedAck, byFBOption); - pBuf->data.duration = pBuf->wDuration; - /* Get RTS Frame body */ - pBuf->data.frame_control = TYPE_CTL_RTS; - - if (pDevice->eOPMode == OP_MODE_ADHOC || - pDevice->eOPMode == OP_MODE_AP) - memcpy(pBuf->data.ra, psEthHeader->h_dest, ETH_ALEN); - else - memcpy(pBuf->data.ra, pDevice->abyBSSID, ETH_ALEN); - if (pDevice->eOPMode == OP_MODE_AP) - memcpy(pBuf->data.ta, pDevice->abyBSSID, ETH_ALEN); - else - memcpy(pBuf->data.ta, psEthHeader->h_source, ETH_ALEN); + vnt_rxtx_rts_ab_head(pDevice, pBuf, + psEthHeader, byPktType, cbFrameLength, + bNeedAck, wCurrentRate, byFBOption); } else { struct vnt_rts_a_fb *pBuf = (struct vnt_rts_a_fb *)pvRTS; @@ -759,28 +760,10 @@ static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, } else if (byPktType == PK_TYPE_11B) { struct vnt_rts_ab *pBuf = (struct vnt_rts_ab *)pvRTS; - //Get SignalField,ServiceField,Length - BBvCalculateParameter(pDevice, uRTSFrameLen, pDevice->byTopCCKBasicRate, - PK_TYPE_11B, &pBuf->ab); - //Get Duration - pBuf->wDuration = s_uGetRTSCTSDuration(pDevice, RTSDUR_BB, - cbFrameLength, byPktType, wCurrentRate, - bNeedAck, byFBOption); - - pBuf->data.duration = pBuf->wDuration; - /* Get RTS Frame body */ - pBuf->data.frame_control = TYPE_CTL_RTS; - - if (pDevice->eOPMode == OP_MODE_ADHOC || - pDevice->eOPMode == OP_MODE_AP) - memcpy(pBuf->data.ra, psEthHeader->h_dest, ETH_ALEN); - else - memcpy(pBuf->data.ra, pDevice->abyBSSID, ETH_ALEN); - if (pDevice->eOPMode == OP_MODE_AP) - memcpy(pBuf->data.ta, pDevice->abyBSSID, ETH_ALEN); - else - memcpy(pBuf->data.ta, psEthHeader->h_source, ETH_ALEN); + vnt_rxtx_rts_ab_head(pDevice, pBuf, + psEthHeader, byPktType, cbFrameLength, + bNeedAck, wCurrentRate, byFBOption); } } -- GitLab From 9d2578c1703a59e2815ead3519ec3bdd261f0d7e Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 26 Aug 2013 11:12:00 +0100 Subject: [PATCH 832/942] staging: vt6656: rxtx.c s_vFillRTSHead Parse out struct vnt_rts_a_fb to new function. Parse out vnt_rts_a_fb code to new function vnt_rxtx_rts_a_fb_head. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 54 +++++++++++++++++------------------ 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index ce8018e2b16e5..a45cc9f27eec1 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -692,11 +692,34 @@ static int vnt_rxtx_rts_ab_head(struct vnt_private *priv, return 0; } +static int vnt_rxtx_rts_a_fb_head(struct vnt_private *priv, + struct vnt_rts_a_fb *buf, struct ethhdr *eth_hdr, + u8 pkt_type, u32 frame_len, int need_ack, + u16 current_rate, u8 fb_option) +{ + u16 rts_frame_len = 20; + + BBvCalculateParameter(priv, rts_frame_len, + priv->byTopOFDMBasicRate, pkt_type, &buf->a); + + buf->wDuration = s_uGetRTSCTSDuration(priv, RTSDUR_AA, frame_len, + pkt_type, current_rate, need_ack, fb_option); + + buf->wRTSDuration_f0 = s_uGetRTSCTSDuration(priv, RTSDUR_AA_F0, + frame_len, pkt_type, current_rate, need_ack, fb_option); + + buf->wRTSDuration_f1 = s_uGetRTSCTSDuration(priv, RTSDUR_AA_F1, + frame_len, pkt_type, current_rate, need_ack, fb_option); + + vnt_fill_ieee80211_rts(priv, &buf->data, eth_hdr, buf->wDuration); + + return 0; +} + static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, void *pvRTS, u32 cbFrameLength, int bNeedAck, struct ethhdr *psEthHeader, u16 wCurrentRate, u8 byFBOption) { - u32 uRTSFrameLen = 20; if (pvRTS == NULL) return; @@ -729,33 +752,10 @@ static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, } else { struct vnt_rts_a_fb *pBuf = (struct vnt_rts_a_fb *)pvRTS; - //Get SignalField,ServiceField,Length - BBvCalculateParameter(pDevice, uRTSFrameLen, - pDevice->byTopOFDMBasicRate, byPktType, &pBuf->a); - //Get Duration - pBuf->wDuration = s_uGetRTSCTSDuration(pDevice, RTSDUR_AA, - cbFrameLength, byPktType, wCurrentRate, - bNeedAck, byFBOption); - pBuf->wRTSDuration_f0 = s_uGetRTSCTSDuration(pDevice, - RTSDUR_AA_F0, cbFrameLength, byPktType, - wCurrentRate, bNeedAck, byFBOption); - pBuf->wRTSDuration_f1 = s_uGetRTSCTSDuration(pDevice, - RTSDUR_AA_F1, cbFrameLength, byPktType, - wCurrentRate, bNeedAck, byFBOption); - pBuf->data.duration = pBuf->wDuration; - /* Get RTS Frame body */ - pBuf->data.frame_control = TYPE_CTL_RTS; - - if (pDevice->eOPMode == OP_MODE_ADHOC || - pDevice->eOPMode == OP_MODE_AP) - memcpy(pBuf->data.ra, psEthHeader->h_dest, ETH_ALEN); - else - memcpy(pBuf->data.ra, pDevice->abyBSSID, ETH_ALEN); - if (pDevice->eOPMode == OP_MODE_AP) - memcpy(pBuf->data.ta, pDevice->abyBSSID, ETH_ALEN); - else - memcpy(pBuf->data.ta, psEthHeader->h_source, ETH_ALEN); + vnt_rxtx_rts_a_fb_head(pDevice, pBuf, + psEthHeader, byPktType, cbFrameLength, + bNeedAck, wCurrentRate, byFBOption); } } else if (byPktType == PK_TYPE_11B) { -- GitLab From 13fe62ae6a471e7a9c8c11c72d18e650235909e3 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 26 Aug 2013 11:17:52 +0100 Subject: [PATCH 833/942] staging: vt6656: rxtx s_vFillRTSHead create union of vnt_rts*/vnt_cts* structures. Only one of vnt_rts*/vnt_cts* structures are accessed at any one time. Join these structures in to a single union. These will eventually form the tail structure of vnt_tx_buffer and include structures vnt_tx_datahead* Structures in s_vFillCTSHead will join in next patch series. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 25 ++++++++----------------- drivers/staging/vt6656/rxtx.h | 12 ++++++++++++ 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index a45cc9f27eec1..07854316ca593 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -720,48 +720,39 @@ static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, void *pvRTS, u32 cbFrameLength, int bNeedAck, struct ethhdr *psEthHeader, u16 wCurrentRate, u8 byFBOption) { + union vnt_tx_data_head *head = pvRTS; - if (pvRTS == NULL) - return; + if (!head) + return; // Note: So far RTSHead doesn't appear in ATIM & Beacom DMA, so we don't need to take them into account. // Otherwise, we need to modified codes for them. if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { if (byFBOption == AUTO_FB_NONE) { - struct vnt_rts_g *pBuf = (struct vnt_rts_g *)pvRTS; - - vnt_rxtx_rts_g_head(pDevice, pBuf, + vnt_rxtx_rts_g_head(pDevice, &head->rts_g, psEthHeader, byPktType, cbFrameLength, bNeedAck, wCurrentRate, byFBOption); } else { - struct vnt_rts_g_fb *pBuf = (struct vnt_rts_g_fb *)pvRTS; - - vnt_rxtx_rts_g_fb_head(pDevice, pBuf, + vnt_rxtx_rts_g_fb_head(pDevice, &head->rts_g_fb, psEthHeader, byPktType, cbFrameLength, bNeedAck, wCurrentRate, byFBOption); } // if (byFBOption == AUTO_FB_NONE) } else if (byPktType == PK_TYPE_11A) { if (byFBOption == AUTO_FB_NONE) { - struct vnt_rts_ab *pBuf = (struct vnt_rts_ab *)pvRTS; - - vnt_rxtx_rts_ab_head(pDevice, pBuf, + vnt_rxtx_rts_ab_head(pDevice, &head->rts_ab, psEthHeader, byPktType, cbFrameLength, bNeedAck, wCurrentRate, byFBOption); } else { - struct vnt_rts_a_fb *pBuf = (struct vnt_rts_a_fb *)pvRTS; - - vnt_rxtx_rts_a_fb_head(pDevice, pBuf, + vnt_rxtx_rts_a_fb_head(pDevice, &head->rts_a_fb, psEthHeader, byPktType, cbFrameLength, bNeedAck, wCurrentRate, byFBOption); } } else if (byPktType == PK_TYPE_11B) { - struct vnt_rts_ab *pBuf = (struct vnt_rts_ab *)pvRTS; - - vnt_rxtx_rts_ab_head(pDevice, pBuf, + vnt_rxtx_rts_ab_head(pDevice, &head->rts_ab, psEthHeader, byPktType, cbFrameLength, bNeedAck, wCurrentRate, byFBOption); } diff --git a/drivers/staging/vt6656/rxtx.h b/drivers/staging/vt6656/rxtx.h index ad6205255967d..4bbee1c2fcace 100644 --- a/drivers/staging/vt6656/rxtx.h +++ b/drivers/staging/vt6656/rxtx.h @@ -168,6 +168,18 @@ struct vnt_cts_fb { u16 reserved2; } __packed; +union vnt_tx_data_head { + /* rts g */ + struct vnt_rts_g rts_g; + struct vnt_rts_g_fb rts_g_fb; + /* rts a/b */ + struct vnt_rts_ab rts_ab; + struct vnt_rts_a_fb rts_a_fb; + /* cts g */ + struct vnt_cts cts_g; + struct vnt_cts_fb cts_g_fb; +}; + struct vnt_tx_buffer { u8 byType; u8 byPKTNO; -- GitLab From 9d5829bfbae67d3b185a1360185ea56af163147d Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Mon, 26 Aug 2013 11:21:11 +0100 Subject: [PATCH 834/942] staging: rxtx.c s_vFillRTSHead white space and formating clean up Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 39 ++++++++++++++++------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 07854316ca593..e97bc4098f89d 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -725,37 +725,34 @@ static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, if (!head) return; - // Note: So far RTSHead doesn't appear in ATIM & Beacom DMA, so we don't need to take them into account. - // Otherwise, we need to modified codes for them. - if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { - if (byFBOption == AUTO_FB_NONE) { - vnt_rxtx_rts_g_head(pDevice, &head->rts_g, + /* Note: So far RTSHead doesn't appear in ATIM + * & Beacom DMA, so we don't need to take them + * into account. + * Otherwise, we need to modified codes for them. + */ + if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { + if (byFBOption == AUTO_FB_NONE) + vnt_rxtx_rts_g_head(pDevice, &head->rts_g, psEthHeader, byPktType, cbFrameLength, bNeedAck, wCurrentRate, byFBOption); - } - else { - vnt_rxtx_rts_g_fb_head(pDevice, &head->rts_g_fb, + else + vnt_rxtx_rts_g_fb_head(pDevice, &head->rts_g_fb, psEthHeader, byPktType, cbFrameLength, bNeedAck, wCurrentRate, byFBOption); - } // if (byFBOption == AUTO_FB_NONE) - } - else if (byPktType == PK_TYPE_11A) { - if (byFBOption == AUTO_FB_NONE) { - vnt_rxtx_rts_ab_head(pDevice, &head->rts_ab, + } else if (byPktType == PK_TYPE_11A) { + if (byFBOption == AUTO_FB_NONE) + vnt_rxtx_rts_ab_head(pDevice, &head->rts_ab, psEthHeader, byPktType, cbFrameLength, bNeedAck, wCurrentRate, byFBOption); - } - else { - vnt_rxtx_rts_a_fb_head(pDevice, &head->rts_a_fb, + else + vnt_rxtx_rts_a_fb_head(pDevice, &head->rts_a_fb, psEthHeader, byPktType, cbFrameLength, bNeedAck, wCurrentRate, byFBOption); - } - } - else if (byPktType == PK_TYPE_11B) { - vnt_rxtx_rts_ab_head(pDevice, &head->rts_ab, + } else if (byPktType == PK_TYPE_11B) { + vnt_rxtx_rts_ab_head(pDevice, &head->rts_ab, psEthHeader, byPktType, cbFrameLength, bNeedAck, wCurrentRate, byFBOption); - } + } } static void s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx, -- GitLab From 050596a488d7de6bef1ab60d25cecadf96aa788a Mon Sep 17 00:00:00 2001 From: Rupesh Gujare Date: Fri, 23 Aug 2013 18:33:28 +0100 Subject: [PATCH 835/942] staging: ozwpan: Check for correct config number. Check for valid config number before completing set interface. Signed-off-by: Rupesh Gujare Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozhcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c index ab93b74e34be4..83ed64c728721 100644 --- a/drivers/staging/ozwpan/ozhcd.c +++ b/drivers/staging/ozwpan/ozhcd.c @@ -909,7 +909,7 @@ static void oz_hcd_complete_set_interface(struct oz_port *port, struct urb *urb, struct usb_hcd *hcd = port->ozhcd->hcd; int rc = 0; - if (rcode == 0) { + if ((rcode == 0) && (port->config_num > 0)) { struct usb_host_config *config; struct usb_host_interface *intf; oz_dbg(ON, "Set interface %d alt %d\n", if_num, alt); -- GitLab From 0f750be948852325f84466d136316ef510e7fd7b Mon Sep 17 00:00:00 2001 From: Rupesh Gujare Date: Fri, 23 Aug 2013 18:33:29 +0100 Subject: [PATCH 836/942] staging: ozwpan: Convert hard coded value to Macro Use macro instead of hard coded value for readability. Signed-off-by: Rupesh Gujare Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozhcd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c index 83ed64c728721..89e498b245e66 100644 --- a/drivers/staging/ozwpan/ozhcd.c +++ b/drivers/staging/ozwpan/ozhcd.c @@ -73,6 +73,7 @@ struct oz_urb_link { /* Holds state information about a USB endpoint. */ +#define OZ_EP_BUFFER_SIZE_ISOC (1024 * 24) struct oz_endpoint { struct list_head urb_list; /* List of oz_urb_link items. */ struct list_head link; /* For isoc ep, links in to isoc @@ -1261,7 +1262,7 @@ static int oz_build_endpoints_for_interface(struct usb_hcd *hcd, switch (hep->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) { case USB_ENDPOINT_XFER_ISOC: - buffer_size = 24*1024; + buffer_size = OZ_EP_BUFFER_SIZE_ISOC; break; case USB_ENDPOINT_XFER_INT: buffer_size = 128; -- GitLab From 00d2a46ca90619d93d913935844c7f456284ab16 Mon Sep 17 00:00:00 2001 From: Rupesh Gujare Date: Fri, 23 Aug 2013 18:33:30 +0100 Subject: [PATCH 837/942] staging: ozwpan: Increase interrupt end point buffer size Increase interrupt end point buffer size & convert hard coded value to macro for better readability. Signed-off-by: Rupesh Gujare Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozhcd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c index 89e498b245e66..16fd60b5f5c74 100644 --- a/drivers/staging/ozwpan/ozhcd.c +++ b/drivers/staging/ozwpan/ozhcd.c @@ -74,6 +74,7 @@ struct oz_urb_link { /* Holds state information about a USB endpoint. */ #define OZ_EP_BUFFER_SIZE_ISOC (1024 * 24) +#define OZ_EP_BUFFER_SIZE_INT 512 struct oz_endpoint { struct list_head urb_list; /* List of oz_urb_link items. */ struct list_head link; /* For isoc ep, links in to isoc @@ -1265,7 +1266,7 @@ static int oz_build_endpoints_for_interface(struct usb_hcd *hcd, buffer_size = OZ_EP_BUFFER_SIZE_ISOC; break; case USB_ENDPOINT_XFER_INT: - buffer_size = 128; + buffer_size = OZ_EP_BUFFER_SIZE_INT; break; } } -- GitLab From 4882ad9561d2a719ac9fb269bf0567141fd9892e Mon Sep 17 00:00:00 2001 From: Rupesh Gujare Date: Fri, 23 Aug 2013 18:33:31 +0100 Subject: [PATCH 838/942] staging: ozwpan: change variable type. We have icreased interrupt end point buffer size to 512 bytes, Change variable data type to accomodate it. Signed-off-by: Rupesh Gujare Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozhcd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c index 16fd60b5f5c74..35488608df7a3 100644 --- a/drivers/staging/ozwpan/ozhcd.c +++ b/drivers/staging/ozwpan/ozhcd.c @@ -441,9 +441,9 @@ static void oz_complete_buffered_urb(struct oz_port *port, struct oz_endpoint *ep, struct urb *urb) { - u8 data_len, available_space, copy_len; + int data_len, available_space, copy_len; - memcpy(&data_len, &ep->buffer[ep->out_ix], sizeof(u8)); + data_len = ep->buffer[ep->out_ix]; if (data_len <= urb->transfer_buffer_length) available_space = data_len; else -- GitLab From 37bc8f7856fc0c851980f01174ca936741511523 Mon Sep 17 00:00:00 2001 From: Rupesh Gujare Date: Fri, 23 Aug 2013 18:33:32 +0100 Subject: [PATCH 839/942] staging: ozwpan: Fix error checking while transmitting frame. Make sure that we return negative value if oz_build_frame() returns NULL. Signed-off-by: Rupesh Gujare Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozpd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/ozwpan/ozpd.c b/drivers/staging/ozwpan/ozpd.c index daaff2af14ae0..e1757aa27253f 100644 --- a/drivers/staging/ozwpan/ozpd.c +++ b/drivers/staging/ozwpan/ozpd.c @@ -618,14 +618,14 @@ static int oz_send_next_queued_frame(struct oz_pd *pd, int more_data) pd->last_sent_frame = e; skb = oz_build_frame(pd, f); spin_unlock(&pd->tx_frame_lock); + if (!skb) + return -1; if (more_data) oz_set_more_bit(skb); oz_dbg(TX_FRAMES, "TX frame PN=0x%x\n", f->hdr.pkt_num); - if (skb) { - if (dev_queue_xmit(skb) < 0) - return -1; + if (dev_queue_xmit(skb) < 0) + return -1; - } return 0; } -- GitLab From 0472c9890d7deaf39404206081b3d616594d6dff Mon Sep 17 00:00:00 2001 From: Rupesh Gujare Date: Fri, 23 Aug 2013 18:33:33 +0100 Subject: [PATCH 840/942] staging: ozwpan: change max. TX frame size supported. Max. TX frame size supported is changed to 760 bytes. Signed-off-by: Rupesh Gujare Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozproto.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/ozwpan/ozproto.h b/drivers/staging/ozwpan/ozproto.h index e532347cfdfda..0c49c8a0e815f 100644 --- a/drivers/staging/ozwpan/ozproto.h +++ b/drivers/staging/ozwpan/ozproto.h @@ -19,7 +19,7 @@ #define OZ_PRESLEEP_TOUT 11 /* Maximun sizes of tx frames. */ -#define OZ_MAX_TX_SIZE 1514 +#define OZ_MAX_TX_SIZE 760 /* Maximum number of uncompleted isoc frames that can be pending in network. */ #define OZ_MAX_SUBMITTED_ISOC 16 -- GitLab From 30224b5e0b8251ae6738ba7c4685ff0bb1d718ce Mon Sep 17 00:00:00 2001 From: navin patidar Date: Mon, 26 Aug 2013 08:25:50 +0530 Subject: [PATCH 841/942] staging: rtl8192e: Remove pt_regs * irq handler parameter struct pt_regs pointer is no longer passed as a irq handler argument. and also remove unnecessary macros. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 5 +++-- drivers/staging/rtl8192e/rtl8192e/rtl_core.h | 6 ------ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index 2b6c61c5d3d8b..d952a347679da 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -94,6 +94,7 @@ MODULE_DEVICE_TABLE(pci, rtl8192_pci_id_tbl); static int rtl8192_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id); static void rtl8192_pci_disconnect(struct pci_dev *pdev); +static irqreturn_t rtl8192_interrupt(int irq, void *netdev); static struct pci_driver rtl8192_pci_driver = { .name = DRV_NAME, /* Driver name */ @@ -1324,7 +1325,7 @@ static short rtl8192_init(struct net_device *dev) (unsigned long)dev); rtl8192_irq_disable(dev); - if (request_irq(dev->irq, (void *)rtl8192_interrupt_rsl, IRQF_SHARED, + if (request_irq(dev->irq, rtl8192_interrupt, IRQF_SHARED, dev->name, dev)) { printk(KERN_ERR "Error allocating IRQ %d", dev->irq); return -1; @@ -2704,7 +2705,7 @@ static int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) } -irqreturn_type rtl8192_interrupt(int irq, void *netdev, struct pt_regs *regs) +irqreturn_t rtl8192_interrupt(int irq, void *netdev) { struct net_device *dev = (struct net_device *) netdev; struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv(dev); diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h index 87d4d349c8905..9d7cb0edb2d36 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h @@ -88,10 +88,6 @@ .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID , \ .driver_data = (kernel_ulong_t)&(cfg) -#define irqreturn_type irqreturn_t - -#define rtl8192_interrupt(x, y, z) rtl8192_interrupt_rsl(x, y) - #define RTL_MAX_SCAN_SIZE 128 #define RTL_RATE_MAX 30 @@ -1044,8 +1040,6 @@ void rtl8192_set_chan(struct net_device *dev, short ch); void check_rfctrl_gpio_timer(unsigned long data); void rtl8192_hw_wakeup_wq(void *data); -irqreturn_type rtl8192_interrupt(int irq, void *netdev, struct pt_regs *regs); - short rtl8192_pci_initdescring(struct net_device *dev); void rtl8192_cancel_deferred_work(struct r8192_priv *priv); -- GitLab From 2b2843264260d4d6c4afd0fecf6082736ff86b78 Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Sun, 25 Aug 2013 10:10:14 +0900 Subject: [PATCH 842/942] staging: lustre: Fix typo in lustre/lnet Correct spelling typo in comments and debug messages. Signed-off-by: Masanari Iida Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/include/linux/lnet/lib-types.h | 2 +- drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c | 6 +++--- drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 4 ++-- .../staging/lustre/lnet/klnds/socklnd/socklnd_proto.c | 2 +- drivers/staging/lustre/lnet/lnet/lib-msg.c | 10 +++++----- drivers/staging/lustre/lnet/selftest/brw_test.c | 2 +- drivers/staging/lustre/lnet/selftest/conrpc.c | 2 +- drivers/staging/lustre/lnet/selftest/rpc.c | 2 +- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h index 538e4ffa7a184..e579e7ed50706 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h @@ -619,7 +619,7 @@ typedef struct lnet_portal { unsigned int ptl_index; /* portal ID, reserved */ /* flags on this portal: lazy, unique... */ unsigned int ptl_options; - /* list of messags which are stealing buffer */ + /* list of messages which are stealing buffer */ struct list_head ptl_msg_stealing; /* messages blocking for MD */ struct list_head ptl_msg_delayed; diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c index 1f367638eec43..6825b452e5fe6 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c @@ -1441,7 +1441,7 @@ ksocknal_close_conn_locked (ksock_conn_t *conn, int error) conn->ksnc_route = NULL; -#if 0 /* irrelevent with only eager routes */ +#if 0 /* irrelevant with only eager routes */ /* make route least favourite */ list_del (&route->ksnr_list); list_add_tail (&route->ksnr_list, &peer->ksnp_routes); @@ -1496,7 +1496,7 @@ ksocknal_peer_failed (ksock_peer_t *peer) /* There has been a connection failure or comms error; but I'll only * tell LNET I think the peer is dead if it's to another kernel and - * there are no connections or connection attempts in existance. */ + * there are no connections or connection attempts in existence. */ read_lock(&ksocknal_data.ksnd_global_lock); @@ -2358,7 +2358,7 @@ ksocknal_new_incarnation (void) /* The incarnation number is the time this module loaded and it * identifies this particular instance of the socknal. Hopefully * we won't be able to reboot more frequently than 1MHz for the - * forseeable future :) */ + * foreseeable future :) */ do_gettimeofday(&tv); diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c index 727f352e88609..2c581b7fa8ade 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c @@ -1116,7 +1116,7 @@ ksocknal_process_receive (ksock_conn_t *conn) LASSERT (atomic_read(&conn->ksnc_conn_refcount) > 0); /* NB: sched lock NOT held */ - /* SOCKNAL_RX_LNET_HEADER is here for backward compatability */ + /* SOCKNAL_RX_LNET_HEADER is here for backward compatibility */ LASSERT (conn->ksnc_rx_state == SOCKNAL_RX_KSM_HEADER || conn->ksnc_rx_state == SOCKNAL_RX_LNET_PAYLOAD || conn->ksnc_rx_state == SOCKNAL_RX_LNET_HEADER || @@ -1985,7 +1985,7 @@ ksocknal_connect (ksock_route_t *route) list_splice_init(&peer->ksnp_tx_queue, &zombies); } -#if 0 /* irrelevent with only eager routes */ +#if 0 /* irrelevant with only eager routes */ if (!route->ksnr_deleted) { /* make this route least-favourite for re-selection */ list_del(&route->ksnr_list); diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c index 6f7147dd36e58..71205e2015ce5 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c @@ -218,7 +218,7 @@ ksocknal_queue_tx_zcack_v3(ksock_conn_t *conn, if (tx->tx_msg.ksm_zc_cookies[0] > tx->tx_msg.ksm_zc_cookies[1]) { __u64 tmp = 0; - /* two seperated cookies: (a+2, a) or (a+1, a) */ + /* two separated cookies: (a+2, a) or (a+1, a) */ LASSERT (tx->tx_msg.ksm_zc_cookies[0] - tx->tx_msg.ksm_zc_cookies[1] <= 2); diff --git a/drivers/staging/lustre/lnet/lnet/lib-msg.c b/drivers/staging/lustre/lnet/lnet/lib-msg.c index fc7ba42a4dd1a..61ae88be6f021 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-msg.c +++ b/drivers/staging/lustre/lnet/lnet/lib-msg.c @@ -316,7 +316,7 @@ lnet_msg_attach_md(lnet_msg_t *msg, lnet_libmd_t *md, LASSERT(!msg->msg_routing); msg->msg_md = md; - if (msg->msg_receiving) { /* commited for receiving */ + if (msg->msg_receiving) { /* committed for receiving */ msg->msg_offset = offset; msg->msg_wanted = mlen; } @@ -392,7 +392,7 @@ lnet_complete_msg_locked(lnet_msg_t *msg, int cpt) * NB: message is committed for sending, we should return * on success because LND will finalize this message later. * - * Also, there is possibility that message is commited for + * Also, there is possibility that message is committed for * sending and also failed before delivering to LND, * i.e: ENOMEM, in that case we can't fall through either * because CPT for sending can be different with CPT for @@ -414,7 +414,7 @@ lnet_complete_msg_locked(lnet_msg_t *msg, int cpt) * NB: message is committed for sending, we should return * on success because LND will finalize this message later. * - * Also, there is possibility that message is commited for + * Also, there is possibility that message is committed for * sending and also failed before delivering to LND, * i.e: ENOMEM, in that case we can't fall through either: * - The rule is message must decommit for sending first if @@ -474,14 +474,14 @@ lnet_finalize (lnet_ni_t *ni, lnet_msg_t *msg, int status) again: rc = 0; if (!msg->msg_tx_committed && !msg->msg_rx_committed) { - /* not commited to network yet */ + /* not committed to network yet */ LASSERT(!msg->msg_onactivelist); lnet_msg_free(msg); return; } /* - * NB: routed message can be commited for both receiving and sending, + * NB: routed message can be committed for both receiving and sending, * we should finalize in LIFO order and keep counters correct. * (finalize sending first then finalize receiving) */ diff --git a/drivers/staging/lustre/lnet/selftest/brw_test.c b/drivers/staging/lustre/lnet/selftest/brw_test.c index 3bb6fbe23f782..ef5064e0055f2 100644 --- a/drivers/staging/lustre/lnet/selftest/brw_test.c +++ b/drivers/staging/lustre/lnet/selftest/brw_test.c @@ -361,7 +361,7 @@ brw_server_rpc_done (srpc_server_rpc_t *rpc) blk->bk_sink ? "from" : "to", libcfs_id2str(rpc->srpc_peer), rpc->srpc_status); else - CDEBUG (D_NET, "Transfered %d pages bulk data %s %s\n", + CDEBUG (D_NET, "Transferred %d pages bulk data %s %s\n", blk->bk_niov, blk->bk_sink ? "from" : "to", libcfs_id2str(rpc->srpc_peer)); diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.c b/drivers/staging/lustre/lnet/selftest/conrpc.c index 446de0e4672ff..cbce662b987bd 100644 --- a/drivers/staging/lustre/lnet/selftest/conrpc.c +++ b/drivers/staging/lustre/lnet/selftest/conrpc.c @@ -1356,7 +1356,7 @@ lstcon_rpc_cleanup_wait(void) lst_wait_until((atomic_read(&console_session.ses_rpc_counter) == 0), console_session.ses_rpc_lock, - "Network is not accessable or target is down, " + "Network is not accessible or target is down, " "waiting for %d console RPCs to being recycled\n", atomic_read(&console_session.ses_rpc_counter)); diff --git a/drivers/staging/lustre/lnet/selftest/rpc.c b/drivers/staging/lustre/lnet/selftest/rpc.c index 0dfc76e02e0bd..7659a26676bbe 100644 --- a/drivers/staging/lustre/lnet/selftest/rpc.c +++ b/drivers/staging/lustre/lnet/selftest/rpc.c @@ -1117,7 +1117,7 @@ srpc_del_client_rpc_timer (srpc_client_rpc_t *rpc) if (rpc->crpc_timeout == 0) return; - /* timer sucessfully defused */ + /* timer successfully defused */ if (stt_del_timer(&rpc->crpc_timer)) return; -- GitLab From b0b15cb27d0ae43ea15e10c7693781e92e92a370 Mon Sep 17 00:00:00 2001 From: Chen Gang Date: Mon, 26 Aug 2013 11:55:50 +0800 Subject: [PATCH 843/942] staging: dgnc: Kconfig: add dependency PCI for it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DGNC is based on PCI, so need add related dependency, or when compiled with PCI disabled, it will be fail. The related error (randconfig for PCI disabled under s390): drivers/staging/dgnc/dgnc_cls.c:1394:2: error: implicit declaration of function ‘ioremap’ [-Werror=implicit-function-declaration] drivers/staging/dgnc/dgnc_cls.c:1407:3: error: implicit declaration of function ‘iounmap’ [-Werror=implicit-function-declaration] Cc: Lidza Louina Signed-off-by: Chen Gang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/dgnc/Kconfig b/drivers/staging/dgnc/Kconfig index 23daaa5d520ee..032c2a7952389 100644 --- a/drivers/staging/dgnc/Kconfig +++ b/drivers/staging/dgnc/Kconfig @@ -1,6 +1,6 @@ config DGNC tristate "Digi Neo and Classic PCI Products" default n - depends on TTY + depends on TTY && PCI ---help--- Driver for the Digi International Neo and Classic PCI based product line. -- GitLab From 06d7e063b239d71d1e8dbfda60c759a244495125 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 23 Aug 2013 14:44:56 +0100 Subject: [PATCH 844/942] staging: comedi: comedi_bond: reformat some comments Reformat some comments according to CodingStyle and remove some comments inherited from the comedi 'skel' example driver. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/comedi_bond.c | 141 ++++++++++--------- 1 file changed, 73 insertions(+), 68 deletions(-) diff --git a/drivers/staging/comedi/drivers/comedi_bond.c b/drivers/staging/comedi/drivers/comedi_bond.c index 7e20bf00759ce..32a26f2199344 100644 --- a/drivers/staging/comedi/drivers/comedi_bond.c +++ b/drivers/staging/comedi/drivers/comedi_bond.c @@ -1,49 +1,50 @@ /* - comedi/drivers/comedi_bond.c - A Comedi driver to 'bond' or merge multiple drivers and devices as one. - - COMEDI - Linux Control and Measurement Device Interface - Copyright (C) 2000 David A. Schleef - Copyright (C) 2005 Calin A. Culianu - - 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 the License, or - (at your option) any later version. - - 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. -*/ + * comedi_bond.c + * A Comedi driver to 'bond' or merge multiple drivers and devices as one. + * + * COMEDI - Linux Control and Measurement Device Interface + * Copyright (C) 2000 David A. Schleef + * Copyright (C) 2005 Calin A. Culianu + * + * 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 the License, or + * (at your option) any later version. + * + * 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. + */ + /* -Driver: comedi_bond -Description: A driver to 'bond' (merge) multiple subdevices from multiple - devices together as one. -Devices: -Author: ds -Updated: Mon, 10 Oct 00:18:25 -0500 -Status: works - -This driver allows you to 'bond' (merge) multiple comedi subdevices -(coming from possibly difference boards and/or drivers) together. For -example, if you had a board with 2 different DIO subdevices, and -another with 1 DIO subdevice, you could 'bond' them with this driver -so that they look like one big fat DIO subdevice. This makes writing -applications slightly easier as you don't have to worry about managing -different subdevices in the application -- you just worry about -indexing one linear array of channel id's. - -Right now only DIO subdevices are supported as that's the personal itch -I am scratching with this driver. If you want to add support for AI and AO -subdevs, go right on ahead and do so! - -Commands aren't supported -- although it would be cool if they were. - -Configuration Options: - List of comedi-minors to bond. All subdevices of the same type - within each minor will be concatenated together in the order given here. -*/ + * Driver: comedi_bond + * Description: A driver to 'bond' (merge) multiple subdevices from multiple + * devices together as one. + * Devices: + * Author: ds + * Updated: Mon, 10 Oct 00:18:25 -0500 + * Status: works + * + * This driver allows you to 'bond' (merge) multiple comedi subdevices + * (coming from possibly difference boards and/or drivers) together. For + * example, if you had a board with 2 different DIO subdevices, and + * another with 1 DIO subdevice, you could 'bond' them with this driver + * so that they look like one big fat DIO subdevice. This makes writing + * applications slightly easier as you don't have to worry about managing + * different subdevices in the application -- you just worry about + * indexing one linear array of channel id's. + * + * Right now only DIO subdevices are supported as that's the personal itch + * I am scratching with this driver. If you want to add support for AI and AO + * subdevs, go right on ahead and do so! + * + * Commands aren't supported -- although it would be cool if they were. + * + * Configuration Options: + * List of comedi-minors to bond. All subdevices of the same type + * within each minor will be concatenated together in the order given here. + */ #include #include @@ -62,13 +63,10 @@ struct BondedDevice { unsigned subdev_type; unsigned nchans; unsigned chanid_offset; /* The offset into our unified linear - channel-id's of chanid 0 on this - subdevice. */ + * channel-id's of chanid 0 on this + * subdevice. */ }; -/* this structure is for data unique to this hardware driver. If - several hardware drivers keep similar information in this structure, - feel free to suggest moving the variable to the struct comedi_device struct. */ struct comedi_bond_private { # define MAX_BOARD_NAME 256 char name[MAX_BOARD_NAME]; @@ -78,11 +76,6 @@ struct comedi_bond_private { unsigned nchans; }; -/* DIO devices are slightly special. Although it is possible to - * implement the insn_read/insn_write interface, it is much more - * useful to applications if you implement the insn_bits interface. - * This allows packed reading/writing of the DIO channels. The - * comedi core can convert between insn_bits and insn_read/write */ static int bonding_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) @@ -94,13 +87,17 @@ static int bonding_dio_insn_bits(struct comedi_device *dev, if (devpriv->nchans < nchans) nchans = devpriv->nchans; - /* The insn data is a mask in data[0] and the new data - * in data[1], each channel cooresponding to a bit. */ + /* + * The insn data is a mask in data[0] and the new data + * in data[1], each channel cooresponding to a bit. + */ for (i = 0; num_done < nchans && i < devpriv->ndevs; ++i) { struct BondedDevice *bdev = devpriv->devs[i]; - /* Grab the channel mask and data of only the bits corresponding - to this subdevice.. need to shift them to zero position of - course. */ + /* + * Grab the channel mask and data of only the bits corresponding + * to this subdevice.. need to shift them to zero position of + * course. + */ /* Bits corresponding to this subdev. */ unsigned int subdevMask = ((1 << bdev->nchans) - 1); unsigned int writeMask, dataBits; @@ -143,10 +140,12 @@ static int bonding_dio_insn_config(struct comedi_device *dev, return -EINVAL; bdev = devpriv->chanIdDevMap[chan]; - /* The input or output configuration of each digital line is + /* + * The input or output configuration of each digital line is * configured by a special insn_config instruction. chanspec * contains the channel to be changed, and data[0] contains the - * value COMEDI_INPUT or COMEDI_OUTPUT. */ + * value COMEDI_INPUT or COMEDI_OUTPUT. + */ switch (data[0]) { case INSN_CONFIG_DIO_OUTPUT: io = COMEDI_OUTPUT; /* is this really necessary? */ @@ -170,8 +169,10 @@ static int bonding_dio_insn_config(struct comedi_device *dev, ret = comedi_dio_config(bdev->dev, bdev->subdev, chan, io); if (ret != 1) return -EINVAL; - /* Finally, save the new io_bits values since we didn't get - an error above. */ + /* + * Finally, save the new io_bits values since we didn't get an error + * above. + */ s->io_bits = io_bits; return insn->n; } @@ -194,8 +195,10 @@ static int doDevConfig(struct comedi_device *dev, struct comedi_devconfig *it) memset(devs_opened, 0, sizeof(devs_opened)); devpriv->name[0] = 0; - /* Loop through all comedi devices specified on the command-line, - building our device list */ + /* + * Loop through all comedi devices specified on the command-line, + * building our device list. + */ for (i = 0; i < COMEDI_NDEVCONFOPTS && (!i || it->options[i]); ++i) { char file[] = "/dev/comediXXXXXX"; int minor = it->options[i]; @@ -255,8 +258,10 @@ static int doDevConfig(struct comedi_device *dev, struct comedi_devconfig *it) while (nchans--) devpriv->chanIdDevMap[devpriv->nchans++] = bdev; - /* Now put bdev pointer at end of devpriv->devs array - * list.. */ + /* + * Now put bdev pointer at end of devpriv->devs array + * list.. + */ /* ergh.. ugly.. we need to realloc :( */ tmp = devpriv->ndevs * sizeof(bdev); @@ -271,7 +276,7 @@ static int doDevConfig(struct comedi_device *dev, struct comedi_devconfig *it) devpriv->devs[devpriv->ndevs - 1] = bdev; { - /** Append dev:subdev to devpriv->name */ + /* Append dev:subdev to devpriv->name */ char buf[20]; int left = MAX_BOARD_NAME - strlen(devpriv->name) - 1; -- GitLab From 0cc194998f0de93965e69ae0a6ea59cba125b27d Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 23 Aug 2013 14:44:57 +0100 Subject: [PATCH 845/942] staging: comedi: comedi_bond: shorten module description Omit the fanciful prose from the MODULE_DESCRIPTION() line and combine concantenated string literals. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/comedi_bond.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/comedi_bond.c b/drivers/staging/comedi/drivers/comedi_bond.c index 32a26f2199344..a995b0b7ca350 100644 --- a/drivers/staging/comedi/drivers/comedi_bond.c +++ b/drivers/staging/comedi/drivers/comedi_bond.c @@ -371,7 +371,5 @@ static struct comedi_driver bonding_driver = { module_comedi_driver(bonding_driver); MODULE_AUTHOR("Calin A. Culianu"); -MODULE_DESCRIPTION("comedi_bond: A driver for COMEDI to bond multiple COMEDI " - "devices together as one. In the words of John Lennon: " - "'And the world will live as one...'"); +MODULE_DESCRIPTION("comedi_bond: A driver for COMEDI to bond multiple COMEDI devices together as one."); MODULE_LICENSE("GPL"); -- GitLab From c2b03cec564afc8c313f39ca7a7b654e8ebda079 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 23 Aug 2013 14:44:58 +0100 Subject: [PATCH 846/942] staging: comedi: comedi_bond: rename CamelCase identifiers Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/comedi_bond.c | 47 ++++++++++---------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/drivers/staging/comedi/drivers/comedi_bond.c b/drivers/staging/comedi/drivers/comedi_bond.c index a995b0b7ca350..253a67da8e03b 100644 --- a/drivers/staging/comedi/drivers/comedi_bond.c +++ b/drivers/staging/comedi/drivers/comedi_bond.c @@ -56,7 +56,7 @@ /* The maxiumum number of channels per subdevice. */ #define MAX_CHANS 256 -struct BondedDevice { +struct bonded_device { struct comedi_device *dev; unsigned minor; unsigned subdev; @@ -70,9 +70,9 @@ struct BondedDevice { struct comedi_bond_private { # define MAX_BOARD_NAME 256 char name[MAX_BOARD_NAME]; - struct BondedDevice **devs; + struct bonded_device **devs; unsigned ndevs; - struct BondedDevice *chanIdDevMap[MAX_CHANS]; + struct bonded_device *chan_id_dev_map[MAX_CHANS]; unsigned nchans; }; @@ -92,32 +92,32 @@ static int bonding_dio_insn_bits(struct comedi_device *dev, * in data[1], each channel cooresponding to a bit. */ for (i = 0; num_done < nchans && i < devpriv->ndevs; ++i) { - struct BondedDevice *bdev = devpriv->devs[i]; + struct bonded_device *bdev = devpriv->devs[i]; /* * Grab the channel mask and data of only the bits corresponding * to this subdevice.. need to shift them to zero position of * course. */ /* Bits corresponding to this subdev. */ - unsigned int subdevMask = ((1 << bdev->nchans) - 1); - unsigned int writeMask, dataBits; + unsigned int subdev_mask = ((1 << bdev->nchans) - 1); + unsigned int write_mask, data_bits; /* Argh, we have >= LSAMPL_BITS chans.. take all bits */ if (bdev->nchans >= LSAMPL_BITS) - subdevMask = (unsigned int)(-1); + subdev_mask = (unsigned int)(-1); - writeMask = (data[0] >> num_done) & subdevMask; - dataBits = (data[1] >> num_done) & subdevMask; + write_mask = (data[0] >> num_done) & subdev_mask; + data_bits = (data[1] >> num_done) & subdev_mask; /* Read/Write the new digital lines */ - if (comedi_dio_bitfield(bdev->dev, bdev->subdev, writeMask, - &dataBits) != 2) + if (comedi_dio_bitfield(bdev->dev, bdev->subdev, write_mask, + &data_bits) != 2) return -EINVAL; /* Make room for the new bits in data[1], the return value */ - data[1] &= ~(subdevMask << num_done); + data[1] &= ~(subdev_mask << num_done); /* Put the bits in the return value */ - data[1] |= (dataBits & subdevMask) << num_done; + data[1] |= (data_bits & subdev_mask) << num_done; /* Save the new bits to the saved state.. */ s->state = data[1]; @@ -134,11 +134,11 @@ static int bonding_dio_insn_config(struct comedi_device *dev, struct comedi_bond_private *devpriv = dev->private; int chan = CR_CHAN(insn->chanspec), ret, io_bits = s->io_bits; unsigned int io; - struct BondedDevice *bdev; + struct bonded_device *bdev; if (chan < 0 || chan >= devpriv->nchans) return -EINVAL; - bdev = devpriv->chanIdDevMap[chan]; + bdev = devpriv->chan_id_dev_map[chan]; /* * The input or output configuration of each digital line is @@ -177,7 +177,7 @@ static int bonding_dio_insn_config(struct comedi_device *dev, return insn->n; } -static void *Realloc(const void *oldmem, size_t newlen, size_t oldlen) +static void *realloc(const void *oldmem, size_t newlen, size_t oldlen) { void *newmem = kmalloc(newlen, GFP_KERNEL); @@ -187,7 +187,7 @@ static void *Realloc(const void *oldmem, size_t newlen, size_t oldlen) return newmem; } -static int doDevConfig(struct comedi_device *dev, struct comedi_devconfig *it) +static int do_dev_config(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_bond_private *devpriv = dev->private; int i; @@ -204,7 +204,7 @@ static int doDevConfig(struct comedi_device *dev, struct comedi_devconfig *it) int minor = it->options[i]; struct comedi_device *d; int sdev = -1, nchans, tmp; - struct BondedDevice *bdev = NULL; + struct bonded_device *bdev = NULL; if (minor < 0 || minor >= COMEDI_NUM_BOARD_MINORS) { dev_err(dev->class_dev, @@ -254,9 +254,10 @@ static int doDevConfig(struct comedi_device *dev, struct comedi_devconfig *it) bdev->nchans = nchans; bdev->chanid_offset = devpriv->nchans; - /* map channel id's to BondedDevice * pointer.. */ + /* map channel id's to bonded_device * pointer.. */ while (nchans--) - devpriv->chanIdDevMap[devpriv->nchans++] = bdev; + devpriv->chan_id_dev_map[devpriv->nchans++] = + bdev; /* * Now put bdev pointer at end of devpriv->devs array @@ -266,7 +267,7 @@ static int doDevConfig(struct comedi_device *dev, struct comedi_devconfig *it) /* ergh.. ugly.. we need to realloc :( */ tmp = devpriv->ndevs * sizeof(bdev); devpriv->devs = - Realloc(devpriv->devs, + realloc(devpriv->devs, ++devpriv->ndevs * sizeof(bdev), tmp); if (!devpriv->devs) { dev_err(dev->class_dev, @@ -311,7 +312,7 @@ static int bonding_attach(struct comedi_device *dev, /* * Setup our bonding from config params.. sets up our private struct.. */ - if (!doDevConfig(dev, it)) + if (!do_dev_config(dev, it)) return -EINVAL; dev->board_name = devpriv->name; @@ -344,7 +345,7 @@ static void bonding_detach(struct comedi_device *dev) if (devpriv) { while (devpriv->ndevs-- && devpriv->devs) { - struct BondedDevice *bdev; + struct bonded_device *bdev; bdev = devpriv->devs[devpriv->ndevs]; if (!bdev) -- GitLab From a7e240a40c0e9cff7572cda74daea18985ff4aad Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 23 Aug 2013 14:44:59 +0100 Subject: [PATCH 847/942] staging: comedi: comedi_bond: no need to initialize file[] The `char file[]` variable in `do_dev_config()` doesn't need to be initialized as it gets overwritten with a `snprintf()`. It just needs to be long enough. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/comedi_bond.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/comedi_bond.c b/drivers/staging/comedi/drivers/comedi_bond.c index 253a67da8e03b..00c065a3dafdf 100644 --- a/drivers/staging/comedi/drivers/comedi_bond.c +++ b/drivers/staging/comedi/drivers/comedi_bond.c @@ -200,7 +200,7 @@ static int do_dev_config(struct comedi_device *dev, struct comedi_devconfig *it) * building our device list. */ for (i = 0; i < COMEDI_NDEVCONFOPTS && (!i || it->options[i]); ++i) { - char file[] = "/dev/comediXXXXXX"; + char file[sizeof("/dev/comediXXXXXX")]; int minor = it->options[i]; struct comedi_device *d; int sdev = -1, nchans, tmp; -- GitLab From fcf26cff891930e62bc4cd208a6b679fb1a1f144 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 23 Aug 2013 14:45:00 +0100 Subject: [PATCH 848/942] staging: comedi: comedi_bond: return error code in do_dev_config() Change `do_dev_config()` to return an error code on failure and 0 on success, instead of 0 on failure and 1 on success. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/comedi_bond.c | 23 ++++++++++---------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/staging/comedi/drivers/comedi_bond.c b/drivers/staging/comedi/drivers/comedi_bond.c index 00c065a3dafdf..4a1135b6e4c5e 100644 --- a/drivers/staging/comedi/drivers/comedi_bond.c +++ b/drivers/staging/comedi/drivers/comedi_bond.c @@ -209,17 +209,17 @@ static int do_dev_config(struct comedi_device *dev, struct comedi_devconfig *it) if (minor < 0 || minor >= COMEDI_NUM_BOARD_MINORS) { dev_err(dev->class_dev, "Minor %d is invalid!\n", minor); - return 0; + return -EINVAL; } if (minor == dev->minor) { dev_err(dev->class_dev, "Cannot bond this driver to itself!\n"); - return 0; + return -EINVAL; } if (devs_opened[minor]) { dev_err(dev->class_dev, "Minor %d specified more than once!\n", minor); - return 0; + return -EINVAL; } snprintf(file, sizeof(file), "/dev/comedi%u", minor); @@ -230,7 +230,7 @@ static int do_dev_config(struct comedi_device *dev, struct comedi_devconfig *it) if (!d) { dev_err(dev->class_dev, "Minor %u could not be opened\n", minor); - return 0; + return -ENODEV; } /* Do DIO, as that's all we support now.. */ @@ -241,11 +241,11 @@ static int do_dev_config(struct comedi_device *dev, struct comedi_devconfig *it) dev_err(dev->class_dev, "comedi_get_n_channels() returned %d on minor %u subdev %d!\n", nchans, minor, sdev); - return 0; + return -EINVAL; } bdev = kmalloc(sizeof(*bdev), GFP_KERNEL); if (!bdev) - return 0; + return -ENOMEM; bdev->dev = d; bdev->minor = minor; @@ -272,7 +272,7 @@ static int do_dev_config(struct comedi_device *dev, struct comedi_devconfig *it) if (!devpriv->devs) { dev_err(dev->class_dev, "Could not allocate memory. Out of memory?\n"); - return 0; + return -ENOMEM; } devpriv->devs[devpriv->ndevs - 1] = bdev; @@ -292,10 +292,10 @@ static int do_dev_config(struct comedi_device *dev, struct comedi_devconfig *it) if (!devpriv->nchans) { dev_err(dev->class_dev, "No channels found!\n"); - return 0; + return -EINVAL; } - return 1; + return 0; } static int bonding_attach(struct comedi_device *dev, @@ -312,8 +312,9 @@ static int bonding_attach(struct comedi_device *dev, /* * Setup our bonding from config params.. sets up our private struct.. */ - if (!do_dev_config(dev, it)) - return -EINVAL; + ret = do_dev_config(dev, it); + if (ret) + return ret; dev->board_name = devpriv->name; -- GitLab From 8fe73691f905a172fa6aa6800a9c08016c460b06 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 23 Aug 2013 14:45:01 +0100 Subject: [PATCH 849/942] staging: comedi: comedi_bond: change return value of bonding_attach() `bonding_attach()` is the comedi "attach" handler for the driver. Any non-negative return value is treated as successful, but 0 is the preferred return value on success. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/comedi_bond.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/comedi_bond.c b/drivers/staging/comedi/drivers/comedi_bond.c index 4a1135b6e4c5e..dd93e4f0d8901 100644 --- a/drivers/staging/comedi/drivers/comedi_bond.c +++ b/drivers/staging/comedi/drivers/comedi_bond.c @@ -336,7 +336,7 @@ static int bonding_attach(struct comedi_device *dev, dev->driver->driver_name, dev->board_name, devpriv->nchans, devpriv->ndevs); - return 1; + return 0; } static void bonding_detach(struct comedi_device *dev) -- GitLab From f59ebeda209306f10e33016b510996f54cc5248e Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 23 Aug 2013 14:45:02 +0100 Subject: [PATCH 850/942] staging: comedi: comedi_bond: use bitmap to record opened/closed minors `do_dev_config()` currently records the comedi minor devices it has opened by setting `devs_opened[minor]` to the pointer returned by `comedi_open()`. This is checked to avoid opening the same minor device twice. The pointer values in `devs_opened[]` aren't needed; we only need to record which minor device numbers are being used. Change `devs_opened` to a bitmap (declared with `DECLARE_BITMAP()`) of length `COMEDI_NUM_BOARD_MINORS` as the minor device numbers are range-checked to fit in a bitmap of this length. Use `test_and_set_bit()` to record the minor device numbers we attempt to open with `comedi_open()`. `bonding_detach()` calls `comedi_close()` to close the comedi minor devices. Since the minor device numbers may be repeated in its list of bonded subdevices, it currently uses a simple `unsigned long devs_closed` variable as a bitmap to keep track of which minor device numbers it has already closed to avoid closing them twice. As a single `unsigned long` consists of less than `COMEDI_NUM_BOARD_MINORS` bits on a 32-bit machine, change `devs_closed to a bitmap of this length using `DECLARE_BITMAP()` and use `test_and_set_bit()` to avoid calling `comedi_close()` more than once for each minor device number in use. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/comedi_bond.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/comedi_bond.c b/drivers/staging/comedi/drivers/comedi_bond.c index dd93e4f0d8901..c0a427cab9dbd 100644 --- a/drivers/staging/comedi/drivers/comedi_bond.c +++ b/drivers/staging/comedi/drivers/comedi_bond.c @@ -190,10 +190,10 @@ static void *realloc(const void *oldmem, size_t newlen, size_t oldlen) static int do_dev_config(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_bond_private *devpriv = dev->private; + DECLARE_BITMAP(devs_opened, COMEDI_NUM_BOARD_MINORS); int i; - struct comedi_device *devs_opened[COMEDI_NUM_BOARD_MINORS]; - memset(devs_opened, 0, sizeof(devs_opened)); + memset(&devs_opened, 0, sizeof(devs_opened)); devpriv->name[0] = 0; /* * Loop through all comedi devices specified on the command-line, @@ -216,7 +216,7 @@ static int do_dev_config(struct comedi_device *dev, struct comedi_devconfig *it) "Cannot bond this driver to itself!\n"); return -EINVAL; } - if (devs_opened[minor]) { + if (test_and_set_bit(minor, devs_opened)) { dev_err(dev->class_dev, "Minor %d specified more than once!\n", minor); return -EINVAL; @@ -225,7 +225,7 @@ static int do_dev_config(struct comedi_device *dev, struct comedi_devconfig *it) snprintf(file, sizeof(file), "/dev/comedi%u", minor); file[sizeof(file) - 1] = 0; - d = devs_opened[minor] = comedi_open(file); + d = comedi_open(file); if (!d) { dev_err(dev->class_dev, @@ -342,19 +342,19 @@ static int bonding_attach(struct comedi_device *dev, static void bonding_detach(struct comedi_device *dev) { struct comedi_bond_private *devpriv = dev->private; - unsigned long devs_closed = 0; if (devpriv) { + DECLARE_BITMAP(devs_closed, COMEDI_NUM_BOARD_MINORS); + + memset(&devs_closed, 0, sizeof(devs_closed)); while (devpriv->ndevs-- && devpriv->devs) { struct bonded_device *bdev; bdev = devpriv->devs[devpriv->ndevs]; if (!bdev) continue; - if (!(devs_closed & (0x1 << bdev->minor))) { + if (!test_and_set_bit(bdev->minor, devs_closed)) comedi_close(bdev->dev); - devs_closed |= (0x1 << bdev->minor); - } kfree(bdev); } kfree(devpriv->devs); -- GitLab From 10b799d2fe7c004f204b833818486544080441d2 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 23 Aug 2013 14:45:03 +0100 Subject: [PATCH 851/942] staging: comedi: comedi_bond: don't map channels individually The private data structure (`struct comedi_bond_private`) for the overall "comedi_bond" device maps each channel individually to a pointer to the `struct bonded_device` it belongs to via array member `chan_id_dev_map[MAX_CHANS]`. This speeds up look-ups from channel number to bonded device a bit, but the length of the array used to look this up is currently fixed at `MAX_CHANS` (256) and there are no overflow checks when filling the array. In practice, there will only be a few bonded devices (actually bonded subdevices) and it is practical to just skip through the list until we reach the one containing the desired channel. The only place where the bonded device is looked up from the channel number is in `bonding_dio_insn_config()`. Change it to do the look-up by skipping through the list of bonded devices and remove the `chan_id_dev_map[]` member. The `chanid_offset` member of `struct bonded_device` is also no longer needed as the value can be derived while skipping through the list of bonded devices, so remove that member as well. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/comedi_bond.c | 28 +++++++++----------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/drivers/staging/comedi/drivers/comedi_bond.c b/drivers/staging/comedi/drivers/comedi_bond.c index c0a427cab9dbd..493fdb7dee504 100644 --- a/drivers/staging/comedi/drivers/comedi_bond.c +++ b/drivers/staging/comedi/drivers/comedi_bond.c @@ -53,18 +53,12 @@ #include "../comedilib.h" #include "../comedidev.h" -/* The maxiumum number of channels per subdevice. */ -#define MAX_CHANS 256 - struct bonded_device { struct comedi_device *dev; unsigned minor; unsigned subdev; unsigned subdev_type; unsigned nchans; - unsigned chanid_offset; /* The offset into our unified linear - * channel-id's of chanid 0 on this - * subdevice. */ }; struct comedi_bond_private { @@ -72,7 +66,6 @@ struct comedi_bond_private { char name[MAX_BOARD_NAME]; struct bonded_device **devs; unsigned ndevs; - struct bonded_device *chan_id_dev_map[MAX_CHANS]; unsigned nchans; }; @@ -133,12 +126,22 @@ static int bonding_dio_insn_config(struct comedi_device *dev, { struct comedi_bond_private *devpriv = dev->private; int chan = CR_CHAN(insn->chanspec), ret, io_bits = s->io_bits; + unsigned int chanid_offset; unsigned int io; struct bonded_device *bdev; + struct bonded_device **devs; if (chan < 0 || chan >= devpriv->nchans) return -EINVAL; - bdev = devpriv->chan_id_dev_map[chan]; + + /* + * Locate bonded subdevice. + */ + chanid_offset = 0; + devs = devpriv->devs; + for (bdev = *devs++; chan >= chanid_offset + bdev->nchans; + bdev = *devs++) + chanid_offset += bdev->nchans; /* * The input or output configuration of each digital line is @@ -165,7 +168,7 @@ static int bonding_dio_insn_config(struct comedi_device *dev, break; } /* 'real' channel id for this subdev.. */ - chan -= bdev->chanid_offset; + chan -= chanid_offset; ret = comedi_dio_config(bdev->dev, bdev->subdev, chan, io); if (ret != 1) return -EINVAL; @@ -252,12 +255,7 @@ static int do_dev_config(struct comedi_device *dev, struct comedi_devconfig *it) bdev->subdev = sdev; bdev->subdev_type = COMEDI_SUBD_DIO; bdev->nchans = nchans; - bdev->chanid_offset = devpriv->nchans; - - /* map channel id's to bonded_device * pointer.. */ - while (nchans--) - devpriv->chan_id_dev_map[devpriv->nchans++] = - bdev; + devpriv->nchans += nchans; /* * Now put bdev pointer at end of devpriv->devs array -- GitLab From ad9f81f0b591986db6db1f750d7203db2d33c040 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 23 Aug 2013 14:45:04 +0100 Subject: [PATCH 852/942] staging: comedi: comedi_bond: remove unused subdev_type The `subdev_type` member of `struct bonded_device` is set but not used. Remove it. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/comedi_bond.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/comedi_bond.c b/drivers/staging/comedi/drivers/comedi_bond.c index 493fdb7dee504..ab5451ec3480c 100644 --- a/drivers/staging/comedi/drivers/comedi_bond.c +++ b/drivers/staging/comedi/drivers/comedi_bond.c @@ -57,7 +57,6 @@ struct bonded_device { struct comedi_device *dev; unsigned minor; unsigned subdev; - unsigned subdev_type; unsigned nchans; }; @@ -253,7 +252,6 @@ static int do_dev_config(struct comedi_device *dev, struct comedi_devconfig *it) bdev->dev = d; bdev->minor = minor; bdev->subdev = sdev; - bdev->subdev_type = COMEDI_SUBD_DIO; bdev->nchans = nchans; devpriv->nchans += nchans; -- GitLab From c2af5b9681a9d1beaf37310ee3d6a5c4860750d5 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 23 Aug 2013 14:45:05 +0100 Subject: [PATCH 853/942] staging: comedi: comedi_bond: no need to free dev->private on detach The comedi core will free `dev->private` if it is non-NULL after calling the "detach" handler (`bonding_detach()`), so don't bother freeing it in `bonding_detach()`. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/comedi_bond.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/comedi_bond.c b/drivers/staging/comedi/drivers/comedi_bond.c index ab5451ec3480c..a2cc28565586e 100644 --- a/drivers/staging/comedi/drivers/comedi_bond.c +++ b/drivers/staging/comedi/drivers/comedi_bond.c @@ -355,8 +355,6 @@ static void bonding_detach(struct comedi_device *dev) } kfree(devpriv->devs); devpriv->devs = NULL; - kfree(devpriv); - dev->private = NULL; } } -- GitLab From 7b8cbe92be6dc2665e3247f4b136199055972b5a Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 23 Aug 2013 14:45:06 +0100 Subject: [PATCH 854/942] staging: comedi: comedi_bond: just check devprivs->devs once on detach The `while` loop in `bonding_detach()` doesn't need to check `devpriv->devs` each time round the loop. Move the test outside the loop. The enclosing `if (devpriv)` can be changed to `if (devpriv && devpriv->devs)` as everything in this `if` statement is associated with `devpriv->devs` anyway. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/comedi_bond.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/comedi_bond.c b/drivers/staging/comedi/drivers/comedi_bond.c index a2cc28565586e..2ea605fa683f4 100644 --- a/drivers/staging/comedi/drivers/comedi_bond.c +++ b/drivers/staging/comedi/drivers/comedi_bond.c @@ -339,11 +339,11 @@ static void bonding_detach(struct comedi_device *dev) { struct comedi_bond_private *devpriv = dev->private; - if (devpriv) { + if (devpriv && devpriv->devs) { DECLARE_BITMAP(devs_closed, COMEDI_NUM_BOARD_MINORS); memset(&devs_closed, 0, sizeof(devs_closed)); - while (devpriv->ndevs-- && devpriv->devs) { + while (devpriv->ndevs--) { struct bonded_device *bdev; bdev = devpriv->devs[devpriv->ndevs]; -- GitLab From 16d2d3cbb353406956267283425d8fcae873c948 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 23 Aug 2013 14:45:07 +0100 Subject: [PATCH 855/942] staging: comedi: comedi_bond: get INSN_CONFIG_DIO_QUERY info from horse's mouth The DIO subdevice of the "comedi_bond" device attempts to remember the directions of DIO channels itself in the `io_bits` member of the subdevice, but that is only large enough for the first 32 channels and it might not be accurate anyway as changing the direction of one channel may have affected a whole group of channels and we have no idea of the initial directions before the "bonded" device was linked to the the "comedi_bond" device. It would be better to ask the bonded device for this information when handling a `INSN_CONFIG_DIO_QUERY` configuration instruction. Add new function `comedi_dio_get_config()` to the "kcomedilib" module to allow us to get the DIO direction of a channel and use it. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedilib.h | 2 + drivers/staging/comedi/drivers/comedi_bond.c | 49 +++++++------------ .../comedi/kcomedilib/kcomedilib_main.c | 21 ++++++++ 3 files changed, 40 insertions(+), 32 deletions(-) diff --git a/drivers/staging/comedi/comedilib.h b/drivers/staging/comedi/comedilib.h index 1a78b15543c44..47b1640241825 100644 --- a/drivers/staging/comedi/comedilib.h +++ b/drivers/staging/comedi/comedilib.h @@ -21,6 +21,8 @@ struct comedi_device *comedi_open(const char *path); int comedi_close(struct comedi_device *dev); +int comedi_dio_get_config(struct comedi_device *dev, unsigned int subdev, + unsigned int chan, unsigned int *io); int comedi_dio_config(struct comedi_device *dev, unsigned int subdev, unsigned int chan, unsigned int io); int comedi_dio_bitfield(struct comedi_device *dev, unsigned int subdev, diff --git a/drivers/staging/comedi/drivers/comedi_bond.c b/drivers/staging/comedi/drivers/comedi_bond.c index 2ea605fa683f4..a1c51a2e9c597 100644 --- a/drivers/staging/comedi/drivers/comedi_bond.c +++ b/drivers/staging/comedi/drivers/comedi_bond.c @@ -124,59 +124,44 @@ static int bonding_dio_insn_config(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { struct comedi_bond_private *devpriv = dev->private; - int chan = CR_CHAN(insn->chanspec), ret, io_bits = s->io_bits; - unsigned int chanid_offset; - unsigned int io; + unsigned int chan = CR_CHAN(insn->chanspec); + int ret; struct bonded_device *bdev; struct bonded_device **devs; - if (chan < 0 || chan >= devpriv->nchans) - return -EINVAL; - /* - * Locate bonded subdevice. + * Locate bonded subdevice and adjust channel. */ - chanid_offset = 0; devs = devpriv->devs; - for (bdev = *devs++; chan >= chanid_offset + bdev->nchans; - bdev = *devs++) - chanid_offset += bdev->nchans; + for (bdev = *devs++; chan >= bdev->nchans; bdev = *devs++) + chan -= bdev->nchans; /* * The input or output configuration of each digital line is * configured by a special insn_config instruction. chanspec * contains the channel to be changed, and data[0] contains the - * value COMEDI_INPUT or COMEDI_OUTPUT. + * configuration instruction INSN_CONFIG_DIO_OUTPUT, + * INSN_CONFIG_DIO_INPUT or INSN_CONFIG_DIO_QUERY. + * + * Note that INSN_CONFIG_DIO_OUTPUT == COMEDI_OUTPUT, + * and INSN_CONFIG_DIO_INPUT == COMEDI_INPUT. This is deliberate ;) */ switch (data[0]) { case INSN_CONFIG_DIO_OUTPUT: - io = COMEDI_OUTPUT; /* is this really necessary? */ - io_bits |= 1 << chan; - break; case INSN_CONFIG_DIO_INPUT: - io = COMEDI_INPUT; /* is this really necessary? */ - io_bits &= ~(1 << chan); + ret = comedi_dio_config(bdev->dev, bdev->subdev, chan, data[0]); break; case INSN_CONFIG_DIO_QUERY: - data[1] = - (io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT; - return insn->n; + ret = comedi_dio_get_config(bdev->dev, bdev->subdev, chan, + &data[1]); break; default: - return -EINVAL; + ret = -EINVAL; break; } - /* 'real' channel id for this subdev.. */ - chan -= chanid_offset; - ret = comedi_dio_config(bdev->dev, bdev->subdev, chan, io); - if (ret != 1) - return -EINVAL; - /* - * Finally, save the new io_bits values since we didn't get an error - * above. - */ - s->io_bits = io_bits; - return insn->n; + if (ret >= 0) + ret = insn->n; + return ret; } static void *realloc(const void *oldmem, size_t newlen, size_t oldlen) diff --git a/drivers/staging/comedi/kcomedilib/kcomedilib_main.c b/drivers/staging/comedi/kcomedilib/kcomedilib_main.c index 066083c1bceb1..c7e809b35fd25 100644 --- a/drivers/staging/comedi/kcomedilib/kcomedilib_main.c +++ b/drivers/staging/comedi/kcomedilib/kcomedilib_main.c @@ -123,6 +123,27 @@ static int comedi_do_insn(struct comedi_device *dev, return ret; } +int comedi_dio_get_config(struct comedi_device *dev, unsigned int subdev, + unsigned int chan, unsigned int *io) +{ + struct comedi_insn insn; + unsigned int data[2]; + int ret; + + memset(&insn, 0, sizeof(insn)); + insn.insn = INSN_CONFIG; + insn.n = 2; + insn.subdev = subdev; + insn.chanspec = CR_PACK(chan, 0, 0); + data[0] = INSN_CONFIG_DIO_QUERY; + data[1] = 0; + ret = comedi_do_insn(dev, &insn, data); + if (ret >= 0) + *io = data[1]; + return ret; +} +EXPORT_SYMBOL_GPL(comedi_dio_get_config); + int comedi_dio_config(struct comedi_device *dev, unsigned int subdev, unsigned int chan, unsigned int io) { -- GitLab From 0f3ce1a600fc1aca996a550f332c9f0c712ea80a Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 23 Aug 2013 14:45:08 +0100 Subject: [PATCH 856/942] staging: comedi: comedi_bond: handle base channel for insn_bits If a DIO subdevice has more than 32 channels, its 'insn_bits' handler is supposed to take account of the base channel from `CR_CHAN(insn->chanspec)`. (The comedi core will adjust the base channel to 0 and shift the mask and data to compensate if the subdevice has less than or equal to 32 channels.) The "comedi_bond" driver currently ignores the base channel and assumes it is 0. Replace `comedi_dio_bitfield()` in the "kcomedilib" module with `comedi_dio_bitfield2()` that takes account of the base channel, and rewrite the "comedi_bond" driver's 'insn_bits' handler (`bonding_dio_insn_bits()`) to take account of the base channel and use the new function. No other modules use `comedi_dio_bitfield()` so it is safe to replace it with `comedi_dio_bitfield2()`. The name follows that of the equivalent function in the user-space comedilib. If the base channel is non-zero and the subdevice has less than or equal to 32 channels it needs to adjust things in the same way as the comedi core (same as `parse_insn()` in "comedi_fops.c") due to most drivers ignoring the base channel. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedilib.h | 5 +- drivers/staging/comedi/drivers/comedi_bond.c | 87 +++++++++++-------- .../comedi/kcomedilib/kcomedilib_main.c | 37 ++++++-- 3 files changed, 83 insertions(+), 46 deletions(-) diff --git a/drivers/staging/comedi/comedilib.h b/drivers/staging/comedi/comedilib.h index 47b1640241825..56baf852ecf5d 100644 --- a/drivers/staging/comedi/comedilib.h +++ b/drivers/staging/comedi/comedilib.h @@ -25,8 +25,9 @@ int comedi_dio_get_config(struct comedi_device *dev, unsigned int subdev, unsigned int chan, unsigned int *io); int comedi_dio_config(struct comedi_device *dev, unsigned int subdev, unsigned int chan, unsigned int io); -int comedi_dio_bitfield(struct comedi_device *dev, unsigned int subdev, - unsigned int mask, unsigned int *bits); +int comedi_dio_bitfield2(struct comedi_device *dev, unsigned int subdev, + unsigned int mask, unsigned int *bits, + unsigned int base_channel); int comedi_find_subdevice_by_type(struct comedi_device *dev, int type, unsigned int subd); int comedi_get_n_channels(struct comedi_device *dev, unsigned int subdevice); diff --git a/drivers/staging/comedi/drivers/comedi_bond.c b/drivers/staging/comedi/drivers/comedi_bond.c index a1c51a2e9c597..8e2696c857207 100644 --- a/drivers/staging/comedi/drivers/comedi_bond.c +++ b/drivers/staging/comedi/drivers/comedi_bond.c @@ -73,48 +73,59 @@ static int bonding_dio_insn_bits(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { struct comedi_bond_private *devpriv = dev->private; -#define LSAMPL_BITS (sizeof(unsigned int)*8) - unsigned nchans = LSAMPL_BITS, num_done = 0, i; + unsigned int n_left, n_done, base_chan; + unsigned int write_mask, data_bits; + struct bonded_device **devs; - if (devpriv->nchans < nchans) - nchans = devpriv->nchans; + write_mask = data[0]; + data_bits = data[1]; + base_chan = CR_CHAN(insn->chanspec); + /* do a maximum of 32 channels, starting from base_chan. */ + n_left = devpriv->nchans - base_chan; + if (n_left > 32) + n_left = 32; - /* - * The insn data is a mask in data[0] and the new data - * in data[1], each channel cooresponding to a bit. - */ - for (i = 0; num_done < nchans && i < devpriv->ndevs; ++i) { - struct bonded_device *bdev = devpriv->devs[i]; - /* - * Grab the channel mask and data of only the bits corresponding - * to this subdevice.. need to shift them to zero position of - * course. - */ - /* Bits corresponding to this subdev. */ - unsigned int subdev_mask = ((1 << bdev->nchans) - 1); - unsigned int write_mask, data_bits; - - /* Argh, we have >= LSAMPL_BITS chans.. take all bits */ - if (bdev->nchans >= LSAMPL_BITS) - subdev_mask = (unsigned int)(-1); - - write_mask = (data[0] >> num_done) & subdev_mask; - data_bits = (data[1] >> num_done) & subdev_mask; - - /* Read/Write the new digital lines */ - if (comedi_dio_bitfield(bdev->dev, bdev->subdev, write_mask, - &data_bits) != 2) - return -EINVAL; + n_done = 0; + devs = devpriv->devs; + do { + struct bonded_device *bdev = *devs++; - /* Make room for the new bits in data[1], the return value */ - data[1] &= ~(subdev_mask << num_done); - /* Put the bits in the return value */ - data[1] |= (data_bits & subdev_mask) << num_done; - /* Save the new bits to the saved state.. */ - s->state = data[1]; + if (base_chan < bdev->nchans) { + /* base channel falls within bonded device */ + unsigned int b_chans, b_mask, b_write_mask, b_data_bits; + int ret; - num_done += bdev->nchans; - } + /* + * Get num channels to do for bonded device and set + * up mask and data bits for bonded device. + */ + b_chans = bdev->nchans - base_chan; + if (b_chans > n_left) + b_chans = n_left; + b_mask = (1U << b_chans) - 1; + b_write_mask = (write_mask >> n_done) & b_mask; + b_data_bits = (data_bits >> n_done) & b_mask; + /* Read/Write the new digital lines. */ + ret = comedi_dio_bitfield2(bdev->dev, bdev->subdev, + b_write_mask, &b_data_bits, + base_chan); + if (ret < 0) + return ret; + /* Place read bits into data[1]. */ + data[1] &= ~(b_mask << n_done); + data[1] |= (b_data_bits & b_mask) << n_done; + /* + * Set up for following bonded device (if still have + * channels to read/write). + */ + base_chan = 0; + n_done += b_chans; + n_left -= b_chans; + } else { + /* Skip bonded devices before base channel. */ + base_chan -= bdev->nchans; + } + } while (n_left); return insn->n; } diff --git a/drivers/staging/comedi/kcomedilib/kcomedilib_main.c b/drivers/staging/comedi/kcomedilib/kcomedilib_main.c index c7e809b35fd25..cd60677a3ed2f 100644 --- a/drivers/staging/comedi/kcomedilib/kcomedilib_main.c +++ b/drivers/staging/comedi/kcomedilib/kcomedilib_main.c @@ -159,28 +159,53 @@ int comedi_dio_config(struct comedi_device *dev, unsigned int subdev, } EXPORT_SYMBOL_GPL(comedi_dio_config); -int comedi_dio_bitfield(struct comedi_device *dev, unsigned int subdev, - unsigned int mask, unsigned int *bits) +int comedi_dio_bitfield2(struct comedi_device *dev, unsigned int subdev, + unsigned int mask, unsigned int *bits, + unsigned int base_channel) { struct comedi_insn insn; unsigned int data[2]; + unsigned int n_chan; + unsigned int shift; int ret; + if (subdev >= dev->n_subdevices) + return -EINVAL; + + base_channel = CR_CHAN(base_channel); + n_chan = comedi_get_n_channels(dev, subdev); + if (base_channel >= n_chan) + return -EINVAL; + memset(&insn, 0, sizeof(insn)); insn.insn = INSN_BITS; + insn.chanspec = base_channel; insn.n = 2; insn.subdev = subdev; data[0] = mask; data[1] = *bits; - ret = comedi_do_insn(dev, &insn, data); - - *bits = data[1]; + /* + * Most drivers ignore the base channel in insn->chanspec. + * Fix this here if the subdevice has <= 32 channels. + */ + if (n_chan <= 32) { + shift = base_channel; + if (shift) { + insn.chanspec = 0; + data[0] <<= shift; + data[1] <<= shift; + } + } else { + shift = 0; + } + ret = comedi_do_insn(dev, &insn, data); + *bits = data[1] >> shift; return ret; } -EXPORT_SYMBOL_GPL(comedi_dio_bitfield); +EXPORT_SYMBOL_GPL(comedi_dio_bitfield2); int comedi_find_subdevice_by_type(struct comedi_device *dev, int type, unsigned int subd) -- GitLab From a55de0f4931028622e2f6059007454758403f7c0 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 23 Aug 2013 14:45:09 +0100 Subject: [PATCH 857/942] staging: comedi: comedi_bond: use krealloc() and fix memory leak `do_dev_config()` is called from the comedi 'attach' handler, `bonding_attach()`. The device private data structure contains a dynamically allocated array of pointers to "bonded" device structures which grows during the `do_dev_config()` call. The length of this array is in `devpriv->ndevs`. It currently uses a local function `realloc()` to allocate a new array, copy the old contents over and free the old array. It should be more efficient to use `krealloc()` as it may be able to use slack space at the end of the previous array and avoid a copy. The old `realloc()` function always freed the old buffer which meant that if it failed to allocate the new buffer it would lose the contents of the old buffer. Unfortunately, that contained pointers to more dynamically allocated memory, leading to a memory leak. If `krealloc()` fails, keep the old buffer and avoid the memory leak. The aforementioned pointers to more dynamically allocated memory will be cleaned up by the 'detach' handler, `bonding_detach()` which will be called by the comedi core as a consequence of `krealloc()` failing in `do_dev_config()`. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/comedi_bond.c | 28 +++++++------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/drivers/staging/comedi/drivers/comedi_bond.c b/drivers/staging/comedi/drivers/comedi_bond.c index 8e2696c857207..ccac7b9bc8540 100644 --- a/drivers/staging/comedi/drivers/comedi_bond.c +++ b/drivers/staging/comedi/drivers/comedi_bond.c @@ -175,16 +175,6 @@ static int bonding_dio_insn_config(struct comedi_device *dev, return ret; } -static void *realloc(const void *oldmem, size_t newlen, size_t oldlen) -{ - void *newmem = kmalloc(newlen, GFP_KERNEL); - - if (newmem && oldmem) - memcpy(newmem, oldmem, min(oldlen, newlen)); - kfree(oldmem); - return newmem; -} - static int do_dev_config(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_bond_private *devpriv = dev->private; @@ -201,8 +191,9 @@ static int do_dev_config(struct comedi_device *dev, struct comedi_devconfig *it) char file[sizeof("/dev/comediXXXXXX")]; int minor = it->options[i]; struct comedi_device *d; - int sdev = -1, nchans, tmp; - struct bonded_device *bdev = NULL; + int sdev = -1, nchans; + struct bonded_device *bdev; + struct bonded_device **devs; if (minor < 0 || minor >= COMEDI_NUM_BOARD_MINORS) { dev_err(dev->class_dev, @@ -257,17 +248,16 @@ static int do_dev_config(struct comedi_device *dev, struct comedi_devconfig *it) */ /* ergh.. ugly.. we need to realloc :( */ - tmp = devpriv->ndevs * sizeof(bdev); - devpriv->devs = - realloc(devpriv->devs, - ++devpriv->ndevs * sizeof(bdev), tmp); - if (!devpriv->devs) { + devs = krealloc(devpriv->devs, + (devpriv->ndevs + 1) * sizeof(*devs), + GFP_KERNEL); + if (!devs) { dev_err(dev->class_dev, "Could not allocate memory. Out of memory?\n"); return -ENOMEM; } - - devpriv->devs[devpriv->ndevs - 1] = bdev; + devpriv->devs = devs; + devpriv->devs[devpriv->ndevs++] = bdev; { /* Append dev:subdev to devpriv->name */ char buf[20]; -- GitLab From 7322b320d6376c5f5e3a8ec5a59eb117f81e9f69 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Fri, 23 Aug 2013 14:45:10 +0100 Subject: [PATCH 858/942] staging: comedi: comedi_bond: use correct minor device numbers in name The board name for "comedi_bond" is constructed from a space-separated list of items of the form "minor:subdevice" where "minor" is a minor device number and "subdevice" is a subdevice number. Currently, all the "minor" device numbers are for the "comedi_bond" device itself and the "subdevice" numbers are for the bonded devices. It makes makes more sense for the "minor" device numbers to come from the bonded devices as well so that the string is a list of bonded "minor:subdevice" pairs. Fix it. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/comedi_bond.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/comedi_bond.c b/drivers/staging/comedi/drivers/comedi_bond.c index ccac7b9bc8540..51a59e5b8ec50 100644 --- a/drivers/staging/comedi/drivers/comedi_bond.c +++ b/drivers/staging/comedi/drivers/comedi_bond.c @@ -263,8 +263,8 @@ static int do_dev_config(struct comedi_device *dev, struct comedi_devconfig *it) char buf[20]; int left = MAX_BOARD_NAME - strlen(devpriv->name) - 1; - snprintf(buf, sizeof(buf), "%d:%d ", dev->minor, - bdev->subdev); + snprintf(buf, sizeof(buf), "%d:%d ", + bdev->minor, bdev->subdev); buf[sizeof(buf) - 1] = 0; strncat(devpriv->name, buf, left); } -- GitLab From b1f56acaca2efefcdf4b3f5962a99b27700c6e0a Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 26 Aug 2013 12:02:54 -0700 Subject: [PATCH 859/942] staging: usbip: use DEVICE_ATTR_RO/RW for sysfs attributes It's easier to audit the sysfs files if they use the RO/RW macros, so convert the usbip code to them. Signed-off-by: Greg Kroah-Hartman --- drivers/staging/usbip/stub_dev.c | 6 +++--- drivers/staging/usbip/usbip_common.c | 11 ++++++----- drivers/staging/usbip/vhci_sysfs.c | 4 ++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/staging/usbip/stub_dev.c b/drivers/staging/usbip/stub_dev.c index 83d629afdfe12..d8957a5566264 100644 --- a/drivers/staging/usbip/stub_dev.c +++ b/drivers/staging/usbip/stub_dev.c @@ -56,8 +56,8 @@ MODULE_DEVICE_TABLE(usb, stub_table); * usbip_status shows the status of usbip-host as long as this driver is bound * to the target device. */ -static ssize_t show_status(struct device *dev, struct device_attribute *attr, - char *buf) +static ssize_t usbip_status_show(struct device *dev, + struct device_attribute *attr, char *buf) { struct stub_device *sdev = dev_get_drvdata(dev); int status; @@ -73,7 +73,7 @@ static ssize_t show_status(struct device *dev, struct device_attribute *attr, return snprintf(buf, PAGE_SIZE, "%d\n", status); } -static DEVICE_ATTR(usbip_status, S_IRUGO, show_status, NULL); +static DEVICE_ATTR_RO(usbip_status); /* * usbip_sockfd gets a socket descriptor of an established TCP connection that diff --git a/drivers/staging/usbip/usbip_common.c b/drivers/staging/usbip/usbip_common.c index 7b97df6f2a422..e3fc749c1e7e0 100644 --- a/drivers/staging/usbip/usbip_common.c +++ b/drivers/staging/usbip/usbip_common.c @@ -45,19 +45,20 @@ MODULE_PARM_DESC(usbip_debug_flag, "debug flags (defined in usbip_common.h)"); struct device_attribute dev_attr_usbip_debug; EXPORT_SYMBOL_GPL(dev_attr_usbip_debug); -static ssize_t show_flag(struct device *dev, struct device_attribute *attr, - char *buf) +static ssize_t usbip_debug_show(struct device *dev, + struct device_attribute *attr, char *buf) { return sprintf(buf, "%lx\n", usbip_debug_flag); } -static ssize_t store_flag(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t usbip_debug_store(struct device *dev, + struct device_attribute *attr, const char *buf, + size_t count) { sscanf(buf, "%lx", &usbip_debug_flag); return count; } -DEVICE_ATTR(usbip_debug, (S_IRUGO | S_IWUSR), show_flag, store_flag); +DEVICE_ATTR_RW(usbip_debug); static void usbip_dump_buffer(char *buff, int bufflen) { diff --git a/drivers/staging/usbip/vhci_sysfs.c b/drivers/staging/usbip/vhci_sysfs.c index c66e9c05c76b7..9b51586d11d92 100644 --- a/drivers/staging/usbip/vhci_sysfs.c +++ b/drivers/staging/usbip/vhci_sysfs.c @@ -27,7 +27,7 @@ /* TODO: refine locking ?*/ /* Sysfs entry to show port status */ -static ssize_t show_status(struct device *dev, struct device_attribute *attr, +static ssize_t status_show(struct device *dev, struct device_attribute *attr, char *out) { char *s = out; @@ -74,7 +74,7 @@ static ssize_t show_status(struct device *dev, struct device_attribute *attr, return out - s; } -static DEVICE_ATTR(status, S_IRUGO, show_status, NULL); +static DEVICE_ATTR_RO(status); /* Sysfs entry to shutdown a virtual connection */ static int vhci_port_disconnect(__u32 rhport) -- GitLab From 2ea550bdfad1442749e6a1353afda93c8bb7a9ac Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Mon, 26 Aug 2013 10:53:09 -0400 Subject: [PATCH 860/942] staging: dgnc: cls_uart_struct: adds marker and changes vars' types for sparse This patch removes these sparse warnings found in the cls.c file: warning: incorrect type in argument 1 (different address spaces) expected void const volatile [noderef] *addr got unsigned char volatile * warning: incorrect type in argument 2 (different address spaces) expected void volatile [noderef] *addr got unsigned char volatile * The variables passed to readb and writeb need to be of type u8 with a __iomem marker. These warnings were popping up everytime the readb and writeb functions were called with a cls_uart_struct variable. The change made to the driver.h file adds the marker to the cls_uart_struct and the changes in cls.h changes its variables' types. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_cls.h | 16 ++++++++-------- drivers/staging/dgnc/dgnc_driver.h | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_cls.h b/drivers/staging/dgnc/dgnc_cls.h index a27338573f752..ffe8535a84a9d 100644 --- a/drivers/staging/dgnc/dgnc_cls.h +++ b/drivers/staging/dgnc/dgnc_cls.h @@ -36,14 +36,14 @@ ************************************************************************/ struct cls_uart_struct { - volatile uchar txrx; /* WR RHR/THR - Holding Reg */ - volatile uchar ier; /* WR IER - Interrupt Enable Reg */ - volatile uchar isr_fcr; /* WR ISR/FCR - Interrupt Status Reg/Fifo Control Reg */ - volatile uchar lcr; /* WR LCR - Line Control Reg */ - volatile uchar mcr; /* WR MCR - Modem Control Reg */ - volatile uchar lsr; /* WR LSR - Line Status Reg */ - volatile uchar msr; /* WR MSR - Modem Status Reg */ - volatile uchar spr; /* WR SPR - Scratch Pad Reg */ + u8 txrx; /* WR RHR/THR - Holding Reg */ + u8 ier; /* WR IER - Interrupt Enable Reg */ + u8 isr_fcr; /* WR ISR/FCR - Interrupt Status Reg/Fifo Control Reg */ + u8 lcr; /* WR LCR - Line Control Reg */ + u8 mcr; /* WR MCR - Modem Control Reg */ + u8 lsr; /* WR LSR - Line Status Reg */ + u8 msr; /* WR MSR - Modem Status Reg */ + u8 spr; /* WR SPR - Scratch Pad Reg */ }; /* Where to read the interrupt register (8bits) */ diff --git a/drivers/staging/dgnc/dgnc_driver.h b/drivers/staging/dgnc/dgnc_driver.h index 47bc781ac5742..6644e95dfcaa9 100644 --- a/drivers/staging/dgnc/dgnc_driver.h +++ b/drivers/staging/dgnc/dgnc_driver.h @@ -481,7 +481,7 @@ struct channel_t { uchar ch_mistat; /* FEP input modem status */ struct neo_uart_struct *ch_neo_uart; /* Pointer to the "mapped" UART struct */ - struct cls_uart_struct *ch_cls_uart; /* Pointer to the "mapped" UART struct */ + struct cls_uart_struct __iomem *ch_cls_uart; /* Pointer to the "mapped" UART struct */ uchar ch_cached_lsr; /* Cached value of the LSR register */ -- GitLab From 2587771a61bdf89a45cf54ddbed5458deaaddf26 Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Mon, 26 Aug 2013 11:08:02 -0400 Subject: [PATCH 861/942] staging: dgnc: neo_uart_struct: adds marker and changes vars' types for sparse This patch fixes these warnings found in the neo.c file: warning: incorrect type in argument 1 (different address spaces) expected void const volatile [noderef] *addr got unsigned char volatile * warning: incorrect type in argument 2 (different address spaces) expected void volatile [noderef] *addr got unsigned char volatile * The variables passed to readb and writeb need to be of type u8 with a __iomem marker. These warnings were popping up everytime the readb and writeb functions were called with a neo_uart_struct variable. The change made to the driver.h file adds the marker to the neo_uart_struct and the changes in neo.h changes the variables' types. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_driver.h | 2 +- drivers/staging/dgnc/dgnc_neo.h | 42 +++++++++++++++--------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_driver.h b/drivers/staging/dgnc/dgnc_driver.h index 6644e95dfcaa9..953d90414887e 100644 --- a/drivers/staging/dgnc/dgnc_driver.h +++ b/drivers/staging/dgnc/dgnc_driver.h @@ -480,7 +480,7 @@ struct channel_t { uchar ch_mostat; /* FEP output modem status */ uchar ch_mistat; /* FEP input modem status */ - struct neo_uart_struct *ch_neo_uart; /* Pointer to the "mapped" UART struct */ + struct neo_uart_struct __iomem *ch_neo_uart; /* Pointer to the "mapped" UART struct */ struct cls_uart_struct __iomem *ch_cls_uart; /* Pointer to the "mapped" UART struct */ uchar ch_cached_lsr; /* Cached value of the LSR register */ diff --git a/drivers/staging/dgnc/dgnc_neo.h b/drivers/staging/dgnc/dgnc_neo.h index f7f569b3de933..7ec5710a4340f 100644 --- a/drivers/staging/dgnc/dgnc_neo.h +++ b/drivers/staging/dgnc/dgnc_neo.h @@ -36,27 +36,27 @@ ************************************************************************/ struct neo_uart_struct { - volatile uchar txrx; /* WR RHR/THR - Holding Reg */ - volatile uchar ier; /* WR IER - Interrupt Enable Reg */ - volatile uchar isr_fcr; /* WR ISR/FCR - Interrupt Status Reg/Fifo Control Reg */ - volatile uchar lcr; /* WR LCR - Line Control Reg */ - volatile uchar mcr; /* WR MCR - Modem Control Reg */ - volatile uchar lsr; /* WR LSR - Line Status Reg */ - volatile uchar msr; /* WR MSR - Modem Status Reg */ - volatile uchar spr; /* WR SPR - Scratch Pad Reg */ - volatile uchar fctr; /* WR FCTR - Feature Control Reg */ - volatile uchar efr; /* WR EFR - Enhanced Function Reg */ - volatile uchar tfifo; /* WR TXCNT/TXTRG - Transmit FIFO Reg */ - volatile uchar rfifo; /* WR RXCNT/RXTRG - Recieve FIFO Reg */ - volatile uchar xoffchar1; /* WR XOFF 1 - XOff Character 1 Reg */ - volatile uchar xoffchar2; /* WR XOFF 2 - XOff Character 2 Reg */ - volatile uchar xonchar1; /* WR XON 1 - Xon Character 1 Reg */ - volatile uchar xonchar2; /* WR XON 2 - XOn Character 2 Reg */ - - volatile uchar reserved1[0x2ff - 0x200]; /* U Reserved by Exar */ - volatile uchar txrxburst[64]; /* RW 64 bytes of RX/TX FIFO Data */ - volatile uchar reserved2[0x37f - 0x340]; /* U Reserved by Exar */ - volatile uchar rxburst_with_errors[64]; /* R 64 bytes of RX FIFO Data + LSR */ + u8 txrx; /* WR RHR/THR - Holding Reg */ + u8 ier; /* WR IER - Interrupt Enable Reg */ + u8 isr_fcr; /* WR ISR/FCR - Interrupt Status Reg/Fifo Control Reg */ + u8 lcr; /* WR LCR - Line Control Reg */ + u8 mcr; /* WR MCR - Modem Control Reg */ + u8 lsr; /* WR LSR - Line Status Reg */ + u8 msr; /* WR MSR - Modem Status Reg */ + u8 spr; /* WR SPR - Scratch Pad Reg */ + u8 fctr; /* WR FCTR - Feature Control Reg */ + u8 efr; /* WR EFR - Enhanced Function Reg */ + u8 tfifo; /* WR TXCNT/TXTRG - Transmit FIFO Reg */ + u8 rfifo; /* WR RXCNT/RXTRG - Recieve FIFO Reg */ + u8 xoffchar1; /* WR XOFF 1 - XOff Character 1 Reg */ + u8 xoffchar2; /* WR XOFF 2 - XOff Character 2 Reg */ + u8 xonchar1; /* WR XON 1 - Xon Character 1 Reg */ + u8 xonchar2; /* WR XON 2 - XOn Character 2 Reg */ + + u8 reserved1[0x2ff - 0x200]; /* U Reserved by Exar */ + u8 txrxburst[64]; /* RW 64 bytes of RX/TX FIFO Data */ + u8 reserved2[0x37f - 0x340]; /* U Reserved by Exar */ + u8 rxburst_with_errors[64]; /* R 64 bytes of RX FIFO Data + LSR */ }; /* Where to read the extended interrupt register (32bits instead of 8bits) */ -- GitLab From 7915dea707820724ad5d5117e9e07ccccf712dd6 Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Mon, 26 Aug 2013 12:49:31 -0400 Subject: [PATCH 862/942] staging: dgnc: driver.h: changes a struct board_t var's type and marker for sparse This patch changes the board_t->re_map_membase variable type and marker. It removes these warnings found in the neo.c, driver.c and cls.c files: warning: incorrect type in argument 1 (different address spaces) expected void const volatile [noderef] *addr got unsigned char volatile * warning: incorrect type in argument 2 (different address spaces) expected void volatile [noderef] *addr got unsigned char volatile * The variables passed to readb and writeb need to be of type u8 with a __iomem marker. These warnings were popping up everytime the readb and writeb functions were called with a board_t->re_map_membase variable. The change made to the driver.h file adds the marker and changes the variable type. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_driver.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/dgnc/dgnc_driver.h b/drivers/staging/dgnc/dgnc_driver.h index 953d90414887e..e77303cf6d539 100644 --- a/drivers/staging/dgnc/dgnc_driver.h +++ b/drivers/staging/dgnc/dgnc_driver.h @@ -324,7 +324,7 @@ struct board_t { ulong membase; /* Start of base memory of the card */ ulong membase_end; /* End of base memory of the card */ - uchar *re_map_membase;/* Remapped memory of the card */ + u8 __iomem *re_map_membase;/* Remapped memory of the card */ ulong iobase; /* Start of io base of the card */ ulong iobase_end; /* End of io base of the card */ -- GitLab From 68b146e8944ae3cfc64feb7f9a12cc6190562758 Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Mon, 26 Aug 2013 13:05:49 -0400 Subject: [PATCH 863/942] staging: dgnc: cls.c: changes var in cls_vpd function for sparse This patch changes cls_vpd function's re_map_vpdbase variable type and marker. It removes these warnings found in cls.c: warning: incorrect type in assignment (different address spaces) expected unsigned char [usertype] *re_map_vpdbase got void [noderef] * warning: incorrect type in argument 1 (different address spaces) expected void const volatile [noderef] *addr got unsigned char [usertype] * warning: incorrect type in argument 1 (different address spaces) expected void volatile [noderef] *addr got unsigned char [usertype] *re_map_vpdbase The variables passed to readb needs to be of type u8 with a __iomem marker. re_map_vpdbase is passed into readb in the code. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_cls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/dgnc/dgnc_cls.c b/drivers/staging/dgnc/dgnc_cls.c index 92ecbfb62515e..117e158082402 100644 --- a/drivers/staging/dgnc/dgnc_cls.c +++ b/drivers/staging/dgnc/dgnc_cls.c @@ -1381,7 +1381,7 @@ static void cls_send_immediate_char(struct channel_t *ch, unsigned char c) static void cls_vpd(struct board_t *brd) { ulong vpdbase; /* Start of io base of the card */ - uchar *re_map_vpdbase;/* Remapped memory of the card */ + u8 __iomem *re_map_vpdbase;/* Remapped memory of the card */ int i = 0; -- GitLab From c2ac546ea4b5e71dafb80892558ca0f125187998 Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Mon, 26 Aug 2013 13:56:11 -0400 Subject: [PATCH 864/942] staging: dgnc: neo.c: changes param in neo_read_eeprom function for sparse This patch adds a marker to neo_read_eeprom function's base parameter. It removes these warnings found in neo.c: warning: incorrect type in argument 1 (different address spaces) expected unsigned char *base got unsigned char [noderef] [usertype] *re_map_membase warning: incorrect type in argument 2 (different address spaces) expected void volatile [noderef] *addr got unsigned char * These warnings happen because this function gets called with a board_t->re_map_base variable. A previous patch added the __iomem marker to this variable. This patch ensures that the changes are consistent. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_neo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/dgnc/dgnc_neo.c b/drivers/staging/dgnc/dgnc_neo.c index 22c8ce32f8cdd..8b9e09a83f757 100644 --- a/drivers/staging/dgnc/dgnc_neo.c +++ b/drivers/staging/dgnc/dgnc_neo.c @@ -1898,7 +1898,7 @@ static void neo_send_immediate_char(struct channel_t *ch, unsigned char c) } -static unsigned int neo_read_eeprom(unsigned char *base, unsigned int address) +static unsigned int neo_read_eeprom(unsigned char __iomem *base, unsigned int address) { unsigned int enable; unsigned int bits; -- GitLab From e7f1c9320ee6b596d58c4b2baeb1bbdfb1f0d9af Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Mon, 26 Aug 2013 14:04:59 -0400 Subject: [PATCH 865/942] staging: dgnc: tty.c: edits var in init func for sparse This patch edits the vaddr variable in dgnc_tty_init. The variable gets set to board_t->re_map_membase. A previous patch changed the re_map_membase variable's marker and type. This patch makes sure that the changes are consistent and that it doesn't cause sparse warnings. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_tty.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c index f0ecc65b86b77..a54b829669762 100644 --- a/drivers/staging/dgnc/dgnc_tty.c +++ b/drivers/staging/dgnc/dgnc_tty.c @@ -344,7 +344,7 @@ int dgnc_tty_register(struct board_t *brd) int dgnc_tty_init(struct board_t *brd) { int i; - uchar *vaddr; + u8 __iomem *vaddr; struct channel_t *ch; if (!brd) -- GitLab From 0bddd303f416c4abcfd64cedfa46880163c1d9c6 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Tue, 27 Aug 2013 09:56:50 +0100 Subject: [PATCH 866/942] staging: vt6656: rxtx.c: s_vFillRTSHead change if/else to switch on byPktype Allowing fall through where necessary. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index e97bc4098f89d..e049a34ad91f2 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -730,7 +730,9 @@ static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, * into account. * Otherwise, we need to modified codes for them. */ - if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { + switch (byPktType) { + case PK_TYPE_11GB: + case PK_TYPE_11GA: if (byFBOption == AUTO_FB_NONE) vnt_rxtx_rts_g_head(pDevice, &head->rts_g, psEthHeader, byPktType, cbFrameLength, @@ -739,7 +741,8 @@ static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, vnt_rxtx_rts_g_fb_head(pDevice, &head->rts_g_fb, psEthHeader, byPktType, cbFrameLength, bNeedAck, wCurrentRate, byFBOption); - } else if (byPktType == PK_TYPE_11A) { + break; + case PK_TYPE_11A: if (byFBOption == AUTO_FB_NONE) vnt_rxtx_rts_ab_head(pDevice, &head->rts_ab, psEthHeader, byPktType, cbFrameLength, @@ -748,7 +751,8 @@ static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, vnt_rxtx_rts_a_fb_head(pDevice, &head->rts_a_fb, psEthHeader, byPktType, cbFrameLength, bNeedAck, wCurrentRate, byFBOption); - } else if (byPktType == PK_TYPE_11B) { + break; + case PK_TYPE_11B: vnt_rxtx_rts_ab_head(pDevice, &head->rts_ab, psEthHeader, byPktType, cbFrameLength, bNeedAck, wCurrentRate, byFBOption); -- GitLab From 2b83ebd0b78ea5a0a8a5858d3b72325c8ce7a9c5 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Tue, 27 Aug 2013 09:58:21 +0100 Subject: [PATCH 867/942] staging: vt6656: rxtx.c s_vFillRTSHead PK_TYPE_11A allow fall through AUTO_FB_NONE byFBOption == AUTO_FB_NONE (0) is the same as PK_TYPE_11B Reverse if condition to break and allow fall through. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index e049a34ad91f2..463a8d5a09651 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -743,15 +743,12 @@ static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, bNeedAck, wCurrentRate, byFBOption); break; case PK_TYPE_11A: - if (byFBOption == AUTO_FB_NONE) - vnt_rxtx_rts_ab_head(pDevice, &head->rts_ab, - psEthHeader, byPktType, cbFrameLength, - bNeedAck, wCurrentRate, byFBOption); - else + if (byFBOption) { vnt_rxtx_rts_a_fb_head(pDevice, &head->rts_a_fb, psEthHeader, byPktType, cbFrameLength, bNeedAck, wCurrentRate, byFBOption); - break; + break; + } case PK_TYPE_11B: vnt_rxtx_rts_ab_head(pDevice, &head->rts_ab, psEthHeader, byPktType, cbFrameLength, -- GitLab From 43e48a4a8bc7a2f68c3bd932739e927851aec7a1 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Tue, 27 Aug 2013 11:46:17 +0100 Subject: [PATCH 868/942] staging: vt6656: rxtx.c s_vFillCTSHead Remove byPktType if s_vFillCTSHead is only called when byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA so remove unnecessary if on byPktType. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 463a8d5a09651..98224bc3ea5ff 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -766,7 +766,6 @@ static void s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx, return; } - if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { if (byFBOption != AUTO_FB_NONE) { /* Auto Fall back */ struct vnt_cts_fb *pBuf = (struct vnt_cts_fb *)pvCTS; @@ -802,7 +801,6 @@ static void s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx, pBuf->data.frame_control = TYPE_CTL_CTS; memcpy(pBuf->data.ra, pDevice->abyCurrentNetAddr, ETH_ALEN); } - } } /*+ -- GitLab From 27df3ebf363bc1a63ab2356975848a07fb2229dc Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Tue, 27 Aug 2013 11:48:34 +0100 Subject: [PATCH 869/942] staging: vt6656: s_vFillCTSHead join structures of vnt_cts* to union vnt_tx_data_head Only one of vnt_rts*/vnt_cts* structures are accessed at any one time. structures vnt_cts and vnt_cts_fb are members of union vnt_tx_data_head. Create pointer union head and point structures to the correct member. Point the union to pvCTS. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 98224bc3ea5ff..fd3c598241520 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -760,15 +760,15 @@ static void s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx, u8 byPktType, void *pvCTS, u32 cbFrameLength, int bNeedAck, u16 wCurrentRate, u8 byFBOption) { + union vnt_tx_data_head *head = pvCTS; u32 uCTSFrameLen = 14; - if (pvCTS == NULL) { - return; - } + if (!head) + return; if (byFBOption != AUTO_FB_NONE) { /* Auto Fall back */ - struct vnt_cts_fb *pBuf = (struct vnt_cts_fb *)pvCTS; + struct vnt_cts_fb *pBuf = &head->cts_g_fb; /* Get SignalField,ServiceField,Length */ BBvCalculateParameter(pDevice, uCTSFrameLen, pDevice->byTopCCKBasicRate, PK_TYPE_11B, &pBuf->b); @@ -788,7 +788,7 @@ static void s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx, pBuf->data.frame_control = TYPE_CTL_CTS; memcpy(pBuf->data.ra, pDevice->abyCurrentNetAddr, ETH_ALEN); } else { - struct vnt_cts *pBuf = (struct vnt_cts *)pvCTS; + struct vnt_cts *pBuf = &head->cts_g; /* Get SignalField,ServiceField,Length */ BBvCalculateParameter(pDevice, uCTSFrameLen, pDevice->byTopCCKBasicRate, PK_TYPE_11B, &pBuf->b); -- GitLab From f46142b0bbde093e9faa8cc6172057e515d17653 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Tue, 27 Aug 2013 11:56:33 +0100 Subject: [PATCH 870/942] staging: vt6656: rxtx.c s_vGenerateTxParameter create argument bool need rts Allow conditional statements to be based on true/false instead of NULL or not pointer pvRTS. Harmonise all call functions will bool type. If need_rts is true then rts is needed. If need_rts is false then cts is needed only when byPktType == PK_TYPE_11GB || PK_TYPE_11GA. none no rts/cts other byPktTypes. This allow the joining of pointers pvRTS/pvCTS in to single pointer. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index fd3c598241520..2fd71c3c06cb1 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -101,7 +101,7 @@ static void *s_vGetFreeContext(struct vnt_private *pDevice); static void s_vGenerateTxParameter(struct vnt_private *pDevice, u8 byPktType, u16 wCurrentRate, void *pTxBufHead, void *pvRrvTime, void *pvRTS, void *pvCTS, u32 cbFrameSize, int bNeedACK, u32 uDMAIdx, - struct ethhdr *psEthHeader); + struct ethhdr *psEthHeader, bool need_rts); static u32 s_uFillDataHead(struct vnt_private *pDevice, u8 byPktType, u16 wCurrentRate, void *pTxDataHead, u32 cbFrameLength, @@ -829,7 +829,7 @@ static void s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx, static void s_vGenerateTxParameter(struct vnt_private *pDevice, u8 byPktType, u16 wCurrentRate, void *pTxBufHead, void *pvRrvTime, void *pvRTS, void *pvCTS, u32 cbFrameSize, int bNeedACK, u32 uDMAIdx, - struct ethhdr *psEthHeader) + struct ethhdr *psEthHeader, bool need_rts) { u32 cbMACHdLen = WLAN_HDR_ADDR3_LEN; /* 24 */ u16 wFifoCtl; @@ -854,8 +854,7 @@ static void s_vGenerateTxParameter(struct vnt_private *pDevice, cbMACHdLen = WLAN_HDR_ADDR3_LEN + 6; if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { - - if (pvRTS != NULL) { //RTS_need + if (need_rts) { //Fill RsvTime struct vnt_rrv_time_rts *pBuf = (struct vnt_rrv_time_rts *)pvRrvTime; @@ -891,8 +890,7 @@ static void s_vGenerateTxParameter(struct vnt_private *pDevice, } } else if (byPktType == PK_TYPE_11A) { - - if (pvRTS != NULL) {//RTS_need, non PCF mode + if (need_rts) { //Fill RsvTime struct vnt_rrv_time_ab *pBuf = (struct vnt_rrv_time_ab *)pvRrvTime; @@ -903,8 +901,7 @@ static void s_vGenerateTxParameter(struct vnt_private *pDevice, //Fill RTS s_vFillRTSHead(pDevice, byPktType, pvRTS, cbFrameSize, bNeedACK, psEthHeader, wCurrentRate, byFBOption); - } - else if (pvRTS == NULL) {//RTS_needless, non PCF mode + } else { //Fill RsvTime struct vnt_rrv_time_ab *pBuf = (struct vnt_rrv_time_ab *)pvRrvTime; @@ -913,8 +910,7 @@ static void s_vGenerateTxParameter(struct vnt_private *pDevice, } } else if (byPktType == PK_TYPE_11B) { - - if ((pvRTS != NULL)) {//RTS_need, non PCF mode + if (need_rts) { //Fill RsvTime struct vnt_rrv_time_ab *pBuf = (struct vnt_rrv_time_ab *)pvRrvTime; @@ -953,7 +949,8 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, u32 cb802_1_H_len; u32 cbIVlen = 0, cbICVlen = 0, cbMIClen = 0, cbMACHdLen = 0; u32 cbFCSlen = 4, cbMICHDR = 0; - int bNeedACK, bRTS; + int bNeedACK; + bool bRTS = false; u8 *pbyType, *pbyMacHdr, *pbyIVHead, *pbyPayloadHead, *pbyTxBufferAddr; u8 abySNAP_RFC1042[ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00}; u8 abySNAP_Bridgetunnel[ETH_ALEN] @@ -1236,7 +1233,7 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, //Fill FIFO,RrvTime,RTS,and CTS s_vGenerateTxParameter(pDevice, byPktType, wCurrentRate, (void *)pbyTxBufferAddr, pvRrvTime, pvRTS, pvCTS, - cbFrameSize, bNeedACK, uDMAIdx, psEthHeader); + cbFrameSize, bNeedACK, uDMAIdx, psEthHeader, bRTS); //Fill DataHead uDuration = s_uFillDataHead(pDevice, byPktType, wCurrentRate, pvTxDataHd, cbFrameSize, uDMAIdx, bNeedACK, byFBOption); @@ -1640,7 +1637,7 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice, //Fill FIFO,RrvTime,RTS,and CTS s_vGenerateTxParameter(pDevice, byPktType, wCurrentRate, pbyTxBufferAddr, pvRrvTime, pvRTS, pCTS, - cbFrameSize, bNeedACK, TYPE_TXDMA0, &sEthHeader); + cbFrameSize, bNeedACK, TYPE_TXDMA0, &sEthHeader, false); //Fill DataHead uDuration = s_uFillDataHead(pDevice, byPktType, wCurrentRate, pvTxDataHd, cbFrameSize, TYPE_TXDMA0, bNeedACK, @@ -2051,7 +2048,7 @@ void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb) //Fill FIFO,RrvTime,RTS,and CTS s_vGenerateTxParameter(pDevice, byPktType, wCurrentRate, pbyTxBufferAddr, pvRrvTime, pvRTS, pvCTS, - cbFrameSize, bNeedACK, TYPE_TXDMA0, &sEthHeader); + cbFrameSize, bNeedACK, TYPE_TXDMA0, &sEthHeader, false); //Fill DataHead uDuration = s_uFillDataHead(pDevice, byPktType, wCurrentRate, pvTxDataHd, cbFrameSize, TYPE_TXDMA0, bNeedACK, -- GitLab From 351c7dc3f7864c79d51d79dbc68ae15a12d1590d Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Tue, 27 Aug 2013 12:02:54 +0100 Subject: [PATCH 871/942] staging: vt6656: rxtx.c merge pvRTS and pvCTS/pCTS void pointers As result of patch rxtx.c s_vGenerateTxParameter create argument bool need rts RTS and CTS void pointers can be merged. Create new pointer rts_cts so that unions in s_vFillCTSHead/s_vFillRTSHead can be joined. If rts_cts is NULL neither exist. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 86 +++++++++++++++-------------------- 1 file changed, 36 insertions(+), 50 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 2fd71c3c06cb1..c9f6ffc8a0214 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -100,7 +100,7 @@ static void *s_vGetFreeContext(struct vnt_private *pDevice); static void s_vGenerateTxParameter(struct vnt_private *pDevice, u8 byPktType, u16 wCurrentRate, void *pTxBufHead, void *pvRrvTime, - void *pvRTS, void *pvCTS, u32 cbFrameSize, int bNeedACK, u32 uDMAIdx, + void *rts_cts, u32 cbFrameSize, int bNeedACK, u32 uDMAIdx, struct ethhdr *psEthHeader, bool need_rts); static u32 s_uFillDataHead(struct vnt_private *pDevice, @@ -828,7 +828,7 @@ static void s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx, static void s_vGenerateTxParameter(struct vnt_private *pDevice, u8 byPktType, u16 wCurrentRate, void *pTxBufHead, void *pvRrvTime, - void *pvRTS, void *pvCTS, u32 cbFrameSize, int bNeedACK, u32 uDMAIdx, + void *rts_cts, u32 cbFrameSize, int bNeedACK, u32 uDMAIdx, struct ethhdr *psEthHeader, bool need_rts) { u32 cbMACHdLen = WLAN_HDR_ADDR3_LEN; /* 24 */ @@ -869,9 +869,9 @@ static void s_vGenerateTxParameter(struct vnt_private *pDevice, pBuf->wTxRrvTime_b = vnt_rxtx_rsvtime_le16(pDevice, PK_TYPE_11B, cbFrameSize, pDevice->byTopCCKBasicRate, bNeedACK); - //Fill RTS - s_vFillRTSHead(pDevice, byPktType, pvRTS, cbFrameSize, bNeedACK, - psEthHeader, wCurrentRate, byFBOption); + /* Fill RTS */ + s_vFillRTSHead(pDevice, byPktType, rts_cts, cbFrameSize, + bNeedACK, psEthHeader, wCurrentRate, byFBOption); } else {//RTS_needless, PCF mode //Fill RsvTime @@ -884,9 +884,9 @@ static void s_vGenerateTxParameter(struct vnt_private *pDevice, pDevice->byTopCCKBasicRate, bNeedACK); pBuf->wCTSTxRrvTime_ba = s_uGetRTSCTSRsvTime(pDevice, 3, byPktType, cbFrameSize, wCurrentRate); - //Fill CTS - s_vFillCTSHead(pDevice, uDMAIdx, byPktType, pvCTS, cbFrameSize, - bNeedACK, wCurrentRate, byFBOption); + /* Fill CTS */ + s_vFillCTSHead(pDevice, uDMAIdx, byPktType, rts_cts, + cbFrameSize, bNeedACK, wCurrentRate, byFBOption); } } else if (byPktType == PK_TYPE_11A) { @@ -898,9 +898,9 @@ static void s_vGenerateTxParameter(struct vnt_private *pDevice, byPktType, cbFrameSize, wCurrentRate); pBuf->wTxRrvTime = vnt_rxtx_rsvtime_le16(pDevice, byPktType, cbFrameSize, wCurrentRate, bNeedACK); - //Fill RTS - s_vFillRTSHead(pDevice, byPktType, pvRTS, cbFrameSize, bNeedACK, - psEthHeader, wCurrentRate, byFBOption); + /* Fill RTS */ + s_vFillRTSHead(pDevice, byPktType, rts_cts, cbFrameSize, + bNeedACK, psEthHeader, wCurrentRate, byFBOption); } else { //Fill RsvTime struct vnt_rrv_time_ab *pBuf = @@ -918,9 +918,9 @@ static void s_vGenerateTxParameter(struct vnt_private *pDevice, byPktType, cbFrameSize, wCurrentRate); pBuf->wTxRrvTime = vnt_rxtx_rsvtime_le16(pDevice, PK_TYPE_11B, cbFrameSize, wCurrentRate, bNeedACK); - //Fill RTS - s_vFillRTSHead(pDevice, byPktType, pvRTS, cbFrameSize, bNeedACK, - psEthHeader, wCurrentRate, byFBOption); + /* Fill RTS */ + s_vFillRTSHead(pDevice, byPktType, rts_cts, cbFrameSize, + bNeedACK, psEthHeader, wCurrentRate, byFBOption); } else { //RTS_needless, non PCF mode //Fill RsvTime @@ -959,8 +959,7 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, u32 cbHeaderLength = 0, uPadding = 0; void *pvRrvTime; struct vnt_mic_hdr *pMICHDR; - void *pvRTS; - void *pvCTS; + void *rts_cts = NULL; void *pvTxDataHd; u8 byFBOption = AUTO_FB_NONE, byFragType; u16 wTxBufSize; @@ -968,7 +967,7 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, u32 *pdwMIC_L, *pdwMIC_R; int bSoftWEP = false; - pvRrvTime = pMICHDR = pvRTS = pvCTS = pvTxDataHd = NULL; + pvRrvTime = pMICHDR = pvTxDataHd = NULL; if (bNeedEncryption && pTransmitKey->pvKeyTable) { if (((PSKeyTable)pTransmitKey->pvKeyTable)->bSoftWEP == true) @@ -1098,9 +1097,8 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, (pbyTxBufferAddr + wTxBufSize); pMICHDR = (struct vnt_mic_hdr *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_rts)); - pvRTS = (struct vnt_rts_g *) (pbyTxBufferAddr + wTxBufSize + + rts_cts = (struct vnt_rts_g *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_rts) + cbMICHDR); - pvCTS = NULL; pvTxDataHd = (struct vnt_tx_datahead_g *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_rts) + cbMICHDR + sizeof(struct vnt_rts_g)); @@ -1113,8 +1111,7 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, (pbyTxBufferAddr + wTxBufSize); pMICHDR = (struct vnt_mic_hdr *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_cts)); - pvRTS = NULL; - pvCTS = (struct vnt_cts *) (pbyTxBufferAddr + wTxBufSize + + rts_cts = (struct vnt_cts *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_cts) + cbMICHDR); pvTxDataHd = (struct vnt_tx_datahead_g *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_cts) + @@ -1130,9 +1127,8 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, wTxBufSize); pMICHDR = (struct vnt_mic_hdr *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_rts)); - pvRTS = (struct vnt_rts_g_fb *) (pbyTxBufferAddr + wTxBufSize + + rts_cts = (struct vnt_rts_g_fb *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_rts) + cbMICHDR); - pvCTS = NULL; pvTxDataHd = (struct vnt_tx_datahead_g_fb *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_rts) + cbMICHDR + sizeof(struct vnt_rts_g_fb)); @@ -1145,8 +1141,7 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, (pbyTxBufferAddr + wTxBufSize); pMICHDR = (struct vnt_mic_hdr *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_cts)); - pvRTS = NULL; - pvCTS = (struct vnt_cts_fb *) (pbyTxBufferAddr + wTxBufSize + + rts_cts = (struct vnt_cts_fb *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_cts) + cbMICHDR); pvTxDataHd = (struct vnt_tx_datahead_g_fb *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_cts) + @@ -1164,9 +1159,8 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, wTxBufSize); pMICHDR = (struct vnt_mic_hdr *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab)); - pvRTS = (struct vnt_rts_ab *) (pbyTxBufferAddr + wTxBufSize + + rts_cts = (struct vnt_rts_ab *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab) + cbMICHDR); - pvCTS = NULL; pvTxDataHd = (struct vnt_tx_datahead_ab *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab) + cbMICHDR + sizeof(struct vnt_rts_ab)); @@ -1179,8 +1173,6 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, wTxBufSize); pMICHDR = (struct vnt_mic_hdr *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab)); - pvRTS = NULL; - pvCTS = NULL; pvTxDataHd = (struct vnt_tx_datahead_ab *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab) + cbMICHDR); cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_ab) + @@ -1193,9 +1185,8 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, wTxBufSize); pMICHDR = (struct vnt_mic_hdr *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab)); - pvRTS = (struct vnt_rts_a_fb *) (pbyTxBufferAddr + wTxBufSize + + rts_cts = (struct vnt_rts_a_fb *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab) + cbMICHDR); - pvCTS = NULL; pvTxDataHd = (struct vnt_tx_datahead_a_fb *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab) + cbMICHDR + sizeof(struct vnt_rts_a_fb)); @@ -1208,8 +1199,6 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, wTxBufSize); pMICHDR = (struct vnt_mic_hdr *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab)); - pvRTS = NULL; - pvCTS = NULL; pvTxDataHd = (struct vnt_tx_datahead_a_fb *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab) + cbMICHDR); cbHeaderLength = wTxBufSize + sizeof(struct vnt_rrv_time_ab) + @@ -1232,7 +1221,7 @@ static int s_bPacketToWirelessUsb(struct vnt_private *pDevice, u8 byPktType, //Fill FIFO,RrvTime,RTS,and CTS s_vGenerateTxParameter(pDevice, byPktType, wCurrentRate, - (void *)pbyTxBufferAddr, pvRrvTime, pvRTS, pvCTS, + (void *)pbyTxBufferAddr, pvRrvTime, rts_cts, cbFrameSize, bNeedACK, uDMAIdx, psEthHeader, bRTS); //Fill DataHead uDuration = s_uFillDataHead(pDevice, byPktType, wCurrentRate, pvTxDataHd, cbFrameSize, uDMAIdx, bNeedACK, @@ -1467,10 +1456,10 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice, PSTxBufHead pTxBufHead; PUSB_SEND_CONTEXT pContext; struct ieee80211_hdr *pMACHeader; - struct vnt_cts *pCTS; struct ethhdr sEthHeader; u8 byPktType, *pbyTxBufferAddr; - void *pvRTS, *pvTxDataHd, *pvRrvTime, *pMICHDR; + void *rts_cts = NULL; + void *pvTxDataHd, *pvRrvTime, *pMICHDR; u32 uDuration, cbReqCount, cbHeaderSize, cbFrameBodySize, cbFrameSize; int bNeedACK, bIsPSPOLL = false; u32 cbIVlen = 0, cbICVlen = 0, cbMIClen = 0, cbFCSlen = 4; @@ -1605,8 +1594,7 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice, pvRrvTime = (struct vnt_rrv_time_cts *) (pbyTxBufferAddr + wTxBufSize); pMICHDR = NULL; - pvRTS = NULL; - pCTS = (struct vnt_cts *) (pbyTxBufferAddr + wTxBufSize + + rts_cts = (struct vnt_cts *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_cts)); pvTxDataHd = (struct vnt_tx_datahead_g *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_cts) + sizeof(struct vnt_cts)); @@ -1616,8 +1604,6 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice, else { // 802.11a/b packet pvRrvTime = (struct vnt_rrv_time_ab *) (pbyTxBufferAddr + wTxBufSize); pMICHDR = NULL; - pvRTS = NULL; - pCTS = NULL; pvTxDataHd = (struct vnt_tx_datahead_ab *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab)); cbHeaderSize = wTxBufSize + sizeof(struct vnt_rrv_time_ab) + @@ -1635,8 +1621,9 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice, //========================= pTxBufHead->wFragCtl |= (u16)FRAGCTL_NONFRAG; - //Fill FIFO,RrvTime,RTS,and CTS - s_vGenerateTxParameter(pDevice, byPktType, wCurrentRate, pbyTxBufferAddr, pvRrvTime, pvRTS, pCTS, + /* Fill FIFO,RrvTime,RTS,and CTS */ + s_vGenerateTxParameter(pDevice, byPktType, wCurrentRate, + pbyTxBufferAddr, pvRrvTime, rts_cts, cbFrameSize, bNeedACK, TYPE_TXDMA0, &sEthHeader, false); //Fill DataHead @@ -1824,7 +1811,8 @@ void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb) struct vnt_tx_buffer *pTX_Buffer; u8 byPktType; u8 *pbyTxBufferAddr; - void *pvRTS, *pvCTS, *pvTxDataHd; + void *rts_cts = NULL; + void *pvTxDataHd; u32 uDuration, cbReqCount; struct ieee80211_hdr *pMACHeader; u32 cbHeaderSize, cbFrameBodySize; @@ -1851,7 +1839,7 @@ void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb) u32 cbExtSuppRate = 0; PUSB_SEND_CONTEXT pContext; - pvRrvTime = pMICHDR = pvRTS = pvCTS = pvTxDataHd = NULL; + pvRrvTime = pMICHDR = pvTxDataHd = NULL; if(skb->len <= WLAN_HDR_ADDR3_LEN) { cbFrameBodySize = 0; @@ -2013,8 +2001,7 @@ void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb) pvRrvTime = (struct vnt_rrv_time_cts *) (pbyTxBufferAddr + wTxBufSize); pMICHDR = (struct vnt_mic_hdr *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_cts)); - pvRTS = NULL; - pvCTS = (struct vnt_cts *) (pbyTxBufferAddr + wTxBufSize + + rts_cts = (struct vnt_cts *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_cts) + cbMICHDR); pvTxDataHd = (struct vnt_tx_datahead_g *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_cts) + cbMICHDR + @@ -2028,8 +2015,6 @@ void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb) pvRrvTime = (struct vnt_rrv_time_ab *) (pbyTxBufferAddr + wTxBufSize); pMICHDR = (struct vnt_mic_hdr *) (pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab)); - pvRTS = NULL; - pvCTS = NULL; pvTxDataHd = (struct vnt_tx_datahead_ab *)(pbyTxBufferAddr + wTxBufSize + sizeof(struct vnt_rrv_time_ab) + cbMICHDR); cbHeaderSize = wTxBufSize + sizeof(struct vnt_rrv_time_ab) + cbMICHDR + @@ -2046,8 +2031,9 @@ void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb) //========================= pTxBufHead->wFragCtl |= (u16)FRAGCTL_NONFRAG; - //Fill FIFO,RrvTime,RTS,and CTS - s_vGenerateTxParameter(pDevice, byPktType, wCurrentRate, pbyTxBufferAddr, pvRrvTime, pvRTS, pvCTS, + /* Fill FIFO,RrvTime,RTS,and CTS */ + s_vGenerateTxParameter(pDevice, byPktType, wCurrentRate, + pbyTxBufferAddr, pvRrvTime, rts_cts, cbFrameSize, bNeedACK, TYPE_TXDMA0, &sEthHeader, false); //Fill DataHead -- GitLab From 5fb8e412abac14823490c4b37e0fbd0efee80837 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Tue, 27 Aug 2013 12:07:58 +0100 Subject: [PATCH 872/942] staging: vt6656: rxtx.c s_vFillRTSHead/s_vFillCTSHead move union vnt_tx_data_head up one level. Move s_vFillRTSHead union vnt_tx_data_head to void *pvRTS argument. s_vFillCTSHead union vnt_tx_data_head to void *pvCTS argument. In s_vGenerateTxParameter create union vnt_tx_data_head pointing to rts_cts; Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index c9f6ffc8a0214..273bd5d4ff294 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -125,11 +125,11 @@ static u16 s_uGetRTSCTSRsvTime(struct vnt_private *pDevice, u8 byRTSRsvType, u8 byPktType, u32 cbFrameLength, u16 wCurrentRate); static void s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx, - u8 byPktType, void *pvCTS, u32 cbFrameLength, int bNeedAck, - u16 wCurrentRate, u8 byFBOption); + u8 byPktType, union vnt_tx_data_head *head, u32 cbFrameLength, + int bNeedAck, u16 wCurrentRate, u8 byFBOption); static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, - void *pvRTS, u32 cbFrameLength, int bNeedAck, + union vnt_tx_data_head *head, u32 cbFrameLength, int bNeedAck, struct ethhdr *psEthHeader, u16 wCurrentRate, u8 byFBOption); static u16 s_uGetDataDuration(struct vnt_private *pDevice, @@ -717,10 +717,9 @@ static int vnt_rxtx_rts_a_fb_head(struct vnt_private *priv, } static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, - void *pvRTS, u32 cbFrameLength, int bNeedAck, + union vnt_tx_data_head *head, u32 cbFrameLength, int bNeedAck, struct ethhdr *psEthHeader, u16 wCurrentRate, u8 byFBOption) { - union vnt_tx_data_head *head = pvRTS; if (!head) return; @@ -757,10 +756,9 @@ static void s_vFillRTSHead(struct vnt_private *pDevice, u8 byPktType, } static void s_vFillCTSHead(struct vnt_private *pDevice, u32 uDMAIdx, - u8 byPktType, void *pvCTS, u32 cbFrameLength, int bNeedAck, - u16 wCurrentRate, u8 byFBOption) + u8 byPktType, union vnt_tx_data_head *head, u32 cbFrameLength, + int bNeedAck, u16 wCurrentRate, u8 byFBOption) { - union vnt_tx_data_head *head = pvCTS; u32 uCTSFrameLen = 14; if (!head) @@ -831,6 +829,7 @@ static void s_vGenerateTxParameter(struct vnt_private *pDevice, void *rts_cts, u32 cbFrameSize, int bNeedACK, u32 uDMAIdx, struct ethhdr *psEthHeader, bool need_rts) { + union vnt_tx_data_head *head = rts_cts; u32 cbMACHdLen = WLAN_HDR_ADDR3_LEN; /* 24 */ u16 wFifoCtl; u8 byFBOption = AUTO_FB_NONE; @@ -870,7 +869,7 @@ static void s_vGenerateTxParameter(struct vnt_private *pDevice, PK_TYPE_11B, cbFrameSize, pDevice->byTopCCKBasicRate, bNeedACK); /* Fill RTS */ - s_vFillRTSHead(pDevice, byPktType, rts_cts, cbFrameSize, + s_vFillRTSHead(pDevice, byPktType, head, cbFrameSize, bNeedACK, psEthHeader, wCurrentRate, byFBOption); } else {//RTS_needless, PCF mode @@ -885,7 +884,7 @@ static void s_vGenerateTxParameter(struct vnt_private *pDevice, pBuf->wCTSTxRrvTime_ba = s_uGetRTSCTSRsvTime(pDevice, 3, byPktType, cbFrameSize, wCurrentRate); /* Fill CTS */ - s_vFillCTSHead(pDevice, uDMAIdx, byPktType, rts_cts, + s_vFillCTSHead(pDevice, uDMAIdx, byPktType, head, cbFrameSize, bNeedACK, wCurrentRate, byFBOption); } } @@ -899,7 +898,7 @@ static void s_vGenerateTxParameter(struct vnt_private *pDevice, pBuf->wTxRrvTime = vnt_rxtx_rsvtime_le16(pDevice, byPktType, cbFrameSize, wCurrentRate, bNeedACK); /* Fill RTS */ - s_vFillRTSHead(pDevice, byPktType, rts_cts, cbFrameSize, + s_vFillRTSHead(pDevice, byPktType, head, cbFrameSize, bNeedACK, psEthHeader, wCurrentRate, byFBOption); } else { //Fill RsvTime @@ -919,7 +918,7 @@ static void s_vGenerateTxParameter(struct vnt_private *pDevice, pBuf->wTxRrvTime = vnt_rxtx_rsvtime_le16(pDevice, PK_TYPE_11B, cbFrameSize, wCurrentRate, bNeedACK); /* Fill RTS */ - s_vFillRTSHead(pDevice, byPktType, rts_cts, cbFrameSize, + s_vFillRTSHead(pDevice, byPktType, head, cbFrameSize, bNeedACK, psEthHeader, wCurrentRate, byFBOption); } else { //RTS_needless, non PCF mode -- GitLab From 95bfb1ae0d2e4a8c58b45f9ff40f4a71c6bbdc6e Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Tue, 27 Aug 2013 12:29:10 +0100 Subject: [PATCH 873/942] staging: vt6656: rxtx.c s_vFillTxKey clean up format and white space. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 175 ++++++++++++++++++---------------- 1 file changed, 93 insertions(+), 82 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 273bd5d4ff294..54aa576341043 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -190,95 +190,106 @@ static void s_vFillTxKey(struct vnt_private *pDevice, u8 *pbyBuf, struct ieee80211_hdr *pMACHeader = (struct ieee80211_hdr *)pbyHdrBuf; u32 dwRevIVCounter; - //Fill TXKEY - if (pTransmitKey == NULL) - return; - - dwRevIVCounter = cpu_to_le32(pDevice->dwIVCounter); - *pdwIV = pDevice->dwIVCounter; - pDevice->byKeyIndex = pTransmitKey->dwKeyIndex & 0xf; - - if (pTransmitKey->byCipherSuite == KEY_CTL_WEP) { - if (pTransmitKey->uKeyLength == WLAN_WEP232_KEYLEN ){ - memcpy(pDevice->abyPRNG, (u8 *)&(dwRevIVCounter), 3); - memcpy(pDevice->abyPRNG+3, pTransmitKey->abyKey, pTransmitKey->uKeyLength); - } else { - memcpy(pbyBuf, (u8 *)&(dwRevIVCounter), 3); - memcpy(pbyBuf+3, pTransmitKey->abyKey, pTransmitKey->uKeyLength); - if(pTransmitKey->uKeyLength == WLAN_WEP40_KEYLEN) { - memcpy(pbyBuf+8, (u8 *)&(dwRevIVCounter), 3); - memcpy(pbyBuf+11, pTransmitKey->abyKey, pTransmitKey->uKeyLength); - } - memcpy(pDevice->abyPRNG, pbyBuf, 16); - } - // Append IV after Mac Header - *pdwIV &= WEP_IV_MASK;//00000000 11111111 11111111 11111111 - *pdwIV |= (u32)pDevice->byKeyIndex << 30; - *pdwIV = cpu_to_le32(*pdwIV); - pDevice->dwIVCounter++; - if (pDevice->dwIVCounter > WEP_IV_MASK) { - pDevice->dwIVCounter = 0; - } - } else if (pTransmitKey->byCipherSuite == KEY_CTL_TKIP) { - pTransmitKey->wTSC15_0++; - if (pTransmitKey->wTSC15_0 == 0) { - pTransmitKey->dwTSC47_16++; - } - TKIPvMixKey(pTransmitKey->abyKey, pDevice->abyCurrentNetAddr, - pTransmitKey->wTSC15_0, pTransmitKey->dwTSC47_16, pDevice->abyPRNG); - memcpy(pbyBuf, pDevice->abyPRNG, 16); - // Make IV - memcpy(pdwIV, pDevice->abyPRNG, 3); - - *(pbyIVHead+3) = (u8)(((pDevice->byKeyIndex << 6) & 0xc0) | 0x20); // 0x20 is ExtIV - // Append IV&ExtIV after Mac Header - *pdwExtIV = cpu_to_le32(pTransmitKey->dwTSC47_16); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"vFillTxKey()---- pdwExtIV: %x\n", - *pdwExtIV); - - } else if (pTransmitKey->byCipherSuite == KEY_CTL_CCMP) { - pTransmitKey->wTSC15_0++; - if (pTransmitKey->wTSC15_0 == 0) { - pTransmitKey->dwTSC47_16++; - } - memcpy(pbyBuf, pTransmitKey->abyKey, 16); - - // Make IV - *pdwIV = 0; - *(pbyIVHead+3) = (u8)(((pDevice->byKeyIndex << 6) & 0xc0) | 0x20); // 0x20 is ExtIV - *pdwIV |= cpu_to_le16((u16)(pTransmitKey->wTSC15_0)); - //Append IV&ExtIV after Mac Header - *pdwExtIV = cpu_to_le32(pTransmitKey->dwTSC47_16); - - if (!mic_hdr) + /* Fill TXKEY */ + if (pTransmitKey == NULL) return; - /* MICHDR0 */ - mic_hdr->id = 0x59; - mic_hdr->payload_len = cpu_to_be16(wPayloadLen); - memcpy(mic_hdr->mic_addr2, pMACHeader->addr2, ETH_ALEN); + dwRevIVCounter = cpu_to_le32(pDevice->dwIVCounter); + *pdwIV = pDevice->dwIVCounter; + pDevice->byKeyIndex = pTransmitKey->dwKeyIndex & 0xf; - mic_hdr->tsc_47_16 = cpu_to_be32(pTransmitKey->dwTSC47_16); - mic_hdr->tsc_15_0 = cpu_to_be16(pTransmitKey->wTSC15_0); - - /* MICHDR1 */ - if (pDevice->bLongHeader) - mic_hdr->hlen = cpu_to_be16(28); - else - mic_hdr->hlen = cpu_to_be16(22); + if (pTransmitKey->byCipherSuite == KEY_CTL_WEP) { + if (pTransmitKey->uKeyLength == WLAN_WEP232_KEYLEN) { + memcpy(pDevice->abyPRNG, (u8 *)&dwRevIVCounter, 3); + memcpy(pDevice->abyPRNG + 3, pTransmitKey->abyKey, + pTransmitKey->uKeyLength); + } else { + memcpy(pbyBuf, (u8 *)&dwRevIVCounter, 3); + memcpy(pbyBuf + 3, pTransmitKey->abyKey, + pTransmitKey->uKeyLength); + if (pTransmitKey->uKeyLength == WLAN_WEP40_KEYLEN) { + memcpy(pbyBuf+8, (u8 *)&dwRevIVCounter, 3); + memcpy(pbyBuf+11, pTransmitKey->abyKey, + pTransmitKey->uKeyLength); + } + + memcpy(pDevice->abyPRNG, pbyBuf, 16); + } + /* Append IV after Mac Header */ + *pdwIV &= WEP_IV_MASK; + *pdwIV |= (u32)pDevice->byKeyIndex << 30; + *pdwIV = cpu_to_le32(*pdwIV); + + pDevice->dwIVCounter++; + if (pDevice->dwIVCounter > WEP_IV_MASK) + pDevice->dwIVCounter = 0; + } else if (pTransmitKey->byCipherSuite == KEY_CTL_TKIP) { + pTransmitKey->wTSC15_0++; + if (pTransmitKey->wTSC15_0 == 0) + pTransmitKey->dwTSC47_16++; + + TKIPvMixKey(pTransmitKey->abyKey, pDevice->abyCurrentNetAddr, + pTransmitKey->wTSC15_0, pTransmitKey->dwTSC47_16, + pDevice->abyPRNG); + memcpy(pbyBuf, pDevice->abyPRNG, 16); + + /* Make IV */ + memcpy(pdwIV, pDevice->abyPRNG, 3); + + *(pbyIVHead+3) = (u8)(((pDevice->byKeyIndex << 6) & + 0xc0) | 0x20); + /* Append IV&ExtIV after Mac Header */ + *pdwExtIV = cpu_to_le32(pTransmitKey->dwTSC47_16); + + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO + "vFillTxKey()---- pdwExtIV: %x\n", *pdwExtIV); + + } else if (pTransmitKey->byCipherSuite == KEY_CTL_CCMP) { + pTransmitKey->wTSC15_0++; + if (pTransmitKey->wTSC15_0 == 0) + pTransmitKey->dwTSC47_16++; + + memcpy(pbyBuf, pTransmitKey->abyKey, 16); + + /* Make IV */ + *pdwIV = 0; + *(pbyIVHead+3) = (u8)(((pDevice->byKeyIndex << 6) & + 0xc0) | 0x20); + + *pdwIV |= cpu_to_le16((u16)(pTransmitKey->wTSC15_0)); + + /* Append IV&ExtIV after Mac Header */ + *pdwExtIV = cpu_to_le32(pTransmitKey->dwTSC47_16); + + if (!mic_hdr) + return; + + /* MICHDR0 */ + mic_hdr->id = 0x59; + mic_hdr->payload_len = cpu_to_be16(wPayloadLen); + memcpy(mic_hdr->mic_addr2, pMACHeader->addr2, ETH_ALEN); + + mic_hdr->tsc_47_16 = cpu_to_be32(pTransmitKey->dwTSC47_16); + mic_hdr->tsc_15_0 = cpu_to_be16(pTransmitKey->wTSC15_0); + + /* MICHDR1 */ + if (pDevice->bLongHeader) + mic_hdr->hlen = cpu_to_be16(28); + else + mic_hdr->hlen = cpu_to_be16(22); - memcpy(mic_hdr->addr1, pMACHeader->addr1, ETH_ALEN); - memcpy(mic_hdr->addr2, pMACHeader->addr2, ETH_ALEN); + memcpy(mic_hdr->addr1, pMACHeader->addr1, ETH_ALEN); + memcpy(mic_hdr->addr2, pMACHeader->addr2, ETH_ALEN); - /* MICHDR2 */ - memcpy(mic_hdr->addr3, pMACHeader->addr3, ETH_ALEN); - mic_hdr->frame_control = cpu_to_le16(pMACHeader->frame_control + /* MICHDR2 */ + memcpy(mic_hdr->addr3, pMACHeader->addr3, ETH_ALEN); + mic_hdr->frame_control = cpu_to_le16(pMACHeader->frame_control & 0xc78f); - mic_hdr->seq_ctrl = cpu_to_le16(pMACHeader->seq_ctrl & 0xf); + mic_hdr->seq_ctrl = cpu_to_le16(pMACHeader->seq_ctrl & 0xf); - if (pDevice->bLongHeader) - memcpy(mic_hdr->addr4, pMACHeader->addr4, ETH_ALEN); - } + if (pDevice->bLongHeader) + memcpy(mic_hdr->addr4, pMACHeader->addr4, ETH_ALEN); + } } static void s_vSWencryption(struct vnt_private *pDevice, -- GitLab From f6804f337686cc768c05ef4799e250c1a8efd40b Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Tue, 27 Aug 2013 12:32:01 +0100 Subject: [PATCH 874/942] staging: vt6656: rxtx.c s_vFillTxKey use switch for pTransmitKey->byCipherSuite Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/rxtx.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 54aa576341043..e4ee352847e4b 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -198,7 +198,8 @@ static void s_vFillTxKey(struct vnt_private *pDevice, u8 *pbyBuf, *pdwIV = pDevice->dwIVCounter; pDevice->byKeyIndex = pTransmitKey->dwKeyIndex & 0xf; - if (pTransmitKey->byCipherSuite == KEY_CTL_WEP) { + switch (pTransmitKey->byCipherSuite) { + case KEY_CTL_WEP: if (pTransmitKey->uKeyLength == WLAN_WEP232_KEYLEN) { memcpy(pDevice->abyPRNG, (u8 *)&dwRevIVCounter, 3); memcpy(pDevice->abyPRNG + 3, pTransmitKey->abyKey, @@ -223,7 +224,9 @@ static void s_vFillTxKey(struct vnt_private *pDevice, u8 *pbyBuf, pDevice->dwIVCounter++; if (pDevice->dwIVCounter > WEP_IV_MASK) pDevice->dwIVCounter = 0; - } else if (pTransmitKey->byCipherSuite == KEY_CTL_TKIP) { + + break; + case KEY_CTL_TKIP: pTransmitKey->wTSC15_0++; if (pTransmitKey->wTSC15_0 == 0) pTransmitKey->dwTSC47_16++; @@ -244,7 +247,8 @@ static void s_vFillTxKey(struct vnt_private *pDevice, u8 *pbyBuf, DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "vFillTxKey()---- pdwExtIV: %x\n", *pdwExtIV); - } else if (pTransmitKey->byCipherSuite == KEY_CTL_CCMP) { + break; + case KEY_CTL_CCMP: pTransmitKey->wTSC15_0++; if (pTransmitKey->wTSC15_0 == 0) pTransmitKey->dwTSC47_16++; -- GitLab From dcdf1d0323a4eea3bc0a1131057f78234d082079 Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Tue, 27 Aug 2013 12:41:50 +0100 Subject: [PATCH 875/942] staging: vt6656: device.h replace typedef struct _USB_SEND_CONTEXT. Replace with struct vnt_usb_send_context. Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/device.h | 24 ++++++++++++------------ drivers/staging/vt6656/main_usb.c | 7 +++---- drivers/staging/vt6656/rxtx.c | 24 ++++++++++++------------ drivers/staging/vt6656/usbpipe.c | 7 ++++--- drivers/staging/vt6656/usbpipe.h | 3 ++- 5 files changed, 33 insertions(+), 32 deletions(-) diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h index e8f4b194005e5..3151c8fb88b35 100644 --- a/drivers/staging/vt6656/device.h +++ b/drivers/staging/vt6656/device.h @@ -179,17 +179,17 @@ typedef struct _RCB } RCB, *PRCB; /* used to track bulk out irps */ -typedef struct _USB_SEND_CONTEXT { - void *pDevice; - struct sk_buff *pPacket; - struct urb *pUrb; - unsigned int uBufLen; - CONTEXT_TYPE Type; - struct ethhdr sEthHeader; - void *Next; - bool bBoolInUse; - unsigned char Data[MAX_TOTAL_SIZE_WITH_ALL_HEADERS]; -} USB_SEND_CONTEXT, *PUSB_SEND_CONTEXT; +struct vnt_usb_send_context { + void *pDevice; + struct sk_buff *pPacket; + struct urb *pUrb; + unsigned int uBufLen; + CONTEXT_TYPE Type; + struct ethhdr sEthHeader; + void *Next; + bool bBoolInUse; + unsigned char Data[MAX_TOTAL_SIZE_WITH_ALL_HEADERS]; +}; /* structure got from configuration file as user-desired default settings */ typedef struct _DEFAULT_CONFIG { @@ -430,7 +430,7 @@ struct vnt_private { unsigned long ulRcvRefCount; /* packets that have not returned back */ /* Variables to track resources for the BULK Out Pipe */ - PUSB_SEND_CONTEXT apTD[CB_MAX_TX_DESC]; + struct vnt_usb_send_context *apTD[CB_MAX_TX_DESC]; u32 cbTD; /* Variables to track resources for the Interrupt In Pipe */ diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index 3bc5834a13cc0..37d66a348d7f1 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -733,7 +733,7 @@ vt6656_probe(struct usb_interface *intf, const struct usb_device_id *id) static void device_free_tx_bufs(struct vnt_private *pDevice) { - PUSB_SEND_CONTEXT pTxContext; + struct vnt_usb_send_context *pTxContext; int ii; for (ii = 0; ii < pDevice->cbTD; ii++) { @@ -788,14 +788,13 @@ static void device_free_int_bufs(struct vnt_private *pDevice) static bool device_alloc_bufs(struct vnt_private *pDevice) { - - PUSB_SEND_CONTEXT pTxContext; + struct vnt_usb_send_context *pTxContext; PRCB pRCB; int ii; for (ii = 0; ii < pDevice->cbTD; ii++) { - pTxContext = kmalloc(sizeof(USB_SEND_CONTEXT), GFP_KERNEL); + pTxContext = kmalloc(sizeof(struct vnt_usb_send_context), GFP_KERNEL); if (pTxContext == NULL) { DBG_PRT(MSG_LEVEL_ERR,KERN_ERR "%s : allocate tx usb context failed\n", pDevice->dev->name); goto free_tx; diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index e4ee352847e4b..fb743a8811bbc 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -141,8 +141,8 @@ static u16 s_uGetRTSCTSDuration(struct vnt_private *pDevice, static void *s_vGetFreeContext(struct vnt_private *pDevice) { - PUSB_SEND_CONTEXT pContext = NULL; - PUSB_SEND_CONTEXT pReturnContext = NULL; + struct vnt_usb_send_context *pContext = NULL; + struct vnt_usb_send_context *pReturnContext = NULL; int ii; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"GetFreeContext()\n"); @@ -1468,7 +1468,7 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice, struct vnt_manager *pMgmt = &pDevice->vnt_mgmt; struct vnt_tx_buffer *pTX_Buffer; PSTxBufHead pTxBufHead; - PUSB_SEND_CONTEXT pContext; + struct vnt_usb_send_context *pContext; struct ieee80211_hdr *pMACHeader; struct ethhdr sEthHeader; u8 byPktType, *pbyTxBufferAddr; @@ -1482,7 +1482,7 @@ CMD_STATUS csMgmt_xmit(struct vnt_private *pDevice, u32 cbMacHdLen; u16 wCurrentRate = RATE_1M; - pContext = (PUSB_SEND_CONTEXT)s_vGetFreeContext(pDevice); + pContext = (struct vnt_usb_send_context *)s_vGetFreeContext(pDevice); if (NULL == pContext) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ManagementSend TX...NO CONTEXT!\n"); @@ -1749,10 +1749,10 @@ CMD_STATUS csBeacon_xmit(struct vnt_private *pDevice, u32 cbFrameBodySize; u32 cbReqCount; u8 *pbyTxBufferAddr; - PUSB_SEND_CONTEXT pContext; + struct vnt_usb_send_context *pContext; CMD_STATUS status; - pContext = (PUSB_SEND_CONTEXT)s_vGetFreeContext(pDevice); + pContext = (struct vnt_usb_send_context *)s_vGetFreeContext(pDevice); if (NULL == pContext) { status = CMD_STATUS_RESOURCES; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ManagementSend TX...NO CONTEXT!\n"); @@ -1851,7 +1851,7 @@ void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb) PSKeyItem pTransmitKey = NULL; u8 *pbyIVHead, *pbyPayloadHead, *pbyMacHdr; u32 cbExtSuppRate = 0; - PUSB_SEND_CONTEXT pContext; + struct vnt_usb_send_context *pContext; pvRrvTime = pMICHDR = pvTxDataHd = NULL; @@ -1863,7 +1863,7 @@ void vDMA0_tx_80211(struct vnt_private *pDevice, struct sk_buff *skb) } p80211Header = (PUWLAN_80211HDR)skb->data; - pContext = (PUSB_SEND_CONTEXT)s_vGetFreeContext(pDevice); + pContext = (struct vnt_usb_send_context *)s_vGetFreeContext(pDevice); if (NULL == pContext) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"DMA0 TX...NO CONTEXT!\n"); @@ -2225,7 +2225,7 @@ int nsDMA_tx_packet(struct vnt_private *pDevice, int bNeedDeAuth = false; u8 *pbyBSSID; int bNodeExist = false; - PUSB_SEND_CONTEXT pContext; + struct vnt_usb_send_context *pContext; bool fConvertedPacket; u32 status; u16 wKeepRate = pDevice->wCurrentRate; @@ -2296,7 +2296,7 @@ int nsDMA_tx_packet(struct vnt_private *pDevice, } } - pContext = (PUSB_SEND_CONTEXT)s_vGetFreeContext(pDevice); + pContext = (struct vnt_usb_send_context *)s_vGetFreeContext(pDevice); if (pContext == NULL) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG" pContext == NULL\n"); @@ -2612,13 +2612,13 @@ int bRelayPacketSend(struct vnt_private *pDevice, u8 *pbySkbData, u32 uDataLen, SKeyItem STempKey; PSKeyItem pTransmitKey = NULL; u8 *pbyBSSID; - PUSB_SEND_CONTEXT pContext; + struct vnt_usb_send_context *pContext; u8 byPktTyp; int fConvertedPacket; u32 status; u16 wKeepRate = pDevice->wCurrentRate; - pContext = (PUSB_SEND_CONTEXT)s_vGetFreeContext(pDevice); + pContext = (struct vnt_usb_send_context *)s_vGetFreeContext(pDevice); if (NULL == pContext) { return false; diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c index 9b9122dc68cde..78749eff26e44 100644 --- a/drivers/staging/vt6656/usbpipe.c +++ b/drivers/staging/vt6656/usbpipe.c @@ -546,7 +546,8 @@ static void s_nsBulkInUsbIoCompleteRead(struct urb *urb) * */ -int PIPEnsSendBulkOut(struct vnt_private *pDevice, PUSB_SEND_CONTEXT pContext) +int PIPEnsSendBulkOut(struct vnt_private *pDevice, + struct vnt_usb_send_context *pContext) { int status; struct urb *pUrb; @@ -628,13 +629,13 @@ static void s_nsBulkOutIoCompleteWrite(struct urb *urb) int status; CONTEXT_TYPE ContextType; unsigned long ulBufLen; - PUSB_SEND_CONTEXT pContext; + struct vnt_usb_send_context *pContext; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsBulkOutIoCompleteWrite\n"); // // The context given to IoSetCompletionRoutine is an USB_CONTEXT struct // - pContext = (PUSB_SEND_CONTEXT) urb->context; + pContext = (struct vnt_usb_send_context *)urb->context; pDevice = pContext->pDevice; ContextType = pContext->Type; diff --git a/drivers/staging/vt6656/usbpipe.h b/drivers/staging/vt6656/usbpipe.h index bb7a61111a621..e2a2bce75f1fc 100644 --- a/drivers/staging/vt6656/usbpipe.h +++ b/drivers/staging/vt6656/usbpipe.h @@ -41,6 +41,7 @@ int PIPEnsControlIn(struct vnt_private *, u8 byRequest, u16 wValue, int PIPEnsInterruptRead(struct vnt_private *); int PIPEnsBulkInUsbRead(struct vnt_private *, PRCB pRCB); -int PIPEnsSendBulkOut(struct vnt_private *, PUSB_SEND_CONTEXT pContext); +int PIPEnsSendBulkOut(struct vnt_private *, + struct vnt_usb_send_context *pContext); #endif /* __USBPIPE_H__ */ -- GitLab From c7fe22f6f6e5715d29bdfca99358001c0dfbdae6 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 26 Aug 2013 15:28:32 -0700 Subject: [PATCH 876/942] staging: comedi: dt2817: fix dt2817_dio_insn_config() This is the (*insn_config) function for a DIO subdevice. It should be using the data[0] value as the "instruction" to perform on the subdevice. Use the comedi_dio_insn_config() helper to properly handle instructions. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt2817.c | 30 ++++++++++++------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt2817.c b/drivers/staging/comedi/drivers/dt2817.c index 51cf1211f1ba6..f4a8529239b54 100644 --- a/drivers/staging/comedi/drivers/dt2817.c +++ b/drivers/staging/comedi/drivers/dt2817.c @@ -43,28 +43,26 @@ Configuration options: static int dt2817_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { - int mask; - int chan; - int oe = 0; - - if (insn->n != 1) - return -EINVAL; + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned int oe = 0; + unsigned int mask; + int ret; - chan = CR_CHAN(insn->chanspec); if (chan < 8) - mask = 0xff; + mask = 0x000000ff; else if (chan < 16) - mask = 0xff00; + mask = 0x0000ff00; else if (chan < 24) - mask = 0xff0000; + mask = 0x00ff0000; else mask = 0xff000000; - if (data[0]) - s->io_bits |= mask; - else - s->io_bits &= ~mask; + + ret = comedi_dio_insn_config(dev, s, insn, data, mask); + if (ret) + return ret; if (s->io_bits & 0x000000ff) oe |= 0x1; @@ -77,7 +75,7 @@ static int dt2817_dio_insn_config(struct comedi_device *dev, outb(oe, dev->iobase + DT2817_CR); - return 1; + return insn->n; } static int dt2817_dio_insn_bits(struct comedi_device *dev, -- GitLab From 9b3e5aec9b275a6a7bad48f2dc2c2dcfd38a4779 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 26 Aug 2013 15:28:51 -0700 Subject: [PATCH 877/942] staging: comedi: dt282x: fix dt282x_dio_insn_config() This is the (*insn_config) function for a DIO subdevice. It should be using the data[0] value as the "instruction" to perform on the subdevice. Use the comedi_dio_insn_config() helper to properly handle instructions. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt282x.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt282x.c b/drivers/staging/comedi/drivers/dt282x.c index 4a25382e9b861..da3ee859bdbce 100644 --- a/drivers/staging/comedi/drivers/dt282x.c +++ b/drivers/staging/comedi/drivers/dt282x.c @@ -982,29 +982,32 @@ static int dt282x_dio_insn_bits(struct comedi_device *dev, static int dt282x_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { struct dt282x_private *devpriv = dev->private; - int mask; + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned int mask; + int ret; - mask = (CR_CHAN(insn->chanspec) < 8) ? 0x00ff : 0xff00; - if (data[0]) - s->io_bits |= mask; + if (chan < 8) + mask = 0x00ff; else - s->io_bits &= ~mask; + mask = 0xff00; + + ret = comedi_dio_insn_config(dev, s, insn, data, mask); + if (ret) + return ret; + devpriv->dacsr &= ~(DT2821_LBOE | DT2821_HBOE); if (s->io_bits & 0x00ff) devpriv->dacsr |= DT2821_LBOE; - else - devpriv->dacsr &= ~DT2821_LBOE; if (s->io_bits & 0xff00) devpriv->dacsr |= DT2821_HBOE; - else - devpriv->dacsr &= ~DT2821_HBOE; outw(devpriv->dacsr, dev->iobase + DT2821_DACSR); - return 1; + return insn->n; } static const struct comedi_lrange *const ai_range_table[] = { -- GitLab From 49b71ebab2b40ffec19007e8b4dba6b8f8622f46 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 26 Aug 2013 15:29:10 -0700 Subject: [PATCH 878/942] staging: comedi: dmm32at: fix dmm32at_dio_insn_config() This is the (*insn_config) function for a DIO subdevice. It should be using the data[0] value as the "instruction" to perform on the subdevice. Use the comedi_dio_insn_config() helper to properly handle instructions. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dmm32at.c | 35 +++++++++++++----------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index 5237f47d39ae9..118a4fd129f90 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -648,31 +648,34 @@ static int dmm32at_dio_insn_bits(struct comedi_device *dev, static int dmm32at_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { struct dmm32at_private *devpriv = dev->private; + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned int mask; unsigned char chanbit; - int chan = CR_CHAN(insn->chanspec); - - if (insn->n != 1) - return -EINVAL; + int ret; - if (chan < 8) + if (chan < 8) { + mask = 0x0000ff; chanbit = DMM32AT_DIRA; - else if (chan < 16) + } else if (chan < 16) { + mask = 0x00ff00; chanbit = DMM32AT_DIRB; - else if (chan < 20) + } else if (chan < 20) { + mask = 0x0f0000; chanbit = DMM32AT_DIRCL; - else + } else { + mask = 0xf00000; chanbit = DMM32AT_DIRCH; + } - /* The input or output configuration of each digital line is - * configured by a special insn_config instruction. chanspec - * contains the channel to be changed, and data[0] contains the - * value COMEDI_INPUT or COMEDI_OUTPUT. */ + ret = comedi_dio_insn_config(dev, s, insn, data, mask); + if (ret) + return ret; - /* if output clear the bit, otherwise set it */ - if (data[0] == COMEDI_OUTPUT) + if (data[0] == INSN_CONFIG_DIO_OUTPUT) devpriv->dio_config &= ~chanbit; else devpriv->dio_config |= chanbit; @@ -681,7 +684,7 @@ static int dmm32at_dio_insn_config(struct comedi_device *dev, /* set the DIO's to the new configuration setting */ outb(devpriv->dio_config, dev->iobase + DMM32AT_DIOCONF); - return 1; + return insn->n; } static int dmm32at_attach(struct comedi_device *dev, -- GitLab From f9f34d57bab010e6f11ec3ebd674b4ff4fc909ee Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 26 Aug 2013 15:29:33 -0700 Subject: [PATCH 879/942] staging: comedi: ni_atmio16d: fix atmio16d_dio_insn_config() This is the (*insn_config) function for a DIO subdevice. It should be using the data[0] value as the "instruction" to perform on the subdevice. Use the comedi_dio_insn_config() helper to properly handle instructions. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_atmio16d.c | 22 ++++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_atmio16d.c b/drivers/staging/comedi/drivers/ni_atmio16d.c index 8520d83d940f7..bb3491f5ad21c 100644 --- a/drivers/staging/comedi/drivers/ni_atmio16d.c +++ b/drivers/staging/comedi/drivers/ni_atmio16d.c @@ -576,15 +576,19 @@ static int atmio16d_dio_insn_config(struct comedi_device *dev, unsigned int *data) { struct atmio16d_private *devpriv = dev->private; - int i; - int mask; + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned int mask; + int ret; + + if (chan < 4) + mask = 0x0f; + else + mask = 0xf0; + + ret = comedi_dio_insn_config(dev, s, insn, data, mask); + if (ret) + return ret; - for (i = 0; i < insn->n; i++) { - mask = (CR_CHAN(insn->chanspec) < 4) ? 0x0f : 0xf0; - s->io_bits &= ~mask; - if (data[i]) - s->io_bits |= mask; - } devpriv->com_reg_2_state &= ~(COMREG2_DOUTEN0 | COMREG2_DOUTEN1); if (s->io_bits & 0x0f) devpriv->com_reg_2_state |= COMREG2_DOUTEN0; @@ -592,7 +596,7 @@ static int atmio16d_dio_insn_config(struct comedi_device *dev, devpriv->com_reg_2_state |= COMREG2_DOUTEN1; outw(devpriv->com_reg_2_state, dev->iobase + COM_REG_2); - return i; + return insn->n; } /* -- GitLab From 0140eb27756899f0d7b2ee0af111839e4006f196 Mon Sep 17 00:00:00 2001 From: Rupesh Gujare Date: Tue, 27 Aug 2013 16:53:42 +0100 Subject: [PATCH 880/942] staging: ozwpan: Add debounce time before unregistering. Fixes following error caused during unloading driver. [ 1127.542888] usb 5-1: USB disconnect, device number 2 [ 1127.542909] ozwpan ozwpan: remove, state 1 [ 1127.542933] usb usb5: USB disconnect, device number 1 [ 1127.618634] hub 5-0:1.0: hub_port_status failed (err = -19) [ 1127.618647] hub_port_connect_change: 45 callbacks suppressed [ 1127.618657] hub 5-0:1.0: connect-debounce failed, port 1 disabled [ 1127.618668] hub 5-0:1.0: cannot disable port 1 (err = -19) Signed-off-by: Rupesh Gujare Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozhcd.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c index 35488608df7a3..4eb2f539f3355 100644 --- a/drivers/staging/ozwpan/ozhcd.c +++ b/drivers/staging/ozwpan/ozhcd.c @@ -57,6 +57,10 @@ */ #define EP0_TIMEOUT_COUNTER 13 +/* Debounce time HCD driver should wait before unregistering. + */ +#define OZ_HUB_DEBOUNCE_TIMEOUT 1500 + /* * Used to link urbs together and also store some status information for each * urb. @@ -2355,6 +2359,7 @@ int oz_hcd_init(void) */ void oz_hcd_term(void) { + msleep(OZ_HUB_DEBOUNCE_TIMEOUT); tasklet_kill(&g_urb_process_tasklet); tasklet_kill(&g_urb_cancel_tasklet); platform_device_unregister(g_plat_dev); -- GitLab From 6850143ab547ca9256c23e7b885612cd6976dfa7 Mon Sep 17 00:00:00 2001 From: Rupesh Gujare Date: Tue, 27 Aug 2013 16:53:41 +0100 Subject: [PATCH 881/942] staging: ozwpan: Reset PORT_ENABLE bit. Reset PORT_ENABLE bit of port status on loosing PD. Signed-off-by: Rupesh Gujare Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozhcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c index 4eb2f539f3355..d6c3d0ebba7b2 100644 --- a/drivers/staging/ozwpan/ozhcd.c +++ b/drivers/staging/ozwpan/ozhcd.c @@ -760,7 +760,7 @@ void oz_hcd_pd_departed(struct oz_port *port) port->config_num = 0; port->flags &= ~(OZ_PORT_F_PRESENT | OZ_PORT_F_DYING); port->flags |= OZ_PORT_F_CHANGED; - port->status &= ~USB_PORT_STAT_CONNECTION; + port->status &= ~(USB_PORT_STAT_CONNECTION | USB_PORT_STAT_ENABLE); port->status |= (USB_PORT_STAT_C_CONNECTION << 16); /* If there is an endpont 0 then clear the pointer while we hold * the spinlock be we deallocate it after releasing the lock. -- GitLab From 854984d70c6b0e67569e5390f50d8c6c9ad5c8b7 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 27 Aug 2013 17:12:36 -0500 Subject: [PATCH 882/942] staging: r8188eu: Fix build error with random configuration The kbuild test robot reports the following error: tree: git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master head: e4a745f9519ef2bbb9d75212ae1cca7582d76266 commit: b63c05394f3fe9ae547e1fa9df30f1ba0bcdabb4 [7011/7939] staging: r8188eu: Turn on build of new driver config: x86_64-randconfig-x0-0828 (attached as .config) All error/warnings: drivers/staging/rtl8188eu/core/rtw_p2p.c: In function 'go_add_group_info_attr': >> drivers/staging/rtl8188eu/core/rtw_p2p.c:70:11: error: 'struct sta_info' has no member named 'is_p2p_device' if (psta->is_p2p_device) { This and the following errors were caused by an incorrect nesting of conditional compilation directives. Signed-off-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/sta_info.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/include/sta_info.h b/drivers/staging/rtl8188eu/include/sta_info.h index acc632ae5ae0d..3ed2a39741adb 100644 --- a/drivers/staging/rtl8188eu/include/sta_info.h +++ b/drivers/staging/rtl8188eu/include/sta_info.h @@ -180,6 +180,7 @@ struct sta_info { u8 has_legacy_ac; unsigned int sleepq_ac_len; +#endif /* CONFIG_88EU_AP_MODE */ #ifdef CONFIG_88EU_P2P /* p2p priv data */ @@ -198,7 +199,6 @@ struct sta_info { #endif /* CONFIG_88EU_P2P */ u8 under_exist_checking; u8 keep_alive_trycnt; -#endif /* CONFIG_88EU_AP_MODE */ /* for DM */ struct rssi_sta rssi_stat; -- GitLab From 7ca1ea66026f1aba48128a0077ce472440aac63e Mon Sep 17 00:00:00 2001 From: Fengguang Wu Date: Tue, 27 Aug 2013 17:08:16 -0700 Subject: [PATCH 883/942] staging: gdm7240: gdm_driver[] can be static Signed-off-by: Fengguang Wu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm724x/gdm_tty.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c index c1530b76cd860..0247a2055e8d6 100644 --- a/drivers/staging/gdm724x/gdm_tty.c +++ b/drivers/staging/gdm724x/gdm_tty.c @@ -47,8 +47,8 @@ #define GDM_TTY_READY(gdm) (gdm && gdm->tty_dev && gdm->port.count) -struct tty_driver *gdm_driver[TTY_MAX_COUNT]; -struct gdm *gdm_table[TTY_MAX_COUNT][GDM_TTY_MINOR]; +static struct tty_driver *gdm_driver[TTY_MAX_COUNT]; +static struct gdm *gdm_table[TTY_MAX_COUNT][GDM_TTY_MINOR]; static DEFINE_MUTEX(gdm_table_lock); static char *DRIVER_STRING[TTY_MAX_COUNT] = {"GCTATC", "GCTDM"}; -- GitLab From 421acbc251a016b98797a06103374b48b30f943a Mon Sep 17 00:00:00 2001 From: Fengguang Wu Date: Tue, 27 Aug 2013 17:36:16 -0700 Subject: [PATCH 884/942] staging: ozwpan: oz_pd_free() can be static Cc: Rupesh Gujare Signed-off-by: Fengguang Wu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozpd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/ozwpan/ozpd.c b/drivers/staging/ozwpan/ozpd.c index e1757aa27253f..ab85a724a0e2d 100644 --- a/drivers/staging/ozwpan/ozpd.c +++ b/drivers/staging/ozwpan/ozpd.c @@ -200,7 +200,7 @@ struct oz_pd *oz_pd_alloc(const u8 *mac_addr) /* * Context: softirq or process */ -void oz_pd_free(struct work_struct *work) +static void oz_pd_free(struct work_struct *work) { struct list_head *e; struct oz_tx_frame *f; -- GitLab From a7a75386f958daa23ac042c0a12b48944ff41c53 Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Tue, 27 Aug 2013 22:13:26 -0400 Subject: [PATCH 885/942] staging: dgnc: tty.c: updates uart_struct declaration for sparse This patch edits the type casts neo_uart_struct and cls_uart_struct. A previous patch added the marker __iomem to these structs. This patch ensures that the change to the marker is consistent. This also removes these sparse warnings: warning: incorrect type in assignment (different address spaces) expected struct neo_uart_struct [noderef] *ch_neo_uart got struct neo_uart_struct * warning: incorrect type in assignment (different address spaces) expected struct cls_uart_struct [noderef] *ch_cls_uart got struct cls_uart_struct * Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_tty.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c index a54b829669762..b4fa29f83cd85 100644 --- a/drivers/staging/dgnc/dgnc_tty.c +++ b/drivers/staging/dgnc/dgnc_tty.c @@ -344,7 +344,7 @@ int dgnc_tty_register(struct board_t *brd) int dgnc_tty_init(struct board_t *brd) { int i; - u8 __iomem *vaddr; + void __iomem *vaddr; struct channel_t *ch; if (!brd) @@ -403,9 +403,9 @@ int dgnc_tty_init(struct board_t *brd) ch->ch_pun.un_dev = i + 128; if (brd->bd_uart_offset == 0x200) - ch->ch_neo_uart = (struct neo_uart_struct *) ((ulong) vaddr + (brd->bd_uart_offset * i)); + ch->ch_neo_uart = vaddr + (brd->bd_uart_offset * i); else - ch->ch_cls_uart = (struct cls_uart_struct *) ((ulong) vaddr + (brd->bd_uart_offset * i)); + ch->ch_cls_uart = vaddr + (brd->bd_uart_offset * i); ch->ch_bd = brd; ch->ch_portnum = i; -- GitLab From 52f9d66844ee191e4d4c0c93394749050aa9b9e5 Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Tue, 27 Aug 2013 22:13:27 -0400 Subject: [PATCH 886/942] staging: dgnc: driver.c and tty.c: replaces dgnc_driver_kzmalloc with kzalloc This patch replaces dgnc_driver_kzmalloc with kzalloc. A patch that follows removes the dgnc_driver_kzmalloc function. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_driver.c | 6 +++--- drivers/staging/dgnc/dgnc_tty.c | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c index 9fef18ac5358d..197c325baa57b 100644 --- a/drivers/staging/dgnc/dgnc_driver.c +++ b/drivers/staging/dgnc/dgnc_driver.c @@ -499,7 +499,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id) /* get the board structure and prep it */ brd = dgnc_Board[dgnc_NumBoards] = - (struct board_t *) dgnc_driver_kzmalloc(sizeof(struct board_t), GFP_KERNEL); + (struct board_t *) kzalloc(sizeof(struct board_t), GFP_KERNEL); if (!brd) { APR(("memory allocation for board structure failed\n")); return(-ENOMEM); @@ -507,7 +507,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id) /* make a temporary message buffer for the boot messages */ brd->msgbuf = brd->msgbuf_head = - (char *) dgnc_driver_kzmalloc(sizeof(char) * 8192, GFP_KERNEL); + (char *) kzalloc(sizeof(char) * 8192, GFP_KERNEL); if (!brd->msgbuf) { kfree(brd); APR(("memory allocation for board msgbuf failed\n")); @@ -721,7 +721,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id) * Okay to malloc with GFP_KERNEL, we are not at interrupt * context, and there are no locks held. */ - brd->flipbuf = dgnc_driver_kzmalloc(MYFLIPLEN, GFP_KERNEL); + brd->flipbuf = kzalloc(MYFLIPLEN, GFP_KERNEL); wake_up_interruptible(&brd->state_wait); diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c index b4fa29f83cd85..a7bb6bceb9e7b 100644 --- a/drivers/staging/dgnc/dgnc_tty.c +++ b/drivers/staging/dgnc/dgnc_tty.c @@ -230,7 +230,7 @@ int dgnc_tty_register(struct board_t *brd) * The kernel wants space to store pointers to * tty_struct's and termios's. */ - brd->SerialDriver.ttys = dgnc_driver_kzmalloc(brd->maxports * sizeof(struct tty_struct *), GFP_KERNEL); + brd->SerialDriver.ttys = kzalloc(brd->maxports * sizeof(struct tty_struct *), GFP_KERNEL); if (!brd->SerialDriver.ttys) return(-ENOMEM); @@ -240,12 +240,12 @@ int dgnc_tty_register(struct board_t *brd) kref_init(&brd->SerialDriver.kref); #endif - brd->SerialDriver.termios = dgnc_driver_kzmalloc(brd->maxports * sizeof(struct ktermios *), GFP_KERNEL); + brd->SerialDriver.termios = kzalloc(brd->maxports * sizeof(struct ktermios *), GFP_KERNEL); if (!brd->SerialDriver.termios) return(-ENOMEM); #if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0) - brd->SerialDriver.termios_locked = dgnc_driver_kzmalloc(brd->maxports * sizeof(struct ktermios *), GFP_KERNEL); + brd->SerialDriver.termios_locked = kzalloc(brd->maxports * sizeof(struct ktermios *), GFP_KERNEL); if (!brd->SerialDriver.termios_locked) return(-ENOMEM); #endif @@ -289,7 +289,7 @@ int dgnc_tty_register(struct board_t *brd) * tty_struct's and termios's. Must be seperate from * the Serial Driver so we don't get confused */ - brd->PrintDriver.ttys = dgnc_driver_kzmalloc(brd->maxports * sizeof(struct tty_struct *), GFP_KERNEL); + brd->PrintDriver.ttys = kzalloc(brd->maxports * sizeof(struct tty_struct *), GFP_KERNEL); if (!brd->PrintDriver.ttys) return(-ENOMEM); @@ -299,12 +299,12 @@ int dgnc_tty_register(struct board_t *brd) kref_init(&brd->PrintDriver.kref); #endif - brd->PrintDriver.termios = dgnc_driver_kzmalloc(brd->maxports * sizeof(struct ktermios *), GFP_KERNEL); + brd->PrintDriver.termios = kzalloc(brd->maxports * sizeof(struct ktermios *), GFP_KERNEL); if (!brd->PrintDriver.termios) return(-ENOMEM); #if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0) - brd->PrintDriver.termios_locked = dgnc_driver_kzmalloc(brd->maxports * sizeof(struct ktermios *), GFP_KERNEL); + brd->PrintDriver.termios_locked = kzalloc(brd->maxports * sizeof(struct ktermios *), GFP_KERNEL); if (!brd->PrintDriver.termios_locked) return(-ENOMEM); #endif @@ -371,7 +371,7 @@ int dgnc_tty_init(struct board_t *brd) * Okay to malloc with GFP_KERNEL, we are not at * interrupt context, and there are no locks held. */ - brd->channels[i] = dgnc_driver_kzmalloc(sizeof(struct channel_t), GFP_KERNEL); + brd->channels[i] = kzalloc(sizeof(struct channel_t), GFP_KERNEL); if (!brd->channels[i]) { DPR_CORE(("%s:%d Unable to allocate memory for channel struct\n", __FILE__, __LINE__)); @@ -1392,11 +1392,11 @@ static int dgnc_tty_open(struct tty_struct *tty, struct file *file) DGNC_UNLOCK(ch->ch_lock, lock_flags); if (!ch->ch_rqueue) - ch->ch_rqueue = dgnc_driver_kzmalloc(RQUEUESIZE, GFP_KERNEL); + ch->ch_rqueue = kzalloc(RQUEUESIZE, GFP_KERNEL); if (!ch->ch_equeue) - ch->ch_equeue = dgnc_driver_kzmalloc(EQUEUESIZE, GFP_KERNEL); + ch->ch_equeue = kzalloc(EQUEUESIZE, GFP_KERNEL); if (!ch->ch_wqueue) - ch->ch_wqueue = dgnc_driver_kzmalloc(WQUEUESIZE, GFP_KERNEL); + ch->ch_wqueue = kzalloc(WQUEUESIZE, GFP_KERNEL); DGNC_LOCK(ch->ch_lock, lock_flags); -- GitLab From f230586994c7f571356570634b942f88bf2772bb Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Tue, 27 Aug 2013 22:13:28 -0400 Subject: [PATCH 887/942] staging: dgnc: driver.c and .h: removes dgnc_driver_kzmalloc func This patch removes the dgnc_driver_kzmalloc function from driver.c and driver.h. A previous patch replaced all dgnc_driver_kzmalloc function calls with kzalloc. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/dgnc_driver.c | 15 --------------- drivers/staging/dgnc/dgnc_driver.h | 1 - 2 files changed, 16 deletions(-) diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c index 197c325baa57b..f8c1e22585d6c 100644 --- a/drivers/staging/dgnc/dgnc_driver.c +++ b/drivers/staging/dgnc/dgnc_driver.c @@ -889,21 +889,6 @@ static void dgnc_init_globals(void) * ************************************************************************/ - -/* - * dgnc_driver_kzmalloc() - * - * Malloc and clear memory, - */ -void *dgnc_driver_kzmalloc(size_t size, int priority) -{ - void *p = kmalloc(size, priority); - if(p) - memset(p, 0, size); - return(p); -} - - /* * dgnc_ms_sleep() * diff --git a/drivers/staging/dgnc/dgnc_driver.h b/drivers/staging/dgnc/dgnc_driver.h index e77303cf6d539..218b15dccb7dc 100644 --- a/drivers/staging/dgnc/dgnc_driver.h +++ b/drivers/staging/dgnc/dgnc_driver.h @@ -542,7 +542,6 @@ struct channel_t { *************************************************************************/ extern int dgnc_ms_sleep(ulong ms); -extern void *dgnc_driver_kzmalloc(size_t size, int priority); extern char *dgnc_ioctl_name(int cmd); /* -- GitLab From 559a4c318ca303880fc9f26d50711791c16ae2f3 Mon Sep 17 00:00:00 2001 From: Andrea Merello Date: Mon, 26 Aug 2013 13:53:30 +0200 Subject: [PATCH 888/942] staging: Update e-mail address for Andrea Merello A lot of files contain reference to my old e-mail address. Now I'm going not to read mail from it anymore, so update it with my current address everywhere. Signed-off-by: Andrea Merello Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8187se/ieee80211/ieee80211.h | 2 +- drivers/staging/rtl8187se/ieee80211/ieee80211_rx.c | 2 +- drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c | 2 +- drivers/staging/rtl8187se/ieee80211/ieee80211_softmac_wx.c | 2 +- drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c | 2 +- drivers/staging/rtl8187se/r8180.h | 2 +- drivers/staging/rtl8187se/r8180_93cx6.h | 2 +- drivers/staging/rtl8187se/r8180_core.c | 4 ++-- drivers/staging/rtl8187se/r8180_hw.h | 2 +- drivers/staging/rtl8187se/r8180_rtl8225.h | 2 +- drivers/staging/rtl8187se/r8180_rtl8225z2.c | 2 +- drivers/staging/rtl8187se/r8180_wx.c | 2 +- drivers/staging/rtl8187se/r8180_wx.h | 2 +- drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c | 2 +- drivers/staging/rtl8192e/rtl8192e/r8192E_dev.h | 2 +- drivers/staging/rtl8192e/rtl8192e/rtl_cam.c | 2 +- drivers/staging/rtl8192e/rtl8192e/rtl_cam.h | 2 +- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 2 +- drivers/staging/rtl8192e/rtl8192e/rtl_core.h | 2 +- drivers/staging/rtl8192e/rtl8192e/rtl_eeprom.c | 2 +- drivers/staging/rtl8192e/rtl8192e/rtl_eeprom.h | 2 +- drivers/staging/rtl8192e/rtl8192e/rtl_ethtool.c | 2 +- drivers/staging/rtl8192e/rtl8192e/rtl_pci.c | 2 +- drivers/staging/rtl8192e/rtl8192e/rtl_pci.h | 2 +- drivers/staging/rtl8192e/rtl8192e/rtl_ps.c | 2 +- drivers/staging/rtl8192e/rtl8192e/rtl_ps.h | 2 +- drivers/staging/rtl8192e/rtllib.h | 2 +- drivers/staging/rtl8192e/rtllib_debug.h | 2 +- drivers/staging/rtl8192e/rtllib_rx.c | 2 +- drivers/staging/rtl8192e/rtllib_softmac.c | 2 +- drivers/staging/rtl8192e/rtllib_softmac_wx.c | 2 +- drivers/staging/rtl8192e/rtllib_tx.c | 2 +- drivers/staging/rtl8192u/authors | 2 +- drivers/staging/rtl8192u/ieee80211/ieee80211.h | 2 +- drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c | 2 +- drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c | 2 +- drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c | 2 +- drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c | 2 +- drivers/staging/rtl8192u/r8180_93cx6.c | 2 +- drivers/staging/rtl8192u/r8180_93cx6.h | 2 +- drivers/staging/rtl8192u/r8180_pm.c | 2 +- drivers/staging/rtl8192u/r8180_pm.h | 2 +- drivers/staging/rtl8192u/r8190_rtl8256.h | 2 +- drivers/staging/rtl8192u/r8192U.h | 2 +- drivers/staging/rtl8192u/r8192U_core.c | 2 +- drivers/staging/rtl8192u/r8192U_hw.h | 2 +- drivers/staging/rtl8192u/r8192U_wx.c | 2 +- drivers/staging/rtl8192u/r8192U_wx.h | 2 +- 48 files changed, 49 insertions(+), 49 deletions(-) diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211.h b/drivers/staging/rtl8187se/ieee80211/ieee80211.h index 8fc9f588b056a..7f015499cfae9 100644 --- a/drivers/staging/rtl8187se/ieee80211/ieee80211.h +++ b/drivers/staging/rtl8187se/ieee80211/ieee80211.h @@ -14,7 +14,7 @@ * Copyright (c) 2004, Intel Corporation * * Modified for Realtek's wi-fi cards by Andrea Merello - * + * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_rx.c index d5df0d691fcc0..10b22100dd3a2 100644 --- a/drivers/staging/rtl8187se/ieee80211/ieee80211_rx.c +++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_rx.c @@ -14,7 +14,7 @@ ****************************************************************************** Few modifications for Realtek's Wi-Fi drivers by - Andrea Merello + Andrea Merello A special thanks goes to Realtek for their support ! diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c index 00f9af06aca5e..b65db542e1ab5 100644 --- a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c @@ -1,5 +1,5 @@ /* IEEE 802.11 SoftMAC layer - * Copyright (c) 2005 Andrea Merello + * Copyright (c) 2005 Andrea Merello * * Mostly extracted from the rtl8180-sa2400 driver for the * in-kernel generic ieee802.11 stack. diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac_wx.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac_wx.c index d9add5305e29c..e5282068e3dee 100644 --- a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac_wx.c +++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac_wx.c @@ -1,5 +1,5 @@ /* IEEE 802.11 SoftMAC layer - * Copyright (c) 2005 Andrea Merello + * Copyright (c) 2005 Andrea Merello * * Mostly extracted from the rtl8180-sa2400 driver for the * in-kernel generic ieee802.11 stack. diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c index 89ed86ef0d15b..b3466530cf942 100644 --- a/drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c +++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c @@ -25,7 +25,7 @@ ****************************************************************************** Few modifications for Realtek's Wi-Fi drivers by - Andrea Merello + Andrea Merello A special thanks goes to Realtek for their support ! diff --git a/drivers/staging/rtl8187se/r8180.h b/drivers/staging/rtl8187se/r8180.h index edacc8001640b..d052f4a9a839e 100644 --- a/drivers/staging/rtl8187se/r8180.h +++ b/drivers/staging/rtl8187se/r8180.h @@ -1,6 +1,6 @@ /* This is part of rtl8180 OpenSource driver. - Copyright (C) Andrea Merello 2004-2005 + Copyright (C) Andrea Merello 2004-2005 Released under the terms of GPL (General Public Licence) Parts of this driver are based on the GPL part of the diff --git a/drivers/staging/rtl8187se/r8180_93cx6.h b/drivers/staging/rtl8187se/r8180_93cx6.h index 79e7391ac8815..b52b5b0610abe 100644 --- a/drivers/staging/rtl8187se/r8180_93cx6.h +++ b/drivers/staging/rtl8187se/r8180_93cx6.h @@ -1,6 +1,6 @@ /* This is part of rtl8180 OpenSource driver - Copyright (C) Andrea Merello 2004-2005 + Copyright (C) Andrea Merello 2004-2005 Released under the terms of GPL (General Public Licence) Parts of this driver are based on the GPL part of the official realtek driver diff --git a/drivers/staging/rtl8187se/r8180_core.c b/drivers/staging/rtl8187se/r8180_core.c index eee4fd3c0643c..5947a6f8e16f9 100644 --- a/drivers/staging/rtl8187se/r8180_core.c +++ b/drivers/staging/rtl8187se/r8180_core.c @@ -1,6 +1,6 @@ /* This is part of rtl818x pci OpenSource driver - v 0.1 - Copyright (C) Andrea Merello 2004-2005 + Copyright (C) Andrea Merello 2004-2005 Released under the terms of GPL (General Public License) Parts of this driver are based on the GPL part of the official @@ -70,7 +70,7 @@ static int hwwep; MODULE_LICENSE("GPL"); MODULE_DEVICE_TABLE(pci, rtl8180_pci_id_tbl); -MODULE_AUTHOR("Andrea Merello "); +MODULE_AUTHOR("Andrea Merello "); MODULE_DESCRIPTION("Linux driver for Realtek RTL8187SE WiFi cards"); module_param_string(ifname, ifname, sizeof(ifname), S_IRUGO|S_IWUSR); diff --git a/drivers/staging/rtl8187se/r8180_hw.h b/drivers/staging/rtl8187se/r8180_hw.h index 533938123a976..92c05af557cf4 100644 --- a/drivers/staging/rtl8187se/r8180_hw.h +++ b/drivers/staging/rtl8187se/r8180_hw.h @@ -1,6 +1,6 @@ /* This is part of rtl8180 OpenSource driver. - Copyright (C) Andrea Merello 2004-2005 + Copyright (C) Andrea Merello 2004-2005 Released under the terms of GPL (General Public Licence) Parts of this driver are based on the GPL part of the diff --git a/drivers/staging/rtl8187se/r8180_rtl8225.h b/drivers/staging/rtl8187se/r8180_rtl8225.h index c6f2128e755cb..c94ca0794a5d5 100644 --- a/drivers/staging/rtl8187se/r8180_rtl8225.h +++ b/drivers/staging/rtl8187se/r8180_rtl8225.h @@ -1,7 +1,7 @@ /* This is part of the rtl8180-sa2400 driver released under the GPL (See file COPYING for details). - Copyright (c) 2005 Andrea Merello + Copyright (c) 2005 Andrea Merello This files contains programming code for the rtl8225 radio frontend. diff --git a/drivers/staging/rtl8187se/r8180_rtl8225z2.c b/drivers/staging/rtl8187se/r8180_rtl8225z2.c index c592f7936ddb6..9ae96b7852f30 100644 --- a/drivers/staging/rtl8187se/r8180_rtl8225z2.c +++ b/drivers/staging/rtl8187se/r8180_rtl8225z2.c @@ -1,7 +1,7 @@ /* * This is part of the rtl8180-sa2400 driver * released under the GPL (See file COPYING for details). - * Copyright (c) 2005 Andrea Merello + * Copyright (c) 2005 Andrea Merello * * This files contains programming code for the rtl8225 * radio frontend. diff --git a/drivers/staging/rtl8187se/r8180_wx.c b/drivers/staging/rtl8187se/r8180_wx.c index 156b75882290f..dab787542c45d 100644 --- a/drivers/staging/rtl8187se/r8180_wx.c +++ b/drivers/staging/rtl8187se/r8180_wx.c @@ -2,7 +2,7 @@ This file contains wireless extension handlers. This is part of rtl8180 OpenSource driver. - Copyright (C) Andrea Merello 2004-2005 + Copyright (C) Andrea Merello 2004-2005 Released under the terms of GPL (General Public Licence) Parts of this driver are based on the GPL part diff --git a/drivers/staging/rtl8187se/r8180_wx.h b/drivers/staging/rtl8187se/r8180_wx.h index 408191403112c..d471520ac7724 100644 --- a/drivers/staging/rtl8187se/r8180_wx.h +++ b/drivers/staging/rtl8187se/r8180_wx.h @@ -1,6 +1,6 @@ /* This is part of rtl8180 OpenSource driver - v 0.3 - Copyright (C) Andrea Merello 2004 + Copyright (C) Andrea Merello 2004 Released under the terms of GPL (General Public Licence) Parts of this driver are based on the GPL part of the official realtek driver diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c index 50c7bb773984e..74fbd70d58388 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c @@ -2,7 +2,7 @@ * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. * * Based on the r8180 driver, which is: - * Copyright 2004-2005 Andrea Merello , et al. + * Copyright 2004-2005 Andrea Merello , et al. * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.h b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.h index b9b3b52f9120a..dbe0e1c87056b 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.h +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.h @@ -2,7 +2,7 @@ * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. * * Based on the r8180 driver, which is: - * Copyright 2004-2005 Andrea Merello , et al. + * Copyright 2004-2005 Andrea Merello , et al. * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_cam.c b/drivers/staging/rtl8192e/rtl8192e/rtl_cam.c index baf3b6342e440..fa5603a562c34 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_cam.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_cam.c @@ -2,7 +2,7 @@ * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. * * Based on the r8180 driver, which is: - * Copyright 2004-2005 Andrea Merello , et al. + * Copyright 2004-2005 Andrea Merello , et al. * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_cam.h b/drivers/staging/rtl8192e/rtl8192e/rtl_cam.h index fa607f98b1722..7d075d3cbe62b 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_cam.h +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_cam.h @@ -2,7 +2,7 @@ * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. * * Based on the r8180 driver, which is: - * Copyright 2004-2005 Andrea Merello , et al. + * Copyright 2004-2005 Andrea Merello , et al. * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index d952a347679da..e068443555519 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -2,7 +2,7 @@ * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. * * Based on the r8180 driver, which is: - * Copyright 2004-2005 Andrea Merello , et al. + * Copyright 2004-2005 Andrea Merello , et al. * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h index 9d7cb0edb2d36..b015bf61cf057 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h @@ -2,7 +2,7 @@ * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. * * Based on the r8180 driver, which is: - * Copyright 2004-2005 Andrea Merello , et al. + * Copyright 2004-2005 Andrea Merello , et al. * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_eeprom.c b/drivers/staging/rtl8192e/rtl8192e/rtl_eeprom.c index c1ccff4a83210..a6778e0853c72 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_eeprom.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_eeprom.c @@ -2,7 +2,7 @@ * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. * * Based on the r8180 driver, which is: - * Copyright 2004-2005 Andrea Merello , et al. + * Copyright 2004-2005 Andrea Merello , et al. * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_eeprom.h b/drivers/staging/rtl8192e/rtl8192e/rtl_eeprom.h index 9452e1683a724..adea2b4c7a449 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_eeprom.h +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_eeprom.h @@ -2,7 +2,7 @@ * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. * * Based on the r8180 driver, which is: - * Copyright 2004-2005 Andrea Merello , et al. + * Copyright 2004-2005 Andrea Merello , et al. * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_ethtool.c b/drivers/staging/rtl8192e/rtl8192e/rtl_ethtool.c index 0cfb3ecaadee5..529ea54d16831 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_ethtool.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_ethtool.c @@ -2,7 +2,7 @@ * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. * * Based on the r8180 driver, which is: - * Copyright 2004-2005 Andrea Merello , et al. + * Copyright 2004-2005 Andrea Merello , et al. * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_pci.c b/drivers/staging/rtl8192e/rtl8192e/rtl_pci.c index 5abbee37cdca1..2ad92eee50c27 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_pci.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_pci.c @@ -2,7 +2,7 @@ * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. * * Based on the r8180 driver, which is: - * Copyright 2004-2005 Andrea Merello , et al. + * Copyright 2004-2005 Andrea Merello , et al. * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_pci.h b/drivers/staging/rtl8192e/rtl8192e/rtl_pci.h index 28c7da677a80a..356aec4379631 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_pci.h +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_pci.h @@ -2,7 +2,7 @@ * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. * * Based on the r8180 driver, which is: - * Copyright 2004-2005 Andrea Merello , et al. + * Copyright 2004-2005 Andrea Merello , et al. * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_ps.c b/drivers/staging/rtl8192e/rtl8192e/rtl_ps.c index c9a7c563b6826..a8c2ade4f4353 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_ps.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_ps.c @@ -2,7 +2,7 @@ * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. * * Based on the r8180 driver, which is: - * Copyright 2004-2005 Andrea Merello , et al. + * Copyright 2004-2005 Andrea Merello , et al. * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_ps.h b/drivers/staging/rtl8192e/rtl8192e/rtl_ps.h index df79d6c4ca03e..962f2e5b8bf82 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_ps.h +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_ps.h @@ -2,7 +2,7 @@ * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. * * Based on the r8180 driver, which is: - * Copyright 2004-2005 Andrea Merello , et al. + * Copyright 2004-2005 Andrea Merello , et al. * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h index 3485ef1dfab15..05ef49f24cd91 100644 --- a/drivers/staging/rtl8192e/rtllib.h +++ b/drivers/staging/rtl8192e/rtllib.h @@ -14,7 +14,7 @@ * Copyright (c) 2004, Intel Corporation * * Modified for Realtek's wi-fi cards by Andrea Merello - * + * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as diff --git a/drivers/staging/rtl8192e/rtllib_debug.h b/drivers/staging/rtl8192e/rtllib_debug.h index 2bfc1155f5054..c59f67b263638 100644 --- a/drivers/staging/rtl8192e/rtllib_debug.h +++ b/drivers/staging/rtl8192e/rtllib_debug.h @@ -2,7 +2,7 @@ * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved. * * Based on the r8180 driver, which is: - * Copyright 2004-2005 Andrea Merello , et al. + * Copyright 2004-2005 Andrea Merello , et al. * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index 6a51f29e0737f..8aeaed5a987d6 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -14,7 +14,7 @@ ****************************************************************************** Few modifications for Realtek's Wi-Fi drivers by - Andrea Merello + Andrea Merello A special thanks goes to Realtek for their support ! diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index aefffac556a66..0cbf6f5593a39 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -1,5 +1,5 @@ /* IEEE 802.11 SoftMAC layer - * Copyright (c) 2005 Andrea Merello + * Copyright (c) 2005 Andrea Merello * * Mostly extracted from the rtl8180-sa2400 driver for the * in-kernel generic ieee802.11 stack. diff --git a/drivers/staging/rtl8192e/rtllib_softmac_wx.c b/drivers/staging/rtl8192e/rtllib_softmac_wx.c index 740cf85e9d5b1..e6af8cfab12b7 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac_wx.c +++ b/drivers/staging/rtl8192e/rtllib_softmac_wx.c @@ -1,5 +1,5 @@ /* IEEE 802.11 SoftMAC layer - * Copyright (c) 2005 Andrea Merello + * Copyright (c) 2005 Andrea Merello * * Mostly extracted from the rtl8180-sa2400 driver for the * in-kernel generic ieee802.11 stack. diff --git a/drivers/staging/rtl8192e/rtllib_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c index 759d7c7d78e5d..1cc6a9d5e8a3d 100644 --- a/drivers/staging/rtl8192e/rtllib_tx.c +++ b/drivers/staging/rtl8192e/rtllib_tx.c @@ -25,7 +25,7 @@ ****************************************************************************** Few modifications for Realtek's Wi-Fi drivers by - Andrea Merello + Andrea Merello A special thanks goes to Realtek for their support ! diff --git a/drivers/staging/rtl8192u/authors b/drivers/staging/rtl8192u/authors index b08bbae39e727..0fab11228b48b 100644 --- a/drivers/staging/rtl8192u/authors +++ b/drivers/staging/rtl8192u/authors @@ -1 +1 @@ -Andrea Merello +Andrea Merello diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211.h b/drivers/staging/rtl8192u/ieee80211/ieee80211.h index c9f3bb363be42..bc64f05a7e6af 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211.h +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211.h @@ -14,7 +14,7 @@ * Copyright (c) 2004, Intel Corporation * * Modified for Realtek's wi-fi cards by Andrea Merello - * + * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c index a6b18409103ba..59900bfa1c18f 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c @@ -14,7 +14,7 @@ ****************************************************************************** Few modifications for Realtek's Wi-Fi drivers by - Andrea Merello + Andrea Merello A special thanks goes to Realtek for their support ! diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index 8a0075db92531..5fd696926ee3c 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -1,5 +1,5 @@ /* IEEE 802.11 SoftMAC layer - * Copyright (c) 2005 Andrea Merello + * Copyright (c) 2005 Andrea Merello * * Mostly extracted from the rtl8180-sa2400 driver for the * in-kernel generic ieee802.11 stack. diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c index 60746b8b1eb0e..7b7d929f1536b 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c @@ -1,5 +1,5 @@ /* IEEE 802.11 SoftMAC layer - * Copyright (c) 2005 Andrea Merello + * Copyright (c) 2005 Andrea Merello * * Mostly extracted from the rtl8180-sa2400 driver for the * in-kernel generic ieee802.11 stack. diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c index 995504207fc66..a7bcc64ff2263 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c @@ -25,7 +25,7 @@ ****************************************************************************** Few modifications for Realtek's Wi-Fi drivers by - Andrea Merello + Andrea Merello A special thanks goes to Realtek for their support ! diff --git a/drivers/staging/rtl8192u/r8180_93cx6.c b/drivers/staging/rtl8192u/r8180_93cx6.c index d2199986d1326..c61729b727ef9 100644 --- a/drivers/staging/rtl8192u/r8180_93cx6.c +++ b/drivers/staging/rtl8192u/r8180_93cx6.c @@ -3,7 +3,7 @@ memory is addressed by 16 bits words. This is part of rtl8180 OpenSource driver. - Copyright (C) Andrea Merello 2004 + Copyright (C) Andrea Merello 2004 Released under the terms of GPL (General Public Licence) Parts of this driver are based on the GPL part of the diff --git a/drivers/staging/rtl8192u/r8180_93cx6.h b/drivers/staging/rtl8192u/r8180_93cx6.h index 5cea51e1142e5..ee55dbffe32c2 100644 --- a/drivers/staging/rtl8192u/r8180_93cx6.h +++ b/drivers/staging/rtl8192u/r8180_93cx6.h @@ -1,6 +1,6 @@ /* This is part of rtl8187 OpenSource driver - Copyright (C) Andrea Merello 2004-2005 + Copyright (C) Andrea Merello 2004-2005 Released under the terms of GPL (General Public Licence) Parts of this driver are based on the GPL part of the official realtek driver diff --git a/drivers/staging/rtl8192u/r8180_pm.c b/drivers/staging/rtl8192u/r8180_pm.c index 0c58d0ed502af..999968d417203 100644 --- a/drivers/staging/rtl8192u/r8180_pm.c +++ b/drivers/staging/rtl8192u/r8180_pm.c @@ -5,7 +5,7 @@ does not do anything useful. This is part of rtl8180 OpenSource driver. - Copyright (C) Andrea Merello 2004 + Copyright (C) Andrea Merello 2004 Released under the terms of GPL (General Public Licence) */ diff --git a/drivers/staging/rtl8192u/r8180_pm.h b/drivers/staging/rtl8192u/r8180_pm.h index 52d6fba99debf..4be63da0b7819 100644 --- a/drivers/staging/rtl8192u/r8180_pm.h +++ b/drivers/staging/rtl8192u/r8180_pm.h @@ -5,7 +5,7 @@ does not do anything useful. This is part of rtl8180 OpenSource driver. - Copyright (C) Andrea Merello 2004 + Copyright (C) Andrea Merello 2004 Released under the terms of GPL (General Public Licence) */ diff --git a/drivers/staging/rtl8192u/r8190_rtl8256.h b/drivers/staging/rtl8192u/r8190_rtl8256.h index b64dd662761af..592e7807fa428 100644 --- a/drivers/staging/rtl8192u/r8190_rtl8256.h +++ b/drivers/staging/rtl8192u/r8190_rtl8256.h @@ -1,7 +1,7 @@ /* This is part of the rtl8180-sa2400 driver released under the GPL (See file COPYING for details). - Copyright (c) 2005 Andrea Merello + Copyright (c) 2005 Andrea Merello This files contains programming code for the rtl8256 radio frontend. diff --git a/drivers/staging/rtl8192u/r8192U.h b/drivers/staging/rtl8192u/r8192U.h index 338e7bc237c3d..b484ee128c13f 100644 --- a/drivers/staging/rtl8192u/r8192U.h +++ b/drivers/staging/rtl8192u/r8192U.h @@ -1,6 +1,6 @@ /* * This is part of rtl8187 OpenSource driver. - * Copyright (C) Andrea Merello 2004-2005 + * Copyright (C) Andrea Merello 2004-2005 * Released under the terms of GPL (General Public Licence) * * Parts of this driver are based on the GPL part of the diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index 14c14c24ac500..cd0946db025c3 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -3,7 +3,7 @@ * Linux device driver for RTL8192U * * Based on the r8187 driver, which is: - * Copyright 2004-2005 Andrea Merello , et al. + * Copyright 2004-2005 Andrea Merello , et al. * This program is free software; you can redistribute it and/or modify it * under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. diff --git a/drivers/staging/rtl8192u/r8192U_hw.h b/drivers/staging/rtl8192u/r8192U_hw.h index 7e612aa56fa4c..dd07a735b5377 100644 --- a/drivers/staging/rtl8192u/r8192U_hw.h +++ b/drivers/staging/rtl8192u/r8192U_hw.h @@ -1,6 +1,6 @@ /* This is part of rtl8187 OpenSource driver. - Copyright (C) Andrea Merello 2004-2005 + Copyright (C) Andrea Merello 2004-2005 Released under the terms of GPL (General Public Licence) Parts of this driver are based on the GPL part of the diff --git a/drivers/staging/rtl8192u/r8192U_wx.c b/drivers/staging/rtl8192u/r8192U_wx.c index 3e2576347d29e..61f6620213e2e 100644 --- a/drivers/staging/rtl8192u/r8192U_wx.c +++ b/drivers/staging/rtl8192u/r8192U_wx.c @@ -2,7 +2,7 @@ This file contains wireless extension handlers. This is part of rtl8180 OpenSource driver. - Copyright (C) Andrea Merello 2004-2005 + Copyright (C) Andrea Merello 2004-2005 Released under the terms of GPL (General Public Licence) Parts of this driver are based on the GPL part diff --git a/drivers/staging/rtl8192u/r8192U_wx.h b/drivers/staging/rtl8192u/r8192U_wx.h index 9f6b10505426f..ae7a617740a31 100644 --- a/drivers/staging/rtl8192u/r8192U_wx.h +++ b/drivers/staging/rtl8192u/r8192U_wx.h @@ -1,6 +1,6 @@ /* This is part of rtl8180 OpenSource driver - v 0.3 - Copyright (C) Andrea Merello 2004 + Copyright (C) Andrea Merello 2004 Released under the terms of GPL (General Public Licence) Parts of this driver are based on the GPL part of the official realtek driver -- GitLab From c6b223b1899f97736b4bee5535ffc76e846c2bf2 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 28 Aug 2013 10:53:49 +0530 Subject: [PATCH 889/942] staging: gdm724x: Remove version.h header inclusion in netlink_k.c version.h header inclusion is not necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm724x/netlink_k.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/gdm724x/netlink_k.c b/drivers/staging/gdm724x/netlink_k.c index 9e8be6a48261d..77fc64e28428f 100644 --- a/drivers/staging/gdm724x/netlink_k.c +++ b/drivers/staging/gdm724x/netlink_k.c @@ -13,7 +13,6 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt -#include #include #include #include -- GitLab From 63fa65d3322f1ddeb912d5128b0a2cd072806903 Mon Sep 17 00:00:00 2001 From: Oleksandr Kravchenko Date: Wed, 28 Aug 2013 12:01:00 +0100 Subject: [PATCH 890/942] staging: iio: Documentation sysfs-bus-iio add power_mode Add description about in_accelX_power_mode and in_accel_power_mode_available. Signed-off-by: Oleksandr Kravchenko Signed-off-by: Jonathan Cameron --- Documentation/ABI/testing/sysfs-bus-iio | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio index 45ae709db4ffc..39c8de0e53d00 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio +++ b/Documentation/ABI/testing/sysfs-bus-iio @@ -794,6 +794,16 @@ Description: This attribute is used to read the amount of quadrature error present in the device at a given time. +What: /sys/.../iio:deviceX/in_accelX_power_mode +KernelVersion: 3.11 +Contact: linux-iio@vger.kernel.org +Description: + Specifies the chip power mode. + low_noise: reduce noise level from ADC, + low_power: enable low current consumption. + For a list of available output power modes read + in_accel_power_mode_available. + What: /sys/bus/iio/devices/iio:deviceX/store_eeprom KernelVersion: 3.4.0 Contact: linux-iio@vger.kernel.org -- GitLab From fdadbce0da424c3f608576504f04e807217746a5 Mon Sep 17 00:00:00 2001 From: Oleksandr Kravchenko Date: Wed, 28 Aug 2013 12:01:00 +0100 Subject: [PATCH 891/942] iio: add Bosch BMA180 acceleration sensor driver This patch adds IIO driver for Bosch BMA180 triaxial acceleration sensor. http://dlnmh9ip6v2uc.cloudfront.net/datasheets/ Sensors/Accelerometers/BST-BMA180-DS000-07_2.pdf Signed-off-by: Oleksandr Kravchenko Acked-by: Stephen Warren Signed-off-by: Jonathan Cameron --- .../devicetree/bindings/iio/accel/bma180.txt | 24 + drivers/iio/accel/Kconfig | 12 + drivers/iio/accel/Makefile | 1 + drivers/iio/accel/bma180.c | 676 ++++++++++++++++++ 4 files changed, 713 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/accel/bma180.txt create mode 100644 drivers/iio/accel/bma180.c diff --git a/Documentation/devicetree/bindings/iio/accel/bma180.txt b/Documentation/devicetree/bindings/iio/accel/bma180.txt new file mode 100644 index 0000000000000..c5933573e0f6d --- /dev/null +++ b/Documentation/devicetree/bindings/iio/accel/bma180.txt @@ -0,0 +1,24 @@ +* Bosch BMA180 triaxial acceleration sensor + +http://omapworld.com/BMA180_111_1002839.pdf + +Required properties: + + - compatible : should be "bosch,bma180" + - reg : the I2C address of the sensor + +Optional properties: + + - interrupt-parent : should be the phandle for the interrupt controller + + - interrupts : interrupt mapping for GPIO IRQ, it should by configured with + flags IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_EDGE_RISING + +Example: + +bma180@40 { + compatible = "bosch,bma180"; + reg = <0x40>; + interrupt-parent = <&gpio6>; + interrupts = <18 (IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_EDGE_RISING)>; +}; diff --git a/drivers/iio/accel/Kconfig b/drivers/iio/accel/Kconfig index 61ca7ec0f3e71..e23e50850655f 100644 --- a/drivers/iio/accel/Kconfig +++ b/drivers/iio/accel/Kconfig @@ -5,6 +5,18 @@ menu "Accelerometers" +config BMA180 + tristate "Bosch BMA180 3-Axis Accelerometer Driver" + depends on I2C + select IIO_BUFFER + select IIO_TRIGGERED_BUFFER + help + Say Y here if you want to build a driver for the Bosch BMA180 + triaxial acceleration sensor. + + To compile this driver as a module, choose M here: the + module will be called bma180. + config HID_SENSOR_ACCEL_3D depends on HID_SENSOR_HUB select IIO_BUFFER diff --git a/drivers/iio/accel/Makefile b/drivers/iio/accel/Makefile index 2f95a3dffa474..c48d15f25616a 100644 --- a/drivers/iio/accel/Makefile +++ b/drivers/iio/accel/Makefile @@ -3,6 +3,7 @@ # # When adding new entries keep the list in alphabetical order +obj-$(CONFIG_BMA180) += bma180.o obj-$(CONFIG_HID_SENSOR_ACCEL_3D) += hid-sensor-accel-3d.o obj-$(CONFIG_KXSD9) += kxsd9.o diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c new file mode 100644 index 0000000000000..12e32e6b41037 --- /dev/null +++ b/drivers/iio/accel/bma180.c @@ -0,0 +1,676 @@ +/* + * bma180.c - IIO driver for Bosch BMA180 triaxial acceleration sensor + * + * Copyright 2013 Oleksandr Kravchenko + * + * This file is subject to the terms and conditions of version 2 of + * the GNU General Public License. See the file COPYING in the main + * directory of this archive for more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define BMA180_DRV_NAME "bma180" +#define BMA180_IRQ_NAME "bma180_event" + +/* Register set */ +#define BMA180_CHIP_ID 0x00 /* Need to distinguish BMA180 from other */ +#define BMA180_ACC_X_LSB 0x02 /* First of 6 registers of accel data */ +#define BMA180_CTRL_REG0 0x0d +#define BMA180_RESET 0x10 +#define BMA180_BW_TCS 0x20 +#define BMA180_CTRL_REG3 0x21 +#define BMA180_TCO_Z 0x30 +#define BMA180_OFFSET_LSB1 0x35 + +/* BMA180_CTRL_REG0 bits */ +#define BMA180_DIS_WAKE_UP BIT(0) /* Disable wake up mode */ +#define BMA180_SLEEP BIT(1) /* 1 - chip will sleep */ +#define BMA180_EE_W BIT(4) /* Unlock writing to addr from 0x20 */ +#define BMA180_RESET_INT BIT(6) /* Reset pending interrupts */ + +/* BMA180_CTRL_REG3 bits */ +#define BMA180_NEW_DATA_INT BIT(1) /* Intr every new accel data is ready */ + +/* BMA180_OFFSET_LSB1 skipping mode bit */ +#define BMA180_SMP_SKIP BIT(0) + +/* Bit masks for registers bit fields */ +#define BMA180_RANGE 0x0e /* Range of measured accel values*/ +#define BMA180_BW 0xf0 /* Accel bandwidth */ +#define BMA180_MODE_CONFIG 0x03 /* Config operation modes */ + +/* We have to write this value in reset register to do soft reset */ +#define BMA180_RESET_VAL 0xb6 + +#define BMA_180_ID_REG_VAL 0x03 + +/* Chip power modes */ +#define BMA180_LOW_NOISE 0x00 +#define BMA180_LOW_POWER 0x03 + +#define BMA180_LOW_NOISE_STR "low_noise" +#define BMA180_LOW_POWER_STR "low_power" + +/* Defaults values */ +#define BMA180_DEF_PMODE 0 +#define BMA180_DEF_BW 20 +#define BMA180_DEF_SCALE 250 + +/* Available values for sysfs */ +#define BMA180_FLP_FREQ_AVAILABLE \ + "10 20 40 75 150 300" +#define BMA180_SCALE_AVAILABLE \ + "0.000130 0.000190 0.000250 0.000380 0.000500 0.000990 0.001980" + +struct bma180_data { + struct i2c_client *client; + struct iio_trigger *trig; + struct mutex mutex; + int sleep_state; + int scale; + int bw; + int pmode; + char *buff; +}; + +enum bma180_axis { + AXIS_X, + AXIS_Y, + AXIS_Z, +}; + +static int bw_table[] = { 10, 20, 40, 75, 150, 300 }; /* Hz */ +static int scale_table[] = { 130, 190, 250, 380, 500, 990, 1980 }; + +static int bma180_get_acc_reg(struct bma180_data *data, enum bma180_axis axis) +{ + u8 reg = BMA180_ACC_X_LSB + axis * 2; + int ret; + + if (data->sleep_state) + return -EBUSY; + + ret = i2c_smbus_read_word_data(data->client, reg); + if (ret < 0) + dev_err(&data->client->dev, + "failed to read accel_%c registers\n", 'x' + axis); + + return ret; +} + +static int bma180_set_bits(struct bma180_data *data, u8 reg, u8 mask, u8 val) +{ + int ret = i2c_smbus_read_byte_data(data->client, reg); + u8 reg_val = (ret & ~mask) | (val << (ffs(mask) - 1)); + + if (ret < 0) + return ret; + + return i2c_smbus_write_byte_data(data->client, reg, reg_val); +} + +static int bma180_reset_intr(struct bma180_data *data) +{ + int ret = bma180_set_bits(data, BMA180_CTRL_REG0, BMA180_RESET_INT, 1); + + if (ret) + dev_err(&data->client->dev, "failed to reset interrupt\n"); + + return ret; +} + +static int bma180_set_new_data_intr_state(struct bma180_data *data, int state) +{ + u8 reg_val = state ? BMA180_NEW_DATA_INT : 0x00; + int ret = i2c_smbus_write_byte_data(data->client, BMA180_CTRL_REG3, + reg_val); + + if (ret) + goto err; + ret = bma180_reset_intr(data); + if (ret) + goto err; + + return 0; + +err: + dev_err(&data->client->dev, + "failed to set new data interrupt state %d\n", state); + return ret; +} + +static int bma180_set_sleep_state(struct bma180_data *data, int state) +{ + int ret = bma180_set_bits(data, BMA180_CTRL_REG0, BMA180_SLEEP, state); + + if (ret) { + dev_err(&data->client->dev, + "failed to set sleep state %d\n", state); + return ret; + } + data->sleep_state = state; + + return 0; +} + +static int bma180_set_ee_writing_state(struct bma180_data *data, int state) +{ + int ret = bma180_set_bits(data, BMA180_CTRL_REG0, BMA180_EE_W, state); + + if (ret) + dev_err(&data->client->dev, + "failed to set ee writing state %d\n", state); + + return ret; +} + +static int bma180_set_bw(struct bma180_data *data, int val) +{ + int ret, i; + + if (data->sleep_state) + return -EBUSY; + + for (i = 0; i < ARRAY_SIZE(bw_table); ++i) { + if (bw_table[i] == val) { + ret = bma180_set_bits(data, + BMA180_BW_TCS, BMA180_BW, i); + if (ret) { + dev_err(&data->client->dev, + "failed to set bandwidth\n"); + return ret; + } + data->bw = val; + return 0; + } + } + + return -EINVAL; +} + +static int bma180_set_scale(struct bma180_data *data, int val) +{ + int ret, i; + + if (data->sleep_state) + return -EBUSY; + + for (i = 0; i < ARRAY_SIZE(scale_table); ++i) + if (scale_table[i] == val) { + ret = bma180_set_bits(data, + BMA180_OFFSET_LSB1, BMA180_RANGE, i); + if (ret) { + dev_err(&data->client->dev, + "failed to set scale\n"); + return ret; + } + data->scale = val; + return 0; + } + + return -EINVAL; +} + +static int bma180_set_pmode(struct bma180_data *data, int mode) +{ + u8 reg_val = mode ? BMA180_LOW_POWER : BMA180_LOW_NOISE; + int ret = bma180_set_bits(data, BMA180_TCO_Z, BMA180_MODE_CONFIG, + reg_val); + + if (ret) { + dev_err(&data->client->dev, "failed to set power mode\n"); + return ret; + } + data->pmode = mode; + + return 0; +} + +static int bma180_soft_reset(struct bma180_data *data) +{ + int ret = i2c_smbus_write_byte_data(data->client, + BMA180_RESET, BMA180_RESET_VAL); + + if (ret) + dev_err(&data->client->dev, "failed to reset the chip\n"); + + return ret; +} + +static int bma180_chip_init(struct bma180_data *data) +{ + /* Try to read chip_id register. It must return 0x03. */ + int ret = i2c_smbus_read_byte_data(data->client, BMA180_CHIP_ID); + + if (ret < 0) + goto err; + if (ret != BMA_180_ID_REG_VAL) { + ret = -ENODEV; + goto err; + } + + ret = bma180_soft_reset(data); + if (ret) + goto err; + /* + * No serial transaction should occur within minimum 10 us + * after soft_reset command + */ + msleep(20); + + ret = bma180_set_bits(data, BMA180_CTRL_REG0, BMA180_DIS_WAKE_UP, 1); + if (ret) + goto err; + ret = bma180_set_ee_writing_state(data, 1); + if (ret) + goto err; + ret = bma180_set_new_data_intr_state(data, 0); + if (ret) + goto err; + ret = bma180_set_bits(data, BMA180_OFFSET_LSB1, BMA180_SMP_SKIP, 1); + if (ret) + goto err; + ret = bma180_set_pmode(data, BMA180_DEF_PMODE); + if (ret) + goto err; + ret = bma180_set_bw(data, BMA180_DEF_BW); + if (ret) + goto err; + ret = bma180_set_scale(data, BMA180_DEF_SCALE); + if (ret) + goto err; + + return 0; + +err: + dev_err(&data->client->dev, "failed to init the chip\n"); + return ret; +} + +static void bma180_chip_disable(struct bma180_data *data) +{ + if (bma180_set_new_data_intr_state(data, 0)) + goto err; + if (bma180_set_ee_writing_state(data, 0)) + goto err; + if (bma180_set_sleep_state(data, 1)) + goto err; + + return; + +err: + dev_err(&data->client->dev, "failed to disable the chip\n"); +} + +static IIO_CONST_ATTR(in_accel_filter_low_pass_3db_frequency_available, + BMA180_FLP_FREQ_AVAILABLE); +static IIO_CONST_ATTR(in_accel_scale_available, BMA180_SCALE_AVAILABLE); + +static struct attribute *bma180_attributes[] = { + &iio_const_attr_in_accel_filter_low_pass_3db_frequency_available.dev_attr.attr, + &iio_const_attr_in_accel_scale_available.dev_attr.attr, + NULL, +}; + +static const struct attribute_group bma180_attrs_group = { + .attrs = bma180_attributes, +}; + +static int bma180_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, int *val, int *val2, + long mask) +{ + struct bma180_data *data = iio_priv(indio_dev); + int ret; + + switch (mask) { + case IIO_CHAN_INFO_RAW: + mutex_lock(&data->mutex); + if (iio_buffer_enabled(indio_dev)) + ret = -EBUSY; + else + ret = bma180_get_acc_reg(data, chan->scan_index); + mutex_unlock(&data->mutex); + if (ret < 0) + return ret; + *val = (s16)ret >> chan->scan_type.shift; + return IIO_VAL_INT; + case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY: + *val = data->bw; + return IIO_VAL_INT; + case IIO_CHAN_INFO_SCALE: + *val = 0; + *val2 = data->scale; + return IIO_VAL_INT_PLUS_MICRO; + default: + return -EINVAL; + } +} + +static int bma180_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, int val, int val2, long mask) +{ + struct bma180_data *data = iio_priv(indio_dev); + int ret; + + switch (mask) { + case IIO_CHAN_INFO_SCALE: + if (val) + return -EINVAL; + mutex_lock(&data->mutex); + ret = bma180_set_scale(data, val2); + mutex_unlock(&data->mutex); + return ret; + case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY: + mutex_lock(&data->mutex); + ret = bma180_set_bw(data, val); + mutex_unlock(&data->mutex); + return ret; + default: + return -EINVAL; + } +} + +static int bma180_update_scan_mode(struct iio_dev *indio_dev, + const unsigned long *scan_mask) +{ + struct bma180_data *data = iio_priv(indio_dev); + + if (data->buff) + devm_kfree(&indio_dev->dev, data->buff); + data->buff = devm_kzalloc(&indio_dev->dev, + indio_dev->scan_bytes, GFP_KERNEL); + if (!data->buff) + return -ENOMEM; + + return 0; +} + +static const struct iio_info bma180_info = { + .attrs = &bma180_attrs_group, + .read_raw = bma180_read_raw, + .write_raw = bma180_write_raw, + .update_scan_mode = bma180_update_scan_mode, + .driver_module = THIS_MODULE, +}; + +static const char * const bma180_power_modes[] = { + BMA180_LOW_NOISE_STR, + BMA180_LOW_POWER_STR, +}; + +static int bma180_get_power_mode(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan) +{ + struct bma180_data *data = iio_priv(indio_dev); + + return data->pmode; +} + +static int bma180_set_power_mode(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan, unsigned int mode) +{ + struct bma180_data *data = iio_priv(indio_dev); + int ret; + + mutex_lock(&data->mutex); + ret = bma180_set_pmode(data, mode); + mutex_unlock(&data->mutex); + + return ret; +} + +static const struct iio_enum bma180_power_mode_enum = { + .items = bma180_power_modes, + .num_items = ARRAY_SIZE(bma180_power_modes), + .get = bma180_get_power_mode, + .set = bma180_set_power_mode, +}; + +static const struct iio_chan_spec_ext_info bma180_ext_info[] = { + IIO_ENUM("power_mode", true, &bma180_power_mode_enum), + IIO_ENUM_AVAILABLE("power_mode", &bma180_power_mode_enum), + { }, +}; + +#define BMA180_CHANNEL(_index) { \ + .type = IIO_ACCEL, \ + .indexed = 1, \ + .channel = (_index), \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ + BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY), \ + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ + .scan_index = (_index), \ + .scan_type = IIO_ST('s', 14, 16, 2), \ + .ext_info = bma180_ext_info, \ +} + +static const struct iio_chan_spec bma180_channels[] = { + BMA180_CHANNEL(AXIS_X), + BMA180_CHANNEL(AXIS_Y), + BMA180_CHANNEL(AXIS_Z), + IIO_CHAN_SOFT_TIMESTAMP(4), +}; + +static irqreturn_t bma180_trigger_handler(int irq, void *p) +{ + struct iio_poll_func *pf = p; + struct iio_dev *indio_dev = pf->indio_dev; + struct bma180_data *data = iio_priv(indio_dev); + int bit, ret, i = 0; + + mutex_lock(&data->mutex); + if (indio_dev->scan_timestamp) { + ret = indio_dev->scan_bytes / sizeof(s64) - 1; + ((s64 *)data->buff)[ret] = iio_get_time_ns(); + } + + for_each_set_bit(bit, indio_dev->buffer->scan_mask, + indio_dev->masklength) { + ret = bma180_get_acc_reg(data, bit); + if (ret < 0) { + mutex_unlock(&data->mutex); + goto err; + } + ((s16 *)data->buff)[i++] = ret; + } + mutex_unlock(&data->mutex); + + iio_push_to_buffers(indio_dev, (u8 *)data->buff); +err: + iio_trigger_notify_done(indio_dev->trig); + + return IRQ_HANDLED; +} + +static int bma180_data_rdy_trigger_set_state(struct iio_trigger *trig, + bool state) +{ + struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig); + struct bma180_data *data = iio_priv(indio_dev); + + return bma180_set_new_data_intr_state(data, state); +} + +static int bma180_trig_try_reen(struct iio_trigger *trig) +{ + struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig); + struct bma180_data *data = iio_priv(indio_dev); + + return bma180_reset_intr(data); +} + +static const struct iio_trigger_ops bma180_trigger_ops = { + .set_trigger_state = bma180_data_rdy_trigger_set_state, + .try_reenable = bma180_trig_try_reen, + .owner = THIS_MODULE, +}; + +static int bma180_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct bma180_data *data; + struct iio_dev *indio_dev; + struct iio_trigger *trig; + int ret; + + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); + if (!indio_dev) + return -ENOMEM; + + data = iio_priv(indio_dev); + i2c_set_clientdata(client, indio_dev); + data->client = client; + + ret = bma180_chip_init(data); + if (ret < 0) + goto err_chip_disable; + + mutex_init(&data->mutex); + + indio_dev->dev.parent = &client->dev; + indio_dev->channels = bma180_channels; + indio_dev->num_channels = ARRAY_SIZE(bma180_channels); + indio_dev->name = BMA180_DRV_NAME; + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->info = &bma180_info; + + trig = iio_trigger_alloc("%s-dev%d", indio_dev->name, indio_dev->id); + if (!trig) { + ret = -ENOMEM; + goto err_chip_disable; + } + + ret = devm_request_irq(&client->dev, client->irq, + iio_trigger_generic_data_rdy_poll, + IRQF_TRIGGER_RISING, BMA180_IRQ_NAME, trig); + if (ret) { + dev_err(&client->dev, "unable to request IRQ\n"); + goto err_trigger_free; + } + + trig->dev.parent = &client->dev; + trig->ops = &bma180_trigger_ops; + iio_trigger_set_drvdata(trig, indio_dev); + data->trig = trig; + indio_dev->trig = trig; + + ret = iio_trigger_register(trig); + if (ret) + goto err_trigger_free; + + ret = iio_triggered_buffer_setup(indio_dev, NULL, + bma180_trigger_handler, NULL); + if (ret < 0) { + dev_err(&client->dev, "unable to setup iio triggered buffer\n"); + goto err_trigger_unregister; + } + + ret = iio_device_register(indio_dev); + if (ret < 0) { + dev_err(&client->dev, "unable to register iio device\n"); + goto err_buffer_cleanup; + } + + return 0; + +err_buffer_cleanup: + iio_triggered_buffer_cleanup(indio_dev); +err_trigger_unregister: + iio_trigger_unregister(trig); +err_trigger_free: + iio_trigger_free(trig); +err_chip_disable: + bma180_chip_disable(data); + + return ret; +} + +static int bma180_remove(struct i2c_client *client) +{ + struct iio_dev *indio_dev = i2c_get_clientdata(client); + struct bma180_data *data = iio_priv(indio_dev); + + iio_device_unregister(indio_dev); + iio_triggered_buffer_cleanup(indio_dev); + iio_trigger_unregister(data->trig); + iio_trigger_free(data->trig); + + mutex_lock(&data->mutex); + bma180_chip_disable(data); + mutex_unlock(&data->mutex); + + return 0; +} + +#ifdef CONFIG_PM_SLEEP +static int bma180_suspend(struct device *dev) +{ + struct iio_dev *indio_dev = dev_to_iio_dev(dev); + struct bma180_data *data = iio_priv(indio_dev); + int ret; + + mutex_lock(&data->mutex); + ret = bma180_set_sleep_state(data, 1); + mutex_unlock(&data->mutex); + + return ret; +} + +static int bma180_resume(struct device *dev) +{ + struct iio_dev *indio_dev = dev_to_iio_dev(dev); + struct bma180_data *data = iio_priv(indio_dev); + int ret; + + mutex_lock(&data->mutex); + ret = bma180_set_sleep_state(data, 0); + mutex_unlock(&data->mutex); + + return ret; +} + +static SIMPLE_DEV_PM_OPS(bma180_pm_ops, bma180_suspend, bma180_resume); +#define BMA180_PM_OPS (&bma180_pm_ops) +#else +#define BMA180_PM_OPS NULL +#endif + +static struct i2c_device_id bma180_id[] = { + { BMA180_DRV_NAME, 0 }, + { } +}; + +MODULE_DEVICE_TABLE(i2c, bma180_id); + +static struct i2c_driver bma180_driver = { + .driver = { + .name = BMA180_DRV_NAME, + .owner = THIS_MODULE, + .pm = BMA180_PM_OPS, + }, + .probe = bma180_probe, + .remove = bma180_remove, + .id_table = bma180_id, +}; + +module_i2c_driver(bma180_driver); + +MODULE_AUTHOR("Kravchenko Oleksandr "); +MODULE_AUTHOR("Texas Instruments, Inc."); +MODULE_DESCRIPTION("Bosch BMA180 triaxial acceleration sensor"); +MODULE_LICENSE("GPL"); -- GitLab From f7448349609b8defa856f0920f56f3e3c8bf0dd5 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Sat, 24 Aug 2013 19:48:00 +0100 Subject: [PATCH 892/942] staging: iio: adis16201: Use devm_iio_device_alloc Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat Signed-off-by: Jonathan Cameron --- drivers/staging/iio/accel/adis16201_core.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/staging/iio/accel/adis16201_core.c b/drivers/staging/iio/accel/adis16201_core.c index ab8ec7af88b49..2105576fa77c4 100644 --- a/drivers/staging/iio/accel/adis16201_core.c +++ b/drivers/staging/iio/accel/adis16201_core.c @@ -182,11 +182,10 @@ static int adis16201_probe(struct spi_device *spi) struct iio_dev *indio_dev; /* setup the industrialio driver allocated elements */ - indio_dev = iio_device_alloc(sizeof(*st)); - if (indio_dev == NULL) { - ret = -ENOMEM; - goto error_ret; - } + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); + if (!indio_dev) + return -ENOMEM; + st = iio_priv(indio_dev); /* this is only used for removal purposes */ spi_set_drvdata(spi, indio_dev); @@ -201,10 +200,10 @@ static int adis16201_probe(struct spi_device *spi) ret = adis_init(st, indio_dev, spi, &adis16201_data); if (ret) - goto error_free_dev; + return ret; ret = adis_setup_buffer_and_trigger(st, indio_dev, NULL); if (ret) - goto error_free_dev; + return ret; /* Get the device into a sane initial state */ ret = adis_initial_startup(st); @@ -218,9 +217,6 @@ static int adis16201_probe(struct spi_device *spi) error_cleanup_buffer_trigger: adis_cleanup_buffer_and_trigger(st, indio_dev); -error_free_dev: - iio_device_free(indio_dev); -error_ret: return ret; } @@ -231,7 +227,6 @@ static int adis16201_remove(struct spi_device *spi) iio_device_unregister(indio_dev); adis_cleanup_buffer_and_trigger(st, indio_dev); - iio_device_free(indio_dev); return 0; } -- GitLab From 69fad8aa4dc81e04427faf2a9a43a615fb618cb2 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Sat, 24 Aug 2013 19:48:00 +0100 Subject: [PATCH 893/942] staging: iio: adis16203: Use devm_iio_device_alloc Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat Signed-off-by: Jonathan Cameron --- drivers/staging/iio/accel/adis16203_core.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/staging/iio/accel/adis16203_core.c b/drivers/staging/iio/accel/adis16203_core.c index b08ac8fdeee27..409a28ed90431 100644 --- a/drivers/staging/iio/accel/adis16203_core.c +++ b/drivers/staging/iio/accel/adis16203_core.c @@ -148,11 +148,9 @@ static int adis16203_probe(struct spi_device *spi) struct adis *st; /* setup the industrialio driver allocated elements */ - indio_dev = iio_device_alloc(sizeof(*st)); - if (indio_dev == NULL) { - ret = -ENOMEM; - goto error_ret; - } + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); + if (!indio_dev) + return -ENOMEM; st = iio_priv(indio_dev); /* this is only used for removal purposes */ spi_set_drvdata(spi, indio_dev); @@ -166,11 +164,11 @@ static int adis16203_probe(struct spi_device *spi) ret = adis_init(st, indio_dev, spi, &adis16203_data); if (ret) - goto error_free_dev; + return ret; ret = adis_setup_buffer_and_trigger(st, indio_dev, NULL); if (ret) - goto error_free_dev; + return ret; /* Get the device into a sane initial state */ ret = adis_initial_startup(st); @@ -185,9 +183,6 @@ static int adis16203_probe(struct spi_device *spi) error_cleanup_buffer_trigger: adis_cleanup_buffer_and_trigger(st, indio_dev); -error_free_dev: - iio_device_free(indio_dev); -error_ret: return ret; } @@ -198,7 +193,6 @@ static int adis16203_remove(struct spi_device *spi) iio_device_unregister(indio_dev); adis_cleanup_buffer_and_trigger(st, indio_dev); - iio_device_free(indio_dev); return 0; } -- GitLab From cdfb09a40dc9cd71e86f458353ddd3cdeecd5ace Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Sat, 24 Aug 2013 19:48:00 +0100 Subject: [PATCH 894/942] staging: iio: adis16204: Use devm_iio_device_alloc Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat Signed-off-by: Jonathan Cameron --- drivers/staging/iio/accel/adis16204_core.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/staging/iio/accel/adis16204_core.c b/drivers/staging/iio/accel/adis16204_core.c index 792ec25a50dca..b8ea76857cd64 100644 --- a/drivers/staging/iio/accel/adis16204_core.c +++ b/drivers/staging/iio/accel/adis16204_core.c @@ -187,11 +187,9 @@ static int adis16204_probe(struct spi_device *spi) struct iio_dev *indio_dev; /* setup the industrialio driver allocated elements */ - indio_dev = iio_device_alloc(sizeof(*st)); - if (indio_dev == NULL) { - ret = -ENOMEM; - goto error_ret; - } + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); + if (!indio_dev) + return -ENOMEM; st = iio_priv(indio_dev); /* this is only used for removal purposes */ spi_set_drvdata(spi, indio_dev); @@ -205,11 +203,11 @@ static int adis16204_probe(struct spi_device *spi) ret = adis_init(st, indio_dev, spi, &adis16204_data); if (ret) - goto error_free_dev; + return ret; ret = adis_setup_buffer_and_trigger(st, indio_dev, NULL); if (ret) - goto error_free_dev; + return ret; /* Get the device into a sane initial state */ ret = adis_initial_startup(st); @@ -223,9 +221,6 @@ static int adis16204_probe(struct spi_device *spi) error_cleanup_buffer_trigger: adis_cleanup_buffer_and_trigger(st, indio_dev); -error_free_dev: - iio_device_free(indio_dev); -error_ret: return ret; } @@ -236,7 +231,6 @@ static int adis16204_remove(struct spi_device *spi) iio_device_unregister(indio_dev); adis_cleanup_buffer_and_trigger(st, indio_dev); - iio_device_free(indio_dev); return 0; } -- GitLab From 864bf5cd86b3a91a6608929e5661947060ca160d Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Sat, 24 Aug 2013 19:48:00 +0100 Subject: [PATCH 895/942] staging: iio: adis16209: Use devm_iio_device_alloc Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat Signed-off-by: Jonathan Cameron --- drivers/staging/iio/accel/adis16209_core.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/staging/iio/accel/adis16209_core.c b/drivers/staging/iio/accel/adis16209_core.c index 323c169d699ca..4492e51d88865 100644 --- a/drivers/staging/iio/accel/adis16209_core.c +++ b/drivers/staging/iio/accel/adis16209_core.c @@ -183,11 +183,9 @@ static int adis16209_probe(struct spi_device *spi) struct iio_dev *indio_dev; /* setup the industrialio driver allocated elements */ - indio_dev = iio_device_alloc(sizeof(*st)); - if (indio_dev == NULL) { - ret = -ENOMEM; - goto error_ret; - } + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); + if (!indio_dev) + return -ENOMEM; st = iio_priv(indio_dev); /* this is only used for removal purposes */ spi_set_drvdata(spi, indio_dev); @@ -201,10 +199,10 @@ static int adis16209_probe(struct spi_device *spi) ret = adis_init(st, indio_dev, spi, &adis16209_data); if (ret) - goto error_free_dev; + return ret; ret = adis_setup_buffer_and_trigger(st, indio_dev, NULL); if (ret) - goto error_free_dev; + return ret; /* Get the device into a sane initial state */ ret = adis_initial_startup(st); @@ -218,9 +216,6 @@ static int adis16209_probe(struct spi_device *spi) error_cleanup_buffer_trigger: adis_cleanup_buffer_and_trigger(st, indio_dev); -error_free_dev: - iio_device_free(indio_dev); -error_ret: return ret; } @@ -231,7 +226,6 @@ static int adis16209_remove(struct spi_device *spi) iio_device_unregister(indio_dev); adis_cleanup_buffer_and_trigger(st, indio_dev); - iio_device_free(indio_dev); return 0; } -- GitLab From 1868171c5caef74996c3604146e60b976e249344 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Sat, 24 Aug 2013 19:48:00 +0100 Subject: [PATCH 896/942] staging: iio: adis16220: Use devm_iio_device_alloc Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat Signed-off-by: Jonathan Cameron --- drivers/staging/iio/accel/adis16220_core.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/staging/iio/accel/adis16220_core.c b/drivers/staging/iio/accel/adis16220_core.c index 0e72f795ed091..5c289614357c5 100644 --- a/drivers/staging/iio/accel/adis16220_core.c +++ b/drivers/staging/iio/accel/adis16220_core.c @@ -428,11 +428,9 @@ static int adis16220_probe(struct spi_device *spi) struct iio_dev *indio_dev; /* setup the industrialio driver allocated elements */ - indio_dev = iio_device_alloc(sizeof(*st)); - if (indio_dev == NULL) { - ret = -ENOMEM; - goto error_ret; - } + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); + if (!indio_dev) + return -ENOMEM; st = iio_priv(indio_dev); /* this is only used for removal purposes */ @@ -447,7 +445,7 @@ static int adis16220_probe(struct spi_device *spi) ret = iio_device_register(indio_dev); if (ret) - goto error_free_dev; + return ret; ret = sysfs_create_bin_file(&indio_dev->dev.kobj, &accel_bin); if (ret) @@ -478,9 +476,6 @@ static int adis16220_probe(struct spi_device *spi) sysfs_remove_bin_file(&indio_dev->dev.kobj, &accel_bin); error_unregister_dev: iio_device_unregister(indio_dev); -error_free_dev: - iio_device_free(indio_dev); -error_ret: return ret; } @@ -492,7 +487,6 @@ static int adis16220_remove(struct spi_device *spi) sysfs_remove_bin_file(&indio_dev->dev.kobj, &adc1_bin); sysfs_remove_bin_file(&indio_dev->dev.kobj, &accel_bin); iio_device_unregister(indio_dev); - iio_device_free(indio_dev); return 0; } -- GitLab From e8cac7f61452d45cd4bca8cb11c139edc9633f38 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Sat, 24 Aug 2013 19:48:00 +0100 Subject: [PATCH 897/942] staging: iio: adis16240: Use devm_iio_device_alloc Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat Signed-off-by: Jonathan Cameron --- drivers/staging/iio/accel/adis16240_core.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/staging/iio/accel/adis16240_core.c b/drivers/staging/iio/accel/adis16240_core.c index fd1f0fd0fba8c..3a303a03d028c 100644 --- a/drivers/staging/iio/accel/adis16240_core.c +++ b/drivers/staging/iio/accel/adis16240_core.c @@ -236,11 +236,9 @@ static int adis16240_probe(struct spi_device *spi) struct iio_dev *indio_dev; /* setup the industrialio driver allocated elements */ - indio_dev = iio_device_alloc(sizeof(*st)); - if (indio_dev == NULL) { - ret = -ENOMEM; - goto error_ret; - } + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); + if (!indio_dev) + return -ENOMEM; st = iio_priv(indio_dev); /* this is only used for removal purposes */ spi_set_drvdata(spi, indio_dev); @@ -254,10 +252,10 @@ static int adis16240_probe(struct spi_device *spi) ret = adis_init(st, indio_dev, spi, &adis16240_data); if (ret) - goto error_free_dev; + return ret; ret = adis_setup_buffer_and_trigger(st, indio_dev, NULL); if (ret) - goto error_free_dev; + return ret; /* Get the device into a sane initial state */ ret = adis_initial_startup(st); @@ -270,9 +268,6 @@ static int adis16240_probe(struct spi_device *spi) error_cleanup_buffer_trigger: adis_cleanup_buffer_and_trigger(st, indio_dev); -error_free_dev: - iio_device_free(indio_dev); -error_ret: return ret; } @@ -283,7 +278,6 @@ static int adis16240_remove(struct spi_device *spi) iio_device_unregister(indio_dev); adis_cleanup_buffer_and_trigger(st, indio_dev); - iio_device_free(indio_dev); return 0; } -- GitLab From 4c247470531d437acf3b78b8d2bd08222395ecc9 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Sat, 24 Aug 2013 19:48:00 +0100 Subject: [PATCH 898/942] staging: iio: lis3l02dq: Use devm_iio_device_alloc Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat Signed-off-by: Jonathan Cameron --- drivers/staging/iio/accel/lis3l02dq_core.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/staging/iio/accel/lis3l02dq_core.c b/drivers/staging/iio/accel/lis3l02dq_core.c index 8ed75a94f4658..bb852dc9c9870 100644 --- a/drivers/staging/iio/accel/lis3l02dq_core.c +++ b/drivers/staging/iio/accel/lis3l02dq_core.c @@ -668,11 +668,9 @@ static int lis3l02dq_probe(struct spi_device *spi) struct lis3l02dq_state *st; struct iio_dev *indio_dev; - indio_dev = iio_device_alloc(sizeof *st); - if (indio_dev == NULL) { - ret = -ENOMEM; - goto error_ret; - } + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); + if (!indio_dev) + return -ENOMEM; st = iio_priv(indio_dev); /* this is only used for removal purposes */ spi_set_drvdata(spi, indio_dev); @@ -690,7 +688,7 @@ static int lis3l02dq_probe(struct spi_device *spi) ret = lis3l02dq_configure_buffer(indio_dev); if (ret) - goto error_free_dev; + return ret; ret = iio_buffer_register(indio_dev, lis3l02dq_channels, @@ -736,9 +734,6 @@ static int lis3l02dq_probe(struct spi_device *spi) iio_buffer_unregister(indio_dev); error_unreg_buffer_funcs: lis3l02dq_unconfigure_buffer(indio_dev); -error_free_dev: - iio_device_free(indio_dev); -error_ret: return ret; } @@ -786,8 +781,6 @@ static int lis3l02dq_remove(struct spi_device *spi) iio_buffer_unregister(indio_dev); lis3l02dq_unconfigure_buffer(indio_dev); - iio_device_free(indio_dev); - return 0; } -- GitLab From 0189d93fdf82cd546d5e54c6f4f7c4622c90aa3c Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Sat, 24 Aug 2013 19:48:00 +0100 Subject: [PATCH 899/942] staging: iio: sca3000: Use devm_iio_device_alloc Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat Signed-off-by: Jonathan Cameron --- drivers/staging/iio/accel/sca3000_core.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c index 32950ad948577..48a25ba290f5a 100644 --- a/drivers/staging/iio/accel/sca3000_core.c +++ b/drivers/staging/iio/accel/sca3000_core.c @@ -1135,11 +1135,9 @@ static int sca3000_probe(struct spi_device *spi) struct sca3000_state *st; struct iio_dev *indio_dev; - indio_dev = iio_device_alloc(sizeof(*st)); - if (indio_dev == NULL) { - ret = -ENOMEM; - goto error_ret; - } + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); + if (!indio_dev) + return -ENOMEM; st = iio_priv(indio_dev); spi_set_drvdata(spi, indio_dev); @@ -1162,7 +1160,7 @@ static int sca3000_probe(struct spi_device *spi) sca3000_configure_ring(indio_dev); ret = iio_device_register(indio_dev); if (ret < 0) - goto error_free_dev; + return ret; ret = iio_buffer_register(indio_dev, sca3000_channels, @@ -1198,10 +1196,6 @@ static int sca3000_probe(struct spi_device *spi) iio_buffer_unregister(indio_dev); error_unregister_dev: iio_device_unregister(indio_dev); -error_free_dev: - iio_device_free(indio_dev); - -error_ret: return ret; } @@ -1235,7 +1229,6 @@ static int sca3000_remove(struct spi_device *spi) iio_device_unregister(indio_dev); iio_buffer_unregister(indio_dev); sca3000_unconfigure_ring(indio_dev); - iio_device_free(indio_dev); return 0; } -- GitLab From d15b73c5bf67f273ded2f4405aea4ba79c3542ae Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Sat, 24 Aug 2013 20:24:00 +0100 Subject: [PATCH 900/942] staging: iio: ad7150: Use devm_* APIs devm_* APIs are device managed and make code simpler. Signed-off-by: Sachin Kamat Signed-off-by: Jonathan Cameron --- drivers/staging/iio/cdc/ad7150.c | 36 +++++++------------------------- 1 file changed, 8 insertions(+), 28 deletions(-) diff --git a/drivers/staging/iio/cdc/ad7150.c b/drivers/staging/iio/cdc/ad7150.c index 687dd2c914378..f4a0341cc70c1 100644 --- a/drivers/staging/iio/cdc/ad7150.c +++ b/drivers/staging/iio/cdc/ad7150.c @@ -558,11 +558,9 @@ static int ad7150_probe(struct i2c_client *client, struct ad7150_chip_info *chip; struct iio_dev *indio_dev; - indio_dev = iio_device_alloc(sizeof(*chip)); - if (indio_dev == NULL) { - ret = -ENOMEM; - goto error_ret; - } + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip)); + if (!indio_dev) + return -ENOMEM; chip = iio_priv(indio_dev); mutex_init(&chip->state_lock); /* this is only used for device removal purposes */ @@ -581,7 +579,7 @@ static int ad7150_probe(struct i2c_client *client, indio_dev->modes = INDIO_DIRECT_MODE; if (client->irq) { - ret = request_threaded_irq(client->irq, + ret = devm_request_threaded_irq(&client->dev, client->irq, NULL, &ad7150_event_handler, IRQF_TRIGGER_RISING | @@ -590,11 +588,11 @@ static int ad7150_probe(struct i2c_client *client, "ad7150_irq1", indio_dev); if (ret) - goto error_free_dev; + return ret; } if (client->dev.platform_data) { - ret = request_threaded_irq(*(unsigned int *) + ret = devm_request_threaded_irq(&client->dev, *(unsigned int *) client->dev.platform_data, NULL, &ad7150_event_handler, @@ -604,28 +602,17 @@ static int ad7150_probe(struct i2c_client *client, "ad7150_irq2", indio_dev); if (ret) - goto error_free_irq; + return ret; } ret = iio_device_register(indio_dev); if (ret) - goto error_free_irq2; + return ret; dev_info(&client->dev, "%s capacitive sensor registered,irq: %d\n", id->name, client->irq); return 0; -error_free_irq2: - if (client->dev.platform_data) - free_irq(*(unsigned int *)client->dev.platform_data, - indio_dev); -error_free_irq: - if (client->irq) - free_irq(client->irq, indio_dev); -error_free_dev: - iio_device_free(indio_dev); -error_ret: - return ret; } static int ad7150_remove(struct i2c_client *client) @@ -633,13 +620,6 @@ static int ad7150_remove(struct i2c_client *client) struct iio_dev *indio_dev = i2c_get_clientdata(client); iio_device_unregister(indio_dev); - if (client->irq) - free_irq(client->irq, indio_dev); - - if (client->dev.platform_data) - free_irq(*(unsigned int *)client->dev.platform_data, indio_dev); - - iio_device_free(indio_dev); return 0; } -- GitLab From 538ee7cbffc1663d76f257438c35c889b0664fcc Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Sat, 24 Aug 2013 20:24:00 +0100 Subject: [PATCH 901/942] staging: iio: ad7152: Use devm_iio_device_alloc Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat Signed-off-by: Jonathan Cameron --- drivers/staging/iio/cdc/ad7152.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/staging/iio/cdc/ad7152.c b/drivers/staging/iio/cdc/ad7152.c index 1d7c5283a85c4..f2c309d1eb594 100644 --- a/drivers/staging/iio/cdc/ad7152.c +++ b/drivers/staging/iio/cdc/ad7152.c @@ -481,11 +481,9 @@ static int ad7152_probe(struct i2c_client *client, struct ad7152_chip_info *chip; struct iio_dev *indio_dev; - indio_dev = iio_device_alloc(sizeof(*chip)); - if (indio_dev == NULL) { - ret = -ENOMEM; - goto error_ret; - } + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip)); + if (!indio_dev) + return -ENOMEM; chip = iio_priv(indio_dev); /* this is only used for device removal purposes */ i2c_set_clientdata(client, indio_dev); @@ -506,16 +504,11 @@ static int ad7152_probe(struct i2c_client *client, ret = iio_device_register(indio_dev); if (ret) - goto error_free_dev; + return ret; dev_err(&client->dev, "%s capacitive sensor registered\n", id->name); return 0; - -error_free_dev: - iio_device_free(indio_dev); -error_ret: - return ret; } static int ad7152_remove(struct i2c_client *client) @@ -523,7 +516,6 @@ static int ad7152_remove(struct i2c_client *client) struct iio_dev *indio_dev = i2c_get_clientdata(client); iio_device_unregister(indio_dev); - iio_device_free(indio_dev); return 0; } -- GitLab From 0eab65c64a2fbc6356f330b41f7bdadd1a094bbd Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Sat, 24 Aug 2013 20:24:00 +0100 Subject: [PATCH 902/942] staging: iio: ad7746: Use devm_iio_device_alloc Using devm_iio_device_alloc makes code simpler. Signed-off-by: Sachin Kamat Signed-off-by: Jonathan Cameron --- drivers/staging/iio/cdc/ad7746.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/drivers/staging/iio/cdc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c index 94f9ca726d1c1..75a533bce0217 100644 --- a/drivers/staging/iio/cdc/ad7746.c +++ b/drivers/staging/iio/cdc/ad7746.c @@ -699,11 +699,9 @@ static int ad7746_probe(struct i2c_client *client, int ret = 0; unsigned char regval = 0; - indio_dev = iio_device_alloc(sizeof(*chip)); - if (indio_dev == NULL) { - ret = -ENOMEM; - goto error_ret; - } + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip)); + if (!indio_dev) + return -ENOMEM; chip = iio_priv(indio_dev); /* this is only used for device removal purposes */ i2c_set_clientdata(client, indio_dev); @@ -748,20 +746,15 @@ static int ad7746_probe(struct i2c_client *client, ret = i2c_smbus_write_byte_data(chip->client, AD7746_REG_EXC_SETUP, regval); if (ret < 0) - goto error_free_dev; + return ret; ret = iio_device_register(indio_dev); if (ret) - goto error_free_dev; + return ret; dev_info(&client->dev, "%s capacitive sensor registered\n", id->name); return 0; - -error_free_dev: - iio_device_free(indio_dev); -error_ret: - return ret; } static int ad7746_remove(struct i2c_client *client) @@ -769,7 +762,6 @@ static int ad7746_remove(struct i2c_client *client) struct iio_dev *indio_dev = i2c_get_clientdata(client); iio_device_unregister(indio_dev); - iio_device_free(indio_dev); return 0; } -- GitLab From 2d2da9fc7113ee5df06519e435f2f9430acf40c5 Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Fri, 23 Aug 2013 03:47:00 +0100 Subject: [PATCH 903/942] iio: adc: twl6030-gpadc: fix error return code in twl6030_gpadc_read_raw() Fix to return -EINTR in the error handling case instead of 0 (ret is assigned after goto, which has no effect), as done elsewhere in this function. Signed-off-by: Wei Yongjun Reported-by: Dan Carpenter Signed-off-by: Jonathan Cameron --- drivers/iio/adc/twl6030-gpadc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/adc/twl6030-gpadc.c b/drivers/iio/adc/twl6030-gpadc.c index a558516d140d2..0ea96c058c088 100644 --- a/drivers/iio/adc/twl6030-gpadc.c +++ b/drivers/iio/adc/twl6030-gpadc.c @@ -537,8 +537,8 @@ static int twl6030_gpadc_read_raw(struct iio_dev *indio_dev, ret = -ETIMEDOUT; goto err; } else if (timeout < 0) { - goto err; ret = -EINTR; + goto err; } switch (mask) { -- GitLab From e06534fd37b170d463421124157fd56840a15a31 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 28 Aug 2013 10:35:47 +0530 Subject: [PATCH 904/942] staging: dgap: Remove version.h header inclusion in dgap_parse.c version.h header inclusion is not necessary as detected by versioncheck. Cc: Lidza Louina Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap_parse.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/dgap/dgap_parse.c b/drivers/staging/dgap/dgap_parse.c index d6d507bb05a4e..5497e6de06088 100644 --- a/drivers/staging/dgap/dgap_parse.c +++ b/drivers/staging/dgap/dgap_parse.c @@ -36,7 +36,6 @@ * */ #include -#include #include #include -- GitLab From 27029899599d41cc8240545d2c69a8e5f2a7fef6 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 28 Aug 2013 10:35:48 +0530 Subject: [PATCH 905/942] staging: dgap: Remove version.h header inclusion in dgap_sysfs.c version.h header inclusion is not necessary as detected by versioncheck. Cc: Lidza Louina Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap_sysfs.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/dgap/dgap_sysfs.c b/drivers/staging/dgap/dgap_sysfs.c index d4300ce7b6bdb..94da06fcf7e9b 100644 --- a/drivers/staging/dgap/dgap_sysfs.c +++ b/drivers/staging/dgap/dgap_sysfs.c @@ -34,7 +34,6 @@ #include -#include #include #include #include -- GitLab From 9bfcc70355a61100352a720ed56200d01048c030 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 28 Aug 2013 10:35:49 +0530 Subject: [PATCH 906/942] staging: dgap: Remove version.h header inclusion in dgap_trace.c version.h header inclusion is not necessary as detected by versioncheck. Cc: Lidza Louina Signed-off-by: Sachin Kamat Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap_trace.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/dgap/dgap_trace.c b/drivers/staging/dgap/dgap_trace.c index 17610025b8f45..0f9a9569ea277 100644 --- a/drivers/staging/dgap/dgap_trace.c +++ b/drivers/staging/dgap/dgap_trace.c @@ -32,7 +32,6 @@ /* $Id: dgap_trace.c,v 1.1 2009/10/23 14:01:57 markh Exp $ */ #include -#include #include /* For jiffies, task states */ #include /* For tasklet and interrupt structs/defines */ #include -- GitLab From ccaf5bd061ae41b4f573e552c437ffc10b87185a Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 28 Aug 2013 11:05:19 +0530 Subject: [PATCH 907/942] staging: rtl8188eu: Remove version.h inclusion in osdep_service.h version.h header inclusion is not necessary as detected by versioncheck. Signed-off-by: Sachin Kamat Acked-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/osdep_service.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/include/osdep_service.h b/drivers/staging/rtl8188eu/include/osdep_service.h index 1be33b74f8354..44f24fa31a341 100644 --- a/drivers/staging/rtl8188eu/include/osdep_service.h +++ b/drivers/staging/rtl8188eu/include/osdep_service.h @@ -26,7 +26,6 @@ #define _SUCCESS 1 #define RTW_RX_HANDLED 2 -#include #include #include #include -- GitLab From d605eb150dcac45ddc0c9e2d8a2fb5ccd0afae9b Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 28 Aug 2013 11:05:21 +0530 Subject: [PATCH 908/942] staging: rtl8188eu: Include version.h header in xmit_linux.c Include version.h header file as detected by versioncheck. Signed-off-by: Sachin Kamat Acked-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/xmit_linux.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c index 1e2c8abd7dd2a..2e586c063ab89 100644 --- a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c @@ -19,6 +19,7 @@ ******************************************************************************/ #define _XMIT_OSDEP_C_ +#include #include #include -- GitLab From 55350178ce5368a5b4369dd146af9491a087d863 Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 28 Aug 2013 11:05:20 +0530 Subject: [PATCH 909/942] staging: rtl8188eu: Include version.h in usb_ops.h Include version.h header file as detected by versioncheck. Signed-off-by: Sachin Kamat Acked-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/usb_ops.h | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/rtl8188eu/include/usb_ops.h b/drivers/staging/rtl8188eu/include/usb_ops.h index c23de7bd36e3b..df34237655372 100644 --- a/drivers/staging/rtl8188eu/include/usb_ops.h +++ b/drivers/staging/rtl8188eu/include/usb_ops.h @@ -20,6 +20,7 @@ #ifndef __USB_OPS_H_ #define __USB_OPS_H_ +#include #include #include #include -- GitLab From 12b54e0f60f0a5b8e82810be309221c6bb4438ba Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 28 Aug 2013 11:25:01 +0530 Subject: [PATCH 910/942] staging: rtl8188eu: Remove duplicate incusion in drv_types.h wlan_bssdef.h was included twice. Signed-off-by: Sachin Kamat Acked-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/drv_types.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/include/drv_types.h b/drivers/staging/rtl8188eu/include/drv_types.h index 6e49359a182d9..ad073c8af2752 100644 --- a/drivers/staging/rtl8188eu/include/drv_types.h +++ b/drivers/staging/rtl8188eu/include/drv_types.h @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include -- GitLab From 6554f313d105097aca9ce3d0b6df96d426226e2c Mon Sep 17 00:00:00 2001 From: Sachin Kamat Date: Wed, 28 Aug 2013 11:25:02 +0530 Subject: [PATCH 911/942] staging: rtl8188eu: Remove duplicate header inclusion in ioctl_linux.c Removed the header files included twice. Signed-off-by: Sachin Kamat Acked-by: Larry Finger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c index d438256a205f9..cd4100fb3645f 100644 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -29,13 +29,11 @@ #include #include #include -#include #include #include #include #include -#include #include #define RTL_IOCTL_WPA_SUPPLICANT (SIOCIWFIRSTPRIV + 30) -- GitLab From be5e5926522f9f03ebec4124f0034d3928872c8c Mon Sep 17 00:00:00 2001 From: Rupesh Gujare Date: Wed, 28 Aug 2013 12:43:14 +0100 Subject: [PATCH 912/942] staging: ozwpan: Increase ISOC IN buffer depth Buffer depth of 50 units is not sufficient when there is considerable delay occuring on air due to interference, increase ISOC IN buffer depth to 100 units. Signed-off-by: Rupesh Gujare Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozhcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/ozwpan/ozhcd.c b/drivers/staging/ozwpan/ozhcd.c index d6c3d0ebba7b2..d9c43c3282e7b 100644 --- a/drivers/staging/ozwpan/ozhcd.c +++ b/drivers/staging/ozwpan/ozhcd.c @@ -39,7 +39,7 @@ * Number of units of buffering to capture for an isochronous IN endpoint before * allowing data to be indicated up. */ -#define OZ_IN_BUFFERING_UNITS 50 +#define OZ_IN_BUFFERING_UNITS 100 /* Name of our platform device. */ -- GitLab From b93d85f007177076c07acd8bf249dc466a977260 Mon Sep 17 00:00:00 2001 From: Rupesh Gujare Date: Wed, 28 Aug 2013 12:43:15 +0100 Subject: [PATCH 913/942] staging: ozwpan: Change error number. Incorrect error number was returned here (EPERM), ENXIO is more appropriate. Signed-off-by: Rupesh Gujare Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozcdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/ozwpan/ozcdev.c b/drivers/staging/ozwpan/ozcdev.c index 03b41eecc62c2..50722eab7e1fb 100644 --- a/drivers/staging/ozwpan/ozcdev.c +++ b/drivers/staging/ozwpan/ozcdev.c @@ -161,7 +161,7 @@ static ssize_t oz_cdev_write(struct file *filp, const char __user *buf, oz_pd_get(pd); spin_unlock_bh(&g_cdev.lock); if (pd == NULL) - return -1; + return -ENXIO; eb = &pd->elt_buff; ei = oz_elt_info_alloc(eb); if (ei == NULL) { -- GitLab From 8503f9016f01d01b4c3a1e8c9848d4f564e71bd1 Mon Sep 17 00:00:00 2001 From: Rupesh Gujare Date: Wed, 28 Aug 2013 12:43:16 +0100 Subject: [PATCH 914/942] staging: ozwpan: Return error, if PD is not connected. Return error if we receive write(), while PD is not connected. Signed-off-by: Rupesh Gujare Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ozwpan/ozcdev.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/ozwpan/ozcdev.c b/drivers/staging/ozwpan/ozcdev.c index 50722eab7e1fb..6ccb64fb07865 100644 --- a/drivers/staging/ozwpan/ozcdev.c +++ b/drivers/staging/ozwpan/ozcdev.c @@ -162,6 +162,8 @@ static ssize_t oz_cdev_write(struct file *filp, const char __user *buf, spin_unlock_bh(&g_cdev.lock); if (pd == NULL) return -ENXIO; + if (!(pd->state & OZ_PD_S_CONNECTED)) + return -EAGAIN; eb = &pd->elt_buff; ei = oz_elt_info_alloc(eb); if (ei == NULL) { -- GitLab From 688141d674b4b44b43b46adfa52bff5cf48834bf Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 28 Aug 2013 20:52:23 +0100 Subject: [PATCH 915/942] staging: vt6656: baseband.h re: baseband.c:877:26: sparse: incorrect type in assignment (different base types) sparse warnings: (new ones prefixed by >>) ... >> drivers/staging/vt6656/baseband.c:877:26: sparse: incorrect type in assignment (different base types) drivers/staging/vt6656/baseband.c:877:26: expected unsigned short [unsigned] [usertype] len drivers/staging/vt6656/baseband.c:877:26: got restricted __le16 [usertype] >> drivers/staging/vt6656/baseband.c:880:26: sparse: incorrect type in assignment (different base types) drivers/staging/vt6656/baseband.c:880:26: expected unsigned short [unsigned] [usertype] len drivers/staging/vt6656/baseband.c:880:26: got restricted __le16 [usertype] vnt_phy_field member len should be __le16. Reported-by: kbuild test robot Cc: kbuild-all@01.org Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/baseband.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/vt6656/baseband.h b/drivers/staging/vt6656/baseband.h index a8db17dc366e8..79faedf4a5e9f 100644 --- a/drivers/staging/vt6656/baseband.h +++ b/drivers/staging/vt6656/baseband.h @@ -85,7 +85,7 @@ struct vnt_phy_field { u8 signal; u8 service; - u16 len; + __le16 len; } __packed; unsigned int -- GitLab From 8114c93e48e642e12a49c96e31a674d6a7946bf1 Mon Sep 17 00:00:00 2001 From: Robert Foss Date: Wed, 28 Aug 2013 20:51:47 +0200 Subject: [PATCH 916/942] Staging: crystalhd: fixed whitespace and string style issues Fixed 3 instances of user-visible string being broken into two string. Fixed 2 instances of illegal whitespace. Signed-off-by: Greg Kroah-Hartman --- drivers/staging/crystalhd/crystalhd_cmds.c | 3 +-- drivers/staging/crystalhd/crystalhd_hw.c | 7 +++---- drivers/staging/crystalhd/crystalhd_lnx.c | 3 +-- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/staging/crystalhd/crystalhd_cmds.c b/drivers/staging/crystalhd/crystalhd_cmds.c index 3ab502b8c3be7..07a2f24d0d47d 100644 --- a/drivers/staging/crystalhd/crystalhd_cmds.c +++ b/drivers/staging/crystalhd/crystalhd_cmds.c @@ -94,8 +94,7 @@ static enum BC_STATUS bc_cproc_notify_mode(struct crystalhd_cmd *ctx, for (i = 0; i < BC_LINK_MAX_OPENS; i++) { if (ctx->user[i].mode == DTS_DIAG_MODE || ctx->user[i].mode == DTS_PLAYBACK_MODE) { - BCMLOG_ERR("multiple playback sessions are not " - "supported..\n"); + BCMLOG_ERR("multiple playback sessions are not supported..\n"); return BC_STS_ERR_USAGE; } } diff --git a/drivers/staging/crystalhd/crystalhd_hw.c b/drivers/staging/crystalhd/crystalhd_hw.c index 0c8cb329420f2..5845e899ee806 100644 --- a/drivers/staging/crystalhd/crystalhd_hw.c +++ b/drivers/staging/crystalhd/crystalhd_hw.c @@ -1061,7 +1061,7 @@ static void cpy_pib_to_app(struct c011_pib *src_pib, dst_pib->aspect_ratio = src_pib->ppb.aspect_ratio; dst_pib->colour_primaries = src_pib->ppb.colour_primaries; dst_pib->picture_meta_payload = src_pib->ppb.picture_meta_payload; - dst_pib->frame_rate = src_pib->resolution ; + dst_pib->frame_rate = src_pib->resolution; return; } @@ -1553,11 +1553,10 @@ static void crystalhd_rx_isr(struct crystalhd_hw *hw, uint32_t intr_sts) crystalhd_get_dnsz(hw, i, &y_dn_sz, &uv_dn_sz); /* FIXME: jarod: this is where my mini pci-e card is tripping up */ - BCMLOG(BCMLOG_DBG, "list_index:%x rx[%d] Y:%x " - "UV:%x Int:%x YDnSz:%x UVDnSz:%x\n", + BCMLOG(BCMLOG_DBG, "list_index:%x rx[%d] Y:%x UV:%x Int:%x YDnSz:%x UVDnSz:%x\n", i, hw->stats.rx_errors, y_err_sts, uv_err_sts, intr_sts, y_dn_sz, - uv_dn_sz); + uv_dn_sz); hw->rx_list_sts[i] = sts_free; comp_sts = BC_STS_ERROR; break; diff --git a/drivers/staging/crystalhd/crystalhd_lnx.c b/drivers/staging/crystalhd/crystalhd_lnx.c index c1f6163cdeb81..b17fbf8181cf4 100644 --- a/drivers/staging/crystalhd/crystalhd_lnx.c +++ b/drivers/staging/crystalhd/crystalhd_lnx.c @@ -545,8 +545,7 @@ static int chd_dec_pci_probe(struct pci_dev *pdev, int rc; enum BC_STATUS sts = BC_STS_SUCCESS; - BCMLOG(BCMLOG_DBG, "PCI_INFO: Vendor:0x%04x Device:0x%04x " - "s_vendor:0x%04x s_device: 0x%04x\n", + BCMLOG(BCMLOG_DBG, "PCI_INFO: Vendor:0x%04x Device:0x%04x s_vendor:0x%04x s_device: 0x%04x\n", pdev->vendor, pdev->device, pdev->subsystem_vendor, pdev->subsystem_device); -- GitLab From 115cac2e7a8d06aa347bf233b4cb94828eb0509a Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Wed, 28 Aug 2013 21:12:35 +0100 Subject: [PATCH 917/942] staging: vt6656: device.h Replace typedef struct _RCB Replace with struct vnt_rcb Signed-off-by: Malcolm Priestley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/device.h | 20 +++++++++----------- drivers/staging/vt6656/dpc.c | 10 +++++----- drivers/staging/vt6656/dpc.h | 4 ++-- drivers/staging/vt6656/main_usb.c | 14 ++++++++------ drivers/staging/vt6656/usbpipe.c | 4 ++-- drivers/staging/vt6656/usbpipe.h | 2 +- 6 files changed, 27 insertions(+), 27 deletions(-) diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h index 3151c8fb88b35..8e396341c5e84 100644 --- a/drivers/staging/vt6656/device.h +++ b/drivers/staging/vt6656/device.h @@ -166,8 +166,7 @@ typedef enum _CONTEXT_TYPE { } CONTEXT_TYPE; /* RCB (Receive Control Block) */ -typedef struct _RCB -{ +struct vnt_rcb { void *Next; signed long Ref; void *pDevice; @@ -175,8 +174,7 @@ typedef struct _RCB struct vnt_rx_mgmt sMngPacket; struct sk_buff *skb; int bBoolInUse; - -} RCB, *PRCB; +}; /* used to track bulk out irps */ struct vnt_usb_send_context { @@ -416,14 +414,14 @@ struct vnt_private { u32 int_interval; /* Variables to track resources for the BULK In Pipe */ - PRCB pRCBMem; - PRCB apRCB[CB_MAX_RX_DESC]; + struct vnt_rcb *pRCBMem; + struct vnt_rcb *apRCB[CB_MAX_RX_DESC]; u32 cbRD; - PRCB FirstRecvFreeList; - PRCB LastRecvFreeList; + struct vnt_rcb *FirstRecvFreeList; + struct vnt_rcb *LastRecvFreeList; u32 NumRecvFreeList; - PRCB FirstRecvMngList; - PRCB LastRecvMngList; + struct vnt_rcb *FirstRecvMngList; + struct vnt_rcb *LastRecvMngList; u32 NumRecvMngList; int bIsRxWorkItemQueued; int bIsRxMngWorkItemQueued; @@ -774,7 +772,7 @@ struct vnt_private { #define DequeueRCB(Head, Tail) \ { \ - PRCB RCB = Head; \ + struct vnt_rcb *RCB = Head; \ if (!RCB->Next) { \ Tail = NULL; \ } \ diff --git a/drivers/staging/vt6656/dpc.c b/drivers/staging/vt6656/dpc.c index 4bc362f530a77..ea7d443b11d06 100644 --- a/drivers/staging/vt6656/dpc.c +++ b/drivers/staging/vt6656/dpc.c @@ -246,7 +246,7 @@ s_vGetDASA ( *pcbHeaderSize = cbHeaderSize; } -int RXbBulkInProcessData(struct vnt_private *pDevice, PRCB pRCB, +int RXbBulkInProcessData(struct vnt_private *pDevice, struct vnt_rcb *pRCB, unsigned long BytesToIndicate) { struct net_device_stats *pStats = &pDevice->stats; @@ -271,7 +271,7 @@ int RXbBulkInProcessData(struct vnt_private *pDevice, PRCB pRCB, /* signed long ldBm = 0; */ int bIsWEP = false; int bExtIV = false; u32 dwWbkStatus; - PRCB pRCBIndicate = pRCB; + struct vnt_rcb *pRCBIndicate = pRCB; u8 *pbyDAddress; u16 *pwPLCP_Length; u8 abyVaildRate[MAX_RATE] @@ -1336,7 +1336,7 @@ static int s_bAPModeRxData(struct vnt_private *pDevice, struct sk_buff *skb, void RXvWorkItem(struct vnt_private *pDevice) { int ntStatus; - PRCB pRCB = NULL; + struct vnt_rcb *pRCB = NULL; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Rx Polling Thread\n"); spin_lock_irq(&pDevice->lock); @@ -1354,7 +1354,7 @@ void RXvWorkItem(struct vnt_private *pDevice) } -void RXvFreeRCB(PRCB pRCB, int bReAllocSkb) +void RXvFreeRCB(struct vnt_rcb *pRCB, int bReAllocSkb) { struct vnt_private *pDevice = pRCB->pDevice; @@ -1391,7 +1391,7 @@ void RXvFreeRCB(PRCB pRCB, int bReAllocSkb) void RXvMngWorkItem(struct vnt_private *pDevice) { - PRCB pRCB = NULL; + struct vnt_rcb *pRCB = NULL; struct vnt_rx_mgmt *pRxPacket; int bReAllocSkb = false; diff --git a/drivers/staging/vt6656/dpc.h b/drivers/staging/vt6656/dpc.h index 876468f2c3d29..95388dc03ee39 100644 --- a/drivers/staging/vt6656/dpc.h +++ b/drivers/staging/vt6656/dpc.h @@ -36,9 +36,9 @@ void RXvWorkItem(void *Context); void RXvMngWorkItem(void *Context); -void RXvFreeRCB(PRCB pRCB, int bReAllocSkb); +void RXvFreeRCB(struct vnt_rcb *pRCB, int bReAllocSkb); -int RXbBulkInProcessData(struct vnt_private *, PRCB pRCB, +int RXbBulkInProcessData(struct vnt_private *, struct vnt_rcb *pRCB, unsigned long BytesToIndicate); #endif /* __RXTX_H__ */ diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index 37d66a348d7f1..536971786ae8e 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -751,8 +751,8 @@ static void device_free_tx_bufs(struct vnt_private *pDevice) static void device_free_rx_bufs(struct vnt_private *pDevice) { - PRCB pRCB; - int ii; + struct vnt_rcb *pRCB; + int ii; for (ii = 0; ii < pDevice->cbRD; ii++) { @@ -789,8 +789,8 @@ static void device_free_int_bufs(struct vnt_private *pDevice) static bool device_alloc_bufs(struct vnt_private *pDevice) { struct vnt_usb_send_context *pTxContext; - PRCB pRCB; - int ii; + struct vnt_rcb *pRCB; + int ii; for (ii = 0; ii < pDevice->cbTD; ii++) { @@ -811,7 +811,8 @@ static bool device_alloc_bufs(struct vnt_private *pDevice) } /* allocate RCB mem */ - pDevice->pRCBMem = kzalloc((sizeof(RCB) * pDevice->cbRD), GFP_KERNEL); + pDevice->pRCBMem = kzalloc((sizeof(struct vnt_rcb) * pDevice->cbRD), + GFP_KERNEL); if (pDevice->pRCBMem == NULL) { DBG_PRT(MSG_LEVEL_ERR,KERN_ERR "%s : alloc rx usb context failed\n", pDevice->dev->name); goto free_tx; @@ -822,7 +823,8 @@ static bool device_alloc_bufs(struct vnt_private *pDevice) pDevice->FirstRecvMngList = NULL; pDevice->LastRecvMngList = NULL; pDevice->NumRecvFreeList = 0; - pRCB = (PRCB) pDevice->pRCBMem; + + pRCB = (struct vnt_rcb *)pDevice->pRCBMem; for (ii = 0; ii < pDevice->cbRD; ii++) { diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c index 78749eff26e44..3a03f1d5b6856 100644 --- a/drivers/staging/vt6656/usbpipe.c +++ b/drivers/staging/vt6656/usbpipe.c @@ -421,7 +421,7 @@ static void s_nsInterruptUsbIoCompleteRead(struct urb *urb) * */ -int PIPEnsBulkInUsbRead(struct vnt_private *pDevice, PRCB pRCB) +int PIPEnsBulkInUsbRead(struct vnt_private *pDevice, struct vnt_rcb *pRCB) { int ntStatus = 0; struct urb *pUrb; @@ -479,7 +479,7 @@ int PIPEnsBulkInUsbRead(struct vnt_private *pDevice, PRCB pRCB) static void s_nsBulkInUsbIoCompleteRead(struct urb *urb) { - PRCB pRCB = (PRCB)urb->context; + struct vnt_rcb *pRCB = (struct vnt_rcb *)urb->context; struct vnt_private *pDevice = pRCB->pDevice; unsigned long bytesRead; int bIndicateReceive = false; diff --git a/drivers/staging/vt6656/usbpipe.h b/drivers/staging/vt6656/usbpipe.h index e2a2bce75f1fc..f53770329e757 100644 --- a/drivers/staging/vt6656/usbpipe.h +++ b/drivers/staging/vt6656/usbpipe.h @@ -40,7 +40,7 @@ int PIPEnsControlIn(struct vnt_private *, u8 byRequest, u16 wValue, u16 wIndex, u16 wLength, u8 *pbyBuffer); int PIPEnsInterruptRead(struct vnt_private *); -int PIPEnsBulkInUsbRead(struct vnt_private *, PRCB pRCB); +int PIPEnsBulkInUsbRead(struct vnt_private *, struct vnt_rcb *pRCB); int PIPEnsSendBulkOut(struct vnt_private *, struct vnt_usb_send_context *pContext); -- GitLab From e1811f97ba985fef3f703f55aeb5d23660c919ef Mon Sep 17 00:00:00 2001 From: Josh Wu Date: Tue, 27 Aug 2013 12:28:00 +0100 Subject: [PATCH 918/942] iio: at91: introduce the multiple compatible string for different IPs. As use the multiple compatible string, we can remove hardware register in dt. CC: devicetree@vger.kernel.org Signed-off-by: Josh Wu Acked-by: Maxime Ripard Signed-off-by: Jonathan Cameron --- .../devicetree/bindings/arm/atmel-adc.txt | 7 +- arch/arm/mach-at91/include/mach/at91_adc.h | 9 +++ drivers/iio/adc/at91_adc.c | 79 ++++++++++--------- 3 files changed, 52 insertions(+), 43 deletions(-) diff --git a/Documentation/devicetree/bindings/arm/atmel-adc.txt b/Documentation/devicetree/bindings/arm/atmel-adc.txt index 16769d9cedd63..723c205cb10d8 100644 --- a/Documentation/devicetree/bindings/arm/atmel-adc.txt +++ b/Documentation/devicetree/bindings/arm/atmel-adc.txt @@ -1,18 +1,15 @@ * AT91's Analog to Digital Converter (ADC) Required properties: - - compatible: Should be "atmel,at91sam9260-adc" + - compatible: Should be "atmel,-adc" + can be "at91sam9260", "at91sam9g45" or "at91sam9x5" - reg: Should contain ADC registers location and length - interrupts: Should contain the IRQ line for the ADC - - atmel,adc-channel-base: Offset of the first channel data register - atmel,adc-channels-used: Bitmask of the channels muxed and enable for this device - - atmel,adc-drdy-mask: Mask of the DRDY interruption in the ADC - atmel,adc-num-channels: Number of channels available in the ADC - atmel,adc-startup-time: Startup Time of the ADC in microseconds as defined in the datasheet - - atmel,adc-status-register: Offset of the Interrupt Status Register - - atmel,adc-trigger-register: Offset of the Trigger Register - atmel,adc-vref: Reference voltage in millivolts for the conversions - atmel,adc-res: List of resolution in bits supported by the ADC. List size must be two at least. diff --git a/arch/arm/mach-at91/include/mach/at91_adc.h b/arch/arm/mach-at91/include/mach/at91_adc.h index 8e7ed5c908175..bea1a2021d1e3 100644 --- a/arch/arm/mach-at91/include/mach/at91_adc.h +++ b/arch/arm/mach-at91/include/mach/at91_adc.h @@ -48,6 +48,9 @@ #define AT91_ADC_ENDRX (1 << 18) /* End of RX Buffer */ #define AT91_ADC_RXFUFF (1 << 19) /* RX Buffer Full */ +#define AT91_ADC_SR_9X5 0x30 /* Status Register for 9x5 */ +#define AT91_ADC_SR_DRDY_9X5 (1 << 24) /* Data Ready */ + #define AT91_ADC_LCDR 0x20 /* Last Converted Data Register */ #define AT91_ADC_LDATA (0x3ff) @@ -58,4 +61,10 @@ #define AT91_ADC_CHR(n) (0x30 + ((n) * 4)) /* Channel Data Register N */ #define AT91_ADC_DATA (0x3ff) +#define AT91_ADC_CDR0_9X5 (0x50) /* Channel Data Register 0 for 9X5 */ + +#define AT91_ADC_TRGR_9260 AT91_ADC_MR +#define AT91_ADC_TRGR_9G45 0x08 +#define AT91_ADC_TRGR_9X5 0xC0 + #endif diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c index 423e079460d3a..ed5eebc93bb74 100644 --- a/drivers/iio/adc/at91_adc.c +++ b/drivers/iio/adc/at91_adc.c @@ -39,6 +39,10 @@ #define at91_adc_writel(st, reg, val) \ (writel_relaxed(val, st->reg_base + reg)) +struct at91_adc_caps { + struct at91_adc_reg_desc registers; +}; + struct at91_adc_state { struct clk *adc_clk; u16 *buffer; @@ -62,6 +66,7 @@ struct at91_adc_state { u32 res; /* resolution used for convertions */ bool low_res; /* the resolution corresponds to the lowest one */ wait_queue_head_t wq_data_avail; + struct at91_adc_caps *caps; }; static irqreturn_t at91_adc_trigger_handler(int irq, void *p) @@ -429,6 +434,8 @@ static int at91_adc_of_get_resolution(struct at91_adc_state *st, return ret; } +static const struct of_device_id at91_adc_dt_ids[]; + static int at91_adc_probe_dt(struct at91_adc_state *st, struct platform_device *pdev) { @@ -441,6 +448,9 @@ static int at91_adc_probe_dt(struct at91_adc_state *st, if (!node) return -EINVAL; + st->caps = (struct at91_adc_caps *) + of_match_device(at91_adc_dt_ids, &pdev->dev)->data; + st->use_external = of_property_read_bool(node, "atmel,adc-use-external-triggers"); if (of_property_read_u32(node, "atmel,adc-channels-used", &prop)) { @@ -481,43 +491,7 @@ static int at91_adc_probe_dt(struct at91_adc_state *st, if (ret) goto error_ret; - st->registers = devm_kzalloc(&idev->dev, - sizeof(struct at91_adc_reg_desc), - GFP_KERNEL); - if (!st->registers) { - dev_err(&idev->dev, "Could not allocate register memory.\n"); - ret = -ENOMEM; - goto error_ret; - } - - if (of_property_read_u32(node, "atmel,adc-channel-base", &prop)) { - dev_err(&idev->dev, "Missing adc-channel-base property in the DT.\n"); - ret = -EINVAL; - goto error_ret; - } - st->registers->channel_base = prop; - - if (of_property_read_u32(node, "atmel,adc-drdy-mask", &prop)) { - dev_err(&idev->dev, "Missing adc-drdy-mask property in the DT.\n"); - ret = -EINVAL; - goto error_ret; - } - st->registers->drdy_mask = prop; - - if (of_property_read_u32(node, "atmel,adc-status-register", &prop)) { - dev_err(&idev->dev, "Missing adc-status-register property in the DT.\n"); - ret = -EINVAL; - goto error_ret; - } - st->registers->status_register = prop; - - if (of_property_read_u32(node, "atmel,adc-trigger-register", &prop)) { - dev_err(&idev->dev, "Missing adc-trigger-register property in the DT.\n"); - ret = -EINVAL; - goto error_ret; - } - st->registers->trigger_register = prop; - + st->registers = &st->caps->registers; st->trigger_number = of_get_child_count(node); st->trigger_list = devm_kzalloc(&idev->dev, st->trigger_number * sizeof(struct at91_adc_trigger), @@ -766,8 +740,37 @@ static int at91_adc_remove(struct platform_device *pdev) } #ifdef CONFIG_OF +static struct at91_adc_caps at91sam9260_caps = { + .registers = { + .channel_base = AT91_ADC_CHR(0), + .drdy_mask = AT91_ADC_DRDY, + .status_register = AT91_ADC_SR, + .trigger_register = AT91_ADC_TRGR_9260, + }, +}; + +static struct at91_adc_caps at91sam9g45_caps = { + .registers = { + .channel_base = AT91_ADC_CHR(0), + .drdy_mask = AT91_ADC_DRDY, + .status_register = AT91_ADC_SR, + .trigger_register = AT91_ADC_TRGR_9G45, + }, +}; + +static struct at91_adc_caps at91sam9x5_caps = { + .registers = { + .channel_base = AT91_ADC_CDR0_9X5, + .drdy_mask = AT91_ADC_SR_DRDY_9X5, + .status_register = AT91_ADC_SR_9X5, + .trigger_register = AT91_ADC_TRGR_9X5, + }, +}; + static const struct of_device_id at91_adc_dt_ids[] = { - { .compatible = "atmel,at91sam9260-adc" }, + { .compatible = "atmel,at91sam9260-adc", .data = &at91sam9260_caps }, + { .compatible = "atmel,at91sam9g45-adc", .data = &at91sam9g45_caps }, + { .compatible = "atmel,at91sam9x5-adc", .data = &at91sam9x5_caps }, {}, }; MODULE_DEVICE_TABLE(of, at91_adc_dt_ids); -- GitLab From 9120c0bea999cc26c3493486828d34138a7ac901 Mon Sep 17 00:00:00 2001 From: Josh Wu Date: Tue, 27 Aug 2013 12:28:00 +0100 Subject: [PATCH 919/942] iio: at91: Use different prescal, startup mask in MR for different IP For at91 boards, there are different IPs for adc. Different IPs has different STARTUP & PRESCAL mask in ADC_MR. Signed-off-by: Josh Wu Acked-by: Maxime Ripard Signed-off-by: Jonathan Cameron --- arch/arm/mach-at91/include/mach/at91_adc.h | 7 +++++-- drivers/iio/adc/at91_adc.c | 11 +++++++++-- include/linux/platform_data/at91_adc.h | 4 ++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/arch/arm/mach-at91/include/mach/at91_adc.h b/arch/arm/mach-at91/include/mach/at91_adc.h index bea1a2021d1e3..048a57f76bd3b 100644 --- a/arch/arm/mach-at91/include/mach/at91_adc.h +++ b/arch/arm/mach-at91/include/mach/at91_adc.h @@ -28,9 +28,12 @@ #define AT91_ADC_TRGSEL_EXTERNAL (6 << 1) #define AT91_ADC_LOWRES (1 << 4) /* Low Resolution */ #define AT91_ADC_SLEEP (1 << 5) /* Sleep Mode */ -#define AT91_ADC_PRESCAL (0x3f << 8) /* Prescalar Rate Selection */ +#define AT91_ADC_PRESCAL_9260 (0x3f << 8) /* Prescalar Rate Selection */ +#define AT91_ADC_PRESCAL_9G45 (0xff << 8) #define AT91_ADC_PRESCAL_(x) ((x) << 8) -#define AT91_ADC_STARTUP (0x1f << 16) /* Startup Up Time */ +#define AT91_ADC_STARTUP_9260 (0x1f << 16) /* Startup Up Time */ +#define AT91_ADC_STARTUP_9G45 (0x7f << 16) +#define AT91_ADC_STARTUP_9X5 (0xf << 16) #define AT91_ADC_STARTUP_(x) ((x) << 16) #define AT91_ADC_SHTIM (0xf << 24) /* Sample & Hold Time */ #define AT91_ADC_SHTIM_(x) ((x) << 24) diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c index ed5eebc93bb74..84be63bdf0382 100644 --- a/drivers/iio/adc/at91_adc.c +++ b/drivers/iio/adc/at91_adc.c @@ -672,8 +672,8 @@ static int at91_adc_probe(struct platform_device *pdev) shtim = round_up((st->sample_hold_time * adc_clk / 1000000) - 1, 1); - reg = AT91_ADC_PRESCAL_(prsc) & AT91_ADC_PRESCAL; - reg |= AT91_ADC_STARTUP_(ticks) & AT91_ADC_STARTUP; + reg = AT91_ADC_PRESCAL_(prsc) & st->registers->mr_prescal_mask; + reg |= AT91_ADC_STARTUP_(ticks) & st->registers->mr_startup_mask; if (st->low_res) reg |= AT91_ADC_LOWRES; if (st->sleep_mode) @@ -746,6 +746,8 @@ static struct at91_adc_caps at91sam9260_caps = { .drdy_mask = AT91_ADC_DRDY, .status_register = AT91_ADC_SR, .trigger_register = AT91_ADC_TRGR_9260, + .mr_prescal_mask = AT91_ADC_PRESCAL_9260, + .mr_startup_mask = AT91_ADC_STARTUP_9260, }, }; @@ -755,6 +757,8 @@ static struct at91_adc_caps at91sam9g45_caps = { .drdy_mask = AT91_ADC_DRDY, .status_register = AT91_ADC_SR, .trigger_register = AT91_ADC_TRGR_9G45, + .mr_prescal_mask = AT91_ADC_PRESCAL_9G45, + .mr_startup_mask = AT91_ADC_STARTUP_9G45, }, }; @@ -764,6 +768,9 @@ static struct at91_adc_caps at91sam9x5_caps = { .drdy_mask = AT91_ADC_SR_DRDY_9X5, .status_register = AT91_ADC_SR_9X5, .trigger_register = AT91_ADC_TRGR_9X5, + /* prescal mask is same as 9G45 */ + .mr_prescal_mask = AT91_ADC_PRESCAL_9G45, + .mr_startup_mask = AT91_ADC_STARTUP_9X5, }, }; diff --git a/include/linux/platform_data/at91_adc.h b/include/linux/platform_data/at91_adc.h index e15745b4f3a53..b3ca1e94e0c88 100644 --- a/include/linux/platform_data/at91_adc.h +++ b/include/linux/platform_data/at91_adc.h @@ -14,12 +14,16 @@ (Interruptions registers mostly) * @status_register: Offset of the Interrupt Status Register * @trigger_register: Offset of the Trigger setup register + * @mr_prescal_mask: Mask of the PRESCAL field in the adc MR register + * @mr_startup_mask: Mask of the STARTUP field in the adc MR register */ struct at91_adc_reg_desc { u8 channel_base; u32 drdy_mask; u8 status_register; u8 trigger_register; + u32 mr_prescal_mask; + u32 mr_startup_mask; }; /** -- GitLab From c211148fb6355f347ec819a05c3034acd56e75c1 Mon Sep 17 00:00:00 2001 From: Lidza Louina Date: Thu, 29 Aug 2013 19:00:37 -0400 Subject: [PATCH 920/942] staging: dgnc: adds TODO This patchs adds a TODO for the driver. Signed-off-by: Lidza Louina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgnc/TODO | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 drivers/staging/dgnc/TODO diff --git a/drivers/staging/dgnc/TODO b/drivers/staging/dgnc/TODO new file mode 100644 index 0000000000000..1ff2d1874aa25 --- /dev/null +++ b/drivers/staging/dgnc/TODO @@ -0,0 +1,17 @@ +* remove kzalloc casts +* checkpatch fixes +* sparse fixes +* fix use of sizeof(). Example replace sizeof(struct board_t) + with sizeof(*brd) and remove sizeof(char) +* change name of board_t to dgnc_board +* split two assignments into the two assignments on two lines; + don't use two equals signs +* remove unecessary comments +* remove unecessary error messages. Example kzalloc() has its + own error message. Adding an extra one is useless. +* use goto statements for error handling when appropriate +* there is a lot of unecessary code in the driver. It was + originally a standalone driver. Remove uneeded code. + +Please send patches to Greg Kroah-Hartman and +Cc: Lidza Louina -- GitLab From 351699d7ebb1e489d2ee5b51d1b4dd4cc2a822ac Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Thu, 29 Aug 2013 22:53:25 +0200 Subject: [PATCH 921/942] staging: dgap: Add missing #include MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit drivers/staging/dgap/dgap_driver.c: In function ‘dgap_cleanup_module’: drivers/staging/dgap/dgap_driver.c:423: error: implicit declaration of function ‘kfree’ drivers/staging/dgap/dgap_driver.c: In function ‘dgap_driver_kzmalloc’: drivers/staging/dgap/dgap_driver.c:940: error: implicit declaration of function ‘kmalloc’ drivers/staging/dgap/dgap_driver.c:940: warning: initialization makes pointer from integer without a cast Signed-off-by: Geert Uytterhoeven Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dgap/dgap_driver.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/dgap/dgap_driver.c b/drivers/staging/dgap/dgap_driver.c index 9f777e41c9a63..724a685753dd8 100644 --- a/drivers/staging/dgap/dgap_driver.c +++ b/drivers/staging/dgap/dgap_driver.c @@ -36,6 +36,7 @@ #include #include #include /* For udelay */ +#include #include /* For copy_from_user/copy_to_user */ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39) -- GitLab From 40fac5a1322719074312e58273392e9b652c64a1 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 28 Aug 2013 21:12:25 -0500 Subject: [PATCH 922/942] staging: r8188eu: Fix compiler warnings in os_dep/ioctl_linux.c The 0-DAY kernel build testing backend reports the following compiler warnings not shown on my compiler version/options: drivers/staging/rtl8188eu/os_dep/ioctl_linux.c: In function 'rtw_mp_efuse_get': >> drivers/staging/rtl8188eu/os_dep/ioctl_linux.c:5836:65: warning: iteration 16u invokes undefined behavior [-Waggressive-loop-optimizations] sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeEfuseInitMap[i+j]); ^ drivers/staging/rtl8188eu/os_dep/ioctl_linux.c:5830:3: note: containing loop for (i = 0; i < EFUSE_MAP_SIZE; i += 16) { ^ >> drivers/staging/rtl8188eu/os_dep/ioctl_linux.c:6042:69: warning: iteration 16u invokes undefined behavior [-Waggressive-loop-optimizations] sprintf(extra, "%s %02X", extra, pEfuseHal->fakeEfuseModifiedMap[i+j]); ^ drivers/staging/rtl8188eu/os_dep/ioctl_linux.c:6036:3: note: containing loop for (i = 0; i < EFUSE_MAP_SIZE; i += 16) { ^ The problem is due to improper settings for some of the EFUSE_XXX defines such that EFUSE_MAP_SIZE was larger than the sizes of the marked arrays. Thanks to Fengguang Wu for helping me understand the root cause. Reported-by: Fengguang Wu Signed-off-by: Larry Finger Cc: Fengguang Wu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/rtl8188e_hal.h | 2 +- drivers/staging/rtl8188eu/include/rtw_efuse.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h index fc4adb614bfed..52b280165a926 100644 --- a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h +++ b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h @@ -197,7 +197,6 @@ struct txpowerinfo24g { }; #define EFUSE_REAL_CONTENT_LEN 512 -#define EFUSE_MAP_LEN 128 #define EFUSE_MAX_SECTION 16 #define EFUSE_IC_ID_OFFSET 506 /* For some inferior IC purpose*/ #define AVAILABLE_EFUSE_ADDR(addr) (addr < EFUSE_REAL_CONTENT_LEN) @@ -215,6 +214,7 @@ struct txpowerinfo24g { #define EFUSE_REAL_CONTENT_LEN_88E 256 #define EFUSE_MAP_LEN_88E 512 +#define EFUSE_MAP_LEN EFUSE_MAP_LEN_88E #define EFUSE_MAX_SECTION_88E 64 #define EFUSE_MAX_WORD_UNIT_88E 4 #define EFUSE_IC_ID_OFFSET_88E 506 diff --git a/drivers/staging/rtl8188eu/include/rtw_efuse.h b/drivers/staging/rtl8188eu/include/rtw_efuse.h index 4d45e1e82543b..cee6b5e8b070f 100644 --- a/drivers/staging/rtl8188eu/include/rtw_efuse.h +++ b/drivers/staging/rtl8188eu/include/rtw_efuse.h @@ -54,7 +54,7 @@ enum _EFUSE_DEF_TYPE { #define EFUSE_MAX_SIZE 256 /* end of E-Fuse */ -#define EFUSE_MAX_MAP_LEN 256 +#define EFUSE_MAX_MAP_LEN 512 #define EFUSE_MAX_HW_SIZE 512 #define EFUSE_MAX_SECTION_BASE 16 -- GitLab From df23983c212ab58b3171177a53fad78cea325b99 Mon Sep 17 00:00:00 2001 From: Shaun Laing Date: Thu, 29 Aug 2013 08:27:22 -0600 Subject: [PATCH 923/942] staging: crystalhd: Resolve sparse 'different base types' warnings. The result from crystalhd_get_sgle_paddr and crystalhd_get_sgle_len are later used in calculations, so the result should be in CPU byte ordering. Signed-off-by: Shaun Laing Signed-off-by: Greg Kroah-Hartman --- drivers/staging/crystalhd/crystalhd_misc.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/crystalhd/crystalhd_misc.h b/drivers/staging/crystalhd/crystalhd_misc.h index 4dae3a797e956..aa736c8855dec 100644 --- a/drivers/staging/crystalhd/crystalhd_misc.h +++ b/drivers/staging/crystalhd/crystalhd_misc.h @@ -177,8 +177,8 @@ extern enum BC_STATUS crystalhd_map_dio(struct crystalhd_adp *, void *, extern enum BC_STATUS crystalhd_unmap_dio(struct crystalhd_adp *, struct crystalhd_dio_req*); -#define crystalhd_get_sgle_paddr(_dio, _ix) (cpu_to_le64(sg_dma_address(&_dio->sg[_ix]))) -#define crystalhd_get_sgle_len(_dio, _ix) (cpu_to_le32(sg_dma_len(&_dio->sg[_ix]))) +#define crystalhd_get_sgle_paddr(_dio, _ix) (sg_dma_address(&_dio->sg[_ix])) +#define crystalhd_get_sgle_len(_dio, _ix) (sg_dma_len(&_dio->sg[_ix])) /*================ General Purpose Queues ==================*/ extern enum BC_STATUS crystalhd_create_dioq(struct crystalhd_adp *, -- GitLab From 955fae6fd7d77264a788441586515b75948c7985 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Fri, 30 Aug 2013 00:45:06 +0300 Subject: [PATCH 924/942] staging: r8188eu: off by one bugs These should be "<" instead of "<=". Also we can use the ARRAY_SIZE() macro. Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_cmd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_cmd.c b/drivers/staging/rtl8188eu/core/rtw_cmd.c index 859fc1919ad64..9632ef48fbc12 100644 --- a/drivers/staging/rtl8188eu/core/rtw_cmd.c +++ b/drivers/staging/rtl8188eu/core/rtw_cmd.c @@ -367,7 +367,7 @@ _func_enter_; memcpy(pcmdbuf, pcmd->parmbuf, pcmd->cmdsz); - if (pcmd->cmdcode <= (sizeof(wlancmds) / sizeof(struct cmd_hdl))) { + if (pcmd->cmdcode < ARRAY_SIZE(wlancmds)) { cmd_hdl = wlancmds[pcmd->cmdcode].h2cfuns; if (cmd_hdl) { @@ -385,7 +385,7 @@ _func_enter_; post_process: /* call callback function for post-processed */ - if (pcmd->cmdcode <= (sizeof(rtw_cmd_callback) / sizeof(struct _cmd_callback))) { + if (pcmd->cmdcode < ARRAY_SIZE(rtw_cmd_callback)) { pcmd_callback = rtw_cmd_callback[pcmd->cmdcode].callback; if (pcmd_callback == NULL) { RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("mlme_cmd_hdl(): pcmd_callback = 0x%p, cmdcode = 0x%x\n", pcmd_callback, pcmd->cmdcode)); -- GitLab From 976e0cf6855da26995c0560f4befd66c3b06de9f Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Fri, 30 Aug 2013 00:46:14 +0300 Subject: [PATCH 925/942] staging: rtl8188eu: || vs && typo Obviously it's impossible for ->KeyLength to be both 5 and 13. I assume that && was intended here. Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ioctl_set.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c b/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c index 9e127746416fd..47fb253fff171 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c @@ -743,7 +743,7 @@ _func_enter_; /* Check key length for WEP. For NDTEST, 2005.01.27, by rcnjko. */ if ((encryptionalgo == _WEP40_ || encryptionalgo == _WEP104_) && - (key->KeyLength != 5 || key->KeyLength != 13)) { + (key->KeyLength != 5 && key->KeyLength != 13)) { RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("WEP KeyLength:0x%x != 5 or 13\n", key->KeyLength)); ret = _FAIL; goto exit; -- GitLab From 15f7af8be40e7db5cd642d2ffbbe15e5d8bc1ed8 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Fri, 30 Aug 2013 00:47:01 +0300 Subject: [PATCH 926/942] staging: r8188eu: copying one byte too much There is a copy and paste bug here so we copy 4 bytes instead of 3. Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_wlan_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c index a43fc8892d612..013ea487e7acc 100644 --- a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c @@ -1592,7 +1592,7 @@ void update_bmc_sta_support_rate(struct adapter *padapter, u32 mac_id) /* Only B, B/G, and B/G/N AP could use CCK rate */ memcpy((pmlmeinfo->FW_sta_info[mac_id].SupportedRates), rtw_basic_rate_cck, 4); } else { - memcpy((pmlmeinfo->FW_sta_info[mac_id].SupportedRates), rtw_basic_rate_ofdm, 4); + memcpy((pmlmeinfo->FW_sta_info[mac_id].SupportedRates), rtw_basic_rate_ofdm, 3); } } -- GitLab From dc427fe72bcb281a3ff07183da2d4f277f41524e Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Fri, 30 Aug 2013 00:45:42 +0300 Subject: [PATCH 927/942] staging: rtl8188eu: off by one in rtw_set_802_11_add_wep() "keyid" is used as an offset into the ->dot11DefKey[] array. The array has 4 elements. Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ioctl_set.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c b/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c index 47fb253fff171..193f641bd0deb 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c @@ -566,7 +566,7 @@ _func_enter_; keyid = wep->KeyIndex & 0x3fffffff; - if (keyid > 4) { + if (keyid >= 4) { RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("MgntActrtw_set_802_11_add_wep:keyid>4 =>fail\n")); ret = false; goto exit; -- GitLab From bad40bb4be4acc40434a5f2dcce9d6f4190a4da5 Mon Sep 17 00:00:00 2001 From: navin patidar Date: Fri, 30 Aug 2013 12:31:51 +0530 Subject: [PATCH 928/942] staging: bcm: remove Version.h file. many of the macros defined in Version.h are not being used, so we can remove the file. Signed-off-by: navin patidar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/Bcmchar.c | 4 ++-- drivers/staging/bcm/Version.h | 29 ----------------------------- drivers/staging/bcm/headers.h | 3 +-- 3 files changed, 3 insertions(+), 33 deletions(-) delete mode 100644 drivers/staging/bcm/Version.h diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c index f67a22536cbf6..f91bc1fdd895e 100644 --- a/drivers/staging/bcm/Bcmchar.c +++ b/drivers/staging/bcm/Bcmchar.c @@ -1004,9 +1004,9 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg) if (copy_from_user(&IoBuffer, argp, sizeof(struct bcm_ioctl_buffer))) return -EFAULT; - len = min_t(ulong, IoBuffer.OutputLength, strlen(VER_FILEVERSION_STR) + 1); + len = min_t(ulong, IoBuffer.OutputLength, strlen(DRV_VERSION) + 1); - if (copy_to_user(IoBuffer.OutputBuffer, VER_FILEVERSION_STR, len)) + if (copy_to_user(IoBuffer.OutputBuffer, DRV_VERSION, len)) return -EFAULT; Status = STATUS_SUCCESS; break; diff --git a/drivers/staging/bcm/Version.h b/drivers/staging/bcm/Version.h deleted file mode 100644 index f1cb9de734a6a..0000000000000 --- a/drivers/staging/bcm/Version.h +++ /dev/null @@ -1,29 +0,0 @@ -/*Copyright (c) 2005 Beceem Communications Inc. - -Module Name: - - Version.h - -Abstract: - - ---*/ - -#ifndef VERSION_H -#define VERSION_H - - -#define VER_FILETYPE VFT_DRV -#define VER_FILESUBTYPE VFT2_DRV_NETWORK - -#define VER_FILEVERSION 5.2.45 -#define VER_FILEVERSION_STR "5.2.45" - -#undef VER_PRODUCTVERSION -#define VER_PRODUCTVERSION VER_FILEVERSION - -#undef VER_PRODUCTVERSION_STR -#define VER_PRODUCTVERSION_STR VER_FILEVERSION_STR - - -#endif /* VERSION_H */ diff --git a/drivers/staging/bcm/headers.h b/drivers/staging/bcm/headers.h index da47db8c8f299..7fd21c6923cb7 100644 --- a/drivers/staging/bcm/headers.h +++ b/drivers/staging/bcm/headers.h @@ -38,7 +38,6 @@ #include #include "Typedefs.h" -#include "Version.h" #include "Macros.h" #include "HostMIBSInterface.h" #include "cntrl_SignalingInterface.h" @@ -71,7 +70,7 @@ #define DEV_NAME "tarang" #define DRV_DESCRIPTION "Beceem Communications Inc. WiMAX driver" #define DRV_COPYRIGHT "Copyright 2010. Beceem Communications Inc" -#define DRV_VERSION VER_FILEVERSION_STR +#define DRV_VERSION "5.2.45" #define PFX DRV_NAME " " extern struct class *bcm_class; -- GitLab From 025a9230c8373e0bac5b432ea9d4991cc3be5f11 Mon Sep 17 00:00:00 2001 From: Paul McQuade Date: Thu, 15 Aug 2013 20:00:50 +0100 Subject: [PATCH 929/942] Staging:BCM:DDRInit.c:Renaming __FUNCTION__ __Function__ gets renamed with __func__ Signed-Off-By: Paul McQuade Signed-off-by: Greg Kroah-Hartman --- drivers/staging/bcm/DDRInit.c | 54 +++++++++++++++++------------------ 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/drivers/staging/bcm/DDRInit.c b/drivers/staging/bcm/DDRInit.c index 8c696b64ab247..f5eda96f0f837 100644 --- a/drivers/staging/bcm/DDRInit.c +++ b/drivers/staging/bcm/DDRInit.c @@ -828,13 +828,13 @@ int ddr_init(struct bcm_mini_adapter *Adapter) { retval= rdmalt(Adapter,(UINT)0x0f000830, &uiResetValue, sizeof(uiResetValue)); if(retval < 0) { - BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); + BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; } uiResetValue |= 0x44; retval = wrmalt(Adapter,(UINT)0x0f000830, &uiResetValue, sizeof(uiResetValue)); if(retval < 0) { - BCM_DEBUG_PRINT(Adapter,CMHOST, WRM, DBG_LVL_ALL, "%s:%d WRM failed\n", __FUNCTION__, __LINE__); + BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; } } @@ -972,7 +972,7 @@ int ddr_init(struct bcm_mini_adapter *Adapter) } retval = wrmalt(Adapter, psDDRSetting->ulRegAddress, &value, sizeof(value)); if(STATUS_SUCCESS != retval) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"%s:%d\n", __FUNCTION__, __LINE__); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "%s:%d\n", __func__, __LINE__); break; } @@ -992,25 +992,25 @@ int ddr_init(struct bcm_mini_adapter *Adapter) uiResetValue = 0x01010001; retval = wrmalt(Adapter, (UINT)0x0F007018, &uiResetValue, sizeof(uiResetValue)); if(retval < 0) { - BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); + BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; } uiResetValue = 0x00040020; retval = wrmalt(Adapter, (UINT)0x0F007094, &uiResetValue, sizeof(uiResetValue)); if(retval < 0) { - BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); + BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; } uiResetValue = 0x01020101; retval = wrmalt(Adapter, (UINT)0x0F00701c, &uiResetValue, sizeof(uiResetValue)); if(retval < 0) { - BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); + BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; } uiResetValue = 0x01010000; retval = wrmalt(Adapter, (UINT)0x0F007018, &uiResetValue, sizeof(uiResetValue)); if(retval < 0) { - BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); + BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; } } @@ -1026,34 +1026,34 @@ int ddr_init(struct bcm_mini_adapter *Adapter) { retval = rdmalt(Adapter,(UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); if(retval < 0) { - BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); + BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; } retval = rdmalt(Adapter,(UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); if(retval < 0) { - BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); + BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; } uiResetValue = 0x1322a8; retval = wrmalt(Adapter, (UINT)0x0f000d1c, &uiResetValue, sizeof(uiResetValue)); if(retval < 0) { - BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); + BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; } retval = rdmalt(Adapter,(UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); if(retval < 0) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; } retval = rdmalt(Adapter,(UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); if(retval < 0) { - BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); + BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; } uiResetValue = 0x132296; retval = wrmalt(Adapter, (UINT)0x0f000d14, &uiResetValue, sizeof(uiResetValue)); if(retval < 0) { - BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); + BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; } } @@ -1062,34 +1062,34 @@ int ddr_init(struct bcm_mini_adapter *Adapter) retval = rdmalt(Adapter,(UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); if(retval < 0) { - BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); + BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; } retval = rdmalt(Adapter,(UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); if(retval < 0) { - BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); + BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; } uiResetValue = 0x6003229a; retval = wrmalt(Adapter, (UINT)0x0f000d14, &uiResetValue, sizeof(uiResetValue)); if(retval < 0) { - BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); + BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; } retval = rdmalt(Adapter,(UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); if(retval < 0) { - BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); + BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; } retval = rdmalt(Adapter,(UINT)0x0f000c00, &uiResetValue, sizeof(uiResetValue)); if(retval < 0) { - BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); + BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; } uiResetValue = 0x1322a8; retval = wrmalt(Adapter, (UINT)0x0f000d1c, &uiResetValue, sizeof(uiResetValue)); if(retval < 0) { - BCM_DEBUG_PRINT(Adapter,CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __FUNCTION__, __LINE__); + BCM_DEBUG_PRINT(Adapter, CMHOST, RDM, DBG_LVL_ALL, "%s:%d RDM failed\n", __func__, __LINE__); return retval; } } @@ -1235,28 +1235,28 @@ int download_ddr_settings(struct bcm_mini_adapter *Adapter) retval = wrmalt(Adapter, ul_ddr_setting_load_addr, &value, sizeof(value)); if(retval) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"%s:%d\n", __FUNCTION__, __LINE__); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "%s:%d\n", __func__, __LINE__); return retval; } - ul_ddr_setting_load_addr+=sizeof(ULONG); + ul_ddr_setting_load_addr += sizeof(ULONG); /*signature */ value =(0x1d1e0dd0); retval = wrmalt(Adapter, ul_ddr_setting_load_addr, &value, sizeof(value)); if(retval) { - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"%s:%d\n", __FUNCTION__, __LINE__); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "%s:%d\n", __func__, __LINE__); return retval; } - ul_ddr_setting_load_addr+=sizeof(ULONG); + ul_ddr_setting_load_addr += sizeof(ULONG); RegCount*=(sizeof(struct bcm_ddr_setting)/sizeof(ULONG)); while(RegCount && !retval) { value = psDDRSetting->ulRegAddress ; retval = wrmalt( Adapter, ul_ddr_setting_load_addr, &value, sizeof(value)); - ul_ddr_setting_load_addr+=sizeof(ULONG); + ul_ddr_setting_load_addr += sizeof(ULONG); if(!retval) { if(bOverrideSelfRefresh && (psDDRSetting->ulRegAddress == 0x0F007018)) @@ -1264,7 +1264,7 @@ int download_ddr_settings(struct bcm_mini_adapter *Adapter) value = (psDDRSetting->ulRegValue |(1<<8)); if(STATUS_SUCCESS != wrmalt(Adapter, ul_ddr_setting_load_addr, &value, sizeof(value))){ - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"%s:%d\n", __FUNCTION__, __LINE__); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "%s:%d\n", __func__, __LINE__); break; } } @@ -1274,12 +1274,12 @@ int download_ddr_settings(struct bcm_mini_adapter *Adapter) if(STATUS_SUCCESS != wrmalt(Adapter, ul_ddr_setting_load_addr , &value, sizeof(value))){ - BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"%s:%d\n", __FUNCTION__, __LINE__); + BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "%s:%d\n", __func__, __LINE__); break; } } } - ul_ddr_setting_load_addr+=sizeof(ULONG); + ul_ddr_setting_load_addr += sizeof(ULONG); RegCount--; psDDRSetting++; } -- GitLab From 4ab799df6d71694ce091780af31484d6a63c2939 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Fri, 30 Aug 2013 18:45:11 +0200 Subject: [PATCH 930/942] staging: dwc2: remove specific fifo size constants A generic set of FIFOSIZE_* constants is defined which applies to all fifo size and offset registers. It is already used for both the GNPTXFSIZ and HPTXFSIZ registers, but it applies to DPTXFSIZN as well. Some of these also had specific constants defined. This patch removes the specific constants and documents to use the generic constants. Note that the removed constants weren't actually used. Instead, most of the related code uses hardcoded masks and shifts. But given that subsequent patches will be moving that code around and introducing the constants in the process, this patch leaves those untouched. Also note that the GRXFSIZ register also contains a fifo size, but there is no corresponding start address register (it is always the first fifo in memory), the layout of the GRXFSIZ register is different and cannot use the same constants. Signed-off-by: Matthijs Kooijman Acked-by: Paul Zimmerman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dwc2/hw.h | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/drivers/staging/dwc2/hw.h b/drivers/staging/dwc2/hw.h index cf0dc97d5520e..0777d8a23e51e 100644 --- a/drivers/staging/dwc2/hw.h +++ b/drivers/staging/dwc2/hw.h @@ -190,14 +190,7 @@ #define GRXFSIZ HSOTG_REG(0x024) #define GNPTXFSIZ HSOTG_REG(0x028) -#define GNPTXFSIZ_NP_TXF_DEP_MASK (0xffff << 16) -#define GNPTXFSIZ_NP_TXF_DEP_SHIFT 16 -#define GNPTXFSIZ_NP_TXF_DEP_LIMIT 0xffff -#define GNPTXFSIZ_NP_TXF_DEP(_x) ((_x) << 16) -#define GNPTXFSIZ_NP_TXF_ST_ADDR_MASK (0xffff << 0) -#define GNPTXFSIZ_NP_TXF_ST_ADDR_SHIFT 0 -#define GNPTXFSIZ_NP_TXF_ST_ADDR_LIMIT 0xffff -#define GNPTXFSIZ_NP_TXF_ST_ADDR(_x) ((_x) << 0) +/* Use FIFOSIZE_* constants to access this register */ #define GNPTXSTS HSOTG_REG(0x02C) #define GNPTXSTS_NP_TXQ_TOP_MASK (0x7f << 24) @@ -395,16 +388,12 @@ #define ADPCTL_PRB_DSCHRG_SHIFT 0 #define HPTXFSIZ HSOTG_REG(0x100) +/* Use FIFOSIZE_* constants to access this register */ #define DPTXFSIZN(_a) HSOTG_REG(0x104 + (((_a) - 1) * 4)) -#define DPTXFSIZN_DP_TXF_SIZE_MASK (0xffff << 16) -#define DPTXFSIZN_DP_TXF_SIZE_SHIFT 16 -#define DPTXFSIZN_DP_TXF_SIZE_GET(_v) (((_v) >> 16) & 0xffff) -#define DPTXFSIZN_DP_TXF_SIZE_LIMIT 0xffff -#define DPTXFSIZN_DP_TXF_SIZE(_x) ((_x) << 16) -#define DPTXFSIZN_DP_TXF_ST_ADDR_MASK (0xffff << 0) -#define DPTXFSIZN_DP_TXF_ST_ADDR_SHIFT 0 +/* Use FIFOSIZE_* constants to access this register */ +/* These apply to the GNPTXFSIZ, HPTXFSIZ and DPTXFSIZN registers */ #define FIFOSIZE_DEPTH_MASK (0xffff << 16) #define FIFOSIZE_DEPTH_SHIFT 16 #define FIFOSIZE_STARTADDR_MASK (0xffff << 0) -- GitLab From 3b9edf88472e9259f9361aa485a1f399e54c4c77 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Fri, 30 Aug 2013 18:45:12 +0200 Subject: [PATCH 931/942] staging: dwc2: fix off-by-one in check for max_packet_count parameter Previously, the max_packet_count could be set to 1 << x, where x is the number of bits available (width + 4 in the code). Since 1 << x requires x + 1 bits to represent, this will not work. The real maximum value is (1 << x) - 1. This value is already used the default when the set value is invalid, but the upper limit for the set value was off-by-one. This change makes the check the same as the one for max_transfer_size, which was already correct. Signed-off-by: Matthijs Kooijman Acked-by: Paul Zimmerman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dwc2/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/dwc2/core.c b/drivers/staging/dwc2/core.c index a090f79bb5f53..5f09f47bdf730 100644 --- a/drivers/staging/dwc2/core.c +++ b/drivers/staging/dwc2/core.c @@ -2209,7 +2209,7 @@ int dwc2_set_param_max_packet_count(struct dwc2_hsotg *hsotg, int val) GHWCFG3_PACKET_SIZE_CNTR_WIDTH_MASK >> GHWCFG3_PACKET_SIZE_CNTR_WIDTH_SHIFT; - if (val < 15 || val > (1 << (width + 4))) + if (val < 15 || val >= (1 << (width + 4))) valid = 0; if (!valid) { -- GitLab From f92346333538558a186890053d4e8212807726af Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Fri, 30 Aug 2013 18:45:13 +0200 Subject: [PATCH 932/942] staging: dwc2: unshift non-bool register value constants Various register fields wider than one bit have constants defined for their value. Previously, these registers would define the values as they appear in the register, so shifted to the right to the position the value appears in the register. This commit changes those constants to their natural values (e.g, 0, 1, 2, etc.), as they are after shifting the register value to the right. This also changes all relevant code to shift the values before comparing them with constants. This has the advantage that the values can be stored in smaller variables (now they always require a u32) and makes the handling of these values more consistent with other register fields that represent natural numbers instead of enumerations (e.g., number of host channels). Signed-off-by: Matthijs Kooijman Acked-by: Paul Zimmerman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dwc2/core.c | 53 ++++++++----- drivers/staging/dwc2/hcd.c | 2 +- drivers/staging/dwc2/hcd.h | 18 ++--- drivers/staging/dwc2/hcd_intr.c | 19 ++--- drivers/staging/dwc2/hcd_queue.c | 2 +- drivers/staging/dwc2/hw.h | 128 +++++++++++++++---------------- 6 files changed, 118 insertions(+), 104 deletions(-) diff --git a/drivers/staging/dwc2/core.c b/drivers/staging/dwc2/core.c index 5f09f47bdf730..9eabebbc16b8d 100644 --- a/drivers/staging/dwc2/core.c +++ b/drivers/staging/dwc2/core.c @@ -90,8 +90,10 @@ static void dwc2_enable_common_interrupts(struct dwc2_hsotg *hsotg) */ static void dwc2_init_fs_ls_pclk_sel(struct dwc2_hsotg *hsotg) { - u32 hs_phy_type = hsotg->hwcfg2 & GHWCFG2_HS_PHY_TYPE_MASK; - u32 fs_phy_type = hsotg->hwcfg2 & GHWCFG2_FS_PHY_TYPE_MASK; + u32 hs_phy_type = (hsotg->hwcfg2 & GHWCFG2_HS_PHY_TYPE_MASK) >> + GHWCFG2_HS_PHY_TYPE_SHIFT; + u32 fs_phy_type = (hsotg->hwcfg2 & GHWCFG2_FS_PHY_TYPE_MASK) >> + GHWCFG2_FS_PHY_TYPE_SHIFT; u32 hcfg, val; if ((hs_phy_type == GHWCFG2_HS_PHY_TYPE_ULPI && @@ -108,7 +110,7 @@ static void dwc2_init_fs_ls_pclk_sel(struct dwc2_hsotg *hsotg) dev_dbg(hsotg->dev, "Initializing HCFG.FSLSPClkSel to %08x\n", val); hcfg = readl(hsotg->regs + HCFG); hcfg &= ~HCFG_FSLSPCLKSEL_MASK; - hcfg |= val; + hcfg |= val << HCFG_FSLSPCLKSEL_SHIFT; writel(hcfg, hsotg->regs + HCFG); } @@ -256,8 +258,10 @@ static void dwc2_phy_init(struct dwc2_hsotg *hsotg, bool select_phy) dwc2_hs_phy_init(hsotg, select_phy); } - hs_phy_type = hsotg->hwcfg2 & GHWCFG2_HS_PHY_TYPE_MASK; - fs_phy_type = hsotg->hwcfg2 & GHWCFG2_FS_PHY_TYPE_MASK; + hs_phy_type = (hsotg->hwcfg2 & GHWCFG2_HS_PHY_TYPE_MASK) >> + GHWCFG2_HS_PHY_TYPE_SHIFT; + fs_phy_type = (hsotg->hwcfg2 & GHWCFG2_FS_PHY_TYPE_MASK) >> + GHWCFG2_FS_PHY_TYPE_SHIFT; if (hs_phy_type == GHWCFG2_HS_PHY_TYPE_ULPI && fs_phy_type == GHWCFG2_FS_PHY_TYPE_DEDICATED && @@ -279,7 +283,8 @@ static int dwc2_gahbcfg_init(struct dwc2_hsotg *hsotg) { u32 ahbcfg = readl(hsotg->regs + GAHBCFG); - switch (hsotg->hwcfg2 & GHWCFG2_ARCHITECTURE_MASK) { + switch ((hsotg->hwcfg2 & GHWCFG2_ARCHITECTURE_MASK) >> + GHWCFG2_ARCHITECTURE_SHIFT) { case GHWCFG2_EXT_DMA_ARCH: dev_err(hsotg->dev, "External DMA Mode not supported\n"); return -EINVAL; @@ -328,7 +333,8 @@ static void dwc2_gusbcfg_init(struct dwc2_hsotg *hsotg) usbcfg = readl(hsotg->regs + GUSBCFG); usbcfg &= ~(GUSBCFG_HNPCAP | GUSBCFG_SRPCAP); - switch (hsotg->hwcfg2 & GHWCFG2_OP_MODE_MASK) { + switch ((hsotg->hwcfg2 & GHWCFG2_OP_MODE_MASK) >> + GHWCFG2_OP_MODE_SHIFT) { case GHWCFG2_OP_MODE_HNP_SRP_CAPABLE: if (hsotg->core_params->otg_cap == DWC2_CAP_PARAM_HNP_SRP_CAPABLE) @@ -599,7 +605,8 @@ void dwc2_core_host_init(struct dwc2_hsotg *hsotg) } if (hsotg->core_params->dma_desc_enable > 0) { - u32 op_mode = hsotg->hwcfg2 & GHWCFG2_OP_MODE_MASK; + u32 op_mode = (hsotg->hwcfg2 & GHWCFG2_OP_MODE_MASK) >> + GHWCFG2_OP_MODE_SHIFT; if (hsotg->snpsid < DWC2_CORE_REV_2_90a || !(hsotg->hwcfg4 & GHWCFG4_DESC_DMA) || @@ -1666,7 +1673,8 @@ u32 dwc2_calc_frame_interval(struct dwc2_hsotg *hsotg) if (!(usbcfg & GUSBCFG_PHYSEL) && (usbcfg & GUSBCFG_ULPI_UTMI_SEL) && !(usbcfg & GUSBCFG_PHYIF16)) clock = 60; - if ((usbcfg & GUSBCFG_PHYSEL) && (hwcfg2 & GHWCFG2_FS_PHY_TYPE_MASK) == + if ((usbcfg & GUSBCFG_PHYSEL) && + (hwcfg2 & GHWCFG2_FS_PHY_TYPE_MASK) >> GHWCFG2_FS_PHY_TYPE_SHIFT == GHWCFG2_FS_PHY_TYPE_SHARED_ULPI) clock = 48; if (!(usbcfg & GUSBCFG_PHY_LP_CLK_SEL) && !(usbcfg & GUSBCFG_PHYSEL) && @@ -1679,14 +1687,15 @@ u32 dwc2_calc_frame_interval(struct dwc2_hsotg *hsotg) !(usbcfg & GUSBCFG_ULPI_UTMI_SEL) && (usbcfg & GUSBCFG_PHYIF16)) clock = 48; if ((usbcfg & GUSBCFG_PHYSEL) && !(usbcfg & GUSBCFG_PHYIF16) && - (hwcfg2 & GHWCFG2_FS_PHY_TYPE_MASK) == + (hwcfg2 & GHWCFG2_FS_PHY_TYPE_MASK) >> GHWCFG2_FS_PHY_TYPE_SHIFT == GHWCFG2_FS_PHY_TYPE_SHARED_UTMI) clock = 48; - if ((usbcfg & GUSBCFG_PHYSEL) && (hwcfg2 & GHWCFG2_FS_PHY_TYPE_MASK) == + if ((usbcfg & GUSBCFG_PHYSEL) && + (hwcfg2 & GHWCFG2_FS_PHY_TYPE_MASK) >> GHWCFG2_FS_PHY_TYPE_SHIFT == GHWCFG2_FS_PHY_TYPE_DEDICATED) clock = 48; - if ((hprt0 & HPRT0_SPD_MASK) == HPRT0_SPD_HIGH_SPEED) + if ((hprt0 & HPRT0_SPD_MASK) >> HPRT0_SPD_SHIFT == HPRT0_SPD_HIGH_SPEED) /* High speed case */ return 125 * clock; else @@ -1957,7 +1966,8 @@ int dwc2_set_param_otg_cap(struct dwc2_hsotg *hsotg, int val) int retval = 0; u32 op_mode; - op_mode = hsotg->hwcfg2 & GHWCFG2_OP_MODE_MASK; + op_mode = (hsotg->hwcfg2 & GHWCFG2_OP_MODE_MASK) >> + GHWCFG2_OP_MODE_SHIFT; switch (val) { case DWC2_CAP_PARAM_HNP_SRP_CAPABLE: @@ -2015,8 +2025,8 @@ int dwc2_set_param_dma_enable(struct dwc2_hsotg *hsotg, int val) int valid = 1; int retval = 0; - if (val > 0 && (hsotg->hwcfg2 & GHWCFG2_ARCHITECTURE_MASK) == - GHWCFG2_SLAVE_ONLY_ARCH) + if (val > 0 && (hsotg->hwcfg2 & GHWCFG2_ARCHITECTURE_MASK) >> + GHWCFG2_ARCHITECTURE_SHIFT == GHWCFG2_SLAVE_ONLY_ARCH) valid = 0; if (val < 0) valid = 0; @@ -2026,8 +2036,8 @@ int dwc2_set_param_dma_enable(struct dwc2_hsotg *hsotg, int val) dev_err(hsotg->dev, "%d invalid for dma_enable parameter. Check HW configuration.\n", val); - val = (hsotg->hwcfg2 & GHWCFG2_ARCHITECTURE_MASK) != - GHWCFG2_SLAVE_ONLY_ARCH; + val = (hsotg->hwcfg2 & GHWCFG2_ARCHITECTURE_MASK) >> + GHWCFG2_ARCHITECTURE_SHIFT != GHWCFG2_SLAVE_ONLY_ARCH; dev_dbg(hsotg->dev, "Setting dma_enable to %d\n", val); retval = -EINVAL; } @@ -2276,8 +2286,10 @@ int dwc2_set_param_phy_type(struct dwc2_hsotg *hsotg, int val) } #ifndef NO_FS_PHY_HW_CHECKS - hs_phy_type = hsotg->hwcfg2 & GHWCFG2_HS_PHY_TYPE_MASK; - fs_phy_type = hsotg->hwcfg2 & GHWCFG2_FS_PHY_TYPE_MASK; + hs_phy_type = (hsotg->hwcfg2 & GHWCFG2_HS_PHY_TYPE_MASK) >> + GHWCFG2_HS_PHY_TYPE_SHIFT; + fs_phy_type = (hsotg->hwcfg2 & GHWCFG2_FS_PHY_TYPE_MASK) >> + GHWCFG2_FS_PHY_TYPE_SHIFT; if (val == DWC2_PHY_TYPE_PARAM_UTMI && (hs_phy_type == GHWCFG2_HS_PHY_TYPE_UTMI || @@ -2588,7 +2600,8 @@ int dwc2_set_param_ahbcfg(struct dwc2_hsotg *hsotg, int val) if (val != -1) hsotg->core_params->ahbcfg = val; else - hsotg->core_params->ahbcfg = GAHBCFG_HBSTLEN_INCR4; + hsotg->core_params->ahbcfg = GAHBCFG_HBSTLEN_INCR4 << + GAHBCFG_HBSTLEN_SHIFT; return 0; } diff --git a/drivers/staging/dwc2/hcd.c b/drivers/staging/dwc2/hcd.c index 32b52ad5f74fa..4e8fec0640e80 100644 --- a/drivers/staging/dwc2/hcd.c +++ b/drivers/staging/dwc2/hcd.c @@ -1612,7 +1612,7 @@ static int dwc2_hcd_hub_control(struct dwc2_hsotg *hsotg, u16 typereq, if (hprt0 & HPRT0_PWR) port_status |= USB_PORT_STAT_POWER; - speed = hprt0 & HPRT0_SPD_MASK; + speed = (hprt0 & HPRT0_SPD_MASK) >> HPRT0_SPD_SHIFT; if (speed == HPRT0_SPD_HIGH_SPEED) port_status |= USB_PORT_STAT_HIGH_SPEED; else if (speed == HPRT0_SPD_LOW_SPEED) diff --git a/drivers/staging/dwc2/hcd.h b/drivers/staging/dwc2/hcd.h index 3b060247c7fc8..65c782e90e93c 100644 --- a/drivers/staging/dwc2/hcd.h +++ b/drivers/staging/dwc2/hcd.h @@ -122,11 +122,11 @@ struct dwc2_host_chan { unsigned ep_type:2; unsigned max_packet:11; unsigned data_pid_start:2; -#define DWC2_HC_PID_DATA0 (TSIZ_SC_MC_PID_DATA0 >> TSIZ_SC_MC_PID_SHIFT) -#define DWC2_HC_PID_DATA2 (TSIZ_SC_MC_PID_DATA2 >> TSIZ_SC_MC_PID_SHIFT) -#define DWC2_HC_PID_DATA1 (TSIZ_SC_MC_PID_DATA1 >> TSIZ_SC_MC_PID_SHIFT) -#define DWC2_HC_PID_MDATA (TSIZ_SC_MC_PID_MDATA >> TSIZ_SC_MC_PID_SHIFT) -#define DWC2_HC_PID_SETUP (TSIZ_SC_MC_PID_SETUP >> TSIZ_SC_MC_PID_SHIFT) +#define DWC2_HC_PID_DATA0 TSIZ_SC_MC_PID_DATA0 +#define DWC2_HC_PID_DATA2 TSIZ_SC_MC_PID_DATA2 +#define DWC2_HC_PID_DATA1 TSIZ_SC_MC_PID_DATA1 +#define DWC2_HC_PID_MDATA TSIZ_SC_MC_PID_MDATA +#define DWC2_HC_PID_SETUP TSIZ_SC_MC_PID_SETUP unsigned multi_count:2; @@ -146,10 +146,10 @@ struct dwc2_host_chan { u8 hub_addr; u8 hub_port; u8 xact_pos; -#define DWC2_HCSPLT_XACTPOS_MID (HCSPLT_XACTPOS_MID >> HCSPLT_XACTPOS_SHIFT) -#define DWC2_HCSPLT_XACTPOS_END (HCSPLT_XACTPOS_END >> HCSPLT_XACTPOS_SHIFT) -#define DWC2_HCSPLT_XACTPOS_BEGIN (HCSPLT_XACTPOS_BEGIN >> HCSPLT_XACTPOS_SHIFT) -#define DWC2_HCSPLT_XACTPOS_ALL (HCSPLT_XACTPOS_ALL >> HCSPLT_XACTPOS_SHIFT) +#define DWC2_HCSPLT_XACTPOS_MID HCSPLT_XACTPOS_MID +#define DWC2_HCSPLT_XACTPOS_END HCSPLT_XACTPOS_END +#define DWC2_HCSPLT_XACTPOS_BEGIN HCSPLT_XACTPOS_BEGIN +#define DWC2_HCSPLT_XACTPOS_ALL HCSPLT_XACTPOS_ALL u8 requests; u8 schinfo; diff --git a/drivers/staging/dwc2/hcd_intr.c b/drivers/staging/dwc2/hcd_intr.c index 9e68ef1d5998b..f53f98e5ec528 100644 --- a/drivers/staging/dwc2/hcd_intr.c +++ b/drivers/staging/dwc2/hcd_intr.c @@ -177,7 +177,7 @@ static void dwc2_rx_fifo_level_intr(struct dwc2_hsotg *hsotg) GRXSTS_BYTECNT_MASK >> GRXSTS_BYTECNT_SHIFT; dpid = grxsts >> GRXSTS_DPID_SHIFT & GRXSTS_DPID_MASK >> GRXSTS_DPID_SHIFT; - pktsts = grxsts & GRXSTS_PKTSTS_MASK; + pktsts = (grxsts & GRXSTS_PKTSTS_MASK) >> GRXSTS_PKTSTS_SHIFT; /* Packet Status */ if (dbg_perio()) { @@ -185,9 +185,7 @@ static void dwc2_rx_fifo_level_intr(struct dwc2_hsotg *hsotg) dev_vdbg(hsotg->dev, " Count = %d\n", bcnt); dev_vdbg(hsotg->dev, " DPID = %d, chan.dpid = %d\n", dpid, chan->data_pid_start); - dev_vdbg(hsotg->dev, " PStatus = %d\n", - pktsts >> GRXSTS_PKTSTS_SHIFT & - GRXSTS_PKTSTS_MASK >> GRXSTS_PKTSTS_SHIFT); + dev_vdbg(hsotg->dev, " PStatus = %d\n", pktsts); } switch (pktsts) { @@ -266,7 +264,7 @@ static void dwc2_hprt0_enable(struct dwc2_hsotg *hsotg, u32 hprt0, } usbcfg = readl(hsotg->regs + GUSBCFG); - prtspd = hprt0 & HPRT0_SPD_MASK; + prtspd = (hprt0 & HPRT0_SPD_MASK) >> HPRT0_SPD_SHIFT; if (prtspd == HPRT0_SPD_LOW_SPEED || prtspd == HPRT0_SPD_FULL_SPEED) { /* Low power */ @@ -278,7 +276,8 @@ static void dwc2_hprt0_enable(struct dwc2_hsotg *hsotg, u32 hprt0, } hcfg = readl(hsotg->regs + HCFG); - fslspclksel = hcfg & HCFG_FSLSPCLKSEL_MASK; + fslspclksel = (hcfg & HCFG_FSLSPCLKSEL_MASK) >> + HCFG_FSLSPCLKSEL_SHIFT; if (prtspd == HPRT0_SPD_LOW_SPEED && params->host_ls_low_power_phy_clk == @@ -287,8 +286,9 @@ static void dwc2_hprt0_enable(struct dwc2_hsotg *hsotg, u32 hprt0, dev_vdbg(hsotg->dev, "FS_PHY programming HCFG to 6 MHz\n"); if (fslspclksel != HCFG_FSLSPCLKSEL_6_MHZ) { + fslspclksel = HCFG_FSLSPCLKSEL_6_MHZ; hcfg &= ~HCFG_FSLSPCLKSEL_MASK; - hcfg |= HCFG_FSLSPCLKSEL_6_MHZ; + hcfg |= fslspclksel << HCFG_FSLSPCLKSEL_SHIFT; writel(hcfg, hsotg->regs + HCFG); do_reset = 1; } @@ -297,8 +297,9 @@ static void dwc2_hprt0_enable(struct dwc2_hsotg *hsotg, u32 hprt0, dev_vdbg(hsotg->dev, "FS_PHY programming HCFG to 48 MHz\n"); if (fslspclksel != HCFG_FSLSPCLKSEL_48_MHZ) { + fslspclksel = HCFG_FSLSPCLKSEL_48_MHZ; hcfg &= ~HCFG_FSLSPCLKSEL_MASK; - hcfg |= HCFG_FSLSPCLKSEL_48_MHZ; + hcfg |= fslspclksel << HCFG_FSLSPCLKSEL_SHIFT; writel(hcfg, hsotg->regs + HCFG); do_reset = 1; } @@ -515,7 +516,7 @@ void dwc2_hcd_save_data_toggle(struct dwc2_hsotg *hsotg, struct dwc2_qtd *qtd) { u32 hctsiz = readl(hsotg->regs + HCTSIZ(chnum)); - u32 pid = hctsiz & TSIZ_SC_MC_PID_MASK; + u32 pid = (hctsiz & TSIZ_SC_MC_PID_MASK) >> TSIZ_SC_MC_PID_SHIFT; if (chan->ep_type != USB_ENDPOINT_XFER_CONTROL) { if (pid == TSIZ_SC_MC_PID_DATA0) diff --git a/drivers/staging/dwc2/hcd_queue.c b/drivers/staging/dwc2/hcd_queue.c index 5461e3b86ae94..b1980ef28fa30 100644 --- a/drivers/staging/dwc2/hcd_queue.c +++ b/drivers/staging/dwc2/hcd_queue.c @@ -116,7 +116,7 @@ static void dwc2_qh_init(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh, qh->interval = 8; #endif hprt = readl(hsotg->regs + HPRT0); - prtspd = hprt & HPRT0_SPD_MASK; + prtspd = (hprt & HPRT0_SPD_MASK) >> HPRT0_SPD_SHIFT; if (prtspd == HPRT0_SPD_HIGH_SPEED && (dev_speed == USB_SPEED_LOW || dev_speed == USB_SPEED_FULL)) { diff --git a/drivers/staging/dwc2/hw.h b/drivers/staging/dwc2/hw.h index 0777d8a23e51e..321d071be1e26 100644 --- a/drivers/staging/dwc2/hw.h +++ b/drivers/staging/dwc2/hw.h @@ -72,11 +72,11 @@ #define GAHBCFG_DMA_EN (1 << 5) #define GAHBCFG_HBSTLEN_MASK (0xf << 1) #define GAHBCFG_HBSTLEN_SHIFT 1 -#define GAHBCFG_HBSTLEN_SINGLE (0 << 1) -#define GAHBCFG_HBSTLEN_INCR (1 << 1) -#define GAHBCFG_HBSTLEN_INCR4 (3 << 1) -#define GAHBCFG_HBSTLEN_INCR8 (5 << 1) -#define GAHBCFG_HBSTLEN_INCR16 (7 << 1) +#define GAHBCFG_HBSTLEN_SINGLE 0 +#define GAHBCFG_HBSTLEN_INCR 1 +#define GAHBCFG_HBSTLEN_INCR4 3 +#define GAHBCFG_HBSTLEN_INCR8 5 +#define GAHBCFG_HBSTLEN_INCR16 7 #define GAHBCFG_GLBL_INTR_EN (1 << 0) #define GAHBCFG_CTRL_MASK (GAHBCFG_P_TXF_EMP_LVL | \ GAHBCFG_NP_TXF_EMP_LVL | \ @@ -169,15 +169,15 @@ #define GRXSTS_FN_SHIFT 25 #define GRXSTS_PKTSTS_MASK (0xf << 17) #define GRXSTS_PKTSTS_SHIFT 17 -#define GRXSTS_PKTSTS_GLOBALOUTNAK (1 << 17) -#define GRXSTS_PKTSTS_OUTRX (2 << 17) -#define GRXSTS_PKTSTS_HCHIN (2 << 17) -#define GRXSTS_PKTSTS_OUTDONE (3 << 17) -#define GRXSTS_PKTSTS_HCHIN_XFER_COMP (3 << 17) -#define GRXSTS_PKTSTS_SETUPDONE (4 << 17) -#define GRXSTS_PKTSTS_DATATOGGLEERR (5 << 17) -#define GRXSTS_PKTSTS_SETUPRX (6 << 17) -#define GRXSTS_PKTSTS_HCHHALTED (7 << 17) +#define GRXSTS_PKTSTS_GLOBALOUTNAK 1 +#define GRXSTS_PKTSTS_OUTRX 2 +#define GRXSTS_PKTSTS_HCHIN 2 +#define GRXSTS_PKTSTS_OUTDONE 3 +#define GRXSTS_PKTSTS_HCHIN_XFER_COMP 3 +#define GRXSTS_PKTSTS_SETUPDONE 4 +#define GRXSTS_PKTSTS_DATATOGGLEERR 5 +#define GRXSTS_PKTSTS_SETUPRX 6 +#define GRXSTS_PKTSTS_HCHHALTED 7 #define GRXSTS_HCHNUM_MASK (0xf << 0) #define GRXSTS_HCHNUM_SHIFT 0 #define GRXSTS_DPID_MASK (0x3 << 15) @@ -241,32 +241,32 @@ #define GHWCFG2_NUM_DEV_EP_SHIFT 10 #define GHWCFG2_FS_PHY_TYPE_MASK (0x3 << 8) #define GHWCFG2_FS_PHY_TYPE_SHIFT 8 -#define GHWCFG2_FS_PHY_TYPE_NOT_SUPPORTED (0 << 8) -#define GHWCFG2_FS_PHY_TYPE_DEDICATED (1 << 8) -#define GHWCFG2_FS_PHY_TYPE_SHARED_UTMI (2 << 8) -#define GHWCFG2_FS_PHY_TYPE_SHARED_ULPI (3 << 8) +#define GHWCFG2_FS_PHY_TYPE_NOT_SUPPORTED 0 +#define GHWCFG2_FS_PHY_TYPE_DEDICATED 1 +#define GHWCFG2_FS_PHY_TYPE_SHARED_UTMI 2 +#define GHWCFG2_FS_PHY_TYPE_SHARED_ULPI 3 #define GHWCFG2_HS_PHY_TYPE_MASK (0x3 << 6) #define GHWCFG2_HS_PHY_TYPE_SHIFT 6 -#define GHWCFG2_HS_PHY_TYPE_NOT_SUPPORTED (0 << 6) -#define GHWCFG2_HS_PHY_TYPE_UTMI (1 << 6) -#define GHWCFG2_HS_PHY_TYPE_ULPI (2 << 6) -#define GHWCFG2_HS_PHY_TYPE_UTMI_ULPI (3 << 6) +#define GHWCFG2_HS_PHY_TYPE_NOT_SUPPORTED 0 +#define GHWCFG2_HS_PHY_TYPE_UTMI 1 +#define GHWCFG2_HS_PHY_TYPE_ULPI 2 +#define GHWCFG2_HS_PHY_TYPE_UTMI_ULPI 3 #define GHWCFG2_POINT2POINT (1 << 5) #define GHWCFG2_ARCHITECTURE_MASK (0x3 << 3) #define GHWCFG2_ARCHITECTURE_SHIFT 3 -#define GHWCFG2_SLAVE_ONLY_ARCH (0 << 3) -#define GHWCFG2_EXT_DMA_ARCH (1 << 3) -#define GHWCFG2_INT_DMA_ARCH (2 << 3) +#define GHWCFG2_SLAVE_ONLY_ARCH 0 +#define GHWCFG2_EXT_DMA_ARCH 1 +#define GHWCFG2_INT_DMA_ARCH 2 #define GHWCFG2_OP_MODE_MASK (0x7 << 0) #define GHWCFG2_OP_MODE_SHIFT 0 -#define GHWCFG2_OP_MODE_HNP_SRP_CAPABLE (0 << 0) -#define GHWCFG2_OP_MODE_SRP_ONLY_CAPABLE (1 << 0) -#define GHWCFG2_OP_MODE_NO_HNP_SRP_CAPABLE (2 << 0) -#define GHWCFG2_OP_MODE_SRP_CAPABLE_DEVICE (3 << 0) -#define GHWCFG2_OP_MODE_NO_SRP_CAPABLE_DEVICE (4 << 0) -#define GHWCFG2_OP_MODE_SRP_CAPABLE_HOST (5 << 0) -#define GHWCFG2_OP_MODE_NO_SRP_CAPABLE_HOST (6 << 0) -#define GHWCFG2_OP_MODE_UNDEFINED (7 << 0) +#define GHWCFG2_OP_MODE_HNP_SRP_CAPABLE 0 +#define GHWCFG2_OP_MODE_SRP_ONLY_CAPABLE 1 +#define GHWCFG2_OP_MODE_NO_HNP_SRP_CAPABLE 2 +#define GHWCFG2_OP_MODE_SRP_CAPABLE_DEVICE 3 +#define GHWCFG2_OP_MODE_NO_SRP_CAPABLE_DEVICE 4 +#define GHWCFG2_OP_MODE_SRP_CAPABLE_HOST 5 +#define GHWCFG2_OP_MODE_NO_SRP_CAPABLE_HOST 6 +#define GHWCFG2_OP_MODE_UNDEFINED 7 #define GHWCFG3 HSOTG_REG(0x004c) #define GHWCFG3_DFIFO_DEPTH_MASK (0xffff << 16) @@ -417,10 +417,10 @@ #define DCFG_NZ_STS_OUT_HSHK (1 << 2) #define DCFG_DEVSPD_MASK (0x3 << 0) #define DCFG_DEVSPD_SHIFT 0 -#define DCFG_DEVSPD_HS (0 << 0) -#define DCFG_DEVSPD_FS (1 << 0) -#define DCFG_DEVSPD_LS (2 << 0) -#define DCFG_DEVSPD_FS48 (3 << 0) +#define DCFG_DEVSPD_HS 0 +#define DCFG_DEVSPD_FS 1 +#define DCFG_DEVSPD_LS 2 +#define DCFG_DEVSPD_FS48 3 #define DCTL HSOTG_REG(0x804) #define DCTL_PWRONPRGDONE (1 << 11) @@ -443,10 +443,10 @@ #define DSTS_ERRATICERR (1 << 3) #define DSTS_ENUMSPD_MASK (0x3 << 1) #define DSTS_ENUMSPD_SHIFT 1 -#define DSTS_ENUMSPD_HS (0 << 1) -#define DSTS_ENUMSPD_FS (1 << 1) -#define DSTS_ENUMSPD_LS (2 << 1) -#define DSTS_ENUMSPD_FS48 (3 << 1) +#define DSTS_ENUMSPD_HS 0 +#define DSTS_ENUMSPD_FS 1 +#define DSTS_ENUMSPD_LS 2 +#define DSTS_ENUMSPD_FS48 3 #define DSTS_SUSPSTS (1 << 0) #define DIEPMSK HSOTG_REG(0x810) @@ -494,10 +494,10 @@ */ #define D0EPCTL_MPS_MASK (0x3 << 0) #define D0EPCTL_MPS_SHIFT 0 -#define D0EPCTL_MPS_64 (0 << 0) -#define D0EPCTL_MPS_32 (1 << 0) -#define D0EPCTL_MPS_16 (2 << 0) -#define D0EPCTL_MPS_8 (3 << 0) +#define D0EPCTL_MPS_64 0 +#define D0EPCTL_MPS_32 1 +#define D0EPCTL_MPS_16 2 +#define D0EPCTL_MPS_8 3 #define DXEPCTL_EPENA (1 << 31) #define DXEPCTL_EPDIS (1 << 30) @@ -515,10 +515,10 @@ #define DXEPCTL_SNP (1 << 20) #define DXEPCTL_EPTYPE_MASK (0x3 << 18) #define DXEPCTL_EPTYPE_SHIFT 18 -#define DXEPCTL_EPTYPE_CONTROL (0 << 18) -#define DXEPCTL_EPTYPE_ISO (1 << 18) -#define DXEPCTL_EPTYPE_BULK (2 << 18) -#define DXEPCTL_EPTYPE_INTTERUPT (3 << 18) +#define DXEPCTL_EPTYPE_CONTROL 0 +#define DXEPCTL_EPTYPE_ISO 1 +#define DXEPCTL_EPTYPE_BULK 2 +#define DXEPCTL_EPTYPE_INTTERUPT 3 #define DXEPCTL_NAKSTS (1 << 17) #define DXEPCTL_DPID (1 << 16) #define DXEPCTL_EOFRNUM (1 << 16) @@ -638,9 +638,9 @@ #define HCFG_FSLSSUPP (1 << 2) #define HCFG_FSLSPCLKSEL_MASK (0x3 << 0) #define HCFG_FSLSPCLKSEL_SHIFT 0 -#define HCFG_FSLSPCLKSEL_30_60_MHZ (0 << 0) -#define HCFG_FSLSPCLKSEL_48_MHZ (1 << 0) -#define HCFG_FSLSPCLKSEL_6_MHZ (2 << 0) +#define HCFG_FSLSPCLKSEL_30_60_MHZ 0 +#define HCFG_FSLSPCLKSEL_48_MHZ 1 +#define HCFG_FSLSPCLKSEL_6_MHZ 2 #define HFIR HSOTG_REG(0x0404) #define HFIR_FRINT_MASK (0xffff << 0) @@ -673,9 +673,9 @@ #define HPRT0 HSOTG_REG(0x0440) #define HPRT0_SPD_MASK (0x3 << 17) #define HPRT0_SPD_SHIFT 17 -#define HPRT0_SPD_HIGH_SPEED (0 << 17) -#define HPRT0_SPD_FULL_SPEED (1 << 17) -#define HPRT0_SPD_LOW_SPEED (2 << 17) +#define HPRT0_SPD_HIGH_SPEED 0 +#define HPRT0_SPD_FULL_SPEED 1 +#define HPRT0_SPD_LOW_SPEED 2 #define HPRT0_TSTCTL_MASK (0xf << 13) #define HPRT0_TSTCTL_SHIFT 13 #define HPRT0_PWR (1 << 12) @@ -713,10 +713,10 @@ #define HCSPLT_COMPSPLT (1 << 16) #define HCSPLT_XACTPOS_MASK (0x3 << 14) #define HCSPLT_XACTPOS_SHIFT 14 -#define HCSPLT_XACTPOS_MID (0 << 14) -#define HCSPLT_XACTPOS_END (1 << 14) -#define HCSPLT_XACTPOS_BEGIN (2 << 14) -#define HCSPLT_XACTPOS_ALL (3 << 14) +#define HCSPLT_XACTPOS_MID 0 +#define HCSPLT_XACTPOS_END 1 +#define HCSPLT_XACTPOS_BEGIN 2 +#define HCSPLT_XACTPOS_ALL 3 #define HCSPLT_HUBADDR_MASK (0x7f << 7) #define HCSPLT_HUBADDR_SHIFT 7 #define HCSPLT_PRTADDR_MASK (0x7f << 0) @@ -744,11 +744,11 @@ #define TSIZ_DOPNG (1 << 31) #define TSIZ_SC_MC_PID_MASK (0x3 << 29) #define TSIZ_SC_MC_PID_SHIFT 29 -#define TSIZ_SC_MC_PID_DATA0 (0 << 29) -#define TSIZ_SC_MC_PID_DATA2 (1 << 29) -#define TSIZ_SC_MC_PID_DATA1 (2 << 29) -#define TSIZ_SC_MC_PID_MDATA (3 << 29) -#define TSIZ_SC_MC_PID_SETUP (3 << 29) +#define TSIZ_SC_MC_PID_DATA0 0 +#define TSIZ_SC_MC_PID_DATA2 1 +#define TSIZ_SC_MC_PID_DATA1 2 +#define TSIZ_SC_MC_PID_MDATA 3 +#define TSIZ_SC_MC_PID_SETUP 3 #define TSIZ_PKTCNT_MASK (0x3ff << 19) #define TSIZ_PKTCNT_SHIFT 19 #define TSIZ_NTD_MASK (0xff << 8) -- GitLab From 1c58ce133971e7159f51f331717a61632a2a3897 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Fri, 30 Aug 2013 18:45:14 +0200 Subject: [PATCH 933/942] staging: dwc2: only read the snpsid register once This (read-only) register was read twice, storing it for later use the second time. Now it is only read once, storing it right away. Signed-off-by: Matthijs Kooijman Acked-by: Paul Zimmerman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dwc2/hcd.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/dwc2/hcd.c b/drivers/staging/dwc2/hcd.c index 4e8fec0640e80..d488304145618 100644 --- a/drivers/staging/dwc2/hcd.c +++ b/drivers/staging/dwc2/hcd.c @@ -2734,7 +2734,7 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq, { struct usb_hcd *hcd; struct dwc2_host_chan *channel; - u32 snpsid, gusbcfg, hcfg; + u32 gusbcfg, hcfg; int i, num_channels; int retval = -ENOMEM; @@ -2746,10 +2746,11 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq, * 0x45f42xxx or 0x45f43xxx, which corresponds to either "OT2" or "OT3", * as in "OTG version 2.xx" or "OTG version 3.xx". */ - snpsid = readl(hsotg->regs + GSNPSID); - if ((snpsid & 0xfffff000) != 0x4f542000 && - (snpsid & 0xfffff000) != 0x4f543000) { - dev_err(hsotg->dev, "Bad value for GSNPSID: 0x%08x\n", snpsid); + hsotg->snpsid = readl(hsotg->regs + GSNPSID); + if ((hsotg->snpsid & 0xfffff000) != 0x4f542000 && + (hsotg->snpsid & 0xfffff000) != 0x4f543000) { + dev_err(hsotg->dev, "Bad value for GSNPSID: 0x%08x\n", + hsotg->snpsid); retval = -ENODEV; goto error1; } @@ -2880,7 +2881,6 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq, } INIT_WORK(&hsotg->wf_otg, dwc2_conn_id_status_change); - hsotg->snpsid = readl(hsotg->regs + GSNPSID); dev_dbg(hsotg->dev, "Core Release: %1x.%1x%1x%1x\n", hsotg->snpsid >> 12 & 0xf, hsotg->snpsid >> 8 & 0xf, hsotg->snpsid >> 4 & 0xf, hsotg->snpsid & 0xf); -- GitLab From d6ec53e04bf7906a0fffd8f272d89ab4e04c2cd5 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Fri, 30 Aug 2013 18:45:15 +0200 Subject: [PATCH 934/942] staging: dwc2: simplify register shift expressions This commit changes expressions from (val >> shift) & (mask >> shift) to (val & mask) >> shift. Signed-off-by: Matthijs Kooijman Acked-by: Paul Zimmerman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dwc2/core.c | 20 +++++------ drivers/staging/dwc2/hcd.c | 62 +++++++++++++++------------------ drivers/staging/dwc2/hcd_ddma.c | 8 ++--- drivers/staging/dwc2/hcd_intr.c | 22 +++++------- 4 files changed, 50 insertions(+), 62 deletions(-) diff --git a/drivers/staging/dwc2/core.c b/drivers/staging/dwc2/core.c index 9eabebbc16b8d..04c251c82bc85 100644 --- a/drivers/staging/dwc2/core.c +++ b/drivers/staging/dwc2/core.c @@ -1386,14 +1386,14 @@ void dwc2_hc_start_transfer(struct dwc2_hsotg *hsotg, dev_vdbg(hsotg->dev, "%s: Channel %d\n", __func__, chan->hc_num); dev_vdbg(hsotg->dev, " Xfer Size: %d\n", - hctsiz >> TSIZ_XFERSIZE_SHIFT & - TSIZ_XFERSIZE_MASK >> TSIZ_XFERSIZE_SHIFT); + (hctsiz & TSIZ_XFERSIZE_MASK) >> + TSIZ_XFERSIZE_SHIFT); dev_vdbg(hsotg->dev, " Num Pkts: %d\n", - hctsiz >> TSIZ_PKTCNT_SHIFT & - TSIZ_PKTCNT_MASK >> TSIZ_PKTCNT_SHIFT); + (hctsiz & TSIZ_PKTCNT_MASK) >> + TSIZ_PKTCNT_SHIFT); dev_vdbg(hsotg->dev, " Start PID: %d\n", - hctsiz >> TSIZ_SC_MC_PID_SHIFT & - TSIZ_SC_MC_PID_MASK >> TSIZ_SC_MC_PID_SHIFT); + (hctsiz & TSIZ_SC_MC_PID_MASK) >> + TSIZ_SC_MC_PID_SHIFT); } if (hsotg->core_params->dma_enable > 0) { @@ -1437,8 +1437,8 @@ void dwc2_hc_start_transfer(struct dwc2_hsotg *hsotg, if (dbg_hc(chan)) dev_vdbg(hsotg->dev, " Multi Cnt: %d\n", - hcchar >> HCCHAR_MULTICNT_SHIFT & - HCCHAR_MULTICNT_MASK >> HCCHAR_MULTICNT_SHIFT); + (hcchar & HCCHAR_MULTICNT_MASK) >> + HCCHAR_MULTICNT_SHIFT); writel(hcchar, hsotg->regs + HCCHAR(chan->hc_num)); if (dbg_hc(chan)) @@ -1526,8 +1526,8 @@ void dwc2_hc_start_transfer_ddma(struct dwc2_hsotg *hsotg, if (dbg_hc(chan)) dev_vdbg(hsotg->dev, " Multi Cnt: %d\n", - hcchar >> HCCHAR_MULTICNT_SHIFT & - HCCHAR_MULTICNT_MASK >> HCCHAR_MULTICNT_SHIFT); + (hcchar & HCCHAR_MULTICNT_MASK) >> + HCCHAR_MULTICNT_SHIFT); writel(hcchar, hsotg->regs + HCCHAR(chan->hc_num)); if (dbg_hc(chan)) diff --git a/drivers/staging/dwc2/hcd.c b/drivers/staging/dwc2/hcd.c index d488304145618..f11b4f0980064 100644 --- a/drivers/staging/dwc2/hcd.c +++ b/drivers/staging/dwc2/hcd.c @@ -1005,10 +1005,10 @@ static void dwc2_process_periodic_channels(struct dwc2_hsotg *hsotg) dev_vdbg(hsotg->dev, "Queue periodic transactions\n"); tx_status = readl(hsotg->regs + HPTXSTS); - qspcavail = tx_status >> TXSTS_QSPCAVAIL_SHIFT & - TXSTS_QSPCAVAIL_MASK >> TXSTS_QSPCAVAIL_SHIFT; - fspcavail = tx_status >> TXSTS_FSPCAVAIL_SHIFT & - TXSTS_FSPCAVAIL_MASK >> TXSTS_FSPCAVAIL_SHIFT; + qspcavail = (tx_status & TXSTS_QSPCAVAIL_MASK) >> + TXSTS_QSPCAVAIL_SHIFT; + fspcavail = (tx_status & TXSTS_FSPCAVAIL_MASK) >> + TXSTS_FSPCAVAIL_SHIFT; if (dbg_perio()) { dev_vdbg(hsotg->dev, " P Tx Req Queue Space Avail (before queue): %d\n", @@ -1046,8 +1046,8 @@ static void dwc2_process_periodic_channels(struct dwc2_hsotg *hsotg) qh->channel->multi_count > 1) hsotg->queuing_high_bandwidth = 1; - fspcavail = tx_status >> TXSTS_FSPCAVAIL_SHIFT & - TXSTS_FSPCAVAIL_MASK >> TXSTS_FSPCAVAIL_SHIFT; + fspcavail = (tx_status & TXSTS_FSPCAVAIL_MASK) >> + TXSTS_FSPCAVAIL_SHIFT; status = dwc2_queue_transaction(hsotg, qh->channel, fspcavail); if (status < 0) { no_fifo_space = 1; @@ -1078,10 +1078,10 @@ static void dwc2_process_periodic_channels(struct dwc2_hsotg *hsotg) if (hsotg->core_params->dma_enable <= 0) { tx_status = readl(hsotg->regs + HPTXSTS); - qspcavail = tx_status >> TXSTS_QSPCAVAIL_SHIFT & - TXSTS_QSPCAVAIL_MASK >> TXSTS_QSPCAVAIL_SHIFT; - fspcavail = tx_status >> TXSTS_FSPCAVAIL_SHIFT & - TXSTS_FSPCAVAIL_MASK >> TXSTS_FSPCAVAIL_SHIFT; + qspcavail = (tx_status & TXSTS_QSPCAVAIL_MASK) >> + TXSTS_QSPCAVAIL_SHIFT; + fspcavail = (tx_status & TXSTS_FSPCAVAIL_MASK) >> + TXSTS_FSPCAVAIL_SHIFT; if (dbg_perio()) { dev_vdbg(hsotg->dev, " P Tx Req Queue Space Avail (after queue): %d\n", @@ -1143,10 +1143,10 @@ static void dwc2_process_non_periodic_channels(struct dwc2_hsotg *hsotg) dev_vdbg(hsotg->dev, "Queue non-periodic transactions\n"); tx_status = readl(hsotg->regs + GNPTXSTS); - qspcavail = tx_status >> TXSTS_QSPCAVAIL_SHIFT & - TXSTS_QSPCAVAIL_MASK >> TXSTS_QSPCAVAIL_SHIFT; - fspcavail = tx_status >> TXSTS_FSPCAVAIL_SHIFT & - TXSTS_FSPCAVAIL_MASK >> TXSTS_FSPCAVAIL_SHIFT; + qspcavail = (tx_status & TXSTS_QSPCAVAIL_MASK) >> + TXSTS_QSPCAVAIL_SHIFT; + fspcavail = (tx_status & TXSTS_FSPCAVAIL_MASK) >> + TXSTS_FSPCAVAIL_SHIFT; dev_vdbg(hsotg->dev, " NP Tx Req Queue Space Avail (before queue): %d\n", qspcavail); dev_vdbg(hsotg->dev, " NP Tx FIFO Space Avail (before queue): %d\n", @@ -1166,8 +1166,8 @@ static void dwc2_process_non_periodic_channels(struct dwc2_hsotg *hsotg) */ do { tx_status = readl(hsotg->regs + GNPTXSTS); - qspcavail = tx_status >> TXSTS_QSPCAVAIL_SHIFT & - TXSTS_QSPCAVAIL_MASK >> TXSTS_QSPCAVAIL_SHIFT; + qspcavail = (tx_status & TXSTS_QSPCAVAIL_MASK) >> + TXSTS_QSPCAVAIL_SHIFT; if (hsotg->core_params->dma_enable <= 0 && qspcavail == 0) { no_queue_space = 1; break; @@ -1182,8 +1182,8 @@ static void dwc2_process_non_periodic_channels(struct dwc2_hsotg *hsotg) if (qh->tt_buffer_dirty) goto next; - fspcavail = tx_status >> TXSTS_FSPCAVAIL_SHIFT & - TXSTS_FSPCAVAIL_MASK >> TXSTS_FSPCAVAIL_SHIFT; + fspcavail = (tx_status & TXSTS_FSPCAVAIL_MASK) >> + TXSTS_FSPCAVAIL_SHIFT; status = dwc2_queue_transaction(hsotg, qh->channel, fspcavail); if (status > 0) { @@ -1203,10 +1203,10 @@ static void dwc2_process_non_periodic_channels(struct dwc2_hsotg *hsotg) if (hsotg->core_params->dma_enable <= 0) { tx_status = readl(hsotg->regs + GNPTXSTS); - qspcavail = tx_status >> TXSTS_QSPCAVAIL_SHIFT & - TXSTS_QSPCAVAIL_MASK >> TXSTS_QSPCAVAIL_SHIFT; - fspcavail = tx_status >> TXSTS_FSPCAVAIL_SHIFT & - TXSTS_FSPCAVAIL_MASK >> TXSTS_FSPCAVAIL_SHIFT; + qspcavail = (tx_status & TXSTS_QSPCAVAIL_MASK) >> + TXSTS_QSPCAVAIL_SHIFT; + fspcavail = (tx_status & TXSTS_FSPCAVAIL_MASK) >> + TXSTS_FSPCAVAIL_SHIFT; dev_vdbg(hsotg->dev, " NP Tx Req Queue Space Avail (after queue): %d\n", qspcavail); @@ -1761,11 +1761,9 @@ int dwc2_hcd_get_frame_number(struct dwc2_hsotg *hsotg) #ifdef DWC2_DEBUG_SOF dev_vdbg(hsotg->dev, "DWC OTG HCD GET FRAME NUMBER %d\n", - hfnum >> HFNUM_FRNUM_SHIFT & - HFNUM_FRNUM_MASK >> HFNUM_FRNUM_SHIFT); + (hfnum & HFNUM_FRNUM_MASK) >> HFNUM_FRNUM_SHIFT); #endif - return hfnum >> HFNUM_FRNUM_SHIFT & - HFNUM_FRNUM_MASK >> HFNUM_FRNUM_SHIFT; + return (hfnum & HFNUM_FRNUM_MASK) >> HFNUM_FRNUM_SHIFT; } int dwc2_hcd_is_b_host(struct dwc2_hsotg *hsotg) @@ -1916,18 +1914,14 @@ void dwc2_hcd_dump_state(struct dwc2_hsotg *hsotg) dev_dbg(hsotg->dev, " periodic_usecs: %d\n", hsotg->periodic_usecs); np_tx_status = readl(hsotg->regs + GNPTXSTS); dev_dbg(hsotg->dev, " NP Tx Req Queue Space Avail: %d\n", - np_tx_status >> TXSTS_QSPCAVAIL_SHIFT & - TXSTS_QSPCAVAIL_MASK >> TXSTS_QSPCAVAIL_SHIFT); + (np_tx_status & TXSTS_QSPCAVAIL_MASK) >> TXSTS_QSPCAVAIL_SHIFT); dev_dbg(hsotg->dev, " NP Tx FIFO Space Avail: %d\n", - np_tx_status >> TXSTS_FSPCAVAIL_SHIFT & - TXSTS_FSPCAVAIL_MASK >> TXSTS_FSPCAVAIL_SHIFT); + (np_tx_status & TXSTS_FSPCAVAIL_MASK) >> TXSTS_FSPCAVAIL_SHIFT); p_tx_status = readl(hsotg->regs + HPTXSTS); dev_dbg(hsotg->dev, " P Tx Req Queue Space Avail: %d\n", - p_tx_status >> TXSTS_QSPCAVAIL_SHIFT & - TXSTS_QSPCAVAIL_MASK >> TXSTS_QSPCAVAIL_SHIFT); + (p_tx_status & TXSTS_QSPCAVAIL_MASK) >> TXSTS_QSPCAVAIL_SHIFT); dev_dbg(hsotg->dev, " P Tx FIFO Space Avail: %d\n", - p_tx_status >> TXSTS_FSPCAVAIL_SHIFT & - TXSTS_FSPCAVAIL_MASK >> TXSTS_FSPCAVAIL_SHIFT); + (p_tx_status & TXSTS_FSPCAVAIL_MASK) >> TXSTS_FSPCAVAIL_SHIFT); dwc2_hcd_dump_frrem(hsotg); dwc2_dump_global_registers(hsotg); dwc2_dump_host_registers(hsotg); diff --git a/drivers/staging/dwc2/hcd_ddma.c b/drivers/staging/dwc2/hcd_ddma.c index de5af1b9b5d9b..69070f4442a81 100644 --- a/drivers/staging/dwc2/hcd_ddma.c +++ b/drivers/staging/dwc2/hcd_ddma.c @@ -806,8 +806,8 @@ static int dwc2_cmpl_host_isoc_dma_desc(struct dwc2_hsotg *hsotg, frame_desc = &qtd->urb->iso_descs[qtd->isoc_frame_index_last]; dma_desc->buf = (u32)(qtd->urb->dma + frame_desc->offset); if (chan->ep_is_in) - remain = dma_desc->status >> HOST_DMA_ISOC_NBYTES_SHIFT & - HOST_DMA_ISOC_NBYTES_MASK >> HOST_DMA_ISOC_NBYTES_SHIFT; + remain = (dma_desc->status & HOST_DMA_ISOC_NBYTES_MASK) >> + HOST_DMA_ISOC_NBYTES_SHIFT; if ((dma_desc->status & HOST_DMA_STS_MASK) == HOST_DMA_STS_PKTERR) { /* @@ -935,8 +935,8 @@ static int dwc2_update_non_isoc_urb_state_ddma(struct dwc2_hsotg *hsotg, u16 remain = 0; if (chan->ep_is_in) - remain = dma_desc->status >> HOST_DMA_NBYTES_SHIFT & - HOST_DMA_NBYTES_MASK >> HOST_DMA_NBYTES_SHIFT; + remain = (dma_desc->status & HOST_DMA_NBYTES_MASK) >> + HOST_DMA_NBYTES_SHIFT; dev_vdbg(hsotg->dev, "remain=%d dwc2_urb=%p\n", remain, urb); diff --git a/drivers/staging/dwc2/hcd_intr.c b/drivers/staging/dwc2/hcd_intr.c index f53f98e5ec528..f60b836b3d131 100644 --- a/drivers/staging/dwc2/hcd_intr.c +++ b/drivers/staging/dwc2/hcd_intr.c @@ -165,18 +165,15 @@ static void dwc2_rx_fifo_level_intr(struct dwc2_hsotg *hsotg) dev_vdbg(hsotg->dev, "--RxFIFO Level Interrupt--\n"); grxsts = readl(hsotg->regs + GRXSTSP); - chnum = grxsts >> GRXSTS_HCHNUM_SHIFT & - GRXSTS_HCHNUM_MASK >> GRXSTS_HCHNUM_SHIFT; + chnum = (grxsts & GRXSTS_HCHNUM_MASK) >> GRXSTS_HCHNUM_SHIFT; chan = hsotg->hc_ptr_array[chnum]; if (!chan) { dev_err(hsotg->dev, "Unable to get corresponding channel\n"); return; } - bcnt = grxsts >> GRXSTS_BYTECNT_SHIFT & - GRXSTS_BYTECNT_MASK >> GRXSTS_BYTECNT_SHIFT; - dpid = grxsts >> GRXSTS_DPID_SHIFT & - GRXSTS_DPID_MASK >> GRXSTS_DPID_SHIFT; + bcnt = (grxsts & GRXSTS_BYTECNT_MASK) >> GRXSTS_BYTECNT_SHIFT; + dpid = (grxsts & GRXSTS_DPID_MASK) >> GRXSTS_DPID_SHIFT; pktsts = (grxsts & GRXSTS_PKTSTS_MASK) >> GRXSTS_PKTSTS_SHIFT; /* Packet Status */ @@ -412,8 +409,8 @@ static u32 dwc2_get_actual_xfer_length(struct dwc2_hsotg *hsotg, if (halt_status == DWC2_HC_XFER_COMPLETE) { if (chan->ep_is_in) { - count = hctsiz >> TSIZ_XFERSIZE_SHIFT & - TSIZ_XFERSIZE_MASK >> TSIZ_XFERSIZE_SHIFT; + count = (hctsiz & TSIZ_XFERSIZE_MASK) >> + TSIZ_XFERSIZE_SHIFT; length = chan->xfer_len - count; if (short_read != NULL) *short_read = (count != 0); @@ -432,8 +429,7 @@ static u32 dwc2_get_actual_xfer_length(struct dwc2_hsotg *hsotg, * hctsiz.xfersize field because that reflects the number of * bytes transferred via the AHB, not the USB). */ - count = hctsiz >> TSIZ_PKTCNT_SHIFT & - TSIZ_PKTCNT_MASK >> TSIZ_PKTCNT_SHIFT; + count = (hctsiz & TSIZ_PKTCNT_MASK) >> TSIZ_PKTCNT_SHIFT; length = (chan->start_pkt_count - count) * chan->max_packet; } @@ -496,8 +492,7 @@ static int dwc2_update_urb_state(struct dwc2_hsotg *hsotg, __func__, (chan->ep_is_in ? "IN" : "OUT"), chnum); dev_vdbg(hsotg->dev, " chan->xfer_len %d\n", chan->xfer_len); dev_vdbg(hsotg->dev, " hctsiz.xfersize %d\n", - hctsiz >> TSIZ_XFERSIZE_SHIFT & - TSIZ_XFERSIZE_MASK >> TSIZ_XFERSIZE_SHIFT); + (hctsiz & TSIZ_XFERSIZE_MASK) >> TSIZ_XFERSIZE_SHIFT); dev_vdbg(hsotg->dev, " urb->transfer_buffer_length %d\n", urb->length); dev_vdbg(hsotg->dev, " urb->actual_length %d\n", urb->actual_length); dev_vdbg(hsotg->dev, " short_read %d, xfer_done %d\n", short_read, @@ -1182,8 +1177,7 @@ static void dwc2_update_urb_state_abn(struct dwc2_hsotg *hsotg, dev_vdbg(hsotg->dev, " chan->start_pkt_count %d\n", chan->start_pkt_count); dev_vdbg(hsotg->dev, " hctsiz.pktcnt %d\n", - hctsiz >> TSIZ_PKTCNT_SHIFT & - TSIZ_PKTCNT_MASK >> TSIZ_PKTCNT_SHIFT); + (hctsiz & TSIZ_PKTCNT_MASK) >> TSIZ_PKTCNT_SHIFT); dev_vdbg(hsotg->dev, " chan->max_packet %d\n", chan->max_packet); dev_vdbg(hsotg->dev, " bytes_transferred %d\n", xfer_length); -- GitLab From acdb9046b61a63be2e0f760e88272b370d638b35 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Fri, 30 Aug 2013 18:45:16 +0200 Subject: [PATCH 935/942] staging: dwc2: add missing shift This line extracted the available queue space without properly shifting it. Since the code only cared wether it was zero or not, it worked as expected without the shift, but adding shift makes the code cleaner. While we're here, store the result in a helper variable that was already declared to increase readability a bit more. Signed-off-by: Matthijs Kooijman Acked-by: Paul Zimmerman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dwc2/hcd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/dwc2/hcd.c b/drivers/staging/dwc2/hcd.c index f11b4f0980064..9a1e062b72978 100644 --- a/drivers/staging/dwc2/hcd.c +++ b/drivers/staging/dwc2/hcd.c @@ -1020,7 +1020,9 @@ static void dwc2_process_periodic_channels(struct dwc2_hsotg *hsotg) qh_ptr = hsotg->periodic_sched_assigned.next; while (qh_ptr != &hsotg->periodic_sched_assigned) { tx_status = readl(hsotg->regs + HPTXSTS); - if ((tx_status & TXSTS_QSPCAVAIL_MASK) == 0) { + qspcavail = (tx_status & TXSTS_QSPCAVAIL_MASK) >> + TXSTS_QSPCAVAIL_SHIFT; + if (qspcavail == 0) { no_queue_space = 1; break; } -- GitLab From 57bb8aeda06af912f92f10a18a446c1e1e000fc1 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Fri, 30 Aug 2013 18:45:17 +0200 Subject: [PATCH 936/942] staging: dwc2: simplify debug output in dwc_hc_init The value of the hcchar register is built from individual values by shifting and masking. Before, the debug output extracted the individual values out of the complete hcchar register again by doing the reverse. This commit makes the debug output use the original values instead. One debug message got removed, since it would always print a fixed value of zero. Signed-off-by: Matthijs Kooijman Acked-by: Paul Zimmerman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dwc2/core.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/drivers/staging/dwc2/core.c b/drivers/staging/dwc2/core.c index 04c251c82bc85..1f8988671eb76 100644 --- a/drivers/staging/dwc2/core.c +++ b/drivers/staging/dwc2/core.c @@ -887,26 +887,20 @@ void dwc2_hc_init(struct dwc2_hsotg *hsotg, struct dwc2_host_chan *chan) dev_vdbg(hsotg->dev, "set HCCHAR(%d) to %08x\n", hc_num, hcchar); - dev_vdbg(hsotg->dev, "%s: Channel %d\n", __func__, hc_num); + dev_vdbg(hsotg->dev, "%s: Channel %d\n", + __func__, hc_num); dev_vdbg(hsotg->dev, " Dev Addr: %d\n", - hcchar >> HCCHAR_DEVADDR_SHIFT & - HCCHAR_DEVADDR_MASK >> HCCHAR_DEVADDR_SHIFT); + chan->dev_addr); dev_vdbg(hsotg->dev, " Ep Num: %d\n", - hcchar >> HCCHAR_EPNUM_SHIFT & - HCCHAR_EPNUM_MASK >> HCCHAR_EPNUM_SHIFT); + chan->ep_num); dev_vdbg(hsotg->dev, " Is In: %d\n", - !!(hcchar & HCCHAR_EPDIR)); + chan->ep_is_in); dev_vdbg(hsotg->dev, " Is Low Speed: %d\n", - !!(hcchar & HCCHAR_LSPDDEV)); + chan->speed == USB_SPEED_LOW); dev_vdbg(hsotg->dev, " Ep Type: %d\n", - hcchar >> HCCHAR_EPTYPE_SHIFT & - HCCHAR_EPTYPE_MASK >> HCCHAR_EPTYPE_SHIFT); + chan->ep_type); dev_vdbg(hsotg->dev, " Max Pkt: %d\n", - hcchar >> HCCHAR_MPS_SHIFT & - HCCHAR_MPS_MASK >> HCCHAR_MPS_SHIFT); - dev_vdbg(hsotg->dev, " Multi Cnt: %d\n", - hcchar >> HCCHAR_MULTICNT_SHIFT & - HCCHAR_MULTICNT_MASK >> HCCHAR_MULTICNT_SHIFT); + chan->max_packet); } /* Program the HCSPLT register for SPLITs */ @@ -936,8 +930,7 @@ void dwc2_hc_init(struct dwc2_hsotg *hsotg, struct dwc2_host_chan *chan) dev_vdbg(hsotg->dev, " is_in %d\n", chan->ep_is_in); dev_vdbg(hsotg->dev, " Max Pkt %d\n", - hcchar >> HCCHAR_MPS_SHIFT & - HCCHAR_MPS_MASK >> HCCHAR_MPS_SHIFT); + chan->max_packet); dev_vdbg(hsotg->dev, " xferlen %d\n", chan->xfer_len); } -- GitLab From c35205aa051244a5ee8ed1e124b9c7b890d97ad9 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Fri, 30 Aug 2013 18:45:18 +0200 Subject: [PATCH 937/942] staging: dwc2: re-use hptxfsiz variable For some reason, the value of the HPTXFSIZ register was built in the ptxfsiz variable, while there was also a hptxfsiz variable availble. Better just use that and remove the (now unused) ptxfsiz variable. Signed-off-by: Matthijs Kooijman Acked-by: Paul Zimmerman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dwc2/core.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/dwc2/core.c b/drivers/staging/dwc2/core.c index 1f8988671eb76..5799f478980ce 100644 --- a/drivers/staging/dwc2/core.c +++ b/drivers/staging/dwc2/core.c @@ -507,7 +507,7 @@ void dwc2_disable_host_interrupts(struct dwc2_hsotg *hsotg) static void dwc2_config_fifos(struct dwc2_hsotg *hsotg) { struct dwc2_core_params *params = hsotg->core_params; - u32 rxfsiz, nptxfsiz, ptxfsiz, hptxfsiz, dfifocfg; + u32 rxfsiz, nptxfsiz, hptxfsiz, dfifocfg; if (!params->enable_dynamic_fifo) return; @@ -539,12 +539,12 @@ static void dwc2_config_fifos(struct dwc2_hsotg *hsotg) /* Periodic Tx FIFO */ dev_dbg(hsotg->dev, "initial hptxfsiz=%08x\n", readl(hsotg->regs + HPTXFSIZ)); - ptxfsiz = params->host_perio_tx_fifo_size << - FIFOSIZE_DEPTH_SHIFT & FIFOSIZE_DEPTH_MASK; - ptxfsiz |= (params->host_rx_fifo_size + - params->host_nperio_tx_fifo_size) << - FIFOSIZE_STARTADDR_SHIFT & FIFOSIZE_STARTADDR_MASK; - writel(ptxfsiz, hsotg->regs + HPTXFSIZ); + hptxfsiz = params->host_perio_tx_fifo_size << + FIFOSIZE_DEPTH_SHIFT & FIFOSIZE_DEPTH_MASK; + hptxfsiz |= (params->host_rx_fifo_size + + params->host_nperio_tx_fifo_size) << + FIFOSIZE_STARTADDR_SHIFT & FIFOSIZE_STARTADDR_MASK; + writel(hptxfsiz, hsotg->regs + HPTXFSIZ); dev_dbg(hsotg->dev, "new hptxfsiz=%08x\n", readl(hsotg->regs + HPTXFSIZ)); -- GitLab From 08b9f9db707bae6c56c0b0b0232a1338ca58e3ce Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Fri, 30 Aug 2013 18:45:19 +0200 Subject: [PATCH 938/942] staging: dwc2: remove redundant register reads For calculating FIFO offsets, the sizes of preceding fifos need to be known. For filling the GDFIFOCFG register, these fifo sizes were read from hardware registers. However, these values were written to these registers just a few lines before, so we can just use the values written instead. Signed-off-by: Matthijs Kooijman Acked-by: Paul Zimmerman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dwc2/core.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/dwc2/core.c b/drivers/staging/dwc2/core.c index 5799f478980ce..f6494df799c9c 100644 --- a/drivers/staging/dwc2/core.c +++ b/drivers/staging/dwc2/core.c @@ -507,7 +507,7 @@ void dwc2_disable_host_interrupts(struct dwc2_hsotg *hsotg) static void dwc2_config_fifos(struct dwc2_hsotg *hsotg) { struct dwc2_core_params *params = hsotg->core_params; - u32 rxfsiz, nptxfsiz, hptxfsiz, dfifocfg; + u32 nptxfsiz, hptxfsiz, dfifocfg; if (!params->enable_dynamic_fifo) return; @@ -555,11 +555,10 @@ static void dwc2_config_fifos(struct dwc2_hsotg *hsotg) * include RxFIFO, NPTXFIFO and HPTXFIFO */ dfifocfg = readl(hsotg->regs + GDFIFOCFG); - rxfsiz = readl(hsotg->regs + GRXFSIZ) & 0x0000ffff; - nptxfsiz = readl(hsotg->regs + GNPTXFSIZ) >> 16 & 0xffff; - hptxfsiz = readl(hsotg->regs + HPTXFSIZ) >> 16 & 0xffff; dfifocfg &= ~GDFIFOCFG_EPINFOBASE_MASK; - dfifocfg |= (rxfsiz + nptxfsiz + hptxfsiz) << + dfifocfg |= (params->host_rx_fifo_size + + params->host_nperio_tx_fifo_size + + params->host_perio_tx_fifo_size) << GDFIFOCFG_EPINFOBASE_SHIFT & GDFIFOCFG_EPINFOBASE_MASK; writel(dfifocfg, hsotg->regs + GDFIFOCFG); -- GitLab From a1fc524393583a217ddbc71293eb30feef58530d Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Fri, 30 Aug 2013 18:45:20 +0200 Subject: [PATCH 939/942] staging: dwc2: properly mask the GRXFSIZ register Bits 16-31 are reserved, so the old code just reads the whole register to get bits 0-15, assuming the reserved bits would be 0 (which seems true on current hardware, but who knows...). This commit properly masks out the reserved bits when reading and doesn't touch the reserved bits while writing. Signed-off-by: Matthijs Kooijman Acked-by: Paul Zimmerman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dwc2/core.c | 23 ++++++++++++++++------- drivers/staging/dwc2/hw.h | 2 ++ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/drivers/staging/dwc2/core.c b/drivers/staging/dwc2/core.c index f6494df799c9c..2f84c24a84ee8 100644 --- a/drivers/staging/dwc2/core.c +++ b/drivers/staging/dwc2/core.c @@ -402,7 +402,9 @@ int dwc2_core_init(struct dwc2_hsotg *hsotg, bool select_phy, int irq) hsotg->total_fifo_size = hsotg->hwcfg3 >> GHWCFG3_DFIFO_DEPTH_SHIFT & GHWCFG3_DFIFO_DEPTH_MASK >> GHWCFG3_DFIFO_DEPTH_SHIFT; - hsotg->rx_fifo_size = readl(hsotg->regs + GRXFSIZ); + hsotg->rx_fifo_size = (readl(hsotg->regs + GRXFSIZ) & + GRXFSIZ_DEPTH_MASK) >> + GRXFSIZ_DEPTH_SHIFT; hsotg->nperio_tx_fifo_size = readl(hsotg->regs + GNPTXFSIZ) >> 16 & 0xffff; @@ -507,7 +509,7 @@ void dwc2_disable_host_interrupts(struct dwc2_hsotg *hsotg) static void dwc2_config_fifos(struct dwc2_hsotg *hsotg) { struct dwc2_core_params *params = hsotg->core_params; - u32 nptxfsiz, hptxfsiz, dfifocfg; + u32 nptxfsiz, hptxfsiz, dfifocfg, grxfsiz; if (!params->enable_dynamic_fifo) return; @@ -520,9 +522,12 @@ static void dwc2_config_fifos(struct dwc2_hsotg *hsotg) params->host_perio_tx_fifo_size); /* Rx FIFO */ - dev_dbg(hsotg->dev, "initial grxfsiz=%08x\n", - readl(hsotg->regs + GRXFSIZ)); - writel(params->host_rx_fifo_size, hsotg->regs + GRXFSIZ); + grxfsiz = readl(hsotg->regs + GRXFSIZ); + dev_dbg(hsotg->dev, "initial grxfsiz=%08x\n", grxfsiz); + grxfsiz &= ~GRXFSIZ_DEPTH_MASK; + grxfsiz |= params->host_rx_fifo_size << + GRXFSIZ_DEPTH_SHIFT & GRXFSIZ_DEPTH_MASK; + writel(grxfsiz, hsotg->regs + GRXFSIZ); dev_dbg(hsotg->dev, "new grxfsiz=%08x\n", readl(hsotg->regs + GRXFSIZ)); /* Non-periodic Tx FIFO */ @@ -2115,7 +2120,9 @@ int dwc2_set_param_host_rx_fifo_size(struct dwc2_hsotg *hsotg, int val) int valid = 1; int retval = 0; - if (val < 16 || val > readl(hsotg->regs + GRXFSIZ)) + if (val < 16 || val > (readl(hsotg->regs + GRXFSIZ) & + GRXFSIZ_DEPTH_MASK) >> + GRXFSIZ_DEPTH_SHIFT) valid = 0; if (!valid) { @@ -2123,7 +2130,9 @@ int dwc2_set_param_host_rx_fifo_size(struct dwc2_hsotg *hsotg, int val) dev_err(hsotg->dev, "%d invalid for host_rx_fifo_size. Check HW configuration.\n", val); - val = readl(hsotg->regs + GRXFSIZ); + val = (readl(hsotg->regs + GRXFSIZ) & + GRXFSIZ_DEPTH_MASK) >> + GRXFSIZ_DEPTH_SHIFT; dev_dbg(hsotg->dev, "Setting host_rx_fifo_size to %d\n", val); retval = -EINVAL; } diff --git a/drivers/staging/dwc2/hw.h b/drivers/staging/dwc2/hw.h index 321d071be1e26..fafdc199b2b5a 100644 --- a/drivers/staging/dwc2/hw.h +++ b/drivers/staging/dwc2/hw.h @@ -188,6 +188,8 @@ #define GRXSTS_EPNUM_SHIFT 0 #define GRXFSIZ HSOTG_REG(0x024) +#define GRXFSIZ_DEPTH_MASK (0xffff << 0) +#define GRXFSIZ_DEPTH_SHIFT 0 #define GNPTXFSIZ HSOTG_REG(0x028) /* Use FIFOSIZE_* constants to access this register */ -- GitLab From 9badec2f9fa9209ceb3bd427972299d69a37d8ee Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Fri, 30 Aug 2013 18:45:21 +0200 Subject: [PATCH 940/942] staging: dwc2: interpret all hwcfg and related register at init time Before, the hwcfg registers were read at device init time, but interpreted at various parts in the code. This commit unpacks the hwcfg register values into a struct with properly labeled variables at init time, which makes all the other code using these values more consise and easier to read. Some values that were previously stored in the hsotg struct are now moved into this new struct as well. In addition to the hwcfg registers, the contents of some fifo size registers are also unpacked. The hwcfg registers are read-only, so they can be safely stored. The fifo size registers are read-write registers, but their power-on values are significant: they give the maximum depth of the fifo they describe. This commit mostly moves code, but also attempts to simplify some expressions from (val >> shift) & (mask >> shift) to (val & mask) >> shift. Finally, all of the parameters read from the hardware are debug printed after unpacking them, so a bunch of debug prints can be removed from other places. Signed-off-by: Matthijs Kooijman Acked-by: Paul Zimmerman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dwc2/core.c | 307 ++++++++++++++++++++----------- drivers/staging/dwc2/core.h | 96 ++++++++-- drivers/staging/dwc2/core_intr.c | 4 +- drivers/staging/dwc2/hcd.c | 80 +------- drivers/staging/dwc2/hcd.h | 1 + drivers/staging/dwc2/hcd_intr.c | 2 +- 6 files changed, 290 insertions(+), 200 deletions(-) diff --git a/drivers/staging/dwc2/core.c b/drivers/staging/dwc2/core.c index 2f84c24a84ee8..825c5e5f157fb 100644 --- a/drivers/staging/dwc2/core.c +++ b/drivers/staging/dwc2/core.c @@ -90,14 +90,10 @@ static void dwc2_enable_common_interrupts(struct dwc2_hsotg *hsotg) */ static void dwc2_init_fs_ls_pclk_sel(struct dwc2_hsotg *hsotg) { - u32 hs_phy_type = (hsotg->hwcfg2 & GHWCFG2_HS_PHY_TYPE_MASK) >> - GHWCFG2_HS_PHY_TYPE_SHIFT; - u32 fs_phy_type = (hsotg->hwcfg2 & GHWCFG2_FS_PHY_TYPE_MASK) >> - GHWCFG2_FS_PHY_TYPE_SHIFT; u32 hcfg, val; - if ((hs_phy_type == GHWCFG2_HS_PHY_TYPE_ULPI && - fs_phy_type == GHWCFG2_FS_PHY_TYPE_DEDICATED && + if ((hsotg->hw_params.hs_phy_type == GHWCFG2_HS_PHY_TYPE_ULPI && + hsotg->hw_params.fs_phy_type == GHWCFG2_FS_PHY_TYPE_DEDICATED && hsotg->core_params->ulpi_fs_ls > 0) || hsotg->core_params->phy_type == DWC2_PHY_TYPE_PARAM_FS) { /* Full speed PHY */ @@ -247,7 +243,7 @@ static void dwc2_hs_phy_init(struct dwc2_hsotg *hsotg, bool select_phy) static void dwc2_phy_init(struct dwc2_hsotg *hsotg, bool select_phy) { - u32 usbcfg, hs_phy_type, fs_phy_type; + u32 usbcfg; if (hsotg->core_params->speed == DWC2_SPEED_PARAM_FULL && hsotg->core_params->phy_type == DWC2_PHY_TYPE_PARAM_FS) { @@ -258,13 +254,8 @@ static void dwc2_phy_init(struct dwc2_hsotg *hsotg, bool select_phy) dwc2_hs_phy_init(hsotg, select_phy); } - hs_phy_type = (hsotg->hwcfg2 & GHWCFG2_HS_PHY_TYPE_MASK) >> - GHWCFG2_HS_PHY_TYPE_SHIFT; - fs_phy_type = (hsotg->hwcfg2 & GHWCFG2_FS_PHY_TYPE_MASK) >> - GHWCFG2_FS_PHY_TYPE_SHIFT; - - if (hs_phy_type == GHWCFG2_HS_PHY_TYPE_ULPI && - fs_phy_type == GHWCFG2_FS_PHY_TYPE_DEDICATED && + if (hsotg->hw_params.hs_phy_type == GHWCFG2_HS_PHY_TYPE_ULPI && + hsotg->hw_params.fs_phy_type == GHWCFG2_FS_PHY_TYPE_DEDICATED && hsotg->core_params->ulpi_fs_ls > 0) { dev_dbg(hsotg->dev, "Setting ULPI FSLS\n"); usbcfg = readl(hsotg->regs + GUSBCFG); @@ -283,8 +274,7 @@ static int dwc2_gahbcfg_init(struct dwc2_hsotg *hsotg) { u32 ahbcfg = readl(hsotg->regs + GAHBCFG); - switch ((hsotg->hwcfg2 & GHWCFG2_ARCHITECTURE_MASK) >> - GHWCFG2_ARCHITECTURE_SHIFT) { + switch (hsotg->hw_params.arch) { case GHWCFG2_EXT_DMA_ARCH: dev_err(hsotg->dev, "External DMA Mode not supported\n"); return -EINVAL; @@ -333,8 +323,7 @@ static void dwc2_gusbcfg_init(struct dwc2_hsotg *hsotg) usbcfg = readl(hsotg->regs + GUSBCFG); usbcfg &= ~(GUSBCFG_HNPCAP | GUSBCFG_SRPCAP); - switch ((hsotg->hwcfg2 & GHWCFG2_OP_MODE_MASK) >> - GHWCFG2_OP_MODE_SHIFT) { + switch (hsotg->hw_params.op_mode) { case GHWCFG2_OP_MODE_HNP_SRP_CAPABLE: if (hsotg->core_params->otg_cap == DWC2_CAP_PARAM_HNP_SRP_CAPABLE) @@ -395,23 +384,6 @@ int dwc2_core_init(struct dwc2_hsotg *hsotg, bool select_phy, int irq) /* Reset the Controller */ dwc2_core_reset(hsotg); - dev_dbg(hsotg->dev, "num_dev_perio_in_ep=%d\n", - hsotg->hwcfg4 >> GHWCFG4_NUM_DEV_PERIO_IN_EP_SHIFT & - GHWCFG4_NUM_DEV_PERIO_IN_EP_MASK >> - GHWCFG4_NUM_DEV_PERIO_IN_EP_SHIFT); - - hsotg->total_fifo_size = hsotg->hwcfg3 >> GHWCFG3_DFIFO_DEPTH_SHIFT & - GHWCFG3_DFIFO_DEPTH_MASK >> GHWCFG3_DFIFO_DEPTH_SHIFT; - hsotg->rx_fifo_size = (readl(hsotg->regs + GRXFSIZ) & - GRXFSIZ_DEPTH_MASK) >> - GRXFSIZ_DEPTH_SHIFT; - hsotg->nperio_tx_fifo_size = - readl(hsotg->regs + GNPTXFSIZ) >> 16 & 0xffff; - - dev_dbg(hsotg->dev, "Total FIFO SZ=%d\n", hsotg->total_fifo_size); - dev_dbg(hsotg->dev, "RxFIFO SZ=%d\n", hsotg->rx_fifo_size); - dev_dbg(hsotg->dev, "NP TxFIFO SZ=%d\n", hsotg->nperio_tx_fifo_size); - /* * This needs to happen in FS mode before any other programming occurs */ @@ -514,13 +486,6 @@ static void dwc2_config_fifos(struct dwc2_hsotg *hsotg) if (!params->enable_dynamic_fifo) return; - dev_dbg(hsotg->dev, "Total FIFO Size=%d\n", hsotg->total_fifo_size); - dev_dbg(hsotg->dev, "Rx FIFO Size=%d\n", params->host_rx_fifo_size); - dev_dbg(hsotg->dev, "NP Tx FIFO Size=%d\n", - params->host_nperio_tx_fifo_size); - dev_dbg(hsotg->dev, "P Tx FIFO Size=%d\n", - params->host_perio_tx_fifo_size); - /* Rx FIFO */ grxfsiz = readl(hsotg->regs + GRXFSIZ); dev_dbg(hsotg->dev, "initial grxfsiz=%08x\n", grxfsiz); @@ -554,7 +519,7 @@ static void dwc2_config_fifos(struct dwc2_hsotg *hsotg) readl(hsotg->regs + HPTXFSIZ)); if (hsotg->core_params->en_multiple_tx_fifo > 0 && - hsotg->snpsid <= DWC2_CORE_REV_2_94a) { + hsotg->hw_params.snpsid <= DWC2_CORE_REV_2_94a) { /* * Global DFIFOCFG calculation for Host mode - * include RxFIFO, NPTXFIFO and HPTXFIFO @@ -609,11 +574,9 @@ void dwc2_core_host_init(struct dwc2_hsotg *hsotg) } if (hsotg->core_params->dma_desc_enable > 0) { - u32 op_mode = (hsotg->hwcfg2 & GHWCFG2_OP_MODE_MASK) >> - GHWCFG2_OP_MODE_SHIFT; - - if (hsotg->snpsid < DWC2_CORE_REV_2_90a || - !(hsotg->hwcfg4 & GHWCFG4_DESC_DMA) || + u32 op_mode = hsotg->hw_params.op_mode; + if (hsotg->hw_params.snpsid < DWC2_CORE_REV_2_90a || + !hsotg->hw_params.dma_desc_enable || op_mode == GHWCFG2_OP_MODE_SRP_CAPABLE_DEVICE || op_mode == GHWCFG2_OP_MODE_NO_SRP_CAPABLE_DEVICE || op_mode == GHWCFG2_OP_MODE_UNDEFINED) { @@ -1659,19 +1622,16 @@ void dwc2_hc_do_ping(struct dwc2_hsotg *hsotg, struct dwc2_host_chan *chan) u32 dwc2_calc_frame_interval(struct dwc2_hsotg *hsotg) { u32 usbcfg; - u32 hwcfg2; u32 hprt0; int clock = 60; /* default value */ usbcfg = readl(hsotg->regs + GUSBCFG); - hwcfg2 = readl(hsotg->regs + GHWCFG2); hprt0 = readl(hsotg->regs + HPRT0); if (!(usbcfg & GUSBCFG_PHYSEL) && (usbcfg & GUSBCFG_ULPI_UTMI_SEL) && !(usbcfg & GUSBCFG_PHYIF16)) clock = 60; - if ((usbcfg & GUSBCFG_PHYSEL) && - (hwcfg2 & GHWCFG2_FS_PHY_TYPE_MASK) >> GHWCFG2_FS_PHY_TYPE_SHIFT == + if ((usbcfg & GUSBCFG_PHYSEL) && hsotg->hw_params.fs_phy_type == GHWCFG2_FS_PHY_TYPE_SHARED_ULPI) clock = 48; if (!(usbcfg & GUSBCFG_PHY_LP_CLK_SEL) && !(usbcfg & GUSBCFG_PHYSEL) && @@ -1684,12 +1644,10 @@ u32 dwc2_calc_frame_interval(struct dwc2_hsotg *hsotg) !(usbcfg & GUSBCFG_ULPI_UTMI_SEL) && (usbcfg & GUSBCFG_PHYIF16)) clock = 48; if ((usbcfg & GUSBCFG_PHYSEL) && !(usbcfg & GUSBCFG_PHYIF16) && - (hwcfg2 & GHWCFG2_FS_PHY_TYPE_MASK) >> GHWCFG2_FS_PHY_TYPE_SHIFT == - GHWCFG2_FS_PHY_TYPE_SHARED_UTMI) + hsotg->hw_params.fs_phy_type == GHWCFG2_FS_PHY_TYPE_SHARED_UTMI) clock = 48; if ((usbcfg & GUSBCFG_PHYSEL) && - (hwcfg2 & GHWCFG2_FS_PHY_TYPE_MASK) >> GHWCFG2_FS_PHY_TYPE_SHIFT == - GHWCFG2_FS_PHY_TYPE_DEDICATED) + hsotg->hw_params.fs_phy_type == GHWCFG2_FS_PHY_TYPE_DEDICATED) clock = 48; if ((hprt0 & HPRT0_SPD_MASK) >> HPRT0_SPD_SHIFT == HPRT0_SPD_HIGH_SPEED) @@ -1961,18 +1919,14 @@ int dwc2_set_param_otg_cap(struct dwc2_hsotg *hsotg, int val) { int valid = 1; int retval = 0; - u32 op_mode; - - op_mode = (hsotg->hwcfg2 & GHWCFG2_OP_MODE_MASK) >> - GHWCFG2_OP_MODE_SHIFT; switch (val) { case DWC2_CAP_PARAM_HNP_SRP_CAPABLE: - if (op_mode != GHWCFG2_OP_MODE_HNP_SRP_CAPABLE) + if (hsotg->hw_params.op_mode != GHWCFG2_OP_MODE_HNP_SRP_CAPABLE) valid = 0; break; case DWC2_CAP_PARAM_SRP_ONLY_CAPABLE: - switch (op_mode) { + switch (hsotg->hw_params.op_mode) { case GHWCFG2_OP_MODE_HNP_SRP_CAPABLE: case GHWCFG2_OP_MODE_SRP_ONLY_CAPABLE: case GHWCFG2_OP_MODE_SRP_CAPABLE_DEVICE: @@ -1996,7 +1950,7 @@ int dwc2_set_param_otg_cap(struct dwc2_hsotg *hsotg, int val) dev_err(hsotg->dev, "%d invalid for otg_cap parameter. Check HW configuration.\n", val); - switch (op_mode) { + switch (hsotg->hw_params.op_mode) { case GHWCFG2_OP_MODE_HNP_SRP_CAPABLE: val = DWC2_CAP_PARAM_HNP_SRP_CAPABLE; break; @@ -2022,8 +1976,7 @@ int dwc2_set_param_dma_enable(struct dwc2_hsotg *hsotg, int val) int valid = 1; int retval = 0; - if (val > 0 && (hsotg->hwcfg2 & GHWCFG2_ARCHITECTURE_MASK) >> - GHWCFG2_ARCHITECTURE_SHIFT == GHWCFG2_SLAVE_ONLY_ARCH) + if (val > 0 && hsotg->hw_params.arch == GHWCFG2_SLAVE_ONLY_ARCH) valid = 0; if (val < 0) valid = 0; @@ -2033,8 +1986,7 @@ int dwc2_set_param_dma_enable(struct dwc2_hsotg *hsotg, int val) dev_err(hsotg->dev, "%d invalid for dma_enable parameter. Check HW configuration.\n", val); - val = (hsotg->hwcfg2 & GHWCFG2_ARCHITECTURE_MASK) >> - GHWCFG2_ARCHITECTURE_SHIFT != GHWCFG2_SLAVE_ONLY_ARCH; + val = hsotg->hw_params.arch != GHWCFG2_SLAVE_ONLY_ARCH; dev_dbg(hsotg->dev, "Setting dma_enable to %d\n", val); retval = -EINVAL; } @@ -2049,7 +2001,7 @@ int dwc2_set_param_dma_desc_enable(struct dwc2_hsotg *hsotg, int val) int retval = 0; if (val > 0 && (hsotg->core_params->dma_enable <= 0 || - !(hsotg->hwcfg4 & GHWCFG4_DESC_DMA))) + !hsotg->hw_params.dma_desc_enable)) valid = 0; if (val < 0) valid = 0; @@ -2060,7 +2012,7 @@ int dwc2_set_param_dma_desc_enable(struct dwc2_hsotg *hsotg, int val) "%d invalid for dma_desc_enable parameter. Check HW configuration.\n", val); val = (hsotg->core_params->dma_enable > 0 && - (hsotg->hwcfg4 & GHWCFG4_DESC_DMA)); + hsotg->hw_params.dma_desc_enable); dev_dbg(hsotg->dev, "Setting dma_desc_enable to %d\n", val); retval = -EINVAL; } @@ -2096,7 +2048,7 @@ int dwc2_set_param_enable_dynamic_fifo(struct dwc2_hsotg *hsotg, int val) int valid = 1; int retval = 0; - if (val > 0 && !(hsotg->hwcfg2 & GHWCFG2_DYNAMIC_FIFO)) + if (val > 0 && !hsotg->hw_params.enable_dynamic_fifo) valid = 0; if (val < 0) valid = 0; @@ -2106,7 +2058,7 @@ int dwc2_set_param_enable_dynamic_fifo(struct dwc2_hsotg *hsotg, int val) dev_err(hsotg->dev, "%d invalid for enable_dynamic_fifo parameter. Check HW configuration.\n", val); - val = !!(hsotg->hwcfg2 & GHWCFG2_DYNAMIC_FIFO); + val = hsotg->hw_params.enable_dynamic_fifo; dev_dbg(hsotg->dev, "Setting enable_dynamic_fifo to %d\n", val); retval = -EINVAL; } @@ -2120,9 +2072,7 @@ int dwc2_set_param_host_rx_fifo_size(struct dwc2_hsotg *hsotg, int val) int valid = 1; int retval = 0; - if (val < 16 || val > (readl(hsotg->regs + GRXFSIZ) & - GRXFSIZ_DEPTH_MASK) >> - GRXFSIZ_DEPTH_SHIFT) + if (val < 16 || val > hsotg->hw_params.host_rx_fifo_size) valid = 0; if (!valid) { @@ -2130,9 +2080,7 @@ int dwc2_set_param_host_rx_fifo_size(struct dwc2_hsotg *hsotg, int val) dev_err(hsotg->dev, "%d invalid for host_rx_fifo_size. Check HW configuration.\n", val); - val = (readl(hsotg->regs + GRXFSIZ) & - GRXFSIZ_DEPTH_MASK) >> - GRXFSIZ_DEPTH_SHIFT; + val = hsotg->hw_params.host_rx_fifo_size; dev_dbg(hsotg->dev, "Setting host_rx_fifo_size to %d\n", val); retval = -EINVAL; } @@ -2146,7 +2094,7 @@ int dwc2_set_param_host_nperio_tx_fifo_size(struct dwc2_hsotg *hsotg, int val) int valid = 1; int retval = 0; - if (val < 16 || val > (readl(hsotg->regs + GNPTXFSIZ) >> 16 & 0xffff)) + if (val < 16 || val > hsotg->hw_params.host_nperio_tx_fifo_size) valid = 0; if (!valid) { @@ -2154,7 +2102,7 @@ int dwc2_set_param_host_nperio_tx_fifo_size(struct dwc2_hsotg *hsotg, int val) dev_err(hsotg->dev, "%d invalid for host_nperio_tx_fifo_size. Check HW configuration.\n", val); - val = readl(hsotg->regs + GNPTXFSIZ) >> 16 & 0xffff; + val = hsotg->hw_params.host_nperio_tx_fifo_size; dev_dbg(hsotg->dev, "Setting host_nperio_tx_fifo_size to %d\n", val); retval = -EINVAL; @@ -2169,7 +2117,7 @@ int dwc2_set_param_host_perio_tx_fifo_size(struct dwc2_hsotg *hsotg, int val) int valid = 1; int retval = 0; - if (val < 16 || val > (hsotg->hptxfsiz >> 16)) + if (val < 16 || val > hsotg->hw_params.host_perio_tx_fifo_size) valid = 0; if (!valid) { @@ -2177,7 +2125,7 @@ int dwc2_set_param_host_perio_tx_fifo_size(struct dwc2_hsotg *hsotg, int val) dev_err(hsotg->dev, "%d invalid for host_perio_tx_fifo_size. Check HW configuration.\n", val); - val = hsotg->hptxfsiz >> 16; + val = hsotg->hw_params.host_perio_tx_fifo_size; dev_dbg(hsotg->dev, "Setting host_perio_tx_fifo_size to %d\n", val); retval = -EINVAL; @@ -2191,11 +2139,8 @@ int dwc2_set_param_max_transfer_size(struct dwc2_hsotg *hsotg, int val) { int valid = 1; int retval = 0; - int width = hsotg->hwcfg3 >> GHWCFG3_XFER_SIZE_CNTR_WIDTH_SHIFT & - GHWCFG3_XFER_SIZE_CNTR_WIDTH_MASK >> - GHWCFG3_XFER_SIZE_CNTR_WIDTH_SHIFT; - if (val < 2047 || val >= (1 << (width + 11))) + if (val < 2047 || val > hsotg->hw_params.max_transfer_size) valid = 0; if (!valid) { @@ -2203,7 +2148,7 @@ int dwc2_set_param_max_transfer_size(struct dwc2_hsotg *hsotg, int val) dev_err(hsotg->dev, "%d invalid for max_transfer_size. Check HW configuration.\n", val); - val = (1 << (width + 11)) - 1; + val = hsotg->hw_params.max_transfer_size; dev_dbg(hsotg->dev, "Setting max_transfer_size to %d\n", val); retval = -EINVAL; } @@ -2216,11 +2161,8 @@ int dwc2_set_param_max_packet_count(struct dwc2_hsotg *hsotg, int val) { int valid = 1; int retval = 0; - int width = hsotg->hwcfg3 >> GHWCFG3_PACKET_SIZE_CNTR_WIDTH_SHIFT & - GHWCFG3_PACKET_SIZE_CNTR_WIDTH_MASK >> - GHWCFG3_PACKET_SIZE_CNTR_WIDTH_SHIFT; - if (val < 15 || val >= (1 << (width + 4))) + if (val < 15 || val > hsotg->hw_params.max_packet_count) valid = 0; if (!valid) { @@ -2228,7 +2170,7 @@ int dwc2_set_param_max_packet_count(struct dwc2_hsotg *hsotg, int val) dev_err(hsotg->dev, "%d invalid for max_packet_count. Check HW configuration.\n", val); - val = (1 << (width + 4)) - 1; + val = hsotg->hw_params.max_packet_count; dev_dbg(hsotg->dev, "Setting max_packet_count to %d\n", val); retval = -EINVAL; } @@ -2241,10 +2183,8 @@ int dwc2_set_param_host_channels(struct dwc2_hsotg *hsotg, int val) { int valid = 1; int retval = 0; - int num_chan = hsotg->hwcfg2 >> GHWCFG2_NUM_HOST_CHAN_SHIFT & - GHWCFG2_NUM_HOST_CHAN_MASK >> GHWCFG2_NUM_HOST_CHAN_SHIFT; - if (val < 1 || val > num_chan + 1) + if (val < 1 || val > hsotg->hw_params.host_channels) valid = 0; if (!valid) { @@ -2252,7 +2192,7 @@ int dwc2_set_param_host_channels(struct dwc2_hsotg *hsotg, int val) dev_err(hsotg->dev, "%d invalid for host_channels. Check HW configuration.\n", val); - val = num_chan + 1; + val = hsotg->hw_params.host_channels; dev_dbg(hsotg->dev, "Setting host_channels to %d\n", val); retval = -EINVAL; } @@ -2265,8 +2205,7 @@ int dwc2_set_param_phy_type(struct dwc2_hsotg *hsotg, int val) { #ifndef NO_FS_PHY_HW_CHECKS int valid = 0; - u32 hs_phy_type; - u32 fs_phy_type; + u32 hs_phy_type, fs_phy_type; #endif int retval = 0; @@ -2287,11 +2226,8 @@ int dwc2_set_param_phy_type(struct dwc2_hsotg *hsotg, int val) } #ifndef NO_FS_PHY_HW_CHECKS - hs_phy_type = (hsotg->hwcfg2 & GHWCFG2_HS_PHY_TYPE_MASK) >> - GHWCFG2_HS_PHY_TYPE_SHIFT; - fs_phy_type = (hsotg->hwcfg2 & GHWCFG2_FS_PHY_TYPE_MASK) >> - GHWCFG2_FS_PHY_TYPE_SHIFT; - + hs_phy_type = hsotg->hw_params.hs_phy_type; + fs_phy_type = hsotg->hw_params.fs_phy_type; if (val == DWC2_PHY_TYPE_PARAM_UTMI && (hs_phy_type == GHWCFG2_HS_PHY_TYPE_UTMI || hs_phy_type == GHWCFG2_HS_PHY_TYPE_UTMI_ULPI)) @@ -2515,7 +2451,7 @@ int dwc2_set_param_i2c_enable(struct dwc2_hsotg *hsotg, int val) } #ifndef NO_FS_PHY_HW_CHECKS - if (val == 1 && !(hsotg->hwcfg3 & GHWCFG3_I2C)) + if (val == 1 && !(hsotg->hw_params.i2c_enable)) valid = 0; if (!valid) { @@ -2523,7 +2459,7 @@ int dwc2_set_param_i2c_enable(struct dwc2_hsotg *hsotg, int val) dev_err(hsotg->dev, "%d invalid for i2c_enable. Check HW configuration.\n", val); - val = !!(hsotg->hwcfg3 & GHWCFG3_I2C); + val = hsotg->hw_params.i2c_enable; dev_dbg(hsotg->dev, "Setting i2c_enable to %d\n", val); retval = -EINVAL; } @@ -2548,7 +2484,7 @@ int dwc2_set_param_en_multiple_tx_fifo(struct dwc2_hsotg *hsotg, int val) valid = 0; } - if (val == 1 && !(hsotg->hwcfg4 & GHWCFG4_DED_FIFO_EN)) + if (val == 1 && !hsotg->hw_params.en_multiple_tx_fifo) valid = 0; if (!valid) { @@ -2556,7 +2492,7 @@ int dwc2_set_param_en_multiple_tx_fifo(struct dwc2_hsotg *hsotg, int val) dev_err(hsotg->dev, "%d invalid for parameter en_multiple_tx_fifo. Check HW configuration.\n", val); - val = !!(hsotg->hwcfg4 & GHWCFG4_DED_FIFO_EN); + val = hsotg->hw_params.en_multiple_tx_fifo; dev_dbg(hsotg->dev, "Setting en_multiple_tx_fifo to %d\n", val); retval = -EINVAL; } @@ -2579,7 +2515,7 @@ int dwc2_set_param_reload_ctl(struct dwc2_hsotg *hsotg, int val) valid = 0; } - if (val == 1 && hsotg->snpsid < DWC2_CORE_REV_2_92a) + if (val == 1 && hsotg->hw_params.snpsid < DWC2_CORE_REV_2_92a) valid = 0; if (!valid) { @@ -2587,7 +2523,7 @@ int dwc2_set_param_reload_ctl(struct dwc2_hsotg *hsotg, int val) dev_err(hsotg->dev, "%d invalid for parameter reload_ctl. Check HW configuration.\n", val); - val = hsotg->snpsid >= DWC2_CORE_REV_2_92a; + val = hsotg->hw_params.snpsid >= DWC2_CORE_REV_2_92a; dev_dbg(hsotg->dev, "Setting reload_ctl to %d\n", val); retval = -EINVAL; } @@ -2626,6 +2562,161 @@ int dwc2_set_param_otg_ver(struct dwc2_hsotg *hsotg, int val) return retval; } +/** + * During device initialization, read various hardware configuration + * registers and interpret the contents. + */ +int dwc2_get_hwparams(struct dwc2_hsotg *hsotg) +{ + struct dwc2_hw_params *hw = &hsotg->hw_params; + unsigned width; + u32 hwcfg1, hwcfg2, hwcfg3, hwcfg4; + u32 hptxfsiz, grxfsiz, gnptxfsiz; + u32 gusbcfg; + + /* + * Attempt to ensure this device is really a DWC_otg Controller. + * Read and verify the GSNPSID register contents. The value should be + * 0x45f42xxx or 0x45f43xxx, which corresponds to either "OT2" or "OT3", + * as in "OTG version 2.xx" or "OTG version 3.xx". + */ + hw->snpsid = readl(hsotg->regs + GSNPSID); + if ((hw->snpsid & 0xfffff000) != 0x4f542000 && + (hw->snpsid & 0xfffff000) != 0x4f543000) { + dev_err(hsotg->dev, "Bad value for GSNPSID: 0x%08x\n", + hw->snpsid); + return -ENODEV; + } + + dev_dbg(hsotg->dev, "Core Release: %1x.%1x%1x%1x (snpsid=%x)\n", + hw->snpsid >> 12 & 0xf, hw->snpsid >> 8 & 0xf, + hw->snpsid >> 4 & 0xf, hw->snpsid & 0xf, hw->snpsid); + + hwcfg1 = readl(hsotg->regs + GHWCFG1); + hwcfg2 = readl(hsotg->regs + GHWCFG2); + hwcfg3 = readl(hsotg->regs + GHWCFG3); + hwcfg4 = readl(hsotg->regs + GHWCFG4); + gnptxfsiz = readl(hsotg->regs + GNPTXFSIZ); + grxfsiz = readl(hsotg->regs + GRXFSIZ); + + dev_dbg(hsotg->dev, "hwcfg1=%08x\n", hwcfg1); + dev_dbg(hsotg->dev, "hwcfg2=%08x\n", hwcfg2); + dev_dbg(hsotg->dev, "hwcfg3=%08x\n", hwcfg3); + dev_dbg(hsotg->dev, "hwcfg4=%08x\n", hwcfg4); + dev_dbg(hsotg->dev, "gnptxfsiz=%08x\n", gnptxfsiz); + dev_dbg(hsotg->dev, "grxfsiz=%08x\n", grxfsiz); + + /* Force host mode to get HPTXFSIZ exact power on value */ + gusbcfg = readl(hsotg->regs + GUSBCFG); + gusbcfg |= GUSBCFG_FORCEHOSTMODE; + writel(gusbcfg, hsotg->regs + GUSBCFG); + usleep_range(100000, 150000); + + hptxfsiz = readl(hsotg->regs + HPTXFSIZ); + dev_dbg(hsotg->dev, "hptxfsiz=%08x\n", hptxfsiz); + gusbcfg = readl(hsotg->regs + GUSBCFG); + gusbcfg &= ~GUSBCFG_FORCEHOSTMODE; + writel(gusbcfg, hsotg->regs + GUSBCFG); + usleep_range(100000, 150000); + + /* hwcfg2 */ + hw->op_mode = (hwcfg2 & GHWCFG2_OP_MODE_MASK) >> + GHWCFG2_OP_MODE_SHIFT; + hw->arch = (hwcfg2 & GHWCFG2_ARCHITECTURE_MASK) >> + GHWCFG2_ARCHITECTURE_SHIFT; + hw->enable_dynamic_fifo = !!(hwcfg2 & GHWCFG2_DYNAMIC_FIFO); + hw->host_channels = 1 + ((hwcfg2 & GHWCFG2_NUM_HOST_CHAN_MASK) >> + GHWCFG2_NUM_HOST_CHAN_SHIFT); + hw->hs_phy_type = (hwcfg2 & GHWCFG2_HS_PHY_TYPE_MASK) >> + GHWCFG2_HS_PHY_TYPE_SHIFT; + hw->fs_phy_type = (hwcfg2 & GHWCFG2_FS_PHY_TYPE_MASK) >> + GHWCFG2_FS_PHY_TYPE_SHIFT; + hw->num_dev_ep = (hwcfg2 & GHWCFG2_NUM_DEV_EP_MASK) >> + GHWCFG2_NUM_DEV_EP_SHIFT; + hw->nperio_tx_q_depth = + (hwcfg2 & GHWCFG2_NONPERIO_TX_Q_DEPTH_MASK) >> + GHWCFG2_NONPERIO_TX_Q_DEPTH_SHIFT << 1; + hw->host_perio_tx_q_depth = + (hwcfg2 & GHWCFG2_HOST_PERIO_TX_Q_DEPTH_MASK) >> + GHWCFG2_HOST_PERIO_TX_Q_DEPTH_SHIFT << 1; + hw->dev_token_q_depth = + (hwcfg2 & GHWCFG2_DEV_TOKEN_Q_DEPTH_MASK) >> + GHWCFG2_DEV_TOKEN_Q_DEPTH_SHIFT; + + /* hwcfg3 */ + width = (hwcfg3 & GHWCFG3_XFER_SIZE_CNTR_WIDTH_MASK) >> + GHWCFG3_XFER_SIZE_CNTR_WIDTH_SHIFT; + hw->max_transfer_size = (1 << (width + 11)) - 1; + width = (hwcfg3 & GHWCFG3_PACKET_SIZE_CNTR_WIDTH_MASK) >> + GHWCFG3_PACKET_SIZE_CNTR_WIDTH_SHIFT; + hw->max_packet_count = (1 << (width + 4)) - 1; + hw->i2c_enable = !!(hwcfg3 & GHWCFG3_I2C); + hw->total_fifo_size = (hwcfg3 & GHWCFG3_DFIFO_DEPTH_MASK) >> + GHWCFG3_DFIFO_DEPTH_SHIFT; + + /* hwcfg4 */ + hw->en_multiple_tx_fifo = !!(hwcfg4 & GHWCFG4_DED_FIFO_EN); + hw->num_dev_perio_in_ep = (hwcfg4 & GHWCFG4_NUM_DEV_PERIO_IN_EP_MASK) >> + GHWCFG4_NUM_DEV_PERIO_IN_EP_SHIFT; + hw->dma_desc_enable = !!(hwcfg4 & GHWCFG4_DESC_DMA); + hw->power_optimized = !!(hwcfg4 & GHWCFG4_POWER_OPTIMIZ); + + /* fifo sizes */ + hw->host_rx_fifo_size = (grxfsiz & GRXFSIZ_DEPTH_MASK) >> + GRXFSIZ_DEPTH_SHIFT; + hw->host_nperio_tx_fifo_size = (gnptxfsiz & FIFOSIZE_DEPTH_MASK) >> + FIFOSIZE_DEPTH_SHIFT; + hw->host_perio_tx_fifo_size = (hptxfsiz & FIFOSIZE_DEPTH_MASK) >> + FIFOSIZE_DEPTH_SHIFT; + + dev_dbg(hsotg->dev, "Detected values from hardware:\n"); + dev_dbg(hsotg->dev, " op_mode=%d\n", + hw->op_mode); + dev_dbg(hsotg->dev, " arch=%d\n", + hw->arch); + dev_dbg(hsotg->dev, " dma_desc_enable=%d\n", + hw->dma_desc_enable); + dev_dbg(hsotg->dev, " power_optimized=%d\n", + hw->power_optimized); + dev_dbg(hsotg->dev, " i2c_enable=%d\n", + hw->i2c_enable); + dev_dbg(hsotg->dev, " hs_phy_type=%d\n", + hw->hs_phy_type); + dev_dbg(hsotg->dev, " fs_phy_type=%d\n", + hw->fs_phy_type); + dev_dbg(hsotg->dev, " num_dev_ep=%d\n", + hw->num_dev_ep); + dev_dbg(hsotg->dev, " num_dev_perio_in_ep=%d\n", + hw->num_dev_perio_in_ep); + dev_dbg(hsotg->dev, " host_channels=%d\n", + hw->host_channels); + dev_dbg(hsotg->dev, " max_transfer_size=%d\n", + hw->max_transfer_size); + dev_dbg(hsotg->dev, " max_packet_count=%d\n", + hw->max_packet_count); + dev_dbg(hsotg->dev, " nperio_tx_q_depth=0x%0x\n", + hw->nperio_tx_q_depth); + dev_dbg(hsotg->dev, " host_perio_tx_q_depth=0x%0x\n", + hw->host_perio_tx_q_depth); + dev_dbg(hsotg->dev, " dev_token_q_depth=0x%0x\n", + hw->dev_token_q_depth); + dev_dbg(hsotg->dev, " enable_dynamic_fifo=%d\n", + hw->enable_dynamic_fifo); + dev_dbg(hsotg->dev, " en_multiple_tx_fifo=%d\n", + hw->en_multiple_tx_fifo); + dev_dbg(hsotg->dev, " total_fifo_size=%d\n", + hw->total_fifo_size); + dev_dbg(hsotg->dev, " host_rx_fifo_size=%d\n", + hw->host_rx_fifo_size); + dev_dbg(hsotg->dev, " host_nperio_tx_fifo_size=%d\n", + hw->host_nperio_tx_fifo_size); + dev_dbg(hsotg->dev, " host_perio_tx_fifo_size=%d\n", + hw->host_perio_tx_fifo_size); + dev_dbg(hsotg->dev, "\n"); + + return 0; +} + /* * This function is called during module intialization to pass module parameters * for the DWC_otg core. It returns non-0 if any parameters are invalid. diff --git a/drivers/staging/dwc2/core.h b/drivers/staging/dwc2/core.h index e5b4dc8948a38..e4eb3a0d0b5b1 100644 --- a/drivers/staging/dwc2/core.h +++ b/drivers/staging/dwc2/core.h @@ -193,6 +193,79 @@ struct dwc2_core_params { int ahbcfg; }; +/** + * struct dwc2_hw_params - Autodetected parameters. + * + * These parameters are the various parameters read from hardware + * registers during initialization. They typically contain the best + * supported or maximum value that can be configured in the + * corresponding dwc2_core_params value. + * + * The values that are not in dwc2_core_params are documented below. + * + * @op_mode Mode of Operation + * 0 - HNP- and SRP-Capable OTG (Host & Device) + * 1 - SRP-Capable OTG (Host & Device) + * 2 - Non-HNP and Non-SRP Capable OTG (Host & Device) + * 3 - SRP-Capable Device + * 4 - Non-OTG Device + * 5 - SRP-Capable Host + * 6 - Non-OTG Host + * @arch Architecture + * 0 - Slave only + * 1 - External DMA + * 2 - Internal DMA + * @power_optimized Are power optimizations enabled? + * @num_dev_ep Number of device endpoints available + * @num_dev_perio_in_ep Number of device periodic IN endpoints + * avaialable + * @dev_token_q_depth Device Mode IN Token Sequence Learning Queue + * Depth + * 0 to 30 + * @host_perio_tx_q_depth + * Host Mode Periodic Request Queue Depth + * 2, 4 or 8 + * @nperio_tx_q_depth + * Non-Periodic Request Queue Depth + * 2, 4 or 8 + * @hs_phy_type High-speed PHY interface type + * 0 - High-speed interface not supported + * 1 - UTMI+ + * 2 - ULPI + * 3 - UTMI+ and ULPI + * @fs_phy_type Full-speed PHY interface type + * 0 - Full speed interface not supported + * 1 - Dedicated full speed interface + * 2 - FS pins shared with UTMI+ pins + * 3 - FS pins shared with ULPI pins + * @total_fifo_size: Total internal RAM for FIFOs (bytes) + * @snpsid: Value from SNPSID register + */ +struct dwc2_hw_params { + unsigned op_mode:3; + unsigned arch:2; + unsigned dma_desc_enable:1; + unsigned enable_dynamic_fifo:1; + unsigned en_multiple_tx_fifo:1; + unsigned host_rx_fifo_size:16; + unsigned host_nperio_tx_fifo_size:16; + unsigned host_perio_tx_fifo_size:16; + unsigned nperio_tx_q_depth:3; + unsigned host_perio_tx_q_depth:3; + unsigned dev_token_q_depth:5; + unsigned max_transfer_size:26; + unsigned max_packet_count:11; + unsigned host_channels:4; + unsigned hs_phy_type:2; + unsigned fs_phy_type:2; + unsigned i2c_enable:1; + unsigned num_dev_ep:4; + unsigned num_dev_perio_in_ep:4; + unsigned total_fifo_size:16; + unsigned power_optimized:1; + u32 snpsid; +}; + /** * struct dwc2_hsotg - Holds the state of the driver, including the non-periodic * and periodic schedules @@ -200,15 +273,8 @@ struct dwc2_core_params { * @dev: The struct device pointer * @regs: Pointer to controller regs * @core_params: Parameters that define how the core should be configured - * @hwcfg1: Hardware Configuration - stored here for convenience - * @hwcfg2: Hardware Configuration - stored here for convenience - * @hwcfg3: Hardware Configuration - stored here for convenience - * @hwcfg4: Hardware Configuration - stored here for convenience - * @hptxfsiz: Hardware Configuration - stored here for convenience - * @snpsid: Value from SNPSID register - * @total_fifo_size: Total internal RAM for FIFOs (bytes) - * @rx_fifo_size: Size of Rx FIFO (bytes) - * @nperio_tx_fifo_size: Size of Non-periodic Tx FIFO (Bytes) + * @hw_params: Parameters that were autodetected from the + * hardware registers * @op_state: The operational State, during transitions (a_host=> * a_peripheral and b_device=>b_host) this may not match * the core, but allows the software to determine @@ -296,16 +362,10 @@ struct dwc2_core_params { struct dwc2_hsotg { struct device *dev; void __iomem *regs; + /** Params detected from hardware */ + struct dwc2_hw_params hw_params; + /** Params to actually use */ struct dwc2_core_params *core_params; - u32 hwcfg1; - u32 hwcfg2; - u32 hwcfg3; - u32 hwcfg4; - u32 hptxfsiz; - u32 snpsid; - u16 total_fifo_size; - u16 rx_fifo_size; - u16 nperio_tx_fifo_size; enum usb_otg_state op_state; unsigned int queuing_high_bandwidth:1; diff --git a/drivers/staging/dwc2/core_intr.c b/drivers/staging/dwc2/core_intr.c index 98c51bba6622e..07cfa2f6aa2ba 100644 --- a/drivers/staging/dwc2/core_intr.c +++ b/drivers/staging/dwc2/core_intr.c @@ -166,7 +166,7 @@ static void dwc2_handle_otg_intr(struct dwc2_hsotg *hsotg) * WA for 3.00a- HW is not setting cur_mode, even sometimes * this does not help */ - if (hsotg->snpsid >= DWC2_CORE_REV_3_00a) + if (hsotg->hw_params.snpsid >= DWC2_CORE_REV_3_00a) udelay(100); if (gotgctl & GOTGCTL_HSTNEGSCS) { if (dwc2_is_host_mode(hsotg)) { @@ -380,7 +380,7 @@ static void dwc2_handle_usb_suspend_intr(struct dwc2_hsotg *hsotg) dev_dbg(hsotg->dev, "DSTS.Suspend Status=%d HWCFG4.Power Optimize=%d\n", !!(dsts & DSTS_SUSPSTS), - !!(hsotg->hwcfg4 & GHWCFG4_POWER_OPTIMIZ)); + hsotg->hw_params.power_optimized); } else { if (hsotg->op_state == OTG_STATE_A_PERIPHERAL) { dev_dbg(hsotg->dev, "a_peripheral->a_host\n"); diff --git a/drivers/staging/dwc2/hcd.c b/drivers/staging/dwc2/hcd.c index 9a1e062b72978..da0d35cc33ce7 100644 --- a/drivers/staging/dwc2/hcd.c +++ b/drivers/staging/dwc2/hcd.c @@ -2678,7 +2678,7 @@ static void dwc2_hcd_free(struct dwc2_hsotg *hsotg) writel(ahbcfg, hsotg->regs + GAHBCFG); writel(0, hsotg->regs + GINTMSK); - if (hsotg->snpsid >= DWC2_CORE_REV_3_00a) { + if (hsotg->hw_params.snpsid >= DWC2_CORE_REV_3_00a) { dctl = readl(hsotg->regs + DCTL); dctl |= DCTL_SFTDISCON; writel(dctl, hsotg->regs + DCTL); @@ -2730,80 +2730,22 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq, { struct usb_hcd *hcd; struct dwc2_host_chan *channel; - u32 gusbcfg, hcfg; + u32 hcfg; int i, num_channels; - int retval = -ENOMEM; + int retval; dev_dbg(hsotg->dev, "DWC OTG HCD INIT\n"); - /* - * Attempt to ensure this device is really a DWC_otg Controller. - * Read and verify the GSNPSID register contents. The value should be - * 0x45f42xxx or 0x45f43xxx, which corresponds to either "OT2" or "OT3", - * as in "OTG version 2.xx" or "OTG version 3.xx". - */ - hsotg->snpsid = readl(hsotg->regs + GSNPSID); - if ((hsotg->snpsid & 0xfffff000) != 0x4f542000 && - (hsotg->snpsid & 0xfffff000) != 0x4f543000) { - dev_err(hsotg->dev, "Bad value for GSNPSID: 0x%08x\n", - hsotg->snpsid); - retval = -ENODEV; - goto error1; - } + /* Detect config values from hardware */ + retval = dwc2_get_hwparams(hsotg); - /* - * Store the contents of the hardware configuration registers here for - * easy access later - */ - hsotg->hwcfg1 = readl(hsotg->regs + GHWCFG1); - hsotg->hwcfg2 = readl(hsotg->regs + GHWCFG2); - hsotg->hwcfg3 = readl(hsotg->regs + GHWCFG3); - hsotg->hwcfg4 = readl(hsotg->regs + GHWCFG4); - - dev_dbg(hsotg->dev, "hwcfg1=%08x\n", hsotg->hwcfg1); - dev_dbg(hsotg->dev, "hwcfg2=%08x\n", hsotg->hwcfg2); - dev_dbg(hsotg->dev, "hwcfg3=%08x\n", hsotg->hwcfg3); - dev_dbg(hsotg->dev, "hwcfg4=%08x\n", hsotg->hwcfg4); - - /* Force host mode to get HPTXFSIZ exact power on value */ - gusbcfg = readl(hsotg->regs + GUSBCFG); - gusbcfg |= GUSBCFG_FORCEHOSTMODE; - writel(gusbcfg, hsotg->regs + GUSBCFG); - usleep_range(100000, 150000); - - hsotg->hptxfsiz = readl(hsotg->regs + HPTXFSIZ); - dev_dbg(hsotg->dev, "hptxfsiz=%08x\n", hsotg->hptxfsiz); - gusbcfg = readl(hsotg->regs + GUSBCFG); - gusbcfg &= ~GUSBCFG_FORCEHOSTMODE; - writel(gusbcfg, hsotg->regs + GUSBCFG); - usleep_range(100000, 150000); + if (retval) + return retval; + + retval = -ENOMEM; hcfg = readl(hsotg->regs + HCFG); dev_dbg(hsotg->dev, "hcfg=%08x\n", hcfg); - dev_dbg(hsotg->dev, "op_mode=%0x\n", - hsotg->hwcfg2 >> GHWCFG2_OP_MODE_SHIFT & - GHWCFG2_OP_MODE_MASK >> GHWCFG2_OP_MODE_SHIFT); - dev_dbg(hsotg->dev, "arch=%0x\n", - hsotg->hwcfg2 >> GHWCFG2_ARCHITECTURE_SHIFT & - GHWCFG2_ARCHITECTURE_MASK >> GHWCFG2_ARCHITECTURE_SHIFT); - dev_dbg(hsotg->dev, "num_dev_ep=%d\n", - hsotg->hwcfg2 >> GHWCFG2_NUM_DEV_EP_SHIFT & - GHWCFG2_NUM_DEV_EP_MASK >> GHWCFG2_NUM_DEV_EP_SHIFT); - dev_dbg(hsotg->dev, "max_host_chan=%d\n", - hsotg->hwcfg2 >> GHWCFG2_NUM_HOST_CHAN_SHIFT & - GHWCFG2_NUM_HOST_CHAN_MASK >> GHWCFG2_NUM_HOST_CHAN_SHIFT); - dev_dbg(hsotg->dev, "nonperio_tx_q_depth=0x%0x\n", - hsotg->hwcfg2 >> GHWCFG2_NONPERIO_TX_Q_DEPTH_SHIFT & - GHWCFG2_NONPERIO_TX_Q_DEPTH_MASK >> - GHWCFG2_NONPERIO_TX_Q_DEPTH_SHIFT); - dev_dbg(hsotg->dev, "host_perio_tx_q_depth=0x%0x\n", - hsotg->hwcfg2 >> GHWCFG2_HOST_PERIO_TX_Q_DEPTH_SHIFT & - GHWCFG2_HOST_PERIO_TX_Q_DEPTH_MASK >> - GHWCFG2_HOST_PERIO_TX_Q_DEPTH_SHIFT); - dev_dbg(hsotg->dev, "dev_token_q_depth=0x%0x\n", - hsotg->hwcfg2 >> GHWCFG2_DEV_TOKEN_Q_DEPTH_SHIFT & - GHWCFG3_XFER_SIZE_CNTR_WIDTH_MASK >> - GHWCFG3_XFER_SIZE_CNTR_WIDTH_SHIFT); #ifdef CONFIG_USB_DWC2_TRACK_MISSED_SOFS hsotg->frame_num_array = kzalloc(sizeof(*hsotg->frame_num_array) * @@ -2877,10 +2819,6 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq, } INIT_WORK(&hsotg->wf_otg, dwc2_conn_id_status_change); - dev_dbg(hsotg->dev, "Core Release: %1x.%1x%1x%1x\n", - hsotg->snpsid >> 12 & 0xf, hsotg->snpsid >> 8 & 0xf, - hsotg->snpsid >> 4 & 0xf, hsotg->snpsid & 0xf); - setup_timer(&hsotg->wkp_timer, dwc2_wakeup_detected, (unsigned long)hsotg); diff --git a/drivers/staging/dwc2/hcd.h b/drivers/staging/dwc2/hcd.h index 65c782e90e93c..cc0a117083194 100644 --- a/drivers/staging/dwc2/hcd.h +++ b/drivers/staging/dwc2/hcd.h @@ -453,6 +453,7 @@ extern void dwc2_hcd_remove(struct dwc2_hsotg *hsotg); extern int dwc2_set_parameters(struct dwc2_hsotg *hsotg, const struct dwc2_core_params *params); extern void dwc2_set_all_params(struct dwc2_core_params *params, int value); +extern int dwc2_get_hwparams(struct dwc2_hsotg *hsotg); /* Transaction Execution Functions */ extern enum dwc2_transaction_type dwc2_hcd_select_transactions( diff --git a/drivers/staging/dwc2/hcd_intr.c b/drivers/staging/dwc2/hcd_intr.c index f60b836b3d131..e143f69939f52 100644 --- a/drivers/staging/dwc2/hcd_intr.c +++ b/drivers/staging/dwc2/hcd_intr.c @@ -1759,7 +1759,7 @@ static void dwc2_hc_chhltd_intr_dma(struct dwc2_hsotg *hsotg, * For core with OUT NAK enhancement, the flow for high-speed * CONTROL/BULK OUT is handled a little differently */ - if (hsotg->snpsid >= DWC2_CORE_REV_2_71a) { + if (hsotg->hw_params.snpsid >= DWC2_CORE_REV_2_71a) { if (chan->speed == USB_SPEED_HIGH && !chan->ep_is_in && (chan->ep_type == USB_ENDPOINT_XFER_CONTROL || chan->ep_type == USB_ENDPOINT_XFER_BULK)) { -- GitLab From de4a1931939891db633fbc3c33e953dd58f94294 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Fri, 30 Aug 2013 18:45:22 +0200 Subject: [PATCH 941/942] staging: dwc2: validate the value for phy_utmi_width The HWCFG4 register stores the supported utmi width values (8, 16 or both). This commit reads that value and validates the configured value against that. If no (valid) value is given, the parameter defaulted to 8 bits previously. However, the documentation for dwc2_core_params_struct suggests that the default should have been 16. Also, the pci bindings explicitely set the value to 16, so this commit changes the default to 16 bits (if supported, 8 bits otherwise). With the default changed, the value set in pci.c is changed to -1 to make it autodetected as well. Signed-off-by: Matthijs Kooijman Acked-by: Paul Zimmerman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dwc2/core.c | 27 +++++++++++++++++++++++---- drivers/staging/dwc2/core.h | 5 +++++ drivers/staging/dwc2/hw.h | 3 +++ drivers/staging/dwc2/pci.c | 2 +- 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/drivers/staging/dwc2/core.c b/drivers/staging/dwc2/core.c index 825c5e5f157fb..06dae67a9d629 100644 --- a/drivers/staging/dwc2/core.c +++ b/drivers/staging/dwc2/core.c @@ -2376,14 +2376,29 @@ int dwc2_set_param_phy_ulpi_ext_vbus(struct dwc2_hsotg *hsotg, int val) int dwc2_set_param_phy_utmi_width(struct dwc2_hsotg *hsotg, int val) { + int valid = 0; int retval = 0; - if (DWC2_PARAM_TEST(val, 8, 8) && DWC2_PARAM_TEST(val, 16, 16)) { + switch (hsotg->hw_params.utmi_phy_data_width) { + case GHWCFG4_UTMI_PHY_DATA_WIDTH_8: + valid = (val == 8); + break; + case GHWCFG4_UTMI_PHY_DATA_WIDTH_16: + valid = (val == 16); + break; + case GHWCFG4_UTMI_PHY_DATA_WIDTH_8_OR_16: + valid = (val == 8 || val == 16); + break; + } + + if (!valid) { if (val >= 0) { - dev_err(hsotg->dev, "Wrong value for phy_utmi_width\n"); - dev_err(hsotg->dev, "phy_utmi_width must be 8 or 16\n"); + dev_err(hsotg->dev, + "%d invalid for phy_utmi_width. Check HW configuration.\n", + val); } - val = 8; + val = (hsotg->hw_params.utmi_phy_data_width == + GHWCFG4_UTMI_PHY_DATA_WIDTH_8) ? 8 : 16; dev_dbg(hsotg->dev, "Setting phy_utmi_width to %d\n", val); retval = -EINVAL; } @@ -2660,6 +2675,8 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg) GHWCFG4_NUM_DEV_PERIO_IN_EP_SHIFT; hw->dma_desc_enable = !!(hwcfg4 & GHWCFG4_DESC_DMA); hw->power_optimized = !!(hwcfg4 & GHWCFG4_POWER_OPTIMIZ); + hw->utmi_phy_data_width = (hwcfg4 & GHWCFG4_UTMI_PHY_DATA_WIDTH_MASK) >> + GHWCFG4_UTMI_PHY_DATA_WIDTH_SHIFT; /* fifo sizes */ hw->host_rx_fifo_size = (grxfsiz & GRXFSIZ_DEPTH_MASK) >> @@ -2684,6 +2701,8 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg) hw->hs_phy_type); dev_dbg(hsotg->dev, " fs_phy_type=%d\n", hw->fs_phy_type); + dev_dbg(hsotg->dev, " utmi_phy_data_wdith=%d\n", + hw->utmi_phy_data_width); dev_dbg(hsotg->dev, " num_dev_ep=%d\n", hw->num_dev_ep); dev_dbg(hsotg->dev, " num_dev_perio_in_ep=%d\n", diff --git a/drivers/staging/dwc2/core.h b/drivers/staging/dwc2/core.h index e4eb3a0d0b5b1..ecfcad83f767e 100644 --- a/drivers/staging/dwc2/core.h +++ b/drivers/staging/dwc2/core.h @@ -239,6 +239,10 @@ struct dwc2_core_params { * 2 - FS pins shared with UTMI+ pins * 3 - FS pins shared with ULPI pins * @total_fifo_size: Total internal RAM for FIFOs (bytes) + * @utmi_phy_data_width UTMI+ PHY data width + * 0 - 8 bits + * 1 - 16 bits + * 2 - 8 or 16 bits * @snpsid: Value from SNPSID register */ struct dwc2_hw_params { @@ -263,6 +267,7 @@ struct dwc2_hw_params { unsigned num_dev_perio_in_ep:4; unsigned total_fifo_size:16; unsigned power_optimized:1; + unsigned utmi_phy_data_width:2; u32 snpsid; }; diff --git a/drivers/staging/dwc2/hw.h b/drivers/staging/dwc2/hw.h index fafdc199b2b5a..9c92a3c7588a0 100644 --- a/drivers/staging/dwc2/hw.h +++ b/drivers/staging/dwc2/hw.h @@ -302,6 +302,9 @@ #define GHWCFG4_NUM_DEV_MODE_CTRL_EP_SHIFT 16 #define GHWCFG4_UTMI_PHY_DATA_WIDTH_MASK (0x3 << 14) #define GHWCFG4_UTMI_PHY_DATA_WIDTH_SHIFT 14 +#define GHWCFG4_UTMI_PHY_DATA_WIDTH_8 0 +#define GHWCFG4_UTMI_PHY_DATA_WIDTH_16 1 +#define GHWCFG4_UTMI_PHY_DATA_WIDTH_8_OR_16 2 #define GHWCFG4_XHIBER (1 << 7) #define GHWCFG4_HIBER (1 << 6) #define GHWCFG4_MIN_AHB_FREQ (1 << 5) diff --git a/drivers/staging/dwc2/pci.c b/drivers/staging/dwc2/pci.c index fdfbc719663c5..9020260d5df8f 100644 --- a/drivers/staging/dwc2/pci.c +++ b/drivers/staging/dwc2/pci.c @@ -74,7 +74,7 @@ static const struct dwc2_core_params dwc2_module_params = { .max_packet_count = 511, .host_channels = -1, .phy_type = -1, - .phy_utmi_width = 16, /* 16 bits - NOT DETECTABLE */ + .phy_utmi_width = -1, .phy_ulpi_ddr = -1, .phy_ulpi_ext_vbus = -1, .i2c_enable = -1, -- GitLab From 91121c103ae93ef117e58712786864270d7f488e Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Fri, 30 Aug 2013 18:45:23 +0200 Subject: [PATCH 942/942] staging: dwc2: make dwc2_core_params documentation more complete Some of the defaults were missing or unclear. In particular, I suspect the defaults were documented assuming there were still module parameters and taking the default module parameters into account. Now, the defaults are the values that will get chosen when the params passed to dwc2_hcd_init are all -1. Signed-off-by: Matthijs Kooijman Acked-by: Paul Zimmerman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dwc2/core.h | 85 +++++++++++++++++++++++++------------ 1 file changed, 59 insertions(+), 26 deletions(-) diff --git a/drivers/staging/dwc2/core.h b/drivers/staging/dwc2/core.h index ecfcad83f767e..9102f66d0111e 100644 --- a/drivers/staging/dwc2/core.h +++ b/drivers/staging/dwc2/core.h @@ -68,19 +68,18 @@ enum dwc2_lx_state { /** * struct dwc2_core_params - Parameters for configuring the core * - * @otg_cap: Specifies the OTG capabilities. The driver will - * automatically detect the value for this parameter if - * none is specified. - * 0 - HNP and SRP capable (default) + * @otg_cap: Specifies the OTG capabilities. + * 0 - HNP and SRP capable * 1 - SRP Only capable - * 2 - No HNP/SRP capable + * 2 - No HNP/SRP capable (always available) + * Defaults to best available option (0, 1, then 2) * @otg_ver: OTG version supported - * 0 - 1.3 + * 0 - 1.3 (default) * 1 - 2.0 * @dma_enable: Specifies whether to use slave or DMA mode for accessing * the data FIFOs. The driver will automatically detect the * value for this parameter if none is specified. - * 0 - Slave + * 0 - Slave (always available) * 1 - DMA (default, if available) * @dma_desc_enable: When DMA mode is enabled, specifies whether to use * address DMA mode or descriptor DMA mode for accessing @@ -91,29 +90,47 @@ enum dwc2_lx_state { * @speed: Specifies the maximum speed of operation in host and * device mode. The actual speed depends on the speed of * the attached device and the value of phy_type. - * 0 - High Speed (default) + * 0 - High Speed + * (default when phy_type is UTMI+ or ULPI) * 1 - Full Speed + * (default when phy_type is Full Speed) * @enable_dynamic_fifo: 0 - Use coreConsultant-specified FIFO size parameters - * 1 - Allow dynamic FIFO sizing (default) + * 1 - Allow dynamic FIFO sizing (default, if available) * @en_multiple_tx_fifo: Specifies whether dedicated per-endpoint transmit FIFOs * are enabled * @host_rx_fifo_size: Number of 4-byte words in the Rx FIFO in host mode when * dynamic FIFO sizing is enabled - * 16 to 32768 (default 1024) + * 16 to 32768 + * Actual maximum value is autodetected and also + * the default. * @host_nperio_tx_fifo_size: Number of 4-byte words in the non-periodic Tx FIFO * in host mode when dynamic FIFO sizing is enabled - * 16 to 32768 (default 1024) + * 16 to 32768 + * Actual maximum value is autodetected and also + * the default. * @host_perio_tx_fifo_size: Number of 4-byte words in the periodic Tx FIFO in * host mode when dynamic FIFO sizing is enabled - * 16 to 32768 (default 1024) + * 16 to 32768 + * Actual maximum value is autodetected and also + * the default. * @max_transfer_size: The maximum transfer size supported, in bytes - * 2047 to 65,535 (default 65,535) + * 2047 to 65,535 + * Actual maximum value is autodetected and also + * the default. * @max_packet_count: The maximum number of packets in a transfer - * 15 to 511 (default 511) + * 15 to 511 + * Actual maximum value is autodetected and also + * the default. * @host_channels: The number of host channel registers to use - * 1 to 16 (default 12) + * 1 to 16 + * Actual maximum value is autodetected and also + * the default. * @phy_type: Specifies the type of PHY interface to use. By default, * the driver will automatically detect the phy_type. + * 0 - Full Speed Phy + * 1 - UTMI+ Phy + * 2 - ULPI Phy + * Defaults to best available option (2, 1, then 0) * @phy_utmi_width: Specifies the UTMI+ Data Width (in bits). This parameter * is applicable for a phy_type of UTMI+ or ULPI. (For a * ULPI phy_type, this parameter indicates the data width @@ -122,7 +139,7 @@ enum dwc2_lx_state { * parameter was set to "8 and 16 bits", meaning that the * core has been configured to work at either data path * width. - * 8 or 16 (default 16) + * 8 or 16 (default 16 if available) * @phy_ulpi_ddr: Specifies whether the ULPI operates at double or single * data rate. This parameter is only applicable if phy_type * is ULPI. @@ -132,35 +149,51 @@ enum dwc2_lx_state { * data bus * @phy_ulpi_ext_vbus: For a ULPI phy, specifies whether to use the internal or * external supply to drive the VBus + * 0 - Internal supply (default) + * 1 - External supply * @i2c_enable: Specifies whether to use the I2Cinterface for a full * speed PHY. This parameter is only applicable if phy_type * is FS. * 0 - No (default) * 1 - Yes - * @ulpi_fs_ls: True to make ULPI phy operate in FS/LS mode only + * @ulpi_fs_ls: Make ULPI phy operate in FS/LS mode only + * 0 - No (default) + * 1 - Yes * @host_support_fs_ls_low_power: Specifies whether low power mode is supported * when attached to a Full Speed or Low Speed device in * host mode. * 0 - Don't support low power mode (default) * 1 - Support low power mode * @host_ls_low_power_phy_clk: Specifies the PHY clock rate in low power mode - * when connected to a Low Speed device in host mode. This - * parameter is applicable only if - * host_support_fs_ls_low_power is enabled. If phy_type is - * set to FS then defaults to 6 MHZ otherwise 48 MHZ. + * when connected to a Low Speed device in host + * mode. This parameter is applicable only if + * host_support_fs_ls_low_power is enabled. * 0 - 48 MHz + * (default when phy_type is UTMI+ or ULPI) * 1 - 6 MHz - * @ts_dline: True to enable Term Select Dline pulsing - * @reload_ctl: True to allow dynamic reloading of HFIR register during - * runtime + * (default when phy_type is Full Speed) + * @ts_dline: Enable Term Select Dline pulsing + * 0 - No (default) + * 1 - Yes + * @reload_ctl: Allow dynamic reloading of HFIR register during runtime + * 0 - No (default for core < 2.92a) + * 1 - Yes (default for core >= 2.92a) * @ahbcfg: This field allows the default value of the GAHBCFG * register to be overridden - * -1 - GAHBCFG value will not be overridden + * -1 - GAHBCFG value will be set to 0x06 + * (INCR4, default) * all others - GAHBCFG value will be overridden with * this value + * Not all bits can be controlled like this, the + * bits defined by GAHBCFG_CTRL_MASK are controlled + * by the driver and are ignored in this + * configuration value. * * The following parameters may be specified when starting the module. These - * parameters define how the DWC_otg controller should be configured. + * parameters define how the DWC_otg controller should be configured. A + * value of -1 (or any other out of range value) for any parameter means + * to read the value from hardware (if possible) or use the builtin + * default described above. */ struct dwc2_core_params { /* -- GitLab